---

 /dev/null                                     |33935 --------------------------
 CREDITS                                       |    2 
 Documentation/DocBook/kernel-locking.tmpl     |    7 
 Documentation/SubmittingPatches               |   14 
 Documentation/devices.txt                     |   12 
 Documentation/fb/modedb.txt                   |    1 
 Documentation/fb/tridentfb.txt                |   11 
 Documentation/filesystems/ntfs.txt            |    3 
 Documentation/i2c/porting-clients             |    5 
 Documentation/i386/zero-page.txt              |    7 
 Documentation/kernel-parameters.txt           |   53 
 Documentation/m68k/00-INDEX                   |    2 
 Documentation/networking/ip-sysctl.txt        |    7 
 Documentation/networking/sk98lin.txt          |    6 
 Documentation/power/swsusp.txt                |  104 
 Documentation/power/video.txt                 |   36 
 Documentation/s390/driver-model.txt           |   26 
 Documentation/scsi/qla2xxx.revision.notes     |  457 
 Documentation/sh/kgdb.txt                     |  179 
 Documentation/sh/new-machine.txt              |  259 
 Documentation/sysctl/kernel.txt               |   19 
 MAINTAINERS                                   |   49 
 arch/alpha/Kconfig                            |    1 
 arch/alpha/kernel/module.c                    |    2 
 arch/alpha/mm/extable.c                       |    5 
 arch/arm/mm/extable.c                         |   21 
 arch/arm26/mm/extable.c                       |   21 
 arch/cris/arch-v10/drivers/ds1302.c           |    1 
 arch/cris/arch-v10/drivers/pcf8563.c          |    1 
 arch/cris/mm/Makefile                         |    2 
 arch/h8300/mm/Makefile                        |    2 
 arch/i386/Kconfig                             |    1 
 arch/i386/kernel/acpi/wakeup.S                |    9 
 arch/i386/kernel/cpu/cpufreq/Kconfig          |   10 
 arch/i386/kernel/cpu/cpufreq/p4-clockmod.c    |   55 
 arch/i386/kernel/cpu/cpufreq/speedstep-lib.c  |   23 
 arch/i386/kernel/cpu/cpufreq/speedstep-lib.h  |    6 
 arch/i386/kernel/cpu/intel.c                  |   31 
 arch/i386/kernel/dmi_scan.c                   |   10 
 arch/i386/kernel/efi.c                        |    4 
 arch/i386/kernel/time.c                       |   24 
 arch/i386/kernel/time_hpet.c                  |    4 
 arch/i386/mach-voyager/voyager_smp.c          |   12 
 arch/i386/mm/extable.c                        |   22 
 arch/ia64/Kconfig                             |   33 
 arch/ia64/Makefile                            |   17 
 arch/ia64/configs/generic_defconfig           | 1045 
 arch/ia64/configs/sn2_defconfig               |   65 
 arch/ia64/hp/common/sba_iommu.c               |  494 
 arch/ia64/ia32/sys_ia32.c                     |    2 
 arch/ia64/kernel/acpi.c                       |    3 
 arch/ia64/kernel/efi.c                        |    3 
 arch/ia64/kernel/ia64_ksyms.c                 |  132 
 arch/ia64/kernel/irq.c                        |    5 
 arch/ia64/kernel/irq_ia64.c                   |    2 
 arch/ia64/kernel/machvec.c                    |    4 
 arch/ia64/kernel/perfmon.c                    |   60 
 arch/ia64/kernel/process.c                    |    1 
 arch/ia64/kernel/setup.c                      |   13 
 arch/ia64/kernel/smp.c                        |    4 
 arch/ia64/kernel/smpboot.c                    |   13 
 arch/ia64/kernel/time.c                       |    1 
 arch/ia64/kernel/unwind.c                     |    9 
 arch/ia64/lib/Makefile                        |    4 
 arch/ia64/lib/io.c                            |    4 
 arch/ia64/lib/memcpy_mck.S                    |    6 
 arch/ia64/lib/memset.S                        |    6 
 arch/ia64/mm/extable.c                        |    5 
 arch/ia64/mm/init.c                           |   10 
 arch/ia64/mm/numa.c                           |    3 
 arch/ia64/mm/tlb.c                            |    3 
 arch/ia64/pci/pci.c                           |    3 
 arch/ia64/scripts/check-text-align.S          |    6 
 arch/ia64/scripts/unwcheck.py                 |   64 
 arch/ia64/sn/Makefile                         |    2 
 arch/ia64/sn/fakeprom/README                  |   32 
 arch/ia64/sn/fakeprom/fprom.lds               |   32 
 arch/ia64/sn/io/Makefile                      |    4 
 arch/ia64/sn/io/cdl.c                         |   16 
 arch/ia64/sn/io/drivers/Makefile              |    2 
 arch/ia64/sn/io/drivers/ioconfig_bus.c        |  110 
 arch/ia64/sn/io/hwgfs/Makefile                |    2 
 arch/ia64/sn/io/hwgfs/hcl.c                   |  250 
 arch/ia64/sn/io/hwgfs/hcl_util.c              |   67 
 arch/ia64/sn/io/hwgfs/interface.c             |   36 
 arch/ia64/sn/io/hwgfs/labelcl.c               |    1 
 arch/ia64/sn/io/hwgfs/ramfs.c                 |   32 
 arch/ia64/sn/io/io.c                          |   44 
 arch/ia64/sn/io/machvec/Makefile              |    2 
 arch/ia64/sn/io/machvec/pci.c                 |   21 
 arch/ia64/sn/io/machvec/pci_bus_cvlink.c      |  359 
 arch/ia64/sn/io/machvec/pci_dma.c             |  125 
 arch/ia64/sn/io/platform_init/Makefile        |    4 
 arch/ia64/sn/io/platform_init/sgi_io_init.c   |  131 
 arch/ia64/sn/io/sn2/Makefile                  |    2 
 arch/ia64/sn/io/sn2/bte_error.c               |   64 
 arch/ia64/sn/io/sn2/geo_op.c                  |    4 
 arch/ia64/sn/io/sn2/klconflib.c               |  179 
 arch/ia64/sn/io/sn2/klgraph.c                 |  478 
 arch/ia64/sn/io/sn2/l1_command.c              |   90 
 arch/ia64/sn/io/sn2/ml_SN_init.c              |   72 
 arch/ia64/sn/io/sn2/ml_SN_intr.c              |    5 
 arch/ia64/sn/io/sn2/ml_iograph.c              |  311 
 arch/ia64/sn/io/sn2/module.c                  |  136 
 arch/ia64/sn/io/sn2/pcibr/Makefile            |    9 
 arch/ia64/sn/io/sn2/pcibr/pcibr_ate.c         |   60 
 arch/ia64/sn/io/sn2/pcibr/pcibr_config.c      |   29 
 arch/ia64/sn/io/sn2/pcibr/pcibr_dvr.c         |  692 
 arch/ia64/sn/io/sn2/pcibr/pcibr_error.c       |  454 
 arch/ia64/sn/io/sn2/pcibr/pcibr_hints.c       |   32 
 arch/ia64/sn/io/sn2/pcibr/pcibr_intr.c        |  226 
 arch/ia64/sn/io/sn2/pcibr/pcibr_reg.c         |  107 
 arch/ia64/sn/io/sn2/pcibr/pcibr_rrb.c         |   70 
 arch/ia64/sn/io/sn2/pcibr/pcibr_slot.c        |  672 
 arch/ia64/sn/io/sn2/pciio.c                   |  504 
 arch/ia64/sn/io/sn2/pic.c                     |  106 
 arch/ia64/sn/io/sn2/shub.c                    |   50 
 arch/ia64/sn/io/sn2/shub_intr.c               |   96 
 arch/ia64/sn/io/sn2/shuberror.c               |   14 
 arch/ia64/sn/io/sn2/shubio.c                  |   22 
 arch/ia64/sn/io/sn2/xbow.c                    |  530 
 arch/ia64/sn/io/sn2/xtalk.c                   |   95 
 arch/ia64/sn/io/snia_if.c                     |  108 
 arch/ia64/sn/io/xswitch.c                     |   12 
 arch/ia64/sn/kernel/Makefile                  |    2 
 arch/ia64/sn/kernel/bte.c                     |   32 
 arch/ia64/sn/kernel/irq.c                     |  132 
 arch/ia64/sn/kernel/machvec.c                 |   32 
 arch/ia64/sn/kernel/mca.c                     |   32 
 arch/ia64/sn/kernel/probe.c                   |   32 
 arch/ia64/sn/kernel/setup.c                   |   88 
 arch/ia64/sn/kernel/sn2/Makefile              |    2 
 arch/ia64/sn/kernel/sn2/cache.c               |    5 
 arch/ia64/sn/kernel/sn2/sn2_smp.c             |   32 
 arch/ia64/sn/kernel/sn2/sn_proc_fs.c          |   31 
 arch/m68k/amiga/amisound.c                    |    2 
 arch/m68k/amiga/chipram.c                     |    4 
 arch/m68k/amiga/config.c                      |   24 
 arch/m68k/atari/hades-pci.c                   |   19 
 arch/m68k/bvme6000/rtc.c                      |   10 
 arch/m68k/kernel/head.S                       |  387 
 arch/m68k/kernel/traps.c                      |  210 
 arch/m68k/mac/config.c                        |    2 
 arch/m68k/mac/misc.c                          |   18 
 arch/m68k/math-emu/fp_arith.c                 |    5 
 arch/m68k/math-emu/fp_log.c                   |    2 
 arch/m68k/math-emu/multi_arith.h              |   87 
 arch/m68k/mm/Makefile                         |    2 
 arch/m68k/mm/hwtest.c                         |    4 
 arch/m68k/mm/motorola.c                       |    2 
 arch/m68k/mvme16x/rtc.c                       |    7 
 arch/m68k/q40/q40ints.c                       |   26 
 arch/m68k/sun3/idprom.c                       |   46 
 arch/m68knommu/kernel/Makefile                |    6 
 arch/m68knommu/kernel/module.c                |   99 
 arch/m68knommu/kernel/time.c                  |    8 
 arch/m68knommu/lib/checksum.c                 |    1 
 arch/m68knommu/mm/Makefile                    |    2 
 arch/m68knommu/platform/5307/entry.S          |    4 
 arch/mips/Kconfig                             |    1 
 arch/mips/mm/Makefile                         |    2 
 arch/parisc/Kconfig                           |    1 
 arch/parisc/kernel/sys_parisc.c               |    8 
 arch/parisc/mm/Makefile                       |    2 
 arch/ppc/Kconfig                              |    1 
 arch/ppc/boot/prep/Makefile                   |    3 
 arch/ppc/boot/prep/head.S                     |   26 
 arch/ppc/boot/prep/misc.c                     |   52 
 arch/ppc/kernel/Makefile                      |    3 
 arch/ppc/kernel/misc.S                        |    1 
 arch/ppc/kernel/module.c                      |    5 
 arch/ppc/kernel/ppc_ksyms.c                   |   32 
 arch/ppc/kernel/syscalls.c                    |    2 
 arch/ppc/mm/Makefile                          |    2 
 arch/ppc/mm/cachemap.c                        |    2 
 arch/ppc64/Kconfig                            |   35 
 arch/ppc64/Makefile                           |   22 
 arch/ppc64/boot/ppc32-types.h                 |    6 
 arch/ppc64/kernel/HvCall.c                    |  113 
 arch/ppc64/kernel/ItLpQueue.c                 |   17 
 arch/ppc64/kernel/LparData.c                  |   52 
 arch/ppc64/kernel/Makefile                    |   30 
 arch/ppc64/kernel/XmPciLpEvent.c              |  126 
 arch/ppc64/kernel/asm-offsets.c               |    6 
 arch/ppc64/kernel/chrp_setup.c                |   88 
 arch/ppc64/kernel/cputable.c                  |   36 
 arch/ppc64/kernel/eeh.c                       |    2 
 arch/ppc64/kernel/entry.S                     |  119 
 arch/ppc64/kernel/head.S                      |  262 
 arch/ppc64/kernel/iSeries_IoMmTable.c         |  182 
 arch/ppc64/kernel/iSeries_IoMmTable.h         |   88 
 arch/ppc64/kernel/iSeries_VpdInfo.c           |  342 
 arch/ppc64/kernel/iSeries_htab.c              |  197 
 arch/ppc64/kernel/iSeries_irq.c               |  284 
 arch/ppc64/kernel/iSeries_pci.c               | 1285 
 arch/ppc64/kernel/iSeries_pci_reset.c         |   67 
 arch/ppc64/kernel/iSeries_proc.c              |   61 
 arch/ppc64/kernel/iSeries_setup.c             |  653 
 arch/ppc64/kernel/iSeries_setup.h             |   39 
 arch/ppc64/kernel/idle.c                      |  191 
 arch/ppc64/kernel/irq.c                       |   45 
 arch/ppc64/kernel/lparcfg.c                   |  478 
 arch/ppc64/kernel/mf.c                        | 1159 
 arch/ppc64/kernel/mf_proc.c                   |  292 
 arch/ppc64/kernel/misc.S                      |  137 
 arch/ppc64/kernel/module.c                    |    4 
 arch/ppc64/kernel/nvram.c                     |  684 
 arch/ppc64/kernel/open_pic.c                  |   34 
 arch/ppc64/kernel/pSeries_htab.c              |   29 
 arch/ppc64/kernel/pSeries_hvCall.S            |   74 
 arch/ppc64/kernel/pSeries_lpar.c              |  133 
 arch/ppc64/kernel/pSeries_pci.c               |  171 
 arch/ppc64/kernel/pci.c                       |   23 
 arch/ppc64/kernel/pci_dma.c                   |   15 
 arch/ppc64/kernel/pci_dn.c                    |    4 
 arch/ppc64/kernel/ppc_ksyms.c                 |   15 
 arch/ppc64/kernel/proc_pmc.c                  |   24 
 arch/ppc64/kernel/proc_ppc64.c                |  263 
 arch/ppc64/kernel/process.c                   |  105 
 arch/ppc64/kernel/prom.c                      |  895 
 arch/ppc64/kernel/ras.c                       |   39 
 arch/ppc64/kernel/rtas-proc.c                 |   56 
 arch/ppc64/kernel/rtas.c                      |  138 
 arch/ppc64/kernel/rtas_flash.c                |  595 
 arch/ppc64/kernel/rtasd.c                     |  286 
 arch/ppc64/kernel/rtc.c                       |    1 
 arch/ppc64/kernel/scanlog.c                   |   13 
 arch/ppc64/kernel/setup.c                     |  134 
 arch/ppc64/kernel/signal.c                    |  186 
 arch/ppc64/kernel/signal32.c                  | 1140 
 arch/ppc64/kernel/smp.c                       |  110 
 arch/ppc64/kernel/sys_ppc32.c                 |  194 
 arch/ppc64/kernel/syscalls.c                  |    4 
 arch/ppc64/kernel/time.c                      |   30 
 arch/ppc64/kernel/traps.c                     |   33 
 arch/ppc64/kernel/udbg.c                      |    4 
 arch/ppc64/kernel/vio.c                       |  536 
 arch/ppc64/kernel/viopath.c                   |  757 
 arch/ppc64/kernel/vmlinux.lds.S               |  231 
 arch/ppc64/kernel/xics.c                      |   22 
 arch/ppc64/mm/Makefile                        |    2 
 arch/ppc64/mm/hash_low.S                      |  283 
 arch/ppc64/mm/hash_utils.c                    |  358 
 arch/ppc64/mm/hugetlbpage.c                   |   10 
 arch/ppc64/mm/imalloc.c                       |  247 
 arch/ppc64/mm/init.c                          |  277 
 arch/ppc64/mm/numa.c                          |   27 
 arch/ppc64/xmon/xmon.c                        |   38 
 arch/s390/Kconfig                             |    2 
 arch/s390/defconfig                           |   30 
 arch/s390/kernel/compat_ioctl.c               |  891 
 arch/s390/kernel/compat_linux.c               |  153 
 arch/s390/kernel/compat_linux.h               |   18 
 arch/s390/kernel/compat_signal.c              |    3 
 arch/s390/kernel/compat_wrapper.S             |   77 
 arch/s390/kernel/entry.S                      |    6 
 arch/s390/kernel/entry64.S                    |   15 
 arch/s390/kernel/head.S                       |   14 
 arch/s390/kernel/head64.S                     |   14 
 arch/s390/kernel/ptrace.c                     |   37 
 arch/s390/kernel/semaphore.c                  |   12 
 arch/s390/kernel/setup.c                      |    7 
 arch/s390/kernel/signal.c                     |    3 
 arch/s390/kernel/sys_s390.c                   |   36 
 arch/s390/kernel/syscalls.S                   |   23 
 arch/s390/kernel/traps.c                      |    8 
 arch/s390/kernel/vmlinux.lds.S                |    3 
 arch/s390/lib/uaccess.S                       |   35 
 arch/s390/lib/uaccess64.S                     |   35 
 arch/s390/mm/Makefile                         |    2 
 arch/s390/mm/fault.c                          |   34 
 arch/sh/Kconfig                               |  503 
 arch/sh/Makefile                              |   67 
 arch/sh/boards/adx/Makefile                   |    2 
 arch/sh/boards/adx/setup.c                    |   34 
 arch/sh/boards/bigsur/Makefile                |    4 
 arch/sh/boards/bigsur/io.c                    |  184 
 arch/sh/boards/bigsur/setup.c                 |   40 
 arch/sh/boards/cat68701/Makefile              |    2 
 arch/sh/boards/cat68701/setup.c               |   47 
 arch/sh/boards/cqreek/Makefile                |    2 
 arch/sh/boards/cqreek/setup.c                 |   36 
 arch/sh/boards/dmida/mach.c                   |   14 
 arch/sh/boards/dreamcast/Makefile             |    4 
 arch/sh/boards/dreamcast/setup.c              |   23 
 arch/sh/boards/ec3104/Makefile                |    2 
 arch/sh/boards/ec3104/setup.c                 |   33 
 arch/sh/boards/harp/mach.c                    |   14 
 arch/sh/boards/hp6xx/hp620/mach.c             |   12 
 arch/sh/boards/hp6xx/hp680/mach.c             |   12 
 arch/sh/boards/hp6xx/hp690/mach.c             |   12 
 arch/sh/boards/mpc1211/Makefile               |    2 
 arch/sh/boards/mpc1211/pci.c                  |    5 
 arch/sh/boards/mpc1211/rtc.c                  |    7 
 arch/sh/boards/mpc1211/setup.c                |   72 
 arch/sh/boards/overdrive/mach.c               |   12 
 arch/sh/boards/saturn/Makefile                |    2 
 arch/sh/boards/saturn/irq.c                   |    7 
 arch/sh/boards/saturn/setup.c                 |   21 
 arch/sh/boards/saturn/smp.c                   |    4 
 arch/sh/boards/se/770x/io.c                   |   32 
 arch/sh/boards/se/770x/mach.c                 |   10 
 arch/sh/boards/se/7751/io.c                   |   60 
 arch/sh/boards/se/7751/mach.c                 |   14 
 arch/sh/boards/se/7751/pci.c                  |   29 
 arch/sh/boards/sh2000/Makefile                |    2 
 arch/sh/boards/sh2000/setup.c                 |   25 
 arch/sh/boards/snapgear/Makefile              |   10 
 arch/sh/boards/snapgear/io.c                  |  226 
 arch/sh/boards/snapgear/rtc.c                 |  333 
 arch/sh/boards/snapgear/setup.c               |  220 
 arch/sh/boards/systemh/Makefile               |   17 
 arch/sh/boards/systemh/io.c                   |  283 
 arch/sh/boards/systemh/irq.c                  |  111 
 arch/sh/boards/systemh/setup.c                |   80 
 arch/sh/boot/compressed/Makefile              |    4 
 arch/sh/boot/compressed/head.S                |   51 
 arch/sh/boot/compressed/vmlinux.scr           |    9 
 arch/sh/cchips/Kconfig                        |   76 
 arch/sh/cchips/hd6446x/hd64461/io.c           |   37 
 arch/sh/cchips/hd6446x/hd64461/setup.c        |   20 
 arch/sh/cchips/hd6446x/hd64465/io.c           |   37 
 arch/sh/cchips/hd6446x/hd64465/setup.c        |   22 
 arch/sh/configs/defconfig-adx                 |    6 
 arch/sh/configs/defconfig-cqreek              |    6 
 arch/sh/configs/defconfig-dreamcast           |  531 
 arch/sh/configs/defconfig-se7751              |  617 
 arch/sh/configs/defconfig-snapgear            |  540 
 arch/sh/configs/defconfig-systemh             |  372 
 arch/sh/drivers/Makefile                      |    7 
 arch/sh/drivers/dma/Kconfig                   |   42 
 arch/sh/drivers/dma/Makefile                  |    8 
 arch/sh/drivers/dma/dma-api.c                 |  193 
 arch/sh/drivers/dma/dma-g2.c                  |  173 
 arch/sh/drivers/dma/dma-isa.c                 |   93 
 arch/sh/drivers/dma/dma-pvr2.c                |  111 
 arch/sh/drivers/dma/dma-sh.c                  |  271 
 arch/sh/drivers/dma/dma-sh.h                  |   48 
 arch/sh/drivers/pci/Kconfig                   |   46 
 arch/sh/drivers/pci/Makefile                  |   16 
 arch/sh/drivers/pci/dma-dreamcast.c           |   61 
 arch/sh/drivers/pci/fixups-dreamcast.c        |   85 
 arch/sh/drivers/pci/ops-bigsur.c              |   88 
 arch/sh/drivers/pci/ops-dreamcast.c           |  169 
 arch/sh/drivers/pci/ops-snapgear.c            |  100 
 arch/sh/drivers/pci/pci-auto.c                |  534 
 arch/sh/drivers/pci/pci-dma.c                 |   42 
 arch/sh/drivers/pci/pci-sh7751.c              |  414 
 arch/sh/drivers/pci/pci-sh7751.h              |  296 
 arch/sh/drivers/pci/pci-st40.c                |  423 
 arch/sh/drivers/pci/pci-st40.h                |   66 
 arch/sh/drivers/pci/pci.c                     |  153 
 arch/sh/kernel/Makefile                       |    6 
 arch/sh/kernel/cpu/Makefile                   |    3 
 arch/sh/kernel/cpu/init.c                     |  214 
 arch/sh/kernel/cpu/sh3/Makefile               |    2 
 arch/sh/kernel/cpu/sh3/ex.S                   |  124 
 arch/sh/kernel/cpu/sh4/Makefile               |    9 
 arch/sh/kernel/cpu/sh4/ex.S                   |  316 
 arch/sh/kernel/cpu/sh4/fpu.c                  |   21 
 arch/sh/kernel/cpu/sh4/sq.c                   |  484 
 arch/sh/kernel/entry.S                        |  441 
 arch/sh/kernel/head.S                         |    6 
 arch/sh/kernel/io.c                           |  185 
 arch/sh/kernel/irq.c                          |  114 
 arch/sh/kernel/kgdb_stub.c                    |    8 
 arch/sh/kernel/module.c                       |    4 
 arch/sh/kernel/process.c                      |  101 
 arch/sh/kernel/ptrace.c                       |  165 
 arch/sh/kernel/setup.c                        |  296 
 arch/sh/kernel/sh_bios.c                      |    2 
 arch/sh/kernel/sh_ksyms.c                     |    4 
 arch/sh/kernel/signal.c                       |   82 
 arch/sh/kernel/smp.c                          |  207 
 arch/sh/kernel/sys_sh.c                       |   40 
 arch/sh/kernel/time.c                         |   69 
 arch/sh/kernel/traps.c                        |  132 
 arch/sh/lib/Makefile                          |    3 
 arch/sh/lib/div64-generic.c                   |   19 
 arch/sh/lib/div64.S                           |    4 
 arch/sh/lib/udivdi3.c                         |    4 
 arch/sh/mm/Makefile                           |   10 
 arch/sh/mm/cache-sh3.c                        |    8 
 arch/sh/mm/cache-sh4.c                        |   79 
 arch/sh/mm/clear_page.S                       |    8 
 arch/sh/mm/copy_page.S                        |    8 
 arch/sh/mm/extable.c                          |   23 
 arch/sh/mm/fault.c                            |   58 
 arch/sh/mm/init.c                             |  106 
 arch/sh/mm/ioremap.c                          |    7 
 arch/sh/mm/pg-dma.c                           |   97 
 arch/sh/mm/pg-nommu.c                         |   36 
 arch/sh/mm/tlb-sh3.c                          |   12 
 arch/sh/oprofile/Kconfig                      |   23 
 arch/sh/oprofile/Makefile                     |   13 
 arch/sh/oprofile/op_model_null.c              |   23 
 arch/sh/tools/mach-types                      |    2 
 arch/sparc/Kconfig                            |    1 
 arch/sparc/kernel/irq.c                       |   19 
 arch/sparc/mm/extable.c                       |    5 
 arch/sparc/mm/fault.c                         |    1 
 arch/sparc/mm/srmmu.c                         |    6 
 arch/sparc64/Kconfig                          |   17 
 arch/sparc64/defconfig                        |    6 
 arch/sparc64/kernel/head.S                    |    6 
 arch/sparc64/kernel/pci_common.c              |   13 
 arch/sparc64/mm/extable.c                     |    5 
 arch/sparc64/prom/bootstr.c                   |    4 
 arch/um/Kconfig                               |    1 
 arch/x86_64/Kconfig                           |    1 
 arch/x86_64/mm/extable.c                      |    8 
 drivers/Kconfig                               |    2 
 drivers/acorn/char/i2c.c                      |    1 
 drivers/atm/atmdev_init.c                     |    6 
 drivers/atm/nicstar.c                         |  253 
 drivers/base/Makefile                         |    2 
 drivers/base/class.c                          |   14 
 drivers/base/class_simple.c                   |  201 
 drivers/base/core.c                           |    9 
 drivers/block/Kconfig                         |    2 
 drivers/block/as-iosched.c                    |  351 
 drivers/block/elevator.c                      |    1 
 drivers/block/floppy.c                        |    3 
 drivers/block/floppy98.c                      |    3 
 drivers/block/ll_rw_blk.c                     |   29 
 drivers/block/loop.c                          |   34 
 drivers/bluetooth/Kconfig                     |   47 
 drivers/bluetooth/Makefile                    |    2 
 drivers/bluetooth/bcm203x.c                   |  309 
 drivers/bluetooth/bfusb.c                     |  782 
 drivers/bluetooth/bluecard_cs.c               |   42 
 drivers/bluetooth/bt3c_cs.c                   |   55 
 drivers/bluetooth/btuart_cs.c                 |   55 
 drivers/bluetooth/dtl1_cs.c                   |   53 
 drivers/bluetooth/hci_usb.c                   |   62 
 drivers/bluetooth/hci_usb.h                   |    9 
 drivers/cdrom/cdrom.c                         |  373 
 drivers/char/Kconfig                          |    2 
 drivers/char/efirtc.c                         |    1 
 drivers/char/genrtc.c                         |  107 
 drivers/char/hp600_keyb.c                     |    1 
 drivers/char/keyboard.c                       |    2 
 drivers/char/lp.c                             |    6 
 drivers/char/mem.c                            |    7 
 drivers/char/misc.c                           |   17 
 drivers/char/pcmcia/synclink_cs.c             |   38 
 drivers/char/raw.c                            |   45 
 drivers/char/rtc.c                            |    3 
 drivers/char/sh-sci.c                         |  471 
 drivers/char/sh-sci.h                         |   56 
 drivers/char/sn_serial.c                      |   17 
 drivers/char/sysrq.c                          |    6 
 drivers/char/tty_io.c                         |   91 
 drivers/char/vt.c                             |   11 
 drivers/char/watchdog/acquirewdt.c            |   48 
 drivers/char/watchdog/advantechwdt.c          |    2 
 drivers/char/watchdog/alim1535_wdt.c          |    4 
 drivers/char/watchdog/alim7101_wdt.c          |    2 
 drivers/char/watchdog/amd7xx_tco.c            |   83 
 drivers/char/watchdog/cpu5wdt.c               |   34 
 drivers/char/watchdog/eurotechwdt.c           |   94 
 drivers/char/watchdog/i810-tco.c              |   38 
 drivers/char/watchdog/ib700wdt.c              |   64 
 drivers/char/watchdog/indydog.c               |   19 
 drivers/char/watchdog/machzwd.c               |  148 
 drivers/char/watchdog/mixcomwd.c              |   51 
 drivers/char/watchdog/pcwd.c                  |   79 
 drivers/char/watchdog/sa1100_wdt.c            |    1 
 drivers/char/watchdog/sbc60xxwdt.c            |    2 
 drivers/char/watchdog/sc1200wdt.c             |   18 
 drivers/char/watchdog/scx200_wdt.c            |   58 
 drivers/char/watchdog/shwdt.c                 |   14 
 drivers/char/watchdog/softdog.c               |   29 
 drivers/char/watchdog/w83627hf_wdt.c          |    2 
 drivers/char/watchdog/w83877f_wdt.c           |    2 
 drivers/char/watchdog/wafer5823wdt.c          |    4 
 drivers/char/watchdog/wdt.c                   |  119 
 drivers/char/watchdog/wdt285.c                |   12 
 drivers/char/watchdog/wdt977.c                |   15 
 drivers/char/watchdog/wdt_pci.c               |  107 
 drivers/i2c/Kconfig                           |   32 
 drivers/i2c/algos/Kconfig                     |    1 
 drivers/i2c/algos/i2c-algo-pcf.h              |    2 
 drivers/i2c/busses/Kconfig                    |   89 
 drivers/i2c/busses/Makefile                   |    2 
 drivers/i2c/busses/i2c-ali1535.c              |    5 
 drivers/i2c/busses/i2c-ali15x3.c              |    5 
 drivers/i2c/busses/i2c-amd756.c               |    5 
 drivers/i2c/busses/i2c-amd8111.c              |    5 
 drivers/i2c/busses/i2c-elektor.c              |   19 
 drivers/i2c/busses/i2c-elv.c                  |   17 
 drivers/i2c/busses/i2c-frodo.c                |    5 
 drivers/i2c/busses/i2c-i801.c                 |    5 
 drivers/i2c/busses/i2c-i810.c                 |    5 
 drivers/i2c/busses/i2c-ibm_iic.c              |    8 
 drivers/i2c/busses/i2c-iop3xx.c               |    9 
 drivers/i2c/busses/i2c-isa.c                  |    5 
 drivers/i2c/busses/i2c-ite.c                  |   24 
 drivers/i2c/busses/i2c-keywest.c              |   36 
 drivers/i2c/busses/i2c-nforce2.c              |    5 
 drivers/i2c/busses/i2c-parport-light.c        |  179 
 drivers/i2c/busses/i2c-parport.c              |  271 
 drivers/i2c/busses/i2c-parport.h              |   87 
 drivers/i2c/busses/i2c-philips-par.c          |    7 
 drivers/i2c/busses/i2c-piix4.c                |   12 
 drivers/i2c/busses/i2c-prosavage.c            |    5 
 drivers/i2c/busses/i2c-rpx.c                  |    9 
 drivers/i2c/busses/i2c-savage4.c              |    5 
 drivers/i2c/busses/i2c-sis5595.c              |   10 
 drivers/i2c/busses/i2c-sis630.c               |    5 
 drivers/i2c/busses/i2c-sis96x.c               |    5 
 drivers/i2c/busses/i2c-velleman.c             |   12 
 drivers/i2c/busses/i2c-via.c                  |    5 
 drivers/i2c/busses/i2c-viapro.c               |    5 
 drivers/i2c/busses/i2c-voodoo3.c              |    5 
 drivers/i2c/busses/scx200_acb.c               |   15 
 drivers/i2c/busses/scx200_i2c.c               |   10 
 drivers/i2c/chips/Kconfig                     |   36 
 drivers/i2c/chips/Makefile                    |    5 
 drivers/i2c/chips/adm1021.c                   |    5 
 drivers/i2c/chips/asb100.c                    | 1055 
 drivers/i2c/chips/eeprom.c                    |   67 
 drivers/i2c/chips/it87.c                      |   13 
 drivers/i2c/chips/lm75.c                      |    5 
 drivers/i2c/chips/lm78.c                      |    7 
 drivers/i2c/chips/lm83.c                      |    7 
 drivers/i2c/chips/lm85.c                      |    5 
 drivers/i2c/chips/lm90.c                      |  525 
 drivers/i2c/chips/via686a.c                   |    5 
 drivers/i2c/chips/w83781d.c                   |   37 
 drivers/i2c/chips/w83l785ts.c                 |  314 
 drivers/i2c/i2c-core.c                        |  112 
 drivers/i2c/i2c-dev.c                         |   10 
 drivers/i2c/i2c-sensor.c                      |    5 
 drivers/ide/Kconfig                           |   24 
 drivers/ide/ide-cd.c                          |  215 
 drivers/ide/ide-cd.h                          |   11 
 drivers/ide/ide-disk.c                        |   39 
 drivers/ide/ide-taskfile.c                    |   25 
 drivers/ide/ide.c                             |    6 
 drivers/ide/legacy/buddha.c                   |    4 
 drivers/ide/legacy/gayle.c                    |   25 
 drivers/ide/legacy/ide-cs.c                   |   57 
 drivers/ide/legacy/pdc4030.c                  |   18 
 drivers/ide/pci/pdc202xx_old.c                |   71 
 drivers/ide/pci/sgiioc4.c                     |   23 
 drivers/ide/pci/siimage.c                     |   21 
 drivers/ieee1394/Kconfig                      |    9 
 drivers/ieee1394/amdtp.c                      |   32 
 drivers/ieee1394/cmp.c                        |   38 
 drivers/ieee1394/csr.c                        |   93 
 drivers/ieee1394/dv1394.c                     |   43 
 drivers/ieee1394/eth1394.c                    |   43 
 drivers/ieee1394/highlevel.c                  |  146 
 drivers/ieee1394/highlevel.h                  |   23 
 drivers/ieee1394/hosts.c                      |    2 
 drivers/ieee1394/hosts.h                      |    2 
 drivers/ieee1394/ieee1394_core.c              |  184 
 drivers/ieee1394/ieee1394_core.h              |   32 
 drivers/ieee1394/ohci1394.c                   |   49 
 drivers/ieee1394/oui.db                       | 2927 +-
 drivers/ieee1394/raw1394.c                    |   24 
 drivers/ieee1394/sbp2.c                       |   25 
 drivers/ieee1394/video1394.c                  |   57 
 drivers/input/evdev.c                         |    4 
 drivers/input/input.c                         |    8 
 drivers/input/joydev.c                        |    4 
 drivers/input/keyboard/atkbd.c                |   38 
 drivers/input/keyboard/maple_keyb.c           |    1 
 drivers/input/keyboard/newtonkbd.c            |    2 
 drivers/input/mouse/98busmouse.c              |   21 
 drivers/input/mouse/Kconfig                   |    2 
 drivers/input/mouse/inport.c                  |   19 
 drivers/input/mouse/logibm.c                  |   17 
 drivers/input/mouse/psmouse-base.c            |   30 
 drivers/input/mouse/synaptics.c               |   11 
 drivers/input/mousedev.c                      |  117 
 drivers/input/serio/i8042.c                   |  100 
 drivers/input/tsdev.c                         |   27 
 drivers/isdn/Makefile                         |    1 
 drivers/isdn/hardware/Kconfig                 |    2 
 drivers/isdn/hardware/avm/avm_cs.c            |   56 
 drivers/isdn/hardware/eicon/capifunc.c        |    4 
 drivers/isdn/hardware/eicon/divamnt.c         |   10 
 drivers/isdn/hardware/eicon/mntfunc.c         |   15 
 drivers/isdn/hardware/eicon/platform.h        |    4 
 drivers/isdn/hardware/eicon/s_bri.c           |    2 
 drivers/isdn/hardware/eicon/um_idi.c          |    4 
 drivers/isdn/hardware/eicon/xdi_adapter.h     |    4 
 drivers/isdn/hisax/avma1_cs.c                 |   56 
 drivers/isdn/hisax/elsa_cs.c                  |   48 
 drivers/isdn/hisax/sedlbauer_cs.c             |   57 
 drivers/macintosh/adb-iop.c                   |   34 
 drivers/macintosh/via-macii.c                 |    2 
 drivers/media/Kconfig                         |   17 
 drivers/media/common/Makefile                 |    2 
 drivers/media/common/ir-common.c              |  218 
 drivers/media/video/Kconfig                   |   13 
 drivers/media/video/Makefile                  |    5 
 drivers/media/video/bt848.h                   |    3 
 drivers/media/video/bttv-cards.c              |  582 
 drivers/media/video/bttv-driver.c             |  468 
 drivers/media/video/bttv-gpio.c               |  183 
 drivers/media/video/bttv-i2c.c                |  471 
 drivers/media/video/bttv-if.c                 |  447 
 drivers/media/video/bttv-risc.c               |   43 
 drivers/media/video/bttv-vbi.c                |    4 
 drivers/media/video/bttv.h                    |   66 
 drivers/media/video/bttvp.h                   |   51 
 drivers/media/video/cx88/Makefile             |    6 
 drivers/media/video/cx88/cx88-cards.c         |  396 
 drivers/media/video/cx88/cx88-core.c          |  612 
 drivers/media/video/cx88/cx88-i2c.c           |  172 
 drivers/media/video/cx88/cx88-reg.h           |  770 
 drivers/media/video/cx88/cx88-tvaudio.c       |  472 
 drivers/media/video/cx88/cx88-video.c         | 2246 +
 drivers/media/video/cx88/cx88.h               |  339 
 drivers/media/video/ir-kbd-gpio.c             |  379 
 drivers/media/video/ir-kbd-i2c.c              |  372 
 drivers/media/video/msp3400.c                 |   38 
 drivers/media/video/saa7134/Makefile          |    2 
 drivers/media/video/saa7134/saa6752hs.c       |   21 
 drivers/media/video/saa7134/saa7134-cards.c   |  392 
 drivers/media/video/saa7134/saa7134-core.c    |   29 
 drivers/media/video/saa7134/saa7134-input.c   |  218 
 drivers/media/video/saa7134/saa7134-oss.c     |   11 
 drivers/media/video/saa7134/saa7134-ts.c      |    6 
 drivers/media/video/saa7134/saa7134-tvaudio.c |  116 
 drivers/media/video/saa7134/saa7134-vbi.c     |    2 
 drivers/media/video/saa7134/saa7134-video.c   |   66 
 drivers/media/video/saa7134/saa7134.h         |   33 
 drivers/media/video/saa7146.h                 |    1 
 drivers/media/video/tda7432.c                 |    5 
 drivers/media/video/tda9875.c                 |    5 
 drivers/media/video/tda9887.c                 |   18 
 drivers/media/video/tuner.c                   |  539 
 drivers/media/video/tvaudio.c                 |   18 
 drivers/media/video/tvmixer.c                 |   27 
 drivers/media/video/v4l1-compat.c             |   43 
 drivers/media/video/v4l2-common.c             |   74 
 drivers/media/video/video-buf.c               |   65 
 drivers/media/video/videodev.c                |   33 
 drivers/message/fusion/mptbase.h              |    4 
 drivers/message/fusion/mptscsih.c             |    4 
 drivers/mtd/maps/pcmciamtd.c                  |   35 
 drivers/net/3c527.c                           |  382 
 drivers/net/3c527.h                           |    6 
 drivers/net/3c59x.c                           |    4 
 drivers/net/Kconfig                           |   23 
 drivers/net/Makefile                          |    1 
 drivers/net/dummy.c                           |   42 
 drivers/net/forcedeth.c                       | 1501 +
 drivers/net/hamradio/bpqether.c               |   25 
 drivers/net/irda/sir-dev.h                    |    1 
 drivers/net/irda/sir_dev.c                    |   62 
 drivers/net/irda/sir_kthread.c                |    9 
 drivers/net/natsemi.c                         |   39 
 drivers/net/ne2k-pci.c                        |    3 
 drivers/net/pcmcia/3c574_cs.c                 |   40 
 drivers/net/pcmcia/3c589_cs.c                 |   38 
 drivers/net/pcmcia/Kconfig                    |    2 
 drivers/net/pcmcia/axnet_cs.c                 |   49 
 drivers/net/pcmcia/com20020_cs.c              |   32 
 drivers/net/pcmcia/fmvj18x_cs.c               |   76 
 drivers/net/pcmcia/ibmtr_cs.c                 |   46 
 drivers/net/pcmcia/nmclan_cs.c                |   42 
 drivers/net/pcmcia/pcnet_cs.c                 |   69 
 drivers/net/pcmcia/smc91c92_cs.c              |   75 
 drivers/net/pcmcia/xirc2ps_cs.c               |   66 
 drivers/net/ppp_async.c                       |  104 
 drivers/net/pppoe.c                           |    6 
 drivers/net/sk98lin/Makefile                  |    2 
 drivers/net/sk98lin/h/skcsum.h                |   12 
 drivers/net/sk98lin/h/skdrv1st.h              |   30 
 drivers/net/sk98lin/h/skdrv2nd.h              |   57 
 drivers/net/sk98lin/h/skgehw.h                |  210 
 drivers/net/sk98lin/h/skgehwt.h               |   23 
 drivers/net/sk98lin/h/skgei2c.h               |   81 
 drivers/net/sk98lin/h/skgeinit.h              |   54 
 drivers/net/sk98lin/h/skgepnmi.h              |   63 
 drivers/net/sk98lin/h/ski2c.h                 |   28 
 drivers/net/sk98lin/h/skqueue.h               |   29 
 drivers/net/sk98lin/h/sktimer.h               |   39 
 drivers/net/sk98lin/h/sktypes.h               |   10 
 drivers/net/sk98lin/h/skversion.h             |   21 
 drivers/net/sk98lin/h/xmac_ii.h               |  122 
 drivers/net/sk98lin/skcsum.c                  |   14 
 drivers/net/sk98lin/skdim.c                   |   20 
 drivers/net/sk98lin/skge.c                    |  972 
 drivers/net/sk98lin/skgehwt.c                 |   86 
 drivers/net/sk98lin/skgeinit.c                |   86 
 drivers/net/sk98lin/skgemib.c                 |   54 
 drivers/net/sk98lin/skgepnmi.c                |  371 
 drivers/net/sk98lin/skgesirq.c                |   87 
 drivers/net/sk98lin/ski2c.c                   |  126 
 drivers/net/sk98lin/sklm80.c                  |   35 
 drivers/net/sk98lin/skproc.c                  |  569 
 drivers/net/sk98lin/skqueue.c                 |  121 
 drivers/net/sk98lin/sktimer.c                 |  153 
 drivers/net/sk98lin/skxmac2.c                 |  637 
 drivers/net/starfire.c                        |    1 
 drivers/net/stnic.c                           |    6 
 drivers/net/tokenring/olympic.c               |    9 
 drivers/net/tokenring/smctr.c                 |    8 
 drivers/net/wan/Kconfig                       |   15 
 drivers/net/wan/Makefile                      |    1 
 drivers/net/wan/farsync.c                     |    3 
 drivers/net/wan/hd64572.h                     |   92 
 drivers/net/wan/lapbether.c                   |   10 
 drivers/net/wan/pc300_drv.c                   |    2 
 drivers/net/wan/pci200syn.c                   |  475 
 drivers/net/wireless/Kconfig                  |    2 
 drivers/net/wireless/airo.c                   |   13 
 drivers/net/wireless/airo_cs.c                |   52 
 drivers/net/wireless/atmel.c                  |  523 
 drivers/net/wireless/atmel_cs.c               |   84 
 drivers/net/wireless/netwave_cs.c             |   37 
 drivers/net/wireless/orinoco_cs.c             |   54 
 drivers/net/wireless/orinoco_pci.c            |    1 
 drivers/net/wireless/ray_cs.c                 |   32 
 drivers/net/wireless/wavelan_cs.c             |   41 
 drivers/net/wireless/wl3501_cs.c              |   31 
 drivers/oprofile/oprofile_stats.c             |    1 
 drivers/parport/parport_cs.c                  |   45 
 drivers/pci/pci.ids                           |    2 
 drivers/pci/quirks.c                          |    1 
 drivers/pcmcia/cs.c                           |  144 
 drivers/s390/block/dasd.c                     |  255 
 drivers/s390/block/dasd_3990_erp.c            |    8 
 drivers/s390/block/dasd_devmap.c              |  233 
 drivers/s390/block/dasd_diag.c                |    4 
 drivers/s390/block/dasd_eckd.c                |   43 
 drivers/s390/block/dasd_fba.c                 |    7 
 drivers/s390/block/dasd_genhd.c               |   21 
 drivers/s390/block/dasd_int.h                 |   11 
 drivers/s390/block/dasd_proc.c                |   11 
 drivers/s390/char/Makefile                    |   12 
 drivers/s390/char/con3215.c                   |   92 
 drivers/s390/char/con3270.c                   |  639 
 drivers/s390/char/defkeymap.c                 |  156 
 drivers/s390/char/defkeymap.map               |  191 
 drivers/s390/char/fs3270.c                    |  373 
 drivers/s390/char/keyboard.c                  |  516 
 drivers/s390/char/keyboard.h                  |   57 
 drivers/s390/char/raw3270.c                   | 1256 
 drivers/s390/char/raw3270.h                   |  273 
 drivers/s390/char/sclp_con.c                  |    4 
 drivers/s390/char/sclp_rw.c                   |   16 
 drivers/s390/char/sclp_rw.h                   |    2 
 drivers/s390/char/sclp_tty.c                  |   38 
 drivers/s390/char/tape.h                      |   90 
 drivers/s390/char/tape_34xx.c                 |  657 
 drivers/s390/char/tape_block.c                |  453 
 drivers/s390/char/tape_char.c                 |  173 
 drivers/s390/char/tape_core.c                 |  496 
 drivers/s390/char/tape_proc.c                 |   14 
 drivers/s390/char/tape_std.c                  |  225 
 drivers/s390/char/tape_std.h                  |   12 
 drivers/s390/char/tty3270.c                   | 1828 +
 drivers/s390/cio/blacklist.c                  |  122 
 drivers/s390/cio/ccwgroup.c                   |   16 
 drivers/s390/cio/chsc.c                       |  476 
 drivers/s390/cio/chsc.h                       |   12 
 drivers/s390/cio/cio.c                        |   92 
 drivers/s390/cio/cio.h                        |    7 
 drivers/s390/cio/css.c                        |  301 
 drivers/s390/cio/css.h                        |   15 
 drivers/s390/cio/device.c                     |  183 
 drivers/s390/cio/device.h                     |    8 
 drivers/s390/cio/device_fsm.c                 |  390 
 drivers/s390/cio/device_id.c                  |   45 
 drivers/s390/cio/device_ops.c                 |   43 
 drivers/s390/cio/device_pgid.c                |  105 
 drivers/s390/cio/device_status.c              |    7 
 drivers/s390/cio/qdio.c                       |  107 
 drivers/s390/cio/qdio.h                       |   18 
 drivers/s390/net/ctcmain.c                    |   18 
 drivers/s390/net/ctctty.c                     |    3 
 drivers/s390/net/cu3088.c                     |   25 
 drivers/s390/net/fsm.c                        |    6 
 drivers/s390/net/iucv.c                       |   37 
 drivers/s390/net/iucv.h                       |    2 
 drivers/s390/net/lcs.c                        |   17 
 drivers/s390/net/netiucv.c                    |   16 
 drivers/s390/net/qeth.c                       |  226 
 drivers/s390/net/qeth.h                       |   12 
 drivers/s390/net/qeth_mpc.h                   |    8 
 drivers/s390/s390mach.c                       |   26 
 drivers/s390/scsi/zfcp_aux.c                  |  206 
 drivers/s390/scsi/zfcp_ccw.c                  |   14 
 drivers/s390/scsi/zfcp_def.h                  |   22 
 drivers/s390/scsi/zfcp_erp.c                  |  132 
 drivers/s390/scsi/zfcp_ext.h                  |   10 
 drivers/s390/scsi/zfcp_fsf.c                  |  122 
 drivers/s390/scsi/zfcp_fsf.h                  |    3 
 drivers/s390/scsi/zfcp_qdio.c                 |   52 
 drivers/s390/scsi/zfcp_scsi.c                 |  228 
 drivers/s390/scsi/zfcp_sysfs_adapter.c        |   12 
 drivers/s390/scsi/zfcp_sysfs_port.c           |   28 
 drivers/s390/scsi/zfcp_sysfs_unit.c           |   14 
 drivers/sbus/char/rtc.c                       |    1 
 drivers/scsi/53c7xx.c                         |    4 
 drivers/scsi/53c7xx.h                         |    4 
 drivers/scsi/Kconfig                          |   49 
 drivers/scsi/Makefile                         |    6 
 drivers/scsi/NCR53C9x.h                       |    3 
 drivers/scsi/aacraid/aachba.c                 |    1 
 drivers/scsi/aha152x.c                        |   83 
 drivers/scsi/aic7xxx/aic79xx_osm.c            |   12 
 drivers/scsi/aic7xxx/aic7xxx_osm.c            |   12 
 drivers/scsi/aic7xxx/aic7xxx_osm_pci.c        |    5 
 drivers/scsi/aic7xxx_old/aic7xxx_proc.c       |    4 
 drivers/scsi/amiga7xx.c                       |  155 
 drivers/scsi/atp870u.c                        |  669 
 drivers/scsi/atp870u.h                        |   54 
 drivers/scsi/bvme6000.c                       |    7 
 drivers/scsi/g_NCR5380.c                      |    9 
 drivers/scsi/ini9100u.c                       |   12 
 drivers/scsi/inia100.c                        |   36 
 drivers/scsi/ips.c                            |  178 
 drivers/scsi/ips.h                            |   34 
 drivers/scsi/mac_esp.c                        |  121 
 drivers/scsi/mac_scsi.c                       |  102 
 drivers/scsi/mvme16x.c                        |    3 
 drivers/scsi/nsp32.h                          |    5 
 drivers/scsi/nsp32_io.h                       |   10 
 drivers/scsi/pcmcia/aha152x_stub.c            |   42 
 drivers/scsi/pcmcia/fdomain_stub.c            |   42 
 drivers/scsi/pcmcia/nsp_cs.c                  |   58 
 drivers/scsi/pcmcia/nsp_cs.h                  |    2 
 drivers/scsi/pcmcia/qlogic_stub.c             |   44 
 drivers/scsi/qla1280.c                        | 1596 -
 drivers/scsi/qla1280.h                        |  127 
 drivers/scsi/qla2xxx/Kconfig                  |   29 
 drivers/scsi/qla2xxx/Makefile                 |   12 
 drivers/scsi/qla2xxx/ql2100.c                 |   92 
 drivers/scsi/qla2xxx/ql2100_fw.c              | 4858 +++
 drivers/scsi/qla2xxx/ql2200.c                 |   92 
 drivers/scsi/qla2xxx/ql2200_fw.c              | 5321 ++++
 drivers/scsi/qla2xxx/ql2300.c                 |  161 
 drivers/scsi/qla2xxx/ql2300_fw.c              | 6695 +++++
 drivers/scsi/qla2xxx/qla_dbg.c                | 1229 
 drivers/scsi/qla2xxx/qla_dbg.h                |  229 
 drivers/scsi/qla2xxx/qla_def.h                | 2371 +
 drivers/scsi/qla2xxx/qla_devtbl.h             |   65 
 drivers/scsi/qla2xxx/qla_gbl.h                |  327 
 drivers/scsi/qla2xxx/qla_gs.c                 |  681 
 drivers/scsi/qla2xxx/qla_init.c               | 4260 +++
 drivers/scsi/qla2xxx/qla_inline.h             |  242 
 drivers/scsi/qla2xxx/qla_iocb.c               |  764 
 drivers/scsi/qla2xxx/qla_isr.c                | 1421 +
 drivers/scsi/qla2xxx/qla_listops.h            |  351 
 drivers/scsi/qla2xxx/qla_mbx.c                | 2778 ++
 drivers/scsi/qla2xxx/qla_os.c                 | 4602 +++
 drivers/scsi/qla2xxx/qla_os.h                 |   93 
 drivers/scsi/qla2xxx/qla_rscn.c               | 1458 +
 drivers/scsi/qla2xxx/qla_settings.h           |   66 
 drivers/scsi/qla2xxx/qla_sup.c                |  680 
 drivers/scsi/qla2xxx/qla_version.h            |   27 
 drivers/scsi/qlogicpti.c                      |   61 
 drivers/scsi/qlogicpti.h                      |    1 
 drivers/scsi/scsi.c                           |   17 
 drivers/scsi/scsi_error.c                     |   30 
 drivers/scsi/scsi_scan.c                      |    5 
 drivers/scsi/scsi_sysfs.c                     |   11 
 drivers/scsi/sr.c                             |   24 
 drivers/scsi/sym53c8xx_2/sym_glue.c           |    2 
 drivers/scsi/sym53c8xx_2/sym_hipd.c           |   22 
 drivers/scsi/sym53c8xx_2/sym_misc.c           |    1 
 drivers/serial/8250_acpi.c                    |   67 
 drivers/serial/8250_hcdp.c                    |    2 
 drivers/serial/8250_pnp.c                     |    2 
 drivers/serial/Kconfig                        |   18 
 drivers/serial/serial_cs.c                    |   77 
 drivers/telephony/ixj_pcmcia.c                |   45 
 drivers/video/Kconfig                         |   21 
 drivers/video/Makefile                        |    1 
 drivers/video/cirrusfb.c                      |    2 
 drivers/video/console/Kconfig                 |    3 
 drivers/video/fbmem.c                         |    6 
 drivers/video/kyro/Makefile                   |   13 
 drivers/video/kyro/STG4000InitDevice.c        |  326 
 drivers/video/kyro/STG4000Interface.h         |   60 
 drivers/video/kyro/STG4000OverlayDevice.c     |  600 
 drivers/video/kyro/STG4000Ramdac.c            |  164 
 drivers/video/kyro/STG4000Reg.h               |  283 
 drivers/video/kyro/STG4000VTG.c               |  170 
 drivers/video/kyro/fbdev.c                    |  808 
 drivers/video/macfb.c                         |    2 
 drivers/video/pvr2fb.c                        |  606 
 drivers/video/radeonfb.c                      |   32 
 drivers/video/tridentfb.c                     |    2 
 drivers/zorro/Makefile                        |    2 
 drivers/zorro/proc.c                          |   21 
 drivers/zorro/zorro-driver.c                  |  150 
 drivers/zorro/zorro-sysfs.c                   |   98 
 drivers/zorro/zorro.c                         |   95 
 drivers/zorro/zorro.h                         |    4 
 fs/afs/callback.c                             |   44 
 fs/afs/cell.c                                 |  235 
 fs/afs/cell.h                                 |    2 
 fs/afs/cmservice.c                            |  125 
 fs/afs/cmservice.h                            |    8 
 fs/afs/dir.c                                  |  292 
 fs/afs/file.c                                 |   74 
 fs/afs/fsclient.c                             |  315 
 fs/afs/fsclient.h                             |   31 
 fs/afs/inode.c                                |   20 
 fs/afs/internal.h                             |   30 
 fs/afs/kafsasyncd.c                           |   62 
 fs/afs/kafsasyncd.h                           |   17 
 fs/afs/kafstimod.c                            |   53 
 fs/afs/kafstimod.h                            |   10 
 fs/afs/main.c                                 |   65 
 fs/afs/mntpt.c                                |   51 
 fs/afs/proc.c                                 |  365 
 fs/afs/server.c                               |  150 
 fs/afs/server.h                               |   27 
 fs/afs/super.c                                |   22 
 fs/afs/types.h                                |   24 
 fs/afs/vlclient.c                             |  223 
 fs/afs/vlclient.h                             |   10 
 fs/afs/vlocation.c                            |  289 
 fs/afs/vnode.c                                |  125 
 fs/afs/vnode.h                                |   13 
 fs/afs/volume.c                               |  131 
 fs/binfmt_elf.c                               |    4 
 fs/bio.c                                      |    6 
 fs/block_dev.c                                |  115 
 fs/buffer.c                                   |   48 
 fs/coda/file.c                                |    1 
 fs/compat_ioctl.c                             |  537 
 fs/cramfs/inode.c                             |   50 
 fs/devfs/base.c                               |   18 
 fs/dnotify.c                                  |    1 
 fs/eventpoll.c                                |    1 
 fs/exec.c                                     |   10 
 fs/ext2/balloc.c                              |    6 
 fs/ext2/ialloc.c                              |   27 
 fs/ext2/inode.c                               |    2 
 fs/ext2/super.c                               |    1 
 fs/ext3/ialloc.c                              |    6 
 fs/ext3/inode.c                               |    2 
 fs/ext3/super.c                               |    3 
 fs/fcntl.c                                    |   16 
 fs/file_table.c                               |    1 
 fs/freevxfs/vxfs_super.c                      |    2 
 fs/fs-writeback.c                             |    8 
 fs/hugetlbfs/inode.c                          |    1 
 fs/intermezzo/file.c                          |    2 
 fs/intermezzo/intermezzo_fs.h                 |    2 
 fs/intermezzo/journal.c                       |    4 
 fs/intermezzo/presto.c                        |    5 
 fs/intermezzo/vfs.c                           |    9 
 fs/ioctl.c                                    |    2 
 fs/jbd/transaction.c                          |    4 
 fs/jffs/intrep.c                              |    6 
 fs/jfs/inode.c                                |    2 
 fs/jfs/super.c                                |   23 
 fs/jfs/xattr.c                                |    7 
 fs/libfs.c                                    |    1 
 fs/locks.c                                    |    4 
 fs/nfs/dir.c                                  |   15 
 fs/nfs/file.c                                 |   10 
 fs/nfs/inode.c                                |    9 
 fs/nfs/write.c                                |   23 
 fs/nfsd/nfsfh.c                               |   24 
 fs/nfsd/nfsxdr.c                              |   11 
 fs/nfsd/vfs.c                                 |   12 
 fs/ntfs/ChangeLog                             |    8 
 fs/ntfs/Makefile                              |    2 
 fs/ntfs/inode.c                               |    4 
 fs/open.c                                     |    7 
 fs/pipe.c                                     |    1 
 fs/proc/base.c                                |   25 
 fs/proc/proc_devtree.c                        |   39 
 fs/proc/proc_misc.c                           |    6 
 fs/proc/task_mmu.c                            |   26 
 fs/read_write.c                               |    2 
 fs/reiserfs/file.c                            |    6 
 fs/reiserfs/inode.c                           |    2 
 fs/reiserfs/journal.c                         |    9 
 fs/xfs/Makefile                               |   47 
 fs/xfs/linux/xfs_aops.c                       |  229 
 fs/xfs/linux/xfs_file.c                       |    6 
 fs/xfs/linux/xfs_globals.c                    |   74 
 fs/xfs/linux/xfs_ioctl.c                      |    2 
 fs/xfs/linux/xfs_iomap.c                      |  122 
 fs/xfs/linux/xfs_iops.c                       |  247 
 fs/xfs/linux/xfs_iops.h                       |   29 
 fs/xfs/linux/xfs_linux.h                      |   18 
 fs/xfs/linux/xfs_lrw.c                        |  134 
 fs/xfs/linux/xfs_lrw.h                        |   52 
 fs/xfs/linux/xfs_super.c                      |   30 
 fs/xfs/linux/xfs_super.h                      |   12 
 fs/xfs/linux/xfs_sysctl.c                     |    2 
 fs/xfs/linux/xfs_version.h                    |    2 
 fs/xfs/linux/xfs_vfs.c                        |    2 
 fs/xfs/linux/xfs_vfs.h                        |   11 
 fs/xfs/linux/xfs_vnode.c                      |   11 
 fs/xfs/linux/xfs_vnode.h                      |   42 
 fs/xfs/pagebuf/page_buf.c                     |  316 
 fs/xfs/pagebuf/page_buf.h                     |   88 
 fs/xfs/quota/xfs_dquot.c                      |   46 
 fs/xfs/quota/xfs_dquot.h                      |   14 
 fs/xfs/quota/xfs_qm.c                         |   47 
 fs/xfs/quota/xfs_qm_syscalls.c                |    5 
 fs/xfs/quota/xfs_trans_dquot.c                |    7 
 fs/xfs/support/debug.h                        |    4 
 fs/xfs/support/kmem.h                         |   21 
 fs/xfs/support/ktrace.c                       |   33 
 fs/xfs/support/ktrace.h                       |   20 
 fs/xfs/support/qsort.c                        |  372 
 fs/xfs/xfs_acl.h                              |    4 
 fs/xfs/xfs_alloc.c                            |   11 
 fs/xfs/xfs_alloc.h                            |   24 
 fs/xfs/xfs_arch.h                             |    6 
 fs/xfs/xfs_attr.c                             |  319 
 fs/xfs/xfs_attr.h                             |   53 
 fs/xfs/xfs_attr_leaf.c                        |   53 
 fs/xfs/xfs_attr_leaf.h                        |    8 
 fs/xfs/xfs_attr_sf.h                          |   12 
 fs/xfs/xfs_bmap.c                             |   45 
 fs/xfs/xfs_bmap.h                             |   63 
 fs/xfs/xfs_bmap_btree.c                       |   12 
 fs/xfs/xfs_bmap_btree.h                       |   15 
 fs/xfs/xfs_buf.h                              |   21 
 fs/xfs/xfs_buf_item.c                         |    9 
 fs/xfs/xfs_buf_item.h                         |   28 
 fs/xfs/xfs_da_btree.c                         |    7 
 fs/xfs/xfs_dfrag.c                            |    4 
 fs/xfs/xfs_dir.c                              |   99 
 fs/xfs/xfs_dir.h                              |    8 
 fs/xfs/xfs_dir2_trace.c                       |  119 
 fs/xfs/xfs_dir2_trace.h                       |   15 
 fs/xfs/xfs_dir_sf.h                           |   20 
 fs/xfs/xfs_dmapi.h                            |    8 
 fs/xfs/xfs_dmops.c                            |    3 
 fs/xfs/xfs_error.c                            |   14 
 fs/xfs/xfs_fsops.c                            |    4 
 fs/xfs/xfs_iget.c                             |   14 
 fs/xfs/xfs_inode.c                            |   62 
 fs/xfs/xfs_inode.h                            |   31 
 fs/xfs/xfs_iocore.c                           |    1 
 fs/xfs/xfs_iomap.h                            |  107 
 fs/xfs/xfs_itable.c                           |   50 
 fs/xfs/xfs_itable.h                           |   10 
 fs/xfs/xfs_log.c                              |   46 
 fs/xfs/xfs_log.h                              |    4 
 fs/xfs/xfs_log_priv.h                         |   13 
 fs/xfs/xfs_mount.c                            |    2 
 fs/xfs/xfs_qmops.c                            |    2 
 fs/xfs/xfs_refcache.h                         |   66 
 fs/xfs/xfs_rename.c                           |   10 
 fs/xfs/xfs_rw.c                               |   56 
 fs/xfs/xfs_rw.h                               |   55 
 fs/xfs/xfs_trans.c                            |    2 
 fs/xfs/xfs_vfsops.c                           |   54 
 fs/xfs/xfs_vnodeops.c                         |   49 
 include/asm-alpha/processor.h                 |   11 
 include/asm-alpha/smp.h                       |    2 
 include/asm-alpha/socket.h                    |    2 
 include/asm-alpha/topology.h                  |    3 
 include/asm-arm/arch-ebsa285/io.h             |    6 
 include/asm-arm/arch-nexuspci/io.h            |    3 
 include/asm-arm/socket.h                      |    2 
 include/asm-arm26/socket.h                    |    2 
 include/asm-cris/arch-v10/byteorder.h         |    5 
 include/asm-cris/socket.h                     |    2 
 include/asm-generic/percpu.h                  |    2 
 include/asm-generic/pgtable.h                 |   65 
 include/asm-h8300/socket.h                    |    2 
 include/asm-i386/byteorder.h                  |   20 
 include/asm-i386/genapic.h                    |    2 
 include/asm-i386/hpet.h                       |    4 
 include/asm-i386/mach-bigsmp/mach_apic.h      |    5 
 include/asm-i386/mach-default/mach_apic.h     |    5 
 include/asm-i386/mach-es7000/mach_apic.h      |    5 
 include/asm-i386/mach-generic/mach_apic.h     |    1 
 include/asm-i386/mach-numaq/mach_apic.h       |    6 
 include/asm-i386/mach-summit/mach_apic.h      |   11 
 include/asm-i386/mach-visws/mach_apic.h       |    6 
 include/asm-i386/pgtable.h                    |    8 
 include/asm-i386/smp.h                        |    3 
 include/asm-i386/socket.h                     |    2 
 include/asm-ia64/acpi.h                       |    3 
 include/asm-ia64/asmmacro.h                   |   13 
 include/asm-ia64/byteorder.h                  |    7 
 include/asm-ia64/mmzone.h                     |    2 
 include/asm-ia64/numa.h                       |    1 
 include/asm-ia64/page.h                       |    2 
 include/asm-ia64/pgtable.h                    |    8 
 include/asm-ia64/smp.h                        |    2 
 include/asm-ia64/sn/addrs.h                   |   20 
 include/asm-ia64/sn/alenlist.h                |    3 
 include/asm-ia64/sn/arch.h                    |    3 
 include/asm-ia64/sn/bte.h                     |   55 
 include/asm-ia64/sn/cdl.h                     |    5 
 include/asm-ia64/sn/clksupport.h              |    3 
 include/asm-ia64/sn/dmamap.h                  |   29 
 include/asm-ia64/sn/driver.h                  |    3 
 include/asm-ia64/sn/geo.h                     |    9 
 include/asm-ia64/sn/hcl.h                     |   42 
 include/asm-ia64/sn/hcl_util.h                |    5 
 include/asm-ia64/sn/hwgfs.h                   |    6 
 include/asm-ia64/sn/intr.h                    |    3 
 include/asm-ia64/sn/io.h                      |    4 
 include/asm-ia64/sn/ioc4.h                    |   29 
 include/asm-ia64/sn/ioconfig_bus.h            |   39 
 include/asm-ia64/sn/ioerror.h                 |    7 
 include/asm-ia64/sn/ioerror_handling.h        |   54 
 include/asm-ia64/sn/iograph.h                 |   80 
 include/asm-ia64/sn/klconfig.h                |  366 
 include/asm-ia64/sn/ksys/elsc.h               |    9 
 include/asm-ia64/sn/ksys/l1.h                 |   37 
 include/asm-ia64/sn/labelcl.h                 |   17 
 include/asm-ia64/sn/module.h                  |    4 
 include/asm-ia64/sn/nodepda.h                 |    3 
 include/asm-ia64/sn/pci/bridge.h              |   16 
 include/asm-ia64/sn/pci/pci_bus_cvlink.h      |   14 
 include/asm-ia64/sn/pci/pci_defs.h            |  191 
 include/asm-ia64/sn/pci/pcibr.h               |   26 
 include/asm-ia64/sn/pci/pcibr_private.h       |  125 
 include/asm-ia64/sn/pci/pciio.h               |   74 
 include/asm-ia64/sn/pci/pciio_private.h       |   29 
 include/asm-ia64/sn/pci/pic.h                 | 1437 -
 include/asm-ia64/sn/pda.h                     |    2 
 include/asm-ia64/sn/pio.h                     |    7 
 include/asm-ia64/sn/prio.h                    |    3 
 include/asm-ia64/sn/router.h                  |    3 
 include/asm-ia64/sn/sgi.h                     |  124 
 include/asm-ia64/sn/slotnum.h                 |    3 
 include/asm-ia64/sn/sn2/addrs.h               |   15 
 include/asm-ia64/sn/sn2/arch.h                |    5 
 include/asm-ia64/sn/sn2/geo.h                 |    9 
 include/asm-ia64/sn/sn2/intr.h                |    3 
 include/asm-ia64/sn/sn2/shub.h                |    1 
 include/asm-ia64/sn/sn2/shub_md.h             |    7 
 include/asm-ia64/sn/sn2/shubio.h              |   12 
 include/asm-ia64/sn/sn2/sn_private.h          |   85 
 include/asm-ia64/sn/sn_fru.h                  |    3 
 include/asm-ia64/sn/sn_private.h              |    3 
 include/asm-ia64/sn/sn_sal.h                  |   43 
 include/asm-ia64/sn/sndrv.h                   |   32 
 include/asm-ia64/sn/vector.h                  |    3 
 include/asm-ia64/sn/xtalk/xbow.h              |  227 
 include/asm-ia64/sn/xtalk/xbow_info.h         |   55 
 include/asm-ia64/sn/xtalk/xswitch.h           |    9 
 include/asm-ia64/sn/xtalk/xtalk.h             |   26 
 include/asm-ia64/sn/xtalk/xtalk_private.h     |   15 
 include/asm-ia64/sn/xtalk/xtalkaddrs.h        |    9 
 include/asm-ia64/sn/xtalk/xwidget.h           |   83 
 include/asm-ia64/socket.h                     |    2 
 include/asm-m68k/atariints.h                  |    8 
 include/asm-m68k/bitops.h                     |   70 
 include/asm-m68k/byteorder.h                  |    3 
 include/asm-m68k/cacheflush.h                 |    8 
 include/asm-m68k/delay.h                      |    5 
 include/asm-m68k/dvma.h                       |    3 
 include/asm-m68k/io.h                         |    8 
 include/asm-m68k/mac_psc.h                    |   12 
 include/asm-m68k/mac_via.h                    |    3 
 include/asm-m68k/mmu_context.h                |   12 
 include/asm-m68k/motorola_pgtable.h           |   71 
 include/asm-m68k/nubus.h                      |    8 
 include/asm-m68k/page.h                       |    2 
 include/asm-m68k/pci.h                        |    4 
 include/asm-m68k/pgtable.h                    |    6 
 include/asm-m68k/processor.h                  |   17 
 include/asm-m68k/sbus.h                       |    6 
 include/asm-m68k/semaphore.h                  |   10 
 include/asm-m68k/signal.h                     |   10 
 include/asm-m68k/socket.h                     |    2 
 include/asm-m68k/string.h                     |    5 
 include/asm-m68k/sun3_pgtable.h               |   79 
 include/asm-m68k/sun3mmu.h                    |   14 
 include/asm-m68k/system.h                     |    4 
 include/asm-m68k/thread_info.h                |    2 
 include/asm-m68k/tlbflush.h                   |    4 
 include/asm-m68k/uaccess.h                    |    2 
 include/asm-m68k/virtconvert.h                |    4 
 include/asm-m68k/zorro.h                      |   16 
 include/asm-m68knommu/types.h                 |   67 
 include/asm-mips/dma-mapping.h                |   12 
 include/asm-mips/pci.h                        |    3 
 include/asm-mips/smp.h                        |    2 
 include/asm-mips/socket.h                     |    2 
 include/asm-parisc/byteorder.h                |   11 
 include/asm-parisc/mmu_context.h              |    5 
 include/asm-parisc/pgtable.h                  |    8 
 include/asm-parisc/smp.h                      |    2 
 include/asm-parisc/socket.h                   |    2 
 include/asm-parisc/tlbflush.h                 |    2 
 include/asm-ppc/byteorder.h                   |    5 
 include/asm-ppc/highmem.h                     |    9 
 include/asm-ppc/ibm4xx.h                      |    3 
 include/asm-ppc/mpc8260.h                     |   34 
 include/asm-ppc/pci.h                         |    9 
 include/asm-ppc/pgtable.h                     |    9 
 include/asm-ppc/smp.h                         |    1 
 include/asm-ppc/socket.h                      |    2 
 include/asm-ppc/uaccess.h                     |    2 
 include/asm-ppc/unistd.h                      |    3 
 include/asm-ppc64/byteorder.h                 |    7 
 include/asm-ppc64/compat.h                    |    6 
 include/asm-ppc64/cputable.h                  |   35 
 include/asm-ppc64/elf.h                       |  110 
 include/asm-ppc64/hvcall.h                    |   58 
 include/asm-ppc64/iSeries/HvCall.h            |   18 
 include/asm-ppc64/iSeries/HvCallCfg.h         |   14 
 include/asm-ppc64/iSeries/HvCallEvent.h       |  238 
 include/asm-ppc64/iSeries/HvCallHpt.h         |   24 
 include/asm-ppc64/iSeries/HvCallPci.h         |   78 
 include/asm-ppc64/iSeries/HvCallSc.h          |    7 
 include/asm-ppc64/iSeries/HvCallSm.h          |   14 
 include/asm-ppc64/iSeries/HvCallXm.h          |   19 
 include/asm-ppc64/iSeries/HvLpConfig.h        |   20 
 include/asm-ppc64/iSeries/HvLpEvent.h         |    3 
 include/asm-ppc64/iSeries/HvReleaseData.h     |   14 
 include/asm-ppc64/iSeries/HvTypes.h           |   12 
 include/asm-ppc64/iSeries/IoHriProcessorVpd.h |   10 
 include/asm-ppc64/iSeries/ItExtVpdPanel.h     |    8 
 include/asm-ppc64/iSeries/ItIplParmsReal.h    |   12 
 include/asm-ppc64/iSeries/ItLpNaca.h          |    8 
 include/asm-ppc64/iSeries/ItLpPaca.h          |   16 
 include/asm-ppc64/iSeries/ItLpQueue.h         |   13 
 include/asm-ppc64/iSeries/ItLpRegSave.h       |    8 
 include/asm-ppc64/iSeries/ItVpdAreas.h        |   12 
 include/asm-ppc64/iSeries/LparMap.h           |    7 
 include/asm-ppc64/iSeries/iSeries_dma.h       |    4 
 include/asm-ppc64/iSeries/iSeries_io.h        |   10 
 include/asm-ppc64/iSeries/iSeries_irq.h       |    8 
 include/asm-ppc64/iSeries/iSeries_pci.h       |  108 
 include/asm-ppc64/iSeries/iSeries_proc.h      |    7 
 include/asm-ppc64/iSeries/mf.h                |   51 
 include/asm-ppc64/iSeries/vio.h               |  129 
 include/asm-ppc64/io.h                        |    4 
 include/asm-ppc64/irq.h                       |    5 
 include/asm-ppc64/machdep.h                   |   12 
 include/asm-ppc64/memory.h                    |   25 
 include/asm-ppc64/mmu.h                       |   56 
 include/asm-ppc64/mmu_context.h               |   13 
 include/asm-ppc64/naca.h                      |    7 
 include/asm-ppc64/nvram.h                     |   39 
 include/asm-ppc64/paca.h                      |   14 
 include/asm-ppc64/pci.h                       |   17 
 include/asm-ppc64/pgalloc.h                   |   55 
 include/asm-ppc64/pgtable.h                   |   93 
 include/asm-ppc64/ppc32.h                     |   47 
 include/asm-ppc64/ppc_asm.h                   |   13 
 include/asm-ppc64/proc_fs.h                   |    1 
 include/asm-ppc64/processor.h                 |   18 
 include/asm-ppc64/prom.h                      |   87 
 include/asm-ppc64/ptrace.h                    |   38 
 include/asm-ppc64/rtas.h                      |   51 
 include/asm-ppc64/sigcontext.h                |   21 
 include/asm-ppc64/smp.h                       |   31 
 include/asm-ppc64/socket.h                    |    2 
 include/asm-ppc64/system.h                    |    3 
 include/asm-ppc64/tlb.h                       |    4 
 include/asm-ppc64/topology.h                  |    3 
 include/asm-ppc64/uaccess.h                   |    1 
 include/asm-ppc64/unistd.h                    |   24 
 include/asm-ppc64/vio.h                       |  130 
 include/asm-s390/bitops.h                     |   18 
 include/asm-s390/bug.h                        |    2 
 include/asm-s390/byteorder.h                  |   12 
 include/asm-s390/ccwdev.h                     |   10 
 include/asm-s390/ccwgroup.h                   |    5 
 include/asm-s390/checksum.h                   |    8 
 include/asm-s390/cio.h                        |    8 
 include/asm-s390/dasd.h                       |    6 
 include/asm-s390/hardirq.h                    |   15 
 include/asm-s390/idals.h                      |    6 
 include/asm-s390/ioctl.h                      |   16 
 include/asm-s390/mmu_context.h                |    2 
 include/asm-s390/pgalloc.h                    |   33 
 include/asm-s390/pgtable.h                    |  170 
 include/asm-s390/scatterlist.h                |    6 
 include/asm-s390/setup.h                      |    1 
 include/asm-s390/siginfo.h                    |    6 
 include/asm-s390/smp.h                        |    1 
 include/asm-s390/socket.h                     |    2 
 include/asm-s390/spinlock.h                   |    2 
 include/asm-s390/tlbflush.h                   |   23 
 include/asm-s390/uaccess.h                    |   23 
 include/asm-s390/unistd.h                     |    4 
 include/asm-sh/bigsur/io.h                    |   54 
 include/asm-sh/byteorder.h                    |    5 
 include/asm-sh/cache.h                        |    7 
 include/asm-sh/cat68701/io.h                  |   67 
 include/asm-sh/cpu-sh2/addrspace.h            |   16 
 include/asm-sh/cpu-sh2/cache.h                |    2 
 include/asm-sh/cpu-sh2/dma.h                  |   23 
 include/asm-sh/cpu-sh2/shmparam.h             |   16 
 include/asm-sh/cpu-sh2/sigcontext.h           |   17 
 include/asm-sh/cpu-sh2/ubc.h                  |   32 
 include/asm-sh/cpu-sh3/cache.h                |    2 
 include/asm-sh/cpu-sh3/dma.h                  |    6 
 include/asm-sh/cpu-sh3/mmu_context.h          |    1 
 include/asm-sh/cpu-sh3/sigcontext.h           |   17 
 include/asm-sh/cpu-sh4/cache.h                |    2 
 include/asm-sh/cpu-sh4/dma.h                  |    6 
 include/asm-sh/cpu-sh4/sigcontext.h           |   24 
 include/asm-sh/cpu-sh4/sq.h                   |   48 
 include/asm-sh/dma.h                          |  136 
 include/asm-sh/dreamcast/dma.h                |   34 
 include/asm-sh/dreamcast/pci.h                |   25 
 include/asm-sh/dreamcast/sysasic.h            |    8 
 include/asm-sh/ec3104/io.h                    |   38 
 include/asm-sh/flat.h                         |   23 
 include/asm-sh/hardirq.h                      |   25 
 include/asm-sh/hd64461/io.h                   |   45 
 include/asm-sh/hd64465/io.h                   |   46 
 include/asm-sh/io.h                           |  232 
 include/asm-sh/ipc.h                          |    2 
 include/asm-sh/irq.h                          |   80 
 include/asm-sh/kgdb.h                         |   14 
 include/asm-sh/local.h                        |    7 
 include/asm-sh/machvec.h                      |    8 
 include/asm-sh/mc146818rtc.h                  |    9 
 include/asm-sh/module.h                       |    8 
 include/asm-sh/mpc1211/io.h                   |   64 
 include/asm-sh/overdrive/io.h                 |   38 
 include/asm-sh/page.h                         |   11 
 include/asm-sh/pci.h                          |   59 
 include/asm-sh/pgalloc.h                      |   26 
 include/asm-sh/pgtable.h                      |    8 
 include/asm-sh/processor.h                    |   54 
 include/asm-sh/ptrace.h                       |   36 
 include/asm-sh/rtc.h                          |    6 
 include/asm-sh/saturn/io.h                    |   38 
 include/asm-sh/se/io.h                        |   45 
 include/asm-sh/se7751/io.h                    |   38 
 include/asm-sh/sections.h                     |    9 
 include/asm-sh/segment.h                      |    6 
 include/asm-sh/sigcontext.h                   |   22 
 include/asm-sh/smp.h                          |   20 
 include/asm-sh/snapgear/io.h                  |   92 
 include/asm-sh/socket.h                       |    2 
 include/asm-sh/spinlock.h                     |   18 
 include/asm-sh/system.h                       |    5 
 include/asm-sh/systemh/7751systemh.h          |   68 
 include/asm-sh/systemh/io.h                   |   43 
 include/asm-sh/timex.h                        |    2 
 include/asm-sh/uaccess.h                      |  220 
 include/asm-sh/unistd.h                       |   10 
 include/asm-sparc/elf.h                       |    3 
 include/asm-sparc/socket.h                    |    2 
 include/asm-sparc64/floppy.h                  |    5 
 include/asm-sparc64/smp.h                     |    2 
 include/asm-sparc64/socket.h                  |    2 
 include/asm-sparc64/tlbflush.h                |    3 
 include/asm-um/smp.h                          |    2 
 include/asm-v850/byteorder.h                  |    5 
 include/asm-v850/socket.h                     |    2 
 include/asm-x86_64/byteorder.h                |    5 
 include/asm-x86_64/pgalloc.h                  |    9 
 include/asm-x86_64/pgtable.h                  |    8 
 include/asm-x86_64/smp.h                      |    3 
 include/asm-x86_64/socket.h                   |    2 
 include/asm-x86_64/spinlock.h                 |   18 
 include/linux/bio.h                           |    3 
 include/linux/bitmap.h                        |  140 
 include/linux/blkdev.h                        |    6 
 include/linux/buffer_head.h                   |    5 
 include/linux/byteorder/swab.h                |    8 
 include/linux/cdrom.h                         |  286 
 include/linux/compat.h                        |    5 
 include/linux/compat_ioctl.h                  |  136 
 include/linux/compiler-gcc+.h                 |    1 
 include/linux/compiler-gcc2.h                 |    1 
 include/linux/compiler-gcc3.h                 |    1 
 include/linux/compiler.h                      |   18 
 include/linux/cpumask.h                       |   32 
 include/linux/dcache.h                        |    3 
 include/linux/device.h                        |   10 
 include/linux/efi.h                           |   16 
 include/linux/ext2_fs_sb.h                    |    1 
 include/linux/ext3_fs_sb.h                    |    1 
 include/linux/ext3_jbd.h                      |   17 
 include/linux/fs.h                            |   19 
 include/linux/genhd.h                         |    2 
 include/linux/highmem.h                       |    3 
 include/linux/i2c-id.h                        |    3 
 include/linux/ide.h                           |   58 
 include/linux/input.h                         |    3 
 include/linux/ipv6.h                          |    4 
 include/linux/kernel.h                        |    2 
 include/linux/kobject.h                       |    1 
 include/linux/miscdevice.h                    |    3 
 include/linux/mm.h                            |   62 
 include/linux/mmzone.h                        |   22 
 include/linux/module.h                        |    6 
 include/linux/moduleparam.h                   |    1 
 include/linux/net.h                           |   14 
 include/linux/netdevice.h                     |    4 
 include/linux/nfs_fs.h                        |    3 
 include/linux/nfsd/nfsfh.h                    |   17 
 include/linux/pci_ids.h                       |    7 
 include/linux/proc_fs.h                       |    2 
 include/linux/quotaops.h                      |    6 
 include/linux/rcupdate.h                      |    2 
 include/linux/rtnetlink.h                     |   47 
 include/linux/sched.h                         |    3 
 include/linux/security.h                      |   50 
 include/linux/signal.h                        |    1 
 include/linux/smp.h                           |    1 
 include/linux/smp_lock.h                      |    3 
 include/linux/sunrpc/sched.h                  |    2 
 include/linux/swap.h                          |    2 
 include/linux/sysctl.h                        |    5 
 include/linux/videodev.h                      |    4 
 include/linux/videodev2.h                     |  103 
 include/linux/zorro.h                         |  147 
 include/media/id.h                            |    3 
 include/media/ir-common.h                     |   61 
 include/media/tuner.h                         |    6 
 include/net/addrconf.h                        |    6 
 include/net/bluetooth/bluetooth.h             |    5 
 include/net/bluetooth/hci.h                   |   10 
 include/net/bluetooth/hci_core.h              |   14 
 include/net/bluetooth/rfcomm.h                |    9 
 include/net/flow.h                            |    1 
 include/net/if_inet6.h                        |    5 
 include/net/inet_common.h                     |    4 
 include/net/ipv6.h                            |    4 
 include/net/irda/ircomm_tty.h                 |    3 
 include/net/irda/timer.h                      |    6 
 include/net/ndisc.h                           |   11 
 include/net/neighbour.h                       |   10 
 include/net/sock.h                            |   51 
 include/net/tcp.h                             |    6 
 include/net/udp.h                             |    2 
 include/pcmcia/cs.h                           |    6 
 include/rxrpc/call.h                          |    3 
 include/rxrpc/connection.h                    |    3 
 include/rxrpc/message.h                       |    3 
 include/rxrpc/peer.h                          |    3 
 include/rxrpc/transport.h                     |    3 
 include/scsi/scsi.h                           |    2 
 include/sound/core.h                          |    1 
 include/video/kyro.h                          |   94 
 init/main.c                                   |    3 
 kernel/cpu.c                                  |    2 
 kernel/dma.c                                  |   15 
 kernel/exit.c                                 |    3 
 kernel/extable.c                              |   11 
 kernel/fork.c                                 |   83 
 kernel/futex.c                                |    1 
 kernel/module.c                               |   14 
 kernel/posix-timers.c                         |    2 
 kernel/printk.c                               |   42 
 kernel/sched.c                                |  402 
 kernel/sys.c                                  |    3 
 kernel/sysctl.c                               |   20 
 kernel/timer.c                                |    5 
 kernel/workqueue.c                            |   18 
 lib/Makefile                                  |    3 
 lib/bitmap.c                                  |  141 
 lib/extable.c                                 |   75 
 lib/kobject.c                                 |   51 
 mm/fadvise.c                                  |    4 
 mm/filemap.c                                  |   48 
 mm/fremap.c                                   |   20 
 mm/madvise.c                                  |    2 
 mm/memory.c                                   |  101 
 mm/mincore.c                                  |    2 
 mm/mmap.c                                     |   20 
 mm/mremap.c                                   |   24 
 mm/msync.c                                    |   32 
 mm/nommu.c                                    |    9 
 mm/page-writeback.c                           |    1 
 mm/page_alloc.c                               |   24 
 mm/readahead.c                                |   14 
 mm/rmap.c                                     |   29 
 mm/shmem.c                                    |    3 
 mm/swapfile.c                                 |   37 
 mm/vmscan.c                                   |   32 
 net/appletalk/ddp.c                           |    4 
 net/atm/br2684.c                              |    4 
 net/atm/clip.c                                |    5 
 net/atm/common.c                              |   25 
 net/atm/common.h                              |    4 
 net/ax25/af_ax25.c                            |   12 
 net/bluetooth/Kconfig                         |    3 
 net/bluetooth/Makefile                        |    1 
 net/bluetooth/af_bluetooth.c                  |    7 
 net/bluetooth/bnep/core.c                     |    1 
 net/bluetooth/cmtp/Kconfig                    |   11 
 net/bluetooth/cmtp/Makefile                   |    7 
 net/bluetooth/cmtp/capi.c                     |  630 
 net/bluetooth/cmtp/cmtp.h                     |  136 
 net/bluetooth/cmtp/core.c                     |  507 
 net/bluetooth/cmtp/sock.c                     |  199 
 net/bluetooth/hci_conn.c                      |    2 
 net/bluetooth/hci_core.c                      |    1 
 net/bluetooth/hci_event.c                     |   27 
 net/bluetooth/hci_sock.c                      |   22 
 net/bluetooth/l2cap.c                         |    4 
 net/bluetooth/rfcomm/core.c                   |   63 
 net/bluetooth/rfcomm/sock.c                   |   11 
 net/bluetooth/sco.c                           |    4 
 net/bridge/br_if.c                            |    4 
 net/core/dev.c                                |   91 
 net/core/dev_mcast.c                          |  100 
 net/core/neighbour.c                          |    7 
 net/core/sock.c                               |   13 
 net/decnet/af_decnet.c                        |   27 
 net/econet/af_econet.c                        |   10 
 net/ipv4/af_inet.c                            |    4 
 net/ipv4/arp.c                                |    2 
 net/ipv4/devinet.c                            |    4 
 net/ipv4/igmp.c                               |    3 
 net/ipv4/ipcomp.c                             |    1 
 net/ipv4/ipmr.c                               |    3 
 net/ipv4/netfilter/Kconfig                    |   13 
 net/ipv4/netfilter/ip_tables.c                |    2 
 net/ipv4/raw.c                                |   17 
 net/ipv4/route.c                              |    5 
 net/ipv4/tcp.c                                |    4 
 net/ipv4/udp.c                                |   17 
 net/ipv6/addrconf.c                           |  191 
 net/ipv6/af_inet6.c                           |    2 
 net/ipv6/ipv6_sockglue.c                      |   18 
 net/ipv6/mcast.c                              |    2 
 net/ipv6/ndisc.c                              |   22 
 net/ipv6/raw.c                                |    9 
 net/ipv6/udp.c                                |   11 
 net/ipx/af_ipx.c                              |    8 
 net/ipx/ipx_route.c                           |    4 
 net/irda/af_irda.c                            |   24 
 net/irda/ircomm/ircomm_tty.c                  |    6 
 net/irda/ircomm/ircomm_tty_ioctl.c            |   77 
 net/irda/irlap_event.c                        |   24 
 net/irda/irlap_frame.c                        |   41 
 net/key/af_key.c                              |    8 
 net/llc/af_llc.c                              |   10 
 net/netlink/af_netlink.c                      |    8 
 net/netrom/af_netrom.c                        |    6 
 net/packet/af_packet.c                        |   19 
 net/rose/af_rose.c                            |    8 
 net/rxrpc/call.c                              |   12 
 net/rxrpc/krxiod.c                            |   10 
 net/rxrpc/krxsecd.c                           |    6 
 net/rxrpc/krxtimod.c                          |    6 
 net/rxrpc/transport.c                         |   14 
 net/sched/sch_teql.c                          |    9 
 net/sctp/socket.c                             |   14 
 net/socket.c                                  |   14 
 net/unix/af_unix.c                            |   10 
 net/x25/af_x25.c                              |   29 
 net/xfrm/xfrm_algo.c                          |    2 
 net/xfrm/xfrm_policy.c                        |   27 
 net/xfrm/xfrm_user.c                          |    1 
 scripts/kconfig/mconf.c                       |    1 
 scripts/modpost.c                             |    1 
 security/Makefile                             |    4 
 security/dummy.c                              |   18 
 security/selinux/Makefile                     |    4 
 security/selinux/avc.c                        |   54 
 security/selinux/hooks.c                      |  588 
 security/selinux/include/av_perm_to_string.h  |    5 
 security/selinux/include/av_permissions.h     |    5 
 security/selinux/include/avc.h                |    5 
 security/selinux/include/netif.h              |   30 
 security/selinux/include/objsec.h             |   13 
 security/selinux/netif.c                      |  239 
 security/selinux/ss/Makefile                  |    6 
 sound/core/sound.c                            |   34 
 sound/oss/dmabuf.c                            |    2 
 sound/oss/soundcard.c                         |   13 
 sound/oss/trident.c                           | 2477 +
 sound/oss/trident.h                           |   17 
 sound/pci/intel8x0.c                          |    1 
 sound/pcmcia/vx/vx_entry.c                    |   38 
 sound/sound_core.c                            |   10 
 1577 files changed, 118715 insertions(+), 69544 deletions(-)

diff -puN arch/alpha/Kconfig~linus arch/alpha/Kconfig
--- 25/arch/alpha/Kconfig~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/alpha/Kconfig	2004-01-19 22:17:09.000000000 -0800
@@ -509,6 +509,7 @@ config HAVE_DEC_LOCK
 
 config NR_CPUS
 	int "Maximum number of CPUs (2-64)"
+	range 2 64
 	depends on SMP
 	default "64"
 
diff -puN arch/alpha/kernel/module.c~linus arch/alpha/kernel/module.c
--- 25/arch/alpha/kernel/module.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/alpha/kernel/module.c	2004-01-19 22:17:09.000000000 -0800
@@ -259,7 +259,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, 
 			*(u64 *)location = value;
 			break;
 		case R_ALPHA_GPRELHIGH:
-			value = (value - gp + 0x8000) >> 16;
+			value = (long)(value - gp + 0x8000) >> 16;
 			if ((short) value != value)
 				goto reloc_overflow;
 			*(u16 *)location = value;
diff -puN arch/alpha/mm/extable.c~linus arch/alpha/mm/extable.c
--- 25/arch/alpha/mm/extable.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/alpha/mm/extable.c	2004-01-19 22:17:09.000000000 -0800
@@ -6,6 +6,11 @@
 #include <linux/module.h>
 #include <asm/uaccess.h>
 
+void sort_extable(struct exception_table_entry *start,
+		  struct exception_table_entry *finish)
+{
+}
+
 const struct exception_table_entry *
 search_extable(const struct exception_table_entry *first,
 	       const struct exception_table_entry *last,
diff -puN arch/arm26/mm/extable.c~linus arch/arm26/mm/extable.c
--- 25/arch/arm26/mm/extable.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/arm26/mm/extable.c	2004-01-19 22:17:09.000000000 -0800
@@ -6,27 +6,6 @@
 #include <linux/module.h>
 #include <asm/uaccess.h>
 
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
-               const struct exception_table_entry *last,
-               unsigned long value)
-{
-        while (first <= last) {
-                const struct exception_table_entry *mid;
-                long diff;
-
-                mid = (last - first) / 2 + first;
-                diff = mid->insn - value;
-                if (diff == 0)
-                        return mid;
-                else if (diff < 0)
-                        first = mid+1;
-                else
-                        last = mid-1;
-        }
-        return NULL;
-}
-
 int fixup_exception(struct pt_regs *regs)
 {
         const struct exception_table_entry *fixup;
diff -puN arch/arm/mm/extable.c~linus arch/arm/mm/extable.c
--- 25/arch/arm/mm/extable.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/arm/mm/extable.c	2004-01-19 22:17:09.000000000 -0800
@@ -4,27 +4,6 @@
 #include <linux/module.h>
 #include <asm/uaccess.h>
 
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
-	       const struct exception_table_entry *last,
-	       unsigned long value)
-{
-        while (first <= last) {
-		const struct exception_table_entry *mid;
-		long diff;
-
-		mid = (last - first) / 2 + first;
-		diff = mid->insn - value;
-                if (diff == 0)
-                        return mid;
-                else if (diff < 0)
-                        first = mid+1;
-                else
-                        last = mid-1;
-        }
-        return NULL;
-}
-
 int fixup_exception(struct pt_regs *regs)
 {
 	const struct exception_table_entry *fixup;
diff -puN arch/cris/arch-v10/drivers/ds1302.c~linus arch/cris/arch-v10/drivers/ds1302.c
--- 25/arch/cris/arch-v10/drivers/ds1302.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/cris/arch-v10/drivers/ds1302.c	2004-01-19 22:17:09.000000000 -0800
@@ -342,6 +342,7 @@ rtc_ioctl(struct inode *inode, struct fi
 		{
 			struct rtc_time rtc_tm;
 						
+			memset(&rtc_tm, 0, sizeof (struct rtc_time));
 			get_rtc_time(&rtc_tm);						
 			if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time)))
 				return -EFAULT;	
diff -puN arch/cris/arch-v10/drivers/pcf8563.c~linus arch/cris/arch-v10/drivers/pcf8563.c
--- 25/arch/cris/arch-v10/drivers/pcf8563.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/cris/arch-v10/drivers/pcf8563.c	2004-01-19 22:17:09.000000000 -0800
@@ -219,6 +219,7 @@ pcf8563_ioctl(struct inode *inode, struc
 				unsigned long flags;
 				struct rtc_time tm;
 
+				memset(&tm, 0, sizeof (struct rtc_time));
 				if (!capable(CAP_SYS_TIME))
 					return -EPERM;
 
diff -puN -L arch/cris/mm/extable.c arch/cris/mm/extable.c~linus /dev/null
--- 25/arch/cris/mm/extable.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,48 +0,0 @@
-/*
- * linux/arch/cris/mm/extable.c
- *
- * $Log: generic-exception-table-sorting-2.patch,v $
- * Revision 1.1  2004/01/19 19:27:07  akpm
- * foo
- *
- * Revision 1.4  2003/01/09 14:42:52  starvik
- * Merge of Linux 2.5.55
- *
- * Revision 1.3  2002/11/21 07:24:54  starvik
- * Made search_exception_table similar to implementation for other archs
- * (now compiles with CONFIG_MODULES)
- *
- * Revision 1.2  2002/11/18 07:36:55  starvik
- * Removed warning
- *
- * Revision 1.1  2001/12/17 13:59:27  bjornw
- * Initial revision
- *
- * Revision 1.3  2001/09/27 13:52:40  bjornw
- * Harmonize underscore-ness with other parts
- *
- *
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <asm/uaccess.h>
-
-/* Simple binary search */
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
-	       const struct exception_table_entry *last,
-	       unsigned long value)
-{
-        while (first <= last) {
-		const struct exception_table_entry *mid;
-		long diff;
-
-		mid = (last - first) / 2 + first;
-		diff = mid->insn - value;
-                if (diff == 0)
-                        return mid;
-                else if (diff < 0)
-                        first = mid+1;
-                else
-                        last = mid-1;
diff -puN arch/cris/mm/Makefile~linus arch/cris/mm/Makefile
--- 25/arch/cris/mm/Makefile~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/cris/mm/Makefile	2004-01-19 22:17:09.000000000 -0800
@@ -2,5 +2,5 @@
 # Makefile for the linux cris-specific parts of the memory manager.
 #
 
-obj-y	 := init.o fault.o tlb.o extable.o ioremap.o
+obj-y	 := init.o fault.o tlb.o ioremap.o
 
diff -puN -L arch/h8300/mm/extable.c arch/h8300/mm/extable.c~linus /dev/null
--- 25/arch/h8300/mm/extable.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,30 +0,0 @@
-/*
- * linux/arch/h8300/mm/extable.c
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/spinlock.h>
-#include <asm/uaccess.h>
-
-/* Simple binary search */
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
-	       const struct exception_table_entry *last,
-	       unsigned long value)
-{
-        while (first <= last) {
-		const struct exception_table_entry *mid;
-		long diff;
-
-		mid = (last - first) / 2 + first;
-		diff = mid->insn - value;
-                if (diff == 0)
-                        return mid;
-                else if (diff < 0)
-                        first = mid+1;
-                else
-                        last = mid-1;
-        }
-        return NULL;
-}
diff -puN arch/h8300/mm/Makefile~linus arch/h8300/mm/Makefile
--- 25/arch/h8300/mm/Makefile~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/h8300/mm/Makefile	2004-01-19 22:17:20.000000000 -0800
@@ -7,4 +7,4 @@
 #
 # Note 2! The CFLAGS definition is now in the main makefile...
 
-obj-y	 := init.o fault.o memory.o kmap.o extable.o
+obj-y	 := init.o fault.o memory.o kmap.o
diff -puN arch/i386/Kconfig~linus arch/i386/Kconfig
--- 25/arch/i386/Kconfig~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/i386/Kconfig	2004-01-19 22:17:20.000000000 -0800
@@ -447,6 +447,7 @@ config SMP
 
 config NR_CPUS
 	int "Maximum number of CPUs (2-255)"
+	range 2 255
 	depends on SMP
 	default "32" if X86_NUMAQ || X86_SUMMIT || X86_BIGSMP || X86_ES7000
 	default "8"
diff -puN arch/i386/kernel/acpi/wakeup.S~linus arch/i386/kernel/acpi/wakeup.S
--- 25/arch/i386/kernel/acpi/wakeup.S~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/i386/kernel/acpi/wakeup.S	2004-01-19 22:17:20.000000000 -0800
@@ -193,21 +193,12 @@ wakeup_pmode_return:
 	# and restore the stack ... but you need gdt for this to work
 	movl	saved_context_esp, %esp
 
-	movw	$0x0e00 + 'W', 0xb8018
-	outl	%eax, $0x80
-	outl	%eax, $0x80
-	movw	$0x0e00 + 'O', 0xb8018
-
 	movl	%cs:saved_magic, %eax
 	cmpl	$0x12345678, %eax
 	jne	bogus_magic
 
 	# jump to place where we left off
 	movl	saved_eip,%eax
-	movw	$0x0e00 + 'x', 0xb8018
-	outl	%eax, $0x80
-	outl	%eax, $0x80
-	movw	$0x0e00 + '!', 0xb801a
 	jmp	*%eax
 
 bogus_magic:
diff -puN arch/i386/kernel/cpu/cpufreq/Kconfig~linus arch/i386/kernel/cpu/cpufreq/Kconfig
--- 25/arch/i386/kernel/cpu/cpufreq/Kconfig~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/i386/kernel/cpu/cpufreq/Kconfig	2004-01-19 22:17:20.000000000 -0800
@@ -145,11 +145,6 @@ config X86_SPEEDSTEP_SMI
 
 	  If in doubt, say N.
 
-config X86_SPEEDSTEP_LIB
-	tristate
-	depends on (X86_SPEEDSTEP_ICH || X86_SPEEDSTEP_SMI)
-	default (X86_SPEEDSTEP_ICH || X86_SPEEDSTEP_SMI)
-
 config X86_P4_CLOCKMOD
 	tristate "Intel Pentium 4 clock modulation"
 	depends on CPU_FREQ_TABLE
@@ -161,6 +156,11 @@ config X86_P4_CLOCKMOD
 
 	  If in doubt, say N.
 
+config X86_SPEEDSTEP_LIB
+	tristate
+	depends on (X86_SPEEDSTEP_ICH || X86_SPEEDSTEP_SMI || X86_P4_CLOCKMOD)
+	default (X86_SPEEDSTEP_ICH || X86_SPEEDSTEP_SMI || X86_P4_CLOCKMOD)
+
 config X86_LONGRUN
 	tristate "Transmeta LongRun"
 	depends on CPU_FREQ
diff -puN arch/i386/kernel/cpu/cpufreq/p4-clockmod.c~linus arch/i386/kernel/cpu/cpufreq/p4-clockmod.c
--- 25/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c	2004-01-19 22:17:20.000000000 -0800
@@ -33,6 +33,8 @@
 #include <asm/msr.h>
 #include <asm/timex.h>
 
+#include "speedstep-lib.h"
+
 #define PFX	"cpufreq: "
 
 /*
@@ -174,51 +176,30 @@ static int cpufreq_p4_verify(struct cpuf
 	return cpufreq_frequency_table_verify(policy, &p4clockmod_table[0]);
 }
 
-/* copied from speedstep_lib, made SMP-compatible */
+
 static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
 {
-	u32 msr_lo, msr_hi, mult;
-	unsigned int fsb = 0;
+	if ((c->x86 == 0x06) && (c->x86_model == 0x09)) {
+		/* Pentium M */
+		printk(KERN_DEBUG PFX "Warning: Pentium M detected. The speedstep_centrino module\n");
+		printk(KERN_DEBUG PFX "offers voltage scaling in addition of frequency scaling. You\n");
+		printk(KERN_DEBUG PFX "should use that instead of p4-clockmod, if possible.\n");
+		return speedstep_get_processor_frequency(SPEEDSTEP_PROCESSOR_PM);
+	}
 
 	if (c->x86 != 0xF) {
-		printk(KERN_DEBUG PFX "Unknown P4. Please send an e-mail to <linux@brodo.de>\n");
+		printk(KERN_DEBUG PFX "Unknown p4-clockmod-capable CPU. Please send an e-mail to <linux@brodo.de>\n");
 		return 0;
 	}
 
-	rdmsr(0x2c, msr_lo, msr_hi);
-
-	/* printk(KERN_DEBUG PFX "P4 - MSR_EBC_FREQUENCY_ID: 0x%x 0x%x\n", msr_lo, msr_hi); */
-	/* decode the FSB: see IA-32 Intel (C) Architecture Software 
-	 * Developer's Manual, Volume 3: System Prgramming Guide,
-	 * revision #12 in Table B-1: MSRs in the Pentium 4 and
-	 * Intel Xeon Processors, on page B-4 and B-5.
-	 */
-	if (c->x86_model < 2)
-		fsb = 100 * 1000;
-	else {
-		u8 fsb_code = (msr_lo >> 16) & 0x7;
-		switch (fsb_code) {
-		case 0:
-			fsb = 100 * 1000;
-			break;
-		case 1:
-			fsb = 13333 * 10;
-			break;
-		case 2:
-			fsb = 200 * 1000;
-			break;
-		}
-	}
-
-	if (!fsb) {
-		printk(KERN_DEBUG PFX "couldn't detect FSB speed. Please send an e-mail to <linux@brodo.de>\n");
-		printk(KERN_DEBUG PFX "P4 - MSR_EBC_FREQUENCY_ID: 0x%x 0x%x\n", msr_lo, msr_hi);
+	if (speedstep_detect_processor() == SPEEDSTEP_PROCESSOR_P4M) {
+		printk(KERN_DEBUG PFX "Warning: Pentium 4-M detected. The speedstep-ich or acpi cpufreq \n");
+		printk(KERN_DEBUG PFX "modules offers voltage scaling in addition of frequency scaling. You\n");
+		printk(KERN_DEBUG PFX "should use either one instead of p4-clockmod, if possible.\n");
+		return speedstep_get_processor_frequency(SPEEDSTEP_PROCESSOR_P4M);
 	}
 
-	/* Multiplier. */
-	mult = msr_lo >> 24;
-
-	return (fsb * mult);
+	return speedstep_get_processor_frequency(SPEEDSTEP_PROCESSOR_P4D);
 }
 
  
@@ -315,6 +296,6 @@ MODULE_AUTHOR ("Zwane Mwaikambo <zwane@c
 MODULE_DESCRIPTION ("cpufreq driver for Pentium(TM) 4/Xeon(TM)");
 MODULE_LICENSE ("GPL");
 
-module_init(cpufreq_p4_init);
+late_initcall(cpufreq_p4_init);
 module_exit(cpufreq_p4_exit);
 
diff -puN arch/i386/kernel/cpu/cpufreq/speedstep-lib.c~linus arch/i386/kernel/cpu/cpufreq/speedstep-lib.c
--- 25/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c	2004-01-19 22:17:20.000000000 -0800
@@ -104,6 +104,26 @@ static unsigned int pentium3_get_frequen
 }
 
 
+static unsigned int pentiumM_get_frequency(void)
+{
+	u32     msr_lo, msr_tmp;
+
+	rdmsr(MSR_IA32_EBL_CR_POWERON, msr_lo, msr_tmp);
+	dprintk(KERN_DEBUG "speedstep-lib: PM - MSR_IA32_EBL_CR_POWERON: 0x%x 0x%x\n", msr_lo, msr_tmp);
+
+	/* see table B-2 of 24547212.pdf */
+	if (msr_lo & 0x00040000) {
+		printk(KERN_DEBUG "speedstep-lib: PM - invalid FSB: 0x%x 0x%x\n", msr_lo, msr_tmp);
+		return 0;
+	}
+
+	msr_tmp = (msr_lo >> 22) & 0x1f;
+	dprintk(KERN_DEBUG "speedstep-lib: bits 22-26 are 0x%x\n", msr_tmp);
+
+	return (msr_tmp * 100 * 10000);
+}
+
+
 static unsigned int pentium4_get_frequency(void)
 {
 	struct cpuinfo_x86 *c = &boot_cpu_data;
@@ -151,6 +171,9 @@ static unsigned int pentium4_get_frequen
 unsigned int speedstep_get_processor_frequency(unsigned int processor)
 {
 	switch (processor) {
+	case SPEEDSTEP_PROCESSOR_PM:
+		return pentiumM_get_frequency();
+	case SPEEDSTEP_PROCESSOR_P4D:
 	case SPEEDSTEP_PROCESSOR_P4M:
 		return pentium4_get_frequency();
 	case SPEEDSTEP_PROCESSOR_PIII_T:
diff -puN arch/i386/kernel/cpu/cpufreq/speedstep-lib.h~linus arch/i386/kernel/cpu/cpufreq/speedstep-lib.h
--- 25/arch/i386/kernel/cpu/cpufreq/speedstep-lib.h~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/i386/kernel/cpu/cpufreq/speedstep-lib.h	2004-01-19 22:17:20.000000000 -0800
@@ -17,6 +17,12 @@
 #define SPEEDSTEP_PROCESSOR_PIII_T 		0x00000003  /* Tualatin core */
 #define SPEEDSTEP_PROCESSOR_P4M			0x00000004  /* P4-M  */
 
+/* the following processors are not speedstep-capable and are not auto-detected
+ * in speedstep_detect_processor(). However, their speed can be detected using
+ * the speedstep_get_processor_frequency() call. */
+#define SPEEDSTEP_PROCESSOR_PM			0xFFFFFF03  /* Pentium M  */
+#define SPEEDSTEP_PROCESSOR_P4D			0xFFFFFF04  /* desktop P4  */
+
 /* speedstep states -- only two of them */
 
 #define SPEEDSTEP_HIGH                  0x00000000
diff -puN arch/i386/kernel/cpu/intel.c~linus arch/i386/kernel/cpu/intel.c
--- 25/arch/i386/kernel/cpu/intel.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/i386/kernel/cpu/intel.c	2004-01-19 22:17:20.000000000 -0800
@@ -1,5 +1,7 @@
+#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+
 #include <linux/string.h>
 #include <linux/bitops.h>
 #include <linux/smp.h>
@@ -11,6 +13,12 @@
 
 #include "cpu.h"
 
+#ifdef CONFIG_X86_LOCAL_APIC
+#include <asm/mpspec.h>
+#include <asm/apic.h>
+#include <mach_apic.h>
+#endif
+
 extern int trap_init_f00f_bug(void);
 
 #ifdef CONFIG_X86_INTEL_USERCOPY
@@ -277,6 +285,7 @@ static void __init init_intel(struct cpu
 		extern	int phys_proc_id[NR_CPUS];
 		
 		u32 	eax, ebx, ecx, edx;
+		int 	index_lsb, index_msb, tmp;
 		int 	cpu = smp_processor_id();
 
 		cpuid(1, &eax, &ebx, &ecx, &edx);
@@ -285,6 +294,8 @@ static void __init init_intel(struct cpu
 		if (smp_num_siblings == 1) {
 			printk(KERN_INFO  "CPU: Hyper-Threading is disabled\n");
 		} else if (smp_num_siblings > 1 ) {
+			index_lsb = 0;
+			index_msb = 31;
 			/*
 			 * At this point we only support two siblings per
 			 * processor package.
@@ -295,13 +306,19 @@ static void __init init_intel(struct cpu
 				smp_num_siblings = 1;
 				goto too_many_siblings;
 			}
-			/* cpuid returns the value latched in the HW at reset,
-			 * not the APIC ID register's value.  For any box
-			 * whose BIOS changes APIC IDs, like clustered APIC
-			 * systems, we must use hard_smp_processor_id.
-			 * See Intel's IA-32 SW Dev's Manual Vol2 under CPUID.
-			 */
-			phys_proc_id[cpu] = hard_smp_processor_id() & ~(smp_num_siblings - 1);
+			tmp = smp_num_siblings;
+			while ((tmp & 1) == 0) {
+				tmp >>=1 ;
+				index_lsb++;
+			}
+			tmp = smp_num_siblings;
+			while ((tmp & 0x80000000 ) == 0) {
+				tmp <<=1 ;
+				index_msb--;
+			}
+			if (index_lsb != index_msb )
+				index_msb++;
+			phys_proc_id[cpu] = phys_pkg_id((ebx >> 24) & 0xFF, index_msb);
 
 			printk(KERN_INFO  "CPU: Physical Processor ID: %d\n",
                                phys_proc_id[cpu]);
diff -puN arch/i386/kernel/dmi_scan.c~linus arch/i386/kernel/dmi_scan.c
--- 25/arch/i386/kernel/dmi_scan.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/i386/kernel/dmi_scan.c	2004-01-19 22:17:20.000000000 -0800
@@ -107,15 +107,7 @@ static int __init dmi_iterate(void (*dec
 	u8 buf[15];
 	u32 fp=0xF0000;
 
-#ifdef CONFIG_SIMNOW
-	/*
- 	 *	Skip on x86/64 with simnow. Will eventually go away
- 	 *	If you see this ifdef in 2.6pre mail me !
- 	 */
-	return -1;
-#endif
- 	
-	while( fp < 0xFFFFF)
+	while (fp < 0xFFFFF)
 	{
 		isa_memcpy_fromio(buf, fp, 15);
 		if(memcmp(buf, "_DMI_", 5)==0 && dmi_checksum(buf))
diff -puN arch/i386/kernel/efi.c~linus arch/i386/kernel/efi.c
--- 25/arch/i386/kernel/efi.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/i386/kernel/efi.c	2004-01-19 22:17:20.000000000 -0800
@@ -174,7 +174,7 @@ phys_efi_get_time(efi_time_t *tm, efi_ti
 	return status;
 }
 
-int inline efi_set_rtc_mmss(unsigned long nowtime)
+inline int efi_set_rtc_mmss(unsigned long nowtime)
 {
 	int real_seconds, real_minutes;
 	efi_status_t 	status;
@@ -207,7 +207,7 @@ int inline efi_set_rtc_mmss(unsigned lon
  * services have been remapped, therefore, we'll need to call in physical
  * mode.  Note, this call isn't used later, so mark it __init.
  */
-unsigned long inline __init efi_get_time(void)
+inline unsigned long __init efi_get_time(void)
 {
 	efi_status_t status;
 	efi_time_t eft;
diff -puN arch/i386/kernel/time.c~linus arch/i386/kernel/time.c
--- 25/arch/i386/kernel/time.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/i386/kernel/time.c	2004-01-19 22:17:20.000000000 -0800
@@ -307,7 +307,31 @@ unsigned long get_cmos_time(void)
 	return retval;
 }
 
+static long clock_cmos_diff;
+
+static int time_suspend(struct sys_device *dev, u32 state)
+{
+	/*
+	 * Estimate time zone so that set_time can update the clock
+	 */
+	clock_cmos_diff = -get_cmos_time();
+	clock_cmos_diff += get_seconds();
+	return 0;
+}
+
+static int time_resume(struct sys_device *dev)
+{
+	unsigned long sec = get_cmos_time() + clock_cmos_diff;
+	write_seqlock_irq(&xtime_lock);
+	xtime.tv_sec = sec;
+	xtime.tv_nsec = 0;
+	write_sequnlock_irq(&xtime_lock);
+	return 0;
+}
+
 static struct sysdev_class pit_sysclass = {
+	.resume = time_resume,
+	.suspend = time_suspend,
 	set_kset_name("pit"),
 };
 
diff -puN arch/i386/kernel/time_hpet.c~linus arch/i386/kernel/time_hpet.c
--- 25/arch/i386/kernel/time_hpet.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/i386/kernel/time_hpet.c	2004-01-19 22:17:20.000000000 -0800
@@ -91,10 +91,6 @@ int __init hpet_enable(void)
 	    !(id & HPET_ID_LEGSUP))
 		return -1;
 
-	if (((id & HPET_ID_VENDOR) >> HPET_ID_VENDOR_SHIFT) !=
-				HPET_ID_VENDOR_8086)
-		return -1;
-
 	hpet_period = hpet_readl(HPET_PERIOD);
 	if ((hpet_period < HPET_MIN_PERIOD) || (hpet_period > HPET_MAX_PERIOD))
 		return -1;
diff -puN arch/i386/mach-voyager/voyager_smp.c~linus arch/i386/mach-voyager/voyager_smp.c
--- 25/arch/i386/mach-voyager/voyager_smp.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/i386/mach-voyager/voyager_smp.c	2004-01-19 22:17:20.000000000 -0800
@@ -130,7 +130,7 @@ send_QIC_CPI(__u32 cpuset, __u8 cpi)
 {
 	int cpu;
 
-	for_each_cpu(cpu, cpu_online_map) {
+	for_each_online_cpu(cpu) {
 		if(cpuset & (1<<cpu)) {
 #ifdef VOYAGER_DEBUG
 			if(!cpu_isset(cpu, cpu_online_map))
@@ -1465,7 +1465,7 @@ send_CPI(__u32 cpuset, __u8 cpi)
 	cpuset &= 0xff;		/* only first 8 CPUs vaild for VIC CPI */
 	if(cpuset == 0)
 		return;
-	for_each_cpu(cpu, cpu_online_map) {
+	for_each_online_cpu(cpu) {
 		if(cpuset & (1<<cpu))
 			set_bit(cpi, &vic_cpi_mailbox[cpu]);
 	}
@@ -1579,7 +1579,7 @@ enable_vic_irq(unsigned int irq)
 	VDEBUG(("VOYAGER: enable_vic_irq(%d) CPU%d affinity 0x%lx\n",
 		irq, cpu, cpu_irq_affinity[cpu]));
 	spin_lock_irqsave(&vic_irq_lock, flags);
-	for_each_cpu(real_cpu, cpu_online_map) {
+	for_each_online_cpu(real_cpu) {
 		if(!(voyager_extended_vic_processors & (1<<real_cpu)))
 			continue;
 		if(!(cpu_irq_affinity[real_cpu] & mask)) {
@@ -1720,7 +1720,7 @@ after_handle_vic_irq(unsigned int irq)
 			int i;
 			__u8 cpu = smp_processor_id();
 			__u8 real_cpu;
-			int mask;
+			int mask; /* Um... initialize me??? --RR */
 
 			printk("VOYAGER SMP: CPU%d lost interrupt %d\n",
 			       cpu, irq);
@@ -1809,7 +1809,7 @@ set_vic_irq_affinity(unsigned int irq, c
 		 * bus) */
 		return;
 
-	for_each_cpu(cpu, cpu_online_map) {
+	for_each_online_cpu(cpu) {
 		unsigned long cpu_mask = 1 << cpu;
 		
 		if(cpu_mask & real_mask) {
@@ -1875,7 +1875,7 @@ voyager_smp_dump()
 	int old_cpu = smp_processor_id(), cpu;
 
 	/* dump the interrupt masks of each processor */
-	for_each_cpu(cpu, cpu_online_map) {
+	for_each_online_cpu(cpu) {
 		__u16 imr, isr, irr;
 		unsigned long flags;
 
diff -puN arch/i386/mm/extable.c~linus arch/i386/mm/extable.c
--- 25/arch/i386/mm/extable.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/i386/mm/extable.c	2004-01-19 22:17:20.000000000 -0800
@@ -7,28 +7,6 @@
 #include <linux/spinlock.h>
 #include <asm/uaccess.h>
 
-/* Simple binary search */
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
-	       const struct exception_table_entry *last,
-	       unsigned long value)
-{
-        while (first <= last) {
-		const struct exception_table_entry *mid;
-		long diff;
-
-		mid = (last - first) / 2 + first;
-		diff = mid->insn - value;
-                if (diff == 0)
-                        return mid;
-                else if (diff < 0)
-                        first = mid+1;
-                else
-                        last = mid-1;
-        }
-        return NULL;
-}
-
 int fixup_exception(struct pt_regs *regs)
 {
 	const struct exception_table_entry *fixup;
diff -puN /dev/null arch/ia64/configs/generic_defconfig
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/ia64/configs/generic_defconfig	2004-01-19 22:17:20.000000000 -0800
@@ -0,0 +1,1045 @@
+#
+# Automatically generated make config: don't edit
+#
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_STANDALONE=y
+
+#
+# General setup
+#
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+# CONFIG_BSD_PROCESS_ACCT is not set
+CONFIG_SYSCTL=y
+CONFIG_LOG_BUF_SHIFT=20
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+# CONFIG_EMBEDDED is not set
+CONFIG_KALLSYMS=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+CONFIG_MODVERSIONS=y
+CONFIG_KMOD=y
+
+#
+# Processor type and features
+#
+CONFIG_IA64=y
+CONFIG_64BIT=y
+CONFIG_MMU=y
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_TIME_INTERPOLATION=y
+# CONFIG_ITANIUM is not set
+CONFIG_MCKINLEY=y
+CONFIG_IA64_GENERIC=y
+# CONFIG_IA64_DIG is not set
+# CONFIG_IA64_HP_SIM is not set
+# CONFIG_IA64_HP_ZX1 is not set
+# CONFIG_IA64_SGI_SN2 is not set
+# CONFIG_IA64_PAGE_SIZE_4KB is not set
+# CONFIG_IA64_PAGE_SIZE_8KB is not set
+CONFIG_IA64_PAGE_SIZE_16KB=y
+# CONFIG_IA64_PAGE_SIZE_64KB is not set
+CONFIG_ACPI=y
+CONFIG_ACPI_INTERPRETER=y
+CONFIG_ACPI_KERNEL_CONFIG=y
+CONFIG_IA64_L1_CACHE_SHIFT=7
+# CONFIG_MCKINLEY_ASTEP_SPECIFIC is not set
+CONFIG_NUMA=y
+CONFIG_DISCONTIGMEM=y
+CONFIG_VIRTUAL_MEM_MAP=y
+CONFIG_IA64_MCA=y
+CONFIG_PM=y
+CONFIG_IOSAPIC=y
+CONFIG_FORCE_MAX_ZONEORDER=18
+# CONFIG_HUGETLB_PAGE_SIZE_4GB is not set
+# CONFIG_HUGETLB_PAGE_SIZE_1GB is not set
+# CONFIG_HUGETLB_PAGE_SIZE_256MB is not set
+# CONFIG_HUGETLB_PAGE_SIZE_64MB is not set
+CONFIG_HUGETLB_PAGE_SIZE_16MB=y
+# CONFIG_HUGETLB_PAGE_SIZE_4MB is not set
+# CONFIG_HUGETLB_PAGE_SIZE_1MB is not set
+# CONFIG_HUGETLB_PAGE_SIZE_256KB is not set
+# CONFIG_IA64_PAL_IDLE is not set
+CONFIG_SMP=y
+# CONFIG_PREEMPT is not set
+CONFIG_IA32_SUPPORT=y
+CONFIG_COMPAT=y
+CONFIG_HAVE_DEC_LOCK=y
+CONFIG_PERFMON=y
+CONFIG_IA64_PALINFO=y
+CONFIG_EFI=y
+CONFIG_EFI_VARS=y
+CONFIG_NR_CPUS=512
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_MISC=m
+
+#
+# ACPI (Advanced Configuration and Power Interface) Support
+#
+CONFIG_ACPI_BOOT=y
+CONFIG_ACPI_BUTTON=m
+CONFIG_ACPI_FAN=m
+CONFIG_ACPI_PROCESSOR=m
+CONFIG_ACPI_THERMAL=m
+CONFIG_ACPI_NUMA=y
+# CONFIG_ACPI_DEBUG is not set
+CONFIG_ACPI_BUS=y
+CONFIG_ACPI_POWER=y
+CONFIG_ACPI_PCI=y
+CONFIG_ACPI_SYSTEM=y
+# CONFIG_ACPI_RELAXED_AML is not set
+CONFIG_PCI=y
+CONFIG_PCI_DOMAINS=y
+CONFIG_PCI_LEGACY_PROC=y
+CONFIG_PCI_NAMES=y
+CONFIG_HOTPLUG=y
+
+#
+# PCI Hotplug Support
+#
+CONFIG_HOTPLUG_PCI=m
+# CONFIG_HOTPLUG_PCI_FAKE is not set
+CONFIG_HOTPLUG_PCI_ACPI=m
+# CONFIG_HOTPLUG_PCI_CPCI is not set
+
+#
+# PCMCIA/CardBus support
+#
+# CONFIG_PCMCIA is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Generic Driver Options
+#
+# CONFIG_FW_LOADER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Plug and Play support
+#
+# CONFIG_PNP is not set
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_CPQ_DA is not set
+# CONFIG_BLK_CPQ_CISS_DA is not set
+# CONFIG_BLK_DEV_DAC960 is not set
+# CONFIG_BLK_DEV_UMEM is not set
+CONFIG_BLK_DEV_LOOP=m
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_RAM=m
+CONFIG_BLK_DEV_RAM_SIZE=4096
+# CONFIG_BLK_DEV_INITRD is not set
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+CONFIG_IDE=y
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+CONFIG_BLK_DEV_IDEDISK=y
+# CONFIG_IDEDISK_MULTI_MODE is not set
+# CONFIG_IDEDISK_STROKE is not set
+CONFIG_BLK_DEV_IDECD=y
+# CONFIG_BLK_DEV_IDETAPE is not set
+CONFIG_BLK_DEV_IDEFLOPPY=y
+CONFIG_BLK_DEV_IDESCSI=m
+# CONFIG_IDE_TASK_IOCTL is not set
+# CONFIG_IDE_TASKFILE_IO is not set
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_BLK_DEV_IDEPCI=y
+# CONFIG_IDEPCI_SHARE_IRQ is not set
+# CONFIG_BLK_DEV_OFFBOARD is not set
+CONFIG_BLK_DEV_GENERIC=y
+# CONFIG_BLK_DEV_OPTI621 is not set
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
+CONFIG_IDEDMA_PCI_AUTO=y
+# CONFIG_IDEDMA_ONLYDISK is not set
+# CONFIG_IDEDMA_PCI_WIP is not set
+CONFIG_BLK_DEV_ADMA=y
+# CONFIG_BLK_DEV_AEC62XX is not set
+# CONFIG_BLK_DEV_ALI15X3 is not set
+# CONFIG_BLK_DEV_AMD74XX is not set
+CONFIG_BLK_DEV_CMD64X=y
+# CONFIG_BLK_DEV_TRIFLEX is not set
+# CONFIG_BLK_DEV_CY82C693 is not set
+# CONFIG_BLK_DEV_CS5520 is not set
+# CONFIG_BLK_DEV_CS5530 is not set
+# CONFIG_BLK_DEV_HPT34X is not set
+# CONFIG_BLK_DEV_HPT366 is not set
+# CONFIG_BLK_DEV_SC1200 is not set
+CONFIG_BLK_DEV_PIIX=y
+# CONFIG_BLK_DEV_NS87415 is not set
+# CONFIG_BLK_DEV_PDC202XX_OLD is not set
+# CONFIG_BLK_DEV_PDC202XX_NEW is not set
+# CONFIG_BLK_DEV_SVWKS is not set
+# CONFIG_BLK_DEV_SIIMAGE is not set
+# CONFIG_BLK_DEV_SLC90E66 is not set
+# CONFIG_BLK_DEV_TRM290 is not set
+# CONFIG_BLK_DEV_VIA82CXXX is not set
+CONFIG_BLK_DEV_IDEDMA=y
+# CONFIG_IDEDMA_IVB is not set
+CONFIG_IDEDMA_AUTO=y
+# CONFIG_DMA_NONPCI is not set
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# IEEE 1394 (FireWire) support (EXPERIMENTAL)
+#
+# CONFIG_IEEE1394 is not set
+
+#
+# I2O device support
+#
+# CONFIG_I2O is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=m
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+CONFIG_MD_RAID5=m
+CONFIG_MD_MULTIPATH=m
+CONFIG_BLK_DEV_DM=m
+CONFIG_DM_IOCTL_V4=y
+
+#
+# Fusion MPT device support
+#
+CONFIG_FUSION=y
+CONFIG_FUSION_BOOT=y
+CONFIG_FUSION_MAX_SGE=40
+# CONFIG_FUSION_ISENSE is not set
+# CONFIG_FUSION_CTL is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_ST=m
+# CONFIG_CHR_DEV_OSST is not set
+CONFIG_BLK_DEV_SR=m
+# CONFIG_BLK_DEV_SR_VENDOR is not set
+CONFIG_CHR_DEV_SG=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+CONFIG_SCSI_REPORT_LUNS=y
+# CONFIG_SCSI_CONSTANTS is not set
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
+# CONFIG_SCSI_ACARD is not set
+# CONFIG_SCSI_AACRAID is not set
+# CONFIG_SCSI_AIC7XXX is not set
+# CONFIG_SCSI_AIC7XXX_OLD is not set
+# CONFIG_SCSI_AIC79XX is not set
+# CONFIG_SCSI_ADVANSYS is not set
+# CONFIG_SCSI_MEGARAID is not set
+# CONFIG_SCSI_SATA is not set
+# CONFIG_SCSI_BUSLOGIC is not set
+# CONFIG_SCSI_CPQFCTS is not set
+# CONFIG_SCSI_DMX3191D is not set
+# CONFIG_SCSI_EATA is not set
+# CONFIG_SCSI_EATA_PIO is not set
+# CONFIG_SCSI_FUTURE_DOMAIN is not set
+# CONFIG_SCSI_GDTH is not set
+# CONFIG_SCSI_IPS is not set
+# CONFIG_SCSI_INIA100 is not set
+CONFIG_SCSI_SYM53C8XX_2=y
+CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
+CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
+CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
+# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set
+# CONFIG_SCSI_QLOGIC_ISP is not set
+CONFIG_SCSI_QLOGIC_FC=y
+# CONFIG_SCSI_QLOGIC_FC_FIRMWARE is not set
+CONFIG_SCSI_QLOGIC_1280=y
+# CONFIG_SCSI_DC395x is not set
+# CONFIG_SCSI_DC390T is not set
+# CONFIG_SCSI_NSP32 is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_NETLINK_DEV=y
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+# CONFIG_IP_ADVANCED_ROUTER is not set
+# CONFIG_IP_PNP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_IP_MROUTE is not set
+CONFIG_ARPD=y
+# CONFIG_INET_ECN is not set
+CONFIG_SYN_COOKIES=y
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_IPV6 is not set
+# CONFIG_DECNET is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_NETFILTER is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IPV6_SCTP__=y
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_FASTROUTE is not set
+# CONFIG_NET_HW_FLOWCONTROL is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+CONFIG_NETDEVICES=y
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+CONFIG_DUMMY=m
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+# CONFIG_ETHERTAP is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+# CONFIG_HAPPYMEAL is not set
+# CONFIG_SUNGEM is not set
+# CONFIG_NET_VENDOR_3COM is not set
+
+#
+# Tulip family network device support
+#
+CONFIG_NET_TULIP=y
+# CONFIG_DE2104X is not set
+CONFIG_TULIP=m
+# CONFIG_TULIP_MWI is not set
+# CONFIG_TULIP_MMIO is not set
+# CONFIG_DE4X5 is not set
+# CONFIG_WINBOND_840 is not set
+# CONFIG_DM9102 is not set
+# CONFIG_HP100 is not set
+CONFIG_NET_PCI=y
+# CONFIG_PCNET32 is not set
+# CONFIG_AMD8111_ETH is not set
+# CONFIG_ADAPTEC_STARFIRE is not set
+# CONFIG_B44 is not set
+# CONFIG_DGRS is not set
+CONFIG_EEPRO100=m
+# CONFIG_EEPRO100_PIO is not set
+CONFIG_E100=m
+# CONFIG_FEALNX is not set
+# CONFIG_NATSEMI is not set
+# CONFIG_NE2K_PCI is not set
+# CONFIG_8139CP is not set
+# CONFIG_8139TOO is not set
+# CONFIG_SIS900 is not set
+# CONFIG_EPIC100 is not set
+# CONFIG_SUNDANCE is not set
+# CONFIG_VIA_RHINE is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+CONFIG_E1000=m
+# CONFIG_E1000_NAPI is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_R8169 is not set
+# CONFIG_SIS190 is not set
+# CONFIG_SK98LIN is not set
+CONFIG_TIGON3=y
+
+#
+# Ethernet (10000 Mbit)
+#
+# CONFIG_IXGB is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+# CONFIG_NET_FC is not set
+# CONFIG_SHAPER is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+
+#
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
+# IrDA (infrared) support
+#
+# CONFIG_IRDA is not set
+
+#
+# Bluetooth support
+#
+# CONFIG_BT is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN_BOOL is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+CONFIG_GAMEPORT=m
+CONFIG_SOUND_GAMEPORT=m
+# CONFIG_GAMEPORT_NS558 is not set
+# CONFIG_GAMEPORT_L4 is not set
+# CONFIG_GAMEPORT_EMU10K1 is not set
+# CONFIG_GAMEPORT_VORTEX is not set
+# CONFIG_GAMEPORT_FM801 is not set
+# CONFIG_GAMEPORT_CS461x is not set
+CONFIG_SERIO=y
+CONFIG_SERIO_I8042=y
+# CONFIG_SERIO_SERPORT is not set
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_PCIPS2 is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+# CONFIG_MOUSE_SERIAL is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+CONFIG_SERIAL_NONSTANDARD=y
+# CONFIG_ROCKETPORT is not set
+# CONFIG_SYNCLINK is not set
+# CONFIG_SYNCLINKMP is not set
+# CONFIG_N_HDLC is not set
+# CONFIG_STALDRV is not set
+CONFIG_SGI_L1_SERIAL=y
+CONFIG_SGI_L1_SERIAL_CONSOLE=y
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_ACPI=y
+CONFIG_SERIAL_8250_HCDP=y
+CONFIG_SERIAL_8250_NR_UARTS=6
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+# CONFIG_SERIAL_8250_DETECT_IRQ is not set
+# CONFIG_SERIAL_8250_MULTIPORT is not set
+# CONFIG_SERIAL_8250_RSA is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# I2C Algorithms
+#
+
+#
+# I2C Hardware Bus support
+#
+
+#
+# I2C Hardware Sensors Chip support
+#
+# CONFIG_I2C_SENSOR is not set
+
+#
+# Mice
+#
+# CONFIG_BUSMOUSE is not set
+# CONFIG_QIC02_TAPE is not set
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_HW_RANDOM is not set
+# CONFIG_NVRAM is not set
+# CONFIG_GEN_RTC is not set
+CONFIG_EFI_RTC=y
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+CONFIG_AGP=m
+CONFIG_AGP_I460=m
+CONFIG_AGP_HP_ZX1=m
+CONFIG_DRM=y
+CONFIG_DRM_TDFX=m
+CONFIG_DRM_GAMMA=m
+CONFIG_DRM_R128=m
+CONFIG_DRM_RADEON=m
+CONFIG_DRM_MGA=m
+CONFIG_DRM_SIS=m
+CONFIG_RAW_DRIVER=m
+CONFIG_MAX_RAW_DEVS=256
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+CONFIG_EXT3_FS=y
+CONFIG_EXT3_FS_XATTR=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_FS_MBCACHE=y
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_JFS_FS is not set
+CONFIG_FS_POSIX_ACL=y
+CONFIG_XFS_FS=y
+# CONFIG_XFS_RT is not set
+# CONFIG_XFS_QUOTA is not set
+# CONFIG_XFS_POSIX_ACL is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_QUOTA is not set
+CONFIG_AUTOFS_FS=y
+CONFIG_AUTOFS4_FS=y
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=m
+CONFIG_JOLIET=y
+# CONFIG_ZISOFS is not set
+CONFIG_UDF_FS=m
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+# CONFIG_MSDOS_FS is not set
+CONFIG_VFAT_FS=y
+CONFIG_NTFS_FS=m
+# CONFIG_NTFS_DEBUG is not set
+# CONFIG_NTFS_RW is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+# CONFIG_DEVFS_FS is not set
+CONFIG_DEVPTS_FS=y
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+CONFIG_HUGETLBFS=y
+CONFIG_HUGETLB_PAGE=y
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=m
+CONFIG_NFS_V3=y
+CONFIG_NFS_V4=y
+CONFIG_NFS_DIRECTIO=y
+CONFIG_NFSD=m
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_TCP=y
+CONFIG_LOCKD=m
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_SUNRPC=m
+# CONFIG_SUNRPC_GSS is not set
+CONFIG_SMB_FS=m
+CONFIG_SMB_NLS_DEFAULT=y
+CONFIG_SMB_NLS_REMOTE="cp437"
+CONFIG_CIFS=m
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_ACORN_PARTITION is not set
+# CONFIG_OSF_PARTITION is not set
+# CONFIG_AMIGA_PARTITION is not set
+# CONFIG_ATARI_PARTITION is not set
+# CONFIG_MAC_PARTITION is not set
+CONFIG_MSDOS_PARTITION=y
+# CONFIG_BSD_DISKLABEL is not set
+# CONFIG_MINIX_SUBPARTITION is not set
+# CONFIG_SOLARIS_X86_PARTITION is not set
+# CONFIG_UNIXWARE_DISKLABEL is not set
+# CONFIG_LDM_PARTITION is not set
+# CONFIG_NEC98_PARTITION is not set
+CONFIG_SGI_PARTITION=y
+# CONFIG_ULTRIX_PARTITION is not set
+# CONFIG_SUN_PARTITION is not set
+CONFIG_EFI_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=m
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ISO8859_1=m
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+
+#
+# Graphics support
+#
+# CONFIG_FB is not set
+
+#
+# Console display driver support
+#
+CONFIG_VGA_CONSOLE=y
+# CONFIG_MDA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+
+#
+# Sound
+#
+CONFIG_SOUND=m
+
+#
+# Advanced Linux Sound Architecture
+#
+CONFIG_SND=m
+CONFIG_SND_SEQUENCER=m
+CONFIG_SND_SEQ_DUMMY=m
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=m
+CONFIG_SND_PCM_OSS=m
+CONFIG_SND_SEQUENCER_OSS=y
+CONFIG_SND_VERBOSE_PRINTK=y
+# CONFIG_SND_DEBUG is not set
+
+#
+# Generic devices
+#
+CONFIG_SND_DUMMY=m
+CONFIG_SND_VIRMIDI=m
+CONFIG_SND_MTPAV=m
+CONFIG_SND_SERIAL_U16550=m
+CONFIG_SND_MPU401=m
+
+#
+# PCI devices
+#
+# CONFIG_SND_ALI5451 is not set
+# CONFIG_SND_AZT3328 is not set
+CONFIG_SND_CS46XX=m
+CONFIG_SND_CS46XX_NEW_DSP=y
+CONFIG_SND_CS4281=m
+CONFIG_SND_EMU10K1=m
+# CONFIG_SND_KORG1212 is not set
+# CONFIG_SND_NM256 is not set
+# CONFIG_SND_RME32 is not set
+# CONFIG_SND_RME96 is not set
+# CONFIG_SND_RME9652 is not set
+# CONFIG_SND_HDSP is not set
+# CONFIG_SND_TRIDENT is not set
+# CONFIG_SND_YMFPCI is not set
+# CONFIG_SND_ALS4000 is not set
+# CONFIG_SND_CMIPCI is not set
+# CONFIG_SND_ENS1370 is not set
+# CONFIG_SND_ENS1371 is not set
+# CONFIG_SND_ES1938 is not set
+# CONFIG_SND_ES1968 is not set
+# CONFIG_SND_MAESTRO3 is not set
+CONFIG_SND_FM801=m
+# CONFIG_SND_ICE1712 is not set
+# CONFIG_SND_ICE1724 is not set
+# CONFIG_SND_INTEL8X0 is not set
+# CONFIG_SND_SONICVIBES is not set
+# CONFIG_SND_VIA82XX is not set
+# CONFIG_SND_VX222 is not set
+
+#
+# ALSA USB devices
+#
+# CONFIG_SND_USB_AUDIO is not set
+
+#
+# Open Sound System
+#
+# CONFIG_SOUND_PRIME is not set
+
+#
+# USB support
+#
+CONFIG_USB=m
+# CONFIG_USB_DEBUG is not set
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEVICEFS=y
+# CONFIG_USB_BANDWIDTH is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+
+#
+# USB Host Controller Drivers
+#
+CONFIG_USB_EHCI_HCD=m
+CONFIG_USB_OHCI_HCD=m
+CONFIG_USB_UHCI_HCD=m
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_BLUETOOTH_TTY is not set
+# CONFIG_USB_MIDI is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+CONFIG_USB_STORAGE=m
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_ISD200 is not set
+# CONFIG_USB_STORAGE_DPCM is not set
+# CONFIG_USB_STORAGE_HP8200e is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_STORAGE_SDDR55 is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+
+#
+# USB Human Interface Devices (HID)
+#
+CONFIG_USB_HID=m
+CONFIG_USB_HIDINPUT=y
+# CONFIG_HID_FF is not set
+# CONFIG_USB_HIDDEV is not set
+
+#
+# USB HID Boot Protocol drivers
+#
+# CONFIG_USB_KBD is not set
+# CONFIG_USB_MOUSE is not set
+# CONFIG_USB_AIPTEK is not set
+# CONFIG_USB_WACOM is not set
+# CONFIG_USB_KBTAB is not set
+# CONFIG_USB_POWERMATE is not set
+# CONFIG_USB_XPAD is not set
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_SCANNER is not set
+# CONFIG_USB_MICROTEK is not set
+# CONFIG_USB_HPUSBSCSI is not set
+
+#
+# USB Multimedia devices
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# Video4Linux support is needed for USB Multimedia device support
+#
+
+#
+# USB Network adaptors
+#
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_RTL8150 is not set
+# CONFIG_USB_USBNET is not set
+
+#
+# USB port drivers
+#
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+
+#
+# USB Miscellaneous drivers
+#
+# CONFIG_USB_TIGL is not set
+# CONFIG_USB_AUERSWALD is not set
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_LEGOTOWER is not set
+# CONFIG_USB_BRLVGER is not set
+# CONFIG_USB_LCD is not set
+# CONFIG_USB_TEST is not set
+# CONFIG_USB_GADGET is not set
+
+#
+# Library routines
+#
+CONFIG_CRC32=y
+
+#
+# HP Simulator drivers
+#
+# CONFIG_HP_SIMETH is not set
+# CONFIG_HP_SIMSERIAL is not set
+# CONFIG_HP_SIMSCSI is not set
+
+#
+# Profiling support
+#
+# CONFIG_PROFILING is not set
+
+#
+# Kernel hacking
+#
+CONFIG_IA64_GRANULE_16MB=y
+# CONFIG_IA64_GRANULE_64MB is not set
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_IA64_PRINT_HAZARDS is not set
+# CONFIG_DISABLE_VHPT is not set
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_IA64_DEBUG_CMPXCHG is not set
+# CONFIG_IA64_DEBUG_IRQ is not set
+# CONFIG_DEBUG_INFO is not set
+
+#
+# Security options
+#
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+# CONFIG_CRYPTO_HMAC is not set
+# CONFIG_CRYPTO_NULL is not set
+# CONFIG_CRYPTO_MD4 is not set
+# CONFIG_CRYPTO_MD5 is not set
+# CONFIG_CRYPTO_SHA1 is not set
+# CONFIG_CRYPTO_SHA256 is not set
+# CONFIG_CRYPTO_SHA512 is not set
+# CONFIG_CRYPTO_DES is not set
+# CONFIG_CRYPTO_BLOWFISH is not set
+# CONFIG_CRYPTO_TWOFISH is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_AES is not set
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+# CONFIG_CRYPTO_DEFLATE is not set
+# CONFIG_CRYPTO_TEST is not set
diff -puN arch/ia64/configs/sn2_defconfig~linus arch/ia64/configs/sn2_defconfig
--- 25/arch/ia64/configs/sn2_defconfig~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/configs/sn2_defconfig	2004-01-19 22:17:20.000000000 -0800
@@ -15,8 +15,6 @@ CONFIG_STANDALONE=y
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_PAGG=y
-CONFIG_PAGG_JOB=y
 CONFIG_SYSCTL=y
 CONFIG_LOG_BUF_SHIFT=20
 # CONFIG_IKCONFIG is not set
@@ -27,6 +25,7 @@ CONFIG_EPOLL=y
 CONFIG_IOSCHED_NOOP=y
 CONFIG_IOSCHED_AS=y
 CONFIG_IOSCHED_DEADLINE=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 
 #
 # Loadable module support
@@ -53,7 +52,6 @@ CONFIG_IA64_SGI_SN2=y
 CONFIG_IA64_PAGE_SIZE_16KB=y
 # CONFIG_IA64_PAGE_SIZE_64KB is not set
 CONFIG_ACPI=y
-CONFIG_ACPI_EFI=y
 CONFIG_ACPI_INTERPRETER=y
 CONFIG_ACPI_KERNEL_CONFIG=y
 CONFIG_IA64_L1_CACHE_SHIFT=7
@@ -70,9 +68,10 @@ CONFIG_SMP=y
 # CONFIG_PREEMPT is not set
 CONFIG_IA32_SUPPORT=y
 CONFIG_COMPAT=y
+CONFIG_HAVE_DEC_LOCK=y
 CONFIG_PERFMON=y
 CONFIG_IA64_PALINFO=y
-CONFIG_IA64_SALINFO=y
+CONFIG_EFI=y
 # CONFIG_EFI_VARS is not set
 CONFIG_NR_CPUS=512
 CONFIG_BINFMT_ELF=y
@@ -145,7 +144,60 @@ CONFIG_BLK_DEV_LOOP=y
 #
 # ATA/ATAPI/MFM/RLL support
 #
-# CONFIG_IDE is not set
+CONFIG_IDE=y
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDEDISK is not set
+CONFIG_BLK_DEV_IDECD=y
+# CONFIG_BLK_DEV_IDETAPE is not set
+# CONFIG_BLK_DEV_IDEFLOPPY is not set
+# CONFIG_BLK_DEV_IDESCSI is not set
+# CONFIG_IDE_TASK_IOCTL is not set
+# CONFIG_IDE_TASKFILE_IO is not set
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_BLK_DEV_IDEPCI=y
+CONFIG_IDEPCI_SHARE_IRQ=y
+# CONFIG_BLK_DEV_OFFBOARD is not set
+# CONFIG_BLK_DEV_GENERIC is not set
+# CONFIG_BLK_DEV_OPTI621 is not set
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
+CONFIG_IDEDMA_PCI_AUTO=y
+# CONFIG_IDEDMA_ONLYDISK is not set
+# CONFIG_IDEDMA_PCI_WIP is not set
+CONFIG_BLK_DEV_ADMA=y
+# CONFIG_BLK_DEV_AEC62XX is not set
+# CONFIG_BLK_DEV_ALI15X3 is not set
+# CONFIG_BLK_DEV_AMD74XX is not set
+# CONFIG_BLK_DEV_CMD64X is not set
+# CONFIG_BLK_DEV_TRIFLEX is not set
+# CONFIG_BLK_DEV_CY82C693 is not set
+# CONFIG_BLK_DEV_CS5520 is not set
+# CONFIG_BLK_DEV_CS5530 is not set
+# CONFIG_BLK_DEV_HPT34X is not set
+# CONFIG_BLK_DEV_HPT366 is not set
+# CONFIG_BLK_DEV_SC1200 is not set
+# CONFIG_BLK_DEV_PIIX is not set
+# CONFIG_BLK_DEV_NS87415 is not set
+# CONFIG_BLK_DEV_PDC202XX_OLD is not set
+# CONFIG_BLK_DEV_PDC202XX_NEW is not set
+# CONFIG_BLK_DEV_SVWKS is not set
+CONFIG_BLK_DEV_SGIIOC4=y
+# CONFIG_BLK_DEV_SIIMAGE is not set
+# CONFIG_BLK_DEV_SLC90E66 is not set
+# CONFIG_BLK_DEV_TRM290 is not set
+# CONFIG_BLK_DEV_VIA82CXXX is not set
+CONFIG_BLK_DEV_IDEDMA=y
+# CONFIG_IDEDMA_IVB is not set
+CONFIG_IDEDMA_AUTO=y
+# CONFIG_DMA_NONPCI is not set
+# CONFIG_BLK_DEV_HD is not set
 
 #
 # IEEE 1394 (FireWire) support (EXPERIMENTAL)
@@ -216,6 +268,7 @@ CONFIG_SCSI_REPORT_LUNS=y
 # CONFIG_SCSI_QLOGIC_FC is not set
 CONFIG_SCSI_QLOGIC_1280=y
 # CONFIG_SCSI_DC395x is not set
+# CONFIG_SCSI_DC390T is not set
 # CONFIG_SCSI_NSP32 is not set
 # CONFIG_SCSI_DEBUG is not set
 
@@ -585,11 +638,11 @@ CONFIG_MSDOS_PARTITION=y
 # CONFIG_ULTRIX_PARTITION is not set
 # CONFIG_SUN_PARTITION is not set
 CONFIG_EFI_PARTITION=y
-CONFIG_NLS=y
 
 #
 # Native Language Support
 #
+CONFIG_NLS=y
 CONFIG_NLS_DEFAULT="iso8859-1"
 # CONFIG_NLS_CODEPAGE_437 is not set
 # CONFIG_NLS_CODEPAGE_737 is not set
diff -puN arch/ia64/hp/common/sba_iommu.c~linus arch/ia64/hp/common/sba_iommu.c
--- 25/arch/ia64/hp/common/sba_iommu.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/hp/common/sba_iommu.c	2004-01-19 22:17:20.000000000 -0800
@@ -1,9 +1,9 @@
 /*
 **  IA64 System Bus Adapter (SBA) I/O MMU manager
 **
-**	(c) Copyright 2002-2003 Alex Williamson
+**	(c) Copyright 2002-2004 Alex Williamson
 **	(c) Copyright 2002-2003 Grant Grundler
-**	(c) Copyright 2002-2003 Hewlett-Packard Company
+**	(c) Copyright 2002-2004 Hewlett-Packard Company
 **
 **	Portions (c) 2000 Grant Grundler (from parisc I/O MMU code)
 **	Portions (c) 1999 Dave S. Miller (from sparc64 I/O MMU code)
@@ -39,12 +39,19 @@
 #include <asm/page.h>		/* PAGE_OFFSET */
 #include <asm/dma.h>
 #include <asm/system.h>		/* wmb() */
+#include <asm/bitops.h>		/* hweight64() */
 
 #include <asm/acpi-ext.h>
 
 #define PFX "IOC: "
 
 /*
+** Enabling timing search of the pdir resource map.  Output in /proc.
+** Disabled by default to optimize performance.
+*/
+#undef PDIR_SEARCH_TIMING
+
+/*
 ** This option allows cards capable of 64bit DMA to bypass the IOMMU.  If
 ** not defined, all DMA will be 32bit and go through the TLB.
 ** There's potentially a conflict in the bio merge code with us
@@ -54,11 +61,6 @@
 */
 #define ALLOW_IOV_BYPASS
 
-#ifdef CONFIG_PROC_FS
-  /* turn it off for now; without per-CPU counters, it's too much of a scalability bottleneck: */
-# define SBA_PROC_FS 0
-#endif
-
 /*
 ** If a device prefetches beyond the end of a valid pdir entry, it will cause
 ** a hard failure, ie. MCA.  Version 3.0 and later of the zx1 LBA should
@@ -160,21 +162,18 @@
 #define ZX1_SBA_IOMMU_COOKIE	0x0000badbadc0ffeeUL
 
 /*
-** IOC supports 4/8/16/64KB page sizes (see TCNFG register)
-** It's safer (avoid memory corruption) to keep DMA page mappings
-** equivalently sized to VM PAGE_SIZE.
+** The zx1 IOC supports 4/8/16/64KB page sizes (see TCNFG register)
 **
-** We really can't avoid generating a new mapping for each
-** page since the Virtual Coherence Index has to be generated
-** and updated for each page.
+** Some IOCs (sx1000) can run at the above pages sizes, but are
+** really only supported using the IOC at a 4k page size.
 **
-** IOVP_SIZE could only be greater than PAGE_SIZE if we are
+** iovp_size could only be greater than PAGE_SIZE if we are
 ** confident the drivers really only touch the next physical
 ** page iff that driver instance owns it.
 */
-#define IOVP_SIZE	PAGE_SIZE
-#define IOVP_SHIFT	PAGE_SHIFT
-#define IOVP_MASK	PAGE_MASK
+static unsigned long iovp_size;
+static unsigned long iovp_shift;
+static unsigned long iovp_mask;
 
 struct ioc {
 	void		*ioc_hpa;	/* I/O MMU base address */
@@ -198,24 +197,10 @@ struct ioc {
 	} saved[DELAYED_RESOURCE_CNT];
 #endif
 
-#if SBA_PROC_FS
+#ifdef PDIR_SEARCH_TIMING
 #define SBA_SEARCH_SAMPLE	0x100
 	unsigned long avg_search[SBA_SEARCH_SAMPLE];
 	unsigned long avg_idx;	/* current index into avg_search */
-	unsigned long used_pages;
-	unsigned long msingle_calls;
-	unsigned long msingle_pages;
-	unsigned long msg_calls;
-	unsigned long msg_pages;
-	unsigned long usingle_calls;
-	unsigned long usingle_pages;
-	unsigned long usg_calls;
-	unsigned long usg_pages;
-#ifdef ALLOW_IOV_BYPASS
-	unsigned long msingle_bypass;
-	unsigned long usingle_bypass;
-	unsigned long msg_bypass;
-#endif
 #endif
 
 	/* Stuff we don't need in performance path */
@@ -252,7 +237,7 @@ static u64 prefetch_spill_page;
 ** rather than the HW. I/O MMU allocation alogorithms can be
 ** faster with smaller size is (to some degree).
 */
-#define DMA_CHUNK_SIZE  (BITS_PER_LONG*PAGE_SIZE)
+#define DMA_CHUNK_SIZE  (BITS_PER_LONG*iovp_size)
 
 #define ROUNDUP(x,y) ((x + ((y)-1)) & ~((y)-1))
 
@@ -416,18 +401,37 @@ sba_check_sg( struct ioc *ioc, struct sc
 #define PAGES_PER_RANGE 1	/* could increase this to 4 or 8 if needed */
 
 /* Convert from IOVP to IOVA and vice versa. */
-#define SBA_IOVA(ioc,iovp,offset,hint_reg) ((ioc->ibase) | (iovp) | (offset) |		\
-					    ((hint_reg)<<(ioc->hint_shift_pdir)))
-#define SBA_IOVP(ioc,iova) (((iova) & ioc->hint_mask_pdir) & ~(ioc->ibase))
+#define SBA_IOVA(ioc,iovp,offset,hint_reg) ((ioc->ibase) | (iovp) | (offset))
+#define SBA_IOVP(ioc,iova) ((iova) & ~(ioc->ibase))
 
-/* FIXME : review these macros to verify correctness and usage */
-#define PDIR_INDEX(iovp)   ((iovp)>>IOVP_SHIFT)
+#define PDIR_ENTRY_SIZE	sizeof(u64)
+
+#define PDIR_INDEX(iovp)   ((iovp)>>iovp_shift)
 
 #define RESMAP_MASK(n)    ~(~0UL << (n))
 #define RESMAP_IDX_MASK   (sizeof(unsigned long) - 1)
 
 
 /**
+ * For most cases the normal get_order is sufficient, however it limits us
+ * to PAGE_SIZE being the minimum mapping alignment and TC flush granularity.
+ * It only incurs about 1 clock cycle to use this one with the static variable
+ * and makes the code more intuitive.
+ */
+static SBA_INLINE int
+get_iovp_order (unsigned long size)
+{
+	long double d = size - 1;
+	long order;
+
+	order = ia64_getf_exp(d);
+	order = order - iovp_shift - 0xffff + 1;
+	if (order < 0)
+		order = 0;
+	return order;
+}
+
+/**
  * sba_search_bitmap - find free space in IO PDIR resource bitmap
  * @ioc: IO MMU structure which owns the pdir we are interested in.
  * @bits_wanted: number of entries we need.
@@ -465,7 +469,7 @@ sba_search_bitmap(struct ioc *ioc, unsig
 		** We need the alignment to invalidate I/O TLB using
 		** SBA HW features in the unmap path.
 		*/
-		unsigned long o = 1 << get_order(bits_wanted << PAGE_SHIFT);
+		unsigned long o = 1 << get_iovp_order(bits_wanted << iovp_shift);
 		uint bitshiftcnt = ROUNDUP(ioc->res_bitshift, o);
 		unsigned long mask;
 
@@ -521,16 +525,15 @@ sba_search_bitmap(struct ioc *ioc, unsig
 static int
 sba_alloc_range(struct ioc *ioc, size_t size)
 {
-	unsigned int pages_needed = size >> IOVP_SHIFT;
-#if SBA_PROC_FS
+	unsigned int pages_needed = size >> iovp_shift;
+#ifdef PDIR_SEARCH_TIMING
 	unsigned long itc_start = ia64_get_itc();
 #endif
 	unsigned long pide;
 
 	ASSERT(pages_needed);
-	ASSERT((pages_needed * IOVP_SIZE) <= DMA_CHUNK_SIZE);
 	ASSERT(pages_needed <= BITS_PER_LONG);
-	ASSERT(0 == (size & ~IOVP_MASK));
+	ASSERT(0 == (size & ~iovp_mask));
 
 	/*
 	** "seek and ye shall find"...praying never hurts either...
@@ -546,7 +549,7 @@ sba_alloc_range(struct ioc *ioc, size_t 
 
 #ifdef ASSERT_PDIR_SANITY
 	/* verify the first enable bit is clear */
-	if(0x00 != ((u8 *) ioc->pdir_base)[pide*sizeof(u64) + 7]) {
+	if(0x00 != ((u8 *) ioc->pdir_base)[pide*PDIR_ENTRY_SIZE + 7]) {
 		sba_dump_pdir_entry(ioc, "sba_search_bitmap() botched it?", pide);
 	}
 #endif
@@ -556,17 +559,9 @@ sba_alloc_range(struct ioc *ioc, size_t 
 		(uint) ((unsigned long) ioc->res_hint - (unsigned long) ioc->res_map),
 		ioc->res_bitshift );
 
-#if SBA_PROC_FS
-	{
-		unsigned long itc_end = ia64_get_itc();
-		unsigned long tmp = itc_end - itc_start;
-		/* check for roll over */
-		itc_start = (itc_end < itc_start) ?  -(tmp) : (tmp);
-	}
-	ioc->avg_search[ioc->avg_idx++] = itc_start;
+#ifdef PDIR_SEARCH_TIMING
+	ioc->avg_search[ioc->avg_idx++] = ia64_get_itc() - itc_start;
 	ioc->avg_idx &= SBA_SEARCH_SAMPLE - 1;
-
-	ioc->used_pages += pages_needed;
 #endif
 
 	return (pide);
@@ -589,7 +584,7 @@ sba_free_range(struct ioc *ioc, dma_addr
 	unsigned int ridx = pide >> 3;	/* convert bit to byte address */
 	unsigned long *res_ptr = (unsigned long *) &((ioc)->res_map[ridx & ~RESMAP_IDX_MASK]);
 
-	int bits_not_wanted = size >> IOVP_SHIFT;
+	int bits_not_wanted = size >> iovp_shift;
 
 	/* 3-bits "bit" address plus 2 (or 3) bits for "byte" == bit in word */
 	unsigned long m = RESMAP_MASK(bits_not_wanted) << (pide & (BITS_PER_LONG - 1));
@@ -598,13 +593,9 @@ sba_free_range(struct ioc *ioc, dma_addr
 		__FUNCTION__, (uint) iova, size,
 		bits_not_wanted, m, pide, res_ptr, *res_ptr);
 
-#if SBA_PROC_FS
-	ioc->used_pages -= bits_not_wanted;
-#endif
-
 	ASSERT(m != 0);
 	ASSERT(bits_not_wanted);
-	ASSERT((bits_not_wanted * IOVP_SIZE) <= DMA_CHUNK_SIZE);
+	ASSERT((bits_not_wanted * iovp_size) <= DMA_CHUNK_SIZE);
 	ASSERT(bits_not_wanted <= BITS_PER_LONG);
 	ASSERT((*res_ptr & m) == m); /* verify same bits are set */
 	*res_ptr &= ~m;
@@ -702,7 +693,7 @@ sba_mark_invalid(struct ioc *ioc, dma_ad
 
 	/* Must be non-zero and rounded up */
 	ASSERT(byte_cnt > 0);
-	ASSERT(0 == (byte_cnt & ~IOVP_MASK));
+	ASSERT(0 == (byte_cnt & ~iovp_mask));
 
 #ifdef ASSERT_PDIR_SANITY
 	/* Assert first pdir entry is set */
@@ -711,11 +702,11 @@ sba_mark_invalid(struct ioc *ioc, dma_ad
 	}
 #endif
 
-	if (byte_cnt <= IOVP_SIZE)
+	if (byte_cnt <= iovp_size)
 	{
 		ASSERT(off < ioc->pdir_size);
 
-		iovp |= IOVP_SHIFT;     /* set "size" field for PCOM */
+		iovp |= iovp_shift;     /* set "size" field for PCOM */
 
 #ifndef FULL_VALID_PDIR
 		/*
@@ -734,7 +725,7 @@ sba_mark_invalid(struct ioc *ioc, dma_ad
 		ioc->pdir_base[off] = (0x80000000000000FFULL | prefetch_spill_page);
 #endif
 	} else {
-		u32 t = get_order(byte_cnt) + PAGE_SHIFT;
+		u32 t = get_iovp_order(byte_cnt) + iovp_shift;
 
 		iovp |= t;
 		ASSERT(t <= 31);   /* 2GB! Max value of "size" field */
@@ -749,7 +740,7 @@ sba_mark_invalid(struct ioc *ioc, dma_ad
 			ioc->pdir_base[off] = (0x80000000000000FFULL | prefetch_spill_page);
 #endif
 			off++;
-			byte_cnt -= IOVP_SIZE;
+			byte_cnt -= iovp_size;
 		} while (byte_cnt > 0);
 	}
 
@@ -790,11 +781,6 @@ sba_map_single(struct device *dev, void 
  		** Device is bit capable of DMA'ing to the buffer...
 		** just return the PCI address of ptr
  		*/
-#if SBA_PROC_FS
-		spin_lock_irqsave(&ioc->res_lock, flags);
-		ioc->msingle_bypass++;
-		spin_unlock_irqrestore(&ioc->res_lock, flags);
-#endif
 		DBG_BYPASS("sba_map_single() bypass mask/addr: 0x%lx/0x%lx\n",
 		           *dev->dma_mask, pci_addr);
 		return pci_addr;
@@ -805,10 +791,10 @@ sba_map_single(struct device *dev, void 
 	ASSERT(size <= DMA_CHUNK_SIZE);
 
 	/* save offset bits */
-	offset = ((dma_addr_t) (long) addr) & ~IOVP_MASK;
+	offset = ((dma_addr_t) (long) addr) & ~iovp_mask;
 
-	/* round up to nearest IOVP_SIZE */
-	size = (size + offset + ~IOVP_MASK) & IOVP_MASK;
+	/* round up to nearest iovp_size */
+	size = (size + offset + ~iovp_mask) & iovp_mask;
 
 	spin_lock_irqsave(&ioc->res_lock, flags);
 #ifdef ASSERT_PDIR_SANITY
@@ -816,12 +802,8 @@ sba_map_single(struct device *dev, void 
 		panic("Sanity check failed");
 #endif
 
-#if SBA_PROC_FS
-	ioc->msingle_calls++;
-	ioc->msingle_pages += size >> IOVP_SHIFT;
-#endif
 	pide = sba_alloc_range(ioc, size);
-	iovp = (dma_addr_t) pide << IOVP_SHIFT;
+	iovp = (dma_addr_t) pide << iovp_shift;
 
 	DBG_RUN("%s() 0x%p -> 0x%lx\n",
 		__FUNCTION__, addr, (long) iovp | offset);
@@ -834,8 +816,8 @@ sba_map_single(struct device *dev, void 
 
 		DBG_RUN("     pdir 0x%p %lx\n", pdir_start, *pdir_start);
 
-		addr += IOVP_SIZE;
-		size -= IOVP_SIZE;
+		addr += iovp_size;
+		size -= iovp_size;
 		pdir_start++;
 	}
 	/* force pdir update */
@@ -875,11 +857,6 @@ void sba_unmap_single(struct device *dev
 		/*
 		** Address does not fall w/in IOVA, must be bypassing
 		*/
-#if SBA_PROC_FS
-		spin_lock_irqsave(&ioc->res_lock, flags);
-		ioc->usingle_bypass++;
-		spin_unlock_irqrestore(&ioc->res_lock, flags);
-#endif
 		DBG_BYPASS("sba_unmap_single() bypass addr: 0x%lx\n", iova);
 
 #ifdef ENABLE_MARK_CLEAN
@@ -890,20 +867,16 @@ void sba_unmap_single(struct device *dev
 		return;
 	}
 #endif
-	offset = iova & ~IOVP_MASK;
+	offset = iova & ~iovp_mask;
 
 	DBG_RUN("%s() iovp 0x%lx/%x\n",
 		__FUNCTION__, (long) iova, size);
 
 	iova ^= offset;        /* clear offset bits */
 	size += offset;
-	size = ROUNDUP(size, IOVP_SIZE);
+	size = ROUNDUP(size, iovp_size);
 
 	spin_lock_irqsave(&ioc->res_lock, flags);
-#if SBA_PROC_FS
-	ioc->usingle_calls++;
-	ioc->usingle_pages += size >> IOVP_SHIFT;
-#endif
 
 #if DELAYED_RESOURCE_CNT > 0
 	d = &(ioc->saved[ioc->saved_cnt]);
@@ -930,7 +903,7 @@ void sba_unmap_single(struct device *dev
 		int off = PDIR_INDEX(iovp);
 		void *addr;
 
-		if (size <= IOVP_SIZE) {
+		if (size <= iovp_size) {
 			addr = phys_to_virt(ioc->pdir_base[off] &
 					    ~0xE000000000000FFFULL);
 			mark_clean(addr, size);
@@ -940,9 +913,9 @@ void sba_unmap_single(struct device *dev
 			do {
 				addr = phys_to_virt(ioc->pdir_base[off] &
 				                    ~0xE000000000000FFFULL);
-				mark_clean(addr, min(byte_cnt, IOVP_SIZE));
+				mark_clean(addr, min(byte_cnt, iovp_size));
 				off++;
-				byte_cnt -= IOVP_SIZE;
+				byte_cnt -= iovp_size;
 
 			   } while (byte_cnt > 0);
 		}
@@ -1061,11 +1034,11 @@ sba_fill_pdir(
 		*/
 		if (startsg->dma_address & PIDE_FLAG) {
 			u32 pide = startsg->dma_address & ~PIDE_FLAG;
-			dma_offset = (unsigned long) pide & ~IOVP_MASK;
+			dma_offset = (unsigned long) pide & ~iovp_mask;
 			startsg->dma_address = 0;
 			dma_sg++;
 			dma_sg->dma_address = pide | ioc->ibase;
-			pdirp = &(ioc->pdir_base[pide >> IOVP_SHIFT]);
+			pdirp = &(ioc->pdir_base[pide >> iovp_shift]);
 			n_mappings++;
 		}
 
@@ -1082,14 +1055,11 @@ sba_fill_pdir(
 			dma_sg->dma_length += cnt;
 			cnt += dma_offset;
 			dma_offset=0;	/* only want offset on first chunk */
-			cnt = ROUNDUP(cnt, IOVP_SIZE);
-#if SBA_PROC_FS
-			ioc->msg_pages += cnt >> IOVP_SHIFT;
-#endif
+			cnt = ROUNDUP(cnt, iovp_size);
 			do {
 				sba_io_pdir_entry(pdirp, vaddr);
-				vaddr += IOVP_SIZE;
-				cnt -= IOVP_SIZE;
+				vaddr += iovp_size;
+				cnt -= iovp_size;
 				pdirp++;
 			} while (cnt > 0);
 		}
@@ -1107,12 +1077,12 @@ sba_fill_pdir(
 
 /*
 ** Two address ranges are DMA contiguous *iff* "end of prev" and
-** "start of next" are both on a page boundry.
+** "start of next" are both on an IOV page boundary.
 **
 ** (shift left is a quick trick to mask off upper bits)
 */
 #define DMA_CONTIG(__X, __Y) \
-	(((((unsigned long) __X) | ((unsigned long) __Y)) << (BITS_PER_LONG - PAGE_SHIFT)) == 0UL)
+	(((((unsigned long) __X) | ((unsigned long) __Y)) << (BITS_PER_LONG - iovp_shift)) == 0UL)
 
 
 /**
@@ -1150,7 +1120,7 @@ sba_coalesce_chunks( struct ioc *ioc,
 		dma_sg = vcontig_sg = startsg;
 		dma_len = vcontig_len = vcontig_end = startsg->length;
 		vcontig_end +=  vaddr;
-		dma_offset = vaddr & ~IOVP_MASK;
+		dma_offset = vaddr & ~iovp_mask;
 
 		/* PARANOID: clear entries */
 		startsg->dma_address = startsg->dma_length = 0;
@@ -1175,7 +1145,7 @@ sba_coalesce_chunks( struct ioc *ioc,
 			** exceed DMA_CHUNK_SIZE if we coalesce the
 			** next entry.
 			*/
-			if (((dma_len + dma_offset + startsg->length + ~IOVP_MASK) & IOVP_MASK)
+			if (((dma_len + dma_offset + startsg->length + ~iovp_mask) & iovp_mask)
 			    > DMA_CHUNK_SIZE)
 				break;
 
@@ -1194,7 +1164,7 @@ sba_coalesce_chunks( struct ioc *ioc,
 			}
 
 #ifdef DEBUG_LARGE_SG_ENTRIES
-			dump_run_sg = (vcontig_len > IOVP_SIZE);
+			dump_run_sg = (vcontig_len > iovp_size);
 #endif
 
 			/*
@@ -1233,10 +1203,10 @@ sba_coalesce_chunks( struct ioc *ioc,
 		** Allocate space for DMA stream.
 		*/
 		vcontig_sg->dma_length = vcontig_len;
-		dma_len = (dma_len + dma_offset + ~IOVP_MASK) & IOVP_MASK;
+		dma_len = (dma_len + dma_offset + ~iovp_mask) & iovp_mask;
 		ASSERT(dma_len <= DMA_CHUNK_SIZE);
 		dma_sg->dma_address = (dma_addr_t) (PIDE_FLAG
-			| (sba_alloc_range(ioc, dma_len) << IOVP_SHIFT)
+			| (sba_alloc_range(ioc, dma_len) << iovp_shift)
 			| dma_offset);
 		n_mappings++;
 	}
@@ -1273,11 +1243,6 @@ int sba_map_sg(struct device *dev, struc
 			sg->dma_length = sg->length;
 			sg->dma_address = virt_to_phys(sba_sg_address(sg));
 		}
-#if SBA_PROC_FS
-		spin_lock_irqsave(&ioc->res_lock, flags);
-		ioc->msg_bypass++;
-		spin_unlock_irqrestore(&ioc->res_lock, flags);
-#endif
 		return filled;
 	}
 #endif
@@ -1285,13 +1250,7 @@ int sba_map_sg(struct device *dev, struc
 	if (nents == 1) {
 		sglist->dma_length = sglist->length;
 		sglist->dma_address = sba_map_single(dev, sba_sg_address(sglist), sglist->length,
-						     dir);
-#if SBA_PROC_FS
-		/*
-		** Should probably do some stats counting, but trying to
-		** be precise quickly starts wasting CPU time.
-		*/
-#endif
+		                                     dir);
 		return 1;
 	}
 
@@ -1305,10 +1264,6 @@ int sba_map_sg(struct device *dev, struc
 	}
 #endif
 
-#if SBA_PROC_FS
-	ioc->msg_calls++;
-#endif
-
 	/*
 	** First coalesce the chunks and allocate I/O pdir space
 	**
@@ -1368,10 +1323,6 @@ void sba_unmap_sg (struct device *dev, s
 	ioc = GET_IOC(dev);
 	ASSERT(ioc);
 
-#if SBA_PROC_FS
-	ioc->usg_calls++;
-#endif
-
 #ifdef ASSERT_PDIR_SANITY
 	spin_lock_irqsave(&ioc->res_lock, flags);
 	sba_check_pdir(ioc,"Check before sba_unmap_sg()");
@@ -1381,16 +1332,6 @@ void sba_unmap_sg (struct device *dev, s
 	while (nents && sglist->dma_length) {
 
 		sba_unmap_single(dev, sglist->dma_address, sglist->dma_length, dir);
-#if SBA_PROC_FS
-		/*
-		** This leaves inconsistent data in the stats, but we can't
-		** tell which sg lists were mapped by map_single and which
-		** were coalesced to a single entry.  The stats are fun,
-		** but speed is more important.
-		*/
-		ioc->usg_pages += ((sglist->dma_address & ~IOVP_MASK) + sglist->dma_length
-				   + IOVP_SIZE - 1) >> PAGE_SHIFT;
-#endif
 		sglist++;
 		nents--;
 	}
@@ -1414,8 +1355,7 @@ void sba_unmap_sg (struct device *dev, s
 static void __init
 ioc_iova_init(struct ioc *ioc)
 {
-	u32 iova_space_mask;
-	int iov_order, tcnfg;
+	int tcnfg;
 	int agp_found = 0;
 	struct pci_dev *device = NULL;
 #ifdef FULL_VALID_PDIR
@@ -1428,23 +1368,27 @@ ioc_iova_init(struct ioc *ioc)
 	** IBASE and IMASK registers.
 	*/
 	ioc->ibase = READ_REG(ioc->ioc_hpa + IOC_IBASE) & ~0x1UL;
-	ioc->iov_size = ~(READ_REG(ioc->ioc_hpa + IOC_IMASK) & 0xFFFFFFFFUL) + 1;
+	ioc->imask = READ_REG(ioc->ioc_hpa + IOC_IMASK) | 0xFFFFFFFF00000000UL;
 
-	/*
-	** iov_order is always based on a 1GB IOVA space since we want to
-	** turn on the other half for AGP GART.
-	*/
-	iov_order = get_order(ioc->iov_size >> (IOVP_SHIFT - PAGE_SHIFT));
-	ioc->pdir_size = (ioc->iov_size / IOVP_SIZE) * sizeof(u64);
+	ioc->iov_size = ~ioc->imask + 1;
 
-	DBG_INIT("%s() hpa %p IOV %dMB (%d bits) PDIR size 0x%x\n",
-		 __FUNCTION__, ioc->ioc_hpa, ioc->iov_size >> 20,
-		 iov_order + PAGE_SHIFT, ioc->pdir_size);
-
-	/* FIXME : DMA HINTs not used */
-	ioc->hint_shift_pdir = iov_order + PAGE_SHIFT;
-	ioc->hint_mask_pdir = ~(0x3 << (iov_order + PAGE_SHIFT));
+	DBG_INIT("%s() hpa %p IOV base 0x%lx mask 0x%lx (%dMB)\n",
+		__FUNCTION__, ioc->ioc_hpa, ioc->ibase, ioc->imask,
+		ioc->iov_size >> 20);
+
+	switch (iovp_size) {
+		case  4*1024: tcnfg = 0; break;
+		case  8*1024: tcnfg = 1; break;
+		case 16*1024: tcnfg = 2; break;
+		case 64*1024: tcnfg = 3; break;
+		default:
+			panic(PFX "Unsupported IOTLB page size %ldK",
+				iovp_size >> 10);
+			break;
+	}
+	WRITE_REG(tcnfg, ioc->ioc_hpa + IOC_TCNFG);
 
+	ioc->pdir_size = (ioc->iov_size / iovp_size) * PDIR_ENTRY_SIZE;
 	ioc->pdir_base = (void *) __get_free_pages(GFP_KERNEL,
 						   get_order(ioc->pdir_size));
 	if (!ioc->pdir_base)
@@ -1452,61 +1396,12 @@ ioc_iova_init(struct ioc *ioc)
 
 	memset(ioc->pdir_base, 0, ioc->pdir_size);
 
-	DBG_INIT("%s() pdir %p size %x hint_shift_pdir %x hint_mask_pdir %lx\n",
-		__FUNCTION__, ioc->pdir_base, ioc->pdir_size,
-		ioc->hint_shift_pdir, ioc->hint_mask_pdir);
+	DBG_INIT("%s() IOV page size %ldK pdir %p size %x\n", __FUNCTION__,
+		iovp_size >> 10, ioc->pdir_base, ioc->pdir_size);
 
-	ASSERT((((unsigned long) ioc->pdir_base) & PAGE_MASK) == (unsigned long) ioc->pdir_base);
+	ASSERT(ALIGN((unsigned long) ioc->pdir_base, 4*1024) == (unsigned long) ioc->pdir_base);
 	WRITE_REG(virt_to_phys(ioc->pdir_base), ioc->ioc_hpa + IOC_PDIR_BASE);
 
-	DBG_INIT(" base %p\n", ioc->pdir_base);
-
-	/* build IMASK for IOC and Elroy */
-	iova_space_mask =  0xffffffff;
-	iova_space_mask <<= (iov_order + PAGE_SHIFT);
-	ioc->imask = iova_space_mask;
-
-	DBG_INIT("%s() IOV base 0x%lx mask 0x%0lx\n",
-		__FUNCTION__, ioc->ibase, ioc->imask);
-
-	/*
-	** FIXME: Hint registers are programmed with default hint
-	** values during boot, so hints should be sane even if we
-	** can't reprogram them the way drivers want.
-	*/
-	WRITE_REG(ioc->imask, ioc->ioc_hpa + IOC_IMASK);
-
-	/*
-	** Setting the upper bits makes checking for bypass addresses
-	** a little faster later on.
-	*/
-	ioc->imask |= 0xFFFFFFFF00000000UL;
-
-	/* Set I/O PDIR Page size to system page size */
-	switch (PAGE_SHIFT) {
-		case 12: tcnfg = 0; break;	/*  4K */
-		case 13: tcnfg = 1; break;	/*  8K */
-		case 14: tcnfg = 2; break;	/* 16K */
-		case 16: tcnfg = 3; break;	/* 64K */
-		default:
-			panic(PFX "Unsupported system page size %d",
-				1 << PAGE_SHIFT);
-			break;
-	}
-	WRITE_REG(tcnfg, ioc->ioc_hpa + IOC_TCNFG);
-
-	/*
-	** Program the IOC's ibase and enable IOVA translation
-	** Bit zero == enable bit.
-	*/
-	WRITE_REG(ioc->ibase | 1, ioc->ioc_hpa + IOC_IBASE);
-
-	/*
-	** Clear I/O TLB of any possible entries.
-	** (Yes. This is a bit paranoid...but so what)
-	*/
-	WRITE_REG(ioc->ibase | (iov_order+PAGE_SHIFT), ioc->ioc_hpa + IOC_PCOM);
-
 	/*
 	** If an AGP device is present, only use half of the IOV space
 	** for PCI DMA.  Unfortunately we can't know ahead of time
@@ -1519,8 +1414,8 @@ ioc_iova_init(struct ioc *ioc)
 		agp_found |= pci_find_capability(device, PCI_CAP_ID_AGP);
 
 	if (agp_found && reserve_sba_gart) {
-		DBG_INIT("%s: AGP device found, reserving half of IOVA for GART support\n",
-			 __FUNCTION__);
+		printk(KERN_INFO PFX "reserving %dMb of IOVA space at 0x%lx for agpgart\n",
+		      ioc->iov_size/2 >> 20, ioc->ibase + ioc->iov_size/2);
 		ioc->pdir_size /= 2;
 		((u64 *)ioc->pdir_base)[PDIR_INDEX(ioc->iov_size/2)] = ZX1_SBA_IOMMU_COOKIE;
 	}
@@ -1534,12 +1429,12 @@ ioc_iova_init(struct ioc *ioc)
 		int poison_size = 16;
 		void *poison_addr, *addr;
 
-		addr = (void *)__get_free_pages(GFP_KERNEL, get_order(IOVP_SIZE));
+		addr = (void *)__get_free_pages(GFP_KERNEL, get_order(iovp_size));
 		if (!addr)
 			panic(PFX "Couldn't allocate PDIR spill page\n");
 
 		poison_addr = addr;
-		for ( ; (u64) poison_addr < addr + IOVP_SIZE; poison_addr += poison_size)
+		for ( ; (u64) poison_addr < addr + iovp_size; poison_addr += poison_size)
 			memcpy(poison_addr, spill_poison, poison_size);
 
 		prefetch_spill_page = virt_to_phys(addr);
@@ -1549,10 +1444,17 @@ ioc_iova_init(struct ioc *ioc)
 	/*
   	** Set all the PDIR entries valid w/ the spill page as the target
 	*/
-	for (index = 0 ; index < (ioc->pdir_size / sizeof(u64)) ; index++)
+	for (index = 0 ; index < (ioc->pdir_size / PDIR_ENTRY_SIZE) ; index++)
 		((u64 *)ioc->pdir_base)[index] = (0x80000000000000FF | prefetch_spill_page);
 #endif
 
+	/* Clear I/O TLB of any possible entries */
+	WRITE_REG(ioc->ibase | (get_iovp_order(ioc->iov_size) + iovp_shift), ioc->ioc_hpa + IOC_PCOM);
+	READ_REG(ioc->ioc_hpa + IOC_PCOM);
+
+	/* Enable IOVA translation */
+	WRITE_REG(ioc->ibase | 1, ioc->ioc_hpa + IOC_IBASE);
+	READ_REG(ioc->ioc_hpa + IOC_IBASE);
 }
 
 static void __init
@@ -1561,7 +1463,7 @@ ioc_resource_init(struct ioc *ioc)
 	spin_lock_init(&ioc->res_lock);
 
 	/* resource map size dictated by pdir_size */
-	ioc->res_size = ioc->pdir_size / sizeof(u64); /* entries */
+	ioc->res_size = ioc->pdir_size / PDIR_ENTRY_SIZE; /* entries */
 	ioc->res_size >>= 3;  /* convert bit count to byte count */
 	DBG_INIT("%s() res_size 0x%x\n", __FUNCTION__, ioc->res_size);
 
@@ -1582,7 +1484,7 @@ ioc_resource_init(struct ioc *ioc)
 #ifdef FULL_VALID_PDIR
 	/* Mark the last resource used so we don't prefetch beyond IOVA space */
 	ioc->res_map[ioc->res_size - 1] |= 0x80UL; /* res_map is chars */
-	ioc->pdir_base[(ioc->pdir_size / sizeof(u64)) - 1] = (0x80000000000000FF
+	ioc->pdir_base[(ioc->pdir_size / PDIR_ENTRY_SIZE) - 1] = (0x80000000000000FF
 							      | prefetch_spill_page);
 #endif
 
@@ -1627,6 +1529,23 @@ ioc_zx1_init(struct ioc *ioc)
 		panic(PFX "IOC 2.0 or later required for IOMMU support\n");
 
 	ioc->dma_mask = 0xFFFFFFFFFFUL;
+
+	if (!iovp_shift) {
+		/* 64k is max iommu page size */
+		iovp_shift = min(PAGE_SHIFT, 16);
+		iovp_size = (1 << iovp_shift);
+		iovp_mask = ~(iovp_size - 1);
+	}
+}
+
+static void __init
+ioc_sx1000_init(struct ioc *ioc)
+{
+	if (!iovp_shift) {
+		iovp_shift = 12;	/* 4K for now */
+		iovp_size = (1 << iovp_shift);
+		iovp_mask = ~(iovp_size - 1);
+	}
 }
 
 typedef void (initfunc)(struct ioc *);
@@ -1639,8 +1558,8 @@ struct ioc_iommu {
 
 static struct ioc_iommu ioc_iommu_info[] __initdata = {
 	{ ZX1_IOC_ID, "zx1", ioc_zx1_init },
-	{ REO_IOC_ID, "REO" },
-	{ SX1000_IOC_ID, "sx1000" },
+	{ REO_IOC_ID, "REO", ioc_sx1000_init },
+	{ SX1000_IOC_ID, "sx1000", ioc_sx1000_init },
 };
 
 static struct ioc * __init
@@ -1665,6 +1584,11 @@ ioc_init(u64 hpa, void *handle)
 	ioc->rev = READ_REG(ioc->ioc_hpa + IOC_FCLASS) & 0xFFUL;
 	ioc->dma_mask = 0xFFFFFFFFFFFFFFFFUL;	/* conservative */
 
+	if (iovp_shift) {
+		iovp_size = (1 << iovp_shift);
+		iovp_mask = ~(iovp_size - 1);
+	}
+
 	for (info = ioc_iommu_info; info < ioc_iommu_info + ARRAY_SIZE(ioc_iommu_info); info++) {
 		if (ioc->func_id == info->func_id) {
 			ioc->name = info->name;
@@ -1672,6 +1596,8 @@ ioc_init(u64 hpa, void *handle)
 				(info->init)(ioc);
 		}
 	}
+	DBG_INIT("%s: PAGE_SIZE %ldK, iovp_size %ldK\n", __FUNCTION__,
+		PAGE_SIZE >> 10, iovp_size >> 10);
 
 	if (!ioc->name) {
 		ioc->name = kmalloc(24, GFP_KERNEL);
@@ -1686,8 +1612,8 @@ ioc_init(u64 hpa, void *handle)
 	ioc_resource_init(ioc);
 	ioc_sac_init(ioc);
 
-	if ((long) ~IOVP_MASK > (long) ia64_max_iommu_merge_mask)
-		ia64_max_iommu_merge_mask = ~IOVP_MASK;
+	if ((long) ~iovp_mask > (long) ia64_max_iommu_merge_mask)
+		ia64_max_iommu_merge_mask = ~iovp_mask;
 	MAX_DMA_ADDRESS = ~0UL;
 
 	printk(KERN_INFO PFX
@@ -1709,7 +1635,7 @@ ioc_init(u64 hpa, void *handle)
 **
 **************************************************************************/
 
-#if SBA_PROC_FS
+#ifdef CONFIG_PROC_FS
 static void *
 ioc_start(struct seq_file *s, loff_t *pos)
 {
@@ -1741,55 +1667,37 @@ static int
 ioc_show(struct seq_file *s, void *v)
 {
 	struct ioc *ioc = v;
-	int total_pages = (int) (ioc->res_size << 3); /* 8 bits per byte */
-	unsigned long i = 0, avg = 0, min, max;
+	unsigned long *res_ptr = (unsigned long *)ioc->res_map;
+	int i, used = 0;
 
 	seq_printf(s, "Hewlett Packard %s IOC rev %d.%d\n",
 		ioc->name, ((ioc->rev >> 4) & 0xF), (ioc->rev & 0xF));
-	seq_printf(s, "IO PDIR size    : %d bytes (%d entries)\n",
-		(int) ((ioc->res_size << 3) * sizeof(u64)), /* 8 bits/byte */
-		total_pages);
-
-	seq_printf(s, "IO PDIR entries : %ld free  %ld used (%d%%)\n",
-		total_pages - ioc->used_pages, ioc->used_pages,
-		(int) (ioc->used_pages * 100 / total_pages));
-
-	seq_printf(s, "Resource bitmap : %d bytes (%d pages)\n",
-		ioc->res_size, ioc->res_size << 3);   /* 8 bits per byte */
-
-	min = max = ioc->avg_search[0];
-	for (i = 0; i < SBA_SEARCH_SAMPLE; i++) {
-		avg += ioc->avg_search[i];
-		if (ioc->avg_search[i] > max) max = ioc->avg_search[i];
-		if (ioc->avg_search[i] < min) min = ioc->avg_search[i];
-	}
-	avg /= SBA_SEARCH_SAMPLE;
-	seq_printf(s, "  Bitmap search : %ld/%ld/%ld (min/avg/max CPU Cycles)\n", min, avg, max);
-
-	seq_printf(s, "pci_map_single(): %12ld calls  %12ld pages (avg %d/1000)\n",
-		   ioc->msingle_calls, ioc->msingle_pages,
-		   (int) ((ioc->msingle_pages * 1000)/ioc->msingle_calls));
-#ifdef ALLOW_IOV_BYPASS
-	seq_printf(s, "pci_map_single(): %12ld bypasses\n", ioc->msingle_bypass);
-#endif
+	seq_printf(s, "IOVA size       : %d MB\n", ioc->iov_size/(1024*1024));
+	seq_printf(s, "IOVA page size  : %ld kb\n", iovp_size/1024);
 
-	seq_printf(s, "pci_unmap_single: %12ld calls  %12ld pages (avg %d/1000)\n",
-		   ioc->usingle_calls, ioc->usingle_pages,
-		   (int) ((ioc->usingle_pages * 1000)/ioc->usingle_calls));
-#ifdef ALLOW_IOV_BYPASS
-	seq_printf(s, "pci_unmap_single: %12ld bypasses\n", ioc->usingle_bypass);
-#endif
-
-	seq_printf(s, "pci_map_sg()    : %12ld calls  %12ld pages (avg %d/1000)\n",
-		   ioc->msg_calls, ioc->msg_pages,
-		   (int) ((ioc->msg_pages * 1000)/ioc->msg_calls));
-#ifdef ALLOW_IOV_BYPASS
-	seq_printf(s, "pci_map_sg()    : %12ld bypasses\n", ioc->msg_bypass);
-#endif
+	for (i = 0; i < (ioc->res_size / sizeof(unsigned long)); ++i, ++res_ptr)
+		used += hweight64(*res_ptr);
 
-	seq_printf(s, "pci_unmap_sg()  : %12ld calls  %12ld pages (avg %d/1000)\n",
-		   ioc->usg_calls, ioc->usg_pages, (int) ((ioc->usg_pages * 1000)/ioc->usg_calls));
+	seq_printf(s, "PDIR size       : %d entries\n", ioc->res_size << 3);
+	seq_printf(s, "PDIR used       : %d entries\n", used);
 
+#ifdef PDIR_SEARCH_TIMING
+	{
+		unsigned long i = 0, avg = 0, min, max;
+		min = max = ioc->avg_search[0];
+		for (i = 0; i < SBA_SEARCH_SAMPLE; i++) {
+			avg += ioc->avg_search[i];
+			if (ioc->avg_search[i] > max) max = ioc->avg_search[i];
+			if (ioc->avg_search[i] < min) min = ioc->avg_search[i];
+		}
+		avg /= SBA_SEARCH_SAMPLE;
+		seq_printf(s, "Bitmap search   : %ld/%ld/%ld (min/avg/max CPU Cycles)\n",
+		           min, avg, max);
+	}
+#endif
+#ifndef ALLOW_IOV_BYPASS
+	 seq_printf(s, "IOVA bypass disabled\n");
+#endif
 	return 0;
 }
 
@@ -1813,39 +1721,6 @@ static struct file_operations ioc_fops =
 	.release = seq_release
 };
 
-static int
-ioc_map_show(struct seq_file *s, void *v)
-{
-	struct ioc *ioc = v;
-	unsigned int i, *res_ptr = (unsigned int *)ioc->res_map;
-
-	for (i = 0; i < ioc->res_size / sizeof(unsigned int); ++i, ++res_ptr)
-		seq_printf(s, "%s%08x", (i & 7) ? " " : "\n   ", *res_ptr);
-	seq_printf(s, "\n");
-
-	return 0;
-}
-
-static struct seq_operations ioc_map_ops = {
-	.start = ioc_start,
-	.next  = ioc_next,
-	.stop  = ioc_stop,
-	.show  = ioc_map_show
-};
-
-static int
-ioc_map_open(struct inode *inode, struct file *file)
-{
-	return seq_open(file, &ioc_map_ops);
-}
-
-static struct file_operations ioc_map_fops = {
-	.open    = ioc_map_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release
-};
-
 static void __init
 ioc_proc_init(void)
 {
@@ -1858,10 +1733,6 @@ ioc_proc_init(void)
 	entry = create_proc_entry(ioc_list->name, 0, dir);
 	if (entry)
 		entry->proc_fops = &ioc_fops;
-
-	entry = create_proc_entry("bitmap", 0, dir);
-	if (entry)
-		entry->proc_fops = &ioc_map_fops;
 }
 #endif
 
@@ -1958,7 +1829,7 @@ sba_init(void)
 	}
 #endif
 
-#if SBA_PROC_FS
+#ifdef CONFIG_PROC_FS
 	ioc_proc_init();
 #endif
 	return 0;
@@ -1982,6 +1853,29 @@ sba_dma_supported (struct device *dev, u
 
 __setup("nosbagart", nosbagart);
 
+static int __init
+sba_page_override(char *str)
+{
+	unsigned long page_size;
+
+	page_size = memparse(str, &str);
+	switch (page_size) {
+		case 4096:
+		case 8192:
+		case 16384:
+		case 65536:
+			iovp_shift = ffs(page_size) - 1;
+			break;
+		default:
+			printk("%s: unknown/unsupported iommu page size %ld\n",
+			       __FUNCTION__, page_size);
+	}
+
+	return 1;
+}
+
+__setup("sbapagesize=",sba_page_override);
+
 EXPORT_SYMBOL(sba_map_single);
 EXPORT_SYMBOL(sba_unmap_single);
 EXPORT_SYMBOL(sba_map_sg);
diff -puN arch/ia64/ia32/sys_ia32.c~linus arch/ia64/ia32/sys_ia32.c
--- 25/arch/ia64/ia32/sys_ia32.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/ia32/sys_ia32.c	2004-01-19 22:17:20.000000000 -0800
@@ -741,7 +741,7 @@ filldir32 (void *__buf, const char *name
 	    || copy_to_user(dirent->d_name, name, namlen)
 	    || put_user(0, dirent->d_name + namlen))
 		return -EFAULT;
-	((char *) dirent) += reclen;
+	dirent = (struct compat_dirent *) ((char *) dirent + reclen);
 	buf->current_dir = dirent;
 	buf->count -= reclen;
 	return 0;
diff -puN arch/ia64/Kconfig~linus arch/ia64/Kconfig
--- 25/arch/ia64/Kconfig~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/Kconfig	2004-01-19 22:17:20.000000000 -0800
@@ -33,6 +33,10 @@ config TIME_INTERPOLATION
 	bool
 	default y
 
+config EFI
+	bool
+	default y
+
 choice
 	prompt "IA-64 processor type"
 	default ITANIUM
@@ -66,26 +70,18 @@ config IA64_GENERIC
 	  will run on any supported IA-64 system.  However, if you configure
 	  a kernel for your specific system, it will be faster and smaller.
 
-	  To find out what type of IA-64 system you have, you may want to
-	  check the IA-64 Linux web site at <http://www.linux-ia64.org/>.
-	  As of the time of this writing, most hardware is DIG compliant,
-	  so the "DIG-compliant" option is usually the right choice.
-
-	  HP-simulator   For the HP simulator
-	  (<http://software.hp.com/ia64linux/>).
-	  HP-zx1         For HP zx1-based systems.
-	  SGI-SN2	 For SGI Altix systems
 	  DIG-compliant  For DIG ("Developer's Interface Guide") compliant
-	  systems.
+	  systems
+	  HP-zx1         For HP systems
+	  SGI-SN2	 For SGI Altix systems
+	  Ski-simulator  For the HP simulator
+	  (<http://www.hpl.hp.com/research/linux/ski/>)
 
 	  If you don't know what to do, choose "generic".
 
 config IA64_DIG
 	bool "DIG-compliant"
 
-config IA64_HP_SIM
-	bool "HP-simulator"
-
 config IA64_HP_ZX1
 	bool "HP-zx1"
 	help
@@ -96,6 +92,9 @@ config IA64_HP_ZX1
 config IA64_SGI_SN2
 	bool "SGI-SN2"
 
+config IA64_HP_SIM
+	bool "Ski-simulator"
+
 endchoice
 
 choice
@@ -395,11 +394,6 @@ config IA64_PALINFO
 	  support" (CONFIG_PROC_FS) is enabled, too.
 
 
-config EFI
-	bool
-	depends on !IA64_HP_SIM
-	default y
-
 config EFI_VARS
 	tristate "/proc/efi/vars support"
 	help
@@ -411,7 +405,8 @@ config EFI_VARS
 	  support" (CONFIG_PROC_FS) is enabled, too.
 
 config NR_CPUS
-	int "Maximum number of CPUs"
+	int "Maximum number of CPUs (2-512)"
+	range 2 512
 	depends on SMP
 	default "64"
 	help
diff -puN arch/ia64/kernel/acpi.c~linus arch/ia64/kernel/acpi.c
--- 25/arch/ia64/kernel/acpi.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/kernel/acpi.c	2004-01-19 22:17:20.000000000 -0800
@@ -32,6 +32,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/module.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -53,6 +54,7 @@
 #define PREFIX			"ACPI: "
 
 void (*pm_idle) (void);
+EXPORT_SYMBOL(pm_idle);
 void (*pm_power_off) (void);
 
 unsigned char acpi_kbd_controller_present = 1;
@@ -629,5 +631,6 @@ acpi_register_irq (u32 gsi, u32 polarity
 			(polarity == ACPI_ACTIVE_HIGH) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW,
 			(trigger == ACPI_EDGE_SENSITIVE) ? IOSAPIC_EDGE : IOSAPIC_LEVEL);
 }
+EXPORT_SYMBOL(acpi_register_irq);
 
 #endif /* CONFIG_ACPI_BOOT */
diff -puN arch/ia64/kernel/efi.c~linus arch/ia64/kernel/efi.c
--- 25/arch/ia64/kernel/efi.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/kernel/efi.c	2004-01-19 22:17:20.000000000 -0800
@@ -19,6 +19,7 @@
  *	Skip non-WB memory and ignore empty memory ranges.
  */
 #include <linux/config.h>
+#include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/types.h>
@@ -37,6 +38,7 @@
 extern efi_status_t efi_call_phys (void *, ...);
 
 struct efi efi;
+EXPORT_SYMBOL(efi);
 static efi_runtime_services_t *runtime;
 
 /*
@@ -48,6 +50,7 @@ static efi_runtime_services_t *runtime;
  */
 #ifdef CONFIG_PROC_FS
 struct proc_dir_entry *efi_dir;
+EXPORT_SYMBOL(efi_dir);
 #endif
 
 static unsigned long mem_limit = ~0UL;
diff -puN arch/ia64/kernel/ia64_ksyms.c~linus arch/ia64/kernel/ia64_ksyms.c
--- 25/arch/ia64/kernel/ia64_ksyms.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/kernel/ia64_ksyms.c	2004-01-19 22:17:20.000000000 -0800
@@ -1,15 +1,18 @@
 /*
  * Architecture-specific kernel symbols
+ *
+ * Don't put any exports here unless it's defined in an assembler file.
+ * All other exports should be put directly after the definition.
  */
 
 #include <linux/config.h>
 #include <linux/module.h>
 
 #include <linux/string.h>
-EXPORT_SYMBOL_NOVERS(memset);			/* gcc generates direct calls to memset()... */
+EXPORT_SYMBOL(memset);
 EXPORT_SYMBOL(memchr);
 EXPORT_SYMBOL(memcmp);
-EXPORT_SYMBOL_NOVERS(memcpy);
+EXPORT_SYMBOL(memcpy);
 EXPORT_SYMBOL(memmove);
 EXPORT_SYMBOL(memscan);
 EXPORT_SYMBOL(strcat);
@@ -25,77 +28,28 @@ EXPORT_SYMBOL(strrchr);
 EXPORT_SYMBOL(strstr);
 EXPORT_SYMBOL(strpbrk);
 
-#include <linux/irq.h>
-EXPORT_SYMBOL(isa_irq_to_vector_map);
-EXPORT_SYMBOL(enable_irq);
-EXPORT_SYMBOL(disable_irq);
-EXPORT_SYMBOL(disable_irq_nosync);
-
-#include <linux/interrupt.h>
-EXPORT_SYMBOL(probe_irq_mask);
-
 #include <asm/checksum.h>
 EXPORT_SYMBOL(ip_fast_csum);		/* hand-coded assembly */
 
-#include <asm/io.h>
-EXPORT_SYMBOL(__ia64_memcpy_fromio);
-EXPORT_SYMBOL(__ia64_memcpy_toio);
-EXPORT_SYMBOL(__ia64_memset_c_io);
-EXPORT_SYMBOL(io_space);
-
 #include <asm/semaphore.h>
-EXPORT_SYMBOL_NOVERS(__down);
-EXPORT_SYMBOL_NOVERS(__down_interruptible);
-EXPORT_SYMBOL_NOVERS(__down_trylock);
-EXPORT_SYMBOL_NOVERS(__up);
+EXPORT_SYMBOL(__down);
+EXPORT_SYMBOL(__down_interruptible);
+EXPORT_SYMBOL(__down_trylock);
+EXPORT_SYMBOL(__up);
 
 #include <asm/page.h>
 EXPORT_SYMBOL(clear_page);
 
 #ifdef CONFIG_VIRTUAL_MEM_MAP
 #include <linux/bootmem.h>
-#include <asm/pgtable.h>
-EXPORT_SYMBOL(vmalloc_end);
-EXPORT_SYMBOL(ia64_pfn_valid);
 EXPORT_SYMBOL(max_low_pfn);	/* defined by bootmem.c, but not exported by generic code */
 #endif
 
 #include <asm/processor.h>
 EXPORT_SYMBOL(per_cpu__cpu_info);
 #ifdef CONFIG_SMP
-EXPORT_SYMBOL(__per_cpu_offset);
 EXPORT_SYMBOL(per_cpu__local_per_cpu_offset);
 #endif
-EXPORT_SYMBOL(kernel_thread);
-
-#include <asm/system.h>
-#ifdef CONFIG_IA64_DEBUG_IRQ
-EXPORT_SYMBOL(last_cli_ip);
-#endif
-
-#include <asm/tlbflush.h>
-
-EXPORT_SYMBOL(flush_tlb_range);
-
-#ifdef CONFIG_SMP
-
-EXPORT_SYMBOL(smp_flush_tlb_all);
-
-#include <asm/current.h>
-#include <asm/hardirq.h>
-EXPORT_SYMBOL(synchronize_irq);
-
-#include <asm/smp.h>
-EXPORT_SYMBOL(smp_call_function);
-EXPORT_SYMBOL(smp_call_function_single);
-EXPORT_SYMBOL(cpu_online_map);
-EXPORT_SYMBOL(phys_cpu_present_map);
-EXPORT_SYMBOL(ia64_cpu_to_sapicid);
-#else /* !CONFIG_SMP */
-
-EXPORT_SYMBOL(local_flush_tlb_all);
-
-#endif /* !CONFIG_SMP */
 
 #include <asm/uaccess.h>
 EXPORT_SYMBOL(__copy_user);
@@ -117,14 +71,14 @@ extern void __udivdi3(void);
 extern void __moddi3(void);
 extern void __umoddi3(void);
 
-EXPORT_SYMBOL_NOVERS(__divsi3);
-EXPORT_SYMBOL_NOVERS(__udivsi3);
-EXPORT_SYMBOL_NOVERS(__modsi3);
-EXPORT_SYMBOL_NOVERS(__umodsi3);
-EXPORT_SYMBOL_NOVERS(__divdi3);
-EXPORT_SYMBOL_NOVERS(__udivdi3);
-EXPORT_SYMBOL_NOVERS(__moddi3);
-EXPORT_SYMBOL_NOVERS(__umoddi3);
+EXPORT_SYMBOL(__divsi3);
+EXPORT_SYMBOL(__udivsi3);
+EXPORT_SYMBOL(__modsi3);
+EXPORT_SYMBOL(__umodsi3);
+EXPORT_SYMBOL(__divdi3);
+EXPORT_SYMBOL(__udivdi3);
+EXPORT_SYMBOL(__moddi3);
+EXPORT_SYMBOL(__umoddi3);
 
 #if defined(CONFIG_MD_RAID5) || defined(CONFIG_MD_RAID5_MODULE)
 extern void xor_ia64_2(void);
@@ -132,15 +86,12 @@ extern void xor_ia64_3(void);
 extern void xor_ia64_4(void);
 extern void xor_ia64_5(void);
 
-EXPORT_SYMBOL_NOVERS(xor_ia64_2);
-EXPORT_SYMBOL_NOVERS(xor_ia64_3);
-EXPORT_SYMBOL_NOVERS(xor_ia64_4);
-EXPORT_SYMBOL_NOVERS(xor_ia64_5);
+EXPORT_SYMBOL(xor_ia64_2);
+EXPORT_SYMBOL(xor_ia64_3);
+EXPORT_SYMBOL(xor_ia64_4);
+EXPORT_SYMBOL(xor_ia64_5);
 #endif
 
-extern unsigned long ia64_iobase;
-EXPORT_SYMBOL(ia64_iobase);
-
 #include <asm/pal.h>
 EXPORT_SYMBOL(ia64_pal_call_phys_stacked);
 EXPORT_SYMBOL(ia64_pal_call_phys_static);
@@ -149,44 +100,8 @@ EXPORT_SYMBOL(ia64_pal_call_static);
 EXPORT_SYMBOL(ia64_load_scratch_fpregs);
 EXPORT_SYMBOL(ia64_save_scratch_fpregs);
 
-extern struct efi efi;
-EXPORT_SYMBOL(efi);
-
-#include <linux/proc_fs.h>
-extern struct proc_dir_entry *efi_dir;
-EXPORT_SYMBOL(efi_dir);
-
-#include <asm/machvec.h>
-#ifdef CONFIG_IA64_GENERIC
-EXPORT_SYMBOL(ia64_mv);
-#endif
-EXPORT_SYMBOL(machvec_noop);
-EXPORT_SYMBOL(machvec_memory_fence);
-EXPORT_SYMBOL(zero_page_memmap_ptr);
-#ifdef CONFIG_PERFMON
-#include <asm/perfmon.h>
-EXPORT_SYMBOL(pfm_register_buffer_fmt);
-EXPORT_SYMBOL(pfm_unregister_buffer_fmt);
-EXPORT_SYMBOL(pfm_mod_fast_read_pmds);
-EXPORT_SYMBOL(pfm_mod_read_pmds);
-EXPORT_SYMBOL(pfm_mod_write_pmcs);
-#endif
-
-#ifdef CONFIG_NUMA
-#include <asm/numa.h>
-EXPORT_SYMBOL(cpu_to_node_map);
-#endif
-
 #include <asm/unwind.h>
-EXPORT_SYMBOL(unw_init_from_blocked_task);
 EXPORT_SYMBOL(unw_init_running);
-EXPORT_SYMBOL(unw_unwind);
-EXPORT_SYMBOL(unw_unwind_to_user);
-EXPORT_SYMBOL(unw_access_gr);
-EXPORT_SYMBOL(unw_access_br);
-EXPORT_SYMBOL(unw_access_fr);
-EXPORT_SYMBOL(unw_access_ar);
-EXPORT_SYMBOL(unw_access_pr);
 
 #ifdef CONFIG_SMP
 # if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 3)
@@ -205,8 +120,3 @@ extern char ia64_spinlock_contention;
 EXPORT_SYMBOL(ia64_spinlock_contention);
 # endif
 #endif
-
-EXPORT_SYMBOL(ia64_max_iommu_merge_mask);
-
-#include <linux/pm.h>
-EXPORT_SYMBOL(pm_idle);
diff -puN arch/ia64/kernel/irq.c~linus arch/ia64/kernel/irq.c
--- 25/arch/ia64/kernel/irq.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/kernel/irq.c	2004-01-19 22:17:20.000000000 -0800
@@ -226,6 +226,7 @@ inline void synchronize_irq(unsigned int
 	while (irq_descp(irq)->status & IRQ_INPROGRESS)
 		cpu_relax();
 }
+EXPORT_SYMBOL(synchronize_irq);
 #endif
 
 /*
@@ -367,6 +368,7 @@ inline void disable_irq_nosync(unsigned 
 	}
 	spin_unlock_irqrestore(&desc->lock, flags);
 }
+EXPORT_SYMBOL(disable_irq_nosync);
 
 /**
  *	disable_irq - disable an irq and wait for completion
@@ -389,6 +391,7 @@ void disable_irq(unsigned int irq)
 	if (desc->action)
 		synchronize_irq(irq);
 }
+EXPORT_SYMBOL(disable_irq);
 
 /**
  *	enable_irq - enable handling of an irq
@@ -427,6 +430,7 @@ void enable_irq(unsigned int irq)
 	}
 	spin_unlock_irqrestore(&desc->lock, flags);
 }
+EXPORT_SYMBOL(enable_irq);
 
 /*
  * do_IRQ handles all normal device IRQ's (the special
@@ -795,6 +799,7 @@ unsigned int probe_irq_mask(unsigned lon
 
 	return mask & val;
 }
+EXPORT_SYMBOL(probe_irq_mask);
 
 /**
  *	probe_irq_off	- end an interrupt autodetect
diff -puN arch/ia64/kernel/irq_ia64.c~linus arch/ia64/kernel/irq_ia64.c
--- 25/arch/ia64/kernel/irq_ia64.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/kernel/irq_ia64.c	2004-01-19 22:17:20.000000000 -0800
@@ -13,6 +13,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/module.h>
 
 #include <linux/jiffies.h>
 #include <linux/errno.h>
@@ -54,6 +55,7 @@ __u8 isa_irq_to_vector_map[16] = {
 	0x2f, 0x20, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29,
 	0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21
 };
+EXPORT_SYMBOL(isa_irq_to_vector_map);
 
 int
 ia64_alloc_vector (void)
diff -puN arch/ia64/kernel/machvec.c~linus arch/ia64/kernel/machvec.c
--- 25/arch/ia64/kernel/machvec.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/kernel/machvec.c	2004-01-19 22:17:20.000000000 -0800
@@ -1,4 +1,5 @@
 #include <linux/config.h>
+#include <linux/module.h>
 
 #include <asm/system.h>
 
@@ -11,6 +12,7 @@
 #include <asm/page.h>
 
 struct ia64_machine_vector ia64_mv;
+EXPORT_SYMBOL(ia64_mv);
 
 static struct ia64_machine_vector *
 lookup_machvec (const char *name)
@@ -45,9 +47,11 @@ void
 machvec_noop (void)
 {
 }
+EXPORT_SYMBOL(machvec_noop);
 
 void
 machvec_memory_fence (void)
 {
 	mb();
 }
+EXPORT_SYMBOL(machvec_memory_fence);
diff -puN arch/ia64/kernel/perfmon.c~linus arch/ia64/kernel/perfmon.c
--- 25/arch/ia64/kernel/perfmon.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/kernel/perfmon.c	2004-01-19 22:17:20.000000000 -0800
@@ -20,6 +20,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/interrupt.h>
@@ -1042,12 +1043,10 @@ pfm_restore_pmds(unsigned long *pmds, un
 	int i;
 	unsigned long val, ovfl_val = pmu_conf.ovfl_val;
 
-	DPRINT(("mask=0x%lx\n", mask));
 	for (i=0; mask; i++, mask>>=1) {
 		if ((mask & 0x1) == 0) continue;
 		val = PMD_IS_COUNTING(i) ? pmds[i] & ovfl_val : pmds[i];
 		ia64_set_pmd(i, val);
-		DPRINT(("pmd[%d]=0x%lx\n", i, val));
 	}
 	ia64_srlz_d();
 }
@@ -1115,11 +1114,9 @@ pfm_restore_pmcs(unsigned long *pmcs, un
 {
 	int i;
 
-	DPRINT(("mask=0x%lx\n", mask));
 	for (i=0; mask; i++, mask>>=1) {
 		if ((mask & 0x1) == 0) continue;
 		ia64_set_pmc(i, pmcs[i]);
-		DPRINT(("pmc[%d]=0x%lx\n", i, pmcs[i]));
 	}
 	ia64_srlz_d();
 }
@@ -1259,6 +1256,7 @@ out:
 	spin_unlock(&pfm_buffer_fmt_lock);
  	return ret;
 }
+EXPORT_SYMBOL(pfm_register_buffer_fmt);
 
 int
 pfm_unregister_buffer_fmt(pfm_uuid_t uuid)
@@ -1282,6 +1280,7 @@ out:
 	return ret;
 
 }
+EXPORT_SYMBOL(pfm_unregister_buffer_fmt);
 
 static int
 pfm_reserve_session(struct task_struct *task, int is_syswide, unsigned int cpu)
@@ -2157,6 +2156,7 @@ pfm_alloc_fd(struct file **cfile)
 
 	d_add(file->f_dentry, inode);
 	file->f_vfsmnt = mntget(pfmfs_mnt);
+	file->f_mapping = inode->i_mapping;
 
 	file->f_op    = &pfm_file_ops;
 	file->f_mode  = FMODE_READ;
@@ -3421,6 +3421,7 @@ pfm_mod_write_pmcs(struct task_struct *t
 
 	return pfm_write_pmcs(ctx, req, nreq, regs);
 }
+EXPORT_SYMBOL(pfm_mod_write_pmcs);
 
 long
 pfm_mod_read_pmds(struct task_struct *task, pfarg_reg_t *req, unsigned int nreq, struct pt_regs *regs)
@@ -3442,6 +3443,7 @@ pfm_mod_read_pmds(struct task_struct *ta
 
 	return pfm_read_pmds(ctx, req, nreq, regs);
 }
+EXPORT_SYMBOL(pfm_mod_read_pmds);
 
 long
 pfm_mod_fast_read_pmds(struct task_struct *task, unsigned long mask[4], unsigned long *addr, struct pt_regs *regs)
@@ -3483,6 +3485,7 @@ pfm_mod_fast_read_pmds(struct task_struc
 	}
 	return 0;
 }
+EXPORT_SYMBOL(pfm_mod_fast_read_pmds);
 
 /*
  * Only call this function when a process it trying to
@@ -5670,7 +5673,7 @@ pfm_save_regs(struct task_struct *task)
 
 
 	ctx = PFM_GET_CTX(task);
-	if (ctx == NULL) goto save_error;
+	if (ctx == NULL) return;
 	t = &task->thread;
 
 	/*
@@ -5685,8 +5688,6 @@ pfm_save_regs(struct task_struct *task)
 
 		pfm_clear_psr_up();
 
-		DPRINT(("ctx zombie, forcing cleanup for [%d]\n", task->pid));
-
 		pfm_force_cleanup(ctx, regs);
 
 		BUG_ON(ctx->ctx_smpl_hdr);
@@ -5701,12 +5702,7 @@ pfm_save_regs(struct task_struct *task)
 	 * sanity check
 	 */
 	if (ctx->ctx_last_activation != GET_ACTIVATION()) {
-		printk("ctx_activation=%lu activation=%lu state=%d: no save\n",
-				ctx->ctx_last_activation,
-				GET_ACTIVATION(), ctx->ctx_state);
-
 		pfm_unprotect_ctx_ctxsw(ctx, flags);
-
 		return;
 	}
 
@@ -5763,13 +5759,6 @@ pfm_save_regs(struct task_struct *task)
 	 * interrupts will still be masked after this call.
 	 */
 	pfm_unprotect_ctx_ctxsw(ctx, flags);
-
-	return;
-
-save_error:
-	printk(KERN_ERR "perfmon: pfm_save_regs CPU%d [%d] NULL context PM_VALID=%ld\n",
-		smp_processor_id(), task->pid,
-		task->thread.flags & IA64_THREAD_PM_VALID);
 }
 
 #else /* !CONFIG_SMP */
@@ -5780,7 +5769,7 @@ pfm_save_regs(struct task_struct *task)
 	u64 psr;
 
 	ctx = PFM_GET_CTX(task);
-	if (ctx == NULL) goto save_error;
+	if (ctx == NULL) return;
 
 	/*
 	 * save current PSR: needed because we modify it
@@ -5802,12 +5791,6 @@ pfm_save_regs(struct task_struct *task)
 	 * keep a copy of psr.up (for reload)
 	 */
 	ctx->ctx_saved_psr_up = psr & IA64_PSR_UP;
-
-	return;
-save_error:
-	printk(KERN_ERR "perfmon: pfm_save_regs CPU%d [%d] NULL context PM_VALID=%ld\n",
-		smp_processor_id(), task->pid,
-		task->thread.flags & IA64_THREAD_PM_VALID);
 }
 
 static void
@@ -5824,8 +5807,6 @@ pfm_lazy_save_regs (struct task_struct *
 	ctx = PFM_GET_CTX(task);
 	t   = &task->thread;
 
-	DPRINT(("on [%d] used_pmds=0x%lx\n", task->pid, ctx->ctx_used_pmds[0]));
-
 	/*
 	 * we need to mask PMU overflow here to
 	 * make sure that we maintain pmc0 until
@@ -5886,10 +5867,7 @@ pfm_load_regs (struct task_struct *task)
 	u64 psr, psr_up;
 
 	ctx = PFM_GET_CTX(task);
-	if (unlikely(ctx == NULL)) {
-		printk(KERN_ERR "perfmon: pfm_load_regs() null context\n");
-		return;
-	}
+	if (unlikely(ctx == NULL)) return;
 
 	BUG_ON(GET_PMU_OWNER());
 
@@ -5897,10 +5875,7 @@ pfm_load_regs (struct task_struct *task)
 	/*
 	 * possible on unload
 	 */
-	if (unlikely((t->flags & IA64_THREAD_PM_VALID) == 0)) {
-		printk("[%d] PM_VALID=0, nothing to do\n", task->pid);
-		return;
-	}
+	if (unlikely((t->flags & IA64_THREAD_PM_VALID) == 0)) return;
 
 	/*
  	 * we always come here with interrupts ALREADY disabled by
@@ -5918,8 +5893,6 @@ pfm_load_regs (struct task_struct *task)
 
 		BUG_ON(ctx->ctx_smpl_hdr);
 
-		DPRINT(("ctx zombie, forcing cleanup for [%d]\n", task->pid));
-
 		pfm_force_cleanup(ctx, regs);
 
 		pfm_unprotect_ctx_ctxsw(ctx, flags);
@@ -5957,7 +5930,6 @@ pfm_load_regs (struct task_struct *task)
 		pmc_mask = ctx->ctx_reload_pmcs[0];
 		pmd_mask = ctx->ctx_reload_pmds[0];
 
-		if (pmc_mask || pmd_mask) DPRINT(("partial reload [%d] pmd_mask=0x%lx pmc_mask=0x%lx\n", task->pid, pmd_mask, pmc_mask));
 	} else {
 		/*
 	 	 * To avoid leaking information to the user level when psr.sp=0,
@@ -5975,12 +5947,6 @@ pfm_load_regs (struct task_struct *task)
 	 	 * PMC0 is never in the mask. It is always restored separately.
 	 	 */
 		pmc_mask = ctx->ctx_all_pmcs[0];
-
-		DPRINT(("full reload for [%d] activation=%lu last_activation=%lu last_cpu=%d pmd_mask=0x%lx pmc_mask=0x%lx\n",
-			task->pid,
-			GET_ACTIVATION(), ctx->ctx_last_activation,
-			GET_LAST_CPU(ctx), pmd_mask, pmc_mask));
-
 	}
 	/*
 	 * when context is MASKED, we will restore PMC with plm=0
@@ -6008,7 +5974,6 @@ pfm_load_regs (struct task_struct *task)
 		/*
 		 * will replay the PMU interrupt
 		 */
-		DPRINT(("perfmon: resend irq for [%d]\n", task->pid));
 		hw_resend_irq(NULL, IA64_PERFMON_VECTOR);
 #endif
 		pfm_stats[smp_processor_id()].pfm_replay_ovfl_intr_count++;
@@ -6102,8 +6067,6 @@ pfm_load_regs (struct task_struct *task)
 		return;
 	}
 
-	DPRINT(("reload for [%d] owner=%d\n", task->pid, owner ? owner->pid : -1));
-
 	/*
 	 * someone else is still using the PMU, first push it out and
 	 * then we'll be able to install our stuff !
@@ -6150,7 +6113,6 @@ pfm_load_regs (struct task_struct *task)
 		/*
 		 * will replay the PMU interrupt
 		 */
-		DPRINT(("perfmon: resend irq for [%d]\n", task->pid));
 		hw_resend_irq(NULL, IA64_PERFMON_VECTOR);
 #endif
 		pfm_stats[smp_processor_id()].pfm_replay_ovfl_intr_count++;
diff -puN arch/ia64/kernel/process.c~linus arch/ia64/kernel/process.c
--- 25/arch/ia64/kernel/process.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/kernel/process.c	2004-01-19 22:17:20.000000000 -0800
@@ -598,6 +598,7 @@ kernel_thread (int (*fn)(void *), void *
 	}
 	return tid;
 }
+EXPORT_SYMBOL(kernel_thread);
 
 /*
  * Flush thread state.  This is called when a thread does an execve().
diff -puN arch/ia64/kernel/setup.c~linus arch/ia64/kernel/setup.c
--- 25/arch/ia64/kernel/setup.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/kernel/setup.c	2004-01-19 22:17:20.000000000 -0800
@@ -17,6 +17,7 @@
  * 06/24/99 W.Drummond	added boot_cpu_data.
  */
 #include <linux/config.h>
+#include <linux/module.h>
 #include <linux/init.h>
 
 #include <linux/acpi.h>
@@ -54,12 +55,9 @@
 # error "struct cpuinfo_ia64 too big!"
 #endif
 
-#ifdef CONFIG_EFI
-int efi_enabled = 1;
-#endif
-
 #ifdef CONFIG_SMP
 unsigned long __per_cpu_offset[NR_CPUS];
+EXPORT_SYMBOL(__per_cpu_offset);
 #endif
 
 DEFINE_PER_CPU(struct cpuinfo_ia64, cpu_info);
@@ -71,7 +69,9 @@ struct screen_info screen_info;
 
 unsigned long ia64_max_cacheline_size;
 unsigned long ia64_iobase;	/* virtual address for I/O accesses */
+EXPORT_SYMBOL(ia64_iobase);
 struct io_space io_space[MAX_IO_SPACES];
+EXPORT_SYMBOL(io_space);
 unsigned int num_io_spaces;
 
 unsigned char aux_device_present = 0xaa;        /* XXX remove this when legacy I/O is gone */
@@ -86,6 +86,7 @@ unsigned char aux_device_present = 0xaa;
  * page-size of 2^64.
  */
 unsigned long ia64_max_iommu_merge_mask = ~0UL;
+EXPORT_SYMBOL(ia64_max_iommu_merge_mask);
 
 #define COMMAND_LINE_SIZE	512
 
@@ -317,13 +318,13 @@ setup_arch (char **cmdline_p)
 #ifdef CONFIG_ACPI_BOOT
 	acpi_boot_init();
 #endif
+#ifdef CONFIG_SERIAL_8250_CONSOLE
 #ifdef CONFIG_SERIAL_8250_HCDP
 	if (efi.hcdp) {
 		void setup_serial_hcdp(void *);
 		setup_serial_hcdp(efi.hcdp);
 	}
 #endif
-#ifdef CONFIG_SERIAL_8250_CONSOLE
 	/*
 	 * Without HCDP, we won't discover any serial ports until the serial driver looks
 	 * in the ACPI namespace.  If ACPI claims there are some legacy devices, register
@@ -520,8 +521,6 @@ identify_cpu (struct cpuinfo_ia64 *c)
 		impl_va_msb = vm2.pal_vm_info_2_s.impl_va_msb;
 		phys_addr_size = vm1.pal_vm_info_1_s.phys_add_size;
 	}
-	printk(KERN_INFO "CPU %d: %lu virtual and %lu physical address bits\n",
-	       smp_processor_id(), impl_va_msb + 1, phys_addr_size);
 	c->unimpl_va_mask = ~((7L<<61) | ((1L << (impl_va_msb + 1)) - 1));
 	c->unimpl_pa_mask = ~((1L<<63) | ((1L << phys_addr_size) - 1));
 }
diff -puN arch/ia64/kernel/smpboot.c~linus arch/ia64/kernel/smpboot.c
--- 25/arch/ia64/kernel/smpboot.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/kernel/smpboot.c	2004-01-19 22:17:20.000000000 -0800
@@ -16,6 +16,7 @@
 
 #include <linux/config.h>
 
+#include <linux/module.h>
 #include <linux/acpi.h>
 #include <linux/bootmem.h>
 #include <linux/delay.h>
@@ -81,10 +82,13 @@ task_t *task_for_booting_cpu;
 
 /* Bitmask of currently online CPUs */
 cpumask_t cpu_online_map;
+EXPORT_SYMBOL(cpu_online_map);
 cpumask_t phys_cpu_present_map;
+EXPORT_SYMBOL(phys_cpu_present_map);
 
 /* which logical CPU number maps to which CPU (physical APIC ID) */
 volatile int ia64_cpu_to_sapicid[NR_CPUS];
+EXPORT_SYMBOL(ia64_cpu_to_sapicid);
 
 static volatile cpumask_t cpu_callin_map;
 
@@ -401,10 +405,7 @@ do_boot_cpu (int sapicid, int cpu)
 	}
 	Dprintk("\n");
 
-	if (cpu_isset(cpu, cpu_callin_map)) {
-		/* number CPUs logically, starting from 1 (BSP is 0) */
-		printk(KERN_INFO "CPU%d: CPU has booted.\n", cpu);
-	} else {
+	if (!cpu_isset(cpu, cpu_callin_map)) {
 		printk(KERN_ERR "Processor 0x%x/0x%x is stuck.\n", cpu, sapicid);
 		ia64_cpu_to_sapicid[cpu] = -1;
 		cpu_clear(cpu, cpu_online_map);  /* was set in smp_callin() */
@@ -467,6 +468,7 @@ smp_build_cpu_map (void)
 
 /* on which node is each logical CPU (one cacheline even for 64 CPUs) */
 volatile u8 cpu_to_node_map[NR_CPUS] __cacheline_aligned;
+EXPORT_SYMBOL(cpu_to_node_map);
 /* which logical CPUs are on which nodes */
 volatile cpumask_t node_to_cpu_mask[MAX_NUMNODES] __cacheline_aligned;
 
@@ -578,14 +580,11 @@ __cpu_up (unsigned int cpu)
 	if (sapicid == -1)
 		return -EINVAL;
 
-	printk(KERN_INFO "Processor %d/%d is spinning up...\n", sapicid, cpu);
-
 	/* Processor goes to start_secondary(), sets online flag */
 	ret = do_boot_cpu(sapicid, cpu);
 	if (ret < 0)
 		return ret;
 
-	printk(KERN_INFO "Processor %d has spun up...\n", cpu);
 	return 0;
 }
 
diff -puN arch/ia64/kernel/smp.c~linus arch/ia64/kernel/smp.c
--- 25/arch/ia64/kernel/smp.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/kernel/smp.c	2004-01-19 22:17:20.000000000 -0800
@@ -22,6 +22,7 @@
 
 #include <linux/config.h>
 
+#include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/init.h>
@@ -210,6 +211,7 @@ smp_flush_tlb_all (void)
 {
 	on_each_cpu((void (*)(void *))local_flush_tlb_all, 0, 1, 1);
 }
+EXPORT_SYMBOL(smp_flush_tlb_all);
 
 void
 smp_flush_tlb_mm (struct mm_struct *mm)
@@ -283,6 +285,7 @@ smp_call_function_single (int cpuid, voi
 	put_cpu();
 	return 0;
 }
+EXPORT_SYMBOL(smp_call_function_single);
 
 /*
  * this function sends a 'generic call function' IPI to all other CPUs
@@ -337,6 +340,7 @@ smp_call_function (void (*func) (void *i
 	spin_unlock(&call_lock);
 	return 0;
 }
+EXPORT_SYMBOL(smp_call_function);
 
 void
 smp_do_timer (struct pt_regs *regs)
diff -puN arch/ia64/kernel/time.c~linus arch/ia64/kernel/time.c
--- 25/arch/ia64/kernel/time.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/kernel/time.c	2004-01-19 22:17:20.000000000 -0800
@@ -39,6 +39,7 @@ EXPORT_SYMBOL(jiffies_64);
 #ifdef CONFIG_IA64_DEBUG_IRQ
 
 unsigned long last_cli_ip;
+EXPORT_SYMBOL(last_cli_ip);
 
 #endif
 
diff -puN arch/ia64/kernel/unwind.c~linus arch/ia64/kernel/unwind.c
--- 25/arch/ia64/kernel/unwind.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/kernel/unwind.c	2004-01-19 22:17:20.000000000 -0800
@@ -26,6 +26,7 @@
  *	o if both the unw.lock spinlock and a script's read-write lock must be
  *	  acquired, then the read-write lock must be acquired first.
  */
+#include <linux/module.h>
 #include <linux/bootmem.h>
 #include <linux/elf.h>
 #include <linux/kernel.h>
@@ -392,6 +393,7 @@ unw_access_gr (struct unw_frame_info *in
 	}
 	return 0;
 }
+EXPORT_SYMBOL(unw_access_gr);
 
 int
 unw_access_br (struct unw_frame_info *info, int regnum, unsigned long *val, int write)
@@ -423,6 +425,7 @@ unw_access_br (struct unw_frame_info *in
 		*val = *addr;
 	return 0;
 }
+EXPORT_SYMBOL(unw_access_br);
 
 int
 unw_access_fr (struct unw_frame_info *info, int regnum, struct ia64_fpreg *val, int write)
@@ -467,6 +470,7 @@ unw_access_fr (struct unw_frame_info *in
 		*val = *addr;
 	return 0;
 }
+EXPORT_SYMBOL(unw_access_fr);
 
 int
 unw_access_ar (struct unw_frame_info *info, int regnum, unsigned long *val, int write)
@@ -559,6 +563,7 @@ unw_access_ar (struct unw_frame_info *in
 		*val = *addr;
 	return 0;
 }
+EXPORT_SYMBOL(unw_access_ar);
 
 int
 unw_access_pr (struct unw_frame_info *info, unsigned long *val, int write)
@@ -575,6 +580,7 @@ unw_access_pr (struct unw_frame_info *in
 		*val = *addr;
 	return 0;
 }
+EXPORT_SYMBOL(unw_access_pr);
 
 
 /* Routines to manipulate the state stack.  */
@@ -1897,6 +1903,7 @@ unw_unwind (struct unw_frame_info *info)
 	STAT(unw.stat.api.unwind_time += ia64_get_itc() - start; local_irq_restore(flags));
 	return retval;
 }
+EXPORT_SYMBOL(unw_unwind);
 
 int
 unw_unwind_to_user (struct unw_frame_info *info)
@@ -1917,6 +1924,7 @@ unw_unwind_to_user (struct unw_frame_inf
 	UNW_DPRINT(0, "unwind.%s: failed to unwind to user-level (ip=0x%lx)\n", __FUNCTION__, ip);
 	return -1;
 }
+EXPORT_SYMBOL(unw_unwind_to_user);
 
 static void
 init_frame_info (struct unw_frame_info *info, struct task_struct *t,
@@ -2014,6 +2022,7 @@ unw_init_from_blocked_task (struct unw_f
 	UNW_DPRINT(1, "unwind.%s\n", __FUNCTION__);
 	unw_init_frame_info(info, t, sw);
 }
+EXPORT_SYMBOL(unw_init_from_blocked_task);
 
 static void
 init_unwind_table (struct unw_table *table, const char *name, unsigned long segment_base,
diff -puN arch/ia64/lib/io.c~linus arch/ia64/lib/io.c
--- 25/arch/ia64/lib/io.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/lib/io.c	2004-01-19 22:17:20.000000000 -0800
@@ -1,4 +1,5 @@
 #include <linux/config.h>
+#include <linux/module.h>
 #include <linux/types.h>
 
 #include <asm/io.h>
@@ -17,6 +18,7 @@ __ia64_memcpy_fromio (void * to, unsigne
 		from++;
 	}
 }
+EXPORT_SYMBOL(__ia64_memcpy_fromio);
 
 /*
  * Copy data from "real" memory space to IO memory space.
@@ -32,6 +34,7 @@ __ia64_memcpy_toio (unsigned long to, vo
 		to++;
 	}
 }
+EXPORT_SYMBOL(__ia64_memcpy_toio);
 
 /*
  * "memset" on IO memory space.
@@ -48,6 +51,7 @@ __ia64_memset_c_io (unsigned long dst, u
 		dst++;
 	}
 }
+EXPORT_SYMBOL(__ia64_memset_c_io);
 
 #ifdef CONFIG_IA64_GENERIC
 
diff -puN arch/ia64/lib/Makefile~linus arch/ia64/lib/Makefile
--- 25/arch/ia64/lib/Makefile~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/lib/Makefile	2004-01-19 22:17:20.000000000 -0800
@@ -2,11 +2,13 @@
 # Makefile for ia64-specific library routines..
 #
 
+obj-y := io.o
+
 lib-y := __divsi3.o __udivsi3.o __modsi3.o __umodsi3.o			\
 	__divdi3.o __udivdi3.o __moddi3.o __umoddi3.o			\
 	checksum.o clear_page.o csum_partial_copy.o copy_page.o		\
 	clear_user.o strncpy_from_user.o strlen_user.o strnlen_user.o	\
-	flush.o io.o ip_fast_csum.o do_csum.o				\
+	flush.o ip_fast_csum.o do_csum.o				\
 	memset.o strlen.o swiotlb.o
 
 lib-$(CONFIG_ITANIUM)	+= copy_page.o copy_user.o memcpy.o
diff -puN arch/ia64/lib/memcpy_mck.S~linus arch/ia64/lib/memcpy_mck.S
--- 25/arch/ia64/lib/memcpy_mck.S~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/lib/memcpy_mck.S	2004-01-19 22:17:20.000000000 -0800
@@ -155,7 +155,7 @@ GLOBAL_ENTRY(__copy_user)
 	mov	ar.ec=2
 (p10)	br.dpnt.few .aligned_src_tail
 	;;
-//	.align 32
+	TEXT_ALIGN(32)
 1:
 EX(.ex_handler, (p16)	ld8	r34=[src0],16)
 EK(.ex_handler, (p16)	ld8	r38=[src1],16)
@@ -312,7 +312,7 @@ EK(.ex_handler,	(p[D])	st8 [dst1] = t15,
 (p7)	mov	ar.lc = r21
 (p8)	mov	ar.lc = r0
 	;;
-//	.align 32
+	TEXT_ALIGN(32)
 1:	lfetch.fault	  [src_pre_mem], 128
 	lfetch.fault.excl [dst_pre_mem], 128
 	br.cloop.dptk.few 1b
@@ -518,7 +518,7 @@ EK(.ex_handler,  (p17)	st8	[dst1]=r39,8)
 		 shrp	r21=r22,r38,shift;	/* speculative work */			\
 		 br.sptk.few .unaligned_src_tail /* branch out of jump table */		\
 		 ;;
-//	.align 32
+	TEXT_ALIGN(32)
 .jump_table:
 	COPYU(8)	// unaligned cases
 .jmp1:
diff -puN arch/ia64/lib/memset.S~linus arch/ia64/lib/memset.S
--- 25/arch/ia64/lib/memset.S~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/lib/memset.S	2004-01-19 22:17:20.000000000 -0800
@@ -125,7 +125,7 @@ GLOBAL_ENTRY(memset)
 (p_zr)	br.cond.dptk.many .l1b			// Jump to use stf.spill
 ;; }
 
-//	.align 32 // -------------------------- //  L1A: store ahead into cache lines; fill later
+	TEXT_ALIGN(32) // --------------------- //  L1A: store ahead into cache lines; fill later
 { .mmi
 	and	tmp = -(LINE_SIZE), cnt		// compute end of range
 	mov	ptr9 = ptr1			// used for prefetching
@@ -194,7 +194,7 @@ GLOBAL_ENTRY(memset)
 	br.cond.dpnt.many  .move_bytes_from_alignment	// Branch no. 3
 ;; }
 
-//	.align 32
+	TEXT_ALIGN(32)
 .l1b:	// ------------------------------------ //  L1B: store ahead into cache lines; fill later
 { .mmi
 	and	tmp = -(LINE_SIZE), cnt		// compute end of range
@@ -261,7 +261,7 @@ GLOBAL_ENTRY(memset)
 	and	cnt = 0x1f, cnt			// compute the remaining cnt
 	mov.i   ar.lc = loopcnt
 ;; }
-//	.align 32
+	TEXT_ALIGN(32)
 .l2:	// ------------------------------------ //  L2A:  store 32B in 2 cycles
 { .mmb
 	stf8	[ptr1] = fvalue, 8
diff -puN arch/ia64/Makefile~linus arch/ia64/Makefile
--- 25/arch/ia64/Makefile~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/Makefile	2004-01-19 22:17:20.000000000 -0800
@@ -5,10 +5,11 @@
 # License.  See the file "COPYING" in the main directory of this archive
 # for more details.
 #
-# Copyright (C) 1998-2003 by David Mosberger-Tang <davidm@hpl.hp.com>
+# Copyright (C) 1998-2004 by David Mosberger-Tang <davidm@hpl.hp.com>
 #
 
 NM := $(CROSS_COMPILE)nm -B
+READELF := $(CROSS_COMPILE)readelf
 
 export AWK
 
@@ -25,9 +26,8 @@ CFLAGS_KERNEL	:= -mconstant-gp
 GCC_VERSION=$(shell $(CC) -v 2>&1 | fgrep 'gcc version' | cut -f3 -d' ' | cut -f1 -d'.')
 GCC_MINOR_VERSION=$(shell $(CC) -v 2>&1 | fgrep 'gcc version' | cut -f3 -d' ' | cut -f2 -d'.')
 
-GAS_STATUS=$(shell $(srctree)/arch/ia64/scripts/check-gas $(CC) $(OBJDUMP))
-
-CPPFLAGS	+= $(shell $(srctree)/arch/ia64/scripts/toolchain-flags $(CC) $(OBJDUMP))
+GAS_STATUS	= $(shell $(srctree)/arch/ia64/scripts/check-gas $(CC) $(OBJDUMP))
+CPPFLAGS += $(shell $(srctree)/arch/ia64/scripts/toolchain-flags $(CC) $(OBJDUMP) $(READELF))
 
 ifeq ($(GAS_STATUS),buggy)
 $(error Sorry, you need a newer version of the assember, one that is built from	\
@@ -71,15 +71,15 @@ boot := arch/ia64/hp/sim/boot
 
 .PHONY: boot compressed check
 
-all: compressed
+all: compressed unwcheck
 
 compressed: vmlinux.gz
 
 vmlinux.gz: vmlinux
 	$(Q)$(MAKE) $(build)=$(boot) $@
 
-check: vmlinux
-	arch/ia64/scripts/unwcheck.sh $<
+unwcheck: vmlinux
+	-$(Q)READELF=$(READELF) $(srctree)/arch/ia64/scripts/unwcheck.py $<
 
 archclean:
 	$(Q)$(MAKE) $(clean)=$(boot)
@@ -88,7 +88,7 @@ CLEAN_FILES += include/asm-ia64/.offsets
 
 prepare: include/asm-ia64/offsets.h
 
-arch/ia64/kernel/asm-offsets.s: include/asm include/linux/version.h
+arch/ia64/kernel/asm-offsets.s: include/asm include/linux/version.h include/config/MARKER
 
 include/asm-ia64/offsets.h: arch/ia64/kernel/asm-offsets.s
 	$(call filechk,gen-asm-offsets)
@@ -108,4 +108,5 @@ boot:	lib/lib.a vmlinux
 define archhelp
   echo '* compressed	- Build compressed kernel image'
   echo '  boot		- Build vmlinux and bootloader for Ski simulator'
+  echo '* unwcheck	- Check vmlinux for invalid unwind info'
 endef
diff -puN arch/ia64/mm/extable.c~linus arch/ia64/mm/extable.c
--- 25/arch/ia64/mm/extable.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/mm/extable.c	2004-01-19 22:17:20.000000000 -0800
@@ -10,6 +10,11 @@
 #include <asm/uaccess.h>
 #include <asm/module.h>
 
+void sort_extable(struct exception_table_entry *start,
+		  struct exception_table_entry *finish)
+{
+}
+
 const struct exception_table_entry *
 search_extable (const struct exception_table_entry *first,
 		const struct exception_table_entry *last,
diff -puN arch/ia64/mm/init.c~linus arch/ia64/mm/init.c
--- 25/arch/ia64/mm/init.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/mm/init.c	2004-01-19 22:17:20.000000000 -0800
@@ -43,15 +43,16 @@ extern void ia64_tlb_init (void);
 unsigned long MAX_DMA_ADDRESS = PAGE_OFFSET + 0x100000000UL;
 
 #ifdef CONFIG_VIRTUAL_MEM_MAP
-  unsigned long vmalloc_end = VMALLOC_END_INIT;
-  struct page *vmem_map;
-
-  EXPORT_SYMBOL(vmem_map);
+unsigned long vmalloc_end = VMALLOC_END_INIT;
+EXPORT_SYMBOL(vmalloc_end);
+struct page *vmem_map;
+EXPORT_SYMBOL(vmem_map);
 #endif
 
 static int pgt_cache_water[2] = { 25, 50 };
 
 struct page *zero_page_memmap_ptr;		/* map entry for zero page */
+EXPORT_SYMBOL(zero_page_memmap_ptr);
 
 void
 check_pgt_cache (void)
@@ -457,6 +458,7 @@ ia64_pfn_valid (unsigned long pfn)
 
 	return __get_user(byte, (char *) pfn_to_page(pfn)) == 0;
 }
+EXPORT_SYMBOL(ia64_pfn_valid);
 
 int
 find_largest_hole (u64 start, u64 end, void *arg)
diff -puN arch/ia64/mm/numa.c~linus arch/ia64/mm/numa.c
--- 25/arch/ia64/mm/numa.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/mm/numa.c	2004-01-19 22:17:20.000000000 -0800
@@ -18,6 +18,7 @@
 #include <linux/node.h>
 #include <linux/init.h>
 #include <linux/bootmem.h>
+#include <asm/mmzone.h>
 #include <asm/numa.h>
 
 static struct memblk *sysfs_memblks;
@@ -28,7 +29,7 @@ static struct cpu *sysfs_cpus;
  * The following structures are usually initialized by ACPI or
  * similar mechanisms and describe the NUMA characteristics of the machine.
  */
-int num_memblks = 0;
+int num_memblks;
 struct node_memblk_s node_memblk[NR_MEMBLKS];
 struct node_cpuid_s node_cpuid[NR_CPUS];
 /*
diff -puN arch/ia64/mm/tlb.c~linus arch/ia64/mm/tlb.c
--- 25/arch/ia64/mm/tlb.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/mm/tlb.c	2004-01-19 22:17:20.000000000 -0800
@@ -10,6 +10,7 @@
  *              IPI based ptc implementation and A-step IPI implementation.
  */
 #include <linux/config.h>
+#include <linux/module.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -126,6 +127,7 @@ local_flush_tlb_all (void)
 	local_irq_restore(flags);
 	ia64_srlz_i();			/* srlz.i implies srlz.d */
 }
+EXPORT_SYMBOL(local_flush_tlb_all);
 
 void
 flush_tlb_range (struct vm_area_struct *vma, unsigned long start, unsigned long end)
@@ -162,6 +164,7 @@ flush_tlb_range (struct vm_area_struct *
 
 	ia64_srlz_i();			/* srlz.i implies srlz.d */
 }
+EXPORT_SYMBOL(flush_tlb_range);
 
 void __init
 ia64_tlb_init (void)
diff -puN arch/ia64/pci/pci.c~linus arch/ia64/pci/pci.c
--- 25/arch/ia64/pci/pci.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/pci/pci.c	2004-01-19 22:17:20.000000000 -0800
@@ -223,6 +223,9 @@ add_window (struct acpi_resource *res, v
 
 	status = acpi_resource_to_address64(res, &addr);
 	if (ACPI_SUCCESS(status)) {
+		if (!addr.address_length)
+			return AE_OK;
+
 		if (addr.resource_type == ACPI_MEMORY_RANGE) {
 			flags = IORESOURCE_MEM;
 			root = &iomem_resource;
diff -puN /dev/null arch/ia64/scripts/check-text-align.S
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/ia64/scripts/check-text-align.S	2004-01-19 22:17:20.000000000 -0800
@@ -0,0 +1,6 @@
+	.proc foo
+	.prologue
+foo:	.save rp, r2
+	nop 0
+	.align 64
+	.endp foo
diff -puN /dev/null arch/ia64/scripts/unwcheck.py
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/ia64/scripts/unwcheck.py	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+#
+# Usage: unwcheck.py FILE
+#
+# This script checks the unwind info of each function in file FILE
+# and verifies that the sum of the region-lengths matches the total
+# length of the function.
+#
+# Based on a shell/awk script originally written by Harish Patil,
+# which was converted to Perl by Matthew Chapman, which was converted
+# to Python by David Mosberger.
+#
+import os
+import re
+import sys
+
+if len(sys.argv) != 2:
+    print "Usage: %s FILE" % sys.argv[0]
+    sys.exit(2)
+
+readelf = os.getenv("READELF", "readelf")
+
+start_pattern = re.compile("<([^>]*)>: \[0x([0-9a-f]+)-0x([0-9a-f]+)\]")
+rlen_pattern  = re.compile(".*rlen=([0-9]+)")
+
+def check_func (func, slots, rlen_sum):
+    if slots != rlen_sum:
+        global num_errors
+        num_errors += 1
+        if not func: func = "[%#x-%#x]" % (start, end)
+        print "ERROR: %s: %lu slots, total region length = %lu" % (func, slots, rlen_sum)
+    return
+
+num_funcs = 0
+num_errors = 0
+func = False
+slots = 0
+rlen_sum = 0
+for line in os.popen("%s -u %s" % (readelf, sys.argv[1])):
+    m = start_pattern.match(line)
+    if m:
+        check_func(func, slots, rlen_sum)
+
+        func  = m.group(1)
+        start = long(m.group(2), 16)
+        end   = long(m.group(3), 16)
+        slots = 3 * (end - start) / 16
+        rlen_sum = 0L
+        num_funcs += 1
+    else:
+        m = rlen_pattern.match(line)
+        if m:
+            rlen_sum += long(m.group(1))
+check_func(func, slots, rlen_sum)
+
+if num_errors == 0:
+    print "No errors detected in %u functions." % num_funcs
+else:
+    if num_errors > 1:
+        err="errors"
+    else:
+        err="error"
+    print "%u %s detected in %u functions." % (num_errors, err, num_funcs)
+    sys.exit(1)
diff -puN -L arch/ia64/scripts/unwcheck.sh arch/ia64/scripts/unwcheck.sh~linus /dev/null
--- 25/arch/ia64/scripts/unwcheck.sh
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,109 +0,0 @@
-#!/bin/sh
-#   Usage: unwcheck.sh <executable_file_name>
-#   Pre-requisite: readelf [from Gnu binutils package]
-#   Purpose: Check the following invariant
-#       For each code range in the input binary:
-#          Sum[ lengths of unwind regions] = Number of slots in code range.
-#   Author : Harish Patil
-#   First version: January 2002
-#   Modified : 2/13/2002
-#   Modified : 3/15/2002: duplicate detection
-readelf -u $1 | gawk '\
- function todec(hexstr){
-    dec = 0;
-    l = length(hexstr);
-    for (i = 1; i <= l; i++)
-    {
-        c = substr(hexstr, i, 1);
-        if (c == "A")
-            dec = dec*16 + 10;
-        else if (c == "B")
-            dec = dec*16 + 11;
-        else if (c == "C")
-            dec = dec*16 + 12;
-        else if (c == "D")
-            dec = dec*16 + 13;
-        else if (c == "E")
-            dec = dec*16 + 14;
-        else if (c == "F")
-            dec = dec*16 + 15;
-        else
-            dec = dec*16 + c;
-    }
-    return dec;
- }
- BEGIN { first = 1; sum_rlen = 0; no_slots = 0; errors=0; no_code_ranges=0; }
- {
-   if (NF==5 && $3=="info")
-   {
-      no_code_ranges += 1;
-      if (first == 0)
-      {
-         if (sum_rlen != no_slots)
-         {
-            print full_code_range;
-            print "       ", "lo = ", lo, " hi =", hi;
-            print "       ", "sum_rlen = ", sum_rlen, "no_slots = " no_slots;
-            print "       ","   ", "*******ERROR ***********";
-            print "       ","   ", "sum_rlen:", sum_rlen, " != no_slots:" no_slots;
-            errors += 1;
-         }
-         sum_rlen = 0;
-      }
-      full_code_range =  $0;
-      code_range =  $2;
-      gsub("..$", "", code_range);
-      gsub("^.", "", code_range);
-      split(code_range, addr, "-");
-      lo = toupper(addr[1]);
-
-      code_range_lo[no_code_ranges] = addr[1];
-      occurs[addr[1]] += 1;
-      full_range[addr[1]] = $0;
-
-      gsub("0X.[0]*", "", lo);
-      hi = toupper(addr[2]);
-      gsub("0X.[0]*", "", hi);
-      no_slots = (todec(hi) - todec(lo))/ 16*3
-      first = 0;
-   }
-   if (index($0,"rlen") > 0 )
-   {
-    rlen_str =  substr($0, index($0,"rlen"));
-    rlen = rlen_str;
-    gsub("rlen=", "", rlen);
-    gsub(")", "", rlen);
-    sum_rlen = sum_rlen +  rlen;
-   }
-  }
-  END {
-      if (first == 0)
-      {
-         if (sum_rlen != no_slots)
-         {
-            print "code_range=", code_range;
-            print "       ", "lo = ", lo, " hi =", hi;
-            print "       ", "sum_rlen = ", sum_rlen, "no_slots = " no_slots;
-            print "       ","   ", "*******ERROR ***********";
-            print "       ","   ", "sum_rlen:", sum_rlen, " != no_slots:" no_slots;
-            errors += 1;
-         }
-      }
-    no_duplicates = 0;
-    for (i=1; i<=no_code_ranges; i++)
-    {
-        cr = code_range_lo[i];
-        if (reported_cr[cr]==1) continue;
-        if ( occurs[cr] > 1)
-        {
-            reported_cr[cr] = 1;
-            print "Code range low ", code_range_lo[i], ":", full_range[cr], " occurs: ", occurs[cr], " times.";
-            print " ";
-            no_duplicates++;
-        }
-    }
-    print "======================================"
-    print "Total errors:", errors, "/", no_code_ranges, " duplicates:", no_duplicates;
-    print "======================================"
-  }
-  '
diff -puN arch/ia64/sn/fakeprom/fprom.lds~linus arch/ia64/sn/fakeprom/fprom.lds
--- 25/arch/ia64/sn/fakeprom/fprom.lds~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/fakeprom/fprom.lds	2004-01-19 22:17:21.000000000 -0800
@@ -1,33 +1,9 @@
 /*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
  * Copyright (c) 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
- * 
- * This program is free software; you can redistribute it and/or modify it 
- * under the terms of version 2 of the GNU General Public License 
- * as published by the Free Software Foundation.
- * 
- * This program is distributed in the hope that it would be useful, but 
- * WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * 
- * Further, this software is distributed without any warranty that it is 
- * free of the rightful claim of any third person regarding infringement 
- * or the like.  Any license provided herein, whether implied or 
- * otherwise, applies only to this software file.  Patent licenses, if 
- * any, provided herein do not apply to combinations of this program with 
- * other software, or any other product whatsoever.
- * 
- * You should have received a copy of the GNU General Public 
- * License along with this program; if not, write the Free Software 
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- * 
- * Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 
- * Mountain View, CA  94043, or:
- * 
- * http://www.sgi.com 
- * 
- * For further information regarding this notice, see: 
- * 
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan
  */
 
 OUTPUT_FORMAT("elf64-ia64-little")
diff -puN arch/ia64/sn/fakeprom/README~linus arch/ia64/sn/fakeprom/README
--- 25/arch/ia64/sn/fakeprom/README~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/fakeprom/README	2004-01-19 22:17:21.000000000 -0800
@@ -1,33 +1,9 @@
 /*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
  * Copyright (c) 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
- * 
- * This program is free software; you can redistribute it and/or modify it 
- * under the terms of version 2 of the GNU General Public License 
- * as published by the Free Software Foundation.
- * 
- * This program is distributed in the hope that it would be useful, but 
- * WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * 
- * Further, this software is distributed without any warranty that it is 
- * free of the rightful claim of any third person regarding infringement 
- * or the like.  Any license provided herein, whether implied or 
- * otherwise, applies only to this software file.  Patent licenses, if 
- * any, provided herein do not apply to combinations of this program with 
- * other software, or any other product whatsoever.
- * 
- * You should have received a copy of the GNU General Public 
- * License along with this program; if not, write the Free Software 
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- * 
- * Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 
- * Mountain View, CA  94043, or:
- * 
- * http://www.sgi.com 
- * 
- * For further information regarding this notice, see: 
- * 
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan
  */
 
 This directory contains the files required to build
diff -puN arch/ia64/sn/io/cdl.c~linus arch/ia64/sn/io/cdl.c
--- 25/arch/ia64/sn/io/cdl.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/cdl.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -11,18 +10,15 @@
 #include <linux/types.h>
 #include <asm/sn/sgi.h>
 #include <asm/io.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
-#include <asm/sn/pci/bridge.h>
+#include <asm/sn/pci/pic.h>
 #include "asm/sn/ioerror_handling.h"
 #include <asm/sn/xtalk/xbow.h>
 
 /* these get called directly in cdl_add_connpt in fops bypass hack */
-extern int pcibr_attach(vertex_hdl_t);
 extern int xbow_attach(vertex_hdl_t);
 extern int pic_attach(vertex_hdl_t);
 
-
 /*
  *    cdl: Connection and Driver List
  *
@@ -32,14 +28,12 @@ extern int pic_attach(vertex_hdl_t);
  *	IO Infrastructure Drivers e.g. pcibr.
  */
 
-#define MAX_SGI_IO_INFRA_DRVR 7
+#define MAX_SGI_IO_INFRA_DRVR 5
 
 static struct cdl sgi_infrastructure_drivers[MAX_SGI_IO_INFRA_DRVR] =
 {
-	{ XBRIDGE_WIDGET_PART_NUM, XBRIDGE_WIDGET_MFGR_NUM, pcibr_attach /* &pcibr_fops  */},
-	{ BRIDGE_WIDGET_PART_NUM,  BRIDGE_WIDGET_MFGR_NUM,  pcibr_attach /* &pcibr_fops */},
-	{ PIC_WIDGET_PART_NUM_BUS0,  PIC_WIDGET_MFGR_NUM,   pic_attach /* &pic_fops */},
-	{ PIC_WIDGET_PART_NUM_BUS1,  PIC_WIDGET_MFGR_NUM,   pic_attach /* &pic_fops */},
+	{ PIC_WIDGET_PART_NUM_BUS0,  PIC_WIDGET_MFGR_NUM,   pic_attach /* &pcibr_fops */},
+	{ PIC_WIDGET_PART_NUM_BUS1,  PIC_WIDGET_MFGR_NUM,   pic_attach /* &pcibr_fops */},
 	{ XXBOW_WIDGET_PART_NUM,   XXBOW_WIDGET_MFGR_NUM,   xbow_attach /* &xbow_fops */},
 	{ XBOW_WIDGET_PART_NUM,    XBOW_WIDGET_MFGR_NUM,    xbow_attach /* &xbow_fops */},
 	{ PXBOW_WIDGET_PART_NUM,   XXBOW_WIDGET_MFGR_NUM,   xbow_attach /* &xbow_fops */},
diff -puN arch/ia64/sn/io/drivers/ioconfig_bus.c~linus arch/ia64/sn/io/drivers/ioconfig_bus.c
--- 25/arch/ia64/sn/io/drivers/ioconfig_bus.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/drivers/ioconfig_bus.c	2004-01-19 22:17:21.000000000 -0800
@@ -19,7 +19,6 @@
 #include <asm/sn/sgi.h>
 #include <asm/io.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/labelcl.h>
 #include <asm/sn/sn_sal.h>
@@ -34,6 +33,7 @@
  */
 static vertex_hdl_t ioconfig_bus_handle;
 static unsigned long ioconfig_bus_debug;
+static struct ioconfig_parm parm;
 
 #ifdef IOCONFIG_BUS_DEBUG
 #define DBG(x...)	printk(x)
@@ -41,8 +41,6 @@ static unsigned long ioconfig_bus_debug;
 #define DBG(x...)
 #endif
 
-static u64 ioconfig_file;
-static u64 ioconfig_file_size;
 static u64 ioconfig_activated;
 static char ioconfig_kernopts[128];
 
@@ -50,8 +48,6 @@ static char ioconfig_kernopts[128];
  * For debugging purpose .. hardcode a table ..
  */
 struct  ascii_moduleid *ioconfig_bus_table;
-u64 ioconfig_bus_table_size;
-
 
 static int free_entry;
 static int new_entry;
@@ -68,6 +64,8 @@ ioconfig_get_busnum(char *io_moduleid, i
 
 	*bus_num = -1;
 	temp = ioconfig_bus_table;
+	if (!ioconfig_bus_table)
+		return;
 	for (index = 0; index < free_entry; temp++, index++) {
 		if ( (io_moduleid[0] == temp->io_moduleid[0]) &&
 		     (io_moduleid[1] == temp->io_moduleid[1]) &&
@@ -101,6 +99,10 @@ dump_ioconfig_table(void)
 	struct ascii_moduleid *temp;
 
 	temp = ioconfig_bus_table;
+	if (!temp) {
+		DBG("ioconfig_bus_table tabel empty\n");
+		return;
+	}
 	while (index < free_entry) {
 		DBG("ASSCI Module ID %s\n", temp->io_moduleid);
 		temp++;
@@ -145,7 +147,7 @@ int nextline(char *buffer, char **next, 
  *	memory by ioconfig command in EFI and builds the
  *	persistent pci bus naming table.
  */
-void
+int
 build_moduleid_table(char *file_contents, struct ascii_moduleid *table)
 {
 	/*
@@ -160,8 +162,17 @@ build_moduleid_table(char *file_contents
 	struct ascii_moduleid *moduleid;
 
 	line = kmalloc(256, GFP_KERNEL);
-	memset(line, 0,256);
 	name = kmalloc(125, GFP_KERNEL);
+	if (!line || !name) {
+		if (line)
+			kfree(line);
+		if (name)
+			kfree(name);
+		printk("build_moduleid_table(): Unabled to allocate memmory");
+		return -ENOMEM;
+	}
+
+	memset(line, 0,256);
 	memset(name, 0, 125);
 	moduleid = table;
 	curr = file_contents;
@@ -210,46 +221,21 @@ build_moduleid_table(char *file_contents
 	kfree(line);
 	kfree(name);
 
-	return;
+	return 0;
 }
 
-void
+int
 ioconfig_bus_init(void)
 {
 
-	struct ia64_sal_retval ret_stuff;
-	u64	*temp;
-	int	cnode;
-
 	DBG("ioconfig_bus_init called.\n");
 
-        for (cnode = 0; cnode < numnodes; cnode++) {
-		nasid_t nasid;
-		/*
-	 	 * Make SAL call to get the address of the bus configuration table.
-	 	 */
-		ret_stuff.status = (uint64_t)0;
-		ret_stuff.v0 = (uint64_t)0;
-		ret_stuff.v1 = (uint64_t)0;
-		ret_stuff.v2 = (uint64_t)0;
-		nasid = COMPACT_TO_NASID_NODEID(cnode);
-		SAL_CALL(ret_stuff, SN_SAL_BUS_CONFIG, 0, nasid, 0, 0, 0, 0, 0);
-		temp = (u64 *)TO_NODE_CAC(nasid, ret_stuff.v0);
-		ioconfig_file = *temp;
-		DBG("ioconfig_bus_init: Nasid %d ret_stuff.v0 0x%lx\n", nasid,
-			ret_stuff.v0);
-		if (ioconfig_file) {
-			ioconfig_file_size = ret_stuff.v1;
-			ioconfig_file = (ioconfig_file | CACHEABLE_MEM_SPACE);
-			ioconfig_activated = 1;
-			break;
-		}
+	ioconfig_bus_table = kmalloc( 512, GFP_KERNEL );
+	if (!ioconfig_bus_table) {
+		printk("ioconfig_bus_init : cannot allocate memory\n");
+		return -1;
 	}
 
-	DBG("ioconfig_bus_init: ret_stuff.v0 %p ioconfig_file %p %d\n",
-		ret_stuff.v0, (void *)ioconfig_file, (int)ioconfig_file_size);
-
-	ioconfig_bus_table = kmalloc( 512, GFP_KERNEL );
 	memset(ioconfig_bus_table, 0, 512);
 
 	/*
@@ -260,27 +246,17 @@ ioconfig_bus_init(void)
 		 * ioconfig="..." kernel options given.
 		 */
 		DBG("ioconfig_bus_init: Kernel Options given.\n");
-		(void) build_moduleid_table((char *)ioconfig_kernopts, ioconfig_bus_table);
+		if ( build_moduleid_table((char *)ioconfig_kernopts, ioconfig_bus_table) < 0 )
+			return -1;
 		(void) dump_ioconfig_table();
-		return;
 	}
-
-	if (ioconfig_activated) {
-		DBG("ioconfig_bus_init: ioconfig file given.\n");
-		(void) build_moduleid_table((char *)ioconfig_file, ioconfig_bus_table);
-		(void) dump_ioconfig_table();
-	} else {
-		DBG("ioconfig_bus_init: ioconfig command not executed in prom\n");
-	}
-
+	return 0;
 }
 
 void
 ioconfig_bus_new_entries(void)
 {
-
-	
-	int index = 0;
+	int index;
 	struct ascii_moduleid *temp;
 
 	if ((ioconfig_activated) && (free_entry > new_entry)) {
@@ -290,6 +266,10 @@ ioconfig_bus_new_entries(void)
 		return;
 
 	index = new_entry;
+	if (!ioconfig_bus_table) {
+		printk("ioconfig_bus_table table is empty\n");
+		return;
+	}
 	temp = &ioconfig_bus_table[index];
         while (index < free_entry) {
                 printk("%s\n", (char *)temp);
@@ -302,17 +282,21 @@ ioconfig_bus_new_entries(void)
 static int ioconfig_bus_ioctl(struct inode * inode, struct file * file,
         unsigned int cmd, unsigned long arg)
 {
-
-	struct ioconfig_parm parm;
-
 	/*
 	 * Copy in the parameters.
 	 */
-	copy_from_user(&parm, (char *)arg, sizeof(struct ioconfig_parm));
+	if (copy_from_user(&parm, (char *)arg, sizeof(struct ioconfig_parm)))
+		return -EFAULT;
 	parm.number = free_entry - new_entry;
 	parm.ioconfig_activated = ioconfig_activated;
-	copy_to_user((char *)arg, &parm, sizeof(struct ioconfig_parm));
-	copy_to_user((char *)parm.buffer, &ioconfig_bus_table[new_entry], sizeof(struct  ascii_moduleid) * (free_entry - new_entry));
+	if (copy_to_user((char *)arg, &parm, sizeof(struct ioconfig_parm)))
+		return -EFAULT;
+
+	if (!ioconfig_bus_table)
+		return -EFAULT;
+
+	if (copy_to_user((char *)parm.buffer, &ioconfig_bus_table[new_entry], sizeof(struct  ascii_moduleid) * (free_entry - new_entry)))
+		return -EFAULT;
 
 	return 0;
 }
@@ -344,9 +328,9 @@ static int ioconfig_bus_close(struct ino
 }
 
 struct file_operations ioconfig_bus_fops = {
-	.ioctl = ioconfig_bus_ioctl,
-	.open = ioconfig_bus_open,		/* open */
-	.release = ioconfig_bus_close	/* release */
+	.ioctl	= ioconfig_bus_ioctl,
+	.open	= ioconfig_bus_open,	/* open */
+	.release=ioconfig_bus_close	/* release */
 };
 
 
@@ -357,7 +341,6 @@ struct file_operations ioconfig_bus_fops
  */
 int init_ioconfig_bus(void)
 {
-	ioconfig_bus_handle = NULL;
 	ioconfig_bus_handle = hwgraph_register(hwgraph_root, ".ioconfig_bus",
 		        0, 0,
 			0, 0,
@@ -368,8 +351,7 @@ int init_ioconfig_bus(void)
 		panic("Unable to create SGI PERSISTENT BUS NUMBERING Driver.\n");
 	}
 
-	return(0);
-
+	return 0;
 }
 
 static int __init ioconfig_bus_setup (char *str)
diff -puN arch/ia64/sn/io/drivers/Makefile~linus arch/ia64/sn/io/drivers/Makefile
--- 25/arch/ia64/sn/io/drivers/Makefile~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/drivers/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -7,6 +7,4 @@
 #
 # Makefile for the sn2 io routines.
 
-EXTRA_CFLAGS    := -DLITTLE_ENDIAN
-
 obj-y				+= ioconfig_bus.o
diff -puN arch/ia64/sn/io/hwgfs/hcl.c~linus arch/ia64/sn/io/hwgfs/hcl.c
--- 25/arch/ia64/sn/io/hwgfs/hcl.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/hwgfs/hcl.c	2004-01-19 22:17:21.000000000 -0800
@@ -23,41 +23,16 @@
 #include <asm/io.h>
 #include <asm/sn/iograph.h>
 #include <asm/sn/hwgfs.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/labelcl.h>
 #include <asm/sn/simulator.h>
 
-#define HCL_NAME "SGI-HWGRAPH COMPATIBILITY DRIVER"
-#define HCL_TEMP_NAME "HCL_TEMP_NAME_USED_FOR_HWGRAPH_VERTEX_CREATE"
-#define HCL_TEMP_NAME_LEN 44 
-#define HCL_VERSION "1.0"
-
 #define vertex_hdl_t hwgfs_handle_t
+
 vertex_hdl_t hwgraph_root;
 vertex_hdl_t linux_busnum;
-
-extern void pci_bus_cvlink_init(void);
-
-/*
- * Debug flag definition.
- */
-#define OPTION_NONE             0x00
-#define HCL_DEBUG_NONE 0x00000
-#define HCL_DEBUG_ALL  0x0ffff
-#if defined(CONFIG_HCL_DEBUG)
-static unsigned int hcl_debug_init __initdata = HCL_DEBUG_NONE;
-#endif
-static unsigned int hcl_debug = HCL_DEBUG_NONE;
-#if defined(CONFIG_HCL_DEBUG) && !defined(MODULE)
-static unsigned int boot_options = OPTION_NONE;
-#endif
-
-invplace_t invplace_none = {
-	GRAPH_VERTEX_NONE,
-	GRAPH_VERTEX_PLACE_NONE,
-	NULL
-};
+extern int pci_bus_cvlink_init(void);
+unsigned long hwgraph_debug_mask;
 
 /*
  * init_hcl() - Boot time initialization.
@@ -71,19 +46,16 @@ int __init init_hcl(void)
 	extern int init_hwgfs_fs(void);
 	int rv = 0;
 
-	if (IS_RUNNING_ON_SIMULATOR()) {
-		extern u64 klgraph_addr[];
-		klgraph_addr[0] = 0xe000003000030000;
-	}
-
 	init_hwgfs_fs();
 
 	/*
 	 * Create the hwgraph_root.
 	 */
 	rv = hwgraph_path_add(NULL, EDGE_LBL_HW, &hwgraph_root);
-	if (rv)
-		printk ("WARNING: init_hcl: Failed to create hwgraph_root. Error = %d.\n", rv);
+	if (rv) {
+		printk("init_hcl: Failed to create hwgraph_root.\n");
+		return -1;
+	}
 
 	/*
 	 * Initialize the HCL string table.
@@ -96,66 +68,23 @@ int __init init_hcl(void)
 	 */
 	rv = hwgraph_path_add(hwgraph_root, EDGE_LBL_LINUX_BUS, &linux_busnum);
 	if (linux_busnum == NULL) {
-		panic("HCL: Unable to create %s\n", EDGE_LBL_LINUX_BUS);
-		return(0);
+		printk("HCL: Unable to create %s\n", EDGE_LBL_LINUX_BUS);
+		return -1;
 	}
 
-	pci_bus_cvlink_init();
+	if (pci_bus_cvlink_init() < 0 ) {
+		printk("init_hcl: Failed to create pcibus cvlink.\n");
+		return -1;
+	}
 
 	/*
-	 * Initialize the ifconfgi_net driver that does network devices 
 	 * Persistent Naming.
 	 */
 	init_ioconfig_bus();
 
-	return(0);
-
-}
-
-
-/*
- * hcl_setup() - Process boot time parameters if given.
- *	"hcl="
- *	This routine gets called only if "hcl=" is given in the 
- *	boot line and before init_hcl().
- *
- *	We currently do not have any boot options .. when we do, 
- *	functionalities can be added here.
- *
- */
-static int __init hcl_setup(char *str)
-{
-    while ( (*str != '\0') && !isspace (*str) )
-    {
-#ifdef CONFIG_HCL_DEBUG
-        if (strncmp (str, "all", 3) == 0) {
-            hcl_debug_init |= HCL_DEBUG_ALL;
-            str += 3;
-        } else 
-        	return 0;
-#endif
-        if (*str != ',') return 0;
-        ++str;
-    }
-
-    return 1;
-
-}
-
-__setup("hcl=", hcl_setup);
-
-
-/*
- * Set device specific "fast information".
- *
- */
-void
-hwgraph_fastinfo_set(vertex_hdl_t de, arbitrary_info_t fastinfo)
-{
-	labelcl_info_replace_IDX(de, HWGRAPH_FASTINFO, fastinfo, NULL);
+	return 0;
 }
 
-
 /*
  * Get device specific "fast information".
  *
@@ -181,25 +110,6 @@ hwgraph_fastinfo_get(vertex_hdl_t de)
 
 
 /*
- * hwgraph_connectpt_set - Sets the connect point handle in de to the 
- *	given connect_de handle.  By default, the connect point of the 
- *	node is the parent.  This effectively changes this assumption.
- */
-int
-hwgraph_connectpt_set(vertex_hdl_t de, vertex_hdl_t connect_de)
-{
-	int rv;
-
-	if (!de)
-		return(-1);
-
-	rv = labelcl_info_connectpt_set(de, connect_de);
-
-	return(rv);
-}
-
-
-/*
  * hwgraph_connectpt_get: Returns the entry's connect point.
  *
  */
@@ -403,39 +313,6 @@ hwgraph_vertex_destroy(vertex_hdl_t de)
 	return(0);
 }
 
-#if 0
-/*
- * hwgraph_edge_add - This routines has changed from the original conext.
- * All it does now is to create a symbolic link from "from" to "to".
- */
-/* ARGSUSED */
-int
-hwgraph_edge_add(vertex_hdl_t from, vertex_hdl_t to, char *name)
-{
-
-	char *path, *link;
-	vertex_hdl_t handle = NULL;
-	int rv, i;
-
-	handle = hwgfs_find_handle(from, name, 0, 0, 0, 1);
-	if (handle) {
-		return(0);
-	}
-
-	path = kmalloc(1024, GFP_KERNEL);
-	memset(path, 0x0, 1024);
-	link = kmalloc(1024, GFP_KERNEL);
-	memset(path, 0x0, 1024);
-	i = hwgfs_generate_path (to, link, 1024);
-	rv = hwgfs_mk_symlink (from, (const char *)name, 
-			       DEVFS_FL_DEFAULT, link,
-			       &handle, NULL);
-	return(0);
-
-
-}
-#endif
-
 int
 hwgraph_edge_add(vertex_hdl_t from, vertex_hdl_t to, char *name)
 {
@@ -448,8 +325,14 @@ hwgraph_edge_add(vertex_hdl_t from, vert
 	int i, count;
 
 	path = kmalloc(1024, GFP_KERNEL);
+	if (!path)
+		return -ENOMEM;
 	memset((char *)path, 0x0, 1024);
 	link = kmalloc(1024, GFP_KERNEL);
+	if (!link) {
+		kfree(path);
+		return -ENOMEM;
+	}
 	memset((char *)link, 0x0, 1024);
 
 	i = hwgfs_generate_path (from, path, 1024);
@@ -706,39 +589,6 @@ hwgraph_traverse(vertex_hdl_t de, char *
 }
 
 /*
- * hwgraph_path_to_vertex - Return the entry handle for the given 
- *	pathname .. assume traverse symlinks too!.
- */
-vertex_hdl_t
-hwgraph_path_to_vertex(char *path)
-{
-	return(hwgfs_find_handle(NULL,	/* start dir */
-			path,		/* path */
-		    	0,		/* major */
-		    	0,		/* minor */
-		    	0,		/* char | block */
-		    	1));		/* traverse symlinks */
-}
-
-/*
- * hwgraph_inventory_remove - Removes an inventory entry.
- *
- *	Remove an inventory item associated with a vertex.   It is the caller's
- *	responsibility to make sure that there are no races between removing
- *	inventory from a vertex and simultaneously removing that vertex.
-*/
-int
-hwgraph_inventory_remove(	vertex_hdl_t de,
-				int class,
-				int type,
-				major_t controller,
-				minor_t unit,
-				int state)
-{
-	return(0); /* Just a Stub for IRIX code. */
-}
-
-/*
  * Find the canonical name for a given vertex by walking back through
  * connectpt's until we hit the hwgraph root vertex (or until we run
  * out of buffer space or until something goes wrong).
@@ -750,7 +600,7 @@ hwgraph_inventory_remove(	vertex_hdl_t d
  * "/" but rather it just stops right before /dev ..
  */
 int
-hwgraph_vertex_name_get(vertex_hdl_t vhdl, char *buf, uint buflen)
+hwgraph_vertex_name_get(vertex_hdl_t vhdl, char *buf, unsigned int buflen)
 {
 	char *locbuf;
 	int   pos;
@@ -785,34 +635,60 @@ hwgraph_vertex_name_get(vertex_hdl_t vhd
 #define DEVNAME_UNKNOWN "UnknownDevice"
 
 char *
-vertex_to_name(vertex_hdl_t vhdl, char *buf, uint buflen)
+vertex_to_name(vertex_hdl_t vhdl, char *buf, unsigned int buflen)
 {
-	if (hwgraph_vertex_name_get(vhdl, buf, buflen) == GRAPH_SUCCESS)
-		return(buf);
-	else
-		return(DEVNAME_UNKNOWN);
+        if (hwgraph_vertex_name_get(vhdl, buf, buflen) == GRAPH_SUCCESS)
+                return(buf);
+        else
+                return(DEVNAME_UNKNOWN);
 }
 
-graph_error_t
-hwgraph_edge_remove(vertex_hdl_t from, char *name, vertex_hdl_t *toptr)
-{
-	return(GRAPH_ILLEGAL_REQUEST);
-}
 
-graph_error_t
-hwgraph_vertex_unref(vertex_hdl_t vhdl)
+void
+hwgraph_debug(char *file, char * function, int line, vertex_hdl_t vhdl1, vertex_hdl_t vhdl2, char *format, ...)
 {
-	return(GRAPH_ILLEGAL_REQUEST);
-}
 
+	int pos;
+	char *hwpath;
+	va_list ap;
+
+	if ( !hwgraph_debug_mask )
+		return;
+
+	hwpath = kmalloc(MAXDEVNAME, GFP_KERNEL);
+	if (!hwpath) {
+		printk("HWGRAPH_DEBUG kmalloc fails at %d ", __LINE__);
+		return;
+	}
+
+	printk("HWGRAPH_DEBUG %s %s %d : ", file, function, line);
+
+	if (vhdl1){
+		memset(hwpath, 0, MAXDEVNAME);
+		pos = hwgfs_generate_path(vhdl1, hwpath, MAXDEVNAME);
+		printk("vhdl1 = %s : ", &hwpath[pos]);
+	}
+
+	if (vhdl2){
+		memset(hwpath, 0, MAXDEVNAME);
+		pos = hwgfs_generate_path(vhdl2, hwpath, MAXDEVNAME);
+		printk("vhdl2 = %s :", &hwpath[pos]);
+	}
+
+	memset(hwpath, 0, MAXDEVNAME);
+        va_start(ap, format);
+        vsnprintf(hwpath, 500, format, ap);
+        va_end(ap);
+	hwpath[MAXDEVNAME -1] = (char)0; /* Just in case. */
+        printk(" %s", hwpath);
+	kfree(hwpath);
+}
 
 EXPORT_SYMBOL(hwgraph_mk_dir);
 EXPORT_SYMBOL(hwgraph_path_add);
 EXPORT_SYMBOL(hwgraph_register);
 EXPORT_SYMBOL(hwgraph_vertex_destroy);
 EXPORT_SYMBOL(hwgraph_fastinfo_get);
-EXPORT_SYMBOL(hwgraph_fastinfo_set);
-EXPORT_SYMBOL(hwgraph_connectpt_set);
 EXPORT_SYMBOL(hwgraph_connectpt_get);
 EXPORT_SYMBOL(hwgraph_info_add_LBL);
 EXPORT_SYMBOL(hwgraph_info_remove_LBL);
diff -puN arch/ia64/sn/io/hwgfs/hcl_util.c~linus arch/ia64/sn/io/hwgfs/hcl_util.c
--- 25/arch/ia64/sn/io/hwgfs/hcl_util.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/hwgfs/hcl_util.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -14,16 +13,33 @@
 #include <asm/sn/io.h>
 #include <asm/sn/iograph.h>
 #include <asm/sn/hwgfs.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/labelcl.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl_util.h>
 #include <asm/sn/nodepda.h>
 
 static vertex_hdl_t hwgraph_all_cnodes = GRAPH_VERTEX_NONE;
 extern vertex_hdl_t hwgraph_root;
+static vertex_hdl_t hwgraph_all_cpuids = GRAPH_VERTEX_NONE;
+extern int maxcpus;
+
+void
+mark_cpuvertex_as_cpu(vertex_hdl_t vhdl, cpuid_t cpuid)
+{
+	char cpuid_buffer[10];
+
+	if (cpuid == CPU_NONE)
+		return;
 
+	if (hwgraph_all_cpuids == GRAPH_VERTEX_NONE) {
+		(void)hwgraph_path_add( hwgraph_root,
+					EDGE_LBL_CPUNUM,
+					&hwgraph_all_cpuids);
+	}
+
+	sprintf(cpuid_buffer, "%ld", cpuid);
+	(void)hwgraph_edge_add( hwgraph_all_cpuids, vhdl, cpuid_buffer);
+}
 
 /*
 ** Return the "master" for a given vertex.  A master vertex is a
@@ -96,32 +112,6 @@ master_node_get(vertex_hdl_t vhdl)
 	}
 }
 
-static vertex_hdl_t hwgraph_all_cpuids = GRAPH_VERTEX_NONE;
-extern int maxcpus;
-
-void
-mark_cpuvertex_as_cpu(vertex_hdl_t vhdl, cpuid_t cpuid)
-{
-	if (cpuid == CPU_NONE)
-		return;
-
-	(void)labelcl_info_add_LBL(vhdl, INFO_LBL_CPUID, INFO_DESC_EXPORT,
-			(arbitrary_info_t)cpuid);
-	{
-		char cpuid_buffer[10];
-
-		if (hwgraph_all_cpuids == GRAPH_VERTEX_NONE) {
-			(void)hwgraph_path_add( hwgraph_root,
-						EDGE_LBL_CPUNUM,
-						&hwgraph_all_cpuids);
-		}
-
-		sprintf(cpuid_buffer, "%ld", cpuid);
-		(void)hwgraph_edge_add( hwgraph_all_cpuids,
-							vhdl,
-							cpuid_buffer);
-	}
-}
 
 /*
 ** If the specified device represents a node, return its
@@ -161,25 +151,11 @@ mark_nodevertex_as_node(vertex_hdl_t vhd
 		(void)hwgraph_edge_add( hwgraph_all_cnodes,
 					vhdl,
 					cnodeid_buffer);
+		HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, hwgraph_all_cnodes, NULL, "Creating path vhdl1\n"));
 	}
 }
 
 /*
-** If the specified device represents a CPU, return its cpuid;
-** otherwise, return CPU_NONE.
-*/
-cpuid_t
-cpuvertex_to_cpuid(vertex_hdl_t vhdl)
-{
-	arbitrary_info_t cpuid = CPU_NONE;
-
-	(void)labelcl_info_get_LBL(vhdl, INFO_LBL_CPUID, NULL, &cpuid);
-
-	return((cpuid_t)cpuid);
-}
-
-
-/*
 ** dev_to_name converts a vertex_hdl_t into a canonical name.  If the vertex_hdl_t
 ** represents a vertex in the hardware graph, it is converted in the
 ** normal way for vertices.  If the vertex_hdl_t is an old vertex_hdl_t (one which
@@ -197,4 +173,3 @@ dev_to_name(vertex_hdl_t dev, char *buf,
         return(vertex_to_name(dev, buf, buflen));
 }
 
-
diff -puN arch/ia64/sn/io/hwgfs/interface.c~linus arch/ia64/sn/io/hwgfs/interface.c
--- 25/arch/ia64/sn/io/hwgfs/interface.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/hwgfs/interface.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,36 +1,12 @@
 /*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
  * Copyright (c) 2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  *  Portions based on Adam Richter's smalldevfs and thus
  *  Copyright 2002-2003  Yggdrasil Computing, Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
  */
 
 #include <linux/module.h>
@@ -40,7 +16,6 @@
 #include <linux/namei.h>
 #include <linux/string.h>
 #include <linux/slab.h>
-#include <linux/dcache.h>
 #include <asm/sn/hwgfs.h>
 
 
@@ -297,8 +272,7 @@ hwgfs_find_handle(
 
 	nd.mnt = mntget(hwgfs_vfsmount);
 	nd.dentry = dget(base ? base : hwgfs_vfsmount->mnt_sb->s_root);
-	if (traverse_symlinks)
-		nd.flags = LOOKUP_FOLLOW;
+	nd.flags = (traverse_symlinks ? LOOKUP_FOLLOW : 0);
 
 	error = link_path_walk(name, &nd);
 	if (likely(!error)) {
diff -puN arch/ia64/sn/io/hwgfs/labelcl.c~linus arch/ia64/sn/io/hwgfs/labelcl.c
--- 25/arch/ia64/sn/io/hwgfs/labelcl.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/hwgfs/labelcl.c	2004-01-19 22:17:21.000000000 -0800
@@ -16,7 +16,6 @@
 #include <linux/smp_lock.h>
 #include <asm/sn/sgi.h>
 #include <asm/sn/hwgfs.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/labelcl.h>
 
diff -puN arch/ia64/sn/io/hwgfs/Makefile~linus arch/ia64/sn/io/hwgfs/Makefile
--- 25/arch/ia64/sn/io/hwgfs/Makefile~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/hwgfs/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -7,6 +7,4 @@
 #
 # Makefile for the sn2 io routines.
 
-EXTRA_CFLAGS    := -DLITTLE_ENDIAN
-
 obj-y		+= hcl.o labelcl.o hcl_util.o ramfs.o interface.o
diff -puN arch/ia64/sn/io/hwgfs/ramfs.c~linus arch/ia64/sn/io/hwgfs/ramfs.c
--- 25/arch/ia64/sn/io/hwgfs/ramfs.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/hwgfs/ramfs.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,37 +1,13 @@
 /*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
  * Copyright (c) 2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  *  Mostly shameless copied from Linus Torvalds' ramfs and thus
  *  Copyright (C) 2000 Linus Torvalds.
  *                2000 Transmeta Corp.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
  */
 
 #include <linux/module.h>
diff -puN arch/ia64/sn/io/io.c~linus arch/ia64/sn/io/io.c
--- 25/arch/ia64/sn/io/io.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/io.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id: io.c,v 1.2 2001/06/26 14:02:43 pfg Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -20,7 +19,6 @@
 #include <asm/sn/io.h>
 #include <asm/sn/sn_private.h>
 #include <asm/sn/addrs.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/hcl_util.h>
 #include <asm/sn/intr.h>
@@ -29,7 +27,6 @@
 #include <asm/sn/sn_cpuid.h>
 
 extern xtalk_provider_t hub_provider;
-extern void hub_intr_init(vertex_hdl_t hubv);
 
 static int force_fire_and_forget = 1;
 static int ignore_conveyor_override;
@@ -86,7 +83,7 @@ hub_pio_init(vertex_hdl_t hubv)
 	}
 	hub_set_piomode(nasid, HUB_PIO_CONVEYOR);
 
-	mutex_spinlock_init(&hubinfo->h_bwlock);
+	spin_lock_init(&hubinfo->h_bwlock);
 	init_waitqueue_head(&hubinfo->h_bwwait);
 }
 
@@ -119,7 +116,6 @@ hub_piomap_alloc(vertex_hdl_t dev,	/* se
 	int bigwin, free_bw_index;
 	nasid_t nasid;
 	volatile hubreg_t junk;
-	unsigned long s;
 	caddr_t kvaddr;
 #ifdef PIOMAP_UNC_ACC_SPACE
 	uint64_t addr;
@@ -167,7 +163,7 @@ hub_piomap_alloc(vertex_hdl_t dev,	/* se
 	 */
 tryagain:
 	free_bw_index = -1;
-	s = mutex_spinlock(&hubinfo->h_bwlock);
+	spin_lock(&hubinfo->h_bwlock);
 	for (bigwin=0; bigwin < HUB_NUM_BIG_WINDOW; bigwin++) {
 		bw_piomap = hubinfo_bwin_piomap_get(hubinfo, bigwin);
 
@@ -187,7 +183,7 @@ tryagain:
 		if ( xtalk_addr == bw_piomap->hpio_xtalk_info.xp_xtalk_addr &&
 		     widget == bw_piomap->hpio_xtalk_info.xp_target) {
 			bw_piomap->hpio_holdcnt++;
-			mutex_spinunlock(&hubinfo->h_bwlock, s);
+			spin_unlock(&hubinfo->h_bwlock);
 			return(bw_piomap);
 		}
 	}
@@ -267,7 +263,7 @@ tryagain:
 		bw_piomap->hpio_flags |= HUB_PIOMAP_IS_VALID;
 
 done:
-	mutex_spinunlock(&hubinfo->h_bwlock, s);
+	spin_unlock(&hubinfo->h_bwlock);
 	return(bw_piomap);
 }
 
@@ -287,7 +283,6 @@ hub_piomap_free(hub_piomap_t hub_piomap)
 	vertex_hdl_t hubv;
 	hubinfo_t hubinfo;
 	nasid_t nasid;
-	unsigned long s;
 
 	/* 
 	 * Small windows are permanently mapped to corresponding widgets,
@@ -303,7 +298,7 @@ hub_piomap_free(hub_piomap_t hub_piomap)
 	hubinfo_get(hubv, &hubinfo);
 	nasid = hubinfo->h_nasid;
 
-	s = mutex_spinlock(&hubinfo->h_bwlock);
+	spin_lock(&hubinfo->h_bwlock);
 
 	/*
 	 * If this is the last hold on this mapping, free it.
@@ -321,7 +316,7 @@ hub_piomap_free(hub_piomap_t hub_piomap)
 		wake_up(&hubinfo->h_bwwait);
 	}
 
-	mutex_spinunlock(&hubinfo->h_bwlock, s);
+	spin_unlock(&hubinfo->h_bwlock);
 }
 
 /*
@@ -442,7 +437,7 @@ void
 hub_dmamap_free(hub_dmamap_t hub_dmamap)
 {
 	hub_dmamap->hdma_flags &= ~HUB_DMAMAP_IS_VALID;
-	kern_free(hub_dmamap);
+	kfree(hub_dmamap);
 }
 
 /*
@@ -463,12 +458,9 @@ hub_dmamap_addr(	hub_dmamap_t dmamap,	/*
 	if (dmamap->hdma_flags & HUB_DMAMAP_USED) {
 	    /* If the map is FIXED, re-use is OK. */
 	    if (!(dmamap->hdma_flags & HUB_DMAMAP_IS_FIXED)) {
+		char name[MAXDEVNAME];
 		vhdl = dmamap->hdma_xtalk_info.xd_dev;
-#if defined(SUPPORT_PRINTING_V_FORMAT)
-		printk(KERN_WARNING  "%v: hub_dmamap_addr re-uses dmamap.\n",vhdl);
-#else
-		printk(KERN_WARNING  "%p: hub_dmamap_addr re-uses dmamap.\n", (void *)vhdl);
-#endif
+		printk(KERN_WARNING  "%s: hub_dmamap_addr re-uses dmamap.\n", vertex_to_name(vhdl, name, MAXDEVNAME));
 	    }
 	} else {
 		dmamap->hdma_flags |= HUB_DMAMAP_USED;
@@ -496,12 +488,9 @@ hub_dmamap_list(hub_dmamap_t hub_dmamap,
 	if (hub_dmamap->hdma_flags & HUB_DMAMAP_USED) {
 	    /* If the map is FIXED, re-use is OK. */
 	    if (!(hub_dmamap->hdma_flags & HUB_DMAMAP_IS_FIXED)) {
+		char name[MAXDEVNAME];
 		vhdl = hub_dmamap->hdma_xtalk_info.xd_dev;
-#if defined(SUPPORT_PRINTING_V_FORMAT)
-		printk(KERN_WARNING  "%v: hub_dmamap_list re-uses dmamap\n",vhdl);
-#else
-		printk(KERN_WARNING  "%p: hub_dmamap_list re-uses dmamap\n", (void *)vhdl);
-#endif
+		printk(KERN_WARNING  "%s: hub_dmamap_list re-uses dmamap\n", vertex_to_name(vhdl, name, MAXDEVNAME));
 	    }
 	} else {
 		hub_dmamap->hdma_flags |= HUB_DMAMAP_USED;
@@ -525,12 +514,9 @@ hub_dmamap_done(hub_dmamap_t hub_dmamap)
 	} else {
 	    /* If the map is FIXED, re-done is OK. */
 	    if (!(hub_dmamap->hdma_flags & HUB_DMAMAP_IS_FIXED)) {
+		char name[MAXDEVNAME];
 		vhdl = hub_dmamap->hdma_xtalk_info.xd_dev;
-#if defined(SUPPORT_PRINTING_V_FORMAT)
-		printk(KERN_WARNING  "%v: hub_dmamap_done already done with dmamap\n",vhdl);
-#else
-		printk(KERN_WARNING  "%p: hub_dmamap_done already done with dmamap\n", (void *)vhdl);
-#endif
+		printk(KERN_WARNING  "%s: hub_dmamap_done already done with dmamap\n", vertex_to_name(vhdl, name, MAXDEVNAME));
 	    }
 	}
 }
@@ -601,7 +587,6 @@ void
 hub_provider_startup(vertex_hdl_t hubv)
 {
 	hub_pio_init(hubv);
-	hub_intr_init(hubv);
 }
 
 /*
@@ -808,4 +793,3 @@ xtalk_provider_t hub_provider = {
 	(xtalk_provider_startup_f *)	hub_provider_startup,
 	(xtalk_provider_shutdown_f *)	hub_provider_shutdown,
 };
-
diff -puN arch/ia64/sn/io/machvec/Makefile~linus arch/ia64/sn/io/machvec/Makefile
--- 25/arch/ia64/sn/io/machvec/Makefile~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/machvec/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -7,6 +7,4 @@
 #
 # Makefile for the sn2 io routines.
 
-EXTRA_CFLAGS    := -DLITTLE_ENDIAN
-
 obj-y				+= pci.o pci_dma.o pci_bus_cvlink.o iomv.o
diff -puN arch/ia64/sn/io/machvec/pci_bus_cvlink.c~linus arch/ia64/sn/io/machvec/pci_bus_cvlink.c
--- 25/arch/ia64/sn/io/machvec/pci_bus_cvlink.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/machvec/pci_bus_cvlink.c	2004-01-19 22:17:21.000000000 -0800
@@ -6,37 +6,12 @@
  * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
  */
 
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/pci.h>
-#include <linux/pci_ids.h>
-#include <linux/sched.h>
-#include <linux/ioport.h>
-#include <asm/sn/types.h>
+#include <linux/vmalloc.h>
 #include <asm/sn/sgi.h>
-#include <asm/sn/io.h>
-#include <asm/sn/driver.h>
 #include <asm/sn/iograph.h>
-#include <asm/param.h>
-#include <asm/sn/pio.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/sn_private.h>
-#include <asm/sn/addrs.h>
-#include <asm/sn/invent.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/hcl_util.h>
-#include <asm/sn/intr.h>
-#include <asm/sn/xtalk/xtalkaddrs.h>
-#include <asm/sn/klconfig.h>
-#include <asm/sn/nodepda.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/pci/pcibr_private.h>
 #include <asm/sn/pci/pci_bus_cvlink.h>
-#include <asm/sn/simulator.h>
 #include <asm/sn/sn_cpuid.h>
-#include <asm/sn/arch.h>
+#include <asm/sn/simulator.h>
 
 extern int bridge_rev_b_data_check_disable;
 
@@ -53,29 +28,32 @@ vertex_hdl_t devfn_to_vertex(unsigned ch
 extern void register_pcibr_intr(int irq, pcibr_intr_t intr);
 
 void sn_dma_flush_init(unsigned long start, unsigned long end, int idx, int pin, int slot);
+extern int cbrick_type_get_nasid(nasid_t);
 
+#define IS_OPUS(nasid) (cbrick_type_get_nasid(nasid) == MODULE_OPUSBRICK)
+#define IS_ALTIX(nasid) (cbrick_type_get_nasid(nasid) == MODULE_CBRICK)
 
 /*
- * For the given device, initialize whether it is a PIC device.
+ * Init the provider asic for a given device
  */
+
 static void
-set_isPIC(struct sn_device_sysdata *device_sysdata)
+set_pci_provider(struct sn_device_sysdata *device_sysdata)
 {
 	pciio_info_t pciio_info = pciio_info_get(device_sysdata->vhdl);
-	pcibr_soft_t pcibr_soft = (pcibr_soft_t) pciio_info_mfast_get(pciio_info);
 
-	device_sysdata->isPIC = IS_PIC_SOFT(pcibr_soft);;
+	device_sysdata->pci_provider = pciio_info_pops_get(pciio_info);
 }
 
 /*
  * pci_bus_cvlink_init() - To be called once during initialization before 
  *	SGI IO Infrastructure init is called.
  */
-void
+int
 pci_bus_cvlink_init(void)
 {
 
-	extern void ioconfig_bus_init(void);
+	extern int ioconfig_bus_init(void);
 
 	memset(busnum_to_pcibr_vhdl, 0x0, sizeof(vertex_hdl_t) * MAX_PCI_XWIDGET);
 	memset(busnum_to_nid, 0x0, sizeof(nasid_t) * MAX_PCI_XWIDGET);
@@ -84,7 +62,7 @@ pci_bus_cvlink_init(void)
 
 	num_bridges = 0;
 
-	ioconfig_bus_init();
+	return ioconfig_bus_init();
 }
 
 /*
@@ -170,62 +148,15 @@ devfn_to_vertex(unsigned char busnum, un
 	return(device_vertex);
 }
 
-/*
- * For the given device, initialize the addresses for both the Device(x) Flush 
- * Write Buffer register and the Xbow Flush Register for the port the PCI bus 
- * is connected.
- */
-static void
-set_flush_addresses(struct pci_dev *device_dev, 
-	struct sn_device_sysdata *device_sysdata)
-{
-	pciio_info_t pciio_info = pciio_info_get(device_sysdata->vhdl);
-	pciio_slot_t pciio_slot = pciio_info_slot_get(pciio_info);
-	pcibr_soft_t pcibr_soft = (pcibr_soft_t) pciio_info_mfast_get(pciio_info);
-    	bridge_t               *bridge = pcibr_soft->bs_base;
-	nasid_t			nasid;
-
-	/*
-	 * Get the nasid from the bridge.
-	 */
-	nasid = NASID_GET(device_sysdata->dma_buf_sync);
-	if (IS_PIC_DEVICE(device_dev)) {
-		device_sysdata->dma_buf_sync = (volatile unsigned int *)
-			&bridge->b_wr_req_buf[pciio_slot].reg;
-		device_sysdata->xbow_buf_sync = (volatile unsigned int *)
-			XBOW_PRIO_LINKREGS_PTR(NODE_SWIN_BASE(nasid, 0),
-			pcibr_soft->bs_xid);
-	} else {
-		/*
-		 * Accessing Xbridge and Xbow register when SHUB swapoper is on!.
-		 */
-		device_sysdata->dma_buf_sync = (volatile unsigned int *)
-			((uint64_t)&(bridge->b_wr_req_buf[pciio_slot].reg)^4);
-		device_sysdata->xbow_buf_sync = (volatile unsigned int *)
-			((uint64_t)(XBOW_PRIO_LINKREGS_PTR(
-			NODE_SWIN_BASE(nasid, 0), pcibr_soft->bs_xid)) ^ 4);
-	}
-
-#ifdef DEBUG
-	printk("set_flush_addresses: dma_buf_sync %p xbow_buf_sync %p\n", 
-		device_sysdata->dma_buf_sync, device_sysdata->xbow_buf_sync);
-
-printk("set_flush_addresses: dma_buf_sync\n");
-	while((volatile unsigned int )*device_sysdata->dma_buf_sync);
-printk("set_flush_addresses: xbow_buf_sync\n");
-	while((volatile unsigned int )*device_sysdata->xbow_buf_sync);
-#endif
-
-}
-
 struct sn_flush_nasid_entry flush_nasid_list[MAX_NASIDS];
 
-// Initialize the data structures for flushing write buffers after a PIO read.
-// The theory is: 
-// Take an unused int. pin and associate it with a pin that is in use.
-// After a PIO read, force an interrupt on the unused pin, forcing a write buffer flush
-// on the in use pin.  This will prevent the race condition between PIO read responses and 
-// DMA writes.
+/* Initialize the data structures for flushing write buffers after a PIO read.
+ * The theory is: 
+ * Take an unused int. pin and associate it with a pin that is in use.
+ * After a PIO read, force an interrupt on the unused pin, forcing a write buffer flush
+ * on the in use pin.  This will prevent the race condition between PIO read responses and 
+ * DMA writes.
+ */
 void
 sn_dma_flush_init(unsigned long start, unsigned long end, int idx, int pin, int slot) {
 	nasid_t nasid; 
@@ -247,101 +178,59 @@ sn_dma_flush_init(unsigned long start, u
 	if (flush_nasid_list[nasid].widget_p == NULL) {
 		flush_nasid_list[nasid].widget_p = (struct sn_flush_device_list **)kmalloc((HUB_WIDGET_ID_MAX+1) *
 			sizeof(struct sn_flush_device_list *), GFP_KERNEL);
+		if (flush_nasid_list[nasid].widget_p <= 0) {
+			printk("sn_dma_flush_init: Cannot allocate memory for nasid list\n");
+			return;
+		}
 		memset(flush_nasid_list[nasid].widget_p, 0, (HUB_WIDGET_ID_MAX+1) * sizeof(struct sn_flush_device_list *));
 	}
 	if (bwin > 0) {
-		bwin--;
-		switch (bwin) {
-			case 0:
-				flush_nasid_list[nasid].iio_itte1 = HUB_L(IIO_ITTE_GET(nasid, 0));
-				wid_num = ((flush_nasid_list[nasid].iio_itte1) >> 8) & 0xf;
-				bus = flush_nasid_list[nasid].iio_itte1 & 0xf;
-				if (bus == 0x4 || bus == 0x8)
-					bus = 0;
-				else
-					bus = 1;
-				break;
-			case 1:
-				flush_nasid_list[nasid].iio_itte2 = HUB_L(IIO_ITTE_GET(nasid, 1));
-				wid_num = ((flush_nasid_list[nasid].iio_itte2) >> 8) & 0xf;
-				bus = flush_nasid_list[nasid].iio_itte2 & 0xf;
-				if (bus == 0x4 || bus == 0x8)
-					bus = 0;
-				else
-					bus = 1;
-				break;
-			case 2:
-				flush_nasid_list[nasid].iio_itte3 = HUB_L(IIO_ITTE_GET(nasid, 2));
-				wid_num = ((flush_nasid_list[nasid].iio_itte3) >> 8) & 0xf;
-				bus = flush_nasid_list[nasid].iio_itte3 & 0xf;
-				if (bus == 0x4 || bus == 0x8)
-					bus = 0;
-				else
-					bus = 1;
-				break;
-			case 3:
-				flush_nasid_list[nasid].iio_itte4 = HUB_L(IIO_ITTE_GET(nasid, 3));
-				wid_num = ((flush_nasid_list[nasid].iio_itte4) >> 8) & 0xf;
-				bus = flush_nasid_list[nasid].iio_itte4 & 0xf;
-				if (bus == 0x4 || bus == 0x8)
-					bus = 0;
-				else
-					bus = 1;
-				break;
-			case 4:
-				flush_nasid_list[nasid].iio_itte5 = HUB_L(IIO_ITTE_GET(nasid, 4));
-				wid_num = ((flush_nasid_list[nasid].iio_itte5) >> 8) & 0xf;
-				bus = flush_nasid_list[nasid].iio_itte5 & 0xf;
-				if (bus == 0x4 || bus == 0x8)
-					bus = 0;
-				else
-					bus = 1;
-				break;
-			case 5:
-				flush_nasid_list[nasid].iio_itte6 = HUB_L(IIO_ITTE_GET(nasid, 5));
-				wid_num = ((flush_nasid_list[nasid].iio_itte6) >> 8) & 0xf;
-				bus = flush_nasid_list[nasid].iio_itte6 & 0xf;
-				if (bus == 0x4 || bus == 0x8)
-					bus = 0;
-				else
-					bus = 1;
-				break;
-			case 6:
-				flush_nasid_list[nasid].iio_itte7 = HUB_L(IIO_ITTE_GET(nasid, 6));
-				wid_num = ((flush_nasid_list[nasid].iio_itte7) >> 8) & 0xf;
-				bus = flush_nasid_list[nasid].iio_itte7 & 0xf;
-				if (bus == 0x4 || bus == 0x8)
-					bus = 0;
-				else
-					bus = 1;
-				break;
+		int itte_index = bwin - 1;
+		unsigned long itte;
+
+		itte = HUB_L(IIO_ITTE_GET(nasid, itte_index));
+		flush_nasid_list[nasid].iio_itte[bwin] = itte;
+		wid_num = (itte >> IIO_ITTE_WIDGET_SHIFT) & 
+			  IIO_ITTE_WIDGET_MASK;
+		bus = itte & IIO_ITTE_OFFSET_MASK;
+		if (bus == 0x4 || bus == 0x8) {
+			bus = 0;
+		} else {
+			bus = 1;
 		}
 	}
 
-	// if it's IO9, bus 1, we don't care about slots 1, 3, and 4.  This is
-	// because these are the IOC4 slots and we don't flush them.
+	/* if it's IO9, bus 1, we don't care about slots 1 and 4.  This is
+	 * because these are the IOC4 slots and we don't flush them.
+	 */
 	if (isIO9(nasid) && bus == 0 && (slot == 1 || slot == 4)) {
 		return;
 	}
 	if (flush_nasid_list[nasid].widget_p[wid_num] == NULL) {
 		flush_nasid_list[nasid].widget_p[wid_num] = (struct sn_flush_device_list *)kmalloc(
 			DEV_PER_WIDGET * sizeof (struct sn_flush_device_list), GFP_KERNEL);
+		if (flush_nasid_list[nasid].widget_p[wid_num] <= 0) {
+			printk("sn_dma_flush_init: Cannot allocate memory for nasid sub-list\n");
+			return;
+		}
 		memset(flush_nasid_list[nasid].widget_p[wid_num], 0, 
 			DEV_PER_WIDGET * sizeof (struct sn_flush_device_list));
 		p = &flush_nasid_list[nasid].widget_p[wid_num][0];
 		for (i=0; i<DEV_PER_WIDGET;i++) {
 			p->bus = -1;
 			p->pin = -1;
+			p->slot = -1;
 			p++;
 		}
 	}
 
 	p = &flush_nasid_list[nasid].widget_p[wid_num][0];
 	for (i=0;i<DEV_PER_WIDGET; i++) {
-		if (p->pin == pin && p->bus == bus) break;
+		if (p->pin == pin && p->bus == bus && p->slot == slot) break;
 		if (p->pin < 0) {
 			p->pin = pin;
 			p->bus = bus;
+			p->slot = slot;
 			break;
 		}
 		p++;
@@ -356,25 +245,28 @@ sn_dma_flush_init(unsigned long start, u
 	}
 	b = (bridge_t *)(NODE_SWIN_BASE(nasid, wid_num) | (bus << 23) );
 
-	// If it's IO9, then slot 2 maps to slot 7 and slot 6 maps to slot 8.
-	// To see this is non-trivial.  By drawing pictures and reading manuals and talking
-	// to HW guys, we can see that on IO9 bus 1, slots 7 and 8 are always unused.
-	// Further, since we short-circuit slots  1, 3, and 4 above, we only have to worry
-	// about the case when there is a card in slot 2.  A multifunction card will appear
-	// to be in slot 6 (from an interrupt point of view) also.  That's the  most we'll
-	// have to worry about.  A four function card will overload the interrupt lines in
-	// slot 2 and 6.  
-	// We also need to special case the 12160 device in slot 3.  Fortunately, we have
-	// a spare intr. line for pin 4, so we'll use that for the 12160.
-	// All other buses have slot 3 and 4 and slots 7 and 8 unused.  Since we can only
-	// see slots 1 and 2 and slots 5 and 6 coming through here for those buses (this
-	// is true only on Pxbricks with 2 physical slots per bus), we just need to add
-	// 2 to the slot number to find an unused slot.
-	// We have convinced ourselves that we will never see a case where two different cards
-	// in two different slots will ever share an interrupt line, so there is no need to
-	// special case this.
-
-	if (isIO9(nasid) && wid_num == 0xc && bus == 0) {
+	/* If it's IO9, then slot 2 maps to slot 7 and slot 6 maps to slot 8.
+	 * To see this is non-trivial.  By drawing pictures and reading manuals and talking
+	 * to HW guys, we can see that on IO9 bus 1, slots 7 and 8 are always unused.
+	 * Further, since we short-circuit slots  1, 3, and 4 above, we only have to worry
+	 * about the case when there is a card in slot 2.  A multifunction card will appear
+	 * to be in slot 6 (from an interrupt point of view) also.  That's the  most we'll
+	 * have to worry about.  A four function card will overload the interrupt lines in
+	 * slot 2 and 6.  
+	 * We also need to special case the 12160 device in slot 3.  Fortunately, we have
+	 * a spare intr. line for pin 4, so we'll use that for the 12160.
+	 * All other buses have slot 3 and 4 and slots 7 and 8 unused.  Since we can only
+	 * see slots 1 and 2 and slots 5 and 6 coming through here for those buses (this
+	 * is true only on Pxbricks with 2 physical slots per bus), we just need to add
+	 * 2 to the slot number to find an unused slot.
+	 * We have convinced ourselves that we will never see a case where two different cards
+	 * in two different slots will ever share an interrupt line, so there is no need to
+	 * special case this.
+	 */
+
+	if (isIO9(nasid) && ( (IS_ALTIX(nasid) && wid_num == 0xc)
+				|| (IS_OPUS(nasid) && wid_num == 0xf) )
+				&& bus == 0) {
 		if (slot == 2) {
 			p->force_int_addr = (unsigned long)&b->b_force_always[6].intr;
 			dev_sel = b->b_int_device;
@@ -427,7 +319,7 @@ sn_pci_fixup(int arg)
 	struct sn_widget_sysdata *widget_sysdata;
 	struct sn_device_sysdata *device_sysdata;
 	pcibr_intr_t intr_handle;
-	int cpuid;
+	pciio_provider_t *pci_provider;
 	vertex_hdl_t device_vertex;
 	pciio_intr_line_t lines;
 	extern int numnodes;
@@ -437,11 +329,10 @@ sn_pci_fixup(int arg)
 #ifdef CONFIG_PROC_FS
 		extern void register_sn_procfs(void);
 #endif
-		extern void irix_io_init(void);
+		extern void sgi_master_io_infr_init(void);
 		extern void sn_init_cpei_timer(void);
 		
-		init_hcl();
-		irix_io_init();
+		sgi_master_io_infr_init();
 		
 		for (cnode = 0; cnode < numnodes; cnode++) {
 			extern void intr_init_vecblk(cnodeid_t);
@@ -474,8 +365,13 @@ sn_pci_fixup(int arg)
  	 * set the root start and end so that drivers calling check_region()
 	 * won't see a conflict
 	 */
-	ioport_resource.start  = 0xc000000000000000;
-	ioport_resource.end =    0xcfffffffffffffff;
+
+#ifdef CONFIG_IA64_SGI_SN_SIM
+	if (! IS_RUNNING_ON_SIMULATOR()) {
+		ioport_resource.start  = 0xc000000000000000;
+		ioport_resource.end =    0xcfffffffffffffff;
+	}
+#endif
 
 	/*
 	 * Set the root start and end for Mem Resource.
@@ -490,6 +386,7 @@ sn_pci_fixup(int arg)
 		unsigned int irq;
 		int idx;
 		u16 cmd;
+		vertex_hdl_t vhdl;
 		unsigned long size;
 		extern int bit_pos_to_irq(int);
 
@@ -497,18 +394,16 @@ sn_pci_fixup(int arg)
 
 		device_sysdata = kmalloc(sizeof(struct sn_device_sysdata),
 					 GFP_KERNEL);
+		if (device_sysdata <= 0) {
+			printk("sn_pci_fixup: Cannot allocate memory for device sysdata\n");
+			return;
+		}
+
 		device_sysdata->vhdl = devfn_to_vertex(device_dev->bus->number, device_dev->devfn);
 		device_sysdata->isa64 = 0;
-		device_vertex = device_sysdata->vhdl;
-
 		device_dev->sysdata = (void *) device_sysdata;
-		set_isPIC(device_sysdata);
+		set_pci_provider(device_sysdata);
 
-		/*
-		 * Set the xbridge Device(X) Write Buffer Flush and Xbow Flush 
-		 * register addresses.
-		 */
-		set_flush_addresses(device_dev, device_sysdata);
 		pci_read_config_word(device_dev, PCI_COMMAND, &cmd);
 
 		/*
@@ -517,22 +412,62 @@ sn_pci_fixup(int arg)
 		 * read from the card and it was set in the card by our
 		 * Infrastructure ..
 		 */
+		vhdl = device_sysdata->vhdl;
+		/* Allocate the IORESOURCE_IO space first */
 		for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) {
-			size = 0;
-			size = device_dev->resource[idx].end -
-				device_dev->resource[idx].start;
-			if (size) {
-				device_dev->resource[idx].start = (unsigned long)pciio_pio_addr(device_vertex, 0, PCIIO_SPACE_WIN(idx), 0, size, 0, (IS_PIC_DEVICE(device_dev)) ? 0 : PCIIO_BYTE_STREAM);
-				device_dev->resource[idx].start |= __IA64_UNCACHED_OFFSET;
-			}
-			else
-				continue;
+			unsigned long start, end, addr;
 
-			device_dev->resource[idx].end = 
-				device_dev->resource[idx].start + size;
+			if (!(device_dev->resource[idx].flags & IORESOURCE_IO))
+				continue; 
+			
+			start = device_dev->resource[idx].start;
+			end = device_dev->resource[idx].end;
+			size = end - start;
+			if (!size)
+				continue; 
+			
+			addr = (unsigned long)pciio_pio_addr(vhdl, 0, 
+					PCIIO_SPACE_WIN(idx), 0, size, 0, 0);
+			if (!addr) {
+				device_dev->resource[idx].start = 0;
+				device_dev->resource[idx].end = 0;
+				printk("sn_pci_fixup(): pio map failure for "
+				    "%s bar%d\n", device_dev->slot_name, idx);
+			} else {
+				addr |= __IA64_UNCACHED_OFFSET;
+				device_dev->resource[idx].start = addr;
+				device_dev->resource[idx].end = addr + size;
+			}	
 
-			if (device_dev->resource[idx].flags & IORESOURCE_IO)
-				cmd |= PCI_COMMAND_IO;
+			if (device_dev->resource[idx].flags & IORESOURCE_IO) 
+				cmd |= PCI_COMMAND_IO; 
+		} 
+
+		/* Allocate the IORESOURCE_MEM space next */
+		for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) {
+			unsigned long start, end, addr;
+
+			if ((device_dev->resource[idx].flags & IORESOURCE_IO))
+				continue; 
+
+			start = device_dev->resource[idx].start;
+			end = device_dev->resource[idx].end;
+			size = end - start;
+			if (!size)
+				continue; 
+
+			addr = (unsigned long)pciio_pio_addr(vhdl, 0, 
+					PCIIO_SPACE_WIN(idx), 0, size, 0, 0);
+			if (!addr) {
+				device_dev->resource[idx].start = 0;
+				device_dev->resource[idx].end = 0;
+				printk("sn_pci_fixup(): pio map failure for "
+				    "%s bar%d\n", device_dev->slot_name, idx);
+			} else {
+				addr |= __IA64_UNCACHED_OFFSET;
+				device_dev->resource[idx].start = addr;
+				device_dev->resource[idx].end = addr + size;
+			}	
 
 			if (device_dev->resource[idx].flags & IORESOURCE_MEM)
 				cmd |= PCI_COMMAND_MEMORY;
@@ -544,17 +479,19 @@ sn_pci_fixup(int arg)
 		cmd |= PCI_COMMAND_MASTER; /* If the device doesn't support */
 					   /* bit gets dropped .. no harm */
 		pci_write_config_word(device_dev, PCI_COMMAND, cmd);
-		
+
 		pci_read_config_byte(device_dev, PCI_INTERRUPT_PIN,
 				     (unsigned char *)&lines);
-	 
+		device_sysdata = (struct sn_device_sysdata *)device_dev->sysdata;
+		device_vertex = device_sysdata->vhdl;
+		pci_provider = device_sysdata->pci_provider;
+ 
 		irqpdaindr->curr = device_dev;
-		intr_handle = pcibr_intr_alloc(device_vertex, NULL, lines, device_vertex);
+		intr_handle = (pci_provider->intr_alloc)(device_vertex, NULL, lines, device_vertex);
 
 		irq = intr_handle->bi_irq;
 		irqpdaindr->device_dev[irq] = device_dev;
-		cpuid = intr_handle->bi_cpu;
-		pcibr_intr_connect(intr_handle, (intr_func_t)0, (intr_arg_t)0);
+		(pci_provider->intr_connect)(intr_handle, (intr_func_t)0, (intr_arg_t)0);
 		device_dev->irq = irq;
 		register_pcibr_intr(irq, intr_handle);
 
@@ -825,10 +762,8 @@ pci_bus_to_hcl_cvlink(void) 
 				
 	devfs_hdl = hwgraph_path_to_vertex("hw/module");
 	for (i = 0; i < nummodules ; i++) {
-	    for ( j = 0; j < 3; j++ ) {
+	    for ( j = 0; j < 2; j++ ) {
 		if ( j == 0 )
-			brick_name = EDGE_LBL_PBRICK;
-		else if ( j == 1 )
 			brick_name = EDGE_LBL_PXBRICK;
 		else
 			brick_name = EDGE_LBL_IXBRICK;
@@ -867,8 +802,8 @@ sn_pci_init (void)
 	int i = 0;
 	struct pci_controller *controller;
 
-	if (!ia64_platform_is("sn2"))
-	    return 0;
+	if (!ia64_platform_is("sn2") || IS_RUNNING_ON_SIMULATOR())
+		return 0;
 
 	/*
 	 * set pci_raw_ops, etc.
diff -puN arch/ia64/sn/io/machvec/pci.c~linus arch/ia64/sn/io/machvec/pci.c
--- 25/arch/ia64/sn/io/machvec/pci.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/machvec/pci.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
 /* 
- *
  * SNI64 specific PCI support for SNI IO.
  *
  * This file is subject to the terms and conditions of the GNU General Public
@@ -8,33 +7,15 @@
  *
  * Copyright (c) 1997, 1998, 2000-2003 Silicon Graphics, Inc.  All rights reserved.
  */
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <asm/sn/types.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/io.h>
-#include <asm/sn/driver.h>
-#include <asm/sn/iograph.h>
-#include <asm/param.h>
-#include <asm/sn/pio.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/sn_private.h>
-#include <asm/sn/addrs.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
-#include <asm/sn/hcl_util.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/pcibr.h>
 #include <asm/sn/pci/pcibr_private.h>
-#include <asm/sn/pci/bridge.h>
 
 /*
  * These routines are only used during sn_pci_init for probing each bus, and
  * can probably be removed with a little more cleanup now that the SAL routines
  * work on sn2.
  */
+
 extern vertex_hdl_t devfn_to_vertex(unsigned char bus, unsigned char devfn);
 
 int sn_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val)
diff -puN arch/ia64/sn/io/machvec/pci_dma.c~linus arch/ia64/sn/io/machvec/pci_dma.c
--- 25/arch/ia64/sn/io/machvec/pci_dma.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/machvec/pci_dma.c	2004-01-19 22:17:21.000000000 -0800
@@ -9,27 +9,8 @@
  * a description of how these routines should be used.
  */
 
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/module.h>
-
-#include <asm/delay.h>
-#include <asm/io.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/io.h>
-#include <asm/sn/invent.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/pci/pcibr_private.h>
-#include <asm/sn/driver.h>
-#include <asm/sn/types.h>
-#include <asm/sn/alenlist.h>
 #include <asm/sn/pci/pci_bus_cvlink.h>
-#include <asm/sn/nag.h>
 
 /*
  * For ATE allocations
@@ -130,10 +111,7 @@ find_sn_dma_map(dma_addr_t dma_addr, uns
  *
  * This interface is usually used for "command" streams (e.g. the command
  * queue for a SCSI controller).  See Documentation/DMA-mapping.txt for
- * more information.  Note that this routine will always put a 32 bit
- * DMA address into @dma_handle.  This is because most devices
- * that are capable of 64 bit PCI DMA transactions can't do 64 bit _coherent_
- * DMAs, and unfortunately this interface has to cater to the LCD.  Oh well.
+ * more information.
  *
  * Also known as platform_pci_alloc_consistent() by the IA64 machvec code.
  */
@@ -146,11 +124,6 @@ sn_pci_alloc_consistent(struct pci_dev *
 	unsigned long phys_addr;
 	pcibr_dmamap_t dma_map = 0;
 
-	*dma_handle = 0;
-
-	if (hwdev->dma_mask < 0xffffffffUL)
-		return NULL;
-
 	/*
 	 * Get hwgraph vertex for the device
 	 */
@@ -158,54 +131,48 @@ sn_pci_alloc_consistent(struct pci_dev *
 	vhdl = device_sysdata->vhdl;
 
 	/*
-	 * Allocate the memory.  FIXME: if we're allocating for
-	 * two devices on the same bus, we should at least try to
-	 * allocate memory in the same 2 GB window to avoid using
-	 * ATEs for the translation.  See the comment above about the
-	 * 32 bit requirement for this function.
+	 * Allocate the memory.
+	 * FIXME: We should be doing alloc_pages_node for the node closest
+	 *        to the PCI device.
 	 */
-	if(!(cpuaddr = (void *)__get_free_pages(GFP_ATOMIC, get_order(size))))
+	if (!(cpuaddr = (void *)__get_free_pages(GFP_ATOMIC, get_order(size))))
 		return NULL;
 
 	/* physical addr. of the memory we just got */
 	phys_addr = __pa(cpuaddr);
 
 	/*
-	 * This will try to use a Direct Map register to do the
-	 * 32 bit DMA mapping, but it may not succeed if another
-	 * device on the same bus is already mapped with different
-	 * attributes or to a different memory region.
-	 */
-	*dma_handle = pcibr_dmatrans_addr(vhdl, NULL, phys_addr, size,
-			((IS_PIC_DEVICE(hwdev)) ? 0 : PCIIO_BYTE_STREAM) |
-					  PCIIO_DMA_CMD);
-
-        /*
-	 * If this device is in PCI-X mode, the system would have
-	 * automatically allocated a 64Bits DMA Address.  Error out if the 
-	 * device cannot support DAC.
-	 */
-	if (*dma_handle > hwdev->consistent_dma_mask) {
-		free_pages((unsigned long) cpuaddr, get_order(size));
-		return NULL;
+	 * 64 bit address translations should never fail.
+	 * 32 bit translations can fail if there are insufficient mapping
+	 *   resources and the direct map is already wired to a different
+	 *   2GB range.
+	 * 32 bit translations can also return a > 32 bit address, because
+	 *   pcibr_dmatrans_addr ignores a missing PCIIO_DMA_A64 flag on
+	 *   PCI-X buses.
+	 */
+	if (hwdev->consistent_dma_mask == ~0UL)
+		*dma_handle = pcibr_dmatrans_addr(vhdl, NULL, phys_addr, size,
+					  PCIIO_DMA_CMD | PCIIO_DMA_A64);
+	else {
+		dma_map = pcibr_dmamap_alloc(vhdl, NULL, size, PCIIO_DMA_CMD);
+		if (dma_map) {
+			*dma_handle = (dma_addr_t)
+				pcibr_dmamap_addr(dma_map, phys_addr, size);
+			dma_map->bd_dma_addr = *dma_handle;
+		}
+		else {
+			*dma_handle = pcibr_dmatrans_addr(vhdl, NULL, phys_addr, size,
+						  PCIIO_DMA_CMD);
+		}
 	}
 
-	/*
-	 * It is a 32 bit card and we cannot do direct mapping,
-	 * so we try to use an ATE.
-	 */
-	if (!(*dma_handle)) {
-		dma_map = pcibr_dmamap_alloc(vhdl, NULL, size,
-				((IS_PIC_DEVICE(hwdev)) ? 0 : PCIIO_BYTE_STREAM) |
-					     PCIIO_DMA_CMD);
-		if (!dma_map) {
-			printk(KERN_ERR "sn_pci_alloc_consistent: Unable to "
-			       "allocate anymore 32 bit page map entries.\n");
-			return 0;
+	if (!*dma_handle || *dma_handle > hwdev->consistent_dma_mask) {
+		if (dma_map) {
+			pcibr_dmamap_done(dma_map);
+			pcibr_dmamap_free(dma_map);
 		}
-		*dma_handle = (dma_addr_t) pcibr_dmamap_addr(dma_map,phys_addr,
-							     size);
-		dma_map->bd_dma_addr = *dma_handle;
+		free_pages((unsigned long) cpuaddr, get_order(size));
+		return NULL;
 	}
 
         return cpuaddr;
@@ -238,7 +205,6 @@ sn_pci_free_consistent(struct pci_dev *h
 	if (dma_map) {
 		pcibr_dmamap_done(dma_map);
 		pcibr_dmamap_free(dma_map);
-		dma_map->bd_dma_addr = 0;
 	}
 	free_pages((unsigned long) vaddr, get_order(size));
 }
@@ -288,9 +254,7 @@ sn_pci_map_sg(struct pci_dev *hwdev, str
 		if (IS_PCIA64(hwdev)) {
 			sg->dma_address = pcibr_dmatrans_addr(vhdl, NULL, phys_addr,
 						       sg->length,
-			       ((IS_PIC_DEVICE(hwdev)) ? 0 : PCIIO_BYTE_STREAM) |
-						       PCIIO_DMA_DATA |
-						       PCIIO_DMA_A64);
+						       PCIIO_DMA_DATA | PCIIO_DMA_A64);
 			sg->dma_length = sg->length;
 			continue;
 		}
@@ -300,9 +264,7 @@ sn_pci_map_sg(struct pci_dev *hwdev, str
 		 */
 		if (IS_PCI32G(hwdev)) {
 			sg->dma_address = pcibr_dmatrans_addr(vhdl, NULL, phys_addr,
-						       sg->length,
-					((IS_PIC_DEVICE(hwdev)) ? 0 : PCIIO_BYTE_STREAM) |
-						       PCIIO_DMA_DATA);
+						       sg->length, PCIIO_DMA_DATA);
 			sg->dma_length = sg->length;
 			/*
 			 * See if we got a direct map entry
@@ -317,9 +279,7 @@ sn_pci_map_sg(struct pci_dev *hwdev, str
 		 * It is a 32 bit card and we cannot do direct mapping,
 		 * so we use an ATE.
 		 */
-		dma_map = pcibr_dmamap_alloc(vhdl, NULL, sg->length,
-				((IS_PIC_DEVICE(hwdev)) ? 0 : PCIIO_BYTE_STREAM) |
-					     PCIIO_DMA_DATA);
+		dma_map = pcibr_dmamap_alloc(vhdl, NULL, sg->length, PCIIO_DMA_DATA);
 		if (!dma_map) {
 			printk(KERN_ERR "sn_pci_map_sg: Unable to allocate "
 			       "anymore 32 bit page map entries.\n");
@@ -369,7 +329,6 @@ sn_pci_unmap_sg(struct pci_dev *hwdev, s
         		if (dma_map) {
                 		pcibr_dmamap_done(dma_map);
                 		pcibr_dmamap_free(dma_map);
-                		dma_map->bd_dma_addr = 0;
 			}
         	}
 
@@ -390,7 +349,7 @@ sn_pci_unmap_sg(struct pci_dev *hwdev, s
  * the IA64 machvec code.
  *
  * We map this to the one step pcibr_dmamap_trans interface rather than
- * the two step pciio_dmamap_alloc/pciio_dmamap_addr because we have
+ * the two step pcibr_dmamap_alloc/pcibr_dmamap_addr because we have
  * no way of saving the dmamap handle from the alloc to later free
  * (which is pretty much unacceptable).
  *
@@ -429,9 +388,7 @@ sn_pci_map_single(struct pci_dev *hwdev,
 	if (IS_PCIA64(hwdev)) {
 		/* This device supports 64 bit DMA addresses. */
 		dma_addr = pcibr_dmatrans_addr(vhdl, NULL, phys_addr, size,
-		       ((IS_PIC_DEVICE(hwdev)) ? 0 : PCIIO_BYTE_STREAM) |
-					       PCIIO_DMA_DATA |
-					       PCIIO_DMA_A64);
+					       PCIIO_DMA_DATA | PCIIO_DMA_A64);
 		return dma_addr;
 	}
 
@@ -443,7 +400,6 @@ sn_pci_map_single(struct pci_dev *hwdev,
 	 */
 	if (IS_PCI32G(hwdev)) {
 		dma_addr = pcibr_dmatrans_addr(vhdl, NULL, phys_addr, size,
-			((IS_PIC_DEVICE(hwdev)) ? 0 : PCIIO_BYTE_STREAM) |
 					       PCIIO_DMA_DATA);
 		if (dma_addr)
 			return dma_addr;
@@ -454,9 +410,7 @@ sn_pci_map_single(struct pci_dev *hwdev,
 	 * let's use the PMU instead.
 	 */
 	dma_map = NULL;
-	dma_map = pcibr_dmamap_alloc(vhdl, NULL, size, 
-			((IS_PIC_DEVICE(hwdev)) ? 0 : PCIIO_BYTE_STREAM) |
-			PCIIO_DMA_DATA);
+	dma_map = pcibr_dmamap_alloc(vhdl, NULL, size, PCIIO_DMA_DATA);
 
 	if (!dma_map) {
 		printk(KERN_ERR "pci_map_single: Unable to allocate anymore "
@@ -500,7 +454,6 @@ sn_pci_unmap_single(struct pci_dev *hwde
 	if (dma_map) {
 		pcibr_dmamap_done(dma_map);
 		pcibr_dmamap_free(dma_map);
-		dma_map->bd_dma_addr = 0;
 	}
 }
 
diff -puN arch/ia64/sn/io/Makefile~linus arch/ia64/sn/io/Makefile
--- 25/arch/ia64/sn/io/Makefile~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -9,7 +9,5 @@
 # Makefile for the sn io routines.
 #
 
-EXTRA_CFLAGS    := -DLITTLE_ENDIAN
-
-obj-y += sgi_if.o xswitch.o sgi_io_sim.o cdl.o \
+obj-y += xswitch.o cdl.o snia_if.o \
 	 io.o machvec/ drivers/ platform_init/ sn2/ hwgfs/
diff -puN -L arch/ia64/sn/io/platform_init/irix_io_init.c arch/ia64/sn/io/platform_init/irix_io_init.c~linus /dev/null
--- 25/arch/ia64/sn/io/platform_init/irix_io_init.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,88 +0,0 @@
-/* $Id$
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/types.h>
-#include <linux/config.h>
-#include <linux/slab.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/io.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/klconfig.h>
-#include <asm/sn/sn_private.h>
-#include <linux/smp.h>
-#include <asm/sn/simulator.h>
-
-extern void init_all_devices(void);
-extern void klhwg_add_all_modules(vertex_hdl_t);
-extern void klhwg_add_all_nodes(vertex_hdl_t);
-
-extern vertex_hdl_t hwgraph_root;
-extern void io_module_init(void);
-extern int pci_bus_to_hcl_cvlink(void);
-extern void mlreset(void);
-
-/* #define DEBUG_IO_INIT 1 */
-#ifdef DEBUG_IO_INIT
-#define DBG(x...) printk(x)
-#else
-#define DBG(x...)
-#endif /* DEBUG_IO_INIT */
-
-/*
- * This routine is responsible for the setup of all the IRIX hwgraph style
- * stuff that's been pulled into linux.  It's called by sn_pci_find_bios which
- * is called just before the generic Linux PCI layer does its probing (by 
- * platform_pci_fixup aka sn_pci_fixup).
- *
- * It is very IMPORTANT that this call is only made by the Master CPU!
- *
- */
-
-void
-irix_io_init(void)
-{
-	cnodeid_t cnode;
-
-	/*
-	 * This is the Master CPU.  Emulate mlsetup and main.c in Irix.
-	 */
-	mlreset();
-
-        /*
-         * Initialize platform-dependent vertices in the hwgraph:
-         *      module
-         *      node
-         *      cpu
-         *      memory
-         *      slot
-         *      hub
-         *      router
-         *      xbow
-         */
-
-        io_module_init(); /* Use to be called module_init() .. */
-        klhwg_add_all_modules(hwgraph_root);
-        klhwg_add_all_nodes(hwgraph_root);
-
-	for (cnode = 0; cnode < numnodes; cnode++) {
-		extern void per_hub_init(cnodeid_t);
-		per_hub_init(cnode);
-	}
-
-	/* We can do headless hub cnodes here .. */
-
-	/*
-	 *
-	 * Our IO Infrastructure drivers are in place .. 
-	 * Initialize the whole IO Infrastructure .. xwidget/device probes.
-	 *
-	 */
-	init_all_devices();
-	pci_bus_to_hcl_cvlink();
-}
diff -puN arch/ia64/sn/io/platform_init/Makefile~linus arch/ia64/sn/io/platform_init/Makefile
--- 25/arch/ia64/sn/io/platform_init/Makefile~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/platform_init/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -7,6 +7,4 @@
 #
 # Makefile for the sn2 io routines.
 
-EXTRA_CFLAGS    := -DLITTLE_ENDIAN
-
-obj-y				+=  sgi_io_init.o irix_io_init.o
+obj-y				+=  sgi_io_init.o
diff -puN arch/ia64/sn/io/platform_init/sgi_io_init.c~linus arch/ia64/sn/io/platform_init/sgi_io_init.c
--- 25/arch/ia64/sn/io/platform_init/sgi_io_init.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/platform_init/sgi_io_init.c	2004-01-19 22:17:21.000000000 -0800
@@ -17,19 +17,35 @@
 #include <asm/sn/sn_private.h>
 #include <asm/sn/pda.h>
 
+extern void init_all_devices(void);
+extern void klhwg_add_all_modules(vertex_hdl_t);
+extern void klhwg_add_all_nodes(vertex_hdl_t);
+
+extern int init_hcl(void);
+extern vertex_hdl_t hwgraph_root;
+extern void io_module_init(void);
+extern int pci_bus_to_hcl_cvlink(void);
+
+cpuid_t master_procid;
+nasid_t console_nasid = (nasid_t) - 1;
+char master_baseio_wid;
+
+nasid_t master_baseio_nasid;
+nasid_t master_nasid = INVALID_NASID;	/* This is the partition master nasid */
+
 /*
  * per_hub_init
  *
  * 	This code is executed once for each Hub chip.
  */
-void
+static void
 per_hub_init(cnodeid_t cnode)
 {
-	nasid_t		nasid;
-	nodepda_t	*npdap;
-	ii_icmr_u_t	ii_icmr;
-	ii_ibcr_u_t	ii_ibcr;
-	ii_ilcsr_u_t	ii_ilcsr;
+	nasid_t nasid;
+	nodepda_t *npdap;
+	ii_icmr_u_t ii_icmr;
+	ii_ibcr_u_t ii_ibcr;
+	ii_ilcsr_u_t ii_ilcsr;
 
 	nasid = COMPACT_TO_NASID_NODEID(cnode);
 
@@ -44,11 +60,11 @@ per_hub_init(cnodeid_t cnode)
 	/*
 	 * Set the total number of CRBs that can be used.
 	 */
-	ii_icmr.ii_icmr_regval= 0x0;
+	ii_icmr.ii_icmr_regval = 0x0;
 	ii_icmr.ii_icmr_fld_s.i_c_cnt = 0xf;
-	if (enable_shub_wars_1_1() ) {
+	if (enable_shub_wars_1_1()) {
 		// Set bit one of ICMR to prevent II from sending interrupt for II bug.
-		ii_icmr.ii_icmr_regval |= 0x1; 
+		ii_icmr.ii_icmr_regval |= 0x1;
 	}
 	REMOTE_HUB_S(nasid, IIO_ICMR, ii_icmr.ii_icmr_regval);
 
@@ -56,25 +72,106 @@ per_hub_init(cnodeid_t cnode)
 	 * Set the number of CRBs that both of the BTEs combined
 	 * can use minus 1.
 	 */
-	ii_ibcr.ii_ibcr_regval= 0x0;
+	ii_ibcr.ii_ibcr_regval = 0x0;
 	ii_ilcsr.ii_ilcsr_regval = REMOTE_HUB_L(nasid, IIO_LLP_CSR);
 	if (ii_ilcsr.ii_ilcsr_fld_s.i_llp_stat & LNK_STAT_WORKING) {
-	    ii_ibcr.ii_ibcr_fld_s.i_count = 0x8;
+		ii_ibcr.ii_ibcr_fld_s.i_count = 0x8;
 	} else {
-	    /*
-	     * if the LLP is down, there is no attached I/O, so
-	    * give BTE all the CRBs.
-	    */
-	    ii_ibcr.ii_ibcr_fld_s.i_count = 0x14;
+		/*
+		 * if the LLP is down, there is no attached I/O, so
+		 * give BTE all the CRBs.
+		 */
+		ii_ibcr.ii_ibcr_fld_s.i_count = 0x14;
 	}
 	REMOTE_HUB_S(nasid, IIO_IBCR, ii_ibcr.ii_ibcr_regval);
 
 	/*
 	 * Set CRB timeout to be 10ms.
 	 */
-	REMOTE_HUB_S(nasid, IIO_ICTP, 0xffffff );
+	REMOTE_HUB_S(nasid, IIO_ICTP, 0xffffff);
 	REMOTE_HUB_S(nasid, IIO_ICTO, 0xff);
 
 	/* Initialize error interrupts for this hub. */
 	hub_error_init(cnode);
 }
+
+/*
+ * This routine is responsible for the setup of all the IRIX hwgraph style
+ * stuff that's been pulled into linux.  It's called by sn_pci_find_bios which
+ * is called just before the generic Linux PCI layer does its probing (by 
+ * platform_pci_fixup aka sn_pci_fixup).
+ *
+ * It is very IMPORTANT that this call is only made by the Master CPU!
+ *
+ */
+
+void __init
+sgi_master_io_infr_init(void)
+{
+	cnodeid_t cnode;
+
+	if (init_hcl() < 0) {	/* Sets up the hwgraph compatibility layer */
+		printk("sgi_master_io_infr_init: Cannot init hcl\n");
+		return;
+	}
+
+	/*
+	 * Initialize platform-dependent vertices in the hwgraph:
+	 *      module
+	 *      node
+	 *      cpu
+	 *      memory
+	 *      slot
+	 *      hub
+	 *      router
+	 *      xbow
+	 */
+
+	io_module_init();	/* Use to be called module_init() .. */
+	klhwg_add_all_modules(hwgraph_root);
+	klhwg_add_all_nodes(hwgraph_root);
+
+	for (cnode = 0; cnode < numnodes; cnode++) {
+		extern void per_hub_init(cnodeid_t);
+		per_hub_init(cnode);
+	}
+
+	/*
+	 *
+	 * Our IO Infrastructure drivers are in place .. 
+	 * Initialize the whole IO Infrastructure .. xwidget/device probes.
+	 *
+	 */
+	init_all_devices();
+	pci_bus_to_hcl_cvlink();
+}
+
+inline int
+check_nasid_equiv(nasid_t nasida, nasid_t nasidb)
+{
+	if ((nasida == nasidb)
+	    || (nasida == NODEPDA(NASID_TO_COMPACT_NODEID(nasidb))->xbow_peer))
+		return 1;
+	else
+		return 0;
+}
+
+int
+is_master_baseio_nasid_widget(nasid_t test_nasid, xwidgetnum_t test_wid)
+{
+	/*
+	 * If the widget numbers are different, we're not the master.
+	 */
+	if (test_wid != (xwidgetnum_t) master_baseio_wid) {
+		return 0;
+	}
+
+	/*
+	 * If the NASIDs are the same or equivalent, we're the master.
+	 */
+	if (check_nasid_equiv(test_nasid, master_baseio_nasid)) {
+		return 1;
+	} else {
+		return 0;
+	}
+}
diff -puN -L arch/ia64/sn/io/sgi_if.c arch/ia64/sn/io/sgi_if.c~linus /dev/null
--- 25/arch/ia64/sn/io/sgi_if.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,136 +0,0 @@
-/* $Id$
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/types.h>
-#include <linux/ctype.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/invent.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/pci/bridge.h>
-#include <asm/sn/ioerror_handling.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/slotnum.h>
-
-void *
-snia_kmem_zalloc(size_t size, int flag)
-{
-        void *ptr = kmalloc(size, GFP_KERNEL);
-	if ( ptr )
-        	BZERO(ptr, size);
-        return(ptr);
-}
-
-void
-snia_kmem_free(void *ptr, size_t size)
-{
-        kfree(ptr);
-}
-
-/*
- * the alloc/free_node routines do a simple kmalloc for now ..
- */
-void *
-snia_kmem_alloc_node(register size_t size, register int flags, cnodeid_t node)
-{
-	/* someday will Allocate on node 'node' */
-	return(kmalloc(size, GFP_KERNEL));
-}
-
-void *
-snia_kmem_zalloc_node(register size_t size, register int flags, cnodeid_t node)
-{
-	void *ptr = kmalloc(size, GFP_KERNEL);
-	if ( ptr )
-		BZERO(ptr, size);
-        return(ptr);
-}
-
-
-/*
- * print_register() allows formatted printing of bit fields.  individual
- * bit fields are described by a struct reg_desc, multiple bit fields within
- * a single word can be described by multiple reg_desc structures.
- * %r outputs a string of the format "<bit field descriptions>"
- * %R outputs a string of the format "0x%x<bit field descriptions>"
- *
- * The fields in a reg_desc are:
- *	unsigned long long rd_mask; An appropriate mask to isolate the bit field
- *				within a word, and'ed with val
- *
- *	int rd_shift;		A shift amount to be done to the isolated
- *				bit field.  done before printing the isolate
- *				bit field with rd_format and before searching
- *				for symbolic value names in rd_values
- *
- *	char *rd_name;		If non-null, a bit field name to label any
- *				out from rd_format or searching rd_values.
- *				if neither rd_format or rd_values is non-null
- *				rd_name is printed only if the isolated
- *				bit field is non-null.
- *
- *	char *rd_format;	If non-null, the shifted bit field value
- *				is printed using this format.
- *
- *	struct reg_values *rd_values;	If non-null, a pointer to a table
- *				matching numeric values with symbolic names.
- *				rd_values are searched and the symbolic
- *				value is printed if a match is found, if no
- *				match is found "???" is printed.
- *				
- */
-
-void
-print_register(unsigned long long reg, struct reg_desc *addr)
-{
-	register struct reg_desc *rd;
-	register struct reg_values *rv;
-	unsigned long long field;
-	int any;
-
-	printk("<");
-	any = 0;
-	for (rd = addr; rd->rd_mask; rd++) {
-		field = reg & rd->rd_mask;
-		field = (rd->rd_shift > 0) ? field << rd->rd_shift : field >> -rd->rd_shift;
-		if (any && (rd->rd_format || rd->rd_values || (rd->rd_name && field)))
-			printk(",");
-		if (rd->rd_name) {
-			if (rd->rd_format || rd->rd_values || field) {
-				printk("%s", rd->rd_name);
-				any = 1;
-			}
-			if (rd->rd_format || rd->rd_values) {
-				printk("=");
-				any = 1;
-			}
-		}
-		/* You can have any format so long as it is %x */
-		if (rd->rd_format) {
-			printk("%llx", field);
-			any = 1;
-			if (rd->rd_values)
-				printk(":");
-		}
-		if (rd->rd_values) {
-			any = 1;
-			for (rv = rd->rd_values; rv->rv_name; rv++) {
-				if (field == rv->rv_value) {
-					printk("%s", rv->rv_name);
-					break;
-				}
-			}
-			if (rv->rv_name == NULL)
-				printk("???");
-		}
-	}
-	printk(">\n");
-}
diff -puN -L arch/ia64/sn/io/sgi_io_sim.c arch/ia64/sn/io/sgi_io_sim.c~linus /dev/null
--- 25/arch/ia64/sn/io/sgi_io_sim.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,79 +0,0 @@
-/* $Id$
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/sn_sal.h>
-#include <asm/sn/io.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/klconfig.h>
-#include <asm/sn/module.h>
-#include <asm/sn/sn_private.h>
-
-cpuid_t         master_procid;
-char arg_maxnodes[4];
-
-/*
- * Return non-zero if the given variable was specified
- */
-int
-is_specified(char *s)
-{
-        return (strlen(s) != 0);
-}
-
-/*
- * Routines provided by ml/SN/promif.c.
- */
-static __psunsigned_t master_bridge_base;
-nasid_t console_nasid = (nasid_t)-1;
-char master_baseio_wid;
-static char console_wid;
-static char console_pcislot;
-
-void
-set_master_bridge_base(void)
-{
-        console_wid = WIDGETID_GET(KL_CONFIG_CH_CONS_INFO(master_nasid)->memory_base);
-        console_pcislot = KL_CONFIG_CH_CONS_INFO(master_nasid)->npci;
-        master_bridge_base = (__psunsigned_t)NODE_SWIN_BASE(console_nasid, console_wid);
-	// FIXME("WARNING: set_master_bridge_base: NON NASID 0 DOES NOT WORK\n");
-}
-
-int
-check_nasid_equiv(nasid_t nasida, nasid_t nasidb)
-{
-        if ((nasida == nasidb) || (nasida == NODEPDA(NASID_TO_COMPACT_NODEID(nasidb))->xbow_peer))
-                return 1;
-        else
-                return 0;
-}
-
-int
-is_master_baseio_nasid_widget(nasid_t test_nasid, xwidgetnum_t test_wid)
-{
-	extern nasid_t master_baseio_nasid;
-
-        /*
-         * If the widget numbers are different, we're not the master.
-         */
-        if (test_wid != (xwidgetnum_t)master_baseio_wid) {
-                return 0;
-	}
-
-        /*
-         * If the NASIDs are the same or equivalent, we're the master.
-         */
-        if (check_nasid_equiv(test_nasid, master_baseio_nasid)) {
-                return 1;
-        } else {
-                return 0;
-        }
-}
diff -puN arch/ia64/sn/io/sn2/bte_error.c~linus arch/ia64/sn/io/sn2/bte_error.c
--- 25/arch/ia64/sn/io/sn2/bte_error.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/bte_error.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,35 +1,9 @@
 /*
- *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
  *
  * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- * 
- * This program is free software; you can redistribute it and/or modify it 
- * under the terms of version 2 of the GNU General Public License 
- * as published by the Free Software Foundation.
- * 
- * This program is distributed in the hope that it would be useful, but 
- * WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * 
- * Further, this software is distributed without any warranty that it is 
- * free of the rightful claim of any third person regarding infringement 
- * or the like.  Any license provided herein, whether implied or 
- * otherwise, applies only to this software file.  Patent licenses, if 
- * any, provided herein do not apply to combinations of this program with 
- * other software, or any other product whatsoever.
- * 
- * You should have received a copy of the GNU General Public 
- * License along with this program; if not, write the Free Software 
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- * 
- * Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 
- * Mountain View, CA  94043, or:
- * 
- * http://www.sgi.com 
- * 
- * For further information regarding this notice, see: 
- * 
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan
  */
 
 
@@ -39,7 +13,6 @@
 #include <asm/sn/sgi.h>
 #include <asm/sn/io.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/labelcl.h>
 #include <asm/sn/sn_private.h>
@@ -89,36 +62,11 @@ bte_crb_error_handler(vertex_hdl_t hub_v
 	 * in the bte handle structure for the thread excercising the
 	 * interface to consume.
 	 */
-	switch (ioe->ie_errortype) {
-	case IIO_ICRB_ECODE_PERR:
-		bte->bh_error = BTEFAIL_POISON;
-		break;
-	case IIO_ICRB_ECODE_WERR:
-		bte->bh_error = BTEFAIL_PROT;
-		break;
-	case IIO_ICRB_ECODE_AERR:
-		bte->bh_error = BTEFAIL_ACCESS;
-		break;
-	case IIO_ICRB_ECODE_TOUT:
-		bte->bh_error = BTEFAIL_TOUT;
-		break;
-	case IIO_ICRB_ECODE_XTERR:
-		bte->bh_error = BTEFAIL_XTERR;
-		break;
-	case IIO_ICRB_ECODE_DERR:
-		bte->bh_error = BTEFAIL_DIR;
-		break;
-	case IIO_ICRB_ECODE_PWERR:
-	case IIO_ICRB_ECODE_PRERR:
-		/* NO BREAK */
-	default:
-		bte->bh_error = BTEFAIL_ERROR;
-	}
-
+	bte->bh_error = ioe->ie_errortype + BTEFAIL_OFFSET;
 	bte->bte_error_count++;
 
-	BTE_PRINTK(("Got an error on cnode %d bte %d\n",
-		    bte->bte_cnode, bte->bte_num));
+	BTE_PRINTK(("Got an error on cnode %d bte %d: HW error type 0x%x\n",
+		    bte->bte_cnode, bte->bte_num, ioe->ie_errortype));
 	bte_error_handler((unsigned long) hinfo->h_nodepda);
 }
 
diff -puN arch/ia64/sn/io/sn2/geo_op.c~linus arch/ia64/sn/io/sn2/geo_op.c
--- 25/arch/ia64/sn/io/sn2/geo_op.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/geo_op.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -29,7 +28,6 @@
 #include <asm/sn/types.h>
 #include <asm/sn/sgi.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/labelcl.h>
 #include <asm/sn/io.h>
diff -puN arch/ia64/sn/io/sn2/klconflib.c~linus arch/ia64/sn/io/sn2/klconflib.c
--- 25/arch/ia64/sn/io/sn2/klconflib.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/klconflib.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -15,7 +14,6 @@
 #include <asm/sn/io.h>
 #include <asm/sn/sn_cpuid.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/labelcl.h>
 #include <asm/sn/klconfig.h>
@@ -23,11 +21,9 @@
 #include <asm/sn/module.h>
 #include <asm/sn/router.h>
 #include <asm/sn/xtalk/xbow.h>
+#include <asm/sn/ksys/l1.h>
 
 
-#define LDEBUG 0
-#define NIC_UNKNOWN ((nic_t) -1)
-
 #undef DEBUG_KLGRAPH
 #ifdef DEBUG_KLGRAPH
 #define DBG(x...) printk(x)
@@ -35,11 +31,11 @@
 #define DBG(x...)
 #endif /* DEBUG_KLGRAPH */
 
-u64 klgraph_addr[MAX_COMPACT_NODES];
+lboard_t *root_lboard[MAX_COMPACT_NODES];
 static int hasmetarouter;
 
 
-char brick_types[MAX_BRICK_TYPES + 1] = "crikxdpn%#=012345";
+char brick_types[MAX_BRICK_TYPES + 1] = "crikxdpn%#=vo^34567890123456789...";
 
 lboard_t *
 find_lboard(lboard_t *start, unsigned char brd_type)
@@ -270,17 +266,11 @@ board_to_path(lboard_t *brd, char *path)
 				board_name = EDGE_LBL_PXBRICK;
 			else if (brd->brd_type == KLTYPE_IXBRICK)
 				board_name = EDGE_LBL_IXBRICK;
-			else if (brd->brd_type == KLTYPE_PBRICK)
-				board_name = EDGE_LBL_PBRICK;
-			else if (brd->brd_type == KLTYPE_IBRICK)
-				board_name = EDGE_LBL_IBRICK;
-			else if (brd->brd_type == KLTYPE_XBRICK)
-				board_name = EDGE_LBL_XBRICK;
-			else if (brd->brd_type == KLTYPE_PEBRICK)
-				board_name = EDGE_LBL_PEBRICK;
+			else if (brd->brd_type == KLTYPE_OPUSBRICK)
+				board_name = EDGE_LBL_OPUSBRICK;
 			else if (brd->brd_type == KLTYPE_CGBRICK)
 				board_name = EDGE_LBL_CGBRICK;
-			else
+			else 
 				board_name = EDGE_LBL_IOBRICK;
 			break;
 		default:
@@ -293,23 +283,6 @@ board_to_path(lboard_t *brd, char *path)
 	sprintf(path, EDGE_LBL_MODULE "/%s/" EDGE_LBL_SLAB "/%d/%s", buffer, geo_slab(brd->brd_geoid), board_name);
 }
 
-/*
- * Get the module number for a NASID.
- */
-moduleid_t
-get_module_id(nasid_t nasid)
-{
-	lboard_t *brd;
-
-	brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_SNIA);
-
-	if (!brd)
-		return INVALID_MODULE;
-	else
-		return geo_module(brd->brd_geoid);
-}
-
-
 #define MHZ	1000000
 
 
@@ -440,71 +413,24 @@ board_serial_number_get(lboard_t *board,
 		break;
 	}
 	case KLCLASS_IO: {	/* IO board */
-		if (KLTYPE(board->brd_type) == KLTYPE_TPU) {
-		/* Special case for TPU boards */
-			kltpu_t *tpu;	
+	     	klbri_t	*bridge;
 		
-			/* Get the tpu component information */
-			tpu = (kltpu_t *)find_first_component(board,
-						      KLSTRUCT_TPU);
-			/* If we don't have a tpu component on a tpu board
-			 * then we have a weird klconfig.
-			 */
-			if (!tpu)
-				return(1);
-			/* Get the serial number information from
-			 * the tpu's manufacturing nic info
-			 */
-			if (component_serial_number_get(board,
-						tpu->tpu_mfg_nic,
-						serial_number,
-						""))
-				return(1);
-			break;
-		} else  if ((KLTYPE(board->brd_type) == KLTYPE_GSN_A) ||
-		            (KLTYPE(board->brd_type) == KLTYPE_GSN_B)) {
-		/* Special case for GSN boards */
-			klgsn_t *gsn;	
-		
-			/* Get the gsn component information */
-			gsn = (klgsn_t *)find_first_component(board,
-			      ((KLTYPE(board->brd_type) == KLTYPE_GSN_A) ?
-					KLSTRUCT_GSN_A : KLSTRUCT_GSN_B));
-			/* If we don't have a gsn component on a gsn board
-			 * then we have a weird klconfig.
-			 */
-			if (!gsn)
-				return(1);
-			/* Get the serial number information from
-			 * the gsn's manufacturing nic info
-			 */
-			if (component_serial_number_get(board,
-						gsn->gsn_mfg_nic,
-						serial_number,
-						""))
-				return(1);
-			break;
-		} else {
-		     	klbri_t	*bridge;
-		
-			/* Get the bridge component information */
-			bridge = (klbri_t *)find_first_component(board,
+		/* Get the bridge component information */
+		bridge = (klbri_t *)find_first_component(board,
 							 KLSTRUCT_BRI);
-			/* If we don't have a bridge component on an IO board
-			 * then we have a weird klconfig.
-			 */
-			if (!bridge)
-				return(1);
-			/* Get the serial number information from
-		 	 * the bridge's manufacturing nic info
-			 */
-			if (component_serial_number_get(board,
-						bridge->bri_mfg_nic,
-						serial_number,
-						""))
-				return(1);
-			break;
-		}
+		/* If we don't have a bridge component on an IO board
+		 * then we have a weird klconfig.
+		 */
+		if (!bridge)
+			return(1);
+		/* Get the serial number information from
+	 	 * the bridge's manufacturing nic info
+		 */
+		if (component_serial_number_get(board,
+					bridge->bri_mfg_nic,
+					serial_number, ""))
+			return(1);
+		break;
 	}
 	case KLCLASS_ROUTER: {	/* Router board */
 		klrou_t *router;	
@@ -558,6 +484,23 @@ board_serial_number_get(lboard_t *board,
 
 /*
  * Format a module id for printing.
+ *
+ * There are three possible formats:
+ *
+ *   MODULE_FORMAT_BRIEF	is the brief 6-character format, including
+ *				the actual brick-type as recorded in the 
+ *				moduleid_t, eg. 002c15 for a C-brick, or
+ *				101#17 for a PX-brick.
+ *
+ *   MODULE_FORMAT_LONG		is the hwgraph format, eg. rack/002/bay/15
+ *				of rack/101/bay/17 (note that the brick
+ *				type does not appear in this format).
+ *
+ *   MODULE_FORMAT_LCD		is like MODULE_FORMAT_BRIEF, except that it
+ *				ensures that the module id provided appears
+ *				exactly as it would on the LCD display of
+ *				the corresponding brick, eg. still 002c15
+ *				for a C-brick, but 101p17 for a PX-brick.
  */
 void
 format_module_id(char *buffer, moduleid_t m, int fmt)
@@ -569,9 +512,25 @@ format_module_id(char *buffer, moduleid_
 	ASSERT(MODULE_GET_BTYPE(m) < MAX_BRICK_TYPES);
 	brickchar = MODULE_GET_BTCHAR(m);
 
+	if (fmt == MODULE_FORMAT_LCD) {
+	    /* Be sure we use the same brick type character as displayed
+	     * on the brick's LCD
+	     */
+	    switch (brickchar) 
+	    {
+	    case L1_BRICKTYPE_PX:
+		brickchar = L1_BRICKTYPE_P;
+		break;
+
+	    case L1_BRICKTYPE_IX:
+		brickchar = L1_BRICKTYPE_I;
+		break;
+	    }
+	}
+
 	position = MODULE_GET_BPOS(m);
 
-	if (fmt == MODULE_FORMAT_BRIEF) {
+	if ((fmt == MODULE_FORMAT_BRIEF) || (fmt == MODULE_FORMAT_LCD)) {
 	    /* Brief module number format, eg. 002c15 */
 
 	    /* Decompress the rack number */
@@ -686,3 +645,27 @@ parse_module_id(char *buffer)
 	/* avoid sign extending the moduleid_t */
 	return (int)(unsigned short)m;
 }
+
+int
+cbrick_type_get_nasid(nasid_t nasid)
+{
+	lboard_t *brd;
+	moduleid_t module;
+	uint type;
+	int t;
+
+	brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_SNIA);
+	module = geo_module(brd->brd_geoid);
+	type = (module & MODULE_BTYPE_MASK) >> MODULE_BTYPE_SHFT;
+	/* convert brick_type to lower case */
+	if ((type >= 'A') && (type <= 'Z'))
+		type = type - 'A' + 'a';
+    
+	/* convert to a module.h brick type */
+	for( t = 0; t < MAX_BRICK_TYPES; t++ ) {
+		if( brick_types[t] == type ) {
+			return t;
+		}
+	} 
+	return -1;
+}
diff -puN arch/ia64/sn/io/sn2/klgraph.c~linus arch/ia64/sn/io/sn2/klgraph.c
--- 25/arch/ia64/sn/io/sn2/klgraph.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/klgraph.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -15,196 +14,26 @@
 
 #include <linux/types.h>
 #include <linux/slab.h>
+#include <linux/init.h>
 #include <asm/sn/sgi.h>
 #include <asm/sn/sn_sal.h>
-#include <asm/sn/io.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/kldir.h>
-#include <asm/sn/klconfig.h>
-#include <asm/sn/router.h>
-#include <asm/sn/xtalk/xbow.h>
 #include <asm/sn/hcl_util.h>
+#include <asm/sn/sn_private.h>
 
-// #define KLGRAPH_DEBUG 1
+/* #define KLGRAPH_DEBUG 1 */
 #ifdef KLGRAPH_DEBUG
 #define GRPRINTF(x)	printk x
-#define CE_GRPANIC	CE_PANIC
 #else
 #define GRPRINTF(x)
-#define CE_GRPANIC	CE_PANIC
 #endif
 
-#include <asm/sn/sn_private.h>
-
-extern char arg_maxnodes[];
-extern u64 klgraph_addr[];
 void mark_cpuvertex_as_cpu(vertex_hdl_t vhdl, cpuid_t cpuid);
 
 
-/*
- * Support for verbose inventory via hardware graph. 
- * klhwg_invent_alloc allocates the necessary size of inventory information
- * and fills in the generic information.
- */
-invent_generic_t *
-klhwg_invent_alloc(cnodeid_t cnode, int class, int size)
-{
-	invent_generic_t *invent;
-
-	invent = kern_malloc(size);
-	if (!invent) return NULL;
-	
-	invent->ig_module = NODE_MODULEID(cnode);
-	invent->ig_slot = SLOTNUM_GETSLOT(NODE_SLOTID(cnode));
-	invent->ig_invclass = class;
-
-	return invent;
-}
-
-/*
- * Add detailed disabled cpu inventory info to the hardware graph.
- */
-void
-klhwg_disabled_cpu_invent_info(vertex_hdl_t cpuv,
-                               cnodeid_t cnode,
-                               klcpu_t *cpu, slotid_t slot)
-{
-	invent_cpuinfo_t *cpu_invent;
-	diag_inv_t       *diag_invent;
-
-	cpu_invent = (invent_cpuinfo_t *)
-	klhwg_invent_alloc(cnode, INV_PROCESSOR, sizeof(invent_cpuinfo_t));
-	if (!cpu_invent)
-		return;
-
-	/* Diag information on this processor */
-	diag_invent = (diag_inv_t *)
-	klhwg_invent_alloc(cnode, INV_CPUDIAGVAL, sizeof(diag_inv_t));
-
-	if (!diag_invent)
-		return;
-
-
-	/* Disabled CPU */
-	cpu_invent->ic_gen.ig_flag = 0x0;
-	cpu_invent->ic_gen.ig_slot = slot;
-	cpu_invent->ic_cpu_info.cpuflavor = cpu->cpu_prid;
-	cpu_invent->ic_cpu_info.cpufq = cpu->cpu_speed;
-	cpu_invent->ic_cpu_info.sdfreq = cpu->cpu_scachespeed;
-
-	cpu_invent->ic_cpu_info.sdsize = cpu->cpu_scachesz;
-	cpu_invent->ic_cpuid = cpu->cpu_info.virtid;
-	cpu_invent->ic_slice = cpu->cpu_info.physid;
-
-	/* Disabled CPU label */
-	hwgraph_info_add_LBL(cpuv, INFO_LBL_DETAIL_INVENT,
-			(arbitrary_info_t) cpu_invent);
-	hwgraph_info_export_LBL(cpuv, INFO_LBL_DETAIL_INVENT,
-			sizeof(invent_cpuinfo_t));
-
-	/* Diagval label - stores reason for disable +{virt,phys}id +diagval*/
-	hwgraph_info_add_LBL(cpuv, INFO_LBL_DIAGVAL,
-			(arbitrary_info_t) diag_invent);
-
-	hwgraph_info_export_LBL(cpuv, INFO_LBL_DIAGVAL,
-			sizeof(diag_inv_t));
-}
-
-/*
- * Add detailed cpu inventory info to the hardware graph.
- */
-void
-klhwg_cpu_invent_info(vertex_hdl_t cpuv,
-			cnodeid_t cnode,
-			klcpu_t *cpu)
-{
-	invent_cpuinfo_t *cpu_invent;
-
-	cpu_invent = (invent_cpuinfo_t *)
-		klhwg_invent_alloc(cnode, INV_PROCESSOR, sizeof(invent_cpuinfo_t));
-	if (!cpu_invent)
-		return;
-
-	if (KLCONFIG_INFO_ENABLED((klinfo_t *)cpu))
-		cpu_invent->ic_gen.ig_flag = INVENT_ENABLED;
-	else
-		cpu_invent->ic_gen.ig_flag = 0x0;
-
-	cpu_invent->ic_cpu_info.cpuflavor = cpu->cpu_prid;
-	cpu_invent->ic_cpu_info.cpufq = cpu->cpu_speed;
-	cpu_invent->ic_cpu_info.sdfreq = cpu->cpu_scachespeed;
-
-	cpu_invent->ic_cpu_info.sdsize = cpu->cpu_scachesz;
-	cpu_invent->ic_cpuid = cpu->cpu_info.virtid;
-	cpu_invent->ic_slice = cpu_physical_id_to_slice(cpu->cpu_info.virtid);
-
-	hwgraph_info_add_LBL(cpuv, INFO_LBL_DETAIL_INVENT,
-			(arbitrary_info_t) cpu_invent);
-	hwgraph_info_export_LBL(cpuv, INFO_LBL_DETAIL_INVENT,
-			sizeof(invent_cpuinfo_t));
-}
-
-/* 
- * Add information about the baseio prom version number
- * as a part of detailed inventory info in the hwgraph.
- */
-void
-klhwg_baseio_inventory_add(vertex_hdl_t baseio_vhdl,cnodeid_t cnode)
-{
-	invent_miscinfo_t	*baseio_inventory;
-	unsigned char		version = 0,revision = 0;
-
-	/* Allocate memory for the "detailed inventory" info
-	 * for the baseio
-	 */
-	baseio_inventory = (invent_miscinfo_t *) 
-		klhwg_invent_alloc(cnode, INV_PROM, sizeof(invent_miscinfo_t));
-	baseio_inventory->im_type = INV_IO6PROM;
-	/* Store the revision info  in the inventory */
-	baseio_inventory->im_version = version;
-	baseio_inventory->im_rev = revision;
-	/* Put the inventory info in the hardware graph */
-	hwgraph_info_add_LBL(baseio_vhdl, INFO_LBL_DETAIL_INVENT, 
-			     (arbitrary_info_t) baseio_inventory);
-	/* Make the information available to the user programs
-	 * thru hwgfs.
-	 */
-        hwgraph_info_export_LBL(baseio_vhdl, INFO_LBL_DETAIL_INVENT,
-				sizeof(invent_miscinfo_t));
-}
-
-/*
- * Add detailed cpu inventory info to the hardware graph.
- */
-void
-klhwg_hub_invent_info(vertex_hdl_t hubv,
-		      cnodeid_t cnode, 
-		      klhub_t *hub)
-{
-	invent_miscinfo_t *hub_invent;
-
-	hub_invent = (invent_miscinfo_t *) 
-	    klhwg_invent_alloc(cnode, INV_MISC, sizeof(invent_miscinfo_t));
-	if (!hub_invent)
-	    return;
-
-	if (KLCONFIG_INFO_ENABLED((klinfo_t *)hub))
-	    hub_invent->im_gen.ig_flag = INVENT_ENABLED;
-
-	hub_invent->im_type = INV_HUB;
-	hub_invent->im_rev = hub->hub_info.revision;
-	hub_invent->im_speed = hub->hub_speed;
-	hwgraph_info_add_LBL(hubv, INFO_LBL_DETAIL_INVENT, 
-			     (arbitrary_info_t) hub_invent);
-        hwgraph_info_export_LBL(hubv, INFO_LBL_DETAIL_INVENT,
-				sizeof(invent_miscinfo_t));
-}
-
 /* ARGSUSED */
-void
+static void __init
 klhwg_add_hub(vertex_hdl_t node_vertex, klhub_t *hub, cnodeid_t cnode)
 {
 	vertex_hdl_t myhubv;
@@ -212,18 +41,23 @@ klhwg_add_hub(vertex_hdl_t node_vertex, 
 	int rc;
 	extern struct file_operations shub_mon_fops;
 
-	GRPRINTF(("klhwg_add_hub: adding %s\n", EDGE_LBL_HUB));
-	(void) hwgraph_path_add(node_vertex, EDGE_LBL_HUB, &myhubv);
+	hwgraph_path_add(node_vertex, EDGE_LBL_HUB, &myhubv);
+
+	HWGRAPH_DEBUG((__FILE__, __FUNCTION__,__LINE__, myhubv, NULL, "Created path for hub vertex for Shub node.\n"));
+
 	rc = device_master_set(myhubv, node_vertex);
+	if (rc) {
+		printk("klhwg_add_hub: Unable to create hub vertex.\n");
+		return;
+	}
 	hub_mon = hwgraph_register(myhubv, EDGE_LBL_PERFMON,
-		0, 0,
-		0, 0,
+		0, 0, 0, 0,
 		S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, 0, 0,
 		&shub_mon_fops, (void *)(long)cnode);
 }
 
 /* ARGSUSED */
-void
+static void __init
 klhwg_add_disabled_cpu(vertex_hdl_t node_vertex, cnodeid_t cnode, klcpu_t *cpu, slotid_t slot)
 {
         vertex_hdl_t my_cpu;
@@ -234,19 +68,19 @@ klhwg_add_disabled_cpu(vertex_hdl_t node
 	nasid = COMPACT_TO_NASID_NODEID(cnode);
         cpu_id = nasid_slice_to_cpuid(nasid, cpu->cpu_info.physid);
         if(cpu_id != -1){
-		sprintf(name, "%s/%s/%c", EDGE_LBL_DISABLED, EDGE_LBL_CPU, 'a' + cpu->cpu_info.physid);
+		snprintf(name, 120, "%s/%s/%c", EDGE_LBL_DISABLED, EDGE_LBL_CPU, 'a' + cpu->cpu_info.physid);
 		(void) hwgraph_path_add(node_vertex, name, &my_cpu);
 
+		HWGRAPH_DEBUG((__FILE__, __FUNCTION__,__LINE__, my_cpu, NULL, "Created path for disabled cpu slice.\n"));
+
 		mark_cpuvertex_as_cpu(my_cpu, cpu_id);
 		device_master_set(my_cpu, node_vertex);
-
-		klhwg_disabled_cpu_invent_info(my_cpu, cnode, cpu, slot);
 		return;
         }
 }
 
 /* ARGSUSED */
-void
+static void __init
 klhwg_add_cpu(vertex_hdl_t node_vertex, cnodeid_t cnode, klcpu_t *cpu)
 {
         vertex_hdl_t my_cpu, cpu_dir;
@@ -257,27 +91,28 @@ klhwg_add_cpu(vertex_hdl_t node_vertex, 
 	nasid = COMPACT_TO_NASID_NODEID(cnode);
         cpu_id = nasid_slice_to_cpuid(nasid, cpu->cpu_info.physid);
 
-        sprintf(name, "%s/%d/%c",
+        snprintf(name, 120, "%s/%d/%c",
                 EDGE_LBL_CPUBUS,
                 0,
                 'a' + cpu->cpu_info.physid);
 
-        GRPRINTF(("klhwg_add_cpu: adding %s to vertex 0x%p\n", name, node_vertex));
         (void) hwgraph_path_add(node_vertex, name, &my_cpu);
-        mark_cpuvertex_as_cpu(my_cpu, cpu_id);
+
+	HWGRAPH_DEBUG((__FILE__, __FUNCTION__,__LINE__, my_cpu, NULL, "Created path for active cpu slice.\n"));
+
+	mark_cpuvertex_as_cpu(my_cpu, cpu_id);
         device_master_set(my_cpu, node_vertex);
 
         /* Add an alias under the node's CPU directory */
         if (hwgraph_edge_get(node_vertex, EDGE_LBL_CPU, &cpu_dir) == GRAPH_SUCCESS) {
-                sprintf(name, "%c", 'a' + cpu->cpu_info.physid);
+                snprintf(name, 120, "%c", 'a' + cpu->cpu_info.physid);
                 (void) hwgraph_edge_add(cpu_dir, my_cpu, name);
+		HWGRAPH_DEBUG((__FILE__, __FUNCTION__,__LINE__, cpu_dir, my_cpu, "Created % from vhdl1 to vhdl2.\n", name));
         }
-
-        klhwg_cpu_invent_info(my_cpu, cnode, cpu);
 }
 
 
-void
+static void __init
 klhwg_add_xbow(cnodeid_t cnode, nasid_t nasid)
 {
 	lboard_t *brd;
@@ -295,9 +130,6 @@ klhwg_add_xbow(cnodeid_t cnode, nasid_t 
 	if (KL_CONFIG_DUPLICATE_BOARD(brd))
 	    return;
 
-	GRPRINTF(("klhwg_add_xbow: adding cnode %d nasid %d xbow edges\n",
-			cnode, nasid));
-
 	if ((xbow_p = (klxbow_t *)find_component(brd, NULL, KLSTRUCT_XBOW))
 	    == NULL)
 	    return;
@@ -314,7 +146,7 @@ klhwg_add_xbow(cnodeid_t cnode, nasid_t 
 
 		hub_cnode = NASID_TO_COMPACT_NODEID(hub_nasid);
 
-		if (is_specified(arg_maxnodes) && hub_cnode == INVALID_CNODEID) {
+		if (hub_cnode == INVALID_CNODEID) {
 			continue;
 		}
 			
@@ -326,11 +158,15 @@ klhwg_add_xbow(cnodeid_t cnode, nasid_t 
                                 printk(KERN_WARNING  "klhwg_add_xbow: Check for "
                                         "working routers and router links!");
 
-                        PRINT_PANIC("klhwg_add_xbow: Failed to add "
+                        printk("klhwg_add_xbow: Failed to add "
                                 "edge: vertex 0x%p to vertex 0x%p,"
                                 "error %d\n",
                                 (void *)hubv, (void *)xbow_v, err);
+			return;
                 }
+
+		HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, xbow_v, NULL, "Created path for xtalk.\n"));
+
 		xswitch_vertex_init(xbow_v); 
 
 		NODEPDA(hub_cnode)->xbow_vhdl = xbow_v;
@@ -344,15 +180,12 @@ klhwg_add_xbow(cnodeid_t cnode, nasid_t 
 			NODEPDA(NASID_TO_COMPACT_NODEID(nasid))->xbow_peer =
 				hub_nasid;
 		}
-
-		GRPRINTF(("klhwg_add_xbow: adding port nasid %d %s to vertex 0x%p\n",
-			hub_nasid, EDGE_LBL_XTALK, hubv));
 	}
 }
 
 
 /* ARGSUSED */
-void
+static void __init
 klhwg_add_node(vertex_hdl_t hwgraph_root, cnodeid_t cnode)
 {
 	nasid_t nasid;
@@ -364,98 +197,78 @@ klhwg_add_node(vertex_hdl_t hwgraph_root
 	char *s;
 	int board_disabled = 0;
 	klcpu_t *cpu;
+	vertex_hdl_t cpu_dir;
 
 	nasid = COMPACT_TO_NASID_NODEID(cnode);
 	brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_SNIA);
-	GRPRINTF(("klhwg_add_node: Adding cnode %d, nasid %d, brd 0x%p\n",
-                cnode, nasid, brd));
 	ASSERT(brd);
 
-	do {
-		vertex_hdl_t cpu_dir;
-
-		/* Generate a hardware graph path for this board. */
-		board_to_path(brd, path_buffer);
-
-		GRPRINTF(("klhwg_add_node: adding %s to vertex 0x%p\n",
-			path_buffer, hwgraph_root));
-		rv = hwgraph_path_add(hwgraph_root, path_buffer, &node_vertex);
-
-		if (rv != GRAPH_SUCCESS)
-			PRINT_PANIC("Node vertex creation failed.  "
-					  "Path == %s",
-				path_buffer);
+	/* Generate a hardware graph path for this board. */
+	board_to_path(brd, path_buffer);
+	rv = hwgraph_path_add(hwgraph_root, path_buffer, &node_vertex);
+	if (rv != GRAPH_SUCCESS) {
+		printk("Node vertex creation failed.  Path == %s", path_buffer);
+		return;
+	}
 
-		hub = (klhub_t *)find_first_component(brd, KLSTRUCT_HUB);
-		ASSERT(hub);
-		if(hub->hub_info.flags & KLINFO_ENABLE)
-			board_disabled = 0;
-		else
-			board_disabled = 1;
+	HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, node_vertex, NULL, "Created path for SHUB node.\n"));
+	hub = (klhub_t *)find_first_component(brd, KLSTRUCT_HUB);
+	ASSERT(hub);
+	if(hub->hub_info.flags & KLINFO_ENABLE)
+		board_disabled = 0;
+	else
+		board_disabled = 1;
 		
-		if(!board_disabled) {
-			mark_nodevertex_as_node(node_vertex,
-					    cnode + board_disabled * numnodes);
-
-			s = dev_to_name(node_vertex, path_buffer, sizeof(path_buffer));
-			NODEPDA(cnode)->hwg_node_name =
-						kmalloc(strlen(s) + 1,
-						GFP_KERNEL);
-			ASSERT_ALWAYS(NODEPDA(cnode)->hwg_node_name != NULL);
-			strcpy(NODEPDA(cnode)->hwg_node_name, s);
-
-			hubinfo_set(node_vertex, NODEPDA(cnode)->pdinfo);
-
-			/* Set up node board's slot */
-			NODEPDA(cnode)->slotdesc = brd->brd_slot;
-
-			/* Set up the module we're in */
-			NODEPDA(cnode)->geoid = brd->brd_geoid;
-			NODEPDA(cnode)->module = module_lookup(geo_module(brd->brd_geoid));
+	if(!board_disabled) {
+		mark_nodevertex_as_node(node_vertex, cnode);
+		s = dev_to_name(node_vertex, path_buffer, sizeof(path_buffer));
+		NODEPDA(cnode)->hwg_node_name =
+					kmalloc(strlen(s) + 1, GFP_KERNEL);
+		if (NODEPDA(cnode)->hwg_node_name <= 0) {
+			printk("%s: no memory\n", __FUNCTION__);
+			return;
 		}
+		strcpy(NODEPDA(cnode)->hwg_node_name, s);
+		hubinfo_set(node_vertex, NODEPDA(cnode)->pdinfo);
+		NODEPDA(cnode)->slotdesc = brd->brd_slot;
+		NODEPDA(cnode)->geoid = brd->brd_geoid;
+		NODEPDA(cnode)->module = module_lookup(geo_module(brd->brd_geoid));
+		klhwg_add_hub(node_vertex, hub, cnode);
+	}
 
-		/* Get the first CPU structure */
-		cpu = (klcpu_t *)find_first_component(brd, KLSTRUCT_CPU);
+	/*
+	 * If there's at least 1 CPU, add a "cpu" directory to represent
+	 * the collection of all CPUs attached to this node.
+	 */
+	cpu = (klcpu_t *)find_first_component(brd, KLSTRUCT_CPU);
+	if (cpu) {
+		graph_error_t rv;
+
+		rv = hwgraph_path_add(node_vertex, EDGE_LBL_CPU, &cpu_dir);
+		if (rv != GRAPH_SUCCESS) {
+			printk("klhwg_add_node: Cannot create CPU directory\n");
+			return;
+		}
+		HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, cpu_dir, NULL, "Created cpu directiry on SHUB node.\n"));
 
-		/*
-		* If there's at least 1 CPU, add a "cpu" directory to represent
-		* the collection of all CPUs attached to this node.
-		*/
-		if (cpu) {
-			graph_error_t rv;
-
-			rv = hwgraph_path_add(node_vertex, EDGE_LBL_CPU, &cpu_dir);
-			if (rv != GRAPH_SUCCESS)
-				panic("klhwg_add_node: Cannot create CPU directory\n");
-		}
-
-		/* Add each CPU */
-		while (cpu) {
-			cpuid_t cpu_id;
-			cpu_id = nasid_slice_to_cpuid(nasid,cpu->cpu_info.physid);
-			if (cpu_online(cpu_id))
-				klhwg_add_cpu(node_vertex, cnode, cpu);
-			else
-				klhwg_add_disabled_cpu(node_vertex, cnode, cpu, brd->brd_slot);
-
-			cpu = (klcpu_t *)
-				find_component(brd, (klinfo_t *)cpu, KLSTRUCT_CPU);
-		} /* while */
+	}
 
-		if(!board_disabled)
-			klhwg_add_hub(node_vertex, hub, cnode);
-		
-		brd = KLCF_NEXT(brd);
-		if (brd)
-			brd = find_lboard(brd, KLTYPE_SNIA);
+	while (cpu) {
+		cpuid_t cpu_id;
+		cpu_id = nasid_slice_to_cpuid(nasid,cpu->cpu_info.physid);
+		if (cpu_online(cpu_id))
+			klhwg_add_cpu(node_vertex, cnode, cpu);
 		else
-			break;
-	} while(brd);
+			klhwg_add_disabled_cpu(node_vertex, cnode, cpu, brd->brd_slot);
+
+		cpu = (klcpu_t *)
+			find_component(brd, (klinfo_t *)cpu, KLSTRUCT_CPU);
+	}
 }
 
 
 /* ARGSUSED */
-void
+static void __init
 klhwg_add_all_routers(vertex_hdl_t hwgraph_root)
 {
 	nasid_t nasid;
@@ -467,10 +280,6 @@ klhwg_add_all_routers(vertex_hdl_t hwgra
 
 	for (cnode = 0; cnode < numnodes; cnode++) {
 		nasid = COMPACT_TO_NASID_NODEID(cnode);
-
-		GRPRINTF(("klhwg_add_all_routers: adding router on cnode %d\n",
-			cnode));
-
 		brd = find_lboard_class((lboard_t *)KL_CONFIG_INFO(nasid),
 				KLTYPE_ROUTER);
 
@@ -480,41 +289,32 @@ klhwg_add_all_routers(vertex_hdl_t hwgra
 
 		do {
 			ASSERT(brd);
-			GRPRINTF(("Router board struct is %p\n", brd));
 
 			/* Don't add duplicate boards. */
 			if (brd->brd_flags & DUPLICATE_BOARD)
 				continue;
 
-			GRPRINTF(("Router 0x%p module number is %d\n", brd, brd->brd_geoid));
 			/* Generate a hardware graph path for this board. */
 			board_to_path(brd, path_buffer);
 
-			GRPRINTF(("Router path is %s\n", path_buffer));
-
 			/* Add the router */
-			GRPRINTF(("klhwg_add_all_routers: adding %s to vertex 0x%p\n",
-				path_buffer, hwgraph_root));
 			rv = hwgraph_path_add(hwgraph_root, path_buffer, &node_vertex);
+			if (rv != GRAPH_SUCCESS) {
+				printk("Router vertex creation "
+						  "failed.  Path == %s", path_buffer);
+				return;
+			}
+			HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, node_vertex, NULL, "Created router path.\n"));
 
-			if (rv != GRAPH_SUCCESS)
-				PRINT_PANIC("Router vertex creation "
-						  "failed.  Path == %s",
-					path_buffer);
-
-			GRPRINTF(("klhwg_add_all_routers: get next board from 0x%p\n",
-					brd));
 		/* Find the rest of the routers stored on this node. */
 		} while ( (brd = find_lboard_class(KLCF_NEXT(brd),
 			 KLTYPE_ROUTER)) );
-
-		GRPRINTF(("klhwg_add_all_routers: Done.\n"));
 	}
 
 }
 
 /* ARGSUSED */
-void
+static void __init
 klhwg_connect_one_router(vertex_hdl_t hwgraph_root, lboard_t *brd,
 			 cnodeid_t cnode, nasid_t nasid)
 {
@@ -527,13 +327,8 @@ klhwg_connect_one_router(vertex_hdl_t hw
 	int port;
 	lboard_t *dest_brd;
 
-	GRPRINTF(("klhwg_connect_one_router: Connecting router on cnode %d\n",
-			cnode));
-
 	/* Don't add duplicate boards. */
 	if (brd->brd_flags & DUPLICATE_BOARD) {
-		GRPRINTF(("klhwg_connect_one_router: Duplicate router 0x%p on cnode %d\n",
-			brd, cnode));
 		return;
 	}
 
@@ -542,7 +337,7 @@ klhwg_connect_one_router(vertex_hdl_t hw
 
 	rc = hwgraph_traverse(hwgraph_root, path_buffer, &router_hndl);
 
-	if (rc != GRAPH_SUCCESS && is_specified(arg_maxnodes))
+	if (rc != GRAPH_SUCCESS)
 			return;
 
 	if (rc != GRAPH_SUCCESS)
@@ -550,7 +345,7 @@ klhwg_connect_one_router(vertex_hdl_t hw
 
 	/* We don't know what to do with multiple router components */
 	if (brd->brd_numcompts != 1) {
-		PRINT_PANIC("klhwg_connect_one_router: %d cmpts on router\n",
+		printk("klhwg_connect_one_router: %d cmpts on router\n",
 			brd->brd_numcompts);
 		return;
 	}
@@ -567,7 +362,7 @@ klhwg_connect_one_router(vertex_hdl_t hw
 				 port));
 			continue;
 		}
-		if (is_specified(arg_maxnodes) && NASID_TO_COMPACT_NODEID(router->rou_port[port].port_nasid) 
+		if (NASID_TO_COMPACT_NODEID(router->rou_port[port].port_nasid) 
 		    == INVALID_CNODEID) {
 			continue;
 		}
@@ -582,12 +377,11 @@ klhwg_connect_one_router(vertex_hdl_t hw
 		rc = hwgraph_traverse(hwgraph_root, dest_path, &dest_hndl);
 
 		if (rc != GRAPH_SUCCESS) {
-			if (is_specified(arg_maxnodes) && KL_CONFIG_DUPLICATE_BOARD(dest_brd))
+			if (KL_CONFIG_DUPLICATE_BOARD(dest_brd))
 				continue;
-			PRINT_PANIC("Can't find router: %s", dest_path);
+			printk("Can't find router: %s", dest_path);
+			return;
 		}
-		GRPRINTF(("klhwg_connect_one_router: Link from %s/%d to %s\n",
-			  path_buffer, port, dest_path));
 
 		sprintf(dest_path, "%d", port);
 
@@ -600,15 +394,18 @@ klhwg_connect_one_router(vertex_hdl_t hw
 			continue;
 		}
 
-		if (rc != GRAPH_SUCCESS && !is_specified(arg_maxnodes))
-			PRINT_PANIC("Can't create edge: %s/%s to vertex 0x%p error 0x%x\n",
+		if (rc != GRAPH_SUCCESS) {
+			printk("Can't create edge: %s/%s to vertex 0x%p error 0x%x\n",
 				path_buffer, dest_path, (void *)dest_hndl, rc);
+			return;
+		}
+		HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, router_hndl, dest_hndl, "Created edge %s from vhdl1 to vhdl2.\n", dest_path));
 		
 	}
 }
 
 
-void
+static void __init
 klhwg_connect_routers(vertex_hdl_t hwgraph_root)
 {
 	nasid_t nasid;
@@ -617,10 +414,6 @@ klhwg_connect_routers(vertex_hdl_t hwgra
 
 	for (cnode = 0; cnode < numnodes; cnode++) {
 		nasid = COMPACT_TO_NASID_NODEID(cnode);
-
-		GRPRINTF(("klhwg_connect_routers: Connecting routers on cnode %d\n",
-			cnode));
-
 		brd = find_lboard_class((lboard_t *)KL_CONFIG_INFO(nasid),
 				KLTYPE_ROUTER);
 
@@ -641,7 +434,7 @@ klhwg_connect_routers(vertex_hdl_t hwgra
 
 
 
-void
+static void __init
 klhwg_connect_hubs(vertex_hdl_t hwgraph_root)
 {
 	nasid_t nasid;
@@ -656,12 +449,9 @@ klhwg_connect_hubs(vertex_hdl_t hwgraph_
 	graph_error_t rc;
 	int port;
 
-	for (cnode = 0; cnode < numnodes; cnode++) {
+	for (cnode = 0; cnode < numionodes; cnode++) {
 		nasid = COMPACT_TO_NASID_NODEID(cnode);
 
-		GRPRINTF(("klhwg_connect_hubs: Connecting hubs on cnode %d\n",
-			cnode));
-
 		brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_SNIA);
 		ASSERT(brd);
 
@@ -669,19 +459,15 @@ klhwg_connect_hubs(vertex_hdl_t hwgraph_
 		ASSERT(hub);
 
 		for (port = 1; port <= MAX_NI_PORTS; port++) {
-			/* See if the port's active */
 			if (hub->hub_port[port].port_nasid == INVALID_NASID) {
-				GRPRINTF(("klhwg_connect_hubs: port inactive.\n"));
-				continue;
+				continue; /* Port not active */
 			}
 
-			if (is_specified(arg_maxnodes) && NASID_TO_COMPACT_NODEID(hub->hub_port[port].port_nasid) == INVALID_CNODEID)
+			if (NASID_TO_COMPACT_NODEID(hub->hub_port[port].port_nasid) == INVALID_CNODEID)
 				continue;
 
 			/* Generate a hardware graph path for this board. */
 			board_to_path(brd, path_buffer);
-
-			GRPRINTF(("klhwg_connect_hubs: Hub path is %s.\n", path_buffer));
 			rc = hwgraph_traverse(hwgraph_root, path_buffer, &hub_hndl);
 
 			if (rc != GRAPH_SUCCESS)
@@ -697,26 +483,29 @@ klhwg_connect_hubs(vertex_hdl_t hwgraph_
 			rc = hwgraph_traverse(hwgraph_root, dest_path, &dest_hndl);
 
 			if (rc != GRAPH_SUCCESS) {
-				if (is_specified(arg_maxnodes) && KL_CONFIG_DUPLICATE_BOARD(dest_brd))
+				if (KL_CONFIG_DUPLICATE_BOARD(dest_brd))
 					continue;
-				PRINT_PANIC("Can't find board: %s", dest_path);
+				printk("Can't find board: %s", dest_path);
+				return;
 			} else {
 				char buf[1024];
-		
-
-				GRPRINTF(("klhwg_connect_hubs: Link from %s to %s.\n",
-			  	path_buffer, dest_path));
 
 				rc = hwgraph_path_add(hub_hndl, EDGE_LBL_INTERCONNECT, &hub_hndl);
+
+				HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, hub_hndl, NULL, "Created link path.\n"));
+
 				sprintf(buf,"%s/%s",path_buffer,EDGE_LBL_INTERCONNECT);
 				rc = hwgraph_traverse(hwgraph_root, buf, &hub_hndl);
 				sprintf(buf,"%d",port);
 				rc = hwgraph_edge_add(hub_hndl, dest_hndl, buf);
 
-				if (rc != GRAPH_SUCCESS)
-					PRINT_PANIC("Can't create edge: %s/%s to vertex 0x%p, error 0x%x\n",
-					path_buffer, dest_path, (void *)dest_hndl, rc);
+				HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, hub_hndl, dest_hndl, "Created edge %s from vhdl1 to vhdl2.\n", buf));
 
+				if (rc != GRAPH_SUCCESS) {
+					printk("Can't create edge: %s/%s to vertex 0x%p, error 0x%x\n",
+							path_buffer, dest_path, (void *)dest_hndl, rc);
+					return;
+				}
 			}
 		}
 	}
@@ -726,7 +515,7 @@ klhwg_connect_hubs(vertex_hdl_t hwgraph_
  * hints which can later be used by the drivers using the device/driver
  * admin interface. 
  */
-void
+static void __init
 klhwg_device_disable_hints_add(void)
 {
 	cnodeid_t	cnode; 		/* node we are looking at */
@@ -785,7 +574,7 @@ klhwg_device_disable_hints_add(void)
 	}
 }
 
-void
+void __init
 klhwg_add_all_modules(vertex_hdl_t hwgraph_root)
 {
 	cmoduleid_t	cm;
@@ -807,6 +596,7 @@ klhwg_add_all_modules(vertex_hdl_t hwgra
 		rc = hwgraph_path_add(hwgraph_root, name, &module_vhdl);
 		ASSERT(rc == GRAPH_SUCCESS);
 		rc = rc;
+		HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, module_vhdl, NULL, "Created module path.\n"));
 
 		hwgraph_fastinfo_set(module_vhdl, (arbitrary_info_t) modules[cm]);
 
@@ -818,24 +608,24 @@ klhwg_add_all_modules(vertex_hdl_t hwgra
 		rc = hwgraph_path_add(hwgraph_root, name, &vhdl);
 		ASSERT_ALWAYS(rc == GRAPH_SUCCESS); 
 		rc = rc;
+		HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, vhdl, NULL, "Created L1 path.\n"));
 
-		hwgraph_info_add_LBL(vhdl,
-				     INFO_LBL_ELSC,
-				     (arbitrary_info_t) (__psint_t) 1);
+		hwgraph_info_add_LBL(vhdl, INFO_LBL_ELSC,
+				     (arbitrary_info_t)1);
 
 	}
 }
 
-void
+void __init
 klhwg_add_all_nodes(vertex_hdl_t hwgraph_root)
 {
 	cnodeid_t	cnode;
 
-	for (cnode = 0; cnode < numnodes; cnode++) {
+	for (cnode = 0; cnode < numionodes; cnode++) {
 		klhwg_add_node(hwgraph_root, cnode);
 	}
 
-	for (cnode = 0; cnode < numnodes; cnode++) {
+	for (cnode = 0; cnode < numionodes; cnode++) {
 		klhwg_add_xbow(cnode, cnodeid_to_nasid(cnode));
 	}
 
diff -puN arch/ia64/sn/io/sn2/l1_command.c~linus arch/ia64/sn/io/sn2/l1_command.c
--- 25/arch/ia64/sn/io/sn2/l1_command.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/l1_command.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -12,7 +11,6 @@
 #include <asm/sn/sgi.h>
 #include <asm/sn/io.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/hcl_util.h>
 #include <asm/sn/labelcl.h>
@@ -60,8 +58,6 @@ int iobrick_rack_bay_type_get( nasid_t n
 	*rack = (result & MODULE_RACK_MASK) >> MODULE_RACK_SHFT;
 	*bay = (result & MODULE_BPOS_MASK) >> MODULE_BPOS_SHFT;
 	*brick_type = (result & MODULE_BTYPE_MASK) >> MODULE_BTYPE_SHFT;
-	*brick_type = toupper(*brick_type);
-
 	return 0;
 }
 
@@ -76,63 +72,6 @@ int iomoduleid_get(nasid_t nasid)
 	return result;
 }
 
-int iobrick_module_get(nasid_t nasid)
-{
-    uint rnum, rack, bay, brick_type, t;
-    int ret;
-
-    /* construct module ID from rack and slot info */
-
-    if ((ret = iobrick_rack_bay_type_get(nasid, &rnum, &bay, &brick_type)) < 0)
-        return ret;
-
-    if (bay > MODULE_BPOS_MASK >> MODULE_BPOS_SHFT)
-        return ELSC_ERROR_MODULE;
-
-    /* Build a moduleid_t-compatible rack number */
-
-    rack = 0;           
-    t = rnum / 100;             /* rack class (CPU/IO) */
-    if (t > RACK_CLASS_MASK(rack) >> RACK_CLASS_SHFT(rack))
-        return ELSC_ERROR_MODULE;
-    RACK_ADD_CLASS(rack, t);
-    rnum %= 100;
-
-    t = rnum / 10;              /* rack group */
-    if (t > RACK_GROUP_MASK(rack) >> RACK_GROUP_SHFT(rack))
-        return ELSC_ERROR_MODULE;
-    RACK_ADD_GROUP(rack, t);
-
-    t = rnum % 10;              /* rack number (one-based) */
-    if (t-1 > RACK_NUM_MASK(rack) >> RACK_NUM_SHFT(rack))
-        return ELSC_ERROR_MODULE;
-    RACK_ADD_NUM(rack, t);
-
-    switch( brick_type ) {
-      case L1_BRICKTYPE_IX: 
-	brick_type = MODULE_IXBRICK; break;
-      case L1_BRICKTYPE_PX: 
-	brick_type = MODULE_PXBRICK; break;
-      case L1_BRICKTYPE_I: 
-	brick_type = MODULE_IBRICK; break;
-      case L1_BRICKTYPE_P:
-	brick_type = MODULE_PBRICK; break;
-      case L1_BRICKTYPE_X:
-	brick_type = MODULE_XBRICK; break;
-    }
-
-    ret = RBT_TO_MODULE(rack, bay, brick_type);
-
-    return ret;
-}
-
-/*
- * iobrick_module_get_nasid() returns a module_id which has the brick
- * type encoded in bits 15-12, but this is not the true brick type...
- * The module_id returned by iobrick_module_get_nasid() is modified
- * to make a PEBRICKs & PXBRICKs look like a PBRICK.  So this routine
- * iobrick_type_get_nasid() returns the true unmodified brick type.
- */
 int
 iobrick_type_get_nasid(nasid_t nasid)
 {
@@ -158,14 +97,6 @@ iobrick_type_get_nasid(nasid_t nasid)
     return -1;    /* unknown brick */
 }
 
-int iobrick_module_get_nasid(nasid_t nasid)
-{
-    int io_moduleid;
-
-    io_moduleid = iobrick_module_get(nasid);
-    return io_moduleid;
-}
-
 /*
  * given a L1 bricktype, return a bricktype string.  This string is the
  * string that will be used in the hwpath for I/O bricks
@@ -178,26 +109,23 @@ iobrick_L1bricktype_to_name(int type)
     default:
         return("Unknown");
 
-    case L1_BRICKTYPE_X:
-        return("Xbrick");
-
-    case L1_BRICKTYPE_I:
-        return("Ibrick");
-
-    case L1_BRICKTYPE_P:
-        return("Pbrick");
-
     case L1_BRICKTYPE_PX:
-        return("PXbrick");
+        return(EDGE_LBL_PXBRICK);
+
+    case L1_BRICKTYPE_OPUS:
+        return(EDGE_LBL_OPUSBRICK);
 
     case L1_BRICKTYPE_IX:
-        return("IXbrick");
+        return(EDGE_LBL_IXBRICK);
 
     case L1_BRICKTYPE_C:
         return("Cbrick");
 
     case L1_BRICKTYPE_R:
         return("Rbrick");
+
+    case L1_BRICKTYPE_CHI_CG:
+        return(EDGE_LBL_CGBRICK);
     }
 }
 
diff -puN arch/ia64/sn/io/sn2/Makefile~linus arch/ia64/sn/io/sn2/Makefile
--- 25/arch/ia64/sn/io/sn2/Makefile~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -9,8 +9,6 @@
 # Makefile for the sn2 specific io routines.
 #
 
-EXTRA_CFLAGS := -DLITTLE_ENDIAN
-
 obj-y += pcibr/ ml_SN_intr.o shub_intr.o shuberror.o shub.o bte_error.o \
 	 pic.o geo_op.o l1_command.o klconflib.o klgraph.o ml_SN_init.o \
 	 ml_iograph.o module.o pciio.o xbow.o xtalk.o shubio.o
diff -puN arch/ia64/sn/io/sn2/ml_iograph.c~linus arch/ia64/sn/io/sn2/ml_iograph.c
--- 25/arch/ia64/sn/io/sn2/ml_iograph.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/ml_iograph.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -7,28 +6,16 @@
  * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
  */
 
-#include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/ctype.h>
 #include <asm/sn/sgi.h>
 #include <asm/sn/sn_sal.h>
-#include <asm/sn/io.h>
-#include <asm/sn/sn_cpuid.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/hcl_util.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/xtalk/xbow.h>
-#include <asm/sn/pci/bridge.h>
-#include <asm/sn/klconfig.h>
 #include <asm/sn/sn_private.h>
-#include <asm/sn/pci/pcibr.h>
-#include <asm/sn/xtalk/xtalk.h>
-#include <asm/sn/xtalk/xswitch.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/xtalk/xtalk_private.h>
+#include <asm/sn/pci/pcibr_private.h>
 #include <asm/sn/xtalk/xtalkaddrs.h>
+#include <asm/sn/ksys/l1.h>
 
 /* #define IOGRAPH_DEBUG */
 #ifdef IOGRAPH_DEBUG
@@ -37,8 +24,6 @@
 #define DBG(x...)
 #endif /* IOGRAPH_DEBUG */
 
-/* #define PROBE_TEST */
-
 /* At most 2 hubs can be connected to an xswitch */
 #define NUM_XSWITCH_VOLUNTEER 2
 
@@ -49,7 +34,7 @@
  * xswitch vertex is created.
  */
 typedef struct xswitch_vol_s {
-	mutex_t xswitch_volunteer_mutex;
+	struct semaphore xswitch_volunteer_mutex;
 	int		xswitch_volunteer_count;
 	vertex_hdl_t	xswitch_volunteer[NUM_XSWITCH_VOLUNTEER];
 } *xswitch_vol_t;
@@ -59,12 +44,15 @@ xswitch_vertex_init(vertex_hdl_t xswitch
 {
 	xswitch_vol_t xvolinfo;
 	int rc;
-	extern void * snia_kmem_zalloc(size_t size, int flag);
 
-	xvolinfo = snia_kmem_zalloc(sizeof(struct xswitch_vol_s), GFP_KERNEL);
-	mutex_init(&xvolinfo->xswitch_volunteer_mutex);
-	rc = hwgraph_info_add_LBL(xswitch, 
-			INFO_LBL_XSWITCH_VOL,
+	xvolinfo = kmalloc(sizeof(struct xswitch_vol_s), GFP_KERNEL);
+	if (xvolinfo <= 0 ) {
+		printk("xswitch_vertex_init: out of memory\n");
+		return;
+	}
+       	memset(xvolinfo, 0, sizeof(struct xswitch_vol_s));
+	init_MUTEX(&xvolinfo->xswitch_volunteer_mutex);
+	rc = hwgraph_info_add_LBL(xswitch, INFO_LBL_XSWITCH_VOL,
 			(arbitrary_info_t)xvolinfo);
 	ASSERT(rc == GRAPH_SUCCESS); rc = rc;
 }
@@ -79,12 +67,12 @@ xswitch_volunteer_delete(vertex_hdl_t xs
 {
 	xswitch_vol_t xvolinfo;
 	int rc;
-	extern void snia_kmem_free(void *ptr, size_t size);
 
 	rc = hwgraph_info_remove_LBL(xswitch, 
 				INFO_LBL_XSWITCH_VOL,
 				(arbitrary_info_t *)&xvolinfo);
-	snia_kmem_free(xvolinfo, sizeof(struct xswitch_vol_s));
+	if (xvolinfo > 0)
+		kfree(xvolinfo);
 }
 /*
  * A Crosstalk master volunteers to manage xwidgets on the specified xswitch.
@@ -101,14 +89,16 @@ volunteer_for_widgets(vertex_hdl_t xswit
 				INFO_LBL_XSWITCH_VOL, 
 				(arbitrary_info_t *)&xvolinfo);
 	if (xvolinfo == NULL) {
-	    if (!is_headless_node_vertex(master))
+	    if (!is_headless_node_vertex(master)) {
+		    char name[MAXDEVNAME];
 		    printk(KERN_WARNING
-			"volunteer for widgets: vertex 0x%p has no info label",
-			(void *)xswitch);
+			"volunteer for widgets: vertex %s has no info label",
+			vertex_to_name(xswitch, name, MAXDEVNAME));
+	    }
 	    return;
 	}
 
-	mutex_lock(&xvolinfo->xswitch_volunteer_mutex);
+	down(&xvolinfo->xswitch_volunteer_mutex);
 	ASSERT(xvolinfo->xswitch_volunteer_count < NUM_XSWITCH_VOLUNTEER);
 	xvolinfo->xswitch_volunteer[xvolinfo->xswitch_volunteer_count] = master;
 	xvolinfo->xswitch_volunteer_count++;
@@ -126,7 +116,7 @@ volunteer_for_widgets(vertex_hdl_t xswit
 			xvolinfo->xswitch_volunteer[1] = hubv;
 		}
 	}
-	mutex_unlock(&xvolinfo->xswitch_volunteer_mutex);
+	up(&xvolinfo->xswitch_volunteer_mutex);
 }
 
 extern int xbow_port_io_enabled(nasid_t nasid, int widgetnum);
@@ -158,11 +148,13 @@ assign_widgets_to_volunteers(vertex_hdl_
 				INFO_LBL_XSWITCH_VOL, 
 				(arbitrary_info_t *)&xvolinfo);
 	if (xvolinfo == NULL) {
-	    if (!is_headless_node_vertex(hubv))
+	    if (!is_headless_node_vertex(hubv)) {
+		    char name[MAXDEVNAME];
 		    printk(KERN_WARNING
-			"assign_widgets_to_volunteers:vertex 0x%p has "
+			"assign_widgets_to_volunteers:vertex %s has "
 			" no info label",
-			(void *)xswitch);
+			vertex_to_name(xswitch, name, MAXDEVNAME));
+	    }
 	    return;
 	}
 
@@ -182,9 +174,6 @@ assign_widgets_to_volunteers(vertex_hdl_
 	for (widgetnum=HUB_WIDGET_ID_MIN; widgetnum <= HUB_WIDGET_ID_MAX; widgetnum++) {
 		int i;
 
-		/*
-		 * Ignore disabled/empty ports.
-		 */
 		if (!xbow_port_io_enabled(nasid, widgetnum)) 
 		    continue;
 
@@ -193,16 +182,17 @@ assign_widgets_to_volunteers(vertex_hdl_
 		 * hub that owned it in the prom.
 		 */
 		if (is_master_baseio_nasid_widget(nasid, widgetnum)) {
-			extern nasid_t get_master_baseio_nasid(void);
+			extern nasid_t snia_get_master_baseio_nasid(void);
 			for (i=0; i<num_volunteer; i++) {
 				hubv = xvolinfo->xswitch_volunteer[i];
 				hubinfo_get(hubv, &hubinfo);
 				nasid = hubinfo->h_nasid;
-				if (nasid == get_master_baseio_nasid())
+				if (nasid == snia_get_master_baseio_nasid())
 					goto do_assignment;
 			}
-			PRINT_PANIC("Nasid == %d, console nasid == %d",
-				nasid, get_master_baseio_nasid());
+			printk("Nasid == %d, console nasid == %d",
+				nasid, snia_get_master_baseio_nasid());
+			nasid = 0;
 		}
 
 		/*
@@ -236,38 +226,6 @@ do_assignment:
 	xswitch_volunteer_delete(xswitch);
 }
 
-/*
- * Early iograph initialization.  Called by master CPU in mlreset().
- * Useful for including iograph.o in kernel.o.
- */
-void
-iograph_early_init(void)
-{
-/*
- * Need new way to get this information ..
- */
-	cnodeid_t cnode;
-	nasid_t nasid;
-	lboard_t *board;
-	
-	/*
-	 * Init. the board-to-hwgraph link early, so FRU analyzer
-	 * doesn't trip on leftover values if we panic early on.
-	 */
-	for(cnode = 0; cnode < numnodes; cnode++) {
-		nasid = COMPACT_TO_NASID_NODEID(cnode);
-		board = (lboard_t *)KL_CONFIG_INFO(nasid);
-		DBG("iograph_early_init: Found board 0x%p\n", board);
-
-		/* Check out all the board info stored on a node */
-		while(board) {
-			board->brd_graph_link = GRAPH_VERTEX_NONE;
-			board = KLCF_NEXT(board);
-			DBG("iograph_early_init: Found board 0x%p\n", board);
-		}
-	}
-}
-
 /* 
  * Probe to see if this hub's xtalk link is active.  If so,
  * return the Crosstalk Identification of the widget that we talk to.  
@@ -323,7 +281,7 @@ early_probe_for_widget(vertex_hdl_t hubv
  *	
  */
 
-void
+static void
 io_xswitch_widget_init(vertex_hdl_t  	xswitchv,
 		       vertex_hdl_t	hubv,
 		       xwidgetnum_t	widgetnum)
@@ -424,11 +382,10 @@ io_xswitch_widget_init(vertex_hdl_t  	xs
 		sprintf(pathname, EDGE_LBL_MODULE "/%s/" EDGE_LBL_SLAB "/%d" "/%s" "/%s/%d",
 			buffer,
 			geo_slab(board->brd_geoid),
-			(board->brd_type == KLTYPE_IBRICK) ? EDGE_LBL_IBRICK :
-			(board->brd_type == KLTYPE_PBRICK) ? EDGE_LBL_PBRICK :
 			(board->brd_type == KLTYPE_PXBRICK) ? EDGE_LBL_PXBRICK :
 			(board->brd_type == KLTYPE_IXBRICK) ? EDGE_LBL_IXBRICK :
-			(board->brd_type == KLTYPE_XBRICK) ? EDGE_LBL_XBRICK : "?brick",
+			(board->brd_type == KLTYPE_CGBRICK) ? EDGE_LBL_CGBRICK :
+			(board->brd_type == KLTYPE_OPUSBRICK) ? EDGE_LBL_OPUSBRICK : "?brick",
 			EDGE_LBL_XTALK, widgetnum);
 		
 		DBG("io_xswitch_widget_init: path= %s\n", pathname);
@@ -465,8 +422,7 @@ io_xswitch_widget_init(vertex_hdl_t  	xs
 		(void)xwidget_register(&hwid, widgetv, widgetnum,
 				       hubv, hub_widgetid);
 
-		ia64_sn_sysctl_iobrick_module_get(nasid, &io_module);
-
+		io_module = iomoduleid_get(nasid);
 		if (io_module >= 0) {
 			char			buffer[16];
 			vertex_hdl_t		to, from;
@@ -477,8 +433,8 @@ io_xswitch_widget_init(vertex_hdl_t  	xs
 			memset(buffer, 0, 16);
 			format_module_id(buffer, geo_module(board->brd_geoid), MODULE_FORMAT_BRIEF);
 
-			if ( islower(MODULE_GET_BTCHAR(io_module)) ) {
-				bt = toupper(MODULE_GET_BTCHAR(io_module));
+			if ( isupper(MODULE_GET_BTCHAR(io_module)) ) {
+				bt = tolower(MODULE_GET_BTCHAR(io_module));
 			}
 			else {
 				bt = MODULE_GET_BTCHAR(io_module);
@@ -508,18 +464,12 @@ io_xswitch_widget_init(vertex_hdl_t  	xs
 			ASSERT_ALWAYS(to);
 			rc = hwgraph_edge_add(from, to,
 				EDGE_LBL_INTERCONNECT);
-			if (rc == -EEXIST)
-				goto link_done;
-			if (rc != GRAPH_SUCCESS) {
+			if (rc != -EEXIST && rc != GRAPH_SUCCESS) {
 				printk("%s: Unable to establish link"
 					" for xbmon.", pathname);
 			}
-link_done:
 		}
 
-#ifdef	SN0_USE_BTE
-		bte_bpush_war(cnode, (void *)board);
-#endif
 	}
 }
 
@@ -540,70 +490,6 @@ io_init_xswitch_widgets(vertex_hdl_t xsw
 }
 
 /*
- * For each PCI bridge connected to the xswitch, add a link from the
- * board's klconfig info to the bridge's hwgraph vertex.  This lets
- * the FRU analyzer find the bridge without traversing the hardware
- * graph and risking hangs.
- */
-static void
-io_link_xswitch_widgets(vertex_hdl_t xswitchv, cnodeid_t cnodeid)
-{
-	xwidgetnum_t		widgetnum;
-	char 			pathname[128];
-	vertex_hdl_t		vhdl;
-	nasid_t			nasid, peer_nasid;
-	lboard_t		*board;
-
-
-
-	/* And its connected hub's nasids */
-	nasid = COMPACT_TO_NASID_NODEID(cnodeid);
-	peer_nasid = NODEPDA(cnodeid)->xbow_peer;
-
-	/* 
-	 * Look for paths matching "<widgetnum>/pci" under xswitchv.
-	 * For every widget, init. its lboard's hwgraph link.  If the
-	 * board has a PCI bridge, point the link to it.
-	 */
-	for (widgetnum = HUB_WIDGET_ID_MIN; widgetnum <= HUB_WIDGET_ID_MAX;
-		 widgetnum++) {
-		sprintf(pathname, "%d", widgetnum);
-		if (hwgraph_traverse(xswitchv, pathname, &vhdl) !=
-		    GRAPH_SUCCESS)
-			continue;
-
-		board = find_lboard_module((lboard_t *)KL_CONFIG_INFO(nasid),
-				NODEPDA(cnodeid)->geoid);
-		if (board == NULL && peer_nasid != INVALID_NASID) {
-			/*
-			 * Try to find the board on our peer
-			 */
-			board = find_lboard_module(
-				(lboard_t *)KL_CONFIG_INFO(peer_nasid),
-				NODEPDA(cnodeid)->geoid);
-		}
-		if (board == NULL) {
-			printk(KERN_WARNING  "Could not find PROM info for vertex 0x%p, "
-				"FRU analyzer may fail",
-				(void *)vhdl);
-			return;
-		}
-
-		/* Check both buses */
-		sprintf(pathname, "%d/"EDGE_LBL_PCIX_0, widgetnum);
-		if (hwgraph_traverse(xswitchv, pathname, &vhdl) == GRAPH_SUCCESS)
-			board->brd_graph_link = vhdl;
-		else {
-			sprintf(pathname, "%d/"EDGE_LBL_PCIX_1, widgetnum);
-			if (hwgraph_traverse(xswitchv, pathname, &vhdl) == GRAPH_SUCCESS)
-				board->brd_graph_link = vhdl;
-			else
-				board->brd_graph_link = GRAPH_VERTEX_NONE;
-		}
-	}
-}
-
-/*
  * Initialize all I/O on the specified node.
  */
 static void
@@ -617,7 +503,6 @@ io_init_node(cnodeid_t cnodeid)
 	nodepda_t	*npdap;
 	struct semaphore *peer_sema = 0;
 	uint32_t	widget_partnum;
-	cpu_cookie_t	c = 0;
 
 	npdap = NODEPDA(cnodeid);
 
@@ -633,23 +518,11 @@ io_init_node(cnodeid_t cnodeid)
 
 	ASSERT(hubv != GRAPH_VERTEX_NONE);
 
-	/*
-	 * Read mfg info on this hub
-	 */
-
 	/* 
 	 * If nothing connected to this hub's xtalk port, we're done.
 	 */
 	early_probe_for_widget(hubv, &hwid);
 	if (hwid.part_num == XWIDGET_PART_NUM_NONE) {
-#ifdef PROBE_TEST
-		if ((cnodeid == 1) || (cnodeid == 2)) {
-			int index;
-
-			for (index = 0; index < 600; index++)
-				DBG("Interfering with device probing!!!\n");
-		}
-#endif
 		DBG("**** io_init_node: Node's 0x%p hub widget has XWIDGET_PART_NUM_NONE ****\n", hubv);
 		return;
 		/* NOTREACHED */
@@ -694,16 +567,12 @@ io_init_node(cnodeid_t cnodeid)
 	 * accordingly. In particular, SN00 has direct connected bridge,
 	 * and hence widget id is Not 0.
 	 */
+	widget_partnum = (((*(volatile int32_t *)(NODE_SWIN_BASE
+			(COMPACT_TO_NASID_NODEID(cnodeid), 0) + 
+			WIDGET_ID))) & WIDGET_PART_NUM) 
+			>> WIDGET_PART_NUM_SHFT;
 
-	widget_partnum = (((*(volatile int32_t *)(NODE_SWIN_BASE(COMPACT_TO_NASID_NODEID(cnodeid), 0) + WIDGET_ID))) & WIDGET_PART_NUM) >> WIDGET_PART_NUM_SHFT;
-
-	if (widget_partnum == BRIDGE_WIDGET_PART_NUM ||
-				widget_partnum == XBRIDGE_WIDGET_PART_NUM){
-		npdap->basew_id = (((*(volatile int32_t *)(NODE_SWIN_BASE(COMPACT_TO_NASID_NODEID(cnodeid), 0) + BRIDGE_WID_CONTROL))) & WIDGET_WIDGET_ID);
-
-		DBG("io_init_node: Found XBRIDGE widget_partnum= 0x%x\n", widget_partnum);
-
-	} else if ((widget_partnum == XBOW_WIDGET_PART_NUM) ||
+	if ((widget_partnum == XBOW_WIDGET_PART_NUM) ||
 			(widget_partnum == XXBOW_WIDGET_PART_NUM) ||
 			(widget_partnum == PXBOW_WIDGET_PART_NUM) ) {
 		/* 
@@ -714,11 +583,14 @@ io_init_node(cnodeid_t cnodeid)
 		npdap->basew_id = 0;
 
 	} else {
-		npdap->basew_id = (((*(volatile int32_t *)(NODE_SWIN_BASE(COMPACT_TO_NASID_NODEID(cnodeid), 0) + BRIDGE_WID_CONTROL))) & WIDGET_WIDGET_ID);
+		void	*bridge;
+		extern uint64_t pcireg_control_get(void *);
 
-		panic(" ****io_init_node: Unknown Widget Part Number 0x%x Widget ID 0x%x attached to Hubv 0x%p ****\n", widget_partnum, npdap->basew_id, (void *)hubv);
+		bridge = (void *)NODE_SWIN_BASE(COMPACT_TO_NASID_NODEID(cnodeid), 0);
+		npdap->basew_id = pcireg_control_get(bridge) & WIDGET_WIDGET_ID;
 
-		/*NOTREACHED*/
+		printk(" ****io_init_node: Unknown Widget Part Number 0x%x Widget ID 0x%x attached to Hubv 0x%p ****\n", widget_partnum, npdap->basew_id, (void *)hubv);
+		return;
 	}
 	{
 		char widname[10];
@@ -776,32 +648,22 @@ io_init_node(cnodeid_t cnodeid)
 
 		/* Signal that we're done */
 		if (peer_sema) {
-			mutex_unlock(peer_sema);
+			up(peer_sema);
 		}
 		
 	}
 	else {
 	    /* Wait 'til master is done assigning widgets. */
-	    mutex_lock(&npdap->xbow_sema);
+	    down(&npdap->xbow_sema);
 	}
 
-#ifdef PROBE_TEST
-	if ((cnodeid == 1) || (cnodeid == 2)) {
-		int index;
-
-		for (index = 0; index < 500; index++)
-			DBG("Interfering with device probing!!!\n");
-	}
-#endif
 	/* Now both nodes can safely inititialize widgets */
 	io_init_xswitch_widgets(switchv, cnodeid);
-	io_link_xswitch_widgets(switchv, cnodeid);
 
 	DBG("\nio_init_node: DONE INITIALIZED ALL I/O FOR CNODEID %d\n\n", cnodeid);
 }
 
 #include <asm/sn/ioerror_handling.h>
-/* #endif */
 
 /*
  * Initialize all I/O devices.  Starting closest to nodes, probe and
@@ -810,75 +672,52 @@ io_init_node(cnodeid_t cnodeid)
 void
 init_all_devices(void)
 {
-	/* Governor on init threads..bump up when safe 
-	 * (beware many devfs races) 
-	 */
 	cnodeid_t cnodeid, active;
 
 	active = 0;
-	for (cnodeid = 0; cnodeid < numnodes; cnodeid++) {
+	for (cnodeid = 0; cnodeid < numionodes; cnodeid++) {
                 DBG("init_all_devices: Calling io_init_node() for cnode %d\n", cnodeid);
                 io_init_node(cnodeid);
 
 		DBG("init_all_devices: Done io_init_node() for cnode %d\n", cnodeid);
 	}
 
-	for (cnodeid = 0; cnodeid < numnodes; cnodeid++)
+	for (cnodeid = 0; cnodeid < numnodes; cnodeid++) {
 		/*
 	 	 * Update information generated by IO init.
 		 */
 		update_node_information(cnodeid);
-
-#if HWG_PRINT
-	hwgraph_print();
-#endif
-
+	}
 }
 
-#define toint(x) ((int)(x) - (int)('0'))
-
 static
 struct io_brick_map_s io_brick_tab[] = {
 
-/* Ibrick widget number to PCI bus number map */
- {      MODULE_IBRICK,                          /* Ibrick type    */ 
+/* PXbrick widget number to PCI bus number map */
+ {      MODULE_PXBRICK,                         /* PXbrick type   */ 
     /*  PCI Bus #                                  Widget #       */
     {   0, 0, 0, 0, 0, 0, 0, 0,                 /* 0x0 - 0x7      */
         0,                                      /* 0x8            */
         0,                                      /* 0x9            */
         0, 0,                                   /* 0xa - 0xb      */
-        0,                                      /* 0xc            */
-        0,                                      /* 0xd            */
-        2,                                      /* 0xe            */
-        1                                       /* 0xf            */
-     }
- },
-
-/* Pbrick widget number to PCI bus number map */
- {      MODULE_PBRICK,                          /* Pbrick type    */ 
-    /*  PCI Bus #                                  Widget #       */
-    {   0, 0, 0, 0, 0, 0, 0, 0,                 /* 0x0 - 0x7      */
-        2,                                      /* 0x8            */
-        1,                                      /* 0x9            */
-        0, 0,                                   /* 0xa - 0xb      */
-        4,                                      /* 0xc            */
-        6,                                      /* 0xd            */
-        3,                                      /* 0xe            */
-        5                                       /* 0xf            */
+        1,                                      /* 0xc            */
+        5,                                      /* 0xd            */
+        0,                                      /* 0xe            */
+        3                                       /* 0xf            */
     }
  },
 
-/* PXbrick widget number to PCI bus number map */
- {      MODULE_PXBRICK,                         /* PXbrick type   */ 
+/* OPUSbrick widget number to PCI bus number map */
+ {      MODULE_OPUSBRICK,                       /* OPUSbrick type */ 
     /*  PCI Bus #                                  Widget #       */
     {   0, 0, 0, 0, 0, 0, 0, 0,                 /* 0x0 - 0x7      */
         0,                                      /* 0x8            */
         0,                                      /* 0x9            */
         0, 0,                                   /* 0xa - 0xb      */
-        1,                                      /* 0xc            */
-        5,                                      /* 0xd            */
+        0,                                      /* 0xc            */
+        0,                                      /* 0xd            */
         0,                                      /* 0xe            */
-        3                                       /* 0xf            */
+        1                                       /* 0xf            */
     }
  },
 
@@ -896,19 +735,19 @@ struct io_brick_map_s io_brick_tab[] = {
     }
  },
 
-/* Xbrick widget to XIO slot map */
- {      MODULE_XBRICK,                          /* Xbrick type    */ 
-    /*  XIO Slot #                                 Widget #       */
+/* CG brick widget number to PCI bus number map */
+ {      MODULE_CGBRICK,				/* CG brick       */
+    /*  PCI Bus #                                  Widget #       */
     {   0, 0, 0, 0, 0, 0, 0, 0,                 /* 0x0 - 0x7      */
-        1,                                      /* 0x8            */
-        3,                                      /* 0x9            */
-        0, 0,                                   /* 0xa - 0xb      */
-        2,                                      /* 0xc            */
-        4,                                      /* 0xd            */
+        0,                                      /* 0x8            */
+        0,                                      /* 0x9            */
+        0, 1,                                   /* 0xa - 0xb      */
+        0,                                      /* 0xc            */
+        0,                                      /* 0xd            */
         0,                                      /* 0xe            */
         0                                       /* 0xf            */
-    }
- }
+     }
+ },
 };
 
 /*
diff -puN arch/ia64/sn/io/sn2/ml_SN_init.c~linus arch/ia64/sn/io/sn2/ml_SN_init.c
--- 25/arch/ia64/sn/io/sn2/ml_SN_init.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/ml_SN_init.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -13,58 +12,16 @@
 #include <asm/sn/sgi.h>
 #include <asm/sn/io.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/labelcl.h>
 #include <asm/sn/sn_private.h>
 #include <asm/sn/klconfig.h>
 #include <asm/sn/sn_cpuid.h>
 
-extern cpuid_t master_procid;
 int		maxcpus;
 
 extern xwidgetnum_t hub_widget_id(nasid_t);
 
-extern void iograph_early_init(void);
-
-nasid_t master_nasid = INVALID_NASID;		/* This is the partition master nasid */
-nasid_t master_baseio_nasid = INVALID_NASID;	/* This is the master base I/O nasid */
-
-
-/*
- * mlreset(void)
- * 	very early machine reset - at this point NO interrupts have been
- * 	enabled; nor is memory, tlb, p0, etc setup.
- *
- * 	slave is zero when mlreset is called for the master processor and
- *	is nonzero thereafter.
- */
-
-
-void
-mlreset(int slave)
-{
-	/*
-	 * We are the master cpu and node.
-	 */ 
-	master_nasid = get_nasid();
-	set_master_bridge_base();
-
-	/* We're the master processor */
-	master_procid = smp_processor_id();
-	master_nasid = cpuid_to_nasid(master_procid);
-
-	/*
-	 * master_nasid we get back better be same as one from
-	 * get_nasid()
-	 */
-	ASSERT_ALWAYS(master_nasid == get_nasid());
-
-	/* early initialization of iograph */
-	iograph_early_init();
-}
-
-
 /* XXX - Move the meat of this to intr.c ? */
 /*
  * Set up the platform-dependent fields in the nodepda.
@@ -72,22 +29,26 @@ mlreset(int slave)
 void init_platform_nodepda(nodepda_t *npda, cnodeid_t node)
 {
 	hubinfo_t hubinfo;
+	nasid_t nasid;
 
 	extern void router_map_init(nodepda_t *);
 	extern void router_queue_init(nodepda_t *,cnodeid_t);
 	extern void intr_init_vecblk(nodepda_t *, cnodeid_t, int);
 
 	/* Allocate per-node platform-dependent data */
-	hubinfo = (hubinfo_t)alloc_bootmem_node(NODE_DATA(node), sizeof(struct hubinfo_s));
+	
+	nasid = COMPACT_TO_NASID_NODEID(node);
+	if (node >= numnodes) /* Headless/memless IO nodes */
+		hubinfo = (hubinfo_t)alloc_bootmem_node(NODE_DATA(0), sizeof(struct hubinfo_s));
+	else
+		hubinfo = (hubinfo_t)alloc_bootmem_node(NODE_DATA(node), sizeof(struct hubinfo_s));
 
 	npda->pdinfo = (void *)hubinfo;
 	hubinfo->h_nodepda = npda;
 	hubinfo->h_cnodeid = node;
-	hubinfo->h_nasid = COMPACT_TO_NASID_NODEID(node);
 
 	spin_lock_init(&hubinfo->h_crblock);
 
-	hubinfo->h_widgetid = hub_widget_id(hubinfo->h_nasid);
 	npda->xbow_peer = INVALID_NASID;
 
 	/* 
@@ -104,7 +65,22 @@ void init_platform_nodepda(nodepda_t *np
 	npda->npda_rip_last = &npda->npda_rip_first;
 	npda->geoid.any.type = GEO_TYPE_INVALID;
 
-	mutex_init_locked(&npda->xbow_sema); /* init it locked? */
+	init_MUTEX_LOCKED(&npda->xbow_sema); /* init it locked? */
+}
+
+void
+init_platform_hubinfo(nodepda_t **nodepdaindr) {
+	cnodeid_t       cnode;
+	hubinfo_t hubinfo;
+	nodepda_t *npda;
+	extern int numionodes;
+
+	for (cnode = 0; cnode < numionodes; cnode++) {
+		npda = nodepdaindr[cnode];
+		hubinfo = (hubinfo_t)npda->pdinfo;
+		hubinfo->h_nasid = COMPACT_TO_NASID_NODEID(cnode);
+		hubinfo->h_widgetid = hub_widget_id(hubinfo->h_nasid);
+	}
 }
 
 void
diff -puN arch/ia64/sn/io/sn2/ml_SN_intr.c~linus arch/ia64/sn/io/sn2/ml_SN_intr.c
--- 25/arch/ia64/sn/io/sn2/ml_SN_intr.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/ml_SN_intr.c	2004-01-19 22:17:21.000000000 -0800
@@ -14,7 +14,6 @@
 #include <asm/hw_irq.h>
 #include <asm/sn/sgi.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/labelcl.h>
 #include <asm/sn/io.h>
@@ -82,7 +81,7 @@ void intr_init_vecblk(cnodeid_t node)
 	/* Config and enable UART interrupt, all nodes. */
 	local5_config.sh_local_int5_config_regval = 0;
 	local5_config.sh_local_int5_config_s.idx = SGI_UART_VECTOR;
-	local5_config.sh_local_int5_config_s.pid = cpu0;
+	local5_config.sh_local_int5_config_s.pid = cpu;
 	HUB_S((unsigned long *)GLOBAL_MMR_ADDR(nasid, SH_LOCAL_INT5_CONFIG),
 		local5_config.sh_local_int5_config_regval);
 
@@ -223,7 +222,7 @@ static cpuid_t intr_cpu_choose_from_node
 		int intrs;
 
 		cpu = cnode_slice_to_cpuid(cnode, slice);
-		if (cpu == num_online_cpus())
+		if (cpu == NR_CPUS)
 			continue;
 		if (!cpu_online(cpu))
 			continue;
diff -puN arch/ia64/sn/io/sn2/module.c~linus arch/ia64/sn/io/sn2/module.c
--- 25/arch/ia64/sn/io/sn2/module.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/module.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -9,14 +8,14 @@
 
 #include <linux/types.h>
 #include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/string.h>
 #include <asm/sn/sgi.h>
 #include <asm/sn/sn_sal.h>
 #include <asm/sn/io.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/labelcl.h>
 #include <asm/sn/xtalk/xbow.h>
-#include <asm/sn/pci/bridge.h>
 #include <asm/sn/klconfig.h>
 #include <asm/sn/module.h>
 #include <asm/sn/pci/pcibr.h>
@@ -40,40 +39,8 @@ int			nummodules;
 #define SN00_SERIAL_FUDGE	0x3b1af409d513c2
 #define SN0_SERIAL_FUDGE	0x6e
 
-void
-encode_int_serial(uint64_t src,uint64_t *dest)
-{
-    uint64_t val;
-    int i;
-
-    val = src + SN00_SERIAL_FUDGE;
-
-
-    for (i = 0; i < sizeof(long long); i++) {
-	((char*)dest)[i] =
-	    ((char*)&val)[sizeof(long long)/2 +
-			 ((i%2) ? ((i/2 * -1) - 1) : (i/2))];
-    }
-}
-
-
-void
-decode_int_serial(uint64_t src, uint64_t *dest)
-{
-    uint64_t val;
-    int i;
-
-    for (i = 0; i < sizeof(long long); i++) {
-	((char*)&val)[sizeof(long long)/2 +
-		     ((i%2) ? ((i/2 * -1) - 1) : (i/2))] =
-	    ((char*)&src)[i];
-    }
-
-    *dest = val - SN00_SERIAL_FUDGE;
-}
 
-
-void
+static void __init
 encode_str_serial(const char *src, char *dest)
 {
     int i;
@@ -86,20 +53,8 @@ encode_str_serial(const char *src, char 
     }
 }
 
-void
-decode_str_serial(const char *src, char *dest)
-{
-    int i;
-
-    for (i = 0; i < MAX_SERIAL_NUM_SIZE; i++) {
-	dest[MAX_SERIAL_NUM_SIZE/2 +
-	    ((i%2) ? ((i/2 * -1) - 1) : (i/2))] = src[i] -
-	    SN0_SERIAL_FUDGE;
-    }
-}
-
-
-module_t *module_lookup(moduleid_t id)
+module_t * __init 
+module_lookup(moduleid_t id)
 {
     int			i;
 
@@ -121,13 +76,14 @@ module_t *module_lookup(moduleid_t id)
  *
  *   The node number is added to the list of nodes in the module.
  */
-
-module_t *module_add_node(geoid_t geoid, cnodeid_t cnodeid)
+static module_t * __init
+module_add_node(geoid_t geoid, cnodeid_t cnodeid)
 {
     module_t	       *m;
     int			i;
     char		buffer[16];
     moduleid_t		moduleid;
+    slabid_t		slab_number;
 
     memset(buffer, 0, 16);
     moduleid = geo_module(geoid);
@@ -136,14 +92,16 @@ module_t *module_add_node(geoid_t geoid,
 
     if ((m = module_lookup(moduleid)) == 0) {
 	m = kmalloc(sizeof (module_t), GFP_KERNEL);
-	memset(m, 0 , sizeof(module_t));
 	ASSERT_ALWAYS(m);
+	memset(m, 0 , sizeof(module_t));
+
+	for (slab_number = 0; slab_number <= MAX_SLABS; slab_number++) {
+		m->nodes[slab_number] = -1;
+	}
 
 	m->id = moduleid;
 	spin_lock_init(&m->lock);
 
-	mutex_init_locked(&m->thdcnt);
-
 	/* Insert in sorted order by module number */
 
 	for (i = nummodules; i > 0 && modules[i - 1]->id > moduleid; i--)
@@ -153,16 +111,26 @@ module_t *module_add_node(geoid_t geoid,
 	nummodules++;
     }
 
-    m->nodes[m->nodecnt] = cnodeid;
-    m->geoid[m->nodecnt] = geoid;
-    m->nodecnt++;
+    /*
+     * Save this information in the correct slab number of the node in the 
+     * module.
+     */
+    slab_number = geo_slab(geoid);
+    DPRINTF("slab number added 0x%x\n", slab_number);
+
+    if (m->nodes[slab_number] != -1) {
+	printk("module_add_node .. slab previously found\n");
+	return NULL;
+    }
 
-    DPRINTF("module_add_node: module %s now has %d nodes\n", buffer, m->nodecnt);
+    m->nodes[slab_number] = cnodeid;
+    m->geoid[slab_number] = geoid;
 
     return m;
 }
 
-int module_probe_snum(module_t *m, nasid_t nasid)
+static int __init
+module_probe_snum(module_t *m, nasid_t host_nasid, nasid_t nasid)
 {
     lboard_t	       *board;
     klmod_serial_num_t *comp;
@@ -171,13 +139,10 @@ int module_probe_snum(module_t *m, nasid
     /*
      * record brick serial number
      */
-    board = find_lboard((lboard_t *) KL_CONFIG_INFO(nasid), KLTYPE_SNIA);
+    board = find_lboard((lboard_t *) KL_CONFIG_INFO(host_nasid), KLTYPE_SNIA);
 
     if (! board || KL_CONFIG_DUPLICATE_BOARD(board))
     {
-#if	LDEBUG
-	printf ("module_probe_snum: no IP35 board found!\n");
-#endif
 	return 0;
     }
 
@@ -186,12 +151,6 @@ int module_probe_snum(module_t *m, nasid
 	encode_str_serial( serial_number, m->snum.snum_str );
 	m->snum_valid = 1;
     }
-#if	LDEBUG
-    else {
-	printf("module_probe_snum: brick serial number is null!\n");
-    }
-    printf("module_probe_snum: brick serial number == %s\n", serial_number);
-#endif /* DEBUG */
 
     board = find_lboard((lboard_t *) KL_CONFIG_INFO(nasid),
 			KLTYPE_IOBRICK_XBOW);
@@ -202,22 +161,10 @@ int module_probe_snum(module_t *m, nasid
     comp = GET_SNUM_COMP(board);
 
     if (comp) {
-#if LDEBUG
-	    int i;
-
-	    printf("********found module with id %x and string", m->id);
-
-	    for (i = 0; i < MAX_SERIAL_NUM_SIZE; i++)
-		printf(" %x ", comp->snum.snum_str[i]);
-
-	    printf("\n");	/* Fudged string is not ASCII */
-#endif
-
 	    if (comp->snum.snum_str[0] != '\0') {
-		memcpy(m->sys_snum,
-		       comp->snum.snum_str,
-		       MAX_SERIAL_NUM_SIZE);
-		m->sys_snum_valid = 1;
+		    memcpy(m->sys_snum, comp->snum.snum_str,
+			   MAX_SERIAL_NUM_SIZE);
+		    m->sys_snum_valid = 1;
 	    }
     }
 
@@ -230,7 +177,7 @@ int module_probe_snum(module_t *m, nasid
     }
 }
 
-void
+void __init
 io_module_init(void)
 {
     cnodeid_t		node;
@@ -243,21 +190,20 @@ io_module_init(void)
 
     nserial = 0;
 
+    /*
+     * First pass just scan for compute node boards KLTYPE_SNIA.
+     * We do not support memoryless compute nodes.
+     */
     for (node = 0; node < numnodes; node++) {
 	nasid = COMPACT_TO_NASID_NODEID(node);
 
 	board = find_lboard((lboard_t *) KL_CONFIG_INFO(nasid), KLTYPE_SNIA);
 	ASSERT(board);
 
-	m = module_add_node(board->brd_geoid, node);
+	HWGRAPH_DEBUG((__FILE__, __FUNCTION__, __LINE__, NULL, NULL, "Found Shub lboard 0x%lx nasid 0x%x cnode 0x%x \n", (unsigned long)board, (int)nasid, (int)node));
 
-	if (! m->snum_valid && module_probe_snum(m, nasid))
+	m = module_add_node(board->brd_geoid, node);
+	if (! m->snum_valid && module_probe_snum(m, nasid, nasid))
 	    nserial++;
     }
-
-    DPRINTF("********found total of %d serial numbers in the system\n",
-	    nserial);
-
-    if (nserial == 0)
-	DPRINTF(KERN_WARNING  "io_module_init: No serial number found.\n");
 }
diff -puN arch/ia64/sn/io/sn2/pcibr/Makefile~linus arch/ia64/sn/io/sn2/pcibr/Makefile
--- 25/arch/ia64/sn/io/sn2/pcibr/Makefile~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/pcibr/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -9,7 +9,8 @@
 # Makefile for the sn2 specific pci bridge routines.
 #
 
-EXTRA_CFLAGS    := -DLITTLE_ENDIAN
-
-obj-y += pcibr_ate.o pcibr_config.o pcibr_dvr.o pcibr_hints.o pcibr_intr.o pcibr_rrb.o \
-	 pcibr_slot.o pcibr_error.o
+obj-y += pcibr_ate.o pcibr_config.o \
+	 pcibr_dvr.o pcibr_hints.o  \
+	 pcibr_intr.o pcibr_rrb.o   \
+	 pcibr_slot.o pcibr_error.o \
+	 pcibr_reg.o 
diff -puN arch/ia64/sn/io/sn2/pcibr/pcibr_ate.c~linus arch/ia64/sn/io/sn2/pcibr/pcibr_ate.c
--- 25/arch/ia64/sn/io/sn2/pcibr/pcibr_ate.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/pcibr/pcibr_ate.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
 /*
- *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -8,30 +7,12 @@
  */
 
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/module.h>
 #include <asm/sn/sgi.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/addrs.h>
-#include <asm/sn/arch.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/pci/bridge.h>
 #include <asm/sn/pci/pciio.h>
 #include <asm/sn/pci/pcibr.h>
 #include <asm/sn/pci/pcibr_private.h>
 #include <asm/sn/pci/pci_defs.h>
-#include <asm/sn/prio.h>
-#include <asm/sn/xtalk/xbow.h>
-#include <asm/sn/io.h>
-#include <asm/sn/sn_private.h>
-
-#ifndef LOCAL
-#define LOCAL           static
-#endif
 
 /*
  * functions
@@ -62,7 +43,7 @@ void ate_thaw(pcibr_dmamap_t pcibr_dmama
 #define ATE_NUM_ENTRIES(n) _ate_info[n]
 
 /* Possible choices for number of ATE entries in Bridge's SSRAM */
-LOCAL int               _ate_info[] =
+static int               _ate_info[] =
 {
     0,					/* 0 entries */
     8 * 1024,				/* 8K entries */
@@ -85,7 +66,6 @@ pcibr_init_ext_ate_ram(bridge_t *bridge)
     int                     num_entries, entry;
     int                     i, j;
     bridgereg_t             old_enable, new_enable;
-    int                     s;
 
     /* Probe SSRAM to determine its size. */
     old_enable = bridge->b_int_enable;
@@ -112,12 +92,10 @@ pcibr_init_ext_ate_ram(bridge_t *bridge)
      * The read following the write is required for the Bridge war
      */
 
-    s = splhi();
     bridge->b_wid_control = (bridge->b_wid_control
 			& ~BRIDGE_CTRL_SSRAM_SIZE_MASK)
 			| BRIDGE_CTRL_SSRAM_SIZE(largest_working_size);
     bridge->b_wid_control;		/* inval addr bug war */
-    splx(s);
 
     num_entries = ATE_NUM_ENTRIES(largest_working_size);
 
@@ -381,25 +359,9 @@ ate_write(pcibr_soft_t pcibr_soft,
 	  int ate_count,
 	  bridge_ate_t ate)
 {
-	if (IS_PIC_SOFT(pcibr_soft) ) {
-    		while (ate_count-- > 0) {
-			*ate_ptr++ = ate;
-			ate += IOPGSIZE;
-		}
-	}
-	else {
-		if (io_get_sh_swapper(NASID_GET(ate_ptr))) {
-    			while (ate_count-- > 0) {
-				*ate_ptr++ = __swab64(ate);
-				ate += IOPGSIZE;
-			}
-		}
-		else {
-    			while (ate_count-- > 0) {
-				*ate_ptr++ = ate;
-				ate += IOPGSIZE;
-			}
-		}
+  	while (ate_count-- > 0) {
+		*ate_ptr++ = ate;
+		ate += IOPGSIZE;
 	}
 }
 
@@ -441,19 +403,7 @@ ate_thaw(pcibr_dmamap_t pcibr_dmamap,
     for (slot = pcibr_soft->bs_min_slot; 
 		slot < PCIBR_NUM_SLOTS(pcibr_soft); ++slot) {
 	if ((cmd_reg = cmd_regs[slot]) & PCI_CMD_BUS_MASTER) {
-		if ( IS_PIC_SOFT(pcibr_soft) ) {
-			pcibr_slot_config_set(bridge, slot, PCI_CFG_COMMAND/4, cmd_reg);
-		}
-		else {
-			if (io_get_sh_swapper(NASID_GET(bridge))) {
-				bridge->b_type0_cfg_dev[slot].l[PCI_CFG_COMMAND / 4] = __swab32(cmd_reg);
-			}
-			else {
-//				BUG(); /* Does this really work if called when io_get_sh_swapper = 0? */
-//				bridge->b_type0_cfg_dev[slot].l[PCI_CFG_COMMAND / 4] = cmd_reg;
-				pcibr_slot_config_set(bridge, slot, PCI_CFG_COMMAND/4, cmd_reg);
-			}
-		}
+		pcibr_slot_config_set(bridge, slot, PCI_CFG_COMMAND/4, cmd_reg);
 	}
     }
     pcibr_dmamap->bd_flags |= PCIBR_DMAMAP_BUSY;
diff -puN arch/ia64/sn/io/sn2/pcibr/pcibr_config.c~linus arch/ia64/sn/io/sn2/pcibr/pcibr_config.c
--- 25/arch/ia64/sn/io/sn2/pcibr/pcibr_config.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/pcibr/pcibr_config.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
 /*
- *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -8,27 +7,12 @@
  */
 
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/byteorder/swab.h>
 #include <asm/sn/sgi.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/addrs.h>
-#include <asm/sn/arch.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/pci/bridge.h>
 #include <asm/sn/pci/pciio.h>
 #include <asm/sn/pci/pcibr.h>
 #include <asm/sn/pci/pcibr_private.h>
 #include <asm/sn/pci/pci_defs.h>
-#include <asm/sn/prio.h>
-#include <asm/sn/xtalk/xbow.h>
-#include <asm/sn/io.h>
-#include <asm/sn/sn_private.h>
 
 extern pcibr_info_t      pcibr_info_get(vertex_hdl_t);
 
@@ -38,23 +22,12 @@ void              pcibr_config_set(verte
 void       	  do_pcibr_config_set(cfg_p, unsigned, unsigned, uint64_t);
 
 /*
- * on sn-ia we need to twiddle the the addresses going out
- * the pci bus because we use the unswizzled synergy space
- * (the alternative is to use the swizzled synergy space
- * and byte swap the data)
+ * fancy snia bit twiddling....
  */
-#define CB(b,r) (((volatile uint8_t *) b)[((r)^4)])
-#define CS(b,r) (((volatile uint16_t *) b)[((r^4)/2)])
-#define CW(b,r) (((volatile uint32_t *) b)[((r^4)/4)])
-
 #define	CBP(b,r) (((volatile uint8_t *) b)[(r)])
 #define	CSP(b,r) (((volatile uint16_t *) b)[((r)/2)])
 #define	CWP(b,r) (((volatile uint32_t *) b)[(r)/4])
 
-#define SCB(b,r) (((volatile uint8_t *) b)[((r)^3)])
-#define SCS(b,r) (((volatile uint16_t *) b)[((r^2)/2)])
-#define SCW(b,r) (((volatile uint32_t *) b)[((r)/4)])
-
 /*
  * Return a config space address for given slot / func / offset.  Note the
  * returned pointer is a 32bit word (ie. cfg_p) aligned pointer pointing to
diff -puN arch/ia64/sn/io/sn2/pcibr/pcibr_dvr.c~linus arch/ia64/sn/io/sn2/pcibr/pcibr_dvr.c
--- 25/arch/ia64/sn/io/sn2/pcibr/pcibr_dvr.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/pcibr/pcibr_dvr.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
 /*
- *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -7,31 +6,18 @@
  * Copyright (C) 2001-2003 Silicon Graphics, Inc. All rights reserved.
  */
 
-#include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/string.h>
 #include <linux/interrupt.h>
-#include <linux/ioport.h>
 #include <asm/sn/sgi.h>
 #include <asm/sn/sn_sal.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/addrs.h>
-#include <asm/sn/arch.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/klconfig.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/pci/bridge.h>
 #include <asm/sn/pci/pciio.h>
 #include <asm/sn/pci/pcibr.h>
 #include <asm/sn/pci/pcibr_private.h>
 #include <asm/sn/pci/pci_defs.h>
-#include <asm/sn/prio.h>
-#include <asm/sn/xtalk/xbow.h>
-#include <asm/sn/io.h>
+
+#include <asm/sn/prio.h> 
 #include <asm/sn/sn_private.h>
 
 /*
@@ -39,36 +25,15 @@
  *   -pcibr_debug_mask is the mask of the different types of debugging
  *    you want to enable.  See sys/PCI/pcibr_private.h 
  *   -pcibr_debug_module is the module you want to trace.  By default
- *    all modules are trace.  For IP35 this value has the format of
- *    something like "001c10".  For IP27 this value is a node number,
- *    i.e. "1", "2"...  For IP30 this is undefined and should be set to
- *    'all'.
- *   -pcibr_debug_widget is the widget you want to trace.  For IP27
- *    the widget isn't exposed in the hwpath so use the xio slot num.
- *    i.e. for 'io2' set pcibr_debug_widget to "2".
+ *    all modules are trace.  The format is something like "001c10".
+ *   -pcibr_debug_widget is the widget you want to trace.  For TIO 
+ *    based bricks use the corelet id.
  *   -pcibr_debug_slot is the pci slot you want to trace.
  */
 uint32_t pcibr_debug_mask = 0x0;	/* 0x00000000 to disable */
-char      *pcibr_debug_module = "all";		/* 'all' for all modules */
-int	   pcibr_debug_widget = -1;		/* '-1' for all widgets  */
-int	   pcibr_debug_slot = -1;		/* '-1' for all slots    */
-
-/*
- * Macros related to the Lucent USS 302/312 usb timeout workaround.  It
- * appears that if the lucent part can get into a retry loop if it sees a
- * DAC on the bus during a pio read retry.  The loop is broken after about
- * 1ms, so we need to set up bridges holding this part to allow at least
- * 1ms for pio.
- */
-
-#define USS302_TIMEOUT_WAR
-
-#ifdef USS302_TIMEOUT_WAR
-#define LUCENT_USBHC_VENDOR_ID_NUM	0x11c1
-#define LUCENT_USBHC302_DEVICE_ID_NUM	0x5801
-#define LUCENT_USBHC312_DEVICE_ID_NUM	0x5802
-#define USS302_BRIDGE_TIMEOUT_HLD	4
-#endif
+static char      *pcibr_debug_module = "all";		/* 'all' for all modules */
+static int	   pcibr_debug_widget = -1;		/* '-1' for all widgets  */
+static int	   pcibr_debug_slot = -1;		/* '-1' for all slots    */
 
 /* kbrick widgetnum-to-bus layout */
 int p_busnum[MAX_PORT_NUM] = {                  /* widget#      */
@@ -82,6 +47,24 @@ int p_busnum[MAX_PORT_NUM] = {          
         3,                                      /* 0xf          */
 };
 
+char *pci_space[] = {"NONE",
+                     "ROM",
+                     "IO",
+                     "",
+                     "MEM",
+                     "MEM32",
+                     "MEM64",
+                     "CFG",
+                     "WIN0",
+                     "WIN1",
+                     "WIN2",
+                     "WIN3",
+                     "WIN4",
+                     "WIN5",
+                     "",
+                     "BAD"};
+
+
 #if PCIBR_SOFT_LIST
 pcibr_list_p            pcibr_list = 0;
 #endif
@@ -289,12 +272,10 @@ pcibr_try_set_device(pcibr_soft_t pcibr_
     bridgereg_t             xmask;
 
     xmask = mask;
-    if (IS_XBRIDGE_OR_PIC_SOFT(pcibr_soft)) {
-    	if (mask == BRIDGE_DEV_PMU_BITS)
-		xmask = XBRIDGE_DEV_PMU_BITS;
-	if (mask == BRIDGE_DEV_D64_BITS)
-		xmask = XBRIDGE_DEV_D64_BITS;
-    }
+    if (mask == BRIDGE_DEV_PMU_BITS)
+	xmask = XBRIDGE_DEV_PMU_BITS;
+    if (mask == BRIDGE_DEV_D64_BITS)
+	xmask = XBRIDGE_DEV_D64_BITS;
 
     slotp = &pcibr_soft->bs_slot[slot];
 
@@ -376,11 +357,9 @@ pcibr_try_set_device(pcibr_soft_t pcibr_
 	new &= ~BRIDGE_DEV_WRGA_BITS;
 
     if (flags & PCIIO_BYTE_STREAM)
-	new |= (IS_XBRIDGE_OR_PIC_SOFT(pcibr_soft)) ? 
-			BRIDGE_DEV_SWAP_DIR : BRIDGE_DEV_SWAP_BITS;
+	new |= BRIDGE_DEV_SWAP_DIR;
     if (flags & PCIIO_WORD_VALUES)
-	new &= (IS_XBRIDGE_OR_PIC_SOFT(pcibr_soft)) ? 
-			~BRIDGE_DEV_SWAP_DIR : ~BRIDGE_DEV_SWAP_BITS;
+	new &= ~BRIDGE_DEV_SWAP_DIR;
 
     /* Provider-specific flags
      */
@@ -410,7 +389,7 @@ pcibr_try_set_device(pcibr_soft_t pcibr_
      * device.  The bit is only intended for 64-bit devices and, on
      * PIC, can cause problems for 32-bit devices.
      */
-    if (IS_PIC_SOFT(pcibr_soft) && mask == BRIDGE_DEV_D64_BITS &&
+    if (mask == BRIDGE_DEV_D64_BITS &&
                                 PCIBR_WAR_ENABLED(PV855271, pcibr_soft)) {
         if (flags & PCIBR_VCHAN1) {
                 new |= BRIDGE_DEV_VIRTUAL_EN;
@@ -418,6 +397,11 @@ pcibr_try_set_device(pcibr_soft_t pcibr_
         }
     }
 
+    /* PIC BRINGUP WAR (PV# 878674):   Don't allow 64bit PIO accesses */
+    if (IS_PIC_SOFT(pcibr_soft) && (flags & PCIBR_64BIT) &&
+				PCIBR_WAR_ENABLED(PV878674, pcibr_soft)) {
+	new &= ~(1ull << 22);
+    }
 
     chg = old ^ new;				/* what are we changing, */
     chg &= xmask;				/* of the interesting bits */
@@ -425,13 +409,8 @@ pcibr_try_set_device(pcibr_soft_t pcibr_
     if (chg) {
 
 	badd32 = slotp->bss_d32_uctr ? (BRIDGE_DEV_D32_BITS & chg) : 0;
-	if (IS_XBRIDGE_OR_PIC_SOFT(pcibr_soft)) {
-		badpmu = slotp->bss_pmu_uctr ? (XBRIDGE_DEV_PMU_BITS & chg) : 0;
-		badd64 = slotp->bss_d64_uctr ? (XBRIDGE_DEV_D64_BITS & chg) : 0;
-	} else {
-		badpmu = slotp->bss_pmu_uctr ? (BRIDGE_DEV_PMU_BITS & chg) : 0;
-		badd64 = slotp->bss_d64_uctr ? (BRIDGE_DEV_D64_BITS & chg) : 0;
-	}
+	badpmu = slotp->bss_pmu_uctr ? (XBRIDGE_DEV_PMU_BITS & chg) : 0;
+	badd64 = slotp->bss_d64_uctr ? (XBRIDGE_DEV_D64_BITS & chg) : 0;
 	bad = badpmu | badd32 | badd64;
 
 	if (bad) {
@@ -473,6 +452,8 @@ pcibr_try_set_device(pcibr_soft_t pcibr_
 	     */
 	    if (bad) {
 		pcibr_unlock(pcibr_soft, s);
+		PCIBR_DEBUG((PCIBR_DEBUG_DEVREG, pcibr_soft->bs_vhdl,
+			    "pcibr_try_set_device: mod blocked by 0x%x\n", bad));
 		return bad;
 	    }
 	}
@@ -495,25 +476,13 @@ pcibr_try_set_device(pcibr_soft_t pcibr_
 	pcibr_unlock(pcibr_soft, s);
 	return 0;
     }
-    if ( IS_PIC_SOFT(pcibr_soft) ) {
-	bridge->b_device[slot].reg = new;
-	slotp->bss_device = new;
-	bridge->b_wid_tflush;		/* wait until Bridge PIO complete */
-    }
-    else {
-	if (io_get_sh_swapper(NASID_GET(bridge))) {
-		BRIDGE_REG_SET32((&bridge->b_device[slot].reg)) = __swab32(new);
-		slotp->bss_device = new;
-		BRIDGE_REG_GET32((&bridge->b_wid_tflush));  /* wait until Bridge PIO complete */
-	} else {
-		bridge->b_device[slot].reg = new;
-		slotp->bss_device = new;
-		bridge->b_wid_tflush;               /* wait until Bridge PIO complete */
-	}
-    }
+    bridge->b_device[slot].reg = new;
+    slotp->bss_device = new;
+    bridge->b_wid_tflush;		/* wait until Bridge PIO complete */
     pcibr_unlock(pcibr_soft, s);
 
-    printk("pcibr_try_set_device: Device(%d): %x\n", slot, new);
+    PCIBR_DEBUG((PCIBR_DEBUG_DEVREG, pcibr_soft->bs_vhdl,
+		"pcibr_try_set_device: Device(%d): 0x%x\n", slot, new));
     return 0;
 }
 
@@ -548,22 +517,13 @@ pcibr_device_write_gather_flush(pcibr_so
 {
     bridge_t               *bridge;
     unsigned long          s;
-    volatile uint32_t     wrf;
+    volatile uint32_t     wrf; 
     s = pcibr_lock(pcibr_soft);
     bridge = pcibr_soft->bs_base;
-
-    if ( IS_PIC_SOFT(pcibr_soft) ) {
-	wrf = bridge->b_wr_req_buf[slot].reg;
-    }
-    else {
-	if (io_get_sh_swapper(NASID_GET(bridge))) {
-		wrf = BRIDGE_REG_GET32((&bridge->b_wr_req_buf[slot].reg));
-	} else {
-		wrf = bridge->b_wr_req_buf[slot].reg;
-	}
-    }
+    
+    wrf = bridge->b_wr_req_buf[slot].reg;
     pcibr_unlock(pcibr_soft, s);
-}
+}   
 
 /* =====================================================================
  *    Bridge (pcibr) "Device Driver" entry points
@@ -662,7 +622,12 @@ pcibr_device_info_new(
      * passed into us, into its external representation.  See comment
      * for the PCIBR_DEVICE_TO_SLOT macro for more information.
      */
-    NEW(pcibr_info);
+    pcibr_info = kmalloc(sizeof (*(pcibr_info)), GFP_KERNEL);
+    if ( !pcibr_info ) {
+	return NULL;
+    }
+    memset(pcibr_info, 0, sizeof (*(pcibr_info)));
+
     pciio_device_info_new(&pcibr_info->f_c, pcibr_soft->bs_vhdl,
 			  PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot),
 			  rfunc, vendor, device);
@@ -720,7 +685,7 @@ pcibr_device_unregister(vertex_hdl_t pco
     pcibr_soft_t	 pcibr_soft;
     bridge_t		*bridge;
     int                  count_vchan0, count_vchan1;
-    unsigned             s;
+    unsigned long	 s;
     int			 error_call;
     int			 error = 0;
 
@@ -746,9 +711,6 @@ pcibr_device_unregister(vertex_hdl_t pco
 
         s = pcibr_lock(pcibr_soft);
 
-	/* PIC NOTE: If this is a BRIDGE, VCHAN2 & VCHAN3 will be zero so
-	 * no need to conditionalize this (ie. "if (IS_PIC_SOFT())" ).
-	 */
         pcibr_soft->bs_rrb_res[slot] = pcibr_soft->bs_rrb_res[slot] +
                                        pcibr_soft->bs_rrb_valid[slot][VCHAN0] +
                                        pcibr_soft->bs_rrb_valid[slot][VCHAN1] +
@@ -983,18 +945,15 @@ pcibr_attach2(vertex_hdl_t xconn_vhdl, b
     char                    devnm[MAXDEVNAME], *s;
     pcibr_hints_t           pcibr_hints;
     uint64_t              int_enable;
-    bridgereg_t             int_enable_32;
     picreg_t                int_enable_64;
     unsigned                rrb_fixed = 0;
 
-    int                     spl_level;
-
 #if PCI_FBBE
     int                     fast_back_to_back_enable;
 #endif
     nasid_t		    nasid;
     int	                    iobrick_type_get_nasid(nasid_t nasid);
-    int                     iobrick_module_get_nasid(nasid_t nasid);
+    int                     iomoduleid_get(nasid_t nasid);
 
     PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ATTACH, pcibr_vhdl,
 	        "pcibr_attach2: bridge=0x%p, busnum=%d\n", bridge, busnum));
@@ -1025,10 +984,13 @@ pcibr_attach2(vertex_hdl_t xconn_vhdl, b
      * allocate soft state structure, fill in some
      * fields, and hook it up to our vertex.
      */
-    NEW(pcibr_soft);
+    pcibr_soft = kmalloc(sizeof(*(pcibr_soft)), GFP_KERNEL);
     if (ret_softp)
 	*ret_softp = pcibr_soft;
-    BZERO(pcibr_soft, sizeof *pcibr_soft);
+    if (!pcibr_soft)
+	return -1;
+
+    memset(pcibr_soft, 0, sizeof *pcibr_soft);
     pcibr_soft_set(pcibr_vhdl, pcibr_soft);
     pcibr_soft->bs_conn = xconn_vhdl;
     pcibr_soft->bs_vhdl = pcibr_vhdl;
@@ -1094,7 +1056,10 @@ pcibr_attach2(vertex_hdl_t xconn_vhdl, b
     {
 	pcibr_list_p            self;
 
-	NEW(self);
+	self = kmalloc(sizeof(*(self)), GFP_KERNEL);
+	if (!self)
+		return -1;
+	memset(self, 0, sizeof(*(self)));
 	self->bl_soft = pcibr_soft;
 	self->bl_vhdl = pcibr_vhdl;
 	self->bl_next = pcibr_list;
@@ -1112,8 +1077,7 @@ pcibr_attach2(vertex_hdl_t xconn_vhdl, b
 
     PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ATTACH, pcibr_vhdl,
 		"pcibr_attach2: %s ASIC: rev %s (code=0x%x)\n",
-		IS_XBRIDGE_SOFT(pcibr_soft) ? "XBridge" :
-			IS_PIC_SOFT(pcibr_soft) ? "PIC" : "Bridge", 
+		"PIC",
 		(rev == BRIDGE_PART_REV_A) ? "A" : 
                 (rev == BRIDGE_PART_REV_B) ? "B" :
                 (rev == BRIDGE_PART_REV_C) ? "C" :
@@ -1143,7 +1107,7 @@ pcibr_attach2(vertex_hdl_t xconn_vhdl, b
 	printk(KERN_WARNING "0x%p: Unknown bricktype : 0x%x\n", (void *)xconn_vhdl,
 				(unsigned int)pcibr_soft->bs_bricktype);
 
-    pcibr_soft->bs_moduleid = iobrick_module_get_nasid(nasid);
+    pcibr_soft->bs_moduleid = iomoduleid_get(nasid);
 
     if (pcibr_soft->bs_bricktype > 0) {
 	switch (pcibr_soft->bs_bricktype) {
@@ -1268,12 +1232,8 @@ pcibr_attach2(vertex_hdl_t xconn_vhdl, b
      * is a wrapper routine we register that will call the real error handler
      * pcibr_error_handler() with the correct pcibr_soft struct.
      */
-    if (IS_PIC_SOFT(pcibr_soft)) {
-	if (busnum == 0) {
-	    xwidget_error_register(xconn_vhdl, pcibr_error_handler_wrapper, pcibr_soft);
-	}
-    } else {
-	xwidget_error_register(xconn_vhdl, pcibr_error_handler, pcibr_soft);
+    if (busnum == 0) {
+    	xwidget_error_register(xconn_vhdl, pcibr_error_handler_wrapper, pcibr_soft);
     }
 
     /*
@@ -1293,7 +1253,7 @@ pcibr_attach2(vertex_hdl_t xconn_vhdl, b
     bridge->b_int_rst_stat = (BRIDGE_IRR_ALL_CLR);
 
     /* Initialize some PIC specific registers. */
-    if (IS_PIC_SOFT(pcibr_soft)) {
+    {
 	picreg_t pic_ctrl_reg = bridge->p_wid_control_64;
 
 	/* Bridges Requester ID: bus = busnum, dev = 0, func = 0 */
@@ -1317,19 +1277,7 @@ pcibr_attach2(vertex_hdl_t xconn_vhdl, b
 
 	bridge->p_wid_control_64 = pic_ctrl_reg;
     }
-
-    /*
-     * Until otherwise set up,
-     * assume all interrupts are
-     * from slot 7(Bridge/Xbridge) or 3(PIC).
-     * XXX. Not sure why we're doing this, made change for PIC
-     * just to avoid setting reserved bits.
-     */
-    if (IS_PIC_SOFT(pcibr_soft))
-	bridge->b_int_device = (uint32_t) 0x006db6db;
-    else
-	bridge->b_int_device = (uint32_t) 0xffffffff;
-
+    bridge->b_int_device = (uint32_t) 0x006db6db;
     {
 	bridgereg_t             dirmap;
 	paddr_t                 paddr;
@@ -1367,7 +1315,7 @@ pcibr_attach2(vertex_hdl_t xconn_vhdl, b
 	 * for the lowest hunk of memory.
 	 */
 	xbase = xtalk_dmatrans_addr(xconn_vhdl, 0,
-				    paddr, _PAGESZ, 0);
+				    paddr, PAGE_SIZE, 0);
 
 	if (xbase != XIO_NOWHERE) {
 	    if (XIO_PACKED(xbase)) {
@@ -1397,24 +1345,14 @@ pcibr_attach2(vertex_hdl_t xconn_vhdl, b
 	 * ensure that we write and read without any interruption.
 	 * The read following the write is required for the Bridge war
 	 */
-	spl_level = splhi();
 #if IOPGSIZE == 4096
-        if (IS_PIC_SOFT(pcibr_soft)) {
-            bridge->p_wid_control_64 &= ~BRIDGE_CTRL_PAGE_SIZE;
-        } else {
-            bridge->b_wid_control &= ~BRIDGE_CTRL_PAGE_SIZE;
-        }
+        bridge->p_wid_control_64 &= ~BRIDGE_CTRL_PAGE_SIZE;
 #elif IOPGSIZE == 16384
-        if (IS_PIC_SOFT(pcibr_soft)) {
-            bridge->p_wid_control_64 |= BRIDGE_CTRL_PAGE_SIZE;
-        } else {
-            bridge->b_wid_control |= BRIDGE_CTRL_PAGE_SIZE;
-        }
+        bridge->p_wid_control_64 |= BRIDGE_CTRL_PAGE_SIZE;
 #else
 	<<<Unable to deal with IOPGSIZE >>>;
 #endif
 	bridge->b_wid_control;		/* inval addr bug war */
-	splx(spl_level);
 
 	/* Initialize internal mapping entries */
 	for (entry = 0; entry < pcibr_soft->bs_int_ate_size; entry++) {
@@ -1441,10 +1379,7 @@ pcibr_attach2(vertex_hdl_t xconn_vhdl, b
 	 * time.
 	 */
 
-	if (IS_XBRIDGE_OR_PIC_SOFT(pcibr_soft))
-		num_entries = 0;
-	else
-		num_entries = pcibr_init_ext_ate_ram(bridge);
+	num_entries = 0;
 
 	/* we always have 128 ATEs (512 for Xbridge) inside the chip
 	 * even if disabled for debugging.
@@ -1552,24 +1487,8 @@ pcibr_attach2(vertex_hdl_t xconn_vhdl, b
      * enable all of them.
      * NOTE: some PCI ints may already be enabled.
      */
-    /* We read the INT_ENABLE register as a 64bit picreg_t for PIC and a
-     * 32bit bridgereg_t for BRIDGE, but always process the result as a
-     * 64bit value so the code can be "common" for both PIC and BRIDGE...
-     */
-    if (IS_PIC_SOFT(pcibr_soft)) {
-	int_enable_64 = bridge->p_int_enable_64 | BRIDGE_ISR_ERRORS;
-        int_enable = (uint64_t)int_enable_64;
-#ifdef PFG_TEST
-	int_enable = (uint64_t)0x7ffffeff7ffffeff;
-#endif
-    } else {
-	int_enable_32 = bridge->b_int_enable | (BRIDGE_ISR_ERRORS & 0xffffffff);
-	int_enable = ((uint64_t)int_enable_32 & 0xffffffff);
-#ifdef PFG_TEST
-	int_enable = (uint64_t)0x7ffffeff;
-#endif
-    }
-
+    int_enable_64 = bridge->p_int_enable_64 | BRIDGE_ISR_ERRORS;
+    int_enable = (uint64_t)int_enable_64;
 
 #if BRIDGE_ERROR_INTR_WAR
     if (pcibr_soft->bs_rev_num == BRIDGE_PART_REV_A) {
@@ -1609,7 +1528,7 @@ pcibr_attach2(vertex_hdl_t xconn_vhdl, b
      * locked out to be freed up sooner (by timing out) so that the
      * read tnums are never completely used up.
      */
-    if (IS_PIC_SOFT(pcibr_soft) && PCIBR_WAR_ENABLED(PV856864, pcibr_soft)) {
+    if (PCIBR_WAR_ENABLED(PV856864, pcibr_soft)) {
         int_enable &= ~PIC_ISR_PCIX_REQ_TOUT;
         int_enable &= ~BRIDGE_ISR_XREAD_REQ_TIMEOUT;
 
@@ -1621,16 +1540,12 @@ pcibr_attach2(vertex_hdl_t xconn_vhdl, b
      * RRB0, RRB8, RRB1, and RRB9.  Assign them to DEVICE[2|3]--VCHAN3
      * so they are not used
      */
-    if (IS_PIC_SOFT(pcibr_soft) && PCIBR_WAR_ENABLED(PV856866, pcibr_soft)) {
+    if (PCIBR_WAR_ENABLED(PV856866, pcibr_soft)) {
         bridge->b_even_resp |= 0x000f000f;
         bridge->b_odd_resp |= 0x000f000f;
     }
 
-    if (IS_PIC_SOFT(pcibr_soft)) {
-        bridge->p_int_enable_64 = (picreg_t)int_enable;
-    } else {
-        bridge->b_int_enable = (bridgereg_t)int_enable;
-    }
+    bridge->p_int_enable_64 = (picreg_t)int_enable;
     bridge->b_int_mode = 0;		/* do not send "clear interrupt" packets */
 
     bridge->b_wid_tflush;		/* wait until Bridge PIO complete */
@@ -1690,7 +1605,7 @@ pcibr_attach2(vertex_hdl_t xconn_vhdl, b
     /* Setup the Bus's PCI IO Root Resource. */
     pcibr_soft->bs_io_win_root_resource.start = PCIBR_BUS_IO_BASE;
     pcibr_soft->bs_io_win_root_resource.end = 0xffffffff;
-    res = (struct resource *) kmalloc( sizeof(struct resource), KM_NOSLEEP);
+    res = (struct resource *) kmalloc( sizeof(struct resource), GFP_KERNEL);
     if (!res)
 	panic("PCIBR:Unable to allocate resource structure\n");
 
@@ -1702,13 +1617,13 @@ pcibr_attach2(vertex_hdl_t xconn_vhdl, b
 	panic("PCIBR:Unable to request_resource()\n");
 
     /* Setup the Small Window Root Resource */
-    pcibr_soft->bs_swin_root_resource.start = _PAGESZ;
+    pcibr_soft->bs_swin_root_resource.start = PAGE_SIZE;
     pcibr_soft->bs_swin_root_resource.end = 0x000FFFFF;
 
     /* Setup the Bus's PCI Memory Root Resource */
     pcibr_soft->bs_mem_win_root_resource.start = 0x200000;
     pcibr_soft->bs_mem_win_root_resource.end = 0xffffffff;
-    res = (struct resource *) kmalloc( sizeof(struct resource), KM_NOSLEEP);
+    res = (struct resource *) kmalloc( sizeof(struct resource), GFP_KERNEL);
     if (!res)
         panic("PCIBR:Unable to allocate resource structure\n");
 
@@ -1776,8 +1691,7 @@ pcibr_attach2(vertex_hdl_t xconn_vhdl, b
     }
 
     /* Set up convenience links */
-    if (IS_XBRIDGE_OR_PIC_SOFT(pcibr_soft))
-	pcibr_bus_cnvlink(pcibr_soft->bs_vhdl);
+    pcibr_bus_cnvlink(pcibr_soft->bs_vhdl);
 
     for (slot = pcibr_soft->bs_min_slot; 
 				slot < PCIBR_NUM_SLOTS(pcibr_soft); ++slot)
@@ -1881,11 +1795,7 @@ pcibr_detach(vertex_hdl_t xconn)
 
     s = pcibr_lock(pcibr_soft);
     /* Disable the interrupts from the bridge */
-    if (IS_PIC_SOFT(pcibr_soft)) {
-	bridge->p_int_enable_64 = 0;
-    } else {
-	bridge->b_int_enable = 0;
-    }
+    bridge->p_int_enable_64 = 0;
     pcibr_unlock(pcibr_soft, s);
 
     /* Detach all the PCI devices talking to this bridge */
@@ -1898,7 +1808,6 @@ pcibr_detach(vertex_hdl_t xconn)
     pciio_device_info_unregister(pcibr_vhdl,
 				 &(pcibr_soft->bs_noslot_info->f_c));
 
-    spin_lock_destroy(&pcibr_soft->bs_lock);
     kfree(pcibr_soft->bs_name);
     
     /* Disconnect the error interrupt and free the xtalk resources 
@@ -1910,13 +1819,14 @@ pcibr_detach(vertex_hdl_t xconn)
     /* Clear the software state maintained by the bridge driver for this
      * bridge.
      */
-    DEL(pcibr_soft);
+    kfree(pcibr_soft);
+
     /* Remove the Bridge revision labelled info */
     (void)hwgraph_info_remove_LBL(pcibr_vhdl, INFO_LBL_PCIBR_ASIC_REV, NULL);
     /* Remove the character device associated with this bridge */
-    (void)hwgraph_edge_remove(pcibr_vhdl, EDGE_LBL_CONTROLLER, NULL);
+    hwgraph_edge_remove(pcibr_vhdl, EDGE_LBL_CONTROLLER, NULL);
     /* Remove the PCI bridge vertex */
-    (void)hwgraph_edge_remove(xconn, EDGE_LBL_PCI, NULL);
+    hwgraph_edge_remove(xconn, EDGE_LBL_PCI, NULL);
 
     return(0);
 }
@@ -1994,7 +1904,6 @@ pcibr_addr_pci_to_xio(vertex_hdl_t pconn
     iopaddr_t               mbase;	/* base of devio(x) mapped area on PCI */
     size_t                  msize;	/* size of devio(x) mapped area on PCI */
     size_t                  mmask;	/* addr bits stored in Device(x) */
-    char		    tmp_str[512];
 
     unsigned long           s;
 
@@ -2171,27 +2080,13 @@ pcibr_addr_pci_to_xio(vertex_hdl_t pconn
 		devreg &= ~BRIDGE_DEV_DEV_SWAP;
 
 	    if (pcibr_soft->bs_slot[win].bss_device != devreg) {
-		if ( IS_PIC_SOFT(pcibr_soft) ) {
-			bridge->b_device[win].reg = devreg;
-			pcibr_soft->bs_slot[win].bss_device = devreg;
-			bridge->b_wid_tflush;   /* wait until Bridge PIO complete */
-		}
-		else {
-			if (io_get_sh_swapper(NASID_GET(bridge))) {
-				BRIDGE_REG_SET32((&bridge->b_device[win].reg)) = __swab32(devreg);
-				pcibr_soft->bs_slot[win].bss_device = devreg;
-				BRIDGE_REG_GET32((&bridge->b_wid_tflush)); /* wait until Bridge PIO complete */
-			} else {
-				bridge->b_device[win].reg = devreg;
-				pcibr_soft->bs_slot[win].bss_device = devreg;
-				bridge->b_wid_tflush;   /* wait until Bridge PIO complete */
-			}
-		}
-
+		bridge->b_device[win].reg = devreg;
+		pcibr_soft->bs_slot[win].bss_device = devreg;
+		bridge->b_wid_tflush;   /* wait until Bridge PIO complete */
 #ifdef PCI_LATER
 		PCIBR_DEBUG((PCIBR_DEBUG_DEVREG, pconn_vhdl, 
-			    "pcibr_addr_pci_to_xio: Device(%d): %x\n",
-			    win, devreg, device_bits));
+			    "pcibr_addr_pci_to_xio: Device(%d): 0x%x\n",
+			    win, devreg));
 #endif
 	    }
 	    pcibr_soft->bs_slot[win].bss_devio.bssd_space = space;
@@ -2205,18 +2100,12 @@ pcibr_addr_pci_to_xio(vertex_hdl_t pconn
             if (bar != -1)
                 pcibr_info->f_window[bar].w_devio_index = win;
 
-	    /*
-	     * The kernel only allows functions to have so many variable args,
-	     * attempting to call PCIBR_DEBUG_ALWAYS() with more than 5 printk
-	     * arguments fails so sprintf() it into a temporary string.
-	     */
-	    if (pcibr_debug_mask & PCIBR_DEBUG_PIOMAP) {
-	        sprintf(tmp_str, "pcibr_addr_pci_to_xio: map to [%lx..%lx] for "
-		        "slot %d allocates DevIO(%d) Device(%d) set to %lx\n",
-		        (unsigned long)pci_addr, (unsigned long)(pci_addr + req_size - 1),
-		        (unsigned int)slot, win, win, (unsigned long)devreg);
-	        PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pconn_vhdl, "%s", tmp_str));
-	    }
+	    PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
+		    "pcibr_addr_pci_to_xio: map to space %s [0x%lx..0x%lx] "
+		    "for slot %d allocates DevIO(%d) Device(%d) set to %lx\n",
+		    pci_space[space], pci_addr, pci_addr + req_size - 1,
+		    slot, win, win, devreg));
+
 	    goto done;
 	}				/* endif DevIO(x) not pointed */
 	mbase = pcibr_soft->bs_slot[win].bss_devio.bssd_base;
@@ -2244,9 +2133,10 @@ pcibr_addr_pci_to_xio(vertex_hdl_t pconn
         if (bar != -1)
             pcibr_info->f_window[bar].w_devio_index = win;
 
-	if (pcibr_debug_mask & PCIBR_DEBUG_PIOMAP) {
-	    PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pconn_vhdl, "%s", tmp_str));
-	}
+	PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
+		"pcibr_addr_pci_to_xio: map to space %s [0x%lx..0x%lx] "
+		"for slot %d uses DevIO(%d)\n", pci_space[space],
+		pci_addr, pci_addr + req_size - 1, slot, win));
 	goto done;
     }
 
@@ -2271,9 +2161,9 @@ pcibr_addr_pci_to_xio(vertex_hdl_t pconn
 	} else if (IS_PIC_BUSNUM_SOFT(pcibr_soft, 1)) {	/* PIC bus 1 */
 		base = PICBRIDGE1_PCI_MEM32_BASE;
 		limit = PICBRIDGE1_PCI_MEM32_LIMIT;
-	} else {					/* Bridge/Xbridge */
-		base = BRIDGE_PCI_MEM32_BASE;
-		limit = BRIDGE_PCI_MEM32_LIMIT;
+	} else {
+		printk("pcibr_addr_pci_to_xio(): unknown bridge type");
+		return (iopaddr_t)0;
 	}
 
 	if ((pci_addr + base + req_size - 1) <= limit)
@@ -2287,9 +2177,9 @@ pcibr_addr_pci_to_xio(vertex_hdl_t pconn
 	} else if (IS_PIC_BUSNUM_SOFT(pcibr_soft, 1)) {	/* PIC bus 1 */
 		base = PICBRIDGE1_PCI_MEM64_BASE;
 		limit = PICBRIDGE1_PCI_MEM64_LIMIT;
-	} else {					/* Bridge/Xbridge */
-		base = BRIDGE_PCI_MEM64_BASE;
-		limit = BRIDGE_PCI_MEM64_LIMIT;
+	} else {
+		printk("pcibr_addr_pci_to_xio(): unknown bridge type");
+		return (iopaddr_t)0;
 	}
 
 	if ((pci_addr + base + req_size - 1) <= limit)
@@ -2300,20 +2190,7 @@ pcibr_addr_pci_to_xio(vertex_hdl_t pconn
 	/*
 	 * PIC bridges do not support big-window aliases into PCI I/O space
 	 */
-	if (IS_PIC_SOFT(pcibr_soft)) {
-		xio_addr = XIO_NOWHERE;
-		break;
-	}
-
-	/* Bridge Hardware Bug WAR #482741:
-	 * The 4G area that maps directly from
-	 * XIO space to PCI I/O space is busted
-	 * until Bridge Rev D.
-	 */
-	if ((pcibr_soft->bs_rev_num > BRIDGE_PART_REV_C) &&
-	    ((pci_addr + BRIDGE_PCI_IO_BASE + req_size - 1) <=
-	     BRIDGE_PCI_IO_LIMIT))
-	    xio_addr = pci_addr + BRIDGE_PCI_IO_BASE;
+	xio_addr = XIO_NOWHERE;
 	break;
     }
 
@@ -2340,41 +2217,29 @@ pcibr_addr_pci_to_xio(vertex_hdl_t pconn
 	if (bfn == bfo) {		/* we already match. */
 	    ;
 	} else if (bfo != 0) {		/* we have a conflict. */
-	    if (pcibr_debug_mask & PCIBR_DEBUG_PIOMAP) {
-	        PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pconn_vhdl, "%s", tmp_str));
-	    }
+	    PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
+		    "pcibr_addr_pci_to_xio: swap conflict in %s, "
+		    "was%s%s, want%s%s\n", pci_space[space],
+		    bfo & PCIIO_BYTE_STREAM ? " BYTE_STREAM" : "",
+		    bfo & PCIIO_WORD_VALUES ? " WORD_VALUES" : "",
+		    bfn & PCIIO_BYTE_STREAM ? " BYTE_STREAM" : "",
+		    bfn & PCIIO_WORD_VALUES ? " WORD_VALUES" : ""));
 	    xio_addr = XIO_NOWHERE;
 	} else {			/* OK to make the change. */
+    	    picreg_t             octl, nctl;
 	    swb = (space == PCIIO_SPACE_IO) ? BRIDGE_CTRL_IO_SWAP : BRIDGE_CTRL_MEM_SWAP;
-	    if ( IS_PIC_SOFT(pcibr_soft) ) {
-	    	picreg_t             octl, nctl;
-		octl = bridge->p_wid_control_64;
-		nctl = bst ? octl | (uint64_t)swb : octl & ((uint64_t)~swb);
+	    octl = bridge->p_wid_control_64;
+	    nctl = bst ? octl | (uint64_t)swb : octl & ((uint64_t)~swb);
 
-		if (octl != nctl)		/* make the change if any */
-			bridge->b_wid_control = nctl;
-	    }
-	    else {
-	    	picreg_t             octl, nctl;
-		if (io_get_sh_swapper(NASID_GET(bridge))) {
-			octl = BRIDGE_REG_GET32((&bridge->b_wid_control));
-			nctl = bst ? octl | swb : octl & ~swb;
-
-			if (octl != nctl)           /* make the change if any */
-				BRIDGE_REG_SET32((&bridge->b_wid_control)) = __swab32(nctl);
-		} else {
-			octl = bridge->b_wid_control;
-			nctl = bst ? octl | swb : octl & ~swb;
-
-			if (octl != nctl)           /* make the change if any */
-				bridge->b_wid_control = nctl;
-		}
-	    }
+	    if (octl != nctl)		/* make the change if any */
+		bridge->b_wid_control = nctl;
 	    *bfp = bfn;			/* record the assignment */
 
-	    if (pcibr_debug_mask & PCIBR_DEBUG_PIOMAP) {
-	        PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pconn_vhdl, "%s", tmp_str));
-	    }
+	    PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
+		    "pcibr_addr_pci_to_xio: swap for %s set to%s%s\n",
+		    pci_space[space],
+		    bfn & PCIIO_BYTE_STREAM ? " BYTE_STREAM" : "",
+		    bfn & PCIIO_WORD_VALUES ? " WORD_VALUES" : ""));
 	}
     }
   done:
@@ -2443,7 +2308,13 @@ pcibr_piomap_alloc(vertex_hdl_t pconn_vh
 	mapptr = NULL;
     else {
 	pcibr_unlock(pcibr_soft, s);
-	NEW(pcibr_piomap);
+	pcibr_piomap = kmalloc(sizeof (*(pcibr_piomap)), GFP_KERNEL);
+	if ( !pcibr_piomap ) {
+		PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
+		    	"pcibr_piomap_alloc: malloc fails\n"));
+		return NULL;
+	}
+	memset(pcibr_piomap, 0, sizeof (*(pcibr_piomap)));
     }
 
     pcibr_piomap->bp_dev = pconn_vhdl;
@@ -2480,7 +2351,7 @@ pcibr_piomap_alloc(vertex_hdl_t pconn_vh
     }
     
     PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
-		"pcibr_piomap_alloc: map=0x%x\n", pcibr_piomap));
+		"pcibr_piomap_alloc: map=0x%lx\n", pcibr_piomap));
 
     return pcibr_piomap;
 }
@@ -2490,7 +2361,7 @@ void
 pcibr_piomap_free(pcibr_piomap_t pcibr_piomap)
 {
     PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pcibr_piomap->bp_dev,
-		"pcibr_piomap_free: map=0x%x\n", pcibr_piomap));
+		"pcibr_piomap_free: map=0x%lx\n", pcibr_piomap));
 
     xtalk_piomap_free(pcibr_piomap->bp_xtalk_pio);
     pcibr_piomap->bp_xtalk_pio = 0;
@@ -2509,7 +2380,7 @@ pcibr_piomap_addr(pcibr_piomap_t pcibr_p
 			     pci_addr - pcibr_piomap->bp_pciaddr,
 			     req_size);
     PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pcibr_piomap->bp_dev,
-                "pcibr_piomap_free: map=0x%x, addr=0x%x\n", 
+                "pcibr_piomap_addr: map=0x%lx, addr=0x%lx\n", 
 		pcibr_piomap, addr));
 
     return(addr);
@@ -2520,7 +2391,7 @@ void
 pcibr_piomap_done(pcibr_piomap_t pcibr_piomap)
 {
     PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pcibr_piomap->bp_dev,
-		"pcibr_piomap_done: map=0x%x\n", pcibr_piomap));
+		"pcibr_piomap_done: map=0x%lx\n", pcibr_piomap));
     xtalk_piomap_done(pcibr_piomap->bp_xtalk_pio);
 }
 
@@ -2551,7 +2422,7 @@ pcibr_piotrans_addr(vertex_hdl_t pconn_v
 
     addr = xtalk_piotrans_addr(xconn_vhdl, 0, xio_addr, req_size, flags & PIOMAP_FLAGS);
     PCIBR_DEBUG((PCIBR_DEBUG_PIODIR, pconn_vhdl,
-		"pcibr_piotrans_addr: xio_addr=0x%x, addr=0x%x\n",
+		"pcibr_piotrans_addr: xio_addr=0x%lx, addr=0x%lx\n",
 		xio_addr, addr));
     return(addr);
 }
@@ -2586,7 +2457,7 @@ pcibr_piospace_alloc(vertex_hdl_t pconn_
     /*
      * Check for proper alignment
      */
-    ASSERT(alignment >= NBPP);
+    ASSERT(alignment >= PAGE_SIZE);
     ASSERT((alignment & (alignment - 1)) == 0);
 
     align_mask = alignment - 1;
@@ -2595,7 +2466,8 @@ pcibr_piospace_alloc(vertex_hdl_t pconn_
     /*
      * First look if a previously allocated chunk exists.
      */
-    if ((piosp = pcibr_info->f_piospace)) {
+    piosp = pcibr_info->f_piospace;
+    if (piosp) {
 	/*
 	 * Look through the list for a right sized free chunk.
 	 */
@@ -2647,11 +2519,18 @@ pcibr_piospace_alloc(vertex_hdl_t pconn_
     if (!start_addr) {
 	pcibr_unlock(pcibr_soft, s);
 	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
-		    "pcibr_piospace_alloc: request 0x%x to big\n", req_size));
+		    "pcibr_piospace_alloc: request 0x%lx to big\n", req_size));
 	return 0;
     }
 
-    NEW(piosp);
+    piosp = kmalloc(sizeof (*(piosp)), GFP_KERNEL);
+    if ( !piosp ) {
+	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
+		    "pcibr_piospace_alloc: malloc fails\n"));
+	return 0;
+    }
+    memset(piosp, 0, sizeof (*(piosp)));
+
     piosp->free = 0;
     piosp->space = space;
     piosp->start = start_addr;
@@ -2662,7 +2541,7 @@ pcibr_piospace_alloc(vertex_hdl_t pconn_
     pcibr_unlock(pcibr_soft, s);
 
     PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
-		"pcibr_piospace_alloc: piosp=0x%x\n", piosp));
+		"pcibr_piospace_alloc: piosp=0x%lx\n", piosp));
 
     return start_addr;
 }
@@ -2675,6 +2554,7 @@ pcibr_piospace_free(vertex_hdl_t pconn_v
 		    size_t req_size)
 {
     pcibr_info_t            pcibr_info = pcibr_info_get(pconn_vhdl);
+    pcibr_soft_t            pcibr_soft = (pcibr_soft_t) pcibr_info->f_mfast;
     pciio_piospace_t        piosp;
     unsigned long           s;
     char                    name[1024];
@@ -2718,7 +2598,7 @@ pcibr_piospace_free(vertex_hdl_t pconn_v
     pcibr_unlock(pcibr_soft, s);
 
     PCIBR_DEBUG((PCIBR_DEBUG_PIOMAP, pconn_vhdl,
-		"pcibr_piospace_free: piosp=0x%x\n", piosp));
+		"pcibr_piospace_free: piosp=0x%lx\n", piosp));
     return;
 }
 
@@ -2777,12 +2657,10 @@ pcibr_flags_to_d64(unsigned flags, pcibr
 	attributes &= ~PCI64_ATTR_PREF;
 
     /* the swap bit is in the address attributes for xbridge */
-    if (IS_XBRIDGE_OR_PIC_SOFT(pcibr_soft)) {
-    	if (flags & PCIIO_BYTE_STREAM)
-        	attributes |= PCI64_ATTR_SWAP;
-    	if (flags & PCIIO_WORD_VALUES)
-        	attributes &= ~PCI64_ATTR_SWAP;
-    }
+    if (flags & PCIIO_BYTE_STREAM)
+       	attributes |= PCI64_ATTR_SWAP;
+    if (flags & PCIIO_WORD_VALUES)
+       	attributes &= ~PCI64_ATTR_SWAP;
 
     /* Provider-specific flags
      */
@@ -2832,6 +2710,7 @@ pcibr_dmamap_alloc(vertex_hdl_t pconn_vh
     int                     ate_count;
     int                     ate_index;
     int			    vchan = VCHAN0;
+    unsigned long	    s;
 
     /* merge in forced flags */
     flags |= pcibr_soft->bs_dma_flags;
@@ -2840,7 +2719,9 @@ pcibr_dmamap_alloc(vertex_hdl_t pconn_vh
      * On SNIA64, these maps are pre-allocated because pcibr_dmamap_alloc()
      * can be called within an interrupt thread.
      */
+    s = pcibr_lock(pcibr_soft);
     pcibr_dmamap = (pcibr_dmamap_t)get_free_pciio_dmamap(pcibr_soft->bs_vhdl);
+    pcibr_unlock(pcibr_soft, s);
 
     if (!pcibr_dmamap)
 	return 0;
@@ -2899,16 +2780,19 @@ pcibr_dmamap_alloc(vertex_hdl_t pconn_vh
 		}
 	    }
 	    PCIBR_DEBUG((PCIBR_DEBUG_DMAMAP | PCIBR_DEBUG_DMADIR, pconn_vhdl,
-		 	"pcibr_dmamap_alloc: using direct64, map=0x%x\n",
+		 	"pcibr_dmamap_alloc: using direct64, map=0x%lx\n",
 			pcibr_dmamap));
 	    return pcibr_dmamap;
 	}
 	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DMAMAP | PCIBR_DEBUG_DMADIR, pconn_vhdl,
 		    "pcibr_dmamap_alloc: unable to use direct64\n"));
 
-	/* PIC only supports 64-bit direct mapping in PCI-X mode. */
+	/* PIC in PCI-X mode only supports 64-bit direct mapping so
+	 * don't fall thru and try 32-bit direct mapping or 32-bit
+	 * page mapping
+	 */
 	if (IS_PCIX(pcibr_soft)) {
-	    DEL(pcibr_dmamap);
+	    kfree(pcibr_dmamap);
 	    return 0;
 	}
 
@@ -2927,7 +2811,7 @@ pcibr_dmamap_alloc(vertex_hdl_t pconn_vh
 	     * is outside the direct32 range.
 	     */
 	    PCIBR_DEBUG((PCIBR_DEBUG_DMAMAP | PCIBR_DEBUG_DMADIR, pconn_vhdl,
-			"pcibr_dmamap_alloc: using direct32, map=0x%x\n", 
+			"pcibr_dmamap_alloc: using direct32, map=0x%lx\n", 
 			pcibr_dmamap));
 	    pcibr_dmamap->bd_flags = flags;
 	    pcibr_dmamap->bd_xio_addr = pcibr_soft->bs_dir_xbase;
@@ -2971,29 +2855,25 @@ pcibr_dmamap_alloc(vertex_hdl_t pconn_vh
 
 	    PCIBR_DEBUG((PCIBR_DEBUG_DMAMAP, pconn_vhdl,
 			"pcibr_dmamap_alloc: using PMU, ate_index=%d, "
-			"pcibr_dmamap=0x%x\n", ate_index, pcibr_dmamap));
+			"pcibr_dmamap=0x%lx\n", ate_index, pcibr_dmamap));
 
 	    ate_proto = pcibr_flags_to_ate(flags);
 
 	    pcibr_dmamap->bd_flags = flags;
 	    pcibr_dmamap->bd_pci_addr =
 		PCI32_MAPPED_BASE + IOPGSIZE * ate_index;
+
+	    if (flags & PCIIO_BYTE_STREAM)
+		    ATE_SWAP_ON(pcibr_dmamap->bd_pci_addr);
 	    /*
-	     * for xbridge the byte-swap bit == bit 29 of PCI address
+	     * If swap was set in bss_device in pcibr_endian_set()
+	     * we need to change the address bit.
 	     */
-	    if (IS_XBRIDGE_OR_PIC_SOFT(pcibr_soft)) {
-		    if (flags & PCIIO_BYTE_STREAM)
-			    ATE_SWAP_ON(pcibr_dmamap->bd_pci_addr);
-		    /*
-		     * If swap was set in bss_device in pcibr_endian_set()
-		     * we need to change the address bit.
-		     */
-		    if (pcibr_soft->bs_slot[slot].bss_device & 
-							BRIDGE_DEV_SWAP_PMU)
-			    ATE_SWAP_ON(pcibr_dmamap->bd_pci_addr);
-		    if (flags & PCIIO_WORD_VALUES)
-			    ATE_SWAP_OFF(pcibr_dmamap->bd_pci_addr);
-	    }
+	    if (pcibr_soft->bs_slot[slot].bss_device & 
+						BRIDGE_DEV_SWAP_PMU)
+		    ATE_SWAP_ON(pcibr_dmamap->bd_pci_addr);
+	    if (flags & PCIIO_WORD_VALUES)
+		    ATE_SWAP_OFF(pcibr_dmamap->bd_pci_addr);
 	    pcibr_dmamap->bd_xio_addr = 0;
 	    pcibr_dmamap->bd_ate_ptr = pcibr_ate_addr(pcibr_soft, ate_index);
 	    pcibr_dmamap->bd_ate_index = ate_index;
@@ -3014,32 +2894,6 @@ pcibr_dmamap_alloc(vertex_hdl_t pconn_vh
 					       min_rrbs - have_rrbs);
 		}
 	    }
-	    if (ate_index >= pcibr_soft->bs_int_ate_size && 
-				!IS_XBRIDGE_OR_PIC_SOFT(pcibr_soft)) {
-		bridge_t               *bridge = pcibr_soft->bs_base;
-		volatile unsigned      *cmd_regp;
-		unsigned                cmd_reg;
-		unsigned long           s;
-
-		pcibr_dmamap->bd_flags |= PCIBR_DMAMAP_SSRAM;
-
-		s = pcibr_lock(pcibr_soft);
-		cmd_regp = pcibr_slot_config_addr(bridge, slot, 
-						PCI_CFG_COMMAND/4);
-		if ( IS_PIC_SOFT(pcibr_soft) ) {
-			cmd_reg = pcibr_slot_config_get(bridge, slot, PCI_CFG_COMMAND/4);
-		}
-		else {
-			if (io_get_sh_swapper(NASID_GET(bridge))) {
-				BRIDGE_REG_SET32((&cmd_reg)) = __swab32(*cmd_regp);
-			} else {
-				cmd_reg = pcibr_slot_config_get(bridge, slot, PCI_CFG_COMMAND/4);
-			}
-		}
-		pcibr_soft->bs_slot[slot].bss_cmd_pointer = cmd_regp;
-		pcibr_soft->bs_slot[slot].bss_cmd_shadow = cmd_reg;
-		pcibr_unlock(pcibr_soft, s);
-	    }
 	    return pcibr_dmamap;
 	}
 	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DMAMAP, pconn_vhdl,
@@ -3089,7 +2943,7 @@ pcibr_dmamap_free(pcibr_dmamap_t pcibr_d
     }
 
     PCIBR_DEBUG((PCIBR_DEBUG_DMAMAP, pcibr_dmamap->bd_dev,
-		"pcibr_dmamap_free: pcibr_dmamap=0x%x\n", pcibr_dmamap));
+		"pcibr_dmamap_free: pcibr_dmamap=0x%lx\n", pcibr_dmamap));
 
     free_pciio_dmamap(pcibr_dmamap);
 }
@@ -3132,16 +2986,8 @@ pcibr_addr_xio_to_pci(pcibr_soft_t soft,
 	    return pci_addr;
     	}
     } else {
-    if ((xio_addr >= BRIDGE_PCI_MEM32_BASE) &&
-	(xio_lim <= BRIDGE_PCI_MEM32_LIMIT)) {
-	pci_addr = xio_addr - BRIDGE_PCI_MEM32_BASE;
-	return pci_addr;
-    }
-    if ((xio_addr >= BRIDGE_PCI_MEM64_BASE) &&
-	(xio_lim <= BRIDGE_PCI_MEM64_LIMIT)) {
-	pci_addr = xio_addr - BRIDGE_PCI_MEM64_BASE;
-	return pci_addr;
-    }
+	printk("pcibr_addr_xio_to_pci(): unknown bridge type");
+	return (iopaddr_t)0;
     }
     for (slot = soft->bs_min_slot; slot < PCIBR_NUM_SLOTS(soft); ++slot)
 	if ((xio_addr >= PCIBR_BRIDGE_DEVIO(soft, slot)) &&
@@ -3215,8 +3061,8 @@ pcibr_dmamap_addr(pcibr_dmamap_t pcibr_d
 
 	PCIBR_DEBUG((PCIBR_DEBUG_DMAMAP | PCIBR_DEBUG_DMADIR, 
 		    pcibr_dmamap->bd_dev,
-		    "pcibr_dmamap_addr: (direct64): wanted paddr [0x%x..0x%x] "
-		    "XIO port 0x%x offset 0x%x, returning PCI 0x%x\n",
+		    "pcibr_dmamap_addr: (direct64): wanted paddr [0x%lx..0x%lx] "
+		    "XIO port 0x%x offset 0x%lx, returning PCI 0x%lx\n",
 		    paddr, paddr + req_size - 1, xio_port, xio_addr, pci_addr));
 
     } else if (flags & PCIIO_FIXED) {
@@ -3240,8 +3086,8 @@ pcibr_dmamap_addr(pcibr_dmamap_t pcibr_d
 
 	PCIBR_DEBUG((PCIBR_DEBUG_DMAMAP | PCIBR_DEBUG_DMADIR, 
 		    pcibr_dmamap->bd_dev,
-		    "pcibr_dmamap_addr (direct32): wanted paddr [0x%x..0x%x] "
-		    "XIO port 0x%x offset 0x%x, returning PCI 0x%x\n",
+		    "pcibr_dmamap_addr (direct32): wanted paddr [0x%lx..0x%lx] "
+		    "XIO port 0x%x offset 0x%lx, returning PCI 0x%lx\n",
 		    paddr, paddr + req_size - 1, xio_port, xio_addr, pci_addr));
 
     } else {
@@ -3285,19 +3131,10 @@ pcibr_dmamap_addr(pcibr_dmamap_t pcibr_d
 		ATE_FREEZE();
 		ATE_WRITE();
 		ATE_THAW();
-		if ( IS_PIC_SOFT(pcibr_soft) ) {
-			bridge->b_wid_tflush;	/* wait until Bridge PIO complete */
-		}
-		else {
-			if (io_get_sh_swapper(NASID_GET(bridge))) {
-				BRIDGE_REG_GET32((&bridge->b_wid_tflush));
-			} else {
-				bridge->b_wid_tflush;
-			}
-		}
+		bridge->b_wid_tflush;	/* wait until Bridge PIO complete */
 		PCIBR_DEBUG((PCIBR_DEBUG_DMAMAP, pcibr_dmamap->bd_dev,
 			    "pcibr_dmamap_addr (PMU) : wanted paddr "
-			    "[0x%x..0x%x] returning PCI 0x%x\n", 
+			    "[0x%lx..0x%lx] returning PCI 0x%lx\n", 
 			    paddr, paddr + req_size - 1, pci_addr));
 
 	} else {
@@ -3311,7 +3148,7 @@ pcibr_dmamap_addr(pcibr_dmamap_t pcibr_d
 		 */
 		PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DMAMAP, pcibr_dmamap->bd_dev, 
 		            "pcibr_dmamap_addr (PMU) : wanted paddr "
-			    "[0x%x..0x%x] ate_count 0x%x bd_ate_count 0x%x "
+			    "[0x%lx..0x%lx] ate_count 0x%x bd_ate_count 0x%x "
 			    "ATE's required > number allocated\n",
 			     paddr, paddr + req_size - 1,
 			     ate_count, pcibr_dmamap->bd_ate_count));
@@ -3342,7 +3179,7 @@ pcibr_dmamap_done(pcibr_dmamap_t pcibr_d
     xtalk_dmamap_done(pcibr_dmamap->bd_xtalk);
 
     PCIBR_DEBUG((PCIBR_DEBUG_DMAMAP, pcibr_dmamap->bd_dev,
-		"pcibr_dmamap_done: pcibr_dmamap=0x%x\n", pcibr_dmamap));
+		"pcibr_dmamap_done: pcibr_dmamap=0x%lx\n", pcibr_dmamap));
 }
 
 
@@ -3393,8 +3230,8 @@ pcibr_dmatrans_addr(vertex_hdl_t pconn_v
 				   flags & DMAMAP_FLAGS);
     if (!xio_addr) {
 	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-		    "pcibr_dmatrans_addr: wanted paddr [0x%x..0x%x], "
-		    "xtalk_dmatrans_addr failed with 0x%x\n",
+		    "pcibr_dmatrans_addr: wanted paddr [0x%lx..0x%lx], "
+		    "xtalk_dmatrans_addr failed with 0x%lx\n",
 		    paddr, paddr + req_size - 1, xio_addr));
 	return 0;
     }
@@ -3404,7 +3241,7 @@ pcibr_dmatrans_addr(vertex_hdl_t pconn_v
     if (XIO_PACKED(xio_addr)) {
 	if (xio_addr == XIO_NOWHERE) {
 	    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-		        "pcibr_dmatrans_addr: wanted paddr [0x%x..0x%x], "
+		        "pcibr_dmatrans_addr: wanted paddr [0x%lx..0x%lx], "
 		        "xtalk_dmatrans_addr failed with XIO_NOWHERE\n",
 		        paddr, paddr + req_size - 1));
 	    return 0;
@@ -3425,8 +3262,8 @@ pcibr_dmatrans_addr(vertex_hdl_t pconn_v
     if (xio_port == pcibr_soft->bs_xid) {
 	pci_addr = pcibr_addr_xio_to_pci(pcibr_soft, xio_addr, req_size);
         PCIBR_DEBUG((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-		    "pcibr_dmatrans_addr:  wanted paddr [0x%x..0x%x], "
-		    "xio_port=0x%x, pci_addr=0x%x\n",
+		    "pcibr_dmatrans_addr:  wanted paddr [0x%lx..0x%lx], "
+		    "xio_port=0x%x, pci_addr=0x%lx\n",
 		    paddr, paddr + req_size - 1, xio_port, pci_addr));
 	return pci_addr;
     }
@@ -3480,19 +3317,16 @@ pcibr_dmatrans_addr(vertex_hdl_t pconn_v
 					       min_rrbs - have_rrbs);
 		}
 	    }
-#if HWG_PERF_CHECK
-	    if (xio_addr != 0x20000000)
-#endif
-		PCIBR_DEBUG((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-			    "pcibr_dmatrans_addr:  wanted paddr [0x%x..0x%x], "
-			    "xio_port=0x%x, direct64: pci_addr=0x%x, "
-			    "new flags: 0x%x\n", paddr, paddr + req_size - 1,
-			    xio_addr, pci_addr, (uint64_t) flags));
+	    PCIBR_DEBUG((PCIBR_DEBUG_DMADIR, pconn_vhdl,
+			"pcibr_dmatrans_addr:  wanted paddr [0x%lx..0x%lx], "
+			"xio_port=0x%x, direct64: pci_addr=0x%lx, "
+			"new flags: 0x%x\n", paddr, paddr + req_size - 1,
+			xio_addr, pci_addr, (uint64_t) flags));
 	    return (pci_addr);
 	}
 
 	PCIBR_DEBUG((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-		    "pcibr_dmatrans_addr:  wanted paddr [0x%x..0x%x], "
+		    "pcibr_dmatrans_addr:  wanted paddr [0x%lx..0x%lx], "
 		    "xio_port=0x%x, Unable to set direct64 Device(x) bits\n",
 		    paddr, paddr + req_size - 1, xio_addr));
 
@@ -3503,6 +3337,11 @@ pcibr_dmatrans_addr(vertex_hdl_t pconn_v
 
 	/* our flags conflict with Device(x). try direct32*/
 	flags = flags & ~(PCIIO_DMA_A64 | PCIBR_VCHAN0);
+    } else {
+	/* BUS in PCI-X mode only supports 64-bit direct mapping */
+	if (IS_PCIX(pcibr_soft)) {
+	    return 0;
+	}
     }
     /* Try to satisfy the request with the 32-bit direct
      * map. This can fail if the configuration bits in
@@ -3521,7 +3360,7 @@ pcibr_dmatrans_addr(vertex_hdl_t pconn_v
 	    (endoff > map_size)) {
 
 	    PCIBR_DEBUG((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-			"pcibr_dmatrans_addr:  wanted paddr [0x%x..0x%x], "
+			"pcibr_dmatrans_addr:  wanted paddr [0x%lx..0x%lx], "
 			"xio_port=0x%x, xio region outside direct32 target\n",
 			paddr, paddr + req_size - 1, xio_addr));
 	} else {
@@ -3532,8 +3371,8 @@ pcibr_dmatrans_addr(vertex_hdl_t pconn_v
 		pci_addr |= offset;
 
 		PCIBR_DEBUG((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-                            "pcibr_dmatrans_addr:  wanted paddr [0x%x..0x%x], "
-                            "xio_port=0x%x, direct32: pci_addr=0x%x\n",
+                            "pcibr_dmatrans_addr:  wanted paddr [0x%lx..0x%lx],"
+                            " xio_port=0x%x, direct32: pci_addr=0x%lx\n",
                             paddr, paddr + req_size - 1, xio_addr, pci_addr));
 
 		return (pci_addr);
@@ -3559,12 +3398,9 @@ pcibr_dmatrans_addr(vertex_hdl_t pconn_v
 						   vchan, min_rrbs - have_rrbs);
 		    }
 		}
-#if HWG_PERF_CHECK
-		if (xio_addr != 0x20000000)
-#endif
-                    PCIBR_DEBUG((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-                            "pcibr_dmatrans_addr:  wanted paddr [0x%x..0x%x], "
-                            "xio_port=0x%x, direct32: pci_addr=0x%x, "
+		PCIBR_DEBUG((PCIBR_DEBUG_DMADIR, pconn_vhdl,
+                            "pcibr_dmatrans_addr:  wanted paddr [0x%lx..0x%lx],"
+                            " xio_port=0x%x, direct32: pci_addr=0x%lx, "
 			    "new flags: 0x%x\n", paddr, paddr + req_size - 1,
 			    xio_addr, pci_addr, (uint64_t) flags));
 
@@ -3573,14 +3409,14 @@ pcibr_dmatrans_addr(vertex_hdl_t pconn_v
 	    /* our flags conflict with Device(x).
 	     */
 	    PCIBR_DEBUG((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-                    "pcibr_dmatrans_addr:  wanted paddr [0x%x..0x%x], "
+                    "pcibr_dmatrans_addr:  wanted paddr [0x%lx..0x%lx], "
                     "xio_port=0x%x, Unable to set direct32 Device(x) bits\n",
                     paddr, paddr + req_size - 1, xio_port));
 	}
     }
 
     PCIBR_DEBUG((PCIBR_DEBUG_DMADIR, pconn_vhdl,
-		"pcibr_dmatrans_addr:  wanted paddr [0x%x..0x%x], "
+		"pcibr_dmatrans_addr:  wanted paddr [0x%lx..0x%lx], "
 		"xio_port=0x%x, No acceptable PCI address found\n",
 		paddr, paddr + req_size - 1, xio_port));
 
@@ -3680,22 +3516,9 @@ pcibr_endian_set(vertex_hdl_t pconn_vhdl
     if (pcibr_soft->bs_slot[pciio_slot].bss_device != devreg) {
 	bridge_t               *bridge = pcibr_soft->bs_base;
 
-	if ( IS_PIC_SOFT(pcibr_soft) ) {
-		bridge->b_device[pciio_slot].reg = devreg;
-		pcibr_soft->bs_slot[pciio_slot].bss_device = devreg;
-		bridge->b_wid_tflush;		/* wait until Bridge PIO complete */
-	}
-	else {
-		if (io_get_sh_swapper(NASID_GET(bridge))) {
-			BRIDGE_REG_SET32((&bridge->b_device[pciio_slot].reg)) = __swab32(devreg);
-			pcibr_soft->bs_slot[pciio_slot].bss_device = devreg;
-			BRIDGE_REG_GET32((&bridge->b_wid_tflush));/* wait until Bridge PIO complete */
-		} else {
-			bridge->b_device[pciio_slot].reg = devreg;
-			pcibr_soft->bs_slot[pciio_slot].bss_device = devreg;
-			bridge->b_wid_tflush;           /* wait until Bridge PIO complete */
-		}
-	}
+	bridge->b_device[pciio_slot].reg = devreg;
+	pcibr_soft->bs_slot[pciio_slot].bss_device = devreg;
+	bridge->b_wid_tflush;		/* wait until Bridge PIO complete */
     }
     pcibr_unlock(pcibr_soft, s);
 
@@ -3767,22 +3590,9 @@ pcibr_priority_bits_set(pcibr_soft_t pci
     if (pcibr_soft->bs_slot[pciio_slot].bss_device != devreg) {
 	bridge_t               *bridge = pcibr_soft->bs_base;
 
-	if ( IS_PIC_SOFT(pcibr_soft) ) {
-		bridge->b_device[pciio_slot].reg = devreg;
-		pcibr_soft->bs_slot[pciio_slot].bss_device = devreg;
-		bridge->b_wid_tflush;		/* wait until Bridge PIO complete */
-	}
-	else {
-		if (io_get_sh_swapper(NASID_GET(bridge))) {
-			BRIDGE_REG_SET32((&bridge->b_device[pciio_slot].reg)) = __swab32(devreg);
-			pcibr_soft->bs_slot[pciio_slot].bss_device = devreg;
-			BRIDGE_REG_GET32((&bridge->b_wid_tflush));/* wait until Bridge PIO complete */
-		} else {
-			bridge->b_device[pciio_slot].reg = devreg;
-			pcibr_soft->bs_slot[pciio_slot].bss_device = devreg;
-			bridge->b_wid_tflush;           /* wait until Bridge PIO complete */
-		}
-	}
+	bridge->b_device[pciio_slot].reg = devreg;
+	pcibr_soft->bs_slot[pciio_slot].bss_device = devreg;
+	bridge->b_wid_tflush;		/* wait until Bridge PIO complete */
     }
     pcibr_unlock(pcibr_soft, s);
 
@@ -3865,25 +3675,15 @@ pcibr_device_flags_set(vertex_hdl_t pcon
 	if (pcibr_soft->bs_slot[pciio_slot].bss_device != devreg) {
 	    bridge_t               *bridge = pcibr_soft->bs_base;
 
-	    if ( IS_PIC_SOFT(pcibr_soft) ) {
-		bridge->b_device[pciio_slot].reg = devreg;
-		pcibr_soft->bs_slot[pciio_slot].bss_device = devreg;
-		bridge->b_wid_tflush;	/* wait until Bridge PIO complete */
-	    }
-	    else {
-		if (io_get_sh_swapper(NASID_GET(bridge))) {
-			BRIDGE_REG_SET32((&bridge->b_device[pciio_slot].reg)) = __swab32(devreg);
-			pcibr_soft->bs_slot[pciio_slot].bss_device = devreg;
-			BRIDGE_REG_GET32((&bridge->b_wid_tflush));/* wait until Bridge PIO complete */
-		} else {
-			bridge->b_device[pciio_slot].reg = devreg;
-			pcibr_soft->bs_slot[pciio_slot].bss_device = devreg;
-			bridge->b_wid_tflush;       /* wait until Bridge PIO complete */
-		}
-	    }
+	    bridge->b_device[pciio_slot].reg = devreg;
+	    pcibr_soft->bs_slot[pciio_slot].bss_device = devreg;
+	    bridge->b_wid_tflush;	/* wait until Bridge PIO complete */
 	}
 	pcibr_unlock(pcibr_soft, s);
-	printk("pcibr_device_flags_set: Device(%d): %x\n", pciio_slot, devreg);
+
+	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DEVREG, pconn_vhdl,
+		    "pcibr_device_flags_set: Device(%d): 0x%x\n",
+		    pciio_slot, devreg));
     }
     return (1);
 }
@@ -3967,25 +3767,12 @@ pciio_provider_t        pcibr_provider =
     (pciio_priority_set_f *) pcibr_priority_set,
     (pciio_config_get_f *) pcibr_config_get,
     (pciio_config_set_f *) pcibr_config_set,
-    (pciio_error_devenable_f *) 0,
     (pciio_error_extract_f *) 0,
     (pciio_driver_reg_callback_f *) 0,
     (pciio_driver_unreg_callback_f *) 0,
     (pciio_device_unregister_f 	*) pcibr_device_unregister,
-    (pciio_dma_enabled_f		*) pcibr_dma_enabled,
 };
 
-int
-pcibr_dma_enabled(vertex_hdl_t pconn_vhdl)
-{
-    pciio_info_t            pciio_info = pciio_info_get(pconn_vhdl);
-    pcibr_soft_t            pcibr_soft = (pcibr_soft_t) pciio_info_mfast_get(pciio_info);
-	
-
-    return xtalk_dma_enabled(pcibr_soft->bs_conn);
-}
-
-
 /*
  * pcibr_debug() is used to print pcibr debug messages to the console.  A
  * user enables tracing by setting the following global variables:
@@ -4020,23 +3807,26 @@ pcibr_debug(uint32_t type, vertex_hdl_t 
                 if (strcmp(module, pcibr_debug_module)) {
 		    /* use a copy */
                     (void)strcpy(copy_of_hwpath, hwpath);
-                    cp = strstr(copy_of_hwpath, "/module/");
+		    cp = strstr(copy_of_hwpath, "/" EDGE_LBL_MODULE "/");
                     if (cp) {
-                        cp += strlen("/module");
-                        module = strsep(&cp, "/");
+                        cp += strlen("/" EDGE_LBL_MODULE "/");
+			module = strsep(&cp, "/");
                     }
                 }
                 if (pcibr_debug_widget != -1) {
-                    cp = strstr(hwpath, "/xtalk/");
+		    cp = strstr(hwpath, "/" EDGE_LBL_XTALK "/");
                     if (cp) {
-                        cp += strlen("/xtalk/");
+			cp += strlen("/" EDGE_LBL_XTALK "/");
                         widget = simple_strtoul(cp, NULL, 0);
                     }
                 }
                 if (pcibr_debug_slot != -1) {
-                    cp = strstr(hwpath, "/pci/");
+		    cp = strstr(hwpath, "/" EDGE_LBL_PCIX_0 "/");
+		    if (!cp) {
+			cp = strstr(hwpath, "/" EDGE_LBL_PCIX_1 "/");
+		    }
                     if (cp) {
-                        cp += strlen("/pci/");
+                        cp += strlen("/" EDGE_LBL_PCIX_0 "/");
                         slot = simple_strtoul(cp, NULL, 0);
                     }
                 }
diff -puN arch/ia64/sn/io/sn2/pcibr/pcibr_error.c~linus arch/ia64/sn/io/sn2/pcibr/pcibr_error.c
--- 25/arch/ia64/sn/io/sn2/pcibr/pcibr_error.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/pcibr/pcibr_error.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
 /*
- *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -8,26 +7,15 @@
  */
 
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/module.h>
+#include <linux/interrupt.h>
 #include <asm/sn/sgi.h>
-#include <asm/sn/sn_cpuid.h>
 #include <asm/sn/addrs.h>
-#include <asm/sn/arch.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/pci/bridge.h>
 #include <asm/sn/pci/pciio.h>
 #include <asm/sn/pci/pcibr.h>
 #include <asm/sn/pci/pcibr_private.h>
 #include <asm/sn/pci/pci_defs.h>
-#include <asm/sn/prio.h>
-#include <asm/sn/xtalk/xbow.h>
-#include <asm/sn/io.h>
-#include <asm/sn/sn_private.h>
+
 
 extern int	hubii_check_widget_disabled(nasid_t, int);
 
@@ -43,12 +31,9 @@ extern int	hubii_check_widget_disabled(n
 #define BRIDGE_PIOERR_TIMEOUT	40	/* Timeout in debug mode  */
 #endif
 #else
-#define BRIDGE_PIOERR_TIMEOUT	1	/* Timeout in non-debug mode                            */
+#define BRIDGE_PIOERR_TIMEOUT	1	/* Timeout in non-debug mode */
 #endif
 
-/* PIC has 64bit interrupt error registers, but BRIDGE has 32bit registers.
- * Thus 'bridge_errors_to_dump needs' to default to the larger of the two.
- */
 #ifdef  DEBUG
 #ifdef ERROR_DEBUG
 uint64_t bridge_errors_to_dump = ~BRIDGE_ISR_INT_MSK;
@@ -62,7 +47,29 @@ uint64_t bridge_errors_to_dump = BRIDGE_
 
 int                     pcibr_llp_control_war_cnt; /* PCIBR_LLP_CONTROL_WAR */
 
-static struct reg_values xio_cmd_pactyp[] =
+/*
+ * register values
+ * map between numeric values and symbolic values
+ */
+struct reg_values {
+	unsigned long long rv_value;
+	char *rv_name;
+};
+
+/*
+ * register descriptors are used for formatted prints of register values
+ * rd_mask and rd_shift must be defined, other entries may be null
+ */
+struct reg_desc {
+	unsigned long long rd_mask;	/* mask to extract field */
+	int rd_shift;		/* shift for extracted value, - >>, + << */
+	char *rd_name;		/* field name */
+	char *rd_format;	/* format to print field */
+	struct reg_values *rd_values;	/* symbolic names of values */
+};
+
+/* Crosstalk Packet Types */
+static struct reg_values xtalk_cmd_pactyp[] =
 {
     {0x0, "RdReq"},
     {0x1, "RdResp"},
@@ -83,11 +90,11 @@ static struct reg_values xio_cmd_pactyp[
     {0}
 };
 
-static struct reg_desc   xio_cmd_bits[] =
+static struct reg_desc   xtalk_cmd_bits[] =
 {
     {WIDGET_DIDN, -28, "DIDN", "%x"},
     {WIDGET_SIDN, -24, "SIDN", "%x"},
-    {WIDGET_PACTYP, -20, "PACTYP", 0, xio_cmd_pactyp},
+    {WIDGET_PACTYP, -20, "PACTYP", 0, xtalk_cmd_pactyp},
     {WIDGET_TNUM, -15, "TNUM", "%x"},
     {WIDGET_COHERENT, 0, "COHERENT"},
     {WIDGET_DS, 0, "DS"},
@@ -118,46 +125,16 @@ static struct reg_values       space_v[]
     {PCIIO_SPACE_BAD, "BAD"},
     {0}
 };
-static struct reg_desc         space_desc[] =
+struct reg_desc         space_desc[] =
 {
     {0xFF, 0, "space", 0, space_v},
     {0}
 };
-#define	device_desc	device_bits
-static struct reg_desc   device_bits[] =
-{
-    {BRIDGE_DEV_ERR_LOCK_EN, 0, "ERR_LOCK_EN"},
-    {BRIDGE_DEV_PAGE_CHK_DIS, 0, "PAGE_CHK_DIS"},
-    {BRIDGE_DEV_FORCE_PCI_PAR, 0, "FORCE_PCI_PAR"},
-    {BRIDGE_DEV_VIRTUAL_EN, 0, "VIRTUAL_EN"},
-    {BRIDGE_DEV_PMU_WRGA_EN, 0, "PMU_WRGA_EN"},
-    {BRIDGE_DEV_DIR_WRGA_EN, 0, "DIR_WRGA_EN"},
-    {BRIDGE_DEV_DEV_SIZE, 0, "DEV_SIZE"},
-    {BRIDGE_DEV_RT, 0, "RT"},
-    {BRIDGE_DEV_SWAP_PMU, 0, "SWAP_PMU"},
-    {BRIDGE_DEV_SWAP_DIR, 0, "SWAP_DIR"},
-    {BRIDGE_DEV_PREF, 0, "PREF"},
-    {BRIDGE_DEV_PRECISE, 0, "PRECISE"},
-    {BRIDGE_DEV_COH, 0, "COH"},
-    {BRIDGE_DEV_BARRIER, 0, "BARRIER"},
-    {BRIDGE_DEV_GBR, 0, "GBR"},
-    {BRIDGE_DEV_DEV_SWAP, 0, "DEV_SWAP"},
-    {BRIDGE_DEV_DEV_IO_MEM, 0, "DEV_IO_MEM"},
-    {BRIDGE_DEV_OFF_MASK, BRIDGE_DEV_OFF_ADDR_SHFT, "DEV_OFF", "%x"},
-    {0}
-};
-
-static void
-print_bridge_errcmd(uint32_t cmdword, char *errtype)
-{
-    printk("\t    Bridge %s Error Command Word Register ", errtype);
-    print_register(cmdword, xio_cmd_bits);
-}
 
 static char             *pcibr_isr_errs[] =
 {
     "", "", "", "", "", "", "", "",
-    "08: GIO non-contiguous byte enable in crosstalk packet", /* BRIDGE ONLY */
+    "08: Reserved Bit 08",
     "09: PCI to Crosstalk read request timeout",
     "10: PCI retry operation count exhausted.",
     "11: PCI bus device select timeout",
@@ -165,12 +142,12 @@ static char             *pcibr_isr_errs[
     "13: PCI Address/Cmd parity error ",
     "14: PCI Bridge detected parity error",
     "15: PCI abort condition",
-    "16: SSRAM parity error", /* BRIDGE ONLY */
-    "17: LLP Transmitter Retry count wrapped",
-    "18: LLP Transmitter side required Retry",
-    "19: LLP Receiver retry count wrapped",
-    "20: LLP Receiver check bit error",
-    "21: LLP Receiver sequence number error",
+    "16: Reserved Bit 16",
+    "17: LLP Transmitter Retry count wrapped",	/* PIC ONLY */
+    "18: LLP Transmitter side required Retry",	/* PIC ONLY */
+    "19: LLP Receiver retry count wrapped",	/* PIC ONLY */
+    "20: LLP Receiver check bit error",		/* PIC ONLY */
+    "21: LLP Receiver sequence number error",	/* PIC ONLY */
     "22: Request packet overflow",
     "23: Request operation not supported by bridge",
     "24: Request packet has invalid address for bridge widget",
@@ -180,9 +157,7 @@ static char             *pcibr_isr_errs[
     "28: Framing error, response cmd data size does not match actual",
     "29: Unexpected response arrived",
     "30: PMU Access Fault",
-    "31: Multiple errors occurred", /* BRIDGE ONLY */
-    
-    /* bits 32-45 are PIC ONLY */
+    "31: Reserved Bit 31",
     "32: PCI-X address or attribute cycle parity error",
     "33: PCI-X data cycle parity error",
     "34: PCI-X master timeout (ie. master abort)",
@@ -199,11 +174,86 @@ static char             *pcibr_isr_errs[
     "45: PCI-X split completion message parity error",
 };
 
-#define BEM_ADD_STR(s)  printk("%s", (s))
-#define BEM_ADD_VAR(v)  printk("\t%20s: 0x%llx\n", #v, ((unsigned long long)v))
-#define BEM_ADD_REG(r)  printk("\t%20s: ", #r); print_register((r), r ## _desc)
-#define BEM_ADD_NSPC(n,s)       printk("\t%20s: ", n); print_register(s, space_desc)
-#define BEM_ADD_SPC(s)          BEM_ADD_NSPC(#s, s)
+/*
+ * print_register() allows formatted printing of bit fields.  individual
+ * bit fields are described by a struct reg_desc, multiple bit fields within
+ * a single word can be described by multiple reg_desc structures.
+ * %r outputs a string of the format "<bit field descriptions>"
+ * %R outputs a string of the format "0x%x<bit field descriptions>"
+ *
+ * The fields in a reg_desc are:
+ *	unsigned long long rd_mask; An appropriate mask to isolate the bit field
+ *				within a word, and'ed with val
+ *
+ *	int rd_shift;		A shift amount to be done to the isolated
+ *				bit field.  done before printing the isolate
+ *				bit field with rd_format and before searching
+ *				for symbolic value names in rd_values
+ *
+ *	char *rd_name;		If non-null, a bit field name to label any
+ *				out from rd_format or searching rd_values.
+ *				if neither rd_format or rd_values is non-null
+ *				rd_name is printed only if the isolated
+ *				bit field is non-null.
+ *
+ *	char *rd_format;	If non-null, the shifted bit field value
+ *				is printed using this format.
+ *
+ *	struct reg_values *rd_values;	If non-null, a pointer to a table
+ *				matching numeric values with symbolic names.
+ *				rd_values are searched and the symbolic
+ *				value is printed if a match is found, if no
+ *				match is found "???" is printed.
+ *				
+ */
+
+static void
+print_register(unsigned long long reg, struct reg_desc *addr)
+{
+	register struct reg_desc *rd;
+	register struct reg_values *rv;
+	unsigned long long field;
+	int any;
+
+	printk("<");
+	any = 0;
+	for (rd = addr; rd->rd_mask; rd++) {
+		field = reg & rd->rd_mask;
+		field = (rd->rd_shift > 0) ? field << rd->rd_shift : field >> -rd->rd_shift;
+		if (any && (rd->rd_format || rd->rd_values || (rd->rd_name && field)))
+			printk(",");
+		if (rd->rd_name) {
+			if (rd->rd_format || rd->rd_values || field) {
+				printk("%s", rd->rd_name);
+				any = 1;
+			}
+			if (rd->rd_format || rd->rd_values) {
+				printk("=");
+				any = 1;
+			}
+		}
+		/* You can have any format so long as it is %x */
+		if (rd->rd_format) {
+			printk("%llx", field);
+			any = 1;
+			if (rd->rd_values)
+				printk(":");
+		}
+		if (rd->rd_values) {
+			any = 1;
+			for (rv = rd->rd_values; rv->rv_name; rv++) {
+				if (field == rv->rv_value) {
+					printk("%s", rv->rv_name);
+					break;
+				}
+			}
+			if (rv->rv_name == NULL)
+				printk("???");
+		}
+	}
+	printk(">\n");
+}
+
 
 /*
  * display memory directory state
@@ -225,6 +275,13 @@ pcibr_show_dir_state(paddr_t paddr, char
 #endif
 }
 
+static void
+print_bridge_errcmd(uint32_t cmdword, char *errtype)
+{
+    printk("\t    Bridge %s Error Command Word Register ", errtype);
+    print_register(cmdword, xtalk_cmd_bits);
+}
+
 
 /*
  *	Dump relevant error information for Bridge error interrupts.
@@ -235,10 +292,8 @@ pcibr_error_dump(pcibr_soft_t pcibr_soft
 {
     bridge_t               *bridge = pcibr_soft->bs_base;
     uint64_t		    int_status;
-    bridgereg_t             int_status_32;
     picreg_t		    int_status_64;
     uint64_t		    mult_int;
-    bridgereg_t             mult_int_32;
     picreg_t		    mult_int_64;
     uint64_t		    bit;
     int			    number_bits;
@@ -246,19 +301,9 @@ pcibr_error_dump(pcibr_soft_t pcibr_soft
     char		    *reg_desc;
     paddr_t		    addr = (paddr_t)0;
 
-    /* We read the INT_STATUS register as a 64bit picreg_t for PIC and a
-     * 32bit bridgereg_t for BRIDGE, but always process the result as a
-     * 64bit value so the code can be "common" for both PIC and BRIDGE...
-     */
-    if (IS_PIC_SOFT(pcibr_soft)) {
-	int_status_64 = (bridge->p_int_status_64 & ~BRIDGE_ISR_INT_MSK);
-	int_status = (uint64_t)int_status_64;
-	number_bits = PCIBR_ISR_MAX_ERRS_PIC;
-    } else {
-	int_status_32 = (bridge->b_int_status & ~BRIDGE_ISR_INT_MSK);
-	int_status = ((uint64_t)int_status_32) & 0xffffffff;
-	number_bits = PCIBR_ISR_MAX_ERRS_BRIDGE;
-    }
+    int_status_64 = (bridge->p_int_status_64 & ~BRIDGE_ISR_INT_MSK);
+    int_status = (uint64_t)int_status_64;
+    number_bits = PCIBR_ISR_MAX_ERRS_PIC;
 
     if (!int_status) {
 	/* No error bits set */
@@ -273,8 +318,7 @@ pcibr_error_dump(pcibr_soft_t pcibr_soft
     printk(KERN_ALERT "PCI BRIDGE ERROR: int_status is 0x%lx for %s\n"
 	"    Dumping relevant %s registers for each bit set...\n",
 	    int_status, pcibr_soft->bs_name,
-	    (IS_PIC_SOFT(pcibr_soft) ? "PIC" : 
-	        (IS_BRIDGE_SOFT(pcibr_soft) ? "BRIDGE" : "XBRIDGE")));
+	    "PIC");
 
     for (i = PCIBR_ISR_ERR_START; i < number_bits; i++) {
 	bit = 1ull << i;
@@ -283,15 +327,14 @@ pcibr_error_dump(pcibr_soft_t pcibr_soft
 	 * A number of int_status bits are only defined for Bridge.
 	 * Ignore them in the case of an XBridge or PIC.
 	 */
-	if ((IS_XBRIDGE_SOFT(pcibr_soft) || IS_PIC_SOFT(pcibr_soft)) &&
-	    ((bit == BRIDGE_ISR_MULTI_ERR) ||
+	if (((bit == BRIDGE_ISR_MULTI_ERR) ||
 	     (bit == BRIDGE_ISR_SSRAM_PERR) ||
 	     (bit == BRIDGE_ISR_GIO_B_ENBL_ERR))) {
 	    continue;
 	}
 
 	/* A number of int_status bits are only valid for PIC's bus0 */
-	if ((IS_PIC_SOFT(pcibr_soft) && (pcibr_soft->bs_busnum != 0)) && 
+	if (((pcibr_soft->bs_busnum != 0)) && 
 	    ((bit == BRIDGE_ISR_UNSUPPORTED_XOP) ||
 	     (bit == BRIDGE_ISR_LLP_REC_SNERR) ||
 	     (bit == BRIDGE_ISR_LLP_REC_CBERR) ||
@@ -314,7 +357,7 @@ pcibr_error_dump(pcibr_soft_t pcibr_soft
 
 	    case PIC_ISR_PCIX_ARB_ERR:	    /* bit40	PCI_X_ARB_ERR */
 		/* XXX: should breakdown meaning of bits in reg */
-		printk( "\t	Arbitration Reg: 0x%x\n",
+		printk( "\t	Arbitration Reg: 0x%lx\n",
 		    bridge->b_arb);
 		break;
 
@@ -357,10 +400,7 @@ pcibr_error_dump(pcibr_soft_t pcibr_soft
 		break;
 
 	    case BRIDGE_ISR_PAGE_FAULT:	    /* bit30	PMU_PAGE_FAULT */
-		if (IS_XBRIDGE_OR_PIC_SOFT(pcibr_soft))
-		    reg_desc = "Map Fault Address";
-		else
-		    reg_desc = "SSRAM Parity Error";
+	        reg_desc = "Map Fault Address";
 
 		printk( "\t    %s Register: 0x%x\n", reg_desc,
 		    bridge->b_ram_perr_or_map_fault);
@@ -370,7 +410,7 @@ pcibr_error_dump(pcibr_soft_t pcibr_soft
 		print_bridge_errcmd(bridge->b_wid_aux_err, "Aux ");
 
 		/* PIC in PCI-X mode, dump the PCIX DMA Request registers */
-		if (IS_PIC_SOFT(pcibr_soft) && IS_PCIX(pcibr_soft)) {
+		if (IS_PCIX(pcibr_soft)) {
 		    /* XXX: should breakdown meaning of attr bit */
 		    printk( 
 			"\t    PCI-X DMA Request Error Addr Reg: 0x%lx\n"
@@ -382,32 +422,14 @@ pcibr_error_dump(pcibr_soft_t pcibr_soft
 
 	    case BRIDGE_ISR_BAD_XRESP_PKT:  /* bit28	BAD_RESP_PACKET */
 	    case BRIDGE_ISR_RESP_XTLK_ERR:  /* bit26	RESP_XTALK_ERROR */
-		if (IS_PIC_SOFT(pcibr_soft)) {
-		    print_bridge_errcmd(bridge->b_wid_aux_err, "Aux ");
-		}
+	        print_bridge_errcmd(bridge->b_wid_aux_err, "Aux ");
 		 
-		/* If PIC in PCI-X mode, DMA Request Error registers are
-		 * valid.  But PIC in PCI mode, Response Buffer Address 
-		 * register are valid.
-		 */
-		if (IS_PCIX(pcibr_soft)) {
-		    /* XXX: should breakdown meaning of attribute bit */
-		    printk( 
+		/* XXX: should breakdown meaning of attribute bit */
+		printk( 
 			"\t    PCI-X DMA Request Error Addr Reg: 0x%lx\n"
 		        "\t    PCI-X DMA Request Error Attribute Reg: 0x%lx\n",
 		        bridge->p_pcix_dma_req_err_addr_64,
 		        bridge->p_pcix_dma_req_err_attr_64);
-		} else {
-		    addr= (((uint64_t)(bridge->b_wid_resp_upper & 0xFFFF)<<32)
-			   | bridge->b_wid_resp_lower);
-		    printk("\t    Bridge Response Buf Error Upper Addr Reg: 0x%x\n"
-		        "\t    Bridge Response Buf Error Lower Addr Reg: 0x%x\n"
-		        "\t    dev-num %d buff-num %d addr 0x%lx\n",
-		        bridge->b_wid_resp_upper, bridge->b_wid_resp_lower,
-		        ((bridge->b_wid_resp_upper >> 20) & 0x3),
-		        ((bridge->b_wid_resp_upper >> 16) & 0xF),
-		        addr);
-		}
 		if (bit == BRIDGE_ISR_RESP_XTLK_ERR) {
 			/* display memory directory associated with cacheline */
 			pcibr_show_dir_state(addr, "\t    ");
@@ -429,40 +451,17 @@ pcibr_error_dump(pcibr_soft_t pcibr_soft
 		break;
 
 	    case BRIDGE_ISR_UNSUPPORTED_XOP:/* bit23	UNSUPPORTED_XOP */
-		if (IS_PIC_SOFT(pcibr_soft)) {
-		    print_bridge_errcmd(bridge->b_wid_aux_err, "Aux ");
-		    printk( 
+		print_bridge_errcmd(bridge->b_wid_aux_err, "Aux ");
+		printk( 
 			"\t    Address Holding Link Side Error Reg: 0x%lx\n",
-			bridge->p_addr_lkerr_64);
-		} else {
-		    print_bridge_errcmd(bridge->b_wid_err_cmdword, "");
-		    printk( 
-			"\t    Bridge Error Upper Address Register: 0x%lx\n"
-		        "\t    Bridge Error Lower Address Register: 0x%lx\n"
-		        "\t    Bridge Error Address: 0x%lx\n",
-		        (uint64_t) bridge->b_wid_err_upper,
-		        (uint64_t) bridge->b_wid_err_lower,
-		        (((uint64_t) bridge->b_wid_err_upper << 32) |
-		        bridge->b_wid_err_lower));
-		}
+		bridge->p_addr_lkerr_64);
 		break;
 
 	    case BRIDGE_ISR_XREQ_FIFO_OFLOW:/* bit22	XREQ_FIFO_OFLOW */
-		/* Link side error registers are only valid for PIC */
-		if (IS_PIC_SOFT(pcibr_soft)) {
-		    print_bridge_errcmd(bridge->b_wid_aux_err, "Aux ");
-		    printk(
+		print_bridge_errcmd(bridge->b_wid_aux_err, "Aux ");
+		printk(
 			"\t    Address Holding Link Side Error Reg: 0x%lx\n",
-			bridge->p_addr_lkerr_64);
-		}
-		break;
-
-	    case BRIDGE_ISR_SSRAM_PERR:	    /* bit16	SSRAM_PERR */
-		if (IS_BRIDGE_SOFT(pcibr_soft)) {
-		    printk(
-			"\t    Bridge SSRAM Parity Error Register: 0x%x\n",
-			bridge->b_ram_perr);
-		}
+		bridge->p_addr_lkerr_64);
 		break;
 
 	    case BRIDGE_ISR_PCI_ABORT:	    /* bit15	PCI_ABORT */
@@ -498,23 +497,13 @@ pcibr_error_dump(pcibr_soft_t pcibr_soft
 	}
     }
 
-    /* We read the INT_MULT register as a 64bit picreg_t for PIC and a
-     * 32bit bridgereg_t for BRIDGE, but always process the result as a
-     * 64bit value so the code can be "common" for both PIC and BRIDGE...
-     */
-    if (IS_PIC_SOFT(pcibr_soft)) {
-	mult_int_64 = (bridge->p_mult_int_64 & ~BRIDGE_ISR_INT_MSK);
-	mult_int = (uint64_t)mult_int_64;
-	number_bits = PCIBR_ISR_MAX_ERRS_PIC;
-    } else {
-	mult_int_32 = (bridge->b_mult_int & ~BRIDGE_ISR_INT_MSK);
-	mult_int = ((uint64_t)mult_int_32) & 0xffffffff;
-	number_bits = PCIBR_ISR_MAX_ERRS_BRIDGE;
-    }
+    mult_int_64 = (bridge->p_mult_int_64 & ~BRIDGE_ISR_INT_MSK);
+    mult_int = (uint64_t)mult_int_64;
+    number_bits = PCIBR_ISR_MAX_ERRS_PIC;
 
-    if (IS_XBRIDGE_OR_PIC_SOFT(pcibr_soft)&&(mult_int & ~BRIDGE_ISR_INT_MSK)) {
+    if (mult_int & ~BRIDGE_ISR_INT_MSK) {
 	printk( "    %s Multiple Interrupt Register is 0x%lx\n",
-		IS_PIC_SOFT(pcibr_soft) ? "PIC" : "XBridge", mult_int);
+		"PIC", mult_int);
 	for (i = PCIBR_ISR_ERR_START; i < number_bits; i++) {
 	    if (mult_int & (1ull << i))
 		printk( "\t%s\n", pcibr_isr_errs[i]);
@@ -522,29 +511,6 @@ pcibr_error_dump(pcibr_soft_t pcibr_soft
     }
 }
 
-static uint32_t
-pcibr_errintr_group(uint32_t error)
-{
-    uint32_t              group = BRIDGE_IRR_MULTI_CLR;
-
-    if (error & BRIDGE_IRR_PCI_GRP)
-	group |= BRIDGE_IRR_PCI_GRP_CLR;
-    if (error & BRIDGE_IRR_SSRAM_GRP)
-	group |= BRIDGE_IRR_SSRAM_GRP_CLR;
-    if (error & BRIDGE_IRR_LLP_GRP)
-	group |= BRIDGE_IRR_LLP_GRP_CLR;
-    if (error & BRIDGE_IRR_REQ_DSP_GRP)
-	group |= BRIDGE_IRR_REQ_DSP_GRP_CLR;
-    if (error & BRIDGE_IRR_RESP_BUF_GRP)
-	group |= BRIDGE_IRR_RESP_BUF_GRP_CLR;
-    if (error & BRIDGE_IRR_CRP_GRP)
-	group |= BRIDGE_IRR_CRP_GRP_CLR;
-
-    return group;
-
-}
-
-
 /* pcibr_pioerr_check():
  *	Check to see if this pcibr has a PCI PIO
  *	TIMEOUT error; if so, bump the timeout-count
@@ -555,7 +521,6 @@ pcibr_pioerr_check(pcibr_soft_t soft)
 {
     bridge_t		   *bridge;
     uint64_t              int_status;
-    bridgereg_t             int_status_32;
     picreg_t                int_status_64;
     bridgereg_t		    pci_err_lower;
     bridgereg_t		    pci_err_upper;
@@ -568,18 +533,8 @@ pcibr_pioerr_check(pcibr_soft_t soft)
     int			    func;
 
     bridge = soft->bs_base;
-
-    /* We read the INT_STATUS register as a 64bit picreg_t for PIC and a
-     * 32bit bridgereg_t for BRIDGE, but always process the result as a
-     * 64bit value so the code can be "common" for both PIC and BRIDGE...
-     */
-    if (IS_PIC_SOFT(soft)) {
-        int_status_64 = (bridge->p_int_status_64 & ~BRIDGE_ISR_INT_MSK);
-        int_status = (uint64_t)int_status_64;
-    } else {
-        int_status_32 = (bridge->b_int_status & ~BRIDGE_ISR_INT_MSK);
-        int_status = ((uint64_t)int_status_32) & 0xffffffff;
-    }
+    int_status_64 = (bridge->p_int_status_64 & ~BRIDGE_ISR_INT_MSK);
+    int_status = (uint64_t)int_status_64;
 
     if (int_status & BRIDGE_ISR_PCIBUS_PIOERR) {
 	pci_err_lower = bridge->b_pci_err_lower;
@@ -636,14 +591,13 @@ pcibr_pioerr_check(pcibr_soft_t soft)
  *                due to read or write error!.
  */
 
-void
+irqreturn_t
 pcibr_error_intr_handler(int irq, void *arg, struct pt_regs *ep)
 {
     pcibr_soft_t            pcibr_soft;
     bridge_t               *bridge;
     uint64_t              int_status;
     uint64_t              err_status;
-    bridgereg_t             int_status_32;
     picreg_t                int_status_64;
     int			    number_bits;
     int                     i;
@@ -662,7 +616,9 @@ pcibr_error_intr_handler(int irq, void *
 	entry = pcibr_list;
 	while (1) {
 	    if (entry == NULL) {
-		PRINT_PANIC("pcibr_error_intr_handler:\tmy parameter (0x%p) is not a pcibr_soft!", arg);
+		printk("pcibr_error_intr_handler: (0x%lx) is not a pcibr_soft!",
+	 	      (uint64_t)arg);
+    		return IRQ_NONE;
 	    }
 	    if ((intr_arg_t) entry->bl_soft == arg)
 		break;
@@ -706,22 +662,12 @@ pcibr_error_intr_handler(int irq, void *
 	return(pcibr_error_intr_handler(irq, arg, ep));
     }
 
-    /* We read the INT_STATUS register as a 64bit picreg_t for PIC and a
-     * 32bit bridgereg_t for BRIDGE, but always process the result as a
-     * 64bit value so the code can be "common" for both PIC and BRIDGE...
-     */
-    if (IS_PIC_SOFT(pcibr_soft)) {
-        int_status_64 = (bridge->p_int_status_64 & ~BRIDGE_ISR_INT_MSK);
-        int_status = (uint64_t)int_status_64;
-        number_bits = PCIBR_ISR_MAX_ERRS_PIC;
-    } else {
-        int_status_32 = (bridge->b_int_status & ~BRIDGE_ISR_INT_MSK);
-        int_status = ((uint64_t)int_status_32) & 0xffffffff;
-        number_bits = PCIBR_ISR_MAX_ERRS_BRIDGE;
-    }
+    int_status_64 = (bridge->p_int_status_64 & ~BRIDGE_ISR_INT_MSK);
+    int_status = (uint64_t)int_status_64;
+    number_bits = PCIBR_ISR_MAX_ERRS_PIC;
 
     PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ERROR, pcibr_soft->bs_conn,
-		"pcibr_error_intr_handler: int_status=0x%x\n", int_status));
+		"pcibr_error_intr_handler: int_status=0x%lx\n", int_status));
 
     /* int_status is which bits we have to clear;
      * err_status is the bits we haven't handled yet.
@@ -732,7 +678,7 @@ pcibr_error_intr_handler(int irq, void *
 	/*
 	 * No error bit set!!.
 	 */
-	return;
+	return IRQ_HANDLED;
     }
     /*
      * If we have a PCIBUS_PIOERR, hand it to the logger.
@@ -853,8 +799,7 @@ pcibr_error_intr_handler(int irq, void *
 		 * interrupt inorder to clear the DEV_BROKE bits in
 		 * b_arb register to re-enable the device.
 		 */
-		if (IS_PIC_SOFT(pcibr_soft) &&
-				!(err_status & PIC_ISR_PCIX_ARB_ERR) &&
+		if (!(err_status & PIC_ISR_PCIX_ARB_ERR) &&
 				PCIBR_WAR_ENABLED(PV856155, pcibr_soft)) {
 
 		if (bs_estat->bs_errcount_total > PCIBR_ERRINTR_DISABLE_LEVEL) {
@@ -876,17 +821,13 @@ pcibr_error_intr_handler(int irq, void *
     }
 
     if (disable_errintr_mask) {
-	unsigned s;
+	unsigned long s;
 	/*
 	 * Disable some high frequency errors as they
 	 * could eat up too much cpu time.
 	 */
 	s = pcibr_lock(pcibr_soft);
-	if (IS_PIC_SOFT(pcibr_soft)) {
-	    bridge->p_int_enable_64 &= (picreg_t)(~disable_errintr_mask);
-	} else {
-	    bridge->b_int_enable &= (bridgereg_t)(~disable_errintr_mask);
-	}
+	bridge->p_int_enable_64 &= (picreg_t)(~disable_errintr_mask);
 	pcibr_unlock(pcibr_soft, s);
     }
     /*
@@ -931,15 +872,15 @@ pcibr_error_intr_handler(int irq, void *
      * so we know we've hit the problem defined in PV 867308 that we believe
      * has only been seen in simulation
      */
-    if (IS_PIC_SOFT(pcibr_soft) && PCIBR_WAR_ENABLED(PV867308, pcibr_soft) &&
+    if (PCIBR_WAR_ENABLED(PV867308, pcibr_soft) &&
         (err_status & (BRIDGE_ISR_LLP_REC_SNERR | BRIDGE_ISR_LLP_REC_CBERR))) {
         printk("BRIDGE ERR_STATUS 0x%lx\n", err_status);
         pcibr_error_dump(pcibr_soft);
-        PRINT_PANIC("PCI Bridge Error interrupt killed the system");
+        panic("PCI Bridge Error interrupt killed the system");
     }
 
     if (err_status & BRIDGE_ISR_ERROR_FATAL) {
-	PRINT_PANIC("PCI Bridge Error interrupt killed the system");
+	panic("PCI Bridge Error interrupt killed the system");
 	    /*NOTREACHED */
     }
 
@@ -952,24 +893,20 @@ pcibr_error_intr_handler(int irq, void *
      * 
      * PIC doesn't require groups of interrupts to be cleared...
      */
-    if (IS_PIC_SOFT(pcibr_soft)) {
-	bridge->p_int_rst_stat_64 = (picreg_t)(int_status | BRIDGE_IRR_MULTI_CLR);
-    } else {
-	bridge->b_int_rst_stat = (bridgereg_t)pcibr_errintr_group(int_status);
-    }
+    bridge->p_int_rst_stat_64 = (picreg_t)(int_status | BRIDGE_IRR_MULTI_CLR);
 
     /* PIC BRINGUP WAR (PV# 856155):
      * On a PCI_X_ARB_ERR error interrupt clear the DEV_BROKE bits from
      * the b_arb register to re-enable the device.
      */
-    if (IS_PIC_SOFT(pcibr_soft) &&
-		(err_status & PIC_ISR_PCIX_ARB_ERR) &&
+    if ((err_status & PIC_ISR_PCIX_ARB_ERR) &&
 		PCIBR_WAR_ENABLED(PV856155, pcibr_soft)) {
 	bridge->b_arb |= (0xf << 20);
     }
 
     /* Zero out bserr_intstat field */
     pcibr_soft->bs_errinfo.bserr_intstat = 0;
+    return IRQ_HANDLED;
 }
 
 void
@@ -980,14 +917,9 @@ pcibr_error_cleanup(pcibr_soft_t pcibr_s
     ASSERT(error_code & IOECODE_PIO);
     error_code = error_code;
 
-    if (IS_PIC_SOFT(pcibr_soft)) {
-        bridge->p_int_rst_stat_64 = BRIDGE_IRR_PCI_GRP_CLR |
+    bridge->p_int_rst_stat_64 = BRIDGE_IRR_PCI_GRP_CLR |
 				    PIC_PCIX_GRP_CLR |
 				    BRIDGE_IRR_MULTI_CLR;
-    } else {
-        bridge->b_int_rst_stat = BRIDGE_IRR_PCI_GRP_CLR | BRIDGE_IRR_MULTI_CLR;
-    }
-
     (void) bridge->b_wid_tflush;	/* flushbus */
 }
 
@@ -1079,8 +1011,6 @@ pcibr_pioerror(
     int                     retval = IOERROR_HANDLED;
 
     vertex_hdl_t            pcibr_vhdl = pcibr_soft->bs_vhdl;
-    bridge_t               *bridge = pcibr_soft->bs_base;
-
     iopaddr_t               bad_xaddr;
 
     pciio_space_t           raw_space;	/* raw PCI space */
@@ -1106,7 +1036,7 @@ pcibr_pioerror(
     IOERROR_GETVALUE(bad_xaddr, ioe, xtalkaddr);
 
     PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ERROR_HDLR, pcibr_soft->bs_conn,
-                "pcibr_pioerror: pcibr_soft=0x%x, bad_xaddr=0x%x\n",
+                "pcibr_pioerror: pcibr_soft=0x%lx, bad_xaddr=0x%lx\n",
 		pcibr_soft, bad_xaddr));
 
     slot = PCIIO_SLOT_NONE;
@@ -1405,47 +1335,8 @@ pcibr_pioerror(
 	    printk(KERN_ALERT
 		    "PIO Error on PCI Bus %s",
 		    pcibr_soft->bs_name);
-	    /* this decodes part of the ioe; our caller
-	     * will dump the raw details in DEBUG and
-	     * kdebug kernels.
-	     */
 	    BEM_ADD_IOE(ioe);
 	}
-#if defined(FORCE_ERRORS)
-	if (0) {
-#elif !DEBUG
-	if (kdebug) {
-#endif
-	    /*
-	     * Dump raw data from Bridge/PCI layer.
-	     */
-
-	    BEM_ADD_STR("Raw info from Bridge/PCI layer:\n");
-	    if (IS_PIC_SOFT(pcibr_soft)) {
-		if (bridge->p_int_status_64 & (picreg_t)BRIDGE_ISR_PCIBUS_PIOERR)
-		    pcibr_error_dump(pcibr_soft);
-	    } else {
-		if (bridge->b_int_status & (bridgereg_t)BRIDGE_ISR_PCIBUS_PIOERR)
-		    pcibr_error_dump(pcibr_soft);
-	    }
-	    BEM_ADD_SPC(raw_space);
-	    BEM_ADD_VAR(raw_paddr);
-	    if (IOERROR_FIELDVALID(ioe, widgetdev)) {
-		short widdev;
-		IOERROR_GETVALUE(widdev, ioe, widgetdev);
-		slot = pciio_widgetdev_slot_get(widdev);
-		func = pciio_widgetdev_func_get(widdev);
-		if (slot < PCIBR_NUM_SLOTS(pcibr_soft)) {
-		    bridgereg_t             device = bridge->b_device[slot].reg;
-
-		    BEM_ADD_VAR(slot);
-		    BEM_ADD_VAR(func);
-		    BEM_ADD_REG(device);
-		}
-	    }
-#if !DEBUG || defined(FORCE_ERRORS)
-	}
-#endif
 
 	/*
 	 * Since error could not be handled at lower level,
@@ -1506,7 +1397,6 @@ pcibr_dmard_error(
 	IOERROR_GETVALUE(tmp, ioe, widgetnum);
 	ASSERT(tmp == pcibr_soft->bs_xid);
     }
-    ASSERT(bridge);
 
     /*
      * read error log registers
@@ -1637,7 +1527,7 @@ pcibr_error_handler(
     pcibr_soft = (pcibr_soft_t) einfo;
 
     PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ERROR_HDLR, pcibr_soft->bs_conn,
-		"pcibr_error_handler: pcibr_soft=0x%x, error_code=0x%x\n",
+		"pcibr_error_handler: pcibr_soft=0x%lx, error_code=0x%x\n",
 		pcibr_soft, error_code));
 
 #if DEBUG && ERROR_DEBUG
@@ -1701,7 +1591,7 @@ pcibr_error_handler_wrapper(
     int		       dma_retval = -1;
 
     PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ERROR_HDLR, pcibr_soft->bs_conn,
-                "pcibr_error_handler_wrapper: pcibr_soft=0x%x, "
+                "pcibr_error_handler_wrapper: pcibr_soft=0x%lx, "
 		"error_code=0x%x\n", pcibr_soft, error_code));
 
     /*
@@ -1735,7 +1625,7 @@ pcibr_error_handler_wrapper(
 	    if (!pcibr_soft) {
 #if DEBUG
 		printk(KERN_WARNING "pcibr_error_handler: "
-			"bs_peers_soft==NULL. bad_xaddr= 0x%x mode= 0x%x\n",
+			"bs_peers_soft==NULL. bad_xaddr= 0x%lx mode= 0x%lx\n",
 						bad_xaddr, mode);
 #endif
   		pio_retval = IOERROR_HANDLED;
diff -puN arch/ia64/sn/io/sn2/pcibr/pcibr_hints.c~linus arch/ia64/sn/io/sn2/pcibr/pcibr_hints.c
--- 25/arch/ia64/sn/io/sn2/pcibr/pcibr_hints.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/pcibr/pcibr_hints.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
 /*
- *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -8,26 +7,11 @@
  */
 
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/module.h>
 #include <asm/sn/sgi.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/addrs.h>
-#include <asm/sn/arch.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/pci/bridge.h>
-#include <asm/sn/pci/pciio.h>
 #include <asm/sn/pci/pcibr.h>
 #include <asm/sn/pci/pcibr_private.h>
 #include <asm/sn/pci/pci_defs.h>
-#include <asm/sn/prio.h>
-#include <asm/sn/xtalk/xbow.h>
-#include <asm/sn/io.h>
-#include <asm/sn/sn_private.h>
 
 pcibr_hints_t           pcibr_hints_get(vertex_hdl_t, int);
 void                    pcibr_hints_fix_rrbs(vertex_hdl_t);
@@ -48,7 +32,11 @@ pcibr_hints_get(vertex_hdl_t xconn_vhdl,
 
     if (alloc && (rv != GRAPH_SUCCESS)) {
 
-	NEW(hint);
+	hint = kmalloc(sizeof (*(hint)), GFP_KERNEL);
+	if ( !hint )
+		goto abnormal_exit;
+	memset(hint, 0, sizeof (*(hint)));
+
 	hint->rrb_alloc_funct = NULL;
 	hint->ph_intr_bits = NULL;
 	rv = hwgraph_info_add_LBL(xconn_vhdl, 
@@ -68,10 +56,7 @@ pcibr_hints_get(vertex_hdl_t xconn_vhdl,
     return (pcibr_hints_t) ainfo;
 
 abnormal_exit:
-#ifdef LATER
-    printf("SHOULD NOT BE HERE\n");
-#endif
-    DEL(hint);
+    kfree(hint);
     return(NULL);
 
 }
@@ -162,18 +147,19 @@ pcibr_hints_subdevs(vertex_hdl_t xconn_v
     if (ainfo == 0) {
 	uint64_t                *subdevp;
 
-	NEW(subdevp);
+	subdevp = kmalloc(sizeof (*(subdevp)), GFP_KERNEL);
 	if (!subdevp) {
 	    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HINTS, xconn_vhdl,
 			"pcibr_hints_subdevs: subdev ptr alloc failed\n"));
 	    return;
 	}
+	memset(subdevp, 0, sizeof (*(subdevp)));
 	*subdevp = subdevs;
 	hwgraph_info_add_LBL(pconn_vhdl, INFO_LBL_SUBDEVS, (arbitrary_info_t) subdevp);
 	hwgraph_info_get_LBL(pconn_vhdl, INFO_LBL_SUBDEVS, &ainfo);
 	if (ainfo == (arbitrary_info_t) subdevp)
 	    return;
-	DEL(subdevp);
+	kfree(subdevp);
 	if (ainfo == (arbitrary_info_t) NULL) {
 	    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HINTS, xconn_vhdl,
 			"pcibr_hints_subdevs: null subdevs ptr\n"));
diff -puN arch/ia64/sn/io/sn2/pcibr/pcibr_intr.c~linus arch/ia64/sn/io/sn2/pcibr/pcibr_intr.c
--- 25/arch/ia64/sn/io/sn2/pcibr/pcibr_intr.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/pcibr/pcibr_intr.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
 /*
- *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -8,24 +7,14 @@
  */
 
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/module.h>
 #include <asm/sn/sgi.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/addrs.h>
 #include <asm/sn/arch.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/pci/bridge.h>
 #include <asm/sn/pci/pciio.h>
 #include <asm/sn/pci/pcibr.h>
 #include <asm/sn/pci/pcibr_private.h>
 #include <asm/sn/pci/pci_defs.h>
-#include <asm/sn/prio.h>
-#include <asm/sn/xtalk/xbow.h>
 #include <asm/sn/io.h>
 #include <asm/sn/sn_private.h>
 
@@ -33,7 +22,7 @@
 inline int
 compare_and_swap_ptr(void **location, void *old_ptr, void *new_ptr)
 {
-	FIXME("compare_and_swap_ptr : NOT ATOMIC");
+	/* FIXME - compare_and_swap_ptr NOT ATOMIC */
 	if (*location == old_ptr) {
 		*location = new_ptr;
 		return(1);
@@ -94,49 +83,6 @@ pcibr_intr_bits(pciio_info_t info,
 
 
 /*
- *	Get the next wrapper pointer queued in the interrupt circular buffer.
- */
-pcibr_intr_wrap_t
-pcibr_wrap_get(pcibr_intr_cbuf_t cbuf)
-{
-    pcibr_intr_wrap_t	wrap;
-
-	if (cbuf->ib_in == cbuf->ib_out)
-	    PRINT_PANIC( "pcibr intr circular buffer empty, cbuf=0x%p, ib_in=ib_out=%d\n",
-		(void *)cbuf, cbuf->ib_out);
-
-	wrap = cbuf->ib_cbuf[cbuf->ib_out++];
-	cbuf->ib_out = cbuf->ib_out % IBUFSIZE;
-	return(wrap);
-}
-
-/* 
- *	Queue a wrapper pointer in the interrupt circular buffer.
- */
-void
-pcibr_wrap_put(pcibr_intr_wrap_t wrap, pcibr_intr_cbuf_t cbuf)
-{
-	int	in;
-	int	s;
-
-	/*
-	 * Multiple CPUs could be executing this code simultaneously
-	 * if a handler has registered multiple interrupt lines and
-	 * the interrupts are directed to different CPUs.
-	 */
-	s = mutex_spinlock(&cbuf->ib_lock);
-	in = (cbuf->ib_in + 1) % IBUFSIZE;
-	if (in == cbuf->ib_out) 
-	    PRINT_PANIC( "pcibr intr circular buffer full, cbuf=0x%p, ib_in=%d\n",
-		(void *)cbuf, cbuf->ib_in);
-
-	cbuf->ib_cbuf[cbuf->ib_in] = wrap;
-	cbuf->ib_in = in;
-	mutex_spinunlock(&cbuf->ib_lock, s);
-	return;
-}
-
-/*
  *	On SN systems there is a race condition between a PIO read response
  *	and DMA's.  In rare cases, the read response may beat the DMA, causing
  *	the driver to think that data in memory is complete and meaningful.
@@ -168,36 +114,16 @@ sn_dma_flush(unsigned long addr) {
 
 	if (flush_nasid_list[nasid].widget_p == NULL) return;
 	if (bwin > 0) {
-		bwin--;
-		switch (bwin) {
-			case 0:
-				wid_num = ((flush_nasid_list[nasid].iio_itte1) >> 8) & 0xf;
-				break;
-			case 1:
-				wid_num = ((flush_nasid_list[nasid].iio_itte2) >> 8) & 0xf;
-				break;
-			case 2: 
-				wid_num = ((flush_nasid_list[nasid].iio_itte3) >> 8) & 0xf;
-				break;
-			case 3: 
-				wid_num = ((flush_nasid_list[nasid].iio_itte4) >> 8) & 0xf;
-				break;
-			case 4: 
-				wid_num = ((flush_nasid_list[nasid].iio_itte5) >> 8) & 0xf;
-				break;
-			case 5: 
-				wid_num = ((flush_nasid_list[nasid].iio_itte6) >> 8) & 0xf;
-				break;
-			case 6: 
-				wid_num = ((flush_nasid_list[nasid].iio_itte7) >> 8) & 0xf;
-				break;
-		}
+		unsigned long itte = flush_nasid_list[nasid].iio_itte[bwin];
+
+		wid_num = (itte >> IIO_ITTE_WIDGET_SHIFT) &
+				  IIO_ITTE_WIDGET_MASK;
 	}
 	if (flush_nasid_list[nasid].widget_p == NULL) return;
 	if (flush_nasid_list[nasid].widget_p[wid_num] == NULL) return;
 	p = &flush_nasid_list[nasid].widget_p[wid_num][0];
 
-	// find a matching BAR
+	/* find a matching BAR */
 
 	for (i=0; i<DEV_PER_WIDGET;i++) {
 		for (j=0; j<PCI_ROM_RESOURCE;j++) {
@@ -208,7 +134,7 @@ sn_dma_flush(unsigned long addr) {
 		p++;
 	}
 
-	// if no matching BAR, return without doing anything.
+	/* if no matching BAR, return without doing anything. */
 
 	if (i == DEV_PER_WIDGET) return;
 
@@ -216,15 +142,15 @@ sn_dma_flush(unsigned long addr) {
 
 	p->flush_addr = 0;
 
-	// force an interrupt.
+	/* force an interrupt. */
 
 	*(bridgereg_t *)(p->force_int_addr) = 1;
 
-	// wait for the interrupt to come back.
+	/* wait for the interrupt to come back. */
 
 	while (p->flush_addr != 0x10f);
 
-	// okay, everything is synched up.
+	/* okay, everything is synched up. */
 	spin_unlock_irqrestore(&p->flush_lock, flags);
 
 	return;
@@ -283,9 +209,7 @@ pcibr_force_interrupt(pcibr_intr_t intr)
 			PCIBR_DEBUG((PCIBR_DEBUG_INTR, pcibr_soft->bs_vhdl,
 		    		"pcibr_force_interrupt: bit=0x%x\n", bit));
 
-			if (IS_XBRIDGE_OR_PIC_SOFT(pcibr_soft)) {
-	    			bridge->b_force_pin[bit].intr = 1;
-			}
+    			bridge->b_force_pin[bit].intr = 1;
 		}
 	}
 }
@@ -326,9 +250,10 @@ pcibr_intr_alloc(vertex_hdl_t pconn_vhdl
 		lines & 4 ? " INTC" : "",
 		lines & 8 ? " INTD" : ""));
 
-    NEW(pcibr_intr);
+    pcibr_intr = kmalloc(sizeof (*(pcibr_intr)), GFP_KERNEL);
     if (!pcibr_intr)
 	return NULL;
+    memset(pcibr_intr, 0, sizeof (*(pcibr_intr)));
 
     pcibr_intr->bi_dev = pconn_vhdl;
     pcibr_intr->bi_lines = lines;
@@ -340,7 +265,7 @@ pcibr_intr_alloc(vertex_hdl_t pconn_vhdl
     pcibr_intr->bi_mustruncpu = CPU_NONE;
     pcibr_intr->bi_ibuf.ib_in = 0;
     pcibr_intr->bi_ibuf.ib_out = 0;
-    mutex_spinlock_init(&pcibr_intr->bi_ibuf.ib_lock);
+    spin_lock_init(&pcibr_intr->bi_ibuf.ib_lock);
     pcibr_int_bits = pcibr_soft->bs_intr_bits((pciio_info_t)pcibr_info, lines, 
 		PCIBR_NUM_SLOTS(pcibr_soft));
 
@@ -384,7 +309,7 @@ pcibr_intr_alloc(vertex_hdl_t pconn_vhdl
 			owner_dev);
 
 		PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pconn_vhdl,
-			    "pcibr_intr_alloc: xtalk_intr=0x%x\n", xtalk_intr));
+			    "pcibr_intr_alloc: xtalk_intr=0x%lx\n", xtalk_intr));
 
 		/* both an assert and a runtime check on this:
 		 * we need to check in non-DEBUG kernels, and
@@ -400,15 +325,9 @@ pcibr_intr_alloc(vertex_hdl_t pconn_vhdl
 		     * in xtalk_intr_p.
 		     */
 		    if (!*xtalk_intr_p) {
-#ifdef SUPPORT_PRINTING_V_FORMAT
-			printk(KERN_ALERT  
-				"pcibr_intr_alloc %v: unable to get xtalk interrupt resources",
-				xconn_vhdl);
-#else
-			printk(KERN_ALERT  
-				"pcibr_intr_alloc 0x%p: unable to get xtalk interrupt resources",
-				(void *)xconn_vhdl);
-#endif
+			printk(KERN_ALERT "pcibr_intr_alloc %s: "
+				"unable to get xtalk interrupt resources",
+				pcibr_soft->bs_name);
 			/* yes, we leak resources here. */
 			return 0;
 		    }
@@ -432,25 +351,20 @@ pcibr_intr_alloc(vertex_hdl_t pconn_vhdl
 		     */
 		    xtalk_intr_free(xtalk_intr);
 		    xtalk_intr = *xtalk_intr_p;
-#if PARANOID
-		    /* once xtalk_intr is set, we never clear it,
-		     * so if the CAS fails above, this condition
-		     * can "never happen" ...
-		     */
-		    if (!xtalk_intr) {
-			printk(KERN_ALERT  
-				"pcibr_intr_alloc %v: unable to set xtalk interrupt resources",
-				xconn_vhdl);
-			/* yes, we leak resources here. */
-			return 0;
-		    }
-#endif
 		}
 	    }
 
 	    pcibr_intr->bi_ibits |= 1 << pcibr_int_bit;
 
-	    NEW(intr_entry);
+	    intr_entry = kmalloc(sizeof (*(intr_entry)), GFP_KERNEL);
+	    if ( !intr_entry ) {
+		printk(KERN_ALERT "pcibr_intr_alloc %s: "
+			"unable to get memory",
+			pcibr_soft->bs_name);
+		return 0;
+	    }
+	    memset(intr_entry, 0, sizeof (*(intr_entry)));
+
 	    intr_entry->il_next = NULL;
 	    intr_entry->il_intr = pcibr_intr;
 	    intr_entry->il_wrbf = &(bridge->b_wr_req_buf[pciio_slot].reg);
@@ -458,8 +372,8 @@ pcibr_intr_alloc(vertex_hdl_t pconn_vhdl
 		&pcibr_soft->bs_intr[pcibr_int_bit].bsi_pcibr_intr_wrap.iw_list;
 
 	    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pconn_vhdl,
-			"Bridge bit 0x%x wrap=0x%x\n", pcibr_int_bit,
-			pcibr_soft->bs_intr[pcibr_int_bit].bsi_pcibr_intr_wrap));
+			"Bridge bit 0x%x wrap=0x%lx\n", pcibr_int_bit,
+			&(pcibr_soft->bs_intr[pcibr_int_bit].bsi_pcibr_intr_wrap)));
 
 	    if (compare_and_swap_ptr((void **) intr_list_p, NULL, intr_entry)) {
 		/* we are the first interrupt on this bridge bit.
@@ -476,7 +390,7 @@ pcibr_intr_alloc(vertex_hdl_t pconn_vhdl
 		 * and we replaced it, so we
 		 * don't need our intr_entry.
 		 */
-		DEL(intr_entry);
+		kfree(intr_entry);
 		PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pconn_vhdl,
 			    "INT 0x%x (bridge bit %d) replaces erased first\n",
 			    pcibr_int_bits, pcibr_int_bit));
@@ -499,7 +413,7 @@ pcibr_intr_alloc(vertex_hdl_t pconn_vhdl
 		     * and we replaced it, so we
 		     * don't need our intr_entry.
 		     */
-		    DEL(intr_entry);
+		    kfree(intr_entry);
 
 		    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pconn_vhdl,
 				"INT 0x%x (bridge bit %d) replaces erase Nth\n",
@@ -522,12 +436,11 @@ pcibr_intr_alloc(vertex_hdl_t pconn_vhdl
 	}
     }
 
-#if DEBUG && INTR_DEBUG
-    printk("%v pcibr_intr_alloc complete\n", pconn_vhdl);
-#endif
     hub_intr = (hub_intr_t)xtalk_intr;
     pcibr_intr->bi_irq = hub_intr->i_bit;
     pcibr_intr->bi_cpu = hub_intr->i_cpuid;
+    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pconn_vhdl,
+		"pcibr_intr_alloc complete: pcibr_intr=0x%lx\n", pcibr_intr));
     return pcibr_intr;
 }
 
@@ -582,7 +495,7 @@ pcibr_intr_free(pcibr_intr_t pcibr_intr)
 	    }
 	}
     }
-    DEL(pcibr_intr);
+    kfree(pcibr_intr);
 }
 
 void
@@ -619,8 +532,8 @@ pcibr_intr_connect(pcibr_intr_t pcibr_in
 	return -1;
 
     PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ALLOC, pcibr_intr->bi_dev,
-		"pcibr_intr_connect: intr_func=0x%x\n",
-		pcibr_intr));
+		"pcibr_intr_connect: intr_func=0x%lx, intr_arg=0x%lx\n",
+		intr_func, intr_arg));
 
     pcibr_intr->bi_func = intr_func;
     pcibr_intr->bi_arg = intr_arg;
@@ -653,10 +566,7 @@ pcibr_intr_connect(pcibr_intr_t pcibr_in
 	     * Use the pcibr wrapper function to handle all Bridge interrupts
 	     * regardless of whether the interrupt line is shared or not.
 	     */
-	    if (IS_PIC_SOFT(pcibr_soft)) 
-		int_addr = (void *)&(bridge->p_int_addr_64[pcibr_int_bit]);
-	    else
-		int_addr = (void *)&(bridge->b_int_addr[pcibr_int_bit].addr);
+	    int_addr = (void *)&(bridge->p_int_addr_64[pcibr_int_bit]);
 
 	    xtalk_intr_connect(xtalk_intr, pcibr_intr_func, (intr_arg_t) intr_wrap,
 					(xtalk_intr_setfunc_t) pcibr_setpciint,
@@ -675,8 +585,7 @@ pcibr_intr_connect(pcibr_intr_t pcibr_in
 	 * On PIC we must write 64-bit MMRs with 64-bit stores
 	 */
 	s = pcibr_lock(pcibr_soft);
-	if (IS_PIC_SOFT(pcibr_soft) &&
-			PCIBR_WAR_ENABLED(PV854697, pcibr_soft)) {
+	if (PCIBR_WAR_ENABLED(PV854697, pcibr_soft)) {
 	    int_enable = bridge->p_int_enable_64;
 	    int_enable |= pcibr_int_bits;
 	    bridge->p_int_enable_64 = int_enable;
@@ -726,11 +635,8 @@ pcibr_intr_disconnect(pcibr_intr_t pcibr
     if (!pcibr_int_bits)
 	return;
 
-    /* PIC WAR. PV# 854697
-     * On PIC we must write 64-bit MMRs with 64-bit stores
-     */
     s = pcibr_lock(pcibr_soft);
-    if (IS_PIC_SOFT(pcibr_soft) && PCIBR_WAR_ENABLED(PV854697, pcibr_soft)) {
+    if (PCIBR_WAR_ENABLED(PV854697, pcibr_soft)) {
 	int_enable = bridge->p_int_enable_64;
 	int_enable &= ~pcibr_int_bits;
 	bridge->p_int_enable_64 = int_enable;
@@ -775,10 +681,7 @@ pcibr_intr_disconnect(pcibr_intr_t pcibr
             if (!pcibr_soft->bs_intr[pcibr_int_bit].bsi_pcibr_intr_wrap.iw_shared)
                 continue;
 
-            if (IS_PIC_SOFT(pcibr_soft))
-                int_addr = (void *)&(bridge->p_int_addr_64[pcibr_int_bit]);
-            else
-                int_addr = (void *)&(bridge->b_int_addr[pcibr_int_bit].addr);
+            int_addr = (void *)&(bridge->p_int_addr_64[pcibr_int_bit]);
 
 	    xtalk_intr_connect(pcibr_soft->bs_intr[pcibr_int_bit].bsi_xtalk_intr,
 				pcibr_intr_func, (intr_arg_t) intr_wrap,
@@ -856,7 +759,7 @@ pcibr_setwidint(xtalk_intr_t intr)
 		printk(KERN_WARNING  "NEW=0x%x/0x%x  OLD=0x%x/0x%x\n",
 			NEW_b_wid_int_upper, NEW_b_wid_int_lower,
 			OLD_b_wid_int_upper, OLD_b_wid_int_lower);
-		PRINT_PANIC("PCI Bridge interrupt targetting error\n");
+		panic("PCI Bridge interrupt targetting error\n");
 	}
     }
 
@@ -950,8 +853,7 @@ pcibr_intr_func(intr_arg_t arg)
 	 * interrupt problem.   Briefly disable the enable bit for
 	 * this device.
 	 */
-	if (IS_PIC_SOFT(pcibr_soft) &&
-			PCIBR_WAR_ENABLED(PV855272, pcibr_soft)) {
+	if (PCIBR_WAR_ENABLED(PV855272, pcibr_soft)) {
 		unsigned s;
 
 		/* disable-enable interrupts for this bridge pin */
@@ -986,26 +888,27 @@ pcibr_intr_func(intr_arg_t arg)
 	    for (list = wrap->iw_list; list != NULL; list = list->il_next) {
 		if ((intr = list->il_intr) && (intr->bi_flags & PCIIO_INTR_CONNECTED)) {
 
-		    /*
-		     * This device may have initiated write
-		     * requests since the bridge last saw
-		     * an edge on this interrupt input; flushing
-		     * the buffer prior to invoking the handler
-		     * should help but may not be sufficient if we 
-		     * get more requests after the flush, followed
-		     * by the card deciding it wants service, before
-		     * the interrupt handler checks to see if things need
-		     * to be done.
-		     *
-		     * There is a similar race condition if
-		     * an interrupt handler loops around and
-		     * notices further service is required.
-		     * Perhaps we need to have an explicit
-		     * call that interrupt handlers need to
-		     * do between noticing that DMA to memory
-		     * has completed, but before observing the
-		     * contents of memory?
-		     */
+
+		/*
+		 * This device may have initiated write
+		 * requests since the bridge last saw
+		 * an edge on this interrupt input; flushing
+		 * the buffer prior to invoking the handler
+		 * should help but may not be sufficient if we 
+		 * get more requests after the flush, followed
+		 * by the card deciding it wants service, before
+		 * the interrupt handler checks to see if things need
+		 * to be done.
+		 *
+		 * There is a similar race condition if
+		 * an interrupt handler loops around and
+		 * notices further service is requred.
+		 * Perhaps we need to have an explicit
+		 * call that interrupt handlers need to
+		 * do between noticing that DMA to memory
+		 * has completed, but before observing the
+		 * contents of memory?
+		 */
 
 		    if ((do_nonthreaded) && (!is_threaded)) {
 			/* Non-threaded -  Call the interrupt handler at interrupt level */
@@ -1061,8 +964,7 @@ pcibr_intr_func(intr_arg_t arg)
 	     * On PIC we must write 64-bit MMRs with 64-bit stores
 	     */
 	    s = pcibr_lock(pcibr_soft);
-	    if (IS_PIC_SOFT(pcibr_soft) &&
-				PCIBR_WAR_ENABLED(PV854697, pcibr_soft)) {
+	    if (PCIBR_WAR_ENABLED(PV854697, pcibr_soft)) {
 		int_enable = bridge->p_int_enable_64;
 		int_enable &= ~mask;
 		bridge->p_int_enable_64 = int_enable;
diff -puN /dev/null arch/ia64/sn/io/sn2/pcibr/pcibr_reg.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/ia64/sn/io/sn2/pcibr/pcibr_reg.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,107 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2003 Silicon Graphics, Inc. All rights reserved.
+ */
+
+#include <linux/types.h>
+#include <asm/sn/sgi.h>
+#include <asm/sn/iograph.h>
+#include <asm/sn/addrs.h>
+#include <asm/sn/pci/pcibr.h>
+#include <asm/sn/pci/pcibr_private.h>
+#include <asm/sn/pci/pci_defs.h>
+
+#define IS_IOADDR(ptr) (!(((uint64_t)(ptr) & CAC_BASE) == CAC_BASE))
+
+/*
+ * Control Register Access -- Read/Write                            0000_0020
+ */
+
+uint64_t
+pcireg_control_get(void *ptr)
+{
+	uint64_t ret = 0;
+	pic_t *bridge;
+
+	if (IS_IOADDR(ptr))
+		bridge = (pic_t *) ptr;
+	else
+		bridge = (pic_t *) ((pcibr_soft_t) (ptr))->bs_base;
+
+	ret = ((pic_t *) bridge)->p_wid_control;
+	return ret;
+}
+
+/*
+ * Interrupt Status Register Access -- Read Only                    0000_0100
+ */
+uint64_t
+pcireg_intr_status_get(void *ptr)
+{
+	short bridge_type;
+	pic_t *bridge;
+	uint64_t ret = 0;
+
+	if (IS_IOADDR(ptr))
+		bridge = (pic_t *) ptr;
+	else
+		bridge = (pic_t *) ((pcibr_soft_t) (ptr))->bs_base;
+
+	ret = ((pic_t *) bridge)->p_int_status;
+	return ret;
+}
+
+void
+pcireg_intr_enable_bit_clr(void *ptr, uint64_t bits)
+{
+	pic_t *bridge;
+
+	if (IS_IOADDR(ptr))
+		bridge = (pic_t *) ptr;
+	else
+		bridge = (pic_t *) ((pcibr_soft_t) (ptr))->bs_base;
+	bridge->p_int_enable &= ~bits;
+}
+
+void
+pcireg_intr_enable_bit_set(void *ptr, uint64_t bits)
+{
+	pic_t *bridge;
+
+	if (IS_IOADDR(ptr))
+		bridge = (pic_t *) ptr;
+	else
+		bridge = (pic_t *) ((pcibr_soft_t) (ptr))->bs_base;
+	bridge->p_int_enable |= bits;
+}
+
+void
+pcireg_intr_addr_addr_set(void *ptr, int int_n, uint64_t addr)
+{
+	pic_t *bridge;
+
+	if (IS_IOADDR(ptr))
+		bridge = (pic_t *) ptr;
+	else
+		bridge = (pic_t *) ((pcibr_soft_t) (ptr))->bs_base;
+	bridge->p_int_addr[int_n] &= ~(0x0000FFFFFFFFFFFF);
+	bridge->p_int_addr[int_n] |= (addr & 0x0000FFFFFFFFFFFF);
+}
+
+/*
+ * Force Interrupt Register Access -- Write Only        0000_01C0 - 0000_01F8
+ */
+void
+pcireg_force_intr_set(void *ptr, int int_n)
+{
+	pic_t *bridge;
+
+	if (IS_IOADDR(ptr))
+		bridge = (pic_t *) ptr;
+	else
+		bridge = (pic_t *) ((pcibr_soft_t) (ptr))->bs_base;
+	bridge->p_force_pin[int_n] = 1;
+}
diff -puN arch/ia64/sn/io/sn2/pcibr/pcibr_rrb.c~linus arch/ia64/sn/io/sn2/pcibr/pcibr_rrb.c
--- 25/arch/ia64/sn/io/sn2/pcibr/pcibr_rrb.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/pcibr/pcibr_rrb.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
 /*
- *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -8,26 +7,12 @@
  */
 
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/module.h>
 #include <asm/sn/sgi.h>
-#include <asm/sn/sn_cpuid.h>
-#include <asm/sn/addrs.h>
-#include <asm/sn/arch.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/pci/bridge.h>
 #include <asm/sn/pci/pciio.h>
 #include <asm/sn/pci/pcibr.h>
 #include <asm/sn/pci/pcibr_private.h>
 #include <asm/sn/pci/pci_defs.h>
-#include <asm/sn/prio.h>
-#include <asm/sn/xtalk/xbow.h>
-#include <asm/sn/io.h>
-#include <asm/sn/sn_private.h>
 
 void              do_pcibr_rrb_clear(bridge_t *, int);
 void              do_pcibr_rrb_flush(bridge_t *, int);
@@ -87,7 +72,7 @@ do_pcibr_rrb_count_valid(bridge_t *bridg
 			 pciio_slot_t slot,
 			 int vchan)
 {
-    bridgereg_t tmp;
+    uint64_t tmp;
     uint16_t enable_bit, vchan_bits, pdev_bits, rrb_bits;
     int rrb_index, cnt=0;
 
@@ -120,7 +105,7 @@ int
 do_pcibr_rrb_count_avail(bridge_t *bridge,
 			 pciio_slot_t slot)
 {
-    bridgereg_t tmp;
+    uint64_t tmp;
     uint16_t enable_bit;
     int rrb_index, cnt=0;
     
@@ -156,7 +141,7 @@ do_pcibr_rrb_alloc(bridge_t *bridge,
 		   int vchan,
 		   int more)
 {
-    bridgereg_t reg, tmp = (bridgereg_t)0;
+    uint64_t reg, tmp = 0;
     uint16_t enable_bit, vchan_bits, pdev_bits, rrb_bits;
     int rrb_index;
     
@@ -201,7 +186,7 @@ do_pcibr_rrb_free(bridge_t *bridge,
 		  int vchan,
 		  int less)
 {
-    bridgereg_t reg, tmp = (bridgereg_t)0, clr = 0;
+    uint64_t reg, tmp = 0, clr = 0;
     uint16_t enable_bit, vchan_bits, pdev_bits, rrb_bits;
     int rrb_index;
     
@@ -273,7 +258,7 @@ do_pcibr_rrb_free_all(pcibr_soft_t pcibr
 void
 do_pcibr_rrb_clear(bridge_t *bridge, int rrb)
 {
-    bridgereg_t             status;
+    uint64_t             status;
 
     /* bridge_lock must be held;
      * this RRB must be disabled.
@@ -365,7 +350,7 @@ pcibr_rrb_flush(vertex_hdl_t pconn_vhdl)
     pciio_slot_t  slot = PCIBR_INFO_SLOT_GET_INT(pciio_info);
     bridge_t	 *bridge = pcibr_soft->bs_base;
 
-    bridgereg_t tmp;
+    uint64_t tmp;
     uint16_t enable_bit, pdev_bits, rrb_bits, rrb_mask;
     int rrb_index;
     unsigned long s;
@@ -402,18 +387,8 @@ pcibr_wrb_flush(vertex_hdl_t pconn_vhdl)
     volatile bridgereg_t   *wrb_flush;
 
     wrb_flush = &(bridge->b_wr_req_buf[pciio_slot].reg);
-    if ( IS_PIC_SOFT(pcibr_soft) ) {
-	while (*wrb_flush)
-		;
-    }
-    else {
-	if (io_get_sh_swapper(NASID_GET(bridge))) {
-		while (BRIDGE_REG_GET32((wrb_flush)));
-	} else {
-		while (*wrb_flush)
-			;
-	}
-    }
+    while (*wrb_flush)
+	;
     return(0);
 }
 
@@ -711,24 +686,17 @@ pcibr_slot_initial_rrb_alloc(vertex_hdl_
     for (vchan = 0; vchan < vchan_total; vchan++) 
         chan[vchan] = do_pcibr_rrb_count_valid(bridge, slot, vchan);
 
-    if (IS_PIC_SOFT(pcibr_soft)) {
- 	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_RRB, pcibr_vhdl,
+    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_RRB, pcibr_vhdl,
 	    "pcibr_slot_initial_rrb_alloc: slot %d started with %d+%d+%d+%d\n",
 	    PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), 
 	    chan[VCHAN0], chan[VCHAN1], chan[VCHAN2], chan[VCHAN3]));
-    } else {
-	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_RRB, pcibr_vhdl,
-	    "pcibr_slot_initial_rrb_alloc: slot %d started with %d+%d\n",
-	    PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), 
-	    chan[VCHAN0], chan[VCHAN1]));
-    }
 
     /* Do we really need any?
      */
     pcibr_infoh = pcibr_soft->bs_slot[slot].bss_infos;
     pcibr_info = pcibr_infoh[0];
 
-    if (PCIBR_WAR_ENABLED(PV856866, pcibr_soft) && IS_PIC_SOFT(pcibr_soft) &&
+    if (PCIBR_WAR_ENABLED(PV856866, pcibr_soft) &&
                         (slot == 2 || slot == 3) &&
                         (pcibr_info->f_vendor == PCIIO_VENDOR_ID_NONE) &&
                         !pcibr_soft->bs_slot[slot].has_host) {
@@ -868,13 +836,8 @@ pcibr_rrb_debug(char *calling_func, pcib
                     "%s: rrbs available, even=%d, odd=%d\n", calling_func,
                     pcibr_soft->bs_rrb_avail[0], pcibr_soft->bs_rrb_avail[1]));
 
-        if (IS_PIC_SOFT(pcibr_soft)) {
-            PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_RRB, pcibr_soft->bs_vhdl,
+        PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_RRB, pcibr_soft->bs_vhdl,
                         "\tslot\tvchan0\tvchan1\tvchan2\tvchan3\treserved\n"));
-        } else {
-	    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_RRB, pcibr_soft->bs_vhdl,
-		        "\tslot\tvchan0\tvchan1\treserved\n"));
-        }
 
         for (slot=0; slot < PCIBR_NUM_SLOTS(pcibr_soft); slot++) {
 	    /*
@@ -882,22 +845,13 @@ pcibr_rrb_debug(char *calling_func, pcib
              * attempting to call PCIBR_DEBUG_ALWAYS() with more than 5 printf
              * arguments fails so sprintf() it into a temporary string.
              */
-	    if (IS_PIC_SOFT(pcibr_soft)) {
-                sprintf(tmp_str, "\t %d\t  %d\t  %d\t  %d\t  %d\t  %d\n", 
+            sprintf(tmp_str, "\t %d\t  %d\t  %d\t  %d\t  %d\t  %d\n", 
 		        PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot),
                         0xFFF & pcibr_soft->bs_rrb_valid[slot][VCHAN0],
                         0xFFF & pcibr_soft->bs_rrb_valid[slot][VCHAN1],
                         0xFFF & pcibr_soft->bs_rrb_valid[slot][VCHAN2],
                         0xFFF & pcibr_soft->bs_rrb_valid[slot][VCHAN3],
                         pcibr_soft->bs_rrb_res[slot]);
-	    } else {
-	        sprintf(tmp_str, "\t %d\t  %d\t  %d\t  %d\n", 
-		        PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot),
-		        0xFFF & pcibr_soft->bs_rrb_valid[slot][VCHAN0],
-		        0xFFF & pcibr_soft->bs_rrb_valid[slot][VCHAN1],
-		        pcibr_soft->bs_rrb_res[slot]);
-	    }
-    
             PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_RRB, pcibr_soft->bs_vhdl,
                         "%s", tmp_str));
         }
diff -puN arch/ia64/sn/io/sn2/pcibr/pcibr_slot.c~linus arch/ia64/sn/io/sn2/pcibr/pcibr_slot.c
--- 25/arch/ia64/sn/io/sn2/pcibr/pcibr_slot.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/pcibr/pcibr_slot.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
 /*
- *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -8,26 +7,14 @@
  */
 
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/pci.h>
 #include <asm/sn/sgi.h>
 #include <asm/sn/sn_cpuid.h>
-#include <asm/sn/addrs.h>
-#include <asm/sn/arch.h>
+#include <asm/uaccess.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/pci/bridge.h>
 #include <asm/sn/pci/pciio.h>
 #include <asm/sn/pci/pcibr.h>
 #include <asm/sn/pci/pcibr_private.h>
 #include <asm/sn/pci/pci_defs.h>
-#include <asm/sn/prio.h>
-#include <asm/sn/xtalk/xbow.h>
-#include <asm/sn/io.h>
 #include <asm/sn/sn_private.h>
 
 extern pcibr_info_t     pcibr_info_get(vertex_hdl_t);
@@ -36,6 +23,8 @@ extern pcibr_info_t     pcibr_device_inf
 extern int		pcibr_slot_initial_rrb_alloc(vertex_hdl_t,pciio_slot_t);
 extern int		pcibr_pcix_rbars_calc(pcibr_soft_t);
 
+extern char *pci_space[];
+
 int pcibr_slot_info_init(vertex_hdl_t pcibr_vhdl, pciio_slot_t slot);
 int pcibr_slot_info_free(vertex_hdl_t pcibr_vhdl, pciio_slot_t slot);
 int pcibr_slot_addr_space_init(vertex_hdl_t pcibr_vhdl,  pciio_slot_t slot);
@@ -57,24 +46,6 @@ cfg_p pcibr_find_capability(cfg_p, unsig
 extern uint64_t  do_pcibr_config_get(cfg_p, unsigned, unsigned);
 void do_pcibr_config_set(cfg_p, unsigned, unsigned, uint64_t); 
 
-int pcibr_slot_attach(vertex_hdl_t pcibr_vhdl, pciio_slot_t slot,
-                int drv_flags, char *l1_msg, int *sub_errorp);
-
-int pcibr_slot_info_return(pcibr_soft_t pcibr_soft, pciio_slot_t slot,
-                 pcibr_slot_info_resp_t respp);
-
-extern vertex_hdl_t baseio_pci_vhdl;
-int scsi_ctlr_nums_add(vertex_hdl_t, vertex_hdl_t);
-
-
-/* For now .... */
-/*
- * PCI Hot-Plug Capability Flags
-
- */
-#define D_PCI_HOT_PLUG_ATTACH  0x200  /* Driver supports PCI hot-plug attach */
-#define D_PCI_HOT_PLUG_DETACH  0x400  /* Driver supports PCI hot-plug detach */
-
 
 /* 
  * PCI-X Max Outstanding Split Transactions translation array and Max Memory
@@ -86,158 +57,6 @@ int scsi_ctlr_nums_add(vertex_hdl_t, ver
 int max_splittrans_to_numbuf[MAX_SPLIT_TABLE] = {1, 2, 3, 4, 8, 12, 16, 32};
 int max_readcount_to_bufsize[MAX_READCNT_TABLE] = {512, 1024, 2048, 4096 };
 
-
-/*==========================================================================
- *	BRIDGE PCI SLOT RELATED IOCTLs
- */
-
-/*
- * pcibr_slot_startup
- *	Software start-up the PCI slot.
- */
-
-#ifdef PIC_LATER
-
-int
-pcibr_slot_startup(vertex_hdl_t pcibr_vhdl, pcibr_slot_req_t reqp)
-{
-    pcibr_soft_t                   pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-    pciio_slot_t                   slot;
-    int                            error = 0;
-    char                           l1_msg[BRL1_QSIZE+1];
-    struct pcibr_slot_up_resp_s    tmp_up_resp;
-
-    /* Make sure that we are dealing with a bridge device vertex */
-    if (!pcibr_soft) {
-        return(PCI_NOT_A_BRIDGE);
-    }
-
-    /* req_slot is the 'external' slot number, convert for internal use */
-    slot = PCIBR_SLOT_TO_DEVICE(pcibr_soft, reqp->req_slot);
-
-    /* Check for the valid slot */
-    if (!PCIBR_VALID_SLOT(pcibr_soft, slot))
-        return(PCI_NOT_A_SLOT);
-
-#ifdef PIC_LATER
-    /* Acquire update access to the bus */
-    mrlock(pcibr_soft->bs_bus_lock, MR_UPDATE, PZERO);
-#endif
-
-    if (pcibr_soft->bs_slot[slot].slot_status & SLOT_STARTUP_CMPLT) {
-        error = PCI_SLOT_ALREADY_UP;
-        goto startup_unlock;
-    }
-
-    error = pcibr_slot_attach(pcibr_vhdl, slot, D_PCI_HOT_PLUG_ATTACH,
-                              l1_msg, &tmp_up_resp.resp_sub_errno);
-
-    strncpy(tmp_up_resp.resp_l1_msg, l1_msg, L1_QSIZE);
-    tmp_up_resp.resp_l1_msg[L1_QSIZE] = '\0';
-
-    if (COPYOUT(&tmp_up_resp, reqp->req_respp.up, reqp->req_size)) {
-        return(EFAULT);
-    }
-
-    startup_unlock:
-
-#ifdef PIC_LATER
-    /* Release the bus lock */
-    mrunlock(pcibr_soft->bs_bus_lock);
-#endif
-    return(error);
-}
-
-/*
- * pcibr_slot_shutdown
- *	Software shut-down the PCI slot
- */
-int
-pcibr_slot_shutdown(vertex_hdl_t pcibr_vhdl, pcibr_slot_req_t reqp)
-{
-    pcibr_soft_t                   pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-    bridge_t                      *bridge;
-    pciio_slot_t                   slot;
-    int                            error = 0;
-    char                           l1_msg[BRL1_QSIZE+1];
-    struct pcibr_slot_down_resp_s  tmp_down_resp;
-    pciio_slot_t                   tmp_slot;
-
-    /* Make sure that we are dealing with a bridge device vertex */
-    if (!pcibr_soft) {
-        return(PCI_NOT_A_BRIDGE);
-    }
-
-    /* req_slot is the 'external' slot number, convert for internal use */
-    slot = PCIBR_SLOT_TO_DEVICE(pcibr_soft, reqp->req_slot);
-
-    bridge = pcibr_soft->bs_base;
-
-    /* Check for valid slot */
-    if (!PCIBR_VALID_SLOT(pcibr_soft, slot))
-        return(PCI_NOT_A_SLOT);
-
-#ifdef PIC_LATER
-    /* Acquire update access to the bus */
-    mrlock(pcibr_soft->bs_bus_lock, MR_UPDATE, PZERO);
-#endif
-
-    if ((pcibr_soft->bs_slot[slot].slot_status & SLOT_SHUTDOWN_CMPLT) ||
-        ((pcibr_soft->bs_slot[slot].slot_status & SLOT_STATUS_MASK) == 0)) {
-        error = PCI_SLOT_ALREADY_DOWN;
-        /*
-         * RJR - Should we invoke an L1 slot power-down command just in case
-         *       a previous shut-down failed to power-down the slot?
-         */
-        goto shutdown_unlock;
-    }
-
-    /* Do not allow a multi-function card to be hot-plug removed */
-    if (pcibr_soft->bs_slot[slot].bss_ninfo > 1) {
-        tmp_down_resp.resp_sub_errno = EPERM;
-        error = PCI_MULTI_FUNC_ERR;
-        goto shutdown_copyout;
-    }
-
-    /* Do not allow the last 33 MHz card to be removed */
-    if ((bridge->b_wid_control & BRIDGE_CTRL_BUS_SPEED_MASK) ==
-         BRIDGE_CTRL_BUS_SPEED_33) {
-        for (tmp_slot = pcibr_soft->bs_first_slot;
-             tmp_slot <= pcibr_soft->bs_last_slot; tmp_slot++)
-            if (tmp_slot != slot)
-                if (pcibr_soft->bs_slot[tmp_slot].slot_status & SLOT_POWER_UP) {
-                    error++;
-                    break;
-                }
-        if (!error) {
-            error = PCI_EMPTY_33MHZ;
-            goto shutdown_unlock;
-        }
-    }
-
-    error = pcibr_slot_detach(pcibr_vhdl, slot, D_PCI_HOT_PLUG_DETACH,
-                              l1_msg, &tmp_down_resp.resp_sub_errno);
-
-    strncpy(tmp_down_resp.resp_l1_msg, l1_msg, L1_QSIZE);
-    tmp_down_resp.resp_l1_msg[L1_QSIZE] = '\0';
-
-    shutdown_copyout:
-
-    if (COPYOUT(&tmp_down_resp, reqp->req_respp.down, reqp->req_size)) {
-        return(EFAULT);
-    }
-
-    shutdown_unlock:
-
-#ifdef PIC_LATER
-    /* Release the bus lock */
-    mrunlock(pcibr_soft->bs_bus_lock);
-#endif
-
-    return(error);
-}
-#endif	/* PIC_LATER */
-
 char *pci_space_name[] = {"NONE", 
 			  "ROM",
 			  "IO",
@@ -255,252 +74,6 @@ char *pci_space_name[] = {"NONE", 
 			  "",
 			  "BAD"};
 
-void
-pcibr_slot_func_info_return(pcibr_info_h pcibr_infoh,
-                            int func,
-                            pcibr_slot_func_info_resp_t funcp)
-{
-    pcibr_info_t                 pcibr_info = pcibr_infoh[func];
-    int                          win;
-
-    funcp->resp_f_status = 0;
-
-    if (!pcibr_info) {
-        return;
-    }
-
-    funcp->resp_f_status |= FUNC_IS_VALID;
-#if defined(SUPPORT_PRINTING_V_FORMAT)
-    sprintf(funcp->resp_f_slot_name, "%v", pcibr_info->f_vertex);
-#endif
-
-    funcp->resp_f_bus = pcibr_info->f_bus;
-    funcp->resp_f_slot = PCIBR_INFO_SLOT_GET_EXT(pcibr_info);
-    funcp->resp_f_func = pcibr_info->f_func;
-#if defined(SUPPORT_PRINTING_V_FORMAT)
-    sprintf(funcp->resp_f_master_name, "%v", pcibr_info->f_master);
-#endif
-    funcp->resp_f_pops = pcibr_info->f_pops;
-    funcp->resp_f_efunc = pcibr_info->f_efunc;
-    funcp->resp_f_einfo = pcibr_info->f_einfo;
-
-    funcp->resp_f_vendor = pcibr_info->f_vendor;
-    funcp->resp_f_device = pcibr_info->f_device;
-
-    for(win = 0 ; win < 6 ; win++) {
-        funcp->resp_f_window[win].resp_w_base =
-                                  pcibr_info->f_window[win].w_base;
-        funcp->resp_f_window[win].resp_w_size =
-                                  pcibr_info->f_window[win].w_size;
-        sprintf(funcp->resp_f_window[win].resp_w_space,
-                "%s",
-                pci_space_name[pcibr_info->f_window[win].w_space]);
-    }
-
-    funcp->resp_f_rbase = pcibr_info->f_rbase;
-    funcp->resp_f_rsize = pcibr_info->f_rsize;
-
-    for (win = 0 ; win < 4; win++) {
-        funcp->resp_f_ibit[win] = pcibr_info->f_ibit[win];
-    }
-
-    funcp->resp_f_att_det_error = pcibr_info->f_att_det_error;
-
-}
-
-int
-pcibr_slot_info_return(pcibr_soft_t             pcibr_soft,
-                       pciio_slot_t             slot,
-                       pcibr_slot_info_resp_t   respp)
-{
-    pcibr_soft_slot_t            pss;
-    int                          func;
-    bridge_t                    *bridge = pcibr_soft->bs_base;
-    reg_p                        b_respp;
-    pcibr_slot_info_resp_t       slotp;
-    pcibr_slot_func_info_resp_t  funcp;
-    extern void snia_kmem_free(void *, int);
-
-    slotp = snia_kmem_zalloc(sizeof(*slotp), 0);
-    if (slotp == NULL) {
-        return(ENOMEM);
-    }
-
-    pss = &pcibr_soft->bs_slot[slot];
-
-    slotp->resp_bs_bridge_mode = pcibr_soft->bs_bridge_mode;
-    slotp->resp_bs_bridge_type = pcibr_soft->bs_bridge_type;
-
-    slotp->resp_has_host = pss->has_host;
-    slotp->resp_host_slot = pss->host_slot;
-#if defined(SUPPORT_PRINTING_V_FORMAT)
-    sprintf(slotp->resp_slot_conn_name, "%v", pss->slot_conn);
-#else
-    sprintf(slotp->resp_slot_conn_name, "%p", (void *)pss->slot_conn);
-#endif
-    slotp->resp_slot_status = pss->slot_status;
-
-    slotp->resp_l1_bus_num = pcibr_widget_to_bus(pcibr_soft->bs_vhdl);
-    slotp->resp_bss_ninfo = pss->bss_ninfo;
-
-    for (func = 0; func < pss->bss_ninfo; func++) {
-        funcp = &(slotp->resp_func[func]);
-        pcibr_slot_func_info_return(pss->bss_infos, func, funcp);
-    }
-
-    sprintf(slotp->resp_bss_devio_bssd_space, "%s",
-            pci_space_name[pss->bss_devio.bssd_space]);
-    slotp->resp_bss_devio_bssd_base = pss->bss_devio.bssd_base;
-    slotp->resp_bss_device = pss->bss_device;
-
-    slotp->resp_bss_pmu_uctr = pss->bss_pmu_uctr;
-    slotp->resp_bss_d32_uctr = pss->bss_d32_uctr;
-    slotp->resp_bss_d64_uctr = pss->bss_d64_uctr;
-
-    slotp->resp_bss_d64_base = pss->bss_d64_base;
-    slotp->resp_bss_d64_flags = pss->bss_d64_flags;
-    slotp->resp_bss_d32_base = pss->bss_d32_base;
-    slotp->resp_bss_d32_flags = pss->bss_d32_flags;
-
-    slotp->resp_bss_ext_ates_active = pss->bss_ext_ates_active;
-
-    slotp->resp_bss_cmd_pointer = pss->bss_cmd_pointer;
-    slotp->resp_bss_cmd_shadow = pss->bss_cmd_shadow;
-
-    slotp->resp_bs_rrb_valid = pcibr_soft->bs_rrb_valid[slot][VCHAN0];
-    slotp->resp_bs_rrb_valid_v1 = pcibr_soft->bs_rrb_valid[slot][VCHAN1];
-    slotp->resp_bs_rrb_valid_v2 = pcibr_soft->bs_rrb_valid[slot][VCHAN2];
-    slotp->resp_bs_rrb_valid_v3 = pcibr_soft->bs_rrb_valid[slot][VCHAN3];
-    slotp->resp_bs_rrb_res = pcibr_soft->bs_rrb_res[slot];
-
-    if (slot & 1) {
-        b_respp = &bridge->b_odd_resp;
-    } else {
-        b_respp = &bridge->b_even_resp;
-    }
-
-    slotp->resp_b_resp = *b_respp;
-
-    slotp->resp_b_int_device = bridge->b_int_device;
-
-    if (IS_PIC_SOFT(pcibr_soft)) {
-	slotp->resp_p_int_enable = bridge->p_int_enable_64;
-	slotp->resp_p_int_host = bridge->p_int_addr_64[slot];
-    } else {
-	slotp->resp_b_int_enable = bridge->b_int_enable;
-	slotp->resp_b_int_host = bridge->b_int_addr[slot].addr;
-    }
-
-    if (COPYOUT(slotp, respp, sizeof(*respp))) {
-        return(EFAULT);
-    }
-
-    snia_kmem_free(slotp, sizeof(*slotp));
-
-    return(0);
-}
-
-/*
- * pcibr_slot_query
- *	Return information about the PCI slot maintained by the infrastructure.
- *	Information is requested in the request structure.
- *
- *      Information returned in the response structure:
- *		Slot hwgraph name
- *		Vendor/Device info
- *		Base register info
- *		Interrupt mapping from device pins to the bridge pins
- *		Devio register
- *		Software RRB info
- *		RRB register info
- *		Host/Gues info
- *		PCI Bus #,slot #, function #
- *		Slot provider hwgraph name
- *		Provider Functions
- *		Error handler
- *		DMA mapping usage counters
- *		DMA direct translation info
- *		External SSRAM workaround info
- */
-int
-pcibr_slot_query(vertex_hdl_t pcibr_vhdl, pcibr_slot_req_t reqp)
-{
-    pcibr_soft_t            pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-    pciio_slot_t            slot;
-    pciio_slot_t            tmp_slot;
-    pcibr_slot_info_resp_t  respp = reqp->req_respp.query;
-    int                     size = reqp->req_size;
-    int                     error = 0;
-
-    /* Make sure that we are dealing with a bridge device vertex */
-    if (!pcibr_soft) {
-        return(PCI_NOT_A_BRIDGE);
-    }
-
-    /* req_slot is the 'external' slot number, convert for internal use */
-    slot = PCIBR_SLOT_TO_DEVICE(pcibr_soft, reqp->req_slot);
-
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HOTPLUG, pcibr_vhdl,
-                "pcibr_slot_query: pcibr_soft=0x%x, slot=%d, reqp=0x%x\n",
-                pcibr_soft, slot, reqp));
-
-    /* Make sure that we have a valid PCI slot number or PCIIO_SLOT_NONE */
-    if ((!PCIBR_VALID_SLOT(pcibr_soft, slot)) && (slot != PCIIO_SLOT_NONE)) {
-        return(PCI_NOT_A_SLOT);
-    }
-
-    /* Return information for the requested PCI slot */
-    if (slot != PCIIO_SLOT_NONE) {
-        if (size < sizeof(*respp)) {
-            return(PCI_RESP_AREA_TOO_SMALL);
-        }
-
-#ifdef PIC_LATER
-        /* Acquire read access to the bus */
-        mrlock(pcibr_soft->bs_bus_lock, MR_ACCESS, PZERO);
-#endif
-        error = pcibr_slot_info_return(pcibr_soft, slot, respp);
-
-#ifdef PIC_LATER
-        /* Release the bus lock */
-        mrunlock(pcibr_soft->bs_bus_lock);
-#endif
-        return(error);
-    }
-
-    /* Return information for all the slots */
-    for (tmp_slot = pcibr_soft->bs_min_slot; 
-		tmp_slot < PCIBR_NUM_SLOTS(pcibr_soft); tmp_slot++) {
-
-        if (size < sizeof(*respp)) {
-            return(PCI_RESP_AREA_TOO_SMALL);
-        }
-
-#ifdef PIC_LATER
-        /* Acquire read access to the bus */
-        mrlock(pcibr_soft->bs_bus_lock, MR_ACCESS, PZERO);
-#endif
-        error = pcibr_slot_info_return(pcibr_soft, tmp_slot, respp);
-
-#ifdef PCI_LATER
-        /* Release the bus lock */
-        mrunlock(pcibr_soft->bs_bus_lock);
-#endif
-        if (error) {
-            return(error);
-        }
-
-        ++respp;
-        size -= sizeof(*respp);
-    }
-
-    return(error);
-}
-
-#define PROBE_LOCK 0	/* FIXME: we're attempting to lock around accesses
-			 * to b_int_enable.   This hangs pcibr_probe_slot()
-			 */
-
 /*
  * pcibr_slot_info_init
  *	Probe for this slot and see if it is populated.
@@ -553,14 +126,8 @@ pcibr_slot_info_init(vertex_hdl_t 	pcibr
     /* Try to read the device-id/vendor-id from the config space */
     cfgw = pcibr_slot_config_addr(bridge, slot, 0);
 
-#if PROBE_LOCK
-    s = pcibr_lock(pcibr_soft);
-#endif
     if (pcibr_probe_slot(bridge, cfgw, &idword)) 
 	return(ENODEV);
-#if PROBE_LOCK
-    pcibr_unlock(pcibr_soft, s);
-#endif
 
     slotp = &pcibr_soft->bs_slot[slot];
     slotp->slot_status |= SLOT_POWER_UP;
@@ -591,16 +158,10 @@ pcibr_slot_info_init(vertex_hdl_t 	pcibr
     if (htype & 0x80) {		/* MULTIFUNCTION */
 	for (func = 1; func < 8; ++func) {
 	    cfgw = pcibr_func_config_addr(bridge, 0, slot, func, 0);
-#if PROBE_LOCK
-            s = pcibr_lock(pcibr_soft);
-#endif
 	    if (pcibr_probe_slot(bridge, cfgw, &idwords[func])) {
 		pfail |= 1 << func;
 		continue;
 	    }
-#if PROBE_LOCK
-            pcibr_unlock(pcibr_soft, s);
-#endif
 	    vendor = 0xFFFF & idwords[func];
 	    if (vendor == 0xFFFF) {
 		pfail |= 1 << func;
@@ -611,7 +172,11 @@ pcibr_slot_info_init(vertex_hdl_t 	pcibr
 	}
         cfgw = pcibr_slot_config_addr(bridge, slot, 0);
     }
-    NEWA(pcibr_infoh, nfunc);
+    pcibr_infoh = kmalloc(nfunc*sizeof (*(pcibr_infoh)), GFP_KERNEL);
+    if ( !pcibr_infoh ) {
+	return ENOMEM;
+    }
+    memset(pcibr_infoh, 0, nfunc*sizeof (*(pcibr_infoh)));
     
     pcibr_soft->bs_slot[slot].bss_ninfo = nfunc;
     pcibr_soft->bs_slot[slot].bss_infos = pcibr_infoh;
@@ -641,39 +206,9 @@ pcibr_slot_info_init(vertex_hdl_t 	pcibr
 	}
 
 	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_CONFIG, pcibr_vhdl,
-                "pcibr_slot_info_init: slot=%d, func=%d, cfgw=0x%x\n",
+                "pcibr_slot_info_init: slot=%d, func=%d, cfgw=0x%lx\n",
 		PCIBR_DEVICE_TO_SLOT(pcibr_soft,slot), func, cfgw));
 
-#ifdef PIC_LATER
-        /*
-         * Check for a Quad ATM PCI "card" and return all the PCI bus
-         * memory and I/O space.  This will work-around an apparent
-         * hardware problem with the Quad ATM XIO card handling large
-         * PIO addresses.  Releasing all the space for use by the card
-         * will lower the PIO addresses with the PCI bus address space.
-         * This is OK since the PROM did not assign any BAR addresses. 
-         *
-         * Only release all the PCI bus addresses once.
-         *
-         */
-        if ((vendor == LINC_VENDOR_ID_NUM) && (device == LINC_DEVICE_ID_NUM)) {
-            iopaddr_t               prom_base_addr = pcibr_soft->bs_xid << 24;
-            int                     prom_base_size = 0x1000000;
-
-            if (!(pcibr_soft->bs_bus_addr_status & PCIBR_BUS_ADDR_MEM_FREED)) {
-		pciio_device_win_populate(&pcibr_soft->bs_mem_win_map,
-					  prom_base_addr, prom_base_size);
-                pcibr_soft->bs_bus_addr_status |= PCIBR_BUS_ADDR_MEM_FREED;
-            }
-
-            if (!(pcibr_soft->bs_bus_addr_status & PCIBR_BUS_ADDR_IO_FREED)) {
-		pciio_device_win_populate(&pcibr_soft->bs_io_win_map,
-					  prom_base_addr, prom_base_size);
-                pcibr_soft->bs_bus_addr_status |= PCIBR_BUS_ADDR_IO_FREED;
-            }
-        }
-#endif	/* PIC_LATER */
-
 	/* 
 	 * If the latency timer has already been set, by prom or by the
 	 * card itself, use that value.  Otherwise look at the device's
@@ -745,19 +280,15 @@ pcibr_slot_info_init(vertex_hdl_t 	pcibr
 	     */
 	    if (!(pcix_cap = pcibr_find_capability(cfgw, PCI_CAP_PCIX))) {
 		printk(KERN_WARNING
-#if defined(SUPPORT_PRINTING_V_FORMAT)
-		        "%v: Bus running in PCI-X mode, But card in slot %d, "
-		        "func %d not PCI-X capable\n", pcibr_vhdl, slot, func);
-#else
-		        "0x%lx: Bus running in PCI-X mode, But card in slot %d, "
-		        "func %d not PCI-X capable\n", (unsigned long)pcibr_vhdl, slot, func);
-#endif
+		        "%s: Bus running in PCI-X mode, But card in slot %d, "
+		        "func %d not PCI-X capable\n", 
+			pcibr_soft->bs_name, slot, func);
 		pcibr_device_info_new(pcibr_soft, slot, PCIIO_FUNC_NONE,
 		               PCIIO_VENDOR_ID_NONE, PCIIO_DEVICE_ID_NONE);
 		continue;
 	    }
 	    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_CONFIG, pcibr_vhdl,
-                    "pcibr_slot_info_init: PCI-X capability at 0x%x for "
+                    "pcibr_slot_info_init: PCI-X capability at 0x%lx for "
 		    "slot=%d, func=%d\n", 
 		    pcix_cap, PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), func));
 	} else {
@@ -957,7 +488,7 @@ pcibr_slot_info_free(vertex_hdl_t pcibr_
     pcibr_device_info_free(pcibr_vhdl, slot);
 
     pcibr_infoh = pcibr_soft->bs_slot[slot].bss_infos;
-    DELA(pcibr_infoh,nfunc);
+    kfree(pcibr_infoh);
     pcibr_soft->bs_slot[slot].bss_ninfo = 0;
 
     return(0);
@@ -973,7 +504,6 @@ pcibr_slot_pcix_rbar_init(pcibr_soft_t p
 {
     pcibr_info_h	 pcibr_infoh;
     pcibr_info_t	 pcibr_info;
-    char		 tmp_str[256];
     int		       	 nfunc;
     int			 func;
 
@@ -1047,21 +577,14 @@ pcibr_slot_pcix_rbar_init(pcibr_soft_t p
             pcibr_soft->bs_pcix_rbar_avail -= num_rbar;
 	    pcix_cmdreg_p->max_mem_read_cnt = pcix_statreg_p->max_mem_read_cnt;
 	}
-        /*
-         * The kernel only allows functions to have so many variable args,
-         * attempting to call PCIBR_DEBUG_ALWAYS() with more than 5 printf
-         * arguments fails so sprintf() it into a temporary string.
-         */
-	if (pcibr_debug_mask & PCIBR_DEBUG_RBAR) {
-            sprintf(tmp_str,"\t  %d/%d   \t    %d    \t  %d  \t  %d  \t  %d\n",
-	            PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), func,
-	            max_splittrans_to_numbuf[pcix_statreg_p->max_out_split],
-	            max_splittrans_to_numbuf[pcix_cmdreg_p->max_split],
-	            pcibr_soft->bs_pcix_rbar_inuse, 
-		    pcibr_soft->bs_pcix_rbar_avail);
-            PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_RBAR, pcibr_soft->bs_vhdl, 
-		        "%s", tmp_str));
-	}
+
+	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_RBAR, pcibr_soft->bs_vhdl,
+		"\t  %d/%d   \t    %d    \t  %d  \t  %d  \t  %d\n",
+		PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), func,
+		max_splittrans_to_numbuf[pcix_statreg_p->max_out_split],
+		max_splittrans_to_numbuf[pcix_cmdreg_p->max_split],
+		pcibr_soft->bs_pcix_rbar_inuse,
+		pcibr_soft->bs_pcix_rbar_avail));
     }
     return(0);
 }
@@ -1126,8 +649,7 @@ pcibr_slot_addr_space_init(vertex_hdl_t 
      * the entire "lo" area is only a
      * megabyte, total ...
      */
-    align_slot = 0x100000;
-    align = align_slot;
+    align_slot = (slot < 2) ? 0x200000 : 0x100000;
 
     for (func = 0; func < nfunc; ++func) {
 	cfg_p                   cfgw;
@@ -1135,9 +657,6 @@ pcibr_slot_addr_space_init(vertex_hdl_t 
 	pciio_space_t           space;
 	iopaddr_t               base;
 	size_t                  size;
-#ifdef PCI_LATER
-	char			tmp_str[256];
-#endif
 	unsigned                pci_cfg_cmd_reg;
 	unsigned                pci_cfg_cmd_reg_add = 0;
 
@@ -1166,29 +685,21 @@ pcibr_slot_addr_space_init(vertex_hdl_t 
 		continue;
 
 	    if (base >= size) {
-		/*
-         	 * The kernel only allows functions to have so many variable
-                 * args attempting to call PCIBR_DEBUG_ALWAYS() with more than
-         	 * 5 printf arguments fails so sprintf() it into a temporary 
-		 * string (tmp_str).
-         	 */
-#if defined(SUPPORT_PRINTING_R_FORMAT)
-		if (pcibr_debug_mask & PCIBR_DEBUG_BAR) {
-		    sprintf(tmp_str, "pcibr_slot_addr_space_init: slot=%d, "
-			"func=%d win %d is in %r [0x%x..0x%x], allocated by "
-			"prom\n", PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot),
-			func, win, space, space_desc, base, base + size - 1);
-		    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_BAR, pcibr_vhdl, 
-				"%s",tmp_str));
-		}
-#endif	/* SUPPORT_PRINTING_R_FORMAT */
+		PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_BAR, pcibr_vhdl,
+			"pcibr_slot_addr_space_init: slot=%d, "
+			"func=%d win %d is in space %s [0x%lx..0x%lx], "
+			"allocated by prom\n",
+			PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), func, win,
+			pci_space[space], (uint64_t)base,
+			(uint64_t)(base + size - 1)));
+
 		continue;		/* already allocated */
 	    }
 
 	    align = (win) ? size : align_slot; 
 
-	    if (align < _PAGESZ)
-		align = _PAGESZ;        /* ie. 0x00004000 */
+	    if (align < PAGE_SIZE)
+		align = PAGE_SIZE;        /* ie. 0x00004000 */
  
 	    switch (space) {
 	    case PCIIO_SPACE_IO:
@@ -1232,28 +743,20 @@ pcibr_slot_addr_space_init(vertex_hdl_t 
 	    pcibr_info->f_window[win].w_base = base;
 	    do_pcibr_config_set(wptr, (win * 4), 4, base);
 
-#if defined(SUPPORT_PRINTING_R_FORMAT)
-	    if (pcibr_debug_mask & PCIBR_DEBUG_BAR) {
-                if (base >= size) {
-		    sprintf(tmp_str,"pcibr_slot_addr_space_init: slot=%d, func="
-				    "%d, win %d is in %r[0x%x..0x%x], "
-				    "allocated by pcibr\n",
-				    PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), 
-				    func, win, space, space_desc, base, 
-				    base + size - 1);
-		     PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_BAR, pcibr_vhdl, 
-				 "%s",tmp_str));
-	        }
-		else {
-		    sprintf(tmp_str,"pcibr_slot_addr_space_init: slot=%d, func="
-				    "%d, win %d, unable to alloc 0x%x in %r\n",
-				    PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), 
-				    func, win, size, space, space_desc);
-		    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_BAR, pcibr_vhdl, 
-				"%s",tmp_str));
-	        }
+	    if (base >= size) {
+		PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_BAR, pcibr_vhdl,
+			"pcibr_slot_addr_space_init: slot=%d, func=%d. win %d "
+			"is in space %s [0x%lx..0x%lx], allocated by pcibr\n",
+			PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), func, win,
+			pci_space[space], (uint64_t)base, 
+			(uint64_t)(base + size - 1)));
+	    } else {
+		PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_BAR, pcibr_vhdl,
+			"pcibr_slot_addr_space_init: slot=%d, func=%d, win %d, "
+			"unable to alloc 0x%lx in space %s\n",
+			PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), func, win,
+			(uint64_t)size, pci_space[space]));
 	    }
-#endif	/* SUPPORT_PRINTING_R_FORMAT */
 	}				/* next base */
 
 	/*
@@ -1313,11 +816,6 @@ pcibr_slot_addr_space_init(vertex_hdl_t 
 	pci_cfg_cmd_reg_add |= PCI_CMD_BUS_MASTER;
 
 	pci_cfg_cmd_reg = do_pcibr_config_get(cfgw, PCI_CFG_COMMAND, 4);
-
-#if PCI_FBBE	/* XXX- check here to see if dev can do fast-back-to-back */
-	if (!((pci_cfg_cmd_reg >> 16) & PCI_STAT_F_BK_BK_CAP))
-	    fast_back_to_back_enable = 0;
-#endif
 	pci_cfg_cmd_reg &= 0xFFFF;
 	if (pci_cfg_cmd_reg_add & ~pci_cfg_cmd_reg)
 	    do_pcibr_config_set(cfgw, PCI_CFG_COMMAND, 4, 
@@ -1363,18 +861,12 @@ pcibr_slot_device_init(vertex_hdl_t pcib
      * for 64-bit devices).  We set the bit in pcibr_try_set_device()
      * if we're 64-bit and requesting virtual channels.
      */
-    if (IS_PIC_SOFT(pcibr_soft) && PCIBR_WAR_ENABLED(PV855271, pcibr_soft))
+    if (PCIBR_WAR_ENABLED(PV855271, pcibr_soft))
 	devreg |= BRIDGE_DEV_COH;
     else
 	devreg |= BRIDGE_DEV_COH | BRIDGE_DEV_VIRTUAL_EN;
     pcibr_soft->bs_slot[slot].bss_device = devreg;
     bridge->b_device[slot].reg = devreg;
-
-#ifdef PIC_LATER
-    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DEVREG, pcibr_vhdl,
-		"pcibr_slot_device_init: Device(%d): %R\n",
-		slot, devreg, device_bits));
-#endif
     return(0);
 }
 
@@ -1407,7 +899,12 @@ pcibr_slot_guest_info_init(vertex_hdl_t 
      * build verticies for them).
      */
     if (pcibr_soft->bs_slot[slot].bss_ninfo < 1) {
-	NEWA(pcibr_infoh, 1);
+	pcibr_infoh = kmalloc(sizeof (*(pcibr_infoh)), GFP_KERNEL);
+	if ( !pcibr_infoh ) {
+		return ENOMEM;
+	}
+	memset(pcibr_infoh, 0, sizeof (*(pcibr_infoh)));
+
 	pcibr_soft->bs_slot[slot].bss_ninfo = 1;
 	pcibr_soft->bs_slot[slot].bss_infos = pcibr_infoh;
 
@@ -1461,16 +958,10 @@ pcibr_slot_call_device_attach(vertex_hdl
     pcibr_info_t	pcibr_info;
     int			func;
     vertex_hdl_t	xconn_vhdl, conn_vhdl;
-#ifdef PIC_LATER
-    vertex_hdl_t	scsi_vhdl;
-#endif
     int			nfunc;
     int                 error_func;
     int                 error_slot = 0;
     int                 error = ENODEV;
-#ifdef PIC_LATER
-    int                 hwg_err;
-#endif
 
     pcibr_soft = pcibr_soft_get(pcibr_vhdl);
 
@@ -1501,43 +992,13 @@ pcibr_slot_call_device_attach(vertex_hdl
 
 	conn_vhdl = pcibr_info->f_vertex;
 
-
 	error_func = pciio_device_attach(conn_vhdl, drv_flags);
 
-#ifdef PIC_LATER
-        /*
-         * Try to assign well-known SCSI controller numbers for hot-plug
-         * insert
-         */
-        if (drv_flags) {
-
-            hwg_err = hwgraph_path_lookup(conn_vhdl, EDGE_LBL_SCSI_CTLR "/0",
-                                          &scsi_vhdl, NULL);
-
-            if (hwg_err == GRAPH_SUCCESS)
-                scsi_ctlr_nums_add(baseio_pci_vhdl, scsi_vhdl);
-
-            /* scsi_vhdl will be the final vertex in either the complete path
-             * on success or a partial path on failure;  in either case,
-             * unreference that vertex.
-             */
-            hwgraph_vertex_unref(scsi_vhdl);
-
-            hwg_err = hwgraph_path_lookup(conn_vhdl, EDGE_LBL_SCSI_CTLR "/1",
-                                          &scsi_vhdl, NULL);
-
-            if (hwg_err == GRAPH_SUCCESS)
-                scsi_ctlr_nums_add(baseio_pci_vhdl, scsi_vhdl);
-
-            /* scsi_vhdl will be the final vertex in either the complete path
-             * on success or a partial path on failure;  in either case,
-             * unreference that vertex.
-             */
-            hwgraph_vertex_unref(scsi_vhdl);
-
-        }
-#endif /* PIC_LATER */
-
+	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DEV_ATTACH, pcibr_vhdl,
+		    "pcibr_slot_call_device_attach: slot=%d, func=%d "
+		    "drv_flags=0x%x, pciio_device_attach returned %d\n",
+		    PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), func, 
+		    drv_flags, error_func));
         pcibr_info->f_att_det_error = error_func;
 
 	if (error_func)
@@ -1616,6 +1077,12 @@ pcibr_slot_call_device_detach(vertex_hdl
 
 	error_func = pciio_device_detach(conn_vhdl, drv_flags);
 
+	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_DEV_DETACH, pcibr_vhdl,
+		    "pcibr_slot_call_device_detach: slot=%d, func=%d "
+		    "drv_flags=0x%x, pciio_device_detach returned %d\n",
+		    PCIBR_DEVICE_TO_SLOT(pcibr_soft, slot), func, 
+		    drv_flags, error_func));
+
         pcibr_info->f_att_det_error = error_func;
 
 	if (error_func)
@@ -1656,9 +1123,6 @@ pcibr_slot_attach(vertex_hdl_t pcibr_vhd
                   int         *sub_errorp)
 {
     pcibr_soft_t  pcibr_soft = pcibr_soft_get(pcibr_vhdl);
-#ifdef PIC_LATER
-    timespec_t    ts;
-#endif
     int		  error;
 
     /* Do not allow a multi-function card to be hot-plug inserted */
@@ -1739,7 +1203,7 @@ pcibr_probe_slot_pic(bridge_t *bridge,
 {
 	int rv;
 	picreg_t p_old_enable = (picreg_t)0, p_new_enable;
-	extern int badaddr_val(volatile void *, int, volatile void *);
+	extern int snia_badaddr_val(volatile void *, int, volatile void *);
 
 	p_old_enable = bridge->p_int_enable_64;
 	p_new_enable = p_old_enable & ~(BRIDGE_IMR_PCI_MST_TIMEOUT | PIC_ISR_PCIX_MTOUT);
@@ -1752,7 +1216,7 @@ pcibr_probe_slot_pic(bridge_t *bridge,
 		bridge->p_int_rst_stat_64 = (BRIDGE_IRR_PCI_GRP_CLR | PIC_PCIX_GRP_CLR);
 		(void) bridge->b_wid_tflush;	/* flushbus */
 	}
-	rv = badaddr_val((void *) cfg, 4, valp);
+	rv = snia_badaddr_val((void *) cfg, 4, valp);
 	if (bridge->p_err_int_view_64 & (BRIDGE_ISR_PCI_MST_TIMEOUT | PIC_ISR_PCIX_MTOUT)) {
 		bridge->p_int_rst_stat_64 = BRIDGE_IRR_MULTI_CLR;
 		rv = 1;         /* unoccupied slot */
@@ -1790,7 +1254,7 @@ pcibr_device_info_free(vertex_hdl_t pcib
     int			nfunc = slotp->bss_ninfo;
     int                 bar;
     int                 devio_index;
-    int                 s;
+    unsigned long	s;
     unsigned            cmd_reg;
 
 
@@ -1840,7 +1304,7 @@ pcibr_device_info_free(vertex_hdl_t pcib
 	pciio_device_info_unregister(pcibr_vhdl, &pcibr_info->f_c);
 	pciio_device_info_free(&pcibr_info->f_c);
 
-	DEL(pcibr_info);
+	kfree(pcibr_info);
     }
 
     /* Reset the mapping usage counters */
diff -puN arch/ia64/sn/io/sn2/pciio.c~linus arch/ia64/sn/io/sn2/pciio.c
--- 25/arch/ia64/sn/io/sn2/pciio.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/pciio.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -7,115 +6,11 @@
  * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
  */
 
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/pci.h>
-#include <linux/pci_ids.h>
-#include <linux/sched.h>
-#include <linux/ioport.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/xtalk/xbow.h>	/* Must be before iograph.h to get MAX_PORT_NUM */
-#include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/hcl_util.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/pci/bridge.h>
-#include <asm/sn/ioerror_handling.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/pci/pciio_private.h>
-#include <asm/sn/sn_sal.h>
-#include <asm/sn/io.h>
 #include <asm/sn/pci/pci_bus_cvlink.h>
 #include <asm/sn/simulator.h>
 
-#define DEBUG_PCIIO
-#undef DEBUG_PCIIO	/* turn this on for yet more console output */
-
-
 char                    pciio_info_fingerprint[] = "pciio_info";
 
-int
-badaddr_val(volatile void *addr, int len, volatile void *ptr)
-{
-	int ret = 0;
-	volatile void *new_addr;
-
-	switch (len) {
-		case 4:
-			new_addr = (void *) addr;
-			ret = ia64_sn_probe_io_slot((long)new_addr, len, (void *)ptr);
-			break;
-		default:
-			printk(KERN_WARNING "badaddr_val given len %x but supports len of 4 only\n", len);
-	}
-
-	if (ret < 0)
-		panic("badaddr_val: unexpected status (%d) in probing", ret);
-	return(ret);
-
-}
-
-
-nasid_t
-get_console_nasid(void)
-{
-	extern nasid_t console_nasid;
-	extern nasid_t master_baseio_nasid;
-
-	if (console_nasid < 0) {
-		console_nasid = ia64_sn_get_console_nasid();
-		if (console_nasid < 0) {
-// ZZZ What do we do if we don't get a console nasid on the hardware????
-			if (IS_RUNNING_ON_SIMULATOR() )
-				console_nasid = master_baseio_nasid;
-		}
-	} 
-	return console_nasid;
-}
-
-nasid_t
-get_master_baseio_nasid(void)
-{
-	extern nasid_t master_baseio_nasid;
-	extern char master_baseio_wid;
-
-	if (master_baseio_nasid < 0) {
-		master_baseio_nasid = ia64_sn_get_master_baseio_nasid();
-
-		if ( master_baseio_nasid >= 0 ) {
-        		master_baseio_wid = WIDGETID_GET(KL_CONFIG_CH_CONS_INFO(master_baseio_nasid)->memory_base);
-		}
-	} 
-	return master_baseio_nasid;
-}
-
-int
-hub_dma_enabled(vertex_hdl_t xconn_vhdl)
-{
-	return(0);
-}
-
-int
-hub_error_devenable(vertex_hdl_t xconn_vhdl, int devnum, int error_code)
-{
-	return(0);
-}
-
-void
-ioerror_dump(char *name, int error_code, int error_mode, ioerror_t *ioerror)
-{
-}
-
-/******
- ****** end hack defines ......
- ******/
-
-
-
-
 /* =====================================================================
  *    PCI Generic Bus Provider
  * Implement PCI provider operations.  The pciio* layer provides a
@@ -124,111 +19,6 @@ ioerror_dump(char *name, int error_code,
  */
 
 /* =====================================================================
- *    Provider Function Location SHORTCUT
- *
- * On platforms with only one possible PCI provider, macros can be
- * set up at the top that cause the table lookups and indirections to
- * completely disappear.
- */
-
-
-/* =====================================================================
- *    Function Table of Contents
- */
-
-#if !defined(DEV_FUNC)
-static pciio_provider_t *pciio_to_provider_fns(vertex_hdl_t dev);
-#endif
-
-pciio_piomap_t          pciio_piomap_alloc(vertex_hdl_t, device_desc_t, pciio_space_t, iopaddr_t, size_t, size_t, unsigned);
-void                    pciio_piomap_free(pciio_piomap_t);
-caddr_t                 pciio_piomap_addr(pciio_piomap_t, iopaddr_t, size_t);
-
-void                    pciio_piomap_done(pciio_piomap_t);
-caddr_t                 pciio_piotrans_addr(vertex_hdl_t, device_desc_t, pciio_space_t, iopaddr_t, size_t, unsigned);
-caddr_t			pciio_pio_addr(vertex_hdl_t, device_desc_t, pciio_space_t, iopaddr_t, size_t, pciio_piomap_t *, unsigned);
-
-iopaddr_t               pciio_piospace_alloc(vertex_hdl_t, device_desc_t, pciio_space_t, size_t, size_t);
-void                    pciio_piospace_free(vertex_hdl_t, pciio_space_t, iopaddr_t, size_t);
-
-pciio_dmamap_t          pciio_dmamap_alloc(vertex_hdl_t, device_desc_t, size_t, unsigned);
-void                    pciio_dmamap_free(pciio_dmamap_t);
-iopaddr_t               pciio_dmamap_addr(pciio_dmamap_t, paddr_t, size_t);
-void                    pciio_dmamap_done(pciio_dmamap_t);
-iopaddr_t               pciio_dmatrans_addr(vertex_hdl_t, device_desc_t, paddr_t, size_t, unsigned);
-void			pciio_dmamap_drain(pciio_dmamap_t);
-void			pciio_dmaaddr_drain(vertex_hdl_t, paddr_t, size_t);
-void			pciio_dmalist_drain(vertex_hdl_t, alenlist_t);
-iopaddr_t               pciio_dma_addr(vertex_hdl_t, device_desc_t, paddr_t, size_t, pciio_dmamap_t *, unsigned);
-
-pciio_intr_t            pciio_intr_alloc(vertex_hdl_t, device_desc_t, pciio_intr_line_t, vertex_hdl_t);
-void                    pciio_intr_free(pciio_intr_t);
-int                     pciio_intr_connect(pciio_intr_t, intr_func_t, intr_arg_t);
-void                    pciio_intr_disconnect(pciio_intr_t);
-vertex_hdl_t            pciio_intr_cpu_get(pciio_intr_t);
-
-void			pciio_slot_func_to_name(char *, pciio_slot_t, pciio_function_t);
-
-void                    pciio_provider_startup(vertex_hdl_t);
-void                    pciio_provider_shutdown(vertex_hdl_t);
-
-pciio_endian_t          pciio_endian_set(vertex_hdl_t, pciio_endian_t, pciio_endian_t);
-pciio_priority_t        pciio_priority_set(vertex_hdl_t, pciio_priority_t);
-vertex_hdl_t            pciio_intr_dev_get(pciio_intr_t);
-
-vertex_hdl_t            pciio_pio_dev_get(pciio_piomap_t);
-pciio_slot_t            pciio_pio_slot_get(pciio_piomap_t);
-pciio_space_t           pciio_pio_space_get(pciio_piomap_t);
-iopaddr_t               pciio_pio_pciaddr_get(pciio_piomap_t);
-ulong                   pciio_pio_mapsz_get(pciio_piomap_t);
-caddr_t                 pciio_pio_kvaddr_get(pciio_piomap_t);
-
-vertex_hdl_t            pciio_dma_dev_get(pciio_dmamap_t);
-pciio_slot_t            pciio_dma_slot_get(pciio_dmamap_t);
-
-pciio_info_t            pciio_info_chk(vertex_hdl_t);
-pciio_info_t            pciio_info_get(vertex_hdl_t);
-void                    pciio_info_set(vertex_hdl_t, pciio_info_t);
-vertex_hdl_t            pciio_info_dev_get(pciio_info_t);
-pciio_slot_t            pciio_info_slot_get(pciio_info_t);
-pciio_function_t        pciio_info_function_get(pciio_info_t);
-pciio_vendor_id_t       pciio_info_vendor_id_get(pciio_info_t);
-pciio_device_id_t       pciio_info_device_id_get(pciio_info_t);
-vertex_hdl_t            pciio_info_master_get(pciio_info_t);
-arbitrary_info_t        pciio_info_mfast_get(pciio_info_t);
-pciio_provider_t       *pciio_info_pops_get(pciio_info_t);
-error_handler_f	       *pciio_info_efunc_get(pciio_info_t);
-error_handler_arg_t    *pciio_info_einfo_get(pciio_info_t);
-pciio_space_t		pciio_info_bar_space_get(pciio_info_t, int);
-iopaddr_t		pciio_info_bar_base_get(pciio_info_t, int);
-size_t			pciio_info_bar_size_get(pciio_info_t, int);
-iopaddr_t		pciio_info_rom_base_get(pciio_info_t);
-size_t			pciio_info_rom_size_get(pciio_info_t);
-
-int                     pciio_attach(vertex_hdl_t);
-
-void                    pciio_provider_register(vertex_hdl_t, pciio_provider_t *pciio_fns);
-void                    pciio_provider_unregister(vertex_hdl_t);
-pciio_provider_t       *pciio_provider_fns_get(vertex_hdl_t);
-
-int                     pciio_driver_register(pciio_vendor_id_t, pciio_device_id_t, char *driver_prefix, unsigned);
-
-vertex_hdl_t            pciio_device_register(vertex_hdl_t, vertex_hdl_t, pciio_slot_t, pciio_function_t, pciio_vendor_id_t, pciio_device_id_t);
-
-void			pciio_device_unregister(vertex_hdl_t);
-pciio_info_t		pciio_device_info_new(pciio_info_t, vertex_hdl_t, pciio_slot_t, pciio_function_t, pciio_vendor_id_t, pciio_device_id_t);
-void			pciio_device_info_free(pciio_info_t);
-vertex_hdl_t		pciio_device_info_register(vertex_hdl_t, pciio_info_t);
-void			pciio_device_info_unregister(vertex_hdl_t, pciio_info_t);
-int                     pciio_device_attach(vertex_hdl_t, int);
-int			pciio_device_detach(vertex_hdl_t, int);
-void                    pciio_error_register(vertex_hdl_t, error_handler_f *, error_handler_arg_t);
-
-int                     pciio_reset(vertex_hdl_t);
-int                     pciio_write_gather_flush(vertex_hdl_t);
-int                     pciio_slot_inuse(vertex_hdl_t);
-
-/* =====================================================================
  *    Provider Function Location
  *
  *      If there is more than one possible provider for
@@ -238,9 +28,7 @@ int                     pciio_slot_inuse
  *      appropriately named member.
  */
 
-#if !defined(DEV_FUNC)
-
-static pciio_provider_t *
+pciio_provider_t *
 pciio_to_provider_fns(vertex_hdl_t dev)
 {
     pciio_info_t            card_info;
@@ -261,13 +49,10 @@ pciio_to_provider_fns(vertex_hdl_t dev)
 	}
     }
 
-    if (provider_fns == NULL)
-#if defined(SUPPORT_PRINTING_V_FORMAT)
-	PRINT_PANIC("%v: provider_fns == NULL", dev);
-#else
-	PRINT_PANIC("0x%p: provider_fns == NULL", (void *)dev);
-#endif
-
+    if (provider_fns == NULL) {
+	char devname[MAXDEVNAME];
+	panic("%s: provider_fns == NULL", vertex_to_name(dev, devname, MAXDEVNAME));
+    }
     return provider_fns;
 
 }
@@ -276,7 +61,6 @@ pciio_to_provider_fns(vertex_hdl_t dev)
 #define CAST_PIOMAP(x)		((pciio_piomap_t)(x))
 #define CAST_DMAMAP(x)		((pciio_dmamap_t)(x))
 #define CAST_INTR(x)		((pciio_intr_t)(x))
-#endif
 
 /*
  * Many functions are not passed their vertex
@@ -396,8 +180,8 @@ pciio_piospace_alloc(vertex_hdl_t dev,	/
 		     size_t byte_count,	/* Size of mapping */
 		     size_t align)
 {					/* Alignment needed */
-    if (align < NBPP)
-	align = NBPP;
+    if (align < PAGE_SIZE)
+	align = PAGE_SIZE;
     return DEV_FUNC(dev, piospace_alloc)
 	(dev, dev_desc, space, byte_count, align);
 }
@@ -753,50 +537,6 @@ pciio_provider_shutdown(vertex_hdl_t pci
 }
 
 /*
- * Specify endianness constraints.  The driver tells us what the device
- * does and how it would like to see things in memory.  We reply with
- * how things will actually appear in memory.
- */
-pciio_endian_t
-pciio_endian_set(vertex_hdl_t dev,
-		 pciio_endian_t device_end,
-		 pciio_endian_t desired_end)
-{
-    ASSERT((device_end == PCIDMA_ENDIAN_BIG) || (device_end == PCIDMA_ENDIAN_LITTLE));
-    ASSERT((desired_end == PCIDMA_ENDIAN_BIG) || (desired_end == PCIDMA_ENDIAN_LITTLE));
-
-#if DEBUG
-#if defined(SUPPORT_PRINTING_V_FORMAT)
-    printk(KERN_ALERT  "%v: pciio_endian_set is going away.\n"
-	    "\tplease use PCIIO_BYTE_STREAM or PCIIO_WORD_VALUES in your\n"
-	    "\tpciio_dmamap_alloc and pciio_dmatrans calls instead.\n",
-	    dev);
-#else
-    printk(KERN_ALERT  "0x%x: pciio_endian_set is going away.\n"
-	    "\tplease use PCIIO_BYTE_STREAM or PCIIO_WORD_VALUES in your\n"
-	    "\tpciio_dmamap_alloc and pciio_dmatrans calls instead.\n",
-	    dev);
-#endif
-#endif
-
-    return DEV_FUNC(dev, endian_set)
-	(dev, device_end, desired_end);
-}
-
-/*
- * Specify PCI arbitration priority.
- */
-pciio_priority_t
-pciio_priority_set(vertex_hdl_t dev,
-		   pciio_priority_t device_prio)
-{
-    ASSERT((device_prio == PCI_PRIO_HIGH) || (device_prio == PCI_PRIO_LOW));
-
-    return DEV_FUNC(dev, priority_set)
-	(dev, device_prio);
-}
-
-/*
  * Read value of configuration register
  */
 uint64_t
@@ -865,71 +605,6 @@ pciio_reset(vertex_hdl_t dev)
     return DEV_FUNC(dev, reset) (dev);
 }
 
-/*
- * flush write gather buffers
- */
-int
-pciio_write_gather_flush(vertex_hdl_t dev)
-{
-    return DEV_FUNC(dev, write_gather_flush) (dev);
-}
-
-vertex_hdl_t
-pciio_intr_dev_get(pciio_intr_t pciio_intr)
-{
-    return (pciio_intr->pi_dev);
-}
-
-/****** Generic crosstalk pio interfaces ******/
-vertex_hdl_t
-pciio_pio_dev_get(pciio_piomap_t pciio_piomap)
-{
-    return (pciio_piomap->pp_dev);
-}
-
-pciio_slot_t
-pciio_pio_slot_get(pciio_piomap_t pciio_piomap)
-{
-    return (pciio_piomap->pp_slot);
-}
-
-pciio_space_t
-pciio_pio_space_get(pciio_piomap_t pciio_piomap)
-{
-    return (pciio_piomap->pp_space);
-}
-
-iopaddr_t
-pciio_pio_pciaddr_get(pciio_piomap_t pciio_piomap)
-{
-    return (pciio_piomap->pp_pciaddr);
-}
-
-ulong
-pciio_pio_mapsz_get(pciio_piomap_t pciio_piomap)
-{
-    return (pciio_piomap->pp_mapsz);
-}
-
-caddr_t
-pciio_pio_kvaddr_get(pciio_piomap_t pciio_piomap)
-{
-    return (pciio_piomap->pp_kvaddr);
-}
-
-/****** Generic crosstalk dma interfaces ******/
-vertex_hdl_t
-pciio_dma_dev_get(pciio_dmamap_t pciio_dmamap)
-{
-    return (pciio_dmamap->pd_dev);
-}
-
-pciio_slot_t
-pciio_dma_slot_get(pciio_dmamap_t pciio_dmamap)
-{
-    return (pciio_dmamap->pd_slot);
-}
-
 /****** Generic pci slot information interfaces ******/
 
 pciio_info_t
@@ -979,6 +654,13 @@ pciio_info_dev_get(pciio_info_t pciio_in
     return (pciio_info->c_vertex);
 }
 
+/*ARGSUSED*/
+pciio_bus_t
+pciio_info_bus_get(pciio_info_t pciio_info)
+{
+    return (pciio_info->c_bus);
+}
+
 pciio_slot_t
 pciio_info_slot_get(pciio_info_t pciio_info)
 {
@@ -1021,49 +703,30 @@ pciio_info_pops_get(pciio_info_t pciio_i
     return (pciio_info->c_pops);
 }
 
-error_handler_f	       *
-pciio_info_efunc_get(pciio_info_t pciio_info)
-{
-    return (pciio_info->c_efunc);
-}
-
-error_handler_arg_t    *
-pciio_info_einfo_get(pciio_info_t pciio_info)
-{
-    return (pciio_info->c_einfo);
-}
-
-pciio_space_t
-pciio_info_bar_space_get(pciio_info_t info, int win)
-{
-    return info->c_window[win].w_space;
-}
-
-iopaddr_t
-pciio_info_bar_base_get(pciio_info_t info, int win)
+int
+pciio_businfo_multi_master_get(pciio_businfo_t businfo)
 {
-    return info->c_window[win].w_base;
+    return businfo->bi_multi_master;
 }
 
-size_t
-pciio_info_bar_size_get(pciio_info_t info, int win)
+pciio_asic_type_t
+pciio_businfo_asic_type_get(pciio_businfo_t businfo)
 {
-    return info->c_window[win].w_size;
+    return businfo->bi_asic_type;
 }
 
-iopaddr_t
-pciio_info_rom_base_get(pciio_info_t info)
+pciio_bus_type_t
+pciio_businfo_bus_type_get(pciio_businfo_t businfo)
 {
-    return info->c_rbase;
+    return businfo->bi_bus_type;
 }
 
-size_t
-pciio_info_rom_size_get(pciio_info_t info)
+pciio_bus_speed_t
+pciio_businfo_bus_speed_get(pciio_businfo_t businfo)
 {
-    return info->c_rsize;
+    return businfo->bi_bus_speed;
 }
 
-
 /* =====================================================================
  *          GENERIC PCI INITIALIZATION FUNCTIONS
  */
@@ -1077,11 +740,8 @@ int
 pciio_attach(vertex_hdl_t pciio)
 {
 #if DEBUG && ATTACH_DEBUG
-#if defined(SUPPORT_PRINTING_V_FORMAT)
-    printk("%v: pciio_attach\n", pciio);
-#else
-    printk("0x%x: pciio_attach\n", pciio);
-#endif
+    char devname[MAXDEVNAME];
+    printk("%s: pciio_attach\n", vertex_to_name(pciio, devname, MAXDEVNAME));
 #endif
     return 0;
 }
@@ -1119,37 +779,6 @@ pciio_provider_fns_get(vertex_hdl_t prov
     return (pciio_provider_t *) ainfo;
 }
 
-/*ARGSUSED4 */
-int
-pciio_driver_register(
-			 pciio_vendor_id_t vendor_id,
-			 pciio_device_id_t device_id,
-			 char *driver_prefix,
-			 unsigned flags)
-{
-	return(0);
-}
-
-vertex_hdl_t
-pciio_device_register(
-		vertex_hdl_t connectpt,	/* vertex for /hw/.../pciio/%d */
-		vertex_hdl_t master,	/* card's master ASIC (PCI provider) */
-		pciio_slot_t slot,	/* card's slot */
-		pciio_function_t func,	/* card's func */
-		pciio_vendor_id_t vendor_id,
-		pciio_device_id_t device_id)
-{
-    return pciio_device_info_register
-	(connectpt, pciio_device_info_new (NULL, master, slot, func,
-					   vendor_id, device_id));
-}
-
-void
-pciio_device_unregister(vertex_hdl_t pconn)
-{
-    DEV_FUNC(pconn,device_unregister)(pconn);
-}
-
 pciio_info_t
 pciio_device_info_new(
 		pciio_info_t pciio_info,
@@ -1159,8 +788,11 @@ pciio_device_info_new(
 		pciio_vendor_id_t vendor_id,
 		pciio_device_id_t device_id)
 {
-    if (!pciio_info)
-	NEW(pciio_info);
+    if (!pciio_info) {
+	pciio_info = kmalloc(sizeof (*(pciio_info)), GFP_KERNEL);
+	if ( pciio_info )
+		memset(pciio_info, 0, sizeof (*(pciio_info)));
+    }
     ASSERT(pciio_info != NULL);
 
     pciio_info->c_slot = slot;
@@ -1182,7 +814,7 @@ pciio_device_info_free(pciio_info_t pcii
     /* NOTE : pciio_info is a structure within the pcibr_info
      *	      and not a pointer to memory allocated on the heap !!
      */
-    BZERO((char *)pciio_info,sizeof(pciio_info));
+    memset((char *)pciio_info, 0, sizeof(pciio_info));
 }
 
 vertex_hdl_t
@@ -1293,14 +925,26 @@ pciio_device_win_alloc(struct resource *
 {
 
 	struct resource *new_res;
-	int status = 0;
-
-	new_res = (struct resource *) kmalloc( sizeof(struct resource), KM_NOSLEEP);
+	int status;
 
-	status = allocate_resource( root_resource, new_res,
+	new_res = (struct resource *) kmalloc( sizeof(struct resource), GFP_KERNEL);
+	if (!new_res)
+		return 0;
+
+	if (start > 0) {
+		status = allocate_resource( root_resource, new_res,
+			size, start /* Min start addr. */,
+			(start + size) - 1, 1,
+			NULL, NULL);
+	} else {
+		if (size > align)
+			align = size;
+		status = allocate_resource( root_resource, new_res,
 				    size, align /* Min start addr. */,
 				    root_resource->end, align,
 				    NULL, NULL);
+	}
+
 	if (status) {
 		kfree(new_res);
 		return((iopaddr_t) NULL);
@@ -1326,8 +970,7 @@ pciio_device_win_alloc(struct resource *
 void
 pciio_device_win_free(pciio_win_alloc_t win_alloc)
 {
-
-	int status = 0;
+	int status;
 
 	if (win_alloc->wa_resource) {
 		status = release_resource(win_alloc->wa_resource);
@@ -1389,47 +1032,16 @@ pciio_slot_inuse(vertex_hdl_t pconn_vhdl
 }
 
 int
-pciio_dma_enabled(vertex_hdl_t pconn_vhdl)
-{
-	return DEV_FUNC(pconn_vhdl, dma_enabled)(pconn_vhdl);
-}
-
-int
 pciio_info_type1_get(pciio_info_t pci_info)
 {
-	return(0);
+	return (pci_info->c_type1);
 }
 
-/*
- *  XXX: should probably be called __sn2_pci_rrb_alloc
- */
-/* used by qla1280 */
-int
-snia_pcibr_rrb_alloc(struct pci_dev *pci_dev,
-	int *count_vchan0,
-	int *count_vchan1)
+pciio_businfo_t
+pciio_businfo_get(vertex_hdl_t conn)
 {
-	vertex_hdl_t dev = PCIDEV_VERTEX(pci_dev);
+	pciio_info_t		info;
 
-	return pcibr_rrb_alloc(dev, count_vchan0, count_vchan1);
-}
-EXPORT_SYMBOL(snia_pcibr_rrb_alloc);
-
-/* 
- * XXX: interface should be more like
- *
- *	int __sn2_pci_enable_bwswap(struct pci_dev *dev);
- *	void __sn2_pci_disable_bswap(struct pci_dev *dev);
- */
-/* used by ioc4 ide */
-pciio_endian_t
-snia_pciio_endian_set(struct pci_dev *pci_dev,
-	pciio_endian_t device_end,
-	pciio_endian_t desired_end)
-{
-	vertex_hdl_t dev = PCIDEV_VERTEX(pci_dev);
-	
-	return DEV_FUNC(dev, endian_set)
-		(dev, device_end, desired_end);
+	info = pciio_info_get(conn);
+	return DEV_FUNC(conn, businfo_get)(conn);
 }
-EXPORT_SYMBOL(snia_pciio_endian_set);
diff -puN arch/ia64/sn/io/sn2/pic.c~linus arch/ia64/sn/io/sn2/pic.c
--- 25/arch/ia64/sn/io/sn2/pic.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/pic.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
 /*
- *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -7,26 +6,15 @@
  * Copyright (C) 2001-2003 Silicon Graphics, Inc. All rights reserved.
  */
 
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <asm/sn/sgi.h>
+#include <linux/interrupt.h>
 #include <asm/sn/sn_cpuid.h>
-#include <asm/sn/addrs.h>
-#include <asm/sn/arch.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/pci/bridge.h>
+#include <asm/sn/hcl_util.h>
 #include <asm/sn/pci/pciio.h>
 #include <asm/sn/pci/pcibr.h>
 #include <asm/sn/pci/pcibr_private.h>
 #include <asm/sn/pci/pci_defs.h>
-#include <asm/sn/prio.h>
-#include <asm/sn/xtalk/xbow.h>
-#include <asm/sn/io.h>
+#include <asm/sn/pci/pic.h>
 #include <asm/sn/sn_private.h>
 
 
@@ -38,34 +26,9 @@ extern void pcibr_driver_unreg_callback(
 
 
 /*
- * copy inventory_t from conn_v to peer_conn_v
- */
-int
-pic_bus1_inventory_dup(vertex_hdl_t conn_v, vertex_hdl_t peer_conn_v)
-{
-	inventory_t *pinv, *peer_pinv;
-
-	if (hwgraph_info_get_LBL(conn_v, INFO_LBL_INVENT,
-				(arbitrary_info_t *)&pinv) == GRAPH_SUCCESS)
- {
-		NEW(peer_pinv);
-		memcpy(peer_pinv, pinv, sizeof(inventory_t));
-		if (hwgraph_info_add_LBL(peer_conn_v, INFO_LBL_INVENT,
-			    (arbitrary_info_t)peer_pinv) != GRAPH_SUCCESS) {
-			DEL(peer_pinv);
-			return 0;
-		}
-		return 1;
-	}
-
-	printk("pic_bus1_inventory_dup: cannot get INFO_LBL_INVENT from 0x%lx\n ", (uint64_t)conn_v);
-	return 0;
-}
-
-/*
  * copy xwidget_info_t from conn_v to peer_conn_v
  */
-int
+static int
 pic_bus1_widget_info_dup(vertex_hdl_t conn_v, vertex_hdl_t peer_conn_v,
 							cnodeid_t xbow_peer)
 {
@@ -83,21 +46,27 @@ pic_bus1_widget_info_dup(vertex_hdl_t co
 
 	if (hwgraph_info_get_LBL(conn_v, INFO_LBL_XWIDGET,
 			(arbitrary_info_t *)&widget_info) == GRAPH_SUCCESS) {
-		NEW(peer_widget_info);
-		peer_widget_info->w_vertex = peer_conn_v;
-		peer_widget_info->w_id = widget_info->w_id;
-		peer_widget_info->w_master = peer_hubv;
-		peer_widget_info->w_masterid = peer_hub_info->h_widgetid;
+		peer_widget_info = kmalloc(sizeof (*(peer_widget_info)), GFP_KERNEL);
+		if ( !peer_widget_info ) {
+			return 0;
+		}
+		memset(peer_widget_info, 0, sizeof (*(peer_widget_info)));
+
+		peer_widget_info->w_fingerprint = widget_info_fingerprint;
+    		peer_widget_info->w_vertex = peer_conn_v;
+    		peer_widget_info->w_id = widget_info->w_id;
+    		peer_widget_info->w_master = peer_hubv;
+    		peer_widget_info->w_masterid = peer_hub_info->h_widgetid;
 		/* structure copy */
-		peer_widget_info->w_hwid = widget_info->w_hwid;
-		peer_widget_info->w_efunc = 0;
-		peer_widget_info->w_einfo = 0;
+    		peer_widget_info->w_hwid = widget_info->w_hwid;
+    		peer_widget_info->w_efunc = 0;
+    		peer_widget_info->w_einfo = 0;
 		peer_widget_info->w_name = kmalloc(strlen(peer_path) + 1, GFP_KERNEL);
 		strcpy(peer_widget_info->w_name, peer_path);
 
 		if (hwgraph_info_add_LBL(peer_conn_v, INFO_LBL_XWIDGET,
 			(arbitrary_info_t)peer_widget_info) != GRAPH_SUCCESS) {
-				DEL(peer_widget_info);
+				kfree(peer_widget_info);
 				return 0;
 		}
 
@@ -119,7 +88,7 @@ pic_bus1_widget_info_dup(vertex_hdl_t co
  * If not successful, return zero and both buses will attach to the
  * vertex passed into pic_attach().
  */
-vertex_hdl_t
+static vertex_hdl_t
 pic_bus1_redist(nasid_t nasid, vertex_hdl_t conn_v)
 {
 	cnodeid_t cnode = NASID_TO_COMPACT_NODEID(nasid);
@@ -172,11 +141,6 @@ pic_bus1_redist(nasid_t nasid, vertex_hd
 			     * vertex but that should be safe and we don't
 			     * really expect the additions to fail anyway.
 			     */
-#if 0
-			    if (!pic_bus1_inventory_dup(conn_v, peer_conn_v))
-					return 0;
-			    pic_bus1_device_desc_dup(conn_v, peer_conn_v);
-#endif
 			    if (!pic_bus1_widget_info_dup(conn_v, peer_conn_v, xbow_peer))
 					return 0;
 
@@ -196,6 +160,8 @@ pic_attach(vertex_hdl_t conn_v)
 	vertex_hdl_t	pcibr_vhdl0, pcibr_vhdl1 = (vertex_hdl_t)0;
 	pcibr_soft_t	bus0_soft, bus1_soft = (pcibr_soft_t)0;
 	vertex_hdl_t  conn_v0, conn_v1, peer_conn_v;
+	int		bricktype;
+	int		iobrick_type_get_nasid(nasid_t nasid);
 
 	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ATTACH, conn_v, "pic_attach()\n"));
 
@@ -204,13 +170,14 @@ pic_attach(vertex_hdl_t conn_v)
 	bridge1 = (bridge_t *)((char *)bridge0 + PIC_BUS1_OFFSET);
 
 	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ATTACH, conn_v,
-		    "pic_attach: bridge0=0x%x, bridge1=0x%x\n", 
+		    "pic_attach: bridge0=0x%lx, bridge1=0x%lx\n", 
 		    bridge0, bridge1));
 
 	conn_v0 = conn_v1 = conn_v;
 
 	/* If dual-ported then split the two PIC buses across both Cbricks */
-	if ((peer_conn_v = (pic_bus1_redist(NASID_GET(bridge0), conn_v))))
+	peer_conn_v = pic_bus1_redist(NASID_GET(bridge0), conn_v);
+	if (peer_conn_v)
 		conn_v1 = peer_conn_v;
 
 	/*
@@ -224,14 +191,21 @@ pic_attach(vertex_hdl_t conn_v)
 	 * Opening this vertex will provide access to
 	 * the Bridge registers themselves.
 	 */
-	/* FIXME: what should the hwgraph path look like ? */
-	rc = hwgraph_path_add(conn_v0, EDGE_LBL_PCIX_0, &pcibr_vhdl0);
-	ASSERT(rc == GRAPH_SUCCESS);
-	rc = hwgraph_path_add(conn_v1, EDGE_LBL_PCIX_1, &pcibr_vhdl1);
-	ASSERT(rc == GRAPH_SUCCESS);
+	bricktype = iobrick_type_get_nasid(NASID_GET(bridge0));
+	if ( bricktype == MODULE_CGBRICK ) {
+		rc = hwgraph_path_add(conn_v0, EDGE_LBL_AGP_0, &pcibr_vhdl0);
+		ASSERT(rc == GRAPH_SUCCESS);
+		rc = hwgraph_path_add(conn_v1, EDGE_LBL_AGP_1, &pcibr_vhdl1);
+		ASSERT(rc == GRAPH_SUCCESS);
+	} else {
+		rc = hwgraph_path_add(conn_v0, EDGE_LBL_PCIX_0, &pcibr_vhdl0);
+		ASSERT(rc == GRAPH_SUCCESS);
+		rc = hwgraph_path_add(conn_v1, EDGE_LBL_PCIX_1, &pcibr_vhdl1);
+		ASSERT(rc == GRAPH_SUCCESS);
+	}
 
 	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ATTACH, conn_v,
-		    "pic_attach: pcibr_vhdl0=%v, pcibr_vhdl1=%v\n",
+		    "pic_attach: pcibr_vhdl0=0x%lx, pcibr_vhdl1=0x%lx\n",
 		    pcibr_vhdl0, pcibr_vhdl1));
 
 	/* register pci provider array */
@@ -249,7 +223,7 @@ pic_attach(vertex_hdl_t conn_v)
         bus1_soft->bs_peers_soft = bus0_soft;
 
 	PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_ATTACH, conn_v,
-		    "pic_attach: bus0_soft=0x%x, bus1_soft=0x%x\n",
+		    "pic_attach: bus0_soft=0x%lx, bus1_soft=0x%lx\n",
 		    bus0_soft, bus1_soft));
 
 	return 0;
@@ -294,10 +268,8 @@ pciio_provider_t        pci_pic_provider
     (pciio_priority_set_f *) pcibr_priority_set,
     (pciio_config_get_f *) pcibr_config_get,
     (pciio_config_set_f *) pcibr_config_set,
-    (pciio_error_devenable_f *) 0,
     (pciio_error_extract_f *) 0,
     (pciio_driver_reg_callback_f *) pcibr_driver_reg_callback,
     (pciio_driver_unreg_callback_f *) pcibr_driver_unreg_callback,
     (pciio_device_unregister_f 	*) pcibr_device_unregister,
-    (pciio_dma_enabled_f		*) pcibr_dma_enabled,
 };
diff -puN arch/ia64/sn/io/sn2/shub.c~linus arch/ia64/sn/io/sn2/shub.c
--- 25/arch/ia64/sn/io/sn2/shub.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/shub.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -7,18 +6,18 @@
  * Copyright (C) 1992-1997, 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  */
 
-#ident  "$Revision: 1.167 $"
-
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/interrupt.h>
+#include <linux/seq_file.h>
+#include <linux/sched.h>
 #include <asm/smp.h>
 #include <asm/irq.h>
 #include <asm/hw_irq.h>
 #include <asm/system.h>
 #include <asm/sn/sgi.h>
+#include <asm/uaccess.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/labelcl.h>
 #include <asm/sn/io.h>
@@ -30,49 +29,12 @@
 #include <asm/sn/xtalk/xtalk.h>
 #include <asm/sn/pci/pcibr_private.h>
 #include <asm/sn/intr.h>
+#include <asm/sn/sn2/shub_mmr.h>
 #include <asm/sn/sn2/shub_mmr_t.h>
 #include <asm/sal.h>
 #include <asm/sn/sn_sal.h>
 #include <asm/sn/sndrv.h>
 #include <asm/sn/sn2/shubio.h>
-#include <asm/sn/sn2/shub_mmr.h>
-
-/*
- * Shub WAR for Xbridge Little Endian problem:
- *	Xbridge has to run in BIG ENDIAN even with Shub.
- */
-
-
-/*
- * io_sh_swapper: Turn on Shub byte swapping.
- *	All data destined to and from Shub to XIO are byte-swapped.
- */
-void
-io_sh_swapper(nasid_t nasid, int onoff)
-{
-    ii_iwc_u_t      ii_iwc;
-
-    ii_iwc.ii_iwc_regval = REMOTE_HUB_L(nasid, IIO_IWC);
-
-    ii_iwc.ii_iwc_fld_s.i_dma_byte_swap = onoff;
-    REMOTE_HUB_S(nasid, IIO_IWC, ii_iwc.ii_iwc_regval);
-    ii_iwc.ii_iwc_regval = REMOTE_HUB_L(nasid, IIO_IWC);
-
-}
-
-/*
- * io_get_sh_swapper: Return current Swap mode.
- *	1 = Swap on, 0 = Swap off.
- */
-int
-io_get_sh_swapper(nasid_t nasid)
-{
-    ii_iwc_u_t      ii_iwc;
-
-    ii_iwc.ii_iwc_regval = REMOTE_HUB_L(nasid, IIO_IWC);
-    return(ii_iwc.ii_iwc_fld_s.i_dma_byte_swap);
-
-}
 
 #define SHUB_NUM_ECF_REGISTERS 8
 
@@ -204,6 +166,8 @@ shubstats_ioctl(struct inode *inode, str
 	int		nasid;
 
         cnode = (cnodeid_t)file->f_dentry->d_fsdata;
+        if (cnode < 0 || cnode >= numnodes)
+                return -ENODEV;
 
         switch (cmd) {
 	case SNDRV_SHUB_CONFIGURE:
diff -puN arch/ia64/sn/io/sn2/shuberror.c~linus arch/ia64/sn/io/sn2/shuberror.c
--- 25/arch/ia64/sn/io/sn2/shuberror.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/shuberror.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id: shuberror.c,v 1.1 2002/02/28 17:31:25 marcelo Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -17,7 +16,6 @@
 #include <asm/sn/sgi.h>
 #include <asm/sn/io.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/labelcl.h>
 #include <asm/sn/sn_private.h>
@@ -31,6 +29,7 @@
 #include <asm/sn/ioerror_handling.h>
 #include <asm/sn/ioerror.h>
 #include <asm/sn/sn2/shubio.h>
+#include <asm/sn/sn2/shub_mmr.h>
 #include <asm/sn/bte.h>
 
 extern void hubni_eint_init(cnodeid_t cnode);
@@ -173,7 +172,6 @@ hubii_eint_handler (int irq, void *arg, 
     hubinfo_t		hinfo; 
     ii_wstat_u_t	wstat;
     hubreg_t		idsr;
-    ii_ilcsr_u_t	ilcsr;
 
 
     /* two levels of casting avoids compiler warning.!! */
@@ -228,11 +226,9 @@ hubii_eint_handler (int irq, void *arg, 
 	
 	}
 	/*
-	 * Note: we may never be able to print this, if the II talking
-	 * to Xbow which hosts the console is dead. 
+	 * Only print the II_ECRAZY message if there is an attached xbow.
 	 */
-	ilcsr.ii_ilcsr_regval = REMOTE_HUB_L(hinfo->h_nasid, IIO_ILCSR);
-	if (ilcsr.ii_ilcsr_fld_s.i_llp_en == 1) {	/* Link is enabled */
+	if (NODEPDA(hinfo->h_cnodeid)->xbow_vhdl != 0) {
 	    printk("Hub %d, cnode %d to Xtalk Link failed (II_ECRAZY) Reason: %s", 
 		hinfo->h_nasid, hinfo->h_cnodeid, reason);
 	}
@@ -299,7 +295,7 @@ hubiio_crb_free(hubinfo_t hinfo, int crb
 	* Wait till hub indicates it's done.
 	*/
 	while (REMOTE_HUB_L(hinfo->h_nasid, IIO_ICDR) & IIO_ICDR_PND)
-		us_delay(1);
+		udelay(1);
 
 }
 
diff -puN arch/ia64/sn/io/sn2/shub_intr.c~linus arch/ia64/sn/io/sn2/shub_intr.c
--- 25/arch/ia64/sn/io/sn2/shub_intr.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/shub_intr.c	2004-01-19 22:17:21.000000000 -0800
@@ -18,7 +18,6 @@
 #include <asm/sn/io.h>
 #include <asm/sn/sn_private.h>
 #include <asm/sn/addrs.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/hcl_util.h>
 #include <asm/sn/intr.h>
@@ -26,6 +25,8 @@
 #include <asm/sn/klconfig.h>
 #include <asm/sn/sn2/shub_mmr.h>
 #include <asm/sn/sn_cpuid.h>
+#include <asm/sn/pci/pcibr.h>
+#include <asm/sn/pci/pcibr_private.h>
 
 /* ARGSUSED */
 void
@@ -36,11 +37,15 @@ hub_intr_init(vertex_hdl_t hubv)
 xwidgetnum_t
 hub_widget_id(nasid_t nasid)
 {
-        hubii_wcr_t     ii_wcr; /* the control status register */
-        
-        ii_wcr.wcr_reg_value = REMOTE_HUB_L(nasid,IIO_WCR);
-        
-        return ii_wcr.wcr_fields_s.wcr_widget_id;
+
+	if (!(nasid & 1)) {
+        	hubii_wcr_t     ii_wcr; /* the control status register */
+        	ii_wcr.wcr_reg_value = REMOTE_HUB_L(nasid,IIO_WCR);
+        	return ii_wcr.wcr_fields_s.wcr_widget_id;
+	} else {
+		/* ICE does not have widget id. */
+		return(-1);
+	}
 }
 
 static hub_intr_t
@@ -49,7 +54,7 @@ do_hub_intr_alloc(vertex_hdl_t dev,
 		vertex_hdl_t owner_dev,
 		int uncond_nothread)
 {
-	cpuid_t		cpu = 0;
+	cpuid_t		cpu;
 	int		vector;
 	hub_intr_t	intr_hdl;
 	cnodeid_t	cnode;
@@ -58,7 +63,6 @@ do_hub_intr_alloc(vertex_hdl_t dev,
 	iopaddr_t	xtalk_addr;
 	struct xtalk_intr_s	*xtalk_info;
 	xwidget_info_t	xwidget_info;
-	ilvl_t		intr_swlevel = 0;
 
 	cpu = intr_heuristic(dev, -1, &vector);
 	if (cpu == CPU_NONE) {
@@ -77,8 +81,9 @@ do_hub_intr_alloc(vertex_hdl_t dev,
 		xtalk_addr = SH_II_INT0 | ((unsigned long)nasid << 36) | (1UL << 47);
 	}
 
-	intr_hdl = snia_kmem_alloc_node(sizeof(struct hub_intr_s), KM_NOSLEEP, cnode);
+	intr_hdl = kmalloc(sizeof(struct hub_intr_s), GFP_KERNEL);
 	ASSERT_ALWAYS(intr_hdl);
+	memset(intr_hdl, 0, sizeof(struct hub_intr_s));
 
 	xtalk_info = &intr_hdl->i_xtalk_info;
 	xtalk_info->xi_dev = dev;
@@ -90,12 +95,11 @@ do_hub_intr_alloc(vertex_hdl_t dev,
 		xtalk_info->xi_target = xwidget_info_masterid_get(xwidget_info);
 	}
 
-	intr_hdl->i_swlevel = intr_swlevel;
 	intr_hdl->i_cpuid = cpu;
 	intr_hdl->i_bit = vector;
 	intr_hdl->i_flags |= HUB_INTR_IS_ALLOCED;
 
-	return(intr_hdl);
+	return intr_hdl;
 }
 
 hub_intr_t
@@ -185,3 +189,73 @@ hub_intr_disconnect(hub_intr_t intr_hdl)
 	ASSERT(rv == 0);
 	intr_hdl->i_flags &= ~HUB_INTR_IS_CONNECTED;
 }
+
+/* 
+ * Redirect an interrupt to another cpu.
+ */
+
+void
+sn_shub_redirect_intr(pcibr_intr_t intr, unsigned long cpu)
+{
+	unsigned long bit;
+	int cpuphys, slice;
+	nasid_t nasid;
+	unsigned long xtalk_addr;
+	void		*bridge = intr->bi_soft->bs_base;
+	int		irq;
+	int		i;
+	int		old_cpu;
+	int		new_cpu;
+
+	cpuphys = cpu_physical_id(cpu);
+	slice = cpu_physical_id_to_slice(cpuphys);
+	nasid = cpu_physical_id_to_nasid(cpuphys);
+
+	for (i = CPUS_PER_NODE - 1; i >= 0; i--) {
+		new_cpu = nasid_slice_to_cpuid(nasid, i);
+		if (new_cpu == NR_CPUS) {
+			continue;
+		}
+
+		if (!cpu_online(new_cpu)) {
+			continue;
+		}
+		break;
+	}
+
+	if (enable_shub_wars_1_1() && slice != i) {
+		printk("smp_affinity WARNING: SHUB 1.1 present: cannot target cpu %d, targeting cpu %d instead.\n",(int)cpu, new_cpu);
+		cpu = new_cpu;
+		slice = i;
+	}
+
+	if (slice) {    
+		xtalk_addr = SH_II_INT1 | ((unsigned long)nasid << 36) | (1UL << 47);
+	} else {
+		xtalk_addr = SH_II_INT0 | ((unsigned long)nasid << 36) | (1UL << 47);
+	}
+
+	for (bit = 0; bit < 8; bit++) {
+		if (intr->bi_ibits & (1 << bit) ) {
+			/* Disable interrupts. */
+			pcireg_intr_enable_bit_clr(bridge, bit);
+			/* Reset Host address (Interrupt destination) */
+			pcireg_intr_addr_addr_set(bridge, bit, xtalk_addr);
+			/* Enable interrupt */
+			pcireg_intr_enable_bit_set(bridge, bit);
+			/* Force an interrupt, just in case. */
+			pcireg_force_intr_set(bridge, bit);
+		}
+	}
+	irq = intr->bi_irq;
+	old_cpu = intr->bi_cpu;
+	if (pdacpu(cpu)->sn_first_irq == 0 || pdacpu(cpu)->sn_first_irq > irq) {
+		pdacpu(cpu)->sn_first_irq = irq;
+	}
+	if (pdacpu(cpu)->sn_last_irq < irq) {
+		pdacpu(cpu)->sn_last_irq = irq;
+	}
+	pdacpu(old_cpu)->sn_num_irqs--;
+	pdacpu(cpu)->sn_num_irqs++;
+	intr->bi_cpu = (int)cpu;
+}
diff -puN arch/ia64/sn/io/sn2/shubio.c~linus arch/ia64/sn/io/sn2/shubio.c
--- 25/arch/ia64/sn/io/sn2/shubio.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/shubio.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id: shubio.c,v 1.1 2002/02/28 17:31:25 marcelo Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -14,7 +13,6 @@
 #include <asm/sn/sgi.h>
 #include <asm/sn/io.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/labelcl.h>
 #include <asm/sn/sn_private.h>
@@ -160,8 +158,6 @@ hub_ioerror_handler(
 	iopaddr_t 	p;
 	caddr_t 	cp;
 
-	IOERROR_DUMP("hub_ioerror_handler", error_code, mode, ioerror);
-
 	hubinfo_get(hub_v, &hinfo);
 
 	if (!hinfo){
@@ -287,8 +283,6 @@ hub_ioerror_handler(
 			IOERROR_SETVALUE(ioerror,widgetnum,widgetnum);
 			IOERROR_SETVALUE(ioerror,xtalkaddr,xtalkaddr);
 		} else {
-			IOERROR_DUMP("hub_ioerror_handler", error_code, 
-						mode, ioerror);
 			IOERR_PRINTF(printk(
 				"hub_ioerror_handler: Invalid address passed"));
 
@@ -308,11 +302,6 @@ hub_ioerror_handler(
 			 * widget is enabled.
 			 */
 			if (!is_widget_pio_enabled(ioerror)) {
-				if (error_state_get(hub_v) == 
-				    ERROR_STATE_ACTION)
-					ioerror_dump("No outbound widget"
-						     " access - ", 
-						     error_code, mode, ioerror);
 				return(IOERROR_HANDLED);
 			}
 		  
@@ -350,11 +339,6 @@ hub_ioerror_handler(
 			 */
 
 			if (!is_widget_pio_enabled(ioerror)) {
-				if (error_state_get(hub_v) == 
-				    ERROR_STATE_ACTION)
-					ioerror_dump("No outbound widget"
-						     " access - ", 
-						     error_code, mode, ioerror);
 				return(IOERROR_HANDLED);
 			}
 		  
@@ -478,7 +462,7 @@ error_return_code_t
 error_state_set(vertex_hdl_t v,error_state_t new_state)
 {
         error_state_t   old_state;
-        boolean_t       replace = B_TRUE;
+        int       replace = 1;
 
         /* Check if we have a valid hwgraph vertex */
         if ( v == (vertex_hdl_t)0 )
@@ -497,7 +481,7 @@ error_state_set(vertex_hdl_t v,error_sta
          * for this vertex.
          */
         if (v_error_state_get(v,old_state) != GRAPH_SUCCESS)
-                replace = B_FALSE;
+                replace = 0;
 
         if (v_error_state_set(v,new_state,replace) != GRAPH_SUCCESS) {
                 return(ERROR_RETURN_CODE_CANNOT_SET_STATE);
diff -puN arch/ia64/sn/io/sn2/xbow.c~linus arch/ia64/sn/io/sn2/xbow.c
--- 25/arch/ia64/sn/io/sn2/xbow.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/xbow.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -7,47 +6,24 @@
  * Copyright (c) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
  */
 
-#include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/module.h>
-#include <linux/sched.h>
 #include <linux/interrupt.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/intr.h>
 #include <asm/sn/sn2/sn_private.h>
-#include <asm/sn/sn2/shubio.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/labelcl.h>
-#include <asm/sn/pci/bridge.h>
-#include <asm/sn/xtalk/xtalk_private.h>
 #include <asm/sn/simulator.h>
+#include <asm/sn/hcl.h>
+#include <asm/sn/hcl_util.h>
 
 /* #define DEBUG		1 */
 /* #define XBOW_DEBUG	1 */
-/* #define DEBUG_ERROR	1 */
-
-
-/*
- * Files needed to get the device driver entry points
- */
-
-#include <asm/sn/xtalk/xbow.h>
-#include <asm/sn/xtalk/xtalk.h>
-#include <asm/sn/xtalk/xswitch.h>
-#include <asm/sn/xtalk/xwidget.h>
-
-#include <asm/sn/prio.h>
-#include <asm/sn/hcl_util.h>
 
+#define kdebug 0
 
-#define NEW(ptr)	(ptr = kmalloc(sizeof (*(ptr)), GFP_KERNEL))
-#define DEL(ptr)	(kfree(ptr))
 
 /*
  * This file supports the Xbow chip.  Main functions: initializtion,
- * error handling, and GBR.
+ * error handling.
  */
 
 /*
@@ -55,7 +31,6 @@
  * has a "fastinfo" pointer pointing at one
  * of these things.
  */
-typedef struct xbow_soft_s *xbow_soft_t;
 
 struct xbow_soft_s {
     vertex_hdl_t            conn;	/* our connection point */
@@ -64,30 +39,24 @@ struct xbow_soft_s {
     xbow_t                 *base;	/* PIO pointer to crossbow chip */
     char                   *name;	/* hwgraph name */
 
-    xbow_perf_t             xbow_perfcnt[XBOW_PERF_COUNTERS];
-    xbow_perf_link_t        xbow_perflink[MAX_XBOW_PORTS];
     xbow_link_status_t      xbow_link_status[MAX_XBOW_PORTS];
-    spinlock_t              xbow_perf_lock;
-    int                     link_monitor;
     widget_cfg_t	   *wpio[MAX_XBOW_PORTS];	/* cached PIO pointer */
 
     /* Bandwidth allocation state. Bandwidth values are for the
      * destination port since contention happens there.
      * Implicit mapping from xbow ports (8..f) -> (0..7) array indices.
      */
-    spinlock_t		    xbow_bw_alloc_lock;		/* bw allocation lock */
     unsigned long long	    bw_hiwm[MAX_XBOW_PORTS];	/* hiwater mark values */
     unsigned long long      bw_cur_used[MAX_XBOW_PORTS]; /* bw used currently */
 };
 
 #define xbow_soft_set(v,i)	hwgraph_fastinfo_set((v), (arbitrary_info_t)(i))
-#define xbow_soft_get(v)	((xbow_soft_t)hwgraph_fastinfo_get((v)))
+#define xbow_soft_get(v)	((struct xbow_soft_s *)hwgraph_fastinfo_get((v)))
 
 /*
  * Function Table of Contents
  */
 
-void                    xbow_mlreset(xbow_t *);
 int                     xbow_attach(vertex_hdl_t);
 
 int                     xbow_widget_present(xbow_t *, int);
@@ -95,19 +64,6 @@ static int              xbow_link_alive(
 vertex_hdl_t            xbow_widget_lookup(vertex_hdl_t, int);
 
 void                    xbow_intr_preset(void *, int, xwidgetnum_t, iopaddr_t, xtalk_intr_vector_t);
-
-
-
-void                    xbow_update_perf_counters(vertex_hdl_t);
-xbow_perf_link_t       *xbow_get_perf_counters(vertex_hdl_t);
-int                     xbow_enable_perf_counter(vertex_hdl_t, int, int, int);
-xbow_link_status_t     *xbow_get_llp_status(vertex_hdl_t);
-void                    xbow_update_llp_status(vertex_hdl_t);
-
-int                     xbow_disable_llp_monitor(vertex_hdl_t);
-int                     xbow_enable_llp_monitor(vertex_hdl_t);
-int                     xbow_prio_bw_alloc(vertex_hdl_t, xwidgetnum_t, xwidgetnum_t,
-                                unsigned long long, unsigned long long);
 static void		xbow_setwidint(xtalk_intr_t);
 
 xswitch_reset_link_f    xbow_reset_link;
@@ -122,12 +78,12 @@ static int
 xbow_mmap(struct file * file, struct vm_area_struct * vma)
 {
         unsigned long           phys_addr;
-        int                     error = 0;
+        int                     error;
 
         phys_addr = (unsigned long)file->private_data & ~0xc000000000000000; /* Mask out the Uncache bits */
         vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
         vma->vm_flags |= VM_RESERVED | VM_IO;
-        error = io_remap_page_range(vma, phys_addr, vma->vm_start,
+        error = io_remap_page_range(vma, vma->vm_start, phys_addr,
                                    vma->vm_end-vma->vm_start,
                                    vma->vm_page_prot);
         return(error);
@@ -143,23 +99,6 @@ struct file_operations xbow_fops = {
         .mmap		= xbow_mmap,
 };
 
-/*
- *    xbow_mlreset: called at mlreset time if the
- *      platform specific code determines that there is
- *      a crossbow in a critical path that must be
- *      functional before the driver would normally get
- *      the device properly set up.
- *
- *      what do we need to do, that the boot prom can
- *      not be counted on to have already done, that is
- *      generic across all platforms using crossbows?
- */
-/*ARGSUSED */
-void
-xbow_mlreset(xbow_t * xbow)
-{
-}
-
 #ifdef XBRIDGE_REGS_SIM
 /*    xbow_set_simulated_regs: sets xbow regs as needed
  *	for powering through the boot
@@ -201,8 +140,8 @@ xbow_attach(vertex_hdl_t conn)
     /*REFERENCED */
     vertex_hdl_t            vhdl;
     vertex_hdl_t            busv;
-    xbow_t                 *xbow;
-    xbow_soft_t             soft;
+    xbow_t                  *xbow;
+    struct xbow_soft_s      *soft;
     int                     port;
     xswitch_info_t          info;
     xtalk_intr_t            intr_hdl;
@@ -211,15 +150,14 @@ xbow_attach(vertex_hdl_t conn)
     int                     rev;
     int			    i;
     int			    xbow_num;
+#if DEBUG && ATTACH_DEBUG
+    char		    name[MAXDEVNAME];
+#endif
     static void xbow_errintr_handler(int, void *, struct pt_regs *);
 
 	
 #if DEBUG && ATTACH_DEBUG
-#if defined(SUPPORT_PRINTING_V_FORMAT)
-    printk("%v: xbow_attach\n", conn);
-#else
-    printk("0x%x: xbow_attach\n", conn);
-#endif
+    printk("%s: xbow_attach\n", vertex_to_name(conn, name, MAXDEVNAME));
 #endif
 
     /*
@@ -229,6 +167,8 @@ xbow_attach(vertex_hdl_t conn)
 #ifdef XBRIDGE_REGS_SIM
     printk("xbow_attach: XBRIDGE_REGS_SIM FIXME: allocating %ld bytes for xbow_s\n", sizeof(xbow_t));
     xbow = (xbow_t *) kmalloc(sizeof(xbow_t), GFP_KERNEL);
+    if (!xbow)
+	    return -ENOMEM;
     /*
      * turn on ports e and f like in a real live ibrick
      */
@@ -260,7 +200,6 @@ xbow_attach(vertex_hdl_t conn)
      * Register a xbow driver with hwgraph.
      * file ops.
      */
-    vhdl = NULL;
     vhdl = hwgraph_register(conn, EDGE_LBL_XBOW, 0,
 	   0, 0, 0,
 	   S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, 0, 0,
@@ -274,7 +213,9 @@ xbow_attach(vertex_hdl_t conn)
      * Allocate the soft state structure and attach
      * it to the xbow's vertex
      */
-    NEW(soft);
+    soft = kmalloc(sizeof(*soft), GFP_KERNEL);
+    if (!soft)
+	    return -ENOMEM;
     soft->conn = conn;
     soft->vhdl = vhdl;
     soft->busv = busv;
@@ -298,6 +239,10 @@ xbow_attach(vertex_hdl_t conn)
     s = dev_to_name(vhdl, devnm, MAXDEVNAME);
     soft->name = kmalloc(strlen(s) + strlen(XBOW_NUM_SUFFIX_FORMAT) + 1, 
 			    GFP_KERNEL);
+    if (!soft->name) {
+	    kfree(soft);
+	    return -ENOMEM;
+    }
     sprintf(soft->name,"%s"XBOW_NUM_SUFFIX_FORMAT, s,xbow_num);
 
 #ifdef XBRIDGE_REGS_SIM
@@ -311,14 +256,6 @@ xbow_attach(vertex_hdl_t conn)
 #endif /* XBRIDGE_REGS_SIM */
     rev = XWIDGET_PART_REV_NUM(id);
 
-    mutex_spinlock_init(&soft->xbow_perf_lock);
-    soft->xbow_perfcnt[0].xp_perf_reg = &xbow->xb_perf_ctr_a;
-    soft->xbow_perfcnt[1].xp_perf_reg = &xbow->xb_perf_ctr_b;
-
-    /* Initialization for GBR bw allocation */
-    mutex_spinlock_init(&soft->xbow_bw_alloc_lock);
-
-#define	XBOW_8_BIT_PORT_BW_MAX		(400 * 1000 * 1000)	/* 400 MB/s */
 #define XBOW_16_BIT_PORT_BW_MAX		(800 * 1000 * 1000)	/* 800 MB/s */
 
     /* Set bandwidth hiwatermark and current values */
@@ -419,43 +356,6 @@ xbow_attach(vertex_hdl_t conn)
     return 0;				/* attach successful */
 }
 
-/* This contains special-case code for grio. There are plans to make
- * this general sometime in the future, but till then this should
- * be good enough.
- */
-xwidgetnum_t
-xbow_widget_num_get(vertex_hdl_t dev)
-{
-	vertex_hdl_t	tdev;
-	char		devname[MAXDEVNAME];
-	xwidget_info_t	xwidget_info;
-	int		i;
-
-	vertex_to_name(dev, devname, MAXDEVNAME);
-
-	/* If this is a pci controller vertex, traverse up using
-	 * the ".." links to get to the widget.
-	 */
-	if (strstr(devname, EDGE_LBL_PCI) &&
-			strstr(devname, EDGE_LBL_CONTROLLER)) {
-		tdev = dev;
-		for (i=0; i< 2; i++) {
-			if (hwgraph_edge_get(tdev,
-				HWGRAPH_EDGELBL_DOTDOT, &tdev) !=
-					GRAPH_SUCCESS)
-				return XWIDGET_NONE;
-		}
-
-		if ((xwidget_info = xwidget_info_chk(tdev)) != NULL) {
-			return (xwidget_info_id_get(xwidget_info));
-		} else {
-			return XWIDGET_NONE;
-		}
-	}
-
-	return XWIDGET_NONE;
-}
-
 /*
  * xbow_widget_present: See if a device is present
  * on the specified port of this crossbow.
@@ -477,6 +377,10 @@ xbow_widget_present(xbow_t *xbow, int po
 					IS_PIC_XBOW(xbow->xb_wid_id) && port==0xf) {
 			return 1;
 		}
+		else if ( IS_PIC_XBOW(xbow->xb_wid_id) && port==0xb ) {
+			/* for opus the present bit doesn't work on port 0xb */
+			return 1;
+		}
 		return xbow->xb_link(port).link_aux_status & XB_AUX_STAT_PRESENT;
 	}
 }
@@ -562,10 +466,8 @@ xbow_intr_preset(void *which_widget,
 				    XEM_ADD_NVAR("ioe." #n, p);		\
 				}
 
-int                     xbow_xmit_retry_errors;
-
 int
-xbow_xmit_retry_error(xbow_soft_t soft,
+xbow_xmit_retry_error(struct xbow_soft_s *soft,
 		      int port)
 {
     xswitch_info_t          info;
@@ -600,46 +502,18 @@ xbow_xmit_retry_error(xbow_soft_t soft,
     part = XWIDGET_PART_NUM(id);
     mfgr = XWIDGET_MFG_NUM(id);
 
-    /* If this thing is not a Bridge,
-     * do not activate the WAR, and
-     * tell our caller we do not need
-     * to be called again.
-     */
-    if ((part != BRIDGE_WIDGET_PART_NUM) ||
-	(mfgr != BRIDGE_WIDGET_MFGR_NUM)) {
-		/* FIXME: add Xbridge to the WAR.
-		 * Shouldn't hurt anything.  Later need to
-		 * check if we can remove this.
-                 */
-    		if ((part != XBRIDGE_WIDGET_PART_NUM) ||
-		    (mfgr != XBRIDGE_WIDGET_MFGR_NUM))
-			return 0;
-    }
-
-    /* count how many times we
-     * have picked up after
-     * LLP Transmit problems.
-     */
-    xbow_xmit_retry_errors++;
-
-    /* rewrite the control register
-     * to fix things up.
-     */
-    wid->w_control = wid->w_control;
-    wid->w_control;
-
-    return 1;
+    return 0;
 }
 
 /*
  * xbow_errintr_handler will be called if the xbow
  * sends an interrupt request to report an error.
  */
-static void
+static irqreturn_t
 xbow_errintr_handler(int irq, void *arg, struct pt_regs *ep)
 {
     ioerror_t               ioe[1];
-    xbow_soft_t             soft = (xbow_soft_t) arg;
+    struct xbow_soft_s     *soft = (struct xbow_soft_s *)arg;
     xbow_t                 *xbow = soft->base;
     xbowreg_t               wid_control;
     xbowreg_t               wid_stat;
@@ -805,8 +679,9 @@ xbow_errintr_handler(int irq, void *arg,
 	XEM_ADD_VAR(wid_err_upper);
 	XEM_ADD_VAR(wid_err_lower);
 	XEM_ADD_VAR(wid_err_addr);
-	PRINT_PANIC("XIO Bus Error");
+	panic("XIO Bus Error");
     }
+    return IRQ_HANDLED;
 }
 
 /*
@@ -831,10 +706,10 @@ xbow_error_handler(
 		      ioerror_mode_t mode,
 		      ioerror_t *ioerror)
 {
-    int                     retval = IOERROR_WIDGETLEVEL;
+    int                    retval = IOERROR_WIDGETLEVEL;
 
-    xbow_soft_t             soft = (xbow_soft_t) einfo;
-    int                     port;
+    struct xbow_soft_s    *soft = (struct xbow_soft_s *) einfo;
+    int                   port;
     vertex_hdl_t          conn;
     vertex_hdl_t          busv;
 
@@ -958,8 +833,9 @@ xbow_error_handler(
     if (XBOW_WAR_ENABLED(PV854827, xbow->xb_wid_id) &&
 		IS_PIC_XBOW(xbow->xb_wid_id) && (port==0xf))
 		;
-    else
-    if (!(link_aux_status & XB_AUX_STAT_PRESENT)) {
+    else if (IS_PIC_XBOW(xbow->xb_wid_id) && (port==0xb))
+		;	/* WAR for opus this is missing on 0xb */
+    else if (!(link_aux_status & XB_AUX_STAT_PRESENT)) {
 	/* nobody connected. */
 	if (mode == MODE_DEVPROBE)
 	    return IOERROR_HANDLED;
@@ -1087,173 +963,6 @@ xbow_error_handler(
     return retval;
 }
 
-void
-xbow_update_perf_counters(vertex_hdl_t vhdl)
-{
-    xbow_soft_t             xbow_soft = xbow_soft_get(vhdl);
-    xbow_perf_t            *xbow_perf = xbow_soft->xbow_perfcnt;
-    xbow_perf_link_t       *xbow_plink = xbow_soft->xbow_perflink;
-    xbow_perfcount_t        perf_reg;
-    unsigned long           s;
-    int                     link, i;
-
-    for (i = 0; i < XBOW_PERF_COUNTERS; i++, xbow_perf++) {
-	if (xbow_perf->xp_mode == XBOW_MONITOR_NONE)
-	    continue;
-
-	s = mutex_spinlock(&xbow_soft->xbow_perf_lock);
-
-	perf_reg.xb_counter_val = *(xbowreg_t *) xbow_perf->xp_perf_reg;
-
-	link = perf_reg.xb_perf.link_select;
-
-	(xbow_plink + link)->xlp_cumulative[xbow_perf->xp_curmode] +=
-	    ((perf_reg.xb_perf.count - xbow_perf->xp_current) & XBOW_COUNTER_MASK);
-	xbow_perf->xp_current = perf_reg.xb_perf.count;
-
-	mutex_spinunlock(&xbow_soft->xbow_perf_lock, s);
-    }
-}
-
-xbow_perf_link_t       *
-xbow_get_perf_counters(vertex_hdl_t vhdl)
-{
-    xbow_soft_t             xbow_soft = xbow_soft_get(vhdl);
-    xbow_perf_link_t       *xbow_perf_link = xbow_soft->xbow_perflink;
-
-    return xbow_perf_link;
-}
-
-int
-xbow_enable_perf_counter(vertex_hdl_t vhdl, int link, int mode, int counter)
-{
-    xbow_soft_t             xbow_soft = xbow_soft_get(vhdl);
-    xbow_perf_t            *xbow_perf = xbow_soft->xbow_perfcnt;
-    xbow_linkctrl_t         xbow_link_ctrl;
-    xbow_t                 *xbow = xbow_soft->base;
-    xbow_perfcount_t        perf_reg;
-    unsigned long           s;
-    int                     i;
-
-    link -= BASE_XBOW_PORT;
-    if ((link < 0) || (link >= MAX_XBOW_PORTS))
-	return -1;
-
-    if ((mode < XBOW_MONITOR_NONE) || (mode > XBOW_MONITOR_DEST_LINK))
-	return -1;
-
-    if ((counter < 0) || (counter >= XBOW_PERF_COUNTERS))
-	return -1;
-
-    s = mutex_spinlock(&xbow_soft->xbow_perf_lock);
-
-    if ((xbow_perf + counter)->xp_mode && mode) {
-	mutex_spinunlock(&xbow_soft->xbow_perf_lock, s);
-	return -1;
-    }
-    for (i = 0; i < XBOW_PERF_COUNTERS; i++) {
-	if (i == counter)
-	    continue;
-	if (((xbow_perf + i)->xp_link == link) &&
-	    ((xbow_perf + i)->xp_mode)) {
-	    mutex_spinunlock(&xbow_soft->xbow_perf_lock, s);
-	    return -1;
-	}
-    }
-    xbow_perf += counter;
-
-    xbow_perf->xp_curlink = xbow_perf->xp_link = link;
-    xbow_perf->xp_curmode = xbow_perf->xp_mode = mode;
-
-    xbow_link_ctrl.xbl_ctrlword = xbow->xb_link_raw[link].link_control;
-    xbow_link_ctrl.xb_linkcontrol.perf_mode = mode;
-    xbow->xb_link_raw[link].link_control = xbow_link_ctrl.xbl_ctrlword;
-
-    perf_reg.xb_counter_val = *(xbowreg_t *) xbow_perf->xp_perf_reg;
-    perf_reg.xb_perf.link_select = link;
-    *(xbowreg_t *) xbow_perf->xp_perf_reg = perf_reg.xb_counter_val;
-    xbow_perf->xp_current = perf_reg.xb_perf.count;
-
-    mutex_spinunlock(&xbow_soft->xbow_perf_lock, s);
-    return 0;
-}
-
-xbow_link_status_t     *
-xbow_get_llp_status(vertex_hdl_t vhdl)
-{
-    xbow_soft_t             xbow_soft = xbow_soft_get(vhdl);
-    xbow_link_status_t     *xbow_llp_status = xbow_soft->xbow_link_status;
-
-    return xbow_llp_status;
-}
-
-void
-xbow_update_llp_status(vertex_hdl_t vhdl)
-{
-    xbow_soft_t             xbow_soft = xbow_soft_get(vhdl);
-    xbow_link_status_t     *xbow_llp_status = xbow_soft->xbow_link_status;
-    xbow_t                 *xbow;
-    xbwX_stat_t             lnk_sts;
-    xbow_aux_link_status_t  aux_sts;
-    int                     link;
-    vertex_hdl_t	    xwidget_vhdl;
-    char		   *xwidget_name;	
-
-    xbow = (xbow_t *) xbow_soft->base;
-    for (link = 0; link < MAX_XBOW_PORTS; link++, xbow_llp_status++) {
-	/* Get the widget name corresponding the current link.
-	 * Note : 0 <= link < MAX_XBOW_PORTS(8).
-	 * 	  BASE_XBOW_PORT(0x8) <= xwidget number < MAX_PORT_NUM (0x10)
-	 */
-	xwidget_vhdl = xbow_widget_lookup(xbow_soft->busv,link+BASE_XBOW_PORT);
-	xwidget_name = xwidget_name_get(xwidget_vhdl);
-	aux_sts.aux_linkstatus
-	    = xbow->xb_link_raw[link].link_aux_status;
-	lnk_sts.linkstatus = xbow->xb_link_raw[link].link_status_clr;
-
-	if (lnk_sts.link_alive == 0)
-	    continue;
-
-	xbow_llp_status->rx_err_count +=
-	    aux_sts.xb_aux_linkstatus.rx_err_cnt;
-
-	xbow_llp_status->tx_retry_count +=
-	    aux_sts.xb_aux_linkstatus.tx_retry_cnt;
-
-	if (lnk_sts.linkstatus & ~(XB_STAT_RCV_ERR | XB_STAT_XMT_RTRY_ERR | XB_STAT_LINKALIVE)) {
-#ifdef	LATER
-	    printk(KERN_WARNING  "link %d[%s]: bad status 0x%x\n",
-		    link, xwidget_name, lnk_sts.linkstatus);
-#endif
-	}
-    }
-}
-
-int
-xbow_disable_llp_monitor(vertex_hdl_t vhdl)
-{
-    xbow_soft_t             xbow_soft = xbow_soft_get(vhdl);
-    int                     port;
-
-    for (port = 0; port < MAX_XBOW_PORTS; port++) {
-	xbow_soft->xbow_link_status[port].rx_err_count = 0;
-	xbow_soft->xbow_link_status[port].tx_retry_count = 0;
-    }
-
-    xbow_soft->link_monitor = 0;
-    return 0;
-}
-
-int
-xbow_enable_llp_monitor(vertex_hdl_t vhdl)
-{
-    xbow_soft_t             xbow_soft = xbow_soft_get(vhdl);
-
-    xbow_soft->link_monitor = 1;
-    return 0;
-}
-
-
 int
 xbow_reset_link(vertex_hdl_t xconn_vhdl)
 {
@@ -1262,15 +971,10 @@ xbow_reset_link(vertex_hdl_t xconn_vhdl)
     xbow_t                 *xbow;
     xbowreg_t               ctrl;
     xbwX_stat_t             stat;
-    unsigned                itick;
-    unsigned                dtick;
-    static int              ticks_per_ms = 0;
-
-    if (!ticks_per_ms) {
-	itick = get_timestamp();
-	us_delay(1000);
-	ticks_per_ms = get_timestamp() - itick;
-    }
+    unsigned                long itick;
+    unsigned int            dtick;
+    static long             ticks_to_wait = HZ / 1000;
+
     widget_info = xwidget_info_get(xconn_vhdl);
     port = xwidget_info_id_get(widget_info);
 
@@ -1279,7 +983,7 @@ xbow_reset_link(vertex_hdl_t xconn_vhdl)
 #else
     {
 	vertex_hdl_t            xbow_vhdl;
-	xbow_soft_t             xbow_soft;
+	struct xbow_soft_s      *xbow_soft;
 
 	hwgraph_traverse(xconn_vhdl, ".master/xtalk/0/xbow", &xbow_vhdl);
 	xbow_soft = xbow_soft_get(xbow_vhdl);
@@ -1296,155 +1000,17 @@ xbow_reset_link(vertex_hdl_t xconn_vhdl)
      */
     ctrl = xbow->xb_link(port).link_control;
     xbow->xb_link(port).link_reset = 0;
-    itick = get_timestamp();
+    itick = jiffies;
     while (1) {
 	stat.linkstatus = xbow->xb_link(port).link_status;
 	if (stat.link_alive)
 	    break;
-	dtick = get_timestamp() - itick;
-	if (dtick > ticks_per_ms) {
+	dtick = jiffies - itick;
+	if (dtick > ticks_to_wait) {
 	    return -1;			/* never came out of reset */
 	}
-	DELAY(2);			/* don't beat on link_status */
+	udelay(2);			/* don't beat on link_status */
     }
     xbow->xb_link(port).link_control = ctrl;
     return 0;
 }
-
-#define XBOW_ARB_RELOAD_TICKS		25
-					/* granularity: 4 MB/s, max: 124 MB/s */
-#define GRANULARITY			((100 * 1000000) / XBOW_ARB_RELOAD_TICKS)
-
-#define XBOW_BYTES_TO_GBR(BYTES_per_s)	(int) (BYTES_per_s / GRANULARITY)
-
-#define XBOW_GBR_TO_BYTES(cnt)		(bandwidth_t) ((cnt) * GRANULARITY)
-
-#define CEILING_BYTES_TO_GBR(gbr, bytes_per_sec)	\
-			((XBOW_GBR_TO_BYTES(gbr) < bytes_per_sec) ? gbr+1 : gbr)
-
-#define XBOW_ARB_GBR_MAX		31
-
-#define ABS(x)				((x > 0) ? (x) : (-1 * x))
-					/* absolute value */
-
-int
-xbow_bytes_to_gbr(bandwidth_t old_bytes_per_sec, bandwidth_t bytes_per_sec)
-{
-    int                     gbr_granted;
-    int                     new_total_gbr;
-    int                     change_gbr;
-    bandwidth_t             new_total_bw;
-
-#ifdef GRIO_DEBUG
-    printk("xbow_bytes_to_gbr: old_bytes_per_sec %lld bytes_per_sec %lld\n",
-		old_bytes_per_sec, bytes_per_sec);
-#endif	/* GRIO_DEBUG */
-
-    gbr_granted = CEILING_BYTES_TO_GBR((XBOW_BYTES_TO_GBR(old_bytes_per_sec)),
-			old_bytes_per_sec);
-    new_total_bw = old_bytes_per_sec + bytes_per_sec;
-    new_total_gbr = CEILING_BYTES_TO_GBR((XBOW_BYTES_TO_GBR(new_total_bw)),
-			new_total_bw);
-
-    change_gbr = new_total_gbr - gbr_granted;
-
-#ifdef GRIO_DEBUG
-    printk("xbow_bytes_to_gbr: gbr_granted %d new_total_gbr %d change_gbr %d\n",
-		gbr_granted, new_total_gbr, change_gbr);
-#endif	/* GRIO_DEBUG */
-
-    return (change_gbr);
-}
-
-/* Conversion from GBR to bytes */
-bandwidth_t
-xbow_gbr_to_bytes(int gbr)
-{
-    return (XBOW_GBR_TO_BYTES(gbr));
-}
-
-/* Given the vhdl for the desired xbow, the src and dest. widget ids
- * and the req_bw value, this xbow driver entry point accesses the
- * xbow registers and allocates the desired bandwidth if available.
- *
- * If bandwidth allocation is successful, return success else return failure.
- */
-int
-xbow_prio_bw_alloc(vertex_hdl_t vhdl,
-		xwidgetnum_t src_wid,
-		xwidgetnum_t dest_wid,
-		unsigned long long old_alloc_bw,
-		unsigned long long req_bw)
-{
-    xbow_soft_t             soft = xbow_soft_get(vhdl);
-    volatile xbowreg_t     *xreg;
-    xbowreg_t               mask;
-    unsigned long           s;
-    int                     error = 0;
-    bandwidth_t             old_bw_BYTES, req_bw_BYTES;
-    xbowreg_t               old_xreg;
-    int                     old_bw_GBR, req_bw_GBR, new_bw_GBR;
-
-#ifdef GRIO_DEBUG
-    printk("xbow_prio_bw_alloc: vhdl %d src_wid %d dest_wid %d req_bw %lld\n",
-		(int) vhdl, (int) src_wid, (int) dest_wid, req_bw);
-#endif
-
-    ASSERT(XBOW_WIDGET_IS_VALID(src_wid));
-    ASSERT(XBOW_WIDGET_IS_VALID(dest_wid));
-
-    s = mutex_spinlock(&soft->xbow_bw_alloc_lock);
-
-    /* Get pointer to the correct register */
-    xreg = XBOW_PRIO_ARBREG_PTR(soft->base, dest_wid, src_wid);
-
-    /* Get mask for GBR count value */
-    mask = XB_ARB_GBR_MSK << XB_ARB_GBR_SHFT(src_wid);
-
-    req_bw_GBR = xbow_bytes_to_gbr(old_alloc_bw, req_bw);
-    req_bw_BYTES = (req_bw_GBR < 0) ? (-1 * xbow_gbr_to_bytes(ABS(req_bw_GBR)))
-		: xbow_gbr_to_bytes(req_bw_GBR);
-
-#ifdef GRIO_DEBUG
-    printk("req_bw %lld req_bw_BYTES %lld req_bw_GBR %d\n",
-		req_bw, req_bw_BYTES, req_bw_GBR);
-#endif	/* GRIO_DEBUG */
-
-    old_bw_BYTES = soft->bw_cur_used[(int) dest_wid - MAX_XBOW_PORTS];
-    old_xreg = *xreg;
-    old_bw_GBR = (((*xreg) & mask) >> XB_ARB_GBR_SHFT(src_wid));
-
-#ifdef GRIO_DEBUG
-    ASSERT(XBOW_BYTES_TO_GBR(old_bw_BYTES) == old_bw_GBR);
-
-    printk("old_bw_BYTES %lld old_bw_GBR %d\n", old_bw_BYTES, old_bw_GBR);
-
-    printk("req_bw_BYTES %lld old_bw_BYTES %lld soft->bw_hiwm %lld\n",
-		req_bw_BYTES, old_bw_BYTES,
-		soft->bw_hiwm[(int) dest_wid - MAX_XBOW_PORTS]);
-	   
-#endif				/* GRIO_DEBUG */
-
-    /* Accept the request only if we don't exceed the destination
-     * port HIWATER_MARK *AND* the max. link GBR arbitration count
-     */
-    if (((old_bw_BYTES + req_bw_BYTES) <=
-		soft->bw_hiwm[(int) dest_wid - MAX_XBOW_PORTS]) &&
-		(req_bw_GBR + old_bw_GBR <= XBOW_ARB_GBR_MAX)) {
-
-	new_bw_GBR = (old_bw_GBR + req_bw_GBR);
-
-	/* Set this in the xbow link register */
-	*xreg = (old_xreg & ~mask) | \
-	    (new_bw_GBR << XB_ARB_GBR_SHFT(src_wid) & mask);
-
-	soft->bw_cur_used[(int) dest_wid - MAX_XBOW_PORTS] =
-			xbow_gbr_to_bytes(new_bw_GBR);
-    } else {
-	error = 1;
-    }
-
-    mutex_spinunlock(&soft->xbow_bw_alloc_lock, s);
-
-    return (error);
-}
diff -puN arch/ia64/sn/io/sn2/xtalk.c~linus arch/ia64/sn/io/sn2/xtalk.c
--- 25/arch/ia64/sn/io/sn2/xtalk.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/sn2/xtalk.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -13,7 +12,6 @@
 #include <asm/sn/driver.h>
 #include <asm/sn/io.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/labelcl.h>
 #include <asm/sn/hcl_util.h>
@@ -23,9 +21,9 @@
 #include <asm/sn/xtalk/xtalk_private.h>
 
 /*
- * Implement crosstalk provider operations.  The xtalk* layer provides a
- * platform-independent interface for crosstalk devices.  This layer
- * switches among the possible implementations of a crosstalk adapter.
+ * Implement io channel provider operations.  The xtalk* layer provides a
+ * platform-independent interface for io channel devices.  This layer
+ * switches among the possible implementations of a io channel adapter.
  *
  * On platforms with only one possible xtalk provider, macros can be
  * set up at the top that cause the table lookups and indirections to
@@ -37,11 +35,6 @@
 
 char                    widget_info_fingerprint[] = "widget_info";
 
-#define	DEV_FUNC(dev,func)	hub_##func
-#define	CAST_PIOMAP(x)		((hub_piomap_t)(x))
-#define	CAST_DMAMAP(x)		((hub_dmamap_t)(x))
-#define	CAST_INTR(x)		((hub_intr_t)(x))
-
 /* =====================================================================
  *            Function Table of Contents
  */
@@ -71,7 +64,6 @@ int                     xtalk_intr_conne
 void                    xtalk_intr_disconnect(xtalk_intr_t);
 vertex_hdl_t            xtalk_intr_cpu_get(xtalk_intr_t);
 int                     xtalk_error_handler(vertex_hdl_t, int, ioerror_mode_t, ioerror_t *);
-int                     xtalk_error_devenable(vertex_hdl_t, int, int);
 void                    xtalk_provider_startup(vertex_hdl_t);
 void                    xtalk_provider_shutdown(vertex_hdl_t);
 vertex_hdl_t            xtalk_intr_dev_get(xtalk_intr_t);
@@ -121,6 +113,7 @@ char			*xwidget_name_get(vertex_hdl_t);
 #define	CAST_PIOMAP(x)		((xtalk_piomap_t)(x))
 #define	CAST_DMAMAP(x)		((xtalk_dmamap_t)(x))
 #define	CAST_INTR(x)		((xtalk_intr_t)(x))
+xtalk_provider_t * xwidget_info_pops_get(xwidget_info_t info);
 
 static xtalk_provider_t *
 xwidget_to_provider_fns(vertex_hdl_t xconn)
@@ -136,6 +129,17 @@ xwidget_to_provider_fns(vertex_hdl_t xco
 
     return (provider_fns);
 }
+
+xtalk_provider_t *
+xwidget_info_pops_get(xwidget_info_t info) {
+	vertex_hdl_t master = info->w_master;
+	xtalk_provider_t *provider_fns;
+
+	provider_fns = xtalk_provider_fns_get(master);
+
+	ASSERT(provider_fns != NULL);
+	return provider_fns;
+}
 #endif
 
 /*
@@ -273,13 +277,13 @@ xtalk_set_early_piotrans_addr(xtalk_earl
 }
 
 /* xtalk_early_piotrans_addr:
- * figure out a PIO address for the "nth" crosstalk widget that
+ * figure out a PIO address for the "nth" io channel widget that
  * matches the specified part and mfgr number. Returns NULL if
  * there is no such widget, or if the requested mapping can not
  * be constructed.
- * Limitations on which crosstalk slots (and busses) are
+ * Limitations on which io channel slots (and busses) are
  * checked, and definitions of the ordering of the search across
- * the crosstalk slots, are defined by the platform.
+ * the io channel slots, are defined by the platform.
  */
 caddr_t
 xtalk_early_piotrans_addr(xwidget_part_num_t part_num,
@@ -310,7 +314,7 @@ null_xtalk_early_piotrans_addr(xwidget_p
 			       unsigned flags)
 {
 #if DEBUG
-    PRINT_PANIC("null_xtalk_early_piotrans_addr");
+    panic("null_xtalk_early_piotrans_addr");
 #endif
     return NULL;
 }
@@ -318,7 +322,7 @@ null_xtalk_early_piotrans_addr(xwidget_p
 /* =====================================================================
  *                    DMA MANAGEMENT
  *
- *      For mapping from crosstalk space to system
+ *      For mapping from io channel space to system
  *      physical space.
  */
 
@@ -415,7 +419,7 @@ xtalk_dmalist_drain(vertex_hdl_t dev, al
 /* =====================================================================
  *                    INTERRUPT MANAGEMENT
  *
- *      Allow crosstalk devices to establish interrupts
+ *      Allow io channel devices to establish interrupts
  */
 
 /*
@@ -510,8 +514,8 @@ xtalk_intr_cpu_get(xtalk_intr_t intr_hdl
  * This routine plays two roles during error delivery
  * to most widgets: first, the external agent (heart,
  * hub, or whatever) calls in with the error and the
- * connect point representing the crosstalk switch,
- * or whatever crosstalk device is directly connected
+ * connect point representing the io channel switch,
+ * or whatever io channel device is directly connected
  * to the agent.
  *
  * If there is a switch, it will generally look at the
@@ -528,6 +532,8 @@ xtalk_error_handler(
 		       ioerror_t *ioerror)
 {
     xwidget_info_t          xwidget_info;
+    char		    name[MAXDEVNAME];
+
 
     xwidget_info = xwidget_info_get(xconn);
     /* Make sure that xwidget_info is a valid pointer before derefencing it.
@@ -548,46 +554,33 @@ xtalk_error_handler(
 	(mode == MODE_DEVREENABLE))
 	return IOERROR_HANDLED;
 
-#if defined(SUPPORT_PRINTING_V_FORMAT)
-    printk(KERN_WARNING "Xbow at %v encountered Fatal error", xconn);
-#else
-    printk(KERN_WARNING "Xbow at 0x%p encountered Fatal error", (void *)xconn);
-#endif
-    ioerror_dump("xtalk", error_code, mode, ioerror);
+    printk(KERN_WARNING "Xbow at %s encountered Fatal error", vertex_to_name(xconn, name, MAXDEVNAME));
 
     return IOERROR_UNHANDLED;
 }
 
-int
-xtalk_error_devenable(vertex_hdl_t xconn_vhdl, int devnum, int error_code)
-{
-    return DEV_FUNC(xconn_vhdl, error_devenable) (xconn_vhdl, devnum, error_code);
-}
-
 
 /* =====================================================================
  *                    CONFIGURATION MANAGEMENT
  */
 
 /*
- * Startup a crosstalk provider
+ * Startup an io channel provider
  */
 void
 xtalk_provider_startup(vertex_hdl_t xtalk_provider)
 {
-    DEV_FUNC(xtalk_provider, provider_startup)
-	(xtalk_provider);
+    ((xtalk_provider_t *) hwgraph_fastinfo_get(xtalk_provider))->provider_startup(xtalk_provider);
 }
 
 
 /*
- * Shutdown a crosstalk provider
+ * Shutdown an io channel provider
  */
 void
 xtalk_provider_shutdown(vertex_hdl_t xtalk_provider)
 {
-    DEV_FUNC(xtalk_provider, provider_shutdown)
-	(xtalk_provider);
+    ((xtalk_provider_t *) hwgraph_fastinfo_get(xtalk_provider))->provider_shutdown(xtalk_provider);
 }
 
 /* 
@@ -608,17 +601,12 @@ xtalk_widgetdev_shutdown(vertex_hdl_t xc
 	return;
 }
 
-int
-xtalk_dma_enabled(vertex_hdl_t xconn_vhdl)
-{
-    return DEV_FUNC(xconn_vhdl, dma_enabled) (xconn_vhdl);
-}
 /*
- * Generic crosstalk functions, for use with all crosstalk providers
- * and all crosstalk devices.
+ * Generic io channel functions, for use with all io channel providers
+ * and all io channel devices.
  */
 
-/****** Generic crosstalk interrupt interfaces ******/
+/* Generic io channel interrupt interfaces */
 vertex_hdl_t
 xtalk_intr_dev_get(xtalk_intr_t xtalk_intr)
 {
@@ -649,7 +637,7 @@ xtalk_intr_sfarg_get(xtalk_intr_t xtalk_
     return (xtalk_intr->xi_sfarg);
 }
 
-/****** Generic crosstalk pio interfaces ******/
+/* Generic io channel pio interfaces */
 vertex_hdl_t
 xtalk_pio_dev_get(xtalk_piomap_t xtalk_piomap)
 {
@@ -681,7 +669,7 @@ xtalk_pio_kvaddr_get(xtalk_piomap_t xtal
 }
 
 
-/****** Generic crosstalk dma interfaces ******/
+/* Generic io channel dma interfaces */
 vertex_hdl_t
 xtalk_dma_dev_get(xtalk_dmamap_t xtalk_dmamap)
 {
@@ -695,7 +683,7 @@ xtalk_dma_target_get(xtalk_dmamap_t xtal
 }
 
 
-/****** Generic crosstalk widget information interfaces ******/
+/* Generic io channel widget information interfaces */
 
 /* xwidget_info_chk:
  * check to see if this vertex is a widget;
@@ -797,7 +785,7 @@ xwidget_info_name_get(xwidget_info_t xwi
 	panic("xwidget_info_name_get: null xwidget_info");
     return(xwidget_info->w_name);
 }
-/****** Generic crosstalk initialization interfaces ******/
+/* Generic io channel initialization interfaces */
 
 /*
  * Associate a set of xtalk_provider functions with a vertex.
@@ -912,16 +900,11 @@ xwidget_unregister(vertex_hdl_t widget)
     if (!(widget_info = xwidget_info_get(widget)))
 	return(1);
 
-    /* Remove the inventory information associated
-     * with the widget.
-     */
-    hwgraph_inventory_remove(widget, -1, -1, -1, -1, -1);
-    
     hwid = &(widget_info->w_hwid);
 
     /* Clean out the xwidget information */
     (void)kfree(widget_info->w_name);
-    BZERO((void *)widget_info, sizeof(widget_info));
+    memset((void *)widget_info, 0, sizeof(widget_info));
     DEL(widget_info);
     
     return(0);
diff -puN /dev/null arch/ia64/sn/io/snia_if.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/ia64/sn/io/snia_if.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,108 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2003 Silicon Graphics, Inc. All rights reserved.
+ */
+
+#include <asm/sn/sgi.h>
+#include <asm/sn/sn_sal.h>
+#include <asm/sn/pci/pci_bus_cvlink.h>
+#include <asm/sn/simulator.h>
+
+extern pciio_provider_t *pciio_to_provider_fns(vertex_hdl_t dev);
+
+int
+snia_badaddr_val(volatile void *addr, int len, volatile void *ptr)
+{
+	int ret = 0;
+	volatile void *new_addr;
+
+	switch (len) {
+	case 4:
+		new_addr = (void *) addr;
+		ret = ia64_sn_probe_io_slot((long) new_addr, len, (void *) ptr);
+		break;
+	default:
+		printk(KERN_WARNING
+		       "snia_badaddr_val given len %x but supports len of 4 only\n",
+		       len);
+	}
+
+	if (ret < 0)
+		panic("snia_badaddr_val: unexpected status (%d) in probing",
+		      ret);
+	return (ret);
+
+}
+
+nasid_t
+snia_get_console_nasid(void)
+{
+	extern nasid_t console_nasid;
+	extern nasid_t master_baseio_nasid;
+
+	if (console_nasid < 0) {
+		console_nasid = ia64_sn_get_console_nasid();
+		if (console_nasid < 0) {
+// ZZZ What do we do if we don't get a console nasid on the hardware????
+			if (IS_RUNNING_ON_SIMULATOR())
+				console_nasid = master_baseio_nasid;
+		}
+	}
+	return console_nasid;
+}
+
+nasid_t
+snia_get_master_baseio_nasid(void)
+{
+	extern nasid_t master_baseio_nasid;
+	extern char master_baseio_wid;
+
+	if (master_baseio_nasid < 0) {
+		master_baseio_nasid = ia64_sn_get_master_baseio_nasid();
+
+		if (master_baseio_nasid >= 0) {
+			master_baseio_wid =
+			    WIDGETID_GET(KL_CONFIG_CH_CONS_INFO
+					 (master_baseio_nasid)->memory_base);
+		}
+	}
+	return master_baseio_nasid;
+}
+
+/*
+ * XXX: should probably be called __sn2_pci_rrb_alloc
+ * used by qla1280
+ */
+
+int
+snia_pcibr_rrb_alloc(struct pci_dev *pci_dev,
+		     int *count_vchan0, int *count_vchan1)
+{
+	vertex_hdl_t dev = PCIDEV_VERTEX(pci_dev);
+
+	return pcibr_rrb_alloc(dev, count_vchan0, count_vchan1);
+}
+
+/* 
+ * XXX: interface should be more like
+ *
+ *     int __sn2_pci_enable_bwswap(struct pci_dev *dev);
+ *     void __sn2_pci_disable_bswap(struct pci_dev *dev);
+ */
+/* used by ioc4 ide */
+
+pciio_endian_t
+snia_pciio_endian_set(struct pci_dev * pci_dev,
+		      pciio_endian_t device_end, pciio_endian_t desired_end)
+{
+	vertex_hdl_t dev = PCIDEV_VERTEX(pci_dev);
+
+	return ((pciio_to_provider_fns(dev))->endian_set)
+		(dev, device_end, desired_end);
+}
+
+EXPORT_SYMBOL(snia_pciio_endian_set);
+EXPORT_SYMBOL(snia_pcibr_rrb_alloc);
diff -puN arch/ia64/sn/io/xswitch.c~linus arch/ia64/sn/io/xswitch.c
--- 25/arch/ia64/sn/io/xswitch.c~linus	2004-01-19 22:17:03.000000000 -0800
+++ 25-akpm/arch/ia64/sn/io/xswitch.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -12,7 +11,6 @@
 #include <asm/sn/sgi.h>
 #include <asm/sn/driver.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/labelcl.h>
 #include <asm/sn/xtalk/xtalk.h>
@@ -65,7 +63,7 @@ xswitch_info_vhdl_set(xswitch_info_t xsw
     if (port > XSWITCH_CENSUS_PORT_MAX)
 	return;
 
-    xswitch_info->vhdl[port] = xwidget;
+    xswitch_info->vhdl[(int)port] = xwidget;
 }
 
 vertex_hdl_t
@@ -75,7 +73,7 @@ xswitch_info_vhdl_get(xswitch_info_t xsw
     if (port > XSWITCH_CENSUS_PORT_MAX)
 	return GRAPH_VERTEX_NONE;
 
-    return xswitch_info->vhdl[port];
+    return xswitch_info->vhdl[(int)port];
 }
 
 /*
@@ -91,7 +89,7 @@ xswitch_info_master_assignment_set(xswit
     if (port > XSWITCH_CENSUS_PORT_MAX)
 	return;
 
-    xswitch_info->master_vhdl[port] = master_vhdl;
+    xswitch_info->master_vhdl[(int)port] = master_vhdl;
 }
 
 vertex_hdl_t
@@ -101,7 +99,7 @@ xswitch_info_master_assignment_get(xswit
     if (port > XSWITCH_CENSUS_PORT_MAX)
 	return GRAPH_VERTEX_NONE;
 
-    return xswitch_info->master_vhdl[port];
+    return xswitch_info->master_vhdl[(int)port];
 }
 
 void
diff -puN arch/ia64/sn/kernel/bte.c~linus arch/ia64/sn/kernel/bte.c
--- 25/arch/ia64/sn/kernel/bte.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ia64/sn/kernel/bte.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,35 +1,9 @@
 /*
- *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
  *
  * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- * 
- * This program is free software; you can redistribute it and/or modify it 
- * under the terms of version 2 of the GNU General Public License 
- * as published by the Free Software Foundation.
- * 
- * This program is distributed in the hope that it would be useful, but 
- * WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * 
- * Further, this software is distributed without any warranty that it is 
- * free of the rightful claim of any third person regarding infringement 
- * or the like.  Any license provided herein, whether implied or 
- * otherwise, applies only to this software file.  Patent licenses, if 
- * any, provided herein do not apply to combinations of this program with 
- * other software, or any other product whatsoever.
- * 
- * You should have received a copy of the GNU General Public 
- * License along with this program; if not, write the Free Software 
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- * 
- * Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 
- * Mountain View, CA  94043, or:
- * 
- * http://www.sgi.com 
- * 
- * For further information regarding this notice, see: 
- * 
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan
  */
 
 #include <linux/config.h>
diff -puN arch/ia64/sn/kernel/irq.c~linus arch/ia64/sn/kernel/irq.c
--- 25/arch/ia64/sn/kernel/irq.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ia64/sn/kernel/irq.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,35 +1,11 @@
 /*
  * Platform dependent support for SGI SN
  *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
  * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- * 
- * This program is free software; you can redistribute it and/or modify it 
- * under the terms of version 2 of the GNU General Public License 
- * as published by the Free Software Foundation.
- * 
- * This program is distributed in the hope that it would be useful, but 
- * WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * 
- * Further, this software is distributed without any warranty that it is 
- * free of the rightful claim of any third person regarding infringement 
- * or the like.  Any license provided herein, whether implied or 
- * otherwise, applies only to this software file.  Patent licenses, if 
- * any, provided herein do not apply to combinations of this program with 
- * other software, or any other product whatsoever.
- * 
- * You should have received a copy of the GNU General Public 
- * License along with this program; if not, write the Free Software 
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- * 
- * Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 
- * Mountain View, CA  94043, or:
- * 
- * http://www.sgi.com 
- * 
- * For further information regarding this notice, see: 
- * 
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan
  */
 
 #include <linux/init.h>
@@ -42,10 +18,8 @@
 #include <asm/pgtable.h>
 #include <asm/sn/sgi.h>
 #include <asm/sn/iograph.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/types.h>
-#include <asm/sn/pci/bridge.h>
 #include <asm/sn/pci/pciio.h>
 #include <asm/sn/pci/pciio_private.h>
 #include <asm/sn/pci/pcibr.h>
@@ -62,11 +36,12 @@
 #include <asm/bitops.h>
 #include <asm/sn/sn2/shub_mmr.h>
 
-int irq_to_bit_pos(int irq);
 static void force_interrupt(int irq);
 extern void pcibr_force_interrupt(pcibr_intr_t intr);
 extern int sn_force_interrupt_flag;
 
+static pcibr_intr_list_t *pcibr_intr_list;
+
 
 
 static unsigned int
@@ -139,8 +114,32 @@ sn_end_irq(unsigned int irq)
 }
 
 static void
-sn_set_affinity_irq(unsigned int irq, unsigned long mask)
+sn_set_affinity_irq(unsigned int irq, cpumask_t mask)
 {
+#if CONFIG_SMP  
+        int redir = 0;
+        pcibr_intr_list_t p = pcibr_intr_list[irq];
+        pcibr_intr_t intr; 
+	int	cpu;
+        extern void sn_shub_redirect_intr(pcibr_intr_t intr, unsigned long cpu);
+        extern void sn_tio_redirect_intr(pcibr_intr_t intr, unsigned long cpu);
+                
+	if (p == NULL)
+		return; 
+        
+	intr = p->il_intr;
+
+	if (intr == NULL)
+		return; 
+
+	cpu = first_cpu(mask);
+	if (IS_PIC_SOFT(intr->bi_soft) ) {
+		sn_shub_redirect_intr(intr, cpu);
+	} else { 
+		return; 
+	}
+	(void) set_irq_affinity_info(irq, cpu_physical_id(intr->bi_cpu), redir);
+#endif /* CONFIG_SMP */
 }
 
 
@@ -187,41 +186,18 @@ sn_irq_init (void)
 	}
 }
 
-int
-bit_pos_to_irq(int bit) {
-#define BIT_TO_IRQ 64
-	if (bit > 118) bit = 118;
-
-        return bit + BIT_TO_IRQ;
-}
-
-int
-irq_to_bit_pos(int irq) {
-#define IRQ_TO_BIT 64
-	int bit = irq - IRQ_TO_BIT;
-
-        return bit;
-}
-
-struct pcibr_intr_list_t {
-	struct pcibr_intr_list_t *next;
-	pcibr_intr_t intr;
-};
-
-static struct pcibr_intr_list_t **pcibr_intr_list;
-
 void
 register_pcibr_intr(int irq, pcibr_intr_t intr) {
-	struct pcibr_intr_list_t *p = kmalloc(sizeof(struct pcibr_intr_list_t), GFP_KERNEL);
-	struct pcibr_intr_list_t *list;
+	pcibr_intr_list_t p = kmalloc(sizeof(struct pcibr_intr_list_s), GFP_KERNEL);
+	pcibr_intr_list_t list;
 	int cpu = SN_CPU_FROM_IRQ(irq);
 
 	if (pcibr_intr_list == NULL) {
-		pcibr_intr_list = kmalloc(sizeof(struct pcibr_intr_list_t *) * NR_IRQS, GFP_KERNEL);
+		pcibr_intr_list = kmalloc(sizeof(pcibr_intr_list_t) * NR_IRQS, GFP_KERNEL);
 		if (pcibr_intr_list == NULL) 
-			pcibr_intr_list = vmalloc(sizeof(struct pcibr_intr_list_t *) * NR_IRQS);
+			pcibr_intr_list = vmalloc(sizeof(pcibr_intr_list_t) * NR_IRQS);
 		if (pcibr_intr_list == NULL) panic("Could not allocate memory for pcibr_intr_list\n");
-		memset( (void *)pcibr_intr_list, 0, sizeof(struct pcibr_intr_list_t *) * NR_IRQS);
+		memset( (void *)pcibr_intr_list, 0, sizeof(pcibr_intr_list_t) * NR_IRQS);
 	}
 	if (pdacpu(cpu)->sn_last_irq < irq) {
 		pdacpu(cpu)->sn_last_irq = irq;
@@ -229,42 +205,42 @@ register_pcibr_intr(int irq, pcibr_intr_
 	if (pdacpu(cpu)->sn_first_irq > irq) pdacpu(cpu)->sn_first_irq = irq;
 	if (!p) panic("Could not allocate memory for pcibr_intr_list_t\n");
 	if ((list = pcibr_intr_list[irq])) {
-		while (list->next) list = list->next;
-		list->next = p;
-		p->next = NULL;
-		p->intr = intr;
+		while (list->il_next) list = list->il_next;
+		list->il_next = p;
+		p->il_next = NULL;
+		p->il_intr = intr;
 	} else {
 		pcibr_intr_list[irq] = p;
-		p->next = NULL;
-		p->intr = intr;
+		p->il_next = NULL;
+		p->il_intr = intr;
 	}
 }
 
 void
 force_polled_int(void) {
 	int i;
-	struct pcibr_intr_list_t *p;
+	pcibr_intr_list_t p;
 
 	for (i=0; i<NR_IRQS;i++) {
 		p = pcibr_intr_list[i];
 		while (p) {
-			if (p->intr){
-				pcibr_force_interrupt(p->intr);
+			if (p->il_intr){
+				pcibr_force_interrupt(p->il_intr);
 			}
-			p = p->next;
+			p = p->il_next;
 		}
 	}
 }
 
 static void
 force_interrupt(int irq) {
-	struct pcibr_intr_list_t *p = pcibr_intr_list[irq];
+	pcibr_intr_list_t p = pcibr_intr_list[irq];
 
 	while (p) {
-		if (p->intr) {
-			pcibr_force_interrupt(p->intr);
+		if (p->il_intr) {
+			pcibr_force_interrupt(p->il_intr);
 		}
-		p = p->next;
+		p = p->il_next;
 	}
 }
 
@@ -286,7 +262,7 @@ sn_check_intr(int irq, pcibr_intr_t intr
 	unsigned long irr_reg;
 
 
-	regval = intr->bi_soft->bs_base->p_int_status_64;
+	regval = pcireg_intr_status_get(intr->bi_soft->bs_base);
 	irr_reg_num = irq_to_vector(irq) / 64;
 	irr_bit = irq_to_vector(irq) % 64;
 	switch (irr_reg_num) {
@@ -324,13 +300,13 @@ sn_lb_int_war_check(void) {
 	if (pda->sn_first_irq == 0) return;
 	for (i=pda->sn_first_irq;
 		i <= pda->sn_last_irq; i++) {
-			struct pcibr_intr_list_t *p = pcibr_intr_list[i];
+			pcibr_intr_list_t p = pcibr_intr_list[i];
 			if (p == NULL) {
 				continue;
 			}
 			while (p) {
-				sn_check_intr(i, p->intr);
-				p = p->next;
+				sn_check_intr(i, p->il_intr);
+				p = p->il_next;
 			}
 	}
 }
diff -puN arch/ia64/sn/kernel/machvec.c~linus arch/ia64/sn/kernel/machvec.c
--- 25/arch/ia64/sn/kernel/machvec.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ia64/sn/kernel/machvec.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,33 +1,9 @@
 /*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
  * Copyright (c) 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
- * 
- * This program is free software; you can redistribute it and/or modify it 
- * under the terms of version 2 of the GNU General Public License 
- * as published by the Free Software Foundation.
- * 
- * This program is distributed in the hope that it would be useful, but 
- * WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * 
- * Further, this software is distributed without any warranty that it is 
- * free of the rightful claim of any third person regarding infringement 
- * or the like.  Any license provided herein, whether implied or 
- * otherwise, applies only to this software file.  Patent licenses, if 
- * any, provided herein do not apply to combinations of this program with 
- * other software, or any other product whatsoever.
- * 
- * You should have received a copy of the GNU General Public 
- * License along with this program; if not, write the Free Software 
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- * 
- * Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 
- * Mountain View, CA  94043, or:
- * 
- * http://www.sgi.com 
- * 
- * For further information regarding this notice, see: 
- * 
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan
  */
 
 #define MACHVEC_PLATFORM_NAME	sn2
diff -puN arch/ia64/sn/kernel/Makefile~linus arch/ia64/sn/kernel/Makefile
--- 25/arch/ia64/sn/kernel/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ia64/sn/kernel/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -7,7 +7,5 @@
 # Copyright (C) 1999,2001-2003 Silicon Graphics, Inc.  All Rights Reserved.
 #
 
-EXTRA_CFLAGS := -DLITTLE_ENDIAN
-
 obj-y				+= probe.o setup.o bte.o irq.o mca.o idle.o sn2/
 obj-$(CONFIG_IA64_GENERIC)      += machvec.o
diff -puN arch/ia64/sn/kernel/mca.c~linus arch/ia64/sn/kernel/mca.c
--- 25/arch/ia64/sn/kernel/mca.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ia64/sn/kernel/mca.c	2004-01-19 22:17:21.000000000 -0800
@@ -2,35 +2,11 @@
  * File:	mca.c
  * Purpose:	SN specific MCA code.
  *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
  * Copyright (C) 2001-2003 Silicon Graphics, Inc.  All Rights Reserved.
- * 
- * This program is free software; you can redistribute it and/or modify it 
- * under the terms of version 2 of the GNU General Public License 
- * as published by the Free Software Foundation.
- * 
- * This program is distributed in the hope that it would be useful, but 
- * WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * 
- * Further, this software is distributed without any warranty that it is 
- * free of the rightful claim of any third person regarding infringement 
- * or the like.  Any license provided herein, whether implied or 
- * otherwise, applies only to this software file.  Patent licenses, if 
- * any, provided herein do not apply to combinations of this program with 
- * other software, or any other product whatsoever.
- * 
- * You should have received a copy of the GNU General Public 
- * License along with this program; if not, write the Free Software 
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- * 
- * Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 
- * Mountain View, CA  94043, or:
- * 
- * http://www.sgi.com 
- * 
- * For further information regarding this notice, see: 
- * 
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan
  */
 
 #include <linux/types.h>
diff -puN arch/ia64/sn/kernel/probe.c~linus arch/ia64/sn/kernel/probe.c
--- 25/arch/ia64/sn/kernel/probe.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ia64/sn/kernel/probe.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,35 +1,11 @@
 /*
  * Platform dependent support for IO probing.
  *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
  * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All rights reserved.
- * 
- * This program is free software; you can redistribute it and/or modify it 
- * under the terms of version 2 of the GNU General Public License 
- * as published by the Free Software Foundation.
- * 
- * This program is distributed in the hope that it would be useful, but 
- * WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * 
- * Further, this software is distributed without any warranty that it is 
- * free of the rightful claim of any third person regarding infringement 
- * or the like.  Any license provided herein, whether implied or 
- * otherwise, applies only to this software file.  Patent licenses, if 
- * any, provided herein do not apply to combinations of this program with 
- * other software, or any other product whatsoever.
- * 
- * You should have received a copy of the GNU General Public 
- * License along with this program; if not, write the Free Software 
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- * 
- * Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 
- * Mountain View, CA  94043, or:
- * 
- * http://www.sgi.com 
- * 
- * For further information regarding this notice, see: 
- * 
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan
  */
 
 #include <asm/sn/sn_sal.h>
diff -puN arch/ia64/sn/kernel/setup.c~linus arch/ia64/sn/kernel/setup.c
--- 25/arch/ia64/sn/kernel/setup.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ia64/sn/kernel/setup.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,33 +1,9 @@
 /*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
  * Copyright (C) 1999,2001-2003 Silicon Graphics, Inc. All rights reserved.
- * 
- * This program is free software; you can redistribute it and/or modify it 
- * under the terms of version 2 of the GNU General Public License 
- * as published by the Free Software Foundation.
- * 
- * This program is distributed in the hope that it would be useful, but 
- * WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * 
- * Further, this software is distributed without any warranty that it is 
- * free of the rightful claim of any third person regarding infringement 
- * or the like.  Any license provided herein, whether implied or 
- * otherwise, applies only to this software file.  Patent licenses, if 
- * any, provided herein do not apply to combinations of this program with 
- * other software, or any other product whatsoever.
- * 
- * You should have received a copy of the GNU General Public 
- * License along with this program; if not, write the Free Software 
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- * 
- * Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 
- * Mountain View, CA  94043, or:
- * 
- * http://www.sgi.com 
- * 
- * For further information regarding this notice, see: 
- * 
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan
  */
 
 #include <linux/config.h>
@@ -82,6 +58,7 @@ extern void bte_init_node (nodepda_t *, 
 extern void bte_init_cpu (void);
 extern void sn_timer_init(void);
 extern unsigned long last_time_offset;
+extern void init_platform_hubinfo(nodepda_t **nodepdaindr);
 extern void (*ia64_mark_idle)(int);
 extern void snidle(int);
 
@@ -93,6 +70,8 @@ u64 sn_partition_serial_number;
 
 short physical_node_map[MAX_PHYSNODE_ID];
 
+int     numionodes;
+
 /*
  * This is the address of the RRegs in the HSpace of the global
  * master.  It is used by a hack in serial.c (serial_[in|out],
@@ -240,9 +219,10 @@ sn_setup(char **cmdline_p)
 	long status, ticks_per_sec, drift;
 	int pxm;
 	int major = sn_sal_rev_major(), minor = sn_sal_rev_minor();
-	extern void io_sh_swapper(int, int);
-	extern nasid_t get_master_baseio_nasid(void);
+	extern nasid_t snia_get_master_baseio_nasid(void);
 	extern void sn_cpu_init(void);
+	extern nasid_t snia_get_console_nasid(void);
+
 
 	MAX_DMA_ADDRESS = PAGE_OFFSET + MAX_PHYS_MEMORY;
 
@@ -263,11 +243,9 @@ sn_setup(char **cmdline_p)
 		panic("PROM version too old\n");
 	}
 
-	io_sh_swapper(get_nasid(), 0);
-
 	master_nasid = get_nasid();
-	(void)get_console_nasid();
-	(void)get_master_baseio_nasid();
+	(void)snia_get_console_nasid();
+	(void)snia_get_master_baseio_nasid();
 
 	status = ia64_sal_freq_base(SAL_FREQ_BASE_REALTIME_CLOCK, &ticks_per_sec, &drift);
 	if (status != 0 || ticks_per_sec < 100000) {
@@ -312,6 +290,12 @@ sn_setup(char **cmdline_p)
 	 */
 	sn_cpu_init();
 
+	/*
+	 * Setup hubinfo stuff. Has to happen AFTER sn_cpu_init(),
+	 * because it uses the cnode to nasid tables.
+	 */
+	init_platform_hubinfo(nodepdaindr);
+
 #ifdef CONFIG_SMP
 	init_smp_config();
 #endif
@@ -329,6 +313,7 @@ void
 sn_init_pdas(char **cmdline_p)
 {
 	cnodeid_t	cnode;
+	void scan_for_ionodes(void);
 
 	/*
 	 * Make sure that the PDA fits entirely in the same page as the 
@@ -341,6 +326,9 @@ sn_init_pdas(char **cmdline_p)
 	for (cnode=0; cnode<numnodes; cnode++)
 		pda->cnodeid_to_nasid_table[cnode] = pxm_to_nasid(nid_to_pxm_map[cnode]);
 
+	numionodes = numnodes;
+	scan_for_ionodes();
+
         /*
          * Allocate & initalize the nodepda for each node.
          */
@@ -398,9 +386,6 @@ sn_cpu_init(void)
 	cnode = nasid_to_cnodeid(nasid);
 	slice = cpu_physical_id_to_slice(cpuphyid);
 
-	printk("CPU %d: nasid %d, slice %d, cnode %d\n",
-			smp_processor_id(), nasid, slice, cnode);
-
 	memset(pda, 0, sizeof(pda));
 	pda->p_nodepda = nodepdaindr[cnode];
 	pda->led_address = (typeof(pda->led_address)) (LED0 + (slice<<LED_CPU_SHIFT));
@@ -445,3 +430,32 @@ sn_cpu_init(void)
 
 	bte_init_cpu();
 }
+
+/*
+ * Scan klconfig for ionodes.  Add the nasids to the
+ * physical_node_map and the pda and increment numionodes.
+ */
+
+void
+scan_for_ionodes(void) {
+	int nasid = 0;
+
+	/* Setup ionodes with memory */
+	for (nasid = 0; nasid < MAX_PHYSNODE_ID; nasid +=2) {
+		u64 klgraph_header;
+		cnodeid_t cnodeid;
+
+		if (physical_node_map[nasid] == -1) 
+			continue;
+
+		klgraph_header = cnodeid = -1;
+		klgraph_header = ia64_sn_get_klconfig_addr(nasid);
+		if (klgraph_header <= 0)
+			BUG(); /* All nodes must have klconfig tables! */
+		cnodeid = nasid_to_cnodeid(nasid);
+		root_lboard[cnodeid] = (lboard_t *)
+					NODE_OFFSET_TO_LBOARD( (nasid),
+					((kl_config_hdr_t *)(klgraph_header))->
+					ch_board_info);
+	}
+}
diff -puN arch/ia64/sn/kernel/sn2/cache.c~linus arch/ia64/sn/kernel/sn2/cache.c
--- 25/arch/ia64/sn/kernel/sn2/cache.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ia64/sn/kernel/sn2/cache.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,4 @@
 /*
- * 
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -8,9 +7,7 @@
  *
  */
 
-#include <linux/module.h>
-#include <asm/cacheflush.h>
-#include <asm/system.h>
+#include <asm/pgalloc.h>
 
 /**
  * sn_flush_all_caches - flush a range of address from all caches (incl. L4)
diff -puN arch/ia64/sn/kernel/sn2/Makefile~linus arch/ia64/sn/kernel/sn2/Makefile
--- 25/arch/ia64/sn/kernel/sn2/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ia64/sn/kernel/sn2/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -9,7 +9,5 @@
 # sn2 specific kernel files
 #
 
-EXTRA_CFLAGS := -DLITTLE_ENDIAN
-
 obj-y += cache.o io.o ptc_deadlock.o sn2_smp.o sn_proc_fs.o \
 	 prominfo_proc.o timer.o
diff -puN arch/ia64/sn/kernel/sn2/sn2_smp.c~linus arch/ia64/sn/kernel/sn2/sn2_smp.c
--- 25/arch/ia64/sn/kernel/sn2/sn2_smp.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ia64/sn/kernel/sn2/sn2_smp.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,35 +1,11 @@
 /*
  * SN2 Platform specific SMP Support
  *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
  * Copyright (C) 2000-2003 Silicon Graphics, Inc. All rights reserved.
- * 
- * This program is free software; you can redistribute it and/or modify it 
- * under the terms of version 2 of the GNU General Public License 
- * as published by the Free Software Foundation.
- * 
- * This program is distributed in the hope that it would be useful, but 
- * WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * 
- * Further, this software is distributed without any warranty that it is 
- * free of the rightful claim of any third person regarding infringement 
- * or the like.  Any license provided herein, whether implied or 
- * otherwise, applies only to this software file.  Patent licenses, if 
- * any, provided herein do not apply to combinations of this program with 
- * other software, or any other product whatsoever.
- * 
- * You should have received a copy of the GNU General Public 
- * License along with this program; if not, write the Free Software 
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- * 
- * Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 
- * Mountain View, CA  94043, or:
- * 
- * http://www.sgi.com 
- * 
- * For further information regarding this notice, see: 
- * 
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan
  */
 
 #include <linux/init.h>
diff -puN arch/ia64/sn/kernel/sn2/sn_proc_fs.c~linus arch/ia64/sn/kernel/sn2/sn_proc_fs.c
--- 25/arch/ia64/sn/kernel/sn2/sn_proc_fs.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ia64/sn/kernel/sn2/sn_proc_fs.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,34 +1,9 @@
 /*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
  *
  * Copyright (C) 2000-2003 Silicon Graphics, Inc. All rights reserved.
- * 
- * This program is free software; you can redistribute it and/or modify it 
- * under the terms of version 2 of the GNU General Public License 
- * as published by the Free Software Foundation.
- * 
- * This program is distributed in the hope that it would be useful, but 
- * WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * 
- * Further, this software is distributed without any warranty that it is 
- * free of the rightful claim of any third person regarding infringement 
- * or the like.  Any license provided herein, whether implied or 
- * otherwise, applies only to this software file.  Patent licenses, if 
- * any, provided herein do not apply to combinations of this program with 
- * other software, or any other product whatsoever.
- * 
- * You should have received a copy of the GNU General Public 
- * License along with this program; if not, write the Free Software 
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- * 
- * Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 
- * Mountain View, CA  94043, or:
- * 
- * http://www.sgi.com 
- * 
- * For further information regarding this notice, see: 
- * 
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan
  */
 #include <linux/config.h>
 #include <asm/uaccess.h>
diff -puN arch/ia64/sn/Makefile~linus arch/ia64/sn/Makefile
--- 25/arch/ia64/sn/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ia64/sn/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -9,6 +9,4 @@
 # Makefile for the sn ia64 subplatform
 #
 
-EXTRA_CFLAGS := -DLITTLE_ENDIAN
-
 obj-y += kernel/ io/
diff -puN arch/m68k/amiga/amisound.c~linus arch/m68k/amiga/amisound.c
--- 25/arch/m68k/amiga/amisound.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68k/amiga/amisound.c	2004-01-19 22:17:21.000000000 -0800
@@ -44,7 +44,7 @@ static unsigned long clock_constant;
 
 void __init amiga_init_sound(void)
 {
-	static struct resource beep_res = { "Beep" };
+	static struct resource beep_res = { .name = "Beep" };
 
 	snd_data = amiga_chip_alloc_res(sizeof(sine_data), &beep_res);
 	if (!snd_data) {
diff -puN arch/m68k/amiga/chipram.c~linus arch/m68k/amiga/chipram.c
--- 25/arch/m68k/amiga/chipram.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68k/amiga/chipram.c	2004-01-19 22:17:21.000000000 -0800
@@ -19,7 +19,9 @@
 
 unsigned long amiga_chip_size;
 
-static struct resource chipram_res = { "Chip RAM", CHIP_PHYSADDR };
+static struct resource chipram_res = {
+    .name = "Chip RAM", .start = CHIP_PHYSADDR
+};
 static unsigned long chipavail;
 
 
diff -puN arch/m68k/amiga/config.c~linus arch/m68k/amiga/config.c
--- 25/arch/m68k/amiga/config.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68k/amiga/config.c	2004-01-19 22:17:21.000000000 -0800
@@ -121,14 +121,22 @@ static struct console amiga_console_driv
 static struct {
     struct resource _ciab, _ciaa, _custom, _kickstart;
 } mb_resources = {
-    ._ciab =		{ "CIA B", 0x00bfd000, 0x00bfdfff },
-    ._ciaa =		{ "CIA A", 0x00bfe000, 0x00bfefff },
-    ._custom =		{ "Custom I/O", 0x00dff000, 0x00dfffff },
-    ._kickstart =	{ "Kickstart ROM", 0x00f80000, 0x00ffffff }
+    ._ciab = {
+	.name = "CIA B", .start = 0x00bfd000, .end = 0x00bfdfff
+    },
+    ._ciaa = {
+	.name = "CIA A", .start = 0x00bfe000, .end = 0x00bfefff
+    },
+    ._custom = {
+	.name = "Custom I/O", .start = 0x00dff000, .end = 0x00dfffff
+    },
+    ._kickstart = {
+	.name = "Kickstart ROM", .start = 0x00f80000, .end = 0x00ffffff
+    }
 };
 
 static struct resource rtc_resource = {
-    NULL, 0x00dc0000, 0x00dcffff
+    .start = 0x00dc0000, .end = 0x00dcffff
 };
 
 static struct resource ram_resource[NUM_MEMINFO];
@@ -495,7 +503,7 @@ static void __init amiga_sched_init(irqr
 							  struct pt_regs *))
 {
 	static struct resource sched_res = {
-	    "timer", 0x00bfd400, 0x00bfd5ff,
+	    .name = "timer", .start = 0x00bfd400, .end = 0x00bfd5ff,
 	};
 	jiffy_ticks = (amiga_eclock+HZ/2)/HZ;
 
@@ -798,12 +806,12 @@ static void amiga_mem_console_write(stru
 
 static void amiga_savekmsg_init(void)
 {
-    static struct resource debug_res = { "Debug" };
+    static struct resource debug_res = { .name = "Debug" };
 
     savekmsg = amiga_chip_alloc_res(SAVEKMSG_MAXMEM, &debug_res);
     savekmsg->magic1 = SAVEKMSG_MAGIC1;
     savekmsg->magic2 = SAVEKMSG_MAGIC2;
-    savekmsg->magicptr = virt_to_phys(savekmsg);
+    savekmsg->magicptr = ZTWO_PADDR(savekmsg);
     savekmsg->size = 0;
 }
 
diff -puN arch/m68k/atari/hades-pci.c~linus arch/m68k/atari/hades-pci.c
--- 25/arch/m68k/atari/hades-pci.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68k/atari/hades-pci.c	2004-01-19 22:17:21.000000000 -0800
@@ -40,13 +40,20 @@ static const char pci_mem_name[] = "PCI 
 static const char pci_io_name[] = "PCI I/O space";
 static const char pci_config_name[] = "PCI config space";
 
-static struct resource config_space = { pci_config_name, HADES_CONFIG_BASE,
-										HADES_CONFIG_BASE + HADES_CONFIG_SIZE - 1 };
-static struct resource io_space = { pci_io_name, HADES_IO_BASE, HADES_IO_BASE +
-								    HADES_IO_SIZE - 1 };
+static struct resource config_space = {
+    .name = pci_config_name,
+    .start = HADES_CONFIG_BASE,
+    .end = HADES_CONFIG_BASE + HADES_CONFIG_SIZE - 1
+};
+static struct resource io_space = {
+    .name = pci_io_name,
+    .start = HADES_IO_BASE,
+    .end = HADES_IO_BASE + HADES_IO_SIZE - 1
+};
 
-static const unsigned long pci_conf_base_phys[] = { 0xA0080000, 0xA0040000,
-												    0xA0020000, 0xA0010000 };
+static const unsigned long pci_conf_base_phys[] = {
+    0xA0080000, 0xA0040000, 0xA0020000, 0xA0010000
+};
 static unsigned long pci_conf_base_virt[N_SLOTS];
 static unsigned long pci_io_base_virt;
 
diff -puN arch/m68k/bvme6000/rtc.c~linus arch/m68k/bvme6000/rtc.c
--- 25/arch/m68k/bvme6000/rtc.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68k/bvme6000/rtc.c	2004-01-19 22:17:21.000000000 -0800
@@ -53,6 +53,7 @@ static int rtc_ioctl(struct inode *inode
 		/* Ensure clock and real-time-mode-register are accessible */
 		msr = rtc->msr & 0xc0;
 		rtc->msr = 0x40;
+		memset(&wtime, 0, sizeof(struct rtc_time));
 		do {
 			wtime.tm_sec =  BCD2BIN(rtc->bcd_sec);
 			wtime.tm_min =  BCD2BIN(rtc->bcd_min);
@@ -164,11 +165,10 @@ static struct file_operations rtc_fops =
 	.release =	rtc_release,
 };
 
-static struct miscdevice rtc_dev=
-{
-	RTC_MINOR,
-	"rtc",
-	&rtc_fops
+static struct miscdevice rtc_dev = {
+	.minor =	RTC_MINOR,
+	.name =		"rtc",
+	.fops =		&rtc_fops
 };
 
 int __init rtc_DP8570A_init(void)
diff -puN arch/m68k/kernel/head.S~linus arch/m68k/kernel/head.S
--- 25/arch/m68k/kernel/head.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68k/kernel/head.S	2004-01-19 22:17:21.000000000 -0800
@@ -23,7 +23,7 @@
 ** 98/04/25 Phil Blundell: added HP300 support
 ** 1998/08/30 David Kilzer: Added support for font_desc structures
 **            for linux-2.1.115
-** 9/02/11  Richard Zidlicky: added Q40 support (initial vesion 99/01/01) 
+** 9/02/11  Richard Zidlicky: added Q40 support (initial vesion 99/01/01)
 **
 ** This file is subject to the terms and conditions of the GNU General Public
 ** License. See the file README.legal in the main directory of this archive
@@ -100,14 +100,14 @@
  *
  *	While this essentially describes the function in the abstract, you'll
  * find more indepth description of other parameters at the implementation site.
- * 
+ *
  * mmu_get_root_table_entry
  * ------------------------
  * mmu_get_ptr_table_entry
  * -----------------------
  * mmu_get_page_table_entry
  * ------------------------
- * 
+ *
  *	These routines are used by other mmu routines to get a pointer into
  * a table, if necessary a new table is allocated. These routines are working
  * basically like pmd_alloc() and pte_alloc() in <asm/pgtable.h>. The root
@@ -273,6 +273,7 @@
  */
 
 #define CONSOLE
+#define CONSOLE_PENGUIN
 
 /*
  * Macintosh serial debug support; outputs boot info to the printer
@@ -310,8 +311,8 @@
 .globl mvme_bdid
 #endif
 #ifdef CONFIG_Q40
-.globl q40_mem_cptr	
-#endif		
+.globl q40_mem_cptr
+#endif
 #ifdef CONFIG_HP300
 .globl hp300_phys_ram_base
 #endif
@@ -422,7 +423,7 @@ PAGE_INDEX_SHIFT = 12
 L(\name):
 	linkw	%a6,#-\stack
 	moveml	\saveregs,%sp@-
-.set	stackstart,-\stack	
+.set	stackstart,-\stack
 
 .macro	func_return_\name
 	moveml	%sp@+,\saveregs
@@ -483,6 +484,12 @@ func_define	set_leds
 func_define	serial_putc,1
 func_define	console_putc,1
 
+func_define	console_init
+func_define	console_put_stats
+func_define	console_put_penguin
+func_define	console_plot_pixel,3
+func_define	console_scroll
+
 .macro	putc	ch
 #if defined(CONSOLE) || defined(SERIAL_DEBUG)
 	pea	\ch
@@ -586,7 +593,7 @@ ENTRY(_stext)
 	.long	MACH_MVME16x, MVME16x_BOOTI_VERSION
 	.long	MACH_BVME6000, BVME6000_BOOTI_VERSION
 	.long	MACH_MAC, MAC_BOOTI_VERSION
-	.long	MACH_Q40, Q40_BOOTI_VERSION	
+	.long	MACH_Q40, Q40_BOOTI_VERSION
 	.long	0
 1:	jra	__start
 
@@ -604,8 +611,8 @@ ENTRY(__start)
    address (apparently 0xff002000 in practice) which is not good if we need
    to be able to map this to VA 0x1000.  We could do it with pagetables but
    a better solution seems to be to relocate the kernel in physical memory
-   before we start.  
-	
+   before we start.
+
    So, we copy the entire kernel image (code+data+bss) down to the 16MB
    boundary that marks the start of RAM.  This is slightly tricky because
    we must not overwrite the copying code itself. :-)  */
@@ -650,7 +657,7 @@ Lcopystart:
 	movel	%d6,%a0
 	addl	#Lstart1,%a0
 	jmp	%a0@
-Lcopyend:	
+Lcopyend:
 
 Lstart1:
 	moveb	#0x3f,%d7
@@ -960,11 +967,11 @@ L(gvtdone):
 #ifdef CONFIG_MAC
 	is_not_mac(L(nocon))
 #ifdef CONSOLE
-	jbsr	L(console_init)
+	console_init
 #ifdef CONSOLE_PENGUIN
-	jbsr	L(console_put_penguin)
+	console_put_penguin
 #endif	/* CONSOLE_PENGUIN */
-	jbsr	L(console_put_stats)
+	console_put_stats
 #endif	/* CONSOLE */
 L(nocon):
 #endif	/* CONFIG_MAC */
@@ -1108,12 +1115,12 @@ L(mmu_init_not_atari):
 
 	mmu_map_tt	#0,#0xfe000000,#0x01000000,#_PAGE_CACHE040W
 	mmu_map_tt	#1,#0xff000000,#0x01000000,#_PAGE_NOCACHE_S
-	
+
 	jbra	L(mmu_init_done)
-	
-L(notq40):		
-#endif	
-	
+
+L(notq40):
+#endif
+
 #ifdef CONFIG_HP300
 	is_not_hp300(L(nothp300))
 
@@ -1130,18 +1137,18 @@ L(nothp300):
 
 #ifdef CONFIG_MVME147
 
-       is_not_mvme147(L(not147))
+	is_not_mvme147(L(not147))
 
-       /*
-	* On MVME147 we have already created kernel page tables for
-	* 4MB of RAM at address 0, so now need to do a transparent
-	* mapping of the top of memory space.  Make it 0.5GByte for now,
-	* so we can access on-board i/o areas.
-	*/
+	/*
+	 * On MVME147 we have already created kernel page tables for
+	 * 4MB of RAM at address 0, so now need to do a transparent
+	 * mapping of the top of memory space.  Make it 0.5GByte for now,
+	 * so we can access on-board i/o areas.
+	 */
 
-       mmu_map_tt      #1,#0xe0000000,#0x20000000,#_PAGE_NOCACHE030
+	mmu_map_tt	#1,#0xe0000000,#0x20000000,#_PAGE_NOCACHE030
 
-       jbra    L(mmu_init_done)
+	jbra	L(mmu_init_done)
 
 L(not147):
 #endif /* CONFIG_MVME147 */
@@ -1226,10 +1233,6 @@ L(mmu_init_mac):
 
 	putc	'F'
 
-	lea	%pc@(L(mac_videobase)),%a0
-	lea	%pc@(L(console_video_virtual)),%a1
-	movel	%a0@,%a1@
-
 	is_not_040_or_060(1f)
 
 	moveq	#_PAGE_NOCACHE_S,%d3
@@ -1243,14 +1246,14 @@ L(mmu_init_mac):
 	 */
 
 	movel	#VIDEOMEMMASK,%d0
-	andl	L(mac_videobase),%d0
+	andl	%pc@(L(mac_videobase)),%d0
 
 	mmu_map		#VIDEOMEMBASE,%d0,#VIDEOMEMSIZE,%d3
-	/* The ROM starts at 4000 0000		    	*/
+	/* ROM from 4000 0000 to 4200 0000 (only for mac_reset()) */
 	mmu_map_eq	#0x40000000,#0x02000000,%d3
-	/* IO devices                               	*/
+	/* IO devices (incl. serial port) from 5000 0000 to 5300 0000 */
 	mmu_map_eq	#0x50000000,#0x03000000,%d3
-	/* NuBus slot space				*/
+	/* Nubus slot space (video at 0xF0000000, rom at 0xF0F80000) */
 	mmu_map_tt	#1,#0xf8000000,#0x08000000,%d3
 
 	jbra	L(mmu_init_done)
@@ -1284,7 +1287,7 @@ L(mmu_init_not_mac):
 	andl	#PAGE_TABLE_SIZE-1, %d0
 	mmu_get_page_table_entry	%a0,%d0
 
-	/* this is where the prom page table lives */	
+	/* this is where the prom page table lives */
 	movel	0xfefe00d4, %a1
 	movel	%a1@, %a1
 
@@ -1295,11 +1298,11 @@ L(mmu_init_not_mac):
 	movel	%d3,%a0@+
 	addl	#0x1000,%d3
 	movel	%d3,%a0@+
-	
-	dbra	%d1,1b	
-		
+
+	dbra	%d1,1b
+
 	/* setup tt1 for I/O */
-	mmu_map_tt	#1,#0x40000000,#0x40000000,#_PAGE_NOCACHE_S 
+	mmu_map_tt	#1,#0x40000000,#0x40000000,#_PAGE_NOCACHE_S
 	jbra	L(mmu_init_done)
 
 L(notsun3x):
@@ -1310,8 +1313,8 @@ L(notsun3x):
 
 	putc	'P'
 	mmu_map         #0x80000000,#0,#0x02000000,#_PAGE_NOCACHE030
-	
-L(notapollo):	
+
+L(notapollo):
 	jbra	L(mmu_init_done)
 #endif
 
@@ -1342,7 +1345,7 @@ L(mmu_fixup):
 #endif
 
 	/* first fix the page at the start of the kernel, that
-         * contains also kernel_pg_dir.
+	 * contains also kernel_pg_dir.
 	 */
 	movel	%pc@(L(phys_kernel_start)),%d0
 	subl	#PAGE_OFFSET,%d0
@@ -1462,9 +1465,15 @@ L(mmu_fixup_done):
 	andl	L(mac_videobase),%d0
 	addl	#VIDEOMEMBASE,%d0
 	movel	%d0,L(mac_videobase)
+#if defined(CONSOLE)
+	movel	%pc@(L(phys_kernel_start)),%d0
+	subl	#PAGE_OFFSET,%d0
+	subl	%d0,L(console_font)
+	subl	%d0,L(console_font_data)
+#endif
 #ifdef MAC_SERIAL_DEBUG
 	orl	#0x50000000,L(mac_sccbase)
-#endif		
+#endif
 1:
 #endif
 
@@ -1486,20 +1495,20 @@ L(mmu_fixup_done):
 	is_not_sun3x(1f)
 
 	/* enable copro */
-	oriw	#0x4000,0x61000000 
+	oriw	#0x4000,0x61000000
 1:
 #endif
 
 #ifdef CONFIG_APOLLO
 	is_not_apollo(1f)
 
-        /*
+	/*
 	 * Fix up the iobase before printing
-         */
-        movel   #0x80000000,L(iobase)
+	 */
+	movel	#0x80000000,L(iobase)
 1:
 #endif
-	
+
 	putc	'I'
 	leds	0x10
 
@@ -1889,7 +1898,7 @@ mmu_030_print:
 	movel	%a4,%d5
 	addil	#PAGESIZE<<13,%d5
 	movel	%a0@+,%d6
-	btst	#1,%d6			/* is it a ptr? */
+	btst	#1,%d6			/* is it a table ptr? */
 	jbne	31f			/* yes */
 	btst	#0,%d6			/* is it early terminating? */
 	jbeq	1f			/* no */
@@ -1906,9 +1915,9 @@ mmu_030_print:
 	movel	%a4,%d5
 	addil	#PAGESIZE<<6,%d5
 	movel	%a1@+,%d6
-	btst	#1,%d6
-	jbne	33f
-	btst	#0,%d6
+	btst	#1,%d6			/* is it a table ptr? */
+	jbne	33f			/* yes */
+	btst	#0,%d6			/* is it a page descriptor? */
 	jbeq	1f			/* no */
 	jbsr	mmu_030_print_helper
 	jbra	37f
@@ -2981,7 +2990,7 @@ L(serial_init_not_mac):
    - check for '%LX$' signature in SRAM   */
 	lea	%pc@(q40_mem_cptr),%a1
 	move.l	#0xff020010,%a1@  /* must be inited - also used by debug=mem */
-	move.l	#0xff020000,%a1   
+	move.l	#0xff020000,%a1
 	cmp.b	#'%',%a1@
 	bne	2f	/*nodbg*/
 	addq.w	#4,%a1
@@ -2996,10 +3005,10 @@ L(serial_init_not_mac):
 	/* signature OK */
 	lea	%pc@(L(q40_do_debug)),%a1
 	tas	%a1@
-/*nodbg: q40_do_debug is 0 by default*/	
-2:		
-#endif	
-	
+/*nodbg: q40_do_debug is 0 by default*/
+2:
+#endif
+
 #ifdef CONFIG_APOLLO
 /* We count on the PROM initializing SIO1 */
 #endif
@@ -3152,7 +3161,7 @@ func_start	serial_putc,%d0/%d1/%a0/%a1
 	moveml	%sp@+,%d0-%d7/%a2-%a6
 	jbra	L(serial_putc_done)
 2:
-#endif CONFIG_MVME16x
+#endif /* CONFIG_MVME16x */
 
 #ifdef CONFIG_BVME6000
 	is_not_bvme6000(2f)
@@ -3167,15 +3176,15 @@ func_start	serial_putc,%d0/%d1/%a0/%a1
 #endif
 
 #ifdef CONFIG_SUN3X
-	is_not_sun3x(2f) 
+	is_not_sun3x(2f)
 	movel	%d0,-(%sp)
 	movel	0xFEFE0018,%a1
 	jbsr	(%a1)
 	addq	#4,%sp
 	jbra	L(serial_putc_done)
-2:	
+2:
 #endif
-	
+
 #ifdef CONFIG_Q40
 	is_not_q40(2f)
 	tst.l	%pc@(L(q40_do_debug))	/* only debug if requested */
@@ -3186,16 +3195,16 @@ func_start	serial_putc,%d0/%d1/%a0/%a1
 	addq.l	#4,%a0
 	move.l	%a0,%a1@
 	jbra    L(serial_putc_done)
-2:		
-#endif	
+2:
+#endif
 
 #ifdef CONFIG_APOLLO
 	is_not_apollo(2f)
 	movl    %pc@(L(iobase)),%a1
-        moveb   %d0,%a1@(LTHRB0)
+	moveb	%d0,%a1@(LTHRB0)
 1:      moveb   %a1@(LSRB0),%d0
-        andb    #0x4,%d0
-        beq     1b
+	andb	#0x4,%d0
+	beq	1b
 2:
 #endif
 
@@ -3212,7 +3221,7 @@ func_start	puts,%d0/%a0
 1:
 #ifdef CONSOLE
 	console_putc	%d0
-#endif 
+#endif
 #ifdef SERIAL_DEBUG
 	serial_putc	%d0
 #endif
@@ -3241,7 +3250,7 @@ func_start	putn,%d0-%d2
 2:
 #ifdef CONSOLE
 	console_putc	%d2
-#endif 
+#endif
 #ifdef SERIAL_DEBUG
 	serial_putc	%d2
 #endif
@@ -3290,7 +3299,7 @@ func_start	set_leds,%d0/%a0
 	moveb	%d0,%a0@(0x1ffff)
 	jra	2f
 #endif
-1:	
+1:
 #ifdef CONFIG_APOLLO
 	movel   %pc@(L(iobase)),%a0
 	lsll    #8,%d0
@@ -3313,7 +3322,7 @@ func_return	set_leds
 #define Lconsole_struct_left_edge	16
 #define Lconsole_struct_penguin_putc	20
 
-L(console_init):
+func_start	console_init,%a0-%a4/%d0-%d7
 	/*
 	 *	Some of the register usage that follows
 	 *		a0 = pointer to boot_info
@@ -3327,30 +3336,27 @@ L(console_init):
 	 *		d5 = number of bytes per scan line
 	 *		d6 = number of bytes on the entire screen
 	 */
-	moveml	%a0-%a4/%d0-%d7,%sp@-
 
 	lea	%pc@(L(console_globals)),%a2
-	lea	%pc@(L(mac_videobase)),%a0
-	movel	%a0@,%a1
-	lea	%pc@(L(mac_rowbytes)),%a0
-	movel	%a0@,%d5
-	lea	%pc@(L(mac_dimensions)),%a0
-	movel	%a0@,%d3	/* -> low byte */
+	movel	%pc@(L(mac_videobase)),%a1
+	movel	%pc@(L(mac_rowbytes)),%d5
+	movel	%pc@(L(mac_dimensions)),%d3	/* -> low byte */
 	movel	%d3,%d4
 	swap	%d4		/* -> high byte */
 	andl	#0xffff,%d3	/* d3 = screen width in pixels */
 	andl	#0xffff,%d4	/* d4 = screen height in pixels */
 
 	movel	%d5,%d6
-	subl	#20,%d6
+|	subl	#20,%d6
 	mulul	%d4,%d6		/* scan line bytes x num scan lines */
 	divul	#8,%d6		/* we'll clear 8 bytes at a time */
+	moveq	#-1,%d0		/* Mac_black */
 	subq	#1,%d6
 
-console_clear_loop:
-	movel	#0xffffffff,%a1@+	/* Mac_black */
-	movel	#0xffffffff,%a1@+	/* Mac_black */
-	dbra	%d6,console_clear_loop
+L(console_clear_loop):
+	movel	%d0,%a1@+
+	movel	%d0,%a1@+
+	dbra	%d6,L(console_clear_loop)
 
 	/* Calculate font size */
 
@@ -3368,12 +3374,17 @@ console_clear_loop:
 
 	/*
 	 *	At this point we make a shift in register usage
-	 *	a1 = address of Lconsole_font pointer
+	 *	a1 = address of console_font pointer
 	 */
 	lea	%pc@(L(console_font)),%a1
-	movel	%a0,%a1@	/* store pointer to struct font_desc in Lconsole_font */
+	movel	%a0,%a1@	/* store pointer to struct fbcon_font_desc in console_font */
 	tstl	%a0
 	jeq	1f
+	lea	%pc@(L(console_font_data)),%a4
+	movel	%a0@(FONT_DESC_DATA),%d0
+	subl	#L(console_font),%a1
+	addl	%a1,%d0
+	movel	%d0,%a4@
 
 	/*
 	 *	Calculate global maxs
@@ -3382,11 +3393,11 @@ console_clear_loop:
 	 *	6 x 11 also supported
 	 */
 		/* ASSERT: a0 = contents of Lconsole_font */
-	movel	%d3,%d0			/* screen width in pixels */
-	divul	%a0@(FONT_DESC_WIDTH),%d0		/* d0 = max num chars per row */
+	movel	%d3,%d0				/* screen width in pixels */
+	divul	%a0@(FONT_DESC_WIDTH),%d0	/* d0 = max num chars per row */
 
-	movel	%d4,%d1			 /* screen height in pixels */
-	divul	%a0@(FONT_DESC_HEIGHT),%d1	 /* d1 = max num rows */
+	movel	%d4,%d1				/* screen height in pixels */
+	divul	%a0@(FONT_DESC_HEIGHT),%d1	/* d1 = max num rows */
 
 	movel	%d0,%a2@(Lconsole_struct_num_columns)
 	movel	%d1,%a2@(Lconsole_struct_num_rows)
@@ -3401,17 +3412,15 @@ console_clear_loop:
 	/*
 	 * Initialization is complete
 	 */
-1:	moveml	%sp@+,%a0-%a4/%d0-%d7
-	rts
+1:
+func_return	console_init
 
-L(console_put_stats):
+func_start	console_put_stats,%a0/%d7
 	/*
 	 *	Some of the register usage that follows
 	 *		a0 = pointer to boot_info
 	 *		d7 = value of boot_info fields
 	 */
-	moveml	%a0/%d7,%sp@-
-
 	puts	"\nMacLinux\n\n"
 
 #ifdef SERIAL_DEBUG
@@ -3433,58 +3442,57 @@ L(console_put_stats):
 #ifdef MAC_SERIAL_DEBUG
 	putn	%pc@(L(mac_sccbase))
 	putc	'\n'
-#endif	
+#endif
 #  if defined(MMU_PRINT)
 	jbsr	mmu_print_machine_cpu_types
 #  endif /* MMU_PRINT */
 #endif /* SERIAL_DEBUG */
 
-	moveml	%sp@+,%a0/%d7
-	rts
+func_return	console_put_stats
 
 #ifdef CONSOLE_PENGUIN
-L(console_put_penguin):
+func_start	console_put_penguin,%a0-%a1/%d0-%d7
 	/*
 	 *	Get 'that_penguin' onto the screen in the upper right corner
 	 *	penguin is 64 x 74 pixels, align against right edge of screen
 	 */
-	moveml	%a0-%a1/%d0-%d7,%sp@-
-
 	lea	%pc@(L(mac_dimensions)),%a0
 	movel	%a0@,%d0
 	andil	#0xffff,%d0
 	subil	#64,%d0		/* snug up against the right edge */
 	clrl	%d1		/* start at the top */
 	movel	#73,%d7
-	lea	%pc@(that_penguin),%a1
-console_penguin_row:
+	lea	%pc@(L(that_penguin)),%a1
+L(console_penguin_row):
 	movel	#31,%d6
-console_penguin_pixel_pair:
+L(console_penguin_pixel_pair):
 	moveb	%a1@,%d2
 	lsrb	#4,%d2
-	jbsr	console_plot_pixel
+	console_plot_pixel %d0,%d1,%d2
 	addq	#1,%d0
 	moveb	%a1@+,%d2
-	jbsr	console_plot_pixel
+	console_plot_pixel %d0,%d1,%d2
 	addq	#1,%d0
-	dbra	%d6,console_penguin_pixel_pair
+	dbra	%d6,L(console_penguin_pixel_pair)
 
 	subil	#64,%d0
 	addq	#1,%d1
-	dbra	%d7,console_penguin_row
+	dbra	%d7,L(console_penguin_row)
 
-	moveml	%sp@+,%a0-%a1/%d0-%d7
-	rts
-#endif
+func_return	console_put_penguin
 
-console_scroll:
-	moveml	%a0-%a4/%d0-%d7,%sp@-
+/* include penguin bitmap */
+L(that_penguin):
+#include "../mac/mac_penguin.S"
+#endif
 
 	/*
 	 * Calculate source and destination addresses
 	 *	output	a1 = dest
 	 *		a2 = source
 	 */
+
+func_start	console_scroll,%a0-%a4/%d0-%d7
 	lea	%pc@(L(mac_videobase)),%a0
 	movel	%a0@,%a1
 	movel	%a1,%a2
@@ -3517,7 +3525,7 @@ console_scroll:
 	divul	#32,%d6		/* we'll move 8 longs at a time */
 	subq	#1,%d6
 
-console_scroll_loop:
+L(console_scroll_loop):
 	movel	%a2@+,%a1@+
 	movel	%a2@+,%a1@+
 	movel	%a2@+,%a1@+
@@ -3526,7 +3534,7 @@ console_scroll_loop:
 	movel	%a2@+,%a1@+
 	movel	%a2@+,%a1@+
 	movel	%a2@+,%a1@+
-	dbra	%d6,console_scroll_loop
+	dbra	%d6,L(console_scroll_loop)
 
 	lea	%pc@(L(mac_rowbytes)),%a0
 	movel	%a0@,%d6
@@ -3536,7 +3544,7 @@ console_scroll_loop:
 	subq	#1,%d6
 
 	moveq	#-1,%d0
-console_scroll_clear_loop:
+L(console_scroll_clear_loop):
 	movel	%d0,%a1@+
 	movel	%d0,%a1@+
 	movel	%d0,%a1@+
@@ -3545,17 +3553,17 @@ console_scroll_clear_loop:
 	movel	%d0,%a1@+
 	movel	%d0,%a1@+
 	movel	%d0,%a1@+
-	dbra	%d6,console_scroll_clear_loop
+	dbra	%d6,L(console_scroll_clear_loop)
 
-1:	moveml	%sp@+,%a0-%a4/%d0-%d7
-	rts
+1:
+func_return	console_scroll
 
 
 func_start	console_putc,%a0/%a1/%d0-%d7
 
-	is_not_mac(console_exit)
+	is_not_mac(L(console_exit))
 	tstl	%pc@(L(console_font))
-	jeq	console_exit
+	jeq	L(console_exit)
 
 	/* Output character in d7 on console.
 	 */
@@ -3569,7 +3577,7 @@ func_start	console_putc,%a0/%a1/%d0-%d7
 	lea	%pc@(L(console_globals)),%a0
 
 	cmpib	#10,%d7
-	jne	console_not_lf
+	jne	L(console_not_lf)
 	movel	%a0@(Lconsole_struct_cur_row),%d0
 	addil	#1,%d0
 	movel	%d0,%a0@(Lconsole_struct_cur_row)
@@ -3578,22 +3586,22 @@ func_start	console_putc,%a0/%a1/%d0-%d7
 	jcs	1f
 	subil	#1,%d0
 	movel	%d0,%a0@(Lconsole_struct_cur_row)
-	jbsr	console_scroll
+	console_scroll
 1:
-	jra	console_exit
+	jra	L(console_exit)
 
-console_not_lf:
+L(console_not_lf):
 	cmpib	#13,%d7
-	jne	console_not_cr
+	jne	L(console_not_cr)
 	clrl	%a0@(Lconsole_struct_cur_column)
-	jra	console_exit
+	jra	L(console_exit)
 
-console_not_cr:
+L(console_not_cr):
 	cmpib	#1,%d7
-	jne	console_not_home
+	jne	L(console_not_home)
 	clrl	%a0@(Lconsole_struct_cur_row)
 	clrl	%a0@(Lconsole_struct_cur_column)
-	jra	console_exit
+	jra	L(console_exit)
 
 /*
  *	At this point we know that the %d7 character is going to be
@@ -3604,9 +3612,9 @@ console_not_cr:
  *		d1 = cursor row to draw the character
  *		d7 = character number
  */
-console_not_home:
+L(console_not_home):
 	movel	%a0@(Lconsole_struct_cur_column),%d0
-	addil	#1,%a0@(Lconsole_struct_cur_column)
+	addql	#1,%a0@(Lconsole_struct_cur_column)
 	movel	%a0@(Lconsole_struct_num_columns),%d1
 	cmpl	%d1,%d0
 	jcs	1f
@@ -3616,10 +3624,10 @@ console_not_home:
 
 	/*
 	 *	At this point we make a shift in register usage
-	 *	a0 = address of pointer to font data (font_desc)
+	 *	a0 = address of pointer to font data (fbcon_font_desc)
 	 */
 	movel	%pc@(L(console_font)),%a0
-	movel	%a0@(FONT_DESC_DATA),%a1	/* Load font_desc.data into a1 */
+	movel	%pc@(L(console_font_data)),%a1	/* Load fbcon_font_desc.data into a1 */
 	andl	#0x000000ff,%d7
 		/* ASSERT: a0 = contents of Lconsole_font */
 	mulul	%a0@(FONT_DESC_HEIGHT),%d7	/* d7 = index into font data */
@@ -3637,32 +3645,30 @@ console_not_home:
 		/* ASSERT: a0 = contents of Lconsole_font */
 	mulul	%a0@(FONT_DESC_WIDTH),%d0
 	mulul	%a0@(FONT_DESC_HEIGHT),%d1
-	movel	%a0@(FONT_DESC_HEIGHT),%d7	/* Load font_desc.height into d7 */
+	movel	%a0@(FONT_DESC_HEIGHT),%d7	/* Load fbcon_font_desc.height into d7 */
 	subq	#1,%d7
-console_read_char_scanline:
+L(console_read_char_scanline):
 	moveb	%a1@+,%d3
 
 		/* ASSERT: a0 = contents of Lconsole_font */
-	movel	%a0@(FONT_DESC_WIDTH),%d6	/* Load font_desc.width into d6 */
+	movel	%a0@(FONT_DESC_WIDTH),%d6	/* Load fbcon_font_desc.width into d6 */
 	subql	#1,%d6
 
-console_do_font_scanline:
+L(console_do_font_scanline):
 	lslb	#1,%d3
 	scsb	%d2		/* convert 1 bit into a byte */
-	jbsr	console_plot_pixel
+	console_plot_pixel %d0,%d1,%d2
 	addq	#1,%d0
-	dbra	%d6,console_do_font_scanline
+	dbra	%d6,L(console_do_font_scanline)
 
 		/* ASSERT: a0 = contents of Lconsole_font */
 	subl	%a0@(FONT_DESC_WIDTH),%d0
 	addq	#1,%d1
-	dbra	%d7,console_read_char_scanline
-
-console_exit:
+	dbra	%d7,L(console_read_char_scanline)
 
+L(console_exit):
 func_return	console_putc
 
-console_plot_pixel:
 	/*
 	 *	Input:
 	 *		d0 = x coordinate
@@ -3670,14 +3676,14 @@ console_plot_pixel:
 	 *		d2 = (bit 0) 1/0 for white/black (!)
 	 *	All registers are preserved
 	 */
-	moveml	%a0-%a1/%d0-%d4,%sp@-
+func_start	console_plot_pixel,%a0-%a1/%d0-%d4
 
-	lea	%pc@(L(mac_videobase)),%a0
-	movel	%a0@,%a1
-	lea	%pc@(L(mac_videodepth)),%a0
-	movel	%a0@,%d3
-	lea	%pc@(L(mac_rowbytes)),%a0
-	mulul	%a0@,%d1
+	movel	%pc@(L(mac_videobase)),%a1
+	movel	%pc@(L(mac_videodepth)),%d3
+	movel	ARG1,%d0
+	movel	ARG2,%d1
+	mulul	%pc@(L(mac_rowbytes)),%d1
+	movel	ARG3,%d2
 
 	/*
 	 *	Register usage:
@@ -3686,13 +3692,10 @@ console_plot_pixel:
 	 *		d2 = black or white (0/1)
 	 *		d3 = video depth
 	 *		d4 = temp of x (d0) for many bit depths
-	 *		d5 = unused
-	 *		d6 = unused
-	 *		d7 = unused
 	 */
-test_1bit:
+L(test_1bit):
 	cmpb	#1,%d3
-	jbne	test_2bit
+	jbne	L(test_2bit)
 	movel	%d0,%d4		/* we need the low order 3 bits! */
 	divul	#8,%d0
 	addal	%d0,%a1
@@ -3700,16 +3703,16 @@ test_1bit:
 	andb	#7,%d4
 	eorb	#7,%d4		/* reverse the x-coordinate w/ screen-bit # */
 	andb	#1,%d2
-	jbne	white_1
+	jbne	L(white_1)
 	bsetb	%d4,%a1@
-	jbra	console_plot_pixel_exit
-white_1:
+	jbra	L(console_plot_pixel_exit)
+L(white_1):
 	bclrb	%d4,%a1@
-	jbra	console_plot_pixel_exit
+	jbra	L(console_plot_pixel_exit)
 
-test_2bit:
+L(test_2bit):
 	cmpb	#2,%d3
-	jbne	test_4bit
+	jbne	L(test_4bit)
 	movel	%d0,%d4		/* we need the low order 2 bits! */
 	divul	#4,%d0
 	addal	%d0,%a1
@@ -3718,20 +3721,20 @@ test_2bit:
 	eorb	#3,%d4		/* reverse the x-coordinate w/ screen-bit # */
 	lsll	#1,%d4		/* ! */
 	andb	#1,%d2
-	jbne	white_2
+	jbne	L(white_2)
 	bsetb	%d4,%a1@
 	addq	#1,%d4
 	bsetb	%d4,%a1@
-	jbra	console_plot_pixel_exit
-white_2:
+	jbra	L(console_plot_pixel_exit)
+L(white_2):
 	bclrb	%d4,%a1@
 	addq	#1,%d4
 	bclrb	%d4,%a1@
-	jbra	console_plot_pixel_exit
+	jbra	L(console_plot_pixel_exit)
 
-test_4bit:
+L(test_4bit):
 	cmpb	#4,%d3
-	jbne	test_8bit
+	jbne	L(test_8bit)
 	movel	%d0,%d4		/* we need the low order bit! */
 	divul	#2,%d0
 	addal	%d0,%a1
@@ -3740,7 +3743,7 @@ test_4bit:
 	eorb	#1,%d4
 	lsll	#2,%d4		/* ! */
 	andb	#1,%d2
-	jbne	white_4
+	jbne	L(white_4)
 	bsetb	%d4,%a1@
 	addq	#1,%d4
 	bsetb	%d4,%a1@
@@ -3748,8 +3751,8 @@ test_4bit:
 	bsetb	%d4,%a1@
 	addq	#1,%d4
 	bsetb	%d4,%a1@
-	jbra	console_plot_pixel_exit
-white_4:
+	jbra	L(console_plot_pixel_exit)
+L(white_4):
 	bclrb	%d4,%a1@
 	addq	#1,%d4
 	bclrb	%d4,%a1@
@@ -3757,38 +3760,37 @@ white_4:
 	bclrb	%d4,%a1@
 	addq	#1,%d4
 	bclrb	%d4,%a1@
-	jbra	console_plot_pixel_exit
+	jbra	L(console_plot_pixel_exit)
 
-test_8bit:
+L(test_8bit):
 	cmpb	#8,%d3
-	jbne	test_16bit
+	jbne	L(test_16bit)
 	addal	%d0,%a1
 	addal	%d1,%a1
 	andb	#1,%d2
-	jbne	white_8
+	jbne	L(white_8)
 	moveb	#0xff,%a1@
-	jbra	console_plot_pixel_exit
-white_8:
+	jbra	L(console_plot_pixel_exit)
+L(white_8):
 	clrb	%a1@
-	jbra	console_plot_pixel_exit
+	jbra	L(console_plot_pixel_exit)
 
-test_16bit:
+L(test_16bit):
 	cmpb	#16,%d3
-	jbne	console_plot_pixel_exit
+	jbne	L(console_plot_pixel_exit)
 	addal	%d0,%a1
 	addal	%d0,%a1
 	addal	%d1,%a1
 	andb	#1,%d2
-	jbne	white_16
+	jbne	L(white_16)
 	clrw	%a1@
-	jbra	console_plot_pixel_exit
-white_16:
+	jbra	L(console_plot_pixel_exit)
+L(white_16):
 	movew	#0x0fff,%a1@
-	jbra	console_plot_pixel_exit
+	jbra	L(console_plot_pixel_exit)
 
-console_plot_pixel_exit:
-	moveml	%sp@+,%a0-%a1/%d0-%d4
-	rts
+L(console_plot_pixel_exit):
+func_return	console_plot_pixel
 #endif /* CONSOLE */
 
 #if 0
@@ -3838,11 +3840,6 @@ L(iobase):
 	.long 0
 #endif
 
-#ifdef CONFIG_MAC
-L(console_video_virtual):
-	.long	0
-#endif	/* CONFIG_MAC */
-
 #if defined(CONSOLE)
 L(console_globals):
 	.long	0		/* cursor column */
@@ -3853,6 +3850,8 @@ L(console_globals):
 	.long	0		/* mac putc */
 L(console_font):
 	.long	0		/* pointer to console font (struct font_desc) */
+L(console_font_data):
+	.long	0		/* pointer to console font data */
 #endif /* CONSOLE */
 
 #if defined(MMU_PRINT)
@@ -3941,7 +3940,7 @@ mvme_bdid:
 #endif
 #if defined(CONFIG_Q40)
 q40_mem_cptr:
-	.long 0
-L(q40_do_debug):	
-	.long 0	
+	.long	0
+L(q40_do_debug):
+	.long	0
 #endif
diff -puN arch/m68k/kernel/traps.c~linus arch/m68k/kernel/traps.c
--- 25/arch/m68k/kernel/traps.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68k/kernel/traps.c	2004-01-19 22:17:21.000000000 -0800
@@ -447,7 +447,7 @@ extern int mmu_emu_handle_fault (unsigne
 
 /* sun3 version of bus_error030 */
 
-extern inline void bus_error030 (struct frame *fp)
+static inline void bus_error030 (struct frame *fp)
 {
 	unsigned char buserr_type = sun3_get_buserr ();
 	unsigned long addr, errorcode;
@@ -583,12 +583,9 @@ static inline void bus_error030 (struct 
 	unsigned short mmusr;
 	unsigned long addr, errorcode;
 	unsigned short ssw = fp->un.fmtb.ssw;
-	int user_space_fault = 1;
 #if DEBUG
 	unsigned long desc;
-#endif
 
-#if DEBUG
 	printk ("pid = %x  ", current->pid);
 	printk ("SSW=%#06x  ", ssw);
 
@@ -605,128 +602,116 @@ static inline void bus_error030 (struct 
 			space_names[ssw & DFC], fp->ptregs.pc);
 #endif
 
-	if (fp->ptregs.sr & PS_S) {
-		/* kernel fault must be a data fault to user space */
-		if (! ((ssw & DF) && ((ssw & DFC) == USER_DATA))) {
-			/* instruction fault or kernel data fault! */
-			if (ssw & (FC | FB))
-				printk ("Instruction fault at %#010lx\n",
-					fp->ptregs.pc);
-			if (ssw & DF) {
-				printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
-					ssw & RW ? "read" : "write",
-					fp->un.fmtb.daddr,
-					space_names[ssw & DFC], fp->ptregs.pc);
-			}
-			printk ("BAD KERNEL BUSERR\n");
-			die_if_kernel("Oops",&fp->ptregs,0);
-			force_sig(SIGKILL, current);
-			return;
-		}
-	} else {
-		/* user fault */
-		if (!(ssw & (FC | FB)) && !(ssw & DF))
-			/* not an instruction fault or data fault! BAD */
-			panic ("USER BUSERR w/o instruction or data fault");
-		user_space_fault = 1;
-#if DEBUG
-		printk("User space bus-error\n");
-#endif
-	}
-
 	/* ++andreas: If a data fault and an instruction fault happen
 	   at the same time map in both pages.  */
 
 	/* First handle the data fault, if any.  */
-	if (ssw & DF)
-	  {
-	    addr = fp->un.fmtb.daddr;
+	if (ssw & DF) {
+		addr = fp->un.fmtb.daddr;
 
-	    mmusr = MMU_I;
-	    if (user_space_fault) {
 #if DEBUG
-		    asm volatile ("ptestr #1,%2@,#7,%0\n\t"
-				  "pmove %/psr,%1@"
-				  : "=a&" (desc)
-				  : "a" (&temp), "a" (addr));
+		asm volatile ("ptestr %3,%2@,#7,%0\n\t"
+			      "pmove %%psr,%1@"
+			      : "=a&" (desc)
+			      : "a" (&temp), "a" (addr), "d" (ssw));
 #else
-		    asm volatile ("ptestr #1,%1@,#7\n\t"
-				  "pmove %/psr,%0@"
-				  : : "a" (&temp), "a" (addr));
-#endif
-		    mmusr = temp;
-	    }
-      
-#if DEBUG
-	    printk ("mmusr is %#x for addr %#lx in task %p\n",
-		    mmusr, addr, current);
-	    printk ("descriptor address is %#lx, contents %#lx\n",
-		    __va(desc), *(unsigned long *)__va(desc));
+		asm volatile ("ptestr %2,%1@,#7\n\t"
+			      "pmove %%psr,%0@"
+			      : : "a" (&temp), "a" (addr), "d" (ssw));
 #endif
+		mmusr = temp;
 
-	    errorcode = (mmusr & MMU_I) ? 0 : 1;
-	    if (!(ssw & RW) || (ssw & RM))
-		    errorcode |= 2;
-
-	    if (mmusr & (MMU_I | MMU_WP)) {
-		/* Don't try to do anything further if an exception was
-		   handled. */
-		if (do_page_fault (&fp->ptregs, addr, errorcode) < 0)
+#if DEBUG
+		printk("mmusr is %#x for addr %#lx in task %p\n",
+		       mmusr, addr, current);
+		printk("descriptor address is %#lx, contents %#lx\n",
+		       __va(desc), *(unsigned long *)__va(desc));
+#endif
+
+		errorcode = (mmusr & MMU_I) ? 0 : 1;
+		if (!(ssw & RW) || (ssw & RM))
+			errorcode |= 2;
+
+		if (mmusr & (MMU_I | MMU_WP)) {
+			if (ssw & 4) {
+				printk("Data %s fault at %#010lx in %s (pc=%#lx)\n",
+				       ssw & RW ? "read" : "write",
+				       fp->un.fmtb.daddr,
+				       space_names[ssw & DFC], fp->ptregs.pc);
+				goto buserr;
+			}
+			/* Don't try to do anything further if an exception was
+			   handled. */
+			if (do_page_fault (&fp->ptregs, addr, errorcode) < 0)
+				return;
+		} else if (!(mmusr & MMU_I)) {
+			/* propably a 020 cas fault */
+			if (!(ssw & RM))
+				printk("unexpected bus error (%#x,%#x)\n", ssw, mmusr);
+		} else if (mmusr & (MMU_B|MMU_L|MMU_S)) {
+			printk("invalid %s access at %#lx from pc %#lx\n",
+			       !(ssw & RW) ? "write" : "read", addr,
+			       fp->ptregs.pc);
+			die_if_kernel("Oops",&fp->ptregs,mmusr);
+			force_sig(SIGSEGV, current);
 			return;
-	    } else if (mmusr & (MMU_B|MMU_L|MMU_S)) {
-		    printk ("invalid %s access at %#lx from pc %#lx\n",
-			    !(ssw & RW) ? "write" : "read", addr,
-			    fp->ptregs.pc);
-		    die_if_kernel("Oops",&fp->ptregs,mmusr);
-		    force_sig(SIGSEGV, current);
-		    return;
-	    } else {
+		} else {
 #if 0
-		    static volatile long tlong;
+			static volatile long tlong;
 #endif
 
-		    printk ("weird %s access at %#lx from pc %#lx (ssw is %#x)\n",
-			    !(ssw & RW) ? "write" : "read", addr,
-			    fp->ptregs.pc, ssw);
-		    asm volatile ("ptestr #1,%1@,#0\n\t"
-				  "pmove %/psr,%0@"
-				  : /* no outputs */
-				  : "a" (&temp), "a" (addr));
-		    mmusr = temp;
+			printk("weird %s access at %#lx from pc %#lx (ssw is %#x)\n",
+			       !(ssw & RW) ? "write" : "read", addr,
+			       fp->ptregs.pc, ssw);
+			asm volatile ("ptestr #1,%1@,#0\n\t"
+				      "pmove %%psr,%0@"
+				      : /* no outputs */
+				      : "a" (&temp), "a" (addr));
+			mmusr = temp;
 
-		    printk ("level 0 mmusr is %#x\n", mmusr);
+			printk ("level 0 mmusr is %#x\n", mmusr);
 #if 0
-		    asm volatile ("pmove %/tt0,%0@"
-				  : /* no outputs */
-				  : "a" (&tlong));
-		    printk ("tt0 is %#lx, ", tlong);
-		    asm volatile ("pmove %/tt1,%0@"
-				  : /* no outputs */
-				  : "a" (&tlong));
-		    printk ("tt1 is %#lx\n", tlong);
+			asm volatile ("pmove %%tt0,%0@"
+				      : /* no outputs */
+				      : "a" (&tlong));
+			printk("tt0 is %#lx, ", tlong);
+			asm volatile ("pmove %%tt1,%0@"
+				      : /* no outputs */
+				      : "a" (&tlong));
+			printk("tt1 is %#lx\n", tlong);
 #endif
 #if DEBUG
-		    printk("Unknown SIGSEGV - 1\n");
+			printk("Unknown SIGSEGV - 1\n");
 #endif
-		    die_if_kernel("Oops",&fp->ptregs,mmusr);
-		    force_sig(SIGSEGV, current);
-		    return;
-	    }
-
-	    /* setup an ATC entry for the access about to be retried */
-	    if (!(ssw & RW))
-		    asm volatile ("ploadw %1,%0@" : /* no outputs */
-				  : "a" (addr), "d" (ssw));
-	    else
-		    asm volatile ("ploadr %1,%0@" : /* no outputs */
-				  : "a" (addr), "d" (ssw));
-	  }
+			die_if_kernel("Oops",&fp->ptregs,mmusr);
+			force_sig(SIGSEGV, current);
+			return;
+		}
+
+		/* setup an ATC entry for the access about to be retried */
+		if (!(ssw & RW) || (ssw & RM))
+			asm volatile ("ploadw %1,%0@" : /* no outputs */
+				      : "a" (addr), "d" (ssw));
+		else
+			asm volatile ("ploadr %1,%0@" : /* no outputs */
+				      : "a" (addr), "d" (ssw));
+	}
 
 	/* Now handle the instruction fault. */
 
 	if (!(ssw & (FC|FB)))
 		return;
 
+	if (fp->ptregs.sr & PS_S) {
+		printk("Instruction fault at %#010lx\n",
+			fp->ptregs.pc);
+	buserr:
+		printk ("BAD KERNEL BUSERR\n");
+		die_if_kernel("Oops",&fp->ptregs,0);
+		force_sig(SIGKILL, current);
+		return;
+	}
+
 	/* get the fault address */
 	if (fp->ptregs.format == 10)
 		addr = fp->ptregs.pc + 4;
@@ -740,21 +725,18 @@ static inline void bus_error030 (struct 
 		   should still create the ATC entry.  */
 		goto create_atc_entry;
 
-	mmusr = MMU_I;
-	if (user_space_fault) {
 #if DEBUG
-		asm volatile ("ptestr #1,%2@,#7,%0\n\t"
-			      "pmove %/psr,%1@"
-			      : "=a&" (desc)
-			      : "a" (&temp), "a" (addr));
+	asm volatile ("ptestr #1,%2@,#7,%0\n\t"
+		      "pmove %%psr,%1@"
+		      : "=a&" (desc)
+		      : "a" (&temp), "a" (addr));
 #else
-		asm volatile ("ptestr #1,%1@,#7\n\t"
-			      "pmove %/psr,%0@"
-			      : : "a" (&temp), "a" (addr));
+	asm volatile ("ptestr #1,%1@,#7\n\t"
+		      "pmove %%psr,%0@"
+		      : : "a" (&temp), "a" (addr));
 #endif
-		mmusr = temp;
-	}
-      
+	mmusr = temp;
+
 #ifdef DEBUG
 	printk ("mmusr is %#x for addr %#lx in task %p\n",
 		mmusr, addr, current);
diff -puN arch/m68k/mac/config.c~linus arch/m68k/mac/config.c
--- 25/arch/m68k/mac/config.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68k/mac/config.c	2004-01-19 22:17:21.000000000 -0800
@@ -11,6 +11,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/module.h>
 #include <linux/types.h>
 #include <linux/mm.h>
 #include <linux/tty.h>
@@ -267,6 +268,7 @@ void __init config_mac(void)
  */
  
 struct mac_model *macintosh_config;
+EXPORT_SYMBOL(macintosh_config);
 
 static struct mac_model mac_data_table[]=
 {
diff -puN arch/m68k/mac/misc.c~linus arch/m68k/mac/misc.c
--- 25/arch/m68k/mac/misc.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68k/mac/misc.c	2004-01-19 22:17:21.000000000 -0800
@@ -39,6 +39,7 @@
 extern struct mac_booter_data mac_bi_data;
 static void (*rom_reset)(void);
 
+#ifdef CONFIG_ADB
 /*
  * Return the current time as the number of seconds since January 1, 1904.
  */
@@ -103,6 +104,7 @@ static void adb_write_pram(int offset, _
 			(offset >> 8) & 0xFF, offset & 0xFF,
 			data);
 }
+#endif /* CONFIG_ADB */
 
 /*
  * VIA PRAM/RTC access routines
@@ -356,7 +358,11 @@ void mac_pram_read(int offset, __u8 *buf
 	    macintosh_config->adb_type == MAC_ADB_PB1 ||
 	    macintosh_config->adb_type == MAC_ADB_PB2 ||
 	    macintosh_config->adb_type == MAC_ADB_CUDA) {
+#ifdef CONFIG_ADB
 		func = adb_read_pram;
+#else
+		return;
+#endif
 	} else {
 		func = via_read_pram;
 	}
@@ -374,7 +380,11 @@ void mac_pram_write(int offset, __u8 *bu
 	    macintosh_config->adb_type == MAC_ADB_PB1 ||
 	    macintosh_config->adb_type == MAC_ADB_PB2 ||
 	    macintosh_config->adb_type == MAC_ADB_CUDA) {
+#ifdef CONFIG_ADB
 		func = adb_write_pram;
+#else
+		return;
+#endif
 	} else {
 		func = via_write_pram;
 	}
@@ -580,12 +590,16 @@ int mac_hwclk(int op, struct rtc_time *t
 	if (!op) { /* read */
 		if (macintosh_config->adb_type == MAC_ADB_II) {
 			now = via_read_time();
-		} else if ((macintosh_config->adb_type == MAC_ADB_IISI) ||
+		} else
+#ifdef CONFIG_ADB
+		if ((macintosh_config->adb_type == MAC_ADB_IISI) ||
 			   (macintosh_config->adb_type == MAC_ADB_PB1) ||
 			   (macintosh_config->adb_type == MAC_ADB_PB2) ||
 			   (macintosh_config->adb_type == MAC_ADB_CUDA)) {
 			now = adb_read_time();
-		} else if (macintosh_config->adb_type == MAC_ADB_IOP) {
+		} else
+#endif
+		if (macintosh_config->adb_type == MAC_ADB_IOP) {
 			now = via_read_time();
 		} else {
 			now = 0;
diff -puN arch/m68k/math-emu/fp_arith.c~linus arch/m68k/math-emu/fp_arith.c
--- 25/arch/m68k/math-emu/fp_arith.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68k/math-emu/fp_arith.c	2004-01-19 22:17:21.000000000 -0800
@@ -19,12 +19,13 @@
 
 const struct fp_ext fp_QNaN =
 {
-	0, 0, 0x7fff, { ~0 }
+	.exp = 0x7fff,
+	.mant = { .m64 = ~0 }
 };
 
 const struct fp_ext fp_Inf =
 {
-	0, 0, 0x7fff, { 0 }
+	.exp = 0x7fff,
 };
 
 /* let's start with the easy ones */
diff -puN arch/m68k/math-emu/fp_log.c~linus arch/m68k/math-emu/fp_log.c
--- 25/arch/m68k/math-emu/fp_log.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68k/math-emu/fp_log.c	2004-01-19 22:17:21.000000000 -0800
@@ -19,7 +19,7 @@
 
 static const struct fp_ext fp_one =
 {
-	0, 0, 0x3fff, { 0 }
+	.exp = 0x3fff,
 };
 
 extern struct fp_ext *fp_fadd(struct fp_ext *dest, const struct fp_ext *src);
diff -puN arch/m68k/math-emu/multi_arith.h~linus arch/m68k/math-emu/multi_arith.h
--- 25/arch/m68k/math-emu/multi_arith.h~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68k/math-emu/multi_arith.h	2004-01-19 22:17:21.000000000 -0800
@@ -38,17 +38,14 @@ enum {
 
 /* Convenience functions to stuff various integer values into int128s */
 
-extern inline void zero128(int128 a)
+static inline void zero128(int128 a)
 {
 	a[LSW128] = a[NLSW128] = a[NMSW128] = a[MSW128] = 0;
 }
 
 /* Human-readable word order in the arguments */
-extern inline void set128(unsigned int i3,
-			  unsigned int i2,
-			  unsigned int i1,
-			  unsigned int i0,
-			  int128 a)
+static inline void set128(unsigned int i3, unsigned int i2, unsigned int i1,
+			  unsigned int i0, int128 a)
 {
 	a[LSW128] = i0;
 	a[NLSW128] = i1;
@@ -57,21 +54,19 @@ extern inline void set128(unsigned int i
 }
 
 /* Convenience functions (for testing as well) */
-extern inline void int64_to_128(unsigned long long src,
-				int128 dest)
+static inline void int64_to_128(unsigned long long src, int128 dest)
 {
 	dest[LSW128] = (unsigned int) src;
 	dest[NLSW128] = src >> 32;
 	dest[NMSW128] = dest[MSW128] = 0;
 }
 
-extern inline void int128_to_64(const int128 src,
-				unsigned long long *dest)
+static inline void int128_to_64(const int128 src, unsigned long long *dest)
 {
 	*dest = src[LSW128] | (long long) src[NLSW128] << 32;
 }
 
-extern inline void put_i128(const int128 a)
+static inline void put_i128(const int128 a)
 {
 	printk("%08x %08x %08x %08x\n", a[MSW128], a[NMSW128],
 	       a[NLSW128], a[LSW128]);
@@ -82,7 +77,7 @@ extern inline void put_i128(const int128
    Note that these are only good for 0 < count < 32.
  */
 
-extern inline void _lsl128(unsigned int count, int128 a)
+static inline void _lsl128(unsigned int count, int128 a)
 {
 	a[MSW128] = (a[MSW128] << count) | (a[NMSW128] >> (32 - count));
 	a[NMSW128] = (a[NMSW128] << count) | (a[NLSW128] >> (32 - count));
@@ -90,7 +85,7 @@ extern inline void _lsl128(unsigned int 
 	a[LSW128] <<= count;
 }
 
-extern inline void _lsr128(unsigned int count, int128 a)
+static inline void _lsr128(unsigned int count, int128 a)
 {
 	a[LSW128] = (a[LSW128] >> count) | (a[NLSW128] << (32 - count));
 	a[NLSW128] = (a[NLSW128] >> count) | (a[NMSW128] << (32 - count));
@@ -100,7 +95,7 @@ extern inline void _lsr128(unsigned int 
 
 /* Should be faster, one would hope */
 
-extern inline void lslone128(int128 a)
+static inline void lslone128(int128 a)
 {
 	asm volatile ("lsl.l #1,%0\n"
 		      "roxl.l #1,%1\n"
@@ -118,7 +113,7 @@ extern inline void lslone128(int128 a)
 		      "3"(a[MSW128]));
 }
 
-extern inline void lsrone128(int128 a)
+static inline void lsrone128(int128 a)
 {
 	asm volatile ("lsr.l #1,%0\n"
 		      "roxr.l #1,%1\n"
@@ -140,7 +135,7 @@ extern inline void lsrone128(int128 a)
 
    These bit-shift to a multiple of 32, then move whole longwords.  */
 
-extern inline void lsl128(unsigned int count, int128 a)
+static inline void lsl128(unsigned int count, int128 a)
 {
 	int wordcount, i;
 
@@ -159,7 +154,7 @@ extern inline void lsl128(unsigned int c
 	}
 }
 
-extern inline void lsr128(unsigned int count, int128 a)
+static inline void lsr128(unsigned int count, int128 a)
 {
 	int wordcount, i;
 
@@ -177,18 +172,18 @@ extern inline void lsr128(unsigned int c
 	}
 }
 
-extern inline int orl128(int a, int128 b)
+static inline int orl128(int a, int128 b)
 {
 	b[LSW128] |= a;
 }
 
-extern inline int btsthi128(const int128 a)
+static inline int btsthi128(const int128 a)
 {
 	return a[MSW128] & 0x80000000;
 }
 
 /* test bits (numbered from 0 = LSB) up to and including "top" */
-extern inline int bftestlo128(int top, const int128 a)
+static inline int bftestlo128(int top, const int128 a)
 {
 	int r = 0;
 
@@ -206,7 +201,7 @@ extern inline int bftestlo128(int top, c
 
 /* Aargh.  We need these because GCC is broken */
 /* FIXME: do them in assembly, for goodness' sake! */
-extern inline void mask64(int pos, unsigned long long *mask)
+static inline void mask64(int pos, unsigned long long *mask)
 {
 	*mask = 0;
 
@@ -218,7 +213,7 @@ extern inline void mask64(int pos, unsig
 	HI_WORD(*mask) = (1 << (pos - 32)) - 1;
 }
 
-extern inline void bset64(int pos, unsigned long long *dest)
+static inline void bset64(int pos, unsigned long long *dest)
 {
 	/* This conditional will be optimized away.  Thanks, GCC! */
 	if (pos < 32)
@@ -229,7 +224,7 @@ extern inline void bset64(int pos, unsig
 			      (HI_WORD(*dest)):"id"(pos - 32));
 }
 
-extern inline int btst64(int pos, unsigned long long dest)
+static inline int btst64(int pos, unsigned long long dest)
 {
 	if (pos < 32)
 		return (0 != (LO_WORD(dest) & (1 << pos)));
@@ -237,7 +232,7 @@ extern inline int btst64(int pos, unsign
 		return (0 != (HI_WORD(dest) & (1 << (pos - 32))));
 }
 
-extern inline void lsl64(int count, unsigned long long *dest)
+static inline void lsl64(int count, unsigned long long *dest)
 {
 	if (count < 32) {
 		HI_WORD(*dest) = (HI_WORD(*dest) << count)
@@ -250,7 +245,7 @@ extern inline void lsl64(int count, unsi
 	LO_WORD(*dest) = 0;
 }
 
-extern inline void lsr64(int count, unsigned long long *dest)
+static inline void lsr64(int count, unsigned long long *dest)
 {
 	if (count < 32) {
 		LO_WORD(*dest) = (LO_WORD(*dest) >> count)
@@ -264,7 +259,7 @@ extern inline void lsr64(int count, unsi
 }
 #endif
 
-extern inline void fp_denormalize(struct fp_ext *reg, unsigned int cnt)
+static inline void fp_denormalize(struct fp_ext *reg, unsigned int cnt)
 {
 	reg->exp += cnt;
 
@@ -306,7 +301,7 @@ extern inline void fp_denormalize(struct
 	}
 }
 
-extern inline int fp_overnormalize(struct fp_ext *reg)
+static inline int fp_overnormalize(struct fp_ext *reg)
 {
 	int shift;
 
@@ -324,7 +319,7 @@ extern inline int fp_overnormalize(struc
 	return shift;
 }
 
-extern inline int fp_addmant(struct fp_ext *dest, struct fp_ext *src)
+static inline int fp_addmant(struct fp_ext *dest, struct fp_ext *src)
 {
 	int carry;
 
@@ -340,7 +335,7 @@ extern inline int fp_addmant(struct fp_e
 	return carry;
 }
 
-extern inline int fp_addcarry(struct fp_ext *reg)
+static inline int fp_addcarry(struct fp_ext *reg)
 {
 	if (++reg->exp == 0x7fff) {
 		if (reg->mant.m64)
@@ -357,7 +352,8 @@ extern inline int fp_addcarry(struct fp_
 	return 1;
 }
 
-extern inline void fp_submant(struct fp_ext *dest, struct fp_ext *src1, struct fp_ext *src2)
+static inline void fp_submant(struct fp_ext *dest, struct fp_ext *src1,
+			      struct fp_ext *src2)
 {
 	/* we assume here, gcc only insert move and a clr instr */
 	asm volatile ("sub.b %1,%0" : "=d,g" (dest->lowmant)
@@ -407,7 +403,8 @@ extern inline void fp_submant(struct fp_
 	carry;								\
 })
 
-extern inline void fp_multiplymant(union fp_mant128 *dest, struct fp_ext *src1, struct fp_ext *src2)
+static inline void fp_multiplymant(union fp_mant128 *dest, struct fp_ext *src1,
+				   struct fp_ext *src2)
 {
 	union fp_mant64 temp;
 
@@ -421,7 +418,8 @@ extern inline void fp_multiplymant(union
 	fp_addx96(dest, temp);
 }
 
-extern inline void fp_dividemant(union fp_mant128 *dest, struct fp_ext *src, struct fp_ext *div)
+static inline void fp_dividemant(union fp_mant128 *dest, struct fp_ext *src,
+				 struct fp_ext *div)
 {
 	union fp_mant128 tmp;
 	union fp_mant64 tmp64;
@@ -484,7 +482,7 @@ extern inline void fp_dividemant(union f
 }
 
 #if 0
-extern inline unsigned int fp_fls128(union fp_mant128 *src)
+static inline unsigned int fp_fls128(union fp_mant128 *src)
 {
 	unsigned long data;
 	unsigned int res, off;
@@ -504,7 +502,7 @@ extern inline unsigned int fp_fls128(uni
 	return res + off;
 }
 
-extern inline void fp_shiftmant128(union fp_mant128 *src, int shift)
+static inline void fp_shiftmant128(union fp_mant128 *src, int shift)
 {
 	unsigned long sticky;
 
@@ -594,7 +592,8 @@ extern inline void fp_shiftmant128(union
 }
 #endif
 
-extern inline void fp_putmant128(struct fp_ext *dest, union fp_mant128 *src, int shift)
+static inline void fp_putmant128(struct fp_ext *dest, union fp_mant128 *src,
+				 int shift)
 {
 	unsigned long tmp;
 
@@ -639,7 +638,7 @@ extern inline void fp_putmant128(struct 
 }
 
 #if 0 /* old code... */
-extern inline int fls(unsigned int a)
+static inline int fls(unsigned int a)
 {
 	int r;
 
@@ -649,7 +648,7 @@ extern inline int fls(unsigned int a)
 }
 
 /* fls = "find last set" (cf. ffs(3)) */
-extern inline int fls128(const int128 a)
+static inline int fls128(const int128 a)
 {
 	if (a[MSW128])
 		return fls(a[MSW128]);
@@ -668,12 +667,12 @@ extern inline int fls128(const int128 a)
 		return -1;
 }
 
-extern inline int zerop128(const int128 a)
+static inline int zerop128(const int128 a)
 {
 	return !(a[LSW128] | a[NLSW128] | a[NMSW128] | a[MSW128]);
 }
 
-extern inline int nonzerop128(const int128 a)
+static inline int nonzerop128(const int128 a)
 {
 	return (a[LSW128] | a[NLSW128] | a[NMSW128] | a[MSW128]);
 }
@@ -681,7 +680,7 @@ extern inline int nonzerop128(const int1
 /* Addition and subtraction */
 /* Do these in "pure" assembly, because "extended" asm is unmanageable
    here */
-extern inline void add128(const int128 a, int128 b)
+static inline void add128(const int128 a, int128 b)
 {
 	/* rotating carry flags */
 	unsigned int carry[2];
@@ -699,7 +698,7 @@ extern inline void add128(const int128 a
 }
 
 /* Note: assembler semantics: "b -= a" */
-extern inline void sub128(const int128 a, int128 b)
+static inline void sub128(const int128 a, int128 b)
 {
 	/* rotating borrow flags */
 	unsigned int borrow[2];
@@ -717,9 +716,7 @@ extern inline void sub128(const int128 a
 }
 
 /* Poor man's 64-bit expanding multiply */
-extern inline void mul64(unsigned long long a,
-		  unsigned long long b,
-		  int128 c)
+static inline void mul64(unsigned long long a, unsigned long long b, int128 c)
 {
 	unsigned long long acc;
 	int128 acc128;
@@ -756,7 +753,7 @@ extern inline void mul64(unsigned long l
 }
 
 /* Note: unsigned */
-extern inline int cmp128(int128 a, int128 b)
+static inline int cmp128(int128 a, int128 b)
 {
 	if (a[MSW128] < b[MSW128])
 		return -1;
diff -puN -L arch/m68k/mm/extable.c arch/m68k/mm/extable.c~linus /dev/null
--- 25/arch/m68k/mm/extable.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,33 +0,0 @@
-/*
- * linux/arch/m68k/mm/extable.c
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <asm/uaccess.h>
-
-extern const struct exception_table_entry __start___ex_table[];
-extern const struct exception_table_entry __stop___ex_table[];
-
-/* Simple binary search */
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
-	       const struct exception_table_entry *last,
-	       unsigned long value)
-{
-        while (first <= last) {
-		const struct exception_table_entry *mid;
-		long diff;
-
-		mid = (last - first) / 2 + first;
-		diff = value - mid->insn;
-		if (diff >= 0 && diff <= 2)
-			return mid;
-		else if (diff > 0)
-			first = mid+1;
-		else
-			last = mid-1;
-	}
-	return NULL;
-}
-
diff -puN arch/m68k/mm/hwtest.c~linus arch/m68k/mm/hwtest.c
--- 25/arch/m68k/mm/hwtest.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68k/mm/hwtest.c	2004-01-19 22:17:21.000000000 -0800
@@ -23,6 +23,8 @@
  * a temporary VBR and a vector table for the duration of the test.
  */
 
+#include <linux/module.h>
+
 int hwreg_present( volatile void *regp )
 {
     int	ret = 0;
@@ -47,6 +49,7 @@ int hwreg_present( volatile void *regp )
 
     return( ret );
 }
+EXPORT_SYMBOL(hwreg_present);
   
 /* Basically the same, but writes a value into a word register, protected
  * by a bus error handler. Returns 1 if successful, 0 otherwise.
@@ -78,4 +81,5 @@ int hwreg_write( volatile void *regp, un
 
 	return( ret );
 }
+EXPORT_SYMBOL(hwreg_write);
 
diff -puN arch/m68k/mm/Makefile~linus arch/m68k/mm/Makefile
--- 25/arch/m68k/mm/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68k/mm/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -2,7 +2,7 @@
 # Makefile for the linux m68k-specific parts of the memory manager.
 #
 
-obj-y		:= init.o fault.o extable.o hwtest.o
+obj-y		:= init.o fault.o hwtest.o
 
 ifndef CONFIG_SUN3
 obj-y		+= kmap.o memory.o motorola.o
diff -puN arch/m68k/mm/motorola.c~linus arch/m68k/mm/motorola.c
--- 25/arch/m68k/mm/motorola.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68k/mm/motorola.c	2004-01-19 22:17:21.000000000 -0800
@@ -9,6 +9,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/module.h>
 #include <linux/signal.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
@@ -40,6 +41,7 @@
  * For 68040, this is _PAGE_CACHE040 (cachable, copyback)
  */
 unsigned long mm_cachebits = 0;
+EXPORT_SYMBOL(mm_cachebits);
 #endif
 
 static pte_t * __init kernel_page_table(void)
diff -puN arch/m68k/mvme16x/rtc.c~linus arch/m68k/mvme16x/rtc.c
--- 25/arch/m68k/mvme16x/rtc.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68k/mvme16x/rtc.c	2004-01-19 22:17:21.000000000 -0800
@@ -51,6 +51,7 @@ static int rtc_ioctl(struct inode *inode
 		local_irq_save(flags);
 		/* Ensure clock and real-time-mode-register are accessible */
 		rtc->ctrl = RTC_READ;
+		memset(&wtime, 0, sizeof(struct rtc_time));
 		wtime.tm_sec =  BCD2BIN(rtc->bcd_sec);
 		wtime.tm_min =  BCD2BIN(rtc->bcd_min);
 		wtime.tm_hour = BCD2BIN(rtc->bcd_hr);
@@ -155,9 +156,9 @@ static struct file_operations rtc_fops =
 
 static struct miscdevice rtc_dev=
 {
-	RTC_MINOR,
-	"rtc",
-	&rtc_fops
+	.minor =	RTC_MINOR,
+	.name =		"rtc",
+	.fops =		&rtc_fops
 };
 
 int __init rtc_MK48T08_init(void)
diff -puN arch/m68knommu/kernel/Makefile~linus arch/m68knommu/kernel/Makefile
--- 25/arch/m68knommu/kernel/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68knommu/kernel/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -4,8 +4,8 @@
 
 extra-y := vmlinux.lds.s
 
-obj-y += entry.o init_task.o m68k_ksyms.o process.o ptrace.o \
-	 semaphore.o setup.o signal.o syscalltable.o sys_m68k.o time.o \
-	 traps.o
+obj-y += entry.o init_task.o m68k_ksyms.o process.o ptrace.o semaphore.o \
+	 setup.o signal.o syscalltable.o sys_m68k.o time.o traps.o
 
+obj-$(CONFIG_MODULES)	+= module.o
 obj-$(CONFIG_COMEMPCI)	+= comempci.o
diff -puN /dev/null arch/m68knommu/kernel/module.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/m68knommu/kernel/module.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,99 @@
+#include <linux/moduleloader.h>
+#include <linux/elf.h>
+#include <linux/vmalloc.h>
+#include <linux/fs.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+
+#if 0
+#define DEBUGP printk
+#else
+#define DEBUGP(fmt...)
+#endif
+
+void *module_alloc(unsigned long size)
+{
+	if (size == 0)
+		return NULL;
+	return vmalloc(size);
+}
+
+
+/* Free memory returned from module_alloc */
+void module_free(struct module *mod, void *module_region)
+{
+	vfree(module_region);
+	/* FIXME: If module_region == mod->init_region, trim exception
+           table entries. */
+}
+
+/* We don't need anything special. */
+int module_frob_arch_sections(Elf_Ehdr *hdr,
+			      Elf_Shdr *sechdrs,
+			      char *secstrings,
+			      struct module *mod)
+{
+	return 0;
+}
+
+int apply_relocate(Elf32_Shdr *sechdrs,
+		   const char *strtab,
+		   unsigned int symindex,
+		   unsigned int relsec,
+		   struct module *me)
+{
+	unsigned int i;
+	Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
+	Elf32_Sym *sym;
+	uint32_t *location;
+
+	DEBUGP("Applying relocate section %u to %u\n", relsec,
+	       sechdrs[relsec].sh_info);
+	for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
+		/* This is where to make the change */
+		location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
+			+ rel[i].r_offset;
+		/* This is the symbol it is referring to.  Note that all
+		   undefined symbols have been resolved.  */
+		sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
+			+ ELF32_R_SYM(rel[i].r_info);
+
+		switch (ELF32_R_TYPE(rel[i].r_info)) {
+		case R_68K_32:
+			/* We add the value into the location given */
+			*location += sym->st_value;
+			break;
+		case R_68K_PC32:
+			/* Add the value, subtract its postition */
+			*location += sym->st_value - (uint32_t)location;
+			break;
+		default:
+			printk(KERN_ERR "module %s: Unknown relocation: %u\n",
+			       me->name, ELF32_R_TYPE(rel[i].r_info));
+			return -ENOEXEC;
+		}
+	}
+	return 0;
+}
+
+int apply_relocate_add(Elf32_Shdr *sechdrs,
+		       const char *strtab,
+		       unsigned int symindex,
+		       unsigned int relsec,
+		       struct module *me)
+{
+	printk(KERN_ERR "module %s: ADD RELOCATION unsupported\n",
+	       me->name);
+	return -ENOEXEC;
+}
+
+int module_finalize(const Elf_Ehdr *hdr,
+		    const Elf_Shdr *sechdrs,
+		    struct module *me)
+{
+	return 0;
+}
+
+void module_arch_cleanup(struct module *mod)
+{
+}
diff -puN arch/m68knommu/kernel/time.c~linus arch/m68knommu/kernel/time.c
--- 25/arch/m68knommu/kernel/time.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68knommu/kernel/time.c	2004-01-19 22:17:21.000000000 -0800
@@ -202,4 +202,12 @@ int do_settimeofday(struct timespec *tv)
 	return 0;
 }
 
+/*
+ * Scheduler clock - returns current time in nanosec units.
+ */
+unsigned long long sched_clock(void)
+{
+	return (unsigned long long)jiffies * (1000000000 / HZ);
+}
+
 EXPORT_SYMBOL(do_settimeofday);
diff -puN arch/m68knommu/lib/checksum.c~linus arch/m68knommu/lib/checksum.c
--- 25/arch/m68knommu/lib/checksum.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68knommu/lib/checksum.c	2004-01-19 22:17:21.000000000 -0800
@@ -32,7 +32,6 @@
    of the assembly has to go. */
 
 #include <net/checksum.h>
-#include <net/module.h>
 
 static inline unsigned short from32to16(unsigned long x)
 {
diff -puN -L arch/m68knommu/mm/extable.c arch/m68knommu/mm/extable.c~linus /dev/null
--- 25/arch/m68knommu/mm/extable.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,30 +0,0 @@
-/*
- * linux/arch/m68knommu/mm/extable.c
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/spinlock.h>
-#include <asm/uaccess.h>
-
-/* Simple binary search */
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
-	       const struct exception_table_entry *last,
-	       unsigned long value)
-{
-        while (first <= last) {
-		const struct exception_table_entry *mid;
-		long diff;
-
-		mid = (last - first) / 2 + first;
-		diff = mid->insn - value;
-                if (diff == 0)
-                        return mid;
-                else if (diff < 0)
-                        first = mid+1;
-                else
-                        last = mid-1;
-        }
-        return NULL;
-}
diff -puN arch/m68knommu/mm/Makefile~linus arch/m68knommu/mm/Makefile
--- 25/arch/m68knommu/mm/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68knommu/mm/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -2,4 +2,4 @@
 # Makefile for the linux m68knommu specific parts of the memory manager.
 #
 
-obj-y += init.o fault.o memory.o kmap.o extable.o
+obj-y += init.o fault.o memory.o kmap.o
diff -puN arch/m68knommu/platform/5307/entry.S~linus arch/m68knommu/platform/5307/entry.S
--- 25/arch/m68knommu/platform/5307/entry.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68knommu/platform/5307/entry.S	2004-01-19 22:17:21.000000000 -0800
@@ -182,7 +182,7 @@ ENTRY(inthandler)
 	movew   %sp@(LFORMATVEC),%d0	/* put exception # in d0 */
 	andl	#0x03fc,%d0		/* mask out vector only */
 
-	leal	kstat__per_cpu+STAT_IRQ,%a0
+	leal	per_cpu__kstat+STAT_IRQ,%a0
 	addql	#1,%a0@(%d0)
 
 	lsrl	#2,%d0			/* calculate real vector # */
@@ -213,7 +213,7 @@ ENTRY(fasthandler)
 	movew   %sp@(LFORMATVEC),%d0
 	andl	#0x03fc,%d0		/* mask out vector only */
 
-	leal	kstat__per_cpu+STAT_IRQ,%a0
+	leal	per_cpu__kstat+STAT_IRQ,%a0
 	addql	#1,%a0@(%d0)
 
 	movel	%sp,%sp@-		/* push regs arg onto stack */
diff -puN arch/m68k/q40/q40ints.c~linus arch/m68k/q40/q40ints.c
--- 25/arch/m68k/q40/q40ints.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68k/q40/q40ints.c	2004-01-19 22:17:21.000000000 -0800
@@ -281,21 +281,17 @@ static struct IRQ_TABLE iirqs[]={
   {Q40_IRQ_KEYB_MASK,Q40_IRQ_KEYBOARD},
   {0,0}};
 #endif
-static struct IRQ_TABLE eirqs[]={
-  {Q40_IRQ3_MASK,3},                   /* ser 1 */
-  {Q40_IRQ4_MASK,4},                   /* ser 2 */
-  {Q40_IRQ14_MASK,14},                 /* IDE 1 */
-  {Q40_IRQ15_MASK,15},                 /* IDE 2 */
-  {Q40_IRQ6_MASK,6},                   /* floppy, handled elsewhere */
-  {Q40_IRQ7_MASK,7},                   /* par */
-
-  {Q40_IRQ5_MASK,5},
-  {Q40_IRQ10_MASK,10},
-
-
-
-
-  {0,0}};
+static struct IRQ_TABLE eirqs[] = {
+  { .mask = Q40_IRQ3_MASK,	.irq = 3 },	/* ser 1 */
+  { .mask = Q40_IRQ4_MASK,	.irq = 4 },	/* ser 2 */
+  { .mask = Q40_IRQ14_MASK,	.irq = 14 },	/* IDE 1 */
+  { .mask = Q40_IRQ15_MASK,	.irq = 15 },	/* IDE 2 */
+  { .mask = Q40_IRQ6_MASK,	.irq = 6 },	/* floppy, handled elsewhere */
+  { .mask = Q40_IRQ7_MASK,	.irq = 7 },	/* par */
+  { .mask = Q40_IRQ5_MASK,	.irq = 5 },
+  { .mask = Q40_IRQ10_MASK,	.irq = 10 },
+  {0,0}
+};
 
 /* complain only this many times about spurious ints : */
 static int ccleirq=60;    /* ISA dev IRQ's*/
diff -puN arch/m68k/sun3/idprom.c~linus arch/m68k/sun3/idprom.c
--- 25/arch/m68k/sun3/idprom.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/m68k/sun3/idprom.c	2004-01-19 22:17:21.000000000 -0800
@@ -24,34 +24,34 @@ static struct idprom idprom_buffer;
  */
 struct Sun_Machine_Models Sun_Machines[NUM_SUN_MACHINES] = {
 /* First, Sun3's */
-{ "Sun 3/160 Series", (SM_SUN3 | SM_3_160) },
-{ "Sun 3/50", (SM_SUN3 | SM_3_50) },
-{ "Sun 3/260 Series", (SM_SUN3 | SM_3_260) },
-{ "Sun 3/110 Series", (SM_SUN3 | SM_3_110) },
-{ "Sun 3/60", (SM_SUN3 | SM_3_60) },
-{ "Sun 3/E", (SM_SUN3 | SM_3_E) },
+    { .name = "Sun 3/160 Series",	.id_machtype = (SM_SUN3 | SM_3_160) },
+    { .name = "Sun 3/50",		.id_machtype = (SM_SUN3 | SM_3_50) },
+    { .name = "Sun 3/260 Series",	.id_machtype = (SM_SUN3 | SM_3_260) },
+    { .name = "Sun 3/110 Series",	.id_machtype = (SM_SUN3 | SM_3_110) },
+    { .name = "Sun 3/60",		.id_machtype = (SM_SUN3 | SM_3_60) },
+    { .name = "Sun 3/E",		.id_machtype = (SM_SUN3 | SM_3_E) },
 /* Now, Sun3x's */
-{ "Sun 3/460 Series", (SM_SUN3X | SM_3_460) },
-{ "Sun 3/80", (SM_SUN3X | SM_3_80) },
+    { .name = "Sun 3/460 Series",	.id_machtype = (SM_SUN3X | SM_3_460) },
+    { .name = "Sun 3/80",		.id_machtype = (SM_SUN3X | SM_3_80) },
 /* Then, Sun4's */
-//{ "Sun 4/100 Series", (SM_SUN4 | SM_4_110) },
-//{ "Sun 4/200 Series", (SM_SUN4 | SM_4_260) },
-//{ "Sun 4/300 Series", (SM_SUN4 | SM_4_330) },
-//{ "Sun 4/400 Series", (SM_SUN4 | SM_4_470) },
+// { .name = "Sun 4/100 Series",	.id_machtype = (SM_SUN4 | SM_4_110) },
+// { .name = "Sun 4/200 Series",	.id_machtype = (SM_SUN4 | SM_4_260) },
+// { .name = "Sun 4/300 Series",	.id_machtype = (SM_SUN4 | SM_4_330) },
+// { .name = "Sun 4/400 Series",	.id_machtype = (SM_SUN4 | SM_4_470) },
 /* And now, Sun4c's */
-//{ "Sun4c SparcStation 1", (SM_SUN4C | SM_4C_SS1) },
-//{ "Sun4c SparcStation IPC", (SM_SUN4C | SM_4C_IPC) },
-//{ "Sun4c SparcStation 1+", (SM_SUN4C | SM_4C_SS1PLUS) },
-//{ "Sun4c SparcStation SLC", (SM_SUN4C | SM_4C_SLC) },
-//{ "Sun4c SparcStation 2", (SM_SUN4C | SM_4C_SS2) },
-//{ "Sun4c SparcStation ELC", (SM_SUN4C | SM_4C_ELC) },
-//{ "Sun4c SparcStation IPX", (SM_SUN4C | SM_4C_IPX) },
+// { .name = "Sun4c SparcStation 1",	.id_machtype = (SM_SUN4C | SM_4C_SS1) },
+// { .name = "Sun4c SparcStation IPC",	.id_machtype = (SM_SUN4C | SM_4C_IPC) },
+// { .name = "Sun4c SparcStation 1+",	.id_machtype = (SM_SUN4C | SM_4C_SS1PLUS) },
+// { .name = "Sun4c SparcStation SLC",	.id_machtype = (SM_SUN4C | SM_4C_SLC) },
+// { .name = "Sun4c SparcStation 2",	.id_machtype = (SM_SUN4C | SM_4C_SS2) },
+// { .name = "Sun4c SparcStation ELC",	.id_machtype = (SM_SUN4C | SM_4C_ELC) },
+// { .name = "Sun4c SparcStation IPX",	.id_machtype = (SM_SUN4C | SM_4C_IPX) },
 /* Finally, early Sun4m's */
-//{ "Sun4m SparcSystem600", (SM_SUN4M | SM_4M_SS60) },
-//{ "Sun4m SparcStation10/20", (SM_SUN4M | SM_4M_SS50) },
-//{ "Sun4m SparcStation5", (SM_SUN4M | SM_4M_SS40) },
+// { .name = "Sun4m SparcSystem600",	.id_machtype = (SM_SUN4M | SM_4M_SS60) },
+// { .name = "Sun4m SparcStation10/20",	.id_machtype = (SM_SUN4M | SM_4M_SS50) },
+// { .name = "Sun4m SparcStation5",	.id_machtype = (SM_SUN4M | SM_4M_SS40) },
 /* One entry for the OBP arch's which are sun4d, sun4e, and newer sun4m's */
-//{ "Sun4M OBP based system", (SM_SUN4M_OBP | 0x0) }
+// { .name = "Sun4M OBP based system",	.id_machtype = (SM_SUN4M_OBP | 0x0) }
 };
 
 static void __init display_system_type(unsigned char machtype)
diff -puN arch/mips/Kconfig~linus arch/mips/Kconfig
--- 25/arch/mips/Kconfig~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/mips/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -981,6 +981,7 @@ config SMP
 
 config NR_CPUS
 	int "Maximum number of CPUs (2-32)"
+	range 2 32
 	depends on SMP
 	default "32"
 	help
diff -puN -L arch/mips/mm/extable.c arch/mips/mm/extable.c~linus /dev/null
--- 25/arch/mips/mm/extable.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,30 +0,0 @@
-/*
- * linux/arch/i386/mm/extable.c
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/spinlock.h>
-#include <asm/uaccess.h>
-
-/* Simple binary search */
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
-	       const struct exception_table_entry *last,
-	       unsigned long value)
-{
-        while (first <= last) {
-		const struct exception_table_entry *mid;
-		long diff;
-
-		mid = (last - first) / 2 + first;
-		diff = mid->insn - value;
-                if (diff == 0)
-                        return mid;
-                else if (diff < 0)
-                        first = mid+1;
-                else
-                        last = mid-1;
-        }
-        return NULL;
-}
diff -puN arch/mips/mm/Makefile~linus arch/mips/mm/Makefile
--- 25/arch/mips/mm/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/mips/mm/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -2,7 +2,7 @@
 # Makefile for the Linux/MIPS-specific parts of the memory manager.
 #
 
-obj-y				+= cache.o extable.o fault.o loadmmu.o pgtable.o
+obj-y				+= cache.o fault.o loadmmu.o pgtable.o
 
 obj-$(CONFIG_MIPS32)		+= ioremap.o pgtable-32.o
 obj-$(CONFIG_MIPS64)		+= pgtable-64.o
diff -puN arch/parisc/Kconfig~linus arch/parisc/Kconfig
--- 25/arch/parisc/Kconfig~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/parisc/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -154,6 +154,7 @@ config HPUX
 
 config NR_CPUS
 	int "Maximum number of CPUs (2-32)"
+	range 2 32
 	depends on SMP
 	default "32"
 
diff -puN arch/parisc/kernel/sys_parisc.c~linus arch/parisc/kernel/sys_parisc.c
--- 25/arch/parisc/kernel/sys_parisc.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/parisc/kernel/sys_parisc.c	2004-01-19 22:17:21.000000000 -0800
@@ -93,17 +93,13 @@ static unsigned long get_shared_area(str
 unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
 		unsigned long len, unsigned long pgoff, unsigned long flags)
 {
-	struct inode *inode;
-
 	if (len > TASK_SIZE)
 		return -ENOMEM;
 	if (!addr)
 		addr = TASK_UNMAPPED_BASE;
 
-	inode = filp ? filp->f_dentry->d_inode : NULL;
-
-	if (inode && (flags & MAP_SHARED)) {
-		addr = get_shared_area(inode->i_mapping, addr, len, pgoff);
+	if (filp && (flags & MAP_SHARED)) {
+		addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
 	} else {
 		addr = get_unshared_area(addr, len);
 	}
diff -puN -L arch/parisc/mm/extable.c arch/parisc/mm/extable.c~linus /dev/null
--- 25/arch/parisc/mm/extable.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,37 +0,0 @@
-/*
- * Kernel exception handling table support.  Derived from arch/i386/mm/extable.c.
- *
- * Copyright (C) 2000 Hewlett-Packard Co
- * Copyright (C) 2000 John Marvin (jsm@fc.hp.com)
- */
-
-#include <asm/uaccess.h>
-
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
-	       const struct exception_table_entry *last,
-	       unsigned long addr)
-{
-	/* Abort early if the search value is out of range.  */
-
-	if ((addr < first->addr) || (addr > last->addr))
-		return 0;
-
-        while (first <= last) {
-		const struct exception_table_entry *mid;
-		long diff;
-
-		mid = first + ((last - first)/2);
-		diff = mid->addr - addr;
-
-                if (diff == 0)
-                        return mid;
-                else if (diff < 0)
-                        first = mid+1;
-                else
-                        last = mid-1;
-        }
-
-        return 0;
-}
-
diff -puN arch/parisc/mm/Makefile~linus arch/parisc/mm/Makefile
--- 25/arch/parisc/mm/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/parisc/mm/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -2,4 +2,4 @@
 # Makefile for arch/parisc/mm
 #
 
-obj-y	 := init.o fault.o extable.o ioremap.o
+obj-y	 := init.o fault.o ioremap.o
diff -puN arch/ppc64/boot/ppc32-types.h~linus arch/ppc64/boot/ppc32-types.h
--- 25/arch/ppc64/boot/ppc32-types.h~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/boot/ppc32-types.h	2004-01-19 22:17:21.000000000 -0800
@@ -25,6 +25,12 @@ typedef unsigned int u32;
 typedef signed long long s64;
 typedef unsigned long long u64;
 
+typedef struct {
+	__u32 u[4];
+} __attribute((aligned(16))) __vector128;
+
 #define BITS_PER_LONG 32
 
+typedef __vector128 vector128;
+
 #endif /* _PPC64_TYPES_H */
diff -puN arch/ppc64/Kconfig~linus arch/ppc64/Kconfig
--- 25/arch/ppc64/Kconfig~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -72,6 +72,21 @@ config PPC64
 	bool
 	default y
 
+# VMX is pSeries only for now until somebody writes the iSeries
+# exception vectors for it
+config ALTIVEC
+	bool "Support for VMX (Altivec) vector unit"
+	depends on PPC_PSERIES
+	default y
+
+config POWER4_ONLY
+	bool "Optimize for POWER4"
+	default n
+	---help---
+	  Cause the compiler to optimize for POWER4 processors. The resulting
+	  binary will not work on POWER3 or RS64 processors when compiled with
+	  binutils 2.15 or later.
+
 config SMP
 	bool "Symmetric multi-processing support"
 	---help---
@@ -97,6 +112,7 @@ config IRQ_ALL_CPUS
 
 config NR_CPUS
 	int "Maximum number of CPUs (2-128)"
+	range 2 128
 	depends on SMP
 	default "32"
 
@@ -130,17 +146,24 @@ config MSCHUNKS
 	depends on PPC_ISERIES
 	default y
 
+
+config PPC_RTAS
+	bool "Proc interface to RTAS"
+	depends on !PPC_ISERIES
+
 config RTAS_FLASH
 	tristate "Firmware flash interface"
-	depends on !PPC_ISERIES
+	depends on PPC_RTAS
 
 config SCANLOG
 	tristate "Scanlog dump interface"
-	depends on !PPC_ISERIES
+	depends on PPC_RTAS
 
-config PPC_RTAS
-	bool "Proc interface to RTAS"
-	depends on !PPC_ISERIES
+config LPARCFG
+	bool "LPAR Configuration Data"
+	help
+	Provide system capacity information via human readable 
+	<key word>=<value> pairs through a /proc/ppc64/lparcfg interface.
 
 endmenu
 
@@ -318,7 +341,7 @@ endmenu
 
 config VIOPATH
 	bool
-	depends on PPC_ISERIES
+	depends on VIOCONS || VIODASD || VIOCD || VIOTAPE || VETH
 	default y
 
 source "arch/ppc64/oprofile/Kconfig"
diff -puN arch/ppc64/kernel/asm-offsets.c~linus arch/ppc64/kernel/asm-offsets.c
--- 25/arch/ppc64/kernel/asm-offsets.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/asm-offsets.c	2004-01-19 22:17:21.000000000 -0800
@@ -56,6 +56,12 @@ int main(void)
 	DEFINE(THREAD_FPSCR, offsetof(struct thread_struct, fpscr));
 	DEFINE(KSP, offsetof(struct thread_struct, ksp));
 
+#ifdef CONFIG_ALTIVEC
+	DEFINE(THREAD_VR0, offsetof(struct thread_struct, vr[0]));
+	DEFINE(THREAD_VRSAVE, offsetof(struct thread_struct, vrsave));
+	DEFINE(THREAD_VSCR, offsetof(struct thread_struct, vscr));
+	DEFINE(THREAD_USED_VR, offsetof(struct thread_struct, used_vr));
+#endif /* CONFIG_ALTIVEC */
 	DEFINE(MM, offsetof(struct task_struct, mm));
 
 	/* naca */
diff -puN arch/ppc64/kernel/chrp_setup.c~linus arch/ppc64/kernel/chrp_setup.c
--- 25/arch/ppc64/kernel/chrp_setup.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/chrp_setup.c	2004-01-19 22:17:21.000000000 -0800
@@ -57,6 +57,7 @@
 #include <asm/irq.h>
 #include <asm/naca.h>
 #include <asm/time.h>
+#include <asm/nvram.h>
 
 #include "i8259.h"
 #include "open_pic.h"
@@ -64,8 +65,6 @@
 #include <asm/ppcdebug.h>
 #include <asm/cputable.h>
 
-extern volatile unsigned char *chrp_int_ack_special;
-
 void chrp_progress(char *, unsigned short);
 
 extern void openpic_init_IRQ(void);
@@ -96,16 +95,19 @@ chrp_get_cpuinfo(struct seq_file *m)
 
 	seq_printf(m, "timebase\t: %lu\n", ppc_tb_freq);
 
-	root = find_path_device("/");
+	root = of_find_node_by_path("/");
 	if (root)
 		model = get_property(root, "model", NULL);
 	seq_printf(m, "machine\t\t: CHRP %s\n", model);
+	of_node_put(root);
 }
 
 #define I8042_DATA_REG 0x60
 
-void __init chrp_request_regions(void) 
+void __init chrp_request_regions(void)
 {
+	struct device_node *i8042;
+
 	request_region(0x20,0x20,"pic1");
 	request_region(0xa0,0x20,"pic2");
 	request_region(0x00,0x20,"dma1");
@@ -118,8 +120,9 @@ void __init chrp_request_regions(void) 
 	 * tree and reserve the region if it does not appear. Later on
 	 * the i8042 code will try and reserve this region and fail.
 	 */
-	if (!find_type_devices("8042"))
+	if (!(i8042 = of_find_node_by_type(NULL, "8042")))
 		request_region(I8042_DATA_REG, 16, "reserved (no i8042)");
+	of_node_put(i8042);
 }
 
 void __init
@@ -158,7 +161,7 @@ chrp_setup_arch(void)
 #endif
 
 	/* Find the Open PIC if present */
-	root = find_path_device("/");
+	root = of_find_node_by_path("/");
 	opprop = (unsigned int *) get_property(root,
 				"platform-open-pic", NULL);
 	if (opprop != 0) {
@@ -170,6 +173,7 @@ chrp_setup_arch(void)
 		printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic);
 		OpenPIC_Addr = __ioremap(openpic, 0x40000, _PAGE_NO_CACHE);
 	}
+	of_node_put(root);
 
 #ifdef CONFIG_DUMMY_CONSOLE
 	conswitchp = &dummy_con;
@@ -229,6 +233,10 @@ void __init
 chrp_init(unsigned long r3, unsigned long r4, unsigned long r5,
 	  unsigned long r6, unsigned long r7)
 {
+	struct device_node * dn;
+	char * hypertas;
+	unsigned int len;
+
 #if 0 /* PPPBBB remove this later... -Peter */
 #ifdef CONFIG_BLK_DEV_INITRD
 	/* take care of initrd if we have one */
@@ -262,36 +270,40 @@ chrp_init(unsigned long r3, unsigned lon
 	ppc_md.set_rtc_time   = pSeries_set_rtc_time;
 	ppc_md.calibrate_decr = pSeries_calibrate_decr;
 
-	ppc_md.progress = chrp_progress;
+	ppc_md.progress       = chrp_progress;
+
+	ppc_md.nvram_read     = pSeries_nvram_read;
+	ppc_md.nvram_write    = pSeries_nvram_write;
 
-        /* build up the firmware_features bitmask field
+        /* 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");
+	dn = of_find_node_by_path("/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;
-		    } 
+		while (len > 0){
+			int i, hypertas_len;
+			/* 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 |= 
+						(firmware_features_table[i].val);
+					break;
+				} 
+			}
+			hypertas_len = strlen(hypertas);
+			len -= hypertas_len +1;
+			hypertas+= hypertas_len +1;
 		}
-		int hypertas_len = strlen(hypertas);
-		len -= hypertas_len +1;
-		hypertas+= hypertas_len +1;
-	    }
 	}
-	udbg_printf("firmware_features bitmask: 0x%x \n",
-		    cur_cpu_spec->firmware_features);
+
+	of_node_put(dn);
+	printk(KERN_INFO "firmware_features = 0x%lx\n", 
+	       cur_cpu_spec->firmware_features);
 }
 
 void
@@ -319,6 +331,13 @@ chrp_progress(char *s, unsigned short he
 		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);
+		return;
+	}
 
 	if(display_character == RTAS_UNKNOWN_SERVICE) {
 		/* use hex display if available */
@@ -405,11 +424,11 @@ void __init pSeries_calibrate_decr(void)
 
 	/*
 	 * The cpu node should have a timebase-frequency property
-	 * to tell us the rate at which the decrementer counts. 
+	 * to tell us the rate at which the decrementer counts.
 	 */
 	freq = 16666000;        /* hardcoded default */
-	cpu = find_type_devices("cpu");
-	if (cpu != 0) { 
+	cpu = of_find_node_by_type(NULL, "cpu");
+	if (cpu != 0) {
 		fp = (int *) get_property(cpu, "timebase-frequency", NULL);
 		if (fp != 0)
 			freq = *fp;
@@ -422,11 +441,12 @@ void __init pSeries_calibrate_decr(void)
 			processor_freq = *fp;
 	}
 	ppc_proc_freq = processor_freq;
-	
-        printk("time_init: decrementer frequency = %lu.%.6lu MHz\n", 
-	       freq/1000000, freq%1000000 );
+	of_node_put(cpu);
+
+	printk("time_init: decrementer frequency = %lu.%.6lu MHz\n",
+	       freq/1000000, freq%1000000);
 	printk("time_init: processor frequency   = %lu.%.6lu MHz\n",
-		processor_freq/1000000, processor_freq%1000000 );
+	       processor_freq/1000000, processor_freq%1000000);
 
 	tb_ticks_per_jiffy = freq / HZ;
 	tb_ticks_per_sec = tb_ticks_per_jiffy * HZ;
diff -puN arch/ppc64/kernel/cputable.c~linus arch/ppc64/kernel/cputable.c
--- 25/arch/ppc64/kernel/cputable.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/cputable.c	2004-01-19 22:17:21.000000000 -0800
@@ -21,6 +21,13 @@
 
 struct cpu_spec* cur_cpu_spec = NULL;
 
+/* NOTE:
+ * Unlike ppc32, ppc64 will only call this once for the boot CPU, it's
+ * the responsibility of the appropriate CPU save/restore functions to
+ * eventually copy these settings over. Those save/restore aren't yet
+ * part of the cputable though. That has to be fixed for both ppc32
+ * and ppc64
+ */
 extern void __setup_cpu_power3(unsigned long offset, struct cpu_spec* spec);
 extern void __setup_cpu_power4(unsigned long offset, struct cpu_spec* spec);
 
@@ -30,8 +37,10 @@ extern void __setup_cpu_power4(unsigned 
  */
 #ifdef CONFIG_ALTIVEC
 #define CPU_FTR_ALTIVEC_COMP	CPU_FTR_ALTIVEC
+#define PPC_FEATURE_HAS_ALTIVEC_COMP PPC_FEATURE_HAS_ALTIVEC
 #else
 #define CPU_FTR_ALTIVEC_COMP	0
+#define PPC_FEATURE_HAS_ALTIVEC_COMP    0
 #endif
 
 struct cpu_spec	cpu_specs[] = {
@@ -107,6 +116,24 @@ struct cpu_spec	cpu_specs[] = {
 	    __setup_cpu_power4,
 	    COMMON_PPC64_FW
     },
+    {	/* PPC970 */
+	    0xffff0000, 0x00390000, "PPC970",
+	    CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE |
+	    CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_ALTIVEC_COMP,
+	    COMMON_USER_PPC64 | PPC_FEATURE_HAS_ALTIVEC_COMP,
+	    128, 128,
+	    __setup_cpu_power4,
+	    COMMON_PPC64_FW
+    },
+    {	/* Power5 */
+	    0xffff0000, 0x003a0000, "Power5",
+	    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 |
@@ -130,4 +157,13 @@ firmware_feature_t firmware_features_tab
     {FW_FEATURE_DUMP,		"hcall-dump"},
     {FW_FEATURE_INTERRUPT,	"hcall-interrupt"},
     {FW_FEATURE_MIGRATE,	"hcall-migrate"},
+    {FW_FEATURE_PERFMON,	"hcall-perfmon"},
+    {FW_FEATURE_CRQ,    	"hcall-crq"},
+    {FW_FEATURE_VIO,	        "hcall-vio"},
+    {FW_FEATURE_RDMA,	        "hcall-rdma"},
+    {FW_FEATURE_LLAN,	        "hcall-lLAN"},
+    {FW_FEATURE_BULK,   	"hcall-bulk"},
+    {FW_FEATURE_XDABR,  	"hcall-xdabr"},
+    {FW_FEATURE_MULTITCE,	"hcall-multi-tce"},
+    {FW_FEATURE_SPLPAR,	        "hcall-splpar"},
 };
diff -puN arch/ppc64/kernel/eeh.c~linus arch/ppc64/kernel/eeh.c
--- 25/arch/ppc64/kernel/eeh.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/eeh.c	2004-01-19 22:17:21.000000000 -0800
@@ -257,7 +257,7 @@ void eeh_init(void)
 
 	/* Enable EEH for all adapters.  Note that eeh requires buid's */
 	info.adapters_enabled = 0;
-	for (phb = find_devices("pci"); phb; phb = phb->next) {
+	for (phb = of_find_node_by_name(NULL, "pci"); phb; phb = of_find_node_by_name(phb, "pci")) {
 		int len;
 		int *buid_vals = (int *) get_property(phb, "ibm,fw-phb-id", &len);
 		if (!buid_vals)
diff -puN arch/ppc64/kernel/entry.S~linus arch/ppc64/kernel/entry.S
--- 25/arch/ppc64/kernel/entry.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/entry.S	2004-01-19 22:17:21.000000000 -0800
@@ -29,6 +29,7 @@
 #include <asm/thread_info.h>
 #include <asm/ppc_asm.h>
 #include <asm/offsets.h>
+#include <asm/cputable.h>
 
 #ifdef CONFIG_PPC_ISERIES
 #define DO_SOFT_DISABLE
@@ -211,6 +212,15 @@ _GLOBAL(ret_from_syscall_2)
 	.align	2,0
 #endif
 
+	
+_GLOBAL(ppc32_swapcontext)
+	bl	.sys32_swapcontext
+	b	80f
+	
+_GLOBAL(ppc64_swapcontext)
+	bl	.sys_swapcontext
+	b	80f
+
 _GLOBAL(ppc32_sigreturn)
 	bl	.sys32_sigreturn
 	b	80f
@@ -261,10 +271,17 @@ _GLOBAL(_switch)
 	SAVE_10GPRS(22, r1)
 	mflr	r20		/* Return to switch caller */
 	mfmsr	r22
-	andi.	r21, r22, MSR_FP
+	li	r0, MSR_FP
+#ifdef CONFIG_ALTIVEC
+BEGIN_FTR_SECTION
+	oris	r0,r0,MSR_VEC@h	/* Disable altivec */
+	mfspr	r24,SPRN_VRSAVE	/* save vrsave register value */
+	std	r24,THREAD_VRSAVE(r3)
+END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
+#endif /* CONFIG_ALTIVEC */
+	and.	r0,r0,r22
 	beq+	1f
-	li	r6,MSR_FP	/* Disable floating-point */
-	andc	r22,r22,r6
+	andc	r22,r22,r0
 	mtmsrd	r22
 	isync
 1:	std	r20,_NIP(r1)
@@ -275,22 +292,30 @@ _GLOBAL(_switch)
 	addi	r6,r4,-THREAD	/* Convert THREAD to 'current' */
 	std	r6,PACACURRENT(r13)	/* Set new 'current' */
 
-#ifdef CONFIG_PPC_ISERIES
-#error fixme
-	ld	r7,TI_FLAGS(r4)	/* Get run light flag */
-	mfspr	r9,CTRLF
-	srdi	r7,r7,1		/* Align to run light bit in CTRL reg */
-	insrdi	r9,r7,1,63	/* Insert run light into CTRL */
-	mtspr	CTRLT,r9
-#endif
-
 	ld	r1,KSP(r4)	/* Load new stack pointer */
 	ld	r6,_CCR(r1)
 	mtcrf	0xFF,r6
+
+#ifdef CONFIG_ALTIVEC
+BEGIN_FTR_SECTION
+	ld	r0,THREAD_VRSAVE(r4)
+	mtspr	SPRN_VRSAVE,r0		/* if G4, restore VRSAVE reg */
+END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
+#endif /* CONFIG_ALTIVEC */
+
 	/* r3-r13 are destroyed -- Cort */
 	REST_8GPRS(14, r1)
 	REST_10GPRS(22, r1)
 
+#ifdef CONFIG_PPC_ISERIES
+	clrrdi	r7,r1,THREAD_SHIFT	/* get current_thread_info() */
+	ld	r7,TI_FLAGS(r7)		/* Get run light flag */
+	mfspr	r9,CTRLF
+	srdi	r7,r7,TIF_RUN_LIGHT
+	insrdi	r9,r7,1,63		/* Insert run light into CTRL */
+	mtspr	CTRLT,r9
+#endif
+
 	/* convert old thread to its task_struct for return value */
 	addi	r3,r3,-THREAD
 	ld	r7,_NIP(r1)	/* Return to _switch caller in new task */
@@ -308,39 +333,16 @@ _GLOBAL(ret_from_fork)
 	b	.ret_from_except
 
 _GLOBAL(ret_from_except)
-#ifdef CONFIG_PPC_ISERIES
-	ld	r5,SOFTE(r1)
-	cmpdi	0,r5,0
-	beq	4f
-irq_recheck:
-	/* Check for pending interrupts (iSeries) */
-	CHECKANYINT(r3,r4)
-	beq+	4f	/* skip do_IRQ if no interrupts */
-
-#warning FIX ISERIES
-	mfspr	r5,SPRG3
-	li	r3,0
-	stb	r3,PACAPROCENABLED(r5)	/* ensure we are disabled */
-	addi	r3,r1,STACK_FRAME_OVERHEAD
-	bl	.do_IRQ
-	b	irq_recheck	/* loop back and handle more */
-4:
-#endif
 	/*
 	 * Disable interrupts so that current_thread_info()->flags
 	 * can't change between when we test it and when we return
 	 * from the interrupt.
 	 */
-recheck:
 	mfmsr	r10		/* Get current interrupt state */
 	li	r4,0
 	ori	r4,r4,MSR_EE
-	andc	r10,r10,r4	/* clear MSR_EE */
-	mtmsrd	r10,1		/* Update machine state */
-
-#ifdef CONFIG_PPC_ISERIES
-#error fix iSeries soft disable
-#endif
+	andc	r9,r10,r4	/* clear MSR_EE */
+	mtmsrd	r9,1		/* Update machine state */
 
 	ld	r3,_MSR(r1)	/* Returning to user mode? */
 	andi.	r3,r3,MSR_PR
@@ -364,6 +366,28 @@ recheck:
 	REST_GPR(13,r1)
 
 restore:
+#ifdef CONFIG_PPC_ISERIES
+	ld	r5,SOFTE(r1)
+	mfspr	r4,SPRG3		/* get paca address */
+	cmpdi	0,r5,0
+	beq	4f
+	/* Check for pending interrupts (iSeries) */
+	/* this is CHECKANYINT except that we already have the paca address */
+	ld	r3,PACALPPACA+LPPACAANYINT(r4)
+	cmpdi	r3,0
+	beq+	4f			/* skip do_IRQ if no interrupts */
+
+	mfspr	r13,SPRG3		/* get paca pointer back */
+	li	r3,0
+	stb	r3,PACAPROCENABLED(r13)	/* ensure we are soft-disabled */
+	mtmsrd	r10			/* hard-enable again */
+	addi	r3,r1,STACK_FRAME_OVERHEAD
+	bl	.do_IRQ
+	b	.ret_from_except		/* loop back and handle more */
+
+4:	stb	r5,PACAPROCENABLED(r4)
+#endif
+
 	ld	r3,_CTR(r1)
 	ld	r0,_LINK(r1)
 	mtctr	r3
@@ -377,12 +401,6 @@ restore:
 
 	stdcx.	r0,0,r1		/* to clear the reservation */
 
-#ifdef DO_SOFT_DISABLE
-	/* XXX do this in do_work, r13 isnt valid here */
-	ld	r0,SOFTE(r1)
-	stb	r0,PACAPROCENABLED(r13)
-#endif
-
 	mfmsr	r0
 	li	r2, MSR_RI
 	andc	r0,r0,r2
@@ -407,21 +425,21 @@ restore:
 /* Note: this must change if we start using the  TIF_NOTIFY_RESUME bit */
 do_work:
 	/* Enable interrupts */
-	ori	r10,r10,MSR_EE
 	mtmsrd	r10,1
 
 	andi.	r0,r3,_TIF_NEED_RESCHED
 	beq	1f
 	bl	.schedule
-	b	recheck
+	b	.ret_from_except
 
 1:	andi.	r0,r3,_TIF_SIGPENDING
-	beq	recheck
+	beq	.ret_from_except
 	li	r3,0
 	addi	r4,r1,STACK_FRAME_OVERHEAD
 	bl	.do_signal
-	b	recheck
+	b	.ret_from_except
 
+#ifdef CONFIG_PPC_PSERIES
 /*
  * On CHRP, the Run-Time Abstraction Services (RTAS) have to be
  * called with the MMU off.
@@ -498,6 +516,12 @@ _STATIC(rtas_return_loc)
 	mfspr	r4,SPRG3	        /* Get PACA */
 	SET_REG_TO_CONST(r5, KERNELBASE)
         sub     r4,r4,r5                /* RELOC the PACA base pointer */
+
+	mfmsr   r6
+	li	r0,MSR_RI
+	andc	r6,r6,r0
+	sync	
+	mtmsrd  r6
         
         ld	r1,PACAR1(r4)           /* Restore our SP */
 	LOADADDR(r3,.rtas_restore_regs)
@@ -626,3 +650,4 @@ _GLOBAL(enter_prom)
 
 	mtlr    r0
         blr				/* return to caller */
+#endif	/* defined(CONFIG_PPC_PSERIES) */
diff -puN arch/ppc64/kernel/head.S~linus arch/ppc64/kernel/head.S
--- 25/arch/ppc64/kernel/head.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/head.S	2004-01-19 22:17:21.000000000 -0800
@@ -91,20 +91,26 @@
 	.text
 	.globl  _stext
 _stext:
+#ifdef CONFIG_PPC_PSERIES
 _STATIC(__start)
 	b .__start_initialization_pSeries
+#endif
 #ifdef CONFIG_PPC_ISERIES
-	/* At offset 0x20, there is a pointer to iSeries LPAR data.
-	 * This is required by the hypervisor */
+	/*
+	 * At offset 0x20, there is a pointer to iSeries LPAR data.
+	 * This is required by the hypervisor
+	 */
 	. = 0x20
 	.llong hvReleaseData-KERNELBASE
 
-	/* At offset 0x28 and 0x30 are offsets to the msChunks
+	/*
+	 * At offset 0x28 and 0x30 are offsets to the msChunks
 	 * array (used by the iSeries LPAR debugger to do translation
 	 * between physical addresses and absolute addresses) and
-	 * to the pidhash table (also used by the debugger) */
+	 * to the pidhash table (also used by the debugger)
+	 */
 	.llong msChunks-KERNELBASE
-	.llong pidhash-KERNELBASE
+	.llong 0 /* pidhash-KERNELBASE SFRXXX */
 
 	/* Offset 0x38 - Pointer to start of embedded System.map */
 	.globl	embedded_sysmap_start
@@ -114,7 +120,7 @@ embedded_sysmap_start:
 	.globl	embedded_sysmap_end
 embedded_sysmap_end:
 	.llong	0
-#endif
+#else
 
 	/* Secondary processors spin on this value until it goes to 1. */
 	.globl  __secondary_hold_spinloop
@@ -147,6 +153,7 @@ _GLOBAL(__secondary_hold)
 	/* Relocation is off & we are located at an address less */
 	/* than 0x100, so only need to grab low order offset.    */
 	std     r24,__secondary_hold_acknowledge@l(0)
+	sync
 
 	/* All secondary cpu's wait here until told to start. */
 100:    ld      r4,__secondary_hold_spinloop@l(0)
@@ -163,6 +170,7 @@ _GLOBAL(__secondary_hold)
 	BUG_OPCODE
 #endif
 #endif
+#endif
 
 /*
  * The following macros define the code that appears as
@@ -244,6 +252,14 @@ _GLOBAL(__secondary_hold)
 	std	r22,EX_SRR0(r21);	    /* save SRR0 in exc. frame     */ \
 	ld      r23,LPPACA+LPPACASRR1(r20); /* Get SRR1 from ItLpPaca      */ \
 	std	r23,EX_SRR1(r21);	    /* save SRR1 in exc. frame     */ \
+                                                                         \
+	mfspr   r23,DAR;                /* Save DAR in exc. frame      */ \
+	std	r23,EX_DAR(r21);	                                  \
+	mfspr	r23,DSISR;		/* Save DSISR in exc. frame    */ \
+	stw	r23,EX_DSISR(r21);	                                  \
+	mfspr	r23,SPRG2;		/* Save r20 in exc. frame      */ \
+	std	r23,EX_R20(r21);	                                  \
+                                                                         \
 	mfcr    r23;                        /* save CR in r23              */
 
 /*
@@ -375,9 +391,34 @@ __start_interrupts:
 	STD_EXCEPTION_PSERIES( 0xc00, SystemCall )
 	STD_EXCEPTION_PSERIES( 0xd00, SingleStep )
 	STD_EXCEPTION_PSERIES( 0xe00, Trap_0e )
-	STD_EXCEPTION_PSERIES( 0xf00, PerformanceMonitor )
+
+	/* We need to deal with the Altivec unavailable exception
+	 * here which is at 0xf20, thus in the middle of the
+	 * prolog code of the PerformanceMonitor one. A little
+	 * trickery is thus necessary
+	 */
+	. = 0xf00
+	b	.PerformanceMonitor_Pseries
+	. = 0xf20
+	b	.AltivecUnavailable_Pseries
+
 	STD_EXCEPTION_PSERIES( 0x1300, InstructionBreakpoint )
+	STD_EXCEPTION_PSERIES( 0x1700, AltivecAssist )
 
+	/* Here are the "moved" performance monitor and
+	 * altivec unavailable exceptions
+	 */
+	. = 0x3000
+	.globl PerformanceMonitor_Pseries;
+.PerformanceMonitor_Pseries:
+	EXCEPTION_PROLOG_PSERIES(0xf00, PerformanceMonitor_common)
+	
+	. = 0x3100
+	.globl AltivecUnavailable_Pseries;
+.AltivecUnavailable_Pseries:
+	EXCEPTION_PROLOG_PSERIES(0xf20, AltivecUnavailable_common)
+	
+		
 	/* Space for the naca.  Architected to be located at real address
 	 * NACA_PHYS_ADDR.  Various tools rely on this location being fixed.
 	 * The first dword of the naca is required by iSeries LPAR to
@@ -564,7 +605,11 @@ __end_stab:
 	STD_EXCEPTION_COMMON( 0xe00, Trap_0e, .UnknownException )
 	STD_EXCEPTION_COMMON( 0xf00, PerformanceMonitor, .PerformanceMonitorException )
 	STD_EXCEPTION_COMMON(0x1300, InstructionBreakpoint, .InstructionBreakpointException )
-
+#ifdef CONFIG_ALTIVEC
+	STD_EXCEPTION_COMMON(0x1700, AltivecAssist, .AltivecAssistException )
+#else
+	STD_EXCEPTION_COMMON(0x1700, AltivecAssist, .UnknownException )
+#endif
 /*
  * Return from an exception which is handled without calling
  * save_remaining_regs.  The caller is assumed to have done
@@ -739,6 +784,23 @@ FPUnavailable_common:
 	bl      .KernelFPUnavailableException
 	BUG_OPCODE
 
+	.globl AltivecUnavailable_common
+AltivecUnavailable_common:
+	EXCEPTION_PROLOG_COMMON
+#ifdef CONFIG_ALTIVEC
+	bne	.load_up_altivec		/* if from user, just load it up */
+#endif
+	addi	r3,r1,STACK_FRAME_OVERHEAD
+	DO_COPY_EE()
+	li	r6,0xf20
+	bl      .save_remaining_regs
+#ifdef CONFIG_ALTIVEC
+	bl	.KernelAltivecUnavailableException
+#else
+	bl      .UnknownException
+#endif
+	BUG_OPCODE
+		
 	.globl SystemCall_common
 SystemCall_common:
 	EXCEPTION_PROLOG_COMMON
@@ -1113,7 +1175,6 @@ _GLOBAL(save_remaining_regs)
 	SET_REG_TO_CONST(r22, MSR_KERNEL)
 
 #ifdef DO_SOFT_DISABLE
-#warning FIX ISERIES
 	stb	r20,PACAPROCENABLED(r13) /* possibly soft enable */
 	ori	r22,r22,MSR_EE		/* always hard enable */
 #else
@@ -1187,7 +1248,21 @@ _GLOBAL(pseries_secondary_smp_init)
 	b 	1b			 /* Loop until told to go         */
 #ifdef CONFIG_PPC_ISERIES
 _GLOBAL(__start_initialization_iSeries)
+	/* Clear out the BSS */
+	LOADADDR(r11,__bss_stop)
+
+	LOADADDR(r8,__bss_start)
 
+	sub	r11,r11,r8        /* bss size                        */
+	addi	r11,r11,7         /* round up to an even double word */
+	rldicl. r11,r11,61,3      /* shift right by 3                */
+	beq	4f
+	addi	r8,r8,-8
+	li	r0,0
+	mtctr	r11		  /* zero this many doublewords      */
+3:	stdu	r0,8(r8)
+	bdnz	3b
+4:
 	LOADADDR(r1,init_thread_union)
 	addi	r1,r1,THREAD_SIZE
 	li	r0,0
@@ -1216,9 +1291,12 @@ _GLOBAL(__start_initialization_iSeries)
 
 	bl      .iSeries_fixup_klimit
 
+	/* relocation is on at this point */
+
 	b	.start_here_common
 #endif
 
+#ifdef CONFIG_PPC_PSERIES
 _GLOBAL(__start_initialization_pSeries)
 	mr	r31,r3			/* save parameters */
 	mr	r30,r4
@@ -1238,20 +1316,6 @@ _GLOBAL(__start_initialization_pSeries)
 	/* Relocate the TOC from a virt addr to a real addr */
 	sub	r2,r2,r3
 
-	/* setup the systemcfg pointer which is needed by prom_init       */
-	LOADADDR(r9,systemcfg)
-	sub	r9,r9,r3                /* addr of the variable systemcfg */
-	SET_REG_TO_CONST(r4, SYSTEMCFG_VIRT_ADDR)
-	sub	r4,r4,r3
-	std	r4,0(r9)		/* set the value of systemcfg     */
-
-	/* setup the naca pointer which is needed by prom_init            */
-	LOADADDR(r9,naca)
-	sub	r9,r9,r3                /* addr of the variable naca      */
-	SET_REG_TO_CONST(r4, NACA_VIRT_ADDR)
-	sub	r4,r4,r3
-	std	r4,0(r9)		/* set the value of naca          */
-
 	/* DRENG / PPPBBB Fix the following comment!!! -Peter */
 	/* The following copies the first 0x100 bytes of code from the    */
 	/* load addr to physical addr 0x0.  This code causes secondary    */
@@ -1328,6 +1392,7 @@ _STATIC(__after_prom_start)
 	sub	r5,r5,r27
 	bl	.copy_and_flush		/* copy the rest */
 	b	.start_here_pSeries
+#endif
 
 /*
  * Copy routine used to copy the kernel to start at physical address 0
@@ -1466,6 +1531,126 @@ _GLOBAL(giveup_fpu)
 #endif /* CONFIG_SMP */
 	blr
 
+
+#ifdef CONFIG_ALTIVEC
+		
+/*
+ * load_up_altivec(unused, unused, tsk)
+ * Disable VMX for the task which had it previously,
+ * and save its vector registers in its thread_struct.
+ * Enables the VMX for use in the kernel on return.
+ * On SMP we know the VMX is free, since we give it up every
+ * switch (ie, no lazy save of the vector registers).
+ * On entry: r13 == 'current' && last_task_used_altivec != 'current'
+ */
+_STATIC(load_up_altivec)
+	mfmsr	r5                      /* grab the current MSR */
+	oris	r5,r5,MSR_VEC@h
+	mtmsrd  r5			/* enable use of VMX now */
+	isync
+	
+/*
+ * For SMP, we don't do lazy VMX switching because it just gets too
+ * horrendously complex, especially when a task switches from one CPU
+ * to another.  Instead we call giveup_altvec in switch_to.
+ * VRSAVE isn't dealt with here, that is done in the normal context
+ * switch code. Note that we could rely on vrsave value to eventually
+ * avoid saving all of the VREGs here...
+ */
+#ifndef CONFIG_SMP
+	LOADBASE(r3,last_task_used_altivec)
+	ld	r4,last_task_used_altivec@l(r3)
+	cmpi	0,r4,0
+	beq	1f
+	/* Save VMX state to last_task_used_altivec's THREAD struct */
+	addi	r4,r4,THREAD
+	SAVE_32VRS(0,r5,r4)
+	mfvscr	vr0
+	li	r10,THREAD_VSCR
+	stvx	vr0,r10,r4
+	/* Disable VMX for last_task_used_altivec */
+	ld	r5,PT_REGS(r4)
+	ld	r4,_MSR-STACK_FRAME_OVERHEAD(r5)
+	lis	r20,MSR_VEC@h
+	andc	r4,r4,r20
+	std	r4,_MSR-STACK_FRAME_OVERHEAD(r5)
+1:
+#endif /* CONFIG_SMP */
+	/* Hack: if we get an altivec unavailable trap with VRSAVE
+	 * set to all zeros, we assume this is a broken application
+	 * that fails to set it properly, and thus we switch it to
+	 * all 1's
+	 */
+	mfspr	r4,SPRN_VRSAVE
+	cmpi	0,r4,0
+	bne+	1f
+	li	r4,-1
+	mtspr	SPRN_VRSAVE,r4
+1:
+	/* enable use of VMX after return */
+	ld	r4,PACACURRENT(r13)
+	addi	r5,r4,THREAD		/* Get THREAD */
+	oris	r23,r23,MSR_VEC@h
+	li	r4,1
+	li	r10,THREAD_VSCR
+	stw	r4,THREAD_USED_VR(r5)
+	lvx	vr0,r10,r5
+	REST_32VRS(0,r4,r5)
+#ifndef CONFIG_SMP
+	/* Update last_task_used_math to 'current' */
+	subi	r4,r5,THREAD		/* Back to 'current' */
+	std	r4,last_task_used_altivec@l(r3)
+#endif /* CONFIG_SMP */
+	/* restore registers and return */
+	b	fast_exception_return
+
+/*
+ * disable_kernel_altivec()
+ * Disable the VMX.
+ */
+_GLOBAL(disable_kernel_altivec)
+	mfmsr   r3
+	rldicl  r0,r3,(63-MSR_VEC_LG),1
+	rldicl  r3,r0,(MSR_VEC_LG+1),0
+	mtmsrd  r3			/* disable use of VMX now */
+	isync
+	blr
+
+/*
+ * giveup_altivec(tsk)
+ * Disable VMX for the task given as the argument,
+ * and save the vector registers in its thread_struct.
+ * Enables the VMX for use in the kernel on return.
+ */
+_GLOBAL(giveup_altivec)
+	mfmsr	r5
+	oris	r5,r5,MSR_VEC@h
+	mtmsrd	r5			/* enable use of VMX now */
+	isync
+	cmpi	0,r3,0
+	beqlr-				/* if no previous owner, done */
+	addi	r3,r3,THREAD		/* want THREAD of task */
+	ld	r5,PT_REGS(r3)
+	cmpi	0,r5,0
+	SAVE_32VRS(0,r4,r3)
+	mfvscr	vr0
+	li	r4,THREAD_VSCR
+	stvx	vr0,r4,r3
+	beq	1f
+	ld	r4,_MSR-STACK_FRAME_OVERHEAD(r5)
+	lis	r3,MSR_VEC@h
+	andc	r4,r4,r3		/* disable FP for previous task */
+	std	r4,_MSR-STACK_FRAME_OVERHEAD(r5)
+1:
+#ifndef CONFIG_SMP
+	li	r5,0
+	LOADBASE(r4,last_task_used_altivec)
+	std	r5,last_task_used_altivec@l(r4)
+#endif /* CONFIG_SMP */
+	blr
+
+#endif /* CONFIG_ALTIVEC */
+
 #ifdef CONFIG_SMP
 /*
  * This function is called after the master CPU has released the
@@ -1594,6 +1779,7 @@ _GLOBAL(enable_32b_mode)
 	isync
 	blr
 
+#ifdef CONFIG_PPC_PSERIES
 /*
  * This is where the main kernel code starts.
  */
@@ -1729,27 +1915,11 @@ _STATIC(start_here_pSeries)
 	mtspr	SRR0,r3
 	mtspr	SRR1,r4
 	rfid
+#endif	/* CONFIG_PPC_PSERIES */
 
 	/* This is where all platforms converge execution */
 _STATIC(start_here_common)
-	/* relocation is on at this point */
-
-	/* Clear out the BSS */
-	LOADADDR(r11,_end)
-
-	LOADADDR(r8,__bss_start)
-
-	sub	r11,r11,r8        /* bss size                        */
-	addi	r11,r11,7         /* round up to an even double word */
-	rldicl. r11,r11,61,3      /* shift right by 3                */
-	beq	4f
-	addi	r8,r8,-8
-	li	r0,0
-	mtctr	r11		  /* zero this many doublewords      */
-3:	stdu	r0,8(r8)
-	bdnz	3b
-4:
-
+	
 	/* The following code sets up the SP and TOC now that we are */
 	/* running with translation enabled. */
 
@@ -1765,6 +1935,12 @@ _STATIC(start_here_common)
 	addi    r2,r2,0x4000
 	addi    r2,r2,0x4000
 
+	/* Apply the CPUs-specific fixups (nop out sections not relevant
+	 * to this CPU
+	 */
+	li	r3,0
+	bl	.do_cpu_ftr_fixups
+
 	/* setup the systemcfg pointer */
 	LOADADDR(r9,systemcfg)
 	SET_REG_TO_CONST(r8, SYSTEMCFG_VIRT_ADDR)
@@ -1803,10 +1979,8 @@ _STATIC(start_here_common)
 	/* Load up the kernel context */
 5:
 #ifdef DO_SOFT_DISABLE
-#warning FIX ISERIES
-	mfspr	r4,SPRG3
 	li	r5,0
-	stb	r5,PACAPROCENABLED(r4)	/* Soft Disabled */
+	stb	r5,PACAPROCENABLED(r13)	/* Soft Disabled */
 	mfmsr	r5
 	ori	r5,r5,MSR_EE		/* Hard Enabled */
 	mtmsrd	r5
diff -puN -L arch/ppc64/kernel/htab.c arch/ppc64/kernel/htab.c~linus /dev/null
--- 25/arch/ppc64/kernel/htab.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,491 +0,0 @@
-/*
- * PowerPC64 port by Mike Corrigan and Dave Engebretsen
- *   {mikejc|engebret}@us.ibm.com
- *
- *    Copyright (c) 2000 Mike Corrigan <mikejc@us.ibm.com>
- *
- * SMP scalability work:
- *    Copyright (C) 2001 Anton Blanchard <anton@au.ibm.com>, IBM
- * 
- *    Module name: htab.c
- *
- *    Description:
- *      PowerPC Hashed Page Table functions
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the 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/spinlock.h>
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/proc_fs.h>
-#include <linux/stat.h>
-#include <linux/sysctl.h>
-#include <linux/ctype.h>
-#include <linux/cache.h>
-
-#include <asm/ppcdebug.h>
-#include <asm/processor.h>
-#include <asm/pgtable.h>
-#include <asm/mmu.h>
-#include <asm/mmu_context.h>
-#include <asm/page.h>
-#include <asm/types.h>
-#include <asm/system.h>
-#include <asm/uaccess.h>
-#include <asm/naca.h>
-#include <asm/pmc.h>
-#include <asm/machdep.h>
-#include <asm/lmb.h>
-#include <asm/abs_addr.h>
-#include <asm/tlbflush.h>
-#include <asm/io.h>
-#include <asm/eeh.h>
-#include <asm/tlb.h>
-#include <asm/cacheflush.h>
-#include <asm/cputable.h>
-
-/*
- * Note:  pte   --> Linux PTE
- *        HPTE  --> PowerPC Hashed Page Table Entry
- *
- * Execution context:
- *   htab_initialize is called with the MMU off (of course), but
- *   the kernel has been copied down to zero so it can directly
- *   reference global data.  At this point it is very difficult
- *   to print debug info.
- *
- */
-
-HTAB htab_data = {NULL, 0, 0, 0, 0};
-
-extern unsigned long _SDR1;
-
-#define KB (1024)
-#define MB (1024*KB)
-
-static inline void
-loop_forever(void)
-{
-	volatile unsigned long x = 1;
-	for(;x;x|=1)
-		;
-}
-
-static inline void
-create_pte_mapping(unsigned long start, unsigned long end,
-		   unsigned long mode, int large)
-{
-	unsigned long addr;
-	unsigned int step;
-
-	if (large)
-		step = 16*MB;
-	else
-		step = 4*KB;
-
-	for (addr = start; addr < end; addr += step) {
-		unsigned long vpn, hash, hpteg;
-		unsigned long vsid = get_kernel_vsid(addr);
-		unsigned long va = (vsid << 28) | (addr & 0xfffffff);
-		int ret;
-
-		if (large)
-			vpn = va >> LARGE_PAGE_SHIFT;
-		else
-			vpn = va >> PAGE_SHIFT;
-
-		hash = hpt_hash(vpn, large);
-
-		hpteg = ((hash & htab_data.htab_hash_mask)*HPTES_PER_GROUP);
-
-		if (systemcfg->platform == PLATFORM_PSERIES_LPAR)
-			ret = pSeries_lpar_hpte_insert(hpteg, va,
-				(unsigned long)__v2a(addr) >> PAGE_SHIFT,
-				0, mode, 1, large);
-		else
-			ret = pSeries_hpte_insert(hpteg, va,
-				(unsigned long)__v2a(addr) >> PAGE_SHIFT,
-				0, mode, 1, large);
-
-		if (ret == -1) {
-			ppc64_terminate_msg(0x20, "create_pte_mapping");
-			loop_forever();
-		}
-	}
-}
-
-void
-htab_initialize(void)
-{
-	unsigned long table, htab_size_bytes;
-	unsigned long pteg_count;
-	unsigned long mode_rw;
-
-	/*
-	 * Calculate the required size of the htab.  We want the number of
-	 * PTEGs to equal one half the number of real pages.
-	 */ 
-	htab_size_bytes = 1UL << naca->pftSize;
-	pteg_count = htab_size_bytes >> 7;
-
-	/* For debug, make the HTAB 1/8 as big as it normally would be. */
-	ifppcdebug(PPCDBG_HTABSIZE) {
-		pteg_count >>= 3;
-		htab_size_bytes = pteg_count << 7;
-	}
-
-	htab_data.htab_num_ptegs = pteg_count;
-	htab_data.htab_hash_mask = pteg_count - 1;
-
-	if (systemcfg->platform == PLATFORM_PSERIES) {
-		/* Find storage for the HPT.  Must be contiguous in
-		 * the absolute address space.
-		 */
-		table = lmb_alloc(htab_size_bytes, htab_size_bytes);
-		if ( !table ) {
-			ppc64_terminate_msg(0x20, "hpt space");
-			loop_forever();
-		}
-		htab_data.htab = (HPTE *)__a2v(table);
-
-		/* htab absolute addr + encoded htabsize */
-		_SDR1 = table + __ilog2(pteg_count) - 11;
-
-		/* Initialize the HPT with no entries */
-		memset((void *)table, 0, htab_size_bytes);
-	} else {
-		/* Using a hypervisor which owns the htab */
-		htab_data.htab = NULL;
-		_SDR1 = 0; 
-	}
-
-	mode_rw = _PAGE_ACCESSED | _PAGE_COHERENT | PP_RWXX;
-
-	/* XXX we currently map kernel text rw, should fix this */
-	if ((cur_cpu_spec->cpu_features & CPU_FTR_16M_PAGE)
-	    && systemcfg->physicalMemorySize > 256*MB) {
-		create_pte_mapping((unsigned long)KERNELBASE, 
-				   KERNELBASE + 256*MB, mode_rw, 0);
-		create_pte_mapping((unsigned long)KERNELBASE + 256*MB, 
-				   KERNELBASE + (systemcfg->physicalMemorySize), 
-				   mode_rw, 1);
-	} else {
-		create_pte_mapping((unsigned long)KERNELBASE, 
-				   KERNELBASE+(systemcfg->physicalMemorySize), 
-				   mode_rw, 0);
-	}
-}
-#undef KB
-#undef MB
-
-/*
- * find_linux_pte returns the address of a linux pte for a given 
- * effective address and directory.  If not found, it returns zero.
- */
-pte_t *find_linux_pte(pgd_t *pgdir, unsigned long ea)
-{
-	pgd_t *pg;
-	pmd_t *pm;
-	pte_t *pt = NULL;
-	pte_t pte;
-
-	pg = pgdir + pgd_index(ea);
-	if (!pgd_none(*pg)) {
-
-		pm = pmd_offset(pg, ea);
-		if (pmd_present(*pm)) { 
-			pt = pte_offset_kernel(pm, ea);
-			pte = *pt;
-			if (!pte_present(pte))
-				pt = NULL;
-		}
-	}
-
-	return pt;
-}
-
-static inline unsigned long computeHptePP(unsigned long pte)
-{
-	return (pte & _PAGE_USER) |
-		(((pte & _PAGE_USER) >> 1) &
-		 ((~((pte >> 2) &	/* _PAGE_RW */
-		     (pte >> 7))) &	/* _PAGE_DIRTY */
-		  1));
-}
-
-/*
- * Handle a fault by adding an HPTE. If the address can't be determined
- * to be valid via Linux page tables, return 1. If handled return 0
- */
-int __hash_page(unsigned long ea, unsigned long access, unsigned long vsid,
-		pte_t *ptep, unsigned long trap, int local)
-{
-	unsigned long va, vpn;
-	unsigned long newpp, prpn;
-	unsigned long hpteflags;
-	long slot;
-	pte_t old_pte, new_pte;
-
-	/* XXX fix for large ptes */
-	int large = 0;
-
-	/* Search the Linux page table for a match with va */
-	va = (vsid << 28) | (ea & 0x0fffffff);
-
-	if (large)
-		vpn = va >> LARGE_PAGE_SHIFT;
-	else
-		vpn = va >> PAGE_SHIFT;
-
-	/*
-	 * If no pte found or not present, send the problem up to
-	 * do_page_fault
-	 */
-	if (unlikely(!ptep || !pte_present(*ptep)))
-		return 1;
-
-	/* 
-	 * Check the user's access rights to the page.  If access should be
-	 * prevented then send the problem up to do_page_fault.
-	 */
-	access |= _PAGE_PRESENT;
-	if (unlikely(access & ~(pte_val(*ptep))))
-		return 1;
-
-	/*
-	 * At this point, we have a pte (old_pte) which can be used to build
-	 * or update an HPTE. There are 2 cases:
-	 *
-	 * 1. There is a valid (present) pte with no associated HPTE (this is 
-	 *	the most common case)
-	 * 2. There is a valid (present) pte with an associated HPTE. The
-	 *	current values of the pp bits in the HPTE prevent access
-	 *	because we are doing software DIRTY bit management and the
-	 *	page is currently not DIRTY. 
-	 */
-
-	old_pte = *ptep;
-	new_pte = old_pte;
-	/* If the attempted access was a store */
-	if (access & _PAGE_RW)
-		pte_val(new_pte) |= _PAGE_ACCESSED | _PAGE_DIRTY;
-	else
-		pte_val(new_pte) |= _PAGE_ACCESSED;
-
-	newpp = computeHptePP(pte_val(new_pte));
-
-#define PPC64_HWNOEXEC (1 << 2)
-
-	/* We do lazy icache flushing on cpus that support it */
-	if (unlikely((cur_cpu_spec->cpu_features & CPU_FTR_NOEXECUTE)
-		     && pfn_valid(pte_pfn(new_pte)))) {
-		struct page *page = pte_page(new_pte);
-
-		/* page is dirty */
-		if (!PageReserved(page) &&
-		    !test_bit(PG_arch_1, &page->flags)) {
-			if (trap == 0x400) {
-				__flush_dcache_icache(page_address(page));
-				set_bit(PG_arch_1, &page->flags);
-			} else {
-				newpp |= PPC64_HWNOEXEC;
-			}
-		}
-	}
-
-	/* Check if pte already has an hpte (case 2) */
-	if (unlikely(pte_val(old_pte) & _PAGE_HASHPTE)) {
-		/* There MIGHT be an HPTE for this pte */
-		unsigned long hash, slot, secondary;
-
-		hash = hpt_hash(vpn, large);
-		secondary = (pte_val(old_pte) & _PAGE_SECONDARY) >> 15;
-		if (secondary)
-			hash = ~hash;
-		slot = (hash & htab_data.htab_hash_mask) * HPTES_PER_GROUP;
-		slot += (pte_val(old_pte) & _PAGE_GROUP_IX) >> 12;
-
-		if (ppc_md.hpte_updatepp(slot, newpp, va, large, local) == -1)
-			pte_val(old_pte) &= ~_PAGE_HPTEFLAGS;
-		else
-			if (!pte_same(old_pte, new_pte))
-				*ptep = new_pte;
-	}
-
-	if (likely(!(pte_val(old_pte) & _PAGE_HASHPTE))) {
-		unsigned long hash = hpt_hash(vpn, large);
-		unsigned long hpte_group;
-		prpn = pte_val(old_pte) >> PTE_SHIFT;
-
-repeat:
-		hpte_group = ((hash & htab_data.htab_hash_mask) *
-			      HPTES_PER_GROUP) & ~0x7UL;
-
-		/* Update the linux pte with the HPTE slot */
-		pte_val(new_pte) &= ~_PAGE_HPTEFLAGS;
-		pte_val(new_pte) |= _PAGE_HASHPTE;
-
-		/* copy appropriate flags from linux pte */
-		hpteflags = (pte_val(new_pte) & 0x1f8) | newpp;
-
-		slot = ppc_md.hpte_insert(hpte_group, va, prpn, 0,
-					  hpteflags, 0, large);
-
-		/* Primary is full, try the secondary */
-		if (unlikely(slot == -1)) {
-			pte_val(new_pte) |= 1 << 15;
-			hpte_group = ((~hash & htab_data.htab_hash_mask) *
-				      HPTES_PER_GROUP) & ~0x7UL; 
-			slot = ppc_md.hpte_insert(hpte_group, va, prpn,
-						  1, hpteflags, 0, large);
-			if (slot == -1) {
-				if (mftb() & 0x1)
-					hpte_group = ((hash & htab_data.htab_hash_mask) * HPTES_PER_GROUP) & ~0x7UL;
-
-				ppc_md.hpte_remove(hpte_group);
-				goto repeat;
-                        }
-		}
-
-		if (unlikely(slot == -2))
-			panic("hash_page: pte_insert failed\n");
-
-		pte_val(new_pte) |= (slot<<12) & _PAGE_GROUP_IX;
-
-		/* 
-		 * No need to use ldarx/stdcx here because all who
-		 * might be updating the pte will hold the
-		 * page_table_lock or the hash_table_lock
-		 * (we hold both)
-		 */
-		*ptep = new_pte;
-	}
-
-	return 0;
-}
-
-int hash_page(unsigned long ea, unsigned long access, unsigned long trap)
-{
-	void *pgdir;
-	unsigned long vsid;
-	struct mm_struct *mm;
-	pte_t *ptep;
-	int ret;
-	int user_region = 0;
-	int local = 0;
-	cpumask_t tmp;
-
-	/* Check for invalid addresses. */
-	if (!IS_VALID_EA(ea))
-		return 1;
-
- 	switch (REGION_ID(ea)) {
-	case USER_REGION_ID:
-		user_region = 1;
-		mm = current->mm;
-		if (mm == NULL)
-			return 1;
-
-		vsid = get_vsid(mm->context, ea);
-		break;
-	case IO_REGION_ID:
-		mm = &ioremap_mm;
-		vsid = get_kernel_vsid(ea);
-		break;
-	case VMALLOC_REGION_ID:
-		mm = &init_mm;
-		vsid = get_kernel_vsid(ea);
-		break;
-#if 0
-	case EEH_REGION_ID:
-		/*
-		 * Should only be hit if there is an access to MMIO space
-		 * which is protected by EEH.
-		 * Send the problem up to do_page_fault 
-		 */
-	case KERNEL_REGION_ID:
-		/*
-		 * Should never get here - entire 0xC0... region is bolted.
-		 * Send the problem up to do_page_fault 
-		 */
-#endif
-	default:
-		/* Not a valid range
-		 * Send the problem up to do_page_fault 
-		 */
-		return 1;
-		break;
-	}
-
-	pgdir = mm->pgd;
-
-	if (pgdir == NULL)
-		return 1;
-
-	/*
-	 * Lock the Linux page table to prevent mmap and kswapd
-	 * from modifying entries while we search and update
-	 */
-	spin_lock(&mm->page_table_lock);
-
-	tmp = cpumask_of_cpu(smp_processor_id());
-	if (user_region && cpus_equal(mm->cpu_vm_mask, tmp))
-		local = 1;
-
-	ret = hash_huge_page(mm, access, ea, vsid, local);
-	if (ret < 0) {
-		ptep = find_linux_pte(pgdir, ea);
-		ret = __hash_page(ea, access, vsid, ptep, trap, local);
-	}
-
-	spin_unlock(&mm->page_table_lock);
-
-	return ret;
-}
-
-void flush_hash_page(unsigned long context, unsigned long ea, pte_t pte,
-		     int local)
-{
-	unsigned long vsid, vpn, va, hash, secondary, slot;
-
-	/* XXX fix for large ptes */
-	unsigned long large = 0;
-
-	if ((ea >= USER_START) && (ea <= USER_END))
-		vsid = get_vsid(context, ea);
-	else
-		vsid = get_kernel_vsid(ea);
-
-	va = (vsid << 28) | (ea & 0x0fffffff);
-	if (large)
-		vpn = va >> LARGE_PAGE_SHIFT;
-	else
-		vpn = va >> PAGE_SHIFT;
-	hash = hpt_hash(vpn, large);
-	secondary = (pte_val(pte) & _PAGE_SECONDARY) >> 15;
-	if (secondary)
-		hash = ~hash;
-	slot = (hash & htab_data.htab_hash_mask) * HPTES_PER_GROUP;
-	slot += (pte_val(pte) & _PAGE_GROUP_IX) >> 12;
-
-	ppc_md.hpte_invalidate(slot, va, large, local);
-}
-
-void flush_hash_range(unsigned long context, unsigned long number, int local)
-{
-	if (ppc_md.flush_hash_range) {
-		ppc_md.flush_hash_range(context, number, local);
-	} else {
-		int i;
-		struct ppc64_tlb_batch *batch =
-			&ppc64_tlb_batch[smp_processor_id()];
-
-		for (i = 0; i < number; i++)
-			flush_hash_page(context, batch->addr[i], batch->pte[i],
-					local);
-	}
-}
diff -puN arch/ppc64/kernel/HvCall.c~linus arch/ppc64/kernel/HvCall.c
--- 25/arch/ppc64/kernel/HvCall.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/HvCall.c	2004-01-19 22:17:21.000000000 -0800
@@ -8,108 +8,29 @@
  * (at your option) any later version.
  */
 
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <asm/system.h>
 #include <asm/page.h>
+#include <asm/abs_addr.h>
 #include <asm/iSeries/HvCall.h>
-#ifndef  _HVCALLSC_H
 #include <asm/iSeries/HvCallSc.h>
-#endif
-#include <asm/iSeries/LparData.h>
-
-#ifndef  _HVTYPES_H
 #include <asm/iSeries/HvTypes.h>
-#endif
 
 
-/*=====================================================================
- * Note that this call takes at MOST one page worth of data
- */
-int HvCall_readLogBuffer(HvLpIndex lpIndex, void *buffer, u64 bufLen)
+void HvCall_writeLogBuffer(const void *buffer, u64 len)
 {
-	struct HvLpBufferList *bufList;
-	u64 bytesLeft = bufLen;
-	u64 leftThisPage;
-	u64 curPtr = virt_to_absolute( (unsigned long) buffer );
-	u64 retVal;
-	int npages;
-	int i;
-
-	npages = 0;
-	while (bytesLeft) {
-		npages++;
-		leftThisPage = ((curPtr & PAGE_MASK) + PAGE_SIZE) - curPtr;
-
-		if (leftThisPage > bytesLeft)
-			bytesLeft = 0;
-		else
-			bytesLeft -= leftThisPage;
-
-		curPtr = (curPtr & PAGE_MASK) + PAGE_SIZE;
+	struct HvLpBufferList hv_buf;
+	u64 left_this_page;
+	u64 cur = virt_to_absolute((unsigned long)buffer);
+
+	while (len) {
+		hv_buf.addr = cur;
+		left_this_page = ((cur & PAGE_MASK) + PAGE_SIZE) - cur;
+		if (left_this_page > len)
+			left_this_page = len;
+		hv_buf.len = left_this_page;
+		len -= left_this_page;
+		HvCall2(HvCallBaseWriteLogBuffer,
+				virt_to_absolute((unsigned long)&hv_buf),
+				left_this_page);
+		cur = (cur & PAGE_MASK) + PAGE_SIZE;
 	}
-
-	if (npages == 0)
-		return 0;
-
-	bufList = (struct HvLpBufferList *)
-		kmalloc(npages * sizeof(struct HvLpBufferList), GFP_ATOMIC);
-	bytesLeft = bufLen;
-	curPtr = virt_to_absolute( (unsigned long) buffer );
-	for(i=0; i<npages; i++) {
-		bufList[i].addr = curPtr;
-      
-		leftThisPage = ((curPtr & PAGE_MASK) + PAGE_SIZE) - curPtr;
-
-		if (leftThisPage > bytesLeft) {
-			bufList[i].len = bytesLeft;
-			bytesLeft = 0;
-		} else {
-			bufList[i].len = leftThisPage;
-			bytesLeft -= leftThisPage;
-		}
-
-		curPtr = (curPtr & PAGE_MASK) + PAGE_SIZE;
-	}
-
-
-	retVal = HvCall3(HvCallBaseReadLogBuffer, lpIndex,
-			 virt_to_absolute((unsigned long)bufList), bufLen);
-
-	kfree(bufList);
-
-	return (int)retVal;
-}
-
-/*=====================================================================
- */
-void HvCall_writeLogBuffer(const void *buffer, u64 bufLen)
-{
-	struct HvLpBufferList bufList;
-	u64 bytesLeft = bufLen;
-	u64 leftThisPage;
-	u64 curPtr = virt_to_absolute( (unsigned long) buffer );
-
-	while (bytesLeft) {
-		bufList.addr = curPtr;
-      
-		leftThisPage = ((curPtr & PAGE_MASK) + PAGE_SIZE) - curPtr;
-
-		if (leftThisPage > bytesLeft) {
-			bufList.len = bytesLeft;
-			bytesLeft = 0;
-		} else {
-			bufList.len = leftThisPage;
-			bytesLeft -= leftThisPage;
-		}
-
-		curPtr = (curPtr & PAGE_MASK) + PAGE_SIZE;
-	}
-
-
-	HvCall2(HvCallBaseWriteLogBuffer,
-		virt_to_absolute((unsigned long)&bufList), bufLen);
-
 }
diff -puN arch/ppc64/kernel/idle.c~linus arch/ppc64/kernel/idle.c
--- 25/arch/ppc64/kernel/idle.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/idle.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,13 @@
 /*
- * idle.c
+ * Idle daemon for PowerPC.  Idle daemon will handle any action
+ * that needs to be taken when the system becomes idle.
+ *
+ * Originally Written by Cort Dougan (cort@cs.nmt.edu)
+ *
+ * iSeries supported added by Mike Corrigan <mikejc@us.ibm.com>
+ *
+ * Additional shared processor, SMT, and firmware support
+ *    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
@@ -26,14 +34,18 @@
 #include <asm/processor.h>
 #include <asm/mmu.h>
 #include <asm/cache.h>
+#include <asm/cputable.h>
 #include <asm/time.h>
-
-#ifdef CONFIG_PPC_ISERIES
-
 #include <asm/iSeries/LparData.h>
 #include <asm/iSeries/HvCall.h>
 #include <asm/iSeries/ItLpQueue.h>
 
+extern long cede_processor(void);
+extern long poll_pending(void);
+
+int (*idle_loop)(void);
+
+#ifdef CONFIG_PPC_ISERIES
 unsigned long maxYieldTime = 0;
 unsigned long minYieldTime = 0xffffffffffffffffUL;
 
@@ -66,24 +78,24 @@ static void yield_shared_processor(void)
 	process_iSeries_events();
 }
 
-int cpu_idle(void)
+int iSeries_idle(void)
 {
 	struct paca_struct *lpaca;
 	long oldval;
 	unsigned long CTRL;
 
-#warning fix iseries run light
-#if 0
 	/* ensure iSeries run light will be out when idle */
-	current->thread.flags &= ~PPC_FLAG_RUN_LIGHT;
+	clear_thread_flag(TIF_RUN_LIGHT);
 	CTRL = mfspr(CTRLF);
 	CTRL &= ~RUNLATCH;
 	mtspr(CTRLT, CTRL);
+#if 0
+	init_idle();	
 #endif
 
 	lpaca = get_paca();
 
-	while (1) {
+	for (;;) {
 		if (lpaca->xLpPaca.xSharedProc) {
 			if (ItLpQueue_isLpIntPending(lpaca->lpQueuePtr))
 				process_iSeries_events();
@@ -109,16 +121,13 @@ int cpu_idle(void)
 			}
 		}
 
-		if (need_resched())
-			schedule();
+		schedule();
 	}
-
 	return 0;
 }
+#endif
 
-#else /* CONFIG_PPC_ISERIES */
-
-int cpu_idle(void)
+int default_idle(void)
 {
 	long oldval;
 
@@ -145,9 +154,155 @@ int cpu_idle(void)
 	return 0;
 }
 
-#endif /* CONFIG_PPC_ISERIES */
+#ifdef CONFIG_PPC_PSERIES
+int dedicated_idle(void)
+{
+	long oldval;
+	struct paca_struct *lpaca = get_paca(), *ppaca;
+	unsigned long start_snooze;
+
+	ppaca = &paca[(lpaca->xPacaIndex) ^ 1];
+
+	while (1) {
+		/* Indicate to the HV that we are idle.  Now would be
+		 * a good time to find other work to dispatch. */
+		lpaca->xLpPaca.xIdle = 1;
+
+		oldval = test_and_clear_thread_flag(TIF_NEED_RESCHED);
+		if (!oldval) {
+			set_thread_flag(TIF_POLLING_NRFLAG);
+			start_snooze = __get_tb();
+			while (!need_resched()) {
+				/* need_resched could be 1 or 0 at this 
+				 * point.  If it is 0, set it to 0, so
+				 * an IPI/Prod is sent.  If it is 1, keep
+				 * it that way & schedule work.
+				 */
+				if (__get_tb() < 
+				    (start_snooze + 
+				     naca->smt_snooze_delay*tb_ticks_per_usec)) {  
+					HMT_low(); /* Low thread priority */
+					continue;
+				}
+
+				HMT_very_low(); /* Low power mode */
+
+				/* If the SMT mode is system controlled & the 
+				 * partner thread is doing work, switch into
+				 * ST mode.
+				 */
+				if((naca->smt_state == SMT_DYNAMIC) &&
+				   (!(ppaca->xLpPaca.xIdle))) {
+					/* Indicate we are no longer polling for
+					 * work, and then clear need_resched.  If
+					 * need_resched was 1, set it back to 1
+					 * and schedule work
+					 */
+					clear_thread_flag(TIF_POLLING_NRFLAG);
+					oldval = test_and_clear_thread_flag(TIF_NEED_RESCHED);
+					if(oldval == 1) {
+						set_need_resched();
+						break;
+					}
+
+					/* DRENG: Go HMT_medium here ? */
+					local_irq_disable(); 
+					lpaca->yielded = 1;
+
+					/* SMT dynamic mode.  Cede will result 
+					 * in this thread going dormant, if the
+					 * partner thread is still doing work.
+					 * Thread wakes up if partner goes idle,
+					 * an interrupt is presented, or a prod
+					 * occurs.  Returning from the cede
+					 * enables external interrupts.
+					 */
+					cede_processor();
+
+					lpaca->yielded = 0;
+				} else {
+					/* Give the HV an opportunity at the
+					 * processor, since we are not doing
+					 * any work.
+					 */
+					poll_pending();
+				}
+			}
+		} else {
+			set_need_resched();
+		}
+
+		HMT_medium();
+		lpaca->xLpPaca.xIdle = 0;
+		schedule();
+	}
+	return 0;
+}
+
+int shared_idle(void)
+{
+	struct paca_struct *lpaca = get_paca();
+
+	while (1) {
+		/* Indicate to the HV that we are idle.  Now would be
+		 * a good time to find other work to dispatch. */
+		lpaca->xLpPaca.xIdle = 1;
+
+		if (!need_resched()) {
+			local_irq_disable(); 
+			lpaca->yielded = 1;
+			
+			/* 
+			 * Yield the processor to the hypervisor.  We return if
+			 * an external interrupt occurs (which are driven prior
+			 * to returning here) or if a prod occurs from another 
+			 * processor.  When returning here, external interrupts 
+			 * are enabled.
+			 */
+			cede_processor();
+			
+			lpaca->yielded = 0;
+		}
+
+		HMT_medium();
+		lpaca->xLpPaca.xIdle = 0;
+		schedule();
+	}
+
+	return 0;
+}
+#endif
+
+int cpu_idle(void)
+{
+	idle_loop();
+	return 0; 
+}
 
-void default_idle(void)
+int idle_setup(void)
 {
-	barrier();
+#ifdef CONFIG_PPC_ISERIES
+	idle_loop = iSeries_idle;
+#else
+	if (systemcfg->platform & PLATFORM_PSERIES) {
+		if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) {
+			if(get_paca()->xLpPaca.xSharedProc) {
+				printk("idle = shared_idle\n");
+				idle_loop = shared_idle;
+			} else {
+				printk("idle = dedicated_idle\n");
+				idle_loop = dedicated_idle;
+			}
+		} else {
+			printk("idle = default_idle\n");
+			idle_loop = default_idle;
+		}
+	} else {
+		printk("idle_setup: unknown platform, use default_idle\n");
+		idle_loop = default_idle;
+	}
+#endif
+
+	return 1;
 }
+
diff -puN arch/ppc64/kernel/irq.c~linus arch/ppc64/kernel/irq.c
--- 25/arch/ppc64/kernel/irq.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/irq.c	2004-01-19 22:17:21.000000000 -0800
@@ -59,7 +59,6 @@
 extern void iSeries_smp_message_recv( struct pt_regs * );
 #endif
 
-volatile unsigned char *chrp_int_ack_special;
 static void register_irq_proc (unsigned int irq);
 
 irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = {
@@ -300,7 +299,7 @@ void enable_irq(unsigned int irq)
 	spin_lock_irqsave(&desc->lock, flags);
 	switch (desc->depth) {
 	case 1: {
-		unsigned int status = desc->status & ~(IRQ_DISABLED | IRQ_INPROGRESS);
+		unsigned int status = desc->status & ~IRQ_DISABLED;
 		desc->status = status;
 		if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) {
 			desc->status = status | IRQ_REPLAY;
@@ -561,17 +560,14 @@ out:
 	spin_unlock(&desc->lock);
 }
 
+#ifdef CONFIG_PPC_ISERIES
 int do_IRQ(struct pt_regs *regs)
 {
-	int irq, first = 1;
-#ifdef CONFIG_PPC_ISERIES
 	struct paca_struct *lpaca;
 	struct ItLpQueue *lpq;
-#endif
 
 	irq_enter();
 
-#ifdef CONFIG_PPC_ISERIES
 	lpaca = get_paca();
 #ifdef CONFIG_SMP
 	if (lpaca->xLpPaca.xIntDword.xFields.xIpiCnt) {
@@ -582,7 +578,26 @@ int do_IRQ(struct pt_regs *regs)
 	lpq = lpaca->lpQueuePtr;
 	if (lpq && ItLpQueue_isLpIntPending(lpq))
 		lpEvent_count += ItLpQueue_process(lpq, regs);
-#else
+
+	irq_exit();
+
+	if (lpaca->xLpPaca.xIntDword.xFields.xDecrInt) {
+		lpaca->xLpPaca.xIntDword.xFields.xDecrInt = 0;
+		/* Signal a fake decrementer interrupt */
+		timer_interrupt(regs);
+	}
+
+	return 1; /* lets ret_from_int know we can do checks */
+}
+
+#else	/* CONFIG_PPC_ISERIES */
+
+int do_IRQ(struct pt_regs *regs)
+{
+	int irq, first = 1;
+
+	irq_enter();
+
 	/*
 	 * Every arch is required to implement ppc_md.get_irq.
 	 * This function will either return an irq number or -1 to
@@ -598,20 +613,12 @@ int do_IRQ(struct pt_regs *regs)
 	if (irq != -2 && first)
 		/* That's not SMP safe ... but who cares ? */
 		ppc_spurious_interrupts++;
-#endif
 
 	irq_exit();
 
-#ifdef CONFIG_PPC_ISERIES
-	if (lpaca->xLpPaca.xIntDword.xFields.xDecrInt) {
-		lpaca->xLpPaca.xIntDword.xFields.xDecrInt = 0;
-		/* Signal a fake decrementer interrupt */
-		timer_interrupt(regs);
-	}
-#endif
-
 	return 1; /* lets ret_from_int know we can do checks */
 }
+#endif	/* CONFIG_PPC_ISERIES */
 
 unsigned long probe_irq_on (void)
 {
@@ -636,10 +643,10 @@ void __init init_IRQ(void)
 {
 	static int once = 0;
 
-	if ( once )
+	if (once)
 		return;
-	else
-		once++;
+
+	once++;
 	
 	ppc_md.init_IRQ();
 }
diff -puN /dev/null arch/ppc64/kernel/iSeries_htab.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/ppc64/kernel/iSeries_htab.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,197 @@
+/*
+ * iSeries hashtable management.
+ * 	Derived from pSeries_htab.c
+ *
+ * SMP scalability work:
+ *    Copyright (C) 2001 Anton Blanchard <anton@au.ibm.com>, IBM
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+#include <asm/machdep.h>
+#include <asm/pgtable.h>
+#include <asm/mmu.h>
+#include <asm/mmu_context.h>
+#include <asm/iSeries/HvCallHpt.h>
+#include <asm/abs_addr.h>
+
+#if 0
+#include <linux/spinlock.h>
+#include <linux/bitops.h>
+#include <linux/threads.h>
+#include <linux/smp.h>
+
+#include <asm/tlbflush.h>
+#include <asm/tlb.h>
+#include <asm/cputable.h>
+#endif
+
+static long iSeries_hpte_insert(unsigned long hpte_group, unsigned long va,
+			 unsigned long prpn, int secondary,
+			 unsigned long hpteflags, int bolted, int large)
+{
+	long slot;
+	HPTE lhpte;
+
+	/*
+	 * The hypervisor tries both primary and secondary.
+	 * If we are being called to insert in the secondary,
+	 * it means we have already tried both primary and secondary,
+	 * so we return failure immediately.
+	 */
+	if (secondary)
+		return -1;
+
+	slot = HvCallHpt_findValid(&lhpte, va >> PAGE_SHIFT);
+	if (lhpte.dw0.dw0.v)
+		panic("select_hpte_slot found entry already valid\n");
+
+	if (slot == -1)	/* No available entry found in either group */
+		return -1;
+
+	if (slot < 0) {		/* MSB set means secondary group */
+		secondary = 1;
+		slot &= 0x7fffffffffffffff;
+	}
+
+	lhpte.dw1.dword1      = 0;
+	lhpte.dw1.dw1.rpn     = physRpn_to_absRpn(prpn);
+	lhpte.dw1.flags.flags = hpteflags;
+
+	lhpte.dw0.dword0      = 0;
+	lhpte.dw0.dw0.avpn    = va >> 23;
+	lhpte.dw0.dw0.h       = secondary;
+	lhpte.dw0.dw0.bolted  = bolted;
+	lhpte.dw0.dw0.v       = 1;
+
+	/* Now fill in the actual HPTE */
+	HvCallHpt_addValidate(slot, secondary, &lhpte);
+
+	return (secondary << 3) | (slot & 7);
+}
+
+static unsigned long iSeries_hpte_getword0(unsigned long slot)
+{
+	unsigned long dword0;
+	HPTE hpte;
+
+	HvCallHpt_get(&hpte, slot);
+	dword0 = hpte.dw0.dword0;
+
+	return dword0;
+}
+
+static long iSeries_hpte_remove(unsigned long hpte_group)
+{
+	unsigned long slot_offset;
+	int i;
+	HPTE lhpte;
+
+	/* Pick a random slot to start at */
+	slot_offset = mftb() & 0x7;
+
+	for (i = 0; i < HPTES_PER_GROUP; i++) {
+		lhpte.dw0.dword0 = 
+			iSeries_hpte_getword0(hpte_group + slot_offset);
+
+		if (!lhpte.dw0.dw0.bolted) {
+			HvCallHpt_invalidateSetSwBitsGet(hpte_group + 
+							 slot_offset, 0, 0);
+			return i;
+		}
+
+		slot_offset++;
+		slot_offset &= 0x7;
+	}
+
+	return -1;
+}
+
+static long iSeries_hpte_updatepp(unsigned long slot, unsigned long newpp,
+				  unsigned long va, int large, int local)
+{
+	HPTE hpte;
+	unsigned long avpn = va >> 23;
+
+	HvCallHpt_get(&hpte, slot);
+	if ((hpte.dw0.dw0.avpn == avpn) && (hpte.dw0.dw0.v)) {
+		HvCallHpt_setPp(slot, newpp);
+		return 0;
+	}
+	return -1;
+}
+
+/*
+ * Functions used to find the PTE for a particular virtual address. 
+ * Only used during boot when bolting pages.
+ *
+ * Input : vpn      : virtual page number
+ * Output: PTE index within the page table of the entry
+ *         -1 on failure
+ */
+static long iSeries_hpte_find(unsigned long vpn)
+{
+	HPTE hpte;
+	long slot;
+
+	/*
+	 * The HvCallHpt_findValid interface is as follows:
+	 * 0xffffffffffffffff : No entry found.
+	 * 0x00000000xxxxxxxx : Entry found in primary group, slot x
+	 * 0x80000000xxxxxxxx : Entry found in secondary group, slot x
+	 */
+	slot = HvCallHpt_findValid(&hpte, vpn); 
+	if (hpte.dw0.dw0.v) {
+		if (slot < 0) {
+			slot &= 0x7fffffffffffffff;
+			slot = -slot;
+		}
+	} else
+		slot = -1;
+	return slot;
+}
+
+/*
+ * Update the page protection bits. Intended to be used to create
+ * guard pages for kernel data structures on pages which are bolted
+ * in the HPT. Assumes pages being operated on will not be stolen.
+ * Does not work on large pages.
+ *
+ * No need to lock here because we should be the only user.
+ */
+static void iSeries_hpte_updateboltedpp(unsigned long newpp, unsigned long ea)
+{
+	unsigned long vsid,va,vpn;
+	long slot;
+
+	vsid = get_kernel_vsid(ea);
+	va = (vsid << 28) | (ea & 0x0fffffff);
+	vpn = va >> PAGE_SHIFT;
+	slot = iSeries_hpte_find(vpn); 
+	if (slot == -1)
+		panic("updateboltedpp: Could not find page to bolt\n");
+	HvCallHpt_setPp(slot, newpp);
+}
+
+static void iSeries_hpte_invalidate(unsigned long slot, unsigned long va,
+				    int large, int local)
+{
+	HPTE lhpte;
+	unsigned long avpn = va >> 23;
+
+	lhpte.dw0.dword0 = iSeries_hpte_getword0(slot);
+	
+	if ((lhpte.dw0.dw0.avpn == avpn) && lhpte.dw0.dw0.v)
+		HvCallHpt_invalidateSetSwBitsGet(slot, 0, 0);
+}
+
+void hpte_init_iSeries(void)
+{
+	ppc_md.hpte_invalidate	= iSeries_hpte_invalidate;
+	ppc_md.hpte_updatepp	= iSeries_hpte_updatepp;
+	ppc_md.hpte_updateboltedpp = iSeries_hpte_updateboltedpp;
+	ppc_md.hpte_insert	= iSeries_hpte_insert;
+	ppc_md.hpte_remove     	= iSeries_hpte_remove;
+}
diff -puN arch/ppc64/kernel/iSeries_IoMmTable.c~linus arch/ppc64/kernel/iSeries_IoMmTable.c
--- 25/arch/ppc64/kernel/iSeries_IoMmTable.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/iSeries_IoMmTable.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,3 +1,4 @@
+#define PCIFR(...)
 /************************************************************************/
 /* This module supports the iSeries I/O Address translation mapping     */
 /* Copyright (C) 20yy  <Allan H Trautman> <IBM Corp>                    */
@@ -30,134 +31,139 @@
 #include <linux/pci.h>
 #include <linux/spinlock.h>
 #include <asm/ppcdebug.h>
-#include <asm/flight_recorder.h>
 #include <asm/iSeries/HvCallPci.h>
 #include <asm/iSeries/iSeries_pci.h>
 
 #include "iSeries_IoMmTable.h"
 #include "pci.h"
 
-/*******************************************************************/
-/* Table defines                                                   */
-/* Each Entry size is 4 MB * 1024 Entries = 4GB I/O address space. */
-/*******************************************************************/
+/*
+ * Table defines
+ * Each Entry size is 4 MB * 1024 Entries = 4GB I/O address space.
+ */
 #define Max_Entries 1024
 unsigned long iSeries_IoMmTable_Entry_Size = 0x0000000000400000; 
 unsigned long iSeries_Base_Io_Memory       = 0xE000000000000000;
 unsigned long iSeries_Max_Io_Memory        = 0xE000000000000000;
 static   long iSeries_CurrentIndex         = 0;
 
-/*******************************************************************/
-/* Lookup Tables.                                                  */
-/*******************************************************************/
-struct iSeries_Device_Node** iSeries_IoMmTable;
-u8*                          iSeries_IoBarTable;
-
-/*******************************************************************/
-/* Static and Global variables                                     */
-/*******************************************************************/
-static char*      iSeriesPciIoText     = "iSeries PCI I/O";
+/*
+ * Lookup Tables.
+ */
+struct iSeries_Device_Node **iSeries_IoMmTable;
+u8 *iSeries_IoBarTable;
+
+/*
+ * Static and Global variables
+ */
+static char *iSeriesPciIoText = "iSeries PCI I/O";
 static spinlock_t iSeriesIoMmTableLock = SPIN_LOCK_UNLOCKED;
 
-/*******************************************************************/
-/* iSeries_IoMmTable_Initialize                                    */
-/*******************************************************************/
-/* Allocates and initalizes the Address Translation Table and Bar  */
-/* Tables to get them ready for use.  Must be called before any    */
-/* I/O space is handed out to the device BARs.                     */
-/* A follow up method,iSeries_IoMmTable_Status can be called to    */
-/* adjust the table after the device BARs have been assiged to     */
-/* resize the table.                                               */
-/*******************************************************************/
+/*
+ * iSeries_IoMmTable_Initialize
+ *
+ * Allocates and initalizes the Address Translation Table and Bar
+ * Tables to get them ready for use.  Must be called before any
+ * I/O space is handed out to the device BARs.
+ * A follow up method,iSeries_IoMmTable_Status can be called to
+ * adjust the table after the device BARs have been assiged to
+ * resize the table.
+ */
 void iSeries_IoMmTable_Initialize(void)
 {
 	spin_lock(&iSeriesIoMmTableLock);
-	iSeries_IoMmTable  = kmalloc(sizeof(void*)*Max_Entries,GFP_KERNEL);
-	iSeries_IoBarTable = kmalloc(sizeof(u8)*Max_Entries,   GFP_KERNEL);
+	iSeries_IoMmTable  = kmalloc(sizeof(void *) * Max_Entries, GFP_KERNEL);
+	iSeries_IoBarTable = kmalloc(sizeof(u8) * Max_Entries, GFP_KERNEL);
 	spin_unlock(&iSeriesIoMmTableLock);
-	PCIFR("IoMmTable Initialized 0x%p",  iSeries_IoMmTable);
-	if(iSeries_IoMmTable == NULL || iSeries_IoBarTable == NULL) {
+	PCIFR("IoMmTable Initialized 0x%p", iSeries_IoMmTable);
+	if ((iSeries_IoMmTable == NULL) || (iSeries_IoBarTable == NULL))
 		panic("PCI: I/O tables allocation failed.\n");
-	}
 }
 
-/*******************************************************************/
-/* iSeries_IoMmTable_AllocateEntry                                 */
-/*******************************************************************/
-/* Adds pci_dev entry in address translation table                 */
-/*******************************************************************/
-/* - Allocates the number of entries required in table base on BAR */
-/*   size.                                                         */
-/* - Allocates starting at iSeries_Base_Io_Memory and increases.   */
-/* - The size is round up to be a multiple of entry size.          */
-/* - CurrentIndex is incremented to keep track of the last entry.  */
-/* - Builds the resource entry for allocated BARs.                 */
-/*******************************************************************/
-static void iSeries_IoMmTable_AllocateEntry(struct pci_dev* PciDev, int BarNumber)
+/*
+ * iSeries_IoMmTable_AllocateEntry
+ *
+ * Adds pci_dev entry in address translation table
+ *
+ * - Allocates the number of entries required in table base on BAR
+ *   size.
+ * - Allocates starting at iSeries_Base_Io_Memory and increases.
+ * - The size is round up to be a multiple of entry size.
+ * - CurrentIndex is incremented to keep track of the last entry.
+ * - Builds the resource entry for allocated BARs.
+ */
+static void iSeries_IoMmTable_AllocateEntry(struct pci_dev *PciDev,
+		int BarNumber)
 {
-	struct resource* BarResource = &PciDev->resource[BarNumber];
-	long             BarSize     = pci_resource_len(PciDev,BarNumber);
-	/***********************************************************/
-	/* No space to allocate, quick exit, skip Allocation.      */
-	/***********************************************************/
-	if(BarSize == 0) return;
-	/***********************************************************/
-	/* Set Resource values.                                    */
-	/***********************************************************/
+	struct resource *BarResource = &PciDev->resource[BarNumber];
+	long BarSize = pci_resource_len(PciDev, BarNumber);
+
+	/*
+	 * No space to allocate, quick exit, skip Allocation.
+	 */
+	if (BarSize == 0)
+		return;
+	/*
+	 * Set Resource values.
+	 */
 	spin_lock(&iSeriesIoMmTableLock);
-	BarResource->name  = iSeriesPciIoText;
-	BarResource->start = iSeries_IoMmTable_Entry_Size*iSeries_CurrentIndex;
-	BarResource->start+= iSeries_Base_Io_Memory;
-	BarResource->end   = BarResource->start+BarSize-1;
-	/***********************************************************/
-	/* Allocate the number of table entries needed for BAR.    */
-	/***********************************************************/
+	BarResource->name = iSeriesPciIoText;
+	BarResource->start =
+		iSeries_IoMmTable_Entry_Size * iSeries_CurrentIndex;
+	BarResource->start += iSeries_Base_Io_Memory;
+	BarResource->end = BarResource->start+BarSize-1;
+	/*
+	 * Allocate the number of table entries needed for BAR.
+	 */
 	while (BarSize > 0 ) {
-		*(iSeries_IoMmTable +iSeries_CurrentIndex) = (struct iSeries_Device_Node*)PciDev->sysdata;
-		*(iSeries_IoBarTable+iSeries_CurrentIndex) = BarNumber;
+		*(iSeries_IoMmTable + iSeries_CurrentIndex) =
+			(struct iSeries_Device_Node *)PciDev->sysdata;
+		*(iSeries_IoBarTable + iSeries_CurrentIndex) = BarNumber;
 		BarSize -= iSeries_IoMmTable_Entry_Size;
 		++iSeries_CurrentIndex;
 	}
-	iSeries_Max_Io_Memory = (iSeries_IoMmTable_Entry_Size*iSeries_CurrentIndex)+iSeries_Base_Io_Memory;
+	iSeries_Max_Io_Memory = iSeries_Base_Io_Memory +
+		(iSeries_IoMmTable_Entry_Size * iSeries_CurrentIndex);
 	spin_unlock(&iSeriesIoMmTableLock);
 }
 
-/*******************************************************************/
-/* iSeries_allocateDeviceBars                                      */
-/*******************************************************************/
-/* - Allocates ALL pci_dev BAR's and updates the resources with the*/
-/*   BAR value.  BARS with zero length will have the resources     */
-/*   The HvCallPci_getBarParms is used to get the size of the BAR  */
-/*   space.  It calls iSeries_IoMmTable_AllocateEntry to allocate  */
-/*   each entry.                                                   */
-/* - Loops through The Bar resources(0 - 5) including the ROM      */
-/*   is resource(6).                                               */
-/*******************************************************************/
-void iSeries_allocateDeviceBars(struct pci_dev* PciDev)
+/*
+ * iSeries_allocateDeviceBars
+ *
+ * - Allocates ALL pci_dev BAR's and updates the resources with the
+ *   BAR value.  BARS with zero length will have the resources
+ *   The HvCallPci_getBarParms is used to get the size of the BAR
+ *   space.  It calls iSeries_IoMmTable_AllocateEntry to allocate
+ *   each entry.
+ * - Loops through The Bar resources(0 - 5) including the ROM
+ *   is resource(6).
+ */
+void iSeries_allocateDeviceBars(struct pci_dev *PciDev)
 {
-	struct resource* BarResource;
-	int              BarNumber;
-	for(BarNumber = 0; BarNumber <= PCI_ROM_RESOURCE; ++BarNumber) {
+	struct resource *BarResource;
+	int BarNumber;
+
+	for (BarNumber = 0; BarNumber <= PCI_ROM_RESOURCE; ++BarNumber) {
 		BarResource = &PciDev->resource[BarNumber];
 		iSeries_IoMmTable_AllocateEntry(PciDev, BarNumber);
     	}
 }
 
-/************************************************************************/
-/* Translates the IoAddress to the device that is mapped to IoSpace.    */
-/* This code is inlined, see the iSeries_pci.c file for the replacement.*/
-/************************************************************************/
-struct iSeries_Device_Node* iSeries_xlateIoMmAddress(void* IoAddress)
+/*
+ * Translates the IoAddress to the device that is mapped to IoSpace.
+ * This code is inlined, see the iSeries_pci.c file for the replacement.
+ */
+struct iSeries_Device_Node *iSeries_xlateIoMmAddress(void *IoAddress)
 {
 	return NULL;	   
 }
 
-/************************************************************************
+/*
  * Status hook for IoMmTable
- ************************************************************************/
-void     iSeries_IoMmTable_Status(void)
+ */
+void iSeries_IoMmTable_Status(void)
 {
-	PCIFR("IoMmTable......: 0x%p",iSeries_IoMmTable);
-	PCIFR("IoMmTable Range: 0x%p to 0x%p",iSeries_Base_Io_Memory,iSeries_Max_Io_Memory);
-	return;
+	PCIFR("IoMmTable......: 0x%p", iSeries_IoMmTable);
+	PCIFR("IoMmTable Range: 0x%p to 0x%p", iSeries_Base_Io_Memory,
+			iSeries_Max_Io_Memory);
 }
diff -puN arch/ppc64/kernel/iSeries_IoMmTable.h~linus arch/ppc64/kernel/iSeries_IoMmTable.h
--- 25/arch/ppc64/kernel/iSeries_IoMmTable.h~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/iSeries_IoMmTable.h	2004-01-19 22:17:21.000000000 -0800
@@ -31,55 +31,55 @@
 struct pci_dev;
 struct iSeries_Device_Node;
 
-extern struct iSeries_Device_Node** iSeries_IoMmTable;
-extern u8*                          iSeries_IoBarTable;
+extern struct iSeries_Device_Node **iSeries_IoMmTable;
+extern u8 *iSeries_IoBarTable;
 extern unsigned long iSeries_Base_Io_Memory;
 extern unsigned long iSeries_Max_Io_Memory;
 extern unsigned long iSeries_Base_Io_Memory;
 extern unsigned long iSeries_IoMmTable_Entry_Size;
-/************************************************************************/
-/* iSeries_IoMmTable_Initialize                                         */
-/************************************************************************/
-/* - Initalizes the Address Translation Table and get it ready for use. */
-/*   Must be called before any client calls any of the other methods.   */
-/*                                                                      */
-/* Parameters: None.                                                    */
-/*                                                                      */
-/* Return: None.                                                        */  
-/************************************************************************/
-extern  void iSeries_IoMmTable_Initialize(void);
-extern  void iSeries_IoMmTable_Status(void);
+/*
+ * iSeries_IoMmTable_Initialize
+ *
+ * - Initalizes the Address Translation Table and get it ready for use.
+ *   Must be called before any client calls any of the other methods.
+ *
+ * Parameters: None.
+ *
+ * Return: None.
+ */
+extern void iSeries_IoMmTable_Initialize(void);
+extern void iSeries_IoMmTable_Status(void);
 
-/************************************************************************/
-/* iSeries_allocateDeviceBars                                           */
-/************************************************************************/
-/* - Allocates ALL pci_dev BAR's and updates the resources with the BAR */
-/*   value.  BARS with zero length will not have the resources.  The    */
-/*   HvCallPci_getBarParms is used to get the size of the BAR space.    */
-/*   It calls iSeries_IoMmTable_AllocateEntry to allocate each entry.   */
-/*                                                                      */
-/* Parameters:                                                          */
-/* pci_dev = Pointer to pci_dev structure that will be mapped to pseudo */
-/*           I/O Address.                                               */
-/*                                                                      */
-/* Return:                                                              */
-/*   The pci_dev I/O resources updated with pseudo I/O Addresses.       */
-/************************************************************************/
-extern  void iSeries_allocateDeviceBars(struct pci_dev* );
+/*
+ * iSeries_allocateDeviceBars
+ *
+ * - Allocates ALL pci_dev BAR's and updates the resources with the BAR
+ *   value.  BARS with zero length will not have the resources.  The
+ *   HvCallPci_getBarParms is used to get the size of the BAR space.
+ *   It calls iSeries_IoMmTable_AllocateEntry to allocate each entry.
+ *
+ * Parameters:
+ * pci_dev = Pointer to pci_dev structure that will be mapped to pseudo
+ *           I/O Address.
+ *
+ * Return:
+ *   The pci_dev I/O resources updated with pseudo I/O Addresses.
+ */
+extern void iSeries_allocateDeviceBars(struct pci_dev *);
 
-/************************************************************************/
-/* iSeries_xlateIoMmAddress                                             */
-/************************************************************************/
-/* - Translates an I/O Memory address to Device Node that has been the  */
-/*   allocated the psuedo I/O Address.                                  */
-/*                                                                      */
-/* Parameters:                                                          */
-/* IoAddress = I/O Memory Address.                                      */
-/*                                                                      */
-/* Return:                                                              */
-/*   An iSeries_Device_Node to the device mapped to the I/O address. The*/
-/*   BarNumber and BarOffset are valid if the Device Node is returned.  */
-/************************************************************************/
-extern struct iSeries_Device_Node* iSeries_xlateIoMmAddress(void* IoAddress);
+/*
+ * iSeries_xlateIoMmAddress
+ *
+ * - Translates an I/O Memory address to Device Node that has been the
+ *   allocated the psuedo I/O Address.
+ *
+ * Parameters:
+ * IoAddress = I/O Memory Address.
+ *
+ * Return:
+ *   An iSeries_Device_Node to the device mapped to the I/O address. The
+ *   BarNumber and BarOffset are valid if the Device Node is returned.
+ */
+extern struct iSeries_Device_Node *iSeries_xlateIoMmAddress(void *IoAddress);
 
 #endif /* _ISERIES_IOMMTABLE_H */
diff -puN arch/ppc64/kernel/iSeries_irq.c~linus arch/ppc64/kernel/iSeries_irq.c
--- 25/arch/ppc64/kernel/iSeries_irq.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/iSeries_irq.c	2004-01-19 22:17:21.000000000 -0800
@@ -40,219 +40,177 @@
 #include <asm/iSeries/iSeries_irq.h>
 #include <asm/iSeries/XmPciLpEvent.h>
 
-
-hw_irq_controller iSeries_IRQ_handler = {
-	"iSeries irq controller",
-	iSeries_startup_IRQ,	/* startup */
-	iSeries_shutdown_IRQ,	/* shutdown */
-	iSeries_enable_IRQ,	/* enable */
-	iSeries_disable_IRQ,	/* disable */
-	NULL,			/* ack  */
-	iSeries_end_IRQ,	/* end  */
-	NULL			/* set_affinity */
-};
-
-
-struct iSeries_irqEntry {
-	u32 dsa;
-	struct iSeries_irqEntry* next;
-};
-
-struct iSeries_irqAnchor {
-	u8  valid : 1;
-	u8  reserved : 7;
-	u16  entryCount;
-	struct iSeries_irqEntry* head;
+static unsigned int iSeries_startup_IRQ(unsigned int irq);
+static void iSeries_shutdown_IRQ(unsigned int irq);
+static void iSeries_enable_IRQ(unsigned int irq);
+static void iSeries_disable_IRQ(unsigned int irq);
+static void iSeries_end_IRQ(unsigned int irq);
+
+static hw_irq_controller iSeries_IRQ_handler = {
+	.typename = "iSeries irq controller",
+	.startup = iSeries_startup_IRQ,
+	.shutdown = iSeries_shutdown_IRQ,
+	.enable = iSeries_enable_IRQ,
+	.disable = iSeries_disable_IRQ,
+	.end = iSeries_end_IRQ
 };
 
-struct iSeries_irqAnchor iSeries_irqMap[NR_IRQS];
-
-void iSeries_init_irqMap(int irq);
+void iSeries_init_irq_desc(irq_desc_t *desc)
+{
+}
 
-/*  This is called by init_IRQ.  set in ppc_md.init_IRQ by iSeries_setup.c */
+/* This is called by init_IRQ.  set in ppc_md.init_IRQ by iSeries_setup.c */
 void __init iSeries_init_IRQ(void)
 {
-	int i;
-	for (i = 0; i < NR_IRQS; i++) {
-		irq_desc[i].handler = &iSeries_IRQ_handler;
-		irq_desc[i].status = 0;
-		irq_desc[i].status |= IRQ_DISABLED;
-		irq_desc[i].depth = 1;
-		iSeries_init_irqMap(i);
-	}
 	/* Register PCI event handler and open an event path */
-	PPCDBG(PPCDBG_BUSWALK,"Register PCI event handler and open an event path\n");
+	PPCDBG(PPCDBG_BUSWALK,
+			"Register PCI event handler and open an event path\n");
 	XmPciLpEvent_init();
 	return;
 }
 
-/**********************************************************************
- *  Called by iSeries_init_IRQ 
- * Prevent IRQs 0 and 255 from being used.  IRQ 0 appears in
- * uninitialized devices.  IRQ 255 appears in the PCI interrupt
- * line register if a PCI error occurs,
- *********************************************************************/
-void __init iSeries_init_irqMap(int irq)
-{
-	iSeries_irqMap[irq].valid = (irq == 0 || irq == 255)? 0 : 1;
-	iSeries_irqMap[irq].entryCount = 0;
-	iSeries_irqMap[irq].head = NULL;
-}
-
-/* This is called out of iSeries_scan_slot to allocate an IRQ for an EADS slot */
-/* It calculates the irq value for the slot.                                   */
-int __init iSeries_allocate_IRQ(HvBusNumber busNumber, HvSubBusNumber subBusNumber, HvAgentId deviceId)
+/*
+ * This is called out of iSeries_scan_slot to allocate an IRQ for an EADS slot
+ * It calculates the irq value for the slot.
+ * Note that subBusNumber is always 0 (at the moment at least).
+ */
+int __init iSeries_allocate_IRQ(HvBusNumber busNumber,
+		HvSubBusNumber subBusNumber, HvAgentId deviceId)
 {
 	u8 idsel = (deviceId >> 4);
-	u8 function = deviceId & 0x0F;
-	int irq = ((((busNumber-1)*16 + (idsel-1)*8 + function)*9/8) % 253) + 2;
-	return irq;
+	u8 function = deviceId & 7;
+
+	return ((busNumber - 1) << 6) + ((idsel - 1) << 3) + function + 1;
 }
 
-/* This is called out of iSeries_scan_slot to assign the EADS slot to its IRQ number */
-int __init iSeries_assign_IRQ(int irq, HvBusNumber busNumber, HvSubBusNumber subBusNumber, HvAgentId deviceId)
+#define IRQ_TO_BUS(irq)		(((((irq) - 1) >> 6) & 0xff) + 1)
+#define IRQ_TO_IDSEL(irq)	(((((irq) - 1) >> 3) & 7) + 1)
+#define IRQ_TO_FUNC(irq)	(((irq) - 1) & 7)
+
+/*
+ * This is called out of iSeries_scan_slot to assign the EADS slot
+ * to its IRQ number
+ */
+int __init iSeries_assign_IRQ(int irq, HvBusNumber busNumber,
+		HvSubBusNumber subBusNumber, HvAgentId deviceId)
 {
-	int rc;
-	u32 dsa = (busNumber << 16) | (subBusNumber << 8) | deviceId;
-	struct iSeries_irqEntry* newEntry;
-	unsigned long flags;
+	irq_desc_t *desc = get_real_irq_desc(irq);
 
-	if (irq < 0 || irq >= NR_IRQS) {
+	if (desc == NULL)
 		return -1;
-	}
-	newEntry = kmalloc(sizeof(*newEntry), GFP_KERNEL);
-	if (newEntry == NULL) {
-		return -ENOMEM;
-	}
-	newEntry->dsa  = dsa;
-	newEntry->next = NULL;
-	/********************************************************************
-	* Probably not necessary to lock the irq since allocation is only 
-	* done during buswalk, but it should not hurt anything except a 
-	* little performance to be smp safe.
-	*******************************************************************/
-	spin_lock_irqsave(&irq_desc[irq].lock, flags);
-
-	if (iSeries_irqMap[irq].valid) {
-		/* Push the new element onto the irq stack */
-		newEntry->next = iSeries_irqMap[irq].head;
-		iSeries_irqMap[irq].head = newEntry;
-		++iSeries_irqMap[irq].entryCount;
-		rc = 0;
-		PPCDBG(PPCDBG_BUSWALK,"iSeries_assign_IRQ   0x%04X.%02X.%02X = 0x%04X\n",busNumber, subBusNumber, deviceId, irq);
-	}
-	else {
-		printk("PCI: Something is wrong with the iSeries_irqMap. \n");
-		kfree(newEntry);
-		rc = -1;
-    }
-	spin_unlock_irqrestore(&irq_desc[irq].lock, flags);
-	return rc;
+	desc->handler = &iSeries_IRQ_handler;
+	return 0;
 }
 
 
 /* This is called by iSeries_activate_IRQs */
-unsigned int iSeries_startup_IRQ(unsigned int irq)
+static unsigned int iSeries_startup_IRQ(unsigned int irq)
 {
-	struct iSeries_irqEntry* entry;
-	u32 bus, subBus, deviceId, function, mask;
-	for(entry=iSeries_irqMap[irq].head; entry!=NULL; entry=entry->next) {
-		bus      = (entry->dsa >> 16) & 0xFFFF;
-		subBus   = (entry->dsa >> 8) & 0xFF;
-		deviceId = entry->dsa & 0xFF;
-		function = deviceId & 0x0F;
-		/* Link the IRQ number to the bridge */
-		HvCallXm_connectBusUnit(bus, subBus, deviceId, irq);
-        	/* Unmask bridge interrupts in the FISR */
-		mask = 0x01010000 << function;
-		HvCallPci_unmaskFisr(bus, subBus, deviceId, mask);
-		PPCDBG(PPCDBG_BUSWALK,"iSeries_activate_IRQ 0x%02X.%02X.%02X  Irq:0x%02X\n",bus,subBus,deviceId,irq);
-	}
+	u32 bus, deviceId, function, mask;
+	const u32 subBus = 0;
+
+	bus = IRQ_TO_BUS(irq);
+	function = IRQ_TO_FUNC(irq);
+	deviceId = (IRQ_TO_IDSEL(irq) << 4) + function;
+
+	/* Link the IRQ number to the bridge */
+	HvCallXm_connectBusUnit(bus, subBus, deviceId, irq);
+
+	/* Unmask bridge interrupts in the FISR */
+	mask = 0x01010000 << function;
+	HvCallPci_unmaskFisr(bus, subBus, deviceId, mask);
+	PPCDBG(PPCDBG_BUSWALK, "iSeries_activate_IRQ 0x%02X.%02X.%02X  Irq:0x%02X\n",
+				bus, subBus, deviceId, irq);
 	return 0;
 }
 
-/* This is called out of iSeries_fixup to activate interrupt
- * generation for usable slots                              */
+/*
+ * This is called out of iSeries_fixup to activate interrupt
+ * generation for usable slots
+ */
 void __init iSeries_activate_IRQs()
 {
 	int irq;
 	unsigned long flags;
-	for (irq=0; irq < NR_IRQS; irq++) {
-		spin_lock_irqsave(&irq_desc[irq].lock, flags);
-		irq_desc[irq].handler->startup(irq);
-		spin_unlock_irqrestore(&irq_desc[irq].lock, flags);
+
+	for (irq = 0; irq < NR_IRQS; irq++) {
+		irq_desc_t *desc = get_irq_desc(irq);
+
+		if (desc && desc->handler && desc->handler->startup) {
+			spin_lock_irqsave(&desc->lock, flags);
+			desc->handler->startup(irq);
+			spin_unlock_irqrestore(&desc->lock, flags);
+		}
     	}
 }
 
 /*  this is not called anywhere currently */
-void iSeries_shutdown_IRQ(unsigned int irq) {
-	struct iSeries_irqEntry* entry;
-	u32 bus, subBus, deviceId, function, mask;
+static void iSeries_shutdown_IRQ(unsigned int irq)
+{
+	u32 bus, deviceId, function, mask;
+	const u32 subBus = 0;
 
 	/* irq should be locked by the caller */
+	bus = IRQ_TO_BUS(irq);
+	function = IRQ_TO_FUNC(irq);
+	deviceId = (IRQ_TO_IDSEL(irq) << 4) + function;
 
-	for (entry=iSeries_irqMap[irq].head; entry; entry=entry->next) {
-		bus = (entry->dsa >> 16) & 0xFFFF;
-		subBus = (entry->dsa >> 8) & 0xFF;
-		deviceId = entry->dsa & 0xFF;
-		function = deviceId & 0x0F;
-		/* Invalidate the IRQ number in the bridge */
-		HvCallXm_connectBusUnit(bus, subBus, deviceId, 0);
-		/* Mask bridge interrupts in the FISR */
-		mask = 0x01010000 << function;
-		HvCallPci_maskFisr(bus, subBus, deviceId, mask);
-	}
+	/* Invalidate the IRQ number in the bridge */
+	HvCallXm_connectBusUnit(bus, subBus, deviceId, 0);
 
+	/* Mask bridge interrupts in the FISR */
+	mask = 0x01010000 << function;
+	HvCallPci_maskFisr(bus, subBus, deviceId, mask);
 }
 
-/***********************************************************
+/*
  * This will be called by device drivers (via disable_IRQ)
  * to disable INTA in the bridge interrupt status register.
- ***********************************************************/
-void iSeries_disable_IRQ(unsigned int irq)
+ */
+static void iSeries_disable_IRQ(unsigned int irq)
 {
-	struct iSeries_irqEntry* entry;
-	u32 bus, subBus, deviceId, mask;
+	u32 bus, deviceId, function, mask;
+	const u32 subBus = 0;
 
 	/* The IRQ has already been locked by the caller */
-
-	for (entry=iSeries_irqMap[irq].head; entry; entry=entry->next) {
-		bus      = (entry->dsa >> 16) & 0xFFFF;
-		subBus   = (entry->dsa >> 8) & 0xFF;
-		deviceId = entry->dsa & 0xFF;
-		/* Mask secondary INTA   */
-		mask = 0x80000000;
-		HvCallPci_maskInterrupts(bus, subBus, deviceId, mask);
-		PPCDBG(PPCDBG_BUSWALK,"iSeries_disable_IRQ 0x%02X.%02X.%02X 0x%04X\n",bus,subBus,deviceId,irq);
-    	}
+	bus = IRQ_TO_BUS(irq);
+	function = IRQ_TO_FUNC(irq);
+	deviceId = (IRQ_TO_IDSEL(irq) << 4) + function;
+
+	/* Mask secondary INTA   */
+	mask = 0x80000000;
+	HvCallPci_maskInterrupts(bus, subBus, deviceId, mask);
+	PPCDBG(PPCDBG_BUSWALK, "iSeries_disable_IRQ 0x%02X.%02X.%02X 0x%04X\n",
+	       bus, subBus, deviceId, irq);
 }
 
-/***********************************************************
+/*
  * This will be called by device drivers (via enable_IRQ)
  * to enable INTA in the bridge interrupt status register.
- ***********************************************************/
-void iSeries_enable_IRQ(unsigned int irq)
+ */
+static void iSeries_enable_IRQ(unsigned int irq)
 {
-	struct iSeries_irqEntry* entry;
-	u32 bus, subBus, deviceId, mask;
+	u32 bus, deviceId, function, mask;
+	const u32 subBus = 0;
 
 	/* The IRQ has already been locked by the caller */
-	for (entry=iSeries_irqMap[irq].head; entry; entry=entry->next) {
-		bus      = (entry->dsa >> 16) & 0xFFFF;
-		subBus   = (entry->dsa >> 8) & 0xFF;
-		deviceId = entry->dsa & 0xFF;
-		/* Unmask secondary INTA */
-		mask = 0x80000000;
-		HvCallPci_unmaskInterrupts(bus, subBus, deviceId, mask);
-		PPCDBG(PPCDBG_BUSWALK,"iSeries_enable_IRQ 0x%02X.%02X.%02X 0x%04X\n",bus,subBus,deviceId,irq);
-	}
-}
-
-/* Need to define this so ppc_irq_dispatch_handler will NOT call
-   enable_IRQ at the end of interrupt handling.  However, this
-   does nothing because there is not enough information provided
-   to do the EOI HvCall.  This is done by XmPciLpEvent.c */
-void iSeries_end_IRQ(unsigned int irq)
+	bus = IRQ_TO_BUS(irq);
+	function = IRQ_TO_FUNC(irq);
+	deviceId = (IRQ_TO_IDSEL(irq) << 4) + function;
+
+	/* Unmask secondary INTA */
+	mask = 0x80000000;
+	HvCallPci_unmaskInterrupts(bus, subBus, deviceId, mask);
+	PPCDBG(PPCDBG_BUSWALK, "iSeries_enable_IRQ 0x%02X.%02X.%02X 0x%04X\n",
+	       bus, subBus, deviceId, irq);
+}
+
+/*
+ * Need to define this so ppc_irq_dispatch_handler will NOT call
+ * enable_IRQ at the end of interrupt handling.  However, this does
+ * nothing because there is not enough information provided to do
+ * the EOI HvCall.  This is done by XmPciLpEvent.c
+ */
+static void iSeries_end_IRQ(unsigned int irq)
 {
 }
-
diff -puN arch/ppc64/kernel/iSeries_pci.c~linus arch/ppc64/kernel/iSeries_pci.c
--- 25/arch/ppc64/kernel/iSeries_pci.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/iSeries_pci.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,3 +1,4 @@
+#define PCIFR(...)
 /*
  * iSeries_pci.c
  *
@@ -35,7 +36,6 @@
 #include <asm/pci-bridge.h>
 #include <asm/ppcdebug.h>
 #include <asm/naca.h>
-#include <asm/flight_recorder.h>
 #include <asm/pci_dma.h>
 
 #include <asm/iSeries/HvCallPci.h>
@@ -49,856 +49,811 @@
 #include "iSeries_IoMmTable.h"
 #include "pci.h"
 
-extern struct pci_controller* hose_head;
-extern struct pci_controller** hose_tail;
-extern int    global_phb_number;
-extern int    panic_timeout;
+extern int panic_timeout;
 
-extern struct device_node *allnodes;
 extern unsigned long iSeries_Base_Io_Memory;    
 
-extern struct pci_ops iSeries_pci_ops;
-extern struct flightRecorder* PciFr;
-extern struct TceTable* tceTables[256];
-
-/*******************************************************************
- * Counters and control flags. 
- *******************************************************************/
-extern long   Pci_Io_Read_Count;
-extern long   Pci_Io_Write_Count;
-extern long   Pci_Cfg_Read_Count;
-extern long   Pci_Cfg_Write_Count;
-extern long   Pci_Error_Count;
-
-extern int    Pci_Retry_Max;	
-extern int    Pci_Error_Flag;
-extern int    Pci_Trace_Flag;
+extern struct TceTable *tceTables[256];
 
 extern void iSeries_MmIoTest(void);
 
-
-/*******************************************************************
+/*
  * Forward declares of prototypes. 
- *******************************************************************/
-struct iSeries_Device_Node* find_Device_Node(struct pci_dev* PciDev);
-struct iSeries_Device_Node* get_Device_Node(struct pci_dev* PciDev);
-
-unsigned long find_and_init_phbs(void);
-struct        pci_controller* alloc_phb(struct device_node *dev, char *model, unsigned int addr_size_words) ;
-
-void  iSeries_Scan_PHBs_Slots(struct pci_controller* Phb);
-void  iSeries_Scan_EADs_Bridge(HvBusNumber Bus, HvSubBusNumber SubBus, int IdSel);
-int   iSeries_Scan_Bridge_Slot(HvBusNumber Bus, struct HvCallPci_BridgeInfo* Info);
-void  list_device_nodes(void);
-
-struct pci_dev;
+ */
+static struct iSeries_Device_Node *find_Device_Node(int bus, int devfn);
+static void iSeries_Scan_PHBs_Slots(struct pci_controller *Phb);
+static void iSeries_Scan_EADs_Bridge(HvBusNumber Bus, HvSubBusNumber SubBus,
+		int IdSel);
+static int iSeries_Scan_Bridge_Slot(HvBusNumber Bus,
+		struct HvCallPci_BridgeInfo *Info);
 
 LIST_HEAD(iSeries_Global_Device_List);
 
-int DeviceCount = 0;
-
+static int DeviceCount;
 
 /* Counters and control flags. */
-static long   Pci_Io_Read_Count  = 0;
-static long   Pci_Io_Write_Count = 0;
-static long   Pci_Cfg_Read_Count = 0;
-static long   Pci_Cfg_Write_Count= 0;
-static long   Pci_Error_Count    = 0;
-
-static int    Pci_Retry_Max      = 3;	/* Only retry 3 times  */	
-static int    Pci_Error_Flag     = 1;	/* Set Retry Error on. */
-static int    Pci_Trace_Flag     = 0;
+static long Pci_Io_Read_Count;
+static long Pci_Io_Write_Count;
+#if 0
+static long Pci_Cfg_Read_Count;
+static long Pci_Cfg_Write_Count;
+#endif
+static long Pci_Error_Count;
+
+static int Pci_Retry_Max = 3;	/* Only retry 3 times  */	
+static int Pci_Error_Flag = 1;	/* Set Retry Error on. */
 
+static struct pci_ops iSeries_pci_ops;
 
-/**********************************************************************************
+/*
  * Log Error infor in Flight Recorder to system Console.
  * Filter out the device not there errors.
  * PCI: EADs Connect Failed 0x18.58.10 Rc: 0x00xx
  * PCI: Read Vendor Failed 0x18.58.10 Rc: 0x00xx
  * PCI: Connect Bus Unit Failed 0x18.58.10 Rc: 0x00xx
- **********************************************************************************/
-void  pci_Log_Error(char* Error_Text, int Bus, int SubBus, int AgentId, int HvRc)
+ */
+static void pci_Log_Error(char *Error_Text, int Bus, int SubBus,
+		int AgentId, int HvRc)
 {
-	if( HvRc != 0x0302) { 
-		char ErrorString[128];
-		sprintf(ErrorString,"%s Failed: 0x%02X.%02X.%02X Rc: 0x%04X",Error_Text,Bus,SubBus,AgentId,HvRc);
-		PCIFR(ErrorString);
-		printk("PCI: %s\n",ErrorString);
-	}
+	if (HvRc == 0x0302)
+		return;
+
+	printk(KERN_ERR "PCI: %s Failed: 0x%02X.%02X.%02X Rc: 0x%04X",
+	       Error_Text, Bus, SubBus, AgentId, HvRc);
 }
 
-/**********************************************************************************
+#if 0
+/*
  * Dump the iSeries Temp Device Node 
- *<4>buswalk [swapper : - DeviceNode: 0xC000000000634300
- *<4>00. Device Node   = 0xC000000000634300
- *<4>    - PciDev      = 0x0000000000000000
- *<4>    - tDevice     = 0x  17:01.00  0x1022 00
- *<4>  4. Device Node = 0xC000000000634480
- *<4>     - PciDev    = 0x0000000000000000
- *<4>     - Device    = 0x  18:38.16 Irq:0xA7 Vendor:0x1014  Flags:0x00
- *<4>     - Devfn     = 0xB0: 22.18
- **********************************************************************************/
-void dumpDevice_Node(struct iSeries_Device_Node* DevNode)
+ * <4>buswalk [swapper : - DeviceNode: 0xC000000000634300
+ * <4>00. Device Node   = 0xC000000000634300
+ * <4>    - PciDev      = 0x0000000000000000
+ * <4>    - tDevice     = 0x  17:01.00  0x1022 00
+ * <4>  4. Device Node = 0xC000000000634480
+ * <4>     - PciDev    = 0x0000000000000000
+ * <4>     - Device    = 0x  18:38.16 Irq:0xA7 Vendor:0x1014  Flags:0x00
+ * <4>     - Devfn     = 0xB0: 22.18
+ */
+void dumpDevice_Node(struct iSeries_Device_Node *DevNode)
 {
-	udbg_printf("Device Node      = 0x%p\n",DevNode);
-	udbg_printf("     - PciDev    = 0x%p\n",DevNode->PciDev);
+	udbg_printf("Device Node      = 0x%p\n", DevNode);
+	udbg_printf("     - PciDev    = 0x%p\n", DevNode->PciDev);
 	udbg_printf("     - Device    = 0x%4X:%02X.%02X (0x%02X)\n",
-		    ISERIES_BUS(DevNode),
-		    ISERIES_SUBBUS(DevNode),
-		    DevNode->AgentId,
-		    DevNode->DevFn);
-	udbg_printf("     - LSlot     = 0x%02X\n",DevNode->LogicalSlot);
-	udbg_printf("     - TceTable  = 0x%p\n  ",DevNode->DevTceTable);
-
-	udbg_printf("     - DSA       = 0x%04X\n",ISERIES_DSA(DevNode)>>32 );
-
+			ISERIES_BUS(DevNode), ISERIES_SUBBUS(DevNode),
+			DevNode->AgentId, DevNode->DevFn);
+	udbg_printf("     - LSlot     = 0x%02X\n", DevNode->LogicalSlot);
+	udbg_printf("     - TceTable  = 0x%p\n  ", DevNode->DevTceTable);
+	udbg_printf("     - DSA       = 0x%04X\n", ISERIES_DSA(DevNode) >> 32);
 	udbg_printf("                 = Irq:0x%02X Vendor:0x%04X  Flags:0x%02X\n",
-		    DevNode->Irq,
-		    DevNode->Vendor,
-		    DevNode->Flags );
-	udbg_printf("     - Location  = %s\n",DevNode->CardLocation);
-
-
+			DevNode->Irq, DevNode->Vendor, DevNode->Flags);
+	udbg_printf("     - Location  = %s\n", DevNode->CardLocation);
 }
-/**********************************************************************************
+
+/*
  * Walk down the device node chain 
- **********************************************************************************/
-void  list_device_nodes(void)
+ */
+static void list_device_nodes(void)
 {
-	struct list_head* Device_Node_Ptr = iSeries_Global_Device_List.next;
-	while(Device_Node_Ptr != &iSeries_Global_Device_List) {
-		dumpDevice_Node( (struct iSeries_Device_Node*)Device_Node_Ptr );
+	struct list_head *Device_Node_Ptr = iSeries_Global_Device_List.next;
+
+	while (Device_Node_Ptr != &iSeries_Global_Device_List) {
+		dumpDevice_Node((struct iSeries_Device_Node*)Device_Node_Ptr);
 		Device_Node_Ptr = Device_Node_Ptr->next;
 	}
 }
-	
+#endif
 
-/***********************************************************************
+/*
  * build_device_node(u16 Bus, int SubBus, u8 DevFn)
- *
- ***********************************************************************/
-struct iSeries_Device_Node* build_device_node(HvBusNumber Bus, HvSubBusNumber  SubBus, int AgentId, int Function)
+ */
+static struct iSeries_Device_Node *build_device_node(HvBusNumber Bus,
+		HvSubBusNumber SubBus, int AgentId, int Function)
 {
-	struct iSeries_Device_Node*  DeviceNode;
-
-	PPCDBG(PPCDBG_BUSWALK,"-build_device_node 0x%02X.%02X.%02X Function: %02X\n",Bus,SubBus,AgentId, Function);
+	struct iSeries_Device_Node *node;
 
-	DeviceNode = kmalloc(sizeof(struct iSeries_Device_Node), GFP_KERNEL);
-	if(DeviceNode == NULL) return NULL;
-
-	memset(DeviceNode,0,sizeof(struct iSeries_Device_Node) );
-	list_add_tail(&DeviceNode->Device_List,&iSeries_Global_Device_List);
-	/*DeviceNode->DsaAddr      = ((u64)Bus<<48)+((u64)SubBus<<40)+((u64)0x10<<32); */
-	ISERIES_BUS(DeviceNode)       = Bus;
-	ISERIES_SUBBUS(DeviceNode)    = SubBus;
-	DeviceNode->DsaAddr.deviceId  = 0x10;
-        DeviceNode->DsaAddr.barNumber = 0;
-	DeviceNode->AgentId           = AgentId;
-	DeviceNode->DevFn             = PCI_DEVFN(ISERIES_ENCODE_DEVICE(AgentId),Function );
-	DeviceNode->IoRetry           = 0;
-	iSeries_Get_Location_Code(DeviceNode);
-	PCIFR("Device 0x%02X.%2X, Node:0x%p ",ISERIES_BUS(DeviceNode),ISERIES_DEVFUN(DeviceNode),DeviceNode);
-	return DeviceNode;
-}
-/****************************************************************************
-* 
-* Allocate pci_controller(phb) initialized common variables. 
-* 
-*****************************************************************************/
-struct pci_controller* pci_alloc_pci_controllerX(char *model, enum phb_types controller_type)
-{
-	struct pci_controller *hose;
-	hose = (struct pci_controller*)kmalloc(sizeof(struct pci_controller), GFP_KERNEL);
-	if(hose == NULL) return NULL;
-
-	memset(hose, 0, sizeof(struct pci_controller));
-	if(strlen(model) < 8) strcpy(hose->what,model);
-	else                  memcpy(hose->what,model,7);
-	hose->type = controller_type;
-	hose->global_number = global_phb_number;
-	global_phb_number++;
-
-	*hose_tail = hose;
-	hose_tail = &hose->next;
-	return hose;
+	PPCDBG(PPCDBG_BUSWALK,
+			"-build_device_node 0x%02X.%02X.%02X Function: %02X\n",
+			Bus, SubBus, AgentId, Function);
+
+	node = kmalloc(sizeof(struct iSeries_Device_Node), GFP_KERNEL);
+	if (node == NULL)
+		return NULL;
+
+	memset(node, 0, sizeof(struct iSeries_Device_Node));
+	list_add_tail(&node->Device_List, &iSeries_Global_Device_List);
+#if 0
+	node->DsaAddr = ((u64)Bus << 48) + ((u64)SubBus << 40) + ((u64)0x10 << 32);
+#endif
+	node->DsaAddr.DsaAddr = 0;
+	node->DsaAddr.Dsa.busNumber = Bus;
+	node->DsaAddr.Dsa.subBusNumber = SubBus;
+	node->DsaAddr.Dsa.deviceId = 0x10;
+	node->AgentId = AgentId;
+	node->DevFn = PCI_DEVFN(ISERIES_ENCODE_DEVICE(AgentId), Function);
+	node->IoRetry = 0;
+	iSeries_Get_Location_Code(node);
+	PCIFR("Device 0x%02X.%2X, Node:0x%p ", ISERIES_BUS(node),
+			ISERIES_DEVFUN(node), node);
+	return node;
 }
 
-/****************************************************************************
- *
- * unsigned int __init find_and_init_phbs(void)
+/*
+ * unsigned long __init find_and_init_phbs(void)
  *
  * Description:
  *   This function checks for all possible system PCI host bridges that connect
  *   PCI buses.  The system hypervisor is queried as to the guest partition
- *   ownership status.  A pci_controller is build for any bus which is partially
+ *   ownership status.  A pci_controller is built for any bus which is partially
  *   owned or fully owned by this guest partition.
- ****************************************************************************/
+ */
 unsigned long __init find_and_init_phbs(void)
 {
-	struct      pci_controller* phb;
-	HvBusNumber BusNumber;
+	struct pci_controller *phb;
+	HvBusNumber bus;
 
-	PPCDBG(PPCDBG_BUSWALK,"find_and_init_phbs Entry\n");
+	PPCDBG(PPCDBG_BUSWALK, "find_and_init_phbs Entry\n");
 
 	/* Check all possible buses. */
-	for (BusNumber = 0; BusNumber < 256; BusNumber++) {
-		int RtnCode = HvCallXm_testBus(BusNumber);
-		if (RtnCode == 0) {
-			phb = pci_alloc_pci_controllerX("PHB HV", phb_type_hypervisor);
-			if(phb == NULL) {
-				printk("PCI: Allocate pci_controller failed.\n");
-				PCIFR(      "Allocate pci_controller failed.");
+	for (bus = 0; bus < 256; bus++) {
+		int ret = HvCallXm_testBus(bus);
+		if (ret == 0) {
+			printk("bus %d appears to exist\n", bus);
+			phb = pci_alloc_pci_controller(phb_type_hypervisor);
+			if (phb == NULL) {
+				PCIFR("Allocate pci_controller failed.");
 				return -1;
 			}
-			phb->pci_mem_offset = phb->local_number = BusNumber;
-			phb->first_busno  = BusNumber;
-			phb->last_busno   = BusNumber;
-			phb->ops          = &iSeries_pci_ops;
-
-			PPCDBG(PPCDBG_BUSWALK, "PCI:Create iSeries pci_controller(%p), Bus: %04X\n",phb,BusNumber);
-			PCIFR("Create iSeries PHB controller: %04X",BusNumber);
-
-			/***************************************************/
-			/* Find and connect the devices.                   */
-			/***************************************************/
+			phb->pci_mem_offset = phb->local_number = bus;
+			phb->first_busno = bus;
+			phb->last_busno = bus;
+			phb->ops = &iSeries_pci_ops;
+
+			PPCDBG(PPCDBG_BUSWALK, "PCI:Create iSeries pci_controller(%p), Bus: %04X\n",
+					phb, bus);
+			PCIFR("Create iSeries PHB controller: %04X", bus);
+
+			/* Find and connect the devices. */
 			iSeries_Scan_PHBs_Slots(phb);
 		}
-		/* Check for Unexpected Return code, a clue that something */
-		/* has gone wrong.                                         */
-		else if(RtnCode != 0x0301) {
-			PCIFR("Unexpected Return on Probe(0x%04X): 0x%04X",BusNumber,RtnCode);
-		}
-
+		/*
+		 * Check for Unexpected Return code, a clue that something
+		 * has gone wrong.
+		 */
+		else if (ret != 0x0301)
+			printk(KERN_ERR "Unexpected Return on Probe(0x%04X): 0x%04X",
+			       bus, ret);
 	}
 	return 0;
 }
-/*********************************************************************** 
+
+/*
  * iSeries_pcibios_init
  *  
  * Chance to initialize and structures or variable before PCI Bus walk.
- *  
- *<4>buswalk [swapper : iSeries_pcibios_init Entry.
- *<4>buswalk [swapper : IoMmTable Initialized 0xC00000000034BD30
- *<4>buswalk [swapper : find_and_init_phbs Entry
- *<4>buswalk [swapper : Create iSeries pci_controller:(0xC00000001F5C7000), Bus 0x0017
- *<4>buswalk [swapper : Connect EADs: 0x17.00.12 = 0x00
- *<4>buswalk [swapper : iSeries_assign_IRQ   0x0017.00.12 = 0x0091
- *<4>buswalk [swapper : - allocate and assign IRQ 0x17.00.12 = 0x91
- *<4>buswalk [swapper : - FoundDevice: 0x17.28.10 = 0x12AE
- *<4>buswalk [swapper : - build_device_node 0x17.28.12
- *<4>buswalk [swapper : iSeries_pcibios_init Exit.
- ***********************************************************************/
+ */
 void iSeries_pcibios_init(void)
 {
-	PPCDBG(PPCDBG_BUSWALK,"iSeries_pcibios_init Entry.\n"); 
-
+	PPCDBG(PPCDBG_BUSWALK, "iSeries_pcibios_init Entry.\n"); 
 	iSeries_IoMmTable_Initialize();
-
 	find_and_init_phbs();
-
-	pci_assign_all_busses = 0;
-	PPCDBG(PPCDBG_BUSWALK,"iSeries_pcibios_init Exit.\n"); 
+	/* pci_assign_all_busses = 0;		SFRXXX*/
+	PPCDBG(PPCDBG_BUSWALK, "iSeries_pcibios_init Exit.\n"); 
 }
-/***********************************************************************
+
+/*
  * pcibios_final_fixup(void)  
- ***********************************************************************/
+ */
 void __init pcibios_final_fixup(void)
 {
-	struct pci_dev* PciDev = NULL;
-	struct iSeries_Device_Node* DeviceNode;
-	char   Buffer[256];
-    	int    DeviceCount = 0;
+	struct pci_dev *pdev = NULL;
+	struct iSeries_Device_Node *node;
+	char Buffer[256];
+    	int DeviceCount = 0;
+
+	PPCDBG(PPCDBG_BUSWALK, "iSeries_pcibios_fixup Entry.\n"); 
 
-	PPCDBG(PPCDBG_BUSWALK,"iSeries_pcibios_fixup Entry.\n"); 
-	/******************************************************/
 	/* Fix up at the device node and pci_dev relationship */
-	/******************************************************/
 	mf_displaySrc(0xC9000100);
 
-	while ((PciDev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, PciDev)) != NULL) {
-		DeviceNode = find_Device_Node(PciDev);
-		if(DeviceNode != NULL) {
-			++DeviceCount;
-			PciDev->sysdata    = (void*)DeviceNode;
-			DeviceNode->PciDev = PciDev;
-
-			PPCDBG(PPCDBG_BUSWALK,"PciDev 0x%p <==> DevNode 0x%p\n",PciDev,DeviceNode );
-
-			iSeries_allocateDeviceBars(PciDev);
-
-			iSeries_Device_Information(PciDev,Buffer, sizeof(Buffer) );
-			printk("%d. %s\n",DeviceCount,Buffer);
+	printk("pcibios_final_fixup\n");
+	while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev))
+			!= NULL) {
+		node = find_Device_Node(pdev->bus->number, pdev->devfn);
+		printk("pci dev %p (%x.%x), node %p\n", pdev,
+		       pdev->bus->number, pdev->devfn, node);
 
-			create_pci_bus_tce_table((unsigned long)DeviceNode);
-		} else {
-			printk("PCI: Device Tree not found for 0x%016lX\n",(unsigned long)PciDev);
-		}
+		if (node != NULL) {
+			++DeviceCount;
+			pdev->sysdata = (void *)node;
+			node->PciDev = pdev;
+			PPCDBG(PPCDBG_BUSWALK,
+					"pdev 0x%p <==> DevNode 0x%p\n",
+					pdev, node);
+			iSeries_allocateDeviceBars(pdev);
+			iSeries_Device_Information(pdev, Buffer,
+					sizeof(Buffer));
+			printk("%d. %s\n", DeviceCount, Buffer);
+			create_pci_bus_tce_table((unsigned long)node);
+		} else
+			printk("PCI: Device Tree not found for 0x%016lX\n",
+					(unsigned long)pdev);
 	}
 	iSeries_IoMmTable_Status();
-
 	iSeries_activate_IRQs();
-
 	mf_displaySrc(0xC9000200);
 }
 
-void pcibios_fixup_bus(struct pci_bus* PciBus)
+void pcibios_fixup_bus(struct pci_bus *PciBus)
 {
-	PPCDBG(PPCDBG_BUSWALK,"iSeries_pcibios_fixup_bus(0x%04X) Entry.\n",PciBus->number); 
-
+	PPCDBG(PPCDBG_BUSWALK, "iSeries_pcibios_fixup_bus(0x%04X) Entry.\n",
+			PciBus->number); 
 }
 
-
-/***********************************************************************
- * pcibios_fixup_resources(struct pci_dev *dev) 
- *	
- ***********************************************************************/
-void pcibios_fixup_resources(struct pci_dev *PciDev)
+void pcibios_fixup_resources(struct pci_dev *pdev)
 {
-	PPCDBG(PPCDBG_BUSWALK,"pcibios_fixup_resources PciDev %p\n",PciDev);
+	PPCDBG(PPCDBG_BUSWALK, "fixup_resources pdev %p\n", pdev);
 }   
 
+/*
+ * Loop through each node function to find usable EADs bridges.  
+ */
+static void iSeries_Scan_PHBs_Slots(struct pci_controller *Phb)
+{
+	struct HvCallPci_DeviceInfo *DevInfo;
+	HvBusNumber bus = Phb->local_number;	/* System Bus */	
+	const HvSubBusNumber SubBus = 0;	/* EADs is always 0. */
+	int HvRc = 0;
+	int IdSel;	
+	const int MaxAgents = 8;
+
+	DevInfo = (struct HvCallPci_DeviceInfo*)
+		kmalloc(sizeof(struct HvCallPci_DeviceInfo), GFP_KERNEL);
+	if (DevInfo == NULL)
+		return;
 
-/********************************************************************************
-* Loop through each node function to find usable EADs bridges.  
-*********************************************************************************/
-void  iSeries_Scan_PHBs_Slots(struct pci_controller* Phb)
-{
-	struct HvCallPci_DeviceInfo* DevInfo;
-	HvBusNumber    Bus       = Phb->local_number;       /* System Bus        */	
-	HvSubBusNumber SubBus    = 0;                       /* EADs is always 0. */
-	int            HvRc      = 0;
-	int            IdSel     = 1;	
-	int            MaxAgents = 8;
-
-	DevInfo    = (struct HvCallPci_DeviceInfo*)kmalloc(sizeof(struct HvCallPci_DeviceInfo), GFP_KERNEL);
-	if(DevInfo == NULL) return;
-
-	/********************************************************************************
+	/*
 	 * Probe for EADs Bridges      
-	 ********************************************************************************/
-	for (IdSel=1; IdSel < MaxAgents; ++IdSel) {
-    		HvRc = HvCallPci_getDeviceInfo(Bus, SubBus, IdSel,REALADDR(DevInfo), sizeof(struct HvCallPci_DeviceInfo));
+	 */
+	for (IdSel = 1; IdSel < MaxAgents; ++IdSel) {
+    		HvRc = HvCallPci_getDeviceInfo(bus, SubBus, IdSel,
+				REALADDR(DevInfo),
+				sizeof(struct HvCallPci_DeviceInfo));
 		if (HvRc == 0) {
-			if(DevInfo->deviceType == HvCallPci_NodeDevice) {
-				iSeries_Scan_EADs_Bridge(Bus, SubBus, IdSel);
-			}
-			else printk("PCI: Invalid System Configuration(0x%02X.\n",DevInfo->deviceType);
+			if (DevInfo->deviceType == HvCallPci_NodeDevice)
+				iSeries_Scan_EADs_Bridge(bus, SubBus, IdSel);
+			else
+				printk("PCI: Invalid System Configuration(0x%02X)"
+				       " for bus 0x%02x id 0x%02x.\n",
+				       DevInfo->deviceType, bus, IdSel);
 		}
-		else pci_Log_Error("getDeviceInfo",Bus, SubBus, IdSel,HvRc);
+		else
+			pci_Log_Error("getDeviceInfo", bus, SubBus, IdSel, HvRc);
 	}
 	kfree(DevInfo);
 }
 
-/********************************************************************************
-* 
-*********************************************************************************/
-void  iSeries_Scan_EADs_Bridge(HvBusNumber Bus, HvSubBusNumber SubBus, int IdSel)
-{
-	struct HvCallPci_BridgeInfo* BridgeInfo;
-	HvAgentId      AgentId;
-	int            Function;
-	int            HvRc;
-
-	BridgeInfo = (struct HvCallPci_BridgeInfo*)kmalloc(sizeof(struct HvCallPci_BridgeInfo), GFP_KERNEL);
-	if(BridgeInfo == NULL) return;
-
-	/*********************************************************************
-	 * Note: hvSubBus and irq is always be 0 at this level!
-	 *********************************************************************/
-	for (Function=0; Function < 8; ++Function) {
+static void iSeries_Scan_EADs_Bridge(HvBusNumber bus, HvSubBusNumber SubBus,
+		int IdSel)
+{
+	struct HvCallPci_BridgeInfo *BridgeInfo;
+	HvAgentId AgentId;
+	int Function;
+	int HvRc;
+
+	BridgeInfo = (struct HvCallPci_BridgeInfo *)
+		kmalloc(sizeof(struct HvCallPci_BridgeInfo), GFP_KERNEL);
+	if (BridgeInfo == NULL)
+		return;
+
+	/* Note: hvSubBus and irq is always be 0 at this level! */
+	for (Function = 0; Function < 8; ++Function) {
 	  	AgentId = ISERIES_PCI_AGENTID(IdSel, Function);
-		HvRc = HvCallXm_connectBusUnit(Bus, SubBus, AgentId, 0);
+		HvRc = HvCallXm_connectBusUnit(bus, SubBus, AgentId, 0);
  		if (HvRc == 0) {
+			printk("found device at bus %d idsel %d func %d (AgentId %x)\n",
+			       bus, IdSel, Function, AgentId);
   			/*  Connect EADs: 0x18.00.12 = 0x00 */
-			PPCDBG(PPCDBG_BUSWALK,"PCI:Connect EADs: 0x%02X.%02X.%02X\n",Bus, SubBus, AgentId);
-			PCIFR(                    "Connect EADs: 0x%02X.%02X.%02X",  Bus, SubBus, AgentId);
-	    		HvRc = HvCallPci_getBusUnitInfo(Bus, SubBus, AgentId, 
-			                                REALADDR(BridgeInfo), sizeof(struct HvCallPci_BridgeInfo));
+			PPCDBG(PPCDBG_BUSWALK,
+					"PCI:Connect EADs: 0x%02X.%02X.%02X\n",
+					bus, SubBus, AgentId);
+	    		HvRc = HvCallPci_getBusUnitInfo(bus, SubBus, AgentId,
+					REALADDR(BridgeInfo),
+					sizeof(struct HvCallPci_BridgeInfo));
 	 		if (HvRc == 0) {
-				PPCDBG(PPCDBG_BUSWALK,"PCI: BridgeInfo, Type:0x%02X, SubBus:0x%02X, MaxAgents:0x%02X, MaxSubBus: 0x%02X, LSlot: 0x%02X\n",
-				       BridgeInfo->busUnitInfo.deviceType,
-				       BridgeInfo->subBusNumber,
-				       BridgeInfo->maxAgents,
-				       BridgeInfo->maxSubBusNumber,
-				       BridgeInfo->logicalSlotNumber);
-				PCIFR(                     "BridgeInfo, Type:0x%02X, SubBus:0x%02X, MaxAgents:0x%02X, MaxSubBus: 0x%02X, LSlot: 0x%02X",
-				       BridgeInfo->busUnitInfo.deviceType,
-				       BridgeInfo->subBusNumber,
-				       BridgeInfo->maxAgents,
-				       BridgeInfo->maxSubBusNumber,
-				       BridgeInfo->logicalSlotNumber);
+				printk("bridge info: type %x subbus %x maxAgents %x maxsubbus %x logslot %x\n",
+					BridgeInfo->busUnitInfo.deviceType,
+					BridgeInfo->subBusNumber,
+					BridgeInfo->maxAgents,
+					BridgeInfo->maxSubBusNumber,
+					BridgeInfo->logicalSlotNumber);
+				PPCDBG(PPCDBG_BUSWALK,
+					"PCI: BridgeInfo, Type:0x%02X, SubBus:0x%02X, MaxAgents:0x%02X, MaxSubBus: 0x%02X, LSlot: 0x%02X\n",
+					BridgeInfo->busUnitInfo.deviceType,
+					BridgeInfo->subBusNumber,
+					BridgeInfo->maxAgents,
+					BridgeInfo->maxSubBusNumber,
+					BridgeInfo->logicalSlotNumber);
 
-				if (BridgeInfo->busUnitInfo.deviceType == HvCallPci_BridgeDevice)  {
+				if (BridgeInfo->busUnitInfo.deviceType ==
+						HvCallPci_BridgeDevice)  {
 					/* Scan_Bridge_Slot...: 0x18.00.12 */
-					iSeries_Scan_Bridge_Slot(Bus,BridgeInfo);
-				}
-				else printk("PCI: Invalid Bridge Configuration(0x%02X)",BridgeInfo->busUnitInfo.deviceType);
+					iSeries_Scan_Bridge_Slot(bus, BridgeInfo);
+				} else
+					printk("PCI: Invalid Bridge Configuration(0x%02X)",
+						BridgeInfo->busUnitInfo.deviceType);
 			}
-    		}
-		else if(HvRc != 0x000B) pci_Log_Error("EADs Connect",Bus,SubBus,AgentId,HvRc);
+    		} else if (HvRc != 0x000B)
+			pci_Log_Error("EADs Connect",
+					bus, SubBus, AgentId, HvRc);
 	}
 	kfree(BridgeInfo);
 }
 
-/********************************************************************************
-* 
-* This assumes that the node slot is always on the primary bus!
-*
-*********************************************************************************/
-int iSeries_Scan_Bridge_Slot(HvBusNumber Bus, struct HvCallPci_BridgeInfo* BridgeInfo)
+/*
+ * This assumes that the node slot is always on the primary bus!
+ */
+static int iSeries_Scan_Bridge_Slot(HvBusNumber Bus,
+		struct HvCallPci_BridgeInfo *BridgeInfo)
 {
-	struct iSeries_Device_Node* DeviceNode;
+	struct iSeries_Device_Node *node;
 	HvSubBusNumber SubBus = BridgeInfo->subBusNumber;
-	u16       VendorId    = 0;
-	int       HvRc        = 0;
-	u8        Irq         = 0;
-	int       IdSel       = ISERIES_GET_DEVICE_FROM_SUBBUS(SubBus);
-	int       Function    = ISERIES_GET_FUNCTION_FROM_SUBBUS(SubBus);
-	HvAgentId AgentId     = ISERIES_PCI_AGENTID(IdSel, Function);
-	HvAgentId EADsIdSel   = ISERIES_PCI_AGENTID(IdSel, Function);
-	int       FirstSlotId = 0; 	
-
-	/**********************************************************/
-	/* iSeries_allocate_IRQ.: 0x18.00.12(0xA3)                */
-	/**********************************************************/
-  	Irq   = iSeries_allocate_IRQ(Bus, 0, AgentId);
-	iSeries_assign_IRQ(Irq, Bus, 0, AgentId);
-	PPCDBG(PPCDBG_BUSWALK,"PCI:- allocate and assign IRQ 0x%02X.%02X.%02X = 0x%02X\n",Bus, 0, AgentId, Irq );
+	u16 VendorId = 0;
+	int HvRc = 0;
+	u8 Irq = 0;
+	int IdSel = ISERIES_GET_DEVICE_FROM_SUBBUS(SubBus);
+	int Function = ISERIES_GET_FUNCTION_FROM_SUBBUS(SubBus);
+	HvAgentId EADsIdSel = ISERIES_PCI_AGENTID(IdSel, Function);
+
+	/* iSeries_allocate_IRQ.: 0x18.00.12(0xA3) */
+  	Irq = iSeries_allocate_IRQ(Bus, 0, EADsIdSel);
+	iSeries_assign_IRQ(Irq, Bus, 0, EADsIdSel);
+	PPCDBG(PPCDBG_BUSWALK,
+		"PCI:- allocate and assign IRQ 0x%02X.%02X.%02X = 0x%02X\n",
+		Bus, 0, EADsIdSel, Irq);
 
-	/****************************************************************************
+	/*
 	 * Connect all functions of any device found.  
-	 ****************************************************************************/
+	 */
   	for (IdSel = 1; IdSel <= BridgeInfo->maxAgents; ++IdSel) {
     		for (Function = 0; Function < 8; ++Function) {
-			AgentId = ISERIES_PCI_AGENTID(IdSel, Function);
-			HvRc = HvCallXm_connectBusUnit(Bus, SubBus, AgentId, Irq);
-			if( HvRc == 0) {
-				HvRc = HvCallPci_configLoad16(Bus, SubBus, AgentId, PCI_VENDOR_ID, &VendorId);
-				if( HvRc == 0) {
-					/**********************************************************/
-					/* FoundDevice: 0x18.28.10 = 0x12AE                       */
-					/**********************************************************/
-					PPCDBG(PPCDBG_BUSWALK,"PCI:- FoundDevice: 0x%02X.%02X.%02X = 0x%04X\n",
-					                                       Bus, SubBus, AgentId, VendorId);
-
-					HvRc = HvCallPci_configStore8(Bus, SubBus, AgentId, PCI_INTERRUPT_LINE, Irq);  
-					if( HvRc != 0) {
-						pci_Log_Error("PciCfgStore Irq Failed!",Bus,SubBus,AgentId,HvRc);
-					}
-
-					++DeviceCount;
-					DeviceNode = build_device_node(Bus, SubBus, EADsIdSel, Function);
-					DeviceNode->Vendor      = VendorId;
-					DeviceNode->Irq         = Irq;
-					DeviceNode->LogicalSlot = BridgeInfo->logicalSlotNumber;
-					PCIFR("Device(%4d): 0x%02X.%02X.%02X 0x%02X 0x%04X",
-					      DeviceCount,Bus, SubBus, AgentId,
-					      DeviceNode->LogicalSlot,DeviceNode->Vendor);
-
-					/***********************************************************
-					 * On the first device/function, assign irq to slot
-					 ***********************************************************/
-					if(Function == 0) { 
-						FirstSlotId = AgentId;
-						// AHT iSeries_assign_IRQ(Irq, Bus, SubBus, AgentId);
-    					}
-				}
-				else pci_Log_Error("Read Vendor",Bus,SubBus,AgentId,HvRc);
+			HvAgentId AgentId = ISERIES_PCI_AGENTID(IdSel, Function);
+			HvRc = HvCallXm_connectBusUnit(Bus, SubBus,
+					AgentId, Irq);
+			if (HvRc != 0) {
+				pci_Log_Error("Connect Bus Unit",
+					      Bus, SubBus, AgentId, HvRc);
+				continue;
+			}
+			printk("connected bus unit at bus %d subbus 0x%x agentid 0x%x (idsel=%d func=%d)\n",
+			       Bus, SubBus, AgentId, IdSel, Function);
+
+			HvRc = HvCallPci_configLoad16(Bus, SubBus, AgentId,
+						      PCI_VENDOR_ID, &VendorId);
+			if (HvRc != 0) {
+				pci_Log_Error("Read Vendor",
+					      Bus, SubBus, AgentId, HvRc);
+				continue;
 			}
-			else pci_Log_Error("Connect Bus Unit",Bus,SubBus, AgentId,HvRc);
+			printk("read vendor ID: %x\n", VendorId);
+
+			/* FoundDevice: 0x18.28.10 = 0x12AE */
+			PPCDBG(PPCDBG_BUSWALK,
+			       "PCI:- FoundDevice: 0x%02X.%02X.%02X = 0x%04X\n",
+			       Bus, SubBus, AgentId, VendorId);
+			HvRc = HvCallPci_configStore8(Bus, SubBus, AgentId,
+						      PCI_INTERRUPT_LINE, Irq);  
+			if (HvRc != 0)
+				pci_Log_Error("PciCfgStore Irq Failed!",
+					      Bus, SubBus, AgentId, HvRc);
+
+			++DeviceCount;
+			node = build_device_node(Bus, SubBus, EADsIdSel, Function);
+			node->Vendor = VendorId;
+			node->Irq = Irq;
+			node->LogicalSlot = BridgeInfo->logicalSlotNumber;
+
 		} /* for (Function = 0; Function < 8; ++Function) */
 	} /* for (IdSel = 1; IdSel <= MaxAgents; ++IdSel) */
 	return HvRc;
 }
-/************************************************************************/
-/* I/0 Memory copy MUST use mmio commands on iSeries                    */
-/* To do; For performance, include the hv call directly                 */
-/************************************************************************/
-void* iSeries_memset_io(void* dest, char c, size_t Count)
-{
-	u8    ByteValue     = c;
-	long  NumberOfBytes = Count;
-	char* IoBuffer      = dest;
-	while(NumberOfBytes > 0) {
-		iSeries_Write_Byte( ByteValue, (void*)IoBuffer );
+
+/*
+ * I/0 Memory copy MUST use mmio commands on iSeries
+ * To do; For performance, include the hv call directly
+ */
+void *iSeries_memset_io(void *dest, char c, size_t Count)
+{
+	u8 ByteValue = c;
+	long NumberOfBytes = Count;
+	char *IoBuffer = dest;
+
+	while (NumberOfBytes > 0) {
+		iSeries_Write_Byte(ByteValue, (void *)IoBuffer);
 		++IoBuffer;
 		-- NumberOfBytes;
 	}
 	return dest;
-}	
-void* iSeries_memcpy_toio(void *dest, void *source, size_t count)
+}
+
+void *iSeries_memcpy_toio(void *dest, void *source, size_t count)
 {
-	char *dst           = dest;
-	char *src           = source;
-	long  NumberOfBytes = count;
-	while(NumberOfBytes > 0) {
-		iSeries_Write_Byte(*src++, (void*)dst++);
+	char *dst = dest;
+	char *src = source;
+	long NumberOfBytes = count;
+
+	while (NumberOfBytes > 0) {
+		iSeries_Write_Byte(*src++, (void *)dst++);
 		-- NumberOfBytes;
 	}
 	return dest;
 }
-void* iSeries_memcpy_fromio(void *dest, void *source, size_t count)
+
+void *iSeries_memcpy_fromio(void *dest, void *source, size_t count)
 {
 	char *dst = dest;
 	char *src = source;
-	long  NumberOfBytes = count;
-	while(NumberOfBytes > 0) {
-		*dst++ = iSeries_Read_Byte( (void*)src++);
+	long NumberOfBytes = count;
+
+	while (NumberOfBytes > 0) {
+		*dst++ = iSeries_Read_Byte((void *)src++);
 		-- NumberOfBytes;
 	}
 	return dest;
 }
-/**********************************************************************************
+
+/*
  * Look down the chain to find the matching Device Device
- **********************************************************************************/
-struct iSeries_Device_Node* find_Device_Node(struct pci_dev* PciDev)
+ */
+static struct iSeries_Device_Node *find_Device_Node(int bus, int devfn)
 {
-	struct list_head* Device_Node_Ptr = iSeries_Global_Device_List.next;
-	int Bus   = PciDev->bus->number;
-	int DevFn = PciDev->devfn;
-	
-	while(Device_Node_Ptr != &iSeries_Global_Device_List) { 
-		struct iSeries_Device_Node* DevNode = (struct iSeries_Device_Node*)Device_Node_Ptr;
-		if(Bus == ISERIES_BUS(DevNode) && DevFn == DevNode->DevFn) {
-			return DevNode;
-		}
-		Device_Node_Ptr = Device_Node_Ptr->next;
+	struct list_head *pos;
+
+	list_for_each(pos, &iSeries_Global_Device_List) {
+		struct iSeries_Device_Node *node =
+			list_entry(pos, struct iSeries_Device_Node, Device_List);
+
+		if ((bus == ISERIES_BUS(node)) && (devfn == node->DevFn))
+			return node;
 	}
 	return NULL;
 }
-/******************************************************************/
-/* Returns the device node for the passed pci_dev                 */
-/* Sanity Check Node PciDev to passed pci_dev                     */
-/* If none is found, returns a NULL which the client must handle. */
-/******************************************************************/
-struct iSeries_Device_Node* get_Device_Node(struct pci_dev* PciDev)
-{
-	struct iSeries_Device_Node* Node;
-	Node = (struct iSeries_Device_Node*)PciDev->sysdata;
-	if(Node == NULL ) {
-		Node = find_Device_Node(PciDev);
-	}
-	else if(Node->PciDev != PciDev) { 
-		Node = find_Device_Node(PciDev);
+
+#if 0
+/*
+ * Returns the device node for the passed pci_dev
+ * Sanity Check Node PciDev to passed pci_dev
+ * If none is found, returns a NULL which the client must handle.
+ */
+static struct iSeries_Device_Node *get_Device_Node(struct pci_dev *pdev)
+{
+	struct iSeries_Device_Node *node;
+
+	node = pdev->sysdata;
+	if (node == NULL || node->PciDev != pdev)
+		node = find_Device_Node(pdev->bus->number, pdev->devfn);
+	return node;
+}
+#endif
+
+/*
+ * Config space read and write functions.
+ * For now at least, we look for the device node for the bus and devfn
+ * that we are asked to access.  It may be possible to translate the devfn
+ * to a subbus and deviceid more directly.
+ */
+static u64 hv_cfg_read_func[4]  = {
+	HvCallPciConfigLoad8, HvCallPciConfigLoad16,
+	HvCallPciConfigLoad32, HvCallPciConfigLoad32
+};
+
+static u64 hv_cfg_write_func[4] = {
+	HvCallPciConfigStore8, HvCallPciConfigStore16,
+	HvCallPciConfigStore32, HvCallPciConfigStore32
+};
+
+/*
+ * Read PCI config space
+ */
+static int iSeries_pci_read_config(struct pci_bus *bus, unsigned int devfn,
+		int offset, int size, u32 *val)
+{
+	struct iSeries_Device_Node *node = find_Device_Node(bus->number, devfn);
+	u64 fn;
+	struct HvCallPci_LoadReturn ret;
+
+	if (node == NULL)
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
+	fn = hv_cfg_read_func[(size - 1) & 3];
+	HvCall3Ret16(fn, &ret, node->DsaAddr.DsaAddr, offset, 0);
+
+	if (ret.rc != 0) {
+		*val = ~0;
+		return PCIBIOS_DEVICE_NOT_FOUND;	/* or something */
 	}
-	return Node;
+
+	*val = ret.value;
+	return 0;
 }
-/**********************************************************************************
- *
- * Read PCI Config Space Code 
- *
- **********************************************************************************/
-/** BYTE  *************************************************************************/
-int iSeries_Node_read_config_byte(struct iSeries_Device_Node* DevNode, int Offset, u8* ReadValue)
-{
-	u8  ReadData; 
-	if(DevNode == NULL) { return 0x301; } 
-	++Pci_Cfg_Read_Count;
-	DevNode->ReturnCode = HvCallPci_configLoad8(ISERIES_BUS(DevNode),ISERIES_SUBBUS(DevNode),0x10,
-	                                                Offset,&ReadData);
-	if(Pci_Trace_Flag == 1) {
-		PCIFR("RCB: 0x%04X.%02X 0x%04X = 0x%02X",ISERIES_BUS(DevNode),DevNode->DevFn,Offset,ReadData);
-	}
-	if(DevNode->ReturnCode != 0 ) { 
-		printk("PCI: RCB: 0x%04X.%02X  Error: 0x%04X\n",ISERIES_BUS(DevNode),DevNode->DevFn,DevNode->ReturnCode);
-		PCIFR(      "RCB: 0x%04X.%02X  Error: 0x%04X",  ISERIES_BUS(DevNode),DevNode->DevFn,DevNode->ReturnCode);
-	}
-	*ReadValue = ReadData; 
- 	return DevNode->ReturnCode;
-}
-/** WORD  *************************************************************************/
-int iSeries_Node_read_config_word(struct iSeries_Device_Node* DevNode, int Offset, u16* ReadValue)
-{
-	u16  ReadData; 
-	if(DevNode == NULL) { return 0x301; } 
-	++Pci_Cfg_Read_Count;
-	DevNode->ReturnCode = HvCallPci_configLoad16(ISERIES_BUS(DevNode),ISERIES_SUBBUS(DevNode),0x10,
-	                                                Offset,&ReadData);
-	if(Pci_Trace_Flag == 1) {
-		PCIFR("RCW: 0x%04X.%02X 0x%04X = 0x%04X",ISERIES_BUS(DevNode),DevNode->DevFn,Offset,ReadData);
-	}
-	if(DevNode->ReturnCode != 0 ) { 
-		printk("PCI: RCW: 0x%04X.%02X  Error: 0x%04X\n",ISERIES_BUS(DevNode),DevNode->DevFn,DevNode->ReturnCode);
-		PCIFR(      "RCW: 0x%04X.%02X  Error: 0x%04X",  ISERIES_BUS(DevNode),DevNode->DevFn,DevNode->ReturnCode);
-
-	}
-	*ReadValue = ReadData; 
- 	return DevNode->ReturnCode;
-}
-/** DWORD *************************************************************************/
-int iSeries_Node_read_config_dword(struct iSeries_Device_Node* DevNode, int Offset, u32* ReadValue)
-{
- 	u32  ReadData; 
-	if(DevNode == NULL) { return 0x301; } 
-	++Pci_Cfg_Read_Count;
-	DevNode->ReturnCode = HvCallPci_configLoad32(ISERIES_BUS(DevNode),ISERIES_SUBBUS(DevNode),0x10,
-	                                                Offset,&ReadData);
-	if(Pci_Trace_Flag == 1) {
-		PCIFR("RCL: 0x%04X.%02X 0x%04X = 0x%08X",ISERIES_BUS(DevNode),DevNode->DevFn,Offset,ReadData);
-	}
-	if(DevNode->ReturnCode != 0 ) { 
-		printk("PCI: RCL: 0x%04X.%02X  Error: 0x%04X\n",ISERIES_BUS(DevNode),DevNode->DevFn,DevNode->ReturnCode);
-		PCIFR(      "RCL: 0x%04X.%02X  Error: 0x%04X",  ISERIES_BUS(DevNode),DevNode->DevFn,DevNode->ReturnCode);
-	}
-	*ReadValue = ReadData; 
- 	return DevNode->ReturnCode;
-}
-int iSeries_pci_read_config_byte(struct pci_dev* PciDev, int Offset, u8* ReadValue) { 
-	struct iSeries_Device_Node* DevNode = get_Device_Node(PciDev);
-	if(DevNode == NULL) return 0x0301;
-	return iSeries_Node_read_config_byte( DevNode ,Offset,ReadValue);
-}
-int iSeries_pci_read_config_word(struct pci_dev* PciDev, int Offset, u16* ReadValue) { 
-	struct iSeries_Device_Node* DevNode = get_Device_Node(PciDev);
-	if(DevNode == NULL) return 0x0301;
-	return iSeries_Node_read_config_word( DevNode ,Offset,ReadValue );
-}
-int iSeries_pci_read_config_dword(struct pci_dev* PciDev, int Offset, u32* ReadValue) { 
-	struct iSeries_Device_Node* DevNode = get_Device_Node(PciDev);
-	if(DevNode == NULL) return 0x0301;
-	return iSeries_Node_read_config_dword(DevNode ,Offset,ReadValue  );
-}
-/**********************************************************************************/
-/*                                                                                */
-/* Write PCI Config Space                                                         */
-/*                                                                                */
-/** BYTE  *************************************************************************/
-int iSeries_Node_write_config_byte(struct iSeries_Device_Node* DevNode, int Offset, u8 WriteData)
-{
-	++Pci_Cfg_Write_Count;
-	DevNode->ReturnCode = HvCallPci_configStore8(ISERIES_BUS(DevNode),ISERIES_SUBBUS(DevNode),0x10,
-	                                                  Offset,WriteData);
-	if(Pci_Trace_Flag == 1) {
-		PCIFR("WCB: 0x%04X.%02X 0x%04X = 0x%02X",ISERIES_BUS(DevNode),DevNode->DevFn,Offset,WriteData);
-	}
-	if(DevNode->ReturnCode != 0 ) { 
-		printk("PCI: WCB: 0x%04X.%02X  Error: 0x%04X\n",ISERIES_BUS(DevNode),DevNode->DevFn,DevNode->ReturnCode);
-		PCIFR(      "WCB: 0x%04X.%02X  Error: 0x%04X",  ISERIES_BUS(DevNode),DevNode->DevFn,DevNode->ReturnCode);
-	}
- 	return DevNode->ReturnCode;
-}
-/** WORD  *************************************************************************/
-int iSeries_Node_write_config_word(struct iSeries_Device_Node* DevNode, int Offset, u16 WriteData)
-{
-	++Pci_Cfg_Write_Count;
-	DevNode->ReturnCode = HvCallPci_configStore16(ISERIES_BUS(DevNode),ISERIES_SUBBUS(DevNode),0x10,
-	                                                  Offset,WriteData);
-	if(Pci_Trace_Flag == 1) {
-		PCIFR("WCW: 0x%04X.%02X 0x%04X = 0x%04X",ISERIES_BUS(DevNode),DevNode->DevFn,Offset,WriteData);
-	}
-	if(DevNode->ReturnCode != 0 ) { 
-		printk("PCI: WCW: 0x%04X.%02X  Error: 0x%04X\n",ISERIES_BUS(DevNode),DevNode->DevFn,DevNode->ReturnCode);
-		PCIFR(      "WCW: 0x%04X.%02X  Error: 0x%04X",  ISERIES_BUS(DevNode),DevNode->DevFn,DevNode->ReturnCode);
-	}
- 	return DevNode->ReturnCode;
-}
-/** DWORD *************************************************************************/
-int iSeries_Node_write_config_dword(struct iSeries_Device_Node* DevNode, int Offset, u32 WriteData)
-{
-	++Pci_Cfg_Write_Count;
-	DevNode->ReturnCode = HvCallPci_configStore32(ISERIES_BUS(DevNode),ISERIES_SUBBUS(DevNode),0x10,
-	                                                  Offset,WriteData);
-	if(Pci_Trace_Flag == 1) {
-		PCIFR("WCL: 0x%04X.%02X 0x%04X = 0x%08X",ISERIES_BUS(DevNode),DevNode->DevFn,Offset,WriteData);
-	}
-	if(DevNode->ReturnCode != 0 ) { 
-		printk("PCI: WCL: 0x%04X.%02X  Error: 0x%04X\n",ISERIES_BUS(DevNode),DevNode->DevFn,DevNode->ReturnCode);
-		PCIFR(      "WCL: 0x%04X.%02X  Error: 0x%04X",  ISERIES_BUS(DevNode),DevNode->DevFn,DevNode->ReturnCode);
-	}
-	return DevNode->ReturnCode;
-}
-int iSeries_pci_write_config_byte( struct pci_dev* PciDev,int Offset, u8 WriteValue)
-{
-	struct iSeries_Device_Node* DevNode = get_Device_Node(PciDev);
-	if(DevNode == NULL) return 0x0301;
-	return iSeries_Node_write_config_byte( DevNode,Offset,WriteValue);
-}
-int iSeries_pci_write_config_word( struct pci_dev* PciDev,int Offset,u16 WriteValue)
-{
-	struct iSeries_Device_Node* DevNode = get_Device_Node(PciDev);
-	if(DevNode == NULL) return 0x0301;
-	return iSeries_Node_write_config_word( DevNode,Offset,WriteValue);
-}
-int iSeries_pci_write_config_dword(struct pci_dev* PciDev,int Offset,u32 WriteValue)
-{
-	struct iSeries_Device_Node* DevNode = get_Device_Node(PciDev);
-	if(DevNode == NULL) return 0x0301;
-	return iSeries_Node_write_config_dword(DevNode,Offset,WriteValue);
-}
-
-/************************************************************************/
-/* Branch Table                                                         */
-/************************************************************************/
-struct pci_ops iSeries_pci_ops = {
-	iSeries_pci_read_config_byte,
-	iSeries_pci_read_config_word,
-	iSeries_pci_read_config_dword,
-	iSeries_pci_write_config_byte,
-	iSeries_pci_write_config_word,
-	iSeries_pci_write_config_dword 
+
+/*
+ * Write PCI config space
+ */
+
+static int iSeries_pci_write_config(struct pci_bus *bus, unsigned int devfn,
+		int offset, int size, u32 val)
+{
+	struct iSeries_Device_Node *node = find_Device_Node(bus->number, devfn);
+	u64 fn;
+	u64 ret;
+
+	if (node == NULL)
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
+	fn = hv_cfg_write_func[(size - 1) & 3];
+	ret = HvCall4(fn, node->DsaAddr.DsaAddr, offset, val, 0);
+
+	if (ret != 0)
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
+	return 0;
+}
+
+static struct pci_ops iSeries_pci_ops = {
+	.read = iSeries_pci_read_config,
+	.write = iSeries_pci_write_config
 };
 
-/************************************************************************
+/*
  * Check Return Code
  * -> On Failure, print and log information.
  *    Increment Retry Count, if exceeds max, panic partition.
  * -> If in retry, print and log success 
- ************************************************************************
+ *
  * PCI: Device 23.90 ReadL I/O Error( 0): 0x1234
  * PCI: Device 23.90 ReadL Retry( 1)
  * PCI: Device 23.90 ReadL Retry Successful(1)
- ************************************************************************/
-int  CheckReturnCode(char* TextHdr, struct iSeries_Device_Node* DevNode, u64 RtnCode)
+ */
+static int CheckReturnCode(char *TextHdr, struct iSeries_Device_Node *DevNode,
+		u64 ret)
 {
-	if(RtnCode != 0)  {
+	if (ret != 0)  {
 		++Pci_Error_Count;
 		++DevNode->IoRetry;
-		PCIFR(      "%s: Device 0x%04X:%02X  I/O Error(%2d): 0x%04X",
-			    TextHdr,ISERIES_BUS(DevNode),DevNode->DevFn,DevNode->IoRetry,(int)RtnCode);
 		printk("PCI: %s: Device 0x%04X:%02X  I/O Error(%2d): 0x%04X\n",
-		            TextHdr,ISERIES_BUS(DevNode),DevNode->DevFn,DevNode->IoRetry,(int)RtnCode);
-		/*******************************************************/
-		/* Bump the retry and check for retry count exceeded.  */
-		/* If, Exceeded, panic the system.                     */           
-		/*******************************************************/
-		if(DevNode->IoRetry > Pci_Retry_Max && Pci_Error_Flag > 0 ) {
+				TextHdr, DevNode->DsaAddr.Dsa.busNumber, DevNode->DevFn,
+				DevNode->IoRetry, (int)ret);
+		/*
+		 * Bump the retry and check for retry count exceeded.
+		 * If, Exceeded, panic the system.
+		 */
+		if ((DevNode->IoRetry > Pci_Retry_Max) &&
+				(Pci_Error_Flag > 0)) {
 			mf_displaySrc(0xB6000103);
 			panic_timeout = 0; 
-			panic("PCI: Hardware I/O Error, SRC B6000103, Automatic Reboot Disabled.\n");
+			panic("PCI: Hardware I/O Error, SRC B6000103, "
+					"Automatic Reboot Disabled.\n");
 		}
 		return -1;	/* Retry Try */
 	}
-	/********************************************************************
-	* If retry was in progress, log success and rest retry count        *
-	*********************************************************************/
-	else if(DevNode->IoRetry > 0) {
+	/* If retry was in progress, log success and rest retry count */
+	if (DevNode->IoRetry > 0) {
 		PCIFR("%s: Device 0x%04X:%02X Retry Successful(%2d).",
-		      TextHdr,ISERIES_BUS(DevNode),DevNode->DevFn,DevNode->IoRetry);
+				TextHdr, DevNode->DsaAddr.Dsa.busNumber, DevNode->DevFn,
+				DevNode->IoRetry);
 		DevNode->IoRetry = 0;
-		return 0; 
 	}
 	return 0; 
 }
-/************************************************************************/
-/* Translate the I/O Address into a device node, bar, and bar offset.   */
-/* Note: Make sure the passed variable end up on the stack to avoid     */
-/* the exposure of being device global.                                 */
-/************************************************************************/
-static inline struct iSeries_Device_Node* xlateIoMmAddress(void* IoAddress,
-							    union HvDsaMap* DsaPtr,
-							   u64* BarOffsetPtr) {
-
-	unsigned long BaseIoAddr = (unsigned long)IoAddress-iSeries_Base_Io_Memory;
-	long          TableIndex = BaseIoAddr/iSeries_IoMmTable_Entry_Size;
-	struct iSeries_Device_Node* DevNode = *(iSeries_IoMmTable +TableIndex);
-	if(DevNode != NULL) {
-		DsaPtr->DsaAddr       = ISERIES_DSA(DevNode);
-		DsaPtr->Dsa.barNumber = *(iSeries_IoBarTable+TableIndex);
-		*BarOffsetPtr         = BaseIoAddr % iSeries_IoMmTable_Entry_Size;
-	}
-	else {
+
+/*
+ * Translate the I/O Address into a device node, bar, and bar offset.
+ * Note: Make sure the passed variable end up on the stack to avoid
+ * the exposure of being device global.
+ */
+static inline struct iSeries_Device_Node *xlateIoMmAddress(void *IoAddress,
+		 u64 *dsaptr, u64 *BarOffsetPtr)
+{
+	unsigned long BaseIoAddr;
+	unsigned long TableIndex;
+	struct iSeries_Device_Node *DevNode;
+
+	if (((unsigned long)IoAddress < iSeries_Base_Io_Memory) ||
+			((unsigned long)IoAddress >= iSeries_Max_Io_Memory))
+		return NULL;
+	BaseIoAddr = (unsigned long)IoAddress - iSeries_Base_Io_Memory;
+	TableIndex = BaseIoAddr / iSeries_IoMmTable_Entry_Size;
+	DevNode = iSeries_IoMmTable[TableIndex];
+
+	if (DevNode != NULL) {
+		int barnum = iSeries_IoBarTable[TableIndex];
+		*dsaptr = DevNode->DsaAddr.DsaAddr | (barnum << 24);
+		*BarOffsetPtr = BaseIoAddr % iSeries_IoMmTable_Entry_Size;
+	} else
 		panic("PCI: Invalid PCI IoAddress detected!\n");
-	}
 	return DevNode;
 }
 
-/************************************************************************/
-/* Read MM I/O Instructions for the iSeries                             */
-/* On MM I/O error, all ones are returned and iSeries_pci_IoError is cal*/
-/* else, data is returned in big Endian format.                         */
-/************************************************************************/
-/* iSeries_Read_Byte = Read Byte  ( 8 bit)                              */
-/* iSeries_Read_Word = Read Word  (16 bit)                              */
-/* iSeries_Read_Long = Read Long  (32 bit)                              */
-/************************************************************************/
-u8  iSeries_Read_Byte(void* IoAddress)
-{
-	u64    BarOffset;
-	union  HvDsaMap DsaData;
-	struct HvCallPci_LoadReturn Return;
-	struct iSeries_Device_Node* DevNode = xlateIoMmAddress(IoAddress,&DsaData,&BarOffset);
-
+/*
+ * Read MM I/O Instructions for the iSeries
+ * On MM I/O error, all ones are returned and iSeries_pci_IoError is cal
+ * else, data is returned in big Endian format.
+ *
+ * iSeries_Read_Byte = Read Byte  ( 8 bit)
+ * iSeries_Read_Word = Read Word  (16 bit)
+ * iSeries_Read_Long = Read Long  (32 bit)
+ */
+u8 iSeries_Read_Byte(void *IoAddress)
+{
+	u64 BarOffset;
+	u64 dsa;
+	struct HvCallPci_LoadReturn ret;
+	struct iSeries_Device_Node *DevNode =
+		xlateIoMmAddress(IoAddress, &dsa, &BarOffset);
+
+	if (DevNode == NULL) {
+		static unsigned long last_jiffies;
+		static int num_printed;
+
+		if ((jiffies - last_jiffies) > 60 * HZ) {
+			last_jiffies = jiffies;
+			num_printed = 0;
+		}
+		if (num_printed++ < 10)
+			printk(KERN_ERR "iSeries_Read_Byte: invalid access at IO address %p\n", IoAddress);
+		return 0xff;
+	}
 	do {
 		++Pci_Io_Read_Count;
-		HvCall3Ret16(HvCallPciBarLoad8, &Return, DsaData.DsaAddr,BarOffset, 0);
-	} while (CheckReturnCode("RDB",DevNode, Return.rc) != 0);
+		HvCall3Ret16(HvCallPciBarLoad8, &ret, dsa, BarOffset, 0);
+	} while (CheckReturnCode("RDB", DevNode, ret.rc) != 0);
 
-	if(Pci_Trace_Flag == 1)	PCIFR("RDB: IoAddress 0x%p = 0x%02X",IoAddress, (u8)Return.value); 
-	return (u8)Return.value;
+	return (u8)ret.value;
 }
-u16  iSeries_Read_Word(void* IoAddress)
+
+u16 iSeries_Read_Word(void *IoAddress)
 {
-	u64    BarOffset;
-	union  HvDsaMap DsaData;
-	struct HvCallPci_LoadReturn Return;
-	struct iSeries_Device_Node* DevNode = xlateIoMmAddress(IoAddress,&DsaData,&BarOffset);
+	u64 BarOffset;
+	u64 dsa;
+	struct HvCallPci_LoadReturn ret;
+	struct iSeries_Device_Node *DevNode =
+		xlateIoMmAddress(IoAddress, &dsa, &BarOffset);
+
+	if (DevNode == NULL) {
+		static unsigned long last_jiffies;
+		static int num_printed;
 
+		if ((jiffies - last_jiffies) > 60 * HZ) {
+			last_jiffies = jiffies;
+			num_printed = 0;
+		}
+		if (num_printed++ < 10)
+			printk(KERN_ERR "iSeries_Read_Word: invalid access at IO address %p\n", IoAddress);
+		return 0xffff;
+	}
 	do {
 		++Pci_Io_Read_Count;
-		HvCall3Ret16(HvCallPciBarLoad16,&Return, DsaData.DsaAddr,BarOffset, 0);
-	} while (CheckReturnCode("RDW",DevNode, Return.rc) != 0);
+		HvCall3Ret16(HvCallPciBarLoad16, &ret, dsa,
+				BarOffset, 0);
+	} while (CheckReturnCode("RDW", DevNode, ret.rc) != 0);
 
-	if(Pci_Trace_Flag == 1) PCIFR("RDW: IoAddress 0x%p = 0x%04X",IoAddress, swab16((u16)Return.value));
-	return swab16((u16)Return.value);
+	return swab16((u16)ret.value);
 }
-u32  iSeries_Read_Long(void* IoAddress)
+
+u32 iSeries_Read_Long(void *IoAddress)
 {
-	u64    BarOffset;
-	union  HvDsaMap DsaData;
-	struct HvCallPci_LoadReturn Return;
-	struct iSeries_Device_Node* DevNode = xlateIoMmAddress(IoAddress,&DsaData,&BarOffset);
+	u64 BarOffset;
+	u64 dsa;
+	struct HvCallPci_LoadReturn ret;
+	struct iSeries_Device_Node *DevNode =
+		xlateIoMmAddress(IoAddress, &dsa, &BarOffset);
+
+	if (DevNode == NULL) {
+		static unsigned long last_jiffies;
+		static int num_printed;
 
+		if ((jiffies - last_jiffies) > 60 * HZ) {
+			last_jiffies = jiffies;
+			num_printed = 0;
+		}
+		if (num_printed++ < 10)
+			printk(KERN_ERR "iSeries_Read_Long: invalid access at IO address %p\n", IoAddress);
+		return 0xffffffff;
+	}
 	do {
 		++Pci_Io_Read_Count;
-		HvCall3Ret16(HvCallPciBarLoad32,&Return, DsaData.DsaAddr,BarOffset, 0);
-	} while (CheckReturnCode("RDL",DevNode, Return.rc) != 0);
+		HvCall3Ret16(HvCallPciBarLoad32, &ret, dsa,
+				BarOffset, 0);
+	} while (CheckReturnCode("RDL", DevNode, ret.rc) != 0);
 
-	if(Pci_Trace_Flag == 1) PCIFR("RDL: IoAddress 0x%p = 0x%04X",IoAddress, swab32((u32)Return.value));
-	return swab32((u32)Return.value);
+	return swab32((u32)ret.value);
 }
-/************************************************************************/
-/* Write MM I/O Instructions for the iSeries                            */
-/************************************************************************/
-/* iSeries_Write_Byte = Write Byte (8 bit)                              */
-/* iSeries_Write_Word = Write Word(16 bit)                              */
-/* iSeries_Write_Long = Write Long(32 bit)                              */
-/************************************************************************/
-void iSeries_Write_Byte(u8 Data, void* IoAddress)
-{
-	u64    BarOffset;
-	union  HvDsaMap DsaData;
-	struct HvCallPci_LoadReturn Return;
-	struct iSeries_Device_Node* DevNode = xlateIoMmAddress(IoAddress,&DsaData,&BarOffset);
 
+/*
+ * Write MM I/O Instructions for the iSeries
+ *
+ * iSeries_Write_Byte = Write Byte (8 bit)
+ * iSeries_Write_Word = Write Word(16 bit)
+ * iSeries_Write_Long = Write Long(32 bit)
+ */
+void iSeries_Write_Byte(u8 data, void *IoAddress)
+{
+	u64 BarOffset;
+	u64 dsa;
+	u64 rc;
+	struct iSeries_Device_Node *DevNode =
+		xlateIoMmAddress(IoAddress, &dsa, &BarOffset);
+
+	if (DevNode == NULL) {
+		static unsigned long last_jiffies;
+		static int num_printed;
+
+		if ((jiffies - last_jiffies) > 60 * HZ) {
+			last_jiffies = jiffies;
+			num_printed = 0;
+		}
+		if (num_printed++ < 10)
+			printk(KERN_ERR "iSeries_Write_Byte: invalid access at IO address %p\n", IoAddress);
+		return;
+	}
 	do {
 		++Pci_Io_Write_Count;
-		Return.rc = HvCall4(HvCallPciBarStore8, DsaData.DsaAddr,BarOffset, Data, 0);
-	} while (CheckReturnCode("WWB",DevNode, Return.rc) != 0);
-	if(Pci_Trace_Flag == 1) PCIFR("WWB: IoAddress 0x%p = 0x%02X",IoAddress,Data);
-}
-void iSeries_Write_Word(u16 Data, void* IoAddress)
-{
-	u64    BarOffset;
-	union  HvDsaMap DsaData;
-	struct HvCallPci_LoadReturn Return;
-	struct iSeries_Device_Node* DevNode = xlateIoMmAddress(IoAddress,&DsaData,&BarOffset);
+		rc = HvCall4(HvCallPciBarStore8, dsa, BarOffset, data, 0);
+	} while (CheckReturnCode("WWB", DevNode, rc) != 0);
+}
+
+void iSeries_Write_Word(u16 data, void *IoAddress)
+{
+	u64 BarOffset;
+	u64 dsa;
+	u64 rc;
+	struct iSeries_Device_Node *DevNode =
+		xlateIoMmAddress(IoAddress, &dsa, &BarOffset);
 
+	if (DevNode == NULL) {
+		static unsigned long last_jiffies;
+		static int num_printed;
+
+		if ((jiffies - last_jiffies) > 60 * HZ) {
+			last_jiffies = jiffies;
+			num_printed = 0;
+		}
+		if (num_printed++ < 10)
+			printk(KERN_ERR "iSeries_Write_Word: invalid access at IO address %p\n", IoAddress);
+		return;
+	}
 	do {
 		++Pci_Io_Write_Count;
-		Return.rc = HvCall4(HvCallPciBarStore16,DsaData.DsaAddr,BarOffset, swab16(Data), 0);
-	} while (CheckReturnCode("WWW",DevNode, Return.rc) != 0);
-	if(Pci_Trace_Flag == 1) PCIFR("WWW: IoAddress 0x%p = 0x%04X",IoAddress,Data);
-}
-void iSeries_Write_Long(u32 Data, void* IoAddress)
-{
-	u64    BarOffset;
-	union  HvDsaMap DsaData;
-	struct HvCallPci_LoadReturn Return;
-	struct iSeries_Device_Node* DevNode = xlateIoMmAddress(IoAddress,&DsaData,&BarOffset);
+		rc = HvCall4(HvCallPciBarStore16, dsa, BarOffset, swab16(data), 0);
+	} while (CheckReturnCode("WWW", DevNode, rc) != 0);
+}
+
+void iSeries_Write_Long(u32 data, void *IoAddress)
+{
+	u64 BarOffset;
+	u64 dsa;
+	u64 rc;
+	struct iSeries_Device_Node *DevNode =
+		xlateIoMmAddress(IoAddress, &dsa, &BarOffset);
+
+	if (DevNode == NULL) {
+		static unsigned long last_jiffies;
+		static int num_printed;
 
+		if ((jiffies - last_jiffies) > 60 * HZ) {
+			last_jiffies = jiffies;
+			num_printed = 0;
+		}
+		if (num_printed++ < 10)
+			printk(KERN_ERR "iSeries_Write_Long: invalid access at IO address %p\n", IoAddress);
+		return;
+	}
 	do {
 		++Pci_Io_Write_Count;
-		Return.rc = HvCall4(HvCallPciBarStore32,DsaData.DsaAddr,BarOffset, swab32(Data), 0);
-	} while (CheckReturnCode("WWL",DevNode, Return.rc) != 0);
-	if(Pci_Trace_Flag == 1) PCIFR("WWL: IoAddress 0x%p = 0x%08X",IoAddress, Data);
+		rc = HvCall4(HvCallPciBarStore32, dsa, BarOffset, swab32(data), 0);
+	} while (CheckReturnCode("WWL", DevNode, rc) != 0);
+}
+
+void pcibios_name_device(struct pci_dev *dev)
+{
 }
diff -puN arch/ppc64/kernel/iSeries_pci_reset.c~linus arch/ppc64/kernel/iSeries_pci_reset.c
--- 25/arch/ppc64/kernel/iSeries_pci_reset.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/iSeries_pci_reset.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,3 +1,4 @@
+#define PCIFR(...)
 /************************************************************************/
 /* File iSeries_pci_reset.c created by Allan Trautman on Mar 21 2001.   */
 /************************************************************************/
@@ -35,53 +36,67 @@
 #include <asm/iSeries/HvCallPci.h>
 #include <asm/iSeries/HvTypes.h>
 #include <asm/iSeries/mf.h>
-#include <asm/flight_recorder.h>
 #include <asm/pci.h>
 
 #include <asm/iSeries/iSeries_pci.h>
 #include "pci.h"
 
-/************************************************************************/
-/* Interface to toggle the reset line                                   */
-/* Time is in .1 seconds, need for seconds.                             */
-/************************************************************************/
-int  iSeries_Device_ToggleReset(struct pci_dev* PciDev, int AssertTime, int DelayTime)
+/*
+ * Interface to toggle the reset line
+ * Time is in .1 seconds, need for seconds.
+ */
+int iSeries_Device_ToggleReset(struct pci_dev *PciDev, int AssertTime,
+		int DelayTime)
 {
 	unsigned long AssertDelay, WaitDelay;
-	struct iSeries_Device_Node* DeviceNode = (struct iSeries_Device_Node*)PciDev->sysdata;
+	struct iSeries_Device_Node *DeviceNode =
+		(struct iSeries_Device_Node *)PciDev->sysdata;
+
  	if (DeviceNode == NULL) { 
-		printk("PCI: Pci Reset Failed, Device Node not found for pci_dev %p\n",PciDev);
+		printk("PCI: Pci Reset Failed, Device Node not found for pci_dev %p\n",
+				PciDev);
 		return -1;
 	}
-	/********************************************************************
+	/*
 	 * Set defaults, Assert is .5 second, Wait is 3 seconds.
-	 ********************************************************************/
-	if (AssertTime == 0) AssertDelay = ( 5 * HZ)/10;
-	else                 AssertDelay = (AssertTime*HZ)/10;
-	if (WaitDelay == 0)  WaitDelay   = (30 * HZ)/10;
-	else                 WaitDelay   = (DelayTime* HZ)/10;
+	 */
+	if (AssertTime == 0)
+		AssertDelay = (5 * HZ) / 10;
+	else
+		AssertDelay = (AssertTime * HZ) / 10;
+	if (WaitDelay == 0)
+		WaitDelay = (30 * HZ) / 10;
+	else
+		WaitDelay = (DelayTime * HZ) / 10;
 
-	/********************************************************************
+	/*
 	 * Assert reset
-	 ********************************************************************/
-	DeviceNode->ReturnCode = HvCallPci_setSlotReset(ISERIES_BUS(DeviceNode),0x00,DeviceNode->AgentId,1);
+	 */
+	DeviceNode->ReturnCode = HvCallPci_setSlotReset(ISERIES_BUS(DeviceNode),
+			0x00, DeviceNode->AgentId, 1);
 	if (DeviceNode->ReturnCode == 0) {
 		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(AssertDelay);       /* Sleep for the time     */
-		DeviceNode->ReturnCode = HvCallPci_setSlotReset(ISERIES_BUS(DeviceNode),0x00,DeviceNode->AgentId, 0);
+		schedule_timeout(AssertDelay);       /* Sleep for the time */
+		DeviceNode->ReturnCode =
+			HvCallPci_setSlotReset(ISERIES_BUS(DeviceNode),
+					0x00, DeviceNode->AgentId, 0);
 
-		/***************************************************************
+		/*
    		 * Wait for device to reset
-		 ***************************************************************/
+		 */
 		set_current_state(TASK_UNINTERRUPTIBLE);  
 		schedule_timeout(WaitDelay);
 	}
-	if (DeviceNode->ReturnCode == 0) {
-		PCIFR("Slot 0x%04X.%02 Reset\n",ISERIES_BUS(DeviceNode),DeviceNode->AgentId );
-	} 
+	if (DeviceNode->ReturnCode == 0)
+		PCIFR("Slot 0x%04X.%02 Reset\n", ISERIES_BUS(DeviceNode),
+				DeviceNode->AgentId);
 	else {
-		printk("PCI: Slot 0x%04X.%02X Reset Failed, RCode: %04X\n",ISERIES_BUS(DeviceNode),DeviceNode->AgentId,DeviceNode->ReturnCode);
-		PCIFR(      "Slot 0x%04X.%02X Reset Failed, RCode: %04X\n",ISERIES_BUS(DeviceNode),DeviceNode->AgentId,DeviceNode->ReturnCode);
+		printk("PCI: Slot 0x%04X.%02X Reset Failed, RCode: %04X\n",
+				ISERIES_BUS(DeviceNode), DeviceNode->AgentId,
+				DeviceNode->ReturnCode);
+		PCIFR("Slot 0x%04X.%02X Reset Failed, RCode: %04X\n",
+				ISERIES_BUS(DeviceNode), DeviceNode->AgentId,
+				DeviceNode->ReturnCode);
 	}
 	return DeviceNode->ReturnCode;
 }
diff -puN arch/ppc64/kernel/iSeries_proc.c~linus arch/ppc64/kernel/iSeries_proc.c
--- 25/arch/ppc64/kernel/iSeries_proc.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/iSeries_proc.c	2004-01-19 22:17:21.000000000 -0800
@@ -16,30 +16,22 @@
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
   */
-
-
-/* Change Activity: */
-/* End Change Activity */
-
 #include <linux/proc_fs.h>
 #include <linux/spinlock.h>
-#ifndef _ISERIES_PROC_H
+#include <linux/init.h>
 #include <asm/iSeries/iSeries_proc.h>
-#endif
 
-
-static struct proc_dir_entry * iSeries_proc_root = NULL;
-static int iSeries_proc_initializationDone = 0;
+static struct proc_dir_entry *iSeries_proc_root;
+static int iSeries_proc_initializationDone;
 static spinlock_t iSeries_proc_lock;
 
-struct iSeries_proc_registration
-{
+struct iSeries_proc_registration {
 	struct iSeries_proc_registration *next;
 	iSeriesProcFunction functionMember;
 };
 
-
 struct iSeries_proc_registration preallocated[16];
+
 #define MYQUEUETYPE(T) struct MYQueue##T
 #define MYQUEUE(T) \
 MYQUEUETYPE(T) \
@@ -69,74 +61,71 @@ do { \
 	if ((q)->tail == NULL) \
 		(q)->head = NULL; \
 } while(0)
+
 MYQUEUE(iSeries_proc_registration);
 typedef MYQUEUETYPE(iSeries_proc_registration) aQueue;
 
-
-aQueue iSeries_free;
-aQueue iSeries_queued;
+static aQueue iSeries_free;
+static aQueue iSeries_queued;
 
 void iSeries_proc_early_init(void)
 {
 	int i = 0;
 	unsigned long flags;
+
 	iSeries_proc_initializationDone = 0;
 	spin_lock_init(&iSeries_proc_lock);
 	MYQUEUECTOR(&iSeries_free);
 	MYQUEUECTOR(&iSeries_queued);
 
 	spin_lock_irqsave(&iSeries_proc_lock, flags);
-	for (i = 0; i < 16; ++i) {
-		MYQUEUEENQ(&iSeries_free, preallocated+i);
-	}
+	for (i = 0; i < 16; ++i)
+		MYQUEUEENQ(&iSeries_free, preallocated + i);
 	spin_unlock_irqrestore(&iSeries_proc_lock, flags);
 }
 
-void iSeries_proc_create(void)
+static int iSeries_proc_create(void)
 {
 	unsigned long flags;
-	struct iSeries_proc_registration *reg = NULL;
-	spin_lock_irqsave(&iSeries_proc_lock, flags);
+	struct iSeries_proc_registration *reg;
+
 	printk("iSeries_proc: Creating /proc/iSeries\n");
 
+	spin_lock_irqsave(&iSeries_proc_lock, flags);
 	iSeries_proc_root = proc_mkdir("iSeries", 0);
-	if (!iSeries_proc_root) return;
+	if (!iSeries_proc_root)
+		goto out;
 
 	MYQUEUEDEQ(&iSeries_queued, reg);
-
 	while (reg != NULL) {
 		(*(reg->functionMember))(iSeries_proc_root);
-
 		MYQUEUEDEQ(&iSeries_queued, reg);
 	}
 
 	iSeries_proc_initializationDone = 1;
+out:
 	spin_unlock_irqrestore(&iSeries_proc_lock, flags);
+	return 0;
 }
 
+arch_initcall(iSeries_proc_create);
+
 void iSeries_proc_callback(iSeriesProcFunction initFunction)
 {
 	unsigned long flags;
-	spin_lock_irqsave(&iSeries_proc_lock, flags);
 
-	if (iSeries_proc_initializationDone) {
+	spin_lock_irqsave(&iSeries_proc_lock, flags);
+	if (iSeries_proc_initializationDone)
 		(*initFunction)(iSeries_proc_root);
-	} else {
+	else {
 		struct iSeries_proc_registration *reg = NULL;
 
 		MYQUEUEDEQ(&iSeries_free, reg);
-
 		if (reg != NULL) {
-			/* printk("Registering %p in reg %p\n", initFunction, reg); */
 			reg->functionMember = initFunction;
-
 			MYQUEUEENQ(&iSeries_queued, reg);
-		} else {
+		} else
 			printk("Couldn't get a queue entry\n");
-		}
 	}
-
 	spin_unlock_irqrestore(&iSeries_proc_lock, flags);
 }
-
-
diff -puN arch/ppc64/kernel/iSeries_setup.c~linus arch/ppc64/kernel/iSeries_setup.c
--- 25/arch/ppc64/kernel/iSeries_setup.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/iSeries_setup.c	2004-01-19 22:17:21.000000000 -0800
@@ -25,6 +25,8 @@
 #include <linux/bootmem.h>
 #include <linux/initrd.h>
 #include <linux/seq_file.h>
+#include <linux/kdev_t.h>
+#include <linux/major.h>
 #include <linux/root_dev.h>
 
 #include <asm/processor.h>
@@ -53,34 +55,35 @@
 #include <asm/iSeries/mf.h>
 
 /* Function Prototypes */
-
 extern void abort(void);
-#ifdef CONFIG_PPC_ISERIES
-static void build_iSeries_Memory_Map( void );
-static void setup_iSeries_cache_sizes( void );
-static void iSeries_bolt_kernel(unsigned long saddr, unsigned long eaddr);
-#endif
-void build_valid_hpte( unsigned long vsid, unsigned long ea, unsigned long pa,
-		       pte_t * ptep, unsigned hpteflags, unsigned bolted );
 extern void ppcdbg_initialize(void);
 extern void iSeries_pcibios_init(void);
+extern void tce_init_iSeries(void);
+
+static void build_iSeries_Memory_Map(void);
+static void setup_iSeries_cache_sizes(void);
+static void iSeries_bolt_kernel(unsigned long saddr, unsigned long eaddr);
+void build_valid_hpte(unsigned long vsid, unsigned long ea, unsigned long pa,
+		pte_t *ptep, unsigned hpteflags, unsigned bolted);
 static void iSeries_setup_dprofile(void);
+void iSeries_setup_arch(void);
 
 /* Global Variables */
+static unsigned long procFreqHz;
+static unsigned long procFreqMhz;
+static unsigned long procFreqMhzHundreths;
+
+static unsigned long tbFreqHz;
+static unsigned long tbFreqMhz;
+static unsigned long tbFreqMhzHundreths;
 
-static unsigned long procFreqHz = 0;
-static unsigned long procFreqMhz = 0;
-static unsigned long procFreqMhzHundreths = 0;
-
-static unsigned long tbFreqHz = 0;
-static unsigned long tbFreqMhz = 0;
-static unsigned long tbFreqMhzHundreths = 0;
-
-unsigned long dprof_shift = 0;
-unsigned long dprof_len = 0;
-unsigned int * dprof_buffer = NULL;
+unsigned long dprof_shift;
+unsigned long dprof_len;
+unsigned int *dprof_buffer;
 
-int piranha_simulator = 0;
+int piranha_simulator;
+
+int boot_cpuid;
 
 extern char _end[];
 
@@ -92,7 +95,7 @@ extern unsigned long embedded_sysmap_end
 extern unsigned long iSeries_recal_tb;
 extern unsigned long iSeries_recal_titan;
 
-static int mf_initialized = 0;
+static int mf_initialized;
 
 struct MemoryBlock {
 	unsigned long absStart;
@@ -106,30 +109,30 @@ struct MemoryBlock {
  * and return the number of physical blocks and fill in the array of
  * block data.
  */
-
-unsigned long iSeries_process_Condor_mainstore_vpd( struct MemoryBlock *mb_array, unsigned long max_entries )
+unsigned long iSeries_process_Condor_mainstore_vpd(struct MemoryBlock *mb_array,
+		unsigned long max_entries)
 {
-	/* Determine if absolute memory has any
-	 * holes so that we can interpret the
-	 * access map we get back from the hypervisor
-	 * correctly.
-	 */
-	
 	unsigned long holeFirstChunk, holeSizeChunks;
 	unsigned long numMemoryBlocks = 1;
-	struct IoHriMainStoreSegment4 * msVpd = (struct IoHriMainStoreSegment4 *)xMsVpd;
+	struct IoHriMainStoreSegment4 *msVpd =
+		(struct IoHriMainStoreSegment4 *)xMsVpd;
 	unsigned long holeStart = msVpd->nonInterleavedBlocksStartAdr;
-	unsigned long holeEnd   = msVpd->nonInterleavedBlocksEndAdr;
+	unsigned long holeEnd = msVpd->nonInterleavedBlocksEndAdr;
 	unsigned long holeSize = holeEnd - holeStart;
 
 	printk("Mainstore_VPD: Condor\n");
-
+	/*
+	 * Determine if absolute memory has any
+	 * holes so that we can interpret the
+	 * access map we get back from the hypervisor
+	 * correctly.
+	 */
 	mb_array[0].logicalStart = 0;
-	mb_array[0].logicalEnd   = 0x100000000;
-	mb_array[0].absStart     = 0;
-	mb_array[0].absEnd       = 0x100000000;
+	mb_array[0].logicalEnd = 0x100000000;
+	mb_array[0].absStart = 0;
+	mb_array[0].absEnd = 0x100000000;
 
-	if ( holeSize ) {
+	if (holeSize) {
 		numMemoryBlocks = 2;
 		holeStart = holeStart & 0x000fffffffffffff;
 		holeStart = addr_to_chunk(holeStart);
@@ -138,275 +141,264 @@ unsigned long iSeries_process_Condor_mai
 		holeSizeChunks = holeSize;
 		printk( "Main store hole: start chunk = %0lx, size = %0lx chunks\n",
 				holeFirstChunk, holeSizeChunks );
-		mb_array[0].logicalEnd   = holeFirstChunk;
-		mb_array[0].absEnd       = holeFirstChunk;
+		mb_array[0].logicalEnd = holeFirstChunk;
+		mb_array[0].absEnd = holeFirstChunk;
 		mb_array[1].logicalStart = holeFirstChunk;
-		mb_array[1].logicalEnd   = 0x100000000 - holeSizeChunks;
-		mb_array[1].absStart     = holeFirstChunk + holeSizeChunks;
-		mb_array[1].absEnd       = 0x100000000;
+		mb_array[1].logicalEnd = 0x100000000 - holeSizeChunks;
+		mb_array[1].absStart = holeFirstChunk + holeSizeChunks;
+		mb_array[1].absEnd = 0x100000000;
 	}
-
-	
 	return numMemoryBlocks;
 }
 
-#define MaxSegmentAreas 32
-#define MaxSegmentAdrRangeBlocks 128
-#define MaxAreaRangeBlocks 4
-unsigned long iSeries_process_Regatta_mainstore_vpd( struct MemoryBlock *mb_array, unsigned long max_entries )
+#define MaxSegmentAreas			32
+#define MaxSegmentAdrRangeBlocks	128
+#define MaxAreaRangeBlocks		4
+
+unsigned long iSeries_process_Regatta_mainstore_vpd(
+		struct MemoryBlock *mb_array, unsigned long max_entries)
 {
-	struct IoHriMainStoreSegment5 * msVpdP = (struct IoHriMainStoreSegment5 *)xMsVpd;
+	struct IoHriMainStoreSegment5 *msVpdP =
+		(struct IoHriMainStoreSegment5 *)xMsVpd;
 	unsigned long numSegmentBlocks = 0;
 	u32 existsBits = msVpdP->msAreaExists;
 	unsigned long area_num;
 
 	printk("Mainstore_VPD: Regatta\n");
 
-	for ( area_num = 0; area_num < MaxSegmentAreas; ++area_num ) {
+	for (area_num = 0; area_num < MaxSegmentAreas; ++area_num ) {
 		unsigned long numAreaBlocks;
-		struct IoHriMainStoreArea4 * currentArea;
+		struct IoHriMainStoreArea4 *currentArea;
 
-		if ( existsBits & 0x80000000 ) {
+		if (existsBits & 0x80000000) {
 			unsigned long block_num;
 
 			currentArea = &msVpdP->msAreaArray[area_num];
 			numAreaBlocks = currentArea->numAdrRangeBlocks;
-
-			printk("ms_vpd: processing area %2ld  blocks=%ld", area_num, numAreaBlocks);
-
-			for ( block_num = 0; block_num < numAreaBlocks; ++block_num ) {
+			printk("ms_vpd: processing area %2ld  blocks=%ld",
+					area_num, numAreaBlocks);
+			for (block_num = 0; block_num < numAreaBlocks;
+					++block_num ) {
 				/* Process an address range block */
 				struct MemoryBlock tempBlock;
 				unsigned long i;
 
-				tempBlock.absStart = (unsigned long)currentArea->xAdrRangeBlock[block_num].blockStart;
-				tempBlock.absEnd   = (unsigned long)currentArea->xAdrRangeBlock[block_num].blockEnd;
+				tempBlock.absStart =
+					(unsigned long)currentArea->xAdrRangeBlock[block_num].blockStart;
+				tempBlock.absEnd =
+					(unsigned long)currentArea->xAdrRangeBlock[block_num].blockEnd;
 				tempBlock.logicalStart = 0;
 				tempBlock.logicalEnd   = 0;
-
-				printk("\n          block %ld absStart=%016lx absEnd=%016lx", block_num,
-							tempBlock.absStart, tempBlock.absEnd);
-
-				for ( i=0; i<numSegmentBlocks; ++i ) {
-					if ( mb_array[i].absStart == tempBlock.absStart )
+				printk("\n          block %ld absStart=%016lx absEnd=%016lx",
+						block_num, tempBlock.absStart,
+						tempBlock.absEnd);
+
+				for (i = 0; i < numSegmentBlocks; ++i) {
+					if (mb_array[i].absStart ==
+							tempBlock.absStart)
 						break;
 				}
-				if ( i == numSegmentBlocks ) {
-					if ( numSegmentBlocks == max_entries ) {
+				if (i == numSegmentBlocks) {
+					if (numSegmentBlocks == max_entries)
 						panic("iSeries_process_mainstore_vpd: too many memory blocks");
-					}
 					mb_array[numSegmentBlocks] = tempBlock;
 					++numSegmentBlocks;
-				}
-				else {
+				} else
 					printk(" (duplicate)");
-				}
 			}
 			printk("\n");
 		}
 		existsBits <<= 1;
 	}
 	/* Now sort the blocks found into ascending sequence */
-	if ( numSegmentBlocks > 1 ) {
+	if (numSegmentBlocks > 1) {
 		unsigned long m, n;
-		for ( m=0; m<numSegmentBlocks-1; ++m ) {
-			for ( n=numSegmentBlocks-1; m<n; --n ) {
-				if ( mb_array[n].absStart < mb_array[n-1].absStart ) {
+
+		for (m = 0; m < numSegmentBlocks - 1; ++m) {
+			for (n = numSegmentBlocks - 1; m < n; --n) {
+				if (mb_array[n].absStart <
+						mb_array[n-1].absStart) {
 					struct MemoryBlock tempBlock;
+
 					tempBlock = mb_array[n];
 					mb_array[n] = mb_array[n-1];
 					mb_array[n-1] = tempBlock;
 				}
-				
 			}
 		}
 	}
-	/* Assign "logical" addresses to each block.  These
+	/*
+	 * Assign "logical" addresses to each block.  These
 	 * addresses correspond to the hypervisor "bitmap" space.
 	 * Convert all addresses into units of 256K chunks.
 	 */
 	{
 	unsigned long i, nextBitmapAddress;
+
 	printk("ms_vpd: %ld sorted memory blocks\n", numSegmentBlocks);
 	nextBitmapAddress = 0;
-	for ( i=0; i<numSegmentBlocks; ++i ) {
-		unsigned long length = mb_array[i].absEnd - mb_array[i].absStart;
+	for (i = 0; i < numSegmentBlocks; ++i) {
+		unsigned long length = mb_array[i].absEnd -
+			mb_array[i].absStart;
+
 		mb_array[i].logicalStart = nextBitmapAddress;
 		mb_array[i].logicalEnd = nextBitmapAddress + length;
 		nextBitmapAddress += length;
 		printk("          Bitmap range: %016lx - %016lx\n"
-		       "        Absolute range: %016lx - %016lx\n",
-				mb_array[i].logicalStart, mb_array[i].logicalEnd, 
+				"        Absolute range: %016lx - %016lx\n",
+				mb_array[i].logicalStart,
+				mb_array[i].logicalEnd, 
 				mb_array[i].absStart, mb_array[i].absEnd);
-		mb_array[i].absStart     = addr_to_chunk( mb_array[i].absStart & 0x000fffffffffffff );
-		mb_array[i].absEnd       = addr_to_chunk( mb_array[i].absEnd & 0x000fffffffffffff );
-		mb_array[i].logicalStart = addr_to_chunk( mb_array[i].logicalStart );
-		mb_array[i].logicalEnd   = addr_to_chunk( mb_array[i].logicalEnd );
+		mb_array[i].absStart = addr_to_chunk(mb_array[i].absStart &
+				0x000fffffffffffff);
+		mb_array[i].absEnd = addr_to_chunk(mb_array[i].absEnd &
+				0x000fffffffffffff);
+		mb_array[i].logicalStart =
+			addr_to_chunk(mb_array[i].logicalStart);
+		mb_array[i].logicalEnd = addr_to_chunk(mb_array[i].logicalEnd);
 	}
 	}
 
 	return numSegmentBlocks;
-
 }
 
-unsigned long iSeries_process_mainstore_vpd( struct MemoryBlock *mb_array, unsigned long max_entries )
+unsigned long iSeries_process_mainstore_vpd(struct MemoryBlock *mb_array,
+		unsigned long max_entries)
 {
 	unsigned long i;
 	unsigned long mem_blocks = 0;
+
 	if (cur_cpu_spec->cpu_features & CPU_FTR_SLB)
-		mem_blocks = iSeries_process_Regatta_mainstore_vpd( mb_array, max_entries );
+		mem_blocks = iSeries_process_Regatta_mainstore_vpd(mb_array,
+				max_entries);
 	else
-		mem_blocks = iSeries_process_Condor_mainstore_vpd( mb_array, max_entries );
+		mem_blocks = iSeries_process_Condor_mainstore_vpd(mb_array,
+				max_entries);
 
 	printk("Mainstore_VPD: numMemoryBlocks = %ld \n", mem_blocks);
-	for ( i=0; i<mem_blocks; ++i ) {
+	for (i = 0; i < mem_blocks; ++i) {
 		printk("Mainstore_VPD: block %3ld logical chunks %016lx - %016lx\n"
 		       "                             abs chunks %016lx - %016lx\n",
 			i, mb_array[i].logicalStart, mb_array[i].logicalEnd,
 			mb_array[i].absStart, mb_array[i].absEnd);
 	}
-
 	return mem_blocks;
 }
 
-/*
- * void __init iSeries_init_early()
- */
-
-
-
-void __init
-iSeries_init_early(void)
+void __init iSeries_init_early(void)
 {
-#ifdef CONFIG_PPC_ISERIES
 	ppcdbg_initialize();
-	
+
 #if defined(CONFIG_BLK_DEV_INITRD)
 	/*
 	 * If the init RAM disk has been configured and there is
 	 * a non-zero starting address for it, set it up
 	 */
-
-	if ( naca->xRamDisk ) {
+	if (naca->xRamDisk) {
 		initrd_start = (unsigned long)__va(naca->xRamDisk);
-		initrd_end   = initrd_start + naca->xRamDiskSize * PAGE_SIZE;
+		initrd_end = initrd_start + naca->xRamDiskSize * PAGE_SIZE;
 		initrd_below_start_ok = 1;	// ramdisk in kernel space
 		ROOT_DEV = Root_RAM0;
-
-		if ( ((rd_size*1024)/PAGE_SIZE) < naca->xRamDiskSize )
-			rd_size = (naca->xRamDiskSize*PAGE_SIZE)/1024;
+		if (((rd_size * 1024) / PAGE_SIZE) < naca->xRamDiskSize)
+			rd_size = (naca->xRamDiskSize * PAGE_SIZE) / 1024;
 	} else
-	
 #endif /* CONFIG_BLK_DEV_INITRD */
-	  {
-                
-	    /*		ROOT_DEV = MKDEV( VIODASD_MAJOR, 1 ); */
-	  }
+	{
+	    /* ROOT_DEV = MKDEV(VIODASD_MAJOR, 1); */
+	}
 
 	iSeries_recal_tb = get_tb();
 	iSeries_recal_titan = HvCallXm_loadTod();
 
-	ppc_md.setup_arch	 	= iSeries_setup_arch;
-	ppc_md.setup_residual	 	= iSeries_setup_residual;
-	ppc_md.get_cpuinfo	 	= iSeries_get_cpuinfo;
-	ppc_md.init_IRQ		 	= iSeries_init_IRQ;
-	ppc_md.get_irq		 	= iSeries_get_irq;
-	ppc_md.init		 	= NULL;
-
-	ppc_md.restart		 	= iSeries_restart;
-	ppc_md.power_off	 	= iSeries_power_off;
-	ppc_md.halt		 	= iSeries_halt;
-
-	ppc_md.get_boot_time		= iSeries_get_boot_time;
-	ppc_md.set_rtc_time	 	= iSeries_set_rtc_time;
-	ppc_md.get_rtc_time	 	= iSeries_get_rtc_time;
-	ppc_md.calibrate_decr	 	= iSeries_calibrate_decr;
-	ppc_md.progress			= iSeries_progress;
+	ppc_md.setup_arch = iSeries_setup_arch;
+	ppc_md.setup_residual = iSeries_setup_residual;
+	ppc_md.get_cpuinfo = iSeries_get_cpuinfo;
+	ppc_md.init_IRQ = iSeries_init_IRQ;
+	ppc_md.init_irq_desc = iSeries_init_irq_desc;
+	ppc_md.get_irq = iSeries_get_irq;
+	ppc_md.init = NULL;
+
+	ppc_md.restart = iSeries_restart;
+	ppc_md.power_off = iSeries_power_off;
+	ppc_md.halt = iSeries_halt;
+
+	ppc_md.get_boot_time = iSeries_get_boot_time;
+	ppc_md.set_rtc_time = iSeries_set_rtc_time;
+	ppc_md.get_rtc_time = iSeries_get_rtc_time;
+	ppc_md.calibrate_decr = iSeries_calibrate_decr;
+	ppc_md.progress = iSeries_progress;
 
 	hpte_init_iSeries();
 	tce_init_iSeries();
 
-	/* Initialize the table which translate Linux physical addresses to
+	/*
+	 * Initialize the table which translate Linux physical addresses to
 	 * AS/400 absolute addresses
 	 */
-
 	build_iSeries_Memory_Map();
-
 	setup_iSeries_cache_sizes();
-
 	/* Initialize machine-dependency vectors */
-
-
 #ifdef CONFIG_SMP
 	smp_init_iSeries();
 #endif
-
-	if ( itLpNaca.xPirEnvironMode == 0 ) 
+	if (itLpNaca.xPirEnvironMode == 0) 
 		piranha_simulator = 1;
-#endif
 }
 
-/*
- * void __init iSeries_init()
- */
-
-void __init
-iSeries_init(unsigned long r3, unsigned long r4, unsigned long r5, 
+void __init iSeries_init(unsigned long r3, unsigned long r4, unsigned long r5, 
 	   unsigned long r6, unsigned long r7)
 {
+	char *p, *q;
+
 	/* Associate Lp Event Queue 0 with processor 0 */
-	HvCallEvent_setLpEventQueueInterruptProc( 0, 0 );
+	HvCallEvent_setLpEventQueueInterruptProc(0, 0);
 
-	{
-		/* copy the command line parameter from the primary VSP  */
-		char *p, *q;
-		HvCallEvent_dmaToSp( cmd_line,
-				     2*64*1024,
-				     256,
-				     HvLpDma_Direction_RemoteToLocal );
-
-		p = q = cmd_line + 255;
-		while( p > cmd_line ) {
-			if ((*p == 0) || (*p == ' ') || (*p == '\n'))
-				--p;
-			else
-				break;
-		}
-		if ( p < q )
-			*(p+1) = 0;
+	/* copy the command line parameter from the primary VSP  */
+	HvCallEvent_dmaToSp(cmd_line, 2 * 64* 1024, 256,
+			HvLpDma_Direction_RemoteToLocal);
+
+	p = q = cmd_line + 255;
+	while (p > cmd_line) {
+		if ((*p == 0) || (*p == ' ') || (*p == '\n'))
+			--p;
+		else
+			break;
 	}
+	if (p < q)
+		*(p + 1) = 0;
 
         if (strstr(cmd_line, "dprofile=")) {
-                char *p, *q;
-
                 for (q = cmd_line; (p = strstr(q, "dprofile=")) != 0; ) {
 			unsigned long size, new_klimit;
+
                         q = p + 9;
-                        if (p > cmd_line && p[-1] != ' ')
+                        if ((p > cmd_line) && (p[-1] != ' '))
                                 continue;
                         dprof_shift = simple_strtoul(q, &q, 0);
-			dprof_len = (unsigned long)_etext - (unsigned long)_stext;
+			dprof_len = (unsigned long)_etext -
+				(unsigned long)_stext;
 			dprof_len >>= dprof_shift;
-			size = ((dprof_len * sizeof(unsigned int)) + (PAGE_SIZE-1)) & PAGE_MASK;
-			dprof_buffer = (unsigned int *)((klimit + (PAGE_SIZE-1)) & PAGE_MASK);
+			size = ((dprof_len * sizeof(unsigned int)) +
+					(PAGE_SIZE-1)) & PAGE_MASK;
+			dprof_buffer = (unsigned int *)((klimit +
+						(PAGE_SIZE-1)) & PAGE_MASK);
 			new_klimit = ((unsigned long)dprof_buffer) + size;
-			lmb_reserve( __pa(klimit), (new_klimit-klimit));
+			lmb_reserve(__pa(klimit), (new_klimit-klimit));
 			klimit = new_klimit;
-			memset( dprof_buffer, 0, size );
+			memset(dprof_buffer, 0, size);
                 }
         }
 
 	iSeries_setup_dprofile();
 
-	iSeries_proc_early_init();	
+	iSeries_proc_early_init();
 	mf_init();
 	mf_initialized = 1;
 	mb();
 
-	iSeries_proc_callback( &pmc_proc_init );
+	iSeries_proc_callback(&pmc_proc_init);
 }
 
-#ifdef CONFIG_PPC_ISERIES
 /*
  * The iSeries may have very large memories ( > 128 GB ) and a partition
  * may get memory in "chunks" that may be anywhere in the 2**52 real
@@ -444,9 +436,10 @@ static void __init build_iSeries_Memory_
 
 	/* Chunk size on iSeries is 256K bytes */
 	totalChunks = (u32)HvLpConfig_getMsChunks();
-	klimit = msChunks_alloc(klimit, totalChunks, 1UL<<18);
+	klimit = msChunks_alloc(klimit, totalChunks, 1UL << 18);
 
-	/* Get absolute address of our load area
+	/*
+	 * Get absolute address of our load area
 	 * and map it to physical address 0
 	 * This guarantees that the loadarea ends up at physical 0
 	 * otherwise, it might not be returned by PLIC as the first
@@ -456,63 +449,68 @@ static void __init build_iSeries_Memory_
 	loadAreaFirstChunk = (u32)addr_to_chunk(itLpNaca.xLoadAreaAddr);
 	loadAreaSize =  itLpNaca.xLoadAreaChunks;
 
-	/* Only add the pages already mapped here.  
+	/*
+	 * Only add the pages already mapped here.  
 	 * Otherwise we might add the hpt pages 
 	 * The rest of the pages of the load area
 	 * aren't in the HPT yet and can still
 	 * be assigned an arbitrary physical address
 	 */
-	if ( (loadAreaSize * 64) > HvPagesToMap )
+	if ((loadAreaSize * 64) > HvPagesToMap)
 		loadAreaSize = HvPagesToMap / 64;
 
 	loadAreaLastChunk = loadAreaFirstChunk + loadAreaSize - 1;
 
-	/* TODO Do we need to do something if the HPT is in the 64MB load area?
+	/*
+	 * TODO Do we need to do something if the HPT is in the 64MB load area?
 	 * This would be required if the itLpNaca.xLoadAreaChunks includes 
 	 * the HPT size
 	 */
 
-	printk( "Mapping load area - physical addr = 0000000000000000\n"
-                "                    absolute addr = %016lx\n", 
-			chunk_to_addr(loadAreaFirstChunk) );
-	printk( "Load area size %dK\n", loadAreaSize*256 );
+	printk("Mapping load area - physical addr = 0000000000000000\n"
+		"                    absolute addr = %016lx\n",
+		chunk_to_addr(loadAreaFirstChunk));
+	printk("Load area size %dK\n", loadAreaSize * 256);
+	
+	for (nextPhysChunk = 0; nextPhysChunk < loadAreaSize; ++nextPhysChunk)
+		msChunks.abs[nextPhysChunk] =
+			loadAreaFirstChunk + nextPhysChunk;
 	
-	for (	nextPhysChunk = 0; 
-		nextPhysChunk < loadAreaSize; 
-		++nextPhysChunk ) {
-		msChunks.abs[nextPhysChunk] = loadAreaFirstChunk+nextPhysChunk;
-	}
-	
-	/* Get absolute address of our HPT and remember it so
+	/*
+	 * Get absolute address of our HPT and remember it so
 	 * we won't map it to any physical address
 	 */
-
 	hptFirstChunk = (u32)addr_to_chunk(HvCallHpt_getHptAddress());
-	hptSizePages =  (u32)(HvCallHpt_getHptPages());
-	hptSizeChunks = hptSizePages >> (msChunks.chunk_shift-PAGE_SHIFT);
+	hptSizePages = (u32)HvCallHpt_getHptPages();
+	hptSizeChunks = hptSizePages >> (msChunks.chunk_shift - PAGE_SHIFT);
 	hptLastChunk = hptFirstChunk + hptSizeChunks - 1;
-	
-	printk( "HPT absolute addr = %016lx, size = %dK\n",
-			chunk_to_addr(hptFirstChunk), hptSizeChunks*256 );
+
+	printk("HPT absolute addr = %016lx, size = %dK\n",
+			chunk_to_addr(hptFirstChunk), hptSizeChunks * 256);
 
 	/* Fill in the htab_data structure */
-	
 	/* Fill in size of hashed page table */
-	num_ptegs = hptSizePages * (PAGE_SIZE/(sizeof(HPTE)*HPTES_PER_GROUP));
+	num_ptegs = hptSizePages *
+		(PAGE_SIZE / (sizeof(HPTE) * HPTES_PER_GROUP));
 	htab_data.htab_num_ptegs = num_ptegs;
 	htab_data.htab_hash_mask = num_ptegs - 1;
 	
-	/* The actual hashed page table is in the hypervisor, we have no direct access */
+	/*
+	 * The actual hashed page table is in the hypervisor,
+	 * we have no direct access
+	 */
 	htab_data.htab = NULL;
 
-	/* Determine if absolute memory has any
+	/*
+	 * Determine if absolute memory has any
 	 * holes so that we can interpret the
 	 * access map we get back from the hypervisor
 	 * correctly.
 	 */
-	numMemoryBlocks = iSeries_process_mainstore_vpd( mb, 32 );
+	numMemoryBlocks = iSeries_process_mainstore_vpd(mb, 32);
 
-	/* Process the main store access map from the hypervisor
+	/*
+	 * Process the main store access map from the hypervisor
 	 * to build up our physical -> absolute translation table
 	 */
 	curBlock = 0;
@@ -520,30 +518,29 @@ static void __init build_iSeries_Memory_
 	currDword = 0;
 	moreChunks = totalChunks;
 
-	while ( moreChunks ) {
-		map = HvCallSm_get64BitsOfAccessMap( itLpNaca.xLpIndex,
-						     currDword );
+	while (moreChunks) {
+		map = HvCallSm_get64BitsOfAccessMap(itLpNaca.xLpIndex,
+				currDword);
 		thisChunk = currChunk;
-		while ( map ) {
+		while (map) {
 			chunkBit = map >> 63;
 			map <<= 1;
-			if ( chunkBit ) {
+			if (chunkBit) {
 				--moreChunks;
-
-				while ( thisChunk >= mb[curBlock].logicalEnd ) {
+				while (thisChunk >= mb[curBlock].logicalEnd) {
 					++curBlock;
-					if ( curBlock >= numMemoryBlocks )
+					if (curBlock >= numMemoryBlocks)
 						panic("out of memory blocks");
 				}
-				if ( thisChunk < mb[curBlock].logicalStart )
+				if (thisChunk < mb[curBlock].logicalStart)
 					panic("memory block error");
 
-				absChunk = mb[curBlock].absStart + ( thisChunk - mb[curBlock].logicalStart );
-
-				if ( ( ( absChunk < hptFirstChunk ) ||
-				       ( absChunk > hptLastChunk ) ) &&
-				     ( ( absChunk < loadAreaFirstChunk ) ||
-				       ( absChunk > loadAreaLastChunk ) ) ) {
+				absChunk = mb[curBlock].absStart +
+					(thisChunk - mb[curBlock].logicalStart);
+				if (((absChunk < hptFirstChunk) ||
+				     (absChunk > hptLastChunk)) &&
+				    ((absChunk < loadAreaFirstChunk) ||
+				     (absChunk > loadAreaLastChunk))) {
 					msChunks.abs[nextPhysChunk] = absChunk;
 					++nextPhysChunk;
 				}
@@ -553,8 +550,9 @@ static void __init build_iSeries_Memory_
 		++currDword;
 		currChunk += 64;
 	}
-					
-	/* main store size (in chunks) is 
+
+	/*
+	 * main store size (in chunks) is 
 	 *   totalChunks - hptSizeChunks
 	 * which should be equal to 
 	 *   nextPhysChunk
@@ -562,12 +560,12 @@ static void __init build_iSeries_Memory_
 	systemcfg->physicalMemorySize = chunk_to_addr(nextPhysChunk);
 
 	/* Bolt kernel mappings for all of memory */
-	iSeries_bolt_kernel( 0, systemcfg->physicalMemorySize );
+	iSeries_bolt_kernel(0, systemcfg->physicalMemorySize);
 
 	lmb_init();
-	lmb_add( 0, systemcfg->physicalMemorySize );
+	lmb_add(0, systemcfg->physicalMemorySize);
 	lmb_analyze();	/* ?? */
-	lmb_reserve( 0, __pa(klimit));
+	lmb_reserve(0, __pa(klimit));
 
 	/* 
 	 * Hardcode to GP size.  I am not sure where to get this info. DRENG
@@ -579,59 +577,94 @@ static void __init build_iSeries_Memory_
  * Set up the variables that describe the cache line sizes
  * for this machine.
  */
-
 static void __init setup_iSeries_cache_sizes(void)
 {
 	unsigned int i, n;
 	unsigned int procIx = get_paca()->xLpPaca.xDynHvPhysicalProcIndex;
 
-	systemcfg->iCacheL1Size = xIoHriProcessorVpd[procIx].xInstCacheSize * 1024;
-	systemcfg->iCacheL1LineSize = xIoHriProcessorVpd[procIx].xInstCacheOperandSize;
-	systemcfg->dCacheL1Size = xIoHriProcessorVpd[procIx].xDataL1CacheSizeKB * 1024;
-	systemcfg->dCacheL1LineSize = xIoHriProcessorVpd[procIx].xDataCacheOperandSize;
+	systemcfg->iCacheL1Size =
+		xIoHriProcessorVpd[procIx].xInstCacheSize * 1024;
+	systemcfg->iCacheL1LineSize =
+		xIoHriProcessorVpd[procIx].xInstCacheOperandSize;
+	systemcfg->dCacheL1Size =
+		xIoHriProcessorVpd[procIx].xDataL1CacheSizeKB * 1024;
+	systemcfg->dCacheL1LineSize =
+		xIoHriProcessorVpd[procIx].xDataCacheOperandSize;
 	naca->iCacheL1LinesPerPage = PAGE_SIZE / systemcfg->iCacheL1LineSize;
 	naca->dCacheL1LinesPerPage = PAGE_SIZE / systemcfg->dCacheL1LineSize;
 
 	i = systemcfg->iCacheL1LineSize;
 	n = 0;
-	while ((i=(i/2))) ++n;
+	while ((i = (i / 2)))
+		++n;
 	naca->iCacheL1LogLineSize = n;
 
 	i = systemcfg->dCacheL1LineSize;
 	n = 0;
-	while ((i=(i/2))) ++n;
+	while ((i = (i / 2)))
+		++n;
 	naca->dCacheL1LogLineSize = n;
 
-	printk( "D-cache line size = %d\n", (unsigned int)systemcfg->dCacheL1LineSize);
-	printk( "I-cache line size = %d\n", (unsigned int)systemcfg->iCacheL1LineSize);
+	printk("D-cache line size = %d\n",
+			(unsigned int)systemcfg->dCacheL1LineSize);
+	printk("I-cache line size = %d\n",
+			(unsigned int)systemcfg->iCacheL1LineSize);
 }
 
 /*
- * Bolt the kernel addr space into the HPT
+ * Create a pte. Used during initialization only.
  */
+static void iSeries_make_pte(unsigned long va, unsigned long pa,
+			     int mode)
+{
+	HPTE local_hpte, rhpte;
+	unsigned long hash, vpn;
+	long slot;
+
+	vpn = va >> PAGE_SHIFT;
+	hash = hpt_hash(vpn, 0);
+
+	local_hpte.dw1.dword1 = pa | mode;
+	local_hpte.dw0.dword0 = 0;
+	local_hpte.dw0.dw0.avpn = va >> 23;
+	local_hpte.dw0.dw0.bolted = 1;		/* bolted */
+	local_hpte.dw0.dw0.v = 1;
+
+	slot = HvCallHpt_findValid(&rhpte, vpn);
+	if (slot < 0) {
+		/* Must find space in primary group */
+		panic("hash_page: hpte already exists\n");
+	}
+	HvCallHpt_addValidate(slot, 0, (HPTE *)&local_hpte );
+}
 
+/*
+ * Bolt the kernel addr space into the HPT
+ */
 static void __init iSeries_bolt_kernel(unsigned long saddr, unsigned long eaddr)
 {
 	unsigned long pa;
 	unsigned long mode_rw = _PAGE_ACCESSED | _PAGE_COHERENT | PP_RWXX;
 	HPTE hpte;
 
-	for (pa=saddr; pa < eaddr ;pa+=PAGE_SIZE) {
+	for (pa = saddr; pa < eaddr ;pa += PAGE_SIZE) {
 		unsigned long ea = (unsigned long)__va(pa);
-		unsigned long vsid = get_kernel_vsid( ea );
-		unsigned long va = ( vsid << 28 ) | ( pa & 0xfffffff );
+		unsigned long vsid = get_kernel_vsid(ea);
+		unsigned long va = (vsid << 28) | (pa & 0xfffffff);
 		unsigned long vpn = va >> PAGE_SHIFT;
-		unsigned long slot = HvCallHpt_findValid( &hpte, vpn );
-		if ( hpte.dw0.dw0.v ) {
+		unsigned long slot = HvCallHpt_findValid(&hpte, vpn);
+
+		if (hpte.dw0.dw0.v) {
 			/* HPTE exists, so just bolt it */
-			HvCallHpt_setSwBits( slot, 0x10, 0 );
-		} else {
+			HvCallHpt_setSwBits(slot, 0x10, 0);
+			/* And make sure the pp bits are correct */
+			HvCallHpt_setPp(slot, PP_RWXX);
+		} else
 			/* No HPTE exists, so create a new bolted one */
-			build_valid_hpte(vsid, ea, pa, NULL, mode_rw, 1);
-		}
+			iSeries_make_pte(va, (unsigned long)__v2a(ea),
+					mode_rw);
 	}
 }
-#endif /* CONFIG_PPC_ISERIES */
 
 extern unsigned long ppc_proc_freq;
 extern unsigned long ppc_tb_freq;
@@ -639,10 +672,9 @@ extern unsigned long ppc_tb_freq;
 /*
  * Document me.
  */
-void __init
-iSeries_setup_arch(void)
+void __init iSeries_setup_arch(void)
 {
-	void *	eventStack;
+	void *eventStack;
 	unsigned procIx = get_paca()->xLpPaca.xDynHvPhysicalProcIndex;
 
 	/* Add an eye catcher and the systemcfg layout version number */
@@ -657,50 +689,43 @@ iSeries_setup_arch(void)
 	 * we subtract out the KERNELBASE and add in the
 	 * absolute real address of the kernel load area
 	 */
-	
-	eventStack = alloc_bootmem_pages( LpEventStackSize );
-	
-	memset( eventStack, 0, LpEventStackSize );
+	eventStack = alloc_bootmem_pages(LpEventStackSize);
+	memset(eventStack, 0, LpEventStackSize);
 	
 	/* Invoke the hypervisor to initialize the event stack */
-	
-	HvCallEvent_setLpEventStack( 0, eventStack, LpEventStackSize );
-	
+	HvCallEvent_setLpEventStack(0, eventStack, LpEventStackSize);
+
 	/* Initialize fields in our Lp Event Queue */
-	
 	xItLpQueue.xSlicEventStackPtr = (char *)eventStack;
 	xItLpQueue.xSlicCurEventPtr = (char *)eventStack;
 	xItLpQueue.xSlicLastValidEventPtr = (char *)eventStack + 
 					(LpEventStackSize - LpEventMaxSize);
 	xItLpQueue.xIndex = 0;
-	
+
 	/* Compute processor frequency */
-	procFreqHz = (((1UL<<34) * 1000000) / xIoHriProcessorVpd[procIx].xProcFreq );
+	procFreqHz = ((1UL << 34) * 1000000) /
+			xIoHriProcessorVpd[procIx].xProcFreq;
 	procFreqMhz = procFreqHz / 1000000;
-	procFreqMhzHundreths = (procFreqHz/10000) - (procFreqMhz*100);
-
+	procFreqMhzHundreths = (procFreqHz / 10000) - (procFreqMhz * 100);
 	ppc_proc_freq = procFreqHz;
 
 	/* Compute time base frequency */
-	tbFreqHz = (((1UL<<32) * 1000000) / xIoHriProcessorVpd[procIx].xTimeBaseFreq );
+	tbFreqHz = ((1UL << 32) * 1000000) /
+		xIoHriProcessorVpd[procIx].xTimeBaseFreq;
 	tbFreqMhz = tbFreqHz / 1000000;
-	tbFreqMhzHundreths = (tbFreqHz/10000) - (tbFreqMhz*100);
-
+	tbFreqMhzHundreths = (tbFreqHz / 10000) - (tbFreqMhz * 100);
 	ppc_tb_freq = tbFreqHz;
 
 	printk("Max  logical processors = %d\n", 
-			itVpdAreas.xSlicMaxLogicalProcs );
+			itVpdAreas.xSlicMaxLogicalProcs);
 	printk("Max physical processors = %d\n",
-			itVpdAreas.xSlicMaxPhysicalProcs );
-	printk("Processor frequency = %lu.%02lu\n",
-			procFreqMhz, 
-			procFreqMhzHundreths );
-	printk("Time base frequency = %lu.%02lu\n",
-			tbFreqMhz,
-			tbFreqMhzHundreths );
+			itVpdAreas.xSlicMaxPhysicalProcs);
+	printk("Processor frequency = %lu.%02lu\n", procFreqMhz,
+			procFreqMhzHundreths);
+	printk("Time base frequency = %lu.%02lu\n", tbFreqMhz,
+			tbFreqMhzHundreths);
 	systemcfg->processor = xIoHriProcessorVpd[procIx].xPVR;
 	printk("Processor version = %x\n", systemcfg->processor);
-
 }
 
 /*
@@ -715,38 +740,27 @@ iSeries_setup_arch(void)
  *
  * Output(s):
  *  *buffer - Buffer with CPU data.
- *
- * Returns:
- *   The number of bytes copied into 'buffer' if OK, otherwise zero or less
- *   on error.
  */
-void iSeries_setup_residual(struct seq_file *m)
+void iSeries_setup_residual(struct seq_file *m, int cpu_id)
 {
-	
-	seq_printf(m,"clock\t\t: %lu.%02luMhz\n",
-		procFreqMhz, procFreqMhzHundreths );
-	seq_printf(m,"time base\t: %lu.%02luMHz\n",
-		tbFreqMhz, tbFreqMhzHundreths );
-	seq_printf(m,"i-cache\t\t: %d\n",
-		systemcfg->iCacheL1LineSize);
-	seq_printf(m,"d-cache\t\t: %d\n",
-		systemcfg->dCacheL1LineSize);
-
+	seq_printf(m, "clock\t\t: %lu.%02luMhz\n", procFreqMhz,
+			procFreqMhzHundreths);
+	seq_printf(m, "time base\t: %lu.%02luMHz\n", tbFreqMhz,
+			tbFreqMhzHundreths);
+	seq_printf(m, "i-cache\t\t: %d\n", systemcfg->iCacheL1LineSize);
+	seq_printf(m, "d-cache\t\t: %d\n", systemcfg->dCacheL1LineSize);
 }
 
 void iSeries_get_cpuinfo(struct seq_file *m)
 {
-
-	seq_printf(m,"machine\t\t: 64-bit iSeries Logical Partition\n");
-
+	seq_printf(m, "machine\t\t: 64-bit iSeries Logical Partition\n");
 }
 
 /*
  * Document me.
  * and Implement me.
  */
-int
-iSeries_get_irq(struct pt_regs *regs)
+int iSeries_get_irq(struct pt_regs *regs)
 {
 	/* -2 means ignore this interrupt */
 	return -2;
@@ -755,8 +769,7 @@ iSeries_get_irq(struct pt_regs *regs)
 /*
  * Document me.
  */
-void
-iSeries_restart(char *cmd)
+void iSeries_restart(char *cmd)
 {
 	mf_reboot();
 }
@@ -764,8 +777,7 @@ iSeries_restart(char *cmd)
 /*
  * Document me.
  */
-void
-iSeries_power_off(void)
+void iSeries_power_off(void)
 {
 	mf_powerOff();
 }
@@ -773,8 +785,7 @@ iSeries_power_off(void)
 /*
  * Document me.
  */
-void
-iSeries_halt(void)
+void iSeries_halt(void)
 {
 	mf_powerOff();
 }
@@ -792,24 +803,19 @@ extern void setup_default_decr(void);
  *   and sets up the kernel timer decrementer based on that value.
  *
  */
-void __init
-iSeries_calibrate_decr(void)
+void __init iSeries_calibrate_decr(void)
 {
 	unsigned long	cyclesPerUsec;
-
 	struct div_result divres;
 	
-	/* Compute decrementer (and TB) frequency 
-	 * in cycles/sec 
-	 */
+	/* Compute decrementer (and TB) frequency in cycles/sec */
+	cyclesPerUsec = ppc_tb_freq / 1000000;
 
-	cyclesPerUsec = ppc_tb_freq / 1000000;	/* cycles / usec */
-
-	/* Set the amount to refresh the decrementer by.  This
+	/*
+	 * Set the amount to refresh the decrementer by.  This
 	 * is the number of decrementer ticks it takes for 
 	 * 1/HZ seconds.
 	 */
-
 	tb_ticks_per_jiffy = ppc_tb_freq / HZ;
 
 #if 0
@@ -824,47 +830,54 @@ iSeries_calibrate_decr(void)
 	 * that jiffies (and xtime) will match the time returned
 	 * by do_gettimeofday.
 	 */
-	tb_ticks_per_sec   = tb_ticks_per_jiffy * HZ;
+	tb_ticks_per_sec = tb_ticks_per_jiffy * HZ;
 	tb_ticks_per_usec = cyclesPerUsec;
 	tb_to_us = mulhwu_scale_factor(ppc_tb_freq, 1000000);
-	div128_by_32( 1024*1024, 0, tb_ticks_per_sec, &divres );
+	div128_by_32(1024 * 1024, 0, tb_ticks_per_sec, &divres);
 	tb_to_xs = divres.result_low;
 	setup_default_decr();
 }
 
-void __init
-iSeries_progress( char * st, unsigned short code )
+void __init iSeries_progress(char * st, unsigned short code)
 {
-	printk( "Progress: [%04x] - %s\n", (unsigned)code, st );
-	if ( !piranha_simulator && mf_initialized ) {
-	    if (code != 0xffff)
-		mf_displayProgress( code );
-	    else
-		mf_clearSrc();
+	printk("Progress: [%04x] - %s\n", (unsigned)code, st);
+	if (!piranha_simulator && mf_initialized) {
+		if (code != 0xffff)
+			mf_displayProgress(code);
+		else
+			mf_clearSrc();
 	}
 }
 
-
 void iSeries_fixup_klimit(void)
 {
-	/* Change klimit to take into account any ram disk that may be included */
+	/*
+	 * Change klimit to take into account any ram disk
+	 * that may be included
+	 */
 	if (naca->xRamDisk)
-		klimit = KERNELBASE + (u64)naca->xRamDisk + (naca->xRamDiskSize * PAGE_SIZE);
+		klimit = KERNELBASE + (u64)naca->xRamDisk +
+			(naca->xRamDiskSize * PAGE_SIZE);
 	else {
-		/* No ram disk was included - check and see if there was an embedded system map */
-		/* Change klimit to take into account any embedded system map */
+		/*
+		 * No ram disk was included - check and see if there
+		 * was an embedded system map.  Change klimit to take
+		 * into account any embedded system map
+		 */
 		if (embedded_sysmap_end)
-			klimit = KERNELBASE + ((embedded_sysmap_end+4095) & 0xfffffffffffff000);
+			klimit = KERNELBASE + ((embedded_sysmap_end + 4095) &
+					0xfffffffffffff000);
 	}
 }
 
 static void iSeries_setup_dprofile(void)
 {
-	if ( dprof_buffer ) {
+	if (dprof_buffer) {
 		unsigned i;
-		for (i=0; i<NR_CPUS; ++i) {
+
+		for (i = 0; i < NR_CPUS; ++i) {
 			paca[i].prof_shift = dprof_shift;
-			paca[i].prof_len = dprof_len-1;
+			paca[i].prof_len = dprof_len - 1;
 			paca[i].prof_buffer = dprof_buffer;
 			paca[i].prof_stext = (unsigned *)_stext;
 			mb();
diff -puN arch/ppc64/kernel/iSeries_setup.h~linus arch/ppc64/kernel/iSeries_setup.h
--- 25/arch/ppc64/kernel/iSeries_setup.h~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/iSeries_setup.h	2004-01-19 22:17:21.000000000 -0800
@@ -19,25 +19,24 @@
 #ifndef	__ISERIES_SETUP_H__
 #define	__ISERIES_SETUP_H__
 
-extern void		 iSeries_init_early(void);
-extern void		 iSeries_init(unsigned long r3,
-			            unsigned long ird_start,
-				    unsigned long ird_end,
-				    unsigned long cline_start,
-				    unsigned long cline_end);
-extern void		 iSeries_setup_arch(void);
-extern void		 iSeries_setup_residual(struct seq_file *m);
-extern void		 iSeries_get_cpuinfo(struct seq_file *m);
-extern void		 iSeries_init_IRQ(void);
-extern int		 iSeries_get_irq(struct pt_regs *regs);
-extern void		 iSeries_restart(char *cmd);
-extern void		 iSeries_power_off(void);
-extern void		 iSeries_halt(void);
-extern void		 iSeries_time_init(void);
-extern void      iSeries_get_boot_time(struct rtc_time *tm);
-extern int		 iSeries_set_rtc_time(unsigned long now);
-extern unsigned long	 iSeries_get_rtc_time(void);
-extern void		 iSeries_calibrate_decr(void);
-extern void 	 iSeries_progress( char *, unsigned short );
+extern void iSeries_init_early(void);
+extern void iSeries_init(unsigned long r3, unsigned long ird_start,
+		unsigned long ird_end, unsigned long cline_start,
+		unsigned long cline_end);
+extern void iSeries_setup_arch(void);
+extern void iSeries_setup_residual(struct seq_file *m, int cpu_id);
+extern void iSeries_get_cpuinfo(struct seq_file *m);
+extern void iSeries_init_IRQ(void);
+extern void iSeries_init_irq_desc(irq_desc_t *);
+extern int iSeries_get_irq(struct pt_regs *regs);
+extern void iSeries_restart(char *cmd);
+extern void iSeries_power_off(void);
+extern void iSeries_halt(void);
+extern void iSeries_time_init(void);
+extern void iSeries_get_boot_time(struct rtc_time *tm);
+extern int iSeries_set_rtc_time(struct rtc_time *tm);
+extern void iSeries_get_rtc_time(struct rtc_time *tm);
+extern void iSeries_calibrate_decr(void);
+extern void iSeries_progress( char *, unsigned short );
 
 #endif /* __ISERIES_SETUP_H__ */
diff -puN arch/ppc64/kernel/iSeries_VpdInfo.c~linus arch/ppc64/kernel/iSeries_VpdInfo.c
--- 25/arch/ppc64/kernel/iSeries_VpdInfo.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/iSeries_VpdInfo.c	2004-01-19 22:17:21.000000000 -0800
@@ -38,20 +38,20 @@
 #include <asm/iSeries/iSeries_pci.h>
 #include "pci.h"
 
-/************************************************/
-/* Size of Bus VPD data                         */
-/************************************************/
+/*
+ * Size of Bus VPD data
+ */
 #define BUS_VPDSIZE      1024
-/************************************************/
-/* Bus Vpd Tags                                 */
-/************************************************/
+/*
+ * Bus Vpd Tags
+ */
 #define  VpdEndOfDataTag   0x78
 #define  VpdEndOfAreaTag   0x79
 #define  VpdIdStringTag    0x82
 #define  VpdVendorAreaTag  0x84
-/************************************************/
-/* Mfg Area Tags                                */
-/************************************************/
+/*
+ * Mfg Area Tags
+ */
 #define  VpdFruFlag       0x4647     // "FG"
 #define  VpdFruFrameId    0x4649     // "FI"
 #define  VpdSlotMapFormat 0x4D46     // "MF"
@@ -59,9 +59,9 @@
 #define  VpdFruSerial     0x534E     // "SN"
 #define  VpdSlotMap       0x534D     // "SM"
 
-/************************************************/
-/* Structures of the areas                      */
-/************************************************/
+/*
+ * Structures of the areas
+ */
 struct MfgVpdAreaStruct {
 	u16 Tag;
 	u8  TagLength;
@@ -82,168 +82,172 @@ struct SlotMapStruct {
 typedef struct SlotMapStruct SlotMap;
 #define SLOT_ENTRY_SIZE   16
 
-/****************************************************************
- *                                                              *
- * Bus, Card, Board, FrameId, CardLocation.                     *
- ****************************************************************/
-LocationData* iSeries_GetLocationData(struct pci_dev* PciDev)
+/*
+ * Bus, Card, Board, FrameId, CardLocation.
+ */
+LocationData* iSeries_GetLocationData(struct pci_dev *PciDev)
 {
-	struct iSeries_Device_Node* DevNode = (struct iSeries_Device_Node*)PciDev->sysdata;
-	LocationData* LocationPtr = (LocationData*)kmalloc(LOCATION_DATA_SIZE, GFP_KERNEL);
+	struct iSeries_Device_Node *DevNode =
+		(struct iSeries_Device_Node *)PciDev->sysdata;
+	LocationData *LocationPtr =
+		(LocationData *)kmalloc(LOCATION_DATA_SIZE, GFP_KERNEL);
+
 	if (LocationPtr == NULL) {
 		printk("PCI: LocationData area allocation failed!\n");
 		return NULL;
 	}
-	memset(LocationPtr,0,LOCATION_DATA_SIZE);
-	LocationPtr->Bus              = ISERIES_BUS(DevNode);
-	LocationPtr->Board            = DevNode->Board;
-	LocationPtr->FrameId          = DevNode->FrameId;
-	LocationPtr->Card             = PCI_SLOT(DevNode->DevFn);
-	strcpy(&LocationPtr->CardLocation[0],&DevNode->CardLocation[0]);
+	memset(LocationPtr, 0, LOCATION_DATA_SIZE);
+	LocationPtr->Bus = ISERIES_BUS(DevNode);
+	LocationPtr->Board = DevNode->Board;
+	LocationPtr->FrameId = DevNode->FrameId;
+	LocationPtr->Card = PCI_SLOT(DevNode->DevFn);
+	strcpy(&LocationPtr->CardLocation[0], &DevNode->CardLocation[0]);
 	return LocationPtr;
 }
 
-/************************************************************************/
-/* Formats the device information.                                      */
-/* - Pass in pci_dev* pointer to the device.                            */
-/* - Pass in buffer to place the data.  Danger here is the buffer must  */
-/*   be as big as the client says it is.   Should be at least 128 bytes.*/
-/* Return will the length of the string data put in the buffer.         */
-/* Format:                                                              */
-/* PCI: Bus  0, Device 26, Vendor 0x12AE  Frame  1, Card  C10  Ethernet */
-/* controller                                                           */
-/************************************************************************/
-int  iSeries_Device_Information(struct pci_dev* PciDev,char* Buffer, int BufferSize)
+/*
+ * Formats the device information.
+ * - Pass in pci_dev* pointer to the device.
+ * - Pass in buffer to place the data.  Danger here is the buffer must
+ *   be as big as the client says it is.   Should be at least 128 bytes.
+ * Return will the length of the string data put in the buffer.
+ * Format:
+ * PCI: Bus  0, Device 26, Vendor 0x12AE  Frame  1, Card  C10  Ethernet
+ * controller
+ */
+int iSeries_Device_Information(struct pci_dev *PciDev, char *buffer,
+		int BufferSize)
 {
-	struct iSeries_Device_Node* DevNode = (struct iSeries_Device_Node*)PciDev->sysdata;
-	char*          BufPtr  = Buffer;
-	int            LineLen = 0;
-
-	if (DevNode == NULL) {
-		LineLen = sprintf(BufPtr+LineLen, "PCI: iSeries_Device_Information DevNode is NULL");
-		return LineLen;
-	}
-
-	if (BufferSize >= 128) {
-		LineLen =  sprintf(BufPtr+LineLen,"PCI: Bus%3d, Device%3d, Vendor %04X ",
-				   ISERIES_BUS(DevNode), PCI_SLOT(PciDev->devfn),PciDev->vendor);
-
-		LineLen += sprintf(BufPtr+LineLen,"Frame%3d, Card %4s  ", DevNode->FrameId,DevNode->CardLocation);
-
-		if (pci_class_name(PciDev->class >> 8) == 0) {
-			LineLen += sprintf(BufPtr+LineLen,"0x%04X  ",(int)(PciDev->class >> 8));
-		}
-		else {
-			LineLen += sprintf(BufPtr+LineLen,"%s",pci_class_name(PciDev->class >> 8) );
-		}
-	}
-	return LineLen;
+	struct iSeries_Device_Node *DevNode =
+		(struct iSeries_Device_Node *)PciDev->sysdata;
+	int len;
+
+	if (DevNode == NULL)
+		return sprintf(buffer,
+				"PCI: iSeries_Device_Information DevNode is NULL");
+
+	if (BufferSize < 128)
+		return 0;
+
+	len = sprintf(buffer, "PCI: Bus%3d, Device%3d, Vendor %04X ",
+			ISERIES_BUS(DevNode), PCI_SLOT(PciDev->devfn),
+			PciDev->vendor);
+	len += sprintf(buffer + len, "Frame%3d, Card %4s  ",
+			DevNode->FrameId, DevNode->CardLocation);
+#ifdef CONFIG_PCI
+	if (pci_class_name(PciDev->class >> 8) == 0)
+		len += sprintf(buffer + len, "0x%04X  ",
+				(int)(PciDev->class >> 8));
+	else
+		len += sprintf(buffer + len, "%s",
+				pci_class_name(PciDev->class >> 8));
+#endif
+	return len;
 }
-/************************************************************************/
-/* Build a character string of the device location, Frame  1, Card  C10 */
-/************************************************************************/
-int   device_Location(struct pci_dev* PciDev,char* BufPtr)
+
+/*
+ * Build a character string of the device location, Frame  1, Card  C10
+ */
+int device_Location(struct pci_dev *PciDev, char *BufPtr)
 {
-	struct iSeries_Device_Node* DevNode = (struct iSeries_Device_Node*)PciDev->sysdata;
-	return sprintf(BufPtr,"PCI: Bus%3d, AgentId%3d, Vendor %04X, Location %s",
-		       DevNode->DsaAddr.busNumber,
-		       DevNode->AgentId,
-		       DevNode->Vendor,
-		       DevNode->Location);
+	struct iSeries_Device_Node *DevNode =
+		(struct iSeries_Device_Node *)PciDev->sysdata;
+	return sprintf(BufPtr, "PCI: Bus%3d, AgentId%3d, Vendor %04X, Location %s",
+		       DevNode->DsaAddr.Dsa.busNumber, DevNode->AgentId,
+		       DevNode->Vendor, DevNode->Location);
 }
 
-/*****************************************************************/
-/* Parse the Slot Area                                           */
-/*****************************************************************/
-void  iSeries_Parse_SlotArea(SlotMap* MapPtr,int MapLen, struct iSeries_Device_Node* DevNode)
+/*
+ * Parse the Slot Area
+ */
+void iSeries_Parse_SlotArea(SlotMap *MapPtr, int MapLen,
+		struct iSeries_Device_Node *DevNode)
 {
-	int      SlotMapLen = MapLen;
-	SlotMap* SlotMapPtr = MapPtr;
-	/*************************************************************/
-	/* Parse Slot label until we find the one requrested         */
-	/*************************************************************/
+	int SlotMapLen = MapLen;
+	SlotMap *SlotMapPtr = MapPtr;
+
+	/*
+	 * Parse Slot label until we find the one requrested
+	 */
 	while (SlotMapLen > 0) {
 		if (SlotMapPtr->AgentId == DevNode->AgentId ) {
-			/*******************************************************/
-			/* If Phb wasn't found, grab the entry first one found.*/ 
-			/*******************************************************/
-			if (DevNode->PhbId == 0xff) {
+			/*
+			 * If Phb wasn't found, grab the entry first one found.
+			 */
+			if (DevNode->PhbId == 0xff)
 				DevNode->PhbId = SlotMapPtr->PhbId; 
-			}
-			/**************************************************/
-			/* Found it, extract the data.                    */
-			/**************************************************/
+			/* Found it, extract the data. */
 			if (SlotMapPtr->PhbId == DevNode->PhbId ) {
-	        		memcpy(&DevNode->CardLocation,&SlotMapPtr->CardLocation,3);
+	        		memcpy(&DevNode->CardLocation,
+						&SlotMapPtr->CardLocation, 3);
 				DevNode->CardLocation[3]  = 0;
 				break;
 			}
 		}
-		/*********************************************************/
-		/* Point to the next Slot                                */
-		/*********************************************************/
-		SlotMapPtr = (SlotMap*)((char*)SlotMapPtr+SLOT_ENTRY_SIZE);
+		/* Point to the next Slot */
+		SlotMapPtr = (SlotMap *)((char *)SlotMapPtr + SLOT_ENTRY_SIZE);
 		SlotMapLen -= SLOT_ENTRY_SIZE;
 	}
 }
 
-/*****************************************************************/
-/* Parse the Mfg Area                                            */
-/*****************************************************************/
-static void  iSeries_Parse_MfgArea(u8* AreaData,int AreaLen, struct iSeries_Device_Node* DevNode)
+/*
+ * Parse the Mfg Area
+ */
+static void iSeries_Parse_MfgArea(u8 *AreaData, int AreaLen,
+		struct iSeries_Device_Node *DevNode)
 {
-	MfgArea* MfgAreaPtr = (MfgArea*)AreaData;
-	int      MfgAreaLen = AreaLen;
-	u16      SlotMapFmt = 0;
-
-	/*************************************************************/
-	/* Parse Mfg Data                                            */
-	/*************************************************************/
+	MfgArea *MfgAreaPtr = (MfgArea *)AreaData;
+	int MfgAreaLen = AreaLen;
+	u16 SlotMapFmt = 0;
+
+	/* Parse Mfg Data */
 	while (MfgAreaLen > 0) {
-		int MfgTagLen  = MfgAreaPtr->TagLength;
-		/*******************************************************/
-		/* Frame ID         (FI 4649020310 )                   */
-		/*******************************************************/
-		if (MfgAreaPtr->Tag == VpdFruFrameId) {     /* FI  */
+		int MfgTagLen = MfgAreaPtr->TagLength;
+		/* Frame ID         (FI 4649020310 ) */
+		if (MfgAreaPtr->Tag == VpdFruFrameId)		/* FI  */
 			DevNode->FrameId = MfgAreaPtr->AreaData1;
+		/* Slot Map Format  (MF 4D46020004 ) */
+		else if (MfgAreaPtr->Tag == VpdSlotMapFormat)	/* MF  */
+			SlotMapFmt = (MfgAreaPtr->AreaData1 * 256)
+				+ MfgAreaPtr->AreaData2;
+		/* Slot Map         (SM 534D90 */
+		else if (MfgAreaPtr->Tag == VpdSlotMap)	{	/* SM  */
+			SlotMap *SlotMapPtr;
+
+			if (SlotMapFmt == 0x1004)
+				SlotMapPtr = (SlotMap *)((char *)MfgAreaPtr
+						+ MFG_ENTRY_SIZE + 1);
+ 	    		else
+				SlotMapPtr = (SlotMap *)((char *)MfgAreaPtr
+						+ MFG_ENTRY_SIZE);
+	    		iSeries_Parse_SlotArea(SlotMapPtr, MfgTagLen, DevNode);
 		}
-		/*******************************************************/
-		/* Slot Map Format  (MF 4D46020004 )                   */
-		/*******************************************************/
-		else if (MfgAreaPtr->Tag == VpdSlotMapFormat){   /* MF  */
-			SlotMapFmt = (MfgAreaPtr->AreaData1*256)+(MfgAreaPtr->AreaData2);
-		}
-		/*******************************************************/
-		/* Slot Map         (SM 534D90                         */
-		/*******************************************************/
-		else if (MfgAreaPtr->Tag == VpdSlotMap){         /* SM  */
-			SlotMap*  SlotMapPtr;
-			if (SlotMapFmt == 0x1004) SlotMapPtr = (SlotMap*)((char*)MfgAreaPtr+MFG_ENTRY_SIZE+1);
- 	    		else                     SlotMapPtr = (SlotMap*)((char*)MfgAreaPtr+MFG_ENTRY_SIZE);
-	    		iSeries_Parse_SlotArea(SlotMapPtr,MfgTagLen, DevNode);
-		}
-		/*********************************************************/
-		/* Point to the next Mfg Area                            */
-		/* Use defined size, sizeof give wrong answer            */
-		/*********************************************************/
-		MfgAreaPtr = (MfgArea*)((char*)MfgAreaPtr + MfgTagLen + MFG_ENTRY_SIZE);
+		/*
+		 * Point to the next Mfg Area
+		 * Use defined size, sizeof give wrong answer
+		 */
+		MfgAreaPtr = (MfgArea *)((char *)MfgAreaPtr + MfgTagLen
+				+ MFG_ENTRY_SIZE);
 		MfgAreaLen -= (MfgTagLen + MFG_ENTRY_SIZE); 
 	}	
 }
 
-/*****************************************************************/
-/* Look for "BUS".. Data is not Null terminated.                 */
-/* PHBID of 0xFF indicates PHB was not found in VPD Data.        */	
-/*****************************************************************/
-static int iSeries_Parse_PhbId(u8* AreaPtr,int AreaLength)
+/*
+ * Look for "BUS".. Data is not Null terminated.
+ * PHBID of 0xFF indicates PHB was not found in VPD Data.
+ */
+static int iSeries_Parse_PhbId(u8 *AreaPtr, int AreaLength)
 {
-	u8*  PhbPtr  = AreaPtr;
-	int  DataLen = AreaLength;
-	char PhbId   = 0xFF;                   
+	u8 *PhbPtr = AreaPtr;
+	int DataLen = AreaLength;
+	char PhbId = 0xFF;                   
+
 	while (DataLen > 0) {
-		if (*PhbPtr == 'B' && *(PhbPtr+1) == 'U' && *(PhbPtr+2) == 'S') {
+		if ((*PhbPtr == 'B') && (*(PhbPtr + 1) == 'U')
+				&& (*(PhbPtr + 2) == 'S')) {
 			PhbPtr += 3;
-			while(*PhbPtr == ' ') ++PhbPtr;
+			while (*PhbPtr == ' ')
+				++PhbPtr;
 			PhbId = (*PhbPtr & 0x0F);
 			break;
         	}
@@ -253,64 +257,54 @@ static int iSeries_Parse_PhbId(u8* AreaP
 	return PhbId;
 }
 
-/****************************************************************/
-/* Parse out the VPD Areas                                      */
-/****************************************************************/
-static void  iSeries_Parse_Vpd(u8* VpdData, int VpdDataLen, struct iSeries_Device_Node* DevNode)
+/*
+ * Parse out the VPD Areas
+ */
+static void iSeries_Parse_Vpd(u8 *VpdData, int VpdDataLen,
+		struct iSeries_Device_Node *DevNode)
 {
-	u8*  TagPtr  = VpdData;
-	int  DataLen = VpdDataLen-3;
-	/*************************************************************/
-	/* Parse the Areas                                           */
-	/*************************************************************/
-	while (*TagPtr != VpdEndOfAreaTag && DataLen > 0) {
-		int  AreaLen   = *(TagPtr+1) + (*(TagPtr+2)*256);	
-		u8*  AreaData  = TagPtr+3;
+	u8 *TagPtr = VpdData;
+	int DataLen = VpdDataLen - 3;
 
-		if (*TagPtr == VpdIdStringTag) {
-			DevNode->PhbId = iSeries_Parse_PhbId(AreaData,AreaLen);
-		}
-		else if (*TagPtr == VpdVendorAreaTag) {
-	    		iSeries_Parse_MfgArea(AreaData,AreaLen,DevNode);
-		}
-		/*********************************************************
-		 * Point to next Area.
-		 *********************************************************/
+	while ((*TagPtr != VpdEndOfAreaTag) && (DataLen > 0)) {
+		int AreaLen = *(TagPtr + 1) + (*(TagPtr + 2) * 256);	
+		u8 *AreaData  = TagPtr + 3;
+
+		if (*TagPtr == VpdIdStringTag)
+			DevNode->PhbId = iSeries_Parse_PhbId(AreaData, AreaLen);
+		else if (*TagPtr == VpdVendorAreaTag)
+	    		iSeries_Parse_MfgArea(AreaData, AreaLen, DevNode);
+		/* Point to next Area. */
 		TagPtr  = AreaData + AreaLen;
 		DataLen -= AreaLen;
 	}
 }    
 
-/****************************************************************
- *  iSeries_Get_Location_Code(struct iSeries_Device_Node*)      *
- *
- ****************************************************************/
-void  iSeries_Get_Location_Code(struct iSeries_Device_Node* DevNode)
+void iSeries_Get_Location_Code(struct iSeries_Device_Node *DevNode)
 {
-	int  BusVpdLen = 0;
-	u8*  BusVpdPtr = (u8*)kmalloc(BUS_VPDSIZE, GFP_KERNEL);
+	int BusVpdLen = 0;
+	u8 *BusVpdPtr = (u8 *)kmalloc(BUS_VPDSIZE, GFP_KERNEL);
+
 	if (BusVpdPtr == NULL) {
 		printk("PCI: Bus VPD Buffer allocation failure.\n");
 		return;
 	}
-	BusVpdLen  = HvCallPci_getBusVpd(ISERIES_BUS(DevNode),REALADDR(BusVpdPtr),BUS_VPDSIZE);
+	BusVpdLen = HvCallPci_getBusVpd(ISERIES_BUS(DevNode),
+			REALADDR(BusVpdPtr), BUS_VPDSIZE);
 	if (BusVpdLen == 0) {
 		kfree(BusVpdPtr);
 		printk("PCI: Bus VPD Buffer zero length.\n");
 		return;
 	}
-	//printk("PCI: BusVpdPtr: %p, %d\n",BusVpdPtr, BusVpdLen);
-	/*************************************************************/
-	/* Make sure this is what I think it is                      */
-	/*************************************************************/
-	if (*BusVpdPtr != VpdIdStringTag) {               /*0x82     */
+	/* printk("PCI: BusVpdPtr: %p, %d\n",BusVpdPtr, BusVpdLen); */
+	/* Make sure this is what I think it is */
+	if (*BusVpdPtr != VpdIdStringTag) {	/* 0x82 */
 		printk("PCI: Bus VPD Buffer missing starting tag.\n");
 		kfree(BusVpdPtr);
 		return;
 	}
-	/***************************************************************/
-	/***************************************************************/
 	iSeries_Parse_Vpd(BusVpdPtr,BusVpdLen, DevNode);
-	sprintf(DevNode->Location,"Frame%3d, Card %-4s",DevNode->FrameId,DevNode->CardLocation);
+	sprintf(DevNode->Location, "Frame%3d, Card %-4s", DevNode->FrameId,
+			DevNode->CardLocation);
 	kfree(BusVpdPtr);
 }
diff -puN arch/ppc64/kernel/ItLpQueue.c~linus arch/ppc64/kernel/ItLpQueue.c
--- 25/arch/ppc64/kernel/ItLpQueue.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/ItLpQueue.c	2004-01-19 22:17:21.000000000 -0800
@@ -147,17 +147,14 @@ unsigned ItLpQueue_process( struct ItLpQ
 				printk(KERN_INFO "Unexpected Lp Event type=%d\n", nextLpEvent->xType );
 			
 			ItLpQueue_clearValid( nextLpEvent );
-		}
-		else 	/* No more valid events
-			 * If overflow events are pending
-			 * process them
+		} else if ( lpQueue->xPlicOverflowIntPending )
+			/*
+			 * No more valid events. If overflow events are
+			 * pending process them
 			 */
-			if ( lpQueue->xPlicOverflowIntPending ) {
-				HvCallEvent_getOverflowLpEvents( 
-						lpQueue->xIndex);
-			}
-			else	/* If nothing left then we are done */
-				break;
+			HvCallEvent_getOverflowLpEvents( lpQueue->xIndex);
+		else
+			break;
 	}
 
 	ItLpQueueInProcess = 0;
diff -puN /dev/null arch/ppc64/kernel/lparcfg.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/ppc64/kernel/lparcfg.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,478 @@
+/*
+ * PowerPC64 LPAR Configuration Information Driver
+ *
+ * Dave Engebretsen engebret@us.ibm.com
+ *    Copyright (c) 2003 Dave Engebretsen
+ * Will Schmidt willschm@us.ibm.com
+ *    SPLPAR updates, Copyright (c) 2003 Will Schmidt IBM Corporation.
+ *
+ *      This program is free software; you can redistribute it and/or
+ *      modify it under the terms of the GNU General Public License
+ *      as published by the Free Software Foundation; either version
+ *      2 of the License, or (at your option) any later version.
+ *
+ * This driver creates a proc file at /proc/ppc64/lparcfg which contains
+ * keyword - value pairs that specify the configuration of the partition.
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <asm/uaccess.h>
+#include <asm/iSeries/HvLpConfig.h>
+#include <asm/iSeries/ItLpPaca.h>
+#include <asm/hvcall.h>
+#include <asm/cputable.h>
+
+#define MODULE_VERSION "1.0"
+#define MODULE_NAME "lparcfg"
+
+static struct proc_dir_entry *proc_ppc64_lparcfg;
+#define LPARCFG_BUFF_SIZE 4096
+
+#ifdef CONFIG_PPC_ISERIES
+static unsigned char e2a(unsigned char x)
+{
+        switch (x) {
+        case 0xF0:
+                return '0';
+        case 0xF1:
+                return '1';
+        case 0xF2:
+                return '2';
+        case 0xF3:
+                return '3';
+        case 0xF4:
+                return '4';
+        case 0xF5:
+                return '5';
+        case 0xF6:
+                return '6';
+        case 0xF7:
+                return '7';
+        case 0xF8:
+                return '8';
+        case 0xF9:
+                return '9';
+        case 0xC1:
+                return 'A';
+        case 0xC2:
+                return 'B';
+        case 0xC3:
+                return 'C';
+        case 0xC4:
+                return 'D';
+        case 0xC5:
+                return 'E';
+        case 0xC6:
+                return 'F';
+        case 0xC7:
+                return 'G';
+        case 0xC8:
+                return 'H';
+        case 0xC9:
+                return 'I';
+        case 0xD1:
+                return 'J';
+        case 0xD2:
+                return 'K';
+        case 0xD3:
+                return 'L';
+        case 0xD4:
+                return 'M';
+        case 0xD5:
+                return 'N';
+        case 0xD6:
+                return 'O';
+        case 0xD7:
+                return 'P';
+        case 0xD8:
+                return 'Q';
+        case 0xD9:
+                return 'R';
+        case 0xE2:
+                return 'S';
+        case 0xE3:
+                return 'T';
+        case 0xE4:
+                return 'U';
+        case 0xE5:
+                return 'V';
+        case 0xE6:
+                return 'W';
+        case 0xE7:
+                return 'X';
+        case 0xE8:
+                return 'Y';
+        case 0xE9:
+                return 'Z';
+        }
+        return ' ';
+}
+
+/* 
+ * Methods used to fetch LPAR data when running on an iSeries platform.
+ */
+static int lparcfg_data(unsigned char *buf, unsigned long size)
+{
+	unsigned long n = 0, pool_id, lp_index; 
+	int shared, entitled_capacity, max_entitled_capacity;
+	int processors, max_processors;
+	struct paca_struct *lpaca = get_paca();
+
+	if((buf == NULL) || (size > LPARCFG_BUFF_SIZE)) {
+		return -EFAULT;
+	}
+	memset(buf, 0, size); 
+
+	shared = (int)(lpaca->xLpPacaPtr->xSharedProc);
+	n += snprintf(buf, LPARCFG_BUFF_SIZE - n,
+		      "serial_number=%c%c%c%c%c%c%c\n", 
+		      e2a(xItExtVpdPanel.mfgID[2]),
+		      e2a(xItExtVpdPanel.mfgID[3]),
+		      e2a(xItExtVpdPanel.systemSerial[1]),
+		      e2a(xItExtVpdPanel.systemSerial[2]),
+		      e2a(xItExtVpdPanel.systemSerial[3]),
+		      e2a(xItExtVpdPanel.systemSerial[4]),
+		      e2a(xItExtVpdPanel.systemSerial[5])); 
+
+	n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+		      "system_type=%c%c%c%c\n",
+		      e2a(xItExtVpdPanel.machineType[0]),
+		      e2a(xItExtVpdPanel.machineType[1]),
+		      e2a(xItExtVpdPanel.machineType[2]),
+		      e2a(xItExtVpdPanel.machineType[3])); 
+
+	lp_index = HvLpConfig_getLpIndex(); 
+	n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+		      "partition_id=%d\n", (int)lp_index); 
+
+	n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+		      "system_active_processors=%d\n", 
+		      (int)HvLpConfig_getSystemPhysicalProcessors()); 
+
+	n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+		      "system_potential_processors=%d\n", 
+		      (int)HvLpConfig_getSystemPhysicalProcessors()); 
+
+	processors = (int)HvLpConfig_getPhysicalProcessors(); 
+	n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+		      "partition_active_processors=%d\n", processors);  
+
+	max_processors = (int)HvLpConfig_getMaxPhysicalProcessors(); 
+	n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+		      "partition_potential_processors=%d\n", max_processors);  
+
+	if(shared) {
+		entitled_capacity = HvLpConfig_getSharedProcUnits(); 
+		max_entitled_capacity = HvLpConfig_getMaxSharedProcUnits(); 
+	} else {
+		entitled_capacity = processors * 100; 
+		max_entitled_capacity = max_processors * 100; 
+	}
+	n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+		      "partition_entitled_capacity=%d\n", entitled_capacity);
+
+	n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+		      "partition_max_entitled_capacity=%d\n", 
+		      max_entitled_capacity);
+
+	if(shared) {
+		pool_id = HvLpConfig_getSharedPoolIndex(); 
+		n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, "pool=%d\n", 
+			      (int)pool_id); 
+		n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+			      "pool_capacity=%d\n", (int)(HvLpConfig_getNumProcsInSharedPool(pool_id)*100)); 
+	}
+
+	n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+		      "shared_processor_mode=%d\n", shared);
+
+	return 0;
+}
+#endif /* CONFIG_PPC_ISERIES */
+
+#ifdef CONFIG_PPC_PSERIES
+/* 
+ * Methods used to fetch LPAR data when running on a pSeries platform.
+ */
+
+/*
+ * H_GET_PPP hcall returns info in 4 parms.
+ *  entitled_capacity,unallocated_capacity,
+ *  aggregation, resource_capability).
+ *
+ *  R4 = Entitled Processor Capacity Percentage. 
+ *  R5 = Unallocated Processor Capacity Percentage.
+ *  R6 (AABBCCDDEEFFGGHH).
+ *      XXXX - reserved (0)
+ *          XXXX - reserved (0)
+ *              XXXX - Group Number
+ *                  XXXX - Pool Number.
+ *  R7 (PPOONNMMLLKKJJII)
+ *      XX - reserved. (0)
+ *        XX - bit 0-6 reserved (0).   bit 7 is Capped indicator.
+ *          XX - variable processor Capacity Weight
+ *            XX - Unallocated Variable Processor Capacity Weight.
+ *              XXXX - Active processors in Physical Processor Pool.
+ *                  XXXX  - Processors active on platform. 
+ */
+unsigned int h_get_ppp(unsigned long *entitled,unsigned long  *unallocated,unsigned long *aggregation,unsigned long *resource)
+{
+	unsigned long rc;
+	rc = plpar_hcall_4out(H_GET_PPP,0,0,0,0,entitled,unallocated,aggregation,resource);
+	return 0;
+}
+
+/*
+ * get_splpar_potential_characteristics().
+ * Retrieve the potential_processors and max_entitled_capacity values
+ * through the get-system-parameter rtas call.
+ */
+#define SPLPAR_CHARACTERISTICS_TOKEN 20
+#define SPLPAR_MAXLENGTH 1026*(sizeof(char))
+unsigned int get_splpar_potential_characteristics(void)
+{
+	/* return 0 for now.  Underlying rtas functionality is not yet complete. 12/01/2003*/
+	return 0; 
+#if 0 
+	long call_status;
+	unsigned long ret[2];
+
+	char * buffer = kmalloc(SPLPAR_MAXLENGTH, GFP_KERNEL);
+
+	printk("token for ibm,get-system-parameter (0x%x)\n",rtas_token("ibm,get-system-parameter"));
+
+	call_status = rtas_call(rtas_token("ibm,get-system-parameter"), 3, 1,
+				NULL,
+				SPLPAR_CHARACTERISTICS_TOKEN,
+				&buffer,
+				SPLPAR_MAXLENGTH,
+				(void *)&ret);
+
+	if (call_status!=0) {
+		printk("Error calling get-system-parameter (0x%lx)\n",call_status);
+		kfree(buffer);
+		return -1;
+	} else {
+		printk("get-system-parameter (%s)\n",buffer);
+		kfree(buffer);
+		/* TODO: Add code here to parse out value for system_potential_processors and partition_max_entitled_capacity */
+		return 1;
+	}
+#endif
+}
+
+static int lparcfg_data(unsigned char *buf, unsigned long size)
+{
+	unsigned long n = 0;
+	int shared, max_entitled_capacity;
+	int processors, system_active_processors, system_potential_processors;
+	struct device_node *root;
+	const char *model = "";
+	const char *system_id = "";
+	unsigned int *lp_index_ptr, lp_index = 0;
+	struct device_node *rtas_node;
+	int *ip;
+	unsigned long h_entitled,h_unallocated,h_aggregation,h_resource;
+
+	if((buf == NULL) || (size > LPARCFG_BUFF_SIZE)) {
+		return -EFAULT;
+	}
+	memset(buf, 0, size); 
+
+	root = find_path_device("/");
+	if (root) {
+		model = get_property(root, "model", NULL);
+		system_id = get_property(root, "system-id", NULL);
+		lp_index_ptr = (unsigned int *)get_property(root, "ibm,partition-no", NULL);
+		if(lp_index_ptr) lp_index = *lp_index_ptr;
+	}
+
+	n  = snprintf(buf, LPARCFG_BUFF_SIZE - n,
+		      "serial_number=%s\n", system_id); 
+
+	n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+		      "system_type=%s\n", model); 
+
+	n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+		      "partition_id=%d\n", (int)lp_index); 
+
+	rtas_node = find_path_device("/rtas");
+	ip = (int *)get_property(rtas_node, "ibm,lrdr-capacity", NULL);
+	if (ip == NULL) {
+		system_active_processors = systemcfg->processorCount; 
+	} else {
+		system_active_processors = *(ip + 4);
+	}
+
+	if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) {
+		h_get_ppp(&h_entitled,&h_unallocated,&h_aggregation,&h_resource);
+#ifdef DEBUG
+		n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+			      "R4=0x%lx\n", h_entitled);
+		n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+			      "R5=0x%lx\n", h_unallocated);
+		n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+			      "R6=0x%lx\n", h_aggregation);
+		n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+			      "R7=0x%lx\n", h_resource);
+#endif /* DEBUG */
+	}
+
+	if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) {
+		system_potential_processors =  get_splpar_potential_characteristics();
+		n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+			      "system_active_processors=%d\n", 
+			      (h_resource >> 2*8) && 0xffff);
+		n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+			      "system_potential_processors=%d\n", 
+			      system_potential_processors);
+	} else {
+		system_potential_processors = system_active_processors;
+		n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+			      "system_active_processors=%d\n", 
+			      system_active_processors);
+		n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+			      "system_potential_processors=%d\n", 
+			      system_potential_processors);
+	}
+
+	processors = systemcfg->processorCount;
+	n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+		      "partition_active_processors=%d\n", processors);  
+	n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+		      "partition_potential_processors=%d\n",
+		      system_active_processors);
+
+	/* max_entitled_capacity will come out of get_splpar_potential_characteristics() when that function is complete */
+	max_entitled_capacity = system_active_processors * 100; 
+	if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) {
+		n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+			      "partition_entitled_capacity=%ld\n", h_entitled);
+	} else {
+		n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+			      "partition_entitled_capacity=%d\n", system_active_processors*100);
+	}
+
+	n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+		      "partition_max_entitled_capacity=%d\n", 
+		      max_entitled_capacity);
+
+	shared = 0;
+	n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+		      "shared_processor_mode=%d\n", shared);
+
+	if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) {
+		n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+			      "pool=%d\n", (h_aggregation >> 0*8)&&0xffff);
+
+		n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+			      "pool_capacity=%d\n", (h_resource >> 3*8) &&0xffff);
+
+		n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+			      "group=%d\n", (h_aggregation >> 2*8)&&0xffff);
+
+		n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+			      "capped=%d\n", (h_resource >> 6*8)&&0x40);
+
+		n += snprintf(buf+n, LPARCFG_BUFF_SIZE - n, 
+			      "capacity_weight=%d\n", (int)(h_resource>>5*8)&0xFF);
+	}
+	return 0;
+}
+#endif /* CONFIG_PPC_PSERIES */
+
+
+static ssize_t lparcfg_read(struct file *file, char *buf,
+			    size_t count, loff_t *ppos)
+{
+	struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+	unsigned long *data = (unsigned long *)dp->data;
+	unsigned long p;
+	ssize_t read;
+	char * pnt;
+
+	if (!data) {
+		printk(KERN_ERR "lparcfg: read failed no data\n");
+		return -EIO;
+	}
+
+	if(ppos) {
+		p = *ppos;
+	} else {
+		return -EFAULT;
+	}
+
+	if (p >= LPARCFG_BUFF_SIZE) return 0;
+
+	lparcfg_data((unsigned char *)data, LPARCFG_BUFF_SIZE); 
+	if (count > (strlen((char *)data) - p))
+		count = (strlen((char *)data)) - p;
+	read = 0;
+
+	pnt = (char *)(data) + p;
+	copy_to_user(buf, (void *)pnt, count);
+	read += count;
+	*ppos += read;
+	return read;
+}
+
+static int lparcfg_open(struct inode * inode, struct file * file)
+{
+	struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+	unsigned int *data = (unsigned int *)dp->data;
+
+	if (!data) {
+		printk(KERN_ERR "lparcfg: open failed no data\n");
+		return -EIO;
+	}
+
+	return 0;
+}
+
+struct file_operations lparcfg_fops = {
+	owner:		THIS_MODULE,
+	read:		lparcfg_read,
+	open:		lparcfg_open,
+};
+
+int __init lparcfg_init(void)
+{
+	struct proc_dir_entry *ent;
+
+	ent = create_proc_entry("ppc64/lparcfg", S_IRUSR, NULL);
+	if (ent) {
+		ent->proc_fops = &lparcfg_fops;
+		ent->data = kmalloc(LPARCFG_BUFF_SIZE, GFP_KERNEL);
+		if (!ent->data) {
+			printk(KERN_ERR "Failed to allocate buffer for lparcfg\n");
+			remove_proc_entry("lparcfg", ent->parent);
+			return -ENOMEM;
+		}
+	} else {
+		printk(KERN_ERR "Failed to create ppc64/lparcfg\n");
+		return -EIO;
+	}
+
+	proc_ppc64_lparcfg = ent;
+	return 0;
+}
+
+void __exit lparcfg_cleanup(void)
+{
+	if (proc_ppc64_lparcfg) {
+		if (proc_ppc64_lparcfg->data) {
+		    kfree(proc_ppc64_lparcfg->data);
+		}
+		remove_proc_entry("lparcfg", proc_ppc64_lparcfg->parent);
+	}
+}
+
+module_init(lparcfg_init);
+module_exit(lparcfg_cleanup);
+MODULE_DESCRIPTION("Interface for LPAR configuration data");
+MODULE_AUTHOR("Dave Engebretsen");
+MODULE_LICENSE("GPL");
diff -puN arch/ppc64/kernel/LparData.c~linus arch/ppc64/kernel/LparData.c
--- 25/arch/ppc64/kernel/LparData.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/LparData.c	2004-01-19 22:17:21.000000000 -0800
@@ -28,29 +28,12 @@
 #include <asm/iSeries/IoHriProcessorVpd.h>
 #include <asm/iSeries/ItSpCommArea.h>
 
-extern char _start_boltedStacks[];
-
-/* The LparMap data is now located at offset 0x6000 in head.S
- * It was put there so that the HvReleaseData could address it
- * with a 32-bit offset as required by the iSeries hypervisor
- *
- * The Naca has a pointer to the ItVpdAreas.  The hypervisor finds
- * the Naca via the HvReleaseData area.  The HvReleaseData has the
- * offset into the Naca of the pointer to the ItVpdAreas.
- */
-
-extern struct ItVpdAreas itVpdAreas;
-
 /* The LpQueue is used to pass event data from the hypervisor to
  * the partition.  This is where I/O interrupt events are communicated.
- * The ItLpQueue must be initialized (even though only to all zeros)
- * If it were uninitialized (in .bss) it would get zeroed after the
- * kernel gets control.  The hypervisor will have filled in some fields
- * before the kernel gets control.  By initializing it we keep it out
- * of the .bss
  */
 
-struct ItLpQueue xItLpQueue = {};
+/* May be filled in by the hypervisor so cannot end up in the BSS */
+struct ItLpQueue xItLpQueue __attribute__((__section__(".data")));
 
 
 /* The HvReleaseData is the root of the information shared between 
@@ -71,7 +54,7 @@ struct HvReleaseData hvReleaseData = {
 	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 },
@@ -141,9 +124,11 @@ struct ItLpNaca itLpNaca = {
 	}
 };
 
-struct ItIplParmsReal xItIplParmsReal = {};
+/* May be filled in by the hypervisor so cannot end up in the BSS */
+struct ItIplParmsReal xItIplParmsReal __attribute__((__section__(".data"))); 
 
-struct ItExtVpdPanel xItExtVpdPanel = {};
+/* May be filled in by the hypervisor so cannot end up in the BSS */
+struct ItExtVpdPanel xItExtVpdPanel __attribute__((__section__(".data")));
 
 #define maxPhysicalProcessors 32
 
@@ -157,10 +142,13 @@ struct IoHriProcessorVpd xIoHriProcessor
 	}
 };
 	
-
-u64    xMsVpd[3400] = {};		/* Space for Main Store Vpd 27,200 bytes */
-
-u64    xRecoveryLogBuffer[32] = {};	/* Space for Recovery Log Buffer */
+/* Space for Main Store Vpd 27,200 bytes */
+/* May be filled in by the hypervisor so cannot end up in the BSS */
+u64    xMsVpd[3400] __attribute__((__section__(".data")));
+
+/* Space for Recovery Log Buffer */
+/* May be filled in by the hypervisor so cannot end up in the BSS */
+u64    xRecoveryLogBuffer[32] __attribute__((__section__(".data")));
 
 struct SpCommArea xSpCommArea = {
 	0xE2D7C3C2,
@@ -169,13 +157,21 @@ struct SpCommArea xSpCommArea = {
 	0, 0, 0, 0, {0}
 };
 
+/* The LparMap data is now located at offset 0x6000 in head.S
+ * It was put there so that the HvReleaseData could address it
+ * with a 32-bit offset as required by the iSeries hypervisor
+ *
+ * The Naca has a pointer to the ItVpdAreas.  The hypervisor finds
+ * the Naca via the HvReleaseData area.  The HvReleaseData has the
+ * offset into the Naca of the pointer to the ItVpdAreas.
+ */
 struct ItVpdAreas itVpdAreas = {
 	0xc9a3e5c1,	/* "ItVA" */
 	sizeof( struct ItVpdAreas ),
 	0, 0,
 	26,		/* # VPD array entries */
 	10,		/* # DMA array entries */
-	MAX_PROCESSORS*2, maxPhysicalProcessors,	/* Max logical, physical procs */
+	NR_CPUS*2, maxPhysicalProcessors,	/* Max logical, physical procs */
 	offsetof(struct ItVpdAreas,xPlicDmaToks),/* offset to DMA toks */
 	offsetof(struct ItVpdAreas,xSlicVpdAdrs),/* offset to VPD addrs */
 	offsetof(struct ItVpdAreas,xPlicDmaLens),/* offset to DMA lens */
@@ -223,7 +219,7 @@ struct ItVpdAreas itVpdAreas = {
 	}
 };
 
-struct msChunks msChunks = {0, 0, 0, 0, NULL};
+struct msChunks msChunks;
 
 /* Depending on whether this is called from iSeries or pSeries setup
  * code, the location of the msChunks struct may or may not have
diff -puN arch/ppc64/kernel/Makefile~linus arch/ppc64/kernel/Makefile
--- 25/arch/ppc64/kernel/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -7,24 +7,29 @@ extra-y		:= head.o vmlinux.lds.s
 
 obj-y               :=	setup.o entry.o traps.o irq.o idle.o \
 			time.o process.o signal.o syscalls.o misc.o ptrace.o \
-			align.o semaphore.o bitops.o stab.o htab.o pacaData.o \
+			align.o semaphore.o bitops.o stab.o pacaData.o \
 			udbg.o binfmt_elf32.o sys_ppc32.o ioctl32.o \
 			ptrace32.o signal32.o pmc.o rtc.o init_task.o \
-			lmb.o pci.o pci_dn.o pci_dma.o cputable.o
+			lmb.o cputable.o
 
-obj-$(CONFIG_PPC_ISERIES) += iSeries_pci.o       iSeries_pci_reset.o \
-			     iSeries_IoMmTable.o iSeries_irq.o \
-			     iSeries_VpdInfo.o   XmPciLpEvent.o \
+obj-$(CONFIG_PCI)	+= pci.o pci_dn.o pci_dma.o
+
+ifdef CONFIG_PPC_ISERIES
+obj-$(CONFIG_PCI)	+= iSeries_pci.o iSeries_pci_reset.o \
+			     iSeries_IoMmTable.o 
+endif
+
+obj-$(CONFIG_PPC_ISERIES) += iSeries_irq.o \
+			     iSeries_VpdInfo.o XmPciLpEvent.o \
 			     HvCall.o HvLpConfig.o LparData.o mf_proc.o \
 			     iSeries_setup.o ItLpQueue.o hvCall.o \
-			     mf.o HvLpEvent.o iSeries_proc.o 
+			     mf.o HvLpEvent.o iSeries_proc.o iSeries_htab.o \
+			     proc_pmc.o
 
 obj-$(CONFIG_PPC_PSERIES) += pSeries_pci.o pSeries_lpar.o pSeries_hvCall.o \
-			     eeh.o rtasd.o nvram.o ras.o
-
-# Change this to pSeries only once we've got iSeries up to date
-obj-y			  += open_pic.o xics.o pSeries_htab.o rtas.o \
-			     chrp_setup.o i8259.o prom.o 
+			     eeh.o nvram.o rtasd.o ras.o \
+			     open_pic.o xics.o pSeries_htab.o rtas.o \
+			     chrp_setup.o i8259.o prom.o vio.o
 
 obj-$(CONFIG_PROC_FS)		+= proc_ppc64.o
 obj-$(CONFIG_RTAS_FLASH)	+= rtas_flash.o
@@ -32,5 +37,8 @@ obj-$(CONFIG_SMP)		+= smp.o
 obj-$(CONFIG_MODULES)		+= module.o ppc_ksyms.o
 obj-$(CONFIG_PPC_RTAS)		+= rtas-proc.o
 obj-$(CONFIG_SCANLOG)		+= scanlog.o
+obj-$(CONFIG_VIOPATH)		+= viopath.o
+obj-$(CONFIG_LPARCFG)		+= lparcfg.o
+
 
 CFLAGS_ioctl32.o += -Ifs/
diff -puN arch/ppc64/kernel/mf.c~linus arch/ppc64/kernel/mf.c
--- 25/arch/ppc64/kernel/mf.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/mf.c	2004-01-19 22:17:21.000000000 -0800
@@ -36,166 +36,125 @@
 #include <asm/nvram.h>
 #include <asm/time.h>
 #include <asm/iSeries/ItSpCommArea.h>
-#include <asm/iSeries/mf_proc.h>
 #include <asm/iSeries/iSeries_proc.h>
 #include <asm/uaccess.h>
 #include <linux/pci.h>
 #include <linux/bcd.h>
 
-extern struct pci_dev * iSeries_vio_dev;
+extern struct pci_dev *iSeries_vio_dev;
 
 /*
  * This is the structure layout for the Machine Facilites LPAR event
  * flows.
  */
-struct VspCmdData;
-struct CeMsgData;
-union SafeCast
-{
-	u64 ptrAsU64;
+union safe_cast {
+	u64 ptr_as_u64;
 	void *ptr;
 };
 
+struct VspCmdData {
+	union safe_cast token;
+	u16 cmd;
+	HvLpIndex lp_index;
+	u8 result_code;
+	u32 reserved;
+	union {
+		u64 state;	/* GetStateOut */
+		u64 ipl_type;	/* GetIplTypeOut, Function02SelectIplTypeIn */
+		u64 ipl_mode;	/* GetIplModeOut, Function02SelectIplModeIn */
+		u64 page[4];	/* GetSrcHistoryIn */
+		u64 flag;	/* GetAutoIplWhenPrimaryIplsOut,
+				   SetAutoIplWhenPrimaryIplsIn,
+				   WhiteButtonPowerOffIn,
+				   Function08FastPowerOffIn,
+				   IsSpcnRackPowerIncompleteOut */
+		struct {
+			u64 token;
+			u64 address_type;
+			u64 side;
+			u32 length;
+			u32 offset;
+		} kern;		/* SetKernelImageIn, GetKernelImageIn,
+				   SetKernelCmdLineIn, GetKernelCmdLineIn */
+		u32 length_out;	/* GetKernelImageOut, GetKernelCmdLineOut */
+		u8 reserved[80];
+	} sub_data;
+};
 
-typedef void (*CeMsgCompleteHandler)( void *token, struct CeMsgData *vspCmdRsp );
-
-struct CeMsgCompleteData
-{
-	CeMsgCompleteHandler xHdlr;
-	void *xToken;
+struct VspRspData {
+	struct semaphore *sem;
+	struct VspCmdData *response;
 };
 
-struct VspRspData
-{
-	struct semaphore *xSemaphore;
-	struct VspCmdData *xResponse;
+struct AllocData {
+	u16 size;
+	u16 type;
+	u32 count;
+	u16 reserved1;
+	u8 reserved2;
+	HvLpIndex target_lp;
 };
 
-struct IoMFLpEvent
-{
-	struct HvLpEvent xHvLpEvent;
+struct CeMsgData;
 
-	u16 xSubtypeRc;
-	u16 xRsvd1;
-	u32 xRsvd2;
-
-	union
-	{
-
-		struct AllocData
-		{
-			u16 xSize;
-			u16 xType;
-			u32 xCount;
-			u16 xRsvd3;
-			u8 xRsvd4;
-			HvLpIndex xTargetLp;
-		} xAllocData;
-
-		struct CeMsgData
-		{
-			u8 xCEMsg[12];
-			char xReserved[4];
-			struct CeMsgCompleteData *xToken;
-		} xCEMsgData;
-
-		struct VspCmdData
-		{
-			union SafeCast xTokenUnion;
-			u16 xCmd;
-			HvLpIndex xLpIndex;
-			u8 xRc;
-			u32 xReserved1;
+typedef void (*CeMsgCompleteHandler)(void *token, struct CeMsgData *vspCmdRsp);
 
-			union VspCmdSubData
-			{
-				struct
-				{
-					u64 xState;
-				} xGetStateOut;
-
-				struct
-				{
-					u64 xIplType;
-				} xGetIplTypeOut, xFunction02SelectIplTypeIn;
-
-				struct
-				{
-					u64 xIplMode;
-				} xGetIplModeOut, xFunction02SelectIplModeIn;
-
-				struct
-				{
-					u64 xPage[4];
-				} xGetSrcHistoryIn;
-
-				struct
-				{
-					u64 xFlag;
-				} xGetAutoIplWhenPrimaryIplsOut,
-					xSetAutoIplWhenPrimaryIplsIn,
-					xWhiteButtonPowerOffIn,
-					xFunction08FastPowerOffIn,
-					xIsSpcnRackPowerIncompleteOut;
-
-				struct
-				{
-					u64 xToken;
-					u64 xAddressType;
-					u64 xSide;
-					u32 xTransferLength;
-					u32 xOffset;
-				} xSetKernelImageIn,
-					xGetKernelImageIn,
-					xSetKernelCmdLineIn,
-					xGetKernelCmdLineIn;
-
-				struct
-				{
-					u32 xTransferLength;
-				} xGetKernelImageOut,xGetKernelCmdLineOut;
-
-
-				u8 xReserved2[80];
-
-			} xSubData;
-		} xVspCmd;
-	} xUnion;
+struct CeMsgCompleteData {
+	CeMsgCompleteHandler handler;
+	void *token;
 };
 
+struct CeMsgData {
+	u8 ce_msg[12];
+	char reserved[4];
+	struct CeMsgCompleteData *completion;
+};
+
+struct IoMFLpEvent {
+	struct HvLpEvent hp_lp_event;
+	u16 subtype_result_code;
+	u16 reserved1;
+	u32 reserved2;
+	union {
+		struct AllocData alloc;
+		struct CeMsgData ce_msg;
+		struct VspCmdData vsp_cmd;
+	} data;
+};
+
+#define subtype_data(a, b, c, d)	\
+		(((a) << 24) + ((b) << 16) + ((c) << 8) + (d))
 
 /*
  * All outgoing event traffic is kept on a FIFO queue.  The first
  * pointer points to the one that is outstanding, and all new
  * requests get stuck on the end.  Also, we keep a certain number of
- * preallocated stack elements so that we can operate very early in
+ * preallocated pending events so that we can operate very early in
  * the boot up sequence (before kmalloc is ready).
  */
-struct StackElement
-{
-	struct StackElement * next;
+struct pending_event {
+	struct pending_event *next;
 	struct IoMFLpEvent event;
 	MFCompleteHandler hdlr;
-	char dmaData[72];
-	unsigned dmaDataLength;
-	unsigned remoteAddress;
+	char dma_data[72];
+	unsigned dma_data_length;
+	unsigned remote_address;
 };
-static spinlock_t spinlock;
-static struct StackElement * head = NULL;
-static struct StackElement * tail = NULL;
-static struct StackElement * avail = NULL;
-static struct StackElement prealloc[16];
+static spinlock_t pending_event_spinlock;
+static struct pending_event *pending_event_head;
+static struct pending_event *pending_event_tail;
+static struct pending_event *pending_event_avail;
+static struct pending_event pending_event_prealloc[16];
 
 /*
- * Put a stack element onto the available queue, so it can get reused.
- * Attention! You must have the spinlock before calling!
+ * Put a pending event onto the available queue, so it can get reused.
+ * Attention! You must have the pending_event_spinlock before calling!
  */
-void free( struct StackElement * element )
+static void free_pending_event(struct pending_event *ev)
 {
-	if ( element != NULL )
-	{
-		element->next = avail;
-		avail = element;
+	if (ev != NULL) {
+		ev->next = pending_event_avail;
+		pending_event_avail = ev;
 	}
 }
 
@@ -203,68 +162,68 @@ void free( struct StackElement * element
  * Enqueue the outbound event onto the stack.  If the queue was
  * empty to begin with, we must also issue it via the Hypervisor
  * interface.  There is a section of code below that will touch
- * the first stack pointer without the protection of the spinlock.
+ * the first stack pointer without the protection of the pending_event_spinlock.
  * This is OK, because we know that nobody else will be modifying
  * the first pointer when we do this.
  */
-static int signalEvent( struct StackElement * newElement )
+static int signal_event(struct pending_event *ev)
 {
 	int rc = 0;
 	unsigned long flags;
 	int go = 1;
-	struct StackElement * element;
+	struct pending_event *ev1;
 	HvLpEvent_Rc hvRc;
 
 	/* enqueue the event */
-	if ( newElement != NULL )
-	{
-		spin_lock_irqsave( &spinlock, flags );
-		if ( head == NULL )
-			head = newElement;
+	if (ev != NULL) {
+		ev->next = NULL;
+		spin_lock_irqsave(&pending_event_spinlock, flags);
+		if (pending_event_head == NULL)
+			pending_event_head = ev;
 		else {
 			go = 0;
-			tail->next = newElement;
+			pending_event_tail->next = ev;
 		}
-		newElement->next = NULL;
-		tail = newElement;
-		spin_unlock_irqrestore( &spinlock, flags );
+		pending_event_tail = ev;
+		spin_unlock_irqrestore(&pending_event_spinlock, flags);
 	}
 
 	/* send the event */
-	while ( go )
-	{
+	while (go) {
 		go = 0;
 
 		/* any DMA data to send beforehand? */
-		if ( head->dmaDataLength > 0 )
-			HvCallEvent_dmaToSp( head->dmaData, head->remoteAddress, head->dmaDataLength, HvLpDma_Direction_LocalToRemote );
-
-		hvRc = HvCallEvent_signalLpEvent(&head->event.xHvLpEvent);
-		if ( hvRc != HvLpEvent_Rc_Good )
-		{
-			printk( KERN_ERR "mf.c: HvCallEvent_signalLpEvent() failed with %d\n", (int)hvRc );
-
-			spin_lock_irqsave( &spinlock, flags );
-			element = head;
-			head = head->next;
-			if ( head != NULL )
+		if (pending_event_head->dma_data_length > 0)
+			HvCallEvent_dmaToSp(pending_event_head->dma_data,
+					pending_event_head->remote_address,
+					pending_event_head->dma_data_length,
+					HvLpDma_Direction_LocalToRemote);
+
+		hvRc = HvCallEvent_signalLpEvent(
+				&pending_event_head->event.hp_lp_event);
+		if (hvRc != HvLpEvent_Rc_Good) {
+			printk(KERN_ERR "mf.c: HvCallEvent_signalLpEvent() failed with %d\n",
+					(int)hvRc);
+
+			spin_lock_irqsave(&pending_event_spinlock, flags);
+			ev1 = pending_event_head;
+			pending_event_head = pending_event_head->next;
+			if (pending_event_head != NULL)
 				go = 1;
-			spin_unlock_irqrestore( &spinlock, flags );
+			spin_unlock_irqrestore(&pending_event_spinlock, flags);
 
-			if ( element == newElement )
+			if (ev1 == ev)
 				rc = -EIO;
-			else {
-				if ( element->hdlr != NULL )
-				{
-					union SafeCast mySafeCast;
-					mySafeCast.ptrAsU64 = element->event.xHvLpEvent.xCorrelationToken;
-					(*element->hdlr)( mySafeCast.ptr, -EIO );
-				}
+			else if (ev1->hdlr != NULL) {
+				union safe_cast mySafeCast;
+
+				mySafeCast.ptr_as_u64 = ev1->event.hp_lp_event.xCorrelationToken;
+				(*ev1->hdlr)(mySafeCast.ptr, -EIO);
 			}
 
-			spin_lock_irqsave( &spinlock, flags );
-			free( element );
-			spin_unlock_irqrestore( &spinlock, flags );
+			spin_lock_irqsave(&pending_event_spinlock, flags);
+			free_pending_event(ev1);
+			spin_unlock_irqrestore(&pending_event_spinlock, flags);
 		}
 	}
 
@@ -272,80 +231,74 @@ static int signalEvent( struct StackElem
 }
 
 /*
- * Allocate a new StackElement structure, and initialize it.
+ * Allocate a new pending_event structure, and initialize it.
  */
-static struct StackElement * newStackElement( void )
+static struct pending_event *new_pending_event(void)
 {
-	struct StackElement * newElement = NULL;
+	struct pending_event *ev = NULL;
 	HvLpIndex primaryLp = HvLpConfig_getPrimaryLpIndex();
 	unsigned long flags;
+	struct HvLpEvent *hev;
 
-	if ( newElement == NULL )
-	{
-		spin_lock_irqsave( &spinlock, flags );
-		if ( avail != NULL )
-		{
-			newElement = avail;
-			avail = avail->next;
-		}
-		spin_unlock_irqrestore( &spinlock, flags );
-	}
-
-	if ( newElement == NULL )
-		newElement = kmalloc(sizeof(struct StackElement),GFP_ATOMIC);
-
-	if ( newElement == NULL )
-	{
-		printk( KERN_ERR "mf.c: unable to kmalloc %ld bytes\n", sizeof(struct StackElement) );
+	spin_lock_irqsave(&pending_event_spinlock, flags);
+	if (pending_event_avail != NULL) {
+		ev = pending_event_avail;
+		pending_event_avail = pending_event_avail->next;
+	}
+	spin_unlock_irqrestore(&pending_event_spinlock, flags);
+	if (ev == NULL)
+		ev = kmalloc(sizeof(struct pending_event),GFP_ATOMIC);
+	if (ev == NULL) {
+		printk(KERN_ERR "mf.c: unable to kmalloc %ld bytes\n",
+				sizeof(struct pending_event));
 		return NULL;
 	}
+	memset(ev, 0, sizeof(struct pending_event));
+	hev = &ev->event.hp_lp_event;
+	hev->xFlags.xValid = 1;
+	hev->xFlags.xAckType = HvLpEvent_AckType_ImmediateAck;
+	hev->xFlags.xAckInd = HvLpEvent_AckInd_DoAck;
+	hev->xFlags.xFunction = HvLpEvent_Function_Int;
+	hev->xType = HvLpEvent_Type_MachineFac;
+	hev->xSourceLp = HvLpConfig_getLpIndex();
+	hev->xTargetLp = primaryLp;
+	hev->xSizeMinus1 = sizeof(ev->event)-1;
+	hev->xRc = HvLpEvent_Rc_Good;
+	hev->xSourceInstanceId = HvCallEvent_getSourceLpInstanceId(primaryLp,
+			HvLpEvent_Type_MachineFac);
+	hev->xTargetInstanceId = HvCallEvent_getTargetLpInstanceId(primaryLp,
+			HvLpEvent_Type_MachineFac);
 
-	memset( newElement, 0, sizeof(struct StackElement) );
-	newElement->event.xHvLpEvent.xFlags.xValid = 1;
-	newElement->event.xHvLpEvent.xFlags.xAckType = HvLpEvent_AckType_ImmediateAck;
-	newElement->event.xHvLpEvent.xFlags.xAckInd = HvLpEvent_AckInd_DoAck;
-	newElement->event.xHvLpEvent.xFlags.xFunction = HvLpEvent_Function_Int;
-	newElement->event.xHvLpEvent.xType = HvLpEvent_Type_MachineFac;
-	newElement->event.xHvLpEvent.xSourceLp = HvLpConfig_getLpIndex();
-	newElement->event.xHvLpEvent.xTargetLp = primaryLp;
-	newElement->event.xHvLpEvent.xSizeMinus1 = sizeof(newElement->event)-1;
-	newElement->event.xHvLpEvent.xRc = HvLpEvent_Rc_Good;
-	newElement->event.xHvLpEvent.xSourceInstanceId = HvCallEvent_getSourceLpInstanceId(primaryLp,HvLpEvent_Type_MachineFac);
-	newElement->event.xHvLpEvent.xTargetInstanceId = HvCallEvent_getTargetLpInstanceId(primaryLp,HvLpEvent_Type_MachineFac);
-
-	return newElement;
+	return ev;
 }
 
-static int signalVspInstruction( struct VspCmdData *vspCmd )
+static int signal_vsp_instruction(struct VspCmdData *vspCmd)
 {
-	struct StackElement * newElement = newStackElement();
-	int rc = 0;
+	struct pending_event *ev = new_pending_event();
+	int rc;
 	struct VspRspData response;
 	DECLARE_MUTEX_LOCKED(Semaphore);
-	response.xSemaphore = &Semaphore;
-	response.xResponse = vspCmd;
 
-	if ( newElement == NULL )
-		rc = -ENOMEM;
-	else {
-		newElement->event.xHvLpEvent.xSubtype = 6;
-		newElement->event.xHvLpEvent.x.xSubtypeData = ('M'<<24)+('F'<<16)+('V'<<8)+('I'<<0);
-		newElement->event.xUnion.xVspCmd.xTokenUnion.ptr = &response;
-		newElement->event.xUnion.xVspCmd.xCmd = vspCmd->xCmd;
-		newElement->event.xUnion.xVspCmd.xLpIndex = HvLpConfig_getLpIndex();
-		newElement->event.xUnion.xVspCmd.xRc = 0xFF;
-		newElement->event.xUnion.xVspCmd.xReserved1 = 0;
-		memcpy(&(newElement->event.xUnion.xVspCmd.xSubData),&(vspCmd->xSubData), sizeof(vspCmd->xSubData));
-		mb();
+	if (ev == NULL)
+		return -ENOMEM;
 
-		rc = signalEvent(newElement);
-	}
+	response.sem = &Semaphore;
+	response.response = vspCmd;
+	ev->event.hp_lp_event.xSubtype = 6;
+	ev->event.hp_lp_event.x.xSubtypeData =
+		subtype_data('M', 'F',  'V',  'I');
+	ev->event.data.vsp_cmd.token.ptr = &response;
+	ev->event.data.vsp_cmd.cmd = vspCmd->cmd;
+	ev->event.data.vsp_cmd.lp_index = HvLpConfig_getLpIndex();
+	ev->event.data.vsp_cmd.result_code = 0xFF;
+	ev->event.data.vsp_cmd.reserved = 0;
+	memcpy(&(ev->event.data.vsp_cmd.sub_data),
+			&(vspCmd->sub_data), sizeof(vspCmd->sub_data));
+	mb();
 
+	rc = signal_event(ev);
 	if (rc == 0)
-	{
 		down(&Semaphore);
-	}
-
 	return rc;
 }
 
@@ -353,46 +306,42 @@ static int signalVspInstruction( struct 
 /*
  * Send a 12-byte CE message to the primary partition VSP object
  */
-static int signalCEMsg( char * ceMsg, void * token )
+static int signal_ce_msg(char *ce_msg, struct CeMsgCompleteData *completion)
 {
-	struct StackElement * newElement = newStackElement();
-	int rc = 0;
+	struct pending_event *ev = new_pending_event();
 
-	if ( newElement == NULL )
-		rc = -ENOMEM;
-	else {
-		newElement->event.xHvLpEvent.xSubtype = 0;
-		newElement->event.xHvLpEvent.x.xSubtypeData = ('M'<<24)+('F'<<16)+('C'<<8)+('E'<<0);
-		memcpy( newElement->event.xUnion.xCEMsgData.xCEMsg, ceMsg, 12 );
-		newElement->event.xUnion.xCEMsgData.xToken = token;
-		rc = signalEvent(newElement);
-	}
+	if (ev == NULL)
+		return -ENOMEM;
 
-	return rc;
+	ev->event.hp_lp_event.xSubtype = 0;
+	ev->event.hp_lp_event.x.xSubtypeData =
+		subtype_data('M',  'F',  'C',  'E');
+	memcpy(ev->event.data.ce_msg.ce_msg, ce_msg, 12);
+	ev->event.data.ce_msg.completion = completion;
+	return signal_event(ev);
 }
 
 /*
  * Send a 12-byte CE message and DMA data to the primary partition VSP object
  */
-static int dmaAndSignalCEMsg( char * ceMsg, void * token, void * dmaData, unsigned dmaDataLength, unsigned remoteAddress )
+static int dma_and_signal_ce_msg(char *ce_msg,
+		struct CeMsgCompleteData *completion, void *dma_data,
+		unsigned dma_data_length, unsigned remote_address)
 {
-	struct StackElement * newElement = newStackElement();
-	int rc = 0;
+	struct pending_event *ev = new_pending_event();
 
-	if ( newElement == NULL )
-		rc = -ENOMEM;
-	else {
-		newElement->event.xHvLpEvent.xSubtype = 0;
-		newElement->event.xHvLpEvent.x.xSubtypeData = ('M'<<24)+('F'<<16)+('C'<<8)+('E'<<0);
-		memcpy( newElement->event.xUnion.xCEMsgData.xCEMsg, ceMsg, 12 );
-		newElement->event.xUnion.xCEMsgData.xToken = token;
-		memcpy( newElement->dmaData, dmaData, dmaDataLength );
-		newElement->dmaDataLength = dmaDataLength;
-		newElement->remoteAddress = remoteAddress;
-		rc = signalEvent(newElement);
-	}
+	if (ev == NULL)
+		return -ENOMEM;
 
-	return rc;
+	ev->event.hp_lp_event.xSubtype = 0;
+	ev->event.hp_lp_event.x.xSubtypeData =
+		subtype_data('M', 'F', 'C', 'E');
+	memcpy(ev->event.data.ce_msg.ce_msg, ce_msg, 12);
+	ev->event.data.ce_msg.completion = completion;
+	memcpy(ev->dma_data, dma_data, dma_data_length);
+	ev->dma_data_length = dma_data_length;
+	ev->remote_address = remote_address;
+	return signal_event(ev);
 }
 
 /*
@@ -401,18 +350,17 @@ static int dmaAndSignalCEMsg( char * ceM
  * this fails (why?), we'll simply force it off in a not-so-nice
  * manner.
  */
-static int shutdown( void )
+static int shutdown(void)
 {
-	int rc = kill_proc(1,SIGINT,1);
+	int rc = kill_proc(1, SIGINT, 1);
 
-	if ( rc )
-	{
-		printk( KERN_ALERT "mf.c: SIGINT to init failed (%d), hard shutdown commencing\n", rc );
+	if (rc) {
+		printk(KERN_ALERT "mf.c: SIGINT to init failed (%d), "
+				"hard shutdown commencing\n", rc);
 		mf_powerOff();
-	}
-	else
-		printk( KERN_INFO "mf.c: init has been successfully notified to proceed with shutdown\n" );
-
+	} else
+		printk(KERN_INFO "mf.c: init has been successfully notified "
+				"to proceed with shutdown\n");
 	return rc;
 }
 
@@ -420,67 +368,64 @@ static int shutdown( void )
  * The primary partition VSP object is sending us a new
  * event flow.  Handle it...
  */
-static void intReceived( struct IoMFLpEvent * event )
+static void intReceived(struct IoMFLpEvent *event)
 {
 	int freeIt = 0;
-	struct StackElement * two = NULL;
+	struct pending_event *two = NULL;
+
 	/* ack the interrupt */
-	event->xHvLpEvent.xRc = HvLpEvent_Rc_Good;
-	HvCallEvent_ackLpEvent( &event->xHvLpEvent );
+	event->hp_lp_event.xRc = HvLpEvent_Rc_Good;
+	HvCallEvent_ackLpEvent(&event->hp_lp_event);
 
-    /* process interrupt */
-	switch( event->xHvLpEvent.xSubtype )
-	{
+	/* process interrupt */
+	switch (event->hp_lp_event.xSubtype) {
 	case 0:	/* CE message */
-		switch( event->xUnion.xCEMsgData.xCEMsg[3] )
-		{
+		switch (event->data.ce_msg.ce_msg[3]) {
 		case 0x5B:	/* power control notification */
-			if ( (event->xUnion.xCEMsgData.xCEMsg[5]&0x20) != 0 )
-			{
-				printk( KERN_INFO "mf.c: Commencing partition shutdown\n" );
-				if ( shutdown() == 0 )
-					signalCEMsg( "\x00\x00\x00\xDB\x00\x00\x00\x00\x00\x00\x00\x00", NULL );
+			if ((event->data.ce_msg.ce_msg[5] & 0x20) != 0) {
+				printk(KERN_INFO "mf.c: Commencing partition shutdown\n");
+				if (shutdown() == 0)
+					signal_ce_msg("\x00\x00\x00\xDB\x00\x00\x00\x00\x00\x00\x00\x00", NULL);
 			}
 			break;
 		case 0xC0:	/* get time */
-			{
-				if ( (head != NULL) && ( head->event.xUnion.xCEMsgData.xCEMsg[3] == 0x40 ) )
-				{
-					freeIt = 1;
-					if ( head->event.xUnion.xCEMsgData.xToken != 0 )
-					{
-						CeMsgCompleteHandler xHdlr = head->event.xUnion.xCEMsgData.xToken->xHdlr;
-						void * token = head->event.xUnion.xCEMsgData.xToken->xToken;
+			if ((pending_event_head == NULL) ||
+			    (pending_event_head->event.data.ce_msg.ce_msg[3]
+			     != 0x40))
+				break;
+			freeIt = 1;
+			if (pending_event_head->event.data.ce_msg.completion != 0) {
+				CeMsgCompleteHandler handler = pending_event_head->event.data.ce_msg.completion->handler;
+				void *token = pending_event_head->event.data.ce_msg.completion->token;
 
-						if (xHdlr != NULL)
-							(*xHdlr)( token, &(event->xUnion.xCEMsgData) );
-					}
-				}
+				if (handler != NULL)
+					(*handler)(token, &(event->data.ce_msg));
 			}
 			break;
 		}
 
 		/* remove from queue */
-		if ( freeIt == 1 )
-		{
+		if (freeIt == 1) {
 			unsigned long flags;
-			spin_lock_irqsave( &spinlock, flags );
-			if ( head != NULL )
-			{
-				struct StackElement *oldHead = head;
-				head = head->next;
-				two = head;
-				free( oldHead );
+
+			spin_lock_irqsave(&pending_event_spinlock, flags);
+			if (pending_event_head != NULL) {
+				struct pending_event *oldHead =
+					pending_event_head;
+
+				pending_event_head = pending_event_head->next;
+				two = pending_event_head;
+				free_pending_event(oldHead);
 			}
-			spin_unlock_irqrestore( &spinlock, flags );
+			spin_unlock_irqrestore(&pending_event_spinlock, flags);
 		}
 
 		/* send next waiting event */
-		if ( two != NULL )
-			signalEvent( NULL );
+		if (two != NULL)
+			signal_event(NULL);
 		break;
 	case 1:	/* IT sys shutdown */
-		printk( KERN_INFO "mf.c: Commencing system shutdown\n" );
+		printk(KERN_INFO "mf.c: Commencing system shutdown\n");
 		shutdown();
 		break;
 	}
@@ -491,81 +436,74 @@ static void intReceived( struct IoMFLpEv
  * of a flow we sent to them.  If there are other flows queued
  * up, we must send another one now...
  */
-static void ackReceived( struct IoMFLpEvent * event )
+static void ackReceived(struct IoMFLpEvent *event)
 {
 	unsigned long flags;
-	struct StackElement * two = NULL;
+	struct pending_event * two = NULL;
 	unsigned long freeIt = 0;
 
-    /* handle current event */
-	if ( head != NULL )
-	{
-		switch( event->xHvLpEvent.xSubtype )
-		{
+	/* handle current event */
+	if (pending_event_head != NULL) {
+		switch (event->hp_lp_event.xSubtype) {
 		case 0:     /* CE msg */
-			if ( event->xUnion.xCEMsgData.xCEMsg[3] == 0x40 )
-			{
-				if ( event->xUnion.xCEMsgData.xCEMsg[2] != 0 )
-				{
+			if (event->data.ce_msg.ce_msg[3] == 0x40) {
+				if (event->data.ce_msg.ce_msg[2] != 0) {
 					freeIt = 1;
-					if ( head->event.xUnion.xCEMsgData.xToken != 0 )
-					{
-						CeMsgCompleteHandler xHdlr = head->event.xUnion.xCEMsgData.xToken->xHdlr;
-						void * token = head->event.xUnion.xCEMsgData.xToken->xToken;
+					if (pending_event_head->event.data.ce_msg.completion
+							!= 0) {
+						CeMsgCompleteHandler handler = pending_event_head->event.data.ce_msg.completion->handler;
+						void *token = pending_event_head->event.data.ce_msg.completion->token;
 
-						if (xHdlr != NULL)
-							(*xHdlr)( token, &(event->xUnion.xCEMsgData) );
+						if (handler != NULL)
+							(*handler)(token, &(event->data.ce_msg));
 					}
 				}
-			} else {
+			} else
 				freeIt = 1;
-			}
 			break;
 		case 4:	/* allocate */
 		case 5:	/* deallocate */
-			if ( head->hdlr != NULL )
-			{
-				union SafeCast mySafeCast;
-				mySafeCast.ptrAsU64 = event->xHvLpEvent.xCorrelationToken;
-				(*head->hdlr)( mySafeCast.ptr, event->xUnion.xAllocData.xCount );
+			if (pending_event_head->hdlr != NULL) {
+				union safe_cast mySafeCast;
+
+				mySafeCast.ptr_as_u64 = event->hp_lp_event.xCorrelationToken;
+				(*pending_event_head->hdlr)(mySafeCast.ptr, event->data.alloc.count);
 			}
 			freeIt = 1;
 			break;
 		case 6:
 			{
-				struct VspRspData *rsp = (struct VspRspData *)event->xUnion.xVspCmd.xTokenUnion.ptr;
+				struct VspRspData *rsp = (struct VspRspData *)event->data.vsp_cmd.token.ptr;
 
-				if (rsp != NULL)
-				{
-					if (rsp->xResponse != NULL)
-						memcpy(rsp->xResponse, &(event->xUnion.xVspCmd), sizeof(event->xUnion.xVspCmd));
-					if (rsp->xSemaphore != NULL)
-						up(rsp->xSemaphore);
-				} else {
-					printk( KERN_ERR "mf.c: no rsp\n");
-				}
+				if (rsp != NULL) {
+					if (rsp->response != NULL)
+						memcpy(rsp->response, &(event->data.vsp_cmd), sizeof(event->data.vsp_cmd));
+					if (rsp->sem != NULL)
+						up(rsp->sem);
+				} else
+					printk(KERN_ERR "mf.c: no rsp\n");
 				freeIt = 1;
 			}
 			break;
 		}
 	}
 	else
-		printk( KERN_ERR "mf.c: stack empty for receiving ack\n" );
+		printk(KERN_ERR "mf.c: stack empty for receiving ack\n");
 
-    /* remove from queue */
-	spin_lock_irqsave( &spinlock, flags );
-	if (( head != NULL ) && ( freeIt == 1 ))
-	{
-		struct StackElement *oldHead = head;
-		head = head->next;
-		two = head;
-		free( oldHead );
+	/* remove from queue */
+	spin_lock_irqsave(&pending_event_spinlock, flags);
+	if ((pending_event_head != NULL) && (freeIt == 1)) {
+		struct pending_event *oldHead = pending_event_head;
+
+		pending_event_head = pending_event_head->next;
+		two = pending_event_head;
+		free_pending_event(oldHead);
 	} 
-	spin_unlock_irqrestore( &spinlock, flags );
+	spin_unlock_irqrestore(&pending_event_spinlock, flags);
 
-    /* send next waiting event */
-	if ( two != NULL )
-		signalEvent( NULL );
+	/* send next waiting event */
+	if (two != NULL)
+		signal_event(NULL);
 }
 
 /*
@@ -574,101 +512,94 @@ static void ackReceived( struct IoMFLpEv
  * parse it enough to know if it is an interrupt or an
  * acknowledge.
  */
-static void hvHandler( struct HvLpEvent * event, struct pt_regs * regs )
+static void hvHandler(struct HvLpEvent *event, struct pt_regs *regs)
 {
-	if ( (event != NULL) && (event->xType == HvLpEvent_Type_MachineFac) )
-	{
-		switch( event->xFlags.xFunction )
-		{
+	if ((event != NULL) && (event->xType == HvLpEvent_Type_MachineFac)) {
+		switch(event->xFlags.xFunction) {
 		case HvLpEvent_Function_Ack:
-			ackReceived( (struct IoMFLpEvent *)event );
+			ackReceived((struct IoMFLpEvent *)event);
 			break;
 		case HvLpEvent_Function_Int:
-			intReceived( (struct IoMFLpEvent *)event );
+			intReceived((struct IoMFLpEvent *)event);
 			break;
 		default:
-			printk( KERN_ERR "mf.c: non ack/int event received\n" );
+			printk(KERN_ERR "mf.c: non ack/int event received\n");
 			break;
 		}
-	}
-	else
-		printk( KERN_ERR "mf.c: alien event received\n" );
+	} else
+		printk(KERN_ERR "mf.c: alien event received\n");
 }
 
 /*
  * Global kernel interface to allocate and seed events into the
  * Hypervisor.
  */
-void mf_allocateLpEvents( HvLpIndex targetLp,
-			  HvLpEvent_Type type,
-			  unsigned size,
-			  unsigned count,
-			  MFCompleteHandler hdlr,
-			  void * userToken )
+void mf_allocateLpEvents(HvLpIndex targetLp, HvLpEvent_Type type,
+		unsigned size, unsigned count, MFCompleteHandler hdlr,
+		void *userToken)
 {
-	struct StackElement * newElement = newStackElement();
-	int rc = 0;
+	struct pending_event *ev = new_pending_event();
+	int rc;
 
-	if ( newElement == NULL )
+	if (ev == NULL) {
 		rc = -ENOMEM;
-	else {
-		union SafeCast mine;
+	} else {
+		union safe_cast mine;
+
 		mine.ptr = userToken;
-		newElement->event.xHvLpEvent.xSubtype = 4;
-		newElement->event.xHvLpEvent.xCorrelationToken = mine.ptrAsU64;
-		newElement->event.xHvLpEvent.x.xSubtypeData = ('M'<<24)+('F'<<16)+('M'<<8)+('A'<<0);
-		newElement->event.xUnion.xAllocData.xTargetLp = targetLp;
-		newElement->event.xUnion.xAllocData.xType = type;
-		newElement->event.xUnion.xAllocData.xSize = size;
-		newElement->event.xUnion.xAllocData.xCount = count;
-		newElement->hdlr = hdlr;
-		rc = signalEvent(newElement);
+		ev->event.hp_lp_event.xSubtype = 4;
+		ev->event.hp_lp_event.xCorrelationToken = mine.ptr_as_u64;
+		ev->event.hp_lp_event.x.xSubtypeData =
+			subtype_data('M', 'F', 'M', 'A');
+		ev->event.data.alloc.target_lp = targetLp;
+		ev->event.data.alloc.type = type;
+		ev->event.data.alloc.size = size;
+		ev->event.data.alloc.count = count;
+		ev->hdlr = hdlr;
+		rc = signal_event(ev);
 	}
-
-	if ( (rc != 0) && (hdlr != NULL) )
-		(*hdlr)( userToken, rc );
+	if ((rc != 0) && (hdlr != NULL))
+		(*hdlr)(userToken, rc);
 }
 
 /*
  * Global kernel interface to unseed and deallocate events already in
  * Hypervisor.
  */
-void mf_deallocateLpEvents( HvLpIndex targetLp,
-			    HvLpEvent_Type type,
-			    unsigned count,
-			    MFCompleteHandler hdlr,
-			    void * userToken )
+void mf_deallocateLpEvents(HvLpIndex targetLp, HvLpEvent_Type type,
+		unsigned count, MFCompleteHandler hdlr, void *userToken)
 {
-	struct StackElement * newElement = newStackElement();
-	int rc = 0;
+	struct pending_event *ev = new_pending_event();
+	int rc;
 
-	if ( newElement == NULL )
+	if (ev == NULL)
 		rc = -ENOMEM;
 	else {
-		union SafeCast mine;
+		union safe_cast mine;
+
 		mine.ptr = userToken;
-		newElement->event.xHvLpEvent.xSubtype = 5;
-		newElement->event.xHvLpEvent.xCorrelationToken = mine.ptrAsU64;
-		newElement->event.xHvLpEvent.x.xSubtypeData = ('M'<<24)+('F'<<16)+('M'<<8)+('D'<<0);
-		newElement->event.xUnion.xAllocData.xTargetLp = targetLp;
-		newElement->event.xUnion.xAllocData.xType = type;
-		newElement->event.xUnion.xAllocData.xCount = count;
-		newElement->hdlr = hdlr;
-		rc = signalEvent(newElement);
+		ev->event.hp_lp_event.xSubtype = 5;
+		ev->event.hp_lp_event.xCorrelationToken = mine.ptr_as_u64;
+		ev->event.hp_lp_event.x.xSubtypeData =
+			subtype_data('M', 'F', 'M', 'D');
+		ev->event.data.alloc.target_lp = targetLp;
+		ev->event.data.alloc.type = type;
+		ev->event.data.alloc.count = count;
+		ev->hdlr = hdlr;
+		rc = signal_event(ev);
 	}
-
-	if ( (rc != 0) && (hdlr != NULL) )
-		(*hdlr)( userToken, rc );
+	if ((rc != 0) && (hdlr != NULL))
+		(*hdlr)(userToken, rc);
 }
 
 /*
  * Global kernel interface to tell the VSP object in the primary
  * partition to power this partition off.
  */
-void mf_powerOff( void )
+void mf_powerOff(void)
 {
-	printk( KERN_INFO "mf.c: Down it goes...\n" );
-	signalCEMsg( "\x00\x00\x00\x4D\x00\x00\x00\x00\x00\x00\x00\x00", NULL );
+	printk(KERN_INFO "mf.c: Down it goes...\n");
+	signal_ce_msg("\x00\x00\x00\x4D\x00\x00\x00\x00\x00\x00\x00\x00", NULL);
 	for (;;);
 }
 
@@ -676,111 +607,104 @@ void mf_powerOff( void )
  * Global kernel interface to tell the VSP object in the primary
  * partition to reboot this partition.
  */
-void mf_reboot( void )
+void mf_reboot(void)
 {
-	printk( KERN_INFO "mf.c: Preparing to bounce...\n" );
-	signalCEMsg( "\x00\x00\x00\x4E\x00\x00\x00\x00\x00\x00\x00\x00", NULL );
+	printk(KERN_INFO "mf.c: Preparing to bounce...\n");
+	signal_ce_msg("\x00\x00\x00\x4E\x00\x00\x00\x00\x00\x00\x00\x00", NULL);
 	for (;;);
 }
 
 /*
  * Display a single word SRC onto the VSP control panel.
  */
-void mf_displaySrc( u32 word )
+void mf_displaySrc(u32 word)
 {
 	u8 ce[12];
 
-	memcpy( ce, "\x00\x00\x00\x4A\x00\x00\x00\x01\x00\x00\x00\x00", 12 );
-	ce[8] = word>>24;
-	ce[9] = word>>16;
-	ce[10] = word>>8;
+	memcpy(ce, "\x00\x00\x00\x4A\x00\x00\x00\x01\x00\x00\x00\x00", 12);
+	ce[8] = word >> 24;
+	ce[9] = word >> 16;
+	ce[10] = word >> 8;
 	ce[11] = word;
-	signalCEMsg( ce, NULL );
+	signal_ce_msg(ce, NULL);
 }
 
 /*
  * Display a single word SRC of the form "PROGXXXX" on the VSP control panel.
  */
-void mf_displayProgress( u16 value )
+void mf_displayProgress(u16 value)
 {
 	u8 ce[12];
 	u8 src[72];
 
-	memcpy( ce, "\x00\x00\x04\x4A\x00\x00\x00\x48\x00\x00\x00\x00", 12 );
-	memcpy( src,
-		"\x01\x00\x00\x01"
-		"\x00\x00\x00\x00"
-		"\x00\x00\x00\x00"
-		"\x00\x00\x00\x00"
-		"\x00\x00\x00\x00"
-		"\x00\x00\x00\x00"
-		"\x00\x00\x00\x00"
-		"\x00\x00\x00\x00"
-		"\x00\x00\x00\x00"
-		"\x00\x00\x00\x00"
-		"PROGxxxx"
-		"                        ",
-		72 );
-	src[6] = value>>8;
-	src[7] = value&255;
-	src[44] = "0123456789ABCDEF"[(value>>12)&15];
-	src[45] = "0123456789ABCDEF"[(value>>8)&15];
-	src[46] = "0123456789ABCDEF"[(value>>4)&15];
-	src[47] = "0123456789ABCDEF"[value&15];
-	dmaAndSignalCEMsg( ce, NULL, src, sizeof(src), 9*64*1024 );
+	memcpy(ce, "\x00\x00\x04\x4A\x00\x00\x00\x48\x00\x00\x00\x00", 12);
+	memcpy(src, "\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
+		"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+		"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+		"\x00\x00\x00\x00PROGxxxx                        ",
+		72);
+	src[6] = value >> 8;
+	src[7] = value & 255;
+	src[44] = "0123456789ABCDEF"[(value >> 12) & 15];
+	src[45] = "0123456789ABCDEF"[(value >> 8) & 15];
+	src[46] = "0123456789ABCDEF"[(value >> 4) & 15];
+	src[47] = "0123456789ABCDEF"[value & 15];
+	dma_and_signal_ce_msg(ce, NULL, src, sizeof(src), 9 * 64 * 1024);
 }
 
 /*
  * Clear the VSP control panel.  Used to "erase" an SRC that was
  * previously displayed.
  */
-void mf_clearSrc( void )
+void mf_clearSrc(void)
 {
-	signalCEMsg( "\x00\x00\x00\x4B\x00\x00\x00\x00\x00\x00\x00\x00", NULL );
+	signal_ce_msg("\x00\x00\x00\x4B\x00\x00\x00\x00\x00\x00\x00\x00", NULL);
 }
 
 /*
  * Initialization code here.
  */
-void mf_init( void )
+void mf_init(void)
 {
 	int i;
 
-    /* initialize */
-	spin_lock_init( &spinlock );
-	for ( i = 0; i < sizeof(prealloc)/sizeof(*prealloc); ++i )
-		free( &prealloc[i] );
-	HvLpEvent_registerHandler( HvLpEvent_Type_MachineFac, &hvHandler );
+	/* initialize */
+	spin_lock_init(&pending_event_spinlock);
+	for (i = 0;
+	     i < sizeof(pending_event_prealloc) / sizeof(*pending_event_prealloc);
+	     ++i)
+		free_pending_event(&pending_event_prealloc[i]);
+	HvLpEvent_registerHandler(HvLpEvent_Type_MachineFac, &hvHandler);
 
 	/* virtual continue ack */
-	signalCEMsg( "\x00\x00\x00\x57\x00\x00\x00\x00\x00\x00\x00\x00", NULL );
+	signal_ce_msg("\x00\x00\x00\x57\x00\x00\x00\x00\x00\x00\x00\x00", NULL);
 
 	/* initialization complete */
-	printk( KERN_NOTICE "mf.c: iSeries Linux LPAR Machine Facilities initialized\n" );
+	printk(KERN_NOTICE "mf.c: iSeries Linux LPAR Machine Facilities initialized\n");
 
 	iSeries_proc_callback(&mf_proc_init);
 }
 
 void mf_setSide(char side)
 {
-	int rc = 0;
-	u64 newSide = 0;
+	u64 newSide;
 	struct VspCmdData myVspCmd;
 
 	memset(&myVspCmd, 0, sizeof(myVspCmd));
-	if (side == 'A')
-		newSide = 0;
-	else if (side == 'B')
-		newSide = 1;
-	else if (side == 'C')
-		newSide = 2; 
-	else
-		newSide = 3;
-
-	myVspCmd.xSubData.xFunction02SelectIplTypeIn.xIplType = newSide;
-	myVspCmd.xCmd = 10;
+	switch (side) {
+	case 'A':	newSide = 0;
+			break;
+	case 'B':	newSide = 1;
+			break;
+	case 'C':	newSide = 2; 
+			break;
+	default:	newSide = 3;
+			break;
+	}
+	myVspCmd.sub_data.ipl_type = newSide;
+	myVspCmd.cmd = 10;
 
-	rc = signalVspInstruction(&myVspCmd);
+	(void)signal_vsp_instruction(&myVspCmd);
 }
 
 char mf_getSide(void)
@@ -790,91 +714,82 @@ char mf_getSide(void)
 	struct VspCmdData myVspCmd;
 
 	memset(&myVspCmd, 0, sizeof(myVspCmd));
-	myVspCmd.xCmd = 2;
-	myVspCmd.xSubData.xFunction02SelectIplTypeIn.xIplType = 0;
+	myVspCmd.cmd = 2;
+	myVspCmd.sub_data.ipl_type = 0;
 	mb();
-	rc = signalVspInstruction(&myVspCmd);
+	rc = signal_vsp_instruction(&myVspCmd);
 
 	if (rc != 0)
-	{
 		return returnValue;
-	} else {
-		if (myVspCmd.xRc == 0)
-		{
-			if (myVspCmd.xSubData.xGetIplTypeOut.xIplType == 0)
-				returnValue = 'A';
-			else if (myVspCmd.xSubData.xGetIplTypeOut.xIplType == 1)
-				returnValue = 'B';
-			else if (myVspCmd.xSubData.xGetIplTypeOut.xIplType == 2)
-				returnValue = 'C';
-			else
-				returnValue = 'D';
+
+	if (myVspCmd.result_code == 0) {
+		switch (myVspCmd.sub_data.ipl_type) {
+		case 0:	returnValue = 'A';
+			break;
+		case 1:	returnValue = 'B';
+			break;
+		case 2:	returnValue = 'C';
+			break;
+		default:	returnValue = 'D';
+			break;
 		}
 	}
-
 	return returnValue;
 }
 
 void mf_getSrcHistory(char *buffer, int size)
 {
-    /*    struct IplTypeReturnStuff returnStuff;
-     struct StackElement * newElement = newStackElement();
-     int rc = 0;
-     char *pages[4];
-
-     pages[0] = kmalloc(4096, GFP_ATOMIC);
-     pages[1] = kmalloc(4096, GFP_ATOMIC);
-     pages[2] = kmalloc(4096, GFP_ATOMIC);
-     pages[3] = kmalloc(4096, GFP_ATOMIC);
-     if (( newElement == NULL ) || (pages[0] == NULL) || (pages[1] == NULL) || (pages[2] == NULL) || (pages[3] == NULL))
-     rc = -ENOMEM;
-     else
-     {
-     returnStuff.xType = 0;
-     returnStuff.xRc = 0;
-     returnStuff.xDone = 0;
-     newElement->event.xHvLpEvent.xSubtype = 6;
-     newElement->event.xHvLpEvent.x.xSubtypeData = ('M'<<24)+('F'<<16)+('V'<<8)+('I'<<0);
-     newElement->event.xUnion.xVspCmd.xEvent = &returnStuff;
-     newElement->event.xUnion.xVspCmd.xCmd = 4;
-     newElement->event.xUnion.xVspCmd.xLpIndex = HvLpConfig_getLpIndex();
-     newElement->event.xUnion.xVspCmd.xRc = 0xFF;
-     newElement->event.xUnion.xVspCmd.xReserved1 = 0;
-     newElement->event.xUnion.xVspCmd.xSubData.xGetSrcHistoryIn.xPage[0] = (0x8000000000000000ULL | virt_to_absolute((unsigned long)pages[0]));
-     newElement->event.xUnion.xVspCmd.xSubData.xGetSrcHistoryIn.xPage[1] = (0x8000000000000000ULL | virt_to_absolute((unsigned long)pages[1]));
-     newElement->event.xUnion.xVspCmd.xSubData.xGetSrcHistoryIn.xPage[2] = (0x8000000000000000ULL | virt_to_absolute((unsigned long)pages[2]));
-     newElement->event.xUnion.xVspCmd.xSubData.xGetSrcHistoryIn.xPage[3] = (0x8000000000000000ULL | virt_to_absolute((unsigned long)pages[3]));
-     mb();
-     rc = signalEvent(newElement);
-     }
-
-     if (rc != 0)
-     {
-     return;
-     }
-     else
-     {
-     while (returnStuff.xDone != 1)
-     {
-     udelay(10);
-     }
-
-     if (returnStuff.xRc == 0)
-     {
-     memcpy(buffer, pages[0], size);
-     }
-     }
-
-     kfree(pages[0]);
-     kfree(pages[1]);
-     kfree(pages[2]);
-     kfree(pages[3]);*/
+#if 0
+	struct IplTypeReturnStuff returnStuff;
+	struct pending_event *ev = new_pending_event();
+	int rc = 0;
+	char *pages[4];
+
+	pages[0] = kmalloc(4096, GFP_ATOMIC);
+	pages[1] = kmalloc(4096, GFP_ATOMIC);
+	pages[2] = kmalloc(4096, GFP_ATOMIC);
+	pages[3] = kmalloc(4096, GFP_ATOMIC);
+	if ((ev == NULL) || (pages[0] == NULL) || (pages[1] == NULL)
+			 || (pages[2] == NULL) || (pages[3] == NULL))
+		return -ENOMEM;
+
+	returnStuff.xType = 0;
+	returnStuff.xRc = 0;
+	returnStuff.xDone = 0;
+	ev->event.hp_lp_event.xSubtype = 6;
+	ev->event.hp_lp_event.x.xSubtypeData =
+		subtype_data('M', 'F', 'V', 'I');
+	ev->event.data.vsp_cmd.xEvent = &returnStuff;
+	ev->event.data.vsp_cmd.cmd = 4;
+	ev->event.data.vsp_cmd.lp_index = HvLpConfig_getLpIndex();
+	ev->event.data.vsp_cmd.result_code = 0xFF;
+	ev->event.data.vsp_cmd.reserved = 0;
+	ev->event.data.vsp_cmd.sub_data.page[0] =
+		(0x8000000000000000ULL | virt_to_absolute((unsigned long)pages[0]));
+	ev->event.data.vsp_cmd.sub_data.page[1] =
+		(0x8000000000000000ULL | virt_to_absolute((unsigned long)pages[1]));
+	ev->event.data.vsp_cmd.sub_data.page[2] =
+		(0x8000000000000000ULL | virt_to_absolute((unsigned long)pages[2]));
+	ev->event.data.vsp_cmd.sub_data.page[3] =
+		(0x8000000000000000ULL | virt_to_absolute((unsigned long)pages[3]));
+	mb();
+	if (signal_event(ev) != 0)
+		return;
+
+ 	while (returnStuff.xDone != 1)
+ 		udelay(10);
+ 	if (returnStuff.xRc == 0)
+ 		memcpy(buffer, pages[0], size);
+	kfree(pages[0]);
+	kfree(pages[1]);
+	kfree(pages[2]);
+	kfree(pages[3]);
+#endif
 }
 
 void mf_setCmdLine(const char *cmdline, int size, u64 side)
 {
 	struct VspCmdData myVspCmd;
-	int rc = 0;
 	dma_addr_t dma_addr = 0;
 	char *page = pci_alloc_consistent(iSeries_vio_dev, size, &dma_addr);
 
@@ -886,13 +801,13 @@ void mf_setCmdLine(const char *cmdline, 
 	copy_from_user(page, cmdline, size);
 
 	memset(&myVspCmd, 0, sizeof(myVspCmd));
-	myVspCmd.xCmd = 31;
-	myVspCmd.xSubData.xSetKernelCmdLineIn.xToken = dma_addr;
-	myVspCmd.xSubData.xSetKernelCmdLineIn.xAddressType = HvLpDma_AddressType_TceIndex;
-	myVspCmd.xSubData.xSetKernelCmdLineIn.xSide = side;
-	myVspCmd.xSubData.xSetKernelCmdLineIn.xTransferLength = size;
+	myVspCmd.cmd = 31;
+	myVspCmd.sub_data.kern.token = dma_addr;
+	myVspCmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
+	myVspCmd.sub_data.kern.side = side;
+	myVspCmd.sub_data.kern.length = size;
 	mb();
-	rc = signalVspInstruction(&myVspCmd);
+	(void)signal_vsp_instruction(&myVspCmd);
 
 	pci_free_consistent(iSeries_vio_dev, size, page, dma_addr);
 }
@@ -900,31 +815,29 @@ void mf_setCmdLine(const char *cmdline, 
 int mf_getCmdLine(char *cmdline, int *size, u64 side)
 {
 	struct VspCmdData myVspCmd;
-	int rc = 0;
+	int rc;
 	int len = *size;
-	dma_addr_t dma_addr = pci_map_single(iSeries_vio_dev, cmdline, *size, PCI_DMA_FROMDEVICE);
+	dma_addr_t dma_addr;
 
-	memset(cmdline, 0, *size);
+	dma_addr = pci_map_single(iSeries_vio_dev, cmdline, len,
+			PCI_DMA_FROMDEVICE);
+	memset(cmdline, 0, len);
 	memset(&myVspCmd, 0, sizeof(myVspCmd));
-	myVspCmd.xCmd = 33;
-	myVspCmd.xSubData.xGetKernelCmdLineIn.xToken = dma_addr;
-	myVspCmd.xSubData.xGetKernelCmdLineIn.xAddressType = HvLpDma_AddressType_TceIndex;
-	myVspCmd.xSubData.xGetKernelCmdLineIn.xSide = side;
-	myVspCmd.xSubData.xGetKernelCmdLineIn.xTransferLength = *size;
+	myVspCmd.cmd = 33;
+	myVspCmd.sub_data.kern.token = dma_addr;
+	myVspCmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
+	myVspCmd.sub_data.kern.side = side;
+	myVspCmd.sub_data.kern.length = len;
 	mb();
-	rc = signalVspInstruction(&myVspCmd);
-
-	if ( ! rc ) {
+	rc = signal_vsp_instruction(&myVspCmd);
 
-		if (myVspCmd.xRc == 0)
-		{
-			len = myVspCmd.xSubData.xGetKernelCmdLineOut.xTransferLength;
-		}
-		/* else
-			{
+	if (rc == 0) {
+		if (myVspCmd.result_code == 0)
+			len = myVspCmd.sub_data.length_out;
+#if 0
+		else
 			memcpy(cmdline, "Bad cmdline", 11);
-			}
-		*/
+#endif
 	}
 
 	pci_unmap_single(iSeries_vio_dev, dma_addr, *size, PCI_DMA_FROMDEVICE);
@@ -936,10 +849,8 @@ int mf_getCmdLine(char *cmdline, int *si
 int mf_setVmlinuxChunk(const char *buffer, int size, int offset, u64 side)
 {
 	struct VspCmdData myVspCmd;
-	int rc = 0;
-
+	int rc;
 	dma_addr_t dma_addr = 0;
-
 	char *page = pci_alloc_consistent(iSeries_vio_dev, size, &dma_addr);
 
 	if (page == NULL) {
@@ -950,23 +861,19 @@ int mf_setVmlinuxChunk(const char *buffe
 	copy_from_user(page, buffer, size);
 	memset(&myVspCmd, 0, sizeof(myVspCmd));
 
-	myVspCmd.xCmd = 30;
-	myVspCmd.xSubData.xGetKernelImageIn.xToken = dma_addr;
-	myVspCmd.xSubData.xGetKernelImageIn.xAddressType = HvLpDma_AddressType_TceIndex;
-	myVspCmd.xSubData.xGetKernelImageIn.xSide = side;
-	myVspCmd.xSubData.xGetKernelImageIn.xOffset = offset;
-	myVspCmd.xSubData.xGetKernelImageIn.xTransferLength = size;
+	myVspCmd.cmd = 30;
+	myVspCmd.sub_data.kern.token = dma_addr;
+	myVspCmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
+	myVspCmd.sub_data.kern.side = side;
+	myVspCmd.sub_data.kern.offset = offset;
+	myVspCmd.sub_data.kern.length = size;
 	mb();
-	rc = signalVspInstruction(&myVspCmd);
-
-	if (rc == 0)
-	{
-		if (myVspCmd.xRc == 0)
-		{
+	rc = signal_vsp_instruction(&myVspCmd);
+	if (rc == 0) {
+		if (myVspCmd.result_code == 0)
 			rc = 0;
-		} else {
+		else
 			rc = -ENOMEM;
-		}
 	}
 
 	pci_free_consistent(iSeries_vio_dev, size, page, dma_addr);
@@ -977,31 +884,27 @@ int mf_setVmlinuxChunk(const char *buffe
 int mf_getVmlinuxChunk(char *buffer, int *size, int offset, u64 side)
 {
 	struct VspCmdData myVspCmd;
-	int rc = 0;
+	int rc;
 	int len = *size;
+	dma_addr_t dma_addr;
 
-	dma_addr_t dma_addr = pci_map_single(iSeries_vio_dev, buffer, *size, PCI_DMA_FROMDEVICE);
-
+	dma_addr = pci_map_single(iSeries_vio_dev, buffer, len,
+			PCI_DMA_FROMDEVICE);
 	memset(buffer, 0, len);
-
 	memset(&myVspCmd, 0, sizeof(myVspCmd));
-	myVspCmd.xCmd = 32;
-	myVspCmd.xSubData.xGetKernelImageIn.xToken = dma_addr;
-	myVspCmd.xSubData.xGetKernelImageIn.xAddressType = HvLpDma_AddressType_TceIndex;
-	myVspCmd.xSubData.xGetKernelImageIn.xSide = side;
-	myVspCmd.xSubData.xGetKernelImageIn.xOffset = offset;
-	myVspCmd.xSubData.xGetKernelImageIn.xTransferLength = len;
+	myVspCmd.cmd = 32;
+	myVspCmd.sub_data.kern.token = dma_addr;
+	myVspCmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
+	myVspCmd.sub_data.kern.side = side;
+	myVspCmd.sub_data.kern.offset = offset;
+	myVspCmd.sub_data.kern.length = len;
 	mb();
-	rc = signalVspInstruction(&myVspCmd);
-
-	if (rc == 0)
-	{
-		if (myVspCmd.xRc == 0)
-		{
-			*size = myVspCmd.xSubData.xGetKernelImageOut.xTransferLength;
-		} else {
+	rc = signal_vsp_instruction(&myVspCmd);
+	if (rc == 0) {
+		if (myVspCmd.result_code == 0)
+			*size = myVspCmd.sub_data.length_out;
+		else
 			rc = -ENOMEM;
-		}
 	}
 
 	pci_unmap_single(iSeries_vio_dev, dma_addr, len, PCI_DMA_FROMDEVICE);
@@ -1015,12 +918,11 @@ int mf_setRtcTime(unsigned long time)
 
 	to_tm(time, &tm);
 
-	return mf_setRtc( &tm );
+	return mf_setRtc(&tm);
 }
 
-struct RtcTimeData
-{
-	struct semaphore *xSemaphore;
+struct RtcTimeData {
+	struct semaphore *sem;
 	struct CeMsgData xCeMsg;
 	int xRc;
 };
@@ -1030,26 +932,23 @@ void getRtcTimeComplete(void * token, st
 	struct RtcTimeData *rtc = (struct RtcTimeData *)token;
 
 	memcpy(&(rtc->xCeMsg), ceMsg, sizeof(rtc->xCeMsg));
-
 	rtc->xRc = 0;
-	up(rtc->xSemaphore);
+	up(rtc->sem);
 }
 
 static unsigned long lastsec = 1;
 
 int mf_getRtcTime(unsigned long *time)
 {
-/*    unsigned long usec, tsec; */
-	
 	u32 dataWord1 = *((u32 *)(&xSpCommArea.xBcdTimeAtIplStart));
 	u32 dataWord2 = *(((u32 *)&(xSpCommArea.xBcdTimeAtIplStart)) + 1);
 	int year = 1970;
-	int year1 = ( dataWord1 >> 24 ) & 0x000000FF;
-	int year2 = ( dataWord1 >> 16 ) & 0x000000FF;
-	int sec = ( dataWord1 >> 8 ) & 0x000000FF;
+	int year1 = (dataWord1 >> 24) & 0x000000FF;
+	int year2 = (dataWord1 >> 16) & 0x000000FF;
+	int sec = (dataWord1 >> 8) & 0x000000FF;
 	int min = dataWord1 & 0x000000FF;
-	int hour = ( dataWord2 >> 24 ) & 0x000000FF;
-	int day = ( dataWord2 >> 8 ) & 0x000000FF;
+	int hour = (dataWord2 >> 24) & 0x000000FF;
+	int day = (dataWord2 >> 8) & 0x000000FF;
 	int mon = dataWord2 & 0x000000FF;
 
 	BCD_TO_BIN(sec);
@@ -1062,49 +961,41 @@ int mf_getRtcTime(unsigned long *time)
 	year = year1 * 100 + year2;
 
 	*time = mktime(year, mon, day, hour, min, sec);
-
-	*time += ( jiffies / HZ );
+	*time += (jiffies / HZ);
     
-	/* Now THIS is a nasty hack!
+	/*
+	 * Now THIS is a nasty hack!
 	 * It ensures that the first two calls to mf_getRtcTime get different
 	 * answers.  That way the loop in init_time (time.c) will not think
 	 * the clock is stuck.
 	 */
-	if ( lastsec ) {
+	if (lastsec) {
 		*time -= lastsec;
 		--lastsec;
 	}
-    
 	return 0;
-
 }
 
-int mf_getRtc( struct rtc_time * tm )
+int mf_getRtc(struct rtc_time *tm)
 {
-
 	struct CeMsgCompleteData ceComplete;
 	struct RtcTimeData rtcData;
-	int rc = 0;
+	int rc;
 	DECLARE_MUTEX_LOCKED(Semaphore);
 
 	memset(&ceComplete, 0, sizeof(ceComplete));
 	memset(&rtcData, 0, sizeof(rtcData));
-
-	rtcData.xSemaphore = &Semaphore;
-
-	ceComplete.xHdlr = &getRtcTimeComplete;
-	ceComplete.xToken = (void *)&rtcData;
-
-	rc = signalCEMsg( "\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00", &ceComplete );
-
-	if ( rc == 0 )
-	{
+	rtcData.sem = &Semaphore;
+	ceComplete.handler = &getRtcTimeComplete;
+	ceComplete.token = (void *)&rtcData;
+	rc = signal_ce_msg("\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00",
+			&ceComplete);
+	if (rc == 0) {
 		down(&Semaphore);
 
-		if ( rtcData.xRc == 0)
-		{
-			if ( ( rtcData.xCeMsg.xCEMsg[2] == 0xa9 ) ||
-			     ( rtcData.xCeMsg.xCEMsg[2] == 0xaf ) ) {
+		if (rtcData.xRc == 0) {
+			if ((rtcData.xCeMsg.ce_msg[2] == 0xa9) ||
+			    (rtcData.xCeMsg.ce_msg[2] == 0xaf)) {
 				/* TOD clock is not set */
 				tm->tm_sec = 1;
 				tm->tm_min = 1;
@@ -1112,16 +1003,16 @@ int mf_getRtc( struct rtc_time * tm )
 				tm->tm_mday = 10;
 				tm->tm_mon = 8;
 				tm->tm_year = 71;
-				mf_setRtc( tm );
+				mf_setRtc(tm);
 			}
 			{
-				u32 dataWord1 = *((u32 *)(rtcData.xCeMsg.xCEMsg+4));
-				u32 dataWord2 = *((u32 *)(rtcData.xCeMsg.xCEMsg+8));
-				u8 year = (dataWord1 >> 16 ) & 0x000000FF;
-				u8 sec = ( dataWord1 >> 8 ) & 0x000000FF;
+				u32 dataWord1 = *((u32 *)(rtcData.xCeMsg.ce_msg+4));
+				u32 dataWord2 = *((u32 *)(rtcData.xCeMsg.ce_msg+8));
+				u8 year = (dataWord1 >> 16) & 0x000000FF;
+				u8 sec = (dataWord1 >> 8) & 0x000000FF;
 				u8 min = dataWord1 & 0x000000FF;
-				u8 hour = ( dataWord2 >> 24 ) & 0x000000FF;
-				u8 day = ( dataWord2 >> 8 ) & 0x000000FF;
+				u8 hour = (dataWord2 >> 24) & 0x000000FF;
+				u8 day = (dataWord2 >> 8) & 0x000000FF;
 				u8 mon = dataWord2 & 0x000000FF;
 
 				BCD_TO_BIN(sec);
@@ -1131,7 +1022,7 @@ int mf_getRtc( struct rtc_time * tm )
 				BCD_TO_BIN(mon);
 				BCD_TO_BIN(year);
 
-				if ( year <= 69 )
+				if (year <= 69)
 					year += 100;
 	    
 				tm->tm_sec = sec;
@@ -1154,17 +1045,14 @@ int mf_getRtc( struct rtc_time * tm )
 		tm->tm_wday = 0;
 		tm->tm_yday = 0;
 		tm->tm_isdst = 0;
-
 	}
 
 	return rc;
-
 }
 
 int mf_setRtc(struct rtc_time * tm)
 {
 	char ceTime[12] = "\x00\x00\x00\x41\x00\x00\x00\x00\x00\x00\x00\x00";
-	int rc = 0;
 	u8 day, mon, hour, min, sec, y1, y2;
 	unsigned year;
     
@@ -1194,10 +1082,5 @@ int mf_setRtc(struct rtc_time * tm)
 	ceTime[10] = day;
 	ceTime[11] = mon;
    
-	rc = signalCEMsg( ceTime, NULL );
-
-	return rc;
+	return signal_ce_msg(ceTime, NULL);
 }
-
-
-
diff -puN arch/ppc64/kernel/mf_proc.c~linus arch/ppc64/kernel/mf_proc.c
--- 25/arch/ppc64/kernel/mf_proc.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/mf_proc.c	2004-01-19 22:17:21.000000000 -0800
@@ -16,151 +16,27 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
-
-
-/* Change Activity: */
-/* End Change Activity */
-
-#ifndef _MF_PROC_H
-#include <asm/iSeries/mf_proc.h>
-#endif
-#ifndef MF_H_INCLUDED
-#include <asm/iSeries/mf.h>
-#endif
 #include <asm/uaccess.h>
+#include <asm/iSeries/mf.h>
 
 static struct proc_dir_entry *mf_proc_root = NULL;
 
-int proc_mf_dump_cmdline
-(char *page, char **start, off_t off, int count, int *eof, void *data);
-
-int proc_mf_dump_vmlinux
-(char *page, char **start, off_t off, int count, int *eof, void *data);
-
-int proc_mf_dump_side
-(char *page, char **start, off_t off, int count, int *eof, void *data);
-
-int proc_mf_change_side
-(struct file *file, const char *buffer, unsigned long count, void *data);
-
-int proc_mf_dump_src
-(char *page, char **start, off_t off, int count, int *eof, void *data);
-int proc_mf_change_src (struct file *file, const char *buffer, unsigned long count, void *data);
-int proc_mf_change_cmdline(struct file *file, const char *buffer, unsigned long count, void *data);
-int proc_mf_change_vmlinux(struct file *file, const char *buffer, unsigned long count, void *data);
-
-
-void mf_proc_init(struct proc_dir_entry *iSeries_proc)
+static int proc_mf_dump_cmdline(char *page, char **start, off_t off,
+		int count, int *eof, void *data)
 {
-	struct proc_dir_entry *ent = NULL;
-	struct proc_dir_entry *mf_a = NULL;
-	struct proc_dir_entry *mf_b = NULL;
-	struct proc_dir_entry *mf_c = NULL;
-	struct proc_dir_entry *mf_d = NULL;
-
-	mf_proc_root = proc_mkdir("mf", iSeries_proc);
-	if (!mf_proc_root) return;
-
-	mf_a = proc_mkdir("A", mf_proc_root);
-	if (!mf_a) return;
-
-	ent = create_proc_entry("cmdline", S_IFREG|S_IRUSR|S_IWUSR, mf_a);
-	if (!ent) return;
-	ent->nlink = 1;
-	ent->data = (void *)0;
-	ent->read_proc = proc_mf_dump_cmdline;
-	ent->write_proc = proc_mf_change_cmdline;
-
-	ent = create_proc_entry("vmlinux", S_IFREG|S_IWUSR, mf_a);
-	if (!ent) return;
-	ent->nlink = 1;
-	ent->data = (void *)0;
-	ent->write_proc = proc_mf_change_vmlinux;
-	ent->read_proc = NULL;
-
-	mf_b = proc_mkdir("B", mf_proc_root);
-	if (!mf_b) return;
-
-	ent = create_proc_entry("cmdline", S_IFREG|S_IRUSR|S_IWUSR, mf_b);
-	if (!ent) return;
-	ent->nlink = 1;
-	ent->data = (void *)1;
-	ent->read_proc = proc_mf_dump_cmdline;
-	ent->write_proc = proc_mf_change_cmdline;
-
-	ent = create_proc_entry("vmlinux", S_IFREG|S_IWUSR, mf_b);
-	if (!ent) return;
-	ent->nlink = 1;
-	ent->data = (void *)1;
-	ent->write_proc = proc_mf_change_vmlinux;
-	ent->read_proc = NULL;
-
-	mf_c = proc_mkdir("C", mf_proc_root);
-	if (!mf_c) return;
-
-	ent = create_proc_entry("cmdline", S_IFREG|S_IRUSR|S_IWUSR, mf_c);
-	if (!ent) return;
-	ent->nlink = 1;
-	ent->data = (void *)2;
-	ent->read_proc = proc_mf_dump_cmdline;
-	ent->write_proc = proc_mf_change_cmdline;
-
-	ent = create_proc_entry("vmlinux", S_IFREG|S_IWUSR, mf_c);
-	if (!ent) return;
-	ent->nlink = 1;
-	ent->data = (void *)2;
-	ent->write_proc = proc_mf_change_vmlinux;
-	ent->read_proc = NULL;
-
-	mf_d = proc_mkdir("D", mf_proc_root);
-	if (!mf_d) return;
-
-
-	ent = create_proc_entry("cmdline", S_IFREG|S_IRUSR|S_IWUSR, mf_d);
-	if (!ent) return;
-	ent->nlink = 1;
-	ent->data = (void *)3;
-	ent->read_proc = proc_mf_dump_cmdline;
-	ent->write_proc = proc_mf_change_cmdline;
-#if 0
-	ent = create_proc_entry("vmlinux", S_IFREG|S_IRUSR, mf_d);
-	if (!ent) return;
-	ent->nlink = 1;
-	ent->data = (void *)3;
-	ent->read_proc = proc_mf_dump_vmlinux;
-	ent->write_proc = NULL;
-#endif
-	ent = create_proc_entry("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
-	if (!ent) return;
-	ent->nlink = 1;
-	ent->data = (void *)0;
-	ent->read_proc = proc_mf_dump_side;
-	ent->write_proc = proc_mf_change_side;
-
-	ent = create_proc_entry("src", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
-	if (!ent) return;
-	ent->nlink = 1;
-	ent->data = (void *)0;
-	ent->read_proc = proc_mf_dump_src;
-	ent->write_proc = proc_mf_change_src;
-}
-
-int proc_mf_dump_cmdline
-(char *page, char **start, off_t off, int count, int *eof, void *data)
-{
-	int		len = count;
+	int len = count;
 	char *p;
     
 	len = mf_getCmdLine(page, &len, (u64)data);
    
 	p = page + len - 1;
-	while ( p > page ) {
-		if ( (*p == 0) || (*p == ' ') )
+	while (p > page) {
+		if ((*p == 0) || (*p == ' '))
 			--p;
 		else
 			break;
 	}
-	if ( *p != '\n' ) {
+	if (*p != '\n') {
 		++p;
 		*p = '\n';
 	}
@@ -179,74 +55,76 @@ int proc_mf_dump_cmdline
 	return len;			
 }
 
-int proc_mf_dump_vmlinux
-(char *page, char **start, off_t off, int count, int *eof, void *data)
+#if 0
+static int proc_mf_dump_vmlinux(char *page, char **start, off_t off,
+		int count, int *eof, void *data)
 {
 	int sizeToGet = count;
+
 	if (!capable(CAP_SYS_ADMIN))
 		return -EACCES;
 
-	if (mf_getVmlinuxChunk(page, &sizeToGet, off, (u64)data) == 0)
-	{
-		if (sizeToGet != 0)
-		{
+	if (mf_getVmlinuxChunk(page, &sizeToGet, off, (u64)data) == 0) {
+		if (sizeToGet != 0) {
 			*start = page + off;
 			return sizeToGet;
-		} else {
-			*eof = 1;
-			return 0;
 		}
-	} else {
 		*eof = 1;
 		return 0;
 	}
+	*eof = 1;
+	return 0;
 }
+#endif
 
-int proc_mf_dump_side
-(char *page, char **start, off_t off, int count, int *eof, void *data)
+static int proc_mf_dump_side(char *page, char **start, off_t off,
+		int count, int *eof, void *data)
 {
-	int		len = 0;
-
+	int len;
 	char mf_current_side = mf_getSide();
+
 	len = sprintf(page, "%c\n", mf_current_side);
 
-	if (len <= off+count) *eof = 1;
+	if (len <= (off + count))
+		*eof = 1;
 	*start = page + off;
 	len -= off;
-	if (len>count) len = count;
-	if (len<0) len = 0;
+	if (len > count)
+		len = count;
+	if (len < 0)
+		len = 0;
 	return len;			
 }
 
-int proc_mf_change_side(struct file *file, const char *buffer, unsigned long count, void *data)
+static int proc_mf_change_side(struct file *file, const char __user *buffer,
+		unsigned long count, void *data)
 {
 	char stkbuf[10];
+
 	if (!capable(CAP_SYS_ADMIN))
 		return -EACCES;
 
-	if (count > 9) count = 9;
-	if (copy_from_user (stkbuf, buffer, count)) {
+	if (count > (sizeof(stkbuf) - 1))
+		count = sizeof(stkbuf) - 1;
+	if (copy_from_user(stkbuf, buffer, count))
 		return -EFAULT;
-	}
 	stkbuf[count] = 0;
-	if ((*stkbuf != 'A') &&
-	    (*stkbuf != 'B') &&
-	    (*stkbuf != 'C') &&
-	    (*stkbuf != 'D'))
-	{
+	if ((*stkbuf != 'A') && (*stkbuf != 'B') &&
+	    (*stkbuf != 'C') && (*stkbuf != 'D')) {
 		printk(KERN_ERR "mf_proc.c: proc_mf_change_side: invalid side\n");
 		return -EINVAL;
 	}
 
 	mf_setSide(*stkbuf);
 
-	return count;			
+	return count;
 }
 
-int proc_mf_dump_src
-(char *page, char **start, off_t off, int count, int *eof, void *data)
+static int proc_mf_dump_src(char *page, char **start, off_t off,
+		int count, int *eof, void *data)
 {
-	int		len = 0;
+	int len;
+
 	mf_getSrcHistory(page, count);
 	len = count;
 	len -= off;			
@@ -260,34 +138,34 @@ int proc_mf_dump_src
 	return len;			
 }
 
-int proc_mf_change_src(struct file *file, const char *buffer, unsigned long count, void *data)
+static int proc_mf_change_src(struct file *file, const char __user *buffer,
+		unsigned long count, void *data)
 {
 	char stkbuf[10];
+
 	if (!capable(CAP_SYS_ADMIN))
 		return -EACCES;
 
-	if ((count < 4) && (count != 1))
-	{
+	if ((count < 4) && (count != 1)) {
 		printk(KERN_ERR "mf_proc: invalid src\n");
 		return -EINVAL;
 	}
 
-	if (count > 9) count = 9;
-	if (copy_from_user (stkbuf, buffer, count)) {
+	if (count > (sizeof(stkbuf) - 1))
+		count = sizeof(stkbuf) - 1;
+	if (copy_from_user(stkbuf, buffer, count))
 		return -EFAULT;
-	}
 
-	if ((count == 1) && ((*stkbuf) == '\0'))
-	{
+	if ((count == 1) && (*stkbuf == '\0'))
 		mf_clearSrc();
-	} else {
+	else
 		mf_displaySrc(*(u32 *)stkbuf);
-	}
 
 	return count;			
 }
 
-int proc_mf_change_cmdline(struct file *file, const char *buffer, unsigned long count, void *data)
+static int proc_mf_change_cmdline(struct file *file, const char *buffer,
+		unsigned long count, void *data)
 {
 	if (!capable(CAP_SYS_ADMIN))
 		return -EACCES;
@@ -297,7 +175,8 @@ int proc_mf_change_cmdline(struct file *
 	return count;			
 }
 
-int proc_mf_change_vmlinux(struct file *file, const char *buffer, unsigned long count, void *data)
+static int proc_mf_change_vmlinux(struct file *file, const char *buffer,
+		unsigned long count, void *data)
 {
 	if (!capable(CAP_SYS_ADMIN))
 		return -EACCES;
@@ -307,3 +186,70 @@ int proc_mf_change_vmlinux(struct file *
 
 	return count;			
 }
+
+void mf_proc_init(struct proc_dir_entry *iSeries_proc)
+{
+	struct proc_dir_entry *ent;
+	struct proc_dir_entry *mf;
+	char name[2];
+	int i;
+
+	mf_proc_root = proc_mkdir("mf", iSeries_proc);
+	if (!mf_proc_root)
+		return;
+
+	name[1] = '\0';
+	for (i = 0; i < 4; i++) {
+		name[0] = 'A' + i;
+		mf = proc_mkdir(name, mf_proc_root);
+		if (!mf)
+			return;
+
+		ent = create_proc_entry("cmdline", S_IFREG|S_IRUSR|S_IWUSR, mf);
+		if (!ent)
+			return;
+		ent->nlink = 1;
+		ent->data = (void *)(long)i;
+		ent->read_proc = proc_mf_dump_cmdline;
+		ent->write_proc = proc_mf_change_cmdline;
+
+		if (i == 3)	/* no vmlinux entry for 'D' */
+			continue;
+
+		ent = create_proc_entry("vmlinux", S_IFREG|S_IWUSR, mf);
+		if (!ent)
+			return;
+		ent->nlink = 1;
+		ent->data = (void *)(long)i;
+#if 0
+		if (i == 3) {
+			/*
+			 * if we had a 'D' vmlinux entry, it would only
+			 * be readable.
+			 */
+			ent->read_proc = proc_mf_dump_vmlinux;
+			ent->write_proc = NULL;
+		} else
+#endif
+		{
+			ent->write_proc = proc_mf_change_vmlinux;
+			ent->read_proc = NULL;
+		}
+	}
+
+	ent = create_proc_entry("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
+	if (!ent)
+		return;
+	ent->nlink = 1;
+	ent->data = (void *)0;
+	ent->read_proc = proc_mf_dump_side;
+	ent->write_proc = proc_mf_change_side;
+
+	ent = create_proc_entry("src", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
+	if (!ent)
+		return;
+	ent->nlink = 1;
+	ent->data = (void *)0;
+	ent->read_proc = proc_mf_dump_src;
+	ent->write_proc = proc_mf_change_src;
+}
diff -puN arch/ppc64/kernel/misc.S~linus arch/ppc64/kernel/misc.S
--- 25/arch/ppc64/kernel/misc.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/misc.S	2004-01-19 22:17:21.000000000 -0800
@@ -66,32 +66,31 @@ _GLOBAL(get_sp)
 	blr
 		
 #ifdef CONFIG_PPC_ISERIES
-/* unsigned long __no_use_save_flags(void) */
-_GLOBAL(__no_use_save_flags)
-#warning FIX ISERIES
-	mfspr	r4,SPRG3
-	lbz	r3,PACAPROCENABLED(r4)
+/* unsigned long local_save_flags(void) */
+_GLOBAL(local_get_flags)
+	lbz	r3,PACAPROCENABLED(r13)
 	blr
 
-/* void __no_use_restore_flags(unsigned long flags) */	
-_GLOBAL(__no_use_restore_flags)
-/*
- * Just set/clear the MSR_EE bit through restore/flags but do not
- * change anything else.  This is needed by the RT system and makes
- * sense anyway.
- *    -- Cort
- */
-#warning FIX ISERIES
-	mfspr	r6,SPRG3
-	lbz	r5,PACAPROCENABLED(r6)
+/* unsigned long local_irq_disable(void) */
+_GLOBAL(local_irq_disable)
+	lbz	r3,PACAPROCENABLED(r13)
+	li	r4,0
+	stb	r4,PACAPROCENABLED(r13)
+	blr			/* Done */
+
+/* void local_irq_restore(unsigned long flags) */	
+_GLOBAL(local_irq_restore)
+	lbz	r5,PACAPROCENABLED(r13)
 	 /* Check if things are setup the way we want _already_. */
 	cmpw	0,r3,r5
 	beqlr
 	/* are we enabling interrupts? */
 	cmpi	0,r3,0
-	stb	r3,PACAPROCENABLED(r6)
+	stb	r3,PACAPROCENABLED(r13)
 	beqlr
 	/* Check pending interrupts */
+	/*   A decrementer, IPI or PMC interrupt may have occurred
+	 *   while we were in the hypervisor (which enables) */
 	CHECKANYINT(r4,r5)
 	beqlr
 
@@ -101,35 +100,8 @@ _GLOBAL(__no_use_restore_flags)
 	li	r0,0x5555
 	sc
 	blr
+#endif /* CONFIG_PPC_ISERIES */
 
-_GLOBAL(__no_use_cli)
-#warning FIX ISERIES
-	mfspr	r5,SPRG3
-	lbz	r3,PACAPROCENABLED(r5)
-	li	r4,0
-	stb	r4,PACAPROCENABLED(r5)
-	blr			/* Done */
-
-_GLOBAL(__no_use_sti)
-#warning FIX ISERIES
-	mfspr	r6,SPRG3
-	li	r3,1
-	stb	r3,PACAPROCENABLED(r6)
-
-	/* Check for pending interrupts
-	 *   A decrementer, IPI or PMC interrupt may have occurred
-	 *   while we were in the hypervisor (which enables)
-	 */
-	CHECKANYINT(r4,r5)
-	beqlr
-
-	/* 
-	 * Handle pending interrupts in interrupt context
-	 */
-	li	r0,0x5555
-	sc	
-	blr
-#endif
 /*
  * Flush instruction cache.
  */
@@ -446,7 +418,7 @@ _GLOBAL(cvt_df)
 	blr
 
 /*
- * identify_cpu,
+ * identify_cpu and calls setup_cpu
  * In:	r3 = base of the cpu_specs array
  *	r4 = address of cur_cpu_spec
  *	r5 = relocation offset
@@ -462,9 +434,17 @@ _GLOBAL(identify_cpu)
 	addi	r3,r3,CPU_SPEC_ENTRY_SIZE
 	b	1b
 1:
-	add	r3,r3,r5
-	std	r3,0(r4)
-	blr
+	add	r0,r3,r5
+	std	r0,0(r4)
+	ld	r4,CPU_SPEC_SETUP(r3)
+	sub	r4,r4,r5
+	ld	r4,0(r4)
+	sub	r4,r4,r5
+	mtctr	r4
+	/* Calling convention for cpu setup is r3=offset, r4=cur_cpu_spec */
+	mr	r4,r3
+	mr	r3,r5
+	bctr
 
 /*
  * do_cpu_ftr_fixups - goes through the list of CPU feature fixups
@@ -514,25 +494,6 @@ _GLOBAL(do_cpu_ftr_fixups)
 	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
@@ -595,6 +556,10 @@ SYSCALL(dup)
 SYSCALL(execve)
 SYSCALL(waitpid)
 
+#ifdef CONFIG_PPC_ISERIES	/* hack hack hack */
+#define ppc_rtas	sys_ni_syscall
+#endif
+
 /* Why isn't this a) automatic, b) written in 'C'? */	
 	.balign 8
 _GLOBAL(sys_call_table32)
@@ -825,10 +790,10 @@ _GLOBAL(sys_call_table32)
 	.llong .sys_ni_syscall
 	.llong .sys_ni_syscall		/* 225 - reserved for tux */
 	.llong .sys32_sendfile64
-	.llong .sys32_io_setup
+	.llong .compat_sys_io_setup
 	.llong .sys_io_destroy
-	.llong .sys32_io_getevents
-	.llong .sys32_io_submit
+	.llong .compat_sys_io_getevents
+	.llong .compat_sys_io_submit
 	.llong .sys_io_cancel
 	.llong .sys_set_tid_address
 	.llong .ppc32_fadvise64
@@ -838,20 +803,22 @@ _GLOBAL(sys_call_table32)
 	.llong .sys_epoll_ctl
 	.llong .sys_epoll_wait
 	.llong .sys_remap_file_pages
-	.llong .sys_ni_syscall		/* 240 */
-	.llong .sys_ni_syscall
-	.llong .sys_ni_syscall
-	.llong .sys_ni_syscall
-	.llong .sys_ni_syscall
-	.llong .sys_ni_syscall		/* 245 */
-	.llong .sys_ni_syscall
-	.llong .sys_ni_syscall
-	.llong .sys_ni_syscall
-	.llong .sys_ni_syscall
+	.llong .ppc32_timer_create	/* 240 */
+	.llong .compat_timer_settime
+	.llong .compat_timer_gettime
+	.llong .sys_timer_getoverrun
+	.llong .sys_timer_delete
+	.llong .compat_clock_settime	/* 245 */
+	.llong .compat_clock_gettime
+	.llong .compat_clock_getres
+	.llong .compat_clock_nanosleep
+	.llong .ppc32_swapcontext
 	.llong .sys32_tgkill		/* 250 */
 	.llong .sys32_utimes
-	.llong .sys_statfs64
-	.llong .sys_fstatfs64
+	.llong .compat_statfs64
+	.llong .compat_fstatfs64
+	.llong .ppc32_fadvise64_64	/* 32bit only fadvise64_64 */
+	.llong .ppc_rtas		/* 255 */
 
 	.balign 8
 _GLOBAL(sys_call_table)
@@ -1104,8 +1071,10 @@ _GLOBAL(sys_call_table)
 	.llong .sys_clock_gettime
 	.llong .sys_clock_getres
 	.llong .sys_clock_nanosleep
-	.llong .sys_ni_syscall
+	.llong .ppc64_swapcontext
 	.llong .sys_tgkill		/* 250 */
 	.llong .sys_utimes
 	.llong .sys_statfs64
 	.llong .sys_fstatfs64
+	.llong .sys_ni_syscall		/* 32bit only fadvise64_64 */
+	.llong .ppc_rtas		/* 255 */
diff -puN arch/ppc64/kernel/module.c~linus arch/ppc64/kernel/module.c
--- 25/arch/ppc64/kernel/module.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/module.c	2004-01-19 22:17:21.000000000 -0800
@@ -404,10 +404,6 @@ int module_finalize(const Elf_Ehdr *hdr,
 	 */
 	list_add(&me->arch.bug_list, &module_bug_list);
 
-	sort_ex_table((struct exception_table_entry *)me->extable,
-		      (struct exception_table_entry *)me->extable +
-				me->num_exentries);
-
 	return 0;
 }
 
diff -puN arch/ppc64/kernel/nvram.c~linus arch/ppc64/kernel/nvram.c
--- 25/arch/ppc64/kernel/nvram.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/nvram.c	2004-01-19 22:17:21.000000000 -0800
@@ -20,23 +20,50 @@
 #include <linux/fcntl.h>
 #include <linux/nvram.h>
 #include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
 #include <asm/uaccess.h>
 #include <asm/nvram.h>
 #include <asm/rtas.h>
 #include <asm/prom.h>
+#include <asm/machdep.h>
 
-static unsigned int rtas_nvram_size;
+#define DEBUG_NVRAM
+
+static int nvram_scan_partitions(void);
+static int nvram_setup_partition(void);
+static int nvram_create_os_partition(void);
+static int nvram_remove_os_partition(void);
+static unsigned char nvram_checksum(struct nvram_header *p);
+static int nvram_write_header(struct nvram_partition * part);
+
+static unsigned int nvram_size;
 static unsigned int nvram_fetch, nvram_store;
-static char nvram_buf[4];	/* assume this is in the first 4GB */
+static char nvram_buf[NVRW_CNT];	/* assume this is in the first 4GB */
+static struct nvram_partition * nvram_part;
+static long nvram_error_log_index = -1;
+static long nvram_error_log_size = 0;
+static spinlock_t nvram_lock = SPIN_LOCK_UNLOCKED;
+
+volatile int no_more_logging = 1; /* Until we initialize everything,
+				   * make sure we don't try logging
+				   * anything */
+
+extern volatile int error_log_cnt;
+
+struct err_log_info {
+	int error_type;
+	unsigned int seq_num;
+};
 
-static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
+static loff_t dev_nvram_llseek(struct file *file, loff_t offset, int origin)
 {
 	switch (origin) {
 	case 1:
 		offset += file->f_pos;
 		break;
 	case 2:
-		offset += rtas_nvram_size;
+		offset += nvram_size;
 		break;
 	}
 	if (offset < 0)
@@ -46,53 +73,76 @@ static loff_t nvram_llseek(struct file *
 }
 
 
-static ssize_t read_nvram(struct file *file, char *buf,
+static ssize_t dev_nvram_read(struct file *file, char *buf,
 			  size_t count, loff_t *ppos)
 {
-	unsigned int i;
-	unsigned long len;
-	char *p = buf;
+	ssize_t len;
+	char *tmp_buffer;
 
 	if (verify_area(VERIFY_WRITE, buf, count))
 		return -EFAULT;
-	if (*ppos >= rtas_nvram_size)
+	if (*ppos >= nvram_size)
 		return 0;
-	for (i = *ppos; count > 0 && i < rtas_nvram_size; ++i, ++p, --count) {
-		if ((rtas_call(nvram_fetch, 3, 2, &len, i, __pa(nvram_buf), 1) != 0) ||
-		    len != 1)
-			return -EIO;
-		if (__put_user(nvram_buf[0], p))
-			return -EFAULT;
+	if (count > nvram_size) 
+		count = nvram_size;
+
+	tmp_buffer = (char *) kmalloc(count, GFP_KERNEL);
+	if (!tmp_buffer) {
+		printk(KERN_ERR "dev_read_nvram: kmalloc failed\n");
+		return -ENOMEM;
 	}
-	*ppos = i;
-	return p - buf;
+
+	len = ppc_md.nvram_read(tmp_buffer, count, ppos);
+	if ((long)len <= 0) {
+		kfree(tmp_buffer);
+		return len;
+	}
+
+	if (copy_to_user(buf, tmp_buffer, len)) {
+		kfree(tmp_buffer);
+		return -EFAULT;
+	}
+
+	kfree(tmp_buffer);
+	return len;
+
 }
 
-static ssize_t write_nvram(struct file *file, const char *buf,
+static ssize_t dev_nvram_write(struct file *file, const char *buf,
 			   size_t count, loff_t *ppos)
 {
-	unsigned int i;
-	unsigned long len;
-	const char *p = buf;
-	char c;
+	ssize_t len;
+	char * tmp_buffer;
 
 	if (verify_area(VERIFY_READ, buf, count))
 		return -EFAULT;
-	if (*ppos >= rtas_nvram_size)
+	if (*ppos >= nvram_size)
 		return 0;
-	for (i = *ppos; count > 0 && i < rtas_nvram_size; ++i, ++p, --count) {
-		if (__get_user(c, p))
-			return -EFAULT;
-		nvram_buf[0] = c;
-		if ((rtas_call(nvram_store, 3, 2, &len, i, __pa(nvram_buf), 1) != 0) ||
-		    len != 1)
-			return -EIO;
+	if (count > nvram_size)
+		count = nvram_size;
+
+	tmp_buffer = (char *) kmalloc(count, GFP_KERNEL);
+	if (!tmp_buffer) {
+		printk(KERN_ERR "dev_nvram_write: kmalloc failed\n");
+		return -ENOMEM;
 	}
-	*ppos = i;
-	return p - buf;
+	
+	if (copy_from_user(tmp_buffer, buf, count)) {
+		kfree(tmp_buffer);
+		return -EFAULT;
+	}
+
+	len = ppc_md.nvram_write(tmp_buffer, count, ppos);
+	if ((long)len <= 0) {
+		kfree(tmp_buffer);
+		return len;
+	}
+
+	kfree(tmp_buffer);
+	return len;
 }
 
-static int nvram_ioctl(struct inode *inode, struct file *file,
+static int dev_nvram_ioctl(struct inode *inode, struct file *file,
 	unsigned int cmd, unsigned long arg)
 {
 	return -EINVAL;
@@ -100,10 +150,10 @@ static int nvram_ioctl(struct inode *ino
 
 struct file_operations nvram_fops = {
 	.owner =	THIS_MODULE,
-	.llseek =	nvram_llseek,
-	.read =		read_nvram,
-	.write =	write_nvram,
-	.ioctl =	nvram_ioctl,
+	.llseek =	dev_nvram_llseek,
+	.read =		dev_nvram_read,
+	.write =	dev_nvram_write,
+	.ioctl =	dev_nvram_ioctl,
 };
 
 static struct miscdevice nvram_dev = {
@@ -112,21 +162,135 @@ static struct miscdevice nvram_dev = {
 	&nvram_fops
 };
 
+ssize_t pSeries_nvram_read(char *buf, size_t count, loff_t *index)
+{
+	unsigned int i;
+	unsigned long len, done;
+	unsigned long flags;
+	char *p = buf;
+
+	if (*index >= nvram_size)
+		return 0;
+
+	i = *index;
+	if (i + count > nvram_size)
+		count = nvram_size - i;
+
+	spin_lock_irqsave(&nvram_lock, flags);
+
+	for (; count != 0; count -= len) {
+		len = count;
+		if (len > NVRW_CNT)
+			len = NVRW_CNT;
+		
+		if ((rtas_call(nvram_fetch, 3, 2, &done, i, __pa(nvram_buf),
+			       len) != 0) || len != done) {
+			spin_unlock_irqrestore(&nvram_lock, flags);
+			return -EIO;
+		}
+		
+		memcpy(p, nvram_buf, len);
+
+		p += len;
+		i += len;
+	}
+
+	spin_unlock_irqrestore(&nvram_lock, flags);
+	
+	*index = i;
+	return p - buf;
+}
+
+ssize_t pSeries_nvram_write(char *buf, size_t count, loff_t *index)
+{
+	unsigned int i;
+	unsigned long len, done;
+	unsigned long flags;
+	const char *p = buf;
+
+	if (*index >= nvram_size)
+		return 0;
+
+	i = *index;
+	if (i + count > nvram_size)
+		count = nvram_size - i;
+
+	spin_lock_irqsave(&nvram_lock, flags);
+
+	for (; count != 0; count -= len) {
+		len = count;
+		if (len > NVRW_CNT)
+			len = NVRW_CNT;
+
+		memcpy(nvram_buf, p, len);
+
+		if ((rtas_call(nvram_store, 3, 2, &done, i, __pa(nvram_buf),
+			       len) != 0) || len != done) {
+			spin_unlock_irqrestore(&nvram_lock, flags);
+			return -EIO;
+		}
+		
+		p += len;
+		i += len;
+	}
+	spin_unlock_irqrestore(&nvram_lock, flags);
+	
+	*index = i;
+	return p - buf;
+}
+ 
 int __init nvram_init(void)
 {
 	struct device_node *nvram;
 	unsigned int *nbytes_p, proplen;
-	if ((nvram = find_type_devices("nvram")) != NULL) {
+	int error;
+	int rc;
+	
+	if ((nvram = of_find_node_by_type(NULL, "nvram")) != NULL) {
 		nbytes_p = (unsigned int *)get_property(nvram, "#bytes", &proplen);
 		if (nbytes_p && proplen == sizeof(unsigned int)) {
-			rtas_nvram_size = *nbytes_p;
+			nvram_size = *nbytes_p;
+		} else {
+			return -EIO;
 		}
 	}
 	nvram_fetch = rtas_token("nvram-fetch");
 	nvram_store = rtas_token("nvram-store");
-	printk(KERN_INFO "PPC64 nvram contains %d bytes\n", rtas_nvram_size);
+	printk(KERN_INFO "PPC64 nvram contains %d bytes\n", nvram_size);
+	of_node_put(nvram);
+
+  	rc = misc_register(&nvram_dev);
+  
+  	/* If we don't know how big NVRAM is then we shouldn't touch
+  	   the nvram partitions */
+  	if (nvram == NULL) {
+  		return rc;
+  	}
+  	
+  	/* initialize our anchor for the nvram partition list */
+  	nvram_part = (struct nvram_partition *) kmalloc(sizeof(struct nvram_partition), GFP_KERNEL);
+  	if (!nvram_part) {
+  		printk(KERN_ERR "nvram_init: Failed kmalloc\n");
+  		return -ENOMEM;
+  	}
+  	INIT_LIST_HEAD(&nvram_part->partition);
+  
+  	/* Get all the NVRAM partitions */
+  	error = nvram_scan_partitions();
+  	if (error) {
+  		printk(KERN_ERR "nvram_init: Failed nvram_scan_partitions\n");
+  		return error;
+  	}
+  		
+  	if(nvram_setup_partition()) 
+  		printk(KERN_WARNING "nvram_init: Could not find nvram partition"
+  		       " for nvram buffered error logging.\n");
+  
+#ifdef DEBUG_NVRAM
+	nvram_print_partitions("NVRAM Partitions");
+#endif
 
-	return misc_register(&nvram_dev);
+  	return rc;
 }
 
 void __exit nvram_cleanup(void)
@@ -134,6 +298,444 @@ void __exit nvram_cleanup(void)
         misc_deregister( &nvram_dev );
 }
 
+static int nvram_scan_partitions(void)
+{
+	loff_t cur_index = 0;
+	struct nvram_header phead;
+	struct nvram_partition * tmp_part;
+	unsigned char c_sum;
+	char * header;
+	long size;
+	
+	header = (char *) kmalloc(NVRAM_HEADER_LEN, GFP_KERNEL);
+	if (!header) {
+		printk(KERN_ERR "nvram_scan_partitions: Failed kmalloc\n");
+		return -ENOMEM;
+	}
+
+	while (cur_index < nvram_size) {
+
+		size = ppc_md.nvram_read(header, NVRAM_HEADER_LEN, &cur_index);
+		if (size != NVRAM_HEADER_LEN) {
+			printk(KERN_ERR "nvram_scan_partitions: Error parsing "
+			       "nvram partitions\n");
+			kfree(header);
+			return size;
+		}
+
+		cur_index -= NVRAM_HEADER_LEN; /* nvram_read will advance us */
+
+		memcpy(&phead, header, NVRAM_HEADER_LEN);
+
+		c_sum = nvram_checksum(&phead);
+		if (c_sum != phead.checksum)
+			printk(KERN_WARNING "WARNING: nvram partition checksum "
+			       "was %02x, should be %02x!\n", phead.checksum, c_sum);
+		
+		tmp_part = (struct nvram_partition *)
+			kmalloc(sizeof(struct nvram_partition), GFP_KERNEL);
+		if (!tmp_part) {
+			printk(KERN_ERR "nvram_scan_partitions: kmalloc failed\n");
+			kfree(header);
+			return -ENOMEM;
+		}
+		
+		memcpy(&tmp_part->header, &phead, NVRAM_HEADER_LEN);
+		tmp_part->index = cur_index;
+		list_add_tail(&tmp_part->partition, &nvram_part->partition);
+		
+		cur_index += phead.length * NVRAM_BLOCK_LEN;
+	}
+
+	kfree(header);
+	return 0;
+}
+
+/* nvram_setup_partition
+ *
+ * This will setup the partition we need for buffering the
+ * error logs and cleanup partitions if needed.
+ *
+ * The general strategy is the following:
+ * 1.) If there is ppc64,linux partition large enough then use it.
+ * 2.) If there is not a ppc64,linux partition large enough, search
+ * for a free partition that is large enough.
+ * 3.) If there is not a free partition large enough remove 
+ * _all_ OS partitions and consolidate the space.
+ * 4.) Will first try getting a chunk that will satisfy the maximum
+ * error log size (NVRAM_MAX_REQ).
+ * 5.) If the max chunk cannot be allocated then try finding a chunk
+ * that will satisfy the minum needed (NVRAM_MIN_REQ).
+ */
+static int nvram_setup_partition(void)
+{
+	struct list_head * p;
+	struct nvram_partition * part;
+	int rc;
+
+	/* see if we have an OS partition that meets our needs.
+	   will try getting the max we need.  If not we'll delete
+	   partitions and try again. */
+	list_for_each(p, &nvram_part->partition) {
+		part = list_entry(p, struct nvram_partition, partition);
+		if (part->header.signature != NVRAM_SIG_OS)
+			continue;
+
+		if (strcmp(part->header.name, "ppc64,linux"))
+			continue;
+
+		if (part->header.length >= NVRAM_MIN_REQ) {
+			/* found our partition */
+			nvram_error_log_index = part->index + NVRAM_HEADER_LEN;
+			nvram_error_log_size = ((part->header.length - 1) *
+						NVRAM_BLOCK_LEN) - sizeof(struct err_log_info);
+			return 0;
+		}
+	}
+	
+	/* try creating a partition with the free space we have */
+	rc = nvram_create_os_partition();
+	if (!rc) {
+		return 0;
+	}
+		
+	/* need to free up some space */
+	rc = nvram_remove_os_partition();
+	if (rc) {
+		return rc;
+	}
+	
+	/* create a partition in this new space */
+	rc = nvram_create_os_partition();
+	if (rc) {
+		printk(KERN_ERR "nvram_create_os_partition: Could not find a "
+		       "NVRAM partition large enough\n");
+		return rc;
+	}
+	
+	return 0;
+}
+
+static int nvram_remove_os_partition(void)
+{
+	struct list_head *i;
+	struct list_head *j;
+	struct nvram_partition * part;
+	struct nvram_partition * cur_part;
+	int rc;
+
+	list_for_each(i, &nvram_part->partition) {
+		part = list_entry(i, struct nvram_partition, partition);
+		if (part->header.signature != NVRAM_SIG_OS)
+			continue;
+		
+		/* Make os partition a free partition */
+		part->header.signature = NVRAM_SIG_FREE;
+		sprintf(part->header.name, "wwwwwwwwwwww");
+		part->header.checksum = nvram_checksum(&part->header);
+
+		/* Merge contiguous free partitions backwards */
+		list_for_each_prev(j, &part->partition) {
+			cur_part = list_entry(j, struct nvram_partition, partition);
+			if (cur_part == nvram_part || cur_part->header.signature != NVRAM_SIG_FREE) {
+				break;
+			}
+			
+			part->header.length += cur_part->header.length;
+			part->header.checksum = nvram_checksum(&part->header);
+			part->index = cur_part->index;
+
+			list_del(&cur_part->partition);
+			kfree(cur_part);
+			j = &part->partition; /* fixup our loop */
+		}
+		
+		/* Merge contiguous free partitions forwards */
+		list_for_each(j, &part->partition) {
+			cur_part = list_entry(j, struct nvram_partition, partition);
+			if (cur_part == nvram_part || cur_part->header.signature != NVRAM_SIG_FREE) {
+				break;
+			}
+
+			part->header.length += cur_part->header.length;
+			part->header.checksum = nvram_checksum(&part->header);
+
+			list_del(&cur_part->partition);
+			kfree(cur_part);
+			j = &part->partition; /* fixup our loop */
+		}
+		
+		rc = nvram_write_header(part);
+		if (rc <= 0) {
+			printk(KERN_ERR "nvram_remove_os_partition: nvram_write failed (%d)\n", rc);
+			return rc;
+		}
+
+	}
+	
+	return 0;
+}
+
+/* nvram_create_os_partition
+ *
+ * Create a OS linux partition to buffer error logs.
+ * Will create a partition starting at the first free
+ * space found if space has enough room.
+ */
+static int nvram_create_os_partition(void)
+{
+	struct list_head * p;
+	struct nvram_partition * part;
+	struct nvram_partition * new_part = NULL;
+	struct nvram_partition * free_part;
+	int seq_init[2] = { 0, 0 };
+	loff_t tmp_index;
+	long size = 0;
+	int rc;
+	
+	/* Find a free partition that will give us the maximum needed size 
+	   If can't find one that will give us the minimum size needed */
+	list_for_each(p, &nvram_part->partition) {
+		part = list_entry(p, struct nvram_partition, partition);
+		if (part->header.signature != NVRAM_SIG_FREE)
+			continue;
+
+		if (part->header.length >= NVRAM_MAX_REQ) {
+			size = NVRAM_MAX_REQ;
+			free_part = part;
+			break;
+		}
+		if (!size && part->header.length >= NVRAM_MIN_REQ) {
+			size = NVRAM_MIN_REQ;
+			free_part = part;
+		}
+	}
+	if (!size) {
+		return -ENOSPC;
+	}
+	
+	/* Create our OS partition */
+	new_part = (struct nvram_partition *)
+		kmalloc(sizeof(struct nvram_partition), GFP_KERNEL);
+	if (!new_part) {
+		printk(KERN_ERR "nvram_create_os_partition: kmalloc failed\n");
+		return -ENOMEM;
+	}
+
+	new_part->index = free_part->index;
+	new_part->header.signature = NVRAM_SIG_OS;
+	new_part->header.length = size;
+	sprintf(new_part->header.name, "ppc64,linux");
+	new_part->header.checksum = nvram_checksum(&new_part->header);
+
+	rc = nvram_write_header(new_part);
+	if (rc <= 0) {
+		printk(KERN_ERR "nvram_create_os_partition: nvram_write_header \
+				failed (%d)\n", rc);
+		return rc;
+	}
+
+	/* make sure and initialize to zero the sequence number and the error
+	   type logged */
+	tmp_index = new_part->index + NVRAM_HEADER_LEN;
+	rc = ppc_md.nvram_write((char *)&seq_init, sizeof(seq_init), &tmp_index);
+	if (rc <= 0) {
+		printk(KERN_ERR "nvram_create_os_partition: nvram_write failed (%d)\n", rc);
+		return rc;
+	}
+	
+	nvram_error_log_index = new_part->index + NVRAM_HEADER_LEN;
+	nvram_error_log_size = ((part->header.length - 1) *
+				NVRAM_BLOCK_LEN) - sizeof(struct err_log_info);
+	
+	list_add_tail(&new_part->partition, &free_part->partition);
+
+	if (free_part->header.length <= size) {
+		list_del(&free_part->partition);
+		kfree(free_part);
+		return 0;
+	} 
+
+	/* Adjust the partition we stole the space from */
+	free_part->index += size * NVRAM_BLOCK_LEN;
+	free_part->header.length -= size;
+	free_part->header.checksum = nvram_checksum(&free_part->header);
+	
+	rc = nvram_write_header(free_part);
+	if (rc <= 0) {
+		printk(KERN_ERR "nvram_create_os_partition: nvram_write_header "
+		       "failed (%d)\n", rc);
+		return rc;
+	}
+
+	return 0;
+}
+
+
+void nvram_print_partitions(char * label)
+{
+	struct list_head * p;
+	struct nvram_partition * tmp_part;
+	
+	printk(KERN_WARNING "--------%s---------\n", label);
+	printk(KERN_WARNING "indx\t\tsig\tchks\tlen\tname\n");
+	list_for_each(p, &nvram_part->partition) {
+		tmp_part = list_entry(p, struct nvram_partition, partition);
+		printk(KERN_WARNING "%d    \t%02x\t%02x\t%d\t%s\n",
+		       tmp_part->index, tmp_part->header.signature,
+		       tmp_part->header.checksum, tmp_part->header.length,
+		       tmp_part->header.name);
+	}
+}
+
+/* nvram_write_error_log
+ *
+ * We need to buffer the error logs into nvram to ensure that we have
+ * the failure information to decode.  If we have a severe error there
+ * is no way to guarantee that the OS or the machine is in a state to
+ * get back to user land and write the error to disk.  For example if
+ * the SCSI device driver causes a Machine Check by writing to a bad
+ * IO address, there is no way of guaranteeing that the device driver
+ * is in any state that is would also be able to write the error data
+ * captured to disk, thus we buffer it in NVRAM for analysis on the
+ * next boot.
+ *
+ * In NVRAM the partition containing the error log buffer will looks like:
+ * Header (in bytes):
+ * +-----------+----------+--------+------------+------------------+
+ * | signature | checksum | length | name       | data             |
+ * |0          |1         |2      3|4         15|16        length-1|
+ * +-----------+----------+--------+------------+------------------+
+ *
+ * The 'data' section would look like (in bytes):
+ * +--------------+------------+-----------------------------------+
+ * | event_logged | sequence # | error log                         |
+ * |0            3|4          7|8            nvram_error_log_size-1|
+ * +--------------+------------+-----------------------------------+
+ *
+ * event_logged: 0 if event has not been logged to syslog, 1 if it has
+ * sequence #: The unique sequence # for each event. (until it wraps)
+ * error log: The error log from event_scan
+ */
+int nvram_write_error_log(char * buff, int length, unsigned int err_type)
+{
+	int rc;
+	loff_t tmp_index;
+	struct err_log_info info;
+	
+	if (no_more_logging) {
+		return -EPERM;
+	}
+
+	if (nvram_error_log_index == -1) {
+		return -ESPIPE;
+	}
+
+	if (length > nvram_error_log_size) {
+		length = nvram_error_log_size;
+	}
+
+	info.error_type = err_type;
+	info.seq_num = error_log_cnt;
+
+	tmp_index = nvram_error_log_index;
+
+	rc = ppc_md.nvram_write((char *)&info, sizeof(struct err_log_info), &tmp_index);
+	if (rc <= 0) {
+		printk(KERN_ERR "nvram_write_error_log: Failed nvram_write (%d)\n", rc);
+		return rc;
+	}
+
+	rc = ppc_md.nvram_write(buff, length, &tmp_index);
+	if (rc <= 0) {
+		printk(KERN_ERR "nvram_write_error_log: Failed nvram_write (%d)\n", rc);
+		return rc;
+	}
+	
+	return 0;
+}
+
+/* nvram_read_error_log
+ *
+ * Reads nvram for error log for at most 'length'
+ */
+int nvram_read_error_log(char * buff, int length, unsigned int * err_type)
+{
+	int rc;
+	loff_t tmp_index;
+	struct err_log_info info;
+	
+	if (nvram_error_log_index == -1)
+		return -1;
+
+	if (length > nvram_error_log_size)
+		length = nvram_error_log_size;
+
+	tmp_index = nvram_error_log_index;
+
+	rc = ppc_md.nvram_read((char *)&info, sizeof(struct err_log_info), &tmp_index);
+	if (rc <= 0) {
+		printk(KERN_ERR "nvram_read_error_log: Failed nvram_read (%d)\n", rc);
+		return rc;
+	}
+
+	rc = ppc_md.nvram_read(buff, length, &tmp_index);
+	if (rc <= 0) {
+		printk(KERN_ERR "nvram_read_error_log: Failed nvram_read (%d)\n", rc);
+		return rc;
+	}
+
+	error_log_cnt = info.seq_num;
+	*err_type = info.error_type;
+
+	return 0;
+}
+
+/* This doesn't actually zero anything, but it sets the event_logged
+ * word to tell that this event is safely in syslog.
+ */
+int nvram_clear_error_log()
+{
+	loff_t tmp_index;
+	int clear_word = ERR_FLAG_ALREADY_LOGGED;
+	int rc;
+
+	tmp_index = nvram_error_log_index;
+	
+	rc = ppc_md.nvram_write((char *)&clear_word, sizeof(int), &tmp_index);
+	if (rc <= 0) {
+		printk(KERN_ERR "nvram_clear_error_log: Failed nvram_write (%d)\n", rc);
+		return rc;
+	}
+
+	return 0;
+}
+
+static int nvram_write_header(struct nvram_partition * part)
+{
+	loff_t tmp_index;
+	int rc;
+	
+	tmp_index = part->index;
+	rc = ppc_md.nvram_write((char *)&part->header, NVRAM_HEADER_LEN, &tmp_index); 
+
+	return rc;
+}
+
+static unsigned char nvram_checksum(struct nvram_header *p)
+{
+	unsigned int c_sum, c_sum2;
+	unsigned short *sp = (unsigned short *)p->name; /* assume 6 shorts */
+	c_sum = p->signature + p->length + sp[0] + sp[1] + sp[2] + sp[3] + sp[4] + sp[5];
+
+	/* The sum may have spilled into the 3rd byte.  Fold it back. */
+	c_sum = ((c_sum & 0xffff) + (c_sum >> 16)) & 0xffff;
+	/* The sum cannot exceed 2 bytes.  Fold it into a checksum */
+	c_sum2 = (c_sum >> 8) + (c_sum << 8);
+	c_sum = ((c_sum + c_sum2) >> 8) & 0xff;
+	return c_sum;
+}
+
 module_init(nvram_init);
 module_exit(nvram_cleanup);
 MODULE_LICENSE("GPL");
diff -puN arch/ppc64/kernel/open_pic.c~linus arch/ppc64/kernel/open_pic.c
--- 25/arch/ppc64/kernel/open_pic.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/open_pic.c	2004-01-19 22:17:21.000000000 -0800
@@ -85,10 +85,10 @@ unsigned int openpic_vec_spurious;
  */
 #ifdef CONFIG_SMP
 #define THIS_CPU		Processor[cpu]
-#define DECL_THIS_CPU		int cpu = smp_processor_id()
+#define DECL_THIS_CPU		int cpu = hard_smp_processor_id()
 #define CHECK_THIS_CPU		check_arg_cpu(cpu)
 #else
-#define THIS_CPU		Processor[smp_processor_id()]
+#define THIS_CPU		Processor[hard_smp_processor_id()]
 #define DECL_THIS_CPU
 #define CHECK_THIS_CPU
 #endif /* CONFIG_SMP */
@@ -142,7 +142,7 @@ void __init openpic_init_IRQ(void)
         struct device_node *kbd;
 #endif
 
-        if (!(np = find_devices("pci"))
+        if (!(np = of_find_node_by_name(NULL, "pci"))
             || !(addrp = (unsigned int *)
                  get_property(np, "8259-interrupt-acknowledge", NULL)))
                 printk(KERN_ERR "Cannot find pci to get ack address\n");
@@ -158,6 +158,7 @@ void __init openpic_init_IRQ(void)
         openpic_init(1, NUM_8259_INTERRUPTS, chrp_int_ack_special, nmi_irq);
         for ( i = 0 ; i < NUM_8259_INTERRUPTS  ; i++ )
                 irq_desc[i].handler = &i8259_pic;
+	of_node_put(np);
 }
 
 static inline u_int openpic_read(volatile u_int *addr)
@@ -354,7 +355,7 @@ void __init openpic_init(int main_pic, i
 	/* SIOint (8259 cascade) is special */
 	if (offset) {
 		openpic_initirq(0, 8, offset, 1, 1);
-		openpic_mapirq(0, 1 << boot_cpuid);
+		openpic_mapirq(0, 1 << get_hard_smp_processor_id(boot_cpuid));
 	}
 
 	/* Init all external sources */
@@ -372,7 +373,7 @@ void __init openpic_init(int main_pic, i
 		/* Enabled, Priority 8 or 9 */
 		openpic_initirq(i, pri, i+offset, !sense, sense);
 		/* Processor 0 */
-		openpic_mapirq(i, 1 << boot_cpuid);
+		openpic_mapirq(i, 1 << get_hard_smp_processor_id(boot_cpuid));
 	}
 
 	/* Init descriptors */
@@ -513,10 +514,23 @@ static void openpic_set_spurious(u_int v
 			   vec);
 }
 
+/*
+ * Convert a cpu mask from logical to physical cpu numbers.
+ */
+static inline u32 physmask(u32 cpumask)
+{
+	int i;
+	u32 mask = 0;
+
+	for (i = 0; i < NR_CPUS; ++i, cpumask >>= 1)
+		mask |= (cpumask & 1) << get_hard_smp_processor_id(i);
+	return mask;
+}
+
 void openpic_init_processor(u_int cpumask)
 {
 	openpic_write(&OpenPIC->Global.Processor_Initialization,
-		      cpumask & cpus_coerce(cpu_online_map));
+		      physmask(cpumask & cpus_coerce(cpu_online_map)));
 }
 
 #ifdef CONFIG_SMP
@@ -550,7 +564,7 @@ void openpic_cause_IPI(u_int ipi, u_int 
 	CHECK_THIS_CPU;
 	check_arg_ipi(ipi);
 	openpic_write(&OpenPIC->THIS_CPU.IPI_Dispatch(ipi),
-		      cpumask & cpus_coerce(cpu_online_map));
+		      physmask(cpumask & cpus_coerce(cpu_online_map)));
 }
 
 void openpic_request_IPIs(void)
@@ -591,7 +605,7 @@ void __devinit do_openpic_setup_cpu(void
 {
 #ifdef CONFIG_IRQ_ALL_CPUS
  	int i;
-	u32 msk = 1 << smp_processor_id();
+	u32 msk = 1 << hard_smp_processor_id();
 #endif
 
 	spin_lock(&openpic_setup_lock);
@@ -636,7 +650,7 @@ static void __init openpic_maptimer(u_in
 {
 	check_arg_timer(timer);
 	openpic_write(&OpenPIC->Global.Timer[timer].Destination,
-		      cpumask & cpus_coerce(cpu_online_map));
+		      physmask(cpumask & cpus_coerce(cpu_online_map)));
 }
 
 
@@ -762,7 +776,7 @@ static void openpic_set_affinity(unsigne
 	cpumask_t tmp;
 
 	cpus_and(tmp, cpumask, cpu_online_map);
-	openpic_mapirq(irq_nr - open_pic_irq_offset, cpus_coerce(tmp));
+	openpic_mapirq(irq_nr - open_pic_irq_offset, physmask(cpus_coerce(tmp)));
 }
 
 #ifdef CONFIG_SMP
diff -puN arch/ppc64/kernel/pci.c~linus arch/ppc64/kernel/pci.c
--- 25/arch/ppc64/kernel/pci.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/pci.c	2004-01-19 22:17:21.000000000 -0800
@@ -144,7 +144,7 @@ struct pci_dev *pci_find_dev_by_addr(uns
 	return NULL;
 }
 
-void __devinit
+void 
 pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
 			struct resource *res)
 {
@@ -224,7 +224,11 @@ pci_alloc_pci_controller(enum phb_types 
         struct pci_controller *hose;
 	char *model;
 
+#ifdef CONFIG_PPC_ISERIES
+        hose = (struct pci_controller *)kmalloc(sizeof(struct pci_controller), GFP_KERNEL);
+#else
         hose = (struct pci_controller *)alloc_bootmem(sizeof(struct pci_controller));
+#endif
         if(hose == NULL) {
                 printk(KERN_ERR "PCI: Allocate pci_controller failed.\n");
                 return NULL;
@@ -232,6 +236,11 @@ pci_alloc_pci_controller(enum phb_types 
         memset(hose, 0, sizeof(struct pci_controller));
 
 	switch(controller_type) {
+#ifdef CONFIG_PPC_ISERIES
+	case phb_type_hypervisor:
+		model = "PHB HV";
+		break;
+#endif
 	case phb_type_python:
 		model = "PHB PY";
 		break;
@@ -280,6 +289,7 @@ static void __init pcibios_claim_one_bus
 		pcibios_claim_one_bus(child_bus);
 }
 
+#ifndef CONFIG_PPC_ISERIES
 static void __init pcibios_claim_of_setup(void)
 {
 	struct list_head *lb;
@@ -289,6 +299,7 @@ static void __init pcibios_claim_of_setu
 		pcibios_claim_one_bus(b);
 	}
 }
+#endif
 
 static int __init pcibios_init(void)
 {
@@ -311,6 +322,7 @@ static int __init pcibios_init(void)
 		hose->last_busno = bus->subordinate;
 	}
 
+#ifndef CONFIG_PPC_ISERIES
 	if (pci_probe_only)
 		pcibios_claim_of_setup();
 	else
@@ -318,6 +330,7 @@ static int __init pcibios_init(void)
 		   pci_assign_unassigned_resources() is able to work
 		   correctly with [partially] allocated PCI tree. */
 		pci_assign_unassigned_resources();
+#endif
 
 	/* Call machine dependent fixup */
 	pcibios_final_fixup();
@@ -375,19 +388,27 @@ int pcibios_enable_device(struct pci_dev
  */
 int pci_domain_nr(struct pci_bus *bus)
 {
+#ifdef CONFIG_PPC_ISERIES
+	return 0;
+#else
 	struct pci_controller *hose = PCI_GET_PHB_PTR(bus);
 
 	return hose->global_number;
+#endif
 }
 
+EXPORT_SYMBOL(pci_domain_nr);
+
 /* Set the name of the bus as it appears in /proc/bus/pci */
 int pci_name_bus(char *name, struct pci_bus *bus)
 {
+#ifndef CONFIG_PPC_ISERIES
 	struct pci_controller *hose = PCI_GET_PHB_PTR(bus);
 
 	if (hose->buid)
 		sprintf(name, "%04x:%02x", pci_domain_nr(bus), bus->number);
 	else
+#endif
 		sprintf(name, "%02x", bus->number);
 
 	return 0;
diff -puN arch/ppc64/kernel/pci_dma.c~linus arch/ppc64/kernel/pci_dma.c
--- 25/arch/ppc64/kernel/pci_dma.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/pci_dma.c	2004-01-19 22:17:21.000000000 -0800
@@ -48,11 +48,13 @@
 /* #define MONITOR_TCE 1 */ /* Turn on to sanity check TCE generation. */
 
 
+#ifdef CONFIG_PPC_PSERIES
 /* Initialize so this guy does not end up in the BSS section.
  * Only used to pass OF initialization data set in prom.c into the main 
  * kernel code -- data ultimately copied into tceTables[].
  */
 extern struct _of_tce_table of_tce_table[];
+#endif
 
 extern struct pci_controller* hose_head;
 extern struct pci_controller** hose_tail;
@@ -553,7 +555,7 @@ inline dma_addr_t get_tces( struct TceTa
 }
 
 #ifdef CONFIG_PPC_ISERIES
-static void tce_free_one_iSeries( struct TceTable *tbl, long tcenum )
+void tce_free_one_iSeries( struct TceTable *tbl, long tcenum )
 {
 	u64 set_tce_rc;
 	union Tce tce;
@@ -701,6 +703,7 @@ void create_tce_tables_for_buses(struct 
 	}
 }
 
+#ifdef CONFIG_PPC_PSERIES
 void create_tce_tables_for_busesLP(struct list_head *bus_list)
 {
 	struct list_head *ln;
@@ -722,15 +725,19 @@ void create_tce_tables_for_busesLP(struc
 		create_tce_tables_for_busesLP(&bus->children);
 	}
 }
+#endif
 
 void create_tce_tables(void) {
 	struct pci_dev *dev = NULL;
 	struct device_node *dn, *mydn;
 
+#ifdef CONFIG_PPC_PSERIES
 	if (systemcfg->platform == PLATFORM_PSERIES_LPAR) {
 		create_tce_tables_for_busesLP(&pci_root_buses);
 	}
-	else {
+	else
+#endif
+	{
 		create_tce_tables_for_buses(&pci_root_buses);
 	}
 	/* Now copy the tce_table ptr from the bus devices down to every
@@ -884,6 +891,7 @@ static void getTceTableParmsiSeries(stru
 static void getTceTableParmsPSeries(struct pci_controller *phb,
 				    struct device_node *dn,
 				    struct TceTable *newTceTable ) {
+#ifdef CONFIG_PPC_PSERIES
 	phandle node;
 	unsigned long i;
 
@@ -953,6 +961,7 @@ static void getTceTableParmsPSeries(stru
 		}
 		i++;
 	}
+#endif
 }
 
 /*
@@ -970,6 +979,7 @@ static void getTceTableParmsPSeries(stru
 static void getTceTableParmsPSeriesLP(struct pci_controller *phb,
 				    struct device_node *dn,
 				    struct TceTable *newTceTable ) {
+#ifdef CONFIG_PPC_PSERIES
 	u32 *dma_window = (u32 *)get_property(dn, "ibm,dma-window", 0);
 	if (!dma_window) {
 		panic("PCI_DMA: getTceTableParmsPSeriesLP: device %s has no ibm,dma-window property!\n", dn->full_name);
@@ -985,6 +995,7 @@ static void getTceTableParmsPSeriesLP(st
 	PPCDBG(PPCDBG_TCEINIT, "\tnewTceTable->index       = 0x%lx\n", newTceTable->index);
 	PPCDBG(PPCDBG_TCEINIT, "\tnewTceTable->startOffset = 0x%lx\n", newTceTable->startOffset);
 	PPCDBG(PPCDBG_TCEINIT, "\tnewTceTable->size        = 0x%lx\n", newTceTable->size);
+#endif
 }
 
 /* Allocates a contiguous real buffer and creates TCEs over it.
diff -puN arch/ppc64/kernel/pci_dn.c~linus arch/ppc64/kernel/pci_dn.c
--- 25/arch/ppc64/kernel/pci_dn.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/pci_dn.c	2004-01-19 22:17:21.000000000 -0800
@@ -46,6 +46,7 @@
 static void * __init
 update_dn_pci_info(struct device_node *dn, void *data)
 {
+#ifdef CONFIG_PPC_PSERIES
 	struct pci_controller *phb = (struct pci_controller *)data;
 	u32 *regs;
 	char *device_type = get_property(dn, "device_type", 0);
@@ -64,6 +65,7 @@ update_dn_pci_info(struct device_node *d
 			dn->devfn = (regs[0] >> 8) & 0xff;
 		}
 	}
+#endif
 	return NULL;
 }
 
@@ -97,6 +99,7 @@ void *traverse_pci_devices(struct device
 		return ret;
 	for (dn = start->child; dn; dn = nextdn) {
 		nextdn = NULL;
+#ifdef CONFIG_PPC_PSERIES
 		if (get_property(dn, "class-code", 0)) {
 			if (pre && (ret = pre(dn, data)) != NULL)
 				return ret;
@@ -112,6 +115,7 @@ void *traverse_pci_devices(struct device
 					post(dn, data);
 			}
 		}
+#endif
 		if (!nextdn) {
 			/* Walk up to next valid sibling. */
 			do {
diff -puN arch/ppc64/kernel/ppc_ksyms.c~linus arch/ppc64/kernel/ppc_ksyms.c
--- 25/arch/ppc64/kernel/ppc_ksyms.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/ppc_ksyms.c	2004-01-19 22:17:21.000000000 -0800
@@ -39,6 +39,7 @@
 #include <asm/hw_irq.h>
 #include <asm/abs_addr.h>
 #include <asm/cacheflush.h>
+#include <asm/proc_fs.h>
 #ifdef CONFIG_PPC_ISERIES
 #include <asm/iSeries/iSeries_pci.h>
 #include <asm/iSeries/iSeries_proc.h>
@@ -163,21 +164,23 @@ EXPORT_SYMBOL(kernel_thread);
 EXPORT_SYMBOL(flush_instruction_cache);
 EXPORT_SYMBOL(_get_PVR);
 EXPORT_SYMBOL(giveup_fpu);
-EXPORT_SYMBOL(enable_kernel_fp);
+#ifdef CONFIG_ALTIVEC
+EXPORT_SYMBOL(giveup_altivec);
+#endif
 EXPORT_SYMBOL(flush_icache_range);
 EXPORT_SYMBOL(flush_icache_user_range);
 EXPORT_SYMBOL(flush_dcache_page);
 #ifdef CONFIG_SMP
 #ifdef CONFIG_PPC_ISERIES
-EXPORT_SYMBOL(__no_use_restore_flags);
-EXPORT_SYMBOL(__no_use_save_flags);
-EXPORT_SYMBOL(__no_use_sti);
-EXPORT_SYMBOL(__no_use_cli);
+EXPORT_SYMBOL(local_get_flags);
+EXPORT_SYMBOL(local_irq_disable);
+EXPORT_SYMBOL(local_irq_restore);
 #endif
 #endif
 
 EXPORT_SYMBOL(ppc_md);
 
+#ifdef CONFIG_PPC_PSERIES
 EXPORT_SYMBOL(find_devices);
 EXPORT_SYMBOL(find_type_devices);
 EXPORT_SYMBOL(find_compatible_devices);
@@ -186,6 +189,7 @@ EXPORT_SYMBOL(device_is_compatible);
 EXPORT_SYMBOL(machine_is_compatible);
 EXPORT_SYMBOL(find_all_nodes);
 EXPORT_SYMBOL(get_property);
+#endif
 
 
 EXPORT_SYMBOL_NOVERS(memcpy);
@@ -222,3 +226,4 @@ EXPORT_SYMBOL(debugger_fault_handler);
 
 EXPORT_SYMBOL(tb_ticks_per_usec);
 EXPORT_SYMBOL(paca);
+EXPORT_SYMBOL(proc_ppc64);
diff -puN arch/ppc64/kernel/process.c~linus arch/ppc64/kernel/process.c
--- 25/arch/ppc64/kernel/process.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/process.c	2004-01-19 22:17:21.000000000 -0800
@@ -50,7 +50,10 @@
 #include <asm/cputable.h>
 #include <asm/sections.h>
 
+#ifndef CONFIG_SMP
 struct task_struct *last_task_used_math = NULL;
+struct task_struct *last_task_used_altivec = NULL;
+#endif
 
 struct mm_struct ioremap_mm = { pgd             : ioremap_dir  
                                ,page_table_lock : SPIN_LOCK_UNLOCKED };
@@ -58,8 +61,7 @@ struct mm_struct ioremap_mm = { pgd     
 char *sysmap = NULL;
 unsigned long sysmap_size = 0;
 
-void
-enable_kernel_fp(void)
+void enable_kernel_fp(void)
 {
 #ifdef CONFIG_SMP
 	if (current->thread.regs && (current->thread.regs->msr & MSR_FP))
@@ -70,6 +72,7 @@ enable_kernel_fp(void)
 	giveup_fpu(last_task_used_math);
 #endif /* CONFIG_SMP */
 }
+EXPORT_SYMBOL(enable_kernel_fp);
 
 int dump_task_fpu(struct task_struct *tsk, elf_fpregset_t *fpregs)
 {
@@ -85,6 +88,31 @@ int dump_task_fpu(struct task_struct *ts
 	return 1;
 }
 
+#ifdef CONFIG_ALTIVEC
+
+void enable_kernel_altivec(void)
+{
+#ifdef CONFIG_SMP
+	if (current->thread.regs && (current->thread.regs->msr & MSR_VEC))
+		giveup_altivec(current);
+	else
+		giveup_altivec(NULL);	/* just enables FP for kernel */
+#else
+	giveup_altivec(last_task_used_altivec);
+#endif /* CONFIG_SMP */
+}
+EXPORT_SYMBOL(enable_kernel_altivec);
+
+int dump_task_altivec(struct pt_regs *regs, elf_vrregset_t *vrregs)
+{
+	if (regs->msr & MSR_VEC)
+		giveup_altivec(current);
+	memcpy(vrregs, &current->thread.vr[0], sizeof(*vrregs));
+	return 1;
+}
+
+#endif /* CONFIG_ALTIVEC */
+
 struct task_struct *__switch_to(struct task_struct *prev,
 				struct task_struct *new)
 {
@@ -104,8 +132,20 @@ struct task_struct *__switch_to(struct t
 	 */
 	if (prev->thread.regs && (prev->thread.regs->msr & MSR_FP))
 		giveup_fpu(prev);
+#ifdef CONFIG_ALTIVEC
+	if (prev->thread.regs && (prev->thread.regs->msr & MSR_VEC))
+		giveup_altivec(prev);
+#endif /* CONFIG_ALTIVEC */
 #endif /* CONFIG_SMP */
 
+#if defined(CONFIG_ALTIVEC) && !defined(CONFIG_SMP)
+	/* Avoid the trap.  On smp this this never happens since
+	 * we don't set last_task_used_altivec -- Cort
+	 */
+	if (new->thread.regs && last_task_used_altivec == new)
+		new->thread.regs->msr |= MSR_VEC;
+#endif /* CONFIG_ALTIVEC */
+
 	new_thread = &new->thread;
 	old_thread = &current->thread;
 
@@ -158,8 +198,14 @@ void show_regs(struct pt_regs * regs)
 
 void exit_thread(void)
 {
+#ifndef CONFIG_SMP
 	if (last_task_used_math == current)
 		last_task_used_math = NULL;
+#ifdef CONFIG_ALTIVEC
+	if (last_task_used_altivec == current)
+		last_task_used_altivec = NULL;
+#endif /* CONFIG_ALTIVEC */
+#endif /* CONFIG_SMP */
 }
 
 void flush_thread(void)
@@ -169,8 +215,14 @@ void flush_thread(void)
 	if (t->flags & _TIF_ABI_PENDING)
 		t->flags ^= (_TIF_ABI_PENDING | _TIF_32BIT);
 
+#ifndef CONFIG_SMP
 	if (last_task_used_math == current)
 		last_task_used_math = NULL;
+#ifdef CONFIG_ALTIVEC
+	if (last_task_used_altivec == current)
+		last_task_used_altivec = NULL;
+#endif /* CONFIG_ALTIVEC */
+#endif /* CONFIG_SMP */
 }
 
 void
@@ -178,6 +230,25 @@ release_thread(struct task_struct *t)
 {
 }
 
+
+/*
+ * This gets called before we allocate a new thread and copy
+ * the current task into it.
+ */
+void prepare_to_copy(struct task_struct *tsk)
+{
+	struct pt_regs *regs = tsk->thread.regs;
+
+	if (regs == NULL)
+		return;
+	if (regs->msr & MSR_FP)
+		giveup_fpu(current);
+#ifdef CONFIG_ALTIVEC
+	if (regs->msr & MSR_VEC)
+		giveup_altivec(current);
+#endif /* CONFIG_ALTIVEC */
+}
+
 /*
  * Copy a thread..
  */
@@ -268,9 +339,25 @@ void start_thread(struct pt_regs *regs, 
 	regs->gpr[1] = sp;
 	regs->gpr[2] = toc;
 	regs->msr = MSR_USER64;
+#ifndef CONFIG_SMP
 	if (last_task_used_math == current)
 		last_task_used_math = 0;
+#endif /* CONFIG_SMP */
+	memset(current->thread.fpr, 0, sizeof(current->thread.fpr));
 	current->thread.fpscr = 0;
+#ifdef CONFIG_ALTIVEC
+#ifndef CONFIG_SMP
+	if (last_task_used_altivec == current)
+		last_task_used_altivec = 0;
+#endif /* CONFIG_SMP */
+	memset(current->thread.vr, 0, sizeof(current->thread.vr));
+	current->thread.vscr.u[0] = 0;
+	current->thread.vscr.u[1] = 0;
+	current->thread.vscr.u[2] = 0;
+	current->thread.vscr.u[3] = 0x00010000; /* Java mode disabled */
+	current->thread.vrsave = 0;
+	current->thread.used_vr = 0;
+#endif /* CONFIG_ALTIVEC */
 }
 
 int set_fpexc_mode(struct task_struct *tsk, unsigned int val)
@@ -314,9 +401,6 @@ int sys_clone(unsigned long clone_flags,
 		}
 	}
 
-	if (regs->msr & MSR_FP)
-		giveup_fpu(current);
-
 	return do_fork(clone_flags & ~CLONE_IDLETASK, p2, regs, 0,
 		    (int *)parent_tidptr, (int *)child_tidptr);
 }
@@ -325,9 +409,6 @@ int sys_fork(unsigned long p1, unsigned 
 	     unsigned long p4, unsigned long p5, unsigned long p6,
 	     struct pt_regs *regs)
 {
-	if (regs->msr & MSR_FP)
-		giveup_fpu(current);
-
 	return do_fork(SIGCHLD, regs->gpr[1], regs, 0, NULL, NULL);
 }
 
@@ -335,9 +416,6 @@ int sys_vfork(unsigned long p1, unsigned
 	      unsigned long p4, unsigned long p5, unsigned long p6,
 	      struct pt_regs *regs)
 {
-	if (regs->msr & MSR_FP)
-		giveup_fpu(current);
-
 	return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->gpr[1], regs, 0,
 	            NULL, NULL);
 }
@@ -355,7 +433,10 @@ int sys_execve(unsigned long a0, unsigne
 		goto out;
 	if (regs->msr & MSR_FP)
 		giveup_fpu(current);
-  
+#ifdef CONFIG_ALTIVEC
+	if (regs->msr & MSR_VEC)
+		giveup_altivec(current);
+#endif /* CONFIG_ALTIVEC */
 	error = do_execve(filename, (char **) a1, (char **) a2, regs);
   
 	if (error == 0)
diff -puN arch/ppc64/kernel/proc_pmc.c~linus arch/ppc64/kernel/proc_pmc.c
--- 25/arch/ppc64/kernel/proc_pmc.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/proc_pmc.c	2004-01-19 22:17:21.000000000 -0800
@@ -44,8 +44,6 @@
 
 static int proc_pmc_control_mode = 0;
 
-static 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, };
 
@@ -82,8 +80,8 @@ int proc_pmc_set_pmc6(  struct file *fil
 int proc_pmc_set_pmc7(  struct file *file, const char *buffer, unsigned long count, void *data);
 int proc_pmc_set_pmc8(  struct file *file, const char *buffer, unsigned long count, void *data);
 
-
-void proc_ppc64_init(void)
+#if 0
+int proc_ppc64_init(void)
 {
 	unsigned long i;
 	struct proc_dir_entry *ent = NULL;
@@ -97,15 +95,21 @@ void proc_ppc64_init(void)
 	 *   /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_init();
+		if (!proc_ppc64.root) {
+			spin_unlock(&proc_ppc64_lock);
+			return;
+		}
+	}
 	spin_unlock(&proc_ppc64_lock);
 
 	/* Placeholder for rtas interfaces. */
-	rtas_proc_dir = proc_mkdir("rtas", proc_ppc64_root);
-
+	if (proc_ppc64.rtas == NULL) {
+		return;
+	}
 
-	proc_ppc64_pmc_root = proc_mkdir("pmc", proc_ppc64_root);
+	proc_ppc64_pmc_root = proc_mkdir("pmc", proc_ppc64.root);
 
 	proc_ppc64_pmc_system_root = proc_mkdir("system", proc_ppc64_pmc_root);
 	for (i = 0; i < NR_CPUS; i++) {
@@ -116,7 +120,6 @@ void proc_ppc64_init(void)
 		}
 	}
 
-
 	/* Create directories for the software counters. */
 	for (i = 0; i < NR_CPUS; i++) {
 		if (!cpu_online(i))
@@ -181,6 +184,7 @@ void proc_ppc64_init(void)
 		ent->write_proc = NULL;
 	}
 }
+#endif
 
 /*
  * Find the requested 'file' given a proc token.
diff -puN arch/ppc64/kernel/proc_ppc64.c~linus arch/ppc64/kernel/proc_ppc64.c
--- 25/arch/ppc64/kernel/proc_ppc64.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/proc_ppc64.c	2004-01-19 22:17:21.000000000 -0800
@@ -30,6 +30,8 @@
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/proc_fs.h>
+#include <linux/slab.h>
+#include <linux/kernel.h>
 
 #include <asm/proc_fs.h>
 #include <asm/naca.h>
@@ -37,6 +39,7 @@
 #include <asm/systemcfg.h>
 #include <asm/rtas.h>
 #include <asm/uaccess.h>
+#include <asm/prom.h>
 
 struct proc_ppc64_t proc_ppc64;
 
@@ -52,15 +55,32 @@ static struct file_operations page_map_f
 	.mmap	= page_map_mmap
 };
 
+#ifdef CONFIG_PPC_PSERIES
+/* routines for /proc/ppc64/ofdt */
+static ssize_t ofdt_write(struct file *, const char __user *, size_t, loff_t *);
+static void proc_ppc64_create_ofdt(struct proc_dir_entry *);
+static int do_remove_node(char *);
+static int do_add_node(char *, size_t);
+static void release_prop_list(const struct property *);
+static struct property *new_property(const char *, const int, const unsigned char *, struct property *);
+static char * parse_next_property(char *, char *, char **, int *, unsigned char**);
+static struct file_operations ofdt_fops = {
+	.write = ofdt_write
+};
+#endif
 
-static int __init proc_ppc64_init(void)
+int __init proc_ppc64_init(void)
 {
 
-	printk(KERN_INFO "proc_ppc64: Creating /proc/ppc64/\n");
 
-	proc_ppc64.root = proc_mkdir("ppc64", 0);
-	if (!proc_ppc64.root)
+	if (proc_ppc64.root == NULL) {
+		printk(KERN_INFO "proc_ppc64: Creating /proc/ppc64/\n");
+		proc_ppc64.root = proc_mkdir("ppc64", 0);
+		if (!proc_ppc64.root)
+			return 0;
+	} else {
 		return 0;
+	}
 
 	proc_ppc64.naca = create_proc_entry("naca", S_IRUSR, proc_ppc64.root);
 	if ( proc_ppc64.naca ) {
@@ -90,8 +110,16 @@ static int __init proc_ppc64_init(void)
 		}
 	}
 
+#ifdef CONFIG_PPC_PSERIES
 	/* Placeholder for rtas interfaces. */
-	proc_ppc64.rtas = proc_mkdir("rtas", proc_ppc64.root);
+	if (proc_ppc64.rtas == NULL)
+		proc_ppc64.rtas = proc_mkdir("rtas", proc_ppc64.root);
+
+	if (proc_ppc64.rtas)
+		proc_symlink("rtas", 0, "ppc64/rtas");
+
+	proc_ppc64_create_ofdt(proc_ppc64.root);
+#endif
 
 	return 0;
 }
@@ -173,5 +201,228 @@ static int page_map_mmap( struct file *f
 	return 0;
 }
 
-fs_initcall(proc_ppc64_init);
+#ifdef CONFIG_PPC_PSERIES
+/* create /proc/ppc64/ofdt write-only by root */
+static void proc_ppc64_create_ofdt(struct proc_dir_entry *parent)
+{
+	struct proc_dir_entry *ent;
+
+	ent = create_proc_entry("ofdt", S_IWUSR, parent);
+	if (ent) {
+		ent->nlink = 1;
+		ent->data = NULL;
+		ent->size = 0;
+		ent->proc_fops = &ofdt_fops;
+	}
+}
+
+/**
+ * ofdt_write - perform operations on the Open Firmware device tree
+ *
+ * @file: not used
+ * @buf: command and arguments
+ * @count: size of the command buffer
+ * @off: not used
+ *
+ * Operations supported at this time are addition and removal of
+ * whole nodes along with their properties.  Operations on individual
+ * properties are not implemented (yet).
+ */
+static ssize_t ofdt_write(struct file *file, const char __user *buf, size_t count, loff_t *off)
+{
+	int rv = 0;
+	char *kbuf;
+	char *tmp;
+
+	if (!(kbuf = kmalloc(count + 1, GFP_KERNEL))) {
+		rv = -ENOMEM;
+		goto out;
+	}
+	if (copy_from_user(kbuf, buf, count)) {
+		rv = -EFAULT;
+		goto out;
+	}
+
+	kbuf[count] = '\0';
+
+	tmp = strchr(kbuf, ' ');
+	if (!tmp) {
+		rv = -EINVAL;
+		goto out;
+	}
+	*tmp = '\0';
+	tmp++;
+
+	if (!strcmp(kbuf, "add_node"))
+		rv = do_add_node(tmp, count - (tmp - kbuf));
+	else if (!strcmp(kbuf, "remove_node"))
+		rv = do_remove_node(tmp);
+	else
+		rv = -EINVAL;
+out:
+	kfree(kbuf);
+	return rv ? rv : count;
+}
+
+static int do_remove_node(char *buf)
+{
+	struct device_node *node;
+	int rv = 0;
+
+	if ((node = of_find_node_by_path(buf)))
+		of_remove_node(node);
+	else
+		rv = -ENODEV;
+
+	of_node_put(node);
+	return rv;
+}
+
+static int do_add_node(char *buf, size_t bufsize)
+{
+	char *path, *end, *name;
+	struct device_node *np;
+	struct property *prop = NULL;
+	unsigned char* value;
+	int length, rv = 0;
+
+	end = buf + bufsize;
+	path = buf;
+	buf = strchr(buf, ' ');
+	if (!buf)
+		return -EINVAL;
+	*buf = '\0';
+	buf++;
+
+	if ((np = of_find_node_by_path(path))) {
+		of_node_put(np);
+		return -EINVAL;
+	}
 
+	/* rv = build_prop_list(tmp, bufsize - (tmp - buf), &proplist); */
+	while (buf < end &&
+	       (buf = parse_next_property(buf, end, &name, &length, &value))) {
+		struct property *last = prop;
+
+		prop = new_property(name, length, value, last);
+		if (!prop) {
+			rv = -ENOMEM;
+			prop = last;
+			goto out;
+		}
+	}
+	if (!buf) {
+		rv = -EINVAL;
+		goto out;
+	}
+
+	rv = of_add_node(path, prop);
+
+out:
+	if (rv)
+		release_prop_list(prop);
+	return rv;
+}
+
+static struct property *new_property(const char *name, const int length, const unsigned char *value, struct property *last)
+{
+	struct property *new = kmalloc(sizeof(*new), GFP_KERNEL);
+
+	if (!new)
+		return NULL;
+	memset(new, 0, sizeof(*new));
+
+	if (!(new->name = kmalloc(strlen(name) + 1, GFP_KERNEL)))
+		goto cleanup;
+	if (!(new->value = kmalloc(length + 1, GFP_KERNEL)))
+		goto cleanup;
+
+	strcpy(new->name, name);
+	memcpy(new->value, value, length);
+	*(((char *)new->value) + length) = 0;
+	new->length = length;
+	new->next = last;
+	return new;
+
+cleanup:
+	if (new->name)
+		kfree(new->name);
+	if (new->value)
+		kfree(new->value);
+	kfree(new);
+	return NULL;
+}
+
+/**
+ * parse_next_property - process the next property from raw input buffer
+ * @buf: input buffer, must be nul-terminated
+ * @end: end of the input buffer + 1, for validation
+ * @name: return value; set to property name in buf
+ * @length: return value; set to length of value
+ * @value: return value; set to the property value in buf
+ *
+ * Note that the caller must make copies of the name and value returned,
+ * this function does no allocation or copying of the data.  Return value
+ * is set to the next name in buf, or NULL on error.
+ */
+static char * parse_next_property(char *buf, char *end, char **name, int *length, unsigned char **value)
+{
+	char *tmp;
+
+	*name = buf;
+
+	tmp = strchr(buf, ' ');
+	if (!tmp) {
+		printk(KERN_ERR "property parse failed in %s at line %d\n", __FUNCTION__, __LINE__);
+		return NULL;
+	}
+	*tmp = '\0';
+
+	if (++tmp >= end) {
+		printk(KERN_ERR "property parse failed in %s at line %d\n", __FUNCTION__, __LINE__);
+		return NULL;
+	}
+
+	/* now we're on the length */
+	*length = -1;
+	*length = simple_strtoul(tmp, &tmp, 10);
+	if (*length == -1) {
+		printk(KERN_ERR "property parse failed in %s at line %d\n", __FUNCTION__, __LINE__);
+		return NULL;
+	}
+	if (*tmp != ' ' || ++tmp >= end) {
+		printk(KERN_ERR "property parse failed in %s at line %d\n", __FUNCTION__, __LINE__);
+		return NULL;
+	}
+
+	/* now we're on the value */
+	*value = tmp;
+	tmp += *length;
+	if (tmp > end) {
+		printk(KERN_ERR "property parse failed in %s at line %d\n", __FUNCTION__, __LINE__);
+		return NULL;
+	}
+	else if (tmp < end && *tmp != ' ' && *tmp != '\0') {
+		printk(KERN_ERR "property parse failed in %s at line %d\n", __FUNCTION__, __LINE__);
+		return NULL;
+	}
+	tmp++;
+
+	/* and now we should be on the next name, or the end */
+	return tmp;
+}
+
+static void release_prop_list(const struct property *prop)
+{
+	struct property *next;
+	for (; prop; prop = next) {
+		next = prop->next;
+		kfree(prop->name);
+		kfree(prop->value);
+		kfree(prop);
+	}
+
+}
+#endif	/* defined(CONFIG_PPC_PSERIES) */
+
+fs_initcall(proc_ppc64_init);
diff -puN arch/ppc64/kernel/prom.c~linus arch/ppc64/kernel/prom.c
--- 25/arch/ppc64/kernel/prom.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/prom.c	2004-01-19 22:17:21.000000000 -0800
@@ -29,6 +29,7 @@
 #include <linux/spinlock.h>
 #include <linux/types.h>
 #include <linux/pci.h>
+#include <linux/proc_fs.h>
 #include <asm/prom.h>
 #include <asm/rtas.h>
 #include <asm/lmb.h>
@@ -44,8 +45,10 @@
 #include <asm/bitops.h>
 #include <asm/naca.h>
 #include <asm/pci.h>
+#include <asm/pci_dma.h>
 #include <asm/bootinfo.h>
 #include <asm/ppcdebug.h>
+#include <asm/sections.h>
 #include "open_pic.h"
 
 #ifdef CONFIG_LOGO_LINUX_CLUT224
@@ -147,8 +150,13 @@ char *bootpath = 0;
 char *bootdevice = 0;
 
 int boot_cpuid = 0;
+#define MAX_CPU_THREADS 2
 
 struct device_node *allnodes = 0;
+/* use when traversing tree through the allnext, child, sibling,
+ * or parent members of struct device_node.
+ */
+static rwlock_t devtree_lock = RW_LOCK_UNLOCKED;
 
 #define UNDEFINED_IRQ 0xffff
 unsigned short real_irq_to_virt_map[NR_HW_IRQS];
@@ -156,7 +164,7 @@ unsigned short virt_irq_to_real_map[NR_I
 int last_virt_irq = 2;	/* index of last virt_irq.  Skip through IPI */
 
 static unsigned long call_prom(const char *service, int nargs, int nret, ...);
-static void prom_exit(void);
+static void prom_panic(const char *reason);
 static unsigned long copy_device_tree(unsigned long);
 static unsigned long inspect_node(phandle, struct device_node *, unsigned long,
 				  unsigned long, struct device_node ***);
@@ -168,6 +176,11 @@ static int prom_next_node(phandle *);
 static struct bi_record * prom_bi_rec_verify(struct bi_record *);
 static unsigned long prom_bi_rec_reserve(unsigned long);
 static struct device_node *find_phandle(phandle);
+static void of_node_cleanup(struct device_node *);
+static struct device_node *derive_parent(const char *);
+static void add_node_proc_entries(struct device_node *);
+static void remove_node_proc_entries(struct device_node *);
+static int of_finish_dynamic_node(struct device_node *);
 
 #ifdef DEBUG_PROM
 void prom_dump_lmb(void);
@@ -223,10 +236,12 @@ call_prom(const char *service, int nargs
 
 
 static void __init
-prom_exit()
+prom_panic(const char *reason)
 {
 	unsigned long offset = reloc_offset();
 
+	prom_print(reason);
+	/* ToDo: should put up an SRC here */
 	call_prom(RELOC("exit"), 0, 0);
 
 	for (;;)			/* should never get here */
@@ -602,6 +617,9 @@ prom_instantiate_rtas(void)
 						      _rtas->base) >= 0) {
 				_rtas->entry = (long)_prom->args.rets[1];
 			}
+			RELOC(rtas_rmo_buf)
+				= lmb_alloc_base(RTAS_RMOBUF_MAX, PAGE_SIZE,
+							rtas_region);
 		}
 
 		if (_rtas->entry <= 0) {
@@ -785,8 +803,7 @@ prom_initialize_tce_table(void)
 		base = lmb_alloc(minsize, align);
 
 		if ( !base ) {
-			prom_print(RELOC("ERROR, cannot find space for TCE table.\n"));
-			prom_exit();
+			prom_panic(RELOC("ERROR, cannot find space for TCE table.\n"));
 		}
 
 		vbase = absolute_to_virt(base);
@@ -884,16 +901,21 @@ static void
 prom_hold_cpus(unsigned long mem)
 {
 	unsigned long i;
-	unsigned int cpuid;
+	unsigned int reg;
 	phandle node;
 	unsigned long offset = reloc_offset();
 	char type[64], *path;
+	int cpuid = 0;
+	unsigned int interrupt_server[MAX_CPU_THREADS];
+	unsigned int cpu_threads, hw_cpu_num;
+	int propsize;
 	extern void __secondary_hold(void);
         extern unsigned long __secondary_hold_spinloop;
         extern unsigned long __secondary_hold_acknowledge;
         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);
@@ -946,13 +968,9 @@ prom_hold_cpus(unsigned long mem)
 		if (strcmp(type, RELOC("okay")) != 0)
 			continue;
 
-                cpuid = -1;
+                reg = -1;
 		call_prom(RELOC("getprop"), 4, 1, node, RELOC("reg"),
-			  &cpuid, sizeof(cpuid));
-
-		/* Only need to start secondary procs, not ourself. */
-		if ( cpuid == _prom->cpu )
-			continue;
+			  &reg, sizeof(reg));
 
 		path = (char *) mem;
 		memset(path, 0, 256);
@@ -962,12 +980,14 @@ prom_hold_cpus(unsigned long mem)
 
 #ifdef DEBUG_PROM
 		prom_print_nl();
-		prom_print(RELOC("cpu hw idx   = 0x"));
+		prom_print(RELOC("cpuid        = 0x"));
 		prom_print_hex(cpuid);
 		prom_print_nl();
+		prom_print(RELOC("cpu hw idx   = 0x"));
+		prom_print_hex(reg);
+		prom_print_nl();
 #endif
-		prom_print(RELOC("starting cpu "));
-		prom_print(path);
+		_xPaca[cpuid].xHwProcNum = reg;
 
 		/* Init the acknowledge var which will be reset by
 		 * the secondary cpu when it awakens from its OF
@@ -975,45 +995,85 @@ prom_hold_cpus(unsigned long mem)
 		 */
 		*acknowledge = (unsigned long)-1;
 
-#ifdef DEBUG_PROM
-		prom_print(RELOC("    3) spinloop       = 0x"));
-		prom_print_hex(spinloop);
-		prom_print_nl();
-		prom_print(RELOC("    3) *spinloop      = 0x"));
-		prom_print_hex(*spinloop);
-		prom_print_nl();
-		prom_print(RELOC("    3) acknowledge    = 0x"));
-		prom_print_hex(acknowledge);
-		prom_print_nl();
-		prom_print(RELOC("    3) *acknowledge   = 0x"));
-		prom_print_hex(*acknowledge);
-		prom_print_nl();
-		prom_print(RELOC("    3) secondary_hold = 0x"));
-		prom_print_hex(secondary_hold);
-		prom_print_nl();
-#endif
-		call_prom(RELOC("start-cpu"), 3, 0, node, secondary_hold, cpuid);
-		prom_print(RELOC("..."));
-		for ( i = 0 ; (i < 100000000) && 
-			      (*acknowledge == ((unsigned long)-1)); i++ ) ;
-#ifdef DEBUG_PROM
-		{
-			unsigned long *p = 0x0;
-			prom_print(RELOC("    4) 0x0 = 0x"));
-			prom_print_hex(*p);
-			prom_print_nl();
+		propsize = call_prom(RELOC("getprop"), 4, 1, node,
+				     RELOC("ibm,ppc-interrupt-server#s"), 
+				     &interrupt_server, 
+				     sizeof(interrupt_server));
+		if (propsize < 0) {
+			/* no property.  old hardware has no SMT */
+			cpu_threads = 1;
+			interrupt_server[0] = reg; /* fake it with phys id */
+		} else {
+			/* We have a threaded processor */
+			cpu_threads = propsize / sizeof(u32);
+			if (cpu_threads > MAX_CPU_THREADS) {
+				prom_print(RELOC("SMT: too many threads!\nSMT: found "));
+				prom_print_hex(cpu_threads);
+				prom_print(RELOC(", max is "));
+				prom_print_hex(MAX_CPU_THREADS);
+				prom_print_nl();
+				cpu_threads = 1; /* ToDo: panic? */
+			}
 		}
+
+		hw_cpu_num = interrupt_server[0];
+		if (hw_cpu_num != _prom->cpu) {
+			/* Primary Thread of non-boot cpu */
+			prom_print_hex(cpuid);
+			prom_print(RELOC(" : starting cpu "));
+			prom_print(path);
+			prom_print(RELOC("..."));
+			call_prom(RELOC("start-cpu"), 3, 0, node, 
+				  secondary_hold, cpuid);
+
+			for ( i = 0 ; (i < 100000000) && 
+			      (*acknowledge == ((unsigned long)-1)); i++ ) ;
+
+			if (*acknowledge == cpuid) {
+				prom_print(RELOC("ok\n"));
+#ifdef CONFIG_SMP
+				/* Set the number of active processors. */
+				_systemcfg->processorCount++;
+				cpu_set(cpuid, RELOC(cpu_available_map));
+				cpu_set(cpuid, RELOC(cpu_possible_map));
+				cpu_set(cpuid, RELOC(cpu_present_at_boot));
 #endif
-		if (*acknowledge == cpuid) {
-			prom_print(RELOC("ok\n"));
-			/* Set the number of active processors. */
-			_systemcfg->processorCount++;
-			_xPaca[cpuid].active = 1;
-		} else {
-			prom_print(RELOC("failed: "));
-			prom_print_hex(*acknowledge);
+			} else {
+				prom_print(RELOC("failed: "));
+				prom_print_hex(*acknowledge);
+				prom_print_nl();
+				/* prom_panic(RELOC("cpu failed to start")); */
+			}
+		}
+#ifdef CONFIG_SMP
+		else {
+			prom_print_hex(cpuid);
+			prom_print(RELOC(" : booting  cpu "));
+			prom_print(path);
+			prom_print_nl();
+			cpu_set(cpuid, RELOC(cpu_available_map));
+			cpu_set(cpuid, RELOC(cpu_possible_map));
+			cpu_set(cpuid, RELOC(cpu_online_map));
+			cpu_set(cpuid, RELOC(cpu_present_at_boot));
+		}
+
+		/* Init paca for secondary threads.   They start later. */
+		for (i=1; i < cpu_threads; i++) {
+			cpuid++;
+			_xPaca[cpuid].xHwProcNum = interrupt_server[i];
+			prom_print_hex(interrupt_server[i]);
+			prom_print(RELOC(" : preparing thread ... "));
+			if (_naca->smt_state) {
+				cpu_set(cpuid, RELOC(cpu_available_map));
+				cpu_set(cpuid, RELOC(cpu_present_at_boot));
+				prom_print(RELOC("available"));
+			} else {
+				prom_print(RELOC("not available"));
+			}
 			prom_print_nl();
 		}
+#endif
+		cpuid++;
 	}
 #ifdef CONFIG_HMT
 	/* Only enable HMT on processors that provide support. */
@@ -1023,10 +1083,10 @@ prom_hold_cpus(unsigned long mem)
 		prom_print(RELOC("    starting secondary threads\n"));
 
 		for (i = 0; i < NR_CPUS; i += 2) {
-			if (!_xPaca[i].active)
+			if (!cpu_online(i))
 				continue;
 
-			if (i == boot_cpuid) {
+			if (i == 0) {
 				unsigned long pir = _get_PIR();
 				if (__is_processor(PV_PULSAR)) {
 					RELOC(hmt_thread_data)[i].pir = 
@@ -1036,7 +1096,8 @@ prom_hold_cpus(unsigned long mem)
 						pir & 0x3ff;
 				}
 			}
-			_xPaca[i+1].active = 1;
+/* 			cpu_set(i+1, cpu_online_map); */
+			cpu_set(i+1, RELOC(cpu_possible_map));
 		}
 		_systemcfg->processorCount *= 2;
 	} else {
@@ -1049,6 +1110,105 @@ prom_hold_cpus(unsigned long mem)
 #endif
 }
 
+static void
+smt_setup(void)
+{
+	char *p, *q;
+	char my_smt_enabled = SMT_DYNAMIC;
+	unsigned long my_smt_snooze_delay; 
+	ihandle prom_options = NULL;
+	char option[9];
+	unsigned long offset = reloc_offset();
+        struct naca_struct *_naca = RELOC(naca);
+	char found = 0;
+
+	if (strstr(RELOC(cmd_line), RELOC("smt-enabled="))) {
+		for (q = RELOC(cmd_line); (p = strstr(q, RELOC("smt-enabled="))) != 0; ) {
+			q = p + 12;
+			if (p > RELOC(cmd_line) && p[-1] != ' ')
+				continue;
+			found = 1;
+			if (q[0] == 'o' && q[1] == 'f' && 
+			    q[2] == 'f' && (q[3] == ' ' || q[3] == '\0')) {
+				my_smt_enabled = SMT_OFF;
+			} else if (q[0]=='o' && q[1] == 'n' && 
+				   (q[2] == ' ' || q[2] == '\0')) {
+				my_smt_enabled = SMT_ON;
+			} else {
+				my_smt_enabled = SMT_DYNAMIC;
+			} 
+		}
+	}
+	if (!found) {
+		prom_options = (ihandle)call_prom(RELOC("finddevice"), 1, 1, RELOC("/options"));
+		if (prom_options != (ihandle) -1) {
+			call_prom(RELOC("getprop"), 
+				4, 1, prom_options,
+				RELOC("ibm,smt-enabled"), 
+				option, 
+				sizeof(option));
+			if (option[0] != 0) {
+				found = 1;
+				if (!strcmp(option, "off"))	
+					my_smt_enabled = SMT_OFF;
+				else if (!strcmp(option, "on"))	
+					my_smt_enabled = SMT_ON;
+				else
+					my_smt_enabled = SMT_DYNAMIC;
+			}
+		}
+	}
+
+	if (!found )
+		my_smt_enabled = SMT_DYNAMIC; /* default to on */
+
+	found = 0;
+	if (my_smt_enabled) {
+		if (strstr(RELOC(cmd_line), RELOC("smt-snooze-delay="))) {
+			for (q = RELOC(cmd_line); (p = strstr(q, RELOC("smt-snooze-delay="))) != 0; ) {
+				q = p + 17;
+				if (p > RELOC(cmd_line) && p[-1] != ' ')
+					continue;
+				found = 1;
+				/* Don't use simple_strtoul() because _ctype & others aren't RELOC'd */
+				my_smt_snooze_delay = 0;
+				while (*q >= '0' && *q <= '9') {
+					my_smt_snooze_delay = my_smt_snooze_delay * 10 + *q - '0';
+					q++;
+				}
+			}
+		}
+
+		if (!found) {
+			prom_options = (ihandle)call_prom(RELOC("finddevice"), 1, 1, RELOC("/options"));
+			if (prom_options != (ihandle) -1) {
+				call_prom(RELOC("getprop"), 
+					4, 1, prom_options,
+					RELOC("ibm,smt-snooze-delay"), 
+					option, 
+					sizeof(option));
+				if (option[0] != 0) {
+					found = 1;
+					/* Don't use simple_strtoul() because _ctype & others aren't RELOC'd */
+					my_smt_snooze_delay = 0;
+					q = option;
+					while (*q >= '0' && *q <= '9') {
+						my_smt_snooze_delay = my_smt_snooze_delay * 10 + *q - '0';
+						q++;
+					}
+				}
+			}
+		}
+
+		if (!found) {
+			my_smt_snooze_delay = 30000; /* default value */
+		}
+	} else {
+		my_smt_snooze_delay = 0; /* default value */
+	}
+	_naca->smt_snooze_delay = my_smt_snooze_delay;
+	_naca->smt_state = my_smt_enabled;
+}
 
 /*
  * We enter here early on, when the Open Firmware prom is still
@@ -1065,12 +1225,20 @@ prom_init(unsigned long r3, unsigned lon
 	unsigned long offset = reloc_offset();
 	long l;
 	char *p, *d;
- 	unsigned long phys;
-        u32 getprop_rval;
-        struct systemcfg *_systemcfg = RELOC(systemcfg);
+	unsigned long phys;
+	u32 getprop_rval;
+	struct systemcfg *_systemcfg;
 	struct paca_struct *_xPaca = PTRRELOC(&paca[0]);
 	struct prom_t *_prom = PTRRELOC(&prom);
 
+	/* First zero the BSS -- use memset, some arches don't have
+	 * caches on yet */
+	memset(PTRRELOC(&__bss_start), 0, __bss_stop - __bss_start);
+
+	/* Setup systemcfg and NACA pointers now */
+	RELOC(systemcfg) = _systemcfg = (struct systemcfg *)(SYSTEMCFG_VIRT_ADDR - offset);
+	RELOC(naca) = (struct naca_struct *)(NACA_VIRT_ADDR - offset);
+
 	/* Default machine type. */
 	_systemcfg->platform = PLATFORM_PSERIES;
 
@@ -1092,12 +1260,12 @@ prom_init(unsigned long r3, unsigned lon
 				       RELOC("/chosen"));
 
 	if ((long)_prom->chosen <= 0)
-		prom_exit();
+		prom_panic(RELOC("cannot find chosen")); /* msg won't be printed :( */
 
         if ((long)call_prom(RELOC("getprop"), 4, 1, _prom->chosen,
 			    RELOC("stdout"), &getprop_rval,
 			    sizeof(getprop_rval)) <= 0)
-                prom_exit();
+                prom_panic(RELOC("cannot find stdout"));
 
         _prom->stdout = (ihandle)(unsigned long)getprop_rval;
 
@@ -1123,7 +1291,7 @@ prom_init(unsigned long r3, unsigned lon
         if ((long)call_prom(RELOC("getprop"), 4, 1, _prom->chosen,
 			    RELOC("cpu"), &getprop_rval,
 			    sizeof(getprop_rval)) <= 0)
-                prom_exit();
+                prom_panic(RELOC("cannot find boot cpu"));
 
 	prom_cpu = (ihandle)(unsigned long)getprop_rval;
 	cpu_pkg = call_prom(RELOC("instance-to-package"), 1, 1, prom_cpu);
@@ -1131,11 +1299,9 @@ prom_init(unsigned long r3, unsigned lon
 		cpu_pkg, RELOC("reg"),
 		&getprop_rval, sizeof(getprop_rval));
 	_prom->cpu = (int)(unsigned long)getprop_rval;
-	_xPaca[_prom->cpu].active = 1;
-#ifdef CONFIG_SMP
-	cpu_set(_prom->cpu, RELOC(cpu_online_map));
-#endif
-	RELOC(boot_cpuid) = _prom->cpu;
+	_xPaca[0].xHwProcNum = _prom->cpu;
+
+	RELOC(boot_cpuid) = 0;
 
 #ifdef DEBUG_PROM
   	prom_print(RELOC("Booting CPU hw index = 0x"));
@@ -1169,11 +1335,12 @@ prom_init(unsigned long r3, unsigned lon
         /* Initialize some system info into the Naca early... */
         mem = prom_initialize_naca(mem);
 
+	smt_setup();
+	
         /* If we are on an SMP machine, then we *MUST* do the
          * following, regardless of whether we have an SMP
          * kernel or not.
          */
-        if (_systemcfg->processorCount > 1)
 	        prom_hold_cpus(mem);
 
 #ifdef DEBUG_PROM
@@ -1381,8 +1548,7 @@ copy_device_tree(unsigned long mem_start
 
 	root = call_prom(RELOC("peer"), 1, 1, (phandle)0);
 	if (root == (phandle)0) {
-		prom_print(RELOC("couldn't get device tree root\n"));
-		prom_exit();
+		prom_panic(RELOC("couldn't get device tree root\n"));
 	}
 	allnextp = &RELOC(allnodes);
 	mem_start = DOUBLEWORD_ALIGN(mem_start);
@@ -1444,6 +1610,23 @@ inspect_node(phandle node, struct device
 		*prev_propp = PTRUNRELOC(pp);
 		prev_propp = &pp->next;
 	}
+
+	/* Add a "linux_phandle" value */
+        if (np->node) {
+		u32 ibm_phandle = 0;
+		int len;
+
+                /* First see if "ibm,phandle" exists and use its value */
+                len = (int)
+                        call_prom(RELOC("getprop"), 4, 1, node, RELOC("ibm,phandle"),
+                                  &ibm_phandle, sizeof(ibm_phandle));
+                if (len < 0) {
+                        np->linux_phandle = np->node;
+                } else {
+                        np->linux_phandle = ibm_phandle;
+		}
+	}
+
 	*prev_propp = 0;
 
 	/* get the node's full name */
@@ -1487,7 +1670,7 @@ finish_device_tree(void)
 
 	klimit = mem;
 
-	rtas.dev = find_devices("rtas");
+	rtas.dev = of_find_node_by_name(NULL, "rtas");
 }
 
 static unsigned long __init
@@ -1540,7 +1723,7 @@ finish_node(struct device_node *np, unsi
 /*
  * Find the interrupt parent of a node.
  */
-static struct device_node * __init
+static struct device_node * __devinit
 intr_parent(struct device_node *p)
 {
 	phandle *parp;
@@ -1555,7 +1738,7 @@ intr_parent(struct device_node *p)
  * Find out the size of each entry of the interrupts property
  * for a node.
  */
-static int __init
+static int __devinit
 prom_n_intr_cells(struct device_node *np)
 {
 	struct device_node *p;
@@ -1583,7 +1766,7 @@ prom_n_intr_cells(struct device_node *np
  * Map an interrupt from a device up to the platform interrupt
  * descriptor.
  */
-static int __init
+static int __devinit
 map_interrupt(unsigned int **irq, struct device_node **ictrler,
 	      struct device_node *np, unsigned int *ints, int nintrc)
 {
@@ -1939,11 +2122,14 @@ int
 machine_is_compatible(const char *compat)
 {
 	struct device_node *root;
-	
-	root = find_path_device("/");
-	if (root == 0)
-		return 0;
-	return device_is_compatible(root, compat);
+	int rc = 0;
+  
+	root = of_find_node_by_path("/");
+	if (root) {
+		rc = device_is_compatible(root, compat);
+		of_node_put(root);
+	}
+	return rc;
 }
 
 /*
@@ -1983,16 +2169,560 @@ find_path_device(const char *path)
 	return NULL;
 }
 
+/*******
+ *
+ * New implementation of the OF "find" APIs, return a refcounted
+ * object, call of_node_put() when done.  The device tree and list
+ * are protected by a rw_lock.
+ *
+ * Note that property management will need some locking as well,
+ * this isn't dealt with yet.
+ *
+ *******/
+
+/**
+ *	of_find_node_by_name - Find a node by its "name" property
+ *	@from:	The node to start searching from or NULL, the node
+ *		you pass will not be searched, only the next one
+ *		will; typically, you pass what the previous call
+ *		returned. of_node_put() will be called on it
+ *	@name:	The name string to match against
+ *
+ *	Returns a node pointer with refcount incremented, use
+ *	of_node_put() on it when done.
+ */
+struct device_node *of_find_node_by_name(struct device_node *from,
+	const char *name)
+{
+	struct device_node *np;
+
+	read_lock(&devtree_lock);
+	np = from ? from->allnext : allnodes;
+	for (; np != 0; np = np->allnext)
+		if (np->name != 0 && strcasecmp(np->name, name) == 0
+		    && of_node_get(np))
+			break;
+	if (from)
+		of_node_put(from);
+	read_unlock(&devtree_lock);
+	return np;
+}
+
+/**
+ *	of_find_node_by_type - Find a node by its "device_type" property
+ *	@from:	The node to start searching from or NULL, the node
+ *		you pass will not be searched, only the next one
+ *		will; typically, you pass what the previous call
+ *		returned. of_node_put() will be called on it
+ *	@name:	The type string to match against
+ *
+ *	Returns a node pointer with refcount incremented, use
+ *	of_node_put() on it when done.
+ */
+struct device_node *of_find_node_by_type(struct device_node *from,
+	const char *type)
+{
+	struct device_node *np;
+
+	read_lock(&devtree_lock);
+	np = from ? from->allnext : allnodes;
+	for (; np != 0; np = np->allnext)
+		if (np->type != 0 && strcasecmp(np->type, type) == 0
+		    && of_node_get(np))
+			break;
+	if (from)
+		of_node_put(from);
+	read_unlock(&devtree_lock);
+	return np;
+}
+EXPORT_SYMBOL(of_find_node_by_type);
+
+/**
+ *	of_find_compatible_node - Find a node based on type and one of the
+ *                                tokens in its "compatible" property
+ *	@from:		The node to start searching from or NULL, the node
+ *			you pass will not be searched, only the next one
+ *			will; typically, you pass what the previous call
+ *			returned. of_node_put() will be called on it
+ *	@type:		The type string to match "device_type" or NULL to ignore
+ *	@compatible:	The string to match to one of the tokens in the device
+ *			"compatible" list.
+ *
+ *	Returns a node pointer with refcount incremented, use
+ *	of_node_put() on it when done.
+ */
+struct device_node *of_find_compatible_node(struct device_node *from,
+	const char *type, const char *compatible)
+{
+	struct device_node *np;
+
+	read_lock(&devtree_lock);
+	np = from ? from->allnext : allnodes;
+	for (; np != 0; np = np->allnext) {
+		if (type != NULL
+		    && !(np->type != 0 && strcasecmp(np->type, type) == 0))
+			continue;
+		if (device_is_compatible(np, compatible) && of_node_get(np))
+			break;
+	}
+	if (from)
+		of_node_put(from);
+	read_unlock(&devtree_lock);
+	return np;
+}
+
+/**
+ *	of_find_node_by_path - Find a node matching a full OF path
+ *	@path:	The full path to match
+ *
+ *	Returns a node pointer with refcount incremented, use
+ *	of_node_put() on it when done.
+ */
+struct device_node *of_find_node_by_path(const char *path)
+{
+	struct device_node *np = allnodes;
+
+	read_lock(&devtree_lock);
+	for (; np != 0; np = np->allnext)
+		if (np->full_name != 0 && strcasecmp(np->full_name, path) == 0
+		    && of_node_get(np))
+			break;
+	read_unlock(&devtree_lock);
+	return np;
+}
+
+/**
+ *	of_find_all_nodes - Get next node in global list
+ *	@prev:	Previous node or NULL to start iteration
+ *		of_node_put() will be called on it
+ *
+ *	Returns a node pointer with refcount incremented, use
+ *	of_node_put() on it when done.
+ */
+struct device_node *of_find_all_nodes(struct device_node *prev)
+{
+	struct device_node *np;
+
+	read_lock(&devtree_lock);
+	np = prev ? prev->allnext : allnodes;
+	for (; np != 0; np = np->allnext)
+		if (of_node_get(np))
+			break;
+	if (prev)
+		of_node_put(prev);
+	read_unlock(&devtree_lock);
+	return np;
+}
+
+/**
+ *	of_get_parent - Get a node's parent if any
+ *	@node:	Node to get parent
+ *
+ *	Returns a node pointer with refcount incremented, use
+ *	of_node_put() on it when done.
+ */
+struct device_node *of_get_parent(const struct device_node *node)
+{
+	struct device_node *np;
+
+	if (!node)
+		return NULL;
+
+	read_lock(&devtree_lock);
+	np = of_node_get(node->parent);
+	read_unlock(&devtree_lock);
+	return np;
+}
+
+/**
+ *	of_get_next_child - Iterate a node childs
+ *	@node:	parent node
+ *	@prev:	previous child of the parent node, or NULL to get first
+ *
+ *	Returns a node pointer with refcount incremented, use
+ *	of_node_put() on it when done.
+ */
+struct device_node *of_get_next_child(const struct device_node *node,
+	struct device_node *prev)
+{
+	struct device_node *next;
+
+	read_lock(&devtree_lock);
+	next = prev ? prev->sibling : node->child;
+	for (; next != 0; next = next->sibling)
+		if (of_node_get(next))
+			break;
+	if (prev)
+		of_node_put(prev);
+	read_unlock(&devtree_lock);
+	return next;
+}
+
+/**
+ *	of_node_get - Increment refcount of a node
+ *	@node:	Node to inc refcount, NULL is supported to
+ *		simplify writing of callers
+ *
+ *	Returns the node itself or NULL if gone.
+ */
+struct device_node *of_node_get(struct device_node *node)
+{
+	if (node && !OF_IS_STALE(node)) {
+		atomic_inc(&node->_users);
+		return node;
+	}
+	return NULL;
+}
+
+/**
+ *	of_node_put - Decrement refcount of a node
+ *	@node:	Node to dec refcount, NULL is supported to
+ *		simplify writing of callers
+ *
+ */
+void of_node_put(struct device_node *node)
+{
+	if (!node)
+		return;
+
+	WARN_ON(0 == atomic_read(&node->_users));
+
+	if (OF_IS_STALE(node)) {
+		if (atomic_dec_and_test(&node->_users)) {
+			of_node_cleanup(node);
+			return;
+		}
+	}
+	else
+		atomic_dec(&node->_users);
+}
+
+/**
+ *	of_node_cleanup - release a dynamically allocated node
+ *	@arg:  Node to be released
+ */
+static void of_node_cleanup(struct device_node *node)
+{
+	struct property *prop = node->properties;
+
+	if (!OF_IS_DYNAMIC(node))
+		return;
+	while (prop) {
+		struct property *next = prop->next;
+		kfree(prop->name);
+		kfree(prop->value);
+		kfree(prop);
+		prop = next;
+	}
+	kfree(node->intrs);
+	kfree(node->addrs);
+	kfree(node->full_name);
+	kfree(node);
+}
+
+/**
+ *	derive_parent - basically like dirname(1)
+ *	@path:  the full_name of a node to be added to the tree
+ *
+ *	Returns the node which should be the parent of the node
+ *	described by path.  E.g., for path = "/foo/bar", returns
+ *	the node with full_name = "/foo".
+ */
+static struct device_node *derive_parent(const char *path)
+{
+	struct device_node *parent = NULL;
+	char *parent_path = "/";
+	size_t parent_path_len = strrchr(path, '/') - path + 1;
+
+	/* reject if path is "/" */
+	if (!strcmp(path, "/"))
+		return NULL;
+
+	if (strrchr(path, '/') != path) {
+		parent_path = kmalloc(parent_path_len, GFP_KERNEL);
+		if (!parent_path)
+			return NULL;
+		strlcpy(parent_path, path, parent_path_len);
+	}
+	parent = of_find_node_by_path(parent_path);
+	if (strcmp(parent_path, "/"))
+		kfree(parent_path);
+	return parent;
+}
+
+/*
+ * Routines for "runtime" addition and removal of device tree nodes.
+ */
+
+/*
+ * Given a path and a property list, construct an OF device node, add
+ * it to the device tree and global list, and place it in
+ * /proc/device-tree.  This function may sleep.
+ */
+int of_add_node(const char *path, struct property *proplist)
+{
+	struct device_node *np;
+	int err = 0;
+
+	np = kmalloc(sizeof(struct device_node), GFP_KERNEL);
+	if (!np)
+		return -ENOMEM;
+
+	memset(np, 0, sizeof(*np));
+
+	np->full_name = kmalloc(strlen(path) + 1, GFP_KERNEL);
+	if (!np->full_name) {
+		kfree(np);
+		return -ENOMEM;
+	}
+	strcpy(np->full_name, path);
+
+	np->properties = proplist;
+	OF_MARK_DYNAMIC(np);
+	of_node_get(np);
+	np->parent = derive_parent(path);
+	if (!np->parent) {
+		kfree(np);
+		return -EINVAL; /* could also be ENOMEM, though */
+	}
+
+	if (0 != (err = of_finish_dynamic_node(np))) {
+		kfree(np);
+		return err;
+	}
+
+	write_lock(&devtree_lock);
+	np->sibling = np->parent->child;
+	np->allnext = allnodes;
+	np->parent->child = np;
+	allnodes = np;
+	write_unlock(&devtree_lock);
+
+	add_node_proc_entries(np);
+
+	of_node_put(np->parent);
+	of_node_put(np);
+	return 0;
+}
+
+/*
+ * Remove an OF device node from the system.
+ */
+int of_remove_node(struct device_node *np)
+{
+	struct device_node *parent, *child;
+
+	parent = of_get_parent(np);
+	child = of_get_next_child(np, NULL);
+	if (child && !child->child && !child->sibling) {
+		/* For now, we will allow removal of a
+		 * node with one and only one child, so
+		 * that we can support removing a slot with
+		 * an IOA in it.  More general support for
+		 * subtree removal to be implemented later, if
+		 * necessary.
+		 */
+		of_remove_node(child);
+	}
+	else if (child) {
+		of_node_put(child);
+		of_node_put(parent);
+		return -EINVAL;
+	}
+	of_node_put(child);
+
+	write_lock(&devtree_lock);
+	OF_MARK_STALE(np);
+	remove_node_proc_entries(np);
+	if (allnodes == np)
+		allnodes = np->allnext;
+	else {
+		struct device_node *prev;
+		for (prev = allnodes;
+		     prev->allnext != np;
+		     prev = prev->allnext)
+			;
+		prev->allnext = np->allnext;
+	}
+
+	if (np->parent->child == np)
+		np->parent->child = np->sibling;
+	else {
+		struct device_node *prevsib;
+		for (prevsib = np->parent->child;
+		     prevsib->sibling != np;
+		     prevsib = prevsib->sibling)
+			;
+		prevsib->sibling = np->sibling;
+	}
+	write_unlock(&devtree_lock);
+	of_node_put(parent);
+	return 0;
+}
+
+/*
+ * Add a node to /proc/device-tree.
+ */
+static void add_node_proc_entries(struct device_node *np)
+{
+	struct proc_dir_entry *ent;
+
+	ent = proc_mkdir(strrchr(np->full_name, '/') + 1, np->parent->pde);
+	if (ent)
+		proc_device_tree_add_node(np, ent);
+}
+
+static void remove_node_proc_entries(struct device_node *np)
+{
+	struct property *pp = np->properties;
+	struct device_node *parent = np->parent;
+
+	while (pp) {
+		remove_proc_entry(pp->name, np->pde);
+		pp = pp->next;
+	}
+
+	/* Assuming that symlinks have the same parent directory as
+	 * np->pde.
+	 */
+	if (np->name_link)
+		remove_proc_entry(np->name_link->name, parent->pde);
+	if (np->addr_link)
+		remove_proc_entry(np->addr_link->name, parent->pde);
+	if (np->pde)
+		remove_proc_entry(np->pde->name, parent->pde);
+}
+
+/*
+ * Fix up the uninitialized fields in a new device node:
+ * name, type, n_addrs, addrs, n_intrs, intrs, and pci-specific fields
+ *
+ * A lot of boot-time code is duplicated here, because functions such
+ * as finish_node_interrupts, interpret_pci_props, etc. cannot use the
+ * slab allocator.
+ *
+ * This should probably be split up into smaller chunks.
+ */
+
+static int of_finish_dynamic_node(struct device_node *node)
+{
+	struct device_node *parent = of_get_parent(node);
+	u32 *regs;
+	unsigned int *ints;
+	int intlen, intrcells;
+	int i, j, n, err = 0;
+	unsigned int *irq;
+	struct device_node *ic;
+ 
+	node->name = get_property(node, "name", 0);
+	node->type = get_property(node, "device_type", 0);
+
+	if (!parent) {
+		err = -ENODEV;
+		goto out;
+	}
+
+	/* do the work of interpret_pci_props */
+	if (parent->type && !strcmp(parent->type, "pci")) {
+		struct address_range *adr;
+		struct pci_reg_property *pci_addrs;
+		int i, l;
+
+		pci_addrs = (struct pci_reg_property *)
+			get_property(node, "assigned-addresses", &l);
+		if (pci_addrs != 0 && l >= sizeof(struct pci_reg_property)) {
+			i = 0;
+			adr = kmalloc(sizeof(struct address_range) * 
+				      (l / sizeof(struct pci_reg_property)),
+				      GFP_KERNEL);
+			if (!adr) {
+				err = -ENOMEM;
+				goto out;
+			}
+			while ((l -= sizeof(struct pci_reg_property)) >= 0) {
+				adr[i].space = pci_addrs[i].addr.a_hi;
+				adr[i].address = pci_addrs[i].addr.a_lo;
+				adr[i].size = pci_addrs[i].size_lo;
+				++i;
+			}
+			node->addrs = adr;
+			node->n_addrs = i;
+		}
+	}
+
+	/* now do the work of finish_node_interrupts */
+
+	ints = (unsigned int *) get_property(node, "interrupts", &intlen);
+	if (!ints)
+		goto out;
+
+	intrcells = prom_n_intr_cells(node);
+	intlen /= intrcells * sizeof(unsigned int);
+	node->n_intrs = intlen;
+	node->intrs = kmalloc(sizeof(struct interrupt_info) * intlen,
+			      GFP_KERNEL);
+	if (!node->intrs) {
+		err = -ENOMEM;
+		goto out;
+	}
+
+	for (i = 0; i < intlen; ++i) {
+		node->intrs[i].line = 0;
+		node->intrs[i].sense = 1;
+		n = map_interrupt(&irq, &ic, node, ints, intrcells);
+		if (n <= 0)
+			continue;
+		node->intrs[i].line = openpic_to_irq(virt_irq_create_mapping(irq[0]));
+		if (n > 1)
+			node->intrs[i].sense = irq[1];
+		if (n > 2) {
+			printk(KERN_DEBUG "hmmm, got %d intr cells for %s:", n,
+			       node->full_name);
+			for (j = 0; j < n; ++j)
+				printk(" %d", irq[j]);
+			printk("\n");
+		}
+		ints += intrcells;
+	}
+
+       /* now do the rough equivalent of update_dn_pci_info, this
+        * probably is not correct for phb's, but should work for
+	* IOAs and slots.
+        */
+
+       node->phb = parent->phb;
+
+       regs = (u32 *)get_property(node, "reg", 0);
+       if (regs) {
+               node->busno = (regs[0] >> 16) & 0xff;
+               node->devfn = (regs[0] >> 8) & 0xff;
+       }
+
+	/* fixing up tce_table */
+
+	if(strcmp(node->name, "pci") == 0 &&
+                get_property(node, "ibm,dma-window", NULL)) {
+                node->bussubno = node->busno;
+                create_pci_bus_tce_table((unsigned long)node);
+        }
+	else
+		node->tce_table = parent->tce_table;
+
+out:
+	of_node_put(parent);
+	return err;
+}
+
 /*
  * Find the device_node with a given phandle.
  */
-static struct device_node * __init
+static struct device_node * __devinit
 find_phandle(phandle ph)
 {
 	struct device_node *np;
 
 	for (np = allnodes; np != 0; np = np->allnext)
-		if (np->node == ph)
+		if (np->linux_phandle == ph)
 			return np;
 	return NULL;
 }
@@ -2082,17 +2812,6 @@ print_properties(struct device_node *np)
 #endif
 
 
-void __init
-abort()
-{
-#ifdef CONFIG_XMON
-	xmon(NULL);
-#endif
-	for (;;)
-		prom_exit();
-}
-
-
 /* Verify bi_recs are good */
 static struct bi_record *
 prom_bi_rec_verify(struct bi_record *bi_recs)
diff -puN arch/ppc64/kernel/pSeries_htab.c~linus arch/ppc64/kernel/pSeries_htab.c
--- 25/arch/ppc64/kernel/pSeries_htab.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/pSeries_htab.c	2004-01-19 22:17:21.000000000 -0800
@@ -219,10 +219,10 @@ static long pSeries_hpte_updatepp(unsign
 
 	/* Ensure it is out of the tlb too */
 	if ((cur_cpu_spec->cpu_features & CPU_FTR_TLBIEL) && !large && local) {
-		_tlbiel(va);
+		tlbiel(va);
 	} else {
 		spin_lock_irqsave(&pSeries_tlbie_lock, flags);
-		_tlbie(va, large);
+		tlbie(va, large);
 		spin_unlock_irqrestore(&pSeries_tlbie_lock, flags);
 	}
 
@@ -256,7 +256,7 @@ static void pSeries_hpte_updateboltedpp(
 
 	/* Ensure it is out of the tlb too */
 	spin_lock_irqsave(&pSeries_tlbie_lock, flags);
-	_tlbie(va, 0);
+	tlbie(va, 0);
 	spin_unlock_irqrestore(&pSeries_tlbie_lock, flags);
 }
 
@@ -285,10 +285,10 @@ static void pSeries_hpte_invalidate(unsi
 
 	/* Invalidate the tlb */
 	if ((cur_cpu_spec->cpu_features & CPU_FTR_TLBIEL) && !large && local) {
-		_tlbiel(va);
+		tlbiel(va);
 	} else {
 		spin_lock_irqsave(&pSeries_tlbie_lock, flags);
-		_tlbie(va, large);
+		tlbie(va, large);
 		spin_unlock_irqrestore(&pSeries_tlbie_lock, flags);
 	}
 }
@@ -350,12 +350,8 @@ static void pSeries_flush_hash_range(uns
 	if ((cur_cpu_spec->cpu_features & CPU_FTR_TLBIEL) && !large && local) {
 		asm volatile("ptesync":::"memory");
 
-		for (i = 0; i < j; i++) {
-			asm volatile("\n\
-			clrldi  %0,%0,16\n\
-			tlbiel   %0"
-			: : "r" (batch->vaddr[i]) : "memory" );
-		}
+		for (i = 0; i < j; i++)
+			__tlbiel(batch->vaddr[i]);
 
 		asm volatile("ptesync":::"memory");
 	} else {
@@ -364,12 +360,8 @@ static void pSeries_flush_hash_range(uns
 
 		asm volatile("ptesync":::"memory");
 
-		for (i = 0; i < j; i++) {
-			asm volatile("\n\
-			clrldi  %0,%0,16\n\
-			tlbie   %0"
-			: : "r" (batch->vaddr[i]) : "memory" );
-		}
+		for (i = 0; i < j; i++)
+			__tlbie(batch->vaddr[i], 0);
 
 		asm volatile("eieio; tlbsync; ptesync":::"memory");
 
@@ -389,10 +381,11 @@ void hpte_init_pSeries(void)
 	ppc_md.hpte_remove     	= pSeries_hpte_remove;
 
 	/* Disable TLB batching on nighthawk */
-	root = find_path_device("/");
+	root = of_find_node_by_path("/");
 	if (root) {
 		model = get_property(root, "model", NULL);
 		if (strcmp(model, "CHRP IBM,9076-N81"))
 			ppc_md.flush_hash_range = pSeries_flush_hash_range;
+		of_node_put(root);
 	}
 }
diff -puN arch/ppc64/kernel/pSeries_hvCall.S~linus arch/ppc64/kernel/pSeries_hvCall.S
--- 25/arch/ppc64/kernel/pSeries_hvCall.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/pSeries_hvCall.S	2004-01-19 22:17:21.000000000 -0800
@@ -67,3 +67,77 @@ _GLOBAL(plpar_hcall_norets)
 	ld	r0,-8(r1)
 	mtcrf	0xff,r0
 	blr                     /* return r3 = status */
+
+
+/* long plpar_hcall_8arg_2ret(unsigned long opcode,		 R3 
+			     unsigned long arg1,		 R4 
+		 	     unsigned long arg2,		 R5 
+			     unsigned long arg3,		 R6 
+	 		     unsigned long arg4,		 R7 
+	 		     unsigned long arg5,		 R8 
+			     unsigned long arg6,		 R9 
+	 		     unsigned long arg7,		 R10 
+	 		     unsigned long arg8,		 112(R1)
+	 		     unsigned long *out1);		 120(R1)
+
+ */
+
+	.text
+_GLOBAL(plpar_hcall_8arg_2ret)
+	mfcr	r0
+
+	ld              r11, 112(r1) /* put arg8 and out1 in R11 and R12 */
+	ld              r12, 120(r1)
+
+	std	r0,-8(r1)
+	stdu	r1,-32(r1)
+
+        std     r12,-8(r1)      /* Save out ptr */
+	
+	HSC                    /* invoke the hypervisor */
+
+        ld      r10,-8(r1)      /* Fetch r4 ret arg */
+        std     r4,0(r10)
+
+	ld	r1,0(r1)
+	ld	r0,-8(r1)
+	mtcrf	0xff,r0
+	blr                     /* return r3 = status */
+
+
+/* long plpar_hcall_4out(unsigned long opcode,	 R3 
+		 unsigned long arg1,		 R4 
+		 unsigned long arg2,		 R5 
+		 unsigned long arg3,		 R6 
+		 unsigned long arg4,		 R7 
+		 unsigned long *out1,	(r4)	 R8 
+		 unsigned long *out2,	(r5)	 R9
+		 unsigned long *out3,   (r6)     R10
+		 unsigned long *out4);	(r7)	 112(R1). From Parameter save area. 
+ */
+_GLOBAL(plpar_hcall_4out)
+	mfcr	r0
+	std	r0,-8(r1)
+	ld      r14,112(r1)
+	stdu	r1,-48(r1) 
+
+	std     r8,32(r1)       /* Save out ptrs. */
+	std     r9,24(r1)
+	std     r10,16(r1)
+	std     r14,8(r1)
+	
+	HSC                    /* invoke the hypervisor */
+
+	ld      r14,32(r1)      /* Fetch r4-r7 ret args. */
+	std     r4,0(r14)
+	ld      r14,24(r1)
+	std     r5,0(r14)
+	ld      r14,16(r1)
+	std     r6,0(r14)
+	ld      r14,8(r1)
+	std     r7,0(r14)
+
+	ld	r1,0(r1) 
+	ld	r0,-8(r1)
+	mtcrf	0xff,r0
+	blr                     /* return r3 = status */
diff -puN arch/ppc64/kernel/pSeries_lpar.c~linus arch/ppc64/kernel/pSeries_lpar.c
--- 25/arch/ppc64/kernel/pSeries_lpar.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/pSeries_lpar.c	2004-01-19 22:17:21.000000000 -0800
@@ -35,6 +35,32 @@
 #include <asm/tlbflush.h>
 #include <asm/tlb.h>
 #include <asm/hvcall.h>
+#include <asm/prom.h>
+
+long poll_pending(void)
+{
+	unsigned long dummy;
+	return plpar_hcall(H_POLL_PENDING, 0, 0, 0, 0,
+			   &dummy, &dummy, &dummy);
+}
+
+long prod_processor(void)
+{
+	plpar_hcall_norets(H_PROD);
+	return(0); 
+}
+
+long cede_processor(void)
+{
+	plpar_hcall_norets(H_CEDE);
+	return(0); 
+}
+
+long register_vpa(unsigned long flags, unsigned long proc, unsigned long vpa)
+{
+	plpar_hcall_norets(H_REGISTER_VPA, flags, proc, vpa);
+	return(0); 
+}
 
 long plpar_pte_remove(unsigned long flags,
 		      unsigned long ptex,
@@ -206,6 +232,61 @@ static unsigned char udbg_getcLP(void)
 	}
 }
 
+/* returns 0 if couldn't find or use /chosen/stdout as console */
+static int find_udbg_vterm(void)
+{
+	struct device_node *stdout_node;
+	u32 *termno;
+	char *name;
+	int found = 0;
+
+	/* find the boot console from /chosen/stdout */
+	if (!of_stdout_device) {
+		printk(KERN_WARNING "couldn't get path from /chosen/stdout!\n");
+		return found;
+	}
+	stdout_node = of_find_node_by_path(of_stdout_device);
+	if (!stdout_node) {
+		printk(KERN_WARNING "couldn't find node from /chosen/stdout\n");
+		return found;
+	}
+
+	/* now we have the stdout node; figure out what type of device it is. */
+	name = (char *)get_property(stdout_node, "name", 0);
+	if (!name) {
+		printk(KERN_WARNING "stdout node missing 'name' property!\n");
+		goto out;
+	}
+
+	if (strncmp(name, "vty", 3) == 0) {
+		if (device_is_compatible(stdout_node, "hvterm1")) {
+			termno = (u32 *)get_property(stdout_node, "reg", 0);
+			if (termno) {
+				vtermno = termno[0];
+				ppc_md.udbg_putc = udbg_putcLP;
+				ppc_md.udbg_getc = udbg_getcLP;
+				ppc_md.udbg_getc_poll = udbg_getc_pollLP;
+				found = 1;
+			}
+		} else {
+			/* XXX implement udbg_putcLP_vtty for hvterm-protocol1 case */
+			printk(KERN_WARNING "%s doesn't speak hvterm1; "
+					"can't print udbg messages\n", of_stdout_device);
+		}
+	} else if (strncmp(name, "serial", 6)) {
+		/* XXX fix ISA serial console */
+		printk(KERN_WARNING "serial stdout on LPAR ('%s')! "
+				"can't print udbg messages\n", of_stdout_device);
+	} else {
+		printk(KERN_WARNING "don't know how to print to stdout '%s'\n",
+				of_stdout_device);
+	}
+
+out:
+	of_node_put(stdout_node);
+	return found;
+}
+
 void pSeries_lpar_mm_init(void);
 
 /* This is called early in setup.c.
@@ -213,8 +294,6 @@ void pSeries_lpar_mm_init(void);
  */
 void pSeriesLP_init_early(void)
 {
-	struct device_node *np;
-
 	pSeries_lpar_mm_init();
 
 	ppc_md.tce_build	 = tce_build_pSeriesLP;
@@ -225,24 +304,13 @@ void pSeriesLP_init_early(void)
 #endif
 
 	/* The keyboard is not useful in the LPAR environment.
-	 * Leave all the interfaces NULL.
+	 * Leave all the ppc_md keyboard interfaces NULL.
 	 */
 
-	/* lookup the first virtual terminal number in case we don't have a
-	 * com port. Zero is probably correct in case someone calls udbg
-	 * before the init. The property is a pair of numbers.  The first
-	 * is the starting termno (the one we use) and the second is the
-	 * number of terminals.
-	 */
-	np = find_path_device("/rtas");
-	if (np) {
-		u32 *termno = (u32 *)get_property(np, "ibm,termno", 0);
-		if (termno)
-			vtermno = termno[0];
-	}
-	ppc_md.udbg_putc = udbg_putcLP;
-	ppc_md.udbg_getc = udbg_getcLP;
-	ppc_md.udbg_getc_poll = udbg_getc_pollLP;
+	if (0 == find_udbg_vterm()) {
+		printk(KERN_WARNING
+			"can't use stdout; can't print early debug messages.\n");
+	}
 }
 
 int hvc_get_chars(int index, char *buf, int count)
@@ -285,23 +353,28 @@ int hvc_put_chars(int index, const char 
 	return -1;
 }
 
+/* return the number of client vterms present */
+/* XXX this requires an interface change to handle multiple discontiguous
+ * vterms */
 int hvc_count(int *start_termno)
 {
-	u32 *termno;
-	struct device_node *dn;
+	struct device_node *vty;
+	int num_found = 0;
 
-	if ((dn = find_path_device("/rtas")) != NULL) {
-		if ((termno = (u32 *)get_property(dn, "ibm,termno", 0)) != NULL) {
-			if (start_termno)
-				*start_termno = termno[0];
-			return termno[1];
-		}
+	/* consider only the first vty node.
+	 * we should _always_ be able to find one. */
+	vty = of_find_node_by_name(NULL, "vty");
+	if (vty && device_is_compatible(vty, "hvterm1")) {
+		u32 *termno = (u32 *)get_property(vty, "reg", 0);
+
+		if (termno && start_termno)
+			*start_termno = *termno;
+		num_found = 1;
+		of_node_put(vty);
 	}
-	return 0;
-}
-
-
 
+	return num_found;
+}
 
 long pSeries_lpar_hpte_insert(unsigned long hpte_group,
 			      unsigned long va, unsigned long prpn,
diff -puN arch/ppc64/kernel/pSeries_pci.c~linus arch/ppc64/kernel/pSeries_pci.c
--- 25/arch/ppc64/kernel/pSeries_pci.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/pSeries_pci.c	2004-01-19 22:17:21.000000000 -0800
@@ -176,6 +176,55 @@ int pci_read_irq_line(struct pci_dev *pc
 	       pci_name(pci_dev), pci_dev->irq);
 	return 0;
 }
+EXPORT_SYMBOL(pci_read_irq_line);
+
+#define ISA_SPACE_MASK 0x1
+#define ISA_SPACE_IO 0x1
+
+static void pci_process_ISA_OF_ranges(struct device_node *isa_node,
+		                      unsigned long phb_io_base_phys,
+				      void * phb_io_base_virt)
+{
+	struct isa_range *range;
+	unsigned long pci_addr;
+	unsigned int isa_addr;
+	unsigned int size;
+	int rlen = 0;
+
+	range = (struct isa_range *) get_property(isa_node, "ranges", &rlen);
+	if (rlen < sizeof(struct isa_range)) {
+		printk(KERN_ERR "unexpected isa range size: %s\n", 
+				__FUNCTION__);
+		return;	
+	}
+	
+	/* From "ISA Binding to 1275"
+	 * The ranges property is laid out as an array of elements,
+	 * each of which comprises:
+	 *   cells 0 - 1:	an ISA address
+	 *   cells 2 - 4:	a PCI address 
+	 *			(size depending on dev->n_addr_cells)
+	 *   cell 5:		the size of the range
+	 */
+	if ((range->isa_addr.a_hi && ISA_SPACE_MASK) == ISA_SPACE_IO) {
+		isa_addr = range->isa_addr.a_lo;
+		pci_addr = (unsigned long) range->pci_addr.a_mid << 32 | 
+			range->pci_addr.a_lo;
+
+		/* Assume these are both zero */
+		if ((pci_addr != 0) || (isa_addr != 0)) {
+			printk(KERN_ERR "unexpected isa to pci mapping: %s\n",
+					__FUNCTION__);
+			return;
+		}
+		
+		size = PAGE_ALIGN(range->size);
+
+		__ioremap_explicit(phb_io_base_phys, 
+				   (unsigned long) phb_io_base_virt, 
+				   size, _PAGE_NO_CACHE);
+	}
+}
 
 static void __init pci_process_bridge_OF_ranges(struct pci_controller *hose,
 						struct device_node *dev,
@@ -188,10 +237,11 @@ static void __init pci_process_bridge_OF
 	struct resource *res;
 	int np, na = prom_n_addr_cells(dev);
 	unsigned long pci_addr, cpu_phys_addr;
+	struct device_node *isa_dn;
 
 	np = na + 5;
 
-	/*
+	/* From "PCI Binding to 1275"
 	 * The ranges property is laid out as an array of elements,
 	 * each of which comprises:
 	 *   cells 0 - 2:	a PCI address
@@ -215,12 +265,22 @@ static void __init pci_process_bridge_OF
 		switch (ranges[0] >> 24) {
 		case 1:		/* I/O space */
 			hose->io_base_phys = cpu_phys_addr;
-			hose->io_base_virt = __ioremap(hose->io_base_phys,
-						       size, _PAGE_NO_CACHE);
+			hose->io_base_virt = reserve_phb_iospace(size);
+			PPCDBG(PPCDBG_PHBINIT, 
+			       "phb%d io_base_phys 0x%lx io_base_virt 0x%lx\n", 
+			       hose->global_number, hose->io_base_phys, 
+			       (unsigned long) hose->io_base_virt);
+
 			if (primary) {
 				pci_io_base = (unsigned long)hose->io_base_virt;
-				if (find_type_devices("isa"))
+				isa_dn = of_find_node_by_type(NULL, "isa");
+				if (isa_dn) {
 					isa_io_base = pci_io_base;
+					of_node_put(isa_dn);
+					pci_process_ISA_OF_ranges(isa_dn,
+						hose->io_base_phys,
+						hose->io_base_virt);
+				}
 			}
 
 			res = &hose->io_resource;
@@ -386,7 +446,7 @@ unsigned long __init find_and_init_phbs(
 	unsigned int root_size_cells = 0;
 	unsigned int index;
 	unsigned int *opprop;
-	struct device_node *root = find_path_device("/");
+	struct device_node *root = of_find_node_by_path("/");
 
 	read_pci_config = rtas_token("read-pci-config");
 	write_pci_config = rtas_token("write-pci-config");
@@ -402,7 +462,9 @@ unsigned long __init find_and_init_phbs(
 
 	index = 0;
 
-	for (node = root->child; node != NULL; node = node->sibling) {
+	for (node = of_get_next_child(root, NULL);
+	     node != NULL;
+	     node = of_get_next_child(root, node)) {
 		if (node->type == NULL || strcmp(node->type, "pci") != 0)
 			continue;
 
@@ -420,6 +482,7 @@ unsigned long __init find_and_init_phbs(
 		index++;
 	}
 
+	of_node_put(root);
 	pci_devs_phb_init();
 
 	return 0;
@@ -450,7 +513,7 @@ void pcibios_name_device(struct pci_dev 
 #endif
 }   
 
-void __init pcibios_fixup_device_resources(struct pci_dev *dev,
+void __devinit pcibios_fixup_device_resources(struct pci_dev *dev,
 					   struct pci_bus *bus)
 {
 	/* Update device resources.  */
@@ -469,8 +532,9 @@ void __init pcibios_fixup_device_resourc
 		}
         }
 }
+EXPORT_SYMBOL(pcibios_fixup_device_resources);
 
-void __init pcibios_fixup_bus(struct pci_bus *bus)
+void __devinit pcibios_fixup_bus(struct pci_bus *bus)
 {
 	struct pci_controller *hose = PCI_GET_PHB_PTR(bus);
 	struct list_head *ln;
@@ -519,18 +583,106 @@ void __init pcibios_fixup_bus(struct pci
 			pcibios_fixup_device_resources(dev, bus);
 	}
 }
+EXPORT_SYMBOL(pcibios_fixup_bus);
 
 static void check_s7a(void)
 {
 	struct device_node *root;
 	char *model;
 
-	root = find_path_device("/");
+	root = of_find_node_by_path("/");
 	if (root) {
 		model = get_property(root, "model", NULL);
 		if (model && !strcmp(model, "IBM,7013-S7A"))
 			s7a_workaround = 1;
+		of_node_put(root);
+	}
+}
+
+static int get_bus_io_range(struct pci_bus *bus, unsigned long *start_phys,
+				unsigned long *start_virt, unsigned long *size)
+{
+	struct pci_controller *hose = PCI_GET_PHB_PTR(bus);
+	struct pci_bus_region region;
+	struct resource *res;
+
+	if (bus->self) {
+		res = bus->resource[0];
+		pcibios_resource_to_bus(bus->self, &region, res);
+		*start_phys = hose->io_base_phys + region.start;
+		*start_virt = (unsigned long) hose->io_base_virt + 
+				region.start;
+		if (region.end > region.start) 
+			*size = region.end - region.start + 1;
+		else {
+			printk("%s(): unexpected region 0x%lx->0x%lx\n", 
+					__FUNCTION__, region.start, region.end);
+			return 1;
+		}
+		
+	} else {
+		/* Root Bus */
+		res = &hose->io_resource;
+		*start_phys = hose->io_base_phys;
+		*start_virt = (unsigned long) hose->io_base_virt;
+		if (res->end > res->start)
+			*size = res->end - res->start + 1;
+		else {
+			printk("%s(): unexpected region 0x%lx->0x%lx\n", 
+					__FUNCTION__, res->start, res->end);
+			return 1;
+		}
 	}
+
+	return 0;
+}
+
+int unmap_bus_range(struct pci_bus *bus)
+{
+	unsigned long start_phys;
+	unsigned long start_virt;
+	unsigned long size;
+
+	if (!bus) {
+		printk(KERN_ERR "%s() expected bus\n", __FUNCTION__);
+		return 1;
+	}
+	
+	if (get_bus_io_range(bus, &start_phys, &start_virt, &size))
+		return 1;
+	if (iounmap_explicit((void *) start_virt, size))
+		return 1;
+
+	return 0;
+}
+EXPORT_SYMBOL(unmap_bus_range);
+
+int remap_bus_range(struct pci_bus *bus)
+{
+	unsigned long start_phys;
+	unsigned long start_virt;
+	unsigned long size;
+
+	if (!bus) {
+		printk(KERN_ERR "%s() expected bus\n", __FUNCTION__);
+		return 1;
+	}
+	
+	if (get_bus_io_range(bus, &start_phys, &start_virt, &size))
+		return 1;
+	if (__ioremap_explicit(start_phys, start_virt, size, _PAGE_NO_CACHE))
+		return 1;
+
+	return 0;
+}
+EXPORT_SYMBOL(remap_bus_range);
+
+static void phbs_fixup_io(void)
+{
+	struct pci_controller *hose;
+
+	for (hose=hose_head;hose;hose=hose->next) 
+		remap_bus_range(hose->bus);
 }
 
 extern void chrp_request_regions(void);
@@ -544,6 +696,7 @@ void __init pcibios_final_fixup(void)
 	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL)
 		pci_read_irq_line(dev);
 
+	phbs_fixup_io();
 	chrp_request_regions();
 	pci_fix_bus_sysdata();
 	create_tce_tables();
diff -puN arch/ppc64/kernel/ras.c~linus arch/ppc64/kernel/ras.c
--- 25/arch/ppc64/kernel/ras.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/ras.c	2004-01-19 22:17:21.000000000 -0800
@@ -70,27 +70,29 @@ static int __init init_ras_IRQ(void)
 	struct device_node *np;
 	unsigned int *ireg, len, i;
 
-	if((np = find_path_device("/event-sources/internal-errors")) &&
-	   (ireg = (unsigned int *)get_property(np, "open-pic-interrupt", 
-						&len))) {
-		for(i=0; i<(len / sizeof(*ireg)); i++) {
+	if ((np = of_find_node_by_path("/event-sources/internal-errors")) &&
+	    (ireg = (unsigned int *)get_property(np, "open-pic-interrupt",
+						 &len))) {
+		for (i=0; i<(len / sizeof(*ireg)); i++) {
 			request_irq(virt_irq_create_mapping(*(ireg)) + NUM_8259_INTERRUPTS, 
 				    ras_error_interrupt, 0, 
 				    "RAS_ERROR", NULL);
 			ireg++;
 		}
 	}
+	of_node_put(np);
 
-	if((np = find_path_device("/event-sources/epow-events")) &&
-	   (ireg = (unsigned int *)get_property(np, "open-pic-interrupt", 
-						&len))) {
-		for(i=0; i<(len / sizeof(*ireg)); i++) {
+	if ((np = of_find_node_by_path("/event-sources/epow-events")) &&
+	    (ireg = (unsigned int *)get_property(np, "open-pic-interrupt",
+						 &len))) {
+		for (i=0; i<(len / sizeof(*ireg)); i++) {
 			request_irq(virt_irq_create_mapping(*(ireg)) + NUM_8259_INTERRUPTS, 
 				    ras_epow_interrupt, 0, 
 				    "RAS_EPOW", NULL);
 			ireg++;
 		}
 	}
+	of_node_put(np);
 
 	return 1;
 }
@@ -112,7 +114,7 @@ ras_epow_interrupt(int irq, void *dev_id
 
 	status = rtas_call(rtas_token("check-exception"), 6, 1, NULL, 
 			   0x500, irq, 
-			   EPOW_WARNING | POWERMGM_EVENTS, 
+			   RTAS_EPOW_WARNING | RTAS_POWERMGM_EVENTS, 
 			   1,  /* Time Critical */
 			   __pa(&log_entry), size);
 
@@ -120,6 +122,10 @@ ras_epow_interrupt(int irq, void *dev_id
 		    *((unsigned long *)&log_entry), status); 
 	printk(KERN_WARNING 
 		"EPOW <0x%lx 0x%lx>\n",*((unsigned long *)&log_entry), status);
+
+	/* format and print the extended information */
+	log_error((char *)&log_entry, ERR_TYPE_RTAS_LOG, 0);
+	
 	return IRQ_HANDLED;
 }
 
@@ -137,15 +143,23 @@ ras_error_interrupt(int irq, void *dev_i
 	struct rtas_error_log log_entry;
 	unsigned int size = sizeof(log_entry);
 	long status = 0xdeadbeef;
+	int fatal;
 
 	status = rtas_call(rtas_token("check-exception"), 6, 1, NULL, 
 			   0x500, irq, 
-			   INTERNAL_ERROR, 
+			   RTAS_INTERNAL_ERROR, 
 			   1, /* Time Critical */
 			   __pa(&log_entry), size);
 
-	if((status != 1) && 
-	   (log_entry.severity >= SEVERITY_ERROR_SYNC)) {
+	if ((status == 0) && (log_entry.severity >= SEVERITY_ERROR_SYNC)) 
+		fatal = 1;
+	else
+		fatal = 0;
+
+	/* format and print the extended information */
+	log_error((char *)&log_entry, ERR_TYPE_RTAS_LOG, fatal); 
+
+	if (fatal) {
 		udbg_printf("HW Error <0x%lx 0x%lx>\n",
 			    *((unsigned long *)&log_entry), status);
 		printk(KERN_EMERG 
@@ -155,6 +169,7 @@ ras_error_interrupt(int irq, void *dev_i
 #ifndef DEBUG
 		/* Don't actually power off when debugging so we can test
 		 * without actually failing while injecting errors.
+		 * Error data will not be logged to syslog.
 		 */
 		ppc_md.power_off();
 #endif
diff -puN arch/ppc64/kernel/rtas.c~linus arch/ppc64/kernel/rtas.c
--- 25/arch/ppc64/kernel/rtas.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/rtas.c	2004-01-19 22:17:21.000000000 -0800
@@ -16,6 +16,7 @@
 #include <linux/types.h>
 #include <linux/spinlock.h>
 #include <linux/module.h>
+#include <linux/init.h>
 
 #include <asm/prom.h>
 #include <asm/proc_fs.h>
@@ -28,6 +29,8 @@
 #include <asm/system.h>
 #include <asm/abs_addr.h>
 #include <asm/udbg.h>
+#include <asm/delay.h>
+#include <asm/uaccess.h>
 
 struct flash_block_list_header rtas_firmware_flash_list = {0, 0};
 
@@ -59,7 +62,7 @@ struct rtas_t rtas = { 
 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, ...)
@@ -180,23 +183,98 @@ rtas_call(int token, int nargs, int nret
 }
 
 /* Given an RTAS status code of 990n compute the hinted delay of 10^n
- * (last digit) milliseconds.  For now we bound at n=3 (1 sec).
+ * (last digit) milliseconds.  For now we bound at n=5 (100 sec).
  */
 unsigned int
 rtas_extended_busy_delay_time(int status)
 {
 	int order = status - 9900;
-	unsigned int ms;
+	unsigned long ms;
 
 	if (order < 0)
 		order = 0;	/* RTC depends on this for -2 clock busy */
-	else if (order > 3)
-		order = 3;	/* bound */
+	else if (order > 5)
+		order = 5;	/* bound */
 
 	/* Use microseconds for reasonable accuracy */
-	for (ms = 1000; order > 0; order--)
-		ms = ms * 10;
-	return ms / (1000000/HZ); /* round down is fine */
+	for (ms=1; order > 0; order--)
+		ms *= 10;          
+
+	return ms; 
+}
+
+int
+rtas_get_power_level(int powerdomain, int *level)
+{
+	int token = rtas_token("get-power-level");
+	long powerlevel;
+	int rc;
+
+	if (token == RTAS_UNKNOWN_SERVICE)
+		return RTAS_UNKNOWN_OP;
+
+	while(1) {
+		rc = (int) rtas_call(token, 1, 2, &powerlevel, powerdomain);
+		if (rc == RTAS_BUSY)
+			udelay(1);
+		else
+			break;
+	}
+	*level = (int) powerlevel;
+	return rc;
+}
+
+int
+rtas_get_sensor(int sensor, int index, int *state)
+{
+	int token = rtas_token("get-sensor-state");
+	unsigned int wait_time;
+	long returned_state;
+	int rc;
+
+	if (token == RTAS_UNKNOWN_SERVICE)
+		return RTAS_UNKNOWN_OP;
+
+	while (1) {
+		rc = (int) rtas_call(token, 2, 2, &returned_state, sensor,
+					index);
+		if (rc == RTAS_BUSY)
+			udelay(1);
+		else if (rtas_is_extended_busy(rc)) {
+			wait_time = rtas_extended_busy_delay_time(rc);
+			udelay(wait_time * 1000);
+		}
+		else
+			break;
+	}
+	*state = (int) returned_state;
+	return rc;
+}
+
+int
+rtas_set_indicator(int indicator, int index, int new_value)
+{
+	int token = rtas_token("set-indicator");
+	unsigned int wait_time;
+	int rc;
+
+	if (token == RTAS_UNKNOWN_SERVICE)
+		return RTAS_UNKNOWN_OP;
+
+	while (1) {
+		rc = (int) rtas_call(token, 3, 1, NULL, indicator, index,
+					new_value);
+		if (rc == RTAS_BUSY)
+			udelay(1);
+		else if (rtas_is_extended_busy(rc)) {
+			wait_time = rtas_extended_busy_delay_time(rc);
+			udelay(wait_time * 1000);
+		}
+		else
+			break;
+	}
+
+	return rc;
 }
 
 #define FLASH_BLOCK_LIST_VERSION (1UL)
@@ -308,9 +386,51 @@ rtas_halt(void)
         rtas_power_off();
 }
 
-EXPORT_SYMBOL(proc_ppc64);
+unsigned long rtas_rmo_buf = 0;
+
+asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
+{
+	struct rtas_args args;
+	unsigned long flags;
+
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
+
+	if (copy_from_user(&args, uargs, 3 * sizeof(u32)) != 0)
+		return -EFAULT;
+
+	if (args.nargs > ARRAY_SIZE(args.args)
+	    || args.nret > ARRAY_SIZE(args.args)
+	    || args.nargs + args.nret > ARRAY_SIZE(args.args))
+		return -EINVAL;
+
+	/* Copy in args. */
+	if (copy_from_user(args.args, uargs->args,
+			   args.nargs * sizeof(rtas_arg_t)) != 0)
+		return -EFAULT;
+
+	spin_lock_irqsave(&rtas.lock, flags);
+	get_paca()->xRtas = args;
+	enter_rtas((void *)__pa((unsigned long)&get_paca()->xRtas));
+	args = get_paca()->xRtas;
+	spin_unlock_irqrestore(&rtas.lock, flags);
+
+	/* Copy out args. */
+	if (copy_to_user(uargs->args + args.nargs,
+			 args.args + args.nargs,
+			 args.nret * sizeof(rtas_arg_t)) != 0)
+		return -EFAULT;
+
+	return 0;
+}
+
+
 EXPORT_SYMBOL(rtas_firmware_flash_list);
 EXPORT_SYMBOL(rtas_token);
 EXPORT_SYMBOL(rtas_call);
 EXPORT_SYMBOL(rtas_data_buf);
 EXPORT_SYMBOL(rtas_data_buf_lock);
+EXPORT_SYMBOL(rtas_extended_busy_delay_time);
+EXPORT_SYMBOL(rtas_get_sensor);
+EXPORT_SYMBOL(rtas_get_power_level);
+EXPORT_SYMBOL(rtas_set_indicator);
diff -puN arch/ppc64/kernel/rtasd.c~linus arch/ppc64/kernel/rtasd.c
--- 25/arch/ppc64/kernel/rtasd.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/rtasd.c	2004-01-19 22:17:21.000000000 -0800
@@ -17,11 +17,15 @@
 #include <linux/proc_fs.h>
 #include <linux/init.h>
 #include <linux/vmalloc.h>
+#include <linux/spinlock.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/rtas.h>
 #include <asm/prom.h>
+#include <asm/nvram.h>
+#include <asm/atomic.h>
+#include <asm/proc_fs.h>
 
 #if 0
 #define DEBUG(A...)	printk(KERN_ERR A)
@@ -29,36 +33,184 @@
 #define DEBUG(A...)
 #endif
 
-static spinlock_t rtas_log_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t log_lock = SPIN_LOCK_UNLOCKED;
 
 DECLARE_WAIT_QUEUE_HEAD(rtas_log_wait);
 
-#define LOG_NUMBER		64		/* must be a power of two */
-#define LOG_NUMBER_MASK		(LOG_NUMBER-1)
-
 static char *rtas_log_buf;
 static unsigned long rtas_log_start;
 static unsigned long rtas_log_size;
 
-static int surveillance_requested;
+static int surveillance_timeout = -1;
 static unsigned int rtas_event_scan_rate;
 static unsigned int rtas_error_log_max;
+static unsigned int rtas_error_log_buffer_max;
 
-#define EVENT_SCAN_ALL_EVENTS	0xf0000000
-#define SURVEILLANCE_TOKEN	9000
-#define SURVEILLANCE_TIMEOUT	1
-#define SURVEILLANCE_SCANRATE	1
+extern spinlock_t proc_ppc64_lock;
+extern volatile int no_more_logging;
 
-struct proc_dir_entry *proc_rtas;
+volatile int error_log_cnt = 0;
 
 /*
  * 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
  * make it big enough.
  */
-#define RTAS_ERROR_LOG_MAX 1024
 static unsigned char logdata[RTAS_ERROR_LOG_MAX];
 
+/* To see this info, grep RTAS /var/log/messages and each entry
+ * will be collected together with obvious begin/end.
+ * There will be a unique identifier on the begin and end lines.
+ * This will persist across reboots.
+ *
+ * format of error logs returned from RTAS:
+ * bytes	(size)	: contents
+ * --------------------------------------------------------
+ * 0-7		(8)	: rtas_error_log
+ * 8-47		(40)	: extended info
+ * 48-51	(4)	: vendor id
+ * 52-1023 (vendor specific) : location code and debug data
+ */
+static void printk_log_rtas(char *buf, int len)
+{
+
+	int i,j,n;
+	int perline = 16;
+	char buffer[64];
+	char * str = "RTAS event";
+
+	printk(RTAS_ERR "%d -------- %s begin --------\n", error_log_cnt, str);
+
+	/*
+	 * Print perline bytes on each line, each line will start
+	 * with RTAS and a changing number, so syslogd will
+	 * print lines that are otherwise the same.  Separate every
+	 * 4 bytes with a space.
+	 */
+	for (i=0; i < len; i++) {
+		j = i % perline;
+		if (j == 0) {
+			memset(buffer, 0, sizeof(buffer));
+			n = sprintf(buffer, "RTAS %d:", i/perline);
+		}
+
+		if ((i % 4) == 0)
+			n += sprintf(buffer+n, " ");
+
+		n += sprintf(buffer+n, "%02x", (unsigned char)buf[i]);
+
+		if (j == (perline-1))
+			printk(KERN_ERR "%s\n", buffer);
+	}
+	if ((i % perline) != 0)
+		printk(KERN_ERR "%s\n", buffer);
+
+	printk(RTAS_ERR "%d -------- %s end ----------\n", error_log_cnt, str);
+}
+
+static int log_rtas_len(char * buf)
+{
+	int len;
+	struct rtas_error_log *err;
+
+	/* rtas fixed header */
+	len = 8;
+	err = (struct rtas_error_log *)buf;
+	if (err->extended_log_length) {
+
+		/* extended header */
+		len += err->extended_log_length;
+
+		if (len > RTAS_ERROR_LOG_MAX)
+			len = RTAS_ERROR_LOG_MAX;
+	}
+	return len;
+}
+
+/*
+ * First write to nvram, if fatal error, that is the only
+ * place we log the info.  The error will be picked up
+ * on the next reboot by rtasd.  If not fatal, run the
+ * method for the type of error.  Currently, only RTAS
+ * errors have methods implemented, but in the future
+ * there might be a need to store data in nvram before a
+ * call to panic().
+ *
+ * XXX We write to nvram periodically, to indicate error has
+ * been written and sync'd, but there is a possibility
+ * that if we don't shutdown correctly, a duplicate error
+ * record will be created on next reboot.
+ */
+void pSeries_log_error(char *buf, unsigned int err_type, int fatal)
+{
+	unsigned long offset;
+	unsigned long s;
+	int len = 0;
+
+	DEBUG("logging event\n");
+
+	if (buf == NULL)
+		return;
+
+	spin_lock_irqsave(&log_lock, s);
+
+	/* get length and increase count */
+	switch (err_type & ERR_TYPE_MASK) {
+	case ERR_TYPE_RTAS_LOG:
+		len = log_rtas_len(buf);
+		if (!(err_type & ERR_FLAG_BOOT))
+			error_log_cnt++;
+		break;
+	case ERR_TYPE_KERNEL_PANIC:
+	default:
+		spin_unlock_irqrestore(&log_lock, s);
+		return;
+	}
+
+	/* Write error to NVRAM */
+	if (!no_more_logging && !(err_type & ERR_FLAG_BOOT))
+		nvram_write_error_log(buf, len, err_type);
+
+	/* Check to see if we need to or have stopped logging */
+	if (fatal || no_more_logging) {
+		no_more_logging = 1;
+		spin_unlock_irqrestore(&log_lock, s);
+		return;
+	}
+
+	/* call type specific method for error */
+	switch (err_type & ERR_TYPE_MASK) {
+	case ERR_TYPE_RTAS_LOG:
+		/* put into syslog and error_log file */
+		printk_log_rtas(buf, len);
+
+		offset = rtas_error_log_buffer_max *
+			((rtas_log_start+rtas_log_size) & LOG_NUMBER_MASK);
+
+		/* First copy over sequence number */
+		memcpy(&rtas_log_buf[offset], (void *) &error_log_cnt, sizeof(int));
+
+		/* Second copy over error log data */
+		offset += sizeof(int);
+		memcpy(&rtas_log_buf[offset], buf, len);
+
+		if (rtas_log_size < LOG_NUMBER)
+			rtas_log_size += 1;
+		else
+			rtas_log_start += 1;
+
+		spin_unlock_irqrestore(&log_lock, s);
+		wake_up_interruptible(&rtas_log_wait);
+		break;
+	case ERR_TYPE_KERNEL_PANIC:
+	default:
+		spin_unlock_irqrestore(&log_lock, s);
+		return;
+	}
+
+}
+
+
 static int rtas_log_open(struct inode * inode, struct file * file)
 {
 	return 0;
@@ -69,36 +221,50 @@ static int rtas_log_release(struct inode
 	return 0;
 }
 
+/* This will check if all events are logged, if they are then, we
+ * know that we can safely clear the events in NVRAM.
+ * Next we'll sit and wait for something else to log.
+ */
 static ssize_t rtas_log_read(struct file * file, char * buf,
 			 size_t count, loff_t *ppos)
 {
 	int error;
 	char *tmp;
+	unsigned long s;
 	unsigned long offset;
 
-	if (!buf || count < rtas_error_log_max)
+	if (!buf || count < rtas_error_log_buffer_max)
 		return -EINVAL;
 
-	count = rtas_error_log_max;
+	count = rtas_error_log_buffer_max;
 
 	error = verify_area(VERIFY_WRITE, buf, count);
 	if (error)
-		return -EINVAL;
+		return -EFAULT;
 
-	tmp = kmalloc(rtas_error_log_max, GFP_KERNEL);
+	tmp = kmalloc(count, GFP_KERNEL);
 	if (!tmp)
 		return -ENOMEM;
 
+
+	spin_lock_irqsave(&log_lock, s);
+	/* if it's 0, then we know we got the last one (the one in NVRAM) */
+	if (rtas_log_size == 0 && !no_more_logging)
+		nvram_clear_error_log();
+	spin_unlock_irqrestore(&log_lock, s);
+
+
 	error = wait_event_interruptible(rtas_log_wait, rtas_log_size);
 	if (error)
 		goto out;
 
-	spin_lock(&rtas_log_lock);
-	offset = rtas_error_log_max * (rtas_log_start & LOG_NUMBER_MASK);
+	spin_lock_irqsave(&log_lock, s);
+	offset = rtas_error_log_buffer_max * (rtas_log_start & LOG_NUMBER_MASK);
 	memcpy(tmp, &rtas_log_buf[offset], count);
+
 	rtas_log_start += 1;
 	rtas_log_size -= 1;
-	spin_unlock(&rtas_log_lock);
+	spin_unlock_irqrestore(&log_lock, s);
 
 	error = copy_to_user(buf, tmp, count) ? -EFAULT : count;
 out:
@@ -121,42 +287,18 @@ struct file_operations proc_rtas_log_ope
 	.release =	rtas_log_release,
 };
 
-static void log_rtas(char *buf)
-{
-	unsigned long offset;
-
-	DEBUG("logging rtas event\n");
-
-	spin_lock(&rtas_log_lock);
-
-	offset = rtas_error_log_max *
-			((rtas_log_start+rtas_log_size) & LOG_NUMBER_MASK);
-
-	memcpy(&rtas_log_buf[offset], buf, rtas_error_log_max);
-
-	if (rtas_log_size < LOG_NUMBER)
-		rtas_log_size += 1;
-	else
-		rtas_log_start += 1;
-
-	spin_unlock(&rtas_log_lock);
-	wake_up_interruptible(&rtas_log_wait);
-}
-
-static int enable_surveillance(void)
+static int enable_surveillance(int timeout)
 {
 	int error;
 
 	error = rtas_call(rtas_token("set-indicator"), 3, 1, NULL,
-			  SURVEILLANCE_TOKEN, 0, SURVEILLANCE_TIMEOUT);
+			  SURVEILLANCE_TOKEN, 0, timeout);
 
 	if (error) {
 		printk(KERN_ERR "rtasd: could not enable surveillance\n");
 		return -1;
 	}
 
-	rtas_event_scan_rate = SURVEILLANCE_SCANRATE;
-
 	return 0;
 }
 
@@ -165,11 +307,12 @@ static int get_eventscan_parms(void)
 	struct device_node *node;
 	int *ip;
 
-	node = find_path_device("/rtas");
+	node = of_find_node_by_path("/rtas");
 
 	ip = (int *)get_property(node, "rtas-event-scan-rate", NULL);
 	if (ip == NULL) {
 		printk(KERN_ERR "rtasd: no rtas-event-scan-rate\n");
+		of_node_put(node);
 		return -1;
 	}
 	rtas_event_scan_rate = *ip;
@@ -178,6 +321,7 @@ static int get_eventscan_parms(void)
 	ip = (int *)get_property(node, "rtas-error-log-max", NULL);
 	if (ip == NULL) {
 		printk(KERN_ERR "rtasd: no rtas-error-log-max\n");
+		of_node_put(node);
 		return -1;
 	}
 	rtas_error_log_max = *ip;
@@ -187,6 +331,7 @@ static int get_eventscan_parms(void)
 		printk(KERN_ERR "rtasd: truncated error log from %d to %d bytes\n", rtas_error_log_max, RTAS_ERROR_LOG_MAX);
 		rtas_error_log_max = RTAS_ERROR_LOG_MAX;
 	}
+	of_node_put(node);
 
 	return 0;
 }
@@ -195,10 +340,12 @@ extern long sys_sched_get_priority_max(i
 
 static int rtasd(void *unused)
 {
+	unsigned int err_type;
 	int cpu = 0;
 	int error;
 	int first_pass = 1;
 	int event_scan = rtas_token("event-scan");
+	int rc;
 
 	if (event_scan == RTAS_UNKNOWN_SERVICE || get_eventscan_parms() == -1)
 		goto error;
@@ -209,6 +356,9 @@ static int rtasd(void *unused)
 		goto error;
 	}
 
+	/* We can use rtas_log_buf now */
+	no_more_logging = 0;
+
 	DEBUG("will sleep for %d jiffies\n", (HZ*60/rtas_event_scan_rate) / 2);
 
 	daemonize("rtasd");
@@ -219,6 +369,16 @@ static int rtasd(void *unused)
 	current->nice = sys_sched_get_priority_max(SCHED_FIFO) + 1;
 #endif
 
+	/* See if we have any error stored in NVRAM */
+	memset(logdata, 0, rtas_error_log_max);
+
+	rc = nvram_read_error_log(logdata, rtas_error_log_max, &err_type);
+	if (!rc) {
+		if (err_type != ERR_FLAG_ALREADY_LOGGED) {
+			pSeries_log_error(logdata, err_type | ERR_FLAG_BOOT, 0);
+		}
+	}
+
 repeat:
 	for (cpu = 0; cpu < NR_CPUS; cpu++) {
 		if (!cpu_online(cpu))
@@ -231,7 +391,7 @@ repeat:
 		do {
 			memset(logdata, 0, rtas_error_log_max);
 			error = rtas_call(event_scan, 4, 1, NULL,
-					EVENT_SCAN_ALL_EVENTS, 0,
+					RTAS_EVENT_SCAN_ALL_EVENTS, 0,
 					__pa(logdata), rtas_error_log_max);
 			if (error == -1) {
 				printk(KERN_ERR "event-scan failed\n");
@@ -239,7 +399,7 @@ repeat:
 			}
 
 			if (error == 0)
-				log_rtas(logdata);
+				pSeries_log_error(logdata, ERR_TYPE_RTAS_LOG, 0);
 
 		} while(error == 0);
 
@@ -252,9 +412,9 @@ repeat:
 		schedule_timeout(first_pass ? HZ : (HZ*60/rtas_event_scan_rate) / 2);
 	}
 
-	if (first_pass && surveillance_requested) {
+	if (first_pass && (surveillance_timeout != -1)) {
 		DEBUG("enabling surveillance\n");
-		if (enable_surveillance())
+		if (enable_surveillance(surveillance_timeout))
 			goto error_vfree;
 		DEBUG("surveillance enabled\n");
 	}
@@ -273,25 +433,29 @@ static int __init rtas_init(void)
 {
 	struct proc_dir_entry *entry;
 
-	if (proc_rtas == NULL) {
-		proc_rtas = proc_mkdir("rtas", 0);
+	if (proc_ppc64.rtas == NULL) {
+		proc_ppc64_init();
 	}
 
-	if (proc_rtas == NULL) {
-		printk(KERN_ERR "Failed to create /proc/rtas in rtas_init\n");
-	} else {
-		entry = create_proc_entry("error_log", S_IRUSR, proc_rtas);
-		if (entry)
-			entry->proc_fops = &proc_rtas_log_operations;
-		else
-			printk(KERN_ERR "Failed to create rtas/error_log proc entry\n");
+	if (proc_ppc64.rtas == NULL) {
+		printk(KERN_ERR "rtas_init: /proc/ppc64/rtas does not exist.");
+		return -EIO;
 	}
 
+	entry = create_proc_entry("error_log", S_IRUSR, proc_ppc64.rtas);
+	if (entry)
+		entry->proc_fops = &proc_rtas_log_operations;
+	else
+		printk(KERN_ERR "Failed to create rtas/error_log proc entry\n");
+
 	if (kernel_thread(rtasd, 0, CLONE_FS) < 0)
 		printk(KERN_ERR "Failed to start RTAS daemon\n");
 
 	printk(KERN_ERR "RTAS daemon started\n");
 
+	/* Make room for the sequence number */
+	rtas_error_log_buffer_max = rtas_error_log_max + sizeof(int);
+
 	return 0;
 }
 
@@ -300,8 +464,8 @@ static int __init surveillance_setup(cha
 	int i;
 
 	if (get_option(&str,&i)) {
-		if (i == 1)
-			surveillance_requested = 1;
+		if (i >= 0 && i <= 255)
+			surveillance_timeout = i;
 	}
 
 	return 1;
diff -puN arch/ppc64/kernel/rtas_flash.c~linus arch/ppc64/kernel/rtas_flash.c
--- 25/arch/ppc64/kernel/rtas_flash.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/rtas_flash.c	2004-01-19 22:17:21.000000000 -0800
@@ -14,15 +14,64 @@
  */
 
 #include <linux/module.h>
-#include <linux/proc_fs.h>
+
+#include <linux/config.h>
 #include <linux/init.h>
+#include <asm/proc_fs.h>
+#include <asm/delay.h>
 #include <asm/uaccess.h>
 #include <asm/rtas.h>
 
 #define MODULE_VERSION "1.0"
 #define MODULE_NAME "rtas_flash"
 
-#define FIRMWARE_FLASH_NAME "firmware_flash"
+#define FIRMWARE_FLASH_NAME "firmware_flash"   
+#define FIRMWARE_UPDATE_NAME "firmware_update"
+#define MANAGE_FLASH_NAME "manage_flash"
+#define VALIDATE_FLASH_NAME "validate_flash"
+
+/* General RTAS Status Codes */
+#define RTAS_RC_SUCCESS  0
+#define RTAS_RC_HW_ERR	-1
+#define RTAS_RC_BUSY	-2
+
+/* Flash image status values */
+#define FLASH_AUTH           -9002 /* RTAS Not Service Authority Partition */
+#define FLASH_NO_OP          -1099 /* No operation initiated by user */	
+#define FLASH_IMG_SHORT	     -1005 /* Flash image shorter than expected */
+#define FLASH_IMG_BAD_LEN    -1004 /* Bad length value in flash list block */
+#define FLASH_IMG_NULL_DATA  -1003 /* Bad data value in flash list block */
+#define FLASH_IMG_READY      0     /* Firmware img ready for flash on reboot */
+
+/* Manage image status values */
+#define MANAGE_AUTH          -9002 /* RTAS Not Service Authority Partition */
+#define MANAGE_ACTIVE_ERR    -9001 /* RTAS Cannot Overwrite Active Img */
+#define MANAGE_NO_OP         -1099 /* No operation initiated by user */
+#define MANAGE_PARAM_ERR     -3    /* RTAS Parameter Error */
+#define MANAGE_HW_ERR        -1    /* RTAS Hardware Error */
+
+/* Validate image status values */
+#define VALIDATE_AUTH          -9002 /* RTAS Not Service Authority Partition */
+#define VALIDATE_NO_OP         -1099 /* No operation initiated by the user */
+#define VALIDATE_INCOMPLETE    -1002 /* User copied < VALIDATE_BUF_SIZE */
+#define VALIDATE_READY	       -1001 /* Firmware image ready for validation */
+#define VALIDATE_PARAM_ERR     -3    /* RTAS Parameter Error */
+#define VALIDATE_HW_ERR        -1    /* RTAS Hardware Error */
+#define VALIDATE_TMP_UPDATE    0     /* Validate Return Status */
+#define VALIDATE_FLASH_AUTH    1     /* Validate Return Status */
+#define VALIDATE_INVALID_IMG   2     /* Validate Return Status */
+#define VALIDATE_CUR_UNKNOWN   3     /* Validate Return Status */
+#define VALIDATE_TMP_COMMIT_DL 4     /* Validate Return Status */
+#define VALIDATE_TMP_COMMIT    5     /* Validate Return Status */
+#define VALIDATE_TMP_UPDATE_DL 6     /* Validate Return Status */
+
+/* ibm,manage-flash-image operation tokens */
+#define RTAS_REJECT_TMP_IMG   0
+#define RTAS_COMMIT_TMP_IMG   1
+
+/* Array sizes */
+#define VALIDATE_BUF_SIZE 4096    
+#define RTAS_MSG_MAXLEN   64
 
 /* Local copy of the flash block list.
  * We only allow one open of the flash proc file and create this
@@ -34,21 +83,35 @@
  * is treated as the number of entries currently in the block
  * (i.e. not a byte count).  This is all fixed on release.
  */
-static struct flash_block_list *flist;
-static char *flash_msg;
-static int flash_possible;
-
-static int rtas_flash_open(struct inode *inode, struct file *file)
-{
-	if ((file->f_mode & FMODE_WRITE) && flash_possible) {
-		if (flist)
-			return -EBUSY;
-		flist = (struct flash_block_list *)get_zeroed_page(GFP_KERNEL);
-		if (!flist)
-			return -ENOMEM;
-	}
-	return 0;
-}
+
+/* Status int must be first member of struct */
+struct rtas_update_flash_t
+{
+	int status;			/* Flash update status */
+	struct flash_block_list *flist; /* Local copy of flash block list */
+};
+
+/* Status int must be first member of struct */
+struct rtas_manage_flash_t
+{
+	int status;			/* Returned status */
+	unsigned int op;		/* Reject or commit image */
+};
+
+/* Status int must be first member of struct */
+struct rtas_validate_flash_t
+{
+	int status;		 	/* Returned status */	
+	char buf[VALIDATE_BUF_SIZE]; 	/* Candidate image buffer */
+	unsigned int buf_size;		/* Size of image buf */
+	unsigned int update_results;	/* Update results token */
+};
+
+static spinlock_t flash_file_open_lock = SPIN_LOCK_UNLOCKED;
+static struct proc_dir_entry *firmware_flash_pde = NULL;
+static struct proc_dir_entry *firmware_update_pde = NULL;
+static struct proc_dir_entry *validate_pde = NULL;
+static struct proc_dir_entry *manage_pde = NULL;
 
 /* Do simple sanity checks on the flash image. */
 static int flash_list_valid(struct flash_block_list *flist)
@@ -57,32 +120,29 @@ static int flash_list_valid(struct flash
 	int i;
 	unsigned long block_size, image_size;
 
-	flash_msg = NULL;
 	/* Paranoid self test here.  We also collect the image size. */
 	image_size = 0;
 	for (f = flist; f; f = f->next) {
 		for (i = 0; i < f->num_blocks; i++) {
 			if (f->blocks[i].data == NULL) {
-				flash_msg = "error: internal error null data\n";
-				return 0;
+				return FLASH_IMG_NULL_DATA;
 			}
 			block_size = f->blocks[i].length;
 			if (block_size <= 0 || block_size > PAGE_SIZE) {
-				flash_msg = "error: internal error bad length\n";
-				return 0;
+				return FLASH_IMG_BAD_LEN;
 			}
 			image_size += block_size;
 		}
 	}
+
 	if (image_size < (256 << 10)) {
-		if (image_size < 2)
-			flash_msg = NULL;	/* allow "clear" of image */
-		else
-			flash_msg = "error: flash image short\n";
-		return 0;
+		if (image_size < 2) 
+			return FLASH_NO_OP;
 	}
+
 	printk(KERN_INFO "FLASH: flash image with %ld bytes stored for hardware flash on reboot\n", image_size);
-	return 1;
+
+	return FLASH_IMG_READY;
 }
 
 static void free_flash_list(struct flash_block_list *f)
@@ -101,40 +161,80 @@ static void free_flash_list(struct flash
 
 static int rtas_flash_release(struct inode *inode, struct file *file)
 {
-	if (flist) {
-		/* Always clear saved list on a new attempt. */
+	struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+	struct rtas_update_flash_t *uf;
+	
+	uf = (struct rtas_update_flash_t *) dp->data;
+	if (uf->flist) {    
+		/* File was opened in write mode for a new flash attempt */
+		/* Clear saved list */
 		if (rtas_firmware_flash_list.next) {
 			free_flash_list(rtas_firmware_flash_list.next);
 			rtas_firmware_flash_list.next = NULL;
 		}
 
-		if (flash_list_valid(flist))
-			rtas_firmware_flash_list.next = flist;
+		if (uf->status != FLASH_AUTH)  
+			uf->status = flash_list_valid(uf->flist);
+
+		if (uf->status == FLASH_IMG_READY) 
+			rtas_firmware_flash_list.next = uf->flist;
 		else
-			free_flash_list(flist);
-		flist = NULL;
+			free_flash_list(uf->flist);
+
+		uf->flist = NULL;
 	}
+
+	atomic_dec(&dp->count);
 	return 0;
 }
 
+static void get_flash_status_msg(int status, char *buf)
+{
+	char *msg;
+
+	switch (status) {
+	case FLASH_AUTH:
+		msg = "error: this partition does not have service authority\n";
+		break;
+	case FLASH_NO_OP:
+		msg = "info: no firmware image for flash\n";
+		break;
+	case FLASH_IMG_SHORT:
+		msg = "error: flash image short\n";
+		break;
+	case FLASH_IMG_BAD_LEN:
+		msg = "error: internal error bad length\n";
+		break;
+	case FLASH_IMG_NULL_DATA:
+		msg = "error: internal error null data\n";
+		break;
+	case FLASH_IMG_READY:
+		msg = "ready: firmware image ready for flash on reboot\n";
+		break;
+	default:
+		sprintf(buf, "error: unexpected status value %d\n", status);
+		return;
+	}
+
+	strcpy(buf, msg);	
+}
+
 /* Reading the proc file will show status (not the firmware contents) */
 static ssize_t rtas_flash_read(struct file *file, char *buf,
 			       size_t count, loff_t *ppos)
 {
+	struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+	struct rtas_update_flash_t *uf;
+	char msg[RTAS_MSG_MAXLEN];
 	int error;
-	char *msg;
 	int msglen;
 
-	if (!flash_possible) {
-		msg = "error: this partition does not have service authority\n";
-	} else if (flist) {
-		msg = "info: this file is busy for write by some process\n";
-	} else if (flash_msg) {
-		msg = flash_msg;	/* message from last flash attempt */
-	} else if (rtas_firmware_flash_list.next) {
-		msg = "ready: firmware image ready for flash on reboot\n";
-	} else {
-		msg = "info: no firmware image for flash\n";
+	uf = (struct rtas_update_flash_t *) dp->data;
+
+	if (!strcmp(dp->name, FIRMWARE_FLASH_NAME)) {
+		get_flash_status_msg(uf->status, msg);
+	} else {	   /* FIRMWARE_UPDATE_NAME */
+		sprintf(msg, "%d\n", uf->status);
 	}
 	msglen = strlen(msg);
 	if (msglen > count)
@@ -147,7 +247,8 @@ static ssize_t rtas_flash_read(struct fi
 	if (error)
 		return -EINVAL;
 
-	copy_to_user(buf, msg, msglen);
+	if (copy_to_user(buf, msg, msglen))
+		return -EFAULT;
 
 	if (ppos)
 		*ppos = msglen;
@@ -162,14 +263,28 @@ static ssize_t rtas_flash_read(struct fi
 static ssize_t rtas_flash_write(struct file *file, const char *buffer,
 				size_t count, loff_t *off)
 {
-	size_t len = count;
+	struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+	struct rtas_update_flash_t *uf;
 	char *p;
 	int next_free;
-	struct flash_block_list *fl = flist;
+	struct flash_block_list *fl;
+
+	uf = (struct rtas_update_flash_t *) dp->data;
 
-	if (!flash_possible || len == 0)
-		return len;	/* discard data */
+	if (uf->status == FLASH_AUTH || count == 0)
+		return count;	/* discard data */
 
+	/* In the case that the image is not ready for flashing, the memory
+	 * allocated for the block list will be freed upon the release of the 
+	 * proc file
+	 */
+	if (uf->flist == NULL) {
+		uf->flist = (struct flash_block_list *) get_zeroed_page(GFP_KERNEL);
+		if (!uf->flist)
+			return -ENOMEM;
+	}
+
+	fl = uf->flist;
 	while (fl->next)
 		fl = fl->next; /* seek to last block_list for append */
 	next_free = fl->num_blocks;
@@ -182,47 +297,392 @@ static ssize_t rtas_flash_write(struct f
 		next_free = 0;
 	}
 
-	if (len > PAGE_SIZE)
-		len = PAGE_SIZE;
+	if (count > PAGE_SIZE)
+		count = PAGE_SIZE;
 	p = (char *)get_zeroed_page(GFP_KERNEL);
 	if (!p)
 		return -ENOMEM;
-	if(copy_from_user(p, buffer, len)) {
+	
+	if(copy_from_user(p, buffer, count)) {
 		free_page((unsigned long)p);
 		return -EFAULT;
 	}
 	fl->blocks[next_free].data = p;
-	fl->blocks[next_free].length = len;
+	fl->blocks[next_free].length = count;
 	fl->num_blocks++;
 
-	return len;
+	return count;
+}
+
+static int rtas_excl_open(struct inode *inode, struct file *file)
+{
+	struct proc_dir_entry *dp = PDE(inode);
+
+	/* Enforce exclusive open with use count of PDE */
+	spin_lock(&flash_file_open_lock);
+	if (atomic_read(&dp->count) > 1) {
+		spin_unlock(&flash_file_open_lock);
+		return -EBUSY;
+	}
+
+	atomic_inc(&dp->count);
+	spin_unlock(&flash_file_open_lock);
+	
+	return 0;
+}
+
+static int rtas_excl_release(struct inode *inode, struct file *file)
+{
+	struct proc_dir_entry *dp = PDE(inode);
+
+	atomic_dec(&dp->count);
+
+	return 0;
+}
+
+static void manage_flash(struct rtas_manage_flash_t *args_buf)
+{
+	unsigned int wait_time;
+	s32 rc;
+
+	while (1) {
+		rc = (s32) rtas_call(rtas_token("ibm,manage-flash-image"), 1, 
+				1, NULL, (long) args_buf->op);
+		if (rc == RTAS_RC_BUSY)
+			udelay(1);
+		else if (rtas_is_extended_busy(rc)) {
+			wait_time = rtas_extended_busy_delay_time(rc);
+			udelay(wait_time * 1000);
+		} else
+			break;
+	}
+
+	args_buf->status = rc;
+}
+
+static ssize_t manage_flash_read(struct file *file, char *buf,
+			       size_t count, loff_t *ppos)
+{
+	struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+	struct rtas_manage_flash_t *args_buf;
+	char msg[RTAS_MSG_MAXLEN];
+	int msglen;
+	int error;
+
+	args_buf = (struct rtas_manage_flash_t *) dp->data;
+	if (args_buf == NULL)
+		return 0;
+
+	msglen = sprintf(msg, "%d\n", args_buf->status);
+	if (msglen > count)
+		msglen = count;
+
+	if (ppos && *ppos != 0)
+		return 0;	/* be cheap */
+
+	error = verify_area(VERIFY_WRITE, buf, msglen);
+	if (error)
+		return -EINVAL;
+
+	if (copy_to_user(buf, msg, msglen))
+		return -EFAULT;
+
+	if (ppos)
+		*ppos = msglen;
+	return msglen;
+}
+
+static ssize_t manage_flash_write(struct file *file, const char *buf,
+				size_t count, loff_t *off)
+{
+	struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+	struct rtas_manage_flash_t *args_buf;
+	const char reject_str[] = "0";
+	const char commit_str[] = "1";
+	char stkbuf[10];
+	int op;
+
+	args_buf = (struct rtas_manage_flash_t *) dp->data;
+	if ((args_buf->status == MANAGE_AUTH) || (count == 0))
+		return count;
+		
+	op = -1;
+	if (buf) {
+		if (count > 9) count = 9;
+		if (copy_from_user (stkbuf, buf, count)) {
+			return -EFAULT;
+		}
+		if (strncmp(stkbuf, reject_str, strlen(reject_str)) == 0) 
+			op = RTAS_REJECT_TMP_IMG;
+		else if (strncmp(stkbuf, commit_str, strlen(commit_str)) == 0) 
+			op = RTAS_COMMIT_TMP_IMG;
+	}
+	
+	if (op == -1)   /* buf is empty, or contains invalid string */
+		return -EINVAL;
+
+	args_buf->op = op;
+	manage_flash(args_buf);
+
+	return count;
+}
+
+static void validate_flash(struct rtas_validate_flash_t *args_buf)
+{
+	int token = rtas_token("ibm,validate-flash-image");
+	unsigned int wait_time;
+	long update_results;
+	s32 rc;	
+
+	rc = 0;
+	while(1) {
+		spin_lock(&rtas_data_buf_lock);
+		memcpy(rtas_data_buf, args_buf->buf, VALIDATE_BUF_SIZE);
+		rc = (s32) rtas_call(token, 2, 2, &update_results, 
+				     __pa(rtas_data_buf), args_buf->buf_size);
+		memcpy(args_buf->buf, rtas_data_buf, VALIDATE_BUF_SIZE);
+		spin_unlock(&rtas_data_buf_lock);
+			
+		if (rc == RTAS_RC_BUSY)
+			udelay(1);
+		else if (rtas_is_extended_busy(rc)) {
+			wait_time = rtas_extended_busy_delay_time(rc);
+			udelay(wait_time * 1000);
+		} else
+			break;
+	}
+
+	args_buf->status = rc;
+	args_buf->update_results = (u32) update_results;
+}
+
+static int get_validate_flash_msg(struct rtas_validate_flash_t *args_buf, 
+		                   char *msg)
+{
+	int n;
+
+	if (args_buf->status >= VALIDATE_TMP_UPDATE) { 
+		n = sprintf(msg, "%d\n", args_buf->update_results);
+		if ((args_buf->update_results >= VALIDATE_CUR_UNKNOWN) ||
+		    (args_buf->update_results == VALIDATE_TMP_UPDATE))
+			n += sprintf(msg + n, "%s\n", args_buf->buf);
+	} else {
+		n = sprintf(msg, "%d\n", args_buf->status);
+	}
+	return n;
+}
+
+static ssize_t validate_flash_read(struct file *file, char *buf,
+			       size_t count, loff_t *ppos)
+{
+	struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+	struct rtas_validate_flash_t *args_buf;
+	char msg[RTAS_MSG_MAXLEN];
+	int msglen;
+	int error;
+
+	args_buf = (struct rtas_validate_flash_t *) dp->data;
+
+	if (ppos && *ppos != 0)
+		return 0;	/* be cheap */
+	
+	msglen = get_validate_flash_msg(args_buf, msg);
+	if (msglen > count)
+		msglen = count;
+
+	error = verify_area(VERIFY_WRITE, buf, msglen);
+	if (error)
+		return -EINVAL;
+
+	if (copy_to_user(buf, msg, msglen))
+		return -EFAULT;
+
+	if (ppos)
+		*ppos = msglen;
+	return msglen;
+}
+
+static ssize_t validate_flash_write(struct file *file, const char *buf,
+				size_t count, loff_t *off)
+{
+	struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+	struct rtas_validate_flash_t *args_buf;
+	int rc;
+
+	args_buf = (struct rtas_validate_flash_t *) dp->data;
+
+	if (dp->data == NULL) {
+		dp->data = kmalloc(sizeof(struct rtas_validate_flash_t), 
+				GFP_KERNEL);
+		if (dp->data == NULL) 
+			return -ENOMEM;
+	}
+
+	/* We are only interested in the first 4K of the
+	 * candidate image */
+	if ((*off >= VALIDATE_BUF_SIZE) || 
+		(args_buf->status == VALIDATE_AUTH)) {
+		*off += count;
+		return count;
+	}
+
+	if (*off + count >= VALIDATE_BUF_SIZE)  {
+		count = VALIDATE_BUF_SIZE - *off;
+		args_buf->status = VALIDATE_READY;	
+	} else {
+		args_buf->status = VALIDATE_INCOMPLETE;
+	}
+
+	if (verify_area(VERIFY_READ, buf, count)) {
+		rc = -EFAULT;
+		goto done;
+	}
+	if (copy_from_user(args_buf->buf + *off, buf, count)) {
+		rc = -EFAULT;
+		goto done;
+	}
+
+	*off += count;
+	rc = count;
+done:
+	if (rc < 0) {
+		kfree(dp->data);
+		dp->data = NULL;
+	}
+	return rc;
+}
+
+static int validate_flash_release(struct inode *inode, struct file *file)
+{
+	struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
+	struct rtas_validate_flash_t *args_buf;
+
+	args_buf = (struct rtas_validate_flash_t *) dp->data;
+
+	if (args_buf->status == VALIDATE_READY) {
+		args_buf->buf_size = VALIDATE_BUF_SIZE;
+		validate_flash(args_buf);
+	}
+
+	atomic_dec(&dp->count);
+
+	return 0;
+}
+
+static inline void remove_flash_pde(struct proc_dir_entry *dp)
+{
+	if (dp) {
+		if (dp->data != NULL)
+			kfree(dp->data);
+		remove_proc_entry(dp->name, proc_ppc64.rtas);
+	}
+}
+
+static inline int initialize_flash_pde_data(const char *rtas_call_name, 
+		                            size_t buf_size,
+					    struct proc_dir_entry *dp)
+{
+	int *status;
+	int token;
+
+	dp->data = kmalloc(buf_size, GFP_KERNEL);
+	if (dp->data == NULL) {
+		remove_flash_pde(dp);
+		return -ENOMEM;
+	}
+
+	memset(dp->data, 0, buf_size);
+
+	/* This code assumes that the status int is the first member of the
+	 * struct 
+	 */
+	status = (int *) dp->data;
+	token = rtas_token(rtas_call_name);
+	if (token == RTAS_UNKNOWN_SERVICE)
+		*status = FLASH_AUTH;
+	else
+		*status = FLASH_NO_OP;
+
+	return 0;
+}
+
+static inline struct proc_dir_entry * create_flash_pde(const char *filename, 
+					struct file_operations *fops)
+{
+	struct proc_dir_entry *ent = NULL;
+
+	ent = create_proc_entry(filename, S_IRUSR | S_IWUSR, proc_ppc64.rtas);
+	if (ent != NULL) {
+		ent->nlink = 1;
+		ent->proc_fops = fops;
+		ent->owner = THIS_MODULE;
+	}
+
+	return ent;
 }
 
 static struct file_operations rtas_flash_operations = {
 	.read		= rtas_flash_read,
 	.write		= rtas_flash_write,
-	.open		= rtas_flash_open,
+	.open		= rtas_excl_open,
 	.release	= rtas_flash_release,
 };
 
+static struct file_operations manage_flash_operations = {
+	.read		= manage_flash_read,
+	.write		= manage_flash_write,
+	.open		= rtas_excl_open,
+	.release	= rtas_excl_release,
+};
+
+static struct file_operations validate_flash_operations = {
+	.read		= validate_flash_read,
+	.write		= validate_flash_write,
+	.open		= rtas_excl_open,
+	.release	= validate_flash_release,
+};
 
 int __init rtas_flash_init(void)
 {
-	struct proc_dir_entry *ent = NULL;
+	int rc;
 
 	if (!proc_ppc64.rtas) {
 		printk(KERN_WARNING "rtas proc dir does not already exist");
 		return -ENOENT;
 	}
 
-	if (rtas_token("ibm,update-flash-64-and-reboot") != RTAS_UNKNOWN_SERVICE)
-		flash_possible = 1;
-
-	if ((ent = create_proc_entry(FIRMWARE_FLASH_NAME, S_IRUSR | S_IWUSR, proc_ppc64.rtas)) != NULL) {
-		ent->nlink = 1;
-		ent->proc_fops = &rtas_flash_operations;
-		ent->owner = THIS_MODULE;
-	}
+	firmware_flash_pde = create_flash_pde(FIRMWARE_FLASH_NAME, 
+					      &rtas_flash_operations);
+	rc = initialize_flash_pde_data("ibm,update-flash-64-and-reboot",
+			 	       sizeof(struct rtas_update_flash_t), 
+				       firmware_flash_pde);
+	if (rc != 0)
+		return rc;
+	
+	firmware_update_pde = create_flash_pde(FIRMWARE_UPDATE_NAME, 
+					       &rtas_flash_operations);
+	rc = initialize_flash_pde_data("ibm,update-flash-64-and-reboot",
+			 	       sizeof(struct rtas_update_flash_t), 
+				       firmware_update_pde);
+	if (rc != 0)
+		return rc;
+	
+	validate_pde = create_flash_pde(VALIDATE_FLASH_NAME, 
+			      		&validate_flash_operations);
+	rc = initialize_flash_pde_data("ibm,validate-flash-image",
+		                       sizeof(struct rtas_validate_flash_t), 
+				       validate_pde);
+	if (rc != 0)
+		return rc;
+	
+	manage_pde = create_flash_pde(MANAGE_FLASH_NAME, 
+				      &manage_flash_operations);
+	rc = initialize_flash_pde_data("ibm,manage-flash-image",
+			               sizeof(struct rtas_manage_flash_t),
+				       manage_pde);
+	if (rc != 0)
+		return rc;
+	
 	return 0;
 }
 
@@ -230,7 +690,10 @@ void __exit rtas_flash_cleanup(void)
 {
 	if (!proc_ppc64.rtas)
 		return;
-	remove_proc_entry(FIRMWARE_FLASH_NAME, proc_ppc64.rtas);
+	remove_flash_pde(firmware_flash_pde);
+	remove_flash_pde(firmware_update_pde);
+	remove_flash_pde(validate_pde);
+	remove_flash_pde(manage_pde);
 }
 
 module_init(rtas_flash_init);
diff -puN arch/ppc64/kernel/rtas-proc.c~linus arch/ppc64/kernel/rtas-proc.c
--- 25/arch/ppc64/kernel/rtas-proc.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/rtas-proc.c	2004-01-19 22:17:21.000000000 -0800
@@ -20,6 +20,7 @@
 #include <linux/ctype.h>
 #include <linux/time.h>
 #include <linux/string.h>
+#include <linux/init.h>
 
 #include <asm/uaccess.h>
 #include <asm/bitops.h>
@@ -27,6 +28,7 @@
 #include <asm/io.h>
 #include <asm/prom.h>
 #include <asm/rtas.h>
+#include <asm/proc_fs.h>
 #include <asm/machdep.h> /* for ppc_md */
 #include <asm/time.h>
 
@@ -161,6 +163,8 @@ static ssize_t ppc_rtas_tone_volume_writ
 		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 ssize_t ppc_rtas_rmo_buf_read(struct file *file, char *buf,
+				    size_t count, loff_t *ppos);
 
 struct file_operations ppc_rtas_poweron_operations = {
 	.read =		ppc_rtas_poweron_read,
@@ -185,6 +189,10 @@ struct file_operations ppc_rtas_tone_vol
 	.write =	ppc_rtas_tone_volume_write
 };
 
+static struct file_operations ppc_rtas_rmo_buf_ops = {
+	.read =		ppc_rtas_rmo_buf_read,
+};
+
 int ppc_rtas_find_all_sensors (void);
 int ppc_rtas_process_sensor(struct individual_sensor s, int state, 
 		int error, char * buf);
@@ -200,39 +208,42 @@ void proc_rtas_init(void)
 {
 	struct proc_dir_entry *entry;
 
-	rtas_node = find_devices("rtas");
+	rtas_node = of_find_node_by_name(NULL, "rtas");
 	if ((rtas_node == NULL) || (systemcfg->platform == PLATFORM_ISERIES_LPAR)) {
 		return;
 	}
 	
-	if (proc_rtas == NULL) {
-		proc_rtas = proc_mkdir("rtas", 0);
+	if (proc_ppc64.rtas == NULL) {
+		proc_ppc64_init();
 	}
 
-	if (proc_rtas == NULL) {
+	if (proc_ppc64.rtas == NULL) {
 		printk(KERN_ERR "Failed to create /proc/rtas in proc_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, proc_ppc64.rtas);
 	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, proc_ppc64.rtas); 
 	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, proc_ppc64.rtas); 
 	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, proc_ppc64.rtas, 
 			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, proc_ppc64.rtas); 
 	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, proc_ppc64.rtas); 
 	if (entry) entry->proc_fops = &ppc_rtas_tone_volume_operations;
+
+	entry = create_proc_entry("rmo_buffer", S_IRUSR, proc_ppc64.rtas);
+	if (entry) entry->proc_fops = &ppc_rtas_rmo_buf_ops;
 }
 
 /* ****************************************************************** */
@@ -919,3 +930,28 @@ static ssize_t ppc_rtas_tone_volume_read
 	*ppos += n;
 	return n;
 }
+
+#define RMO_READ_BUF_MAX 30
+
+/* RTAS Userspace access */
+static ssize_t ppc_rtas_rmo_buf_read(struct file *file, char __user *buf,
+				    size_t count, loff_t *ppos)
+{
+	char kbuf[RMO_READ_BUF_MAX];
+	int n;
+
+	n = sprintf(kbuf, "%016lx %x\n", rtas_rmo_buf, RTAS_RMOBUF_MAX);
+	if (n > count)
+		n = count;
+
+	if (ppos && *ppos != 0)
+		return 0;
+
+	if (copy_to_user(buf, kbuf, n))
+		return -EFAULT;
+
+	if (ppos)
+		*ppos = n;
+	
+	return n;
+}
diff -puN arch/ppc64/kernel/rtc.c~linus arch/ppc64/kernel/rtc.c
--- 25/arch/ppc64/kernel/rtc.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/rtc.c	2004-01-19 22:17:21.000000000 -0800
@@ -99,6 +99,7 @@ static int rtc_ioctl(struct inode *inode
 	switch (cmd) {
 	case RTC_RD_TIME:	/* Read the time/date from RTC	*/
 	{
+		memset(&wtime, 0, sizeof(struct rtc_time));
 		ppc_md.get_rtc_time(&wtime);
 		break;
 	}
diff -puN arch/ppc64/kernel/scanlog.c~linus arch/ppc64/kernel/scanlog.c
--- 25/arch/ppc64/kernel/scanlog.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/scanlog.c	2004-01-19 22:17:21.000000000 -0800
@@ -28,6 +28,7 @@
 #include <asm/uaccess.h>
 #include <asm/rtas.h>
 #include <asm/prom.h>
+#include <asm/proc_fs.h>
 
 #define MODULE_VERSION "1.0"
 #define MODULE_NAME "scanlog"
@@ -43,9 +44,6 @@ static int scanlog_debug;
 static unsigned int ibm_scan_log_dump;			/* RTAS token */
 static struct proc_dir_entry *proc_ppc64_scan_log_dump;	/* The proc file */
 
-extern struct proc_dir_entry *proc_rtas;
-
-
 static ssize_t scanlog_read(struct file *file, char *buf,
 			    size_t count, loff_t *ppos)
 {
@@ -214,15 +212,16 @@ int __init scanlog_init(void)
 		return -EIO;
 	}
 
-	if (proc_rtas == NULL)
-                proc_rtas = proc_mkdir("rtas", 0);
+	if (proc_ppc64.rtas == NULL) {
+		proc_ppc64_init();
+	}
 
-	if (proc_rtas == NULL) {
+	if (proc_ppc64.rtas == NULL) {
 		printk(KERN_ERR "Failed to create /proc/rtas in scanlog_init\n");
 		return -EIO;
 	}
 
-        ent = create_proc_entry("scan-log-dump",  S_IRUSR, proc_rtas);
+        ent = create_proc_entry("scan-log-dump",  S_IRUSR, proc_ppc64.rtas);
 	if (ent) {
 		ent->proc_fops = &scanlog_fops;
 		/* Ideally we could allocate a buffer < 4G */
diff -puN arch/ppc64/kernel/setup.c~linus arch/ppc64/kernel/setup.c
--- 25/arch/ppc64/kernel/setup.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/setup.c	2004-01-19 22:17:21.000000000 -0800
@@ -58,6 +58,9 @@ extern void iSeries_init_early( void );
 extern void pSeries_init_early( void );
 extern void pSeriesLP_init_early(void);
 extern void mm_init_ppc64( void ); 
+extern void pseries_secondary_smp_init(unsigned long); 
+extern int  idle_setup(void);
+extern void vpa_init(int cpu);
 
 unsigned long decr_overclock = 1;
 unsigned long decr_overclock_proc0 = 1;
@@ -137,12 +140,16 @@ void __init disable_early_printk(void)
 }
 
 /*
- * 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,
 		  unsigned long r6, unsigned long r7)
 {
+#ifdef CONFIG_PPC_PSERIES
+        unsigned int ret, i;
+#endif
+
 #ifdef CONFIG_XMON_DEFAULT
 	debugger = xmon;
 	debugger_bpt = xmon_bpt;
@@ -183,10 +190,33 @@ void setup_system(unsigned long r3, unsi
 #endif
 	}
 
+#ifdef CONFIG_PPC_PSERIES
 	if (systemcfg->platform & PLATFORM_PSERIES) {
 		early_console_initialized = 1;
 		register_console(&udbg_console);
+		finish_device_tree();
+		chrp_init(r3, r4, r5, r6, r7);
+
+#ifdef CONFIG_SMP
+		/* Start secondary threads on SMT systems */
+		for (i = 0; i < NR_CPUS; i++) {
+			if(cpu_available(i)  && !cpu_possible(i)) {
+				printk("%16.16x : starting thread\n", i);
+				rtas_call(rtas_token("start-cpu"), 3, 1, 
+					  (void *)&ret,
+					  get_hard_smp_processor_id(i), 
+					  *((unsigned long *)pseries_secondary_smp_init), i);
+				cpu_set(i, cpu_possible_map);
+				systemcfg->processorCount++;
+			}
+		}
+#endif
 	}
+#endif
+	/* Finish initializing the hash table (do the dynamic
+	 * patching for the fast-path hashtable.S code)
+	 */
+	htab_finish_init();
 
 	printk("Starting Linux PPC64 %s\n", UTS_RELEASE);
 
@@ -204,12 +234,16 @@ void setup_system(unsigned long r3, unsi
 	printk("htab_data.num_ptegs           = 0x%lx\n", htab_data.htab_num_ptegs);
 	printk("-----------------------------------------------------\n");
 
-	if (systemcfg->platform & PLATFORM_PSERIES) {
-		finish_device_tree();
-		chrp_init(r3, r4, r5, r6, r7);
+	mm_init_ppc64();
+
+#if defined(CONFIG_SMP) && defined(CONFIG_PPC_PSERIES)
+	if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) {
+		vpa_init(boot_cpuid);
 	}
+#endif
 
-	mm_init_ppc64();
+	/* Select the correct idle loop for the platform. */
+	idle_setup();
 
 	switch (systemcfg->platform) {
 #ifdef CONFIG_PPC_ISERIES
@@ -277,36 +311,19 @@ static int show_cpuinfo(struct seq_file 
 	seq_printf(m, "processor\t: %lu\n", cpu_id);
 	seq_printf(m, "cpu\t\t: ");
 
-	switch (PVR_VER(pvr)) {
-	case PV_NORTHSTAR:
-		seq_printf(m, "RS64-II (northstar)\n");
-		break;
-	case PV_PULSAR:
-		seq_printf(m, "RS64-III (pulsar)\n");
-		break;
-	case PV_POWER4:
-		seq_printf(m, "POWER4 (gp)\n");
-		break;
-	case PV_ICESTAR:
-		seq_printf(m, "RS64-III (icestar)\n");
-		break;
-	case PV_SSTAR:
-		seq_printf(m, "RS64-IV (sstar)\n");
-		break;
-	case PV_POWER4p:
-		seq_printf(m, "POWER4+ (gq)\n");
-		break;
-	case PV_630:
-		seq_printf(m, "POWER3 (630)\n");
-		break;
-	case PV_630p:
-		seq_printf(m, "POWER3 (630+)\n");
-		break;
-	default:
-		seq_printf(m, "Unknown (%08x)\n", pvr);
-		break;
-	}
+	if (cur_cpu_spec->pvr_mask)
+		seq_printf(m, "%s", cur_cpu_spec->cpu_name);
+	else
+		seq_printf(m, "unknown (%08x)", pvr);
+
+#ifdef CONFIG_ALTIVEC
+	if (cur_cpu_spec->cpu_features & CPU_FTR_ALTIVEC)
+		seq_printf(m, ", altivec supported");
+#endif /* CONFIG_ALTIVEC */
 
+	seq_printf(m, "\n");
+
+#ifdef CONFIG_PPC_PSERIES
 	/*
 	 * Assume here that all clock rates are the same in a
 	 * smp system.  -- Cort
@@ -315,15 +332,17 @@ static int show_cpuinfo(struct seq_file 
 		struct device_node *cpu_node;
 		int *fp;
 
-		cpu_node = find_type_devices("cpu");
+		cpu_node = of_find_node_by_type(NULL, "cpu");
 		if (cpu_node) {
 			fp = (int *) get_property(cpu_node, "clock-frequency",
 						  NULL);
 			if (fp)
 				seq_printf(m, "clock\t\t: %dMHz\n",
 					   *fp / 1000000);
+			of_node_put(cpu_node);
 		}
 	}
+#endif
 
 	if (ppc_md.setup_residual != NULL)
 		ppc_md.setup_residual(m, cpu_id);
@@ -353,13 +372,11 @@ struct seq_operations cpuinfo_op = {
 };
 
 /*
- * Fetch the cmd_line from open firmware. */
+ * Fetch the cmd_line from open firmware. 
+ */
 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
 	if ((initrd_start == 0) && r3 && r4 && r4 != 0xdeadbeef) {
 		initrd_start = (r3 >= KERNELBASE) ? r3 : (unsigned long)__va(r3);
@@ -375,12 +392,20 @@ void parse_cmd_line(unsigned long r3, un
 	strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line));
 #endif /* CONFIG_CMDLINE */
 
-	chosen = find_devices("chosen");
+#ifdef CONFIG_PPC_PSERIES
+	{
+	struct device_node *chosen;
+
+	chosen = of_find_node_by_name(NULL, "chosen");
 	if (chosen != NULL) {
+		char *p;
 		p = get_property(chosen, "bootargs", NULL);
 		if (p != NULL && p[0] != 0)
 			strlcpy(cmd_line, p, sizeof(cmd_line));
+		of_node_put(chosen);
 	}
+	}
+#endif
 
 	/* Look for mem= option on command line */
 	if (strstr(cmd_line, "mem=")) {
@@ -406,28 +431,7 @@ void parse_cmd_line(unsigned long r3, un
 }
 
 
-char *bi_tag2str(unsigned long tag)
-{
-	switch (tag) {
-	case BI_FIRST:
-		return "BI_FIRST";
-	case BI_LAST:
-		return "BI_LAST";
-	case BI_CMD_LINE:
-		return "BI_CMD_LINE";
-	case BI_BOOTLOADER_ID:
-		return "BI_BOOTLOADER_ID";
-	case BI_INITRD:
-		return "BI_INITRD";
-	case BI_SYSMAP:
-		return "BI_SYSMAP";
-	case BI_MACHTYPE:
-		return "BI_MACHTYPE";
-	default:
-		return "BI_UNKNOWN";
-	}
-}
-
+#ifdef CONFIG_PPC_PSERIES
 int parse_bootinfo(void)
 {
 	struct bi_record *rec;
@@ -445,8 +449,7 @@ int parse_bootinfo(void)
 			memcpy(cmd_line, (void *)rec->data, rec->size);
 			break;
 		case BI_SYSMAP:
-			sysmap = (char *)((rec->data[0] >= (KERNELBASE))
-					? rec->data[0] : (unsigned long)__va(rec->data[0]));
+			sysmap = __va(rec->data[0]);
 			sysmap_size = rec->data[1];
 			break;
 #ifdef CONFIG_BLK_DEV_INITRD
@@ -462,6 +465,7 @@ int parse_bootinfo(void)
 
 	return 0;
 }
+#endif
 
 int __init ppc_init(void)
 {
@@ -486,7 +490,6 @@ void __init ppc64_calibrate_delay(void)
 }	
 
 extern void (*calibrate_delay)(void);
-extern void sort_exception_table(void);
 
 /*
  * Called into from start_kernel, after lock_kernel has been called.
@@ -534,7 +537,6 @@ void __init setup_arch(char **cmdline_p)
 	ppc_md.setup_arch();
 
 	paging_init();
-	sort_exception_table();
 	ppc64_boot_msg(0x15, "Setup Done");
 }
 
diff -puN arch/ppc64/kernel/signal32.c~linus arch/ppc64/kernel/signal32.c
--- 25/arch/ppc64/kernel/signal32.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/signal32.c	2004-01-19 22:17:21.000000000 -0800
@@ -32,71 +32,207 @@
 #define DEBUG_SIG 0
 
 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
-/* 
- * These are the flags in the MSR that the user is allowed to change
- * by modifying the saved value of the MSR on the stack.  SE and BE
- * should not be in this list since gdb may want to change these.  I.e,
- * you should be able to step out of a signal handler to see what
- * instruction executes next after the signal handler completes.
- * Alternately, if you stepped into a signal handler, you should be
- * able to continue 'til the next breakpoint from within the signal
- * handler, even if the handler returns.
- */
-#if 0
-#define MSR_USERCHANGE	(MSR_FE0 | MSR_FE1)
-#else
+
+#define GP_REGS_SIZE32	min(sizeof(elf_gregset_t32), sizeof(struct pt_regs32))
+
 /*
- * glibc tries to set FE0/FE1 via a signal handler. Since it only ever
- * sets both bits and this is the default setting we now disable this
- * behaviour. This is done to insure the new prctl which alters FE0/FE1 does
- * not get overriden by glibc. Setting and clearing FE0/FE1 via signal
- * handler has always been bogus since load_up_fpu used to set FE0/FE1
- * unconditionally.
+ * When we have signals to deliver, we set up on the
+ * user stack, going down from the original stack pointer:
+ *	a sigregs32 struct
+ *	a sigcontext32 struct
+ *	a gap of __SIGNAL_FRAMESIZE32 bytes
+ *
+ * Each of these things must be a multiple of 16 bytes in size.
+ *
  */
-#define MSR_USERCHANGE	0
-#endif
-
 struct sigregs32 {
-	/*
-	 * the gp_regs array is 32 bit representation of the pt_regs
-	 * structure that was stored on the kernel stack during the
-	 * system call that was interrupted for the signal.
-	 *
-	 * Note that the entire pt_regs regs structure will fit in
-	 * the gp_regs structure because the ELF_NREG value is 48 for
-	 * PPC and the pt_regs structure contains 44 registers
-	 */
-	elf_gregset_t32	gp_regs;
-	double		fp_regs[ELF_NFPREG];
-	unsigned int	tramp[2];
+	struct mcontext32	mctx;		/* all the register values */
 	/*
 	 * Programs using the rs6000/xcoff abi can save up to 19 gp
 	 * regs and 18 fp regs below sp before decrementing it.
 	 */
-	int		abigap[56];
+	int			abigap[56];
 };
 
+/* We use the mc_pad field for the signal return trampoline. */
+#define tramp	mc_pad
 
-struct rt_sigframe_32 {
-	/*
-	 * Unused space at start of frame to allow for storing of
-	 * stack pointers
-	 */
-	unsigned long _unused;
+/*
+ *  When we have rt signals to deliver, we set up on the
+ *  user stack, going down from the original stack pointer:
+ *	one rt_sigframe32 struct (siginfo + ucontext + ABI gap)
+ *	a gap of __SIGNAL_FRAMESIZE32+16 bytes
+ *  (the +16 is to get the siginfo and ucontext32 in the same
+ *  positions as in older kernels).
+ *
+ *  Each of these things must be a multiple of 16 bytes in size.
+ *
+ */
+struct rt_sigframe32 {
+	struct compat_siginfo	info;
+	struct ucontext32	uc;
 	/*
-	 * This is a 32 bit pointer in user address space 
-	 * it is a pointer to the siginfo stucture in the rt stack frame 
+	 * Programs using the rs6000/xcoff abi can save up to 19 gp
+	 * regs and 18 fp regs below sp before decrementing it.
 	 */
-	u32 pinfo;
+	int			abigap[56];
+};
+
+
+/*
+ * Common utility functions used by signal and context support
+ *
+ */
+
+/*
+ * Restore the user process's signal mask
+ * (implemented in signal.c)
+ */
+extern void restore_sigmask(sigset_t *set);
+
+/*
+ * Functions for flipping sigsets (thanks to brain dead generic
+ * implementation that makes things simple for little endian only
+ */
+static inline void compat_from_sigset(compat_sigset_t *compat, sigset_t *set)
+{
+	switch (_NSIG_WORDS) {
+	case 4: compat->sig[5] = set->sig[3] & 0xffffffffull ;
+		compat->sig[7] = set->sig[3] >> 32; 
+	case 3: compat->sig[4] = set->sig[2] & 0xffffffffull ;
+		compat->sig[5] = set->sig[2] >> 32; 
+	case 2: compat->sig[2] = set->sig[1] & 0xffffffffull ;
+		compat->sig[3] = set->sig[1] >> 32; 
+	case 1: compat->sig[0] = set->sig[0] & 0xffffffffull ;
+		compat->sig[1] = set->sig[0] >> 32; 
+	}
+}
+
+static inline void sigset_from_compat(sigset_t *set, compat_sigset_t *compat)
+{
+	switch (_NSIG_WORDS) {
+	case 4: set->sig[3] = compat->sig[6] | (((long)compat->sig[7]) << 32);
+	case 3: set->sig[2] = compat->sig[4] | (((long)compat->sig[5]) << 32);
+	case 2: set->sig[1] = compat->sig[2] | (((long)compat->sig[3]) << 32);
+	case 1: set->sig[0] = compat->sig[0] | (((long)compat->sig[1]) << 32);
+	}
+}
+
+
+/*
+ * Save the current user registers on the user stack.
+ * We only save the altivec registers if the process has used
+ * altivec instructions at some point.
+ */
+static int save_user_regs(struct pt_regs *regs, struct mcontext32 *frame, int sigret)
+{
+	elf_greg_t64 *gregs = (elf_greg_t64 *)regs;
+	int i, err = 0;
+	
+	/* Make sure floating point registers are stored in regs */ 
+	if (regs->msr & MSR_FP)
+		giveup_fpu(current);
+	
+	/* save general and floating-point registers */
+	for (i = 0; i <= PT_RESULT; i ++)
+		err |= __put_user((unsigned int)gregs[i], &frame->mc_gregs[i]);
+	err |= __copy_to_user(&frame->mc_fregs, current->thread.fpr,
+			      ELF_NFPREG * sizeof(double));
+	if (err)
+		return 1;
+
+	current->thread.fpscr = 0;	/* turn off all fp exceptions */
+
+#ifdef CONFIG_ALTIVEC
+	/* save altivec registers */
+	if (current->thread.used_vr) {
+		if (regs->msr & MSR_VEC)
+			giveup_altivec(current);
+		if (__copy_to_user(&frame->mc_vregs, current->thread.vr,
+				   ELF_NVRREG32 * sizeof(vector128)))
+			return 1;
+		/* set MSR_VEC in the saved MSR value to indicate that
+		   frame->mc_vregs contains valid data */
+		if (__put_user(regs->msr | MSR_VEC, &frame->mc_gregs[PT_MSR]))
+			return 1;
+	}
+	/* else assert((regs->msr & MSR_VEC) == 0) */
+
+	/* We always copy to/from vrsave, it's 0 if we don't have or don't
+	 * use altivec. Since VSCR only contains 32 bits saved in the least
+	 * significant bits of a vector, we "cheat" and stuff VRSAVE in the
+	 * most significant bits of that same vector. --BenH
+	 */
+	if (__put_user(current->thread.vrsave, (u32 *)&frame->mc_vregs[32]))
+		return 1;
+#endif /* CONFIG_ALTIVEC */
+
+	if (sigret) {
+		/* Set up the sigreturn trampoline: li r0,sigret; sc */
+		if (__put_user(0x38000000UL + sigret, &frame->tramp[0])
+		    || __put_user(0x44000002UL, &frame->tramp[1]))
+			return 1;
+		flush_icache_range((unsigned long) &frame->tramp[0],
+				   (unsigned long) &frame->tramp[2]);
+	}
+
+	return 0;
+}
+
+/*
+ * Restore the current user register values from the user stack,
+ * (except for MSR).
+ */
+static int restore_user_regs(struct pt_regs *regs, struct mcontext32 __user *sr, int sig)
+{
+	elf_greg_t64 *gregs = (elf_greg_t64 *)regs;
+	int i, err = 0;
+	unsigned int save_r2;
+#ifdef CONFIG_ALTIVEC
+	unsigned long msr;
+#endif
+
 	/*
-	 * This is a 32 bit pointer in user address space
-	 * it is a pointer to the user context in the rt stack frame
+	 * restore general registers but not including MSR. Also take
+	 * care of keeping r2 (TLS) intact if not a signal
 	 */
-	u32 puc;
-	struct siginfo32  info;
-	struct ucontext32 uc;
-};
+	if (!sig)
+		save_r2 = (unsigned int)regs->gpr[2];
+	for (i = 0; i < PT_MSR; i ++)
+		err |= __get_user(gregs[i], &sr->mc_gregs[i]);
+	for (i ++; i <= PT_RESULT; i ++)
+		err |= __get_user(gregs[i], &sr->mc_gregs[i]);
+	if (!sig)
+		regs->gpr[2] = (unsigned long) save_r2;
+	if (err)
+		return 1;
+
+	/* force the process to reload the FP registers from
+	   current->thread when it next does FP instructions */
+	regs->msr &= ~(MSR_FP | MSR_FE0 | MSR_FE1);
+	if (__copy_from_user(current->thread.fpr, &sr->mc_fregs,
+			     sizeof(sr->mc_fregs)))
+		return 1;
+
+#ifdef CONFIG_ALTIVEC
+	/* force the process to reload the altivec registers from
+	   current->thread when it next does altivec instructions */
+	regs->msr &= ~MSR_VEC;
+	if (!__get_user(msr, &sr->mc_gregs[PT_MSR]) && (msr & MSR_VEC) != 0) {
+		/* restore altivec registers from the stack */
+		if (__copy_from_user(current->thread.vr, &sr->mc_vregs,
+				     sizeof(sr->mc_vregs)))
+			return 1;
+	} else if (current->thread.used_vr)
+		memset(&current->thread.vr, 0, ELF_NVRREG32 * sizeof(vector128));
+
+	/* Always get VRSAVE back */
+	if (__get_user(current->thread.vrsave, (u32 *)&sr->mc_vregs[32]))
+		return 1;
+#endif /* CONFIG_ALTIVEC */
 
+	return 0;
+}
 
 
 /*
@@ -181,209 +317,6 @@ long sys32_sigaction(int sig, struct old
 }
 
 
-/*
- * When we have signals to deliver, we set up on the
- * user stack, going down from the original stack pointer:
- *	a sigregs struct
- *	one or more sigcontext structs
- *	a gap of __SIGNAL_FRAMESIZE32 bytes
- *
- * Each of these things must be a multiple of 16 bytes in size.
- *
- */
-
-
-/*
- * Do a signal return; undo the signal stack.
- */
-long sys32_sigreturn(unsigned long r3, unsigned long r4, unsigned long r5,
-		     unsigned long r6, unsigned long r7, unsigned long r8,
-		     struct pt_regs *regs)
-{
-	struct sigcontext32 *sc, sigctx;
-	struct sigregs32 *sr;
-	int ret;
-	elf_gregset_t32 saved_regs;  /* an array of ELF_NGREG unsigned ints (32 bits) */
-	sigset_t set;
-	int i;
-
-	sc = (struct sigcontext32 *)(regs->gpr[1] + __SIGNAL_FRAMESIZE32);
-	if (copy_from_user(&sigctx, sc, sizeof(sigctx)))
-		goto badframe;
-
-	/*
-	 * Note that PPC32 puts the upper 32 bits of the sigmask in the
-	 * unused part of the signal stackframe
-	 */
-	set.sig[0] = sigctx.oldmask + ((long)(sigctx._unused[3]) << 32);
-	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
-	if (regs->msr & MSR_FP )
-		giveup_fpu(current);
-	/* Last stacked signal - restore registers */
-	sr = (struct sigregs32*)(u64)sigctx.regs;
-	/*
-	 * copy the 32 bit register values off the user stack
-	 * into the 32 bit register area
-	 */
-	if (copy_from_user(saved_regs, &sr->gp_regs, sizeof(sr->gp_regs)))
-		goto badframe;
-	/*
-	 * The saved reg structure in the frame is an elf_grepset_t32,
-	 * it is a 32 bit register save of the registers in the
-	 * pt_regs structure that was stored on the kernel stack
-	 * during the system call when the system call was interrupted
-	 * for the signal. Only 32 bits are saved because the
-	 * sigcontext contains a pointer to the regs and the sig
-	 * context address is passed as a pointer to the signal
-	 * handler.  
-	 *
-	 * The entries in the elf_grepset have the same index as the
-	 * elements in the pt_regs structure.
-	 */
-	saved_regs[PT_MSR] = (regs->msr & ~MSR_USERCHANGE)
-		| (saved_regs[PT_MSR] & MSR_USERCHANGE);
-	/*
-	 * Register 2 is the kernel toc - should be reset on
-	 * any calls into the kernel 
-	 */
-	for (i = 0; i < 32; i++)
-		regs->gpr[i] = (u64)(saved_regs[i]) & 0xFFFFFFFF;
-
-	/*
-	 *  restore the non gpr registers 
-	 */
-	regs->msr = (u64)(saved_regs[PT_MSR]) & 0xFFFFFFFF;
-	/*
-	 * Insure that the interrupt mode is 64 bit, during 32 bit
-	 * execution. (This is necessary because we only saved
-	 * lower 32 bits of msr.)
-	 */
-	regs->msr = regs->msr | MSR_ISF;  /* When this thread is interrupted it should run in 64 bit mode. */
-
-	regs->nip = (u64)(saved_regs[PT_NIP]) & 0xFFFFFFFF;
-	regs->orig_gpr3 = (u64)(saved_regs[PT_ORIG_R3]) & 0xFFFFFFFF; 
-	regs->ctr = (u64)(saved_regs[PT_CTR]) & 0xFFFFFFFF; 
-	regs->link = (u64)(saved_regs[PT_LNK]) & 0xFFFFFFFF; 
-	regs->xer = (u64)(saved_regs[PT_XER]) & 0xFFFFFFFF; 
-	regs->ccr = (u64)(saved_regs[PT_CCR]) & 0xFFFFFFFF;
-	/* regs->softe is left unchanged (like the MSR.EE bit) */
-	/******************************************************/
-	/* the DAR and the DSISR are only relevant during a   */
-	/*   data or instruction storage interrupt. The value */
-	/*   will be set to zero.                             */
-	/******************************************************/
-	regs->dar = 0; 
-	regs->dsisr = 0;
-	regs->result = (u64)(saved_regs[PT_RESULT]) & 0xFFFFFFFF;
-
-	if (copy_from_user(current->thread.fpr, &sr->fp_regs,
-			   sizeof(sr->fp_regs)))
-		goto badframe;
-
-	ret = regs->result;
-	return ret;
-
-badframe:
-	do_exit(SIGSEGV);
-}	
-
-/*
- * Set up a signal frame.
- */
-static void setup_frame32(struct pt_regs *regs, struct sigregs32 *frame,
-            unsigned int newsp)
-{
-	struct sigcontext32 *sc = (struct sigcontext32 *)(u64)newsp;
-	int i;
-
-	/* Always make any pending restarted system calls return -EINTR */
-	current_thread_info()->restart_block.fn = do_no_restart_syscall;
-
-	if (verify_area(VERIFY_WRITE, frame, sizeof(*frame)))
-		goto badframe;
-	if (regs->msr & MSR_FP)
-		giveup_fpu(current);
-
-	/*
-	 * Copy the register contents for the pt_regs structure on the
-	 *   kernel stack to the elf_gregset_t32 structure on the user
-	 *   stack. This is a copy of 64 bit register values to 32 bit
-	 *   register values. The high order 32 bits of the 64 bit
-	 *   registers are not needed since a 32 bit application is
-	 *   running and the saved registers are the contents of the
-	 *   user registers at the time of a system call.
-	 * 
-	 * The values saved on the user stack will be restored into
-	 *  the registers during the signal return processing
-	 */
-	for (i = 0; i < 32; i++) {
-		if (__put_user((u32)regs->gpr[i], &frame->gp_regs[i]))
-			goto badframe;
-	}
-
-	/*
-	 * Copy the non gpr registers to the user stack
-	 */
-	if (__put_user((u32)regs->gpr[PT_NIP], &frame->gp_regs[PT_NIP])
-	    || __put_user((u32)regs->gpr[PT_MSR], &frame->gp_regs[PT_MSR])
-	    || __put_user((u32)regs->gpr[PT_ORIG_R3], &frame->gp_regs[PT_ORIG_R3])
-	    || __put_user((u32)regs->gpr[PT_CTR], &frame->gp_regs[PT_CTR])
-	    || __put_user((u32)regs->gpr[PT_LNK], &frame->gp_regs[PT_LNK])
-	    || __put_user((u32)regs->gpr[PT_XER], &frame->gp_regs[PT_XER])
-	    || __put_user((u32)regs->gpr[PT_CCR], &frame->gp_regs[PT_CCR])
-#if 0
-	    || __put_user((u32)regs->gpr[PT_MQ], &frame->gp_regs[PT_MQ])
-#endif
-	    || __put_user((u32)regs->gpr[PT_RESULT], &frame->gp_regs[PT_RESULT]))
-		goto badframe;
-
-
-	/*
-	 * Now copy the floating point registers onto the user stack 
-	 *
-	 * Also set up so on the completion of the signal handler, the
-	 * sys_sigreturn will get control to reset the stack
-	 */
-	if (__copy_to_user(&frame->fp_regs, current->thread.fpr,
-			   ELF_NFPREG * sizeof(double))
-	    /* li r0, __NR_sigreturn */
-	    || __put_user(0x38000000U + __NR_sigreturn, &frame->tramp[0])
-	    /* sc */
-	    || __put_user(0x44000002U, &frame->tramp[1]))
-		goto badframe;
-	flush_icache_range((unsigned long)&frame->tramp[0],
-			   (unsigned long)&frame->tramp[2]);
-	current->thread.fpscr = 0;	/* turn off all fp exceptions */
-
-	newsp -= __SIGNAL_FRAMESIZE32;
-	if (put_user(regs->gpr[1], (u32*)(u64)newsp)
-	    || get_user(regs->nip, &sc->handler)
-	    || get_user(regs->gpr[3], &sc->signal))
-		goto badframe;
-
-	regs->gpr[1] = newsp & 0xFFFFFFFF;
-	/*
-	 * first parameter to the signal handler is the signal number
-	 *  - the value is in gpr3
-	 * second parameter to the signal handler is the sigcontext
-	 *   - set the value into gpr4
-	 */
-	regs->gpr[4] = (unsigned long) sc;
-	regs->link = (unsigned long) frame->tramp;
-	return;
-
-badframe:
-#if DEBUG_SIG
-	printk("badframe in setup_frame32, regs=%p frame=%p newsp=%lx\n",
-	       regs, frame, newsp);
-#endif
-	do_exit(SIGSEGV);
-}
-
 
 /*
  *  Start of RT signal support
@@ -405,115 +338,6 @@ badframe:
  *        siginfo32to64
  */
 
-/*
- * This code executes after the rt signal handler in 32 bit mode has
- * completed and returned  
- */
-long sys32_rt_sigreturn(unsigned long r3, unsigned long r4, unsigned long r5,
-			unsigned long r6, unsigned long r7, unsigned long r8,
-			struct pt_regs * regs)
-{
-	struct rt_sigframe_32 *rt_sf;
-	struct sigcontext32 sigctx;
-	struct sigregs32 *sr;
-	int ret;
-	elf_gregset_t32 saved_regs;   /* an array of 32 bit register values */
-	sigset_t set; 
-	stack_t st;
-	int i;
-	mm_segment_t old_fs;
-
-	/* Always make any pending restarted system calls return -EINTR */
-	current_thread_info()->restart_block.fn = do_no_restart_syscall;
-
-	/* Adjust the inputted reg1 to point to the first rt signal frame */
-	rt_sf = (struct rt_sigframe_32 *)(regs->gpr[1] + __SIGNAL_FRAMESIZE32);
-	/* Copy the information from the user stack  */
-	if (copy_from_user(&sigctx, &rt_sf->uc.uc_mcontext, sizeof(sigctx))
-	    || copy_from_user(&set, &rt_sf->uc.uc_sigmask, sizeof(set))
-	    || copy_from_user(&st,&rt_sf->uc.uc_stack, sizeof(st)))
-		goto badframe;
-
-	/*
-	 * Unblock the signal that was processed 
-	 *   After a signal handler runs - 
-	 *     if the signal is blockable - the signal will be unblocked  
-	 *       (sigkill and sigstop are not blockable)
-	 */
-	sigdelsetmask(&set, ~_BLOCKABLE); 
-	/* update the current based on the sigmask found in the rt_stackframe */
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
-
-	/* If currently owning the floating point - give them up */
-	if (regs->msr & MSR_FP)
-		giveup_fpu(current);
-	/*
-	 * Set to point to the next rt_sigframe - this is used to
-	 * determine whether this is the last signal to process
-	 */
-	sr = (struct sigregs32 *)(u64)sigctx.regs;
-	if (copy_from_user(saved_regs, &sr->gp_regs, sizeof(sr->gp_regs))) 
-		goto badframe;
-	/*
-	 * The saved reg structure in the frame is an elf_grepset_t32,
-	 * it is a 32 bit register save of the registers in the
-	 * pt_regs structure that was stored on the kernel stack
-	 * during the system call when the system call was interrupted
-	 * for the signal. Only 32 bits are saved because the
-	 * sigcontext contains a pointer to the regs and the sig
-	 * context address is passed as a pointer to the signal handler
-	 *
-	 * The entries in the elf_grepset have the same index as
-	 * the elements in the pt_regs structure.
-	 */
-	saved_regs[PT_MSR] = (regs->msr & ~MSR_USERCHANGE)
-		| (saved_regs[PT_MSR] & MSR_USERCHANGE);
-	/*
-	 * Register 2 is the kernel toc - should be reset on any
-	 * calls into the kernel
-	 */
-	for (i = 0; i < 32; i++)
-		regs->gpr[i] = (u64)(saved_regs[i]) & 0xFFFFFFFF;
-	/*
-	 * restore the non gpr registers
-	 */
-	regs->msr = (u64)(saved_regs[PT_MSR]) & 0xFFFFFFFF;
-	regs->nip = (u64)(saved_regs[PT_NIP]) & 0xFFFFFFFF;
-	regs->orig_gpr3 = (u64)(saved_regs[PT_ORIG_R3]) & 0xFFFFFFFF; 
-	regs->ctr = (u64)(saved_regs[PT_CTR]) & 0xFFFFFFFF; 
-	regs->link = (u64)(saved_regs[PT_LNK]) & 0xFFFFFFFF; 
-	regs->xer = (u64)(saved_regs[PT_XER]) & 0xFFFFFFFF; 
-	regs->ccr = (u64)(saved_regs[PT_CCR]) & 0xFFFFFFFF;
-	/* regs->softe is left unchanged (like MSR.EE) */
-	/*
-	 * the DAR and the DSISR are only relevant during a
-	 *   data or instruction storage interrupt. The value
-	 *   will be set to zero.
-	 */
-	regs->dar = 0; 
-	regs->dsisr = 0;
-	regs->result = (u64)(saved_regs[PT_RESULT]) & 0xFFFFFFFF;
-	if (copy_from_user(current->thread.fpr, &sr->fp_regs,
-			   sizeof(sr->fp_regs)))
-		goto badframe;
-	/* This function sets back the stack flags into
-	   the current task structure.  */
-	old_fs = get_fs();
-	set_fs(KERNEL_DS);
-	do_sigaltstack(&st, NULL, regs->gpr[1]);
-	set_fs(old_fs);
-
-	ret = regs->result;
-	return ret;
-
- badframe:
-	do_exit(SIGSEGV);     
-}
-
-
 
 long sys32_rt_sigaction(int sig, const struct sigaction32 *act,
 		struct sigaction32 *oact, size_t sigsetsize)
@@ -530,16 +354,7 @@ long sys32_rt_sigaction(int sig, const s
 		ret = get_user((long)new_ka.sa.sa_handler, &act->sa_handler);
 		ret |= __copy_from_user(&set32, &act->sa_mask,
 					sizeof(compat_sigset_t));
-		switch (_NSIG_WORDS) {
-		case 4: new_ka.sa.sa_mask.sig[3] = set32.sig[6]
-				| (((long)set32.sig[7]) << 32);
-		case 3: new_ka.sa.sa_mask.sig[2] = set32.sig[4]
-				| (((long)set32.sig[5]) << 32);
-		case 2: new_ka.sa.sa_mask.sig[1] = set32.sig[2]
-				| (((long)set32.sig[3]) << 32);
-		case 1: new_ka.sa.sa_mask.sig[0] = set32.sig[0]
-				| (((long)set32.sig[1]) << 32);
-		}
+		sigset_from_compat(&new_ka.sa.sa_mask, &set32);
 		ret |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
 		if (ret)
 			return -EFAULT;
@@ -547,20 +362,7 @@ long sys32_rt_sigaction(int sig, const s
 
 	ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
 	if (!ret && oact) {
-		switch (_NSIG_WORDS) {
-		case 4:
-			set32.sig[7] = (old_ka.sa.sa_mask.sig[3] >> 32);
-			set32.sig[6] = old_ka.sa.sa_mask.sig[3];
-		case 3:
-			set32.sig[5] = (old_ka.sa.sa_mask.sig[2] >> 32);
-			set32.sig[4] = old_ka.sa.sa_mask.sig[2];
-		case 2:
-			set32.sig[3] = (old_ka.sa.sa_mask.sig[1] >> 32);
-			set32.sig[2] = old_ka.sa.sa_mask.sig[1];
-		case 1:
-			set32.sig[1] = (old_ka.sa.sa_mask.sig[0] >> 32);
-			set32.sig[0] = old_ka.sa.sa_mask.sig[0];
-		}
+		compat_from_sigset(&set32, &old_ka.sa.sa_mask);
 		ret = put_user((long)old_ka.sa.sa_handler, &oact->sa_handler);
 		ret |= __copy_to_user(&oact->sa_mask, &set32,
 				      sizeof(compat_sigset_t));
@@ -586,14 +388,8 @@ long sys32_rt_sigprocmask(u32 how, compa
 
 	if (set) {
 		if (copy_from_user (&s32, set, sizeof(compat_sigset_t)))
-			return -EFAULT;
-    
-		switch (_NSIG_WORDS) {
-		case 4: s.sig[3] = s32.sig[6] | (((long)s32.sig[7]) << 32);
-		case 3: s.sig[2] = s32.sig[4] | (((long)s32.sig[5]) << 32);
-		case 2: s.sig[1] = s32.sig[2] | (((long)s32.sig[3]) << 32);
-		case 1: s.sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32);
-		}
+			return -EFAULT;    
+		sigset_from_compat(&s, &s32);
 	}
 	
 	set_fs(KERNEL_DS);
@@ -603,12 +399,7 @@ long sys32_rt_sigprocmask(u32 how, compa
 	if (ret)
 		return ret;
 	if (oset) {
-		switch (_NSIG_WORDS) {
-		case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3];
-		case 3: s32.sig[5] = (s.sig[2] >> 32); s32.sig[4] = s.sig[2];
-		case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1];
-		case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0];
-		}
+		compat_from_sigset(&s32, &s);
 		if (copy_to_user (oset, &s32, sizeof(compat_sigset_t)))
 			return -EFAULT;
 	}
@@ -626,12 +417,7 @@ long sys32_rt_sigpending(compat_sigset_t
 	ret = sys_rt_sigpending(&s, sigsetsize);
 	set_fs(old_fs);
 	if (!ret) {
-		switch (_NSIG_WORDS) {
-		case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3];
-		case 3: s32.sig[5] = (s.sig[2] >> 32); s32.sig[4] = s.sig[2];
-		case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1];
-		case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0];
-		}
+		compat_from_sigset(&s32, &s);
 		if (copy_to_user (set, &s32, sizeof(compat_sigset_t)))
 			return -EFAULT;
 	}
@@ -639,7 +425,7 @@ long sys32_rt_sigpending(compat_sigset_t
 }
 
 
-static int copy_siginfo_to_user32(siginfo_t32 *d, siginfo_t *s)
+static int copy_siginfo_to_user32(compat_siginfo_t *d, siginfo_t *s)
 {
 	int err;
 
@@ -681,7 +467,7 @@ static int copy_siginfo_to_user32(siginf
 	return err;
 }
 
-long sys32_rt_sigtimedwait(compat_sigset_t *uthese, siginfo_t32 *uinfo,
+long sys32_rt_sigtimedwait(compat_sigset_t *uthese, compat_siginfo_t *uinfo,
 		struct compat_timespec *uts, compat_size_t sigsetsize)
 {
 	sigset_t s;
@@ -693,12 +479,7 @@ long sys32_rt_sigtimedwait(compat_sigset
 
 	if (copy_from_user(&s32, uthese, sizeof(compat_sigset_t)))
 		return -EFAULT;
-	switch (_NSIG_WORDS) {
-	case 4: s.sig[3] = s32.sig[6] | (((long)s32.sig[7]) << 32);
-	case 3: s.sig[2] = s32.sig[4] | (((long)s32.sig[5]) << 32);
-	case 2: s.sig[1] = s32.sig[2] | (((long)s32.sig[3]) << 32);
-	case 1: s.sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32);
-	}
+	sigset_from_compat(&s, &s32);
 	if (uts && get_compat_timespec(&t, uts))
 		return -EFAULT;
 	set_fs(KERNEL_DS);
@@ -714,7 +495,7 @@ long sys32_rt_sigtimedwait(compat_sigset
 
 
 
-static siginfo_t * siginfo32to64(siginfo_t *d, siginfo_t32 *s)
+static siginfo_t * siginfo32to64(siginfo_t *d, compat_siginfo_t *s)
 {
 	d->si_signo = s->si_signo;
 	d->si_errno = s->si_errno;
@@ -758,14 +539,14 @@ static siginfo_t * siginfo32to64(siginfo
  * (msr in 32-bit mode) and the register representation of a signed int
  * (msr in 64-bit mode) is performed.
  */
-long sys32_rt_sigqueueinfo(u32 pid, u32 sig, siginfo_t32 *uinfo)
+long sys32_rt_sigqueueinfo(u32 pid, u32 sig, compat_siginfo_t *uinfo)
 {
 	siginfo_t info;
-	siginfo_t32 info32;
+	compat_siginfo_t info32;
 	int ret;
 	mm_segment_t old_fs = get_fs();
 	
-	if (copy_from_user (&info32, uinfo, sizeof(siginfo_t32)))
+	if (copy_from_user (&info32, uinfo, sizeof(compat_siginfo_t)))
 		return -EFAULT;
     	/* XXX: Is this correct? */
 	siginfo32to64(&info, &info32);
@@ -793,15 +574,9 @@ int sys32_rt_sigsuspend(compat_sigset_t*
 	 * Swap the 2 words of the 64-bit sigset_t (they are stored
 	 * in the "wrong" endian in 32-bit user storage).
 	 */
-	switch (_NSIG_WORDS) {
-	case 4: newset.sig[3] = s32.sig[6] | (((long)s32.sig[7]) << 32);
-	case 3: newset.sig[2] = s32.sig[4] | (((long)s32.sig[5]) << 32);
-	case 2: newset.sig[1] = s32.sig[2] | (((long)s32.sig[3]) << 32);
-	case 1: newset.sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32);
-	}
+	sigset_from_compat(&newset, &s32);
 
 	sigdelsetmask(&newset, ~_BLOCKABLE);
-
 	spin_lock_irq(&current->sighand->siglock);
 	saveset = current->blocked;
 	current->blocked = newset;
@@ -827,237 +602,324 @@ int sys32_rt_sigsuspend(compat_sigset_t*
 	}
 }
 
-
 /*
- * Set up a rt signal frame.
+ *  Start Alternate signal stack support
+ *
+ *  System Calls
+ *       sigaltatck               sys32_sigaltstack
  */
-static void setup_rt_frame32(struct pt_regs *regs, struct sigregs32 *frame,
-            unsigned int newsp)
+
+int sys32_sigaltstack(u32 newstack, u32 oldstack, int r5,
+		      int r6, int r7, int r8, struct pt_regs *regs)
 {
-	unsigned int copyreg4, copyreg5;
-	struct rt_sigframe_32 * rt_sf = (struct rt_sigframe_32 *) (u64)newsp;
-	int i;
-  
-	if (verify_area(VERIFY_WRITE, frame, sizeof(*frame)))
-		goto badframe;
-	if (regs->msr & MSR_FP)
-		giveup_fpu(current);
+	stack_t uss, uoss;
+	int ret;
+	mm_segment_t old_fs;
+	unsigned long sp;
 
 	/*
-	 * Copy the register contents for the pt_regs structure on the
-	 *   kernel stack to the elf_gregset_t32 structure on the user
-	 *   stack. This is a copy of 64 bit register values to 32 bit
-	 *   register values. The high order 32 bits of the 64 bit
-	 *   registers are not needed since a 32 bit application is
-	 *   running and the saved registers are the contents of the
-	 *   user registers at the time of a system call.
-	 *
-	 * The values saved on the user stack will be restored into
-	 *  the registers during the signal return processing
+	 * set sp to the user stack on entry to the system call
+	 * the system call router sets R9 to the saved registers
 	 */
-	for (i = 0; i < 32; i++) {
-		if (__put_user((u32)regs->gpr[i], &frame->gp_regs[i]))
-			goto badframe;
-	}
+	sp = regs->gpr[1];
 
-	/*
-	 * Copy the non gpr registers to the user stack
-	 */
-	if (__put_user((u32)regs->gpr[PT_NIP], &frame->gp_regs[PT_NIP])
-	    || __put_user((u32)regs->gpr[PT_MSR], &frame->gp_regs[PT_MSR])
-	    || __put_user((u32)regs->gpr[PT_ORIG_R3], &frame->gp_regs[PT_ORIG_R3])
-	    || __put_user((u32)regs->gpr[PT_CTR], &frame->gp_regs[PT_CTR])
-	    || __put_user((u32)regs->gpr[PT_LNK], &frame->gp_regs[PT_LNK])
-	    || __put_user((u32)regs->gpr[PT_XER], &frame->gp_regs[PT_XER])
-	    || __put_user((u32)regs->gpr[PT_CCR], &frame->gp_regs[PT_CCR])
-	    || __put_user((u32)regs->gpr[PT_RESULT], &frame->gp_regs[PT_RESULT]))
-		goto badframe;
+	/* Put new stack info in local 64 bit stack struct */
+	if (newstack &&
+		(get_user((long)uss.ss_sp,
+			  &((stack_32_t *)(long)newstack)->ss_sp) ||
+		 __get_user(uss.ss_flags,
+			 &((stack_32_t *)(long)newstack)->ss_flags) ||
+		 __get_user(uss.ss_size,
+			 &((stack_32_t *)(long)newstack)->ss_size)))
+		return -EFAULT; 
 
+	old_fs = get_fs();
+	set_fs(KERNEL_DS);
+	ret = do_sigaltstack(newstack ? &uss : NULL, oldstack ? &uoss : NULL,
+			sp);
+	set_fs(old_fs);
+	/* Copy the stack information to the user output buffer */
+	if (!ret && oldstack  &&
+		(put_user((long)uoss.ss_sp,
+			  &((stack_32_t *)(long)oldstack)->ss_sp) ||
+		 __put_user(uoss.ss_flags,
+			 &((stack_32_t *)(long)oldstack)->ss_flags) ||
+		 __put_user(uoss.ss_size,
+			 &((stack_32_t *)(long)oldstack)->ss_size)))
+		return -EFAULT;
+	return ret;
+}
 
-	/*
-	 * Now copy the floating point registers onto the user stack
-	 *
-	 * Also set up so on the completion of the signal handler, the
-	 * sys_sigreturn will get control to reset the stack
-	 */
-	if (__copy_to_user(&frame->fp_regs, current->thread.fpr,
-			   ELF_NFPREG * sizeof(double))
-	    || __put_user(0x38000000U + __NR_rt_sigreturn, &frame->tramp[0])    /* li r0, __NR_rt_sigreturn */
-	    || __put_user(0x44000002U, &frame->tramp[1]))   /* sc */
+
+/*
+ * Set up a signal frame for a "real-time" signal handler
+ * (one which gets siginfo).
+ */
+static void handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
+			       siginfo_t *info, sigset_t *oldset,
+			       struct pt_regs * regs, unsigned long newsp)
+{
+	struct rt_sigframe32 __user *rt_sf;
+	struct mcontext32 __user *frame;
+	unsigned long origsp = newsp;
+	compat_sigset_t c_oldset;
+
+	/* Set up Signal Frame */
+	/* Put a Real Time Context onto stack */
+	newsp -= sizeof(*rt_sf);
+	rt_sf = (struct rt_sigframe32 __user *)newsp;
+
+	/* create a stack frame for the caller of the handler */
+	newsp -= __SIGNAL_FRAMESIZE32 + 16;
+
+	if (verify_area(VERIFY_WRITE, (void __user *)newsp, origsp - newsp))
 		goto badframe;
 
-	flush_icache_range((unsigned long) &frame->tramp[0],
-			   (unsigned long) &frame->tramp[2]);
-	current->thread.fpscr = 0;	/* turn off all fp exceptions */
+	compat_from_sigset(&c_oldset, oldset);
 
-	/*
-	 * Retrieve rt_sigframe from stack and
-	 * set up registers for signal handler
-	 */
-	newsp -= __SIGNAL_FRAMESIZE32;
-      
+	/* Put the siginfo & fill in most of the ucontext */
+	if (copy_siginfo_to_user32(&rt_sf->info, info)
+	    || __put_user(0, &rt_sf->uc.uc_flags)
+	    || __put_user(0, &rt_sf->uc.uc_link)
+	    || __put_user(current->sas_ss_sp, &rt_sf->uc.uc_stack.ss_sp)
+	    || __put_user(sas_ss_flags(regs->gpr[1]),
+			  &rt_sf->uc.uc_stack.ss_flags)
+	    || __put_user(current->sas_ss_size, &rt_sf->uc.uc_stack.ss_size)
+	    || __put_user((u32)(u64)&rt_sf->uc.uc_mcontext, &rt_sf->uc.uc_regs)
+	    || __copy_to_user(&rt_sf->uc.uc_sigmask, &c_oldset, sizeof(c_oldset)))
+		goto badframe;
 
-	if (put_user((u32)(regs->gpr[1]), (unsigned int *)(u64)newsp)
-	    || get_user(regs->nip, &rt_sf->uc.uc_mcontext.handler)
-	    || get_user(regs->gpr[3], &rt_sf->uc.uc_mcontext.signal)
-	    || get_user(copyreg4, &rt_sf->pinfo)
-	    || get_user(copyreg5, &rt_sf->puc))
+	/* Save user registers on the stack */
+	frame = &rt_sf->uc.uc_mcontext;
+	if (save_user_regs(regs, frame, __NR_rt_sigreturn))
 		goto badframe;
 
-	regs->gpr[4] = copyreg4;
-	regs->gpr[5] = copyreg5;
-	regs->gpr[1] = newsp;
+	if (put_user(regs->gpr[1], (unsigned long __user *)newsp))
+		goto badframe;
+	regs->gpr[1] = (unsigned long) newsp;
+	regs->gpr[3] = sig;
+	regs->gpr[4] = (unsigned long) &rt_sf->info;
+	regs->gpr[5] = (unsigned long) &rt_sf->uc;
 	regs->gpr[6] = (unsigned long) rt_sf;
+	regs->nip = (unsigned long) ka->sa.sa_handler;
 	regs->link = (unsigned long) frame->tramp;
+	regs->trap = 0;
 
 	return;
 
 badframe:
 #if DEBUG_SIG
-	printk("badframe in setup_frame32, regs=%p frame=%p newsp=%lx\n",
+	printk("badframe in handle_rt_signal, regs=%p frame=%p newsp=%lx\n",
 	       regs, frame, newsp);
 #endif
-	do_exit(SIGSEGV);
+	if (sig == SIGSEGV)
+		ka->sa.sa_handler = SIG_DFL;
+	force_sig(SIGSEGV, current);
 }
 
+static long do_setcontext32(struct ucontext32 __user *ucp, struct pt_regs *regs, int sig)
+{
+	compat_sigset_t c_set;
+	sigset_t set;
+	u32 mcp;
+
+	if (__copy_from_user(&c_set, &ucp->uc_sigmask, sizeof(c_set))
+	    || __get_user(mcp, &ucp->uc_regs))
+		return -EFAULT;
+	sigset_from_compat(&set, &c_set);
+	restore_sigmask(&set);
+	if (restore_user_regs(regs, (struct mcontext32 *)(u64)mcp, sig))
+		return -EFAULT;
+
+	return 0;
+}
 
 /*
- * OK, we're invoking a handler
+ * Handle {get,set,swap}_context operations for 32 bits processes
  */
-static void handle_signal32(unsigned long sig, siginfo_t *info,
-		sigset_t *oldset, struct pt_regs * regs, unsigned int *newspp,
-		unsigned int frame)
-{
-	struct sigcontext32 *sc;
-	struct rt_sigframe_32 *rt_sf;
-	struct k_sigaction *ka = &current->sighand->action[sig-1];
-
-	if (regs->trap == 0x0C00 /* System Call! */
-	    && ((int)regs->result == -ERESTARTNOHAND ||
-		(int)regs->result == -ERESTART_RESTARTBLOCK ||
-		((int)regs->result == -ERESTARTSYS &&
-		 !(ka->sa.sa_flags & SA_RESTART)))) {
-		if ((int)regs->result == -ERESTART_RESTARTBLOCK)
-			current_thread_info()->restart_block.fn
-				= do_no_restart_syscall;
-		regs->result = -EINTR;
+
+long sys32_swapcontext(struct ucontext32 __user *old_ctx,
+		       struct ucontext32 __user *new_ctx,
+		       int ctx_size, int r6, int r7, int r8, struct pt_regs *regs)
+{
+	unsigned char tmp;
+	compat_sigset_t c_set;
+
+	/* Context size is for future use. Right now, we only make sure
+	 * we are passed something we understand
+	 */
+	if (ctx_size < sizeof(struct ucontext32))
+		return -EINVAL;
+
+	if (old_ctx != NULL) {
+		compat_from_sigset(&c_set, &current->blocked);
+		if (verify_area(VERIFY_WRITE, old_ctx, sizeof(*old_ctx))
+		    || save_user_regs(regs, &old_ctx->uc_mcontext, 0)
+		    || __copy_to_user(&old_ctx->uc_sigmask, &c_set, sizeof(c_set))
+		    || __put_user((u32)(u64)&old_ctx->uc_mcontext, &old_ctx->uc_regs))
+			return -EFAULT;
 	}
+	if (new_ctx == NULL)
+		return 0;
+	if (verify_area(VERIFY_READ, new_ctx, sizeof(*new_ctx))
+	    || __get_user(tmp, (u8 *) new_ctx)
+	    || __get_user(tmp, (u8 *) (new_ctx + 1) - 1))
+		return -EFAULT;
 
 	/*
-	 * Set up the signal frame
-	 * Determine if a real time frame and a siginfo is required
+	 * If we get a fault copying the context into the kernel's
+	 * image of the user's registers, we can't just return -EFAULT
+	 * because the user's registers will be corrupted.  For instance
+	 * the NIP value may have been updated but not some of the
+	 * other registers.  Given that we have done the verify_area
+	 * and successfully read the first and last bytes of the region
+	 * above, this should only happen in an out-of-memory situation
+	 * or if another thread unmaps the region containing the context.
+	 * We kill the task with a SIGSEGV in this situation.
 	 */
-	if (ka->sa.sa_flags & SA_SIGINFO) {
-		*newspp -= sizeof(*rt_sf);
-		rt_sf = (struct rt_sigframe_32 *)(u64)(*newspp);
-		if (verify_area(VERIFY_WRITE, rt_sf, sizeof(*rt_sf)))
-			goto badframe;
-		if (__put_user((u32)(u64)ka->sa.sa_handler,
-					&rt_sf->uc.uc_mcontext.handler)
-		    || __put_user((u32)(u64)&rt_sf->info, &rt_sf->pinfo)
-		    || __put_user((u32)(u64)&rt_sf->uc, &rt_sf->puc)
-		    /*  put the siginfo on the user stack                    */
-		    || copy_siginfo_to_user32(&rt_sf->info, info)
-		    /*  set the ucontext on the user stack                   */ 
-		    || __put_user(0, &rt_sf->uc.uc_flags)
-		    || __put_user(0, &rt_sf->uc.uc_link)
-		    || __put_user(current->sas_ss_sp, &rt_sf->uc.uc_stack.ss_sp)
-		    || __put_user(sas_ss_flags(regs->gpr[1]),
-			    &rt_sf->uc.uc_stack.ss_flags)
-		    || __put_user(current->sas_ss_size,
-			    &rt_sf->uc.uc_stack.ss_size)
-		    || __copy_to_user(&rt_sf->uc.uc_sigmask,
-			    oldset, sizeof(*oldset))
-		    /* point the mcontext.regs to the pramble register frame  */
-		    || __put_user(frame, &rt_sf->uc.uc_mcontext.regs)
-		    || __put_user(sig,&rt_sf->uc.uc_mcontext.signal))
-			goto badframe; 
-	} else {
-		/* Put a sigcontext on the stack */
-		*newspp -= sizeof(*sc);
-		sc = (struct sigcontext32 *)(u64)*newspp;
-		if (verify_area(VERIFY_WRITE, sc, sizeof(*sc)))
-			goto badframe;
-		/*
-		 * Note the upper 32 bits of the signal mask are stored
-		 * in the unused part of the signal stack frame
-		 */
-		if (__put_user((u32)(u64)ka->sa.sa_handler, &sc->handler)
-		    || __put_user(oldset->sig[0], &sc->oldmask)
-		    || __put_user((oldset->sig[0] >> 32), &sc->_unused[3])
-		    || __put_user((unsigned int)frame, &sc->regs)
-		    || __put_user(sig, &sc->signal))
-			goto badframe;
-	}
+	if (do_setcontext32(new_ctx, regs, 0))
+		do_exit(SIGSEGV);
 
-	if (ka->sa.sa_flags & SA_ONESHOT)
-		ka->sa.sa_handler = SIG_DFL;
+	return 0;
+}
+
+long sys32_rt_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8,
+		     struct pt_regs *regs)
+{
+	struct rt_sigframe32 __user *rt_sf;
+	int ret;
+
+
+	/* Always make any pending restarted system calls return -EINTR */
+	current_thread_info()->restart_block.fn = do_no_restart_syscall;
+
+	rt_sf = (struct rt_sigframe32 __user *)
+		(regs->gpr[1] + __SIGNAL_FRAMESIZE32 + 16);
+	if (verify_area(VERIFY_READ, rt_sf, sizeof(*rt_sf)))
+		goto bad;
+	if (do_setcontext32(&rt_sf->uc, regs, 1))
+		goto bad;
+
+	/*
+	 * It's not clear whether or why it is desirable to save the
+	 * sigaltstack setting on signal delivery and restore it on
+	 * signal return.  But other architectures do this and we have
+	 * always done it up until now so it is probably better not to
+	 * change it.  -- paulus
+	 * We use the sys32_ version that does the 32/64 bits conversion
+	 * and takes userland pointer directly. What about error checking ?
+	 * nobody does any...
+	 */
+       	sys32_sigaltstack((u32)(u64)&rt_sf->uc.uc_stack, 0, 0, 0, 0, 0, regs);
+
+	regs->result &= 0xFFFFFFFF;
+	ret = regs->result;
+
+	return ret;
+
+ bad:
+	force_sig(SIGSEGV, current);
+	return 0;
+}
+
+
+/*
+ * OK, we're invoking a handler
+ */
+static void handle_signal32(unsigned long sig, struct k_sigaction *ka,
+			    siginfo_t *info, sigset_t *oldset,
+			    struct pt_regs * regs, unsigned long newsp)
+{
+	struct sigcontext32 __user *sc;
+	struct sigregs32 __user *frame;
+	unsigned long origsp = newsp;
+
+	/* Set up Signal Frame */
+	newsp -= sizeof(struct sigregs32);
+	frame = (struct sigregs32 __user *) newsp;
+
+	/* Put a sigcontext on the stack */
+	newsp -= sizeof(*sc);
+	sc = (struct sigcontext32 __user *) newsp;
+
+	/* create a stack frame for the caller of the handler */
+	newsp -= __SIGNAL_FRAMESIZE32;
+
+	if (verify_area(VERIFY_WRITE, (void *) newsp, origsp - newsp))
+		goto badframe;
+
+#if _NSIG != 64
+#error "Please adjust handle_signal32()"
+#endif
+	if (__put_user((u32)(u64)ka->sa.sa_handler, &sc->handler)
+	    || __put_user(oldset->sig[0], &sc->oldmask)
+	    || __put_user((oldset->sig[0] >> 32), &sc->_unused[3])
+	    || __put_user((u32)(u64)frame, &sc->regs)
+	    || __put_user(sig, &sc->signal))
+		goto badframe;
+
+	if (save_user_regs(regs, &frame->mctx, __NR_sigreturn))
+		goto badframe;
+
+	if (put_user(regs->gpr[1], (unsigned long __user *)newsp))
+		goto badframe;
+	regs->gpr[1] = (unsigned long) newsp;
+	regs->gpr[3] = sig;
+	regs->gpr[4] = (unsigned long) sc;
+	regs->nip = (unsigned long) ka->sa.sa_handler;
+	regs->link = (unsigned long) frame->mctx.tramp;
+	regs->trap = 0;
 
-	if (!(ka->sa.sa_flags & SA_NODEFER)) {
-		spin_lock_irq(&current->sighand->siglock);
-		sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
-		sigaddset(&current->blocked,sig);
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
-	}
 	return;
 
 badframe:
 #if DEBUG_SIG
-	printk("badframe in handle_signal32, regs=%p frame=%lx newsp=%lx\n",
+	printk("badframe in handle_signal, regs=%p frame=%x newsp=%x\n",
 	       regs, frame, *newspp);
-	printk("sc=%p sig=%d ka=%p info=%p oldset=%p\n", sc, sig, ka, info, oldset);
 #endif
-	do_exit(SIGSEGV);
+	if (sig == SIGSEGV)
+		ka->sa.sa_handler = SIG_DFL;
+	force_sig(SIGSEGV, current);
 }
 
-
 /*
- *  Start Alternate signal stack support
- *
- *  System Calls
- *       sigaltatck               sys32_sigaltstack
+ * Do a signal return; undo the signal stack.
  */
-
-int sys32_sigaltstack(u32 newstack, u32 oldstack, int p3,
-		      int p4, int p6, int p7, struct pt_regs *regs)
+long sys32_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8,
+		       struct pt_regs *regs)
 {
-	stack_t uss, uoss;
+	struct sigcontext32 __user *sc;
+	struct sigcontext32 sigctx;
+	struct mcontext32 __user *sr;
+	sigset_t set;
 	int ret;
-	mm_segment_t old_fs;
-	unsigned long sp;
+
+	/* Always make any pending restarted system calls return -EINTR */
+	current_thread_info()->restart_block.fn = do_no_restart_syscall;
+
+	sc = (struct sigcontext32 __user *)(regs->gpr[1] + __SIGNAL_FRAMESIZE32);
+	if (copy_from_user(&sigctx, sc, sizeof(sigctx)))
+		goto badframe;
 
 	/*
-	 * set sp to the user stack on entry to the system call
-	 * the system call router sets R9 to the saved registers
+	 * Note that PPC32 puts the upper 32 bits of the sigmask in the
+	 * unused part of the signal stackframe
 	 */
-	sp = regs->gpr[1];
+	set.sig[0] = sigctx.oldmask + ((long)(sigctx._unused[3]) << 32);
+	restore_sigmask(&set);
 
-	/* Put new stack info in local 64 bit stack struct */
-	if (newstack &&
-		(get_user((long)uss.ss_sp,
-			  &((stack_32_t *)(long)newstack)->ss_sp) ||
-		 __get_user(uss.ss_flags,
-			 &((stack_32_t *)(long)newstack)->ss_flags) ||
-		 __get_user(uss.ss_size,
-			 &((stack_32_t *)(long)newstack)->ss_size)))
-		return -EFAULT; 
+	sr = (struct mcontext32 *)(u64)sigctx.regs;
+	if (verify_area(VERIFY_READ, sr, sizeof(*sr))
+	    || restore_user_regs(regs, sr, 1))
+		goto badframe;
 
-	old_fs = get_fs();
-	set_fs(KERNEL_DS);
-	ret = do_sigaltstack(newstack ? &uss : NULL, oldstack ? &uoss : NULL,
-			sp);
-	set_fs(old_fs);
-	/* Copy the stack information to the user output buffer */
-	if (!ret && oldstack  &&
-		(put_user((long)uoss.ss_sp,
-			  &((stack_32_t *)(long)oldstack)->ss_sp) ||
-		 __put_user(uoss.ss_flags,
-			 &((stack_32_t *)(long)oldstack)->ss_flags) ||
-		 __put_user(uoss.ss_size,
-			 &((stack_32_t *)(long)oldstack)->ss_size)))
-		return -EFAULT;
+	regs->result &= 0xFFFFFFFF;
+	ret = regs->result;
 	return ret;
+
+badframe:
+	force_sig(SIGSEGV, current);
+	return 0;
 }
 
 
@@ -1082,7 +944,7 @@ int do_signal32(sigset_t *oldset, struct
 	siginfo_t info;
 	struct k_sigaction *ka;
 	unsigned int frame, newsp;
-	int signr;
+	int signr, ret;
 
 	if (!oldset)
 		oldset = &current->blocked;
@@ -1090,40 +952,60 @@ int do_signal32(sigset_t *oldset, struct
 	newsp = frame = 0;
 
 	signr = get_signal_to_deliver(&info, regs, NULL);
-	if (signr > 0) {
-		ka = &current->sighand->action[signr-1];
-		if ((ka->sa.sa_flags & SA_ONSTACK)
-		     && (!on_sig_stack(regs->gpr[1])))
-			newsp = (current->sas_ss_sp + current->sas_ss_size);
-		else
-			newsp = regs->gpr[1];
-		newsp = frame = newsp - sizeof(struct sigregs32);
 
-		/* Whee!  Actually deliver the signal.  */
-		handle_signal32(signr, &info, oldset, regs, &newsp, frame);
-	}
+	ka = (signr == 0)? NULL: &current->sighand->action[signr-1];
 
-	if (regs->trap == 0x0C00) {	/* System Call! */
-		if ((int)regs->result == -ERESTARTNOHAND ||
-		    (int)regs->result == -ERESTARTSYS ||
-		    (int)regs->result == -ERESTARTNOINTR) {
-			regs->gpr[3] = regs->orig_gpr3;
-			regs->nip -= 4; /* Back up & retry system call */
-			regs->result = 0;
-		} else if ((int)regs->result == -ERESTART_RESTARTBLOCK) {
-			regs->gpr[0] = __NR_restart_syscall;
-			regs->nip -= 4;
+	if (regs->trap == 0x0C00		/* System Call! */
+	    && regs->ccr & 0x10000000		/* error signalled */
+	    && ((ret = regs->gpr[3]) == ERESTARTSYS
+		|| ret == ERESTARTNOHAND || ret == ERESTARTNOINTR
+		|| ret == ERESTART_RESTARTBLOCK)) {
+
+		if (signr > 0
+		    && (ret == ERESTARTNOHAND || ret == ERESTART_RESTARTBLOCK
+			|| (ret == ERESTARTSYS
+			    && !(ka->sa.sa_flags & SA_RESTART)))) {
+			/* make the system call return an EINTR error */
+			regs->result = -EINTR;
+			regs->gpr[3] = EINTR;
+			/* note that the cr0.SO bit is already set */
+		} else {
+			regs->nip -= 4;	/* Back up & retry system call */
 			regs->result = 0;
+			regs->trap = 0;
+			if (ret == ERESTART_RESTARTBLOCK)
+				regs->gpr[0] = __NR_restart_syscall;
+			else
+				regs->gpr[3] = regs->orig_gpr3;
 		}
 	}
 
-	if (newsp == frame)
+	if (signr == 0)
 		return 0;		/* no signals delivered */
 
-	/* Invoke correct stack setup routine */
+	if ((ka->sa.sa_flags & SA_ONSTACK) && current->sas_ss_size
+	    && (!on_sig_stack(regs->gpr[1])))
+		newsp = (current->sas_ss_sp + current->sas_ss_size);
+	else
+		newsp = regs->gpr[1];
+	newsp &= ~0xfUL;
+
+	/* Whee!  Actually deliver the signal.  */
 	if (ka->sa.sa_flags & SA_SIGINFO)
-		setup_rt_frame32(regs, (struct sigregs32*)(u64)frame, newsp);
+		handle_rt_signal32(signr, ka, &info, oldset, regs, newsp);
 	else
-		setup_frame32(regs, (struct sigregs32*)(u64)frame, newsp);
+		handle_signal32(signr, ka, &info, oldset, regs, newsp);
+
+	if (ka->sa.sa_flags & SA_ONESHOT)
+		ka->sa.sa_handler = SIG_DFL;
+
+	if (!(ka->sa.sa_flags & SA_NODEFER)) {
+		spin_lock_irq(&current->sighand->siglock);
+		sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
+		sigaddset(&current->blocked, signr);
+		recalc_sigpending();
+		spin_unlock_irq(&current->sighand->siglock);
+	}
+
 	return 1;
 }
diff -puN arch/ppc64/kernel/signal.c~linus arch/ppc64/kernel/signal.c
--- 25/arch/ppc64/kernel/signal.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/signal.c	2004-01-19 22:17:21.000000000 -0800
@@ -114,19 +114,49 @@ long sys_sigaltstack(const stack_t *uss,
  * Set up the sigcontext for the signal frame.
  */
 
-static int
-setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs,
+static int setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs,
 		 int signr, sigset_t *set, unsigned long handler)
 {
+	/* When CONFIG_ALTIVEC is set, we _always_ setup v_regs even if the
+	 * process never used altivec yet (MSR_VEC is zero in pt_regs of
+	 * the context). This is very important because we must ensure we
+	 * don't lose the VRSAVE content that may have been set prior to
+	 * the process doing its first vector operation
+	 * Userland shall check AT_HWCAP to know wether it can rely on the
+	 * v_regs pointer or not
+	 */
+#ifdef CONFIG_ALTIVEC
+	elf_vrreg_t *v_regs = (elf_vrreg_t *)(((unsigned long)sc->vmx_reserve) & ~0xful);
+#endif
 	int err = 0;
 
 	if (regs->msr & MSR_FP)
 		giveup_fpu(current);
 
-	current->thread.saved_msr = regs->msr & ~(MSR_FP | MSR_FE0 | MSR_FE1);
-	regs->msr = current->thread.saved_msr | current->thread.fpexc_mode;
-	current->thread.saved_softe = regs->softe;
+	/* Make sure signal doesn't get spurrious FP exceptions */
+	current->thread.fpscr = 0;
+
+#ifdef CONFIG_ALTIVEC
+	err |= __put_user(v_regs, &sc->v_regs);
 
+	/* save altivec registers */
+	if (current->thread.used_vr) {		
+		if (regs->msr & MSR_VEC)
+			giveup_altivec(current);
+		/* Copy 33 vec registers (vr0..31 and vscr) to the stack */
+		err |= __copy_to_user(v_regs, current->thread.vr, 33 * sizeof(vector128));
+		/* set MSR_VEC in the MSR value in the frame to indicate that sc->v_reg)
+		 * contains valid data.
+		 */
+		regs->msr |= MSR_VEC;
+	}
+	/* We always copy to/from vrsave, it's 0 if we don't have or don't
+	 * use altivec.
+	 */
+	err |= __put_user(current->thread.vrsave, (u32 *)&v_regs[33]);
+#else /* CONFIG_ALTIVEC */
+	err |= __put_user(0, &sc->v_regs);
+#endif /* CONFIG_ALTIVEC */
 	err |= __put_user(&sc->gp_regs, &sc->regs);
 	err |= __copy_to_user(&sc->gp_regs, regs, GP_REGS_SIZE);
 	err |= __copy_to_user(&sc->fp_regs, &current->thread.fpr, FP_REGS_SIZE);
@@ -135,9 +165,6 @@ setup_sigcontext(struct sigcontext *sc, 
 	if (set != NULL)
 		err |=  __put_user(set->sig[0], &sc->oldmask);
 
-	regs->msr &= ~(MSR_FP | MSR_FE0 | MSR_FE1);
-	current->thread.fpscr = 0;
-
 	return err;
 }
 
@@ -145,23 +172,42 @@ setup_sigcontext(struct sigcontext *sc, 
  * Restore the sigcontext from the signal frame.
  */
 
-static int
-restore_sigcontext(struct pt_regs *regs, sigset_t *set, struct sigcontext *sc)
+static int restore_sigcontext(struct pt_regs *regs, sigset_t *set, int sig, struct sigcontext *sc)
 {
+#ifdef CONFIG_ALTIVEC
+	elf_vrreg_t *v_regs;
+#endif
 	unsigned int err = 0;
+	unsigned long save_r13;
 
-	if (regs->msr & MSR_FP)
-		giveup_fpu(current);
-
+	/* If this is not a signal return, we preserve the TLS in r13 */
+	if (!sig)
+		save_r13 = regs->gpr[13];
 	err |= __copy_from_user(regs, &sc->gp_regs, GP_REGS_SIZE);
+	if (!sig)
+		regs->gpr[13] = save_r13;
 	err |= __copy_from_user(&current->thread.fpr, &sc->fp_regs, FP_REGS_SIZE);
-	current->thread.fpexc_mode = regs->msr & (MSR_FE0 | MSR_FE1);
 	if (set != NULL)
 		err |=  __get_user(set->sig[0], &sc->oldmask);
 
-	/* Don't allow the signal handler to change these modulo FE{0,1} */
-	regs->msr = current->thread.saved_msr & ~(MSR_FP | MSR_FE0 | MSR_FE1);
-	regs->softe = current->thread.saved_softe;
+#ifdef CONFIG_ALTIVEC
+	err |= __get_user(v_regs, &sc->v_regs);
+	if (err)
+		return err;
+	/* Copy 33 vec registers (vr0..31 and vscr) from the stack */
+	if (v_regs != 0 && (regs->msr & MSR_VEC) != 0)
+		err |= __copy_from_user(current->thread.vr, v_regs, 33 * sizeof(vector128));
+	else if (current->thread.used_vr)
+		memset(&current->thread.vr, 0, 33);
+	/* Always get VRSAVE back */
+	if (v_regs != 0)
+		err |= __get_user(current->thread.vrsave, (u32 *)&v_regs[33]);
+	else
+		current->thread.vrsave = 0;
+#endif /* CONFIG_ALTIVEC */
+
+	/* Force reload of FP/VEC */
+	regs->msr &= ~(MSR_FP | MSR_FE0 | MSR_FE1 | MSR_VEC);
 
 	return err;
 }
@@ -169,8 +215,8 @@ restore_sigcontext(struct pt_regs *regs,
 /*
  * Allocate space for the signal frame
  */
-static inline void *
-get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size)
+static inline void * get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
+				  size_t frame_size)
 {
         unsigned long newsp;
 
@@ -185,8 +231,10 @@ get_sigframe(struct k_sigaction *ka, str
         return (void *)((newsp - frame_size) & -8ul);
 }
 
-static int
-setup_trampoline(unsigned int syscall, unsigned int *tramp)
+/*
+ * Setup the trampoline code on the stack
+ */
+static int setup_trampoline(unsigned int syscall, unsigned int *tramp)
 {
 	int i, err = 0;
 
@@ -209,6 +257,72 @@ setup_trampoline(unsigned int syscall, u
 }
 
 /*
+ * Restore the user process's signal mask (also used by signal32.c)
+ */
+void restore_sigmask(sigset_t *set)
+{
+	sigdelsetmask(set, ~_BLOCKABLE);
+	spin_lock_irq(&current->sighand->siglock);
+	current->blocked = *set;
+	recalc_sigpending();
+	spin_unlock_irq(&current->sighand->siglock);
+}
+
+
+/*
+ * Handle {get,set,swap}_context operations
+ */
+int sys_swapcontext(struct ucontext __user *old_ctx,
+		    struct ucontext __user *new_ctx,
+		    long ctx_size, long r6, long r7, long r8, struct pt_regs *regs)
+{
+	unsigned char tmp;
+	sigset_t set;
+
+	/* Context size is for future use. Right now, we only make sure
+	 * we are passed something we understand
+	 */
+	if (ctx_size < sizeof(struct ucontext))
+		return -EINVAL;
+
+	if (old_ctx != NULL) {
+		if (verify_area(VERIFY_WRITE, old_ctx, sizeof(*old_ctx))
+		    || setup_sigcontext(&old_ctx->uc_mcontext, regs, 0, NULL, 0)
+		    || __copy_to_user(&old_ctx->uc_sigmask,
+				      &current->blocked, sizeof(sigset_t)))
+			return -EFAULT;
+	}
+	if (new_ctx == NULL)
+		return 0;
+	if (verify_area(VERIFY_READ, new_ctx, sizeof(*new_ctx))
+	    || __get_user(tmp, (u8 *) new_ctx)
+	    || __get_user(tmp, (u8 *) (new_ctx + 1) - 1))
+		return -EFAULT;
+
+	/*
+	 * If we get a fault copying the context into the kernel's
+	 * image of the user's registers, we can't just return -EFAULT
+	 * because the user's registers will be corrupted.  For instance
+	 * the NIP value may have been updated but not some of the
+	 * other registers.  Given that we have done the verify_area
+	 * and successfully read the first and last bytes of the region
+	 * above, this should only happen in an out-of-memory situation
+	 * or if another thread unmaps the region containing the context.
+	 * We kill the task with a SIGSEGV in this situation.
+	 */
+
+	if (__copy_from_user(&set, &new_ctx->uc_sigmask, sizeof(set)))
+		do_exit(SIGSEGV);
+	restore_sigmask(&set);
+	if (restore_sigcontext(regs, NULL, 0, &new_ctx->uc_mcontext))
+		do_exit(SIGSEGV);
+
+	/* This returns like rt_sigreturn */
+	return 0;
+}
+
+
+/*
  * Do a signal return; undo the signal stack.
  */
 
@@ -218,7 +332,6 @@ int sys_rt_sigreturn(unsigned long r3, u
 {
 	struct ucontext *uc = (struct ucontext *)regs->gpr[1];
 	sigset_t set;
-	stack_t st;
 
 	/* Always make any pending restarted system calls return -EINTR */
 	current_thread_info()->restart_block.fn = do_no_restart_syscall;
@@ -228,20 +341,14 @@ int sys_rt_sigreturn(unsigned long r3, u
 
 	if (__copy_from_user(&set, &uc->uc_sigmask, sizeof(set)))
 		goto badframe;
-	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
-
-	if (restore_sigcontext(regs, NULL, &uc->uc_mcontext))
+	restore_sigmask(&set);
+	if (restore_sigcontext(regs, NULL, 1, &uc->uc_mcontext))
 		goto badframe;
 
-	if (__copy_from_user(&st, &uc->uc_stack, sizeof(st)))
-		goto badframe;
-	/* This function sets back the stack flags into
-	   the current task structure.  */
-	sys_sigaltstack(&st, NULL, 0, 0, 0, 0, regs);
+	/* do_sigaltstack expects a __user pointer and won't modify
+	 * what's in there anyway
+	 */
+	do_sigaltstack(&uc->uc_stack, NULL, regs->gpr[1]);
 
 	return regs->result;
 
@@ -253,8 +360,7 @@ badframe:
 	do_exit(SIGSEGV);
 }
 
-static void
-setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info,
+static void setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info,
 		sigset_t *set, struct pt_regs *regs)
 {
 	/* Handler is *really* a pointer to the function descriptor for
@@ -332,9 +438,8 @@ badframe:
 /*
  * OK, we're invoking a handler
  */
-static void
-handle_signal(unsigned long sig, struct k_sigaction *ka,
-	      siginfo_t *info, sigset_t *oldset, struct pt_regs *regs)
+static void handle_signal(unsigned long sig, struct k_sigaction *ka,
+			  siginfo_t *info, sigset_t *oldset, struct pt_regs *regs)
 {
 	/* Set up Signal Frame */
 	setup_rt_frame(sig, ka, info, oldset, regs);
@@ -352,8 +457,7 @@ handle_signal(unsigned long sig, struct 
 	return;
 }
 
-static inline void
-syscall_restart(struct pt_regs *regs, struct k_sigaction *ka)
+static inline void syscall_restart(struct pt_regs *regs, struct k_sigaction *ka)
 {
 	switch ((int)regs->result) {
 	case -ERESTART_RESTARTBLOCK:
diff -puN arch/ppc64/kernel/smp.c~linus arch/ppc64/kernel/smp.c
--- 25/arch/ppc64/kernel/smp.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/smp.c	2004-01-19 22:17:21.000000000 -0800
@@ -53,10 +53,14 @@
 int smp_threads_ready;
 unsigned long cache_decay_ticks;
 
-/* initialised so it doesn't end up in bss */
+/* Initialised so it doesn't end up in bss */
+cpumask_t cpu_possible_map    = CPU_MASK_NONE;
 cpumask_t cpu_online_map = CPU_MASK_NONE;
+cpumask_t cpu_available_map   = CPU_MASK_NONE;
+cpumask_t cpu_present_at_boot = CPU_MASK_NONE;
 
 EXPORT_SYMBOL(cpu_online_map);
+EXPORT_SYMBOL(cpu_possible_map);
 
 static struct smp_ops_t *smp_ops;
 
@@ -67,6 +71,8 @@ extern unsigned char stab_array[];
 extern int cpu_idle(void *unused);
 void smp_call_function_interrupt(void);
 void smp_message_pass(int target, int msg, unsigned long data, int wait);
+extern long register_vpa(unsigned long flags, unsigned long proc,
+			 unsigned long vpa);
 
 #define smp_message_pass(t,m,d,w) smp_ops->message_pass((t),(m),(d),(w))
 
@@ -120,6 +126,9 @@ static int smp_iSeries_numProcs(void)
         for (i=0; i < NR_CPUS; ++i) {
                 lpPaca = paca[i].xLpPacaPtr;
                 if ( lpPaca->xDynProcStatus < 2 ) {
+			cpu_set(i, cpu_available_map);
+			cpu_set(i, cpu_possible_map);
+			cpu_set(i, cpu_present_at_boot);
                         ++np;
                 }
         }
@@ -135,7 +144,7 @@ static int smp_iSeries_probe(void)
 	for (i=0; i < NR_CPUS; ++i) {
 		lpPaca = paca[i].xLpPacaPtr;
 		if (lpPaca->xDynProcStatus < 2) {
-			paca[i].active = 1;
+			/*paca[i].active = 1;*/
 			++np;
 		}
 	}
@@ -181,7 +190,6 @@ void __init smp_init_iSeries(void)
 	smp_ops->probe        = smp_iSeries_probe;
 	smp_ops->kick_cpu     = smp_iSeries_kick_cpu;
 	smp_ops->setup_cpu    = smp_iSeries_setup_cpu;
-#warning fix for iseries
 	systemcfg->processorCount	= smp_iSeries_numProcs();
 }
 #endif
@@ -227,6 +235,11 @@ static int __init smp_openpic_probe(void
 	return nr_cpus;
 }
 
+static void __devinit smp_openpic_setup_cpu(int cpu)
+{
+	do_openpic_setup_cpu();
+}
+
 static void
 smp_kick_cpu(int nr)
 {
@@ -266,14 +279,15 @@ static void __init smp_space_timers(unsi
 }
 
 #ifdef CONFIG_PPC_PSERIES
-static void __devinit pSeries_setup_cpu(int cpu)
+void vpa_init(int cpu)
 {
-	if (OpenPIC_Addr) {
-		do_openpic_setup_cpu();
-	} else {
-		if (cpu != boot_cpuid)
-			xics_setup_cpu();
-	}
+	unsigned long flags;
+
+	/* Register the Virtual Processor Area (VPA) */
+	printk(KERN_INFO "register_vpa: cpu 0x%x\n", cpu);
+	flags = 1UL << (63 - 18);
+	paca[cpu].xLpPaca.xSLBCount = 64; /* SLB restore highwater mark */
+	register_vpa(flags, cpu, __pa((unsigned long)&(paca[cpu].xLpPaca))); 
 }
 
 static void
@@ -295,6 +309,8 @@ smp_xics_message_pass(int target, int ms
 	}
 }
 
+extern void xics_request_IPIs(void);
+
 static int __init smp_xics_probe(void)
 {
 	int i;
@@ -305,13 +321,18 @@ static int __init smp_xics_probe(void)
 			nr_cpus++;
 	}
 #ifdef CONFIG_SMP
-	extern void xics_request_IPIs(void);
 	xics_request_IPIs();
 #endif
 
 	return nr_cpus;
 }
 
+static void __devinit smp_xics_setup_cpu(int cpu)
+{
+	if (cpu != boot_cpuid)
+		xics_setup_cpu();
+}
+
 static spinlock_t timebase_lock = SPIN_LOCK_UNLOCKED;
 static unsigned long timebase = 0;
 
@@ -345,9 +366,11 @@ void __init smp_init_pSeries(void)
 	if (naca->interrupt_controller == IC_OPEN_PIC) {
 		smp_ops->message_pass	= smp_openpic_message_pass;
 		smp_ops->probe		= smp_openpic_probe;
+		smp_ops->setup_cpu	= smp_openpic_setup_cpu;
 	} else {
 		smp_ops->message_pass	= smp_xics_message_pass;
 		smp_ops->probe		= smp_xics_probe;
+		smp_ops->setup_cpu	= smp_xics_setup_cpu;
 	}
 
 	if (systemcfg->platform == PLATFORM_PSERIES) {
@@ -356,7 +379,6 @@ void __init smp_init_pSeries(void)
 	}
 
 	smp_ops->kick_cpu = smp_kick_cpu;
-	smp_ops->setup_cpu = pSeries_setup_cpu;
 }
 #endif
 
@@ -480,13 +502,13 @@ int smp_call_function (void (*func) (voi
 	while (atomic_read(&data.started) != cpus) {
 		HMT_low();
 		if (--timeout == 0) {
+			printk("smp_call_function on cpu %d: other cpus not "
+			       "responding (%d)\n", smp_processor_id(),
+			       atomic_read(&data.started));
 #ifdef CONFIG_DEBUG_KERNEL
 			if (debugger)
 				debugger(0);
 #endif
-			printk("smp_call_function on cpu %d: other cpus not "
-			       "responding (%d)\n", smp_processor_id(),
-			       atomic_read(&data.started));
 			goto out;
 		}
 	}
@@ -496,15 +518,15 @@ int smp_call_function (void (*func) (voi
 		while (atomic_read(&data.finished) != cpus) {
 			HMT_low();
 			if (--timeout == 0) {
-#ifdef CONFIG_DEBUG_KERNEL
-				if (debugger)
-					debugger(0);
-#endif
 				printk("smp_call_function on cpu %d: other "
 				       "cpus not finishing (%d/%d)\n",
 				       smp_processor_id(),
 				       atomic_read(&data.finished),
 				       atomic_read(&data.started));
+#ifdef CONFIG_DEBUG_KERNEL
+				if (debugger)
+					debugger(0);
+#endif
 				goto out;
 			}
 		}
@@ -513,6 +535,7 @@ int smp_call_function (void (*func) (voi
 	ret = 0;
 
 out:
+	call_data = NULL;
 	HMT_medium();
 	spin_unlock(&call_lock);
 	return ret;
@@ -520,9 +543,19 @@ out:
 
 void smp_call_function_interrupt(void)
 {
-	void (*func) (void *info) = call_data->func;
-	void *info = call_data->info;
-	int wait = call_data->wait;
+	void (*func) (void *info);
+	void *info;
+	int wait;
+
+	/* call_data will be NULL if the sender timed out while
+	 * waiting on us to receive the call.
+	 */
+	if (!call_data)
+		return;
+
+	func = call_data->func;
+	info = call_data->info;
+	wait = call_data->wait;
 
 	/*
 	 * Notify initiating CPU that I've grabbed the data and am
@@ -549,11 +582,17 @@ static void __devinit smp_store_cpu_info
 
 void __init smp_prepare_cpus(unsigned int max_cpus)
 {
+	/* 
+	 * setup_cpu may need to be called on the boot cpu. We havent
+	 * spun any cpus up but lets be paranoid.
+	 */
+	BUG_ON(boot_cpuid != smp_processor_id());
+
 	/* Fixup boot cpu */
-	smp_store_cpu_info(smp_processor_id());
-	cpu_callin_map[smp_processor_id()] = 1;
-	paca[smp_processor_id()].prof_counter = 1;
-	paca[smp_processor_id()].prof_multiplier = 1;
+	smp_store_cpu_info(boot_cpuid);
+	cpu_callin_map[boot_cpuid] = 1;
+	paca[boot_cpuid].prof_counter = 1;
+	paca[boot_cpuid].prof_multiplier = 1;
 
 	/*
 	 * XXX very rough. 
@@ -658,6 +697,14 @@ int __devinit start_secondary(void *unus
 	if (smp_ops->take_timebase)
 		smp_ops->take_timebase();
 
+	get_paca()->yielded = 0;
+
+#ifdef CONFIG_PPC_PSERIES
+	if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) {
+		vpa_init(cpu); 
+	}
+#endif
+
 	local_irq_enable();
 
 	return cpu_idle(NULL);
@@ -670,8 +717,19 @@ int setup_profiling_timer(unsigned int m
 
 void __init smp_cpus_done(unsigned int max_cpus)
 {
+	cpumask_t old_mask;
+
+	/* We want the setup_cpu() here to be called from CPU 0, but our
+	 * init thread may have been "borrowed" by another CPU in the meantime
+	 * se we pin us down to CPU 0 for a short while
+	 */
+	old_mask = current->cpus_allowed;
+	set_cpus_allowed(current, cpumask_of_cpu(boot_cpuid));
+	
 	smp_ops->setup_cpu(boot_cpuid);
 
 	/* XXX fix this, xics currently relies on it - Anton */
 	smp_threads_ready = 1;
+
+	set_cpus_allowed(current, old_mask);
 }
diff -puN arch/ppc64/kernel/syscalls.c~linus arch/ppc64/kernel/syscalls.c
--- 25/arch/ppc64/kernel/syscalls.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/syscalls.c	2004-01-19 22:17:21.000000000 -0800
@@ -41,6 +41,7 @@
 #include <asm/ipc.h>
 #include <asm/semaphore.h>
 #include <asm/time.h>
+#include <asm/unistd.h>
 
 extern unsigned long wall_jiffies;
 
@@ -234,3 +235,6 @@ asmlinkage time_t sys64_time(time_t* tlo
 
 	return secs;
 }
+
+/* Only exists on P-series. */
+cond_syscall(ppc_rtas);
diff -puN arch/ppc64/kernel/sys_ppc32.c~linus arch/ppc64/kernel/sys_ppc32.c
--- 25/arch/ppc64/kernel/sys_ppc32.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/sys_ppc32.c	2004-01-19 22:17:21.000000000 -0800
@@ -746,30 +746,31 @@ int ppc32_select(u32 n, u32* inp, u32* o
 
 int cp_compat_stat(struct kstat *stat, struct compat_stat *statbuf)
 {
-	int err;
+	long err;
 
 	if (stat->size > MAX_NON_LFS || !new_valid_dev(stat->dev) ||
 	    !new_valid_dev(stat->rdev))
 		return -EOVERFLOW;
 
-	err  = put_user(new_encode_dev(stat->dev), &statbuf->st_dev);
-	err |= put_user(stat->ino, &statbuf->st_ino);
-	err |= put_user(stat->mode, &statbuf->st_mode);
-	err |= put_user(stat->nlink, &statbuf->st_nlink);
-	err |= put_user(stat->uid, &statbuf->st_uid);
-	err |= put_user(stat->gid, &statbuf->st_gid);
-	err |= put_user(new_encode_dev(stat->rdev), &statbuf->st_rdev);
-	err |= put_user(stat->size, &statbuf->st_size);
-	err |= put_user(stat->atime.tv_sec, &statbuf->st_atime);
-	err |= put_user(0, &statbuf->__unused1);
-	err |= put_user(stat->mtime.tv_sec, &statbuf->st_mtime);
-	err |= put_user(0, &statbuf->__unused2);
-	err |= put_user(stat->ctime.tv_sec, &statbuf->st_ctime);
-	err |= put_user(0, &statbuf->__unused3);
-	err |= put_user(stat->blksize, &statbuf->st_blksize);
-	err |= put_user(stat->blocks, &statbuf->st_blocks);
-	err |= put_user(0, &statbuf->__unused4[0]);
-	err |= put_user(0, &statbuf->__unused4[1]);
+	err  = verify_area(VERIFY_WRITE, statbuf, sizeof(*statbuf));
+	err |= __put_user(new_encode_dev(stat->dev), &statbuf->st_dev);
+	err |= __put_user(stat->ino, &statbuf->st_ino);
+	err |= __put_user(stat->mode, &statbuf->st_mode);
+	err |= __put_user(stat->nlink, &statbuf->st_nlink);
+	err |= __put_user(stat->uid, &statbuf->st_uid);
+	err |= __put_user(stat->gid, &statbuf->st_gid);
+	err |= __put_user(new_encode_dev(stat->rdev), &statbuf->st_rdev);
+	err |= __put_user(stat->size, &statbuf->st_size);
+	err |= __put_user(stat->atime.tv_sec, &statbuf->st_atime);
+	err |= __put_user(stat->atime.tv_nsec, &statbuf->st_atime_nsec);
+	err |= __put_user(stat->mtime.tv_sec, &statbuf->st_mtime);
+	err |= __put_user(stat->mtime.tv_nsec, &statbuf->st_mtime_nsec);
+	err |= __put_user(stat->ctime.tv_sec, &statbuf->st_ctime);
+	err |= __put_user(stat->ctime.tv_nsec, &statbuf->st_ctime_nsec);
+	err |= __put_user(stat->blksize, &statbuf->st_blksize);
+	err |= __put_user(stat->blocks, &statbuf->st_blocks);
+	err |= __put_user(0, &statbuf->__unused4[0]);
+	err |= __put_user(0, &statbuf->__unused4[1]);
 
 	return err;
 }
@@ -2106,6 +2107,10 @@ long sys32_execve(unsigned long a0, unsi
 		goto out;
 	if (regs->msr & MSR_FP)
 		giveup_fpu(current);
+#ifdef CONFIG_ALTIVEC
+	if (regs->msr & MSR_VEC)
+		giveup_altivec(current);
+#endif /* CONFIG_ALTIVEC */
 
 	error = do_execve32(filename, (u32*) a1, (u32*) a2, regs);
 
@@ -2126,9 +2131,25 @@ void start_thread32(struct pt_regs* regs
 	regs->nip = nip;
 	regs->gpr[1] = sp;
 	regs->msr = MSR_USER32;
+#ifndef CONFIG_SMP
 	if (last_task_used_math == current)
 		last_task_used_math = 0;
+#endif /* CONFIG_SMP */
 	current->thread.fpscr = 0;
+	memset(current->thread.fpr, 0, sizeof(current->thread.fpr));
+#ifdef CONFIG_ALTIVEC
+#ifndef CONFIG_SMP
+	if (last_task_used_altivec == current)
+		last_task_used_altivec = 0;
+#endif /* CONFIG_SMP */
+	memset(current->thread.vr, 0, sizeof(current->thread.vr));
+	current->thread.vscr.u[0] = 0;
+	current->thread.vscr.u[1] = 0;
+	current->thread.vscr.u[2] = 0;
+	current->thread.vscr.u[3] = 0x00010000; /* Java mode disabled */
+	current->thread.vrsave = 0;
+	current->thread.used_vr = 0;
+#endif /* CONFIG_ALTIVEC */
 }
 
 extern asmlinkage int sys_prctl(int option, unsigned long arg2, unsigned long arg3,
@@ -2683,98 +2704,6 @@ unsigned long sys32_mmap2(unsigned long 
 	return sys_mmap(addr, len, prot, flags, fd, pgoff << 12);
 }
 
-extern long sys_io_setup(unsigned nr_reqs, aio_context_t *ctx);
-
-long sys32_io_setup(unsigned nr_reqs, u32 *ctx32p)
-{
-	long ret;
-	aio_context_t ctx64;
-	mm_segment_t oldfs = get_fs();
-
-	if (get_user((u32)ctx64, ctx32p))
-		return -EFAULT;
-
-	set_fs(KERNEL_DS);
-	ret = sys_io_setup(nr_reqs, &ctx64);
-	set_fs(oldfs);
-
-	/* truncating is ok because it's a user address */
-	if (!ret)
-		ret = put_user((u32)ctx64, ctx32p);
-
-	return ret;
-}
-
-long sys_io_getevents(aio_context_t ctx_id, long min_nr, long nr,
-		      struct io_event *events, struct timespec *timeout);
-
-long sys32_io_getevents(aio_context_t ctx_id, u32 min_nr, u32 nr,
-			struct io_event *events, struct compat_timespec *t32)
-{
-	struct timespec t;
-	long ret;
-	mm_segment_t oldfs = get_fs();
-
-	if (t32) {
-		if (get_user(t.tv_sec, &t32->tv_sec) ||
-		    __get_user(t.tv_nsec, &t32->tv_nsec))
-			return -EFAULT;
-	}
-
-	if (verify_area(VERIFY_WRITE, events, nr * sizeof(*events)))
-		return -EFAULT;
-
-	set_fs(KERNEL_DS);
-	/* sign extend min_nr and nr */
-	ret = sys_io_getevents(ctx_id, (int)min_nr, (int)nr, events,
-			       t32 ? &t : NULL);
-	set_fs(oldfs);
-
-	return ret;
-}
-
-long sys32_io_submit(aio_context_t ctx_id, u32 number, u32 *iocbpp)
-{
-	struct kioctx *ctx;
-	long ret = 0;
-	int i;
-	int nr = (int)number;	/* sign extend */
-
-	if (unlikely(nr < 0))
-		return -EINVAL;
-
-	if (unlikely(!access_ok(VERIFY_READ, iocbpp, (nr*sizeof(u32)))))
-		return -EFAULT;
-
-	ctx = lookup_ioctx(ctx_id);
-	if (unlikely(!ctx)) {
-		pr_debug("EINVAL: io_submit: invalid context id\n");
-		return -EINVAL;
-	}
-
-	for (i=0; i<nr; i++) {
-		struct iocb tmp;
-		u32 *user_iocb;
-
-		if (unlikely(__get_user((u32)(long)user_iocb, iocbpp + i))) {
-			ret = -EFAULT;
-			break;
-		}
-
-		if (unlikely(copy_from_user(&tmp, user_iocb, sizeof(tmp)))) {
-			ret = -EFAULT;
-			break;
-		}
-
-		ret = io_submit_one(ctx, (struct iocb *)user_iocb, &tmp);
-		if (ret)
-			break;
-	}
-
-	put_ioctx(ctx);
-	return i ? i : ret;
-}
-
 int get_compat_timeval(struct timeval *tv, struct compat_timeval *ctv)
 {
 	return (verify_area(VERIFY_READ, ctv, sizeof(*ctv)) ||
@@ -2878,3 +2807,46 @@ long ppc32_fadvise64(int fd, u32 unused,
 			     advice);
 }
 
+long ppc32_fadvise64_64(int fd, int advice, u32 offset_high, u32 offset_low,
+			u32 len_high, u32 len_low)
+{
+	return sys_fadvise64(fd, (u64)offset_high << 32 | offset_low,
+			     (u64)len_high << 32 | len_low, advice);
+}
+
+extern long sys_timer_create(clockid_t, sigevent_t *, timer_t *);
+
+long ppc32_timer_create(clockid_t clock,
+			struct compat_sigevent __user *ev32,
+			timer_t __user *timer_id)
+{
+	sigevent_t event;
+	timer_t t;
+	long err;
+	mm_segment_t savefs;
+
+	if (ev32 == NULL)
+		return sys_timer_create(clock, NULL, timer_id);
+
+	memset(&event, 0, sizeof(event));
+	if (!access_ok(VERIFY_READ, ev32, sizeof(struct compat_sigevent))
+	    || __get_user(event.sigev_value.sival_int,
+			  &ev32->sigev_value.sival_int)
+	    || __get_user(event.sigev_signo, &ev32->sigev_signo)
+	    || __get_user(event.sigev_notify, &ev32->sigev_notify)
+	    || __get_user(event.sigev_notify_thread_id,
+			  &ev32->sigev_notify_thread_id))
+		return -EFAULT;
+
+	if (!access_ok(VERIFY_WRITE, timer_id, sizeof(timer_t)))
+		return -EFAULT;
+
+	savefs = get_fs();
+	err = sys_timer_create(clock, &event, &t);
+	set_fs(savefs);
+
+	if (err == 0)
+		err = __put_user(t, timer_id);
+
+	return err;
+}
diff -puN arch/ppc64/kernel/time.c~linus arch/ppc64/kernel/time.c
--- 25/arch/ppc64/kernel/time.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/time.c	2004-01-19 22:17:21.000000000 -0800
@@ -91,6 +91,9 @@ unsigned      tb_to_us;
 unsigned long processor_freq;
 spinlock_t rtc_lock = SPIN_LOCK_UNLOCKED;
 
+unsigned long tb_to_ns_scale;
+unsigned long tb_to_ns_shift;
+
 struct gettimeofday_struct do_gtod;
 
 extern unsigned long wall_jiffies;
@@ -313,11 +316,13 @@ int timer_interrupt(struct pt_regs * reg
 /*
  * Scheduler clock - returns current time in nanosec units.
  *
- * This is wrong, but my CPUs run at 1GHz, so nyer nyer.
+ * Note: mulhdu(a, b) (multiply high double unsigned) returns
+ * the high 64 bits of a * b, i.e. (a * b) >> 64, where a and b
+ * are 64-bit unsigned numbers.
  */
 unsigned long long sched_clock(void)
 {
-	return get_tb();
+	return mulhdu(get_tb(), tb_to_ns_scale) << tb_to_ns_shift;
 }
 
 /*
@@ -473,9 +478,30 @@ void __init time_init(void)
 	/* This function is only called on the boot processor */
 	unsigned long flags;
 	struct rtc_time tm;
+	struct div_result res;
+	unsigned long scale, shift;
 
 	ppc_md.calibrate_decr();
 
+	/*
+	 * Compute scale factor for sched_clock.
+	 * The calibrate_decr() function has set tb_ticks_per_sec,
+	 * which is the timebase frequency.
+	 * We compute 1e9 * 2^64 / tb_ticks_per_sec and interpret
+	 * the 128-bit result as a 64.64 fixed-point number.
+	 * We then shift that number right until it is less than 1.0,
+	 * giving us the scale factor and shift count to use in
+	 * sched_clock().
+	 */
+	div128_by_32(1000000000, 0, tb_ticks_per_sec, &res);
+	scale = res.result_low;
+	for (shift = 0; res.result_high != 0; ++shift) {
+		scale = (scale >> 1) | (res.result_high << 63);
+		res.result_high >>= 1;
+	}
+	tb_to_ns_scale = scale;
+	tb_to_ns_shift = shift;
+
 #ifdef CONFIG_PPC_ISERIES
 	if (!piranha_simulator)
 #endif
diff -puN arch/ppc64/kernel/traps.c~linus arch/ppc64/kernel/traps.c
--- 25/arch/ppc64/kernel/traps.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/traps.c	2004-01-19 22:17:21.000000000 -0800
@@ -16,6 +16,7 @@
  * This file handles the architecture-dependent parts of hardware exceptions
  */
 
+#include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
 #include <linux/kernel.h>
@@ -26,7 +27,6 @@
 #include <linux/user.h>
 #include <linux/a.out.h>
 #include <linux/interrupt.h>
-#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/module.h>
 
@@ -40,8 +40,10 @@
 extern int fix_alignment(struct pt_regs *);
 extern void bad_page_fault(struct pt_regs *, unsigned long, int);
 
+#ifdef CONFIG_PPC_PSERIES
 /* This is true if we are using the firmware NMI handler (typically LPAR) */
 extern int fwnmi_active;
+#endif
 
 #ifdef CONFIG_DEBUG_KERNEL
 void (*debugger)(struct pt_regs *regs);
@@ -96,6 +98,7 @@ _exception(int signr, siginfo_t *info, s
 	force_sig_info(signr, info, current);
 }
 
+#ifdef CONFIG_PPC_PSERIES
 /* Get the error information for errors coming through the
  * FWNMI vectors.  The pt_regs' r3 will be updated to reflect
  * the actual r3 if possible, and a ptr to the error log entry
@@ -128,10 +131,12 @@ static void FWNMI_release_errinfo(void)
 	if (ret != 0)
 		printk("FWNMI: nmi-interlock failed: %ld\n", ret);
 }
+#endif
 
 void
 SystemResetException(struct pt_regs *regs)
 {
+#ifdef CONFIG_PPC_PSERIES
 	if (fwnmi_active) {
 		struct rtas_error_log *errhdr = FWNMI_get_errinfo(regs);
 		if (errhdr) {
@@ -139,6 +144,7 @@ SystemResetException(struct pt_regs *reg
 		}
 		FWNMI_release_errinfo();
 	}
+#endif
 
 #ifdef CONFIG_DEBUG_KERNEL
 	if (debugger)
@@ -154,6 +160,7 @@ SystemResetException(struct pt_regs *reg
 	/* What should we do here? We could issue a shutdown or hard reset. */
 }
 
+#ifdef CONFIG_PPC_PSERIES
 /* 
  * See if we can recover from a machine check exception.
  * This is only called on power4 (or above) and only via
@@ -190,6 +197,7 @@ static int recover_mce(struct pt_regs *r
 	}
 	return 0;
 }
+#endif
 
 /*
  * Handle a machine check.
@@ -207,6 +215,7 @@ static int recover_mce(struct pt_regs *r
 void
 MachineCheckException(struct pt_regs *regs)
 {
+#ifdef CONFIG_PPC_PSERIES
 	struct rtas_error_log err, *errp;
 
 	if (fwnmi_active) {
@@ -217,6 +226,7 @@ MachineCheckException(struct pt_regs *re
 		if (errp && recover_mce(regs, err))
 			return;
 	}
+#endif
 
 #ifdef CONFIG_DEBUG_KERNEL
 	if (debugger_fault_handler) {
@@ -349,7 +359,7 @@ check_bug_trap(struct pt_regs *regs)
 		printk(KERN_ERR "Badness in %s at %s:%d\n",
 		       bug->function, bug->file,
 		      (unsigned int)bug->line & ~BUG_WARNING_TRAP);
-		dump_stack();
+		show_stack(current, (void *)regs->gpr[1]);
 		return 1;
 	}
 	printk(KERN_CRIT "kernel BUG in %s at %s:%d!\n",
@@ -410,6 +420,14 @@ KernelFPUnavailableException(struct pt_r
 }
 
 void
+KernelAltivecUnavailableException(struct pt_regs *regs)
+{
+	printk("Illegal VMX/Altivec used in kernel (task=0x%p, "
+		"pc=0x%016lx, trap=0x%lx)\n", current, regs->nip, regs->trap);
+	panic("Unrecoverable VMX/Altivec Unavailable Exception in Kernel");
+}
+
+void
 SingleStepException(struct pt_regs *regs)
 {
 	siginfo_t info;
@@ -478,6 +496,17 @@ AlignmentException(struct pt_regs *regs)
 	_exception(SIGBUS, &info, regs);	
 }
 
+#ifdef CONFIG_ALTIVEC
+void
+AltivecAssistException(struct pt_regs *regs)
+{
+	if (regs->msr & MSR_VEC)
+		giveup_altivec(current);
+	/* XXX quick hack for now: set the non-Java bit in the VSCR */
+	current->thread.vscr.u[3] |= 0x10000;
+}
+#endif /* CONFIG_ALTIVEC */
+
 void __init trap_init(void)
 {
 }
diff -puN arch/ppc64/kernel/udbg.c~linus arch/ppc64/kernel/udbg.c
--- 25/arch/ppc64/kernel/udbg.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/udbg.c	2004-01-19 22:17:21.000000000 -0800
@@ -127,8 +127,10 @@ udbg_write(const char *s, int n)
 {
 	int remain = n;
 	char c;
+
 	if (!ppc_md.udbg_putc)
-		for (;;);	/* stop here for cpuctl */
+		return 0;
+
 	if ( s && *s != '\0' ) {
 		while ( (( c = *s++ ) != '\0') && (remain-- > 0)) {
 			ppc_md.udbg_putc(c);
diff -puN /dev/null arch/ppc64/kernel/vio.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/ppc64/kernel/vio.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,536 @@
+/*
+ * IBM PowerPC Virtual I/O Infrastructure Support.
+ *
+ *    Copyright (c) 2003 IBM Corp.
+ *     Dave Engebretsen engebret@us.ibm.com
+ *     Santiago Leon santil@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/init.h>
+#include <linux/console.h>
+#include <linux/pci.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#include <asm/rtas.h>
+#include <asm/pci_dma.h>
+#include <asm/dma.h>
+#include <asm/ppcdebug.h>
+#include <asm/vio.h>
+#include <asm/hvcall.h>
+#include <linux/mm.h>
+#include "open_pic.h" 	/* temporary, until we merge large irq support */
+
+extern struct TceTable *build_tce_table(struct TceTable *tbl);
+
+extern dma_addr_t get_tces(struct TceTable *, unsigned order,
+			   void *page, unsigned numPages, int direction);
+extern void tce_free(struct TceTable *tbl, dma_addr_t dma_addr,
+		     unsigned order, unsigned num_pages);
+
+
+static struct vio_bus vio_bus;
+static LIST_HEAD(registered_vio_drivers);
+int vio_num_address_cells;
+EXPORT_SYMBOL(vio_num_address_cells);
+
+/* TODO:
+ *   really fit into driver model (see include/linux/device.h)
+ *   locking around list accesses
+ */
+
+/**
+ * vio_register_driver: - Register a new vio driver
+ * @drv:	The vio_driver structure to be registered.
+ *
+ * Adds the driver structure to the list of registered drivers
+ * Returns the number of vio devices which were claimed by the driver
+ * during registration.  The driver remains registered even if the
+ * return value is zero.
+ */
+int vio_register_driver(struct vio_driver *drv)
+{
+	int count = 0;
+	struct vio_dev *dev;
+
+	printk(KERN_DEBUG "%s: driver %s/%s registering\n", __FUNCTION__,
+		drv->id_table[0].type, drv->id_table[0].type);
+
+	/* find matching devices not already claimed by other drivers and pass
+	 * them to probe() */
+	list_for_each_entry(dev, &vio_bus.devices, devices_list) {
+		const struct vio_device_id* id;
+
+		if (dev->driver)
+			continue; /* this device is already owned */
+
+		id = vio_match_device(drv->id_table, dev);
+		if (drv && id) {
+			if (0 == drv->probe(dev, id)) {
+				printk(KERN_DEBUG "  took device %p\n", dev);
+				dev->driver = drv;
+				count++;
+			}
+		}
+	}
+
+	list_add_tail(&drv->node, &registered_vio_drivers);
+
+	return count;
+}
+EXPORT_SYMBOL(vio_register_driver);
+
+/**
+ * vio_unregister_driver - Remove registration of vio driver.
+ * @driver:	The vio_driver struct to be removed form registration
+ *
+ * Searches for devices that are assigned to the driver and calls
+ * driver->remove() for each one.  Removes the driver from the list
+ * of registered drivers.  Returns the number of devices that were
+ * assigned to that driver.
+ */
+int vio_unregister_driver(struct vio_driver *driver)
+{
+	struct vio_dev *dev;
+	int devices_found = 0;
+
+	list_for_each_entry(dev, &vio_bus.devices, devices_list) {
+		if (dev->driver == driver) {
+			driver->remove(dev);
+			dev->driver = NULL;
+			devices_found++;
+		}
+	}
+
+	list_del(&driver->node);
+
+	return devices_found;
+}
+EXPORT_SYMBOL(vio_unregister_driver);
+
+/**
+ * vio_match_device: - Tell if a VIO device has a matching VIO device id structure.
+ * @ids: 	array of VIO device id structures to search in
+ * @dev: 	the VIO device structure to match against
+ *
+ * Used by a driver to check whether a VIO device present in the
+ * system is in its list of supported devices. Returns the matching
+ * vio_device_id structure or NULL if there is no match.
+ */
+const struct vio_device_id *
+vio_match_device(const struct vio_device_id *ids, const struct vio_dev *dev)
+{
+	while (ids->type) {
+		if ((strncmp(dev->archdata->type, ids->type, strlen(ids->type)) == 0) &&
+			device_is_compatible((struct device_node*)dev->archdata, ids->compat))
+			return ids;
+		ids++;
+	}
+	return NULL;
+}
+
+/**
+ * vio_bus_init: - Initialize the virtual IO bus
+ */
+int __init
+vio_bus_init(void)
+{
+	struct device_node *node_vroot, *node_vdev;
+
+	INIT_LIST_HEAD(&vio_bus.devices);
+
+	/*
+	 * Create device node entries for each virtual device
+	 * identified in the device tree.
+	 * Functionally takes the place of pci_scan_bus
+	 */
+	node_vroot = find_devices("vdevice");
+	if ((node_vroot == NULL) || (node_vroot->child == NULL)) {
+		printk(KERN_INFO "VIO: missing or empty /vdevice node; no virtual IO"
+			" devices present.\n");
+		return 0;
+	}
+
+	vio_num_address_cells = prom_n_addr_cells(node_vroot->child);
+
+	for (node_vdev = node_vroot->child;
+			node_vdev != NULL;
+			node_vdev = node_vdev->sibling) {
+		printk(KERN_DEBUG "%s: processing %p\n", __FUNCTION__, node_vdev);
+
+		vio_register_device(node_vdev);
+	}
+
+	return 0;
+}
+
+__initcall(vio_bus_init);
+
+
+/**
+ * vio_probe_device - attach dev to appropriate driver
+ * @dev:	device to find a driver for
+ *
+ * Walks the list of registered VIO drivers looking for one to take this
+ * device.
+ *
+ * Returns a pointer to the matched driver or NULL if driver is not
+ * found.
+ */
+struct vio_driver * __devinit vio_probe_device(struct vio_dev* dev)
+{
+	struct vio_driver *driver;
+
+	list_for_each_entry(driver, &registered_vio_drivers, node) {
+		const struct vio_device_id* id;
+
+		id = vio_match_device(driver->id_table, dev);
+		if (id && (0 < driver->probe(dev, id))) {
+			printk(KERN_DEBUG "%s: driver %s/%s took device %p\n",
+				__FUNCTION__, id->type, id->compat, dev);
+			dev->driver = driver;
+			return driver;
+		}
+	}
+
+	printk(KERN_DEBUG "%s: device %p found no driver\n", __FUNCTION__, dev);
+	return NULL;
+}
+
+/**
+ * vio_register_device: - Register a new vio device.
+ * @archdata:	The OF node for this device.
+ *
+ * Creates and initializes a vio_dev structure from the data in
+ * node_vdev (archdata) and adds it to the list of virtual devices.
+ * Returns a pointer to the created vio_dev or NULL if node has
+ * NULL device_type or compatible fields.
+ */
+struct vio_dev * __devinit vio_register_device(struct device_node *node_vdev)
+{
+	struct vio_dev *dev;
+	unsigned int *unit_address;
+	unsigned int *irq_p;
+
+	/* guarantee all vio_devs have 'device_type' field*/
+	if ((NULL == node_vdev->type)) {
+		printk(KERN_WARNING
+			"%s: node %s missing 'device_type'\n", __FUNCTION__,
+			node_vdev->name ? node_vdev->name : "<unknown>");
+		return NULL;
+	}
+
+	unit_address = (unsigned int *)get_property(node_vdev, "reg", NULL);
+	if (!unit_address) {
+		printk(KERN_WARNING "%s: node %s missing 'reg'\n", __FUNCTION__,
+			node_vdev->name ? node_vdev->name : "<unknown>");
+		return NULL;
+	}
+
+	/* allocate a vio_dev for this node */
+	dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+	if (!dev)
+		return NULL;
+	memset(dev, 0, sizeof(*dev));
+
+	dev->archdata = (void*)of_node_get(node_vdev);
+	dev->bus = &vio_bus;
+	dev->unit_address = *unit_address;
+	dev->tce_table = vio_build_tce_table(dev);
+
+	irq_p = (unsigned int *) get_property(node_vdev, "interrupts", 0);
+	if(irq_p) {
+		dev->irq = openpic_to_irq(virt_irq_create_mapping(*irq_p));
+	} else {
+		dev->irq = (unsigned int) -1;
+	}
+
+	list_add_tail(&dev->devices_list, &vio_bus.devices);
+
+	vio_probe_device(dev); /* finally, assign it to a driver */
+
+	return dev;
+}
+EXPORT_SYMBOL(vio_register_device);
+
+int __devinit vio_unregister_device(struct vio_dev *dev)
+{
+	list_del(&dev->devices_list);
+	of_node_put(dev->archdata);
+
+	return 0;
+}
+EXPORT_SYMBOL(vio_unregister_device);
+
+/**
+ * vio_get_attribute: - get attribute for virtual device
+ * @vdev:	The vio device to get property.
+ * @which:	The property/attribute to be extracted.
+ * @length:	Pointer to length of returned data size (unused if NULL).
+ *
+ * Calls prom.c's get_property() to return the value of the
+ * attribute specified by the preprocessor constant @which
+*/
+const void * vio_get_attribute(struct vio_dev *vdev, void* which, int* length)
+{
+	return get_property((struct device_node *)vdev->archdata, (char*)which, length);
+}
+EXPORT_SYMBOL(vio_get_attribute);
+
+/**
+ * vio_build_tce_table: - gets the dma information from OF and builds the TCE tree.
+ * @dev: the virtual device.
+ *
+ * Returns a pointer to the built tce tree, or NULL if it can't
+ * find property.
+*/
+struct TceTable * vio_build_tce_table(struct vio_dev *dev)
+{
+	unsigned int *dma_window;
+	struct TceTable *newTceTable;
+	unsigned long offset;
+	unsigned long size;
+	int dma_window_property_size;
+
+	dma_window = (unsigned int *) get_property((struct device_node *)dev->archdata, "ibm,my-dma-window", &dma_window_property_size);
+	if(!dma_window) {
+		return NULL;
+	}
+
+	newTceTable = (struct TceTable *) kmalloc(sizeof(struct TceTable), GFP_KERNEL);
+
+	/* RPA docs say that #address-cells is always 1 for virtual
+		devices, but some older boxes' OF returns 2.  This should
+		be removed by GA, unless there is legacy OFs that still
+		have 2 for #address-cells */
+	size = ((dma_window[1+vio_num_address_cells]
+		>> PAGE_SHIFT) << 3) >> PAGE_SHIFT;
+
+	/* This is just an ugly kludge. Remove as soon as the OF for all
+	machines actually follow the spec and encodes the offset field
+	as phys-encode (that is, #address-cells wide)*/
+	if (dma_window_property_size == 12) {
+		size = ((dma_window[1] >> PAGE_SHIFT) << 3) >> PAGE_SHIFT;
+	} else if (dma_window_property_size == 20) {
+		size = ((dma_window[4] >> PAGE_SHIFT) << 3) >> PAGE_SHIFT;
+	} else {
+		printk(KERN_WARNING "vio_build_tce_table: Invalid size of ibm,my-dma-window=%i, using 0x80 for size\n", dma_window_property_size);
+		size = 0x80;
+	}
+
+	/*  There should be some code to extract the phys-encoded offset
+		using prom_n_addr_cells(). However, according to a comment
+		on earlier versions, it's always zero, so we don't bother */
+	offset = dma_window[1] >>  PAGE_SHIFT;
+
+	/* TCE table size - measured in units of pages of tce table */
+	newTceTable->size = size;
+	/* offset for VIO should always be 0 */
+	newTceTable->startOffset = offset;
+	newTceTable->busNumber   = 0;
+	newTceTable->index       = (unsigned long)dma_window[0];
+	newTceTable->tceType     = TCE_VB;
+
+	return build_tce_table(newTceTable);
+}
+
+int vio_enable_interrupts(struct vio_dev *dev)
+{
+	int rc = h_vio_signal(dev->unit_address, VIO_IRQ_ENABLE);
+	if (rc != H_Success) {
+		printk(KERN_ERR "vio: Error 0x%x enabling interrupts\n", rc);
+	}
+	return rc;
+}
+EXPORT_SYMBOL(vio_enable_interrupts);
+
+int vio_disable_interrupts(struct vio_dev *dev)
+{
+	int rc = h_vio_signal(dev->unit_address, VIO_IRQ_DISABLE);
+	if (rc != H_Success) {
+		printk(KERN_ERR "vio: Error 0x%x disabling interrupts\n", rc);
+	}
+	return rc;
+}
+EXPORT_SYMBOL(vio_disable_interrupts);
+
+
+dma_addr_t vio_map_single(struct vio_dev *dev, void *vaddr,
+			  size_t size, int direction )
+{
+	struct TceTable * tbl;
+	dma_addr_t dma_handle = NO_TCE;
+	unsigned long uaddr;
+	unsigned order, nPages;
+
+	if(direction == PCI_DMA_NONE) BUG();
+
+	uaddr = (unsigned long)vaddr;
+	nPages = PAGE_ALIGN( uaddr + size ) - ( uaddr & PAGE_MASK );
+	order = get_order( nPages & PAGE_MASK );
+	nPages >>= PAGE_SHIFT;
+
+ 	/* Client asked for way to much space.  This is checked later anyway */
+	/* It is easier to debug here for the drivers than in the tce tables.*/
+ 	if(order >= NUM_TCE_LEVELS) {
+ 		printk("VIO_DMA: vio_map_single size to large: 0x%lx \n",size);
+ 		return NO_TCE;
+ 	}
+
+	tbl = dev->tce_table;
+
+	if(tbl) {
+		dma_handle = get_tces(tbl, order, vaddr, nPages, direction);
+		dma_handle |= (uaddr & ~PAGE_MASK);
+	}
+
+	return dma_handle;
+}
+EXPORT_SYMBOL(vio_map_single);
+
+void vio_unmap_single(struct vio_dev *dev, dma_addr_t dma_handle,
+		      size_t size, int direction)
+{
+	struct TceTable * tbl;
+	unsigned order, nPages;
+
+	if (direction == PCI_DMA_NONE) BUG();
+
+	nPages = PAGE_ALIGN( dma_handle + size ) - ( dma_handle & PAGE_MASK );
+	order = get_order( nPages & PAGE_MASK );
+	nPages >>= PAGE_SHIFT;
+
+ 	/* Client asked for way to much space.  This is checked later anyway */
+	/* It is easier to debug here for the drivers than in the tce tables.*/
+ 	if(order >= NUM_TCE_LEVELS) {
+ 		printk("VIO_DMA: vio_unmap_single 0x%lx size to large: 0x%lx \n",(unsigned long)dma_handle,(unsigned long)size);
+ 		return;
+ 	}
+
+	tbl = dev->tce_table;
+	if(tbl) tce_free(tbl, dma_handle, order, nPages);
+}
+EXPORT_SYMBOL(vio_unmap_single);
+
+int vio_map_sg(struct vio_dev *vdev, struct scatterlist *sglist, int nelems,
+	       int direction)
+{
+	int i;
+
+	for (i = 0; i < nelems; i++) {
+
+		/* 2.4 scsi scatterlists use address field.
+		   Not sure about other subsystems. */
+		void *vaddr;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0)
+		if (sglist->address)
+			vaddr = sglist->address;
+		else
+#endif
+			vaddr = page_address(sglist->page) + sglist->offset;
+
+		sglist->dma_address = vio_map_single(vdev, vaddr,
+						     sglist->length,
+						     direction);
+		sglist->dma_length = sglist->length;
+		sglist++;
+	}
+
+	return nelems;
+}
+EXPORT_SYMBOL(vio_map_sg);
+
+void vio_unmap_sg(struct vio_dev *vdev, struct scatterlist *sglist, int nelems,
+		  int direction)
+{
+	while (nelems--) {
+		vio_unmap_single(vdev, sglist->dma_address,
+				 sglist->dma_length, direction);
+		sglist++;
+	}
+}
+
+void *vio_alloc_consistent(struct vio_dev *dev, size_t size,
+			   dma_addr_t *dma_handle)
+{
+	struct TceTable * tbl;
+	void *ret = NULL;
+	unsigned order, nPages;
+	dma_addr_t tce;
+
+	size = PAGE_ALIGN(size);
+	order = get_order(size);
+	nPages = 1 << order;
+
+ 	/* Client asked for way to much space.  This is checked later anyway */
+	/* It is easier to debug here for the drivers than in the tce tables.*/
+ 	if(order >= NUM_TCE_LEVELS) {
+ 		printk("VIO_DMA: vio_alloc_consistent size to large: 0x%lx \n",size);
+ 		return (void *)NO_TCE;
+ 	}
+
+	tbl = dev->tce_table;
+
+	if ( tbl ) {
+		/* Alloc enough pages (and possibly more) */
+		ret = (void *)__get_free_pages( GFP_ATOMIC, order );
+		if ( ret ) {
+			/* Page allocation succeeded */
+			memset(ret, 0, nPages << PAGE_SHIFT);
+			/* Set up tces to cover the allocated range */
+			tce = get_tces( tbl, order, ret, nPages, PCI_DMA_BIDIRECTIONAL );
+			if ( tce == NO_TCE ) {
+				PPCDBG(PPCDBG_TCE, "vio_alloc_consistent: get_tces failed\n" );
+				free_pages( (unsigned long)ret, order );
+				ret = NULL;
+			}
+			else
+				{
+					*dma_handle = tce;
+				}
+		}
+		else PPCDBG(PPCDBG_TCE, "vio_alloc_consistent: __get_free_pages failed for order = %d\n", order);
+	}
+	else PPCDBG(PPCDBG_TCE, "vio_alloc_consistent: get_tce_table failed for 0x%016lx\n", dev);
+
+	PPCDBG(PPCDBG_TCE, "\tvio_alloc_consistent: dma_handle = 0x%16.16lx\n", *dma_handle);
+	PPCDBG(PPCDBG_TCE, "\tvio_alloc_consistent: return     = 0x%16.16lx\n", ret);
+	return ret;
+}
+EXPORT_SYMBOL(vio_alloc_consistent);
+
+void vio_free_consistent(struct vio_dev *dev, size_t size,
+			 void *vaddr, dma_addr_t dma_handle)
+{
+	struct TceTable * tbl;
+	unsigned order, nPages;
+
+	PPCDBG(PPCDBG_TCE, "vio_free_consistent:\n");
+	PPCDBG(PPCDBG_TCE, "\tdev = 0x%16.16lx, size = 0x%16.16lx, dma_handle = 0x%16.16lx, vaddr = 0x%16.16lx\n", dev, size, dma_handle, vaddr);
+
+	size = PAGE_ALIGN(size);
+	order = get_order(size);
+	nPages = 1 << order;
+
+ 	/* Client asked for way to much space.  This is checked later anyway */
+	/* It is easier to debug here for the drivers than in the tce tables.*/
+ 	if(order >= NUM_TCE_LEVELS) {
+ 		printk("PCI_DMA: pci_free_consistent size to large: 0x%lx \n",size);
+ 		return;
+ 	}
+
+	tbl = dev->tce_table;
+
+	if ( tbl ) {
+		tce_free(tbl, dma_handle, order, nPages);
+		free_pages( (unsigned long)vaddr, order );
+	}
+}
+EXPORT_SYMBOL(vio_free_consistent);
+
+EXPORT_SYMBOL(plpar_hcall_norets);
+EXPORT_SYMBOL(plpar_hcall_8arg_2ret);
diff -puN /dev/null arch/ppc64/kernel/viopath.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/ppc64/kernel/viopath.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,757 @@
+/* -*- linux-c -*-
+ *  arch/ppc64/kernel/viopath.c
+ *
+ *  iSeries Virtual I/O Message Path code
+ *
+ *  Authors: Dave Boutcher <boutcher@us.ibm.com>
+ *           Ryan Arnold <ryanarn@us.ibm.com>
+ *           Colin Devilbiss <devilbis@us.ibm.com>
+ *
+ * (C) Copyright 2000-2003 IBM Corporation
+ *
+ * This code is used by the iSeries virtual disk, cd,
+ * tape, and console to communicate with OS/400 in another
+ * partition.
+ *
+ * This program is free software;  you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) anyu later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 <asm/uaccess.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/vmalloc.h>
+#include <linux/string.h>
+#include <linux/proc_fs.h>
+#include <linux/pci.h>
+#include <linux/wait.h>
+
+#include <asm/hardirq.h>	/* for is_atomic */
+
+#include <asm/iSeries/LparData.h>
+#include <asm/iSeries/HvLpEvent.h>
+#include <asm/iSeries/HvLpConfig.h>
+#include <asm/iSeries/HvCallCfg.h>
+#include <asm/iSeries/mf.h>
+#include <asm/iSeries/iSeries_proc.h>
+#include <asm/iSeries/vio.h>
+
+extern struct pci_dev *iSeries_vio_dev;
+
+/* Status of the path to each other partition in the system.
+ * This is overkill, since we will only ever establish connections
+ * to our hosting partition and the primary partition on the system.
+ * But this allows for other support in the future.
+ */
+static struct viopathStatus {
+	int isOpen:1;		/* Did we open the path?            */
+	int isActive:1;		/* Do we have a mon msg outstanding */
+	int users[VIO_MAX_SUBTYPES];
+	HvLpInstanceId mSourceInst;
+	HvLpInstanceId mTargetInst;
+	int numberAllocated;
+} viopathStatus[HVMAXARCHITECTEDLPS];
+
+static spinlock_t statuslock = SPIN_LOCK_UNLOCKED;
+
+/*
+ * For each kind of event we allocate a buffer that is
+ * guaranteed not to cross a page boundary
+ */
+static unsigned char event_buffer[VIO_MAX_SUBTYPES * 256] __page_aligned;
+static atomic_t event_buffer_available[VIO_MAX_SUBTYPES];
+static int event_buffer_initialised;
+
+static void handleMonitorEvent(struct HvLpEvent *event);
+
+/*
+ * We use this structure to handle asynchronous responses.  The caller
+ * blocks on the semaphore and the handler posts the semaphore.  However,
+ * if in_atomic() is true in the caller, then wait_atomic is used ...
+ */
+struct doneAllocParms_t {
+	struct semaphore *sem;
+	int number;
+	atomic_t *wait_atomic;
+	int used_wait_atomic;
+};
+
+/* Put a sequence number in each mon msg.  The value is not
+ * important.  Start at something other than 0 just for
+ * readability.  wrapping this is ok.
+ */
+static u8 viomonseq = 22;
+
+/* Our hosting logical partition.  We get this at startup
+ * time, and different modules access this variable directly.
+ */
+HvLpIndex viopath_hostLp = 0xff;	/* HvLpIndexInvalid */
+EXPORT_SYMBOL(viopath_hostLp);
+HvLpIndex viopath_ourLp = 0xff;
+EXPORT_SYMBOL(viopath_ourLp);
+
+/* For each kind of incoming event we set a pointer to a
+ * routine to call.
+ */
+static vio_event_handler_t *vio_handler[VIO_MAX_SUBTYPES];
+
+static unsigned char e2a(unsigned char x)
+{
+	switch (x) {
+	case 0xF0:
+		return '0';
+	case 0xF1:
+		return '1';
+	case 0xF2:
+		return '2';
+	case 0xF3:
+		return '3';
+	case 0xF4:
+		return '4';
+	case 0xF5:
+		return '5';
+	case 0xF6:
+		return '6';
+	case 0xF7:
+		return '7';
+	case 0xF8:
+		return '8';
+	case 0xF9:
+		return '9';
+	case 0xC1:
+		return 'A';
+	case 0xC2:
+		return 'B';
+	case 0xC3:
+		return 'C';
+	case 0xC4:
+		return 'D';
+	case 0xC5:
+		return 'E';
+	case 0xC6:
+		return 'F';
+	case 0xC7:
+		return 'G';
+	case 0xC8:
+		return 'H';
+	case 0xC9:
+		return 'I';
+	case 0xD1:
+		return 'J';
+	case 0xD2:
+		return 'K';
+	case 0xD3:
+		return 'L';
+	case 0xD4:
+		return 'M';
+	case 0xD5:
+		return 'N';
+	case 0xD6:
+		return 'O';
+	case 0xD7:
+		return 'P';
+	case 0xD8:
+		return 'Q';
+	case 0xD9:
+		return 'R';
+	case 0xE2:
+		return 'S';
+	case 0xE3:
+		return 'T';
+	case 0xE4:
+		return 'U';
+	case 0xE5:
+		return 'V';
+	case 0xE6:
+		return 'W';
+	case 0xE7:
+		return 'X';
+	case 0xE8:
+		return 'Y';
+	case 0xE9:
+		return 'Z';
+	}
+	return ' ';
+}
+
+/* Handle reads from the proc file system
+ */
+static int proc_read(char *buf, char **start, off_t offset,
+		     int blen, int *eof, void *data)
+{
+	HvLpEvent_Rc hvrc;
+	DECLARE_MUTEX_LOCKED(Semaphore);
+	dma_addr_t dmaa =
+	    pci_map_single(iSeries_vio_dev, buf, PAGE_SIZE,
+			   PCI_DMA_FROMDEVICE);
+	int len = PAGE_SIZE;
+
+	if (len > blen)
+		len = blen;
+
+	memset(buf, 0x00, len);
+	hvrc = HvCallEvent_signalLpEventFast(viopath_hostLp,
+			HvLpEvent_Type_VirtualIo,
+			viomajorsubtype_config | vioconfigget,
+			HvLpEvent_AckInd_DoAck, HvLpEvent_AckType_ImmediateAck,
+			viopath_sourceinst(viopath_hostLp),
+			viopath_targetinst(viopath_hostLp),
+			(u64)(unsigned long)&Semaphore, VIOVERSION << 16,
+			((u64)dmaa) << 32, len, 0, 0);
+	if (hvrc != HvLpEvent_Rc_Good)
+		printk("viopath hv error on op %d\n", (int) hvrc);
+
+	down(&Semaphore);
+
+	pci_unmap_single(iSeries_vio_dev, dmaa, PAGE_SIZE,
+			 PCI_DMA_FROMDEVICE);
+
+	sprintf(buf + strlen(buf), "SRLNBR=");
+	buf[strlen(buf)] = e2a(xItExtVpdPanel.mfgID[2]);
+	buf[strlen(buf)] = e2a(xItExtVpdPanel.mfgID[3]);
+	buf[strlen(buf)] = e2a(xItExtVpdPanel.systemSerial[1]);
+	buf[strlen(buf)] = e2a(xItExtVpdPanel.systemSerial[2]);
+	buf[strlen(buf)] = e2a(xItExtVpdPanel.systemSerial[3]);
+	buf[strlen(buf)] = e2a(xItExtVpdPanel.systemSerial[4]);
+	buf[strlen(buf)] = e2a(xItExtVpdPanel.systemSerial[5]);
+	buf[strlen(buf)] = '\n';
+	*eof = 1;
+	return strlen(buf);
+}
+
+/* Handle writes to our proc file system
+ */
+static int proc_write(struct file *file, const char *buffer,
+		      unsigned long count, void *data)
+{
+	/* Doesn't do anything today!!!
+	 */
+	return count;
+}
+
+/* setup our proc file system entries
+ */
+static void vio_proc_init(struct proc_dir_entry *iSeries_proc)
+{
+	struct proc_dir_entry *ent;
+	ent = create_proc_entry("config", S_IFREG | S_IRUSR, iSeries_proc);
+	if (!ent)
+		return;
+	ent->nlink = 1;
+	ent->data = NULL;
+	ent->read_proc = proc_read;
+	ent->write_proc = proc_write;
+}
+
+/* See if a given LP is active.  Allow for invalid lps to be passed in
+ * and just return invalid
+ */
+int viopath_isactive(HvLpIndex lp)
+{
+	if (lp == HvLpIndexInvalid)
+		return 0;
+	if (lp < HVMAXARCHITECTEDLPS)
+		return viopathStatus[lp].isActive;
+	else
+		return 0;
+}
+EXPORT_SYMBOL(viopath_isactive);
+
+/*
+ * We cache the source and target instance ids for each
+ * partition.  
+ */
+HvLpInstanceId viopath_sourceinst(HvLpIndex lp)
+{
+	return viopathStatus[lp].mSourceInst;
+}
+EXPORT_SYMBOL(viopath_sourceinst);
+
+HvLpInstanceId viopath_targetinst(HvLpIndex lp)
+{
+	return viopathStatus[lp].mTargetInst;
+}
+EXPORT_SYMBOL(viopath_targetinst);
+
+/*
+ * Send a monitor message.  This is a message with the acknowledge
+ * bit on that the other side will NOT explicitly acknowledge.  When
+ * the other side goes down, the hypervisor will acknowledge any
+ * outstanding messages....so we will know when the other side dies.
+ */
+static void sendMonMsg(HvLpIndex remoteLp)
+{
+	HvLpEvent_Rc hvrc;
+
+	viopathStatus[remoteLp].mSourceInst =
+		HvCallEvent_getSourceLpInstanceId(remoteLp,
+				HvLpEvent_Type_VirtualIo);
+	viopathStatus[remoteLp].mTargetInst =
+		HvCallEvent_getTargetLpInstanceId(remoteLp,
+				HvLpEvent_Type_VirtualIo);
+
+	/*
+	 * Deliberately ignore the return code here.  if we call this
+	 * more than once, we don't care.
+	 */
+	vio_setHandler(viomajorsubtype_monitor, handleMonitorEvent);
+
+	hvrc = HvCallEvent_signalLpEventFast(remoteLp, HvLpEvent_Type_VirtualIo,
+			viomajorsubtype_monitor, HvLpEvent_AckInd_DoAck,
+			HvLpEvent_AckType_DeferredAck,
+			viopathStatus[remoteLp].mSourceInst,
+			viopathStatus[remoteLp].mTargetInst,
+			viomonseq++, 0, 0, 0, 0, 0);
+
+	if (hvrc == HvLpEvent_Rc_Good)
+		viopathStatus[remoteLp].isActive = 1;
+	else {
+		printk(KERN_WARNING_VIO "could not connect to partition %d\n",
+				remoteLp);
+		viopathStatus[remoteLp].isActive = 0;
+	}
+}
+
+static void handleMonitorEvent(struct HvLpEvent *event)
+{
+	HvLpIndex remoteLp;
+	int i;
+
+	/*
+	 * This handler is _also_ called as part of the loop
+	 * at the end of this routine, so it must be able to
+	 * ignore NULL events...
+	 */
+	if (!event)
+		return;
+
+	/*
+	 * First see if this is just a normal monitor message from the
+	 * other partition
+	 */
+	if (event->xFlags.xFunction == HvLpEvent_Function_Int) {
+		remoteLp = event->xSourceLp;
+		if (!viopathStatus[remoteLp].isActive)
+			sendMonMsg(remoteLp);
+		return;
+	}
+
+	/*
+	 * This path is for an acknowledgement; the other partition
+	 * died
+	 */
+	remoteLp = event->xTargetLp;
+	if ((event->xSourceInstanceId != viopathStatus[remoteLp].mSourceInst) ||
+	    (event->xTargetInstanceId != viopathStatus[remoteLp].mTargetInst)) {
+		printk(KERN_WARNING_VIO "ignoring ack....mismatched instances\n");
+		return;
+	}
+
+	printk(KERN_WARNING_VIO "partition %d ended\n", remoteLp);
+
+	viopathStatus[remoteLp].isActive = 0;
+
+	/*
+	 * For each active handler, pass them a NULL
+	 * message to indicate that the other partition
+	 * died
+	 */
+	for (i = 0; i < VIO_MAX_SUBTYPES; i++) {
+		if (vio_handler[i] != NULL)
+			(*vio_handler[i])(NULL);
+	}
+}
+
+int vio_setHandler(int subtype, vio_event_handler_t *beh)
+{
+	subtype = subtype >> VIOMAJOR_SUBTYPE_SHIFT;
+	if ((subtype < 0) || (subtype >= VIO_MAX_SUBTYPES))
+		return -EINVAL;
+	if (vio_handler[subtype] != NULL)
+		return -EBUSY;
+	vio_handler[subtype] = beh;
+	return 0;
+}
+EXPORT_SYMBOL(vio_setHandler);
+
+int vio_clearHandler(int subtype)
+{
+	subtype = subtype >> VIOMAJOR_SUBTYPE_SHIFT;
+	if ((subtype < 0) || (subtype >= VIO_MAX_SUBTYPES))
+		return -EINVAL;
+	if (vio_handler[subtype] == NULL)
+		return -EAGAIN;
+	vio_handler[subtype] = NULL;
+	return 0;
+}
+EXPORT_SYMBOL(vio_clearHandler);
+
+static void handleConfig(struct HvLpEvent *event)
+{
+	if (!event)
+		return;
+	if (event->xFlags.xFunction == HvLpEvent_Function_Int) {
+		printk(KERN_WARNING_VIO
+		       "unexpected config request from partition %d",
+		       event->xSourceLp);
+
+		if ((event->xFlags.xFunction == HvLpEvent_Function_Int) &&
+		    (event->xFlags.xAckInd == HvLpEvent_AckInd_DoAck)) {
+			event->xRc = HvLpEvent_Rc_InvalidSubtype;
+			HvCallEvent_ackLpEvent(event);
+		}
+		return;
+	}
+
+	up((struct semaphore *)event->xCorrelationToken);
+}
+
+/*
+ * Initialization of the hosting partition
+ */
+void vio_set_hostlp(void)
+{
+	/*
+	 * If this has already been set then we DON'T want to either change
+	 * it or re-register the proc file system
+	 */
+	if (viopath_hostLp != HvLpIndexInvalid)
+		return;
+
+	/*
+	 * Figure out our hosting partition.  This isn't allowed to change
+	 * while we're active
+	 */
+	viopath_ourLp = HvLpConfig_getLpIndex();
+	viopath_hostLp = HvCallCfg_getHostingLpIndex(viopath_ourLp);
+
+	/* If we have a valid hosting LP, create a proc file system entry
+	 * for config information
+	 */
+	if (viopath_hostLp != HvLpIndexInvalid) {
+		iSeries_proc_callback(&vio_proc_init);
+		vio_setHandler(viomajorsubtype_config, handleConfig);
+	}
+}
+EXPORT_SYMBOL(vio_set_hostlp);
+
+static void vio_handleEvent(struct HvLpEvent *event, struct pt_regs *regs)
+{
+	HvLpIndex remoteLp;
+	int subtype = (event->xSubtype & VIOMAJOR_SUBTYPE_MASK)
+		>> VIOMAJOR_SUBTYPE_SHIFT;
+
+	if (event->xFlags.xFunction == HvLpEvent_Function_Int) {
+		remoteLp = event->xSourceLp;
+		/*
+		 * The isActive is checked because if the hosting partition
+		 * went down and came back up it would not be active but it
+		 * would have different source and target instances, in which
+		 * case we'd want to reset them.  This case really protects
+		 * against an unauthorized active partition sending interrupts
+		 * or acks to this linux partition.
+		 */
+		if (viopathStatus[remoteLp].isActive
+		    && (event->xSourceInstanceId !=
+			viopathStatus[remoteLp].mTargetInst)) {
+			printk(KERN_WARNING_VIO
+			       "message from invalid partition. "
+			       "int msg rcvd, source inst (%d) doesnt match (%d)\n",
+			       viopathStatus[remoteLp].mTargetInst,
+			       event->xSourceInstanceId);
+			return;
+		}
+
+		if (viopathStatus[remoteLp].isActive
+		    && (event->xTargetInstanceId !=
+			viopathStatus[remoteLp].mSourceInst)) {
+			printk(KERN_WARNING_VIO
+			       "message from invalid partition. "
+			       "int msg rcvd, target inst (%d) doesnt match (%d)\n",
+			       viopathStatus[remoteLp].mSourceInst,
+			       event->xTargetInstanceId);
+			return;
+		}
+	} else {
+		remoteLp = event->xTargetLp;
+		if (event->xSourceInstanceId !=
+		    viopathStatus[remoteLp].mSourceInst) {
+			printk(KERN_WARNING_VIO
+			       "message from invalid partition. "
+			       "ack msg rcvd, source inst (%d) doesnt match (%d)\n",
+			       viopathStatus[remoteLp].mSourceInst,
+			       event->xSourceInstanceId);
+			return;
+		}
+
+		if (event->xTargetInstanceId !=
+		    viopathStatus[remoteLp].mTargetInst) {
+			printk(KERN_WARNING_VIO
+			       "message from invalid partition. "
+			       "viopath: ack msg rcvd, target inst (%d) doesnt match (%d)\n",
+			       viopathStatus[remoteLp].mTargetInst,
+			       event->xTargetInstanceId);
+			return;
+		}
+	}
+
+	if (vio_handler[subtype] == NULL) {
+		printk(KERN_WARNING_VIO
+		       "unexpected virtual io event subtype %d from partition %d\n",
+		       event->xSubtype, remoteLp);
+		/* No handler.  Ack if necessary */
+		if ((event->xFlags.xFunction == HvLpEvent_Function_Int) &&
+		    (event->xFlags.xAckInd == HvLpEvent_AckInd_DoAck)) {
+			event->xRc = HvLpEvent_Rc_InvalidSubtype;
+			HvCallEvent_ackLpEvent(event);
+		}
+		return;
+	}
+
+	/* This innocuous little line is where all the real work happens */
+	(*vio_handler[subtype])(event);
+}
+
+static void viopath_donealloc(void *parm, int number)
+{
+	struct doneAllocParms_t *parmsp = (struct doneAllocParms_t *)parm;
+
+	parmsp->number = number;
+	if (parmsp->used_wait_atomic)
+		atomic_set(parmsp->wait_atomic, 0);
+	else
+		up(parmsp->sem);
+}
+
+static int allocateEvents(HvLpIndex remoteLp, int numEvents)
+{
+	struct doneAllocParms_t parms;
+	DECLARE_MUTEX_LOCKED(Semaphore);
+	atomic_t wait_atomic;
+
+	if (in_atomic()) {
+		parms.used_wait_atomic = 1;
+		atomic_set(&wait_atomic, 1);
+		parms.wait_atomic = &wait_atomic;
+	} else {
+		parms.used_wait_atomic = 0;
+		parms.sem = &Semaphore;
+	}
+	mf_allocateLpEvents(remoteLp, HvLpEvent_Type_VirtualIo, 250,	/* It would be nice to put a real number here! */
+			    numEvents, &viopath_donealloc, &parms);
+	if (in_atomic()) {
+		while (atomic_read(&wait_atomic))
+			mb();
+	} else
+		down(&Semaphore);
+	return parms.number;
+}
+
+int viopath_open(HvLpIndex remoteLp, int subtype, int numReq)
+{
+	int i;
+	unsigned long flags;
+	int tempNumAllocated;
+
+	if ((remoteLp >= HvMaxArchitectedLps) || (remoteLp == HvLpIndexInvalid))
+		return -EINVAL;
+
+	subtype = subtype >> VIOMAJOR_SUBTYPE_SHIFT;
+	if ((subtype < 0) || (subtype >= VIO_MAX_SUBTYPES))
+		return -EINVAL;
+
+	spin_lock_irqsave(&statuslock, flags);
+
+	if (!event_buffer_initialised) {
+		for (i = 0; i < VIO_MAX_SUBTYPES; i++)
+			atomic_set(&event_buffer_available[i], 1);
+		event_buffer_initialised = 1;
+	}
+
+	viopathStatus[remoteLp].users[subtype]++;
+
+	if (!viopathStatus[remoteLp].isOpen) {
+		viopathStatus[remoteLp].isOpen = 1;
+		HvCallEvent_openLpEventPath(remoteLp, HvLpEvent_Type_VirtualIo);
+
+		/*
+		 * Don't hold the spinlock during an operation that
+		 * can sleep.
+		 */
+		spin_unlock_irqrestore(&statuslock, flags);
+		tempNumAllocated = allocateEvents(remoteLp, 1);
+		spin_lock_irqsave(&statuslock, flags);
+
+		viopathStatus[remoteLp].numberAllocated += tempNumAllocated;
+
+		if (viopathStatus[remoteLp].numberAllocated == 0) {
+			HvCallEvent_closeLpEventPath(remoteLp,
+					HvLpEvent_Type_VirtualIo);
+
+			spin_unlock_irqrestore(&statuslock, flags);
+			return -ENOMEM;
+		}
+
+		viopathStatus[remoteLp].mSourceInst =
+			HvCallEvent_getSourceLpInstanceId(remoteLp,
+					HvLpEvent_Type_VirtualIo);
+		viopathStatus[remoteLp].mTargetInst =
+			HvCallEvent_getTargetLpInstanceId(remoteLp,
+					HvLpEvent_Type_VirtualIo);
+		HvLpEvent_registerHandler(HvLpEvent_Type_VirtualIo,
+					  &vio_handleEvent);
+		sendMonMsg(remoteLp);
+		printk(KERN_INFO_VIO
+		       "Opening connection to partition %d, setting sinst %d, tinst %d\n",
+		       remoteLp, viopathStatus[remoteLp].mSourceInst,
+		       viopathStatus[remoteLp].mTargetInst);
+	}
+
+	spin_unlock_irqrestore(&statuslock, flags);
+	tempNumAllocated = allocateEvents(remoteLp, numReq);
+	spin_lock_irqsave(&statuslock, flags);
+	viopathStatus[remoteLp].numberAllocated += tempNumAllocated;
+	spin_unlock_irqrestore(&statuslock, flags);
+
+	return 0;
+}
+EXPORT_SYMBOL(viopath_open);
+
+int viopath_close(HvLpIndex remoteLp, int subtype, int numReq)
+{
+	unsigned long flags;
+	int i;
+	int numOpen;
+	struct doneAllocParms_t doneAllocParms;
+	DECLARE_MUTEX_LOCKED(Semaphore);
+
+	if ((remoteLp >= HvMaxArchitectedLps) || (remoteLp == HvLpIndexInvalid))
+		return -EINVAL;
+
+	subtype = subtype >> VIOMAJOR_SUBTYPE_SHIFT;
+	if ((subtype < 0) || (subtype >= VIO_MAX_SUBTYPES))
+		return -EINVAL;
+
+	spin_lock_irqsave(&statuslock, flags);
+	/*
+	 * If the viopath_close somehow gets called before a
+	 * viopath_open it could decrement to -1 which is a non
+	 * recoverable state so we'll prevent this from
+	 * happening.
+	 */
+	if (viopathStatus[remoteLp].users[subtype] > 0)
+		viopathStatus[remoteLp].users[subtype]--;
+
+	spin_unlock_irqrestore(&statuslock, flags);
+
+	doneAllocParms.used_wait_atomic = 0;
+	doneAllocParms.sem = &Semaphore;
+	mf_deallocateLpEvents(remoteLp, HvLpEvent_Type_VirtualIo,
+			      numReq, &viopath_donealloc, &doneAllocParms);
+	down(&Semaphore);
+
+	spin_lock_irqsave(&statuslock, flags);
+	for (i = 0, numOpen = 0; i < VIO_MAX_SUBTYPES; i++)
+		numOpen += viopathStatus[remoteLp].users[i];
+
+	if ((viopathStatus[remoteLp].isOpen) && (numOpen == 0)) {
+		printk(KERN_INFO_VIO "Closing connection to partition %d",
+				remoteLp);
+
+		HvCallEvent_closeLpEventPath(remoteLp,
+					     HvLpEvent_Type_VirtualIo);
+		viopathStatus[remoteLp].isOpen = 0;
+		viopathStatus[remoteLp].isActive = 0;
+
+		for (i = 0; i < VIO_MAX_SUBTYPES; i++)
+			atomic_set(&event_buffer_available[i], 0);
+		event_buffer_initialised = 0;
+	}
+	spin_unlock_irqrestore(&statuslock, flags);
+	return 0;
+}
+EXPORT_SYMBOL(viopath_close);
+
+void *vio_get_event_buffer(int subtype)
+{
+	subtype = subtype >> VIOMAJOR_SUBTYPE_SHIFT;
+	if ((subtype < 0) || (subtype >= VIO_MAX_SUBTYPES))
+		return NULL;
+
+	if (atomic_dec_if_positive(&event_buffer_available[subtype]) == 0)
+		return &event_buffer[subtype * 256];
+	else
+		return NULL;
+}
+EXPORT_SYMBOL(vio_get_event_buffer);
+
+void vio_free_event_buffer(int subtype, void *buffer)
+{
+	subtype = subtype >> VIOMAJOR_SUBTYPE_SHIFT;
+	if ((subtype < 0) || (subtype >= VIO_MAX_SUBTYPES)) {
+		printk(KERN_WARNING_VIO
+		       "unexpected subtype %d freeing event buffer\n",
+		       subtype);
+		return;
+	}
+
+	if (atomic_read(&event_buffer_available[subtype]) != 0) {
+		printk(KERN_WARNING_VIO
+		       "freeing unallocated event buffer, subtype %d\n",
+		       subtype);
+		return;
+	}
+
+	if (buffer != &event_buffer[subtype * 256]) {
+		printk(KERN_WARNING_VIO
+		       "freeing invalid event buffer, subtype %d\n",
+		       subtype);
+	}
+
+	atomic_set(&event_buffer_available[subtype], 1);
+}
+EXPORT_SYMBOL(vio_free_event_buffer);
+
+static const struct vio_error_entry vio_no_error =
+    { 0, 0, "Non-VIO Error" };
+static const struct vio_error_entry vio_unknown_error =
+    { 0, EIO, "Unknown Error" };
+
+static const struct vio_error_entry vio_default_errors[] = {
+	{0x0001, EIO, "No Connection"},
+	{0x0002, EIO, "No Receiver"},
+	{0x0003, EIO, "No Buffer Available"},
+	{0x0004, EBADRQC, "Invalid Message Type"},
+	{0x0000, 0, NULL},
+};
+
+const struct vio_error_entry *vio_lookup_rc(
+		const struct vio_error_entry *local_table, u16 rc)
+{
+	const struct vio_error_entry *cur;
+
+	if (!rc)
+		return &vio_no_error;
+	if (local_table)
+		for (cur = local_table; cur->rc; ++cur)
+			if (cur->rc == rc)
+				return cur;
+	for (cur = vio_default_errors; cur->rc; ++cur)
+		if (cur->rc == rc)
+			return cur;
+	return &vio_unknown_error;
+}
+EXPORT_SYMBOL(vio_lookup_rc);
diff -puN arch/ppc64/kernel/vmlinux.lds.S~linus arch/ppc64/kernel/vmlinux.lds.S
--- 25/arch/ppc64/kernel/vmlinux.lds.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/vmlinux.lds.S	2004-01-19 22:17:21.000000000 -0800
@@ -1,145 +1,146 @@
 #include <asm-generic/vmlinux.lds.h>
 
 OUTPUT_ARCH(powerpc:common64)
-/* Do we need any of these for elf?
-   __DYNAMIC = 0;    */
 jiffies = jiffies_64;
 SECTIONS
 {
-  /* Read-only sections, merged into text segment: */
-  . = + SIZEOF_HEADERS;
-  .interp : { *(.interp) }
-  .hash          : { *(.hash)		}
-  .dynsym        : { *(.dynsym)		}
-  .dynstr        : { *(.dynstr)		}
-  .rel.text      : { *(.rel.text)		}
-  .rela.text     : { *(.rela.text) 	}
-  .rel.data      : { *(.rel.data)		}
-  .rela.data     : { *(.rela.data) 	}
-  .rel.rodata    : { *(.rel.rodata) 	}
-  .rela.rodata   : { *(.rela.rodata) 	}
-  .rel.got       : { *(.rel.got)		}
-  .rela.got      : { *(.rela.got)		}
-  .rel.ctors     : { *(.rel.ctors)	}
-  .rela.ctors    : { *(.rela.ctors)	}
-  .rel.dtors     : { *(.rel.dtors)	}
-  .rela.dtors    : { *(.rela.dtors)	}
-  .rel.bss       : { *(.rel.bss)		}
-  .rela.bss      : { *(.rela.bss)		}
-  .rel.plt       : { *(.rel.plt)		}
-  .rela.plt      : { *(.rela.plt)		}
-/*  .init          : { *(.init)	} =0*/
-  .plt : { *(.plt) }
-  .text      :
-  {
-    *(.text)
-    *(.fixup)
-    *(.got1)
-  }
-  . = ALIGN(4096);
-  _etext = .;
-  PROVIDE (etext = .);
-
-  RODATA
-
-  .fini      : { *(.fini)    } =0
-  .ctors     : { *(.ctors)   }
-  .dtors     : { *(.dtors)   }
-  /* Read-write section, merged into data segment: */
-  . = (. + 0x0FFF) & 0xFFFFFFFFFFFFF000;
-  .data    :
-  {
-    *(.data)
-    *(.data1)
-    *(.sdata)
-    *(.sdata2)
-    *(.got.plt) *(.got)
-    *(.dynamic)
-    CONSTRUCTORS
-  }
-  . = ALIGN(4096);
-  _edata  =  .;
-  PROVIDE (edata = .);
+  /* Sections to be discarded. */
+  /DISCARD/ : {
+	*(.exitcall.exit)
+	}
 
-  __start___ex_table = .;
-  __ex_table : { *(__ex_table) }
-  __stop___ex_table = .;
-
-  __start___bug_table = .;
-  __bug_table : { *(__bug_table) }
-  __stop___bug_table = .;
-
-  __start___ftr_fixup = .;
-  __ftr_fixup : { *(__ftr_fixup) }
-  __stop___ftr_fixup = .;
 
-  . = ALIGN(16384);		/* init_task */
-  .data.init_task : { *(.data.init_task) }
+  /* Read-only sections, merged into text segment: */
+  .text : {
+	*(.text .text.*)
+	*(.fixup)
+	. = ALIGN(4096);
+	_etext = .;
+	}
+
+  __ex_table : {
+	__start___ex_table = .;
+	*(__ex_table)
+	__stop___ex_table = .;
+	}
+
+  __bug_table : {
+	__start___bug_table = .;
+	*(__bug_table)
+	__stop___bug_table = .;
+	}
+
+  __ftr_fixup : {
+	__start___ftr_fixup = .;
+	*(__ftr_fixup)
+	__stop___ftr_fixup = .;
+	}
 
-  . = ALIGN(4096);
-  .data.page_aligned : { *(.data.page_aligned) }
+  RODATA
 
-  . = ALIGN(128);
-  .data.cacheline_aligned : { *(.data.cacheline_aligned) }
 
   /* will be freed after init */
   . = ALIGN(4096);
   __init_begin = .;
-  .init.text : { 
+
+  .init.text : {
 	_sinittext = .;
 	*(.init.text)
 	_einittext = .;
-  }
-  .init.data : { *(.init.data) }
+	}
+
+  .init.data : {
+	*(.init.data)
+	}
+
   . = ALIGN(16);
-  __setup_start = .;
-  .init.setup : { *(.init.setup) }
-  __setup_end = .;
-  __start___param = .;
-  __param : { *(__param) }
-  __stop___param = .;
-  __initcall_start = .;
+  .init.setup : {
+	__setup_start = .;
+	*(.init.setup)
+	__setup_end = .;
+	}
+
+  __param : {
+	__start___param = .;
+	*(__param)
+	__stop___param = .;
+	}
+
   .initcall.init : {
-	*(.initcall1.init) 
-	*(.initcall2.init) 
-	*(.initcall3.init) 
-	*(.initcall4.init) 
-	*(.initcall5.init) 
-	*(.initcall6.init) 
+	__initcall_start = .;
+	*(.initcall1.init)
+	*(.initcall2.init)
+	*(.initcall3.init)
+	*(.initcall4.init)
+	*(.initcall5.init)
+	*(.initcall6.init)
 	*(.initcall7.init)
-  }
-  __initcall_end = .;
-  __con_initcall_start = .;
-  .con_initcall.init : { *(.con_initcall.init) }
-  __con_initcall_end = .;
+	__initcall_end = .;
+	}
+
+  .con_initcall.init : {
+	__con_initcall_start = .;
+	*(.con_initcall.init)
+	__con_initcall_end = .;
+	}
+
   SECURITY_INIT
+
   . = ALIGN(4096);
-  __initramfs_start = .;
-  .init.ramfs : { *(.init.ramfs) }
-  __initramfs_end = .;
-  . = ALIGN(32);
-  __per_cpu_start = .;
-  .data.percpu  : { *(.data.percpu) }
-  __per_cpu_end = .;
-  . = ALIGN(4096);
+  .init.ramfs : {
+	__initramfs_start = .;
+	*(.init.ramfs)
+	__initramfs_end = .;
+	}
+
+  .data.percpu : {
+	__per_cpu_start = .;
+	*(.data.percpu)
+	__per_cpu_end = .;
+	}
+
+  . = ALIGN(16384);
   __init_end = .;
   /* freed after init ends here */
 
-  __toc_start = .;
-  .toc : { *(.toc) }
-  . = ALIGN(4096);
-  __toc_end = .;
 
-  __bss_start = .;
-  .bss : { *(.bss) }
-  __bss_stop = .;
+  /* Read/write sections */
+  . = ALIGN(16384);
+  /* The initial task and kernel stack */
+  .data.init_task : {
+	*(.data.init_task)
+	}
+
+  .data.page_aligned : {
+	*(.data.page_aligned)
+	}
+
+  .data.cacheline_aligned : {
+	*(.data.cacheline_aligned)
+	}
+
+  .data : {
+	*(.data .data.rel* .toc1)
+	*(.opd)
+	*(.branch_lt)
+	}
+
+  .got : {
+	__toc_start = .;
+	*(.got)
+	*(.toc)
+	. = ALIGN(4096);
+	_edata = .;
+	}
+
 
   . = ALIGN(4096);
-  _end = . ;
-  PROVIDE (end = .);
+  .bss : {
+	__bss_start = .;
+	*(.bss)
+	__bss_stop = .;
+	}
 
-  /* Sections to be discarded. */
-  /DISCARD/ : {
-    *(.exitcall.exit)
-  }
+  . = ALIGN(4096);
+  _end = . ;
 }
diff -puN arch/ppc64/kernel/xics.c~linus arch/ppc64/kernel/xics.c
--- 25/arch/ppc64/kernel/xics.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/xics.c	2004-01-19 22:17:21.000000000 -0800
@@ -202,7 +202,7 @@ static void pSeriesLP_qirr_info(int n_cp
 {
 	unsigned long lpar_rc;
 
-	lpar_rc = plpar_ipi(n_cpu, value);
+	lpar_rc = plpar_ipi(get_hard_smp_processor_id(n_cpu), value);
 	if (lpar_rc != H_Success)
 		panic("bad return code qirr - rc = %lx\n", lpar_rc); 
 }
@@ -398,7 +398,7 @@ void xics_init_IRQ(void)
 	ibm_int_on  = rtas_token("ibm,int-on");
 	ibm_int_off = rtas_token("ibm,int-off");
 
-	np = find_type_devices("PowerPC-External-Interrupt-Presentation");
+	np = of_find_node_by_type(NULL, "PowerPC-External-Interrupt-Presentation");
 	if (!np) {
 		printk(KERN_WARNING "Can't find Interrupt Presentation\n");
 		udbg_printf("Can't find Interrupt Presentation\n");
@@ -433,13 +433,15 @@ nextnode:
 		if (indx >= NR_CPUS) break;
 	}
 
-	np = np->next;
+	np = of_find_node_by_type(np, "PowerPC-External-Interrupt-Presentation");
 	if ((indx < NR_CPUS) && np) goto nextnode;
 
 	/* Find the server numbers for the boot cpu. */
-	for (np = find_type_devices("cpu"); np; np = np->next) {
+	for (np = of_find_node_by_type(NULL, "cpu");
+	     np;
+	     np = of_find_node_by_type(np, "cpu")) {
 		ireg = (uint *)get_property(np, "reg", &ilen);
-		if (ireg && ireg[0] == smp_processor_id()) {
+		if (ireg && ireg[0] == hard_smp_processor_id()) {
 			ireg = (uint *)get_property(np, "ibm,ppc-interrupt-gserver#s", &ilen);
 			i = ilen / sizeof(int);
 			if (ireg && i > 0) {
@@ -449,11 +451,12 @@ nextnode:
 			break;
 		}
 	}
+	of_node_put(np);
 
 	intr_base = inodes[0].addr;
 	intr_size = (ulong)inodes[0].size;
 
-	np = find_type_devices("interrupt-controller");
+	np = of_find_node_by_type(NULL, "interrupt-controller");
 	if (!np) {
 		printk(KERN_WARNING "xics:  no ISA Interrupt Controller\n");
 		xics_irq_8259_cascade_real = -1;
@@ -467,6 +470,7 @@ nextnode:
 		}
 		xics_irq_8259_cascade_real = *ireg;
 		xics_irq_8259_cascade = virt_irq_create_mapping(xics_irq_8259_cascade_real);
+		of_node_put(np);
 	}
 
 	if (systemcfg->platform == PLATFORM_PSERIES) {
@@ -474,8 +478,8 @@ nextnode:
 		for (i = 0; i < NR_CPUS; ++i) {
 			if (!cpu_possible(i))
 				continue;
-			xics_per_cpu[i] = __ioremap((ulong)inodes[i].addr, 
-						    (ulong)inodes[i].size,
+			xics_per_cpu[i] = __ioremap((ulong)inodes[get_hard_smp_processor_id(i)].addr, 
+						    (ulong)inodes[get_hard_smp_processor_id(i)].size,
 						    _PAGE_NO_CACHE);
 		}
 #else
@@ -566,7 +570,7 @@ void xics_set_affinity(unsigned int virq
 		cpus_and(tmp, cpu_online_map, cpumask);
 		if (cpus_empty(tmp))
 			goto out;
-		newmask = first_cpu(cpumask);
+		newmask = get_hard_smp_processor_id(first_cpu(cpumask));
 	}
 
 	status = rtas_call(ibm_set_xive, 3, 1, NULL,
diff -puN arch/ppc64/kernel/XmPciLpEvent.c~linus arch/ppc64/kernel/XmPciLpEvent.c
--- 25/arch/ppc64/kernel/XmPciLpEvent.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/kernel/XmPciLpEvent.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,10 +1,10 @@
 /*
-   * File XmPciLpEvent.h created by Wayne Holm on Mon Jan 15 2001.
-   *
-   * This module handles PCI interrupt events sent by the iSeries Hypervisor.
+ * File XmPciLpEvent.h created by Wayne Holm on Mon Jan 15 2001.
+ *
+ * This module handles PCI interrupt events sent by the iSeries Hypervisor.
 */
 
-
+#include <linux/config.h>
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/threads.h>
@@ -20,13 +20,13 @@
 #include <asm/iSeries/XmPciLpEvent.h>
 #include <asm/ppcdebug.h>
 
-long Pci_Interrupt_Count = 0;
-long Pci_Event_Count     = 0;
+static long Pci_Interrupt_Count;
+static long Pci_Event_Count;
 
 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
@@ -36,14 +36,14 @@ enum XmPciLpEvent_Subtype {
 };
 
 struct XmPciLpEvent_BusInterrupt {
-	HvBusNumber		busNumber;
+	HvBusNumber	busNumber;
 	HvSubBusNumber	subBusNumber;
 };
 
 struct XmPciLpEvent_NodeInterrupt {
-	HvBusNumber		busNumber;
+	HvBusNumber	busNumber;
 	HvSubBusNumber	subBusNumber;
-	HvAgentId		deviceId;
+	HvAgentId	deviceId;
 };
 
 struct XmPciLpEvent {
@@ -53,10 +53,10 @@ struct XmPciLpEvent {
 		u64 alignData;			// Align on an 8-byte boundary
 
 		struct {
-			u32			fisr;
+			u32		fisr;
 			HvBusNumber	busNumber;
 			HvSubBusNumber	subBusNumber;
-			HvAgentId		deviceId;
+			HvAgentId	deviceId;
 		} slotInterrupt;
 
 		struct XmPciLpEvent_BusInterrupt busFailed;
@@ -70,40 +70,52 @@ struct XmPciLpEvent {
 
 };
 
-static void intReceived(struct XmPciLpEvent* eventParm, struct pt_regs* regsParm);
+static void intReceived(struct XmPciLpEvent *eventParm,
+		struct pt_regs *regsParm);
 
-static void XmPciLpEvent_handler( struct HvLpEvent* eventParm, struct pt_regs* regsParm)
+static void XmPciLpEvent_handler(struct HvLpEvent *eventParm,
+		struct pt_regs *regsParm)
 {
-	//PPCDBG(PPCDBG_BUSWALK,"XmPciLpEvent_handler, type 0x%x\n",eventParm->xType );
+#ifdef CONFIG_PCI
+#if 0
+	PPCDBG(PPCDBG_BUSWALK, "XmPciLpEvent_handler, type 0x%x\n",
+			eventParm->xType);
+#endif
 	++Pci_Event_Count;
 
-	if (eventParm && eventParm->xType == HvLpEvent_Type_PciIo) {
-		switch( eventParm->xFlags.xFunction ) {
+	if (eventParm && (eventParm->xType == HvLpEvent_Type_PciIo)) {
+		switch (eventParm->xFlags.xFunction) {
 		case HvLpEvent_Function_Int:
-			intReceived( (struct XmPciLpEvent*)eventParm, regsParm );
+			intReceived((struct XmPciLpEvent *)eventParm, regsParm);
 			break;
 		case HvLpEvent_Function_Ack:
-			printk(KERN_ERR "XmPciLpEvent.c: unexpected ack received\n");
+			printk(KERN_ERR
+				"XmPciLpEvent.c: unexpected ack received\n");
 			break;
 		default:
-			printk(KERN_ERR "XmPciLpEvent.c: unexpected event function %d\n",(int)eventParm->xFlags.xFunction);
+			printk(KERN_ERR
+				"XmPciLpEvent.c: unexpected event function %d\n",
+				(int)eventParm->xFlags.xFunction);
 			break;
 		}
-	}
-	else if (event) {
-		printk(KERN_ERR "XmPciLpEvent.c: Unrecognized PCI event type 0x%x\n",(int)eventParm->xType);
-	}
-	else {
+	} else if (eventParm)
+		printk(KERN_ERR
+			"XmPciLpEvent.c: Unrecognized PCI event type 0x%x\n",
+			(int)eventParm->xType);
+	else
 		printk(KERN_ERR "XmPciLpEvent.c: NULL event received\n");
-	}
+#endif
 }
 
-static void intReceived(struct XmPciLpEvent* eventParm, struct pt_regs* regsParm)
+static void intReceived(struct XmPciLpEvent *eventParm,
+		struct pt_regs *regsParm)
 {
 	int irq;
 
 	++Pci_Interrupt_Count;
-	//PPCDBG(PPCDBG_BUSWALK,"PCI: XmPciLpEvent.c: intReceived\n");
+#if 0
+	PPCDBG(PPCDBG_BUSWALK, "PCI: XmPciLpEvent.c: intReceived\n");
+#endif
 
 	switch (eventParm->hvLpEvent.xSubtype) {
 	case XmPciLpEvent_SlotInterrupt:
@@ -111,33 +123,45 @@ static void intReceived(struct XmPciLpEv
 		/* Dispatch the interrupt handlers for this irq */
 		ppc_irq_dispatch_handler(regsParm, irq);
 		HvCallPci_eoi(eventParm->eventData.slotInterrupt.busNumber,
-			      eventParm->eventData.slotInterrupt.subBusNumber,
-			      eventParm->eventData.slotInterrupt.deviceId);
+			eventParm->eventData.slotInterrupt.subBusNumber,
+			eventParm->eventData.slotInterrupt.deviceId);
 		break;
 		/* Ignore error recovery events for now */
 	case XmPciLpEvent_BusCreated:
-		printk(KERN_INFO "XmPciLpEvent.c: system bus %d created\n", eventParm->eventData.busCreated.busNumber);
+		printk(KERN_INFO "XmPciLpEvent.c: system bus %d created\n",
+			eventParm->eventData.busCreated.busNumber);
 		break;
 	case XmPciLpEvent_BusError:
 	case XmPciLpEvent_BusFailed:
-		printk(KERN_INFO "XmPciLpEvent.c: system bus %d failed\n", eventParm->eventData.busFailed.busNumber);
+		printk(KERN_INFO "XmPciLpEvent.c: system bus %d failed\n",
+			eventParm->eventData.busFailed.busNumber);
 		break;
 	case XmPciLpEvent_BusRecovered:
 	case XmPciLpEvent_UnQuiesceBus:
-		printk(KERN_INFO "XmPciLpEvent.c: system bus %d recovered\n", eventParm->eventData.busRecovered.busNumber);
+		printk(KERN_INFO "XmPciLpEvent.c: system bus %d recovered\n",
+			eventParm->eventData.busRecovered.busNumber);
 		break;
 	case XmPciLpEvent_NodeFailed:
 	case XmPciLpEvent_BridgeError:
-		printk(KERN_INFO "XmPciLpEvent.c: multi-adapter bridge %d/%d/%d failed\n", eventParm->eventData.nodeFailed.busNumber, eventParm->eventData.nodeFailed.subBusNumber, eventParm->eventData.nodeFailed.deviceId);
+		printk(KERN_INFO
+			"XmPciLpEvent.c: multi-adapter bridge %d/%d/%d failed\n",
+			eventParm->eventData.nodeFailed.busNumber,
+			eventParm->eventData.nodeFailed.subBusNumber,
+			eventParm->eventData.nodeFailed.deviceId);
 		break;
 	case XmPciLpEvent_NodeRecovered:
-		printk(KERN_INFO "XmPciLpEvent.c: multi-adapter bridge %d/%d/%d recovered\n", eventParm->eventData.nodeRecovered.busNumber, eventParm->eventData.nodeRecovered.subBusNumber, eventParm->eventData.nodeRecovered.deviceId);
+		printk(KERN_INFO
+			"XmPciLpEvent.c: multi-adapter bridge %d/%d/%d recovered\n",
+			eventParm->eventData.nodeRecovered.busNumber,
+			eventParm->eventData.nodeRecovered.subBusNumber,
+			eventParm->eventData.nodeRecovered.deviceId);
 		break;
 	default:
-		printk(KERN_ERR "XmPciLpEvent.c: unrecognized event subtype 0x%x\n",
-		       eventParm->hvLpEvent.xSubtype);
+		printk(KERN_ERR
+			"XmPciLpEvent.c: unrecognized event subtype 0x%x\n",
+			eventParm->hvLpEvent.xSubtype);
 		break;
-	};
+	}
 }
 
 
@@ -145,18 +169,22 @@ static void intReceived(struct XmPciLpEv
 int XmPciLpEvent_init()
 {
 	int xRc;
-	PPCDBG(PPCDBG_BUSWALK,"XmPciLpEvent_init, Register Event type 0x%04X\n",HvLpEvent_Type_PciIo);
 
-	xRc = HvLpEvent_registerHandler(HvLpEvent_Type_PciIo, &XmPciLpEvent_handler);
+	PPCDBG(PPCDBG_BUSWALK,
+			"XmPciLpEvent_init, Register Event type 0x%04X\n",
+			HvLpEvent_Type_PciIo);
+
+	xRc = HvLpEvent_registerHandler(HvLpEvent_Type_PciIo,
+			&XmPciLpEvent_handler);
 	if (xRc == 0) {
 		xRc = HvLpEvent_openPath(HvLpEvent_Type_PciIo, 0);
-		if (xRc != 0) {
-			printk(KERN_ERR "XmPciLpEvent.c: open event path failed with rc 0x%x\n", xRc);
-		}
-	}
-	else {
-		printk(KERN_ERR "XmPciLpEvent.c: register handler failed with rc 0x%x\n", xRc);
-    	}
-    return xRc;
+		if (xRc != 0)
+			printk(KERN_ERR
+				"XmPciLpEvent.c: open event path failed with rc 0x%x\n",
+				xRc);
+	} else
+		printk(KERN_ERR
+			"XmPciLpEvent.c: register handler failed with rc 0x%x\n",
+			xRc);
+	return xRc;
 }
-
diff -puN arch/ppc64/Makefile~linus arch/ppc64/Makefile
--- 25/arch/ppc64/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -15,15 +15,25 @@
 
 KERNELLOAD	:= 0xc000000000000000
 
+HAS_BIARCH      := $(shell if $(CC) -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		:= $(CC) -m64
+endif
+
 LDFLAGS		:= -m elf64ppc
 LDFLAGS_vmlinux	:= -Bstatic -e $(KERNELLOAD) -Ttext $(KERNELLOAD)
 CFLAGS		+= -msoft-float -pipe -Wno-uninitialized -mminimal-toc \
-		-mcpu=power4
-
-have_zero_bss := $(shell if $(CC) -fno-zero-initialized-in-bss -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo y; else echo n; fi)
+		   -mtraceback=none
 
-ifeq ($(have_zero_bss),y)
-CFLAGS		+= -fno-zero-initialized-in-bss
+HAS_POWER4	:= $(shell if $(CC) -mcpu=power4 -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo y; else echo n; fi;)
+ifeq ($(HAS_POWER4),y)
+ifeq ($(CONFIG_POWER4_ONLY),y)
+CFLAGS		+= -mcpu=power4
+else
+CFLAGS		+= -mtune=power4
+endif
 endif
 
 head-y := arch/ppc64/kernel/head.o
@@ -47,6 +57,8 @@ BOOTIMAGE := $(bootimage-y)
 install: vmlinux
 	$(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) $@
 
+all: $(BOOTIMAGE)
+
 archclean:
 	$(Q)$(MAKE) $(clean)=$(boot)
 
diff -puN -L arch/ppc64/mm/extable.c arch/ppc64/mm/extable.c~linus /dev/null
--- 25/arch/ppc64/mm/extable.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,74 +0,0 @@
-/*
- * arch/ppc64/mm/extable.c
- *
- * from arch/i386/mm/extable.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.
- */
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <asm/uaccess.h>
-
-extern struct exception_table_entry __start___ex_table[];
-extern struct exception_table_entry __stop___ex_table[];
-
-/*
- * The exception table needs to be sorted because we use the macros
- * which put things into the exception table in a variety of segments
- * as well as the init segment and the main kernel text segment.
- *
- * Also used for modules.
- */
-void __init_or_module sort_ex_table(struct exception_table_entry *start,
-				    struct exception_table_entry *finish)
-{
-	struct exception_table_entry el, *p, *q;
-
-	/* insertion sort */
-	for (p = start + 1; p < finish; ++p) {
-		/* start .. p-1 is sorted */
-		if (p[0].insn < p[-1].insn) {
-			/* move element p down to its right place */
-			el = *p;
-			q = p;
-			do {
-				/* el comes before q[-1], move q[-1] up one */
-				q[0] = q[-1];
-				--q;
-			} while (q > start && el.insn < q[-1].insn);
-			*q = el;
-		}
-	}
-}
-
-void __init
-sort_exception_table(void)
-{
-	sort_ex_table(__start___ex_table, __stop___ex_table);
-}
-
-/* Simple binary search */
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
-	       const struct exception_table_entry *last,
-	       unsigned long value)
-{
-	while (first <= last) {
-		const struct exception_table_entry *mid;
-		long diff;
-
-		mid = (last - first) / 2 + first;
-		diff = mid->insn - value;
-		if (diff == 0)
-			return mid;
-		else if (diff < 0)
-			first = mid+1;
-		else
-			last = mid-1;
-	}
-	return NULL;
-}
diff -puN /dev/null arch/ppc64/mm/hash_low.S
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/ppc64/mm/hash_low.S	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,283 @@
+/*
+ * ppc64 MMU hashtable management routines
+ *
+ * (c) Copyright IBM Corp. 2003
+ *
+ * Maintained by: Benjamin Herrenschmidt
+ *                <benh@kernel.crashing.org>
+ *
+ * This file is covered by the GNU Public Licence v2 as
+ * described in the kernel's COPYING file.
+ */
+
+#include <linux/config.h>
+#include <asm/processor.h>
+#include <asm/pgtable.h>
+#include <asm/mmu.h>
+#include <asm/page.h>
+#include <asm/types.h>
+#include <asm/ppc_asm.h>
+#include <asm/offsets.h>
+#include <asm/cputable.h>
+
+	.text
+
+/*
+ * Stackframe:
+ *		
+ *         +-> Back chain			(SP + 256)
+ *         |   General register save area	(SP + 112)
+ *         |   Parameter save area		(SP + 48)
+ *         |   TOC save area			(SP + 40)
+ *         |   link editor doubleword		(SP + 32)
+ *         |   compiler doubleword		(SP + 24)
+ *         |   LR save area			(SP + 16)
+ *         |   CR save area			(SP + 8)
+ * SP ---> +-- Back chain			(SP + 0)
+ */
+#define STACKFRAMESIZE	256
+
+/* Save parameters offsets */
+#define STK_PARM(i)	(STACKFRAMESIZE + 48 + ((i)-3)*8)
+
+/* Save non-volatile offsets */
+#define STK_REG(i)	(112 + ((i)-14)*8)
+
+/*
+ * _hash_page(unsigned long ea, unsigned long access, unsigned long vsid,
+ *		pte_t *ptep, unsigned long trap, int local)
+ *
+ * Adds a page to the hash table. This is the non-LPAR version for now
+ */
+
+_GLOBAL(__hash_page)
+	mflr	r0
+	std	r0,16(r1)
+	stdu	r1,-STACKFRAMESIZE(r1)
+	/* Save all params that we need after a function call */
+	std	r6,STK_PARM(r6)(r1)
+	std	r8,STK_PARM(r8)(r1)
+	
+	/* Add _PAGE_PRESENT to access */
+	ori	r4,r4,_PAGE_PRESENT
+
+	/* Save non-volatile registers.
+	 * r31 will hold "old PTE"
+	 * r30 is "new PTE"
+	 * r29 is "va"
+	 * r28 is a hash value
+	 * r27 is hashtab mask (maybe dynamic patched instead ?)
+	 */
+	std	r27,STK_REG(r27)(r1)
+	std	r28,STK_REG(r28)(r1)
+	std	r29,STK_REG(r29)(r1)
+	std	r30,STK_REG(r30)(r1)
+	std	r31,STK_REG(r31)(r1)
+	
+	/* Step 1:
+	 *
+	 * Check permissions, atomically mark the linux PTE busy
+	 * and hashed.
+	 */ 
+1:
+	ldarx	r31,0,r6
+	/* Check access rights (access & ~(pte_val(*ptep))) */
+	andc.	r0,r4,r31
+	bne-	htab_wrong_access
+	/* Check if PTE is busy */
+	andi.	r0,r31,_PAGE_BUSY
+	bne-	1b
+	/* Prepare new PTE value (turn access RW into DIRTY, then
+	 * add BUSY,HASHPTE and ACCESSED)
+	 */
+	rlwinm	r30,r4,5,24,24	/* _PAGE_RW -> _PAGE_DIRTY */
+	or	r30,r30,r31
+	ori	r30,r30,_PAGE_BUSY | _PAGE_ACCESSED | _PAGE_HASHPTE
+	/* Write the linux PTE atomically (setting busy) */
+	stdcx.	r30,0,r6
+	bne-	1b
+	
+
+	/* Step 2:
+	 *
+	 * Insert/Update the HPTE in the hash table. At this point,
+	 * r4 (access) is re-useable, we use it for the new HPTE flags
+	 */
+
+	/* Calc va and put it in r29 */
+	rldicr	r29,r5,28,63-28
+	rldicl	r3,r3,0,36
+	or	r29,r3,r29
+
+	/* Calculate hash value for primary slot and store it in r28 */
+	rldicl	r5,r5,0,25		/* vsid & 0x0000007fffffffff */
+	rldicl	r0,r3,64-12,48		/* (ea >> 12) & 0xffff */
+	xor	r28,r5,r0
+	
+	/* Convert linux PTE bits into HW equivalents
+	 */
+	andi.	r3,r30,0x1fa		/* Get basic set of flags */
+	rlwinm	r0,r30,32-2+1,30,30	/* _PAGE_RW -> _PAGE_USER (r0) */
+	rlwinm	r4,r30,32-7+1,30,30	/* _PAGE_DIRTY -> _PAGE_USER (r4) */
+	and	r0,r0,r4		/* _PAGE_RW & _PAGE_DIRTY -> r0 bit 30 */
+	andc	r0,r30,r0		/* r0 = pte & ~r0 */
+	rlwimi	r3,r0,32-1,31,31	/* Insert result into PP lsb */
+
+	/* We eventually do the icache sync here (maybe inline that
+	 * code rather than call a C function...) 
+	 */
+BEGIN_FTR_SECTION
+	mr	r4,r30
+	mr	r5,r7
+	bl	.hash_page_do_lazy_icache
+END_FTR_SECTION_IFSET(CPU_FTR_NOEXECUTE)
+
+	/* At this point, r3 contains new PP bits, save them in
+	 * place of "access" in the param area (sic)
+	 */
+	std	r3,STK_PARM(r4)(r1)
+
+	/* Get htab_hash_mask */
+	ld	r4,htab_data@got(2)
+	ld	r27,16(r4)	/* htab_data.htab_hash_mask -> r27 */
+
+	/* Check if we may already be in the hashtable, in this case, we
+	 * go to out-of-line code to try to modify the HPTE
+	 */
+	andi.	r0,r31,_PAGE_HASHPTE
+	bne	htab_modify_pte
+
+htab_insert_pte:
+	/* Clear hpte bits in new pte (we also clear BUSY btw) and
+	 * add _PAGE_HASHPTE
+	 */
+	lis	r0,_PAGE_HPTEFLAGS@h
+	ori	r0,r0,_PAGE_HPTEFLAGS@l
+	andc	r30,r30,r0
+	ori	r30,r30,_PAGE_HASHPTE
+
+	/* page number in r5 */
+	rldicl	r5,r31,64-PTE_SHIFT,PTE_SHIFT
+
+	/* Calculate primary group hash */
+	and	r0,r28,r27
+	rldicr	r3,r0,3,63-3	/* r0 = (hash & mask) << 3 */
+
+	/* Call ppc_md.hpte_insert */
+	ld	r7,STK_PARM(r4)(r1)	/* Retreive new pp bits */
+	mr	r4,r29			/* Retreive va */
+	li	r6,0			/* primary slot */
+	li	r8,0			/* not bolted and not large */
+	li	r9,0
+_GLOBAL(htab_call_hpte_insert1)
+	bl	.			/* Will be patched by htab_finish_init() */
+	cmpi	0,r3,0
+	bge	htab_pte_insert_ok	/* Insertion successful */
+	cmpi	0,r3,-2			/* Critical failure */
+	beq-	htab_pte_insert_failure
+
+	/* Now try secondary slot */
+	ori	r30,r30,_PAGE_SECONDARY
+	
+	/* page number in r5 */
+	rldicl	r5,r31,64-PTE_SHIFT,PTE_SHIFT
+
+	/* Calculate secondary group hash */
+	andc	r0,r27,r28
+	rldicr	r3,r0,3,63-3	/* r0 = (~hash & mask) << 3 */
+	
+	/* Call ppc_md.hpte_insert */
+	ld	r7,STK_PARM(r4)(r1)	/* Retreive new pp bits */
+	mr	r4,r29			/* Retreive va */
+	li	r6,1			/* secondary slot */
+	li	r8,0			/* not bolted and not large */
+	li	r9,0
+_GLOBAL(htab_call_hpte_insert2)
+	bl	.			/* Will be patched by htab_finish_init() */
+	cmpi	0,r3,0
+	bge+	htab_pte_insert_ok	/* Insertion successful */
+	cmpi	0,r3,-2			/* Critical failure */
+	beq-	htab_pte_insert_failure
+
+	/* Both are full, we need to evict something */
+	mftb	r0
+	/* Pick a random group based on TB */
+	andi.	r0,r0,1
+	mr	r5,r28
+	bne	2f
+	not	r5,r5
+2:	and	r0,r5,r27
+	rldicr	r3,r0,3,63-3	/* r0 = (hash & mask) << 3 */	
+	/* Call ppc_md.hpte_remove */
+_GLOBAL(htab_call_hpte_remove)
+	bl	.			/* Will be patched by htab_finish_init() */
+
+	/* Try all again */
+	b	htab_insert_pte	
+
+htab_pte_insert_ok:
+	/* Insert slot number in PTE */
+	rldimi	r30,r3,12,63-14
+		
+	/* Write out the PTE with a normal write
+	 * (maybe add eieio may be good still ?)
+	 */
+htab_write_out_pte:
+	ld	r6,STK_PARM(r6)(r1)
+	std	r30,0(r6)
+	li	r3, 0
+bail:
+	ld	r27,STK_REG(r27)(r1)
+	ld	r28,STK_REG(r28)(r1)
+	ld	r29,STK_REG(r29)(r1)
+	ld      r30,STK_REG(r30)(r1)
+	ld      r31,STK_REG(r31)(r1)
+	addi    r1,r1,STACKFRAMESIZE
+	ld      r0,16(r1)
+	mtlr    r0
+	blr
+
+htab_modify_pte:
+	/* Keep PP bits in r4 and slot idx from the PTE around in r3 */
+	mr	r4,r3
+	rlwinm	r3,r31,32-12,29,31
+
+	/* Secondary group ? if yes, get a inverted hash value */
+	mr	r5,r28
+	andi.	r0,r31,_PAGE_SECONDARY
+	beq	1f
+	not	r5,r5
+1:
+	/* Calculate proper slot value for ppc_md.hpte_updatepp */
+	and	r0,r5,r27
+	rldicr	r0,r0,3,63-3	/* r0 = (hash & mask) << 3 */
+	add	r3,r0,r3	/* add slot idx */
+
+	/* Call ppc_md.hpte_updatepp */
+	mr	r5,r29			/* va */
+	li	r6,0			/* large is 0 */
+	ld	r7,STK_PARM(r8)(r1)	/* get "local" param */
+_GLOBAL(htab_call_hpte_updatepp)
+	bl	.			/* Will be patched by htab_finish_init() */
+
+	/* if we failed because typically the HPTE wasn't really here
+	 * we try an insertion. 
+	 */
+	cmpi	0,r3,-1
+	beq-	htab_insert_pte
+
+	/* Clear the BUSY bit and Write out the PTE */
+	li	r0,_PAGE_BUSY
+	andc	r30,r30,r0
+	b	htab_write_out_pte
+
+htab_wrong_access:
+	/* Bail out clearing reservation */
+	stdcx.	r31,0,r6
+	li	r3,1
+	b	bail
+
+htab_pte_insert_failure:
+	b	.htab_insert_failure
+
+
diff -puN /dev/null arch/ppc64/mm/hash_utils.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/ppc64/mm/hash_utils.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,358 @@
+/*
+ * PowerPC64 port by Mike Corrigan and Dave Engebretsen
+ *   {mikejc|engebret}@us.ibm.com
+ *
+ *    Copyright (c) 2000 Mike Corrigan <mikejc@us.ibm.com>
+ *
+ * SMP scalability work:
+ *    Copyright (C) 2001 Anton Blanchard <anton@au.ibm.com>, IBM
+ * 
+ *    Module name: htab.c
+ *
+ *    Description:
+ *      PowerPC Hashed Page Table functions
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the 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/spinlock.h>
+#include <linux/errno.h>
+#include <linux/sched.h>
+#include <linux/proc_fs.h>
+#include <linux/stat.h>
+#include <linux/sysctl.h>
+#include <linux/ctype.h>
+#include <linux/cache.h>
+#include <linux/init.h>
+
+#include <asm/ppcdebug.h>
+#include <asm/processor.h>
+#include <asm/pgtable.h>
+#include <asm/mmu.h>
+#include <asm/mmu_context.h>
+#include <asm/page.h>
+#include <asm/types.h>
+#include <asm/system.h>
+#include <asm/uaccess.h>
+#include <asm/naca.h>
+#include <asm/pmc.h>
+#include <asm/machdep.h>
+#include <asm/lmb.h>
+#include <asm/abs_addr.h>
+#include <asm/tlbflush.h>
+#include <asm/io.h>
+#include <asm/eeh.h>
+#include <asm/tlb.h>
+#include <asm/cacheflush.h>
+#include <asm/cputable.h>
+/*
+ * Note:  pte   --> Linux PTE
+ *        HPTE  --> PowerPC Hashed Page Table Entry
+ *
+ * Execution context:
+ *   htab_initialize is called with the MMU off (of course), but
+ *   the kernel has been copied down to zero so it can directly
+ *   reference global data.  At this point it is very difficult
+ *   to print debug info.
+ *
+ */
+
+HTAB htab_data = {NULL, 0, 0, 0, 0};
+
+extern unsigned long _SDR1;
+
+#define KB (1024)
+#define MB (1024*KB)
+
+static inline void loop_forever(void)
+{
+	volatile unsigned long x = 1;
+	for(;x;x|=1)
+		;
+}
+
+#ifdef CONFIG_PPC_PSERIES
+static inline void create_pte_mapping(unsigned long start, unsigned long end,
+				      unsigned long mode, int large)
+{
+	unsigned long addr;
+	unsigned int step;
+
+	if (large)
+		step = 16*MB;
+	else
+		step = 4*KB;
+
+	for (addr = start; addr < end; addr += step) {
+		unsigned long vpn, hash, hpteg;
+		unsigned long vsid = get_kernel_vsid(addr);
+		unsigned long va = (vsid << 28) | (addr & 0xfffffff);
+		int ret;
+
+		if (large)
+			vpn = va >> LARGE_PAGE_SHIFT;
+		else
+			vpn = va >> PAGE_SHIFT;
+
+		hash = hpt_hash(vpn, large);
+
+		hpteg = ((hash & htab_data.htab_hash_mask)*HPTES_PER_GROUP);
+
+		if (systemcfg->platform == PLATFORM_PSERIES_LPAR)
+			ret = pSeries_lpar_hpte_insert(hpteg, va,
+				(unsigned long)__v2a(addr) >> PAGE_SHIFT,
+				0, mode, 1, large);
+		else
+			ret = pSeries_hpte_insert(hpteg, va,
+				(unsigned long)__v2a(addr) >> PAGE_SHIFT,
+				0, mode, 1, large);
+
+		if (ret == -1) {
+			ppc64_terminate_msg(0x20, "create_pte_mapping");
+			loop_forever();
+		}
+	}
+}
+
+void __init htab_initialize(void)
+{
+	unsigned long table, htab_size_bytes;
+	unsigned long pteg_count;
+	unsigned long mode_rw;
+
+	/*
+	 * Calculate the required size of the htab.  We want the number of
+	 * PTEGs to equal one half the number of real pages.
+	 */ 
+	htab_size_bytes = 1UL << naca->pftSize;
+	pteg_count = htab_size_bytes >> 7;
+
+	/* For debug, make the HTAB 1/8 as big as it normally would be. */
+	ifppcdebug(PPCDBG_HTABSIZE) {
+		pteg_count >>= 3;
+		htab_size_bytes = pteg_count << 7;
+	}
+
+	htab_data.htab_num_ptegs = pteg_count;
+	htab_data.htab_hash_mask = pteg_count - 1;
+
+	if (systemcfg->platform == PLATFORM_PSERIES) {
+		/* Find storage for the HPT.  Must be contiguous in
+		 * the absolute address space.
+		 */
+		table = lmb_alloc(htab_size_bytes, htab_size_bytes);
+		if ( !table ) {
+			ppc64_terminate_msg(0x20, "hpt space");
+			loop_forever();
+		}
+		htab_data.htab = (HPTE *)__a2v(table);
+
+		/* htab absolute addr + encoded htabsize */
+		_SDR1 = table + __ilog2(pteg_count) - 11;
+
+		/* Initialize the HPT with no entries */
+		memset((void *)table, 0, htab_size_bytes);
+	} else {
+		/* Using a hypervisor which owns the htab */
+		htab_data.htab = NULL;
+		_SDR1 = 0; 
+	}
+
+	mode_rw = _PAGE_ACCESSED | _PAGE_COHERENT | PP_RWXX;
+
+	/* XXX we currently map kernel text rw, should fix this */
+	if ((cur_cpu_spec->cpu_features & CPU_FTR_16M_PAGE)
+	    && systemcfg->physicalMemorySize > 256*MB) {
+		create_pte_mapping((unsigned long)KERNELBASE, 
+				   KERNELBASE + 256*MB, mode_rw, 0);
+		create_pte_mapping((unsigned long)KERNELBASE + 256*MB, 
+				   KERNELBASE + (systemcfg->physicalMemorySize), 
+				   mode_rw, 1);
+	} else {
+		create_pte_mapping((unsigned long)KERNELBASE, 
+				   KERNELBASE+(systemcfg->physicalMemorySize), 
+				   mode_rw, 0);
+	}
+}
+#undef KB
+#undef MB
+#endif
+
+/*
+ * Called by asm hashtable.S for doing lazy icache flush
+ */
+unsigned int hash_page_do_lazy_icache(unsigned int pp, pte_t pte, int trap)
+{
+	struct page *page;
+
+#define PPC64_HWNOEXEC (1 << 2)
+
+	if (!pfn_valid(pte_pfn(pte)))
+		return pp;
+
+	page = pte_page(pte);
+
+	/* page is dirty */
+	if (!test_bit(PG_arch_1, &page->flags) && !PageReserved(page)) {
+		if (trap == 0x400) {
+			__flush_dcache_icache(page_address(page));
+			set_bit(PG_arch_1, &page->flags);
+		} else
+			pp |= PPC64_HWNOEXEC;
+	}
+	return pp;
+}
+
+/*
+ * Called by asm hashtable.S in case of critical insert failure
+ */
+void htab_insert_failure(void)
+{
+	panic("hash_page: pte_insert failed\n");
+}
+
+int hash_page(unsigned long ea, unsigned long access, unsigned long trap)
+{
+	void *pgdir;
+	unsigned long vsid;
+	struct mm_struct *mm;
+	pte_t *ptep;
+	int ret;
+	int user_region = 0;
+	int local = 0;
+	cpumask_t tmp;
+
+	/* Check for invalid addresses. */
+	if (!IS_VALID_EA(ea))
+		return 1;
+
+ 	switch (REGION_ID(ea)) {
+	case USER_REGION_ID:
+		user_region = 1;
+		mm = current->mm;
+		if (mm == NULL)
+			return 1;
+
+		vsid = get_vsid(mm->context, ea);
+		break;
+	case IO_REGION_ID:
+		mm = &ioremap_mm;
+		vsid = get_kernel_vsid(ea);
+		break;
+	case VMALLOC_REGION_ID:
+		mm = &init_mm;
+		vsid = get_kernel_vsid(ea);
+		break;
+#if 0
+	case EEH_REGION_ID:
+		/*
+		 * Should only be hit if there is an access to MMIO space
+		 * which is protected by EEH.
+		 * Send the problem up to do_page_fault 
+		 */
+	case KERNEL_REGION_ID:
+		/*
+		 * Should never get here - entire 0xC0... region is bolted.
+		 * Send the problem up to do_page_fault 
+		 */
+#endif
+	default:
+		/* Not a valid range
+		 * Send the problem up to do_page_fault 
+		 */
+		return 1;
+		break;
+	}
+
+	pgdir = mm->pgd;
+
+	if (pgdir == NULL)
+		return 1;
+
+	tmp = cpumask_of_cpu(smp_processor_id());
+	if (user_region && cpus_equal(mm->cpu_vm_mask, tmp))
+		local = 1;
+
+	/* Is this a huge page ? */
+	if (unlikely(in_hugepage_area(mm->context, ea)))
+		ret = hash_huge_page(mm, access, ea, vsid, local);
+	else {
+		ptep = find_linux_pte(pgdir, ea);
+		if (ptep == NULL)
+			return 1;
+		ret = __hash_page(ea, access, vsid, ptep, trap, local);
+	}
+
+
+	return ret;
+}
+
+void flush_hash_page(unsigned long context, unsigned long ea, pte_t pte,
+		     int local)
+{
+	unsigned long vsid, vpn, va, hash, secondary, slot;
+
+	/* XXX fix for large ptes */
+	unsigned long large = 0;
+
+	if ((ea >= USER_START) && (ea <= USER_END))
+		vsid = get_vsid(context, ea);
+	else
+		vsid = get_kernel_vsid(ea);
+
+	va = (vsid << 28) | (ea & 0x0fffffff);
+	if (large)
+		vpn = va >> LARGE_PAGE_SHIFT;
+	else
+		vpn = va >> PAGE_SHIFT;
+	hash = hpt_hash(vpn, large);
+	secondary = (pte_val(pte) & _PAGE_SECONDARY) >> 15;
+	if (secondary)
+		hash = ~hash;
+	slot = (hash & htab_data.htab_hash_mask) * HPTES_PER_GROUP;
+	slot += (pte_val(pte) & _PAGE_GROUP_IX) >> 12;
+
+	ppc_md.hpte_invalidate(slot, va, large, local);
+}
+
+void flush_hash_range(unsigned long context, unsigned long number, int local)
+{
+	if (ppc_md.flush_hash_range) {
+		ppc_md.flush_hash_range(context, number, local);
+	} else {
+		int i;
+		struct ppc64_tlb_batch *batch =
+			&ppc64_tlb_batch[smp_processor_id()];
+
+		for (i = 0; i < number; i++)
+			flush_hash_page(context, batch->addr[i], batch->pte[i],
+					local);
+	}
+}
+
+static inline void make_bl(unsigned int *insn_addr, void *func)
+{
+	unsigned long funcp = *((unsigned long *)func);
+	int offset = funcp - (unsigned long)insn_addr;
+
+	*insn_addr = (unsigned int)(0x48000001 | (offset & 0x03fffffc));
+	flush_icache_range((unsigned long)insn_addr, 4+
+			   (unsigned long)insn_addr);
+}
+
+void __init htab_finish_init(void)
+{
+	extern unsigned int *htab_call_hpte_insert1;
+	extern unsigned int *htab_call_hpte_insert2;
+	extern unsigned int *htab_call_hpte_remove;
+	extern unsigned int *htab_call_hpte_updatepp;
+
+	make_bl(htab_call_hpte_insert1, ppc_md.hpte_insert);
+	make_bl(htab_call_hpte_insert2, ppc_md.hpte_insert);
+	make_bl(htab_call_hpte_remove, ppc_md.hpte_remove);
+	make_bl(htab_call_hpte_updatepp, ppc_md.hpte_updatepp);
+}
diff -puN arch/ppc64/mm/hugetlbpage.c~linus arch/ppc64/mm/hugetlbpage.c
--- 25/arch/ppc64/mm/hugetlbpage.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/mm/hugetlbpage.c	2004-01-19 22:17:21.000000000 -0800
@@ -652,13 +652,9 @@ int hash_huge_page(struct mm_struct *mm,
 	unsigned long va, vpn;
 	int is_write;
 	hugepte_t old_pte, new_pte;
-	unsigned long hpteflags, prpn;
+	unsigned long hpteflags, prpn, flags;
 	long slot;
 
-	/* Is this for us? */
-	if (!in_hugepage_area(mm->context, ea))
-		return -1;
-
 	ea &= ~(HPAGE_SIZE-1);
 
 	/* We have to find the first hugepte in the batch, since
@@ -698,6 +694,8 @@ int hash_huge_page(struct mm_struct *mm,
 	 *	page is currently not DIRTY. 
 	 */
 
+	spin_lock_irqsave(&mm->page_table_lock, flags);
+
 	old_pte = *ptep;
 	new_pte = old_pte;
 
@@ -769,6 +767,8 @@ repeat:
 		*ptep = new_pte;
 	}
 
+	spin_unlock_irqrestore(&mm->page_table_lock, flags);
+
 	return 0;
 }
 
diff -puN arch/ppc64/mm/imalloc.c~linus arch/ppc64/mm/imalloc.c
--- 25/arch/ppc64/mm/imalloc.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/mm/imalloc.c	2004-01-19 22:17:21.000000000 -0800
@@ -18,55 +18,264 @@
 rwlock_t imlist_lock = RW_LOCK_UNLOCKED;
 struct vm_struct * imlist = NULL;
 
-struct vm_struct *get_im_area(unsigned long size)
+static int get_free_im_addr(unsigned long size, unsigned long *im_addr)
 {
 	unsigned long addr;
-	struct vm_struct **p, *tmp, *area;
-  
-	area = (struct vm_struct *) kmalloc(sizeof(*area), GFP_KERNEL);
-	if (!area)
-		return NULL;
+	struct vm_struct **p, *tmp;
+
 	addr = IMALLOC_START;
-	write_lock(&imlist_lock);
 	for (p = &imlist; (tmp = *p) ; p = &tmp->next) {
 		if (size + addr < (unsigned long) tmp->addr)
 			break;
-		addr = tmp->size + (unsigned long) tmp->addr;
-		if (addr > IMALLOC_END-size) {
-			write_unlock(&imlist_lock);
-			kfree(area);
+		if ((unsigned long)tmp->addr >= IMALLOC_START) 
+			addr = tmp->size + (unsigned long) tmp->addr;
+		if (addr > IMALLOC_END-size) 
+			return 1;
+	}
+	*im_addr = addr;
+
+	return 0;
+}
+
+/* Return whether the region described by v_addr and size overlaps
+ * the region described by vm.  Overlapping regions meet the 
+ * following conditions:
+ * 1) The regions share some part of the address space
+ * 2) The regions aren't identical
+ * 3) The first region is not a subset of the second
+ */
+static inline int im_region_overlaps(unsigned long v_addr, unsigned long size,
+		     struct vm_struct *vm)
+{
+	return (v_addr + size > (unsigned long) vm->addr + vm->size &&
+		v_addr < (unsigned long) vm->addr + vm->size) ||
+	       (v_addr < (unsigned long) vm->addr &&
+		v_addr + size > (unsigned long) vm->addr);
+}
+
+/* Return whether the region described by v_addr and size is a subset
+ * of the region described by vm
+ */
+static inline int im_region_is_subset(unsigned long v_addr, unsigned long size,
+			struct vm_struct *vm)
+{
+	return (int) (v_addr >= (unsigned long) vm->addr && 
+	              v_addr < (unsigned long) vm->addr + vm->size &&
+	    	      size < vm->size);
+}
+
+/* Determine imalloc status of region described by v_addr and size.
+ * Can return one of the following:
+ * IM_REGION_UNUSED   -  Entire region is unallocated in imalloc space.
+ * IM_REGION_SUBSET -    Region is a subset of a region that is already
+ * 			 allocated in imalloc space.
+ * 		         vm will be assigned to a ptr to the parent region.
+ * IM_REGION_EXISTS -    Exact region already allocated in imalloc space.
+ *                       vm will be assigned to a ptr to the existing imlist
+ *                       member.
+ * IM_REGION_OVERLAPS -  A portion of the region is already allocated in 
+ *                       imalloc space.
+ */
+static int im_region_status(unsigned long v_addr, unsigned long size, 
+		    struct vm_struct **vm)
+{
+	struct vm_struct *tmp;
+
+	for (tmp = imlist; tmp; tmp = tmp->next) 
+		if (v_addr < (unsigned long) tmp->addr + tmp->size) 
+			break;
+					
+	if (tmp) {
+		if (im_region_overlaps(v_addr, size, tmp))
+			return IM_REGION_OVERLAP;
+
+		*vm = tmp;
+		if (im_region_is_subset(v_addr, size, tmp))
+			return IM_REGION_SUBSET;
+		else if (v_addr == (unsigned long) tmp->addr && 
+		 	 size == tmp->size) 
+			return IM_REGION_EXISTS;
+	}
+
+	*vm = NULL;
+	return IM_REGION_UNUSED;
+}
+
+static struct vm_struct * split_im_region(unsigned long v_addr, 
+		unsigned long size, struct vm_struct *parent)
+{
+	struct vm_struct *vm1 = NULL;
+	struct vm_struct *vm2 = NULL;
+	struct vm_struct *new_vm = NULL;
+	
+	vm1 = (struct vm_struct *) kmalloc(sizeof(*vm1), GFP_KERNEL);
+	if (vm1	== NULL) {
+		printk(KERN_ERR "%s() out of memory\n", __FUNCTION__);
+		return NULL;
+	}
+
+	if (v_addr == (unsigned long) parent->addr) {
+	        /* Use existing parent vm_struct to represent child, allocate
+		 * new one for the remainder of parent range
+		 */
+		vm1->size = parent->size - size;
+		vm1->addr = (void *) (v_addr + size);
+		vm1->next = parent->next;
+
+		parent->size = size;
+		parent->next = vm1;
+		new_vm = parent;
+	} else if (v_addr + size == (unsigned long) parent->addr + 
+			parent->size) {
+		/* Allocate new vm_struct to represent child, use existing
+		 * parent one for remainder of parent range
+		 */
+		vm1->size = size;
+		vm1->addr = (void *) v_addr;
+		vm1->next = parent->next;
+		new_vm = vm1;
+
+		parent->size -= size;
+		parent->next = vm1;
+	} else {
+	        /* Allocate two new vm_structs for the new child and 
+		 * uppermost remainder, and use existing parent one for the
+		 * lower remainder of parent range
+		 */
+		vm2 = (struct vm_struct *) kmalloc(sizeof(*vm2), GFP_KERNEL);
+		if (vm2 == NULL) {
+			printk(KERN_ERR "%s() out of memory\n", __FUNCTION__);
+			kfree(vm1);
 			return NULL;
 		}
+
+		vm1->size = size;
+		vm1->addr = (void *) v_addr;
+		vm1->next = vm2;
+		new_vm = vm1;
+
+		vm2->size = ((unsigned long) parent->addr + parent->size) - 
+				(v_addr + size);
+		vm2->addr = (void *) v_addr + size;
+		vm2->next = parent->next;
+
+		parent->size = v_addr - (unsigned long) parent->addr;
+		parent->next = vm1;
 	}
+
+	return new_vm;
+}
+
+static struct vm_struct * __add_new_im_area(unsigned long req_addr, 
+					    unsigned long size)
+{
+	struct vm_struct **p, *tmp, *area;
+		
+	for (p = &imlist; (tmp = *p) ; p = &tmp->next) {
+		if (req_addr + size <= (unsigned long)tmp->addr)
+			break;
+	}
+	
+	area = (struct vm_struct *) kmalloc(sizeof(*area), GFP_KERNEL);
+	if (!area)
+		return NULL;
 	area->flags = 0;
-	area->addr = (void *)addr;
+	area->addr = (void *)req_addr;
 	area->size = size;
 	area->next = *p;
 	*p = area;
+
+	return area;
+}
+
+static struct vm_struct * __im_get_area(unsigned long req_addr, 
+					unsigned long size,
+					int criteria)
+{
+	struct vm_struct *tmp;
+	int status;
+
+	status = im_region_status(req_addr, size, &tmp);
+	if ((criteria & status) == 0) {
+		return NULL;
+	}
+	
+	switch (status) {
+	case IM_REGION_UNUSED:
+		tmp = __add_new_im_area(req_addr, size);
+		break;
+	case IM_REGION_SUBSET:
+		tmp = split_im_region(req_addr, size, tmp);
+		break;
+	case IM_REGION_EXISTS:
+		break;
+	default:
+		printk(KERN_ERR "%s() unexpected imalloc region status\n",
+				__FUNCTION__);
+		tmp = NULL;
+	}
+
+	return tmp;
+}
+
+struct vm_struct * im_get_free_area(unsigned long size)
+{
+	struct vm_struct *area;
+	unsigned long addr;
+	
+	write_lock(&imlist_lock);
+	if (get_free_im_addr(size, &addr)) {
+		printk(KERN_ERR "%s() cannot obtain addr for size 0x%lx\n",
+				__FUNCTION__, size);
+		area = NULL;
+		goto next_im_done;
+	}
+
+	area = __im_get_area(addr, size, IM_REGION_UNUSED);
+	if (area == NULL) {
+		printk(KERN_ERR 
+		       "%s() cannot obtain area for addr 0x%lx size 0x%lx\n",
+			__FUNCTION__, addr, size);
+	}
+next_im_done:
 	write_unlock(&imlist_lock);
 	return area;
 }
 
-void ifree(void * addr)
+struct vm_struct * im_get_area(unsigned long v_addr, unsigned long size,
+		int criteria)
+{
+	struct vm_struct *area;
+
+	write_lock(&imlist_lock);
+	area = __im_get_area(v_addr, size, criteria);
+	write_unlock(&imlist_lock);
+	return area;
+}
+
+unsigned long im_free(void * addr)
 {
 	struct vm_struct **p, *tmp;
+	unsigned long ret_size = 0;
   
 	if (!addr)
-		return;
+		return ret_size;
 	if ((PAGE_SIZE-1) & (unsigned long) addr) {
-		printk(KERN_ERR "Trying to ifree() bad address (%p)\n", addr);
-		return;
+		printk(KERN_ERR "Trying to %s bad address (%p)\n", __FUNCTION__,			addr);
+		return ret_size;
 	}
 	write_lock(&imlist_lock);
 	for (p = &imlist ; (tmp = *p) ; p = &tmp->next) {
 		if (tmp->addr == addr) {
+			ret_size = tmp->size;
 			*p = tmp->next;
 			kfree(tmp);
 			write_unlock(&imlist_lock);
-			return;
+			return ret_size;
 		}
 	}
 	write_unlock(&imlist_lock);
-	printk(KERN_ERR "Trying to ifree() nonexistent area (%p)\n", addr);
+	printk(KERN_ERR "Trying to %s nonexistent area (%p)\n", __FUNCTION__,
+			addr);
+	return ret_size;
 }
-
diff -puN arch/ppc64/mm/init.c~linus arch/ppc64/mm/init.c
--- 25/arch/ppc64/mm/init.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/mm/init.c	2004-01-19 22:17:21.000000000 -0800
@@ -67,6 +67,7 @@
 struct mmu_context_queue_t mmu_context_queue;
 int mem_init_done;
 unsigned long ioremap_bot = IMALLOC_BASE;
+static unsigned long phbs_io_bot = PHBS_IO_BASE;
 
 extern pgd_t swapper_pg_dir[];
 extern struct task_struct *current_set[NR_CPUS];
@@ -74,6 +75,9 @@ extern struct task_struct *current_set[N
 extern pgd_t ioremap_dir[];
 pgd_t * ioremap_pgd = (pgd_t *)&ioremap_dir;
 
+static void * __ioremap_com(unsigned long addr, unsigned long pa, 
+			    unsigned long ea, unsigned long size, 
+			    unsigned long flags);
 static void map_io_page(unsigned long va, unsigned long pa, int flags);
 
 unsigned long klimit = (unsigned long)_end;
@@ -90,6 +94,52 @@ unsigned long __max_memory;
  * include/asm-ppc64/tlb.h file -- tgall
  */
 DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
+DEFINE_PER_CPU(struct pte_freelist_batch *, pte_freelist_cur);
+unsigned long pte_freelist_forced_free;
+
+static void pte_free_smp_sync(void *arg)
+{
+	/* Do nothing, just ensure we sync with all CPUs */
+}
+
+/* This is only called when we are critically out of memory
+ * (and fail to get a page in pte_free_tlb).
+ */
+void pte_free_now(struct page *ptepage)
+{
+	pte_freelist_forced_free++;
+
+	smp_call_function(pte_free_smp_sync, NULL, 0, 1);
+
+	pte_free(ptepage);
+}
+
+static void pte_free_rcu_callback(void *arg)
+{
+	struct pte_freelist_batch *batch = arg;
+	unsigned int i;
+
+	for (i = 0; i < batch->index; i++)
+		pte_free(batch->pages[i]);
+	free_page((unsigned long)batch);
+}
+
+void pte_free_submit(struct pte_freelist_batch *batch)
+{
+	INIT_RCU_HEAD(&batch->rcu);
+	call_rcu(&batch->rcu, pte_free_rcu_callback, batch);
+}
+
+void pte_free_finish(void)
+{
+	/* This is safe as we are holding page_table_lock */
+	struct pte_freelist_batch **batchp = &__get_cpu_var(pte_freelist_cur);
+	
+	if (*batchp == NULL)
+		return;
+	pte_free_submit(*batchp);
+	*batchp = NULL;
+}
 
 void show_mem(void)
 {
@@ -133,12 +183,10 @@ ioremap(unsigned long addr, unsigned lon
 #endif
 }
 
-extern struct vm_struct * get_im_area( unsigned long size );
-
 void *
 __ioremap(unsigned long addr, unsigned long size, unsigned long flags)
 {
-	unsigned long pa, ea, i;
+	unsigned long pa, ea;
 
 	/*
 	 * Choose an address to map it to.
@@ -157,26 +205,163 @@ __ioremap(unsigned long addr, unsigned l
 
 	if (mem_init_done) {
 		struct vm_struct *area;
-		area = get_im_area(size);
-		if (area == 0)
+		area = im_get_free_area(size);
+		if (area == NULL)
 			return NULL;
 		ea = (unsigned long)(area->addr);
-	} 
-	else {
+	} else {
 		ea = ioremap_bot;
 		ioremap_bot += size;
 	}
 
-	if ((flags & _PAGE_PRESENT) == 0)
-		flags |= pgprot_val(PAGE_KERNEL);
-	if (flags & (_PAGE_NO_CACHE | _PAGE_WRITETHRU))
-		flags |= _PAGE_GUARDED;
+	return __ioremap_com(addr, pa, ea, size, flags);
+}
 
-	for (i = 0; i < size; i += PAGE_SIZE) {
-		map_io_page(ea+i, pa+i, flags);
+#define IS_PAGE_ALIGNED(_val) ((_val) == ((_val) & PAGE_MASK))
+
+int __ioremap_explicit(unsigned long pa, unsigned long ea,
+		       unsigned long size, unsigned long flags)
+{
+	struct vm_struct *area;
+	
+	/* For now, require page-aligned values for pa, ea, and size */
+	if (!IS_PAGE_ALIGNED(pa) || !IS_PAGE_ALIGNED(ea) ||
+	    !IS_PAGE_ALIGNED(size)) {
+		printk(KERN_ERR	"unaligned value in %s\n", __FUNCTION__);
+		return 1;
+	}
+	
+	if (!mem_init_done) {
+		/* Two things to consider in this case:
+		 * 1) No records will be kept (imalloc, etc) that the region
+		 *    has been remapped
+		 * 2) It won't be easy to iounmap() the region later (because
+		 *    of 1)
+		 */
+		;
+	} else {
+		area = im_get_area(ea, size, IM_REGION_UNUSED|IM_REGION_SUBSET);
+		if (area == NULL) {
+			printk(KERN_ERR "could not obtain imalloc area for ea 0x%lx\n", ea);
+			return 1;
+		}
+		if (ea != (unsigned long) area->addr) {
+			printk(KERN_ERR "unexpected addr return from im_get_area\n");
+			return 1;
+		}
+	}
+	
+	if (__ioremap_com(pa, pa, ea, size, flags) != (void *) ea) {
+		printk(KERN_ERR "__ioremap_com() returned unexpected addr\n");
+		return 1;
 	}
 
-	return (void *) (ea + (addr & ~PAGE_MASK));
+	return 0;
+}
+
+static void unmap_im_area_pte(pmd_t *pmd, unsigned long address,
+				  unsigned long size)
+{
+	unsigned long end;
+	pte_t *pte;
+
+	if (pmd_none(*pmd))
+		return;
+	if (pmd_bad(*pmd)) {
+		pmd_ERROR(*pmd);
+		pmd_clear(pmd);
+		return;
+	}
+
+	pte = pte_offset_kernel(pmd, address);
+	address &= ~PMD_MASK;
+	end = address + size;
+	if (end > PMD_SIZE)
+		end = PMD_SIZE;
+
+	do {
+		pte_t page;
+		page = ptep_get_and_clear(pte);
+		address += PAGE_SIZE;
+		pte++;
+		if (pte_none(page))
+			continue;
+		if (pte_present(page))
+			continue;
+		printk(KERN_CRIT "Whee.. Swapped out page in kernel page table\n");
+	} while (address < end);
+}
+
+static void unmap_im_area_pmd(pgd_t *dir, unsigned long address,
+				  unsigned long size)
+{
+	unsigned long end;
+	pmd_t *pmd;
+
+	if (pgd_none(*dir))
+		return;
+	if (pgd_bad(*dir)) {
+		pgd_ERROR(*dir);
+		pgd_clear(dir);
+		return;
+	}
+
+	pmd = pmd_offset(dir, address);
+	address &= ~PGDIR_MASK;
+	end = address + size;
+	if (end > PGDIR_SIZE)
+		end = PGDIR_SIZE;
+
+	do {
+		unmap_im_area_pte(pmd, address, end - address);
+		address = (address + PMD_SIZE) & PMD_MASK;
+		pmd++;
+	} while (address < end);
+}
+
+/*  
+ * Unmap an IO region and remove it from imalloc'd list.
+ * Access to IO memory should be serialized by driver.
+ * This code is modeled after vmalloc code - unmap_vm_area()
+ *
+ * XXX	what about calls before mem_init_done (ie python_countermeasures())	
+ */
+void pSeries_iounmap(void *addr)
+{
+	unsigned long address, start, end, size;
+	struct mm_struct *mm;
+	pgd_t *dir;
+
+	if (!mem_init_done) {
+		return;
+	}
+	
+	/* addr could be in EEH or IO region, map it to IO region regardless.
+	 */
+	addr = (void *) (IO_TOKEN_TO_ADDR(addr) & PAGE_MASK);
+	
+	if ((size = im_free(addr)) == 0) {
+		return;
+	}
+
+	address = (unsigned long)addr; 
+	start = address;
+	end = address + size;
+
+	mm = &ioremap_mm;
+	spin_lock(&mm->page_table_lock);
+
+	dir = pgd_offset_i(address);
+	flush_cache_all();
+	do {
+		unmap_im_area_pmd(dir, address, end - address);
+		address = (address + PGDIR_SIZE) & PGDIR_MASK;
+		dir++;
+	} while (address && (address < end));
+	__flush_tlb_range(mm, start, end);
+
+	spin_unlock(&mm->page_table_lock);
+	return;
 }
 
 void iounmap(void *addr) 
@@ -186,10 +371,52 @@ void iounmap(void *addr) 
 	return;
 #else
 	/* DRENG / PPPBBB todo */
-	return;
+	return pSeries_iounmap(addr);
 #endif
 }
 
+int iounmap_explicit(void *addr, unsigned long size)
+{
+	struct vm_struct *area;
+	
+	/* addr could be in EEH or IO region, map it to IO region regardless.
+	 */
+	addr = (void *) (IO_TOKEN_TO_ADDR(addr) & PAGE_MASK);
+
+	/* Verify that the region either exists or is a subset of an existing
+	 * region.  In the latter case, split the parent region to create 
+	 * the exact region 
+	 */
+	area = im_get_area((unsigned long) addr, size, 
+			    IM_REGION_EXISTS | IM_REGION_SUBSET);
+	if (area == NULL) {
+		printk(KERN_ERR "%s() cannot unmap nonexistant range 0x%lx\n",
+				__FUNCTION__, (unsigned long) addr);
+		return 1;
+	}
+
+	iounmap(area->addr);
+	return 0;
+}
+
+static void * __ioremap_com(unsigned long addr, unsigned long pa, 
+			    unsigned long ea, unsigned long size, 
+			    unsigned long flags)
+{
+	unsigned long i;
+	
+	if ((flags & _PAGE_PRESENT) == 0)
+		flags |= pgprot_val(PAGE_KERNEL);
+	if (flags & (_PAGE_NO_CACHE | _PAGE_WRITETHRU))
+		flags |= _PAGE_GUARDED;
+
+	for (i = 0; i < size; i += PAGE_SIZE) {
+		map_io_page(ea+i, pa+i, flags);
+	}
+
+	return (void *) (ea + (addr & ~PAGE_MASK));
+}
+
 /*
  * map_io_page currently only called by __ioremap
  * map_io_page adds an entry to the ioremap page table
@@ -674,10 +901,6 @@ void flush_icache_user_range(struct vm_a
 	flush_icache_range(maddr, maddr + len);
 }
 
-extern pte_t *find_linux_pte(pgd_t *pgdir, unsigned long ea);
-int __hash_page(unsigned long ea, unsigned long access, unsigned long vsid,
-		pte_t *ptep, unsigned long trap, int local);
-
 /*
  * This is called at the end of handling a user page fault, when the
  * fault has been handled by updating a PTE in the linux page tables.
@@ -717,6 +940,9 @@ void update_mmu_cache(struct vm_area_str
 		return;
 
 	ptep = find_linux_pte(pgdir, ea);
+	if (!ptep)
+		return;
+
 	vsid = get_vsid(vma->vm_mm->context, ea);
 
 	tmp = cpumask_of_cpu(smp_processor_id());
@@ -727,6 +953,19 @@ void update_mmu_cache(struct vm_area_str
 		    0x300, local);
 }
 
+void * reserve_phb_iospace(unsigned long size)
+{
+	void *virt_addr;
+		
+	if (phbs_io_bot >= IMALLOC_BASE) 
+		panic("reserve_phb_iospace(): phb io space overflow\n");
+			
+	virt_addr = (void *) phbs_io_bot;
+	phbs_io_bot += size;
+
+	return virt_addr;
+}
+
 kmem_cache_t *zero_cache;
 
 static void zero_ctor(void *pte, kmem_cache_t *cache, unsigned long flags)
diff -puN arch/ppc64/mm/Makefile~linus arch/ppc64/mm/Makefile
--- 25/arch/ppc64/mm/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/mm/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -4,6 +4,6 @@
 
 EXTRA_CFLAGS += -mno-minimal-toc
 
-obj-y := fault.o init.o extable.o imalloc.o
+obj-y := fault.o init.o imalloc.o hash_utils.o hash_low.o
 obj-$(CONFIG_DISCONTIGMEM) += numa.o
 obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
diff -puN arch/ppc64/mm/numa.c~linus arch/ppc64/mm/numa.c
--- 25/arch/ppc64/mm/numa.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/mm/numa.c	2004-01-19 22:17:21.000000000 -0800
@@ -46,29 +46,29 @@ static inline void map_cpu_to_node(int c
 
 static int __init parse_numa_properties(void)
 {
-	struct device_node *cpu;
-	struct device_node *memory;
+	struct device_node *cpu = NULL;
+	struct device_node *memory = NULL;
 	int *cpu_associativity;
 	int *memory_associativity;
 	int depth;
 	int max_domain = 0;
 
-	cpu = find_type_devices("cpu");
+	cpu = of_find_node_by_type(NULL, "cpu");
 	if (!cpu)
-		return -1;
+		goto err;
 
-	memory = find_type_devices("memory");
+	memory = of_find_node_by_type(NULL, "memory");
 	if (!memory)
-		return -1;
+		goto err;
 
 	cpu_associativity = (int *)get_property(cpu, "ibm,associativity", NULL);
 	if (!cpu_associativity)
-		return -1;
+		goto err;
 
 	memory_associativity = (int *)get_property(memory, "ibm,associativity",
 						   NULL);
 	if (!memory_associativity)
-		return -1;
+		goto err;
 
 	/* find common depth */
 	if (cpu_associativity[0] < memory_associativity[0])
@@ -76,7 +76,7 @@ static int __init parse_numa_properties(
 	else
 		depth = memory_associativity[0];
 
-	for (cpu = find_type_devices("cpu"); cpu; cpu = cpu->next) {
+	for (; cpu; cpu = of_find_node_by_type(cpu, "cpu")) {
 		int *tmp;
 		int cpu_nr, numa_domain;
 
@@ -106,9 +106,8 @@ static int __init parse_numa_properties(
 		map_cpu_to_node(cpu_nr, numa_domain);
 	}
 
-	for (memory = find_type_devices("memory"); memory;
-	     memory = memory->next) {
-		int *tmp1, *tmp2;
+	for (; memory; memory = of_find_node_by_type(memory, "memory")) {
+		unsigned int *tmp1, *tmp2;
 		unsigned long i;
 		unsigned long start = 0;
 		unsigned long size = 0;
@@ -196,6 +195,10 @@ new_range:
 	numnodes = max_domain + 1;
 
 	return 0;
+err:
+	of_node_put(cpu);
+	of_node_put(memory);
+	return -1;
 }
 
 void setup_nonnuma(void)
diff -puN arch/ppc64/xmon/xmon.c~linus arch/ppc64/xmon/xmon.c
--- 25/arch/ppc64/xmon/xmon.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc64/xmon/xmon.c	2004-01-19 22:17:21.000000000 -0800
@@ -37,9 +37,10 @@
 #define skipbl	xmon_skipbl
 
 #ifdef CONFIG_SMP
-unsigned long cpus_in_xmon = 0;
+volatile unsigned long cpus_in_xmon = 0;
 static unsigned long got_xmon = 0;
 static volatile int take_xmon = -1;
+static volatile int leaving_xmon = 0;
 #endif /* CONFIG_SMP */
 
 static unsigned long adrs;
@@ -162,7 +163,6 @@ Commands:\n\
   mz	zero a block of memory\n\
   mx	translation information for an effective address\n\
   mi	show information about memory allocation\n\
-  M	print System.map\n\
   p 	show the task list\n\
   r	print registers\n\
   s	single step\n\
@@ -227,7 +227,7 @@ void
 xmon(struct pt_regs *excp)
 {
 	struct pt_regs regs;
-	int cmd;
+	int cmd = 0;
 	unsigned long msr;
 
 	if (excp == NULL) {
@@ -285,9 +285,15 @@ xmon(struct pt_regs *excp)
 	xmon_regs[smp_processor_id()] = excp;
 	excprint(excp);
 #ifdef CONFIG_SMP
-	if (test_and_set_bit(smp_processor_id(), &cpus_in_xmon))
+	leaving_xmon = 0;
+	/* possible race condition here if a CPU is held up and gets
+	 * here while we are exiting */
+	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;
@@ -304,6 +310,9 @@ xmon(struct pt_regs *excp)
 	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;
@@ -313,7 +322,9 @@ xmon(struct pt_regs *excp)
 	}
 	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 */
@@ -421,8 +432,6 @@ insert_bpts()
 	int i;
 	struct bpt *bp;
 
-	if (systemcfg->platform != PLATFORM_PSERIES)
-		return;
 	bp = bpts;
 	for (i = 0; i < NBPTS; ++i, ++bp) {
 		if (!bp->enabled)
@@ -450,9 +459,6 @@ remove_bpts()
 	struct bpt *bp;
 	unsigned instr;
 
-	if (systemcfg->platform != PLATFORM_PSERIES)
-		return;
-
 	if ((cur_cpu_spec->cpu_features & CPU_FTR_DABR))
 		set_dabr(0);
 	if ((cur_cpu_spec->cpu_features & CPU_FTR_IABR))
@@ -478,11 +484,15 @@ static char *last_cmd;
 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> ");
@@ -832,6 +842,12 @@ bpt_cmds(void)
 				}
 			break;
 		}
+		
+		if (!(systemcfg->platform & PLATFORM_PSERIES)) {
+			printf("Not supported for this platform\n");
+			break;
+		}
+
 		bp = at_breakpoint(a);
 		if (bp == 0) {
 			for (bp = bpts; bp < &bpts[NBPTS]; ++bp)
diff -puN arch/ppc/boot/prep/head.S~linus arch/ppc/boot/prep/head.S
--- 25/arch/ppc/boot/prep/head.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc/boot/prep/head.S	2004-01-19 22:17:21.000000000 -0800
@@ -35,9 +35,28 @@ start_:
 
 	mr	r11,r3		/* Save pointer to residual/board data */
 
-	/* Establish default MSR value */
-	li	r3,MSR_IP|MSR_FP
-	mtmsr	r3
+/*
+ * Save the OF pointer to r25, but only if the entry point is in a sane
+ * location; if not we store 0.  If there is no entry point, or it is
+ * invalid, we establish the default MSR value immediately.  Otherwise,
+ * we defer doing that, to allow OF functions to be called, until we
+ * begin uncompressing the kernel.
+ */
+	lis	r3,0x0fff		/* r3 = 0x0fffffff */
+	ori	r3,r3,0xffff
+
+	subc	r3,r3,r5		/* r3 = (r5 <= r3) ? ~0 : 0 */
+	subfe	r3,r3,r3
+	nand	r3,r3,r3
+
+	and.	r5,r5,r3		/* r5 will be cleared if (r5 > r3) */
+	bne+	haveOF
+
+	li	r3,MSR_IP|MSR_FP	/* Not OF: set MSR immediately */
+  	mtmsr	r3
+	isync
+haveOF:
+	mr	r25,r5
 
 	/* compute the size of the whole image in words. */
 	lis	r4,start@h
@@ -111,6 +130,7 @@ start_ldr:
 	mr	r4,r7			/* Program length */
 	mr	r5,r6			/* Checksum */
 	mr	r6,r11			/* Residual data */
+	mr      r7,r25                  /* Validated OFW interface */
 	bl	decompress_kernel
 
 	/*
diff -puN arch/ppc/boot/prep/Makefile~linus arch/ppc/boot/prep/Makefile
--- 25/arch/ppc/boot/prep/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc/boot/prep/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -27,9 +27,10 @@ utils	:= $(boot)/utils
 bootlib	:= $(boot)/lib
 images	:= $(boot)/images
 simple	:= $(boot)/simple
+of1275	:= $(boot)/of1275
 
 OBJCOPYFLAGS	:= -O elf32-powerpc
-LIBS 		:= $(common)/lib.a $(bootlib)/lib.a
+LIBS 		:= $(common)/lib.a $(bootlib)/lib.a $(of1275)/lib.a
 
 targets		:= $(boot-y) dummy.o ../simple/legacy.o
 OBJS		:= $(addprefix $(obj)/,$(boot-y)) $(simple)/legacy.o
diff -puN arch/ppc/boot/prep/misc.c~linus arch/ppc/boot/prep/misc.c
--- 25/arch/ppc/boot/prep/misc.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc/boot/prep/misc.c	2004-01-19 22:17:21.000000000 -0800
@@ -19,7 +19,7 @@
 #include <asm/bootinfo.h>
 #include <asm/mmu.h>
 #include <asm/byteorder.h>
-
+#include "of1275.h"
 #include "nonstdio.h"
 #include "zlib.h"
 
@@ -114,17 +114,19 @@ scroll(void)
 
 unsigned long
 decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum,
-		  RESIDUAL *residual)
+		  RESIDUAL *residual, void *OFW_interface)
 {
 	int timer = 0;
 	extern unsigned long start;
 	char *cp, ch;
 	unsigned long TotalMemory;
-	unsigned char board_type;
-	unsigned char base_mod;
 	int start_multi = 0;
 	unsigned int pci_viddid, pci_did, tulip_pci_base, tulip_base;
 
+	/* If we have Open Firmware, initialise it immediately */
+	if (OFW_interface)
+		ofinit(OFW_interface);
+
 	serial_fixups();
 #if defined(CONFIG_SERIAL_8250_CONSOLE)
 	com_port = serial_init(0, NULL);
@@ -163,7 +165,8 @@ decompress_kernel(unsigned long load_add
 		/* Is this Motorola PPCBug? */
 		if ((1 & residual->VitalProductData.FirmwareSupports) &&
 		    (1 == residual->VitalProductData.FirmwareSupplier)) {
-			board_type = inb(0x800) & 0xF0;
+			unsigned char base_mod;
+			unsigned char board_type = inb(0x800) & 0xF0;
 
 			/*
 			 * Reset the onboard 21x4x Ethernet
@@ -229,8 +232,31 @@ decompress_kernel(unsigned long load_add
 	/* If it's not, see if we have anything in the residual data. */
 	else if (residual && residual->TotalMemory)
 		TotalMemory = residual->TotalMemory;
-	/* Fall back to hard-coding 32MB. */
-	else
+	else if (OFW_interface) {
+		/*
+		 * This is a 'best guess' check.  We want to make sure
+		 * we don't try this on a PReP box without OF
+		 *     -- Cort
+		 */
+		while (OFW_interface)
+		{
+			phandle dev_handle;
+			int mem_info[2];
+
+			/* get handle to memory description */
+			if (!(dev_handle = finddevice("/memory@0")))
+				break;
+
+			/* get the info */
+			if (getprop(dev_handle, "reg", mem_info,
+						sizeof(mem_info)) != 8)
+				break;
+
+			TotalMemory = mem_info[1];
+			break;
+		}
+	} else
+		/* Fall back to hard-coding 32MB. */
 		TotalMemory = 32*1024*1024;
 
 
@@ -304,6 +330,18 @@ decompress_kernel(unsigned long load_add
 	*cp = 0;
 	puts("\nUncompressing Linux...");
 
+	/*
+	 * If we have OF, then we have deferred setting the MSR.
+	 * We must set it now because we are about to overwrite
+	 * the exception table.  The new MSR value will disable
+	 * machine check exceptions and point the exception table
+	 * to the ROM.
+	 */
+	if (OFW_interface) {
+		mtmsr(MSR_IP | MSR_FP);
+		asm volatile("isync");
+	}
+
 	gunzip(0, 0x400000, zimage_start, &zimage_size);
 	puts("done.\n");
 
diff -puN arch/ppc/Kconfig~linus arch/ppc/Kconfig
--- 25/arch/ppc/Kconfig~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -681,6 +681,7 @@ config IRQ_ALL_CPUS
 
 config NR_CPUS
 	int "Maximum number of CPUs (2-32)"
+	range 2 32
 	depends on SMP
 	default "4"
 
diff -puN arch/ppc/kernel/Makefile~linus arch/ppc/kernel/Makefile
--- 25/arch/ppc/kernel/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc/kernel/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -9,8 +9,7 @@ ifdef CONFIG_4xx
 EXTRA_AFLAGS		:= -Wa,-m405
 endif
 
-# Start off with 'head.o', change as needed.
-extra-y				:= head.o
+extra-$(CONFIG_PPC_STD_MMU)	:= head.o
 extra-$(CONFIG_40x)		:= head_4xx.o
 extra-$(CONFIG_44x)		:= head_44x.o
 extra-$(CONFIG_8xx)		:= head_8xx.o
diff -puN arch/ppc/kernel/misc.S~linus arch/ppc/kernel/misc.S
--- 25/arch/ppc/kernel/misc.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc/kernel/misc.S	2004-01-19 22:17:21.000000000 -0800
@@ -1385,3 +1385,4 @@ _GLOBAL(sys_call_table)
 	.long sys_statfs64
 	.long sys_fstatfs64
 	.long ppc_fadvise64_64
+	.long sys_ni_syscall	/* 255 - rtas (used on ppc64) */
diff -puN arch/ppc/kernel/module.c~linus arch/ppc/kernel/module.c
--- 25/arch/ppc/kernel/module.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc/kernel/module.c	2004-01-19 22:17:21.000000000 -0800
@@ -88,6 +88,10 @@ static unsigned long get_plt_size(const 
 		    != is_init)
 			continue;
 
+		/* We don't want to look at debug sections. */
+		if (strstr(secstrings + sechdrs[i].sh_name, ".debug") != 0)
+			continue;
+
 		if (sechdrs[i].sh_type == SHT_RELA) {
 			DEBUGP("Found relocations in section %u\n", i);
 			DEBUGP("Ptr: %p.  Number: %u\n",
@@ -265,7 +269,6 @@ int apply_relocate_add(Elf32_Shdr *sechd
 	return 0;
 }
 
-/* FIXME: Sort exception table --RR */
 int module_finalize(const Elf_Ehdr *hdr,
 		    const Elf_Shdr *sechdrs,
 		    struct module *me)
diff -puN arch/ppc/kernel/ppc_ksyms.c~linus arch/ppc/kernel/ppc_ksyms.c
--- 25/arch/ppc/kernel/ppc_ksyms.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc/kernel/ppc_ksyms.c	2004-01-19 22:17:21.000000000 -0800
@@ -92,7 +92,7 @@ EXPORT_SYMBOL(disable_irq_nosync);
 EXPORT_SYMBOL(probe_irq_mask);
 
 EXPORT_SYMBOL(ISA_DMA_THRESHOLD);
-EXPORT_SYMBOL_NOVERS(DMA_MODE_READ);
+EXPORT_SYMBOL(DMA_MODE_READ);
 EXPORT_SYMBOL(DMA_MODE_WRITE);
 #if defined(CONFIG_PPC_PREP)
 EXPORT_SYMBOL(_prep_type);
@@ -167,9 +167,9 @@ EXPORT_SYMBOL(ppc_ide_md);
 #endif
 
 #ifdef CONFIG_PCI
-EXPORT_SYMBOL_NOVERS(isa_io_base);
-EXPORT_SYMBOL_NOVERS(isa_mem_base);
-EXPORT_SYMBOL_NOVERS(pci_dram_offset);
+EXPORT_SYMBOL(isa_io_base);
+EXPORT_SYMBOL(isa_mem_base);
+EXPORT_SYMBOL(pci_dram_offset);
 EXPORT_SYMBOL(pci_alloc_consistent);
 EXPORT_SYMBOL(pci_free_consistent);
 EXPORT_SYMBOL(pci_bus_io_base);
@@ -246,7 +246,7 @@ EXPORT_SYMBOL(register_backlight_control
 EXPORT_SYMBOL(_machine);
 #endif
 #ifdef CONFIG_PPC_PMAC
-EXPORT_SYMBOL_NOVERS(sys_ctrler);
+EXPORT_SYMBOL(sys_ctrler);
 EXPORT_SYMBOL(pmac_newworld);
 #endif
 #ifdef CONFIG_PPC_OF
@@ -294,15 +294,15 @@ EXPORT_SYMBOL(to_tm);
 
 EXPORT_SYMBOL(pm_power_off);
 
-EXPORT_SYMBOL_NOVERS(__ashrdi3);
-EXPORT_SYMBOL_NOVERS(__ashldi3);
-EXPORT_SYMBOL_NOVERS(__lshrdi3);
-EXPORT_SYMBOL_NOVERS(memcpy);
-EXPORT_SYMBOL_NOVERS(memset);
-EXPORT_SYMBOL_NOVERS(memmove);
-EXPORT_SYMBOL_NOVERS(memscan);
-EXPORT_SYMBOL_NOVERS(memcmp);
-EXPORT_SYMBOL_NOVERS(memchr);
+EXPORT_SYMBOL(__ashrdi3);
+EXPORT_SYMBOL(__ashldi3);
+EXPORT_SYMBOL(__lshrdi3);
+EXPORT_SYMBOL(memcpy);
+EXPORT_SYMBOL(memset);
+EXPORT_SYMBOL(memmove);
+EXPORT_SYMBOL(memscan);
+EXPORT_SYMBOL(memcmp);
+EXPORT_SYMBOL(memchr);
 
 EXPORT_SYMBOL(abs);
 
@@ -366,7 +366,7 @@ EXPORT_SYMBOL(request_8xxirq);
 EXPORT_SYMBOL(next_mmu_context);
 EXPORT_SYMBOL(set_context);
 EXPORT_SYMBOL(handle_mm_fault); /* For MOL */
-EXPORT_SYMBOL_NOVERS(disarm_decr);
+EXPORT_SYMBOL(disarm_decr);
 #ifdef CONFIG_PPC_STD_MMU
 extern long mol_trampoline;
 EXPORT_SYMBOL(mol_trampoline); /* For MOL */
@@ -381,5 +381,5 @@ EXPORT_SYMBOL(intercept_table);
 EXPORT_SYMBOL(cur_cpu_spec);
 #ifdef CONFIG_PPC_PMAC
 extern unsigned long agp_special_page;
-EXPORT_SYMBOL_NOVERS(agp_special_page);
+EXPORT_SYMBOL(agp_special_page);
 #endif
diff -puN arch/ppc/kernel/syscalls.c~linus arch/ppc/kernel/syscalls.c
--- 25/arch/ppc/kernel/syscalls.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc/kernel/syscalls.c	2004-01-19 22:17:21.000000000 -0800
@@ -271,5 +271,3 @@ long ppc_fadvise64_64(int fd, int advice
 {
 	return sys_fadvise64_64(fd, offset, len, advice);
 }
-
-cond_syscall(sys_pciconfig_iobase);
diff -puN arch/ppc/mm/cachemap.c~linus arch/ppc/mm/cachemap.c
--- 25/arch/ppc/mm/cachemap.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc/mm/cachemap.c	2004-01-19 22:17:21.000000000 -0800
@@ -170,3 +170,5 @@ void consistent_sync_page(struct page *p
 	start = (unsigned long)page_address(page) + offset;
 	consistent_sync((void *)start, size, direction);
 }
+
+EXPORT_SYMBOL(consistent_sync_page);
diff -puN -L arch/ppc/mm/extable.c arch/ppc/mm/extable.c~linus /dev/null
--- 25/arch/ppc/mm/extable.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,70 +0,0 @@
-/*
- * arch/ppc/mm/extable.c
- *
- * from arch/i386/mm/extable.c
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <asm/uaccess.h>
-
-extern struct exception_table_entry __start___ex_table[];
-extern struct exception_table_entry __stop___ex_table[];
-
-/*
- * The exception table needs to be sorted because we use the macros
- * which put things into the exception table in a variety of segments
- * such as the prep, pmac, chrp, etc. segments as well as the init
- * segment and the main kernel text segment.
- */
-static inline void
-sort_ex_table(struct exception_table_entry *start,
-	      struct exception_table_entry *finish)
-{
-	struct exception_table_entry el, *p, *q;
-
-	/* insertion sort */
-	for (p = start + 1; p < finish; ++p) {
-		/* start .. p-1 is sorted */
-		if (p[0].insn < p[-1].insn) {
-			/* move element p down to its right place */
-			el = *p;
-			q = p;
-			do {
-				/* el comes before q[-1], move q[-1] up one */
-				q[0] = q[-1];
-				--q;
-			} while (q > start && el.insn < q[-1].insn);
-			*q = el;
-		}
-	}
-}
-
-void __init
-sort_exception_table(void)
-{
-	sort_ex_table(__start___ex_table, __stop___ex_table);
-}
-
-/* Simple binary search */
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
-	       const struct exception_table_entry *last,
-	       unsigned long value)
-{
-        while (first <= last) {
-		const struct exception_table_entry *mid;
-		long diff;
-
-		mid = (last - first) / 2 + first;
-		diff = mid->insn - value;
-                if (diff == 0)
-                        return mid;
-                else if (diff < 0)
-                        first = mid+1;
-                else
-                        last = mid-1;
-        }
-	return NULL;
-}
diff -puN arch/ppc/mm/Makefile~linus arch/ppc/mm/Makefile
--- 25/arch/ppc/mm/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/ppc/mm/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -6,7 +6,7 @@ ifdef CONFIG_PPC64BRIDGE
 EXTRA_AFLAGS		:= -Wa,-mppc64bridge
 endif
 
-obj-y				:= fault.o init.o mem_pieces.o extable.o \
+obj-y				:= fault.o init.o mem_pieces.o \
 					mmu_context.o pgtable.o
 
 obj-$(CONFIG_PPC_STD_MMU)	+= hashtable.o ppc_mmu.o tlb.o
diff -puN -L arch/ppc/platforms/mpc82xx.h arch/ppc/platforms/mpc82xx.h~linus /dev/null
--- 25/arch/ppc/platforms/mpc82xx.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,42 +0,0 @@
-/*
- * arch/ppc/platforms/mpc82xx.h
- *
- * Board specific support for various 82xx platforms.
- *
- * Author: Allen Curtis <acurtis@onz.com>
- *
- * Copyright 2002 Ones and Zeros, 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.
- */
-#ifndef __CONFIG_82XX_PLATFORMS
-#define __CONFIG_82XX_PLATFORMS
-
-#ifdef CONFIG_8260
-
-#ifdef CONFIG_EST8260
-#include <platforms/est8260.h>
-#endif
-
-#ifdef CONFIG_SBS8260
-#include <platforms/sbs8260.h>
-#endif
-
-#ifdef CONFIG_RPX6
-#include <platforms/rpxsuper.h>
-#endif
-
-#ifdef CONFIG_WILLOW
-#include <platforms/willow.h>
-#endif
-
-#ifdef CONFIG_TQM8260
-#include <platforms/tqm8260.h>
-#endif
-
-#endif	/* CONFIG_8260 */
-
-#endif
diff -puN arch/s390/defconfig~linus arch/s390/defconfig
--- 25/arch/s390/defconfig~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/defconfig	2004-01-19 22:17:21.000000000 -0800
@@ -29,6 +29,7 @@ CONFIG_EPOLL=y
 CONFIG_IOSCHED_NOOP=y
 CONFIG_IOSCHED_AS=y
 CONFIG_IOSCHED_DEADLINE=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 
 #
 # Loadable module support
@@ -109,8 +110,8 @@ CONFIG_SCSI_LOGGING=y
 #
 # SCSI low-level drivers
 #
-# CONFIG_SCSI_AIC7XXX is not set
 # CONFIG_SCSI_AIC7XXX_OLD is not set
+# CONFIG_SCSI_SATA is not set
 # CONFIG_SCSI_EATA_PIO is not set
 # CONFIG_SCSI_DEBUG is not set
 CONFIG_ZFCP=y
@@ -158,7 +159,8 @@ CONFIG_UNIX98_PTY_COUNT=2048
 #
 # S/390 character device drivers
 #
-# CONFIG_TN3270 is not set
+CONFIG_TN3270=y
+CONFIG_TN3270_CONSOLE=y
 CONFIG_TN3215=y
 CONFIG_TN3215_CONSOLE=y
 CONFIG_CCW_CONSOLE=y
@@ -318,6 +320,21 @@ CONFIG_QETH=y
 CONFIG_CCWGROUP=y
 
 #
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
+# IrDA (infrared) support
+#
+# CONFIG_IRDA is not set
+
+#
+# Bluetooth support
+#
+# CONFIG_BT is not set
+
+#
 # File systems
 #
 CONFIG_EXT2_FS=y
@@ -358,8 +375,7 @@ CONFIG_PROC_KCORE=y
 # CONFIG_DEVFS_FS is not set
 CONFIG_DEVPTS_FS=y
 # CONFIG_DEVPTS_FS_XATTR is not set
-# CONFIG_TMPFS is not set
-# CONFIG_HUGETLBFS is not set
+CONFIG_TMPFS=y
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
 
@@ -385,6 +401,7 @@ CONFIG_RAMFS=y
 CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
 # CONFIG_NFS_V4 is not set
+# CONFIG_NFS_DIRECTIO is not set
 CONFIG_NFSD=y
 CONFIG_NFSD_V3=y
 # CONFIG_NFSD_V4 is not set
@@ -424,6 +441,11 @@ CONFIG_MSDOS_PARTITION=y
 # CONFIG_EFI_PARTITION is not set
 
 #
+# Native Language Support
+#
+# CONFIG_NLS is not set
+
+#
 # Kernel hacking
 #
 CONFIG_DEBUG_KERNEL=y
diff -puN arch/s390/Kconfig~linus arch/s390/Kconfig
--- 25/arch/s390/Kconfig~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -97,6 +97,7 @@ config SMP
 
 config NR_CPUS
 	int "Maximum number of CPUs (2-32)"
+	range 2 32
 	depends on SMP && ARCH_S390X = 'n'
 	default "32"
 	help
@@ -109,6 +110,7 @@ config NR_CPUS
 	
 config NR_CPUS
 	int "Maximum number of CPUs (2-64)"
+	range 2 64
 	depends on SMP && ARCH_S390X
 	default "64"
 	help
diff -puN arch/s390/kernel/compat_ioctl.c~linus arch/s390/kernel/compat_ioctl.c
--- 25/arch/s390/kernel/compat_ioctl.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/kernel/compat_ioctl.c	2004-01-19 22:17:21.000000000 -0800
@@ -2,818 +2,46 @@
  * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
  *
  *  S390 version
- *    Copyright (C) 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ *    Copyright (C) 2000-2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
  *    Author(s): Gerhard Tonn (ton@de.ibm.com)
+ *               Arnd Bergmann (arndb@de.ibm.com)
  *
- * Heavily inspired by the 32-bit Sparc compat code which is  
+ * Original implementation from 32-bit Sparc compat code which is
  * Copyright (C) 2000 Silicon Graphics, Inc.
  * Written by Ulf Carlsson (ulfc@engr.sgi.com) 
- *
  */
 
-#include <linux/compat.h>
-#include <linux/init.h>
-#include <linux/ioctl32.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/sched.h>
-#include <linux/types.h>
-
-#include <asm/ioctls.h>
-#include <asm/types.h>
-#include <asm/uaccess.h>
-
-#include <linux/blkdev.h>
-#include <linux/blkpg.h>
-#include <linux/cdrom.h>
-#include <linux/dm-ioctl.h>
-#include <linux/elevator.h>
-#include <linux/file.h>
-#include <linux/fs.h>
-#include <linux/hdreg.h>
-#include <linux/kd.h>
-#include <linux/loop.h>
-#include <linux/lp.h>
-#include <linux/mtio.h>
-#include <linux/netdevice.h>
-#include <linux/nbd.h>
-#include <linux/ppp_defs.h>
-#include <linux/raid/md_u.h>
-#include <linux/random.h>
-#include <linux/raw.h>
-#include <linux/route.h>
-#include <linux/rtc.h>
-#include <linux/vt.h>
-#include <linux/watchdog.h>
-
-#include <linux/auto_fs.h>
-#include <linux/auto_fs4.h>
-#include <linux/devfs_fs.h>
-#include <linux/ext2_fs.h>
-#include <linux/ncp_fs.h>
-#include <linux/smb_fs.h>
-
-#include <linux/if_bonding.h>
-#include <linux/if_ppp.h>
-#include <linux/if_pppox.h>
-#include <linux/if_tun.h>
-
-#include <scsi/scsi.h>
-#include <scsi/scsi_ioctl.h>
-#include <scsi/sg.h>
-
+#include "compat_linux.h"
+#define INCLUDES
+#define CODE
+#include "../../../fs/compat_ioctl.c"
 #include <asm/dasd.h>
-#include <asm/sockios.h>
 #include <asm/tape390.h>
 
-#include "compat_linux.h"
-
-long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
-
-struct hd_geometry32 {
-	unsigned char	heads;
-	unsigned char	sectors;
-	unsigned short	cylinders;
-	__u32		start;
-};  
-
-static inline int hd_geometry_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg,
-				    struct file *f)
-{
-	struct hd_geometry32 *hg32 = (struct hd_geometry32 *) A(arg);
-	struct hd_geometry hg;
-	int ret;
-	mm_segment_t old_fs = get_fs();
-	
-	set_fs (KERNEL_DS);
-	ret = sys_ioctl (fd, cmd, (long)&hg);
-	set_fs (old_fs);
-
-	if (ret)
-		return ret;
-
-	ret = put_user (hg.heads, &(hg32->heads));
-	ret |= __put_user (hg.sectors, &(hg32->sectors));
-	ret |= __put_user (hg.cylinders, &(hg32->cylinders));
-	ret |= __put_user (hg.start, &(hg32->start));
-
-	return ret;
-}
-
-#define EXT2_IOC32_GETFLAGS               _IOR('f', 1, int)
-#define EXT2_IOC32_SETFLAGS               _IOW('f', 2, int)
-#define EXT2_IOC32_GETVERSION             _IOR('v', 1, int)
-#define EXT2_IOC32_SETVERSION             _IOW('v', 2, int)
-
-struct ifmap32 {
-	unsigned int mem_start;
-	unsigned int mem_end;
-	unsigned short base_addr;
-	unsigned char irq;
-	unsigned char dma;
-	unsigned char port;
-};
-
-struct ifreq32 {
-#define IFHWADDRLEN     6
-#define IFNAMSIZ        16
-        union {
-                char    ifrn_name[IFNAMSIZ];	/* if name, e.g. "en0" */
-        } ifr_ifrn;
-        union {
-                struct  sockaddr ifru_addr;
-                struct  sockaddr ifru_dstaddr;
-                struct  sockaddr ifru_broadaddr;
-                struct  sockaddr ifru_netmask;
-                struct  sockaddr ifru_hwaddr;
-                short   ifru_flags;
-                int     ifru_ivalue;
-                int     ifru_mtu;
-                struct  ifmap32 ifru_map;
-                char    ifru_slave[IFNAMSIZ];   /* Just fits the size */
-		char	ifru_newname[IFNAMSIZ];
-                __u32	ifru_data;
-        } ifr_ifru;
-};
-
-struct ifconf32 {
-        int     ifc_len;                        /* size of buffer       */
-        __u32	ifcbuf;
-};
-
-static int dev_ifname32(unsigned int fd, unsigned int cmd,
-			unsigned long arg, struct file *f)
-{
-	struct ireq32 *uir32 = (struct ireq32 *) A(arg);
-	struct net_device *dev;
-	struct ifreq32 ifr32;
-
-	if (copy_from_user(&ifr32, uir32, sizeof(struct ifreq32)))
-		return -EFAULT;
-
-	read_lock(&dev_base_lock);
-	dev = __dev_get_by_index(ifr32.ifr_ifindex);
-	if (!dev) {
-		read_unlock(&dev_base_lock);
-		return -ENODEV;
-	}
-
-	strcpy(ifr32.ifr_name, dev->name);
-	read_unlock(&dev_base_lock);
-
-	if (copy_to_user(uir32, &ifr32, sizeof(struct ifreq32)))
-	    return -EFAULT;
-
-	return 0;
-}
-
-static int dev_ifconf(unsigned int fd, unsigned int cmd,
-		      unsigned long arg, struct file *f)
-{
-	struct ioconf32 *uifc32 = (struct ioconf32 *) A(arg);
-	struct ifconf32 ifc32;
-	struct ifconf ifc;
-	struct ifreq32 *ifr32;
-	struct ifreq *ifr;
-	mm_segment_t old_fs;
-	int len;
-	int err;
-
-	if (copy_from_user(&ifc32, uifc32, sizeof(struct ifconf32)))
-		return -EFAULT;
-
-	if(ifc32.ifcbuf == 0) {
-		ifc32.ifc_len = 0;
-		ifc.ifc_len = 0;
-		ifc.ifc_buf = NULL;
-	} else {
-		ifc.ifc_len = ((ifc32.ifc_len / sizeof (struct ifreq32))) *
-			sizeof (struct ifreq);
-		ifc.ifc_buf = kmalloc (ifc.ifc_len, GFP_KERNEL);
-		if (!ifc.ifc_buf)
-			return -ENOMEM;
-	}
-	ifr = ifc.ifc_req;
-	ifr32 = (struct ifreq32 *) A(ifc32.ifcbuf);
-	len = ifc32.ifc_len / sizeof (struct ifreq32);
-	while (len--) {
-		if (copy_from_user(ifr++, ifr32++, sizeof (struct ifreq32))) {
-			err = -EFAULT;
-			goto out;
-		}
-	}
-
-	old_fs = get_fs();
-	set_fs (KERNEL_DS);
-	err = sys_ioctl (fd, SIOCGIFCONF, (unsigned long)&ifc);	
-	set_fs (old_fs);
-	if (err)
-		goto out;
-
-	ifr = ifc.ifc_req;
-	ifr32 = (struct ifreq32 *) A(ifc32.ifcbuf);
-	len = ifc.ifc_len / sizeof (struct ifreq);
-	ifc32.ifc_len = len * sizeof (struct ifreq32);
-
-	while (len--) {
-		if (copy_to_user(ifr32++, ifr++, sizeof (struct ifreq32))) {
-			err = -EFAULT;
-			goto out;
-		}
-	}
-
-	if (copy_to_user(uifc32, &ifc32, sizeof(struct ifconf32))) {
-		err = -EFAULT;
-		goto out;
-	}
-out:
-	if(ifc.ifc_buf != NULL)
-		kfree (ifc.ifc_buf);
-	return err;
-}
-
-static int bond_ioctl(unsigned int fd, unsigned int cmd,
-		      unsigned long arg, struct file *f)
-{
-	struct ifreq ifr;
-	mm_segment_t old_fs;
-	int err, len;
-	u32 data;
-	
-	if (copy_from_user(&ifr, (struct ifreq32 *)arg, sizeof(struct ifreq32)))
-		return -EFAULT;
-	ifr.ifr_data = (__kernel_caddr_t)get_zeroed_page(GFP_KERNEL);
-	if (!ifr.ifr_data)
-		return -EAGAIN;
-
-	switch (cmd) {
-	case SIOCBONDENSLAVE:
-	case SIOCBONDRELEASE:
-	case SIOCBONDSETHWADDR:
-	case SIOCBONDCHANGEACTIVE:
-		len = IFNAMSIZ * sizeof(char);
-		break;
-	case SIOCBONDSLAVEINFOQUERY:
-		len = sizeof(struct ifslave);
-		break;
-	case SIOCBONDINFOQUERY:
-		len = sizeof(struct ifbond);
-		break;
-	default:
-		err = -EINVAL;
-		goto out;
-	};
-
-	__get_user(data, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_data));
-	if (copy_from_user(ifr.ifr_data, (char *)A(data), len)) {
-		err = -EFAULT;
-		goto out;
-	}
-
-	old_fs = get_fs();
-	set_fs (KERNEL_DS);
-	err = sys_ioctl (fd, cmd, (unsigned long)&ifr);
-	set_fs (old_fs);
-	if (!err) {
-		len = copy_to_user((char *)A(data), ifr.ifr_data, len);
-		if (len)
-			err = -EFAULT;
-	}
-
-out:
-	free_page((unsigned long)ifr.ifr_data);
-	return err;
-}
-
-static int dev_ifsioc(unsigned int fd, unsigned int cmd,
-			     unsigned long arg, struct file *f)
+static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd,
+				unsigned long arg, struct file *f)
 {
-	struct ifreq32 *uifr = (struct ifreq32 *) A(arg);
-	struct ifreq ifr;
-	mm_segment_t old_fs;
-	int err;
-	
-	switch (cmd) {
-	case SIOCSIFMAP:
-		err = copy_from_user(&ifr, uifr, sizeof(ifr.ifr_name));
-		err |= __get_user(ifr.ifr_map.mem_start, &(uifr->ifr_ifru.ifru_map.mem_start));
-		err |= __get_user(ifr.ifr_map.mem_end, &(uifr->ifr_ifru.ifru_map.mem_end));
-		err |= __get_user(ifr.ifr_map.base_addr, &(uifr->ifr_ifru.ifru_map.base_addr));
-		err |= __get_user(ifr.ifr_map.irq, &(uifr->ifr_ifru.ifru_map.irq));
-		err |= __get_user(ifr.ifr_map.dma, &(uifr->ifr_ifru.ifru_map.dma));
-		err |= __get_user(ifr.ifr_map.port, &(uifr->ifr_ifru.ifru_map.port));
-		if (err)
-			return -EFAULT;
-		break;
-	default:
-		if (copy_from_user(&ifr, uifr, sizeof(struct ifreq32)))
-			return -EFAULT;
-		break;
-	}
-	old_fs = get_fs();
-	set_fs (KERNEL_DS);
-	err = sys_ioctl (fd, cmd, (unsigned long)&ifr);
-	set_fs (old_fs);
-	if (!err) {
-		switch (cmd) {
-		case SIOCGIFFLAGS:
-		case SIOCGIFMETRIC:
-		case SIOCGIFMTU:
-		case SIOCGIFMEM:
-		case SIOCGIFHWADDR:
-		case SIOCGIFINDEX:
-		case SIOCGIFADDR:
-		case SIOCGIFBRDADDR:
-		case SIOCGIFDSTADDR:
-		case SIOCGIFNETMASK:
-		case SIOCGIFTXQLEN:
-			if (copy_to_user(uifr, &ifr, sizeof(struct ifreq32)))
-				return -EFAULT;
-			break;
-		case SIOCGIFMAP:
-			err = copy_to_user(uifr, &ifr, sizeof(ifr.ifr_name));
-			err |= __put_user(ifr.ifr_map.mem_start, &(uifr->ifr_ifru.ifru_map.mem_start));
-			err |= __put_user(ifr.ifr_map.mem_end, &(uifr->ifr_ifru.ifru_map.mem_end));
-			err |= __put_user(ifr.ifr_map.base_addr, &(uifr->ifr_ifru.ifru_map.base_addr));
-			err |= __put_user(ifr.ifr_map.irq, &(uifr->ifr_ifru.ifru_map.irq));
-			err |= __put_user(ifr.ifr_map.dma, &(uifr->ifr_ifru.ifru_map.dma));
-			err |= __put_user(ifr.ifr_map.port, &(uifr->ifr_ifru.ifru_map.port));
-			if (err)
-				err = -EFAULT;
-			break;
-		}
-	}
-	return err;
+	return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
 }
 
-struct rtentry32
-{
-	unsigned int	rt_pad1;
-	struct sockaddr	rt_dst;		/* target address		*/
-	struct sockaddr	rt_gateway;	/* gateway addr (RTF_GATEWAY)	*/
-	struct sockaddr	rt_genmask;	/* target network mask (IP)	*/
-	unsigned short	rt_flags;
-	short		rt_pad2;
-	unsigned int	rt_pad3;
-	unsigned int	rt_pad4;
-	short		rt_metric;	/* +1 for binary compatibility!	*/
-	unsigned int	rt_dev;		/* forcing the device at add	*/
-	unsigned int	rt_mtu;		/* per route MTU/Window 	*/
-#ifndef __KERNEL__
-#define rt_mss	rt_mtu			/* Compatibility :-(            */
-#endif
-	unsigned int	rt_window;	/* Window clamping 		*/
-	unsigned short	rt_irtt;	/* Initial RTT			*/
-};
-
-static int routing_ioctl(unsigned int fd, unsigned int cmd,
-			 unsigned long arg, struct file *f)
+static int do_ioctl32_ulong(unsigned int fd, unsigned int cmd,
+				unsigned long arg, struct file *f)
 {
-	struct rtentry32 *ur = (struct rtentry32 *) A(arg);
-	struct rtentry r;
-	char devname[16];
-	u32 rtdev;
-	int ret;
-	mm_segment_t old_fs = get_fs();
-	
-	ret = copy_from_user (&r.rt_dst, &(ur->rt_dst), 3 * sizeof(struct sockaddr));
-	ret |= __get_user (r.rt_flags, &(ur->rt_flags));
-	ret |= __get_user (r.rt_metric, &(ur->rt_metric));
-	ret |= __get_user (r.rt_mtu, &(ur->rt_mtu));
-	ret |= __get_user (r.rt_window, &(ur->rt_window));
-	ret |= __get_user (r.rt_irtt, &(ur->rt_irtt));
-	ret |= __get_user (rtdev, &(ur->rt_dev));
-	if (rtdev) {
-		ret |= copy_from_user (devname, (char *) A(rtdev), 15);
-		r.rt_dev = devname; devname[15] = 0;
-	} else
-		r.rt_dev = 0;
-	if (ret)
-		return -EFAULT;
-	set_fs (KERNEL_DS);
-	ret = sys_ioctl (fd, cmd, (long)&r);
-	set_fs (old_fs);
-	return ret;
-}
-
-static int do_ext2_ioctl(unsigned int fd, unsigned int cmd,
-			 unsigned long arg, struct file *f)
-{
-	/* These are just misnamed, they actually get/put from/to user an int */
-	switch (cmd) {
-	case EXT2_IOC32_GETFLAGS: cmd = EXT2_IOC_GETFLAGS; break;
-	case EXT2_IOC32_SETFLAGS: cmd = EXT2_IOC_SETFLAGS; break;
-	case EXT2_IOC32_GETVERSION: cmd = EXT2_IOC_GETVERSION; break;
-	case EXT2_IOC32_SETVERSION: cmd = EXT2_IOC_SETVERSION; break;
-	}
 	return sys_ioctl(fd, cmd, arg);
 }
 
+#define COMPATIBLE_IOCTL(cmd)		HANDLE_IOCTL((cmd),(ioctl_trans_handler_t)do_ioctl32_pointer)
+#define ULONG_IOCTL(cmd)		HANDLE_IOCTL((cmd),(ioctl_trans_handler_t)do_ioctl32_ulong)
+#define HANDLE_IOCTL(cmd,handler)	{ (cmd), (ioctl_trans_handler_t)(handler), NULL },
 
-struct loop_info32 {
-	int			lo_number;      /* ioctl r/o */
-	compat_dev_t	lo_device;      /* ioctl r/o */
-	unsigned int		lo_inode;       /* ioctl r/o */
-	compat_dev_t	lo_rdevice;     /* ioctl r/o */
-	int			lo_offset;
-	int			lo_encrypt_type;
-	int			lo_encrypt_key_size;    /* ioctl w/o */
-	int			lo_flags;       /* ioctl r/o */
-	char			lo_name[LO_NAME_SIZE];
-	unsigned char		lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
-	unsigned int		lo_init[2];
-	char			reserved[4];
-};
-
-static int loop_status(unsigned int fd, unsigned int cmd,
-		       unsigned long arg, struct file *f)
-{
-	mm_segment_t old_fs = get_fs();
-	struct loop_info l;
-	int err = -EINVAL;
-
-	switch(cmd) {
-	case LOOP_SET_STATUS:
-		err = get_user(l.lo_number, &((struct loop_info32 *)arg)->lo_number);
-		err |= __get_user(l.lo_device, &((struct loop_info32 *)arg)->lo_device);
-		err |= __get_user(l.lo_inode, &((struct loop_info32 *)arg)->lo_inode);
-		err |= __get_user(l.lo_rdevice, &((struct loop_info32 *)arg)->lo_rdevice);
-		err |= __copy_from_user((char *)&l.lo_offset, (char *)&((struct loop_info32 *)arg)->lo_offset,
-					   8 + (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
-		if (err) {
-			err = -EFAULT;
-		} else {
-			set_fs (KERNEL_DS);
-			err = sys_ioctl (fd, cmd, (unsigned long)&l);
-			set_fs (old_fs);
-		}
-		break;
-	case LOOP_GET_STATUS:
-		set_fs (KERNEL_DS);
-		err = sys_ioctl (fd, cmd, (unsigned long)&l);
-		set_fs (old_fs);
-		if (!err) {
-			err = put_user(l.lo_number, &((struct loop_info32 *)arg)->lo_number);
-			err |= __put_user(l.lo_device, &((struct loop_info32 *)arg)->lo_device);
-			err |= __put_user(l.lo_inode, &((struct loop_info32 *)arg)->lo_inode);
-			err |= __put_user(l.lo_rdevice, &((struct loop_info32 *)arg)->lo_rdevice);
-			err |= __copy_to_user((char *)&((struct loop_info32 *)arg)->lo_offset,
-					   (char *)&l.lo_offset, (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
-			if (err)
-				err = -EFAULT;
-		}
-		break;
-	default: {
-		static int count = 0;
-		if (++count <= 20)
-			printk("%s: Unknown loop ioctl cmd, fd(%d) "
-			       "cmd(%08x) arg(%08lx)\n",
-			       __FUNCTION__, fd, cmd, arg);
-	}
-	}
-	return err;
-}
-
-
-struct blkpg_ioctl_arg32 {
-	int op;
-	int flags;
-	int datalen;
-	u32 data;
-};
-                                
-static int blkpg_ioctl_trans(unsigned int fd, unsigned int cmd,
-			     unsigned long uarg, struct file *f)
-{
-	struct blkpg_ioctl_arg a;
-	struct blkpg_partition p;
-	struct blkpg_ioctl_arg32 *arg = (void*)A(uarg);
-	int err;
-	mm_segment_t old_fs = get_fs();
-	
-	err = get_user(a.op, &arg->op);
-	err |= __get_user(a.flags, &arg->flags);
-	err |= __get_user(a.datalen, &arg->datalen);
-	err |= __get_user((long)a.data, &arg->data);
-	if (err) return err;
-	switch (a.op) {
-	case BLKPG_ADD_PARTITION:
-	case BLKPG_DEL_PARTITION:
-		if (a.datalen < sizeof(struct blkpg_partition))
-			return -EINVAL;
-                if (copy_from_user(&p, a.data, sizeof(struct blkpg_partition)))
-			return -EFAULT;
-		a.data = &p;
-		set_fs (KERNEL_DS);
-		err = sys_ioctl(fd, cmd, (unsigned long)&a);
-		set_fs (old_fs);
-	default:
-		return -EINVAL;
-	}                                        
-	return err;
-}
-
-
-typedef struct ica_z90_status_t {
-  int totalcount;
-  int leedslitecount;
-  int leeds2count;
-  int requestqWaitCount;
-  int pendingqWaitCount;
-  int totalOpenCount;
-  int cryptoDomain;
-  unsigned char status[64];
-  unsigned char qdepth[64];
-} ica_z90_status;
-
-typedef struct _ica_rsa_modexpo {
-  char         *inputdata;
-  unsigned int  inputdatalength;
-  char         *outputdata;
-  unsigned int  outputdatalength;
-  char         *b_key;
-  char         *n_modulus;
-} ica_rsa_modexpo_t;
-
-typedef struct _ica_rsa_modexpo_32 {
-  u32          inputdata;
-  u32          inputdatalength;
-  u32          outputdata;
-  u32          outputdatalength;
-  u32          b_key;
-  u32          n_modulus;
-} ica_rsa_modexpo_32_t;
-
-typedef struct _ica_rsa_modexpo_crt {
-  char         *inputdata;
-  unsigned int  inputdatalength;
-  char         *outputdata;
-  unsigned int  outputdatalength;
-  char         *bp_key;
-  char         *bq_key;
-  char         *np_prime;
-  char         *nq_prime;
-  char         *u_mult_inv;
-} ica_rsa_modexpo_crt_t;
-
-typedef struct _ica_rsa_modexpo_crt_32 {
-  u32          inputdata;
-  u32          inputdatalength;
-  u32          outputdata;
-  u32          outputdatalength;
-  u32          bp_key;
-  u32          bq_key;
-  u32          np_prime;
-  u32          nq_prime;
-  u32          u_mult_inv;
-} ica_rsa_modexpo_crt_32_t;
-
-#define ICA_IOCTL_MAGIC 'z'
-#define ICARSAMODEXPO   _IOC(_IOC_READ|_IOC_WRITE, ICA_IOCTL_MAGIC, 0x05, 0)
-#define ICARSACRT       _IOC(_IOC_READ|_IOC_WRITE, ICA_IOCTL_MAGIC, 0x06, 0) 
-#define ICARSAMODMULT   _IOC(_IOC_READ|_IOC_WRITE, ICA_IOCTL_MAGIC, 0x07, 0)
-#define ICAZ90STATUS    _IOC(_IOC_READ, ICA_IOCTL_MAGIC, 0x10, sizeof(ica_z90_status))
-#define ICAZ90QUIESCE   _IOC(_IOC_NONE, ICA_IOCTL_MAGIC, 0x11, 0)
-#define ICAZ90HARDRESET _IOC(_IOC_NONE, ICA_IOCTL_MAGIC, 0x12, 0)
-#define ICAZ90HARDERROR _IOC(_IOC_NONE, ICA_IOCTL_MAGIC, 0x13, 0)
-
-static int do_rsa_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *f)
-{
-	mm_segment_t old_fs = get_fs();
-	int err = 0;
-	ica_rsa_modexpo_t rsa;
-	ica_rsa_modexpo_32_t *rsa32 = (ica_rsa_modexpo_32_t *)arg;
-	u32 inputdata, outputdata, b_key, n_modulus;
-
-	memset (&rsa, 0, sizeof(rsa));
-
-	err |= __get_user (inputdata, &rsa32->inputdata);
-	err |= __get_user (rsa.inputdatalength, &rsa32->inputdatalength);
-	err |= __get_user (outputdata, &rsa32->outputdata);
-	err |= __get_user (rsa.outputdatalength, &rsa32->outputdatalength);
-	err |= __get_user (b_key, &rsa32->b_key);
-	err |= __get_user (n_modulus, &rsa32->n_modulus);
-	if (err)
-		return -EFAULT;
-
-	rsa.inputdata = (char *)kmalloc(rsa.inputdatalength, GFP_KERNEL);
-	if (!rsa.inputdata) {
-		err = -ENOMEM;
-		goto cleanup;
-	}
-	if (copy_from_user(rsa.inputdata, (char *)(u64)(inputdata & 0x7fffffff), 
-			   rsa.inputdatalength)) {
-		err = -EFAULT;
-		goto cleanup;
-	}
-
-	rsa.outputdata = (char *)kmalloc(rsa.outputdatalength, GFP_KERNEL);
-	if (!rsa.outputdata) {
-		err = -ENOMEM;
-		goto cleanup;
-	}
-
-	rsa.b_key = (char *)kmalloc(rsa.inputdatalength, GFP_KERNEL);
-	if (!rsa.b_key) {
-		err = -ENOMEM;
-		goto cleanup;
-	}
-	if (copy_from_user(rsa.b_key, (char *)(u64)(b_key & 0x7fffffff), 
-			   rsa.inputdatalength)) {
-		err = -EFAULT;
-		goto cleanup;
-	}
-
-	rsa.n_modulus = (char *)kmalloc(rsa.inputdatalength, GFP_KERNEL);
-	if (!rsa.n_modulus) {
-		err = -ENOMEM;
-		goto cleanup;
-	}
-	if (copy_from_user(rsa.n_modulus, (char *)(u64)(n_modulus & 0x7fffffff), 
-			   rsa.inputdatalength)) {
-		err = -EFAULT;
-		goto cleanup;
-	}
-
-	set_fs(KERNEL_DS);
-	err = sys_ioctl(fd, cmd, (unsigned long)&rsa);
-	set_fs(old_fs);
-	if (err < 0)
-		goto cleanup;
-
-	if (copy_to_user((char *)(u64)(outputdata & 0x7fffffff), rsa.outputdata,
-			 rsa.outputdatalength))
-		err = -EFAULT;
-
-cleanup:
-	if (rsa.inputdata)
-		kfree(rsa.inputdata);
-	if (rsa.outputdata)
-		kfree(rsa.outputdata);
-	if (rsa.b_key)
-		kfree(rsa.b_key);
-	if (rsa.n_modulus)
-		kfree(rsa.n_modulus);
-	
-	return err;
-}
-
-static int do_rsa_crt_ioctl(unsigned int fd, unsigned int cmd,
-			    unsigned long arg, struct file *f)
-{
-	mm_segment_t old_fs = get_fs();
-	int err = 0;
-	ica_rsa_modexpo_crt_t rsa;
-	ica_rsa_modexpo_crt_32_t *rsa32 = (ica_rsa_modexpo_crt_32_t *)arg;
-	u32 inputdata, outputdata, bp_key, bq_key, np_prime, nq_prime, u_mult_inv;
-
-	memset (&rsa, 0, sizeof(rsa));
-
-	err |= __get_user (inputdata, &rsa32->inputdata);
-	err |= __get_user (rsa.inputdatalength, &rsa32->inputdatalength);
-	err |= __get_user (outputdata, &rsa32->outputdata);
-	err |= __get_user (rsa.outputdatalength, &rsa32->outputdatalength);
-	err |= __get_user (bp_key, &rsa32->bp_key);
-	err |= __get_user (bq_key, &rsa32->bq_key);
-	err |= __get_user (np_prime, &rsa32->np_prime);
-	err |= __get_user (nq_prime, &rsa32->nq_prime);
-	err |= __get_user (u_mult_inv, &rsa32->u_mult_inv);
-	if (err)
-		return -EFAULT;
-
-	rsa.inputdata = (char *)kmalloc(rsa.inputdatalength, GFP_KERNEL);
-	if (!rsa.inputdata) {
-		err = -ENOMEM;
-		goto cleanup;
-	}
-	if (copy_from_user(rsa.inputdata, (char *)(u64)(inputdata & 0x7fffffff), 
-			   rsa.inputdatalength)) {
-		err = -EFAULT;
-		goto cleanup;
-	}
-
-	rsa.outputdata = (char *)kmalloc(rsa.outputdatalength, GFP_KERNEL);
-	if (!rsa.outputdata) {
-		err = -ENOMEM;
-		goto cleanup;
-	}
-
-	rsa.bp_key = (char *)kmalloc(rsa.inputdatalength/2 + 8, GFP_KERNEL);
-	if (!rsa.bp_key) {
-		err = -ENOMEM;
-		goto cleanup;
-	}
-	if (copy_from_user(rsa.bp_key, (char *)(u64)(bp_key & 0x7fffffff), 
-			   rsa.inputdatalength/2 + 8)) {
-		err = -EFAULT;
-		goto cleanup;
-	}
-
-	rsa.bq_key = (char *)kmalloc(rsa.inputdatalength/2, GFP_KERNEL);
-	if (!rsa.bq_key) {
-		err = -ENOMEM;
-		goto cleanup;
-	}
-	if (copy_from_user(rsa.bq_key, (char *)(u64)(bq_key & 0x7fffffff), 
-			   rsa.inputdatalength/2)) {
-		err = -EFAULT;
-		goto cleanup;
-	}
-
-	rsa.np_prime = (char *)kmalloc(rsa.inputdatalength/2 + 8, GFP_KERNEL);
-	if (!rsa.np_prime) {
-		err = -ENOMEM;
-		goto cleanup;
-	}
-	if (copy_from_user(rsa.np_prime, (char *)(u64)(np_prime & 0x7fffffff), 
-			   rsa.inputdatalength/2 + 8)) {
-		err = -EFAULT;
-		goto cleanup;
-	}
-
-	rsa.nq_prime = (char *)kmalloc(rsa.inputdatalength/2, GFP_KERNEL);
-	if (!rsa.nq_prime) {
-		err = -ENOMEM;
-		goto cleanup;
-	}
-	if (copy_from_user(rsa.nq_prime, (char *)(u64)(nq_prime & 0x7fffffff), 
-			   rsa.inputdatalength/2)) {
-		err = -EFAULT;
-		goto cleanup;
-	}
-
-	rsa.u_mult_inv = (char *)kmalloc(rsa.inputdatalength/2 + 8, GFP_KERNEL);
-	if (!rsa.u_mult_inv) {
-		err = -ENOMEM;
-		goto cleanup;
-	}
-	if (copy_from_user(rsa.u_mult_inv, (char *)(u64)(u_mult_inv & 0x7fffffff), 
-			   rsa.inputdatalength/2 + 8)) {
-		err = -EFAULT;
-		goto cleanup;
-	}
-
-	set_fs(KERNEL_DS);
-	err = sys_ioctl(fd, cmd, (unsigned long)&rsa);
-	set_fs(old_fs);
-	if (err < 0)
-		goto cleanup;
-
-	if (copy_to_user((char *)(u64)(outputdata & 0x7fffffff), rsa.outputdata,
-			 rsa.outputdatalength))
-		err = -EFAULT;
-
-cleanup:
-	if (rsa.inputdata)
-		kfree(rsa.inputdata);
-	if (rsa.outputdata)
-		kfree(rsa.outputdata);
-	if (rsa.bp_key)
-		kfree(rsa.bp_key);
-	if (rsa.bq_key)
-		kfree(rsa.bq_key);
-	if (rsa.np_prime)
-		kfree(rsa.np_prime);
-	if (rsa.nq_prime)
-		kfree(rsa.nq_prime);
-	if (rsa.u_mult_inv)
-		kfree(rsa.u_mult_inv);
-	
-	return err;
-}
-
-static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg,
-		  struct file *f)
-{
-	mm_segment_t old_fs = get_fs();
-	int err;
-	unsigned long val;
-	
-	set_fs (KERNEL_DS);
-	err = sys_ioctl(fd, cmd, (unsigned long)&val);
-	set_fs (old_fs);
-	if (!err && put_user((unsigned int) val, (u32 *)arg))
-		return -EFAULT;
-	return err;
-}
-
-int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd,
-			 unsigned long arg, struct file *f)
-{
-	/* siocdevprivate cannot be emulated properly */
-	return -EINVAL;
-}
-
-#define COMPATIBLE_IOCTL(cmd)		HANDLE_IOCTL((cmd), NULL)
-#define HANDLE_IOCTL(cmd,handler)	{ (cmd), (handler), NULL },
-#define IOCTL_TABLE_START \
-	struct ioctl_trans ioctl_start[] = {
-#define IOCTL_TABLE_END \
-	};
-
-IOCTL_TABLE_START
+struct ioctl_trans ioctl_start[] = {
+/* architecture independent ioctls */
 #include <linux/compat_ioctl.h>
+#define DECLARES
+#include "../../../fs/compat_ioctl.c"
 
+/* s390 only ioctls */
+#if defined(CONFIG_DASD) || defined(CONFIG_DASD_MODULE)
 COMPATIBLE_IOCTL(DASDAPIVER)
 COMPATIBLE_IOCTL(BIODASDDISABLE)
 COMPATIBLE_IOCTL(BIODASDENABLE)
@@ -822,83 +50,18 @@ COMPATIBLE_IOCTL(BIODASDRLSE)
 COMPATIBLE_IOCTL(BIODASDSLCK)
 COMPATIBLE_IOCTL(BIODASDINFO)
 COMPATIBLE_IOCTL(BIODASDFMT)
+#endif
 
+#if defined(CONFIG_S390_TAPE) || defined(CONFIG_S390_TAPE_MODULE)
 COMPATIBLE_IOCTL(TAPE390_DISPLAY)
-COMPATIBLE_IOCTL(BLKRASET)
-COMPATIBLE_IOCTL(BLKFRASET)
-COMPATIBLE_IOCTL(BLKBSZGET)
-COMPATIBLE_IOCTL(BLKGETSIZE64)
-
-HANDLE_IOCTL(HDIO_GETGEO, hd_geometry_ioctl)
+#endif
 
+/* This one should be architecture independent */
 COMPATIBLE_IOCTL(TCSBRKP)
 
+/* s390 doesn't need handlers here */
 COMPATIBLE_IOCTL(TIOCGSERIAL)
 COMPATIBLE_IOCTL(TIOCSSERIAL)
-
-COMPATIBLE_IOCTL(SIOCGSTAMP)
-
-HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32)
-HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf)
-HANDLE_IOCTL(SIOCGIFFLAGS, dev_ifsioc)
-HANDLE_IOCTL(SIOCSIFFLAGS, dev_ifsioc)
-HANDLE_IOCTL(SIOCGIFMETRIC, dev_ifsioc)
-HANDLE_IOCTL(SIOCSIFMETRIC, dev_ifsioc)
-HANDLE_IOCTL(SIOCGIFMTU, dev_ifsioc)
-HANDLE_IOCTL(SIOCSIFMTU, dev_ifsioc)
-HANDLE_IOCTL(SIOCGIFMEM, dev_ifsioc)
-HANDLE_IOCTL(SIOCSIFMEM, dev_ifsioc)
-HANDLE_IOCTL(SIOCGIFHWADDR, dev_ifsioc)
-HANDLE_IOCTL(SIOCSIFHWADDR, dev_ifsioc)
-HANDLE_IOCTL(SIOCADDMULTI, dev_ifsioc)
-HANDLE_IOCTL(SIOCDELMULTI, dev_ifsioc)
-HANDLE_IOCTL(SIOCGIFINDEX, dev_ifsioc)
-HANDLE_IOCTL(SIOCGIFMAP, dev_ifsioc)
-HANDLE_IOCTL(SIOCSIFMAP, dev_ifsioc)
-HANDLE_IOCTL(SIOCGIFADDR, dev_ifsioc)
-HANDLE_IOCTL(SIOCSIFADDR, dev_ifsioc)
-HANDLE_IOCTL(SIOCGIFBRDADDR, dev_ifsioc)
-HANDLE_IOCTL(SIOCSIFBRDADDR, dev_ifsioc)
-HANDLE_IOCTL(SIOCGIFDSTADDR, dev_ifsioc)
-HANDLE_IOCTL(SIOCSIFDSTADDR, dev_ifsioc)
-HANDLE_IOCTL(SIOCGIFNETMASK, dev_ifsioc)
-HANDLE_IOCTL(SIOCSIFNETMASK, dev_ifsioc)
-HANDLE_IOCTL(SIOCSIFPFLAGS, dev_ifsioc)
-HANDLE_IOCTL(SIOCGIFPFLAGS, dev_ifsioc)
-HANDLE_IOCTL(SIOCGIFTXQLEN, dev_ifsioc)
-HANDLE_IOCTL(SIOCSIFTXQLEN, dev_ifsioc)
-HANDLE_IOCTL(SIOCADDRT, routing_ioctl)
-HANDLE_IOCTL(SIOCDELRT, routing_ioctl)
-HANDLE_IOCTL(SIOCBONDENSLAVE, bond_ioctl)
-HANDLE_IOCTL(SIOCBONDRELEASE, bond_ioctl)
-HANDLE_IOCTL(SIOCBONDSETHWADDR, bond_ioctl)
-HANDLE_IOCTL(SIOCBONDSLAVEINFOQUERY, bond_ioctl)
-HANDLE_IOCTL(SIOCBONDINFOQUERY, bond_ioctl)
-HANDLE_IOCTL(SIOCBONDCHANGEACTIVE, bond_ioctl)
-
-HANDLE_IOCTL(EXT2_IOC32_GETFLAGS, do_ext2_ioctl)
-HANDLE_IOCTL(EXT2_IOC32_SETFLAGS, do_ext2_ioctl)
-HANDLE_IOCTL(EXT2_IOC32_GETVERSION, do_ext2_ioctl)
-HANDLE_IOCTL(EXT2_IOC32_SETVERSION, do_ext2_ioctl)
-
-HANDLE_IOCTL(LOOP_SET_STATUS, loop_status)
-HANDLE_IOCTL(LOOP_GET_STATUS, loop_status)
-
-HANDLE_IOCTL(ICARSAMODEXPO, do_rsa_ioctl)
-HANDLE_IOCTL(ICARSACRT, do_rsa_crt_ioctl)
-HANDLE_IOCTL(ICARSAMODMULT, do_rsa_ioctl)
-
-COMPATIBLE_IOCTL(ICAZ90STATUS)
-COMPATIBLE_IOCTL(ICAZ90QUIESCE)
-COMPATIBLE_IOCTL(ICAZ90HARDRESET)
-COMPATIBLE_IOCTL(ICAZ90HARDERROR)
-
-HANDLE_IOCTL(BLKRAGET, w_long)
-HANDLE_IOCTL(BLKGETSIZE, w_long)
-HANDLE_IOCTL(BLKFRAGET, w_long)
-HANDLE_IOCTL(BLKSECTGET, w_long)
-HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans)
-
-IOCTL_TABLE_END
+};
 
 int ioctl_table_size = ARRAY_SIZE(ioctl_start);
diff -puN arch/s390/kernel/compat_linux.c~linus arch/s390/kernel/compat_linux.c
--- 25/arch/s390/kernel/compat_linux.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/kernel/compat_linux.c	2004-01-19 22:17:21.000000000 -0800
@@ -5,6 +5,7 @@
  *    Copyright (C) 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
  *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
  *               Gerhard Tonn (ton@de.ibm.com)   
+ *               Thomas Spatzier (tspat@de.ibm.com)
  *
  *  Conversion between 31bit and 64bit native syscalls.
  *
@@ -934,19 +935,32 @@ static long do_readv_writev32(int type, 
 	tot_len = 0;
 	i = count;
 	ivp = iov;
+	retval = -EINVAL;
 	while(i > 0) {
-		u32 len;
+		compat_ssize_t tmp = tot_len;
+		compat_ssize_t len;
 		u32 buf;
 
-		__get_user(len, &vector->iov_len);
-		__get_user(buf, &vector->iov_base);
+		if (__get_user(len, &vector->iov_len) ||
+		    __get_user(buf, &vector->iov_base)) {
+			retval = -EFAULT;
+			goto out;
+		}
+		if (len < 0)	/* size_t not fitting an ssize_t32 .. */
+			goto out;
 		tot_len += len;
+		if (tot_len < tmp) /* maths overflow on the compat_ssize_t */
+			goto out;
 		ivp->iov_base = (void *)A(buf);
 		ivp->iov_len = (__kernel_size_t) len;
 		vector++;
 		ivp++;
 		i--;
 	}
+	if (tot_len == 0) {
+		retval = 0;
+		goto out;
+	}
 
 	inode = file->f_dentry->d_inode;
 	/* VERIFY_WRITE actually means a read, as we write to user space */
@@ -1500,50 +1514,6 @@ out:
 	return err;
 }
 
-struct rusage32 {
-        struct compat_timeval ru_utime;
-        struct compat_timeval ru_stime;
-        s32    ru_maxrss;
-        s32    ru_ixrss;
-        s32    ru_idrss;
-        s32    ru_isrss;
-        s32    ru_minflt;
-        s32    ru_majflt;
-        s32    ru_nswap;
-        s32    ru_inblock;
-        s32    ru_oublock;
-        s32    ru_msgsnd; 
-        s32    ru_msgrcv; 
-        s32    ru_nsignals;
-        s32    ru_nvcsw;
-        s32    ru_nivcsw;
-};
-
-static int put_rusage (struct rusage32 *ru, struct rusage *r)
-{
-	int err;
-	
-	err = put_user (r->ru_utime.tv_sec, &ru->ru_utime.tv_sec);
-	err |= __put_user (r->ru_utime.tv_usec, &ru->ru_utime.tv_usec);
-	err |= __put_user (r->ru_stime.tv_sec, &ru->ru_stime.tv_sec);
-	err |= __put_user (r->ru_stime.tv_usec, &ru->ru_stime.tv_usec);
-	err |= __put_user (r->ru_maxrss, &ru->ru_maxrss);
-	err |= __put_user (r->ru_ixrss, &ru->ru_ixrss);
-	err |= __put_user (r->ru_idrss, &ru->ru_idrss);
-	err |= __put_user (r->ru_isrss, &ru->ru_isrss);
-	err |= __put_user (r->ru_minflt, &ru->ru_minflt);
-	err |= __put_user (r->ru_majflt, &ru->ru_majflt);
-	err |= __put_user (r->ru_nswap, &ru->ru_nswap);
-	err |= __put_user (r->ru_inblock, &ru->ru_inblock);
-	err |= __put_user (r->ru_oublock, &ru->ru_oublock);
-	err |= __put_user (r->ru_msgsnd, &ru->ru_msgsnd);
-	err |= __put_user (r->ru_msgrcv, &ru->ru_msgrcv);
-	err |= __put_user (r->ru_nsignals, &ru->ru_nsignals);
-	err |= __put_user (r->ru_nvcsw, &ru->ru_nvcsw);
-	err |= __put_user (r->ru_nivcsw, &ru->ru_nivcsw);
-	return err;
-}
-
 struct sysinfo32 {
         s32 uptime;
         u32 loads[3];
@@ -2706,56 +2676,6 @@ out:
 	return error;
 }
 
-extern asmlinkage int sys_sched_setaffinity(pid_t pid, unsigned int len,
-					    unsigned long *user_mask_ptr);
-
-asmlinkage int sys32_sched_setaffinity(compat_pid_t pid, unsigned int len,
-				       u32 *user_mask_ptr)
-{
-	unsigned long kernel_mask;
-	mm_segment_t old_fs;
-	int ret;
-
-	if (get_user(kernel_mask, user_mask_ptr))
-		return -EFAULT;
-
-	old_fs = get_fs();
-	set_fs(KERNEL_DS);
-	ret = sys_sched_setaffinity(pid,
-				    /* XXX Nice api... */
-				    sizeof(kernel_mask),
-				    &kernel_mask);
-	set_fs(old_fs);
-
-	return ret;
-}
-
-extern asmlinkage int sys_sched_getaffinity(pid_t pid, unsigned int len,
-					    unsigned long *user_mask_ptr);
-
-asmlinkage int sys32_sched_getaffinity(compat_pid_t pid, unsigned int len,
-				       u32 *user_mask_ptr)
-{
-	unsigned long kernel_mask;
-	mm_segment_t old_fs;
-	int ret;
-
-	old_fs = get_fs();
-	set_fs(KERNEL_DS);
-	ret = sys_sched_getaffinity(pid,
-				    /* XXX Nice api... */
-				    sizeof(kernel_mask),
-				    &kernel_mask);
-	set_fs(old_fs);
-
-	if (ret == 0) {
-		if (put_user(kernel_mask, user_mask_ptr))
-			ret = -EFAULT;
-	}
-
-	return ret;
-}
-
 asmlinkage ssize_t sys_read(unsigned int fd, char * buf, size_t count);
 
 asmlinkage compat_ssize_t sys32_read(unsigned int fd, char * buf, size_t count)
@@ -2792,4 +2712,43 @@ asmlinkage int sys32_clone(struct pt_reg
 		       parent_tidptr, child_tidptr);
 }
 
+/*
+ * Wrapper function for sys_timer_create.
+ */
+extern asmlinkage long
+sys_timer_create(clockid_t, struct sigevent *, timer_t *);
+
+asmlinkage long
+sys32_timer_create(clockid_t which_clock, struct sigevent32 *se32,
+		timer_t *timer_id)
+{
+	struct sigevent se;
+	timer_t ktimer_id;
+	mm_segment_t old_fs;
+	long ret;
+
+	if (se32 == NULL)
+		return sys_timer_create(which_clock, NULL, timer_id);
 
+	/* XXX: converting se32 to se is filthy because of the
+	 * two union members. For now it is ok, because the pointers
+	 * are not touched in kernel.
+	 */
+	memset(&se, 0, sizeof(se));
+	if (get_user(se.sigev_value.sival_int,  &se32->sigev_value.sival_int) ||
+	    get_user(se.sigev_signo, &se32->sigev_signo) ||
+	    get_user(se.sigev_notify, &se32->sigev_notify) ||
+	    copy_from_user(&se._sigev_un._pad, &se32->_sigev_un._pad,
+	    sizeof(se._sigev_un._pad)))
+		return -EFAULT;
+
+	old_fs = get_fs();
+	set_fs(KERNEL_DS);
+	ret = sys_timer_create(which_clock, &se, &ktimer_id);
+	set_fs(old_fs);
+
+	if (!ret)
+		ret = put_user (ktimer_id, timer_id);
+
+	return ret;
+}
diff -puN arch/s390/kernel/compat_linux.h~linus arch/s390/kernel/compat_linux.h
--- 25/arch/s390/kernel/compat_linux.h~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/kernel/compat_linux.h	2004-01-19 22:17:21.000000000 -0800
@@ -190,4 +190,22 @@ struct ucontext32 {
 	compat_sigset_t		uc_sigmask;	/* mask last for extensibility */
 };
 
+#define SIGEV_PAD_SIZE32 ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
+struct sigevent32 {
+	union {
+		int sival_int;
+		u32 sival_ptr;
+	} sigev_value;
+	int sigev_signo;
+	int sigev_notify;
+	union {
+		int _pad[SIGEV_PAD_SIZE32];
+		int _tid;
+		struct {
+			u32 *_function;
+			u32 *_attribute;
+		} _sigev_thread;
+	} _sigev_un;
+};
+
 #endif /* _ASM_S390X_S390_H */
diff -puN arch/s390/kernel/compat_signal.c~linus arch/s390/kernel/compat_signal.c
--- 25/arch/s390/kernel/compat_signal.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/kernel/compat_signal.c	2004-01-19 22:17:21.000000000 -0800
@@ -314,6 +314,9 @@ static int restore_sigregs32(struct pt_r
 	_s390_regs_common32 regs32;
 	int err, i;
 
+	/* Alwys make any pending restarted system call return -EINTR */
+	current_thread_info()->restart_block.fn = do_no_restart_syscall;
+
 	err = __copy_from_user(&regs32, &sregs->regs, sizeof(regs32));
 	if (err)
 		return err;
diff -puN arch/s390/kernel/compat_wrapper.S~linus arch/s390/kernel/compat_wrapper.S
--- 25/arch/s390/kernel/compat_wrapper.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/kernel/compat_wrapper.S	2004-01-19 22:17:21.000000000 -0800
@@ -135,7 +135,7 @@ sys32_alarm_wrapper:
 compat_sys_utime_wrapper:
 	llgtr	%r2,%r2			# char *
 	llgtr	%r3,%r3			# struct compat_utimbuf *
-	jg	compat_sys_utime		# branch to system call
+	jg	compat_sys_utime	# branch to system call
 
 	.globl  sys32_access_wrapper 
 sys32_access_wrapper:
@@ -1192,14 +1192,14 @@ sys32_sched_setaffinity_wrapper:
 	lgfr	%r2,%r2			# int
 	llgfr	%r3,%r3			# unsigned int
 	llgtr	%r4,%r4			# unsigned long *
-	jg	sys32_sched_setaffinity
+	jg	compat_sys_sched_setaffinity
 
 	.globl	sys32_sched_getaffinity_wrapper
 sys32_sched_getaffinity_wrapper:
 	lgfr	%r2,%r2			# int
 	llgfr	%r3,%r3			# unsigned int
 	llgtr	%r4,%r4			# unsigned long *
-	jg	sys32_sched_getaffinity
+	jg	compat_sys_sched_getaffinity
 
 	.globl  sys32_exit_group_wrapper
 sys32_exit_group_wrapper:
@@ -1232,6 +1232,77 @@ sys_epoll_wait_wrapper:
 	lgfr	%r5,%r5			# int
 	jg	sys_epoll_wait		# branch to system call
 
+	.globl	sys32_fadvise64_wrapper
+sys32_fadvise64_wrapper:
+	lgfr	%r2,%r2			# int
+	sllg	%r3,%r3,32		# get high word of 64bit loff_t
+	or	%r3,%r4			# get low word of 64bit loff_t
+	llgfr	%r4,%r5			# size_t (unsigned long)
+	lgfr	%r5,%r6			# int
+	jg	sys_fadvise64
+
+	.globl	sys32_fadvise64_64_wrapper
+sys32_fadvise64_64_wrapper:
+	llgtr	%r2,%r2			# struct fadvise64_64_args *
+	jg	s390_fadvise64_64
+
+	.globl	sys32_clock_settime_wrapper
+sys32_clock_settime_wrapper:
+	lgfr	%r2,%r2			# clockid_t (int)
+	llgtr	%r3,%r3			# struct compat_timespec *
+	jg	compat_clock_settime
+
+	.globl	sys32_clock_gettime_wrapper
+sys32_clock_gettime_wrapper:
+	lgfr	%r2,%r2			# clockid_t (int)
+	llgtr	%r3,%r3			# struct compat_timespec *
+	jg	compat_clock_gettime
+
+	.globl	sys32_clock_getres_wrapper
+sys32_clock_getres_wrapper:
+	lgfr	%r2,%r2			# clockid_t (int)
+	llgtr	%r3,%r3			# struct compat_timespec *
+	jg	compat_clock_getres
+
+	.globl	sys32_clock_nanosleep_wrapper
+sys32_clock_nanosleep_wrapper:
+	lgfr	%r2,%r2			# clockid_t (int)
+	lgfr	%r3,%r3			# int
+	llgtr	%r4,%r4			# struct compat_timespec *
+	llgtr	%r5,%r5			# struct compat_timespec *
+	jg	compat_clock_nanosleep
+
+	.globl	sys32_timer_create_wrapper
+sys32_timer_create_wrapper:
+	lgfr	%r2,%r2			# timer_t (int)
+	llgtr	%r3,%r3			# struct compat_sigevent *
+	llgtr	%r4,%r4			# timer_t *
+	jg	sys32_timer_create
+
+	.globl	sys32_timer_settime_wrapper
+sys32_timer_settime_wrapper:
+	lgfr	%r2,%r2			# timer_t (int)
+	lgfr	%r3,%r3			# int
+	llgtr	%r4,%r4			# struct compat_itimerspec *
+	llgtr	%r5,%r5			# struct compat_itimerspec *
+	jg	compat_timer_settime
+
+	.globl	sys32_timer_gettime_wrapper
+sys32_timer_gettime_wrapper:
+	lgfr	%r2,%r2			# timer_t (int)
+	llgtr	%r3,%r3			# struct compat_itimerspec *
+	jg	compat_timer_gettime
+
+	.globl	sys32_timer_getoverrun_wrapper
+sys32_timer_getoverrun_wrapper:
+	lgfr	%r2,%r2			# timer_t (int)
+	jg	sys_timer_getoverrun
+
+	.globl	sys32_timer_delete_wrapper
+sys32_timer_delete_wrapper:
+	lgfr	%r2,%r2			# timer_t (int)
+	jg	sys_timer_delete
+
 	.globl	sys32_io_setup_wrapper
 sys32_io_setup_wrapper:
 	llgfr	%r2,%r2			# unsigned int
diff -puN arch/s390/kernel/entry64.S~linus arch/s390/kernel/entry64.S
--- 25/arch/s390/kernel/entry64.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/kernel/entry64.S	2004-01-19 22:17:21.000000000 -0800
@@ -169,9 +169,10 @@ system_call:
         slag    %r7,%r7,2         # *4 and test for svc 0
 	jnz	sysc_do_restart
 	# svc 0: system call number in %r1
-	clg	%r1,.Lnr_syscalls-.Lconst(%r14)
+	cl	%r1,.Lnr_syscalls-.Lconst(%r14)
 	jnl	sysc_do_restart
-	slag    %r7,%r1,2         # svc 0: system call number in %r1
+	lgfr	%r7,%r1           # clear high word in r1
+	slag    %r7,%r7,2         # svc 0: system call number in %r1
 sysc_do_restart:
 	larl    %r10,sys_call_table
 #ifdef CONFIG_S390_SUPPORT
@@ -235,16 +236,18 @@ sysc_sigpending:     
         sgr     %r3,%r3           # clear *oldset
 	brasl	%r14,do_signal    # call do_signal
 	stnsm   48(%r15),0xfc     # disable I/O and ext. interrupts
+	tm	__TI_flags+7(%r9),_TIF_RESTART_SVC
+	jo	sysc_restart
 	j	sysc_leave        # out of here, do NOT recheck
 
 #
 # _TIF_RESTART_SVC is set, set up registers and restart svc
 #
 sysc_restart:
-	ni	__TI_flags+3(%r9),255-_TIF_RESTART_SVC # clear TIF_RESTART_SVC
+	ni	__TI_flags+7(%r9),255-_TIF_RESTART_SVC # clear TIF_RESTART_SVC
 	stosm	48(%r15),0x03          # reenable interrupts
 	lg	%r7,SP_R2(%r15)        # load new svc number
-        slag    %r7,%r7,3              # *8
+        slag    %r7,%r7,2              # *4
 	mvc	SP_R2(8,%r15),SP_ORIG_R2(%r15) # restore first argument
 	lmg	%r2,%r6,SP_R2(%r15)    # load svc arguments
 	j	sysc_do_restart        # restart svc
@@ -503,7 +506,7 @@ pgm_svcstd:
 	larl    %r10,sys_call_table_emu # use 31 bit emulation system calls
 pgm_svcper_noemu:
 #endif
-	tm	__TI_flags+3(%r9),_TIF_SYSCALL_TRACE
+	tm	__TI_flags+7(%r9),_TIF_SYSCALL_TRACE
         lgf     %r8,0(%r7,%r10)   # load address of system call routine
         jo      pgm_tracesys
         basr    %r14,%r8          # call sys_xxxx
@@ -512,7 +515,7 @@ pgm_svcper_noemu:
                                   # changing anything here !!
 
 pgm_svcret:
-	tm	__TI_flags+3(%r9),_TIF_SIGPENDING
+	tm	__TI_flags+7(%r9),_TIF_SIGPENDING
 	jo	pgm_svcper_nosig
         la      %r2,SP_PTREGS(%r15) # load pt_regs
         sgr     %r3,%r3             # clear *oldset
diff -puN arch/s390/kernel/entry.S~linus arch/s390/kernel/entry.S
--- 25/arch/s390/kernel/entry.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/kernel/entry.S	2004-01-19 22:17:21.000000000 -0800
@@ -249,6 +249,8 @@ sysc_sigpending:     
         l       %r1,BASED(.Ldo_signal)
 	basr	%r14,%r1               # call do_signal
         stnsm   24(%r15),0xfc          # disable I/O and ext. interrupts
+	tm	__TI_flags+3(%r9),_TIF_RESTART_SVC
+	bo	BASED(sysc_restart)
 	b	BASED(sysc_leave)      # out of here, do NOT recheck
 
 #
@@ -258,7 +260,7 @@ sysc_restart:
 	ni	__TI_flags+3(%r9),255-_TIF_RESTART_SVC # clear TIF_RESTART_SVC
 	stosm	24(%r15),0x03          # reenable interrupts
 	l	%r7,SP_R2(%r15)        # load new svc number
-	sla	%r2,2
+	sla	%r7,2
 	mvc	SP_R2(4,%r15),SP_ORIG_R2(%r15) # restore first argument
 	lm	%r2,%r6,SP_R2(%r15)    # load svc arguments
 	b	BASED(sysc_do_restart) # restart svc
@@ -541,7 +543,7 @@ io_preempt:
 io_resume_loop:
 	tm	__TI_flags+3(%r9),_TIF_NEED_RESCHED
 	bno	BASED(io_leave)
-	mvc     __TI_precount(4,%r9),.Lc_pactive
+	mvc     __TI_precount(4,%r9),BASED(.Lc_pactive)
 	# hmpf, we are on the async. stack but to call schedule
 	# we have to move the interrupt frame to the process stack
 	l	%r1,SP_R15(%r15)
diff -puN arch/s390/kernel/head64.S~linus arch/s390/kernel/head64.S
--- 25/arch/s390/kernel/head64.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/kernel/head64.S	2004-01-19 22:17:21.000000000 -0800
@@ -582,6 +582,20 @@ startup:basr  %r13,0                    
 	mvc    __LC_DIAG44_OPCODE(8),.Ldiag44-.LPG1(%r13)
 0:	
 
+#
+# find out if we have the IDTE instruction
+#
+	la     %r1,0f-.LPG1(%r13)	# set program check address
+	stg    %r1,__LC_PGM_NEW_PSW+8
+	.long	0xb2b10000		# store facility list
+	tm	0xc8,0x08		# check bit for clearing-by-ASCE
+	bno	0f-.LPG1(%r13)
+	lhi	%r1,2094
+	lhi	%r2,0
+	.long	0xb98e2001
+	oi	7(%r12),0x80		# set IDTE flag
+0:
+
         lpswe .Lentry-.LPG1(13)         # jump to _stext in primary-space,
                                         # virtual and never return ...
         .align 16
diff -puN arch/s390/kernel/head.S~linus arch/s390/kernel/head.S
--- 25/arch/s390/kernel/head.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/kernel/head.S	2004-01-19 22:17:21.000000000 -0800
@@ -569,6 +569,19 @@ startup:basr  %r13,0                    
        oi     3(%r12),16                # set MVPG flag
 .Lchkmvpg:
 
+#
+# find out if we have the IDTE instruction
+#
+	mvc	__LC_PGM_NEW_PSW(8),.Lpcidte-.LPG1(%r13)
+	.long	0xb2b10000		# store facility list
+	tm	0xc8,0x08		# check bit for clearing-by-ASCE
+	bno	.Lchkidte-.LPG1(%r13)
+	lhi	%r1,2094
+	lhi	%r2,0
+	.long	0xb98e2001
+	oi	3(%r12),0x80		# set IDTE flag
+.Lchkidte:
+
         lpsw  .Lentry-.LPG1(13)         # jump to _stext in primary-space,
                                         # virtual and never return ...
         .align 8
@@ -593,6 +606,7 @@ startup:basr  %r13,0                    
 .Lpcfpu:.long  0x00080000,0x80000000 + .Lchkfpu
 .Lpccsp:.long  0x00080000,0x80000000 + .Lchkcsp
 .Lpcmvpg:.long 0x00080000,0x80000000 + .Lchkmvpg
+.Lpcidte:.long 0x00080000,0x80000000 + .Lchkidte
 .Lmemsize:.long memory_size
 .Lmchunk:.long memory_chunk
 .Lmflags:.long machine_flags
diff -puN arch/s390/kernel/ptrace.c~linus arch/s390/kernel/ptrace.c
--- 25/arch/s390/kernel/ptrace.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/kernel/ptrace.c	2004-01-19 22:17:21.000000000 -0800
@@ -130,7 +130,11 @@ peek_user(struct task_struct *child, add
 	struct user *dummy = NULL;
 	addr_t offset, tmp;
 
-	if ((addr & __ADDR_MASK) || addr > sizeof(struct user) - __ADDR_MASK)
+	/*
+	 * Stupid gdb peeks/pokes the access registers in 64 bit with
+	 * an alignment of 4. Programmers from hell...
+	 */
+	if ((addr & 3) || addr > sizeof(struct user) - __ADDR_MASK)
 		return -EIO;
 
 	if (addr <= (addr_t) &dummy->regs.orig_gpr2) {
@@ -138,6 +142,9 @@ peek_user(struct task_struct *child, add
 		 * psw, gprs, acrs and orig_gpr2 are stored on the stack
 		 */
 		tmp = *(addr_t *)((addr_t) __KSTK_PTREGS(child) + addr);
+		if (addr == (addr_t) &dummy->regs.psw.mask)
+			/* Remove per bit from user psw. */
+			tmp &= ~PSW_MASK_PER;
 
 	} else if (addr >= (addr_t) &dummy->regs.fp_regs &&
 		   addr < (addr_t) (&dummy->regs.fp_regs + 1)) {
@@ -173,7 +180,11 @@ poke_user(struct task_struct *child, add
 	struct user *dummy = NULL;
 	addr_t offset;
 
-	if ((addr & __ADDR_MASK) || addr > sizeof(struct user) - __ADDR_MASK)
+	/*
+	 * Stupid gdb peeks/pokes the access registers in 64 bit with
+	 * an alignment of 4. Programmers from hell indeed...
+	 */
+	if ((addr & 3) || addr > sizeof(struct user) - __ADDR_MASK)
 		return -EIO;
 
 	if (addr <= (addr_t) &dummy->regs.orig_gpr2) {
@@ -258,7 +269,7 @@ do_ptrace_normal(struct task_struct *chi
 
 	case PTRACE_PEEKUSR_AREA:
 	case PTRACE_POKEUSR_AREA:
-		if (!copy_from_user(&parea, (void *) addr, sizeof(parea)))
+		if (copy_from_user(&parea, (void *) addr, sizeof(parea)))
 			return -EFAULT;
 		addr = parea.kernel_addr;
 		data = parea.process_addr;
@@ -266,8 +277,12 @@ do_ptrace_normal(struct task_struct *chi
 		while (copied < parea.len) {
 			if (request == PTRACE_PEEKUSR_AREA)
 				ret = peek_user(child, addr, data);
-			else
-				ret = poke_user(child, addr, data);
+			else {
+				addr_t tmp;
+				if (get_user (tmp, (addr_t *) data))
+					return -EFAULT;
+				ret = poke_user(child, addr, tmp);
+			}
 			if (ret)
 				return ret;
 			addr += sizeof(unsigned long);
@@ -390,7 +405,7 @@ poke_user_emu31(struct task_struct *chil
 			if ((tmp & ~PSW32_MASK_CC) != PSW32_USER_BITS)
 				/* Invalid psw mask. */
 				return -EINVAL;
-			__KSTK_PTREGS(child)->psw.mask = PSW_USER_BITS |
+			__KSTK_PTREGS(child)->psw.mask = PSW_USER32_BITS |
 				((tmp & PSW32_MASK_CC) << 32);
 		} else if (addr == (addr_t) &dummy32->regs.psw.addr) {
 			/* Build a 64 bit psw address from 31 bit address. */
@@ -484,7 +499,7 @@ do_ptrace_emu31(struct task_struct *chil
 
 	case PTRACE_PEEKUSR_AREA:
 	case PTRACE_POKEUSR_AREA:
-		if (!copy_from_user(&parea, (void *) addr, sizeof(parea)))
+		if (copy_from_user(&parea, (void *) addr, sizeof(parea)))
 			return -EFAULT;
 		addr = parea.kernel_addr;
 		data = parea.process_addr;
@@ -492,8 +507,12 @@ do_ptrace_emu31(struct task_struct *chil
 		while (copied < parea.len) {
 			if (request == PTRACE_PEEKUSR_AREA)
 				ret = peek_user_emu31(child, addr, data);
-			else
-				ret = poke_user_emu31(child, addr, data);
+			else {
+				__u32 tmp;
+				if (get_user (tmp, (__u32 *) data))
+					return -EFAULT;
+				ret = poke_user_emu31(child, addr, tmp);
+			}
 			if (ret)
 				return ret;
 			addr += sizeof(unsigned int);
diff -puN arch/s390/kernel/semaphore.c~linus arch/s390/kernel/semaphore.c
--- 25/arch/s390/kernel/semaphore.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/kernel/semaphore.c	2004-01-19 22:17:21.000000000 -0800
@@ -64,14 +64,14 @@ void __down(struct semaphore * sem)
 	struct task_struct *tsk = current;
 	DECLARE_WAITQUEUE(wait, tsk);
 
-	tsk->state = TASK_UNINTERRUPTIBLE;
+	__set_task_state(tsk, TASK_UNINTERRUPTIBLE);
 	add_wait_queue_exclusive(&sem->wait, &wait);
 	while (__sem_update_count(sem, -1) <= 0) {
 		schedule();
-		tsk->state = TASK_UNINTERRUPTIBLE;
+		set_task_state(tsk, TASK_UNINTERRUPTIBLE);
 	}
 	remove_wait_queue(&sem->wait, &wait);
-	tsk->state = TASK_RUNNING;
+	__set_task_state(tsk, TASK_RUNNING);
 	wake_up(&sem->wait);
 }
 
@@ -87,7 +87,7 @@ int __down_interruptible(struct semaphor
 	struct task_struct *tsk = current;
 	DECLARE_WAITQUEUE(wait, tsk);
 
-	tsk->state = TASK_INTERRUPTIBLE;
+	__set_task_state(tsk, TASK_INTERRUPTIBLE);
 	add_wait_queue_exclusive(&sem->wait, &wait);
 	while (__sem_update_count(sem, -1) <= 0) {
 		if (signal_pending(current)) {
@@ -96,10 +96,10 @@ int __down_interruptible(struct semaphor
 			break;
 		}
 		schedule();
-		tsk->state = TASK_INTERRUPTIBLE;
+		set_task_state(tsk, TASK_INTERRUPTIBLE);
 	}
 	remove_wait_queue(&sem->wait, &wait);
-	tsk->state = TASK_RUNNING;
+	__set_task_state(tsk, TASK_RUNNING);
 	wake_up(&sem->wait);
 	return retval;
 }
diff -puN arch/s390/kernel/setup.c~linus arch/s390/kernel/setup.c
--- 25/arch/s390/kernel/setup.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/kernel/setup.c	2004-01-19 22:17:21.000000000 -0800
@@ -158,8 +158,10 @@ static int __init condev_setup(char *str
 	int vdev;
 
 	vdev = simple_strtoul(str, &str, 0);
-	if (vdev >= 0 && vdev < 65536)
+	if (vdev >= 0 && vdev < 65536) {
 		console_device = vdev;
+		console_irq = -1;
+	}
 	return 1;
 }
 
@@ -287,6 +289,7 @@ void (*_machine_power_off)(void) = do_ma
 
 void machine_restart(char *command)
 {
+	console_unblank();
 	_machine_restart(command);
 }
 
@@ -294,6 +297,7 @@ EXPORT_SYMBOL(machine_restart);
 
 void machine_halt(void)
 {
+	console_unblank();
 	_machine_halt();
 }
 
@@ -301,6 +305,7 @@ EXPORT_SYMBOL(machine_halt);
 
 void machine_power_off(void)
 {
+	console_unblank();
 	_machine_power_off();
 }
 
diff -puN arch/s390/kernel/signal.c~linus arch/s390/kernel/signal.c
--- 25/arch/s390/kernel/signal.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/kernel/signal.c	2004-01-19 22:17:21.000000000 -0800
@@ -167,6 +167,9 @@ static int restore_sigregs(struct pt_reg
 {
 	int err;
 
+	/* Alwys make any pending restarted system call return -EINTR */
+	current_thread_info()->restart_block.fn = do_no_restart_syscall;
+
 	err = __copy_from_user(regs, &sregs->regs, sizeof(_s390_regs_common));
 	regs->psw.mask = PSW_USER_BITS | (regs->psw.mask & PSW_MASK_CC);
 	regs->psw.addr |= PSW_ADDR_AMODE;
diff -puN arch/s390/kernel/syscalls.S~linus arch/s390/kernel/syscalls.S
--- 25/arch/s390/kernel/syscalls.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/kernel/syscalls.S	2004-01-19 22:17:21.000000000 -0800
@@ -15,7 +15,7 @@ SYSCALL(sys_read,sys_read,sys32_read_wra
 SYSCALL(sys_write,sys_write,sys32_write_wrapper)
 SYSCALL(sys_open,sys_open,sys32_open_wrapper)			/* 5 */
 SYSCALL(sys_close,sys_close,sys32_close_wrapper)
-SYSCALL(sys_restart_syscall,sys_restart_syscall,sys_ni_syscall)
+SYSCALL(sys_restart_syscall,sys_restart_syscall,sys_restart_syscall)
 SYSCALL(sys_creat,sys_creat,sys32_creat_wrapper)
 SYSCALL(sys_link,sys_link,sys32_link_wrapper)
 SYSCALL(sys_unlink,sys_unlink,sys32_unlink_wrapper)		/* 10 */
@@ -261,14 +261,15 @@ SYSCALL(sys_epoll_create,sys_epoll_creat
 SYSCALL(sys_epoll_ctl,sys_epoll_ctl,sys_epoll_ctl_wrapper)	/* 250 */
 SYSCALL(sys_epoll_wait,sys_epoll_wait,sys_epoll_wait_wrapper)
 SYSCALL(sys_set_tid_address,sys_set_tid_address,sys32_set_tid_address_wrapper)
-SYSCALL(sys_fadvise64,sys_fadvise64,sys_ni_syscall)
-SYSCALL(sys_timer_create,sys_timer_create,sys_ni_syscall)
-SYSCALL(sys_timer_settime,sys_timer_settime,sys_ni_syscall)	/* 255 */
-SYSCALL(sys_timer_gettime,sys_timer_gettime,sys_ni_syscall)
-SYSCALL(sys_timer_getoverrun,sys_timer_getoverrun,sys_ni_syscall)
-SYSCALL(sys_timer_delete,sys_timer_delete,sys_ni_syscall)
-SYSCALL(sys_clock_settime,sys_clock_settime,sys_ni_syscall)
-SYSCALL(sys_clock_gettime,sys_clock_gettime,sys_ni_syscall)	/* 260 */
-SYSCALL(sys_clock_getres,sys_clock_getres,sys_ni_syscall)
-SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys_ni_syscall)
+SYSCALL(s390_fadvise64,sys_fadvise64_64,sys32_fadvise64_wrapper)
+SYSCALL(sys_timer_create,sys_timer_create,sys32_timer_create_wrapper)
+SYSCALL(sys_timer_settime,sys_timer_settime,sys32_timer_settime_wrapper)	/* 255 */
+SYSCALL(sys_timer_gettime,sys_timer_gettime,sys32_timer_gettime_wrapper)
+SYSCALL(sys_timer_getoverrun,sys_timer_getoverrun,sys32_timer_getoverrun_wrapper)
+SYSCALL(sys_timer_delete,sys_timer_delete,sys32_timer_delete_wrapper)
+SYSCALL(sys_clock_settime,sys_clock_settime,sys32_clock_settime_wrapper)
+SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper)	/* 260 */
+SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
+SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
 NI_SYSCALL							/* reserved for vserver */
+SYSCALL(s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
diff -puN arch/s390/kernel/sys_s390.c~linus arch/s390/kernel/sys_s390.c
--- 25/arch/s390/kernel/sys_s390.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/kernel/sys_s390.c	2004-01-19 22:17:21.000000000 -0800
@@ -325,3 +325,39 @@ asmlinkage int s390x_personality(unsigne
 	return ret;
 }
 #endif /* CONFIG_ARCH_S390X */
+
+/*
+ * Wrapper function for sys_fadvise64/fadvise64_64
+ */
+#ifndef CONFIG_ARCH_S390X
+
+extern asmlinkage long sys_fadvise64(int, loff_t, size_t, int);
+
+asmlinkage long
+s390_fadvise64(int fd, u32 offset_high, u32 offset_low, size_t len, int advice)
+{
+	return sys_fadvise64(fd, (u64) offset_high << 32 | offset_low,
+			len, advice);
+}
+
+#endif
+
+extern asmlinkage long sys_fadvise64_64(int, loff_t, loff_t, int);
+
+struct fadvise64_64_args {
+	int fd;
+	long long offset;
+	long long len;
+	int advice;
+};
+
+asmlinkage long
+s390_fadvise64_64(struct fadvise64_64_args *args)
+{
+	struct fadvise64_64_args a;
+
+	if ( copy_from_user(&a, args, sizeof(a)) )
+		return -EFAULT;
+	return sys_fadvise64_64(a.fd, a.offset, a.len, a.advice);
+}
+
diff -puN arch/s390/kernel/traps.c~linus arch/s390/kernel/traps.c
--- 25/arch/s390/kernel/traps.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/kernel/traps.c	2004-01-19 22:17:21.000000000 -0800
@@ -25,6 +25,7 @@
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
 #include <linux/init.h>
+#include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/kallsyms.h>
@@ -156,9 +157,10 @@ void show_registers(struct pt_regs *regs
 	int i;
 
 	mode = (regs->psw.mask & PSW_MASK_PSTATE) ? "User" : "Krnl";
-	printk("%s PSW : %p %p\n",
+	printk("%s PSW : %p %p",
 	       mode, (void *) regs->psw.mask,
 	       (void *) regs->psw.addr);
+	print_symbol(" (%s)\n", regs->psw.addr & PSW_ADDR_INSN);
 	printk("%s GPRS: " FOURLONG, mode,
 	       regs->gprs[0], regs->gprs[1], regs->gprs[2], regs->gprs[3]);
 	printk("           " FOURLONG,
@@ -250,6 +252,10 @@ void die(const char * str, struct pt_reg
         show_regs(regs);
 	bust_spinlocks(0);
         spin_unlock_irq(&die_lock);
+	if (in_interrupt())
+		panic("Fatal exception in interrupt");
+	if (panic_on_oops)
+		panic("Fatal exception: panic_on_oops");
         do_exit(SIGSEGV);
 }
 
diff -puN arch/s390/kernel/vmlinux.lds.S~linus arch/s390/kernel/vmlinux.lds.S
--- 25/arch/s390/kernel/vmlinux.lds.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/kernel/vmlinux.lds.S	2004-01-19 22:17:21.000000000 -0800
@@ -117,10 +117,7 @@ SECTIONS
 
   /* Sections to be discarded */
   /DISCARD/ : {
-	*(.exit.text)
-	*(.exit.data)
 	*(.exitcall.exit)
-	*(.eh_frame)
 	}
 
   /* Stabs debugging sections.  */
diff -puN arch/s390/lib/uaccess64.S~linus arch/s390/lib/uaccess64.S
--- 25/arch/s390/lib/uaccess64.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/lib/uaccess64.S	2004-01-19 22:17:21.000000000 -0800
@@ -73,6 +73,41 @@ __copy_to_user_asm:
 
         .align 4
         .text
+        .globl __copy_in_user_asm
+__copy_in_user_asm:
+	stmg	%r6,%r15,48(%r15)
+	lgr	%r5,%r3
+	lgr	%r7,%r5
+	lgr	%r6,%r2
+	cpya	6,4          # ar6 = ar4
+	sacf	512
+0:	mvcle	%r4,%r6,0
+	jo	0b
+1:	sacf	0
+	lgr	%r2,%r7
+	lmg	%r6,%r15,48(%r15)
+	br	%r14
+2:	lghi	%r1,-4096
+	lgr	%r5,%r4
+	slgr	%r5,%r1      # %r5 = %r4 + 4096
+	ngr	%r5,%r1      # %r5 = (%r4 + 4096) & -4096
+	slgr	%r5,%r4      # %r5 = #bytes to next user page boundary
+	clgr	%r7,%r5      # copy crosses next page boundary ?
+	jnh	1b           # no, the current page fauled
+	# The page after the current user page might have faulted.
+	# We cant't find out which page because the program check handler
+	# might have callled schedule, destroying all lowcore information.
+	# We retry with the shortened length.
+3:	mvcle	%r4,%r6,0
+	jo	3b
+	j	1b
+        .section __ex_table,"a"
+	.quad	0b,2b
+	.quad	3b,1b
+        .previous
+
+        .align 4
+        .text
         .globl __clear_user_asm
 __clear_user_asm:
 	lgr	%r4,%r2
diff -puN arch/s390/lib/uaccess.S~linus arch/s390/lib/uaccess.S
--- 25/arch/s390/lib/uaccess.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/lib/uaccess.S	2004-01-19 22:17:21.000000000 -0800
@@ -73,6 +73,41 @@ __copy_to_user_asm:
 
         .align 4
         .text
+        .globl __copy_in_user_asm
+__copy_in_user_asm:
+	stm	%r6,%r15,24(%r15)
+	lr	%r5,%r3
+	lr	%r7,%r3
+	lr	%r6,%r2
+	cpya	6,4          # ar6 = ar4
+	sacf	512
+0:	mvcle	%r4,%r6,0
+	jo	0b
+1:	sacf	0
+	lr	%r2,%r7
+	lm	%r6,%r15,24(%r15)
+	br	%r14
+2:	lhi	%r1,-4096
+	lr	%r5,%r4
+	slr	%r5,%r1      # %r5 = %r4 + 4096
+	nr	%r5,%r1      # %r5 = (%r4 + 4096) & -4096
+	slr	%r5,%r4      # %r5 = #bytes to next user page boundary
+	clr	%r7,%r5      # copy crosses next page boundary ?
+	jnh	1b           # no, the current page fauled
+	# The page after the current user page might have faulted.
+	# We cant't find out which page because the program check handler
+	# might have callled schedule, destroying all lowcore information.
+	# We retry with the shortened length.
+3:	mvcle	%r4,%r6,0
+	jo	3b
+	j	1b
+        .section __ex_table,"a"
+	.long	0b,2b
+	.long	3b,1b
+        .previous
+
+        .align 4
+        .text
         .globl __clear_user_asm
 __clear_user_asm:
 	lr	%r4,%r2
diff -puN -L arch/s390/mm/extable.c arch/s390/mm/extable.c~linus /dev/null
--- 25/arch/s390/mm/extable.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,34 +0,0 @@
-/*
- *  arch/s390/mm/extable.c
- *
- *  S390 version
- *
- *  identical to arch/i386/mm/extable.c
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/spinlock.h>
-#include <asm/uaccess.h>
-
-/* Simple binary search */
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
-	       const struct exception_table_entry *last,
-	       unsigned long value)
-{
-	while (first <= last) {
-		const struct exception_table_entry *mid;
-		long diff;
-
-		mid = (last - first) / 2 + first;
-		diff = mid->insn - value;
-		if (diff == 0)
-			return mid;
-		else if (diff < 0)
-			first = mid+1;
-		else
-			last = mid-1;
-	}
-	return NULL;
-}
diff -puN arch/s390/mm/fault.c~linus arch/s390/mm/fault.c
--- 25/arch/s390/mm/fault.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/mm/fault.c	2004-01-19 22:17:21.000000000 -0800
@@ -538,8 +538,6 @@ asmlinkage void
 pfault_interrupt(struct pt_regs *regs, __u16 error_code)
 {
 	struct task_struct *tsk;
-	wait_queue_head_t queue;
-	wait_queue_head_t *qp;
 	__u16 subcode;
 
 	/*
@@ -553,46 +551,34 @@ pfault_interrupt(struct pt_regs *regs, _
 		return;
 
 	/*
-	 * Get the token (= address of kernel stack of affected task).
+	 * Get the token (= address of the task structure of the affected task).
 	 */
 	tsk = *(struct task_struct **) __LC_PFAULT_INTPARM;
 
-	/*
-	 * We got all needed information from the lowcore and can
-	 * now safely switch on interrupts.
-	 */
-	if (regs->psw.mask & PSW_MASK_PSTATE)
-		local_irq_enable();
-
 	if (subcode & 0x0080) {
 		/* signal bit is set -> a page has been swapped in by VM */
-		qp = (wait_queue_head_t *)
-			xchg(&tsk->thread.pfault_wait, -1);
-		if (qp != NULL) {
+		if (xchg(&tsk->thread.pfault_wait, -1) != 0) {
 			/* Initial interrupt was faster than the completion
 			 * interrupt. pfault_wait is valid. Set pfault_wait
 			 * back to zero and wake up the process. This can
 			 * safely be done because the task is still sleeping
 			 * and can't procude new pfaults. */
-			tsk->thread.pfault_wait = 0ULL;
-			wake_up(qp);
+			tsk->thread.pfault_wait = 0;
+			wake_up_process(tsk);
 		}
 	} else {
 		/* signal bit not set -> a real page is missing. */
-                init_waitqueue_head (&queue);
-		qp = (wait_queue_head_t *)
-			xchg(&tsk->thread.pfault_wait, (addr_t) &queue);
-		if (qp != NULL) {
+		set_task_state(tsk, TASK_UNINTERRUPTIBLE);
+		if (xchg(&tsk->thread.pfault_wait, 1) != 0) {
 			/* Completion interrupt was faster than the initial
 			 * interrupt (swapped in a -1 for pfault_wait). Set
 			 * pfault_wait back to zero and exit. This can be
 			 * done safely because tsk is running in kernel 
 			 * mode and can't produce new pfaults. */
-			tsk->thread.pfault_wait = 0ULL;
-		}
-
-                /* go to sleep */
-                wait_event(queue, tsk->thread.pfault_wait == 0ULL);
+			tsk->thread.pfault_wait = 0;
+			set_task_state(tsk, TASK_RUNNING);
+		} else
+			set_tsk_need_resched(tsk);
 	}
 }
 #endif
diff -puN arch/s390/mm/Makefile~linus arch/s390/mm/Makefile
--- 25/arch/s390/mm/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/s390/mm/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -2,4 +2,4 @@
 # Makefile for the linux s390-specific parts of the memory manager.
 #
 
-obj-y	 := init.o fault.o ioremap.o extable.o
+obj-y	 := init.o fault.o ioremap.o
diff -puN -L arch/sh/boards/adx/io.c arch/sh/boards/adx/io.c~linus /dev/null
--- 25/arch/sh/boards/adx/io.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,195 +0,0 @@
-/* 
- * linux/arch/sh/kernel/io_adx.c
- *
- * Copyright (C) 2001 A&D Co., Ltd.
- *
- * I/O routine and setup routines for A&D ADX Board
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- */
-
-#include <asm/io.h>
-#include <asm/machvec.h>
-#include <linux/module.h>
-
-#define PORT2ADDR(x) (adx_isa_port2addr(x))
-
-static inline void delay(void)
-{
-	ctrl_inw(0xa0000000);
-}
-
-unsigned char adx_inb(unsigned long port)
-{
-	return *(volatile unsigned char*)PORT2ADDR(port);
-}
-
-unsigned short adx_inw(unsigned long port)
-{
-	return *(volatile unsigned short*)PORT2ADDR(port);
-}
-
-unsigned int adx_inl(unsigned long port)
-{
-	return *(volatile unsigned long*)PORT2ADDR(port);
-}
-
-unsigned char adx_inb_p(unsigned long port)
-{
-	unsigned long v = *(volatile unsigned char*)PORT2ADDR(port);
-
-	delay();
-	return v;
-}
-
-unsigned short adx_inw_p(unsigned long port)
-{
-	unsigned long v = *(volatile unsigned short*)PORT2ADDR(port);
-
-	delay();
-	return v;
-}
-
-unsigned int adx_inl_p(unsigned long port)
-{
-	unsigned long v = *(volatile unsigned long*)PORT2ADDR(port);
-
-	delay();
-	return v;
-}
-
-void adx_insb(unsigned long port, void *buffer, unsigned long count)
-{
-	unsigned char *buf = buffer;
-	while(count--) *buf++ = inb(port);
-}
-
-void adx_insw(unsigned long port, void *buffer, unsigned long count)
-{
-	unsigned short *buf = buffer;
-	while(count--) *buf++ = inw(port);
-}
-
-void adx_insl(unsigned long port, void *buffer, unsigned long count)
-{
-	unsigned long *buf = buffer;
-	while(count--) *buf++ = inl(port);
-}
-
-void adx_outb(unsigned char b, unsigned long port)
-{
-	*(volatile unsigned char*)PORT2ADDR(port) = b;
-}
-
-void adx_outw(unsigned short b, unsigned long port)
-{
-	*(volatile unsigned short*)PORT2ADDR(port) = b;
-}
-
-void adx_outl(unsigned int b, unsigned long port)
-{
-	*(volatile unsigned long*)PORT2ADDR(port) = b;
-}
-
-void adx_outb_p(unsigned char b, unsigned long port)
-{
-	*(volatile unsigned char*)PORT2ADDR(port) = b;
-	delay();
-}
-
-void adx_outw_p(unsigned short b, unsigned long port)
-{
-	*(volatile unsigned short*)PORT2ADDR(port) = b;
-	delay();
-}
-
-void adx_outl_p(unsigned int b, unsigned long port)
-{
-	*(volatile unsigned long*)PORT2ADDR(port) = b;
-	delay();
-}
-
-void adx_outsb(unsigned long port, const void *buffer, unsigned long count)
-{
-	const unsigned char *buf = buffer;
-	while(count--) outb(*buf++, port);
-}
-
-void adx_outsw(unsigned long port, const void *buffer, unsigned long count)
-{
-	const unsigned short *buf = buffer;
-	while(count--) outw(*buf++, port);
-}
-
-void adx_outsl(unsigned long port, const void *buffer, unsigned long count)
-{
-	const unsigned long *buf = buffer;
-	while(count--) outl(*buf++, port);
-}
-
-unsigned char adx_readb(unsigned long addr)
-{
-	return *(volatile unsigned char*)addr;
-}
-
-unsigned short adx_readw(unsigned long addr)
-{
-	return *(volatile unsigned short*)addr;
-}
-
-unsigned int adx_readl(unsigned long addr)
-{
-	return *(volatile unsigned long*)addr;
-}
-
-void adx_writeb(unsigned char b, unsigned long addr)
-{
-	*(volatile unsigned char*)addr = b;
-}
-
-void adx_writew(unsigned short b, unsigned long addr)
-{
-	*(volatile unsigned short*)addr = b;
-}
-
-void adx_writel(unsigned int b, unsigned long addr)
-{
-	*(volatile unsigned long*)addr = b;
-}
-
-void *adx_ioremap(unsigned long offset, unsigned long size)
-{
-	return (void *)P2SEGADDR(offset);
-}
-
-EXPORT_SYMBOL (adx_ioremap);
-
-void adx_iounmap(void *addr)
-{
-}
-
-EXPORT_SYMBOL(adx_iounmap);
-
-#ifdef CONFIG_IDE
-#include <linux/vmalloc.h>
-extern void *cf_io_base;
-
-unsigned long adx_isa_port2addr(unsigned long offset)
-{
-  /* CompactFlash (IDE) */
-	if (((offset >= 0x1f0) && (offset <= 0x1f7)) || (offset == 0x3f6)) {
-		return (unsigned long)cf_io_base + offset;
-	}
-
-  /* eth0 */
-	if ((offset >= 0x300) && (offset <= 0x30f)) {
-		return 0xa5000000 + offset;	/* COMM BOARD (AREA1) */
-	}
-
-	return offset + 0xb0000000; /* IOBUS (AREA 4)*/
-}
-#endif
-
diff -puN -L arch/sh/boards/adx/mach.c arch/sh/boards/adx/mach.c~linus /dev/null
--- 25/arch/sh/boards/adx/mach.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,64 +0,0 @@
-/*
- * linux/arch/sh/kernel/mach_adx.c
- *
- * Copyright (C) 2001 A&D Co., Ltd.
- *
- * This file may be copied or modified under the terms of the GNU
- * General Public License.  See linux/COPYING for more information.
- *
- * Machine vector for the A&D ADX Board
- */
-
-#include <linux/config.h>
-#include <linux/init.h>
-
-#include <asm/machvec.h>
-#include <asm/rtc.h>
-#include <asm/machvec_init.h>
-#include <asm/adx/io.h>
-
-extern void init_adx_IRQ(void);
-
-/*
- * The Machine Vector
- */
-
-struct sh_machine_vector mv_adx __initmv = {
-	.mv_nr_irqs		= 48,
-
-	.mv_inb			= adx_inb,
-	.mv_inw			= adx_inw,
-	.mv_inl			= adx_inl,
-	.mv_outb		= adx_outb,
-	.mv_outw		= adx_outw,
-	.mv_outl		= adx_outl,
-
-	.mv_inb_p		= adx_inb_p,
-	.mv_inw_p		= adx_inw,
-	.mv_inl_p		= adx_inl,
-	.mv_outb_p		= adx_outb_p,
-	.mv_outw_p		= adx_outw,
-	.mv_outl_p		= adx_outl,
-
-	.mv_insb		= adx_insb,
-	.mv_insw		= adx_insw,
-	.mv_insl		= adx_insl,
-	.mv_outsb		= adx_outsb,
-	.mv_outsw		= adx_outsw,
-	.mv_outsl		= adx_outsl,
-
-	.mv_readb		= adx_readb,
-	.mv_readw		= adx_readw,
-	.mv_readl		= adx_readl,
-	.mv_writeb		= adx_writeb,
-	.mv_writew		= adx_writew,
-	.mv_writel		= adx_writel,
-
-	.mv_ioremap		= adx_ioremap,
-	.mv_iounmap		= adx_iounmap,
-
-	.mv_isa_port2addr	= adx_isa_port2addr,
-
-	.mv_init_irq		= init_adx_IRQ,
-};
-ALIAS_MV(adx)
diff -puN arch/sh/boards/adx/Makefile~linus arch/sh/boards/adx/Makefile
--- 25/arch/sh/boards/adx/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/adx/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -6,5 +6,5 @@
 # unless it's something special (ie not a .c file).
 #
 
-obj-y	 := mach.o setup.o io.o irq.o irq_maskreq.o
+obj-y	 := setup.o irq.o irq_maskreq.o
 
diff -puN arch/sh/boards/adx/setup.c~linus arch/sh/boards/adx/setup.c
--- 25/arch/sh/boards/adx/setup.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/adx/setup.c	2004-01-19 22:17:21.000000000 -0800
@@ -14,11 +14,43 @@
 #include <asm/machvec.h>
 #include <linux/module.h>
 
+extern void init_adx_IRQ(void);
+extern void *cf_io_base;
+
 const char *get_system_type(void)
 {
 	return "A&D ADX";
 }
 
-void platform_setup(void)
+unsigned long adx_isa_port2addr(unsigned long offset)
 {
+	/* CompactFlash (IDE) */
+	if (((offset >= 0x1f0) && (offset <= 0x1f7)) || (offset == 0x3f6)) {
+		return (unsigned long)cf_io_base + offset;
+	}
+
+	/* eth0 */
+	if ((offset >= 0x300) && (offset <= 0x30f)) {
+		return 0xa5000000 + offset;	/* COMM BOARD (AREA1) */
+	}
+
+	return offset + 0xb0000000; /* IOBUS (AREA 4)*/
 }
+
+/*
+ * The Machine Vector
+ */
+
+struct sh_machine_vector mv_adx __initmv = {
+	.mv_nr_irqs		= 48,
+	.mv_isa_port2addr	= adx_isa_port2addr,
+	.mv_init_irq		= init_adx_IRQ,
+};
+ALIAS_MV(adx)
+
+int __init platform_setup(void)
+{
+	/* Nothing to see here .. */
+	return 0;
+}
+
diff -puN arch/sh/boards/bigsur/io.c~linus arch/sh/boards/bigsur/io.c
--- 25/arch/sh/boards/bigsur/io.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/bigsur/io.c	2004-01-19 22:17:21.000000000 -0800
@@ -21,18 +21,6 @@
 #include <asm/io.h>
 #include <asm/bigsur/bigsur.h>
 
-//#define BIGSUR_DEBUG 2
-#undef BIGSUR_DEBUG
-
-#ifdef BIGSUR_DEBUG
-#define DPRINTK(args...)	printk(args)
-#define DIPRINTK(n, args...)	if (BIGSUR_DEBUG>(n)) printk(args)
-#else
-#define DPRINTK(args...)
-#define DIPRINTK(n, args...)
-#endif
-
-
 /* Low iomap maps port 0-1K to addresses in 8byte chunks */
 #define BIGSUR_IOMAP_LO_THRESH 0x400
 #define BIGSUR_IOMAP_LO_SHIFT	3
@@ -53,19 +41,17 @@ static u8 bigsur_iomap_hi_shift[BIGSUR_I
 #define MAX(a,b)    ((a)>(b)?(a):(b))
 #endif
 
-#define PORT2ADDR(x) (sh_mv.mv_isa_port2addr(x))
-
 void bigsur_port_map(u32 baseport, u32 nports, u32 addr, u8 shift)
 {
-    u32 port, endport = baseport + nports;
+	u32 port, endport = baseport + nports;
 
-    DPRINTK("bigsur_port_map(base=0x%0x, n=0x%0x, addr=0x%08x)\n",
-	    baseport, nports, addr);
+	pr_debug("bigsur_port_map(base=0x%0x, n=0x%0x, addr=0x%08x)\n",
+		 baseport, nports, addr);
 	    
 	for (port = baseport ;
 	     port < endport && port < BIGSUR_IOMAP_LO_THRESH ;
 	     port += (1<<BIGSUR_IOMAP_LO_SHIFT)) {
-	    	DPRINTK("    maplo[0x%x] = 0x%08x\n", port, addr);
+	    	pr_debug("    maplo[0x%x] = 0x%08x\n", port, addr);
     	    bigsur_iomap_lo[port>>BIGSUR_IOMAP_LO_SHIFT] = addr;
     	    bigsur_iomap_lo_shift[port>>BIGSUR_IOMAP_LO_SHIFT] = shift;
 	    	addr += (1<<(BIGSUR_IOMAP_LO_SHIFT));
@@ -74,7 +60,7 @@ void bigsur_port_map(u32 baseport, u32 n
 	for (port = MAX(baseport, BIGSUR_IOMAP_LO_THRESH) ;
 	     port < endport && port < BIGSUR_IOMAP_HI_THRESH ;
 	     port += (1<<BIGSUR_IOMAP_HI_SHIFT)) {
-	    	DPRINTK("    maphi[0x%x] = 0x%08x\n", port, addr);
+	    	pr_debug("    maphi[0x%x] = 0x%08x\n", port, addr);
     	    bigsur_iomap_hi[port>>BIGSUR_IOMAP_HI_SHIFT] = addr;
     	    bigsur_iomap_hi_shift[port>>BIGSUR_IOMAP_HI_SHIFT] = shift;
 	    	addr += (1<<(BIGSUR_IOMAP_HI_SHIFT));
@@ -84,166 +70,56 @@ EXPORT_SYMBOL(bigsur_port_map);
 
 void bigsur_port_unmap(u32 baseport, u32 nports)
 {
-    u32 port, endport = baseport + nports;
+	u32 port, endport = baseport + nports;
 	
-    DPRINTK("bigsur_port_unmap(base=0x%0x, n=0x%0x)\n", baseport, nports);
+	pr_debug("bigsur_port_unmap(base=0x%0x, n=0x%0x)\n", baseport, nports);
 
 	for (port = baseport ;
 	     port < endport && port < BIGSUR_IOMAP_LO_THRESH ;
 	     port += (1<<BIGSUR_IOMAP_LO_SHIFT)) {
-    	    bigsur_iomap_lo[port>>BIGSUR_IOMAP_LO_SHIFT] = 0;
+		bigsur_iomap_lo[port>>BIGSUR_IOMAP_LO_SHIFT] = 0;
 	}
 
 	for (port = MAX(baseport, BIGSUR_IOMAP_LO_THRESH) ;
 	     port < endport && port < BIGSUR_IOMAP_HI_THRESH ;
 	     port += (1<<BIGSUR_IOMAP_HI_SHIFT)) {
-    	    bigsur_iomap_hi[port>>BIGSUR_IOMAP_HI_SHIFT] = 0;
+		bigsur_iomap_hi[port>>BIGSUR_IOMAP_HI_SHIFT] = 0;
 	}
 }
 EXPORT_SYMBOL(bigsur_port_unmap);
 
 unsigned long bigsur_isa_port2addr(unsigned long port)
 {
-    unsigned long addr = 0;
+	unsigned long addr = 0;
 	unsigned char shift;
 
 	/* Physical address not in P0, do nothing */
-	if (PXSEG(port)) addr = port;
+	if (PXSEG(port)) {
+		addr = port;
 	/* physical address in P0, map to P2 */
-	else if (port >= 0x30000)
-	    addr = P2SEGADDR(port);
+	} else if (port >= 0x30000) {
+		addr = P2SEGADDR(port);
 	/* Big Sur I/O + HD64465 registers 0x10000-0x30000 */
-	else if (port >= BIGSUR_IOMAP_HI_THRESH)
-	    addr = BIGSUR_INTERNAL_BASE + (port - BIGSUR_IOMAP_HI_THRESH);
+	} else if (port >= BIGSUR_IOMAP_HI_THRESH) {
+		addr = BIGSUR_INTERNAL_BASE + (port - BIGSUR_IOMAP_HI_THRESH);
 	/* Handle remapping of high IO/PCI IO ports */
-	else if (port >= BIGSUR_IOMAP_LO_THRESH) {
-	    addr = bigsur_iomap_hi[port >> BIGSUR_IOMAP_HI_SHIFT];
-	    shift = bigsur_iomap_hi_shift[port >> BIGSUR_IOMAP_HI_SHIFT];
-	    if (addr != 0)
-		    addr += (port & BIGSUR_IOMAP_HI_MASK) << shift;
-	}
-	/* Handle remapping of low IO ports */
-	else {
-	    addr = bigsur_iomap_lo[port >> BIGSUR_IOMAP_LO_SHIFT];
-	    shift = bigsur_iomap_lo_shift[port >> BIGSUR_IOMAP_LO_SHIFT];
-	    if (addr != 0)
-	    	addr += (port & BIGSUR_IOMAP_LO_MASK) << shift;
+	} else if (port >= BIGSUR_IOMAP_LO_THRESH) {
+		addr = bigsur_iomap_hi[port >> BIGSUR_IOMAP_HI_SHIFT];
+		shift = bigsur_iomap_hi_shift[port >> BIGSUR_IOMAP_HI_SHIFT];
+
+		if (addr != 0)
+			addr += (port & BIGSUR_IOMAP_HI_MASK) << shift;
+	} else {
+		/* Handle remapping of low IO ports */
+		addr = bigsur_iomap_lo[port >> BIGSUR_IOMAP_LO_SHIFT];
+		shift = bigsur_iomap_lo_shift[port >> BIGSUR_IOMAP_LO_SHIFT];
+
+		if (addr != 0)
+			addr += (port & BIGSUR_IOMAP_LO_MASK) << shift;
 	}
 
-    DIPRINTK(2, "PORT2ADDR(0x%08lx) = 0x%08lx\n", port, addr);
+	pr_debug("%s(0x%08lx) = 0x%08lx\n", __FUNCTION__, port, addr);
 
 	return addr;
 }
 
-static inline void delay(void)
-{
-	ctrl_inw(0xa0000000);
-}
-
-unsigned char bigsur_inb(unsigned long port)
-{
-	unsigned long addr = PORT2ADDR(port);
-	unsigned long b = (addr == 0 ? 0 : *(volatile unsigned char*)addr);
-
-	DIPRINTK(0, "inb(%08lx) = %02x\n", addr, (unsigned)b);
-	return b;
-}
-
-unsigned char bigsur_inb_p(unsigned long port)
-{
-    unsigned long v;
-	unsigned long addr = PORT2ADDR(port);
-
-	v = (addr == 0 ? 0 : *(volatile unsigned char*)addr);
-	delay();
-	DIPRINTK(0, "inb_p(%08lx) = %02x\n", addr, (unsigned)v);
-	return v;
-}
-
-unsigned short bigsur_inw(unsigned long port)
-{
-    unsigned long addr = PORT2ADDR(port);
-	unsigned long b = (addr == 0 ? 0 : *(volatile unsigned short*)addr);
-	DIPRINTK(0, "inw(%08lx) = %04lx\n", addr, b);
-	return b;
-}
-
-unsigned int bigsur_inl(unsigned long port)
-{
-    unsigned long addr = PORT2ADDR(port);
-	unsigned int b = (addr == 0 ? 0 : *(volatile unsigned long*)addr);
-	DIPRINTK(0, "inl(%08lx) = %08x\n", addr, b);
-	return b;
-}
-
-void bigsur_insb(unsigned long port, void *buffer, unsigned long count)
-{
-	unsigned char *buf=buffer;
-	while(count--) *buf++=inb(port);
-}
-
-void bigsur_insw(unsigned long port, void *buffer, unsigned long count)
-{
-	unsigned short *buf=buffer;
-	while(count--) *buf++=inw(port);
-}
-
-void bigsur_insl(unsigned long port, void *buffer, unsigned long count)
-{
-	unsigned long *buf=buffer;
-	while(count--) *buf++=inl(port);
-}
-
-void bigsur_outb(unsigned char b, unsigned long port)
-{
-	unsigned long addr = PORT2ADDR(port);
-
-	DIPRINTK(0, "outb(%02x, %08lx)\n", (unsigned)b, addr);
-	if (addr != 0)
-	    *(volatile unsigned char*)addr = b;
-}
-
-void bigsur_outb_p(unsigned char b, unsigned long port)
-{
-	unsigned long addr = PORT2ADDR(port);
-
-	DIPRINTK(0, "outb_p(%02x, %08lx)\n", (unsigned)b, addr);
-    if (addr != 0)
-	    *(volatile unsigned char*)addr = b;
-	delay();
-}
-
-void bigsur_outw(unsigned short b, unsigned long port)
-{
-	unsigned long addr = PORT2ADDR(port);
-	DIPRINTK(0, "outw(%04x, %08lx)\n", (unsigned)b, addr);
-	if (addr != 0)
-	    *(volatile unsigned short*)addr = b;
-}
-
-void bigsur_outl(unsigned int b, unsigned long port)
-{
-	unsigned long addr = PORT2ADDR(port);
-	DIPRINTK(0, "outl(%08x, %08lx)\n", b, addr);
-	if (addr != 0)
-            *(volatile unsigned long*)addr = b;
-}
-
-void bigsur_outsb(unsigned long port, const void *buffer, unsigned long count)
-{
-	const unsigned char *buf=buffer;
-	while(count--) outb(*buf++, port);
-}
-
-void bigsur_outsw(unsigned long port, const void *buffer, unsigned long count)
-{
-	const unsigned short *buf=buffer;
-	while(count--) outw(*buf++, port);
-}
-
-void bigsur_outsl(unsigned long port, const void *buffer, unsigned long count)
-{
-	const unsigned long *buf=buffer;
-	while(count--) outl(*buf++, port);
-}
-
diff -puN -L arch/sh/boards/bigsur/mach.c arch/sh/boards/bigsur/mach.c~linus /dev/null
--- 25/arch/sh/boards/bigsur/mach.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,72 +0,0 @@
-/*
- * linux/arch/sh/kernel/mach_bigsur.c
- *
- * By Dustin McIntire (dustin@sensoria.com) (c)2001
- * Derived from mach_se.h, which bore the message:
- * Copyright (C) 2000 Stuart Menefy (stuart.menefy@st.com)
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * Machine vector for the Hitachi Big Sur Evaluation Board
- */
-
-#include <linux/config.h>
-#include <linux/init.h>
-
-#include <asm/machvec.h>
-#include <asm/rtc.h>
-#include <asm/machvec_init.h>
-#include <asm/io.h>
-#include <asm/bigsur/io.h>
-#include <asm/irq.h>
-
-/*
- * The Machine Vector
- */
-extern void heartbeat_bigsur(void);
-extern void init_bigsur_IRQ(void);
-
-struct sh_machine_vector mv_bigsur __initmv = {
-	.mv_nr_irqs		= NR_IRQS,     // Defined in <asm/irq.h>
-	.mv_inb			= bigsur_inb,
-	.mv_inw			= bigsur_inw,
-	.mv_inl			= bigsur_inl,
-	.mv_outb		= bigsur_outb,
-	.mv_outw		= bigsur_outw,
-	.mv_outl		= bigsur_outl,
-
-	.mv_inb_p		= bigsur_inb_p,
-	.mv_inw_p		= bigsur_inw,
-	.mv_inl_p		= bigsur_inl,
-	.mv_outb_p		= bigsur_outb_p,
-	.mv_outw_p		= bigsur_outw,
-	.mv_outl_p		= bigsur_outl,
-
-	.mv_insb		= bigsur_insb,
-	.mv_insw		= bigsur_insw,
-	.mv_insl		= bigsur_insl,
-	.mv_outsb		= bigsur_outsb,
-	.mv_outsw		= bigsur_outsw,
-	.mv_outsl		= bigsur_outsl,
-
-	.mv_readb		= generic_readb,
-	.mv_readw		= generic_readw,
-	.mv_readl		= generic_readl,
-	.mv_writeb		= generic_writeb,
-	.mv_writew		= generic_writew,
-	.mv_writel		= generic_writel,
-
-	.mv_ioremap		= generic_ioremap,
-	.mv_iounmap		= generic_iounmap,
-
-	.mv_isa_port2addr	= bigsur_isa_port2addr,
-	.mv_irq_demux       = bigsur_irq_demux,
-
-	.mv_init_irq		= init_bigsur_IRQ,
-#ifdef CONFIG_HEARTBEAT
-	.mv_heartbeat		= heartbeat_bigsur,
-#endif
-
-};
-ALIAS_MV(bigsur)
diff -puN arch/sh/boards/bigsur/Makefile~linus arch/sh/boards/bigsur/Makefile
--- 25/arch/sh/boards/bigsur/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/bigsur/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -6,7 +6,5 @@
 # unless it's something special (ie not a .c file).
 #
 
-obj-y	 := mach.o setup.o io.o irq.o led.o
-
-obj-$(CONFIG_PCI) += pci.o
+obj-y	 := setup.o io.o irq.o led.o
 
diff -puN -L arch/sh/boards/bigsur/pci.c arch/sh/boards/bigsur/pci.c~linus /dev/null
--- 25/arch/sh/boards/bigsur/pci.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,163 +0,0 @@
-/*
- * linux/arch/sh/kernel/pci-bigsur.c
- *
- * By Dustin McIntire (dustin@sensoria.com) (c)2001
-
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * PCI initialization for the Hitachi Big Sur Evaluation Board
- */
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/pci.h>
-
-#include <asm/io.h>
-#include <asm/pci-sh7751.h>
-#include <asm/bigsur/bigsur.h>
-
-#define PCI_REG(reg)        (SH7751_PCIREG_BASE+reg)
-
-/*
- * Initialize the Big Sur PCI interface 
- * Setup hardware to be Central Funtion
- * Copy the BSR regs to the PCI interface
- * Setup PCI windows into local RAM
- */
-int __init pcibios_init_platform(void) {
-	u32 reg;
-	u32 word;
-
-	PCIDBG(1,"PCI: bigsur_pci_init called\n");
-	/* Set the BCR's to enable PCI access */
-	reg = inl(SH7751_BCR1);
-	reg |= 0x80000;
-	outl(reg, SH7751_BCR1);
-	
-	/* Setup the host hardware */
-	if(inl(PCI_REG(SH7751_PCICONF0)) !=
-	   (u32)((SH7751_DEVICE_ID <<16) | (SH7751_VENDOR_ID))) {
-	   printk("PCI: Unkown PCI host bridge.\n");
-	   return 0;
-	}  
-	printk("PCI: SH7751 PCI host bridge found.\n");
-	
-	/* Turn the clocks back on (not done in reset)*/
-	outl(0, PCI_REG(SH7751_PCICLKR));
-	/* Clear Powerdown IRQ's (not done in reset) */
-	word = SH7751_PCIPINT_D3 | SH7751_PCIPINT_D0;
-	outl(word, PCI_REG(SH7751_PCICLKR));
-
-	/* toggle PCI reset pin */
-	word = SH7751_PCICR_PREFIX | SH7751_PCICR_PRST;
-	outl(word,PCI_REG(SH7751_PCICR));    
-	/* Wait for a long time... not 1 sec. but long enough */
-	mdelay(100);
-	word = SH7751_PCICR_PREFIX;
-	outl(word,PCI_REG(SH7751_PCICR)); 
-	
-    /* set the command/status bits to:
-     * Wait Cycle Control + Parity Enable + Bus Master +
-     * Mem space enable
-     */
-    word = SH7751_PCICONF1_WCC | SH7751_PCICONF1_PER | 
-           SH7751_PCICONF1_BUM | SH7751_PCICONF1_MES;
-	outl(word, PCI_REG(SH7751_PCICONF1));
-
-	/* define this host as the host bridge */
-	word = SH7751_PCI_HOST_BRIDGE << 24;
-	outl(word, PCI_REG(SH7751_PCICONF2));
-
-	/* Set IO and Mem windows to local address 
-	 * Make PCI and local address the same for easy 1 to 1 mapping 
-	 * Window0 = BIGSUR_LSR0_SIZE @ non-cached CS3 base = SDRAM
-	 * Window1 = BIGSUR_LSR1_SIZE @ cached CS3 base = SDRAM 
-	 */
-	word = BIGSUR_LSR0_SIZE - 1;
-	outl(word, PCI_REG(SH7751_PCILSR0));
-	word = BIGSUR_LSR1_SIZE - 1;
-	outl(word, PCI_REG(SH7751_PCILSR1));
-	/* Set the values on window 0 PCI config registers */
-	word = P2SEGADDR(SH7751_CS3_BASE_ADDR);
-	outl(word, PCI_REG(SH7751_PCILAR0));
-	outl(word, PCI_REG(SH7751_PCICONF5));
-	/* Set the values on window 1 PCI config registers */
-	word =  PHYSADDR(SH7751_CS3_BASE_ADDR);
-	outl(word, PCI_REG(SH7751_PCILAR1));
-	outl(word, PCI_REG(SH7751_PCICONF6));
-
-	/* Set the local 16MB PCI memory space window to 
-	 * the lowest PCI mapped address
-	 */
-	word = PCIBIOS_MIN_MEM & SH7751_PCIMBR_MASK;
-	PCIDBG(2,"PCI: Setting upper bits of Memory window to 0x%x\n", word);
-	outl(word , PCI_REG(SH7751_PCIMBR));
-
-	/* Map IO space into PCI IO window
-	 * The IO window is 64K-PCIBIOS_MIN_IO in size
-	 * IO addresses will be translated to the 
-	 * PCI IO window base address
-	 */
-	PCIDBG(3,"PCI: Mapping IO address 0x%x - 0x%x to base 0x%x\n", PCIBIOS_MIN_IO,
-	    (64*1024), SH7751_PCI_IO_BASE+PCIBIOS_MIN_IO);
-	bigsur_port_map(PCIBIOS_MIN_IO, (64*1024), SH7751_PCI_IO_BASE+PCIBIOS_MIN_IO,0);
-	    
-	/* Make sure the MSB's of IO window are set to access PCI space correctly */
-	word = PCIBIOS_MIN_IO & SH7751_PCIIOBR_MASK;
-	PCIDBG(2,"PCI: Setting upper bits of IO window to 0x%x\n", word);
-	outl(word, PCI_REG(SH7751_PCIIOBR));
-	
-	/* Set PCI WCRx, BCRx's, copy from BSC locations */
-	word = inl(SH7751_BCR1);
-	/* check BCR for SDRAM in area 3 */
-	if(((word >> 3) & 1) == 0) {
-		printk("PCI: Area 3 is not configured for SDRAM. BCR1=0x%x\n", word);
-		return 0;
-	}
-	outl(word, PCI_REG(SH7751_PCIBCR1));
-	word = (u16)inw(SH7751_BCR2);
-	/* check BCR2 for 32bit SDRAM interface*/
-	if(((word >> 6) & 0x3) != 0x3) {
-		printk("PCI: Area 3 is not 32 bit SDRAM. BCR2=0x%x\n", word);
-		return 0;
-	}
-	outl(word, PCI_REG(SH7751_PCIBCR2));
-	/* configure the wait control registers */
-	word = inl(SH7751_WCR1);
-	outl(word, PCI_REG(SH7751_PCIWCR1));
-	word = inl(SH7751_WCR2);
-	outl(word, PCI_REG(SH7751_PCIWCR2));
-	word = inl(SH7751_WCR3);
-	outl(word, PCI_REG(SH7751_PCIWCR3));
-	word = inl(SH7751_MCR);
-	outl(word, PCI_REG(SH7751_PCIMCR));
-
-	/* NOTE: I'm ignoring the PCI error IRQs for now..
-	 * TODO: add support for the internal error interrupts and
-	 * DMA interrupts...
-	 */
-	 
-	/* SH7751 init done, set central function init complete */
-	word = SH7751_PCICR_PREFIX | SH7751_PCICR_CFIN;
-	outl(word,PCI_REG(SH7751_PCICR)); 
-	PCIDBG(2,"PCI: bigsur_pci_init finished\n");
-
-	return 1;
-}
-
-int pcibios_map_platform_irq(u8 slot, u8 pin)
-{
-    /* The Big Sur can be used in a CPCI chassis, but the SH7751 PCI interface is on the
-     * wrong end of the board so that it can also support a V320 CPI interface chip...
-     * Therefor the IRQ mapping is somewhat use dependent... I'l assume a linear map for
-     * now, i.e. INTA=slot0,pin0... INTD=slot3,pin0...
-     */ 
-    int irq = (slot + pin-1)%4 + BIGSUR_SH7751_PCI_IRQ_BASE;
-    PCIDBG(2,"PCI: Mapping Big Sur IRQ for slot %d, pin %c to irq %d\n", slot, pin-1+'A', irq);
-    return irq;
-     
-}
diff -puN arch/sh/boards/bigsur/setup.c~linus arch/sh/boards/bigsur/setup.c
--- 25/arch/sh/boards/bigsur/setup.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/bigsur/setup.c	2004-01-19 22:17:21.000000000 -0800
@@ -33,22 +33,11 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/bitops.h>
-
+#include <asm/machvec.h>
 #include <asm/bigsur/io.h>
 #include <asm/hd64465/hd64465.h>
 #include <asm/bigsur/bigsur.h>
 
-//#define BIGSUR_DEBUG 3
-#undef BIGSUR_DEBUG
-
-#ifdef BIGSUR_DEBUG
-#define DPRINTK(args...)	printk(args)
-#define DIPRINTK(n, args...)	if (BIGSUR_DEBUG>(n)) printk(args)
-#else
-#define DPRINTK(args...)
-#define DIPRINTK(n, args...)
-#endif /* BIGSUR_DEBUG */
-
 /*===========================================================*/
 //		Big Sur Init Routines	
 /*===========================================================*/
@@ -58,13 +47,27 @@ const char *get_system_type(void)
 	return "Big Sur";
 }
 
+/*
+ * The Machine Vector
+ */
+extern void heartbeat_bigsur(void);
+extern void init_bigsur_IRQ(void);
+
+struct sh_machine_vector mv_bigsur __initmv = {
+	.mv_nr_irqs		= NR_IRQS,     // Defined in <asm/irq.h>
+
+	.mv_isa_port2addr	= bigsur_isa_port2addr,
+	.mv_irq_demux       	= bigsur_irq_demux,
+
+	.mv_init_irq		= init_bigsur_IRQ,
+#ifdef CONFIG_HEARTBEAT
+	.mv_heartbeat		= heartbeat_bigsur,
+#endif
+};
+ALIAS_MV(bigsur)
+
 int __init platform_setup(void)
 {
-	static int done = 0; /* run this only once */
-
-	if (!MACH_BIGSUR || done) return 0;
-	done = 1;
-
 	/* Mask all 2nd level IRQ's */
 	outb(-1,BIGSUR_IMR0);
 	outb(-1,BIGSUR_IMR1);
@@ -88,7 +91,6 @@ int __init platform_setup(void)
 	/* set the IO port to BIGSUR_ETHER_IOPORT */
 	outw(BIGSUR_ETHER_IOPORT<<3, BIGSUR_ETHR+0x2);
 
-    return 0;
+	return 0;
 }
 
-module_init(setup_bigsur);
diff -puN -L arch/sh/boards/cat68701/io.c arch/sh/boards/cat68701/io.c~linus /dev/null
--- 25/arch/sh/boards/cat68701/io.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,207 +0,0 @@
-/* 
- * linux/arch/sh/boards/cat68701/io.c
- *
- * Copyright (C) 2000  Niibe Yutaka
- *               2001  Yutaro Ebihara
- *
- * I/O routines for A-ONE Corp CAT-68701 SH7708 Board
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- */
-
-#include <asm/io.h>
-#include <asm/machvec.h>
-#include <linux/config.h>
-#include <linux/module.h>
-
-#define SH3_PCMCIA_BUG_WORKAROUND 1
-#define DUMMY_READ_AREA6	  0xba000000
-
-#define PORT2ADDR(x) (cat68701_isa_port2addr(x))
-
-static inline void delay(void)
-{
-	ctrl_inw(0xa0000000);
-}
-
-unsigned char cat68701_inb(unsigned long port)
-{
-	return *(volatile unsigned char*)PORT2ADDR(port);
-}
-
-unsigned short cat68701_inw(unsigned long port)
-{
-	return *(volatile unsigned short*)PORT2ADDR(port);
-}
-
-unsigned int cat68701_inl(unsigned long port)
-{
-	return *(volatile unsigned long*)PORT2ADDR(port);
-}
-
-unsigned char cat68701_inb_p(unsigned long port)
-{
-	unsigned long v = *(volatile unsigned char*)PORT2ADDR(port);
-
-	delay();
-	return v;
-}
-
-unsigned short cat68701_inw_p(unsigned long port)
-{
-	unsigned long v = *(volatile unsigned short*)PORT2ADDR(port);
-
-	delay();
-	return v;
-}
-
-unsigned int cat68701_inl_p(unsigned long port)
-{
-	unsigned long v = *(volatile unsigned long*)PORT2ADDR(port);
-
-	delay();
-	return v;
-}
-
-void cat68701_insb(unsigned long port, void *buffer, unsigned long count)
-{
-	unsigned char *buf=buffer;
-	while(count--) *buf++=inb(port);
-}
-
-void cat68701_insw(unsigned long port, void *buffer, unsigned long count)
-{
-	unsigned short *buf=buffer;
-	while(count--) *buf++=inw(port);
-#ifdef SH3_PCMCIA_BUG_WORKAROUND
-	ctrl_inb (DUMMY_READ_AREA6);
-#endif
-}
-
-void cat68701_insl(unsigned long port, void *buffer, unsigned long count)
-{
-	unsigned long *buf=buffer;
-	while(count--) *buf++=inl(port);
-#ifdef SH3_PCMCIA_BUG_WORKAROUND
-	ctrl_inb (DUMMY_READ_AREA6);
-#endif
-}
-
-void cat68701_outb(unsigned char b, unsigned long port)
-{
-	*(volatile unsigned char*)PORT2ADDR(port) = b;
-}
-
-void cat68701_outw(unsigned short b, unsigned long port)
-{
-	*(volatile unsigned short*)PORT2ADDR(port) = b;
-}
-
-void cat68701_outl(unsigned int b, unsigned long port)
-{
-        *(volatile unsigned long*)PORT2ADDR(port) = b;
-}
-
-void cat68701_outb_p(unsigned char b, unsigned long port)
-{
-	*(volatile unsigned char*)PORT2ADDR(port) = b;
-	delay();
-}
-
-void cat68701_outw_p(unsigned short b, unsigned long port)
-{
-	*(volatile unsigned short*)PORT2ADDR(port) = b;
-	delay();
-}
-
-void cat68701_outl_p(unsigned int b, unsigned long port)
-{
-	*(volatile unsigned long*)PORT2ADDR(port) = b;
-	delay();
-}
-
-void cat68701_outsb(unsigned long port, const void *buffer, unsigned long count)
-{
-	const unsigned char *buf=buffer;
-	while(count--) outb(*buf++, port);
-}
-
-void cat68701_outsw(unsigned long port, const void *buffer, unsigned long count)
-{
-	const unsigned short *buf=buffer;
-	while(count--) outw(*buf++, port);
-#ifdef SH3_PCMCIA_BUG_WORKAROUND
-	ctrl_inb (DUMMY_READ_AREA6);
-#endif
-}
-
-void cat68701_outsl(unsigned long port, const void *buffer, unsigned long count)
-{
-	const unsigned long *buf=buffer;
-	while(count--) outl(*buf++, port);
-#ifdef SH3_PCMCIA_BUG_WORKAROUND
-	ctrl_inb (DUMMY_READ_AREA6);
-#endif
-}
-
-unsigned char cat68701_readb(unsigned long addr)
-{
-	return *(volatile unsigned char*)addr;
-}
-
-unsigned short cat68701_readw(unsigned long addr)
-{
-	return *(volatile unsigned short*)addr;
-}
-
-unsigned int cat68701_readl(unsigned long addr)
-{
-	return *(volatile unsigned long*)addr;
-}
-
-void cat68701_writeb(unsigned char b, unsigned long addr)
-{
-	*(volatile unsigned char*)addr = b;
-}
-
-void cat68701_writew(unsigned short b, unsigned long addr)
-{
-	*(volatile unsigned short*)addr = b;
-}
-
-void cat68701_writel(unsigned int b, unsigned long addr)
-{
-        *(volatile unsigned long*)addr = b;
-}
-
-void * cat68701_ioremap(unsigned long offset, unsigned long size)
-{
-	return (void *) P2SEGADDR(offset);
-}
-EXPORT_SYMBOL(cat68701_ioremap);
-
-void cat68701_iounmap(void *addr)
-{
-}
-EXPORT_SYMBOL(cat68701_iounmap);
-
-unsigned long cat68701_isa_port2addr(unsigned long offset)
-{
-  /* CompactFlash (IDE) */
-  if(((offset >= 0x1f0) && (offset <= 0x1f7)) || (offset==0x3f6))
-    return 0xba000000 + offset;
-
-  /* INPUT PORT */
-  if((offset >= 0x3fc) && (offset <= 0x3fd))
-    return 0xb4007000 + offset;
-
-  /* OUTPUT PORT */
-  if((offset >= 0x3fe) && (offset <= 0x3ff))
-    return 0xb4007400 + offset;
-
-  return offset + 0xb4000000; /* other I/O (EREA 5)*/
-}
-
diff -puN -L arch/sh/boards/cat68701/mach.c arch/sh/boards/cat68701/mach.c~linus /dev/null
--- 25/arch/sh/boards/cat68701/mach.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,66 +0,0 @@
-/*
- * linux/arch/sh/boards/cat68701/mach.c
- *
- * Copyright (C) 2000 Stuart Menefy (stuart.menefy@st.com)
- *               2001 Yutaro Ebihara (ebihara@si-linux.com)
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * Machine vector for the A-ONE corp. CAT-68701 SH7708 board
- */
-
-#include <linux/config.h>
-#include <linux/init.h>
-
-#include <asm/machvec.h>
-#include <asm/rtc.h>
-#include <asm/machvec_init.h>
-#include <asm/cat68701/io.h>
-
-/*
- * The Machine Vector
- */
-
-struct sh_machine_vector mv_cat68701 __initmv = {
-	.mv_nr_irqs		= 32,
-	.mv_inb			= cat68701_inb,
-	.mv_inw			= cat68701_inw,
-	.mv_inl			= cat68701_inl,
-	.mv_outb		= cat68701_outb,
-	.mv_outw		= cat68701_outw,
-	.mv_outl		= cat68701_outl,
-
-	.mv_inb_p		= cat68701_inb_p,
-	.mv_inw_p		= cat68701_inw,
-	.mv_inl_p		= cat68701_inl,
-	.mv_outb_p		= cat68701_outb_p,
-	.mv_outw_p		= cat68701_outw,
-	.mv_outl_p		= cat68701_outl,
-
-	.mv_insb		= cat68701_insb,
-	.mv_insw		= cat68701_insw,
-	.mv_insl		= cat68701_insl,
-	.mv_outsb		= cat68701_outsb,
-	.mv_outsw		= cat68701_outsw,
-	.mv_outsl		= cat68701_outsl,
-
-	.mv_readb		= cat68701_readb,
-	.mv_readw		= cat68701_readw,
-	.mv_readl		= cat68701_readl,
-	.mv_writeb		= cat68701_writeb,
-	.mv_writew		= cat68701_writew,
-	.mv_writel		= cat68701_writel,
-
-	.mv_ioremap		= cat68701_ioremap,
-	.mv_iounmap		= cat68701_iounmap,
-
-	.mv_isa_port2addr	= cat68701_isa_port2addr,
-	.mv_irq_demux           = cat68701_irq_demux,
-
-	.mv_init_irq		= init_cat68701_IRQ,
-#ifdef CONFIG_HEARTBEAT
-	.mv_heartbeat		= heartbeat_cat68701,
-#endif
-};
-ALIAS_MV(cat68701)
diff -puN arch/sh/boards/cat68701/Makefile~linus arch/sh/boards/cat68701/Makefile
--- 25/arch/sh/boards/cat68701/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/cat68701/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -6,5 +6,5 @@
 # unless it's something special (ie not a .c file).
 #
 
-obj-y	 := mach.o setup.o io.o irq.o
+obj-y	 := setup.o irq.o
 
diff -puN arch/sh/boards/cat68701/setup.c~linus arch/sh/boards/cat68701/setup.c
--- 25/arch/sh/boards/cat68701/setup.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/cat68701/setup.c	2004-01-19 22:17:21.000000000 -0800
@@ -14,21 +14,18 @@
 
 #include <asm/io.h>
 #include <asm/machvec.h>
+#include <asm/mach/io.h>
 #include <linux/config.h>
 #include <linux/module.h>
+#include <linux/init.h>
+#include <linux/sched.h>
 
 const char *get_system_type(void)
 {
 	return "CAT-68701";
 }
 
-void platform_setup()
-{
-	/* dummy read erea5 (CS8900A) */
-}
-
 #ifdef CONFIG_HEARTBEAT
-#include <linux/sched.h>
 void heartbeat_cat68701()
 {
         static unsigned int cnt = 0, period = 0 , bit = 0;
@@ -49,3 +46,41 @@ void heartbeat_cat68701()
 }
 #endif /* CONFIG_HEARTBEAT */
 
+unsigned long cat68701_isa_port2addr(unsigned long offset)
+{
+	/* CompactFlash (IDE) */
+	if (((offset >= 0x1f0) && (offset <= 0x1f7)) || (offset==0x3f6))
+		return 0xba000000 + offset;
+
+	/* INPUT PORT */
+	if ((offset >= 0x3fc) && (offset <= 0x3fd))
+		return 0xb4007000 + offset;
+
+	/* OUTPUT PORT */
+	if ((offset >= 0x3fe) && (offset <= 0x3ff))
+		return 0xb4007400 + offset;
+
+	return offset + 0xb4000000; /* other I/O (EREA 5)*/
+}
+
+/*
+ * The Machine Vector
+ */
+
+struct sh_machine_vector mv_cat68701 __initmv = {
+	.mv_nr_irqs		= 32,
+	.mv_isa_port2addr	= cat68701_isa_port2addr,
+	.mv_irq_demux		= cat68701_irq_demux,
+
+	.mv_init_irq		= init_cat68701_IRQ,
+#ifdef CONFIG_HEARTBEAT
+	.mv_heartbeat		= heartbeat_cat68701,
+#endif
+};
+ALIAS_MV(cat68701)
+
+int __init platform_setup(void)
+{
+	/* dummy read erea5 (CS8900A) */
+}
+
diff -puN -L arch/sh/boards/cqreek/io.c arch/sh/boards/cqreek/io.c~linus /dev/null
--- 25/arch/sh/boards/cqreek/io.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,14 +0,0 @@
-#define IDE_OFFSET 0xA4000000UL
-#define ISA_OFFSET 0xA4A00000UL
-
-unsigned long cqreek_port2addr(unsigned long port)
-{
-	if (0x0000<=port && port<=0x0040)
-		return IDE_OFFSET + port;
-	if ((0x01f0<=port && port<=0x01f7) || port == 0x03f6)
-		return IDE_OFFSET + port;
-
-	return ISA_OFFSET + port;
-}
-
-
diff -puN -L arch/sh/boards/cqreek/mach.c arch/sh/boards/cqreek/mach.c~linus /dev/null
--- 25/arch/sh/boards/cqreek/mach.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,66 +0,0 @@
-/* $Id: mach.c,v 1.1.2.4.2.1 2003/01/10 17:26:32 lethal Exp $
- *
- * arch/sh/kernel/setup_cqreek.c
- *
- * Copyright (C) 2000  Niibe Yutaka
- *
- * CqREEK IDE/ISA Bridge Support.
- *
- */
-
-#include <asm/rtc.h>
-#include <asm/io.h>
-#include <asm/io_generic.h>
-#include <asm/machvec.h>
-#include <asm/machvec_init.h>
-#include <asm/cqreek/cqreek.h>
-
-/*
- * The Machine Vector
- */
-
-struct sh_machine_vector mv_cqreek __initmv = {
-#if defined(CONFIG_CPU_SH4)
-	.mv_nr_irqs		= 48,
-#elif defined(CONFIG_CPU_SUBTYPE_SH7708)
-	.mv_nr_irqs		= 32,
-#elif defined(CONFIG_CPU_SUBTYPE_SH7709)
-	.mv_nr_irqs		= 61,
-#endif
-
-	.mv_inb			= generic_inb,
-	.mv_inw			= generic_inw,
-	.mv_inl			= generic_inl,
-	.mv_outb		= generic_outb,
-	.mv_outw		= generic_outw,
-	.mv_outl		= generic_outl,
-
-	.mv_inb_p		= generic_inb_p,
-	.mv_inw_p		= generic_inw_p,
-	.mv_inl_p		= generic_inl_p,
-	.mv_outb_p		= generic_outb_p,
-	.mv_outw_p		= generic_outw_p,
-	.mv_outl_p		= generic_outl_p,
-
-	.mv_insb		= generic_insb,
-	.mv_insw		= generic_insw,
-	.mv_insl		= generic_insl,
-	.mv_outsb		= generic_outsb,
-	.mv_outsw		= generic_outsw,
-	.mv_outsl		= generic_outsl,
-
-	.mv_readb		= generic_readb,
-	.mv_readw		= generic_readw,
-	.mv_readl		= generic_readl,
-	.mv_writeb		= generic_writeb,
-	.mv_writew		= generic_writew,
-	.mv_writel		= generic_writel,
-
-	.mv_init_irq		= init_cqreek_IRQ,
-
-	.mv_isa_port2addr	= cqreek_port2addr,
-
-	.mv_ioremap		= generic_ioremap,
-	.mv_iounmap		= generic_iounmap,
-};
-ALIAS_MV(cqreek)
diff -puN arch/sh/boards/cqreek/Makefile~linus arch/sh/boards/cqreek/Makefile
--- 25/arch/sh/boards/cqreek/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/cqreek/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -6,5 +6,5 @@
 # unless it's something special (ie not a .c file).
 #
 
-obj-y	 := mach.o setup.o io.o irq.o
+obj-y	 := setup.o irq.o
 
diff -puN arch/sh/boards/cqreek/setup.c~linus arch/sh/boards/cqreek/setup.c
--- 25/arch/sh/boards/cqreek/setup.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/cqreek/setup.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: setup.c,v 1.1.2.5 2002/03/02 21:57:07 lethal Exp $
+/* $Id: setup.c,v 1.5 2003/08/04 01:51:58 lethal Exp $
  *
  * arch/sh/kernel/setup_cqreek.c
  *
@@ -13,17 +13,49 @@
 #include <linux/init.h>
 #include <linux/irq.h>
 
-#include <asm/cqreek/cqreek.h>
+#include <asm/mach/cqreek.h>
+#include <asm/machvec.h>
 #include <asm/io.h>
 #include <asm/io_generic.h>
 #include <asm/irq.h>
 #include <asm/rtc.h>
 
+#define IDE_OFFSET 0xA4000000UL
+#define ISA_OFFSET 0xA4A00000UL
+
 const char *get_system_type(void)
 {
 	return "CqREEK";
 }
 
+static unsigned long cqreek_port2addr(unsigned long port)
+{
+	if (0x0000<=port && port<=0x0040)
+		return IDE_OFFSET + port;
+	if ((0x01f0<=port && port<=0x01f7) || port == 0x03f6)
+		return IDE_OFFSET + port;
+
+	return ISA_OFFSET + port;
+}
+
+/*
+ * The Machine Vector
+ */
+struct sh_machine_vector mv_cqreek __initmv = {
+#if defined(CONFIG_CPU_SH4)
+	.mv_nr_irqs		= 48,
+#elif defined(CONFIG_CPU_SUBTYPE_SH7708)
+	.mv_nr_irqs		= 32,
+#elif defined(CONFIG_CPU_SUBTYPE_SH7709)
+	.mv_nr_irqs		= 61,
+#endif
+
+	.mv_init_irq		= init_cqreek_IRQ,
+
+	.mv_isa_port2addr	= cqreek_port2addr,
+};
+ALIAS_MV(cqreek)
+
 /*
  * Initialize the board
  */
diff -puN arch/sh/boards/dmida/mach.c~linus arch/sh/boards/dmida/mach.c
--- 25/arch/sh/boards/dmida/mach.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/dmida/mach.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * linux/arch/sh/kernel/mach_dmida.c
+ * linux/arch/sh/boards/dmida/mach.c
  *
  * by Greg Banks <gbanks@pocketpenguins.com>
  * (c) 2000 PocketPenguins Inc
@@ -30,8 +30,6 @@
  */
 
 struct sh_machine_vector mv_dmida __initmv = {
-	.mv_name		= "DMIDA",
-
 	.mv_nr_irqs		= HD64465_IRQ_BASE+HD64465_IRQ_NUM,
 
 	.mv_inb			= hd64465_inb,
@@ -55,17 +53,7 @@ struct sh_machine_vector mv_dmida __init
 	.mv_outsw		= hd64465_outsw,
 	.mv_outsl		= hd64465_outsl,
 
-	.mv_readb		= generic_readb,
-	.mv_readw		= generic_readw,
-	.mv_readl		= generic_readl,
-	.mv_writeb		= generic_writeb,
-	.mv_writew		= generic_writew,
-	.mv_writel		= generic_writel,
-
 	.mv_irq_demux		= hd64465_irq_demux,
-
-	.mv_rtc_gettimeofday	= sh_rtc_gettimeofday,
-	.mv_rtc_settimeofday	= sh_rtc_settimeofday,
 };
 ALIAS_MV(dmida)
 
diff -puN -L arch/sh/boards/dreamcast/io.c arch/sh/boards/dreamcast/io.c~linus /dev/null
--- 25/arch/sh/boards/dreamcast/io.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,12 +0,0 @@
-/*
- *	$Id: io.c,v 1.1.2.1 2002/01/19 23:54:19 mrbrown Exp $
- *	I/O routines for SEGA Dreamcast
- */
-
-#include <asm/io.h>
-#include <asm/machvec.h>
-
-unsigned long dreamcast_isa_port2addr(unsigned long offset)
-{
-	return offset + 0xa0000000;
-}
diff -puN -L arch/sh/boards/dreamcast/mach.c arch/sh/boards/dreamcast/mach.c~linus /dev/null
--- 25/arch/sh/boards/dreamcast/mach.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,60 +0,0 @@
-/*
- *	$Id: mach.c,v 1.4 2003/05/20 03:04:36 lethal Exp $
- *	SEGA Dreamcast machine vector
- */
-
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/time.h>
-
-#include <asm/machvec.h>
-#include <asm/machvec_init.h>
-
-#include <asm/io_generic.h>
-#include <asm/dreamcast/io.h>
-#include <asm/irq.h>
-
-void __init dreamcast_pcibios_init(void);
-
-/*
- * The Machine Vector
- */
-
-struct sh_machine_vector mv_dreamcast __initmv = {
-	.mv_nr_irqs		= NR_IRQS,
-
-	.mv_inb			= generic_inb,
-	.mv_inw			= generic_inw,
-	.mv_inl			= generic_inl,
-	.mv_outb		= generic_outb,
-	.mv_outw		= generic_outw,
-	.mv_outl		= generic_outl,
-
-	.mv_inb_p		= generic_inb_p,
-	.mv_inw_p		= generic_inw,
-	.mv_inl_p		= generic_inl,
-	.mv_outb_p		= generic_outb_p,
-	.mv_outw_p		= generic_outw,
-	.mv_outl_p		= generic_outl,
-
-	.mv_insb		= generic_insb,
-	.mv_insw		= generic_insw,
-	.mv_insl		= generic_insl,
-	.mv_outsb		= generic_outsb,
-	.mv_outsw		= generic_outsw,
-	.mv_outsl		= generic_outsl,
-
-	.mv_readb		= generic_readb,
-	.mv_readw		= generic_readw,
-	.mv_readl		= generic_readl,
-	.mv_writeb		= generic_writeb,
-	.mv_writew		= generic_writew,
-	.mv_writel		= generic_writel,
-
-	.mv_ioremap		= generic_ioremap,
-	.mv_iounmap		= generic_iounmap,
-
-	.mv_isa_port2addr	= dreamcast_isa_port2addr,
-	.mv_irq_demux		= systemasic_irq_demux,
-};
-ALIAS_MV(dreamcast)
diff -puN arch/sh/boards/dreamcast/Makefile~linus arch/sh/boards/dreamcast/Makefile
--- 25/arch/sh/boards/dreamcast/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/dreamcast/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -6,7 +6,5 @@
 # unless it's something special (ie not a .c file).
 #
 
-obj-y	 := mach.o setup.o io.o irq.o rtc.o
-
-obj-$(CONFIG_PCI) += pci.o
+obj-y	 := setup.o irq.o rtc.o
 
diff -puN -L arch/sh/boards/dreamcast/pci.c arch/sh/boards/dreamcast/pci.c~linus /dev/null
--- 25/arch/sh/boards/dreamcast/pci.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,214 +0,0 @@
-/*
- $	$Id: pci.c,v 1.1.2.4.2.1 2003/03/31 14:33:18 lethal Exp $
- *	Dreamcast PCI: Supports SEGA Broadband Adaptor only.
- */
-
-#include <linux/config.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/param.h>
-#include <linux/interrupt.h>
-#include <linux/init.h>
-#include <linux/irq.h>
-#include <linux/pci.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/dreamcast/sysasic.h>
-
-#define	GAPSPCI_REGS		0x01001400
-#define GAPSPCI_DMA_BASE	0x01840000
-#define GAPSPCI_DMA_SIZE	32768
-#define GAPSPCI_BBA_CONFIG	0x01001600
-
-#define	GAPSPCI_IRQ		HW_EVENT_EXTERNAL
-
-static int gapspci_dma_used;
-
-/* XXX: Uh... */
-static struct resource gapspci_io_resource = {
-	"GAPSPCI IO",
-	0x01001600,
-	0x010016ff,
-	IORESOURCE_IO
-};
-
-static struct resource gapspci_mem_resource = {
-	"GAPSPCI mem",
-	0x01840000,
-	0x01847fff,
-	IORESOURCE_MEM
-};
-
-static struct pci_ops gapspci_pci_ops;
-struct pci_channel board_pci_channels[] = {
-	{&gapspci_pci_ops, &gapspci_io_resource, &gapspci_mem_resource, 0, 1},
-	{NULL, NULL, NULL, 0, 0},
-};
-
-struct pci_fixup pcibios_fixups[] = {
-	{0, 0, 0, NULL}
-};
-
-#define BBA_SELECTED(bus,devfn) (bus->number==0 && devfn==0)
-
-static int gapspci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 * val)
-{
-	switch (size) {
-	case 1:
-		if (BBA_SELECTED(bus, devfn))
-			*val = (u8)inb(GAPSPCI_BBA_CONFIG+where);
-	else
-			*val = (u8)0xff;
-		break;
-	case 2:
-		if (BBA_SELECTED(bus, devfn))
-			*val = (u16)inw(GAPSPCI_BBA_CONFIG+where);
-	else
-			*val = (u16)0xffff;
-		break;
-	case 4:
-		if (BBA_SELECTED(bus, devfn))
-		*val = inl(GAPSPCI_BBA_CONFIG+where);
-	else
-                *val = 0xffffffff;
-		break;
-	}	
-        return PCIBIOS_SUCCESSFUL;
-}
-
-static int gapspci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val)
-{
-	if (BBA_SELECTED(bus, devfn)) {
-		switch (size) {
-		case 1:
-			if (BBA_SELECTED(bus, devfn))
-				outb((u8)val, GAPSPCI_BBA_CONFIG+where);
-			break;
-		case 2:
-			if (BBA_SELECTED(bus, devfn))
-				outw((u16)val, GAPSPCI_BBA_CONFIG+where);
-			break;
-		case 4:
-			if (BBA_SELECTED(bus, devfn))
-		outl(val, GAPSPCI_BBA_CONFIG+where);
-			break;
-		}
-	}
-        return PCIBIOS_SUCCESSFUL;
-}
-
-static struct pci_ops gapspci_pci_ops = {
-	.read = 	gapspci_read,
-	.write = 	gapspci_write,
-};
-
-
-void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
-			   dma_addr_t * dma_handle)
-{
-	unsigned long buf;
-
-	if (gapspci_dma_used+size > GAPSPCI_DMA_SIZE)
-		return NULL;
-
-	buf = GAPSPCI_DMA_BASE+gapspci_dma_used;
-
-	gapspci_dma_used = PAGE_ALIGN(gapspci_dma_used+size);
-	
-	printk("pci_alloc_consistent: %ld bytes at 0x%lx\n", (long)size, buf);
-
-	*dma_handle = (dma_addr_t)buf;
-
-	return (void *)P2SEGADDR(buf);
-}
-
-
-void pci_free_consistent(struct pci_dev *hwdev, size_t size,
-			 void *vaddr, dma_addr_t dma_handle)
-{
-	/* XXX */
-	gapspci_dma_used = 0;
-}
-
-
-void __init pcibios_fixup_bus(struct pci_bus *bus)
-{
-	struct list_head *ln;
-	struct pci_dev *dev;
-
-	for (ln=bus->devices.next; ln != &bus->devices; ln=ln->next) {
-		dev = pci_dev_b(ln);
-		if (!BBA_SELECTED(bus, dev->devfn)) continue;
-
-		printk("PCI: MMIO fixup to %s\n", dev->dev.name);
-		dev->resource[1].start=0x01001700;
-		dev->resource[1].end=0x010017ff;
-	}
-}
-
-
-static u8 __init no_swizzle(struct pci_dev *dev, u8 * pin)
-{
-	return PCI_SLOT(dev->devfn);
-}
-
-
-static int __init map_dc_irq(struct pci_dev *dev, u8 slot, u8 pin)
-{
-	return GAPSPCI_IRQ;
-}
-
-void __init pcibios_fixup(void) { /* Do nothing. */ }
-
-void __init pcibios_fixup_irqs(void)
-{
-	pci_fixup_irqs(no_swizzle, map_dc_irq);
-}
-
-int __init gapspci_init(void)
-{
-	int i;
-	char idbuf[16];
-
-	for(i=0; i<16; i++)
-		idbuf[i]=inb(GAPSPCI_REGS+i);
-
-	if(strncmp(idbuf, "GAPSPCI_BRIDGE_2", 16))
-		return -1;
-
-	outl(0x5a14a501, GAPSPCI_REGS+0x18);
-
-	for(i=0; i<1000000; i++);
-
-	if(inl(GAPSPCI_REGS+0x18)!=1)
-		return -1;
-
-	outl(0x01000000, GAPSPCI_REGS+0x20);
-	outl(0x01000000, GAPSPCI_REGS+0x24);
-
-	outl(GAPSPCI_DMA_BASE, GAPSPCI_REGS+0x28);
-	outl(GAPSPCI_DMA_BASE+GAPSPCI_DMA_SIZE, GAPSPCI_REGS+0x2c);
-
-	outl(1, GAPSPCI_REGS+0x14);
-	outl(1, GAPSPCI_REGS+0x34);
-
-	gapspci_dma_used=0;
-
-	/* Setting Broadband Adapter */
-	outw(0xf900, GAPSPCI_BBA_CONFIG+0x06);
-	outl(0x00000000, GAPSPCI_BBA_CONFIG+0x30);
-	outb(0x00, GAPSPCI_BBA_CONFIG+0x3c);
-	outb(0xf0, GAPSPCI_BBA_CONFIG+0x0d);
-	outw(0x0006, GAPSPCI_BBA_CONFIG+0x04);
-	outl(0x00002001, GAPSPCI_BBA_CONFIG+0x10);
-	outl(0x01000000, GAPSPCI_BBA_CONFIG+0x14);
-
-	return 0;
-}
-
-/* Haven't done anything here as yet */
-char * __devinit pcibios_setup(char *str)
-{
-	return str;
-}
diff -puN arch/sh/boards/dreamcast/setup.c~linus arch/sh/boards/dreamcast/setup.c
--- 25/arch/sh/boards/dreamcast/setup.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/dreamcast/setup.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,9 +1,10 @@
-/* arch/sh/kernel/setup_dc.c
+/* 
+ * arch/sh/boards/dreamcast/setup.c
  *
  * Hardware support for the Sega Dreamcast.
  *
  * Copyright (c) 2001, 2002 M. R. Brown <mrbrown@linuxdc.org>
- * Copyright (c) 2002 Paul Mundt <lethal@chaoticdreams.org>
+ * Copyright (c) 2002, 2003 Paul Mundt <lethal@linux-sh.org>
  *
  * This file is part of the LinuxDC project (www.linuxdc.org)
  *
@@ -23,21 +24,27 @@
 
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/dreamcast/sysasic.h>
+#include <asm/machvec.h>
+#include <asm/machvec_init.h>
+#include <asm/mach/sysasic.h>
 
 extern struct hw_interrupt_type systemasic_int;
 /* XXX: Move this into it's proper header. */
 extern void (*board_time_init)(void);
 extern void aica_time_init(void);
-
+extern int gapspci_init(void);
+extern int systemasic_irq_demux(int);
 const char *get_system_type(void)
 {
 	return "Sega Dreamcast";
 }
 
-#ifdef CONFIG_PCI
-extern int gapspci_init(void);
-#endif
+struct sh_machine_vector mv_dreamcast __initmv = {
+	.mv_nr_irqs		= NR_IRQS,
+
+	.mv_irq_demux		= systemasic_irq_demux,
+};
+ALIAS_MV(dreamcast)
 
 int __init platform_setup(void)
 {
@@ -49,6 +56,8 @@ int __init platform_setup(void)
 	/* Acknowledge any previous events */
 	/* XXX */
 
+	__set_io_port_base(0xa0000000);
+
 	/* Assign all virtual IRQs to the System ASIC int. handler */
 	for (i = HW_EVENT_IRQ_BASE; i < HW_EVENT_IRQ_MAX; i++)
 		irq_desc[i].handler = &systemasic_int;
diff -puN -L arch/sh/boards/ec3104/mach.c arch/sh/boards/ec3104/mach.c~linus /dev/null
--- 25/arch/sh/boards/ec3104/mach.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,69 +0,0 @@
-/*
- * linux/arch/sh/kernel/mach_ec3104.c
- *  EC3104 companion chip support
- *
- * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>
- *
- */
-/* EC3104 note:
- * This code was written without any documentation about the EC3104 chip.  While
- * I hope I got most of the basic functionality right, the register names I use
- * are most likely completely different from those in the chip documentation.
- *
- * If you have any further information about the EC3104, please tell me
- * (prumpf@tux.org).
- */
-
-#include <linux/init.h>
-
-#include <asm/machvec.h>
-#include <asm/rtc.h>
-#include <asm/machvec_init.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-
-/*
- * The Machine Vector
- */
-
-struct sh_machine_vector mv_ec3104 __initmv = {
-	.mv_name		= "EC3104",
-
-	.mv_nr_irqs		= 96,
-
-	.mv_inb			= ec3104_inb,
-	.mv_inw			= ec3104_inw,
-	.mv_inl			= ec3104_inl,
-	.mv_outb		= ec3104_outb,
-	.mv_outw		= ec3104_outw,
-	.mv_outl		= ec3104_outl,
-
-	.mv_inb_p		= generic_inb_p,
-	.mv_inw_p		= generic_inw,
-	.mv_inl_p		= generic_inl,
-	.mv_outb_p		= generic_outb_p,
-	.mv_outw_p		= generic_outw,
-	.mv_outl_p		= generic_outl,
-
-	.mv_insb		= generic_insb,
-	.mv_insw		= generic_insw,
-	.mv_insl		= generic_insl,
-	.mv_outsb		= generic_outsb,
-	.mv_outsw		= generic_outsw,
-	.mv_outsl		= generic_outsl,
-
-	.mv_readb		= generic_readb,
-	.mv_readw		= generic_readw,
-	.mv_readl		= generic_readl,
-	.mv_writeb		= generic_writeb,
-	.mv_writew		= generic_writew,
-	.mv_writel		= generic_writel,
-
-	.mv_irq_demux		= ec3104_irq_demux,
-
-	.mv_rtc_gettimeofday	= sh_rtc_gettimeofday,
-	.mv_rtc_settimeofday	= sh_rtc_settimeofday,
-};
-
-ALIAS_MV(ec3104)
diff -puN arch/sh/boards/ec3104/Makefile~linus arch/sh/boards/ec3104/Makefile
--- 25/arch/sh/boards/ec3104/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/ec3104/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -6,5 +6,5 @@
 # unless it's something special (ie not a .c file).
 #
 
-obj-y	 := mach.o setup.o io.o irq.o
+obj-y	 := setup.o io.o irq.o
 
diff -puN arch/sh/boards/ec3104/setup.c~linus arch/sh/boards/ec3104/setup.c
--- 25/arch/sh/boards/ec3104/setup.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/ec3104/setup.c	2004-01-19 22:17:21.000000000 -0800
@@ -24,16 +24,38 @@
 
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/ec3104/ec3104.h>
+#include <asm/machvec.h>
+#include <asm/mach/ec3104.h>
 
-int __init setup_ec3104(void)
+const char *get_system_type(void)
+{
+	return "EC3104";
+}
+
+/*
+ * The Machine Vector
+ */
+
+struct sh_machine_vector mv_ec3104 __initmv = {
+	.mv_nr_irqs	= 96,
+
+	.mv_inb		= ec3104_inb,
+	.mv_inw		= ec3104_inw,
+	.mv_inl		= ec3104_inl,
+	.mv_outb	= ec3104_outb,
+	.mv_outw	= ec3104_outw,
+	.mv_outl	= ec3104_outl,
+
+	.mv_irq_demux	= ec3104_irq_demux,
+};
+
+ALIAS_MV(ec3104)
+
+int __init platform_setup(void)
 {
 	char str[8];
 	int i;
 	
-	if (!MACH_EC3104)
-		printk("!MACH_EC3104\n");
-
 	if (0)
 		return 0;
 
@@ -54,4 +76,3 @@ int __init setup_ec3104(void)
 	return 0;
 }
 
-module_init(setup_ec3104);
diff -puN arch/sh/boards/harp/mach.c~linus arch/sh/boards/harp/mach.c
--- 25/arch/sh/boards/harp/mach.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/harp/mach.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * linux/arch/sh/stboards/mach.c
+ * linux/arch/sh/boards/harp/mach.c
  *
  * Copyright (C) 2000 Stuart Menefy (stuart.menefy@st.com)
  *
@@ -14,7 +14,7 @@
 #include <asm/machvec.h>
 #include <asm/rtc.h>
 #include <asm/machvec_init.h>
-#include <asm/hd64465.h/io.h>
+#include <asm/hd64465/io.h>
 #include <asm/hd64465/hd64465.h>
 
 void setup_harp(void);
@@ -49,16 +49,6 @@ struct sh_machine_vector mv_harp __initm
 	.mv_outsw		= hd64465_outsw,
 	.mv_outsl		= hd64465_outsl,
 
-	.mv_readb		= generic_readb,
-	.mv_readw		= generic_readw,
-	.mv_readl		= generic_readl,
-	.mv_writeb		= generic_writeb,
-	.mv_writew		= generic_writew,
-	.mv_writel		= generic_writel,
-
-        .mv_ioremap             = generic_ioremap,
-        .mv_iounmap             = generic_iounmap,
- 
         .mv_isa_port2addr       = hd64465_isa_port2addr,
 
 #ifdef CONFIG_PCI
diff -puN arch/sh/boards/hp6xx/hp620/mach.c~linus arch/sh/boards/hp6xx/hp620/mach.c
--- 25/arch/sh/boards/hp6xx/hp620/mach.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/hp6xx/hp620/mach.c	2004-01-19 22:17:21.000000000 -0800
@@ -24,8 +24,6 @@
  */
 
 struct sh_machine_vector mv_hp620 __initmv = {
-        .mv_name                = "hp620",
-
         .mv_nr_irqs             = HD64461_IRQBASE+HD64461_IRQ_NUM,
 
         .mv_inb                 = hd64461_inb,
@@ -49,16 +47,6 @@ struct sh_machine_vector mv_hp620 __init
         .mv_outsw               = hd64461_outsw,
         .mv_outsl               = hd64461_outsl,
 
-        .mv_readb               = generic_readb,
-        .mv_readw               = generic_readw,
-        .mv_readl               = generic_readl,
-        .mv_writeb              = generic_writeb,
-        .mv_writew              = generic_writew,
-        .mv_writel              = generic_writel,
-
         .mv_irq_demux           = hd64461_irq_demux,
-
-        .mv_rtc_gettimeofday    = sh_rtc_gettimeofday,
-        .mv_rtc_settimeofday    = sh_rtc_settimeofday,
 };
 ALIAS_MV(hp620)
diff -puN arch/sh/boards/hp6xx/hp680/mach.c~linus arch/sh/boards/hp6xx/hp680/mach.c
--- 25/arch/sh/boards/hp6xx/hp680/mach.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/hp6xx/hp680/mach.c	2004-01-19 22:17:21.000000000 -0800
@@ -20,8 +20,6 @@
 #include <asm/irq.h>
 
 struct sh_machine_vector mv_hp680 __initmv = {
-        .mv_name                = "hp680",
-
         .mv_nr_irqs             = HD64461_IRQBASE+HD64461_IRQ_NUM,
 
         .mv_inb                 = hd64461_inb,
@@ -45,16 +43,6 @@ struct sh_machine_vector mv_hp680 __init
         .mv_outsw               = hd64461_outsw,
         .mv_outsl               = hd64461_outsl,
 
-        .mv_readb               = generic_readb,
-        .mv_readw               = generic_readw,
-        .mv_readl               = generic_readl,
-        .mv_writeb              = generic_writeb,
-        .mv_writew              = generic_writew,
-        .mv_writel              = generic_writel,
-
         .mv_irq_demux           = hd64461_irq_demux,
-
-        .mv_rtc_gettimeofday    = sh_rtc_gettimeofday,
-        .mv_rtc_settimeofday    = sh_rtc_settimeofday,
 };
 ALIAS_MV(hp680)
diff -puN arch/sh/boards/hp6xx/hp690/mach.c~linus arch/sh/boards/hp6xx/hp690/mach.c
--- 25/arch/sh/boards/hp6xx/hp690/mach.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/hp6xx/hp690/mach.c	2004-01-19 22:17:21.000000000 -0800
@@ -20,8 +20,6 @@
 #include <asm/irq.h>
 
 struct sh_machine_vector mv_hp690 __initmv = {
-        .mv_name                = "hp690",
-
         .mv_nr_irqs             = HD64461_IRQBASE+HD64461_IRQ_NUM,
 
         .mv_inb                 = hd64461_inb,
@@ -45,16 +43,6 @@ struct sh_machine_vector mv_hp690 __init
         .mv_outsw               = hd64461_outsw,
         .mv_outsl               = hd64461_outsl,
 
-        .mv_readb               = generic_readb,
-        .mv_readw               = generic_readw,
-        .mv_readl               = generic_readl,
-        .mv_writeb              = generic_writeb,
-        .mv_writew              = generic_writew,
-        .mv_writel              = generic_writel,
-
         .mv_irq_demux           = hd64461_irq_demux,
-
-        .mv_rtc_gettimeofday    = sh_rtc_gettimeofday,
-        .mv_rtc_settimeofday    = sh_rtc_settimeofday,
 };
 ALIAS_MV(hp690)
diff -puN -L arch/sh/boards/mpc1211/io.c arch/sh/boards/mpc1211/io.c~linus /dev/null
--- 25/arch/sh/boards/mpc1211/io.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,158 +0,0 @@
-/*
- * linux/arch/sh/kernel/io_mpc1211.c
- *
- * Copyright (C) 2001  Saito.K & Jeanne
- *
- * I/O routine for Interface MPC-1211.
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/pci.h>
-#include <asm/io.h>
-#include <asm/mpc1211/pci.h>
-
-static inline void delay(void)
-{
-	ctrl_inw(0xa0000000);
-}
-
-static inline unsigned long port2adr(unsigned long port)
-{
-        return port + PA_PCI_IO;
-}
-
-unsigned char mpc1211_inb(unsigned long port)
-{
-        return *(__u8 *)port2adr(port);
-}
-
-unsigned short mpc1211_inw(unsigned long port)
-{
-        return *(__u16 *)port2adr(port);
-}
-
-unsigned int mpc1211_inl(unsigned long port)
-{
-        return *(__u32 *)port2adr(port);
-}
-
-void mpc1211_outb(unsigned char value, unsigned long port)
-{
-	*(__u8 *)port2adr(port) = value; 
-}
-
-void mpc1211_outw(unsigned short value, unsigned long port)
-{
-	*(__u16 *)port2adr(port) = value; 
-}
-
-void mpc1211_outl(unsigned int value, unsigned long port)
-{
-	*(__u32 *)port2adr(port) = value; 
-}
-
-unsigned char mpc1211_inb_p(unsigned long port)
-{
-	unsigned char v;
-
-	v = *(__u8 *)port2adr(port);
-	delay();
-	return v;
-}
-
-void mpc1211_outb_p(unsigned char value, unsigned long port)
-{
-	*(__u8 *)port2adr(port) = value; 
-	delay();
-}
-
-void mpc1211_insb(unsigned long port, void *addr, unsigned long count)
-{
-	volatile __u8 *p = (__u8 *)port2adr(port);
-
-	while (count--) {
-	        *((__u8 *)addr)++ = *p;
-	}
-}
-
-void mpc1211_insw(unsigned long port, void *addr, unsigned long count)
-{
-	volatile __u16 *p = (__u16 *)port2adr(port);
-
-	while (count--) {
-	        *((__u16 *)addr)++ = *p;
-	}
-}
-
-void mpc1211_insl(unsigned long port, void *addr, unsigned long count)
-{
-	volatile __u32 *p = (__u32 *)port2adr(port);
-
-	while (count--) {
-	        *((__u32 *)addr)++ = *p;
-	}
-}
-
-void mpc1211_outsb(unsigned long port, const void *addr, unsigned long count)
-{
-	volatile __u8 *p = (__u8 *)port2adr(port);
-
-	while (count--) {
-	        *p = *((__u8 *)addr)++;
-	}
-}
-
-void mpc1211_outsw(unsigned long port, const void *addr, unsigned long count)
-{
-	volatile __u16 *p = (__u16 *)port2adr(port);
-
-	while (count--) {
-	        *p = *((__u16 *)addr)++;
-	}
-}
-
-void mpc1211_outsl(unsigned long port, const void *addr, unsigned long count)
-{
-	volatile __u32 *p = (__u32 *)port2adr(port);
-
-	while (count--) {
-	        *p = *((__u32 *)addr)++;
-	}
-}
-
-unsigned char mpc1211_readb(unsigned long addr)
-{
-	return *(volatile unsigned char *)addr;
-}
-
-unsigned short mpc1211_readw(unsigned long addr)
-{
-	return *(volatile unsigned short *)addr;
-}
-
-unsigned int mpc1211_readl(unsigned long addr)
-{
-	return *(volatile unsigned int *)addr;
-}
-
-void mpc1211_writeb(unsigned char b, unsigned long addr)
-{
-	*(volatile unsigned char *)addr = b;
-}
-
-void mpc1211_writew(unsigned short b, unsigned long addr)
-{
-	*(volatile unsigned short *)addr = b;
-}
-
-void mpc1211_writel(unsigned int b, unsigned long addr)
-{
-        *(volatile unsigned int *)addr = b;
-}
-
-unsigned long mpc1211_isa_port2addr(unsigned long offset)
-{
-	return port2adr(offset);
-}
diff -puN -L arch/sh/boards/mpc1211/mach.c arch/sh/boards/mpc1211/mach.c~linus /dev/null
--- 25/arch/sh/boards/mpc1211/mach.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,77 +0,0 @@
-/*
- * linux/arch/sh/kernel/mach_mpc1211.c
- *
- * Copyright (C) 2001 Saito.K & Jeanne
- *
- * Machine vector for the Interface MPC-1211
- */
-
-#include <linux/config.h>
-#include <linux/init.h>
-
-#include <asm/machvec.h>
-#include <asm/rtc.h>
-#include <asm/machvec_init.h>
-
-#include <asm/mpc1211/io.h>
-
-void heartbeat_mpc1211(void);
-void setup_mpc1211(void);
-void init_mpc1211_IRQ(void);
-
-/*
- * The Machine Vector
- */
-
-struct sh_machine_vector mv_mpc1211 __initmv = {
-	.mv_name		= "MPC-1211",
-
-	.mv_nr_irqs		= 48,
-
-	.mv_inb			= mpc1211_inb,
-	.mv_inw			= mpc1211_inw,
-	.mv_inl			= mpc1211_inl,
-	.mv_outb		= mpc1211_outb,
-	.mv_outw		= mpc1211_outw,
-	.mv_outl		= mpc1211_outl,
-
-	.mv_inb_p		= mpc1211_inb_p,
-	.mv_inw_p		= mpc1211_inw,
-	.mv_inl_p		= mpc1211_inl,
-	.mv_outb_p		= mpc1211_outb_p,
-	.mv_outw_p		= mpc1211_outw,
-	.mv_outl_p		= mpc1211_outl,
-
-	.mv_insb		= mpc1211_insb,
-	.mv_insw		= mpc1211_insw,
-	.mv_insl		= mpc1211_insl,
-	.mv_outsb		= mpc1211_outsb,
-	.mv_outsw		= mpc1211_outsw,
-	.mv_outsl		= mpc1211_outsl,
-
-	.mv_readb		= mpc1211_readb,
-	.mv_readw		= mpc1211_readw,
-	.mv_readl		= mpc1211_readl,
-	.mv_writeb		= mpc1211_writeb,
-	.mv_writew		= mpc1211_writew,
-	.mv_writel		= mpc1211_writel,
-
-	.mv_ioremap		= generic_ioremap,
-	.mv_iounmap		= generic_iounmap,
-
-	.mv_isa_port2addr	= mpc1211_isa_port2addr,
-
-	.mv_irq_demux		= mpc1211_irq_demux,
-
-	.mv_init_arch		= setup_mpc1211,
-	.mv_init_irq		= init_mpc1211_IRQ,
-	//	mv_init_pci            = mpc1211_pcibios_init,
-
-#ifdef CONFIG_HEARTBEAT
-	.mv_heartbeat		= heartbeat_mpc1211,
-#endif
-
-	.mv_rtc_gettimeofday	= mpc1211_rtc_gettimeofday,
-	.mv_rtc_settimeofday	= mpc1211_rtc_settimeofday,
-};
-ALIAS_MV(mpc1211)
diff -puN arch/sh/boards/mpc1211/Makefile~linus arch/sh/boards/mpc1211/Makefile
--- 25/arch/sh/boards/mpc1211/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/mpc1211/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -6,7 +6,7 @@
 # unless it's something special (ie not a .c file).
 #
 
-obj-y	 := mach.o setup.o io.o rtc.o led.o
+obj-y	 := setup.o rtc.o led.o
 
 obj-$(CONFIG_PCI) += pci.o
 
diff -puN arch/sh/boards/mpc1211/pci.c~linus arch/sh/boards/mpc1211/pci.c
--- 25/arch/sh/boards/mpc1211/pci.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/mpc1211/pci.c	2004-01-19 22:17:21.000000000 -0800
@@ -180,7 +180,8 @@ static void __devinit quirk_ali_ide_port
 
 /* Add future fixups here... */
 struct pci_fixup pcibios_fixups[] = {
-  { PCI_FIXUP_HEADER, PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M5229, quirk_ali_ide_ports },
+	{ PCI_FIXUP_HEADER, PCI_VENDOR_ID_AL,
+	  PCI_DEVICE_ID_AL_M5229, quirk_ali_ide_ports },
 	{ 0 }
 };
 
@@ -273,8 +274,6 @@ static int __init map_mpc1211_irq(struct
 	return irq;
 }
 
-void __init pcibios_fixup(void) { /* Do nothing. */ }
-
 void __init pcibios_fixup_irqs(void)
 {
 	pci_fixup_irqs(mpc1211_swizzle, map_mpc1211_irq);
diff -puN arch/sh/boards/mpc1211/rtc.c~linus arch/sh/boards/mpc1211/rtc.c
--- 25/arch/sh/boards/mpc1211/rtc.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/mpc1211/rtc.c	2004-01-19 22:17:21.000000000 -0800
@@ -143,3 +143,10 @@ int mpc1211_rtc_settimeofday(const struc
 
 	return set_rtc_mmss(nowtime);
 }
+
+void mpc1211_time_init(void)
+{
+	rtc_get_time = mpc1211_rtc_gettimeofday;
+	rtc_set_time = mpc1211_rtc_settimeofday;
+}
+
diff -puN arch/sh/boards/mpc1211/setup.c~linus arch/sh/boards/mpc1211/setup.c
--- 25/arch/sh/boards/mpc1211/setup.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/mpc1211/setup.c	2004-01-19 22:17:21.000000000 -0800
@@ -13,7 +13,9 @@
 #include <linux/interrupt.h>
 
 #include <asm/io.h>
+#include <asm/machvec.h>
 #include <asm/mpc1211/mpc1211.h>
+#include <asm/mpc1211/pci.h>
 #include <asm/mpc1211/m1543c.h>
 
 
@@ -54,10 +56,6 @@ const char *get_system_type(void)
 	return "Interface MPC-1211(CTP/PCI/MPC-SH02)";
 }
 
-void platform_setup(void)
-{
-}
-
 static void __init pci_write_config(unsigned long busNo,
 				    unsigned long devNo,
 				    unsigned long fncNo,
@@ -265,15 +263,16 @@ void __init init_mpc1211_IRQ(void)
 
 static void delay (void)
 {
-  volatile unsigned short tmp;
-  tmp = *(volatile unsigned short *) 0xa0000000;
+	volatile unsigned short tmp;
+	tmp = *(volatile unsigned short *) 0xa0000000;
 }
 
 static void delay1000 (void)
 {
-  int i;
-  for (i=0; i<1000; i++)
-    delay ();
+	int i;
+
+	for (i=0; i<1000; i++)
+		delay ();
 }
 
 static int put_smb_blk(unsigned char *p, int address, int command, int no)
@@ -316,21 +315,46 @@ static int put_smb_blk(unsigned char *p,
 	return 0;
 }
 
-void __init setup_mpc1211(void)
+/*
+ * The Machine Vector
+ */
+
+struct sh_machine_vector mv_mpc1211 __initmv = {
+	.mv_nr_irqs		= 48,
+	.mv_irq_demux		= mpc1211_irq_demux,
+	.mv_init_irq		= init_mpc1211_IRQ,
+
+#ifdef CONFIG_HEARTBEAT
+	.mv_heartbeat		= heartbeat_mpc1211,
+#endif
+};
+
+ALIAS_MV(mpc1211)
+
+/* arch/sh/boards/mpc1211/rtc.c */
+void mpc1211_time_init(void);
+
+int __init platform_setup(void)
 {
-  unsigned char spd_buf[128];
-  pci_write_config(0,0,0,0x54, 0xb0b00000);
+	unsigned char spd_buf[128];
+
+	__set_io_port_base(PA_PCI_IO);
+
+	pci_write_config(0,0,0,0x54, 0xb0b00000);
 
-retry:
-  outb(ALI15X3_ABORT, SMBHSTCNT);
-  spd_buf[0] = 0x0c;
-  spd_buf[1] = 0x43;
-  spd_buf[2] = 0x7f;
-  spd_buf[3] = 0x03;
-  spd_buf[4] = 0x00;
-  spd_buf[5] = 0x03;
-  spd_buf[6] = 0x00;
-  if (put_smb_blk(spd_buf, 0x69, 0, 7) < 0) {
-    goto retry;
-  }
+	do {
+		outb(ALI15X3_ABORT, SMBHSTCNT);
+		spd_buf[0] = 0x0c;
+		spd_buf[1] = 0x43;
+		spd_buf[2] = 0x7f;
+		spd_buf[3] = 0x03;
+		spd_buf[4] = 0x00;
+		spd_buf[5] = 0x03;
+		spd_buf[6] = 0x00;
+	} while (put_smb_blk(spd_buf, 0x69, 0, 7) < 0);
+
+	board_time_init = mpc1211_time_init;
+
+	return 0;
 }
+
diff -puN arch/sh/boards/overdrive/mach.c~linus arch/sh/boards/overdrive/mach.c
--- 25/arch/sh/boards/overdrive/mach.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/overdrive/mach.c	2004-01-19 22:17:21.000000000 -0800
@@ -51,18 +51,6 @@ struct sh_machine_vector mv_od __initmv 
 	.mv_outsw		= od_outsw,
 	.mv_outsl		= od_outsl,
 
-	.mv_readb		= generic_readb,
-	.mv_readw		= generic_readw,
-	.mv_readl		= generic_readl,
-	.mv_writeb		= generic_writeb,
-	.mv_writew		= generic_writew,
-	.mv_writel		= generic_writel,
-
-	.mv_ioremap		= generic_ioremap,
-	.mv_iounmap		= generic_iounmap,
-
-	.mv_isa_port2addr	= generic_isa_port2addr,
-
 #ifdef CONFIG_PCI
 	.mv_init_irq		= init_overdrive_irq,
 #endif
diff -puN arch/sh/boards/saturn/irq.c~linus arch/sh/boards/saturn/irq.c
--- 25/arch/sh/boards/saturn/irq.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/saturn/irq.c	2004-01-19 22:17:21.000000000 -0800
@@ -7,8 +7,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/init.h>
-#include <asm/saturn/saturn.h>
-#include <asm/saturn/irq.h>
+#include <linux/interrupt.h>
 #include <asm/irq.h>
 #include <asm/io.h>
 
@@ -65,7 +64,7 @@ static inline void unmask_saturn_irq(uns
 
 	mask = ctrl_inl(SATURN_IMR);
 	mask &= ~saturn_irq_mask(irq_nr);
-	ctrl_outl(SATURN_IMR);
+	ctrl_outl(mask, SATURN_IMR);
 }
 
 static void disable_saturn_irq(unsigned int irq_nr)
@@ -85,7 +84,7 @@ static void mask_and_ack_saturn_irq(unsi
 
 static void end_saturn_irq(unsigned int irq_nr)
 {
-	if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
+	if (!(irq_desc[irq_nr].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
 		unmask_saturn_irq(irq_nr);
 }
 
diff -puN -L arch/sh/boards/saturn/mach.c arch/sh/boards/saturn/mach.c~linus /dev/null
--- 25/arch/sh/boards/saturn/mach.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,59 +0,0 @@
-/*
- * arch/sh/boards/saturn/mach.c
- *
- * machvec definitions for the Sega Saturn.
- *
- * Copyright (C) 2002 Paul Mundt
- * 
- * Released under the terms of the GNU GPL v2.0.
- */
-#include <asm/io.h>
-#include <asm/io_generic.h>
-#include <asm/machvec.h>
-#include <asm/machvec_init.h>
-#include <asm/rtc.h>
-#include <asm/saturn/io.h>
-
-/*
- * The Machine Vector
- */
-struct sh_machine_vector mv_saturn __initmv = {
-        .mv_nr_irqs             = 80,	/* Fix this later */
-
-        .mv_inb                 = generic_inb,
-        .mv_inw                 = generic_inw,
-        .mv_inl                 = generic_inl,
-        .mv_outb                = generic_outb,
-        .mv_outw                = generic_outw,
-        .mv_outl                = generic_outl,
-
-        .mv_inb_p               = generic_inb_p,
-        .mv_inw_p               = generic_inw_p,
-        .mv_inl_p               = generic_inl_p,
-        .mv_outb_p              = generic_outb_p,
-        .mv_outw_p              = generic_outw_p,
-        .mv_outl_p              = generic_outl_p,
-
-        .mv_insb                = generic_insb,
-        .mv_insw                = generic_insw,
-        .mv_insl                = generic_insl,
-        .mv_outsb               = generic_outsb,
-        .mv_outsw               = generic_outsw,
-        .mv_outsl               = generic_outsl,
-
-        .mv_readb               = generic_readb,
-        .mv_readw               = generic_readw,
-        .mv_readl               = generic_readl,
-        .mv_writeb              = generic_writeb,
-        .mv_writew              = generic_writew,
-        .mv_writel              = generic_writel,
-
-        .mv_isa_port2addr       = saturn_isa_port2addr,
-	.mv_irq_demux		= saturn_irq_demux,
-
-        .mv_ioremap             = saturn_ioremap,
-        .mv_iounmap             = saturn_iounmap,
-};
-
-ALIAS_MV(saturn)
-
diff -puN arch/sh/boards/saturn/Makefile~linus arch/sh/boards/saturn/Makefile
--- 25/arch/sh/boards/saturn/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/saturn/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -6,7 +6,7 @@
 # unless it's something special (ie not a .c file).
 #
 
-obj-y	 := mach.o setup.o io.o irq.o
+obj-y	 := setup.o io.o irq.o
 
 obj-$(CONFIG_SMP) += smp.o
 
diff -puN arch/sh/boards/saturn/setup.c~linus arch/sh/boards/saturn/setup.c
--- 25/arch/sh/boards/saturn/setup.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/saturn/setup.c	2004-01-19 22:17:21.000000000 -0800
@@ -10,11 +10,32 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 
+#include <asm/io.h>
+#include <asm/machvec.h>
+#include <asm/mach/io.h>
+
+extern int saturn_irq_demux(int irq_nr);
+
 const char *get_system_type(void)
 {
 	return "Sega Saturn";
 }
 
+/*
+ * The Machine Vector
+ */
+struct sh_machine_vector mv_saturn __initmv = {
+	.mv_nr_irqs		= 80,	/* Fix this later */
+
+	.mv_isa_port2addr	= saturn_isa_port2addr,
+	.mv_irq_demux		= saturn_irq_demux,
+
+	.mv_ioremap		= saturn_ioremap,
+	.mv_iounmap		= saturn_iounmap,
+};
+
+ALIAS_MV(saturn)
+
 int __init platform_setup(void)
 {
 	return 0;
diff -puN arch/sh/boards/saturn/smp.c~linus arch/sh/boards/saturn/smp.c
--- 25/arch/sh/boards/saturn/smp.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/saturn/smp.c	2004-01-19 22:17:21.000000000 -0800
@@ -34,7 +34,7 @@ unsigned int __smp_probe_cpus(void)
  * addition to which, we treat them as write-only, since
  * reading from them will return undefined data.
  */
-static inline void smpc_slave_off(unsigned int cpu)
+static inline void smpc_slave_stop(unsigned int cpu)
 {
 	smpc_barrier();
 	ctrl_outb(1, SMPC_STATUS);
@@ -43,7 +43,7 @@ static inline void smpc_slave_off(unsign
 	smpc_barrier();
 }
 
-static inline void smpc_slave_on(unsigned int cpu)
+static inline void smpc_slave_start(unsigned int cpu)
 {
 	ctrl_outb(1, SMPC_STATUS);
 	ctrl_outb(SMPC_CMD_SSHON, SMPC_COMMAND);
diff -puN arch/sh/boards/se/770x/io.c~linus arch/sh/boards/se/770x/io.c
--- 25/arch/sh/boards/se/770x/io.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/se/770x/io.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: io.c,v 1.1.2.2 2002/01/20 05:03:25 mrbrown Exp $
+/* $Id: io.c,v 1.4 2003/08/03 03:05:10 lethal Exp $
  *
  * linux/arch/sh/kernel/io_se.c
  *
@@ -189,36 +189,6 @@ void se_outsl(unsigned long port, const 
 	maybebadio(outsw, port);
 }
 
-unsigned char se_readb(unsigned long addr)
-{
-	return *(volatile unsigned char*)addr;
-}
-
-unsigned short se_readw(unsigned long addr)
-{
-	return *(volatile unsigned short*)addr;
-}
-
-unsigned int se_readl(unsigned long addr)
-{
-	return *(volatile unsigned long*)addr;
-}
-
-void se_writeb(unsigned char b, unsigned long addr)
-{
-	*(volatile unsigned char*)addr = b;
-}
-
-void se_writew(unsigned short b, unsigned long addr)
-{
-	*(volatile unsigned short*)addr = b;
-}
-
-void se_writel(unsigned int b, unsigned long addr)
-{
-        *(volatile unsigned long*)addr = b;
-}
-
 /* Map ISA bus address to the real address. Only for PCMCIA.  */
 
 /* ISA page descriptor.  */
diff -puN arch/sh/boards/se/770x/mach.c~linus arch/sh/boards/se/770x/mach.c
--- 25/arch/sh/boards/se/770x/mach.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/se/770x/mach.c	2004-01-19 22:17:21.000000000 -0800
@@ -56,16 +56,6 @@ struct sh_machine_vector mv_se __initmv 
 	.mv_outsw		= se_outsw,
 	.mv_outsl		= se_outsl,
 
-	.mv_readb		= se_readb,
-	.mv_readw		= se_readw,
-	.mv_readl		= se_readl,
-	.mv_writeb		= se_writeb,
-	.mv_writew		= se_writew,
-	.mv_writel		= se_writel,
-
-	.mv_ioremap		= generic_ioremap,
-	.mv_iounmap		= generic_iounmap,
-
 	.mv_isa_port2addr	= se_isa_port2addr,
 
 	.mv_init_irq		= init_se_IRQ,
diff -puN arch/sh/boards/se/7751/io.c~linus arch/sh/boards/se/7751/io.c
--- 25/arch/sh/boards/se/7751/io.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/se/7751/io.c	2004-01-19 22:17:21.000000000 -0800
@@ -201,76 +201,16 @@ void sh7751se_outl(unsigned int value, u
 		maybebadio(outl, port);
 }
 
-void sh7751se_insb(unsigned long port, void *addr, unsigned long count)
-{
-	unsigned char *p = addr;
-	while (count--) *p++ = sh7751se_inb(port);
-}
-
-void sh7751se_insw(unsigned long port, void *addr, unsigned long count)
-{
-	unsigned short *p = addr;
-	while (count--) *p++ = sh7751se_inw(port);
-}
-
 void sh7751se_insl(unsigned long port, void *addr, unsigned long count)
 {
 	maybebadio(insl, port);
 }
 
-void sh7751se_outsb(unsigned long port, const void *addr, unsigned long count)
-{
-	unsigned char *p = (unsigned char*)addr;
-	while (count--) sh7751se_outb(*p++, port);
-}
-
-void sh7751se_outsw(unsigned long port, const void *addr, unsigned long count)
-{
-	unsigned short *p = (unsigned short*)addr;
-	while (count--) sh7751se_outw(*p++, port);
-}
-
 void sh7751se_outsl(unsigned long port, const void *addr, unsigned long count)
 {
 	maybebadio(outsw, port);
 }
 
-/* For read/write calls, just copy generic (pass-thru); PCIMBR is  */
-/* already set up.  For a larger memory space, these would need to */
-/* reset PCIMBR as needed on a per-call basis...                   */
-
-unsigned char sh7751se_readb(unsigned long addr)
-{
-	return *(volatile unsigned char*)addr;
-}
-
-unsigned short sh7751se_readw(unsigned long addr)
-{
-	return *(volatile unsigned short*)addr;
-}
-
-unsigned int sh7751se_readl(unsigned long addr)
-{
-	return *(volatile unsigned long*)addr;
-}
-
-void sh7751se_writeb(unsigned char b, unsigned long addr)
-{
-	*(volatile unsigned char*)addr = b;
-}
-
-void sh7751se_writew(unsigned short b, unsigned long addr)
-{
-	*(volatile unsigned short*)addr = b;
-}
-
-void sh7751se_writel(unsigned int b, unsigned long addr)
-{
-        *(volatile unsigned long*)addr = b;
-}
-
-
-
 /* Map ISA bus address to the real address. Only for PCMCIA.  */
 
 /* ISA page descriptor.  */
diff -puN arch/sh/boards/se/7751/mach.c~linus arch/sh/boards/se/7751/mach.c
--- 25/arch/sh/boards/se/7751/mach.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/se/7751/mach.c	2004-01-19 22:17:21.000000000 -0800
@@ -42,23 +42,9 @@ struct sh_machine_vector mv_7751se __ini
 	.mv_outw_p		= sh7751se_outw,
 	.mv_outl_p		= sh7751se_outl,
 
-	.mv_insb		= sh7751se_insb,
-	.mv_insw		= sh7751se_insw,
 	.mv_insl		= sh7751se_insl,
-	.mv_outsb		= sh7751se_outsb,
-	.mv_outsw		= sh7751se_outsw,
 	.mv_outsl		= sh7751se_outsl,
 
-	.mv_readb		= sh7751se_readb,
-	.mv_readw		= sh7751se_readw,
-	.mv_readl		= sh7751se_readl,
-	.mv_writeb		= sh7751se_writeb,
-	.mv_writew		= sh7751se_writew,
-	.mv_writel		= sh7751se_writel,
-
-	.mv_ioremap		= generic_ioremap,
-	.mv_iounmap		= generic_iounmap,
-
 	.mv_isa_port2addr	= sh7751se_isa_port2addr,
 
 	.mv_init_irq		= init_7751se_IRQ,
diff -puN arch/sh/boards/se/7751/pci.c~linus arch/sh/boards/se/7751/pci.c
--- 25/arch/sh/boards/se/7751/pci.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/se/7751/pci.c	2004-01-19 22:17:21.000000000 -0800
@@ -95,12 +95,11 @@ int __init pcibios_init_platform(void)
 
    /*
     * Set the MBR so PCI address is one-to-one with window,
-    * meaning all calls go straight through... use ifdef to
+    * meaning all calls go straight through... use BUG_ON to
     * catch erroneous assumption.
     */
-#if PCIBIOS_MIN_MEM != SH7751_PCI_MEMORY_BASE
-#error One-to-one assumption for PCI memory mapping is wrong!?!?!?
-#endif   
+   BUG_ON(PCIBIOS_MIN_MEM != SH7751_PCI_MEMORY_BASE);
+
    PCIC_WRITE(SH7751_PCIMBR, PCIBIOS_MIN_MEM);
 
    /* Set IOBR for window containing area specified in pci.h */
@@ -125,3 +124,25 @@ int __init pcibios_map_platform_irq(u8 s
                 return -1;
         }
 }
+
+static struct resource sh7751_io_resource = {
+	.name   = "SH7751 IO",
+	.start  = SH7751_PCI_IO_BASE,
+	.end    = SH7751_PCI_IO_BASE + SH7751_PCI_IO_SIZE - 1,
+	.flags  = IORESOURCE_IO
+};
+
+static struct resource sh7751_mem_resource = {
+	.name   = "SH7751 mem",
+	.start  = SH7751_PCI_MEMORY_BASE,
+	.end    = SH7751_PCI_MEMORY_BASE + SH7751_PCI_MEM_SIZE - 1,
+	.flags  = IORESOURCE_MEM
+};
+
+extern struct pci_ops sh7751_pci_ops;
+
+struct pci_channel board_pci_channels[] = {
+	{ &sh7751_pci_ops, &sh7751_io_resource, &sh7751_mem_resource, 0, 0xff },
+	{ NULL, NULL, NULL, 0, 0 },
+};
+
diff -puN -L arch/sh/boards/sh2000/io.c arch/sh/boards/sh2000/io.c~linus /dev/null
--- 25/arch/sh/boards/sh2000/io.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,19 +0,0 @@
-/*
- * I/O routine for SH-2000
- */
-#include <linux/config.h>
-#include <asm/io.h>
-#include <asm/machvec.h>
-
-#define IDE_OFFSET    0xb6200000
-#define NIC_OFFSET    0xb6000000
-#define EXTBUS_OFFSET 0xba000000
-
-unsigned long sh2000_isa_port2addr(unsigned long offset)
-{
-	if((offset & ~7) == 0x1f0 || offset == 0x3f6)
-		return IDE_OFFSET + offset;
-	else if((offset & ~0x1f) == 0x300)
-		return NIC_OFFSET + offset;
-	return EXTBUS_OFFSET + offset;
-}
diff -puN -L arch/sh/boards/sh2000/mach.c arch/sh/boards/sh2000/mach.c~linus /dev/null
--- 25/arch/sh/boards/sh2000/mach.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,57 +0,0 @@
-/*
- * linux/arch/sh/boards/sh2000/mach.c
- *
- * Original copyright message:
- * Copyright (C) 2001  SUGIOKA Tochinobu
- *
- * Split into mach.c from setup.c by M. R. Brown <mrbrown@0xd6.org>
- */
-
-#include <asm/io.h>
-#include <asm/io_generic.h>
-#include <asm/machvec.h>
-#include <asm/machvec_init.h>
-#include <asm/rtc.h>
-#include <asm/sh2000/sh2000.h>
-
-/*
- * The Machine Vector
- */
-
-struct sh_machine_vector mv_sh2000 __initmv = {
-        .mv_nr_irqs             = 80,
-
-        .mv_inb                 = generic_inb,
-        .mv_inw                 = generic_inw,
-        .mv_inl                 = generic_inl,
-        .mv_outb                = generic_outb,
-        .mv_outw                = generic_outw,
-        .mv_outl                = generic_outl,
-
-        .mv_inb_p               = generic_inb_p,
-        .mv_inw_p               = generic_inw_p,
-        .mv_inl_p               = generic_inl_p,
-        .mv_outb_p              = generic_outb_p,
-        .mv_outw_p              = generic_outw_p,
-        .mv_outl_p              = generic_outl_p,
-
-        .mv_insb                = generic_insb,
-        .mv_insw                = generic_insw,
-        .mv_insl                = generic_insl,
-        .mv_outsb               = generic_outsb,
-        .mv_outsw               = generic_outsw,
-        .mv_outsl               = generic_outsl,
-
-        .mv_readb               = generic_readb,
-        .mv_readw               = generic_readw,
-        .mv_readl               = generic_readl,
-        .mv_writeb              = generic_writeb,
-        .mv_writew              = generic_writew,
-        .mv_writel              = generic_writel,
-
-        .mv_isa_port2addr       = sh2000_isa_port2addr,
-
-        .mv_ioremap             = generic_ioremap,
-        .mv_iounmap             = generic_iounmap,
-};
-ALIAS_MV(sh2000)
diff -puN arch/sh/boards/sh2000/Makefile~linus arch/sh/boards/sh2000/Makefile
--- 25/arch/sh/boards/sh2000/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/sh2000/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -6,5 +6,5 @@
 # unless it's something special (ie not a .c file).
 #
 
-obj-y	 := mach.o setup.o io.o
+obj-y	 := setup.o
 
diff -puN arch/sh/boards/sh2000/setup.c~linus arch/sh/boards/sh2000/setup.c
--- 25/arch/sh/boards/sh2000/setup.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boards/sh2000/setup.c	2004-01-19 22:17:21.000000000 -0800
@@ -12,6 +12,8 @@
 #include <linux/irq.h>
 
 #include <asm/io.h>
+#include <asm/machvec.h>
+#include <asm/mach/sh2000.h>
 
 #define CF_CIS_BASE	0xb4200000
 
@@ -20,11 +22,34 @@
 #define	PORT_ICR1	0xa4000010
 #define	PORT_IRR0	0xa4000004
 
+#define IDE_OFFSET	0xb6200000
+#define NIC_OFFSET	0xb6000000
+#define EXTBUS_OFFSET	0xba000000
+
+
 const char *get_system_type(void)
 {
 	return "sh2000";
 }
 
+static unsigned long sh2000_isa_port2addr(unsigned long offset)
+{
+	if((offset & ~7) == 0x1f0 || offset == 0x3f6)
+		return IDE_OFFSET + offset;
+	else if((offset & ~0x1f) == 0x300)
+		return NIC_OFFSET + offset;
+	return EXTBUS_OFFSET + offset;
+}
+
+/*
+ * The Machine Vector
+ */
+struct sh_machine_vector mv_sh2000 __initmv = {
+        .mv_nr_irqs		= 80,
+        .mv_isa_port2addr	= sh2000_isa_port2addr,
+};
+ALIAS_MV(sh2000)
+
 /*
  * Initialize the board
  */
diff -puN /dev/null arch/sh/boards/snapgear/io.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/boards/snapgear/io.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,226 @@
+/* 
+ * linux/arch/sh/kernel/io_7751se.c
+ *
+ * Copyright (C) 2002  David McCullough <davidm@snapgear.com>
+ * Copyright (C) 2001  Ian da Silva, Jeremy Siegel
+ * Based largely on io_se.c.
+ *
+ * I/O routine for Hitachi 7751 SolutionEngine.
+ *
+ * Initial version only to support LAN access; some
+ * placeholder code from io_se.c left in with the
+ * expectation of later SuperIO and PCMCIA access.
+ */
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <asm/io.h>
+#include <asm/addrspace.h>
+
+#include <asm/pci.h>
+#include "../../drivers/pci/pci-sh7751.h"
+
+#ifdef CONFIG_SH_SECUREEDGE5410
+unsigned short secureedge5410_ioport;
+#endif
+
+/*
+ * The SnapGear uses the built-in PCI controller (PCIC)
+ * of the 7751 processor
+ */ 
+
+#define PCIIOBR		(volatile long *)PCI_REG(SH7751_PCIIOBR)
+#define PCIMBR          (volatile long *)PCI_REG(SH7751_PCIMBR)
+#define PCI_IO_AREA	SH7751_PCI_IO_BASE
+#define PCI_MEM_AREA	SH7751_PCI_CONFIG_BASE
+
+
+#define PCI_IOMAP(adr)	(PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK))
+
+
+#define maybebadio(name,port) \
+  printk("bad PC-like io %s for port 0x%lx at 0x%08x\n", \
+	 #name, (port), (__u32) __builtin_return_address(0))
+
+
+static inline void delay(void)
+{
+	ctrl_inw(0xa0000000);
+}
+
+
+static inline volatile __u16 *port2adr(unsigned int port)
+{
+#if 0
+	if (port >= 0x2000)
+		return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
+#endif
+	maybebadio(name,(unsigned long)port);
+	return (volatile __u16*)port;
+}
+
+
+/* In case someone configures the kernel w/o PCI support: in that */
+/* scenario, don't ever bother to check for PCI-window addresses */
+
+/* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */
+#if defined(CONFIG_PCI)
+#define CHECK_SH7751_PCIIO(port) \
+  ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE)))
+#else
+#define CHECK_SH7751_PCIIO(port) (0)
+#endif
+
+/*
+ * General outline: remap really low stuff [eventually] to SuperIO,
+ * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
+ * is mapped through the PCI IO window.  Stuff with high bits (PXSEG)
+ * should be way beyond the window, and is used  w/o translation for
+ * compatibility.
+ */
+
+unsigned char snapgear_inb(unsigned long port)
+{
+	if (PXSEG(port))
+		return *(volatile unsigned char *)port;
+	else if (CHECK_SH7751_PCIIO(port))
+		return *(volatile unsigned char *)PCI_IOMAP(port);
+	else
+		return (*port2adr(port))&0xff; 
+}
+
+
+unsigned char snapgear_inb_p(unsigned long port)
+{
+	unsigned char v;
+
+	if (PXSEG(port))
+		v = *(volatile unsigned char *)port;
+	else if (CHECK_SH7751_PCIIO(port))
+		v = *(volatile unsigned char *)PCI_IOMAP(port);
+	else
+		v = (*port2adr(port))&0xff; 
+	delay();
+	return v;
+}
+
+
+unsigned short snapgear_inw(unsigned long port)
+{
+	if (PXSEG(port))
+		return *(volatile unsigned short *)port;
+	else if (CHECK_SH7751_PCIIO(port))
+		return *(volatile unsigned short *)PCI_IOMAP(port);
+	else if (port >= 0x2000)
+		return *port2adr(port);
+	else
+		maybebadio(inw, port);
+	return 0;
+}
+
+
+unsigned int snapgear_inl(unsigned long port)
+{
+	if (PXSEG(port))
+		return *(volatile unsigned long *)port;
+	else if (CHECK_SH7751_PCIIO(port))
+		return *(volatile unsigned int *)PCI_IOMAP(port);
+	else if (port >= 0x2000)
+		return *port2adr(port);
+	else
+		maybebadio(inl, port);
+	return 0;
+}
+
+
+void snapgear_outb(unsigned char value, unsigned long port)
+{
+
+	if (PXSEG(port))
+		*(volatile unsigned char *)port = value;
+	else if (CHECK_SH7751_PCIIO(port))
+		*((unsigned char*)PCI_IOMAP(port)) = value;
+	else
+		*(port2adr(port)) = value;
+}
+
+
+void snapgear_outb_p(unsigned char value, unsigned long port)
+{
+	if (PXSEG(port))
+		*(volatile unsigned char *)port = value;
+	else if (CHECK_SH7751_PCIIO(port))
+		*((unsigned char*)PCI_IOMAP(port)) = value;
+	else
+		*(port2adr(port)) = value;
+	delay();
+}
+
+
+void snapgear_outw(unsigned short value, unsigned long port)
+{
+	if (PXSEG(port))
+		*(volatile unsigned short *)port = value;
+	else if (CHECK_SH7751_PCIIO(port))
+		*((unsigned short *)PCI_IOMAP(port)) = value;
+	else if (port >= 0x2000)
+		*port2adr(port) = value;
+	else
+		maybebadio(outw, port);
+}
+
+
+void snapgear_outl(unsigned int value, unsigned long port)
+{
+	if (PXSEG(port))
+		*(volatile unsigned long *)port = value;
+	else if (CHECK_SH7751_PCIIO(port))
+		*((unsigned long*)PCI_IOMAP(port)) = value;
+	else
+		maybebadio(outl, port);
+}
+
+void snapgear_insl(unsigned long port, void *addr, unsigned long count)
+{
+	maybebadio(insl, port);
+}
+
+void snapgear_outsl(unsigned long port, const void *addr, unsigned long count)
+{
+	maybebadio(outsw, port);
+}
+
+/* Map ISA bus address to the real address. Only for PCMCIA.  */
+
+
+/* ISA page descriptor.  */
+static __u32 sh_isa_memmap[256];
+
+
+#if 0
+static int sh_isa_mmap(__u32 start, __u32 length, __u32 offset)
+{
+	int idx;
+
+	if (start >= 0x100000 || (start & 0xfff) || (length != 0x1000))
+		return -1;
+
+	idx = start >> 12;
+	sh_isa_memmap[idx] = 0xb8000000 + (offset &~ 0xfff);
+#if 0
+	printk("sh_isa_mmap: start %x len %x offset %x (idx %x paddr %x)\n",
+	       start, length, offset, idx, sh_isa_memmap[idx]);
+#endif
+	return 0;
+}
+#endif
+
+unsigned long snapgear_isa_port2addr(unsigned long offset)
+{
+	int idx;
+
+	idx = (offset >> 12) & 0xff;
+	offset &= 0xfff;
+	return sh_isa_memmap[idx] + offset;
+}
diff -puN /dev/null arch/sh/boards/snapgear/Makefile
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/boards/snapgear/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,10 @@
+#
+# Makefile for the SnapGear specific parts of the kernel
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+
+obj-y	 := setup.o io.o rtc.o
+
diff -puN /dev/null arch/sh/boards/snapgear/rtc.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/boards/snapgear/rtc.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,333 @@
+/****************************************************************************/
+/*
+ * linux/arch/sh/boards/snapgear/rtc.c -- Secureedge5410 RTC code
+ *
+ *  Copyright (C) 2002  David McCullough <davidm@snapgear.com>
+ *  Copyright (C) 2003  Paul Mundt <lethal@linux-sh.org>
+ *
+ * The SecureEdge5410 can have one of 2 real time clocks, the SH
+ * built in version or the preferred external DS1302.  Here we work out
+ * each to see what we have and then run with it.
+ */
+/****************************************************************************/
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/time.h>
+#include <linux/rtc.h>
+#include <linux/mc146818rtc.h>
+
+#include <asm/io.h>
+#include <asm/rtc.h>
+#include <asm/mc146818rtc.h>
+
+/****************************************************************************/
+
+static int use_ds1302 = 0;
+
+/****************************************************************************/
+/*
+ *	we need to implement a DS1302 driver here that can operate in
+ *	conjunction with the builtin rtc driver which is already quite friendly
+ */
+/*****************************************************************************/
+
+#define	RTC_CMD_READ	0x81		/* Read command */
+#define	RTC_CMD_WRITE	0x80		/* Write command */
+
+#define	RTC_ADDR_YEAR	0x06		/* Address of year register */
+#define	RTC_ADDR_DAY	0x05		/* Address of day of week register */
+#define	RTC_ADDR_MON	0x04		/* Address of month register */
+#define	RTC_ADDR_DATE	0x03		/* Address of day of month register */
+#define	RTC_ADDR_HOUR	0x02		/* Address of hour register */
+#define	RTC_ADDR_MIN	0x01		/* Address of minute register */
+#define	RTC_ADDR_SEC	0x00		/* Address of second register */
+
+#define	RTC_RESET	0x1000
+#define	RTC_IODATA	0x0800
+#define	RTC_SCLK	0x0400
+
+#define set_dirp(x)
+#define get_dirp(x) 0
+#define set_dp(x)	SECUREEDGE_WRITE_IOPORT(x, 0x1c00)
+#define get_dp(x)	SECUREEDGE_READ_IOPORT()
+
+static void ds1302_sendbits(unsigned int val)
+{
+	int	i;
+
+	for (i = 8; (i); i--, val >>= 1) {
+		set_dp((get_dp() & ~RTC_IODATA) | ((val & 0x1) ? RTC_IODATA : 0));
+		set_dp(get_dp() | RTC_SCLK);	// clock high
+		set_dp(get_dp() & ~RTC_SCLK);	// clock low
+	}
+}
+
+static unsigned int ds1302_recvbits(void)
+{
+	unsigned int	val;
+	int		i;
+
+	for (i = 0, val = 0; (i < 8); i++) {
+		val |= (((get_dp() & RTC_IODATA) ? 1 : 0) << i);
+		set_dp(get_dp() | RTC_SCLK);	// clock high
+		set_dp(get_dp() & ~RTC_SCLK);	// clock low
+	}
+	return(val);
+}
+
+static unsigned int ds1302_readbyte(unsigned int addr)
+{
+	unsigned int	val;
+	unsigned long	flags;
+
+#if 0
+	printk("SnapGear RTC: ds1302_readbyte(addr=%x)\n", addr);
+#endif
+
+	local_irq_save(flags);
+	set_dirp(get_dirp() | RTC_RESET | RTC_IODATA | RTC_SCLK);
+	set_dp(get_dp() & ~(RTC_RESET | RTC_IODATA | RTC_SCLK));
+
+	set_dp(get_dp() | RTC_RESET);
+	ds1302_sendbits(((addr & 0x3f) << 1) | RTC_CMD_READ);
+	set_dirp(get_dirp() & ~RTC_IODATA);
+	val = ds1302_recvbits();
+	set_dp(get_dp() & ~RTC_RESET);
+	local_irq_restore(flags);
+
+	return(val);
+}
+
+static void ds1302_writebyte(unsigned int addr, unsigned int val)
+{
+	unsigned long	flags;
+
+#if 0
+	printk("SnapGear RTC: ds1302_writebyte(addr=%x)\n", addr);
+#endif
+
+	local_irq_save(flags);
+	set_dirp(get_dirp() | RTC_RESET | RTC_IODATA | RTC_SCLK);
+	set_dp(get_dp() & ~(RTC_RESET | RTC_IODATA | RTC_SCLK));
+	set_dp(get_dp() | RTC_RESET);
+	ds1302_sendbits(((addr & 0x3f) << 1) | RTC_CMD_WRITE);
+	ds1302_sendbits(val);
+	set_dp(get_dp() & ~RTC_RESET);
+	local_irq_restore(flags);
+}
+
+static void ds1302_reset(void)
+{
+	unsigned long	flags;
+	/* Hardware dependant reset/init */
+	local_irq_save(flags);
+	set_dirp(get_dirp() | RTC_RESET | RTC_IODATA | RTC_SCLK);
+	set_dp(get_dp() & ~(RTC_RESET | RTC_IODATA | RTC_SCLK));
+	local_irq_restore(flags);
+}
+
+/*****************************************************************************/
+
+static inline int bcd2int(int val)
+{
+	return((((val & 0xf0) >> 4) * 10) + (val & 0xf));
+}
+
+static inline int int2bcd(int val)
+{
+	return(((val / 10) << 4) + (val % 10));
+}
+
+/*****************************************************************************/
+/*
+ *	Write and Read some RAM in the DS1302,  if it works assume it's there
+ *	Otherwise use the SH4 internal RTC
+ */
+
+void snapgear_rtc_gettimeofday(struct timespec *);
+int snapgear_rtc_settimeofday(const time_t);
+
+void __init secureedge5410_rtc_init(void)
+{
+	unsigned char *test = "snapgear";
+	int i;
+
+	ds1302_reset();
+
+	use_ds1302 = 1;
+
+	for (i = 0; test[i]; i++)
+		ds1302_writebyte(32 + i, test[i]);
+
+	for (i = 0; test[i]; i++)
+		if (ds1302_readbyte(32 + i) != test[i]) {
+			use_ds1302 = 0;
+			break;
+		}
+
+	if (use_ds1302) {
+		rtc_get_time = snapgear_rtc_gettimeofday;
+		rtc_set_time = snapgear_rtc_settimeofday;
+	} else {
+		rtc_get_time = sh_rtc_gettimeofday;
+		rtc_set_time = sh_rtc_settimeofday;
+	}
+		
+	printk("SnapGear RTC: using %s rtc.\n", use_ds1302 ? "ds1302" : "internal");
+}
+
+/****************************************************************************/
+/*
+ *	our generic interface that chooses the correct code to use
+ */
+
+void snapgear_rtc_gettimeofday(struct timespec *ts)
+{
+	unsigned int sec, min, hr, day, mon, yr;
+
+	if (!use_ds1302) {
+		sh_rtc_gettimeofday(ts);
+		return;
+	}
+
+ 	sec = bcd2int(ds1302_readbyte(RTC_ADDR_SEC));
+ 	min = bcd2int(ds1302_readbyte(RTC_ADDR_MIN));
+ 	hr  = bcd2int(ds1302_readbyte(RTC_ADDR_HOUR));
+ 	day = bcd2int(ds1302_readbyte(RTC_ADDR_DATE));
+ 	mon = bcd2int(ds1302_readbyte(RTC_ADDR_MON));
+ 	yr  = bcd2int(ds1302_readbyte(RTC_ADDR_YEAR));
+
+bad_time:
+	if (yr > 99 || mon < 1 || mon > 12 || day > 31 || day < 1 ||
+	    hr > 23 || min > 59 || sec > 59) {
+		printk(KERN_ERR
+		       "SnapGear RTC: invalid value, resetting to 1 Jan 2000\n");
+		ds1302_writebyte(RTC_ADDR_MIN,  min = 0);
+		ds1302_writebyte(RTC_ADDR_HOUR, hr  = 0);
+		ds1302_writebyte(RTC_ADDR_DAY,        7);
+		ds1302_writebyte(RTC_ADDR_DATE, day = 1);
+		ds1302_writebyte(RTC_ADDR_MON,  mon = 1);
+		ds1302_writebyte(RTC_ADDR_YEAR, yr  = 0);
+		ds1302_writebyte(RTC_ADDR_SEC,  sec = 0);
+	}
+
+	ts->tv_sec = mktime(2000 + yr, mon, day, hr, min, sec);
+	if (ts->tv_sec < 0) {
+#if 0
+		printk("BAD TIME %d %d %d %d %d %d\n", yr, mon, day, hr, min, sec);
+#endif
+		yr = 100;
+		goto bad_time;
+	}
+	ts->tv_nsec = 0;
+}
+
+int snapgear_rtc_settimeofday(const time_t secs)
+{
+	int retval = 0;
+	int real_seconds, real_minutes, cmos_minutes;
+	unsigned long nowtime;
+
+	if (!use_ds1302)
+		return sh_rtc_settimeofday(secs);
+
+/*
+ *	This is called direct from the kernel timer handling code.
+ *	It is supposed to synchronize the kernel clock to the RTC.
+ */
+
+	nowtime = secs;
+
+#if 1
+	printk("SnapGear RTC: snapgear_rtc_settimeofday(nowtime=%ld)\n", nowtime);
+#endif
+
+	/* STOP RTC */
+	ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) | 0x80);
+
+	cmos_minutes = bcd2int(ds1302_readbyte(RTC_ADDR_MIN));
+
+	/*
+	 * since we're only adjusting minutes and seconds,
+	 * don't interfere with hour overflow. This avoids
+	 * messing with unknown time zones but requires your
+	 * RTC not to be off by more than 15 minutes
+	 */
+	real_seconds = nowtime % 60;
+	real_minutes = nowtime / 60;
+	if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1)
+		real_minutes += 30;	/* correct for half hour time zone */
+	real_minutes %= 60;
+
+	if (abs(real_minutes - cmos_minutes) < 30) {
+		ds1302_writebyte(RTC_ADDR_MIN, int2bcd(real_minutes));
+		ds1302_writebyte(RTC_ADDR_SEC, int2bcd(real_seconds));
+	} else {
+		printk(KERN_WARNING
+		       "SnapGear RTC: can't update from %d to %d\n",
+		       cmos_minutes, real_minutes);
+		retval = -1;
+	}
+
+	/* START RTC */
+	ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) & ~0x80);
+	return(0);
+}
+
+unsigned char secureedge5410_cmos_read(int addr)
+{
+	unsigned char val = 0;
+
+	if (!use_ds1302)
+		return(__CMOS_READ(addr, w));
+
+	switch(addr) {
+	case RTC_SECONDS:       val = ds1302_readbyte(RTC_ADDR_SEC);  break;
+	case RTC_SECONDS_ALARM:                                       break;
+	case RTC_MINUTES:       val = ds1302_readbyte(RTC_ADDR_MIN);  break;
+	case RTC_MINUTES_ALARM:                                       break;
+	case RTC_HOURS:         val = ds1302_readbyte(RTC_ADDR_HOUR); break;
+	case RTC_HOURS_ALARM:                                         break;
+	case RTC_DAY_OF_WEEK:   val = ds1302_readbyte(RTC_ADDR_DAY);  break;
+	case RTC_DAY_OF_MONTH:  val = ds1302_readbyte(RTC_ADDR_DATE); break;
+	case RTC_MONTH:         val = ds1302_readbyte(RTC_ADDR_MON);  break;
+	case RTC_YEAR:          val = ds1302_readbyte(RTC_ADDR_YEAR); break;
+	case RTC_REG_A:         /* RTC_FREQ_SELECT */                 break;
+	case RTC_REG_B:	        /* RTC_CONTROL */                     break;
+	case RTC_REG_C:	        /* RTC_INTR_FLAGS */                  break;
+	case RTC_REG_D:         val = RTC_VRT /* RTC_VALID */;        break;
+	default:                                                      break;
+	}
+
+	return(val);
+}
+
+void secureedge5410_cmos_write(unsigned char val, int addr)
+{
+	if (!use_ds1302) {
+		__CMOS_WRITE(val, addr, w);
+		return;
+	}
+
+	switch(addr) {
+	case RTC_SECONDS:       ds1302_writebyte(RTC_ADDR_SEC, val);  break;
+	case RTC_SECONDS_ALARM:                                       break;
+	case RTC_MINUTES:       ds1302_writebyte(RTC_ADDR_MIN, val);  break;
+	case RTC_MINUTES_ALARM:                                       break;
+	case RTC_HOURS:         ds1302_writebyte(RTC_ADDR_HOUR, val); break;
+	case RTC_HOURS_ALARM:                                         break;
+	case RTC_DAY_OF_WEEK:   ds1302_writebyte(RTC_ADDR_DAY, val);  break;
+	case RTC_DAY_OF_MONTH:  ds1302_writebyte(RTC_ADDR_DATE, val); break;
+	case RTC_MONTH:         ds1302_writebyte(RTC_ADDR_MON, val);  break;
+	case RTC_YEAR:          ds1302_writebyte(RTC_ADDR_YEAR, val); break;
+	case RTC_REG_A:         /* RTC_FREQ_SELECT */                 break;
+	case RTC_REG_B:        	/* RTC_CONTROL */                     break;
+	case RTC_REG_C:	        /* RTC_INTR_FLAGS */                  break;
+	case RTC_REG_D:	        /* RTC_VALID */                       break;
+	default:                                                      break;
+	}
+}
+
+/****************************************************************************/
diff -puN /dev/null arch/sh/boards/snapgear/setup.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/boards/snapgear/setup.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,220 @@
+/****************************************************************************/
+/* 
+ * linux/arch/sh/boards/snapgear/setup.c
+ *
+ * Copyright (C) 2002  David McCullough <davidm@snapgear.com>
+ * Copyright (C) 2003  Paul Mundt <lethal@linux-sh.org>
+ *
+ * Based on files with the following comments:
+ *
+ *           Copyright (C) 2000  Kazumoto Kojima
+ *
+ *           Modified for 7751 Solution Engine by
+ *           Ian da Silva and Jeremy Siegel, 2001.
+ */
+/****************************************************************************/
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/timer.h>
+#include <linux/delay.h>
+#include <linux/module.h>
+#include <linux/sched.h>
+
+#include <asm/machvec.h>
+#include <asm/mach/io.h>
+#include <asm/irq.h>
+#include <asm/io.h>
+
+extern void (*board_time_init)(void);
+extern void secureedge5410_rtc_init(void);
+extern void pcibios_init(void);
+
+/****************************************************************************/
+/*
+ * EraseConfig handling functions
+ */
+
+static irqreturn_t eraseconfig_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+	volatile char dummy __attribute__((unused)) = * (volatile char *) 0xb8000000;
+
+	printk("SnapGear: erase switch interrupt!\n");
+
+	return IRQ_HANDLED;
+}
+
+static int __init eraseconfig_init(void)
+{
+	printk("SnapGear: EraseConfig init\n");
+	/* Setup "EraseConfig" switch on external IRQ 0 */
+	if (request_irq(IRL0_IRQ, eraseconfig_interrupt, SA_INTERRUPT,
+				"Erase Config", NULL))
+		printk("SnapGear: failed to register IRQ%d for Reset witch\n",
+				IRL0_IRQ);
+	else
+		printk("SnapGear: registered EraseConfig switch on IRQ%d\n",
+				IRL0_IRQ);
+	return(0);
+}
+
+module_init(eraseconfig_init);
+
+/****************************************************************************/
+/*
+ * Initialize IRQ setting
+ *
+ * IRL0 = erase switch
+ * IRL1 = eth0
+ * IRL2 = eth1
+ * IRL3 = crypto
+ */
+
+static void __init init_snapgear_IRQ(void)
+{
+	/* enable individual interrupt mode for externals */
+	ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
+
+	printk("Setup SnapGear IRQ/IPR ...\n");
+
+	make_ipr_irq(IRL0_IRQ, IRL0_IPR_ADDR, IRL0_IPR_POS, IRL0_PRIORITY);
+	make_ipr_irq(IRL1_IRQ, IRL1_IPR_ADDR, IRL1_IPR_POS, IRL1_PRIORITY);
+	make_ipr_irq(IRL2_IRQ, IRL2_IPR_ADDR, IRL2_IPR_POS, IRL2_PRIORITY);
+	make_ipr_irq(IRL3_IRQ, IRL3_IPR_ADDR, IRL3_IPR_POS, IRL3_PRIORITY);
+}
+
+/****************************************************************************/
+/*
+ *	Fast poll interrupt simulator.
+ */
+
+/*
+ * Leave all of the fast timer/fast poll stuff commented out for now, since
+ * it's not clear whether it actually works or not. Since it wasn't being used
+ * at all in 2.4, we'll assume it's not sane for 2.6 either.. -- PFM
+ */
+#if 0
+#define FAST_POLL	1000
+//#define FAST_POLL_INTR
+
+#define FASTTIMER_IRQ   17
+#define FASTTIMER_IPR_ADDR  INTC_IPRA
+#define FASTTIMER_IPR_POS    2
+#define FASTTIMER_PRIORITY   3
+
+#ifdef FAST_POLL_INTR
+#define TMU1_TCR_INIT	0x0020
+#else
+#define TMU1_TCR_INIT	0
+#endif
+#define TMU_TSTR_INIT	1
+#define TMU1_TCR_CALIB	0x0000
+#define TMU_TOCR	0xffd80000	/* Byte access */
+#define TMU_TSTR	0xffd80004	/* Byte access */
+#define TMU1_TCOR	0xffd80014	/* Long access */
+#define TMU1_TCNT	0xffd80018	/* Long access */
+#define TMU1_TCR	0xffd8001c	/* Word access */
+
+
+#ifdef FAST_POLL_INTR
+static void fast_timer_irq(int irq, void *dev_instance, struct pt_regs *regs)
+{
+	unsigned long timer_status;
+    timer_status = ctrl_inw(TMU1_TCR);
+	timer_status &= ~0x100;
+	ctrl_outw(timer_status, TMU1_TCR);
+}
+#endif
+
+/*
+ * return the current ticks on the fast timer
+ */
+
+unsigned long fast_timer_count(void)
+{
+	return(ctrl_inl(TMU1_TCNT));
+}
+
+/*
+ * setup a fast timer for profiling etc etc
+ */
+
+static void setup_fast_timer()
+{
+	unsigned long interval;
+
+#ifdef FAST_POLL_INTR
+	interval = (current_cpu_data.module_clock/4 + FAST_POLL/2) / FAST_POLL;
+
+	make_ipr_irq(FASTTIMER_IRQ, FASTTIMER_IPR_ADDR, FASTTIMER_IPR_POS,
+			FASTTIMER_PRIORITY);
+
+	printk("SnapGear: %dHz fast timer on IRQ %d\n",FAST_POLL,FASTTIMER_IRQ);
+
+	if (request_irq(FASTTIMER_IRQ, fast_timer_irq, 0, "SnapGear fast timer",
+			NULL) != 0)
+		printk("%s(%d): request_irq() failed?\n", __FILE__, __LINE__);
+#else
+	printk("SnapGear: fast timer running\n",FAST_POLL,FASTTIMER_IRQ);
+	interval = 0xffffffff;
+#endif
+
+	ctrl_outb(ctrl_inb(TMU_TSTR) & ~0x2, TMU_TSTR); /* disable timer 1 */
+	ctrl_outw(TMU1_TCR_INIT, TMU1_TCR);
+	ctrl_outl(interval, TMU1_TCOR);
+	ctrl_outl(interval, TMU1_TCNT);
+	ctrl_outb(ctrl_inb(TMU_TSTR) | 0x2, TMU_TSTR); /* enable timer 1 */
+
+	printk("Timer count 1 = 0x%x\n", fast_timer_count());
+	udelay(1000);
+	printk("Timer count 2 = 0x%x\n", fast_timer_count());
+}
+#endif
+
+/****************************************************************************/
+
+const char *get_system_type(void)
+{
+	return "SnapGear SecureEdge5410";
+}
+
+/*
+ * The Machine Vector
+ */
+
+struct sh_machine_vector mv_snapgear __initmv = {
+	.mv_nr_irqs		= 72,
+
+	.mv_inb			= snapgear_inb,
+	.mv_inw			= snapgear_inw,
+	.mv_inl			= snapgear_inl,
+	.mv_outb		= snapgear_outb,
+	.mv_outw		= snapgear_outw,
+	.mv_outl		= snapgear_outl,
+
+	.mv_inb_p		= snapgear_inb_p,
+	.mv_inw_p		= snapgear_inw,
+	.mv_inl_p		= snapgear_inl,
+	.mv_outb_p		= snapgear_outb_p,
+	.mv_outw_p		= snapgear_outw,
+	.mv_outl_p		= snapgear_outl,
+
+	.mv_isa_port2addr	= snapgear_isa_port2addr,
+
+	.mv_init_irq		= init_snapgear_IRQ,
+};
+ALIAS_MV(snapgear)
+
+/*
+ * Initialize the board
+ */
+
+int __init platform_setup(void)
+{
+	board_time_init = secureedge5410_rtc_init;
+
+	return 0;
+}
+
diff -puN /dev/null arch/sh/boards/systemh/io.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/boards/systemh/io.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,283 @@
+/* 
+ * linux/arch/sh/boards/systemh/io.c
+ *
+ * Copyright (C) 2001  Ian da Silva, Jeremy Siegel
+ * Based largely on io_se.c.
+ *
+ * I/O routine for Hitachi 7751 Systemh.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <asm/systemh/7751systemh.h>
+#include <asm/addrspace.h>
+#include <asm/io.h>
+
+#include <linux/pci.h>
+#include "../../drivers/pci/pci-sh7751.h"
+
+/*
+ * The 7751 SystemH Engine uses the built-in PCI controller (PCIC)
+ * of the 7751 processor, and has a SuperIO accessible on its memory 
+ * bus.
+ */ 
+
+#define PCIIOBR		(volatile long *)PCI_REG(SH7751_PCIIOBR)
+#define PCIMBR          (volatile long *)PCI_REG(SH7751_PCIMBR)
+#define PCI_IO_AREA	SH7751_PCI_IO_BASE
+#define PCI_MEM_AREA	SH7751_PCI_CONFIG_BASE
+
+#define PCI_IOMAP(adr)	(PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK))
+#define ETHER_IOMAP(adr) (0xB3000000 + (adr)) /*map to 16bits access area
+                                                of smc lan chip*/ 
+
+#define maybebadio(name,port) \
+  printk("bad PC-like io %s for port 0x%lx at 0x%08x\n", \
+	 #name, (port), (__u32) __builtin_return_address(0))
+
+static inline void delay(void)
+{
+	ctrl_inw(0xa0000000);
+}
+
+static inline volatile __u16 *
+port2adr(unsigned int port)
+{
+	if (port >= 0x2000)
+		return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
+#if 0
+	else
+		return (volatile __u16 *) (PA_SUPERIO + (port << 1));
+#endif
+	maybebadio(name,(unsigned long)port);
+	return (volatile __u16*)port;
+}
+
+/* In case someone configures the kernel w/o PCI support: in that */
+/* scenario, don't ever bother to check for PCI-window addresses */
+
+/* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */
+#if defined(CONFIG_PCI)
+#define CHECK_SH7751_PCIIO(port) \
+  ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE)))
+#else
+#define CHECK_SH7751_PCIIO(port) (0)
+#endif
+
+/*
+ * General outline: remap really low stuff [eventually] to SuperIO,
+ * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
+ * is mapped through the PCI IO window.  Stuff with high bits (PXSEG)
+ * should be way beyond the window, and is used  w/o translation for
+ * compatibility.
+ */
+unsigned char sh7751systemh_inb(unsigned long port)
+{
+	if (PXSEG(port))
+		return *(volatile unsigned char *)port;
+	else if (CHECK_SH7751_PCIIO(port))
+		return *(volatile unsigned char *)PCI_IOMAP(port);
+	else if (port <= 0x3F1)
+		return *(volatile unsigned char *)ETHER_IOMAP(port);
+	else
+		return (*port2adr(port))&0xff; 
+}
+
+unsigned char sh7751systemh_inb_p(unsigned long port)
+{
+	unsigned char v;
+
+        if (PXSEG(port))
+                v = *(volatile unsigned char *)port;
+	else if (CHECK_SH7751_PCIIO(port))
+                v = *(volatile unsigned char *)PCI_IOMAP(port);
+	else if (port <= 0x3F1)
+		v = *(volatile unsigned char *)ETHER_IOMAP(port);
+	else
+		v = (*port2adr(port))&0xff; 
+	delay();
+	return v;
+}
+
+unsigned short sh7751systemh_inw(unsigned long port)
+{
+        if (PXSEG(port))
+                return *(volatile unsigned short *)port;
+	else if (CHECK_SH7751_PCIIO(port))
+                return *(volatile unsigned short *)PCI_IOMAP(port);
+	else if (port >= 0x2000)
+		return *port2adr(port);
+	else if (port <= 0x3F1)
+		return *(volatile unsigned int *)ETHER_IOMAP(port);
+	else
+		maybebadio(inw, port);
+	return 0;
+}
+
+unsigned int sh7751systemh_inl(unsigned long port)
+{
+        if (PXSEG(port))
+                return *(volatile unsigned long *)port;
+	else if (CHECK_SH7751_PCIIO(port))
+                return *(volatile unsigned int *)PCI_IOMAP(port);
+	else if (port >= 0x2000)
+		return *port2adr(port);
+	else if (port <= 0x3F1)
+		return *(volatile unsigned int *)ETHER_IOMAP(port);
+	else
+		maybebadio(inl, port);
+	return 0;
+}
+
+void sh7751systemh_outb(unsigned char value, unsigned long port)
+{
+
+        if (PXSEG(port))
+                *(volatile unsigned char *)port = value;
+	else if (CHECK_SH7751_PCIIO(port))
+        	*((unsigned char*)PCI_IOMAP(port)) = value;
+	else if (port <= 0x3F1)
+		*(volatile unsigned char *)ETHER_IOMAP(port) = value;
+	else
+		*(port2adr(port)) = value;
+}
+
+void sh7751systemh_outb_p(unsigned char value, unsigned long port)
+{
+        if (PXSEG(port))
+                *(volatile unsigned char *)port = value;
+	else if (CHECK_SH7751_PCIIO(port))
+        	*((unsigned char*)PCI_IOMAP(port)) = value;
+	else if (port <= 0x3F1)
+		*(volatile unsigned char *)ETHER_IOMAP(port) = value;
+	else
+		*(port2adr(port)) = value;
+	delay();
+}
+
+void sh7751systemh_outw(unsigned short value, unsigned long port)
+{
+        if (PXSEG(port))
+                *(volatile unsigned short *)port = value;
+	else if (CHECK_SH7751_PCIIO(port))
+        	*((unsigned short *)PCI_IOMAP(port)) = value;
+	else if (port >= 0x2000)
+		*port2adr(port) = value;
+	else if (port <= 0x3F1)
+		*(volatile unsigned short *)ETHER_IOMAP(port) = value;
+	else
+		maybebadio(outw, port);
+}
+
+void sh7751systemh_outl(unsigned int value, unsigned long port)
+{
+        if (PXSEG(port))
+                *(volatile unsigned long *)port = value;
+	else if (CHECK_SH7751_PCIIO(port))
+        	*((unsigned long*)PCI_IOMAP(port)) = value;
+	else
+		maybebadio(outl, port);
+}
+
+void sh7751systemh_insb(unsigned long port, void *addr, unsigned long count)
+{
+	unsigned char *p = addr;
+	while (count--) *p++ = sh7751systemh_inb(port);
+}
+
+void sh7751systemh_insw(unsigned long port, void *addr, unsigned long count)
+{
+	unsigned short *p = addr;
+	while (count--) *p++ = sh7751systemh_inw(port);
+}
+
+void sh7751systemh_insl(unsigned long port, void *addr, unsigned long count)
+{
+	maybebadio(insl, port);
+}
+
+void sh7751systemh_outsb(unsigned long port, const void *addr, unsigned long count)
+{
+	unsigned char *p = (unsigned char*)addr;
+	while (count--) sh7751systemh_outb(*p++, port);
+}
+
+void sh7751systemh_outsw(unsigned long port, const void *addr, unsigned long count)
+{
+	unsigned short *p = (unsigned short*)addr;
+	while (count--) sh7751systemh_outw(*p++, port);
+}
+
+void sh7751systemh_outsl(unsigned long port, const void *addr, unsigned long count)
+{
+	maybebadio(outsw, port);
+}
+
+/* For read/write calls, just copy generic (pass-thru); PCIMBR is  */
+/* already set up.  For a larger memory space, these would need to */
+/* reset PCIMBR as needed on a per-call basis...                   */
+
+unsigned char sh7751systemh_readb(unsigned long addr)
+{
+	return *(volatile unsigned char*)addr;
+}
+
+unsigned short sh7751systemh_readw(unsigned long addr)
+{
+	return *(volatile unsigned short*)addr;
+}
+
+unsigned int sh7751systemh_readl(unsigned long addr)
+{
+	return *(volatile unsigned long*)addr;
+}
+
+void sh7751systemh_writeb(unsigned char b, unsigned long addr)
+{
+	*(volatile unsigned char*)addr = b;
+}
+
+void sh7751systemh_writew(unsigned short b, unsigned long addr)
+{
+	*(volatile unsigned short*)addr = b;
+}
+
+void sh7751systemh_writel(unsigned int b, unsigned long addr)
+{
+        *(volatile unsigned long*)addr = b;
+}
+
+
+
+/* Map ISA bus address to the real address. Only for PCMCIA.  */
+
+/* ISA page descriptor.  */
+static __u32 sh_isa_memmap[256];
+
+#if 0
+static int
+sh_isa_mmap(__u32 start, __u32 length, __u32 offset)
+{
+	int idx;
+
+	if (start >= 0x100000 || (start & 0xfff) || (length != 0x1000))
+		return -1;
+
+	idx = start >> 12;
+	sh_isa_memmap[idx] = 0xb8000000 + (offset &~ 0xfff);
+	printk("sh_isa_mmap: start %x len %x offset %x (idx %x paddr %x)\n",
+	       start, length, offset, idx, sh_isa_memmap[idx]);
+	return 0;
+}
+#endif
+
+unsigned long
+sh7751systemh_isa_port2addr(unsigned long offset)
+{
+	int idx;
+
+	idx = (offset >> 12) & 0xff;
+	offset &= 0xfff;
+	return sh_isa_memmap[idx] + offset;
+}
diff -puN /dev/null arch/sh/boards/systemh/irq.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/boards/systemh/irq.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,111 @@
+/* 
+ * linux/arch/sh/boards/systemh/irq.c
+ *
+ * Copyright (C) 2000  Kazumoto Kojima
+ *
+ * Hitachi SystemH Support.
+ *
+ * Modified for 7751 SystemH by
+ * Jonathan Short.
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+
+#include <linux/hdreg.h>
+#include <linux/ide.h>
+#include <asm/io.h>
+#include <asm/mach/7751systemh.h>
+#include <asm/smc37c93x.h>
+
+/* address of external interrupt mask register
+ * address must be set prior to use these (maybe in init_XXX_irq())
+ * XXX : is it better to use .config than specifying it in code? */
+static unsigned long *systemh_irq_mask_register = (unsigned long *)0xB3F10004;
+static unsigned long *systemh_irq_request_register = (unsigned long *)0xB3F10000;
+
+/* forward declaration */
+static unsigned int startup_systemh_irq(unsigned int irq);
+static void shutdown_systemh_irq(unsigned int irq);
+static void enable_systemh_irq(unsigned int irq);
+static void disable_systemh_irq(unsigned int irq);
+static void mask_and_ack_systemh(unsigned int);
+static void end_systemh_irq(unsigned int irq);
+
+/* hw_interrupt_type */
+static struct hw_interrupt_type systemh_irq_type = {
+	" SystemH Register",
+	startup_systemh_irq,
+	shutdown_systemh_irq,
+	enable_systemh_irq,
+	disable_systemh_irq,
+	mask_and_ack_systemh,
+	end_systemh_irq
+};
+
+static unsigned int startup_systemh_irq(unsigned int irq)
+{ 
+	enable_systemh_irq(irq);
+	return 0; /* never anything pending */
+}
+
+static void shutdown_systemh_irq(unsigned int irq)
+{
+	disable_systemh_irq(irq);
+}
+
+static void disable_systemh_irq(unsigned int irq)
+{
+	if (systemh_irq_mask_register) {
+		unsigned long flags;
+		unsigned long val, mask = 0x01 << 1;
+
+		/* Clear the "irq"th bit in the mask and set it in the request */
+		local_irq_save(flags);
+
+		val = ctrl_inl((unsigned long)systemh_irq_mask_register);
+		val &= ~mask;
+		ctrl_outl(val, (unsigned long)systemh_irq_mask_register);
+
+		val = ctrl_inl((unsigned long)systemh_irq_request_register);
+		val |= mask;
+		ctrl_outl(val, (unsigned long)systemh_irq_request_register);
+
+		local_irq_restore(flags);
+	}
+}
+
+static void enable_systemh_irq(unsigned int irq)
+{
+	if (systemh_irq_mask_register) {
+		unsigned long flags;
+		unsigned long val, mask = 0x01 << 1;
+
+		/* Set "irq"th bit in the mask register */
+		local_irq_save(flags);
+		val = ctrl_inl((unsigned long)systemh_irq_mask_register);
+		val |= mask;
+		ctrl_outl(val, (unsigned long)systemh_irq_mask_register);
+		local_irq_restore(flags);
+	}
+}
+
+static void mask_and_ack_systemh(unsigned int irq)
+{
+	disable_systemh_irq(irq);
+}
+
+static void end_systemh_irq(unsigned int irq)
+{
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_systemh_irq(irq);
+}
+
+void make_systemh_irq(unsigned int irq)
+{
+	disable_irq_nosync(irq);
+	irq_desc[irq].handler = &systemh_irq_type;
+	disable_systemh_irq(irq);
+}
+
diff -puN /dev/null arch/sh/boards/systemh/Makefile
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/boards/systemh/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,17 @@
+#
+# Makefile for the SystemH specific parts of the kernel
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+
+obj-y	 := setup.o irq.o io.o
+
+# XXX: This wants to be consolidated in arch/sh/drivers/pci, and more
+# importantly, with the generic sh7751_pcic_init() code. For now, we'll
+# just abuse the hell out of kbuild, because we can..
+
+obj-$(CONFIG_PCI) += pci.o
+pci-y := ../se/7751/pci.o
+
diff -puN /dev/null arch/sh/boards/systemh/setup.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/boards/systemh/setup.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,80 @@
+/* 
+ * linux/arch/sh/boards/systemh/setup.c
+ *
+ * Copyright (C) 2000  Kazumoto Kojima
+ * Copyright (C) 2003  Paul Mundt
+ *
+ * Hitachi SystemH Support.
+ *
+ * Modified for 7751 SystemH by Jonathan Short.
+ *
+ * Rewritten for 2.6 by Paul Mundt.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#include <linux/init.h>
+#include <asm/mach/7751systemh.h>
+#include <asm/mach/io.h>
+#include <asm/machvec.h>
+
+extern void make_systemh_irq(unsigned int irq);
+
+const char *get_system_type(void)
+{
+	return "7751 SystemH";
+}
+
+/*
+ * Initialize IRQ setting
+ */
+void __init init_7751systemh_IRQ(void)
+{
+/*  	make_ipr_irq(10, BCR_ILCRD, 1, 0x0f-10); LAN */
+/*  	make_ipr_irq(14, BCR_ILCRA, 2, 0x0f-4); */
+	make_systemh_irq(0xb);	/* Ethernet interrupt */
+}
+
+struct sh_machine_vector mv_7751systemh __initmv = {
+	.mv_nr_irqs		= 72,
+
+	.mv_inb			= sh7751systemh_inb,
+	.mv_inw			= sh7751systemh_inw,
+	.mv_inl			= sh7751systemh_inl,
+	.mv_outb		= sh7751systemh_outb,
+	.mv_outw		= sh7751systemh_outw,
+	.mv_outl		= sh7751systemh_outl,
+
+	.mv_inb_p		= sh7751systemh_inb_p,
+	.mv_inw_p		= sh7751systemh_inw,
+	.mv_inl_p		= sh7751systemh_inl,
+	.mv_outb_p		= sh7751systemh_outb_p,
+	.mv_outw_p		= sh7751systemh_outw,
+	.mv_outl_p		= sh7751systemh_outl,
+
+	.mv_insb		= sh7751systemh_insb,
+	.mv_insw		= sh7751systemh_insw,
+	.mv_insl		= sh7751systemh_insl,
+	.mv_outsb		= sh7751systemh_outsb,
+	.mv_outsw		= sh7751systemh_outsw,
+	.mv_outsl		= sh7751systemh_outsl,
+
+	.mv_readb		= sh7751systemh_readb,
+	.mv_readw		= sh7751systemh_readw,
+	.mv_readl		= sh7751systemh_readl,
+	.mv_writeb		= sh7751systemh_writeb,
+	.mv_writew		= sh7751systemh_writew,
+	.mv_writel		= sh7751systemh_writel,
+
+	.mv_isa_port2addr	= sh7751systemh_isa_port2addr,
+
+	.mv_init_irq		= init_7751systemh_IRQ,
+};
+ALIAS_MV(7751systemh)
+
+int __init platform_setup(void)
+{
+	return 0;
+}
+
diff -puN arch/sh/boot/compressed/head.S~linus arch/sh/boot/compressed/head.S
--- 25/arch/sh/boot/compressed/head.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boot/compressed/head.S	2004-01-19 22:17:21.000000000 -0800
@@ -2,10 +2,12 @@
  *  linux/arch/sh/boot/compressed/head.S
  *
  *  Copyright (C) 1999 Stuart Menefy
+ *  Copyright (C) 2003 SUGIOKA Toshinobu
  */
 
 .text
 
+#include <linux/config.h>
 #include <linux/linkage.h>
 
 	.global	startup
@@ -14,7 +16,54 @@ startup:
 	mov.l   init_sr, r1
 	ldc     r1, sr
 
-	/* First clear BSS */
+	/* Move myself to proper location if necessary */
+	mova	1f, r0
+	mov.l	1f, r2
+	cmp/eq	r2, r0
+	bt	clear_bss
+	sub	r0, r2
+	mov.l	bss_start_addr, r0
+	mov	#0xe0, r1
+	and	r1, r0			! align cache line
+	mov.l	text_start_addr, r3
+	mov	r0, r1
+	sub	r2, r1
+3:
+	mov.l	@r1, r4
+	mov.l	@(4,r1), r5
+	mov.l	@(8,r1), r6
+	mov.l	@(12,r1), r7
+	mov.l	@(16,r1), r8
+	mov.l	@(20,r1), r9
+	mov.l	@(24,r1), r10
+	mov.l	@(28,r1), r11
+	mov.l	r4, @r0
+	mov.l	r5, @(4,r0)
+	mov.l	r6, @(8,r0)
+	mov.l	r7, @(12,r0)
+	mov.l	r8, @(16,r0)
+	mov.l	r9, @(20,r0)
+	mov.l	r10, @(24,r0)
+	mov.l	r11, @(28,r0)
+#ifdef CONFIG_CPU_SH4
+	ocbwb	@r0
+#endif
+	cmp/hi	r3, r0
+	add	#-32, r0
+	bt/s	3b
+	 add	#-32, r1
+	mov.l	2f, r0
+	jmp	@r0
+	 nop
+
+	.align 2
+1:	.long	1b
+2:	.long	clear_bss
+text_start_addr:
+	.long	startup
+
+	/* Clear BSS */
+clear_bss:
 	mov.l	end_addr, r1
 	mov.l	bss_start_addr, r2
 	mov	#0, r0
diff -puN arch/sh/boot/compressed/Makefile~linus arch/sh/boot/compressed/Makefile
--- 25/arch/sh/boot/compressed/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/boot/compressed/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -16,9 +16,9 @@ endif
 #
 # IMAGE_OFFSET is the load offset of the compression loader
 #
-IMAGE_OFFSET = $(shell printf "0x%8x" $$[0x80000000+0x$(CONFIG_MEMORY_START)+0x200000+0x10000])
+IMAGE_OFFSET := $(shell printf "0x%8x" $$[0x80000000+$(CONFIG_MEMORY_START)+$(CONFIG_BOOT_LINK_OFFSET)])
 
-LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -e startup -T $(obj)/../../vmlinux.lds.s
+LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -e startup -T $(obj)/../../kernel/vmlinux.lds.s
 
 $(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o FORCE
 	$(call if_changed,ld)
diff -puN /dev/null arch/sh/boot/compressed/vmlinux.scr
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/boot/compressed/vmlinux.scr	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,9 @@
+SECTIONS
+{
+  .data : { 
+	input_len = .;
+	LONG(input_data_end - input_data) input_data = .; 
+	*(.data) 
+	input_data_end = .; 
+	}
+}
diff -puN arch/sh/cchips/hd6446x/hd64461/io.c~linus arch/sh/cchips/hd6446x/hd64461/io.c
--- 25/arch/sh/cchips/hd6446x/hd64461/io.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/cchips/hd6446x/hd64461/io.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- *	$Id: io.c,v 1.1.2.2 2002/01/20 05:03:25 mrbrown Exp $
+ *	$Id: io.c,v 1.4 2003/08/03 03:05:10 lethal Exp $
  *	Copyright (C) 2000 YAEGASHI Takeshi
  *	Typical I/O routines for HD64461 system.
  */
@@ -78,24 +78,6 @@ unsigned int hd64461_inl(unsigned long p
 	return *(volatile unsigned long*)PORT2ADDR(port);
 }
 
-void hd64461_insb(unsigned long port, void *buffer, unsigned long count)
-{
-	unsigned char *buf=buffer;
-	while(count--) *buf++=inb(port);
-}
-
-void hd64461_insw(unsigned long port, void *buffer, unsigned long count)
-{
-	unsigned short *buf=buffer;
-	while(count--) *buf++=inw(port);
-}
-
-void hd64461_insl(unsigned long port, void *buffer, unsigned long count)
-{
-	unsigned long *buf=buffer;
-	while(count--) *buf++=inl(port);
-}
-
 void hd64461_outb(unsigned char b, unsigned long port)
 {
 	*(volatile unsigned char*)PORT2ADDR(port) = b;
@@ -117,20 +99,3 @@ void hd64461_outl(unsigned int b, unsign
         *(volatile unsigned long*)PORT2ADDR(port) = b;
 }
 
-void hd64461_outsb(unsigned long port, const void *buffer, unsigned long count)
-{
-	const unsigned char *buf=buffer;
-	while(count--) outb(*buf++, port);
-}
-
-void hd64461_outsw(unsigned long port, const void *buffer, unsigned long count)
-{
-	const unsigned short *buf=buffer;
-	while(count--) outw(*buf++, port);
-}
-
-void hd64461_outsl(unsigned long port, const void *buffer, unsigned long count)
-{
-	const unsigned long *buf=buffer;
-	while(count--) outl(*buf++, port);
-}
diff -puN arch/sh/cchips/hd6446x/hd64461/setup.c~linus arch/sh/cchips/hd6446x/hd64461/setup.c
--- 25/arch/sh/cchips/hd6446x/hd64461/setup.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/cchips/hd6446x/hd64461/setup.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- *	$Id: setup.c,v 1.1.2.3 2002/11/04 20:33:57 lethal Exp $
+ *	$Id: setup.c,v 1.4 2003/08/03 03:05:10 lethal Exp $
  *	Copyright (C) 2000 YAEGASHI Takeshi
  *	Hitachi HD64461 companion chip support
  */
@@ -76,21 +76,23 @@ static void shutdown_hd64461_irq(unsigne
 
 
 static struct hw_interrupt_type hd64461_irq_type = {
-	"HD64461-IRQ",
-	startup_hd64461_irq,
-	shutdown_hd64461_irq,
-	enable_hd64461_irq,
-	disable_hd64461_irq,
-	mask_and_ack_hd64461,
-	end_hd64461_irq
+	.typename	= "HD64461-IRQ",
+	.startup	= startup_hd64461_irq,
+	.shutdown	= shutdown_hd64461_irq,
+	.enable		= enable_hd64461_irq,
+	.disable	= disable_hd64461_irq,
+	.ack		= mask_and_ack_hd64461,
+	.end		= end_hd64461_irq,
 };
 
 
-static void hd64461_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t hd64461_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	printk(KERN_INFO
 	       "HD64461: spurious interrupt, nirr: 0x%x nimr: 0x%x\n",
 	       inw(HD64461_NIRR), inw(HD64461_NIMR));
+
+	return IRQ_NONE;
 }
 
 int hd64461_irq_demux(int irq)
diff -puN arch/sh/cchips/hd6446x/hd64465/io.c~linus arch/sh/cchips/hd6446x/hd64465/io.c
--- 25/arch/sh/cchips/hd6446x/hd64465/io.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/cchips/hd6446x/hd64465/io.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * $Id: io.c,v 1.1.2.2 2002/01/20 05:03:25 mrbrown Exp $
+ * $Id: io.c,v 1.4 2003/08/03 03:05:10 lethal Exp $
  * by Greg Banks <gbanks@pocketpenguins.com>
  * (c) 2000 PocketPenguins Inc
  *
@@ -179,24 +179,6 @@ unsigned int hd64465_inl(unsigned long p
 	return b;
 }
 
-void hd64465_insb(unsigned long port, void *buffer, unsigned long count)
-{
-	unsigned char *buf=buffer;
-	while(count--) *buf++=inb(port);
-}
-
-void hd64465_insw(unsigned long port, void *buffer, unsigned long count)
-{
-	unsigned short *buf=buffer;
-	while(count--) *buf++=inw(port);
-}
-
-void hd64465_insl(unsigned long port, void *buffer, unsigned long count)
-{
-	unsigned long *buf=buffer;
-	while(count--) *buf++=inl(port);
-}
-
 void hd64465_outb(unsigned char b, unsigned long port)
 {
 	unsigned long addr = PORT2ADDR(port);
@@ -232,20 +214,3 @@ void hd64465_outl(unsigned int b, unsign
             *(volatile unsigned long*)addr = b;
 }
 
-void hd64465_outsb(unsigned long port, const void *buffer, unsigned long count)
-{
-	const unsigned char *buf=buffer;
-	while(count--) outb(*buf++, port);
-}
-
-void hd64465_outsw(unsigned long port, const void *buffer, unsigned long count)
-{
-	const unsigned short *buf=buffer;
-	while(count--) outw(*buf++, port);
-}
-
-void hd64465_outsl(unsigned long port, const void *buffer, unsigned long count)
-{
-	const unsigned long *buf=buffer;
-	while(count--) outl(*buf++, port);
-}
diff -puN arch/sh/cchips/hd6446x/hd64465/setup.c~linus arch/sh/cchips/hd6446x/hd64465/setup.c
--- 25/arch/sh/cchips/hd6446x/hd64465/setup.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/cchips/hd6446x/hd64465/setup.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * $Id: setup.c,v 1.1.2.3 2002/11/04 20:33:57 lethal Exp $
+ * $Id: setup.c,v 1.4 2003/08/03 03:05:10 lethal Exp $
  *
  * Setup and IRQ handling code for the HD64465 companion chip.
  * by Greg Banks <gbanks@pocketpenguins.com>
@@ -24,21 +24,13 @@
 
 #include <asm/hd64465/hd64465.h>
 
-#undef HD64465_DEBUG
-
-#ifdef HD64465_DEBUG
-#define DPRINTK(args...)	printk(args)
-#else
-#define DPRINTK(args...)
-#endif
-
 static void disable_hd64465_irq(unsigned int irq)
 {
 	unsigned long flags;
 	unsigned short nimr;
 	unsigned short mask = 1 << (irq - HD64465_IRQ_BASE);
 
-    	DPRINTK("disable_hd64465_irq(%d): mask=%x\n", irq, mask);
+    	pr_debug("disable_hd64465_irq(%d): mask=%x\n", irq, mask);
 	local_irq_save(flags);
 	nimr = inw(HD64465_REG_NIMR);
 	nimr |= mask;
@@ -53,7 +45,7 @@ static void enable_hd64465_irq(unsigned 
 	unsigned short nimr;
 	unsigned short mask = 1 << (irq - HD64465_IRQ_BASE);
 
-    	DPRINTK("enable_hd64465_irq(%d): mask=%x\n", irq, mask);
+    	pr_debug("enable_hd64465_irq(%d): mask=%x\n", irq, mask);
 	local_irq_save(flags);
 	nimr = inw(HD64465_REG_NIMR);
 	nimr &= ~mask;
@@ -95,15 +87,17 @@ static struct hw_interrupt_type hd64465_
 	.enable		= enable_hd64465_irq,
 	.disable	= disable_hd64465_irq,
 	.ack		= mask_and_ack_hd64465,
-	.end		= end_hd64465_irq
+	.end		= end_hd64465_irq,
 };
 
 
-static void hd64465_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t hd64465_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	printk(KERN_INFO
 	       "HD64465: spurious interrupt, nirr: 0x%x nimr: 0x%x\n",
 	       inw(HD64465_REG_NIRR), inw(HD64465_REG_NIMR));
+
+	return IRQ_NONE;
 }
 
 
@@ -145,7 +139,7 @@ int hd64465_irq_demux(int irq)
 		unsigned short nirr = inw(HD64465_REG_NIRR);
 		unsigned short nimr = inw(HD64465_REG_NIMR);
 
-    	    	DPRINTK("hd64465_irq_demux, nirr=%04x, nimr=%04x\n", nirr, nimr);
+    	    	pr_debug("hd64465_irq_demux, nirr=%04x, nimr=%04x\n", nirr, nimr);
 		nirr &= ~nimr;
 		for (bit = 1, i = 0 ; i < HD64465_IRQ_NUM ; bit <<= 1, i++)
 		    if (nirr & bit)
diff -puN /dev/null arch/sh/cchips/Kconfig
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/cchips/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,76 @@
+# A board must have defined HD6446X_SERIES in order to see these
+choice
+	prompt "HD6446x options"
+	depends HD6446X_SERIES
+	default HD64461
+
+config HD64461
+	bool "Hitachi HD64461 companion chip support"
+	depends on CPU_SUBTYPE_SH7709
+	---help---
+	  The Hitachi HD64461 provides an interface for
+	  the SH7709 CPU, supporting a LCD controller,
+	  CRT color controller, IrDA up to 4 Mbps, and a
+	  PCMCIA controller supporting 2 slots.
+
+	  More information is available at
+	  <http://semiconductor.hitachi.com/windowsce/superh/sld013.htm>.
+
+	  Say Y if you want support for the HD64461.
+	  Otherwise, say N.
+
+config HD64465
+	bool "Hitachi HD64465 companion chip support"
+	depends on CPU_SUBTYPE_SH7750
+	---help---
+	  The Hitachi HD64465 provides an interface for
+	  the SH7750 CPU, supporting a LCD controller,
+	  CRT color controller, IrDA, USB, PCMCIA,
+	  keyboard controller, and a printer interface.
+
+	  More information is available at
+	  <http://global.hitachi.com/New/cnews/E/1998/981019B.html>.
+
+	  Say Y if you want support for the HD64465.
+	  Otherwise, say N.
+
+endchoice
+
+# These will also be split into the Kconfig's below
+config HD64461_IRQ
+	int "HD64461 IRQ"
+	depends on HD64461
+	default "36"
+	help
+	  The default setting of the HD64461 IRQ is 36.
+
+	  Do not change this unless you know what you are doing.
+
+config HD64461_ENABLER
+	bool "HD64461 PCMCIA enabler"
+	depends on HD64461
+	help
+	  Say Y here if you want to enable PCMCIA support
+	  via the HD64461 companion chip.
+	  Otherwise, say N.
+
+
+config HD64465_IOBASE
+	hex "HD64465 start address"
+	depends on HD64465
+	default "0xb0000000"
+	help
+	  The default setting of the HD64465 IO base address is 0xb0000000.
+
+	  Do not change this unless you know what you are doing.
+
+config HD64465_IRQ
+	int "HD64465 IRQ"
+	depends on HD64465
+	default "5"
+	help
+	  The default setting of the HD64465 IRQ is 5.
+
+	  Do not change this unless you know what you are doing.
+
+
diff -puN arch/sh/configs/defconfig-adx~linus arch/sh/configs/defconfig-adx
--- 25/arch/sh/configs/defconfig-adx~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/configs/defconfig-adx	2004-01-19 22:17:21.000000000 -0800
@@ -45,8 +45,8 @@ CONFIG_CPU_SUBTYPE_SH7750=y
 # CONFIG_CPU_SH3 is not set
 CONFIG_CPU_SH4=y
 CONFIG_CPU_LITTLE_ENDIAN=y
-CONFIG_MEMORY_START=08000000
-CONFIG_MEMORY_SIZE=00400000
+CONFIG_MEMORY_START=0x08000000
+CONFIG_MEMORY_SIZE=0x00400000
 CONFIG_MEMORY_SET=y
 # CONFIG_DISCONTIGMEM is not set
 
@@ -61,7 +61,7 @@ CONFIG_ISA=y
 CONFIG_CF_ENABLER=y
 # CONFIG_CF_AREA5 is not set
 CONFIG_CF_AREA6=y
-CONFIG_CF_BASE_ADDR=b8000000
+CONFIG_CF_BASE_ADDR=0xb8000000
 # CONFIG_HD64461 is not set
 # CONFIG_HD64465 is not set
 # CONFIG_SH_DMA is not set
diff -puN arch/sh/configs/defconfig-cqreek~linus arch/sh/configs/defconfig-cqreek
--- 25/arch/sh/configs/defconfig-cqreek~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/configs/defconfig-cqreek	2004-01-19 22:17:21.000000000 -0800
@@ -45,8 +45,8 @@ CONFIG_CPU_SUBTYPE_SH7708=y
 CONFIG_CPU_SH3=y
 # CONFIG_CPU_SH4 is not set
 CONFIG_CPU_LITTLE_ENDIAN=y
-CONFIG_MEMORY_START=0c000000
-CONFIG_MEMORY_SIZE=00400000
+CONFIG_MEMORY_START=0x0c000000
+CONFIG_MEMORY_SIZE=0x00400000
 # CONFIG_DISCONTIGMEM is not set
 
 #
@@ -59,7 +59,7 @@ CONFIG_ISA=y
 # CONFIG_NET is not set
 # CONFIG_CF_AREA5 is not set
 CONFIG_CF_AREA6=y
-CONFIG_CF_BASE_ADDR=b8000000
+CONFIG_CF_BASE_ADDR=0xb8000000
 # CONFIG_HD64461 is not set
 # CONFIG_HD64465 is not set
 # CONFIG_SH_DMA is not set
diff -puN arch/sh/configs/defconfig-dreamcast~linus arch/sh/configs/defconfig-dreamcast
--- 25/arch/sh/configs/defconfig-dreamcast~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/configs/defconfig-dreamcast	2004-01-19 22:17:21.000000000 -0800
@@ -1,23 +1,48 @@
 #
-# Automatically generated by make menuconfig: don't edit
+# Automatically generated make config: don't edit
 #
 CONFIG_SUPERH=y
 CONFIG_UID16=y
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
-# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
+# CONFIG_CLEAN_COMPILE is not set
+# CONFIG_STANDALONE is not set
+CONFIG_BROKEN=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_SWAP=y
+# CONFIG_SYSVIPC is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_SYSCTL is not set
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_IKCONFIG is not set
+CONFIG_EMBEDDED=y
+CONFIG_KALLSYMS=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
 
 #
 # Loadable module support
 #
-# CONFIG_MODULES is not set
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_KMOD is not set
 
 #
-# Processor type and features
+# System type
 #
 # CONFIG_SH_SOLUTION_ENGINE is not set
 # CONFIG_SH_7751_SOLUTION_ENGINE is not set
@@ -29,60 +54,77 @@ CONFIG_EXPERIMENTAL=y
 # CONFIG_SH_CQREEK is not set
 # CONFIG_SH_DMIDA is not set
 # CONFIG_SH_EC3104 is not set
+# CONFIG_SH_SATURN is not set
 CONFIG_SH_DREAMCAST=y
 # CONFIG_SH_CAT68701 is not set
 # CONFIG_SH_BIGSUR is not set
 # CONFIG_SH_SH2000 is not set
 # CONFIG_SH_ADX is not set
+# CONFIG_SH_MPC1211 is not set
+# CONFIG_SH_SECUREEDGE5410 is not set
 # CONFIG_SH_UNKNOWN is not set
-# CONFIG_SH_RTC is not set
+# CONFIG_CPU_SH2 is not set
+# CONFIG_CPU_SH3 is not set
+CONFIG_CPU_SH4=y
+# CONFIG_CPU_SUBTYPE_SH7604 is not set
+# CONFIG_CPU_SUBTYPE_SH7300 is not set
 # CONFIG_CPU_SUBTYPE_SH7707 is not set
 # CONFIG_CPU_SUBTYPE_SH7708 is not set
 # CONFIG_CPU_SUBTYPE_SH7709 is not set
 CONFIG_CPU_SUBTYPE_SH7750=y
 # CONFIG_CPU_SUBTYPE_SH7751 is not set
 # CONFIG_CPU_SUBTYPE_ST40STB1 is not set
-# CONFIG_CPU_SH3 is not set
-CONFIG_CPU_SH4=y
-CONFIG_CPU_LITTLE_ENDIAN=y
-CONFIG_MEMORY_START=0c000000
-CONFIG_MEMORY_SIZE=00400000
+CONFIG_MMU=y
+# CONFIG_CMDLINE_BOOL is not set
+CONFIG_MEMORY_START=0x0c000000
+CONFIG_MEMORY_SIZE=0x01000000
 CONFIG_MEMORY_SET=y
-# CONFIG_DISCONTIGMEM is not set
+# CONFIG_MEMORY_OVERRIDE is not set
+CONFIG_ZERO_PAGE_OFFSET=0x00001000
+CONFIG_BOOT_LINK_OFFSET=0x00800000
+CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_PREEMPT=y
+# CONFIG_UBC_WAKEUP is not set
+# CONFIG_SH_WRITETHROUGH is not set
+# CONFIG_SH_OCRAM is not set
+CONFIG_SH_STORE_QUEUES=y
+# CONFIG_SMP is not set
+CONFIG_SH_PCLK_FREQ=49876504
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_TABLE=y
+CONFIG_SH_CPU_FREQ=y
+# CONFIG_CPU_FREQ_PROC_INTF is not set
+CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
+CONFIG_CPU_FREQ_GOV_USERSPACE=y
+CONFIG_SH_DMA=y
+CONFIG_NR_ONCHIP_DMA_CHANNELS=4
+CONFIG_NR_DMA_CHANNELS_BOOL=y
+CONFIG_NR_DMA_CHANNELS=9
+CONFIG_DMA_PAGE_OPS=y
 
 #
-# General setup
+# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
-CONFIG_ISA=y
-# CONFIG_EISA is not set
-# CONFIG_MCA is not set
-# CONFIG_SBUS is not set
-CONFIG_NET=y
-# CONFIG_HD64461 is not set
-# CONFIG_HD64465 is not set
-# CONFIG_SH_DMA is not set
 CONFIG_PCI=y
-# CONFIG_PCI_GOBIOS is not set
-# CONFIG_PCI_GODIRECT is not set
-CONFIG_PCI_GOANY=y
-CONFIG_PCI_BIOS=y
-CONFIG_PCI_DIRECT=y
 # CONFIG_SH_PCIDMA_NONCOHERENT is not set
+CONFIG_PCI_AUTO=y
+CONFIG_PCI_LEGACY_PROC=y
 CONFIG_PCI_NAMES=y
 # CONFIG_HOTPLUG is not set
-# CONFIG_PCMCIA is not set
-# CONFIG_SYSVIPC is not set
-# CONFIG_BSD_PROCESS_ACCT is not set
-# CONFIG_SYSCTL is not set
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
+
+#
+# Executable file formats
+#
 CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_FLAT is not set
 # CONFIG_BINFMT_MISC is not set
 
 #
-# Parallel port support
+# Generic Driver Options
 #
-# CONFIG_PARPORT is not set
 
 #
 # Memory Technology Devices (MTD)
@@ -90,64 +132,89 @@ CONFIG_BINFMT_ELF=y
 # CONFIG_MTD is not set
 
 #
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
 # Block devices
 #
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_DEV_XD is not set
-# CONFIG_PARIDE is not set
 # CONFIG_BLK_CPQ_DA is not set
 # CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_CISS_SCSI_TAPE is not set
 # CONFIG_BLK_DEV_DAC960 is not set
+# CONFIG_BLK_DEV_UMEM is not set
 # CONFIG_BLK_DEV_LOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
 CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_RAM_SIZE=1024
 CONFIG_BLK_DEV_INITRD=y
+# CONFIG_LBD is not set
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+# CONFIG_SCSI is not set
 
 #
 # Multi-device support (RAID and LVM)
 #
 # CONFIG_MD is not set
-# CONFIG_BLK_DEV_MD is not set
-# CONFIG_MD_LINEAR is not set
-# CONFIG_MD_RAID0 is not set
-# CONFIG_MD_RAID1 is not set
-# CONFIG_MD_RAID5 is not set
-# CONFIG_MD_MULTIPATH is not set
-# CONFIG_BLK_DEV_LVM is not set
+
+#
+# IEEE 1394 (FireWire) support (EXPERIMENTAL)
+#
+# CONFIG_IEEE1394 is not set
+
+#
+# Networking support
+#
+CONFIG_NET=y
 
 #
 # Networking options
 #
 CONFIG_PACKET=y
 # CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK is not set
-# CONFIG_NETFILTER is not set
-# CONFIG_FILTER is not set
+# CONFIG_NETLINK_DEV is not set
 CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
 CONFIG_INET=y
 # CONFIG_IP_MULTICAST is not set
 # CONFIG_IP_ADVANCED_ROUTER is not set
 CONFIG_IP_PNP=y
-# CONFIG_IP_PNP_DHCP is not set
+CONFIG_IP_PNP_DHCP=y
 # CONFIG_IP_PNP_BOOTP is not set
 # CONFIG_IP_PNP_RARP is not set
 # CONFIG_NET_IPIP is not set
 # CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
 # CONFIG_INET_ECN is not set
 # CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
 # CONFIG_IPV6 is not set
-# CONFIG_KHTTPD is not set
+# CONFIG_DECNET is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_NETFILTER is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IPV6_SCTP__=y
+# CONFIG_IP_SCTP is not set
 # CONFIG_ATM is not set
 # CONFIG_VLAN_8021Q is not set
+# CONFIG_LLC2 is not set
 # CONFIG_IPX is not set
 # CONFIG_ATALK is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
 # CONFIG_X25 is not set
 # CONFIG_LAPB is not set
-# CONFIG_LLC is not set
 # CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
@@ -160,24 +227,9 @@ CONFIG_IP_PNP=y
 # CONFIG_NET_SCHED is not set
 
 #
-# ATA/IDE/MFM/RLL support
-#
-# CONFIG_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
-
-#
-# SCSI support
-#
-# CONFIG_SCSI is not set
-
-#
-# IEEE 1394 (FireWire) support (EXPERIMENTAL)
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# Network device support
+# Network testing
 #
+# CONFIG_NET_PKTGEN is not set
 CONFIG_NETDEVICES=y
 
 #
@@ -193,65 +245,60 @@ CONFIG_NETDEVICES=y
 # Ethernet (10 or 100Mbit)
 #
 CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
 # CONFIG_STNIC is not set
-# CONFIG_SUNLANCE is not set
 # CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNBMAC is not set
-# CONFIG_SUNQE is not set
-# CONFIG_SUNLANCE is not set
 # CONFIG_SUNGEM is not set
 # CONFIG_NET_VENDOR_3COM is not set
-# CONFIG_LANCE is not set
-# CONFIG_NET_VENDOR_SMC is not set
-# CONFIG_NET_VENDOR_RACAL is not set
-# CONFIG_AT1700 is not set
-# CONFIG_DEPCA is not set
+
+#
+# Tulip family network device support
+#
+# CONFIG_NET_TULIP is not set
 # CONFIG_HP100 is not set
-# CONFIG_NET_ISA is not set
 CONFIG_NET_PCI=y
 # CONFIG_PCNET32 is not set
+# CONFIG_AMD8111_ETH is not set
 # CONFIG_ADAPTEC_STARFIRE is not set
-# CONFIG_AC3200 is not set
-# CONFIG_APRICOT is not set
-# CONFIG_TULIP is not set
-# CONFIG_DE4X5 is not set
+# CONFIG_B44 is not set
 # CONFIG_DGRS is not set
-# CONFIG_DM9102 is not set
 # CONFIG_EEPRO100 is not set
-# CONFIG_LNE390 is not set
+# CONFIG_E100 is not set
 # CONFIG_FEALNX is not set
 # CONFIG_NATSEMI is not set
 # CONFIG_NE2K_PCI is not set
-# CONFIG_NE3210 is not set
-# CONFIG_ES3210 is not set
 # CONFIG_8139CP is not set
 CONFIG_8139TOO=y
 # CONFIG_8139TOO_PIO is not set
 # CONFIG_8139TOO_TUNE_TWISTER is not set
 # CONFIG_8139TOO_8129 is not set
-CONFIG_8139TOO_DREAMCAST=y
+# CONFIG_8139_OLD_RX_RESET is not set
 # CONFIG_SIS900 is not set
 # CONFIG_EPIC100 is not set
 # CONFIG_SUNDANCE is not set
 # CONFIG_TLAN is not set
 # CONFIG_VIA_RHINE is not set
-# CONFIG_VIA_RHINE_MMIO is not set
-# CONFIG_WINBOND_840 is not set
-# CONFIG_NET_POCKET is not set
 
 #
 # Ethernet (1000 Mbit)
 #
 # CONFIG_ACENIC is not set
 # CONFIG_DL2K is not set
-# CONFIG_MYRI_SBUS is not set
+# CONFIG_E1000 is not set
 # CONFIG_NS83820 is not set
 # CONFIG_HAMACHI is not set
 # CONFIG_YELLOWFIN is not set
+# CONFIG_R8169 is not set
+# CONFIG_SIS190 is not set
 # CONFIG_SK98LIN is not set
+# CONFIG_TIGON3 is not set
+
+#
+# Ethernet (10000 Mbit)
+#
+# CONFIG_IXGB is not set
 # CONFIG_FDDI is not set
 # CONFIG_HIPPI is not set
-# CONFIG_PLIP is not set
 # CONFIG_PPP is not set
 # CONFIG_SLIP is not set
 
@@ -264,7 +311,6 @@ CONFIG_8139TOO_DREAMCAST=y
 # Token Ring devices
 #
 # CONFIG_TR is not set
-# CONFIG_NET_FC is not set
 # CONFIG_RCPCI is not set
 # CONFIG_SHAPER is not set
 
@@ -274,165 +320,186 @@ CONFIG_8139TOO_DREAMCAST=y
 # CONFIG_WAN is not set
 
 #
-# Old CD-ROM drivers (not SCSI, not IDE)
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
+# IrDA (infrared) support
+#
+# CONFIG_IRDA is not set
+
+#
+# Bluetooth support
+#
+# CONFIG_BT is not set
+
+#
+# ISDN subsystem
 #
-# CONFIG_CD_NO_IDESCSI is not set
+# CONFIG_ISDN_BOOL is not set
 
 #
-# Input core support
+# Telephony Support
 #
-CONFIG_INPUT=y
-CONFIG_INPUT_KEYBDEV=y
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-CONFIG_INPUT_JOYDEV=y
-# CONFIG_INPUT_EVDEV is not set
+# CONFIG_PHONE is not set
 
 #
-# Maple Bus support
+# Input device support
+#
+# CONFIG_INPUT is not set
+
+#
+# Userland interfaces
+#
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=y
+# CONFIG_SERIO_I8042 is not set
+# CONFIG_SERIO_SERPORT is not set
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_PCIPS2 is not set
+
+#
+# Input Device Drivers
 #
-CONFIG_MAPLE=y
 
 #
 # Character devices
 #
-CONFIG_VT=y
-CONFIG_VT_CONSOLE=y
+# CONFIG_VT is not set
 # CONFIG_SERIAL is not set
 CONFIG_SH_SCI=y
 CONFIG_SERIAL_CONSOLE=y
-# CONFIG_UNIX98_PTYS is not set
 
 #
-# Maple Bus input peripherals
-#
-CONFIG_MAPLE_KEYBOARD=y
-CONFIG_MAPLE_MOUSE=y
-
+# Unix 98 PTY support
 #
-# Joysticks
-#
-# CONFIG_INPUT_GAMEPORT is not set
-# CONFIG_INPUT_NS558 is not set
-# CONFIG_INPUT_LIGHTNING is not set
-# CONFIG_INPUT_PCIGAME is not set
-# CONFIG_INPUT_CS461X is not set
-# CONFIG_INPUT_EMU10K1 is not set
-# CONFIG_INPUT_SERIO is not set
-# CONFIG_INPUT_SERPORT is not set
-# CONFIG_INPUT_ANALOG is not set
-# CONFIG_INPUT_A3D is not set
-# CONFIG_INPUT_ADI is not set
-# CONFIG_INPUT_COBRA is not set
-# CONFIG_INPUT_GF2K is not set
-# CONFIG_INPUT_GRIP is not set
-# CONFIG_INPUT_INTERACT is not set
-# CONFIG_INPUT_TMDC is not set
-# CONFIG_INPUT_SIDEWINDER is not set
-# CONFIG_INPUT_IFORCE_USB is not set
-# CONFIG_INPUT_IFORCE_232 is not set
-# CONFIG_INPUT_WARRIOR is not set
-# CONFIG_INPUT_MAGELLAN is not set
-# CONFIG_INPUT_SPACEORB is not set
-# CONFIG_INPUT_SPACEBALL is not set
-# CONFIG_INPUT_STINGER is not set
-# CONFIG_INPUT_DB9 is not set
-# CONFIG_INPUT_GAMECON is not set
-# CONFIG_INPUT_TURBOGRAFX is not set
-CONFIG_INPUT_MAPLE_CONTROL=y
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
 # CONFIG_PSMOUSE is not set
 
 #
 # Watchdog Cards
 #
-CONFIG_WATCHDOG=y
-# CONFIG_WATCHDOG_NOWAYOUT is not set
-CONFIG_SH_WDT=y
+# CONFIG_WATCHDOG is not set
 # CONFIG_RTC is not set
 
 #
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+# CONFIG_SERIAL_SH_SCI is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# I2C Algorithms
+#
+
+#
+# I2C Hardware Bus support
+#
+
+#
+# I2C Hardware Sensors Chip support
+#
+# CONFIG_I2C_SENSOR is not set
+
+#
 # File systems
 #
+# CONFIG_EXT2_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_MINIX_FS is not set
+CONFIG_ROMFS_FS=y
 # CONFIG_QUOTA is not set
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_REISERFS_CHECK is not set
-# CONFIG_REISERFS_PROC_INFO is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+# CONFIG_FAT_FS is not set
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_DEVFS_FS=y
+CONFIG_DEVFS_MOUNT=y
+# CONFIG_DEVFS_DEBUG is not set
+CONFIG_DEVPTS_FS=y
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+# CONFIG_HUGETLBFS is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
 # CONFIG_ADFS_FS is not set
-# CONFIG_ADFS_FS_RW is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
+# CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_JBD_DEBUG is not set
-# CONFIG_FAT_FS is not set
-# CONFIG_MSDOS_FS is not set
-# CONFIG_UMSDOS_FS is not set
-# CONFIG_VFAT_FS is not set
 # CONFIG_EFS_FS is not set
-# CONFIG_JFFS_FS is not set
-# CONFIG_JFFS2_FS is not set
-# CONFIG_CRAMFS is not set
-CONFIG_TMPFS=y
-CONFIG_RAMFS=y
-CONFIG_ISO9660_FS=y
-# CONFIG_JOLIET is not set
-# CONFIG_ZISOFS is not set
-# CONFIG_MINIX_FS is not set
+CONFIG_CRAMFS=y
 # CONFIG_VXFS_FS is not set
-# CONFIG_NTFS_FS is not set
-# CONFIG_NTFS_RW is not set
 # CONFIG_HPFS_FS is not set
-CONFIG_PROC_FS=y
-# CONFIG_DEVFS_FS is not set
-# CONFIG_DEVFS_MOUNT is not set
-# CONFIG_DEVFS_DEBUG is not set
-# CONFIG_DEVPTS_FS is not set
 # CONFIG_QNX4FS_FS is not set
-# CONFIG_QNX4FS_RW is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_EXT2_FS is not set
 # CONFIG_SYSV_FS is not set
-# CONFIG_UDF_FS is not set
-# CONFIG_UDF_RW is not set
 # CONFIG_UFS_FS is not set
-# CONFIG_UFS_FS_WRITE is not set
 
 #
 # Network File Systems
 #
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
 CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-CONFIG_ROOT_NFS=y
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V4 is not set
 # CONFIG_NFSD is not set
-# CONFIG_NFSD_V3 is not set
-CONFIG_SUNRPC=y
+CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+# CONFIG_EXPORTFS is not set
+CONFIG_SUNRPC=y
+# CONFIG_SUNRPC_GSS is not set
 # CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
-# CONFIG_NCPFS_PACKET_SIGNING is not set
-# CONFIG_NCPFS_IOCTL_LOCKING is not set
-# CONFIG_NCPFS_STRONG is not set
-# CONFIG_NCPFS_NFS_NS is not set
-# CONFIG_NCPFS_OS2_NS is not set
-# CONFIG_NCPFS_SMALLDOS is not set
-# CONFIG_NCPFS_NLS is not set
-# CONFIG_NCPFS_EXTRAS is not set
-# CONFIG_ZISOFS_FS is not set
-# CONFIG_ZLIB_FS_INFLATE is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
+# CONFIG_AFS_FS is not set
 
 #
 # Partition Types
 #
 # CONFIG_PARTITION_ADVANCED is not set
 CONFIG_MSDOS_PARTITION=y
-# CONFIG_SMB_NLS is not set
-# CONFIG_NLS is not set
 
 #
 # Multimedia devices
@@ -440,40 +507,39 @@ CONFIG_MSDOS_PARTITION=y
 # CONFIG_VIDEO_DEV is not set
 
 #
-# Console drivers
+# Digital Video Broadcasting Devices
 #
-# CONFIG_VGA_CONSOLE is not set
-# CONFIG_VIDEO_SELECT is not set
-# CONFIG_MDA_CONSOLE is not set
+# CONFIG_DVB is not set
 
 #
-# Frame-buffer support
+# Graphics support
 #
 CONFIG_FB=y
-CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FB_RIVA is not set
-# CONFIG_FB_CLGEN is not set
+# CONFIG_FB_CIRRUS is not set
 # CONFIG_FB_PM2 is not set
 # CONFIG_FB_CYBER2000 is not set
+# CONFIG_FB_ASILIANT is not set
+# CONFIG_FB_IMSTT is not set
 CONFIG_FB_PVR2=y
-CONFIG_FB_PVR2_DEBUG=y
+# CONFIG_FB_PVR2_DEBUG is not set
 # CONFIG_FB_E1355 is not set
+# CONFIG_FB_RIVA is not set
 # CONFIG_FB_MATROX is not set
-# CONFIG_FB_ATY is not set
 # CONFIG_FB_RADEON is not set
 # CONFIG_FB_ATY128 is not set
+# CONFIG_FB_ATY is not set
 # CONFIG_FB_SIS is not set
+# CONFIG_FB_NEOMAGIC is not set
 # CONFIG_FB_3DFX is not set
 # CONFIG_FB_VOODOO1 is not set
+# CONFIG_FB_TRIDENT is not set
+# CONFIG_FB_PM3 is not set
 # CONFIG_FB_VIRTUAL is not set
-# CONFIG_FBCON_ADVANCED is not set
-CONFIG_FBCON_CFB16=y
-CONFIG_FBCON_CFB24=y
-CONFIG_FBCON_CFB32=y
-# CONFIG_FBCON_FONTWIDTH8_ONLY is not set
-# CONFIG_FBCON_FONTS is not set
-CONFIG_FONT_8x8=y
-CONFIG_FONT_8x16=y
+
+#
+# Logo configuration
+#
+# CONFIG_LOGO is not set
 
 #
 # Sound
@@ -481,7 +547,38 @@ CONFIG_FONT_8x16=y
 # CONFIG_SOUND is not set
 
 #
+# USB support
+#
+# CONFIG_USB is not set
+# CONFIG_USB_GADGET is not set
+
+#
+# Profiling support
+#
+CONFIG_PROFILING=y
+CONFIG_OPROFILE=y
+
+#
 # Kernel hacking
 #
 # CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_DEBUG_SPINLOCK is not set
 # CONFIG_SH_STANDARD_BIOS is not set
+# CONFIG_KGDB is not set
+# CONFIG_FRAME_POINTER is not set
+
+#
+# Security options
+#
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
+#
+CONFIG_CRC32=y
+CONFIG_ZLIB_INFLATE=y
diff -puN /dev/null arch/sh/configs/defconfig-se7751
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/configs/defconfig-se7751	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,617 @@
+#
+# Automatically generated make config: don't edit
+#
+CONFIG_SUPERH=y
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_STANDALONE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_SYSCTL=y
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_IKCONFIG is not set
+CONFIG_EMBEDDED=y
+CONFIG_KALLSYMS=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+# CONFIG_MODULE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_KMOD is not set
+
+#
+# System type
+#
+# CONFIG_SH_SOLUTION_ENGINE is not set
+CONFIG_SH_7751_SOLUTION_ENGINE=y
+# CONFIG_SH_7751_SYSTEMH is not set
+# CONFIG_SH_STB1_HARP is not set
+# CONFIG_SH_STB1_OVERDRIVE is not set
+# CONFIG_SH_HP620 is not set
+# CONFIG_SH_HP680 is not set
+# CONFIG_SH_HP690 is not set
+# CONFIG_SH_CQREEK is not set
+# CONFIG_SH_DMIDA is not set
+# CONFIG_SH_EC3104 is not set
+# CONFIG_SH_SATURN is not set
+# CONFIG_SH_DREAMCAST is not set
+# CONFIG_SH_CAT68701 is not set
+# CONFIG_SH_BIGSUR is not set
+# CONFIG_SH_SH2000 is not set
+# CONFIG_SH_ADX is not set
+# CONFIG_SH_MPC1211 is not set
+# CONFIG_SH_SECUREEDGE5410 is not set
+# CONFIG_SH_UNKNOWN is not set
+# CONFIG_CPU_SH2 is not set
+# CONFIG_CPU_SH3 is not set
+CONFIG_CPU_SH4=y
+# CONFIG_CPU_SUBTYPE_SH7604 is not set
+# CONFIG_CPU_SUBTYPE_SH7300 is not set
+# CONFIG_CPU_SUBTYPE_SH7707 is not set
+# CONFIG_CPU_SUBTYPE_SH7708 is not set
+# CONFIG_CPU_SUBTYPE_SH7709 is not set
+# CONFIG_CPU_SUBTYPE_SH7750 is not set
+CONFIG_CPU_SUBTYPE_SH7751=y
+# CONFIG_CPU_SUBTYPE_SH7760 is not set
+# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
+CONFIG_MMU=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE="console=ttySC1,38400"
+CONFIG_MEMORY_START=0x0c000000
+CONFIG_MEMORY_SIZE=0x04000000
+CONFIG_MEMORY_SET=y
+# CONFIG_MEMORY_OVERRIDE is not set
+CONFIG_SH_RTC=y
+CONFIG_ZERO_PAGE_OFFSET=0x00010000
+CONFIG_BOOT_LINK_OFFSET=0x00800000
+CONFIG_CPU_LITTLE_ENDIAN=y
+# CONFIG_PREEMPT is not set
+# CONFIG_UBC_WAKEUP is not set
+# CONFIG_SH_WRITETHROUGH is not set
+# CONFIG_SH_OCRAM is not set
+# CONFIG_SH_STORE_QUEUES is not set
+# CONFIG_SMP is not set
+CONFIG_SH_PCLK_FREQ=60013568
+# CONFIG_CPU_FREQ is not set
+# CONFIG_SH_DMA is not set
+
+#
+# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
+#
+CONFIG_PCI=y
+# CONFIG_SH_PCIDMA_NONCOHERENT is not set
+CONFIG_PCI_AUTO=y
+CONFIG_PCI_AUTO_UPDATE_RESOURCES=y
+CONFIG_PCI_DMA=y
+# CONFIG_PCI_LEGACY_PROC is not set
+# CONFIG_PCI_NAMES is not set
+# CONFIG_HOTPLUG is not set
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_FLAT is not set
+# CONFIG_BINFMT_MISC is not set
+
+#
+# Generic Driver Options
+#
+
+#
+# Memory Technology Devices (MTD)
+#
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+CONFIG_MTD_PARTITIONS=y
+# CONFIG_MTD_CONCAT is not set
+# CONFIG_MTD_REDBOOT_PARTS is not set
+# CONFIG_MTD_CMDLINE_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+# CONFIG_MTD_CHAR is not set
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=y
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_GEN_PROBE=y
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
+# CONFIG_MTD_CFI_INTELEXT is not set
+CONFIG_MTD_CFI_AMDSTD=y
+# CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_RAM=y
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+# CONFIG_MTD_OBSOLETE_CHIPS is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PHYSMAP is not set
+# CONFIG_MTD_MPC1211 is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_PMC551 is not set
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLKMTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+
+#
+# NAND Flash Device Drivers
+#
+# CONFIG_MTD_NAND is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_CPQ_DA is not set
+# CONFIG_BLK_CPQ_CISS_DA is not set
+# CONFIG_BLK_DEV_DAC960 is not set
+# CONFIG_BLK_DEV_UMEM is not set
+# CONFIG_BLK_DEV_LOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_LBD is not set
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+# CONFIG_SCSI is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# IEEE 1394 (FireWire) support (EXPERIMENTAL)
+#
+# CONFIG_IEEE1394 is not set
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_NETLINK_DEV=y
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_IP_MROUTE is not set
+# CONFIG_ARPD is not set
+# CONFIG_INET_ECN is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+
+#
+# IP: Virtual Server Configuration
+#
+# CONFIG_IP_VS is not set
+# CONFIG_IPV6 is not set
+# CONFIG_DECNET is not set
+# CONFIG_BRIDGE is not set
+CONFIG_NETFILTER=y
+CONFIG_NETFILTER_DEBUG=y
+
+#
+# IP: Netfilter Configuration
+#
+# CONFIG_IP_NF_CONNTRACK is not set
+CONFIG_IP_NF_QUEUE=y
+# CONFIG_IP_NF_IPTABLES is not set
+# CONFIG_IP_NF_ARPTABLES is not set
+# CONFIG_IP_NF_COMPAT_IPCHAINS is not set
+# CONFIG_IP_NF_COMPAT_IPFWADM is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IPV6_SCTP__=y
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_FASTROUTE is not set
+# CONFIG_NET_HW_FLOWCONTROL is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+CONFIG_NETDEVICES=y
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+# CONFIG_ETHERTAP is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+# CONFIG_STNIC is not set
+# CONFIG_HAPPYMEAL is not set
+# CONFIG_SUNGEM is not set
+# CONFIG_NET_VENDOR_3COM is not set
+
+#
+# Tulip family network device support
+#
+# CONFIG_NET_TULIP is not set
+# CONFIG_HP100 is not set
+CONFIG_NET_PCI=y
+CONFIG_PCNET32=y
+# CONFIG_AMD8111_ETH is not set
+# CONFIG_ADAPTEC_STARFIRE is not set
+# CONFIG_B44 is not set
+# CONFIG_DGRS is not set
+# CONFIG_EEPRO100 is not set
+# CONFIG_E100 is not set
+# CONFIG_FEALNX is not set
+# CONFIG_NATSEMI is not set
+# CONFIG_NE2K_PCI is not set
+# CONFIG_8139CP is not set
+# CONFIG_8139TOO is not set
+# CONFIG_SIS900 is not set
+# CONFIG_EPIC100 is not set
+# CONFIG_SUNDANCE is not set
+# CONFIG_TLAN is not set
+# CONFIG_VIA_RHINE is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_E1000 is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_R8169 is not set
+# CONFIG_SIS190 is not set
+# CONFIG_SK98LIN is not set
+# CONFIG_TIGON3 is not set
+
+#
+# Ethernet (10000 Mbit)
+#
+# CONFIG_IXGB is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+# CONFIG_RCPCI is not set
+# CONFIG_SHAPER is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+
+#
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
+# IrDA (infrared) support
+#
+# CONFIG_IRDA is not set
+
+#
+# Bluetooth support
+#
+# CONFIG_BT is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN_BOOL is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+# CONFIG_INPUT is not set
+
+#
+# Userland interfaces
+#
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+# CONFIG_SERIO is not set
+# CONFIG_SERIO_I8042 is not set
+
+#
+# Input Device Drivers
+#
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+# CONFIG_SERIAL is not set
+CONFIG_SH_SCI=y
+CONFIG_SERIAL_CONSOLE=y
+
+#
+# Unix 98 PTY support
+#
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
+CONFIG_HEARTBEAT=y
+# CONFIG_PSMOUSE is not set
+
+#
+# Watchdog Cards
+#
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+# CONFIG_SH_WDT is not set
+# CONFIG_RTC is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+# CONFIG_SERIAL_SH_SCI is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# I2C Algorithms
+#
+
+#
+# I2C Hardware Bus support
+#
+
+#
+# I2C Hardware Sensors Chip support
+#
+# CONFIG_I2C_SENSOR is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+# CONFIG_FAT_FS is not set
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+# CONFIG_DEVFS_FS is not set
+CONFIG_DEVPTS_FS=y
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+CONFIG_JFFS2_FS=y
+CONFIG_JFFS2_FS_DEBUG=0
+# CONFIG_JFFS2_FS_NAND is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+# CONFIG_NFS_FS is not set
+# CONFIG_NFSD is not set
+# CONFIG_EXPORTFS is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+# CONFIG_FB is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB is not set
+# CONFIG_USB_GADGET is not set
+
+#
+# Profiling support
+#
+# CONFIG_PROFILING is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_SH_STANDARD_BIOS is not set
+# CONFIG_KGDB is not set
+# CONFIG_FRAME_POINTER is not set
+
+#
+# Security options
+#
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
+#
+CONFIG_CRC32=y
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=y
diff -puN /dev/null arch/sh/configs/defconfig-snapgear
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/configs/defconfig-snapgear	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,540 @@
+#
+# Automatically generated make config: don't edit
+#
+CONFIG_SUPERH=y
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_STANDALONE=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_SWAP=y
+# CONFIG_SYSVIPC is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_SYSCTL is not set
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_IKCONFIG is not set
+# CONFIG_EMBEDDED is not set
+CONFIG_KALLSYMS=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+
+#
+# Loadable module support
+#
+# CONFIG_MODULES is not set
+
+#
+# System type
+#
+# CONFIG_SH_SOLUTION_ENGINE is not set
+# CONFIG_SH_7751_SOLUTION_ENGINE is not set
+# CONFIG_SH_STB1_HARP is not set
+# CONFIG_SH_STB1_OVERDRIVE is not set
+# CONFIG_SH_HP620 is not set
+# CONFIG_SH_HP680 is not set
+# CONFIG_SH_HP690 is not set
+# CONFIG_SH_CQREEK is not set
+# CONFIG_SH_DMIDA is not set
+# CONFIG_SH_EC3104 is not set
+# CONFIG_SH_SATURN is not set
+# CONFIG_SH_DREAMCAST is not set
+# CONFIG_SH_CAT68701 is not set
+# CONFIG_SH_BIGSUR is not set
+# CONFIG_SH_SH2000 is not set
+# CONFIG_SH_ADX is not set
+# CONFIG_SH_MPC1211 is not set
+CONFIG_SH_SECUREEDGE5410=y
+# CONFIG_SH_UNKNOWN is not set
+# CONFIG_CPU_SH2 is not set
+# CONFIG_CPU_SH3 is not set
+CONFIG_CPU_SH4=y
+# CONFIG_CPU_SUBTYPE_SH7604 is not set
+# CONFIG_CPU_SUBTYPE_SH7300 is not set
+# CONFIG_CPU_SUBTYPE_SH7707 is not set
+# CONFIG_CPU_SUBTYPE_SH7708 is not set
+# CONFIG_CPU_SUBTYPE_SH7709 is not set
+# CONFIG_CPU_SUBTYPE_SH7750 is not set
+CONFIG_CPU_SUBTYPE_SH7751=y
+# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
+CONFIG_MMU=y
+# CONFIG_CMDLINE_BOOL is not set
+CONFIG_MEMORY_START=0x08000000
+CONFIG_MEMORY_SIZE=0x01000000
+CONFIG_MEMORY_SET=y
+# CONFIG_MEMORY_OVERRIDE is not set
+CONFIG_SH_RTC=y
+CONFIG_ZERO_PAGE_OFFSET=0x00001000
+CONFIG_BOOT_LINK_OFFSET=0x00800000
+CONFIG_CPU_LITTLE_ENDIAN=y
+# CONFIG_PREEMPT is not set
+# CONFIG_UBC_WAKEUP is not set
+# CONFIG_SH_WRITETHROUGH is not set
+# CONFIG_SH_OCRAM is not set
+# CONFIG_SH_STORE_QUEUES is not set
+# CONFIG_SMP is not set
+CONFIG_SH_PCLK_FREQ=60013568
+# CONFIG_CPU_FREQ is not set
+CONFIG_SH_DMA=y
+CONFIG_NR_DMA_CHANNELS=8
+# CONFIG_DMA_PAGE_OPS is not set
+
+#
+# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
+#
+CONFIG_PCI=y
+# CONFIG_SH_PCIDMA_NONCOHERENT is not set
+CONFIG_PCI_AUTO=y
+CONFIG_PCI_AUTO_UPDATE_RESOURCES=y
+CONFIG_PCI_DMA=y
+# CONFIG_PCI_LEGACY_PROC is not set
+CONFIG_PCI_NAMES=y
+# CONFIG_HOTPLUG is not set
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_FLAT is not set
+# CONFIG_BINFMT_MISC is not set
+
+#
+# Generic Driver Options
+#
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_CPQ_DA is not set
+# CONFIG_BLK_CPQ_CISS_DA is not set
+# CONFIG_BLK_DEV_DAC960 is not set
+# CONFIG_BLK_DEV_UMEM is not set
+# CONFIG_BLK_DEV_LOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_LBD is not set
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+# CONFIG_SCSI is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# IEEE 1394 (FireWire) support (EXPERIMENTAL)
+#
+# CONFIG_IEEE1394 is not set
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_PACKET is not set
+# CONFIG_NETLINK_DEV is not set
+# CONFIG_UNIX is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_INET_ECN is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_IPV6 is not set
+# CONFIG_DECNET is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_NETFILTER is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IPV6_SCTP__=y
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_LLC is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_FASTROUTE is not set
+# CONFIG_NET_HW_FLOWCONTROL is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+CONFIG_NETDEVICES=y
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+# CONFIG_MII is not set
+# CONFIG_STNIC is not set
+# CONFIG_HAPPYMEAL is not set
+# CONFIG_SUNGEM is not set
+# CONFIG_NET_VENDOR_3COM is not set
+
+#
+# Tulip family network device support
+#
+# CONFIG_NET_TULIP is not set
+# CONFIG_HP100 is not set
+CONFIG_NET_PCI=y
+# CONFIG_PCNET32 is not set
+# CONFIG_AMD8111_ETH is not set
+# CONFIG_ADAPTEC_STARFIRE is not set
+# CONFIG_B44 is not set
+# CONFIG_DGRS is not set
+# CONFIG_EEPRO100 is not set
+# CONFIG_E100 is not set
+# CONFIG_FEALNX is not set
+# CONFIG_NATSEMI is not set
+# CONFIG_NE2K_PCI is not set
+# CONFIG_8139CP is not set
+CONFIG_8139TOO=y
+# CONFIG_8139TOO_PIO is not set
+# CONFIG_8139TOO_TUNE_TWISTER is not set
+# CONFIG_8139TOO_8129 is not set
+# CONFIG_8139_OLD_RX_RESET is not set
+# CONFIG_SIS900 is not set
+# CONFIG_EPIC100 is not set
+# CONFIG_SUNDANCE is not set
+# CONFIG_TLAN is not set
+# CONFIG_VIA_RHINE is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_E1000 is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_R8169 is not set
+# CONFIG_SIS190 is not set
+# CONFIG_SK98LIN is not set
+# CONFIG_TIGON3 is not set
+
+#
+# Ethernet (10000 Mbit)
+#
+# CONFIG_IXGB is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Token Ring devices (depends on LLC=y)
+#
+# CONFIG_RCPCI is not set
+# CONFIG_SHAPER is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+
+#
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
+# IrDA (infrared) support
+#
+# CONFIG_IRDA is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN_BOOL is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+# CONFIG_SERIO is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+# CONFIG_SERIAL is not set
+CONFIG_SH_SCI=y
+CONFIG_SERIAL_CONSOLE=y
+
+#
+# Unix 98 PTY support
+#
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
+# CONFIG_PSMOUSE is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_RTC is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+# CONFIG_SERIAL_SH_SCI is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# I2C Hardware Sensors Mainboard support
+#
+
+#
+# I2C Hardware Sensors Chip support
+#
+# CONFIG_I2C_SENSOR is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_MINIX_FS is not set
+CONFIG_ROMFS_FS=y
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+# CONFIG_FAT_FS is not set
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_DEVFS_FS=y
+CONFIG_DEVFS_MOUNT=y
+# CONFIG_DEVFS_DEBUG is not set
+CONFIG_DEVPTS_FS=y
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_CRAMFS=y
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V4 is not set
+# CONFIG_NFSD is not set
+CONFIG_ROOT_NFS=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+# CONFIG_EXPORTFS is not set
+CONFIG_SUNRPC=y
+# CONFIG_SUNRPC_GSS is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+# CONFIG_FB is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB is not set
+# CONFIG_USB_GADGET is not set
+
+#
+# Bluetooth support
+#
+# CONFIG_BT is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_SH_STANDARD_BIOS is not set
+# CONFIG_KGDB is not set
+# CONFIG_FRAME_POINTER is not set
+
+#
+# Security options
+#
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
+#
+# CONFIG_CRC32 is not set
+CONFIG_ZLIB_INFLATE=y
diff -puN /dev/null arch/sh/configs/defconfig-systemh
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/configs/defconfig-systemh	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,372 @@
+#
+# Automatically generated make config: don't edit
+#
+CONFIG_SUPERH=y
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+# CONFIG_CLEAN_COMPILE is not set
+# CONFIG_STANDALONE is not set
+CONFIG_BROKEN=y
+CONFIG_BROKEN_ON_SMP=y
+
+#
+# General setup
+#
+CONFIG_SWAP=y
+# CONFIG_SYSVIPC is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_SYSCTL is not set
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_IKCONFIG is not set
+CONFIG_EMBEDDED=y
+CONFIG_KALLSYMS=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_KMOD is not set
+
+#
+# System type
+#
+# CONFIG_SH_SOLUTION_ENGINE is not set
+# CONFIG_SH_7751_SOLUTION_ENGINE is not set
+CONFIG_SH_7751_SYSTEMH=y
+# CONFIG_SH_STB1_HARP is not set
+# CONFIG_SH_STB1_OVERDRIVE is not set
+# CONFIG_SH_HP620 is not set
+# CONFIG_SH_HP680 is not set
+# CONFIG_SH_HP690 is not set
+# CONFIG_SH_CQREEK is not set
+# CONFIG_SH_DMIDA is not set
+# CONFIG_SH_EC3104 is not set
+# CONFIG_SH_SATURN is not set
+# CONFIG_SH_DREAMCAST is not set
+# CONFIG_SH_CAT68701 is not set
+# CONFIG_SH_BIGSUR is not set
+# CONFIG_SH_SH2000 is not set
+# CONFIG_SH_ADX is not set
+# CONFIG_SH_MPC1211 is not set
+# CONFIG_SH_SECUREEDGE5410 is not set
+# CONFIG_SH_UNKNOWN is not set
+# CONFIG_CPU_SH2 is not set
+# CONFIG_CPU_SH3 is not set
+CONFIG_CPU_SH4=y
+# CONFIG_CPU_SUBTYPE_SH7604 is not set
+# CONFIG_CPU_SUBTYPE_SH7300 is not set
+# CONFIG_CPU_SUBTYPE_SH7707 is not set
+# CONFIG_CPU_SUBTYPE_SH7708 is not set
+# CONFIG_CPU_SUBTYPE_SH7709 is not set
+# CONFIG_CPU_SUBTYPE_SH7750 is not set
+CONFIG_CPU_SUBTYPE_SH7751=y
+# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
+CONFIG_MMU=y
+# CONFIG_CMDLINE_BOOL is not set
+CONFIG_MEMORY_START=0x0c000000
+CONFIG_MEMORY_SIZE=0x00400000
+# CONFIG_MEMORY_OVERRIDE is not set
+CONFIG_SH_RTC=y
+CONFIG_ZERO_PAGE_OFFSET=0x00001000
+CONFIG_BOOT_LINK_OFFSET=0x00800000
+CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_PREEMPT=y
+# CONFIG_UBC_WAKEUP is not set
+# CONFIG_SH_WRITETHROUGH is not set
+# CONFIG_SH_OCRAM is not set
+# CONFIG_SH_STORE_QUEUES is not set
+# CONFIG_SMP is not set
+CONFIG_SH_PCLK_FREQ=49876504
+# CONFIG_CPU_FREQ is not set
+# CONFIG_SH_DMA is not set
+
+#
+# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
+#
+CONFIG_PCI=y
+# CONFIG_SH_PCIDMA_NONCOHERENT is not set
+CONFIG_PCI_AUTO=y
+CONFIG_PCI_AUTO_UPDATE_RESOURCES=y
+CONFIG_PCI_DMA=y
+CONFIG_PCI_LEGACY_PROC=y
+CONFIG_PCI_NAMES=y
+# CONFIG_HOTPLUG is not set
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_FLAT is not set
+# CONFIG_BINFMT_MISC is not set
+
+#
+# Generic Driver Options
+#
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Block devices
+#
+# CONFIG_BLK_CPQ_DA is not set
+# CONFIG_BLK_CPQ_CISS_DA is not set
+# CONFIG_BLK_DEV_DAC960 is not set
+# CONFIG_BLK_DEV_UMEM is not set
+# CONFIG_BLK_DEV_LOOP is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=1024
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_LBD is not set
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+# CONFIG_SCSI is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# IEEE 1394 (FireWire) support (EXPERIMENTAL)
+#
+# CONFIG_IEEE1394 is not set
+
+#
+# Networking support
+#
+# CONFIG_NET is not set
+
+#
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
+# ISDN subsystem
+#
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+# CONFIG_INPUT is not set
+
+#
+# Userland interfaces
+#
+
+#
+# Input I/O drivers
+#
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+CONFIG_SERIO=y
+# CONFIG_SERIO_I8042 is not set
+# CONFIG_SERIO_SERPORT is not set
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_PCIPS2 is not set
+
+#
+# Input Device Drivers
+#
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+# CONFIG_SERIAL is not set
+CONFIG_SH_SCI=y
+CONFIG_SERIAL_CONSOLE=y
+
+#
+# Unix 98 PTY support
+#
+CONFIG_UNIX98_PTYS=y
+CONFIG_UNIX98_PTY_COUNT=256
+# CONFIG_PSMOUSE is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_RTC is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+# CONFIG_SERIAL_SH_SCI is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# I2C Algorithms
+#
+
+#
+# I2C Hardware Bus support
+#
+
+#
+# I2C Hardware Sensors Chip support
+#
+# CONFIG_I2C_SENSOR is not set
+
+#
+# File systems
+#
+# CONFIG_EXT2_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_MINIX_FS is not set
+CONFIG_ROMFS_FS=y
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+# CONFIG_FAT_FS is not set
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_DEVFS_FS=y
+CONFIG_DEVFS_MOUNT=y
+# CONFIG_DEVFS_DEBUG is not set
+CONFIG_DEVPTS_FS=y
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+# CONFIG_HUGETLBFS is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_CRAMFS=y
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+
+#
+# Graphics support
+#
+# CONFIG_FB is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB is not set
+# CONFIG_USB_GADGET is not set
+
+#
+# Profiling support
+#
+# CONFIG_PROFILING is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_SH_STANDARD_BIOS is not set
+# CONFIG_KGDB is not set
+# CONFIG_FRAME_POINTER is not set
+
+#
+# Security options
+#
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Library routines
+#
+CONFIG_CRC32=y
+CONFIG_ZLIB_INFLATE=y
diff -puN /dev/null arch/sh/drivers/dma/dma-api.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/dma/dma-api.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,193 @@
+/*
+ * arch/sh/drivers/dma/dma-api.c
+ *
+ * SuperH-specific DMA management API
+ *
+ * Copyright (C) 2003  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */ 
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+#include <linux/proc_fs.h>
+#include <asm/dma.h>
+
+struct dma_info dma_info[MAX_DMA_CHANNELS] = { { 0, } };
+spinlock_t dma_spin_lock = SPIN_LOCK_UNLOCKED;
+
+/* 
+ * A brief note about the reasons for this API as it stands.
+ *
+ * For starters, the old ISA DMA API didn't work for us for a number of
+ * reasons, for one, the vast majority of channels on the SH DMAC are
+ * dual-address mode only, and both the new and the old DMA APIs are after the
+ * concept of managing a DMA buffer, which doesn't overly fit this model very
+ * well. In addition to which, the new API is largely geared at IOMMUs and
+ * GARTs, and doesn't even support the channel notion very well.
+ *
+ * The other thing that's a marginal issue, is the sheer number of random DMA
+ * engines that are present (ie, in boards like the Dreamcast), some of which
+ * cascade off of the SH DMAC, and others do not. As such, there was a real
+ * need for a scalable subsystem that could deal with both single and
+ * dual-address mode usage, in addition to interoperating with cascaded DMACs.
+ *
+ * There really isn't any reason why this needs to be SH specific, though I'm
+ * not aware of too many other processors (with the exception of some MIPS)
+ * that have the same concept of a dual address mode, or any real desire to
+ * actually make use of the DMAC even if such a subsystem were exposed
+ * elsewhere.
+ *
+ * The idea for this was derived from the ARM port, which acted as an excellent
+ * reference when trying to address these issues.
+ *
+ * It should also be noted that the decision to add Yet Another DMA API(tm) to
+ * the kernel wasn't made easily, and was only decided upon after conferring
+ * with jejb with regards to the state of the old and new APIs as they applied
+ * to these circumstances. Philip Blundell was also a great help in figuring
+ * out some single-address mode DMA semantics that were otherwise rather
+ * confusing.
+ */
+
+struct dma_info *get_dma_info(unsigned int chan)
+{
+	return dma_info + chan;
+}
+
+int get_dma_residue(unsigned int chan)
+{
+	struct dma_info *info = get_dma_info(chan);
+
+	if (info->ops->get_residue)
+		return info->ops->get_residue(info);
+	
+	return 0;
+}
+
+int request_dma(unsigned int chan, const char *dev_id)
+{
+	struct dma_info *info = get_dma_info(chan);
+
+	down(&info->sem);
+
+	if (!info->ops || chan >= MAX_DMA_CHANNELS) {
+		up(&info->sem);
+		return -EINVAL;
+	}
+	
+	atomic_set(&info->busy, 1);
+
+	info->dev_id = dev_id;
+
+	up(&info->sem);
+
+	if (info->ops->request)
+		return info->ops->request(info);
+	
+	return 0;
+}
+
+void free_dma(unsigned int chan)
+{
+	struct dma_info *info = get_dma_info(chan);
+
+	if (info->ops->free)
+		info->ops->free(info);
+	
+	atomic_set(&info->busy, 0);
+}
+
+void dma_wait_for_completion(unsigned int chan)
+{
+	struct dma_info *info = get_dma_info(chan);
+
+	while (info->ops->get_residue(info))
+		cpu_relax();
+}
+
+void dma_configure_channel(unsigned int chan, unsigned long flags)
+{
+	struct dma_info *info = get_dma_info(chan);
+
+	if (info->ops->configure)
+		info->ops->configure(info, flags);
+}
+
+int dma_xfer(unsigned int chan, unsigned long from,
+	     unsigned long to, size_t size, unsigned int mode)
+{
+	struct dma_info *info = get_dma_info(chan);
+
+	info->sar	= from;
+	info->dar	= to;
+	info->count	= size;
+	info->mode	= mode;
+
+	return info->ops->xfer(info);
+}
+
+#ifdef CONFIG_PROC_FS
+static int dma_read_proc(char *buf, char **start, off_t off,
+			 int len, int *eof, void *data)
+{
+	struct dma_info *info;
+	char *p = buf;
+	int i;
+
+	for (i = 0, info = dma_info; i < MAX_DMA_CHANNELS; i++, info++) {
+		if (!atomic_read(&info->busy))
+			continue;
+
+		p += sprintf(p, "%2d: %14s    %s\n", i,
+			     info->ops->name, info->dev_id);
+	}
+
+	return p - buf;
+}
+#endif
+
+int __init register_dmac(struct dma_ops *ops)
+{
+	int i;
+
+	printk("DMA: Registering %s handler.\n", ops->name);
+
+	for (i = 0; i < MAX_DMA_CHANNELS; i++) {
+		struct dma_info *info = get_dma_info(i);
+
+		info->chan = i;
+
+		init_MUTEX(&info->sem);
+	}
+
+	return 0;
+}
+
+static int __init dma_api_init(void)
+{
+	printk("DMA: Registering DMA API.\n");
+
+#ifdef CONFIG_PROC_FS
+	create_proc_read_entry("dma", 0, 0, dma_read_proc, 0);
+#endif
+
+	return 0;
+}
+
+subsys_initcall(dma_api_init);
+
+MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>");
+MODULE_DESCRIPTION("DMA API for SuperH");
+MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(request_dma);
+EXPORT_SYMBOL(free_dma);
+EXPORT_SYMBOL(get_dma_residue);
+EXPORT_SYMBOL(get_dma_info);
+EXPORT_SYMBOL(dma_xfer);
+EXPORT_SYMBOL(dma_wait_for_completion);
+EXPORT_SYMBOL(dma_configure_channel);
+
diff -puN /dev/null arch/sh/drivers/dma/dma-g2.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/dma/dma-g2.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,173 @@
+/*
+ * arch/sh/drivers/dma/dma-g2.c
+ *
+ * G2 bus DMA support
+ *
+ * Copyright (C) 2003  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+
+#include <asm/mach/sysasic.h>
+#include <asm/mach/dma.h>
+#include <asm/dma.h>
+
+struct g2_channel {
+	unsigned long g2_addr;		/* G2 bus address */
+	unsigned long root_addr;	/* Root bus (SH-4) address */
+	unsigned long size;		/* Size (in bytes), 32-byte aligned */
+	unsigned long direction;	/* Transfer direction */
+	unsigned long ctrl;		/* Transfer control */
+	unsigned long chan_enable;	/* Channel enable */
+	unsigned long xfer_enable;	/* Transfer enable */
+	unsigned long xfer_stat;	/* Transfer status */
+} __attribute__ ((aligned(32)));
+
+struct g2_status {
+	unsigned long g2_addr;
+	unsigned long root_addr;
+	unsigned long size;
+	unsigned long status;
+} __attribute__ ((aligned(16)));
+
+struct g2_dma_info {
+	struct g2_channel channel[G2_NR_DMA_CHANNELS];
+	unsigned long pad1[G2_NR_DMA_CHANNELS];
+	unsigned long wait_state;
+	unsigned long pad2[10];
+	unsigned long magic;
+	struct g2_status status[G2_NR_DMA_CHANNELS];
+} __attribute__ ((aligned(256)));
+
+static volatile struct g2_dma_info *g2_dma = (volatile struct g2_dma_info *)0xa05f7800;
+
+static irqreturn_t g2_dma_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+	/* FIXME: Do some meaningful completion work here.. */
+	return IRQ_HANDLED;
+}
+
+static struct irqaction g2_dma_irq = {
+	.name		= "g2 DMA handler",
+	.handler	= g2_dma_interrupt,
+	.flags		= SA_INTERRUPT,
+};
+
+static int g2_enable_dma(struct dma_info *info)
+{
+	unsigned int chan = info->chan;
+
+	g2_dma->channel[chan].chan_enable = 1;
+	g2_dma->channel[chan].xfer_enable = 1;
+
+	return 0;
+}
+
+static int g2_disable_dma(struct dma_info *info)
+{
+	unsigned int chan = info->chan;
+
+	g2_dma->channel[chan].chan_enable = 0;
+	g2_dma->channel[chan].xfer_enable = 0;
+
+	return 0;
+}
+
+static int g2_xfer_dma(struct dma_info *info)
+{
+	unsigned int chan = info->chan;
+
+	if (info->sar & 31) {
+		printk("g2dma: unaligned source 0x%lx\n", info->sar);
+		return -EINVAL;
+	}
+
+	if (info->dar & 31) {
+		printk("g2dma: unaligned dest 0x%lx\n", info->dar);
+		return -EINVAL;
+	}
+
+	/* Align the count */
+	if (info->count & 31)
+		info->count = (info->count + (32 - 1)) & ~(32 - 1);
+
+	/* Fixup destination */
+	info->dar += 0xa0800000;
+
+	/* Fixup direction */
+	info->mode = !info->mode;
+
+	flush_icache_range((unsigned long)info->sar, info->count);
+
+	g2_disable_dma(info);
+
+	g2_dma->channel[chan].g2_addr	= info->dar & 0x1fffffe0;
+	g2_dma->channel[chan].root_addr = info->sar & 0x1fffffe0;
+	g2_dma->channel[chan].size	= (info->count & ~31) | 0x80000000;
+	g2_dma->channel[chan].direction = info->mode;
+
+	/*
+	 * bit 0 - ???
+	 * bit 1 - if set, generate a hardware event on transfer completion
+	 * bit 2 - ??? something to do with suspend?
+	 */
+	g2_dma->channel[chan].ctrl	= 5; /* ?? */
+
+	g2_enable_dma(info);
+	
+	/* debug cruft */
+	pr_debug("count, sar, dar, mode, ctrl, chan, xfer: %ld, 0x%08lx, "
+		 "0x%08lx, %ld, %ld, %ld, %ld\n",
+		 g2_dma->channel[chan].size,
+		 g2_dma->channel[chan].root_addr,
+		 g2_dma->channel[chan].g2_addr,
+		 g2_dma->channel[chan].direction,
+		 g2_dma->channel[chan].ctrl,
+		 g2_dma->channel[chan].chan_enable,
+		 g2_dma->channel[chan].xfer_enable);
+
+	return 0;
+}
+
+static struct dma_ops g2_dma_ops = {
+	.name		= "G2 DMA",
+	.xfer		= g2_xfer_dma,
+};
+
+static int __init g2_dma_init(void)
+{
+	int i, base;
+
+	setup_irq(HW_EVENT_G2_DMA, &g2_dma_irq);
+
+	/* Magic */
+	g2_dma->wait_state	= 27;
+	g2_dma->magic		= 0x4659404f;
+
+	/* G2 channels come after on-chip and pvr2 */
+	base = ONCHIP_NR_DMA_CHANNELS + PVR2_NR_DMA_CHANNELS;
+
+	for (i = 0; i < G2_NR_DMA_CHANNELS; i++)
+		dma_info[base + i].ops = &g2_dma_ops;
+	
+	return register_dmac(&g2_dma_ops);
+}
+
+static void __exit g2_dma_exit(void)
+{
+	free_irq(HW_EVENT_G2_DMA, 0);
+}
+
+subsys_initcall(g2_dma_init);
+module_exit(g2_dma_exit);
+
+MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>");
+MODULE_DESCRIPTION("G2 bus DMA driver");
+MODULE_LICENSE("GPL");
+
diff -puN /dev/null arch/sh/drivers/dma/dma-isa.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/dma/dma-isa.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,93 @@
+/*
+ * arch/sh/drivers/dma/dma-isa.c
+ *
+ * Generic ISA DMA wrapper for SH DMA API
+ *
+ * Copyright (C) 2003  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */ 
+#include <linux/kernel.h>
+#include <asm/dma.h>
+
+/*
+ * This implements a small wrapper set to make code using the old ISA DMA API
+ * work with the SH DMA API. Since most of the work in the new API happens
+ * at ops->xfer() time, we simply use the various set_dma_xxx() routines to
+ * fill in per-channel info, and then hand hand this off to ops->xfer() at
+ * enable_dma() time.
+ *
+ * For channels that are doing on-demand data transfer via cascading, the
+ * channel itself will still need to be configured through the new API. As
+ * such, this code is meant for only the simplest of tasks (and shouldn't be
+ * used in any new drivers at all).
+ *
+ * It should also be noted that various functions here are labelled as
+ * being deprecated. This is due to the fact that the ops->xfer() method is
+ * the preferred way of doing things (as well as just grabbing the spinlock
+ * directly). As such, any users of this interface will be warned rather
+ * loudly.
+ */
+
+unsigned long __deprecated claim_dma_lock(void)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&dma_spin_lock, flags);
+
+	return flags;
+}
+
+void __deprecated release_dma_lock(unsigned long flags)
+{
+	spin_unlock_irqrestore(&dma_spin_lock, flags);
+}
+
+void __deprecated disable_dma(unsigned int chan)
+{
+	/* Nothing */
+}
+
+void __deprecated enable_dma(unsigned int chan)
+{
+	struct dma_info *info = get_dma_info(chan);
+
+	info->ops->xfer(info);
+}
+
+void clear_dma_ff(unsigned int chan)
+{
+	/* Nothing */
+}
+
+void set_dma_mode(unsigned int chan, char mode)
+{
+	struct dma_info *info = get_dma_info(chan);
+
+	info->mode = mode;
+}
+
+void set_dma_addr(unsigned int chan, unsigned int addr)
+{
+	struct dma_info *info = get_dma_info(chan);
+
+	/*
+	 * Single address mode is the only thing supported through
+	 * this interface.
+	 */
+	if ((info->mode & DMA_MODE_MASK) == DMA_MODE_READ) {
+		info->sar = addr;
+	} else {
+		info->dar = addr;
+	}
+}
+
+void set_dma_count(unsigned int chan, unsigned int count)
+{
+	struct dma_info *info = get_dma_info(chan);
+
+	info->count = count;
+}
+
diff -puN /dev/null arch/sh/drivers/dma/dma-pvr2.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/dma/dma-pvr2.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,111 @@
+/*
+ * arch/sh/boards/dreamcast/dma-pvr2.c
+ *
+ * NEC PowerVR 2 (Dreamcast) DMA support
+ *
+ * Copyright (C) 2003  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <asm/mach/sysasic.h>
+#include <asm/mach/dma.h>
+#include <asm/dma.h>
+#include <asm/io.h>
+
+static unsigned int xfer_complete = 0;
+static int count = 0;
+
+static irqreturn_t pvr2_dma_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+	if (get_dma_residue(PVR2_CASCADE_CHAN)) {
+		printk(KERN_WARNING "DMA: SH DMAC did not complete transfer "
+		       "on channel %d, waiting..\n", PVR2_CASCADE_CHAN);
+		dma_wait_for_completion(PVR2_CASCADE_CHAN);
+	}
+
+	if (count++ < 10)
+		pr_debug("Got a pvr2 dma interrupt for channel %d\n",
+			 irq - HW_EVENT_PVR2_DMA);
+
+	xfer_complete = 1;
+
+	return IRQ_HANDLED;
+}
+
+static int pvr2_request_dma(struct dma_info *info)
+{
+	if (ctrl_inl(PVR2_DMA_MODE) != 0)
+		return -EBUSY;
+
+	ctrl_outl(0, PVR2_DMA_LMMODE0);
+
+	return 0;
+}
+
+static int pvr2_get_dma_residue(struct dma_info *info)
+{
+	return xfer_complete == 0;
+}
+
+static int pvr2_xfer_dma(struct dma_info *info)
+{
+	if (info->sar || !info->dar)
+		return -EINVAL;
+
+	xfer_complete = 0;
+
+	ctrl_outl(info->dar, PVR2_DMA_ADDR);
+	ctrl_outl(info->count, PVR2_DMA_COUNT);
+	ctrl_outl(info->mode & DMA_MODE_MASK, PVR2_DMA_MODE);
+
+	return 0;
+}
+
+static struct irqaction pvr2_dma_irq = {
+	.name		= "pvr2 DMA handler",
+	.handler	= pvr2_dma_interrupt,
+	.flags		= SA_INTERRUPT,
+};
+
+static struct dma_ops pvr2_dma_ops = {
+	.name		= "PowerVR 2 DMA",
+	.request	= pvr2_request_dma,
+	.get_residue	= pvr2_get_dma_residue,
+	.xfer		= pvr2_xfer_dma,
+};
+
+static int __init pvr2_dma_init(void)
+{
+	int i, base;
+
+	setup_irq(HW_EVENT_PVR2_DMA, &pvr2_dma_irq);
+	request_dma(PVR2_CASCADE_CHAN, "pvr2 cascade");
+
+	/* PVR2 cascade comes after on-chip DMAC */
+	base = ONCHIP_NR_DMA_CHANNELS;
+
+	for (i = 0; i < PVR2_NR_DMA_CHANNELS; i++)
+		dma_info[base + i].ops = &pvr2_dma_ops;
+
+	return register_dmac(&pvr2_dma_ops);
+}
+
+static void __exit pvr2_dma_exit(void)
+{
+	free_dma(PVR2_CASCADE_CHAN);
+	free_irq(HW_EVENT_PVR2_DMA, 0);
+}
+
+subsys_initcall(pvr2_dma_init);
+module_exit(pvr2_dma_exit);
+
+MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>");
+MODULE_DESCRIPTION("NEC PowerVR 2 DMA driver");
+MODULE_LICENSE("GPL");
+
diff -puN /dev/null arch/sh/drivers/dma/dma-sh.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/dma/dma-sh.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,271 @@
+/*
+ * arch/sh/kernel/cpu/dma.c
+ *
+ * Copyright (C) 2000 Takashi YOSHII
+ * Copyright (C) 2003 Paul Mundt
+ *
+ * PC like DMA API for SuperH's DMAC.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <asm/signal.h>
+#include <asm/irq.h>
+#include <asm/dma.h>
+#include <asm/io.h>
+#include "dma-sh.h"
+
+/*
+ * The SuperH DMAC supports a number of transmit sizes, we list them here,
+ * with their respective values as they appear in the CHCR registers.
+ *
+ * Defaults to a 64-bit transfer size.
+ */
+enum {
+	XMIT_SZ_64BIT	= 0,
+	XMIT_SZ_8BIT	= 1,
+	XMIT_SZ_16BIT	= 2,
+	XMIT_SZ_32BIT	= 3,
+	XMIT_SZ_256BIT	= 4,
+};
+
+/*
+ * The DMA count is defined as the number of bytes to transfer.
+ */
+static unsigned int ts_shift[] = {
+	[XMIT_SZ_64BIT]		3,
+	[XMIT_SZ_8BIT]		0,
+	[XMIT_SZ_16BIT]		1,
+	[XMIT_SZ_32BIT]		2,
+	[XMIT_SZ_256BIT]	5,
+};
+
+struct sh_dmac_channel {
+        unsigned long sar;
+        unsigned long dar;
+        unsigned long dmatcr;
+        unsigned long chcr;
+} __attribute__ ((aligned(16)));
+
+struct sh_dmac_info {
+        struct sh_dmac_channel channel[MAX_DMAC_CHANNELS];
+        unsigned long dmaor;
+} __attribute__ ((packed));
+
+static volatile struct sh_dmac_info *sh_dmac = (volatile struct sh_dmac_info *)SH_DMAC_BASE;
+
+static inline unsigned int get_dmte_irq(unsigned int chan)
+{
+	unsigned int irq;
+
+	/* 
+	 * Normally we could just do DMTE0_IRQ + chan outright, though in the
+	 * case of the 7751R, the DMTE IRQs for channels > 4 start right above
+	 * the SCIF
+	 */
+
+	if (chan < 4) {
+		irq = DMTE0_IRQ + chan;
+	} else {
+		irq = DMTE4_IRQ + chan;
+	}
+
+	return irq;
+}
+
+static inline int get_dmte_chan(unsigned int irq)
+{
+	int chan;
+
+	if ((irq - DMTE4_IRQ) < 0) {
+		chan = irq - DMTE0_IRQ;
+	} else {
+		chan = irq - DMTE4_IRQ + 4;
+	}
+
+	return chan;
+}
+
+/*
+ * We determine the correct shift size based off of the CHCR transmit size
+ * for the given channel. Since we know that it will take:
+ *
+ * 	info->count >> ts_shift[transmit_size]
+ *
+ * iterations to complete the transfer.
+ */
+static inline unsigned int calc_xmit_shift(struct dma_info *info)
+{
+	return ts_shift[(sh_dmac->channel[info->chan].chcr >> 4) & 0x0007];
+}
+
+static irqreturn_t dma_tei(int irq, void *dev_id, struct pt_regs *regs)
+{
+	
+	int chan = get_dmte_chan(irq);
+	struct dma_info *info = get_dma_info(chan);
+
+	if (info->sar)
+		sh_dmac->channel[info->chan].sar = info->sar;
+	if (info->dar)
+		sh_dmac->channel[info->chan].sar = info->dar;
+
+	sh_dmac->channel[info->chan].dmatcr = info->count >> calc_xmit_shift(info);
+	sh_dmac->channel[info->chan].chcr &= ~CHCR_TE;
+
+	disable_irq(irq);
+
+	return IRQ_HANDLED;
+}
+
+static struct irqaction irq_tei = {
+	.name		= "DMAC Transfer End",
+	.handler	= dma_tei,
+	.flags		= SA_INTERRUPT,
+};
+
+static int sh_dmac_request_dma(struct dma_info *info)
+{
+	int irq = get_dmte_irq(info->chan);
+	char *p = (char *)((&irq_tei)->name);
+
+	sprintf(p, "%s (Channel %d)", p, info->chan);
+
+	make_ipr_irq(irq, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
+
+	return setup_irq(irq, &irq_tei);
+}
+
+static void sh_dmac_free_dma(struct dma_info *info)
+{
+	free_irq(get_dmte_irq(info->chan), 0);
+}
+
+static void sh_dmac_configure_channel(struct dma_info *info, unsigned long chcr)
+{
+	if (!chcr) {
+		chcr = sh_dmac->channel[info->chan].chcr;
+		chcr |= /* CHCR_IE | */ RS_DUAL;
+	}
+
+	sh_dmac->channel[info->chan].chcr = chcr;
+
+	info->configured = 1;
+}
+
+static void sh_dmac_enable_dma(struct dma_info *info)
+{
+	sh_dmac->channel[info->chan].chcr |= CHCR_DE;
+}
+
+static void sh_dmac_disable_dma(struct dma_info *info)
+{
+	sh_dmac->channel[info->chan].chcr &= ~(CHCR_DE | CHCR_TE);
+}
+
+static int sh_dmac_xfer_dma(struct dma_info *info)
+{
+	/* 
+	 * If we haven't pre-configured the channel with special flags, use
+	 * the defaults.
+	 */
+	if (!info->configured)
+		sh_dmac_configure_channel(info, 0);
+
+	sh_dmac_disable_dma(info);
+	
+	/* 
+	 * Single-address mode usage note!
+	 *
+	 * It's important that we don't accidentally write any value to SAR/DAR
+	 * (this includes 0) that hasn't been directly specified by the user if
+	 * we're in single-address mode.
+	 *
+	 * In this case, only one address can be defined, anything else will
+	 * result in a DMA address error interrupt (at least on the SH-4),
+	 * which will subsequently halt the transfer.
+	 */
+	if (info->sar)
+		sh_dmac->channel[info->chan].sar = info->sar;
+	if (info->dar)
+		sh_dmac->channel[info->chan].dar = info->dar;
+	
+	sh_dmac->channel[info->chan].dmatcr = info->count >> calc_xmit_shift(info);
+
+	sh_dmac_enable_dma(info);
+
+	return 0;
+}
+
+static int sh_dmac_get_dma_residue(struct dma_info *info)
+{
+	return sh_dmac->channel[info->chan].dmatcr << calc_xmit_shift(info);
+}
+
+#if defined(CONFIG_CPU_SH4)
+static irqreturn_t dma_err(int irq, void *dev_id, struct pt_regs *regs)
+{
+	printk("DMAE: DMAOR=%lx\n", sh_dmac->dmaor);
+
+	sh_dmac->dmaor &= ~(DMAOR_NMIF | DMAOR_AE);
+	sh_dmac->dmaor |= DMAOR_DME;
+
+	disable_irq(irq);
+
+	return IRQ_HANDLED;
+}
+
+static struct irqaction irq_err = {
+	.name		= "DMAC Address Error",
+	.handler	= dma_err,
+	.flags		= SA_INTERRUPT,
+};
+#endif
+
+static struct dma_ops sh_dmac_ops = {
+	.name		= "SuperH DMAC",
+	.request	= sh_dmac_request_dma,
+	.free		= sh_dmac_free_dma,
+	.get_residue	= sh_dmac_get_dma_residue,
+	.xfer		= sh_dmac_xfer_dma,
+	.configure	= sh_dmac_configure_channel,
+};
+	
+static int __init sh_dmac_init(void)
+{
+	int i;
+
+#ifdef CONFIG_CPU_SH4
+	make_ipr_irq(DMAE_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
+	setup_irq(DMAE_IRQ, &irq_err);
+#endif
+
+	/* Kick the DMAOR */
+	sh_dmac->dmaor |= DMAOR_DME /* | 0x200 */ | 0x8000;	/* DDT = 1, PR1 = 1, DME = 1 */
+	sh_dmac->dmaor &= ~(DMAOR_NMIF | DMAOR_AE);
+
+	for (i = 0; i < MAX_DMAC_CHANNELS; i++)
+		dma_info[i].ops  = &sh_dmac_ops;
+
+	return register_dmac(&sh_dmac_ops);
+}
+
+static void __exit sh_dmac_exit(void)
+{
+#ifdef CONFIG_CPU_SH4
+	free_irq(DMAE_IRQ, 0);
+#endif
+}
+
+subsys_initcall(sh_dmac_init);
+module_exit(sh_dmac_exit);
+
+MODULE_LICENSE("GPL");
+
diff -puN /dev/null arch/sh/drivers/dma/dma-sh.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/dma/dma-sh.h	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,48 @@
+/*
+ * arch/sh/drivers/dma/dma-sh.h
+ *
+ * Copyright (C) 2000  Takashi YOSHII
+ * Copyright (C) 2003  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#ifndef __DMA_SH_H
+#define __DMA_SH_H
+
+/* Definitions for the SuperH DMAC */
+#define REQ_L	0x00000000
+#define REQ_E	0x00080000
+#define RACK_H	0x00000000
+#define RACK_L	0x00040000
+#define ACK_R	0x00000000
+#define ACK_W	0x00020000
+#define ACK_H	0x00000000
+#define ACK_L	0x00010000
+#define DM_INC	0x00004000
+#define DM_DEC	0x00008000
+#define SM_INC	0x00001000
+#define SM_DEC	0x00002000
+#define RS_DUAL	0x00000000
+#define RS_IN	0x00000200
+#define RS_OUT	0x00000300
+#define TM_BURST 0x0000080
+#define TS_8	0x00000010
+#define TS_16	0x00000020
+#define TS_32	0x00000030
+#define TS_64	0x00000000
+#define TS_BLK	0x00000040
+#define CHCR_DE 0x00000001
+#define CHCR_TE 0x00000002
+#define CHCR_IE 0x00000004
+
+#define DMAOR_COD	0x00000008
+#define DMAOR_AE	0x00000004
+#define DMAOR_NMIF	0x00000002
+#define DMAOR_DME	0x00000001
+
+#define MAX_DMAC_CHANNELS	(CONFIG_NR_ONCHIP_DMA_CHANNELS)
+
+#endif /* __DMA_SH_H */
+
diff -puN /dev/null arch/sh/drivers/dma/Kconfig
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/dma/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,42 @@
+config SH_DMA
+	bool "DMA controller (DMAC) support"
+	help
+	  Selecting this option will provide same API as PC's Direct Memory
+	  Access Controller(8237A) for SuperH DMAC.
+
+	  If unsure, say N.
+
+config NR_ONCHIP_DMA_CHANNELS
+	depends on SH_DMA
+	int "Number of on-chip DMAC channels"
+	default "4"
+	help
+	  This allows you to specify the number of channels that the on-chip
+	  DMAC supports. This will be 4 for SH7750/SH7751 and 8 for the
+	  SH7750R/SH7751R.
+
+config NR_DMA_CHANNELS_BOOL
+	depends on SH_DMA
+	bool "Override default number of maximum DMA channels"
+	help
+	  This allows you to forcibly update the maximum number of supported
+	  DMA channels for a given board. If this is unset, this will default
+	  to the number of channels that the on-chip DMAC has.
+
+config NR_DMA_CHANNELS
+	int "Maximum number of DMA channels"
+	depends on SH_DMA && NR_DMA_CHANNELS_BOOL
+	default NR_ONCHIP_DMA_CHANNELS
+	help
+	  This allows you to specify the maximum number of DMA channels to
+	  support. Setting this to a higher value allows for cascading DMACs
+	  with additional channels.
+
+config DMA_PAGE_OPS
+	bool "Use DMAC for page copy/clear"
+	depends on SH_DMA
+	help
+	  Selecting this option will use a dual-address mode configured channel
+	  in the SH DMAC for copy_page()/clear_page(). Primarily a performance
+	  hack.
+
diff -puN /dev/null arch/sh/drivers/dma/Makefile
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/dma/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,8 @@
+#
+# Makefile for the SuperH DMA specific kernel interface routines under Linux.
+#
+
+obj-y				+= dma-api.o dma-isa.o
+obj-$(CONFIG_SH_DMA)		+= dma-sh.o
+obj-$(CONFIG_SH_DREAMCAST)	+= dma-pvr2.o dma-g2.o
+
diff -puN /dev/null arch/sh/drivers/Makefile
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,7 @@
+#
+# Makefile for the Linux SuperH-specific device drivers.
+#
+
+obj-$(CONFIG_PCI)	+= pci/
+obj-$(CONFIG_SH_DMA)	+= dma/
+
diff -puN /dev/null arch/sh/drivers/pci/dma-dreamcast.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/pci/dma-dreamcast.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,61 @@
+/*
+ * arch/sh/pci/dma-dreamcast.c
+ *
+ * PCI DMA support for the Sega Dreamcast
+ *
+ * Copyright (C) 2001, 2002  M. R. Brown
+ * Copyright (C) 2002, 2003  Paul Mundt
+ *
+ * This file originally bore the message (with enclosed-$):
+ *	Id: pci.c,v 1.3 2003/05/04 19:29:46 lethal Exp
+ *	Dreamcast PCI: Supports SEGA Broadband Adaptor only.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/config.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/param.h>
+#include <linux/interrupt.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/pci.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/mach/pci.h>
+
+static int gapspci_dma_used = 0;
+
+void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
+			   dma_addr_t * dma_handle)
+{
+	unsigned long buf;
+
+	if (gapspci_dma_used+size > GAPSPCI_DMA_SIZE)
+		return NULL;
+
+	buf = GAPSPCI_DMA_BASE+gapspci_dma_used;
+
+	gapspci_dma_used = PAGE_ALIGN(gapspci_dma_used+size);
+	
+	*dma_handle = (dma_addr_t)buf;
+
+	buf = P2SEGADDR(buf);
+
+	/* Flush the dcache before we hand off the buffer */
+	dma_cache_wback_inv((void *)buf, size);
+
+	return (void *)buf;
+}
+
+void pci_free_consistent(struct pci_dev *hwdev, size_t size,
+			 void *vaddr, dma_addr_t dma_handle)
+{
+	/* XXX */
+	gapspci_dma_used = 0;
+}
+
diff -puN /dev/null arch/sh/drivers/pci/fixups-dreamcast.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/pci/fixups-dreamcast.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,85 @@
+/*
+ * arch/sh/pci/fixups-dreamcast.c
+ *
+ * PCI fixups for the Sega Dreamcast
+ *
+ * Copyright (C) 2001, 2002  M. R. Brown
+ * Copyright (C) 2002, 2003  Paul Mundt
+ *
+ * This file originally bore the message (with enclosed-$):
+ *	Id: pci.c,v 1.3 2003/05/04 19:29:46 lethal Exp
+ *	Dreamcast PCI: Supports SEGA Broadband Adaptor only.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/config.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/param.h>
+#include <linux/interrupt.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/pci.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/mach/pci.h>
+
+static void __init gapspci_fixup_resources(struct pci_dev *dev)
+{
+	struct pci_channel *p = board_pci_channels;
+
+	printk(KERN_NOTICE "PCI: Fixing up device %s\n", pci_name(dev));
+
+	switch (dev->device) {
+	case PCI_DEVICE_ID_SEGA_BBA:
+		/*
+		 * We also assume that dev->devfn == 0
+		 */
+		dev->resource[1].start	= p->io_resource->start  + 0x100;
+		dev->resource[1].end	= dev->resource[1].start + 0x200 - 1;
+		break;
+	default:
+		printk("PCI: Failed resource fixup\n");
+	}
+}
+
+struct pci_fixup pcibios_fixups[] = {
+	{ PCI_FIXUP_HEADER, PCI_ANY_ID,
+	  PCI_ANY_ID, gapspci_fixup_resources },
+	{ 0, }
+};
+
+void __init pcibios_fixup_bus(struct pci_bus *bus)
+{
+	/* 
+	 * We don't have any sub bus to fix up, and this is a rather
+	 * stupid place to put general device fixups. Don't do it.
+	 * Use the pcibios_fixups table or suffer the consequences.
+	 */
+}
+
+void __init pcibios_fixup_irqs(void)
+{
+	struct pci_dev *dev = 0;
+
+	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+		/*
+		 * The interrupt routing semantics here are quite trivial.
+		 *
+		 * We basically only support one interrupt, so we only bother
+		 * updating a device's interrupt line with this single shared
+		 * interrupt. Keeps routing quite simple, doesn't it?
+		 */
+		printk(KERN_NOTICE "PCI: Fixing up IRQ routing for device %s\n",
+		       pci_name(dev));
+
+		dev->irq = GAPSPCI_IRQ;
+
+		pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
+	}
+}
+
diff -puN /dev/null arch/sh/drivers/pci/Kconfig
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/pci/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,46 @@
+config PCI
+	bool "PCI support"
+	help
+	  Find out whether you have a PCI motherboard. PCI is the name of a
+	  bus system, i.e. the way the CPU talks to the other stuff inside
+	  your box. Other bus systems are ISA, EISA, MicroChannel (MCA) or
+	  VESA. If you have PCI, say Y, otherwise N.
+
+	  The PCI-HOWTO, available from
+	  <http://www.tldp.org/docs.html#howto>, contains valuable
+	  information about which PCI hardware does work under Linux and which
+	  doesn't.
+
+config SH_PCIDMA_NONCOHERENT
+	bool "Cache and PCI noncoherent"
+	depends on PCI
+	help
+	  Enable this option if your platform does not have a CPU cache which
+	  remains coherent with PCI DMA. It is safest to say 'Y', although you
+	  will see better performance if you can say 'N', because the PCI DMA
+	  code will not have to flush the CPU's caches. If you have a PCI host
+	  bridge integrated with your SH CPU, refer carefully to the chip specs
+	  to see if you can say 'N' here. Otherwise, leave it as 'Y'.
+
+# This is also board-specific
+config PCI_AUTO
+	bool
+	depends on PCI
+	default y
+
+config PCI_AUTO_UPDATE_RESOURCES
+	bool
+	depends on PCI_AUTO
+	default y if !SH_DREAMCAST
+	help
+	  Selecting this option will cause the PCI auto code to leave your
+	  BAR values alone. Otherwise they will be updated automatically. If
+	  for some reason, you have a board that simply refuses to work
+	  with its resources updated beyond what they are when the device
+	  is powered up, set this to N. Everyone else will want this as Y.
+
+config PCI_DMA
+	bool
+	depends on PCI
+	default y if !SH_DREAMCAST
+
diff -puN /dev/null arch/sh/drivers/pci/Makefile
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/pci/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,16 @@
+#
+# Makefile for the PCI specific kernel interface routines under Linux.
+#
+
+obj-y					+= pci.o
+obj-$(CONFIG_PCI_AUTO)			+= pci-auto.o
+obj-$(CONFIG_PCI_DMA)			+= pci-dma.o
+
+obj-$(CONFIG_CPU_SUBTYPE_ST40STB1)	+= pci-st40.o
+obj-$(CONFIG_CPU_SUBTYPE_SH7751)	+= pci-sh7751.o 
+
+obj-$(CONFIG_SH_DREAMCAST)		+= ops-dreamcast.o fixups-dreamcast.o \
+					   dma-dreamcast.o
+obj-$(CONFIG_SH_SECUREEDGE5410)		+= ops-snapgear.o
+obj-$(CONFIG_SH_BIGSUR)			+= ops-bigsur.o
+
diff -puN /dev/null arch/sh/drivers/pci/ops-bigsur.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/pci/ops-bigsur.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,88 @@
+/*
+ * linux/arch/sh/kernel/pci-bigsur.c
+ *
+ * By Dustin McIntire (dustin@sensoria.com) (c)2001
+ *
+ * Ported to new API by Paul Mundt <lethal@linux-sh.org>.
+ *
+ * May be copied or modified under the terms of the GNU General Public
+ * License.  See linux/COPYING for more information.
+ *
+ * PCI initialization for the Hitachi Big Sur Evaluation Board
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/pci.h>
+
+#include <asm/io.h>
+#include "pci-sh7751.h"
+#include <asm/bigsur/bigsur.h>
+
+#define BIGSUR_PCI_IO	0x4000
+#define BIGSUR_PCI_MEM	0xfd000000
+
+static struct resource sh7751_io_resource = {
+	.name		= "SH7751 IO",
+	.start		= BIGSUR_PCI_IO,
+	.end		= BIGSUR_PCI_IO + (64*1024) - 1,
+	.flags		= IORESOURCE_IO,
+};
+
+static struct resource sh7751_mem_resource = {
+	.name		= "SH7751 mem",
+	.start		= BIGSUR_PCI_MEM,
+	.end		= BIGSUR_PCI_MEM + (64*1024*1024) - 1,
+	.flags		= IORESOURCE_MEM,
+};
+
+extern struct pci_ops sh7751_pci_ops;
+
+struct pci_channel board_pci_channels[] = {
+	{ &sh7751_pci_ops, &sh7751_io_resource, &sh7751_mem_resource, 0, 0xff },
+	{ 0, }
+};
+
+static struct sh7751_pci_address_map sh7751_pci_map = {
+	.window0	= {
+		.base	= SH7751_CS3_BASE_ADDR,
+		.size	= BIGSUR_LSR0_SIZE,
+	},
+
+	.window1	= {
+		.base	= SH7751_CS3_BASE_ADDR,
+		.size	= BIGSUR_LSR1_SIZE,
+	},
+};
+
+/*
+ * Initialize the Big Sur PCI interface 
+ * Setup hardware to be Central Funtion
+ * Copy the BSR regs to the PCI interface
+ * Setup PCI windows into local RAM
+ */
+int __init pcibios_init_platform(void)
+{
+	return sh7751_pcic_init(&sh7751_pci_map);
+}
+
+int pcibios_map_platform_irq(u8 slot, u8 pin)
+{
+	/* 
+	 * The Big Sur can be used in a CPCI chassis, but the SH7751 PCI
+	 * interface is on the wrong end of the board so that it can also
+	 * support a V320 CPI interface chip...  Therefor the IRQ mapping is
+	 * somewhat use dependent... I'l assume a linear map for now, i.e.
+	 * INTA=slot0,pin0... INTD=slot3,pin0...
+	 */ 
+	int irq = (slot + pin-1) % 4 + BIGSUR_SH7751_PCI_IRQ_BASE;
+
+	PCIDBG(2, "PCI: Mapping Big Sur IRQ for slot %d, pin %c to irq %d\n",
+	       slot, pin-1+'A', irq);
+
+	return irq;
+}
+
diff -puN /dev/null arch/sh/drivers/pci/ops-dreamcast.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/pci/ops-dreamcast.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,169 @@
+/*
+ * arch/sh/pci/ops-dreamcast.c
+ *
+ * PCI operations for the Sega Dreamcast
+ *
+ * Copyright (C) 2001, 2002  M. R. Brown
+ * Copyright (C) 2002, 2003  Paul Mundt
+ *
+ * This file originally bore the message (with enclosed-$):
+ *	Id: pci.c,v 1.3 2003/05/04 19:29:46 lethal Exp
+ *	Dreamcast PCI: Supports SEGA Broadband Adaptor only.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/config.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/param.h>
+#include <linux/interrupt.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/pci.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/mach/pci.h>
+
+static struct resource gapspci_io_resource = {
+	.name	= "GAPSPCI IO",
+	.start	= GAPSPCI_BBA_CONFIG,
+	.end	= GAPSPCI_BBA_CONFIG + GAPSPCI_BBA_CONFIG_SIZE - 1,
+	.flags	= IORESOURCE_IO,
+};
+
+static struct resource gapspci_mem_resource = {
+	.name	= "GAPSPCI mem",
+	.start	= GAPSPCI_DMA_BASE,
+	.end	= GAPSPCI_DMA_BASE + GAPSPCI_DMA_SIZE - 1,
+	.flags	= IORESOURCE_MEM,
+};
+
+static struct pci_ops gapspci_pci_ops;
+
+struct pci_channel board_pci_channels[] = {
+	{ &gapspci_pci_ops, &gapspci_io_resource,
+	  &gapspci_mem_resource, 0, 1 },
+	{ 0, }
+};
+
+/*
+ * The !gapspci_config_access case really shouldn't happen, ever, unless
+ * someone implicitly messes around with the last devfn value.. otherwise we
+ * only support a single device anyways, and if we didn't have a BBA, we
+ * wouldn't make it terribly far through the PCI setup anyways.
+ *
+ * Also, we could very easily support both Type 0 and Type 1 configurations
+ * here, but since it doesn't seem that there is any such implementation in
+ * existance, we don't bother.
+ *
+ * I suppose if someone actually gets around to ripping the chip out of
+ * the BBA and hanging some more devices off of it, then this might be
+ * something to take into consideration. However, due to the cost of the BBA,
+ * and the general lack of activity by DC hardware hackers, this doesn't seem
+ * likely to happen anytime soon.
+ */
+static int gapspci_config_access(unsigned char bus, unsigned int devfn)
+{
+	return (bus == 0) && (devfn == 0);
+}
+
+/*
+ * We can also actually read and write in b/w/l sizes! Thankfully this part
+ * was at least done right, and we don't have to do the stupid masking and
+ * shifting that we do on the 7751! Small wonders never cease to amaze.
+ */
+static int gapspci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val)
+{
+	*val = 0xffffffff;
+
+	if (!gapspci_config_access(bus->number, devfn))
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
+	switch (size) {
+		case 1: *val = inb(GAPSPCI_BBA_CONFIG+where); break;
+		case 2: *val = inw(GAPSPCI_BBA_CONFIG+where); break;
+		case 4: *val = inl(GAPSPCI_BBA_CONFIG+where); break;
+	}	
+
+        return PCIBIOS_SUCCESSFUL;
+}
+
+static int gapspci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val)
+{
+	if (!gapspci_config_access(bus->number, devfn))
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
+	switch (size) {
+		case 1: outb(( u8)val, GAPSPCI_BBA_CONFIG+where); break;
+		case 2: outw((u16)val, GAPSPCI_BBA_CONFIG+where); break;
+		case 4: outl((u32)val, GAPSPCI_BBA_CONFIG+where); break;
+	}
+
+        return PCIBIOS_SUCCESSFUL;
+}
+
+static struct pci_ops gapspci_pci_ops = {
+	.read	= gapspci_read,
+	.write	= gapspci_write,
+};
+
+/*
+ * gapspci init
+ */
+
+int __init gapspci_init(void)
+{
+	char idbuf[16];
+	int i;
+
+	/*
+	 * FIXME: All of this wants documenting to some degree,
+	 * even some basic register definitions would be nice.
+	 *
+	 * I haven't seen anything this ugly since.. maple.
+	 */
+
+	for (i=0; i<16; i++)
+		idbuf[i] = inb(GAPSPCI_REGS+i);
+
+	if (strncmp(idbuf, "GAPSPCI_BRIDGE_2", 16))
+		return -ENODEV;
+
+	outl(0x5a14a501, GAPSPCI_REGS+0x18);
+
+	for (i=0; i<1000000; i++)
+		;
+
+	if (inl(GAPSPCI_REGS+0x18) != 1)
+		return -EINVAL;
+
+	outl(0x01000000, GAPSPCI_REGS+0x20);
+	outl(0x01000000, GAPSPCI_REGS+0x24);
+
+	outl(GAPSPCI_DMA_BASE, GAPSPCI_REGS+0x28);
+	outl(GAPSPCI_DMA_BASE+GAPSPCI_DMA_SIZE, GAPSPCI_REGS+0x2c);
+
+	outl(1, GAPSPCI_REGS+0x14);
+	outl(1, GAPSPCI_REGS+0x34);
+
+	/* Setting Broadband Adapter */
+	outw(0xf900, GAPSPCI_BBA_CONFIG+0x06);
+	outl(0x00000000, GAPSPCI_BBA_CONFIG+0x30);
+	outb(0x00, GAPSPCI_BBA_CONFIG+0x3c);
+	outb(0xf0, GAPSPCI_BBA_CONFIG+0x0d);
+	outw(0x0006, GAPSPCI_BBA_CONFIG+0x04);
+	outl(0x00002001, GAPSPCI_BBA_CONFIG+0x10);
+	outl(0x01000000, GAPSPCI_BBA_CONFIG+0x14);
+
+	return 0;
+}
+
+/* Haven't done anything here as yet */
+char * __devinit pcibios_setup(char *str)
+{
+	return str;
+}
diff -puN /dev/null arch/sh/drivers/pci/ops-snapgear.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/pci/ops-snapgear.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,100 @@
+/*
+ * arch/sh/drivers/pci/ops-snapgear.c
+ *
+ * Author:  David McCullough <davidm@snapgear.com>
+ * 
+ * Ported to new API by Paul Mundt <lethal@linux-sh.org>
+ *
+ * Highly leveraged from pci-bigsur.c, written by Dustin McIntire.
+ *
+ * May be copied or modified under the terms of the GNU General Public
+ * License.  See linux/COPYING for more information.
+ *
+ * PCI initialization for the SnapGear boards
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/pci.h>
+
+#include <asm/io.h>
+#include "pci-sh7751.h"
+
+#define SNAPGEAR_PCI_IO		0x4000
+#define SNAPGEAR_PCI_MEM	0xfd000000
+
+/* PCI: default LOCAL memory window sizes (seen from PCI bus) */
+#define SNAPGEAR_LSR0_SIZE    (64*(1<<20)) //64MB
+#define SNAPGEAR_LSR1_SIZE    (64*(1<<20)) //64MB
+
+static struct resource sh7751_io_resource = {
+	.name		= "SH7751 IO",
+	.start		= SNAPGEAR_PCI_IO,
+	.end		= SNAPGEAR_PCI_IO + (64*1024) - 1, /* 64KiB I/O */
+	.flags		= IORESOURCE_IO,
+};
+
+static struct resource sh7751_mem_resource = {
+	.name		= "SH7751 mem",
+	.start		= SNAPGEAR_PCI_MEM,
+	.end		= SNAPGEAR_PCI_MEM + (64*1024*1024) - 1, /* 64MiB mem */
+	.flags		= IORESOURCE_MEM,
+};
+
+extern struct pci_ops sh7751_pci_ops;
+
+struct pci_channel board_pci_channels[] = {
+	{ &sh7751_pci_ops, &sh7751_io_resource, &sh7751_mem_resource, 0, 0xff },
+	{ 0, }
+};
+
+static struct sh7751_pci_address_map sh7751_pci_map = {
+	.window0	= {
+		.base	= SH7751_CS2_BASE_ADDR,
+		.size	= SNAPGEAR_LSR0_SIZE,
+	},
+
+	.window1	= {
+		.base	= SH7751_CS2_BASE_ADDR,
+		.size	= SNAPGEAR_LSR1_SIZE,
+	},
+};
+
+/*
+ * Initialize the SnapGear PCI interface 
+ * Setup hardware to be Central Funtion
+ * Copy the BSR regs to the PCI interface
+ * Setup PCI windows into local RAM
+ */
+int __init pcibios_init_platform(void)
+{
+	return sh7751_pcic_init(&sh7751_pci_map);
+}
+
+int __init pcibios_map_platform_irq(u8 slot, u8 pin)
+{
+	int irq = -1;
+
+	switch (slot) {
+	case 8:  /* the PCI bridge */ break;
+	case 11: irq = 8;  break; /* USB    */
+	case 12: irq = 11; break; /* PCMCIA */
+	case 13: irq = 5;  break; /* eth0   */
+	case 14: irq = 8;  break; /* eth1   */
+	case 15: irq = 11; break; /* safenet (unused) */
+	}
+
+	printk("PCI: Mapping SnapGear IRQ for slot %d, pin %c to irq %d\n",
+	       slot, pin - 1 + 'A', irq);
+
+	return irq;
+}
+
+void __init pcibios_fixup(void)
+{
+	/* Nothing to fixup .. */
+}
+
diff -puN /dev/null arch/sh/drivers/pci/pci-auto.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/pci/pci-auto.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,534 @@
+/*
+ * PCI autoconfiguration library
+ *
+ * Author: Matt Porter <mporter@mvista.com>
+ *
+ * Copyright 2000, 2001 MontaVista Software Inc.
+ * Copyright 2001 Bradley D. LaRonde <brad@ltc.com>
+ * Copyright 2003 Paul Mundt <lethal@linux-sh.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.
+ */
+
+/*
+ * Modified for MIPS by Jun Sun, jsun@mvista.com
+ *
+ * . Simplify the interface between pci_auto and the rest: a single function.
+ * . Assign resources from low address to upper address.
+ * . change most int to u32.
+ *
+ * Further modified to include it as mips generic code, ppopov@mvista.com.
+ *
+ * 2001-10-26  Bradley D. LaRonde <brad@ltc.com>
+ * - Add a top_bus argument to the "early config" functions so that
+ *   they can set a fake parent bus pointer to convince the underlying
+ *   pci ops to use type 1 configuration for sub busses.
+ * - Set bridge base and limit registers correctly.
+ * - Align io and memory base properly before and after bridge setup.
+ * - Don't fall through to pci_setup_bars for bridge.
+ * - Reformat the debug output to look more like lspci's output.
+ *
+ * Cloned for SuperH by M. R. Brown, mrbrown@0xd6.org
+ *
+ * 2003-08-05  Paul Mundt <lethal@linux-sh.org>
+ * - Don't update the BAR values on systems that already have valid addresses
+ *   and don't want these updated for whatever reason, by way of a new config
+ *   option check. However, we still read in the old BAR values so that they
+ *   can still be reported through the debug output.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+
+#define	DEBUG
+#ifdef 	DEBUG
+#define	DBG(x...)	printk(x)
+#else
+#define	DBG(x...)	
+#endif
+
+/*
+ * These functions are used early on before PCI scanning is done
+ * and all of the pci_dev and pci_bus structures have been created.
+ */
+static struct pci_dev *fake_pci_dev(struct pci_channel *hose,
+	int top_bus, int busnr, int devfn)
+{
+	static struct pci_dev dev;
+	static struct pci_bus bus;
+
+	dev.bus = &bus;
+	dev.sysdata = hose;
+	dev.devfn = devfn;
+	bus.number = busnr;
+	bus.ops = hose->pci_ops;
+
+	if(busnr != top_bus)
+		/* Fake a parent bus structure. */
+		bus.parent = &bus;
+	else
+		bus.parent = NULL;
+
+	return &dev;
+}
+
+#define EARLY_PCI_OP(rw, size, type)					\
+int early_##rw##_config_##size(struct pci_channel *hose,		\
+	int top_bus, int bus, int devfn, int offset, type value)	\
+{									\
+	return pci_##rw##_config_##size(				\
+		fake_pci_dev(hose, top_bus, bus, devfn),		\
+		offset, value);						\
+}
+
+EARLY_PCI_OP(read, byte, u8 *)
+EARLY_PCI_OP(read, word, u16 *)
+EARLY_PCI_OP(read, dword, u32 *)
+EARLY_PCI_OP(write, byte, u8)
+EARLY_PCI_OP(write, word, u16)
+EARLY_PCI_OP(write, dword, u32)
+
+static struct resource *io_resource_inuse;
+static struct resource *mem_resource_inuse;
+
+static u32 pciauto_lower_iospc;
+static u32 pciauto_upper_iospc;
+
+static u32 pciauto_lower_memspc;
+static u32 pciauto_upper_memspc;
+
+static void __init 
+pciauto_setup_bars(struct pci_channel *hose,
+		   int top_bus,
+		   int current_bus,
+		   int pci_devfn)
+{
+	u32 bar_response, bar_size, bar_value;
+	u32 bar, addr_mask, bar_nr = 0;
+	u32 * upper_limit;
+	u32 * lower_limit;
+	int found_mem64 = 0;
+
+	for (bar = PCI_BASE_ADDRESS_0; bar <= PCI_BASE_ADDRESS_5; bar+=4) {
+		u32 bar_addr;
+
+		/* Read the old BAR value */
+		early_read_config_dword(hose, top_bus,
+					current_bus,
+					pci_devfn,
+					bar,
+					&bar_addr);
+
+		/* Tickle the BAR and get the response */
+		early_write_config_dword(hose, top_bus,
+					 current_bus,
+					 pci_devfn,
+					 bar,
+					 0xffffffff);
+
+		early_read_config_dword(hose, top_bus,
+					current_bus,
+					pci_devfn,
+					bar,
+					&bar_response);
+
+		/* 
+		 * Write the old BAR value back out, only update the BAR
+		 * if we implicitly want resources to be updated, which
+		 * is done by the generic code further down. -- PFM.
+		 */
+		early_write_config_dword(hose, top_bus,
+					 current_bus,
+					 pci_devfn,
+					 bar,
+					 bar_addr);
+
+		/* If BAR is not implemented go to the next BAR */
+		if (!bar_response)
+			continue;
+
+		/*
+		 * Workaround for a BAR that doesn't use its upper word,
+		 * like the ALi 1535D+ PCI DC-97 Controller Modem (M5457).
+		 * bdl <brad@ltc.com>
+		 */
+		if (!(bar_response & 0xffff0000))
+			bar_response |= 0xffff0000;
+
+retry:
+		/* Check the BAR type and set our address mask */
+		if (bar_response & PCI_BASE_ADDRESS_SPACE) {
+			addr_mask = PCI_BASE_ADDRESS_IO_MASK;
+			upper_limit = &pciauto_upper_iospc;
+			lower_limit = &pciauto_lower_iospc;
+			DBG("        I/O");
+		} else {
+			if ((bar_response & PCI_BASE_ADDRESS_MEM_TYPE_MASK) ==
+			    PCI_BASE_ADDRESS_MEM_TYPE_64)
+				found_mem64 = 1;
+
+			addr_mask = PCI_BASE_ADDRESS_MEM_MASK;		
+			upper_limit = &pciauto_upper_memspc;
+			lower_limit = &pciauto_lower_memspc;
+			DBG("        Mem");
+		}
+
+
+		/* Calculate requested size */
+		bar_size = ~(bar_response & addr_mask) + 1;
+
+		/* Allocate a base address */
+		bar_value = ((*lower_limit - 1) & ~(bar_size - 1)) + bar_size;
+
+		if ((bar_value + bar_size) > *upper_limit) {
+			if (bar_response & PCI_BASE_ADDRESS_SPACE) {
+				if (io_resource_inuse->child) {
+					io_resource_inuse = 
+						io_resource_inuse->child;
+					pciauto_lower_iospc = 
+						io_resource_inuse->start;
+					pciauto_upper_iospc = 
+						io_resource_inuse->end + 1;
+					goto retry;
+				}
+
+			} else {
+				if (mem_resource_inuse->child) {
+					mem_resource_inuse = 
+						mem_resource_inuse->child;
+					pciauto_lower_memspc = 
+						mem_resource_inuse->start;
+					pciauto_upper_memspc = 
+						mem_resource_inuse->end + 1;
+					goto retry;
+				}
+			}
+			DBG(" unavailable -- skipping, value %x size %x\n",
+					bar_value, bar_size);
+			continue;
+		}
+
+#ifdef CONFIG_PCI_AUTO_UPDATE_RESOURCES
+		/* Write it out and update our limit */
+		early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
+					 bar, bar_value);
+#endif
+
+		*lower_limit = bar_value + bar_size;
+
+		/*
+		 * If we are a 64-bit decoder then increment to the
+		 * upper 32 bits of the bar and force it to locate
+		 * in the lower 4GB of memory.
+		 */ 
+		if (found_mem64) {
+			bar += 4;
+			early_write_config_dword(hose, top_bus,
+						 current_bus,
+						 pci_devfn,
+						 bar,
+						 0x00000000);
+		}
+
+		DBG(" at 0x%.8x [size=0x%x]\n", bar_value, bar_size);
+
+		bar_nr++;
+	}
+
+}
+
+static void __init
+pciauto_prescan_setup_bridge(struct pci_channel *hose,
+			     int top_bus,
+			     int current_bus,
+			     int pci_devfn,
+			     int sub_bus)
+{
+	/* Configure bus number registers */
+	early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+	                        PCI_PRIMARY_BUS, current_bus);
+	early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+				PCI_SECONDARY_BUS, sub_bus + 1);
+	early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+				PCI_SUBORDINATE_BUS, 0xff);
+
+	/* Align memory and I/O to 1MB and 4KB boundaries. */
+	pciauto_lower_memspc = (pciauto_lower_memspc + (0x100000 - 1))
+		& ~(0x100000 - 1);
+	pciauto_lower_iospc = (pciauto_lower_iospc + (0x1000 - 1))
+		& ~(0x1000 - 1);
+
+	/* Set base (lower limit) of address range behind bridge. */
+	early_write_config_word(hose, top_bus, current_bus, pci_devfn,
+		PCI_MEMORY_BASE, pciauto_lower_memspc >> 16);
+	early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+		PCI_IO_BASE, (pciauto_lower_iospc & 0x0000f000) >> 8);
+	early_write_config_word(hose, top_bus, current_bus, pci_devfn,
+		PCI_IO_BASE_UPPER16, pciauto_lower_iospc >> 16);
+
+	/* We don't support prefetchable memory for now, so disable */
+	early_write_config_word(hose, top_bus, current_bus, pci_devfn,
+				PCI_PREF_MEMORY_BASE, 0);
+	early_write_config_word(hose, top_bus, current_bus, pci_devfn,
+				PCI_PREF_MEMORY_LIMIT, 0);
+}
+
+static void __init
+pciauto_postscan_setup_bridge(struct pci_channel *hose,
+			      int top_bus,
+			      int current_bus,
+			      int pci_devfn,
+			      int sub_bus)
+{
+	u32 temp;
+
+	pciauto_lower_memspc += 1;
+	pciauto_lower_iospc += 1;
+
+	/* Configure bus number registers */
+	early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+				PCI_SUBORDINATE_BUS, sub_bus);
+
+	/* Set upper limit of address range behind bridge. */
+	early_write_config_word(hose, top_bus, current_bus, pci_devfn,
+		PCI_MEMORY_LIMIT, pciauto_lower_memspc >> 16);
+	early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+		PCI_IO_LIMIT, (pciauto_lower_iospc & 0x0000f000) >> 8);
+	early_write_config_word(hose, top_bus, current_bus, pci_devfn,
+		PCI_IO_LIMIT_UPPER16, pciauto_lower_iospc >> 16);
+
+	/* Align memory and I/O to 1MB and 4KB boundaries. */
+	pciauto_lower_memspc = (pciauto_lower_memspc + (0x100000 - 1))
+		& ~(0x100000 - 1);
+	pciauto_lower_iospc = (pciauto_lower_iospc + (0x1000 - 1))
+		& ~(0x1000 - 1);
+
+	/* Enable memory and I/O accesses, enable bus master */
+	early_read_config_dword(hose, top_bus, current_bus, pci_devfn,
+		PCI_COMMAND, &temp);
+	early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
+		PCI_COMMAND, temp | PCI_COMMAND_IO | PCI_COMMAND_MEMORY
+		| PCI_COMMAND_MASTER);
+}
+
+static void __init
+pciauto_prescan_setup_cardbus_bridge(struct pci_channel *hose,
+                            int top_bus,
+                            int current_bus,
+                            int pci_devfn,
+                            int sub_bus)
+{
+       /* Configure bus number registers */
+       early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+                               PCI_PRIMARY_BUS, current_bus);
+       early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+                               PCI_SECONDARY_BUS, sub_bus + 1);
+       early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+                               PCI_SUBORDINATE_BUS, 0xff);
+
+       /* Align memory and I/O to 4KB and 4 byte boundaries. */
+       pciauto_lower_memspc = (pciauto_lower_memspc + (0x1000 - 1))
+               & ~(0x1000 - 1);
+       pciauto_lower_iospc = (pciauto_lower_iospc + (0x4 - 1))
+               & ~(0x4 - 1);
+
+       early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
+               PCI_CB_MEMORY_BASE_0, pciauto_lower_memspc);
+       early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
+               PCI_CB_IO_BASE_0, pciauto_lower_iospc);  
+}
+
+static void __init
+pciauto_postscan_setup_cardbus_bridge(struct pci_channel *hose,
+                             int top_bus,
+                             int current_bus,
+                             int pci_devfn,
+                             int sub_bus)
+{
+       u32 temp;
+
+       /* 
+        * [jsun] we always bump up baselines a little, so that if there 
+        * nothing behind P2P bridge, we don't wind up overlapping IO/MEM 
+        * spaces.
+        */
+       pciauto_lower_memspc += 1;
+       pciauto_lower_iospc += 1;
+
+       /*
+        * Configure subordinate bus number.  The PCI subsystem
+        * bus scan will renumber buses (reserving three additional
+        * for this PCI<->CardBus bridge for the case where a CardBus
+        * adapter contains a P2P or CB2CB bridge.
+        */
+
+       early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+                               PCI_SUBORDINATE_BUS, sub_bus);
+
+       /*
+        * Reserve an additional 4MB for mem space and 16KB for
+        * I/O space.  This should cover any additional space
+        * requirement of unusual CardBus devices with 
+        * additional bridges that can consume more address space.
+        * 
+        * Although pcmcia-cs currently will reprogram bridge
+        * windows, the goal is to add an option to leave them
+        * alone and use the bridge window ranges as the regions
+        * that are searched for free resources upon hot-insertion
+        * of a device.  This will allow a PCI<->CardBus bridge
+        * configured by this routine to happily live behind a
+        * P2P bridge in a system.
+        */
+
+       /* Align memory and I/O to 4KB and 4 byte boundaries. */
+       pciauto_lower_memspc = (pciauto_lower_memspc + (0x1000 - 1))
+               & ~(0x1000 - 1);
+       pciauto_lower_iospc = (pciauto_lower_iospc + (0x4 - 1))
+               & ~(0x4 - 1);
+       /* Set up memory and I/O filter limits, assume 32-bit I/O space */
+       early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
+               PCI_CB_MEMORY_LIMIT_0, pciauto_lower_memspc - 1); 
+       early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
+               PCI_CB_IO_LIMIT_0, pciauto_lower_iospc - 1);
+       
+       /* Enable memory and I/O accesses, enable bus master */
+       early_read_config_dword(hose, top_bus, current_bus, pci_devfn,
+               PCI_COMMAND, &temp);
+       early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
+               PCI_COMMAND, temp | PCI_COMMAND_IO | PCI_COMMAND_MEMORY
+               | PCI_COMMAND_MASTER);
+}
+
+#define      PCIAUTO_IDE_MODE_MASK           0x05
+
+static int __init
+pciauto_bus_scan(struct pci_channel *hose, int top_bus, int current_bus)
+{
+	int sub_bus;
+	u32 pci_devfn, pci_class, cmdstat, found_multi=0;
+	unsigned short vid, did;
+	unsigned char header_type;
+	int devfn_start = 0;
+	int devfn_stop = 0xff;
+
+	sub_bus = current_bus;
+	
+	if (hose->first_devfn)
+		devfn_start = hose->first_devfn;
+	if (hose->last_devfn)
+		devfn_stop = hose->last_devfn;
+	
+	for (pci_devfn=devfn_start; pci_devfn<devfn_stop; pci_devfn++) {
+
+		if (PCI_FUNC(pci_devfn) && !found_multi)
+			continue;
+
+		early_read_config_word(hose, top_bus, current_bus, pci_devfn,
+				       PCI_VENDOR_ID, &vid);
+
+		if (vid == 0xffff) continue;
+
+		early_read_config_byte(hose, top_bus, current_bus, pci_devfn,
+				       PCI_HEADER_TYPE, &header_type);
+
+		if (!PCI_FUNC(pci_devfn))
+			found_multi = header_type & 0x80;
+
+		early_read_config_word(hose, top_bus, current_bus, pci_devfn,
+				       PCI_DEVICE_ID, &did);
+
+		early_read_config_dword(hose, top_bus, current_bus, pci_devfn,
+					PCI_CLASS_REVISION, &pci_class);
+
+		DBG("%.2x:%.2x.%x Class %.4x: %.4x:%.4x",
+			current_bus, PCI_SLOT(pci_devfn), PCI_FUNC(pci_devfn),
+			pci_class >> 16, vid, did);
+		if (pci_class & 0xff)
+			DBG(" (rev %.2x)", pci_class & 0xff);
+		DBG("\n");
+
+		if ((pci_class >> 16) == PCI_CLASS_BRIDGE_PCI) {
+			DBG("        Bridge: primary=%.2x, secondary=%.2x\n",
+				current_bus, sub_bus + 1);
+			pciauto_prescan_setup_bridge(hose, top_bus, current_bus,
+						     pci_devfn, sub_bus);
+			DBG("Scanning sub bus %.2x, I/O 0x%.8x, Mem 0x%.8x\n",
+				sub_bus + 1,
+				pciauto_lower_iospc, pciauto_lower_memspc);
+			sub_bus = pciauto_bus_scan(hose, top_bus, sub_bus+1);
+			DBG("Back to bus %.2x\n", current_bus);
+			pciauto_postscan_setup_bridge(hose, top_bus, current_bus,
+						      pci_devfn, sub_bus);
+			continue;
+                } else if ((pci_class >> 16) == PCI_CLASS_BRIDGE_CARDBUS) {
+                        DBG("  CARDBUS  Bridge: primary=%.2x, secondary=%.2x\n",
+                                current_bus, sub_bus + 1);
+                        DBG("PCI Autoconfig: Found CardBus bridge, device %d function %d\n", PCI_SLOT(pci_devfn), PCI_FUNC(pci_devfn));
+                        /* Place CardBus Socket/ExCA registers */
+                        pciauto_setup_bars(hose, top_bus, current_bus, pci_devfn);
+ 
+                        pciauto_prescan_setup_cardbus_bridge(hose, top_bus, 
+                                        current_bus, pci_devfn, sub_bus);
+ 
+                        DBG("Scanning sub bus %.2x, I/O 0x%.8x, Mem 0x%.8x\n",
+                                sub_bus + 1,
+                                pciauto_lower_iospc, pciauto_lower_memspc);
+                        sub_bus = pciauto_bus_scan(hose, top_bus, sub_bus+1);
+                        DBG("Back to bus %.2x, sub_bus is %x\n", current_bus, sub_bus);
+                        pciauto_postscan_setup_cardbus_bridge(hose, top_bus, 
+                                        current_bus, pci_devfn, sub_bus);
+                        continue;
+		} else if ((pci_class >> 16) == PCI_CLASS_STORAGE_IDE) {
+
+			unsigned char prg_iface;
+
+			early_read_config_byte(hose, top_bus, current_bus,
+				pci_devfn, PCI_CLASS_PROG, &prg_iface);
+			if (!(prg_iface & PCIAUTO_IDE_MODE_MASK)) {
+				DBG("Skipping legacy mode IDE controller\n");
+				continue;
+			}
+		}
+
+ 		/*
+		 * Found a peripheral, enable some standard
+		 * settings
+		 */
+		early_read_config_dword(hose, top_bus, current_bus, pci_devfn,
+					PCI_COMMAND, &cmdstat);
+		early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
+					 PCI_COMMAND, cmdstat | PCI_COMMAND_IO |
+					 PCI_COMMAND_MEMORY |
+					 PCI_COMMAND_MASTER);
+		early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
+					PCI_LATENCY_TIMER, 0x80);
+
+		/* Allocate PCI I/O and/or memory space */
+		pciauto_setup_bars(hose, top_bus, current_bus, pci_devfn);
+	}
+	return sub_bus;
+}
+
+int __init
+pciauto_assign_resources(int busno, struct pci_channel *hose)
+{
+	/* setup resource limits */
+	io_resource_inuse = hose->io_resource;
+	mem_resource_inuse = hose->mem_resource;
+
+	pciauto_lower_iospc = io_resource_inuse->start;
+	pciauto_upper_iospc = io_resource_inuse->end + 1;
+	pciauto_lower_memspc = mem_resource_inuse->start;
+	pciauto_upper_memspc = mem_resource_inuse->end + 1;
+	DBG("Autoconfig PCI channel 0x%p\n", hose);
+	DBG("Scanning bus %.2x, I/O 0x%.8x:0x%.8x, Mem 0x%.8x:0x%.8x\n",
+		busno, pciauto_lower_iospc, pciauto_upper_iospc, 
+		pciauto_lower_memspc, pciauto_upper_memspc);
+
+	return pciauto_bus_scan(hose, busno, busno);
+}
diff -puN /dev/null arch/sh/drivers/pci/pci.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/pci/pci.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,153 @@
+/* arch/sh/kernel/pci.c
+ * $Id: pci.c,v 1.1 2003/08/24 19:15:45 lethal Exp $
+ *
+ * Copyright (c) 2002 M. R. Brown  <mrbrown@linux-sh.org>
+ * 
+ * 
+ * These functions are collected here to reduce duplication of common
+ * code amongst the many platform-specific PCI support code files.
+ * 
+ * These routines require the following board-specific routines:
+ * void pcibios_fixup_irqs();
+ *
+ * See include/asm-sh/pci.h for more information.
+ */
+
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+
+static int __init pcibios_init(void)
+{
+	struct pci_channel *p;
+	struct pci_bus *bus;
+	int busno;
+
+#ifdef CONFIG_PCI_AUTO
+	/* assign resources */
+	busno=0;
+	for (p = board_pci_channels; p->pci_ops != NULL; p++) {
+		busno = pciauto_assign_resources(busno, p) + 1;
+	}
+#endif
+
+	/* scan the buses */
+	busno = 0;
+	for (p= board_pci_channels; p->pci_ops != NULL; p++) {
+		bus = pci_scan_bus(busno, p->pci_ops, p);
+		busno = bus->subordinate+1;
+	}
+
+	/* board-specific fixups */
+	pcibios_fixup_irqs();
+
+	return 0;
+}
+
+subsys_initcall(pcibios_init);
+
+void
+pcibios_update_resource(struct pci_dev *dev, struct resource *root,
+			struct resource *res, int resource)
+{
+	u32 new, check;
+	int reg;
+
+	new = res->start | (res->flags & PCI_REGION_FLAG_MASK);
+	if (resource < 6) {
+		reg = PCI_BASE_ADDRESS_0 + 4*resource;
+	} else if (resource == PCI_ROM_RESOURCE) {
+		res->flags |= PCI_ROM_ADDRESS_ENABLE;
+		new |= PCI_ROM_ADDRESS_ENABLE;
+		reg = dev->rom_base_reg;
+	} else {
+		/* Somebody might have asked allocation of a non-standard resource */
+		return;
+	}
+	
+	pci_write_config_dword(dev, reg, new);
+	pci_read_config_dword(dev, reg, &check);
+	if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) {
+		printk(KERN_ERR "PCI: Error while updating region "
+		       "%s/%d (%08x != %08x)\n", pci_name(dev), resource,
+		       new, check);
+	}
+}
+
+void pcibios_align_resource(void *data, struct resource *res,
+			    unsigned long size, unsigned long align)
+			    __attribute__ ((weak));
+
+/*
+ * We need to avoid collisions with `mirrored' VGA ports
+ * and other strange ISA hardware, so we always want the
+ * addresses to be allocated in the 0x000-0x0ff region
+ * modulo 0x400.
+ */
+void pcibios_align_resource(void *data, struct resource *res,
+			    unsigned long size, unsigned long align)
+{
+	if (res->flags & IORESOURCE_IO) {
+		unsigned long start = res->start;
+
+		if (start & 0x300) {
+			start = (start + 0x3ff) & ~0x3ff;
+			res->start = start;
+		}
+	}
+}
+
+int pcibios_enable_device(struct pci_dev *dev, int mask)
+{
+	u16 cmd, old_cmd;
+	int idx;
+	struct resource *r;
+
+	pci_read_config_word(dev, PCI_COMMAND, &cmd);
+	old_cmd = cmd;
+	for(idx=0; idx<6; idx++) {
+		r = &dev->resource[idx];
+		if (!r->start && r->end) {
+			printk(KERN_ERR "PCI: Device %s not available because "
+			       "of resource collisions\n", pci_name(dev));
+			return -EINVAL;
+		}
+		if (r->flags & IORESOURCE_IO)
+			cmd |= PCI_COMMAND_IO;
+		if (r->flags & IORESOURCE_MEM)
+			cmd |= PCI_COMMAND_MEMORY;
+	}
+	if (dev->resource[PCI_ROM_RESOURCE].start)
+		cmd |= PCI_COMMAND_MEMORY;
+	if (cmd != old_cmd) {
+		printk(KERN_INFO "PCI: Enabling device %s (%04x -> %04x)\n",
+		       pci_name(dev), old_cmd, cmd);
+		pci_write_config_word(dev, PCI_COMMAND, cmd);
+	}
+	return 0;
+}
+
+/*
+ *  If we set up a device for bus mastering, we need to check and set
+ *  the latency timer as it may not be properly set.
+ */
+unsigned int pcibios_max_latency = 255;
+
+void pcibios_set_master(struct pci_dev *dev)
+{
+	u8 lat;
+	pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
+	if (lat < 16)
+		lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency;
+	else if (lat > pcibios_max_latency)
+		lat = pcibios_max_latency;
+	else
+		return;
+	printk(KERN_INFO "PCI: Setting latency timer of device %s to %d\n", pci_name(dev), lat);
+	pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
+}
+
+void __init pcibios_update_irq(struct pci_dev *dev, int irq)
+{
+	pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
+}
diff -puN /dev/null arch/sh/drivers/pci/pci-dma.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/pci/pci-dma.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,42 @@
+/* 
+ * Copyright (C) 2001 David J. Mckay (david.mckay@st.com)
+ *
+ * May be copied or modified under the terms of the GNU General Public
+ * License.  See linux/COPYING for more information.                            
+ *
+ * Dynamic DMA mapping support.
+ */
+
+#include <linux/types.h>
+#include <linux/mm.h>
+#include <linux/string.h>
+#include <linux/pci.h>
+#include <asm/io.h>
+#include <asm/addrspace.h>
+
+
+void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
+			   dma_addr_t * dma_handle)
+{
+	void *ret;
+	int gfp = GFP_ATOMIC;
+
+	ret = (void *) __get_free_pages(gfp, get_order(size));
+
+	if (ret != NULL) {
+	        /* Is it necessary to do the memset? */
+		memset(ret, 0, size);
+		*dma_handle = virt_to_phys(ret);
+	}
+	/* We must flush the cache before we pass it on to the device */
+	dma_cache_wback_inv(ret, size);
+	return  P2SEGADDR(ret);
+}
+
+void pci_free_consistent(struct pci_dev *hwdev, size_t size,
+			 void *vaddr, dma_addr_t dma_handle)
+{
+        unsigned long p1addr=P1SEGADDR((unsigned long)vaddr);
+
+	free_pages(p1addr, get_order(size));
+}
diff -puN /dev/null arch/sh/drivers/pci/pci-sh7751.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/pci/pci-sh7751.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,414 @@
+/*
+ *	Low-Level PCI Support for the SH7751
+ *
+ *  Dustin McIntire (dustin@sensoria.com)
+ *	Derived from arch/i386/kernel/pci-*.c which bore the message:
+ *	(c) 1999--2000 Martin Mares <mj@ucw.cz>
+ *
+ *  Ported to the new API by Paul Mundt <lethal@linux-sh.org>
+ *  With cleanup by Paul van Gool <pvangool@mimotech.com>
+ *
+ *  May be copied or modified under the terms of the GNU General Public
+ *  License.  See linux/COPYING for more information.
+ *
+ */
+
+#undef DEBUG
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/sched.h>
+#include <linux/ioport.h>
+#include <linux/errno.h>
+#include <linux/irq.h>
+#include <linux/delay.h>
+
+#include <asm/machvec.h>
+#include <asm/io.h>
+#include "pci-sh7751.h"
+
+static unsigned int pci_probe = PCI_PROBE_CONF1;
+
+/*
+ * Direct access to PCI hardware...
+ */
+
+#define CONFIG_CMD(bus, devfn, where) (0x80000000 | (bus->number << 16) | (devfn << 8) | (where & ~3))
+
+/*
+ * Functions for accessing PCI configuration space with type 1 accesses
+ */
+static int sh7751_pci_read(struct pci_bus *bus, unsigned int devfn,
+			   int where, int size, u32 *val)
+{
+	unsigned long flags;
+	u32 data;
+
+	/* 
+	 * PCIPDR may only be accessed as 32 bit words, 
+	 * so we must do byte alignment by hand 
+	 */
+	local_irq_save(flags);
+	outl(CONFIG_CMD(bus,devfn,where), PCI_REG(SH7751_PCIPAR));
+	data = inl(PCI_REG(SH7751_PCIPDR));
+	local_irq_restore(flags);
+
+	switch (size) {
+	case 1:
+		*val = (data >> ((where & 3) << 3)) & 0xff;
+		break;
+	case 2:
+		*val = (data >> ((where & 2) << 3)) & 0xffff;
+		break;
+	case 4:
+		*val = data;
+		break;
+	default:
+		return PCIBIOS_FUNC_NOT_SUPPORTED;
+	}
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+/* 
+ * Since SH7751 only does 32bit access we'll have to do a read,mask,write operation.  
+ * We'll allow an odd byte offset, though it should be illegal.
+ */ 
+static int sh7751_pci_write(struct pci_bus *bus, unsigned int devfn,
+			    int where, int size, u32 val)
+{
+	unsigned long flags;
+	int shift;
+	u32 data;
+
+	local_irq_save(flags);
+	outl(CONFIG_CMD(bus,devfn,where), PCI_REG(SH7751_PCIPAR));
+	data = inl(PCI_REG(SH7751_PCIPDR));
+	local_irq_restore(flags);
+
+	switch (size) {
+	case 1:
+		shift = (where & 3) << 3;
+		data &= ~(0xff << shift);
+		data |= ((val & 0xff) << shift);
+		break;
+	case 2:
+		shift = (where & 2) << 3;
+		data &= ~(0xffff << shift);
+		data |= ((val & 0xffff) << shift);
+		break;
+	case 4:
+		data = val;
+		break;
+	default:
+		return PCIBIOS_FUNC_NOT_SUPPORTED;
+	}
+
+	outl(data, PCI_REG(SH7751_PCIPDR));
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+#undef CONFIG_CMD
+
+struct pci_ops sh7751_pci_ops = {
+	.read 		= sh7751_pci_read,
+	.write		= sh7751_pci_write,
+};
+
+static int __init pci_check_direct(void)
+{
+	unsigned int tmp, id;
+
+	/* check for SH7751/SH7751R hardware */
+	id = inl(SH7751_PCIREG_BASE+SH7751_PCICONF0);
+	if (id != ((SH7751_DEVICE_ID << 16) | SH7751_VENDOR_ID) &&
+	    id != ((SH7751R_DEVICE_ID << 16) | SH7751_VENDOR_ID)) {
+		pr_debug("PCI: This is not an SH7751(R) (%x)\n", id);
+		return -ENODEV;
+	}
+
+	/*
+	 * Check if configuration works.
+	 */
+	if (pci_probe & PCI_PROBE_CONF1) {
+		tmp = inl (PCI_REG(SH7751_PCIPAR));
+		outl (0x80000000, PCI_REG(SH7751_PCIPAR));
+		if (inl (PCI_REG(SH7751_PCIPAR)) == 0x80000000) {
+			outl (tmp, PCI_REG(SH7751_PCIPAR));
+			printk(KERN_INFO "PCI: Using configuration type 1\n");
+			request_region(PCI_REG(SH7751_PCIPAR), 8, "PCI conf1");
+			return 0;
+		}
+		outl (tmp, PCI_REG(SH7751_PCIPAR));
+	}
+
+	pr_debug("PCI: pci_check_direct failed\n");
+	return -EINVAL;
+}
+
+/***************************************************************************************/
+
+/*
+ *  Handle bus scanning and fixups ....
+ */
+
+static void __init pci_fixup_ide_bases(struct pci_dev *d)
+{
+	int i;
+
+	/*
+	 * PCI IDE controllers use non-standard I/O port decoding, respect it.
+	 */
+	if ((d->class >> 8) != PCI_CLASS_STORAGE_IDE)
+		return;
+	pr_debug("PCI: IDE base address fixup for %s\n", d->slot_name);
+	for(i=0; i<4; i++) {
+		struct resource *r = &d->resource[i];
+		if ((r->start & ~0x80) == 0x374) {
+			r->start |= 2;
+			r->end = r->start;
+		}
+	}
+}
+
+
+/* Add future fixups here... */
+struct pci_fixup pcibios_fixups[] = {
+	{ PCI_FIXUP_HEADER,	PCI_ANY_ID,	PCI_ANY_ID,	pci_fixup_ide_bases },
+	{ 0 }
+};
+
+/*
+ *  Called after each bus is probed, but before its children
+ *  are examined.
+ */
+
+void __init pcibios_fixup_bus(struct pci_bus *b)
+{
+	pci_read_bridge_bases(b);
+}
+
+/*
+ * Initialization. Try all known PCI access methods. Note that we support
+ * using both PCI BIOS and direct access: in such cases, we use I/O ports
+ * to access config space.
+ * 
+ * Note that the platform specific initialization (BSC registers, and memory
+ * space mapping) will be called via the machine vectors (sh_mv.mv_pci_init()) if it
+ * exitst and via the platform defined function pcibios_init_platform().  
+ * See pci_bigsur.c for implementation;
+ * 
+ * The BIOS version of the pci functions is not yet implemented but it is left
+ * in for completeness.  Currently an error will be genereated at compile time. 
+ */
+
+static int __init sh7751_pci_init(void)
+{
+	int ret;
+
+	pr_debug("PCI: Starting intialization.\n");
+	if ((ret = pci_check_direct()) != 0)
+		return ret;
+
+	return pcibios_init_platform();
+}
+
+subsys_initcall(sh7751_pci_init);
+
+static int __init __area_sdram_check(unsigned int area)
+{
+	u32 word;
+
+	word = inl(SH7751_BCR1);
+	/* check BCR for SDRAM in area */
+	if(((word >> area) & 1) == 0) {
+		printk("PCI: Area %d is not configured for SDRAM. BCR1=0x%x\n",
+		       area, word);
+		return 0;
+	}
+	outl(word, PCI_REG(SH7751_PCIBCR1));
+
+	word = (u16)inw(SH7751_BCR2);
+	/* check BCR2 for 32bit SDRAM interface*/
+	if(((word >> (area << 1)) & 0x3) != 0x3) {
+		printk("PCI: Area %d is not 32 bit SDRAM. BCR2=0x%x\n",
+		       area, word);
+		return 0;
+	}
+	outl(word, PCI_REG(SH7751_PCIBCR2));
+
+	return 1;
+}
+
+int __init sh7751_pcic_init(struct sh7751_pci_address_map *map)
+{
+	u32 reg;
+	u32 word;
+
+	/* Set the BCR's to enable PCI access */
+	reg = inl(SH7751_BCR1);
+	reg |= 0x80000;
+	outl(reg, SH7751_BCR1);
+	
+	/* Turn the clocks back on (not done in reset)*/
+	outl(0, PCI_REG(SH7751_PCICLKR));
+	/* Clear Powerdown IRQ's (not done in reset) */
+	word = SH7751_PCIPINT_D3 | SH7751_PCIPINT_D0;
+	outl(word, PCI_REG(SH7751_PCICLKR));
+
+	/*
+	 * XXX: This code is unused for the SnapGear boards as it is done in
+	 * the bootloader and doing it here means the MAC addresses loaded by
+	 * the bootloader get lost.
+	 */
+#ifndef CONFIG_SH_SECUREEDGE5410
+	/* toggle PCI reset pin */
+	word = SH7751_PCICR_PREFIX | SH7751_PCICR_PRST;
+	outl(word,PCI_REG(SH7751_PCICR));    
+	/* Wait for a long time... not 1 sec. but long enough */
+	mdelay(100);
+	word = SH7751_PCICR_PREFIX;
+	outl(word,PCI_REG(SH7751_PCICR)); 
+#endif
+	
+	/* set the command/status bits to:
+	 * Wait Cycle Control + Parity Enable + Bus Master +
+	 * Mem space enable
+	 */
+	word = SH7751_PCICONF1_WCC | SH7751_PCICONF1_PER | 
+	       SH7751_PCICONF1_BUM | SH7751_PCICONF1_MES;
+	outl(word, PCI_REG(SH7751_PCICONF1));
+
+	/* define this host as the host bridge */
+	word = SH7751_PCI_HOST_BRIDGE << 24;
+	outl(word, PCI_REG(SH7751_PCICONF2));
+
+	/* Set IO and Mem windows to local address 
+	 * Make PCI and local address the same for easy 1 to 1 mapping 
+	 * Window0 = map->window0.size @ non-cached area base = SDRAM
+	 * Window1 = map->window1.size @ cached area base = SDRAM 
+	 */
+	word = map->window0.size - 1;
+	outl(word, PCI_REG(SH7751_PCILSR0));
+	word = map->window1.size - 1;
+	outl(word, PCI_REG(SH7751_PCILSR1));
+	/* Set the values on window 0 PCI config registers */
+	word = P2SEGADDR(map->window0.base);
+	outl(word, PCI_REG(SH7751_PCILAR0));
+	outl(word, PCI_REG(SH7751_PCICONF5));
+	/* Set the values on window 1 PCI config registers */
+	word =  PHYSADDR(map->window1.base);
+	outl(word, PCI_REG(SH7751_PCILAR1));
+	outl(word, PCI_REG(SH7751_PCICONF6));
+
+	/* Set the local 16MB PCI memory space window to 
+	 * the lowest PCI mapped address
+	 */
+	word = PCIBIOS_MIN_MEM & SH7751_PCIMBR_MASK;
+	PCIDBG(2,"PCI: Setting upper bits of Memory window to 0x%x\n", word);
+	outl(word , PCI_REG(SH7751_PCIMBR));
+
+	/* Map IO space into PCI IO window
+	 * The IO window is 64K-PCIBIOS_MIN_IO in size
+	 * IO addresses will be translated to the 
+	 * PCI IO window base address
+	 */
+	PCIDBG(3,"PCI: Mapping IO address 0x%x - 0x%x to base 0x%x\n", PCIBIOS_MIN_IO,
+	    (64*1024), SH7751_PCI_IO_BASE+PCIBIOS_MIN_IO);
+
+	/* 
+	 * XXX: For now, leave this board-specific. In the event we have other
+	 * boards that need to do similar work, this can be wrapped.
+	 */
+#ifdef CONFIG_SH_BIGSUR
+	bigsur_port_map(PCIBIOS_MIN_IO, (64*1024), SH7751_PCI_IO_BASE+PCIBIOS_MIN_IO,0);
+#endif
+
+	/* Make sure the MSB's of IO window are set to access PCI space correctly */
+	word = PCIBIOS_MIN_IO & SH7751_PCIIOBR_MASK;
+	PCIDBG(2,"PCI: Setting upper bits of IO window to 0x%x\n", word);
+	outl(word, PCI_REG(SH7751_PCIIOBR));
+	
+	/* Set PCI WCRx, BCRx's, copy from BSC locations */
+
+	/* check BCR for SDRAM in specified area */
+	switch (map->window0.base) {
+	case SH7751_CS0_BASE_ADDR: word = __area_sdram_check(0); break;
+	case SH7751_CS1_BASE_ADDR: word = __area_sdram_check(1); break;
+	case SH7751_CS2_BASE_ADDR: word = __area_sdram_check(2); break;
+	case SH7751_CS3_BASE_ADDR: word = __area_sdram_check(3); break;
+	case SH7751_CS4_BASE_ADDR: word = __area_sdram_check(4); break;
+	case SH7751_CS5_BASE_ADDR: word = __area_sdram_check(5); break;
+	case SH7751_CS6_BASE_ADDR: word = __area_sdram_check(6); break;
+	}
+	
+	if (!word)
+		return 0;
+
+	/* configure the wait control registers */
+	word = inl(SH7751_WCR1);
+	outl(word, PCI_REG(SH7751_PCIWCR1));
+	word = inl(SH7751_WCR2);
+	outl(word, PCI_REG(SH7751_PCIWCR2));
+	word = inl(SH7751_WCR3);
+	outl(word, PCI_REG(SH7751_PCIWCR3));
+	word = inl(SH7751_MCR);
+	outl(word, PCI_REG(SH7751_PCIMCR));
+
+	/* NOTE: I'm ignoring the PCI error IRQs for now..
+	 * TODO: add support for the internal error interrupts and
+	 * DMA interrupts...
+	 */
+	 
+	/* SH7751 init done, set central function init complete */
+	/* use round robin mode to stop a device starving/overruning */
+	word = SH7751_PCICR_PREFIX | SH7751_PCICR_CFIN | SH7751_PCICR_ARBM;
+	outl(word,PCI_REG(SH7751_PCICR)); 
+
+	return 1;
+}
+
+char * __init pcibios_setup(char *str)
+{
+	if (!strcmp(str, "off")) {
+		pci_probe = 0;
+		return NULL;
+	}
+
+	return str;
+}
+
+/* 
+ * 	IRQ functions 
+ */
+static u8 __init sh7751_no_swizzle(struct pci_dev *dev, u8 *pin)
+{
+	/* no swizzling */
+	return PCI_SLOT(dev->devfn);
+}
+
+static int sh7751_pci_lookup_irq(struct pci_dev *dev, u8 slot, u8 pin)
+{
+	int irq = -1;
+
+	/* now lookup the actual IRQ on a platform specific basis (pci-'platform'.c) */
+	irq = pcibios_map_platform_irq(slot,pin);
+	if( irq < 0 ) {
+		pr_debug("PCI: Error mapping IRQ on device %s\n", dev->slot_name);
+		return irq;
+	}
+	
+	pr_debug("Setting IRQ for slot %s to %d\n", dev->slot_name, irq);
+
+	return irq;
+}
+
+void __init pcibios_fixup_irqs(void)
+{
+	pci_fixup_irqs(sh7751_no_swizzle, sh7751_pci_lookup_irq);
+}
+
diff -puN /dev/null arch/sh/drivers/pci/pci-sh7751.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/pci/pci-sh7751.h	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,296 @@
+/*
+ *	Low-Level PCI Support for SH7751 targets
+ *
+ *  Dustin McIntire (dustin@sensoria.com) (c) 2001
+ *  Paul Mundt (lethal@linux-sh.org) (c) 2003
+ *	
+ *  May be copied or modified under the terms of the GNU General Public
+ *  License.  See linux/COPYING for more information.
+ *
+ */
+
+#ifndef _PCI_SH7751_H_
+#define _PCI_SH7751_H_
+
+#include <linux/pci.h>
+
+/* set debug level 4=verbose...1=terse */
+//#define DEBUG_PCI 3
+#undef DEBUG_PCI
+
+#ifdef DEBUG_PCI
+#define PCIDBG(n, x...) { if(DEBUG_PCI>=n) printk(x); }
+#else
+#define PCIDBG(n, x...)
+#endif
+
+/* startup values */
+#define PCI_PROBE_BIOS 1
+#define PCI_PROBE_CONF1 2
+#define PCI_PROBE_CONF2 4
+#define PCI_NO_SORT 0x100
+#define PCI_BIOS_SORT 0x200
+#define PCI_NO_CHECKS 0x400
+#define PCI_ASSIGN_ROMS 0x1000
+#define PCI_BIOS_IRQ_SCAN 0x2000
+
+/* Platform Specific Values */
+#define SH7751_VENDOR_ID             0x1054
+#define SH7751_DEVICE_ID             0x3505
+#define SH7751R_DEVICE_ID            0x350e
+
+/* SH7751 Specific Values */
+#define SH7751_PCI_CONFIG_BASE	     0xFD000000  /* Config space base addr */
+#define SH7751_PCI_CONFIG_SIZE       0x1000000   /* Config space size */
+#define SH7751_PCI_MEMORY_BASE	     0xFD000000  /* Memory space base addr */
+#define SH7751_PCI_MEM_SIZE          0x01000000  /* Size of Memory window */
+#define SH7751_PCI_IO_BASE           0xFE240000  /* IO space base address */
+#define SH7751_PCI_IO_SIZE           0x40000     /* Size of IO window */
+
+#define SH7751_PCIREG_BASE           0xFE200000  /* PCI regs base address */
+#define PCI_REG(n)                  (SH7751_PCIREG_BASE+ n)
+
+#define SH7751_PCICONF0            0x0           /* PCI Config Reg 0 */
+  #define SH7751_PCICONF0_DEVID      0xFFFF0000  /* Device ID */
+  #define SH7751_PCICONF0_VNDID      0x0000FFFF  /* Vendor ID */
+#define SH7751_PCICONF1            0x4           /* PCI Config Reg 1 */
+  #define SH7751_PCICONF1_DPE        0x80000000  /* Data Parity Error */
+  #define SH7751_PCICONF1_SSE        0x40000000  /* System Error Status */
+  #define SH7751_PCICONF1_RMA        0x20000000  /* Master Abort */
+  #define SH7751_PCICONF1_RTA        0x10000000  /* Target Abort Rx Status */
+  #define SH7751_PCICONF1_STA        0x08000000  /* Target Abort Exec Status */
+  #define SH7751_PCICONF1_DEV        0x06000000  /* Timing Status */
+  #define SH7751_PCICONF1_DPD        0x01000000  /* Data Parity Status */
+  #define SH7751_PCICONF1_FBBC       0x00800000  /* Back 2 Back Status */
+  #define SH7751_PCICONF1_UDF        0x00400000  /* User Defined Status */
+  #define SH7751_PCICONF1_66M        0x00200000  /* 66Mhz Operation Status */
+  #define SH7751_PCICONF1_PM         0x00100000  /* Power Management Status */
+  #define SH7751_PCICONF1_PBBE       0x00000200  /* Back 2 Back Control */
+  #define SH7751_PCICONF1_SER        0x00000100  /* SERR Output Control */
+  #define SH7751_PCICONF1_WCC        0x00000080  /* Wait Cycle Control */
+  #define SH7751_PCICONF1_PER        0x00000040  /* Parity Error Response */
+  #define SH7751_PCICONF1_VPS        0x00000020  /* VGA Pallet Snoop */
+  #define SH7751_PCICONF1_MWIE       0x00000010  /* Memory Write+Invalidate */
+  #define SH7751_PCICONF1_SPC        0x00000008  /* Special Cycle Control */
+  #define SH7751_PCICONF1_BUM        0x00000004  /* Bus Master Control */
+  #define SH7751_PCICONF1_MES        0x00000002  /* Memory Space Control */
+  #define SH7751_PCICONF1_IOS        0x00000001  /* I/O Space Control */
+#define SH7751_PCICONF2            0x8           /* PCI Config Reg 2 */
+  #define SH7751_PCICONF2_BCC        0xFF000000  /* Base Class Code */
+  #define SH7751_PCICONF2_SCC        0x00FF0000  /* Sub-Class Code */
+  #define SH7751_PCICONF2_RLPI       0x0000FF00  /* Programming Interface */
+  #define SH7751_PCICONF2_REV        0x000000FF  /* Revision ID */
+#define SH7751_PCICONF3            0xC           /* PCI Config Reg 3 */ 
+  #define SH7751_PCICONF3_BIST7      0x80000000  /* Bist Supported */
+  #define SH7751_PCICONF3_BIST6      0x40000000  /* Bist Executing */
+  #define SH7751_PCICONF3_BIST3_0    0x0F000000  /* Bist Passed */
+  #define SH7751_PCICONF3_HD7        0x00800000  /* Single Funtion device */
+  #define SH7751_PCICONF3_HD6_0      0x007F0000  /* Configuration Layout */
+  #define SH7751_PCICONF3_LAT        0x0000FF00  /* Latency Timer */
+  #define SH7751_PCICONF3_CLS        0x000000FF  /* Cache Line Size */
+#define SH7751_PCICONF4            0x10          /* PCI Config Reg 4 */
+  #define SH7751_PCICONF4_BASE       0xFFFFFFFC  /* I/O Space Base Addr */
+  #define SH7751_PCICONF4_ASI        0x00000001  /* Address Space Type */
+#define SH7751_PCICONF5            0x14          /* PCI Config Reg 5 */
+  #define SH7751_PCICONF5_BASE       0xFFFFFFF0  /* Mem Space Base Addr */
+  #define SH7751_PCICONF5_LAP        0x00000008  /* Prefetch Enabled */
+  #define SH7751_PCICONF5_LAT        0x00000006  /* Local Memory type */
+  #define SH7751_PCICONF5_ASI        0x00000001  /* Address Space Type */  
+#define SH7751_PCICONF6            0x18          /* PCI Config Reg 6 */
+  #define SH7751_PCICONF6_BASE       0xFFFFFFF0  /* Mem Space Base Addr */
+  #define SH7751_PCICONF6_LAP        0x00000008  /* Prefetch Enabled */
+  #define SH7751_PCICONF6_LAT        0x00000006  /* Local Memory type */
+  #define SH7751_PCICONF6_ASI        0x00000001  /* Address Space Type */  
+/* PCICONF7 - PCICONF10 are undefined */
+#define SH7751_PCICONF11           0x2C          /* PCI Config Reg 11 */
+  #define SH7751_PCICONF11_SSID      0xFFFF0000  /* Subsystem ID */
+  #define SH7751_PCICONF11_SVID      0x0000FFFF  /* Subsystem Vendor ID */
+/* PCICONF12 is undefined */
+#define SH7751_PCICONF13           0x34          /* PCI Config Reg 13 */
+  #define SH7751_PCICONF13_CPTR      0x000000FF  /* PM function pointer */
+/* PCICONF14 is undefined */
+#define SH7751_PCICONF15           0x3C          /* PCI Config Reg 15 */
+  #define SH7751_PCICONF15_IPIN      0x000000FF  /* Interrupt Pin */
+#define SH7751_PCICONF16           0x40          /* PCI Config Reg 16 */
+  #define SH7751_PCICONF16_PMES      0xF8000000  /* PME Support */
+  #define SH7751_PCICONF16_D2S       0x04000000  /* D2 Support */
+  #define SH7751_PCICONF16_D1S       0x02000000  /* D1 Support */
+  #define SH7751_PCICONF16_DSI       0x00200000  /* Bit Device Init. */
+  #define SH7751_PCICONF16_PMCK      0x00080000  /* Clock for PME req. */
+  #define SH7751_PCICONF16_VER       0x00070000  /* PM Version */
+  #define SH7751_PCICONF16_NIP       0x0000FF00  /* Next Item Pointer */
+  #define SH7751_PCICONF16_CID       0x000000FF  /* Capability Identifier */
+#define SH7751_PCICONF17           0x44          /* PCI Config Reg 17 */
+  #define SH7751_PCICONF17_DATA      0xFF000000  /* Data field for PM */
+  #define SH7751_PCICONF17_PMES      0x00800000  /* PME Status */
+  #define SH7751_PCICONF17_DSCL      0x00600000  /* Data Scaling Value */
+  #define SH7751_PCICONF17_DSEL      0x001E0000  /* Data Select */
+  #define SH7751_PCICONF17_PMEN      0x00010000  /* PME Enable */
+  #define SH7751_PCICONF17_PWST      0x00000003  /* Power State */
+/* SH7715 Internal PCI Registers */
+#define SH7751_PCICR               0x100         /* PCI Control Register */
+  #define SH7751_PCICR_PREFIX        0xA5000000  /* CR prefix for write */
+  #define SH7751_PCICR_TRSB          0x00000200  /* Target Read Single */
+  #define SH7751_PCICR_BSWP          0x00000100  /* Target Byte Swap */
+  #define SH7751_PCICR_PLUP          0x00000080  /* Enable PCI Pullup */
+  #define SH7751_PCICR_ARBM          0x00000040  /* PCI Arbitration Mode */
+  #define SH7751_PCICR_MD            0x00000030  /* MD9 and MD10 status */
+  #define SH7751_PCICR_SERR          0x00000008  /* SERR output assert */
+  #define SH7751_PCICR_INTA          0x00000004  /* INTA output assert */
+  #define SH7751_PCICR_PRST          0x00000002  /* PCI Reset Assert */
+  #define SH7751_PCICR_CFIN          0x00000001  /* Central Fun. Init Done */
+#define SH7751_PCILSR0             0x104         /* PCI Local Space Register0 */
+#define SH7751_PCILSR1             0x108         /* PCI Local Space Register1 */
+#define SH7751_PCILAR0             0x10C         /* PCI Local Address Register1 */
+#define SH7751_PCILAR1             0x110         /* PCI Local Address Register1 */
+#define SH7751_PCIINT              0x114         /* PCI Interrupt Register */
+  #define SH7751_PCIINT_MLCK         0x00008000  /* Master Lock Error */
+  #define SH7751_PCIINT_TABT         0x00004000  /* Target Abort Error */
+  #define SH7751_PCIINT_TRET         0x00000200  /* Target Retry Error */
+  #define SH7751_PCIINT_MFDE         0x00000100  /* Master Func. Disable Error */
+  #define SH7751_PCIINT_PRTY         0x00000080  /* Address Parity Error */
+  #define SH7751_PCIINT_SERR         0x00000040  /* SERR Detection Error */
+  #define SH7751_PCIINT_TWDP         0x00000020  /* Tgt. Write Parity Error */
+  #define SH7751_PCIINT_TRDP         0x00000010  /* Tgt. Read Parity Error Det. */
+  #define SH7751_PCIINT_MTABT        0x00000008  /* Master-Tgt. Abort Error */
+  #define SH7751_PCIINT_MMABT        0x00000004  /* Master-Master Abort Error */
+  #define SH7751_PCIINT_MWPD         0x00000002  /* Master Write PERR Detect */
+  #define SH7751_PCIINT_MRPD         0x00000002  /* Master Read PERR Detect */
+#define SH7751_PCIINTM             0x118         /* PCI Interrupt Mask Register */
+#define SH7751_PCIALR              0x11C         /* Error Address Register */
+#define SH7751_PCICLR              0x120         /* Error Command/Data Register */
+  #define SH7751_PCICLR_MPIO         0x80000000  /* Error Command/Data Register */
+  #define SH7751_PCICLR_MDMA0        0x40000000  /* DMA0 Transfer Error */
+  #define SH7751_PCICLR_MDMA1        0x20000000  /* DMA1 Transfer Error */
+  #define SH7751_PCICLR_MDMA2        0x10000000  /* DMA2 Transfer Error */
+  #define SH7751_PCICLR_MDMA3        0x08000000  /* DMA3 Transfer Error */
+  #define SH7751_PCICLR_TGT          0x04000000  /* Target Transfer Error */
+  #define SH7751_PCICLR_CMDL         0x0000000F  /* PCI Command at Error */
+#define SH7751_PCIAINT             0x130         /* Arbiter Interrupt Register */
+  #define SH7751_PCIAINT_MBKN        0x00002000  /* Master Broken Interrupt */
+  #define SH7751_PCIAINT_TBTO        0x00001000  /* Target Bus Time Out */
+  #define SH7751_PCIAINT_MBTO        0x00001000  /* Master Bus Time Out */
+  #define SH7751_PCIAINT_TABT        0x00000008  /* Target Abort */
+  #define SH7751_PCIAINT_MABT        0x00000004  /* Master Abort */
+  #define SH7751_PCIAINT_RDPE        0x00000002  /* Read Data Parity Error */
+  #define SH7751_PCIAINT_WDPE        0x00000002  /* Write Data Parity Error */
+#define SH7751_PCIAINTM            0x134         /* Arbiter Int. Mask Register */
+#define SH7751_PCIBMLR             0x138         /* Error Bus Master Register */
+  #define SH7751_PCIBMLR_REQ4        0x00000010  /* REQ4 bus master at error */
+  #define SH7751_PCIBMLR_REQ3        0x00000008  /* REQ3 bus master at error */
+  #define SH7751_PCIBMLR_REQ2        0x00000004  /* REQ2 bus master at error */
+  #define SH7751_PCIBMLR_REQ1        0x00000002  /* REQ1 bus master at error */
+  #define SH7751_PCIBMLR_REQ0        0x00000001  /* REQ0 bus master at error */
+#define SH7751_PCIDMABT            0x140         /* DMA Transfer Arb. Register */
+  #define SH7751_PCIDMABT_RRBN       0x00000001  /* DMA Arbitor Round-Robin */
+#define SH7751_PCIDPA0             0x180         /* DMA0 Transfer Addr. Register */
+#define SH7751_PCIDLA0             0x184         /* DMA0 Local Addr. Register */
+#define SH7751_PCIDTC0             0x188         /* DMA0 Transfer Cnt. Register */
+#define SH7751_PCIDCR0             0x18C         /* DMA0 Control Register */
+  #define SH7751_PCIDCR_ALGN         0x00000600  /* DMA Alignment Mode */
+  #define SH7751_PCIDCR_MAST         0x00000100  /* DMA Termination Type */
+  #define SH7751_PCIDCR_INTM         0x00000080  /* DMA Interrupt Done Mask*/
+  #define SH7751_PCIDCR_INTS         0x00000040  /* DMA Interrupt Done Status */
+  #define SH7751_PCIDCR_LHLD         0x00000020  /* Local Address Control */
+  #define SH7751_PCIDCR_PHLD         0x00000010  /* PCI Address Control*/
+  #define SH7751_PCIDCR_IOSEL        0x00000008  /* PCI Address Space Type */
+  #define SH7751_PCIDCR_DIR          0x00000004  /* DMA Transfer Direction */
+  #define SH7751_PCIDCR_STOP         0x00000002  /* Force DMA Stop */
+  #define SH7751_PCIDCR_STRT         0x00000001  /* DMA Start */
+#define SH7751_PCIDPA1             0x190         /* DMA1 Transfer Addr. Register */
+#define SH7751_PCIDLA1             0x194         /* DMA1 Local Addr. Register */
+#define SH7751_PCIDTC1             0x198         /* DMA1 Transfer Cnt. Register */
+#define SH7751_PCIDCR1             0x19C         /* DMA1 Control Register */
+#define SH7751_PCIDPA2             0x1A0         /* DMA2 Transfer Addr. Register */
+#define SH7751_PCIDLA2             0x1A4         /* DMA2 Local Addr. Register */
+#define SH7751_PCIDTC2             0x1A8         /* DMA2 Transfer Cnt. Register */
+#define SH7751_PCIDCR2             0x1AC         /* DMA2 Control Register */
+#define SH7751_PCIDPA3             0x1B0         /* DMA3 Transfer Addr. Register */
+#define SH7751_PCIDLA3             0x1B4         /* DMA3 Local Addr. Register */
+#define SH7751_PCIDTC3             0x1B8         /* DMA3 Transfer Cnt. Register */
+#define SH7751_PCIDCR3             0x1BC         /* DMA3 Control Register */
+#define SH7751_PCIPAR              0x1C0         /* PIO Address Register */
+  #define SH7751_PCIPAR_CFGEN        0x80000000  /* Configuration Enable */
+  #define SH7751_PCIPAR_BUSNO        0x00FF0000  /* Config. Bus Number */
+  #define SH7751_PCIPAR_DEVNO        0x0000FF00  /* Config. Device Number */
+  #define SH7751_PCIPAR_REGAD        0x000000FC  /* Register Address Number */
+#define SH7751_PCIMBR              0x1C4         /* Memory Base Address Register */
+  #define SH7751_PCIMBR_MASK         0xFF000000  /* Memory Space Mask */
+  #define SH7751_PCIMBR_LOCK         0x00000001  /* Lock Memory Space */
+#define SH7751_PCIIOBR             0x1C8         /* I/O Base Address Register */
+  #define SH7751_PCIIOBR_MASK         0xFFFC0000 /* IO Space Mask */
+  #define SH7751_PCIIOBR_LOCK         0x00000001 /* Lock IO Space */
+#define SH7751_PCIPINT             0x1CC         /* Power Mgmnt Int. Register */
+  #define SH7751_PCIPINT_D3           0x00000002 /* D3 Pwr Mgmt. Interrupt */
+  #define SH7751_PCIPINT_D0           0x00000001 /* D0 Pwr Mgmt. Interrupt */  
+#define SH7751_PCIPINTM            0x1D0         /* Power Mgmnt Mask Register */
+#define SH7751_PCICLKR             0x1D4         /* Clock Ctrl. Register */
+  #define SH7751_PCICLKR_PCSTP        0x00000002 /* PCI Clock Stop */
+  #define SH7751_PCICLKR_BCSTP        0x00000002 /* BCLK Clock Stop */
+/* For definitions of BCR, MCR see ... */
+#define SH7751_PCIBCR1             0x1E0         /* Memory BCR1 Register */
+#define SH7751_PCIBCR2             0x1E4         /* Memory BCR2 Register */
+#define SH7751_PCIWCR1             0x1E8         /* Wait Control 1 Register */
+#define SH7751_PCIWCR2             0x1EC         /* Wait Control 2 Register */
+#define SH7751_PCIWCR3             0x1F0         /* Wait Control 3 Register */
+#define SH7751_PCIMCR              0x1F4         /* Memory Control Register */
+#define SH7751_PCIPCTR             0x200         /* Port Control Register */
+  #define SH7751_PCIPCTR_P2EN        0x000400000 /* Port 2 Enable */
+  #define SH7751_PCIPCTR_P1EN        0x000200000 /* Port 1 Enable */
+  #define SH7751_PCIPCTR_P0EN        0x000100000 /* Port 0 Enable */
+  #define SH7751_PCIPCTR_P2UP        0x000000020 /* Port2 Pull Up Enable */
+  #define SH7751_PCIPCTR_P2IO        0x000000010 /* Port2 Output Enable */
+  #define SH7751_PCIPCTR_P1UP        0x000000008 /* Port1 Pull Up Enable */
+  #define SH7751_PCIPCTR_P1IO        0x000000004 /* Port1 Output Enable */
+  #define SH7751_PCIPCTR_P0UP        0x000000002 /* Port0 Pull Up Enable */
+  #define SH7751_PCIPCTR_P0IO        0x000000001 /* Port0 Output Enable */
+#define SH7751_PCIPDTR             0x204         /* Port Data Register */
+  #define SH7751_PCIPDTR_PB5         0x000000020 /* Port 5 Enable */
+  #define SH7751_PCIPDTR_PB4         0x000000010 /* Port 4 Enable */
+  #define SH7751_PCIPDTR_PB3         0x000000008 /* Port 3 Enable */
+  #define SH7751_PCIPDTR_PB2         0x000000004 /* Port 2 Enable */
+  #define SH7751_PCIPDTR_PB1         0x000000002 /* Port 1 Enable */
+  #define SH7751_PCIPDTR_PB0         0x000000001 /* Port 0 Enable */
+#define SH7751_PCIPDR              0x220         /* Port IO Data Register */
+
+/* Memory Control Registers */
+#define SH7751_BCR1                0xFF800000    /* Memory BCR1 Register */
+#define SH7751_BCR2                0xFF800004    /* Memory BCR2 Register */
+#define SH7751_WCR1                0xFF800008    /* Wait Control 1 Register */
+#define SH7751_WCR2                0xFF80000C    /* Wait Control 2 Register */
+#define SH7751_WCR3                0xFF800010    /* Wait Control 3 Register */
+#define SH7751_MCR                 0xFF800014    /* Memory Control Register */
+
+/* General Memory Config Addresses */
+#define SH7751_CS0_BASE_ADDR       0x0
+#define SH7751_MEM_REGION_SIZE     0x04000000
+#define SH7751_CS1_BASE_ADDR       (SH7751_CS0_BASE_ADDR + SH7751_MEM_REGION_SIZE)
+#define SH7751_CS2_BASE_ADDR       (SH7751_CS1_BASE_ADDR + SH7751_MEM_REGION_SIZE)
+#define SH7751_CS3_BASE_ADDR       (SH7751_CS2_BASE_ADDR + SH7751_MEM_REGION_SIZE)
+#define SH7751_CS4_BASE_ADDR       (SH7751_CS3_BASE_ADDR + SH7751_MEM_REGION_SIZE)
+#define SH7751_CS5_BASE_ADDR       (SH7751_CS4_BASE_ADDR + SH7751_MEM_REGION_SIZE)
+#define SH7751_CS6_BASE_ADDR       (SH7751_CS5_BASE_ADDR + SH7751_MEM_REGION_SIZE)
+
+/* General PCI values */
+#define SH7751_PCI_HOST_BRIDGE		0x6
+
+/* External functions defined per platform i.e. Big Sur, SE... (these could be routed 
+ * through the machine vectors... */
+extern int pcibios_init_platform(void);
+extern int pcibios_map_platform_irq(u8 slot, u8 pin);
+
+struct sh7751_pci_address_space {
+	unsigned long base;
+	unsigned long size;
+};
+
+struct sh7751_pci_address_map {
+	struct sh7751_pci_address_space window0;
+	struct sh7751_pci_address_space window1;
+};
+
+/* arch/sh/drivers/pci/pci-sh7751.c */
+extern int sh7751_pcic_init(struct sh7751_pci_address_map *map);
+
+#endif /* _PCI_SH7751_H_ */
+
diff -puN /dev/null arch/sh/drivers/pci/pci-st40.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/pci/pci-st40.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,423 @@
+/* 
+ * Copyright (C) 2001 David J. Mckay (david.mckay@st.com)
+ *
+ * May be copied or modified under the terms of the GNU General Public
+ * License.  See linux/COPYING for more information.                            
+ *
+ * Support functions for the ST40 PCI hardware.
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/smp.h>
+#include <linux/smp_lock.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/pci.h>
+#include <linux/delay.h>
+#include <linux/types.h>
+#include <asm/pci.h>
+#include <linux/irq.h>
+
+#include "pci-st40.h"
+
+/* This is in P2 of course */
+#define ST40PCI_BASE_ADDRESS     (0xb0000000)
+#define ST40PCI_MEM_ADDRESS      (ST40PCI_BASE_ADDRESS+0x0)
+#define ST40PCI_IO_ADDRESS       (ST40PCI_BASE_ADDRESS+0x06000000)
+#define ST40PCI_REG_ADDRESS      (ST40PCI_BASE_ADDRESS+0x07000000)
+
+#define ST40PCI_REG(x) (ST40PCI_REG_ADDRESS+(ST40PCI_##x))
+
+#define ST40PCI_WRITE(reg,val) writel((val),ST40PCI_REG(reg))
+#define ST40PCI_WRITE_SHORT(reg,val) writew((val),ST40PCI_REG(reg))
+#define ST40PCI_WRITE_BYTE(reg,val) writeb((val),ST40PCI_REG(reg))
+
+#define ST40PCI_READ(reg) readl(ST40PCI_REG(reg))
+#define ST40PCI_READ_SHORT(reg) readw(ST40PCI_REG(reg))
+#define ST40PCI_READ_BYTE(reg) readb(ST40PCI_REG(reg))
+
+#define ST40PCI_SERR_IRQ        64
+#define ST40PCI_SERR_INT_GROUP  0
+#define ST40PCI_SERR_INT_POS    0
+#define ST40PCI_SERR_INT_PRI    15
+
+#define ST40PCI_ERR_IRQ        65
+#define ST40PCI_ERR_INT_GROUP   1
+#define ST40PCI_ERR_INT_POS     1
+#define ST40PCI_ERR_INT_PRI     14
+
+
+/* Macros to extract PLL params */
+#define PLL_MDIV(reg)  ( ((unsigned)reg) & 0xff )
+#define PLL_NDIV(reg) ( (((unsigned)reg)>>8) & 0xff )
+#define PLL_PDIV(reg) ( (((unsigned)reg)>>16) & 0x3 )
+#define PLL_SETUP(reg) ( (((unsigned)reg)>>19) & 0x1ff )
+
+/* Build up the appropriate settings */
+#define PLL_SET(mdiv,ndiv,pdiv,setup) \
+( ((mdiv)&0xff) | (((ndiv)&0xff)<<8) | (((pdiv)&3)<<16)| (((setup)&0x1ff)<<19))
+
+#define PLLPCICR (0xbb040000+0x10)
+
+#define PLLPCICR_POWERON (1<<28)
+#define PLLPCICR_OUT_EN (1<<29)
+#define PLLPCICR_LOCKSELECT (1<<30)
+#define PLLPCICR_LOCK (1<<31)
+
+
+#define PLL_25MHZ 0x793c8512
+#define PLL_33MHZ PLL_SET(18,88,3,295)
+
+
+static __init void SetPCIPLL(void)
+{
+	/* Stop the PLL */
+	writel(0, PLLPCICR);
+
+	/* Always run at 33Mhz. The PCI clock is totally async 
+	 * to the rest of the system
+	 */
+	writel(PLL_33MHZ | PLLPCICR_POWERON, PLLPCICR);
+
+	printk("ST40PCI: Waiting for PCI PLL to lock\n");
+	while ((readl(PLLPCICR) & PLLPCICR_LOCK) == 0);
+	writel(readl(PLLPCICR) | PLLPCICR_OUT_EN, PLLPCICR);
+}
+
+
+static irqreturn_t st40_pci_irq(int irq, void *dev_instance, struct pt_regs *regs)
+{
+
+	unsigned pci_int, pci_air, pci_cir, pci_aint;
+
+	pci_int = ST40PCI_READ(INT);
+	pci_cir = ST40PCI_READ(CIR);
+	pci_air = ST40PCI_READ(AIR);
+
+	if (pci_int) {
+		printk("PCI INTERRUPT!\n");
+		printk("PCI INT -> 0x%x\n", pci_int & 0xffff);
+		printk("PCI AIR -> 0x%x\n", pci_air);
+		printk("PCI CIR -> 0x%x\n", pci_cir);
+		ST40PCI_WRITE(INT, ~0);
+	}
+
+	pci_aint = ST40PCI_READ(AINT);
+	if (pci_aint) {
+		printk("PCI ARB INTERRUPT!\n");
+		printk("PCI AINT -> 0x%x\n", pci_aint);
+		printk("PCI AIR -> 0x%x\n", pci_air);
+		printk("PCI CIR -> 0x%x\n", pci_cir);
+		ST40PCI_WRITE(AINT, ~0);
+	}
+
+	return IRQ_HANDLED;
+}
+
+
+/* Rounds a number UP to the nearest power of two. Used for
+ * sizing the PCI window.
+ */
+static u32 __init r2p2(u32 num)
+{
+	int i = 31;
+	u32 tmp = num;
+
+	if (num == 0)
+		return 0;
+
+	do {
+		if (tmp & (1 << 31))
+			break;
+		i--;
+		tmp <<= 1;
+	} while (i >= 0);
+
+	tmp = 1 << i;
+	/* If the original number isn't a power of 2, round it up */
+	if (tmp != num)
+		tmp <<= 1;
+
+	return tmp;
+}
+
+static void __init pci_fixup_ide_bases(struct pci_dev *d)
+{
+	int i;
+
+	/*
+	 * PCI IDE controllers use non-standard I/O port decoding, respect it.
+	 */
+	if ((d->class >> 8) != PCI_CLASS_STORAGE_IDE)
+		return;
+	printk("PCI: IDE base address fixup for %s\n", d->slot_name);
+	for(i=0; i<4; i++) {
+		struct resource *r = &d->resource[i];
+		if ((r->start & ~0x80) == 0x374) {
+			r->start |= 2;
+			r->end = r->start;
+		}
+	}
+}
+
+
+/* Add future fixups here... */
+struct pci_fixup pcibios_fixups[] = {
+	{ PCI_FIXUP_HEADER,	PCI_ANY_ID,	PCI_ANY_ID,	pci_fixup_ide_bases },
+	{ 0 }
+};
+
+int __init st40pci_init(unsigned memStart, unsigned memSize)
+{
+	u32 lsr0;
+
+	SetPCIPLL();
+
+	/* Initialises the ST40 pci subsystem, performing a reset, then programming
+	 * up the address space decoders appropriately
+	 */
+
+	/* Should reset core here as well methink */
+
+	ST40PCI_WRITE(CR, CR_LOCK_MASK | CR_SOFT_RESET);
+
+	/* Loop while core resets */
+	while (ST40PCI_READ(CR) & CR_SOFT_RESET);
+
+	/* Now, lets reset all the cards on the bus with extreme prejudice */
+	ST40PCI_WRITE(CR, CR_LOCK_MASK | CR_RSTCTL);
+	udelay(250);
+
+	/* Set bus active, take it out of reset */
+	ST40PCI_WRITE(CR, CR_LOCK_MASK | CR_CFINT | CR_PFCS | CR_PFE);
+
+	/* The PCI spec says that no access must be made to the bus until 1 second
+	 * after reset. This seem ludicrously long, but some delay is needed here
+	 */
+	mdelay(1000);
+
+	/* Switch off interrupts */
+	ST40PCI_WRITE(INTM, 0);
+	ST40PCI_WRITE(AINT, 0);
+
+	/* Allow it to be a master */
+
+	ST40PCI_WRITE_SHORT(CSR_CMD,
+			    PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
+			    PCI_COMMAND_IO);
+
+	/* Accesse to the 0xb0000000 -> 0xb6000000 area will go through to 0x10000000 -> 0x16000000
+	 * on the PCI bus. This allows a nice 1-1 bus to phys mapping.
+	 */
+
+
+	ST40PCI_WRITE(MBR, 0x10000000);
+	/* Always set the max size 128M (actually, it is only 96MB wide) */
+	ST40PCI_WRITE(MBMR, 0x07ff0000);
+
+	/* I/O addresses are mapped at 0xb6000000 -> 0xb7000000. These are changed to 0, to 
+	 * allow cards that have legacy io such as vga to function correctly. This gives a 
+	 * maximum of 64K of io/space as only the bottom 16 bits of the address are copied 
+	 * over to the bus  when the transaction is made. 64K of io space is more than enough
+	 */
+	ST40PCI_WRITE(IOBR, 0x0);
+	/* Set up the 64K window */
+	ST40PCI_WRITE(IOBMR, 0x0);
+
+	/* Now we set up the mbars so the PCI bus can see the memory of the machine */
+
+	if (memSize < (64 * 1024)) {
+		printk("Ridiculous memory size of 0x%x?\n",memSize);
+		return 0;
+	}
+
+	lsr0 =
+	    (memSize >
+	     (512 * 1024 * 1024)) ? 0x1fff0001 : ((r2p2(memSize) -
+						   0x10000) | 0x1);
+
+	ST40PCI_WRITE(LSR0, lsr0);
+
+	ST40PCI_WRITE(CSR_MBAR0, memStart);
+	ST40PCI_WRITE(LAR0, memStart);
+
+	/* Maximise timeout values */
+	ST40PCI_WRITE_BYTE(CSR_TRDY, 0xff);
+	ST40PCI_WRITE_BYTE(CSR_RETRY, 0xff);
+	ST40PCI_WRITE_BYTE(CSR_MIT, 0xff);
+
+
+	/* Install the pci interrupt handlers */
+	make_intc2_irq(ST40PCI_SERR_IRQ, INTC2_BASE0,
+		       ST40PCI_SERR_INT_GROUP, ST40PCI_SERR_INT_POS,
+		       ST40PCI_SERR_INT_PRI);
+
+	make_intc2_irq(ST40PCI_ERR_IRQ, INTC2_BASE0, ST40PCI_ERR_INT_GROUP,
+		       ST40PCI_ERR_INT_POS, ST40PCI_ERR_INT_PRI);
+
+
+	return 1;
+}
+
+char * __init pcibios_setup(char *str)
+{
+	return str;
+}
+
+
+#define SET_CONFIG_BITS(bus,devfn,where)\
+  (((bus) << 16) | ((devfn) << 8) | ((where) & ~3) | (bus!=0))
+
+#define CONFIG_CMD(bus, devfn, where) SET_CONFIG_BITS(bus->number,devfn,where)
+
+
+static int CheckForMasterAbort(void)
+{
+	if (ST40PCI_READ(INT) & INT_MADIM) {
+		/* Should we clear config space version as well ??? */
+		ST40PCI_WRITE(INT, INT_MADIM);
+		ST40PCI_WRITE_SHORT(CSR_STATUS, 0);
+		return 1;
+	}
+
+	return 0;
+}
+
+/* Write to config register */
+static int st40pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 * val)
+{
+	ST40PCI_WRITE(PAR, CONFIG_CMD(bus, devfn, where));
+	switch (size) {
+		case 1:
+			*val = (u8)ST40PCI_READ_BYTE(PDR + (where & 3));
+			break;
+		case 2:
+			*val = (u16)ST40PCI_READ_SHORT(PDR + (where & 2));
+			break;
+		case 4:
+			*val = ST40PCI_READ(PDR);
+			break;
+	}
+
+	if (CheckForMasterAbort()){
+		switch (size) {
+			case 1:
+				*val = (u8)0xff;
+				break;
+			case 2:
+				*val = (u16)0xffff;
+				break;
+			case 4:
+				*val = 0xffffffff;
+				break;
+		}
+	}
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int st40pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val)
+{
+	ST40PCI_WRITE(PAR, CONFIG_CMD(bus, devfn, where));
+
+	switch (size) {
+		case 1:
+			ST40PCI_WRITE_BYTE(PDR + (where & 3), (u8)val);
+			break;
+		case 2:
+			ST40PCI_WRITE_SHORT(PDR + (where & 2), (u16)val);
+			break;
+		case 4:
+			ST40PCI_WRITE(PDR, val);
+			break;
+	}
+
+	CheckForMasterAbort();
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static struct pci_ops pci_config_ops = {
+	.read = 	st40pci_read,
+	.write = 	st40pci_write,
+};
+
+
+/* Everything hangs off this */
+static struct pci_bus *pci_root_bus;
+
+
+static u8 __init no_swizzle(struct pci_dev *dev, u8 * pin)
+{
+	return PCI_SLOT(dev->devfn);
+}
+
+
+/* This needs to be shunted out of here into the board specific bit */
+#define HARP_PCI_IRQ    1
+#define HARP_BRIDGE_IRQ 2
+#define OVERDRIVE_SLOT0_IRQ 0
+
+static int __init map_harp_irq(struct pci_dev *dev, u8 slot, u8 pin)
+{
+	switch (slot) {
+#ifdef CONFIG_SH_STB1_HARP
+	case 2:		/*This is the PCI slot on the */
+		return HARP_PCI_IRQ;
+	case 1:		/* this is the bridge */
+		return HARP_BRIDGE_IRQ;
+#elif defined(CONFIG_SH_STB1_OVERDRIVE)
+	case 1:
+	case 2:
+	case 3:
+		return slot - 1;
+#else
+#error Unknown board
+#endif
+	default:
+		return -1;
+	}
+}
+
+void __init pcibios_init(void)
+{
+	extern unsigned long memory_start, memory_end;
+
+	if (sh_mv.mv_init_pci != NULL) {
+		sh_mv.mv_init_pci();
+	}
+
+	/* The pci subsytem needs to know where memory is and how much 
+	 * of it there is. I've simply made these globals. A better mechanism
+	 * is probably needed.
+	 */
+	st40pci_init(PHYSADDR(memory_start),
+		     PHYSADDR(memory_end) - PHYSADDR(memory_start));
+
+	if (request_irq(ST40PCI_ERR_IRQ, st40_pci_irq, 
+                        SA_INTERRUPT, "st40pci", NULL)) {
+		printk(KERN_ERR "st40pci: Cannot hook interrupt\n");
+		return;
+	}
+
+	/* Enable the PCI interrupts on the device */
+	ST40PCI_WRITE(INTM, ~0);
+	ST40PCI_WRITE(AINT, ~0);
+
+	/* Map the io address apprioately */
+#ifdef CONFIG_HD64465
+	hd64465_port_map(PCIBIOS_MIN_IO, (64 * 1024) - PCIBIOS_MIN_IO + 1,
+			 ST40_IO_ADDR + PCIBIOS_MIN_IO, 0);
+#endif
+
+	/* ok, do the scan man */
+	pci_root_bus = pci_scan_bus(0, &pci_config_ops, NULL);
+	pci_assign_unassigned_resources();
+	pci_fixup_irqs(no_swizzle, map_harp_irq);
+
+}
+
+void __init pcibios_fixup_bus(struct pci_bus *bus)
+{
+}
diff -puN /dev/null arch/sh/drivers/pci/pci-st40.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/drivers/pci/pci-st40.h	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,66 @@
+/* 
+ * Copyright (C) 2001 David J. Mckay (david.mckay@st.com)
+ *
+ * May be copied or modified under the terms of the GNU General Public
+ * License.  See linux/COPYING for more information.                            
+ *
+ * Defintions for the ST40 PCI hardware.
+ */
+
+#ifndef __PCI_ST40_H__
+#define __PCI_ST40_H__
+
+#define ST40PCI_VCR_STATUS    0x00
+
+#define ST40PCI_VCR_VERSION   0x08
+
+#define ST40PCI_CR            0x10
+
+#define CR_SOFT_RESET (1<<12)
+#define CR_PFCS       (1<<11)
+#define CR_PFE        (1<<9)
+#define CR_BMAM       (1<<6)
+#define CR_HOST       (1<<5)
+#define CR_CLKEN      (1<<4)
+#define CR_SOCS       (1<<3)
+#define CR_IOCS       (1<<2)
+#define CR_RSTCTL     (1<<1)
+#define CR_CFINT      (1<<0)
+#define CR_LOCK_MASK  0x5a000000
+
+
+#define ST40PCI_LSR0          0X14
+#define ST40PCI_LAR0          0x1c
+
+#define ST40PCI_INT           0x24
+#define INT_MADIM             (1<<2)
+
+
+#define ST40PCI_INTM          0x28
+#define ST40PCI_AIR           0x2c
+#define ST40PCI_CIR           0x30
+#define ST40PCI_AINT          0x40
+#define ST40PCI_AINTM         0x44
+#define ST40PCI_BMIR          0x48
+#define ST40PCI_PAR           0x4c
+#define ST40PCI_MBR           0x50
+#define ST40PCI_IOBR          0x54
+#define ST40PCI_PINT          0x58
+#define ST40PCI_PINTM         0x5c
+#define ST40PCI_MBMR          0x70
+#define ST40PCI_IOBMR         0x74
+#define ST40PCI_PDR           0x78
+
+/* These are configs space registers */
+#define ST40PCI_CSR_VID               0x10000
+#define ST40PCI_CSR_DID               0x10002
+#define ST40PCI_CSR_CMD               0x10004
+#define ST40PCI_CSR_STATUS            0x10006
+#define ST40PCI_CSR_MBAR0             0x10010
+#define ST40PCI_CSR_TRDY              0x10040
+#define ST40PCI_CSR_RETRY             0x10041
+#define ST40PCI_CSR_MIT               0x1000d
+
+#define ST40_IO_ADDR 0xb6000000       
+
+#endif /* __PCI_ST40_H__ */
diff -puN arch/sh/Kconfig~linus arch/sh/Kconfig
--- 25/arch/sh/Kconfig~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -25,14 +25,6 @@ config RWSEM_GENERIC_SPINLOCK
 config RWSEM_XCHGADD_ALGORITHM
 	bool
 
-config GENERIC_ISA_DMA
-	bool
-	default y
-
-config VARIABLE_CLOCK_TICK_RATE
-	bool
-	default y
-
 source "init/Kconfig"
 
 
@@ -54,6 +46,12 @@ config SH_7751_SOLUTION_ENGINE
 	  Select 7751 SolutionEngine if configuring for a Hitachi SH7751
 	  evalutation board.
 
+config SH_7751_SYSTEMH
+	bool "SystemH7751R"
+	help
+	  Select SystemH if you are configuring for a Renesas SystemH
+	  7751R evaluation board.
+
 config SH_STB1_HARP
 	bool "STB1_Harp"
 
@@ -102,6 +100,8 @@ config SH_EC3104
 
 config SH_SATURN
 	bool "Saturn"
+	help
+	  Select Saturn if configuring for a SEGA Saturn.
 
 config SH_DREAMCAST
 	bool "Dreamcast"
@@ -132,6 +132,13 @@ config SH_ADX
 config SH_MPC1211
 	bool "MPC1211"
 
+config SH_SECUREEDGE5410
+	bool "SecureEdge5410"
+	help
+	  Select SecureEdge5410 if configuring for a SnapGear SH board.
+	  This includes both the OEM SecureEdge products as well as the
+	  SME product line.
+
 config SH_UNKNOWN
 	bool "BareCPU"
 	help
@@ -146,6 +153,85 @@ config SH_UNKNOWN
 
 endchoice
 
+choice
+	prompt "Processor family"
+	default CPU_SH4
+	help
+	  This option determines the CPU family to compile for. Supported
+	  targets are SH-2, SH-3, and SH-4. These options are independent of
+	  CPU functionality. As such, SH-DSP users will still want to select
+	  their respective processor family in addition to the DSP support
+	  option.
+
+config CPU_SH2
+	bool "SH-2"
+	select SH_WRITETHROUGH
+
+config CPU_SH3
+	bool "SH-3"
+
+config CPU_SH4
+	bool "SH-4"
+
+endchoice
+
+choice
+	prompt "Processor subtype"
+	
+config CPU_SUBTYPE_SH7604
+	bool "SH7604"
+	depends on CPU_SH2
+	help
+	  Select SH7604 if you have SH7604
+
+config CPU_SUBTYPE_SH7300
+	bool "SH7300"
+	depends on CPU_SH3
+	  
+config CPU_SUBTYPE_SH7707
+	bool "SH7707"
+	depends on CPU_SH3
+	help
+	  Select SH7707 if you have a  60 Mhz SH-3 HD6417707 CPU.
+
+config CPU_SUBTYPE_SH7708
+	bool "SH7708"
+	depends on CPU_SH3
+	help
+	  Select SH7708 if you have a  60 Mhz SH-3 HD6417708S or
+	  if you have a 100 Mhz SH-3 HD6417708R CPU.
+
+config CPU_SUBTYPE_SH7709
+	bool "SH7709"
+	depends on CPU_SH3
+	help
+	  Select SH7709 if you have a  80 Mhz SH-3 HD6417709 CPU.
+
+config CPU_SUBTYPE_SH7750
+	bool "SH7750"
+	depends on CPU_SH4
+	help
+	  Select SH7750 if you have a 200 Mhz SH-4 HD6417750 CPU.
+
+config CPU_SUBTYPE_SH7751
+	bool "SH7751/SH7751R"
+	depends on CPU_SH4
+	help
+	  Select SH7751 if you have a 166 Mhz SH-4 HD6417751 CPU,
+	  or if you have a HD6417751R CPU.
+
+config CPU_SUBTYPE_SH7760
+	bool "SH7760"
+	depends on CPU_SH4
+
+config CPU_SUBTYPE_ST40STB1
+	bool "ST40STB1"
+	depends on CPU_SH4
+	help
+	  Select ST40STB1 if you have a ST40STB1 CPU.
+
+endchoice
+
 config MMU
         bool "Support for memory management hardware"
 	depends on !CPU_SH2
@@ -169,8 +255,8 @@ config CMDLINE
 # Platform-specific memory start and size definitions
 config MEMORY_START
 	hex "Physical memory start address" if !MEMORY_SET || MEMORY_OVERRIDE
-	default "08000000" if !MEMORY_SET || MEMORY_OVERRIDE || !MEMORY_OVERRIDE && SH_ADX || SH_MPC1211
-	default "0c000000" if !MEMORY_OVERRIDE && (SH_DREAMCAST || SH_HP600 || SH_BIGSUR || SH_SH2000 || SH_7751_SOLUTION_ENGINE || SH_SOLUTION_ENGINE)
+	default "0x08000000" if !MEMORY_SET || MEMORY_OVERRIDE || !MEMORY_OVERRIDE && SH_ADX || SH_MPC1211 || SH_SECUREEDGE5410
+	default "0x0c000000" if !MEMORY_OVERRIDE && (SH_DREAMCAST || SH_HP600 || SH_BIGSUR || SH_SH2000 || SH_7751_SOLUTION_ENGINE || SH_SOLUTION_ENGINE)
 	---help---
 	  Computers built with Hitachi SuperH processors always
 	  map the ROM starting at address zero.  But the processor
@@ -187,11 +273,11 @@ config MEMORY_START
 
 config MEMORY_SIZE
 	hex "Physical memory size" if !MEMORY_SET || MEMORY_OVERRIDE
-	default "00400000" if !MEMORY_SET || MEMORY_OVERRIDE || !MEMORY_OVERRIDE && SH_ADX || !MEMORY_OVERRIDE && (SH_HP600 || SH_BIGSUR || SH_SH2000)
-	default "01000000" if !MEMORY_OVERRIDE && SH_DREAMCAST
-	default "04000000" if !MEMORY_OVERRIDE && SH_7751_SOLUTION_ENGINE
-	default "02000000" if !MEMORY_OVERRIDE && SH_SOLUTION_ENGINE
-	default "08000000" if SH_MPC1211
+	default "0x00400000" if !MEMORY_SET || MEMORY_OVERRIDE || !MEMORY_OVERRIDE && SH_ADX || !MEMORY_OVERRIDE && (SH_HP600 || SH_BIGSUR || SH_SH2000)
+	default "0x01000000" if !MEMORY_OVERRIDE && SH_DREAMCAST || SH_SECUREEDGE5410
+	default "0x04000000" if !MEMORY_OVERRIDE && SH_7751_SOLUTION_ENGINE
+	default "0x02000000" if !MEMORY_OVERRIDE && SH_SOLUTION_ENGINE
+	default "0x08000000" if SH_MPC1211
 	help
 	  This sets the default memory size assumed by your SH kernel. It can
 	  be overridden as normal by the 'mem=' argument on the kernel command
@@ -201,7 +287,7 @@ config MEMORY_SIZE
 
 config MEMORY_SET
 	bool
-	depends on !MEMORY_OVERRIDE && (SH_MPC1211 || SH_ADX || SH_DREAMCAST || SH_HP600 || SH_BIGSUR || SH_SH2000 || SH_7751_SOLUTION_ENGINE || SH_SOLUTION_ENGINE)
+	depends on !MEMORY_OVERRIDE && (SH_MPC1211 || SH_ADX || SH_DREAMCAST || SH_HP600 || SH_BIGSUR || SH_SH2000 || SH_7751_SOLUTION_ENGINE || SH_SOLUTION_ENGINE || SH_SECUREEDGE5410)
 	default y
 	help
 	  This is an option about which you will never be asked a question.
@@ -254,15 +340,13 @@ endchoice
 config CF_BASE_ADDR
 	hex
 	depends on CF_ENABLER
-	default "b8000000" if CF_AREA6
-	default "b4000000" if CF_AREA5
-
-endmenu
+	default "0xb8000000" if CF_AREA6
+	default "0xb4000000" if CF_AREA5
 
 # The SH7750 RTC module is disabled in the Dreamcast
 config SH_RTC
 	bool
-	depends on !SH_DREAMCAST
+	depends on !SH_DREAMCAST && !SH_SATURN
 	default y
 	help
 	  Selecting this option will allow the Linux kernel to emulate
@@ -270,9 +354,16 @@ config SH_RTC
 
 	  If unsure, say N.
 
-# This is also board-specific
-config PCI_AUTO
-	bool
+config SH_DSP
+	bool "DSP support"
+	depends on !CPU_SH4
+	default y
+	help
+	  Selecting this option will enable support for SH processors that
+	  have DSP units (ie, SH2-DSP and SH3-DSP). It is safe to say Y here
+	  by default, as the existance of the DSP will be probed at runtime.
+
+	  This option must be set in order to enable the DSP.
 
 config SH_HP600
 	bool
@@ -289,91 +380,10 @@ config DISCONTIGMEM
 	  or have huge holes in the physical address space for other reasons.
 	  See <file:Documentation/vm/numa> for more.
 
-
-menu "Processor type and features"
-
-#
-# Ick, get rid of all this CPU_SUBTYPE nonsense. Just probe it, fill in
-# cpu_data, and leave it alone. (Feasible for SH-4 at least, and some
-# SH-3). ++paulm
-#
-choice
-	prompt "Processor type"
-	default CPU_SUBTYPE_SH7708
-
-config CPU_SUBTYPE_SH7604
-	bool "SH7604"
-	help
-	  Select SH7604 if you have SH7604
-
-config CPU_SUBTYPE_SH7707
-	bool "SH7707"
-	---help---
-	  Select the type of SuperH processor you have. This information is
-	  used for optimizing and configuration purposes.
-
-          Select SH7604 if you have a SH-2 CPU.
-
-	  Select SH7707 if you have a  60 Mhz SH-3 HD6417707 CPU.
-
-	  Select SH7708 if you have a  60 Mhz SH-3 HD6417708S or
-	  if you have a 100 Mhz SH-3 HD6417708R CPU.
-
-	  Select SH7709 if you have a  80 Mhz SH-3 HD6417709 CPU.
-
-	  Select SH7750 if you have a 200 Mhz SH-4 HD6417750 CPU.
-
-	  Select SH7751 if you have a SH7751
-
-	  Select ST40STB1 if you have a ST40STB1
-
-config CPU_SUBTYPE_SH7708
-	bool "SH7708"
-	help
-	  Select SH7708 if you have a  60 Mhz SH-3 HD6417708S or
-	  if you have a 100 Mhz SH-3 HD6417708R CPU.
-
-config CPU_SUBTYPE_SH7709
-	bool "SH7709"
-	help
-	  Select SH7709 if you have a  80 Mhz SH-3 HD6417709 CPU.
-
-config CPU_SUBTYPE_SH7750
-	bool "SH7750"
-	help
-	  Select SH7750 if you have a 200 Mhz SH-4 HD6417750 CPU.
-
-config CPU_SUBTYPE_SH7751
-	bool "SH7751"
-	help
-	  Select SH7750 if you have a 166 Mhz SH-4 HD6417751 CPU.
-
-config CPU_SUBTYPE_ST40STB1
-	bool "ST40STB1"
-	help
-	  Select ST40STB1 if you have a ST40STB1 CPU.
-
-endchoice
-
-config CPU_SH2
-	bool
-	depends on CPU_SUBTYPE_SH7604
-	default y
-
-config CPU_SH3
-	bool
-	depends on !CPU_SH2 && (CPU_SUBTYPE_SH7707 || CPU_SUBTYPE_SH7708 || CPU_SUBTYPE_SH7709)
-	default y
-
-config CPU_SH4
-	bool
-	depends on !CPU_SH3 && !CPU_SH2 && (CPU_SUBTYPE_SH7750 || CPU_SUBTYPE_SH7751 || CPU_SUBTYPE_ST40STB1)
-	default y
-
 config ZERO_PAGE_OFFSET
 	hex "Zero page offset"
-	default "00001000" if !SH_MPC1211
-	default "00004000" if SH_MPC1211
+	default "0x00001000" if !SH_MPC1211
+	default "0x00004000" if SH_MPC1211
 	help
 	  This sets the default offset of zero page.
 
@@ -385,18 +395,26 @@ config ST40_LMI_MEMORY
 config MEMORY_START
 	hex
 	depends on CPU_SUBTYPE_ST40STB1 && ST40_LMI_MEMORY
-	default "08000000"
+	default "0x08000000"
 
 config MEMORY_SIZE
 	hex
 	depends on CPU_SUBTYPE_ST40STB1 && ST40_LMI_MEMORY
-	default "00400000"
+	default "0x00400000"
 
 config MEMORY_SET
 	bool
 	depends on CPU_SUBTYPE_ST40STB1 && ST40_LMI_MEMORY
 	default y
 
+config BOOT_LINK_OFFSET
+	hex "Link address offset for booting"
+	default "0x00800000"
+	help
+	  This option allows you to set the link address offset of the zImage.
+	  This can be useful if you are on a board which has a small amount of
+	  memory.
+
 config CPU_LITTLE_ENDIAN
 	bool "Little Endian"
 	help
@@ -442,6 +460,13 @@ config SH_OCRAM
 
 	  If unsure, say N.
 
+config SH_STORE_QUEUES
+	bool "Support for Store Queues"
+	depends on CPU_SH4
+	help
+	  Selecting this option will enable an in-kernel API for manipulating
+	  the store queues integrated in the SH-4 processors.
+	
 config SMP
 	bool "Symmetric multi-processing support"
 	---help---
@@ -467,6 +492,7 @@ config SMP
 
 config NR_CPUS
 	int "Maximum number of CPUs (2-32)"
+	range 2 32
 	depends on SMP
 	default "2"
 	help
@@ -477,13 +503,18 @@ config NR_CPUS
 	  This is purely to save memory - each supported CPU adds
 	  approximately eight kilobytes to the kernel image.
 
-config SH_DMA
-	bool "DMA controller (DMAC) support"
-	help
-	  Selecting this option will provide same API as PC's Direct Memory
-	  Access Controller(8237A) for SuperH DMAC.
-
-	  If unsure, say N.
+config SH_PCLK_FREQ
+	int "Peripheral clock frequency (in Hz)"
+	default "49876504" if CPU_SUBTYPE_SH7750
+	default "60013568" if CPU_SUBTYPE_SH7751
+	default "1193182"
+	help
+	  This option is used to specify the peripheral clock frequency. This
+	  option must be set for each processor in order for the kernel to
+	  function reliably. If no sane default exists, we use a default from
+	  the legacy i8254. Any discrepancies will be reported on boot time
+	  with an auto-probed frequency which should be considered the proper
+	  value for your hardware.
 
 config CPU_FREQ
 	bool "CPU Frequency scaling"
@@ -518,80 +549,9 @@ config SH_CPU_FREQ
 
 source "drivers/cpufreq/Kconfig"
 
-# A board must have defined HD6446X_SERIES in order to see these
-choice
-	prompt "HD6446x options"
-	depends HD6446X_SERIES
-	default HD64461
-
-config HD64461
-	bool "Hitachi HD64461 companion chip support"
-	depends on CPU_SUBTYPE_SH7709
-	---help---
-	  The Hitachi HD64461 provides an interface for
-	  the SH7709 CPU, supporting a LCD controller,
-	  CRT color controller, IrDA up to 4 Mbps, and a
-	  PCMCIA controller supporting 2 slots.
-
-	  More information is available at
-	  <http://semiconductor.hitachi.com/windowsce/superh/sld013.htm>.
-
-	  Say Y if you want support for the HD64461.
-	  Otherwise, say N.
-
-config HD64465
-	bool "Hitachi HD64465 companion chip support"
-	depends on CPU_SUBTYPE_SH7750
-	---help---
-	  The Hitachi HD64465 provides an interface for
-	  the SH7750 CPU, supporting a LCD controller,
-	  CRT color controller, IrDA, USB, PCMCIA,
-	  keyboard controller, and a printer interface.
-
-	  More information is available at
-	  <http://global.hitachi.com/New/cnews/E/1998/981019B.html>.
-
-	  Say Y if you want support for the HD64465.
-	  Otherwise, say N.
-
-endchoice
-
-# These will also be split into the Kconfig's below
-config HD64461_IRQ
-	int "HD64461 IRQ"
-	depends on HD64461
-	default "36"
-	help
-	  The default setting of the HD64461 IRQ is 36.
-
-	  Do not change this unless you know what you are doing.
-
-config HD64461_ENABLER
-	bool "HD64461 PCMCIA enabler"
-	depends on HD64461
-	help
-	  Say Y here if you want to enable PCMCIA support
-	  via the HD64461 companion chip.
-	  Otherwise, say N.
-
+source "arch/sh/drivers/dma/Kconfig"
 
-config HD64465_IOBASE
-	hex "HD64465 start address"
-	depends on HD64465
-	default "b0000000"
-	help
-	  The default setting of the HD64465 IO base address is 0xb0000000.
-
-	  Do not change this unless you know what you are doing.
-
-config HD64465_IRQ
-	int "HD64465 IRQ"
-	depends on HD64465
-	default "5"
-	help
-	  The default setting of the HD64465 IRQ is 5.
-
-	  Do not change this unless you know what you are doing.
+source "arch/sh/cchips/Kconfig"
 
 endmenu
 
@@ -601,9 +561,13 @@ menu "Bus options (PCI, PCMCIA, EISA, MC
 # Even on SuperH devices which don't have an ISA bus,
 # this variable helps the PCMCIA modules handle
 # IRQ requesting properly -- Greg Banks.
+#
+# Though we're generally not interested in it when
+# we're not using PCMCIA, so we make it dependent on
+# PCMCIA outright. -- PFM.
 config ISA
 	bool
-	default y
+	default y if PCMCIA
 	help
 	  Find out whether you have ISA slots on your motherboard.  ISA is the
 	  name of a bus system, i.e. the way the CPU talks to the other stuff
@@ -637,68 +601,11 @@ config MCA
 config SBUS
 	bool
 
-config PCI
-	bool "PCI support"
-	help
-	  Find out whether you have a PCI motherboard. PCI is the name of a
-	  bus system, i.e. the way the CPU talks to the other stuff inside
-	  your box. Other bus systems are ISA, EISA, MicroChannel (MCA) or
-	  VESA. If you have PCI, say Y, otherwise N.
-
-	  The PCI-HOWTO, available from
-	  <http://www.tldp.org/docs.html#howto>, contains valuable
-	  information about which PCI hardware does work under Linux and which
-	  doesn't.
-
-choice
-	prompt "PCI access mode"
-	depends on PCI
-	default PCI_GOANY
-
-config PCI_GOBIOS
-	bool "BIOS"
-	---help---
-	  On PCI systems, the BIOS can be used to detect the PCI devices and
-	  determine their configuration. However, some old PCI motherboards
-	  have BIOS bugs and may crash if this is done. Also, some embedded
-	  PCI-based systems don't have any BIOS at all. Linux can also try to
-	  detect the PCI hardware directly without using the BIOS.
-
-	  With this option, you can specify how Linux should detect the PCI
-	  devices. If you choose "BIOS", the BIOS will be used, if you choose
-	  "Direct", the BIOS won't be used, and if you choose "Any", the
-	  kernel will try the direct access method and falls back to the BIOS
-	  if that doesn't work. If unsure, go with the default, which is
-	  "Any".
-
-config PCI_GODIRECT
-	bool "Direct"
-
-config PCI_GOANY
-	bool "Any"
-
-endchoice
-
-config PCI_BIOS
-	bool
-	depends on PCI && (PCI_GOBIOS || PCI_GOANY)
-	default y
-
-config PCI_DIRECT
+config MAPLE
 	bool
-	depends on PCI && (PCI_GODIRECT || PCI_GOANY)
-	default y
+	default y if SH_DREAMCAST
 
-config SH_PCIDMA_NONCOHERENT
-	bool "Cache and PCI noncoherent"
-	depends on PCI
-	help
-	  Enable this option if your platform does not have a CPU cache which
-	  remains coherent with PCI DMA. It is safest to say 'Y', although you
-	  will see better performance if you can say 'N', because the PCI DMA
-	  code will not have to flush the CPU's caches. If you have a PCI host
-	  bridge integrated with your SH CPU, refer carefully to the chip specs
-	  to see if you can say 'N' here. Otherwise, leave it as 'Y'.
+source "arch/sh/drivers/pci/Kconfig"
 
 source "drivers/pci/Kconfig"
 
@@ -762,10 +669,6 @@ source "drivers/telephony/Kconfig"
 #
 source "drivers/input/Kconfig"
 
-#if [ "$CONFIG_SH_DREAMCAST" = "y" ]; then
-#   source drivers/maple/Config.in
-#fi
-
 menu "Character devices"
 
 config VT
@@ -1136,6 +1039,7 @@ source "sound/Kconfig"
 
 source "drivers/usb/Kconfig"
 
+source "arch/sh/oprofile/Kconfig"
 
 menu "Kernel hacking"
 
@@ -1184,6 +1088,97 @@ config SH_EARLY_PRINTK
 	  when the kernel may crash or hang before the serial console is
 	  initialised. If unsure, say N.
 
+config KGDB
+	bool "Include KGDB kernel debugger"
+	help
+	  Include in-kernel hooks for kgdb, the Linux kernel source level
+	  debugger.  See <http://kgdb.sourceforge.net/> for more information.
+	  Unless you are intending to debug the kernel, say N here.
+
+menu "KGDB configuration options"
+	depends on KGDB
+
+config MORE_COMPILE_OPTIONS
+	bool "Add any additional compile options"
+	help
+	  If you want to add additional CFLAGS to the kernel build, enable this
+	  option and then enter what you would like to add in the next question.
+	  Note however that -g is already appended with the selection of KGDB.
+
+config COMPILE_OPTIONS
+	string "Additional compile arguments"
+	depends on MORE_COMPILE_OPTIONS
+
+config KGDB_NMI
+	bool "Enter KGDB on NMI"
+	default n
+
+config KGDB_THREAD
+	bool "Include KGDB thread support"
+	default y
+
+config SH_KGDB_CONSOLE
+	bool "Console messages through GDB"
+	default n
+
+config KGDB_SYSRQ
+	bool "Allow SysRq 'G' to enter KGDB"
+	default y
+
+config KGDB_KERNEL_ASSERTS
+	bool "Include KGDB kernel assertions"
+	default n
+
+comment "Serial port setup"
+
+config KGDB_DEFPORT
+	int "Port number (ttySCn)"
+	default "1"
+
+config KGDB_DEFBAUD
+	int "Baud rate"
+	default "115200"
+
+choice
+	prompt "Parity"
+	depends on KGDB
+	default KGDB_DEFPARITY_N
+
+config KGDB_DEFPARITY_N
+	bool "None"
+
+config KGDB_DEFPARITY_E
+	bool "Even"
+
+config KGDB_DEFPARITY_O
+	bool "Odd"
+
+endchoice
+
+choice
+	prompt "Data bits"
+	depends on KGDB
+	default KGDB_DEFBITS_8
+
+config KGDB_DEFBITS_8
+	bool "8"
+
+config KGDB_DEFBITS_7
+	bool "7"
+
+endchoice
+
+endmenu
+
+config FRAME_POINTER
+	bool "Compile the kernel with frame pointers"
+	default y if KGDB
+	help
+	  If you say Y here the resulting kernel image will be slightly larger
+	  and slower, but it will give very useful debugging information.
+	  If you don't debug the kernel, you can say N, but we may not be able
+	  to solve problems without frame pointers.
+
 endmenu
 
 source "security/Kconfig"
diff -puN -L arch/sh/kernel/cpu/dma.c arch/sh/kernel/cpu/dma.c~linus /dev/null
--- 25/arch/sh/kernel/cpu/dma.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,211 +0,0 @@
-/*
- * arch/sh/kernel/cpu/dma.c
- *
- * Copyright (C) 2000 Takashi YOSHII
- * Copyright (C) 2003 Paul Mundt
- *
- * PC like DMA API for SuperH's DMAC.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/irq.h>
-#include <linux/interrupt.h>
-#include <linux/module.h>
-
-#include <asm/signal.h>
-#include <asm/dma.h>
-
-static struct dma_info_t *dma_info[MAX_DMA_CHANNELS];
-static struct dma_info_t *autoinit_info[SH_MAX_DMA_CHANNELS] = {0};
-extern spinlock_t dma_spin_lock;
-
-/*
- * The SuperH DMAC supports a number of transmit sizes, we list them here,
- * with their respective values as they appear in the CHCR registers.
- *
- * Defaults to a 64-bit transfer size.
- */
-enum {
-	XMIT_SZ_64BIT	= 0,
-	XMIT_SZ_8BIT	= 1,
-	XMIT_SZ_16BIT	= 2,
-	XMIT_SZ_32BIT	= 3,
-	XMIT_SZ_256BIT	= 4,
-};
-
-/*
- * The DMA count is defined as the number of bytes to transfer.
- */
-static unsigned int ts_shift[] = {
-	[XMIT_SZ_64BIT]		3,
-	[XMIT_SZ_8BIT]		0,
-	[XMIT_SZ_16BIT]		1,
-	[XMIT_SZ_32BIT]		2,
-	[XMIT_SZ_256BIT]	5,
-};
-
-/*
- * We determine the correct shift size based off of the CHCR transmit size
- * for the given channel. Since we know that it will take:
- *
- * 	info->count >> ts_shift[transmit_size]
- *
- * iterations to complete the transfer.
- */
-static inline unsigned int calc_xmit_shift(struct dma_info_t *info)
-{
-	return ts_shift[(ctrl_inl(CHCR[info->chan]) >> 4) & 0x0007];
-}
-
-static irqreturn_t dma_tei(int irq, void *dev_id, struct pt_regs *regs)
-{
-	int chan = irq - DMTE_IRQ[0];
-	struct dma_info_t *info = autoinit_info[chan];
-
-	if( info->mode & DMA_MODE_WRITE )
-		ctrl_outl(info->mem_addr, SAR[info->chan]);
-	else
-		ctrl_outl(info->mem_addr, DAR[info->chan]);
-
-	ctrl_outl(info->count >> calc_xmit_shift(info), DMATCR[info->chan]);
-	ctrl_outl(ctrl_inl(CHCR[info->chan])&~CHCR_TE, CHCR[info->chan]);
-
-	return IRQ_HANDLED;
-}
-
-static struct irqaction irq_tei = {
-	.handler	= dma_tei,
-	.flags		= SA_INTERRUPT,
-	.name		= "dma_tei",
-};
-
-void setup_dma(unsigned int dmanr, struct dma_info_t *info)
-{
-	make_ipr_irq(DMTE_IRQ[info->chan], DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
-	setup_irq(DMTE_IRQ[info->chan], &irq_tei);
-	dma_info[dmanr] = info;
-}
-
-unsigned long claim_dma_lock(void)
-{
-	unsigned long flags;
-	spin_lock_irqsave(&dma_spin_lock, flags);
-	return flags;
-}
-
-void release_dma_lock(unsigned long flags)
-{
-	spin_unlock_irqrestore(&dma_spin_lock, flags);
-}
-
-void enable_dma(unsigned int dmanr)
-{
-	struct dma_info_t *info = dma_info[dmanr];
-	unsigned long chcr;
-
-	chcr = ctrl_inl(CHCR[info->chan]);
-	chcr |= CHCR_DE;
-	ctrl_outl(chcr, CHCR[info->chan]);
-}
-
-void disable_dma(unsigned int dmanr)
-{
-	struct dma_info_t *info = dma_info[dmanr];
-	unsigned long chcr;
-
-	chcr = ctrl_inl(CHCR[info->chan]);
-	chcr &= ~CHCR_DE;
-	ctrl_outl(chcr, CHCR[info->chan]);
-}
-
-void set_dma_mode(unsigned int dmanr, char mode)
-{
-	struct dma_info_t *info = dma_info[dmanr];
-
-	info->mode = mode;
-	set_dma_addr(dmanr, info->mem_addr);
-	set_dma_count(dmanr, info->count);
-	autoinit_info[info->chan] = info;
-}
-
-void set_dma_addr(unsigned int dmanr, unsigned int a)
-{
-	struct dma_info_t *info = dma_info[dmanr];
-	unsigned long sar, dar;
-
-	info->mem_addr = a;
-	sar = (info->mode & DMA_MODE_WRITE)? info->mem_addr: info->dev_addr;
-	dar = (info->mode & DMA_MODE_WRITE)? info->dev_addr: info->mem_addr;
-	ctrl_outl(sar, SAR[info->chan]);
-	ctrl_outl(dar, DAR[info->chan]);
-}
-
-void set_dma_count(unsigned int dmanr, unsigned int count)
-{
-	struct dma_info_t *info = dma_info[dmanr];
-	info->count = count;
-	ctrl_outl(count >> calc_xmit_shift(info), DMATCR[info->chan]);
-}
-
-int get_dma_residue(unsigned int dmanr)
-{
-	struct dma_info_t *info = dma_info[dmanr];
-	return (ctrl_inl(DMATCR[info->chan]) << calc_xmit_shift(info));
-}
-
-#if defined(CONFIG_CPU_SH4)
-static irqreturn_t dma_err(int irq, void *dev_id, struct pt_regs *regs)
-{
-	printk(KERN_WARNING "DMAE: DMAOR=%x\n",ctrl_inl(DMAOR));
-	ctrl_outl(ctrl_inl(DMAOR)&~DMAOR_NMIF, DMAOR);
-	ctrl_outl(ctrl_inl(DMAOR)&~DMAOR_AE, DMAOR);
-	ctrl_outl(ctrl_inl(DMAOR)|DMAOR_DME, DMAOR);
-
-	return IRQ_HANDLED;
-}
-
-static struct irqaction irq_err = {
-	.handler	= dma_err,
-	.flags		= SA_INTERRUPT,
-	.name		= "dma_err",
-};
-#endif
-
-int __init init_dma(void)
-{
-#if defined(CONFIG_CPU_SH4)
-	make_ipr_irq(DMAE_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
-	setup_irq(DMAE_IRQ, &irq_err);
-#endif
-
-	ctrl_outl(DMAOR_DME, DMAOR);
-	return 0;
-}
-
-static void __exit exit_dma(void)
-{
-#ifdef CONFIG_CPU_SH4
-	free_irq(DMAE_IRQ, 0);
-#endif
-}
-
-module_init(init_dma);
-module_exit(exit_dma);
-
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(setup_dma);
-EXPORT_SYMBOL(claim_dma_lock);
-EXPORT_SYMBOL(release_dma_lock);
-EXPORT_SYMBOL(enable_dma);
-EXPORT_SYMBOL(disable_dma);
-EXPORT_SYMBOL(set_dma_mode);
-EXPORT_SYMBOL(set_dma_addr);
-EXPORT_SYMBOL(set_dma_count);
-EXPORT_SYMBOL(get_dma_residue);
-
diff -puN /dev/null arch/sh/kernel/cpu/init.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/kernel/cpu/init.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,214 @@
+/*
+ * arch/sh/kernel/cpu/init.c
+ *
+ * CPU init code
+ *
+ * Copyright (C) 2002, 2003  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <asm/processor.h>
+#include <asm/uaccess.h>
+#include <asm/system.h>
+#include <asm/cacheflush.h>
+#include <asm/cache.h>
+#include <asm/io.h>
+
+extern void detect_cpu_and_cache_system(void);
+
+/*
+ * Generic wrapper for command line arguments to disable on-chip
+ * peripherals (nofpu, nodsp, and so forth).
+ */
+#define onchip_setup(x) 			\
+static int x##_disabled __initdata = 0; 	\
+						\
+static int __init x##_setup(char *opts)		\
+{						\
+	x##_disabled = 1;			\
+	return 0;				\
+}						\
+__setup("no" __stringify(x), x##_setup);
+
+onchip_setup(fpu);
+onchip_setup(dsp);
+
+/*
+ * Generic first-level cache init
+ */
+static void __init cache_init(void)
+{
+	unsigned long ccr, flags = 0;
+
+	if (cpu_data->type == CPU_SH_NONE)
+		panic("Unknown CPU");
+
+	jump_to_P2();
+	ccr = ctrl_inl(CCR);
+
+	/*
+	 * If the cache is already enabled .. flush it.
+	 */
+	if (ccr & CCR_CACHE_ENABLE) {
+		unsigned long entries, i, j;
+
+		entries = cpu_data->dcache.sets;
+
+		/*
+		 * If the OC is already in RAM mode, we only have
+		 * half of the entries to flush..
+		 */
+		if (ccr & CCR_CACHE_ORA)
+			entries >>= 1;
+
+		for (i = 0; i < entries; i++) {
+			for (j = 0; j < cpu_data->dcache.ways; j++) {
+				unsigned long data, addr;
+
+				addr = CACHE_OC_ADDRESS_ARRAY |
+					(j << cpu_data->dcache.way_shift) |
+					(i << cpu_data->dcache.entry_shift);
+
+				data = ctrl_inl(addr);
+
+				if ((data & (SH_CACHE_UPDATED | SH_CACHE_VALID))
+					== (SH_CACHE_UPDATED | SH_CACHE_VALID))
+					ctrl_outl(data & ~SH_CACHE_UPDATED, addr);
+			}
+		}
+	}
+
+	/* 
+	 * Default CCR values .. enable the caches
+	 * and flush them immediately..
+	 */
+	flags |= CCR_CACHE_ENABLE | CCR_CACHE_INVALIDATE;
+	
+#ifdef CCR_CACHE_EMODE
+	flags |= (ccr & CCR_CACHE_EMODE);
+#endif
+
+#ifdef CONFIG_SH_WRITETHROUGH
+	/* Turn on Write-through caching */
+	flags |= CCR_CACHE_WT;
+#else
+	/* .. or default to Write-back */
+	flags |= CCR_CACHE_CB;
+#endif
+
+#ifdef CONFIG_SH_OCRAM
+	/* Turn on OCRAM -- halve the OC */
+	flags |= CCR_CACHE_ORA;
+	cpu_data->dcache.sets >>= 1;
+#endif
+
+	ctrl_outl(flags, CCR);
+	back_to_P1();
+}
+
+#ifdef CONFIG_SH_DSP
+static void __init release_dsp(void)
+{
+	unsigned long sr;
+
+	/* Clear SR.DSP bit */
+	__asm__ __volatile__ (
+		"stc\tsr, %0\n\t"
+		"and\t%1, %0\n\t"
+		"ldc\t%0, sr\n\t"
+		: "=&r" (sr)
+		: "r" (~SR_DSP)
+	);
+}
+
+static void __init dsp_init(void)
+{
+	unsigned long sr;
+
+	/*
+	 * Set the SR.DSP bit, wait for one instruction, and then read
+	 * back the SR value.
+	 */
+	__asm__ __volatile__ (
+		"stc\tsr, %0\n\t"
+		"or\t%1, %0\n\t"
+		"ldc\t%0, sr\n\t"
+		"nop\n\t"
+		"stc\tsr, %0\n\t"
+		: "=&r" (sr)
+		: "r" (SR_DSP)
+	);
+
+	/* If the DSP bit is still set, this CPU has a DSP */
+	if (sr & SR_DSP)
+		set_bit(CPU_HAS_DSP, &(cpu_data->flags));
+	
+	/* Now that we've determined the DSP status, clear the DSP bit. */
+	release_dsp();
+}
+#endif /* CONFIG_SH_DSP */
+
+/*
+ * sh_cpu_init
+ *
+ * This is our initial entry point for each CPU, and is invoked on the boot
+ * CPU prior to calling start_kernel(). For SMP, a combination of this and
+ * start_secondary() will bring up each processor to a ready state prior
+ * to hand forking the idle loop.
+ *
+ * We do all of the basic processor init here, including setting up the
+ * caches, FPU, DSP, kicking the UBC, etc. By the time start_kernel() is
+ * hit (and subsequently platform_setup()) things like determining the
+ * CPU subtype and initial configuration will all be done.
+ *
+ * Each processor family is still responsible for doing its own probing
+ * and cache configuration in detect_cpu_and_cache_system().
+ */
+asmlinkage void __init sh_cpu_init(void)
+{
+	/* First, probe the CPU */
+	detect_cpu_and_cache_system();
+
+	/* Init the cache */
+	cache_init();
+
+	/* Disable the FPU */
+	if (fpu_disabled) {
+		printk("FPU Disabled\n");
+		cpu_data->flags &= ~CPU_HAS_FPU;
+		release_fpu();
+	}
+
+	/* FPU initialization */
+	if (test_bit(CPU_HAS_FPU, &(cpu_data->flags))) {
+		clear_thread_flag(TIF_USEDFPU);
+		current->used_math = 0;
+	}
+
+#ifdef CONFIG_SH_DSP
+	/* Probe for DSP */
+	dsp_init();
+	
+	/* Disable the DSP */
+	if (dsp_disabled) {
+		printk("DSP Disabled\n");
+		cpu_data->flags &= ~CPU_HAS_DSP;
+		release_dsp();
+	}
+#endif
+
+#ifdef CONFIG_UBC_WAKEUP
+	/*
+	 * Some brain-damaged loaders decided it would be a good idea to put
+	 * the UBC to sleep. This causes some issues when it comes to things
+	 * like PTRACE_SINGLESTEP or doing hardware watchpoints in GDB.  So ..
+	 * we wake it up and hope that all is well.
+	 */
+	ubc_wakeup();
+#endif
+}
+
diff -puN arch/sh/kernel/cpu/Makefile~linus arch/sh/kernel/cpu/Makefile
--- 25/arch/sh/kernel/cpu/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/kernel/cpu/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -2,13 +2,12 @@
 # Makefile for the Linux/SuperH CPU-specifc backends.
 #
 
-obj-y	:= irq_ipr.o irq_imask.o
+obj-y	:= irq_ipr.o irq_imask.o init.o
 
 obj-$(CONFIG_CPU_SH2)		+= sh2/
 obj-$(CONFIG_CPU_SH3)		+= sh3/
 obj-$(CONFIG_CPU_SH4)		+= sh4/
 
-obj-$(CONFIG_SH_DMA)            += dma.o
 obj-$(CONFIG_SH_RTC)            += rtc.o
 obj-$(CONFIG_UBC_WAKEUP)	+= ubc.o
 
diff -puN /dev/null arch/sh/kernel/cpu/sh3/ex.S
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/kernel/cpu/sh3/ex.S	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,124 @@
+/*
+ *  arch/sh/kernel/cpu/sh3/ex.S
+ *
+ *  The SH-3 exception vector table.
+
+ *  Copyright (C) 1999, 2000, 2002  Niibe Yutaka
+ *  Copyright (C) 2003  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ */
+#include <linux/linkage.h>
+#include <linux/config.h>
+
+	.align 2
+	.data
+
+ENTRY(exception_handling_table)
+	.long	exception_error		/* 000 */
+	.long	exception_error
+#if defined(CONFIG_MMU)
+	.long	tlb_miss_load		/* 040 */
+	.long	tlb_miss_store
+	.long	initial_page_write
+	.long	tlb_protection_violation_load
+	.long	tlb_protection_violation_store
+	.long	address_error_load
+	.long	address_error_store	/* 100 */
+#else
+	.long	exception_error	! tlb miss load		/* 040 */
+	.long	exception_error	! tlb miss store
+	.long	exception_error	! initial page write
+	.long	exception_error	! tlb prot violation load
+	.long	exception_error	! tlb prot violation store
+	.long	exception_error	! address error load
+	.long	exception_error	! address error store	/* 100 */
+#endif
+	.long	exception_error	! fpu_exception	/* 120 */
+	.long	exception_error			/* 140 */
+	.long	system_call	! Unconditional Trap	 /* 160 */
+	.long	exception_error	! reserved_instruction (filled by trap_init) /* 180 */
+	.long	exception_error	! illegal_slot_instruction (filled by trap_init) /*1A0*/
+ENTRY(nmi_slot)
+#if defined (CONFIG_KGDB_NMI)
+	.long	debug_enter	/* 1C0 */	! Allow trap to debugger
+#else
+	.long	exception_none	/* 1C0 */	! Not implemented yet
+#endif
+ENTRY(user_break_point_trap)
+	.long	break_point_trap	/* 1E0 */
+ENTRY(interrupt_table)
+	! external hardware
+	.long	do_IRQ	! 0000		/* 200 */
+	.long	do_IRQ	! 0001
+	.long	do_IRQ	! 0010
+	.long	do_IRQ	! 0011
+	.long	do_IRQ	! 0100
+	.long	do_IRQ	! 0101
+	.long	do_IRQ	! 0110
+	.long	do_IRQ	! 0111
+	.long	do_IRQ	! 1000		/* 300 */
+	.long	do_IRQ	! 1001
+	.long	do_IRQ	! 1010
+	.long	do_IRQ	! 1011
+	.long	do_IRQ	! 1100
+	.long	do_IRQ	! 1101
+	.long	do_IRQ	! 1110
+	.long	exception_error		
+	! Internal hardware
+	.long	do_IRQ	! TMU0 tuni0	/* 400 */
+	.long	do_IRQ	! TMU1 tuni1
+	.long	do_IRQ	! TMU2 tuni2
+	.long	do_IRQ	!      ticpi2
+	.long	do_IRQ	! RTC  ati
+	.long	do_IRQ	!      pri
+	.long	do_IRQ	!      cui
+	.long	do_IRQ	! SCI  eri
+	.long	do_IRQ	!      rxi	/* 500 */
+	.long	do_IRQ	!      txi
+	.long	do_IRQ	!      tei
+	.long	do_IRQ	! WDT  iti	/* 560 */
+	.long	do_IRQ	! REF  rcmi
+	.long	do_IRQ	!      rovi
+	.long	do_IRQ			
+	.long	do_IRQ			/* 5E0 */
+#if  defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)
+	.long	do_IRQ	! 32 IRQ  irq0	/* 600 */
+	.long	do_IRQ	! 33      irq1
+	.long	do_IRQ	! 34      irq2
+	.long	do_IRQ	! 35      irq3
+	.long	do_IRQ	! 36      irq4
+	.long	do_IRQ	! 37      irq5
+	.long	do_IRQ	! 38
+	.long	do_IRQ	! 39
+	.long	do_IRQ	! 40 PINT pint0-7	/* 700 */
+	.long	do_IRQ	! 41      pint8-15
+	.long	do_IRQ	! 42
+	.long	do_IRQ	! 43
+	.long	do_IRQ	! 44
+	.long	do_IRQ	! 45	
+	.long	do_IRQ	! 46
+	.long	do_IRQ	! 47
+	.long	do_IRQ	! 48 DMAC dei0	/* 800 */
+	.long	do_IRQ	! 49      dei1
+	.long	do_IRQ	! 50      dei2
+	.long	do_IRQ	! 51      dei3
+	.long	do_IRQ	! 52 IrDA eri1
+	.long	do_IRQ	! 53      rxi1
+	.long	do_IRQ	! 54      bri1
+	.long	do_IRQ	! 55      txi1
+	.long	do_IRQ	! 56 SCIF eri2
+	.long	do_IRQ	! 57      rxi2
+	.long	do_IRQ	! 58      bri2
+	.long	do_IRQ	! 59      txi2
+	.long	do_IRQ	! 60 ADC  adi	/* 980 */
+#if defined(CONFIG_CPU_SUBTYPE_SH7707)
+	.long   do_IRQ	! 61 LCDC lcdi	/* 9A0 */
+	.long   do_IRQ	! 62 PCC  pcc0i
+	.long   do_IRQ	! 63      pcc1i	/* 9E0 */
+#endif
+#endif
+
diff -puN arch/sh/kernel/cpu/sh3/Makefile~linus arch/sh/kernel/cpu/sh3/Makefile
--- 25/arch/sh/kernel/cpu/sh3/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/kernel/cpu/sh3/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -2,3 +2,5 @@
 # Makefile for the Linux/SuperH SH-3 backends.
 #
 
+obj-y	:= ex.o
+
diff -puN /dev/null arch/sh/kernel/cpu/sh4/ex.S
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/kernel/cpu/sh4/ex.S	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,316 @@
+/*
+ *  arch/sh/kernel/cpu/sh4/ex.S
+ *
+ *  The SH-4 exception vector table.
+
+ *  Copyright (C) 1999, 2000, 2002  Niibe Yutaka
+ *  Copyright (C) 2003  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ */
+#include <linux/linkage.h>
+#include <linux/config.h>
+
+	.align 2
+	.data
+
+ENTRY(exception_handling_table)
+	.long	exception_error		/* 000 */
+	.long	exception_error
+#if defined(CONFIG_MMU)
+	.long	tlb_miss_load		/* 040 */
+	.long	tlb_miss_store
+	.long	initial_page_write
+	.long	tlb_protection_violation_load
+	.long	tlb_protection_violation_store
+	.long	address_error_load
+	.long	address_error_store	/* 100 */
+#else
+	.long	exception_error	! tlb miss load		/* 040 */
+	.long	exception_error	! tlb miss store
+	.long	exception_error	! initial page write
+	.long	exception_error	! tlb prot violation load
+	.long	exception_error	! tlb prot violation store
+	.long	exception_error	! address error load
+	.long	exception_error	! address error store	/* 100 */
+#endif
+
+	.long	do_fpu_error		/* 120 */
+	.long	exception_error		/* 140 */
+	.long	system_call	! Unconditional Trap	 /* 160 */
+	.long	exception_error	! reserved_instruction (filled by trap_init) /* 180 */
+	.long	exception_error	! illegal_slot_instruction (filled by trap_init) /*1A0*/
+ENTRY(nmi_slot)
+#if defined (CONFIG_KGDB_NMI)
+	.long	debug_enter	/* 1C0 */	! Allow trap to debugger
+#else
+	.long	exception_none	/* 1C0 */	! Not implemented yet
+#endif
+ENTRY(user_break_point_trap)
+	.long	break_point_trap	/* 1E0 */
+ENTRY(interrupt_table)
+	! external hardware
+	.long	do_IRQ	! 0000		/* 200 */
+	.long	do_IRQ	! 0001
+	.long	do_IRQ	! 0010
+	.long	do_IRQ	! 0011
+	.long	do_IRQ	! 0100
+	.long	do_IRQ	! 0101
+	.long	do_IRQ	! 0110
+	.long	do_IRQ	! 0111
+	.long	do_IRQ	! 1000		/* 300 */
+	.long	do_IRQ	! 1001
+	.long	do_IRQ	! 1010
+	.long	do_IRQ	! 1011
+	.long	do_IRQ	! 1100
+	.long	do_IRQ	! 1101
+	.long	do_IRQ	! 1110
+	.long	exception_error		
+	! Internal hardware
+	.long	do_IRQ	! TMU0 tuni0	/* 400 */
+	.long	do_IRQ	! TMU1 tuni1
+	.long	do_IRQ	! TMU2 tuni2
+	.long	do_IRQ	!      ticpi2
+#if  defined(CONFIG_CPU_SUBTYPE_SH7760)
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error			/* 500 */
+	.long	exception_error
+	.long	exception_error
+#else
+	.long	do_IRQ	! RTC  ati
+	.long	do_IRQ	!      pri
+	.long	do_IRQ	!      cui
+	.long	do_IRQ	! SCI  eri
+	.long	do_IRQ	!      rxi	/* 500 */
+	.long	do_IRQ	!      txi
+	.long	do_IRQ	!      tei
+#endif
+	.long	do_IRQ	! WDT  iti	/* 560 */
+	.long	do_IRQ	! REF  rcmi
+	.long	do_IRQ	!      rovi
+	.long	do_IRQ			
+	.long	do_IRQ			/* 5E0 */
+	.long	do_IRQ	! 32 Hitachi UDI	/* 600 */
+	.long	do_IRQ	! 33 GPIO
+	.long	do_IRQ	! 34 DMAC dmte0
+	.long	do_IRQ	! 35      dmte1
+	.long	do_IRQ	! 36      dmte2
+	.long	do_IRQ	! 37      dmte3
+	.long	do_IRQ	! 38      dmae
+	.long	exception_error			! 39	/* 6E0 */
+#if defined(CONFIG_CPU_SUBTYPE_SH7760)
+	.long	exception_error				/* 700 */
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error				/* 760 */
+#else
+	.long	do_IRQ	! 40 SCIF eri		/* 700 */
+	.long	do_IRQ	! 41      rxi
+	.long	do_IRQ	! 42      bri
+	.long	do_IRQ	! 43      txi
+#endif
+#if CONFIG_NR_ONCHIP_DMA_CHANNELS == 8
+	.long	do_IRQ	! 44 DMAC dmte4		/* 780 */
+	.long	do_IRQ	! 45      dmte5
+	.long	do_IRQ	! 46      dmte6
+	.long	do_IRQ	! 47      dmte7		/* 7E0 */
+#else
+	.long	exception_error			! 44	/* 780 */
+	.long	exception_error			! 45
+	.long	exception_error			! 46
+	.long	exception_error			! 47
+#endif
+	.long	do_fpu_state_restore	! 48	/* 800 */
+	.long	do_fpu_state_restore	! 49	/* 820 */
+#if defined(CONFIG_CPU_SUBTYPE_SH7751)
+	.long	exception_error			/* 840 */
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error			/* 900 */
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error
+	.long	do_IRQ	! PCI serr	/* A00 */
+	.long	do_IRQ	!     dma3
+	.long	do_IRQ	!     dma2
+	.long	do_IRQ	!     dma1
+	.long	do_IRQ	!     dma0
+	.long	do_IRQ	!     pwon
+	.long	do_IRQ	!     pwdwn
+	.long	do_IRQ	!     err
+	.long	do_IRQ	! TMU3 tuni3	/* B00 */
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error
+	.long	do_IRQ	! TMU4 tuni4	/* B80 */
+#elif defined(CONFIG_CPU_SUBTYPE_SH7760)
+	.long	do_IRQ	! IRQ	irq6	/* 840 */
+	.long	do_IRQ	!	irq7
+	.long	do_IRQ	! SCIF	eri0
+	.long	do_IRQ	!	rxi0
+	.long	do_IRQ	!	bri0
+	.long	do_IRQ	!	txi0
+	.long	do_IRQ	! HCAN2	cani0	/* 900 */
+	.long	do_IRQ	!	cani1
+	.long	do_IRQ	! SSI	ssii0
+	.long	do_IRQ	!	ssii1
+	.long	do_IRQ	! HAC	haci0
+	.long	do_IRQ	!	haci1
+	.long	do_IRQ	! IIC	iici0
+	.long	do_IRQ	!	iici1
+	.long	do_IRQ	! USB	usbi	/* A00 */
+	.long	do_IRQ	! LCDC	vint
+	.long	exception_error
+	.long	exception_error
+	.long	do_IRQ	! DMABRG dmabrgi0
+	.long	do_IRQ	!        dmabrgi1
+	.long	do_IRQ	!        dmabrgi2
+	.long	exception_error
+	.long	do_IRQ	! SCIF	eri1	/* B00 */
+	.long	do_IRQ	!	rxi1
+	.long	do_IRQ	!	bri1
+	.long	do_IRQ	!	txi1
+	.long	do_IRQ	!	eri2
+	.long	do_IRQ	!	rxi2
+	.long	do_IRQ	!	bri2
+	.long	do_IRQ  !	txi2
+	.long	do_IRQ	! SIM	simeri	/* C00 */
+	.long	do_IRQ	!	simrxi
+	.long	do_IRQ	!	simtxi
+	.long	do_IRQ	!	simtei
+	.long	do_IRQ	! HSPI	spii
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error
+	.long	do_IRQ	! MMCIF	mmci0	/* D00 */
+	.long	do_IRQ	!	mmci1
+	.long	do_IRQ	!	mmci2
+	.long	do_IRQ	!	mmci3
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error			/* E00 */
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error
+	.long	do_IRQ	! MFI	mfii
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error			/* F00 */
+	.long	exception_error
+	.long	exception_error
+	.long	exception_error
+	.long	do_IRQ	! ADC	adi
+	.long	do_IRQ	! CMT	cmti	/* FA0 */
+#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
+	.long	exception_error			!  50 0x840
+	.long	exception_error			!  51 0x860
+	.long	exception_error			!  52 0x880
+	.long	exception_error			!  53 0x8a0
+	.long	exception_error			!  54 0x8c0
+	.long	exception_error			!  55 0x8e0
+	.long	exception_error			!  56 0x900
+	.long	exception_error			!  57 0x920
+	.long	exception_error			!  58 0x940
+	.long	exception_error			!  59 0x960
+	.long	exception_error			!  60 0x980
+	.long	exception_error			!  61 0x9a0
+	.long	exception_error			!  62 0x9c0
+	.long	exception_error			!  63 0x9e0
+	.long	do_IRQ	!  64 0xa00 PCI serr
+	.long	do_IRQ	!  65 0xa20     err
+	.long	do_IRQ	!  66 0xa40     ad
+	.long	do_IRQ	!  67 0xa60     pwr_dwn
+	.long	exception_error			!  68 0xa80
+	.long	exception_error			!  69 0xaa0
+	.long	exception_error			!  70 0xac0
+	.long	exception_error			!  71 0xae0
+	.long	do_IRQ	!  72 0xb00 DMA INT0
+	.long	do_IRQ	!  73 0xb20     INT1
+	.long	do_IRQ	!  74 0xb40     INT2
+	.long	do_IRQ	!  75 0xb60     INT3
+	.long	do_IRQ	!  76 0xb80     INT4
+	.long	exception_error			!  77 0xba0
+	.long	do_IRQ	!  78 0xbc0 DMA ERR
+	.long	exception_error			!  79 0xbe0
+	.long	do_IRQ	!  80 0xc00 PIO0
+	.long	do_IRQ	!  81 0xc20 PIO1
+	.long	do_IRQ	!  82 0xc40 PIO2
+	.long	exception_error			!  83 0xc60
+	.long	exception_error			!  84 0xc80
+	.long	exception_error			!  85 0xca0
+	.long	exception_error			!  86 0xcc0
+	.long	exception_error			!  87 0xce0
+	.long	exception_error			!  88 0xd00
+	.long	exception_error			!  89 0xd20
+	.long	exception_error			!  90 0xd40
+	.long	exception_error			!  91 0xd60
+	.long	exception_error			!  92 0xd80
+	.long	exception_error			!  93 0xda0
+	.long	exception_error			!  94 0xdc0
+	.long	exception_error			!  95 0xde0
+	.long	exception_error			!  96 0xe00
+	.long	exception_error			!  97 0xe20
+	.long	exception_error			!  98 0xe40
+	.long	exception_error			!  99 0xe60
+	.long	exception_error			! 100 0xe80
+	.long	exception_error			! 101 0xea0
+	.long	exception_error			! 102 0xec0
+	.long	exception_error			! 103 0xee0
+	.long	exception_error			! 104 0xf00
+	.long	exception_error			! 105 0xf20
+	.long	exception_error			! 106 0xf40
+	.long	exception_error			! 107 0xf60
+	.long	exception_error			! 108 0xf80
+	.long	exception_error			! 109 0xfa0
+	.long	exception_error			! 110 0xfc0
+	.long	exception_error			! 111 0xfe0
+	.long	do_IRQ	! 112 0x1000 Mailbox
+	.long	exception_error			! 113 0x1020
+	.long	exception_error			! 114 0x1040
+	.long	exception_error			! 115 0x1060
+	.long	exception_error			! 116 0x1080
+	.long	exception_error			! 117 0x10a0
+	.long	exception_error			! 118 0x10c0
+	.long	exception_error			! 119 0x10e0
+	.long	exception_error			! 120 0x1100
+	.long	exception_error			! 121 0x1120
+	.long	exception_error			! 122 0x1140
+	.long	exception_error			! 123 0x1160
+	.long	exception_error			! 124 0x1180
+	.long	exception_error			! 125 0x11a0
+	.long	exception_error			! 126 0x11c0
+	.long	exception_error			! 127 0x11e0
+	.long	exception_error			! 128 0x1200
+	.long	exception_error			! 129 0x1220
+	.long	exception_error			! 130 0x1240
+	.long	exception_error			! 131 0x1260
+	.long	exception_error			! 132 0x1280
+	.long	exception_error			! 133 0x12a0
+	.long	exception_error			! 134 0x12c0
+	.long	exception_error			! 135 0x12e0
+	.long	exception_error			! 136 0x1300
+	.long	exception_error			! 137 0x1320
+	.long	exception_error			! 138 0x1340
+	.long	exception_error			! 139 0x1360
+	.long	do_IRQ	! 140 0x1380 EMPI INV_ADDR
+	.long	exception_error			! 141 0x13a0
+	.long	exception_error			! 142 0x13c0
+	.long	exception_error			! 143 0x13e0
+#endif
+
diff -puN arch/sh/kernel/cpu/sh4/fpu.c~linus arch/sh/kernel/cpu/sh4/fpu.c
--- 25/arch/sh/kernel/cpu/sh4/fpu.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/kernel/cpu/sh4/fpu.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: fpu.c,v 1.2 2003/05/04 19:29:54 lethal Exp $
+/* $Id: fpu.c,v 1.3 2003/09/23 23:15:44 lethal Exp $
  *
  * linux/arch/sh/kernel/fpu.c
  *
@@ -18,6 +18,14 @@
 #include <asm/processor.h>
 #include <asm/io.h>
 
+/* The PR (precision) bit in the FP Status Register must be clear when
+ * an frchg instruction is executed, otherwise the instruction is undefined.
+ * Executing frchg with PR set causes a trap on some SH4 implementations.
+ */
+
+#define FPSCR_RCHG 0x00000000
+
+
 /*
  * Save FPU registers onto task structure.
  * Assume called with FPU enabled (SR.FD=0).
@@ -61,9 +69,11 @@ save_fpu(struct task_struct *tsk)
 		     "fmov.s	fr3, @-%0\n\t"
 		     "fmov.s	fr2, @-%0\n\t"
 		     "fmov.s	fr1, @-%0\n\t"
-		     "fmov.s	fr0, @-%0"
+		     "fmov.s	fr0, @-%0\n\t"
+		     "lds	%2, fpscr\n\t"
 		     : /* no output */
 		     : "r" ((char *)(&tsk->thread.fpu.hard.status)),
+		       "r" (FPSCR_RCHG),
 		       "r" (FPSCR_INIT)
 		     : "memory");
 
@@ -112,7 +122,7 @@ restore_fpu(struct task_struct *tsk)
 		     "lds.l	@%0+, fpscr\n\t"
 		     "lds.l	@%0+, fpul\n\t"
 		     : /* no output */
-		     : "r" (&tsk->thread.fpu), "r" (FPSCR_INIT)
+		     : "r" (&tsk->thread.fpu), "r" (FPSCR_RCHG)
 		     : "memory");
 }
 
@@ -160,9 +170,10 @@ fpu_init(void)
 		     "fsts	fpul, fr13\n\t"
 		     "fsts	fpul, fr14\n\t"
 		     "fsts	fpul, fr15\n\t"
-		     "frchg"
+		     "frchg\n\t"
+		     "lds	%2, fpscr\n\t"
 		     : /* no output */
-		     : "r" (0), "r" (FPSCR_INIT));
+		     : "r" (0), "r" (FPSCR_RCHG), "r" (FPSCR_INIT));
 }
 
 /**
diff -puN arch/sh/kernel/cpu/sh4/Makefile~linus arch/sh/kernel/cpu/sh4/Makefile
--- 25/arch/sh/kernel/cpu/sh4/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/kernel/cpu/sh4/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -2,13 +2,8 @@
 # Makefile for the Linux/SuperH SH-4 backends.
 #
 
-obj-y	:= fpu.o
+obj-y	:= fpu.o ex.o
 
 obj-$(CONFIG_CPU_SUBTYPE_ST40STB1)	+= irq_intc2.o
-obj-$(CONFIG_CPU_SUBTYPE_SH7751)	+= irq_intc2.o
-
-ifeq ($(CONFIG_PCI),y)
-obj-$(CONFIG_CPU_SUBTYPE_ST40STB1)	+= pci-st40.o
-obj-$(CONFIG_CPU_SUBTYPE_SH7751)	+= pci-sh7751.o 
-endif
+obj-$(CONFIG_SH_STORE_QUEUES)		+= sq.o
 
diff -puN -L arch/sh/kernel/cpu/sh4/pci-sh7751.c arch/sh/kernel/cpu/sh4/pci-sh7751.c~linus /dev/null
--- 25/arch/sh/kernel/cpu/sh4/pci-sh7751.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,503 +0,0 @@
-/*
- *	Low-Level PCI Support for the SH7751
- *
- *  Dustin McIntire (dustin@sensoria.com)
- *	Derived from arch/i386/kernel/pci-*.c which bore the message:
- *	(c) 1999--2000 Martin Mares <mj@ucw.cz>
- *	
- *  May be copied or modified under the terms of the GNU General Public
- *  License.  See linux/COPYING for more information.
- *
-*/
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <linux/sched.h>
-#include <linux/ioport.h>
-#include <linux/errno.h>
-#include <linux/irq.h>
-
-#include <asm/machvec.h>
-#include <asm/io.h>
-#include <asm/pci-sh7751.h>
-
-struct pci_ops *pci_check_direct(void);
-void pcibios_resource_survey(void);
-static u8 pcibios_swizzle(struct pci_dev *dev, u8 *pin);
-static int pcibios_lookup_irq(struct pci_dev *dev, u8 slot, u8 pin);
-
-unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1;
-int pcibios_last_bus = -1;
-struct pci_bus *pci_root_bus;
-struct pci_ops *pci_root_ops;
-
-/*
- * Direct access to PCI hardware...
- */
-
-#ifdef CONFIG_PCI_DIRECT
-
-
-#define CONFIG_CMD(bus, devfn, where) (0x80000000 | (bus->number << 16) | (devfn << 8) | (where & ~3))
-
-#define PCI_REG(reg) (SH7751_PCIREG_BASE+reg)
-
-/*
- * Functions for accessing PCI configuration space with type 1 accesses
- */
-static int pci_conf1_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
-{
-	unsigned long flags;
-	u32 word;
-
-	/* 
-	 * PCIPDR may only be accessed as 32 bit words, 
-	 * so we must do byte alignment by hand 
-	 */
-	local_irq_save(flags);
-	outl(CONFIG_CMD(bus,devfn,where), PCI_REG(SH7751_PCIPAR));
-	word = inl(PCI_REG(SH7751_PCIPDR));
-	local_irq_restore(flags);
-
-	switch (size) {
-	case 1:
-		switch (where & 0x3) {
-		    	case 3: *value = (u8)(word >> 24); break;
-			case 2: *value = (u8)(word >> 16); break;
-			case 1: *value = (u8)(word >> 8);  break;
-		}
-		break;
-	case 2:
-		switch (where & 0x2) {
-			case 2:	*value = (u16)(word >> 16); break;
-			case 1: *value = (u16)(word >> 8);  break;
-		}
-		break;
-	case 4:
-		*value = word;
-		break;
-	}
-
-	PCIDBG(4,"pci_conf1_read@0x%08x=0x%x\n", CONFIG_CMD(bus,devfn,where),*value); 
-
-	return PCIBIOS_SUCCESSFUL;
-}
-
-/* 
- * Since SH7751 only does 32bit access we'll have to do a read,mask,write operation.  
- * We'll allow an odd byte offset, though it should be illegal.
- */ 
-static int pci_conf1_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
-{
-	u32 word,mask;
-	unsigned long flags;
-	u32 shift = (where & 3) * 8;
-
-	if(size == 1) {
-		mask = ((1 << 8) - 1) << shift;  // create the byte mask
-	} else if(size == 2){
-		if(shift == 24)
-			return PCIBIOS_BAD_REGISTER_NUMBER;           
-		mask = ((1 << 16) - 1) << shift;  // create the word mask
-	}
-
-	local_irq_save(flags);
-	outl(CONFIG_CMD(bus,devfn,where), PCI_REG(SH7751_PCIPAR));
-
-	if(size == 4){
-		outl(value, PCI_REG(SH7751_PCIPDR));
-		local_irq_restore(flags);
-
-		PCIDBG(4,"pci_conf1_write@0x%08x=0x%x\n", CONFIG_CMD(bus,devfn,where),value);
-
-		return PCIBIOS_SUCCESSFUL;
-	}
-
-	word = inl(PCI_REG(SH7751_PCIPDR)) ;
-	word &= ~mask;
-	word |= value << shift;
-	outl(word, PCI_REG(SH7751_PCIPDR));
-	local_irq_restore(flags);
-
-	PCIDBG(4,"pci_conf1_write@0x%08x=0x%x\n", CONFIG_CMD(bus,devfn,where),word);
-
-	return PCIBIOS_SUCCESSFUL;
-}
-
-#undef CONFIG_CMD
-
-static struct pci_ops pci_direct_conf1 = {
-	.read =		pci_conf1_read,
-	.write = 	pci_conf1_write,
-};
-
-struct pci_ops * __init pci_check_direct(void)
-{
-	unsigned int tmp, id;
-
-	/* check for SH7751 hardware */
-	id = (SH7751_DEVICE_ID << 16) | SH7751_VENDOR_ID;
-	if(inl(SH7751_PCIREG_BASE+SH7751_PCICONF0) != id) {
-		PCIDBG(2,"PCI: This is not an SH7751\n");
-		return NULL;
-	}
-	/*
-	 * Check if configuration works.
-	 */
-	if (pci_probe & PCI_PROBE_CONF1) {
-		tmp = inl (PCI_REG(SH7751_PCIPAR));
-		outl (0x80000000, PCI_REG(SH7751_PCIPAR));
-		if (inl (PCI_REG(SH7751_PCIPAR)) == 0x80000000) {
-			outl (tmp, PCI_REG(SH7751_PCIPAR));
-			printk(KERN_INFO "PCI: Using configuration type 1\n");
-			request_region(PCI_REG(SH7751_PCIPAR), 8, "PCI conf1");
-			return &pci_direct_conf1;
-		}
-		outl (tmp, PCI_REG(SH7751_PCIPAR));
-	}
-
-	PCIDBG(2,"PCI: pci_check_direct failed\n");
-	return NULL;
-}
-
-#endif
-
-/*
- * BIOS32 and PCI BIOS handling.
- * 
- * The BIOS version of the pci functions is not yet implemented but it is left
- * in for completeness.  Currently an error will be generated at compile time. 
- */
- 
-#ifdef CONFIG_PCI_BIOS
-
-#error PCI BIOS is not yet supported on SH7751
-
-#endif /* CONFIG_PCI_BIOS */
-
-/***************************************************************************************/
-
-/*
- *  Handle bus scanning and fixups ....
- */
-
-
-/*
- * Discover remaining PCI buses in case there are peer host bridges.
- * We use the number of last PCI bus provided by the PCI BIOS.
- */
-static void __init pcibios_fixup_peer_bridges(void)
-{
-	int n;
-	struct pci_bus bus;
-	struct pci_dev dev;
-	u16 l;
-
-	if (pcibios_last_bus <= 0 || pcibios_last_bus >= 0xff)
-		return;
-	PCIDBG(2,"PCI: Peer bridge fixup\n");
-	for (n=0; n <= pcibios_last_bus; n++) {
-		if (pci_find_bus(0, n))
-			continue;
-		bus.number = n;
-		bus.ops = pci_root_ops;
-		dev.bus = &bus;
-		for(dev.devfn=0; dev.devfn<256; dev.devfn += 8)
-			if (!pci_read_config_word(&dev, PCI_VENDOR_ID, &l) &&
-			    l != 0x0000 && l != 0xffff) {
-				PCIDBG(3,"Found device at %02x:%02x [%04x]\n", n, dev.devfn, l);
-				printk(KERN_INFO "PCI: Discovered peer bus %02x\n", n);
-				pci_scan_bus(n, pci_root_ops, NULL);
-				break;
-			}
-	}
-}
-
-
-static void __init pci_fixup_ide_bases(struct pci_dev *d)
-{
-	int i;
-
-	/*
-	 * PCI IDE controllers use non-standard I/O port decoding, respect it.
-	 */
-	if ((d->class >> 8) != PCI_CLASS_STORAGE_IDE)
-		return;
-	PCIDBG(3,"PCI: IDE base address fixup for %s\n", pci_name(d));
-	for(i=0; i<4; i++) {
-		struct resource *r = &d->resource[i];
-		if ((r->start & ~0x80) == 0x374) {
-			r->start |= 2;
-			r->end = r->start;
-		}
-	}
-}
-
-
-/* Add future fixups here... */
-struct pci_fixup pcibios_fixups[] = {
-	{ PCI_FIXUP_HEADER,	PCI_ANY_ID,	PCI_ANY_ID,	pci_fixup_ide_bases },
-	{ 0 }
-};
-
-/*
- *  Called after each bus is probed, but before its children
- *  are examined.
- */
-
-void __init pcibios_fixup_bus(struct pci_bus *b)
-{
-	pci_read_bridge_bases(b);
-}
-
-/*
- * Initialization. Try all known PCI access methods. Note that we support
- * using both PCI BIOS and direct access: in such cases, we use I/O ports
- * to access config space.
- * 
- * Note that the platform specific initialization (BSC registers, and memory
- * space mapping) will be called via the machine vectors (sh_mv.mv_pci_init()) if it
- * exitst and via the platform defined function pcibios_init_platform().  
- * See pci_bigsur.c for implementation;
- * 
- * The BIOS version of the pci functions is not yet implemented but it is left
- * in for completeness.  Currently an error will be genereated at compile time. 
- */
-
-void __init pcibios_init(void)
-{
-	struct pci_ops *bios = NULL;
-	struct pci_ops *dir = NULL;
-
-	PCIDBG(1,"PCI: Starting intialization.\n");
-#ifdef CONFIG_PCI_BIOS
-	if ((pci_probe & PCI_PROBE_BIOS) && ((bios = pci_find_bios()))) {
-		pci_probe |= PCI_BIOS_SORT;
-		pci_bios_present = 1;
-	}
-#endif
-#ifdef CONFIG_PCI_DIRECT
-	if (pci_probe & PCI_PROBE_CONF1 )
-		dir = pci_check_direct();
-#endif
-	if (dir) {
-		pci_root_ops = dir;
-	    if(!pcibios_init_platform())
-			PCIDBG(1,"PCI: Initialization failed\n");
-	    if (sh_mv.mv_init_pci != NULL)
-            sh_mv.mv_init_pci();
-	}
-	else if (bios)
-		pci_root_ops = bios;
-	else {
-		PCIDBG(1,"PCI: No PCI bus detected\n");
-		return;
-	}
-
-	PCIDBG(1,"PCI: Probing PCI hardware\n");
-	pci_root_bus = pci_scan_bus(0, pci_root_ops, NULL);
-	//pci_assign_unassigned_resources();
-	pci_fixup_irqs(pcibios_swizzle, pcibios_lookup_irq);
-	pcibios_fixup_peer_bridges();
-	pcibios_resource_survey();
-
-#ifdef CONFIG_PCI_BIOS
-	if ((pci_probe & PCI_BIOS_SORT) && !(pci_probe & PCI_NO_SORT))
-		pcibios_sort();
-#endif
-}
-
-char * __init pcibios_setup(char *str)
-{
-	if (!strcmp(str, "off")) {
-		pci_probe = 0;
-		return NULL;
-	}
-#ifdef CONFIG_PCI_BIOS
-	else if (!strcmp(str, "bios")) {
-		pci_probe = PCI_PROBE_BIOS;
-		return NULL;
-	} else if (!strcmp(str, "nobios")) {
-		pci_probe &= ~PCI_PROBE_BIOS;
-		return NULL;
-	} else if (!strcmp(str, "nosort")) {
-		pci_probe |= PCI_NO_SORT;
-		return NULL;
-	} else if (!strcmp(str, "biosirq")) {
-		pci_probe |= PCI_BIOS_IRQ_SCAN;
-		return NULL;
-	}
-#endif
-#ifdef CONFIG_PCI_DIRECT
-	else if (!strcmp(str, "conf1")) {
-		pci_probe = PCI_PROBE_CONF1 | PCI_NO_CHECKS;
-		return NULL;
-	}
-#endif
-	else if (!strcmp(str, "rom")) {
-		pci_probe |= PCI_ASSIGN_ROMS;
-		return NULL;
-	} else if (!strncmp(str, "lastbus=", 8)) {
-		pcibios_last_bus = simple_strtol(str+8, NULL, 0);
-		return NULL;
-	}
-	return str;
-}
-
-/*
- *    Allocate the bridge and device resources
- */
-
-static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
-{
-	struct list_head *ln;
-	struct pci_bus *bus;
-	struct pci_dev *dev;
-	int idx;
-	struct resource *r, *pr;
-	
-	PCIDBG(2,"PCI: pcibios_allocate_bus_reasources called\n" );
-	/* Depth-First Search on bus tree */
-	for (ln=bus_list->next; ln != bus_list; ln=ln->next) {
-		bus = pci_bus_b(ln);
-		if ((dev = bus->self)) {
-			for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) {
-				r = &dev->resource[idx];
-				if (!r->start)
-					continue;
-				pr = pci_find_parent_resource(dev, r);
-				if (!pr || request_resource(pr, r) < 0)
-					printk(KERN_ERR "PCI: Cannot allocate resource region %d of bridge %s\n", idx, pci_name(dev));
-			}
-		}
-		pcibios_allocate_bus_resources(&bus->children);
-	}
-}
-
-static void __init pcibios_allocate_resources(int pass)
-{
-	struct pci_dev *dev;
-	int idx, disabled;
-	u16 command;
-	struct resource *r, *pr;
-
-	PCIDBG(2,"PCI: pcibios_allocate_resources pass %d called\n", pass);
-	pci_for_each_dev(dev) {
-		pci_read_config_word(dev, PCI_COMMAND, &command);
-		for(idx = 0; idx < 6; idx++) {
-			r = &dev->resource[idx];
-			if (r->parent)		/* Already allocated */
-				continue;
-			if (!r->start)		/* Address not assigned at all */
-				continue;
-			if (r->flags & IORESOURCE_IO)
-				disabled = !(command & PCI_COMMAND_IO);
-			else
-				disabled = !(command & PCI_COMMAND_MEMORY);
-			if (pass == disabled) {
-				PCIDBG(3,"PCI: Resource %08lx-%08lx (f=%lx, d=%d, p=%d)\n",
-				    r->start, r->end, r->flags, disabled, pass);
-				pr = pci_find_parent_resource(dev, r);
-				if (!pr || request_resource(pr, r) < 0) {
-					printk(KERN_ERR "PCI: Cannot allocate resource region %d of device %s\n", idx, pci_name(dev));
-					/* We'll assign a new address later */
-					r->end -= r->start;
-					r->start = 0;
-				}
-			}
-		}
-		if (!pass) {
-			r = &dev->resource[PCI_ROM_RESOURCE];
-			if (r->flags & PCI_ROM_ADDRESS_ENABLE) {
-				/* Turn the ROM off, leave the resource region, but keep it unregistered. */
-				u32 reg;
-				PCIDBG(3,"PCI: Switching off ROM of %s\n", pci_name(dev));
-				r->flags &= ~PCI_ROM_ADDRESS_ENABLE;
-				pci_read_config_dword(dev, dev->rom_base_reg, &reg);
-				pci_write_config_dword(dev, dev->rom_base_reg, reg & ~PCI_ROM_ADDRESS_ENABLE);
-			}
-		}
-	}
-}
-
-static void __init pcibios_assign_resources(void)
-{
-	struct pci_dev *dev;
-	int idx;
-	struct resource *r;
-
-	PCIDBG(2,"PCI: pcibios_assign_resources called\n");
-	pci_for_each_dev(dev) {
-		int class = dev->class >> 8;
-
-		/* Don't touch classless devices and host bridges */
-		if (!class || class == PCI_CLASS_BRIDGE_HOST)
-			continue;
-
-		for(idx=0; idx<6; idx++) {
-			r = &dev->resource[idx];
-
-			/*
-			 *  Don't touch IDE controllers and I/O ports of video cards!
-			 */
-			if ((class == PCI_CLASS_STORAGE_IDE && idx < 4) ||
-			    (class == PCI_CLASS_DISPLAY_VGA && (r->flags & IORESOURCE_IO)))
-				continue;
-
-			/*
-			 *  We shall assign a new address to this resource, either because
-			 *  the BIOS forgot to do so or because we have decided the old
-			 *  address was unusable for some reason.
-			 */
-			if (!r->start && r->end)
-				pci_assign_resource(dev, idx);
-		}
-
-		if (pci_probe & PCI_ASSIGN_ROMS) {
-			r = &dev->resource[PCI_ROM_RESOURCE];
-			r->end -= r->start;
-			r->start = 0;
-			if (r->end)
-				pci_assign_resource(dev, PCI_ROM_RESOURCE);
-		}
-	}
-}
-
-void __init pcibios_resource_survey(void)
-{
-	PCIDBG(1,"PCI: Allocating resources\n");
-	pcibios_allocate_bus_resources(&pci_root_buses);
-	pcibios_allocate_resources(0);
-	pcibios_allocate_resources(1);
-	pcibios_assign_resources();
-}
-
-
-/***************************************************************************************/
-/* 
- * 	IRQ functions 
- */
-static u8 __init pcibios_swizzle(struct pci_dev *dev, u8 *pin)
-{
-	/* no swizzling */
-	return PCI_SLOT(dev->devfn);
-}
-
-static int pcibios_lookup_irq(struct pci_dev *dev, u8 slot, u8 pin)
-{
-	int irq = -1;
-
-	/* now lookup the actual IRQ on a platform specific basis (pci-'platform'.c) */
-	irq = pcibios_map_platform_irq(slot,pin);
-	if( irq < 0 ) {
-	    PCIDBG(3,"PCI: Error mapping IRQ on device %s\n", dev->name);
-		return irq;
-	}
-	
-	PCIDBG(2,"Setting IRQ for slot %s to %d\n", pci_name(dev), irq);
-
-	return irq;
-}
diff -puN -L arch/sh/kernel/cpu/sh4/pci-st40.c arch/sh/kernel/cpu/sh4/pci-st40.c~linus /dev/null
--- 25/arch/sh/kernel/cpu/sh4/pci-st40.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,423 +0,0 @@
-/* 
- * Copyright (C) 2001 David J. Mckay (david.mckay@st.com)
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.                            
- *
- * Support functions for the ST40 PCI hardware.
- */
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/smp.h>
-#include <linux/smp_lock.h>
-#include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/pci.h>
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <asm/pci.h>
-#include <linux/irq.h>
-
-#include "pci-st40.h"
-
-/* This is in P2 of course */
-#define ST40PCI_BASE_ADDRESS     (0xb0000000)
-#define ST40PCI_MEM_ADDRESS      (ST40PCI_BASE_ADDRESS+0x0)
-#define ST40PCI_IO_ADDRESS       (ST40PCI_BASE_ADDRESS+0x06000000)
-#define ST40PCI_REG_ADDRESS      (ST40PCI_BASE_ADDRESS+0x07000000)
-
-#define ST40PCI_REG(x) (ST40PCI_REG_ADDRESS+(ST40PCI_##x))
-
-#define ST40PCI_WRITE(reg,val) writel((val),ST40PCI_REG(reg))
-#define ST40PCI_WRITE_SHORT(reg,val) writew((val),ST40PCI_REG(reg))
-#define ST40PCI_WRITE_BYTE(reg,val) writeb((val),ST40PCI_REG(reg))
-
-#define ST40PCI_READ(reg) readl(ST40PCI_REG(reg))
-#define ST40PCI_READ_SHORT(reg) readw(ST40PCI_REG(reg))
-#define ST40PCI_READ_BYTE(reg) readb(ST40PCI_REG(reg))
-
-#define ST40PCI_SERR_IRQ        64
-#define ST40PCI_SERR_INT_GROUP  0
-#define ST40PCI_SERR_INT_POS    0
-#define ST40PCI_SERR_INT_PRI    15
-
-#define ST40PCI_ERR_IRQ        65
-#define ST40PCI_ERR_INT_GROUP   1
-#define ST40PCI_ERR_INT_POS     1
-#define ST40PCI_ERR_INT_PRI     14
-
-
-/* Macros to extract PLL params */
-#define PLL_MDIV(reg)  ( ((unsigned)reg) & 0xff )
-#define PLL_NDIV(reg) ( (((unsigned)reg)>>8) & 0xff )
-#define PLL_PDIV(reg) ( (((unsigned)reg)>>16) & 0x3 )
-#define PLL_SETUP(reg) ( (((unsigned)reg)>>19) & 0x1ff )
-
-/* Build up the appropriate settings */
-#define PLL_SET(mdiv,ndiv,pdiv,setup) \
-( ((mdiv)&0xff) | (((ndiv)&0xff)<<8) | (((pdiv)&3)<<16)| (((setup)&0x1ff)<<19))
-
-#define PLLPCICR (0xbb040000+0x10)
-
-#define PLLPCICR_POWERON (1<<28)
-#define PLLPCICR_OUT_EN (1<<29)
-#define PLLPCICR_LOCKSELECT (1<<30)
-#define PLLPCICR_LOCK (1<<31)
-
-
-#define PLL_25MHZ 0x793c8512
-#define PLL_33MHZ PLL_SET(18,88,3,295)
-
-
-static __init void SetPCIPLL(void)
-{
-	/* Stop the PLL */
-	writel(0, PLLPCICR);
-
-	/* Always run at 33Mhz. The PCI clock is totally async 
-	 * to the rest of the system
-	 */
-	writel(PLL_33MHZ | PLLPCICR_POWERON, PLLPCICR);
-
-	printk("ST40PCI: Waiting for PCI PLL to lock\n");
-	while ((readl(PLLPCICR) & PLLPCICR_LOCK) == 0);
-	writel(readl(PLLPCICR) | PLLPCICR_OUT_EN, PLLPCICR);
-}
-
-
-static irqreturn_t st40_pci_irq(int irq, void *dev_instance, struct pt_regs *regs)
-{
-
-	unsigned pci_int, pci_air, pci_cir, pci_aint;
-
-	pci_int = ST40PCI_READ(INT);
-	pci_cir = ST40PCI_READ(CIR);
-	pci_air = ST40PCI_READ(AIR);
-
-	if (pci_int) {
-		printk("PCI INTERRUPT!\n");
-		printk("PCI INT -> 0x%x\n", pci_int & 0xffff);
-		printk("PCI AIR -> 0x%x\n", pci_air);
-		printk("PCI CIR -> 0x%x\n", pci_cir);
-		ST40PCI_WRITE(INT, ~0);
-	}
-
-	pci_aint = ST40PCI_READ(AINT);
-	if (pci_aint) {
-		printk("PCI ARB INTERRUPT!\n");
-		printk("PCI AINT -> 0x%x\n", pci_aint);
-		printk("PCI AIR -> 0x%x\n", pci_air);
-		printk("PCI CIR -> 0x%x\n", pci_cir);
-		ST40PCI_WRITE(AINT, ~0);
-	}
-
-	return IRQ_HANDLED;
-}
-
-
-/* Rounds a number UP to the nearest power of two. Used for
- * sizing the PCI window.
- */
-static u32 __init r2p2(u32 num)
-{
-	int i = 31;
-	u32 tmp = num;
-
-	if (num == 0)
-		return 0;
-
-	do {
-		if (tmp & (1 << 31))
-			break;
-		i--;
-		tmp <<= 1;
-	} while (i >= 0);
-
-	tmp = 1 << i;
-	/* If the original number isn't a power of 2, round it up */
-	if (tmp != num)
-		tmp <<= 1;
-
-	return tmp;
-}
-
-static void __init pci_fixup_ide_bases(struct pci_dev *d)
-{
-	int i;
-
-	/*
-	 * PCI IDE controllers use non-standard I/O port decoding, respect it.
-	 */
-	if ((d->class >> 8) != PCI_CLASS_STORAGE_IDE)
-		return;
-	printk("PCI: IDE base address fixup for %s\n", pci_name(d));
-	for(i=0; i<4; i++) {
-		struct resource *r = &d->resource[i];
-		if ((r->start & ~0x80) == 0x374) {
-			r->start |= 2;
-			r->end = r->start;
-		}
-	}
-}
-
-
-/* Add future fixups here... */
-struct pci_fixup pcibios_fixups[] = {
-	{ PCI_FIXUP_HEADER,	PCI_ANY_ID,	PCI_ANY_ID,	pci_fixup_ide_bases },
-	{ 0 }
-};
-
-int __init st40pci_init(unsigned memStart, unsigned memSize)
-{
-	u32 lsr0;
-
-	SetPCIPLL();
-
-	/* Initialises the ST40 pci subsystem, performing a reset, then programming
-	 * up the address space decoders appropriately
-	 */
-
-	/* Should reset core here as well methink */
-
-	ST40PCI_WRITE(CR, CR_LOCK_MASK | CR_SOFT_RESET);
-
-	/* Loop while core resets */
-	while (ST40PCI_READ(CR) & CR_SOFT_RESET);
-
-	/* Now, lets reset all the cards on the bus with extreme prejudice */
-	ST40PCI_WRITE(CR, CR_LOCK_MASK | CR_RSTCTL);
-	udelay(250);
-
-	/* Set bus active, take it out of reset */
-	ST40PCI_WRITE(CR, CR_LOCK_MASK | CR_CFINT | CR_PFCS | CR_PFE);
-
-	/* The PCI spec says that no access must be made to the bus until 1 second
-	 * after reset. This seem ludicrously long, but some delay is needed here
-	 */
-	mdelay(1000);
-
-	/* Switch off interrupts */
-	ST40PCI_WRITE(INTM, 0);
-	ST40PCI_WRITE(AINT, 0);
-
-	/* Allow it to be a master */
-
-	ST40PCI_WRITE_SHORT(CSR_CMD,
-			    PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
-			    PCI_COMMAND_IO);
-
-	/* Accesse to the 0xb0000000 -> 0xb6000000 area will go through to 0x10000000 -> 0x16000000
-	 * on the PCI bus. This allows a nice 1-1 bus to phys mapping.
-	 */
-
-
-	ST40PCI_WRITE(MBR, 0x10000000);
-	/* Always set the max size 128M (actually, it is only 96MB wide) */
-	ST40PCI_WRITE(MBMR, 0x07ff0000);
-
-	/* I/O addresses are mapped at 0xb6000000 -> 0xb7000000. These are changed to 0, to 
-	 * allow cards that have legacy io such as vga to function correctly. This gives a 
-	 * maximum of 64K of io/space as only the bottom 16 bits of the address are copied 
-	 * over to the bus  when the transaction is made. 64K of io space is more than enough
-	 */
-	ST40PCI_WRITE(IOBR, 0x0);
-	/* Set up the 64K window */
-	ST40PCI_WRITE(IOBMR, 0x0);
-
-	/* Now we set up the mbars so the PCI bus can see the memory of the machine */
-
-	if (memSize < (64 * 1024)) {
-		printk("Ridiculous memory size of 0x%x?\n",memSize);
-		return 0;
-	}
-
-	lsr0 =
-	    (memSize >
-	     (512 * 1024 * 1024)) ? 0x1fff0001 : ((r2p2(memSize) -
-						   0x10000) | 0x1);
-
-	ST40PCI_WRITE(LSR0, lsr0);
-
-	ST40PCI_WRITE(CSR_MBAR0, memStart);
-	ST40PCI_WRITE(LAR0, memStart);
-
-	/* Maximise timeout values */
-	ST40PCI_WRITE_BYTE(CSR_TRDY, 0xff);
-	ST40PCI_WRITE_BYTE(CSR_RETRY, 0xff);
-	ST40PCI_WRITE_BYTE(CSR_MIT, 0xff);
-
-
-	/* Install the pci interrupt handlers */
-	make_intc2_irq(ST40PCI_SERR_IRQ, INTC2_BASE0,
-		       ST40PCI_SERR_INT_GROUP, ST40PCI_SERR_INT_POS,
-		       ST40PCI_SERR_INT_PRI);
-
-	make_intc2_irq(ST40PCI_ERR_IRQ, INTC2_BASE0, ST40PCI_ERR_INT_GROUP,
-		       ST40PCI_ERR_INT_POS, ST40PCI_ERR_INT_PRI);
-
-
-	return 1;
-}
-
-char * __init pcibios_setup(char *str)
-{
-	return str;
-}
-
-
-#define SET_CONFIG_BITS(bus,devfn,where)\
-  (((bus) << 16) | ((devfn) << 8) | ((where) & ~3) | (bus!=0))
-
-#define CONFIG_CMD(bus, devfn, where) SET_CONFIG_BITS(bus->number,devfn,where)
-
-
-static int CheckForMasterAbort(void)
-{
-	if (ST40PCI_READ(INT) & INT_MADIM) {
-		/* Should we clear config space version as well ??? */
-		ST40PCI_WRITE(INT, INT_MADIM);
-		ST40PCI_WRITE_SHORT(CSR_STATUS, 0);
-		return 1;
-	}
-
-	return 0;
-}
-
-/* Write to config register */
-static int st40pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 * val)
-{
-	ST40PCI_WRITE(PAR, CONFIG_CMD(bus, devfn, where));
-	switch (size) {
-		case 1:
-			*val = (u8)ST40PCI_READ_BYTE(PDR + (where & 3));
-			break;
-		case 2:
-			*val = (u16)ST40PCI_READ_SHORT(PDR + (where & 2));
-			break;
-		case 4:
-			*val = ST40PCI_READ(PDR);
-			break;
-	}
-
-	if (CheckForMasterAbort()){
-		switch (size) {
-			case 1:
-				*val = (u8)0xff;
-				break;
-			case 2:
-				*val = (u16)0xffff;
-				break;
-			case 4:
-				*val = 0xffffffff;
-				break;
-		}
-	}
-
-	return PCIBIOS_SUCCESSFUL;
-}
-
-static int st40pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val)
-{
-	ST40PCI_WRITE(PAR, CONFIG_CMD(bus, devfn, where));
-
-	switch (size) {
-		case 1:
-			ST40PCI_WRITE_BYTE(PDR + (where & 3), (u8)val);
-			break;
-		case 2:
-			ST40PCI_WRITE_SHORT(PDR + (where & 2), (u16)val);
-			break;
-		case 4:
-			ST40PCI_WRITE(PDR, val);
-			break;
-	}
-
-	CheckForMasterAbort();
-
-	return PCIBIOS_SUCCESSFUL;
-}
-
-static struct pci_ops pci_config_ops = {
-	.read = 	st40pci_read,
-	.write = 	st40pci_write,
-};
-
-
-/* Everything hangs off this */
-static struct pci_bus *pci_root_bus;
-
-
-static u8 __init no_swizzle(struct pci_dev *dev, u8 * pin)
-{
-	return PCI_SLOT(dev->devfn);
-}
-
-
-/* This needs to be shunted out of here into the board specific bit */
-#define HARP_PCI_IRQ    1
-#define HARP_BRIDGE_IRQ 2
-#define OVERDRIVE_SLOT0_IRQ 0
-
-static int __init map_harp_irq(struct pci_dev *dev, u8 slot, u8 pin)
-{
-	switch (slot) {
-#ifdef CONFIG_SH_STB1_HARP
-	case 2:		/*This is the PCI slot on the */
-		return HARP_PCI_IRQ;
-	case 1:		/* this is the bridge */
-		return HARP_BRIDGE_IRQ;
-#elif defined(CONFIG_SH_STB1_OVERDRIVE)
-	case 1:
-	case 2:
-	case 3:
-		return slot - 1;
-#else
-#error Unknown board
-#endif
-	default:
-		return -1;
-	}
-}
-
-void __init pcibios_init(void)
-{
-	extern unsigned long memory_start, memory_end;
-
-	if (sh_mv.mv_init_pci != NULL) {
-		sh_mv.mv_init_pci();
-	}
-
-	/* The pci subsytem needs to know where memory is and how much 
-	 * of it there is. I've simply made these globals. A better mechanism
-	 * is probably needed.
-	 */
-	st40pci_init(PHYSADDR(memory_start),
-		     PHYSADDR(memory_end) - PHYSADDR(memory_start));
-
-	if (request_irq(ST40PCI_ERR_IRQ, st40_pci_irq, 
-                        SA_INTERRUPT, "st40pci", NULL)) {
-		printk(KERN_ERR "st40pci: Cannot hook interrupt\n");
-		return;
-	}
-
-	/* Enable the PCI interrupts on the device */
-	ST40PCI_WRITE(INTM, ~0);
-	ST40PCI_WRITE(AINT, ~0);
-
-	/* Map the io address apprioately */
-#ifdef CONFIG_HD64465
-	hd64465_port_map(PCIBIOS_MIN_IO, (64 * 1024) - PCIBIOS_MIN_IO + 1,
-			 ST40_IO_ADDR + PCIBIOS_MIN_IO, 0);
-#endif
-
-	/* ok, do the scan man */
-	pci_root_bus = pci_scan_bus(0, &pci_config_ops, NULL);
-	pci_assign_unassigned_resources();
-	pci_fixup_irqs(no_swizzle, map_harp_irq);
-
-}
-
-void __init pcibios_fixup_bus(struct pci_bus *bus)
-{
-}
diff -puN -L arch/sh/kernel/cpu/sh4/pci-st40.h arch/sh/kernel/cpu/sh4/pci-st40.h~linus /dev/null
--- 25/arch/sh/kernel/cpu/sh4/pci-st40.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,66 +0,0 @@
-/* 
- * Copyright (C) 2001 David J. Mckay (david.mckay@st.com)
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.                            
- *
- * Defintions for the ST40 PCI hardware.
- */
-
-#ifndef __PCI_ST40_H__
-#define __PCI_ST40_H__
-
-#define ST40PCI_VCR_STATUS    0x00
-
-#define ST40PCI_VCR_VERSION   0x08
-
-#define ST40PCI_CR            0x10
-
-#define CR_SOFT_RESET (1<<12)
-#define CR_PFCS       (1<<11)
-#define CR_PFE        (1<<9)
-#define CR_BMAM       (1<<6)
-#define CR_HOST       (1<<5)
-#define CR_CLKEN      (1<<4)
-#define CR_SOCS       (1<<3)
-#define CR_IOCS       (1<<2)
-#define CR_RSTCTL     (1<<1)
-#define CR_CFINT      (1<<0)
-#define CR_LOCK_MASK  0x5a000000
-
-
-#define ST40PCI_LSR0          0X14
-#define ST40PCI_LAR0          0x1c
-
-#define ST40PCI_INT           0x24
-#define INT_MADIM             (1<<2)
-
-
-#define ST40PCI_INTM          0x28
-#define ST40PCI_AIR           0x2c
-#define ST40PCI_CIR           0x30
-#define ST40PCI_AINT          0x40
-#define ST40PCI_AINTM         0x44
-#define ST40PCI_BMIR          0x48
-#define ST40PCI_PAR           0x4c
-#define ST40PCI_MBR           0x50
-#define ST40PCI_IOBR          0x54
-#define ST40PCI_PINT          0x58
-#define ST40PCI_PINTM         0x5c
-#define ST40PCI_MBMR          0x70
-#define ST40PCI_IOBMR         0x74
-#define ST40PCI_PDR           0x78
-
-/* These are configs space registers */
-#define ST40PCI_CSR_VID               0x10000
-#define ST40PCI_CSR_DID               0x10002
-#define ST40PCI_CSR_CMD               0x10004
-#define ST40PCI_CSR_STATUS            0x10006
-#define ST40PCI_CSR_MBAR0             0x10010
-#define ST40PCI_CSR_TRDY              0x10040
-#define ST40PCI_CSR_RETRY             0x10041
-#define ST40PCI_CSR_MIT               0x1000d
-
-#define ST40_IO_ADDR 0xb6000000       
-
-#endif /* __PCI_ST40_H__ */
diff -puN /dev/null arch/sh/kernel/cpu/sh4/sq.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/kernel/cpu/sh4/sq.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,484 @@
+/*
+ * arch/sh/kernel/cpu/sq.c
+ *
+ * General management API for SH-4 integrated Store Queues
+ *
+ * Copyright (C) 2001, 2002, 2003  Paul Mundt
+ * Copyright (C) 2001, 2002  M. R. Brown
+ *
+ * Some of this code has been adopted directly from the old arch/sh/mm/sq.c
+ * hack that was part of the LinuxDC project. For all intensive purposes, this
+ * is a completely new interface that really doesn't have much in common with
+ * the old zone-based approach at all. Infact, I'm only listing it here for
+ * general completeness.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/config.h>
+#include <linux/slab.h>
+#include <linux/list.h>
+#include <linux/proc_fs.h>
+#include <linux/miscdevice.h>
+
+#include <asm/io.h>
+#include <asm/page.h>
+#include <asm/mmu_context.h>
+#include <asm/cpu/sq.h>
+
+static LIST_HEAD(sq_mapping_list);
+
+/**
+ * sq_flush - Flush (prefetch) the store queue cache
+ *
+ * @addr: the store queue address to flush
+ *
+ * Executes a prefetch instruction on the specified store queue cache,
+ * so that the cached data is written to physical memory.
+ */
+inline void sq_flush(void *addr)
+{
+	__asm__ __volatile__ ("pref @%0": "=r" (addr) : : "memory");
+}
+
+/**
+ * sq_flush_range - Flush (prefetch) a specific SQ range
+ *
+ * @start: the store queue address to start flushing from
+ * @len: the length to flush
+ *
+ * Flushes the store queue cache from @start to @start + @len in a
+ * linear fashion.
+ */
+void sq_flush_range(unsigned long start, unsigned int len)
+{
+	volatile unsigned long *sq = (unsigned long *)start;
+
+	/* Flush the queues */
+	for (len >>= 5; len--; sq += 8)
+		sq_flush((void *)sq);
+	
+	/* Wait for completion */
+	sq = (volatile unsigned long *)start;
+}
+
+static struct sq_mapping *__sq_alloc_mapping(unsigned long virt, unsigned long phys, unsigned long size, const char *name)
+{
+	struct sq_mapping *map;
+
+	if (virt + size > SQ_ADDRMAX)
+		return ERR_PTR(-ENOSPC);
+
+	map = kmalloc(sizeof(struct sq_mapping), GFP_KERNEL);
+	if (!map)
+		return ERR_PTR(-ENOMEM);
+
+	INIT_LIST_HEAD(&map->list);
+
+	map->sq_addr	= virt;
+	map->addr	= phys;
+	map->size	= size;
+	map->name	= name;
+
+	list_add(&map->list, &sq_mapping_list);
+
+	return map;
+}
+
+static unsigned long __sq_get_next_addr(void)
+{
+	if (!list_empty(&sq_mapping_list)) {
+		struct list_head *pos, *tmp;
+		
+		/*
+		 * Read one off the list head, as it will have the highest
+		 * mapped allocation. Set the next one up right above it.
+		 *
+		 * This is somewhat sub-optimal, as we don't look at
+		 * gaps between allocations or anything lower then the
+		 * highest-level allocation.
+		 *
+		 * However, in the interest of performance and the general
+		 * lack of desire to do constant list rebalancing, we don't
+		 * worry about it.
+		 */
+		list_for_each_safe(pos, tmp, &sq_mapping_list) {
+			struct sq_mapping *entry;
+
+			entry = list_entry(pos, typeof(*entry), list);
+
+			return entry->sq_addr + entry->size;
+		}
+	}
+
+	return P4SEG_STORE_QUE;
+}
+
+/**
+ * __sq_remap - Perform a translation from the SQ to a phys addr
+ *
+ * @phys: Physical address to map store queues too.
+ * @virt: Associated store queue address.
+ *
+ * Maps the store queue address @virt to the physical address @phys.
+ */
+static struct sq_mapping *__sq_remap(struct sq_mapping *map)
+{
+	/*
+	 * First check the MMU status..
+	 */
+#ifndef CONFIG_MMU
+	/*
+	 * Without an MMU (or with it turned off), this is much more
+	 * straightforward, as we can just load up each queue's QACR with
+	 * the physical address appropriately masked.
+	 */
+	ctrl_outl(((map->addr >> 26) << 2) & 0x1c, SQ_QACR0);
+	ctrl_outl(((map->addr >> 26) << 2) & 0x1c, SQ_QACR1);
+#else
+	unsigned long flags, pteh, ptel;
+	pgprot_t pgprot;
+	pgd_t *pgd;
+	pmd_t *pmd;
+	pte_t *pte;
+
+	/*
+	 * With an MMU on the other hand, things are slightly more involved.
+	 * Namely, we have to have a direct mapping between the SQ addr and
+	 * the associated physical address in the UTLB by way of setting up
+	 * a virt<->phys translation by hand. We do this by simply specifying
+	 * the SQ addr in UTLB.VPN and the associated physical address in
+	 * UTLB.PPN.
+	 *
+	 * Notably, even though this is a special case translation, and some
+	 * of the configuration bits are meaningless, we're still required
+	 * to have a valid ASID context in PTEH.
+	 *
+	 * We could also probably get by without explicitly setting PTEA, but
+	 * we do it here just for good measure.
+	 */
+	local_irq_save(flags);
+
+	pteh = map->sq_addr;
+	ctrl_outl((pteh & MMU_VPN_MASK) | get_asid(), MMU_PTEH);
+
+	ptel = map->addr & PAGE_MASK;
+	ctrl_outl(((ptel >> 28) & 0xe) | (ptel & 0x1), MMU_PTEA);
+
+	pgprot = pgprot_noncached(PAGE_KERNEL);
+
+	ptel &= _PAGE_FLAGS_HARDWARE_MASK;
+	ptel |= pgprot_val(pgprot);
+	ctrl_outl(ptel, MMU_PTEL);
+
+	__asm__ __volatile__ ("ldtlb" : : : "memory");
+
+	/*
+	 * Next, we need to map ourselves in the kernel page table, so that
+	 * future accesses after a TLB flush will be handled when we take a
+	 * page fault.
+	 *
+	 * Theoretically we could just do this directly and not worry about
+	 * setting up the translation by hand ahead of time, but for the
+	 * cases where we want a one-shot SQ mapping followed by a quick
+	 * writeout before we hit the TLB flush, we do it anyways. This way
+	 * we at least save ourselves the initial page fault overhead.
+	 */
+	pgd = pgd_offset_k(map->sq_addr);
+
+	spin_lock(&init_mm.page_table_lock);
+
+	pmd = pmd_alloc(&init_mm, pgd, map->sq_addr);
+	if (!pmd)
+		goto out;
+	
+	pte = pte_alloc_map(&init_mm, pmd, map->sq_addr);
+	if (!pte)
+		goto out;
+	if (!pte_none(*pte)) {
+		pte_unmap(pte);
+		goto out;
+	}
+
+	set_pte(pte, mk_pte(phys_to_page(map->addr), pgprot));
+	pte_unmap(pte);
+
+out:
+	spin_unlock(&init_mm.page_table_lock);
+	sq_flush((void *)pteh);
+
+	local_irq_restore(flags);
+
+#endif /* CONFIG_MMU */
+
+	return map;
+}
+
+/**
+ * sq_remap - Map a physical address through the Store Queues
+ *
+ * @phys: Physical address of mapping.
+ * @size: Length of mapping.
+ * @name: User invoking mapping.
+ *
+ * Remaps the physical address @phys through the next available store queue
+ * address of @size length. @name is logged at boot time as well as through
+ * the procfs interface.
+ *
+ * A pre-allocated and filled sq_mapping pointer is returned, and must be
+ * cleaned up with a call to sq_unmap() when the user is done with the
+ * mapping.
+ */
+struct sq_mapping *sq_remap(unsigned long phys, unsigned int size, const char *name)
+{
+	struct sq_mapping *map;
+	unsigned long virt;
+	unsigned int psz;
+
+	phys &= PAGE_MASK;
+
+	virt  = __sq_get_next_addr();
+	psz   = (size + (PAGE_SIZE - 1)) / PAGE_SIZE;
+	map   = __sq_alloc_mapping(virt, phys, size, name);
+
+	printk("sqremap: %15s  [%4d page%s]  va 0x%08lx   pa 0x%08lx\n",
+	       map->name ? map->name : "???",
+	       psz, psz == 1 ? " " : "s",
+	       map->sq_addr, map->addr);
+
+	return __sq_remap(map);
+}
+
+/**
+ * sq_unmap - Unmap a Store Queue allocation
+ *
+ * @map: Pre-allocated Store Queue mapping.
+ *
+ * Unmaps the store queue allocation @map that was previously created by
+ * sq_remap(). Also frees up the pte that was previously inserted into
+ * the kernel page table and discards the UTLB translation.
+ */
+void sq_unmap(struct sq_mapping *map)
+{
+#ifdef CONFIG_MMU
+	pgd_t *pgd;
+	pmd_t *pmd;
+	pte_t *pte;
+	
+	pgd = pgd_offset_k(map->sq_addr);
+	pmd = pmd_offset(pgd, map->sq_addr);
+
+	if (pmd_none(*pmd))
+		return;
+	if (pmd_bad(*pmd)) {
+		pmd_ERROR(*pmd);
+		pmd_clear(pmd);
+		return;
+	}
+
+	pte = pte_offset_kernel(pmd, map->sq_addr);
+	if (pte_none(*pte) || pte_not_present(*pte))
+		return;
+
+	ptep_get_and_clear(pte);
+
+	__flush_tlb_page(get_asid(), map->sq_addr & PAGE_MASK);
+#endif
+
+	list_del(&map->list);
+	kfree(map);
+}
+
+/**
+ * sq_clear - Clear a store queue range
+ *
+ * @addr: Address to start clearing from.
+ * @len: Length to clear.
+ *
+ * A quick zero-fill implementation for clearing out memory that has been
+ * remapped through the store queues.
+ */
+void sq_clear(unsigned long addr, unsigned int len)
+{
+	int i;
+	
+	/* Clear out both queues linearly */
+	for (i = 0; i < 8; i++) {
+		ctrl_outl(0, addr + i + 0);
+		ctrl_outl(0, addr + i + 8);
+	}
+
+	sq_flush_range(addr, len);
+}
+
+/**
+ * sq_vma_unmap - Unmap a VMA range
+ *
+ * @area: VMA containing range.
+ * @addr: Start of range.
+ * @len: Length of range.
+ *
+ * Searches the sq_mapping_list for a mapping matching the sq addr @addr,
+ * and subsequently frees up the entry. Further cleanup is done by generic
+ * code.
+ */
+static void sq_vma_unmap(struct vm_area_struct *area,
+			 unsigned long addr, size_t len)
+{
+	struct list_head *pos, *tmp;
+
+	list_for_each_safe(pos, tmp, &sq_mapping_list) {
+		struct sq_mapping *entry;
+
+		entry = list_entry(pos, typeof(*entry), list);
+
+		if (entry->sq_addr == addr) {
+			/* 
+			 * We could probably get away without doing the tlb flush
+			 * here, as generic code should take care of most of this
+			 * when unmapping the rest of the VMA range for us. Leave
+			 * it in for added sanity for the time being..
+			 */
+			__flush_tlb_page(get_asid(), entry->sq_addr & PAGE_MASK);
+			
+			list_del(&entry->list);
+			kfree(entry);
+
+			return;
+		}	
+	}
+}
+
+/**
+ * sq_vma_sync - Sync a VMA range
+ *
+ * @area: VMA containing range.
+ * @start: Start of range.
+ * @len: Length of range.
+ * @flags: Additional flags.
+ *
+ * Synchronizes an sq mapped range by flushing the store queue cache for
+ * the duration of the mapping.
+ *
+ * Used internally for user mappings, which must use msync() to prefetch
+ * the store queue cache.
+ */
+static int sq_vma_sync(struct vm_area_struct *area,
+		       unsigned long start, size_t len, unsigned int flags)
+{
+	sq_flush_range(start, len);
+
+	return 0;
+}
+
+static struct vm_operations_struct sq_vma_ops = {
+	.unmap	= sq_vma_unmap,
+	.sync	= sq_vma_sync,
+};
+
+/**
+ * sq_mmap - mmap() for /dev/cpu/sq
+ *
+ * @file: unused.
+ * @vma: VMA to remap.
+ *
+ * Remap the specified vma @vma through the store queues, and setup associated
+ * information for the new mapping. Also build up the page tables for the new
+ * area.
+ */
+static int sq_mmap(struct file *file, struct vm_area_struct *vma)
+{
+	unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
+	unsigned long size = vma->vm_end - vma->vm_start;
+	struct sq_mapping *map;
+
+	/* 
+	 * We're not interested in any arbitrary virtual address that has
+	 * been stuck in the VMA, as we already know what addresses we
+	 * want. Save off the size, and reposition the VMA to begin at
+	 * the next available sq address.
+	 */
+	vma->vm_start = __sq_get_next_addr();
+	vma->vm_end   = vma->vm_start + size;
+
+	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+
+	vma->vm_flags |= VM_IO | VM_RESERVED;
+
+	map = __sq_alloc_mapping(vma->vm_start, offset, size, "Userspace");
+
+	if (io_remap_page_range(vma, map->sq_addr, map->addr,
+				size, vma->vm_page_prot))
+		return -EAGAIN;
+	
+	vma->vm_ops = &sq_vma_ops;
+
+	return 0;
+}
+
+#ifdef CONFIG_PROC_FS
+static int sq_mapping_read_proc(char *buf, char **start, off_t off,
+				int len, int *eof, void *data)
+{
+	struct list_head *pos;
+	char *p = buf;
+
+	list_for_each_prev(pos, &sq_mapping_list) {
+		struct sq_mapping *entry;
+		
+		entry = list_entry(pos, typeof(*entry), list);
+
+		p += sprintf(p, "%08lx-%08lx [%08lx]: %s\n", entry->sq_addr,
+			     entry->sq_addr + entry->size - 1, entry->addr,
+			     entry->name);
+	}
+
+	return p - buf;
+}
+#endif
+
+static struct file_operations sq_fops = {
+	.owner		= THIS_MODULE,
+	.mmap		= sq_mmap,
+};
+
+static struct miscdevice sq_dev = {
+	.minor		= STORE_QUEUE_MINOR,
+	.name		= "sq",
+	.devfs_name	= "cpu/sq",
+	.fops		= &sq_fops,
+};
+
+static int __init sq_api_init(void)
+{
+	printk(KERN_NOTICE "sq: Registering store queue API.\n");
+
+#ifdef CONFIG_PROC_FS
+	create_proc_read_entry("sq_mapping", 0, 0, sq_mapping_read_proc, 0);
+#endif
+
+	return misc_register(&sq_dev);
+}
+
+static void __exit sq_api_exit(void)
+{
+	misc_deregister(&sq_dev);
+}
+
+module_init(sq_api_init);
+module_exit(sq_api_exit);
+
+MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>, M. R. Brown <mrbrown@0xd6.org>");
+MODULE_DESCRIPTION("Simple API for SH-4 integrated Store Queues");
+MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(sq_remap);
+EXPORT_SYMBOL(sq_unmap);
+EXPORT_SYMBOL(sq_clear);
+EXPORT_SYMBOL(sq_flush);
+EXPORT_SYMBOL(sq_flush_range);
+
diff -puN -L arch/sh/kernel/dma.c arch/sh/kernel/dma.c~linus /dev/null
--- 25/arch/sh/kernel/dma.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,142 +0,0 @@
-/*
- * arch/sh/kernel/dma.c
- *
- * Copyright (C) 2000 Takashi YOSHII
- *
- * PC like DMA API for SuperH's DMAC.
- */
-
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/irq.h>
-#include <linux/interrupt.h>
-
-#include <asm/signal.h>
-#include <asm/dma.h>
-
-static struct dma_info_t *dma_info[MAX_DMA_CHANNELS];
-static struct dma_info_t *autoinit_info[SH_MAX_DMA_CHANNELS] = {0};
-static spinlock_t  dma_spin_lock;
-
-static unsigned int calc_chcr(struct dma_info_t *info)
-{
-	unsigned int chcr;
-
-	chcr = ( info->mode & DMA_MODE_WRITE )? info->mode_write : info->mode_read;
-	if( info->mode & DMA_AUTOINIT )
-		chcr |= CHCR_IE;
-	return chcr;
-}
-
-static __inline__ int ts_shift(unsigned long chcr)
-{
-	return ((int[]){3,0,1,2,5,0,0,0})[(chcr>>4)&0x000007];
-}
-
-static void dma_tei(int irq, void *dev_id, struct pt_regs *regs)
-{
-	int chan = irq - DMTE_IRQ[0];
-	struct dma_info_t *info = autoinit_info[chan];
-
-	if( info->mode & DMA_MODE_WRITE )
-		ctrl_outl(info->mem_addr, SAR[info->chan]);
-	else
-		ctrl_outl(info->mem_addr, DAR[info->chan]);
-
-	ctrl_outl(info->count>>ts_shift(calc_chcr(info)), DMATCR[info->chan]);
-	ctrl_outl(ctrl_inl(CHCR[info->chan])&~CHCR_TE, CHCR[info->chan]);
-}
-
-static struct irqaction irq_tei = { dma_tei, SA_INTERRUPT, 0, "dma_tei", NULL, NULL};
-
-void setup_dma(unsigned int dmanr, struct dma_info_t *info)
-{
-	make_ipr_irq(DMTE_IRQ[info->chan], DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
-	setup_irq(DMTE_IRQ[info->chan], &irq_tei);
-	dma_info[dmanr] = info;
-}
-
-unsigned long claim_dma_lock(void)
-{
-	unsigned long flags;
-	spin_lock_irqsave(&dma_spin_lock, flags);
-	return flags;
-}
-
-void release_dma_lock(unsigned long flags)
-{
-	spin_unlock_irqrestore(&dma_spin_lock, flags);
-}
-
-void enable_dma(unsigned int dmanr)
-{
-	struct dma_info_t *info = dma_info[dmanr];
-	ctrl_outl(calc_chcr(info)|CHCR_DE, CHCR[info->chan]);
-}
-
-void disable_dma(unsigned int dmanr)
-{
-	struct dma_info_t *info = dma_info[dmanr];
-	ctrl_outl(calc_chcr(info)&~CHCR_DE, CHCR[info->chan]);
-}
-
-void set_dma_mode(unsigned int dmanr, char mode)
-{
-	struct dma_info_t *info = dma_info[dmanr];
-
-	info->mode = mode;
-	set_dma_addr(dmanr, info->mem_addr);
-	set_dma_count(dmanr, info->count);
-	autoinit_info[info->chan] = info;
-}
-
-void set_dma_addr(unsigned int dmanr, unsigned int a)
-{
-	struct dma_info_t *info = dma_info[dmanr];
-	unsigned long sar, dar;
-
-	info->mem_addr = a;
-	sar = (info->mode & DMA_MODE_WRITE)? info->mem_addr: info->dev_addr;
-	dar = (info->mode & DMA_MODE_WRITE)? info->dev_addr: info->mem_addr;
-	ctrl_outl(sar, SAR[info->chan]);
-	ctrl_outl(dar, DAR[info->chan]);
-}
-
-void set_dma_count(unsigned int dmanr, unsigned int count)
-{
-	struct dma_info_t *info = dma_info[dmanr];
-	info->count = count;
-	ctrl_outl(count>>ts_shift(calc_chcr(info)), DMATCR[info->chan]);
-}
-
-int get_dma_residue(unsigned int dmanr)
-{
-	struct dma_info_t *info = dma_info[dmanr];
-	return ctrl_inl(DMATCR[info->chan])<<ts_shift(calc_chcr(info));
-}
-
-#if defined(__SH4__)
-static void dma_err(int irq, void *dev_id, struct pt_regs *regs)
-{
-	printk(KERN_WARNING "DMAE: DMAOR=%lx\n",ctrl_inl(DMAOR));
-	ctrl_outl(ctrl_inl(DMAOR)&~DMAOR_NMIF, DMAOR);
-	ctrl_outl(ctrl_inl(DMAOR)&~DMAOR_AE, DMAOR);
-	ctrl_outl(ctrl_inl(DMAOR)|DMAOR_DME, DMAOR);
-}
-static struct irqaction irq_err = { dma_err, SA_INTERRUPT, 0, "dma_err", NULL, NULL};
-#endif
-
-int __init init_dma(void)
-{
-#if defined(__SH4__)
-	make_ipr_irq(DMAE_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
-	setup_irq(DMAE_IRQ, &irq_err);
-#endif
-
-	ctrl_outl(DMAOR_DME, DMAOR);
-	return 0;
-}
-
-module_init(init_dma);
-
-/**/
diff -puN arch/sh/kernel/entry.S~linus arch/sh/kernel/entry.S
--- 25/arch/sh/kernel/entry.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/kernel/entry.S	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: entry.S,v 1.19 2003/05/06 23:28:47 lethal Exp $
+/* $Id: entry.S,v 1.33 2003/11/22 15:39:51 lethal Exp $
  *
  *  linux/arch/sh/entry.S
  *
@@ -24,6 +24,15 @@
 #if !defined(CONFIG_MMU)
 #define sys_madvise		sys_ni_syscall
 #define sys_readahead		sys_ni_syscall
+#define sys_mprotect		sys_ni_syscall
+#define sys_msync		sys_ni_syscall
+#define sys_mlock		sys_ni_syscall
+#define sys_munlock		sys_ni_syscall
+#define sys_mlockall		sys_ni_syscall
+#define sys_munlockall		sys_ni_syscall
+#define sys_mremap		sys_ni_syscall
+#define sys_mincore		sys_ni_syscall
+#define sys_remap_file_pages	sys_ni_syscall
 #endif
 
 ! NOTE:
@@ -137,6 +146,11 @@ OFF_TRA	=  (16*4+6*4)
 ! this first version depends *much* on C implementation.
 !
 
+#define CLI()				\
+	stc	sr, r0;			\
+	or	#0xf0, r0;		\
+	ldc	r0, sr
+
 #define STI()				\
 	mov.l	__INV_IMASK, r11;	\
 	stc	sr, r10;		\
@@ -145,29 +159,36 @@ OFF_TRA	=  (16*4+6*4)
 	or	r11, r10;		\
 	ldc	r10, sr
 
+#if defined(CONFIG_PREEMPT)
+#  define preempt_stop()	CLI()
+#else
+#  define preempt_stop()
+#  define resume_kernel		restore_all
+#endif
+
 #if defined(CONFIG_MMU)
 	.align	2
-tlb_miss_load:
+ENTRY(tlb_miss_load)
 	bra	call_dpf
 	 mov	#0, r5
 
 	.align	2
-tlb_miss_store:
+ENTRY(tlb_miss_store)
 	bra	call_dpf
 	 mov	#1, r5
 
 	.align	2
-initial_page_write:
+ENTRY(initial_page_write)
 	bra	call_dpf
 	 mov	#1, r5
 
 	.align	2
-tlb_protection_violation_load:
+ENTRY(tlb_protection_violation_load)
 	bra	call_dpf
 	 mov	#0, r5
 
 	.align	2
-tlb_protection_violation_store:
+ENTRY(tlb_protection_violation_store)
 	bra	call_dpf
 	 mov	#1, r5
 
@@ -199,12 +220,12 @@ call_dpf:
 3:	.long	do_page_fault
 
 	.align	2
-address_error_load:
+ENTRY(address_error_load)
 	bra	call_dae
 	 mov	#0,r5		! writeaccess = 0
 
 	.align	2
-address_error_store:
+ENTRY(address_error_store)
 	bra	call_dae
 	 mov	#1,r5		! writeaccess = 1
 
@@ -244,7 +265,7 @@ debug_kernel_sw:
 	jmp	@r0
 	 mov	r15, r4
 	.align	2
-3:	.long	SYMBOL_NAME(kgdb_handle_exception)
+3:	.long	kgdb_handle_exception
 #endif /* CONFIG_SH_KGDB */
 
 #if defined(CONFIG_SH_STANDARD_BIOS)
@@ -305,7 +326,7 @@ debug_trap:	
 	 nop
 
 	.align	2
-error:	
+ENTRY(exception_error)
 	!
 	STI()
 	mov.l	2f, r0
@@ -318,22 +339,53 @@ error:	
 2:	.long	do_exception_error
 
 	.align	2
-ret_from_irq:
 ret_from_exception:
+	preempt_stop()
+ret_from_irq:
+	!
 	mov	#OFF_SR, r0
 	mov.l	@(r0,r15), r0	! get status register
 	shll	r0
 	shll	r0		! kernel space?
-	bt/s	restore_all	! Yes, it's from kernel, go back soon
+	bt/s	resume_kernel	! Yes, it's from kernel, go back soon
 	 GET_THREAD_INFO(r8)
 
+#ifdef CONFIG_PREEMPT
+ENTRY(resume_kernel)
+	mov.l	@(TI_PRE_COUNT,r8), r0	! current_thread_info->preempt_count
+	tst	r0, r0
+	bf	restore_all
+need_resched:
+	mov.l	@(TI_FLAGS,r8), r0	! current_thread_info->flags
+	tst	#_TIF_NEED_RESCHED, r0	! need_resched set?
+	bt	restore_all
+
+	stc	sr, r0			! interrupts disabled?
+	tst	#0xf0, r0
+	bf	restore_all
+
+	mov.l	1f, r0
+	mov.l	r0, @(TI_PRE_COUNT,r8)
+
+	STI()
+	mov.l	2f, r0
+	jsr	@r0
+	 nop
+	mov	#0, r0
+	mov.l	r0, @(TI_PRE_COUNT,r8)
+	CLI()
+
+	bra need_resched
+	 nop
+
+	.align 2
+1:	.long	PREEMPT_ACTIVE
+2:	.long	schedule
+#endif
+
 ENTRY(resume_userspace)
 	! r8: current_thread_info
-	/* CLI */
-	stc	sr, r0
-	or	#0xf0, r0
-	ldc	r0, sr
-	!
+	CLI()
 	mov.l	@(TI_FLAGS,r8), r0		! current_thread_info->flags
 	tst	#_TIF_WORK_MASK, r0
 	bt/s	restore_all
@@ -377,10 +429,7 @@ work_resched:
 	mov.l	1f, r1
 	jsr	@r1				! schedule
 	 nop
-	/* CLI */
-	stc	sr, r0
-	or	#0xf0, r0
-	ldc	r0, sr
+	CLI()
 	!
 	mov.l	@(TI_FLAGS,r8), r0		! current_thread_info->flags
 	tst	#_TIF_WORK_MASK, r0
@@ -469,7 +518,7 @@ ret_from_fork:
 	.align	2
 1:	.long	schedule_tail
 	!
-system_call:
+ENTRY(system_call)
 	mov.l	1f, r9
 	mov.l	@r9, r8		! Read from TRA (Trap Address) Register
 	!
@@ -510,10 +559,7 @@ syscall_call:
 	mov.l	r0, @(OFF_R0,r15)		! save the return value
 	!
 syscall_exit:
-	/* CLI */
-	stc	sr, r0
-	or	#0xf0, r0
-	ldc	r0, sr
+	CLI()
 	!
 	GET_THREAD_INFO(r8)
 	mov.l	@(TI_FLAGS,r8), r0		! current_thread_info->flags
@@ -550,6 +596,40 @@ restore_all:
 	lds.l	@r15+, macl
 	add	#4, r15			! Skip syscall number
 	!
+#ifdef CONFIG_SH_DSP
+	mov.l	@r15+, k0		! DSP mode marker
+	mov.l	5f, k1
+	cmp/eq	k0, k1			! Do we have a DSP stack frame?
+	bf	skip_restore
+
+	stc	sr, k0			! Enable CPU DSP mode
+	or	k1, k0			! (within kernel it may be disabled)
+	ldc	k0, sr
+	mov	r2, k0			! Backup r2
+
+	! Restore DSP registers from stack
+	mov	r15, r2
+	movs.l	@r2+, a1
+	movs.l	@r2+, a0g
+	movs.l	@r2+, a1g
+	movs.l	@r2+, m0
+	movs.l	@r2+, m1
+	mov	r2, r15
+
+	lds.l	@r15+, a0
+	lds.l	@r15+, x0
+	lds.l	@r15+, x1
+	lds.l	@r15+, y0
+	lds.l	@r15+, y1
+	lds.l	@r15+, dsr
+	ldc.l	@r15+, rs
+	ldc.l	@r15+, re
+	ldc.l	@r15+, mod
+
+	mov	k0, r2			! Restore r2
+skip_restore:
+#endif
+	!
 	! Calculate new SR value
 	mov	k3, k2			! original SR value
 	mov.l	8f, k1
@@ -576,6 +656,7 @@ restore_all:
 	mov	#0, k1
 	mov.b	k1, @k0
 #endif
+	mov.l	@r15+, k2		! restore EXPEVT
 	mov	k4, r15
 	rte
 	 nop
@@ -585,14 +666,12 @@ restore_all:
 2:	.long	NR_syscalls
 3:	.long	sys_call_table
 4:	.long	do_syscall_trace
+5:	.long	0x00001000	! DSP
 7:	.long	0x30000000
 8:	.long	0x00008000	! FD
 9:	.long	0xffff7f0f	! ~(IMASK+FD)
 __INV_IMASK:
 	.long	0xffffff0f	! ~(IMASK)
-#if defined(CONFIG_KGDB_NMI)
-10:	.long	in_nmi
-#endif
 
 ! Exception Vector Base
 !
@@ -637,7 +716,7 @@ interrupt:
 	 nop
 	.align	2
 5:	.long	NMI_VEC
-6:	.long	SYMBOL_NAME(in_nmi)
+6:	.long	in_nmi
 0:
 #endif /* defined(CONFIG_KGDB_NMI) */
 	bra	handle_exception
@@ -669,7 +748,50 @@ handle_exception:
 	!
 1:  	mov	#-1, k4
 	mov.l	2f, k1
+	!
+#ifdef CONFIG_SH_DSP
+	mov.l	r2, @-r15		! Save r2, we need another reg
+	stc	sr, k4
+	mov.l	1f, r2
+	tst	r2, k4			! Check if in DSP mode
+	mov.l	@r15+, r2		! Restore r2 now
+	bt/s	skip_save
+	 mov	#0, k4			! Set marker for no stack frame
+
+	mov	r2, k4			! Backup r2 (in k4) for later
+
+	! Save DSP registers on stack
+	stc.l	mod, @-r15
+	stc.l	re, @-r15
+	stc.l	rs, @-r15
+	sts.l	dsr, @-r15
+	sts.l	y1, @-r15
+	sts.l	y0, @-r15
+	sts.l	x1, @-r15
+	sts.l	x0, @-r15
+	sts.l	a0, @-r15
+
+	! GAS is broken, does not generate correct "movs.l Ds,@-As" instr.
+
+	! FIXME: Make sure that this is still the case with newer toolchains,
+	! as we're not at all interested in supporting ancient toolchains at
+	! this point. -- PFM.
+
+	mov	r15, r2
+	.word	0xf653			! movs.l	a1, @-r2
+	.word	0xf6f3			! movs.l	a0g, @-r2
+	.word	0xf6d3			! movs.l	a1g, @-r2
+	.word	0xf6c3			! movs.l	m0, @-r2
+	.word	0xf6e3			! movs.l	m1, @-r2
+	mov	r2, r15
+
+	mov	k4, r2			! Restore r2
+	mov.l	1f, k4			! Force DSP stack frame
+skip_save:
+	mov.l	k4, @-r15		! Push DSP mode marker onto stack
+#endif
 	! Save the user registers on the stack.
+	mov.l	k2, @-r15	! EXPEVT
 	mov.l	k4, @-r15	! set TRA (default: -1)
 	!
 	sts.l	macl, @-r15
@@ -715,264 +837,17 @@ handle_exception:
 	 nop
 
 	.align	2
+1:	.long	0x00001000	! DSP=1
 2:	.long	0x000000f0	! FD=0, IMASK=15
 3:	.long	0xcfffffff	! RB=0, BL=0
 4:	.long	exception_handling_table
 
 	.align	2
-none:
+ENTRY(exception_none)
 	rts
 	 nop
 
-.data
-ENTRY(exception_handling_table)
-	.long	error
-	.long	error
-#if defined(CONFIG_MMU)
-	.long	tlb_miss_load
-	.long	tlb_miss_store
-	.long	initial_page_write
-	.long	tlb_protection_violation_load
-	.long	tlb_protection_violation_store
-	.long	address_error_load
-	.long	address_error_store
-#else
-	.long	error	! tlb miss load
-	.long	error	! tlb miss store
-	.long	error	! initial page write
-	.long	error	! tlb prot violation load
-	.long	error	! tlb prot violation store
-	.long	error	! address error load
-	.long	error	! address error store
-#endif
-
-#if defined(CONFIG_CPU_SH4)
-	.long	do_fpu_error
-#else
-	.long	error	! fpu_exception
-#endif
-	.long	error
-	.long	system_call			! Unconditional Trap
-	.long	error	! reserved_instruction      (filled by trap_init)
-	.long	error	! illegal_slot_instruction  (filled by trap_init)
-ENTRY(nmi_slot)
-#if defined (CONFIG_KGDB_NMI)
-	.long	debug_enter			! Allow trap to debugger
-#else
-	.long	none				! Not implemented yet
-#endif
-ENTRY(user_break_point_trap)
-	.long	break_point_trap
-ENTRY(interrupt_table)
-	! external hardware
-	.long	do_IRQ	! 0000
-	.long	do_IRQ	! 0001
-	.long	do_IRQ	! 0010
-	.long	do_IRQ	! 0011
-	.long	do_IRQ	! 0100
-	.long	do_IRQ	! 0101
-	.long	do_IRQ	! 0110
-	.long	do_IRQ	! 0111
-	.long	do_IRQ	! 1000
-	.long	do_IRQ	! 1001
-	.long	do_IRQ	! 1010
-	.long	do_IRQ	! 1011
-	.long	do_IRQ	! 1100
-	.long	do_IRQ	! 1101
-	.long	do_IRQ	! 1110
-	.long	error
-	! Internal hardware
-	.long	do_IRQ	! TMU0 tuni0
-	.long	do_IRQ	! TMU1 tuni1
-	.long	do_IRQ	! TMU2 tuni2
-	.long	do_IRQ	!      ticpi2
-	.long	do_IRQ	! RTC  ati
-	.long	do_IRQ	!      pri
-	.long	do_IRQ	!      cui
-	.long	do_IRQ	! SCI  eri
-	.long	do_IRQ	!      rxi
-	.long	do_IRQ	!      txi
-	.long	do_IRQ	!      tei
-	.long	do_IRQ	! WDT  iti
-	.long	do_IRQ	! REF  rcmi
-	.long	do_IRQ	!      rovi
-	.long	do_IRQ
-	.long	do_IRQ
-#if  defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)
-	.long	do_IRQ	! 32 IRQ  irq0
-	.long	do_IRQ	! 33      irq1
-	.long	do_IRQ	! 34      irq2
-	.long	do_IRQ	! 35      irq3
-	.long	do_IRQ	! 36      irq4
-	.long	do_IRQ	! 37      irq5
-	.long	do_IRQ	! 38
-	.long	do_IRQ	! 39
-	.long	do_IRQ	! 40 PINT pint0-7
-	.long	do_IRQ	! 41      pint8-15
-	.long	do_IRQ	! 42
-	.long	do_IRQ	! 43
-	.long	do_IRQ	! 44
-	.long	do_IRQ	! 45
-	.long	do_IRQ	! 46
-	.long	do_IRQ	! 47
-	.long	do_IRQ	! 48 DMAC dei0
-	.long	do_IRQ	! 49      dei1
-	.long	do_IRQ	! 50      dei2
-	.long	do_IRQ	! 51      dei3
-	.long	do_IRQ	! 52 IrDA eri1
-	.long	do_IRQ	! 53      rxi1
-	.long	do_IRQ	! 54      bri1
-	.long	do_IRQ	! 55      txi1
-	.long	do_IRQ	! 56 SCIF eri2
-	.long	do_IRQ	! 57      rxi2
-	.long	do_IRQ	! 58      bri2
-	.long	do_IRQ	! 59      txi2
-	.long	do_IRQ	! 60 ADC  adi
-#if defined(CONFIG_CPU_SUBTYPE_SH7707)
-	.long   do_IRQ	! 61 LCDC lcdi
-	.long   do_IRQ	! 62 PCC  pcc0i
-	.long   do_IRQ	! 63      pcc1i
-#endif
-#elif defined(CONFIG_CPU_SH4)
-	.long	do_IRQ	! 32 Hitachi UDI
-	.long	do_IRQ	! 33 GPIO
-	.long	do_IRQ	! 34 DMAC dmte0
-	.long	do_IRQ	! 35      dmte1
-	.long	do_IRQ	! 36      dmte2
-	.long	do_IRQ	! 37      dmte3
-	.long	do_IRQ	! 38      dmae
-	.long	error			! 39
-	.long	do_IRQ	! 40 SCIF eri
-	.long	do_IRQ	! 41      rxi
-	.long	do_IRQ	! 42      bri
-	.long	do_IRQ	! 43      txi
-	.long	error			! 44
-	.long	error			! 45
-	.long	error			! 46
-	.long	error			! 47
-	.long	do_fpu_state_restore	! 48
-	.long	do_fpu_state_restore	! 49
-#endif
-#if defined(CONFIG_CPU_SUBTYPE_SH7751)
-	.long	error
-	.long	error
-	.long	error
-	.long	error
-	.long	error
-	.long	error
-	.long	error
-	.long	error
-	.long	error
-	.long	error
-	.long	error
-	.long	error
-	.long	error
-	.long	error
-	.long	do_IRQ	! PCI serr
-	.long	do_IRQ	!     dma3
-	.long	do_IRQ	!     dma2
-	.long	do_IRQ	!     dma1
-	.long	do_IRQ	!     dma0
-	.long	do_IRQ	!     pwon
-	.long	do_IRQ	!     pwdwn
-	.long	do_IRQ	!     err
-#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
-	.long	error			!  50 0x840
-	.long	error			!  51 0x860
-	.long	error			!  52 0x880
-	.long	error			!  53 0x8a0
-	.long	error			!  54 0x8c0
-	.long	error			!  55 0x8e0
-	.long	error			!  56 0x900
-	.long	error			!  57 0x920
-	.long	error			!  58 0x940
-	.long	error			!  59 0x960
-	.long	error			!  60 0x980
-	.long	error			!  61 0x9a0
-	.long	error			!  62 0x9c0
-	.long	error			!  63 0x9e0
-	.long	do_IRQ	!  64 0xa00 PCI serr
-	.long	do_IRQ	!  65 0xa20     err
-	.long	do_IRQ	!  66 0xa40     ad
-	.long	do_IRQ	!  67 0xa60     pwr_dwn
-	.long	error			!  68 0xa80
-	.long	error			!  69 0xaa0
-	.long	error			!  70 0xac0
-	.long	error			!  71 0xae0
-	.long	do_IRQ	!  72 0xb00 DMA INT0
-	.long	do_IRQ	!  73 0xb20     INT1
-	.long	do_IRQ	!  74 0xb40     INT2
-	.long	do_IRQ	!  75 0xb60     INT3
-	.long	do_IRQ	!  76 0xb80     INT4
-	.long	error			!  77 0xba0
-	.long	do_IRQ	!  78 0xbc0 DMA ERR
-	.long	error			!  79 0xbe0
-	.long	do_IRQ	!  80 0xc00 PIO0
-	.long	do_IRQ	!  81 0xc20 PIO1
-	.long	do_IRQ	!  82 0xc40 PIO2
-	.long	error			!  83 0xc60
-	.long	error			!  84 0xc80
-	.long	error			!  85 0xca0
-	.long	error			!  86 0xcc0
-	.long	error			!  87 0xce0
-	.long	error			!  88 0xd00
-	.long	error			!  89 0xd20
-	.long	error			!  90 0xd40
-	.long	error			!  91 0xd60
-	.long	error			!  92 0xd80
-	.long	error			!  93 0xda0
-	.long	error			!  94 0xdc0
-	.long	error			!  95 0xde0
-	.long	error			!  96 0xe00
-	.long	error			!  97 0xe20
-	.long	error			!  98 0xe40
-	.long	error			!  99 0xe60
-	.long	error			! 100 0xe80
-	.long	error			! 101 0xea0
-	.long	error			! 102 0xec0
-	.long	error			! 103 0xee0
-	.long	error			! 104 0xf00
-	.long	error			! 105 0xf20
-	.long	error			! 106 0xf40
-	.long	error			! 107 0xf60
-	.long	error			! 108 0xf80
-	.long	error			! 109 0xfa0
-	.long	error			! 110 0xfc0
-	.long	error			! 111 0xfe0
-	.long	do_IRQ	! 112 0x1000 Mailbox
-	.long	error			! 113 0x1020
-	.long	error			! 114 0x1040
-	.long	error			! 115 0x1060
-	.long	error			! 116 0x1080
-	.long	error			! 117 0x10a0
-	.long	error			! 118 0x10c0
-	.long	error			! 119 0x10e0
-	.long	error			! 120 0x1100
-	.long	error			! 121 0x1120
-	.long	error			! 122 0x1140
-	.long	error			! 123 0x1160
-	.long	error			! 124 0x1180
-	.long	error			! 125 0x11a0
-	.long	error			! 126 0x11c0
-	.long	error			! 127 0x11e0
-	.long	error			! 128 0x1200
-	.long	error			! 129 0x1220
-	.long	error			! 130 0x1240
-	.long	error			! 131 0x1260
-	.long	error			! 132 0x1280
-	.long	error			! 133 0x12a0
-	.long	error			! 134 0x12c0
-	.long	error			! 135 0x12e0
-	.long	error			! 136 0x1300
-	.long	error			! 137 0x1320
-	.long	error			! 138 0x1340
-	.long	error			! 139 0x1360
-	.long	do_IRQ	! 140 0x1380 EMPI INV_ADDR
-	.long	error			! 141 0x13a0
-	.long	error			! 142 0x13c0
-	.long	error			! 143 0x13e0
-#endif
-
+	.data
 ENTRY(sys_call_table)
 	.long sys_ni_syscall	/* 0  -  old "setup()" system call*/
 	.long sys_exit
@@ -1242,6 +1117,12 @@ ENTRY(sys_call_table)
  	.long sys_clock_gettime		/* 265 */
  	.long sys_clock_getres
  	.long sys_clock_nanosleep
+	.long sys_statfs64
+	.long sys_fstatfs64     
+	.long sys_tgkill		/* 270 */
+	.long sys_utimes
+ 	.long sys_fadvise64_64_wrapper
+	.long sys_ni_syscall	/* Reserved for vserver */
 
 	.rept NR_syscalls-(.-sys_call_table)/4
 		.long sys_ni_syscall
diff -puN -L arch/sh/kernel/fpu.c arch/sh/kernel/fpu.c~linus /dev/null
--- 25/arch/sh/kernel/fpu.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,314 +0,0 @@
-/* $Id: fpu.c,v 1.29 2000/03/22 13:42:10 gniibe Exp $
- *
- * linux/arch/sh/kernel/fpu.c
- *
- * Save/restore floating point context for signal handlers.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1999, 2000  Kaz Kojima & Niibe Yutaka
- *
- * FIXME! These routines can be optimized in big endian case.
- */
-
-#include <linux/sched.h>
-#include <linux/signal.h>
-#include <asm/processor.h>
-#include <asm/io.h>
-
-/*
- * Save FPU registers onto task structure.
- * Assume called with FPU enabled (SR.FD=0).
- */
-void
-save_fpu(struct task_struct *tsk)
-{
-	asm volatile("sts.l	fpul, @-%0\n\t"
-		     "sts.l	fpscr, @-%0\n\t"
-		     "lds	%1, fpscr\n\t"
-		     "frchg\n\t"
-		     "fmov.s	fr15, @-%0\n\t"
-		     "fmov.s	fr14, @-%0\n\t"
-		     "fmov.s	fr13, @-%0\n\t"
-		     "fmov.s	fr12, @-%0\n\t"
-		     "fmov.s	fr11, @-%0\n\t"
-		     "fmov.s	fr10, @-%0\n\t"
-		     "fmov.s	fr9, @-%0\n\t"
-		     "fmov.s	fr8, @-%0\n\t"
-		     "fmov.s	fr7, @-%0\n\t"
-		     "fmov.s	fr6, @-%0\n\t"
-		     "fmov.s	fr5, @-%0\n\t"
-		     "fmov.s	fr4, @-%0\n\t"
-		     "fmov.s	fr3, @-%0\n\t"
-		     "fmov.s	fr2, @-%0\n\t"
-		     "fmov.s	fr1, @-%0\n\t"
-		     "fmov.s	fr0, @-%0\n\t"
-		     "frchg\n\t"
-		     "fmov.s	fr15, @-%0\n\t"
-		     "fmov.s	fr14, @-%0\n\t"
-		     "fmov.s	fr13, @-%0\n\t"
-		     "fmov.s	fr12, @-%0\n\t"
-		     "fmov.s	fr11, @-%0\n\t"
-		     "fmov.s	fr10, @-%0\n\t"
-		     "fmov.s	fr9, @-%0\n\t"
-		     "fmov.s	fr8, @-%0\n\t"
-		     "fmov.s	fr7, @-%0\n\t"
-		     "fmov.s	fr6, @-%0\n\t"
-		     "fmov.s	fr5, @-%0\n\t"
-		     "fmov.s	fr4, @-%0\n\t"
-		     "fmov.s	fr3, @-%0\n\t"
-		     "fmov.s	fr2, @-%0\n\t"
-		     "fmov.s	fr1, @-%0\n\t"
-		     "fmov.s	fr0, @-%0"
-		     : /* no output */
-		     : "r" ((char *)(&tsk->thread.fpu.hard.status)),
-		       "r" (FPSCR_INIT)
-		     : "memory");
-
-	tsk->flags &= ~PF_USEDFPU;
-	release_fpu();
-}
-
-static void
-restore_fpu(struct task_struct *tsk)
-{
-	asm volatile("lds	%1, fpscr\n\t"
-		     "fmov.s	@%0+, fr0\n\t"
-		     "fmov.s	@%0+, fr1\n\t"
-		     "fmov.s	@%0+, fr2\n\t"
-		     "fmov.s	@%0+, fr3\n\t"
-		     "fmov.s	@%0+, fr4\n\t"
-		     "fmov.s	@%0+, fr5\n\t"
-		     "fmov.s	@%0+, fr6\n\t"
-		     "fmov.s	@%0+, fr7\n\t"
-		     "fmov.s	@%0+, fr8\n\t"
-		     "fmov.s	@%0+, fr9\n\t"
-		     "fmov.s	@%0+, fr10\n\t"
-		     "fmov.s	@%0+, fr11\n\t"
-		     "fmov.s	@%0+, fr12\n\t"
-		     "fmov.s	@%0+, fr13\n\t"
-		     "fmov.s	@%0+, fr14\n\t"
-		     "fmov.s	@%0+, fr15\n\t"
-		     "frchg\n\t"
-		     "fmov.s	@%0+, fr0\n\t"
-		     "fmov.s	@%0+, fr1\n\t"
-		     "fmov.s	@%0+, fr2\n\t"
-		     "fmov.s	@%0+, fr3\n\t"
-		     "fmov.s	@%0+, fr4\n\t"
-		     "fmov.s	@%0+, fr5\n\t"
-		     "fmov.s	@%0+, fr6\n\t"
-		     "fmov.s	@%0+, fr7\n\t"
-		     "fmov.s	@%0+, fr8\n\t"
-		     "fmov.s	@%0+, fr9\n\t"
-		     "fmov.s	@%0+, fr10\n\t"
-		     "fmov.s	@%0+, fr11\n\t"
-		     "fmov.s	@%0+, fr12\n\t"
-		     "fmov.s	@%0+, fr13\n\t"
-		     "fmov.s	@%0+, fr14\n\t"
-		     "fmov.s	@%0+, fr15\n\t"
-		     "frchg\n\t"
-		     "lds.l	@%0+, fpscr\n\t"
-		     "lds.l	@%0+, fpul\n\t"
-		     : /* no output */
-		     : "r" (&tsk->thread.fpu), "r" (FPSCR_INIT)
-		     : "memory");
-}
-
-/*
- * Load the FPU with signalling NANS.  This bit pattern we're using
- * has the property that no matter whether considered as single or as
- * double precission represents signaling NANS.  
- */
-
-static void
-fpu_init(void)
-{
-	asm volatile("lds	%0, fpul\n\t"
-		     "lds	%1, fpscr\n\t"
-		     "fsts	fpul, fr0\n\t"
-		     "fsts	fpul, fr1\n\t"
-		     "fsts	fpul, fr2\n\t"
-		     "fsts	fpul, fr3\n\t"
-		     "fsts	fpul, fr4\n\t"
-		     "fsts	fpul, fr5\n\t"
-		     "fsts	fpul, fr6\n\t"
-		     "fsts	fpul, fr7\n\t"
-		     "fsts	fpul, fr8\n\t"
-		     "fsts	fpul, fr9\n\t"
-		     "fsts	fpul, fr10\n\t"
-		     "fsts	fpul, fr11\n\t"
-		     "fsts	fpul, fr12\n\t"
-		     "fsts	fpul, fr13\n\t"
-		     "fsts	fpul, fr14\n\t"
-		     "fsts	fpul, fr15\n\t"
-		     "frchg\n\t"
-		     "fsts	fpul, fr0\n\t"
-		     "fsts	fpul, fr1\n\t"
-		     "fsts	fpul, fr2\n\t"
-		     "fsts	fpul, fr3\n\t"
-		     "fsts	fpul, fr4\n\t"
-		     "fsts	fpul, fr5\n\t"
-		     "fsts	fpul, fr6\n\t"
-		     "fsts	fpul, fr7\n\t"
-		     "fsts	fpul, fr8\n\t"
-		     "fsts	fpul, fr9\n\t"
-		     "fsts	fpul, fr10\n\t"
-		     "fsts	fpul, fr11\n\t"
-		     "fsts	fpul, fr12\n\t"
-		     "fsts	fpul, fr13\n\t"
-		     "fsts	fpul, fr14\n\t"
-		     "fsts	fpul, fr15\n\t"
-		     "frchg"
-		     : /* no output */
-		     : "r" (0), "r" (FPSCR_INIT));
-}
-
-/**
- *	denormal_to_double - Given denormalized float number,
- *	                     store double float
- *
- *	@fpu: Pointer to sh_fpu_hard structure
- *	@n: Index to FP register
- */
-static void
-denormal_to_double (struct sh_fpu_hard_struct *fpu, int n)
-{
-	unsigned long du, dl;
-	unsigned long x = fpu->fpul;
-	int exp = 1023 - 126;
-
-	if (x != 0 && (x & 0x7f800000) == 0) {
-		du = (x & 0x80000000);
-		while ((x & 0x00800000) == 0) {
-			x <<= 1;
-			exp--;
-		}
-		x &= 0x007fffff;
-		du |= (exp << 20) | (x >> 3);
-		dl = x << 29;
-
-		fpu->fp_regs[n] = du;
-		fpu->fp_regs[n+1] = dl;
-	}
-}
-
-/**
- *	ieee_fpe_handler - Handle denormalized number exception
- *
- *	@regs: Pointer to register structure
- *
- *	Returns 1 when it's handled (should not cause exception).
- */
-static int
-ieee_fpe_handler (struct pt_regs *regs)
-{
-	unsigned short insn = *(unsigned short *) regs->pc;
-	unsigned short finsn;
-	unsigned long nextpc;
-	int nib[4] = {
-		(insn >> 12) & 0xf,
-		(insn >> 8) & 0xf,
-		(insn >> 4) & 0xf,
-		insn & 0xf};
-
-	if (nib[0] == 0xb ||
-	    (nib[0] == 0x4 && nib[2] == 0x0 && nib[3] == 0xb)) /* bsr & jsr */
-		regs->pr = regs->pc + 4;
-  
-	if (nib[0] == 0xa || nib[0] == 0xb) { /* bra & bsr */
-		nextpc = regs->pc + 4 + ((short) ((insn & 0xfff) << 4) >> 3);
-		finsn = *(unsigned short *) (regs->pc + 2);
-	} else if (nib[0] == 0x8 && nib[1] == 0xd) { /* bt/s */
-		if (regs->sr & 1)
-			nextpc = regs->pc + 4 + ((char) (insn & 0xff) << 1);
-		else
-			nextpc = regs->pc + 4;
-		finsn = *(unsigned short *) (regs->pc + 2);
-	} else if (nib[0] == 0x8 && nib[1] == 0xf) { /* bf/s */
-		if (regs->sr & 1)
-			nextpc = regs->pc + 4;
-		else
-			nextpc = regs->pc + 4 + ((char) (insn & 0xff) << 1);
-		finsn = *(unsigned short *) (regs->pc + 2);
-	} else if (nib[0] == 0x4 && nib[3] == 0xb &&
-		 (nib[2] == 0x0 || nib[2] == 0x2)) { /* jmp & jsr */
-		nextpc = regs->regs[nib[1]];
-		finsn = *(unsigned short *) (regs->pc + 2);
-	} else if (nib[0] == 0x0 && nib[3] == 0x3 &&
-		 (nib[2] == 0x0 || nib[2] == 0x2)) { /* braf & bsrf */
-		nextpc = regs->pc + 4 + regs->regs[nib[1]];
-		finsn = *(unsigned short *) (regs->pc + 2);
-	} else if (insn == 0x000b) { /* rts */
-		nextpc = regs->pr;
-		finsn = *(unsigned short *) (regs->pc + 2);
-	} else {
-		nextpc = regs->pc + 2;
-		finsn = insn;
-	}
-
-	if ((finsn & 0xf1ff) == 0xf0ad) { /* fcnvsd */
-		struct task_struct *tsk = current;
-
-		save_fpu(tsk);
-		if ((tsk->thread.fpu.hard.fpscr & (1 << 17))) {
-			/* FPU error */
-			denormal_to_double (&tsk->thread.fpu.hard,
-					    (finsn >> 8) & 0xf);
-			tsk->thread.fpu.hard.fpscr &=
-				~(FPSCR_CAUSE_MASK | FPSCR_FLAG_MASK);
-			grab_fpu();
-			restore_fpu(tsk);
-			tsk->flags |= PF_USEDFPU;
-		} else {
-			tsk->thread.trap_no = 11;
-			tsk->thread.error_code = 0;
-			force_sig(SIGFPE, tsk);
-		}
-
-		regs->pc = nextpc;
-		return 1;
-	}
-
-	return 0;
-}
-
-asmlinkage void
-do_fpu_error(unsigned long r4, unsigned long r5, unsigned long r6, unsigned long r7,
-	     struct pt_regs regs)
-{
-	struct task_struct *tsk = current;
-
-	if (ieee_fpe_handler (&regs))
-		return;
-
-	regs.pc += 2;
-	save_fpu(tsk);
-	tsk->thread.trap_no = 11;
-	tsk->thread.error_code = 0;
-	force_sig(SIGFPE, tsk);
-}
-
-asmlinkage void
-do_fpu_state_restore(unsigned long r4, unsigned long r5, unsigned long r6,
-		     unsigned long r7, struct pt_regs regs)
-{
-	struct task_struct *tsk = current;
-
-	grab_fpu();
-	if (!user_mode(&regs)) {
-		printk(KERN_ERR "BUG: FPU is used in kernel mode.\n");
-		return;
-	}
-
-	if (tsk->used_math) {
-		/* Using the FPU again.  */
-		restore_fpu(tsk);
-	} else	{
-		/* First time FPU user.  */
-		fpu_init();
-		tsk->used_math = 1;
-	}
-	tsk->flags |= PF_USEDFPU;
-}
diff -puN arch/sh/kernel/head.S~linus arch/sh/kernel/head.S
--- 25/arch/sh/kernel/head.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/kernel/head.S	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: head.S,v 1.6 2003/05/04 19:29:53 lethal Exp $
+/* $Id: head.S,v 1.7 2003/09/01 17:58:19 lethal Exp $
  *
  *  arch/sh/kernel/head.S
  *
@@ -50,7 +50,7 @@ ENTRY(_stext)
 	sub	r1, r0		!
 	ldc	r0, r7_bank	! ... and initial thread_info
 	!
-	!			Enable cache
+	!			Additional CPU initialization
 	mov.l	6f, r0
 	jsr	@r0
 	 nop
@@ -73,4 +73,4 @@ ENTRY(_stext)
 3:	.long	__bss_start
 4:	.long	_end
 5:	.long	start_kernel
-6:	.long	sh_cache_init
+6:	.long	sh_cpu_init
diff -puN arch/sh/kernel/io.c~linus arch/sh/kernel/io.c
--- 25/arch/sh/kernel/io.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/kernel/io.c	2004-01-19 22:17:21.000000000 -0800
@@ -10,186 +10,6 @@
 #include <asm/io.h>
 #include <linux/module.h>
 
-unsigned char _inb(unsigned long port)
-{
-	return __inb(port);
-}
-EXPORT_SYMBOL(_inb);
-
-unsigned short _inw(unsigned long port)
-{
-	return __inw(port);
-}
-EXPORT_SYMBOL(_inw);
-
-unsigned int _inl(unsigned long port)
-{
-	return __inl(port);
-}
-EXPORT_SYMBOL(_inl);
-
-void _outb(unsigned char b, unsigned long port)
-{
-	__outb(b, port);
-}
-EXPORT_SYMBOL(_outb);
-
-void _outw(unsigned short b, unsigned long port)
-{
-	__outw(b, port);
-}
-EXPORT_SYMBOL(_outw);
-
-
-void _outl(unsigned int b, unsigned long port)
-{
-	__outl(b, port);
-}
-EXPORT_SYMBOL(_outl);
-
-
-unsigned char _inb_p(unsigned long port)
-{
-	return __inb_p(port);
-}
-EXPORT_SYMBOL(_inb_p);
-
-unsigned short _inw_p(unsigned long port)
-{
-	return __inw_p(port);
-}
-EXPORT_SYMBOL(_inw_p);
-
-
-void _outb_p(unsigned char b, unsigned long port)
-{
-	__outb_p(b, port);
-}
-EXPORT_SYMBOL(_outb_p);
-
-void _outw_p(unsigned short b, unsigned long port)
-{
-	__outw_p(b, port);
-}
-EXPORT_SYMBOL(_outw_p);
-
-void _insb(unsigned long port, void *buffer, unsigned long count)
-{
-	return __insb(port, buffer, count);
-}
-EXPORT_SYMBOL(_insb);
-
-void _insw(unsigned long port, void *buffer, unsigned long count)
-{
-	__insw(port, buffer, count);
-}
-EXPORT_SYMBOL(_insw);
-
-void _insl(unsigned long port, void *buffer, unsigned long count)
-{
-	__insl(port, buffer, count);
-}
-EXPORT_SYMBOL(_insl);
-
-void _outsb(unsigned long port, const void *buffer, unsigned long count)
-{
-	__outsb(port, buffer, count);
-}
-EXPORT_SYMBOL(_outsb);
-
-void _outsw(unsigned long port, const void *buffer, unsigned long count)
-{
-	__outsw(port, buffer, count);
-}
-EXPORT_SYMBOL(_outsw);
-
-void _outsl(unsigned long port, const void *buffer, unsigned long count)
-{
-	__outsl(port, buffer, count);
-
-}
-EXPORT_SYMBOL(_outsl);
-
-unsigned char ___raw_readb(unsigned long addr)
-{
-	return __readb(addr);
-}
-EXPORT_SYMBOL(___raw_readb);
-
-unsigned short ___raw_readw(unsigned long addr)
-{
-	return __readw(addr);
-}
-EXPORT_SYMBOL(___raw_readw);
-
-unsigned int ___raw_readl(unsigned long addr)
-{
-	return __readl(addr);
-}
-EXPORT_SYMBOL(___raw_readl);
-
-unsigned char _readb(unsigned long addr)
-{
-	unsigned long r = __readb(addr);
-	mb();
-	return r;
-}
-EXPORT_SYMBOL(_readb);
-
-unsigned short _readw(unsigned long addr)
-{
-	unsigned long r = __readw(addr);
-	mb();
-	return r;
-}
-EXPORT_SYMBOL(_readw);
-
-unsigned int _readl(unsigned long addr)
-{
-	unsigned long r = __readl(addr);
-	mb();
-	return r;
-}
-EXPORT_SYMBOL(_readl);
-
-void ___raw_writeb(unsigned char b, unsigned long addr)
-{
-	__writeb(b, addr);
-}
-
-void ___raw_writew(unsigned short b, unsigned long addr)
-{
-	__writew(b, addr);
-}
-EXPORT_SYMBOL(___raw_writew);
-
-void ___raw_writel(unsigned int b, unsigned long addr)
-{
-	__writel(b, addr);
-}
-EXPORT_SYMBOL(___raw_writel);
-
-void _writeb(unsigned char b, unsigned long addr)
-{
-	__writeb(b, addr);
-	mb();
-}
-EXPORT_SYMBOL(_writeb);
-
-void _writew(unsigned short b, unsigned long addr)
-{
-	__writew(b, addr);
-	mb();
-}
-EXPORT_SYMBOL(_writew);
-
-void _writel(unsigned int b, unsigned long addr)
-{
-	__writel(b, addr);
-	mb();
-}
-EXPORT_SYMBOL(_writel);
-
 /*
  * Copy data from IO memory space to "real" memory space.
  * This needs to be optimized.
@@ -230,3 +50,8 @@ void  memset_io(unsigned long dst, int c
                 dst++;
         }
 }
+
+EXPORT_SYMBOL(memcpy_fromio);
+EXPORT_SYMBOL(memcpy_toio);
+EXPORT_SYMBOL(memset_io);
+
diff -puN arch/sh/kernel/irq.c~linus arch/sh/kernel/irq.c
--- 25/arch/sh/kernel/irq.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/kernel/irq.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: irq.c,v 1.12 2003/06/28 15:34:55 lethal Exp $
+/* $Id: irq.c,v 1.19 2004/01/10 01:25:32 lethal Exp $
  *
  * linux/arch/sh/kernel/irq.c
  *
@@ -30,6 +30,7 @@
 #include <linux/smp_lock.h>
 #include <linux/init.h>
 #include <linux/seq_file.h>
+#include <linux/kallsyms.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
@@ -45,6 +46,7 @@
 irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = {
 	[0 ... NR_IRQS-1] = {
 		.handler = &no_irq_type,
+		.lock = SPIN_LOCK_UNLOCKED
 	}
 };
 
@@ -150,23 +152,88 @@ int handle_IRQ_event(unsigned int irq, s
 		add_interrupt_randomness(irq);
 
 	local_irq_disable();
+	return retval;
+}
 
-	if (retval != 1) {
-		static int count = 100;
+static void __report_bad_irq(int irq, irq_desc_t *desc, irqreturn_t action_ret)
+{
+	struct irqaction *action;
 
-		if (count) {
-			count--;
+	if (action_ret != IRQ_HANDLED && action_ret != IRQ_NONE) {
+		printk(KERN_ERR "irq event %d: bogus return value %x\n",
+				irq, action_ret);
+	} else {
+		printk(KERN_ERR "irq %d: nobody cared!\n", irq);
+	}
+	dump_stack();
+	printk(KERN_ERR "handlers:\n");
+	action = desc->action;
+	do {
+		printk(KERN_ERR "[<%p>]", action->handler);
+		print_symbol(" (%s)",
+			(unsigned long)action->handler);
+		printk("\n");
+		action = action->next;
+	} while (action);
+}
 
-			if (retval) {
-				printk("irq event %d: bogus retval mask %x\n",
-					irq, retval);
-			} else {
-				printk("irq %d: nobody cared\n", irq);
-			}
-		}
+static void report_bad_irq(int irq, irq_desc_t *desc, irqreturn_t action_ret)
+{
+	static int count = 100;
+
+	if (count) {
+		count--;
+		__report_bad_irq(irq, desc, action_ret);
+	}
+}
+
+static int noirqdebug;
+
+static int __init noirqdebug_setup(char *str)
+{
+	noirqdebug = 1;
+	printk("IRQ lockup detection disabled\n");
+	return 1;
+}
+
+__setup("noirqdebug", noirqdebug_setup);
+
+/*
+ * If 99,900 of the previous 100,000 interrupts have not been handled then
+ * assume that the IRQ is stuck in some manner.  Drop a diagnostic and try to
+ * turn the IRQ off.
+ *
+ * (The other 100-of-100,000 interrupts may have been a correctly-functioning
+ *  device sharing an IRQ with the failing one)
+ *
+ * Called under desc->lock
+ */
+static void note_interrupt(int irq, irq_desc_t *desc, irqreturn_t action_ret)
+{
+	if (action_ret != IRQ_HANDLED) {
+		desc->irqs_unhandled++;
+		if (action_ret != IRQ_NONE)
+			report_bad_irq(irq, desc, action_ret);
 	}
 
-	return status;
+	desc->irq_count++;
+	if (desc->irq_count < 100000)
+		return;
+
+	desc->irq_count = 0;
+	if (desc->irqs_unhandled > 99900) {
+		/*
+		 * The interrupt is stuck
+		 */
+		__report_bad_irq(irq, desc, action_ret);
+		/*
+		 * Now kill the IRQ
+		 */
+		printk(KERN_EMERG "Disabling IRQ #%d\n", irq);
+		desc->status |= IRQ_DISABLED;
+		desc->handler->disable(irq);
+	}
+	desc->irqs_unhandled = 0;
 }
 
 /*
@@ -194,8 +261,10 @@ inline void disable_irq_nosync(unsigned 
  */
 void disable_irq(unsigned int irq)
 {
+	irq_desc_t *desc = irq_desc + irq;
 	disable_irq_nosync(irq);
-	synchronize_irq(irq);
+	if (desc->action)
+		synchronize_irq(irq);
 }
 
 void enable_irq(unsigned int irq)
@@ -206,7 +275,7 @@ void enable_irq(unsigned int irq)
 	spin_lock_irqsave(&desc->lock, flags);
 	switch (desc->depth) {
 	case 1: {
-		unsigned int status = desc->status & ~IRQ_DISABLED;
+		unsigned int status = desc->status & ~(IRQ_DISABLED | IRQ_INPROGRESS);
 		desc->status = status;
 		if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) {
 			desc->status = status | IRQ_REPLAY;
@@ -243,7 +312,6 @@ asmlinkage int do_IRQ(unsigned long r4, 
 	 * handled by some other CPU. (or is disabled)
 	 */
 	int irq;
-	int cpu = smp_processor_id();
 	irq_desc_t *desc;
 	struct irqaction * action;
 	unsigned int status;
@@ -259,7 +327,7 @@ asmlinkage int do_IRQ(unsigned long r4, 
 		     :"=z" (irq));
 	irq = irq_demux(irq);
 
-	kstat_cpu(cpu).irqs[irq]++;
+	kstat_this_cpu.irqs[irq]++;
 	desc = irq_desc + irq;
 	spin_lock(&desc->lock);
 	desc->handler->ack(irq);
@@ -302,10 +370,13 @@ asmlinkage int do_IRQ(unsigned long r4, 
 	 * SMP environment.
 	 */
 	for (;;) {
+		irqreturn_t action_ret;
+
 		spin_unlock(&desc->lock);
-		handle_IRQ_event(irq, &regs, action);
+		action_ret = handle_IRQ_event(irq, &regs, action);
 		spin_lock(&desc->lock);
-
+		if (!noirqdebug)
+			note_interrupt(irq, desc, action_ret);
 		if (likely(!(desc->status & IRQ_PENDING)))
 			break;
 		desc->status &= ~IRQ_PENDING;
@@ -454,16 +525,17 @@ unsigned long probe_irq_on(void)
 	 * Wait for spurious interrupts to trigger
 	 */
 	for (delay = jiffies + HZ/10; time_after(delay, jiffies); )
-		/* about 100ms delay */ synchronize_irq();
+		/* about 100ms delay */ barrier();
 
 	/*
 	 * Now filter out any obviously spurious interrupts
 	 */
 	val = 0;
 	for (i=0; i<NR_IRQS; i++) {
-		desc = irq_desc + i;
 		unsigned int status;
 
+		desc = irq_desc + i;
+
 		spin_lock_irq(&desc->lock);
 		status = desc->status;
 
diff -puN arch/sh/kernel/kgdb_stub.c~linus arch/sh/kernel/kgdb_stub.c
--- 25/arch/sh/kernel/kgdb_stub.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/kernel/kgdb_stub.c	2004-01-19 22:17:21.000000000 -0800
@@ -778,7 +778,7 @@ static short *get_step_address(void)
 	else
 		addr = trap_registers.pc + 2;
 
-	flush_icache_range(addr, addr + 2);
+	kgdb_flush_icache_range(addr, addr + 2);
 	return (short *) addr;
 }
 
@@ -801,7 +801,7 @@ static void do_single_step(void)
 	*addr = STEP_OPCODE;
 
 	/* Flush and return */
-	flush_icache_range((long) addr, (long) addr + 2);
+	kgdb_flush_icache_range((long) addr, (long) addr + 2);
 	return;
 }
 
@@ -812,7 +812,7 @@ static void undo_single_step(void)
 	/* Use stepped_address in case we stopped elsewhere */
 	if (stepped_opcode != 0) {
 		*(short*)stepped_address = stepped_opcode;
-		flush_icache_range(stepped_address, stepped_address + 2);
+		kgdb_flush_icache_range(stepped_address, stepped_address + 2);
 	}
 	stepped_opcode = 0;
 }
@@ -924,7 +924,7 @@ static void write_mem_msg(int binary)
 					ebin_to_mem(ptr, (char*)addr, length);
 				else
 					hex_to_mem(ptr, (char*)addr, length);
-				flush_icache_range(addr, addr + length);
+				kgdb_flush_icache_range(addr, addr + length);
 				ptr = 0;
 				send_ok_msg();
 			}
diff -puN arch/sh/kernel/Makefile~linus arch/sh/kernel/Makefile
--- 25/arch/sh/kernel/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/kernel/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -17,11 +17,5 @@ obj-$(CONFIG_SH_KGDB)		+= kgdb_stub.o kg
 obj-$(CONFIG_SH_CPU_FREQ)	+= cpufreq.o
 obj-$(CONFIG_MODULES)		+= module.o
 
-ifneq ($(CONFIG_SH_DREAMCAST),y)
-obj-$(CONFIG_PCI)		+= pci-dma.o
-endif
-obj-$(CONFIG_PCI)		+= pci.o
-obj-$(CONFIG_PCI_AUTO)		+= pci_auto.o
-
 USE_STANDARD_AS_RULE := true
 
diff -puN arch/sh/kernel/module.c~linus arch/sh/kernel/module.c
--- 25/arch/sh/kernel/module.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/kernel/module.c	2004-01-19 22:17:21.000000000 -0800
@@ -138,3 +138,7 @@ int module_finalize(const Elf_Ehdr *hdr,
 {
 	return 0;
 }
+
+void module_arch_cleanup(struct module *mod)
+{
+}
diff -puN -L arch/sh/kernel/pci_auto.c arch/sh/kernel/pci_auto.c~linus /dev/null
--- 25/arch/sh/kernel/pci_auto.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,502 +0,0 @@
-/*
- * PCI autoconfiguration library
- *
- * Author: Matt Porter <mporter@mvista.com>
- *
- * Copyright 2000, 2001 MontaVista Software Inc.
- * Copyright 2001 Bradley D. LaRonde <brad@ltc.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.
- */
-
-/*
- * Modified for MIPS by Jun Sun, jsun@mvista.com
- *
- * . Simplify the interface between pci_auto and the rest: a single function.
- * . Assign resources from low address to upper address.
- * . change most int to u32.
- *
- * Further modified to include it as mips generic code, ppopov@mvista.com.
- *
- * 2001-10-26  Bradley D. LaRonde <brad@ltc.com>
- * - Add a top_bus argument to the "early config" functions so that
- *   they can set a fake parent bus pointer to convince the underlying
- *   pci ops to use type 1 configuration for sub busses.
- * - Set bridge base and limit registers correctly.
- * - Align io and memory base properly before and after bridge setup.
- * - Don't fall through to pci_setup_bars for bridge.
- * - Reformat the debug output to look more like lspci's output.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/pci.h>
-
-#define	DEBUG
-#ifdef 	DEBUG
-#define	DBG(x...)	printk(x)
-#else
-#define	DBG(x...)	
-#endif
-
-/*
- * These functions are used early on before PCI scanning is done
- * and all of the pci_dev and pci_bus structures have been created.
- */
-static struct pci_dev *fake_pci_dev(struct pci_channel *hose,
-	int top_bus, int busnr, int devfn)
-{
-	static struct pci_dev dev;
-	static struct pci_bus bus;
-
-	dev.bus = &bus;
-	dev.sysdata = hose;
-	dev.devfn = devfn;
-	bus.number = busnr;
-	bus.ops = hose->pci_ops;
-
-	if(busnr != top_bus)
-		/* Fake a parent bus structure. */
-		bus.parent = &bus;
-	else
-		bus.parent = NULL;
-
-	return &dev;
-}
-
-#define EARLY_PCI_OP(rw, size, type)					\
-int early_##rw##_config_##size(struct pci_channel *hose,		\
-	int top_bus, int bus, int devfn, int offset, type value)	\
-{									\
-	return pci_##rw##_config_##size(				\
-		fake_pci_dev(hose, top_bus, bus, devfn),		\
-		offset, value);						\
-}
-
-EARLY_PCI_OP(read, byte, u8 *)
-EARLY_PCI_OP(read, word, u16 *)
-EARLY_PCI_OP(read, dword, u32 *)
-EARLY_PCI_OP(write, byte, u8)
-EARLY_PCI_OP(write, word, u16)
-EARLY_PCI_OP(write, dword, u32)
-
-static struct resource *io_resource_inuse;
-static struct resource *mem_resource_inuse;
-
-static u32 pciauto_lower_iospc;
-static u32 pciauto_upper_iospc;
-
-static u32 pciauto_lower_memspc;
-static u32 pciauto_upper_memspc;
-
-static void __init 
-pciauto_setup_bars(struct pci_channel *hose,
-		   int top_bus,
-		   int current_bus,
-		   int pci_devfn)
-{
-	u32 bar_response, bar_size, bar_value;
-	u32 bar, addr_mask, bar_nr = 0;
-	u32 * upper_limit;
-	u32 * lower_limit;
-	int found_mem64 = 0;
-
-	for (bar = PCI_BASE_ADDRESS_0; bar <= PCI_BASE_ADDRESS_5; bar+=4) {
-		/* Tickle the BAR and get the response */
-		early_write_config_dword(hose, top_bus,
-					 current_bus,
-					 pci_devfn,
-					 bar,
-					 0xffffffff);
-		early_read_config_dword(hose, top_bus,
-					current_bus,
-					pci_devfn,
-					bar,
-					&bar_response);
-
-		/* If BAR is not implemented go to the next BAR */
-		if (!bar_response)
-			continue;
-
-		/*
-		 * Workaround for a BAR that doesn't use its upper word,
-		 * like the ALi 1535D+ PCI DC-97 Controller Modem (M5457).
-		 * bdl <brad@ltc.com>
-		 */
-		if (!(bar_response & 0xffff0000))
-			bar_response |= 0xffff0000;
-
-retry:
-		/* Check the BAR type and set our address mask */
-		if (bar_response & PCI_BASE_ADDRESS_SPACE) {
-			addr_mask = PCI_BASE_ADDRESS_IO_MASK;
-			upper_limit = &pciauto_upper_iospc;
-			lower_limit = &pciauto_lower_iospc;
-			DBG("        I/O");
-		} else {
-			if ((bar_response & PCI_BASE_ADDRESS_MEM_TYPE_MASK) ==
-			    PCI_BASE_ADDRESS_MEM_TYPE_64)
-				found_mem64 = 1;
-
-			addr_mask = PCI_BASE_ADDRESS_MEM_MASK;		
-			upper_limit = &pciauto_upper_memspc;
-			lower_limit = &pciauto_lower_memspc;
-			DBG("        Mem");
-		}
-
-
-		/* Calculate requested size */
-		bar_size = ~(bar_response & addr_mask) + 1;
-
-		/* Allocate a base address */
-		bar_value = ((*lower_limit - 1) & ~(bar_size - 1)) + bar_size;
-
-		if ((bar_value + bar_size) > *upper_limit) {
-			if (bar_response & PCI_BASE_ADDRESS_SPACE) {
-				if (io_resource_inuse->child) {
-					io_resource_inuse = 
-						io_resource_inuse->child;
-					pciauto_lower_iospc = 
-						io_resource_inuse->start;
-					pciauto_upper_iospc = 
-						io_resource_inuse->end + 1;
-					goto retry;
-				}
-
-			} else {
-				if (mem_resource_inuse->child) {
-					mem_resource_inuse = 
-						mem_resource_inuse->child;
-					pciauto_lower_memspc = 
-						mem_resource_inuse->start;
-					pciauto_upper_memspc = 
-						mem_resource_inuse->end + 1;
-					goto retry;
-				}
-			}
-			DBG(" unavailable -- skipping, value %x size %x\n",
-					bar_value, bar_size);
-			continue;
-		}
-
-		/* Write it out and update our limit */
-		early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
-					 bar, bar_value);
-
-		*lower_limit = bar_value + bar_size;
-
-		/*
-		 * If we are a 64-bit decoder then increment to the
-		 * upper 32 bits of the bar and force it to locate
-		 * in the lower 4GB of memory.
-		 */ 
-		if (found_mem64) {
-			bar += 4;
-			early_write_config_dword(hose, top_bus,
-						 current_bus,
-						 pci_devfn,
-						 bar,
-						 0x00000000);
-		}
-
-		DBG(" at 0x%.8x [size=0x%x]\n", bar_value, bar_size);
-
-		bar_nr++;
-	}
-
-}
-
-static void __init
-pciauto_prescan_setup_bridge(struct pci_channel *hose,
-			     int top_bus,
-			     int current_bus,
-			     int pci_devfn,
-			     int sub_bus)
-{
-	/* Configure bus number registers */
-	early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
-	                        PCI_PRIMARY_BUS, current_bus);
-	early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
-				PCI_SECONDARY_BUS, sub_bus + 1);
-	early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
-				PCI_SUBORDINATE_BUS, 0xff);
-
-	/* Align memory and I/O to 1MB and 4KB boundaries. */
-	pciauto_lower_memspc = (pciauto_lower_memspc + (0x100000 - 1))
-		& ~(0x100000 - 1);
-	pciauto_lower_iospc = (pciauto_lower_iospc + (0x1000 - 1))
-		& ~(0x1000 - 1);
-
-	/* Set base (lower limit) of address range behind bridge. */
-	early_write_config_word(hose, top_bus, current_bus, pci_devfn,
-		PCI_MEMORY_BASE, pciauto_lower_memspc >> 16);
-	early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
-		PCI_IO_BASE, (pciauto_lower_iospc & 0x0000f000) >> 8);
-	early_write_config_word(hose, top_bus, current_bus, pci_devfn,
-		PCI_IO_BASE_UPPER16, pciauto_lower_iospc >> 16);
-
-	/* We don't support prefetchable memory for now, so disable */
-	early_write_config_word(hose, top_bus, current_bus, pci_devfn,
-				PCI_PREF_MEMORY_BASE, 0);
-	early_write_config_word(hose, top_bus, current_bus, pci_devfn,
-				PCI_PREF_MEMORY_LIMIT, 0);
-}
-
-static void __init
-pciauto_postscan_setup_bridge(struct pci_channel *hose,
-			      int top_bus,
-			      int current_bus,
-			      int pci_devfn,
-			      int sub_bus)
-{
-	u32 temp;
-
-	pciauto_lower_memspc += 1;
-	pciauto_lower_iospc += 1;
-
-	/* Configure bus number registers */
-	early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
-				PCI_SUBORDINATE_BUS, sub_bus);
-
-	/* Set upper limit of address range behind bridge. */
-	early_write_config_word(hose, top_bus, current_bus, pci_devfn,
-		PCI_MEMORY_LIMIT, pciauto_lower_memspc >> 16);
-	early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
-		PCI_IO_LIMIT, (pciauto_lower_iospc & 0x0000f000) >> 8);
-	early_write_config_word(hose, top_bus, current_bus, pci_devfn,
-		PCI_IO_LIMIT_UPPER16, pciauto_lower_iospc >> 16);
-
-	/* Align memory and I/O to 1MB and 4KB boundaries. */
-	pciauto_lower_memspc = (pciauto_lower_memspc + (0x100000 - 1))
-		& ~(0x100000 - 1);
-	pciauto_lower_iospc = (pciauto_lower_iospc + (0x1000 - 1))
-		& ~(0x1000 - 1);
-
-	/* Enable memory and I/O accesses, enable bus master */
-	early_read_config_dword(hose, top_bus, current_bus, pci_devfn,
-		PCI_COMMAND, &temp);
-	early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
-		PCI_COMMAND, temp | PCI_COMMAND_IO | PCI_COMMAND_MEMORY
-		| PCI_COMMAND_MASTER);
-}
-
-static void __init
-pciauto_prescan_setup_cardbus_bridge(struct pci_channel *hose,
-                            int top_bus,
-                            int current_bus,
-                            int pci_devfn,
-                            int sub_bus)
-{
-       /* Configure bus number registers */
-       early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
-                               PCI_PRIMARY_BUS, current_bus);
-       early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
-                               PCI_SECONDARY_BUS, sub_bus + 1);
-       early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
-                               PCI_SUBORDINATE_BUS, 0xff);
-
-       /* Align memory and I/O to 4KB and 4 byte boundaries. */
-       pciauto_lower_memspc = (pciauto_lower_memspc + (0x1000 - 1))
-               & ~(0x1000 - 1);
-       pciauto_lower_iospc = (pciauto_lower_iospc + (0x4 - 1))
-               & ~(0x4 - 1);
-
-       early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
-               PCI_CB_MEMORY_BASE_0, pciauto_lower_memspc);
-       early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
-               PCI_CB_IO_BASE_0, pciauto_lower_iospc);  
-}
-
-static void __init
-pciauto_postscan_setup_cardbus_bridge(struct pci_channel *hose,
-                             int top_bus,
-                             int current_bus,
-                             int pci_devfn,
-                             int sub_bus)
-{
-       u32 temp;
-
-       /* 
-        * [jsun] we always bump up baselines a little, so that if there 
-        * nothing behind P2P bridge, we don't wind up overlapping IO/MEM 
-        * spaces.
-        */
-       pciauto_lower_memspc += 1;
-       pciauto_lower_iospc += 1;
-
-       /*
-        * Configure subordinate bus number.  The PCI subsystem
-        * bus scan will renumber buses (reserving three additional
-        * for this PCI<->CardBus bridge for the case where a CardBus
-        * adapter contains a P2P or CB2CB bridge.
-        */
-
-       early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
-                               PCI_SUBORDINATE_BUS, sub_bus);
-
-       /*
-        * Reserve an additional 4MB for mem space and 16KB for
-        * I/O space.  This should cover any additional space
-        * requirement of unusual CardBus devices with 
-        * additional bridges that can consume more address space.
-        * 
-        * Although pcmcia-cs currently will reprogram bridge
-        * windows, the goal is to add an option to leave them
-        * alone and use the bridge window ranges as the regions
-        * that are searched for free resources upon hot-insertion
-        * of a device.  This will allow a PCI<->CardBus bridge
-        * configured by this routine to happily live behind a
-        * P2P bridge in a system.
-        */
-
-       /* Align memory and I/O to 4KB and 4 byte boundaries. */
-       pciauto_lower_memspc = (pciauto_lower_memspc + (0x1000 - 1))
-               & ~(0x1000 - 1);
-       pciauto_lower_iospc = (pciauto_lower_iospc + (0x4 - 1))
-               & ~(0x4 - 1);
-       /* Set up memory and I/O filter limits, assume 32-bit I/O space */
-       early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
-               PCI_CB_MEMORY_LIMIT_0, pciauto_lower_memspc - 1); 
-       early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
-               PCI_CB_IO_LIMIT_0, pciauto_lower_iospc - 1);
-       
-       /* Enable memory and I/O accesses, enable bus master */
-       early_read_config_dword(hose, top_bus, current_bus, pci_devfn,
-               PCI_COMMAND, &temp);
-       early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
-               PCI_COMMAND, temp | PCI_COMMAND_IO | PCI_COMMAND_MEMORY
-               | PCI_COMMAND_MASTER);
-}
-
-#define      PCIAUTO_IDE_MODE_MASK           0x05
-
-static int __init
-pciauto_bus_scan(struct pci_channel *hose, int top_bus, int current_bus)
-{
-	int sub_bus;
-	u32 pci_devfn, pci_class, cmdstat, found_multi=0;
-	unsigned short vid, did;
-	unsigned char header_type;
-	int devfn_start = 0;
-	int devfn_stop = 0xff;
-
-	sub_bus = current_bus;
-	
-	if (hose->first_devfn)
-		devfn_start = hose->first_devfn;
-	if (hose->last_devfn)
-		devfn_stop = hose->last_devfn;
-	
-	for (pci_devfn=devfn_start; pci_devfn<devfn_stop; pci_devfn++) {
-
-		if (PCI_FUNC(pci_devfn) && !found_multi)
-			continue;
-
-		early_read_config_word(hose, top_bus, current_bus, pci_devfn,
-				       PCI_VENDOR_ID, &vid);
-
-		if (vid == 0xffff) continue;
-
-		early_read_config_byte(hose, top_bus, current_bus, pci_devfn,
-				       PCI_HEADER_TYPE, &header_type);
-
-		if (!PCI_FUNC(pci_devfn))
-			found_multi = header_type & 0x80;
-
-		early_read_config_word(hose, top_bus, current_bus, pci_devfn,
-				       PCI_DEVICE_ID, &did);
-
-		early_read_config_dword(hose, top_bus, current_bus, pci_devfn,
-					PCI_CLASS_REVISION, &pci_class);
-
-		DBG("%.2x:%.2x.%x Class %.4x: %.4x:%.4x",
-			current_bus, PCI_SLOT(pci_devfn), PCI_FUNC(pci_devfn),
-			pci_class >> 16, vid, did);
-		if (pci_class & 0xff)
-			DBG(" (rev %.2x)", pci_class & 0xff);
-		DBG("\n");
-
-		if ((pci_class >> 16) == PCI_CLASS_BRIDGE_PCI) {
-			DBG("        Bridge: primary=%.2x, secondary=%.2x\n",
-				current_bus, sub_bus + 1);
-			pciauto_prescan_setup_bridge(hose, top_bus, current_bus,
-						     pci_devfn, sub_bus);
-			DBG("Scanning sub bus %.2x, I/O 0x%.8x, Mem 0x%.8x\n",
-				sub_bus + 1,
-				pciauto_lower_iospc, pciauto_lower_memspc);
-			sub_bus = pciauto_bus_scan(hose, top_bus, sub_bus+1);
-			DBG("Back to bus %.2x\n", current_bus);
-			pciauto_postscan_setup_bridge(hose, top_bus, current_bus,
-						      pci_devfn, sub_bus);
-			continue;
-                } else if ((pci_class >> 16) == PCI_CLASS_BRIDGE_CARDBUS) {
-                        DBG("  CARDBUS  Bridge: primary=%.2x, secondary=%.2x\n",
-                                current_bus, sub_bus + 1);
-                        DBG("PCI Autoconfig: Found CardBus bridge, device %d function %d\n", PCI_SLOT(pci_devfn), PCI_FUNC(pci_devfn));
-                        /* Place CardBus Socket/ExCA registers */
-                        pciauto_setup_bars(hose, top_bus, current_bus, pci_devfn);
- 
-                        pciauto_prescan_setup_cardbus_bridge(hose, top_bus, 
-                                        current_bus, pci_devfn, sub_bus);
- 
-                        DBG("Scanning sub bus %.2x, I/O 0x%.8x, Mem 0x%.8x\n",
-                                sub_bus + 1,
-                                pciauto_lower_iospc, pciauto_lower_memspc);
-                        sub_bus = pciauto_bus_scan(hose, top_bus, sub_bus+1);
-                        DBG("Back to bus %.2x, sub_bus is %x\n", current_bus, sub_bus);
-                        pciauto_postscan_setup_cardbus_bridge(hose, top_bus, 
-                                        current_bus, pci_devfn, sub_bus);
-                        continue;
-		} else if ((pci_class >> 16) == PCI_CLASS_STORAGE_IDE) {
-
-			unsigned char prg_iface;
-
-			early_read_config_byte(hose, top_bus, current_bus,
-				pci_devfn, PCI_CLASS_PROG, &prg_iface);
-			if (!(prg_iface & PCIAUTO_IDE_MODE_MASK)) {
-				DBG("Skipping legacy mode IDE controller\n");
-				continue;
-			}
-		}
-
- 		/*
-		 * Found a peripheral, enable some standard
-		 * settings
-		 */
-		early_read_config_dword(hose, top_bus, current_bus, pci_devfn,
-					PCI_COMMAND, &cmdstat);
-		early_write_config_dword(hose, top_bus, current_bus, pci_devfn,
-					 PCI_COMMAND, cmdstat | PCI_COMMAND_IO |
-					 PCI_COMMAND_MEMORY |
-					 PCI_COMMAND_MASTER);
-		early_write_config_byte(hose, top_bus, current_bus, pci_devfn,
-					PCI_LATENCY_TIMER, 0x80);
-
-		/* Allocate PCI I/O and/or memory space */
-		pciauto_setup_bars(hose, top_bus, current_bus, pci_devfn);
-	}
-	return sub_bus;
-}
-
-int __init
-pciauto_assign_resources(int busno, struct pci_channel *hose)
-{
-	/* setup resource limits */
-	io_resource_inuse = hose->io_resource;
-	mem_resource_inuse = hose->mem_resource;
-
-	pciauto_lower_iospc = io_resource_inuse->start;
-	pciauto_upper_iospc = io_resource_inuse->end + 1;
-	pciauto_lower_memspc = mem_resource_inuse->start;
-	pciauto_upper_memspc = mem_resource_inuse->end + 1;
-	DBG("Autoconfig PCI channel 0x%p\n", hose);
-	DBG("Scanning bus %.2x, I/O 0x%.8x:0x%.8x, Mem 0x%.8x:0x%.8x\n",
-		busno, pciauto_lower_iospc, pciauto_upper_iospc, 
-		pciauto_lower_memspc, pciauto_upper_memspc);
-
-	return pciauto_bus_scan(hose, busno, busno);
-}
diff -puN -L arch/sh/kernel/pcibios.c arch/sh/kernel/pcibios.c~linus /dev/null
--- 25/arch/sh/kernel/pcibios.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,97 +0,0 @@
-/*
- * $Id: pcibios.c,v 1.1 2001/08/24 12:38:19 dwmw2 Exp $
- *
- * arch/sh/kernel/pcibios.c
- *
- * This is GPL'd.
- *
- * Provided here are generic versions of:
- *	pcibios_align_resource()
- *	pcibios_enable_device()
- *	pcibios_set_master()
- *	pcibios_update_irq()
- *
- * These functions are collected here to reduce duplication of common
- * code amongst the many platform-specific PCI support code files.
- *
- * Platform-specific files are expected to provide:
- *	pcibios_fixup_bus()
- *	pcibios_init()
- *	pcibios_setup()
- */
-
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/init.h>
-
-/*
- * We need to avoid collisions with `mirrored' VGA ports
- * and other strange ISA hardware, so we always want the
- * addresses to be allocated in the 0x000-0x0ff region
- * modulo 0x400.
- */
-void pcibios_align_resource(void *data, struct resource *res,
-			    unsigned long size, unsigned long align)
-{
-	if (res->flags & IORESOURCE_IO) {
-		unsigned long start = res->start;
-
-		if (start & 0x300) {
-			start = (start + 0x3ff) & ~0x3ff;
-			res->start = start;
-		}
-	}
-}
-
-int pcibios_enable_device(struct pci_dev *dev)
-{
-	u16 cmd, old_cmd;
-	int idx;
-	struct resource *r;
-
-	pci_read_config_word(dev, PCI_COMMAND, &cmd);
-	old_cmd = cmd;
-	for(idx=0; idx<6; idx++) {
-		r = &dev->resource[idx];
-		if (!r->start && r->end) {
-			printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", pci_name(dev));
-			return -EINVAL;
-		}
-		if (r->flags & IORESOURCE_IO)
-			cmd |= PCI_COMMAND_IO;
-		if (r->flags & IORESOURCE_MEM)
-			cmd |= PCI_COMMAND_MEMORY;
-	}
-	if (dev->resource[PCI_ROM_RESOURCE].start)
-		cmd |= PCI_COMMAND_MEMORY;
-	if (cmd != old_cmd) {
-		printk(KERN_INFO "PCI: Enabling device %s (%04x -> %04x)\n", dev->name, old_cmd, cmd);
-		pci_write_config_word(dev, PCI_COMMAND, cmd);
-	}
-	return 0;
-}
-
-/*
- *  If we set up a device for bus mastering, we need to check and set
- *  the latency timer as it may not be properly set.
- */
-unsigned int pcibios_max_latency = 255;
-
-void pcibios_set_master(struct pci_dev *dev)
-{
-	u8 lat;
-	pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
-	if (lat < 16)
-		lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency;
-	else if (lat > pcibios_max_latency)
-		lat = pcibios_max_latency;
-	else
-		return;
-	printk(KERN_INFO "PCI: Setting latency timer of device %s to %d\n", dev->name, lat);
-	pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
-}
-
-void __init pcibios_update_irq(struct pci_dev *dev, int irq)
-{
-	pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
-}
diff -puN -L arch/sh/kernel/pci.c arch/sh/kernel/pci.c~linus /dev/null
--- 25/arch/sh/kernel/pci.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,153 +0,0 @@
-/* arch/sh/kernel/pci.c
- * $Id: pci.c,v 1.4 2003/05/25 01:29:24 lethal Exp $
- *
- * Copyright (c) 2002 M. R. Brown  <mrbrown@linux-sh.org>
- * 
- * 
- * These functions are collected here to reduce duplication of common
- * code amongst the many platform-specific PCI support code files.
- * 
- * These routines require the following board-specific routines:
- * void pcibios_fixup();
- * void pcibios_fixup_irqs();
- *
- * See include/asm-sh/pci.h for more information.
- */
-
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/init.h>
-
-static int __init pcibios_init(void)
-{
-	struct pci_channel *p;
-	struct pci_bus *bus;
-	int busno;
-
-#ifdef CONFIG_PCI_AUTO
-	/* assign resources */
-	busno=0;
-	for (p = board_pci_channels; p->pci_ops != NULL; p++) {
-		busno = pciauto_assign_resources(busno, p) + 1;
-	}
-#endif
-
-	/* scan the buses */
-	busno = 0;
-	for (p= board_pci_channels; p->pci_ops != NULL; p++) {
-		bus = pci_scan_bus(busno, p->pci_ops, p);
-		busno = bus->subordinate+1;
-	}
-
-	/* board-specific fixups */
-	pcibios_fixup();
-	pcibios_fixup_irqs();
-
-	return 0;
-}
-
-subsys_initcall(pcibios_init);
-
-void
-pcibios_update_resource(struct pci_dev *dev, struct resource *root,
-			struct resource *res, int resource)
-{
-	u32 new, check;
-	int reg;
-
-	new = res->start | (res->flags & PCI_REGION_FLAG_MASK);
-	if (resource < 6) {
-		reg = PCI_BASE_ADDRESS_0 + 4*resource;
-	} else if (resource == PCI_ROM_RESOURCE) {
-		res->flags |= PCI_ROM_ADDRESS_ENABLE;
-		new |= PCI_ROM_ADDRESS_ENABLE;
-		reg = dev->rom_base_reg;
-	} else {
-		/* Somebody might have asked allocation of a non-standard resource */
-		return;
-	}
-	
-	pci_write_config_dword(dev, reg, new);
-	pci_read_config_dword(dev, reg, &check);
-	if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) {
-		printk(KERN_ERR "PCI: Error while updating region "
-		       "%s/%d (%08x != %08x)\n", pci_name(dev), resource,
-		       new, check);
-	}
-}
-
-void pcibios_align_resource(void *data, struct resource *res,
-			    unsigned long size, unsigned long align)
-			    __attribute__ ((weak));
-
-/*
- * We need to avoid collisions with `mirrored' VGA ports
- * and other strange ISA hardware, so we always want the
- * addresses to be allocated in the 0x000-0x0ff region
- * modulo 0x400.
- */
-void pcibios_align_resource(void *data, struct resource *res,
-			    unsigned long size, unsigned long align)
-{
-	if (res->flags & IORESOURCE_IO) {
-		unsigned long start = res->start;
-
-		if (start & 0x300) {
-			start = (start + 0x3ff) & ~0x3ff;
-			res->start = start;
-		}
-	}
-}
-
-int pcibios_enable_device(struct pci_dev *dev, int mask)
-{
-	u16 cmd, old_cmd;
-	int idx;
-	struct resource *r;
-
-	pci_read_config_word(dev, PCI_COMMAND, &cmd);
-	old_cmd = cmd;
-	for(idx=0; idx<6; idx++) {
-		r = &dev->resource[idx];
-		if (!r->start && r->end) {
-			printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", pci_name(dev));
-			return -EINVAL;
-		}
-		if (r->flags & IORESOURCE_IO)
-			cmd |= PCI_COMMAND_IO;
-		if (r->flags & IORESOURCE_MEM)
-			cmd |= PCI_COMMAND_MEMORY;
-	}
-	if (dev->resource[PCI_ROM_RESOURCE].start)
-		cmd |= PCI_COMMAND_MEMORY;
-	if (cmd != old_cmd) {
-		printk(KERN_INFO "PCI: Enabling device %s (%04x -> %04x)\n", dev->dev.name, old_cmd, cmd);
-		pci_write_config_word(dev, PCI_COMMAND, cmd);
-	}
-	return 0;
-}
-
-/*
- *  If we set up a device for bus mastering, we need to check and set
- *  the latency timer as it may not be properly set.
- */
-unsigned int pcibios_max_latency = 255;
-
-void pcibios_set_master(struct pci_dev *dev)
-{
-	u8 lat;
-	pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
-	if (lat < 16)
-		lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency;
-	else if (lat > pcibios_max_latency)
-		lat = pcibios_max_latency;
-	else
-		return;
-	printk(KERN_INFO "PCI: Setting latency timer of device %s to %d\n", dev->dev.name, lat);
-	pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
-}
-
-void __init pcibios_update_irq(struct pci_dev *dev, int irq)
-{
-	pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
-}
diff -puN -L arch/sh/kernel/pci-dma.c arch/sh/kernel/pci-dma.c~linus /dev/null
--- 25/arch/sh/kernel/pci-dma.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,42 +0,0 @@
-/* 
- * Copyright (C) 2001 David J. Mckay (david.mckay@st.com)
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.                            
- *
- * Dynamic DMA mapping support.
- */
-
-#include <linux/types.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/pci.h>
-#include <asm/io.h>
-#include <asm/addrspace.h>
-
-
-void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
-			   dma_addr_t * dma_handle)
-{
-	void *ret;
-	int gfp = GFP_ATOMIC;
-
-	ret = (void *) __get_free_pages(gfp, get_order(size));
-
-	if (ret != NULL) {
-	        /* Is it necessary to do the memset? */
-		memset(ret, 0, size);
-		*dma_handle = virt_to_phys(ret);
-	}
-	/* We must flush the cache before we pass it on to the device */
-	dma_cache_wback_inv(ret, size);
-	return  P2SEGADDR(ret);
-}
-
-void pci_free_consistent(struct pci_dev *hwdev, size_t size,
-			 void *vaddr, dma_addr_t dma_handle)
-{
-        unsigned long p1addr=P1SEGADDR((unsigned long)vaddr);
-
-	free_pages(p1addr, get_order(size));
-}
diff -puN arch/sh/kernel/process.c~linus arch/sh/kernel/process.c
--- 25/arch/sh/kernel/process.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/kernel/process.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: process.c,v 1.17 2003/05/27 21:37:11 lethal Exp $
+/* $Id: process.c,v 1.24 2003/11/28 23:05:43 kkojima Exp $
  *
  *  linux/arch/sh/kernel/process.c
  *
@@ -19,6 +19,7 @@
 #include <linux/a.out.h>
 #include <linux/ptrace.h>
 #include <linux/platform.h>
+#include <linux/kallsyms.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -27,6 +28,8 @@
 
 static int hlt_counter=0;
 
+int ubc_usercnt = 0;
+
 #define HARD_IDLE_TIMEOUT (HZ / 3)
 
 void disable_hlt(void)
@@ -47,19 +50,9 @@ void default_idle(void)
 {
 	/* endless idle loop with no priority at all */
 	while (1) {
-		if (hlt_counter) {
-			while (1)
-				if (need_resched())
-					break;
-		} else {
-			local_irq_disable();
-			while (!need_resched()) {
-				local_irq_enable();
-				asm volatile("sleep" : : : "memory");
-				local_irq_disable();
-			}
-			local_irq_enable();
-		}
+		while (!need_resched())
+			cpu_relax();
+
 		schedule();
 	}
 }
@@ -81,7 +74,7 @@ EXPORT_SYMBOL(machine_restart);
 void machine_halt(void)
 {
 	while (1)
-		asm volatile("sleep" : : : "memory");
+		cpu_relax();
 }
 
 EXPORT_SYMBOL(machine_halt);
@@ -95,8 +88,17 @@ EXPORT_SYMBOL(machine_power_off);
 void show_regs(struct pt_regs * regs)
 {
 	printk("\n");
-	printk("PC  : %08lx SP  : %08lx SR  : %08lx TEA : %08x    %s\n",
-	       regs->pc, regs->regs[15], regs->sr, ctrl_inl(MMU_TEA), print_tainted());
+	printk("Pid : %d, Comm: %20s\n", current->pid, current->comm);
+	print_symbol("PC is at %s\n", regs->pc);
+	printk("PC  : %08lx SP  : %08lx SR  : %08lx ",
+	       regs->pc, regs->regs[15], regs->sr);
+#ifdef CONFIG_MMU
+	printk("TEA : %08x    ", ctrl_inl(MMU_TEA));
+#else
+	printk("                  ");
+#endif
+	printk("%s\n", print_tainted());
+
 	printk("R0  : %08lx R1  : %08lx R2  : %08lx R3  : %08lx\n",
 	       regs->regs[0],regs->regs[1],
 	       regs->regs[2],regs->regs[3]);
@@ -162,7 +164,10 @@ int kernel_thread(int (*fn)(void *), voi
  */
 void exit_thread(void)
 {
-	/* Nothing to do. */
+	if (current->thread.ubc_pc) {
+		current->thread.ubc_pc = 0;
+		ubc_usercnt -= 1;
+	}
 }
 
 void flush_thread(void)
@@ -207,7 +212,11 @@ int dump_task_regs(struct task_struct *t
 	struct pt_regs ptregs;
 	
 	ptregs = *(struct pt_regs *)
-		((unsigned long)tsk->thread_info+THREAD_SIZE - sizeof(ptregs));
+		((unsigned long)tsk->thread_info+THREAD_SIZE - sizeof(ptregs)
+#ifdef CONFIG_SH_DSP
+		 - sizeof(struct pt_dspregs)
+#endif
+		 - sizeof(unsigned long));
 	elf_core_copy_regs(regs, &ptregs);
 
 	return 1;
@@ -237,7 +246,12 @@ int copy_thread(int nr, unsigned long cl
 {
 	struct pt_regs *childregs;
 
-	childregs = ((struct pt_regs *)(THREAD_SIZE + (unsigned long) p->thread_info)) - 1;
+	childregs = ((struct pt_regs *)
+		(THREAD_SIZE + (unsigned long) p->thread_info)
+#ifdef CONFIG_SH_DSP
+		- sizeof(struct pt_dspregs)
+#endif
+		- sizeof(unsigned long)) - 1;
 	*childregs = *regs;
 
 	if (user_mode(regs)) {
@@ -255,6 +269,8 @@ int copy_thread(int nr, unsigned long cl
 	p->thread.sp = (unsigned long) childregs;
 	p->thread.pc = (unsigned long) ret_from_fork;
 
+	p->thread.ubc_pc = 0;
+
 #if defined(CONFIG_CPU_SH4)
 	{
 		struct task_struct *tsk = current;
@@ -288,6 +304,27 @@ void dump_thread(struct pt_regs * regs, 
 	dump->u_fpvalid = dump_fpu(regs, &dump->fpu);
 }
 
+/* Tracing by user break controller.  */
+static void
+ubc_set_tracing(int asid, unsigned long pc)
+{
+	ctrl_outl(pc, UBC_BARA);
+
+	/* We don't have any ASID settings for the SH-2! */
+	if (cpu_data->type != CPU_SH7604)
+		ctrl_outb(asid, UBC_BASRA);
+
+	ctrl_outl(0, UBC_BAMRA);
+
+	if (cpu_data->type == CPU_SH7729) {
+		ctrl_outw(BBR_INST | BBR_READ | BBR_CPU, UBC_BBRA);
+		ctrl_outl(BRCR_PCBA | BRCR_PCTE, UBC_BRCR);
+	} else {
+		ctrl_outw(BBR_INST | BBR_READ, UBC_BBRA);
+		ctrl_outw(BRCR_PCBA, UBC_BRCR);
+	}
+}
+
 /*
  *	switch_to(x,y) should switch tasks from x to y.
  *
@@ -305,6 +342,19 @@ struct task_struct *__switch_to(struct t
 		     : /* no output */
 		     : "r" (next->thread_info));
 
+#ifdef CONFIG_MMU
+	/* If no tasks are using the UBC, we're done */
+	if (ubc_usercnt == 0)
+		/* If no tasks are using the UBC, we're done */;
+	else if (next->thread.ubc_pc && next->mm) {
+		ubc_set_tracing(next->mm->context & MMU_CONTEXT_ASID_MASK,
+				next->thread.ubc_pc);
+	} else {
+		ctrl_outw(0, UBC_BBRA);
+		ctrl_outw(0, UBC_BBRB);
+	}
+#endif
+
 	return prev;
 }
 
@@ -328,7 +378,7 @@ asmlinkage int sys_clone(unsigned long c
 	if (!newsp)
 		newsp = regs.regs[15];
 	return do_fork(clone_flags & ~CLONE_IDLETASK, newsp, &regs, 0,
-			(int *)parent_tidptr, (int *)child_tidptr);
+			(int __user *)parent_tidptr, (int __user *)child_tidptr);
 }
 
 /*
@@ -359,12 +409,15 @@ asmlinkage int sys_execve(char *ufilenam
 	int error;
 	char *filename;
 
-	filename = getname(ufilename);
+	filename = getname((char __user *)ufilename);
 	error = PTR_ERR(filename);
 	if (IS_ERR(filename))
 		goto out;
 
-	error = do_execve(filename, uargv, uenvp, &regs);
+	error = do_execve(filename,
+			  (char __user * __user *)uargv,
+			  (char __user * __user *)uenvp,
+			  &regs);
 	if (error == 0)
 		current->ptrace &= ~PT_DTRACE;
 	putname(filename);
@@ -406,6 +459,8 @@ asmlinkage void break_point_trap(unsigne
 	/* Clear tracing.  */
 	ctrl_outw(0, UBC_BBRA);
 	ctrl_outw(0, UBC_BBRB);
+	current->thread.ubc_pc = 0;
+	ubc_usercnt -= 1;
 
 	force_sig(SIGTRAP, current);
 }
diff -puN arch/sh/kernel/ptrace.c~linus arch/sh/kernel/ptrace.c
--- 25/arch/sh/kernel/ptrace.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/kernel/ptrace.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: ptrace.c,v 1.9 2003/05/06 23:28:47 lethal Exp $
+/* $Id: ptrace.c,v 1.14 2003/11/28 23:05:43 kkojima Exp $
  *
  * linux/arch/sh/kernel/ptrace.c
  *
@@ -41,7 +41,12 @@ static inline int get_stack_long(struct 
 {
 	unsigned char *stack;
 
-	stack = (unsigned char *)task->thread_info + THREAD_SIZE - sizeof(struct pt_regs);
+	stack = (unsigned char *)
+		task->thread_info + THREAD_SIZE	- sizeof(struct pt_regs)
+#ifdef CONFIG_SH_DSP
+		- sizeof(struct pt_dspregs)
+#endif
+		- sizeof(unsigned long);
 	stack += offset;
 	return (*((int *)stack));
 }
@@ -54,97 +59,17 @@ static inline int put_stack_long(struct 
 {
 	unsigned char *stack;
 
-	stack = (unsigned char *)task->thread_info + THREAD_SIZE - sizeof(struct pt_regs);
+	stack = (unsigned char *)
+		task->thread_info + THREAD_SIZE - sizeof(struct pt_regs)
+#ifdef CONFIG_SH_DSP
+		- sizeof(struct pt_dspregs)
+#endif
+		- sizeof(unsigned long);
 	stack += offset;
 	*(unsigned long *) stack = data;
 	return 0;
 }
 
-static void
-compute_next_pc(struct pt_regs *regs, unsigned short inst,
-		unsigned long *pc1, unsigned long *pc2)
-{
-	int nib[4]
-		= { (inst >> 12) & 0xf,
-		    (inst >> 8) & 0xf,
-		    (inst >> 4) & 0xf,
-		    inst & 0xf};
-
-	/* bra & bsr */
-	if (nib[0] == 0xa || nib[0] == 0xb) {
-		*pc1 = regs->pc + 4 + ((short) ((inst & 0xfff) << 4) >> 3);
-		*pc2 = (unsigned long) -1;
-		return;
-	}
-
-	/* bt & bf */
-	if (nib[0] == 0x8 && (nib[1] == 0x9 || nib[1] == 0xb)) {
-		*pc1 = regs->pc + 4 + ((char) (inst & 0xff) << 1);
-		*pc2 = regs->pc + 2;
-		return;
-	}
-
-	/* bt/s & bf/s */
-	if (nib[0] == 0x8 && (nib[1] == 0xd || nib[1] == 0xf)) {
-		*pc1 = regs->pc + 4 + ((char) (inst & 0xff) << 1);
-		*pc2 = regs->pc + 4;
-		return;
-	}
-
-	/* jmp & jsr */
-	if (nib[0] == 0x4 && nib[3] == 0xb
-	    && (nib[2] == 0x0 || nib[2] == 0x2)) {
-		*pc1 = regs->regs[nib[1]];
-		*pc2 = (unsigned long) -1;
-		return;
-	}
-
-	/* braf & bsrf */
-	if (nib[0] == 0x0 && nib[3] == 0x3
-	    && (nib[2] == 0x0 || nib[2] == 0x2)) {
-		*pc1 = regs->pc + 4 + regs->regs[nib[1]];
-		*pc2 = (unsigned long) -1;
-		return;
-	}
-
-	if (inst == 0x000b) {
-		*pc1 = regs->pr;
-		*pc2 = (unsigned long) -1;
-		return;
-	}
-
-	*pc1 = regs->pc + 2;
-	*pc2 = (unsigned long) -1;
-	return;
-}
-
-/* Tracing by user break controller.  */
-static void
-ubc_set_tracing(int asid, unsigned long nextpc1, unsigned nextpc2)
-{
-	ctrl_outl(nextpc1, UBC_BARA);
-	ctrl_outb(asid, UBC_BASRA);
-	ctrl_outl(0, UBC_BAMRA);
-	if(UBC_TYPE_SH7729)
-		ctrl_outw(BBR_INST | BBR_READ | BBR_CPU, UBC_BBRA);
-	else
-		ctrl_outw(BBR_INST | BBR_READ, UBC_BBRA);
-
-	if (nextpc2 != (unsigned long) -1) {
-		ctrl_outl(nextpc2, UBC_BARB);
-		ctrl_outb(asid, UBC_BASRB);
-		ctrl_outl(0, UBC_BAMRB);
-		if(UBC_TYPE_SH7729)
-			ctrl_outw(BBR_INST | BBR_READ | BBR_CPU, UBC_BBRB);
-		else
-			ctrl_outw(BBR_INST | BBR_READ, UBC_BBRB);
-	}
-	if(UBC_TYPE_SH7729)
-		ctrl_outl(BRCR_PCTE, UBC_BRCR);
-	else
-		ctrl_outw(0, UBC_BRCR);
-}
-
 /*
  * Called by kernel/ptrace.c when detaching..
  *
@@ -300,11 +225,8 @@ asmlinkage int sys_ptrace(long request, 
 	}
 
 	case PTRACE_SINGLESTEP: {  /* set the trap flag. */
-		long tmp, pc;
+		long pc;
 		struct pt_regs *dummy = NULL;
-		struct pt_regs *regs;
-		unsigned long nextpc1, nextpc2;
-		unsigned short insn;
 
 		ret = -EIO;
 		if ((unsigned long) data > _NSIG)
@@ -315,34 +237,12 @@ asmlinkage int sys_ptrace(long request, 
 			child->ptrace |= PT_DTRACE;
 		}
 
-		/* Compute next pc.  */
 		pc = get_stack_long(child, (long)&dummy->pc);
-		regs = (struct pt_regs *)(THREAD_SIZE + (unsigned long)child->thread_info) - 1;
-		if (access_process_vm(child, pc&~3, &tmp, sizeof(tmp), 0) != sizeof(tmp))
-			break;
- 
-#ifdef  __LITTLE_ENDIAN__
-		if (pc & 3)
-			insn = tmp >> 16;
-		else
-			insn = tmp & 0xffff;
-#else
-		if (pc & 3)
-			insn = tmp & 0xffff;
-		else
-			insn = tmp >> 16;
-#endif
-		compute_next_pc(regs, insn, &nextpc1, &nextpc2);
-
-		if (nextpc1 & 0x80000000)
-			break;
-		if (nextpc2 != (unsigned long) -1 && (nextpc2 & 0x80000000))
-			break;
 
-#ifdef CONFIG_MMU
-		ubc_set_tracing(child->mm->context & MMU_CONTEXT_ASID_MASK,
-				nextpc1, nextpc2);
-#endif
+		/* Next scheduling will set up UBC */
+		if (child->thread.ubc_pc == 0)
+			ubc_usercnt += 1;
+		child->thread.ubc_pc = pc;
 
 		child->exit_code = data;
 		/* give it a chance to run. */
@@ -362,7 +262,36 @@ asmlinkage int sys_ptrace(long request, 
 			child->ptrace &= ~PT_TRACESYSGOOD;
 		ret = 0;
 		break;
+#ifdef CONFIG_SH_DSP
+	case PTRACE_GETDSPREGS: {
+		unsigned long dp;
+
+		ret = -EIO;
+		dp = ((unsigned long) child) + THREAD_SIZE -
+			 sizeof(struct pt_dspregs);
+		if (*((int *) (dp - 4)) == SR_FD) {
+			copy_to_user(addr, (void *) dp,
+				sizeof(struct pt_dspregs));
+			ret = 0;
+		}
+		break;
+	}
+
+	case PTRACE_SETDSPREGS: {
+		unsigned long dp;
+		int i;
 
+		ret = -EIO;
+		dp = ((unsigned long) child) + THREAD_SIZE -
+			 sizeof(struct pt_dspregs);
+		if (*((int *) (dp - 4)) == SR_FD) {
+			copy_from_user((void *) dp, addr,
+				sizeof(struct pt_dspregs));
+			ret = 0;
+		}
+		break;
+	}
+#endif
 	default:
 		ret = ptrace_request(child, request, addr, data);
 		break;
diff -puN -L arch/sh/kernel/rtc.c arch/sh/kernel/rtc.c~linus /dev/null
--- 25/arch/sh/kernel/rtc.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,124 +0,0 @@
-/*
- * linux/arch/sh/kernel/rtc.c -- SH3 / SH4 on-chip RTC support
- *
- *  Copyright (C) 2000  Philipp Rumpf <prumpf@tux.org>
- *  Copyright (C) 1999  Tetsuya Okada & Niibe Yutaka
- */
-
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/time.h>
-#include <linux/bcd.h>
-
-#include <asm/io.h>
-#include <asm/rtc.h>
-
-void sh_rtc_gettimeofday(struct timeval *tv)
-{
-	unsigned int sec128, sec, min, hr, wk, day, mon, yr, yr100;
-
- again:
-	do {
-		ctrl_outb(0, RCR1);  /* Clear CF-bit */
-		sec128 = ctrl_inb(R64CNT);
-		sec = ctrl_inb(RSECCNT);
-		min = ctrl_inb(RMINCNT);
-		hr  = ctrl_inb(RHRCNT);
-		wk  = ctrl_inb(RWKCNT);
-		day = ctrl_inb(RDAYCNT);
-		mon = ctrl_inb(RMONCNT);
-#if defined(__SH4__)
-		yr  = ctrl_inw(RYRCNT);
-		yr100 = (yr >> 8);
-		yr &= 0xff;
-#else
-		yr  = ctrl_inb(RYRCNT);
-		yr100 = (yr == 0x99) ? 0x19 : 0x20;
-#endif
-	} while ((ctrl_inb(RCR1) & RCR1_CF) != 0);
-
-#if RTC_BIT_INVERTED != 0
-	/* Work around to avoid reading incorrect value. */
-	if (sec128 == RTC_BIT_INVERTED) {
-		schedule_timeout(1);
-		goto again;
-	}
-#endif
-
-	BCD_TO_BIN(yr100);
-	BCD_TO_BIN(yr);
-	BCD_TO_BIN(mon);
-	BCD_TO_BIN(day);
-	BCD_TO_BIN(hr);
-	BCD_TO_BIN(min);
-	BCD_TO_BIN(sec);
-
-	if (yr > 99 || mon < 1 || mon > 12 || day > 31 || day < 1 ||
-	    hr > 23 || min > 59 || sec > 59) {
-		printk(KERN_ERR
-		       "SH RTC: invalid value, resetting to 1 Jan 2000\n");
-		ctrl_outb(RCR2_RESET, RCR2);  /* Reset & Stop */
-		ctrl_outb(0, RSECCNT);
-		ctrl_outb(0, RMINCNT);
-		ctrl_outb(0, RHRCNT);
-		ctrl_outb(6, RWKCNT);
-		ctrl_outb(1, RDAYCNT);
-		ctrl_outb(1, RMONCNT);
-#if defined(__SH4__)
-		ctrl_outw(0x2000, RYRCNT);
-#else
-		ctrl_outb(0, RYRCNT);
-#endif
-		ctrl_outb(RCR2_RTCEN|RCR2_START, RCR2);  /* Start */
-		goto again;
-	}
-
-#if RTC_BIT_INVERTED != 0
-	if ((sec128 & RTC_BIT_INVERTED))
-		sec--;
-#endif
-
-	tv->tv_sec = mktime(yr100 * 100 + yr, mon, day, hr, min, sec);
-	tv->tv_usec = (sec128 * 1000000) / 128;
-}
-
-int sh_rtc_settimeofday(const struct timeval *tv)
-{
-	unsigned long nowtime = tv->tv_sec;
-	int retval = 0;
-	int real_seconds, real_minutes, cmos_minutes;
-
-	ctrl_outb(RCR2_RESET, RCR2);  /* Reset pre-scaler & stop RTC */
-
-	cmos_minutes = ctrl_inb(RMINCNT);
-	BCD_TO_BIN(cmos_minutes);
-
-	/*
-	 * since we're only adjusting minutes and seconds,
-	 * don't interfere with hour overflow. This avoids
-	 * messing with unknown time zones but requires your
-	 * RTC not to be off by more than 15 minutes
-	 */
-	real_seconds = nowtime % 60;
-	real_minutes = nowtime / 60;
-	if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1)
-		real_minutes += 30;	/* correct for half hour time zone */
-	real_minutes %= 60;
-
-	if (abs(real_minutes - cmos_minutes) < 30) {
-		BIN_TO_BCD(real_seconds);
-		BIN_TO_BCD(real_minutes);
-		ctrl_outb(real_seconds, RSECCNT);
-		ctrl_outb(real_minutes, RMINCNT);
-	} else {
-		printk(KERN_WARNING
-		       "set_rtc_time: can't update from %d to %d\n",
-		       cmos_minutes, real_minutes);
-		retval = -1;
-	}
-
-	ctrl_outb(RCR2_RTCEN|RCR2_START, RCR2);  /* Start RTC */
-
-	return retval;
-}
diff -puN arch/sh/kernel/setup.c~linus arch/sh/kernel/setup.c
--- 25/arch/sh/kernel/setup.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/kernel/setup.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: setup.c,v 1.17 2003/05/20 01:51:37 lethal Exp $
+/* $Id: setup.c,v 1.30 2003/10/13 07:21:19 lethal Exp $
  *
  *  linux/arch/sh/kernel/setup.c
  *
@@ -10,38 +10,21 @@
  * This file handles the architecture-dependent parts of initialization
  */
 
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/stddef.h>
-#include <linux/unistd.h>
-#include <linux/ptrace.h>
-#include <linux/slab.h>
-#include <linux/user.h>
-#include <linux/a.out.h>
 #include <linux/tty.h>
 #include <linux/ioport.h>
-#include <linux/delay.h>
-#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/initrd.h>
 #include <linux/bootmem.h>
 #include <linux/console.h>
-#include <linux/ctype.h>
 #include <linux/seq_file.h>
-#include <linux/utsname.h>
 #include <linux/root_dev.h>
 #include <linux/utsname.h>
 #include <linux/cpu.h>
-#include <asm/processor.h>
-#include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/uaccess.h>
-#include <asm/system.h>
 #include <asm/io.h>
 #include <asm/io_generic.h>
-#include <asm/machvec.h>
+#include <asm/sections.h>
+#include <asm/irq.h>
 #ifdef CONFIG_SH_EARLY_PRINTK
 #include <asm/sh_bios.h>
 #endif
@@ -63,7 +46,6 @@ static int kgdb_parse_options(char *opti
 struct sh_cpuinfo boot_cpu_data = { CPU_SH_NONE, 0, 10000000, };
 struct screen_info screen_info;
 unsigned char aux_device_present = 0xaa;
-static int fpu_disabled __initdata = 0;
 
 #if defined(CONFIG_SH_UNKNOWN)
 struct sh_machine_vector sh_mv;
@@ -82,11 +64,9 @@ struct screen_info screen_info = {
         16                      /* orig-video-points */
 };
 
-extern void fpu_init(void);
 extern void platform_setup(void);
 extern char *get_system_type(void);
 extern int root_mountflags;
-extern int _text, _etext, _edata, _end;
 
 #define MV_NAME_SIZE 32
 
@@ -174,7 +154,7 @@ static void scif_sercon_write(struct con
 
 static int __init scif_sercon_setup(struct console *con, char *options)
 {
-	con->cflag = CREAD | HUPCL | CLOCAL | B115200 | CS8;
+	con->cflag = CREAD | HUPCL | CLOCAL | B57600 | CS8;
 
 	return 0;
 }
@@ -333,7 +313,7 @@ static inline void parse_cmdline (char *
 	*cmdline_p = command_line;
 }
 
-void __init setup_arch(char **cmdline_p)
+static int __init sh_mv_setup(char **cmdline_p)
 {
 #if defined(CONFIG_SH_UNKNOWN)
 	extern struct sh_machine_vector mv_unknown;
@@ -342,41 +322,11 @@ void __init setup_arch(char **cmdline_p)
 	char mv_name[MV_NAME_SIZE] = "";
 	unsigned long mv_io_base = 0;
 	int mv_mmio_enable = 0;
-	unsigned long bootmap_size;
-	unsigned long start_pfn, max_pfn, max_low_pfn;
-
-/* XXX: MRB-remove */
-#if 0
-	scif_sercon_init(115200);
-#endif
-#ifdef CONFIG_SH_EARLY_PRINTK
-	sh_console_init();
-#endif
-	
-	ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
-
-#ifdef CONFIG_BLK_DEV_RAM
-	rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
-	rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
-	rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
-#endif
-
-	if (!MOUNT_ROOT_RDONLY)
-		root_mountflags &= ~MS_RDONLY;
-	init_mm.start_code = (unsigned long)&_text;
-	init_mm.end_code = (unsigned long) &_etext;
-	init_mm.end_data = (unsigned long) &_edata;
-	init_mm.brk = (unsigned long) &_end;
-
-	code_resource.start = virt_to_bus(&_text);
-	code_resource.end = virt_to_bus(&_etext)-1;
-	data_resource.start = virt_to_bus(&_etext);
-	data_resource.end = virt_to_bus(&_edata)-1;
 
 	parse_cmdline(cmdline_p, mv_name, &mv, &mv_io_base, &mv_mmio_enable);
 
 #ifdef CONFIG_CMDLINE_BOOL
-	sprintf(*cmdline_p, CONFIG_CMDLINE);
+        sprintf(*cmdline_p, CONFIG_CMDLINE);
 #endif
 
 #ifdef CONFIG_SH_GENERIC
@@ -393,42 +343,75 @@ void __init setup_arch(char **cmdline_p)
 	sh_mv = mv_unknown;
 #endif
 
-#if defined(CONFIG_SH_UNKNOWN)
-	if (mv_io_base != 0) {
-		sh_mv.mv_inb = generic_inb;
-		sh_mv.mv_inw = generic_inw;
-		sh_mv.mv_inl = generic_inl;
-		sh_mv.mv_outb = generic_outb;
-		sh_mv.mv_outw = generic_outw;
-		sh_mv.mv_outl = generic_outl;
-
-		sh_mv.mv_inb_p = generic_inb_p;
-		sh_mv.mv_inw_p = generic_inw_p;
-		sh_mv.mv_inl_p = generic_inl_p;
-		sh_mv.mv_outb_p = generic_outb_p;
-		sh_mv.mv_outw_p = generic_outw_p;
-		sh_mv.mv_outl_p = generic_outl_p;
-
-		sh_mv.mv_insb = generic_insb;
-		sh_mv.mv_insw = generic_insw;
-		sh_mv.mv_insl = generic_insl;
-		sh_mv.mv_outsb = generic_outsb;
-		sh_mv.mv_outsw = generic_outsw;
-		sh_mv.mv_outsl = generic_outsl;
-
-		sh_mv.mv_isa_port2addr = generic_isa_port2addr;
-		generic_io_base = mv_io_base;
-	}
-	if (mv_mmio_enable != 0) {
-		sh_mv.mv_readb = generic_readb;
-		sh_mv.mv_readw = generic_readw;
-		sh_mv.mv_readl = generic_readl;
-		sh_mv.mv_writeb = generic_writeb;
-		sh_mv.mv_writew = generic_writew;
-		sh_mv.mv_writel = generic_writel;
-	}
+	/*
+	 * Manually walk the vec, fill in anything that the board hasn't yet
+	 * by hand, wrapping to the generic implementation.
+	 */
+#define mv_set(elem) do { \
+	if (!sh_mv.mv_##elem) \
+		sh_mv.mv_##elem = generic_##elem; \
+} while (0)
+
+	mv_set(inb);	mv_set(inw);	mv_set(inl);
+	mv_set(outb);	mv_set(outw);	mv_set(outl);
+
+	mv_set(inb_p);	mv_set(inw_p);	mv_set(inl_p);
+	mv_set(outb_p);	mv_set(outw_p);	mv_set(outl_p);
+
+	mv_set(insb);	mv_set(insw);	mv_set(insl);
+	mv_set(outsb);	mv_set(outsw);	mv_set(outsl);
+
+	mv_set(readb);	mv_set(readw);	mv_set(readl);
+	mv_set(writeb);	mv_set(writew);	mv_set(writel);
+
+	mv_set(ioremap);
+	mv_set(iounmap);
+
+	mv_set(isa_port2addr);
+	mv_set(irq_demux);
+
+#ifdef CONFIG_SH_UNKNOWN
+	__set_io_port_base(mv_io_base);
 #endif
 
+	return 0;
+}
+
+void __init setup_arch(char **cmdline_p)
+{
+	unsigned long bootmap_size;
+	unsigned long start_pfn, max_pfn, max_low_pfn;
+
+/* XXX: MRB-remove */
+#if 0
+	scif_sercon_init(57600);
+#endif
+#ifdef CONFIG_SH_EARLY_PRINTK
+	sh_console_init();
+#endif
+	
+	ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
+
+#ifdef CONFIG_BLK_DEV_RAM
+	rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
+	rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
+	rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
+#endif
+
+	if (!MOUNT_ROOT_RDONLY)
+		root_mountflags &= ~MS_RDONLY;
+	init_mm.start_code = (unsigned long) _text;
+	init_mm.end_code = (unsigned long) _etext;
+	init_mm.end_data = (unsigned long) _edata;
+	init_mm.brk = (unsigned long) _end;
+
+	code_resource.start = virt_to_bus(_text);
+	code_resource.end = virt_to_bus(_etext)-1;
+	data_resource.start = virt_to_bus(_etext);
+	data_resource.end = virt_to_bus(_edata)-1;
+
+	sh_mv_setup(cmdline_p);
+
 #define PFN_UP(x)	(((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
 #define PFN_DOWN(x)	((x) >> PAGE_SHIFT)
 #define PFN_PHYS(x)	((x) << PAGE_SHIFT)
@@ -459,7 +442,8 @@ void __init setup_arch(char **cmdline_p)
 	 * Partially used pages are not usable - thus
 	 * we are rounding upwards:
  	 */
-	start_pfn = PFN_UP(__pa(&_end));
+	start_pfn = PFN_UP(__pa(_end));
+
 	/*
 	 * Find a proper area for the bootmem bitmap. After this
 	 * bootstrap step all allocations (until the page allocator
@@ -524,40 +508,13 @@ void __init setup_arch(char **cmdline_p)
 	}
 #endif
 
-#ifdef CONFIG_VT
-#if defined(CONFIG_VGA_CONSOLE)
-	conswitchp = &vga_con;
-#elif defined(CONFIG_DUMMY_CONSOLE)
+#ifdef CONFIG_DUMMY_CONSOLE
 	conswitchp = &dummy_con;
 #endif
-#endif
 
 	/* Perform the machine specific initialisation */
 	platform_setup();
 
-#if defined(CONFIG_CPU_SH4)
-	/* FPU initialization */
-	clear_thread_flag(TIF_USEDFPU);
-	current->used_math = 0;
-#endif
-
-	/* Disable the FPU */
-	if (fpu_disabled) {
-		printk("FPU Disabled\n");
-		cpu_data->flags &= ~CPU_HAS_FPU;
-		release_fpu();
-	}
-
-#ifdef CONFIG_UBC_WAKEUP
-	/*
-	 * Some brain-damaged loaders decided it would be a good idea to put
-	 * the UBC to sleep. This causes some issues when it comes to things
-	 * like PTRACE_SINGLESTEP or doing hardware watchpoints in GDB.  So ..
-	 * we wake it up and hope that all is well.
-	 */
-	ubc_wakeup();
-#endif
-
 	paging_init();
 }
 
@@ -599,17 +556,20 @@ static int __init topology_init(void)
 subsys_initcall(topology_init);
 
 static const char *cpu_name[] = {
-	[CPU_SH7604]	"SH7604",
-	[CPU_SH7708]	"SH7708",
-	[CPU_SH7729]	"SH7729",
-	[CPU_SH7750]	"SH7750",
-	[CPU_SH7750S]	"SH7750S",
-	[CPU_SH7750R]	"SH7750R",
-	[CPU_SH7751]	"SH7751",
-	[CPU_SH7751R]	"SH7751R",
-	[CPU_ST40RA]	"ST40RA",
-	[CPU_ST40GX1]	"ST40GX1",
-	[CPU_SH_NONE]	"Unknown"
+	[CPU_SH7604]	= "SH7604",
+	[CPU_SH7708]	= "SH7708",
+	[CPU_SH7729]	= "SH7729",
+	[CPU_SH7750]	= "SH7750",
+	[CPU_SH7750S]	= "SH7750S",
+	[CPU_SH7750R]	= "SH7750R",
+	[CPU_SH7751]	= "SH7751",
+	[CPU_SH7751R]	= "SH7751R",
+	[CPU_SH7760]	= "SH7760",
+	[CPU_ST40RA]	= "ST40RA",
+	[CPU_ST40GX1]	= "ST40GX1",
+	[CPU_SH4_202]	= "SH4-202",
+	[CPU_SH4_501]	= "SH4-501",
+	[CPU_SH_NONE]	= "Unknown"
 };
 
 const char *get_cpu_subtype(void)
@@ -617,44 +577,73 @@ const char *get_cpu_subtype(void)
 	return cpu_name[boot_cpu_data.type];
 }
 
+#ifdef CONFIG_PROC_FS
+static const char *cpu_flags[] = {
+	"none", "fpu", "p2flush", "mmuassoc", "dsp",
+};
+
+static void show_cpuflags(struct seq_file *m)
+{
+	unsigned long i;
+
+	seq_printf(m, "cpu flags\t:");
+
+	if (!cpu_data->flags) {
+		seq_printf(m, " %s\n", cpu_flags[0]);
+		return;
+	}
+
+	for (i = 0; i < cpu_data->flags; i++)
+		if ((cpu_data->flags & (1 << i)))
+			seq_printf(m, " %s", cpu_flags[i]);
+	
+	seq_printf(m, "\n");
+}
+
+static void show_cacheinfo(struct seq_file *m, const char *type, struct cache_info info)
+{
+	unsigned int cache_size;
+
+	cache_size = info.ways * info.sets * info.linesz;
+
+	seq_printf(m, "%s size\t: %dKiB\n", type, cache_size >> 10);
+}
+
 /*
  *	Get CPU information for use by the procfs.
  */
-#ifdef CONFIG_PROC_FS
 static int show_cpuinfo(struct seq_file *m, void *v)
 {
-	unsigned int dcachesz, icachesz;
 	unsigned int cpu = smp_processor_id();
 
-	icachesz = boot_cpu_data.icache.ways *
-		   boot_cpu_data.icache.sets *
-		   boot_cpu_data.icache.linesz;
-
 	if (!cpu && cpu_online(cpu))
 		seq_printf(m, "machine\t\t: %s\n", get_system_type());
 
 	seq_printf(m, "processor\t: %d\n", cpu);
 	seq_printf(m, "cpu family\t: %s\n", system_utsname.machine);
 	seq_printf(m, "cpu type\t: %s\n", get_cpu_subtype());
-	seq_printf(m, "cache size\t: %dK-bytes", icachesz >> 10);
+
+	show_cpuflags(m);
+
+	seq_printf(m, "cache type\t: ");
 
 	/*
-	 * SH-2 and SH-3 have a combined cache, thus there's no real
-	 * I/D distinction ..  so don't inadvertently double
-	 * up the output.
+	 * Check for what type of cache we have, we support both the
+	 * unified cache on the SH-2 and SH-3, as well as the harvard
+	 * style cache on the SH-4.
 	 */
-	if (strcmp(system_utsname.machine, "sh2") ||
-	    strcmp(system_utsname.machine, "sh3")) {
-		dcachesz = boot_cpu_data.dcache.ways *
-			   boot_cpu_data.dcache.sets *
-			   boot_cpu_data.dcache.linesz;
-
-		seq_printf(m, "/%dK-bytes", dcachesz >> 10);
+	if (test_bit(SH_CACHE_COMBINED, &(boot_cpu_data.icache.flags))) {
+		seq_printf(m, "unified\n");
+		show_cacheinfo(m, "cache", boot_cpu_data.icache);
+	} else {
+		seq_printf(m, "split (harvard)\n");
+		show_cacheinfo(m, "icache", boot_cpu_data.icache);
+		show_cacheinfo(m, "dcache", boot_cpu_data.dcache);
 	}
 
-	seq_printf(m, "\nbogomips\t: %lu.%02lu\n",
-		     loops_per_jiffy/(500000/HZ),
-		     (loops_per_jiffy/(5000/HZ)) % 100);
+	seq_printf(m, "bogomips\t: %lu.%02lu\n",
+		     boot_cpu_data.loops_per_jiffy/(500000/HZ),
+		     (boot_cpu_data.loops_per_jiffy/(5000/HZ)) % 100);
 
 #define PRINT_CLOCK(name, value) \
 	seq_printf(m, name " clock\t: %d.%02dMHz\n", \
@@ -780,10 +769,3 @@ static int __init kgdb_parse_options(cha
 __setup("kgdb=", kgdb_parse_options);
 #endif /* CONFIG_SH_KGDB */
 
-static int __init fpu_setup(char *opts)
-{
-	fpu_disabled = 1;
-	return 0;
-}
-__setup("nofpu", fpu_setup);
-
diff -puN arch/sh/kernel/sh_bios.c~linus arch/sh/kernel/sh_bios.c
--- 25/arch/sh/kernel/sh_bios.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/kernel/sh_bios.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: sh_bios.c,v 1.5 2001/01/08 08:42:32 gniibe Exp $
+/* $Id: sh_bios.c,v 1.2 2003/05/04 19:29:53 lethal Exp $
  *
  *  linux/arch/sh/kernel/sh_bios.c
  *  C interface for trapping into the standard LinuxSH BIOS.
diff -puN arch/sh/kernel/sh_ksyms.c~linus arch/sh/kernel/sh_ksyms.c
--- 25/arch/sh/kernel/sh_ksyms.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/kernel/sh_ksyms.c	2004-01-19 22:17:21.000000000 -0800
@@ -25,6 +25,8 @@ extern void dump_thread(struct pt_regs *
 extern int dump_fpu(struct pt_regs *, elf_fpregset_t *);
 extern struct hw_interrupt_type no_irq_type;
 
+EXPORT_SYMBOL(sh_mv);
+
 /* platform dependent support */
 EXPORT_SYMBOL(dump_thread);
 EXPORT_SYMBOL(dump_fpu);
@@ -71,7 +73,9 @@ EXPORT_SYMBOL(screen_info);
 
 EXPORT_SYMBOL(boot_cpu_data);
 
+#ifdef CONFIG_MMU
 EXPORT_SYMBOL(get_vm_area);
+#endif
 
 /* semaphore exports */
 EXPORT_SYMBOL(__up);
diff -puN arch/sh/kernel/signal.c~linus arch/sh/kernel/signal.c
--- 25/arch/sh/kernel/signal.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/kernel/signal.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: signal.c,v 1.15 2003/05/06 23:28:47 lethal Exp $
+/* $Id: signal.c,v 1.19 2003/10/13 07:21:19 lethal Exp $
  *
  *  linux/arch/sh/kernel/signal.c
  *
@@ -93,8 +93,8 @@ sys_rt_sigsuspend(sigset_t *unewset, siz
 }
 
 asmlinkage int 
-sys_sigaction(int sig, const struct old_sigaction *act,
-	      struct old_sigaction *oact)
+sys_sigaction(int sig, const struct old_sigaction __user *act,
+	      struct old_sigaction __user *oact)
 {
 	struct k_sigaction new_ka, old_ka;
 	int ret;
@@ -125,7 +125,7 @@ sys_sigaction(int sig, const struct old_
 }
 
 asmlinkage int
-sys_sigaltstack(const stack_t *uss, stack_t *uoss,
+sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
 		unsigned long r6, unsigned long r7,
 		struct pt_regs regs)
 {
@@ -137,24 +137,26 @@ sys_sigaltstack(const stack_t *uss, stac
  * Do a signal return; undo the signal stack.
  */
 
+#define MOVW(n)	 (0x9300|((n)-2))	/* Move mem word at PC+n to R3 */
+#define TRAP16	 0xc310			/* Syscall w/no args (NR in R3) */
+#define OR_R0_R0 0x200b			/* or r0,r0 (insert to avoid hardware bug) */
+
 struct sigframe
 {
 	struct sigcontext sc;
 	unsigned long extramask[_NSIG_WORDS-1];
-	char retcode[4];
+	u16 retcode[8];
 };
 
 struct rt_sigframe
 {
-	struct siginfo *pinfo;
-	void *puc;
 	struct siginfo info;
 	struct ucontext uc;
-	char retcode[4];
+	u16 retcode[8];
 };
 
 #ifdef CONFIG_CPU_SH4
-static inline int restore_sigcontext_fpu(struct sigcontext *sc)
+static inline int restore_sigcontext_fpu(struct sigcontext __user *sc)
 {
 	struct task_struct *tsk = current;
 
@@ -166,7 +168,7 @@ static inline int restore_sigcontext_fpu
 				sizeof(long)*(16*2+2));
 }
 
-static inline int save_sigcontext_fpu(struct sigcontext *sc)
+static inline int save_sigcontext_fpu(struct sigcontext __user *sc)
 {
 	struct task_struct *tsk = current;
 
@@ -192,7 +194,7 @@ static inline int save_sigcontext_fpu(st
 #endif /* CONFIG_CPU_SH4 */
 
 static int
-restore_sigcontext(struct pt_regs *regs, struct sigcontext *sc, int *r0_p)
+restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *r0_p)
 {
 	unsigned int err = 0;
 
@@ -233,7 +235,7 @@ asmlinkage int sys_sigreturn(unsigned lo
 			     unsigned long r6, unsigned long r7,
 			     struct pt_regs regs)
 {
-	struct sigframe *frame = (struct sigframe *)regs.regs[15];
+	struct sigframe __user *frame = (struct sigframe __user *)regs.regs[15];
 	sigset_t set;
 	int r0;
 
@@ -266,7 +268,7 @@ asmlinkage int sys_rt_sigreturn(unsigned
 				unsigned long r6, unsigned long r7,
 				struct pt_regs regs)
 {
-	struct rt_sigframe *frame = (struct rt_sigframe *)regs.regs[15];
+	struct rt_sigframe __user *frame = (struct rt_sigframe __user *)regs.regs[15];
 	sigset_t set;
 	stack_t st;
 	int r0;
@@ -304,7 +306,7 @@ badframe:
  */
 
 static int
-setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs,
+setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
 		 unsigned long mask)
 {
 	int err = 0;
@@ -336,19 +338,19 @@ setup_sigcontext(struct sigcontext *sc, 
 /*
  * Determine which stack to use..
  */
-static inline void *
+static inline void __user *
 get_sigframe(struct k_sigaction *ka, unsigned long sp, size_t frame_size)
 {
 	if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && ! on_sig_stack(sp))
 		sp = current->sas_ss_sp + current->sas_ss_size;
 
-	return (void *)((sp - frame_size) & -8ul);
+	return (void __user *)((sp - frame_size) & -8ul);
 }
 
 static void setup_frame(int sig, struct k_sigaction *ka,
 			sigset_t *set, struct pt_regs *regs)
 {
-	struct sigframe *frame;
+	struct sigframe __user *frame;
 	int err = 0;
 	int signal;
 
@@ -375,15 +377,16 @@ static void setup_frame(int sig, struct 
 	if (ka->sa.sa_flags & SA_RESTORER) {
 		regs->pr = (unsigned long) ka->sa.sa_restorer;
 	} else {
-		/* This is : mov  #__NR_sigreturn,r3 ; trapa #0x10 */
-#ifdef __LITTLE_ENDIAN__
-		unsigned long code = 0xc310e300 | (__NR_sigreturn);
-#else
-		unsigned long code = 0xe300c310 | (__NR_sigreturn << 16);
-#endif
-
+		/* Generate return code (system call to sigreturn) */
+		err |= __put_user(MOVW(7), &frame->retcode[0]);
+		err |= __put_user(TRAP16, &frame->retcode[1]);
+		err |= __put_user(OR_R0_R0, &frame->retcode[2]);
+		err |= __put_user(OR_R0_R0, &frame->retcode[3]);
+		err |= __put_user(OR_R0_R0, &frame->retcode[4]);
+		err |= __put_user(OR_R0_R0, &frame->retcode[5]);
+		err |= __put_user(OR_R0_R0, &frame->retcode[6]);
+		err |= __put_user((__NR_sigreturn), &frame->retcode[7]);
 		regs->pr = (unsigned long) frame->retcode;
-		err |= __put_user(code, (long *)(frame->retcode+0));
 	}
 
 	if (err)
@@ -392,6 +395,8 @@ static void setup_frame(int sig, struct 
 	/* Set up registers for signal handler */
 	regs->regs[15] = (unsigned long) frame;
 	regs->regs[4] = signal; /* Arg for signal handler */
+	regs->regs[5] = 0;
+	regs->regs[6] = (unsigned long) &frame->sc;
 	regs->pc = (unsigned long) ka->sa.sa_handler;
 
 	set_fs(USER_DS);
@@ -402,6 +407,8 @@ static void setup_frame(int sig, struct 
 #endif
 
 	flush_cache_sigtramp(regs->pr);
+	if ((-regs->pr & (L1_CACHE_BYTES-1)) < sizeof(frame->retcode))
+		flush_cache_sigtramp(regs->pr + L1_CACHE_BYTES);
 	return;
 
 give_sigsegv:
@@ -413,7 +420,7 @@ give_sigsegv:
 static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
 			   sigset_t *set, struct pt_regs *regs)
 {
-	struct rt_sigframe *frame;
+	struct rt_sigframe __user *frame;
 	int err = 0;
 	int signal;
 
@@ -428,8 +435,6 @@ static void setup_rt_frame(int sig, stru
 		? current_thread_info()->exec_domain->signal_invmap[sig]
 		: sig;
 
-	err |= __put_user(&frame->info, &frame->pinfo);
-	err |= __put_user(&frame->uc, &frame->puc);
 	err |= copy_siginfo_to_user(&frame->info, info);
 
 	/* Create the ucontext.  */
@@ -449,15 +454,16 @@ static void setup_rt_frame(int sig, stru
 	if (ka->sa.sa_flags & SA_RESTORER) {
 		regs->pr = (unsigned long) ka->sa.sa_restorer;
 	} else {
-		/* This is : mov  #__NR_rt_sigreturn,r3 ; trapa #0x10 */
-#ifdef __LITTLE_ENDIAN__
-		unsigned long code = 0xc310e300 | (__NR_rt_sigreturn);
-#else
-		unsigned long code = 0xe300c310 | (__NR_rt_sigreturn << 16);
-#endif
-
+		/* Generate return code (system call to rt_sigreturn) */
+		err |= __put_user(MOVW(7), &frame->retcode[0]);
+		err |= __put_user(TRAP16, &frame->retcode[1]);
+		err |= __put_user(OR_R0_R0, &frame->retcode[2]);
+		err |= __put_user(OR_R0_R0, &frame->retcode[3]);
+		err |= __put_user(OR_R0_R0, &frame->retcode[4]);
+		err |= __put_user(OR_R0_R0, &frame->retcode[5]);
+		err |= __put_user(OR_R0_R0, &frame->retcode[6]);
+		err |= __put_user((__NR_rt_sigreturn), &frame->retcode[7]);
 		regs->pr = (unsigned long) frame->retcode;
-		err |= __put_user(code, (long *)(frame->retcode+0));
 	}
 
 	if (err)
@@ -466,6 +472,8 @@ static void setup_rt_frame(int sig, stru
 	/* Set up registers for signal handler */
 	regs->regs[15] = (unsigned long) frame;
 	regs->regs[4] = signal; /* Arg for signal handler */
+	regs->regs[5] = (unsigned long) &frame->info;
+	regs->regs[6] = (unsigned long) &frame->uc;
 	regs->pc = (unsigned long) ka->sa.sa_handler;
 
 	set_fs(USER_DS);
@@ -476,6 +484,8 @@ static void setup_rt_frame(int sig, stru
 #endif
 
 	flush_cache_sigtramp(regs->pr);
+	if ((-regs->pr & (L1_CACHE_BYTES-1)) < sizeof(frame->retcode))
+		flush_cache_sigtramp(regs->pr + L1_CACHE_BYTES);
 	return;
 
 give_sigsegv:
diff -puN /dev/null arch/sh/kernel/smp.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/kernel/smp.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,207 @@
+/*
+ * arch/sh/kernel/smp.c
+ *
+ * SMP support for the SuperH processors.
+ *
+ * Copyright (C) 2002, 2003 Paul Mundt
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the 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/cache.h>
+#include <linux/cpumask.h>
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+#include <linux/threads.h>
+#include <linux/module.h>
+#include <linux/time.h>
+#include <linux/timex.h>
+#include <linux/sched.h>
+
+#include <asm/atomic.h>
+#include <asm/processor.h>
+#include <asm/system.h>
+#include <asm/hardirq.h>
+#include <asm/mmu_context.h>
+#include <asm/smp.h>
+
+/*
+ * This was written with the Sega Saturn (SMP SH-2 7604) in mind,
+ * but is designed to be usable regardless if there's an MMU
+ * present or not.
+ */
+int smp_threads_ready = 0;
+struct sh_cpuinfo cpu_data[NR_CPUS];
+
+extern int cpu_idle(void *unused);
+extern void per_cpu_trap_init(void);
+
+cpumask_t cpu_possible_map;
+cpumask_t cpu_online_map;
+unsigned long cache_decay_ticks = HZ / 100;
+static atomic_t cpus_booted = ATOMIC_INIT(0);
+
+/* These are defined by the board-specific code. */
+
+/*
+ * Cause the function described by call_data to be executed on the passed
+ * cpu.  When the function has finished, increment the finished field of
+ * call_data.
+ */
+void __smp_send_ipi(unsigned int cpu, unsigned int action);
+
+/*
+ * Find the number of available processors
+ */
+unsigned int __smp_probe_cpus(void);
+
+/*
+ * Start a particular processor
+ */
+void __smp_slave_init(unsigned int cpu);
+
+/*
+ * Run specified function on a particular processor.
+ */
+void __smp_call_function(unsigned int cpu);
+
+static inline void __init smp_store_cpu_info(unsigned int cpu)
+{
+	cpu_data[cpu].loops_per_jiffy = loops_per_jiffy;
+}
+
+void __init smp_prepare_cpus(unsigned int max_cpus)
+{
+	unsigned int cpu = smp_processor_id();
+	int i;
+
+	atomic_set(&cpus_booted, 1);
+	smp_store_cpu_info(cpu);
+	
+	for (i = 0; i < __smp_probe_cpus(); i++)
+		cpu_set(i, cpu_possible_map);
+}
+
+void __devinit smp_prepare_boot_cpu(void)
+{
+	unsigned int cpu = smp_processor_id();
+
+	cpu_set(cpu, cpu_online_map);
+	cpu_set(cpu, cpu_possible_map);
+}
+
+int __cpu_up(unsigned int cpu)
+{
+	struct task_struct *tsk;
+	struct pt_regs regs;
+
+	memset(&regs, 0, sizeof(struct pt_regs));
+	tsk = copy_process(CLONE_VM | CLONE_IDLETASK, 0, &regs, 0, 0, 0);
+
+	if (IS_ERR(tsk))
+		panic("Failed forking idle task for cpu %d\n", cpu);
+	
+	wake_up_forked_process(tsk);
+
+	init_idle(tsk, cpu);
+	unhash_process(tsk);
+	
+	tsk->thread_info->cpu = cpu;
+
+	cpu_set(cpu, cpu_online_map);
+
+	return 0;
+}
+
+int start_secondary(void *unused)
+{
+	unsigned int cpu = smp_processor_id();
+
+	atomic_inc(&init_mm.mm_count);
+	current->active_mm = &init_mm;
+
+	smp_store_cpu_info(cpu);
+
+	__smp_slave_init(cpu);
+	per_cpu_trap_init();
+	
+	atomic_inc(&cpus_booted);
+
+	return cpu_idle(0);
+}
+
+void __init smp_cpus_done(unsigned int max_cpus)
+{
+	smp_threads_ready = 1;
+	smp_mb();
+}
+
+void smp_send_reschedule(int cpu)
+{
+	__smp_send_ipi(cpu, SMP_MSG_RESCHEDULE);
+}
+
+static void stop_this_cpu(void *unused)
+{
+	cpu_clear(smp_processor_id(), cpu_online_map);
+	local_irq_disable();
+
+	for (;;)
+		cpu_relax();
+}
+
+void smp_send_stop(void)
+{
+	smp_call_function(stop_this_cpu, 0, 1, 0);
+}
+
+
+struct smp_fn_call_struct smp_fn_call = {
+	.lock		= SPIN_LOCK_UNLOCKED,
+	.finished	= ATOMIC_INIT(0),
+};
+
+/*
+ * The caller of this wants the passed function to run on every cpu.  If wait
+ * is set, wait until all cpus have finished the function before returning.
+ * The lock is here to protect the call structure.
+ * You must not call this function with disabled interrupts or from a
+ * hardware interrupt handler or from a bottom half handler.
+ */
+int smp_call_function(void (*func)(void *info), void *info, int retry, int wait)
+{
+	unsigned int nr_cpus = atomic_read(&cpus_booted);
+	int i;
+
+	if (nr_cpus < 2)
+		return 0;
+
+	spin_lock(&smp_fn_call.lock);
+
+	atomic_set(&smp_fn_call.finished, 0);
+	smp_fn_call.fn = func;
+	smp_fn_call.data = info;
+
+	for (i = 0; i < nr_cpus; i++)
+		if (i != smp_processor_id())
+			__smp_call_function(i);
+
+	if (wait)
+		while (atomic_read(&smp_fn_call.finished) != (nr_cpus - 1));
+
+	spin_unlock(&smp_fn_call.lock);
+
+	return 0;
+}
+
+/* Not really SMP stuff ... */
+int setup_profiling_timer(unsigned int multiplier)
+{
+	return 0;
+}
+
diff -puN arch/sh/kernel/sys_sh.c~linus arch/sh/kernel/sys_sh.c
--- 25/arch/sh/kernel/sys_sh.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/kernel/sys_sh.c	2004-01-19 22:17:21.000000000 -0800
@@ -132,7 +132,7 @@ asmlinkage long sys_mmap2(unsigned long 
  * This is really horribly ugly.
  */
 asmlinkage int sys_ipc(uint call, int first, int second,
-		       int third, void *ptr, long fifth)
+		       int third, void __user *ptr, long fifth)
 {
 	int version, ret;
 
@@ -142,19 +142,19 @@ asmlinkage int sys_ipc(uint call, int fi
 	if (call <= SEMCTL)
 		switch (call) {
 		case SEMOP:
-			return sys_semtimedop(first, (struct sembuf *)ptr,
+			return sys_semtimedop(first, (struct sembuf __user *)ptr,
 					      second, NULL);
 		case SEMTIMEDOP:
-			return sys_semtimedop(first, (struct sembuf *)ptr,
+			return sys_semtimedop(first, (struct sembuf __user *)ptr,
 					      second,
-					      (const struct timespec *)fifth);
+					      (const struct timespec __user *)fifth);
 		case SEMGET:
 			return sys_semget (first, second, third);
 		case SEMCTL: {
 			union semun fourth;
 			if (!ptr)
 				return -EINVAL;
-			if (get_user(fourth.__pad, (void **) ptr))
+			if (get_user(fourth.__pad, (void * __user *) ptr))
 				return -EFAULT;
 			return sys_semctl (first, second, third, fourth);
 			}
@@ -165,7 +165,7 @@ asmlinkage int sys_ipc(uint call, int fi
 	if (call <= MSGCTL) 
 		switch (call) {
 		case MSGSND:
-			return sys_msgsnd (first, (struct msgbuf *) ptr, 
+			return sys_msgsnd (first, (struct msgbuf __user *) ptr, 
 					  second, third);
 		case MSGRCV:
 			switch (version) {
@@ -175,7 +175,7 @@ asmlinkage int sys_ipc(uint call, int fi
 					return -EINVAL;
 				
 				if (copy_from_user(&tmp,
-						   (struct ipc_kludge *) ptr, 
+						   (struct ipc_kludge __user *) ptr, 
 						   sizeof (tmp)))
 					return -EFAULT;
 				return sys_msgrcv (first, tmp.msgp, second,
@@ -183,14 +183,14 @@ asmlinkage int sys_ipc(uint call, int fi
 				}
 			default:
 				return sys_msgrcv (first,
-						   (struct msgbuf *) ptr,
+						   (struct msgbuf __user *) ptr,
 						   second, fifth, third);
 			}
 		case MSGGET:
 			return sys_msgget ((key_t) first, second);
 		case MSGCTL:
 			return sys_msgctl (first, second,
-					   (struct msqid_ds *) ptr);
+					   (struct msqid_ds __user *) ptr);
 		default:
 			return -EINVAL;
 		}
@@ -200,25 +200,25 @@ asmlinkage int sys_ipc(uint call, int fi
 			switch (version) {
 			default: {
 				ulong raddr;
-				ret = sys_shmat (first, (char *) ptr,
+				ret = sys_shmat (first, (char __user *) ptr,
 						 second, &raddr);
 				if (ret)
 					return ret;
-				return put_user (raddr, (ulong *) third);
+				return put_user (raddr, (ulong __user *) third);
 			}
 			case 1:	/* iBCS2 emulator entry point */
 				if (!segment_eq(get_fs(), get_ds()))
 					return -EINVAL;
-				return sys_shmat (first, (char *) ptr,
+				return sys_shmat (first, (char __user *) ptr,
 						  second, (ulong *) third);
 			}
 		case SHMDT: 
-			return sys_shmdt ((char *)ptr);
+			return sys_shmdt ((char __user *)ptr);
 		case SHMGET:
 			return sys_shmget (first, second, third);
 		case SHMCTL:
 			return sys_shmctl (first, second,
-					   (struct shmid_ds *) ptr);
+					   (struct shmid_ds __user *) ptr);
 		default:
 			return -EINVAL;
 		}
@@ -252,3 +252,15 @@ asmlinkage ssize_t sys_pwrite_wrapper(un
 					size_t count, loff_t pos);
 	return sys_pwrite64(fd, buf, count, pos);
 }
+
+asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1,
+				u32 len0, u32 len1, int advice)
+{
+#ifdef  __LITTLE_ENDIAN__
+	return sys_fadvise64_64(fd, (u64)offset1 << 32 | offset0,
+				(u64)len1 << 32 | len0,	advice);
+#else
+	return sys_fadvise64_64(fd, (u64)offset0 << 32 | offset1,
+				(u64)len0 << 32 | len1,	advice);
+#endif
+}
diff -puN arch/sh/kernel/time.c~linus arch/sh/kernel/time.c
--- 25/arch/sh/kernel/time.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/kernel/time.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: time.c,v 1.12 2003/06/28 15:35:28 lethal Exp $
+/* $Id: time.c,v 1.18 2003/10/09 16:28:14 lethal Exp $
  *
  *  linux/arch/sh/kernel/time.c
  *
@@ -68,7 +68,7 @@
 #endif /* CONFIG_CPU_SH3 or CONFIG_CPU_SH4 */
 
 extern unsigned long wall_jiffies;
-#define TICK_SIZE (TICK_NSEC / 1000)
+#define TICK_SIZE (tick_nsec / 1000)
 spinlock_t tmu0_lock = SPIN_LOCK_UNLOCKED;
 
 u64 jiffies_64 = INITIAL_JIFFIES;
@@ -101,6 +101,14 @@ static int pfc_values[]   = { 0, 0, 1, 2
 #error "Unknown ifc/bfc/pfc/stc values for this processor"
 #endif
 
+/*
+ * Scheduler clock - returns current time in nanosec units.
+ */
+unsigned long long sched_clock(void)
+{
+	return (unsigned long long)jiffies * (1000000000 / HZ);
+}
+
 static unsigned long do_gettimeoffset(void)
 {
 	int count;
@@ -198,7 +206,7 @@ int do_settimeofday(struct timespec *tv)
 	 * made, and then undo it!
 	 */
 	nsec -= 1000 * (do_gettimeoffset() +
-			(jiffies - wall_jiffies) * (1000000 / HZ));
+				(jiffies - wall_jiffies) * (1000000 / HZ));
 
 	wtm_sec  = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
 	wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
@@ -230,7 +238,8 @@ extern char _stext;
 
 static inline void sh_do_profile(unsigned long pc)
 {
-	if (!prof_buffer)
+	/* Don't profile cpu_idle.. */
+	if (!prof_buffer || !current->pid)
 		return;
 
 	if (pc >= 0xa0000000UL && pc < 0xc0000000UL)
@@ -365,6 +374,19 @@ static unsigned int __init get_timer_fre
 void (*board_time_init)(void) = 0;
 void (*board_timer_setup)(struct irqaction *irq) = 0;
 
+static unsigned int sh_pclk_freq __initdata = CONFIG_SH_PCLK_FREQ;
+
+static int __init sh_pclk_setup(char *str)
+{
+        unsigned int freq;
+
+	if (get_option(&str, &freq))
+		sh_pclk_freq = freq;
+
+	return 1;
+}
+__setup("sh_pclk=", sh_pclk_setup);
+
 static struct irqaction irq0  = { timer_interrupt, SA_INTERRUPT, 0, "timer", NULL, NULL};
 
 void get_current_frequency_divisors(unsigned int *ifc, unsigned int *bfc, unsigned int *pfc)
@@ -407,23 +429,46 @@ _FREQ_TABLE(pfc);
 
 void __init time_init(void)
 {
-	unsigned int timer_freq;
+	unsigned int timer_freq = 0;
 	unsigned int ifc, pfc, bfc;
 	unsigned long interval;
 
 	if (board_time_init)
 		board_time_init();
 
-	/* 
-	 * XXX: Hmm... when cpu/ is proposed, this looks like a good spot for
-	 * it, but we need a rtc to get the timer_freq so board_time_init()
-	 * must always come before a CPU time_(rtc?)_init().
-	 */
 	get_current_frequency_divisors(&ifc, &bfc, &pfc);
 
-	timer_freq = get_timer_frequency();
+	/*
+	 * If we don't have an RTC (such as with the SH7300), don't attempt to
+	 * probe the timer frequency. Rely on an either hardcoded peripheral
+	 * clock value, or on the sh_pclk command line option.
+	 */
+	current_cpu_data.module_clock = sh_pclk_freq;
 
-	current_cpu_data.module_clock = timer_freq * 4;
+	/* XXX: Switch this over to a more generic test. */
+	if (current_cpu_data.type != CPU_SH7300) {
+		unsigned int freq;
+
+		/* 
+		 * If we've specified a peripheral clock frequency, and we have
+		 * an RTC, compare it against the autodetected value. Complain
+		 * if there's a mismatch.
+		 *
+		 * Note: We should allow for some high and low watermarks for
+		 * the frequency here (compensating for potential drift), as
+		 * otherwise we'll likely end up triggering this essentially
+		 * on every boot.
+		 */
+		timer_freq = get_timer_frequency();
+		freq = timer_freq * 4;
+
+		if (sh_pclk_freq && sh_pclk_freq != freq) {
+			printk(KERN_NOTICE "Calculated peripheral clock value "
+			       "%d differs from sh_pclk value %d, fixing..\n",
+			       freq, sh_pclk_freq);
+			current_cpu_data.module_clock = freq;
+		}
+	}
 
 	rtc_get_time(&xtime);
 
diff -puN arch/sh/kernel/traps.c~linus arch/sh/kernel/traps.c
--- 25/arch/sh/kernel/traps.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/kernel/traps.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: traps.c,v 1.7 2003/05/04 19:29:53 lethal Exp $
+/* $Id: traps.c,v 1.14 2003/11/14 18:40:10 lethal Exp $
  *
  *  linux/arch/sh/traps.c
  *
@@ -26,12 +26,14 @@
 #include <linux/delay.h>
 #include <linux/spinlock.h>
 #include <linux/module.h>
+#include <linux/kallsyms.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/atomic.h>
 #include <asm/processor.h>
+#include <asm/sections.h>
 
 #ifdef CONFIG_SH_KGDB
 #include <asm/kgdb.h>
@@ -46,21 +48,36 @@
 #define CHK_REMOTE_DEBUG(regs)
 #endif
 
-#define DO_ERROR(trapnr, signr, str, name, tsk) \
-asmlinkage void do_##name(unsigned long r4, unsigned long r5, \
-			  unsigned long r6, unsigned long r7, \
-			  struct pt_regs regs) \
-{ \
-	unsigned long error_code; \
- \
-	asm volatile("stc	r2_bank, %0": "=r" (error_code)); \
-	local_irq_enable(); \
-	tsk->thread.error_code = error_code; \
-	tsk->thread.trap_no = trapnr; \
-        CHK_REMOTE_DEBUG(&regs); \
-	force_sig(signr, tsk); \
-	die_if_no_fixup(str,&regs,error_code); \
-}
+#define DO_ERROR(trapnr, signr, str, name, tsk)				\
+asmlinkage void do_##name(unsigned long r4, unsigned long r5,		\
+			  unsigned long r6, unsigned long r7,		\
+			  struct pt_regs regs)				\
+{									\
+	unsigned long error_code;					\
+ 									\
+	/* Check if it's a DSP instruction */				\
+ 	if (is_dsp_inst(&regs)) {					\
+		/* Enable DSP mode, and restart instruction. */		\
+		regs.sr |= SR_DSP;					\
+		return;							\
+	}								\
+									\
+	asm volatile("stc	r2_bank, %0": "=r" (error_code));	\
+	local_irq_enable();						\
+	tsk->thread.error_code = error_code;				\
+	tsk->thread.trap_no = trapnr;					\
+        CHK_REMOTE_DEBUG(&regs);					\
+	force_sig(signr, tsk);						\
+	die_if_no_fixup(str,&regs,error_code);				\
+}
+
+#ifdef CONFIG_CPU_SH2
+#define TRAP_RESERVED_INST	4
+#define TRAP_ILLEGAL_SLOT_INST	6
+#else
+#define TRAP_RESERVED_INST	12
+#define TRAP_ILLEGAL_SLOT_INST	13
+#endif
 
 /*
  * These constants are for searching for possible module text
@@ -530,8 +547,37 @@ asmlinkage void do_address_error(struct 
 	}
 }
 
-DO_ERROR(12, SIGILL,  "reserved instruction", reserved_inst, current)
-DO_ERROR(13, SIGILL,  "illegal slot instruction", illegal_slot_inst, current)
+#ifdef CONFIG_SH_DSP
+/*
+ *	SH-DSP support gerg@snapgear.com.
+ */
+int is_dsp_inst(struct pt_regs *regs)
+{
+	unsigned short inst;
+
+	/* 
+	 * Safe guard if DSP mode is already enabled or we're lacking
+	 * the DSP altogether.
+	 */
+	if (!test_bit(CPU_HAS_DSP, &(cpu_data->flags)) || (regs->sr & SR_DSP))
+		return 0;
+
+	get_user(inst, ((unsigned short *) regs->pc));
+
+	inst &= 0xf000;
+
+	/* Check for any type of DSP or support instruction */
+	if ((inst == 0xf000) || (inst == 0x4000))
+		return 1;
+
+	return 0;
+}
+#else
+#define is_dsp_inst(regs)	(0)
+#endif /* CONFIG_SH_DSP */
+
+DO_ERROR(TRAP_RESERVED_INST, SIGILL, "reserved instruction", reserved_inst, current)
+DO_ERROR(TRAP_ILLEGAL_SLOT_INST, SIGILL, "illegal slot instruction", illegal_slot_inst, current)
 
 asmlinkage void do_exception_error(unsigned long r4, unsigned long r5,
 				   unsigned long r6, unsigned long r7,
@@ -547,18 +593,18 @@ void *gdb_vbr_vector;
 
 static inline void __init gdb_vbr_init(void)
 {
-    	/*
+	register unsigned long vbr;
+
+	/*
 	 * Read the old value of the VBR register to initialise
 	 * the vector through which debug and BIOS traps are
 	 * delegated by the Linux trap handler.
 	 */
-	{
-	    register unsigned long vbr;
-	    asm volatile("stc vbr, %0" : "=r" (vbr));
-	    gdb_vbr_vector = (void *)(vbr + 0x100);
-	    printk("Setting GDB trap vector to 0x%08lx\n",
-	    	(unsigned long)gdb_vbr_vector);
-	}
+	asm volatile("stc vbr, %0" : "=r" (vbr));
+
+	gdb_vbr_vector = (void *)(vbr + 0x100);
+	printk("Setting GDB trap vector to 0x%08lx\n",
+	       (unsigned long)gdb_vbr_vector);
 }
 #endif
 
@@ -582,11 +628,24 @@ void __init per_cpu_trap_init(void)
 
 void __init trap_init(void)
 {
-	extern void *exception_handling_table[14];
-
-	exception_handling_table[12] = (void *)do_reserved_inst;
-	exception_handling_table[13] = (void *)do_illegal_slot_inst;
+	extern void *exception_handling_table[];
 
+	exception_handling_table[TRAP_RESERVED_INST]
+		= (void *)do_reserved_inst;
+	exception_handling_table[TRAP_ILLEGAL_SLOT_INST]
+		= (void *)do_illegal_slot_inst;
+
+#ifdef CONFIG_CPU_SH4
+	if (!test_bit(CPU_HAS_FPU, &(cpu_data->flags))) {
+		/* For SH-4 lacking an FPU, treat floating point instructions
+		   as reserved. */
+		/* entry 64 corresponds to EXPEVT=0x800 */
+		exception_handling_table[64] = (void *)do_reserved_inst;
+		exception_handling_table[65] = (void *)do_illegal_slot_inst;
+	}
+#endif
+		
+	/* Setup VBR for boot cpu */
 	per_cpu_trap_init();
 }
 
@@ -595,7 +654,6 @@ void show_stack(struct task_struct *tsk,
 	unsigned long *stack, addr;
 	unsigned long module_start = VMALLOC_START;
 	unsigned long module_end = VMALLOC_END;
-	extern long _text, _etext;
 	int i = 1;
 
 	if (!sp) {
@@ -612,19 +670,25 @@ void show_stack(struct task_struct *tsk,
 	stack = sp;
 
 	printk("\nCall trace: ");
+#ifdef CONFIG_KALLSYMS
+	printk("\n");
+#endif
 
-	while (((long)stack & (THREAD_SIZE - 1))) {
+	while (!kstack_end(stack)) {
 		addr = *stack++;
-		if (((addr >= (unsigned long)&_text) &&
-		     (addr <= (unsigned long)&_etext)) ||
+		if (((addr >= (unsigned long)_text) &&
+		     (addr <= (unsigned long)_etext)) ||
 		    ((addr >= module_start) && (addr <= module_end))) {
 			/*
 			 * For 80-columns display, 6 entry is maximum.
 			 * NOTE: '[<8c00abcd>] ' consumes 13 columns .
 			 */
+#ifndef CONFIG_KALLSYMS
 			if (i && ((i % 6) == 0))
 				printk("\n       ");
+#endif
 			printk("[<%08lx>] ", addr);
+			print_symbol("%s\n", addr);
 			i++;
 		}
 	}
diff -puN /dev/null arch/sh/lib/div64-generic.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/lib/div64-generic.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,19 @@
+/*
+ * Generic __div64_32 wrapper for __xdiv64_32.
+ */
+
+#include <linux/types.h>
+
+extern u64 __xdiv64_32(u64 n, u32 d);
+
+u64 __div64_32(u64 *xp, u32 y)
+{
+	u64 rem;
+	u64 q = __xdiv64_32(*xp, y);
+
+	rem = *xp - q * y;
+	*xp = q;
+
+	return rem;
+}
+
diff -puN arch/sh/lib/div64.S~linus arch/sh/lib/div64.S
--- 25/arch/sh/lib/div64.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/lib/div64.S	2004-01-19 22:17:21.000000000 -0800
@@ -1,11 +1,11 @@
 /*	
- * unsigned long long __div64_32(unsigned long long n, unsigned long d); 
+ * unsigned long long __xdiv64_32(unsigned long long n, unsigned long d); 
  */
 
 #include <linux/linkage.h>
 
 .text
-ENTRY(__div64_32)
+ENTRY(__xdiv64_32)
 #ifdef  __LITTLE_ENDIAN__
 	mov	r4, r0
 	mov	r5, r1
diff -puN arch/sh/lib/Makefile~linus arch/sh/lib/Makefile
--- 25/arch/sh/lib/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/lib/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -3,4 +3,5 @@
 #
 
 lib-y  = delay.o memcpy.o memset.o memmove.o memchr.o \
-	 checksum.o strcasecmp.o strlen.o div64.o udivdi3.o
+	 checksum.o strcasecmp.o strlen.o div64.o udivdi3.o \
+	 div64-generic.o
diff -puN arch/sh/lib/udivdi3.c~linus arch/sh/lib/udivdi3.c
--- 25/arch/sh/lib/udivdi3.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/lib/udivdi3.c	2004-01-19 22:17:21.000000000 -0800
@@ -4,13 +4,13 @@
 
 #include <linux/types.h>
 
-extern u64 __div64_32(u64 n, u32 d);
+extern u64 __xdiv64_32(u64 n, u32 d);
 extern void panic(const char * fmt, ...);
 
 u64 __udivdi3(u64 n, u64 d)
 {
 	if (d & ~0xffffffff)
 		panic("Need true 64-bit/64-bit division");
-	return __div64_32(n, (u32)d);
+	return __xdiv64_32(n, (u32)d);
 }
 
diff -puN arch/sh/Makefile~linus arch/sh/Makefile
--- 25/arch/sh/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.17 2003/05/20 03:12:54 lethal Exp $
+# $Id: Makefile,v 1.32 2003/10/26 23:33:49 lethal Exp $
 #
 # This file is subject to the terms and conditions of the GNU General Public
 # License.  See the file "COPYING" in the main directory of this archive
@@ -25,20 +25,20 @@ ifndef include_config
 -include .config
 endif
 
-cpu-y				:= -mb
-cpu-$(CONFIG_CPU_LITTLE_ENDIAN)	:= -ml
+cflags-y				:= -mb
+cflags-$(CONFIG_CPU_LITTLE_ENDIAN)	:= -ml
 
-cpu-$(CONFIG_CPU_SH2)		+= -m2
-cpu-$(CONFIG_CPU_SH3)		+= -m3
-cpu-$(CONFIG_CPU_SH4)		+= -m4 -mno-implicit-fp
-
-ifdef CONFIG_SH_KGDB
-CFLAGS :=$(CFLAGS:-fomit-frame-pointer=) -g
-AFLAGS += -g
-ifdef CONFIG_KGDB_MORE
-CFLAGS += $(shell echo $(CONFIG_KGDB_OPTIONS) | sed -e 's/"//g')
-endif
-endif
+cflags-$(CONFIG_CPU_SH2)		+= -m2
+cflags-$(CONFIG_CPU_SH3)		+= -m3
+cflags-$(CONFIG_CPU_SH4)		+= -m4 \
+	$(call check_gcc,-mno-implicit-fp,-m4-nofpu)
+
+cflags-$(CONFIG_SH_DSP)			+= -Wa,-dsp
+cflags-$(CONFIG_SH_KGDB)		+= -g
+cflags-$(CONFIG_EMBEDDED)		+= -Os
+
+cflags-$(CONFIG_MORE_COMPILE_OPTIONS)	+= \
+	$(shell echo $(CONFIG_COMPILE_OPTIONS) | sed -e 's/"//g')
 
 OBJCOPYFLAGS	:= -O binary -R .note -R .comment -R .stab -R .stabstr -S
 
@@ -49,13 +49,15 @@ OBJCOPYFLAGS	:= -O binary -R .note -R .c
 LDFLAGS_vmlinux     += -e _stext
 
 ifdef CONFIG_CPU_LITTLE_ENDIAN
-LDFLAGS_vmlinux     +=  --defsym 'jiffies=jiffies_64' -EL
+LDFLAGS_vmlinux		+= --defsym 'jiffies=jiffies_64'
+LDFLAGS			+= -EL
 else
-LDFLAGS_vmlinux     +=  --defsym 'jiffies=jiffies_64+4' -EB
+LDFLAGS_vmlinux		+= --defsym 'jiffies=jiffies_64+4'
+LDFLAGS			+= -EB
 endif
 
-CFLAGS		+= -pipe $(cpu-y)
-AFLAGS		+= $(cpu-y)
+CFLAGS		+= -pipe $(cflags-y)
+AFLAGS		+= $(cflags-y)
 
 head-y := arch/sh/kernel/head.o arch/sh/kernel/init_task.o
 
@@ -66,6 +68,7 @@ core-y				+= arch/sh/kernel/ arch/sh/mm/
 # Boards
 machdir-$(CONFIG_SH_SOLUTION_ENGINE)		:= se/770x
 machdir-$(CONFIG_SH_7751_SOLUTION_ENGINE)	:= se/7751
+machdir-$(CONFIG_SH_7751_SYSTEMH)		:= systemh
 machdir-$(CONFIG_SH_STB1_HARP)			:= harp
 machdir-$(CONFIG_SH_STB1_OVERDRIVE)		:= overdrive
 machdir-$(CONFIG_SH_HP620)			:= hp6xx/hp620
@@ -81,6 +84,7 @@ machdir-$(CONFIG_SH_BIGSUR)			:= bigsur
 machdir-$(CONFIG_SH_SH2000)			:= sh2000
 machdir-$(CONFIG_SH_ADX)			:= adx
 machdir-$(CONFIG_SH_MPC1211)			:= mpc1211
+machdir-$(CONFIG_SH_SECUREEDGE5410)		:= snapgear
 machdir-$(CONFIG_SH_UNKNOWN)			:= unknown
 
 incdir-y			:= $(machdir-y)
@@ -99,7 +103,10 @@ cpuincdir-$(CONFIG_CPU_SH2)	:= cpu-sh2
 cpuincdir-$(CONFIG_CPU_SH3)	:= cpu-sh3
 cpuincdir-$(CONFIG_CPU_SH4)	:= cpu-sh4
 
-libs-y				+= arch/sh/lib/	$(LIBGCC)
+libs-y				:= arch/sh/lib/	$(libs-y) $(LIBGCC)
+
+drivers-y			+= arch/sh/drivers/
+drivers-$(CONFIG_OPROFILE)	+= arch/sh/oprofile/
 
 boot := arch/sh/boot
 
@@ -110,18 +117,36 @@ prepare: target_links
 .PHONY: target_links FORCE
 target_links:
 	@echo '  Making asm-sh/cpu -> asm-sh/$(cpuincdir-y) link'
+	@rm -f include/asm-sh/cpu
 	@ln -sf $(cpuincdir-y) include/asm-sh/cpu
 
 	@echo '  Making asm-sh/mach -> asm-sh/$(incdir-y) link'
+	@rm -f include/asm-sh/mach
 	@ln -sf $(incdir-y) include/asm-sh/mach
 
 	$(Q)$(MAKE) $(build)=arch/sh/tools include/asm-sh/machtypes.h
 
-BOOTIMAGE=arch/sh/boot/zImage
 zImage: vmlinux
-	$(Q)$(MAKE) $(build)=$(boot) $(BOOTIMAGE)
+	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
 
 compressed: zImage
 
 archclean:
 	$(Q)$(MAKE) $(clean)=$(boot)
+
+defconfig-%:
+	@echo '  Copying arch/sh/configs/$@ -> .config'
+	@if [ -e .config ]; then mv -f .config .config.old; fi
+	@cp -f arch/sh/configs/$@ .config
+	@chmod 644 .config
+
+define archhelp
+	@echo '  zImage		  - Compressed kernel image (arch/sh/boot/zImage)'
+	for board in arch/sh/configs/*; \
+	do \
+		 echo -n ' ' $$board | sed -e 's|arch/sh/configs/||g' ; \
+		 echo -n '  	  - Build for ' ; \
+		 echo -e $$board | sed -e 's|.*-||g'; \
+	done
+endef
+
diff -puN arch/sh/mm/cache-sh3.c~linus arch/sh/mm/cache-sh3.c
--- 25/arch/sh/mm/cache-sh3.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/mm/cache-sh3.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: cache-sh3.c,v 1.5 2003/05/06 23:28:48 lethal Exp $
+/* $Id: cache-sh3.c,v 1.7 2003/08/28 16:16:09 lethal Exp $
  *
  *  linux/arch/sh/mm/cache-sh3.c
  *
@@ -70,6 +70,8 @@ detect_cpu_and_cache_system(void)
 		cpu_data->dcache.entry_mask	= 0x7f0;
 		cpu_data->dcache.sets		= 128;
 		cpu_data->type = CPU_SH7708;
+
+		set_bit(CPU_HAS_MMU_PAGE_ASSOC, &(cpu_data->flags));
 	} else {				/* 7709A or 7729  */
 		cpu_data->dcache.way_shift	= 12;
 		cpu_data->dcache.entry_mask	= 0xff0;
@@ -77,9 +79,9 @@ detect_cpu_and_cache_system(void)
 		cpu_data->type = CPU_SH7729;
 	}
 
-		/*
+	/*
 	 * SH-3 doesn't have separate caches
-		 */
+	 */
 	cpu_data->dcache.flags |= SH_CACHE_COMBINED;
 	cpu_data->icache = cpu_data->dcache;
 
diff -puN arch/sh/mm/cache-sh4.c~linus arch/sh/mm/cache-sh4.c
--- 25/arch/sh/mm/cache-sh4.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/mm/cache-sh4.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: cache-sh4.c,v 1.20 2003/05/10 03:22:05 sugioka Exp $
+/* $Id: cache-sh4.c,v 1.24 2003/10/12 19:40:12 lethal Exp $
  *
  *  linux/arch/sh/mm/cache-sh4.c
  *
@@ -26,10 +26,7 @@ extern void __flush_cache_4096_all(unsig
 static void __flush_cache_4096_all_ex(unsigned long start);
 extern void __flush_dcache_all(void);
 static void __flush_dcache_all_ex(void);
-/*
- * FIXME: Add ST40STB1 probe support (and clean up the manual overdrive stuff)
- * seems to rely on some quirky PVR shifting .. stuart? ++paulm
- */
+
 int __init detect_cpu_and_cache_system(void)
 {
 	unsigned long pvr, prr, ccr;
@@ -37,9 +34,9 @@ int __init detect_cpu_and_cache_system(v
 	pvr = (ctrl_inl(CCN_PVR) >> 8) & 0xffff;
 	prr = (ctrl_inl(CCN_PRR) >> 4) & 0xff;
 
-		/*
+	/*
 	 * Setup some sane SH-4 defaults for the icache
-		 */
+	 */
 	cpu_data->icache.way_shift	= 13;
 	cpu_data->icache.entry_shift	= 5;
 	cpu_data->icache.entry_mask	= 0x1fe0;
@@ -64,9 +61,17 @@ int __init detect_cpu_and_cache_system(v
 	switch (pvr) {
 	case 0x205:
 		cpu_data->type = CPU_SH7750;
+		set_bit(CPU_HAS_P2_FLUSH_BUG, &(cpu_data->flags));
 		break;
 	case 0x206:
 		cpu_data->type = CPU_SH7750S;
+
+		/* 
+		 * FIXME: This is needed for 7750, but do we need it for the
+		 * 7750S and 7750R too? For now, assume we do.. -- PFM
+		 */
+		set_bit(CPU_HAS_P2_FLUSH_BUG, &(cpu_data->flags));
+
 		break;
 	case 0x1100:
 		cpu_data->type = CPU_SH7751;
@@ -77,28 +82,46 @@ int __init detect_cpu_and_cache_system(v
 	case 0x8100:
 		cpu_data->type = CPU_ST40GX1;
 		break;
-	case 0x500:
-		if (prr == 0x10)
-			cpu_data->type = CPU_SH7750R;
-		else
-			cpu_data->type = CPU_SH7751R;
+	case 0x700:
+		/* XXX: Add proper CVR probing */
+		cpu_data->type = CPU_SH4_501;
+		break;
+	case 0x600:
+		cpu_data->type = CPU_SH4_202;
+		/* fall */
+	case 0x500 ... 0x501:
+		switch (prr) {
+		    case 0x10: cpu_data->type = CPU_SH7750R; break;
+		    case 0x11: cpu_data->type = CPU_SH7751R; break;
+		    case 0x50: cpu_data->type = CPU_SH7760;  break;
+		}
+
+		if (cpu_data->type == CPU_SH7750R)
+			set_bit(CPU_HAS_P2_FLUSH_BUG, &(cpu_data->flags));
+
 		jump_to_P2();
 		ccr = ctrl_inl(CCR);
-		back_to_P1();
-		if(ccr & CCR_CACHE_EMODE) {
-			cpu_data->icache.ways = 2;
-			cpu_data->dcache.ways = 2;
+
+		/* Force EMODE */
+		if (!(ccr & CCR_CACHE_EMODE)) {
+			ccr |= CCR_CACHE_EMODE;
+			ctrl_outl(ccr, CCR);
 		}
+
+		back_to_P1();
+
+		cpu_data->icache.ways = 2;
+		cpu_data->dcache.ways = 2;
+
 		break;
 	default:
 		cpu_data->type = CPU_SH_NONE;
 		break;
 	}
 
-	/*
-	 * For now, all SH-4's have an FPU ..
-	 */
-	cpu_data->flags |= CPU_HAS_FPU;
+	/* No FPU on the SH4-500 series.. */
+	if (cpu_data->type != CPU_SH4_501)
+		set_bit(CPU_HAS_FPU, &(cpu_data->flags));
 
 	return 0;
 }
@@ -257,20 +280,16 @@ static inline void flush_cache_4096(unsi
 	unsigned long flags; 
 	extern void __flush_cache_4096(unsigned long addr, unsigned long phys, unsigned long exec_offset);
 
-		/*
+	/*
 	 * SH7751, SH7751R, and ST40 have no restriction to handle cache.
-		 * (While SH7750 must do that at P2 area.)
-		 */
-	if ((cpu_data->type == CPU_SH7751 ||
-	     cpu_data->type == CPU_SH7751R ||
-	     cpu_data->type == CPU_ST40RA ||
-	     cpu_data->type == CPU_ST40GX1) &&
-		(start >= CACHE_OC_ADDRESS_ARRAY)) {
-		__flush_cache_4096(start | SH_CACHE_ASSOC, phys | 0x80000000, 0);
-	} else {
+	 * (While SH7750 must do that at P2 area.)
+	 */
+	if (test_bit(CPU_HAS_P2_FLUSH_BUG, &(cpu_data->flags))) {
 		local_irq_save(flags);
 		__flush_cache_4096(start | SH_CACHE_ASSOC, phys | 0x80000000, 0x20000000);
 		local_irq_restore(flags);
+	} else if (start >= CACHE_OC_ADDRESS_ARRAY) {
+		__flush_cache_4096(start | SH_CACHE_ASSOC, phys | 0x80000000, 0);
 	}
 }
 
diff -puN arch/sh/mm/clear_page.S~linus arch/sh/mm/clear_page.S
--- 25/arch/sh/mm/clear_page.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/mm/clear_page.S	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: clear_page.S,v 1.12 2003/05/10 03:22:05 sugioka Exp $
+/* $Id: clear_page.S,v 1.13 2003/08/25 17:03:10 lethal Exp $
  *
  * __clear_user_page, __clear_user, clear_page implementation of SuperH
  *
@@ -10,10 +10,10 @@
 #include <linux/linkage.h>
 
 /*
- * clear_page
+ * clear_page_slow
  * @to: P1 address
  *
- * void clear_page(void *to)
+ * void clear_page_slow(void *to)
  */
 
 /*
@@ -21,7 +21,7 @@
  * r4 --- to
  * r5 --- to + 4096
  */
-ENTRY(clear_page)
+ENTRY(clear_page_slow)
 	mov	r4,r5
 	mov.w	.Llimit,r0
 	add	r0,r5
diff -puN -L arch/sh/mm/__clear_user_page-sh4.S arch/sh/mm/__clear_user_page-sh4.S~linus /dev/null
--- 25/arch/sh/mm/__clear_user_page-sh4.S
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,49 +0,0 @@
-/* $Id$
- *
- * __clear_user_page implementation of SuperH
- *
- * Copyright (C) 2001  Niibe Yutaka & Kaz Kojima
- *
- */
-
-/*
- * __clear_user_page
- * @to: P1 address (with same color)
- * @orig_to: P1 address
- *
- * void __clear_user_page(void *to, void *orig_to)
- */
-
-/*
- * r0 --- scratch 
- * r4 --- to
- * r5 --- orig_to
- * r6 --- to + 4096
- */
-#include <linux/linkage.h>
-ENTRY(__clear_user_page)
-	mov	r4,r6
-	mov.w	.L4096,r0
-	add	r0,r6
-	mov	#0,r0
-	!
-1:	ocbi	@r5
-	add	#32,r5
-	movca.l	r0,@r4
-	mov	r4,r1
-	add	#32,r4
-	mov.l	r0,@-r4
-	mov.l	r0,@-r4
-	mov.l	r0,@-r4
-	mov.l	r0,@-r4
-	mov.l	r0,@-r4
-	mov.l	r0,@-r4
-	mov.l	r0,@-r4
-	add	#28,r4
-	cmp/eq	r6,r4
-	bf/s	1b
-	 ocbwb	@r1
-	!
-	rts
-	 nop
-.L4096:	.word	4096
diff -puN arch/sh/mm/copy_page.S~linus arch/sh/mm/copy_page.S
--- 25/arch/sh/mm/copy_page.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/mm/copy_page.S	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: copy_page.S,v 1.7 2003/05/04 19:29:54 lethal Exp $
+/* $Id: copy_page.S,v 1.8 2003/08/25 17:03:10 lethal Exp $
  *
  * copy_page, __copy_user_page, __copy_user implementation of SuperH
  *
@@ -9,11 +9,11 @@
 #include <linux/linkage.h>
 
 /*
- * copy_page
+ * copy_page_slow
  * @to: P1 address
  * @from: P1 address
  *
- * void copy_page(void *to, void *from)
+ * void copy_page_slow(void *to, void *from)
  */
 
 /*
@@ -23,7 +23,7 @@
  * r10 --- to
  * r11 --- from
  */
-ENTRY(copy_page)
+ENTRY(copy_page_slow)
 	mov.l	r8,@-r15
 	mov.l	r10,@-r15
 	mov.l	r11,@-r15
diff -puN -L arch/sh/mm/__copy_user_page-sh4.S arch/sh/mm/__copy_user_page-sh4.S~linus /dev/null
--- 25/arch/sh/mm/__copy_user_page-sh4.S
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,69 +0,0 @@
-/* $Id: __copy_user_page-sh4.S,v 1.1 2001/07/23 09:02:17 gniibe Exp $
- *
- * __copy_user_page implementation of SuperH
- *
- * Copyright (C) 2001  Niibe Yutaka & Kaz Kojima
- *
- */
-
-/*
- * __copy_user_page
- * @to: P1 address (with same color)
- * @from: P1 address
- * @orig_to: P1 address
- *
- * void __copy_user_page(void *to, void *from, void *orig_to)
- */
-
-/*
- * r0, r1, r2, r3, r4, r5, r6, r7 --- scratch 
- * r8 --- from + 4096
- * r9 --- orig_to
- * r10 --- to
- * r11 --- from
- */
-#include <linux/linkage.h>
-ENTRY(__copy_user_page)
-	mov.l	r8,@-r15
-	mov.l	r9,@-r15
-	mov.l	r10,@-r15
-	mov.l	r11,@-r15
-	mov	r4,r10
-	mov	r5,r11
-	mov	r6,r9
-	mov	r5,r8
-	mov.w	.L4096,r0
-	add	r0,r8
-	!
-1:	ocbi	@r9
-	add	#32,r9
-	mov.l	@r11+,r0
-	mov.l	@r11+,r1
-	mov.l	@r11+,r2
-	mov.l	@r11+,r3
-	mov.l	@r11+,r4
-	mov.l	@r11+,r5
-	mov.l	@r11+,r6
-	mov.l	@r11+,r7
-	movca.l	r0,@r10
-	mov	r10,r0
-	add	#32,r10
-	mov.l	r7,@-r10
-	mov.l	r6,@-r10
-	mov.l	r5,@-r10
-	mov.l	r4,@-r10
-	mov.l	r3,@-r10
-	mov.l	r2,@-r10
-	mov.l	r1,@-r10
-	ocbwb	@r0
-	cmp/eq	r11,r8
-	bf/s	1b
-	 add	#28,r10
-	!
-	mov.l	@r15+,r11
-	mov.l	@r15+,r10
-	mov.l	@r15+,r9
-	mov.l	@r15+,r8
-	rts
-	 nop
-.L4096:	.word	4096
diff -puN arch/sh/mm/extable.c~linus arch/sh/mm/extable.c
--- 25/arch/sh/mm/extable.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/mm/extable.c	2004-01-19 22:17:21.000000000 -0800
@@ -9,29 +9,6 @@
 #include <linux/module.h>
 #include <asm/uaccess.h>
 
-/* Simple binary search */
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
-		 const struct exception_table_entry *last,
-		 unsigned long value)
-{
-        while (first <= last) {
-		const struct exception_table_entry *mid;
-		long diff;
-
-		mid = (last - first) / 2 + first;
-		diff = mid->insn - value;
-                if (diff == 0)
-                        return mid;
-                else if (diff < 0)
-                        first = mid+1;
-                else
-                        last = mid-1;
-        }
-
-        return NULL;
-}
-
 int fixup_exception(struct pt_regs *regs)
 {
 	const struct exception_table_entry *fixup;
diff -puN arch/sh/mm/fault.c~linus arch/sh/mm/fault.c
--- 25/arch/sh/mm/fault.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/mm/fault.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,7 +1,8 @@
-/* $Id: fault.c,v 1.10 2003/05/04 19:29:54 lethal Exp $
+/* $Id: fault.c,v 1.13 2003/08/11 11:44:50 lethal Exp $
  *
  *  linux/arch/sh/mm/fault.c
  *  Copyright (C) 1999  Niibe Yutaka
+ *  Copyright (C) 2003  Paul Mundt
  *
  *  Based on linux/arch/i386/mm/fault.c:
  *   Copyright (C) 1995  Linus Torvalds
@@ -28,10 +29,7 @@
 #include <asm/hardirq.h>
 #include <asm/mmu_context.h>
 #include <asm/cacheflush.h>
-
-#if defined(CONFIG_SH_KGDB)
 #include <asm/kgdb.h>
-#endif
 
 extern void die(const char *,struct pt_regs *,long);
 
@@ -47,11 +45,10 @@ asmlinkage void do_page_fault(struct pt_
 	struct mm_struct *mm;
 	struct vm_area_struct * vma;
 	unsigned long page;
-	const struct exception_table_entry *fixup;
 
-#if defined(CONFIG_SH_KGDB)
+#ifdef CONFIG_SH_KGDB
 	if (kgdb_nofault && kgdb_bus_err_hook)
-	  kgdb_bus_err_hook();
+		kgdb_bus_err_hook();
 #endif
 
 	tsk = current;
@@ -61,7 +58,7 @@ asmlinkage void do_page_fault(struct pt_
 	 * If we're in an interrupt or have no user
 	 * context, we must not take the fault..
 	 */
-	if (in_interrupt() || !mm)
+	if (in_atomic() || !mm)
 		goto no_context;
 
 	down_read(&mm->mmap_sem);
@@ -95,16 +92,18 @@ good_area:
 	 */
 survive:
 	switch (handle_mm_fault(mm, vma, address, writeaccess)) {
-	case 1:
-		tsk->min_flt++;
-		break;
-	case 2:
-		tsk->maj_flt++;
-		break;
-	case 0:
-		goto do_sigbus;
-	default:
-		goto out_of_memory;
+		case VM_FAULT_MINOR:
+			tsk->min_flt++;
+			break;
+		case VM_FAULT_MAJOR:
+			tsk->maj_flt++;
+			break;
+		case VM_FAULT_SIGBUS:
+			goto do_sigbus;
+		case VM_FAULT_OOM:
+			goto out_of_memory;
+		default:
+			BUG();
 	}
 
 	up_read(&mm->mmap_sem);
@@ -126,11 +125,8 @@ bad_area:
 
 no_context:
 	/* Are we prepared to handle this kernel fault?  */
-	fixup = search_exception_tables(regs->pc);
-	if (fixup) {
-		regs->pc = fixup->fixup;
+	if (fixup_exception(regs))
 		return;
-	}
 
 /*
  * Oops. The kernel tried to access some bad page. We'll have to
@@ -198,16 +194,22 @@ do_sigbus:
 asmlinkage int __do_page_fault(struct pt_regs *regs, unsigned long writeaccess,
 			       unsigned long address)
 {
+	unsigned long addrmax = P4SEG;
 	pgd_t *dir;
 	pmd_t *pmd;
 	pte_t *pte;
 	pte_t entry;
 
-#if defined(CONFIG_SH_KGDB)
+#ifdef CONFIG_SH_KGDB
 	if (kgdb_nofault && kgdb_bus_err_hook)
-	  kgdb_bus_err_hook();
+		kgdb_bus_err_hook();
+#endif
+
+#ifdef CONFIG_SH_STORE_QUEUES
+	addrmax = P4SEG_STORE_QUE + 0x04000000;
 #endif
-	if (address >= P3SEG && address < P4SEG)
+
+	if (address >= P3SEG && address < addrmax)
 		dir = pgd_offset_k(address);
 	else if (address >= TASK_SIZE)
 		return 1;
@@ -233,15 +235,19 @@ asmlinkage int __do_page_fault(struct pt
 	if (writeaccess)
 		entry = pte_mkdirty(entry);
 	entry = pte_mkyoung(entry);
-#if defined(CONFIG_CPU_SH4)
+
+#ifdef CONFIG_CPU_SH4
 	/*
 	 * ITLB is not affected by "ldtlb" instruction.
 	 * So, we need to flush the entry by ourselves.
 	 */
+
 	__flush_tlb_page(get_asid(), address&PAGE_MASK);
 #endif
+
 	set_pte(pte, entry);
 	update_mmu_cache(NULL, address, entry);
+
 	return 0;
 }
 
diff -puN arch/sh/mm/init.c~linus arch/sh/mm/init.c
--- 25/arch/sh/mm/init.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/mm/init.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: init.c,v 1.11 2003/05/27 16:21:23 lethal Exp $
+/* $Id: init.c,v 1.18 2003/10/31 09:26:59 kkojima Exp $
  *
  *  linux/arch/sh/mm/init.c
  *
@@ -24,6 +24,7 @@
 #include <linux/init.h>
 #include <linux/highmem.h>
 #include <linux/bootmem.h>
+#include <linux/pagemap.h>
 
 #include <asm/processor.h>
 #include <asm/system.h>
@@ -55,6 +56,9 @@ pg_data_t discontig_page_data[MAX_NUMNOD
 bootmem_data_t discontig_node_bdata[MAX_NUMNODES];
 #endif
 
+void (*copy_page)(void *from, void *to);
+void (*clear_page)(void *to);
+
 void show_mem(void)
 {
 	int i, total = 0, reserved = 0;
@@ -112,13 +116,13 @@ void __init paging_init(void)
 	{
 		unsigned long max_dma, low, start_pfn;
 		pgd_t *pg_dir;
-	int i;
+		int i;
 
-	/* We don't need kernel mapping as hardware support that. */
-	pg_dir = swapper_pg_dir;
+		/* We don't need kernel mapping as hardware support that. */
+		pg_dir = swapper_pg_dir;
 
 		for (i = 0; i < PTRS_PER_PGD; i++)
-		pgd_val(pg_dir[i]) = 0;
+			pgd_val(pg_dir[i]) = 0;
 
 		/* Turn on the MMU */
 		enable_mmu();
@@ -130,11 +134,13 @@ void __init paging_init(void)
 
 		if (low < max_dma) {
 			zones_size[ZONE_DMA] = low - start_pfn;
+			zones_size[ZONE_NORMAL] = 0;
 		} else {
 			zones_size[ZONE_DMA] = max_dma - start_pfn;
 			zones_size[ZONE_NORMAL] = low - max_dma;
 		}
 	}
+
 #elif defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4)
 	/*
 	 * If we don't have CONFIG_MMU set and the processor in question
@@ -149,17 +155,17 @@ void __init paging_init(void)
 	disable_mmu();
 #endif
 
-		free_area_init_node(0, NODE_DATA(0), 0, zones_size, __MEMORY_START >> PAGE_SHIFT, 0);
+	free_area_init_node(0, NODE_DATA(0), 0, zones_size, __MEMORY_START >> PAGE_SHIFT, 0);
 	/* XXX: MRB-remove - this doesn't seem sane, should this be done somewhere else ?*/
-		mem_map = NODE_DATA(0)->node_mem_map;
+	mem_map = NODE_DATA(0)->node_mem_map;
 
 #ifdef CONFIG_DISCONTIGMEM
 	/*
 	 * And for discontig, do some more fixups on the zone sizes..
 	 */
-		zones_size[ZONE_DMA] = __MEMORY_SIZE_2ND >> PAGE_SHIFT;
-		zones_size[ZONE_NORMAL] = 0;
-		free_area_init_node(1, NODE_DATA(1), 0, zones_size, __MEMORY_START_2ND >> PAGE_SHIFT, 0);
+	zones_size[ZONE_DMA] = __MEMORY_SIZE_2ND >> PAGE_SHIFT;
+	zones_size[ZONE_NORMAL] = 0;
+	free_area_init_node(1, NODE_DATA(1), 0, zones_size, __MEMORY_START_2ND >> PAGE_SHIFT, 0);
 #endif
 }
 
@@ -183,6 +189,13 @@ void __init mem_init(void)
 	memset(empty_zero_page, 0, PAGE_SIZE);
 	__flush_wback_region(empty_zero_page, PAGE_SIZE);
 
+	/* 
+	 * Setup wrappers for copy/clear_page(), these will get overridden
+	 * later in the boot process if a better method is available.
+	 */
+	copy_page = copy_page_slow;
+	clear_page = clear_page_slow;
+
 	/* this will put all low memory onto the freelists */
 	totalram_pages += free_all_bootmem_node(NODE_DATA(0));
 #ifdef CONFIG_DISCONTIGMEM
@@ -195,6 +208,7 @@ void __init mem_init(void)
 		 */
 		if (PageReserved(mem_map+tmp))
 			reservedpages++;
+
 	codesize =  (unsigned long) &_etext - (unsigned long) &_text;
 	datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
 	initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
@@ -238,75 +252,3 @@ void free_initrd_mem(unsigned long start
 }
 #endif
 
-/*
- * Generic first-level cache init
- */
-void __init sh_cache_init(void)
-{
-	extern int detect_cpu_and_cache_system(void);
-	unsigned long ccr, flags = 0;
-
-	detect_cpu_and_cache_system();
-
-	if (cpu_data->type == CPU_SH_NONE)
-		panic("Unknown CPU");
-
-	jump_to_P2();
-	ccr = ctrl_inl(CCR);
-
-	/*
-	 * If the cache is already enabled .. flush it.
-	 */
-	if (ccr & CCR_CACHE_ENABLE) {
-		unsigned long entries, i, j;
-
-		entries = cpu_data->dcache.sets;
-
-		/*
-		 * If the OC is already in RAM mode, we only have
-		 * half of the entries to flush..
-		 */
-		if (ccr & CCR_CACHE_ORA)
-			entries >>= 1;
-
-		for (i = 0; i < entries; i++) {
-			for (j = 0; j < cpu_data->dcache.ways; j++) {
-				unsigned long data, addr;
-
-				addr = CACHE_OC_ADDRESS_ARRAY |
-					(j << cpu_data->dcache.way_shift) |
-					(i << cpu_data->dcache.entry_shift);
-
-				data = ctrl_inl(addr);
-
-				if ((data & (SH_CACHE_UPDATED | SH_CACHE_VALID))
-					== (SH_CACHE_UPDATED | SH_CACHE_VALID))
-					ctrl_outl(data & ~SH_CACHE_UPDATED, addr);
-		}
-		}
-	}
-
-	/* 
-	 * Default CCR values .. enable the caches
-	 * and flush them immediately..
-	 */
-	flags |= CCR_CACHE_ENABLE | CCR_CACHE_INVALIDATE | (ccr & CCR_CACHE_EMODE);
-
-#ifdef CONFIG_SH_WRITETHROUGH
-	/* Turn on Write-through caching */
-	flags |= CCR_CACHE_WT;
-#else
-	/* .. or default to Write-back */
-	flags |= CCR_CACHE_CB;
-#endif
-
-#ifdef CONFIG_SH_OCRAM
-	/* Turn on OCRAM -- halve the OC */
-	flags |= CCR_CACHE_ORA;
-	cpu_data->dcache.sets >>= 1;
-#endif
-
-	ctrl_outl(flags, CCR);
-	back_to_P1();
-}
-
diff -puN arch/sh/mm/ioremap.c~linus arch/sh/mm/ioremap.c
--- 25/arch/sh/mm/ioremap.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/mm/ioremap.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: ioremap.c,v 1.6 2003/05/04 19:29:55 lethal Exp $
+/* $Id: ioremap.c,v 1.8 2003/10/09 15:25:42 lethal Exp $
  *
  * arch/sh/mm/ioremap.c
  *
@@ -140,7 +140,7 @@ void * p3_ioremap(unsigned long phys_add
 	 */
 	offset = phys_addr & ~PAGE_MASK;
 	phys_addr &= PAGE_MASK;
-	size = PAGE_ALIGN(last_addr) - phys_addr;
+	size = PAGE_ALIGN(last_addr+1) - phys_addr;
 
 	/*
 	 * Ok, go for it..
@@ -148,9 +148,10 @@ void * p3_ioremap(unsigned long phys_add
 	area = get_vm_area(size, VM_IOREMAP);
 	if (!area)
 		return NULL;
+	area->phys_addr = phys_addr;
 	addr = area->addr;
 	if (remap_area_pages((unsigned long) addr, phys_addr, size, flags)) {
-		vfree(addr);
+		vunmap(addr);
 		return NULL;
 	}
 	return (void *) (offset + (char *)addr);
diff -puN arch/sh/mm/Makefile~linus arch/sh/mm/Makefile
--- 25/arch/sh/mm/Makefile~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/mm/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -2,14 +2,16 @@
 # Makefile for the Linux SuperH-specific parts of the memory manager.
 #
 
-obj-y			:= init.o extable.o clear_page.o copy_page.o
+obj-y			:= init.o extable.o
 
 obj-$(CONFIG_CPU_SH2)	+= cache-sh2.o
-obj-$(CONFIG_CPU_SH3) += cache-sh3.o
+obj-$(CONFIG_CPU_SH3)	+= cache-sh3.o
 obj-$(CONFIG_CPU_SH4)	+= cache-sh4.o pg-sh4.o
 
-mmu-y			:= fault-nommu.o tlb-nommu.o
-mmu-$(CONFIG_MMU)	:= fault.o
+obj-$(CONFIG_DMA_PAGE_OPS)	+= pg-dma.o
+
+mmu-y			:= fault-nommu.o tlb-nommu.o pg-nommu.o
+mmu-$(CONFIG_MMU)	:= fault.o clear_page.o copy_page.o
 
 obj-y			+= $(mmu-y)
 
diff -puN /dev/null arch/sh/mm/pg-dma.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/mm/pg-dma.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,97 @@
+/*
+ * arch/sh/mm/pg-dma.c
+ *
+ * Fast clear_page()/copy_page() implementation using the SH DMAC
+ *
+ * Copyright (C) 2003  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <asm/semaphore.h>
+#include <asm/mmu_context.h>
+#include <asm/addrspace.h>
+#include <asm/atomic.h>
+#include <asm/page.h>
+#include <asm/dma.h>
+#include <asm/io.h>
+
+/* Channel to use for page ops, must be dual-address mode capable. */
+static int dma_channel = 3;
+
+static void copy_page_dma(void *to, void *from)
+{
+	/* 
+	 * This doesn't seem to get triggered until further along in the
+	 * boot process, at which point the DMAC is already initialized.
+	 * Fix this in the same fashion as clear_page_dma() in the event
+	 * that this crashes due to the DMAC not being initialized.
+	 */
+
+	flush_icache_range((unsigned long)from, PAGE_SIZE);
+	dma_write_page(dma_channel, (unsigned long)from, (unsigned long)to);
+	dma_wait_for_completion(dma_channel);
+}
+
+static void clear_page_dma(void *to)
+{
+	extern unsigned long empty_zero_page[1024];
+
+	/*
+	 * We get invoked quite early on, if the DMAC hasn't been initialized
+	 * yet, fall back on the slow manual implementation.
+	 */
+	if (dma_info[dma_channel].chan != dma_channel) {
+		clear_page_slow(to);
+		return;
+	}
+
+	dma_write_page(dma_channel, (unsigned long)empty_zero_page,
+				    (unsigned long)to);
+
+	/*
+	 * FIXME: Something is a bit racy here, if we poll the counter right
+	 * away, we seem to lock. flushing the page from the dcache doesn't
+	 * seem to make a difference one way or the other, though either a full
+	 * icache or dcache flush does.
+	 *
+	 * The location of this is important as well, and must happen prior to
+	 * the completion loop but after the transfer was initiated.
+	 *
+	 * Oddly enough, this doesn't appear to be an issue for copy_page()..
+	 */
+	flush_icache_range((unsigned long)to, PAGE_SIZE);
+
+	dma_wait_for_completion(dma_channel);
+}
+
+static int __init pg_dma_init(void)
+{
+	int ret;
+	
+	ret = request_dma(dma_channel, "page ops");
+	if (ret != 0)
+		return ret;
+
+	copy_page = copy_page_dma;
+	clear_page = clear_page_dma;
+
+	return ret;
+}
+
+static void __exit pg_dma_exit(void)
+{
+	free_dma(dma_channel);
+}
+
+module_init(pg_dma_init);
+module_exit(pg_dma_exit);
+
+MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>");
+MODULE_DESCRIPTION("Optimized page copy/clear routines using a dual-address mode capable DMAC channel");
+MODULE_LICENSE("GPL");
+
diff -puN /dev/null arch/sh/mm/pg-nommu.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/mm/pg-nommu.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,36 @@
+/*
+ * arch/sh/mm/pg-nommu.c
+ *
+ * clear_page()/copy_page() implementation for MMUless SH.
+ *
+ * Copyright (C) 2003  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <asm/page.h>
+
+static void copy_page_nommu(void *to, void *from)
+{
+	memcpy(to, from, PAGE_SIZE);
+}
+
+static void clear_page_nommu(void *to)
+{
+	memset(to, 0, PAGE_SIZE);
+}
+
+static int __init pg_nommu_init(void)
+{
+	copy_page = copy_page_nommu;
+	clear_page = clear_page_nommu;
+
+	return 0;
+}
+
+subsys_initcall(pg_nommu_init);
+
diff -puN arch/sh/mm/tlb-sh3.c~linus arch/sh/mm/tlb-sh3.c
--- 25/arch/sh/mm/tlb-sh3.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/mm/tlb-sh3.c	2004-01-19 22:17:21.000000000 -0800
@@ -61,6 +61,7 @@ void update_mmu_cache(struct vm_area_str
 void __flush_tlb_page(unsigned long asid, unsigned long page)
 {
 	unsigned long addr, data;
+	int i, ways = MMU_NTLB_WAYS;
 
 	/*
 	 * NOTE: PTEH.ASID should be set to this MM
@@ -68,8 +69,15 @@ void __flush_tlb_page(unsigned long asid
 	 *
 	 * It would be simple if we didn't need to set PTEH.ASID...
 	 */
-	addr = MMU_TLB_ADDRESS_ARRAY |(page & 0x1F000)| MMU_PAGE_ASSOC_BIT;
+	addr = MMU_TLB_ADDRESS_ARRAY | (page & 0x1F000);
 	data = (page & 0xfffe0000) | asid; /* VALID bit is off */
-	ctrl_outl(data, addr);
+	
+	if (test_bit(CPU_HAS_MMU_PAGE_ASSOC, &(cpu_data->flags))) {
+		addr |= MMU_PAGE_ASSOC_BIT;
+		ways = 1;	/* we already know the way .. */
+	}
+
+	for (i = 0; i < ways; i++)
+		ctrl_outl(data, addr + (i << 8));
 }
 
diff -puN /dev/null arch/sh/oprofile/Kconfig
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/oprofile/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,23 @@
+
+menu "Profiling support"
+	depends on EXPERIMENTAL
+
+config PROFILING
+	bool "Profiling support (EXPERIMENTAL)"
+	help
+	  Say Y here to enable the extended profiling support mechanisms used
+	  by profilers such as OProfile.
+	  
+
+config OPROFILE
+	tristate "OProfile system profiling (EXPERIMENTAL)"
+	depends on PROFILING
+	help
+	  OProfile is a profiling system capable of profiling the
+	  whole system, include the kernel, kernel modules, libraries,
+	  and applications.
+
+	  If unsure, say N.
+
+endmenu
+
diff -puN /dev/null arch/sh/oprofile/Makefile
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/oprofile/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,13 @@
+obj-$(CONFIG_OPROFILE) += oprofile.o
+
+DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \
+		oprof.o cpu_buffer.o buffer_sync.o \
+		event_buffer.o oprofile_files.o \
+		oprofilefs.o oprofile_stats.o \
+		timer_int.o )
+
+profdrvr-y				:= op_model_null.o
+profdrvr-$(CONFIG_SH_DREAMCAST)		:= op_model_dreamcast.o
+
+oprofile-y				:= $(DRIVER_OBJS) $(profdrvr-y)
+
diff -puN /dev/null arch/sh/oprofile/op_model_null.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/arch/sh/oprofile/op_model_null.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,23 @@
+/*
+ * arch/sh/oprofile/op_model_null.c
+ *
+ * Copyright (C) 2003  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#include <linux/kernel.h>
+#include <linux/oprofile.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+
+int __init oprofile_arch_init(struct oprofile_operations **ops)
+{
+	return -ENODEV;
+}
+
+void oprofile_arch_exit(void)
+{
+}
+
diff -puN arch/sh/tools/mach-types~linus arch/sh/tools/mach-types
--- 25/arch/sh/tools/mach-types~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sh/tools/mach-types	2004-01-19 22:17:21.000000000 -0800
@@ -7,6 +7,7 @@
 #
 SE			SH_SOLUTION_ENGINE
 7751SE			SH_7751_SOLUTION_ENGINE		
+7751SYSTEMH		SH_7751_SYSTEMH
 HP600			SH_HP600
 HP620			SH_HP620
 HP680			SH_HP680
@@ -19,4 +20,5 @@ DREAMCAST		SH_DREAMCAST
 BIGSUR			SH_BIGSUR
 ADX			SH_ADX
 MPC1211			SH_MPC1211
+SNAPGEAR		SH_SECUREEDGE5410
 
diff -puN arch/sparc64/defconfig~linus arch/sparc64/defconfig
--- 25/arch/sparc64/defconfig~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sparc64/defconfig	2004-01-19 22:17:21.000000000 -0800
@@ -102,6 +102,7 @@ CONFIG_ENVCTRL=m
 CONFIG_DISPLAY7SEG=m
 CONFIG_WATCHDOG_CP1XXX=m
 CONFIG_WATCHDOG_RIO=m
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Generic Driver Options
@@ -1286,6 +1287,7 @@ CONFIG_DVB_CORE=m
 CONFIG_DVB_TWINHAN_DST=m
 CONFIG_DVB_STV0299=m
 CONFIG_DVB_SP887X=m
+CONFIG_DVB_SP887X_FIRMWARE_FILE="/etc/dvb/sc_main.mc"
 CONFIG_DVB_ALPS_TDLB7=m
 CONFIG_DVB_ALPS_TDMB7=m
 CONFIG_DVB_ATMEL_AT76C651=m
@@ -1295,12 +1297,12 @@ CONFIG_DVB_GRUNDIG_29504_401=m
 CONFIG_DVB_MT312=m
 CONFIG_DVB_VES1820=m
 CONFIG_DVB_VES1X93=m
-CONFIG_DVB_SP887X_FIRMWARE_FILE="/etc/dvb/sc_main.mc"
 
 #
 # Supported SAA7146 based PCI Adapters
 #
-# CONFIG_DVB_AV7110 is not set
+CONFIG_DVB_AV7110=m
+# CONFIG_DVB_AV7110_OSD is not set
 CONFIG_DVB_BUDGET=m
 CONFIG_DVB_BUDGET_CI=m
 CONFIG_DVB_BUDGET_AV=m
diff -puN arch/sparc64/Kconfig~linus arch/sparc64/Kconfig
--- 25/arch/sparc64/Kconfig~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sparc64/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -128,6 +128,7 @@ config PREEMPT
 
 config NR_CPUS
 	int "Maximum number of CPUs (2-64)"
+	range 2 64
 	depends on SMP
 	default "64"
 
@@ -489,6 +490,22 @@ config WATCHDOG_RIO
 	  machines.  The watchdog timeout period is normally one minute but
 	  can be changed with a boot-time parameter.
 
+config CMDLINE_BOOL
+	bool "Default bootloader kernel arguments"
+
+config CMDLINE
+	string "Initial kernel command string"
+	depends on CMDLINE_BOOL
+	default "console=ttyS0,9600 root=/dev/sda1"
+	help
+	  Say Y here if you want to be able to pass default arguments to
+	  the kernel. This will be overridden by the bootloader, if you
+	  use one (such as SILO). This is most useful if you want to boot
+	  a kernel from TFTP, and want default options to be available
+	  with having them passed on the command line.
+
+	  NOTE: This option WILL override the PROM bootargs setting!
+
 endmenu
 
 source "drivers/base/Kconfig"
diff -puN arch/sparc64/kernel/head.S~linus arch/sparc64/kernel/head.S
--- 25/arch/sparc64/kernel/head.S~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sparc64/kernel/head.S	2004-01-19 22:17:21.000000000 -0800
@@ -151,6 +151,9 @@ cheetah_generic_boot:
 	blu,pt	%xcc, 1b
 	 add	%l0, (1 << 3), %l0
 
+	/* BUG() if we get here... */
+	ta	0x5
+
 cheetah_got_tlbentry:
 	ldxa	[%l0] ASI_ITLB_DATA_ACCESS, %g0
 	ldxa	[%l0] ASI_ITLB_DATA_ACCESS, %g1
@@ -333,6 +336,9 @@ spitfire_create_mappings:
 	blu,pt	%xcc, 1b
 	 add	%l0, (1 << 3), %l0
 
+	/* BUG() if we get here... */
+	ta	0x5
+
 spitfire_got_tlbentry:
 	/* Nops here again, perhaps Cheetah/Blackbird are better behaved... */
 	nop
diff -puN arch/sparc64/kernel/pci_common.c~linus arch/sparc64/kernel/pci_common.c
--- 25/arch/sparc64/kernel/pci_common.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sparc64/kernel/pci_common.c	2004-01-19 22:17:21.000000000 -0800
@@ -303,14 +303,23 @@ __init get_device_resource(struct linux_
 {
 	struct resource *res;
 	int breg = (ap->phys_hi & 0xff);
-	int space = (ap->phys_hi >> 24) & 3;
 
 	switch (breg) {
 	case  PCI_ROM_ADDRESS:
+		/* Unfortunately I have seen several cases where
+		 * buggy FCODE uses a space value of '1' (I/O space)
+		 * in the register property for the ROM address
+		 * so disable this sanity check for now.
+		 */
+#if 0
+	{
+		int space = (ap->phys_hi >> 24) & 3;
+
 		/* It had better be MEM space. */
 		if (space != 2)
 			bad_assignment(pdev, ap, NULL, 0);
-
+	}
+#endif
 		res = &pdev->resource[PCI_ROM_RESOURCE];
 		break;
 
diff -puN arch/sparc64/mm/extable.c~linus arch/sparc64/mm/extable.c
--- 25/arch/sparc64/mm/extable.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sparc64/mm/extable.c	2004-01-19 22:17:21.000000000 -0800
@@ -9,6 +9,11 @@
 extern const struct exception_table_entry __start___ex_table[];
 extern const struct exception_table_entry __stop___ex_table[];
 
+void sort_extable(struct exception_table_entry *start,
+		  struct exception_table_entry *finish)
+{
+}
+
 /* Caller knows they are in a range if ret->fixup == 0 */
 const struct exception_table_entry *
 search_extable(const struct exception_table_entry *start,
diff -puN arch/sparc64/prom/bootstr.c~linus arch/sparc64/prom/bootstr.c
--- 25/arch/sparc64/prom/bootstr.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sparc64/prom/bootstr.c	2004-01-19 22:17:21.000000000 -0800
@@ -21,6 +21,10 @@ struct {
 	char bootstr_buf[BARG_LEN];
 } bootstr_info = {
 	.bootstr_len = BARG_LEN,
+#ifdef CONFIG_CMDLINE
+	.bootstr_valid = 1,
+	.bootstr_buf = CONFIG_CMDLINE,
+#endif
 };
 
 char * __init
diff -puN arch/sparc/Kconfig~linus arch/sparc/Kconfig
--- 25/arch/sparc/Kconfig~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sparc/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -112,6 +112,7 @@ config SMP
 
 config NR_CPUS
 	int "Maximum number of CPUs (2-32)"
+	range 2 32
 	depends on SMP
 	default "32"
 
diff -puN arch/sparc/kernel/irq.c~linus arch/sparc/kernel/irq.c
--- 25/arch/sparc/kernel/irq.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sparc/kernel/irq.c	2004-01-19 22:17:21.000000000 -0800
@@ -49,6 +49,9 @@
 #include <asm/pcic.h>
 #include <asm/cacheflush.h>
 
+/* Used to protect the IRQ action lists */
+spinlock_t irq_action_lock = SPIN_LOCK_UNLOCKED;
+
 /*
  * Dave Redman (djhr@tadpole.co.uk)
  *
@@ -492,7 +495,7 @@ int request_fast_irq(unsigned int irq,
 		return -EBUSY;
 	}
 
-	save_and_cli(flags);
+	spin_lock_irqsave(&irq_action_lock, flags);
 
 	/* If this is flagged as statically allocated then we use our
 	 * private struct which is never freed.
@@ -507,10 +510,10 @@ int request_fast_irq(unsigned int irq,
 	
 	if (action == NULL)
 	    action = (struct irqaction *)kmalloc(sizeof(struct irqaction),
-						 GFP_KERNEL);
+						 GFP_ATOMIC);
 	
 	if (!action) { 
-		restore_flags(flags);
+		spin_unlock_irqrestore(&irq_action_lock, flags);
 		return -ENOMEM;
 	}
 
@@ -547,7 +550,7 @@ int request_fast_irq(unsigned int irq,
 	*(cpu_irq + irq_action) = action;
 
 	enable_irq(irq);
-	restore_flags(flags);
+	spin_unlock_irqrestore(&irq_action_lock, flags);
 	return 0;
 }
 
@@ -586,7 +589,7 @@ int request_irq(unsigned int irq,
 		action = NULL;		/* Or else! */
 	}
 
-	save_and_cli(flags);
+	spin_lock_irqsave(&irq_action_lock, flags);
 
 	/* If this is flagged as statically allocated then we use our
 	 * private struct which is never freed.
@@ -600,10 +603,10 @@ int request_irq(unsigned int irq,
 	
 	if (action == NULL)
 	    action = (struct irqaction *)kmalloc(sizeof(struct irqaction),
-						 GFP_KERNEL);
+						 GFP_ATOMIC);
 	
 	if (!action) { 
-		restore_flags(flags);
+		spin_unlock_irqrestore(&irq_action_lock, flags);
 		return -ENOMEM;
 	}
 
@@ -620,7 +623,7 @@ int request_irq(unsigned int irq,
 		*(cpu_irq + irq_action) = action;
 
 	enable_irq(irq);
-	restore_flags(flags);
+	spin_unlock_irqrestore(&irq_action_lock, flags);
 	return 0;
 }
 
diff -puN arch/sparc/mm/extable.c~linus arch/sparc/mm/extable.c
--- 25/arch/sparc/mm/extable.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sparc/mm/extable.c	2004-01-19 22:17:21.000000000 -0800
@@ -6,6 +6,11 @@
 #include <linux/module.h>
 #include <asm/uaccess.h>
 
+void sort_extable(struct exception_table_entry *start,
+		  struct exception_table_entry *finish)
+{
+}
+
 /* Caller knows they are in a range if ret->fixup == 0 */
 const struct exception_table_entry *
 search_extable(const struct exception_table_entry *start,
diff -puN arch/sparc/mm/fault.c~linus arch/sparc/mm/fault.c
--- 25/arch/sparc/mm/fault.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sparc/mm/fault.c	2004-01-19 22:17:21.000000000 -0800
@@ -36,7 +36,6 @@
 
 #define ELEMENTS(arr) (sizeof (arr)/sizeof (arr[0]))
 
-extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS+1];
 extern int prom_node_root;
 
 /* At boot time we determine these two values necessary for setting
diff -puN arch/sparc/mm/srmmu.c~linus arch/sparc/mm/srmmu.c
--- 25/arch/sparc/mm/srmmu.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/sparc/mm/srmmu.c	2004-01-19 22:17:21.000000000 -0800
@@ -349,7 +349,7 @@ void srmmu_free_nocache(unsigned long va
 		    vaddr, (unsigned long)SRMMU_NOCACHE_VADDR);
 		BUG();
 	}
-	if (vaddr+size >= srmmu_nocache_end) {
+	if (vaddr+size > srmmu_nocache_end) {
 		printk("Vaddr %lx is bigger than nocache end 0x%lx\n",
 		    vaddr, srmmu_nocache_end);
 		BUG();
@@ -1071,7 +1071,7 @@ void __init srmmu_early_allocate_ptable_
 		}
 		if (start > (0xffffffffUL - SRMMU_PMD_SIZE_SOFT))
 			break;
-		start = (start + SRMMU_PMD_SIZE) & SRMMU_PMD_MASK;
+		start = (start + SRMMU_PMD_SIZE_SOFT) & SRMMU_PMD_MASK_SOFT;
 	}
 }
 
@@ -1101,7 +1101,7 @@ void __init srmmu_allocate_ptable_skelet
 		}
 		if (start > (0xffffffffUL - SRMMU_PMD_SIZE_SOFT))
 			break;
-		start = (start + SRMMU_PMD_SIZE) & SRMMU_PMD_MASK;
+		start = (start + SRMMU_PMD_SIZE_SOFT) & SRMMU_PMD_MASK_SOFT;
 	}
 }
 
diff -puN arch/um/Kconfig~linus arch/um/Kconfig
--- 25/arch/um/Kconfig~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/um/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -128,6 +128,7 @@ config SMP
 
 config NR_CPUS
 	int "Maximum number of CPUs (2-32)"
+	range 2 32
 	depends on SMP
 	default "32"
 
diff -puN arch/x86_64/Kconfig~linus arch/x86_64/Kconfig
--- 25/arch/x86_64/Kconfig~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/x86_64/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -233,6 +233,7 @@ config HAVE_DEC_LOCK
 # to use clustered mode or whatever your big iron needs
 config NR_CPUS
 	int "Maximum number of CPUs (2-8)"
+	range 2 8
 	depends on SMP
 	default "8"
 	help
diff -puN arch/x86_64/mm/extable.c~linus arch/x86_64/mm/extable.c
--- 25/arch/x86_64/mm/extable.c~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/arch/x86_64/mm/extable.c	2004-01-19 22:17:21.000000000 -0800
@@ -36,10 +36,9 @@ search_extable(const struct exception_ta
 
 /* When an exception handler is in an non standard section (like __init)
    the fixup table can end up unordered. Fix that here. */
-static __init int check_extable(void)
+void sort_extable(struct exception_table_entry *start,
+		  struct exception_table_entry *finish)
 {
-	extern struct exception_table_entry __start___ex_table[];
-	extern struct exception_table_entry  __stop___ex_table[];
 	struct exception_table_entry *e;
 	int change;
 
@@ -47,7 +46,7 @@ static __init int check_extable(void)
 	   best (and simplest) sort algorithm. */
 	do {
 		change = 0;
-		for (e = __start___ex_table+1; e < __stop___ex_table; e++) {
+		for (e = start+1; e < finish; e++) {
 			if (e->insn < e[-1].insn) {
 				struct exception_table_entry tmp = e[-1];
 				e[-1] = e[0];
@@ -58,4 +57,3 @@ static __init int check_extable(void)
 	} while (change != 0);
 	return 0;
 }
-core_initcall(check_extable);
diff -puN CREDITS~linus CREDITS
--- 25/CREDITS~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/CREDITS	2004-01-19 22:17:09.000000000 -0800
@@ -1394,7 +1394,9 @@ S: USA
 N: Marcel Holtmann
 E: marcel@holtmann.org
 W: http://www.holtmann.org
+D: Maintainer of the Linux Bluetooth Subsystem
 D: Author and maintainer of the various Bluetooth HCI drivers
+D: Author and maintainer of the CAPI message transport protocol driver
 D: Various other Bluetooth related patches, cleanups and fixes
 S: Germany
 
diff -puN Documentation/devices.txt~linus Documentation/devices.txt
--- 25/Documentation/devices.txt~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/Documentation/devices.txt	2004-01-19 22:17:09.000000000 -0800
@@ -2526,17 +2526,17 @@ Your cooperation is appreciated.
 		  1 = /dev/dri/card1		Second graphics card
 		    ...
 
-227 char	IBM 3270 terminal block-mode access
+227 char	IBM 3270 terminal Unix tty access
+		  1 = /dev/3270/tty1		First 3270 terminal
+		  2 = /dev/3270/tty2		Seconds 3270 terminal
+		    ...
+
+228 char	IBM 3270 terminal block-mode access
 		  0 = /dev/3270/tub		Controlling interface
 		  1 = /dev/3270/tub1		First 3270 terminal
 		  2 = /dev/3270/tub2		Second 3270 terminal
 		    ...
 
-228 char	IBM 3270 terminal Unix tty access
-		  1 = /dev/3270/tty1		First 3270 terminal
-		  2 = /dev/3270/tty2		Seconds 3270 terminal
-		    ...
-
 229 char	IBM iSeries virtual console
 		  0 = /dev/iseries/vtty0	First console port
 		  1 = /dev/iseries/vtty1	Second console port
diff -puN Documentation/DocBook/kernel-locking.tmpl~linus Documentation/DocBook/kernel-locking.tmpl
--- 25/Documentation/DocBook/kernel-locking.tmpl~linus	2004-01-19 22:17:04.000000000 -0800
+++ 25-akpm/Documentation/DocBook/kernel-locking.tmpl	2004-01-19 22:17:09.000000000 -0800
@@ -66,6 +66,7 @@
      fundamentals of concurrency and locking for
      <firstterm linkend="gloss-smp"><acronym>SMP</acronym></firstterm>.
    </para>
+  </chapter>
 
    <chapter id="races">
     <title>The Problem With Concurrency</title>
@@ -193,6 +194,7 @@
       And then there are the unfriendly primitives, but I'll pretend
       they don't exist.
     </para>
+    </sect1>
   </chapter>
 
   <chapter id="locks">
@@ -657,6 +659,7 @@
 </TBODY>
 </TGROUP>
 </TABLE>
+</sect1>
 </chapter>
 
   <chapter id="Examples">
@@ -1110,6 +1113,7 @@ used to protect the reference count itse
          return obj;
  }
 </programlisting>
+</sect2>
 </sect1>
 
    <sect1 id="examples-lock-per-obj">
@@ -1229,6 +1233,7 @@ which locks.  This is extremely importan
 behavior of the code, and can be hard to gain from just reading.  And
 as Alan Cox says, <quote>Lock data, not code</quote>.
 </para>
+</sect1>
 </chapter>
 
    <chapter id="common-problems">
@@ -1317,6 +1322,7 @@ as Alan Cox says, <quote>Lock data, not 
       The two CPUs will spin forever, waiting for the other to give up
       their lock.  It will look, smell, and feel like a crash.
     </para>
+    </sect1>
 
     <sect1 id="techs-deadlock-prevent">
      <title>Preventing Deadlock</title>
@@ -1886,6 +1892,7 @@ machines due to caching.
       </para>
      </listitem>
     </itemizedlist>
+   </sect1>
 
    <sect1 id="dont-sleep">
     <title>Some Functions Which Don't Sleep</title>
diff -puN Documentation/fb/modedb.txt~linus Documentation/fb/modedb.txt
--- 25/Documentation/fb/modedb.txt~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/Documentation/fb/modedb.txt	2004-01-19 22:17:09.000000000 -0800
@@ -55,6 +55,7 @@ There may be more modes.
     aty128fb	- ATI Rage128 / Pro frame buffer
     atyfb	- ATI Mach64 frame buffer
     tdfx	- 3D Fx frame buffer
+    tridentfb	- Trident (Cyber)blade chipset frame buffer
 
 BTW, only a few drivers use this at the moment. Others are to follow
 (feel free to send patches).
diff -puN Documentation/fb/tridentfb.txt~linus Documentation/fb/tridentfb.txt
--- 25/Documentation/fb/tridentfb.txt~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/Documentation/fb/tridentfb.txt	2004-01-19 22:17:09.000000000 -0800
@@ -11,10 +11,15 @@ Only PCI/AGP based cards are supported, 
 
 How to use it?
 ==============
-Just do your usual console work :)
 
-When booting you can pass the following parameters
-==================================================
+When booting you can pass the video parameter.
+video=tridentfb
+
+The parameters for tridentfb are concatenated with a ':' as in this example.
+
+video=tridentfb:800x600,bpp=16,noaccel
+
+The second level parameters that tridentfb understands are:
 
 noaccel - turns off acceleration (when it doesn't work for your card)
 accel - force text acceleration (for boards which by default are noacceled)
diff -puN Documentation/filesystems/ntfs.txt~linus Documentation/filesystems/ntfs.txt
--- 25/Documentation/filesystems/ntfs.txt~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/Documentation/filesystems/ntfs.txt	2004-01-19 22:17:09.000000000 -0800
@@ -272,6 +272,9 @@ ChangeLog
 
 Note, a technical ChangeLog aimed at kernel hackers is in fs/ntfs/ChangeLog.
 
+2.1.6:
+	- Fix minor bug in handling of compressed directories that fixes the
+	  erroneous "du" and "stat" output people reported.
 2.1.5:
 	- Minor bug fix in attribute list attribute handling that fixes the
 	  I/O errors on "ls" of certain fragmented files found by at least two
diff -puN Documentation/i2c/porting-clients~linus Documentation/i2c/porting-clients
--- 25/Documentation/i2c/porting-clients~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/Documentation/i2c/porting-clients	2004-01-19 22:17:09.000000000 -0800
@@ -92,7 +92,10 @@ Technical changes:
   i2c_get_clientdata(client) instead.
 
 * [Interface] Init function should not print anything. Make sure
-  there is a MODULE_LICENSE() line.
+  there is a MODULE_LICENSE() line. MODULE_PARM() is replaced
+  by module_param(). Note that module_param has a third parameter,
+  that you should set to 0 by default. See include/linux/moduleparam.h
+  for details.
 
 Coding policy:
 
diff -puN Documentation/i386/zero-page.txt~linus Documentation/i386/zero-page.txt
--- 25/Documentation/i386/zero-page.txt~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/Documentation/i386/zero-page.txt	2004-01-19 22:17:09.000000000 -0800
@@ -28,8 +28,13 @@ Offset	Type		Description
 
  0xa0	16 bytes	System description table truncated to 16 bytes.
 			( struct sys_desc_table_struct )
- 0xb0 - 0x1df		Free. Add more parameters here if you really need them.
+ 0xb0 - 0x1c3		Free. Add more parameters here if you really need them.
 
+0x1c4	unsigned long	EFI system table pointer
+0x1c8	unsigned long	EFI memory descriptor size
+0x1cc	unsigned long	EFI memory descriptor version
+0x1d0	unsigned long	EFI memory descriptor map pointer
+0x1d4	unsigned long	EFI memory descriptor map size
 0x1e0	unsigned long	ALT_MEM_K, alternative mem check, in Kb
 0x1e8	char		number of entries in E820MAP (below)
 0x1e9	unsigned char	number of entries in EDDBUF (below)
diff -puN Documentation/kernel-parameters.txt~linus Documentation/kernel-parameters.txt
--- 25/Documentation/kernel-parameters.txt~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/Documentation/kernel-parameters.txt	2004-01-19 22:17:09.000000000 -0800
@@ -37,7 +37,7 @@ restrictions referred to are that the re
 	MCA	MCA bus support is enabled.
 	MDA	MDA console support is enabled.
 	MOUSE	Appropriate mouse support is enabled.
-	MTD	MTD support is nebaled.
+	MTD	MTD support is enabled.
 	NET	Appropriate network support is enabled.
 	NFS	Appropriate NFS support is enabled.
 	OSS	OSS sound support is enabled.
@@ -57,6 +57,7 @@ restrictions referred to are that the re
 	SMP	The kernel is an SMP kernel.
 	SPARC	Sparc architecture is enabled.
 	SWSUSP	Software suspension is enabled.
+	TS	Appropriate touchscreen support is enabled.
 	USB	USB support is enabled.
 	V4L	Video For Linux support is enabled.
 	VGA	The VGA console has been enabled.
@@ -85,6 +86,9 @@ running once the system is up.
 			See header of drivers/scsi/53c7xx.c.
 			See also Documentation/scsi/ncr53c7xx.txt.
 
+	98busmouse.irq=	[HW,MOUSE] PC-9801 Bus Mouse Driver
+			Format: <irq>, default is 13
+
 	acpi=		[HW,ACPI] Advanced Configuration and Power Interface 
 			Format: { force | off | ht }
 			force -- enables ACPI for systems with default off
@@ -153,10 +157,11 @@ running once the system is up.
 
 	atascsi=	[HW,SCSI] Atari SCSI
 
-	atkbd_set=	[HW] Select keyboard code set
+	atkbd.set=	[HW] Select keyboard code set
 			Format: <int>
-
-	atkbd_reset	[HW] Reset keyboard during initialization
+	atkbd.softrepeat=
+			[HW] Use software keyboard repeat
+	atkbd.reset=	[HW] Reset keyboard during initialization
 
 	autotest	[IA64]
 
@@ -372,13 +377,15 @@ running once the system is up.
 
 	noirqbalance	[IA-32,SMP,KNL] Disable kernel irq balancing
 
-	i8042_direct	[HW] Keyboard has been put into non-translated mode 
-			by BIOS
-	i8042_dumbkbd	[HW] Don't attempt to blink the leds
-	i8042_noaux	[HW] Don't check for auxiliary (== mouse) port
-	i8042_nomux
-	i8042_reset	[HW] Reset the controller during init and cleanup
-	i8042_unlock	[HW] Unlock (ignore) the keylock
+	i8042.direct	[HW] Put keyboard port into non-translated mode
+	i8042.dumbkbd	[HW] Pretend that controlled can only read data from
+			     keyboard and can not control its state
+			     (Don't attempt to blink the leds)
+	i8042.noaux	[HW] Don't check for auxiliary (== mouse) port
+	i8042.nomux	[HW] Don't check presence of an active multiplexing
+			     controller
+	i8042.reset	[HW] Reset the controller during init and cleanup
+	i8042.unlock	[HW] Unlock (ignore) the keylock
 
 	i810=		[HW,DRM]
 
@@ -414,7 +421,7 @@ running once the system is up.
 
 	initrd=		[BOOT] Specify the location of the initial ramdisk
 
-	inport_irq=	[HW] Inport (ATI XL and Microsoft) busmouse driver
+	inport.irq=	[HW] Inport (ATI XL and Microsoft) busmouse driver
 			Format: <irq>
 
 	inttest=	[IA64]
@@ -462,7 +469,7 @@ running once the system is up.
 
 	lockd.tcpport=	[NFS]
 
-	logibm_irq=	[HW,MOUSE] Logitech Bus Mouse Driver
+	logibm.irq=	[HW,MOUSE] Logitech Bus Mouse Driver
 			Format: <irq>
 
 	log_buf_len=n	Sets the size of the printk ring buffer, in bytes.
@@ -562,6 +569,11 @@ running once the system is up.
 
 	mga=		[HW,DRM]
 
+	mousedev.xres	[MOUSE] Horizontal screen resolution, used for devices
+			reporting absolute coordinates, such as tablets
+	mousedev.yres	[MOUSE] Vertical screen resolution, used for devices
+			reporting absolute coordinates, such as tablets
+
 	mpu401=		[HW,OSS]
 			Format: <io>,<irq>
 
@@ -795,12 +807,18 @@ running once the system is up.
 			before loading.
 			See Documentation/ramdisk.txt.
 
-	psmouse_proto=  [HW,MOUSE] Highest PS2 mouse protocol extension to
+	psmouse.proto=  [HW,MOUSE] Highest PS2 mouse protocol extension to
 			probe for (bare|imps|exps).
-
-	psmouse_resetafter=
+	psmouse.rate=	[HW,MOUSE] Set desired mouse report rate, in reports
+			per second.
+	psmouse.resetafter=
 			[HW,MOUSE] Try to reset Synaptics Touchpad after so many
 			bad packets (0 = never).
+	psmouse.resolution=
+			[HW,MOUSE] Set desired mouse resolution, in dpi.
+	psmouse.smartscroll=
+			[HW,MOUSE] Controls Logitech smartscroll autorepeat,
+			0 = disabled, 1 = enabled (default).
 
 	pss=		[HW,OSS] Personal Sound System (ECHO ESC614)
 			Format: <io>,<mss_io>,<mss_irq>,<mss_dma>,<mpu_io>,<mpu_irq>
@@ -1118,6 +1136,9 @@ running once the system is up.
 	trix=		[HW,OSS] MediaTrix AudioTrix Pro
 			Format: <io>,<irq>,<dma>,<dma2>,<sb_io>,<sb_irq>,<sb_dma>,<mpu_io>,<mpu_irq>
  
+	tsdev.xres	[TS] Horizontal screen resolution.
+	tsdev.yres	[TS] Vertical screen resolution.
+
 	u14-34f=	[HW,SCSI] UltraStor 14F/34F SCSI host adapter
 			See header of drivers/scsi/u14-34f.c.
 
diff -puN Documentation/m68k/00-INDEX~linus Documentation/m68k/00-INDEX
--- 25/Documentation/m68k/00-INDEX~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/Documentation/m68k/00-INDEX	2004-01-19 22:17:09.000000000 -0800
@@ -1,7 +1,5 @@
 00-INDEX
 	- this file
-framebuffer.txt
-	- info about the Linux/m68k frame buffer device
 kernel-options.txt
 	- command line options for Linux/m68k
 
diff -puN Documentation/networking/ip-sysctl.txt~linus Documentation/networking/ip-sysctl.txt
--- 25/Documentation/networking/ip-sysctl.txt~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/Documentation/networking/ip-sysctl.txt	2004-01-19 22:17:09.000000000 -0800
@@ -667,6 +667,13 @@ regen_max_retry - INTEGER
 	valid temporary addresses.
 	Default: 5
 
+max_addresses - INTEGER
+	Number of maximum addresses per interface.  0 disables limitation.
+	It is recommended not set too large value (or 0) because it would 
+	be too easy way to crash kernel to allow to create too much of 
+	autoconfigured addresses.
+	Default: 16
+
 icmp/*:
 ratelimit - INTEGER
 	Limit the maximal rates for sending ICMPv6 packets.
diff -puN Documentation/networking/sk98lin.txt~linus Documentation/networking/sk98lin.txt
--- 25/Documentation/networking/sk98lin.txt~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/Documentation/networking/sk98lin.txt	2004-01-19 22:17:09.000000000 -0800
@@ -2,9 +2,9 @@
 All rights reserved
 ===========================================================================
 
-sk98lin.txt created 23-Sep-2003
+sk98lin.txt created 15-Dec-2003
 
-Readme File for sk98lin v6.18
+Readme File for sk98lin v6.21
 Marvell Yukon/SysKonnect SK-98xx Gigabit Ethernet Adapter family driver for LINUX
 
 This file contains
@@ -466,7 +466,7 @@ The Marvell Yukon/SysKonnect Linux drive
 Link Aggregation according to IEEE standards 802.1, 802.1q, and 802.3ad. 
 These features are only available after installation of open source 
 modules available on the Internet:
-For VLAN go to: http://scry.wanfear.com/~greear/vlan.html
+For VLAN go to: http://www.candelatech.com/~greear/vlan.html
 For Link Aggregation go to: http://www.st.rim.or.jp/~yumo
 
 NOTE: SysKonnect GmbH does not offer any support for these open source 
diff -puN Documentation/power/swsusp.txt~linus Documentation/power/swsusp.txt
--- 25/Documentation/power/swsusp.txt~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/Documentation/power/swsusp.txt	2004-01-19 22:17:09.000000000 -0800
@@ -17,13 +17,30 @@ From kernel/suspend.c:
 You need to append resume=/dev/your_swap_partition to kernel command
 line. Then you suspend by echo 4 > /proc/acpi/sleep.
 
-[Notice. Rest docs is pretty outdated (see date!) It should be safe to
-use swsusp on ext3/reiserfs these days.]
+Pavel's unreliable guide to swsusp mess
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+There are currently two versions of swap suspend in the kernel, the old
+"Pavel's" version in kernel/power/swsusp.c and the new "Patrick's"
+version in kernel/power/pmdisk.c. They provide the same functionality;
+the old version looks ugly but was tested, while the new version looks
+nicer but did not receive so much testing. echo 4 > /proc/acpi/sleep
+calls the old version, echo disk > /sys/power/state calls the new one.
+
+[In the future, when the new version is stable enough, two things can
+happen:
+
+* the new version is moved into swsusp.c, and swsusp is renamed to swap
+  suspend (Pavel prefers this)
+
+* pmdisk is kept as is and swsusp.c is removed from the kernel]
+
 
 
 Article about goals and implementation of Software Suspend for Linux
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Author: G‚ábor Kuti
-Last revised: 2002-04-08
+Last revised: 2003-10-20 by Pavel Machek
 
 Idea and goals to achieve
 
@@ -36,84 +53,23 @@ real high when running from batteries. T
 interrupt our programs so processes that are calculating something for a long
 time shouldn't need to be written interruptible.
 
-On desk machines the power saving function isn't as important as it is in
-laptops but we really may benefit from the second one. Nowadays the number of
-desk machines supporting suspend function in their APM is going up but there
-are (and there will still be for a long time) machines that don't even support
-APM of any kind. On the other hand it is reported that using APM's suspend
-some irqs (e.g. ATA disk irq) is lost and it is annoying for the user until
-the Linux kernel resets the device.
-
-So I started thinking about implementing Software Suspend which doesn't need
-any APM support and - since it uses pretty near only high-level routines - is
-supposed to be architecture independent code.
-
 Using the code
 
-The code is experimental right now - testers, extra eyes are welcome. To
-compile this support into the kernel, you need CONFIG_EXPERIMENTAL, 
-and then CONFIG_SOFTWARE_SUSPEND in menu General Setup to be  enabled. It
-cannot be used as a module and I don't think it will ever be needed.
-
-You have two ways to use this code. The first one is if you've compiled in
-sysrq support then you may press Sysrq-D to request suspend. The other way
-is with a patched SysVinit (my patch is against 2.76 and available at my
-home page). You might call 'swsusp' or 'shutdown -z <time>'. Next way is to
-echo 4 > /proc/acpi/sleep.
+You have two ways to use this code. The first one is is with a patched
+SysVinit (my patch is against 2.76 and available at my home page). You
+might call 'swsusp' or 'shutdown -z <time>'. Next way is to echo 4 >
+/proc/acpi/sleep.
 
 Either way it saves the state of the machine into active swaps and then
 reboots.  You must explicitly specify the swap partition to resume from with
 ``resume='' kernel option. If signature is found it loads and restores saved
 state. If the option ``noresume'' is specified as a boot parameter, it skips
-the resuming.  Warning! Look at section ``Things to implement'' to see what
-isn't yet implemented.  Also I strongly suggest you to list all active swaps
-in /etc/fstab. Firstly because you don't have to specify anything to resume
-and secondly if you have more than one swap area you can't decide which one
-has the 'root' signature. 
+the resuming.
 
 In the meantime while the system is suspended you should not touch any of the
 hardware!
 
 About the code
-Goals reached
-
-The code can be downloaded from
-http://falcon.sch.bme.hu/~seasons/linux/. It mainly works but there are still
-some of XXXs, TODOs, FIXMEs in the code which seem not to be too important. It
-should work all right except for the problems listed in ``Things to
-implement''. Notes about the code are really welcome.
-
-How the code works
-
-When suspending is triggered it immediately wakes up process bdflush. Bdflush
-checks whether we have anything in our run queue tq_bdflush. Since we queued up
-function do_software_suspend, it is called. Here we shrink everything including
-dcache, inodes, buffers and memory (here mainly processes are swapped out). We
-count how many pages we need to duplicate (we have to be atomical!) then we
-create an appropriate sized page directory. It will point to the original and
-the new (copied) address of the page. We get the free pages by
-__get_free_pages() but since it changes state we have to be able to track it
-later so it also flips in a bit in page's flags (a new Nosave flag). We
-duplicate pages and then mark them as used (so atomicity is ensured). After
-this we write out the image to swaps, do another sync and the machine may
-reboot. We also save registers to stack.
-
-By resuming an ``inverse'' method is executed. The image if exists is loaded,
-loadling is either triggered by ``resume='' kernel option.  We
-change our task to bdflush (it is needed because if we don't do this init does
-an oops when it is waken up later) and then pages are copied back to their
-original location. We restore registers, free previously allocated memory,
-activate memory context and task information. Here we should restore hardware
-state but even without this the machine is restored and processes are continued
-to work. I think hardware state should be restored by some list (using
-notify_chain) and probably by some userland program (run-parts?) for users'
-pleasure. Check out my patch at the same location for the sysvinit patch.
-
-WARNINGS!
-- It does not like pcmcia cards. And this is logical: pcmcia cards need
-  cardmgr to be initialized. they are not initialized during singleuser boot,
-  but "resumed" kernel does expect them to be initialized. That leads to
-  armagedon. You should eject any pcmcia cards before suspending.
 
 Things to implement
 - SMP support. I've done an SMP support but since I don't have access to a kind
@@ -122,34 +78,14 @@ Things to implement
   interrupts AFAIK..
 - We should only make a copy of data related to kernel segment, since any
   process data won't be changed.
-- Hardware state restoring.  Now there's support for notifying via the notify
-  chain, event handlers are welcome. Some devices may have microcodes loaded
-  into them. We should have event handlers for them as well.
-- We should support other architectures (There are really only some arch
-  related functions..)
-- We should also restore original state of swaps if the ``noresume'' kernel
-  option is specified.. Or do we need such a feature to save state for some
-  other time? Do we need some kind of ``several saved states''?  (Linux-HA
-  people?). There's been some discussion about checkpointing on linux-future.
 - Should make more sanity checks. Or are these enough?
 
 Not so important ideas for implementing
 
 - If a real time process is running then don't suspend the machine.
-- Support for power.conf file as in Solaris, autoshutdown, special
-  devicetypes support, maybe in sysctl.
-- Introduce timeout for SMP locking. But first locking ought to work :O
-- Pre-detect if we don't have enough swap space or free it instead of
-  calling panic.
 - Support for adding/removing hardware while suspended?
 - We should not free pages at the beginning so aggressively, most of them
   go there anyway..
-- If X is active while suspending then by resuming calling svgatextmode
-  corrupts the virtual console of X.. (Maybe this has been fixed AFAIK).
-
-Drivers we support
-- IDE disks are okay
-- vesafb
 
 Drivers that need support
 - pc_keyb -- perhaps we can wait for vojtech's input patches
diff -puN /dev/null Documentation/power/video.txt
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/Documentation/power/video.txt	2004-01-19 22:17:09.000000000 -0800
@@ -0,0 +1,36 @@
+
+		Video issues with S3 resume
+		~~~~~~~~~~~~~~~~~~~~~~~~~~~
+		     2003, Pavel Machek
+
+During S3 resume, hardware needs to be reinitialized. For most
+devices, this is easy, and kernel driver knows how to do
+it. Unfortunately there's one exception: video card. Those are usually
+initialized by BIOS, and kernel does not have enough information to
+boot video card. (Kernel usually does not even contain video card
+driver -- vesafb and vgacon are widely used).
+
+This is not problem for swsusp, because during swsusp resume, BIOS is
+run normally so video card is normally initialized.
+
+There are three types of systems where video works after S3 resume:
+
+* systems where video state is preserved over S3. (HP Omnibook xe3)
+
+* systems that initialize video card into vga text mode and where BIOS
+  works well enough to be able to set video mode. Use
+  acpi_sleep=s3_mode on these. (Toshiba 4030cdt)
+
+* systems where it is possible to call video bios during S3
+  resume. Unfortunately, it is not correct to call video BIOS at that
+  point, but it happens to work on some machines. Use
+  acpi_sleep=s3_bios (Athlon64 desktop system)
+
+Now, if you pass acpi_sleep=something, and it does not work with your
+bios, you'll get hard crash during resume. Be carefull.
+
+You may have system where none of above works. At that point you
+either invent another ugly hack that works, or write proper driver for
+your video card (good luck getting docs :-(). Maybe suspending from X
+(proper X, knowing your hardware, not XF68_FBcon) might have better
+chance of working.
diff -puN Documentation/s390/driver-model.txt~linus Documentation/s390/driver-model.txt
--- 25/Documentation/s390/driver-model.txt~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/Documentation/s390/driver-model.txt	2004-01-19 22:17:09.000000000 -0800
@@ -32,6 +32,9 @@ cutype:	    The control unit type / mode
 devtype:    The device type / model, if applicable.
 
 online:     An interface to set the device online and offline.
+	    In the special case of the device being disconnected (see the
+	    notify function under 1.2), piping 0 to online will focibly delete
+	    the device.
 
 The device drivers can add entries to export per-device data and interfaces.
 
@@ -82,6 +85,7 @@ struct ccw_driver {
 	int (*remove) (struct ccw_device *);
 	int (*set_online) (struct ccw_device *);
 	int (*set_offline) (struct ccw_device *);
+	int (*notify) (struct ccw_device *, int);
 	struct device_driver driver;
 	char *name;
 };
@@ -143,6 +147,28 @@ Parameters:   cdev       - the device to
 			   verified that the device is online.
 
 
+notify: This function is called by the common I/O layer for some state changes
+	of the device.
+	Signalled to the driver are:
+	* In online state, device detached (CIO_GONE) or last path gone
+	  (CIO_NO_PATH). The driver must return !0 to keep the device; for
+	  return code 0, the device will be deleted as usual (also when no
+	  notify function is registerd). If the driver wants to keep the
+	  device, it is moved into disconnected state.
+	* In disconnected state, device operational again (CIO_OPER). The
+	  common I/O layer performs some sanity checks on device number and
+	  Device / CU to be reasonably sure if it is still the same device.
+	  If not, the old device is removed and a new one registered. By the
+	  return code of the notify function the device driver signals if it
+	  wants the device back: !0 for keeping, 0 to make the device being
+	  removed and re-registered.
+	
+int (*notify) (struct ccw_device *, int);
+
+Parameters:   cdev    - the device whose state changed.
+	      event   - the event that happened. This can be one of CIO_GONE,
+		        CIO_NO_PATH or CIO_OPER.
+
 The handler field of the struct ccw_device is meant to be set to the interrupt
 handler for the device. In order to accommodate drivers which use several 
 distinct handlers (e.g. multi subchannel devices), this is a member of ccw_device
diff -puN /dev/null Documentation/scsi/qla2xxx.revision.notes
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/Documentation/scsi/qla2xxx.revision.notes	2004-01-19 22:17:09.000000000 -0800
@@ -0,0 +1,457 @@
+/*
+ * QLogic ISP2200 and ISP2300 Linux Driver Revision List File.
+ *
+ ********************************************************************
+ *
+ * Revision History
+ *
+ *  Rev  8.00.00b8	December 5, 2003	AV
+ *	- Instruct mid-layer to perform initial scan.
+ *
+ *  Rev  8.00.00b7	December 5, 2003	AV
+ *	- Resync with Linux Kernel 2.6.0-test11.
+ *	- Add basic NVRAM parser (extras/qla_nvr).
+ *
+ *  Rev  8.00.00b7-pre11 December 3, 2003	AV
+ *	- Sanitize the scsi_qla_host structure:
+ *	  - Purge unused elements.
+ *	  - Reorganize high-priority members (cache coherency).
+ *	- Add support for NVRAM access via a sysfs binary attribute:
+ *	  - Consolidate semaphore locking access.
+ *	- Fix more PCI posting issues.
+ *	- Add extras directory for dump/NVRAM tools.
+ *	- Remove unused qla_vendor.c file.
+ *
+ *  Rev  8.00.00b7-pre11 November 26, 2003	DG/AV
+ *	- Merge several patches from Christoph Hellwig [hch@lst.de]:
+ *	  - in Linux 2.6 both pci and the scsi layer use the generic
+ *	    dma direction bits, use them directly instead of the scsi
+ *	    and pci variants and the (noop) conversion routines.
+ *	- Fix _IOXX_BAD() usage for external IOCTL interface.
+ *	- Use atomic construct for HA loop_state member.
+ *	- Add generic model description text for HBA types.
+ *
+ *  Rev  8.00.00b7-pre5	November 17, 2003	AV
+ *	- Merge several patches from Christoph Hellwig [hch@lst.de]:
+ *	  - patch to split the driver into a common qla2xxx.ko and a
+ *	    qla2?00.ko for each HBA type - the latter modules are
+ *	    only very small wrappers, mostly for the firmware
+ *	    images, all the meat is in the common qla2xxx.ko.
+ *	  - make the failover code optional.
+ *	  - kill useless lock_kernel in dpc thread startup.
+ *	  - no need for modversions hacks in 2.6 (or 2.4).
+ *	  - kill qla2x00_register_with_Linux.
+ *	  - simplify EH code, cmd or it's hostdata can't be NULL, no
+ *	    need to search whether the host it's ours, the midlayer
+ *	    makes sure it won't call into a driver for some else
+ *	    host.
+ *	- Merge several patches from Jes Sorensen
+ *	  [jes@wildopensource.com]:
+ *	  - Call qla2x00_config_dma_addressing() before performing
+ *	    any consistent allocations. This is required since the
+ *	    dma mask settings will affect the memory
+ *	    pci_alloc_consistent() will return.
+ *	  - Call pci_set_consistent_dma_mask() to allow for 64 bit
+ *	    consistent allocations, required on some platforms such
+ *	    as the SN2.
+ *	  - Wait 20 usecs (not sure how long is really necessary,
+ *	    but this seems safe) after setting CSR_ISP_SOFT_RESET in
+ *	    the ctrl_status register as the card doesn't respond to
+ *	    PCI reads while in reset state. This causes a machine
+ *	    check on some architectures.
+ *	  - Flush PCI writes before calling udelay() to ensure the
+ *	    write is not sitting idle in-flight for a while before
+ *	    hitting the hardware.
+ *	  - Include linux/vmalloc.h in qla_os.c since it uses
+ *	    vmalloc().
+ *	  - Use auto-negotiate link speed when using default
+ *	    parameters rather than NVRAM settings. Disable NVRAM
+ *	    reading on SN2 since it's not possible to execute the
+ *	    HBA's BIOS on an SN2. I suggest doing something similar
+ *	    for all architectures that do not provide x86 BIOS
+ *	    emulation.
+ *	- Clean-up slab-cache allocations:
+ *	  - locking.
+ *	  - mempool allocations in case of low-memory situations.
+ *	- Fallback to GA_NXT scan if GID_PT call returns more than
+ *	  MAX_FIBRE_DEVICES.
+ *	- Preserve iterating port ID across GA_NXT calls in
+ *	  qla2x00_find_all_fabric_devs().
+ *	- Pre-calculate ASCII firmware dump length as to not incur the
+ *	  cost-to-calculate at each invocation of a read().
+ *
+ *  Rev  8.00.00b6	November 4, 2003	AV
+ *	- Add new 2300 TPX firmware (3.02.18).
+ *
+ *  Rev  8.00.00b6-pre25 October 20, 2003	RA/AV
+ *	- Resync with Linux Kernel 2.6.0-test9.
+ *	- Rework firmware dump process:
+ *	  - Use binary attribute within sysfs tree.
+ *	  - Add user-space tool (gdump.sh) to retrieve formatted
+ *	    buffer.
+ *	  - Add ISP2100 support.
+ *	- Use a slab cache for SRB allocations to reduce memory
+ *	  pressure.
+ *	- Initial conversion of driver logging methods to a new
+ *	  qla_printk() function which uses dev_printk (Daniel
+ *	  Stekloff, IBM).
+ *	- Further reduce stack usage in qla2x00_configure_local_loop()
+ *	  and qla2x00_find_all_fabric_devs().
+ *	- Separate port state used for routing of I/O's from port
+ *	  mgmt-login retry etc.
+ *
+ *  Rev  8.00.00b6-pre19 October 13, 2003	AV
+ *	- Resync with Linux Kernel 2.6.0-test7-bk5.
+ *	- Add intelligent RSCN event handling:
+ *	  - reduce scan time during 'port' RSCN events by only
+ *	    querying specified port ids.
+ *	  - Available on ISP23xx cards only.
+ *	- Increase maximum number of recognizable targets from 256
+ *	  to 512.
+ *	  - Backend changes were previously added to support TPX
+ *	    (2K logins) firmware.  Mid-layer can now scan for targets
+ *	    (H, B, T, L) where 512 < T >= 0.
+ *	- Remove IP support from driver.
+ *	  - Switch firmware types from IP->TP for ISP22xx and
+ *	    IPX->TPX for ISP23xx cards.
+ *	  - Remove files qla_ip.[ch].
+ *	- Remove type designations from firmware filenames.
+ *
+ *  Rev  8.00.00b6-pre11 September 15, 2003	DG/AV
+ *	- Resync with 6.06.00.
+ *	- Resync with Linux Kernel 2.6.0-test5-bk3.
+ *	- Add new 2300 IPX firmware (3.02.15).
+ *
+ *  Rev  8.00.00b5	July 31, 2003		AV
+ *	- Always create an fc_lun_t entry for lun 0 - as the mid-
+ *	  layer requires access to this lun for discovery to occur.
+ *	- General sanitizing:
+ *	  - Add generic firmware option definitions.
+ *	  - Generalize retrieval/update of firmware options.
+ *	  - Fix compile errors which occur with extended debug.
+ *	  - Handle failure cases for scsi_add_host() and
+ *	    down_interruptible().
+ *	- Host template updates:
+ *	  - Use standard bios_param callback function.
+ *	  - Disable clustering.
+ *	  - Remove unchecked_is_dma entry.
+ *
+ *  Rev  8.00.00b5-pre5	July 29, 2003		DG/AV
+ *	- Resync with 6.06.00b13.
+ *	- Resync with Linux Kernel 2.6.0-test2.
+ *	- Pass the complete loop_id, not the masked (0xff) value
+ *	  while issuing mailbox commands (qla_mbx.c/qla_fo.c/
+ *	  qla_iocb.c/qla_init.c).
+ *	- Properly handle zero-length return status for an RLC CDB.
+ *	- Create an fclun_t structure for 'disconnected' luns,
+ *	  peripheral-qualifier of 001b.
+ *	- Remove unused LIP-sequence register access during AE 8010.
+ *	- Generalize qla2x00_mark_device_lost() to handle forced 
+ *	  login request -- modify all direct/indirect invocations 
+ *	  with proper flag.
+ *	- Save RSCN notification (AE 8015h) data in a proper and 
+ *	  consistent format (domain, area, al_pa).
+ *	- General sanitizing:
+ *	  - scsi_qla_host structure member reordering for cache-line
+ *	    coherency.
+ *	  - Remove unused SCSI opcodes, endian-swap definitions.
+ *	  - Remove CMD_* pre-processor defines.
+ *	  - Remove unused SCSIFCHOTSWAP/GAMAP/MULTIHOST codes.
+ *	- Backout patch which added a per-scsi_qla_host scsi host
+ *	  spinlock, since mid-layer already defines one.
+ *	- Add new 2300 IPX firmware (3.02.15).
+ *
+ *  Rev  8.00.00b4	July 14, 2003		RA/DG/AV
+ *	- Resync with 6.06.00b12.
+ *	- Resync with Linux Kernel 2.6.0-test1.
+ *	- Remove IOCB throttling code -- originally #if'd.
+ *	- Remove apidev_*() routines since proc_mknod() has been
+ *	  removed -- need alternate IOCTL interface.
+ *	- Merge several performance/fix patches from Arjan van de
+ *	  Ven:
+ *	  - Undefined operation >> 32.
+ *	  - No need to acquire mid-layer lock during command
+ *	    callback. 
+ *	  - Use a per-HBA mid-layer lock.
+ *	  - Use a non-locked cycle for setting the count of the
+ *	    newly allocated sp (qla2x00_get_new_sp()).
+ *	  - Modify semantic behavior of qla2x00_queuecommand():
+ *	    - Reduce cacheline bouncing by having I/Os submitted
+ *	      by the IRQ handler.
+ *	    - Remove extraneous calls to qla2x00_next() during I/O
+ *	      queuing.
+ *	  - Use list_splice_init() during qla2x00_done() handling
+ *	    of commands to reduce list_lock contention.
+ *	  - RIO mode support for ISP2200:
+ *	    - Implementation differs slightly from original patch.
+ *	  - Do not use bottom-half handler (tasklet/work queue)
+ *	    for qla2x00_done() processing.
+ *
+ *  Rev  8.00.00b4-pre22 July 12, 2003		AV
+ *	- Check for 'Process Response Queue' requests early during
+ *	  the Host Status check.
+ *	- General sanitizing:
+ *	  - srb_t structure rewrite, removal of unused members.
+ *	  - Remove unused fcdev array, fabricid, and PORT_*
+ *	    definitions.
+ *	  - Remove unused config_reg_t PCI definitions.
+ *	- Add new 2200 IP firmware (2.02.06).
+ *	- Add new 2300 IPX firmware (3.02.14).
+ *
+ *  Rev  8.00.00b4-pre19 June 30, 2003		AV
+ *	- Resync with Linux Kernel 2.5.73-bk8.
+ *	- Rework IOCB command queuing methods:
+ *	  - Upper-layer driver *MUST* properly set the direction
+ *	    bit of SCSI commands.
+ *	  - Generalize 32bit/64bit queuing path functions.
+ *	  - Remove costly page-boundary cross check when using
+ *	    64bit address capable IOCBs.
+ *
+ *  Rev  8.00.00b4-pre15 June 19, 2003		AV
+ *	- Resync with 6.06.00b11.
+ *	- Continue fcport list consolidation work:
+ *	  - Updated IOCTL implementations to use new fcports 
+ *	    list.
+ *	- Modified product ID check to not verify ISP chip
+ *	  revision -- ISP2312 v3 (qla2x00_chip_diag()).
+ *	- Add new 2300 IPX firmware (3.02.13):
+ *
+ *  Rev  8.00.00b4-pre13 June 19, 2003		AV
+ *	- Fix build process for qla2100 driver -- no support
+ *	  for IP.
+ *	- SCSI host template modifications:
+ *	  - Set sg_tablesize based on the derived DMA mask.
+ *	  - Increase max_sectors since only limit within RISC
+ *	    is transfer of (((2^32) - 1) >> 9) sectors.
+ *
+ *  Rev  8.00.00b4-pre12 June 18, 2003		RA, DG, RL, AV
+ *	- Resync with 6.06.00b10.
+ *	- Resync with Linux Kernel 2.5.72.
+ *	- Initial fcport list consolidation work:
+ *	  - fcports/fcinitiators/fcdev/fc_ip --> ha->fcports
+ *	    list.
+ *
+ *  Rev  8.00.00b4-pre7	 June 05, 2003		AV
+ *	- Properly release PCI resouces in init-failure case.
+ *	- Reconcile disparite function return code definitions.
+ *
+ *  Rev  8.00.00b4-pre4	 June 03, 2003		AV
+ *	- Resync with Linux Kernel 2.5.70-bk8:
+ *	  - SHT proc_info() changes.
+ *	- Restructure SNS Generic Services routines:
+ *	  - Add qla_gs.c file to driver distribution.
+ *	- Configure PCI latency timer for ISP23xx.
+ *
+ *  Rev  8.00.00b4-pre3	 June 02, 2003		RA, DG, RL, AV
+ *	- Resync with 6.06.00b5.
+ *	- Rework (again) PCI I/O space configuration
+ *	  (Anton Blanchard):
+ *	  - Use pci_set_mwi() routine;
+ *	    - Remove uneeded qla2x00_set_cache_line() function.
+ *	  - Remove extraneous modification of PCI_COMMAND word.
+ *
+ *  Rev  8.00.00b3 	 May 29, 2003		AV
+ *	- Resync with Linux Kernel 2.5.70.
+ *	- Move RISC paused check from ISR fast-path.
+ *
+ *  Rev  8.00.00b3-pre8 May 26, 2003		AV
+ *	- Add new 2300 IPX firmware (3.02.12):
+ *	- Rework PCI I/O space configuration.
+ *
+ *  Rev  8.00.00b3-pre6	May 22, 2003		RA, DG, RL, AV
+ *	- Resync with 6.06.00b3.
+ *
+ *  Rev  8.00.00b3-pre4	May 21 2003		AV
+ *	- Add new 2300 IPX firmware (3.02.11):
+ *	  - Remove 2300 TPX firmware from distribution.
+ *
+ *  Rev  8.00.00b3-pre3	May 21 2003		AV
+ *	- Properly setup PCI configuation space during
+ *	  initialization:
+ *	  - Properly configure Memory-Mapped I/O during early
+ *	    configuration stage.
+ *	- Rework IP functionality to support 2k logins.
+ *	- Add new 2300 IPX firmware (3.02.11):
+ *	  - Remove 2300 TPX firmware from distribution.
+ *
+ *  Rev  8.00.00b3-pre2	May ??, 2003		RA, DG, RL, AV
+ *	- Resync with 6.06.00b1.
+ *
+ *  Rev  8.00.00b3-pre1	May ??, 2003		RA, DG, RL, AV
+ *	- Resync with 6.05.00.
+ *
+ *  Rev  8.00.00b2	May 19, 2003		AV
+ *	- Simplify dma_addr_t handling during command queuing given
+ *	  new block-layer defined restrictions:
+ *	  - Physical addresses not spanning 4GB boundaries.
+ *	- Firmware versions: 2100 TP (1.19.24), 2200 IP (2.02.05),
+ *	  2300 TPX (3.02.10).
+ *
+ *  Rev  8.00.00b2-pre1	May 13, 2003		AV
+ *	- Add support for new 'Hotplug initialization' model. 
+ *	- Simplify host template by removing unused callbacks.
+ *	- Use scsicam facilities to determine geometry.
+ *	- Fix compilation issues for non-ISP23xx builds:
+ *	  - Correct register references in qla_dbg.c.
+ *	  - Correct Makefile build process.
+ *
+ *  Rev  8.00.00b1	May 05, 2003		AV
+ *	- Resync with Linux Kernel 2.5.69.
+ *	- Firmware versions: 2100 TP (1.19.24), 2200 TP (2.02.05),
+ *	  2300 TPX (3.02.10).
+ *
+ *  Rev  8.00.00b1-pre45 April ??, 2003		AV
+ *	- Resync with Linux Kernel 2.5.68-bk11:
+ *	- Fix improper return-code assignment during fabric
+ *	  discovery.
+ *	- Remove additional extraneous #defines from
+ *	  qla_settings.h.
+ *	  - USE_PORTNAME -- FO will always use portname.
+ *	- Default queue depth size set to 64.
+ *
+ *  Rev  8.00.00b1-pre42 April ??, 2003		AV
+ *	- Convert bottom-half tasklet to a work_queue.
+ *	- Initial basic coding of dynamic queue depth handling
+ *	  during QUEUE FULL statuses.
+ *	- Fix mailbox interface problem with
+ *	  qla2x00_get_retry_cnt().
+ *
+ *  Rev  8.00.00b1-pre41 April ??, 2003		AV
+ *	- Convert build defines qla2[1|2|3]00 macros to
+ *	  qla2[1|2|3]xx due to module name stringification clashes.
+ *	- Add additional ISP2322 checks during board configuration.
+ *
+ *  Rev  8.00.00b1-pre40 April ??, 2003		AV
+ *	- Resync with Linux Kernel 2.5.68-bk8:
+ *	  - Updated IRQ handler interface.
+ *	- Add ISP dump code (stub) in case of SYSTEM_ERROR on
+ *	  ISP2100.
+ *	- Add new 2200 IP firmware (2.02.05).
+ *
+ *  Rev  8.00.00b1-pre39 April ??, 2003		AV
+ *	- Resync with Linux Kernel 2.5.68.
+ *	- Add simple build.sh script to aid in external compilation.
+ *	- Clean-break with Kernel 2.4 compatibility.
+ *	  - Rework DPC routine -- completion routines for signaling.
+ *	- Re-add HBAAPI character device node for IOCTL support.
+ *	- Remove residual QLA2X_PERFORMANCE defines.
+ *	- Allocate SP pool via __get_free_pages() rather than
+ *	  individual kmalloc()'s.
+ *	- Inform SCSI mid-layer of 16-byte CDB support
+ *	  (host->max_cmd_len):
+ *	  - Remove unecessary 'more_cdb' handling code from
+ *	    qla_iocb.c and qla_xioct.c.
+ *	- Reduce duplicate code in fabric scanning logic (MS IOCB
+ *	  preparation).
+ *	- Add ISP dump code in case of SYSTEM_ERROR.
+ *	- Remove 2300 VIX firmware from distribution:
+ *	  - Add initial code for IPX support.
+ *	- Add new 2300 TPX firmware (3.02.10).
+ *
+ *  Rev  8.00.00b1-pre34 April ??, 2003		AV
+ *	- Resync with Linux Kernel 2.5.67.
+ *	- Use domain/area/al_pa fields when displaying PortID 
+ *	  values -- addresses endianess issues.
+ *	- Rework large case statement to check 'common' CDB commands
+ *	  early in qla2x00_get_cmd_direction().
+ *
+ *  Rev  8.00.00b1-pre31 April ??, 2003		AV
+ *	- Update makefile to support PPC64 build.
+ *	- Retool NVRAM configuration routine and structures:
+ *	  - Consoldate ISP21xx/ISP22xx/ISP23xx configuration
+ *	    (struct nvram_t).
+ *	  - Remove big/little endian support structures in favor of
+ *	    simplified bit-operations within byte fields.
+ *	- Fix long-standing 'static' buffer sharing problem in 
+ *	  qla2x00_configure_fabric().
+ *
+ *  Rev  8.00.00b1-pre30 April ??, 2003		AV
+ *	- Complete implementation of GID_PT scan.
+ *	- Use consistent MS IOCB invocation method to query SNS:
+ *	  - Add RNN_ID and RSNN_NN registrations in a fabric.
+ *	- Remove unused Mailbox Command 6Eh (Send SNS) support
+ *	  structures.
+ *	- Use 64bit safe IOCBs while issuing INQUIRY and RLC during
+ *	  topology scan.
+ *	- Until reimplementation of fcdev_t/fcport list
+ *	  consolidation, valid loop_id ranges are still limited from
+ *	  0x00 through 0xFF -- enforce this within the code.
+ *
+ *  Rev  8.00.00b1-pre27 March ??, 2003		AV
+ *	- Resync with 6.05.00b9.
+ *	- Retool HBA PCI configuration -- qla2x00_pci_config().
+ *	- Remove inconsistent use of delay routines (UDELAY/SYS*).
+ *	- Continue to teardown/clean/add comments and debug
+ *	  routines.
+ *	- Properly swap bytes of the device's nodename in
+ *	  qla2x00_configure_local_loop().
+ *
+ *  Rev  8.00.00b1-pre25 March ??, 2003		AV
+ *	- Resync with 6.05.00b8.
+ *
+ *  Rev  8.00.00b1-pre23 March ??, 2003		AV
+ *	- Remove (#define) IOCB usage throttling.
+ *	- Abstract interrupt polling with qla2x00_poll().
+ *	- Modify lun scanning logic:
+ *	  - If the device does not support the SCSI Report Luns
+ *	    command, the driver will now only scan from 0 to the
+ *	    max#-luns as defined in the NVRAM (BIOS), rather than
+ *	    blindly scanning from 0 to 255 -- which could result in
+ *	    an increase in startup time when running against slow
+ *	    (JBOD) devices.
+ *	- Rework reset logic in qla2x00_reset_chip() (spec).
+ *
+ *  Rev  8.00.00b1-pre22 March ??, 2003		AV
+ *	- Resync with 6.05.00b7.
+ *	- Cleanup (rewrite) ISR handler.
+ *	- Rename kmem_zalloc --> qla2x00_kmem_zalloc():
+ *	  - This function will eventually be removed.
+ *	- Add new 2300 VIX firmware (3.02.09):
+ *	  - Support for Tape, Fabric, 2K logins, IP, and VI.
+ *
+ *  Rev  8.00.00b1-pre18 March ??, 2003		AV
+ *	- Support 232x type ISPs.
+ *	- Support single firmware for each ISP type:
+ *	  - Restructure brd_info/fw_info methods.
+ *	  - Streamline firmware load process.
+ *	  - Properly query firmware for version information.
+ *	- Remove extraneous scsi_qla_host members:
+ *	  - device_id ==> pdev->device
+ *	- Fix fc4 features (RFF_ID) registration.
+ *	- Convert kmem_zalloc --> qla2x00_kmem_zalloc().
+ *	- Remove unused/extraneous #defines (USE_PORTNAME).
+ *
+ *  Rev  8.00.00b1-pre14 March ??, 2003		AV
+ *	- Resync with 6.05.00b6.
+ *	- Initial source-code restructuring effort.
+ *	  - Build procedure.
+ *	  - Source file layout -- intuitive component layout.
+ *	  - Remove unused #defines (*PERFORMANCE, WORD_FW_LOAD, etc).
+ *	- Add support for 2K logins (TPX -- firmware).
+ *	- Add module parameter ql2xsuspendcount.
+ *	- Add new 2200 IP/TP firmware (2.02.04).
+ *
+ *  Rev  8.00.00b1-pre9	March ??, 2003	RL/DG/RA/AV
+ *	- Use kernel struct list_head for fcport and fclun lists.
+ *	- Remove extraneous (L|M)S_64BITS() and QL21_64*() defines.
+ *
+ *  Rev  8.00.00b1-pre8	February 28, 2003	RL/DG/RA/AV
+ *	- Resync with 6.05.00b3.
+ *
+ *  Rev  8.00.00b1-pre7	February 23, 2003	RL/DG/RA/AV
+ *	- Add alternate fabric scanning logic (GID_PT/GNN_ID/GPN_ID).
+ *	- Remove use of deprecated function check_region().
+ *	- Add new 2300 IP/TP firmware (3.02.08).
+ *
+ *  Rev  8.00.00b1-pre5	January 28, 2003	RL/DG/RA/AV
+ *	- Resync with 6.05.00b3.
+ *	- Consolidate device_reg structure definitions for ISP types.
+ *	- Add support for new queue-depth selection.
+ *	- Add new 2300 IP/TP firmware (3.02.07).
+ *
+ *  Rev  8.00.00b1-pre1	January 17, 2003	AV
+ *	- Initial branch from 6.04.00b8 driver.
+ *	- Remove VMWARE specific code.
+ *	- Add support for pci_driver interface.
+ *
+ ********************************************************************/
diff -puN /dev/null Documentation/sh/kgdb.txt
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/Documentation/sh/kgdb.txt	2004-01-19 22:17:09.000000000 -0800
@@ -0,0 +1,179 @@
+
+This file describes the configuration and behavior of KGDB for the SH
+kernel. Based on a description from Henry Bell <henry.bell@st.com>, it
+has been modified to account for quirks in the current implementation.
+
+Version
+=======
+
+This version of KGDB was written for 2.4.xx kernels for the SH architecture.
+Further documentation is available from the linux-sh project website.
+
+
+Debugging Setup: Host
+======================
+
+The two machines will be connected together via a serial line - this
+should be a null modem cable i.e. with a twist.
+
+On your DEVELOPMENT machine, go to your kernel source directory and
+build the kernel, enabling KGDB support in the "kernel hacking" section.
+This includes the KGDB code, and also makes the kernel be compiled with
+the "-g" option set -- necessary for debugging.
+
+To install this new kernel, use the following installation procedure.
+
+Decide on which tty port you want the machines to communicate, then
+cable them up back-to-back using the null modem.  On the DEVELOPMENT
+machine, you may wish to create an initialization file called .gdbinit
+(in the kernel source directory or in your home directory) to execute 
+commonly-used commands at startup.
+
+A minimal .gdbinit might look like this:
+
+  file vmlinux
+  set remotebaud 115200
+  target remote /dev/ttyS0
+
+Change the "target" definition so that it specifies the tty port that
+you intend to use.  Change the "remotebaud" definition to match the
+data rate that you are going to use for the com line (115200 is the
+default). 
+
+Debugging Setup: Target
+========================
+
+By default, the KGDB stub will communicate with the host GDB using
+ttySC1 at 115200 baud, 8 databits, no parity; these defaults can be
+changed in the kernel configuration. As the kernel starts up, KGDB will
+initialize so that breakpoints, kernel segfaults, and so forth will
+generally enter the debugger.
+
+This behavior can be modified by including the "kgdb" option in the
+kernel command line; this option has the general form:
+
+  kgdb=<ttyspec>,<action>
+
+The <ttyspec> indicates the port to use, and can optionally specify
+baud, parity and databits -- e.g. "ttySC0,9600N8" or "ttySC1,19200".
+
+The <action> can be "halt" or "disabled".  The "halt" action enters the
+debugger via a breakpoint as soon as kgdb is initialized; the "disabled"
+action causes kgdb to ignore kernel segfaults and such until explicitly
+entered by a breakpoint in the code or by external action (sysrq or NMI). 
+
+(Both <ttyspec> and <action> can appear alone, w/o the separating comma.)
+
+For example, if you wish to debug early in kernel startup code, you
+might specify the halt option:
+
+  kgdb=halt
+
+Boot the TARGET machinem, which will appear to hang. 
+
+On your DEVELOPMENT machine, cd to the source directory and run the gdb
+program.  (This is likely to be a cross GDB which runs on your host but
+is built for an SH target.) If everything is working correctly you
+should see gdb print out a few lines indicating that a breakpoint has
+been taken.  It will actually show a line of code in the target kernel
+inside the gdbstub activation code.
+
+NOTE: BE SURE TO TERMINATE OR SUSPEND any other host application which
+may be using the same serial port (for example, a terminal emulator you
+have been using to connect to the target boot code.)  Otherwise, data
+from the target may not all get to GDB!
+
+You can now use whatever gdb commands you like to set breakpoints.
+Enter "continue" to start your target machine executing again.  At this
+point the target system will run at full speed until it encounters
+your breakpoint or gets a segment violation in the kernel, or whatever.
+
+Serial Ports: KGDB, Console
+============================
+
+This version of KGDB may not gracefully handle conflict with other
+drivers in the kernel using the same port. If KGDB is configured on the
+same port (and with the same parameters) as the kernel console, or if
+CONFIG_SH_KGDB_CONSOLE is configured, things should be fine (though in
+some cases console messages may appear twice through GDB).  But if the
+KGDB port is not the kernel console and used by another serial driver
+which assumes different serial parameters (e.g. baud rate) KGDB may not
+recover.
+
+Also, when KGDB is entered via sysrq-g (requires CONFIG_KGDB_SYSRQ) and
+the kgdb port uses the same port as the console, detaching GDB will not
+restore the console to working order without the port being re-opened.
+
+Another serious consequence of this is that GDB currently CANNOT break
+into KGDB externally (e.g. via ^C or <BREAK>); unless a breakpoint or
+error is encountered, the only way to enter KGDB after the initial halt
+(see above) is via NMI (CONFIG_KGDB_NMI) or sysrq-g (CONFIG_KGDB_SYSRQ).
+
+Code is included for the basic Hitachi Solution Engine boards to allow
+the use of ttyS0 for KGDB if desired; this is less robust, but may be
+useful in some cases.  (This cannot be selected using the config file, 
+but only through the kernel command line, e.g. "kgdb=ttyS0", though the
+configured defaults for baud rate etc. still apply if not overridden.)
+
+If gdbstub Does Not Work
+========================
+
+If it doesn't work, you will have to troubleshoot it.  Do the easy
+things first like double checking your cabling and data rates.  You
+might try some non-kernel based programs to see if the back-to-back
+connection works properly.  Just something simple like cat /etc/hosts
+/dev/ttyS0 on one machine and cat /dev/ttyS0 on the other will tell you
+if you can send data from one machine to the other.  There is no point
+in tearing out your hair in the kernel if the line doesn't work.
+
+If you need to debug the GDB/KGDB communication itself, the gdb commands
+"set debug remote 1" and "set debug serial 1" may be useful, but be
+warned: they produce a lot of output.
+
+Threads
+=======
+
+Each process in a target machine is seen as a gdb thread. gdb thread related
+commands (info threads, thread n) can be used. CONFIG_KGDB_THREAD must
+be defined for this to work.
+
+In this version, kgdb reports PID_MAX (32768) as the process ID for the
+idle process (pid 0), since GDB does not accept 0 as an ID.
+
+Detaching (exiting KGDB)
+=========================
+
+There are two ways to resume full-speed target execution: "continue" and
+"detach". With "continue", GDB inserts any specified breakpoints in the
+target code and resumes execution; the target is still in "gdb mode".
+If a breakpoint or other debug event (e.g. NMI) happens, the target
+halts and communicates with GDB again, which is waiting for it.
+
+With "detach", GDB does *not* insert any breakpoints; target execution
+is resumed and GDB stops communicating (does not wait for the target).
+In this case, the target is no longer in "gdb mode" -- for example,
+console messages no longer get sent separately to the KGDB port, or
+encapsulated for GDB.  If a debug event (e.g. NMI) occurs, the target
+will re-enter "gdb mode" and will display this fact on the console; you
+must give a new "target remote" command to gdb.
+
+NOTE: TO AVOID LOSSING CONSOLE MESSAGES IN CASE THE KERNEL CONSOLE AND
+KGDB USING THE SAME PORT, THE TARGET WAITS FOR ANY INPUT CHARACTER ON
+THE KGDB PORT AFTER A DETACH COMMAND.  For example, after the detach you
+could start a terminal emulator on the same host port and enter a <cr>;
+however, this program must then be terminated or suspended in order to
+use GBD again if KGDB is re-entered.
+
+
+Acknowledgements
+================
+
+This code was mostly generated by Henry Bell <henry.bell@st.com>;
+largely from KGDB by Amit S. Kale <akale@veritas.com> - extracts from
+code by Glenn Engel, Jim Kingdon, David Grothe <dave@gcom.com>, Tigran
+Aivazian <tigran@sco.com>, William Gatliff <bgat@open-widgets.com>, Ben
+Lee, Steve Chamberlain and Benoit Miller <fulg@iname.com> are also
+included. 
+
+Jeremy Siegel
+<jsiegel@mvista.com>
diff -puN Documentation/sh/new-machine.txt~linus Documentation/sh/new-machine.txt
--- 25/Documentation/sh/new-machine.txt~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/Documentation/sh/new-machine.txt	2004-01-19 22:17:09.000000000 -0800
@@ -1,6 +1,162 @@
-The multiple machine support relies on redirecting all functions which will
-need to be machine specific through a table of function pointers, the
-machvec. These functions fall into a number of categories:
+
+                Adding a new board to LinuxSH
+               ================================
+
+               Paul Mundt <lethal@linux-sh.org>
+
+This document attempts to outline what steps are necessary to add support
+for new boards to the LinuxSH port under the new 2.5 and 2.6 kernels. This
+also attempts to outline some of the noticeable changes between the 2.4
+and the 2.5/2.6 SH backend.
+
+1. New Directory Structure
+==========================
+
+The first thing to note is the new directory structure. Under 2.4, most
+of the board-specific code (with the exception of stboards) ended up
+in arch/sh/kernel/ directly, with board-specific headers ending up in
+include/asm-sh/. For the new kernel, things are broken out by board type,
+companion chip type, and CPU type. Looking at a tree view of this directory
+heirarchy looks like the following:
+
+Board-specific code:
+
+.
+|-- arch
+|   `-- sh
+|       `-- boards
+|           |-- adx
+|           |   `-- board-specific files
+|           |-- bigsur
+|           |   `-- board-specific files
+|           |
+|           ... more boards here ...
+|
+`-- include
+    `-- asm-sh
+        |-- adx
+        |   `-- board-specific headers
+        |-- bigsur
+        |   `-- board-specific headers
+        |
+	.. more boards here ...
+
+It should also be noted that each board is required to have some certain
+headers. At the time of this writing, io.h is the only thing that needs
+to be provided for each board, and can generally just reference generic
+functions (with the exception of isa_port2addr).
+
+Next, for companion chips:
+.
+`-- arch
+    `-- sh
+        `-- cchips
+            `-- hd6446x
+                |-- hd64461
+                |   `-- cchip-specific files
+                `-- hd64465
+                    `-- cchip-specific files
+
+... and so on. Headers for the companion chips are treated the same way as
+board-specific headers. Thus, include/asm-sh/hd64461 is home to all of the
+hd64461-specific headers.
+
+Finally, CPU family support is also abstracted:
+.
+|-- arch
+|   `-- sh
+|       |-- kernel
+|       |   `-- cpu
+|       |       |-- sh2
+|       |       |   `-- SH-2 generic files
+|       |       |-- sh3
+|       |       |   `-- SH-3 generic files
+|       |       `-- sh4
+|       |           `-- SH-4 generic files
+|       `-- mm
+|           `-- This is also broken out per CPU family, so each family can
+|               have their own set of cache/tlb functions.
+|
+`-- include
+    `-- asm-sh
+        |-- cpu-sh2
+        |   `-- SH-2 specific headers
+        |-- cpu-sh3
+        |   `-- SH-3 specific headers
+        `-- cpu-sh4
+            `-- SH-4 specific headers
+
+It should be noted that CPU subtypes are _not_ abstracted. Thus, these still
+need to be dealt with by the CPU family specific code.
+
+2. Adding a New Board
+=====================
+
+The first thing to determine is whether the board you are adding will be
+isolated, or whether it will be part of a family of boards that can mostly
+share the same board-specific code with minor differences.
+
+In the first case, this is just a matter of making a directory for your
+board in arch/sh/boards/ and adding rules to hook your board in with the
+build system (more on this in the next section). However, for board families
+it makes more sense to have a common top-level arch/sh/boards/ directory
+and then populate that with sub-directories for each member of the family.
+Both the Solution Engine and the hp6xx boards are an example of this.
+
+After you have setup your new arch/sh/boards/ directory, remember that you
+also must add a directory in include/asm-sh for headers localized to this
+board. In order to interoperate seamlessly with the build system, it's best
+to have this directory the same as the arch/sh/boards/ directory name,
+though if your board is again part of a family, the build system has ways
+of dealing with this, and you can feel free to name the directory after
+the family member itself.
+
+There are a few things that each board is required to have, both in the
+arch/sh/boards and the include/asm-sh/ heirarchy. In order to better
+explain this, we use some examples for adding an imaginary board. For
+setup code, we're required at the very least to provide definitions for
+get_system_type() and platform_setup(). For our imaginary board, this
+might look something like:
+
+/*
+ * arch/sh/boards/vapor/setup.c - Setup code for imaginary board
+ */
+#include <linux/init.h>
+
+const char *get_system_type(void)
+{
+	return "FooTech Vaporboard";
+}
+
+int __init platform_setup(void)
+{
+  	/*
+	 * If our hardware actually existed, we would do real
+	 * setup here. Though it's also sane to leave this empty
+	 * if there's no real init work that has to be done for
+	 * this board.
+	 */
+
+  	/* 
+	 * Presume all FooTech boards have the same broken timer,
+	 * and also presume that we've defined foo_timer_init to
+	 * do something useful.
+	 */
+  	board_time_init = foo_timer_init;
+
+	/* Start-up imaginary PCI ... */
+
+	/* And whatever else ... */
+
+	return 0;
+}
+
+Our new imaginary board will also have to tie into the machvec in order for it
+to be of any use. Currently the machvec is slowly on its way out, but is still
+required for the time being. As such, let us take a look at what needs to be
+done for the machvec assignment.
+
+machvec functions fall into a number of categories:
 
  - I/O functions to IO memory (inb etc) and PCI/main memory (readb etc).
  - I/O remapping functions (ioremap etc)
@@ -27,16 +183,16 @@ There are three ways in which IO can be 
    can be read from/written to directly.
 
 Thus adding a new machine involves the following steps (I will assume I am
-adding a machine called fred):
+adding a machine called vapor):
 
- - add a new file include/asm-sh/io_fred.h which contains prototypes for
+ - add a new file include/asm-sh/vapor/io.h which contains prototypes for
    any machine specific IO functions prefixed with the machine name, for
-   example fred_inb. These will be needed when filling out the machine
+   example vapor_inb. These will be needed when filling out the machine
    vector. In addition, a section is required which defines what to do when
    building a machine specific version. For example:
 
      #ifdef __WANT_IO_DEF
-     #define inb  fred_inb
+     #define inb  vapor_inb
      ...
      #endif
 
@@ -47,18 +203,18 @@ adding a machine called fred):
    functions will still be needed, so that a module built for a generic
    setup can be loaded.
 
- - add a new file arch/sh/kernel/mach_fred.c. This contains the definition
+ - add a new file arch/sh/boards/vapor/mach.c. This contains the definition
    of the machine vector. When building the machine specific version, this
    will be the real machine vector (via an alias), while in the generic
    version is used to initialise the machine vector, and then freed, by
    making it initdata. This should be defined as:
 
-     struct sh_machine_vector mv_fred __initmv = {
-       mv_name: "Fred"
+     struct sh_machine_vector mv_vapor __initmv = {
+       .mv_name = "vapor",
      }
-     ALIAS_MV(se)
+     ALIAS_MV(vapor)
 
- - finally add a file arch/sh/kernel/io_fred.c, which contains
+ - finally add a file arch/sh/boards/vapor/io.c, which contains
    definitions of the machine specific io functions.
 
 A note about initialisation functions. Three initialisation functions are
@@ -75,3 +231,82 @@ they are targeting is present, however t
 so a flag can be added to the machine vector which will be set on those
 machines which have the hardware in question, reducing the probe to a
 single conditional.
+
+3. Hooking into the Build System
+================================
+
+Now that we have the corresponding directories setup, and all of the
+board-specific code is in place, it's time to look at how to get the
+whole mess to fit into the build system.
+
+Large portions of the build system are now entirely dynamic, and merely
+require the proper entry here and there in order to get things done.
+
+The first thing to do is to add an entry to arch/sh/Kconfig, under the
+"System type" menu:
+
+config SH_VAPOR
+	bool "Vapor"
+	help
+	  select Vapor if configuring for a FooTech Vaporboard.
+
+next, this has to be added into arch/sh/Makefile. All boards require a
+machdir-y entry in order to be built. This entry needs to be the name of
+the board directory as it appears in arch/sh/boards, even if it is in a
+sub-directory (in which case, all parent directories below arch/sh/boards/
+need to be listed). For our new board, this entry can look like:
+
+machdir-$(CONFIG_SH_VAPOR)	+= vapor
+
+provided that we've placed everything in the arch/sh/boards/vapor/ directory.
+
+Next, the build system assumes that your include/asm-sh directory will also
+be named the same. If this is not the case (as is the case with multiple
+boards belonging to a common family), then the directory name needs to be
+implicitly appended to incdir-y. The existing code manages this for the
+Solution Engine and hp6xx boards, so see these for an example.
+
+Once that is taken care of, it's time to add an entry for the mach type.
+This is done by adding an entry to the end of the arch/sh/tools/mach-types
+list. The method for doing this is self explanatory, and so we won't waste
+space restating it here. After this is done, you will be able to use
+implicit checks for your board if you need this somewhere throughout the
+common code, such as:
+
+	/* Make sure we're on the FooTech Vaporboard */
+	if (!mach_is_vapor())
+		return -ENODEV;
+
+also note that the mach_is_boardname() check will be implicitly forced to
+lowercase, regardless of the fact that the mach-types entries are all
+uppercase. You can read the script if you really care, but it's pretty ugly,
+so you probably don't want to do that.
+
+Now all that's left to do is providing a defconfig for your new board. This
+way, other people who end up with this board can simply use this config
+for reference instead of trying to guess what settings are supposed to be
+used on it.
+
+Also, as soon as you have copied over a sample .config for your new board
+(assume arch/sh/configs/defconfig-vapor), you can also use this directly as a
+build target, and it will be implicitly listed as such in the help text.
+
+Looking at the 'make help' output, you should now see something like:
+
+Architecture specific targets (sh):
+  zImage                  - Compressed kernel image (arch/sh/boot/zImage)
+  defconfig-adx           - Build for adx
+  defconfig-cqreek        - Build for cqreek
+  defconfig-dreamcast     - Build for dreamcast
+...
+  defconfig-vapor         - Build for vapor
+
+which then allows you to do:
+
+$ make ARCH=sh CROSS_COMPILE=sh4-linux- defconfig-vapor vmlinux
+
+which will in turn copy the defconfig for this board, run it through
+oldconfig (prompting you for any new options since the time of creation),
+and start you on your way to having a functional kernel for your new
+board.
+
diff -puN Documentation/SubmittingPatches~linus Documentation/SubmittingPatches
--- 25/Documentation/SubmittingPatches~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/Documentation/SubmittingPatches	2004-01-19 22:17:09.000000000 -0800
@@ -20,16 +20,18 @@ SECTION 1 - CREATING AND SENDING YOUR CH
 
 
 
-1) "diff -u"
+1) "diff -up"
 ------------
 
-Use "diff -u" or "diff -urN" to create patches.
+Use "diff -up" or "diff -uprN" to create patches.
 
 All changes to the Linux kernel occur in the form of patches, as
 generated by diff(1).  When creating your patch, make sure to create it
 in "unified diff" format, as supplied by the '-u' argument to diff(1).
-Patches should be based in the root kernel source directory, not in
-any lower subdirectory.
+Also, please use the '-p' argument which shows which C function each
+change is in - that makes the resultant diff a lot easier to read.
+Patches should be based in the root kernel source directory,
+not in any lower subdirectory.
 
 To create a patch for a single file, it is often sufficient to do:
 
@@ -39,7 +41,7 @@ To create a patch for a single file, it 
 	cd $SRCTREE
 	cp $MYFILE $MYFILE.orig
 	vi $MYFILE	# make your change
-	diff -u $MYFILE.orig $MYFILE > /tmp/patch
+	diff -up $MYFILE.orig $MYFILE > /tmp/patch
 
 To create a patch for multiple files, you should unpack a "vanilla",
 or unmodified kernel source tree, and generate a diff against your
@@ -50,7 +52,7 @@ own source tree.  For example:
 	tar xvfz linux-2.4.0-test11.tar.gz
 	mv linux linux-vanilla
 	wget http://www.moses.uklinux.net/patches/dontdiff
-	diff -urN -X dontdiff linux-vanilla $MYSRC > /tmp/patch
+	diff -uprN -X dontdiff linux-vanilla $MYSRC > /tmp/patch
 	rm -f dontdiff
 
 "dontdiff" is a list of files which are generated by the kernel during
diff -puN Documentation/sysctl/kernel.txt~linus Documentation/sysctl/kernel.txt
--- 25/Documentation/sysctl/kernel.txt~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/Documentation/sysctl/kernel.txt	2004-01-19 22:17:09.000000000 -0800
@@ -251,6 +251,25 @@ the different loglevels.
 
 ==============================================================
 
+printk_ratelimit:
+
+Some warning messages are rate limited. printk_ratelimit specifies
+the minimum length of time between these messages, by default we
+allow one every 5 seconds.
+
+A value of 0 will disable rate limiting.
+
+==============================================================
+
+printk_ratelimit_burst:
+
+While long term we enforce one message per printk_ratelimit
+seconds, we do allow a burst of messages to pass through.
+printk_ratelimit_burst specifies the number of messages we can
+send before ratelimiting kicks in.
+
+==============================================================
+
 reboot-cmd: (Sparc only)
 
 ??? This seems to be a way to give an argument to the Sparc
diff -puN drivers/acorn/char/i2c.c~linus drivers/acorn/char/i2c.c
--- 25/drivers/acorn/char/i2c.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/acorn/char/i2c.c	2004-01-19 22:17:21.000000000 -0800
@@ -167,6 +167,7 @@ static int rtc_ioctl(struct inode *inode
 		break;
 
 	case RTC_RD_TIME:
+		memset(&rtctm, 0, sizeof(struct rtc_time));
 		get_rtc_time(&rtc_raw, &year);
 		rtctm.tm_sec  = rtc_raw.secs;
 		rtctm.tm_min  = rtc_raw.mins;
diff -puN drivers/atm/atmdev_init.c~linus drivers/atm/atmdev_init.c
--- 25/drivers/atm/atmdev_init.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/atm/atmdev_init.c	2004-01-19 22:17:21.000000000 -0800
@@ -10,9 +10,6 @@
 #ifdef CONFIG_ATM_ZATM
 extern int zatm_detect(void);
 #endif
-#ifdef CONFIG_ATM_NICSTAR
-extern int nicstar_detect(void);
-#endif
 #ifdef CONFIG_ATM_AMBASSADOR
 extern int amb_detect(void);
 #endif
@@ -41,9 +38,6 @@ int __init atmdev_init(void)
 #ifdef CONFIG_ATM_ZATM
 	devs += zatm_detect();
 #endif
-#ifdef CONFIG_ATM_NICSTAR
-	devs += nicstar_detect();
-#endif
 #ifdef CONFIG_ATM_AMBASSADOR
 	devs += amb_detect();
 #endif
diff -puN drivers/atm/nicstar.c~linus drivers/atm/nicstar.c
--- 25/drivers/atm/nicstar.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/atm/nicstar.c	2004-01-19 22:17:21.000000000 -0800
@@ -214,8 +214,8 @@
 
 static u32 ns_read_sram(ns_dev *card, u32 sram_address);
 static void ns_write_sram(ns_dev *card, u32 sram_address, u32 *value, int count);
-static int __init ns_init_card(int i, struct pci_dev *pcidev);
-static void __init ns_init_card_error(ns_dev *card, int error);
+static int __devinit ns_init_card(int i, struct pci_dev *pcidev);
+static void __devinit ns_init_card_error(ns_dev *card, int error);
 static scq_info *get_scq(int size, u32 scd);
 static void free_scq(scq_info *scq, struct atm_vcc *vcc);
 static void push_rxbufs(ns_dev *card, u32 type, u32 handle1, u32 addr1,
@@ -276,136 +276,151 @@ MODULE_LICENSE("GPL");
 
 /* Functions*******************************************************************/
 
-static int __init nicstar_module_init(void)
+static int __devinit nicstar_init_one(struct pci_dev *pcidev,
+				      const struct pci_device_id *ent)
 {
-   int i;
-   unsigned error = 0;	/* Initialized to remove compile warning */
-   struct pci_dev *pcidev;
+   static int index = -1;
+   unsigned int error;
 
-   XPRINTK("nicstar: nicstar_module_init() called.\n");
+   index++;
+   cards[index] = NULL;
 
-   for(i = 0; i < NS_MAX_CARDS; i++)
-      cards[i] = NULL;
-
-   pcidev = NULL;
-   for(i = 0; i < NS_MAX_CARDS; i++)
-   {
-      if ((pcidev = pci_find_device(PCI_VENDOR_ID_IDT,
-                                    PCI_DEVICE_ID_IDT_IDT77201,
-                                    pcidev)) == NULL)
-         break;
-
-      error = ns_init_card(i, pcidev);
-      if (error)
-         cards[i--] = NULL;	/* Try to find another card but don't increment index */
+   error = ns_init_card(index, pcidev);
+   if (error) {
+      cards[index--] = NULL;	/* don't increment index */
+      goto err_out;
    }
 
-   if (i == 0)
-   {
-      if (!error)
-      {
-         printk("nicstar: no cards found.\n");
-         return -ENXIO;
-      }
-      else
-         return -EIO;
-   }
-   TXPRINTK("nicstar: TX debug enabled.\n");
-   RXPRINTK("nicstar: RX debug enabled.\n");
-   PRINTK("nicstar: General debug enabled.\n");
-#ifdef PHY_LOOPBACK
-   printk("nicstar: using PHY loopback.\n");
-#endif /* PHY_LOOPBACK */
-   XPRINTK("nicstar: nicstar_module_init() returned.\n");
-
-   init_timer(&ns_timer);
-   ns_timer.expires = jiffies + NS_POLL_PERIOD;
-   ns_timer.data = 0UL;
-   ns_timer.function = ns_poll;
-   add_timer(&ns_timer);
    return 0;
+err_out:
+   return -ENODEV;
 }
 
 
 
-static void __exit nicstar_module_exit(void)
+static void __devexit nicstar_remove_one(struct pci_dev *pcidev)
 {
    int i, j;
-   unsigned short pci_command;
-   ns_dev *card;
+   ns_dev *card = pci_get_drvdata(pcidev);
    struct sk_buff *hb;
    struct sk_buff *iovb;
    struct sk_buff *lb;
    struct sk_buff *sb;
    
-   XPRINTK("nicstar: cleanup_module() called.\n");
+   i = card->index;
 
-   del_timer(&ns_timer);
+   if (cards[i] == NULL)
+      return;
 
-   for (i = 0; i < NS_MAX_CARDS; i++)
+   if (card->atmdev->phy && card->atmdev->phy->stop)
+      card->atmdev->phy->stop(card->atmdev);
+
+   /* Stop everything */
+   writel(0x00000000, card->membase + CFG);
+
+   /* De-register device */
+   atm_dev_deregister(card->atmdev);
+
+   /* Disable PCI device */
+   pci_disable_device(pcidev);
+   
+   /* Free up resources */
+   j = 0;
+   PRINTK("nicstar%d: freeing %d huge buffers.\n", i, card->hbpool.count);
+   while ((hb = skb_dequeue(&card->hbpool.queue)) != NULL)
    {
-      if (cards[i] == NULL)
-         continue;
+      dev_kfree_skb_any(hb);
+      j++;
+   }
+   PRINTK("nicstar%d: %d huge buffers freed.\n", i, j);
+   j = 0;
+   PRINTK("nicstar%d: freeing %d iovec buffers.\n", i, card->iovpool.count);
+   while ((iovb = skb_dequeue(&card->iovpool.queue)) != NULL)
+   {
+      dev_kfree_skb_any(iovb);
+      j++;
+   }
+   PRINTK("nicstar%d: %d iovec buffers freed.\n", i, j);
+   while ((lb = skb_dequeue(&card->lbpool.queue)) != NULL)
+      dev_kfree_skb_any(lb);
+   while ((sb = skb_dequeue(&card->sbpool.queue)) != NULL)
+      dev_kfree_skb_any(sb);
+   free_scq(card->scq0, NULL);
+   for (j = 0; j < NS_FRSCD_NUM; j++)
+   {
+      if (card->scd2vc[j] != NULL)
+         free_scq(card->scd2vc[j]->scq, card->scd2vc[j]->tx_vcc);
+   }
+   kfree(card->rsq.org);
+   kfree(card->tsq.org);
+   free_irq(card->pcidev->irq, card);
+   iounmap((void *) card->membase);
+   kfree(card);
+}
 
-      card = cards[i];
 
-      if (card->atmdev->phy && card->atmdev->phy->stop)
-        card->atmdev->phy->stop(card->atmdev);
 
-      /* Stop everything */
-      writel(0x00000000, card->membase + CFG);
+static struct pci_device_id nicstar_pci_tbl[] __devinitdata =
+{
+	{PCI_VENDOR_ID_IDT, PCI_DEVICE_ID_IDT_IDT77201,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{0,}			/* terminate list */
+};
+MODULE_DEVICE_TABLE(pci, nicstar_pci_tbl);
 
-      /* De-register device */
-      atm_dev_deregister(card->atmdev);
 
-      /* Disable memory mapping and busmastering */
-      if (pci_read_config_word(card->pcidev, PCI_COMMAND, &pci_command) != 0)
-      {
-         printk("nicstar%d: can't read PCI_COMMAND.\n", i);
-      }
-      pci_command &= ~(PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
-      if (pci_write_config_word(card->pcidev, PCI_COMMAND, pci_command) != 0)
-      {
-         printk("nicstar%d: can't write PCI_COMMAND.\n", i);
-      }
-      
-      /* Free up resources */
-      j = 0;
-      PRINTK("nicstar%d: freeing %d huge buffers.\n", i, card->hbpool.count);
-      while ((hb = skb_dequeue(&card->hbpool.queue)) != NULL)
-      {
-         dev_kfree_skb_any(hb);
-	 j++;
-      }
-      PRINTK("nicstar%d: %d huge buffers freed.\n", i, j);
-      j = 0;
-      PRINTK("nicstar%d: freeing %d iovec buffers.\n", i, card->iovpool.count);
-      while ((iovb = skb_dequeue(&card->iovpool.queue)) != NULL)
-      {
-         dev_kfree_skb_any(iovb);
-         j++;
-      }
-      PRINTK("nicstar%d: %d iovec buffers freed.\n", i, j);
-      while ((lb = skb_dequeue(&card->lbpool.queue)) != NULL)
-         dev_kfree_skb_any(lb);
-      while ((sb = skb_dequeue(&card->sbpool.queue)) != NULL)
-         dev_kfree_skb_any(sb);
-      free_scq(card->scq0, NULL);
-      for (j = 0; j < NS_FRSCD_NUM; j++)
-      {
-         if (card->scd2vc[j] != NULL)
-	    free_scq(card->scd2vc[j]->scq, card->scd2vc[j]->tx_vcc);
-      }
-      kfree(card->rsq.org);
-      kfree(card->tsq.org);
-      free_irq(card->pcidev->irq, card);
-      iounmap((void *) card->membase);
-      kfree(card);
-      
+
+static struct pci_driver nicstar_driver = {
+	.name		= "nicstar",
+	.id_table	= nicstar_pci_tbl,
+	.probe		= nicstar_init_one,
+	.remove		= __devexit_p(nicstar_remove_one),
+};
+
+
+
+static int __init nicstar_init(void)
+{
+   unsigned error = 0;	/* Initialized to remove compile warning */
+
+   XPRINTK("nicstar: nicstar_init() called.\n");
+
+   error = pci_module_init(&nicstar_driver);
+   
+   TXPRINTK("nicstar: TX debug enabled.\n");
+   RXPRINTK("nicstar: RX debug enabled.\n");
+   PRINTK("nicstar: General debug enabled.\n");
+#ifdef PHY_LOOPBACK
+   printk("nicstar: using PHY loopback.\n");
+#endif /* PHY_LOOPBACK */
+   XPRINTK("nicstar: nicstar_init() returned.\n");
+
+   if (!error) {
+      init_timer(&ns_timer);
+      ns_timer.expires = jiffies + NS_POLL_PERIOD;
+      ns_timer.data = 0UL;
+      ns_timer.function = ns_poll;
+      add_timer(&ns_timer);
    }
-   XPRINTK("nicstar: cleanup_module() returned.\n");
+   
+   return error;
+}
+
+
+
+static void __exit nicstar_cleanup(void)
+{
+   XPRINTK("nicstar: nicstar_cleanup() called.\n");
+
+   del_timer(&ns_timer);
+
+   pci_unregister_driver(&nicstar_driver);
+
+   XPRINTK("nicstar: nicstar_cleanup() returned.\n");
 }
 
+
+
 static u32 ns_read_sram(ns_dev *card, u32 sram_address)
 {
    unsigned long flags;
@@ -445,11 +460,10 @@ static void ns_write_sram(ns_dev *card, 
 }
 
 
-static int __init ns_init_card(int i, struct pci_dev *pcidev)
+static int __devinit ns_init_card(int i, struct pci_dev *pcidev)
 {
    int j;
    struct ns_dev *card = NULL;
-   unsigned short pci_command;
    unsigned char pci_latency;
    unsigned error;
    u32 data;
@@ -478,6 +492,8 @@ static int __init ns_init_card(int i, st
    spin_lock_init(&card->int_lock);
    spin_lock_init(&card->res_lock);
       
+   pci_set_drvdata(pcidev, card);
+   
    card->index = i;
    card->atmdev = NULL;
    card->pcidev = pcidev;
@@ -492,21 +508,7 @@ static int __init ns_init_card(int i, st
    }
    PRINTK("nicstar%d: membase at 0x%x.\n", i, card->membase);
 
-   if (pci_read_config_word(pcidev, PCI_COMMAND, &pci_command) != 0)
-   {
-      printk("nicstar%d: can't read PCI_COMMAND.\n", i);
-      error = 4;
-      ns_init_card_error(card, error);
-      return error;
-   }
-   pci_command |= (PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
-   if (pci_write_config_word(pcidev, PCI_COMMAND, pci_command) != 0)
-   {
-      printk("nicstar%d: can't write PCI_COMMAND.\n", i);
-      error = 5;
-      ns_init_card_error(card, error);
-      return error;
-   }
+   pci_set_master(pcidev);
 
    if (pci_read_config_byte(pcidev, PCI_LATENCY_TIMER, &pci_latency) != 0)
    {
@@ -932,7 +934,7 @@ static int __init ns_init_card(int i, st
 
 
 
-static void __init ns_init_card_error(ns_dev *card, int error)
+static void __devinit ns_init_card_error(ns_dev *card, int error)
 {
    if (error >= 17)
    {
@@ -981,6 +983,7 @@ static void __init ns_init_card_error(ns
    }
    if (error >= 3)
    {
+      pci_disable_device(card->pcidev);
       kfree(card);
    }
 }
@@ -3099,5 +3102,7 @@ static unsigned char ns_phy_get(struct a
    return (unsigned char) data;
 }
 
-module_init(nicstar_module_init);
-module_exit(nicstar_module_exit);
+
+
+module_init(nicstar_init);
+module_exit(nicstar_cleanup);
diff -puN drivers/base/class.c~linus drivers/base/class.c
--- 25/drivers/base/class.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/base/class.c	2004-01-19 22:17:21.000000000 -0800
@@ -46,6 +46,19 @@ class_attr_store(struct kobject * kobj, 
 	return ret;
 }
 
+static void class_release(struct kobject * kobj)
+{
+	struct class *class = to_class(kobj);
+
+	pr_debug("class '%s': release.\n", class->name);
+
+	if (class->class_release)
+		class->class_release(class);
+	else
+		pr_debug("class '%s' does not have a release() function, "
+			 "be careful\n", class->name);
+}
+
 static struct sysfs_ops class_sysfs_ops = {
 	.show	= class_attr_show,
 	.store	= class_attr_store,
@@ -53,6 +66,7 @@ static struct sysfs_ops class_sysfs_ops 
 
 static struct kobj_type ktype_class = {
 	.sysfs_ops	= &class_sysfs_ops,
+	.release	= class_release,
 };
 
 /* Hotplug events for classes go to the class_obj subsys */
diff -puN /dev/null drivers/base/class_simple.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/base/class_simple.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,201 @@
+/*
+ * class_simple.c - a "simple" interface for classes for simple char devices.
+ *
+ * Copyright (c) 2003-2004 Greg Kroah-Hartman <greg@kroah.com>
+ * Copyright (c) 2003-2004 IBM Corp.
+ * 
+ * This file is released under the GPLv2
+ *
+ */
+
+#define DEBUG 1
+
+#include <linux/device.h>
+#include <linux/kdev_t.h>
+#include <linux/err.h>
+
+struct class_simple {
+	struct class_device_attribute attr;
+	struct class class;
+};
+#define to_class_simple(d) container_of(d, struct class_simple, class)
+
+struct simple_dev {
+	struct list_head node;
+	dev_t dev;
+	struct class_device class_dev;
+};
+#define to_simple_dev(d) container_of(d, struct simple_dev, class_dev)
+
+static LIST_HEAD(simple_dev_list);
+static spinlock_t simple_dev_list_lock = SPIN_LOCK_UNLOCKED;
+
+static void release_simple_dev(struct class_device *class_dev)
+{
+	struct simple_dev *s_dev = to_simple_dev(class_dev);
+	kfree(s_dev);
+}
+
+static ssize_t show_dev(struct class_device *class_dev, char *buf)
+{
+	struct simple_dev *s_dev = to_simple_dev(class_dev);
+	return print_dev_t(buf, s_dev->dev);
+}
+
+static void class_simple_release(struct class *class)
+{
+	struct class_simple *cs = to_class_simple(class);
+	kfree(cs);
+}
+
+/**
+ * class_simple_create - create a struct class_simple structure
+ * @owner: pointer to the module that is to "own" this struct class_simple
+ * @name: pointer to a string for the name of this class.
+ *
+ * This is used to create a struct class_simple pointer that can then be used
+ * in calls to class_simple_device_add().  This is used when you do not wish to
+ * create a full blown class support for a type of char devices.
+ *
+ * Note, the pointer created here is to be destroyed when finished by making a
+ * call to class_simple_destroy().
+ */
+struct class_simple *class_simple_create(struct module *owner, char *name)
+{
+	struct class_simple *cs;
+	int retval;
+
+	cs = kmalloc(sizeof(*cs), GFP_KERNEL);
+	if (!cs) {
+		retval = -ENOMEM;
+		goto error;
+	}
+	memset(cs, 0x00, sizeof(*cs));
+
+	cs->class.name = name;
+	cs->class.class_release = class_simple_release;
+	cs->class.release = release_simple_dev;
+
+	cs->attr.attr.name = "dev";
+	cs->attr.attr.mode = S_IRUGO;
+	cs->attr.attr.owner = owner;
+	cs->attr.show = show_dev;
+	cs->attr.store = NULL;
+
+	retval = class_register(&cs->class);
+	if (retval)
+		goto error;
+
+	return cs;
+
+error:
+	kfree(cs);
+	return ERR_PTR(retval);
+}
+EXPORT_SYMBOL(class_simple_create);
+
+/**
+ * class_simple_destroy - destroys a struct class_simple structure
+ * @cs: pointer to the struct class_simple that is to be destroyed
+ *
+ * Note, the pointer to be destroyed must have been created with a call to
+ * class_simple_create().
+ */
+void class_simple_destroy(struct class_simple *cs)
+{
+	if ((cs == NULL) || (IS_ERR(cs)))
+		return;
+
+	class_unregister(&cs->class);
+}
+EXPORT_SYMBOL(class_simple_destroy);
+
+/**
+ * class_simple_device_add - adds a class device to sysfs for a character driver
+ * @cs: pointer to the struct class_simple that this device should be registered to.  
+ * @dev: the dev_t for the device to be added.
+ * @device: a pointer to a struct device that is assiociated with this class device.
+ * @fmt: string for the class device's name
+ *
+ * This function can be used by simple char device classes that do not
+ * implement their own class device registration.  A struct class_device will
+ * be created in sysfs, registered to the specified class.  A "dev" file will
+ * be created, showing the dev_t for the device.  The pointer to the struct
+ * class_device will be returned from the call.  Any further sysfs files that
+ * might be required can be created using this pointer.
+ * Note: the struct class_device passed to this function must have previously been
+ * created with a call to class_simple_create().
+ */
+struct class_device *class_simple_device_add(struct class_simple *cs, dev_t dev, struct device *device, const char *fmt, ...)
+{
+	va_list args;
+	struct simple_dev *s_dev = NULL;
+	int retval;
+
+	if ((cs == NULL) || (IS_ERR(cs))) {
+		retval = -ENODEV;
+		goto error;
+	}
+
+	s_dev = kmalloc(sizeof(*s_dev), GFP_KERNEL);
+	if (!s_dev) {
+		retval = -ENOMEM;
+		goto error;
+	}
+	memset(s_dev, 0x00, sizeof(*s_dev));
+
+	s_dev->dev = dev;
+	s_dev->class_dev.dev = device;
+	s_dev->class_dev.class = &cs->class;
+	
+	va_start(args,fmt);
+	vsnprintf(s_dev->class_dev.class_id, BUS_ID_SIZE, fmt, args);
+	va_end(args);
+	retval = class_device_register(&s_dev->class_dev);
+	if (retval)
+		goto error;
+
+	class_device_create_file(&s_dev->class_dev, &cs->attr);
+
+	spin_lock(&simple_dev_list_lock);
+	list_add(&s_dev->node, &simple_dev_list);
+	spin_unlock(&simple_dev_list_lock);
+
+	return &s_dev->class_dev;
+
+error:
+	kfree(s_dev);
+	return ERR_PTR(retval);
+}
+EXPORT_SYMBOL(class_simple_device_add);
+
+/**
+ * class_simple_device_remove - removes a class device that was created with class_simple_device_add()
+ * @dev: the dev_t of the device that was previously registered.
+ *
+ * This call unregisters and cleans up a class device that was created with a
+ * call to class_device_simple_add()
+ */
+void class_simple_device_remove(dev_t dev)
+{
+	struct simple_dev *s_dev = NULL;
+	struct list_head *tmp;
+	int found = 0;
+
+	spin_lock(&simple_dev_list_lock);
+	list_for_each(tmp, &simple_dev_list) {
+		s_dev = list_entry(tmp, struct simple_dev, node);
+		if (s_dev->dev == dev) {
+			found = 1;
+			break;
+		}
+	}
+	if (found) {
+		list_del(&s_dev->node);
+		spin_unlock(&simple_dev_list_lock);
+		class_device_unregister(&s_dev->class_dev);
+	} else {
+		spin_unlock(&simple_dev_list_lock);
+	}
+}
+EXPORT_SYMBOL(class_simple_device_remove);
diff -puN drivers/base/core.c~linus drivers/base/core.c
--- 25/drivers/base/core.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/base/core.c	2004-01-19 22:17:21.000000000 -0800
@@ -400,6 +400,14 @@ int device_for_each_child(struct device 
 	return error;
 }
 
+struct device *device_find(const char *name, struct bus_type *bus)
+{
+	struct kobject *k = kset_find_obj(&bus->devices, name);
+	if (k)
+		return to_dev(k);
+	return NULL;
+}
+
 int __init devices_init(void)
 {
 	return subsystem_register(&devices_subsys);
@@ -416,6 +424,7 @@ EXPORT_SYMBOL(device_unregister);
 EXPORT_SYMBOL(device_unregister_wait);
 EXPORT_SYMBOL(get_device);
 EXPORT_SYMBOL(put_device);
+EXPORT_SYMBOL(device_find);
 
 EXPORT_SYMBOL(device_create_file);
 EXPORT_SYMBOL(device_remove_file);
diff -puN drivers/base/Makefile~linus drivers/base/Makefile
--- 25/drivers/base/Makefile~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/base/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -1,7 +1,7 @@
 # Makefile for the Linux device tree
 
 obj-y			:= core.o sys.o interface.o bus.o \
-			   driver.o class.o platform.o \
+			   driver.o class.o class_simple.o platform.o \
 			   cpu.o firmware.o init.o map.o
 obj-y			+= power/
 obj-$(CONFIG_FW_LOADER)	+= firmware_class.o
diff -puN drivers/block/as-iosched.c~linus drivers/block/as-iosched.c
--- 25/drivers/block/as-iosched.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/block/as-iosched.c	2004-01-19 22:17:21.000000000 -0800
@@ -31,19 +31,19 @@
 /*
  * max time before a read is submitted.
  */
-#define default_read_expire (HZ / 20)
+#define default_read_expire (HZ / 8)
 
 /*
  * ditto for writes, these limits are not hard, even
  * if the disk is capable of satisfying them.
  */
-#define default_write_expire (HZ / 5)
+#define default_write_expire (HZ / 4)
 
 /*
  * read_batch_expire describes how long we will allow a stream of reads to
  * persist before looking to see whether it is time to switch over to writes.
  */
-#define default_read_batch_expire (HZ / 5)
+#define default_read_batch_expire (HZ / 4)
 
 /*
  * write_batch_expire describes how long we want a stream of writes to run for.
@@ -51,7 +51,7 @@
  * See, the problem is: we can send a lot of writes to disk cache / TCQ in
  * a short amount of time...
  */
-#define default_write_batch_expire (HZ / 20)
+#define default_write_batch_expire (HZ / 16)
 
 /*
  * max time we may wait to anticipate a read (default around 6ms)
@@ -70,6 +70,7 @@
 /* Bits in as_io_context.state */
 enum as_io_states {
 	AS_TASK_RUNNING=0,	/* Process has not exitted */
+	AS_TASK_IOSTARTED,	/* Process has started some IO */
 	AS_TASK_IORUNNING,	/* Process has completed some IO */
 };
 
@@ -99,7 +100,14 @@ struct as_data {
 	sector_t last_sector[2];	/* last REQ_SYNC & REQ_ASYNC sectors */
 	struct list_head *dispatch;	/* driver dispatch queue */
 	struct list_head *hash;		/* request hash */
-	unsigned long new_success; /* anticipation success on new proc */
+
+	unsigned long exit_prob;	/* probability a task will exit while
+					   being waited on */
+	unsigned long new_ttime_total; 	/* mean thinktime on new proc */
+	unsigned long new_ttime_mean;
+	u64 new_seek_total;		/* mean seek on new proc */
+	sector_t new_seek_mean;
+
 	unsigned long current_batch_expires;
 	unsigned long last_check_fifo[2];
 	int changed_batch;		/* 1: waiting for old batch to end */
@@ -137,6 +145,10 @@ enum arq_state {
 				   scheduler */
 	AS_RQ_DISPATCHED,	/* On the dispatch list. It belongs to the
 				   driver now */
+	AS_RQ_PRESCHED,		/* Debug poisoning for requests being used */
+	AS_RQ_REMOVED,
+	AS_RQ_MERGED,
+	AS_RQ_POSTSCHED,	/* when they shouldn't be */
 };
 
 struct as_rq {
@@ -183,6 +195,7 @@ static void free_as_io_context(struct as
 /* Called when the task exits */
 static void exit_as_io_context(struct as_io_context *aic)
 {
+	WARN_ON(!test_bit(AS_TASK_RUNNING, &aic->state));
 	clear_bit(AS_TASK_RUNNING, &aic->state);
 }
 
@@ -413,6 +426,8 @@ as_find_arq_rb(struct as_data *ad, secto
 				 * for a request.
 				 */
 
+#define BACK_PENALTY	2
+
 /*
  * as_choose_req selects the preferred one of two requests of the same data_dir
  * ignoring time - eg. timeouts, which is the job of as_dispatch_request
@@ -446,7 +461,7 @@ as_choose_req(struct as_data *ad, struct
 	if (s1 >= last)
 		d1 = s1 - last;
 	else if (s1+maxback >= last)
-		d1 = (last - s1)*2;
+		d1 = (last - s1)*BACK_PENALTY;
 	else {
 		r1_wrap = 1;
 		d1 = 0; /* shut up, gcc */
@@ -455,7 +470,7 @@ as_choose_req(struct as_data *ad, struct
 	if (s2 >= last)
 		d2 = s2 - last;
 	else if (s2+maxback >= last)
-		d2 = (last - s2)*2;
+		d2 = (last - s2)*BACK_PENALTY;
 	else {
 		r2_wrap = 1;
 		d2 = 0;
@@ -585,18 +600,11 @@ static void as_antic_stop(struct as_data
 	int status = ad->antic_status;
 
 	if (status == ANTIC_WAIT_REQ || status == ANTIC_WAIT_NEXT) {
-		struct as_io_context *aic;
-
 		if (status == ANTIC_WAIT_NEXT)
 			del_timer(&ad->antic_timer);
 		ad->antic_status = ANTIC_FINISHED;
 		/* see as_work_handler */
 		kblockd_schedule_work(&ad->antic_work);
-
-		aic = ad->io_context->aic;
-		if (aic->seek_samples == 0)
-			/* new process */
-			ad->new_success = (ad->new_success * 3) / 4 + 256;
 	}
 }
 
@@ -612,14 +620,15 @@ static void as_antic_timeout(unsigned lo
 	spin_lock_irqsave(q->queue_lock, flags);
 	if (ad->antic_status == ANTIC_WAIT_REQ
 			|| ad->antic_status == ANTIC_WAIT_NEXT) {
-		struct as_io_context *aic;
+		struct as_io_context *aic = ad->io_context->aic;
+
 		ad->antic_status = ANTIC_FINISHED;
 		kblockd_schedule_work(&ad->antic_work);
 
-		aic = ad->io_context->aic;
-		if (aic->seek_samples == 0)
-			/* new process */
-			ad->new_success = (ad->new_success * 3) / 4;
+		if (aic->ttime_samples == 0) {
+			/* process anticipated on has exitted or timed out*/
+			ad->exit_prob = (7*ad->exit_prob + 256)/8;
+		}
 	}
 	spin_unlock_irqrestore(q->queue_lock, flags);
 }
@@ -633,7 +642,7 @@ static int as_close_req(struct as_data *
 	unsigned long delay;	/* milliseconds */
 	sector_t last = ad->last_sector[ad->batch_data_dir];
 	sector_t next = arq->request->sector;
-	sector_t delta;	/* acceptable close offset (in sectors) */
+	sector_t delta; /* acceptable close offset (in sectors) */
 
 	if (ad->antic_status == ANTIC_OFF || !ad->ioc_finished)
 		delay = 0;
@@ -667,9 +676,13 @@ static int as_can_break_anticipation(str
 {
 	struct io_context *ioc;
 	struct as_io_context *aic;
+	sector_t s;
 
-	if (arq && arq->is_sync == REQ_SYNC && as_close_req(ad, arq)) {
-		/* close request */
+	ioc = ad->io_context;
+	BUG_ON(!ioc);
+
+	if (arq && ioc == arq->io_context) {
+		/* request from same process */
 		return 1;
 	}
 
@@ -681,20 +694,14 @@ static int as_can_break_anticipation(str
 		return 1;
 	}
 
-	ioc = ad->io_context;
-	BUG_ON(!ioc);
-
-	if (arq && ioc == arq->io_context) {
-		/* request from same process */
-		return 1;
-	}
-
 	aic = ioc->aic;
 	if (!aic)
 		return 0;
 
 	if (!test_bit(AS_TASK_RUNNING, &aic->state)) {
 		/* process anticipated on has exitted */
+		if (aic->ttime_samples == 0)
+			ad->exit_prob = (7*ad->exit_prob + 256)/8;
 		return 1;
 	}
 
@@ -708,28 +715,52 @@ static int as_can_break_anticipation(str
 		return 1;
 	}
 
-	if (ad->new_success < 256 &&
-			(aic->seek_samples == 0 || aic->ttime_samples == 0)) {
+	if (arq && arq->is_sync == REQ_SYNC && as_close_req(ad, arq)) {
 		/*
-		 * Process has just started IO and we have a bad history of
-		 * success anticipating on new processes!
+		 * Found a close request that is not one of ours.
+		 *
+		 * This makes close requests from another process reset
+		 * our thinktime delay. Is generally useful when there are
+		 * two or more cooperating processes working in the same
+		 * area.
 		 */
+		spin_lock(&aic->lock);
+		aic->last_end_request = jiffies;
+		spin_unlock(&aic->lock);
 		return 1;
 	}
 
-	if (aic->ttime_mean > ad->antic_expire) {
+
+	if (aic->ttime_samples == 0) {
+		if (ad->new_ttime_mean > ad->antic_expire)
+			return 1;
+		if (ad->exit_prob > 128)
+			return 1;
+	} else if (aic->ttime_mean > ad->antic_expire) {
 		/* the process thinks too much between requests */
 		return 1;
 	}
 
-	if (arq && aic->seek_samples) {
-		sector_t s;
-		if (ad->last_sector[REQ_SYNC] < arq->request->sector)
-			s = arq->request->sector - ad->last_sector[REQ_SYNC];
-		else
-			s = ad->last_sector[REQ_SYNC] - arq->request->sector;
+	if (!arq)
+		return 0;
 
-		if (aic->seek_mean > (s>>1)) {
+	if (ad->last_sector[REQ_SYNC] < arq->request->sector)
+		s = arq->request->sector - ad->last_sector[REQ_SYNC];
+	else
+		s = ad->last_sector[REQ_SYNC] - arq->request->sector;
+
+	if (aic->seek_samples == 0) {
+		/*
+		 * Process has just started IO. Use past statistics to
+		 * guage success possibility
+		 */
+		if (ad->new_seek_mean > s) {
+			/* this request is better than what we're expecting */
+			return 1;
+		}
+
+	} else {
+		if (aic->seek_mean > s) {
 			/* this request is better than what we're expecting */
 			return 1;
 		}
@@ -774,12 +805,51 @@ static int as_can_anticipate(struct as_d
 	return 1;
 }
 
+static void as_update_thinktime(struct as_data *ad, struct as_io_context *aic, unsigned long ttime)
+{
+	/* fixed point: 1.0 == 1<<8 */
+	if (aic->ttime_samples == 0) {
+		ad->new_ttime_total = (7*ad->new_ttime_total + 256*ttime) / 8;
+		ad->new_ttime_mean = ad->new_ttime_total / 256;
+
+		ad->exit_prob = (7*ad->exit_prob)/8;
+	}
+	aic->ttime_samples = (7*aic->ttime_samples + 256) / 8;
+	aic->ttime_total = (7*aic->ttime_total + 256*ttime) / 8;
+	aic->ttime_mean = (aic->ttime_total + 128) / aic->ttime_samples;
+}
+
+static void as_update_seekdist(struct as_data *ad, struct as_io_context *aic, sector_t sdist)
+{
+	u64 total;
+
+	if (aic->seek_samples == 0) {
+		ad->new_seek_total = (7*ad->new_seek_total + 256*(u64)sdist)/8;
+		ad->new_seek_mean = ad->new_seek_total / 256;
+	}
+
+	/*
+	 * Don't allow the seek distance to get too large from the
+	 * odd fragment, pagein, etc
+	 */
+	if (aic->seek_samples <= 60) /* second&third seek */
+		sdist = min(sdist, (aic->seek_mean * 4) + 2*1024*1024);
+	else
+		sdist = min(sdist, (aic->seek_mean * 4)	+ 2*1024*64);
+
+	aic->seek_samples = (7*aic->seek_samples + 256) / 8;
+	aic->seek_total = (7*aic->seek_total + (u64)256*sdist) / 8;
+	total = aic->seek_total + (aic->seek_samples/2);
+	do_div(total, aic->seek_samples);
+	aic->seek_mean = (sector_t)total;
+}
+
 /*
  * as_update_iohist keeps a decaying histogram of IO thinktimes, and
  * updates @aic->ttime_mean based on that. It is called when a new
  * request is queued.
  */
-static void as_update_iohist(struct as_io_context *aic, struct request *rq)
+static void as_update_iohist(struct as_data *ad, struct as_io_context *aic, struct request *rq)
 {
 	struct as_rq *arq = RQ_DATA(rq);
 	int data_dir = arq->is_sync;
@@ -790,60 +860,29 @@ static void as_update_iohist(struct as_i
 		return;
 
 	if (data_dir == REQ_SYNC) {
+		unsigned long in_flight = atomic_read(&aic->nr_queued)
+					+ atomic_read(&aic->nr_dispatched);
 		spin_lock(&aic->lock);
-
-		if (test_bit(AS_TASK_IORUNNING, &aic->state)
-				&& !atomic_read(&aic->nr_queued)
-				&& !atomic_read(&aic->nr_dispatched)) {
+		if (test_bit(AS_TASK_IORUNNING, &aic->state) ||
+			test_bit(AS_TASK_IOSTARTED, &aic->state)) {
 			/* Calculate read -> read thinktime */
-			thinktime = jiffies - aic->last_end_request;
-			thinktime = min(thinktime, MAX_THINKTIME-1);
-			/* fixed point: 1.0 == 1<<8 */
-			aic->ttime_samples += 256;
-			aic->ttime_total += 256*thinktime;
-			if (aic->ttime_samples)
-				/* fixed point factor is cancelled here */
-				aic->ttime_mean = (aic->ttime_total + 128)
-							/ aic->ttime_samples;
-			aic->ttime_samples = (aic->ttime_samples>>1)
-						+ (aic->ttime_samples>>2);
-			aic->ttime_total = (aic->ttime_total>>1)
-						+ (aic->ttime_total>>2);
-		}
-
-		/* Calculate read -> read seek distance */
-		if (!aic->seek_samples)
-			seek_dist = 0;
-		else if (aic->last_request_pos < rq->sector)
-			seek_dist = rq->sector - aic->last_request_pos;
-		else
-			seek_dist = aic->last_request_pos - rq->sector;
-
+			if (test_bit(AS_TASK_IORUNNING, &aic->state)
+							&& in_flight == 0) {
+				thinktime = jiffies - aic->last_end_request;
+				thinktime = min(thinktime, MAX_THINKTIME-1);
+			} else
+				thinktime = 0;
+			as_update_thinktime(ad, aic, thinktime);
+
+			/* Calculate read -> read seek distance */
+			if (aic->last_request_pos < rq->sector)
+				seek_dist = rq->sector - aic->last_request_pos;
+			else
+				seek_dist = aic->last_request_pos - rq->sector;
+			as_update_seekdist(ad, aic, seek_dist);
+		}
 		aic->last_request_pos = rq->sector + rq->nr_sectors;
-
-		/*
-		 * Don't allow the seek distance to get too large from the
-		 * odd fragment, pagein, etc
-		 */
-		if (aic->seek_samples < 400) /* second&third seek */
-			seek_dist = min(seek_dist, (aic->seek_mean * 4)
-							+ 2*1024*1024);
-		else
-			seek_dist = min(seek_dist, (aic->seek_mean * 4)
-							+ 2*1024*64);
-
-		aic->seek_samples += 256;
-		aic->seek_total += (u64)256*seek_dist;
-		if (aic->seek_samples) {
-			u64 total = aic->seek_total + (aic->seek_samples>>1);
-			do_div(total, aic->seek_samples);
-			aic->seek_mean = (sector_t)total;
-		}
-		aic->seek_samples = (aic->seek_samples>>1)
-					+ (aic->seek_samples>>2);
-		aic->seek_total = (aic->seek_total>>1)
-					+ (aic->seek_total>>2);
-
+		set_bit(AS_TASK_IOSTARTED, &aic->state);
 		spin_unlock(&aic->lock);
 	}
 }
@@ -908,15 +947,25 @@ static void as_completed_request(request
 {
 	struct as_data *ad = q->elevator.elevator_data;
 	struct as_rq *arq = RQ_DATA(rq);
-	struct as_io_context *aic;
 
 	WARN_ON(!list_empty(&rq->queuelist));
 
-	if (unlikely(arq->state != AS_RQ_DISPATCHED))
-		return;
+	if (arq->state == AS_RQ_PRESCHED) {
+		WARN_ON(arq->io_context);
+		goto out;
+	}
+
+	if (arq->state == AS_RQ_MERGED)
+		goto out_ioc;
+
+	if (arq->state != AS_RQ_REMOVED) {
+		printk("arq->state %d\n", arq->state);
+		WARN_ON(1);
+		goto out;
+	}
 
 	if (!blk_fs_request(rq))
-		return;
+		goto out;
 
 	if (ad->changed_batch && ad->nr_dispatched == 1) {
 		kblockd_schedule_work(&ad->antic_work);
@@ -940,10 +989,7 @@ static void as_completed_request(request
 		ad->new_batch = 0;
 	}
 
-	if (!arq->io_context)
-		return;
-
-	if (ad->io_context == arq->io_context) {
+	if (ad->io_context == arq->io_context && ad->io_context) {
 		ad->antic_start = jiffies;
 		ad->ioc_finished = 1;
 		if (ad->antic_status == ANTIC_WAIT_REQ) {
@@ -955,18 +1001,23 @@ static void as_completed_request(request
 		}
 	}
 
-	aic = arq->io_context->aic;
-	if (!aic)
-		return;
+out_ioc:
+	if (!arq->io_context)
+		goto out;
 
-	spin_lock(&aic->lock);
 	if (arq->is_sync == REQ_SYNC) {
-		set_bit(AS_TASK_IORUNNING, &aic->state);
-		aic->last_end_request = jiffies;
+		struct as_io_context *aic = arq->io_context->aic;
+		if (aic) {
+			spin_lock(&aic->lock);
+			set_bit(AS_TASK_IORUNNING, &aic->state);
+			aic->last_end_request = jiffies;
+			spin_unlock(&aic->lock);
+		}
 	}
-	spin_unlock(&aic->lock);
 
 	put_io_context(arq->io_context);
+out:
+	arq->state = AS_RQ_POSTSCHED;
 }
 
 /*
@@ -1035,14 +1086,14 @@ static void as_remove_request(request_qu
 	struct as_rq *arq = RQ_DATA(rq);
 
 	if (unlikely(arq->state == AS_RQ_NEW))
-		return;
-
-	if (!arq) {
-		WARN_ON(1);
-		return;
-	}
+		goto out;
 
 	if (ON_RB(&arq->rb_node)) {
+		if (arq->state != AS_RQ_QUEUED) {
+			printk("arq->state %d\n", arq->state);
+			WARN_ON(1);
+			goto out;
+		}
 		/*
 		 * We'll lose the aliased request(s) here. I don't think this
 		 * will ever happen, but if it does, hopefully someone will
@@ -1050,8 +1101,16 @@ static void as_remove_request(request_qu
 		 */
 		WARN_ON(!list_empty(&rq->queuelist));
 		as_remove_queued_request(q, rq);
-	} else
+	} else {
+		if (arq->state != AS_RQ_DISPATCHED) {
+			printk("arq->state %d\n", arq->state);
+			WARN_ON(1);
+			goto out;
+		}
 		as_remove_dispatched_request(q, rq);
+	}
+out:
+	arq->state = AS_RQ_REMOVED;
 }
 
 /*
@@ -1229,9 +1288,9 @@ static int as_dispatch_request(struct as
 			 */
 			goto dispatch_writes;
 
- 		if (ad->batch_data_dir == REQ_ASYNC) {
+		if (ad->batch_data_dir == REQ_ASYNC) {
 			WARN_ON(ad->new_batch);
- 			ad->changed_batch = 1;
+			ad->changed_batch = 1;
 		}
 		ad->batch_data_dir = REQ_SYNC;
 		arq = list_entry_fifo(ad->fifo_list[ad->batch_data_dir].next);
@@ -1247,8 +1306,8 @@ static int as_dispatch_request(struct as
 dispatch_writes:
 		BUG_ON(RB_EMPTY(&ad->sort_list[REQ_ASYNC]));
 
- 		if (ad->batch_data_dir == REQ_SYNC) {
- 			ad->changed_batch = 1;
+		if (ad->batch_data_dir == REQ_SYNC) {
+			ad->changed_batch = 1;
 
 			/*
 			 * new_batch might be 1 when the queue runs out of
@@ -1291,8 +1350,6 @@ fifo_expired:
 			ad->new_batch = 1;
 
 		ad->changed_batch = 0;
-
-		arq->request->flags |= REQ_SOFTBARRIER;
 	}
 
 	/*
@@ -1369,8 +1426,8 @@ static void as_add_request(struct as_dat
 	arq->io_context = as_get_io_context();
 
 	if (arq->io_context) {
+		as_update_iohist(ad, arq->io_context->aic, arq->request);
 		atomic_inc(&arq->io_context->aic->nr_queued);
-		as_update_iohist(arq->io_context->aic, arq->request);
 	}
 
 	alias = as_add_arq_rb(ad, arq);
@@ -1391,6 +1448,7 @@ static void as_add_request(struct as_dat
 
 	} else {
 		as_add_aliased_request(ad, arq, alias);
+
 		/*
 		 * have we been anticipating this request?
 		 * or does it come from the same process as the one we are
@@ -1416,6 +1474,11 @@ static void as_requeue_request(request_q
 	struct as_rq *arq = RQ_DATA(rq);
 
 	if (arq) {
+		if (arq->state != AS_RQ_REMOVED) {
+			printk("arq->state %d\n", arq->state);
+			WARN_ON(1);
+		}
+
 		arq->state = AS_RQ_DISPATCHED;
 		if (arq->io_context && arq->io_context->aic)
 			atomic_inc(&arq->io_context->aic->nr_dispatched);
@@ -1427,8 +1490,6 @@ static void as_requeue_request(request_q
 
 	/* Stop anticipating - let this request get through */
 	as_antic_stop(ad);
-
-	return;
 }
 
 static void
@@ -1437,10 +1498,20 @@ as_insert_request(request_queue_t *q, st
 	struct as_data *ad = q->elevator.elevator_data;
 	struct as_rq *arq = RQ_DATA(rq);
 
+	if (arq) {
+		if (arq->state != AS_RQ_PRESCHED) {
+			printk("arq->state: %d\n", arq->state);
+			WARN_ON(1);
+		}
+		arq->state = AS_RQ_NEW;
+	}
+
 	/* barriers must flush the reorder queue */
 	if (unlikely(rq->flags & (REQ_SOFTBARRIER | REQ_HARDBARRIER)
-			&& where == ELEVATOR_INSERT_SORT))
+			&& where == ELEVATOR_INSERT_SORT)) {
+		WARN_ON(1);
 		where = ELEVATOR_INSERT_BACK;
+	}
 
 	switch (where) {
 		case ELEVATOR_INSERT_BACK:
@@ -1675,7 +1746,8 @@ as_merged_requests(request_queue_t *q, s
 	 * kill knowledge of next, this one is a goner
 	 */
 	as_remove_queued_request(q, next);
-	put_io_context(anext->io_context);
+
+	anext->state = AS_RQ_MERGED;
 }
 
 /*
@@ -1708,6 +1780,11 @@ static void as_put_request(request_queue
 		return;
 	}
 
+	if (arq->state != AS_RQ_POSTSCHED && arq->state != AS_RQ_PRESCHED) {
+		printk("arq->state %d\n", arq->state);
+		WARN_ON(1);
+	}
+
 	mempool_free(arq, ad->arq_pool);
 	rq->elevator_private = NULL;
 }
@@ -1721,7 +1798,7 @@ static int as_set_request(request_queue_
 		memset(arq, 0, sizeof(*arq));
 		RB_CLEAR(&arq->rb_node);
 		arq->request = rq;
-		arq->state = AS_RQ_NEW;
+		arq->state = AS_RQ_PRESCHED;
 		arq->io_context = NULL;
 		INIT_LIST_HEAD(&arq->hash);
 		arq->on_hash = 0;
@@ -1823,8 +1900,6 @@ static int as_init(request_queue_t *q, e
 	if (ad->write_batch_count < 2)
 		ad->write_batch_count = 2;
 
-	ad->new_success = 512;
-
 	return 0;
 }
 
@@ -1860,6 +1935,17 @@ as_var_store(unsigned long *var, const c
 	return count;
 }
 
+static ssize_t as_est_show(struct as_data *ad, char *page)
+{
+	int pos = 0;
+
+	pos += sprintf(page+pos, "%lu %% exit probability\n", 100*ad->exit_prob/256);
+	pos += sprintf(page+pos, "%lu ms new thinktime\n", ad->new_ttime_mean);
+	pos += sprintf(page+pos, "%llu sectors new seek distance\n", (unsigned long long)ad->new_seek_mean);
+
+	return pos;
+}
+
 #define SHOW_FUNCTION(__FUNC, __VAR)					\
 static ssize_t __FUNC(struct as_data *ad, char *page)		\
 {									\
@@ -1891,6 +1977,10 @@ STORE_FUNCTION(as_write_batchexpire_stor
 			&ad->batch_expire[REQ_ASYNC], 0, INT_MAX);
 #undef STORE_FUNCTION
 
+static struct as_fs_entry as_est_entry = {
+	.attr = {.name = "est_time", .mode = S_IRUGO },
+	.show = as_est_show,
+};
 static struct as_fs_entry as_readexpire_entry = {
 	.attr = {.name = "read_expire", .mode = S_IRUGO | S_IWUSR },
 	.show = as_readexpire_show,
@@ -1918,6 +2008,7 @@ static struct as_fs_entry as_write_batch
 };
 
 static struct attribute *default_attrs[] = {
+	&as_est_entry.attr,
 	&as_readexpire_entry.attr,
 	&as_writeexpire_entry.attr,
 	&as_anticexpire_entry.attr,
diff -puN drivers/block/elevator.c~linus drivers/block/elevator.c
--- 25/drivers/block/elevator.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/block/elevator.c	2004-01-19 22:17:21.000000000 -0800
@@ -165,6 +165,7 @@ void __elv_add_request(request_queue_t *
 	if (plug)
 		blk_plug_device(q);
 
+	rq->q = q;
 	q->elevator.elevator_add_req_fn(q, rq, where);
 }
 
diff -puN drivers/block/floppy98.c~linus drivers/block/floppy98.c
--- 25/drivers/block/floppy98.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/block/floppy98.c	2004-01-19 22:17:21.000000000 -0800
@@ -3859,8 +3859,7 @@ static int floppy_open(struct inode * in
 	/* Allow ioctls if we have write-permissions even if read-only open.
 	 * Needed so that programs such as fdrawcmd still can work on write
 	 * protected disks */
-	if ((filp->f_mode & 2) || 
-	    (inode->i_sb && (permission(inode,2) == 0)))
+	if (filp->f_mode & 2 || permission(filp->f_dentry->d_inode,2,NULL) == 0)
 	    filp->private_data = (void*) 8;
 
 	if (UFDCS->rawcmd == 1)
diff -puN drivers/block/floppy.c~linus drivers/block/floppy.c
--- 25/drivers/block/floppy.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/block/floppy.c	2004-01-19 22:17:21.000000000 -0800
@@ -3784,8 +3784,7 @@ static int floppy_open(struct inode * in
 	/* Allow ioctls if we have write-permissions even if read-only open.
 	 * Needed so that programs such as fdrawcmd still can work on write
 	 * protected disks */
-	if ((filp->f_mode & 2) || 
-	    (inode->i_sb && (permission(inode,2, NULL) == 0)))
+	if (filp->f_mode & 2 || permission(filp->f_dentry->d_inode,2,NULL) == 0)
 	    filp->private_data = (void*) 8;
 
 	if (UFDCS->rawcmd == 1)
diff -puN drivers/block/Kconfig~linus drivers/block/Kconfig
--- 25/drivers/block/Kconfig~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/block/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -6,7 +6,7 @@ menu "Block devices"
 
 config BLK_DEV_FD
 	tristate "Normal floppy disk support"
-	depends on !X86_PC9800 && !ARCH_S390
+	depends on (!X86_PC9800 && !ARCH_S390 && !M68K) || Q40 || (SUN3X && BROKEN)
 	---help---
 	  If you want to use the floppy disk drive(s) of your PC under Linux,
 	  say Y. Information about this driver, especially important for IBM
diff -puN drivers/block/ll_rw_blk.c~linus drivers/block/ll_rw_blk.c
--- 25/drivers/block/ll_rw_blk.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/block/ll_rw_blk.c	2004-01-19 22:17:21.000000000 -0800
@@ -173,9 +173,11 @@ EXPORT_SYMBOL(blk_queue_prep_rq);
  * are dynamic, and thus we have to query the queue whether it is ok to
  * add a new bio_vec to a bio at a given offset or not. If the block device
  * has such limitations, it needs to register a merge_bvec_fn to control
- * the size of bio's sent to it. Per default now merge_bvec_fn is defined for
- * a queue, and only the fixed limits are honored.
- *
+ * the size of bio's sent to it. Note that a block device *must* allow a
+ * single page to be added to an empty bio. The block device driver may want
+ * to use the bio_split() function to deal with these bio's. By default
+ * no merge_bvec_fn is defined for a queue, and only the fixed limits are
+ * honored.
  */
 void blk_queue_merge_bvec(request_queue_t *q, merge_bvec_fn *mbfn)
 {
@@ -1834,8 +1836,6 @@ void __blk_put_request(request_queue_t *
 	if (unlikely(--req->ref_count))
 		return;
 
-	elv_completed_request(req->q, req);
-
 	req->rq_status = RQ_INACTIVE;
 	req->q = NULL;
 	req->rl = NULL;
@@ -1847,6 +1847,8 @@ void __blk_put_request(request_queue_t *
 	if (rl) {
 		int rw = rq_data_dir(req);
 
+		elv_completed_request(q, req);
+
 		BUG_ON(!list_empty(&req->queuelist));
 
 		blk_free_request(q, req);
@@ -1856,14 +1858,13 @@ void __blk_put_request(request_queue_t *
 
 void blk_put_request(struct request *req)
 {
-	request_queue_t *q = req->q;
-	
 	/*
-	 * if req->q isn't set, this request didnt originate from the
+	 * if req->rl isn't set, this request didnt originate from the
 	 * block layer, so it's safe to just disregard it
 	 */
-	if (q) {
+	if (req->rl) {
 		unsigned long flags;
+		request_queue_t *q = req->q;
 
 		spin_lock_irqsave(q->queue_lock, flags);
 		__blk_put_request(q, req);
@@ -2489,8 +2490,6 @@ static int __end_that_request_first(stru
 			 * not a complete bvec done
 			 */
 			if (unlikely(nbytes > nr_bytes)) {
-				bio_iovec_idx(bio, idx)->bv_offset += nr_bytes;
-				bio_iovec_idx(bio, idx)->bv_len -= nr_bytes;
 				bio_nbytes += nr_bytes;
 				total_bytes += nr_bytes;
 				break;
@@ -2526,7 +2525,9 @@ static int __end_that_request_first(stru
 	 */
 	if (bio_nbytes) {
 		bio_endio(bio, bio_nbytes, error);
-		req->bio->bi_idx += next_idx;
+		bio->bi_idx += next_idx;
+		bio_iovec(bio)->bv_offset += nr_bytes;
+		bio_iovec(bio)->bv_len -= nr_bytes;
 	}
 
 	blk_recalc_rq_sectors(req, total_bytes >> 9);
@@ -2897,7 +2898,7 @@ int blk_register_queue(struct gendisk *d
 
 	request_queue_t *q = disk->queue;
 
-	if (!q)
+	if (!q || !q->request_fn)
 		return -ENXIO;
 
 	q->kobj.parent = kobject_get(&disk->kobj);
@@ -2924,7 +2925,7 @@ void blk_unregister_queue(struct gendisk
 {
 	request_queue_t *q = disk->queue;
 
-	if (q) {
+	if (q && q->request_fn) {
 		elv_unregister_queue(q);
 
 		kobject_unregister(&q->kobj);
diff -puN drivers/block/loop.c~linus drivers/block/loop.c
--- 25/drivers/block/loop.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/block/loop.c	2004-01-19 22:17:21.000000000 -0800
@@ -140,8 +140,7 @@ figure_loop_size(struct loop_device *lo)
 	sector_t x;
 
 	/* Compute loopsize in bytes */
-	size = i_size_read(lo->lo_backing_file->f_dentry->
-				d_inode->i_mapping->host);
+	size = i_size_read(lo->lo_backing_file->f_mapping->host);
 	offset = lo->lo_offset;
 	loopsize = size - offset;
 	if (lo->lo_sizelimit > 0 && lo->lo_sizelimit < loopsize)
@@ -175,7 +174,7 @@ static int
 do_lo_send(struct loop_device *lo, struct bio_vec *bvec, int bsize, loff_t pos)
 {
 	struct file *file = lo->lo_backing_file; /* kudos to NFsckingS */
-	struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
+	struct address_space *mapping = file->f_mapping;
 	struct address_space_operations *aops = mapping->a_ops;
 	struct page *page;
 	char *kaddr, *data;
@@ -660,6 +659,7 @@ static int loop_set_fd(struct loop_devic
 	struct file	*file;
 	struct inode	*inode;
 	struct block_device *lo_device = NULL;
+	struct address_space *mapping;
 	unsigned lo_blocksize;
 	int		lo_flags = 0;
 	int		error;
@@ -676,27 +676,28 @@ static int loop_set_fd(struct loop_devic
 	if (!file)
 		goto out;
 
-	error = -EINVAL;
-	inode = file->f_dentry->d_inode;
+	mapping = file->f_mapping;
+	inode = mapping->host;
 
 	if (!(file->f_mode & FMODE_WRITE))
 		lo_flags |= LO_FLAGS_READ_ONLY;
 
 	if (S_ISBLK(inode->i_mode)) {
-		lo_device = inode->i_bdev;
+		lo_device = I_BDEV(inode);
 		if (lo_device == bdev) {
 			error = -EBUSY;
-			goto out;
+			goto out_putf;
 		}
 		lo_blocksize = block_size(lo_device);
 		if (bdev_read_only(lo_device))
 			lo_flags |= LO_FLAGS_READ_ONLY;
 	} else if (S_ISREG(inode->i_mode)) {
-		struct address_space_operations *aops = inode->i_mapping->a_ops;
+		struct address_space_operations *aops = mapping->a_ops;
 		/*
 		 * If we can't read - sorry. If we only can't write - well,
 		 * it's going to be read-only.
 		 */
+		error = -EINVAL;
 		if (!inode->i_fop->sendfile)
 			goto out_putf;
 
@@ -709,8 +710,6 @@ static int loop_set_fd(struct loop_devic
 	} else
 		goto out_putf;
 
-	get_file(file);
-
 	if (!(lo_file->f_mode & FMODE_WRITE))
 		lo_flags |= LO_FLAGS_READ_ONLY;
 
@@ -725,14 +724,10 @@ static int loop_set_fd(struct loop_devic
 	lo->lo_sizelimit = 0;
 	if (figure_loop_size(lo)) {
 		error = -EFBIG;
-		fput(file);
 		goto out_putf;
 	}
-	lo->old_gfp_mask = mapping_gfp_mask(inode->i_mapping);
-	mapping_set_gfp_mask(inode->i_mapping,
-			     lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS));
-
-	set_blocksize(bdev, lo_blocksize);
+	lo->old_gfp_mask = mapping_gfp_mask(mapping);
+	mapping_set_gfp_mask(mapping, lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS));
 
 	lo->lo_bio = lo->lo_biotail = NULL;
 
@@ -752,15 +747,16 @@ static int loop_set_fd(struct loop_devic
 		blk_queue_max_sectors(lo->lo_queue, q->max_sectors);
 		blk_queue_max_phys_segments(lo->lo_queue,q->max_phys_segments);
 		blk_queue_max_hw_segments(lo->lo_queue, q->max_hw_segments);
+		blk_queue_hardsect_size(lo->lo_queue, queue_hardsect_size(q));
 		blk_queue_max_segment_size(lo->lo_queue, q->max_segment_size);
 		blk_queue_segment_boundary(lo->lo_queue, q->seg_boundary_mask);
 		blk_queue_merge_bvec(lo->lo_queue, q->merge_bvec_fn);
 	}
 
+	set_blocksize(bdev, lo_blocksize);
+
 	kernel_thread(loop_thread, lo, CLONE_KERNEL);
 	down(&lo->lo_sem);
-
-	fput(file);
 	return 0;
 
  out_putf:
@@ -846,7 +842,7 @@ static int loop_clr_fd(struct loop_devic
 	memset(lo->lo_file_name, 0, LO_NAME_SIZE);
 	invalidate_bdev(bdev, 0);
 	set_capacity(disks[lo->lo_number], 0);
-	mapping_set_gfp_mask(filp->f_dentry->d_inode->i_mapping, gfp);
+	mapping_set_gfp_mask(filp->f_mapping, gfp);
 	lo->lo_state = Lo_unbound;
 	fput(filp);
 	/* This is safe: open() is still holding a reference. */
diff -puN /dev/null drivers/bluetooth/bcm203x.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/bluetooth/bcm203x.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,309 @@
+/*
+ *
+ *  Broadcom Blutonium firmware driver
+ *
+ *  Copyright (C) 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 as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/timer.h>
+
+#include <linux/device.h>
+#include <linux/firmware.h>
+
+#include <linux/usb.h>
+
+#include <net/bluetooth/bluetooth.h>
+
+#ifndef CONFIG_BT_HCIBCM203X_DEBUG
+#undef  BT_DBG
+#define BT_DBG(D...)
+#endif
+
+#define VERSION "1.0"
+
+static struct usb_device_id bcm203x_table[] = {
+	/* Broadcom Blutonium (BCM2033) */
+	{ USB_DEVICE(0x0a5c, 0x2033) },
+
+	{ }	/* Terminating entry */
+};
+
+MODULE_DEVICE_TABLE(usb, bcm203x_table);
+
+
+#define BCM203X_ERROR		0
+#define BCM203X_RESET		1
+#define BCM203X_LOAD_MINIDRV	2
+#define BCM203X_SELECT_MEMORY	3
+#define BCM203X_CHECK_MEMORY	4
+#define BCM203X_LOAD_FIRMWARE	5
+#define BCM203X_CHECK_FIRMWARE	6
+
+#define BCM203X_IN_EP		0x81
+#define BCM203X_OUT_EP		0x02
+
+struct bcm203x_data {
+	struct usb_device	*udev;
+
+	unsigned long		state;
+
+	struct timer_list	timer;
+
+	struct urb		*urb;
+	unsigned char		buffer[4096];
+
+	unsigned char		*fw_data;
+	unsigned int		fw_size;
+	unsigned int		fw_sent;
+};
+
+static void bcm203x_complete(struct urb *urb, struct pt_regs *regs)
+{
+	struct bcm203x_data *data = urb->context;
+	struct usb_device *udev = urb->dev;
+	int len;
+
+	BT_DBG("udev %p urb %p", udev, urb);
+
+	if (urb->status) {
+		BT_ERR("URB failed with status %d", urb->status);
+		data->state = BCM203X_ERROR;
+		return;
+	}
+
+	switch (data->state) {
+	case BCM203X_LOAD_MINIDRV:
+		memcpy(data->buffer, "#", 1);
+
+		usb_fill_bulk_urb(urb, udev,
+				usb_sndbulkpipe(udev, BCM203X_OUT_EP),
+				data->buffer, 1, bcm203x_complete, data);
+
+		data->state = BCM203X_SELECT_MEMORY;
+
+		mod_timer(&data->timer, jiffies + (HZ / 10));
+		break;
+
+	case BCM203X_SELECT_MEMORY:
+		usb_fill_int_urb(urb, udev,
+				usb_rcvintpipe(udev, BCM203X_IN_EP),
+				data->buffer, 32, bcm203x_complete, data, 1);
+
+		data->state = BCM203X_CHECK_MEMORY;
+
+		if (usb_submit_urb(data->urb, GFP_ATOMIC) < 0)
+			BT_ERR("Can't submit URB");
+		break;
+
+	case BCM203X_CHECK_MEMORY:
+		if (data->buffer[0] != '#') {
+			BT_ERR("Memory select failed");
+			data->state = BCM203X_ERROR;
+			break;
+		}
+
+		data->state = BCM203X_LOAD_FIRMWARE;
+
+	case BCM203X_LOAD_FIRMWARE:
+		if (data->fw_sent == data->fw_size) {
+			usb_fill_int_urb(urb, udev,
+					usb_rcvintpipe(udev, BCM203X_IN_EP),
+					data->buffer, 32,
+					bcm203x_complete, data, 1);
+
+			data->state = BCM203X_CHECK_FIRMWARE;
+		} else {
+			len = min_t(uint, data->fw_size - data->fw_sent,
+							sizeof(data->buffer));
+
+			usb_fill_bulk_urb(urb, udev,
+					usb_sndbulkpipe(udev, BCM203X_OUT_EP),
+					data->fw_data + data->fw_sent, len,
+					bcm203x_complete, data);
+
+			data->fw_sent += len;
+		}
+
+		if (usb_submit_urb(data->urb, GFP_ATOMIC) < 0)
+			BT_ERR("Can't submit URB");
+		break;
+
+	case BCM203X_CHECK_FIRMWARE:
+		if (data->buffer[0] != '.') {
+			BT_ERR("Firmware loading failed");
+			data->state = BCM203X_ERROR;
+			break;
+		}
+
+		data->state = BCM203X_RESET;
+		break;
+	}
+}
+
+static void bcm203x_timer(unsigned long user_data)
+{
+	struct bcm203x_data *data = (struct bcm203x_data *) user_data;
+
+	if (usb_submit_urb(data->urb, GFP_ATOMIC) < 0)
+		BT_ERR("Can't submit URB");
+}
+
+static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id *id)
+{
+	const struct firmware *firmware;
+	struct usb_device *udev = interface_to_usbdev(intf);
+	struct bcm203x_data *data;
+
+	BT_DBG("intf %p id %p", intf, id);
+
+	if (intf->altsetting->desc.bInterfaceNumber != 0)
+		return -ENODEV;
+
+	data = kmalloc(sizeof(*data), GFP_KERNEL);
+	if (!data) {
+		BT_ERR("Can't allocate memory for data structure");
+		return -ENOMEM;
+	}
+
+	memset(data, 0, sizeof(*data));
+
+	data->udev  = udev;
+	data->state = BCM203X_LOAD_MINIDRV;
+
+	data->urb = usb_alloc_urb(0, GFP_KERNEL);
+	if (!data->urb) {
+		BT_ERR("Can't allocate URB");
+		kfree(data);
+		return -ENOMEM;
+	}
+
+	if (request_firmware(&firmware, "BCM2033-MD.hex", &udev->dev) < 0) {
+		BT_ERR("Mini driver request failed");
+		usb_free_urb(data->urb);
+		kfree(data);
+		return -EIO;
+	}
+
+	BT_DBG("minidrv data %p size %d", firmware->data, firmware->size);
+
+	if (firmware->size > sizeof(data->buffer)) {
+		BT_ERR("Mini driver exceeds size of buffer");
+		release_firmware(firmware);
+		usb_free_urb(data->urb);
+		kfree(data);
+		return -EIO;
+	}
+
+	memcpy(data->buffer, firmware->data, firmware->size);
+
+	usb_fill_bulk_urb(data->urb, udev,
+			usb_sndbulkpipe(udev, BCM203X_OUT_EP),
+			data->buffer, firmware->size, bcm203x_complete, data);
+
+	release_firmware(firmware);
+
+	if (request_firmware(&firmware, "BCM2033-FW.bin", &udev->dev) < 0) {
+		BT_ERR("Firmware request failed");
+		usb_free_urb(data->urb);
+		kfree(data);
+		return -EIO;
+	}
+
+	BT_DBG("firmware data %p size %d", firmware->data, firmware->size);
+
+	data->fw_data = kmalloc(firmware->size, GFP_KERNEL);
+	if (!data->fw_data) {
+		BT_ERR("Can't allocate memory for firmware image");
+		usb_free_urb(data->urb);
+		kfree(data);
+		return -ENOMEM;
+	}
+
+	memcpy(data->fw_data, firmware->data, firmware->size);
+	data->fw_size = firmware->size;
+	data->fw_sent = 0;
+
+	release_firmware(firmware);
+
+	init_timer(&data->timer);
+	data->timer.function = bcm203x_timer;
+	data->timer.data = (unsigned long) data;
+
+	usb_set_intfdata(intf, data);
+
+	mod_timer(&data->timer, jiffies + HZ);
+
+	return 0;
+}
+
+static void bcm203x_disconnect(struct usb_interface *intf)
+{
+	struct bcm203x_data *data = usb_get_intfdata(intf);
+
+	BT_DBG("intf %p", intf);
+
+	usb_unlink_urb(data->urb);
+
+	usb_set_intfdata(intf, NULL);
+
+	usb_free_urb(data->urb);
+	kfree(data->fw_data);
+	kfree(data);
+}
+
+static struct usb_driver bcm203x_driver = {
+	.owner		= THIS_MODULE,
+	.name		= "bcm203x",
+	.probe		= bcm203x_probe,
+	.disconnect	= bcm203x_disconnect,
+	.id_table	= bcm203x_table,
+};
+
+static int __init bcm203x_init(void)
+{
+	int err;
+
+	BT_INFO("Broadcom Blutonium firmware driver ver %s", VERSION);
+
+	err = usb_register(&bcm203x_driver);
+	if (err < 0)
+		BT_ERR("Failed to register USB driver");
+
+	return err;
+}
+
+static void __exit bcm203x_cleanup(void)
+{
+	usb_deregister(&bcm203x_driver);
+}
+
+module_init(bcm203x_init);
+module_exit(bcm203x_cleanup);
+
+MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
+MODULE_DESCRIPTION("Broadcom Blutonium firmware driver ver " VERSION);
+MODULE_LICENSE("GPL");
diff -puN /dev/null drivers/bluetooth/bfusb.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/bluetooth/bfusb.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,782 @@
+/*
+ *
+ *  AVM BlueFRITZ! USB driver
+ *
+ *  Copyright (C) 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 as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+#include <linux/sched.h>
+#include <linux/errno.h>
+#include <linux/skbuff.h>
+
+#include <linux/device.h>
+#include <linux/firmware.h>
+
+#include <linux/usb.h>
+
+#include <net/bluetooth/bluetooth.h>
+#include <net/bluetooth/hci_core.h>
+
+#ifndef CONFIG_BT_HCIBFUSB_DEBUG
+#undef  BT_DBG
+#define BT_DBG(D...)
+#endif
+
+#define VERSION "1.1"
+
+static struct usb_driver bfusb_driver;
+
+static struct usb_device_id bfusb_table[] = {
+	/* AVM BlueFRITZ! USB */
+	{ USB_DEVICE(0x057c, 0x2200) },
+
+	{ }	/* Terminating entry */
+};
+
+MODULE_DEVICE_TABLE(usb, bfusb_table);
+
+
+#define BFUSB_MAX_BLOCK_SIZE	256
+
+#define BFUSB_BLOCK_TIMEOUT	(HZ * 3)
+
+#define BFUSB_TX_PROCESS	1
+#define BFUSB_TX_WAKEUP		2
+
+#define BFUSB_MAX_BULK_TX	2
+#define BFUSB_MAX_BULK_RX	2
+
+struct bfusb {
+	struct hci_dev		hdev;
+
+	unsigned long		state;
+
+	struct usb_device	*udev;
+
+	unsigned int		bulk_in_ep;
+	unsigned int		bulk_out_ep;
+	unsigned int		bulk_pkt_size;
+
+	rwlock_t		lock;
+
+	struct sk_buff_head	transmit_q;
+
+	struct sk_buff		*reassembly;
+
+	atomic_t		pending_tx;
+	struct sk_buff_head	pending_q;
+	struct sk_buff_head	completed_q;
+};
+
+struct bfusb_scb {
+	struct urb *urb;
+};
+
+static void bfusb_tx_complete(struct urb *urb, struct pt_regs *regs);
+static void bfusb_rx_complete(struct urb *urb, struct pt_regs *regs);
+
+static struct urb *bfusb_get_completed(struct bfusb *bfusb)
+{
+	struct sk_buff *skb;
+	struct urb *urb = NULL;
+
+	BT_DBG("bfusb %p", bfusb);
+
+	skb = skb_dequeue(&bfusb->completed_q);
+	if (skb) {
+		urb = ((struct bfusb_scb *) skb->cb)->urb;
+		kfree_skb(skb);
+	}
+
+	return urb;
+}
+
+static inline void bfusb_unlink_urbs(struct bfusb *bfusb)
+{
+	struct sk_buff *skb;
+	struct urb *urb;
+
+	BT_DBG("bfusb %p", bfusb);
+
+	while ((skb = skb_dequeue(&bfusb->pending_q))) {
+		urb = ((struct bfusb_scb *) skb->cb)->urb;
+		usb_unlink_urb(urb);
+		skb_queue_tail(&bfusb->completed_q, skb);
+	}
+
+	while ((urb = bfusb_get_completed(bfusb)))
+		usb_free_urb(urb);
+}
+
+
+static int bfusb_send_bulk(struct bfusb *bfusb, struct sk_buff *skb)
+{
+	struct bfusb_scb *scb = (void *) skb->cb;
+	struct urb *urb = bfusb_get_completed(bfusb);
+	int err, pipe;
+
+	BT_DBG("bfusb %p skb %p len %d", bfusb, skb, skb->len);
+
+	if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC)))
+		return -ENOMEM;
+
+	pipe = usb_sndbulkpipe(bfusb->udev, bfusb->bulk_out_ep);
+
+	usb_fill_bulk_urb(urb, bfusb->udev, pipe, skb->data, skb->len,
+			bfusb_tx_complete, skb);
+
+	scb->urb = urb;
+
+	skb_queue_tail(&bfusb->pending_q, skb);
+
+	err = usb_submit_urb(urb, GFP_ATOMIC);
+	if (err) {
+		BT_ERR("%s bulk tx submit failed urb %p err %d", 
+					bfusb->hdev.name, urb, err);
+		skb_unlink(skb);
+		usb_free_urb(urb);
+	} else
+		atomic_inc(&bfusb->pending_tx);
+
+	return err;
+}
+
+static void bfusb_tx_wakeup(struct bfusb *bfusb)
+{
+	struct sk_buff *skb;
+
+	BT_DBG("bfusb %p", bfusb);
+
+	if (test_and_set_bit(BFUSB_TX_PROCESS, &bfusb->state)) {
+		set_bit(BFUSB_TX_WAKEUP, &bfusb->state);
+		return;
+	}
+
+	do {
+		clear_bit(BFUSB_TX_WAKEUP, &bfusb->state);
+
+		while ((atomic_read(&bfusb->pending_tx) < BFUSB_MAX_BULK_TX) &&
+				(skb = skb_dequeue(&bfusb->transmit_q))) {
+			if (bfusb_send_bulk(bfusb, skb) < 0) {
+				skb_queue_head(&bfusb->transmit_q, skb);
+				break;
+			}
+		}
+
+	} while (test_bit(BFUSB_TX_WAKEUP, &bfusb->state));
+
+	clear_bit(BFUSB_TX_PROCESS, &bfusb->state);
+}
+
+static void bfusb_tx_complete(struct urb *urb, struct pt_regs *regs)
+{
+	struct sk_buff *skb = (struct sk_buff *) urb->context;
+	struct bfusb *bfusb = (struct bfusb *) skb->dev;
+
+	BT_DBG("bfusb %p urb %p skb %p len %d", bfusb, urb, skb, skb->len);
+
+	atomic_dec(&bfusb->pending_tx);
+
+	if (!test_bit(HCI_RUNNING, &bfusb->hdev.flags))
+		return;
+
+	if (!urb->status)
+		bfusb->hdev.stat.byte_tx += skb->len;
+	else
+		bfusb->hdev.stat.err_tx++;
+
+	read_lock(&bfusb->lock);
+
+	skb_unlink(skb);
+	skb_queue_tail(&bfusb->completed_q, skb);
+
+	bfusb_tx_wakeup(bfusb);
+
+	read_unlock(&bfusb->lock);
+}
+
+
+static int bfusb_rx_submit(struct bfusb *bfusb, struct urb *urb)
+{
+	struct bfusb_scb *scb;
+	struct sk_buff *skb;
+	int err, pipe, size = HCI_MAX_FRAME_SIZE + 32;
+
+	BT_DBG("bfusb %p urb %p", bfusb, urb);
+
+	if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC)))
+		return -ENOMEM;
+
+	if (!(skb = bt_skb_alloc(size, GFP_ATOMIC))) {
+		usb_free_urb(urb);
+		return -ENOMEM;
+	}
+
+	skb->dev = (void *) bfusb;
+
+	scb = (struct bfusb_scb *) skb->cb;
+	scb->urb = urb;
+
+	pipe = usb_rcvbulkpipe(bfusb->udev, bfusb->bulk_in_ep);
+
+	usb_fill_bulk_urb(urb, bfusb->udev, pipe, skb->data, size,
+			bfusb_rx_complete, skb);
+
+	skb_queue_tail(&bfusb->pending_q, skb);
+
+	err = usb_submit_urb(urb, GFP_ATOMIC);
+	if (err) {
+		BT_ERR("%s bulk rx submit failed urb %p err %d",
+					bfusb->hdev.name, urb, err);
+		skb_unlink(skb);
+		kfree_skb(skb);
+		usb_free_urb(urb);
+	}
+
+	return err;
+}
+
+static inline int bfusb_recv_block(struct bfusb *bfusb, int hdr, unsigned char *data, int len)
+{
+	BT_DBG("bfusb %p hdr 0x%02x data %p len %d", bfusb, hdr, data, len);
+
+	if (hdr & 0x10) {
+		BT_ERR("%s error in block", bfusb->hdev.name);
+		if (bfusb->reassembly)
+			kfree_skb(bfusb->reassembly);
+		bfusb->reassembly = NULL;
+		return -EIO;
+	}
+
+	if (hdr & 0x04) {
+		struct sk_buff *skb;
+		unsigned char pkt_type;
+		int pkt_len = 0;
+
+		if (bfusb->reassembly) {
+			BT_ERR("%s unexpected start block", bfusb->hdev.name);
+			kfree_skb(bfusb->reassembly);
+			bfusb->reassembly = NULL;
+		}
+
+		if (len < 1) {
+			BT_ERR("%s no packet type found", bfusb->hdev.name);
+			return -EPROTO;
+		}
+
+		pkt_type = *data++; len--;
+
+		switch (pkt_type) {
+		case HCI_EVENT_PKT:
+			if (len >= HCI_EVENT_HDR_SIZE) {
+				struct hci_event_hdr *hdr = (struct hci_event_hdr *) data;
+				pkt_len = HCI_EVENT_HDR_SIZE + hdr->plen;
+			} else {
+				BT_ERR("%s event block is too short", bfusb->hdev.name);
+				return -EILSEQ;
+			}
+			break;
+
+		case HCI_ACLDATA_PKT:
+			if (len >= HCI_ACL_HDR_SIZE) {
+				struct hci_acl_hdr *hdr = (struct hci_acl_hdr *) data;
+				pkt_len = HCI_ACL_HDR_SIZE + __le16_to_cpu(hdr->dlen);
+			} else {
+				BT_ERR("%s data block is too short", bfusb->hdev.name);
+				return -EILSEQ;
+			}
+			break;
+
+		case HCI_SCODATA_PKT:
+			if (len >= HCI_SCO_HDR_SIZE) {
+				struct hci_sco_hdr *hdr = (struct hci_sco_hdr *) data;
+				pkt_len = HCI_SCO_HDR_SIZE + hdr->dlen;
+			} else {
+				BT_ERR("%s audio block is too short", bfusb->hdev.name);
+				return -EILSEQ;
+			}
+			break;
+		}
+
+		skb = bt_skb_alloc(pkt_len, GFP_ATOMIC);
+		if (!skb) {
+			BT_ERR("%s no memory for the packet", bfusb->hdev.name);
+			return -ENOMEM;
+		}
+
+		skb->dev = (void *) &bfusb->hdev;
+		skb->pkt_type = pkt_type;
+
+		bfusb->reassembly = skb;
+	} else {
+		if (!bfusb->reassembly) {
+			BT_ERR("%s unexpected continuation block", bfusb->hdev.name);
+			return -EIO;
+		}
+	}
+
+	if (len > 0)
+		memcpy(skb_put(bfusb->reassembly, len), data, len);
+
+	if (hdr & 0x08) {
+		hci_recv_frame(bfusb->reassembly);
+		bfusb->reassembly = NULL;
+	}
+
+	return 0;
+}
+
+static void bfusb_rx_complete(struct urb *urb, struct pt_regs *regs)
+{
+	struct sk_buff *skb = (struct sk_buff *) urb->context;
+	struct bfusb *bfusb = (struct bfusb *) skb->dev;
+	unsigned char *buf = urb->transfer_buffer;
+	int count = urb->actual_length;
+	int err, hdr, len;
+
+	BT_DBG("bfusb %p urb %p skb %p len %d", bfusb, urb, skb, skb->len);
+
+	if (!test_bit(HCI_RUNNING, &bfusb->hdev.flags))
+		return;
+
+	read_lock(&bfusb->lock);
+
+	if (urb->status || !count)
+		goto resubmit;
+
+	bfusb->hdev.stat.byte_rx += count;
+
+	skb_put(skb, count);
+
+	while (count) {
+		hdr = buf[0] | (buf[1] << 8);
+
+		if (hdr & 0x4000) {
+			len = 0;
+			count -= 2;
+			buf   += 2;
+		} else {
+			len = (buf[2] == 0) ? 256 : buf[2];
+			count -= 3;
+			buf   += 3;
+		}
+
+		if (count < len) {
+			BT_ERR("%s block extends over URB buffer ranges",
+					bfusb->hdev.name);
+		}
+
+		if ((hdr & 0xe1) == 0xc1)
+			bfusb_recv_block(bfusb, hdr, buf, len);
+
+		count -= len;
+		buf   += len;
+	}
+
+	skb_unlink(skb);
+	kfree_skb(skb);
+
+	bfusb_rx_submit(bfusb, urb);
+
+	read_unlock(&bfusb->lock);
+
+	return;
+
+resubmit:
+	urb->dev = bfusb->udev;
+
+	err = usb_submit_urb(urb, GFP_ATOMIC);
+	if (err) {
+		BT_ERR("%s bulk resubmit failed urb %p err %d",
+					bfusb->hdev.name, urb, err);
+	}
+
+	read_unlock(&bfusb->lock);
+}
+
+
+static int bfusb_open(struct hci_dev *hdev)
+{
+	struct bfusb *bfusb = (struct bfusb *) hdev->driver_data;
+	unsigned long flags;
+	int i, err;
+
+	BT_DBG("hdev %p bfusb %p", hdev, bfusb);
+
+	if (test_and_set_bit(HCI_RUNNING, &hdev->flags))
+		return 0;
+
+	write_lock_irqsave(&bfusb->lock, flags);
+
+	err = bfusb_rx_submit(bfusb, NULL);
+	if (!err) {
+		for (i = 1; i < BFUSB_MAX_BULK_RX; i++)
+			bfusb_rx_submit(bfusb, NULL);
+	} else {
+		clear_bit(HCI_RUNNING, &hdev->flags);
+	}
+
+	write_unlock_irqrestore(&bfusb->lock, flags);
+
+	return err;
+}
+
+static int bfusb_flush(struct hci_dev *hdev)
+{
+	struct bfusb *bfusb = (struct bfusb *) hdev->driver_data;
+
+	BT_DBG("hdev %p bfusb %p", hdev, bfusb);
+
+	skb_queue_purge(&bfusb->transmit_q);
+
+	return 0;
+}
+
+static int bfusb_close(struct hci_dev *hdev)
+{
+	struct bfusb *bfusb = (struct bfusb *) hdev->driver_data;
+	unsigned long flags;
+
+	BT_DBG("hdev %p bfusb %p", hdev, bfusb);
+
+	if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
+		return 0;
+
+	write_lock_irqsave(&bfusb->lock, flags);
+	write_unlock_irqrestore(&bfusb->lock, flags);
+
+	bfusb_unlink_urbs(bfusb);
+	bfusb_flush(hdev);
+
+	return 0;
+}
+
+static int bfusb_send_frame(struct sk_buff *skb)
+{
+	struct hci_dev *hdev = (struct hci_dev *) skb->dev;
+	struct bfusb *bfusb;
+	struct sk_buff *nskb;
+	unsigned char buf[3];
+	int sent = 0, size, count;
+
+	BT_DBG("hdev %p skb %p type %d len %d", hdev, skb, skb->pkt_type, skb->len);
+
+	if (!hdev) {
+		BT_ERR("Frame for unknown HCI device (hdev=NULL)");
+		return -ENODEV;
+	}
+
+	if (!test_bit(HCI_RUNNING, &hdev->flags))
+		return -EBUSY;
+
+	bfusb = (struct bfusb *) hdev->driver_data;
+
+	switch (skb->pkt_type) {
+	case HCI_COMMAND_PKT:
+		hdev->stat.cmd_tx++;
+		break;
+	case HCI_ACLDATA_PKT:
+		hdev->stat.acl_tx++;
+		break;
+	case HCI_SCODATA_PKT:
+		hdev->stat.sco_tx++;
+		break;
+	};
+
+	/* Prepend skb with frame type */
+	memcpy(skb_push(skb, 1), &(skb->pkt_type), 1);
+
+	count = skb->len;
+
+	/* Max HCI frame size seems to be 1511 + 1 */
+	if (!(nskb = bt_skb_alloc(count + 32, GFP_ATOMIC))) {
+		BT_ERR("Can't allocate memory for new packet");
+		return -ENOMEM;
+	}
+
+	nskb->dev = (void *) bfusb;
+
+	while (count) {
+		size = min_t(uint, count, BFUSB_MAX_BLOCK_SIZE);
+
+		buf[0] = 0xc1 | ((sent == 0) ? 0x04 : 0) | ((count == size) ? 0x08 : 0);
+		buf[1] = 0x00;
+		buf[2] = (size == BFUSB_MAX_BLOCK_SIZE) ? 0 : size;
+
+		memcpy(skb_put(nskb, 3), buf, 3);
+		memcpy(skb_put(nskb, size), skb->data + sent, size);
+
+		sent  += size;
+		count -= size;
+	}
+
+	/* Don't send frame with multiple size of bulk max packet */
+	if ((nskb->len % bfusb->bulk_pkt_size) == 0) {
+		buf[0] = 0xdd;
+		buf[1] = 0x00;
+		memcpy(skb_put(nskb, 2), buf, 2);
+	}
+
+	read_lock(&bfusb->lock);
+
+	skb_queue_tail(&bfusb->transmit_q, nskb);
+	bfusb_tx_wakeup(bfusb);
+
+	read_unlock(&bfusb->lock);
+
+	kfree_skb(skb);
+
+	return 0;
+}
+
+static void bfusb_destruct(struct hci_dev *hdev)
+{
+	struct bfusb *bfusb = (struct bfusb *) hdev->driver_data;
+
+	BT_DBG("hdev %p bfusb %p", hdev, bfusb);
+
+	kfree(bfusb);
+}
+
+static int bfusb_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg)
+{
+	return -ENOIOCTLCMD;
+}
+
+
+static int bfusb_load_firmware(struct bfusb *bfusb, unsigned char *firmware, int count)
+{
+	unsigned char *buf;
+	int err, pipe, len, size, sent = 0;
+
+	BT_DBG("bfusb %p udev %p", bfusb, bfusb->udev);
+
+	BT_INFO("BlueFRITZ! USB loading firmware");
+
+	pipe = usb_sndctrlpipe(bfusb->udev, 0);
+
+	if (usb_control_msg(bfusb->udev, pipe, USB_REQ_SET_CONFIGURATION,
+				0, 1, 0, NULL, 0, HZ * USB_CTRL_SET_TIMEOUT) < 0) {
+		BT_ERR("Can't change to loading configuration");
+		return -EBUSY;
+	}
+
+	buf = kmalloc(BFUSB_MAX_BLOCK_SIZE + 3, GFP_ATOMIC);
+	if (!buf) {
+		BT_ERR("Can't allocate memory chunk for firmware");
+		return -ENOMEM;
+	}
+
+	pipe = usb_sndbulkpipe(bfusb->udev, bfusb->bulk_out_ep);
+
+	while (count) {
+		size = min_t(uint, count, BFUSB_MAX_BLOCK_SIZE + 3);
+
+		memcpy(buf, firmware + sent, size);
+
+		err = usb_bulk_msg(bfusb->udev, pipe, buf, size,
+					&len, BFUSB_BLOCK_TIMEOUT);
+
+		if (err || (len != size)) {
+			BT_ERR("Error in firmware loading");
+			goto error;
+		}
+
+		sent  += size;
+		count -= size;
+	}
+
+	if ((err = usb_bulk_msg(bfusb->udev, pipe, NULL, 0,
+				&len, BFUSB_BLOCK_TIMEOUT)) < 0) {
+		BT_ERR("Error in null packet request");
+		goto error;
+	}
+
+	pipe = usb_sndctrlpipe(bfusb->udev, 0);
+
+        if ((err = usb_control_msg(bfusb->udev, pipe, USB_REQ_SET_CONFIGURATION,
+				0, 2, 0, NULL, 0, HZ * USB_CTRL_SET_TIMEOUT)) < 0) {
+		BT_ERR("Can't change to running configuration");
+		goto error;
+	}
+
+	BT_INFO("BlueFRITZ! USB device ready");
+
+	kfree(buf);
+	return 0;
+
+error:
+	kfree(buf);
+
+	pipe = usb_sndctrlpipe(bfusb->udev, 0);
+
+	usb_control_msg(bfusb->udev, pipe, USB_REQ_SET_CONFIGURATION,
+				0, 0, 0, NULL, 0, HZ * USB_CTRL_SET_TIMEOUT);
+
+	return err;
+}
+
+static int bfusb_probe(struct usb_interface *iface, const struct usb_device_id *id)
+{
+	const struct firmware *firmware;
+	struct usb_device *udev = interface_to_usbdev(iface);
+	struct usb_host_endpoint *bulk_out_ep;
+	struct usb_host_endpoint *bulk_in_ep;
+	struct hci_dev *hdev;
+	struct bfusb *bfusb;
+
+	BT_DBG("iface %p id %p", iface, id);
+
+	/* Check number of endpoints */
+	if (iface->altsetting[0].desc.bNumEndpoints < 2)
+		return -EIO;
+
+	bulk_out_ep = &iface->altsetting[0].endpoint[0];
+	bulk_in_ep  = &iface->altsetting[0].endpoint[1];
+
+	if (!bulk_out_ep || !bulk_in_ep) {
+		BT_ERR("Bulk endpoints not found");
+		goto done;
+	}
+
+	/* Initialize control structure and load firmware */
+	if (!(bfusb = kmalloc(sizeof(struct bfusb), GFP_KERNEL))) {
+		BT_ERR("Can't allocate memory for control structure");
+		goto done;
+	}
+
+	memset(bfusb, 0, sizeof(struct bfusb));
+
+	bfusb->udev = udev;
+	bfusb->bulk_in_ep    = bulk_in_ep->desc.bEndpointAddress;
+	bfusb->bulk_out_ep   = bulk_out_ep->desc.bEndpointAddress;
+	bfusb->bulk_pkt_size = bulk_out_ep->desc.wMaxPacketSize;
+
+	bfusb->lock = RW_LOCK_UNLOCKED;
+
+	bfusb->reassembly = NULL;
+
+	skb_queue_head_init(&bfusb->transmit_q);
+	skb_queue_head_init(&bfusb->pending_q);
+	skb_queue_head_init(&bfusb->completed_q);
+
+	if (request_firmware(&firmware, "bfubase.frm", &udev->dev) < 0) {
+		BT_ERR("Firmware request failed");
+		goto error;
+	}
+
+	BT_DBG("firmware data %p size %d", firmware->data, firmware->size);
+
+	if (bfusb_load_firmware(bfusb, firmware->data, firmware->size) < 0) {
+		BT_ERR("Firmware loading failed");
+		goto release;
+	}
+
+	release_firmware(firmware);
+
+	/* Initialize and register HCI device */
+	hdev = &bfusb->hdev;
+
+	hdev->type = HCI_USB;
+	hdev->driver_data = bfusb;
+
+	hdev->open     = bfusb_open;
+	hdev->close    = bfusb_close;
+	hdev->flush    = bfusb_flush;
+	hdev->send     = bfusb_send_frame;
+	hdev->destruct = bfusb_destruct;
+	hdev->ioctl    = bfusb_ioctl;
+
+	hdev->owner = THIS_MODULE;
+
+	if (hci_register_dev(hdev) < 0) {
+		BT_ERR("Can't register HCI device");
+		goto error;
+	}
+
+	usb_set_intfdata(iface, bfusb);
+
+	return 0;
+
+release:
+	release_firmware(firmware);
+
+error:
+	kfree(bfusb);
+
+done:
+	return -EIO;
+}
+
+static void bfusb_disconnect(struct usb_interface *iface)
+{
+	struct bfusb *bfusb = usb_get_intfdata(iface);
+	struct hci_dev *hdev = &bfusb->hdev;
+
+	BT_DBG("iface %p", iface);
+
+	if (!hdev)
+		return;
+
+	usb_set_intfdata(iface, NULL);
+
+	bfusb_close(hdev);
+
+	if (hci_unregister_dev(hdev) < 0)
+		BT_ERR("Can't unregister HCI device %s", hdev->name);
+}
+
+static struct usb_driver bfusb_driver = {
+	.owner		= THIS_MODULE,
+	.name		= "bfusb",
+	.probe		= bfusb_probe,
+	.disconnect	= bfusb_disconnect,
+	.id_table	= bfusb_table,
+};
+
+static int __init bfusb_init(void)
+{
+	int err;
+
+	BT_INFO("BlueFRITZ! USB driver ver %s", VERSION);
+
+	if ((err = usb_register(&bfusb_driver)) < 0)
+		BT_ERR("Failed to register BlueFRITZ! USB driver");
+
+	return err;
+}
+
+static void __exit bfusb_cleanup(void)
+{
+	usb_deregister(&bfusb_driver);
+}
+
+module_init(bfusb_init);
+module_exit(bfusb_cleanup);
+
+MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
+MODULE_DESCRIPTION("BlueFRITZ! USB driver ver " VERSION);
+MODULE_LICENSE("GPL");
diff -puN drivers/bluetooth/bluecard_cs.c~linus drivers/bluetooth/bluecard_cs.c
--- 25/drivers/bluetooth/bluecard_cs.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/bluetooth/bluecard_cs.c	2004-01-19 22:17:21.000000000 -0800
@@ -499,7 +499,7 @@ static void bluecard_receive(bluecard_in
 }
 
 
-void bluecard_interrupt(int irq, void *dev_inst, struct pt_regs *regs)
+static irqreturn_t bluecard_interrupt(int irq, void *dev_inst, struct pt_regs *regs)
 {
 	bluecard_info_t *info = dev_inst;
 	unsigned int iobase;
@@ -507,11 +507,11 @@ void bluecard_interrupt(int irq, void *d
 
 	if (!info) {
 		printk(KERN_WARNING "bluecard_cs: Call of irq %d for unknown device.\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	if (!test_bit(CARD_READY, &(info->hw_state)))
-		return;
+		return IRQ_NONE;
 
 	iobase = info->link.io.BasePort1;
 
@@ -556,6 +556,8 @@ void bluecard_interrupt(int irq, void *d
 	outb(info->ctrl_reg, iobase + REG_CONTROL);
 
 	spin_unlock(&(info->lock));
+
+	return IRQ_HANDLED;
 }
 
 
@@ -869,7 +871,7 @@ dev_link_t *bluecard_attach(void)
 	client_reg.Version = 0x0210;
 	client_reg.event_callback_args.client_data = link;
 
-	ret = CardServices(RegisterClient, &link->handle, &client_reg);
+	ret = pcmcia_register_client(&link->handle, &client_reg);
 	if (ret != CS_SUCCESS) {
 		cs_error(link->handle, RegisterClient, ret);
 		bluecard_detach(link);
@@ -898,7 +900,7 @@ void bluecard_detach(dev_link_t *link)
 		bluecard_release(link);
 
 	if (link->handle) {
-		ret = CardServices(DeregisterClient, link->handle);
+		ret = pcmcia_deregister_client(link->handle);
 		if (ret != CS_SUCCESS)
 			cs_error(link->handle, DeregisterClient, ret);
 	}
@@ -910,25 +912,21 @@ void bluecard_detach(dev_link_t *link)
 }
 
 
-static int get_tuple(int fn, client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
+static int first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
 {
 	int i;
 
-	i = CardServices(fn, handle, tuple);
+	i = pcmcia_get_first_tuple(handle, tuple);
 	if (i != CS_SUCCESS)
 		return CS_NO_MORE_ITEMS;
 
-	i = CardServices(GetTupleData, handle, tuple);
+	i = pcmcia_get_tuple_data(handle, tuple);
 	if (i != CS_SUCCESS)
 		return i;
 
-	return CardServices(ParseTuple, handle, tuple, parse);
+	return pcmcia_parse_tuple(handle, tuple, parse);
 }
 
-
-#define first_tuple(a, b, c) get_tuple(GetFirstTuple, a, b, c)
-#define next_tuple(a, b, c) get_tuple(GetNextTuple, a, b, c)
-
 void bluecard_config(dev_link_t *link)
 {
 	client_handle_t handle = link->handle;
@@ -956,7 +954,7 @@ void bluecard_config(dev_link_t *link)
 
 	/* Configure card */
 	link->state |= DEV_CONFIG;
-	i = CardServices(GetConfigurationInfo, handle, &config);
+	i = pcmcia_get_configuration_info(handle, &config);
 	link->conf.Vcc = config.Vcc;
 
 	link->conf.ConfigIndex = 0x20;
@@ -965,7 +963,7 @@ void bluecard_config(dev_link_t *link)
 
 	for (n = 0; n < 0x400; n += 0x40) {
 		link->io.BasePort1 = n ^ 0x300;
-		i = CardServices(RequestIO, link->handle, &link->io);
+		i = pcmcia_request_io(link->handle, &link->io);
 		if (i == CS_SUCCESS)
 			break;
 	}
@@ -975,13 +973,13 @@ void bluecard_config(dev_link_t *link)
 		goto failed;
 	}
 
-	i = CardServices(RequestIRQ, link->handle, &link->irq);
+	i = pcmcia_request_irq(link->handle, &link->irq);
 	if (i != CS_SUCCESS) {
 		cs_error(link->handle, RequestIRQ, i);
 		link->irq.AssignedIRQ = 0;
 	}
 
-	i = CardServices(RequestConfiguration, link->handle, &link->conf);
+	i = pcmcia_request_configuration(link->handle, &link->conf);
 	if (i != CS_SUCCESS) {
 		cs_error(link->handle, RequestConfiguration, i);
 		goto failed;
@@ -1013,9 +1011,9 @@ void bluecard_release(dev_link_t *link)
 
 	link->dev = NULL;
 
-	CardServices(ReleaseConfiguration, link->handle);
-	CardServices(ReleaseIO, link->handle, &link->io);
-	CardServices(ReleaseIRQ, link->handle, &link->irq);
+	pcmcia_release_configuration(link->handle);
+	pcmcia_release_io(link->handle, &link->io);
+	pcmcia_release_irq(link->handle, &link->irq);
 
 	link->state &= ~DEV_CONFIG;
 }
@@ -1043,14 +1041,14 @@ int bluecard_event(event_t event, int pr
 		/* Fall through... */
 	case CS_EVENT_RESET_PHYSICAL:
 		if (link->state & DEV_CONFIG)
-			CardServices(ReleaseConfiguration, link->handle);
+			pcmcia_release_configuration(link->handle);
 		break;
 	case CS_EVENT_PM_RESUME:
 		link->state &= ~DEV_SUSPEND;
 		/* Fall through... */
 	case CS_EVENT_CARD_RESET:
 		if (DEV_OK(link))
-			CardServices(RequestConfiguration, link->handle, &link->conf);
+			pcmcia_request_configuration(link->handle, &link->conf);
 		break;
 	}
 
diff -puN drivers/bluetooth/bt3c_cs.c~linus drivers/bluetooth/bt3c_cs.c
--- 25/drivers/bluetooth/bt3c_cs.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/bluetooth/bt3c_cs.c	2004-01-19 22:17:21.000000000 -0800
@@ -355,7 +355,7 @@ static void bt3c_receive(bt3c_info_t *in
 }
 
 
-void bt3c_interrupt(int irq, void *dev_inst, struct pt_regs *regs)
+static irqreturn_t bt3c_interrupt(int irq, void *dev_inst, struct pt_regs *regs)
 {
 	bt3c_info_t *info = dev_inst;
 	unsigned int iobase;
@@ -363,7 +363,7 @@ void bt3c_interrupt(int irq, void *dev_i
 
 	if (!info) {
 		printk(KERN_WARNING "bt3c_cs: Call of irq %d for unknown device.\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	iobase = info->link.io.BasePort1;
@@ -396,6 +396,8 @@ void bt3c_interrupt(int irq, void *dev_i
 	}
 
 	spin_unlock(&(info->lock));
+
+	return IRQ_HANDLED;
 }
 
 
@@ -615,7 +617,7 @@ dev_link_t *bt3c_attach(void)
 	client_reg.Version = 0x0210;
 	client_reg.event_callback_args.client_data = link;
 
-	ret = CardServices(RegisterClient, &link->handle, &client_reg);
+	ret = pcmcia_register_client(&link->handle, &client_reg);
 	if (ret != CS_SUCCESS) {
 		cs_error(link->handle, RegisterClient, ret);
 		bt3c_detach(link);
@@ -644,7 +646,7 @@ void bt3c_detach(dev_link_t *link)
 		bt3c_release(link);
 
 	if (link->handle) {
-		ret = CardServices(DeregisterClient, link->handle);
+		ret = pcmcia_deregister_client(link->handle);
 		if (ret != CS_SUCCESS)
 			cs_error(link->handle, DeregisterClient, ret);
 	}
@@ -655,25 +657,30 @@ void bt3c_detach(dev_link_t *link)
 	kfree(info);
 }
 
-
-static int get_tuple(int fn, client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
+static int get_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
 {
 	int i;
 
-	i = CardServices(fn, handle, tuple);
-	if (i != CS_SUCCESS)
-		return CS_NO_MORE_ITEMS;
-
-	i = CardServices(GetTupleData, handle, tuple);
+	i = pcmcia_get_tuple_data(handle, tuple);
 	if (i != CS_SUCCESS)
 		return i;
 
-	return CardServices(ParseTuple, handle, tuple, parse);
+	return pcmcia_parse_tuple(handle, tuple, parse);
 }
 
+static int first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
+{
+	if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS)
+		return CS_NO_MORE_ITEMS;
+	return get_tuple(handle, tuple, parse);
+}
 
-#define first_tuple(a, b, c) get_tuple(GetFirstTuple, a, b, c)
-#define next_tuple(a, b, c) get_tuple(GetNextTuple, a, b, c)
+static int next_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
+{
+	if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS)
+		return CS_NO_MORE_ITEMS;
+	return get_tuple(handle, tuple, parse);
+}
 
 void bt3c_config(dev_link_t *link)
 {
@@ -704,7 +711,7 @@ void bt3c_config(dev_link_t *link)
 
 	/* Configure card */
 	link->state |= DEV_CONFIG;
-	i = CardServices(GetConfigurationInfo, handle, &config);
+	i = pcmcia_get_configuration_info(handle, &config);
 	link->conf.Vcc = config.Vcc;
 
 	/* First pass: look for a config entry that looks normal. */
@@ -725,7 +732,7 @@ void bt3c_config(dev_link_t *link)
 				link->conf.ConfigIndex = cf->index;
 				link->io.BasePort1 = cf->io.win[0].base;
 				link->io.IOAddrLines = (try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK;
-				i = CardServices(RequestIO, link->handle, &link->io);
+				i = pcmcia_request_io(link->handle, &link->io);
 				if (i == CS_SUCCESS)
 					goto found_port;
 			}
@@ -744,7 +751,7 @@ next_entry:
 			for (j = 0; j < 5; j++) {
 				link->io.BasePort1 = base[j];
 				link->io.IOAddrLines = base[j] ? 16 : 3;
-				i = CardServices(RequestIO, link->handle, &link->io);
+				i = pcmcia_request_io(link->handle, &link->io);
 				if (i == CS_SUCCESS)
 					goto found_port;
 			}
@@ -759,13 +766,13 @@ found_port:
 		goto failed;
 	}
 
-	i = CardServices(RequestIRQ, link->handle, &link->irq);
+	i = pcmcia_request_irq(link->handle, &link->irq);
 	if (i != CS_SUCCESS) {
 		cs_error(link->handle, RequestIRQ, i);
 		link->irq.AssignedIRQ = 0;
 	}
 
-	i = CardServices(RequestConfiguration, link->handle, &link->conf);
+	i = pcmcia_request_configuration(link->handle, &link->conf);
 	if (i != CS_SUCCESS) {
 		cs_error(link->handle, RequestConfiguration, i);
 		goto failed;
@@ -797,9 +804,9 @@ void bt3c_release(dev_link_t *link)
 
 	link->dev = NULL;
 
-	CardServices(ReleaseConfiguration, link->handle);
-	CardServices(ReleaseIO, link->handle, &link->io);
-	CardServices(ReleaseIRQ, link->handle, &link->irq);
+	pcmcia_release_configuration(link->handle);
+	pcmcia_release_io(link->handle, &link->io);
+	pcmcia_release_irq(link->handle, &link->irq);
 
 	link->state &= ~DEV_CONFIG;
 }
@@ -827,14 +834,14 @@ int bt3c_event(event_t event, int priori
 		/* Fall through... */
 	case CS_EVENT_RESET_PHYSICAL:
 		if (link->state & DEV_CONFIG)
-			CardServices(ReleaseConfiguration, link->handle);
+			pcmcia_release_configuration(link->handle);
 		break;
 	case CS_EVENT_PM_RESUME:
 		link->state &= ~DEV_SUSPEND;
 		/* Fall through... */
 	case CS_EVENT_CARD_RESET:
 		if (DEV_OK(link))
-			CardServices(RequestConfiguration, link->handle, &link->conf);
+			pcmcia_request_configuration(link->handle, &link->conf);
 		break;
 	}
 
diff -puN drivers/bluetooth/btuart_cs.c~linus drivers/bluetooth/btuart_cs.c
--- 25/drivers/bluetooth/btuart_cs.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/bluetooth/btuart_cs.c	2004-01-19 22:17:21.000000000 -0800
@@ -301,7 +301,7 @@ static void btuart_receive(btuart_info_t
 }
 
 
-void btuart_interrupt(int irq, void *dev_inst, struct pt_regs *regs)
+static irqreturn_t btuart_interrupt(int irq, void *dev_inst, struct pt_regs *regs)
 {
 	btuart_info_t *info = dev_inst;
 	unsigned int iobase;
@@ -310,7 +310,7 @@ void btuart_interrupt(int irq, void *dev
 
 	if (!info) {
 		printk(KERN_WARNING "btuart_cs: Call of irq %d for unknown device.\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	iobase = info->link.io.BasePort1;
@@ -351,6 +351,8 @@ void btuart_interrupt(int irq, void *dev
 	}
 
 	spin_unlock(&(info->lock));
+
+	return IRQ_HANDLED;
 }
 
 
@@ -622,7 +624,7 @@ dev_link_t *btuart_attach(void)
 	client_reg.Version = 0x0210;
 	client_reg.event_callback_args.client_data = link;
 
-	ret = CardServices(RegisterClient, &link->handle, &client_reg);
+	ret = pcmcia_register_client(&link->handle, &client_reg);
 	if (ret != CS_SUCCESS) {
 		cs_error(link->handle, RegisterClient, ret);
 		btuart_detach(link);
@@ -651,7 +653,7 @@ void btuart_detach(dev_link_t *link)
 		btuart_release(link);
 
 	if (link->handle) {
-		ret = CardServices(DeregisterClient, link->handle);
+		ret = pcmcia_deregister_client(link->handle);
 		if (ret != CS_SUCCESS)
 			cs_error(link->handle, DeregisterClient, ret);
 	}
@@ -662,25 +664,30 @@ void btuart_detach(dev_link_t *link)
 	kfree(info);
 }
 
-
-static int get_tuple(int fn, client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
+static int get_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
 {
 	int i;
 
-	i = CardServices(fn, handle, tuple);
-	if (i != CS_SUCCESS)
-		return CS_NO_MORE_ITEMS;
-
-	i = CardServices(GetTupleData, handle, tuple);
+	i = pcmcia_get_tuple_data(handle, tuple);
 	if (i != CS_SUCCESS)
 		return i;
 
-	return CardServices(ParseTuple, handle, tuple, parse);
+	return pcmcia_parse_tuple(handle, tuple, parse);
 }
 
+static int first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
+{
+	if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS)
+		return CS_NO_MORE_ITEMS;
+	return get_tuple(handle, tuple, parse);
+}
 
-#define first_tuple(a, b, c) get_tuple(GetFirstTuple, a, b, c)
-#define next_tuple(a, b, c) get_tuple(GetNextTuple, a, b, c)
+static int next_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
+{
+	if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS)
+		return CS_NO_MORE_ITEMS;
+	return get_tuple(handle, tuple, parse);
+}
 
 void btuart_config(dev_link_t *link)
 {
@@ -711,7 +718,7 @@ void btuart_config(dev_link_t *link)
 
 	/* Configure card */
 	link->state |= DEV_CONFIG;
-	i = CardServices(GetConfigurationInfo, handle, &config);
+	i = pcmcia_get_configuration_info(handle, &config);
 	link->conf.Vcc = config.Vcc;
 
 	/* First pass: look for a config entry that looks normal. */
@@ -732,7 +739,7 @@ void btuart_config(dev_link_t *link)
 				link->conf.ConfigIndex = cf->index;
 				link->io.BasePort1 = cf->io.win[0].base;
 				link->io.IOAddrLines = (try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK;
-				i = CardServices(RequestIO, link->handle, &link->io);
+				i = pcmcia_request_io(link->handle, &link->io);
 				if (i == CS_SUCCESS)
 					goto found_port;
 			}
@@ -752,7 +759,7 @@ next_entry:
 			for (j = 0; j < 5; j++) {
 				link->io.BasePort1 = base[j];
 				link->io.IOAddrLines = base[j] ? 16 : 3;
-				i = CardServices(RequestIO, link->handle, &link->io);
+				i = pcmcia_request_io(link->handle, &link->io);
 				if (i == CS_SUCCESS)
 					goto found_port;
 			}
@@ -767,13 +774,13 @@ found_port:
 		goto failed;
 	}
 
-	i = CardServices(RequestIRQ, link->handle, &link->irq);
+	i = pcmcia_request_irq(link->handle, &link->irq);
 	if (i != CS_SUCCESS) {
 		cs_error(link->handle, RequestIRQ, i);
 		link->irq.AssignedIRQ = 0;
 	}
 
-	i = CardServices(RequestConfiguration, link->handle, &link->conf);
+	i = pcmcia_request_configuration(link->handle, &link->conf);
 	if (i != CS_SUCCESS) {
 		cs_error(link->handle, RequestConfiguration, i);
 		goto failed;
@@ -805,9 +812,9 @@ void btuart_release(dev_link_t *link)
 
 	link->dev = NULL;
 
-	CardServices(ReleaseConfiguration, link->handle);
-	CardServices(ReleaseIO, link->handle, &link->io);
-	CardServices(ReleaseIRQ, link->handle, &link->irq);
+	pcmcia_release_configuration(link->handle);
+	pcmcia_release_io(link->handle, &link->io);
+	pcmcia_release_irq(link->handle, &link->irq);
 
 	link->state &= ~DEV_CONFIG;
 }
@@ -835,14 +842,14 @@ int btuart_event(event_t event, int prio
 		/* Fall through... */
 	case CS_EVENT_RESET_PHYSICAL:
 		if (link->state & DEV_CONFIG)
-			CardServices(ReleaseConfiguration, link->handle);
+			pcmcia_release_configuration(link->handle);
 		break;
 	case CS_EVENT_PM_RESUME:
 		link->state &= ~DEV_SUSPEND;
 		/* Fall through... */
 	case CS_EVENT_CARD_RESET:
 		if (DEV_OK(link))
-			CardServices(RequestConfiguration, link->handle, &link->conf);
+			pcmcia_request_configuration(link->handle, &link->conf);
 		break;
 	}
 
diff -puN drivers/bluetooth/dtl1_cs.c~linus drivers/bluetooth/dtl1_cs.c
--- 25/drivers/bluetooth/dtl1_cs.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/bluetooth/dtl1_cs.c	2004-01-19 22:17:21.000000000 -0800
@@ -304,7 +304,7 @@ static void dtl1_receive(dtl1_info_t *in
 }
 
 
-void dtl1_interrupt(int irq, void *dev_inst, struct pt_regs *regs)
+static irqreturn_t dtl1_interrupt(int irq, void *dev_inst, struct pt_regs *regs)
 {
 	dtl1_info_t *info = dev_inst;
 	unsigned int iobase;
@@ -314,7 +314,7 @@ void dtl1_interrupt(int irq, void *dev_i
 
 	if (!info) {
 		printk(KERN_WARNING "dtl1_cs: Call of irq %d for unknown device.\n", irq);
-		return;
+		return IRQ_NONE;
 	}
 
 	iobase = info->link.io.BasePort1;
@@ -363,6 +363,8 @@ void dtl1_interrupt(int irq, void *dev_i
 	}
 
 	spin_unlock(&(info->lock));
+
+	return IRQ_HANDLED;
 }
 
 
@@ -601,7 +603,7 @@ dev_link_t *dtl1_attach(void)
 	client_reg.Version = 0x0210;
 	client_reg.event_callback_args.client_data = link;
 
-	ret = CardServices(RegisterClient, &link->handle, &client_reg);
+	ret = pcmcia_register_client(&link->handle, &client_reg);
 	if (ret != CS_SUCCESS) {
 		cs_error(link->handle, RegisterClient, ret);
 		dtl1_detach(link);
@@ -630,7 +632,7 @@ void dtl1_detach(dev_link_t *link)
 		dtl1_release(link);
 
 	if (link->handle) {
-		ret = CardServices(DeregisterClient, link->handle);
+		ret = pcmcia_deregister_client(link->handle);
 		if (ret != CS_SUCCESS)
 			cs_error(link->handle, DeregisterClient, ret);
 	}
@@ -641,25 +643,30 @@ void dtl1_detach(dev_link_t *link)
 	kfree(info);
 }
 
-
-static int get_tuple(int fn, client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
+static int get_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
 {
 	int i;
 
-	i = CardServices(fn, handle, tuple);
-	if (i != CS_SUCCESS)
-		return CS_NO_MORE_ITEMS;
-
-	i = CardServices(GetTupleData, handle, tuple);
+	i = pcmcia_get_tuple_data(handle, tuple);
 	if (i != CS_SUCCESS)
 		return i;
 
-	return CardServices(ParseTuple, handle, tuple, parse);
+	return pcmcia_parse_tuple(handle, tuple, parse);
 }
 
+static int first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
+{
+	if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS)
+		return CS_NO_MORE_ITEMS;
+	return get_tuple(handle, tuple, parse);
+}
 
-#define first_tuple(a, b, c) get_tuple(GetFirstTuple, a, b, c)
-#define next_tuple(a, b, c) get_tuple(GetNextTuple, a, b, c)
+static int next_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
+{
+	if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS)
+		return CS_NO_MORE_ITEMS;
+	return get_tuple(handle, tuple, parse);
+}
 
 void dtl1_config(dev_link_t *link)
 {
@@ -689,7 +696,7 @@ void dtl1_config(dev_link_t *link)
 
 	/* Configure card */
 	link->state |= DEV_CONFIG;
-	i = CardServices(GetConfigurationInfo, handle, &config);
+	i = pcmcia_get_configuration_info(handle, &config);
 	link->conf.Vcc = config.Vcc;
 
 	tuple.TupleData = (cisdata_t *)buf;
@@ -707,7 +714,7 @@ void dtl1_config(dev_link_t *link)
 			link->io.BasePort1 = cf->io.win[0].base;
 			link->io.NumPorts1 = cf->io.win[0].len;	/*yo */
 			link->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK;
-			i = CardServices(RequestIO, link->handle, &link->io);
+			i = pcmcia_request_io(link->handle, &link->io);
 			if (i == CS_SUCCESS)
 				break;
 		}
@@ -719,13 +726,13 @@ void dtl1_config(dev_link_t *link)
 		goto failed;
 	}
 
-	i = CardServices(RequestIRQ, link->handle, &link->irq);
+	i = pcmcia_request_irq(link->handle, &link->irq);
 	if (i != CS_SUCCESS) {
 		cs_error(link->handle, RequestIRQ, i);
 		link->irq.AssignedIRQ = 0;
 	}
 
-	i = CardServices(RequestConfiguration, link->handle, &link->conf);
+	i = pcmcia_request_configuration(link->handle, &link->conf);
 	if (i != CS_SUCCESS) {
 		cs_error(link->handle, RequestConfiguration, i);
 		goto failed;
@@ -757,9 +764,9 @@ void dtl1_release(dev_link_t *link)
 
 	link->dev = NULL;
 
-	CardServices(ReleaseConfiguration, link->handle);
-	CardServices(ReleaseIO, link->handle, &link->io);
-	CardServices(ReleaseIRQ, link->handle, &link->irq);
+	pcmcia_release_configuration(link->handle);
+	pcmcia_release_io(link->handle, &link->io);
+	pcmcia_release_irq(link->handle, &link->irq);
 
 	link->state &= ~DEV_CONFIG;
 }
@@ -787,14 +794,14 @@ int dtl1_event(event_t event, int priori
 		/* Fall through... */
 	case CS_EVENT_RESET_PHYSICAL:
 		if (link->state & DEV_CONFIG)
-			CardServices(ReleaseConfiguration, link->handle);
+			pcmcia_release_configuration(link->handle);
 		break;
 	case CS_EVENT_PM_RESUME:
 		link->state &= ~DEV_SUSPEND;
 		/* Fall through... */
 	case CS_EVENT_CARD_RESET:
 		if (DEV_OK(link))
-			CardServices(RequestConfiguration, link->handle, &link->conf);
+			pcmcia_request_configuration(link->handle, &link->conf);
 		break;
 	}
 
diff -puN drivers/bluetooth/hci_usb.c~linus drivers/bluetooth/hci_usb.c
--- 25/drivers/bluetooth/hci_usb.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/bluetooth/hci_usb.c	2004-01-19 22:17:21.000000000 -0800
@@ -62,7 +62,7 @@
 #define BT_DMP( A... )
 #endif
 
-#ifndef CONFIG_BT_USB_ZERO_PACKET
+#ifndef CONFIG_BT_HCIUSB_ZERO_PACKET
 #undef  URB_ZERO_PACKET
 #define URB_ZERO_PACKET 0
 #endif
@@ -70,12 +70,21 @@
 static struct usb_driver hci_usb_driver; 
 
 static struct usb_device_id bluetooth_ids[] = {
+	/* Broadcom BCM2033 without firmware */
+	{ USB_DEVICE(0x0a5c, 0x2033), driver_info: HCI_IGNORE },
+
+	/* Digianswer device */
+	{ USB_DEVICE(0x08fd, 0x0001), driver_info: HCI_DIGIANSWER },
+
 	/* Generic Bluetooth USB device */
 	{ USB_DEVICE_INFO(HCI_DEV_CLASS, HCI_DEV_SUBCLASS, HCI_DEV_PROTOCOL) },
 
 	/* Ericsson with non-standard id */
 	{ USB_DEVICE(0x0bdb, 0x1002) },
 
+	/* ALPS Module with non-standard id */
+	{ USB_DEVICE(0x044e, 0x3002) },
+
 	/* Bluetooth Ultraport Module from IBM */
 	{ USB_DEVICE(0x04bf, 0x030a) },
 
@@ -84,13 +93,6 @@ static struct usb_device_id bluetooth_id
 
 MODULE_DEVICE_TABLE (usb, bluetooth_ids);
 
-static struct usb_device_id ignore_ids[] = {
-	/* Broadcom BCM2033 without firmware */
-	{ USB_DEVICE(0x0a5c, 0x2033) },
-
-	{ }	/* Terminating entry */
-};
-
 struct _urb *_urb_alloc(int isoc, int gfp)
 {
 	struct _urb *_urb = kmalloc(sizeof(struct _urb) +
@@ -134,7 +136,7 @@ static inline struct _urb *__get_complet
 	return _urb_dequeue(__completed_q(husb, type)); 
 }
 
-#ifdef CONFIG_BT_USB_SCO
+#ifdef CONFIG_BT_HCIUSB_SCO
 static void __fill_isoc_desc(struct urb *urb, int len, int mtu)
 {
 	int offset = 0, i;
@@ -232,7 +234,7 @@ static int hci_usb_bulk_rx_submit(struct
 	return err;
 }
 
-#ifdef CONFIG_BT_USB_SCO
+#ifdef CONFIG_BT_HCIUSB_SCO
 static int hci_usb_isoc_rx_submit(struct hci_usb *husb)
 {
 	struct _urb *_urb;
@@ -301,9 +303,10 @@ static int hci_usb_open(struct hci_dev *
 		for (i = 0; i < HCI_MAX_BULK_RX; i++)
 			hci_usb_bulk_rx_submit(husb);
 
-#ifdef CONFIG_BT_USB_SCO
+#ifdef CONFIG_BT_HCIUSB_SCO
 		if (husb->isoc_iface)
-			hci_usb_isoc_rx_submit(husb);
+			for (i = 0; i < HCI_MAX_ISOC_RX; i++)
+				hci_usb_isoc_rx_submit(husb);
 #endif
 	} else {
 		clear_bit(HCI_RUNNING, &hdev->flags);
@@ -425,7 +428,7 @@ static inline int hci_usb_send_ctrl(stru
 	} else
 		dr = (void *) _urb->urb.setup_packet;
 
-	dr->bRequestType = HCI_CTRL_REQ;
+	dr->bRequestType = husb->ctrl_req;
 	dr->bRequest = 0;
 	dr->wIndex   = 0;
 	dr->wValue   = 0;
@@ -466,7 +469,7 @@ static inline int hci_usb_send_bulk(stru
 	return __tx_submit(husb, _urb);
 }
 
-#ifdef CONFIG_BT_USB_SCO
+#ifdef CONFIG_BT_HCIUSB_SCO
 static inline int hci_usb_send_isoc(struct hci_usb *husb, struct sk_buff *skb)
 {
 	struct _urb *_urb = __get_completed(husb, skb->pkt_type);
@@ -517,10 +520,10 @@ static void hci_usb_tx_process(struct hc
 				skb_queue_head(q, skb);
 		}
 
-#ifdef CONFIG_BT_USB_SCO
+#ifdef CONFIG_BT_HCIUSB_SCO
 		/* Process SCO queue */
 		q = __transmit_q(husb, HCI_SCODATA_PKT);
-		if (!atomic_read(__pending_tx(husb, HCI_SCODATA_PKT)) &&
+		if (atomic_read(__pending_tx(husb, HCI_SCODATA_PKT)) < HCI_MAX_ISOC_TX &&
 				(skb = skb_dequeue(q))) {
 			if (hci_usb_send_isoc(husb, skb) < 0)
 				skb_queue_head(q, skb);
@@ -576,7 +579,7 @@ static int hci_usb_send_frame(struct sk_
 		hdev->stat.acl_tx++;
 		break;
 
-#ifdef CONFIG_BT_USB_SCO
+#ifdef CONFIG_BT_HCIUSB_SCO
 	case HCI_SCODATA_PKT:
 		hdev->stat.sco_tx++;
 		break;
@@ -626,7 +629,7 @@ static inline int __recv_frame(struct hc
 				} else
 					return -EILSEQ;
 				break;
-#ifdef CONFIG_BT_USB_SCO
+#ifdef CONFIG_BT_HCIUSB_SCO
 			case HCI_SCODATA_PKT:
 				if (count >= HCI_SCO_HDR_SIZE) {
 					struct hci_sco_hdr *h = data;
@@ -691,7 +694,7 @@ static void hci_usb_rx_complete(struct u
 		goto resubmit;
 
 	if (_urb->type == HCI_SCODATA_PKT) {
-#ifdef CONFIG_BT_USB_SCO
+#ifdef CONFIG_BT_HCIUSB_SCO
 		int i;
 		for (i=0; i < urb->number_of_packets; i++) {
 			BT_DBG("desc %d status %d offset %d len %d", i,
@@ -785,9 +788,11 @@ int hci_usb_probe(struct usb_interface *
 
 	iface = udev->actconfig->interface[0];
 
-	/* Check our black list */
-	if (usb_match_id(intf, ignore_ids))
-		return -EIO;
+	if (id->driver_info & HCI_IGNORE)
+		return -ENODEV;
+
+	if (intf->altsetting->desc.bInterfaceNumber > 0)
+		return -ENODEV;
 
 	/* Check number of endpoints */
 	if (intf->altsetting[0].desc.bNumEndpoints < 3)
@@ -826,9 +831,9 @@ int hci_usb_probe(struct usb_interface *
 						bulk_out_ep[i] = ep;
 					break;
 
-#ifdef CONFIG_BT_USB_SCO
+#ifdef CONFIG_BT_HCIUSB_SCO
 				case USB_ENDPOINT_XFER_ISOC:
-					if (ep->desc.wMaxPacketSize < size)
+					if (ep->desc.wMaxPacketSize < size || a > 2)
 						break;
 					size = ep->desc.wMaxPacketSize;
 
@@ -852,7 +857,7 @@ int hci_usb_probe(struct usb_interface *
 		goto done;
 	}
 
-#ifdef CONFIG_BT_USB_SCO
+#ifdef CONFIG_BT_HCIUSB_SCO
 	if (!isoc_in_ep[1] || !isoc_out_ep[1]) {
 		BT_DBG("Isoc endpoints not found");
 		isoc_iface = NULL;
@@ -871,7 +876,12 @@ int hci_usb_probe(struct usb_interface *
 	husb->bulk_in_ep  = bulk_in_ep[0];
 	husb->intr_in_ep  = intr_in_ep[0];
 
-#ifdef CONFIG_BT_USB_SCO
+	if (id->driver_info & HCI_DIGIANSWER)
+		husb->ctrl_req = HCI_DIGI_REQ;
+	else
+		husb->ctrl_req = HCI_CTRL_REQ;
+
+#ifdef CONFIG_BT_HCIUSB_SCO
 	if (isoc_iface) {
 		BT_DBG("isoc ifnum %d alts %d", isoc_ifnum, isoc_alts);
 		if (usb_set_interface(udev, isoc_ifnum, isoc_alts)) {
diff -puN drivers/bluetooth/hci_usb.h~linus drivers/bluetooth/hci_usb.h
--- 25/drivers/bluetooth/hci_usb.h~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/bluetooth/hci_usb.h	2004-01-19 22:17:21.000000000 -0800
@@ -35,12 +35,19 @@
 #define HCI_DEV_PROTOCOL     0x01	/* Bluetooth programming protocol */
 
 #define HCI_CTRL_REQ	     0x20
+#define HCI_DIGI_REQ	     0x40
+
+#define HCI_IGNORE           0x01
+#define HCI_DIGIANSWER       0x02
 
 #define HCI_MAX_IFACE_NUM	3 
 
 #define HCI_MAX_BULK_TX     	4
 #define HCI_MAX_BULK_RX     	1
 
+#define HCI_MAX_ISOC_RX		2
+#define HCI_MAX_ISOC_TX		2
+
 #define HCI_MAX_ISOC_FRAMES     10
 
 struct _urb_queue {
@@ -119,6 +126,8 @@ struct hci_usb {
 	struct usb_host_endpoint	*isoc_out_ep;
 	struct usb_host_endpoint	*isoc_in_ep;
 
+	__u8			ctrl_req;
+
 	struct sk_buff_head	transmit_q[4];
 	struct sk_buff		*reassembly[4]; // Reassembly buffers
 
diff -puN drivers/bluetooth/Kconfig~linus drivers/bluetooth/Kconfig
--- 25/drivers/bluetooth/Kconfig~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/bluetooth/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -13,22 +13,14 @@ config BT_HCIUSB
 	  Say Y here to compile support for Bluetooth USB devices into the
 	  kernel or say M to compile it as module (hci_usb).
 
-config BT_USB_SCO
-	bool "SCO over HCI USB support"
+config BT_HCIUSB_SCO
+	bool "SCO (voice) support"
 	depends on BT_HCIUSB
 	help
 	  This option enables the SCO support in the HCI USB driver. You need this
-	  to transmit voice data with your Bluetooth USB device. 
-	  Say Y here to compile support for SCO over HCI USB.
+	  to transmit voice data with your Bluetooth USB device.
 
-config BT_USB_ZERO_PACKET
-	bool "USB zero packet support"
-	depends on BT_HCIUSB
-	help
-	  This option is provided only as a work around for buggy Bluetooth USB 
-	  devices. Do _not_ enable it unless you know for sure that your device 
-	  requires zero packets.
-	  Most people should say N here.
+	  Say Y here to compile support for SCO over HCI USB.
 
 config BT_HCIUART
 	tristate "HCI UART driver"
@@ -65,13 +57,38 @@ config BT_HCIUART_BCSP
 	  Say Y here to compile support for HCI BCSP protocol.
 
 config BT_HCIUART_BCSP_TXCRC
-        bool "Transmit CRC with every BCSP packet"
-        depends on BT_HCIUART_BCSP
-        help
+	bool "Transmit CRC with every BCSP packet"
+	depends on BT_HCIUART_BCSP
+	help
 	  If you say Y here, a 16-bit CRC checksum will be transmitted along with
 	  every BCSP (BlueCore Serial Protocol) packet sent to the Bluetooth chip.
 	  This increases reliability, but slightly reduces efficiency.
 
+config BT_HCIBCM203X
+	tristate "HCI BCM203x USB driver"
+	depends on USB && BT
+	select FW_LOADER
+	help
+	  Bluetooth HCI BCM203x USB driver.
+	  This driver provides the firmware loading mechanism for the Broadcom
+	  Blutonium based devices.
+
+	  Say Y here to compile support for HCI BCM203x devices into the
+	  kernel or say M to compile it as module (bcm203x).
+
+config BT_HCIBFUSB
+	tristate "HCI BlueFRITZ! USB driver"
+	depends on USB && BT
+	select FW_LOADER
+	help
+	  Bluetooth HCI BlueFRITZ! USB driver.
+	  This driver provides support for Bluetooth USB devices with AVM
+	  interface:
+	     AVM BlueFRITZ! USB
+
+	  Say Y here to compile support for HCI BFUSB devices into the
+	  kernel or say M to compile it as module (bfusb).
+
 config BT_HCIDTL1
 	tristate "HCI DTL1 (PC Card) driver"
 	depends on PCMCIA && BT
diff -puN drivers/bluetooth/Makefile~linus drivers/bluetooth/Makefile
--- 25/drivers/bluetooth/Makefile~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/bluetooth/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -5,6 +5,8 @@
 obj-$(CONFIG_BT_HCIUSB)		+= hci_usb.o
 obj-$(CONFIG_BT_HCIVHCI)	+= hci_vhci.o
 obj-$(CONFIG_BT_HCIUART)	+= hci_uart.o
+obj-$(CONFIG_BT_HCIBCM203X)	+= bcm203x.o
+obj-$(CONFIG_BT_HCIBFUSB)	+= bfusb.o
 obj-$(CONFIG_BT_HCIDTL1)	+= dtl1_cs.o
 obj-$(CONFIG_BT_HCIBT3C)	+= bt3c_cs.o
 obj-$(CONFIG_BT_HCIBLUECARD)	+= bluecard_cs.o
diff -puN drivers/cdrom/cdrom.c~linus drivers/cdrom/cdrom.c
--- 25/drivers/cdrom/cdrom.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/cdrom/cdrom.c	2004-01-19 22:17:21.000000000 -0800
@@ -228,10 +228,16 @@
    3.12 Oct 18, 2000 - Jens Axboe <axboe@suse.de>
   -- Use quiet bit on packet commands not known to work
 
+   3.20 Dec 17, 2003 - Jens Axboe <axboe@suse.de>
+  -- Various fixes and lots of cleanups not listed :-)
+  -- Locking fixes
+  -- Mt Rainier support
+  -- DVD-RAM write open fixes
+
 -------------------------------------------------------------------------*/
 
-#define REVISION "Revision: 3.12"
-#define VERSION "Id: cdrom.c 3.12 2000/10/18"
+#define REVISION "Revision: 3.20"
+#define VERSION "Id: cdrom.c 3.20 2003/12/17"
 
 /* I use an error-log mask to give fine grain control over the type of
    messages dumped to the system logs.  The available masks include: */
@@ -282,11 +288,25 @@ static int autoeject;
 static int lockdoor = 1;
 /* will we ever get to use this... sigh. */
 static int check_media_type;
+/* automatically restart mrw format */
+static int mrw_format_restart = 1;
 MODULE_PARM(debug, "i");
 MODULE_PARM(autoclose, "i");
 MODULE_PARM(autoeject, "i");
 MODULE_PARM(lockdoor, "i");
 MODULE_PARM(check_media_type, "i");
+MODULE_PARM(mrw_format_restart, "i");
+
+static spinlock_t cdrom_lock = SPIN_LOCK_UNLOCKED;
+
+static const char *mrw_format_status[] = {
+	"not mrw",
+	"bgformat inactive",
+	"bgformat active",
+	"mrw complete",
+};
+
+static const char *mrw_address_space[] = { "DMA", "GAA" };
 
 #if (ERRLOGMASK!=CD_NOTHING)
 #define cdinfo(type, fmt, args...) \
@@ -325,6 +345,10 @@ int cdrom_get_last_written(struct cdrom_
 static int cdrom_get_next_writable(struct cdrom_device_info *, long *);
 static void cdrom_count_tracks(struct cdrom_device_info *, tracktype*);
 
+static int cdrom_mrw_exit(struct cdrom_device_info *cdi);
+
+static int cdrom_get_disc_info(struct cdrom_device_info *cdi, disc_information *di);
+
 #ifdef CONFIG_SYSCTL
 static void cdrom_sysctl_register(void);
 #endif /* CONFIG_SYSCTL */ 
@@ -347,13 +371,14 @@ int register_cdrom(struct cdrom_device_i
 
 	if (cdo->open == NULL || cdo->release == NULL)
 		return -2;
-	if ( !banner_printed ) {
+	if (!banner_printed) {
 		printk(KERN_INFO "Uniform CD-ROM driver " REVISION "\n");
 		banner_printed = 1;
 #ifdef CONFIG_SYSCTL
 		cdrom_sysctl_register();
 #endif /* CONFIG_SYSCTL */ 
 	}
+
 	ENSURE(drive_status, CDC_DRIVE_STATUS );
 	ENSURE(media_changed, CDC_MEDIA_CHANGED);
 	ENSURE(tray_move, CDC_CLOSE_TRAY | CDC_OPEN_TRAY);
@@ -378,9 +403,14 @@ int register_cdrom(struct cdrom_device_i
 	if (check_media_type==1)
 		cdi->options |= (int) CDO_CHECK_TYPE;
 
+	if (CDROM_CAN(CDC_MRW_W))
+		cdi->exit = cdrom_mrw_exit;
+
 	cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
+	spin_lock(&cdrom_lock);
 	cdi->next = topCdromPtr; 	
 	topCdromPtr = cdi;
+	spin_unlock(&cdrom_lock);
 	return 0;
 }
 #undef ENSURE
@@ -391,23 +421,310 @@ int unregister_cdrom(struct cdrom_device
 	cdinfo(CD_OPEN, "entering unregister_cdrom\n"); 
 
 	prev = NULL;
+	spin_lock(&cdrom_lock);
 	cdi = topCdromPtr;
 	while (cdi && cdi != unreg) {
 		prev = cdi;
 		cdi = cdi->next;
 	}
 
-	if (cdi == NULL)
+	if (cdi == NULL) {
+		spin_unlock(&cdrom_lock);
 		return -2;
+	}
 	if (prev)
 		prev->next = cdi->next;
 	else
 		topCdromPtr = cdi->next;
+
+	spin_unlock(&cdrom_lock);
+
+	if (cdi->exit)
+		cdi->exit(cdi);
+
 	cdi->ops->n_minors--;
 	cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
 	return 0;
 }
 
+int cdrom_get_media_event(struct cdrom_device_info *cdi,
+			  struct media_event_desc *med)
+{
+	struct cdrom_generic_command cgc;
+	unsigned char buffer[8];
+	struct event_header *eh = (struct event_header *) buffer;
+
+	init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_READ);
+	cgc.cmd[0] = GPCMD_GET_EVENT_STATUS_NOTIFICATION;
+	cgc.cmd[1] = 1;		/* IMMED */
+	cgc.cmd[4] = 1 << 4;	/* media event */
+	cgc.cmd[8] = sizeof(buffer);
+	cgc.quiet = 1;
+
+	if (cdi->ops->generic_packet(cdi, &cgc))
+		return 1;
+
+	if (be16_to_cpu(eh->data_len) < sizeof(*med))
+		return 1;
+
+	memcpy(med, &buffer[sizeof(*eh)], sizeof(*med));
+	return 0;
+}
+
+/*
+ * the first prototypes used 0x2c as the page code for the mrw mode page,
+ * subsequently this was changed to 0x03. probe the one used by this drive
+ */
+int cdrom_mrw_probe_pc(struct cdrom_device_info *cdi)
+{
+	struct cdrom_generic_command cgc;
+	char buffer[16];
+
+	init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_READ);
+
+	cgc.timeout = HZ;
+	cgc.quiet = 1;
+
+	if (!cdrom_mode_sense(cdi, &cgc, MRW_MODE_PC, 0)) {
+		cdi->mrw_mode_page = MRW_MODE_PC;
+		return 0;
+	} else if (!cdrom_mode_sense(cdi, &cgc, MRW_MODE_PC_PRE1, 0)) {
+		cdi->mrw_mode_page = MRW_MODE_PC_PRE1;
+		return 0;
+	}
+
+	printk(KERN_ERR "cdrom: %s: unknown mrw mode page\n", cdi->name);
+	return 1;
+}
+
+int cdrom_is_mrw(struct cdrom_device_info *cdi, int *write)
+{
+	struct cdrom_generic_command cgc;
+	struct mrw_feature_desc *mfd;
+	unsigned char buffer[16];
+	int ret;
+
+	init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_READ);
+
+	cgc.cmd[0] = GPCMD_GET_CONFIGURATION;
+	cgc.cmd[3] = CDF_MRW;
+	cgc.cmd[8] = sizeof(buffer);
+	cgc.quiet = 1;
+
+	if ((ret = cdi->ops->generic_packet(cdi, &cgc)))
+		return ret;
+
+	mfd = (struct mrw_feature_desc *)&buffer[sizeof(struct feature_header)];
+	*write = mfd->write;
+
+	if ((ret = cdrom_mrw_probe_pc(cdi)))
+		return ret;
+
+	return 0;
+}
+
+static int cdrom_mrw_bgformat(struct cdrom_device_info *cdi, int cont)
+{
+	struct cdrom_generic_command cgc;
+	unsigned char buffer[12];
+	int ret;
+
+	printk(KERN_INFO "cdrom: %sstarting format\n", cont ? "Re" : "");
+
+	/*
+	 * FmtData bit set (bit 4), format type is 1
+	 */
+	init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_WRITE);
+	cgc.cmd[0] = GPCMD_FORMAT_UNIT;
+	cgc.cmd[1] = (1 << 4) | 1;
+
+	cgc.timeout = 5 * 60 * HZ;
+
+	/*
+	 * 4 byte format list header, 8 byte format list descriptor
+	 */
+	buffer[1] = 1 << 1;
+	buffer[3] = 8;
+
+	/*
+	 * nr_blocks field
+	 */
+	buffer[4] = 0xff;
+	buffer[5] = 0xff;
+	buffer[6] = 0xff;
+	buffer[7] = 0xff;
+
+	buffer[8] = 0x24 << 2;
+	buffer[11] = cont;
+
+	ret = cdi->ops->generic_packet(cdi, &cgc);
+	if (ret)
+		printk(KERN_INFO "cdrom: bgformat failed\n");
+
+	return ret;
+}
+
+static int cdrom_mrw_bgformat_susp(struct cdrom_device_info *cdi, int immed)
+{
+	struct cdrom_generic_command cgc;
+
+	init_cdrom_command(&cgc, NULL, 0, CGC_DATA_NONE);
+	cgc.cmd[0] = GPCMD_CLOSE_TRACK;
+
+	/*
+	 * Session = 1, Track = 0
+	 */
+	cgc.cmd[1] = !!immed;
+	cgc.cmd[2] = 1 << 1;
+
+	cgc.timeout = 5 * 60 * HZ;
+
+	return cdi->ops->generic_packet(cdi, &cgc);
+}
+
+static int cdrom_flush_cache(struct cdrom_device_info *cdi)
+{
+	struct cdrom_generic_command cgc;
+
+	init_cdrom_command(&cgc, NULL, 0, CGC_DATA_NONE);
+	cgc.cmd[0] = GPCMD_FLUSH_CACHE;
+
+	cgc.timeout = 5 * 60 * HZ;
+
+	return cdi->ops->generic_packet(cdi, &cgc);
+}
+
+static int cdrom_mrw_exit(struct cdrom_device_info *cdi)
+{
+	disc_information di;
+	int ret = 0;
+
+	if (cdrom_get_disc_info(cdi, &di))
+		return 1;
+
+	if (di.mrw_status == CDM_MRW_BGFORMAT_ACTIVE) {
+		printk(KERN_INFO "cdrom: issuing MRW back ground format suspend\n");
+		ret = cdrom_mrw_bgformat_susp(cdi, 0);
+	}
+
+	if (!ret)
+		ret = cdrom_flush_cache(cdi);
+
+	return ret;
+}
+
+static int cdrom_mrw_set_lba_space(struct cdrom_device_info *cdi, int space)
+{
+	struct cdrom_generic_command cgc;
+	struct mode_page_header *mph;
+	char buffer[16];
+	int ret, offset, size;
+
+	init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_READ);
+
+	cgc.buffer = buffer;
+	cgc.buflen = sizeof(buffer);
+
+	if ((ret = cdrom_mode_sense(cdi, &cgc, cdi->mrw_mode_page, 0)))
+		return ret;
+
+	mph = (struct mode_page_header *) buffer;
+	offset = be16_to_cpu(mph->desc_length);
+	size = be16_to_cpu(mph->mode_data_length) + 2;
+
+	buffer[offset + 3] = space;
+	cgc.buflen = size;
+
+	if ((ret = cdrom_mode_select(cdi, &cgc)))
+		return ret;
+
+	printk(KERN_INFO "cdrom: %s: mrw address space %s selected\n", cdi->name, mrw_address_space[space]);
+	return 0;
+}
+
+static int cdrom_media_erasable(struct cdrom_device_info *cdi)
+{
+	disc_information di;
+
+	if (cdrom_get_disc_info(cdi, &di))
+		return 0;
+
+	return di.erasable;
+}
+
+/*
+ * FIXME: check RO bit
+ */
+static int cdrom_dvdram_open_write(struct cdrom_device_info *cdi)
+{
+	return !cdrom_media_erasable(cdi);
+}
+
+static int cdrom_mrw_open_write(struct cdrom_device_info *cdi)
+{
+	disc_information di;
+	int ret;
+
+	/*
+	 * always reset to DMA lba space on open
+	 */
+	if (cdrom_mrw_set_lba_space(cdi, MRW_LBA_DMA)) {
+		printk(KERN_ERR "cdrom: failed setting lba address space\n");
+		return 1;
+	}
+
+	if (cdrom_get_disc_info(cdi, &di))
+		return 1;
+
+	if (!di.erasable)
+		return 1;
+
+	/*
+	 * mrw_status
+	 * 0	-	not MRW formatted
+	 * 1	-	MRW bgformat started, but not running or complete
+	 * 2	-	MRW bgformat in progress
+	 * 3	-	MRW formatting complete
+	 */
+	ret = 0;
+	printk(KERN_INFO "cdrom open: mrw_status '%s'\n", mrw_format_status[di.mrw_status]);
+	if (!di.mrw_status)
+		ret = 1;
+	else if (di.mrw_status == CDM_MRW_BGFORMAT_INACTIVE && mrw_format_restart)
+		ret = cdrom_mrw_bgformat(cdi, 1);
+
+	return ret;
+}
+
+/*
+ * returns 0 for ok to open write, non-0 to disallow
+ */
+static int cdrom_open_write(struct cdrom_device_info *cdi)
+{
+	int ret = 1;
+
+	if (CDROM_CAN(CDC_MRW_W))
+		ret = cdrom_mrw_open_write(cdi);
+	else if (CDROM_CAN(CDC_DVD_RAM))
+		ret = cdrom_dvdram_open_write(cdi);
+	/*
+	 * needs to really check whether media is writeable
+	 */
+	else if (CDROM_CAN(CDC_MO_DRIVE))
+		ret = 0;
+
+	return ret;
+}
+
+static int cdrom_close_write(struct cdrom_device_info *cdi)
+{
+#if 0
+	return cdrom_flush_cache(cdi);
+#else
+	return 0;
+#endif
+}
+
 /* We use the open-option O_NONBLOCK to indicate that the
  * purpose of opening is only for subsequent ioctl() calls; no device
  * integrity checks are performed.
@@ -421,23 +738,34 @@ int cdrom_open(struct cdrom_device_info 
 	int ret;
 
 	cdinfo(CD_OPEN, "entering cdrom_open\n"); 
+
 	/* if this was a O_NONBLOCK open and we should honor the flags,
 	 * do a quick open without drive/disc integrity checks. */
-	if ((fp->f_flags & O_NONBLOCK) && (cdi->options & CDO_USE_FFLAGS))
+	cdi->use_count++;
+	if ((fp->f_flags & O_NONBLOCK) && (cdi->options & CDO_USE_FFLAGS)) {
 		ret = cdi->ops->open(cdi, 1);
-	else {
-		if ((fp->f_mode & FMODE_WRITE) && !CDROM_CAN(CDC_DVD_RAM))
-			return -EROFS;
-
+	} else {
+		if (fp->f_mode & FMODE_WRITE) {
+			ret = -EROFS;
+			if (!CDROM_CAN(CDC_RAM))
+				goto err;
+			if (cdrom_open_write(cdi))
+				goto err;
+		}
 		ret = open_for_data(cdi);
 	}
 
-	if (!ret) cdi->use_count++;
+	if (ret)
+		goto err;
 
-	cdinfo(CD_OPEN, "Use count for \"/dev/%s\" now %d\n", cdi->name, cdi->use_count);
+	cdinfo(CD_OPEN, "Use count for \"/dev/%s\" now %d\n",
+			cdi->name, cdi->use_count);
 	/* Do this on open.  Don't wait for mount, because they might
 	    not be mounting, but opening with O_NONBLOCK */
 	check_disk_change(ip->i_bdev);
+	return 0;
+err:
+	cdi->use_count--;
 	return ret;
 }
 
@@ -525,7 +853,7 @@ int open_for_data(struct cdrom_device_in
 		cdinfo(CD_OPEN, "open device failed.\n"); 
 		goto clean_up_and_return;
 	}
-	if (CDROM_CAN(CDC_LOCK) && cdi->options & CDO_LOCK) {
+	if (CDROM_CAN(CDC_LOCK) && (cdi->options & CDO_LOCK)) {
 			cdo->lock_door(cdi, 1);
 			cdinfo(CD_OPEN, "door locked.\n");
 	}
@@ -603,7 +931,6 @@ int check_for_audio_disc(struct cdrom_de
 	return 0;
 }
 
-
 /* Admittedly, the logic below could be performed in a nicer way. */
 int cdrom_release(struct cdrom_device_info *cdi, struct file *fp)
 {
@@ -617,12 +944,19 @@ int cdrom_release(struct cdrom_device_in
 	if (cdi->use_count == 0)
 		cdinfo(CD_CLOSE, "Use count for \"/dev/%s\" now zero\n", cdi->name);
 	if (cdi->use_count == 0 &&
-	    cdo->capability & CDC_LOCK && !keeplocked) {
+	    (cdo->capability & CDC_LOCK) && !keeplocked) {
 		cdinfo(CD_CLOSE, "Unlocking door!\n");
 		cdo->lock_door(cdi, 0);
 	}
 	opened_for_data = !(cdi->options & CDO_USE_FFLAGS) ||
 		!(fp && fp->f_flags & O_NONBLOCK);
+
+	/*
+	 * flush cache on last write release
+	 */
+	if (CDROM_CAN(CDC_RAM) && !cdi->use_count && cdi->for_data)
+		cdrom_close_write(cdi);
+
 	cdo->release(cdi);
 	if (cdi->use_count == 0) {      /* last process that closes dev*/
 		if (opened_for_data &&
@@ -2203,7 +2537,6 @@ static int cdrom_get_disc_info(struct cd
 	return cdo->generic_packet(cdi, &cgc);
 }
 
-
 /* return the last written block on the CD-R media. this is for the udf
    file system. */
 int cdrom_get_last_written(struct cdrom_device_info *cdi, long *last_written)
@@ -2310,6 +2643,8 @@ EXPORT_SYMBOL(cdrom_number_of_slots);
 EXPORT_SYMBOL(cdrom_mode_select);
 EXPORT_SYMBOL(cdrom_mode_sense);
 EXPORT_SYMBOL(init_cdrom_command);
+EXPORT_SYMBOL(cdrom_get_media_event);
+EXPORT_SYMBOL(cdrom_is_mrw);
 
 #ifdef CONFIG_SYSCTL
 
@@ -2406,6 +2741,14 @@ int cdrom_sysctl_info(ctl_table *ctl, in
 	for (cdi=topCdromPtr;cdi!=NULL;cdi=cdi->next)
 	    pos += sprintf(info+pos, "\t%d", CDROM_CAN(CDC_DVD_RAM) != 0);
 
+	pos += sprintf(info+pos, "\nCan read MRW:");
+	for (cdi=topCdromPtr;cdi!=NULL;cdi=cdi->next)
+	    pos += sprintf(info+pos, "\t\t%d", CDROM_CAN(CDC_MRW) != 0);
+
+	pos += sprintf(info+pos, "\nCan write MRW:");
+	for (cdi=topCdromPtr;cdi!=NULL;cdi=cdi->next)
+	    pos += sprintf(info+pos, "\t\t%d", CDROM_CAN(CDC_MRW_W) != 0);
+
 	strcpy(info+pos,"\n\n");
 		
         return proc_dostring(ctl, write, filp, buffer, lenp);
diff -puN drivers/char/efirtc.c~linus drivers/char/efirtc.c
--- 25/drivers/char/efirtc.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/efirtc.c	2004-01-19 22:17:21.000000000 -0800
@@ -118,6 +118,7 @@ convert_to_efi_time(struct rtc_time *wti
 static void
 convert_from_efi_time(efi_time_t *eft, struct rtc_time *wtime)
 {
+	memset(wtime, 0, sizeof(*wtime));
 	wtime->tm_sec  = eft->second;
 	wtime->tm_min  = eft->minute;
 	wtime->tm_hour = eft->hour;
diff -puN drivers/char/genrtc.c~linus drivers/char/genrtc.c
--- 25/drivers/char/genrtc.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/genrtc.c	2004-01-19 22:17:21.000000000 -0800
@@ -375,68 +375,13 @@ static int gen_rtc_release(struct inode 
 	return 0;
 }
 
-static int gen_rtc_read_proc(char *page, char **start, off_t off,
-			     int count, int *eof, void *data);
-
-
-/*
- *	The various file operations we support.
- */
-
-static struct file_operations gen_rtc_fops = {
-	.owner		= THIS_MODULE,
-#ifdef CONFIG_GEN_RTC_X
-	.read		= gen_rtc_read,
-	.poll		= gen_rtc_poll,
-#endif
-	.ioctl		= gen_rtc_ioctl,
-	.open		= gen_rtc_open,
-	.release	= gen_rtc_release,
-};
-
-static struct miscdevice rtc_gen_dev =
-{
-	.minor		= RTC_MINOR,
-	.name		= "rtc",
-	.fops		= &gen_rtc_fops,
-};
-
-static int __init rtc_generic_init(void)
-{
-	int retval;
-
-	printk(KERN_INFO "Generic RTC Driver v%s\n", RTC_VERSION);
-
-	retval = misc_register(&rtc_gen_dev);
-	if(retval < 0)
-		return retval;
 
 #ifdef CONFIG_PROC_FS
-	if((create_proc_read_entry ("driver/rtc", 0, 0, gen_rtc_read_proc, NULL)) == NULL){
-		misc_deregister(&rtc_gen_dev);
-		return -ENOMEM;
-	}
-#endif
-
-	return 0;
-}
-
-static void __exit rtc_generic_exit(void)
-{
-	remove_proc_entry ("driver/rtc", NULL);
-	misc_deregister(&rtc_gen_dev);
-}
-
-module_init(rtc_generic_init);
-module_exit(rtc_generic_exit);
-
 
 /*
  *	Info exported via "/proc/rtc".
  */
 
-#ifdef CONFIG_PROC_FS
-
 static int gen_rtc_proc_output(char *buf)
 {
 	char *p;
@@ -524,6 +469,58 @@ static int gen_rtc_read_proc(char *page,
 #endif /* CONFIG_PROC_FS */
 
 
+/*
+ *	The various file operations we support.
+ */
+
+static struct file_operations gen_rtc_fops = {
+	.owner		= THIS_MODULE,
+#ifdef CONFIG_GEN_RTC_X
+	.read		= gen_rtc_read,
+	.poll		= gen_rtc_poll,
+#endif
+	.ioctl		= gen_rtc_ioctl,
+	.open		= gen_rtc_open,
+	.release	= gen_rtc_release,
+};
+
+static struct miscdevice rtc_gen_dev =
+{
+	.minor		= RTC_MINOR,
+	.name		= "rtc",
+	.fops		= &gen_rtc_fops,
+};
+
+static int __init rtc_generic_init(void)
+{
+	int retval;
+
+	printk(KERN_INFO "Generic RTC Driver v%s\n", RTC_VERSION);
+
+	retval = misc_register(&rtc_gen_dev);
+	if(retval < 0)
+		return retval;
+
+#ifdef CONFIG_PROC_FS
+	if((create_proc_read_entry ("driver/rtc", 0, 0, gen_rtc_read_proc, NULL)) == NULL){
+		misc_deregister(&rtc_gen_dev);
+		return -ENOMEM;
+	}
+#endif
+
+	return 0;
+}
+
+static void __exit rtc_generic_exit(void)
+{
+	remove_proc_entry ("driver/rtc", NULL);
+	misc_deregister(&rtc_gen_dev);
+}
+
+
+module_init(rtc_generic_init);
+module_exit(rtc_generic_exit);
+
 MODULE_AUTHOR("Richard Zidlicky");
 MODULE_LICENSE("GPL");
 
diff -puN drivers/char/hp600_keyb.c~linus drivers/char/hp600_keyb.c
--- 25/drivers/char/hp600_keyb.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/hp600_keyb.c	2004-01-19 22:17:21.000000000 -0800
@@ -9,6 +9,7 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/init.h>
+#include <linux/module.h>
 
 #include <asm/machvec.h>
 #include <asm/delay.h>
diff -puN drivers/char/Kconfig~linus drivers/char/Kconfig
--- 25/drivers/char/Kconfig~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -588,8 +588,6 @@ config PC9800_OLDLP_CONSOLE
 	bool "Support for console on line printer"
 	depends on PC9800_OLDLP
 
-source "drivers/i2c/Kconfig"
-
 
 menu "Mice"
 
diff -puN drivers/char/keyboard.c~linus drivers/char/keyboard.c
--- 25/drivers/char/keyboard.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/keyboard.c	2004-01-19 22:17:21.000000000 -0800
@@ -933,7 +933,7 @@ void kbd_refresh_leds(struct input_handl
 	tasklet_enable(&keyboard_tasklet);
 }
 
-#if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_ALPHA) || defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_SPARC32) || defined(CONFIG_SPARC64) || defined(CONFIG_PARISC)
+#if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_ALPHA) || defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_SPARC32) || defined(CONFIG_SPARC64) || defined(CONFIG_PARISC) || defined(CONFIG_SH_MPC1211)
 
 static unsigned short x86_keycodes[256] =
 	{ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
diff -puN drivers/char/lp.c~linus drivers/char/lp.c
--- 25/drivers/char/lp.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/lp.c	2004-01-19 22:17:21.000000000 -0800
@@ -145,6 +145,7 @@
 struct lp_struct lp_table[LP_NO];
 
 static unsigned int lp_count = 0;
+static struct class_simple *lp_class;
 
 #ifdef CONFIG_LP_CONSOLE
 static struct parport *console_registered; // initially NULL
@@ -795,6 +796,8 @@ static int lp_register(int nr, struct pa
 	if (reset)
 		lp_reset(nr);
 
+	class_simple_device_add(lp_class, MKDEV(LP_MAJOR, nr), NULL,
+				"lp%d", nr);
 	devfs_mk_cdev(MKDEV(LP_MAJOR, nr), S_IFCHR | S_IRUGO | S_IWUGO,
 			"printers/%d", nr);
 
@@ -897,6 +900,7 @@ int __init lp_init (void)
 	}
 
 	devfs_mk_dir("printers");
+	lp_class = class_simple_create(THIS_MODULE, "printer");
 
 	if (parport_register_driver (&lp_driver)) {
 		printk (KERN_ERR "lp: unable to register with parport\n");
@@ -958,8 +962,10 @@ static void lp_cleanup_module (void)
 			continue;
 		parport_unregister_device(lp_table[offset].dev);
 		devfs_remove("printers/%d", offset);
+		class_simple_device_remove(MKDEV(LP_MAJOR, offset));
 	}
 	devfs_remove("printers");
+	class_simple_destroy(lp_class);
 }
 
 __setup("lp=", lp_setup);
diff -puN drivers/char/mem.c~linus drivers/char/mem.c
--- 25/drivers/char/mem.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/mem.c	2004-01-19 22:17:21.000000000 -0800
@@ -24,6 +24,7 @@
 #include <linux/smp_lock.h>
 #include <linux/devfs_fs_kernel.h>
 #include <linux/ptrace.h>
+#include <linux/device.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -676,6 +677,8 @@ static const struct {
 	{11,"kmsg",    S_IRUGO | S_IWUSR,           &kmsg_fops},
 };
 
+static struct class_simple *mem_class;
+
 static int __init chr_dev_init(void)
 {
 	int i;
@@ -683,7 +686,11 @@ static int __init chr_dev_init(void)
 	if (register_chrdev(MEM_MAJOR,"mem",&memory_fops))
 		printk("unable to get major %d for memory devs\n", MEM_MAJOR);
 
+	mem_class = class_simple_create(THIS_MODULE, "mem");
 	for (i = 0; i < ARRAY_SIZE(devlist); i++) {
+		class_simple_device_add(mem_class,
+					MKDEV(MEM_MAJOR, devlist[i].minor),
+					NULL, devlist[i].name);
 		devfs_mk_cdev(MKDEV(MEM_MAJOR, devlist[i].minor),
 				S_IFCHR | devlist[i].mode, devlist[i].name);
 	}
diff -puN drivers/char/misc.c~linus drivers/char/misc.c
--- 25/drivers/char/misc.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/misc.c	2004-01-19 22:17:21.000000000 -0800
@@ -47,7 +47,7 @@
 #include <linux/devfs_fs_kernel.h>
 #include <linux/stat.h>
 #include <linux/init.h>
-
+#include <linux/device.h>
 #include <linux/tty.h>
 #include <linux/kmod.h>
 
@@ -180,6 +180,13 @@ fail:
 	return err;
 }
 
+/* 
+ * TODO for 2.7:
+ *  - add a struct class_device to struct miscdevice and make all usages of
+ *    them dynamic.
+ */
+static struct class_simple *misc_class;
+
 static struct file_operations misc_fops = {
 	.owner		= THIS_MODULE,
 	.open		= misc_open,
@@ -234,6 +241,8 @@ int misc_register(struct miscdevice * mi
 				"misc/%s", misc->name);
 	}
 
+	class_simple_device_add(misc_class, MKDEV(MISC_MAJOR, misc->minor),
+				misc->dev, misc->name);
 	devfs_mk_cdev(MKDEV(MISC_MAJOR, misc->minor),
 			S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP, misc->devfs_name);
 
@@ -265,6 +274,7 @@ int misc_deregister(struct miscdevice * 
 
 	down(&misc_sem);
 	list_del(&misc->list);
+	class_simple_device_remove(MKDEV(MISC_MAJOR, misc->minor));
 	devfs_remove(misc->devfs_name);
 	if (i < DYNAMIC_MINORS && i>0) {
 		misc_minors[i>>3] &= ~(1 << (misc->minor & 7));
@@ -285,6 +295,9 @@ static int __init misc_init(void)
 	if (ent)
 		ent->proc_fops = &misc_proc_fops;
 #endif
+	misc_class = class_simple_create(THIS_MODULE, "misc");
+	if (IS_ERR(misc_class))
+		return PTR_ERR(misc_class);
 #ifdef CONFIG_MVME16x
 	rtc_MK48T08_init();
 #endif
@@ -319,4 +332,4 @@ static int __init misc_init(void)
 	}
 	return 0;
 }
-module_init(misc_init);
+subsys_initcall(misc_init);
diff -puN drivers/char/pcmcia/synclink_cs.c~linus drivers/char/pcmcia/synclink_cs.c
--- 25/drivers/char/pcmcia/synclink_cs.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/pcmcia/synclink_cs.c	2004-01-19 22:17:21.000000000 -0800
@@ -592,7 +592,7 @@ static dev_link_t *mgslpc_attach(void)
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
 
-    ret = CardServices(RegisterClient, &link->handle, &client_reg);
+    ret = pcmcia_register_client(&link->handle, &client_reg);
     if (ret != CS_SUCCESS) {
 	    cs_error(link->handle, RegisterClient, ret);
 	    mgslpc_detach(link);
@@ -607,8 +607,8 @@ static dev_link_t *mgslpc_attach(void)
 /* Card has been inserted.
  */
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn),args))!=0) goto cs_failed
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static void mgslpc_config(dev_link_t *link)
 {
@@ -631,9 +631,9 @@ static void mgslpc_config(dev_link_t *li
     tuple.TupleData = buf;
     tuple.TupleDataMax = sizeof(buf);
     tuple.TupleOffset = 0;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
-    CS_CHECK(GetTupleData, handle, &tuple);
-    CS_CHECK(ParseTuple, handle, &tuple, &parse);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+    CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+    CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
     link->conf.ConfigBase = parse.config.base;
     link->conf.Present = parse.config.rmask[0];
     
@@ -641,17 +641,17 @@ static void mgslpc_config(dev_link_t *li
     link->state |= DEV_CONFIG;
 
     /* Look up the current Vcc */
-    CS_CHECK(GetConfigurationInfo, handle, &conf);
+    CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf));
     link->conf.Vcc = conf.Vcc;
 
     /* get CIS configuration entry */
 
     tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
 
     cfg = &(parse.cftable_entry);
-    CS_CHECK(GetTupleData, handle, &tuple);
-    CS_CHECK(ParseTuple, handle, &tuple, &parse);
+    CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+    CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
 
     if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg;
     if (cfg->index == 0)
@@ -672,7 +672,7 @@ static void mgslpc_config(dev_link_t *li
 	    link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;
 	    link->io.BasePort1 = io->win[0].base;
 	    link->io.NumPorts1 = io->win[0].len;
-	    CS_CHECK(RequestIO, link->handle, &link->io);
+	    CS_CHECK(RequestIO, pcmcia_request_io(link->handle, &link->io));
     }
 
     link->conf.Attributes = CONF_ENABLE_IRQ;
@@ -684,9 +684,9 @@ static void mgslpc_config(dev_link_t *li
     link->irq.Attributes |= IRQ_HANDLE_PRESENT;
     link->irq.Handler     = mgslpc_isr;
     link->irq.Instance    = info;
-    CS_CHECK(RequestIRQ, link->handle, &link->irq);
+    CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
 
-    CS_CHECK(RequestConfiguration, link->handle, &link->conf);
+    CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
 
     info->io_base = link->io.BasePort1;
     info->irq_level = link->irq.AssignedIRQ;
@@ -728,11 +728,11 @@ static void mgslpc_release(u_long arg)
     link->dev = NULL;
     link->state &= ~DEV_CONFIG;
 
-    CardServices(ReleaseConfiguration, link->handle);
+    pcmcia_release_configuration(link->handle);
     if (link->io.NumPorts1)
-	    CardServices(ReleaseIO, link->handle, &link->io);
+	    pcmcia_release_io(link->handle, &link->io);
     if (link->irq.AssignedIRQ)
-	    CardServices(ReleaseIRQ, link->handle, &link->irq);
+	    pcmcia_release_irq(link->handle, &link->irq);
     if (link->state & DEV_STALE_LINK)
 	    mgslpc_detach(link);
 }
@@ -763,7 +763,7 @@ static void mgslpc_detach(dev_link_t *li
 
     /* Break the link with Card Services */
     if (link->handle)
-	    CardServices(DeregisterClient, link->handle);
+	    pcmcia_deregister_client(link->handle);
     
     /* Unlink device structure, and free it */
     *linkp = link->next;
@@ -798,14 +798,14 @@ static int mgslpc_event(event_t event, i
 	    /* Mark the device as stopped, to block IO until later */
 	    info->stop = 1;
 	    if (link->state & DEV_CONFIG)
-		    CardServices(ReleaseConfiguration, link->handle);
+		    pcmcia_release_configuration(link->handle);
 	    break;
     case CS_EVENT_PM_RESUME:
 	    link->state &= ~DEV_SUSPEND;
 	    /* Fall through... */
     case CS_EVENT_CARD_RESET:
 	    if (link->state & DEV_CONFIG)
-		    CardServices(RequestConfiguration, link->handle, &link->conf);
+		    pcmcia_request_configuration(link->handle, &link->conf);
 	    info->stop = 0;
 	    break;
     }
diff -puN drivers/char/raw.c~linus drivers/char/raw.c
--- 25/drivers/char/raw.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/raw.c	2004-01-19 22:17:21.000000000 -0800
@@ -57,28 +57,31 @@ static int raw_open(struct inode *inode,
 	 */
 	bdev = raw_devices[minor].binding;
 	err = -ENODEV;
-	if (bdev) {
-		err = blkdev_get(bdev, filp->f_mode, 0, BDEV_RAW);
-		if (err)
-			goto out;
-		igrab(bdev->bd_inode);
-		err = bd_claim(bdev, raw_open);
-		if (err) {
-			blkdev_put(bdev, BDEV_RAW);
-			goto out;
-		}
-		err = set_blocksize(bdev, bdev_hardsect_size(bdev));
-		if (err) {
-			bd_release(bdev);
-			blkdev_put(bdev, BDEV_RAW);
-			goto out;
-		}
-		filp->f_flags |= O_DIRECT;
-		if (++raw_devices[minor].inuse == 1)
-			filp->f_dentry->d_inode->i_mapping =
-				bdev->bd_inode->i_mapping;
-	}
+	if (!bdev)
+		goto out;
+	igrab(bdev->bd_inode);
+	err = blkdev_get(bdev, filp->f_mode, 0, BDEV_RAW);
+	if (err)
+		goto out;
+	err = bd_claim(bdev, raw_open);
+	if (err)
+		goto out1;
+	err = set_blocksize(bdev, bdev_hardsect_size(bdev));
+	if (err)
+		goto out2;
+	filp->f_flags |= O_DIRECT;
+	filp->f_mapping = bdev->bd_inode->i_mapping;
+	if (++raw_devices[minor].inuse == 1)
+		filp->f_dentry->d_inode->i_mapping =
+			bdev->bd_inode->i_mapping;
 	filp->private_data = bdev;
+	up(&raw_mutex);
+	return 0;
+
+out2:
+	bd_release(bdev);
+out1:
+	blkdev_put(bdev, BDEV_RAW);
 out:
 	up(&raw_mutex);
 	return err;
diff -puN drivers/char/rtc.c~linus drivers/char/rtc.c
--- 25/drivers/char/rtc.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/rtc.c	2004-01-19 22:17:21.000000000 -0800
@@ -431,7 +431,7 @@ static int rtc_do_ioctl(unsigned int cmd
 		 * means "don't care" or "match all". Only the tm_hour,
 		 * tm_min, and tm_sec values are filled in.
 		 */
-
+		memset(&wtime, 0, sizeof(struct rtc_time));
 		get_rtc_alm_time(&wtime);
 		break; 
 	}
@@ -481,6 +481,7 @@ static int rtc_do_ioctl(unsigned int cmd
 	}
 	case RTC_RD_TIME:	/* Read the time/date from RTC	*/
 	{
+		memset(&wtime, 0, sizeof(struct rtc_time));
 		rtc_get_rtc_time(&wtime);
 		break;
 	}
diff -puN drivers/char/sh-sci.c~linus drivers/char/sh-sci.c
--- 25/drivers/char/sh-sci.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/sh-sci.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: sh-sci.c,v 1.40 2000/04/15 06:57:29 gniibe Exp $
+/* $Id: sh-sci.c,v 1.15 2003/10/13 07:21:19 lethal Exp $
  *
  *  linux/drivers/char/sh-sci.c
  *
@@ -6,6 +6,7 @@
  *  Copyright (C) 1999, 2000  Niibe Yutaka
  *  Copyright (C) 2000  Sugioka Toshinobu
  *  Modified to support multiple serial ports. Stuart Menefy (May 2000).
+ *  Modified to support SH7760 SCIF. Paul Mundt (Oct 2003).
  *
  * TTY code is based on sx.c (Specialix SX driver) by:
  *
@@ -32,9 +33,13 @@
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/delay.h>
-#ifdef CONFIG_SERIAL_CONSOLE
+#if defined(CONFIG_SERIAL_CONSOLE) || defined(CONFIG_SH_KGDB_CONSOLE)
 #include <linux/console.h>
 #endif
+#ifdef CONFIG_CPU_FREQ
+#include <linux/notifier.h>
+#include <linux/cpufreq.h>
+#endif
 
 #include <asm/system.h>
 #include <asm/io.h>
@@ -50,17 +55,37 @@
 
 #include "sh-sci.h"
 
+#ifdef CONFIG_SH_KGDB
+#include <asm/kgdb.h>
+
+int kgdb_sci_setup(void);
+static int kgdb_get_char(struct sci_port *port);
+static void kgdb_put_char(struct sci_port *port, char c);
+static void kgdb_handle_error(struct sci_port *port);
+static struct sci_port *kgdb_sci_port;
+
+#ifdef CONFIG_SH_KGDB_CONSOLE
+static struct console kgdbcons;
+void __init kgdb_console_init(void);
+#endif /* CONFIG_SH_KGDB_CONSOLE */
+
+#endif /* CONFIG_SH_KGDB */
+
 #ifdef CONFIG_SERIAL_CONSOLE
 static struct console sercons;
 static struct sci_port* sercons_port=0;
 static int sercons_baud;
-#endif
+#ifdef CONFIG_MAGIC_SYSRQ
+#include <linux/sysrq.h>
+static int break_pressed;
+#endif /* CONFIG_MAGIC_SYSRQ */
+#endif /* CONFIG_SERIAL_CONSOLE */
 
 /* Function prototypes */
 static void sci_init_pins_sci(struct sci_port* port, unsigned int cflag);
 #ifndef SCI_ONLY
 static void sci_init_pins_scif(struct sci_port* port, unsigned int cflag);
-#if defined(__sh3__)
+#if defined(CONFIG_CPU_SH3)
 static void sci_init_pins_irda(struct sci_port* port, unsigned int cflag);
 #endif
 #endif
@@ -71,6 +96,8 @@ static void sci_enable_rx_interrupts(voi
 static int  sci_get_CD(void *ptr);
 static void sci_shutdown_port(void *ptr);
 static int sci_set_real_termios(void *ptr);
+static void sci_hungup(void *ptr);
+static void sci_close(void *ptr);
 static int sci_chars_in_buffer(void *ptr);
 static int sci_request_irq(struct sci_port *port);
 static void sci_free_irq(struct sci_port *port);
@@ -94,7 +121,7 @@ static void put_char(struct sci_port *po
 	unsigned long flags;
 	unsigned short status;
 
-	save_and_cli(flags);
+	local_irq_save(flags);
 
 	do
 		status = sci_in(port, SCxSR);
@@ -104,11 +131,11 @@ static void put_char(struct sci_port *po
 	sci_in(port, SCxSR);            /* Dummy read */
 	sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
 
-	restore_flags(flags);
+	local_irq_restore(flags);
 }
 #endif
 
-#ifdef CONFIG_SH_STANDARD_BIOS
+#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
 
 static void handle_error(struct sci_port *port)
 {				/* Clear error flags */
@@ -121,7 +148,7 @@ static int get_char(struct sci_port *por
 	unsigned short status;
 	int c;
 
-	save_and_cli(flags);
+	local_irq_save(flags);
         do {
 		status = sci_in(port, SCxSR);
 		if (status & SCxSR_ERRORS(port)) {
@@ -132,7 +159,7 @@ static int get_char(struct sci_port *por
 	c = sci_in(port, SCxRDR);
 	sci_in(port, SCxSR);            /* Dummy read */
 	sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
-	restore_flags(flags);
+	local_irq_restore(flags);
 
 	return c;
 }
@@ -150,7 +177,7 @@ static __inline__ char lowhex(int  x)
 	return hexchars[x & 0xf];
 }
 
-#endif
+#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
 
 /*
  * Send the packet in buffer.  The host gets one chance to read it.
@@ -162,13 +189,22 @@ static void put_string(struct sci_port *
 {
 	int i;
 	const unsigned char *p = buffer;
-#ifdef CONFIG_SH_STANDARD_BIOS
+
+#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
 	int checksum;
+	int usegdb=0;
 
+#ifdef CONFIG_SH_STANDARD_BIOS
     	/* This call only does a trap the first time it is
 	 * called, and so is safe to do here unconditionally
 	 */
-	if (sh_bios_in_gdb_mode()) {
+	usegdb |= sh_bios_in_gdb_mode();
+#endif
+#ifdef CONFIG_SH_KGDB
+	usegdb |= (kgdb_in_gdb_mode && (port == kgdb_sci_port));
+#endif
+
+	if (usegdb) {
 	    /*  $<packet info>#<checksum>. */
 	    do {
 		unsigned char c;
@@ -191,15 +227,101 @@ static void put_string(struct sci_port *
 		put_char(port, lowhex(checksum));
 	    } while  (get_char(port) != '+');
 	} else
-#endif
+#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
 	for (i=0; i<count; i++) {
 		if (*p == 10)
 			put_char(port, '\r');
 		put_char(port, *p++);
 	}
 }
-#endif
+#endif /* CONFIG_SERIAL_CONSOLE */
+
+
+#ifdef CONFIG_SH_KGDB
+
+/* Is the SCI ready, ie is there a char waiting? */
+static int kgdb_is_char_ready(struct sci_port *port)
+{
+        unsigned short status = sci_in(port, SCxSR);
+
+        if (status & (SCxSR_ERRORS(port) | SCxSR_BRK(port)))
+                kgdb_handle_error(port);
+
+        return (status & SCxSR_RDxF(port));
+}
+
+/* Write a char */
+static void kgdb_put_char(struct sci_port *port, char c)
+{
+        unsigned short status;
+
+        do
+                status = sci_in(port, SCxSR);
+        while (!(status & SCxSR_TDxE(port)));
 
+        sci_out(port, SCxTDR, c);
+        sci_in(port, SCxSR);    /* Dummy read */
+        sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
+}
+
+/* Get a char if there is one, else ret -1 */
+static int kgdb_get_char(struct sci_port *port)
+{
+        int c;
+
+        if (kgdb_is_char_ready(port) == 0)
+                c = -1;
+        else {
+                c = sci_in(port, SCxRDR);
+                sci_in(port, SCxSR);    /* Dummy read */
+                sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
+        }
+
+        return c;
+}
+
+/* Called from kgdbstub.c to get a character, i.e. is blocking */
+static int kgdb_sci_getchar(void)
+{
+        volatile int c;
+
+        /* Keep trying to read a character, this could be neater */
+        while ((c = kgdb_get_char(kgdb_sci_port)) < 0);
+
+        return c;
+}
+
+/* Called from kgdbstub.c to put a character, just a wrapper */
+static void kgdb_sci_putchar(int c)
+{
+
+        kgdb_put_char(kgdb_sci_port, c);
+}
+
+/* Clear any errors on the SCI */
+static void kgdb_handle_error(struct sci_port *port)
+{
+        sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port));  /* Clear error flags */
+}
+
+/* Breakpoint if there's a break sent on the serial port */
+static void kgdb_break_interrupt(int irq, void *ptr, struct pt_regs *regs)
+{
+        struct sci_port *port = ptr;
+        unsigned short status = sci_in(port, SCxSR);
+
+        if (status & SCxSR_BRK(port)) {
+
+                /* Break into the debugger if a break is detected */
+                BREAKPOINT();
+
+                /* Clear */
+                sci_out(port, SCxSR, SCxSR_BREAK_CLEAR(port));
+                return;
+        }
+}
+
+#endif /* CONFIG_SH_KGDB */
 
 static struct real_driver sci_real_driver = {
 	sci_disable_tx_interrupts,
@@ -210,6 +332,8 @@ static struct real_driver sci_real_drive
 	sci_shutdown_port,
 	sci_set_real_termios,
 	sci_chars_in_buffer,
+        sci_close,
+        sci_hungup,
 	NULL
 };
 
@@ -220,7 +344,7 @@ static void sci_init_pins_sci(struct sci
 #endif
 
 #if defined(SCIF_ONLY) || defined(SCI_AND_SCIF)
-#if defined(__sh3__)
+#if defined(CONFIG_CPU_SH3)
 /* For SH7707, SH7709, SH7709A, SH7729 */
 static void sci_init_pins_scif(struct sci_port* port, unsigned int cflag)
 {
@@ -232,7 +356,7 @@ static void sci_init_pins_scif(struct sc
 		/* We need to set SCPCR to enable RTS/CTS */
 		data = ctrl_inw(SCPCR);
 		/* Clear out SCP7MD1,0, SCP6MD1,0, SCP4MD1,0*/
-		ctrl_outw(data&0x0fcf, SCPCR);
+		ctrl_outw(data&0x0cff, SCPCR);
 	}
 	if (cflag & CRTSCTS)
 		fcr_val |= SCFCR_MCE;
@@ -243,7 +367,7 @@ static void sci_init_pins_scif(struct sc
 		data = ctrl_inw(SCPCR);
 		/* Clear out SCP7MD1,0, SCP4MD1,0,
 		   Set SCP6MD1,0 = {01} (output)  */
-		ctrl_outw((data&0x0fcf)|0x1000, SCPCR);
+		ctrl_outw((data&0x0cff)|0x1000, SCPCR);
 
 		data = ctrl_inb(SCPDR);
 		/* Set /RTS2 (bit6) = 0 */
@@ -373,7 +497,7 @@ static void sci_set_termios_cflag(struct
 	if (cflag & PARENB)
 		smr_val |= 0x20;
 	if (cflag & PARODD)
-		smr_val |= 0x10;
+		smr_val |= 0x30;
 	if (cflag & CSTOPB)
 		smr_val |= 0x08;
 	sci_out(port, SCSMR, smr_val);
@@ -393,22 +517,6 @@ static int sci_set_real_termios(void *pt
 		sci_enable_rx_interrupts(port);
 	}
 
-	/* Tell line discipline whether we will do input cooking */
-	if (I_OTHER(port->gs.tty))
-		clear_bit(TTY_HW_COOK_IN, &port->gs.tty->flags);
-	else
-		set_bit(TTY_HW_COOK_IN, &port->gs.tty->flags);
-
-/* Tell line discipline whether we will do output cooking.
- * If OPOST is set and no other output flags are set then we can do output
- * processing.  Even if only *one* other flag in the O_OTHER group is set
- * we do cooking in software.
- */
-	if (O_OPOST(port->gs.tty) && !O_OTHER(port->gs.tty))
-		set_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags);
-	else
-		clear_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags);
-
 	return 0;
 }
 
@@ -437,7 +545,7 @@ static void sci_transmit_chars(struct sc
 
 	status = sci_in(port, SCxSR);
 	if (!(status & SCxSR_TDxE(port))) {
-		save_and_cli(flags);
+		local_irq_save(flags);
 		ctrl = sci_in(port, SCSCR);
 		if (port->gs.xmit_cnt == 0) {
 			ctrl &= ~SCI_CTRL_FLAGS_TIE;
@@ -445,7 +553,7 @@ static void sci_transmit_chars(struct sc
 		} else
 			ctrl |= SCI_CTRL_FLAGS_TIE;
 		sci_out(port, SCSCR, ctrl);
-		restore_flags(flags);
+		local_irq_restore(flags);
 		return;
 	}
 
@@ -459,7 +567,7 @@ static void sci_transmit_chars(struct sc
 		if (count > txroom)
 			count = txroom;
 
-		/* Don't copy pas the end of the source buffer */
+		/* Don't copy past the end of the source buffer */
 		if (count > SERIAL_XMIT_SIZE - port->gs.xmit_tail)
                 	count = SERIAL_XMIT_SIZE - port->gs.xmit_tail;
 
@@ -486,7 +594,7 @@ static void sci_transmit_chars(struct sc
 	if (port->gs.xmit_cnt <= port->gs.wakeup_chars)
 		sci_sched_event(port, SCI_EVENT_WRITE_WAKEUP);
 
-	save_and_cli(flags);
+	local_irq_save(flags);
 	ctrl = sci_in(port, SCSCR);
 	if (port->gs.xmit_cnt == 0) {
 		ctrl &= ~SCI_CTRL_FLAGS_TIE;
@@ -499,10 +607,14 @@ static void sci_transmit_chars(struct sc
 		ctrl |= SCI_CTRL_FLAGS_TIE;
 	}
 	sci_out(port, SCSCR, ctrl);
-	restore_flags(flags);
+	local_irq_restore(flags);
 }
 
-static inline void sci_receive_chars(struct sci_port *port)
+/* On SH3, SCIF may read end-of-break as a space->mark char */
+#define STEPFN(c)  ({int __c=(c); (((__c-1)|(__c)) == -1); })
+
+static inline void sci_receive_chars(struct sci_port *port,
+				     struct pt_regs *regs)
 {
 	int i, count;
 	struct tty_struct *tty;
@@ -525,7 +637,7 @@ static inline void sci_receive_chars(str
 		if (tty->flip.count + count > TTY_FLIPBUF_SIZE)
 			count = TTY_FLIPBUF_SIZE - tty->flip.count;
 
-		/* If for one reason or another, we can't copy more data, we're done! */
+		/* If for any reason we can't copy more data, we're done! */
 		if (count == 0)
 			break;
 
@@ -534,8 +646,42 @@ static inline void sci_receive_chars(str
 			tty->flip.flag_buf_ptr[0] = TTY_NORMAL;
 		} else {
 			for (i=0; i<count; i++) {
-				tty->flip.char_buf_ptr[i] = sci_in(port, SCxRDR);
+				char c = sci_in(port, SCxRDR);
 				status = sci_in(port, SCxSR);
+#if defined(__SH3__)
+				/* Skip "chars" during break */
+				if (port->break_flag) {
+					if ((c == 0) &&
+					    (status & SCxSR_FER(port))) {
+						count--; i--;
+						continue;
+					}
+					/* Nonzero => end-of-break */
+					dprintk("scif: debounce<%02x>\n", c);
+					port->break_flag = 0;
+					if (STEPFN(c)) {
+						count--; i--;
+						continue;
+					}
+				}
+#endif /* __SH3__ */
+#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+				if (break_pressed && (port == sercons_port)) {
+					if (c != 0 &&
+					    time_before(jiffies,
+							break_pressed + HZ*5)) {
+						handle_sysrq(c, regs, NULL);
+						break_pressed = 0;
+						count--; i--;
+						continue;
+					} else if (c != 0) {
+						break_pressed = 0;
+					}
+				}
+#endif /* CONFIG_SERIAL_CONSOLE && CONFIG_MAGIC_SYSRQ */
+
+				/* Store data and status */
+				tty->flip.char_buf_ptr[i] = c;
 				if (status&SCxSR_FER(port)) {
 					tty->flip.flag_buf_ptr[i] = TTY_FRAME;
 					dprintk("sci: frame error\n");
@@ -563,6 +709,10 @@ static inline void sci_receive_chars(str
 	if (copied)
 		/* Tell the rest of the system the news. New characters! */
 		tty_flip_buffer_push(tty);
+	else {
+		sci_in(port, SCxSR); /* dummy read */
+		sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
+	}
 }
 
 static inline int sci_handle_errors(struct sci_port *port)
@@ -615,13 +765,32 @@ static inline int sci_handle_breaks(stru
 	struct tty_struct *tty = port->gs.tty;
 
 	if (status&SCxSR_BRK(port) && tty->flip.count<TTY_FLIPBUF_SIZE) {
+#if defined(__SH3__)
+		/* Debounce break */
+		if (port->break_flag)
+			goto break_continue;
+		port->break_flag = 1;
+#endif
+#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+		if (port == sercons_port) {
+			if (break_pressed == 0) {
+				break_pressed = jiffies;
+				dprintk("sci: implied sysrq\n");
+				goto break_continue;
+			}
+			/* Double break implies a real break */
+			break_pressed = 0;
+		}
+#endif
 		/* Notify of BREAK */
 		copied++;
 		*tty->flip.flag_buf_ptr++ = TTY_BREAK;
 		dprintk("sci: BREAK detected\n");
 	}
+ break_continue:
 
-#if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_ST40STB1)
+#if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_ST40STB1) || \
+    defined(CONFIG_CPU_SUBTYPE_SH7760)
 	/* XXX: Handle SCIF overrun error */
 	if (port->type == PORT_SCIF && (sci_in(port, SCLSR) & SCIF_ORER) != 0) {
 		sci_out(port, SCLSR, 0);
@@ -641,19 +810,22 @@ static inline int sci_handle_breaks(stru
 	return copied;
 }
 
-static void sci_rx_interrupt(int irq, void *ptr, struct pt_regs *regs)
+static irqreturn_t sci_rx_interrupt(int irq, void *ptr, struct pt_regs *regs)
 {
 	struct sci_port *port = ptr;
 
 	if (port->gs.flags & GS_ACTIVE)
 		if (!(port->gs.flags & SCI_RX_THROTTLE)) {
-			sci_receive_chars(port);
-			return;
+			sci_receive_chars(port, regs);
+			return IRQ_HANDLED;
+
 		}
 	sci_disable_rx_interrupts(port);
+
+	return IRQ_HANDLED;
 }
 
-static void sci_tx_interrupt(int irq, void *ptr, struct pt_regs *regs)
+static irqreturn_t sci_tx_interrupt(int irq, void *ptr, struct pt_regs *regs)
 {
 	struct sci_port *port = ptr;
 
@@ -662,9 +834,11 @@ static void sci_tx_interrupt(int irq, vo
 	else {
 		sci_disable_tx_interrupts(port);
 	}
+
+	return IRQ_HANDLED;
 }
 
-static void sci_er_interrupt(int irq, void *ptr, struct pt_regs *regs)
+static irqreturn_t sci_er_interrupt(int irq, void *ptr, struct pt_regs *regs)
 {
 	struct sci_port *port = ptr;
 
@@ -683,15 +857,19 @@ static void sci_er_interrupt(int irq, vo
 
 	/* Kick the transmission */
 	sci_tx_interrupt(irq, ptr, regs);
+
+	return IRQ_HANDLED;
 }
 
-static void sci_br_interrupt(int irq, void *ptr, struct pt_regs *regs)
+static irqreturn_t sci_br_interrupt(int irq, void *ptr, struct pt_regs *regs)
 {
 	struct sci_port *port = ptr;
 
 	/* Handle BREAKs */
 	sci_handle_breaks(port);
 	sci_out(port, SCxSR, SCxSR_BREAK_CLEAR(port));
+
+	return IRQ_HANDLED;
 }
 
 static void do_softint(void *private_)
@@ -723,11 +901,11 @@ static void sci_disable_tx_interrupts(vo
 	unsigned short ctrl;
 
 	/* Clear TIE (Transmit Interrupt Enable) bit in SCSCR */
-	save_and_cli(flags);
+	local_irq_save(flags);
 	ctrl = sci_in(port, SCSCR);
 	ctrl &= ~SCI_CTRL_FLAGS_TIE;
 	sci_out(port, SCSCR, ctrl);
-	restore_flags(flags);
+	local_irq_restore(flags);
 }
 
 static void sci_enable_tx_interrupts(void *ptr)
@@ -746,11 +924,11 @@ static void sci_disable_rx_interrupts(vo
 	unsigned short ctrl;
 
 	/* Clear RIE (Receive Interrupt Enable) bit in SCSCR */
-	save_and_cli(flags);
+	local_irq_save(flags);
 	ctrl = sci_in(port, SCSCR);
 	ctrl &= ~SCI_CTRL_FLAGS_RIE;
 	sci_out(port, SCSCR, ctrl);
-	restore_flags(flags);
+	local_irq_restore(flags);
 }
 
 static void sci_enable_rx_interrupts(void * ptr)
@@ -760,11 +938,11 @@ static void sci_enable_rx_interrupts(voi
 	unsigned short ctrl;
 
 	/* Set RIE (Receive Interrupt Enable) bit in SCSCR */
-	save_and_cli(flags);
+	local_irq_save(flags);
 	ctrl = sci_in(port, SCSCR);
 	ctrl |= SCI_CTRL_FLAGS_RIE;
 	sci_out(port, SCSCR, ctrl);
-	restore_flags(flags);
+	local_irq_restore(flags);
 }
 
 static int sci_get_CD(void * ptr)
@@ -848,6 +1026,15 @@ static int sci_open(struct tty_struct * 
 	}
 #endif
 
+#ifdef CONFIG_SH_KGDB_CONSOLE
+        if (kgdbcons.cflag && kgdbcons.index == line) {
+                tty->termios->c_cflag = kgdbcons.cflag;
+                port->gs.baud = kgdb_baud;
+                sercons.cflag = 0;
+                sci_set_real_termios(port);
+        }
+#endif
+
 	sci_enable_rx_interrupts(port);
 
 	return 0;
@@ -859,6 +1046,16 @@ failed_1:
 	return retval;
 }
 
+static void sci_hungup(void *ptr)
+{
+        return;
+}
+
+static void sci_close(void *ptr)
+{
+        return;
+}
+
 static int sci_ioctl(struct tty_struct * tty, struct file * filp, 
                      unsigned int cmd, unsigned long arg)
 {
@@ -870,41 +1067,41 @@ static int sci_ioctl(struct tty_struct *
 	switch (cmd) {
 	case TIOCGSOFTCAR:
 		rc = put_user(((tty->termios->c_cflag & CLOCAL) ? 1 : 0),
-		              (unsigned int *) arg);
+		              (unsigned int __user *) arg);
 		break;
 	case TIOCSSOFTCAR:
-		if ((rc = get_user(ival, (unsigned int *) arg)) == 0)
+		if ((rc = get_user(ival, (unsigned int __user *) arg)) == 0)
 			tty->termios->c_cflag =
 				(tty->termios->c_cflag & ~CLOCAL) |
 				(ival ? CLOCAL : 0);
 		break;
 	case TIOCGSERIAL:
-		if ((rc = verify_area(VERIFY_WRITE, (void *) arg,
+		if ((rc = verify_area(VERIFY_WRITE, (void __user *) arg,
 		                      sizeof(struct serial_struct))) == 0)
 			rc = gs_getserial(&port->gs, (struct serial_struct *) arg);
 		break;
 	case TIOCSSERIAL:
-		if ((rc = verify_area(VERIFY_READ, (void *) arg,
+		if ((rc = verify_area(VERIFY_READ, (void __user *) arg,
 		                      sizeof(struct serial_struct))) == 0)
 			rc = gs_setserial(&port->gs,
 					  (struct serial_struct *) arg);
 		break;
 	case TIOCMGET:
 		ival = sci_getsignals(port);
-		rc = put_user(ival, (unsigned int *) arg);
+		rc = put_user(ival, (unsigned int __user *) arg);
 		break;
 	case TIOCMBIS:
-		if ((rc = get_user(ival, (unsigned int *) arg)) == 0)
+		if ((rc = get_user(ival, (unsigned int __user *) arg)) == 0)
 			sci_setsignals(port, ((ival & TIOCM_DTR) ? 1 : -1),
 			                     ((ival & TIOCM_RTS) ? 1 : -1));
 		break;
 	case TIOCMBIC:
-		if ((rc = get_user(ival, (unsigned int *) arg)) == 0)
+		if ((rc = get_user(ival, (unsigned int __user *) arg)) == 0)
 			sci_setsignals(port, ((ival & TIOCM_DTR) ? 0 : -1),
 			                     ((ival & TIOCM_RTS) ? 0 : -1));
 		break;
 	case TIOCMSET:
-		if ((rc = get_user(ival, (unsigned int *)arg)) == 0)
+		if ((rc = get_user(ival, (unsigned int __user *)arg)) == 0)
 			sci_setsignals(port, ((ival & TIOCM_DTR) ? 1 : 0),
 			                     ((ival & TIOCM_RTS) ? 1 : 0));
 		break;
@@ -937,6 +1134,7 @@ static void sci_unthrottle(struct tty_st
 	 * was throttled
 	 */
 	port->gs.flags &= ~SCI_RX_THROTTLE;
+	sci_enable_rx_interrupts(port);
 	return;
 }
 
@@ -972,6 +1170,36 @@ static int sci_read_proc(char *page, cha
 }
 #endif
 
+#ifdef CONFIG_CPU_FREQ
+/*
+ * Here we define a transistion notifier so that we can update all of our
+ * ports' baud rate when the peripheral clock changes.
+ */
+
+static int sci_notifier(struct notifier_block *self, unsigned long phase, void *p)
+{
+	struct cpufreq_freqs *freqs = p;
+	int i;
+
+	if (phase == CPUFREQ_POSTCHANGE) {
+		for (i = 0; i < SCI_NPORTS; i++) {
+			/*
+			 * This will force a baud rate change in hardware.
+			 */
+			if (sci_ports[i].gs.tty != NULL) {
+				sci_set_baud(&sci_ports[i], sci_ports[i].gs.baud);
+			}
+		}
+		printk("%s: got a postchange notification for cpu %d (old %d, new %d)\n",
+				__FUNCTION__, freqs->cpu, freqs->old, freqs->new);
+	}
+
+	return NOTIFY_OK;
+}
+
+static struct notifier_block sci_nb = { &sci_notifier, NULL, 0 };
+#endif /* CONFIG_CPU_FREQ */
+
 static struct tty_operations sci_ops = {
 	.open	= sci_open,
 	.close = gs_close,
@@ -1040,13 +1268,21 @@ static int sci_init_drivers(void)
 		port->icount.overrun = port->icount.brk = 0;
 	}
 
+#ifdef CONFIG_CPU_FREQ
+	/* Setup transition notifier */
+	if (cpufreq_register_notifier(&sci_nb, CPUFREQ_TRANSITION_NOTIFIER) < 0) {
+		printk(KERN_ERR "sci: Unable to register CPU frequency notifier\n");
+		return 1;
+	}
+	printk("sci: CPU frequency notifier registered\n");
+#endif
 	return 0;
 }
 
 static int sci_request_irq(struct sci_port *port)
 {
 	int i;
-	void (*handlers[4])(int irq, void *ptr, struct pt_regs *regs) = {
+	irqreturn_t (*handlers[4])(int irq, void *p, struct pt_regs *regs) = {
 		sci_er_interrupt, sci_rx_interrupt, sci_tx_interrupt,
 		sci_br_interrupt,
 	};
@@ -1233,3 +1469,110 @@ static int __init sci_console_init(void)
 console_initcall(sci_console_init);
 
 #endif /* CONFIG_SERIAL_CONSOLE */
+
+
+#ifdef CONFIG_SH_KGDB
+
+/* Initialise the KGDB serial port */
+int kgdb_sci_setup(void)
+{
+	int cflag = CREAD | HUPCL | CLOCAL;
+
+	if ((kgdb_portnum < 0) || (kgdb_portnum >= SCI_NPORTS))
+		return -1;
+
+        kgdb_sci_port = &sci_ports[kgdb_portnum];
+
+	switch (kgdb_baud) {
+        case 115200:
+                cflag |= B115200;
+                break;
+	case 57600:
+                cflag |= B57600;
+                break;
+        case 38400:
+                cflag |= B38400;
+                break;
+        case 19200:
+                cflag |= B19200;
+                break;
+        case 9600:
+        default:
+                cflag |= B9600;
+                kgdb_baud = 9600;
+                break;
+        }
+
+	switch (kgdb_bits) {
+        case '7':
+                cflag |= CS7;
+                break;
+        default:
+        case '8':
+                cflag |= CS8;
+                break;
+        }
+
+        switch (kgdb_parity) {
+        case 'O':
+                cflag |= PARODD;
+                break;
+        case 'E':
+                cflag |= PARENB;
+                break;
+        }
+
+        kgdb_cflag = cflag;
+        sci_set_termios_cflag(kgdb_sci_port, kgdb_cflag, kgdb_baud);
+
+        /* Set up the interrupt for BREAK from GDB */
+	/* Commented out for now since it may not be possible yet...
+	   request_irq(kgdb_sci_port->irqs[0], kgdb_break_interrupt,
+	               SA_INTERRUPT, "sci", kgdb_sci_port);
+	   sci_enable_rx_interrupts(kgdb_sci_port);
+	*/
+
+	/* Setup complete: initialize function pointers */
+	kgdb_getchar = kgdb_sci_getchar;
+	kgdb_putchar = kgdb_sci_putchar;
+
+        return 0;
+}
+
+#ifdef CONFIG_SH_KGDB_CONSOLE
+
+/* Create a console device */
+static kdev_t kgdb_console_device(struct console *c)
+{
+        return MKDEV(SCI_MAJOR, SCI_MINOR_START + c->index);
+}
+
+/* Set up the KGDB console */
+static int __init kgdb_console_setup(struct console *co, char *options)
+{
+        /* NB we ignore 'options' because we've already done the setup */
+        co->cflag = kgdb_cflag;
+
+        return 0;
+}
+
+/* Register the KGDB console so we get messages (d'oh!) */
+void __init kgdb_console_init(void)
+{
+        register_console(&kgdbcons);
+}
+
+/* The console structure for KGDB */
+static struct console kgdbcons = {
+        name:"ttySC",
+        write:kgdb_console_write,
+        device:kgdb_console_device,
+        wait_key:serial_console_wait_key,
+        setup:kgdb_console_setup,
+        flags:CON_PRINTBUFFER | CON_ENABLED,
+        index:-1,
+};
+
+#endif /* CONFIG_SH_KGDB_CONSOLE */
+
+#endif /* CONFIG_SH_KGDB */
diff -puN drivers/char/sh-sci.h~linus drivers/char/sh-sci.h
--- 25/drivers/char/sh-sci.h~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/sh-sci.h	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: sh-sci.h,v 1.8 2000/03/08 15:19:39 gniibe Exp $
+/* $Id: sh-sci.h,v 1.6 2003/10/13 01:11:11 lethal Exp $
  *
  *  linux/drivers/char/sh-sci.h
  *
@@ -6,6 +6,7 @@
  *  Copyright (C) 1999, 2000  Niibe Yutaka
  *  Copyright (C) 2000  Greg Banks
  *  Modified to support multiple serial ports. Stuart Menefy (May 2000).
+ *  Modified to support SH7760 SCIF. Paul Mundt (Oct 2003).
  *
  */
 #include <linux/config.h>
@@ -26,6 +27,9 @@
 #define SH3_IRDA_IRQS { 52,  53,  55,  54 }
 #define SH4_SCIF_IRQS { 40,  41,  43,  42 }
 #define STB1_SCIF1_IRQS {23, 24,  26,  25 }
+#define SH7760_SCIF0_IRQS { 52, 53, 55, 54 }
+#define SH7760_SCIF1_IRQS { 72, 73, 75, 74 }
+#define SH7760_SCIF2_IRQS { 76, 77, 79, 78 }
 
 #if defined(CONFIG_CPU_SUBTYPE_SH7708)
 # define SCI_NPORTS 1
@@ -59,6 +63,19 @@
 	0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ : \
 	0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ )
 # define SCI_AND_SCIF
+#elif defined(CONFIG_CPU_SUBTYPE_SH7760)
+# define SCI_NPORTS 3
+# define SCI_INIT { \
+  { {}, PORT_SCIF, 0xfe600000, SH7760_SCIF0_IRQS, sci_init_pins_scif }, \
+  { {}, PORT_SCIF, 0xfe610000, SH7760_SCIF1_IRQS, sci_init_pins_scif }, \
+  { {}, PORT_SCIF, 0xfe620000, SH7760_SCIF2_IRQS, sci_init_pins_scif }  \
+}
+# define SCSPTR0 0xfe600024 /* 16 bit SCIF */
+# define SCSPTR1 0xfe610024 /* 16 bit SCIF */
+# define SCSPTR2 0xfe620024 /* 16 bit SCIF */
+# define SCIF_ORDER 0x0001  /* overrun error bit */
+# define SCSCR_INIT(port)          0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
+# define SCIF_ONLY
 #elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
 # define SCI_NPORTS 2
 # define SCI_INIT { \
@@ -161,29 +178,6 @@
 /* Generic serial flags */
 #define SCI_RX_THROTTLE		0x0000001
 
-/* generic serial tty */
-#define O_OTHER(tty)    \
-      ((O_OLCUC(tty))  ||\
-      (O_ONLCR(tty))   ||\
-      (O_OCRNL(tty))   ||\
-      (O_ONOCR(tty))   ||\
-      (O_ONLRET(tty))  ||\
-      (O_OFILL(tty))   ||\
-      (O_OFDEL(tty))   ||\
-      (O_NLDLY(tty))   ||\
-      (O_CRDLY(tty))   ||\
-      (O_TABDLY(tty))  ||\
-      (O_BSDLY(tty))   ||\
-      (O_VTDLY(tty))   ||\
-      (O_FFDLY(tty)))
-
-#define I_OTHER(tty)    \
-      ((I_INLCR(tty))  ||\
-      (I_IGNCR(tty))   ||\
-      (I_ICRNL(tty))   ||\
-      (I_IUCLC(tty))   ||\
-      (L_ISIG(tty)))
-
 #define SCI_MAGIC 0xbabeface
 
 /*
@@ -202,6 +196,7 @@ struct sci_port {
 	struct async_icount icount;
 	struct work_struct tqueue;
 	unsigned long event;
+	int break_flag;
 };
 
 #define SCI_IN(size, offset)					\
@@ -247,7 +242,7 @@ struct sci_port {
     SCI_OUT(scif_size, scif_offset, value);				\
   }
 
-#ifdef __sh3__
+#ifdef CONFIG_CPU_SH3
 #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
 		 sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
   CPU_SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh3_scif_offset, sh3_scif_size)
@@ -307,6 +302,16 @@ static inline int sci_rxd_in(struct sci_
 #endif
 	return 1;
 }
+#elif defined(CONFIG_CPU_SUBTYPE_SH7760)
+static inline int sci_rxd_in(struct sci_port *port)
+{
+	if (port->base == 0xfe600000)
+		return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
+	if (port->base == 0xfe610000)
+		return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
+	if (port->base == 0xfe620000)
+		return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
+}
 #elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
 static inline int sci_rxd_in(struct sci_port *port)
 {
@@ -360,4 +365,5 @@ static inline int sci_rxd_in(struct sci_
 #define BPS_38400      SCBRR_VALUE(38400)
 #define BPS_57600      SCBRR_VALUE(57600)
 #define BPS_115200     SCBRR_VALUE(115200)
+#define BPS_230400     SCBRR_VALUE(230400)
 
diff -puN drivers/char/sn_serial.c~linus drivers/char/sn_serial.c
--- 25/drivers/char/sn_serial.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/sn_serial.c	2004-01-19 22:17:21.000000000 -0800
@@ -21,8 +21,9 @@
 #include <linux/sysrq.h>
 #include <linux/circ_buf.h>
 #include <linux/serial_reg.h>
+#include <asm/uaccess.h>
 #include <asm/sn/sn_sal.h>
-#include <asm/sn/pci/pciio.h>		/* this is needed for get_console_nasid */
+#include <asm/sn/pci/pciio.h>
 #include <asm/sn/simulator.h>
 #include <asm/sn/sn2/sn_private.h>
 
@@ -771,7 +772,7 @@ sn_sal_read_proc(char *page, char **star
 	off_t	begin = 0;
 
 	len += sprintf(page, "sn_serial: nasid:%d irq:%d tx:%d rx:%d\n",
-		       get_console_nasid(), sn_sal_irq,
+		       ia64_sn_get_console_nasid(), sn_sal_irq,
 		       sn_total_tx_count, sn_total_rx_count);
 	*eof = 1;
 
@@ -813,13 +814,18 @@ sn_sal_switch_to_asynch(void)
 {
 	unsigned long flags;
 
-	sn_debug_printf("sn_serial: about to switch to asynchronous console\n");
-
 	/* without early_printk, we may be invoked late enough to race
 	 * with other cpus doing console IO at this point, however
 	 * console interrupts will never be enabled */
 	spin_lock_irqsave(&sn_sal_lock, flags);
 
+	if (sn_sal_is_asynch) {
+		spin_unlock_irqrestore(&sn_sal_lock, flags);
+		return;
+	}
+
+	sn_debug_printf("sn_serial: switch to asynchronous console\n");
+
 	/* early_printk invocation may have done this for us */
 	if (!sn_func) {
 		if (IS_RUNNING_ON_SIMULATOR())
@@ -901,8 +907,7 @@ sn_sal_module_init(void)
 	/* when this driver is compiled in, the console initialization
 	 * will have already switched us into asynchronous operation
 	 * before we get here through the module initcalls */
-	if (!sn_sal_is_asynch)
-		sn_sal_switch_to_asynch();
+	sn_sal_switch_to_asynch();
 
 	/* at this point (module_init) we can try to turn on interrupts */
 	if (!IS_RUNNING_ON_SIMULATOR())
diff -puN drivers/char/sysrq.c~linus drivers/char/sysrq.c
--- 25/drivers/char/sysrq.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/sysrq.c	2004-01-19 22:17:21.000000000 -0800
@@ -271,11 +271,11 @@ static struct sysrq_key_op *sysrq_key_ta
 };
 
 /* key2index calculation, -1 on invalid index */
-static __inline__ int sysrq_key_table_key2index(int key) {
+static int sysrq_key_table_key2index(int key) {
 	int retval;
-	if ((key >= '0') & (key <= '9')) {
+	if ((key >= '0') && (key <= '9')) {
 		retval = key - '0';
-	} else if ((key >= 'a') & (key <= 'z')) {
+	} else if ((key >= 'a') && (key <= 'z')) {
 		retval = key + 10 - 'a';
 	} else {
 		retval = -1;
diff -puN drivers/char/tty_io.c~linus drivers/char/tty_io.c
--- 25/drivers/char/tty_io.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/tty_io.c	2004-01-19 22:17:21.000000000 -0800
@@ -2069,79 +2069,7 @@ static void tty_default_put_char(struct 
 	tty->driver->write(tty, 0, &ch, 1);
 }
 
-struct tty_dev {
-	struct list_head node;
-	dev_t dev;
-	struct class_device class_dev;
-};
-#define to_tty_dev(d) container_of(d, struct tty_dev, class_dev)
-
-static void release_tty_dev(struct class_device *class_dev)
-{
-	struct tty_dev *tty_dev = to_tty_dev(class_dev);
-	kfree(tty_dev);
-}
-
-static struct class tty_class = {
-	.name		= "tty",
-	.release	= &release_tty_dev,
-};
-
-static LIST_HEAD(tty_dev_list);
-static spinlock_t tty_dev_list_lock = SPIN_LOCK_UNLOCKED;
-
-static ssize_t show_dev(struct class_device *class_dev, char *buf)
-{
-	struct tty_dev *tty_dev = to_tty_dev(class_dev);
-	return print_dev_t(buf, tty_dev->dev);
-}
-static CLASS_DEVICE_ATTR(dev, S_IRUGO, show_dev, NULL);
-
-static void tty_add_class_device(char *name, dev_t dev, struct device *device)
-{
-	struct tty_dev *tty_dev = NULL;
-	int retval;
-
-	tty_dev = kmalloc(sizeof(*tty_dev), GFP_KERNEL);
-	if (!tty_dev)
-		return;
-	memset(tty_dev, 0x00, sizeof(*tty_dev));
-
-	tty_dev->class_dev.dev = device;
-	tty_dev->class_dev.class = &tty_class;
-	snprintf(tty_dev->class_dev.class_id, BUS_ID_SIZE, "%s", name);
-	retval = class_device_register(&tty_dev->class_dev);
-	if (retval)
-		goto error;
-	class_device_create_file (&tty_dev->class_dev, &class_device_attr_dev);
-	tty_dev->dev = dev;
-	spin_lock(&tty_dev_list_lock);
-	list_add(&tty_dev->node, &tty_dev_list);
-	spin_unlock(&tty_dev_list_lock);
-	return;
-error:
-	kfree(tty_dev);
-}
-
-static void tty_remove_class_device(dev_t dev)
-{
-	struct tty_dev *tty_dev = NULL;
-	struct list_head *tmp;
-	int found = 0;
-
-	spin_lock(&tty_dev_list_lock);
-	list_for_each (tmp, &tty_dev_list) {
-		tty_dev = list_entry(tmp, struct tty_dev, node);
-		if (tty_dev->dev == dev) {
-			list_del(&tty_dev->node);
-			found = 1;
-			break;
-		}
-	}
-	spin_unlock(&tty_dev_list_lock);
-	if (found)
-		class_device_unregister(&tty_dev->class_dev);
-}
+static struct class_simple *tty_class;
 
 /**
  * tty_register_device - register a tty device
@@ -2174,7 +2102,7 @@ void tty_register_device(struct tty_driv
 	if (driver->type != TTY_DRIVER_TYPE_PTY) {
 		char name[64];
 		tty_line_name(driver, index, name);
-		tty_add_class_device(name, dev, device);
+		class_simple_device_add(tty_class, dev, device, name);
 	}
 }
 
@@ -2189,7 +2117,7 @@ void tty_register_device(struct tty_driv
 void tty_unregister_device(struct tty_driver *driver, unsigned index)
 {
 	devfs_remove("%s%d", driver->devfs_name, index + driver->name_base);
-	tty_remove_class_device(MKDEV(driver->major, driver->minor_start) + index);
+	class_simple_device_remove(MKDEV(driver->major, driver->minor_start) + index);
 }
 
 EXPORT_SYMBOL(tty_register_device);
@@ -2406,7 +2334,10 @@ extern int vty_init(void);
 
 static int __init tty_class_init(void)
 {
-	return class_register(&tty_class);
+	tty_class = class_simple_create(THIS_MODULE, "tty");
+	if (IS_ERR(tty_class))
+		return PTR_ERR(tty_class);
+	return 0;
 }
 
 postcore_initcall(tty_class_init);
@@ -2431,7 +2362,7 @@ static int __init tty_init(void)
 	    register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
 		panic("Couldn't register /dev/tty driver\n");
 	devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 0), S_IFCHR|S_IRUGO|S_IWUGO, "tty");
-	tty_add_class_device ("tty", MKDEV(TTYAUX_MAJOR, 0), NULL);
+	class_simple_device_add(tty_class, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty");
 
 	strcpy(console_cdev.kobj.name, "dev.console");
 	cdev_init(&console_cdev, &console_fops);
@@ -2439,7 +2370,7 @@ static int __init tty_init(void)
 	    register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
 		panic("Couldn't register /dev/console driver\n");
 	devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 1), S_IFCHR|S_IRUSR|S_IWUSR, "console");
-	tty_add_class_device ("console", MKDEV(TTYAUX_MAJOR, 1), NULL);
+	class_simple_device_add(tty_class, MKDEV(TTYAUX_MAJOR, 1), NULL, "console");
 
 	tty_kobj.kset = tty_cdev.kobj.kset;
 	kobject_register(&tty_kobj);
@@ -2451,7 +2382,7 @@ static int __init tty_init(void)
 	    register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
 		panic("Couldn't register /dev/ptmx driver\n");
 	devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 2), S_IFCHR|S_IRUGO|S_IWUGO, "ptmx");
-	tty_add_class_device ("ptmx", MKDEV(TTYAUX_MAJOR, 2), NULL);
+	class_simple_device_add(tty_class, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx");
 #endif
 	
 #ifdef CONFIG_VT
@@ -2461,7 +2392,7 @@ static int __init tty_init(void)
 	    register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
 		panic("Couldn't register /dev/tty0 driver\n");
 	devfs_mk_cdev(MKDEV(TTY_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vc/0");
-	tty_add_class_device ("tty0", MKDEV(TTY_MAJOR, 0), NULL);
+	class_simple_device_add(tty_class, MKDEV(TTY_MAJOR, 0), NULL, "tty0");
 
 	vty_init();
 #endif
diff -puN drivers/char/vt.c~linus drivers/char/vt.c
--- 25/drivers/char/vt.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/vt.c	2004-01-19 22:17:21.000000000 -0800
@@ -530,17 +530,22 @@ static void add_softcursor(int currcons)
 		sw->con_putc(vc_cons[currcons].d, i, y, x);
 }
 
-static void hide_cursor(int currcons)
+static void hide_softcursor(int currcons)
 {
-	if (currcons == sel_cons)
-		clear_selection();
 	if (softcursor_original != -1) {
 		scr_writew(softcursor_original,(u16 *) pos);
 		if (DO_UPDATE)
 			sw->con_putc(vc_cons[currcons].d, softcursor_original, y, x);
 		softcursor_original = -1;
 	}
+}
+
+static void hide_cursor(int currcons)
+{
+	if (currcons == sel_cons)
+		clear_selection();
 	sw->con_cursor(vc_cons[currcons].d,CM_ERASE);
+	hide_softcursor(currcons);
 }
 
 static void set_cursor(int currcons)
diff -puN drivers/char/watchdog/acquirewdt.c~linus drivers/char/watchdog/acquirewdt.c
--- 25/drivers/char/watchdog/acquirewdt.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/acquirewdt.c	2004-01-19 22:17:21.000000000 -0800
@@ -100,7 +100,7 @@ static ssize_t acq_write(struct file *fi
 			 * five months ago... */
 			expect_close = 0;
 
-			/* scan to see wether or not we got the magic character */
+			/* scan to see whether or not we got the magic character */
 			for (i = 0; i != count; i++) {
 				char c;
 				if (get_user(c, buf + i))
@@ -263,33 +263,33 @@ static int __init acq_init(void)
 		goto unreg_stop;
 	}
 
-        ret = register_reboot_notifier(&acq_notifier);
-        if (ret != 0) {
-                printk (KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
-                        ret);
-                goto unreg_regions;
-        }
-                                                                                                 
-        ret = misc_register(&acq_miscdev);
-        if (ret != 0) {
-                printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
-                        WATCHDOG_MINOR, ret);
-                goto unreg_reboot;
-        }
-                                                                                                 
-        printk (KERN_INFO PFX "initialized. (nowayout=%d)\n",
-                nowayout);
-                                                                                                 
+	ret = register_reboot_notifier(&acq_notifier);
+	if (ret != 0) {
+		printk (KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
+			ret);
+		goto unreg_regions;
+	}
+
+	ret = misc_register(&acq_miscdev);
+	if (ret != 0) {
+		printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
+			WATCHDOG_MINOR, ret);
+		goto unreg_reboot;
+	}
+
+	printk (KERN_INFO PFX "initialized. (nowayout=%d)\n",
+		nowayout);
+
 out:
-        return ret;
+	return ret;
 unreg_reboot:
-        unregister_reboot_notifier(&acq_notifier);
+	unregister_reboot_notifier(&acq_notifier);
 unreg_regions:
-        release_region(wdt_start, 1);
+	release_region(wdt_start, 1);
 unreg_stop:
-        if (wdt_stop != wdt_start)
-                release_region(wdt_stop, 1);
-        goto out;
+	if (wdt_stop != wdt_start)
+		release_region(wdt_stop, 1);
+	goto out;
 }
 
 static void __exit acq_exit(void)
diff -puN drivers/char/watchdog/advantechwdt.c~linus drivers/char/watchdog/advantechwdt.c
--- 25/drivers/char/watchdog/advantechwdt.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/advantechwdt.c	2004-01-19 22:17:21.000000000 -0800
@@ -183,7 +183,7 @@ advwdt_ioctl(struct inode *inode, struct
 	}
 
 	default:
-	  return -ENOTTY;
+	  return -ENOIOCTLCMD;
 	}
 	return 0;
 }
diff -puN drivers/char/watchdog/alim1535_wdt.c~linus drivers/char/watchdog/alim1535_wdt.c
--- 25/drivers/char/watchdog/alim1535_wdt.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/alim1535_wdt.c	2004-01-19 22:17:21.000000000 -0800
@@ -153,7 +153,7 @@ static ssize_t ali_write(struct file *fi
 			 * five months ago... */
 			ali_expect_release = 0;
 
-			/* scan to see wether or not we got the magic character */
+			/* scan to see whether or not we got the magic character */
 			for (i = 0; i != len; i++) {
 				char c;
 				if(get_user(c, data+i))
@@ -402,7 +402,7 @@ static int __init watchdog_init(void)
 
 	spin_lock_init(&ali_lock);
 
-	/* Check wether or not the hardware watchdog is there */
+	/* Check whether or not the hardware watchdog is there */
 	if (ali_find_watchdog() != 0) {
 		return -ENODEV;
 	}
diff -puN drivers/char/watchdog/alim7101_wdt.c~linus drivers/char/watchdog/alim7101_wdt.c
--- 25/drivers/char/watchdog/alim7101_wdt.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/alim7101_wdt.c	2004-01-19 22:17:21.000000000 -0800
@@ -374,7 +374,7 @@ static int __init alim7101_wdt_init(void
 err_out_miscdev:
 	misc_deregister(&wdt_miscdev);
 err_out:
-        return rc;
+	return rc;
 }
 
 module_init(alim7101_wdt_init);
diff -puN drivers/char/watchdog/amd7xx_tco.c~linus drivers/char/watchdog/amd7xx_tco.c
--- 25/drivers/char/watchdog/amd7xx_tco.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/amd7xx_tco.c	2004-01-19 22:17:21.000000000 -0800
@@ -19,6 +19,7 @@
 
 #include <linux/config.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
@@ -45,7 +46,7 @@
 #define TCO_TIMEOUT_MASK	0x3f
 #define TCO_STATUS1_REG 0x44
 #define TCO_STATUS2_REG	0x46
-#define NDTO_STS2	(1 << 1)	/* we're interested in the second timeout */ 
+#define NDTO_STS2	(1 << 1)	/* we're interested in the second timeout */
 #define BOOT_STS	(1 << 2)	/* will be set if NDTO_STS2 was set before reboot */
 #define TCO_CTRL1_REG	0x48
 #define TCO_HALT	(1 << 11)
@@ -57,11 +58,20 @@ static u32 pmbase;		/* PMxx I/O base */
 static struct pci_dev *dev;
 static struct semaphore open_sem;
 static spinlock_t amdtco_lock;	/* only for device access */
-static int expect_close = 0;
+static char expect_close;
 
-MODULE_PARM(timeout, "i");
+module_param(timeout, int, 0);
 MODULE_PARM_DESC(timeout, "range is 0-38 seconds, default is 38");
 
+#ifdef CONFIG_WATCHDOG_NOWAYOUT
+static int nowayout = 1;
+#else
+static int nowayout = 0;
+#endif
+
+module_param(nowayout, int, 0);
+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
+
 static inline u8 seconds_to_ticks(int seconds)
 {
 	/* the internal timer is stored as ticks which decrement
@@ -124,7 +134,7 @@ static inline void amdtco_global_enable(
 static inline void amdtco_enable(void)
 {
 	u16 reg;
-	
+
 	spin_lock(&amdtco_lock);
 	reg = inw(pmbase+TCO_CTRL1_REG);
 	reg &= ~TCO_HALT;
@@ -152,13 +162,13 @@ static int amdtco_fop_open(struct inode 
 		timeout = MAX_TIMEOUT;
 
 	amdtco_disable();
-	amdtco_settimeout(timeout);	
+	amdtco_settimeout(timeout);
 	amdtco_global_enable();
 	amdtco_enable();
 	amdtco_ping();
 	printk(KERN_INFO PFX "Watchdog enabled, timeout = %ds of %ds\n",
 		amdtco_gettimeout(), timeout);
-	
+
 	return 0;
 }
 
@@ -170,12 +180,12 @@ static int amdtco_fop_ioctl(struct inode
 
 	static struct watchdog_info ident = {
 		.options	= WDIOF_SETTIMEOUT | WDIOF_CARDRESET,
-		.identity	= "AMD 766/768"
+		.identity	= "AMD 766/768",
 	};
 
 	switch (cmd) {
 		default:
-			return -ENOTTY;	
+			return -ENOIOCTLCMD;
 
 		case WDIOC_GETSUPPORT:
 			if (copy_to_user((struct watchdog_info *)arg, &ident, sizeof ident))
@@ -184,7 +194,7 @@ static int amdtco_fop_ioctl(struct inode
 
 		case WDIOC_GETSTATUS:
 			return put_user(amdtco_status(), (int *)arg);
-	
+
 		case WDIOC_KEEPALIVE:
 			amdtco_ping();
 			return 0;
@@ -192,10 +202,10 @@ static int amdtco_fop_ioctl(struct inode
 		case WDIOC_SETTIMEOUT:
 			if (get_user(new_timeout, (int *)arg))
 				return -EFAULT;
-			
+
 			if (new_timeout < 0)
 				return -EINVAL;
-		
+
 			if (new_timeout > MAX_TIMEOUT)
 				new_timeout = MAX_TIMEOUT;
 
@@ -205,17 +215,17 @@ static int amdtco_fop_ioctl(struct inode
 
 		case WDIOC_GETTIMEOUT:
 			return put_user(amdtco_gettimeout(), (int *)arg);
-		
+
 		case WDIOC_SETOPTIONS:
 			if (copy_from_user(&tmp, (int *)arg, sizeof tmp))
-                                return -EFAULT;
+				return -EFAULT;
 
 			if (tmp & WDIOS_DISABLECARD)
 				amdtco_disable();
 
 			if (tmp & WDIOS_ENABLECARD)
 				amdtco_enable();
-			
+
 			return 0;
 	}
 }
@@ -223,14 +233,15 @@ static int amdtco_fop_ioctl(struct inode
 
 static int amdtco_fop_release(struct inode *inode, struct file *file)
 {
-	if (expect_close) {
-		amdtco_disable();	
+	if (expect_close == 42) {
+		amdtco_disable();
 		printk(KERN_INFO PFX "Watchdog disabled\n");
 	} else {
 		amdtco_ping();
 		printk(KERN_CRIT PFX "Unexpected close!, timeout in %d seconds\n", timeout);
-	}	
-	
+	}
+
+	expect_close = 0;
 	up(&open_sem);
 	return 0;
 }
@@ -240,21 +251,21 @@ static ssize_t amdtco_fop_write(struct f
 {
 	if (ppos != &file->f_pos)
 		return -ESPIPE;
-	
-	if (len) {
-#ifndef CONFIG_WATCHDOG_NOWAYOUT
-		size_t i;
-		char c;
-		expect_close = 0;
-		
-		for (i = 0; i != len; i++) {
-			if (get_user(c, data + i))
-				return -EFAULT;
 
-			if (c == 'V')
-				expect_close = 1;
+	if (len) {
+		if (!nowayout) {
+			size_t i;
+			char c;
+			expect_close = 0;
+
+			for (i = 0; i != len; i++) {
+				if (get_user(c, data + i))
+					return -EFAULT;
+
+				if (c == 'V')
+					expect_close = 42;
+			}
 		}
-#endif
 		amdtco_ping();
 	}
 
@@ -273,7 +284,7 @@ static int amdtco_notify_sys(struct noti
 
 static struct notifier_block amdtco_notifier =
 {
-	.notifier_call = amdtco_notify_sys
+	.notifier_call = amdtco_notify_sys,
 };
 
 static struct file_operations amdtco_fops =
@@ -282,20 +293,20 @@ static struct file_operations amdtco_fop
 	.write		= amdtco_fop_write,
 	.ioctl		= amdtco_fop_ioctl,
 	.open		= amdtco_fop_open,
-	.release	= amdtco_fop_release
+	.release	= amdtco_fop_release,
 };
 
 static struct miscdevice amdtco_miscdev =
 {
 	.minor	= WATCHDOG_MINOR,
 	.name	= "watchdog",
-	.fops	= &amdtco_fops
+	.fops	= &amdtco_fops,
 };
 
 static struct pci_device_id amdtco_pci_tbl[] = {
 	/* AMD 766 PCI_IDs here */
 	{ PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_OPUS_7443, PCI_ANY_ID, PCI_ANY_ID, },
-	{ 0, }
+	{ 0, },
 };
 
 MODULE_DEVICE_TABLE (pci, amdtco_pci_tbl);
@@ -316,7 +327,7 @@ static int __init amdtco_init(void)
 	return -ENODEV;
 
 found_one:
-	
+
 	if ((ret = register_reboot_notifier(&amdtco_notifier))) {
 		printk(KERN_ERR PFX "Unable to register reboot notifier err = %d\n", ret);
 		goto out_clean;
diff -puN drivers/char/watchdog/cpu5wdt.c~linus drivers/char/watchdog/cpu5wdt.c
--- 25/drivers/char/watchdog/cpu5wdt.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/cpu5wdt.c	2004-01-19 22:17:21.000000000 -0800
@@ -105,8 +105,8 @@ static void cpu5wdt_start(void)
 {
 	if ( !cpu5wdt_device.queue ) {
 		cpu5wdt_device.queue = 1;
-		outb(0, port + CPU5WDT_TIME_A_REG);  
-		outb(0, port + CPU5WDT_TIME_B_REG);  
+		outb(0, port + CPU5WDT_TIME_A_REG);
+		outb(0, port + CPU5WDT_TIME_B_REG);
 		outb(1, port + CPU5WDT_MODE_REG);
 		outb(0, port + CPU5WDT_RESET_REG);
 		outb(0, port + CPU5WDT_ENABLE_REG);
@@ -134,23 +134,15 @@ static int cpu5wdt_stop(void)
 
 static int cpu5wdt_open(struct inode *inode, struct file *file)
 {
-	switch(iminor(inode)) {
-		case WATCHDOG_MINOR:
-			if ( test_and_set_bit(0, &cpu5wdt_device.inuse) )
-				return -EBUSY;
-			break;
-		default:
-			return -ENODEV;
-	}
+	if ( test_and_set_bit(0, &cpu5wdt_device.inuse) )
+		return -EBUSY;
 	return 0;
 
 }
 
 static int cpu5wdt_release(struct inode *inode, struct file *file)
 {
-	if(iminor(inode)==WATCHDOG_MINOR) {
-		clear_bit(0, &cpu5wdt_device.inuse);
-	}
+	clear_bit(0, &cpu5wdt_device.inuse);
 	return 0;
 }
 
@@ -160,15 +152,15 @@ static int cpu5wdt_ioctl(struct inode *i
 	static struct watchdog_info ident =
 	{
 		.options = WDIOF_CARDRESET,
-		.identity = "CPU5 WDT"
+		.identity = "CPU5 WDT",
 	};
-  
+
 	switch(cmd) {
 		case WDIOC_KEEPALIVE:
 			cpu5wdt_reset();
 			break;
-		case WDIOC_GETSTATUS:    
-			value = inb(port + CPU5WDT_STATUS_REG); 
+		case WDIOC_GETSTATUS:
+			value = inb(port + CPU5WDT_STATUS_REG);
 			value = (value >> 2) & 1;
 			if ( copy_to_user((int *)arg, (int *)&value, sizeof(int)) )
 				return -EFAULT;
@@ -191,7 +183,7 @@ static int cpu5wdt_ioctl(struct inode *i
 			}
 			break;
 		default:
-    			return -EINVAL;
+    			return -ENOIOCTLCMD;
 	}
 	return 0;
 }
@@ -200,7 +192,7 @@ static ssize_t cpu5wdt_write(struct file
 {
 	if ( !count )
 		return -EIO;
-	
+
 	cpu5wdt_reset();
 	return count;
 
@@ -217,7 +209,7 @@ static struct file_operations cpu5wdt_fo
 static struct miscdevice cpu5wdt_misc = {
 	.minor	= WATCHDOG_MINOR,
 	.name	= "watchdog",
-	.fops	= &cpu5wdt_fops
+	.fops	= &cpu5wdt_fops,
 };
 
 /* init/exit function */
@@ -242,7 +234,7 @@ static int __devinit cpu5wdt_init(void)
 	}
 
 	/* watchdog reboot? */
-	val = inb(port + CPU5WDT_STATUS_REG); 
+	val = inb(port + CPU5WDT_STATUS_REG);
 	val = (val >> 2) & 1;
 	if ( !val )
 		printk(KERN_INFO PFX "sorry, was my fault\n");
diff -puN drivers/char/watchdog/eurotechwdt.c~linus drivers/char/watchdog/eurotechwdt.c
--- 25/drivers/char/watchdog/eurotechwdt.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/eurotechwdt.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- *	Eurotech CPU-1220/1410 on board WDT driver for Linux 2.4.x
+ *	Eurotech CPU-1220/1410 on board WDT driver
  *
  *	(c) Copyright 2001 Ascensit <support@ascensit.com>
  *	(c) Copyright 2001 Rodolfo Giometti <giometti@ascensit.com>
@@ -64,11 +64,11 @@ static char eur_expect_close;
  * You must set these - there is no sane way to probe for this board.
  * You can use eurwdt=x,y to set these now.
  */
- 
+
 static int io = 0x3f0;
 static int irq = 10;
 static char *ev = "int";
- 
+
 #define WDT_TIMEOUT		60                /* 1 minute */
 
 #ifdef CONFIG_WATCHDOG_NOWAYOUT
@@ -81,7 +81,7 @@ MODULE_PARM(nowayout,"i");
 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
 
 /*
- * Some symbolic names 
+ * Some symbolic names
  */
 
 #define WDT_CTRL_REG		0x30
@@ -92,7 +92,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog can
 #define WDT_UNIT_SECS		0x80
 #define WDT_TIMEOUT_VAL		0xf2
 #define WDT_TIMER_CFG		0xf3
- 
+
 
 #ifndef MODULE
 
@@ -104,26 +104,26 @@ MODULE_PARM_DESC(nowayout, "Watchdog can
  * get the user to tell us the configuration. Sane people build it
  * modular but the others come here.
  */
- 
+
 static int __init eurwdt_setup(char *str)
 {
 	int ints[4];
- 
+
 str = get_options (str, ARRAY_SIZE(ints), ints);
- 
+
 	if (ints[0] > 0) {
 		io = ints[1];
 		if (ints[0] > 1)
 			irq = ints[2];
 	}
- 
+
 	return 1;
 }
- 
+
 __setup("eurwdt=", eurwdt_setup);
 
 #endif /* !MODULE */
- 
+
 MODULE_PARM(io, "i");
 MODULE_PARM_DESC(io, "Eurotech WDT io port (default=0x3f0)");
 MODULE_PARM(irq, "i");
@@ -162,7 +162,7 @@ static inline void eurwdt_disable_timer(
 {
 	eurwdt_set_timeout(0);
 }
- 
+
 static void eurwdt_activate_timer(void)
 {
 	eurwdt_disable_timer();
@@ -180,18 +180,18 @@ static void eurwdt_activate_timer(void)
 	eurwdt_write_reg(WDT_TIMER_CFG, irq<<4);
 
 	eurwdt_write_reg(WDT_UNIT_SEL, WDT_UNIT_SECS);	/* we use seconds */
-	eurwdt_set_timeout(0);	/* the default timeout */ 
+	eurwdt_set_timeout(0);	/* the default timeout */
 }
 
 
 /*
  * Kernel methods.
  */
- 
+
 static irqreturn_t eurwdt_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	printk(KERN_CRIT "timeout WDT timeout\n");
- 
+
 #ifdef ONLY_TESTING
 	printk(KERN_CRIT "Would Reboot.\n");
 #else
@@ -207,13 +207,13 @@ static irqreturn_t eurwdt_interrupt(int 
  *
  * Reload counter one with the watchdog timeout.
  */
- 
+
 static void eurwdt_ping(void)
 {
 	/* Write the watchdog default value */
 	eurwdt_set_timeout(eurwdt_timeout);
 }
- 
+
 /**
  * eurwdt_write:
  * @file: file handle to the watchdog
@@ -224,14 +224,14 @@ static void eurwdt_ping(void)
  * A write to a watchdog device is defined as a keepalive signal. Any
  * write of data will do, as we we don't define content meaning.
  */
- 
+
 static ssize_t eurwdt_write(struct file *file, const char *buf, size_t count,
 loff_t *ppos)
 {
 	/*  Can't seek (pwrite) on this device  */
 	if (ppos != &file->f_pos)
 	return -ESPIPE;
- 
+
 	if (count) 	{
 		if (!nowayout) {
 			size_t i;
@@ -262,7 +262,7 @@ loff_t *ppos)
  * The watchdog API defines a common set of functions for all watchdogs
  * according to their available features.
  */
- 
+
 static int eurwdt_ioctl(struct inode *inode, struct file *file,
 	unsigned int cmd, unsigned long arg)
 {
@@ -274,15 +274,15 @@ static int eurwdt_ioctl(struct inode *in
 
 	int time;
 	int options, retval = -EINVAL;
- 
+
 	switch(cmd) {
 	default:
-		return -ENOTTY;
+		return -ENOIOCTLCMD;
 
 	case WDIOC_GETSUPPORT:
 		return copy_to_user((struct watchdog_info *)arg, &ident,
 			sizeof(ident)) ? -EFAULT : 0;
- 
+
 	case WDIOC_GETSTATUS:
 	case WDIOC_GETBOOTSTATUS:
 		return put_user(0, (int *) arg);
@@ -299,8 +299,8 @@ static int eurwdt_ioctl(struct inode *in
 		if (time < 0 || time > 255)
 			return -EINVAL;
 
-		eurwdt_timeout = time; 
-		eurwdt_set_timeout(time); 
+		eurwdt_timeout = time;
+		eurwdt_set_timeout(time);
 		/* Fall */
 
 	case WDIOC_GETTIMEOUT:
@@ -330,7 +330,7 @@ static int eurwdt_ioctl(struct inode *in
  * The misc device has been opened. The watchdog device is single
  * open and on opening we load the counter.
  */
- 
+
 static int eurwdt_open(struct inode *inode, struct file *file)
 {
 	if (test_and_set_bit(0, &eurwdt_is_open))
@@ -340,7 +340,7 @@ static int eurwdt_open(struct inode *ino
 	eurwdt_activate_timer();
 	return 0;
 }
- 
+
 /**
  * eurwdt_release:
  * @inode: inode to board
@@ -352,7 +352,7 @@ static int eurwdt_open(struct inode *ino
  * reboots. In the former case we disable the counters, in the latter
  * case you have to open it again very soon.
  */
- 
+
 static int eurwdt_release(struct inode *inode, struct file *file)
 {
 	if (eur_expect_close == 42) {
@@ -360,12 +360,12 @@ static int eurwdt_release(struct inode *
 	} else {
 		printk(KERN_CRIT "eurwdt: Unexpected close, not stopping watchdog!\n");
 		eurwdt_ping();
-    }
+	}
 	clear_bit(0, &eurwdt_is_open);
 	eur_expect_close = 0;
 	return 0;
 }
- 
+
 /**
  * eurwdt_notify_sys:
  * @this: our notifier block
@@ -377,7 +377,7 @@ static int eurwdt_release(struct inode *
  * test or worse yet during the following fsck. This would suck, in fact
  * trust me - if it happens it does suck.
  */
- 
+
 static int eurwdt_notify_sys(struct notifier_block *this, unsigned long code,
 	void *unused)
 {
@@ -388,12 +388,12 @@ static int eurwdt_notify_sys(struct noti
 
 	return NOTIFY_DONE;
 }
- 
+
 /*
  * Kernel Interfaces
  */
- 
- 
+
+
 static struct file_operations eurwdt_fops = {
 	.owner	= THIS_MODULE,
 	.llseek	= no_llseek,
@@ -406,18 +406,18 @@ static struct file_operations eurwdt_fop
 static struct miscdevice eurwdt_miscdev = {
 	.minor	= WATCHDOG_MINOR,
 	.name	= "watchdog",
-	.fops	= &eurwdt_fops
+	.fops	= &eurwdt_fops,
 };
- 
+
 /*
  * The WDT card needs to learn about soft shutdowns in order to
  * turn the timebomb registers off.
  */
- 
+
 static struct notifier_block eurwdt_notifier = {
 	.notifier_call = eurwdt_notify_sys,
 };
- 
+
 /**
  * cleanup_module:
  *
@@ -427,7 +427,7 @@ static struct notifier_block eurwdt_noti
  * will not touch PC memory so all is fine. You just have to load a new
  * module in 60 seconds or reboot.
  */
- 
+
 static void __exit eurwdt_exit(void)
 {
 	eurwdt_lock_chip();
@@ -438,15 +438,15 @@ static void __exit eurwdt_exit(void)
 	release_region(io, 2);
 	free_irq(irq, NULL);
 }
- 
+
 /**
  * eurwdt_init:
  *
- * Set up the WDT watchdog board. After grabbing the resources 
+ * Set up the WDT watchdog board. After grabbing the resources
  * we require we need also to unlock the device.
  * The open() function will actually kick the board off.
  */
- 
+
 static int __init eurwdt_init(void)
 {
 	int ret;
@@ -477,15 +477,15 @@ static int __init eurwdt_init(void)
 	}
 
 	eurwdt_unlock_chip();
- 
+
 	ret = 0;
 	printk(KERN_INFO "Eurotech WDT driver 0.01 at %X (Interrupt %d)"
-		" - timeout event: %s\n", 
+		" - timeout event: %s\n",
 		io, irq, (!strcmp("int", ev) ? "int" : "reboot"));
 
 out:
 	return ret;
- 
+
 outreg:
 	release_region(io, 2);
 
@@ -496,10 +496,10 @@ outmisc:
 	misc_deregister(&eurwdt_miscdev);
 	goto out;
 }
- 
+
 module_init(eurwdt_init);
 module_exit(eurwdt_exit);
- 
+
 MODULE_AUTHOR("Rodolfo Giometti");
 MODULE_DESCRIPTION("Driver for Eurotech CPU-1220/1410 on board watchdog");
 MODULE_LICENSE("GPL");
diff -puN drivers/char/watchdog/i810-tco.c~linus drivers/char/watchdog/i810-tco.c
--- 25/drivers/char/watchdog/i810-tco.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/i810-tco.c	2004-01-19 22:17:21.000000000 -0800
@@ -8,7 +8,7 @@
  *	modify it under the terms of the GNU General Public License
  *	as published by the Free Software Foundation; either version
  *	2 of the License, or (at your option) any later version.
- *	
+ *
  *	Neither kernel concepts nor Nils Faerber admit liability nor provide
  *	warranty for any of this software. This material is provided
  *	"AS-IS" and at no charge.
@@ -112,7 +112,7 @@ static int tco_timer_start (void)
 	outb (val, TCO1_CNT + 1);
 	val = inb (TCO1_CNT + 1);
 	spin_unlock(&tco_lock);
-	
+
 	if (val & 0x08)
 		return -1;
 	return 0;
@@ -131,7 +131,7 @@ static int tco_timer_stop (void)
 	outb (val, TCO1_CNT + 1);
 	val = inb (TCO1_CNT + 1);
 	spin_unlock(&tco_lock);
-	
+
 	if ((val & 0x08) == 0)
 		return -1;
 	return 0;
@@ -148,7 +148,7 @@ static int tco_timer_settimer (unsigned 
 	/* "Values of 0h-3h are ignored and should not be attempted" */
 	if (tmrval > 0x3f || tmrval < 0x04)
 		return -1;
-	
+
 	spin_lock(&tco_lock);
 	val = inb (TCO1_TMR);
 	val &= 0xc0;
@@ -156,7 +156,7 @@ static int tco_timer_settimer (unsigned 
 	outb (val, TCO1_TMR);
 	val = inb (TCO1_TMR);
 	spin_unlock(&tco_lock);
-	
+
 	if ((val & 0x3f) != tmrval)
 		return -1;
 
@@ -197,7 +197,7 @@ static int i810tco_release (struct inode
 	/*
 	 *      Shut off the timer.
 	 */
-	if (tco_expect_close == 42 && !nowayout) {
+	if (tco_expect_close == 42) {
 		tco_timer_stop ();
 	} else {
 		tco_timer_reload ();
@@ -217,17 +217,21 @@ static ssize_t i810tco_write (struct fil
 
 	/* See if we got the magic character 'V' and reload the timer */
 	if (len) {
-		size_t i;
-
-		tco_expect_close = 0;
+		if (!nowayout) {
+			size_t i;
 
-		/* scan to see whether or not we got the magic character */
-		for (i = 0; i != len; i++) {
-			u8 c;
-			if(get_user(c, data+i))
-				return -EFAULT;
-			if (c == 'V')
-				tco_expect_close = 42;
+			/* note: just in case someone wrote the magic character
+			 * five months ago... */
+			tco_expect_close = 0;
+
+			/* scan to see whether or not we got the magic character */
+			for (i = 0; i != len; i++) {
+				u8 c;
+				if(get_user(c, data+i))
+					return -EFAULT;
+				if (c == 'V')
+					tco_expect_close = 42;
+			}
 		}
 
 		/* someone wrote to us, we should reload the timer */
@@ -251,7 +255,7 @@ static int i810tco_ioctl (struct inode *
 	};
 	switch (cmd) {
 		default:
-			return -ENOTTY;
+			return -ENOIOCTLCMD;
 		case WDIOC_GETSUPPORT:
 			if (copy_to_user
 			    ((struct watchdog_info *) arg, &ident, sizeof (ident)))
diff -puN drivers/char/watchdog/ib700wdt.c~linus drivers/char/watchdog/ib700wdt.c
--- 25/drivers/char/watchdog/ib700wdt.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/ib700wdt.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- *	IB700 Single Board Computer WDT driver for Linux 2.4.x
+ *	IB700 Single Board Computer WDT driver
  *
  *	(c) Copyright 2001 Charles Howes <chowes@vsol.net>
  *
@@ -28,7 +28,7 @@
  *      14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com>
  *           Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT
  *           Added timeout module option to override default
- * 
+ *
  */
 
 #include <linux/config.h>
@@ -48,9 +48,9 @@
 #include <asm/uaccess.h>
 #include <asm/system.h>
 
-static int ibwdt_is_open;
+static unsigned long ibwdt_is_open;
 static spinlock_t ibwdt_lock;
-static int expect_close = 0;
+static char expect_close;
 
 #define PFX "ib700wdt: "
 
@@ -157,7 +157,7 @@ ibwdt_write(struct file *file, const cha
 				if (get_user(c, buf + i))
 					return -EFAULT;
 				if (c == 'V')
-					expect_close = 1;
+					expect_close = 42;
 			}
 		}
 		ibwdt_ping();
@@ -174,7 +174,7 @@ ibwdt_ioctl(struct inode *inode, struct 
 	static struct watchdog_info ident = {
 		.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE,
 		.firmware_version = 1,
-		.identity = "IB700 WDT"
+		.identity = "IB700 WDT",
 	};
 
 	switch (cmd) {
@@ -184,9 +184,7 @@ ibwdt_ioctl(struct inode *inode, struct 
 	  break;
 
 	case WDIOC_GETSTATUS:
-	  if (copy_to_user((int *)arg, &ibwdt_is_open,  sizeof(int)))
-	    return -EFAULT;
-	  break;
+	  return put_user(0, (int *) arg);
 
 	case WDIOC_KEEPALIVE:
 	  ibwdt_ping();
@@ -209,7 +207,7 @@ ibwdt_ioctl(struct inode *inode, struct 
 	  break;
 
 	default:
-	  return -ENOTTY;
+	  return -ENOIOCTLCMD;
 	}
 	return 0;
 }
@@ -217,38 +215,32 @@ ibwdt_ioctl(struct inode *inode, struct 
 static int
 ibwdt_open(struct inode *inode, struct file *file)
 {
-	if (iminor(inode) == WATCHDOG_MINOR) {
-		spin_lock(&ibwdt_lock);
-		if (ibwdt_is_open) {
-			spin_unlock(&ibwdt_lock);
-			return -EBUSY;
-		}
-		if (nowayout)
-			__module_get(THIS_MODULE);
-
-		/* Activate */
-		ibwdt_is_open = 1;
-		ibwdt_ping();
+	spin_lock(&ibwdt_lock);
+	if (test_and_set_bit(0, &ibwdt_is_open)) {
 		spin_unlock(&ibwdt_lock);
-		return 0;
-	} else {	
-		return -ENODEV;
+		return -EBUSY;
 	}
+	if (nowayout)
+		__module_get(THIS_MODULE);
+
+	/* Activate */
+	ibwdt_ping();
+	spin_unlock(&ibwdt_lock);
+	return 0;
 }
 
 static int
 ibwdt_close(struct inode *inode, struct file *file)
 {
-	if (iminor(inode) == WATCHDOG_MINOR) {
-		spin_lock(&ibwdt_lock);
-		if (expect_close)
-			outb_p(wd_times[wd_margin], WDT_STOP);
-		else
-			printk(KERN_CRIT PFX "WDT device closed unexpectedly.  WDT will not stop!\n");
+	spin_lock(&ibwdt_lock);
+	if (expect_close == 42)
+		outb_p(wd_times[wd_margin], WDT_STOP);
+	else
+		printk(KERN_CRIT PFX "WDT device closed unexpectedly.  WDT will not stop!\n");
 
-		ibwdt_is_open = 0;
-		spin_unlock(&ibwdt_lock);
-	}
+	clear_bit(0, &ibwdt_is_open);
+	expect_close = 0;
+	spin_unlock(&ibwdt_lock);
 	return 0;
 }
 
@@ -282,7 +274,7 @@ static struct file_operations ibwdt_fops
 static struct miscdevice ibwdt_miscdev = {
 	.minor = WATCHDOG_MINOR,
 	.name = "watchdog",
-	.fops = &ibwdt_fops
+	.fops = &ibwdt_fops,
 };
 
 /*
@@ -293,7 +285,7 @@ static struct miscdevice ibwdt_miscdev =
 static struct notifier_block ibwdt_notifier = {
 	.notifier_call = ibwdt_notify_sys,
 	.next = NULL,
-	.priority = 0
+	.priority = 0,
 };
 
 static int __init ibwdt_init(void)
diff -puN drivers/char/watchdog/indydog.c~linus drivers/char/watchdog/indydog.c
--- 25/drivers/char/watchdog/indydog.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/indydog.c	2004-01-19 22:17:21.000000000 -0800
@@ -7,10 +7,10 @@
  *	modify it under the terms of the GNU General Public License
  *	as published by the Free Software Foundation; either version
  *	2 of the License, or (at your option) any later version.
- *	
+ *
  *	based on softdog.c by Alan Cox <alan@redhat.com>
  */
- 
+
 #include <linux/module.h>
 #include <linux/config.h>
 #include <linux/types.h>
@@ -25,8 +25,8 @@
 #include <asm/sgi/sgimc.h>
 
 static unsigned long indydog_alive;
-static struct sgimc_misc_ctrl *mcmisc_regs; 
-static int expect_close = 0;
+static struct sgimc_misc_ctrl *mcmisc_regs;
+static char expect_close;
 
 #ifdef CONFIG_WATCHDOG_NOWAYOUT
 static int nowayout = 1;
@@ -50,7 +50,7 @@ static void indydog_ping()
 static int indydog_open(struct inode *inode, struct file *file)
 {
 	u32 mc_ctrl0;
-	
+
 	if( test_and_set_bit(0,&indydog_alive) )
 		return -EBUSY;
 
@@ -65,7 +65,7 @@ static int indydog_open(struct inode *in
 	mc_ctrl0 = mcmisc_regs->cpuctrl0 | SGIMC_CCTRL0_WDOG;
 	mcmisc_regs->cpuctrl0 = mc_ctrl0;
 	indydog_ping();
-			
+
 	printk("Started watchdog timer.\n");
 	return 0;
 }
@@ -77,8 +77,8 @@ static int indydog_release(struct inode 
 	 * 	Lock it in if it's a module and we set nowayout
 	 */
 
-	if (expect_close) {
-		u32 mc_ctrl0 = mcmisc_regs->cpuctrl0; 
+	if (expect_close == 42) {
+		u32 mc_ctrl0 = mcmisc_regs->cpuctrl0;
 		mc_ctrl0 &= ~SGIMC_CCTRL0_WDOG;
 		mcmisc_regs->cpuctrl0 = mc_ctrl0;
 		printk("Stopped watchdog timer.\n");
@@ -86,6 +86,7 @@ static int indydog_release(struct inode 
 		printk(KERN_CRIT "WDT device closed unexpectedly.  WDT will not stop!\n");
 	}
 	clear_bit(0,&indydog_alive);
+	expect_close = 0;
 	return 0;
 }
 
@@ -109,7 +110,7 @@ static ssize_t indydog_write(struct file
 				if (get_user(c, data + i))
 					return -EFAULT;
 				if (c == 'V')
-					expect_close = 1;
+					expect_close = 42;
 			}
 		}
 		indydog_ping();
diff -puN drivers/char/watchdog/machzwd.c~linus drivers/char/watchdog/machzwd.c
--- 25/drivers/char/watchdog/machzwd.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/machzwd.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,7 +1,7 @@
 /*
  *  MachZ ZF-Logic Watchdog Timer driver for Linux
- *  
- * 
+ *
+ *
  *  This program is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU General Public License
  *  as published by the Free Software Foundation; either version
@@ -14,14 +14,14 @@
  *  Author: Fernando Fuganti <fuganti@conectiva.com.br>
  *
  *  Based on sbc60xxwdt.c by Jakob Oestergaard
- * 
  *
- *  We have two timers (wd#1, wd#2) driven by a 32 KHz clock with the 
+ *
+ *  We have two timers (wd#1, wd#2) driven by a 32 KHz clock with the
  *  following periods:
  *      wd#1 - 2 seconds;
  *      wd#2 - 7.2 ms;
- *  After the expiration of wd#1, it can generate a NMI, SCI, SMI, or 
- *  a system RESET and it starts wd#2 that unconditionaly will RESET 
+ *  After the expiration of wd#1, it can generate a NMI, SCI, SMI, or
+ *  a system RESET and it starts wd#2 that unconditionaly will RESET
  *  the system when the counter reaches zero.
  *
  *  14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com>
@@ -55,7 +55,7 @@
 
 /* indexes */			/* size */
 #define ZFL_VERSION	0x02	/* 16   */
-#define CONTROL 	0x10	/* 16   */	
+#define CONTROL 	0x10	/* 16   */
 #define STATUS		0x12	/* 8    */
 #define COUNTER_1	0x0C	/* 16   */
 #define COUNTER_2	0x0E	/* 8    */
@@ -111,9 +111,9 @@ MODULE_PARM_DESC(nowayout, "Watchdog can
 #define PFX "machzwd"
 
 static struct watchdog_info zf_info = {
-	.options		= WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, 
-	.firmware_version	= 1, 
-	.identity		= "ZF-Logic watchdog"
+	.options		= WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
+	.firmware_version	= 1,
+	.identity		= "ZF-Logic watchdog",
 };
 
 
@@ -130,8 +130,8 @@ module_param(action, int, 0);
 MODULE_PARM_DESC(action, "after watchdog resets, generate: 0 = RESET(*)  1 = SMI  2 = NMI  3 = SCI");
 
 static int zf_action = GEN_RESET;
-static int zf_is_open = 0;
-static int zf_expect_close = 0;
+static unsigned long zf_is_open;
+static char zf_expect_close;
 static spinlock_t zf_lock;
 static spinlock_t zf_port_lock;
 static struct timer_list zf_timer;
@@ -225,7 +225,7 @@ static void zf_timer_off(void)
 	del_timer_sync(&zf_timer);
 
 	spin_lock_irqsave(&zf_port_lock, flags);
-	/* stop watchdog timer */	
+	/* stop watchdog timer */
 	ctrl_reg = zf_get_control();
 	ctrl_reg |= (ENABLE_WD1|ENABLE_WD2);	/* disable wd1 and wd2 */
 	ctrl_reg &= ~(ENABLE_WD1|ENABLE_WD2);
@@ -237,13 +237,13 @@ static void zf_timer_off(void)
 
 
 /*
- * start hardware timer 
+ * start hardware timer
  */
 static void zf_timer_on(void)
 {
 	unsigned int ctrl_reg = 0;
 	unsigned long flags;
-	
+
 	spin_lock_irqsave(&zf_port_lock, flags);
 
 	zf_writeb(PULSE_LEN, 0xff);
@@ -272,26 +272,26 @@ static void zf_ping(unsigned long data)
 {
 	unsigned int ctrl_reg = 0;
 	unsigned long flags;
-		
+
 	zf_writeb(COUNTER_2, 0xff);
 
 	if(time_before(jiffies, next_heartbeat)){
 
 		dprintk("time_before: %ld\n", next_heartbeat - jiffies);
-		
-		/* 
+
+		/*
 		 * reset event is activated by transition from 0 to 1 on
 		 * RESET_WD1 bit and we assume that it is already zero...
 		 */
 
 		spin_lock_irqsave(&zf_port_lock, flags);
-		ctrl_reg = zf_get_control();    
-		ctrl_reg |= RESET_WD1;		
-		zf_set_control(ctrl_reg);	
-		
+		ctrl_reg = zf_get_control();
+		ctrl_reg |= RESET_WD1;
+		zf_set_control(ctrl_reg);
+
 		/* ...and nothing changes until here */
 		ctrl_reg &= ~(RESET_WD1);
-		zf_set_control(ctrl_reg);		
+		zf_set_control(ctrl_reg);
 		spin_unlock_irqrestore(&zf_port_lock, flags);
 
 		zf_timer.expires = jiffies + ZF_HW_TIMEO;
@@ -301,7 +301,7 @@ static void zf_ping(unsigned long data)
 	}
 }
 
-static ssize_t zf_write(struct file *file, const char *buf, size_t count, 
+static ssize_t zf_write(struct file *file, const char *buf, size_t count,
 								loff_t *ppos)
 {
 	/*  Can't seek (pwrite) on this device  */
@@ -317,21 +317,21 @@ static ssize_t zf_write(struct file *fil
 		 */
 		if (!nowayout) {
 			size_t ofs;
-			
-			/* 
+
+			/*
 			 * note: just in case someone wrote the magic character
 			 * five months ago...
 			 */
 			zf_expect_close = 0;
-			
+
 			/* now scan */
 			for (ofs = 0; ofs != count; ofs++){
 				char c;
 				if (get_user(c, buf + ofs))
 					return -EFAULT;
 				if (c == 'V'){
-					zf_expect_close = 1;
-					dprintk("zf_expect_close 1\n");
+					zf_expect_close = 42;
+					dprintk("zf_expect_close = 42\n");
 				}
 			}
 		}
@@ -342,7 +342,7 @@ static ssize_t zf_write(struct file *fil
 		 */
 		next_heartbeat = jiffies + ZF_USER_TIMEO;
 		dprintk("user ping at %ld\n", jiffies);
-		
+
 	}
 
 	return count;
@@ -353,22 +353,20 @@ static int zf_ioctl(struct inode *inode,
 {
 	switch(cmd){
 		case WDIOC_GETSUPPORT:
-			if (copy_to_user((struct watchdog_info *)arg, 
+			if (copy_to_user((struct watchdog_info *)arg,
 					 &zf_info, sizeof(zf_info)))
 				return -EFAULT;
 			break;
-	  
+
 		case WDIOC_GETSTATUS:
-			if (copy_to_user((int *)arg, &zf_is_open, sizeof(int)))
-				return -EFAULT;
-			break;
+			return put_user(0, (int *) arg);
 
 		case WDIOC_KEEPALIVE:
 			zf_ping(0);
 			break;
 
 		default:
-			return -ENOTTY;
+			return -ENOIOCTLCMD;
 	}
 
 	return 0;
@@ -376,47 +374,37 @@ static int zf_ioctl(struct inode *inode,
 
 static int zf_open(struct inode *inode, struct file *file)
 {
-	switch(iminor(inode)){
-		case WATCHDOG_MINOR:
-			spin_lock(&zf_lock);
-			if(zf_is_open){
-				spin_unlock(&zf_lock);
-				return -EBUSY;
-			}
-
-			if (nowayout)
-				__module_get(THIS_MODULE);
+	spin_lock(&zf_lock);
+	if(test_and_set_bit(0, &zf_is_open)) {
+		spin_unlock(&zf_lock);
+		return -EBUSY;
+	}
 
-			zf_is_open = 1;
+	if (nowayout)
+		__module_get(THIS_MODULE);
 
-			spin_unlock(&zf_lock);
+	spin_unlock(&zf_lock);
 
-			zf_timer_on();
+	zf_timer_on();
 
-			return 0;
-		default:
-			return -ENODEV;
-	}
+	return 0;
 }
 
 static int zf_close(struct inode *inode, struct file *file)
 {
-	if(iminor(inode) == WATCHDOG_MINOR){
+	if(zf_expect_close == 42){
+		zf_timer_off();
+	} else {
+		del_timer(&zf_timer);
+		printk(KERN_ERR PFX ": device file closed unexpectedly. Will not stop the WDT!\n");
+	}
 
-		if(zf_expect_close){
-			zf_timer_off();
-		} else {
-			del_timer(&zf_timer);
-			printk(KERN_ERR PFX ": device file closed unexpectedly. Will not stop the WDT!\n");
-		}
-		
-		spin_lock(&zf_lock);
-		zf_is_open = 0;
-		spin_unlock(&zf_lock);
+	spin_lock(&zf_lock);
+	clear_bit(0, &zf_is_open);
+	spin_unlock(&zf_lock);
+
+	zf_expect_close = 0;
 
-		zf_expect_close = 0;
-	}
-	
 	return 0;
 }
 
@@ -428,9 +416,9 @@ static int zf_notify_sys(struct notifier
 								void *unused)
 {
 	if(code == SYS_DOWN || code == SYS_HALT){
-		zf_timer_off();		
+		zf_timer_off();
 	}
-	
+
 	return NOTIFY_DONE;
 }
 
@@ -448,9 +436,9 @@ static struct file_operations zf_fops = 
 static struct miscdevice zf_miscdev = {
 	.minor = WATCHDOG_MINOR,
 	.name = "watchdog",
-	.fops = &zf_fops
+	.fops = &zf_fops,
 };
-                                                                        
+ 
 
 /*
  * The device needs to learn about soft shutdowns in order to
@@ -459,20 +447,20 @@ static struct miscdevice zf_miscdev = {
 static struct notifier_block zf_notifier = {
 	.notifier_call = zf_notify_sys,
 	.next = NULL,
-	.priority = 0
+	.priority = 0,
 };
 
 static void __init zf_show_action(int act)
 {
 	char *str[] = { "RESET", "SMI", "NMI", "SCI" };
-	
+
 	printk(KERN_INFO PFX ": Watchdog using action = %s\n", str[act]);
 }
 
 static int __init zf_init(void)
 {
 	int ret;
-	
+
 	printk(KERN_INFO PFX ": MachZ ZF-Logic Watchdog driver initializing.\n");
 
 	ret = zf_get_ZFL_version();
@@ -486,12 +474,12 @@ static int __init zf_init(void)
 		zf_action = zf_action>>action;
 	} else
 		action = 0;
-	
+
 	zf_show_action(action);
 
 	spin_lock_init(&zf_lock);
 	spin_lock_init(&zf_port_lock);
-	
+
 	ret = misc_register(&zf_miscdev);
 	if (ret){
 		printk(KERN_ERR "can't misc_register on minor=%d\n",
@@ -512,7 +500,7 @@ static int __init zf_init(void)
 									ret);
 		goto no_reboot;
 	}
-	
+
 	zf_set_status(0);
 	zf_set_control(0);
 
@@ -520,7 +508,7 @@ static int __init zf_init(void)
 	init_timer(&zf_timer);
 	zf_timer.function = zf_ping;
 	zf_timer.data = 0;
-	
+
 	return 0;
 
 no_reboot:
@@ -531,11 +519,11 @@ out:
 	return ret;
 }
 
-	
+
 void __exit zf_exit(void)
 {
 	zf_timer_off();
-	
+
 	misc_deregister(&zf_miscdev);
 	unregister_reboot_notifier(&zf_notifier);
 	release_region(ZF_IOBASE, 3);
diff -puN drivers/char/watchdog/mixcomwd.c~linus drivers/char/watchdog/mixcomwd.c
--- 25/drivers/char/watchdog/mixcomwd.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/mixcomwd.c	2004-01-19 22:17:21.000000000 -0800
@@ -30,11 +30,11 @@
  *
  * Version 0.5 (2001/12/14) Matt Domsch <Matt_Domsch@dell.com>
  *              - added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT
- *	
+ *
  */
 
-#define VERSION "0.5" 
-  
+#define VERSION "0.5"
+
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/config.h>
@@ -55,12 +55,12 @@ static int mixcomwd_ioports[] = { 0x180,
 #define FLASHCOM_WATCHDOG_OFFSET 0x4
 #define FLASHCOM_ID 0x18
 
-static long mixcomwd_opened; /* long req'd for setbit --RR */
+static unsigned long mixcomwd_opened; /* long req'd for setbit --RR */
 
 static int watchdog_port;
 static int mixcomwd_timer_alive;
 static struct timer_list mixcomwd_timer = TIMER_INITIALIZER(NULL, 0, 0);
-static int expect_close = 0;
+static char expect_close;
 
 #ifdef CONFIG_WATCHDOG_NOWAYOUT
 static int nowayout = 1;
@@ -80,21 +80,21 @@ static void mixcomwd_ping(void)
 static void mixcomwd_timerfun(unsigned long d)
 {
 	mixcomwd_ping();
-	
+
 	mod_timer(&mixcomwd_timer,jiffies+ 5*HZ);
 }
 
 /*
  *	Allow only one person to hold it open
  */
- 
+
 static int mixcomwd_open(struct inode *inode, struct file *file)
 {
 	if(test_and_set_bit(0,&mixcomwd_opened)) {
 		return -EBUSY;
 	}
 	mixcomwd_ping();
-	
+
 	if (nowayout) {
 		/*
 		 * fops_get() code via open() has already done
@@ -113,7 +113,7 @@ static int mixcomwd_open(struct inode *i
 
 static int mixcomwd_release(struct inode *inode, struct file *file)
 {
-	if (expect_close) {
+	if (expect_close == 42) {
 		if(mixcomwd_timer_alive) {
 			printk(KERN_ERR "mixcomwd: release called while internal timer alive");
 			return -EBUSY;
@@ -129,6 +129,7 @@ static int mixcomwd_release(struct inode
 	}
 
 	clear_bit(0,&mixcomwd_opened);
+	expect_close=0;
 	return 0;
 }
 
@@ -152,7 +153,7 @@ static ssize_t mixcomwd_write(struct fil
 				if (get_user(c, data + i))
 					return -EFAULT;
 				if (c == 'V')
-					expect_close = 1;
+					expect_close = 42;
 			}
 		}
 		mixcomwd_ping();
@@ -167,9 +168,9 @@ static int mixcomwd_ioctl(struct inode *
 	static struct watchdog_info ident = {
 		.options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
 		.firmware_version = 1,
-		.identity = "MixCOM watchdog"
+		.identity = "MixCOM watchdog",
 	};
-                                        
+
 	switch(cmd)
 	{
 		case WDIOC_GETSTATUS:
@@ -182,7 +183,7 @@ static int mixcomwd_ioctl(struct inode *
 			}
 			break;
 		case WDIOC_GETSUPPORT:
-			if (copy_to_user((struct watchdog_info *)arg, &ident, 
+			if (copy_to_user((struct watchdog_info *)arg, &ident,
 			    sizeof(ident))) {
 				return -EFAULT;
 			}
@@ -191,7 +192,7 @@ static int mixcomwd_ioctl(struct inode *
 			mixcomwd_ping();
 			break;
 		default:
-			return -ENOTTY;
+			return -ENOIOCTLCMD;
 	}
 	return 0;
 }
@@ -207,9 +208,9 @@ static struct file_operations mixcomwd_f
 
 static struct miscdevice mixcomwd_miscdev=
 {
-	WATCHDOG_MINOR,
-	"watchdog",
-	&mixcomwd_fops
+	.minor	= WATCHDOG_MINOR,
+	.name	= "watchdog",
+	.fops	= &mixcomwd_fops,
 };
 
 static int __init mixcomwd_checkcard(int port)
@@ -220,7 +221,7 @@ static int __init mixcomwd_checkcard(int
 	if (!request_region(port, 1, "MixCOM watchdog")) {
 		return 0;
 	}
-	
+
 	id=inb_p(port) & 0x3f;
 	if(id!=MIXCOM_ID) {
 		release_region(port, 1);
@@ -232,12 +233,12 @@ static int __init mixcomwd_checkcard(int
 static int __init flashcom_checkcard(int port)
 {
 	int id;
-	
+
 	port += FLASHCOM_WATCHDOG_OFFSET;
 	if (!request_region(port, 1, "MixCOM watchdog")) {
 		return 0;
 	}
-	
+
 	id=inb_p(port);
  	if(id!=FLASHCOM_ID) {
 		release_region(port, 1);
@@ -245,7 +246,7 @@ static int __init flashcom_checkcard(int
 	}
  	return port;
  }
- 
+
 static int __init mixcomwd_init(void)
 {
 	int i;
@@ -258,7 +259,7 @@ static int __init mixcomwd_init(void)
 			found = 1;
 		}
 	}
-	
+
 	/* The FlashCOM card can be set up at 0x300 -> 0x378, in 0x8 jumps */
 	for (i = 0x300; !found && i < 0x380; i+=0x8) {
 		watchdog_port = flashcom_checkcard(i);
@@ -266,7 +267,7 @@ static int __init mixcomwd_init(void)
 			found = 1;
 		}
 	}
-	
+
 	if (!found) {
 		printk("mixcomwd: No card detected, or port not available.\n");
 		return -ENODEV;
@@ -278,11 +279,11 @@ static int __init mixcomwd_init(void)
 		release_region(watchdog_port, 1);
 		return ret;
 	}
-	
+
 	printk(KERN_INFO "MixCOM watchdog driver v%s, watchdog port at 0x%3x\n",VERSION,watchdog_port);
 
 	return 0;
-}	
+}
 
 static void __exit mixcomwd_exit(void)
 {
diff -puN drivers/char/watchdog/pcwd.c~linus drivers/char/watchdog/pcwd.c
--- 25/drivers/char/watchdog/pcwd.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/pcwd.c	2004-01-19 22:17:21.000000000 -0800
@@ -34,7 +34,7 @@
  * 971222       Changed open/close for temperature handling
  *              Michael Meskes <meskes@debian.org>.
  * 980112       Used minor numbers from include/linux/miscdevice.h
- * 990403       Clear reset status after reading control status register in 
+ * 990403       Clear reset status after reading control status register in
  *              pcwd_showprevstate(). [Marc Boucher <marc@mbsi.ca>]
  * 990605	Made changes to code to support Firmware 1.22a, added
  *		fairly useless proc entry.
@@ -86,10 +86,10 @@ static int pcwd_ioports[] = { 0x270, 0x3
 #define	WD_TIMEOUT		4	/* 2 seconds for a timeout */
 static int timeout_val = WD_TIMEOUT;
 static int timeout = 2;
-static int expect_close = 0;
+static char expect_close;
 
 module_param(timeout, int, 0);
-MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds (default=2)"); 
+MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds (default=2)");
 
 #ifdef CONFIG_WATCHDOG_NOWAYOUT
 static int nowayout = 1;
@@ -248,14 +248,14 @@ static int pcwd_ioctl(struct inode *inod
 	int cdat, rv;
 	static struct watchdog_info ident=
 	{
-		WDIOF_OVERHEAT|WDIOF_CARDRESET,
-		1,
-		"PCWD"
+		.options =		WDIOF_OVERHEAT|WDIOF_CARDRESET,
+		.firmware_version =	1,
+		.identity =		"PCWD",
 	};
 
 	switch(cmd) {
 	default:
-		return -ENOTTY;
+		return -ENOIOCTLCMD;
 
 	case WDIOC_GETSUPPORT:
 		if(copy_to_user((void*)arg, &ident, sizeof(ident)))
@@ -264,19 +264,19 @@ static int pcwd_ioctl(struct inode *inod
 
 	case WDIOC_GETSTATUS:
 		spin_lock(&io_lock);
-		if (revision == PCWD_REVISION_A) 
+		if (revision == PCWD_REVISION_A)
 			cdat = inb(current_readport);
 		else
 			cdat = inb(current_readport + 1 );
 		spin_unlock(&io_lock);
 		rv = WDIOF_MAGICCLOSE;
 
-		if (revision == PCWD_REVISION_A) 
+		if (revision == PCWD_REVISION_A)
 		{
 			if (cdat & WD_WDRST)
 				rv |= WDIOF_CARDRESET;
 
-			if (cdat & WD_T110) 
+			if (cdat & WD_T110)
 			{
 				rv |= WDIOF_OVERHEAT;
 
@@ -286,12 +286,12 @@ static int pcwd_ioctl(struct inode *inod
 				}
 			}
 		}
-		else 
+		else
 		{
 			if (cdat & 0x01)
 				rv |= WDIOF_CARDRESET;
 
-			if (cdat & 0x04) 
+			if (cdat & 0x04)
 			{
 				rv |= WDIOF_OVERHEAT;
 
@@ -309,7 +309,7 @@ static int pcwd_ioctl(struct inode *inod
 	case WDIOC_GETBOOTSTATUS:
 		rv = 0;
 
-		if (revision == PCWD_REVISION_A) 
+		if (revision == PCWD_REVISION_A)
 		{
 			if (initial_status & WD_WDRST)
 				rv |= WDIOF_CARDRESET;
@@ -333,7 +333,7 @@ static int pcwd_ioctl(struct inode *inod
 	case WDIOC_GETTEMP:
 
 		rv = 0;
-		if ((supports_temp) && (mode_debug == 0)) 
+		if ((supports_temp) && (mode_debug == 0))
 		{
 			spin_lock(&io_lock);
 			rv = inb(current_readport);
@@ -345,19 +345,19 @@ static int pcwd_ioctl(struct inode *inod
 		return 0;
 
 	case WDIOC_SETOPTIONS:
-		if (revision == PCWD_REVISION_C) 
+		if (revision == PCWD_REVISION_C)
 		{
 			if(copy_from_user(&rv, (int*) arg, sizeof(int)))
 				return -EFAULT;
 
-			if (rv & WDIOS_DISABLECARD) 
+			if (rv & WDIOS_DISABLECARD)
 			{
 				spin_lock(&io_lock);
 				outb_p(0xA5, current_readport + 3);
 				outb_p(0xA5, current_readport + 3);
 				cdat = inb_p(current_readport + 2);
 				spin_unlock(&io_lock);
-				if ((cdat & 0x10) == 0) 
+				if ((cdat & 0x10) == 0)
 				{
 					printk(KERN_INFO "pcwd: Could not disable card.\n");
 					return -EIO;
@@ -366,13 +366,13 @@ static int pcwd_ioctl(struct inode *inod
 				return 0;
 			}
 
-			if (rv & WDIOS_ENABLECARD) 
+			if (rv & WDIOS_ENABLECARD)
 			{
 				spin_lock(&io_lock);
 				outb_p(0x00, current_readport + 3);
 				cdat = inb_p(current_readport + 2);
 				spin_unlock(&io_lock);
-				if (cdat & 0x10) 
+				if (cdat & 0x10)
 				{
 					printk(KERN_INFO "pcwd: Could not enable card.\n");
 					return -EIO;
@@ -380,13 +380,13 @@ static int pcwd_ioctl(struct inode *inod
 				return 0;
 			}
 
-			if (rv & WDIOS_TEMPPANIC) 
+			if (rv & WDIOS_TEMPPANIC)
 			{
 				temp_panic = 1;
 			}
 		}
 		return -EINVAL;
-		
+
 	case WDIOC_KEEPALIVE:
 		pcwd_send_heartbeat();
 		return 0;
@@ -415,7 +415,7 @@ static ssize_t pcwd_write(struct file *f
 				if (get_user(c, buf + i))
 					return -EFAULT;
 				if (c == 'V')
-					expect_close = 1;
+					expect_close = 42;
 			}
 		}
 		pcwd_send_heartbeat();
@@ -456,14 +456,14 @@ static ssize_t pcwd_read(struct file *fi
 	/*  Can't seek (pread) on this device  */
 	if (ppos != &file->f_pos)
 		return -ESPIPE;
-	switch(iminor(file->f_dentry->d_inode)) 
+	switch(iminor(file->f_dentry->d_inode))
 	{
 		case TEMP_MINOR:
 			/*
 			 * Convert metric to Fahrenheit, since this was
 			 * the decided 'standard' for this return value.
 			 */
-			
+
 			c = inb(current_readport);
 			cp = (c * 9 / 5) + 32;
 			if(copy_to_user(buf, &cp, 1))
@@ -477,7 +477,7 @@ static ssize_t pcwd_read(struct file *fi
 static int pcwd_close(struct inode *ino, struct file *filep)
 {
 	if (iminor(ino)==WATCHDOG_MINOR) {
-		if (expect_close) {
+		if (expect_close == 42) {
 			/*  Disable the board  */
 			if (revision == PCWD_REVISION_C) {
 				spin_lock(&io_lock);
@@ -488,6 +488,7 @@ static int pcwd_close(struct inode *ino,
 			atomic_inc( &open_allowed );
 		}
 	}
+	expect_close = 0;
 	return 0;
 }
 
@@ -500,7 +501,7 @@ static inline void get_support(void)
 static inline int get_revision(void)
 {
 	int r = PCWD_REVISION_C;
-	
+
 	spin_lock(&io_lock);
 	if ((inb(current_readport + 2) == 0xFF) ||
 	    (inb(current_readport + 3) == 0xFF))
@@ -576,29 +577,29 @@ static struct file_operations pcwd_fops 
 };
 
 static struct miscdevice pcwd_miscdev = {
-	WATCHDOG_MINOR,
-	"watchdog",
-	&pcwd_fops
+	.minor =	WATCHDOG_MINOR,
+	.name =		"watchdog",
+	.fops =		&pcwd_fops,
 };
 
 static struct miscdevice temp_miscdev = {
-	TEMP_MINOR,
-	"temperature",
-	&pcwd_fops
+	.minor =	TEMP_MINOR,
+	.name =		"temperature",
+	.fops =		&pcwd_fops,
 };
- 
+
 static void __init pcwd_validate_timeout(void)
 {
 	timeout_val = timeout * 2;
 }
- 
+
 static int __init pcwatchdog_init(void)
 {
 	char *firmware;
 	int i, found = 0;
 	pcwd_validate_timeout();
 	spin_lock_init(&io_lock);
-	
+
 	revision = PCWD_REVISION_A;
 
 	printk(KERN_INFO "pcwd: v%s Ken Hollis (kenji@bitgate.com)\n", WD_VER);
@@ -660,11 +661,11 @@ static int __init pcwatchdog_init(void)
 
 	if (misc_register(&pcwd_miscdev))
 		return -ENODEV;
-	
+
 	if (supports_temp)
 		if (misc_register(&temp_miscdev)) {
 			misc_deregister(&pcwd_miscdev);
-			return -ENODEV;		
+			return -ENODEV;
 		}
 
 
@@ -673,10 +674,10 @@ static int __init pcwatchdog_init(void)
 			misc_deregister(&pcwd_miscdev);
 			if (supports_temp)
 				misc_deregister(&pcwd_miscdev);
-			return -EIO;		
+			return -EIO;
 		}
 	}
-	else 
+	else
 		if (!request_region(current_readport, 4, "PCWD Rev.C (Berkshire)")) {
 			misc_deregister(&pcwd_miscdev);
 			if (supports_temp)
diff -puN drivers/char/watchdog/sa1100_wdt.c~linus drivers/char/watchdog/sa1100_wdt.c
--- 25/drivers/char/watchdog/sa1100_wdt.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/sa1100_wdt.c	2004-01-19 22:17:21.000000000 -0800
@@ -77,6 +77,7 @@ static int sa1100dog_release(struct inod
 	}
 
 	clear_bit(1, &sa1100wdt_users);
+	expect_close = 0;
 
 	return 0;
 }
diff -puN drivers/char/watchdog/sbc60xxwdt.c~linus drivers/char/watchdog/sbc60xxwdt.c
--- 25/drivers/char/watchdog/sbc60xxwdt.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/sbc60xxwdt.c	2004-01-19 22:17:21.000000000 -0800
@@ -183,7 +183,7 @@ static ssize_t fop_write(struct file * f
 			 * five months ago... */
 			wdt_expect_close = 0;
 
-			/* scan to see wether or not we got the magic character */
+			/* scan to see whether or not we got the magic character */
 			for(ofs = 0; ofs != count; ofs++)
 			{
 				char c;
diff -puN drivers/char/watchdog/sc1200wdt.c~linus drivers/char/watchdog/sc1200wdt.c
--- 25/drivers/char/watchdog/sc1200wdt.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/sc1200wdt.c	2004-01-19 22:17:21.000000000 -0800
@@ -175,12 +175,12 @@ static int sc1200wdt_ioctl(struct inode 
 	static struct watchdog_info ident = {
 		.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE,
 		.firmware_version = 0,
-		.identity = "PC87307/PC97307"
+		.identity = "PC87307/PC97307",
 	};
 
 	switch (cmd) {
 		default:
-			return -ENOTTY;	/* Keep Pavel Machek amused ;) */
+			return -ENOIOCTLCMD;	/* Keep Pavel Machek amused ;) */
 
 		case WDIOC_GETSUPPORT:
 			if (copy_to_user((struct watchdog_info *)arg, &ident, sizeof ident))
@@ -256,7 +256,7 @@ static ssize_t sc1200wdt_write(struct fi
 {
 	if (ppos != &file->f_pos)
 		return -ESPIPE;
-	
+
 	if (len) {
 		if (!nowayout) {
 			size_t i;
@@ -292,7 +292,7 @@ static int sc1200wdt_notify_sys(struct n
 
 static struct notifier_block sc1200wdt_notifier =
 {
-	notifier_call:	sc1200wdt_notify_sys
+	.notifier_call =	sc1200wdt_notify_sys,
 };
 
 static struct file_operations sc1200wdt_fops =
@@ -301,7 +301,7 @@ static struct file_operations sc1200wdt_
 	.write		= sc1200wdt_write,
 	.ioctl		= sc1200wdt_ioctl,
 	.open		= sc1200wdt_open,
-	.release	= sc1200wdt_release
+	.release	= sc1200wdt_release,
 };
 
 static struct miscdevice sc1200wdt_miscdev =
@@ -320,7 +320,7 @@ static int __init sc1200wdt_probe(void)
 	 * Nb. This could be done with accuracy by reading the SID registers, but
 	 * we don't have access to those io regions.
 	 */
-	
+
 	unsigned char reg;
 
 	sc1200wdt_read_data(PMC3, &reg);
@@ -334,7 +334,7 @@ static int __init sc1200wdt_probe(void)
 struct pnp_device_id scl200wdt_pnp_devices[] = {
 	/* National Semiconductor PC87307/PC97307 watchdog component */
 	{.id = "NSC0800", .driver_data = 0},
-	{.id = ""}
+	{.id = ""},
 };
 
 static int scl200wdt_pnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id)
@@ -409,7 +409,7 @@ static int __init sc1200wdt_init(void)
 		ret = -EBUSY;
 		goto out_clean;
 	}
-	
+
 	ret = sc1200wdt_probe();
 	if (ret)
 		goto out_io;
@@ -438,7 +438,7 @@ out_io:
 	release_region(io, io_len);
 
 	goto out_clean;
-}	
+}
 
 
 static void __exit sc1200wdt_exit(void)
diff -puN drivers/char/watchdog/scx200_wdt.c~linus drivers/char/watchdog/scx200_wdt.c
--- 25/drivers/char/watchdog/scx200_wdt.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/scx200_wdt.c	2004-01-19 22:17:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* linux/drivers/char/scx200_wdt.c 
+/* drivers/char/watchdog/scx200_wdt.c
 
    National Semiconductor SCx200 Watchdog support
 
@@ -51,7 +51,7 @@ MODULE_PARM_DESC(nowayout, "Disable watc
 
 static u16 wdto_restart;
 static struct semaphore open_semaphore;
-static unsigned expect_close;
+static char expect_close;
 
 /* Bits of the WDCNFG register */
 #define W_ENABLE 0x00fa		/* Enable watchdog */
@@ -73,7 +73,7 @@ static void scx200_wdt_update_margin(voi
 
 static void scx200_wdt_enable(void)
 {
-	printk(KERN_DEBUG NAME ": enabling watchdog timer, wdto_restart = %d\n", 
+	printk(KERN_DEBUG NAME ": enabling watchdog timer, wdto_restart = %d\n",
 	       wdto_restart);
 
 	outw(0, SCx200_CB_BASE + SCx200_WDT_WDTO);
@@ -86,7 +86,7 @@ static void scx200_wdt_enable(void)
 static void scx200_wdt_disable(void)
 {
 	printk(KERN_DEBUG NAME ": disabling watchdog timer\n");
-		
+
 	outw(0, SCx200_CB_BASE + SCx200_WDT_WDTO);
 	outb(SCx200_WDT_WDSTS_WDOVF, SCx200_CB_BASE + SCx200_WDT_WDSTS);
 	outw(W_DISABLE, SCx200_CB_BASE + SCx200_WDT_WDCNFG);
@@ -94,50 +94,50 @@ static void scx200_wdt_disable(void)
 
 static int scx200_wdt_open(struct inode *inode, struct file *file)
 {
-        /* only allow one at a time */
-        if (down_trylock(&open_semaphore))
-                return -EBUSY;
+	/* only allow one at a time */
+	if (down_trylock(&open_semaphore))
+		return -EBUSY;
 	scx200_wdt_enable();
-	expect_close = 0;
 
 	return 0;
 }
 
 static int scx200_wdt_release(struct inode *inode, struct file *file)
 {
-	if (!expect_close) {
+	if (expect_close != 42) {
 		printk(KERN_WARNING NAME ": watchdog device closed unexpectedly, will not disable the watchdog timer\n");
 	} else if (!nowayout) {
 		scx200_wdt_disable();
 	}
-        up(&open_semaphore);
+	expect_close = 0;
+	up(&open_semaphore);
 
 	return 0;
 }
 
-static int scx200_wdt_notify_sys(struct notifier_block *this, 
+static int scx200_wdt_notify_sys(struct notifier_block *this,
 				      unsigned long code, void *unused)
 {
-        if (code == SYS_HALT || code == SYS_POWER_OFF)
+	if (code == SYS_HALT || code == SYS_POWER_OFF)
 		if (!nowayout)
 			scx200_wdt_disable();
 
-        return NOTIFY_DONE;
+	return NOTIFY_DONE;
 }
 
 static struct notifier_block scx200_wdt_notifier =
 {
-        .notifier_call = scx200_wdt_notify_sys
+	.notifier_call = scx200_wdt_notify_sys,
 };
 
-static ssize_t scx200_wdt_write(struct file *file, const char *data, 
+static ssize_t scx200_wdt_write(struct file *file, const char *data,
 				     size_t len, loff_t *ppos)
 {
 	if (ppos != &file->f_pos)
 		return -ESPIPE;
 
 	/* check for a magic close character */
-	if (len) 
+	if (len)
 	{
 		size_t i;
 
@@ -149,7 +149,7 @@ static ssize_t scx200_wdt_write(struct f
 			if (get_user(c, data+i))
 				return -EFAULT;
 			if (c == 'V')
-				expect_close = 1;
+				expect_close = 42;
 		}
 
 		return len;
@@ -163,16 +163,16 @@ static int scx200_wdt_ioctl(struct inode
 {
 	static struct watchdog_info ident = {
 		.identity = "NatSemi SCx200 Watchdog",
-		.firmware_version = 1, 
+		.firmware_version = 1,
 		.options = (WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING),
 	};
 	int new_margin;
-	
+
 	switch (cmd) {
 	default:
-		return -ENOTTY;
+		return -ENOIOCTLCMD;
 	case WDIOC_GETSUPPORT:
-		if(copy_to_user((struct watchdog_info *)arg, &ident, 
+		if(copy_to_user((struct watchdog_info *)arg, &ident,
 				sizeof(ident)))
 			return -EFAULT;
 		return 0;
@@ -220,7 +220,7 @@ static int __init scx200_wdt_init(void)
 	printk(KERN_DEBUG NAME ": NatSemi SCx200 Watchdog Driver\n");
 
 	/* First check that this really is a NatSemi SCx200 CPU */
-	if ((pci_find_device(PCI_VENDOR_ID_NS, 
+	if ((pci_find_device(PCI_VENDOR_ID_NS,
 			     PCI_DEVICE_ID_NS_SCx200_BRIDGE,
 			     NULL)) == NULL)
 		return -ENODEV;
@@ -231,8 +231,8 @@ static int __init scx200_wdt_init(void)
 		return -ENODEV;
 	}
 
-	if (!request_region(SCx200_CB_BASE + SCx200_WDT_OFFSET, 
-			    SCx200_WDT_SIZE, 
+	if (!request_region(SCx200_CB_BASE + SCx200_WDT_OFFSET,
+			    SCx200_WDT_SIZE,
 			    "NatSemi SCx200 Watchdog")) {
 		printk(KERN_WARNING NAME ": watchdog I/O region busy\n");
 		return -EBUSY;
@@ -251,20 +251,20 @@ static int __init scx200_wdt_init(void)
 	}
 
 	r = register_reboot_notifier(&scx200_wdt_notifier);
-        if (r) {
-                printk(KERN_ERR NAME ": unable to register reboot notifier");
+	if (r) {
+		printk(KERN_ERR NAME ": unable to register reboot notifier");
 		misc_deregister(&scx200_wdt_miscdev);
 		release_region(SCx200_CB_BASE + SCx200_WDT_OFFSET,
 				SCx200_WDT_SIZE);
-                return r;
-        }
+		return r;
+	}
 
 	return 0;
 }
 
 static void __exit scx200_wdt_cleanup(void)
 {
-        unregister_reboot_notifier(&scx200_wdt_notifier);
+	unregister_reboot_notifier(&scx200_wdt_notifier);
 	misc_deregister(&scx200_wdt_miscdev);
 	release_region(SCx200_CB_BASE + SCx200_WDT_OFFSET,
 		       SCx200_WDT_SIZE);
diff -puN drivers/char/watchdog/shwdt.c~linus drivers/char/watchdog/shwdt.c
--- 25/drivers/char/watchdog/shwdt.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/shwdt.c	2004-01-19 22:17:21.000000000 -0800
@@ -36,7 +36,7 @@
 /*
  * Default clock division ratio is 5.25 msecs. For an additional table of
  * values, consult the asm-sh/watchdog.h. Overload this at module load
- * time. 
+ * time.
  *
  * In order for this to work reliably we need to have HZ set to 1000 or
  * something quite higher than 100 (or we need a proper high-res timer
@@ -122,7 +122,7 @@ static void sh_wdt_start(void)
 	csr = sh_wdt_read_rstcsr();
 	csr &= ~RSTCSR_RSTS;
 	sh_wdt_write_rstcsr(csr);
-#endif	
+#endif
 }
 
 /**
@@ -202,7 +202,7 @@ static int sh_wdt_close(struct inode *in
 
 	clear_bit(0, &shwdt_is_open);
 	shwdt_expect_close = 0;
-	
+
 	return 0;
 }
 
@@ -264,7 +264,7 @@ static int sh_wdt_ioctl(struct inode *in
 					  sizeof(sh_wdt_info))) {
 				return -EFAULT;
 			}
-			
+
 			break;
 		case WDIOC_GETSTATUS:
 		case WDIOC_GETBOOTSTATUS:
@@ -299,11 +299,11 @@ static int sh_wdt_ioctl(struct inode *in
 				sh_wdt_start();
 				retval = 0;
 			}
-			
+
 			return retval;
 		}
 		default:
-			return -ENOTTY;
+			return -ENOIOCTLCMD;
 	}
 
 	return 0;
@@ -311,7 +311,7 @@ static int sh_wdt_ioctl(struct inode *in
 
 /**
  * 	sh_wdt_notify_sys - Notifier Handler
- * 	
+ *
  * 	@this: notifier block
  * 	@code: notifier event
  * 	@unused: unused
diff -puN drivers/char/watchdog/softdog.c~linus drivers/char/watchdog/softdog.c
--- 25/drivers/char/watchdog/softdog.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/softdog.c	2004-01-19 22:17:21.000000000 -0800
@@ -8,10 +8,10 @@
  *	modify it under the terms of the GNU General Public License
  *	as published by the Free Software Foundation; either version
  *	2 of the License, or (at your option) any later version.
- *	
- *	Neither Alan Cox nor CymruNet Ltd. admit liability nor provide 
- *	warranty for any of this software. This material is provided 
- *	"AS-IS" and at no charge.	
+ *
+ *	Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
+ *	warranty for any of this software. This material is provided
+ *	"AS-IS" and at no charge.
  *
  *	(c) Copyright 1995    Alan Cox <alan@lxorguk.ukuu.org.uk>
  *
@@ -28,14 +28,14 @@
  *	Made SMP safe for 2.3.x
  *
  *  20011127 Joel Becker (jlbec@evilplan.org>
- *	Added soft_noboot; Allows testing the softdog trigger without 
+ *	Added soft_noboot; Allows testing the softdog trigger without
  *	requiring a recompile.
  *	Added WDIOC_GETTIMEOUT and WDIOC_SETTIMOUT.
  *
  *  20020530 Joel Becker <joel.becker@oracle.com>
  *  	Added Matt Domsch's nowayout module option.
  */
- 
+
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/config.h>
@@ -49,7 +49,7 @@
 
 #define TIMER_MARGIN	60		/* (secs) Default is 1 minute */
 
-static int expect_close = 0;
+static char expect_close;
 static int soft_margin = TIMER_MARGIN;	/* in seconds */
 #ifdef ONLY_TESTING
 static int soft_noboot = 1;
@@ -73,7 +73,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog can
 /*
  *	Our timer
  */
- 
+
 static void watchdog_fire(unsigned long);
 
 static struct timer_list watchdog_ticktock =
@@ -84,7 +84,7 @@ static unsigned long timer_alive;
 /*
  *	If the timer expires..
  */
- 
+
 static void watchdog_fire(unsigned long data)
 {
 	if (soft_noboot)
@@ -100,12 +100,12 @@ static void watchdog_fire(unsigned long 
 /*
  *	Allow only one person to hold it open
  */
- 
+
 static int softdog_open(struct inode *inode, struct file *file)
 {
 	if(test_and_set_bit(0, &timer_alive))
 		return -EBUSY;
-	if (nowayout) 
+	if (nowayout)
 		__module_get(THIS_MODULE);
 	/*
 	 *	Activate timer
@@ -120,12 +120,13 @@ static int softdog_release(struct inode 
 	 *	Shut off the timer.
 	 * 	Lock it in if it's a module and we set nowayout
 	 */
-	if (expect_close) {
+	if (expect_close == 42) {
 		del_timer(&watchdog_ticktock);
 	} else {
 		printk(KERN_CRIT "SOFTDOG: WDT device closed unexpectedly.  WDT will not stop!\n");
 	}
 	clear_bit(0, &timer_alive);
+	expect_close = 0;
 	return 0;
 }
 
@@ -151,7 +152,7 @@ static ssize_t softdog_write(struct file
 				if (get_user(c, data + i))
 					return -EFAULT;
 				if (c == 'V')
-					expect_close = 1;
+					expect_close = 42;
 			}
 		}
 		mod_timer(&watchdog_ticktock, jiffies+(soft_margin*HZ));
@@ -169,7 +170,7 @@ static int softdog_ioctl(struct inode *i
 	};
 	switch (cmd) {
 		default:
-			return -ENOTTY;
+			return -ENOIOCTLCMD;
 		case WDIOC_GETSUPPORT:
 			if(copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident)))
 				return -EFAULT;
diff -puN drivers/char/watchdog/w83627hf_wdt.c~linus drivers/char/watchdog/w83627hf_wdt.c
--- 25/drivers/char/watchdog/w83627hf_wdt.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/w83627hf_wdt.c	2004-01-19 22:17:21.000000000 -0800
@@ -184,7 +184,7 @@ wdt_ioctl(struct inode *inode, struct fi
 	}
 
 	default:
-	  return -ENOTTY;
+	  return -ENOIOCTLCMD;
 	}
 	return 0;
 }
diff -puN drivers/char/watchdog/w83877f_wdt.c~linus drivers/char/watchdog/w83877f_wdt.c
--- 25/drivers/char/watchdog/w83877f_wdt.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/w83877f_wdt.c	2004-01-19 22:17:21.000000000 -0800
@@ -205,7 +205,7 @@ static ssize_t fop_write(struct file * f
 			 * five months ago... */
 			wdt_expect_close = 0;
 
-			/* scan to see wether or not we got the magic character */
+			/* scan to see whether or not we got the magic character */
 			for(ofs = 0; ofs != count; ofs++)
 			{
 				char c;
diff -puN drivers/char/watchdog/wafer5823wdt.c~linus drivers/char/watchdog/wafer5823wdt.c
--- 25/drivers/char/watchdog/wafer5823wdt.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/wafer5823wdt.c	2004-01-19 22:17:21.000000000 -0800
@@ -109,7 +109,7 @@ static ssize_t wafwdt_write(struct file 
 			/* In case it was set long ago */
 			expect_close = 0;
 
-			/* scan to see wether or not we got the magic character */
+			/* scan to see whether or not we got the magic character */
 			for (i = 0; i != count; i++) {
 				char c;
 				if (get_user(c, buf + i))
@@ -182,7 +182,7 @@ static int wafwdt_ioctl(struct inode *in
 	}
 
 	default:
-		return -ENOTTY;
+		return -ENOIOCTLCMD;
 	}
 	return 0;
 }
diff -puN drivers/char/watchdog/wdt285.c~linus drivers/char/watchdog/wdt285.c
--- 25/drivers/char/watchdog/wdt285.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/wdt285.c	2004-01-19 22:17:21.000000000 -0800
@@ -12,9 +12,9 @@
  *	modify it under the terms of the GNU General Public License
  *	as published by the Free Software Foundation; either version
  *	2 of the License, or (at your option) any later version.
- *	
+ *
  */
- 
+
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/types.h>
@@ -79,7 +79,7 @@ static int watchdog_open(struct inode *i
 
 	*CSR_TIMER4_CLR = 0;
 	watchdog_ping();
-	*CSR_TIMER4_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD 
+	*CSR_TIMER4_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD
 		| TIMER_CNTL_DIV256;
 
 #ifdef ONLY_TESTING
@@ -132,7 +132,7 @@ watchdog_write(struct file *file, const 
 
 static struct watchdog_info ident = {
 	.options	= WDIOF_SETTIMEOUT,
-	.identity	= "Footbridge Watchdog"
+	.identity	= "Footbridge Watchdog",
 };
 
 static int
@@ -192,7 +192,7 @@ static struct file_operations watchdog_f
 static struct miscdevice watchdog_miscdev = {
 	.minor		= WATCHDOG_MINOR,
 	.name		= "watchdog",
-	.fops		= &watchdog_fops
+	.fops		= &watchdog_fops,
 };
 
 static int __init footbridge_watchdog_init(void)
@@ -206,7 +206,7 @@ static int __init footbridge_watchdog_in
 	if (retval < 0)
 		return retval;
 
-	printk("Footbridge Watchdog Timer: 0.01, timer margin: %d sec\n", 
+	printk("Footbridge Watchdog Timer: 0.01, timer margin: %d sec\n",
 	       soft_margin);
 
 	if (machine_is_cats())
diff -puN drivers/char/watchdog/wdt977.c~linus drivers/char/watchdog/wdt977.c
--- 25/drivers/char/watchdog/wdt977.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/wdt977.c	2004-01-19 22:17:21.000000000 -0800
@@ -43,7 +43,7 @@ static	int timeout = DEFAULT_TIMEOUT*60;
 static	int timeoutM = DEFAULT_TIMEOUT;		/* timeout in minutes */
 static	unsigned long timer_alive;
 static	int testmode;
-static int expect_close = 0;
+static	char expect_close;
 
 module_param(timeout, int, 0);
 MODULE_PARM_DESC(timeout,"Watchdog timeout in seconds (60..15300), default=60");
@@ -165,7 +165,7 @@ static int wdt977_release(struct inode *
 	 *	Shut off the timer.
 	 * 	Lock it in if it's a module and we set nowayout
 	 */
-	if (!nowayout)
+	if (expect_close == 42)
 	{
 		/* unlock the SuperIO chip */
 		outb(0x87,0x370);
@@ -202,6 +202,7 @@ static int wdt977_release(struct inode *
 	} else {
 		printk(KERN_CRIT "WDT device closed unexpectedly.  WDT will not stop!\n");
 	}
+	expect_close = 0;
 	return 0;
 }
 
@@ -235,7 +236,7 @@ static ssize_t wdt977_write(struct file 
 				if (get_user(c, buf + i))
 					return -EFAULT;
 				if (c == 'V')
-					expect_close = 1;
+					expect_close = 42;
 			}
 		}
 
@@ -257,18 +258,18 @@ static ssize_t wdt977_write(struct file 
 
 static struct watchdog_info ident = {
 	.options	= WDIOF_SETTIMEOUT,
-	.identity	= "Winbond 83977"
+	.identity	= "Winbond 83977",
 };
 
 static int wdt977_ioctl(struct inode *inode, struct file *file,
-         unsigned int cmd, unsigned long arg)
+	unsigned int cmd, unsigned long arg)
 {
 	int temp;
 
 	switch(cmd)
 	{
 	default:
-		return -ENOTTY;
+		return -ENOIOCTLCMD;
 
 	case WDIOC_GETSUPPORT:
 	    return copy_to_user((struct watchdog_info *)arg, &ident,
@@ -341,7 +342,7 @@ static struct miscdevice wdt977_miscdev=
 {
 	.minor		= WATCHDOG_MINOR,
 	.name		= "watchdog",
-	.fops		= &wdt977_fops
+	.fops		= &wdt977_fops,
 };
 
 static int __init nwwatchdog_init(void)
diff -puN drivers/char/watchdog/wdt.c~linus drivers/char/watchdog/wdt.c
--- 25/drivers/char/watchdog/wdt.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/wdt.c	2004-01-19 22:17:21.000000000 -0800
@@ -8,10 +8,10 @@
  *	modify it under the terms of the GNU General Public License
  *	as published by the Free Software Foundation; either version
  *	2 of the License, or (at your option) any later version.
- *	
- *	Neither Alan Cox nor CymruNet Ltd. admit liability nor provide 
- *	warranty for any of this software. This material is provided 
- *	"AS-IS" and at no charge.	
+ *
+ *	Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
+ *	warranty for any of this software. This material is provided
+ *	"AS-IS" and at no charge.
  *
  *	(c) Copyright 1995    Alan Cox <alan@lxorguk.ukuu.org.uk>
  *
@@ -49,13 +49,13 @@
 #include "wd501p.h"
 
 static unsigned long wdt_is_open;
-static int expect_close;
+static char expect_close;
 
 /*
  *	You must set these - there is no sane way to probe for this board.
  *	You can use wdt=x,y to set these now.
  */
- 
+
 static int io=0x240;
 static int irq=11;
 
@@ -80,10 +80,10 @@ MODULE_PARM_DESC(nowayout, "Watchdog can
  *	@str: command line string
  *
  *	Setup options. The board isn't really probe-able so we have to
- *	get the user to tell us the configuration. Sane people build it 
+ *	get the user to tell us the configuration. Sane people build it
  *	modular but the others come here.
  */
- 
+
 static int __init wdt_setup(char *str)
 {
 	int ints[4];
@@ -108,11 +108,11 @@ MODULE_PARM(io, "i");
 MODULE_PARM_DESC(io, "WDT io port (default=0x240)");
 MODULE_PARM(irq, "i");
 MODULE_PARM_DESC(irq, "WDT irq (default=11)");
- 
+
 /*
  *	Programming support
  */
- 
+
 static void wdt_ctr_mode(int ctr, int mode)
 {
 	ctr<<=6;
@@ -130,29 +130,29 @@ static void wdt_ctr_load(int ctr, int va
 /*
  *	Kernel methods.
  */
- 
- 
+
+
 /**
  *	wdt_status:
- *	
+ *
  *	Extract the status information from a WDT watchdog device. There are
  *	several board variants so we have to know which bits are valid. Some
  *	bits default to one and some to zero in order to be maximally painful.
  *
  *	we then map the bits onto the status ioctl flags.
  */
- 
+
 static int wdt_status(void)
 {
 	/*
 	 *	Status register to bit flags
 	 */
-	 
+
 	int flag=0;
 	unsigned char status=inb_p(WDT_SR);
 	status|=FEATUREMAP1;
-	status&=~FEATUREMAP2;	
-	
+	status&=~FEATUREMAP2;
+
 	if(!(status&WDC_SR_TGOOD))
 		flag|=WDIOF_OVERHEAT;
 	if(!(status&WDC_SR_PSUOVER))
@@ -178,21 +178,21 @@ static int wdt_status(void)
  *	map changes in what the board considers an interesting way. That means
  *	a failure condition occurring.
  */
- 
+
 static irqreturn_t wdt_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	/*
 	 *	Read the status register see what is up and
-	 *	then printk it. 
+	 *	then printk it.
 	 */
-	 
+
 	unsigned char status=inb_p(WDT_SR);
-	
+
 	status|=FEATUREMAP1;
-	status&=~FEATUREMAP2;	
-	
+	status&=~FEATUREMAP2;
+
 	printk(KERN_CRIT "WDT status %d\n", status);
-	
+
 	if(!(status&WDC_SR_TGOOD))
 		printk(KERN_CRIT "Overheat alarm.(%d)\n",inb_p(WDT_RT));
 	if(!(status&WDC_SR_PSUOVER))
@@ -205,10 +205,10 @@ static irqreturn_t wdt_interrupt(int irq
 #ifdef SOFTWARE_REBOOT
 #ifdef ONLY_TESTING
 		printk(KERN_CRIT "Would Reboot.\n");
-#else		
+#else
 		printk(KERN_CRIT "Initiating system reboot.\n");
 		machine_restart(NULL);
-#endif		
+#endif
 #else
 		printk(KERN_CRIT "Reset in 5ms.\n");
 #endif
@@ -220,9 +220,9 @@ static irqreturn_t wdt_interrupt(int irq
  *	wdt_ping:
  *
  *	Reload counter one with the watchdog timeout. We don't bother reloading
- *	the cascade counter. 
+ *	the cascade counter.
  */
- 
+
 static void wdt_ping(void)
 {
 	/* Write a watchdog value */
@@ -235,14 +235,14 @@ static void wdt_ping(void)
 /**
  *	wdt_write:
  *	@file: file handle to the watchdog
- *	@buf: buffer to write (unused as data does not matter here 
+ *	@buf: buffer to write (unused as data does not matter here
  *	@count: count of bytes
  *	@ppos: pointer to the position to write. No seeks allowed
  *
  *	A write to a watchdog device is defined as a keepalive signal. Any
  *	write of data will do, as we we don't define content meaning.
  */
- 
+
 static ssize_t wdt_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
 {
 	/*  Can't seek (pwrite) on this device  */
@@ -261,7 +261,7 @@ static ssize_t wdt_write(struct file *fi
 				if (get_user(c, buf + i))
 					return -EFAULT;
 				if (c == 'V')
-					expect_close = 1;
+					expect_close = 42;
 			}
 		}
 		wdt_ping();
@@ -279,12 +279,12 @@ static ssize_t wdt_write(struct file *fi
  *	Read reports the temperature in degrees Fahrenheit. The API is in
  *	farenheit. It was designed by an imperial measurement luddite.
  */
- 
+
 static ssize_t wdt_read(struct file *file, char *buf, size_t count, loff_t *ptr)
 {
 	unsigned short c=inb_p(WDT_RT);
 	unsigned char cp;
-	
+
 	/*  Can't seek (pread) on this device  */
 	if (ptr != &file->f_pos)
 		return -ESPIPE;
@@ -312,9 +312,9 @@ static ssize_t wdt_read(struct file *fil
  *
  *	The watchdog API defines a common set of functions for all watchdogs
  *	according to their available features. We only actually usefully support
- *	querying capabilities and current status. 
+ *	querying capabilities and current status.
  */
- 
+
 static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
 	unsigned long arg)
 {
@@ -326,14 +326,14 @@ static int wdt_ioctl(struct inode *inode
 					|WDIOF_EXTERN1|WDIOF_EXTERN2|WDIOF_FANFAULT
 					|WDIOF_SETTIMEOUT|WDIOF_MAGICCLOSE,
 		.firmware_version = 1,
-		.identity = "WDT500/501"
+		.identity = "WDT500/501",
 	};
-	
+
 	ident.options&=WDT_OPTION_MASK;	/* Mask down to the card we have */
 	switch(cmd)
 	{
 		default:
-			return -ENOTTY;
+			return -ENOIOCTLCMD;
 		case WDIOC_GETSUPPORT:
 			return copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident))?-EFAULT:0;
 
@@ -364,12 +364,12 @@ static int wdt_ioctl(struct inode *inode
  *	@file: file handle to device
  *
  *	One of our two misc devices has been opened. The watchdog device is
- *	single open and on opening we load the counters. Counter zero is a 
+ *	single open and on opening we load the counters. Counter zero is a
  *	100Hz cascade, into counter 1 which downcounts to reboot. When the
  *	counter triggers counter 2 downcounts the length of the reset pulse
- *	which set set to be as long as possible. 
+ *	which set set to be as long as possible.
  */
- 
+
 static int wdt_open(struct inode *inode, struct file *file)
 {
 	switch(iminor(inode))
@@ -378,9 +378,9 @@ static int wdt_open(struct inode *inode,
 			if(test_and_set_bit(0, &wdt_is_open))
 				return -EBUSY;
 			/*
-			 *	Activate 
+			 *	Activate
 			 */
-	 
+
 			wdt_is_open=1;
 			inb_p(WDT_DC);		/* Disable */
 			wdt_ctr_mode(0,3);
@@ -403,24 +403,25 @@ static int wdt_open(struct inode *inode,
  *	@inode: inode to board
  *	@file: file handle to board
  *
- *	The watchdog has a configurable API. There is a religious dispute 
- *	between people who want their watchdog to be able to shut down and 
+ *	The watchdog has a configurable API. There is a religious dispute
+ *	between people who want their watchdog to be able to shut down and
  *	those who want to be sure if the watchdog manager dies the machine
  *	reboots. In the former case we disable the counters, in the latter
  *	case you have to open it again very soon.
  */
- 
+
 static int wdt_release(struct inode *inode, struct file *file)
 {
 	if(iminor(inode)==WATCHDOG_MINOR)
 	{
-		if (expect_close) {
+		if (expect_close == 42) {
 			inb_p(WDT_DC);		/* Disable counters */
 			wdt_ctr_load(2,0);	/* 0 length reset pulses now */
 		} else {
 			printk(KERN_CRIT "wdt: WDT device closed unexpectedly.  WDT will not stop!\n");
 		}
 		clear_bit(0, &wdt_is_open);
+		expect_close = 0;
 	}
 	return 0;
 }
@@ -448,12 +449,12 @@ static int wdt_notify_sys(struct notifie
 	}
 	return NOTIFY_DONE;
 }
- 
+
 /*
  *	Kernel Interfaces
  */
- 
- 
+
+
 static struct file_operations wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
@@ -468,7 +469,7 @@ static struct miscdevice wdt_miscdev=
 {
 	.minor	= WATCHDOG_MINOR,
 	.name	= "watchdog",
-	.fops	= &wdt_fops
+	.fops	= &wdt_fops,
 };
 
 #ifdef CONFIG_WDT_501
@@ -476,20 +477,20 @@ static struct miscdevice temp_miscdev=
 {
 	.minor	= TEMP_MINOR,
 	.name	= "temperature",
-	.fops	= &wdt_fops
+	.fops	= &wdt_fops,
 };
 #endif
 
 /*
  *	The WDT card needs to learn about soft shutdowns in order to
- *	turn the timebomb registers off. 
+ *	turn the timebomb registers off.
  */
- 
+
 static struct notifier_block wdt_notifier=
 {
 	.notifier_call = wdt_notify_sys,
 	.next = NULL,
-	.priority = 0
+	.priority = 0,
 };
 
 /**
@@ -501,13 +502,13 @@ static struct notifier_block wdt_notifie
  *	will not touch PC memory so all is fine. You just have to load a new
  *	module in 60 seconds or reboot.
  */
- 
+
 static void __exit wdt_exit(void)
 {
 	misc_deregister(&wdt_miscdev);
-#ifdef CONFIG_WDT_501	
+#ifdef CONFIG_WDT_501
 	misc_deregister(&temp_miscdev);
-#endif	
+#endif
 	unregister_reboot_notifier(&wdt_notifier);
 	release_region(io,8);
 	free_irq(irq, NULL);
@@ -520,7 +521,7 @@ static void __exit wdt_exit(void)
  *	resources we require and bitch if anyone beat us to them.
  *	The open() function will actually kick the board off.
  */
- 
+
 static int __init wdt_init(void)
 {
 	int ret;
diff -puN drivers/char/watchdog/wdt_pci.c~linus drivers/char/watchdog/wdt_pci.c
--- 25/drivers/char/watchdog/wdt_pci.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/char/watchdog/wdt_pci.c	2004-01-19 22:17:21.000000000 -0800
@@ -8,10 +8,10 @@
  *	modify it under the terms of the GNU General Public License
  *	as published by the Free Software Foundation; either version
  *	2 of the License, or (at your option) any later version.
- *	
- *	Neither Alan Cox nor CymruNet Ltd. admit liability nor provide 
- *	warranty for any of this software. This material is provided 
- *	"AS-IS" and at no charge.	
+ *
+ *	Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
+ *	warranty for any of this software. This material is provided
+ *	"AS-IS" and at no charge.
  *
  *	(c) Copyright 1995    Alan Cox <alan@lxorguk.ukuu.org.uk>
  *
@@ -72,7 +72,7 @@
 
 static struct semaphore open_sem;
 static spinlock_t wdtpci_lock;
-static int expect_close = 0;
+static char expect_close;
 
 static int io;
 static int irq;
@@ -95,7 +95,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog can
 /*
  *	Programming support
  */
- 
+
 static void wdtpci_ctr_mode(int ctr, int mode)
 {
 	ctr<<=6;
@@ -113,29 +113,29 @@ static void wdtpci_ctr_load(int ctr, int
 /*
  *	Kernel methods.
  */
- 
- 
+
+
 /**
  *	wdtpci_status:
- *	
+ *
  *	Extract the status information from a WDT watchdog device. There are
  *	several board variants so we have to know which bits are valid. Some
  *	bits default to one and some to zero in order to be maximally painful.
  *
  *	we then map the bits onto the status ioctl flags.
  */
- 
+
 static int wdtpci_status(void)
 {
 	/*
 	 *	Status register to bit flags
 	 */
-	 
+
 	int flag=0;
 	unsigned char status=inb_p(WDT_SR);
 	status|=FEATUREMAP1;
-	status&=~FEATUREMAP2;	
-	
+	status&=~FEATUREMAP2;
+
 	if(!(status&WDC_SR_TGOOD))
 		flag|=WDIOF_OVERHEAT;
 	if(!(status&WDC_SR_PSUOVER))
@@ -161,21 +161,21 @@ static int wdtpci_status(void)
  *	map changes in what the board considers an interesting way. That means
  *	a failure condition occurring.
  */
- 
+
 static irqreturn_t wdtpci_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	/*
 	 *	Read the status register see what is up and
-	 *	then printk it. 
+	 *	then printk it.
 	 */
-	 
+
 	unsigned char status=inb_p(WDT_SR);
-	
+
 	status|=FEATUREMAP1;
-	status&=~FEATUREMAP2;	
-	
+	status&=~FEATUREMAP2;
+
 	printk(KERN_CRIT "WDT status %d\n", status);
-	
+
 	if(!(status&WDC_SR_TGOOD))
 		printk(KERN_CRIT "Overheat alarm.(%d)\n",inb_p(WDT_RT));
 	if(!(status&WDC_SR_PSUOVER))
@@ -188,10 +188,10 @@ static irqreturn_t wdtpci_interrupt(int 
 #ifdef SOFTWARE_REBOOT
 #ifdef ONLY_TESTING
 		printk(KERN_CRIT "Would Reboot.\n");
-#else		
+#else
 		printk(KERN_CRIT "Initiating system reboot.\n");
 		machine_restart(NULL);
-#endif		
+#endif
 #else
 		printk(KERN_CRIT "Reset in 5ms.\n");
 #endif
@@ -203,9 +203,9 @@ static irqreturn_t wdtpci_interrupt(int 
  *	wdtpci_ping:
  *
  *	Reload counter one with the watchdog timeout. We don't bother reloading
- *	the cascade counter. 
+ *	the cascade counter.
  */
- 
+
 static void wdtpci_ping(void)
 {
 	unsigned long flags;
@@ -222,14 +222,14 @@ static void wdtpci_ping(void)
 /**
  *	wdtpci_write:
  *	@file: file handle to the watchdog
- *	@buf: buffer to write (unused as data does not matter here 
+ *	@buf: buffer to write (unused as data does not matter here
  *	@count: count of bytes
  *	@ppos: pointer to the position to write. No seeks allowed
  *
  *	A write to a watchdog device is defined as a keepalive signal. Any
  *	write of data will do, as we we don't define content meaning.
  */
- 
+
 static ssize_t wdtpci_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
 {
 	/*  Can't seek (pwrite) on this device  */
@@ -247,7 +247,7 @@ static ssize_t wdtpci_write(struct file 
 				if(get_user(c, buf+i))
 					return -EFAULT;
 				if (c == 'V')
-					expect_close = 1;
+					expect_close = 42;
 			}
 		}
 		wdtpci_ping();
@@ -266,12 +266,12 @@ static ssize_t wdtpci_write(struct file 
  *	Read reports the temperature in degrees Fahrenheit. The API is in
  *	fahrenheit. It was designed by an imperial measurement luddite.
  */
- 
+
 static ssize_t wdtpci_read(struct file *file, char *buf, size_t count, loff_t *ptr)
 {
 	unsigned short c=inb_p(WDT_RT);
 	unsigned char cp;
-	
+
 	/*  Can't seek (pread) on this device  */
 	if (ptr != &file->f_pos)
 		return -ESPIPE;
@@ -299,9 +299,9 @@ static ssize_t wdtpci_read(struct file *
  *
  *	The watchdog API defines a common set of functions for all watchdogs
  *	according to their available features. We only actually usefully support
- *	querying capabilities and current status. 
+ *	querying capabilities and current status.
  */
- 
+
 static int wdtpci_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
 	unsigned long arg)
 {
@@ -314,12 +314,12 @@ static int wdtpci_ioctl(struct inode *in
 		.firmware_version = 1,
 		.identity	  = "WDT500/501PCI",
 	};
-	
+
 	ident.options&=WDT_OPTION_MASK;	/* Mask down to the card we have */
 	switch(cmd)
 	{
 		default:
-			return -ENOTTY;
+			return -ENOIOCTLCMD;
 		case WDIOC_GETSUPPORT:
 			return copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident))?-EFAULT:0;
 
@@ -351,12 +351,12 @@ static int wdtpci_ioctl(struct inode *in
  *	@file: file handle to device
  *
  *	One of our two misc devices has been opened. The watchdog device is
- *	single open and on opening we load the counters. Counter zero is a 
+ *	single open and on opening we load the counters. Counter zero is a
  *	100Hz cascade, into counter 1 which downcounts to reboot. When the
  *	counter triggers counter 2 downcounts the length of the reset pulse
- *	which set set to be as long as possible. 
+ *	which set set to be as long as possible.
  */
- 
+
 static int wdtpci_open(struct inode *inode, struct file *file)
 {
 	unsigned long flags;
@@ -371,17 +371,17 @@ static int wdtpci_open(struct inode *ino
 				__module_get(THIS_MODULE);
 			}
 			/*
-			 *	Activate 
+			 *	Activate
 			 */
 			spin_lock_irqsave(&wdtpci_lock, flags);
-			
+
 			inb_p(WDT_DC);		/* Disable */
 
 			/*
 			 * "pet" the watchdog, as Access says.
 			 * This resets the clock outputs.
 			 */
-				
+
 			wdtpci_ctr_mode(2,0);
 			outb_p(0, WDT_DC);
 
@@ -413,19 +413,19 @@ static int wdtpci_open(struct inode *ino
  *	@inode: inode to board
  *	@file: file handle to board
  *
- *	The watchdog has a configurable API. There is a religious dispute 
- *	between people who want their watchdog to be able to shut down and 
+ *	The watchdog has a configurable API. There is a religious dispute
+ *	between people who want their watchdog to be able to shut down and
  *	those who want to be sure if the watchdog manager dies the machine
  *	reboots. In the former case we disable the counters, in the latter
  *	case you have to open it again very soon.
  */
- 
+
 static int wdtpci_release(struct inode *inode, struct file *file)
 {
 
 	if (iminor(inode)==WATCHDOG_MINOR) {
 		unsigned long flags;
-		if (expect_close) {
+		if (expect_close == 42) {
 			spin_lock_irqsave(&wdtpci_lock, flags);
 			inb_p(WDT_DC);		/* Disable counters */
 			wdtpci_ctr_load(2,0);	/* 0 length reset pulses now */
@@ -434,6 +434,7 @@ static int wdtpci_release(struct inode *
 			printk(KERN_CRIT PFX "Unexpected close, not stopping timer!");
 			wdtpci_ping();
 		}
+		expect_close = 0;
 		up(&open_sem);
 	}
 	return 0;
@@ -465,12 +466,12 @@ static int wdtpci_notify_sys(struct noti
 	}
 	return NOTIFY_DONE;
 }
- 
+
 /*
  *	Kernel Interfaces
  */
- 
- 
+
+
 static struct file_operations wdtpci_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
@@ -497,9 +498,9 @@ static struct miscdevice temp_miscdev = 
 
 /*
  *	The WDT card needs to learn about soft shutdowns in order to
- *	turn the timebomb registers off. 
+ *	turn the timebomb registers off.
  */
- 
+
 static struct notifier_block wdtpci_notifier = {
 	.notifier_call = wdtpci_notify_sys,
 };
@@ -584,7 +585,7 @@ static void __devexit wdtpci_remove_one 
 	unregister_reboot_notifier(&wdtpci_notifier);
 #ifdef CONFIG_WDT_501_PCI
 	misc_deregister(&temp_miscdev);
-#endif	
+#endif
 	misc_deregister(&wdtpci_miscdev);
 	free_irq(irq, &wdtpci_miscdev);
 	release_region(io, 16);
@@ -620,7 +621,7 @@ static struct pci_driver wdtpci_driver =
  *	will not touch PC memory so all is fine. You just have to load a new
  *	module in 60 seconds or reboot.
  */
- 
+
 static void __exit wdtpci_cleanup(void)
 {
 	pci_unregister_driver (&wdtpci_driver);
@@ -634,14 +635,14 @@ static void __exit wdtpci_cleanup(void)
  *	resources we require and bitch if anyone beat us to them.
  *	The open() function will actually kick the board off.
  */
- 
+
 static int __init wdtpci_init(void)
 {
 	int rc = pci_register_driver (&wdtpci_driver);
-	
+
 	if (rc < 1)
 		return -ENODEV;
-	
+
 	return 0;
 }
 
diff -puN drivers/i2c/algos/i2c-algo-pcf.h~linus drivers/i2c/algos/i2c-algo-pcf.h
--- 25/drivers/i2c/algos/i2c-algo-pcf.h~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/algos/i2c-algo-pcf.h	2004-01-19 22:17:21.000000000 -0800
@@ -21,8 +21,6 @@
 
 /* With some changes from Frodo Looijaard <frodol@dds.nl> */
 
-/* $Id: i2c-pcf8584.h,v 1.3 2000/01/18 23:54:07 frodo Exp $ */
-
 #ifndef I2C_PCF8584_H
 #define I2C_PCF8584_H 1
 
diff -puN drivers/i2c/algos/Kconfig~linus drivers/i2c/algos/Kconfig
--- 25/drivers/i2c/algos/Kconfig~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/algos/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -3,6 +3,7 @@
 #
 
 menu "I2C Algorithms"
+	depends on I2C
 
 config I2C_ALGOBIT
 	tristate "I2C bit-banging interfaces"
diff -puN drivers/i2c/busses/i2c-ali1535.c~linus drivers/i2c/busses/i2c-ali1535.c
--- 25/drivers/i2c/busses/i2c-ali1535.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-ali1535.c	2004-01-19 22:17:21.000000000 -0800
@@ -53,7 +53,10 @@
 
 /* Note: we assume there can only be one ALI1535, with one SMBus interface */
 
-/* #define DEBUG 1 */
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
 
 #include <linux/module.h>
 #include <linux/pci.h>
diff -puN drivers/i2c/busses/i2c-ali15x3.c~linus drivers/i2c/busses/i2c-ali15x3.c
--- 25/drivers/i2c/busses/i2c-ali15x3.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-ali15x3.c	2004-01-19 22:17:21.000000000 -0800
@@ -60,7 +60,10 @@
 
 /* Note: we assume there can only be one ALI15X3, with one SMBus interface */
 
-/* #define DEBUG 1 */
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
 
 #include <linux/module.h>
 #include <linux/pci.h>
diff -puN drivers/i2c/busses/i2c-amd756.c~linus drivers/i2c/busses/i2c-amd756.c
--- 25/drivers/i2c/busses/i2c-amd756.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-amd756.c	2004-01-19 22:17:21.000000000 -0800
@@ -37,7 +37,10 @@
    Note: we assume there can only be one device, with one SMBus interface.
 */
 
-/* #define DEBUG 1 */
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
 
 #include <linux/module.h>
 #include <linux/pci.h>
diff -puN drivers/i2c/busses/i2c-amd8111.c~linus drivers/i2c/busses/i2c-amd8111.c
--- 25/drivers/i2c/busses/i2c-amd8111.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-amd8111.c	2004-01-19 22:17:21.000000000 -0800
@@ -8,6 +8,11 @@
  * the Free Software Foundation version 2.
  */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
+
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/kernel.h>
diff -puN drivers/i2c/busses/i2c-elektor.c~linus drivers/i2c/busses/i2c-elektor.c
--- 25/drivers/i2c/busses/i2c-elektor.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-elektor.c	2004-01-19 22:17:21.000000000 -0800
@@ -25,6 +25,11 @@
 /* Partialy rewriten by Oleg I. Vdovikin for mmapped support of 
    for Alpha Processor Inc. UP-2000(+) boards */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
+
 #include <linux/kernel.h>
 #include <linux/ioport.h>
 #include <linux/module.h>
@@ -50,7 +55,6 @@ static int irq;
 static int clock  = 0x1c;
 static int own    = 0x55;
 static int mmapped;
-static int i2c_debug;
 
 /* vdovikin: removed static struct i2c_pcf_isa gpi; code - 
   this module in real supports only one device, due to missing arguments
@@ -60,12 +64,6 @@ static int i2c_debug;
 static wait_queue_head_t pcf_wait;
 static int pcf_pending;
 
-/* ----- global defines -----------------------------------------------	*/
-#define DEB(x)	if (i2c_debug>=1) x
-#define DEB2(x) if (i2c_debug>=2) x
-#define DEB3(x) if (i2c_debug>=3) x
-#define DEBE(x)	x	/* error messages 				*/
-
 /* ----- local functions ----------------------------------------------	*/
 
 static void pcf_isa_setbyte(void *data, int ctl, int val)
@@ -77,7 +75,7 @@ static void pcf_isa_setbyte(void *data, 
 		val |= I2C_PCF_ENI;
 	}
 
-	DEB3(printk(KERN_DEBUG "i2c-elektor: Write 0x%X 0x%02X\n", address, val & 255));
+	pr_debug("i2c-elektor: Write 0x%X 0x%02X\n", address, val & 255);
 
 	switch (mmapped) {
 	case 0: /* regular I/O */
@@ -98,7 +96,7 @@ static int pcf_isa_getbyte(void *data, i
 	int address = ctl ? (base + 1) : base;
 	int val = mmapped ? readb(address) : inb(address);
 
-	DEB3(printk(KERN_DEBUG "i2c-elektor: Read 0x%X 0x%02X\n", address, val));
+	pr_debug("i2c-elektor: Read 0x%X 0x%02X\n", address, val);
 
 	return (val);
 }
@@ -196,7 +194,7 @@ static int __init i2c_pcfisa_init(void) 
 			/* yeap, we've found cypress, let's check config */
 			if (!pci_read_config_byte(cy693_dev, 0x47, &config)) {
 				
-				DEB3(printk(KERN_DEBUG "i2c-elektor: found cy82c693, config register 0x47 = 0x%02x.\n", config));
+				pr_debug("i2c-elektor: found cy82c693, config register 0x47 = 0x%02x.\n", config);
 
 				/* UP2000 board has this register set to 0xe1,
                                    but the most significant bit as seems can be 
@@ -280,7 +278,6 @@ MODULE_PARM(irq, "i");
 MODULE_PARM(clock, "i");
 MODULE_PARM(own, "i");
 MODULE_PARM(mmapped, "i");
-MODULE_PARM(i2c_debug, "i");
 
 module_init(i2c_pcfisa_init);
 module_exit(i2c_pcfisa_exit);
diff -puN drivers/i2c/busses/i2c-elv.c~linus drivers/i2c/busses/i2c-elv.c
--- 25/drivers/i2c/busses/i2c-elv.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-elv.c	2004-01-19 22:17:21.000000000 -0800
@@ -21,6 +21,11 @@
 /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
    Frodo Looijaard <frodol@dds.nl> */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
+
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/delay.h>
@@ -36,12 +41,6 @@
 static int base=0;
 static unsigned char port_data = 0;
 
-/* ----- global defines -----------------------------------------------	*/
-#define DEB(x)		/* should be reasonable open, close &c. 	*/
-#define DEB2(x) 	/* low level debugging - very slow 		*/
-#define DEBE(x)	x	/* error messages 				*/
-#define DEBINIT(x) x	/* detection status messages			*/
-
 /* --- Convenience defines for the parallel port:			*/
 #define BASE	(unsigned int)(data)
 #define DATA	BASE			/* Centronics data port		*/
@@ -89,7 +88,7 @@ static int bit_elv_init(void)
 		return -ENODEV;
 
 	if (inb(base+1) & 0x80) {	/* BUSY should be high	*/
-		DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Busy was low.\n"));
+		pr_debug("i2c-elv: Busy was low.\n");
 		goto fail;
 	} 
 
@@ -97,7 +96,7 @@ static int bit_elv_init(void)
 	udelay(400);
 	if (!(inb(base+1) && 0x10)) {
 		outb(0x04,base+2);
-		DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Select was high.\n"));
+		pr_debug("i2c-elv: Select was high.\n");
 		goto fail;
 	}
 
@@ -153,7 +152,7 @@ static int __init i2c_bitelv_init(void)
 			return -ENODEV;
 		}
 	}
-	printk(KERN_DEBUG "i2c-elv.o: found device at %#x.\n",base);
+	pr_debug("i2c-elv: found device at %#x.\n",base);
 	return 0;
 }
 
diff -puN drivers/i2c/busses/i2c-frodo.c~linus drivers/i2c/busses/i2c-frodo.c
--- 25/drivers/i2c/busses/i2c-frodo.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-frodo.c	2004-01-19 22:17:21.000000000 -0800
@@ -12,6 +12,11 @@
  * version 2 as published by the Free Software Foundation.
  */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
+
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
diff -puN drivers/i2c/busses/i2c-i801.c~linus drivers/i2c/busses/i2c-i801.c
--- 25/drivers/i2c/busses/i2c-i801.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-i801.c	2004-01-19 22:17:21.000000000 -0800
@@ -38,7 +38,10 @@
 
 /* Note: we assume there can only be one I801, with one SMBus interface */
 
-/* #define DEBUG 1 */
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
 
 #include <linux/module.h>
 #include <linux/pci.h>
diff -puN drivers/i2c/busses/i2c-i810.c~linus drivers/i2c/busses/i2c-i810.c
--- 25/drivers/i2c/busses/i2c-i810.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-i810.c	2004-01-19 22:17:21.000000000 -0800
@@ -34,6 +34,11 @@
    i815			1132           
 */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
+
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
diff -puN drivers/i2c/busses/i2c-ibm_iic.c~linus drivers/i2c/busses/i2c-ibm_iic.c
--- 25/drivers/i2c/busses/i2c-ibm_iic.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-ibm_iic.c	2004-01-19 22:17:21.000000000 -0800
@@ -27,6 +27,12 @@
  * option) any later version.
  *
  */
+
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
+
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/ioport.h>
@@ -601,7 +607,7 @@ static int __devinit iic_probe(struct oc
 	
 	/* Register it with i2c layer */
 	adap = &dev->adap;
-	strcpy(adap->dev.name, "IBM IIC");
+	strcpy(adap->name, "IBM IIC");
 	i2c_set_adapdata(adap, dev);
 	adap->id = I2C_HW_OCP | iic_algo.id;
 	adap->algo = &iic_algo;
diff -puN drivers/i2c/busses/i2c-iop3xx.c~linus drivers/i2c/busses/i2c-iop3xx.c
--- 25/drivers/i2c/busses/i2c-iop3xx.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-iop3xx.c	2004-01-19 22:17:21.000000000 -0800
@@ -31,6 +31,10 @@
 
   ---------------------------------------------------------------------------*/
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
 
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
@@ -529,8 +533,3 @@ module_exit (i2c_iop3xx_exit);
 MODULE_AUTHOR("D-TACQ Solutions Ltd <www.d-tacq.com>");
 MODULE_DESCRIPTION("IOP3xx iic algorithm and driver");
 MODULE_LICENSE("GPL");
-
-MODULE_PARM(i2c_debug,"i");
-
-MODULE_PARM_DESC(i2c_debug, "debug level - 0 off; 1 normal; 2,3 more verbose; 9 iic-protocol");
-
diff -puN drivers/i2c/busses/i2c-isa.c~linus drivers/i2c/busses/i2c-isa.c
--- 25/drivers/i2c/busses/i2c-isa.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-isa.c	2004-01-19 22:17:21.000000000 -0800
@@ -24,6 +24,11 @@
    the SMBus and the ISA bus very much easier. See lm78.c for an example
    of this. */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
+
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
diff -puN drivers/i2c/busses/i2c-ite.c~linus drivers/i2c/busses/i2c-ite.c
--- 25/drivers/i2c/busses/i2c-ite.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-ite.c	2004-01-19 22:17:21.000000000 -0800
@@ -33,6 +33,11 @@
 /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
    Frodo Looijaard <frodol@dds.nl> */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
+
 #include <linux/kernel.h>
 #include <linux/ioport.h>
 #include <linux/module.h>
@@ -58,26 +63,21 @@ static int irq   = 0;
 static int clock = 0;
 static int own   = 0;
 
-static int i2c_debug=0;
 static struct iic_ite gpi;
 static wait_queue_head_t iic_wait;
 static int iic_pending;
 
-/* ----- global defines -----------------------------------------------	*/
-#define DEB(x)	if (i2c_debug>=1) x
-#define DEB2(x) if (i2c_debug>=2) x
-#define DEB3(x) if (i2c_debug>=3) x
-#define DEBE(x)	x	/* error messages 				*/
-
-
 /* ----- local functions ----------------------------------------------	*/
 
 static void iic_ite_setiic(void *data, int ctl, short val)
 {
         unsigned long j = jiffies + 10;
 
-	DEB3(printk(" Write 0x%02x to 0x%x\n",(unsigned short)val, ctl&0xff));
-	DEB3({while (time_before(jiffies, j)) schedule();})
+	pr_debug(" Write 0x%02x to 0x%x\n",(unsigned short)val, ctl&0xff);
+#ifdef DEBUG
+	while (time_before(jiffies, j))
+		schedule();
+#endif
 	outw(val,ctl);
 }
 
@@ -86,7 +86,7 @@ static short iic_ite_getiic(void *data, 
 	short val;
 
 	val = inw(ctl);
-	DEB3(printk("Read 0x%02x from 0x%x\n",(unsigned short)val, ctl&0xff));  
+	pr_debug("Read 0x%02x from 0x%x\n",(unsigned short)val, ctl&0xff);
 	return (val);
 }
 
@@ -145,7 +145,6 @@ static void iic_ite_handler(int this_irq
 	
    iic_pending = 1;
 
-   DEB2(printk("iic_ite_handler: in interrupt handler\n"));
    wake_up_interruptible(&iic_wait);
 }
 
@@ -263,7 +262,6 @@ MODULE_PARM(base, "i");
 MODULE_PARM(irq, "i");
 MODULE_PARM(clock, "i");
 MODULE_PARM(own, "i");
-MODULE_PARM(i2c_debug,"i");
 
 
 /* Called when module is loaded or when kernel is initialized.
diff -puN drivers/i2c/busses/i2c-keywest.c~linus drivers/i2c/busses/i2c-keywest.c
--- 25/drivers/i2c/busses/i2c-keywest.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-keywest.c	2004-01-19 22:17:21.000000000 -0800
@@ -43,6 +43,11 @@
     sound driver to be happy
 */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
+
 #include <linux/module.h>
 #include <linux/config.h>
 #include <linux/kernel.h>
@@ -65,20 +70,13 @@
 
 #include "i2c-keywest.h"
 
-#define DBG(x...) do {\
-	if (debug > 0) \
-		printk(KERN_DEBUG "KW:" x); \
-	} while(0)
-
 
 MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
 MODULE_DESCRIPTION("I2C driver for Apple's Keywest");
 MODULE_LICENSE("GPL");
 MODULE_PARM(probe, "i");
-MODULE_PARM(debug, "i");
 
-int probe = 0;
-int debug = 0;
+static int probe = 0;
 
 static void
 do_stop(struct keywest_iface* iface, int result)
@@ -95,7 +93,7 @@ handle_interrupt(struct keywest_iface *i
 	int ack;
 	int rearm_timer = 1;
 	
-	DBG("handle_interrupt(), got: %x, status: %x, state: %d\n",
+	pr_debug("handle_interrupt(), got: %x, status: %x, state: %d\n",
 		isr, read_reg(reg_status), iface->state);
 	if (isr == 0 && iface->state != state_stop) {
 		do_stop(iface, -1);
@@ -112,7 +110,7 @@ handle_interrupt(struct keywest_iface *i
 			break;
 		}
 		ack = read_reg(reg_status);
-		DBG("ack on set address: %x\n", ack);
+		pr_debug("ack on set address: %x\n", ack);
 		if ((ack & KW_I2C_STAT_LAST_AAK) == 0) {
 			do_stop(iface, -1);
 			break;
@@ -127,7 +125,7 @@ handle_interrupt(struct keywest_iface *i
 					| KW_I2C_CTL_AAK);
 		} else {
 			iface->state = state_write;
-			DBG("write byte: %x\n", *(iface->data));
+			pr_debug("write byte: %x\n", *(iface->data));
 			write_reg(reg_data, *(iface->data++));
 			iface->datalen--;
 		}
@@ -139,7 +137,7 @@ handle_interrupt(struct keywest_iface *i
 			break;
 		}
 		*(iface->data++) = read_reg(reg_data);
-		DBG("read byte: %x\n", *(iface->data-1));
+		pr_debug("read byte: %x\n", *(iface->data-1));
 		iface->datalen--;
 		if (iface->datalen == 0)
 			iface->state = state_stop;
@@ -153,13 +151,13 @@ handle_interrupt(struct keywest_iface *i
 		}
 		/* Check ack status */
 		ack = read_reg(reg_status);
-		DBG("ack on data write: %x\n", ack);
+		pr_debug("ack on data write: %x\n", ack);
 		if ((ack & KW_I2C_STAT_LAST_AAK) == 0) {
 			do_stop(iface, -1);
 			break;
 		}
 		if (iface->datalen) {
-			DBG("write byte: %x\n", *(iface->data));
+			pr_debug("write byte: %x\n", *(iface->data));
 			write_reg(reg_data, *(iface->data++));
 			iface->datalen--;
 		} else
@@ -203,7 +201,7 @@ keywest_timeout(unsigned long data)
 {
 	struct keywest_iface *iface = (struct keywest_iface *)data;
 
-	DBG("timeout !\n");
+	pr_debug("timeout !\n");
 	spin_lock_irq(&iface->lock);
 	if (handle_interrupt(iface, read_reg(reg_isr)))
 		mod_timer(&iface->timeout_timer, jiffies + POLL_TIMEOUT);
@@ -271,7 +269,7 @@ keywest_smbus_xfer(	struct i2c_adapter*	
 
 	down(&iface->sem);
 
-	DBG("chan: %d, addr: 0x%x, transfer len: %d, read: %d\n",
+	pr_debug("chan: %d, addr: 0x%x, transfer len: %d, read: %d\n",
 		chan->chan_no, addr, len, read_write == I2C_SMBUS_READ);
 
 	iface->data = buffer;
@@ -306,7 +304,7 @@ keywest_smbus_xfer(	struct i2c_adapter*	
 	wait_for_completion(&iface->complete);	
 
 	rc = iface->result;	
-	DBG("transfer done, result: %d\n", rc);
+	pr_debug("transfer done, result: %d\n", rc);
 
 	if (rc == 0 && size == I2C_SMBUS_WORD_DATA && read_write == I2C_SMBUS_READ)
 	    	data->word = le16_to_cpu(cur_word);
@@ -348,7 +346,7 @@ keywest_xfer(	struct i2c_adapter *adap,
 			rc = -EINVAL;
 			break;
 		}
-		DBG("xfer: chan: %d, doing %s %d bytes to 0x%02x - %d of %d messages\n",
+		pr_debug("xfer: chan: %d, doing %s %d bytes to 0x%02x - %d of %d messages\n",
 		     chan->chan_no,
 		     pmsg->flags & I2C_M_RD ? "read" : "write",
                      pmsg->len, addr, i, num);
@@ -388,7 +386,7 @@ keywest_xfer(	struct i2c_adapter *adap,
 		rc = iface->result;
 		if (rc == 0)
 			completed++;
-		DBG("transfer done, result: %d\n", rc);
+		pr_debug("transfer done, result: %d\n", rc);
 	}
 
 	/* Release sem */
diff -puN drivers/i2c/busses/i2c-nforce2.c~linus drivers/i2c/busses/i2c-nforce2.c
--- 25/drivers/i2c/busses/i2c-nforce2.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-nforce2.c	2004-01-19 22:17:21.000000000 -0800
@@ -32,6 +32,11 @@
 
 /* Note: we assume there can only be one nForce2, with two SMBus interfaces */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
+
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/kernel.h>
diff -puN /dev/null drivers/i2c/busses/i2c-parport.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/i2c/busses/i2c-parport.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,271 @@
+/* ------------------------------------------------------------------------ *
+ * i2c-parport.c I2C bus over parallel port                                 *
+ * ------------------------------------------------------------------------ *
+   Copyright (C) 2003-2004 Jean Delvare <khali@linux-fr.org>
+   
+   Based on older i2c-philips-par.c driver
+   Copyright (C) 1995-2000 Simon G. Vogl
+   With some changes from:
+   Frodo Looijaard <frodol@dds.nl>
+   Kyösti Mälkki <kmalkki@cc.hut.fi>
+   
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * ------------------------------------------------------------------------ */
+
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/parport.h>
+#include <linux/i2c.h>
+#include <linux/i2c-algo-bit.h>
+#include "i2c-parport.h"
+
+/* ----- Device list ------------------------------------------------------ */
+
+struct i2c_par {
+	struct pardevice *pdev;
+	struct i2c_adapter adapter;
+	struct i2c_algo_bit_data algo_data;
+	struct i2c_par *next;
+};
+
+static struct i2c_par *adapter_list;
+
+/* ----- Low-level parallel port access ----------------------------------- */
+
+static void port_write_data(struct parport *p, unsigned char d)
+{
+	parport_write_data(p, d);
+}
+
+static void port_write_control(struct parport *p, unsigned char d)
+{
+	parport_write_control(p, d);
+}
+
+static unsigned char port_read_data(struct parport *p)
+{
+	return parport_read_data(p);
+}
+
+static unsigned char port_read_status(struct parport *p)
+{
+	return parport_read_status(p);
+}
+
+static unsigned char port_read_control(struct parport *p)
+{
+	return parport_read_control(p);
+}
+
+static void (*port_write[])(struct parport *, unsigned char) = {
+	port_write_data,
+	NULL,
+	port_write_control,
+};
+
+static unsigned char (*port_read[])(struct parport *) = {
+	port_read_data,
+	port_read_status,
+	port_read_control,
+};
+
+/* ----- Unified line operation functions --------------------------------- */
+
+static inline void line_set(struct parport *data, int state,
+	const struct lineop *op)
+{
+	u8 oldval = port_read[op->port](data);
+
+	/* Touch only the bit(s) needed */
+	if ((op->inverted && !state) || (!op->inverted && state))
+		port_write[op->port](data, oldval | op->val);
+	else
+		port_write[op->port](data, oldval & ~op->val);
+}
+
+static inline int line_get(struct parport *data,
+	const struct lineop *op)
+{
+	u8 oldval = port_read[op->port](data);
+
+	return ((op->inverted && (oldval & op->val) != op->val)
+	    || (!op->inverted && (oldval & op->val) == op->val));
+}
+
+/* ----- I2C algorithm call-back functions and structures ----------------- */
+
+static void parport_setscl(void *data, int state)
+{
+	line_set((struct parport *) data, state, &adapter_parm[type].setscl);
+}
+
+static void parport_setsda(void *data, int state)
+{
+	line_set((struct parport *) data, state, &adapter_parm[type].setsda);
+}
+
+static int parport_getscl(void *data)
+{
+	return line_get((struct parport *) data, &adapter_parm[type].getscl);
+}
+
+static int parport_getsda(void *data)
+{
+	return line_get((struct parport *) data, &adapter_parm[type].getsda);
+}
+
+/* Encapsulate the functions above in the correct structure.
+   Note that this is only a template, from which the real structures are
+   copied. The attaching code will set getscl to NULL for adapters that
+   cannot read SCL back, and will also make the the data field point to
+   the parallel port structure. */
+static struct i2c_algo_bit_data parport_algo_data = {
+	.setsda		= parport_setsda,
+	.setscl		= parport_setscl,
+	.getsda		= parport_getsda,
+	.getscl		= parport_getscl,
+	.udelay		= 60,
+	.mdelay		= 60,
+	.timeout	= HZ,
+}; 
+
+/* ----- I2c and parallel port call-back functions and structures --------- */
+
+static struct i2c_adapter parport_adapter = {
+	.owner		= THIS_MODULE,
+	.class		= I2C_ADAP_CLASS_SMBUS,
+	.id		= I2C_HW_B_LP,
+	.name		= "Parallel port adapter",
+};
+
+static void i2c_parport_attach (struct parport *port)
+{
+	struct i2c_par *adapter;
+	
+	adapter = kmalloc(sizeof(struct i2c_par), GFP_KERNEL);
+	if (adapter == NULL) {
+		printk(KERN_ERR "i2c-parport: Failed to kmalloc\n");
+		return;
+	}
+	memset(adapter, 0x00, sizeof(struct i2c_par));
+
+	pr_debug("i2c-parport: attaching to %s\n", port->name);
+	adapter->pdev = parport_register_device(port, "i2c-parport",
+		NULL, NULL, NULL, PARPORT_FLAG_EXCL, NULL);
+	if (!adapter->pdev) {
+		printk(KERN_ERR "i2c-parport: Unable to register with parport\n");
+		goto ERROR0;
+	}
+
+	/* Fill the rest of the structure */
+	adapter->adapter = parport_adapter;
+	adapter->algo_data = parport_algo_data;
+	if (!adapter_parm[type].getscl.val)
+		adapter->algo_data.getscl = NULL;
+	adapter->algo_data.data = port;
+	adapter->adapter.algo_data = &adapter->algo_data;
+
+	if (parport_claim_or_block(adapter->pdev) < 0) {
+		printk(KERN_ERR "i2c-parport: Could not claim parallel port\n");
+		goto ERROR1;
+	}
+
+	/* Reset hardware to a sane state (SCL and SDA high) */
+	parport_setsda(port, 1);
+	parport_setscl(port, 1);
+	/* Other init if needed (power on...) */
+	if (adapter_parm[type].init.val)
+		line_set(port, 1, &adapter_parm[type].init);
+
+	parport_release(adapter->pdev);
+
+	if (i2c_bit_add_bus(&adapter->adapter) < 0) {
+		printk(KERN_ERR "i2c-parport: Unable to register with I2C\n");
+		goto ERROR1;
+	}
+
+	/* Add the new adapter to the list */
+	adapter->next = adapter_list;
+	adapter_list = adapter;
+        return;
+
+ERROR1:
+	parport_unregister_device(adapter->pdev);
+ERROR0:
+	kfree(adapter);
+}
+
+static void i2c_parport_detach (struct parport *port)
+{
+	struct i2c_par *adapter, *prev;
+
+	/* Walk the list */
+	for (prev = NULL, adapter = adapter_list; adapter;
+	     prev = adapter, adapter = adapter->next) {
+		if (adapter->pdev->port == port) {
+			/* Un-init if needed (power off...) */
+			if (adapter_parm[type].init.val)
+				line_set(port, 0, &adapter_parm[type].init);
+				
+			i2c_bit_del_bus(&adapter->adapter);
+			parport_unregister_device(adapter->pdev);
+			if (prev)
+				prev->next = adapter->next;
+			else
+				adapter_list = adapter->next;
+			kfree(adapter);
+			return;
+		}
+	}
+}
+
+static struct parport_driver i2c_driver = {
+	.name	= "i2c-parport",
+	.attach	= i2c_parport_attach,
+	.detach	= i2c_parport_detach,
+};
+
+/* ----- Module loading, unloading and information ------------------------ */
+
+static int __init i2c_parport_init(void)
+{
+	int type_count;
+
+	type_count = sizeof(adapter_parm)/sizeof(struct adapter_parm);
+	if (type < 0 || type >= type_count) {
+		printk(KERN_WARNING "i2c-parport: invalid type (%d)\n", type);
+		type = 0;
+	}
+	
+	return parport_register_driver(&i2c_driver);
+}
+
+static void __exit i2c_parport_exit(void)
+{
+	parport_unregister_driver(&i2c_driver);
+}
+
+MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
+MODULE_DESCRIPTION("I2C bus over parallel port");
+MODULE_LICENSE("GPL");
+
+module_init(i2c_parport_init);
+module_exit(i2c_parport_exit);
diff -puN /dev/null drivers/i2c/busses/i2c-parport.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/i2c/busses/i2c-parport.h	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,87 @@
+/* ------------------------------------------------------------------------ *
+ * i2c-parport.h I2C bus over parallel port                                 *
+ * ------------------------------------------------------------------------ *
+   Copyright (C) 2003-2004 Jean Delvare <khali@linux-fr.org>
+   
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * ------------------------------------------------------------------------ */
+
+#ifdef DATA
+#undef DATA
+#endif
+
+#define DATA	0
+#define STAT	1
+#define CTRL	2
+
+struct lineop {
+	u8 val;
+	u8 port;
+	u8 inverted;
+};
+
+struct adapter_parm {
+	struct lineop setsda;
+	struct lineop setscl;
+	struct lineop getsda;
+	struct lineop getscl;
+	struct lineop init;
+};
+
+static struct adapter_parm adapter_parm[] = {
+	/* type 0: Philips adapter */
+	{
+		.setsda	= { 0x80, DATA, 1 },
+		.setscl	= { 0x08, CTRL, 0 },
+		.getsda	= { 0x80, STAT, 0 },
+		.getscl	= { 0x08, STAT, 0 },
+	},
+	/* type 1: home brew teletext adapter */
+	{
+		.setsda	= { 0x02, DATA, 0 },
+		.setscl	= { 0x01, DATA, 0 },
+		.getsda	= { 0x80, STAT, 1 },
+	},
+	/* type 2: Velleman K8000 adapter */
+	{
+		.setsda	= { 0x02, CTRL, 1 },
+		.setscl	= { 0x08, CTRL, 1 },
+		.getsda	= { 0x10, STAT, 0 },
+	},
+	/* type 3: ELV adapter */
+	{
+		.setsda	= { 0x02, DATA, 1 },
+		.setscl	= { 0x01, DATA, 1 },
+		.getsda	= { 0x40, STAT, 1 },
+		.getscl	= { 0x08, STAT, 1 },
+	},
+	/* type 4: ADM 1032 evaluation board */
+	{
+		.setsda	= { 0x02, DATA, 1 },
+		.setscl	= { 0x01, DATA, 1 },
+		.getsda	= { 0x10, STAT, 1 },
+		.init	= { 0xf0, DATA, 0 },
+	},
+};
+
+static int type;
+MODULE_PARM(type, "i");
+MODULE_PARM_DESC(type,
+	"Type of adapter:\n"
+	" 0 = Philips adapter\n"
+	" 1 = home brew teletext adapter\n"
+	" 2 = Velleman K8000 adapter\n"
+	" 3 = ELV adapter\n"
+	" 4 = ADM 1032 evalulation board\n");
diff -puN /dev/null drivers/i2c/busses/i2c-parport-light.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/i2c/busses/i2c-parport-light.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,179 @@
+/* ------------------------------------------------------------------------ *
+ * i2c-parport.c I2C bus over parallel port                                 *
+ * ------------------------------------------------------------------------ *
+   Copyright (C) 2003-2004 Jean Delvare <khali@linux-fr.org>
+   
+   Based on older i2c-velleman.c driver
+   Copyright (C) 1995-2000 Simon G. Vogl
+   With some changes from:
+   Frodo Looijaard <frodol@dds.nl>
+   Kyösti Mälkki <kmalkki@cc.hut.fi>
+   
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * ------------------------------------------------------------------------ */
+
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/i2c.h>
+#include <linux/i2c-algo-bit.h>
+#include <asm/io.h>
+#include "i2c-parport.h"
+
+#define DEFAULT_BASE 0x378
+
+static int base;
+MODULE_PARM(base, "i");
+MODULE_PARM_DESC(base, "Base I/O address");
+
+/* ----- Low-level parallel port access ----------------------------------- */
+
+static inline void port_write(unsigned char p, unsigned char d)
+{
+	outb(d, base+p);
+}
+
+static inline unsigned char port_read(unsigned char p)
+{
+	return inb(base+p);
+}
+
+/* ----- Unified line operation functions --------------------------------- */
+
+static inline void line_set(int state, const struct lineop *op)
+{
+	u8 oldval = port_read(op->port);
+
+	/* Touch only the bit(s) needed */
+	if ((op->inverted && !state) || (!op->inverted && state))
+		port_write(op->port, oldval | op->val);
+	else
+		port_write(op->port, oldval & ~op->val);
+}
+
+static inline int line_get(const struct lineop *op)
+{
+	u8 oldval = port_read(op->port);
+
+	return ((op->inverted && (oldval & op->val) != op->val)
+	    || (!op->inverted && (oldval & op->val) == op->val));
+}
+
+/* ----- I2C algorithm call-back functions and structures ----------------- */
+
+static void parport_setscl(void *data, int state)
+{
+	line_set(state, &adapter_parm[type].setscl);
+}
+
+static void parport_setsda(void *data, int state)
+{
+	line_set(state, &adapter_parm[type].setsda);
+}
+
+static int parport_getscl(void *data)
+{
+	return line_get(&adapter_parm[type].getscl);
+}
+
+static int parport_getsda(void *data)
+{
+	return line_get(&adapter_parm[type].getsda);
+}
+
+/* Encapsulate the functions above in the correct structure
+   Note that getscl will be set to NULL by the attaching code for adapters
+   that cannot read SCL back */
+static struct i2c_algo_bit_data parport_algo_data = {
+	.setsda		= parport_setsda,
+	.setscl		= parport_setscl,
+	.getsda		= parport_getsda,
+	.getscl		= parport_getscl,
+	.udelay		= 50,
+	.mdelay		= 50,
+	.timeout	= HZ,
+}; 
+
+/* ----- I2c structure ---------------------------------------------------- */
+
+static struct i2c_adapter parport_adapter = {
+	.owner		= THIS_MODULE,
+	.class		= I2C_ADAP_CLASS_SMBUS,
+	.id		= I2C_HW_B_LP,
+	.algo_data	= &parport_algo_data,
+	.name		= "Parallel port adapter (light)",
+};
+
+/* ----- Module loading, unloading and information ------------------------ */
+
+static int __init i2c_parport_init(void)
+{
+	int type_count;
+
+	type_count = sizeof(adapter_parm)/sizeof(struct adapter_parm);
+	if (type < 0 || type >= type_count) {
+		printk(KERN_WARNING "i2c-parport: invalid type (%d)\n", type);
+		type = 0;
+	}
+	
+	if (base == 0) {
+		printk(KERN_INFO "i2c-parport: using default base 0x%x\n", DEFAULT_BASE);
+		base = DEFAULT_BASE;
+	}
+
+	if (!request_region(base, 3, "i2c-parport"))
+		return -ENODEV;
+
+        if (!adapter_parm[type].getscl.val)
+		parport_algo_data.getscl = NULL;
+
+	/* Reset hardware to a sane state (SCL and SDA high) */
+	parport_setsda(NULL, 1);
+	parport_setscl(NULL, 1);
+	/* Other init if needed (power on...) */
+	if (adapter_parm[type].init.val)
+		line_set(1, &adapter_parm[type].init);
+
+	if (i2c_bit_add_bus(&parport_adapter) < 0) {
+		printk(KERN_ERR "i2c-parport: Unable to register with I2C\n");
+		release_region(base, 3);
+		return -ENODEV;
+	}
+	
+	return 0;
+}
+
+static void __exit i2c_parport_exit(void)
+{
+	/* Un-init if needed (power off...) */
+	if (adapter_parm[type].init.val)
+		line_set(0, &adapter_parm[type].init);
+
+	i2c_bit_del_bus(&parport_adapter);
+	release_region(base, 3);
+}
+
+MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
+MODULE_DESCRIPTION("I2C bus over parallel port (light)");
+MODULE_LICENSE("GPL");
+
+module_init(i2c_parport_init);
+module_exit(i2c_parport_exit);
diff -puN drivers/i2c/busses/i2c-philips-par.c~linus drivers/i2c/busses/i2c-philips-par.c
--- 25/drivers/i2c/busses/i2c-philips-par.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-philips-par.c	2004-01-19 22:17:21.000000000 -0800
@@ -21,7 +21,10 @@
 /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
    Frodo Looijaard <frodol@dds.nl> */
 
-/* $Id: i2c-philips-par.c,v 1.29 2003/01/21 08:08:16 kmalkki Exp $ */
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
 
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -158,7 +161,7 @@ static void i2c_parport_attach (struct p
 	}
 	memset (adapter, 0x00, sizeof(struct i2c_par));
 
-	/* printk(KERN_DEBUG "i2c-philips-par.o: attaching to %s\n", port->name); */
+	/* pr_debug("i2c-philips-par: attaching to %s\n", port->name); */
 
 	adapter->pdev = parport_register_device(port, "i2c-philips-par",
 						NULL, NULL, NULL, 
diff -puN drivers/i2c/busses/i2c-piix4.c~linus drivers/i2c/busses/i2c-piix4.c
--- 25/drivers/i2c/busses/i2c-piix4.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-piix4.c	2004-01-19 22:17:21.000000000 -0800
@@ -28,9 +28,13 @@
    Note: we assume there can only be one device, with one SMBus interface.
 */
 
-/* #define DEBUG 1 */
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
 
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/config.h>
 #include <linux/pci.h>
 #include <linux/kernel.h>
@@ -88,13 +92,13 @@ struct sd {
 /* If force is set to anything different from 0, we forcibly enable the
    PIIX4. DANGEROUS! */
 static int force = 0;
-MODULE_PARM(force, "i");
+module_param (force, int, 0);
 MODULE_PARM_DESC(force, "Forcibly enable the PIIX4. DANGEROUS!");
 
 /* If force_addr is set to anything different from 0, we forcibly enable
    the PIIX4 at the given address. VERY DANGEROUS! */
 static int force_addr = 0;
-MODULE_PARM(force_addr, "i");
+module_param (force_addr, int, 0);
 MODULE_PARM_DESC(force_addr,
 		 "Forcibly enable the PIIX4 at the given address. "
 		 "EXTREMELY DANGEROUS!");
@@ -102,7 +106,7 @@ MODULE_PARM_DESC(force_addr,
 /* If fix_hstcfg is set to anything different from 0, we reset one of the
    registers to be a valid value. */
 static int fix_hstcfg = 0;
-MODULE_PARM(fix_hstcfg, "i");
+module_param (fix_hstcfg, int, 0);
 MODULE_PARM_DESC(fix_hstcfg,
 		"Fix config register. Needed on some boards (Force CPCI735).");
 
diff -puN drivers/i2c/busses/i2c-prosavage.c~linus drivers/i2c/busses/i2c-prosavage.c
--- 25/drivers/i2c/busses/i2c-prosavage.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-prosavage.c	2004-01-19 22:17:21.000000000 -0800
@@ -54,6 +54,11 @@
  *    (Additional documentation needed :(
  */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
+
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/pci.h>
diff -puN drivers/i2c/busses/i2c-rpx.c~linus drivers/i2c/busses/i2c-rpx.c
--- 25/drivers/i2c/busses/i2c-rpx.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-rpx.c	2004-01-19 22:17:21.000000000 -0800
@@ -11,12 +11,15 @@
  * changed to eliminate RPXLite references.
  */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
+
 #include <linux/kernel.h>
-#include <linux/ioport.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/stddef.h>
-#include <linux/parport.h>
 #include <linux/i2c.h>
 #include <linux/i2c-algo-8xx.h>
 #include <asm/mpc8xx.h>
@@ -84,7 +87,7 @@ int __init i2c_rpx_init(void)
 	rpx_iic_init(&rpx_data);
 
 	if (i2c_8xx_add_bus(&rpx_ops) < 0) {
-		printk("i2c-rpx: Unable to register with I2C\n");
+		printk(KERN_ERR "i2c-rpx: Unable to register with I2C\n");
 		return -ENODEV;
 	}
 
diff -puN drivers/i2c/busses/i2c-savage4.c~linus drivers/i2c/busses/i2c-savage4.c
--- 25/drivers/i2c/busses/i2c-savage4.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-savage4.c	2004-01-19 22:17:21.000000000 -0800
@@ -29,6 +29,11 @@
    it easier to add later.
 */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
+
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
diff -puN drivers/i2c/busses/i2c-sis5595.c~linus drivers/i2c/busses/i2c-sis5595.c
--- 25/drivers/i2c/busses/i2c-sis5595.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-sis5595.c	2004-01-19 22:17:21.000000000 -0800
@@ -55,7 +55,10 @@
  * Add adapter resets
  */
 
-/* #define DEBUG 1 */
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
 
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -311,13 +314,12 @@ static s32 sis5595_access(struct i2c_ada
 		break;
 /*
 	case I2C_SMBUS_BLOCK_DATA:
-		printk("sis5595.o: Block data not yet implemented!\n");
+		printk(KERN_WARNING "sis5595.o: Block data not yet implemented!\n");
 		return -1;
 		break;
 */
 	default:
-		printk
-		    (KERN_WARNING "sis5595.o: Unsupported transaction %d\n", size);
+		printk(KERN_WARNING "sis5595.o: Unsupported transaction %d\n", size);
 		return -1;
 	}
 
diff -puN drivers/i2c/busses/i2c-sis630.c~linus drivers/i2c/busses/i2c-sis630.c
--- 25/drivers/i2c/busses/i2c-sis630.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-sis630.c	2004-01-19 22:17:21.000000000 -0800
@@ -48,7 +48,10 @@
    Note: we assume there can only be one device, with one SMBus interface.
 */
 
-/* #define DEBUG 1 */
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
 
 #include <linux/kernel.h>
 #include <linux/module.h>
diff -puN drivers/i2c/busses/i2c-sis96x.c~linus drivers/i2c/busses/i2c-sis96x.c
--- 25/drivers/i2c/busses/i2c-sis96x.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-sis96x.c	2004-01-19 22:17:21.000000000 -0800
@@ -32,7 +32,10 @@
     We assume there can only be one SiS96x with one SMBus interface.
 */
 
-/* #define DEBUG */
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
 
 #include <linux/module.h>
 #include <linux/pci.h>
diff -puN drivers/i2c/busses/i2c-velleman.c~linus drivers/i2c/busses/i2c-velleman.c
--- 25/drivers/i2c/busses/i2c-velleman.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-velleman.c	2004-01-19 22:17:21.000000000 -0800
@@ -18,7 +18,10 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.		     */
 /* ------------------------------------------------------------------------- */
 
-/* $Id: i2c-velleman.c,v 1.29 2003/01/21 08:08:16 kmalkki Exp $ */
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
 
 #include <linux/kernel.h>
 #include <linux/ioport.h>
@@ -29,11 +32,6 @@
 #include <linux/i2c-algo-bit.h>
 #include <asm/io.h>
 
-/* ----- global defines -----------------------------------------------	*/
-#define DEB(x)		/* should be reasonable open, close &c. 	*/
-#define DEB2(x) 	/* low level debugging - very slow 		*/
-#define DEBE(x)	x	/* error messages 				*/
-
 					/* Pin Port  Inverted	name	*/
 #define I2C_SDA		0x02		/*  ctrl bit 1 	(inv)	*/
 #define I2C_SCL		0x08		/*  ctrl bit 3 	(inv)	*/
@@ -140,7 +138,7 @@ static int __init i2c_bitvelle_init(void
 			return -ENODEV;
 		}
 	}
-	printk(KERN_DEBUG "i2c-velleman: found device at %#x.\n",base);
+	pr_debug("i2c-velleman: found device at %#x.\n",base);
 	return 0;
 }
 
diff -puN drivers/i2c/busses/i2c-via.c~linus drivers/i2c/busses/i2c-via.c
--- 25/drivers/i2c/busses/i2c-via.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-via.c	2004-01-19 22:17:21.000000000 -0800
@@ -21,7 +21,10 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-#define DEBUG
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
 
 #include <linux/kernel.h>
 #include <linux/module.h>
diff -puN drivers/i2c/busses/i2c-viapro.c~linus drivers/i2c/busses/i2c-viapro.c
--- 25/drivers/i2c/busses/i2c-viapro.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-viapro.c	2004-01-19 22:17:21.000000000 -0800
@@ -33,6 +33,11 @@
    Note: we assume there can only be one device, with one SMBus interface.
 */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
+
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/kernel.h>
diff -puN drivers/i2c/busses/i2c-voodoo3.c~linus drivers/i2c/busses/i2c-voodoo3.c
--- 25/drivers/i2c/busses/i2c-voodoo3.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/i2c-voodoo3.c	2004-01-19 22:17:21.000000000 -0800
@@ -27,6 +27,11 @@
 /* This interfaces to the I2C bus of the Voodoo3 to gain access to
     the BT869 and possibly other I2C devices. */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
+
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
diff -puN drivers/i2c/busses/Kconfig~linus drivers/i2c/busses/Kconfig
--- 25/drivers/i2c/busses/Kconfig~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -3,6 +3,7 @@
 #
 
 menu "I2C Hardware Bus support"
+	depends on I2C
 
 config I2C_ALI1535
 	tristate "ALI 1535"
@@ -48,7 +49,8 @@ config I2C_AMD8111
 
 config I2C_ELEKTOR
 	tristate "Elektor ISA card"
-	depends on I2C_ALGOPCF && BROKEN_ON_SMP
+	depends on I2C && ISA && BROKEN_ON_SMP
+	select I2C_ALGOPCF
 	help
 	  This supports the PCF8584 ISA bus I2C adapter.  Say Y if you own
 	  such an adapter.
@@ -58,7 +60,8 @@ config I2C_ELEKTOR
 
 config I2C_ELV
 	tristate "ELV adapter"
-	depends on I2C_ALGOBIT && ISA
+	depends on I2C
+	select I2C_ALGOBIT
 	help
 	  This supports parallel-port I2C adapters called ELV.  Say Y if you
 	  own such an adapter.
@@ -72,19 +75,21 @@ config I2C_I801
 	help
 	  If you say yes to this option, support will be included for the Intel
 	  801 family of mainboard I2C interfaces.  Specifically, the following
-	  versions of the chipset is supported:
+	  versions of the chipset are supported:
 	    82801AA
 	    82801AB
 	    82801BA
 	    82801CA/CAM
 	    82801DB
+	    82801EB
 
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-i801.
 
 config I2C_I810
 	tristate "Intel 810/815"
-	depends on I2C_ALGOBIT && PCI && EXPERIMENTAL
+	depends on I2C && PCI && EXPERIMENTAL
+	select I2C_ALGOBIT
 	help
 	  If you say yes to this option, support will be included for the Intel
 	  810/815 family of mainboard I2C interfaces.  Specifically, the 
@@ -107,7 +112,7 @@ config I2C_IOP3XX
 
 config I2C_ISA
 	tristate "ISA Bus support"
-	depends on I2C && ISA && EXPERIMENTAL
+	depends on I2C && EXPERIMENTAL
 	help
 	  If you say yes to this option, support will be included for i2c
 	  interfaces that are on the ISA bus.
@@ -117,7 +122,8 @@ config I2C_ISA
 
 config I2C_ITE
 	tristate "ITE I2C Adapter"
-	depends on I2C_ALGOITE
+	depends on I2C && MIPS_ITE8172
+	select I2C_ALGOITE
 	help
 	  This supports the ITE8172 I2C peripheral found on some MIPS
 	  systems. Say Y if you have one of these. You should also say Y for
@@ -148,13 +154,59 @@ config I2C_NFORCE2
 
 config I2C_PHILIPSPAR
 	tristate "Philips style parallel port adapter"
-	depends on I2C_ALGOBIT && PARPORT
+	depends on I2C && PARPORT
+	select I2C_ALGOBIT
 	help
 	  This supports parallel-port I2C adapters made by Philips.
 
 	  This support is also available as a module.  If so, the module 
 	  will be called i2c-philips-par.
 
+config I2C_PARPORT
+	tristate "Parallel port adapter"
+	depends on I2C && PARPORT
+	select I2C_ALGOBIT
+	help
+	  This supports parallel port I2C adapters such as the ones made by
+	  Philips or Velleman, Analog Devices evaluation boards, and more.
+	  Basically any adapter using the parallel port as an I2C bus with
+	  no extra chipset is supported by this driver, or could be.
+
+	  This driver is a replacement for (and was inspired by) an older
+	  driver named i2c-philips-par.  The new driver supports more devices,
+	  and makes it easier to add support for new devices.
+	  
+	  Another driver exists, named i2c-parport-light, which doesn't depend
+	  on the parport driver.  This is meant for embedded systems. Don't say
+	  Y here if you intend to say Y or M there.
+
+	  This support is also available as a module.  If so, the module 
+	  will be called i2c-parport.
+
+config I2C_PARPORT_LIGHT
+	tristate "Parallel port adapter (light)"
+	depends on I2C
+	select I2C_ALGOBIT
+	help
+	  This supports parallel port I2C adapters such as the ones made by
+	  Philips or Velleman, Analog Devices evaluation boards, and more.
+	  Basically any adapter using the parallel port as an I2C bus with
+	  no extra chipset is supported by this driver, or could be.
+
+	  This driver is a light version of i2c-parport.  It doesn't depend
+	  on the parport driver, and uses direct I/O access instead.  This
+	  might be prefered on embedded systems where wasting memory for
+	  the clean but heavy parport handling is not an option.  The
+	  drawback is a reduced portability and the impossibility to
+	  dasiy-chain other parallel port devices.
+	  
+	  Don't say Y here if you said Y or M to i2c-parport.  Saying M to
+	  both is possible but both modules should not be loaded at the same
+	  time.
+
+	  This support is also available as a module.  If so, the module 
+	  will be called i2c-parport-light.
+
 config I2C_PIIX4
 	tristate "Intel PIIX4"
 	depends on I2C && PCI && EXPERIMENTAL && !64BIT
@@ -174,7 +226,8 @@ config I2C_PIIX4
 
 config I2C_PROSAVAGE
 	tristate "S3/VIA (Pro)Savage"
-	depends on I2C_ALGOBIT && PCI && EXPERIMENTAL
+	depends on I2C && PCI && EXPERIMENTAL
+	select I2C_ALGOBIT
 	help
 	  If you say yes to this option, support will be included for the
 	  I2C bus and DDC bus of the S3VIA embedded Savage4 and ProSavage8
@@ -187,12 +240,14 @@ config I2C_PROSAVAGE
 	  will be called i2c-prosavage.
 
 config I2C_RPXLITE
-	tristate "Embedded Planet RPX Lite/Classic suppoort"
-	depends on (RPXLITE || RPXCLASSIC) && I2C_ALGO8XX
+	tristate "Embedded Planet RPX Lite/Classic support"
+	depends on (RPXLITE || RPXCLASSIC) && I2C
+	select I2C_ALGO8XX
 
 config I2C_SAVAGE4
 	tristate "S3 Savage 4"
-	depends on I2C_ALGOBIT && PCI && EXPERIMENTAL
+	depends on I2C && PCI && EXPERIMENTAL
+	select I2C_ALGOBIT
 	help
 	  If you say yes to this option, support will be included for the 
 	  S3 Savage 4 I2C interface.
@@ -202,7 +257,8 @@ config I2C_SAVAGE4
 
 config SCx200_I2C
 	tristate "NatSemi SCx200 I2C using GPIO pins"
-	depends on SCx200_GPIO && I2C_ALGOBIT
+	depends on SCx200_GPIO && I2C
+	select I2C_ALGOBIT
 	help
 	  Enable the use of two GPIO pins of a SCx200 processor as an I2C bus.
 
@@ -277,7 +333,8 @@ config I2C_SIS96X
 
 config I2C_VELLEMAN
 	tristate "Velleman K8000 adapter"
-	depends on I2C_ALGOBIT && ISA
+	depends on I2C
+	select I2C_ALGOBIT
 	help
 	  This supports the Velleman K8000 parallel-port I2C adapter.  Say Y
 	  if you own such an adapter.
@@ -287,7 +344,8 @@ config I2C_VELLEMAN
 
 config I2C_VIA
 	tristate "VIA 82C586B"
-	depends on I2C_ALGOBIT && PCI && EXPERIMENTAL
+	depends on I2C && PCI && EXPERIMENTAL
+	select I2C_ALGOBIT
 	help
 
 	  If you say yes to this option, support will be included for the VIA
@@ -317,7 +375,8 @@ config I2C_VIAPRO
 
 config I2C_VOODOO3
 	tristate "Voodoo 3"
-	depends on I2C_ALGOBIT && PCI && EXPERIMENTAL
+	depends on I2C && PCI && EXPERIMENTAL
+	select I2C_ALGOBIT
 	help
 
 	  If you say yes to this option, support will be included for the
diff -puN drivers/i2c/busses/Makefile~linus drivers/i2c/busses/Makefile
--- 25/drivers/i2c/busses/Makefile~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -17,6 +17,8 @@ obj-$(CONFIG_I2C_ITE)		+= i2c-ite.o
 obj-$(CONFIG_I2C_KEYWEST)	+= i2c-keywest.o
 obj-$(CONFIG_I2C_NFORCE2)	+= i2c-nforce2.o
 obj-$(CONFIG_I2C_PHILIPSPAR)	+= i2c-philips-par.o
+obj-$(CONFIG_I2C_PARPORT)	+= i2c-parport.o
+obj-$(CONFIG_I2C_PARPORT_LIGHT)	+= i2c-parport-light.o
 obj-$(CONFIG_I2C_PIIX4)		+= i2c-piix4.o
 obj-$(CONFIG_I2C_PROSAVAGE)	+= i2c-prosavage.o
 obj-$(CONFIG_I2C_RPXLITE)	+= i2c-rpx.o
diff -puN drivers/i2c/busses/scx200_acb.c~linus drivers/i2c/busses/scx200_acb.c
--- 25/drivers/i2c/busses/scx200_acb.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/scx200_acb.c	2004-01-19 22:17:21.000000000 -0800
@@ -25,6 +25,11 @@
 */
 
 #include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
+
+#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
@@ -47,9 +52,7 @@ static int base[MAX_DEVICES] = { 0x840 }
 MODULE_PARM(base, "1-4i");
 MODULE_PARM_DESC(base, "Base addresses for the ACCESS.bus controllers");
 
-#define DEBUG 0
-
-#if DEBUG
+#ifdef DEBUG
 #define DBG(x...) printk(KERN_DEBUG NAME ": " x)
 #else
 #define DBG(x...)
@@ -374,8 +377,8 @@ static s32 scx200_acb_smbus_xfer(struct 
 	if (rc == 0 && size == I2C_SMBUS_WORD_DATA && rw == I2C_SMBUS_READ)
 	    	data->word = le16_to_cpu(cur_word);
 
-#if DEBUG
-	printk(KERN_DEBUG NAME ": transfer done, result: %d", rc);
+#ifdef DEBUG
+	DBG(": transfer done, result: %d", rc);
 	if (buffer) {
 		int i;
 		printk(" data:");
@@ -507,7 +510,7 @@ static int __init scx200_acb_init(void)
 	int i;
 	int rc;
 
-	printk(KERN_DEBUG NAME ": NatSemi SCx200 ACCESS.bus Driver\n");
+	pr_debug(NAME ": NatSemi SCx200 ACCESS.bus Driver\n");
 
 	/* Verify that this really is a SCx200 processor */
 	if (pci_find_device(PCI_VENDOR_ID_NS,
diff -puN drivers/i2c/busses/scx200_i2c.c~linus drivers/i2c/busses/scx200_i2c.c
--- 25/drivers/i2c/busses/scx200_i2c.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/busses/scx200_i2c.c	2004-01-19 22:17:21.000000000 -0800
@@ -22,6 +22,11 @@
 */
 
 #include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_BUS
+#define DEBUG	1
+#endif
+
+#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
@@ -88,15 +93,14 @@ static struct i2c_adapter scx200_i2c_ops
 
 int scx200_i2c_init(void)
 {
-	printk(KERN_DEBUG NAME ": NatSemi SCx200 I2C Driver\n");
+	pr_debug(NAME ": NatSemi SCx200 I2C Driver\n");
 
 	if (!scx200_gpio_present()) {
 		printk(KERN_ERR NAME ": no SCx200 gpio pins available\n");
 		return -ENODEV;
 	}
 
-	printk(KERN_DEBUG NAME ": SCL=GPIO%02u, SDA=GPIO%02u\n", 
-	       scl, sda);
+	pr_debug(NAME ": SCL=GPIO%02u, SDA=GPIO%02u\n", scl, sda);
 
 	if (scl == -1 || sda == -1 || scl == sda) {
 		printk(KERN_ERR NAME ": scl and sda must be specified\n");
diff -puN drivers/i2c/chips/adm1021.c~linus drivers/i2c/chips/adm1021.c
--- 25/drivers/i2c/chips/adm1021.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/chips/adm1021.c	2004-01-19 22:17:21.000000000 -0800
@@ -19,6 +19,11 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_CHIP
+#define DEBUG	1
+#endif
+
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/slab.h>
diff -puN /dev/null drivers/i2c/chips/asb100.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/i2c/chips/asb100.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,1055 @@
+/*
+    asb100.c - Part of lm_sensors, Linux kernel modules for hardware
+	        monitoring
+
+    Copyright (C) 2004 Mark M. Hoffman <mhoffman@lightlink.com>
+
+	(derived from w83781d.c)
+
+    Copyright (C) 1998 - 2003  Frodo Looijaard <frodol@dds.nl>,
+    Philip Edelbrock <phil@netroedge.com>, and
+    Mark Studebaker <mdsxyz123@yahoo.com>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+/*
+    This driver supports the hardware sensor chips: Asus ASB100 and
+    ASB100-A "BACH".
+
+    ASB100-A supports pwm1, while plain ASB100 does not.  There is no known
+    way for the driver to tell which one is there.
+
+    Chip	#vin	#fanin	#pwm	#temp	wchipid	vendid	i2c	ISA
+    asb100	7	3	1	4	0x31	0x0694	yes	no
+*/
+
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_CHIP
+#define DEBUG	1
+#endif
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/ioport.h>
+#include <linux/types.h>
+#include <linux/i2c.h>
+#include <linux/i2c-sensor.h>
+#include <linux/i2c-vid.h>
+#include <linux/init.h>
+#include <asm/errno.h>
+#include <asm/io.h>
+#include "lm75.h"
+
+/*
+	HISTORY:
+	2003-12-29	1.0.0	Ported from lm_sensors project for kernel 2.6
+*/
+#define ASB100_VERSION "1.0.0"
+
+/* I2C addresses to scan */
+static unsigned short normal_i2c[] = { I2C_CLIENT_END };
+static unsigned short normal_i2c_range[] = { 0x28, 0x2f, I2C_CLIENT_END };
+
+/* ISA addresses to scan (none) */
+static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
+static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
+
+/* default VRM to 9.0 instead of 8.2 */
+#define ASB100_DEFAULT_VRM 90
+
+/* Insmod parameters */
+SENSORS_INSMOD_1(asb100);
+I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: "
+	"{bus, clientaddr, subclientaddr1, subclientaddr2}");
+
+/* Voltage IN registers 0-6 */
+#define ASB100_REG_IN(nr)	(0x20 + (nr))
+#define ASB100_REG_IN_MAX(nr)	(0x2b + (nr * 2))
+#define ASB100_REG_IN_MIN(nr)	(0x2c + (nr * 2))
+
+/* FAN IN registers 1-3 */
+#define ASB100_REG_FAN(nr)	(0x28 + (nr))
+#define ASB100_REG_FAN_MIN(nr)	(0x3b + (nr))
+
+/* TEMPERATURE registers 1-4 */
+static const u16 asb100_reg_temp[]	= {0, 0x27, 0x150, 0x250, 0x17};
+static const u16 asb100_reg_temp_max[]	= {0, 0x39, 0x155, 0x255, 0x18};
+static const u16 asb100_reg_temp_hyst[]	= {0, 0x3a, 0x153, 0x253, 0x19};
+
+#define ASB100_REG_TEMP(nr) (asb100_reg_temp[nr])
+#define ASB100_REG_TEMP_MAX(nr) (asb100_reg_temp_max[nr])
+#define ASB100_REG_TEMP_HYST(nr) (asb100_reg_temp_hyst[nr])
+
+#define ASB100_REG_TEMP2_CONFIG	0x0152
+#define ASB100_REG_TEMP3_CONFIG	0x0252
+
+
+#define ASB100_REG_CONFIG	0x40
+#define ASB100_REG_ALARM1	0x41
+#define ASB100_REG_ALARM2	0x42
+#define ASB100_REG_SMIM1	0x43
+#define ASB100_REG_SMIM2	0x44
+#define ASB100_REG_VID_FANDIV	0x47
+#define ASB100_REG_I2C_ADDR	0x48
+#define ASB100_REG_CHIPID	0x49
+#define ASB100_REG_I2C_SUBADDR	0x4a
+#define ASB100_REG_PIN		0x4b
+#define ASB100_REG_IRQ		0x4c
+#define ASB100_REG_BANK		0x4e
+#define ASB100_REG_CHIPMAN	0x4f
+
+#define ASB100_REG_WCHIPID	0x58
+
+/* bit 7 -> enable, bits 0-3 -> duty cycle */
+#define ASB100_REG_PWM1		0x59
+
+/* CONVERSIONS
+   Rounding and limit checking is only done on the TO_REG variants. */
+
+/* These constants are a guess, consistent w/ w83781d */
+#define ASB100_IN_MIN (   0)
+#define ASB100_IN_MAX (4080)
+
+/* IN: 1/1000 V (0V to 4.08V)
+   REG: 16mV/bit */
+static u8 IN_TO_REG(unsigned val)
+{
+	unsigned nval = SENSORS_LIMIT(val, ASB100_IN_MIN, ASB100_IN_MAX);
+	return nval / 16;
+}
+
+static unsigned IN_FROM_REG(u8 reg)
+{
+	return reg * 16;
+}
+
+static u8 FAN_TO_REG(long rpm, int div)
+{
+	if (rpm == -1)
+		return 0;
+	if (rpm == 0)
+		return 255;
+	rpm = SENSORS_LIMIT(rpm, 1, 1000000);
+	return SENSORS_LIMIT((1350000 + rpm * div / 2) / (rpm * div), 1, 254);
+}
+
+static int FAN_FROM_REG(u8 val, int div)
+{
+	return val==0 ? -1 : val==255 ? 0 : 1350000/(val*div);
+}
+
+/* These constants are a guess, consistent w/ w83781d */
+#define ASB100_TEMP_MIN (-128000)
+#define ASB100_TEMP_MAX ( 127000)
+
+/* TEMP: 0.001C/bit (-128C to +127C)
+   REG: 1C/bit, two's complement */
+static u8 TEMP_TO_REG(int temp)
+{
+	int ntemp = SENSORS_LIMIT(temp, ASB100_TEMP_MIN, ASB100_TEMP_MAX);
+	ntemp += (ntemp<0 ? -500 : 500);
+	return (u8)(ntemp / 1000);
+}
+
+static int TEMP_FROM_REG(u8 reg)
+{
+	return (s8)reg * 1000;
+}
+
+/* PWM: 0 - 255 per sensors documentation
+   REG: (6.25% duty cycle per bit) */
+static u8 ASB100_PWM_TO_REG(int pwm)
+{
+	pwm = SENSORS_LIMIT(pwm, 0, 255);
+	return (u8)(pwm / 16);
+}
+
+static int ASB100_PWM_FROM_REG(u8 reg)
+{
+	return reg * 16;
+}
+
+#define ALARMS_FROM_REG(val) (val)
+
+#define DIV_FROM_REG(val) (1 << (val))
+
+/* FAN DIV: 1, 2, 4, or 8 (defaults to 2)
+   REG: 0, 1, 2, or 3 (respectively) (defaults to 1) */
+static u8 DIV_TO_REG(long val)
+{
+	return val==8 ? 3 : val==4 ? 2 : val==1 ? 0 : 1;
+}
+
+/* For each registered client, we need to keep some data in memory. That
+   data is pointed to by client->data. The structure itself is
+   dynamically allocated, at the same time the client itself is allocated. */
+struct asb100_data {
+	struct semaphore lock;
+	enum chips type;
+
+	struct semaphore update_lock;
+	unsigned long last_updated;	/* In jiffies */
+
+	/* array of 2 pointers to subclients */
+	struct i2c_client *lm75[2];
+
+	char valid;		/* !=0 if following fields are valid */
+	u8 in[7];		/* Register value */
+	u8 in_max[7];		/* Register value */
+	u8 in_min[7];		/* Register value */
+	u8 fan[3];		/* Register value */
+	u8 fan_min[3];		/* Register value */
+	u16 temp[4];		/* Register value (0 and 3 are u8 only) */
+	u16 temp_max[4];	/* Register value (0 and 3 are u8 only) */
+	u16 temp_hyst[4];	/* Register value (0 and 3 are u8 only) */
+	u8 fan_div[3];		/* Register encoding, right justified */
+	u8 pwm;			/* Register encoding */
+	u8 vid;			/* Register encoding, combined */
+	u32 alarms;		/* Register encoding, combined */
+	u8 vrm;
+};
+
+static int asb100_read_value(struct i2c_client *client, u16 reg);
+static void asb100_write_value(struct i2c_client *client, u16 reg, u16 val);
+
+static int asb100_attach_adapter(struct i2c_adapter *adapter);
+static int asb100_detect(struct i2c_adapter *adapter, int address, int kind);
+static int asb100_detach_client(struct i2c_client *client);
+static struct asb100_data *asb100_update_device(struct device *dev);
+static void asb100_init_client(struct i2c_client *client);
+
+static struct i2c_driver asb100_driver = {
+	.owner		= THIS_MODULE,
+	.name		= "asb100",
+	.id		= I2C_DRIVERID_ASB100,
+	.flags		= I2C_DF_NOTIFY,
+	.attach_adapter	= asb100_attach_adapter,
+	.detach_client	= asb100_detach_client,
+};
+
+/* 7 Voltages */
+#define show_in_reg(reg) \
+static ssize_t show_##reg (struct device *dev, char *buf, int nr) \
+{ \
+	struct asb100_data *data = asb100_update_device(dev); \
+	return sprintf(buf, "%d\n", IN_FROM_REG(data->reg[nr])); \
+}
+
+show_in_reg(in)
+show_in_reg(in_min)
+show_in_reg(in_max)
+
+#define set_in_reg(REG, reg) \
+static ssize_t set_in_##reg(struct device *dev, const char *buf, \
+		size_t count, int nr) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct asb100_data *data = i2c_get_clientdata(client); \
+	unsigned long val = simple_strtoul(buf, NULL, 10); \
+	data->in_##reg[nr] = IN_TO_REG(val); \
+	asb100_write_value(client, ASB100_REG_IN_##REG(nr), \
+		data->in_##reg[nr]); \
+	return count; \
+}
+
+set_in_reg(MIN, min)
+set_in_reg(MAX, max)
+
+#define sysfs_in(offset) \
+static ssize_t \
+	show_in##offset (struct device *dev, char *buf) \
+{ \
+	return show_in(dev, buf, 0x##offset); \
+} \
+static DEVICE_ATTR(in_input##offset, S_IRUGO, \
+		show_in##offset, NULL) \
+static ssize_t \
+	show_in##offset##_min (struct device *dev, char *buf) \
+{ \
+	return show_in_min(dev, buf, 0x##offset); \
+} \
+static ssize_t \
+	show_in##offset##_max (struct device *dev, char *buf) \
+{ \
+	return show_in_max(dev, buf, 0x##offset); \
+} \
+static ssize_t set_in##offset##_min (struct device *dev, \
+		const char *buf, size_t count) \
+{ \
+	return set_in_min(dev, buf, count, 0x##offset); \
+} \
+static ssize_t set_in##offset##_max (struct device *dev, \
+		const char *buf, size_t count) \
+{ \
+	return set_in_max(dev, buf, count, 0x##offset); \
+} \
+static DEVICE_ATTR(in_min##offset, S_IRUGO | S_IWUSR, \
+		show_in##offset##_min, set_in##offset##_min) \
+static DEVICE_ATTR(in_max##offset, S_IRUGO | S_IWUSR, \
+		show_in##offset##_max, set_in##offset##_max)
+
+sysfs_in(0)
+sysfs_in(1)
+sysfs_in(2)
+sysfs_in(3)
+sysfs_in(4)
+sysfs_in(5)
+sysfs_in(6)
+
+#define device_create_file_in(client, offset) do { \
+	device_create_file(&client->dev, &dev_attr_in_input##offset); \
+	device_create_file(&client->dev, &dev_attr_in_min##offset); \
+	device_create_file(&client->dev, &dev_attr_in_max##offset); \
+} while (0)
+
+/* 3 Fans */
+static ssize_t show_fan(struct device *dev, char *buf, int nr)
+{
+	struct asb100_data *data = asb100_update_device(dev);
+	return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr],
+		DIV_FROM_REG(data->fan_div[nr])));
+}
+
+static ssize_t show_fan_min(struct device *dev, char *buf, int nr)
+{
+	struct asb100_data *data = asb100_update_device(dev);
+	return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr],
+		DIV_FROM_REG(data->fan_div[nr])));
+}
+
+static ssize_t show_fan_div(struct device *dev, char *buf, int nr)
+{
+	struct asb100_data *data = asb100_update_device(dev);
+	return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr]));
+}
+
+static ssize_t set_fan_min(struct device *dev, const char *buf,
+				size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct asb100_data *data = i2c_get_clientdata(client);
+	u32 val = simple_strtoul(buf, NULL, 10);
+	data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
+	asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]);
+	return count;
+}
+
+/* Note: we save and restore the fan minimum here, because its value is
+   determined in part by the fan divisor.  This follows the principle of
+   least suprise; the user doesn't expect the fan minimum to change just
+   because the divisor changed. */
+static ssize_t set_fan_div(struct device *dev, const char *buf,
+				size_t count, int nr)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct asb100_data *data = i2c_get_clientdata(client);
+	unsigned long min = FAN_FROM_REG(data->fan_min[nr],
+			DIV_FROM_REG(data->fan_div[nr]));
+	unsigned long val = simple_strtoul(buf, NULL, 10);
+	int reg;
+	
+	data->fan_div[nr] = DIV_TO_REG(val);
+
+	switch(nr) {
+	case 0:	/* fan 1 */
+		reg = asb100_read_value(client, ASB100_REG_VID_FANDIV);
+		reg = (reg & 0xcf) | (data->fan_div[0] << 4);
+		asb100_write_value(client, ASB100_REG_VID_FANDIV, reg);
+		break;
+
+	case 1:	/* fan 2 */
+		reg = asb100_read_value(client, ASB100_REG_VID_FANDIV);
+		reg = (reg & 0x3f) | (data->fan_div[1] << 6);
+		asb100_write_value(client, ASB100_REG_VID_FANDIV, reg);
+		break;
+
+	case 2:	/* fan 3 */
+		reg = asb100_read_value(client, ASB100_REG_PIN);
+		reg = (reg & 0x3f) | (data->fan_div[2] << 6);
+		asb100_write_value(client, ASB100_REG_PIN, reg);
+		break;
+	}
+
+	data->fan_min[nr] =
+		FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
+	asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]);
+	return count;
+}
+
+#define sysfs_fan(offset) \
+static ssize_t show_fan##offset(struct device *dev, char *buf) \
+{ \
+	return show_fan(dev, buf, offset - 1); \
+} \
+static ssize_t show_fan##offset##_min(struct device *dev, char *buf) \
+{ \
+	return show_fan_min(dev, buf, offset - 1); \
+} \
+static ssize_t show_fan##offset##_div(struct device *dev, char *buf) \
+{ \
+	return show_fan_div(dev, buf, offset - 1); \
+} \
+static ssize_t set_fan##offset##_min(struct device *dev, const char *buf, \
+					size_t count) \
+{ \
+	return set_fan_min(dev, buf, count, offset - 1); \
+} \
+static ssize_t set_fan##offset##_div(struct device *dev, const char *buf, \
+					size_t count) \
+{ \
+	return set_fan_div(dev, buf, count, offset - 1); \
+} \
+static DEVICE_ATTR(fan_input##offset, S_IRUGO, \
+		show_fan##offset, NULL) \
+static DEVICE_ATTR(fan_min##offset, S_IRUGO | S_IWUSR, \
+		show_fan##offset##_min, set_fan##offset##_min) \
+static DEVICE_ATTR(fan_div##offset, S_IRUGO | S_IWUSR, \
+		show_fan##offset##_div, set_fan##offset##_div)
+
+sysfs_fan(1)
+sysfs_fan(2)
+sysfs_fan(3)
+
+#define device_create_file_fan(client, offset) do { \
+	device_create_file(&client->dev, &dev_attr_fan_input##offset); \
+	device_create_file(&client->dev, &dev_attr_fan_min##offset); \
+	device_create_file(&client->dev, &dev_attr_fan_div##offset); \
+} while (0)
+
+/* 4 Temp. Sensors */
+static int sprintf_temp_from_reg(u16 reg, char *buf, int nr)
+{
+	int ret = 0;
+
+	switch (nr) {
+	case 1: case 2:
+		ret = sprintf(buf, "%d\n", LM75_TEMP_FROM_REG(reg));
+		break;
+	case 0: case 3: default:
+		ret = sprintf(buf, "%d\n", TEMP_FROM_REG(reg));
+		break;
+	}
+	return ret;
+}
+		 	
+#define show_temp_reg(reg) \
+static ssize_t show_##reg(struct device *dev, char *buf, int nr) \
+{ \
+	struct asb100_data *data = asb100_update_device(dev); \
+	return sprintf_temp_from_reg(data->reg[nr], buf, nr); \
+}
+
+show_temp_reg(temp)
+show_temp_reg(temp_max)
+show_temp_reg(temp_hyst)
+
+#define set_temp_reg(REG, reg) \
+static ssize_t set_##reg(struct device *dev, const char *buf, \
+			size_t count, int nr) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct asb100_data *data = i2c_get_clientdata(client); \
+	unsigned long val = simple_strtoul(buf, NULL, 10); \
+	switch (nr) { \
+	case 1: case 2: \
+		data->reg[nr] = LM75_TEMP_TO_REG(val); \
+		break; \
+	case 0: case 3: default: \
+		data->reg[nr] = TEMP_TO_REG(val); \
+		break; \
+	} \
+	asb100_write_value(client, ASB100_REG_TEMP_##REG(nr), \
+			data->reg[nr]); \
+	return count; \
+}
+
+set_temp_reg(MAX, temp_max)
+set_temp_reg(HYST, temp_hyst)
+
+#define sysfs_temp(num) \
+static ssize_t show_temp##num(struct device *dev, char *buf) \
+{ \
+	return show_temp(dev, buf, num-1); \
+} \
+static DEVICE_ATTR(temp_input##num, S_IRUGO, show_temp##num, NULL) \
+static ssize_t show_temp_max##num(struct device *dev, char *buf) \
+{ \
+	return show_temp_max(dev, buf, num-1); \
+} \
+static ssize_t set_temp_max##num(struct device *dev, const char *buf, \
+					size_t count) \
+{ \
+	return set_temp_max(dev, buf, count, num-1); \
+} \
+static DEVICE_ATTR(temp_max##num, S_IRUGO | S_IWUSR, \
+		show_temp_max##num, set_temp_max##num) \
+static ssize_t show_temp_hyst##num(struct device *dev, char *buf) \
+{ \
+	return show_temp_hyst(dev, buf, num-1); \
+} \
+static ssize_t set_temp_hyst##num(struct device *dev, const char *buf, \
+					size_t count) \
+{ \
+	return set_temp_hyst(dev, buf, count, num-1); \
+} \
+static DEVICE_ATTR(temp_hyst##num, S_IRUGO | S_IWUSR, \
+		show_temp_hyst##num, set_temp_hyst##num)
+
+sysfs_temp(1)
+sysfs_temp(2)
+sysfs_temp(3)
+sysfs_temp(4)
+
+/* VID */
+#define device_create_file_temp(client, num) do { \
+	device_create_file(&client->dev, &dev_attr_temp_input##num); \
+	device_create_file(&client->dev, &dev_attr_temp_max##num); \
+	device_create_file(&client->dev, &dev_attr_temp_hyst##num); \
+} while (0)
+
+static ssize_t show_vid(struct device *dev, char *buf)
+{
+	struct asb100_data *data = asb100_update_device(dev);
+	return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm));
+}
+
+static DEVICE_ATTR(vid, S_IRUGO, show_vid, NULL)
+#define device_create_file_vid(client) \
+device_create_file(&client->dev, &dev_attr_vid)
+
+/* VRM */
+static ssize_t show_vrm(struct device *dev, char *buf)
+{
+	struct asb100_data *data = asb100_update_device(dev);
+	return sprintf(buf, "%d\n", data->vrm);
+}
+
+static ssize_t set_vrm(struct device *dev, const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct asb100_data *data = i2c_get_clientdata(client);
+	unsigned long val = simple_strtoul(buf, NULL, 10);
+	data->vrm = val;
+	return count;
+}
+
+/* Alarms */
+static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm)
+#define device_create_file_vrm(client) \
+device_create_file(&client->dev, &dev_attr_vrm);
+
+static ssize_t show_alarms(struct device *dev, char *buf)
+{
+	struct asb100_data *data = asb100_update_device(dev);
+	return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->alarms));
+}
+
+static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL)
+#define device_create_file_alarms(client) \
+device_create_file(&client->dev, &dev_attr_alarms)
+
+/* 1 PWM */
+static ssize_t show_pwm1(struct device *dev, char *buf)
+{
+	struct asb100_data *data = asb100_update_device(dev);
+	return sprintf(buf, "%d\n", ASB100_PWM_FROM_REG(data->pwm & 0x0f));
+}
+
+static ssize_t set_pwm1(struct device *dev, const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct asb100_data *data = i2c_get_clientdata(client);
+	unsigned long val = simple_strtoul(buf, NULL, 10);
+	data->pwm &= 0x80; /* keep the enable bit */
+	data->pwm |= (0x0f & ASB100_PWM_TO_REG(val));
+	asb100_write_value(client, ASB100_REG_PWM1, data->pwm);
+	return count;
+}
+
+static ssize_t show_pwm_enable1(struct device *dev, char *buf)
+{
+	struct asb100_data *data = asb100_update_device(dev);
+	return sprintf(buf, "%d\n", (data->pwm & 0x80) ? 1 : 0);
+}
+
+static ssize_t set_pwm_enable1(struct device *dev, const char *buf,
+				size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct asb100_data *data = i2c_get_clientdata(client);
+	unsigned long val = simple_strtoul(buf, NULL, 10);
+	data->pwm &= 0x0f; /* keep the duty cycle bits */
+	data->pwm |= (val ? 0x80 : 0x00);
+	asb100_write_value(client, ASB100_REG_PWM1, data->pwm);
+	return count;
+}
+
+static DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm1, set_pwm1)
+static DEVICE_ATTR(pwm_enable1, S_IRUGO | S_IWUSR,
+		show_pwm_enable1, set_pwm_enable1)
+#define device_create_file_pwm1(client) do { \
+	device_create_file(&new_client->dev, &dev_attr_pwm1); \
+	device_create_file(&new_client->dev, &dev_attr_pwm_enable1); \
+} while (0)
+
+/* This function is called when:
+	asb100_driver is inserted (when this module is loaded), for each
+		available adapter
+	when a new adapter is inserted (and asb100_driver is still present)
+ */
+static int asb100_attach_adapter(struct i2c_adapter *adapter)
+{
+	if (!(adapter->class & I2C_ADAP_CLASS_SMBUS))
+		return 0;
+	return i2c_detect(adapter, &addr_data, asb100_detect);
+}
+
+static int asb100_detect_subclients(struct i2c_adapter *adapter, int address,
+		int kind, struct i2c_client *new_client)
+{
+	int i, id, err;
+	struct asb100_data *data = i2c_get_clientdata(new_client);
+
+	data->lm75[0] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
+	if (!(data->lm75[0])) {
+		err = -ENOMEM;
+		goto ERROR_SC_0;
+	}
+	memset(data->lm75[0], 0x00, sizeof(struct i2c_client));
+
+	data->lm75[1] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
+	if (!(data->lm75[1])) {
+		err = -ENOMEM;
+		goto ERROR_SC_1;
+	}
+	memset(data->lm75[1], 0x00, sizeof(struct i2c_client));
+
+	id = i2c_adapter_id(adapter);
+
+	if (force_subclients[0] == id && force_subclients[1] == address) {
+		for (i = 2; i <= 3; i++) {
+			if (force_subclients[i] < 0x48 ||
+			    force_subclients[i] > 0x4f) {
+				dev_err(&new_client->dev, "invalid subclient "
+					"address %d; must be 0x48-0x4f\n",
+					force_subclients[i]);
+				err = -ENODEV;
+				goto ERROR_SC_2;
+			}
+		}
+		asb100_write_value(new_client, ASB100_REG_I2C_SUBADDR,
+					(force_subclients[2] & 0x07) |
+					((force_subclients[3] & 0x07) <<4));
+		data->lm75[0]->addr = force_subclients[2];
+		data->lm75[1]->addr = force_subclients[3];
+	} else {
+		int val = asb100_read_value(new_client, ASB100_REG_I2C_SUBADDR);
+		data->lm75[0]->addr = 0x48 + (val & 0x07);
+		data->lm75[1]->addr = 0x48 + ((val >> 4) & 0x07);
+	}
+
+	if(data->lm75[0]->addr == data->lm75[1]->addr) {
+		dev_err(&new_client->dev, "duplicate addresses 0x%x "
+				"for subclients\n", data->lm75[0]->addr);
+		err = -ENODEV;
+		goto ERROR_SC_2;
+	}
+
+	for (i = 0; i <= 1; i++) {
+		i2c_set_clientdata(data->lm75[i], NULL);
+		data->lm75[i]->adapter = adapter;
+		data->lm75[i]->driver = &asb100_driver;
+		data->lm75[i]->flags = 0;
+		strlcpy(data->lm75[i]->name, "asb100 subclient", I2C_NAME_SIZE);
+	}
+
+	if ((err = i2c_attach_client(data->lm75[0]))) {
+		dev_err(&new_client->dev, "subclient %d registration "
+			"at address 0x%x failed.\n", i, data->lm75[0]->addr);
+		goto ERROR_SC_2;
+	}
+
+	if ((err = i2c_attach_client(data->lm75[1]))) {
+		dev_err(&new_client->dev, "subclient %d registration "
+			"at address 0x%x failed.\n", i, data->lm75[1]->addr);
+		goto ERROR_SC_3;
+	}
+
+	return 0;
+
+/* Undo inits in case of errors */
+ERROR_SC_3:
+	i2c_detach_client(data->lm75[0]);
+ERROR_SC_2:
+	kfree(data->lm75[1]);
+ERROR_SC_1:
+	kfree(data->lm75[0]);
+ERROR_SC_0:
+	return err;
+}
+
+static int asb100_detect(struct i2c_adapter *adapter, int address, int kind)
+{
+	int err;
+	struct i2c_client *new_client;
+	struct asb100_data *data;
+
+	/* asb100 is SMBus only */
+	if (i2c_is_isa_adapter(adapter)) {
+		pr_debug("asb100.o: detect failed, "
+				"cannot attach to legacy adapter!\n");
+		err = -ENODEV;
+		goto ERROR0;
+	}
+
+	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
+		pr_debug("asb100.o: detect failed, "
+				"smbus byte data not supported!\n");
+		err = -ENODEV;
+		goto ERROR0;
+	}
+
+	/* OK. For now, we presume we have a valid client. We now create the
+	   client structure, even though we cannot fill it completely yet.
+	   But it allows us to access asb100_{read,write}_value. */
+
+	if (!(new_client = kmalloc(sizeof(struct i2c_client) +
+			sizeof(struct asb100_data), GFP_KERNEL))) {
+		pr_debug("asb100.o: detect failed, kmalloc failed!\n");
+		err = -ENOMEM;
+		goto ERROR0;
+	}
+
+	memset(new_client, 0,
+		sizeof(struct i2c_client) + sizeof(struct asb100_data));
+
+	data = (struct asb100_data *) (new_client + 1);
+	init_MUTEX(&data->lock);
+	i2c_set_clientdata(new_client, data);
+	new_client->addr = address;
+	new_client->adapter = adapter;
+	new_client->driver = &asb100_driver;
+	new_client->flags = 0;
+
+	/* Now, we do the remaining detection. */
+
+	/* The chip may be stuck in some other bank than bank 0. This may
+	   make reading other information impossible. Specify a force=... or
+	   force_*=... parameter, and the chip will be reset to the right
+	   bank. */
+	if (kind < 0) {
+
+		int val1 = asb100_read_value(new_client, ASB100_REG_BANK);
+		int val2 = asb100_read_value(new_client, ASB100_REG_CHIPMAN);
+
+		/* If we're in bank 0 */
+		if ( (!(val1 & 0x07)) &&
+				/* Check for ASB100 ID (low byte) */
+				( ((!(val1 & 0x80)) && (val2 != 0x94)) ||
+				/* Check for ASB100 ID (high byte ) */
+				((val1 & 0x80) && (val2 != 0x06)) ) ) {
+			pr_debug("asb100.o: detect failed, "
+					"bad chip id 0x%02x!\n", val2);
+			err = -ENODEV;
+			goto ERROR1;
+		}
+
+	} /* kind < 0 */
+
+	/* We have either had a force parameter, or we have already detected
+	   Winbond. Put it now into bank 0 and Vendor ID High Byte */
+	asb100_write_value(new_client, ASB100_REG_BANK,
+		(asb100_read_value(new_client, ASB100_REG_BANK) & 0x78) | 0x80);
+
+	/* Determine the chip type. */
+	if (kind <= 0) {
+		int val1 = asb100_read_value(new_client, ASB100_REG_WCHIPID);
+		int val2 = asb100_read_value(new_client, ASB100_REG_CHIPMAN);
+
+		if ((val1 == 0x31) && (val2 == 0x06))
+			kind = asb100;
+		else {
+			if (kind == 0)
+				dev_warn(&new_client->dev, "ignoring "
+					"'force' parameter for unknown chip "
+					"at adapter %d, address 0x%02x.\n",
+					i2c_adapter_id(adapter), address);
+			err = -ENODEV;
+			goto ERROR1;
+		}
+	}
+
+	/* Fill in remaining client fields and put it into the global list */
+	strlcpy(new_client->name, "asb100", I2C_NAME_SIZE);
+	data->type = kind;
+
+	data->valid = 0;
+	init_MUTEX(&data->update_lock);
+
+	/* Tell the I2C layer a new client has arrived */
+	if ((err = i2c_attach_client(new_client)))
+		goto ERROR1;
+
+	/* Attach secondary lm75 clients */
+	if ((err = asb100_detect_subclients(adapter, address, kind,
+			new_client)))
+		goto ERROR2;
+
+	/* Initialize the chip */
+	asb100_init_client(new_client);
+
+	/* Register sysfs hooks */
+	device_create_file_in(new_client, 0);
+	device_create_file_in(new_client, 1);
+	device_create_file_in(new_client, 2);
+	device_create_file_in(new_client, 3);
+	device_create_file_in(new_client, 4);
+	device_create_file_in(new_client, 5);
+	device_create_file_in(new_client, 6);
+
+	device_create_file_fan(new_client, 1);
+	device_create_file_fan(new_client, 2);
+	device_create_file_fan(new_client, 3);
+
+	device_create_file_temp(new_client, 1);
+	device_create_file_temp(new_client, 2);
+	device_create_file_temp(new_client, 3);
+	device_create_file_temp(new_client, 4);
+
+	device_create_file_vid(new_client);
+	device_create_file_vrm(new_client);
+
+	device_create_file_alarms(new_client);
+
+	device_create_file_pwm1(new_client);
+
+	return 0;
+
+ERROR2:
+	i2c_detach_client(new_client);
+ERROR1:
+	kfree(new_client);
+ERROR0:
+	return err;
+}
+
+static int asb100_detach_client(struct i2c_client *client)
+{
+	int err;
+
+	if ((err = i2c_detach_client(client))) {
+		dev_err(&client->dev, "client deregistration failed; "
+			"client not detached.\n");
+		return err;
+	}
+
+	kfree(client);
+
+	return 0;
+}
+
+static u16 swap_bytes(u16 val)
+{
+	return (val >> 8) | (val << 8);
+}
+
+/* The SMBus locks itself, usually, but nothing may access the chip between
+   bank switches. */
+static int asb100_read_value(struct i2c_client *client, u16 reg)
+{
+	struct asb100_data *data = i2c_get_clientdata(client);
+	struct i2c_client *cl;
+	int res, bank;
+
+	down(&data->lock);
+
+	bank = (reg >> 8) & 0x0f;
+	if (bank > 2)
+		/* switch banks */
+		i2c_smbus_write_byte_data(client, ASB100_REG_BANK, bank);
+
+	if (bank == 0 || bank > 2) {
+		res = i2c_smbus_read_byte_data(client, reg & 0xff);
+	} else {
+		/* switch to subclient */
+		cl = data->lm75[bank - 1];
+
+		/* convert from ISA to LM75 I2C addresses */
+		switch (reg & 0xff) {
+		case 0x50: /* TEMP */
+			res = swap_bytes(i2c_smbus_read_word_data (cl, 0));
+			break;
+		case 0x52: /* CONFIG */
+			res = i2c_smbus_read_byte_data(cl, 1);
+			break;
+		case 0x53: /* HYST */
+			res = swap_bytes(i2c_smbus_read_word_data (cl, 2));
+			break;
+		case 0x55: /* MAX */
+		default:
+			res = swap_bytes(i2c_smbus_read_word_data (cl, 3));
+			break;
+		}
+	}
+
+	if (bank > 2)
+		i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0);
+
+	up(&data->lock);
+
+	return res;
+}
+
+static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value)
+{
+	struct asb100_data *data = i2c_get_clientdata(client);
+	struct i2c_client *cl;
+	int bank;
+
+	down(&data->lock);
+
+	bank = (reg >> 8) & 0x0f;
+	if (bank > 2)
+		/* switch banks */
+		i2c_smbus_write_byte_data(client, ASB100_REG_BANK, bank);
+
+	if (bank == 0 || bank > 2) {
+		i2c_smbus_write_byte_data(client, reg & 0xff, value & 0xff);
+	} else {
+		/* switch to subclient */
+		cl = data->lm75[bank - 1];
+
+		/* convert from ISA to LM75 I2C addresses */
+		switch (reg & 0xff) {
+		case 0x52: /* CONFIG */
+			i2c_smbus_write_byte_data(cl, 1, value & 0xff);
+			break;
+		case 0x53: /* HYST */
+			i2c_smbus_write_word_data(cl, 2, swap_bytes(value));
+			break;
+		case 0x55: /* MAX */
+			i2c_smbus_write_word_data(cl, 3, swap_bytes(value));
+			break;
+		}
+	}
+
+	if (bank > 2)
+		i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0);
+
+	up(&data->lock);
+}
+
+static void asb100_init_client(struct i2c_client *client)
+{
+	struct asb100_data *data = i2c_get_clientdata(client);
+	int vid = 0;
+
+	vid = asb100_read_value(client, ASB100_REG_VID_FANDIV) & 0x0f;
+	vid |= (asb100_read_value(client, ASB100_REG_CHIPID) & 0x01) << 4;
+	data->vrm = ASB100_DEFAULT_VRM;
+	vid = vid_from_reg(vid, data->vrm);
+
+	/* Start monitoring */
+	asb100_write_value(client, ASB100_REG_CONFIG, 
+		(asb100_read_value(client, ASB100_REG_CONFIG) & 0xf7) | 0x01);
+}
+
+static struct asb100_data *asb100_update_device(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct asb100_data *data = i2c_get_clientdata(client);
+	int i;
+
+	down(&data->update_lock);
+
+	if (time_after(jiffies - data->last_updated, (unsigned long)(HZ+HZ/2))
+		|| time_before(jiffies, data->last_updated) || !data->valid) {
+
+		dev_dbg(&client->dev, "starting device update...\n");
+
+		/* 7 voltage inputs */
+		for (i = 0; i < 7; i++) {
+			data->in[i] = asb100_read_value(client,
+				ASB100_REG_IN(i));
+			data->in_min[i] = asb100_read_value(client,
+				ASB100_REG_IN_MIN(i));
+			data->in_max[i] = asb100_read_value(client,
+				ASB100_REG_IN_MAX(i));
+		}
+
+		/* 3 fan inputs */
+		for (i = 0; i < 3; i++) {
+			data->fan[i] = asb100_read_value(client,
+					ASB100_REG_FAN(i));
+			data->fan_min[i] = asb100_read_value(client,
+					ASB100_REG_FAN_MIN(i));
+		}
+
+		/* 4 temperature inputs */
+		for (i = 1; i <= 4; i++) {
+			data->temp[i-1] = asb100_read_value(client,
+					ASB100_REG_TEMP(i));
+			data->temp_max[i-1] = asb100_read_value(client,
+					ASB100_REG_TEMP_MAX(i));
+			data->temp_hyst[i-1] = asb100_read_value(client,
+					ASB100_REG_TEMP_HYST(i));
+		}
+
+		/* VID and fan divisors */
+		i = asb100_read_value(client, ASB100_REG_VID_FANDIV);
+		data->vid = i & 0x0f;
+		data->vid |= (asb100_read_value(client,
+				ASB100_REG_CHIPID) & 0x01) << 4;
+		data->fan_div[0] = (i >> 4) & 0x03;
+		data->fan_div[1] = (i >> 6) & 0x03;
+		data->fan_div[2] = (asb100_read_value(client,
+				ASB100_REG_PIN) >> 6) & 0x03;
+
+		/* PWM */
+		data->pwm = asb100_read_value(client, ASB100_REG_PWM1);
+
+		/* alarms */
+		data->alarms = asb100_read_value(client, ASB100_REG_ALARM1) +
+			(asb100_read_value(client, ASB100_REG_ALARM2) << 8);
+
+		data->last_updated = jiffies;
+		data->valid = 1;
+
+		dev_dbg(&client->dev, "... device update complete\n");
+	}
+
+	up(&data->update_lock);
+
+	return data;
+}
+
+static int __init asb100_init(void)
+{
+	return i2c_add_driver(&asb100_driver);
+}
+
+static void __exit asb100_exit(void)
+{
+	i2c_del_driver(&asb100_driver);
+}
+
+MODULE_AUTHOR("Mark M. Hoffman <mhoffman@lightlink.com>");
+MODULE_DESCRIPTION("ASB100 Bach driver");
+MODULE_LICENSE("GPL");
+
+module_init(asb100_init);
+module_exit(asb100_exit);
+
diff -puN drivers/i2c/chips/eeprom.c~linus drivers/i2c/chips/eeprom.c
--- 25/drivers/i2c/chips/eeprom.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/chips/eeprom.c	2004-01-19 22:17:21.000000000 -0800
@@ -6,6 +6,11 @@
     Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
     Copyright (C) 2003 IBM Corp.
 
+    2004-01-16  Jean Delvare <khali@linux-fr.org>
+    Divide the eeprom in 32-byte (arbitrary) slices. This significantly
+    speeds sensors up, as well as various scripts using the eeprom
+    module.
+
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
@@ -21,12 +26,16 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-/* #define DEBUG */
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_CHIP
+#define DEBUG	1
+#endif
 
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <linux/sched.h>
 #include <linux/i2c.h>
 #include <linux/i2c-sensor.h>
 
@@ -59,9 +68,10 @@ enum eeprom_nature {
 /* Each client has this additional data */
 struct eeprom_data {
 	struct semaphore update_lock;
-	char valid;			/* !=0 if following fields are valid */
-	unsigned long last_updated;	/* In jiffies */
+	u8 valid;			/* bitfield, bit!=0 if slice is valid */
+	unsigned long last_updated[8];	/* In jiffies, 8 slices */
 	u8 data[EEPROM_SIZE];		/* Register values */
+	enum eeprom_nature nature;
 };
 
 
@@ -81,35 +91,36 @@ static struct i2c_driver eeprom_driver =
 
 static int eeprom_id = 0;
 
-static void eeprom_update_client(struct i2c_client *client)
+static void eeprom_update_client(struct i2c_client *client, u8 slice)
 {
 	struct eeprom_data *data = i2c_get_clientdata(client);
 	int i, j;
 
 	down(&data->update_lock);
 
-	if ((jiffies - data->last_updated > 300 * HZ) |
-	    (jiffies < data->last_updated) || !data->valid) {
-		dev_dbg(&client->dev, "Starting eeprom update\n");
+	if (!(data->valid & (1 << slice)) ||
+	    (jiffies - data->last_updated[slice] > 300 * HZ) ||
+	    (jiffies < data->last_updated[slice])) {
+		dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice);
 
 		if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
-			for (i=0; i < EEPROM_SIZE; i += I2C_SMBUS_I2C_BLOCK_MAX)
+			for (i = slice << 5; i < (slice + 1) << 5; i += I2C_SMBUS_I2C_BLOCK_MAX)
 				if (i2c_smbus_read_i2c_block_data(client, i, data->data + i) != I2C_SMBUS_I2C_BLOCK_MAX)
 					goto exit;
 		} else {
-			if (i2c_smbus_write_byte(client, 0)) {
+			if (i2c_smbus_write_byte(client, slice << 5)) {
 				dev_dbg(&client->dev, "eeprom read start has failed!\n");
 				goto exit;
 			}
-			for (i = 0; i < EEPROM_SIZE; i++) {
+			for (i = slice << 5; i < (slice + 1) << 5; i++) {
 				j = i2c_smbus_read_byte(client);
 				if (j < 0)
 					goto exit;
 				data->data[i] = (u8) j;
 			}
 		}
-		data->last_updated = jiffies;
-		data->valid = 1;
+		data->last_updated[slice] = jiffies;
+		data->valid |= (1 << slice);
 	}
 exit:
 	up(&data->update_lock);
@@ -119,15 +130,27 @@ static ssize_t eeprom_read(struct kobjec
 {
 	struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj));
 	struct eeprom_data *data = i2c_get_clientdata(client);
-
-	eeprom_update_client(client);
+	u8 slice;
 
 	if (off > EEPROM_SIZE)
 		return 0;
 	if (off + count > EEPROM_SIZE)
 		count = EEPROM_SIZE - off;
 
-	memcpy(buf, &data->data[off], count);
+	/* Only refresh slices which contain requested bytes */
+	for (slice = off >> 5; slice <= (off + count - 1) >> 5; slice++)
+		eeprom_update_client(client, slice);
+
+	/* Hide Vaio security settings to regular users (16 first bytes) */
+	if (data->nature == VAIO && off < 16 && !capable(CAP_SYS_ADMIN)) {
+		int in_row1 = 16 - off;
+		memset(buf, 0, in_row1);
+		if (count - in_row1 > 0)
+			memcpy(buf + in_row1, &data->data[16], count - in_row1);
+	} else {
+		memcpy(buf, &data->data[off], count);
+	}
+
 	return count;
 }
 
@@ -151,7 +174,6 @@ int eeprom_detect(struct i2c_adapter *ad
 	int i, cs;
 	struct i2c_client *new_client;
 	struct eeprom_data *data;
-	enum eeprom_nature nature = UNKNOWN;
 	int err = 0;
 
 	/* Make sure we aren't probing the ISA bus!! This is just a safety check
@@ -199,6 +221,7 @@ int eeprom_detect(struct i2c_adapter *ad
 			goto exit_kfree;
 	}
 
+	data->nature = UNKNOWN;
 	/* Detect the Vaio nature of EEPROMs.
 	   We use the "PCG-" prefix as the signature. */
 	if (address == 0x57) {
@@ -206,17 +229,7 @@ int eeprom_detect(struct i2c_adapter *ad
 		    i2c_smbus_read_byte_data(new_client, 0x81) == 'C' && 
 		    i2c_smbus_read_byte_data(new_client, 0x82) == 'G' &&
 		    i2c_smbus_read_byte_data(new_client, 0x83) == '-')
-			nature = VAIO;
-	}
-
-	/* If this is a VIAO, then we only allow root to read from this file,
-	   as BIOS passwords can be present here in plaintext */
-	switch (nature) {
- 	case VAIO:
-		eeprom_attr.attr.mode = S_IRUSR;
-		break;
-	default:
-		eeprom_attr.attr.mode = S_IRUGO;
+			data->nature = VAIO;
 	}
 
 	/* Fill in the remaining client fields */
diff -puN drivers/i2c/chips/it87.c~linus drivers/i2c/chips/it87.c
--- 25/drivers/i2c/chips/it87.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/chips/it87.c	2004-01-19 22:17:21.000000000 -0800
@@ -31,6 +31,11 @@
     type at module load time.
 */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_CHIP
+#define DEBUG	1
+#endif
+
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/slab.h>
@@ -667,10 +672,10 @@ int it87_detect(struct i2c_adapter *adap
 		}
 		else {
 			if (kind == 0)
-				printk
-				    ("it87.o: Ignoring 'force' parameter for unknown chip at "
-				     "adapter %d, address 0x%02x\n",
-				     i2c_adapter_id(adapter), address);
+				dev_info(&adapter->dev, 
+					"Ignoring 'force' parameter for unknown chip at "
+					"adapter %d, address 0x%02x\n",
+					i2c_adapter_id(adapter), address);
 			goto ERROR1;
 		}
 	}
diff -puN drivers/i2c/chips/Kconfig~linus drivers/i2c/chips/Kconfig
--- 25/drivers/i2c/chips/Kconfig~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/chips/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -3,6 +3,7 @@
 #
 
 menu "I2C Hardware Sensors Chip support"
+	depends on I2C
 
 config I2C_SENSOR
 	tristate
@@ -21,6 +22,17 @@ config SENSORS_ADM1021
 	  This driver can also be built as a module.  If so, the module
 	  will be called adm1021.
 
+config SENSORS_ASB100
+	tristate "Asus ASB100 Bach"
+	depends on I2C && EXPERIMENTAL
+	select I2C_SENSOR
+	help
+	  If you say yes here you get support for the ASB100 Bach sensor
+	  chip found on some Asus mainboards.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called asb100.
+
 config SENSORS_EEPROM
 	tristate "EEPROM (DIMM) reader"
 	depends on I2C && EXPERIMENTAL
@@ -90,10 +102,22 @@ config SENSORS_LM85
 	  This driver can also be built as a module.  If so, the module
 	  will be called lm85.
 
+config SENSORS_LM90
+	tristate "National Semiconductor LM90 and compatibles"
+	depends on I2C && EXPERIMENTAL
+	select I2C_SENSOR
+	help
+	  If you say yes here you get support for National Semiconductor LM90
+	  and Analog Devices ADM1032 sensor chips.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called lm90.
+
 config SENSORS_VIA686A
 	tristate "VIA686A"
 	depends on I2C && EXPERIMENTAL
 	select I2C_SENSOR
+	select I2C_ISA
 	help
 	  If you say yes here you get support for the integrated sensors in
 	  Via 686A/B South Bridges.
@@ -113,4 +137,16 @@ config SENSORS_W83781D
 	  This driver can also be built as a module.  If so, the module
 	  will be called w83781d.
 
+config SENSORS_W83L785TS
+	tristate "Winbond W83L785TS-S"
+	depends on I2C && EXPERIMENTAL
+	select I2C_SENSOR
+	help
+	  If you say yes here you get support for the Winbond W83L785TS-S
+	  sensor chip, which is used on the Asus A7N8X, among other
+	  motherboards.
+	  
+	  This driver can also be built as a module.  If so, the module
+	  will be called w83l785ts.
+
 endmenu
diff -puN drivers/i2c/chips/lm75.c~linus drivers/i2c/chips/lm75.c
--- 25/drivers/i2c/chips/lm75.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/chips/lm75.c	2004-01-19 22:17:21.000000000 -0800
@@ -18,7 +18,10 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-/* #define DEBUG 1 */
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_CHIP
+#define DEBUG	1
+#endif
 
 #include <linux/module.h>
 #include <linux/init.h>
diff -puN drivers/i2c/chips/lm78.c~linus drivers/i2c/chips/lm78.c
--- 25/drivers/i2c/chips/lm78.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/chips/lm78.c	2004-01-19 22:17:21.000000000 -0800
@@ -18,6 +18,11 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_CHIP
+#define DEBUG	1
+#endif
+
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/slab.h>
@@ -615,7 +620,7 @@ int lm78_detect(struct i2c_adapter *adap
 			kind = lm79;
 		else {
 			if (kind == 0)
-				printk(KERN_WARNING "lm78.o: Ignoring 'force' "
+				dev_warn(&adapter->dev, "Ignoring 'force' "
 					"parameter for unknown chip at "
 					"adapter %d, address 0x%02x\n",
 					i2c_adapter_id(adapter), address);
diff -puN drivers/i2c/chips/lm83.c~linus drivers/i2c/chips/lm83.c
--- 25/drivers/i2c/chips/lm83.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/chips/lm83.c	2004-01-19 22:17:21.000000000 -0800
@@ -27,6 +27,11 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_CHIP
+#define DEBUG	1
+#endif
+
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/slab.h>
@@ -270,7 +275,7 @@ static int lm83_detect(struct i2c_adapte
 		    & 0x48) != 0x00) ||
 		    ((i2c_smbus_read_byte_data(new_client, LM83_REG_R_CONFIG)
 		    & 0x41) != 0x00)) {
-			dev_dbg(&client->dev,
+			dev_dbg(&adapter->dev,
 			    "LM83 detection failed at 0x%02x.\n", address);
 			goto exit_free;
 		}
diff -puN drivers/i2c/chips/lm85.c~linus drivers/i2c/chips/lm85.c
--- 25/drivers/i2c/chips/lm85.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/chips/lm85.c	2004-01-19 22:17:21.000000000 -0800
@@ -22,6 +22,11 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_CHIP
+#define DEBUG	1
+#endif
+
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/slab.h>
diff -puN /dev/null drivers/i2c/chips/lm90.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/i2c/chips/lm90.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,525 @@
+/*
+ * lm90.c - Part of lm_sensors, Linux kernel modules for hardware
+ *          monitoring
+ * Copyright (C) 2003  Jean Delvare <khali@linux-fr.org>
+ *
+ * Based on the lm83 driver. The LM90 is a sensor chip made by National
+ * Semiconductor. It reports up to two temperatures (its own plus up to
+ * one external one) with a 0.125 deg resolution (1 deg for local
+ * temperature) and a 3-4 deg accuracy. Complete datasheet can be
+ * obtained from National's website at:
+ *   http://www.national.com/pf/LM/LM90.html
+ *
+ * This driver also supports the ADM1032, a sensor chip made by Analog
+ * Devices. That chip is similar to the LM90, with a few differences
+ * that are not handled by this driver. Complete datasheet can be
+ * obtained from Analog's website at:
+ *   http://products.analog.com/products/info.asp?product=ADM1032
+ *
+ * Since the LM90 was the first chipset supported by this driver, most
+ * comments will refer to this chipset, but are actually general and
+ * concern all supported chipsets, unless mentioned otherwise.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_CHIP
+#define DEBUG	1
+#endif
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/i2c-sensor.h>
+
+/*
+ * Addresses to scan
+ * Address is fully defined internally and cannot be changed.
+ */
+
+static unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END };
+static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
+static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
+static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
+
+/*
+ * Insmod parameters
+ */
+
+SENSORS_INSMOD_2(lm90, adm1032);
+
+/*
+ * The LM90 registers
+ */
+
+#define LM90_REG_R_MAN_ID		0xFE
+#define LM90_REG_R_CHIP_ID		0xFF
+#define LM90_REG_R_CONFIG1		0x03
+#define LM90_REG_W_CONFIG1		0x09
+#define LM90_REG_R_CONFIG2		0xBF
+#define LM90_REG_W_CONFIG2		0xBF
+#define LM90_REG_R_CONVRATE		0x04
+#define LM90_REG_W_CONVRATE		0x0A
+#define LM90_REG_R_STATUS		0x02
+#define LM90_REG_R_LOCAL_TEMP		0x00
+#define LM90_REG_R_LOCAL_HIGH		0x05
+#define LM90_REG_W_LOCAL_HIGH		0x0B
+#define LM90_REG_R_LOCAL_LOW		0x06
+#define LM90_REG_W_LOCAL_LOW		0x0C
+#define LM90_REG_R_LOCAL_CRIT		0x20
+#define LM90_REG_W_LOCAL_CRIT		0x20
+#define LM90_REG_R_REMOTE_TEMPH		0x01
+#define LM90_REG_R_REMOTE_TEMPL		0x10
+#define LM90_REG_R_REMOTE_OFFSH		0x11
+#define LM90_REG_W_REMOTE_OFFSH		0x11
+#define LM90_REG_R_REMOTE_OFFSL		0x12
+#define LM90_REG_W_REMOTE_OFFSL		0x12
+#define LM90_REG_R_REMOTE_HIGHH		0x07
+#define LM90_REG_W_REMOTE_HIGHH		0x0D
+#define LM90_REG_R_REMOTE_HIGHL		0x13
+#define LM90_REG_W_REMOTE_HIGHL		0x13
+#define LM90_REG_R_REMOTE_LOWH		0x08
+#define LM90_REG_W_REMOTE_LOWH		0x0E
+#define LM90_REG_R_REMOTE_LOWL		0x14
+#define LM90_REG_W_REMOTE_LOWL		0x14
+#define LM90_REG_R_REMOTE_CRIT		0x19
+#define LM90_REG_W_REMOTE_CRIT		0x19
+#define LM90_REG_R_TCRIT_HYST		0x21
+#define LM90_REG_W_TCRIT_HYST		0x21
+
+/*
+ * Conversions and various macros
+ * The LM90 uses signed 8-bit values for the local temperatures,
+ * and signed 11-bit values for the remote temperatures (except
+ * T_CRIT). Note that TEMP2_TO_REG does not round values, but
+ * stick to the nearest lower value instead. Fixing it is just
+ * not worth it.
+ */
+
+#define TEMP1_FROM_REG(val)	((val & 0x80 ? val-0x100 : val) * 1000)
+#define TEMP1_TO_REG(val)	((val < 0 ? val+0x100*1000 : val) / 1000)
+#define TEMP2_FROM_REG(val)	(((val & 0x8000 ? val-0x10000 : val) >> 5) * 125)
+#define TEMP2_TO_REG(val)	((((val / 125) << 5) + (val < 0 ? 0x10000 : 0)) & 0xFFE0)
+#define HYST_FROM_REG(val)	(val * 1000)
+#define HYST_TO_REG(val)	(val <= 0 ? 0 : val >= 31000 ? 31 : val / 1000)
+
+/*
+ * Functions declaration
+ */
+
+static int lm90_attach_adapter(struct i2c_adapter *adapter);
+static int lm90_detect(struct i2c_adapter *adapter, int address,
+	int kind);
+static void lm90_init_client(struct i2c_client *client);
+static int lm90_detach_client(struct i2c_client *client);
+static void lm90_update_client(struct i2c_client *client);
+
+/*
+ * Driver data (common to all clients)
+ */
+
+static struct i2c_driver lm90_driver = {
+	.owner		= THIS_MODULE,
+	.name		= "lm90",
+	.id		= I2C_DRIVERID_LM90,
+	.flags		= I2C_DF_NOTIFY,
+	.attach_adapter	= lm90_attach_adapter,
+	.detach_client	= lm90_detach_client,
+};
+
+/*
+ * Client data (each client gets its own)
+ */
+
+struct lm90_data {
+	struct semaphore update_lock;
+	char valid; /* zero until following fields are valid */
+	unsigned long last_updated; /* in jiffies */
+
+	/* registers values */
+	u8 temp_input1, temp_low1, temp_high1; /* local */
+	u16 temp_input2, temp_low2, temp_high2; /* remote, combined */
+	u8 temp_crit1, temp_crit2;
+	u8 temp_hyst;
+	u16 alarms; /* bitvector, combined */
+};
+
+/*
+ * Internal variables
+ */
+
+static int lm90_id = 0;
+
+/*
+ * Sysfs stuff
+ */
+
+#define show_temp(value, converter) \
+static ssize_t show_##value(struct device *dev, char *buf) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct lm90_data *data = i2c_get_clientdata(client); \
+	lm90_update_client(client); \
+	return sprintf(buf, "%d\n", converter(data->value)); \
+}
+show_temp(temp_input1, TEMP1_FROM_REG);
+show_temp(temp_input2, TEMP2_FROM_REG);
+show_temp(temp_low1, TEMP1_FROM_REG);
+show_temp(temp_low2, TEMP2_FROM_REG);
+show_temp(temp_high1, TEMP1_FROM_REG);
+show_temp(temp_high2, TEMP2_FROM_REG);
+show_temp(temp_crit1, TEMP1_FROM_REG);
+show_temp(temp_crit2, TEMP1_FROM_REG);
+
+#define set_temp1(value, reg) \
+static ssize_t set_##value(struct device *dev, const char *buf, \
+	size_t count) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct lm90_data *data = i2c_get_clientdata(client); \
+	data->value = TEMP1_TO_REG(simple_strtol(buf, NULL, 10)); \
+	i2c_smbus_write_byte_data(client, reg, data->value); \
+	return count; \
+}
+#define set_temp2(value, regh, regl) \
+static ssize_t set_##value(struct device *dev, const char *buf, \
+	size_t count) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct lm90_data *data = i2c_get_clientdata(client); \
+	data->value = TEMP2_TO_REG(simple_strtol(buf, NULL, 10)); \
+	i2c_smbus_write_byte_data(client, regh, data->value >> 8); \
+	i2c_smbus_write_byte_data(client, regl, data->value & 0xff); \
+	return count; \
+}
+set_temp1(temp_low1, LM90_REG_W_LOCAL_LOW);
+set_temp2(temp_low2, LM90_REG_W_REMOTE_LOWH, LM90_REG_W_REMOTE_LOWL);
+set_temp1(temp_high1, LM90_REG_W_LOCAL_HIGH);
+set_temp2(temp_high2, LM90_REG_W_REMOTE_HIGHH, LM90_REG_W_REMOTE_HIGHL);
+set_temp1(temp_crit1, LM90_REG_W_LOCAL_CRIT);
+set_temp1(temp_crit2, LM90_REG_W_REMOTE_CRIT);
+
+#define show_temp_hyst(value, basereg) \
+static ssize_t show_##value(struct device *dev, char *buf) \
+{ \
+	struct i2c_client *client = to_i2c_client(dev); \
+	struct lm90_data *data = i2c_get_clientdata(client); \
+	lm90_update_client(client); \
+	return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->basereg) \
+		       - HYST_FROM_REG(data->temp_hyst)); \
+}
+show_temp_hyst(temp_hyst1, temp_crit1);
+show_temp_hyst(temp_hyst2, temp_crit2);
+
+static ssize_t set_temp_hyst1(struct device *dev, const char *buf,
+	size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm90_data *data = i2c_get_clientdata(client);
+	int hyst = TEMP1_FROM_REG(data->temp_crit1) -
+		   simple_strtol(buf, NULL, 10);
+	i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST,
+				  HYST_TO_REG(hyst));
+	return count;
+}
+
+static ssize_t show_alarms(struct device *dev, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct lm90_data *data = i2c_get_clientdata(client);
+	lm90_update_client(client);
+	return sprintf(buf, "%d\n", data->alarms);
+}
+
+static DEVICE_ATTR(temp_input1, S_IRUGO, show_temp_input1, NULL);
+static DEVICE_ATTR(temp_input2, S_IRUGO, show_temp_input2, NULL);
+static DEVICE_ATTR(temp_min1, S_IWUSR | S_IRUGO, show_temp_low1,
+	set_temp_low1);
+static DEVICE_ATTR(temp_min2, S_IWUSR | S_IRUGO, show_temp_low2,
+	set_temp_low2);
+static DEVICE_ATTR(temp_max1, S_IWUSR | S_IRUGO, show_temp_high1,
+	set_temp_high1);
+static DEVICE_ATTR(temp_max2, S_IWUSR | S_IRUGO, show_temp_high2,
+	set_temp_high2);
+static DEVICE_ATTR(temp_crit1, S_IWUSR | S_IRUGO, show_temp_crit1,
+	set_temp_crit1);
+static DEVICE_ATTR(temp_crit2, S_IWUSR | S_IRUGO, show_temp_crit2,
+	set_temp_crit2);
+static DEVICE_ATTR(temp_hyst1, S_IWUSR | S_IRUGO, show_temp_hyst1,
+	set_temp_hyst1);
+static DEVICE_ATTR(temp_hyst2, S_IRUGO, show_temp_hyst2, NULL);
+static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
+
+/*
+ * Real code
+ */
+
+static int lm90_attach_adapter(struct i2c_adapter *adapter)
+{
+	if (!(adapter->class & I2C_ADAP_CLASS_SMBUS))
+		return 0;
+	return i2c_detect(adapter, &addr_data, lm90_detect);
+}
+
+/*
+ * The following function does more than just detection. If detection
+ * succeeds, it also registers the new chip.
+ */
+static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
+{
+	struct i2c_client *new_client;
+	struct lm90_data *data;
+	int err = 0;
+	const char *name = "";
+	u8 reg_config1=0, reg_convrate=0;
+
+	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+		goto exit;
+
+	if (!(new_client = kmalloc(sizeof(struct i2c_client) +
+	    sizeof(struct lm90_data), GFP_KERNEL))) {
+		err = -ENOMEM;
+		goto exit;
+	}
+	memset(new_client, 0x00, sizeof(struct i2c_client) +
+	       sizeof(struct lm90_data));
+
+	/* The LM90-specific data is placed right after the common I2C
+	 * client data. */
+	data = (struct lm90_data *) (new_client + 1);
+	i2c_set_clientdata(new_client, data);
+	new_client->addr = address;
+	new_client->adapter = adapter;
+	new_client->driver = &lm90_driver;
+	new_client->flags = 0;
+
+	/*
+	 * Now we do the remaining detection. A negative kind means that
+	 * the driver was loaded with no force parameter (default), so we
+	 * must both detect and identify the chip. A zero kind means that
+	 * the driver was loaded with the force parameter, the detection
+	 * step shall be skipped. A positive kind means that the driver
+	 * was loaded with the force parameter and a given kind of chip is
+	 * requested, so both the detection and the identification steps
+	 * are skipped.
+	 */
+	if (kind < 0) { /* detection */
+		reg_config1 = i2c_smbus_read_byte_data(new_client,
+			      LM90_REG_R_CONFIG1);
+		reg_convrate = i2c_smbus_read_byte_data(new_client,
+			       LM90_REG_R_CONVRATE);
+
+		if ((reg_config1 & 0x2A) != 0x00
+		 || reg_convrate > 0x0A) {
+			dev_dbg(&adapter->dev,
+				"LM90 detection failed at 0x%02x.\n",
+				address);
+			goto exit_free;
+		}
+	}
+
+	if (kind <= 0) { /* identification */
+		u8 man_id, chip_id;
+
+		man_id = i2c_smbus_read_byte_data(new_client,
+			 LM90_REG_R_MAN_ID);
+		chip_id = i2c_smbus_read_byte_data(new_client,
+			  LM90_REG_R_CHIP_ID);
+		
+		if (man_id == 0x01) { /* National Semiconductor */
+			if (chip_id >= 0x21 && chip_id < 0x30 /* LM90 */
+			 && (kind == 0 /* skip detection */
+			  || ((i2c_smbus_read_byte_data(new_client,
+				LM90_REG_R_CONFIG2) & 0xF8) == 0x00
+			   && reg_convrate <= 0x09))) {
+				kind = lm90;
+				name = "lm90";
+			}
+		}
+		else if (man_id == 0x41) { /* Analog Devices */
+			if ((chip_id & 0xF0) == 0x40 /* ADM1032 */
+			 && (kind == 0 /* skip detection */
+			  || (reg_config1 & 0x3F) == 0x00)) {
+				kind = adm1032;
+				name = "adm1032";
+			}
+		}
+
+		if (kind <= 0) { /* identification failed */
+			dev_info(&adapter->dev,
+			    "Unsupported chip (man_id=0x%02X, "
+			    "chip_id=0x%02X).\n", man_id, chip_id);
+			goto exit_free;
+		}
+	}
+
+	/* We can fill in the remaining client fields */
+	strlcpy(new_client->name, name, I2C_NAME_SIZE);
+	new_client->id = lm90_id++;
+	data->valid = 0;
+	init_MUTEX(&data->update_lock);
+
+	/* Tell the I2C layer a new client has arrived */
+	if ((err = i2c_attach_client(new_client)))
+		goto exit_free;
+
+	/* Initialize the LM90 chip */
+	lm90_init_client(new_client);
+
+	/* Register sysfs hooks */
+	device_create_file(&new_client->dev, &dev_attr_temp_input1);
+	device_create_file(&new_client->dev, &dev_attr_temp_input2);
+	device_create_file(&new_client->dev, &dev_attr_temp_min1);
+	device_create_file(&new_client->dev, &dev_attr_temp_min2);
+	device_create_file(&new_client->dev, &dev_attr_temp_max1);
+	device_create_file(&new_client->dev, &dev_attr_temp_max2);
+	device_create_file(&new_client->dev, &dev_attr_temp_crit1);
+	device_create_file(&new_client->dev, &dev_attr_temp_crit2);
+	device_create_file(&new_client->dev, &dev_attr_temp_hyst1);
+	device_create_file(&new_client->dev, &dev_attr_temp_hyst2);
+	device_create_file(&new_client->dev, &dev_attr_alarms);
+
+	return 0;
+
+exit_free:
+	kfree(new_client);
+exit:
+	return err;
+}
+
+static void lm90_init_client(struct i2c_client *client)
+{
+	u8 config;
+
+	/*
+	 * Start the conversions.
+	 */
+	i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE,
+				  5); /* 2 Hz */
+	config = i2c_smbus_read_byte_data(client, LM90_REG_R_CONFIG1);
+	if (config & 0x40)
+		i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
+					  config & 0xBF); /* run */
+}
+
+static int lm90_detach_client(struct i2c_client *client)
+{
+	int err;
+
+	if ((err = i2c_detach_client(client))) {
+		dev_err(&client->dev, "Client deregistration failed, "
+			"client not detached.\n");
+		return err;
+	}
+
+	kfree(client);
+	return 0;
+}
+
+static void lm90_update_client(struct i2c_client *client)
+{
+	struct lm90_data *data = i2c_get_clientdata(client);
+
+	down(&data->update_lock);
+
+	if ((jiffies - data->last_updated > HZ * 2) ||
+	    (jiffies < data->last_updated) ||
+	    !data->valid) {
+		u8 oldh, newh;
+
+		dev_dbg(&client->dev, "Updating lm90 data.\n");
+		data->temp_input1 = i2c_smbus_read_byte_data(client,
+				    LM90_REG_R_LOCAL_TEMP);
+		data->temp_high1 = i2c_smbus_read_byte_data(client,
+				   LM90_REG_R_LOCAL_HIGH);
+		data->temp_low1 = i2c_smbus_read_byte_data(client,
+				  LM90_REG_R_LOCAL_LOW);
+		data->temp_crit1 = i2c_smbus_read_byte_data(client,
+				   LM90_REG_R_LOCAL_CRIT);
+		data->temp_crit2 = i2c_smbus_read_byte_data(client,
+				   LM90_REG_R_REMOTE_CRIT);
+		data->temp_hyst = i2c_smbus_read_byte_data(client,
+				  LM90_REG_R_TCRIT_HYST);
+
+		/*
+		 * There is a trick here. We have to read two registers to
+		 * have the remote sensor temperature, but we have to beware
+		 * a conversion could occur inbetween the readings. The
+		 * datasheet says we should either use the one-shot
+		 * conversion register, which we don't want to do (disables
+		 * hardware monitoring) or monitor the busy bit, which is
+		 * impossible (we can't read the values and monitor that bit
+		 * at the exact same time). So the solution used here is to
+		 * read the high byte once, then the low byte, then the high
+		 * byte again. If the new high byte matches the old one,
+		 * then we have a valid reading. Else we have to read the low
+		 * byte again, and now we believe we have a correct reading.
+		 */
+		oldh = i2c_smbus_read_byte_data(client,
+		       LM90_REG_R_REMOTE_TEMPH);
+		data->temp_input2 = i2c_smbus_read_byte_data(client,
+				    LM90_REG_R_REMOTE_TEMPL);
+		newh = i2c_smbus_read_byte_data(client,
+		       LM90_REG_R_REMOTE_TEMPH);
+		if (newh != oldh) {
+			data->temp_input2 = i2c_smbus_read_byte_data(client,
+					    LM90_REG_R_REMOTE_TEMPL);
+#ifdef DEBUG
+			oldh = i2c_smbus_read_byte_data(client,
+			       LM90_REG_R_REMOTE_TEMPH);
+			/* oldh is actually newer */
+			if (newh != oldh)
+				dev_warn(&client->dev, "Remote temperature may be "
+					 "wrong.\n");
+#endif
+		}
+		data->temp_input2 |= (newh << 8);
+
+		data->temp_high2 = (i2c_smbus_read_byte_data(client,
+				   LM90_REG_R_REMOTE_HIGHH) << 8) +
+				   i2c_smbus_read_byte_data(client,
+				   LM90_REG_R_REMOTE_HIGHL);
+		data->temp_low2 = (i2c_smbus_read_byte_data(client,
+				  LM90_REG_R_REMOTE_LOWH) << 8) +
+				  i2c_smbus_read_byte_data(client,
+				  LM90_REG_R_REMOTE_LOWL);
+		data->alarms = i2c_smbus_read_byte_data(client,
+			       LM90_REG_R_STATUS);
+
+		data->last_updated = jiffies;
+		data->valid = 1;
+	}
+
+	up(&data->update_lock);
+}
+
+static int __init sensors_lm90_init(void)
+{
+	return i2c_add_driver(&lm90_driver);
+}
+
+static void __exit sensors_lm90_exit(void)
+{
+	i2c_del_driver(&lm90_driver);
+}
+
+MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
+MODULE_DESCRIPTION("LM90/ADM1032 driver");
+MODULE_LICENSE("GPL");
+
+module_init(sensors_lm90_init);
+module_exit(sensors_lm90_exit);
diff -puN drivers/i2c/chips/Makefile~linus drivers/i2c/chips/Makefile
--- 25/drivers/i2c/chips/Makefile~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/chips/Makefile	2004-01-19 22:17:21.000000000 -0800
@@ -2,7 +2,8 @@
 # Makefile for the kernel hardware sensors chip drivers.
 #
 
-# w83781d goes first, as it can override other driver's addresses.
+# asb100, then w83781d go first, as they can override other drivers' addresses.
+obj-$(CONFIG_SENSORS_ASB100)	+= asb100.o
 obj-$(CONFIG_SENSORS_W83781D)	+= w83781d.o
 
 obj-$(CONFIG_SENSORS_ADM1021)	+= adm1021.o
@@ -12,4 +13,6 @@ obj-$(CONFIG_SENSORS_LM75)	+= lm75.o
 obj-$(CONFIG_SENSORS_LM78)	+= lm78.o
 obj-$(CONFIG_SENSORS_LM83)	+= lm83.o
 obj-$(CONFIG_SENSORS_LM85)	+= lm85.o
+obj-$(CONFIG_SENSORS_LM90)	+= lm90.o
 obj-$(CONFIG_SENSORS_VIA686A)	+= via686a.o
+obj-$(CONFIG_SENSORS_W83L785TS)	+= w83l785ts.o
diff -puN drivers/i2c/chips/via686a.c~linus drivers/i2c/chips/via686a.c
--- 25/drivers/i2c/chips/via686a.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/chips/via686a.c	2004-01-19 22:17:21.000000000 -0800
@@ -31,6 +31,11 @@
     Warning - only supports a single device.
 */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_CHIP
+#define DEBUG	1
+#endif
+
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/pci.h>
diff -puN drivers/i2c/chips/w83781d.c~linus drivers/i2c/chips/w83781d.c
--- 25/drivers/i2c/chips/w83781d.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/chips/w83781d.c	2004-01-19 22:17:21.000000000 -0800
@@ -36,6 +36,11 @@
 
 */
 
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_CHIP
+#define DEBUG	1
+#endif
+
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/slab.h>
@@ -43,6 +48,7 @@
 #include <linux/i2c-sensor.h>
 #include <linux/i2c-vid.h>
 #include <asm/io.h>
+#include "lm75.h"
 
 /* RT Table support #defined so we can take it out if it gets bothersome */
 #define W83781D_RT			1
@@ -170,17 +176,14 @@ FAN_TO_REG(long rpm, int div)
 					((val) == 255 ? 0 : \
 							1350000 / ((val) * (div))))
 
-#define TEMP_TO_REG(val)		(SENSORS_LIMIT(((val / 10) < 0 ? (((val / 10) - 5) / 10) : \
-									 ((val / 10) + 5) / 10), 0, 255))
-#define TEMP_FROM_REG(val)		((((val ) > 0x80 ? (val) - 0x100 : (val)) * 10) * 10)
-
-#define TEMP_ADD_TO_REG(val)		(SENSORS_LIMIT(((((val / 10) + 2) / 5) << 7),\
-                                              0, 0xffff))
-#define TEMP_ADD_FROM_REG(val)		((((val) >> 7) * 5) * 10)
-
-#define AS99127_TEMP_ADD_TO_REG(val)	(SENSORS_LIMIT((((((val / 10) + 2)*4)/10) \
-                                               << 7), 0, 0xffff))
-#define AS99127_TEMP_ADD_FROM_REG(val)	(((((val) >> 7) * 10) / 4) * 10)
+#define TEMP_TO_REG(val)		(SENSORS_LIMIT(((val) < 0 ? (val)+0x100*1000 \
+						: (val)) / 1000, 0, 0xff))
+#define TEMP_FROM_REG(val)		(((val) & 0x80 ? (val)-0x100 : (val)) * 1000)
+
+#define AS99127_TEMP_ADD_TO_REG(val)	(SENSORS_LIMIT((((val) < 0 ? (val)+0x10000*250 \
+						: (val)) / 250) << 7, 0, 0xffff))
+#define AS99127_TEMP_ADD_FROM_REG(val)	((((val) & 0x8000 ? (val)-0x10000 : (val)) \
+						>> 7) * 250)
 
 #define ALARMS_FROM_REG(val)		(val)
 #define PWM_FROM_REG(val)		(val)
@@ -437,8 +440,8 @@ static ssize_t show_##reg (struct device
 			return sprintf(buf,"%ld\n", \
 				(long)AS99127_TEMP_ADD_FROM_REG(data->reg##_add[nr-2])); \
 		} else { \
-			return sprintf(buf,"%ld\n", \
-				(long)TEMP_ADD_FROM_REG(data->reg##_add[nr-2])); \
+			return sprintf(buf,"%d\n", \
+				LM75_TEMP_FROM_REG(data->reg##_add[nr-2])); \
 		} \
 	} else {	/* TEMP1 */ \
 		return sprintf(buf,"%ld\n", (long)TEMP_FROM_REG(data->reg)); \
@@ -453,15 +456,15 @@ static ssize_t store_temp_##reg (struct 
 { \
 	struct i2c_client *client = to_i2c_client(dev); \
 	struct w83781d_data *data = i2c_get_clientdata(client); \
-	u32 val; \
+	s32 val; \
 	 \
-	val = simple_strtoul(buf, NULL, 10); \
+	val = simple_strtol(buf, NULL, 10); \
 	 \
 	if (nr >= 2) {	/* TEMP2 and TEMP3 */ \
 		if (data->type == as99127f) \
 			data->temp_##reg##_add[nr-2] = AS99127_TEMP_ADD_TO_REG(val); \
 		else \
-			data->temp_##reg##_add[nr-2] = TEMP_ADD_TO_REG(val); \
+			data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \
 		 \
 		w83781d_write_value(client, W83781D_REG_TEMP_##REG(nr), \
 				data->temp_##reg##_add[nr-2]); \
@@ -1653,7 +1656,7 @@ w83781d_update_client(struct i2c_client 
 	if (time_after
 	    (jiffies - data->last_updated, (unsigned long) (HZ + HZ / 2))
 	    || time_before(jiffies, data->last_updated) || !data->valid) {
-		pr_debug(KERN_DEBUG "Starting device update\n");
+		pr_debug("Starting device update\n");
 
 		for (i = 0; i <= 8; i++) {
 			if ((data->type == w83783s || data->type == w83697hf)
diff -puN /dev/null drivers/i2c/chips/w83l785ts.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/i2c/chips/w83l785ts.c	2004-01-19 22:17:21.000000000 -0800
@@ -0,0 +1,314 @@
+/*
+ * w83l785ts.c - Part of lm_sensors, Linux kernel modules for hardware
+ *               monitoring
+ * Copyright (C) 2003-2004  Jean Delvare <khali@linux-fr.org>
+ *
+ * Inspired from the lm83 driver. The W83L785TS-S is a sensor chip made
+ * by Winbond. It reports a single external temperature with a 1 deg
+ * resolution and a 3 deg accuracy. Datasheet can be obtained from
+ * Winbond's website at:
+ *   http://www.winbond-usa.com/products/winbond_products/pdfs/PCIC/W83L785TS-S.pdf
+ *
+ * Ported to Linux 2.6 by Wolfgang Ziegler <nuppla@gmx.at> and Jean Delvare
+ * <khali@linux-fr.org>.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_CHIP
+#define DEBUG	1
+#endif
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/i2c-sensor.h>
+
+/*
+ * Address to scan
+ * Address is fully defined internally and cannot be changed.
+ */
+
+static unsigned short normal_i2c[] = { 0x2e, I2C_CLIENT_END };
+static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
+static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
+static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
+
+/*
+ * Insmod parameters
+ */
+
+SENSORS_INSMOD_1(w83l785ts);
+
+/*
+ * The W83L785TS-S registers
+ * Manufacturer ID is 0x5CA3 for Winbond.
+ */
+
+#define W83L785TS_REG_MAN_ID1		0x4D
+#define W83L785TS_REG_MAN_ID2		0x4C
+#define W83L785TS_REG_CHIP_ID		0x4E
+#define W83L785TS_REG_CONFIG		0x40
+#define W83L785TS_REG_TYPE		0x52
+#define W83L785TS_REG_TEMP		0x27
+#define W83L785TS_REG_TEMP_OVER		0x53 /* not sure about this one */
+
+/*
+ * Conversions
+ * The W83L785TS-S uses signed 8-bit values.
+ */
+
+#define TEMP_FROM_REG(val)	((val & 0x80 ? val-0x100 : val) * 1000)
+
+/*
+ * Functions declaration
+ */
+
+static int w83l785ts_attach_adapter(struct i2c_adapter *adapter);
+static int w83l785ts_detect(struct i2c_adapter *adapter, int address,
+	int kind);
+static int w83l785ts_detach_client(struct i2c_client *client);
+static void w83l785ts_update_client(struct i2c_client *client);
+
+/*
+ * Driver data (common to all clients)
+ */
+ 
+static struct i2c_driver w83l785ts_driver = {
+	.owner		= THIS_MODULE,
+	.name		= "w83l785ts",
+	.id		= I2C_DRIVERID_W83L785TS,
+	.flags		= I2C_DF_NOTIFY,
+	.attach_adapter	= w83l785ts_attach_adapter,
+	.detach_client	= w83l785ts_detach_client,
+};
+
+/*
+ * Client data (each client gets its own)
+ */
+
+struct w83l785ts_data {
+	
+	struct semaphore update_lock;
+	char valid; /* zero until following fields are valid */
+	unsigned long last_updated; /* in jiffies */
+
+	/* registers values */
+	u8 temp, temp_over;
+};
+
+/*
+ * Internal variables
+ */
+
+static int w83l785ts_id = 0;
+
+/*
+ * Sysfs stuff
+ */
+
+static ssize_t show_temp(struct device *dev, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct w83l785ts_data *data = i2c_get_clientdata(client);
+	w83l785ts_update_client(client);
+	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp));
+}
+
+static ssize_t show_temp_over(struct device *dev, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct w83l785ts_data *data = i2c_get_clientdata(client);
+	w83l785ts_update_client(client);
+	return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over));
+}
+
+static DEVICE_ATTR(temp_input, S_IRUGO, show_temp, NULL)
+static DEVICE_ATTR(temp_max, S_IRUGO, show_temp_over, NULL)
+
+/*
+ * Real code
+ */
+
+static int w83l785ts_attach_adapter(struct i2c_adapter *adapter)
+{
+	if (!(adapter->class & I2C_ADAP_CLASS_SMBUS))
+		return 0;
+	return i2c_detect(adapter, &addr_data, w83l785ts_detect);
+}
+
+/*
+ * The following function does more than just detection. If detection
+ * succeeds, it also registers the new chip.
+ */
+static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
+{
+	struct i2c_client *new_client;
+	struct w83l785ts_data *data;
+	int err = 0;
+	const char *name = "";
+
+
+	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
+		goto exit;
+
+	if (!(new_client = kmalloc(sizeof(struct i2c_client) +  
+		sizeof(struct w83l785ts_data), GFP_KERNEL))) {
+		err = -ENOMEM;
+		goto exit;
+	}
+	memset(new_client, 0x00, sizeof(struct i2c_client) +
+	       sizeof(struct w83l785ts_data));
+
+
+	/* The W83L785TS-specific data is placed right after the common I2C
+	 * client data. */
+	data = (struct w83l785ts_data *) (new_client + 1);
+	i2c_set_clientdata(new_client, data);
+	new_client->addr = address;
+	new_client->adapter = adapter;
+	new_client->driver = &w83l785ts_driver;
+	new_client->flags = 0;
+
+	/*
+	 * Now we do the remaining detection. A negative kind means that
+	 * the driver was loaded with no force parameter (default), so we
+	 * must both detect and identify the chip (actually there is only
+	 * one possible kind of chip for now, W83L785TS-S). A zero kind means
+	 * that the driver was loaded with the force parameter, the detection
+	 * step shall be skipped. A positive kind means that the driver
+	 * was loaded with the force parameter and a given kind of chip is
+	 * requested, so both the detection and the identification steps
+	 * are skipped.
+	 */
+	if (kind < 0) { /* detection */
+		if (((i2c_smbus_read_byte_data(new_client,
+		      W83L785TS_REG_CONFIG) & 0x80) != 0x00)
+		 || ((i2c_smbus_read_byte_data(new_client,
+		      W83L785TS_REG_TYPE) & 0xFC) != 0x00)) {
+			dev_dbg(&adapter->dev,
+				"W83L785TS-S detection failed at 0x%02x.\n",
+				address);
+			goto exit_free;
+		}
+	}
+
+	if (kind <= 0) { /* identification */
+		u16 man_id;
+		u8 chip_id;
+
+		man_id = (i2c_smbus_read_byte_data(new_client,
+			 W83L785TS_REG_MAN_ID1) << 8) +
+			 i2c_smbus_read_byte_data(new_client,
+			 W83L785TS_REG_MAN_ID2);
+		chip_id = i2c_smbus_read_byte_data(new_client,
+			  W83L785TS_REG_CHIP_ID);
+
+		if (man_id == 0x5CA3) { /* Winbond */
+			if (chip_id == 0x70) { /* W83L785TS-S */
+				kind = w83l785ts;			
+				name = "w83l785ts";
+			}
+		}
+	
+		if (kind <= 0) { /* identification failed */
+			dev_info(&adapter->dev,
+				 "Unsupported chip (man_id=0x%04X, "
+				 "chip_id=0x%02X).\n", man_id, chip_id);
+			goto exit_free;
+		}
+	}
+
+	/* We can fill in the remaining client fields. */
+	strlcpy(new_client->name, name, I2C_NAME_SIZE);
+	new_client->id = w83l785ts_id++;
+	data->valid = 0;
+	init_MUTEX(&data->update_lock);
+
+	/* Tell the I2C layer a new client has arrived. */
+	if ((err = i2c_attach_client(new_client))) 
+		goto exit_free;
+
+	/*
+	 * Initialize the W83L785TS chip
+	 * Nothing yet, assume it is already started.
+	 */
+
+	/* Register sysfs hooks */
+	device_create_file(&new_client->dev, &dev_attr_temp_input);
+	device_create_file(&new_client->dev, &dev_attr_temp_max);
+
+	return 0;
+
+exit_free:
+	kfree(new_client);
+exit:
+	return err;
+}
+
+static int w83l785ts_detach_client(struct i2c_client *client)
+{
+	int err;
+
+	if ((err = i2c_detach_client(client))) {
+		dev_err(&client->dev, "Client deregistration failed, "
+			"client not detached.\n");
+		return err;
+	}
+
+	kfree(client);
+	return 0;
+}
+
+static void w83l785ts_update_client(struct i2c_client *client)
+{
+	struct w83l785ts_data *data = i2c_get_clientdata(client);
+
+	down(&data->update_lock);
+
+	if (!data->valid
+	 || (jiffies - data->last_updated > HZ * 2)
+	 || (jiffies < data->last_updated)) {
+		dev_dbg(&client->dev, "Updating w83l785ts data.\n");
+		data->temp = i2c_smbus_read_byte_data(client,
+			     W83L785TS_REG_TEMP);
+		data->temp_over = i2c_smbus_read_byte_data(client,
+				  W83L785TS_REG_TEMP_OVER);
+
+		data->last_updated = jiffies;
+		data->valid = 1;
+	}
+
+	up(&data->update_lock);
+}
+
+static int __init sensors_w83l785ts_init(void)
+{
+	return i2c_add_driver(&w83l785ts_driver);
+}
+
+static void __exit sensors_w83l785ts_exit(void)
+{
+	i2c_del_driver(&w83l785ts_driver);
+}
+
+MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
+MODULE_DESCRIPTION("W83L785TS-S driver");
+MODULE_LICENSE("GPL");
+
+module_init(sensors_w83l785ts_init);
+module_exit(sensors_w83l785ts_exit);
diff -puN drivers/i2c/i2c-core.c~linus drivers/i2c/i2c-core.c
--- 25/drivers/i2c/i2c-core.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/i2c-core.c	2004-01-19 22:17:21.000000000 -0800
@@ -21,9 +21,10 @@
    All SMBus-related things are written by Frodo Looijaard <frodol@dds.nl>
    SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com>                */
 
-/* $Id: i2c-core.c,v 1.95 2003/01/22 05:25:08 kmalkki Exp $ */
-
-/* #define DEBUG 1 */		/* needed to pick up the dev_dbg() calls */
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_CORE
+#define DEBUG	1
+#endif
 
 #include <linux/module.h>
 #include <linux/kernel.h>
@@ -35,16 +36,10 @@
 #include <asm/uaccess.h>
 
 
-#define DEB(x) if (i2c_debug>=1) x;
-#define DEB2(x) if (i2c_debug>=2) x;
-
 static LIST_HEAD(adapters);
 static LIST_HEAD(drivers);
 static DECLARE_MUTEX(core_lists);
 
-/**** debug level */
-static int i2c_debug;
-
 int i2c_device_probe(struct device *dev)
 {
 	return -ENODEV;
@@ -162,7 +157,7 @@ int i2c_add_adapter(struct i2c_adapter *
 	}
 	up(&core_lists);
 
-	DEB(dev_dbg(&adap->dev, "registered as adapter #%d\n", adap->nr));
+	dev_dbg(&adap->dev, "registered as adapter #%d\n", adap->nr);
 	return 0;
 }
 
@@ -217,7 +212,7 @@ int i2c_del_adapter(struct i2c_adapter *
 	wait_for_completion(&adap->dev_released);
 	wait_for_completion(&adap->class_dev_released);
 
-	DEB(dev_dbg(&adap->dev, "adapter unregistered\n"));
+	dev_dbg(&adap->dev, "adapter unregistered\n");
 
  out_unlock:
 	up(&core_lists);
@@ -250,7 +245,7 @@ int i2c_add_driver(struct i2c_driver *dr
 		goto out_unlock;
 	
 	list_add_tail(&driver->list,&drivers);
-	DEB(printk(KERN_DEBUG "i2c-core.o: driver %s registered.\n",driver->name));
+	pr_debug("i2c-core: driver %s registered.\n", driver->name);
 
 	/* now look for instances of driver on our adapters */
 	if (driver->flags & I2C_DF_NOTIFY) {
@@ -279,14 +274,14 @@ int i2c_del_driver(struct i2c_driver *dr
 	 * attached. If so, detach them to be able to kill the driver 
 	 * afterwards.
 	 */
-	DEB2(printk(KERN_DEBUG "i2c-core.o: unregister_driver - looking for clients.\n"));
+	pr_debug("i2c-core: unregister_driver - looking for clients.\n");
 	/* removing clients does not depend on the notify flag, else 
 	 * invalid operation might (will!) result, when using stale client
 	 * pointers.
 	 */
 	list_for_each(item1,&adapters) {
 		adap = list_entry(item1, struct i2c_adapter, list);
-		DEB2(dev_dbg(&adap->dev, "examining adapter\n"));
+		dev_dbg(&adap->dev, "examining adapter\n");
 		if (driver->detach_adapter) {
 			if ((res = driver->detach_adapter(adap))) {
 				dev_warn(&adap->dev, "while unregistering "
@@ -300,9 +295,7 @@ int i2c_del_driver(struct i2c_driver *dr
 				client = list_entry(item2, struct i2c_client, list);
 				if (client->driver != driver)
 					continue;
-				DEB2(printk(KERN_DEBUG "i2c-core.o: "
-					    "detaching client %s:\n",
-					    client->name));
+				pr_debug("i2c-core.o: detaching client %s:\n", client->name);
 				if ((res = driver->detach_client(client))) {
 					dev_err(&adap->dev, "while "
 						"unregistering driver "
@@ -321,7 +314,7 @@ int i2c_del_driver(struct i2c_driver *dr
 
 	driver_unregister(&driver->driver);
 	list_del(&driver->list);
-	DEB(printk(KERN_DEBUG "i2c-core.o: driver unregistered: %s\n",driver->name));
+	pr_debug("i2c-core: driver unregistered: %s\n", driver->name);
 
  out_unlock:
 	up(&core_lists);
@@ -372,8 +365,8 @@ int i2c_attach_client(struct i2c_client 
 		}
 	}
 
-	DEB(dev_dbg(&adapter->dev, "client [%s] registered to adapter\n",
-			client->dev.name));
+	dev_dbg(&adapter->dev, "client [%s] registered to adapter\n",
+		client->name);
 
 	if (client->flags & I2C_CLIENT_ALLOW_USE)
 		client->usage_count = 0;
@@ -385,7 +378,7 @@ int i2c_attach_client(struct i2c_client 
 	
 	snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id),
 		"%d-%04x", i2c_adapter_id(adapter), client->addr);
-	printk("registering %s\n", client->dev.bus_id);
+	pr_debug("registering %s\n", client->dev.bus_id);
 	device_register(&client->dev);
 	device_create_file(&client->dev, &dev_attr_client_name);
 	
@@ -404,8 +397,8 @@ int i2c_detach_client(struct i2c_client 
 	if (adapter->client_unregister)  {
 		res = adapter->client_unregister(client);
 		if (res) {
-			printk(KERN_ERR
-			       "i2c-core.o: client_unregister [%s] failed, "
+			dev_err(&client->dev,
+			       "client_unregister [%s] failed, "
 			       "client not detached", client->name);
 			goto out;
 		}
@@ -467,9 +460,9 @@ int i2c_release_client(struct i2c_client
 	if(client->flags & I2C_CLIENT_ALLOW_USE) {
 		if(client->usage_count>0)
 			client->usage_count--;
-		else
-		{
-			printk(KERN_WARNING " i2c-core.o: dec_use_client used one too many times\n");
+		else {
+			pr_debug("i2c-core: %s used one too many times\n",
+				__FUNCTION__);
 			return -EPERM;
 		}
 	}
@@ -544,7 +537,7 @@ int i2c_transfer(struct i2c_adapter * ad
 	int ret;
 
 	if (adap->algo->master_xfer) {
- 	 	DEB2(dev_dbg(&adap->dev, "master_xfer: with %d msgs.\n", num));
+ 	 	dev_dbg(&adap->dev, "master_xfer: with %d msgs.\n", num);
 
 		down(&adap->bus_lock);
 		ret = adap->algo->master_xfer(adap,msgs,num);
@@ -552,7 +545,7 @@ int i2c_transfer(struct i2c_adapter * ad
 
 		return ret;
 	} else {
-		DEB2(dev_dbg(&adap->dev, "I2C level transfers not supported\n"));
+		dev_dbg(&adap->dev, "I2C level transfers not supported\n");
 		return -ENOSYS;
 	}
 }
@@ -569,8 +562,8 @@ int i2c_master_send(struct i2c_client *c
 		msg.len = count;
 		msg.buf = (char *)buf;
 	
-		DEB2(dev_dbg(&client->adapter->dev, "master_send: writing %d bytes.\n",
-				count));
+		dev_dbg(&client->adapter->dev, "master_send: writing %d bytes.\n",
+			count);
 	
 		down(&adap->bus_lock);
 		ret = adap->algo->master_xfer(adap,&msg,1);
@@ -598,15 +591,15 @@ int i2c_master_recv(struct i2c_client *c
 		msg.len = count;
 		msg.buf = buf;
 
-		DEB2(dev_dbg(&client->adapter->dev, "master_recv: reading %d bytes.\n",
-				count));
+		dev_dbg(&client->adapter->dev, "master_recv: reading %d bytes.\n",
+			count);
 	
 		down(&adap->bus_lock);
 		ret = adap->algo->master_xfer(adap,&msg,1);
 		up(&adap->bus_lock);
 	
-		DEB2(printk(KERN_DEBUG "i2c-core.o: master_recv: return:%d (count:%d, addr:0x%02x)\n",
-			ret, count, client->addr));
+		dev_dbg(&client->dev, "master_recv: return:%d (count:%d, addr:0x%02x)\n",
+			ret, count, client->addr);
 	
 		/* if everything went ok (i.e. 1 msg transmitted), return #bytes
 	 	* transmitted, else error code.
@@ -625,8 +618,8 @@ int i2c_control(struct i2c_client *clien
 	int ret = 0;
 	struct i2c_adapter *adap = client->adapter;
 
-	DEB2(printk(KERN_DEBUG "i2c-core.o: i2c ioctl, cmd: 0x%x, arg: %#lx\n", cmd, arg));
-	switch ( cmd ) {
+	dev_dbg(&client->dev, "i2c ioctl, cmd: 0x%x, arg: %#lx\n", cmd, arg);
+	switch (cmd) {
 		case I2C_RETRIES:
 			adap->retries = arg;
 			break;
@@ -670,8 +663,8 @@ int i2c_probe(struct i2c_adapter *adapte
 			if (((adap_id == address_data->force[i]) || 
 			     (address_data->force[i] == ANY_I2C_BUS)) &&
 			     (addr == address_data->force[i+1])) {
-				DEB2(printk(KERN_DEBUG "i2c-core.o: found force parameter for adapter %d, addr %04x\n",
-				            adap_id,addr));
+				dev_dbg(&adapter->dev, "found force parameter for adapter %d, addr %04x\n",
+					adap_id, addr);
 				if ((err = found_proc(adapter,addr,0)))
 					return err;
 				found = 1;
@@ -688,8 +681,8 @@ int i2c_probe(struct i2c_adapter *adapte
 			if (((adap_id == address_data->ignore[i]) || 
 			    ((address_data->ignore[i] == ANY_I2C_BUS))) &&
 			    (addr == address_data->ignore[i+1])) {
-				DEB2(printk(KERN_DEBUG "i2c-core.o: found ignore parameter for adapter %d, "
-				     "addr %04x\n", adap_id ,addr));
+				dev_dbg(&adapter->dev, "found ignore parameter for adapter %d, "
+					"addr %04x\n", adap_id ,addr);
 				found = 1;
 			}
 		}
@@ -700,8 +693,8 @@ int i2c_probe(struct i2c_adapter *adapte
 			    ((address_data->ignore_range[i]==ANY_I2C_BUS))) &&
 			    (addr >= address_data->ignore_range[i+1]) &&
 			    (addr <= address_data->ignore_range[i+2])) {
-				DEB2(printk(KERN_DEBUG "i2c-core.o: found ignore_range parameter for adapter %d, "
-				            "addr %04x\n", adap_id,addr));
+				dev_dbg(&adapter->dev, "found ignore_range parameter for adapter %d, "
+					"addr %04x\n", adap_id,addr);
 				found = 1;
 			}
 		}
@@ -715,8 +708,8 @@ int i2c_probe(struct i2c_adapter *adapte
 		     i += 1) {
 			if (addr == address_data->normal_i2c[i]) {
 				found = 1;
-				DEB2(printk(KERN_DEBUG "i2c-core.o: found normal i2c entry for adapter %d, "
-				            "addr %02x", adap_id,addr));
+				dev_dbg(&adapter->dev, "found normal i2c entry for adapter %d, "
+					"addr %02x", adap_id,addr);
 			}
 		}
 
@@ -726,8 +719,8 @@ int i2c_probe(struct i2c_adapter *adapte
 			if ((addr >= address_data->normal_i2c_range[i]) &&
 			    (addr <= address_data->normal_i2c_range[i+1])) {
 				found = 1;
-				DEB2(printk(KERN_DEBUG "i2c-core.o: found normal i2c_range entry for adapter %d, "
-				            "addr %04x\n", adap_id,addr));
+				dev_dbg(&adapter->dev, "found normal i2c_range entry for adapter %d, "
+					"addr %04x\n", adap_id,addr);
 			}
 		}
 
@@ -738,8 +731,8 @@ int i2c_probe(struct i2c_adapter *adapte
 			    ((address_data->probe[i] == ANY_I2C_BUS))) &&
 			    (addr == address_data->probe[i+1])) {
 				found = 1;
-				DEB2(printk(KERN_DEBUG "i2c-core.o: found probe parameter for adapter %d, "
-				            "addr %04x\n", adap_id,addr));
+				dev_dbg(&adapter->dev, "found probe parameter for adapter %d, "
+					"addr %04x\n", adap_id,addr);
 			}
 		}
 		for (i = 0;
@@ -750,8 +743,8 @@ int i2c_probe(struct i2c_adapter *adapte
 			   (addr >= address_data->probe_range[i+1]) &&
 			   (addr <= address_data->probe_range[i+2])) {
 				found = 1;
-				DEB2(printk(KERN_DEBUG "i2c-core.o: found probe_range parameter for adapter %d, "
-				            "addr %04x\n", adap_id,addr));
+				dev_dbg(&adapter->dev, "found probe_range parameter for adapter %d, "
+					"addr %04x\n", adap_id,addr);
 			}
 		}
 		if (!found) 
@@ -908,9 +901,9 @@ int i2c_smbus_check_pec(u16 addr, u8 com
 			cpec = rpec = 0;
 			break;
 	}
-	if(rpec != cpec) {
-		DEB(printk(KERN_DEBUG "i2c-core.o: Bad PEC 0x%02x vs. 0x%02x\n",
-		           rpec, cpec));
+	if (rpec != cpec) {
+		pr_debug("i2c-core: Bad PEC 0x%02x vs. 0x%02x\n",
+			rpec, cpec);
 		return -1;
 	}
 	return 0;	
@@ -1130,13 +1123,13 @@ static s32 i2c_smbus_xfer_emulated(struc
 	case I2C_SMBUS_BLOCK_DATA:
 	case I2C_SMBUS_BLOCK_DATA_PEC:
 		if (read_write == I2C_SMBUS_READ) {
-			printk(KERN_ERR "i2c-core.o: Block read not supported "
+			dev_err(&adapter->dev, "Block read not supported "
 			       "under I2C emulation!\n");
 			return -1;
 		} else {
 			msg[0].len = data->block[0] + 2;
 			if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 2) {
-				printk(KERN_ERR "i2c-core.o: smbus_access called with "
+				dev_err(&adapter->dev, "smbus_access called with "
 				       "invalid block write size (%d)\n",
 				       data->block[0]);
 				return -1;
@@ -1149,7 +1142,7 @@ static s32 i2c_smbus_xfer_emulated(struc
 		break;
 	case I2C_SMBUS_BLOCK_PROC_CALL:
 	case I2C_SMBUS_BLOCK_PROC_CALL_PEC:
-		printk(KERN_ERR "i2c-core.o: Block process call not supported "
+		dev_dbg(&adapter->dev, "Block process call not supported "
 		       "under I2C emulation!\n");
 		return -1;
 	case I2C_SMBUS_I2C_BLOCK_DATA:
@@ -1158,7 +1151,7 @@ static s32 i2c_smbus_xfer_emulated(struc
 		} else {
 			msg[0].len = data->block[0] + 1;
 			if (msg[0].len > I2C_SMBUS_I2C_BLOCK_MAX + 1) {
-				printk("i2c-core.o: i2c_smbus_xfer_emulated called with "
+				dev_err(&adapter->dev, "i2c_smbus_xfer_emulated called with "
 				       "invalid block write size (%d)\n",
 				       data->block[0]);
 				return -1;
@@ -1168,7 +1161,7 @@ static s32 i2c_smbus_xfer_emulated(struc
 		}
 		break;
 	default:
-		printk(KERN_ERR "i2c-core.o: smbus_access called with invalid size (%d)\n",
+		dev_err(&adapter->dev, "smbus_access called with invalid size (%d)\n",
 		       size);
 		return -1;
 	}
@@ -1303,6 +1296,3 @@ EXPORT_SYMBOL(i2c_check_functionality);
 MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
 MODULE_DESCRIPTION("I2C-Bus main module");
 MODULE_LICENSE("GPL");
-
-MODULE_PARM(i2c_debug, "i");
-MODULE_PARM_DESC(i2c_debug,"debug level");
diff -puN drivers/i2c/i2c-dev.c~linus drivers/i2c/i2c-dev.c
--- 25/drivers/i2c/i2c-dev.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/i2c-dev.c	2004-01-19 22:17:21.000000000 -0800
@@ -29,8 +29,10 @@
 /* The devfs code is contributed by Philipp Matthias Hahn 
    <pmhahn@titan.lahn.de> */
 
-/* If you want debugging uncomment: */
-/* #define DEBUG 1 */
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_CORE
+#define DEBUG	1
+#endif
 
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -137,7 +139,7 @@ static ssize_t i2cdev_read (struct file 
 	if (tmp==NULL)
 		return -ENOMEM;
 
-	pr_debug("i2c-dev.o: i2c-%d reading %d bytes.\n",
+	pr_debug("i2c-dev: i2c-%d reading %d bytes.\n",
 		iminor(file->f_dentry->d_inode), count);
 
 	ret = i2c_master_recv(client,tmp,count);
@@ -165,7 +167,7 @@ static ssize_t i2cdev_write (struct file
 		return -EFAULT;
 	}
 
-	pr_debug("i2c-dev.o: i2c-%d writing %d bytes.\n",
+	pr_debug("i2c-dev: i2c-%d writing %d bytes.\n",
 		iminor(file->f_dentry->d_inode), count);
 
 	ret = i2c_master_send(client,tmp,count);
diff -puN drivers/i2c/i2c-sensor.c~linus drivers/i2c/i2c-sensor.c
--- 25/drivers/i2c/i2c-sensor.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/i2c-sensor.c	2004-01-19 22:17:21.000000000 -0800
@@ -19,7 +19,10 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-/* #define DEBUG 1 */
+#include <linux/config.h>
+#ifdef CONFIG_I2C_DEBUG_CORE
+#define DEBUG	1
+#endif
 
 #include <linux/module.h>
 #include <linux/kernel.h>
diff -puN drivers/i2c/Kconfig~linus drivers/i2c/Kconfig
--- 25/drivers/i2c/Kconfig~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/i2c/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -37,9 +37,35 @@ config I2C_CHARDEV
 	  This support is also available as a module.  If so, the module 
 	  will be called i2c-dev.
 
-	source drivers/i2c/algos/Kconfig
-	source drivers/i2c/busses/Kconfig
-	source drivers/i2c/chips/Kconfig
+source drivers/i2c/algos/Kconfig
+source drivers/i2c/busses/Kconfig
+source drivers/i2c/chips/Kconfig
+
+config I2C_DEBUG_CORE
+	bool "I2C Core debugging messages"
+	depends on I2C
+	help
+	  Say Y here if you want the I2C core to produce a bunch of debug
+	  messages to the system log.  Select this if you are having a
+	  problem with I2C support and want to see more of what is going on.
+
+config I2C_DEBUG_BUS
+	bool "I2C Bus debugging messages"
+	depends on I2C
+	help
+	  Say Y here if you want the I2C bus drivers to produce a bunch of
+	  debug messages to the system log.  Select this if you are having
+	  a problem with I2C support and want to see more of what is going
+	  on.
+
+config I2C_DEBUG_CHIP
+	bool "I2C Chip debugging messages"
+	depends on I2C
+	help
+	  Say Y here if you want the I2C chip drivers to produce a bunch of
+	  debug messages to the system log.  Select this if you are having
+	  a problem with I2C support and want to see more of what is going
+	  on.
 
 endmenu
 
diff -puN drivers/ide/ide.c~linus drivers/ide/ide.c
--- 25/drivers/ide/ide.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ide/ide.c	2004-01-19 22:17:22.000000000 -0800
@@ -1620,12 +1620,6 @@ int generic_ide_ioctl(struct block_devic
 			switch(drive->media) {
 				case ide_disk:
 					return ide_taskfile_ioctl(drive, cmd, arg);
-#ifdef CONFIG_PKT_TASK_IOCTL
-				case ide_cdrom:
-				case ide_tape:
-				case ide_floppy:
-					return pkt_taskfile_ioctl(drive, cmd, arg);
-#endif /* CONFIG_PKT_TASK_IOCTL */
 				default:
 					return -ENOMSG;
 			}
diff -puN drivers/ide/ide-cd.c~linus drivers/ide/ide-cd.c
--- 25/drivers/ide/ide-cd.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ide/ide-cd.c	2004-01-19 22:17:22.000000000 -0800
@@ -291,10 +291,13 @@
  *			- Use extended sense on drives that support it for
  *			  correctly reporting tray status -- from
  *			  Michael D Johnson <johnsom@orst.edu>
+ * 4.60  Dec 17, 2003	- Add mt rainier support
+ *			- Bump timeout for packet commands, matches sr
+ *			- Odd stuff
  *
  *************************************************************************/
  
-#define IDECD_VERSION "4.59-ac1"
+#define IDECD_VERSION "4.60"
 
 #include <linux/config.h>
 #include <linux/module.h>
@@ -774,11 +777,36 @@ static int cdrom_decode_status(ide_drive
 
 		if (sense_key == NOT_READY) {
 			/* Tray open. */
-			cdrom_saw_media_change (drive);
+			if (rq_data_dir(rq) == READ) {
+				cdrom_saw_media_change (drive);
 
-			/* Fail the request. */
-			printk ("%s: tray open\n", drive->name);
-			do_end_request = 1;
+				/* Fail the request. */
+				printk ("%s: tray open\n", drive->name);
+				do_end_request = 1;
+			} else {
+				struct cdrom_info *info = drive->driver_data;
+
+				/* allow the drive 5 seconds to recover, some
+				 * devices will return this error while flushing
+				 * data from cache */
+				if (!rq->errors)
+					info->write_timeout = jiffies + ATAPI_WAIT_WRITE_BUSY;
+				rq->errors = 1;
+				if (time_after(jiffies, info->write_timeout))
+					do_end_request = 1;
+				else {
+					unsigned long flags;
+
+					/*
+					 * take a breather relying on the
+					 * unplug timer to kick us again
+					 */
+					spin_lock_irqsave(&ide_lock, flags);
+					blk_plug_device(drive->queue);
+					spin_unlock_irqrestore(&ide_lock,flags);
+					return 1;
+				}
+			}
 		} else if (sense_key == UNIT_ATTENTION) {
 			/* Media change. */
 			cdrom_saw_media_change (drive);
@@ -844,9 +872,13 @@ static int cdrom_timer_expiry(ide_drive_
 		case GPCMD_BLANK:
 		case GPCMD_FORMAT_UNIT:
 		case GPCMD_RESERVE_RZONE_TRACK:
-			wait = WAIT_CMD;
+		case GPCMD_CLOSE_TRACK:
+		case GPCMD_FLUSH_CACHE:
+			wait = ATAPI_WAIT_PC;
 			break;
 		default:
+			if (!(rq->flags & REQ_QUIET))
+				printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", rq->cmd[0]);
 			wait = 0;
 			break;
 	}
@@ -894,7 +926,7 @@ static ide_startstop_t cdrom_start_packe
  
 	if (CDROM_CONFIG_FLAGS (drive)->drq_interrupt) {
 		/* packet command */
-		ide_execute_command(drive, WIN_PACKETCMD, handler, WAIT_CMD, cdrom_timer_expiry);
+		ide_execute_command(drive, WIN_PACKETCMD, handler, ATAPI_WAIT_PC, cdrom_timer_expiry);
 		return ide_started;
 	} else {
 		/* packet command */
@@ -1167,7 +1199,7 @@ static ide_startstop_t cdrom_read_intr (
 	}
 
 	/* Done moving data!  Wait for another interrupt. */
-	ide_set_handler(drive, &cdrom_read_intr, WAIT_CMD, NULL);
+	ide_set_handler(drive, &cdrom_read_intr, ATAPI_WAIT_PC, NULL);
 	return ide_started;
 }
 
@@ -1277,7 +1309,7 @@ static ide_startstop_t cdrom_start_read_
 		(65534 / CD_FRAMESIZE) : 65535);
 
 	/* Set up the command */
-	rq->timeout = WAIT_CMD;
+	rq->timeout = ATAPI_WAIT_PC;
 
 	/* Send the command to the drive and return. */
 	return cdrom_transfer_packet_command(drive, rq, &cdrom_read_intr);
@@ -1286,7 +1318,7 @@ static ide_startstop_t cdrom_start_read_
 
 #define IDECD_SEEK_THRESHOLD	(1000)			/* 1000 blocks */
 #define IDECD_SEEK_TIMER	(5 * WAIT_MIN_SLEEP)	/* 100 ms */
-#define IDECD_SEEK_TIMEOUT     WAIT_CMD			/* 10 sec */
+#define IDECD_SEEK_TIMEOUT	(2 * WAIT_CMD)		/* 20 sec */
 
 static ide_startstop_t cdrom_seek_intr (ide_drive_t *drive)
 {
@@ -1326,7 +1358,7 @@ static ide_startstop_t cdrom_start_seek_
 	rq->cmd[0] = GPCMD_SEEK;
 	put_unaligned(cpu_to_be32(frame), (unsigned int *) &rq->cmd[2]);
 
-	rq->timeout = WAIT_CMD;
+	rq->timeout = ATAPI_WAIT_PC;
 	return cdrom_transfer_packet_command(drive, rq, &cdrom_seek_intr);
 }
 
@@ -1502,7 +1534,7 @@ confused:
 	}
 
 	/* Now we wait for another interrupt. */
-	ide_set_handler(drive, &cdrom_pc_intr, WAIT_CMD, cdrom_timer_expiry);
+	ide_set_handler(drive, &cdrom_pc_intr, ATAPI_WAIT_PC, cdrom_timer_expiry);
 	return ide_started;
 }
 
@@ -1511,7 +1543,7 @@ static ide_startstop_t cdrom_do_pc_conti
 	struct request *rq = HWGROUP(drive)->rq;
 
 	if (!rq->timeout)
-		rq->timeout = WAIT_CMD;
+		rq->timeout = ATAPI_WAIT_PC;
 
 	/* Send the command to the drive and return. */
 	return cdrom_transfer_packet_command(drive, rq, &cdrom_pc_intr);
@@ -1716,11 +1748,8 @@ static ide_startstop_t cdrom_newpc_intr(
 	/*
 	 * If DRQ is clear, the command has completed.
 	 */
-	if ((stat & DRQ_STAT) == 0) {
-		if (rq->data_len)
-			printk("%s: %u residual after xfer\n", __FUNCTION__, rq->data_len);
+	if ((stat & DRQ_STAT) == 0)
 		goto end_request;
-	}
 
 	/*
 	 * check which way to transfer data
@@ -1826,10 +1855,8 @@ static ide_startstop_t cdrom_write_intr(
 		}
 	}
 
-	if (cdrom_decode_status(drive, 0, &stat)) {
-		printk("ide-cd: write_intr decode_status bad\n");
+	if (cdrom_decode_status(drive, 0, &stat))
 		return ide_stopped;
-	}
 
 	/*
 	 * using dma, transfer is complete now
@@ -1904,7 +1931,7 @@ static ide_startstop_t cdrom_write_intr(
 	}
 
 	/* re-arm handler */
-	ide_set_handler(drive, &cdrom_write_intr, 5 * WAIT_CMD, NULL);
+	ide_set_handler(drive, &cdrom_write_intr, ATAPI_WAIT_PC, NULL);
 	return ide_started;
 }
 
@@ -1915,7 +1942,7 @@ static ide_startstop_t cdrom_start_write
 #if 0	/* the immediate bit */
 	rq->cmd[1] = 1 << 3;
 #endif
-	rq->timeout = 2 * WAIT_CMD;
+	rq->timeout = ATAPI_WAIT_PC;
 
 	return cdrom_transfer_packet_command(drive, rq, cdrom_write_intr);
 }
@@ -1956,7 +1983,7 @@ static ide_startstop_t cdrom_do_newpc_co
 	struct request *rq = HWGROUP(drive)->rq;
 
 	if (!rq->timeout)
-		rq->timeout = WAIT_CMD;
+		rq->timeout = ATAPI_WAIT_PC;
 
 	return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr);
 }
@@ -2242,6 +2269,7 @@ static int cdrom_read_toc(ide_drive_t *d
 		struct atapi_toc_header hdr;
 		struct atapi_toc_entry  ent;
 	} ms_tmp;
+	long last_written;
 
 	if (toc == NULL) {
 		/* Try to allocate space. */
@@ -2261,6 +2289,13 @@ static int cdrom_read_toc(ide_drive_t *d
 	if (CDROM_STATE_FLAGS(drive)->toc_valid)
 		return 0;
 
+	/* Try to get the total cdrom capacity. */
+	stat = cdrom_read_capacity(drive, &toc->capacity, sense);
+	if (stat)
+		toc->capacity = 0x1fffff;
+
+	set_capacity(drive->disk, toc->capacity * SECTORS_PER_FRAME);
+
 	/* First read just the header, so we know how long the TOC is. */
 	stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr,
 				    sizeof(struct atapi_toc_header), sense);
@@ -2368,13 +2403,11 @@ static int cdrom_read_toc(ide_drive_t *d
 	toc->xa_flag = (ms_tmp.hdr.first_track != ms_tmp.hdr.last_track);
 
 	/* Now try to get the total cdrom capacity. */
-	stat = cdrom_get_last_written(cdi, (long *) &toc->capacity);
-	if (stat || !toc->capacity)
-		stat = cdrom_read_capacity(drive, &toc->capacity, sense);
-	if (stat)
-		toc->capacity = 0x1fffff;
-
-	set_capacity(drive->disk, toc->capacity * SECTORS_PER_FRAME);
+	stat = cdrom_get_last_written(cdi, &last_written);
+	if (!stat && last_written) {
+		toc->capacity = last_written;
+		set_capacity(drive->disk, toc->capacity * SECTORS_PER_FRAME);
+	}
 
 	/* Remember that we've read this stuff. */
 	CDROM_STATE_FLAGS(drive)->toc_valid = 1;
@@ -2483,7 +2516,7 @@ static int ide_cdrom_packet(struct cdrom
 	ide_drive_t *drive = (ide_drive_t*) cdi->handle;
 
 	if (cgc->timeout <= 0)
-		cgc->timeout = WAIT_CMD;
+		cgc->timeout = ATAPI_WAIT_PC;
 
 	/* here we queue the commands from the uniform CD-ROM
 	   layer. the packet must be complete, as we do not
@@ -2688,37 +2721,49 @@ int ide_cdrom_select_speed (struct cdrom
         return 0;
 }
 
+/*
+ * add logic to try GET_EVENT command first to check for media and tray
+ * status. this should be supported by newer cd-r/w and all DVD etc
+ * drives
+ */
 static
 int ide_cdrom_drive_status (struct cdrom_device_info *cdi, int slot_nr)
 {
 	ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+	struct media_event_desc med;
+	struct request_sense sense;
+	int stat;
 
-	if (slot_nr == CDSL_CURRENT) {
-		struct request_sense sense;
-		int stat = cdrom_check_status(drive, &sense);
-		if (stat == 0 || sense.sense_key == UNIT_ATTENTION)
-			return CDS_DISC_OK;
+	if (slot_nr != CDSL_CURRENT)
+		return -EINVAL;
 
-		if (sense.sense_key == NOT_READY && sense.asc == 0x04 &&
-		    sense.ascq == 0x04)
-			return CDS_DISC_OK;
+	stat = cdrom_check_status(drive, &sense);
+	if (!stat || sense.sense_key == UNIT_ATTENTION)
+		return CDS_DISC_OK;
 
+	if (!cdrom_get_media_event(cdi, &med)) {
+		if (med.media_present)
+			return CDS_DISC_OK;
+		if (med.door_open)
+			return CDS_TRAY_OPEN;
+	}
 
-		/*
-		 * If not using Mt Fuji extended media tray reports,
-		 * just return TRAY_OPEN since ATAPI doesn't provide
-		 * any other way to detect this...
-		 */
-		if (sense.sense_key == NOT_READY) {
-			if (sense.asc == 0x3a && sense.ascq == 1)
-				return CDS_NO_DISC;
-			else
-				return CDS_TRAY_OPEN;
-		}
+	if (sense.sense_key == NOT_READY && sense.asc == 0x04 && sense.ascq == 0x04)
+		return CDS_DISC_OK;
 
-		return CDS_DRIVE_NOT_READY;
+	/*
+	 * If not using Mt Fuji extended media tray reports,
+	 * just return TRAY_OPEN since ATAPI doesn't provide
+	 * any other way to detect this...
+	 */
+	if (sense.sense_key == NOT_READY) {
+		if (sense.asc == 0x3a && sense.ascq == 1)
+			return CDS_NO_DISC;
+		else
+			return CDS_TRAY_OPEN;
 	}
-	return -EINVAL;
+
+	return CDS_DRIVE_NOT_READY;
 }
 
 static
@@ -2826,7 +2871,8 @@ static struct cdrom_device_ops ide_cdrom
 				CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET |
 				CDC_IOCTLS | CDC_DRIVE_STATUS | CDC_CD_R |
 				CDC_CD_RW | CDC_DVD | CDC_DVD_R| CDC_DVD_RAM |
-				CDC_GENERIC_PACKET | CDC_MO_DRIVE,
+				CDC_GENERIC_PACKET | CDC_MO_DRIVE | CDC_MRW |
+				CDC_MRW_W | CDC_RAM,
 	.generic_packet		= ide_cdrom_packet,
 };
 
@@ -2861,6 +2907,10 @@ static int ide_cdrom_register (ide_drive
 		devinfo->mask |= CDC_CLOSE_TRAY;
 	if (!CDROM_CONFIG_FLAGS(drive)->mo_drive)
 		devinfo->mask |= CDC_MO_DRIVE;
+	if (!CDROM_CONFIG_FLAGS(drive)->mrw)
+		devinfo->mask |= CDC_MRW;
+	if (!CDROM_CONFIG_FLAGS(drive)->mrw_w)
+		devinfo->mask |= CDC_MRW_W;
 
 	return register_cdrom(devinfo);
 }
@@ -2881,14 +2931,6 @@ int ide_cdrom_get_capabilities(ide_drive
 	    !strcmp(drive->id->model, "WPI CDS-32X")))
 		size -= sizeof(cap->pad);
 
-	/* we have to cheat a little here. the packet will eventually
-	 * be queued with ide_cdrom_packet(), which extracts the
-	 * drive from cdi->handle. Since this device hasn't been
-	 * registered with the Uniform layer yet, it can't do this.
-	 * Same goes for cdi->ops.
-	 */
-	cdi->handle = (ide_drive_t *) drive;
-	cdi->ops = &ide_cdrom_dops;
 	init_cdrom_command(&cgc, cap, size, CGC_DATA_UNKNOWN);
 	do { /* we seem to get stat=0x01,err=0x00 the first time (??) */
 		stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CAPABILITIES_PAGE, 0);
@@ -2904,23 +2946,43 @@ int ide_cdrom_probe_capabilities (ide_dr
 	struct cdrom_info *info = drive->driver_data;
 	struct cdrom_device_info *cdi = &info->devinfo;
 	struct atapi_capabilities_page cap;
-	int nslots = 1;
+	int nslots = 1, mrw_write = 0;
 
 	if (drive->media == ide_optical) {
 		CDROM_CONFIG_FLAGS(drive)->mo_drive = 1;
+		CDROM_CONFIG_FLAGS(drive)->ram = 1;
 		printk("%s: ATAPI magneto-optical drive\n", drive->name);
 		return nslots;
 	}
 
-	if (CDROM_CONFIG_FLAGS(drive)->nec260) {
-		CDROM_CONFIG_FLAGS(drive)->no_eject = 0;                       
-		CDROM_CONFIG_FLAGS(drive)->audio_play = 1;       
+	if (CDROM_CONFIG_FLAGS(drive)->nec260 ||
+	    !strcmp(drive->id->model,"STINGRAY 8422 IDE 8X CD-ROM 7-27-95")) {
+		CDROM_CONFIG_FLAGS(drive)->no_eject = 0;
+		CDROM_CONFIG_FLAGS(drive)->audio_play = 1;
 		return nslots;
 	}
 
+	/*
+	 * we have to cheat a little here. the packet will eventually
+	 * be queued with ide_cdrom_packet(), which extracts the
+	 * drive from cdi->handle. Since this device hasn't been
+	 * registered with the Uniform layer yet, it can't do this.
+	 * Same goes for cdi->ops.
+	 */
+	cdi->handle = (ide_drive_t *) drive;
+	cdi->ops = &ide_cdrom_dops;
+
 	if (ide_cdrom_get_capabilities(drive, &cap))
 		return 0;
 
+	if (!cdrom_is_mrw(cdi, &mrw_write)) {
+		CDROM_CONFIG_FLAGS(drive)->mrw = 1;
+		if (mrw_write) {
+			CDROM_CONFIG_FLAGS(drive)->mrw_w = 1;
+			CDROM_CONFIG_FLAGS(drive)->ram = 1;
+		}
+	}
+
 	if (cap.lock == 0)
 		CDROM_CONFIG_FLAGS(drive)->no_doorlock = 1;
 	if (cap.eject)
@@ -2933,8 +2995,10 @@ int ide_cdrom_probe_capabilities (ide_dr
 		CDROM_CONFIG_FLAGS(drive)->test_write = 1;
 	if (cap.dvd_ram_read || cap.dvd_r_read || cap.dvd_rom)
 		CDROM_CONFIG_FLAGS(drive)->dvd = 1;
-	if (cap.dvd_ram_write)
+	if (cap.dvd_ram_write) {
 		CDROM_CONFIG_FLAGS(drive)->dvd_ram = 1;
+		CDROM_CONFIG_FLAGS(drive)->ram = 1;
+	}
 	if (cap.dvd_r_write)
 		CDROM_CONFIG_FLAGS(drive)->dvd_r = 1;
 	if (cap.audio_play)
@@ -2998,6 +3062,9 @@ int ide_cdrom_probe_capabilities (ide_dr
         	(CDROM_CONFIG_FLAGS(drive)->cd_r)? "-R" : "", 
         	(CDROM_CONFIG_FLAGS(drive)->cd_rw)? "/RW" : "");
 
+	if (CDROM_CONFIG_FLAGS(drive)->mrw || CDROM_CONFIG_FLAGS(drive)->mrw_w)
+		printk(" CD-MR%s", CDROM_CONFIG_FLAGS(drive)->mrw_w ? "W" : "");
+
         if (CDROM_CONFIG_FLAGS(drive)->is_changer) 
         	printk(" changer w/%d slots", nslots);
         else 	
@@ -3105,14 +3172,11 @@ int ide_cdrom_setup (ide_drive_t *drive)
 	struct cdrom_device_info *cdi = &info->devinfo;
 	int nslots;
 
-	/*
-	 * default to read-only always and fix latter at the bottom
-	 */
-	set_disk_ro(drive->disk, 1);
-	blk_queue_hardsect_size(drive->queue, CD_FRAMESIZE);
-
 	blk_queue_prep_rq(drive->queue, ide_cdrom_prep_fn);
 	blk_queue_dma_alignment(drive->queue, 3);
+	drive->queue->unplug_delay = (1 * HZ) / 1000;
+	if (!drive->queue->unplug_delay)
+		drive->queue->unplug_delay = 1;
 
 	drive->special.all	= 0;
 	drive->ready_stat	= 0;
@@ -3215,8 +3279,11 @@ int ide_cdrom_setup (ide_drive_t *drive)
 
 	nslots = ide_cdrom_probe_capabilities (drive);
 
-	if (CDROM_CONFIG_FLAGS(drive)->dvd_ram)
-		set_disk_ro(drive->disk, 0);
+	/*
+	 * set correct block size and read-only for non-ram media
+	 */
+	set_disk_ro(drive->disk, !CDROM_CONFIG_FLAGS(drive)->ram);
+	blk_queue_hardsect_size(drive->queue, CD_FRAMESIZE);
 
 #if 0
 	drive->dsc_overlap = (HWIF(drive)->no_dsc) ? 0 : 1;
diff -puN drivers/ide/ide-cd.h~linus drivers/ide/ide-cd.h
--- 25/drivers/ide/ide-cd.h~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ide/ide-cd.h	2004-01-19 22:17:22.000000000 -0800
@@ -35,6 +35,12 @@
 #define NO_DOOR_LOCKING 0
 #endif
 
+/*
+ * typical timeout for packet command
+ */
+#define ATAPI_WAIT_PC		(60 * HZ)
+#define ATAPI_WAIT_WRITE_BUSY	(10 * HZ)
+
 /************************************************************************/
 
 #define SECTOR_BITS 		9
@@ -75,6 +81,9 @@ struct ide_cd_config_flags {
 	__u8 dvd		: 1; /* Drive is a DVD-ROM */
 	__u8 dvd_r		: 1; /* Drive can write DVD-R */
 	__u8 dvd_ram		: 1; /* Drive can write DVD-RAM */
+	__u8 mrw		: 1; /* drive can read mrw */
+	__u8 mrw_w		: 1; /* drive can write mrw */
+	__u8 ram		: 1; /* generic WRITE (dvd-ram/mrw) */
 	__u8 test_write		: 1; /* Drive can fake writes */
 	__u8 supp_disc_present	: 1; /* Changer can report exact contents
 					of slots. */
@@ -482,6 +491,8 @@ struct cdrom_info {
 
         /* Per-device info needed by cdrom.c generic driver. */
         struct cdrom_device_info devinfo;
+
+	unsigned long write_timeout;
 };
 
 /****************************************************************************
diff -puN drivers/ide/ide-disk.c~linus drivers/ide/ide-disk.c
--- 25/drivers/ide/ide-disk.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ide/ide-disk.c	2004-01-19 22:17:22.000000000 -0800
@@ -239,8 +239,6 @@ static ide_startstop_t write_intr (ide_d
  * ide_multwrite() transfers a block of up to mcount sectors of data
  * to a drive as part of a disk multiple-sector write operation.
  *
- * Returns 0 on success.
- *
  * Note that we may be called from two contexts - __ide_do_rw_disk() context
  * and IRQ context. The IRQ can happen any time after we've output the
  * full "mcount" number of sectors, so we must make sure we update the
@@ -251,7 +249,7 @@ static ide_startstop_t write_intr (ide_d
  * is shorter or smaller than the BH segment then we should be OKAY.
  * This is only valid if we can rewind the rq->current_nr_sectors counter.
  */
-int ide_multwrite (ide_drive_t *drive, unsigned int mcount)
+static void ide_multwrite(ide_drive_t *drive, unsigned int mcount)
 {
  	ide_hwgroup_t *hwgroup	= HWGROUP(drive);
  	struct request *rq	= &hwgroup->wrq;
@@ -279,7 +277,7 @@ int ide_multwrite (ide_drive_t *drive, u
 			 * all bvecs in this one.
 			 */
 			if (++bio->bi_idx >= bio->bi_vcnt) {
-				bio->bi_idx = 0;
+				bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments;
 				bio = bio->bi_next;
 			}
 
@@ -288,7 +286,8 @@ int ide_multwrite (ide_drive_t *drive, u
 				mcount = 0;
 			} else {
 				rq->bio = bio;
-				rq->current_nr_sectors = bio_iovec(bio)->bv_len >> 9;
+				rq->nr_cbio_segments = bio_segments(bio);
+				rq->current_nr_sectors = bio_cur_sectors(bio);
 				rq->hard_cur_sectors = rq->current_nr_sectors;
 			}
 		}
@@ -300,8 +299,6 @@ int ide_multwrite (ide_drive_t *drive, u
 		taskfile_output_data(drive, buffer, nsect<<7);
 		ide_unmap_buffer(rq, buffer, &flags);
 	} while (mcount);
-
-        return 0;
 }
 
 /*
@@ -312,6 +309,7 @@ static ide_startstop_t multwrite_intr (i
 	ide_hwgroup_t *hwgroup	= HWGROUP(drive);
 	ide_hwif_t *hwif	= HWIF(drive);
 	struct request *rq	= &hwgroup->wrq;
+	struct bio *bio		= rq->bio;
 	u8 stat;
 
 	stat = hwif->INB(IDE_STATUS_REG);
@@ -322,8 +320,7 @@ static ide_startstop_t multwrite_intr (i
 			 *	of the request
 			 */
 			if (rq->nr_sectors) {
-				if (ide_multwrite(drive, drive->mult_count))
-					return ide_stopped;
+				ide_multwrite(drive, drive->mult_count);
 				ide_set_handler(drive, &multwrite_intr, WAIT_CMD, NULL);
 				return ide_started;
 			}
@@ -333,14 +330,17 @@ static ide_startstop_t multwrite_intr (i
 			 *	we can end the original request.
 			 */
 			if (!rq->nr_sectors) {	/* all done? */
+				bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments;
 				rq = hwgroup->rq;
 				ide_end_request(drive, 1, rq->nr_sectors);
 				return ide_stopped;
 			}
 		}
+		bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments;
 		/* the original code did this here (?) */
 		return ide_stopped;
 	}
+	bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments;
 	return DRIVER(drive)->error(drive, "multwrite_intr", stat);
 }
 
@@ -506,27 +506,10 @@ ide_startstop_t __ide_do_rw_disk (ide_dr
 			local_irq_disable();
 		if (drive->mult_count) {
 			ide_hwgroup_t *hwgroup = HWGROUP(drive);
-	/*
-	 * Ugh.. this part looks ugly because we MUST set up
-	 * the interrupt handler before outputting the first block
-	 * of data to be written.  If we hit an error (corrupted buffer list)
-	 * in ide_multwrite(), then we need to remove the handler/timer
-	 * before returning.  Fortunately, this NEVER happens (right?).
-	 *
-	 * Except when you get an error it seems...
-	 *
-	 * MAJOR DATA INTEGRITY BUG !!! only if we error 
-	 */
+
 			hwgroup->wrq = *rq; /* scratchpad */
 			ide_set_handler(drive, &multwrite_intr, WAIT_CMD, NULL);
-			if (ide_multwrite(drive, drive->mult_count)) {
-				unsigned long flags;
-				spin_lock_irqsave(&ide_lock, flags);
-				hwgroup->handler = NULL;
-				del_timer(&hwgroup->timer);
-				spin_unlock_irqrestore(&ide_lock, flags);
-				return ide_stopped;
-			}
+			ide_multwrite(drive, drive->mult_count);
 		} else {
 			unsigned long flags;
 			char *to = ide_map_buffer(rq, &flags);
diff -puN drivers/ide/ide-taskfile.c~linus drivers/ide/ide-taskfile.c
--- 25/drivers/ide/ide-taskfile.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ide/ide-taskfile.c	2004-01-19 22:17:22.000000000 -0800
@@ -2208,28 +2208,3 @@ ide_startstop_t flagged_task_mulout_intr
 
 	return ide_started;
 }
-
-/*
- * Beginning of Taskfile OPCODE Library and feature sets.
- */
-
-#ifdef CONFIG_PKT_TASK_IOCTL
-
-int pkt_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
-{
-#if 0
-	switch(req_task->data_phase) {
-		case TASKFILE_P_OUT_DMAQ:
-		case TASKFILE_P_IN_DMAQ:
-		case TASKFILE_P_OUT_DMA:
-		case TASKFILE_P_IN_DMA:
-		case TASKFILE_P_OUT:
-		case TASKFILE_P_IN:
-	}
-#endif
-	return -ENOMSG;
-}
-
-EXPORT_SYMBOL(pkt_taskfile_ioctl);
-
-#endif /* CONFIG_PKT_TASK_IOCTL */
diff -puN drivers/ide/Kconfig~linus drivers/ide/Kconfig
--- 25/drivers/ide/Kconfig~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ide/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -97,7 +97,7 @@ comment "Please see Documentation/ide.tx
 
 config BLK_DEV_HD_IDE
 	bool "Use old disk-only driver on primary interface"
-	depends on X86 && X86_PC9800!=y
+	depends on ((X86 && X86_PC9800!=y) || SH_MPC1211)
 	---help---
 	  There are two drivers for MFM/RLL/IDE disks.  Most people use just
 	  the new enhanced driver by itself.  This option however installs the
@@ -734,10 +734,10 @@ config BLK_DEV_PDC202XX_NEW
 
 # FIXME - probably wants to be one for old and for new
 config PDC202XX_FORCE
-	bool "Special FastTrak Feature"
+	bool "Enable controller even if disabled by BIOS"
 	depends on BLK_DEV_PDC202XX_NEW=y
 	help
-	  For FastTrak enable overriding BIOS.
+	  Enable the PDC202xx controller even if it has been disabled in the BIOS setup.
 
 config BLK_DEV_SVWKS
 	tristate "ServerWorks OSB4/CSB5/CSB6 chipsets support"
@@ -747,7 +747,7 @@ config BLK_DEV_SVWKS
 
 config BLK_DEV_SGIIOC4
 	tristate "Silicon Graphics IOC4 chipset support"
-	depends on IA64_SGI_SN2
+	depends on IA64_SGI_SN2 || IA64_GENERIC
 	help
 	  This driver adds PIO & MultiMode DMA-2 support for the SGI IOC4
 	  chipset, which has one channel and can support two devices.
@@ -899,12 +899,16 @@ config BLK_DEV_GAYLE
 	bool "Amiga Gayle IDE interface support"
 	depends on AMIGA
 	help
-	  This is the IDE driver for the builtin IDE interface on some Amiga
-	  models. It supports both the `A1200 style' (used in A600 and A1200)
-	  and `A4000 style' (used in A4000 and A4000T) of the Gayle IDE
-	  interface. Say Y if you have such an Amiga model and want to use IDE
-	  devices (hard disks, CD-ROM drives, etc.) that are connected to the
-	  builtin IDE interface.
+	  This is the IDE driver for the Amiga Gayle IDE interface. It supports
+	  both the `A1200 style' and `A4000 style' of the Gayle IDE interface,
+	  This includes builtin IDE interfaces on some Amiga models (A600,
+	  A1200, A4000, and A4000T), and IDE interfaces on the Zorro expansion
+	  bus (M-Tech E-Matrix 530 expansion card).
+	  Say Y if you have an Amiga with a Gayle IDE interface and want to use
+	  IDE devices (hard disks, CD-ROM drives, etc.) that are connected to
+	  it.
+	  Note that you also have to enable Zorro bus support if you want to
+	  use Gayle IDE interfaces on the Zorro expansion bus.
 
 config BLK_DEV_IDEDOUBLER
 	bool "Amiga IDE Doubler support (EXPERIMENTAL)"
diff -puN drivers/ide/legacy/buddha.c~linus drivers/ide/legacy/buddha.c
--- 25/drivers/ide/legacy/buddha.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ide/legacy/buddha.c	2004-01-19 22:17:22.000000000 -0800
@@ -146,6 +146,7 @@ static int xsurf_ack_intr(ide_hwif_t *hw
 void __init buddha_init(void)
 {
 	hw_regs_t hw;
+	ide_hwif_t *hwif;
 	int i, index;
 
 	struct zorro_dev *z = NULL;
@@ -212,8 +213,9 @@ fail_base2:
 						IRQ_AMIGA_PORTS);
 			}	
 			
-			index = ide_register_hw(&hw, NULL);
+			index = ide_register_hw(&hw, &hwif);
 			if (index != -1) {
+				hwif->mmio = 2;
 				printk("ide%d: ", index);
 				switch(type) {
 				case BOARD_BUDDHA:
diff -puN drivers/ide/legacy/gayle.c~linus drivers/ide/legacy/gayle.c
--- 25/drivers/ide/legacy/gayle.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ide/legacy/gayle.c	2004-01-19 22:17:22.000000000 -0800
@@ -29,7 +29,7 @@
      */
 
 #define GAYLE_BASE_4000	0xdd2020	/* A4000/A4000T */
-#define GAYLE_BASE_1200	0xda0000	/* A1200/A600 */
+#define GAYLE_BASE_1200	0xda0000	/* A1200/A600 and E-Matrix 530 */
 
     /*
      *  Offsets from one of the above bases
@@ -118,9 +118,17 @@ void __init gayle_init(void)
     if (!MACH_IS_AMIGA)
 	return;
 
-    if (!(a4000 = AMIGAHW_PRESENT(A4000_IDE)) && !AMIGAHW_PRESENT(A1200_IDE))
-	return;
+    if ((a4000 = AMIGAHW_PRESENT(A4000_IDE)) || AMIGAHW_PRESENT(A1200_IDE))
+	goto found;
+
+#ifdef CONFIG_ZORRO
+    if (zorro_find_device(ZORRO_PROD_MTEC_VIPER_MK_V_E_MATRIX_530_SCSI_IDE,
+			  NULL))
+	goto found;
+#endif
+    return;
 
+found:
     for (i = 0; i < GAYLE_NUM_PROBE_HWIFS; i++) {
 	unsigned long base, ctrlport, irqport;
 	ide_ack_intr_t *ack_intr;
@@ -174,16 +182,5 @@ void __init gayle_init(void)
 	    }
 	} else
 	    release_mem_region(res_start, res_n);
-
-#if 1 /* TESTING */
-	if (i == 1) {
-	    volatile u_short *addr = (u_short *)base;
-	    u_short data;
-	    printk("+++ Probing for IDE doubler... ");
-	    *addr = 0xffff;
-	    data = *addr;
-	    printk("probe returned 0x%02x (PLEASE REPORT THIS!!)\n", data);
-	}
-#endif /* TESTING */
     }
 }
diff -puN drivers/ide/legacy/ide-cs.c~linus drivers/ide/legacy/ide-cs.c
--- 25/drivers/ide/legacy/ide-cs.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ide/legacy/ide-cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -152,7 +152,7 @@ static dev_link_t *ide_attach(void)
     client_reg.event_handler = &ide_event;
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
-    ret = CardServices(RegisterClient, &link->handle, &client_reg);
+    ret = pcmcia_register_client(&link->handle, &client_reg);
     if (ret != CS_SUCCESS) {
 	cs_error(link->handle, RegisterClient, ret);
 	ide_detach(link);
@@ -188,7 +188,7 @@ static void ide_detach(dev_link_t *link)
 	ide_release(link);
     
     if (link->handle) {
-	ret = CardServices(DeregisterClient, link->handle);
+	ret = pcmcia_deregister_client(link->handle);
 	if (ret != CS_SUCCESS)
 	    cs_error(link->handle, DeregisterClient, ret);
     }
@@ -207,11 +207,8 @@ static void ide_detach(dev_link_t *link)
 
 ======================================================================*/
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
-
-#define CFG_CHECK(fn, args...) \
-if (CardServices(fn, args) != 0) goto next_entry
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq)
 {
@@ -241,16 +238,16 @@ void ide_config(dev_link_t *link)
     tuple.TupleOffset = 0; tuple.TupleDataMax = 255;
     tuple.Attributes = 0;
     tuple.DesiredTuple = CISTPL_CONFIG;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
-    CS_CHECK(GetTupleData, handle, &tuple);
-    CS_CHECK(ParseTuple, handle, &tuple, &parse);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+    CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+    CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
     link->conf.ConfigBase = parse.config.base;
     link->conf.Present = parse.config.rmask[0];
 
     tuple.DesiredTuple = CISTPL_MANFID;
-    if (!CardServices(GetFirstTuple, handle, &tuple) &&
-	!CardServices(GetTupleData, handle, &tuple) &&
-	!CardServices(ParseTuple, handle, &tuple, &parse))
+    if (!pcmcia_get_first_tuple(handle, &tuple) &&
+	!pcmcia_get_tuple_data(handle, &tuple) &&
+	!pcmcia_parse_tuple(handle, &tuple, &parse))
 	is_kme = ((parse.manfid.manf == MANFID_KME) &&
 		  ((parse.manfid.card == PRODID_KME_KXLC005_A) ||
 		   (parse.manfid.card == PRODID_KME_KXLC005_B)));
@@ -259,16 +256,16 @@ void ide_config(dev_link_t *link)
     link->state |= DEV_CONFIG;
 
     /* Not sure if this is right... look up the current Vcc */
-    CS_CHECK(GetConfigurationInfo, handle, &conf);
+    CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf));
     link->conf.Vcc = conf.Vcc;
     
     pass = io_base = ctl_base = 0;
     tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
     tuple.Attributes = 0;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
     while (1) {
-	CFG_CHECK(GetTupleData, handle, &tuple);
-	CFG_CHECK(ParseTuple, handle, &tuple, &parse);
+    	if (pcmcia_get_tuple_data(handle, &tuple) != 0) goto next_entry;
+	if (pcmcia_parse_tuple(handle, &tuple, &parse) != 0) goto next_entry;
 
 	/* Check for matching Vcc, unless we're desperate */
 	if (!pass) {
@@ -299,13 +296,15 @@ void ide_config(dev_link_t *link)
 		link->io.NumPorts1 = 8;
 		link->io.BasePort2 = io->win[1].base;
 		link->io.NumPorts2 = (is_kme) ? 2 : 1;
-		CFG_CHECK(RequestIO, link->handle, &link->io);
+		if (pcmcia_request_io(link->handle, &link->io) != 0)
+			goto next_entry;
 		io_base = link->io.BasePort1;
 		ctl_base = link->io.BasePort2;
 	    } else if ((io->nwin == 1) && (io->win[0].len >= 16)) {
 		link->io.NumPorts1 = io->win[0].len;
 		link->io.NumPorts2 = 0;
-		CFG_CHECK(RequestIO, link->handle, &link->io);
+		if (pcmcia_request_io(link->handle, &link->io) != 0)
+			goto next_entry;
 		io_base = link->io.BasePort1;
 		ctl_base = link->io.BasePort1+0x0e;
 	    } else goto next_entry;
@@ -316,16 +315,16 @@ void ide_config(dev_link_t *link)
     next_entry:
 	if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg;
 	if (pass) {
-	    CS_CHECK(GetNextTuple, handle, &tuple);
-	} else if (CardServices(GetNextTuple, handle, &tuple) != 0) {
-	    CS_CHECK(GetFirstTuple, handle, &tuple);
+	    CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple));
+	} else if (pcmcia_get_next_tuple(handle, &tuple) != 0) {
+	    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
 	    memset(&dflt, 0, sizeof(dflt));
 	    pass++;
 	}
     }
     
-    CS_CHECK(RequestIRQ, handle, &link->irq);
-    CS_CHECK(RequestConfiguration, handle, &link->conf);
+    CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq));
+    CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf));
 
     /* deal with brain dead IDE resource management */
     release_region(link->io.BasePort1, link->io.NumPorts1);
@@ -413,9 +412,9 @@ void ide_release(dev_link_t *link)
     info->ndev = 0;
     link->dev = NULL;
     
-    CardServices(ReleaseConfiguration, link->handle);
-    CardServices(ReleaseIO, link->handle, &link->io);
-    CardServices(ReleaseIRQ, link->handle, &link->irq);
+    pcmcia_release_configuration(link->handle);
+    pcmcia_release_io(link->handle, &link->io);
+    pcmcia_release_irq(link->handle, &link->irq);
     
     link->state &= ~DEV_CONFIG;
 
@@ -452,14 +451,14 @@ int ide_event(event_t event, int priorit
 	/* Fall through... */
     case CS_EVENT_RESET_PHYSICAL:
 	if (link->state & DEV_CONFIG)
-	    CardServices(ReleaseConfiguration, link->handle);
+	    pcmcia_release_configuration(link->handle);
 	break;
     case CS_EVENT_PM_RESUME:
 	link->state &= ~DEV_SUSPEND;
 	/* Fall through... */
     case CS_EVENT_CARD_RESET:
 	if (DEV_OK(link))
-	    CardServices(RequestConfiguration, link->handle, &link->conf);
+	    pcmcia_request_configuration(link->handle, &link->conf);
 	break;
     }
     return 0;
diff -puN drivers/ide/legacy/pdc4030.c~linus drivers/ide/legacy/pdc4030.c
--- 25/drivers/ide/legacy/pdc4030.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ide/legacy/pdc4030.c	2004-01-19 22:17:22.000000000 -0800
@@ -443,7 +443,12 @@ read_next:
 static ide_startstop_t promise_complete_pollfunc(ide_drive_t *drive)
 {
 	ide_hwgroup_t *hwgroup = HWGROUP(drive);
+#ifdef CONFIG_IDE_TASKFILE_IO
 	struct request *rq = hwgroup->rq;
+#else
+	struct request *rq = &hwgroup->wrq;
+	struct bio *bio = rq->bio;
+#endif
 
 	if ((HWIF(drive)->INB(IDE_STATUS_REG)) & BUSY_STAT) {
 		if (time_before(jiffies, hwgroup->poll_timeout)) {
@@ -472,6 +477,8 @@ static ide_startstop_t promise_complete_
 	while (rq->bio != rq->cbio)
 		(void) DRIVER(drive)->end_request(drive, 1, bio_sectors(rq->bio));
 #else
+	bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments;
+	rq = hwgroup->rq;
 	DRIVER(drive)->end_request(drive, 1, rq->hard_nr_sectors);
 #endif
 	return ide_stopped;
@@ -530,7 +537,7 @@ static void promise_multwrite (ide_drive
 			 * all bvecs in this one.
 			 */
 			if (++bio->bi_idx >= bio->bi_vcnt) {
-				bio->bi_idx = 0;
+				bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments;
 				bio = bio->bi_next;
 			}
 
@@ -539,7 +546,8 @@ static void promise_multwrite (ide_drive
 				mcount = 0;
 			} else {
 				rq->bio = bio;
-				rq->current_nr_sectors = bio_iovec(bio)->bv_len >> 9;
+				rq->nr_cbio_segments = bio_segments(bio);
+				rq->current_nr_sectors = bio_cur_sectors(bio);
 				rq->hard_cur_sectors = rq->current_nr_sectors;
 			}
 		}
@@ -561,6 +569,9 @@ static ide_startstop_t promise_write_pol
 	ide_hwgroup_t *hwgroup = HWGROUP(drive);
 #ifdef CONFIG_IDE_TASKFILE_IO
 	struct request *rq = hwgroup->rq;
+#else
+	struct request *rq = &hwgroup->wrq;
+	struct bio *bio = rq->bio;
 #endif
 
 	if (HWIF(drive)->INB(IDE_NSECTOR_REG) != 0) {
@@ -575,6 +586,9 @@ static ide_startstop_t promise_write_pol
 		}
 		hwgroup->poll_timeout = 0;
 		printk(KERN_ERR "%s: write timed-out!\n",drive->name);
+#ifndef CONFIG_IDE_TASKFILE_IO
+		bio->bi_idx = bio->bi_vcnt - rq->nr_cbio_segments;
+#endif
 		return DRIVER(drive)->error(drive, "write timeout",
 				HWIF(drive)->INB(IDE_STATUS_REG));
 	}
diff -puN drivers/ide/pci/pdc202xx_old.c~linus drivers/ide/pci/pdc202xx_old.c
--- 25/drivers/ide/pci/pdc202xx_old.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ide/pci/pdc202xx_old.c	2004-01-19 22:17:22.000000000 -0800
@@ -361,16 +361,38 @@ static u8 pdc202xx_old_cable_detect (ide
 	return ((u8)(CIS & mask));
 }
 
+/*
+ * Set the control register to use the 66MHz system
+ * clock for UDMA 3/4/5 mode operation when necessary.
+ *
+ * It may also be possible to leave the 66MHz clock on
+ * and readjust the timing parameters.
+ */
+static void pdc_old_enable_66MHz_clock(ide_hwif_t *hwif)
+{
+	unsigned long clock_reg = hwif->dma_master + 0x11;
+	u8 clock = hwif->INB(clock_reg);
+
+	hwif->OUTB(clock | (hwif->channel ? 0x08 : 0x02), clock_reg);
+}
+
+static void pdc_old_disable_66MHz_clock(ide_hwif_t *hwif)
+{
+	unsigned long clock_reg = hwif->dma_master + 0x11;
+	u8 clock = hwif->INB(clock_reg);
+
+	hwif->OUTB(clock & ~(hwif->channel ? 0x08 : 0x02), clock_reg);
+}
+
 static int config_chipset_for_dma (ide_drive_t *drive)
 {
 	struct hd_driveid *id	= drive->id;
 	ide_hwif_t *hwif	= HWIF(drive);
 	struct pci_dev *dev	= hwif->pci_dev;
 	u32 drive_conf		= 0;
-	u8 mask			= hwif->channel ? 0x08 : 0x02;
 	u8 drive_pci		= 0x60 + (drive->dn << 2);
 	u8 test1 = 0, test2 = 0, speed = -1;
-	u8 AP = 0, CLKSPD = 0, cable = 0;
+	u8 AP = 0, cable = 0;
 
 	u8 ultra_66		= ((id->dma_ultra & 0x0010) ||
 				   (id->dma_ultra & 0x0008)) ? 1 : 0;
@@ -394,21 +416,6 @@ static int config_chipset_for_dma (ide_d
 			BUG();
 	}
 
-	CLKSPD = hwif->INB(hwif->dma_master + 0x11);
-
-	/*
-	 * Set the control register to use the 66Mhz system
-	 * clock for UDMA 3/4 mode operation. If one drive on
-	 * a channel is U66 capable but the other isn't we
-	 * fall back to U33 mode. The BIOS INT 13 hooks turn
-	 * the clock on then off for each read/write issued. I don't
-	 * do that here because it would require modifying the
-	 * kernel, separating the fop routines from the kernel or
-	 * somehow hooking the fops calls. It may also be possible to
-	 * leave the 66Mhz clock on and readjust the timing
-	 * parameters.
-	 */
-
 	if ((ultra_66) && (cable)) {
 #ifdef DEBUG
 		printk(KERN_DEBUG "ULTRA 66/100/133: %s channel of Ultra 66/100/133 "
@@ -416,29 +423,12 @@ static int config_chipset_for_dma (ide_d
 			hwif->channel ? "Secondary" : "Primary");
 		printk(KERN_DEBUG "         Switching to Ultra33 mode.\n");
 #endif /* DEBUG */
-		/* Primary   : zero out second bit */
-		/* Secondary : zero out fourth bit */
-		hwif->OUTB(CLKSPD & ~mask, (hwif->dma_master + 0x11));
 		printk(KERN_WARNING "Warning: %s channel requires an 80-pin cable for operation.\n", hwif->channel ? "Secondary":"Primary");
 		printk(KERN_WARNING "%s reduced to Ultra33 mode.\n", drive->name);
-	} else {
-		if (ultra_66) {
-			/*
-			 * check to make sure drive on same channel
-			 * is u66 capable
-			 */
-			if (hwif->drives[!(drive->dn%2)].id) {
-				if (hwif->drives[!(drive->dn%2)].id->dma_ultra & 0x0078) {
-					hwif->OUTB(CLKSPD | mask, (hwif->dma_master + 0x11));
-				} else {
-					hwif->OUTB(CLKSPD & ~mask, (hwif->dma_master + 0x11));
-				}
-			} else { /* udma4 drive by itself */
-				hwif->OUTB(CLKSPD | mask, (hwif->dma_master + 0x11));
-			}
-		}
 	}
 
+	pdc_old_disable_66MHz_clock(drive->hwif);
+
 	drive_pci = 0x60 + (drive->dn << 2);
 	pci_read_config_dword(dev, drive_pci, &drive_conf);
 	if ((drive_conf != 0x004ff304) && (drive_conf != 0x004ff3c4))
@@ -536,6 +526,8 @@ static int pdc202xx_quirkproc (ide_drive
 
 static int pdc202xx_old_ide_dma_begin(ide_drive_t *drive)
 {
+	if (drive->current_speed > XFER_UDMA_2)
+		pdc_old_enable_66MHz_clock(drive->hwif);
 	if (drive->addressing == 1) {
 		struct request *rq	= HWGROUP(drive)->rq;
 		ide_hwif_t *hwif	= HWIF(drive);
@@ -569,6 +561,8 @@ static int pdc202xx_old_ide_dma_end(ide_
 		clock = hwif->INB(high_16 + 0x11);
 		hwif->OUTB(clock & ~(hwif->channel ? 0x08:0x02), high_16+0x11);
 	}
+	if (drive->current_speed > XFER_UDMA_2)
+		pdc_old_disable_66MHz_clock(drive->hwif);
 	return __ide_dma_end(drive);
 }
 
@@ -757,10 +751,7 @@ static void __init init_hwif_pdc202xx (i
 
 	hwif->speedproc = &pdc202xx_tune_chipset;
 
-	if (!hwif->dma_base) {
-		hwif->drives[0].autotune = hwif->drives[1].autotune = 1;
-		return;
-	}
+	hwif->drives[0].autotune = hwif->drives[1].autotune = 1;
 
 	hwif->ultra_mask = 0x3f;
 	hwif->mwdma_mask = 0x07;
diff -puN drivers/ide/pci/sgiioc4.c~linus drivers/ide/pci/sgiioc4.c
--- 25/drivers/ide/pci/sgiioc4.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ide/pci/sgiioc4.c	2004-01-19 22:17:22.000000000 -0800
@@ -23,7 +23,6 @@
  * http://oss.sgi.com/projects/GenInfo/NoticeExplan
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/pci.h>
@@ -686,7 +685,7 @@ sgiioc4_ide_setup_pci_device(struct pci_
 			"0x%p to 0x%p ALREADY in use\n",
 		       __FUNCTION__, hwif->name, (void *) base,
 		       (void *) base + IOC4_CMD_CTL_BLK_SIZE);
-		return 1;
+		return -ENOMEM;
 	}
 
 	if (hwif->io_ports[IDE_DATA_OFFSET] != base) {
@@ -726,20 +725,21 @@ typedef enum pciio_endian_e {
 	PCIDMA_ENDIAN_BIG,
 	PCIDMA_ENDIAN_LITTLE
 } pciio_endian_t;
-pciio_endian_t __attribute__ ((weak)) snia_pciio_endian_set(struct pci_dev
-					    *pci_dev, pciio_endian_t device_end,
-					    pciio_endian_t desired_end);
+pciio_endian_t snia_pciio_endian_set(struct pci_dev
+				     *pci_dev, pciio_endian_t device_end,
+				     pciio_endian_t desired_end);
 
 static unsigned int __init
 pci_init_sgiioc4(struct pci_dev *dev, ide_pci_device_t * d)
 {
 	unsigned int class_rev;
+	pciio_endian_t endian_status;
 
 	if (pci_enable_device(dev)) {
 		printk(KERN_ERR
 		       "Failed to enable device %s at slot %s\n",
 		       d->name, dev->slot_name);
-		return 1;
+		return -ENODEV;
 	}
 	pci_set_master(dev);
 
@@ -751,18 +751,17 @@ pci_init_sgiioc4(struct pci_dev *dev, id
 		printk(KERN_ERR "Skipping %s IDE controller in slot %s: "
 			"firmware is obsolete - please upgrade to revision"
 			"46 or higher\n", d->name, dev->slot_name);
-		return 1;
+		return -ENODEV;
 	}
 
 	/* Enable Byte Swapping in the PIC... */
-	if (snia_pciio_endian_set) {
-		snia_pciio_endian_set(dev, PCIDMA_ENDIAN_LITTLE,
-				      PCIDMA_ENDIAN_BIG);
-	} else {
+	endian_status = snia_pciio_endian_set(dev, PCIDMA_ENDIAN_LITTLE,
+					      PCIDMA_ENDIAN_BIG);
+	if (endian_status != PCIDMA_ENDIAN_BIG) {
 		printk(KERN_ERR
 		       "Failed to set endianness for device %s at slot %s\n",
 		       d->name, dev->slot_name);
-		return 1;
+		return -ENODEV;
 	}
 
 	return sgiioc4_ide_setup_pci_device(dev, d);
diff -puN drivers/ide/pci/siimage.c~linus drivers/ide/pci/siimage.c
--- 25/drivers/ide/pci/siimage.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ide/pci/siimage.c	2004-01-19 22:17:22.000000000 -0800
@@ -767,20 +767,17 @@ static void siimage_reset (ide_drive_t *
  
 static void proc_reports_siimage (struct pci_dev *dev, u8 clocking, const char *name)
 {
-	if(pdev_is_sata(dev))
-		goto sata_skip;
-
-	printk(KERN_INFO "%s: BASE CLOCK ", name);
-	clocking &= 0x03;
-	switch(clocking) {
-		case 0x03: printk("DISABLED !\n"); break;
-		case 0x02: printk("== 2X PCI \n"); break;
-		case 0x01: printk("== 133 \n"); break;
-		case 0x00: printk("== 100 \n"); break;
+	if (!pdev_is_sata(dev)) {
+		printk(KERN_INFO "%s: BASE CLOCK ", name);
+		clocking &= 0x03;
+		switch (clocking) {
+			case 0x03: printk("DISABLED!\n"); break;
+			case 0x02: printk("== 2X PCI\n"); break;
+			case 0x01: printk("== 133\n"); break;
+			case 0x00: printk("== 100\n"); break;
+		}
 	}
 
-sata_skip:
-
 #if defined(DISPLAY_SIIMAGE_TIMINGS) && defined(CONFIG_PROC_FS)
 	siimage_devs[n_siimage_devs++] = dev;
 
diff -puN drivers/ieee1394/amdtp.c~linus drivers/ieee1394/amdtp.c
--- 25/drivers/ieee1394/amdtp.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ieee1394/amdtp.c	2004-01-19 22:17:22.000000000 -0800
@@ -82,6 +82,7 @@
 #include <linux/poll.h>
 #include <linux/ioctl32.h>
 #include <linux/compat.h>
+#include <linux/cdev.h>
 #include <asm/uaccess.h>
 #include <asm/atomic.h>
 
@@ -1196,6 +1197,7 @@ static int amdtp_release(struct inode *i
 	return 0;
 }
 
+static struct cdev amdtp_cdev;
 static struct file_operations amdtp_fops =
 {
 	.owner =	THIS_MODULE,
@@ -1262,12 +1264,11 @@ MODULE_LICENSE("GPL");
 
 static int __init amdtp_init_module (void)
 {
-	int ret;
-
-	ret = ieee1394_register_chardev(IEEE1394_MINOR_BLOCK_AMDTP,
-					THIS_MODULE, &amdtp_fops);
-	if (ret) {
-		HPSB_ERR("amdtp: unable to get minor device block");
+	cdev_init(&amdtp_cdev, &amdtp_fops);
+	amdtp_cdev.owner = THIS_MODULE;
+	kobject_set_name(&amdtp_cdev.kobj, "amdtp");
+	if (cdev_add(&amdtp_cdev, IEEE1394_AMDTP_DEV, 16)) {
+		HPSB_ERR("amdtp: unable to add char device");
  		return -EIO;
  	}
 
@@ -1276,12 +1277,15 @@ static int __init amdtp_init_module (voi
 	hpsb_register_highlevel(&amdtp_highlevel);
 
 #ifdef CONFIG_COMPAT
-	ret = register_ioctl32_conversion(AMDTP_IOC_CHANNEL, NULL);
-	ret |= register_ioctl32_conversion(AMDTP_IOC_PLUG, NULL);
-	ret |= register_ioctl32_conversion(AMDTP_IOC_PING, NULL);
-	ret |= register_ioctl32_conversion(AMDTP_IOC_ZAP, NULL);
-	if (ret)
-		HPSB_ERR("amdtp: Error registering ioctl32 translations");
+	{
+		int ret;
+		ret = register_ioctl32_conversion(AMDTP_IOC_CHANNEL, NULL);
+		ret |= register_ioctl32_conversion(AMDTP_IOC_PLUG, NULL);
+		ret |= register_ioctl32_conversion(AMDTP_IOC_PING, NULL);
+		ret |= register_ioctl32_conversion(AMDTP_IOC_ZAP, NULL);
+		if (ret)
+			HPSB_ERR("amdtp: Error registering ioctl32 translations");
+	}
 #endif
 
 	HPSB_INFO("Loaded AMDTP driver");
@@ -1304,10 +1308,12 @@ static void __exit amdtp_exit_module (vo
 
         hpsb_unregister_highlevel(&amdtp_highlevel);
 	devfs_remove("amdtp");
-        ieee1394_unregister_chardev(IEEE1394_MINOR_BLOCK_AMDTP);
+	cdev_unmap(IEEE1394_AMDTP_DEV, 16);
+	cdev_del(&amdtp_cdev);
 
 	HPSB_INFO("Unloaded AMDTP driver");
 }
 
 module_init(amdtp_init_module);
 module_exit(amdtp_exit_module);
+MODULE_ALIAS_CHARDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_AMDTP * 16);
diff -puN drivers/ieee1394/cmp.c~linus drivers/ieee1394/cmp.c
--- 25/drivers/ieee1394/cmp.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ieee1394/cmp.c	2004-01-19 22:17:22.000000000 -0800
@@ -77,6 +77,25 @@ enum {
 
 static struct hpsb_highlevel cmp_highlevel;
 
+static void cmp_add_host(struct hpsb_host *host);
+static void cmp_host_reset(struct hpsb_host *host);
+static int pcr_read(struct hpsb_host *host, int nodeid, quadlet_t *buf,
+		    u64 addr, size_t length, u16 flags);
+static int pcr_lock(struct hpsb_host *host, int nodeid, quadlet_t *store,
+		    u64 addr, quadlet_t data, quadlet_t arg, int extcode, u16 flags);
+
+static struct hpsb_highlevel cmp_highlevel = {
+	.name =		"cmp",
+	.add_host =	cmp_add_host,
+	.host_reset =	cmp_host_reset,
+};
+
+static struct hpsb_address_ops pcr_ops = {
+	.read =	pcr_read,
+	.lock =	pcr_lock,
+};
+
+
 struct cmp_pcr *
 cmp_register_opcr(struct hpsb_host *host, int opcr_number, int payload,
 		  void (*update)(struct cmp_pcr *pcr, void *data),
@@ -137,6 +156,10 @@ static void cmp_add_host(struct hpsb_hos
 		return;
 	}
 
+	hpsb_register_addrspace(&cmp_highlevel, host, &pcr_ops,
+				CSR_REGISTER_BASE + CSR_PCR_MAP,
+				CSR_REGISTER_BASE + CSR_PCR_MAP_END);
+
 	ch->host = host;
 	ch->u.ompr.rate = IEEE1394_SPEED_100;
 	ch->u.ompr.bcast_channel_base = 63;
@@ -258,17 +281,6 @@ static int pcr_lock(struct hpsb_host *ho
 }
 
 
-static struct hpsb_highlevel cmp_highlevel = {
-	.name =		"cmp",
-	.add_host =	cmp_add_host,
-        .host_reset =	cmp_host_reset,
-};
-
-static struct hpsb_address_ops pcr_ops = {
-	.read =	pcr_read,
-        .lock =	pcr_lock,
-};
-
 /* Module interface */
 
 MODULE_AUTHOR("Kristian Hogsberg <hogsberg@users.sf.net>");
@@ -283,10 +295,6 @@ static int __init cmp_init_module (void)
 {
 	hpsb_register_highlevel (&cmp_highlevel);
 
-	hpsb_register_addrspace(&cmp_highlevel, &pcr_ops,
-				CSR_REGISTER_BASE + CSR_PCR_MAP,
-				CSR_REGISTER_BASE + CSR_PCR_MAP_END);
-
 	HPSB_INFO("Loaded CMP driver");
 
 	return 0;
diff -puN drivers/ieee1394/csr.c~linus drivers/ieee1394/csr.c
--- 25/drivers/ieee1394/csr.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ieee1394/csr.c	2004-01-19 22:17:22.000000000 -0800
@@ -35,6 +35,43 @@ static int fcp = 1;
 module_param(fcp, int, 0444);
 MODULE_PARM_DESC(fcp, "Map FCP registers (default = 1, disable = 0).");
 
+static void add_host(struct hpsb_host *host);
+static void host_reset(struct hpsb_host *host);
+static int read_maps(struct hpsb_host *host, int nodeid, quadlet_t *buffer,
+		     u64 addr, size_t length, u16 fl);
+static int write_fcp(struct hpsb_host *host, int nodeid, int dest,
+		     quadlet_t *data, u64 addr, size_t length, u16 flags);
+static int read_regs(struct hpsb_host *host, int nodeid, quadlet_t *buf,
+		     u64 addr, size_t length, u16 flags);
+static int write_regs(struct hpsb_host *host, int nodeid, int destid,
+		      quadlet_t *data, u64 addr, size_t length, u16 flags);
+static int lock_regs(struct hpsb_host *host, int nodeid, quadlet_t *store,
+		     u64 addr, quadlet_t data, quadlet_t arg, int extcode, u16 fl);
+static int lock64_regs(struct hpsb_host *host, int nodeid, octlet_t * store,
+		       u64 addr, octlet_t data, octlet_t arg, int extcode, u16 fl);
+
+static struct hpsb_highlevel csr_highlevel = {
+	.name =		"standard registers",
+	.add_host =	add_host,
+	.host_reset =	host_reset,
+};
+
+static struct hpsb_address_ops map_ops = {
+	.read = read_maps,
+};
+
+static struct hpsb_address_ops fcp_ops = {
+	.write = write_fcp,
+};
+
+static struct hpsb_address_ops reg_ops = {
+	.read = read_regs,
+	.write = write_regs,
+	.lock = lock_regs,
+	.lock64 = lock64_regs,
+};
+
+
 static u16 csr_crc16(unsigned *data, int length)
 {
         int check=0, i;
@@ -125,6 +162,24 @@ static inline void calculate_expire(stru
 
 static void add_host(struct hpsb_host *host)
 {
+	hpsb_register_addrspace(&csr_highlevel, host, &reg_ops,
+				CSR_REGISTER_BASE,
+				CSR_REGISTER_BASE + CSR_CONFIG_ROM);
+	hpsb_register_addrspace(&csr_highlevel, host, &map_ops,
+				CSR_REGISTER_BASE + CSR_CONFIG_ROM,
+				CSR_REGISTER_BASE + CSR_CONFIG_ROM_END);
+	if (fcp) {
+		hpsb_register_addrspace(&csr_highlevel, host, &fcp_ops,
+					CSR_REGISTER_BASE + CSR_FCP_COMMAND,
+					CSR_REGISTER_BASE + CSR_FCP_END);
+	}
+	hpsb_register_addrspace(&csr_highlevel, host, &map_ops,
+				CSR_REGISTER_BASE + CSR_TOPOLOGY_MAP,
+				CSR_REGISTER_BASE + CSR_TOPOLOGY_MAP_END);
+	hpsb_register_addrspace(&csr_highlevel, host, &map_ops,
+				CSR_REGISTER_BASE + CSR_SPEED_MAP,
+				CSR_REGISTER_BASE + CSR_SPEED_MAP_END);
+
         host->csr.lock = SPIN_LOCK_UNLOCKED;
 
         host->csr.rom_size = host->driver->get_rom(host, &host->csr.rom);
@@ -684,48 +739,10 @@ static int write_fcp(struct hpsb_host *h
 }
 
 
-static struct hpsb_highlevel csr_highlevel = {
-	.name =		"standard registers",
-	.add_host =	add_host,
-        .host_reset =	host_reset,
-};
-
-
-static struct hpsb_address_ops map_ops = {
-        .read = read_maps,
-};
-
-static struct hpsb_address_ops fcp_ops = {
-        .write = write_fcp,
-};
-
-static struct hpsb_address_ops reg_ops = {
-        .read = read_regs,
-        .write = write_regs,
-        .lock = lock_regs,
-	.lock64 = lock64_regs,
-};
 
 void init_csr(void)
 {
 	hpsb_register_highlevel(&csr_highlevel);
-
-        hpsb_register_addrspace(&csr_highlevel, &reg_ops, CSR_REGISTER_BASE,
-                                CSR_REGISTER_BASE + CSR_CONFIG_ROM);
-        hpsb_register_addrspace(&csr_highlevel, &map_ops, 
-                                CSR_REGISTER_BASE + CSR_CONFIG_ROM,
-                                CSR_REGISTER_BASE + CSR_CONFIG_ROM_END);
-        if (fcp) {
-		hpsb_register_addrspace(&csr_highlevel, &fcp_ops,
-                                CSR_REGISTER_BASE + CSR_FCP_COMMAND,
-                                CSR_REGISTER_BASE + CSR_FCP_END);
-	}
-        hpsb_register_addrspace(&csr_highlevel, &map_ops,
-                                CSR_REGISTER_BASE + CSR_TOPOLOGY_MAP,
-                                CSR_REGISTER_BASE + CSR_TOPOLOGY_MAP_END);
-        hpsb_register_addrspace(&csr_highlevel, &map_ops,
-                                CSR_REGISTER_BASE + CSR_SPEED_MAP,
-                                CSR_REGISTER_BASE + CSR_SPEED_MAP_END);
 }
 
 void cleanup_csr(void)
diff -puN drivers/ieee1394/dv1394.c~linus drivers/ieee1394/dv1394.c
--- 25/drivers/ieee1394/dv1394.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ieee1394/dv1394.c	2004-01-19 22:17:22.000000000 -0800
@@ -110,6 +110,7 @@
 #include <linux/string.h>
 #include <linux/ioctl32.h>
 #include <linux/compat.h>
+#include <linux/cdev.h>
 
 #include "ieee1394.h"
 #include "ieee1394_types.h"
@@ -2165,6 +2166,7 @@ out:
 	spin_unlock(&video->spinlock);
 }
 
+static struct cdev dv1394_cdev;
 static struct file_operations dv1394_fops=
 {
 	.owner =	THIS_MODULE,
@@ -2607,17 +2609,17 @@ static void __exit dv1394_exit_module(vo
 	hpsb_unregister_protocol(&dv1394_driver);
 
 	hpsb_unregister_highlevel(&dv1394_highlevel);
-	ieee1394_unregister_chardev(IEEE1394_MINOR_BLOCK_DV1394);
+	cdev_unmap(IEEE1394_DV1394_DEV, 16);
+	cdev_del(&dv1394_cdev);
 	devfs_remove("ieee1394/dv");
 }
 
 static int __init dv1394_init_module(void)
 {
-	int ret;
-
-	ret = ieee1394_register_chardev(IEEE1394_MINOR_BLOCK_DV1394,
-					THIS_MODULE, &dv1394_fops);
-	if (ret) {
+	cdev_init(&dv1394_cdev, &dv1394_fops);
+	dv1394_cdev.owner = THIS_MODULE;
+	kobject_set_name(&dv1394_cdev.kobj, "dv1394");
+	if (cdev_add(&dv1394_cdev, IEEE1394_DV1394_DEV, 16)) {
 		printk(KERN_ERR "dv1394: unable to register character device\n");
 		return -EIO;
 	}
@@ -2629,18 +2631,22 @@ static int __init dv1394_init_module(voi
 	hpsb_register_protocol(&dv1394_driver);
 
 #ifdef CONFIG_COMPAT
-	/* First compatible ones */
-	ret = register_ioctl32_conversion(DV1394_IOC_SHUTDOWN, NULL);
-	ret |= register_ioctl32_conversion(DV1394_IOC_SUBMIT_FRAMES, NULL);
-	ret |= register_ioctl32_conversion(DV1394_IOC_WAIT_FRAMES, NULL);
-	ret |= register_ioctl32_conversion(DV1394_IOC_RECEIVE_FRAMES, NULL);
-	ret |= register_ioctl32_conversion(DV1394_IOC_START_RECEIVE, NULL);
-
-	/* These need to be handled by translation */
-	ret |= register_ioctl32_conversion(DV1394_IOC32_INIT, handle_dv1394_init);
-	ret |= register_ioctl32_conversion(DV1394_IOC32_GET_STATUS, handle_dv1394_get_status);
-	if (ret)
-		printk(KERN_ERR "dv1394: Error registering ioctl32 translations\n");
+	{
+		int ret;
+
+		/* First compatible ones */
+		ret = register_ioctl32_conversion(DV1394_IOC_SHUTDOWN, NULL);
+		ret |= register_ioctl32_conversion(DV1394_IOC_SUBMIT_FRAMES, NULL);
+		ret |= register_ioctl32_conversion(DV1394_IOC_WAIT_FRAMES, NULL);
+		ret |= register_ioctl32_conversion(DV1394_IOC_RECEIVE_FRAMES, NULL);
+		ret |= register_ioctl32_conversion(DV1394_IOC_START_RECEIVE, NULL);
+
+		/* These need to be handled by translation */
+		ret |= register_ioctl32_conversion(DV1394_IOC32_INIT, handle_dv1394_init);
+		ret |= register_ioctl32_conversion(DV1394_IOC32_GET_STATUS, handle_dv1394_get_status);
+		if (ret)
+			printk(KERN_ERR "dv1394: Error registering ioctl32 translations\n");
+	}
 #endif
 
 	return 0;
@@ -2648,3 +2654,4 @@ static int __init dv1394_init_module(voi
 
 module_init(dv1394_init_module);
 module_exit(dv1394_exit_module);
+MODULE_ALIAS_CHARDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16);
diff -puN drivers/ieee1394/eth1394.c~linus drivers/ieee1394/eth1394.c
--- 25/drivers/ieee1394/eth1394.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ieee1394/eth1394.c	2004-01-19 22:17:22.000000000 -0800
@@ -89,7 +89,7 @@
 #define TRACE() printk(KERN_ERR "%s:%s[%d] ---- TRACE\n", driver_name, __FUNCTION__, __LINE__)
 
 static char version[] __devinitdata =
-	"$Rev: 1079 $ Ben Collins <bcollins@debian.org>";
+	"$Rev: 1096 $ Ben Collins <bcollins@debian.org>";
 
 struct fragment_info {
 	struct list_head list;
@@ -168,6 +168,26 @@ static void ether1394_iso(struct hpsb_is
 static int ether1394_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
 static int ether1394_ethtool_ioctl(struct net_device *dev, void *useraddr);
 
+static int ether1394_write(struct hpsb_host *host, int srcid, int destid,
+			   quadlet_t *data, u64 addr, size_t len, u16 flags);
+static void ether1394_add_host (struct hpsb_host *host);
+static void ether1394_remove_host (struct hpsb_host *host);
+static void ether1394_host_reset (struct hpsb_host *host);
+
+/* Function for incoming 1394 packets */
+static struct hpsb_address_ops addr_ops = {
+	.write =	ether1394_write,
+};
+
+/* Ieee1394 highlevel driver functions */
+static struct hpsb_highlevel eth1394_highlevel = {
+	.name =		driver_name,
+	.add_host =	ether1394_add_host,
+	.remove_host =	ether1394_remove_host,
+	.host_reset =	ether1394_host_reset,
+};
+
+
 static void eth1394_iso_shutdown(struct eth1394_priv *priv)
 {
 	priv->bc_state = ETHER1394_BC_CLOSED;
@@ -420,6 +440,10 @@ static void ether1394_add_host (struct h
 	struct eth1394_priv *priv;
 	static int version_printed = 0;
 
+	hpsb_register_addrspace(&eth1394_highlevel, host, &addr_ops,
+				ETHER1394_REGION_ADDR,
+				ETHER1394_REGION_ADDR_END);
+
 	if (version_printed++ == 0)
 		ETH1394_PRINT_G (KERN_INFO, "%s\n", version);
 
@@ -1599,7 +1623,7 @@ static int ether1394_ethtool_ioctl(struc
 		case ETHTOOL_GDRVINFO: {
 			struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
 			strcpy (info.driver, driver_name);
-			strcpy (info.version, "$Rev: 1079 $");
+			strcpy (info.version, "$Rev: 1096 $");
 			/* FIXME XXX provide sane businfo */
 			strcpy (info.bus_info, "ieee1394");
 			if (copy_to_user (useraddr, &info, sizeof (info)))
@@ -1619,18 +1643,6 @@ static int ether1394_ethtool_ioctl(struc
 	return 0;
 }
 
-/* Function for incoming 1394 packets */
-static struct hpsb_address_ops addr_ops = {
-	.write =	ether1394_write,
-};
-
-/* Ieee1394 highlevel driver functions */
-static struct hpsb_highlevel eth1394_highlevel = {
-	.name =		driver_name,
-	.add_host =	ether1394_add_host,
-	.remove_host =	ether1394_remove_host,
-	.host_reset =	ether1394_host_reset,
-};
 
 static int __init ether1394_init_module (void)
 {
@@ -1640,9 +1652,6 @@ static int __init ether1394_init_module 
 	/* Register ourselves as a highlevel driver */
 	hpsb_register_highlevel(&eth1394_highlevel);
 
-	hpsb_register_addrspace(&eth1394_highlevel, &addr_ops, ETHER1394_REGION_ADDR,
-				 ETHER1394_REGION_ADDR_END);
-
 	return 0;
 }
 
diff -puN drivers/ieee1394/highlevel.c~linus drivers/ieee1394/highlevel.c
--- 25/drivers/ieee1394/highlevel.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ieee1394/highlevel.c	2004-01-19 22:17:22.000000000 -0800
@@ -39,7 +39,10 @@ struct hl_host_info {
 
 
 static LIST_HEAD(hl_drivers);
-static rwlock_t hl_drivers_lock = RW_LOCK_UNLOCKED;
+static DECLARE_RWSEM(hl_drivers_sem);
+
+static LIST_HEAD(hl_irqs);
+static rwlock_t hl_irqs_lock = RW_LOCK_UNLOCKED;
 
 static LIST_HEAD(addr_space);
 static rwlock_t addr_space_lock = RW_LOCK_UNLOCKED;
@@ -239,16 +242,18 @@ static int highlevel_for_each_host_reg(s
 
 void hpsb_register_highlevel(struct hpsb_highlevel *hl)
 {
-	unsigned long flags;
-
         INIT_LIST_HEAD(&hl->addr_list);
 	INIT_LIST_HEAD(&hl->host_info_list);
 
 	rwlock_init(&hl->host_info_lock);
 
-	write_lock_irqsave(&hl_drivers_lock, flags);
+	down_write(&hl_drivers_sem);
         list_add_tail(&hl->hl_list, &hl_drivers);
-	write_unlock_irqrestore(&hl_drivers_lock, flags);
+	up_write(&hl_drivers_sem);
+
+	write_lock(&hl_irqs_lock);
+	list_add_tail(&hl->irq_list, &hl_irqs);
+	write_unlock(&hl_irqs_lock);
 
 	if (hl->add_host)
 		nodemgr_for_each_host(hl, highlevel_for_each_host_reg);
@@ -280,15 +285,19 @@ void hpsb_unregister_highlevel(struct hp
         }
 	write_unlock_irqrestore(&addr_space_lock, flags);
 
-	write_lock_irqsave(&hl_drivers_lock, flags);
+	write_lock(&hl_irqs_lock);
+	list_del(&hl->irq_list);
+	write_unlock(&hl_irqs_lock);
+
+	down_write(&hl_drivers_sem);
         list_del(&hl->hl_list);
-	write_unlock_irqrestore(&hl_drivers_lock, flags);
+	up_write(&hl_drivers_sem);
 
         if (hl->remove_host)
 		nodemgr_for_each_host(hl, highlevel_for_each_host_unreg);
 }
 
-int hpsb_register_addrspace(struct hpsb_highlevel *hl,
+int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
                             struct hpsb_address_ops *ops, u64 start, u64 end)
 {
         struct hpsb_address_serve *as;
@@ -314,7 +323,7 @@ int hpsb_register_addrspace(struct hpsb_
         as->end = end;
 
         write_lock_irqsave(&addr_space_lock, flags);
-        entry = addr_space.next;
+        entry = host->addr_space.next;
 
         while (list_entry(entry, struct hpsb_address_serve, as_list)->end
                <= start) {
@@ -336,7 +345,8 @@ int hpsb_register_addrspace(struct hpsb_
         return retval;
 }
 
-int hpsb_unregister_addrspace(struct hpsb_highlevel *hl, u64 start)
+int hpsb_unregister_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
+                              u64 start)
 {
         int retval = 0;
         struct hpsb_address_serve *as;
@@ -350,7 +360,7 @@ int hpsb_unregister_addrspace(struct hps
         while (entry != &hl->addr_list) {
                 as = list_entry(entry, struct hpsb_address_serve, addr_list);
                 entry = entry->next;
-                if (as->start == start) {
+                if (as->start == start && as->host == host) {
                         list_del(&as->as_list);
                         list_del(&as->addr_list);
                         kfree(as);
@@ -392,92 +402,102 @@ void hpsb_unlisten_channel(struct hpsb_h
         }
 }
 
+static void init_hpsb_highlevel(struct hpsb_host *host)
+{
+	INIT_LIST_HEAD(&dummy_zero_addr.as_list);
+	INIT_LIST_HEAD(&dummy_zero_addr.addr_list);
+	INIT_LIST_HEAD(&dummy_max_addr.as_list);
+	INIT_LIST_HEAD(&dummy_max_addr.addr_list);
+
+	dummy_zero_addr.op = dummy_max_addr.op = &dummy_ops;
+
+	dummy_zero_addr.start = dummy_zero_addr.end = 0;
+	dummy_max_addr.start = dummy_max_addr.end = ((u64) 1) << 48;
+
+	list_add_tail(&dummy_zero_addr.as_list, &host->addr_space);
+	list_add_tail(&dummy_max_addr.as_list, &host->addr_space);
+}
 
 void highlevel_add_host(struct hpsb_host *host)
 {
-        struct list_head *entry;
         struct hpsb_highlevel *hl;
 
-        read_lock(&hl_drivers_lock);
-        list_for_each(entry, &hl_drivers) {
-                hl = list_entry(entry, struct hpsb_highlevel, hl_list);
+	init_hpsb_highlevel(host);
+
+	down_read(&hl_drivers_sem);
+        list_for_each_entry(hl, &hl_drivers, hl_list) {
 		if (hl->add_host)
 			hl->add_host(host);
         }
-        read_unlock(&hl_drivers_lock);
+	up_read(&hl_drivers_sem);
 }
 
 void highlevel_remove_host(struct hpsb_host *host)
 {
-        struct list_head *entry;
         struct hpsb_highlevel *hl;
+	struct list_head *lh, *next;
+	struct hpsb_address_serve *as;
+	unsigned long flags;
 
-	read_lock(&hl_drivers_lock);
-	list_for_each(entry, &hl_drivers) {
-                hl = list_entry(entry, struct hpsb_highlevel, hl_list);
-
+	down_read(&hl_drivers_sem);
+	list_for_each_entry(hl, &hl_drivers, hl_list) {
 		if (hl->remove_host) {
 			hl->remove_host(host);
 			hpsb_destroy_hostinfo(hl, host);
 		}
         }
-	read_unlock(&hl_drivers_lock);
+	up_read(&hl_drivers_sem);
+
+	/* Free up 1394 address space left behind by high level drivers. */
+	write_lock_irqsave(&addr_space_lock, flags);
+	list_for_each_safe (lh, next, &host->addr_space) {
+		as = list_entry(lh, struct hpsb_address_serve, as_list);
+		if (!list_empty(&as->addr_list)) {
+			list_del(&as->addr_list);
+			kfree(as);
+		}
+	}
+	write_unlock_irqrestore(&addr_space_lock, flags);
 }
 
 void highlevel_host_reset(struct hpsb_host *host)
 {
-        struct list_head *entry;
         struct hpsb_highlevel *hl;
 
-	read_lock(&hl_drivers_lock);
-	list_for_each(entry, &hl_drivers) {
-                hl = list_entry(entry, struct hpsb_highlevel, hl_list);
-
+	read_lock(&hl_irqs_lock);
+	list_for_each_entry(hl, &hl_irqs, irq_list) {
                 if (hl->host_reset)
                         hl->host_reset(host);
         }
-	read_unlock(&hl_drivers_lock);
+	read_unlock(&hl_irqs_lock);
 }
 
-void highlevel_iso_receive(struct hpsb_host *host, void *data,
-			   size_t length)
+void highlevel_iso_receive(struct hpsb_host *host, void *data, size_t length)
 {
-        struct list_head *entry;
         struct hpsb_highlevel *hl;
         int channel = (((quadlet_t *)data)[0] >> 8) & 0x3f;
 
-        read_lock(&hl_drivers_lock);
-        entry = hl_drivers.next;
-
-        while (entry != &hl_drivers) {
-                hl = list_entry(entry, struct hpsb_highlevel, hl_list);
-                if (hl->iso_receive) {
+        read_lock(&hl_irqs_lock);
+	list_for_each_entry(hl, &hl_irqs, irq_list) {
+                if (hl->iso_receive)
                         hl->iso_receive(host, channel, data, length);
-                }
-                entry = entry->next;
         }
-        read_unlock(&hl_drivers_lock);
+        read_unlock(&hl_irqs_lock);
 }
 
 void highlevel_fcp_request(struct hpsb_host *host, int nodeid, int direction,
 			   void *data, size_t length)
 {
-        struct list_head *entry;
         struct hpsb_highlevel *hl;
         int cts = ((quadlet_t *)data)[0] >> 4;
 
-        read_lock(&hl_drivers_lock);
-        entry = hl_drivers.next;
-
-        while (entry != &hl_drivers) {
-                hl = list_entry(entry, struct hpsb_highlevel, hl_list);
-                if (hl->fcp_request) {
+        read_lock(&hl_irqs_lock);
+	list_for_each_entry(hl, &hl_irqs, irq_list) {
+                if (hl->fcp_request)
                         hl->fcp_request(host, nodeid, direction, cts, data,
-                                            length);
-                }
-                entry = entry->next;
+					length);
         }
-        read_unlock(&hl_drivers_lock);
+        read_unlock(&hl_irqs_lock);
 }
 
 int highlevel_read(struct hpsb_host *host, int nodeid, void *data,
@@ -490,7 +510,7 @@ int highlevel_read(struct hpsb_host *hos
 
         read_lock(&addr_space_lock);
 
-        entry = addr_space.next;
+        entry = host->addr_space.next;
         as = list_entry(entry, struct hpsb_address_serve, as_list);
 
         while (as->start <= addr) {
@@ -536,7 +556,7 @@ int highlevel_write(struct hpsb_host *ho
 
         read_lock(&addr_space_lock);
 
-        entry = addr_space.next;
+        entry = host->addr_space.next;
         as = list_entry(entry, struct hpsb_address_serve, as_list);
 
         while (as->start <= addr) {
@@ -582,7 +602,7 @@ int highlevel_lock(struct hpsb_host *hos
 
         read_lock(&addr_space_lock);
 
-        entry = addr_space.next;
+        entry = host->addr_space.next;
         as = list_entry(entry, struct hpsb_address_serve, as_list);
 
         while (as->start <= addr) {
@@ -615,7 +635,7 @@ int highlevel_lock64(struct hpsb_host *h
 
         read_lock(&addr_space_lock);
 
-        entry = addr_space.next;
+        entry = host->addr_space.next;
         as = list_entry(entry, struct hpsb_address_serve, as_list);
 
         while (as->start <= addr) {
@@ -639,19 +659,3 @@ int highlevel_lock64(struct hpsb_host *h
 
         return rcode;
 }
-
-void init_hpsb_highlevel(void)
-{
-        INIT_LIST_HEAD(&dummy_zero_addr.as_list);
-        INIT_LIST_HEAD(&dummy_zero_addr.addr_list);
-        INIT_LIST_HEAD(&dummy_max_addr.as_list);
-        INIT_LIST_HEAD(&dummy_max_addr.addr_list);
-
-        dummy_zero_addr.op = dummy_max_addr.op = &dummy_ops;
-
-        dummy_zero_addr.start = dummy_zero_addr.end = 0;
-        dummy_max_addr.start = dummy_max_addr.end = ((u64) 1) << 48;
-
-        list_add_tail(&dummy_zero_addr.as_list, &addr_space);
-        list_add_tail(&dummy_max_addr.as_list, &addr_space);
-}
diff -puN drivers/ieee1394/highlevel.h~linus drivers/ieee1394/highlevel.h
--- 25/drivers/ieee1394/highlevel.h~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ieee1394/highlevel.h	2004-01-19 22:17:22.000000000 -0800
@@ -10,6 +10,8 @@ struct hpsb_address_serve {
 
         struct hpsb_address_ops *op;
 
+	struct hpsb_host *host;
+
         /* first address handled and first address behind, quadlet aligned */
         u64 start, end;
 };
@@ -36,9 +38,9 @@ struct hpsb_highlevel {
          * hpsb_unregister_highlevel once for each host. */
         void (*remove_host) (struct hpsb_host *host);
 
-        /* Host experienced bus reset with possible configuration changes.  Note
-         * that this one may occur during interrupt/bottom half handling.  You
-         * can not expect to be able to do stock hpsb_reads. */
+        /* Host experienced bus reset with possible configuration changes.
+	 * Note that this one may occur during interrupt/bottom half handling.
+	 * You can not expect to be able to do stock hpsb_reads. */
         void (*host_reset) (struct hpsb_host *host);
 
         /* An isochronous packet was received.  Channel contains the channel
@@ -50,13 +52,14 @@ struct hpsb_highlevel {
 
         /* A write request was received on either the FCP_COMMAND (direction =
          * 0) or the FCP_RESPONSE (direction = 1) register.  The cts arg
-         * contains the cts field (first byte of data).
-         */
+         * contains the cts field (first byte of data). */
         void (*fcp_request) (struct hpsb_host *host, int nodeid, int direction,
                              int cts, u8 *data, size_t length);
 
-
+	/* These are initialized by the subsystem when the
+	 * hpsb_higlevel is registered. */
 	struct list_head hl_list;
+	struct list_head irq_list;
 	struct list_head addr_list;
 
 	struct list_head host_info_list;
@@ -137,10 +140,11 @@ void hpsb_unregister_highlevel(struct hp
  * It returns true for successful allocation.  There is no unregister function,
  * all address spaces are deallocated together with the hpsb_highlevel.
  */
-int hpsb_register_addrspace(struct hpsb_highlevel *hl,
+int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
                             struct hpsb_address_ops *ops, u64 start, u64 end);
 
-int hpsb_unregister_addrspace(struct hpsb_highlevel *hl, u64 start);
+int hpsb_unregister_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
+                              u64 start);
 
 /*
  * Enable or disable receving a certain isochronous channel through the
@@ -178,7 +182,4 @@ int hpsb_set_hostinfo(struct hpsb_highle
 /* Retrieve hpsb_host using a highlevel handle and a key */
 struct hpsb_host *hpsb_get_host_bykey(struct hpsb_highlevel *hl, unsigned long key);
 
-/* Initialize the highlevel system */
-void init_hpsb_highlevel(void);
-
 #endif /* IEEE1394_HIGHLEVEL_H */
diff -puN drivers/ieee1394/hosts.c~linus drivers/ieee1394/hosts.c
--- 25/drivers/ieee1394/hosts.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ieee1394/hosts.c	2004-01-19 22:17:22.000000000 -0800
@@ -89,6 +89,8 @@ struct hpsb_host *hpsb_alloc_host(struct
         INIT_LIST_HEAD(&h->pending_packets);
         spin_lock_init(&h->pending_pkt_lock);
 
+	INIT_LIST_HEAD(&h->addr_space);
+
 	for (i = 0; i < ARRAY_SIZE(h->tpool); i++)
 		HPSB_TPOOL_INIT(&h->tpool[i]);
 
diff -puN drivers/ieee1394/hosts.h~linus drivers/ieee1394/hosts.h
--- 25/drivers/ieee1394/hosts.h~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ieee1394/hosts.h	2004-01-19 22:17:22.000000000 -0800
@@ -69,6 +69,8 @@ struct hpsb_host {
 	int id;
 
 	struct device device;
+
+	struct list_head addr_space;
 };
 
 
diff -puN drivers/ieee1394/ieee1394_core.c~linus drivers/ieee1394/ieee1394_core.c
--- 25/drivers/ieee1394/ieee1394_core.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ieee1394/ieee1394_core.c	2004-01-19 22:17:22.000000000 -0800
@@ -993,186 +993,11 @@ void abort_timedouts(unsigned long __opa
 }
 
 
-/*
- * character device dispatching (see ieee1394_core.h)
- * Dan Maas <dmaas@dcine.com>
- */
-
-static struct {
-	struct file_operations *file_ops;
-	struct module *module;
-} ieee1394_chardevs[16];
-
-static rwlock_t ieee1394_chardevs_lock = RW_LOCK_UNLOCKED;
-
-static int ieee1394_dispatch_open(struct inode *inode, struct file *file);
-
-static struct file_operations ieee1394_chardev_ops = {
-	.owner =THIS_MODULE,
-	.open =	ieee1394_dispatch_open,
-};
-
-/* claim a block of minor numbers */
-int ieee1394_register_chardev(int blocknum,
-			      struct module *module,
-			      struct file_operations *file_ops)
-{
-	int retval;
-
-	if ( (blocknum < 0) || (blocknum > 15) )
-		return -EINVAL;
-
-	write_lock(&ieee1394_chardevs_lock);
-
-	if (ieee1394_chardevs[blocknum].file_ops == NULL) {
-		/* grab the minor block */
-		ieee1394_chardevs[blocknum].file_ops = file_ops;
-		ieee1394_chardevs[blocknum].module = module;
-		
-		retval = 0;
-	} else {
-		/* block already taken */
-		retval = -EBUSY;
-	}
-
-	write_unlock(&ieee1394_chardevs_lock);
-
-	return retval;
-}
-
-/* release a block of minor numbers */
-void ieee1394_unregister_chardev(int blocknum)
-{
-	if ( (blocknum < 0) || (blocknum > 15) )
-		return;
-
-	write_lock(&ieee1394_chardevs_lock);
-
-	if (ieee1394_chardevs[blocknum].file_ops) {
-		ieee1394_chardevs[blocknum].file_ops = NULL;
-		ieee1394_chardevs[blocknum].module = NULL;
-	}
-
-	write_unlock(&ieee1394_chardevs_lock);
-}
-
-/*
-  ieee1394_get_chardev() - look up and acquire a character device
-  driver that has previously registered using ieee1394_register_chardev()
-  
-  On success, returns 1 and sets module and file_ops to the driver.
-  The module will have an incremented reference count.
-   
-  On failure, returns 0.
-  The module will NOT have an incremented reference count.
-*/
-
-static int ieee1394_get_chardev(int blocknum,
-				struct module **module,
-				struct file_operations **file_ops)
-{
-	int ret = 0;
-       
-	if ((blocknum < 0) || (blocknum > 15))
-		return ret;
-
-	read_lock(&ieee1394_chardevs_lock);
-
-	*module = ieee1394_chardevs[blocknum].module;
-	*file_ops = ieee1394_chardevs[blocknum].file_ops;
-
-	if (*file_ops == NULL)
-		goto out;
-
-	if (!try_module_get(*module))
-		goto out;
-
-	/* success! */
-	ret = 1;
-
-out:
-	read_unlock(&ieee1394_chardevs_lock);
-	return ret;
-}
-
-/* the point of entry for open() on any ieee1394 character device */
-static int ieee1394_dispatch_open(struct inode *inode, struct file *file)
-{
-	struct file_operations *file_ops;
-	struct module *module;
-	int blocknum;
-	int retval;
-
-	/*
-	  Maintaining correct module reference counts is tricky here!
-
-	  The key thing to remember is that the VFS increments the
-	  reference count of ieee1394 before it calls
-	  ieee1394_dispatch_open().
-
-	  If the open() succeeds, then we need to transfer this extra
-	  reference to the task-specific driver module (e.g. raw1394).
-	  The VFS will deref the driver module automatically when the
-	  file is later released.
-
-	  If the open() fails, then the VFS will drop the
-	  reference count of whatever module file->f_op->owner points
-	  to, immediately after this function returns.
-	*/
-
-        /* shift away lower four bits of the minor
-	   to get the index of the ieee1394_driver
-	   we want */
-
-	blocknum = (iminor(inode) >> 4) & 0xF;
-
-	/* look up the driver */
-
-	if (ieee1394_get_chardev(blocknum, &module, &file_ops) == 0)
-		return -ENODEV;
-
-	/* redirect all subsequent requests to the driver's
-	   own file_operations */
-	file->f_op = file_ops;
-
-	/* at this point BOTH ieee1394 and the task-specific driver have
-	   an extra reference */
-
-	/* follow through with the open() */
-	retval = file_ops->open(inode, file);
-
-	if (retval == 0) {
-		
-		/* If the open() succeeded, then ieee1394 will be left
-		 * with an extra module reference, so we discard it here.
-		 *
-		 * The task-specific driver still has the extra reference
-		 * given to it by ieee1394_get_chardev(). This extra
-		 * reference prevents the module from unloading while the
-		 * file is open, and will be dropped by the VFS when the
-		 * file is released. */
-
-		module_put(THIS_MODULE);
-	} else {
-		/* point the file's f_ops back to ieee1394. The VFS will then
-		   decrement ieee1394's reference count immediately after this
-		   function returns. */
-		
-		file->f_op = &ieee1394_chardev_ops;
-
-		/* If the open() failed, then we need to drop the extra
-		 * reference we gave to the task-specific driver. */
-
-		module_put(module);
-	}
-
-	return retval;
-}
-
 static int __init ieee1394_init(void)
 {
 	devfs_mk_dir("ieee1394");
-	if (register_chrdev(IEEE1394_MAJOR, "ieee1394", &ieee1394_chardev_ops)) {
+
+	if (register_chrdev_region(IEEE1394_CORE_DEV, 256, "ieee1394")) {
 		HPSB_ERR("unable to register character device major %d!\n", IEEE1394_MAJOR);
 		return -ENODEV;
 	}
@@ -1184,7 +1009,6 @@ static int __init ieee1394_init(void)
 
 	bus_register(&ieee1394_bus_type);
 
-	init_hpsb_highlevel();
 	init_csr();
 
 	if (!disable_nodemgr)
@@ -1206,7 +1030,7 @@ static void __exit ieee1394_cleanup(void
 
 	kmem_cache_destroy(hpsb_packet_cache);
 
-	unregister_chrdev(IEEE1394_MAJOR, "ieee1394");
+	unregister_chrdev_region(IEEE1394_CORE_DEV, 256);
 	devfs_remove("ieee1394");
 }
 
@@ -1234,8 +1058,6 @@ EXPORT_SYMBOL(hpsb_selfid_received);
 EXPORT_SYMBOL(hpsb_selfid_complete);
 EXPORT_SYMBOL(hpsb_packet_sent);
 EXPORT_SYMBOL(hpsb_packet_received);
-EXPORT_SYMBOL(ieee1394_register_chardev);
-EXPORT_SYMBOL(ieee1394_unregister_chardev);
 
 /** ieee1394_transactions.c **/
 EXPORT_SYMBOL(hpsb_get_tlabel);
diff -puN drivers/ieee1394/ieee1394_core.h~linus drivers/ieee1394/ieee1394_core.h
--- 25/drivers/ieee1394/ieee1394_core.h~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ieee1394/ieee1394_core.h	2004-01-19 22:17:22.000000000 -0800
@@ -176,9 +176,9 @@ void hpsb_packet_received(struct hpsb_ho
  * task-specific interfaces (raw1394, video1394, dv1394, etc) in
  * blocks of 16.
  *
- * The core ieee1394.o modules handles the initial open() for all
- * character devices on major 171; it then dispatches to the
- * appropriate task-specific driver.
+ * The core ieee1394.o module allocates the device number region
+ * 171:0-255, the various drivers must then cdev_add() their cdev
+ * objects to handle their respective sub-regions.
  *
  * Minor device number block allocations:
  *
@@ -199,29 +199,19 @@ void hpsb_packet_received(struct hpsb_ho
 #define IEEE1394_MINOR_BLOCK_AMDTP         3
 #define IEEE1394_MINOR_BLOCK_EXPERIMENTAL 15
 
+#define IEEE1394_CORE_DEV		MKDEV(IEEE1394_MAJOR, 0)
+#define IEEE1394_RAW1394_DEV		MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16)
+#define IEEE1394_VIDEO1394_DEV		MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_VIDEO1394 * 16)
+#define IEEE1394_DV1394_DEV		MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16)
+#define IEEE1394_AMDTP_DEV		MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_AMDTP * 16)
+#define IEEE1394_EXPERIMENTAL_DEV	MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_EXPERIMENTAL * 16)
+
 /* return the index (within a minor number block) of a file */
 static inline unsigned char ieee1394_file_to_instance(struct file *file)
 {
-	unsigned char minor = iminor(file->f_dentry->d_inode);
-	
-	/* return lower 4 bits */
-	return minor & 0xF;
+	return file->f_dentry->d_inode->i_cindex;
 }
 
-/* 
- * Task-specific drivers should call ieee1394_register_chardev() to
- * request a block of 16 minor numbers.
- *
- * Returns 0 if the request was successful, -EBUSY if the block was
- * already taken.
- */
-
-int  ieee1394_register_chardev(int blocknum,           /* 0-15 */
-			       struct module *module,  /* THIS_MODULE */
-			       struct file_operations *file_ops);
-
-/* release a block of minor numbers */
-void ieee1394_unregister_chardev(int blocknum);
 
 /* Our sysfs bus entry */
 extern struct bus_type ieee1394_bus_type;
diff -puN drivers/ieee1394/Kconfig~linus drivers/ieee1394/Kconfig
--- 25/drivers/ieee1394/Kconfig~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ieee1394/Kconfig	2004-01-19 22:17:22.000000000 -0800
@@ -40,7 +40,7 @@ config IEEE1394_OUI_DB
 	help
 	  If you say Y here, then an OUI list (vendor unique ID's) will be
 	  compiled into the ieee1394 module. This doesn't really do much
-	  accept being able to display the vendor of a hardware node. The
+	  except being able to display the vendor of a hardware node. The
 	  downside is that it adds about 300k to the size of the module,
 	  or kernel (depending on whether you compile ieee1394 as a
 	  module, or static in the kernel).
@@ -51,12 +51,13 @@ config IEEE1394_OUI_DB
 comment "Device Drivers"
 	depends on IEEE1394
 
-comment "Texas Instruments PCILynx requires I2C bit-banging"
-	depends on IEEE1394 && (I2C=n || I2C_ALGOBIT=n)
+comment "Texas Instruments PCILynx requires I2C"
+	depends on IEEE1394 && I2C=n
 
 config IEEE1394_PCILYNX
 	tristate "Texas Instruments PCILynx support"
-	depends on PCI && IEEE1394 && I2C_ALGOBIT
+	depends on PCI && IEEE1394 && I2C
+	select I2C_ALGOBIT
 	help
 	  Say Y here if you have an IEEE-1394 controller with the Texas
 	  Instruments PCILynx chip.  Note: this driver is written for revision
diff -puN drivers/ieee1394/ohci1394.c~linus drivers/ieee1394/ohci1394.c
--- 25/drivers/ieee1394/ohci1394.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ieee1394/ohci1394.c	2004-01-19 22:17:22.000000000 -0800
@@ -161,7 +161,7 @@ printk(level "%s: " fmt "\n" , OHCI1394_
 printk(level "%s: fw-host%d: " fmt "\n" , OHCI1394_DRIVER_NAME, card , ## args)
 
 static char version[] __devinitdata =
-	"$Rev: 1087 $ Ben Collins <bcollins@debian.org>";
+	"$Rev: 1097 $ Ben Collins <bcollins@debian.org>";
 
 /* Module Parameters */
 static int phys_dma = 1;
@@ -174,6 +174,7 @@ static void dma_trm_reset(struct dma_trm
 static int alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
 			     enum context_type type, int ctx, int num_desc,
 			     int buf_size, int split_buf_size, int context_base);
+static void stop_dma_rcv_ctx(struct dma_rcv_ctx *d);
 static void free_dma_rcv_ctx(struct dma_rcv_ctx *d);
 
 static int alloc_dma_trm_ctx(struct ti_ohci *ohci, struct dma_trm_ctx *d,
@@ -358,7 +359,7 @@ static void ohci_soft_reset(struct ti_oh
 	reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_softReset);
   
 	for (i = 0; i < OHCI_LOOP_COUNT; i++) {
-		if (!reg_read(ohci, OHCI1394_HCControlSet) & OHCI1394_HCControl_softReset)
+		if (!(reg_read(ohci, OHCI1394_HCControlSet) & OHCI1394_HCControl_softReset))
 			break;
 		mdelay(1);
 	}
@@ -1077,6 +1078,7 @@ static int ohci_devctl(struct hpsb_host 
                 DBGMSG(ohci->id, "Listening disabled on channel %d", arg);
 
 		if (ohci->ir_legacy_channels == 0) {
+			stop_dma_rcv_ctx(&ohci->ir_legacy_context);
 			free_dma_rcv_ctx(&ohci->ir_legacy_context);
 			DBGMSG(ohci->id, "ISO receive legacy context deactivated");
 		}
@@ -2249,6 +2251,14 @@ static irqreturn_t ohci_irq_handler(int 
 	if (!event)
 		return IRQ_NONE;
 
+	/* If event is ~(u32)0 cardbus card was ejected.  In this case
+	 * we just return, and clean up in the ohci1394_pci_remove
+	 * function. */
+	if (event == ~(u32) 0) {
+		DBGMSG(ohci->id, "Device removed.");
+		return IRQ_NONE;
+	}
+
 	DBGMSG(ohci->id, "IntEvent: %08x", event);
 
 	if (event & OHCI1394_unrecoverableError) {
@@ -2811,15 +2821,8 @@ static void dma_trm_tasklet (unsigned lo
 	spin_unlock_irqrestore(&d->lock, flags);
 }
 
-static void free_dma_rcv_ctx(struct dma_rcv_ctx *d)
+static void stop_dma_rcv_ctx(struct dma_rcv_ctx *d)
 {
-	int i;
-
-	if (d->ohci == NULL)
-		return;
-
-	DBGMSG(d->ohci->id, "Freeing dma_rcv_ctx %d", d->ctx);
-
 	if (d->ctrlClear) {
 		ohci1394_stop_context(d->ohci, d->ctrlClear, NULL);
 
@@ -2831,6 +2834,17 @@ static void free_dma_rcv_ctx(struct dma_
 			tasklet_kill(&d->task);
 		}
 	}
+}
+
+
+static void free_dma_rcv_ctx(struct dma_rcv_ctx *d)
+{
+	int i;
+
+	if (d->ohci == NULL)
+		return;
+
+	DBGMSG(d->ohci->id, "Freeing dma_rcv_ctx %d", d->ctx);
 
 	if (d->buf_cpu) {
 		for (i=0; i<d->num_desc; i++)
@@ -2982,19 +2996,6 @@ static void free_dma_trm_ctx(struct dma_
 
 	DBGMSG(d->ohci->id, "Freeing dma_trm_ctx %d", d->ctx);
 
-	if (d->ctrlClear) {
-		ohci1394_stop_context(d->ohci, d->ctrlClear, NULL);
-
-		if (d->type == DMA_CTX_ISO) {
-			/* disable interrupts */
-			reg_write(d->ohci, OHCI1394_IsoXmitIntMaskClear, 1 << d->ctx);
-			ohci1394_unregister_iso_tasklet(d->ohci,
-							&d->ohci->it_legacy_tasklet);
-		} else {
-			tasklet_kill(&d->task);
-		}
-	}
-
 	if (d->prg_cpu) {
 		for (i=0; i<d->num_desc; i++) 
 			if (d->prg_cpu[i] && d->prg_bus[i]) {
@@ -3511,6 +3512,8 @@ static void ohci1394_pci_remove(struct p
 		free_irq(ohci->dev->irq, ohci);
 
 	case OHCI_INIT_HAVE_TXRX_BUFFERS__MAYBE:
+		/* The ohci_soft_reset() stops all DMA contexts, so we
+		 * dont need to do this.  */
 		/* Free AR dma */
 		free_dma_rcv_ctx(&ohci->ar_req_context);
 		free_dma_rcv_ctx(&ohci->ar_resp_context);
diff -puN drivers/ieee1394/oui.db~linus drivers/ieee1394/oui.db
--- 25/drivers/ieee1394/oui.db~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ieee1394/oui.db	2004-01-19 22:17:22.000000000 -0800
@@ -108,7 +108,7 @@
 00006B SILICON GRAPHICS INC./MIPS
 00006D CRAY COMMUNICATIONS, LTD.
 00006E ARTISOFT, INC.
-00006F MADGE NETWORKS LTD.
+00006F Madge Ltd.
 000070 HCL LIMITED
 000071 ADRA SYSTEMS INC.
 000072 MINIWARE TECHNOLOGY
@@ -137,7 +137,7 @@
 000089 CAYMAN SYSTEMS INC.
 00008A DATAHOUSE INFORMATION SYSTEMS
 00008B INFOTRON
-00008C ALLOY COMPUTER PRODUCTS, INC.
+00008C Alloy Computer Products (Australia) Pty Ltd
 00008D VERDIX CORPORATION
 00008E SOLBOURNE COMPUTER, INC.
 00008F RAYTHEON COMPANY
@@ -190,7 +190,7 @@
 0000BE THE NTI GROUP
 0000BF SYMMETRIC COMPUTER SYSTEMS
 0000C0 WESTERN DIGITAL CORPORATION
-0000C1 Madge Networks Ltd.
+0000C1 Madge Ltd.
 0000C2 INFORMATION PRESENTATION TECH.
 0000C3 HARRIS CORP COMPUTER SYS DIV
 0000C4 WATERS DIV. OF MILLIPORE
@@ -202,7 +202,7 @@
 0000CA APPLITEK
 0000CB COMPU-SHACK ELECTRONIC GMBH
 0000CC DENSAN CO., LTD.
-0000CD Centrecom Systems, Ltd.
+0000CD Allied Telesyn Research Ltd.
 0000CE MEGADATA CORP.
 0000CF HAYES MICROCOMPUTER PRODUCTS
 0000D0 DEVELCON ELECTRONICS LTD.
@@ -271,7 +271,7 @@
 000110 Gotham Networks
 000111 iDigm Inc.
 000112 Shark Multimedia Inc.
-000113 OLYMPUS OPTICAL CO., LTD.
+000113 OLYMPUS CORPORATION
 000114 KANDA TSUSHIN KOGYO CO., LTD.
 000115 EXTRATECH CORPORATION
 000116 Netspect Technologies, Inc.
@@ -345,7 +345,7 @@
 00015A Digital Video Broadcasting
 00015B ITALTEL S.p.A/RF-UP-I
 00015C CADANT INC.
-00015D Pirus Networks
+00015D Sun Microsystems, Inc
 00015E BEST TECHNOLOGY CO., LTD.
 00015F DIGITAL DESIGN GmbH
 000160 ELMEX Co., LTD.
@@ -361,7 +361,7 @@
 00016A ALITEC
 00016B LightChip, Inc.
 00016C FOXCONN
-00016D Triton Network Systems
+00016D CarrierComm Inc.
 00016E Conklin Corporation
 00016F HAITAI ELECTRONICS CO., LTD.
 000170 ESE Embedded System Engineer'g
@@ -445,7 +445,7 @@
 0001BE Gigalink Co., Ltd.
 0001BF Teleforce Co., Ltd.
 0001C0 CompuLab, Ltd.
-0001C1 Exbit Technology
+0001C1 Vitesse Semiconductor Corporation
 0001C2 ARK Research Corp.
 0001C3 Acromag, Inc.
 0001C4 NeoWave, Inc.
@@ -495,6 +495,7 @@
 0001EF Camtel Technology Corp.
 0001F0 Tridium, Inc.
 0001F1 Innovative Concepts, Inc.
+0001F2 Mark of the Unicorn, Inc.
 0001F3 QPS, Inc.
 0001F4 Enterasys Networks
 0001F5 ERIM S.A.
@@ -515,6 +516,7 @@
 000204 Bodmann Industries Elektronik GmbH
 000205 Hitachi Denshi, Ltd.
 000206 Telital R&D Denmark A/S
+000207 VisionGlobal Network Corp.
 000208 Unify Networks, Inc.
 000209 Shenzhen SED Information Technology Co., Ltd.
 00020A Gefran Spa
@@ -579,7 +581,7 @@
 000245 Lampus Co, Ltd.
 000246 All-Win Tech Co., Ltd.
 000247 Great Dragon Information Technology (Group) Co., Ltd.
-000248 Pila GmbH & Co.
+000248 Pilz GmbH & Co.
 000249 Aviv Infocom Co, Ltd.
 00024A Cisco Systems, Inc.
 00024B Cisco Systems, Inc.
@@ -600,6 +602,7 @@
 00025A Catena Networks
 00025B Cambridge Silicon Radio
 00025C SCI Systems (Kunshan) Co., Ltd.
+00025D Calix Networks
 00025E High Technology Ltd
 00025F Nortel Networks
 000260 Accordion Networks, Inc.
@@ -635,7 +638,7 @@
 00027E Cisco Systems, Inc.
 00027F ask-technologies.com
 000280 Mu Net, Inc.
-000281 Red-M (Communications) Ltd.
+000281 Madge Ltd.
 000282 ViaClix, Inc.
 000283 Spectrum Controls, Inc.
 000284 Alstom T&D P&C
@@ -662,6 +665,7 @@
 000299 Apex, Inc.
 00029A Storage Apps
 00029B Kreatel Communications AB
+00029C 3COM
 00029D Merix Corp.
 00029E Information Equipment Co., Ltd.
 00029F L-3 Communication Aviation Recorders
@@ -678,7 +682,7 @@
 0002AA PLcom Co., Ltd.
 0002AB CTC Union Technologies Co., Ltd.
 0002AC 3PAR data
-0002AD Asahi Optical Co., Ltd.
+0002AD Pentax Corpotation
 0002AE Scannex Electronics Ltd.
 0002AF TeleCruz Technology, Inc.
 0002B0 Hokubu Communication & Industrial Co., Ltd.
@@ -740,7 +744,7 @@
 0002E8 E.D.&A.
 0002E9 CS Systemes De Securite - C3S
 0002EA Videonics, Inc.
-0002EB Easent Communications
+0002EB Pico Communications
 0002EC Maschoff Design Engineering
 0002ED DXO Telecom Co., Ltd.
 0002EE Nokia Danmark A/S
@@ -760,7 +764,7 @@
 0002FC Cisco Systems, Inc.
 0002FD Cisco Systems, Inc.
 0002FE Viditec, Inc.
-0002FF Handan Broad InfoCom
+0002FF Handan BroadInfoCom
 000300 NetContinuum, Inc.
 000301 Avantas Networks Corporation
 000302 Oasys Telecom, Inc.
@@ -776,7 +780,7 @@
 00030C Telesoft Technologies Ltd.
 00030D Uniwill Computer Corp.
 00030E Core Communications Co., Ltd.
-00030F Legend Digital China Ltd.
+00030F Digital China (Shanghai) Networks Ltd.
 000310 Link Evolution Corp.
 000311 Micro Technology Co., Ltd.
 000312 TR-Systemtechnik GmbH
@@ -797,7 +801,7 @@
 000321 Reco Research Co., Ltd.
 000322 IDIS Co., Ltd.
 000323 Cornet Technology, Inc.
-000324 Tottori SANYO Electric Co., Ltd.
+000324 SANYO Multimedia Tottori Co., Ltd.
 000325 Arima Computer Corp.
 000326 Iwasaki Information Systems Co., Ltd.
 000327 ACT'L
@@ -851,12 +855,12 @@
 000357 Intervoice-Brite, Inc.
 000358 iCable System Co., Ltd.
 000359 DigitalSis
-00035A Phototron Limited
+00035A Photron Limited
 00035B BridgeWave Communications
 00035C Saint Song Corp.
 00035D Bosung Hi-Net Co., Ltd.
 00035E Metropolitan Area Networks, Inc.
-00035F Schuehle Mess - und. Kontrollsysteme
+00035F Prueftechnik Condition Monitoring GmbH & Co. KG
 000360 PAC Interactive Technology, Inc.
 000361 Widcomm, Inc.
 000362 Vodtel Communications, Inc.
@@ -889,6 +893,7 @@
 00037D Stellcom
 00037E PORTech Communications, Inc.
 00037F Atheros Communications, Inc.
+000380 SSH Communications Security Corp.
 000381 Ingenico International
 000382 A-One Co., Ltd.
 000383 Metera Networks, Inc.
@@ -916,7 +921,7 @@
 00039A nSine, Ltd.
 00039B NetChip Technology, Inc.
 00039C OptiMight Communications, Inc.
-00039D Acer Communications & Multimedia, Inc.
+00039D BENQ CORPORATION
 00039E Tera System Co., Ltd.
 00039F Cisco Systems, Inc.
 0003A0 Cisco Systems, Inc.
@@ -1063,7 +1068,7 @@
 00042E Netous Technologies, Ltd.
 00042F International Communications Products, Inc.
 000430 Netgem
-000431 Play Industries
+000431 GlobalStreams, Inc.
 000432 Voyetra Turtle Beach, Inc.
 000433 Cyberboard A/S
 000434 Accelent Systems, Inc.
@@ -1082,7 +1087,7 @@
 000441 Half Dome Systems, Inc.
 000442 NACT
 000443 Agilent Technologies, Inc.
-000444 Wireless Home
+000444 Western Multiplex Corporation
 000445 LMS Skalar Instruments GmbH
 000446 CYZENTECH Co., Ltd.
 000447 Acrowave Systems Co., Ltd.
@@ -1097,7 +1102,7 @@
 000450 DMD Computers SRL
 000451 Medrad, Inc.
 000452 RocketLogix, Inc.
-000453 Yotta Yotta, Inc.
+000453 YottaYotta, Inc.
 000454 Quadriga UK
 000455 ANTARA.net
 000456 PipingHot Networks
@@ -1108,16 +1113,16 @@
 00045B Techsan Electronics Co., Ltd.
 00045C Mobiwave Pte Ltd
 00045D BEKA Elektronik
-00045E Poly Trax Information Technology AG
+00045E PolyTrax Information Technology AG
 00045F Evalue Technology, Inc.
 000460 Knilink Technology, Inc.
 000461 EPOX Computer Co., Ltd.
 000462 DAKOS Data & Communication Co., Ltd.
-000463 Philips Communication Security & Imaging
+000463 Bosch Security Systems
 000464 Fantasma Networks, Inc.
-000465 ist isdn support tecknik GmbH
+000465 i.s.t isdn-support technik GmbH
 000466 ARMITEL Co.
-000467 Wuhan Research Institute
+000467 Wuhan Research Institute of MII
 000468 Vivity, Inc.
 000469 Innocom, Inc.
 00046A Navini Networks
@@ -1133,7 +1138,7 @@
 000474 LEGRAND
 000475 3 Com Corporation
 000476 3 Com Corporation
-000477 e-Appliance Corp.
+000477 Scalant Systems, Inc.
 000478 G. Star Technology Corporation
 000479 Radius Co., Ltd.
 00047A AXXESSIT ASA
@@ -1144,7 +1149,7 @@
 00047F Chr. Mayr GmbH & Co. KG
 000480 Foundry Networks, Inc.
 000481 Econolite Control Products, Inc.
-000482 MediaLogic Corp.
+000482 Medialogic Corp.
 000483 Deltron Technology, Inc.
 000484 Amann GmbH
 000485 PicoLight
@@ -1195,7 +1200,7 @@
 0004B3 Videotek, Inc.
 0004B4 CIAC
 0004B5 Equitrac Corporation
-0004B6 Tellumat (Pty) Ltd.
+0004B6 Stratex Networks, Inc.
 0004B7 AMB i.t. Holding
 0004B8 Kumahira Co., Ltd.
 0004B9 S.I. Soubou, Inc.
@@ -1204,20 +1209,20 @@
 0004BC Giantec, Inc.
 0004BD Motorola BCS
 0004BE OptXCon, Inc.
-0004BF Versa Logic Corp.
+0004BF VersaLogic Corp.
 0004C0 Cisco Systems, Inc.
 0004C1 Cisco Systems, Inc.
 0004C2 Magnipix, Inc.
 0004C3 CASTOR Informatique
-0004C4 Allen & Health
+0004C4 Allen & Heath Limited
 0004C5 ASE Technologies, USA
 0004C6 Yamaha Motor Co., Ltd.
 0004C7 NetMount
-0004C8 LIBA Maschinefabrik GmbH
+0004C8 LIBA Maschinenfabrik GmbH
 0004C9 Micro Electron Co., Ltd.
 0004CA FreeMs Corp.
 0004CB Tdsoft Communication, Ltd.
-0004CC Peek Traffic BV.
+0004CC Peek Traffic B.V.
 0004CD Informedia Research Group
 0004CE Patria Ailon
 0004CF Seagate Technology
@@ -1286,7 +1291,7 @@
 00050E 3ware, Inc.
 00050F Tanaka S/S Ltd.
 000510 Infinite Shanghai Communication Terminals Ltd.
-000511 Complementaty Technologies Ltd
+000511 Complementary Technologies Ltd
 000512 MeshNetworks, Inc.
 000513 VTLinx Multimedia Systems, Inc.
 000514 KDT Systems Co., Ltd.
@@ -1299,7 +1304,7 @@
 00051B Magic Control Technology Corporation
 00051C Xnet Technology Corp.
 00051D Airocon, Inc.
-00051E Rhapsody Networks
+00051E Brocade Communications Systems, Inc.
 00051F Taijin Media Co., Ltd.
 000520 Smartronix, Inc.
 000521 Control Microsystems
@@ -1339,7 +1344,7 @@
 000543 IQ Wireless GmbH
 000544 Valley Technologies, Inc.
 000545 Internet Photonics
-000546 KDD Network Systems Co., Ltd.
+000546 K-Solutions Inc.
 000547 Starent Networks
 000548 Disco Corporation
 000549 Salira Optical Network Systems
@@ -1374,6 +1379,7 @@
 000567 Etymonic Design, Inc.
 000568 Piltofish Networks AB
 000569 VMWARE, Inc.
+00056A Heuft Systemtechnik GmbH
 00056B C.P. Technology Co., Ltd.
 00056C Hung Chang Co., Ltd.
 00056D Pacific Corporation
@@ -1408,18 +1414,18 @@
 00058B IPmental, Inc.
 00058C Opentech Inc.
 00058D Lynx Photonic Networks, Inc.
-00058E Ahead Communications System GmbH
+00058E Flextronics International GmbH & Co. Nfg. KG
 00058F CLCsoft co.
-000590 Ascom Business Systems
+000590 Swissvoice Ltd.
 000591 Active Silicon Ltd.
-000592 Pultex Corp.
+000592 Pultek Corp.
 000593 Grammar Engine Inc.
 000594 IXXAT Automation GmbH
 000595 Alesis Corporation
 000596 Genotech Co., Ltd.
 000597 Eagle Traffic Control Systems
 000598 CRONOS S.r.l.
-000599 PEI Electronics, Inc.
+000599 DRS Test and Energy Management or DRS-TEM
 00059A Cisco Systems, Inc.
 00059B Cisco Systems, Inc.
 00059C Kleinknecht GmbH, Ing. Buero
@@ -1436,7 +1442,7 @@
 0005A7 Hyperchip, Inc.
 0005A8 WYLE ELECTRONICS
 0005A9 Princeton Networks, Inc.
-0005AA Moore Industries Int.
+0005AA Moore Industries International Inc.
 0005AB Cyber Fone, Inc.
 0005AC Northern Digital, Inc.
 0005AD Topspin Communications, Inc.
@@ -1453,13 +1459,14 @@
 0005B8 Electronic Design Associates, Inc.
 0005B9 Airvana, Inc.
 0005BA Area Netwoeks, Inc.
+0005BB Myspace AB
 0005BC Resorsys Ltd.
 0005BD ROAX BV
 0005BE Kongsberg Seatex AS
 0005BF JustEzy Technology, Inc.
 0005C0 Digital Network Alacarte Co., Ltd.
 0005C1 A-Kyung Motion, Inc.
-0005C2 Digital Archway, Inc.
+0005C2 Soronti, Inc.
 0005C3 Pacific Instruments, Inc.
 0005C4 Telect, Inc.
 0005C5 Flaga HF
@@ -1470,13 +1477,13 @@
 0005CA Hitron Technology, Inc.
 0005CB ROIS Technologies, Inc.
 0005CC Sumtel Communications, Inc.
-0005CD Nippon Columbia
+0005CD Denon, Ltd.
 0005CE Prolink Microsystems Corporation
 0005CF Thunder River Technologies, Inc.
 0005D0 Solinet Systems
 0005D1 Metavector Technologies
 0005D2 DAP Technologies
-0005D3 CAC, Inc.
+0005D3 eProduction Solutions, Inc.
 0005D4 FutureSmart Networks, Inc.
 0005D5 Speedcom Wireless
 0005D6 Titan Wireless
@@ -1496,27 +1503,27 @@
 0005E4 Red Lion Controls L.P.
 0005E5 Renishaw PLC
 0005E6 Egenera, Inc.
-0005E7 Netrake
+0005E7 Netrake Corp.
 0005E8 TurboWave, Inc.
-0005E9 Unicess Networks, Inc.
-0005EA Viewcast Corporation
+0005E9 Unicess Network, Inc.
+0005EA Rednix
 0005EB Blue Ridge Networks, Inc.
 0005EC Mosaic Systems Inc.
-0005ED Technikum Joanneaum GmbH
+0005ED Technikum Joanneum GmbH
 0005EE BEWATOR Group
 0005EF ADOIR Digital Technology
 0005F0 SATEC
-0005F1 VRcom, Inc.
+0005F1 Vrcom, Inc.
 0005F2 Power R, Inc.
 0005F3 Weboyn
-0005F4 SystemBase Co., Ltd.
+0005F4 System Base Co., Ltd.
 0005F5 OYO Geospace Corp.
 0005F6 Young Chang Co. Ltd.
 0005F7 Analog Devices, Inc.
 0005F8 Real Time Access, Inc.
-0005F9 Diva Systems
+0005F9 TOA Corporation
 0005FA IPOptical, Inc.
-0005FB Sharegate
+0005FB ShareGate, Inc.
 0005FC Schenck Pegasus Corp.
 0005FD PacketLight Networks Ltd.
 0005FE Traficon N.V.
@@ -1524,23 +1531,23 @@
 000600 Tokyo Electronic Industry Co., Ltd.
 000601 Otanikeiki Co., Ltd.
 000602 Cirkitech Electronics Co.
-000603 Baker Hughes
+000603 Baker Hughes Inc.
 000604 @Track Communications, Inc.
 000605 Inncom International, Inc.
-000606 RapidWan, Inc.
-000607 Omni-Directional Control Technology Inc.
+000606 RapidWAN, Inc.
+000607 Omni Directional Control Technology Inc.
 000608 At-Sky SAS
 000609 Crossport Systems
-00060A Blue2space.com
+00060A Blue2space
 00060B Paceline Systems Corporation
 00060C Melco Industries, Inc.
 00060D Wave7 Optics
-00060E IGSYS Systems, Inc.
+00060E IGYS Systems, Inc.
 00060F Narad Networks Inc
 000610 Abeona Networks Inc
 000611 Zeus Wireless, Inc.
 000612 Accusys, Inc.
-000613 Kawasaki Steel Corporation
+000613 Kawasaki Microelectronics Incorporated
 000614 Prism Holdings
 000615 Kimoto Electric Co., Ltd.
 000616 Tel Net Co., Ltd.
@@ -1557,7 +1564,7 @@
 000621 Hinox, Co., Ltd.
 000622 Chung Fu Chen Yeh Enterprise Corp.
 000623 MGE UPS Systems France
-000624 Gentner Communications
+000624 Gentner Communications Corp.
 000625 The Linksys Group, Inc.
 000626 MWE GmbH
 000627 Uniwide Technologies, Inc.
@@ -1580,7 +1587,7 @@
 000638 Sungjin C&C Co., Ltd.
 000639 Newtec
 00063A Dura Micro, Inc.
-00063B Lineo Canada Corp.
+00063B Arcturus Networks, Inc.
 00063C NMI Electronics Ltd
 00063D Microwave Data Systems Inc.
 00063E Opthos Inc.
@@ -1622,7 +1629,7 @@
 000662 MBM Technology Ltd.
 000663 Human Technology Co., Ltd.
 000664 Fostex Corporation
-000665 Summy Gikem, Inc.
+000665 Sunny Giken, Inc.
 000666 Roving Networks
 000667 Tripp Lite
 000668 Vicon Industries Inc.
@@ -1639,7 +1646,7 @@
 000673 Optelecom, Inc.
 000674 Spectrum Control, Inc.
 000675 Banderacom, Inc.
-000676 Novra Technologies, Inc.
+000676 Novra Technologies Inc.
 000677 SICK AG
 000678 Marantz Japan, Inc.
 000679 Konami Corporation
@@ -1647,18 +1654,2125 @@
 00067B Toplink C&C Corporation
 00067C CISCO SYSTEMS, INC.
 00067D Takasago Ltd.
+00067E WinCom Systems, Inc.
+00067F Rearden Steel Technologies
+000680 Card Access, Inc.
+000681 Goepel Electronic GmbH
+000682 Convedia
+000683 Bravara Communications, Inc.
+000684 Biacore AB
+000685 NetNearU Corporation
+000686 ZARDCOM Co., Ltd.
+000687 Omnitron Systems Technology, Inc.
+000688 Telways Communication Co., Ltd.
+000689 yLez Technologies Pte Ltd
+00068A NeuronNet Co. Ltd. R&D Center
+00068B AirRunner Technologies, Inc.
+00068C 3Com Corporation
+00068D SANgate Systems
+00068E HID Corporation
+00068F Telemonitor, Inc.
+000690 Euracom Communication GmbH
+000691 PT Inovacao
+000692 Intruvert Networks, Inc.
+000693 Flexus Computer Technology, Inc.
+000694 Mobillian Corporation
+000695 Ensure Technologies, Inc.
+000696 Advent Networks
+000697 R & D Center
+000698 egnite Software GmbH
+000699 Vida Design Co.
+00069A e & Tel
+00069B AVT Audio Video Technologies GmbH
+00069C Transmode Systems AB
+00069D Petards Mobile Intelligence
+00069E UNIQA, Inc.
+00069F Kuokoa Networks
+0006A0 Mx Imaging
+0006A1 Celsian Technologies, Inc.
+0006A2 Microtune, Inc.
+0006A3 Bitran Corporation
+0006A4 INNOWELL Corp.
+0006A5 PINON Corp.
+0006A6 Artistic Licence (UK) Ltd
+0006A7 Primarion
+0006A8 KC Technology, Inc.
+0006A9 Universal Instruments Corp.
+0006AA Miltope Corporation
+0006AB W-Link Systems, Inc.
+0006AC Intersoft Co.
+0006AD KB Electronics Ltd.
+0006AE Himachal Futuristic Communications Ltd
+0006B0 Comtech EF Data Corp.
+0006B1 Sonicwall
+0006B2 Linxtek Co.
+0006B3 Diagraph Corporation
+0006B4 Vorne Industries, Inc.
+0006B5 Luminent, Inc.
+0006B6 Nir-Or Israel Ltd.
+0006B7 TELEM GmbH
+0006B8 Bandspeed Pty Ltd
+0006B9 A5TEK Corp.
+0006BA Westwave Communications
+0006BB ATI Technologies Inc.
+0006BC Macrolink, Inc.
+0006BD BNTECHNOLOGY Co., Ltd.
+0006BE Baumer Optronic GmbH
+0006BF Accella Technologies Co., Ltd.
+0006C0 United Internetworks, Inc.
 0006C1 CISCO SYSTEMS, INC.
+0006C2 Smartmatic Corporation
+0006C3 Schindler Elevators Ltd.
+0006C4 Piolink Inc.
+0006C5 INNOVI Technologies Limited
+0006C6 lesswire AG
+0006C7 RFNET Technologies Pte Ltd (S)
+0006C8 Sumitomo Metal Micro Devices, Inc.
+0006C9 Technical Marketing Research, Inc.
+0006CA American Computer & Digital Components, Inc. (ACDC)
+0006CB Jotron Electronics A/S
+0006CC JMI Electronics Co., Ltd.
+0006CD CreoScitex Corporation Ltd.
+0006CE DATENO
+0006CF Thales Avionics In-Flight Systems, LLC
+0006D0 Elgar Electronics Corp.
+0006D1 Tahoe Networks, Inc.
+0006D2 Tundra Semiconductor Corp.
+0006D3 Alpha Telecom, Inc. U.S.A.
+0006D4 Interactive Objects, Inc.
+0006D5 Diamond Systems Corp.
+0006D6 Cisco Systems, Inc.
+0006D7 Cisco Systems, Inc.
+0006D8 Maple Optical Systems
+0006D9 IPM-Net S.p.A.
+0006DA ITRAN Communications Ltd.
+0006DB ICHIPS Co., Ltd.
+0006DC Syabas Technology (Amquest)
+0006DD AT & T Laboratories - Cambridge Ltd
+0006DE Flash Technology
+0006DF AIDONIC Corporation
+0006E0 MAT Co., Ltd.
+0006E1 Techno Trade s.a
+0006E2 Ceemax Technology Co., Ltd.
+0006E3 Quantitative Imaging Corporation
+0006E4 Citel Technologies Ltd.
+0006E5 Fujian Newland Computer Ltd. Co.
+0006E6 DongYang Telecom Co., Ltd.
+0006E7 Bit Blitz Communications Inc.
+0006E8 Optical Network Testing, Inc.
+0006E9 Intime Corp.
+0006EA ELZET80 Mikrocomputer GmbH&Co. KG
+0006EB Global Data
+0006EC M/A COM Private Radio System Inc.
+0006ED Inara Networks
+0006EE Shenyang Neu-era Information & Technology Stock Co., Ltd
+0006EF Maxxan Systems, Inc.
+0006F0 Digeo, Inc.
+0006F1 Optillion
+0006F2 Platys Communications
+0006F3 AcceLight Networks
+0006F4 Prime Electronics & Satellitics Inc.
+0006F9 Mitsui Zosen Systems Research Inc.
+0006FA IP SQUARE Co, Ltd.
+0006FB Hitachi Printing Solutions, Ltd.
+0006FC Fnet Co., Ltd.
+0006FD Comjet Information Systems Corp.
+0006FE Celion Networks, Inc.
+0006FF Sheba Systems Co., Ltd.
+000700 Zettamedia Korea
 000701 RACAL-DATACOM
+000702 Varian Medical Systems
+000703 CSEE Transport
+000705 Endress & Hauser GmbH & Co
+000706 Sanritz Corporation
+000707 Interalia Inc.
+000708 Bitrage Inc.
+000709 Westerstrand Urfabrik AB
+00070A Unicom Automation Co., Ltd.
+00070B Octal, SA
+00070C SVA-Intrusion.com Co. Ltd.
+00070D Cisco Systems Inc.
+00070E Cisco Systems Inc.
+00070F Fujant, Inc.
+000710 Adax, Inc.
+000711 Acterna
+000712 JAL Information Technology
+000713 IP One, Inc.
+000714 Brightcom
+000715 General Research of Electronics, Inc.
+000716 J & S Marine Ltd.
+000717 Wieland Electric GmbH
+000718 iCanTek Co., Ltd.
+000719 Mobiis Co., Ltd.
+00071A Finedigital Inc.
+00071B Position Technology Inc.
+00071C AT&T Fixed Wireless Services
+00071D Satelsa Sistemas Y Aplicaciones De Telecomunicaciones, S.A.
+00071E Tri-M Engineering / Nupak Dev. Corp.
+00071F European Systems Integration
+000720 Trutzschler GmbH & Co. KG
+000721 Formac Elektronik GmbH
+000722 Nielsen Media Research
+000723 ELCON Systemtechnik GmbH
+000724 Telemax Co., Ltd.
+000725 Bematech International Corp.
+000727 Zi Corporation (HK) Ltd.
+000728 Neo Telecom
+000729 Kistler Instrumente AG
+00072A Innovance Networks
+00072B Jung Myung Telecom Co., Ltd.
+00072C Fabricom
+00072D CNSystems
+00072E North Node AB
+00072F Instransa, Inc.
+000730 Hutchison OPTEL Telecom Technology Co., Ltd.
+000731 Spiricon, Inc.
+000732 AAEON Technology Inc.
+000733 DANCONTROL Engineering
+000734 ONStor, Inc.
+000735 Flarion Technologies, Inc.
+000736 Data Video Technologies Co., Ltd.
+000737 Soriya Co. Ltd.
+000738 Young Technology Co., Ltd.
+000739 Motion Media Technology Ltd.
+00073A Inventel Systemes
+00073B Tenovis GmbH & Co KG
+00073C Telecom Design
+00073D Nanjing Postel Telecommunications Co., Ltd.
+00073E China Great-Wall Computer Shenzhen Co., Ltd.
+00073F Woojyun Systec Co., Ltd.
+000740 Melco Inc.
+000741 Sierra Automated Systems
+000742 Current Technologies
+000743 Chelsio Communications
+000744 Unico, Inc.
+000745 Radlan Computer Communications Ltd.
+000746 Interlink BT, LLC
+000747 Mecalc
+000748 The Imaging Source Europe
+000749 CENiX Inc.
+00074A Carl Valentin GmbH
+00074B Daihen Corporation
+00074C Beicom Inc.
+00074D Zebra Technologies Corp.
+00074E Naughty boy co., Ltd.
+00074F Cisco Systems, Inc.
+000750 Cisco Systems, Inc.
+000751 m.u.t. - GmbH
+000752 Rhythm Watch Co., Ltd.
+000753 Beijing Qxcomm Technology Co., Ltd.
+000754 Xyterra Computing, Inc.
+000755 Lafon SA
+000756 Juyoung Telecom
+000757 Topcall International AG
+000758 Dragonwave
+000759 Boris Manufacturing Corp.
+00075A Air Products and Chemicals, Inc.
+00075B Gibson Guitars
+00075C ENCAD, Inc.
+00075D Celleritas Inc.
+00075E Pulsar Technologies, Inc.
+00075F VCS Video Communication Systems AG
+000760 TOMIS Information & Telecom Corp.
+000761 Logitech SA
+000762 Group Sense Limited
+000763 Sunniwell Cyber Tech. Co., Ltd.
+000764 YoungWoo Telecom Co. Ltd.
+000765 Jade Quantum Technologies, Inc.
+000766 Chou Chin Industrial Co., Ltd.
+000767 Yuxing Electronics Company Limited
+000768 Danfoss A/S
+000769 Italiana Macchi SpA
+00076A NEXTEYE Co., Ltd.
+00076B Stralfors AB
+00076C Daehanet, Inc.
+00076D Flexlight Networks
+00076E Sinetica Corporation Ltd.
+00076F Synoptics Limited
+000770 Locusnetworks Corporation
+000771 Embedded System Corporation
+000772 Alcatel Shanghai Bell Co., Ltd.
+000773 Ascom Powerline Communications Ltd.
+000774 GuangZhou Thinker Technology Co. Ltd.
+000775 Valence Semiconductor, Inc.
+000776 Federal APD
+000777 Motah Ltd.
+000778 GERSTEL GmbH & Co. KG
+000779 Sungil Telecom Co., Ltd.
+00077A Infoware System Co., Ltd.
+00077B Millimetrix Broadband Networks
+00077C OnTime Networks
+00077E Elrest GmbH
+00077F J Communications Co., Ltd.
+000780 Bluegiga Technologies OY
+000781 Itron Inc.
+000782 Nauticus Networks, Inc.
+000783 SynCom Network, Inc.
+000784 Cisco Systems Inc.
+000785 Cisco Systems Inc.
+000786 Wireless Networks Inc.
+000787 Idea System Co., Ltd.
+000788 Clipcomm, Inc.
+000789 Eastel Systems Corporation
+00078A Mentor Data System Inc.
+00078B Wegener Communications, Inc.
+00078C Elektronikspecialisten i Borlange AB
+00078D NetEngines Ltd.
+00078E Garz & Friche GmbH
+00078F Emkay Innovative Products
+000790 Tri-M Technologies (s) Limited
+000791 International Data Communications, Inc.
+000792 Suetron Electronic GmbH
+000794 Simple Devices, Inc.
+000795 Elitegroup Computer System Co. (ECS)
+000796 LSI Systems, Inc.
+000797 Netpower Co., Ltd.
+000798 Selea SRL
+000799 Tipping Point Technologies, Inc.
+00079A SmartSight Networks Inc.
+00079B Aurora Networks
+00079C Golden Electronics Technology Co., Ltd.
+00079D Musashi Co., Ltd.
+00079E Ilinx Co., Ltd.
+00079F Action Digital Inc.
+0007A0 e-Watch Inc.
+0007A1 VIASYS Healthcare GmbH
+0007A2 Opteon Corporation
+0007A3 Ositis Software, Inc.
+0007A4 GN Netcom Ltd.
+0007A5 Y.D.K Co. Ltd.
+0007A6 Home Automation, Inc.
+0007A7 A-Z Inc.
+0007A8 Haier Group Technologies Ltd.
+0007A9 Novasonics
+0007AA Quantum Data Inc.
+0007AC Eolring
+0007AD Pentacon GmbH Foto-und Feinwerktechnik
+0007AE Layer N Networks
+0007AF N-Tron Corp.
+0007B0 Office Details, Inc.
+0007B1 Equator Technologies
+0007B2 Transaccess S.A.
+0007B3 Cisco Systems Inc.
+0007B4 Cisco Systems Inc.
+0007B5 Any One Wireless Ltd.
+0007B6 Telecom Technology Ltd.
+0007B7 Samurai Ind. Prods Eletronicos Ltda
+0007B8 American Predator Corp.
+0007B9 Ginganet Corporation
+0007BA Xebeo Communications, Inc.
+0007BB Candera Inc.
+0007BC Identix Inc.
+0007BD Radionet Ltd.
+0007BE DataLogic SpA
+0007BF Armillaire Technologies, Inc.
+0007C0 NetZerver Inc.
+0007C1 Overture Networks, Inc.
+0007C2 Netsys Telecom
+0007C3 Cirpack
+0007C4 JEAN Co. Ltd.
+0007C5 Gcom, Inc.
+0007C6 VDS Vosskuhler GmbH
+0007C7 Synectics Systems Limited
+0007C8 Brain21, Inc.
+0007C9 Technol Seven Co., Ltd.
+0007CA Creatix Polymedia Ges Fur Kommunikaitonssysteme
+0007CB Freebox SA
+0007CC Kaba Benzing GmbH
+0007CD NMTEL Co., Ltd.
+0007CE Cabletime Limited
+0007CF Anoto AB
+0007D0 Automat Engenharia de Automaoa Ltda.
+0007D1 Spectrum Signal Processing Inc.
+0007D2 Logopak Systeme
+0007D3 Stork Digital Imaging B.V.
+0007D4 Zhejiang Yutong Network Communication Co Ltd.
+0007D5 3e Technologies Int;., Inc.
+0007D6 Commil Ltd.
+0007D7 Caporis Networks AG
+0007D8 Hitron Systems Inc.
+0007D9 Splicecom
+0007DA Neuro Telecom Co., Ltd.
+0007DB Kirana Networks, Inc.
+0007DC Atek Co, Ltd.
+0007DD Cradle Technologies
+0007DE eCopilt AB
+0007DF Vbrick Systems Inc.
+0007E0 Palm Inc.
+0007E1 WIS Communications Co. Ltd.
+0007E2 Bitworks, Inc.
+0007E3 Navcom Technology, Inc.
+0007E4 SoftRadio Co., Ltd.
+0007E5 Coup Corporation
+0007E6 edgeflow Canada Inc.
+0007E7 FreeWave Technologies
+0007E8 St. Bernard Software
+0007E9 Intel Corporation
+0007EA Massana, Inc.
+0007EB Cisco Systems Inc.
+0007EC Cisco Systems Inc.
+0007ED Altera Corporation
+0007EE telco Informationssysteme GmbH
+0007EF Lockheed Martin Tactical Systems
+0007F0 LogiSync Corporation
+0007F1 TeraBurst Networks Inc.
+0007F2 IOA Corporation
+0007F3 Think Engine Networks
+0007F4 Eletex Co., Ltd.
+0007F5 Bridgeco Co AG
+0007F6 Qqest Software Systems
+0007F7 Galtronics
+0007F8 ITDevices, Inc.
+0007F9 Phonetics, Inc.
+0007FA ITT Co., Ltd.
+0007FB Giga Stream UMTS Technologies GmbH
+0007FC Adept Systems Inc.
+0007FD LANergy Ltd.
+0007FE Rigaku Corporation
+0007FF Gluon Networks
 000800 MULTITECH SYSTEMS, INC.
+000801 HighSpeed Surfing Inc.
+000802 Compaq Computer Corporation
+000803 Cos Tron
+000804 ICA Inc.
+000805 Techno-Holon Corporation
+000806 Raonet Systems, Inc.
+000807 Access Devices Limited
+000808 PPT Vision, Inc.
+000809 Systemonic AG
+00080A Espera-Werke GmbH
+00080B Birka BPA Informationssystem AB
+00080C VDA elettronica SrL
+00080D Toshiba
+00080E Motorola, BCS
+00080F Proximion Fiber Optics AB
+000810 Key Technology, Inc.
+000811 VOIX Corporation
+000812 GM-2 Corporation
+000813 Diskbank, Inc.
+000814 TIL Technologies
+000815 CATS Co., Ltd.
+000816 Bluetags A/S
+000817 EmergeCore Networks LLC
+000818 Pixelworks, Inc.
+000819 Banksys
+00081A Sanrad Intelligence Storage Communications (2000) Ltd.
+00081B Windigo Systems
+00081C @pos.com
+00081D Ipsil, Incorporated
+00081E Repeatit AB
+00081F Pou Yuen Tech Corp. Ltd.
+000820 Cisco Systems Inc.
+000821 Cisco Systems Inc.
+000822 InPro Comm
+000823 Texa Corp.
+000824 Promatek Industries Ltd.
+000825 Acme Packet
+000826 Colorado Med Tech
+000827 Pirelli Cables & Systems
+000828 Koei Engineering Ltd.
+000829 Aval Nagasaki Corporation
+00082A Powerwallz Network Security
+00082B Wooksung Electronics, Inc.
+00082C Homag AG
+00082D Indus Teqsite Private Limited
+00082E Multitone Electronics PLC
+00084E DivergeNet, Inc.
+00084F Qualstar Corporation
+000850 Arizona Instrument Corp.
+000851 Canadian Bank Note Company, Ltd.
+000852 Davolink Co. Inc.
+000853 Schleicher GmbH & Co. Relaiswerke KG
+000854 Netronix, Inc.
+000855 NASA-Goddard Space Flight Center
+000856 Gamatronic Electronic Industries Ltd.
+000857 Polaris Networks, Inc.
+000858 Novatechnology Inc.
+000859 ShenZhen Unitone Electronics Co., Ltd.
+00085A IntiGate Inc.
+00085B Hanbit Electronics Co., Ltd.
+00085C Shanghai Dare Technologies Co. Ltd.
+00085D Aastra
+00085E PCO AG
+00085F Picanol N.V.
+000860 LodgeNet Entertainment Corp.
+000861 SoftEnergy Co., Ltd.
+000862 NEC Eluminant Technologies, Inc.
+000863 Entrisphere Inc.
+000864 Fasy S.p.A.
+000865 JASCOM CO., LTD
+000866 DSX Access Systems, Inc.
+000867 Uptime Devices
+000868 PurOptix
+000869 Command-e Technology Co.,Ltd.
+00086A Industrie Technik IPS GmbH
+00086B MIPSYS
+00086C Plasmon LMS
+00086D Missouri FreeNet
+00086E Hyglo AB
+00086F Resources Computer Network Ltd.
+000870 Rasvia Systems, Inc.
+000871 NORTHDATA Co., Ltd.
+000872 Sorenson Technologies, Inc.
+000873 DAP Design B.V.
+000874 Dell Computer Corp.
+000875 Acorp Electronics Corp.
+000876 SDSystem
+000877 Liebert HIROSS S.p.A.
+000878 Benchmark Storage Innovations
+000879 CEM Corporation
+00087A Wipotec GmbH
+00087B RTX Telecom A/S
+00087C Cisco Systems, Inc.
+00087D Cisco Systems Inc.
+00087E Bon Electro-Telecom Inc.
+00087F SPAUN electronic GmbH & Co. KG
+000880 BroadTel Canada Communications inc.
+000881 DIGITAL HANDS CO.,LTD.
+000882 SIGMA CORPORATION
+000883 Hewlett-Packard Company
+000884 Index Braille AB
+000885 EMS Dr. Thomas Wuensche
+000886 Hansung Teliann, Inc.
+000887 Maschinenfabrik Reinhausen GmbH
+000888 OULLIM Information Technology Inc,.
+000889 Echostar Technologies Corp
+00088A Minds@Work
+00088B Tropic Networks Inc.
+00088C Quanta Network Systems Inc.
+00088D Sigma-Links Inc.
+00088E Nihon Computer Co., Ltd.
+00088F ADVANCED DIGITAL TECHNOLOGY
+000890 AVILINKS SA
+000891 Lyan Inc.
+000892 EM Solutions
+000894 InnoVISION Multimedia Ltd.
+000895 DIRC Technologie GmbH & Co.KG
+000896 Printronix, Inc.
+000897 Quake Technologies
+000898 Gigabit Optics Corporation
+000899 Netbind, Inc.
+00089A Alcatel Microelectronics
+00089B ICP Electronics Inc.
+00089C Elecs Industry Co., Ltd.
+00089D UHD-Elektronik
+00089E Beijing Enter-Net co.LTD
+00089F EFM Networks
+0008A0 Stotz Feinmesstechnik GmbH
+0008A1 CNet Technology Inc.
+0008A2 ADI Engineering, Inc.
+0008A3 Cisco Systems
+0008A4 Cisco Systems
+0008A5 Peninsula Systems Inc.
+0008A6 Multiware & Image Co., Ltd.
+0008A7 iLogic Inc.
+0008A8 Systec Co., Ltd.
+0008A9 SangSang Technology, Inc.
+0008AA KARAM
+0008AB EnerLinx.com, Inc.
+0008AD Toyo-Linx Co., Ltd.
+0008AE Packetfront
+0008AF Novatec Corporation
+0008B0 BKtel communications GmbH
+0008B1 ProQuent Systems
+0008B2 SHENZHEN COMPASS TECHNOLOGY DEVELOPMENT CO.,LTD
+0008B3 Fastwel
+0008B4 SYSPOL
+0008B5 TAI GUEN ENTERPRISE CO., LTD
+0008B6 RouteFree, Inc.
+0008B7 HIT Incorporated
+0008B8 E.F. Johnson
+0008B9 KAON MEDIA Co., Ltd.
+0008BA Erskine Systems Ltd
+0008BB NetExcell
+0008BC Ilevo AB
+0008BD TEPG-US
+0008BE XENPAK MSA Group
+0008BF Aptus Elektronik AB
+0008C0 ASA SYSTEMS
+0008C1 Avistar Communications Corporation
+0008C2 Cisco Systems
+0008C3 Contex A/S
+0008C4 Hikari Co.,Ltd.
+0008C5 Liontech Co., Ltd.
+0008C6 Philips Consumer Communications
 0008C7 COMPAQ COMPUTER CORPORATION
+0008C8 Soneticom, Inc.
+0008C9 TechniSat Digital GmbH
+0008CA TwinHan Technology Co.,Ltd
+0008CB Zeta Broadband Inc.
+0008CC Remotec, Inc.
+0008CD With-Net Inc
+0008CF Nippon Koei Power Systems Co., Ltd.
+0008D0 Musashi Engineering Co., LTD.
+0008D1 KAREL INC.
+0008D2 ZOOM Networks Inc.
+0008D3 Hercules Technologies S.A.
+0008D4 IneoQuest Technologies, Inc
+0008D5 Vanguard Managed Solutions
+0008D6 HASSNET Inc.
+0008D7 HOW CORPORATION
+0008D8 Dowkey Microwave
+0008D9 Mitadenshi Co.,LTD
+0008DA SofaWare Technologies Ltd.
+0008DB Corrigent Systems
+0008DC Wiznet
+0008DD Telena Communications, Inc.
+0008DE 3UP Systems
+0008DF Alistel Inc.
+0008E0 ATO Technology Ltd.
+0008E1 Barix AG
+0008E2 Cisco Systems
+0008E3 Cisco Systems
+0008E4 Envenergy Inc
+0008E5 IDK Corporation
+0008E6 Littlefeet
+0008E7 SHI ControlSystems,Ltd.
+0008E8 Excel Master Ltd.
+0008E9 NextGig
+0008EA Motion Control Engineering, Inc
+0008EB ROMWin Co.,Ltd.
+0008EC Zonu, Inc.
+0008ED ST&T Instrument Corp.
+0008EE Logic Product Development
+0008EF DIBAL,S.A.
+0008F0 Next Generation Systems, Inc.
+0008F1 Voltaire
+0008F2 C&S Technology
+0008F3 WANY
+0008F4 Bluetake Technology Co., Ltd.
+0008F5 YESTECHNOLOGY Co.,Ltd.
+0008F6 SUMITOMO ELECTRIC HIGHTECHS.co.,ltd.
+0008F7 Hitachi Ltd, Semiconductor &amp; Integrated Circuits Gr
+0008F8 Guardall Ltd
+0008F9 Padcom, Inc.
+0008FA Karl E.Brinkmann GmbH
+0008FB SonoSite, Inc.
+0008FC Gigaphoton Inc.
+0008FD BlueKorea Co., Ltd.
+0008FE UNIK C&C Co.,Ltd.
+0008FF Trilogy Broadcast (Holdings) Ltd
+000900 TMT
+000901 Shenzhen Shixuntong Information & Technoligy Co
+000902 Redline Communications Inc.
+000903 Panasas, Inc
+000904 MONDIAL electronic
+000905 iTEC Technologies Ltd.
+000906 Esteem Networks
+000907 Chrysalis Development
+000908 VTech Technology Corp.
+000909 Telenor Connect A/S
+00090A SnedFar Technology Co., Ltd.
+00090B MTL  Instruments PLC
+00090C Mayekawa Mfg. Co. Ltd.
+00090D LEADER ELECTRONICS CORP.
+00090E Helix Technology Inc.
+00090F Fortinet Inc.
+000910 Simple Access Inc.
+000911 Cisco Systems
+000912 Cisco Systems
+000914 COMPUTROLS INC.
+000915 CAS Corp.
+000916 Listman Home Technologies, Inc.
+000917 WEM Technology Inc
+000918 SAMSUNG TECHWIN CO.,LTD
+000919 MDS Gateways
+00091A Macat Optics & Electronics Co., Ltd.
+00091B Digital Generation Inc.
+00091C CacheVision, Inc
+00091D Proteam Computer Corporation
+00091E Firstech Technology Corp.
+00091F A&amp;D Co., Ltd.
+000920 EpoX COMPUTER CO.,LTD.
+000921 Planmeca Oy
+000922 Touchless Sensor Technology AG
+000923 Heaman System Co., Ltd
+000924 Telebau GmbH
+000925 VSN Systemen BV
+000926 YODA COMMUNICATIONS, INC.
+000927 TOYOKEIKI CO.,LTD.
+000928 Telecore Inc
+000929 Sanyo Industries (UK) Limited
+00092A MYTECS Co.,Ltd.
+00092B iQstor Networks, Inc.
+00092C Hitpoint Inc.
+00092D High Tech Computer, Corp.
+00092E B&Tech System Inc.
+00092F Akom Technology Corporation
+000930 AeroConcierge Inc.
+000931 Future Internet, Inc.
+000932 Omnilux
+000933 OPTOVALLEY Co. Ltd.
+000934 Dream-Multimedia-Tv GmbH
+000935 Sandvine Incorporated
+000936 Ipetronik GmbH & Co.KG
+000937 Inventec Appliance Corp
+000938 Allot Communications
+000939 ShibaSoku Co.,Ltd.
+00093A Molex Fiber Optics
+00093B HYUNDAI NETWORKS INC.
+00093C Jacques Technologies P/L
+00093D Newisys,Inc.
+00093E C&I Technologies
+00093F Double-Win Enterpirse CO., LTD
+000940 AGFEO GmbH & Co. KG
+000941 Allied Telesis K.K.
+000942 CRESCO, LTD.
+000943 Cisco Systems
+000944 Cisco Systems
+000945 Palmmicro Communications Inc
+000946 Cluster Labs GmbH
+000947 Aztek, Inc.
+000948 Vista Control Systems, Corp.
+000949 Glyph Technologies Inc.
+00094A Homenet Communications
+00094B FillFactory NV
+00094C Communication Weaver Co.,Ltd.
+00094D Braintree Communications Pty Ltd
+00094E BARTECH SYSTEMS INTERNATIONAL, INC
+00094F elmegt GmbH & Co. KG
+000950 Independent Storage Corporation
+000951 Apogee Instruments, Inc
+000952 Auerswald GmbH & Co. KG
+000953 Linkage System Integration Co.Ltd.
+000954 AMiT spol. s. r. o.
+000955 Young Generation International Corp.
+000956 Network Systems Group, Ltd. (NSG)
+000957 Supercaller, Inc.
+000958 INTELNET S.A.
+000959 Sitecsoft
+00095A RACEWOOD TECHNOLOGY
+00095B Netgear, Inc.
+00095C Philips Medical Systems - Cardiac and Monitoring Systems (CM
+00095D Dialogue Technology Corp.
+00095E Masstech Group Inc.
+00095F Telebyte, Inc.
+000960 YOZAN Inc.
+000961 Switchgear and Instrumentation Ltd
+000962 Filetrac AS
+000963 Dominion Lasercom Inc.
+000964 Hi-Techniques
+000966 Thales Navigation
+000967 Tachyon, Inc
+000968 TECHNOVENTURE, INC.
+000969 Meret Optical Communications
+00096A Cloverleaf Communications Inc.
+00096B IBM Corporation
+00096C Imedia Semiconductor Corp.
+00096D Powernet Technologies Corp.
+00096E GIANT ELECTRONICS LTD.
+00096F Beijing Zhongqing Elegant Tech. Corp.,Limited
+000970 Vibration Research Corporation
+000971 Time Management, Inc.
+000972 Securebase,Inc
+000973 Lenten Technology Co., Ltd.
+000974 Innopia Technologies, Inc.
+000975 fSONA Communications Corporation
+000976 Datasoft ISDN Systems GmbH
+000977 Brunner Elektronik AG
+000978 AIJI System Co., Ltd.
+000979 Advanced Television Systems Committee, Inc.
+00097A Louis Design Labs.
+00097B Cisco Systems
+00097C Cisco Systems
+00097D SecWell Networks Oy
+00097E IMI TECHNOLOGY CO., LTD
+00097F Vsecure 2000 LTD.
+000980 Power Zenith Inc.
+000981 Newport Networks
+000982 Loewe Opta GmbH
+000983 Gvision Incorporated
+000984 MyCasa Network Inc.
+000985 Auto Telecom Company
+000986 Metalink LTD.
+000987 NISHI NIPPON ELECTRIC WIRE & CABLE CO.,LTD.
+000988 Nudian Electron Co., Ltd.
+000989 VividLogic Inc.
+00098A EqualLogic Inc
+00098B Entropic Communications, Inc.
+00098C Possio AB
+00098D DCT Ltd (Digital Communication Technologies Ltd)
+00098E ipcas GmbH
+00098F Cetacean Networks
+000990 ACKSYS Communications & systems
+000991 GE Fanuc Automation Manufacturing, Inc.
+000992 InterEpoch Technology,INC.
+000993 Visteon Corporation
+000994 Cronyx Engineering
+000995 Castle Technology Ltd
+000996 RDI
+000997 Nortel Networks
+000998 Capinfo Company Limited
+000999 CP GEORGES RENAULT
+00099A ELMO COMPANY, LIMITED
+00099B Western Telematic Inc.
+00099C Naval Research Laboratory
+00099D Haliplex Communications
+00099E Testech, Inc.
+00099F VIDEX INC.
+0009A0 Microtechno Corporation
+0009A1 Telewise Communications, Inc.
+0009A2 Interface Co., Ltd.
+0009A3 Leadfly Techologies Corp. Ltd.
+0009A4 HARTEC Corporation
+0009A5 HANSUNG ELETRONIC INDUSTRIES DEVELOPMENT CO., LTD
+0009A6 Ignis Optics, Inc.
+0009A7 Bang & Olufsen A/S
+0009A8 Eastmode Pte Ltd
+0009A9 Ikanos Communications
+0009AA Data Comm for Business, Inc.
+0009AB Netcontrol Oy
+0009AC LANVOICE
+0009AD HYUNDAI SYSCOMM, INC.
+0009AE OKANO ELECTRIC CO.,LTD
+0009AF e-generis
+0009B0 Onkyo Corporation
+0009B1 Kanematsu Electronics, Ltd.
+0009B2 L&F Inc.
+0009B3 MCM Systems Ltd
+0009B4 KISAN TELECOM CO., LTD.
+0009B5 3J Tech. Co., Ltd.
+0009B6 Cisco Systems
+0009B7 Cisco Systems
+0009B8 Entise Systems
+0009B9 Action Imaging Solutions
+0009BA MAKU Informationstechik GmbH
+0009BB MathStar, Inc.
+0009BC Digital Safety Technologies Inc.
+0009BD Epygi Technologies, Ltd.
+0009BE Mamiya-OP Co.,Ltd.
+0009BF Nintendo Co.,Ltd.
+0009C0 6WIND
+0009C1 PROCES-DATA A/S
+0009C3 NETAS
+0009C4 Medicore Co., Ltd
+0009C5 KINGENE Technology Corporation
+0009C6 Visionics Corporation
+0009C7 Movistec
+0009C8 SINAGAWA TSUSHIN KEISOU SERVICE
+0009C9 BlueWINC Co., Ltd.
+0009CA iMaxNetworks(Shenzhen)Limited.
+0009CB HBrain
+0009CC Moog GmbH
+0009CD HUDSON SOFT CO.,LTD.
+0009CE SpaceBridge Semiconductor Corp.
+0009CF iAd GmbH
+0009D0 Versatel Networks
+0009D1 SERANOA NETWORKS INC
+0009D2 Mai Logic Inc.
+0009D3 Western DataCom Co., Inc.
+0009D4 Transtech Networks
+0009D5 Signal Communication, Inc.
+0009D6 KNC One GmbH
+0009D7 DC Security Products
+0009D9 Neoscale Systems, Inc
+0009DA Control Module Inc.
+0009DB eSpace
+0009DC Galaxis Technology AG
+0009DD Mavin Technology Inc.
+0009DE Samjin Information & Communications Co., Ltd.
+0009DF Vestel Komunikasyon Sanayi ve Ticaret A.S.
+0009E0 XEMICS S.A.
+0009E1 Gemtek Technology Co., Ltd.
+0009E2 Sinbon Electronics Co., Ltd.
+0009E3 Angel Iglesias S.A.
+0009E4 K Tech Infosystem Inc.
+0009E5 Hottinger Baldwin Messtechnik GmbH
+0009E6 Cyber Switching Inc.
+0009E7 ADC Techonology
+0009E8 Cisco Systems
+0009E9 Cisco Systems
+0009EA YEM Inc.
+0009EB HuMANDATA LTD.
+0009EC Daktronics, Inc.
+0009ED CipherOptics
+0009EE MEIKYO ELECTRIC CO.,LTD
+0009EF Vocera Communications
+0009F0 Shimizu Technology Inc.
+0009F1 Yamaki Electric Corporation
+0009F2 Cohu, Inc., Electronics Division
+0009F3 WELL Communication Corp.
+0009F4 Alcon Laboratories, Inc.
+0009F5 Emerson Network Power Co.,Ltd
+0009F6 Shenzhen Eastern Digital Tech Ltd.
+0009F7 SED, a division of Calian
+0009F8 UNIMO TECHNOLOGY CO., LTD.
+0009F9 ART JAPAN CO., LTD.
+0009FB Philips Medizinsysteme Boeblingen GmbH
+0009FC IPFLEX Inc.
+0009FD Ubinetics Limited
+0009FE Daisy Technologies, Inc.
+0009FF X.net 2000 GmbH
+000A00 Mediatek Corp.
+000A01 SOHOware, Inc.
+000A02 ANNSO CO., LTD.
+000A03 ENDESA SERVICIOS, S.L.
+000A04 3Com Europe Ltd
+000A05 Widax Corp.
+000A06 Teledex LLC
+000A07 WebWayOne Ltd
+000A08 ALPINE ELECTRONICS, INC.
+000A09 TaraCom Integrated Products, Inc.
+000A0A SUNIX Co., Ltd.
+000A0B Sealevel Systems, Inc.
+000A0C Scientific Research Corporation
+000A0D MergeOptics GmbH
+000A0E Invivo Research Inc.
+000A0F Ilryung Telesys, Inc
+000A10 FAST media integrations AG
+000A11 ExPet Technologies, Inc
+000A12 Azylex Technology, Inc
+000A13 Silent Witness
+000A14 TECO a.s.
+000A15 Silicon Data, Inc
+000A16 Lassen Research
+000A17 NESTAR COMMUNICATIONS, INC
+000A18 Vichel Inc.
+000A19 Valere Power, Inc.
+000A1A Imerge Ltd
+000A1B Stream Labs
+000A1C Bridge Information Co., Ltd.
+000A1D Optical Communications Products Inc.
+000A1E Red-M (Communications) Limited
+000A1F ART WARE Telecommunication Co., Ltd.
+000A20 SVA Networks, Inc.
+000A21 Integra Telecom Co. Ltd
+000A22 Amperion Inc
+000A23 Parama Networks Inc
+000A24 Octave Communications
+000A25 CERAGON NETWORKS
+000A26 CEIA S.p.A.
 000A27 Apple Computer, Inc.
-001000 CABLE TELEVISION
+000A28 Motorola
+000A29 Pan Dacom Networking AG
+000A2A QSI Systems Inc.
+000A2B Etherstuff
+000A2C Active Tchnology Corporation
+000A2E MAPLE NETWORKS CO., LTD
+000A2F Artnix Inc.
+000A30 Johnson Controls-ASG
+000A31 HCV Wireless
+000A32 Xsido Corporation
+000A33 Sierra Logic, Inc.
+000A34 Identicard Systems Incorporated
+000A35 Xilinx
+000A36 Synelec Telecom Multimedia
+000A37 Procera Networks, Inc.
+000A38 Netlock Technologies, Inc.
+000A39 LoPA Information Technology
+000A3A J-THREE INTERNATIONAL Holding Co., Ltd.
+000A3B GCT Semiconductor, Inc
+000A3C Enerpoint Ltd.
+000A3D Elo Sistemas Eletronicos S.A.
+000A3E EADS Telecom
+000A3F Data East Corporation
+000A40 Crown Audio
+000A41 Cisco Systems
+000A42 Cisco Systems
+000A43 Chunghwa Telecom Co., Ltd.
+000A44 Avery Dennison Deutschland GmbH
+000A45 Audio-Technica Corp.
+000A46 ARO Controls SAS
+000A47 Allied Vision Technologies
+000A48 Albatron Technology
+000A49 Acopia Networks
+000A4A Targa Systems Ltd.
+000A4B DataPower Technology, Inc.
+000A4C Molecular Devices Corporation
+000A4D Noritz Corporation
+000A4E UNITEK Electronics INC.
+000A4F Brain Boxes Limited
+000A50 REMOTEK CORPORATION
+000A51 GyroSignal Technology Co., Ltd.
+000A52 Venitek Co. Ltd.
+000A53 Intronics, Incorporated
+000A54 Laguna Hills, Inc.
+000A55 MARKEM Corporation
+000A56 HITACHI Maxell Ltd.
+000A57 Hewlett-Packard Company - Standards
+000A58 Ingenieur-Buero Freyer & Siegel
+000A59 HW server
+000A5A GreenNET Technologies Co.,Ltd.
+000A5B Power-One as
+000A5C Carel s.p.a.
+000A5D PUC Founder (MSC) Berhad
+000A5E 3COM Corporation
+000A5F almedio inc.
+000A60 Autostar Technology Pte Ltd
+000A61 Cellinx Systems Inc.
+000A62 Crinis Networks, Inc.
+000A63 DHD GmbH
+000A64 Eracom Technologies
+000A65 GentechMedia.co.,ltd.
+000A66 MITSUBISHI ELECTRIC SYSTEM & SERVICE CO.,LTD.
+000A67 OngCorp
+000A68 SolarFlare Communications, Inc.
+000A69 SUNNY bell Technology Co., Ltd.
+000A6A SVM Microwaves s.r.o.
+000A6B Tadiran Telecom Business Systems LTD
+000A6C Walchem Corporation
+000A6D EKS Elektronikservice GmbH
+000A6E Broadcast Technology Limited
+000A6F ZyTera Technologies Inc.
+000A70 MPLS Forum
+000A71 Avrio Technologies, Inc
+000A72 SimpleTech, Inc.
+000A73 Scientific Atlanta
+000A74 Manticom Networks Inc.
+000A75 Cat Electronics
+000A76 Beida Jade Bird Huaguang Technology Co.,Ltd
+000A77 Bluewire Technologies LLC
+000A78 OLITEC
+000A79 corega K.K.
+000A7A Kyoritsu Electric Co., Ltd.
+000A7B Cornelius Consult
+000A7C Tecton Ltd
+000A7D Valo, Inc.
+000A7E The Advantage Group
+000A7F Teradon Industries, Inc
+000A80 Telkonet Inc.
+000A81 TEIMA Audiotex S.L.
+000A82 TATSUTA SYSTEM ELECTRONICS CO.,LTD.
+000A83 SALTO SYSTEMS S.L.
+000A84 Rainsun Enterprise Co., Ltd.
+000A85 PLAT'C2,Inc
+000A86 Lenze
+000A87 Integrated Micromachines Inc.
+000A88 InCypher S.A.
+000A89 Creval Systems, Inc.
+000A8A Cisco Systems
+000A8B Cisco Systems
+000A8C Guardware Systems Ltd.
+000A8D EUROTHERM LIMITED
+000A8E Invacom Ltd
+000A8F Aska International Inc.
+000A90 Bayside Interactive, Inc.
+000A91 HemoCue AB
+000A92 Presonus Corporation
+000A93 W2 Networks, Inc.
+000A94 ShangHai cellink CO., LTD
+000A95 Apple Computer, Inc.
+000A96 MEWTEL TECHNOLOGY INC.
+000A97 SONICblue, Inc.
+000A98 M+F Gwinner GmbH & Co
+000A99 Dataradio Inc.
+000A9A Aiptek International Inc
+000A9B Towa Meccs Corporation
+000A9C Server Technology, Inc.
+000A9D King Young Technology Co. Ltd.
+000A9E BroadWeb Corportation
+000A9F Pannaway Technologies, Inc.
+000AA0 Cedar Point Communications
+000AA1 V V S Limited
+000AA2 SYSTEK INC.
+000AA3 SHIMAFUJI ELECTRIC CO.,LTD.
+000AA4 SHANGHAI SURVEILLANCE TECHNOLOGY CO,LTD
+000AA5 MAXLINK INDUSTRIES LIMITED
+000AA6 Hochiki Corporation
+000AA7 FEI Company
+000AA8 ePipe Pty. Ltd.
+000AA9 Brooks Automation GmbH
+000AAA AltiGen Communications Inc.
+000AAB TOYOTA MACS, INC.
+000AAC TerraTec Electronic GmbH
+000AAD Stargames Corporation
+000AAE Rosemount Process Analytical
+000AAF Pipal Systems
+000AB0 LOYTEC electronics GmbH
+000AB1 GENETEC Corporation
+000AB2 Fresnel Wireless Systems
+000AB3 Fa. GIRA
+000AB4 ETIC Telecommunications
+000AB5 Digital Electronic Network
+000AB6 COMPUNETIX, INC
+000AB7 Cisco Systems
+000AB8 Cisco Systems
+000AB9 Astera Technologies Corp.
+000ABA Arcon Technology Limited
+000ABB Taiwan Secom Co,. Ltd
+000ABC Seabridge Ltd.
+000ABD Rupprecht & Patashnick Co.
+000ABE OPNET Technologies CO., LTD.
+000ABF HIROTA SS
+000AC0 Fuyoh Video Industry CO., LTD.
+000AC1 Futuretel
+000AC2 FiberHome Telecommunication Technologies CO.,LTD
+000AC3 eM Technics Co., Ltd.
+000AC4 Daewoo Teletech Co., Ltd
+000AC5 Color Kinetics
+000AC7 Unication Group
+000AC8 ZPSYS CO.,LTD. (Planning&Management)
+000AC9 Zambeel Inc
+000ACA YOKOYAMA SHOKAI CO.,Ltd.
+000ACB XPAK MSA Group
+000ACC Winnow Networks, Inc.
+000ACD Sunrich Technology Limited
+000ACE RADIANTECH, INC.
+000ACF PROVIDEO Multimedia Co. Ltd.
+000AD0 Niigata Develoment Center,  F.I.T. Co., Ltd.
+000AD1 MWS
+000AD2 JEPICO Corporation
+000AD3 INITECH Co., Ltd
+000AD4 CoreBell Systems Inc.
+000AD5 Brainchild Electronic Co., Ltd.
+000AD6 BeamReach Networks
+000AD8 IPCserv Technology Corp.
+000AD9 Sony Ericsson Mobile Communications AB
+000ADB SkyPilot Network, Inc
+000ADC RuggedCom Inc.
+000ADD InSciTek Microsystems, Inc.
+000ADE Happy Communication Co., Ltd.
+000ADF Gennum Corporation
+000AE0 Fujitsu Softek
+000AE1 EG Technology
+000AE2 Binatone Electronics International, Ltd
+000AE3 YANG MEI TECHNOLOGY CO., LTD
+000AE4 Wistron Corp.
+000AE5 ScottCare Corporation
+000AE6 Elitegroup Computer System Co. (ECS)
+000AE7 ELIOP S.A.
+000AE8 Cathay Roxus Information Technology Co. LTD
+000AE9 AirVast Technology Inc.
+000AEA ADAM ELEKTRONIK LTD.STI.
+000AEB Shenzhen Tp-link Technology Co; Ltd.
+000AEC Koatsu Gas Kogyo Co., Ltd.
+000AED HARTING Vending G.m.b.H. & CO KG
+000AEE GCD Hard- & Software GmbH
+000AEF OTRUM ASA
+000AF0 SHIN-OH ELECTRONICS CO., LTD. R&D
+000AF1 Clarity Design, Inc.
+000AF2 NeoAxiom Corp.
+000AF3 Cisco Systems
+000AF4 Cisco Systems
+000AF5 Airgo Networks, Inc.
+000AF6 Computer Process Controls
+000AF7 Broadcom Corp.
+000AF8 American Telecare Inc.
+000AFA Traverse Technologies Australia
+000AFB Ambri Limited
+000AFC Core Tec Communications, LLC
+000AFD Viking Electronic Services
+000AFE NovaPal Ltd
+000AFF Kilchherr Elektronik AG
+000B00 FUJIAN START COMPUTER EQUIPMENT CO.,LTD
+000B01 DAIICHI ELECTRONICS CO., LTD.
+000B02 Dallmeier electronic
+000B03 Taekwang Industrial Co., Ltd
+000B04 Volktek Corporation
+000B05 Pacific Broadband Networks
+000B06 Motorola BCS
+000B07 Voxpath Networks
+000B08 Pillar Data Systems
+000B09 Ifoundry Systems Singapore
+000B0A dBm Optics
+000B0B Corrent Corporation
+000B0C Agile Systems Inc.
+000B0D Air2U, Inc.
+000B0E Trapeze Networks
+000B0F Nyquist Industrial Control BV
+000B10 11wave Technonlogy Co.,Ltd
+000B11 HIMEJI ABC TRADING CO.,LTD.
+000B13 ZETRON INC
+000B14 ViewSonic Corporation
+000B15 Platypus Technology
+000B16 Communication Machinery Corporation
+000B17 MKS Instruments
+000B19 Vernier Networks, Inc.
+000B1A Teltone Corporation
+000B1B Systronix, Inc.
+000B1D LayerZero Power Systems, Inc.
+000B1E KAPPA opto-electronics GmbH
+000B1F I CON Computer Co.
+000B20 Hirata corporation
+000B21 G-Star Communications Inc.
+000B22 Environmental Systems and Services
+000B23 Efficient Networks, Inc.
+000B24 AirLogic
+000B25 Aeluros
+000B26 Wetek Corporation
+000B27 Scion Corporation
+000B28 Quatech Inc.
+000B29 LG Industrial Systems Co.,Ltd.
+000B2A HOWTEL Co., Ltd.
+000B2B HOSTNET CORPORATION
+000B2C Eiki Industrial Co. Ltd.
+000B2D Danfoss Inc.
+000B2E Cal-Comp Electronics (Thailand) Public Company Limited Taipe
+000B2F bplan GmbH
+000B30 Beijing Gongye Science & Technology Co.,Ltd
+000B31 Yantai ZhiYang Scientific and technology industry CO., LTD
+000B32 VORMETRIC, INC.
+000B33 Vivato
+000B34 ShangHai Broadband Technologies CO.LTD
+000B35 Quad Bit System co., Ltd.
+000B36 Productivity Systems, Inc.
+000B37 MANUFACTURE DES MONTRES ROLEX SA
+000B38 Knuerr AG
+000B39 Keisoku Giken Co.,Ltd.
+000B3A Fortel DTV, Inc.
+000B3B devolo AG
+000B3C Cygnal Integrated Products, Inc.
+000B3D CONTAL OK Ltd.
+000B3E BittWare, Inc
+000B3F Anthology Solutions Inc.
+000B40 OpNext Inc.
+000B41 Ing. Buero Dr. Beutlhauser
+000B42 commax Co., Ltd.
+000B43 Microscan Systems, Inc.
+000B44 Concord IDea Corp.
+000B45 Cisco
+000B46 Cisco
+000B47 Advanced Energy
+000B48 sofrel
+000B49 RF-Link System Inc.
+000B4A Visimetrics (UK) Ltd
+000B4B VISIOWAVE SA
+000B4C Clarion (M) Sdn Bhd
+000B4D Emuzed
+000B4E VertexRSI Antenna Products Division
+000B4F Verifone, INC.
+000B50 Oxygnet
+000B51 Micetek International Inc.
+000B52 JOYMAX ELECTRONICS CORP.
+000B53 INITIUM Co., Ltd.
+000B54 BiTMICRO Networks, Inc.
+000B55 ADInstruments
+000B56 Cybernetics
+000B57 Silicon Laboratories
+000B58 Astronautics C.A  LTD
+000B59 ScriptPro, LLC
+000B5A HyperEdge
+000B5B Rincon Research Corporation
+000B5C Newtech Co.,Ltd
+000B5D FUJITSU LIMITED
+000B5E ATMAVA Ltd
+000B5F Cisco Systems
+000B60 Cisco Systems
+000B61 Friedrich Lütze GmbH &Co.
+000B62 Ingenieurbüro Ingo Mohnen
+000B64 Kieback & Peter GmbH & Co KG
+000B65 Sy.A.C. srl
+000B66 Teralink Communications
+000B67 Topview Technology Corporation
+000B68 Addvalue Communications Pte Ltd
+000B69 Franke Finland Oy
+000B6A Asiarock Incorporation
+000B6B Wistron Neweb Corp.
+000B6C Sychip Inc.
+000B6D SOLECTRON JAPAN NAKANIIDA
+000B6E Neff Instrument Corp.
+000B6F Media Streaming Networks Inc
+000B70 Load Technology, Inc.
+000B71 Litchfield Communications Inc.
+000B72 Lawo AG
+000B73 Kodeos Communications
+000B74 Kingwave Technology Co., Ltd.
+000B75 Iosoft Ltd.
+000B76 ET&T Co. Ltd.
+000B77 Cogent Systems, Inc.
+000B78 TAIFATECH INC.
+000B79 X-COM, Inc.
+000B7B Test-Um Inc.
+000B7C Telex Communications
+000B7D SOLOMON EXTREME INTERNATIONAL LTD.
+000B7E SAGINOMIYA Seisakusho Inc.
+000B7F OmniWerks
+000B81 Kaparel Corporation
+000B82 Grandstream Networks, Inc.
+000B83 DATAWATT B.V.
+000B84 BODET
+000B85 Airespace, Inc.
+000B86 Aruba Networks
+000B87 American Reliance Inc.
+000B88 Vidisco ltd.
+000B89 Top Global Technology, Ltd.
+000B8A MITEQ Inc.
+000B8B KERAJET, S.A.
+000B8C flextronics israel
+000B8D Avvio Networks
+000B8E Ascent Corporation
+000B8F AKITA ELECTRONICS SYSTEMS CO.,LTD.
+000B90 Covaro Networks, Inc.
+000B91 Aglaia Gesellschaft für Bildverarbeitung und Kommunikation m
+000B92 Ascom Danmark A/S
+000B93 Barmag Electronic
+000B94 Digital Monitoring Products, Inc.
+000B95 eBet Gaming Systems Pty Ltd
+000B96 Innotrac Diagnostics Oy
+000B97 Matsushita Electric Industrial Co.,Ltd.
+000B98 NiceTechVision
+000B99 SensAble Technologies, Inc.
+000B9A Shanghai Ulink Telecom Equipment Co. Ltd.
+000B9B Sirius System Co, Ltd.
+000B9C TriBeam Technologies, Inc.
+000B9D TwinMOS Technologies Inc.
+000B9E Yasing Technology Corp.
+000B9F Neue ELSA GmbH
+000BA0 T&L Information Inc.
+000BA1 SYSCOM Ltd.
+000BA2 Sumitomo Electric Networks, Inc
+000BA3 Siemens AG, I&S
+000BA4 Shiron Satellite Communications Ltd. (1996)
+000BA5 Quasar Cipta Mandiri, PT
+000BA6 Miyakawa Electric Works Ltd.
+000BA7 Maranti Networks
+000BA8 HANBACK ELECTRONICS CO., LTD.
+000BAA Aiphone co.,Ltd
+000BAB Advantech Technology (CHINA) Co., Ltd.
+000BAC 3Com Europe Ltd.
+000BAD PC-PoS Inc.
+000BAE Vitals System Inc.
+000BB0 Sysnet Telematica srl
+000BB1 Super Star Technology Co., Ltd.
+000BB2 SMALLBIG TECHNOLOGY
+000BB3 RiT technologies Ltd.
+000BB4 RDC Semiconductor Inc.,
+000BB5 nStor Technologies, Inc.
+000BB6 Mototech Inc.
+000BB7 Micro Systems Co.,Ltd.
+000BB8 Kihoku Electronic Co.
+000BB9 Imsys AB
+000BBA Harmonic Broadband Access Networks
+000BBB Etin Systems Co., Ltd
+000BBC En Garde Systems, Inc.
+000BBD Connexionz Limited
+000BBE Cisco Systems
+000BBF Cisco Systems
+000BC0 China IWNComm Co., Ltd.
+000BC1 Bay Microsystems, Inc.
+000BC2 Corinex Communication Corp.
+000BC3 Multiplex, Inc.
+000BC4 BIOTRONIK GmbH & Co
+000BC5 SMC Networks, Inc.
+000BC6 ISAC, Inc.
+000BC7 ICET S.p.A.
+000BC8 AirFlow Networks
+000BC9 Electroline Equipment
+000BCA DATAVAN International Corporation
+000BCB Fagor Automation , S. Coop
+000BCC JUSAN, S.A.
+000BCD Compaq (HP)
+000BCE Free2move AB
+000BCF AGFA NDT INC.
+000BD0 XiMeta Technology Americas Inc.
+000BD1 Aeronix, Inc.
+000BD2 Remopro Technology Inc.
+000BD3 cd3o
+000BD4 Beijing Wise Technology & Science Development Co.Ltd
+000BD5 Nvergence, Inc.
+000BD6 Paxton Access Ltd
+000BD7 MBB Gelma GmbH
+000BD8 Industrial Scientific Corp.
+000BD9 General Hydrogen
+000BDA EyeCross Co.,Inc.
+000BDB Dell ESG PCBA Test
+000BDC AKCP
+000BDD TOHOKU RICOH Co., LTD.
+000BDF Shenzhen RouterD Networks Limited
+000BE0 SercoNet Ltd.
+000BE2 Lumenera Corporation
+000BE3 Key Stream Co., Ltd.
+000BE4 Hosiden Corporation
+000BE5 HIMS Korea Co., Ltd.
+000BE6 Datel Electronics
+000BE7 COMFLUX TECHNOLOGY INC.
+000BE8 AOIP
+000BEA Zultys Technologies
+000BEB Systegra AG
+000BEC NIPPON ELECTRIC INSTRUMENT, INC.
+000BED ELM Inc.
+000BEE inc.jet, Incorporated
+000BEF Code Corporation
+000BF0 MoTEX Products Co., Ltd.
+000BF1 LAP Laser Applikations
+000BF2 Chih-Kan Technology Co., Ltd.
+000BF3 BAE SYSTEMS
+000BF5 Shanghai Sibo Telecom Technology Co.,Ltd
+000BF6 Nitgen Co., Ltd
+000BF7 NIDEK CO.,LTD
+000BF8 Infinera
+000BF9 Gemstone communications, Inc.
+000BFB D-NET International Corporation
+000BFC Cisco Systems
+000BFD Cisco Systems
+000BFE CASTEL Broadband Limited
+000BFF Berkeley Camera Engineering
+000C00 BEB Industrie-Elektronik AG
+000C01 Abatron AG
+000C02 ABB Oy
+000C03 HDMI Licensing, LLC
+000C04 Tecnova
+000C05 RPA Reserch Co., Ltd.
+000C06 Nixvue Systems  Pte Ltd
+000C07 Iftest AG
+000C08 HUMEX Technologies Corp.
+000C09 Hitachi IE Systems Co., Ltd
+000C0A Guangdong Province Electronic Technology Research Institute
+000C0B Broadbus Technologies
+000C0C APPRO TECHNOLOGY INC.
+000C0D Communications & Power Industries / Satcom Division
+000C0E XtremeSpectrum, Inc.
+000C0F Techno-One Co., Ltd
+000C10 PNI Corporation
+000C11 NIPPON DEMPA CO.,LTD.
+000C12 Micro-Optronic-Messtechnik GmbH
+000C13 MediaQ
+000C14 Diagnostic Instruments, Inc.
+000C15 CyberPower Systems, Inc.
+000C16 Concorde Microsystems Inc.
+000C17 AJA Video Systems Inc
+000C18 Zenisu Keisoku Inc.
+000C19 Telio Communications GmbH
+000C1A Quest Technical Solutions Inc.
+000C1B ORACOM Co, Ltd.
+000C1C MicroWeb Co., Ltd.
+000C1D Mettler & Fuchs AG
+000C1E Global Cache
+000C1F Glimmerglass Networks
+000C20 Fi WIn, Inc.
+000C21 Faculty of Science and Technology, Keio University
+000C22 Double D Electronics Ltd
+000C23 Beijing Lanchuan Tech. Co., Ltd.
+000C25 Allied Telesyn Networks
+000C26 Weintek Labs. Inc.
+000C27 Sammy Corporation
+000C28 RIFATRON
+000C29 VMware, Inc.
+000C2A OCTTEL Communication Co., Ltd.
+000C2B ELIAS Technology, Inc.
+000C2C Enwiser Inc.
+000C2D FullWave Technology Co., Ltd.
+000C2E Openet information technology(shenzhen) Co., Ltd.
+000C2F SeorimTechnology Co.,Ltd.
+000C30 Cisco
+000C31 Cisco
+000C32 Avionic Design Development GmbH
+000C33 Compucase Enterprise Co. Ltd.
+000C34 Vixen Co., Ltd.
+000C35 KaVo Dental GmbH & Co. KG
+000C36 SHARP TAKAYA ELECTRONICS INDUSTRY CO.,LTD.
+000C37 Geomation, Inc.
+000C38 TelcoBridges Inc.
+000C39 Sentinel Wireless Inc.
+000C3A Oxance
+000C3B Orion Electric Co., Ltd.
+000C3C MediaChorus, Inc.
+000C3D Glsystech Co., Ltd.
+000C3E Crest Audio
+000C3F Cogent Defence & Security Networks,
+000C40 Altech Controls
+000C41 The Linksys Group, Inc.
+000C42 Routerboard.com
+000C43 Ralink Technology, Corp.
+000C44 Automated Interfaces, Inc.
+000C45 Animation Technologies Inc.
+000C46 Allied Telesyn Inc.
+000C47 SK Teletech(R&D Planning Team)
+000C48 QoStek Corporation
+000C49 Dangaard Telecom RTC Division A/S
+000C4A Cygnus Microsystems Private Limited
+000C4B Cheops Elektronik
+000C4C Arcor AG&Co.
+000C4D ACRA CONTROL
+000C4E Winbest Technology CO,LT
+000C4F UDTech Japan Corporation
+000C50 Seagate Technology
+000C51 Scientific Technologies Inc.
+000C52 Roll Systems Inc.
+000C54 Pedestal Networks, Inc
+000C55 Microlink Communications Inc.
+000C56 Megatel Computer (1986) Corp.
+000C57 MACKIE Engineering Services Belgium BVBA
+000C58 M&S Systems
+000C59 Indyme Electronics, Inc.
+000C5A IBSmm Industrieelektronik Multimedia
+000C5B HANWANG TECHNOLOGY CO.,LTD
+000C5C GTN Systems B.V.
+000C5D CHIC TECHNOLOGY (CHINA) CORP.
+000C5F Avtec, Inc.
+000C60 ACM Systems
+000C61 AC Tech corporation DBA Advanced Digital
+000C62 ABB Automation Technology Products AB, Control
+000C63 Zenith Electronics Corporation
+000C64 X2 MSA Group
+000C65 Sunin Telecom
+000C66 Pronto Networks Inc
+000C67 OYO ELECTRIC CO.,LTD
+000C68 Oasis Semiconductor, Inc.
+000C69 National Radio Astronomy Observatory
+000C6A MBARI
+000C6B Kurz Industrie-Elektronik GmbH
+000C6C Elgato Systems LLC
+000C6D BOC Edwards
+000C6E ASUSTEK COMPUTER INC.
+000C6F Amtek system co.,LTD.
+000C70 ACC GmbH
+000C71 Wybron, Inc
+000C72 Tempearl Industrial Co., Ltd.
+000C73 TELSON ELECTRONICS CO., LTD
+000C74 RIVERTEC CORPORATION
+000C75 Oriental integrated electronics. LTD
+000C76 MICRO-STAR INTERNATIONAL CO., LTD.
+000C77 Life Racing Ltd
+000C78 In-Tech Electronics Limited
+000C79 Extel Communications P/L
+000C7A DaTARIUS Technologies GmbH
+000C7B ALPHA PROJECT Co.,Ltd.
+000C7C Internet Information Image Inc.
+000C7D TEIKOKU ELECTRIC MFG. CO., LTD
+000C7E Tellium Incorporated
+000C7F synertronixx GmbH
+000C80 Opelcomm Inc.
+000C81 Nulec Industries Pty Ltd
+000C82 NETWORK TECHNOLOGIES INC
+000C83 Logical Solutions
+000C84 Eazix, Inc.
+000C85 Cisco Systems
+000C86 Cisco Systems
+000C87 ATI
+000C88 Apache Micro Peripherals, Inc.
+000C89 AC Electric Vehicles, Ltd.
+000C8A Bose Corporation
+000C8B Connect Tech Inc
+000C8C KODICOM CO.,LTD.
+000C8D MATRIX VISION GmbH
+000C8E Mentor Engineering Inc
+000C8F Nergal s.r.l.
+000C90 Octasic Inc.
+000C91 Riverhead Networks Inc.
+000C92 WolfVision Gmbh
+000C93 Xeline Co., Ltd.
+000C94 United Electronic Industries, Inc.
+000C95 PrimeNet
+000C96 OQO, Inc.
+000C97 NV ADB TTV Technologies SA
+000C98 LETEK Communications Inc.
+000C99 HITEL LINK Co.,Ltd
+000C9A Hitech Electronics Corp.
+000C9B EE Solutions, Inc
+000C9C Chongho information & communications
+000C9D AirWalk Communications, Inc.
+000C9E MemoryLink Corp.
+000C9F NKE Corporation
+000CA0 StorCase Technology, Inc.
+000CA1 SIGMACOM Co., LTD.
+000CA2 Scopus Network Technologies Ltd
+000CA3 Rancho Technology, Inc.
+000CA4 Prompttec Product Management GmbH
+000CA6 Mintera Corporation
+000CA7 Metro (Suzhou) Technologies Co., Ltd.
+000CA8 Garuda Networks Corporation
+000CA9 Ebtron Inc.
+000CAA Cubic Transportation Systems Inc
+000CAB COMMEND International
+000CAC Citizen Watch Co., Ltd.
+000CAD BTU International
+000CAE Ailocom Oy
+000CAF TRI TERM CO.,LTD.
+000CB0 Star Semiconductor Corporation
+000CB1 Salland Engineering (Europe) BV
+000CB2 safei Co., Ltd.
+000CB3 ROUND Co.,Ltd.
+000CB4 Propagate Networks, Inc
+000CB5 Premier Technolgies, Inc
+000CB6 NANJING SEU MOBILE & INTERNET TECHNOLOGY CO.,LTD
+000CB7 Nanjing Huazhuo Electronics Co., Ltd.
+000CB8 MEDION AG
+000CB9 LEA
+000CBA Jamex
+000CBB ISKRAEMECO
+000CBC Iscutum
+000CBD Interface Masters, Inc
+000CBF Holy Stone Ent. Co., Ltd.
+000CC0 Genera Oy
+000CC1 Cooper Industries Inc.
+000CC3 BeWAN systems
+000CC4 Tiptel AG
+000CC5 Nextlink Co., Ltd.
+000CC6 Ka-Ro electronics GmbH
+000CC7 Intelligent Computer Solutions Inc.
+000CC8 Integrated Digital Systems, Inc.
+000CC9 ILWOO DATA & TECHNOLOGY CO.,LTD
+000CCA Hitachi Global Storage Technologies
+000CCB Design Combus Ltd
+000CCC Bluesoft Ltd.
+000CCD IEC - TC57
+000CCE Cisco Systems
+000CCF Cisco Systems
+000CD0 Symetrix
+000CD1 SFOM Technology Corp.
+000CD2 Schaffner EMV AG
+000CD3 Prettl Elektronik Radeberg GmbH
+000CD4 Positron Public Safety Systems inc.
+000CD5 Passave Inc.
+000CD6 PARTNER TECH
+000CD7 Nallatech Ltd
+000CD8 M. K. Juchheim GmbH & Co
+000CD9 Itcare Co., Ltd
+000CDA FreeHand Systems, Inc.
+000CDB Foundry Networks
+000CDC BECS Technology, Inc
+000CDD AOS Technologies AG
+000CDE ABB STOTZ-KONTAKT GmbH
+000CDF PULNiX America, Inc
+000CE0 Trek Diagnostics Inc.
+000CE1 The Open Group
+000CE2 Rolls-Royce
+000CE3 Option International N.V.
+000CE4 NeuroCom International, Inc.
+000CE5 Motorola BCS
+000CE6 Meru Networks Inc
+000CE7 MediaTek Inc.
+000CE8 GuangZhou AnJuBao Co., Ltd
+000CE9 BLOOMBERG L.P.
+000CEA aphona Kommunikationssysteme
+000CEB CNMP Networks, Inc.
+000CEC Spectracom Corp.
+000CED Real Digital Media
+000CEE Q-Networks
+000CEF Open Networks Engineering Ltd
+000CF0 M & N GmbH
+000CF1 Intel Corporation
+000CF2 GAMESA EÓLICA
+000CF3 CALL IMAGE SA
+000CF4 AKATSUKI ELECTRIC MFG.CO.,LTD.
+000CF5 InfoExpress
+000CF6 Sitecom Europe BV
+000CF7 Nortel Networks
+000CF8 Nortel Networks
+000CF9 ITT Flygt AB
+000CFA Digital Systems Corp
+000CFB Korea Network Systems
+000CFC S2io Technologies Corp
+000CFE Grand Electronic Co., Ltd
+000CFF MRO-TEK LIMITED
+000D00 Seaway Networks Inc.
+000D01 P&E Microcomputer Systems, Inc.
+000D02 NEC Access Technica,Ltd
+000D03 Matrics, Inc.
+000D04 Foxboro Eckardt Development GmbH
+000D05 cybernet manufacturing inc.
+000D06 Compulogic Limited
+000D07 Calrec Audio Ltd
+000D08 AboveCable, Inc.
+000D09 Yuehua(Zhuhai) Electronic CO. LTD
+000D0A Projectiondesign as
+000D0B Melco Inc.
+000D0C MDI Security Systems
+000D0D ITSupported, LLC
+000D0E Inqnet Systems, Inc.
+000D0F Finlux Ltd
+000D10 Embedtronics Oy
+000D11 DENTSPLY - Gendex
+000D12 AXELL Corporation
+000D13 Wilhelm Rutenbeck GmbH&Co.
+000D14 Vtech Innovation LP dba Advanced American Telephones
+000D15 Voipac s.r.o.
+000D16 UHS Systems Pty Ltd
+000D17 Turbo Networks Co.Ltd
+000D18 Sunitec Enterprise Co., Ltd.
+000D19 ROBE Show lighting
+000D1A Mustek System Inc.
+000D1B Kyoto Electronics Manufacturing Co., Ltd.
+000D1C I2E TELECOM
+000D1D HIGH-TEK HARNESS ENT. CO., LTD.
+000D1E Control Techniques
+000D1F AV Digital
+000D20 ASAHIKASEI TECHNOSYSTEM CO.,LTD.
+000D21 WISCORE Inc.
+000D22 Unitronics
+000D23 Smart Solution, Inc
+000D24 SENTEC E&E CO., LTD.
+000D25 SANDEN CORPORATION
+000D26 Primagraphics Limited
+000D27 MICROPLEX Printware AG
+000D28 Cisco
+000D29 Cisco
+000D2A Scanmatic AS
+000D2B Racal Instruments
+000D2C Patapsco Designs Ltd
+000D2D NCT Deutschland GmbH
+000D2E Matsushita Avionics Systems Corporation
+000D2F AIN Comm.Tech.Co., LTD
+000D30 IceFyre Semiconductor
+000D31 Compellent Technologies, Inc.
+000D32 DispenseSource, Inc.
+000D33 Prediwave Corp.
+000D34 Shell International Exploration and Production, Inc.
+000D35 PAC International Ltd
+000D36 Wu Han Routon Electronic Co., Ltd
+000D37 WIPLUG
+000D38 NISSIN INC.
+000D39 Network Electronics
+000D3A Microsoft Corp.
+000D3B Microelectronics Technology Inc.
+000D3C i.Tech Dynamic Ltd
+000D3E APLUX Communications Ltd.
+000D3F VXI Technology
+000D40 Verint Loronix Video Solutions
+000D41 Siemens AG ICM MP UC RD IT KLF1
+000D42 Newbest Development Limited
+000D43 DRS Tactical Systems Inc.
+000D45 Tottori SANYO Electric Co., Ltd.
+000D46 Eurotherm Drives, Ltd.
+000D47 Collex
+000D48 AEWIN Technologies Co., Ltd.
+000D49 Triton Systems of Delaware, Inc.
+000D4A Steag ETA-Optik
+000D4B Roku, LLC
+000D4C Outline Electronics Ltd.
+000D4D Ninelanes
+000D4E NDR Co.,LTD.
+000D4F Kenwood Corporation
+000D50 Galazar Networks
+000D51 DIVR Systems, Inc.
+000D52 Comart system
+000D53 Beijing 5w Communication Corp.
+000D54 3Com Europe Ltd
+000D55 SANYCOM Technology Co.,Ltd
+000D56 Dell PCBA Test
+000D57 Fujitsu I-Network Systems Limited.
+000D59 Amity Systems, Inc.
+000D5A Tiesse SpA
+000D5B Smart Empire Investments Limited
+000D5C Robert Bosch GmbH, VT-ATMO
+000D5D Raritan Computer, Inc
+000D5E NEC CustomTechnica, Ltd.
+000D5F Minds Inc
+000D60 IBM Corporation
+000D61 Giga-Byte Technology Co., Ltd.
+000D62 Funkwerk Dabendorf GmbH
+000D63 DENT Instruments, Inc.
+000D64 COMAG Handels AG
+000D65 Cisco Systems
+000D66 Cisco Systems
+000D67 BelAir Networks Inc.
+000D68 Vinci Systems, Inc.
+000D69 TMT&D Corporation
+000D6A Redwood Technologies LTD
+000D6B Mita-Teknik A/S
+000D6C M-Audio
+000D6D K-Tech Devices Corp.
+000D6E K-Patents Oy
+000D6F Ember Corporation
+000D70 Datamax Corporation
+000D71 boca systems
+000D72 2Wire, Inc
+000D73 Technical Support, Inc.
+000D74 Sand Network Systems, Inc.
+000D75 Kobian Pte Ltd - Taiwan Branch
+000D76 Hokuto Denshi Co,. Ltd.
+000D77 FalconStor Software
+000D78 Engineering & Security
+000D79 Dynamic Solutions Co,.Ltd.
+000D7A DiGATTO Asia Pacific Pte Ltd
+000D7B Consensys Computers Inc.
+000D7C Codian Ltd
+000D7D Afco Systems
+000D7E Axiowave Networks, Inc.
+000D7F MIDAS  COMMUNICATION TECHNOLOGIES PTE LTD ( Foreign Branch)
+000D80 Online Development Inc
+000D81 Pepperl+Fuchs GmbH
+000D82 PHS srl
+000D83 Sanmina-SCI Hungary  Ltd.
+000D84 Seodu Inchip, Inc.
+000D85 Tapwave, Inc.
+000D86 Huber + Suhner AG
+000D87 Elitegroup Computer System Co. (ECS)
+000D88 D-Link Corporation
+000D89 Bils Technology Inc
+000D8A Winners Electronics Co., Ltd.
+000D8B T&D Corporation
+000D8C Shanghai Wedone Digital Ltd. CO.
+000D8D ProLinx Communication Gateways, Inc.
+000D8E Koden Electronics Co., Ltd.
+000D8F King Tsushin Kogyo Co., LTD.
+000D90 Factum Electronics AB
+000D91 Eclipse (HQ Espana) S.L.
+000D92 Arima Communication Corporation
+000D93 Apple Computer
+000D94 AFAR Communications,Inc
+000D96 Vtera Technology Inc.
+000D97 Tropos Networks, Inc.
+000D98 S.W.A.C. Schmitt-Walter Automation Consult GmbH
+000D99 Orbital Sciences Corp.; Launch Systems Group
+000D9A INFOTEC LTD
+000D9C Elan GmbH & Co KG
+000D9D Hewlett Packard
+000D9E TOKUDEN OHIZUMI SEISAKUSYO Co.,Ltd.
+000D9F RF Micro Devices
+000DA0 NEDAP N.V.
+000DA1 MIRAE ITS Co.,LTD.
+000DA2 Infrant Technologies, Inc.
+000DA3 Emerging Technologies Limited
+000DA4 DOSCH & AMAND SYSTEMS AG
+000DA5 Fabric7 Systems, Inc
+000DA6 Universal Switching Corporation
+000DA8 Teletronics Technology Corporation
+000DA9 T.E.A.M. S.L.
+000DAA S.A.Tehnology co.,Ltd.
+000DAB Parker Hannifin GmbH Electromechanical Division Europe
+000DAC Japan CBM Corporation
+000DAD Dataprobe Inc
+000DAE SAMSUNG HEAVY INDUSTRIES CO., LTD.
+000DAF Plexus Corp (UK) Ltd
+000DB0 Olym-tech Co.,Ltd.
+000DB1 Japan Network Service Co., Ltd.
+000DB2 Ammasso, Inc.
+000DB3 SDO Communication Corperation
+000DB4 NETASQ
+000DB5 GLOBALSAT TECHNOLOGY CORPORATION
+000DB6 Teknovus, Inc.
+000DB7 SANKO ELECTRIC CO,.LTD
+000DB8 SCHILLER AG
+000DB9 PC Engines GmbH
+000DBA Océ Document Technologies GmbH
+000DBB Nippon Dentsu Co.,Ltd.
+000DBC Cisco Systems
+000DBD Cisco Systems
+000DBE Bel Fuse Europe Ltd.,UK
+000DBF TekTone Sound & Signal Mfg., Inc.
+000DC0 Spagat AS
+000DC1 SafeWeb Inc
+000DC3 First Communication, Inc.
+000DC4 Emcore Corporation
+000DC5 EchoStar International Corporation
+000DC6 DigiRose Technology Co., Ltd.
+000DC7 COSMIC ENGINEERING INC.
+000DC8 AirMagnet, Inc
+000DC9 THALES Elektronik Systeme GmbH
+000DCA Tait Electronics
+000DCB Petcomkorea Co., Ltd.
+000DCC NEOSMART Corp.
+000DCD GROUPE TXCOM
+000DCE Dynavac Technology Pte Ltd
+000DCF Cidra Corp.
+000DD0 TetraTec Instruments GmbH
+000DD1 Stryker Corporation
+000DD2 Simrad Optronics ASA
+000DD3 SAMWOO Telecommunication Co.,Ltd.
+000DD4 Revivio Inc.
+000DD5 O'RITE TECHNOLOGY CO.,LTD
+000DD7 Bright
+000DD8 BBN
+000DD9 Anton Paar GmbH
+000DDA ALLIED TELESIS K.K.
+000DDB AIRWAVE TECHNOLOGIES INC.
+000DDC VAC
+000DDD PROFÝLO TELRA ELEKTRONÝK SANAYÝ VE TÝCARET A.Þ.
+000DDE Joyteck Co., Ltd.
+000DDF Japan Image & Network Inc.
+000DE0 ICPDAS Co.,LTD
+000DE1 Control Products, Inc.
+000DE2 CMZ Sistemi Elettronici
+000DE3 AT Sweden AB
+000DE4 DIGINICS, Inc.
+000DE5 Samsung Thales
+000DE6 YOUNGBO ENGINEERING CO.,LTD
+000DE7 Snap-on OEM Group
+000DE8 Nasaco Electronics Pte. Ltd
+000DE9 Napatech Aps
+000DEA Kingtel Telecommunication Corp.
+000DEB CompXs Limited
+000DEC Cisco Systems
+000DED Cisco Systems
+000DEF Soc. Coop. Bilanciai
+000DF0 QCOM TECHNOLOGY INC.
+000DF1 IONIX INC.
+000DF3 Asmax Solutions
+000DF4 Watertek Co.
+000DF5 Teletronics International Inc.
+000DF6 Technology Thesaurus Corp.
+000DF7 Space Dynamics Lab
+000DF8 ORGA Kartensysteme GmbH
+000DF9 NDS Limited
+000DFA Micro Control Systems Ltd.
+000DFB Komax AG
+000DFC ITFOR Inc. resarch and development
+000DFD Huges Hi-Tech Inc.,
+000DFE Hauppauge Computer Works, Inc.
+000DFF CHENMING MOLD INDUSTRY CORP.
+000E01 ASIP Technologies Inc.
+000E02 Advantech AMT Inc.
+000E03 Aarohi Communications, Inc.
+000E05 WIRELESS MATRIX CORP.
+000E06 Team Simoco Ltd
+000E07 Sony Ericsson Mobile Communications AB
+000E08 Sipura Technology, Inc.
+000E09 Shenzhen Coship Software Co.,LTD.
+000E0B Netac Technology Co., Ltd.
+000E0C Intel Corporation
+000E0D HESCH Schröder GmbH
+000E0E ESA elettronica S.P.A.
+000E0F ERMME
+000E11 BDT Büro- und Datentechnik GmbH & Co. KG
+000E12 Adaptive Micro Systems Inc.
+000E13 Accu-Sort Systems inc.
+000E14 Visionary Solutions, Inc.
+000E15 Tadlys LTD
+000E16 SouthWing
+000E18 MyA Technology
+000E19 LogicaCMG Pty Ltd
+000E1B IAV GmbH
+000E1C Hach Company
+000E1F TCL Networks Equipment Co., Ltd.
+000E20 PalmSource, Inc.
+000E21 MTU Friedrichshafen GmbH
+000E23 Incipient, Inc.
+000E25 Hannae Technology Co., Ltd
+000E26 Gincom Technology Corp.
+000E27 Crere Networks, Inc.
+000E28 Dynamic Ratings P/L
+000E29 Shester Communications Inc
+000E2B Safari Technologies
+000E2C Netcodec co.
+000E2D Hyundai Digital Technology Co.,Ltd.
+000E2E Edimax Technology Co., Ltd.
+000E2F Disetronic Medical Systems AG
+000E30 AERAS Networks, Inc.
+000E31 Olympus BioSystems GmbH
+000E32 Kontron Medical
+000E33 Shuko Electronics Co.,Ltd
+000E34 NexxGenCity
+000E35 Intel Corp
+000E36 HEINESYS, Inc.
+000E37 Harms & Wende GmbH & Co.KG
+000E38 Cisco Systems
+000E39 Cisco Systems
+000E3A Cirrus Logic
+000E3B Hawking Technologies, Inc.
+000E3C TransAct Technoloiges Inc.
+000E3D Televic N.V.
+000E3E Sun Optronics Inc
+000E3F Soronti, Inc.
+000E40 Nortel Networks
+000E41 NIHON MECHATRONICS CO.,LTD.
+000E42 Motic Incoporation Ltd.
+000E43 G-Tek Electronics Sdn. Bhd.
+000E44 Digital 5, Inc.
+000E45 Beijing Newtry Electronic Technology Ltd
+000E46 Niigata Seimitsu Co.,Ltd.
+000E47 NCI System Co.,Ltd.
+000E48 Lipman TransAction Solutions
+000E49 Forsway Scandinavia AB
+000E4A Changchun Huayu WEBPAD Co.,LTD
+000E4B atrium c and i
+000E4C Bermai Inc.
+000E4D Numesa Inc.
+000E4E Waveplus Technology Co., Ltd.
+000E4F Trajet GmbH
+000E50 Thomson Multi Media
+000E51 tecna elettronica srl
+000E52 Optium Corporation
+000E53 AV TECH CORPORATION
+000E54 AlphaCell Wireless Ltd.
+000E55 AUVITRAN
+000E56 4G Systems GmbH
+000E57 Iworld Networking, Inc.
+000E58 Rincon Networks
+000E5A TELEFIELD inc.
+000E5B ParkerVision - Direct2Data
+000E5C Motorola BCS
+000E5D Com-X Networks
+000E5E Beijing Raisecom Science & Technology Development Co.,Ltd
+000E5F activ-net GmbH & Co. KG
+000E60 360SUN Digital Broadband Corporation
+000E61 MICROTROL LIMITED
+000E62 Nortel Networks
+000E63 Lemke Diagnostics GmbH
+000E64 Elphel, Inc
+000E65 TransCore
+000E66 Hitachi Advanced Digital, Inc.
+000E67 Eltis Microelectronics Ltd.
+000E68 E-TOP Network Technology Inc.
+000E69 China Electric Power Research Institute
+000E6A 3COM EUROPE LTD
+000E6B Janitza electronics GmbH
+000E6C Device Drivers Limited
+000E6D Murata Manufacturing Co., Ltd.
+000E6E MICRELEC  ELECTRONICS S.A
+000E6F IRIS Corporation Berhad
+000E70 in2 Networks
+000E71 Gemstar Technology Development Ltd.
+000E72 CTS electronics
+000E73 Tpack A/S
+000E74 Solar Telecom. Tech
+000E75 New York Air Brake Corp.
+000E76 GEMSOC INNOVISION INC.
+000E77 Decru, Inc.
+000E78 Amtelco
+000E79 Ample Communications Inc.
+000E7B Toshiba
+000E7D Electronics Line 3000 Ltd.
+000E7E Comprog Oy
+000E7F Hewlett Packard
+000E81 Instant802 Networks Inc.
+000E82 Commtech Wireless
+000E83 Cisco Systems
+000E84 Cisco Systems
+000E85 Catalyst Enterprises, Inc.
+000E86 Alcatel North America
+000E87 adp Gauselmann GmbH
+000E88 VIDEOTRON CORP.
+000E89 CLEMATIC
+000E8A Avara Technologies Pty. Ltd.
+000E8B Astarte Technology Co, Ltd.
+000E8C Siemens AG A&D ET
+000E8D Systems in Progress Holding GmbH
+000E8E SparkLAN Communications, Inc.
+000E8F Sercomm Corp.
+000E90 PONICO CORP.
+000E92 Millinet Co., Ltd.
+000E93 Milénio 3 Sistemas Electrónicos, Lda.
+000E94 Maas International BV
+000E95 Fujiya Denki Seisakusho Co.,Ltd.
+000E96 Cubic Defense Applications, Inc.
+000E97 Ultracker Technology CO., Inc
+000E98 Vitec CC, INC.
+000E99 Spectrum Digital, Inc
+000E9A BOE TECHNOLOGY GROUP CO.,LTD
+000E9C Pemstar
+000E9D Video Networks Ltd
+000E9E Topfield Co., Ltd
+000E9F TEMIC SDS GmbH
+000EA0 NetKlass Technology Inc.
+000EA1 Formosa Teletek Corporation
+000EA2 CyberGuard Corporation
+000EA3 CNCR-IT CO.,LTD,HangZhou P.R.CHINA
+000EA4 Certance Inc.
+000EA5 BLIP Systems
+000EA6 ASUSTEK COMPUTER INC.
+000EA7 Endace Inc Ltd.
+000EA8 United Technologists Europe Limited
+000EA9 Shanghai Xun Shi Communications Equipment Ltd. Co.
+000EAC MINTRON ENTERPRISE CO., LTD.
+000EAD Metanoia Technologies, Inc.
+000EAE GAWELL TECHNOLOGIES CORP.
+000EAF CASTEL
+000EB0 Solutions Radio BV
+000EB1 Newcotech,Ltd
+000EB2 Micro-Research Finland Oy
+000EB3 LeftHand Networks
+000EB4 GUANGZHOU GAOKE COMMUNICATIONS TECHNOLOGY CO.LTD.
+000EB5 Ecastle Electronics Co., Ltd.
+000EB6 Riverbed Technology, Inc.
+000EB7 Knovative, Inc.
+000EB8 Iiga co.,Ltd
+000EB9 HASHIMOTO Electronics Industry Co.,Ltd.
+000EBA HANMI SEMICONDUCTOR CO., LTD.
+000EBB Everbee Networks
+000EBC Cullmann GmbH
+000EBD Burdick, a Quinton Compny
+000EBE B&B Electronics Manufacturing Co.
+000EC0 Nortel Networks
+000EC1 MYNAH Technologies
+000EC2 Lowrance Electronics, Inc.
+000EC3 Logic Controls, Inc.
+000EC4 Iskra Transmission d.d.
+000EC6 ASIX ELECTRONICS CORP.
+000EC7 Appeal Telecom Co.,Ltd.
+000EC8 Zoran Corporation
+000EC9 YOKO Technology Corp.
+000ECB VineSys Technology
+000ECC Tableau
+000ECD SKOV A/S
+000ECE S.I.T.T.I. S.p.A.
+000ECF PROFIBUS Nutzerorganisation e.V.
+000ED0 Privaris, Inc.
+000ED1 Osaka Micro Computer.
+000ED2 Filtronic plc
+000ED3 Epicenter, Inc.
+000ED4 CRESITT INDUSTRIE
+000ED5 COPAN Systems Inc.
+000ED6 Cisco Systems
+000ED7 Cisco Systems
+000ED8 Aktino, Inc.
+000ED9 Aksys, Ltd.
+000EDA C-TECH UNITED CORP.
+000EDB XiNCOM Corp.
+000EDC Tellion INC.
+000EDD SHURE INCORPORATED
+000EDE REMEC, Inc.
+000EDF PLX Technology
+000EE0 Mcharge
+000EE1 ExtremeSpeed Inc.
+000EE2 Custom Engineering S.p.A.
+000EE3 Chiyu Technology Co.,Ltd
+000EE5 bitWallet, Inc.
+000EE6 Adimos Systems LTD
+000EE7 AAC ELECTRONICS CORP.
+000EE8 zioncom
+000EE9 WayTech Development, Inc.
+000EEA Shadong Luneng Jicheng Electronics,Co.,Ltd
+000EEB Sandmartin(zhong shan)Electronics Co.,Ltd
+000EEC Orban
+000EED Nokia Danmark A/S
+000EEE Muco Industrie BV
+000EF0 Festo AG & Co. KG
+000EF1 EZQUEST INC.
+000EF3 Smarthome
+000EF4 Shenzhen Kasda Digital Technology Co.,Ltd
+000EF5 iPAC Technology Co., Ltd.
+000EF6 E-TEN Information Systems Co., Ltd.
+000EF7 Vulcan Portals Inc
+000EF8 SBC ASI
+000EF9 REA Elektronik GmbH
+000EFA Optoway Technology Incorporation
+000EFB Macey Enterprises
+000EFC JTAG Technologies B.V.
+000EFD FUJI PHOTO OPTICAL CO., LTD.
+000EFE EndRun Technologies LLC
+000EFF Megasolution,Inc.
+000F00 Legra Systems, Inc.
+000F01 DIGITALKS INC
+000F02 Digicube Technology Co., Ltd
+000F03 COM&C CO., LTD
+000F04 cim-usa inc
+000F05 3B SYSTEM INC.
+000F06 Nortel Networks
+000F07 Mangrove Systems, Inc.
+000F08 Indagon Oy
+000F0B Kentima Technologies AB
+000F0C SYNCHRONIC ENGINEERING
+000F0D Hunt Electronic Co., Ltd.
+000F0E WaveSplitter Technologies, Inc.
+000F0F Real ID Technology Co., Ltd.
+000F10 RDM Corporation
+000F11 Prodrive B.V.
+000F12 Panasonic AVC Networks Germany GmbH
+000F13 Nisca corporation
+000F14 Mindray Co., Ltd.
+000F15 Kjaerulff1 A/S
+000F16 JAY HOW TECHNOLOGY CO.,
+000F17 Insta Elektro GmbH
+000F18 Industrial Control Systems
+000F19 Guidant Corporation
+000F1A Gaming Support B.V.
+000F1B Ego Systems Inc.
+000F1C DigitAll World Co., Ltd
+000F1D Cosmo Techs Co., Ltd.
+000F1E Chengdu KT Electric Co.of High & New Technology
+000F1F WW PCBA Test
+000F20 WW Ops
+000F21 Scientific Atlanta, Inc
+000F22 Helius, Inc.
+000F23 Cisco Systems
+000F24 Cisco Systems
+000F25 AimValley B.V.
+000F26 WorldAccxx  LLC
+000F27 TEAL Electronics, Inc.
+000F28 Itronix Corporation
+000F29 Augmentix Corporation
+000F2A Cableware Electronics
+000F2B GREENBELL SYSTEMS
+000F2C Uplogix, Inc.
+001000 CABLE TELEVISION LABORATORIES, INC.
 001001 MCK COMMUNICATIONS
 001002 ACTIA
 001003 IMATRON, INC.
 001004 THE BRANTLEY COILE COMPANY,INC
 001005 UEC COMMERCIAL
-001006 RACAL RECORDERS LTD.
+001006 Thales Contact Solutions Ltd.
 001007 CISCO SYSTEMS, INC.
 001008 VIENNA SYSTEMS CORPORATION
 001009 HORO QUARTZ
@@ -1673,20 +3787,20 @@
 001012 PROCESSOR SYSTEMS (I) PVT LTD
 001013 INDUSTRIAL COMPUTER SOURCE
 001014 CISCO SYSTEMS, INC.
-001015 OOMON INC.
+001015 OOmon Inc.
 001016 T.SQWARE
-001017 MICOS GMBH
+001017 MICOS GmbH
 001018 BROADCOM CORPORATION
-001019 SIRONA DENTAL SYSTEMS
-00101A PICTURETEL CORP.
+001019 SIRONA DENTAL SYSTEMS GmbH & Co. KG
+00101A PictureTel Corp.
 00101B CORNET TECHNOLOGY, INC.
 00101C OHM TECHNOLOGIES INTL, LLC
 00101D WINBOND ELECTRONICS CORP.
-00101E MATSUSHITA ELECTRONIC
+00101E MATSUSHITA ELECTRONIC INSTRUMENTS CORP.
 00101F CISCO SYSTEMS, INC.
 001020 WELCH ALLYN, DATA COLLECTION
 001021 ENCANTO NETWORKS, INC.
-001022 SATCOM MEDIA CORPORATION
+001022 SatCom Media Corporation
 001023 FLOWWISE NETWORKS, INC.
 001024 NAGOYA ELECTRIC WORKS CO., LTD
 001025 GRAYHILL INC.
@@ -1698,18 +3812,18 @@
 00102B UMAX DATA SYSTEMS, INC.
 00102C Lasat Networks A/S
 00102D HITACHI SOFTWARE ENGINEERING
-00102E NETWORK SYSTEMS & TECHNOLOGIES
+00102E NETWORK SYSTEMS & TECHNOLOGIES PVT. LTD.
 00102F CISCO SYSTEMS, INC.
-001030 WI-LAN, INC.
+001030 Wi-LAN, Inc.
 001031 OBJECTIVE COMMUNICATIONS, INC.
 001032 ALTA TECHNOLOGY
 001033 ACCESSLAN COMMUNICATIONS, INC.
-001034 GNP COMPUTERS
-001035 ELITEGROUP COMPUTER
+001034 GNP Computers
+001035 ELITEGROUP COMPUTER SYSTEMS CO., LTD
 001036 INTER-TEL INTEGRATED SYSTEMS
-001037 CYQ'VE TECHNOLOGY CO., LTD.
+001037 CYQ've Technology Co., Ltd.
 001038 MICRO RESEARCH INSTITUTE, INC.
-001039 VECTRON SYSTEMS GMBH
+001039 Vectron Systems AG
 00103A DIAMOND NETWORK TECH
 00103B HIPPI NETWORKING FORUM
 00103C IC ENSEMBLE, INC.
@@ -1718,9 +3832,9 @@
 00103F TOLLGRADE COMMUNICATIONS, INC.
 001040 INTERMEC CORPORATION
 001041 BRISTOL BABCOCK, INC.
-001042 ALACRITECH
+001042 AlacriTech
 001043 A2 CORPORATION
-001044 INNOLABS CORPORATION
+001044 InnoLabs Corporation
 001045 Nortel Networks
 001046 ALCORN MCBRIDE INC.
 001047 ECHO ELETRIC CO. LTD.
@@ -1740,12 +3854,12 @@
 001055 FUJITSU MICROELECTRONICS, INC.
 001056 SODICK CO., LTD.
 001057 Rebel.com, Inc.
-001058 ARROWPOINT COMMUNICATIONS,INC.
+001058 ArrowPoint Communications
 001059 DIABLO RESEARCH CO. LLC
 00105A 3COM CORPORATION
 00105B NET INSIGHT AB
 00105C QUANTUM DESIGNS (H.K.) LTD.
-00105D DRAGER, BUSINESS UNIT
+00105D Draeger Medical
 00105E HEKIMIAN LABORATORIES, INC.
 00105F IN-SNEC
 001060 BILLIONTON SYSTEMS, INC.
@@ -1760,7 +3874,7 @@
 001069 HELIOSS COMMUNICATIONS, INC.
 00106A DIGITAL MICROWAVE CORPORATION
 00106B SONUS NETWORKS, INC.
-00106C INFRATEC PLUS GMBH
+00106C INFRATEC PLUS GmbH
 00106D INTEGRITY COMMUNICATIONS, INC.
 00106E TADIRAN COM. LTD.
 00106F TRENTON TECHNOLOGY INC.
@@ -1770,15 +3884,15 @@
 001073 TECHNOBOX, INC.
 001074 ATEN INTERNATIONAL CO., LTD.
 001075 Maxtor Corporation
-001076 EUREM GMBH
+001076 EUREM GmbH
 001077 SAF DRIVE SYSTEMS, LTD.
 001078 NUERA COMMUNICATIONS, INC.
 001079 CISCO SYSTEMS, INC.
-00107A AMBICOM, INC.
+00107A AmbiCom, Inc.
 00107B CISCO SYSTEMS, INC.
 00107C P-COM, INC.
 00107D AURORA COMMUNICATIONS, LTD.
-00107E BACHMANN ELECTRONIC GMBH
+00107E BACHMANN ELECTRONIC GmbH
 00107F CRESTRON ELECTRONICS, INC.
 001080 METAWAVE COMMUNICATIONS
 001081 DPS, INC.
@@ -1789,23 +3903,23 @@
 001086 ATTO TECHNOLOGY, INC.
 001087 Xstreamis PLC
 001088 AMERICAN NETWORKS INC.
-001089 WEBSONIC
-00108A TERALOGIC, INC.
-00108B LASERANIMATION SOLLINGER GMBH
-00108C FUJITSU TELECOMMUNICATIONS
+001089 WebSonic
+00108A TeraLogic, Inc.
+00108B LASERANIMATION SOLLINGER GmbH
+00108C FUJITSU TELECOMMUNICATIONS EUROPE, LTD.
 00108D JOHNSON CONTROLS, INC.
-00108E HUGH SYMONS CONCEPT
+00108E HUGH SYMONS CONCEPT Technologies Ltd.
 00108F RAPTOR SYSTEMS
 001090 CIMETRICS, INC.
 001091 NO WIRES NEEDED BV
 001092 NETCORE INC.
 001093 CMS COMPUTERS, LTD.
-001094 ADTECH, INC.
-001095 THOMSON CONSUMER ELECTRONICS
+001094 Performance Analysis Broadband, Spirent plc
+001095 Thomson Multimedia, Inc.
 001096 TRACEWELL SYSTEMS, INC.
-001097 WINNET METROPOLITAN
+001097 WinNet Metropolitan Communications Systems, Inc.
 001098 STARNET TECHNOLOGIES, INC.
-001099 INNOMEDIA, INC.
+001099 InnoMedia, Inc.
 00109A NETLINE
 00109B VIXEL CORPORATION
 00109C M-SYSTEM CO., LTD.
@@ -1840,10 +3954,10 @@
 0010B9 MAXTOR CORP.
 0010BA MARTINHO-DAVIS SYSTEMS, INC.
 0010BB DATA & INFORMATION TECHNOLOGY
-0010BC Nortel Networks
-0010BD THE TELECOMMUNICATION
+0010BC Aastra Telecom
+0010BD THE TELECOMMUNICATION TECHNOLOGY COMMITTEE
 0010BE TELEXIS CORP.
-0010BF INTER AIR WIRELESS
+0010BF InterAir Wireless
 0010C0 ARMA, INC.
 0010C1 OI ELECTRIC CO., LTD.
 0010C2 WILLNET, INC.
@@ -1852,11 +3966,11 @@
 0010C5 PROTOCOL TECHNOLOGIES, INC.
 0010C6 USI
 0010C7 DATA TRANSMISSION NETWORK
-0010C8 COMMUNICATIONS ELECTRONICS
-0010C9 MITSUBISHI ELECTRONICS
+0010C8 COMMUNICATIONS ELECTRONICS SECURITY GROUP
+0010C9 MITSUBISHI ELECTRONICS LOGISTIC SUPPORT CO.
 0010CA INTEGRAL ACCESS
 0010CB FACIT K.K.
-0010CC CLP COMPUTER LOGISTIK
+0010CC CLP COMPUTER LOGISTIK PLANUNG GmbH
 0010CD INTERFACE CONCEPT
 0010CE VOLAMP, LTD.
 0010CF FIBERLANE COMMUNICATIONS
@@ -1866,40 +3980,39 @@
 0010D3 GRIPS ELECTRONIC GMBH
 0010D4 STORAGE COMPUTER CORPORATION
 0010D5 IMASDE CANARIAS, S.A.
-0010D6 ITT A/CD
+0010D6 ITT - A/CD
 0010D7 ARGOSY RESEARCH INC.
 0010D8 CALISTA
 0010D9 IBM JAPAN, FUJISAWA MT+D
 0010DA MOTION ENGINEERING, INC.
-0010DB NETSCREEN TECHNOLOGIES, INC.
-0010DC MICRO-STAR INTERNATIONAL
+0010DB NetScreen Technologies, Inc.
+0010DC MICRO-STAR INTERNATIONAL CO., LTD.
 0010DD ENABLE SEMICONDUCTOR, INC.
-0010DE INTERNATIONAL DATACASTING
+0010DE INTERNATIONAL DATACASTING CORPORATION
 0010DF RISE COMPUTER INC.
 0010E0 COBALT MICROSERVER, INC.
 0010E1 S.I. TECH, INC.
-0010E2 ARRAYCOMM, INC.
+0010E2 ArrayComm, Inc.
 0010E3 COMPAQ COMPUTER CORPORATION
 0010E4 NSI CORPORATION
 0010E5 SOLECTRON TEXAS
-0010E6 APPLIED INTELLIGENT
-0010E7 BREEZECOM
+0010E6 APPLIED INTELLIGENT SYSTEMS, INC.
+0010E7 BreezeCom
 0010E8 TELOCITY, INCORPORATED
 0010E9 RAIDTEC LTD.
 0010EA ADEPT TECHNOLOGY
-0010EB SELSIUS SYSTEMS, ILNC.
+0010EB SELSIUS SYSTEMS, INC.
 0010EC RPCG, LLC
 0010ED SUNDANCE TECHNOLOGY, INC.
 0010EE CTI PRODUCTS, INC.
-0010EF DB NETWORKS, INC.
-0010F0 RITTAL-WERK RUDOLF LOH
+0010EF DBTEL INCORPORATED
 0010F1 I-O CORPORATION
 0010F2 ANTEC
-0010F3 NEXCOM INTERNATIONAL CO., LTD.
+0010F3 Nexcom International Co., Ltd.
 0010F4 VERTICAL NETWORKS, INC.
 0010F5 AMHERST SYSTEMS, INC.
 0010F6 CISCO SYSTEMS, INC.
-0010F7 IRIICHI TECHNOLOGIES
+0010F7 IRIICHI TECHNOLOGIES Inc.
 0010F8 KENWOOD TMI CORPORATION
 0010F9 UNIQUE SYSTEMS, INC.
 0010FA ZAYANTE, INC.
@@ -1934,14 +4047,14 @@
 002016 SHOWA ELECTRIC WIRE & CABLE CO
 002017 ORBOTECH
 002018 CIS TECHNOLOGY INC.
-002019 OHLER GMBH
+002019 OHLER GmbH
 00201A N-BASE SWITCH COMMUNICATIONS
 00201B NORTHERN TELECOM/NETWORK
 00201C EXCEL, INC.
 00201D KATANA PRODUCTS
 00201E NETQUEST CORPORATION
 00201F BEST POWER TECHNOLOGY, INC.
-002020 MEGATRON COMPUTER INDUSTRIES
+002020 MEGATRON COMPUTER INDUSTRIES PTY, LTD.
 002021 ALGORITHMS SOFTWARE PVT. LTD.
 002022 TEKNIQUE, INC.
 002023 T.C. TECHNOLOGIES PTY. LTD
@@ -1952,26 +4065,26 @@
 002028 WEST EGG SYSTEMS, INC.
 002029 TELEPROCESSING PRODUCTS, INC.
 00202A N.V. DZINE
-00202B ADVANCED TELECOMMUNICATIONS
+00202B ADVANCED TELECOMMUNICATIONS MODULES, LTD.
 00202C WELLTRONIX CO., LTD.
 00202D TAIYO CORPORATION
 00202E DAYSTAR DIGITAL
 00202F ZETA COMMUNICATIONS, LTD.
 002030 ANALOG & DIGITAL SYSTEMS
-002031 ERTEC GMBH
+002031 ERTEC GmbH
 002032 ALCATEL TAISEL
 002033 SYNAPSE TECHNOLOGIES, INC.
 002034 ROTEC INDUSTRIEAUTOMATION GMBH
 002035 IBM CORPORATION
 002036 BMC SOFTWARE
 002037 SEAGATE TECHNOLOGY
-002038 VME MICROSYSTEMS INTERNATIONAL
+002038 VME MICROSYSTEMS INTERNATIONAL CORPORATION
 002039 SCINETS
 00203A DIGITAL BI0METRICS INC.
 00203B WISDM LTD.
 00203C EUROTIME AB
 00203D NOVAR ELECTRONICS CORPORATION
-00203E LOGICAN TECHNOLOGIES, INC.
+00203E LogiCan Technologies, Inc.
 00203F JUKI CORPORATION
 002040 Motorola Broadband Communications Sector
 002041 DATA NET
@@ -1990,22 +4103,22 @@
 00204E NETWORK SECURITY SYSTEMS, INC.
 00204F DEUTSCHE AEROSPACE AG
 002050 KOREA COMPUTER INC.
-002051 PHOENIX DATA COMMUNUNICATIONS
+002051 Verilink Corporation
 002052 RAGULA SYSTEMS
 002053 HUNTSVILLE MICROSYSTEMS, INC.
 002054 EASTERN RESEARCH, INC.
 002055 ALTECH CO., LTD.
 002056 NEOPRODUCTS
-002057 TITZE DATENTECHNIK GMBH
+002057 TITZE DATENTECHNIK GmbH
 002058 ALLIED SIGNAL INC.
 002059 MIRO COMPUTER PRODUCTS AG
 00205A COMPUTER IDENTICS
 00205B SKYLINE TECHNOLOGY
-00205C INTERNET SYSTEMS/ FLORIDA INC.
+00205C InterNet Systems of Florida, Inc.
 00205D NANOMATIC OY
 00205E CASTLE ROCK, INC.
 00205F GAMMADATA COMPUTER GMBH
-002060 ALCATEL ITALIA S.P.A.
+002060 ALCATEL ITALIA S.p.A.
 002061 DYNATECH COMMUNICATIONS, INC.
 002062 SCORPION LOGIC, LTD.
 002063 WIPRO INFOTECH LTD.
@@ -2015,7 +4128,7 @@
 002068 ISDYNE
 002069 ISDN SYSTEMS CORPORATION
 00206A OSAKA COMPUTER CORP.
-00206B MINOLTA CO., LTD.
+00206B KONICA MINOLTA HOLDINGS, INC.
 00206C EVERGREEN TECHNOLOGY CORP.
 00206D DATA RACE, INC.
 00206E XACT, INC.
@@ -2030,11 +4143,11 @@
 002077 KARDIOS SYSTEMS CORP.
 002078 RUNTOP, INC.
 002079 MIKRON GMBH
-00207A WISE COMMUNICATIONS, INC.
-00207B LEVEL ONE COMMUNICATIONS
-00207C AUTEC GMBH
+00207A WiSE Communications, Inc.
+00207B Intel Corporation
+00207C AUTEC GmbH
 00207D ADVANCED COMPUTER APPLICATIONS
-00207E FINECOM CO., LTD.
+00207E FINECOM Co., Ltd.
 00207F KYOEI SANGYO CO., LTD.
 002080 SYNERGY (UK) LTD.
 002081 TITAN ELECTRONICS
@@ -2052,13 +4165,13 @@
 00208D CMD TECHNOLOGY
 00208E CHEVIN SOFTWARE ENG. LTD.
 00208F ECI TELECOM LTD.
-002090 ADVANCED COMPRESSION
+002090 ADVANCED COMPRESSION TECHNOLOGY, INC.
 002091 J125, NATIONAL SECURITY AGENCY
 002092 CHESS ENGINEERING B.V.
 002093 LANDINGS TECHNOLOGY CORP.
 002094 CUBIX CORPORATION
 002095 RIVA ELECTRONICS
-002096 SIEBE ENVIRONMENTAL CONTROLS
+002096 Invensys
 002097 APPLIED SIGNAL TECHNOLOGY
 002098 HECTRONIC AB
 002099 BON ELECTRIC CO., LTD.
@@ -2066,7 +4179,7 @@
 00209B ERSAT ELECTRONIC GMBH
 00209C PRIMARY ACCESS CORP.
 00209D LIPPERT AUTOMATIONSTECHNIK
-00209E BROWN'S OPERATING SYSTEM
+00209E BROWN'S OPERATING SYSTEM SERVICES, LTD.
 00209F MERCURY COMPUTER SYSTEMS, INC.
 0020A0 OA LABORATORY CO., LTD.
 0020A1 DOVATRON
@@ -2086,7 +4199,7 @@
 0020AF 3COM CORPORATION
 0020B0 GATEWAY DEVICES, INC.
 0020B1 COMTECH RESEARCH INC.
-0020B2 GKD GESELLSCHAFT FUR
+0020B2 GKD Gesellschaft Fur Kommunikation Und Datentechnik
 0020B3 SCLTEC COMMUNICATIONS SYSTEMS
 0020B4 TERMA ELEKTRONIK AS
 0020B5 YASKAWA ELECTRIC CORPORATION
@@ -2123,18 +4236,18 @@
 0020D4 CABLETRON - ZEITTNET INC.
 0020D5 VIPA GMBH
 0020D6 BREEZECOM
-0020D7 JAPAN MINICOMPUTER SYSTEMS CO.
-0020D8 NETWAVE TECHNOLOGIES, INC.
-0020D9 PANASONIC TECHNOLOGIES, INC./
+0020D7 JAPAN MINICOMPUTER SYSTEMS CO., Ltd.
+0020D8 Nortel Networks
+0020D9 PANASONIC TECHNOLOGIES, INC./MIECO-US
 0020DA XYLAN CORPORATION
 0020DB XNET TECHNOLOGY, INC.
 0020DC DENSITRON TAIWAN LTD.
-0020DD AWA LTD.
+0020DD Cybertec Pty Ltd
 0020DE JAPAN DIGITAL LABORAT'Y CO.LTD
 0020DF KYOSAN ELECTRIC MFG. CO., LTD.
 0020E0 PREMAX ELECTRONICS, INC.
 0020E1 ALAMAR ELECTRONICS
-0020E2 INFORMATION RESOURCE
+0020E2 INFORMATION RESOURCE ENGINEERING
 0020E3 MCD KENCOM CORPORATION
 0020E4 HSING TECH ENTERPRISE CO., LTD
 0020E5 APEX DATA, INC.
@@ -2214,7 +4327,7 @@
 00302F Smiths Industries
 003030 HARMONIX CORPORATION
 003031 LIGHTWAVE COMMUNICATIONS, INC.
-003032 MAGICRAM, INC.
+003032 MagicRam, Inc.
 003033 ORIENT TELECOM CO., LTD.
 003036 RMP ELEKTRONIKSYSTEME GMBH
 003037 Packard Bell Nec Services
@@ -2323,7 +4436,7 @@
 00309E WORKBIT CORPORATION.
 00309F AMBER NETWORKS
 0030A0 TYCO SUBMARINE SYSTEMS, LTD.
-0030A1 OPTI TECH CO., LTD.
+0030A1 WEBGATE Inc.
 0030A2 Lightner Engineering
 0030A3 CISCO SYSTEMS, INC.
 0030A4 Woodwind Communications System
@@ -2337,7 +4450,7 @@
 0030AC Systeme Lauer GmbH & Co., Ltd.
 0030AD SHANGHAI COMMUNICATION
 0030AE Times N System, Inc.
-0030AF Honeywell Reqelsysteme GmbH
+0030AF Honeywell GmbH
 0030B0 Convergenet Technologies
 0030B1 GOC GESELLSCHAFT FUR OPTISCHE
 0030B2 WESCAM - HEALDSBURG
@@ -2531,7 +4644,7 @@
 00406F SYNC RESEARCH INC.
 004070 INTERWARE CO., LTD.
 004071 ATM COMPUTER GMBH
-004072 APPLIED INNOVATION, INC.
+004072 Applied Innovation Inc.
 004073 BASS ASSOCIATES
 004074 CABLE AND WIRELESS
 004075 M-TRADE (UK) LTD
@@ -2544,7 +4657,7 @@
 00407C QUME CORPORATION
 00407D EXTENSION TECHNOLOGY CORP.
 00407E EVERGREEN SYSTEMS, INC.
-00407F AGEMA INFRARED SYSTEMS AB
+00407F FLIR Systems
 004080 ATHENIX CORPORATION
 004081 MANNESMANN SCANGRAPHIC GMBH
 004082 LABORATORY EQUIPMENT CORP.
@@ -2673,34 +4786,35 @@
 0040FD LXE
 0040FE SYMPLEX COMMUNICATIONS
 0040FF TELEBIT CORPORATION
+004252 RLX Technologies
 005000 NEXO COMMUNICATIONS, INC.
 005001 YAMASHITA SYSTEMS CORP.
 005002 OMNISEC AG
 005003 GRETAG MACBETH AG
 005004 3COM CORPORATION
 005006 TAC AB
-005007 SIEMENS TELECOMMUNICATION
+005007 SIEMENS TELECOMMUNICATION SYSTEMS LIMITED
 005008 TIVA MICROCOMPUTER CORP. (TMC)
 005009 PHILIPS BROADBAND NETWORKS
 00500A IRIS TECHNOLOGIES, INC.
 00500B CISCO SYSTEMS, INC.
-00500C ETEK LABS, INC.
+00500C e-Tek Labs, Inc.
 00500D SATORI ELECTORIC CO., LTD.
-00500E CHROMATIS NETWORKS,INC.
+00500E CHROMATIS NETWORKS, INC.
 00500F CISCO SYSTEMS, INC.
-005010 NOVANET LEARNING, INC.
+005010 NovaNET Learning, Inc.
 005012 CBL - GMBH
-005013 Chaparral Technologies, Inc.
+005013 Chaparral Network Storage
 005014 CISCO SYSTEMS, INC.
 005015 BRIGHT STAR ENGINEERING
 005016 SST/WOODHEAD INDUSTRIES
 005017 RSR S.R.L.
-005018 ADVANCED MULTIMEDIA INTERNET
+005018 ADVANCED MULTIMEDIA INTERNET TECHNOLOGY INC.
 005019 SPRING TIDE NETWORKS, INC.
 00501A UISIQN
 00501B ABL CANADA, INC.
 00501C JATOM SYSTEMS, INC.
-00501E MIRANDA TECHNOLOGIES, INC.
+00501E Miranda Technologies, Inc.
 00501F MRG SYSTEMS, LTD.
 005020 MEDIASTAR CO., LTD.
 005021 EIS INTERNATIONAL, INC.
@@ -2716,7 +4830,7 @@
 00502C SOYO COMPUTER, INC.
 00502D ACCEL, INC.
 00502E CAMBEX CORPORATION
-00502F TOLLBRIDGE TECHNOLOGIES, INC.
+00502F TollBridge Technologies, Inc.
 005030 FUTURE PLUS SYSTEMS
 005031 AEROFLEX LABORATORIES, INC.
 005032 PICAZO COMMUNICATIONS, INC.
@@ -2732,7 +4846,7 @@
 00503F ANCHOR GAMES
 005040 EMWARE, INC.
 005041 CTX OPTO ELECTRONIC CORP.
-005042 SCI MANUFACTURING
+005042 SCI MANUFACTURING SINGAPORE PTE, LTD.
 005043 MARVELL SEMICONDUCTOR, INC.
 005044 ASACA CORPORATION
 005045 RIOWORKS SOLUTIONS, INC.
@@ -2751,10 +4865,10 @@
 005053 CISCO SYSTEMS, INC.
 005054 CISCO SYSTEMS, INC.
 005055 DOMS A/S
-005056 VMWARE, INC.
+005056 VMWare, Inc.
 005057 BROADBAND ACCESS SYSTEMS
 005058 VEGASTREAM LIMITED
-005059 SUITE TECHNOLOGY SYSTEMS
+005059 SUITE TECHNOLOGY SYSTEMS NETWORK
 00505A NETWORK ALCHEMY, INC.
 00505B KAWASAKI LSI U.S.A., INC.
 00505C TUNDO CORPORATION
@@ -2765,10 +4879,10 @@
 005063 OY COMSEL SYSTEM AB
 005064 CAE ELECTRONICS
 005065 DENSEI-LAMBAD Co., Ltd.
-005066 ATECOM GMBH ADVANCED
+005066 AtecoM GmbH advanced telecomunication modules
 005067 AEROCOMM, INC.
-005068 ELECTRONIC INDUSTRIES
-005069 PIXSTREAM INCORPORATED
+005068 ELECTRONIC INDUSTRIES ASSOCIATION
+005069 PixStream Incorporated
 00506A EDEVA, INC.
 00506B SPX-ATEG
 00506C G & L BEIJER ELECTRONICS AB
@@ -2789,7 +4903,7 @@
 00507C VIDEOCON AG
 00507D IFP
 00507E NEWER TECHNOLOGY
-00507F DRAYTEK CORP.
+00507F DrayTek Corp.
 005080 CISCO SYSTEMS, INC.
 005081 MURATA MACHINERY, LTD.
 005082 FORESSON CORPORATION
@@ -2811,29 +4925,29 @@
 005094 PACE MICRO TECHNOLOGY PLC
 005095 PERACOM NETWORKS
 005096 SALIX TECHNOLOGIES, INC.
-005097 MMC-EMBEDDED
+005097 MMC-EMBEDDED COMPUTERTECHNIK GmbH
 005098 GLOBALOOP, LTD.
 005099 3COM EUROPE, LTD.
 00509A TAG ELECTRONIC SYSTEMS
 00509B SWITCHCORE AB
 00509C BETA RESEARCH
 00509D THE INDUSTREE B.V.
-00509E LES TECHNOLOGIES
+00509E Les Technologies SoftAcoustik Inc.
 00509F HORIZON COMPUTER
 0050A0 DELTA COMPUTER SYSTEMS, INC.
 0050A1 CARLO GAVAZZI, INC.
 0050A2 CISCO SYSTEMS, INC.
-0050A3 TRANSMEDIA COMMUNICATIONS, INC
+0050A3 TransMedia Communications, Inc.
 0050A4 IO TECH, INC.
 0050A5 CAPITOL BUSINESS SYSTEMS, LTD.
 0050A6 OPTRONICS
 0050A7 CISCO SYSTEMS, INC.
-0050A8 OPENCON SYSTEMS, INC.
+0050A8 OpenCon Systems, Inc.
 0050A9 MOLDAT WIRELESS TECHNOLGIES
-0050AA KONICA CORPORATION
+0050AA KONICA MINOLTA HOLDINGS, INC.
 0050AB NALTEC, INC.
 0050AC MAPLE COMPUTER CORPORATION
-0050AD COMMUNIQUE WIRELESS CORP.
+0050AD CommUnique Wireless Corp.
 0050AE IWAKI ELECTRONICS CO., LTD.
 0050AF INTERGON, INC.
 0050B0 TECHNOLOGY ATLANTA CORPORATION
@@ -2857,7 +4971,7 @@
 0050C2 IEEE REGISTRATION AUTHORITY
 0050C4 IMD
 0050C5 ADS TECHNOLOGIES, INC.
-0050C6 LOOP TELECOMMUNICATION
+0050C6 LOOP TELECOMMUNICATION INTERNATIONAL, INC.
 0050C8 ADDONICS COMMUNICATIONS, INC.
 0050C9 MASPRO DENKOH CORP.
 0050CA NET TO NET TECHNOLOGIES
@@ -2865,52 +4979,52 @@
 0050CC XYRATEX
 0050CD DIGIANSWER A/S
 0050CE LG INTERNATIONAL CORP.
-0050CF VANLINK COMMUNICATION
+0050CF VANLINK COMMUNICATION TECHNOLOGY RESEARCH INSTITUTE
 0050D0 MINERVA SYSTEMS
 0050D1 CISCO SYSTEMS, INC.
 0050D2 BAE Systems Canada, Inc.
-0050D3 DIGITAL AUDIO
+0050D3 DIGITAL AUDIO PROCESSING PTY. LTD.
 0050D4 JOOHONG INFORMATION &
 0050D5 AD SYSTEMS CORP.
 0050D6 ATLAS COPCO TOOLS AB
 0050D7 TELSTRAT
 0050D8 UNICORN COMPUTER CORP.
-0050D9 ENGETRON-ENGENHARIA ELETRONICA
+0050D9 ENGETRON-ENGENHARIA ELETRONICA IND. e COM. LTDA
 0050DA 3COM CORPORATION
 0050DB CONTEMPORARY CONTROL
-0050DC TAS TELEFONBAU A. SCHWABE
+0050DC TAS TELEFONBAU A. SCHWABE GMBH & CO. KG
 0050DD SERRA SOLDADURA, S.A.
 0050DE SIGNUM SYSTEMS CORP.
-0050DF AIRFIBER, INC.
+0050DF AirFiber, Inc.
 0050E1 NS TECH ELECTRONICS SDN BHD
 0050E2 CISCO SYSTEMS, INC.
-0050E3 TELEGATE
+0050E3 Terayon Communications Systems
 0050E4 APPLE COMPUTER, INC.
 0050E6 HAKUSAN CORPORATION
 0050E7 PARADISE INNOVATIONS (ASIA)
 0050E8 NOMADIX INC.
-0050EA XEL COMMUNICTIONS, INC.
+0050EA XEL COMMUNICATIONS, INC.
 0050EB ALPHA-TOP CORPORATION
 0050EC OLICOM A/S
 0050ED ANDA NETWORKS
 0050EE TEK DIGITEL CORPORATION
-0050EF SPE SYSTEMHAUS GMBH
+0050EF SPE Systemhaus GmbH
 0050F0 CISCO SYSTEMS, INC.
 0050F1 LIBIT SIGNAL PROCESSING, LTD.
 0050F2 MICROSOFT CORP.
-0050F3 GLOBAL NET INFORMATION CO.,LTD
+0050F3 GLOBAL NET INFORMATION CO., Ltd.
 0050F4 SIGMATEK GMBH & CO. KG
-0050F6 PAN-INTERNATIONAL
-0050F7 VENTURE MANUFACTURING
+0050F6 PAN-INTERNATIONAL INDUSTRIAL CORP.
+0050F7 VENTURE MANUFACTURING (SINGAPORE) LTD.
 0050F8 ENTREGA TECHNOLOGIES, INC.
 0050FA OXTEL, LTD.
 0050FB VSK ELECTRONICS
 0050FC EDIMAX TECHNOLOGY CO., LTD.
-0050FD ISIONCOMM CO., LTD.
-0050FE PCTVNET ASA
+0050FD VISIONCOMM CO., LTD.
+0050FE PCTVnet ASA
 0050FF HAKKO ELECTRONICS CO., LTD.
 006000 XYCOM INC.
-006001 INNOSYS, INC.
+006001 InnoSys, Inc.
 006002 SCREEN SUBTITLING SYSTEMS, LTD
 006003 TERAOKA WEIGH SYSTEM PTE, LTD.
 006004 COMPUTADORES MODULARES SA
@@ -2920,9 +5034,9 @@
 006008 3COM CORPORATION
 006009 CISCO SYSTEMS, INC.
 00600A SORD COMPUTER CORPORATION
-00600B LOGWARE GMBH
+00600B LOGWARE GmbH
 00600C APPLIED DATA SYSTEMS, INC.
-00600D MICRODESIGN GMBH
+00600D Digital Logic GmbH
 00600E WAVENET INTERNATIONAL, INC.
 00600F WESTELL, INC.
 006010 NETWORK MACHINES, INC.
@@ -2934,7 +5048,7 @@
 006016 CLARIION
 006017 TOKIMEC INC.
 006018 STELLAR ONE CORPORATION
-006019 BOEHRINGER MANNHEIM CORP.
+006019 Roche Diagnostics
 00601A KEITHLEY INSTRUMENTS
 00601B MESA ELECTRONICS
 00601C TELXON CORPORATION
@@ -2951,24 +5065,24 @@
 006027 Superior Modular Products
 006028 MACROVISION CORPORATION
 006029 CARY PERIPHERALS INC.
-00602A SYMICRON COMPUTER
+00602A SYMICRON COMPUTER COMMUNICATIONS, LTD.
 00602B PEAK AUDIO
-00602C LINX DATA TERMINALS, INC.
+00602C LINX Data Terminals, Inc.
 00602D ALERTON TECHNOLOGIES, INC.
 00602E CYCLADES CORPORATION
 00602F CISCO SYSTEMS, INC.
-006030 VILLAGE TRONIC
+006030 VILLAGE TRONIC ENTWICKLUNG
 006031 HRK SYSTEMS
 006032 I-CUBE, INC.
 006033 ACUITY IMAGING, INC.
-006034 ROBERT BOSCH GMBH
+006034 ROBERT BOSCH GmbH
 006035 DALLAS SEMICONDUCTOR, INC.
-006036 AUSTRIAN RESEARCH CENTER
+006036 AUSTRIAN RESEARCH CENTER SEIBERSDORF
 006037 PHILIPS SEMICONDUCTORS
 006038 Nortel Networks
-006039 SANCOM TECHNOLOGY, INC.
+006039 SanCom Technology, Inc.
 00603A QUICK CONTROLS LTD.
-00603B AMTEC SPA
+00603B AMTEC spa
 00603C HAGIWARA SYS-COM CO., LTD.
 00603D 3CX
 00603E CISCO SYSTEMS, INC.
@@ -2976,7 +5090,7 @@
 006040 NETRO CORP.
 006041 Yokogawa Electric Corporation
 006042 TKS (USA), INC.
-006043 COMSOFT SYSTEMS, INC.
+006043 ComSoft Systems, Inc.
 006044 LITTON/POLY-SCIENTIFIC
 006045 PATHLIGHT TECHNOLOGIES
 006046 VMETRO, INC.
@@ -2984,23 +5098,23 @@
 006048 EMC CORPORATION
 006049 VINA TECHNOLOGIES
 00604A SAIC IDEAS GROUP
-00604B BIODATA GMBH
+00604B BIODATA GmbH
 00604C SAT
 00604D MMC NETWORKS, INC.
 00604E CYCLE COMPUTER CORPORATION, INC.
 00604F SUZUKI MFG. CO., LTD.
 006050 INTERNIX INC.
 006051 QUALITY SEMICONDUCTOR
-006052 PERIPHERALS ENTERPRISE CO., L.
+006052 PERIPHERALS ENTERPRISE CO., Ltd.
 006053 TOYODA MACHINE WORKS, LTD.
 006054 CONTROLWARE GMBH
 006055 CORNELL UNIVERSITY
 006056 NETWORK TOOLS, INC.
 006057 MURATA MANUFACTURING CO., LTD.
-006058 COPPER MOUNTAIN
+006058 COPPER MOUNTAIN COMMUNICATIONS, INC.
 006059 TECHNICAL COMMUNICATIONS CORP.
 00605A CELCORE, INC.
-00605B INTRASERVER TECHNOLOGY INC.
+00605B IntraServer Technology, Inc.
 00605C CISCO SYSTEMS, INC.
 00605D SCANIVALVE CORP.
 00605E LIBERTY TECHNOLOGY NETWORKING
@@ -3010,13 +5124,13 @@
 006062 TELESYNC, INC.
 006063 PSION DACOM PLC.
 006064 NETCOMM LIMITED
-006065 BERNECKER & RAINER
+006065 BERNECKER & RAINER INDUSTRIE-ELEKTRONIC GmbH
 006066 LACROIX TECHNOLGIE
 006067 ACER NETXUS INC.
 006068 EICON TECHNOLOGY CORPORATION
-006069 BROCADE COMMUNICATIONS SYSTEMS
-00606A MITSUBISHI WIRELESS COMM. INC.
-00606B AICHI ELECTRONICS CO.,LTD.
+006069 BROCADE COMMUNICATIONS SYSTEMS, Inc.
+00606A MITSUBISHI WIRELESS COMMUNICATIONS. INC.
+00606B Synclayer Inc.
 00606C ARESCOM
 00606D DIGITAL EQUIPMENT CORP.
 00606E DAVICOM SEMICONDUCTOR, INC.
@@ -3027,13 +5141,13 @@
 006073 REDCREEK COMMUNICATIONS, INC.
 006074 QSC AUDIO PRODUCTS
 006075 PENTEK, INC.
-006076 SCHLUMBERGER TECHNOLOGIES
+006076 SCHLUMBERGER TECHNOLOGIES RETAIL PETROLEUM SYSTEMS
 006077 PRISA NETWORKS
 006078 POWER MEASUREMENT LTD.
-006079 WAVEPHORE NETWORKS, INC.
-00607A DVS GMBH
+006079 Mainstream Data, Inc.
+00607A DVS GmbH
 00607B FORE SYSTEMS, INC.
-00607C WAVEACCESS, LTD.
+00607C WaveAccess, Ltd.
 00607D SENTIENT NETWORKS INC.
 00607E GIGALABS, INC.
 00607F AURORA TECHNOLOGIES, INC.
@@ -3042,16 +5156,16 @@
 006082 NOVALINK TECHNOLOGIES, INC.
 006083 CISCO SYSTEMS, INC.
 006084 DIGITAL VIDEO
-006085 STORAGE CONCEPTS
+006085 Storage Concepts
 006086 LOGIC REPLACEMENT TECH. LTD.
 006087 KANSAI ELECTRIC CO., LTD.
 006088 WHITE MOUNTAIN DSP, INC.
 006089 XATA
 00608A CITADEL COMPUTER
-00608B CONFERTECH INTERNATIONAL
+00608B ConferTech International
 00608C 3COM CORPORATION
 00608D UNIPULSE CORP.
-00608E HE ELECTRONICS, TECHNOLOGIE &
+00608E HE ELECTRONICS, TECHNOLOGIE & SYSTEMTECHNIK GmbH
 00608F TEKRAM TECHNOLOGY CO., LTD.
 006090 ABLE COMMUNICATIONS, INC.
 006091 FIRST PACIFIC NETWORKS, INC.
@@ -3065,24 +5179,24 @@
 006099 LAN MEDIA CORPORATION
 00609A NJK TECHNO CO.
 00609B ASTRO-MED, INC.
-00609C PERKIN-ELMER CORPORATION
+00609C Perkin-Elmer Incorporated
 00609D PMI FOOD EQUIPMENT GROUP
-00609E X3 - INFORMATION TECHNOLOGY
+00609E ASC X3 - INFORMATION TECHNOLOGY STANDARDS SECRETARIATS
 00609F PHAST CORPORATION
-0060A0 SWITCHED NETWORK
-0060A1 VPNET
+0060A0 SWITCHED NETWORK TECHNOLOGIES, INC.
+0060A1 VPNet, Inc.
 0060A2 NIHON UNISYS LIMITED CO.
 0060A3 CONTINUUM TECHNOLOGY CORP.
 0060A4 GRINAKER SYSTEM TECHNOLOGIES
 0060A5 PERFORMANCE TELECOM CORP.
 0060A6 PARTICLE MEASURING SYSTEMS
-0060A7 MICROSENS GMBH & CO. KG
+0060A7 MICROSENS GmbH & CO. KG
 0060A8 TIDOMAT AB
-0060A9 GESYTEC MBH
+0060A9 GESYTEC MbH
 0060AA INTELLIGENT DEVICES INC. (IDI)
 0060AB LARSCOM INCORPORATED
 0060AC RESILIENCE CORPORATION
-0060AD MEGACHIPS CORPORATION
+0060AD MegaChips Corporation
 0060AE TRIO INFORMATION SYSTEMS AB
 0060AF PACIFIC MICRO DATA, INC.
 0060B0 HEWLETT-PACKARD CO.
@@ -3090,19 +5204,19 @@
 0060B2 PROCESS CONTROL CORP.
 0060B3 Z-COM, INC.
 0060B4 GLENAYRE R&D INC.
-0060B5 KEBA GMBH
+0060B5 KEBA GmbH
 0060B6 LAND COMPUTER CO., LTD.
 0060B7 CHANNELMATIC, INC.
 0060B8 CORELIS INC.
 0060B9 NITSUKO CORPORATION
 0060BA SAHARA NETWORKS, INC.
 0060BB CABLETRON - NETLINK, INC.
-0060BC KEUNYOUNG ELECTRONICS &
+0060BC KeunYoung Electronics & Communication Co., Ltd.
 0060BD HUBBELL-PULSECOM
 0060BE WEBTRONICS
 0060BF MACRAIGOR SYSTEMS, INC.
 0060C0 NERA AS
-0060C1 WAVESPAN CORPORATION
+0060C1 WaveSpan Corporation
 0060C2 MPL AG
 0060C3 NETVISION CORPORATION
 0060C4 SOLITON SYSTEMS K.K.
@@ -3110,40 +5224,40 @@
 0060C6 DCS AG
 0060C7 AMATI COMMUNICATIONS CORP.
 0060C8 KUKA WELDING SYSTEMS & ROBOTS
-0060C9 CONTROLNET, INC.
+0060C9 ControlNet, Inc.
 0060CA HARMONIC SYSTEMS INCORPORATED
 0060CB HITACHI ZOSEN CORPORATION
 0060CC EMTRAK, INCORPORATED
-0060CD VIDEOSERVER, INC.
+0060CD VideoServer, Inc.
 0060CE ACCLAIM COMMUNICATIONS
 0060CF ALTEON NETWORKS, INC.
 0060D0 SNMP RESEARCH INCORPORATED
 0060D1 CASCADE COMMUNICATIONS
-0060D2 LUCENT TECHNOLOGIES TAIWAN
+0060D2 LUCENT TECHNOLOGIES TAIWAN TELECOMMUNICATIONS CO., LTD.
 0060D3 AT&T
 0060D4 ELDAT COMMUNICATION LTD.
 0060D5 MIYACHI TECHNOS CORP.
-0060D6 NOVATEL WIRELESS TECHNOLOGIES
-0060D7 ECOLE POLYTECHNIQUE FEDERALE
+0060D6 NovAtel Wireless Technologies Ltd.
+0060D7 ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE (EPFL)
 0060D8 ELMIC SYSTEMS, INC.
 0060D9 TRANSYS NETWORKS INC.
 0060DA JBM ELECTRONICS CO.
 0060DB NTP ELEKTRONIK A/S
-0060DC TOYO COMMUNICATION EQUIPMENT
+0060DC TOYO COMMUNICATION EQUIPMENT Co., Ltd.
 0060DD MYRICOM, INC.
-0060DE KAYSER-THREDE GMBH
-0060DF INRANGE TECHNOLOGIES CORP.
+0060DE KAYSER-THREDE GmbH
+0060DF CNT Corporation
 0060E0 AXIOM TECHNOLOGY CO., LTD.
 0060E1 ORCKIT COMMUNICATIONS LTD.
-0060E2 QUEST ENGINEERING & DEV.
+0060E2 QUEST ENGINEERING & DEVELOPMENT
 0060E3 ARBIN INSTRUMENTS
 0060E4 COMPUSERVE, INC.
 0060E5 FUJI AUTOMATION CO., LTD.
 0060E6 SHOMITI SYSTEMS INCORPORATED
 0060E7 RANDATA
-0060E8 HITACHI COMPUTER PRODUCTS
+0060E8 HITACHI COMPUTER PRODUCTS (AMERICA), INC.
 0060E9 ATOP TECHNOLOGIES, INC.
-0060EA STREAMLOGIC
+0060EA StreamLogic
 0060EB FOURTHTRACK SYSTEMS
 0060EC HERMARY OPTO ELECTRONICS INC.
 0060ED RICARDO TEST AUTOMATION LTD.
@@ -3152,19 +5266,19 @@
 0060F0 JOHNSON & JOHNSON MEDICAL, INC
 0060F1 EXP COMPUTER, INC.
 0060F2 LASERGRAPHICS, INC.
-0060F3 NETCOM SYSTEMS, INC.
-0060F4 ADVANCED COMPUTER SOLUTIONS,
+0060F3 Performance Analysis Broadband, Spirent plc
+0060F4 ADVANCED COMPUTER SOLUTIONS, Inc.
 0060F5 ICON WEST, INC.
-0060F6 NEXTEST COMMUNICATION
+0060F6 NEXTEST COMMUNICATIONS PRODUCTS, INC.
 0060F7 DATAFUSION SYSTEMS
-0060F8 LORAN INTERNATIONAL TECHN. INC
+0060F8 Loran International Technologies Inc.
 0060F9 DIAMOND LANE COMMUNICATIONS
-0060FA EDUCATIONAL TECHNOLOGY
+0060FA EDUCATIONAL TECHNOLOGY RESOURCES, INC.
 0060FB PACKETEER, INC.
-0060FC CONSERVATION THROUGH
-0060FD NETICS, INC.
+0060FC CONSERVATION THROUGH INNOVATION LTD.
+0060FD NetICs, Inc.
 0060FE LYNX SYSTEM DEVELOPERS, INC.
-0060FF QUVIS, INC.
+0060FF QuVis, Inc.
 0070B0 M/A-COM INC. COMPANIES
 0070B3 DATA RECALL LTD.
 008000 MULTITECH SYSTEMS, INC.
@@ -3200,7 +5314,7 @@
 00801E XINETRON, INC.
 00801F KRUPP ATLAS ELECTRONIK GMBH
 008020 NETWORK PRODUCTS
-008021 NEWBRIDGE RESEARCH CORP.
+008021 Alcatel Canada Inc.
 008022 SCAN-OPTICS
 008023 INTEGRATED BUSINESS NETWORKS
 008024 KALPANA, INC.
@@ -3361,7 +5475,7 @@
 0080BF TAKAOKA ELECTRIC MFG. CO. LTD.
 0080C0 PENRIL DATACOMM
 0080C1 LANEX CORPORATION
-0080C2 IEEE 802 COMMITTEE
+0080C2 IEEE 802.1 COMMITTEE
 0080C3 BICC INFORMATION SYSTEMS & SVC
 0080C4 DOCUMENT TECHNOLOGIES, INC.
 0080C5 NOVELLCO DE MEXICO
@@ -3382,7 +5496,7 @@
 0080D4 CHASE RESEARCH LTD.
 0080D5 CADRE TECHNOLOGIES
 0080D6 NUVOTECH, INC.
-0080D7 FANTUM ENGINEERING, INC.
+0080D7 Fantum Engineering
 0080D8 NETWORK PERIPHERALS INC.
 0080D9 EMK ELEKTRONIK
 0080DA BRUEL & KJAER
@@ -3400,14 +5514,14 @@
 0080E6 PEER NETWORKS, INC.
 0080E7 LYNWOOD SCIENTIFIC DEV. LTD.
 0080E8 CUMULUS CORPORATIION
-0080E9 MADGE NETWORKS
+0080E9 Madge Ltd.
 0080EA ADVA Optical Networking Ltd.
 0080EB COMPCONTROL B.V.
 0080EC SUPERCOMPUTING SOLUTIONS, INC.
 0080ED IQ TECHNOLOGIES, INC.
 0080EE THOMSON CSF
 0080EF RATIONAL
-0080F0 KYUSHU MATSUSHITA ELECTRIC CO.
+0080F0 Panasonic Communications Co., Ltd.
 0080F1 OPUS SYSTEMS
 0080F2 RAYCOM SYSTEMS INC
 0080F3 SUN ELECTRONICS CORP.
@@ -3424,23 +5538,23 @@
 0080FE AZURE TECHNOLOGIES, INC.
 0080FF SOC. DE TELEINFORMATIQUE RTC
 009000 DIAMOND MULTIMEDIA
-009001 NISHIMU ELCTRONICS INDUSTRIES
+009001 NISHIMU ELECTRONICS INDUSTRIES CO., LTD.
 009002 ALLGON AB
 009003 APLIO
 009004 3COM EUROPE LTD.
 009005 PROTECH SYSTEMS CO., LTD.
 009006 HAMAMATSU PHOTONICS K.K.
 009007 DOMEX TECHNOLOGY CORP.
-009008 HAN A SYSTEMS, INC.
+009008 HanA Systems Inc.
 009009 i Controls, Inc.
-00900A PROTON ELECTRONIC INDUSTRIAL
+00900A PROTON ELECTRONIC INDUSTRIAL CO., LTD.
 00900B LANNER ELECTRONICS, INC.
 00900C CISCO SYSTEMS, INC.
 00900D OVERLAND DATA INC.
 00900E HANDLINK TECHNOLOGIES, INC.
 00900F KAWASAKI HEAVY INDUSTRIES, LTD
 009010 SIMULATION LABORATORIES, INC.
-009011 WAVTRACE, INC.
+009011 WAVTrace, Inc.
 009012 GLOBESPAN SEMICONDUCTOR, INC.
 009013 SAMSAN CORP.
 009014 ROTORK INSTRUMENTS, LTD.
@@ -3451,7 +5565,7 @@
 009019 HERMES ELECTRONICS CO., LTD.
 00901A UNISPHERE SOLUTIONS
 00901B DIGITAL CONTROLS
-00901C MPS SOFTWARE GMBH
+00901C mps Software Gmbh
 00901D PEC (NZ) LTD.
 00901E SELESTA INGEGNE RIA S.P.A.
 00901F ADTEC PRODUCTIONS, INC.
@@ -3461,44 +5575,44 @@
 009023 ZILOG INC.
 009024 PIPELINKS, INC.
 009025 VISION SYSTEMS LTD. PTY
-009026 ADVANCED SWITCHING
+009026 ADVANCED SWITCHING COMMUNICATIONS, INC.
 009027 INTEL CORPORATION
 009028 NIPPON SIGNAL CO., LTD.
 009029 CRYPTO AG
 00902A COMMUNICATION DEVICES, INC.
 00902B CISCO SYSTEMS, INC.
 00902C DATA & CONTROL EQUIPMENT LTD.
-00902D DATA ELECTRONICS
+00902D DATA ELECTRONICS (AUST.) PTY, LTD.
 00902E NAMCO LIMITED
 00902F NETCORE SYSTEMS, INC.
 009030 HONEYWELL-DATING
 009031 MYSTICOM, LTD.
 009032 PELCOMBE GROUP LTD.
-009033 INNOVAPHONE GMBH
+009033 INNOVAPHONE GmbH
 009034 IMAGIC, INC.
 009035 ALPHA TELECOM, INC.
-009036 ENS, INC.
+009036 ens, inc.
 009037 ACUCOMM, INC.
 009038 FOUNTAIN TECHNOLOGIES, INC.
 009039 SHASTA NETWORKS
 00903A NIHON MEDIA TOOL INC.
-00903B TRIEMS RESEARCH LAB, INC.
+00903B TriEMS Research Lab, Inc.
 00903C ATLANTIC NETWORK SYSTEMS
 00903D BIOPAC SYSTEMS, INC.
-00903E N.V. PHILIPS INDUSTRIAL
+00903E N.V. PHILIPS INDUSTRIAL ACTIVITIES
 00903F AZTEC RADIOMEDIA
-009040 CASTLE NETWORKS, INC.
+009040 Siemens Network Convergence LLC
 009041 APPLIED DIGITAL ACCESS
-009042 ECCS
+009042 ECCS, Inc.
 009043 NICHIBEI DENSHI CO., LTD.
 009044 ASSURED DIGITAL, INC.
-009045 MARIPOSA TECHNOLOGY
+009045 Marconi Communications
 009046 DEXDYNE, LTD.
 009047 GIGA FAST E. LTD.
 009048 ZEAL CORPORATION
 009049 ENTRIDIA CORPORATION
 00904A CONCUR SYSTEM TECHNOLOGIES
-00904B GEMTEK TECHNOLOGY CO., LTD.
+00904B GemTek Technology Co., Ltd.
 00904C EPIGRAM, INC.
 00904D SPEC S.A.
 00904E DELEM BV
@@ -3508,49 +5622,49 @@
 009052 SELCOM ELETTRONICA S.R.L.
 009053 DAEWOO ELECTRONICS CO., LTD.
 009054 INNOVATIVE SEMICONDUCTORS, INC
-009055 PARKER HANNIFIN CORPORATION
+009055 PARKER HANNIFIN CORPORATION COMPUMOTOR DIVISION
 009056 TELESTREAM, INC.
-009057 AANETCOM, INC.
-009058 ULTRA ELECTRONICS LTD.
+009057 AANetcom, Inc.
+009058 Ultra Electronics Ltd., Command and Control Systems
 009059 TELECOM DEVICE K.K.
 00905A DEARBORN GROUP, INC.
 00905B RAYMOND AND LAE ENGINEERING
 00905C EDMI
-00905D NETCOM SICHERHEITSTECHNIK GMBH
+00905D NETCOM SICHERHEITSTECHNIK GmbH
 00905E RAULAND-BORG CORPORATION
 00905F CISCO SYSTEMS, INC.
 009060 SYSTEM CREATE CORP.
-009061 PACIFIC RESEARCH & ENGINEERING
-009062 ICP VORTEX COMPUTERSYSTEME
-009063 COHERENT COMMUNICATIONS
+009061 PACIFIC RESEARCH & ENGINEERING CORPORATION
+009062 ICP VORTEX COMPUTERSYSTEME GmbH
+009063 COHERENT COMMUNICATIONS SYSTEMS CORPORATION
 009064 THOMSON BROADCAST SYSTEMS
 009065 FINISAR CORPORATION
 009066 Troika Networks, Inc.
-009067 WALKABOUT COMPUTERS, INC.
+009067 WalkAbout Computers, Inc.
 009068 DVT CORP.
 009069 JUNIPER NETWORKS, INC.
 00906A TURNSTONE SYSTEMS, INC.
 00906B APPLIED RESOURCES, INC.
-00906C GWT GLOBAL WEIGHING
+00906C GWT GLOBAL WEIGHING TECHNOLOGIES GmbH
 00906D CISCO SYSTEMS, INC.
 00906E PRAXON, INC.
 00906F CISCO SYSTEMS, INC.
 009070 NEO NETWORKS, INC.
-009071 BADGER TECHNOLOGY, INC.
+009071 Applied Innovation Inc.
 009072 SIMRAD AS
 009073 GAIO TECHNOLOGY
 009074 ARGON NETWORKS, INC.
 009075 NEC DO BRASIL S.A.
-009076 FMT AIRCRAFT GATE SUPPORT
+009076 FMT AIRCRAFT GATE SUPPORT SYSTEMS AB
 009077 ADVANCED FIBRE COMMUNICATIONS
-009078 MER TELEMANAGEMENT
-009079 CLEARONE INC.
+009078 MER TELEMANAGEMENT SOLUTIONS, LTD.
+009079 ClearOne, Inc.
 00907A SPECTRALINK CORP.
 00907B E-TECH, INC.
 00907C DIGITALCAST, INC.
-00907D HOME WIRELESS NETWORKS
+00907D Lake Communications
 00907E VETRONIX CORP.
-00907F WATCHGUARD TECHNOLOGIES, INC.
+00907F WatchGuard Technologies, Inc.
 009080 NOT LIMITED, INC.
 009081 ALOHA NETWORKS, INC.
 009082 FORCE INSTITUTE
@@ -3566,9 +5680,9 @@
 00908C ETREND ELECTRONICS, INC.
 00908D VICKERS ELECTRONICS SYSTEMS
 00908E Nortel Networks Broadband Access
-00908F AUDIOCODES LTD.
+00908F AUDIO CODES LTD.
 009090 I-BUS
-009091 DIGITALSCAPE, INC.
+009091 DigitalScape, Inc.
 009092 CISCO SYSTEMS, INC.
 009093 NANAO CORPORATION
 009094 OSPREY TECHNOLOGIES, INC.
@@ -3576,28 +5690,28 @@
 009096 ASKEY COMPUTER CORP.
 009097 SYCAMORE NETWORKS
 009098 SBC DESIGNS, INC.
-009099 ALLIED TELESIS,K.K.
+009099 ALLIED TELESIS, K.K.
 00909A ONE WORLD SYSTEMS, INC.
 00909B MARKPOINT AB
-00909C COMBOX, LTD.
+00909C Terayon Communications Systems
 00909D GSE SYSTEMS, INC.
-00909E DELPHI ENGINEERING GROUP
+00909E Critical IO, LLC
 00909F DIGI-DATA CORPORATION
 0090A0 8X8 INC.
 0090A1 FLYING PIG SYSTEMS, LTD.
 0090A2 CYBERTAN TECHNOLOGY, INC.
-0090A3 MEDIALINCS CO., LTD.
+0090A3 Corecess Inc.
 0090A4 ALTIGA NETWORKS
 0090A5 SPECTRA LOGIC
 0090A6 CISCO SYSTEMS, INC.
 0090A7 CLIENTEC CORPORATION
-0090A8 NINETILES NETWORKS LTD.
+0090A8 NineTiles Networks, Ltd.
 0090A9 WESTERN DIGITAL
-0090AA INDIGO ACTIVE VISION
+0090AA INDIGO ACTIVE VISION SYSTEMS LIMITED
 0090AB CISCO SYSTEMS, INC.
 0090AC OPTIVISION, INC.
 0090AD ASPECT ELECTRONICS, INC.
-0090AE ITALTEL SPA
+0090AE ITALTEL S.p.A.
 0090AF J. MORITA MFG. CORP.
 0090B0 VADEM
 0090B1 CISCO SYSTEMS, INC.
@@ -3610,46 +5724,46 @@
 0090B8 ROHDE & SCHWARZ GMBH & CO. KG
 0090B9 BERAN INSTRUMENTS LTD.
 0090BA VALID NETWORKS, INC.
-0090BB TAINET COMMUNICATION SYSTEM
+0090BB TAINET COMMUNICATION SYSTEM Corp.
 0090BC TELEMANN CO., LTD.
 0090BD OMNIA COMMUNICATIONS, INC.
-0090BE IBC/INTEGRATED BUSINESS
+0090BE IBC/INTEGRATED BUSINESS COMPUTERS
 0090BF CISCO SYSTEMS, INC.
 0090C0 K.J. LAW ENGINEERS, INC.
-0090C1 EDA INDUSTRIES
-0090C2 JK MICROSYSTEMS, INC.
+0090C1 Peco II, Inc.
+0090C2 JK microsystems, Inc.
 0090C3 TOPIC SEMICONDUCTOR CORP.
 0090C4 JAVELIN SYSTEMS, INC.
 0090C5 INTERNET MAGIC, INC.
 0090C6 OPTIM SYSTEMS, INC.
 0090C7 ICOM INC.
-0090C8 WAVERIDER COMMUNICATIONS
-0090C9 PRODUCTIVITY ENHANCEMENT
-0090CA ACCORD VIDEO
-0090CB WIRELESS ONLINE, INC.
-0090CC PLANEX COMMUNICATIONS, INC.
-0090CD ENT-EMPRESA NACIONAL
-0090CE TETRA GMBH
+0090C8 WAVERIDER COMMUNICATIONS (CANADA) INC.
+0090C9 DPAC Technologies
+0090CA ACCORD VIDEO TELECOMMUNICATIONS, LTD.
+0090CB Wireless OnLine, Inc.
+0090CC PLANET COMMUNICATIONS, INC.
+0090CD ENT-EMPRESA NACIONAL DE TELECOMMUNICACOES, S.A.
+0090CE TETRA GmbH
 0090CF NORTEL
-0090D0 ALCATEL BELL
+0090D0 Thomson Belgium
 0090D1 LEICHU ENTERPRISE CO., LTD.
 0090D2 ARTEL VIDEO SYSTEMS
-0090D3 GIESECKE & DEVRIENT GMBH
-0090D4 BINDVIEW DEVELOPMENT CORP.
+0090D3 GIESECKE & DEVRIENT GmbH
+0090D4 BindView Development Corp.
 0090D5 EUPHONIX, INC.
 0090D6 CRYSTAL GROUP
-0090D7 NETBOOST CORP.
+0090D7 NetBoost Corp.
 0090D8 WHITECROSS SYSTEMS
 0090D9 CISCO SYSTEMS, INC.
 0090DA DYNARC, INC.
 0090DB NEXT LEVEL COMMUNICATIONS
 0090DC TECO INFORMATION SYSTEMS
-0090DD THE MIHARU COMMUNICATIONS
+0090DD THE MIHARU COMMUNICATIONS CO., LTD.
 0090DE CARDKEY SYSTEMS, INC.
-0090DF MITSUBISHI CHEMICAL
+0090DF MITSUBISHI CHEMICAL AMERICA, INC.
 0090E0 SYSTRAN CORP.
 0090E1 TELENA S.P.A.
-0090E2 DISTRIBUTED PROCESSING
+0090E2 DISTRIBUTED PROCESSING TECHNOLOGY
 0090E3 AVEX ELECTRONICS INC.
 0090E4 NEC AMERICA, INC.
 0090E5 TEKNEMA, INC.
@@ -3660,8 +5774,8 @@
 0090EA ALPHA TECHNOLOGIES, INC.
 0090EB SENTRY TELECOM SYSTEMS
 0090EC PYRESCOM
-0090ED CENTRAL SYSTEM RESEARCH
-0090EE PERSONAL COMMUNICATIONS
+0090ED CENTRAL SYSTEM RESEARCH CO., LTD.
+0090EE PERSONAL COMMUNICATIONS TECHNOLOGIES
 0090EF INTEGRIX, INC.
 0090F0 HARMONIC LIGHTWAVES, LTD.
 0090F1 DOT HILL SYSTEMS CORPORATION
@@ -3673,20 +5787,21 @@
 0090F7 NBASE COMMUNICATIONS LTD.
 0090F8 MEDIATRIX TELECOM
 0090F9 LEITCH
-0090FA GIGANET, INC.
+0090FA GigaNet, Inc.
 0090FB PORTWELL, INC.
 0090FC NETWORK COMPUTING DEVICES
-0090FD COPPERCOM, INC.
-0090FE ELECOM CO., LTD.  (LANEED DIV.
+0090FD CopperCom, Inc.
+0090FE ELECOM CO., LTD.  (LANEED DIV.)
 0090FF TELLUS TECHNOLOGY INC.
+0091D6 Crystal Group, Inc.
 009D8E CARDIAC RECORDERS, INC.
 00A000 CENTILLION NETWORKS, INC.
 00A001 WATKINS-JOHNSON COMPANY
-00A002 LEEDS & NORTHRUP AUSTRALIA
+00A002 LEEDS & NORTHRUP AUSTRALIA PTY LTD
 00A003 STAEFA CONTROL SYSTEM
 00A004 NETPOWER, INC.
 00A005 DANIEL INSTRUMENTS, LTD.
-00A006 IMAGE DATA PROCESSING
+00A006 IMAGE DATA PROCESSING SYSTEM GROUP
 00A007 APEXX TECHNOLOGY, INC.
 00A008 NETCORP
 00A009 WHITETREE NETWORK
@@ -3714,8 +5829,8 @@
 00A01F TRICORD SYSTEMS, INC.
 00A020 CITICORP/TTI
 00A021 GENERAL DYNAMICS-
-00A022 CENTRE FOR DEVELOPMENT OF
-00A023 APPLIED CREATIVE TECHNOLOGY,
+00A022 CENTRE FOR DEVELOPMENT OF ADVANCED COMPUTING
+00A023 APPLIED CREATIVE TECHNOLOGY, INC.
 00A024 3COM CORPORATION
 00A025 REDCOM LABS INC.
 00A026 TELDAT, S.A.
@@ -3724,14 +5839,14 @@
 00A029 COULTER CORPORATION
 00A02A TRANCELL SYSTEMS
 00A02B TRANSITIONS RESEARCH CORP.
-00A02C INTERWAVE COMMUNICATIONS
+00A02C interWAVE Communications
 00A02D 1394 Trade Association
 00A02E BRAND COMMUNICATIONS, LTD.
 00A02F PIRELLI CAVI
 00A030 CAPTOR NV/SA
 00A031 HAZELTINE CORPORATION, MS 1-17
 00A032 GES SINGAPORE PTE. LTD.
-00A033 IMC MESS-SYSTEME GMBH
+00A033 imc MeBsysteme GmbH
 00A034 AXEL
 00A035 CYLINK CORPORATION
 00A036 APPLIED NETWORK TECHNOLOGY
@@ -3741,14 +5856,14 @@
 00A03A KUBOTEK CORPORATION
 00A03B TOSHIN ELECTRIC CO., LTD.
 00A03C EG&G NUCLEAR INSTRUMENTS
-00A03D OPTO - 22
+00A03D OPTO-22
 00A03E ATM FORUM
-00A03F COMPUTER SOCIETY MICROPROCES'R
+00A03F COMPUTER SOCIETY MICROPROCESSOR & MICROPROCESSOR STANDARDS C
 00A040 APPLE COMPUTER
 00A041 LEYBOLD-INFICON
 00A042 SPUR PRODUCTS CORP.
 00A043 AMERICAN TECHNOLOGY LABS, INC.
-00A044 NTT INTELLIGENT TECHNOLOGY
+00A044 NTT IT CO., LTD.
 00A045 PHOENIX CONTACT GMBH & CO.
 00A046 SCITEX CORP. LTD.
 00A047 INTEGRATED FITNESS CORP.
@@ -3756,7 +5871,7 @@
 00A049 DIGITECH INDUSTRIES, INC.
 00A04A NISSHIN ELECTRIC CO., LTD.
 00A04B TFL LAN INC.
-00A04C INNOVATIVE SYSTEMS & TECH. INC
+00A04C INNOVATIVE SYSTEMS & TECHNOLOGIES, INC.
 00A04D EDA INSTRUMENTS, INC.
 00A04E VOELKER TECHNOLOGIES, INC.
 00A04F AMERITEC CORP.
@@ -3764,15 +5879,15 @@
 00A051 ANGIA COMMUNICATIONS. INC.
 00A052 STANILITE ELECTRONICS PTY. LTD
 00A053 COMPACT DEVICES, INC.
-00A055 LINKTECH, INC.
+00A055 Data Device Corporation
 00A056 MICROPROSS
-00A057 ELSA AG
+00A057 LANCOM Systems GmbH
 00A058 GLORY, LTD.
 00A059 HAMILTON HALLMARK
 00A05A KOFAX IMAGE PRODUCTS
 00A05B MARQUIP, INC.
 00A05C INVENTORY CONVERSION, INC./
-00A05D CS COMPUTER SYSTEME GMBH
+00A05D CS COMPUTER SYSTEME GmbH
 00A05E MYRIAD LOGIC INC.
 00A05F BTG ENGINEERING BV
 00A060 ACER PERIPHERALS, INC.
@@ -3784,10 +5899,10 @@
 00A066 ISA CO., LTD.
 00A067 NETWORK SERVICES GROUP
 00A068 BHP LIMITED
-00A069 TrueTime
-00A06A VERILINK CORP.
+00A069 Symmetricom, Inc.
+00A06A Verilink Corporation
 00A06B DMS DORSCH MIKROSYSTEM GMBH
-00A06C SHINDENGEN ELECTRIC MFG.
+00A06C SHINDENGEN ELECTRIC MFG. CO., LTD.
 00A06D MANNESMANN TALLY CORPORATION
 00A06E AUSTRON, INC.
 00A06F THE APPCON GROUP, INC.
@@ -3801,7 +5916,7 @@
 00A077 FUJITSU NEXION, INC.
 00A078 Marconi Communications
 00A079 ALPS ELECTRIC (USA), INC.
-00A07A ADVANCED PERIPHERALS
+00A07A ADVANCED PERIPHERALS TECHNOLOGIES, INC.
 00A07B DAWN COMPUTER INCORPORATION
 00A07C TONYANG NYLON CO., LTD.
 00A07D SEEQ TECHNOLOGY, INC.
@@ -3813,28 +5928,28 @@
 00A083 ASIMMPHONY TURKEY
 00A084 DATAPLEX PTY. LTD.
 00A086 AMBER WAVE SYSTEMS, INC.
-00A087 MITEL SEMICONDUCTOR, LTD.
+00A087 Zarlink Semiconductor Ltd.
 00A088 ESSENTIAL COMMUNICATIONS
 00A089 XPOINT TECHNOLOGIES, INC.
 00A08A BROOKTROUT TECHNOLOGY, INC.
 00A08B ASTON ELECTRONIC DESIGNS LTD.
-00A08C MULTIMEDIA LANS, INC.
+00A08C MultiMedia LANs, Inc.
 00A08D JACOMO CORPORATION
 00A08E Nokia Internet Communications
 00A08F DESKNET SYSTEMS, INC.
-00A090 TIMESTEP CORPORATION
+00A090 TimeStep Corporation
 00A091 APPLICOM INTERNATIONAL
 00A092 H. BOLLMANN MANUFACTURERS, LTD
-00A093 B/E AEROSPACE
+00A093 B/E AEROSPACE, Inc.
 00A094 COMSAT CORPORATION
 00A095 ACACIA NETWORKS, INC.
-00A096 MITSUMI ELECTRIC CO., LTD.
+00A096 MITUMI ELECTRIC CO., LTD.
 00A097 JC INFORMATION SYSTEMS
 00A098 NETWORK APPLIANCE CORP.
 00A099 K-NET LTD.
 00A09A NIHON KOHDEN AMERICA
 00A09B QPSX COMMUNICATIONS, LTD.
-00A09C XYPLEX, INC.
+00A09C Xyplex, Inc.
 00A09D JOHNATHON FREEMAN TECHNOLOGIES
 00A09E ICTV
 00A09F COMMVISION CORP.
@@ -3847,7 +5962,7 @@
 00A0A6 M.I. SYSTEMS, K.K.
 00A0A7 VORAX CORPORATION
 00A0A8 RENEX CORPORATION
-00A0A9 GN NETTEST (CANADA) INC.
+00A0A9 GN NETTEST (CANADA) NAVTEL DIVISION
 00A0AA SPACELABS MEDICAL
 00A0AB NETCS INFORMATIONSTECHNIK GMBH
 00A0AC GILAT SATELLITE NETWORKS, LTD.
@@ -3868,7 +5983,7 @@
 00A0BB HILAN GMBH
 00A0BC VIASAT, INCORPORATED
 00A0BD I-TECH CORP.
-00A0BE INTEGRATED CIRCUIT SYSTEMS,INC
+00A0BE INTEGRATED CIRCUIT SYSTEMS, INC. COMMUNICATIONS GROUP
 00A0BF WIRELESS DATA GROUP MOTOROLA
 00A0C0 DIGITAL LINK CORP.
 00A0C1 ORTIVUS MEDICAL AB
@@ -3883,12 +5998,12 @@
 00A0CA FUJITSU DENSO LTD.
 00A0CB ARK TELECOMMUNICATIONS, INC.
 00A0CC LITE-ON COMMUNICATIONS, INC.
-00A0CD DR. JOHANNES HEIDENHAIN GMBH
+00A0CD DR. JOHANNES HEIDENHAIN GmbH
 00A0CE ASTROCOM CORPORATION
 00A0CF SOTAS, INC.
 00A0D0 TEN X TECHNOLOGY, INC.
 00A0D1 INVENTEC CORPORATION
-00A0D2 ALLIED TELESIS INTERNATIONAL
+00A0D2 ALLIED TELESIS INTERNATIONAL CORPORATION
 00A0D3 INSTEM COMPUTER SYSTEMS, LTD.
 00A0D4 RADIOLAN,  INC.
 00A0D5 SIERRA WIRELESS INC.
@@ -3896,14 +6011,14 @@
 00A0D7 KASTEN CHASE APPLIED RESEARCH
 00A0D8 SPECTRA - TEK
 00A0D9 CONVEX COMPUTER CORPORATION
-00A0DA INTEGRATED SYSTEMS
+00A0DA INTEGRATED SYSTEMS Technology, Inc.
 00A0DB FISHER & PAYKEL PRODUCTION
 00A0DC O.N. ELECTRONIC CO., LTD.
 00A0DD AZONIX CORPORATION
 00A0DE YAMAHA CORPORATION
 00A0DF STS TECHNOLOGIES, INC.
 00A0E0 TENNYSON TECHNOLOGIES PTY LTD
-00A0E1 WESTPORT RESEARCH
+00A0E1 WESTPORT RESEARCH ASSOCIATES, INC.
 00A0E2 KEISOKU GIKEN CORP.
 00A0E3 XKL SYSTEMS CORP.
 00A0E4 OPTIQUEST
@@ -3911,9 +6026,9 @@
 00A0E6 DIALOGIC CORPORATION
 00A0E7 CENTRAL DATA CORPORATION
 00A0E8 REUTERS HOLDINGS PLC
-00A0E9 ELECTRONIC RETAILING SYSTEMS
+00A0E9 ELECTRONIC RETAILING SYSTEMS INTERNATIONAL
 00A0EA ETHERCOM CORP.
-00A0EB FASTCOMM COMMUNICATIONS CORP.
+00A0EB Encore Networks
 00A0EC TRANSMITTON LTD.
 00A0ED PRI AUTOMATION
 00A0EE NASHOBA NETWORKS
@@ -3924,7 +6039,7 @@
 00A0F3 STAUBLI
 00A0F4 GE
 00A0F5 RADGUARD LTD.
-00A0F6 AUTOGAS SYSTEMS, INC.
+00A0F6 AutoGas Systems Inc.
 00A0F7 V.I COMPUTER CORP.
 00A0F8 SYMBOL TECHNOLOGIES, INC.
 00A0F9 BINTEC COMMUNICATIONS GMBH
@@ -4016,7 +6131,7 @@
 00C026 LANS TECHNOLOGY CO., LTD.
 00C027 CIPHER SYSTEMS, INC.
 00C028 JASCO CORPORATION
-00C029 KABEL RHEYDT AG
+00C029 Nexans Deutschland AG - ANS
 00C02A OHKURA ELECTRIC CO., LTD.
 00C02B GERLOFF GESELLSCHAFT FUR
 00C02C CENTRUM COMMUNICATIONS, INC.
@@ -4080,7 +6195,7 @@
 00C066 DOCUPOINT, INC.
 00C067 UNITED BARCODE INDUSTRIES
 00C068 PHILIP DRAKE ELECTRONICS LTD.
-00C069 ADAPTIVE BROADBAND CORPORATION
+00C069 Axxcelera Broadband Wireless
 00C06A ZAHNER-ELEKTRIK GMBH & CO. KG
 00C06B OSI PLUS CORPORATION
 00C06C SVEC COMPUTER CORP.
@@ -4157,7 +6272,7 @@
 00C0B3 COMSTAT DATACOMM CORPORATION
 00C0B4 MYSON TECHNOLOGY, INC.
 00C0B5 CORPORATE NETWORK SYSTEMS,INC.
-00C0B6 MERIDIAN DATA, INC.
+00C0B6 Snap Appliance, Inc.
 00C0B7 AMERICAN POWER CONVERSION CORP
 00C0B8 FRASER'S HILL LTD.
 00C0B9 FUNK SOFTWARE, INC.
@@ -4198,7 +6313,7 @@
 00C0DC EOS TECHNOLOGIES, INC.
 00C0DD QLogic Corporation
 00C0DE ZCOMM, INC.
-00C0DF KYE SYSTEMS CORP.
+00C0DF KYE Systems Corp.
 00C0E0 DSC COMMUNICATION CORP.
 00C0E1 SONIC SOLUTIONS
 00C0E2 CALCOMP, INC.
@@ -4275,7 +6390,7 @@
 00D027 APPLIED AUTOMATION, INC.
 00D028 OMNEON VIDEO NETWORKS
 00D029 WAKEFERN FOOD CORPORATION
-00D02A FLEXION SYSTEMS
+00D02A Voxent Systems Ltd.
 00D02B JETCELL, INC.
 00D02C CAMPBELL SCIENTIFIC, INC.
 00D02D ADEMCO
@@ -4294,6 +6409,7 @@
 00D03A ZONEWORX, INC.
 00D03B VISION PRODUCTS PTY. LTD.
 00D03C Vieo, Inc.
+00D03D GALILEO TECHNOLOGY, LTD.
 00D03E ROCKETCHIPS, INC.
 00D03F AMERICAN COMMUNICATION
 00D040 SYSMATE CO., LTD.
@@ -4368,7 +6484,7 @@
 00D085 OTIS ELEVATOR COMPANY
 00D086 FOVEON, INC.
 00D087 MICROFIRST INC.
-00D088 MAINSAIL NETWORKS, INC.
+00D088 Terayon Communications Systems
 00D089 DYNACOLOR, INC.
 00D08A PHOTRON USA
 00D08B ADVA Limited
@@ -4384,7 +6500,7 @@
 00D095 XYLAN CORPORATION
 00D096 3COM EUROPE LTD.
 00D097 CISCO SYSTEMS, INC.
-00D098 IPS AUTOMATION
+00D098 Photon Dynamics Canada Inc.
 00D099 ELCARD OY
 00D09A FILANET CORPORATION
 00D09B SPECTEL LTD.
@@ -4413,9 +6529,9 @@
 00D0B2 XIOTECH CORPORATION
 00D0B3 DRS FLIGHT SAFETY AND
 00D0B4 KATSUJIMA CO., LTD.
-00D0B5 DOTCOM
+00D0B5 IPricot formerly DotCom
 00D0B6 CRESCENT NETWORKS, INC.
-00D0B7 INTEL CORPOTATION
+00D0B7 INTEL CORPORATION
 00D0B8 IOMEGA CORP.
 00D0B9 MICROTEK INTERNATIONAL, INC.
 00D0BA CISCO SYSTEMS, INC.
@@ -4478,7 +6594,7 @@
 00D0F3 SOLARI DI UDINE SPA
 00D0F4 CARINTHIAN TECH INSTITUTE
 00D0F5 ORANGE MICRO, INC.
-00D0F6 NORTHCHURCH COMMUNICATIONS INC
+00D0F6 Alcatel Canada
 00D0F7 NEXT NETS CORPORATION
 00D0F8 FUJIAN STAR TERMINAL
 00D0F9 ACUTE COMMUNICATIONS CORP.
@@ -4520,28 +6636,28 @@
 00E00D RADIANT SYSTEMS
 00E00E AVALON IMAGING SYSTEMS, INC.
 00E00F SHANGHAI BAUD DATA
-00E010 HESS SB-AUTOMATENBAU GMBH
-00E011 UNIDEN SAN DIEGO
-00E012 PLUTO TECHNOLOGIES
+00E010 HESS SB-AUTOMATENBAU GmbH
+00E011 UNIDEN SAN DIEGO R&D CENTER, INC.
+00E012 PLUTO TECHNOLOGIES INTERNATIONAL INC.
 00E013 EASTERN ELECTRONIC CO., LTD.
 00E014 CISCO SYSTEMS, INC.
 00E015 HEIWA CORPORATION
 00E016 RAPID CITY COMMUNICATIONS
-00E017 EXXACT GMBH
+00E017 EXXACT GmbH
 00E018 ASUSTEK COMPUTER INC.
 00E019 ING. GIORDANO ELETTRONICA
 00E01A COMTEC SYSTEMS. CO., LTD.
 00E01B SPHERE COMMUNICATIONS, INC.
 00E01C MOBILITY ELECTRONICSY
-00E01D WEBTV NETWORKS, INC.
+00E01D WebTV NETWORKS, INC.
 00E01E CISCO SYSTEMS, INC.
-00E01F AVIDIA SYSTEMS, INC.
+00E01F AVIDIA Systems, Inc.
 00E020 TECNOMEN OY
 00E021 FREEGATE CORP.
-00E022 MEDIALIGHT INC.
+00E022 MediaLight, Inc.
 00E023 TELRAD
 00E024 GADZOOX NETWORKS
-00E025 DIT CO., LTD.
+00E025 dit CO., LTD.
 00E026 EASTMAN KODAK CO.
 00E027 DUX, INC.
 00E028 APTIX CORPORATION
@@ -4549,13 +6665,13 @@
 00E02A TANDBERG TELEVISION AS
 00E02B EXTREME NETWORKS
 00E02C AST COMPUTER
-00E02D INNOMEDIALOGIC, INC.
+00E02D InnoMediaLogic, Inc.
 00E02E SPC ELECTRONICS CORPORATION
 00E02F MCNS HOLDINGS, L.P.
 00E030 MELITA INTERNATIONAL CORP.
 00E031 HAGIWARA ELECTRIC CO., LTD.
 00E032 MISYS FINANCIAL SYSTEMS, LTD.
-00E033 E.E.P.D. GMBH
+00E033 E.E.P.D. GmbH
 00E034 CISCO SYSTEMS, INC.
 00E035 LOUGHBOROUGH SOUND IMAGES, PLC
 00E036 PIONEER CORPORATION
@@ -4564,64 +6680,64 @@
 00E039 PARADYNE CORP.
 00E03A CABLETRON SYSTEMS, INC.
 00E03B PROMINET CORPORATION
-00E03C ADVANSYS
+00E03C AdvanSys
 00E03D FOCON ELECTRONIC SYSTEMS A/S
 00E03E ALFATECH, INC.
 00E03F JATON CORPORATION
-00E040 DESKSTATION TECHNOLOGY, INC.
+00E040 DeskStation Technology, Inc.
 00E041 CSPI
-00E042 PACOM DATA LTD.
-00E043 VITALCOM
+00E042 Pacom Systems Ltd.
+00E043 VitalCom
 00E044 LSICS CORPORATION
 00E045 TOUCHWAVE, INC.
 00E046 BENTLY NEVADA CORP.
 00E047 INFOCUS SYSTEMS
 00E048 SDL COMMUNICATIONS, INC.
-00E049 MICROWI ELECTRONIC GMBH
-00E04A ENHANCED MESSAGING SYSTEMS,INC
-00E04B JUMP INDUSTRIELLE
+00E049 MICROWI ELECTRONIC GmbH
+00E04A ENHANCED MESSAGING SYSTEMS, INC
+00E04B JUMP INDUSTRIELLE COMPUTERTECHNIK GmbH
 00E04C REALTEK SEMICONDUCTOR CORP.
 00E04D INTERNET INITIATIVE JAPAN, INC
 00E04E SANYO DENKI CO., LTD.
 00E04F CISCO SYSTEMS, INC.
-00E050 EXECUTONE INFORMATION
+00E050 EXECUTONE INFORMATION SYSTEMS, INC.
 00E051 TALX CORPORATION
 00E052 FOUNDRY NETWORKS, INC.
 00E053 CELLPORT LABS, INC.
 00E054 KODAI HITEC CO., LTD.
-00E055 INGENIERIA ELECTRONICA
+00E055 INGENIERIA ELECTRONICA COMERCIAL INELCOM S.A.
 00E056 HOLONTECH CORPORATION
 00E057 HAN MICROTELECOM. CO., LTD.
 00E058 PHASE ONE DENMARK A/S
 00E059 CONTROLLED ENVIRONMENTS, LTD.
 00E05A GALEA NETWORK SECURITY
 00E05B WEST END SYSTEMS CORP.
-00E05C MATSUSHITA KOTOBUKI
+00E05C MATSUSHITA KOTOBUKI ELECTRONICS INDUSTRIES, LTD.
 00E05D UNITEC CO., LTD.
-00E05E JAPAN AVIATION ELECTRONICS
-00E05F E-NET, INC.
+00E05E JAPAN AVIATION ELECTRONICS INDUSTRY, LTD.
+00E05F e-Net, Inc.
 00E060 SHERWOOD
-00E061 EDGEPOINT NETWORKS, INC.
+00E061 EdgePoint Networks, Inc.
 00E062 HOST ENGINEERING
 00E063 CABLETRON - YAGO SYSTEMS, INC.
 00E064 SAMSUNG ELECTRONICS
 00E065 OPTICAL ACCESS INTERNATIONAL
-00E066 PROMAX SYSTEMS, INC.
-00E067 EAC AUTOMATION-CONSULTING GMBH
+00E066 ProMax Systems, Inc.
+00E067 eac AUTOMATION-CONSULTING GmbH
 00E068 MERRIMAC SYSTEMS INC.
-00E069 JAYCOR NETWORKS, INC.
+00E069 JAYCOR
 00E06A KAPSCH AG
 00E06B W&G SPECIAL PRODUCTS
-00E06C BALTIMORE TECHNOLOGIES, LTD.
+00E06C AEP Systems International Ltd
 00E06D COMPUWARE CORPORATION
-00E06E FAR SYSTEMS SPA
-00E06F TERAYON CORP.
+00E06E FAR SYSTEMS S.p.A.
+00E06F Terayon Communications Systems
 00E070 DH TECHNOLOGY
 00E071 EPIS MICROCOMPUTER
 00E072 LYNK
-00E073 NATIONAL AMUSEMENT
+00E073 NATIONAL AMUSEMENT NETWORK, INC.
 00E074 TIERNAN COMMUNICATIONS, INC.
-00E075 ATLAS COMPUTER EQUIPMENT, INC.
+00E075 Verilink Corporation
 00E076 DEVELOPMENT CONCEPTS, INC.
 00E077 WEBGEAR, INC.
 00E078 BERKELEY NETWORKS
@@ -4631,7 +6747,7 @@
 00E07C METTLER-TOLEDO, INC.
 00E07D NETRONIX, INC.
 00E07E WALT DISNEY IMAGINEERING
-00E07F LOGISTISTEM SRL
+00E07F LOGISTISTEM s.r.l.
 00E080 CONTROL RESOURCES CORPORATION
 00E081 TYAN COMPUTER CORP.
 00E082 ANERMA
@@ -4639,11 +6755,11 @@
 00E084 COMPULITE R&D
 00E085 GLOBAL MAINTECH, INC.
 00E086 CYBEX COMPUTER PRODUCTS
-00E087 LECROY
+00E087 LeCroy - Networking Productions Division
 00E088 LTX CORPORATION
 00E089 ION Networks, Inc.
 00E08A GEC AVERY, LTD.
-00E08B QLOGIC CORP.
+00E08B QLogic Corp.
 00E08C NEOPARADIGM LABS, INC.
 00E08D PRESSURE SYSTEMS, INC.
 00E08E UTSTARCOM
@@ -4653,10 +6769,10 @@
 00E092 ADMTEK INCORPORATED
 00E093 ACKFIN NETWORKS
 00E094 OSAI SRL
-00E095 ADVANCED-VISION TECHNOLGIES
+00E095 ADVANCED-VISION TECHNOLGIES CORP.
 00E096 SHIMADZU CORPORATION
 00E097 CARRIER ACCESS CORPORATION
-00E098 ABOCOM SYSTEMS, INC.
+00E098 AboCom Systems, Inc.
 00E099 SAMSON AG
 00E09A POSITRON INDUSTRIES, INC.
 00E09B ENGAGE NETWORKS, INC.
@@ -4665,78 +6781,78 @@
 00E09E QUANTUM CORPORATION
 00E09F PIXEL VISION
 00E0A0 WILTRON CO.
-00E0A1 HIMA PAUL HILDEBRANDT
+00E0A1 HIMA PAUL HILDEBRANDT GmbH Co. KG
 00E0A2 MICROSLATE INC.
 00E0A3 CISCO SYSTEMS, INC.
-00E0A4 ESAOTE S.P.A.
-00E0A5 COMCORE SEMICONDUCTOR, INC.
+00E0A4 ESAOTE S.p.A.
+00E0A5 ComCore Semiconductor, Inc.
 00E0A6 TELOGY NETWORKS, INC.
 00E0A7 IPC INFORMATION SYSTEMS, INC.
-00E0A8 SAT GMBH&CO
+00E0A8 SAT GmbH & Co.
 00E0A9 FUNAI ELECTRIC CO., LTD.
 00E0AA ELECTROSONIC LTD.
 00E0AB DIMAT S.A.
 00E0AC MIDSCO, INC.
 00E0AD EES TECHNOLOGY, LTD.
 00E0AE XAQTI CORPORATION
-00E0AF GENERAL DYNAMICS INFORMATION
+00E0AF GENERAL DYNAMICS INFORMATION SYSTEMS
 00E0B0 CISCO SYSTEMS, INC.
 00E0B1 PACKET ENGINES, INC.
 00E0B2 TELMAX COMMUNICATIONS CORP.
-00E0B3 ETHERWAN SYSTEMS, INC.
+00E0B3 EtherWAN Systems, Inc.
 00E0B4 TECHNO SCOPE CO., LTD.
 00E0B5 ARDENT COMMUNICATIONS CORP.
 00E0B6 Entrada Networks
 00E0B7 PI GROUP, LTD.
 00E0B8 GATEWAY 2000
 00E0B9 BYAS SYSTEMS
-00E0BA BERGHOF AUTOMATIONSTECHNIK
+00E0BA BERGHOF AUTOMATIONSTECHNIK GmbH
 00E0BB NBX CORPORATION
 00E0BC SYMON COMMUNICATIONS, INC.
 00E0BD INTERFACE SYSTEMS, INC.
 00E0BE GENROCO INTERNATIONAL, INC.
-00E0BF TORRENT NETWORKING
-00E0C0 SEIWA ERECTRIC MFG. CO., LTD.
+00E0BF TORRENT NETWORKING TECHNOLOGIES CORP.
+00E0C0 SEIWA ELECTRIC MFG. CO., LTD.
 00E0C1 MEMOREX TELEX JAPAN, LTD.
-00E0C2 NECSY SPA
+00E0C2 NECSY S.p.A.
 00E0C3 SAKAI SYSTEM DEVELOPMENT CORP.
 00E0C4 HORNER ELECTRIC, INC.
 00E0C5 BCOM ELECTRONICS INC.
 00E0C6 LINK2IT, L.L.C.
 00E0C7 EUROTECH SRL
 00E0C8 VIRTUAL ACCESS, LTD.
-00E0C9 AUTOMATEDLOGIC CORPORATION
+00E0C9 AutomatedLogic Corporation
 00E0CA BEST DATA PRODUCTS
 00E0CB RESON, INC.
 00E0CC HERO SYSTEMS, LTD.
 00E0CD SENSIS CORPORATION
 00E0CE ARN
-00E0CF INTEGRATED DEVICE
+00E0CF INTEGRATED DEVICE TECHNOLOGY, INC.
 00E0D0 NETSPEED, INC.
 00E0D1 TELSIS LIMITED
 00E0D2 VERSANET COMMUNICATIONS, INC.
-00E0D3 DATENTECHNIK GMBH
+00E0D3 DATENTECHNIK GmbH
 00E0D4 EXCELLENT COMPUTER
 00E0D5 ARCXEL TECHNOLOGIES, INC.
-00E0D6 COMPUTER & COMMUNICATION
+00E0D6 COMPUTER & COMMUNICATION RESEARCH LAB.
 00E0D7 SUNSHINE ELECTRONICS, INC.
-00E0D8 LANBIT COMPUTER, INC.
+00E0D8 LANBit Computer, Inc.
 00E0D9 TAZMO CO., LTD.
-00E0DA ASSURED ACCESS
-00E0DB VIAVIDEO COMMUNICATIONS
+00E0DA ASSURED ACCESS TECHNOLOGY, INC.
+00E0DB ViaVideo Communications, Inc.
 00E0DC NEXWARE CORP.
 00E0DD ZENITH ELECTRONICS CORPORATION
 00E0DE DATAX NV
 00E0DF KE KOMMUNIKATIONS-ELECTRONIK
 00E0E0 SI ELECTRONICS, LTD.
-00E0E1 G2 NETWORKS, ILNC.
+00E0E1 G2 NETWORKS, INC.
 00E0E2 INNOVA CORP.
-00E0E3 SK-ELEKTRONIK GMBH
-00E0E4 FANUC ROBOTICS NORTH AMERICA,
+00E0E3 SK-ELEKTRONIK GmbH
+00E0E4 FANUC ROBOTICS NORTH AMERICA, Inc.
 00E0E5 CINCO NETWORKS, INC.
 00E0E6 INCAA DATACOM B.V.
 00E0E7 RAYTHEON E-SYSTEMS, INC.
-00E0E8 GRETACODER DATA SYSTEMS AG
+00E0E8 GRETACODER Data Systems AG
 00E0E9 DATA LABS, INC.
 00E0EA INNOVAT COMMUNICATIONS, INC.
 00E0EB DIGICOM SYSTEMS, INCORPORATED
@@ -4747,19 +6863,19 @@
 00E0F0 ABLER TECHNOLOGY, INC.
 00E0F1 THAT CORPORATION
 00E0F2 ARLOTTO COMNET, INC.
-00E0F3 WEBSPRINT COMMUNICATIONS, INC.
-00E0F4 INSIDE TECHNOLOGY A/S
+00E0F3 WebSprint Communications, Inc.
+00E0F4 INSIDE Technology A/S
 00E0F5 TELES AG
 00E0F6 DECISION EUROPE
 00E0F7 CISCO SYSTEMS, INC.
-00E0F8 DIANA CONTROL AB
+00E0F8 DICNA CONTROL AB
 00E0F9 CISCO SYSTEMS, INC.
 00E0FA TRL TECHNOLOGY, LTD.
 00E0FB LEIGHTRONIX, INC.
 00E0FC HUAWEI TECHNOLOGIES CO., LTD.
 00E0FD A-TREND TECHNOLOGY CO., LTD.
 00E0FE CISCO SYSTEMS, INC.
-00E0FF SECURITY DYNAMICS TECHNOLOGIES
+00E0FF SECURITY DYNAMICS TECHNOLOGIES, Inc.
 00E6D3 NIXDORF COMPUTER CORP.
 020701 RACAL-DATACOM
 021C7C PERQ SYSTEMS CORPORATION
@@ -4809,12 +6925,12 @@
 080020 SUN MICROSYSTEMS INC.
 080021 3M COMPANY
 080022 NBI INC.
-080023 MATSUHITA GRAPHIC COMM SYS INC
+080023 Panasonic Communications Co., Ltd.
 080024 10NET COMMUNICATIONS/DCA
 080025 CONTROL DATA
 080026 NORSK DATA A.S.
 080027 CADMUS COMPUTER SYSTEMS
-080028 TEXAS INSTRUMENTS
+080028 Texas Instruments
 080029 MEGATEK CORPORATION
 08002A MOSAIC TECHNOLOGIES INC.
 08002B DIGITAL EQUIPMENT CORPORATION
@@ -4905,10 +7021,10 @@
 080080 AES DATA INC.
 080081 ,ASTECH INC.
 080082 VERITAS SOFTWARE
-080083 SEIKO INSTRUM. AND ELECTRONICS
+080083 Seiko Instruments Inc.
 080084 TOMEN ELECTRONICS CORP.
 080085 ELXSI
-080086 IMAGEN CORPORATION
+080086 KONICA MINOLTA HOLDINGS, INC.
 080087 XYPLEX
 080088 MCDATA CORPORATION
 080089 KINETICS
@@ -4919,7 +7035,8 @@
 08008E TANDEM COMPUTERS
 08008F CHIPCOM CORPORATION
 080090 SONOMA SYSTEMS
-08BBCC AK-NORD EDV VERTRIEBSGES. MBH
+081443 UNIBRAIN S.A.
+08BBCC AK-NORD EDV VERTRIEBSGES. mbH
 10005A IBM CORPORATION
 1000E8 NATIONAL SEMICONDUCTOR
 800010 ATT BELL LABORATORIES
diff -puN drivers/ieee1394/raw1394.c~linus drivers/ieee1394/raw1394.c
--- 25/drivers/ieee1394/raw1394.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ieee1394/raw1394.c	2004-01-19 22:17:22.000000000 -0800
@@ -38,6 +38,7 @@
 #include <linux/smp_lock.h>
 #include <linux/interrupt.h>
 #include <linux/vmalloc.h>
+#include <linux/cdev.h>
 #include <asm/uaccess.h>
 #include <asm/atomic.h>
 #include <linux/devfs_fs_kernel.h>
@@ -1695,7 +1696,7 @@ static int arm_register(struct file_info
                 spin_unlock_irqrestore(&host_info_lock, flags);
                 return sizeof(struct raw1394_request);
         }
-        retval = hpsb_register_addrspace(&raw1394_highlevel, &arm_ops, req->req.address,
+        retval = hpsb_register_addrspace(&raw1394_highlevel, fi->host, &arm_ops, req->req.address,
                 req->req.address + req->req.length);
         if (retval) {
                /* INSERT ENTRY */
@@ -1782,7 +1783,7 @@ static int arm_unregister(struct file_in
                 spin_unlock_irqrestore(&host_info_lock, flags);
                 return sizeof(struct raw1394_request);
         } 
-        retval = hpsb_unregister_addrspace(&raw1394_highlevel, addr->start);
+        retval = hpsb_unregister_addrspace(&raw1394_highlevel, fi->host, addr->start);
         if (!retval) {
                 printk(KERN_ERR "raw1394: arm_Unregister failed -> EINVAL\n");
                 spin_unlock_irqrestore(&host_info_lock, flags);
@@ -2464,10 +2465,6 @@ static int raw1394_open(struct inode *in
 {
         struct file_info *fi;
 
-        if (ieee1394_file_to_instance(file) > 0) {
-                return -ENXIO;
-        }
-
         fi = kmalloc(sizeof(struct file_info), SLAB_KERNEL);
         if (fi == NULL)
                 return -ENOMEM;
@@ -2554,7 +2551,7 @@ static int raw1394_release(struct inode 
                 }
                 if (!another_host) {
                         DBGMSG("raw1394_release: call hpsb_arm_unregister");
-                        retval = hpsb_unregister_addrspace(&raw1394_highlevel, addr->start);
+                        retval = hpsb_unregister_addrspace(&raw1394_highlevel, fi->host, addr->start);
                         if (!retval) {
                                 ++fail;
                                 printk(KERN_ERR "raw1394_release arm_Unregister failed\n");
@@ -2646,7 +2643,8 @@ static struct hpsb_highlevel raw1394_hig
         .fcp_request = fcp_request,
 };
 
-static struct file_operations file_ops = {
+static struct cdev raw1394_cdev;
+static struct file_operations raw1394_fops = {
 	.owner =	THIS_MODULE,
         .read =		raw1394_read, 
         .write =	raw1394_write,
@@ -2664,8 +2662,10 @@ static int __init init_raw1394(void)
         devfs_mk_cdev(MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16),
 			S_IFCHR | S_IRUSR | S_IWUSR, RAW1394_DEVICE_NAME);
 
-        if (ieee1394_register_chardev(IEEE1394_MINOR_BLOCK_RAW1394,
-                                      THIS_MODULE, &file_ops)) {
+	cdev_init(&raw1394_cdev, &raw1394_fops);
+	raw1394_cdev.owner = THIS_MODULE;
+	kobject_set_name(&raw1394_cdev.kobj, RAW1394_DEVICE_NAME);
+	if (cdev_add(&raw1394_cdev, IEEE1394_RAW1394_DEV, 1)) {
                 HPSB_ERR("raw1394 failed to register minor device block");
                 devfs_remove(RAW1394_DEVICE_NAME);
                 hpsb_unregister_highlevel(&raw1394_highlevel);
@@ -2682,7 +2682,8 @@ static int __init init_raw1394(void)
 static void __exit cleanup_raw1394(void)
 {
 	hpsb_unregister_protocol(&raw1394_driver);
-        ieee1394_unregister_chardev(IEEE1394_MINOR_BLOCK_RAW1394);
+	cdev_unmap(IEEE1394_RAW1394_DEV, 1);
+	cdev_del(&raw1394_cdev);
         devfs_remove(RAW1394_DEVICE_NAME);
         hpsb_unregister_highlevel(&raw1394_highlevel);
 }
@@ -2690,3 +2691,4 @@ static void __exit cleanup_raw1394(void)
 module_init(init_raw1394);
 module_exit(cleanup_raw1394);
 MODULE_LICENSE("GPL");
+MODULE_ALIAS_CHARDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16);
diff -puN drivers/ieee1394/sbp2.c~linus drivers/ieee1394/sbp2.c
--- 25/drivers/ieee1394/sbp2.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ieee1394/sbp2.c	2004-01-19 22:17:22.000000000 -0800
@@ -77,7 +77,7 @@
 #include "sbp2.h"
 
 static char version[] __devinitdata =
-	"$Rev: 1082 $ Ben Collins <bcollins@debian.org>";
+	"$Rev: 1096 $ Ben Collins <bcollins@debian.org>";
 
 /*
  * Module load parameter definitions
@@ -712,6 +712,18 @@ static struct sbp2scsi_host_info *sbp2_a
 		return NULL;
 	}
 
+	/* Register our sbp2 status address space... */
+	hpsb_register_addrspace(&sbp2_highlevel, host, &sbp2_ops,
+				SBP2_STATUS_FIFO_ADDRESS,
+				SBP2_STATUS_FIFO_ADDRESS +
+				SBP2_STATUS_FIFO_ENTRY_TO_OFFSET(SBP2SCSI_MAX_SCSI_IDS+1));
+
+	/* Handle data movement if physical dma is not enabled/supported
+	 * on host controller */
+#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA
+	hpsb_register_addrspace(&sbp2_highlevel, host, &sbp2_physdma_ops, 0x0ULL, 0xfffffffcULL);
+#endif
+
 	hi = hpsb_create_hostinfo(&sbp2_highlevel, host, sizeof(*hi));
 	if (!hi) {
 		SBP2_ERR("failed to allocate hostinfo");
@@ -2881,17 +2893,6 @@ static int sbp2_module_init(void)
 	/* Register our high level driver with 1394 stack */
 	hpsb_register_highlevel(&sbp2_highlevel);
 
-	/* Register our sbp2 status address space... */
-	hpsb_register_addrspace(&sbp2_highlevel, &sbp2_ops, SBP2_STATUS_FIFO_ADDRESS,
-				SBP2_STATUS_FIFO_ADDRESS + 
-				SBP2_STATUS_FIFO_ENTRY_TO_OFFSET(SBP2SCSI_MAX_SCSI_IDS+1));
-
-	/* Handle data movement if physical dma is not enabled/supported
-	 * on host controller */
-#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA
-	hpsb_register_addrspace(&sbp2_highlevel, &sbp2_physdma_ops, 0x0ULL, 0xfffffffcULL);
-#endif
-
 	hpsb_register_protocol(&sbp2_driver);
 
 	return 0;
diff -puN drivers/ieee1394/video1394.c~linus drivers/ieee1394/video1394.c
--- 25/drivers/ieee1394/video1394.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/ieee1394/video1394.c	2004-01-19 22:17:22.000000000 -0800
@@ -46,6 +46,7 @@
 #include <linux/mm.h>
 #include <linux/ioctl32.h>
 #include <linux/compat.h>
+#include <linux/cdev.h>
 
 #include "ieee1394.h"
 #include "ieee1394_types.h"
@@ -1231,6 +1232,7 @@ static int video1394_release(struct inod
 	return 0;
 }
 
+static struct cdev video1394_cdev;
 static struct file_operations video1394_fops=
 {
 	.owner =	THIS_MODULE,
@@ -1445,18 +1447,18 @@ static void __exit video1394_exit_module
 	hpsb_unregister_highlevel(&video1394_highlevel);
 
 	devfs_remove(VIDEO1394_DRIVER_NAME);
-	ieee1394_unregister_chardev(IEEE1394_MINOR_BLOCK_VIDEO1394);
+	cdev_unmap(IEEE1394_VIDEO1394_DEV, 16);
+	cdev_del(&video1394_cdev);
 
 	PRINT_G(KERN_INFO, "Removed " VIDEO1394_DRIVER_NAME " module");
 }
 
 static int __init video1394_init_module (void)
 {
-	int ret;
-
-	ret = ieee1394_register_chardev(IEEE1394_MINOR_BLOCK_VIDEO1394,
-					THIS_MODULE, &video1394_fops);
-	if (ret) {
+	cdev_init(&video1394_cdev, &video1394_fops);
+	video1394_cdev.owner = THIS_MODULE;
+	kobject_set_name(&video1394_cdev.kobj, VIDEO1394_DRIVER_NAME);
+	if (cdev_add(&video1394_cdev, IEEE1394_VIDEO1394_DEV, 16)) {
 		PRINT_G(KERN_ERR, "video1394: unable to get minor device block");
 		return -EIO;
         }
@@ -1468,25 +1470,29 @@ static int __init video1394_init_module 
 	hpsb_register_protocol(&video1394_driver);
 
 #ifdef CONFIG_COMPAT
-	/* First the compatible ones */
-	ret = register_ioctl32_conversion(VIDEO1394_IOC_LISTEN_CHANNEL, NULL);
-	ret |= register_ioctl32_conversion(VIDEO1394_IOC_UNLISTEN_CHANNEL, NULL);
-	ret |= register_ioctl32_conversion(VIDEO1394_IOC_TALK_CHANNEL, NULL);
-	ret |= register_ioctl32_conversion(VIDEO1394_IOC_UNTALK_CHANNEL, NULL);
-
-	/* These need translation */
-	ret |= register_ioctl32_conversion(VIDEO1394_IOC32_LISTEN_QUEUE_BUFFER,
-				    video1394_w_wait32);
-	ret |= register_ioctl32_conversion(VIDEO1394_IOC32_LISTEN_WAIT_BUFFER,
-				    video1394_wr_wait32);
-	ret |= register_ioctl32_conversion(VIDEO1394_IOC_TALK_QUEUE_BUFFER,
-				    video1394_queue_buf32);
-	ret |= register_ioctl32_conversion(VIDEO1394_IOC32_TALK_WAIT_BUFFER,
-				    video1394_w_wait32);
-	ret |= register_ioctl32_conversion(VIDEO1394_IOC32_LISTEN_POLL_BUFFER,
-				    video1394_wr_wait32);
-	if (ret)
-		PRINT_G(KERN_INFO, "Error registering ioctl32 translations");
+	{
+		int ret;
+
+		/* First the compatible ones */
+		ret = register_ioctl32_conversion(VIDEO1394_IOC_LISTEN_CHANNEL, NULL);
+		ret |= register_ioctl32_conversion(VIDEO1394_IOC_UNLISTEN_CHANNEL, NULL);
+		ret |= register_ioctl32_conversion(VIDEO1394_IOC_TALK_CHANNEL, NULL);
+		ret |= register_ioctl32_conversion(VIDEO1394_IOC_UNTALK_CHANNEL, NULL);
+
+		/* These need translation */
+		ret |= register_ioctl32_conversion(VIDEO1394_IOC32_LISTEN_QUEUE_BUFFER,
+					    video1394_w_wait32);
+		ret |= register_ioctl32_conversion(VIDEO1394_IOC32_LISTEN_WAIT_BUFFER,
+					    video1394_wr_wait32);
+		ret |= register_ioctl32_conversion(VIDEO1394_IOC_TALK_QUEUE_BUFFER,
+					    video1394_queue_buf32);
+		ret |= register_ioctl32_conversion(VIDEO1394_IOC32_TALK_WAIT_BUFFER,
+					    video1394_w_wait32);
+		ret |= register_ioctl32_conversion(VIDEO1394_IOC32_LISTEN_POLL_BUFFER,
+					    video1394_wr_wait32);
+		if (ret)
+			PRINT_G(KERN_INFO, "Error registering ioctl32 translations");
+	}
 #endif
 
 	PRINT_G(KERN_INFO, "Installed " VIDEO1394_DRIVER_NAME " module");
@@ -1496,3 +1502,4 @@ static int __init video1394_init_module 
 
 module_init(video1394_init_module);
 module_exit(video1394_exit_module);
+MODULE_ALIAS_CHARDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_VIDEO1394 * 16);
diff -puN drivers/input/evdev.c~linus drivers/input/evdev.c
--- 25/drivers/input/evdev.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/input/evdev.c	2004-01-19 22:17:22.000000000 -0800
@@ -92,6 +92,7 @@ static int evdev_flush(struct file * fil
 static void evdev_free(struct evdev *evdev)
 {
 	devfs_remove("input/event%d", evdev->minor);
+	class_simple_device_remove(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + evdev->minor));
 	evdev_table[evdev->minor] = NULL;
 	kfree(evdev);
 }
@@ -426,6 +427,9 @@ static struct input_handle *evdev_connec
 
 	devfs_mk_cdev(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor),
 			S_IFCHR|S_IRUGO|S_IWUSR, "input/event%d", minor);
+	class_simple_device_add(input_class, 
+				MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor),
+				dev->dev, "event%d", minor);
 
 	return &evdev->handle;
 }
diff -puN drivers/input/input.c~linus drivers/input/input.c
--- 25/drivers/input/input.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/input/input.c	2004-01-19 22:17:22.000000000 -0800
@@ -720,15 +720,13 @@ static int __init input_proc_init(void)
 static inline int input_proc_init(void) { return 0; }
 #endif
 
-struct class input_class = {
-	.name		= "input",
-};
+struct class_simple *input_class;
 
 static int __init input_init(void)
 {
 	int retval = -ENOMEM;
 
-	class_register(&input_class);
+	input_class = class_simple_create(THIS_MODULE, "input");
 	input_proc_init();
 	retval = register_chrdev(INPUT_MAJOR, "input", &input_fops);
 	if (retval) {
@@ -757,7 +755,7 @@ static void __exit input_exit(void)
 
 	devfs_remove("input");
 	unregister_chrdev(INPUT_MAJOR, "input");
-	class_unregister(&input_class);
+	class_simple_destroy(input_class);
 }
 
 subsys_initcall(input_init);
diff -puN drivers/input/joydev.c~linus drivers/input/joydev.c
--- 25/drivers/input/joydev.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/input/joydev.c	2004-01-19 22:17:22.000000000 -0800
@@ -145,6 +145,7 @@ static void joydev_free(struct joydev *j
 {
 	devfs_remove("js%d", joydev->minor);
 	joydev_table[joydev->minor] = NULL;
+	class_simple_device_remove(MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + joydev->minor));
 	kfree(joydev);
 }
 
@@ -444,6 +445,9 @@ static struct input_handle *joydev_conne
 	
 	devfs_mk_cdev(MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor),
 			S_IFCHR|S_IRUGO|S_IWUSR, "js%d", minor);
+	class_simple_device_add(input_class, 
+				MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor),
+				dev->dev, "js%d", minor);
 
 	return &joydev->handle;
 }
diff -puN drivers/input/keyboard/atkbd.c~linus drivers/input/keyboard/atkbd.c
--- 25/drivers/input/keyboard/atkbd.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/input/keyboard/atkbd.c	2004-01-19 22:17:22.000000000 -0800
@@ -19,6 +19,7 @@
 
 #include <linux/delay.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
@@ -35,6 +36,8 @@ MODULE_PARM(atkbd_softrepeat, "1i");
 MODULE_LICENSE("GPL");
 
 static int atkbd_set = 2;
+module_param_named(set, atkbd_set, int, 0);
+MODULE_PARM_DESC(set, "Select keyboard code set (2 = default, 3, 4)");
 #if defined(__i386__) || defined (__x86_64__)
 static int atkbd_reset;
 #else
@@ -42,6 +45,13 @@ static int atkbd_reset = 1;
 #endif
 static int atkbd_softrepeat;
 
+module_param_named(reset, atkbd_reset, bool, 0);
+MODULE_PARM_DESC(reset, "Reset keyboard during initialization");
+
+static int atkbd_softrepeat;
+module_param_named(softrepeat, atkbd_softrepeat, bool, 0);
+MODULE_PARM_DESC(softrepeat, "Use software keyboard repeat");
+
 /*
  * Scancode to keycode tables. These are just the default setting, and
  * are loadable via an userland utility.
@@ -760,34 +770,6 @@ static struct serio_dev atkbd_dev = {
 	.cleanup =	atkbd_cleanup,
 };
 
-#ifndef MODULE
-static int __init atkbd_setup_set(char *str)
-{
-        int ints[4];
-        str = get_options(str, ARRAY_SIZE(ints), ints);
-        if (ints[0] > 0) atkbd_set = ints[1];
-        return 1;
-}
-static int __init atkbd_setup_reset(char *str)
-{
-        int ints[4];
-        str = get_options(str, ARRAY_SIZE(ints), ints);
-        if (ints[0] > 0) atkbd_reset = ints[1];
-        return 1;
-}
-static int __init atkbd_setup_softrepeat(char *str)
-{
-        int ints[4];
-        str = get_options(str, ARRAY_SIZE(ints), ints);
-        if (ints[0] > 0) atkbd_softrepeat = ints[1];
-        return 1;
-}
-
-__setup("atkbd_set=", atkbd_setup_set);
-__setup("atkbd_reset", atkbd_setup_reset);
-__setup("atkbd_softrepeat=", atkbd_setup_softrepeat);
-#endif
-
 int __init atkbd_init(void)
 {
 	serio_register_device(&atkbd_dev);
diff -puN drivers/input/keyboard/maple_keyb.c~linus drivers/input/keyboard/maple_keyb.c
--- 25/drivers/input/keyboard/maple_keyb.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/input/keyboard/maple_keyb.c	2004-01-19 22:17:22.000000000 -0800
@@ -14,6 +14,7 @@
 
 MODULE_AUTHOR("YAEGASHI Takeshi <t@keshi.org>");
 MODULE_DESCRIPTION("SEGA Dreamcast keyboard driver");
+MODULE_LICENSE("GPL");
 
 static unsigned char dc_kbd_keycode[256] = {
 	  0,  0,  0,  0, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38,
diff -puN drivers/input/keyboard/newtonkbd.c~linus drivers/input/keyboard/newtonkbd.c
--- 25/drivers/input/keyboard/newtonkbd.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/input/keyboard/newtonkbd.c	2004-01-19 22:17:22.000000000 -0800
@@ -33,6 +33,8 @@
 #include <linux/serio.h>
 
 MODULE_AUTHOR("Justin Cormack <j.cormack@doc.ic.ac.uk>");
+MODULE_DESCRIPTION("Newton keyboard driver");
+MODULE_LICENSE("GPL");
 
 #define NKBD_KEY	0x7f
 #define NKBD_PRESS	0x80
diff -puN drivers/input/mouse/98busmouse.c~linus drivers/input/mouse/98busmouse.c
--- 25/drivers/input/mouse/98busmouse.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/input/mouse/98busmouse.c	2004-01-19 22:17:22.000000000 -0800
@@ -33,6 +33,7 @@
 
 #include <linux/config.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/delay.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -69,12 +70,13 @@ MODULE_LICENSE("GPL");
 
 #define PC98BM_IRQ		13
 
-MODULE_PARM(pc98bm_irq, "i");
-
 static int pc98bm_irq = PC98BM_IRQ;
+module_param_named(irq, pc98bm_irq, uint, 0);
+MODULE_PARM_DESC(irq, "IRQ number (13=default)");
+
 static int pc98bm_used = 0;
 
-static void pc98bm_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t pc98bm_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 static int pc98bm_open(struct input_dev *dev)
 {
@@ -113,7 +115,7 @@ static struct input_dev pc98bm_dev = {
 	},
 };
 
-static void pc98bm_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t pc98bm_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	char dx, dy;
 	unsigned char buttons;
@@ -137,18 +139,9 @@ static void pc98bm_interrupt(int irq, vo
 	input_sync(&pc98bm_dev);
 
 	outb(PC98BM_ENABLE_IRQ, PC98BM_CONTROL_PORT);
-}
 
-#ifndef MODULE
-static int __init pc98bm_setup(char *str)
-{
-        int ints[4];
-        str = get_options(str, ARRAY_SIZE(ints), ints);
-        if (ints[0] > 0) pc98bm_irq = ints[1];
-        return 1;
+	return IRQ_HANDLED;
 }
-__setup("pc98bm_irq=", pc98bm_setup);
-#endif
 
 static int __init pc98bm_init(void)
 {
diff -puN drivers/input/mousedev.c~linus drivers/input/mousedev.c
--- 25/drivers/input/mousedev.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/input/mousedev.c	2004-01-19 22:17:22.000000000 -0800
@@ -15,6 +15,7 @@
 #include <linux/slab.h>
 #include <linux/poll.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/input.h>
 #include <linux/config.h>
@@ -38,6 +39,14 @@ MODULE_LICENSE("GPL");
 #define CONFIG_INPUT_MOUSEDEV_SCREEN_Y	768
 #endif
 
+static int xres = CONFIG_INPUT_MOUSEDEV_SCREEN_X;
+module_param(xres, uint, 0);
+MODULE_PARM_DESC(xres, "Horizontal screen resolution");
+
+static int yres = CONFIG_INPUT_MOUSEDEV_SCREEN_Y;
+module_param(yres, uint, 0);
+MODULE_PARM_DESC(yres, "Vertical screen resolution");
+
 struct mousedev {
 	int exist;
 	int open;
@@ -53,12 +62,14 @@ struct mousedev_list {
 	struct fasync_struct *fasync;
 	struct mousedev *mousedev;
 	struct list_head node;
-	int dx, dy, dz, oldx, oldy;
-	signed char ps2[6];
+	int dx, dy, dz;
+	int old_x[4], old_y[4];
 	unsigned long buttons;
+	signed char ps2[6];
 	unsigned char ready, buffer, bufsiz;
 	unsigned char mode, imexseq, impsseq;
-	int finger;
+	unsigned int pkt_count;
+	unsigned char touch;
 };
 
 #define MOUSEDEV_SEQ_LEN	6
@@ -71,52 +82,49 @@ static struct input_handler mousedev_han
 static struct mousedev *mousedev_table[MOUSEDEV_MINORS];
 static struct mousedev mousedev_mix;
 
-static int xres = CONFIG_INPUT_MOUSEDEV_SCREEN_X;
-static int yres = CONFIG_INPUT_MOUSEDEV_SCREEN_Y;
+#define fx(i)  (list->old_x[(list->pkt_count - (i)) & 03])
+#define fy(i)  (list->old_y[(list->pkt_count - (i)) & 03])
 
 static void mousedev_abs_event(struct input_handle *handle, struct mousedev_list *list, unsigned int code, int value)
 {
 	int size;
+	int touchpad;
 
 	/* Ignore joysticks */
 	if (test_bit(BTN_TRIGGER, handle->dev->keybit))
 		return;
 
-	/* Handle touchpad data */
-	if (test_bit(BTN_TOOL_FINGER, handle->dev->keybit)) {
-
-		if (list->finger && list->finger < 3)
-			list->finger++;
-
-		switch (code) {
-			case ABS_X:
-				if (list->finger == 3)
-					list->dx += (value - list->oldx) / 8;
-				list->oldx = value;
-				return;
-			case ABS_Y:
-				if (list->finger == 3)
-					list->dy -= (value - list->oldy) / 8;
-				list->oldy = value;
-				return;
-		}
-		return;
-	}
+	touchpad = test_bit(BTN_TOOL_FINGER, handle->dev->keybit);
 
-	/* Handle tablet data */
 	switch (code) {
 		case ABS_X:
-			size = handle->dev->absmax[ABS_X] - handle->dev->absmin[ABS_X];
-			if (size == 0) size = xres;
-			list->dx += (value * xres - list->oldx) / size;
-			list->oldx += list->dx * size;
-			return;
+			if (touchpad) {
+				if (list->touch) {
+					fx(0) = value;
+					if (list->pkt_count >= 2)
+						list->dx = ((fx(0) - fx(1)) / 2 + (fx(1) - fx(2)) / 2) / 8;
+				}
+			} else {
+				size = handle->dev->absmax[ABS_X] - handle->dev->absmin[ABS_X];
+				if (size == 0) size = xres;
+				list->dx += (value * xres - list->old_x[0]) / size;
+				list->old_x[0] += list->dx * size;
+			}
+			break;
 		case ABS_Y:
-			size = handle->dev->absmax[ABS_Y] - handle->dev->absmin[ABS_Y];
-			if (size == 0) size = yres;
-			list->dy -= (value * yres - list->oldy) / size;
-			list->oldy -= list->dy * size;
-			return;
+			if (touchpad) {
+				if (list->touch) {
+					fy(0) = value;
+					if (list->pkt_count >= 2)
+						list->dy = -((fy(0) - fy(1)) / 2 + (fy(1) - fy(2)) / 2) / 8;
+				}
+			} else {
+				size = handle->dev->absmax[ABS_Y] - handle->dev->absmin[ABS_Y];
+				if (size == 0) size = yres;
+				list->dy -= (value * yres - list->old_y[0]) / size;
+				list->old_y[0] -= list->dy * size;
+			}
+			break;
 	}
 }
 
@@ -146,12 +154,16 @@ static void mousedev_event(struct input_
 					break;
 
 				case EV_KEY:
+					if (code == BTN_TOUCH && test_bit(BTN_TOOL_FINGER, handle->dev->keybit)) {
+						/* Handle touchpad data */
+						list->touch = value;
+						if (!list->touch)
+							list->pkt_count = 0;
+						break;
+					}
+
 					switch (code) {
-						case BTN_TOUCH: /* Handle touchpad data */
-							if (test_bit(BTN_TOOL_FINGER, handle->dev->keybit)) {
-								list->finger = value;
-								return;
-							}
+						case BTN_TOUCH:
 						case BTN_0:
 						case BTN_FORWARD:
 						case BTN_LEFT:   index = 0; break;
@@ -178,6 +190,16 @@ static void mousedev_event(struct input_
 				case EV_SYN:
 					switch (code) {
 						case SYN_REPORT:
+							if (list->touch) {
+								list->pkt_count++;
+								/* Input system eats duplicate events,
+								 * but we need all of them to do correct
+								 * averaging so apply present one forward
+								 */
+								fx(0) = fx(1);
+								fy(0) = fy(1);
+							}
+
 							list->ready = 1;
 							kill_fasync(&list->fasync, SIGIO, POLL_IN);
 							wake = 1;
@@ -203,6 +225,7 @@ static int mousedev_fasync(int fd, struc
 static void mousedev_free(struct mousedev *mousedev)
 {
 	devfs_remove("input/mouse%d", mousedev->minor);
+	class_simple_device_remove(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + mousedev->minor));
 	mousedev_table[mousedev->minor] = NULL;
 	kfree(mousedev);
 }
@@ -464,6 +487,9 @@ static struct input_handle *mousedev_con
 
 	devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor),
 			S_IFCHR|S_IRUGO|S_IWUSR, "input/mouse%d", minor);
+	class_simple_device_add(input_class, 
+				MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor),
+				dev->dev, "mouse%d", minor);
 
 	return &mousedev->handle;
 }
@@ -542,7 +568,8 @@ static int __init mousedev_init(void)
 
 	devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX),
 			S_IFCHR|S_IRUGO|S_IWUSR, "input/mice");
-
+	class_simple_device_add(input_class, MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX),
+				NULL, "mice");
 
 #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
 	if (!(mousedev_mix.misc = !misc_register(&psaux_mouse)))
@@ -561,13 +588,9 @@ static void __exit mousedev_exit(void)
 		misc_deregister(&psaux_mouse);
 #endif
 	devfs_remove("input/mice");
+	class_simple_device_remove(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX));
 	input_unregister_handler(&mousedev_handler);
 }
 
 module_init(mousedev_init);
 module_exit(mousedev_exit);
-
-MODULE_PARM(xres, "i");
-MODULE_PARM_DESC(xres, "Horizontal screen resolution");
-MODULE_PARM(yres, "i");
-MODULE_PARM_DESC(yres, "Vertical screen resolution");
diff -puN drivers/input/mouse/inport.c~linus drivers/input/mouse/inport.c
--- 25/drivers/input/mouse/inport.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/input/mouse/inport.c	2004-01-19 22:17:22.000000000 -0800
@@ -35,6 +35,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/config.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -80,10 +81,11 @@ MODULE_LICENSE("GPL");
 
 #define INPORT_IRQ		5
 
-MODULE_PARM(inport_irq, "i");
-
 static int inport_irq = INPORT_IRQ;
-static int inport_used = 0;
+module_param_named(irq, inport_irq, uint, 0);
+MODULE_PARM_DESC(irq, "IRQ number (5=default)");
+
+static int inport_used;
 
 static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
@@ -153,17 +155,6 @@ static irqreturn_t inport_interrupt(int 
 	return IRQ_HANDLED;
 }
 
-#ifndef MODULE
-static int __init inport_setup(char *str)
-{
-        int ints[4];
-        str = get_options(str, ARRAY_SIZE(ints), ints);
-        if (ints[0] > 0) inport_irq = ints[1];
-        return 1;
-}
-__setup("inport_irq=", inport_setup);
-#endif
-
 static int __init inport_init(void)
 {
 	unsigned char a,b,c;
diff -puN drivers/input/mouse/Kconfig~linus drivers/input/mouse/Kconfig
--- 25/drivers/input/mouse/Kconfig~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/input/mouse/Kconfig	2004-01-19 22:17:22.000000000 -0800
@@ -29,6 +29,8 @@ config MOUSE_PS2
 	  and a new verion of GPM at:
 		http://www.geocities.com/dt_or/gpm/gpm.html
 	  to take advantage of the advanced features of the touchpad.
+	  If you do not want install specialized drivers but want tapping
+	  working please use option psmouse.proto=imps.
 
 	  If unsure, say Y.
 
diff -puN drivers/input/mouse/logibm.c~linus drivers/input/mouse/logibm.c
--- 25/drivers/input/mouse/logibm.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/input/mouse/logibm.c	2004-01-19 22:17:22.000000000 -0800
@@ -36,6 +36,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/delay.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -70,9 +71,10 @@ MODULE_LICENSE("GPL");
 
 #define LOGIBM_IRQ		5
 
-MODULE_PARM(logibm_irq, "i");
-
 static int logibm_irq = LOGIBM_IRQ;
+module_param_named(irq, logibm_irq, uint, 0);
+MODULE_PARM_DESC(irq, "IRQ number (5=default)");
+
 static int logibm_used = 0;
 
 static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs);
@@ -142,17 +144,6 @@ static irqreturn_t logibm_interrupt(int 
 	return IRQ_HANDLED;
 }
 
-#ifndef MODULE
-static int __init logibm_setup(char *str)
-{
-        int ints[4];
-        str = get_options(str, ARRAY_SIZE(ints), ints);
-        if (ints[0] > 0) logibm_irq = ints[1];
-        return 1;
-}
-__setup("logibm_irq=", logibm_setup);
-#endif
-
 static int __init logibm_init(void)
 {
 	if (!request_region(LOGIBM_BASE, LOGIBM_EXTENT, "logibm")) {
diff -puN drivers/input/mouse/psmouse-base.c~linus drivers/input/mouse/psmouse-base.c
--- 25/drivers/input/mouse/psmouse-base.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/input/mouse/psmouse-base.c	2004-01-19 22:17:22.000000000 -0800
@@ -26,30 +26,26 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@s
 MODULE_DESCRIPTION("PS/2 mouse driver");
 MODULE_LICENSE("GPL");
 
-static int psmouse_noext;
-module_param(psmouse_noext, int, 0);
-MODULE_PARM_DESC(psmouse_noext, "[DEPRECATED] Disable any protocol extensions. Useful for KVM switches.");
-
 static char *psmouse_proto;
 static unsigned int psmouse_max_proto = -1U;
-module_param(psmouse_proto, charp, 0);
-MODULE_PARM_DESC(psmouse_proto, "Highest protocol extension to probe (bare, imps, exps). Useful for KVM switches.");
+module_param_named(proto, psmouse_proto, charp, 0);
+MODULE_PARM_DESC(proto, "Highest protocol extension to probe (bare, imps, exps). Useful for KVM switches.");
 
 int psmouse_resolution = 200;
-module_param(psmouse_resolution, uint, 0);
-MODULE_PARM_DESC(psmouse_resolution, "Resolution, in dpi.");
+module_param_named(resolution, psmouse_resolution, uint, 0);
+MODULE_PARM_DESC(resolution, "Resolution, in dpi.");
 
 unsigned int psmouse_rate = 100;
-module_param(psmouse_rate, uint, 0);
-MODULE_PARM_DESC(psmouse_rate, "Report rate, in reports per second.");
+module_param_named(rate, psmouse_rate, uint, 0);
+MODULE_PARM_DESC(rate, "Report rate, in reports per second.");
 
 int psmouse_smartscroll = 1;
-module_param(psmouse_smartscroll, bool, 0);
-MODULE_PARM_DESC(psmouse_smartscroll, "Logitech Smartscroll autorepeat, 1 = enabled (default), 0 = disabled.");
+module_param_named(smartscroll, psmouse_smartscroll, bool, 0);
+MODULE_PARM_DESC(smartscroll, "Logitech Smartscroll autorepeat, 1 = enabled (default), 0 = disabled.");
 
 unsigned int psmouse_resetafter;
-module_param(psmouse_resetafter, uint, 0);
-MODULE_PARM_DESC(psmouse_resetafter, "Reset Synaptics Touchpad after so many bad packets (0 = never).");
+module_param_named(resetafter, psmouse_resetafter, uint, 0);
+MODULE_PARM_DESC(resetafter, "Reset Synaptics Touchpad after so many bad packets (0 = never).");
 
 static char *psmouse_protocols[] = { "None", "PS/2", "PS2++", "PS2T++", "GenPS/2", "ImPS/2", "ImExPS/2", "SynPS/2"};
 
@@ -665,12 +661,6 @@ static struct serio_dev psmouse_dev = {
 
 static inline void psmouse_parse_proto(void)
 {
-	if (psmouse_noext) {
-		printk(KERN_WARNING "psmouse: 'psmouse_noext' option is deprecated, please use 'psmouse_proto'\n");
-		psmouse_max_proto = PSMOUSE_PS2;
-	}
-
-	/* even is psmouse_noext is present psmouse_proto overrides it */
 	if (psmouse_proto) {
 		if (!strcmp(psmouse_proto, "bare"))
 			psmouse_max_proto = PSMOUSE_PS2;
diff -puN drivers/input/mouse/synaptics.c~linus drivers/input/mouse/synaptics.c
--- 25/drivers/input/mouse/synaptics.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/input/mouse/synaptics.c	2004-01-19 22:17:22.000000000 -0800
@@ -553,16 +553,19 @@ static void synaptics_process_packet(str
 		finger_width = 0;
 	}
 
-	/* Post events */
+	/* Post events
+	 * BTN_TOUCH has to be first as mousedev relies on it when doing
+	 * absolute -> relative conversion
+	 */
+	if (hw.z > 30) input_report_key(dev, BTN_TOUCH, 1);
+	if (hw.z < 25) input_report_key(dev, BTN_TOUCH, 0);
+
 	if (hw.z > 0) {
 		input_report_abs(dev, ABS_X, hw.x);
 		input_report_abs(dev, ABS_Y, YMAX_NOMINAL + YMIN_NOMINAL - hw.y);
 	}
 	input_report_abs(dev, ABS_PRESSURE, hw.z);
 
-	if (hw.z > 30) input_report_key(dev, BTN_TOUCH, 1);
-	if (hw.z < 25) input_report_key(dev, BTN_TOUCH, 0);
-
 	input_report_abs(dev, ABS_TOOL_WIDTH, finger_width);
 	input_report_key(dev, BTN_TOOL_FINGER, num_fingers == 1);
 	input_report_key(dev, BTN_TOOL_DOUBLETAP, num_fingers == 2);
diff -puN drivers/input/serio/i8042.c~linus drivers/input/serio/i8042.c
--- 25/drivers/input/serio/i8042.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/input/serio/i8042.c	2004-01-19 22:17:22.000000000 -0800
@@ -29,22 +29,28 @@ MODULE_DESCRIPTION("i8042 keyboard and m
 MODULE_LICENSE("GPL");
 
 static unsigned int i8042_noaux;
-module_param(i8042_noaux, bool, 0);
+module_param_named(noaux, i8042_noaux, bool, 0);
+MODULE_PARM_DESC(noaux, "Do not probe or use AUX (mouse) port.");
 
 static unsigned int i8042_nomux;
-module_param(i8042_nomux, bool, 0);
+module_param_named(nomux, i8042_nomux, bool, 0);
+MODULE_PARM_DESC(nomux, "Do not check whether an active multiplexing conrtoller is present.");
 
 static unsigned int i8042_unlock;
-module_param(i8042_unlock, bool, 0);
+module_param_named(unlock, i8042_unlock, bool, 0);
+MODULE_PARM_DESC(unlock, "Ignore keyboard lock.");
 
 static unsigned int i8042_reset;
-module_param(i8042_reset, bool, 0);
+module_param_named(reset, i8042_reset, bool, 0);
+MODULE_PARM_DESC(reset, "Reset controller during init and cleanup.");
 
 static unsigned int i8042_direct;
-module_param(i8042_direct, bool, 0);
+module_param_named(direct, i8042_direct, bool, 0);
+MODULE_PARM_DESC(direct, "Put keyboard port into non-translated mode.");
 
 static unsigned int i8042_dumbkbd;
-module_param(i8042_dumbkbd, bool, 0);
+module_param_named(dumbkbd, i8042_dumbkbd, bool, 0);
+MODULE_PARM_DESC(dumbkbd, "Pretend that controller can only read data from keyboard");
 
 #undef DEBUG
 #include "i8042.h"
@@ -592,8 +598,10 @@ static int __init i8042_check_aux(struct
 	
 	if (i8042_command(&param, I8042_CMD_AUX_DISABLE))
 		return -1;
-	if (i8042_command(&param, I8042_CMD_CTL_RCTR) || (~param & I8042_CTR_AUXDIS))
-		return -1;	
+	if (i8042_command(&param, I8042_CMD_CTL_RCTR) || (~param & I8042_CTR_AUXDIS)) {
+		printk(KERN_WARNING "Failed to disable AUX port, but continuing anyway... Is this a SiS?\n");
+		printk(KERN_WARNING "If AUX port is really absent please use the 'i8042.noaux' option.\n");
+	}
 
 	if (i8042_command(&param, I8042_CMD_AUX_ENABLE))
 		return -1;
@@ -746,6 +754,29 @@ static int i8042_controller_init(void)
 
 
 /*
+ * Reset the controller.
+ */
+void i8042_controller_reset(void)
+{
+	if (i8042_reset) {
+		unsigned char param;
+
+		if (i8042_command(&param, I8042_CMD_CTL_TEST))
+			printk(KERN_ERR "i8042.c: i8042 controller reset timeout.\n");
+	}
+
+/*
+ * Restore the original control register setting.
+ */
+
+	i8042_ctr = i8042_initial_ctr;
+
+	if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR))
+		printk(KERN_WARNING "i8042.c: Can't restore CTR.\n");
+}
+
+
+/*
  * Here we try to reset everything back to a state in which the BIOS will be
  * able to talk to the hardware when rebooting.
  */
@@ -770,26 +801,20 @@ void i8042_controller_cleanup(void)
 		if (i8042_mux_values[i].exists)
 			serio_cleanup(i8042_mux_port + i);
 
-/*
- * Reset the controller.
- */
-
-	if (i8042_reset) {
-		unsigned char param;
+	i8042_controller_reset();
+}
 
-		if (i8042_command(&param, I8042_CMD_CTL_TEST))
-			printk(KERN_ERR "i8042.c: i8042 controller reset timeout.\n");
-	}
 
 /*
- * Restore the original control register setting.
+ * Here we try to restore the original BIOS settings
  */
 
-	i8042_ctr = i8042_initial_ctr;
-
-	if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR))
-		printk(KERN_WARNING "i8042.c: Can't restore CTR.\n");
+static int i8042_controller_suspend(void)
+{
+	del_timer_sync(&i8042_timer);
+	i8042_controller_reset();
 
+	return 0;
 }
 
 
@@ -809,7 +834,7 @@ static int i8042_controller_resume(void)
 	if (i8042_mux_present)
 		if (i8042_enable_mux_mode(&i8042_aux_values, NULL) ||
 		    i8042_enable_mux_ports(&i8042_aux_values)) {
-			printk(KERN_WARNING "i8042: failed to resume active multiplexor, mouse won't wotk.\n");
+			printk(KERN_WARNING "i8042: failed to resume active multiplexor, mouse won't work.\n");
 		}
 
 /*
@@ -825,6 +850,10 @@ static int i8042_controller_resume(void)
 	for (i = 0; i < 4; i++)
 		if (i8042_mux_values[i].exists && i8042_activate_port(i8042_mux_port + i) == 0)
 			serio_reconnect(i8042_mux_port + i);
+/*
+ * Restart timer (for polling "stuck" data)
+ */
+	mod_timer(&i8042_timer, jiffies + I8042_POLL_PERIOD);
 
 	return 0;
 }
@@ -851,16 +880,22 @@ static struct notifier_block i8042_notif
 };
 
 /*
- * Resume handler for the new PM scheme (driver model)
+ * Suspend/resume handlers for the new PM scheme (driver model)
  */
+static int i8042_suspend(struct sys_device *dev, u32 state)
+{
+	return i8042_controller_suspend();
+}
+
 static int i8042_resume(struct sys_device *dev)
 {
 	return i8042_controller_resume();
 }
 
 static struct sysdev_class kbc_sysclass = {
-       set_kset_name("i8042"),
-       .resume = i8042_resume,
+	set_kset_name("i8042"),
+	.suspend = i8042_suspend,
+	.resume = i8042_resume,
 };
 
 static struct sys_device device_i8042 = {
@@ -869,12 +904,17 @@ static struct sys_device device_i8042 = 
 };
 
 /*
- * Resume handler for the old PM scheme (APM)
+ * Suspend/resume handler for the old PM scheme (APM)
  */
 static int i8042_pm_callback(struct pm_dev *dev, pm_request_t request, void *dummy)
 {
-	if (request == PM_RESUME)
-		return i8042_controller_resume();
+	switch (request) {
+		case PM_SUSPEND:
+			return i8042_controller_suspend();
+
+		case PM_RESUME:
+			return i8042_controller_resume();
+	}
 
 	return 0;
 }
@@ -955,7 +995,7 @@ void __exit i8042_exit(void)
 		sysdev_class_unregister(&kbc_sysclass);
 	}
 
-	del_timer(&i8042_timer);
+	del_timer_sync(&i8042_timer);
 
 	i8042_controller_cleanup();
 	
diff -puN drivers/input/tsdev.c~linus drivers/input/tsdev.c
--- 25/drivers/input/tsdev.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/input/tsdev.c	2004-01-19 22:17:22.000000000 -0800
@@ -34,6 +34,7 @@
 #include <linux/slab.h>
 #include <linux/poll.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/input.h>
 #include <linux/major.h>
@@ -51,6 +52,18 @@
 #define CONFIG_INPUT_TSDEV_SCREEN_Y	320
 #endif
 
+MODULE_AUTHOR("James Simmons <jsimmons@transvirtual.com>");
+MODULE_DESCRIPTION("Input driver to touchscreen converter");
+MODULE_LICENSE("GPL");
+
+static int xres = CONFIG_INPUT_TSDEV_SCREEN_X;
+module_param(xres, uint, 0);
+MODULE_PARM_DESC(xres, "Horizontal screen resolution");
+
+static int yres = CONFIG_INPUT_TSDEV_SCREEN_Y;
+module_param(yres, uint, 0);
+MODULE_PARM_DESC(yres, "Vertical screen resolution");
+
 struct tsdev {
 	int exist;
 	int open;
@@ -82,9 +95,6 @@ static struct input_handler tsdev_handle
 
 static struct tsdev *tsdev_table[TSDEV_MINORS];
 
-static int xres = CONFIG_INPUT_TSDEV_SCREEN_X;
-static int yres = CONFIG_INPUT_TSDEV_SCREEN_Y;
-
 static int tsdev_fasync(int fd, struct file *file, int on)
 {
 	struct tsdev_list *list = file->private_data;
@@ -119,6 +129,7 @@ static int tsdev_open(struct inode *inod
 static void tsdev_free(struct tsdev *tsdev)
 {
 	devfs_remove("input/ts%d", tsdev->minor);
+	class_simple_device_remove(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + tsdev->minor));
 	tsdev_table[tsdev->minor] = NULL;
 	kfree(tsdev);
 }
@@ -333,6 +344,9 @@ static struct input_handle *tsdev_connec
 	
 	devfs_mk_cdev(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor),
 			S_IFCHR|S_IRUGO|S_IWUSR, "input/ts%d", minor);
+	class_simple_device_add(input_class, 
+				MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor),
+				dev->dev, "ts%d", minor);
 
 	return &tsdev->handle;
 }
@@ -394,10 +408,3 @@ static void __exit tsdev_exit(void)
 
 module_init(tsdev_init);
 module_exit(tsdev_exit);
-
-MODULE_AUTHOR("James Simmons <jsimmons@transvirtual.com>");
-MODULE_DESCRIPTION("Input driver to touchscreen converter");
-MODULE_PARM(xres, "i");
-MODULE_PARM_DESC(xres, "Horizontal screen resolution");
-MODULE_PARM(yres, "i");
-MODULE_PARM_DESC(yres, "Vertical screen resolution");
diff -puN -L drivers/isdn/eicon/adapter.h drivers/isdn/eicon/adapter.h~linus /dev/null
--- 25/drivers/isdn/eicon/adapter.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,247 +0,0 @@
-/*
- * Main internal include file for Diva Server driver
- *
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.7  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#if !defined(ADAPTER_H)
-#define ADAPTER_H
-
-#include "sys.h"
-#include "idi.h"
-#include "divas.h"
-#undef ID_MASK
-#include "pc.h"
-
-#define XMOREC 0x1f
-#define XMOREF 0x20
-#define XBUSY  0x40
-#define RMORE  0x80
-
-        /* structure for all information we have to keep on a per   */
-        /* adapater basis                                           */
-
-typedef struct adapter_s ADAPTER;
-
-struct adapter_s {
-  void * io;
-
-  byte IdTable[256];
-  byte ReadyInt;
-
-  byte (* ram_in)(ADAPTER * a, void * adr);
-  word (* ram_inw)(ADAPTER * a, void * adr);
-  void (* ram_in_buffer)(ADAPTER * a, void * adr, void * P, word length);
-  void (* ram_look_ahead)(ADAPTER * a, PBUFFER * RBuffer, ENTITY * e);
-
-  void (* ram_out)(ADAPTER * a, void * adr, byte data);
-  void (* ram_outw)(ADAPTER * a, void * adr, word data);
-  void (* ram_out_buffer)(ADAPTER * a, void * adr, void * P, word length);
-
-  void (* ram_inc)(ADAPTER * a, void * adr);
-};
-
-typedef struct card card_t;
-
-typedef int	card_load_fn_t(card_t *card, dia_load_t *load);
-typedef int	card_config_fn_t(card_t *card, dia_config_t *config);
-typedef int	card_start_fn_t(card_t *card, byte *channels);
-typedef	int	card_reset_fn_t(card_t *card);
-typedef int card_mem_get_fn_t(card_t *card, mem_block_t *mem_block);
-
-#define	MAX_PENTITIES	256		/* Number of entities primary adapter */
-#define MAX_ENTITIES	16		/* Number of entities standard adapter */
-
-typedef struct e_info_s E_INFO;
-
-struct e_info_s
-{
-	ENTITY		*e;				/* entity pointer */
-	byte		next;			/* chaining index */
-	word		assign_ref;		/* assign reference */
-};
-
-/* DIVA card info (details hidden from user) */
-
-typedef struct	ux_diva_card_s ux_diva_card_t;
-
-/* card info */
-
-struct card
-{
-	ADAPTER				a;				/* per-adapter information */
-	dia_card_t			cfg;			/* card configuration */
-	int 				state;			/* State of the adapter */
-	dword 				serial_no;		/* serial number */
-	int 				test_int_pend;	/* set for interrupt testing */
-	ux_diva_card_t		*hw;			/* O/S-specific handle */
-	card_reset_fn_t		*card_reset;	/* call this to reset card */
-	card_load_fn_t		*card_load;		/* call this to load card */
-	card_config_fn_t	*card_config;	/* call this to config card */
-	card_start_fn_t		*card_start;	/* call this to start card */
-	card_mem_get_fn_t	*card_mem_get;	/* call this to get card memory */
-	E_INFO				*e_tbl;			/* table of ENTITY pointers */
-	byte				e_head;			/* list of active ENTITIES */
-	byte				e_tail;			/* list of active ENTITIES */
-	int					e_count;		/* # of active ENTITIES */
-	int					e_max;			/* total # of ENTITIES */
-	byte				assign;			/* assign queue entry */
-	PBUFFER				RBuffer;		/* Copy of receive lookahead buffer */
-	int					log_types;		/* bit-mask of active logs */
-	word				xlog_offset;	/* offset to XLOG buffer on card */
-	void		(*out)(ADAPTER *a);
-	byte		(*dpc)(ADAPTER * a);
-	byte		(*test_int)(ADAPTER * a);
-	void		(*clear_int)(ADAPTER * a);
-	void		(*reset_int)(card_t *c);
-	int  		is_live;
-
-	int		(*card_isr)(card_t *card);
-
-	int 		int_pend;		/* interrupt pending */
-	long		interrupt_reentered;
-	long 		dpc_reentered;
-	int 		set_xlog_request;
-
-} ;
-
-/* card information */
-
-#define	MAX_CARDS	20		/* max number of cards on a system */
-
-extern
-card_t			DivasCards[];
-
-extern
-int				DivasCardNext;
-
-extern
-dia_config_t	DivasCardConfigs[];
-
-extern
-byte 			DivasFlavourConfig[];
-
-/*------------------------------------------------------------------*/
-/* public functions of IDI common code                              */
-/*------------------------------------------------------------------*/
-
-void DivasOut(ADAPTER * a);
-byte DivasDpc(ADAPTER * a);
-byte DivasTestInt(ADAPTER * a);
-void DivasClearInt(ADAPTER * a);
-
-/*------------------------------------------------------------------*/
-/* public functions of configuration platform-specific code         */
-/*------------------------------------------------------------------*/
-
-int DivasConfigGet(dia_card_t *card);
-
-/*------------------------------------------------------------------*/
-/* public functions of LOG related code                             */
-/*------------------------------------------------------------------*/
-
-void	DivasXlogReq(int card_num);
-int		DivasXlogRetrieve(card_t *card);
-void	DivasLog(dia_log_t *log);
-void	DivasLogIdi(card_t *card, ENTITY *e, int request);
-
-/*------------------------------------------------------------------*/
-/* public functions to initialise cards for each type supported     */
-/*------------------------------------------------------------------*/
-
-int		DivasPriInit(card_t *card, dia_card_t *cfg);
-
-int		DivasBriInit(card_t *card, dia_card_t *cfg);
-int		Divas4BriInit(card_t *card, dia_card_t *cfg);
-void 	DivasBriPatch(card_t *card);
-
-/*------------------------------------------------------------------*/
-/* public functions of log common code                              */
-/*------------------------------------------------------------------*/
-
-extern	char	*DivasLogFifoRead(void);
-extern	void	DivasLogFifoWrite(char *entry, int length);
-extern	int		DivasLogFifoEmpty(void);
-extern	int		DivasLogFifoFull(void);
-extern	void    DivasLogAdd(void *buffer, int length);
-
-/*------------------------------------------------------------------*/
-/* public functions of misc. platform-specific code         		*/
-/*------------------------------------------------------------------*/
-
-int		DivasDpcSchedule(void);
-void		DivasDoDpc(unsigned long);
-int		DivasScheduleRequestDpc(void);
-
-/* table of IDI request functions */
-
-extern
-IDI_CALL	DivasIdiRequest[];
-
-/*
- * initialisation entry point
- */
-
-int		DivasInit(void);
-
-/*
- * Get information on the number and type of cards present
- */
-
-extern
-int 	DivasCardsDiscover(void);
-
-/*
- * initialise a new card
- */
-
-int		DivasCardNew(dia_card_t *card);
-
-/*
- * configure specified card
- */
-
-int		DivasCardConfig(dia_config_t *config);
-
-/*
- * load specified binary code onto card
- */
-
-int		DivasCardLoad(dia_load_t *load);
-
-/*
- * start specified card running
- */
-
-int		DivasCardStart(int card_id);
-
-/*
- * ISR for card
- * Returns 0 if specified card was interrupting
- */
-
-int		DivasIsr(void *arg);
-
-/*
- * Get number of active cards
- */
-
-int		DivasGetNum(void);
-
-/*
- * Get list of active cards
- */
-
-int		DivasGetList(dia_card_list_t *card_list);
-
-/* definitions common to several card types */
-
-#define DIVAS_SHARED_OFFSET     (0x1000)
-
-#endif /* ADAPTER_H */
diff -puN -L drivers/isdn/eicon/bri.c drivers/isdn/eicon/bri.c~linus /dev/null
--- 25/drivers/isdn/eicon/bri.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,697 +0,0 @@
-/*
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.8  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#include "eicon.h"
-#include "sys.h"
-#include "idi.h"
-#include "divas.h"
-#include "pc.h"
-#include "pr_pc.h"
-#include "dsp_defs.h"
-
-#include "adapter.h"
-#include "uxio.h"
-
-#define PCI_BADDR0	0x10
-#define PCI_BADDR1	0x14
-#define PCI_BADDR2	0x18
-
-#define DIVAS_SIGNATURE 0x4447
-
-/* offset to start of MAINT area (used by xlog) */
-
-#define	DIVAS_MAINT_OFFSET	0xff00		/* value for BRI card */
-
-#define PROTCAP_TELINDUS	0x1
-#define PROTCAP_V90D		0x8
-
-word GetProtFeatureValue(char *sw_id);
-byte io_in(ADAPTER *a, void *adr);
-word io_inw(ADAPTER *a, void *adr);
-void io_in_buffer(ADAPTER *a, void *adr, void *P, word length);
-void io_look_ahead(ADAPTER *a, PBUFFER *RBuffer, ENTITY *e);
-void io_out(ADAPTER *a, void *adr, byte data);
-void io_outw(ADAPTER *a, void *adr, word data);
-void io_out_buffer(ADAPTER *a, void *adr, void *P, word length);
-void io_inc(ADAPTER *a, void *adr);
-
-static int diva_server_bri_test_int(card_t *card);
-static int bri_ISR (card_t* card);
-
-#define PLX_IOBASE		0
-#define	DIVAS_IOBASE	1
-
-#define	REG_DATA		0x00
-#define	REG_ADDRLO		0x04
-#define REG_ADDRHI		0x0C
-#define REG_IOCTRL		0x10
-
-#define M_PCI_RESET	0x10
-
-byte UxCardPortIoIn(ux_diva_card_t *card, byte *base, int offset);
-word UxCardPortIoInW(ux_diva_card_t *card, byte *base, int offset);
-void UxCardPortIoOut(ux_diva_card_t *card, byte *base, int offset, byte);
-void UxCardPortIoOutW(ux_diva_card_t *card, byte *base, int offset, word);
-
-int DivasBRIInitPCI(card_t *card, dia_card_t *cfg);
-
-static
-int	diva_server_bri_reset(card_t *card)
-{
-	byte *DivasIOBase;
-	word i;
-	dword dwWait;
-
-	UxCardLog(0);
-
-	DPRINTF(("divas: resetting BRI adapter"));
-
-	DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE);
-
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_IOCTRL, 0);
-
-	for (i=0; i < 50000; i++)
-		;
-
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_ADDRHI, 0);
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 0);
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_DATA  , 0);
-
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_ADDRHI, 0xFF);
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 0x0000);
-
-	for (i=0; i<0x8000; i++)
-	{
-		UxCardPortIoOutW(card->hw, DivasIOBase, REG_DATA , 0);
-	}
-
-	for (dwWait=0; dwWait < 0x00FFFFFF; dwWait++)
-		;
-
-	UxCardMemDetach(card->hw, DivasIOBase);
-
-	return 0;
-}
-
-static
-void diva_server_bri_reset_int(card_t *card)
-{
-	byte *DivasIOBase = NULL;
-
-	DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE);
-
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_IOCTRL, 0x08);
-
-	UxCardMemDetach(card->hw, DivasIOBase);
-
-	return;
-}
-
-static
-int diva_server_bri_start(card_t *card, byte *channels)
-{
-	byte *DivasIOBase, *PLXIOBase;
-	word wSig = 0;
-	word i;
-	dword dwSerialNum;
-	byte bPLX9060 = FALSE;
-
-	DPRINTF(("divas: starting Diva Server BRI card"));
-
-	card->is_live = FALSE;
-
-	DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE);
-
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_ADDRHI, 0xFF);
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 0x1E);
-
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA  , 0);
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA  , 0);
-	
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_IOCTRL, 0x08);
-
-	/* wait for signature to indicate card has started */
-	for (i = 0; i < 300; i++)
-	{
-		UxCardPortIoOut(card->hw, DivasIOBase, REG_ADDRHI, 0xFF);
-		UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 0x1E);
-		wSig = UxCardPortIoInW(card->hw, DivasIOBase, REG_DATA);
-
-		if (wSig == DIVAS_SIGNATURE)
-		{
-			DPRINTF(("divas: card started after %d ms", i * 10));
-			break;
-		}
-		UxPause(10);
-	}
-
-	if (wSig != DIVAS_SIGNATURE)
-	{
-		DPRINTF(("divas: card failed to start (Sig=0x%x)", wSig));
-		UxCardMemDetach(card->hw, DivasIOBase);
-		return -1;
-	}
-
-	card->is_live = TRUE;
-
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_ADDRHI, 0xFF);
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 0x3F6);
-	*channels = UxCardPortIoInW(card->hw, DivasIOBase, REG_DATA);
-
-	UxCardMemDetach(card->hw, DivasIOBase);
-
-	PLXIOBase = UxCardMemAttach(card->hw, PLX_IOBASE);
-
-	bPLX9060 = UxCardPortIoInW(card->hw, PLXIOBase, 0x6C) | UxCardPortIoInW(card->hw, PLXIOBase, 0x6E);
-
-	if (bPLX9060)
-	{ 
-		dwSerialNum = (UxCardPortIoInW(card->hw, PLXIOBase, 0x1E) << 16) | 
-					(UxCardPortIoInW(card->hw, PLXIOBase, 0x22));
-		DPRINTF(("divas: PLX9060 in use. Serial number 0x%04X", dwSerialNum));
-	}
-	else
-	{
-		dwSerialNum = (UxCardPortIoInW(card->hw, PLXIOBase, 0x22) << 16) | 
-					(UxCardPortIoInW(card->hw, PLXIOBase, 0x26));
-		DPRINTF(("divas: PLX9050 in use. Serial number 0x%04X", dwSerialNum));
-	}
-
-	UxCardMemDetach(card->hw, PLXIOBase);
-
-	card->serial_no = dwSerialNum;
-
-	diva_server_bri_test_int(card);
-	
-	return 0;
-}
-
-static
-int diva_server_bri_load(card_t *card, dia_load_t *load)
-{
-	byte *DivasIOBase;
-	dword r3000_base;
-	dword dwAddr, dwLength, i;
-	word wTest, aWord;
-
-	DPRINTF(("divas: loading Diva Server BRI card"));
-
-	switch (load->code_type)
-	{
-		case DIA_CPU_CODE:
-		DPRINTF(("divas: loading RISC %s", &load->code[0x80]));
-
-		card->hw->features = GetProtFeatureValue((char *)&load->code[0x80]);
-		DPRINTF(("divas: features 0x%x", card->hw->features));
-		if (card->hw->features == 0xFFFF)
-		{
-			DPRINTF(("divas: invalid feature string failed load\n"));
-			return -1;
-		}
-
-		r3000_base = 0;
-		break;
-
-		case DIA_DSP_CODE:
-		DPRINTF(("divas: DSP code \"%s\"", load->code));
-
-		if ((card->hw->features) && (!(card->hw->features & PROTCAP_TELINDUS)))
-		{
-			DPRINTF(("divas: only Telindus style binaries supported"));
-			return -1;
-		}
-
-		if ((card->hw->features) && (card->hw->features & PROTCAP_V90D))
-		{
-			DPRINTF(("divas: V.90 DSP binary"));
-			r3000_base = (0xBF790000 + (((sizeof(dword) + (sizeof(t_dsp_download_desc)* DSP_MAX_DOWNLOAD_COUNT)) + 3) & 0xFFFFFFFC));
-		}
-		else
-		{
-			DPRINTF(("divas: non-V.90 DSP binary"));
-			r3000_base = (0xBF7A0000 + (((sizeof(dword) + (sizeof(t_dsp_download_desc)* DSP_MAX_DOWNLOAD_COUNT)) + 3) & 0xFFFFFFFC));
-		}
-		DPRINTF(("divas: loading at 0x%x", r3000_base));
-		break;
-
-		case DIA_TABLE_CODE:
-		DPRINTF(("divas: TABLE code"));
-		if ((card->hw->features) && (card->hw->features & PROTCAP_V90D))
-		{
-			r3000_base = 0xBF790000 + sizeof(dword);
-		}
-		else
-		{
-			r3000_base = 0xBF7A0000 + sizeof(dword);
-		}
-
-		break;
-
-		case DIA_DLOAD_CNT:
-		DPRINTF(("divas: COUNT code"));
-		if ((card->hw->features) && (card->hw->features & PROTCAP_V90D))
-		{
-			r3000_base = 0xBF790000;
-		}
-		else
-		{
-			r3000_base = 0xBF7A0000;
-		}
-		break;
-
-		default:
-		DPRINTF(("divas: unknown code type %d", load->code_type));
-		return -1;
-		break;
-	}
-
-	DPRINTF(("divas: Writing %d bytes to adapter, address 0x%x", load->length, r3000_base));
-
-	DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE);
-
-	DPRINTF(("divas: Attached to 0x%04X", DivasIOBase));
-
-	dwLength = load->length;
-
-	for (i=0; i < dwLength; i++)
-	{
-		dwAddr = r3000_base + i;
-
-		UxCardPortIoOut(card->hw, DivasIOBase, REG_ADDRHI, dwAddr >> 16);
-		UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, dwAddr);
-
-		UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, load->code[i]);
-	}
-
-	DPRINTF(("divas: Verifying"));
-
-	for (i=0; i<dwLength; i++)
-	{
-		dwAddr = r3000_base + i;
-
-		UxCardPortIoOut(card->hw, DivasIOBase, REG_ADDRHI, dwAddr >> 16);
-		UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, dwAddr);
-
-		wTest = UxCardPortIoIn(card->hw, DivasIOBase, REG_DATA);
-
-		aWord = load->code[i];
-
-		if (wTest != aWord)
-		{
-			DPRINTF(("divas: load verify failed on byte %d", i));
-			DPRINTF(("divas: RAM 0x%x   File 0x%x",wTest,aWord));
-			
-			UxCardMemDetach(card->hw, DivasIOBase);
-
-			return -1;
-		}
-	}
-
-	DPRINTF(("divas: Loaded and verified. Detaching from adapter"));
-
-	UxCardMemDetach(card->hw, DivasIOBase);
-
-	UxCardLog(0);
-
-	return 0;
-}
-
-static
-int diva_server_bri_config(card_t *card, dia_config_t *config)
-{
-	byte *DivasIOBase, i;
-
-	DPRINTF(("divas: configuring Diva Server BRI card"));
-
-	DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE);
-
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_ADDRHI, 0xFF);
-
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 8);
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->tei);
-
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 9);
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->nt2);
-
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 10);
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->sig_flags);
-
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 11);
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->watchdog);
-
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 12);
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->permanent);
-
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 13);
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, 0);
-
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 14);
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->stable_l2);
-
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 15);
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->no_order_check);
-
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 16);
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, 0);
-
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 17);
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, 0);
-
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 18);
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->low_channel);
-
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 19);
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->prot_version);
-
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 20);
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->crc4);
-
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 21);
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, 0);
-
-	if ((card->hw->features) && (card->hw->features & PROTCAP_V90D))
-	{
-		DPRINTF(("divas: Signifying V.90"));
-		UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 22);
-		UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, 4);
-	}
-	else
-	{
-		UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 22);
-		UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, 0);
-	}
-
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 23);
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, card->serial_no & 0xFF);
-
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 24);
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, (card->serial_no >> 8) & 0xFF);
-
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 25);
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, (card->serial_no >> 16) & 0xFF);
-
-	UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 26);
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, 21);
-
-	for (i=0; i<32; i++)
-	{
-		UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 32+i);
-		UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->terminal[0].oad[i]);
-
-		UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 64+i);
-		UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->terminal[0].osa[i]);
-
-		UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 96+i);
-		UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->terminal[0].spid[i]);
-
-
-		UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 128+i);
-		UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->terminal[1].oad[i]);
-
-		UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 160+i);
-		UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->terminal[1].osa[i]);
-
-		UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, 192+i);
-		UxCardPortIoOut(card->hw, DivasIOBase, REG_DATA, config->terminal[1].spid[i]);
-	}
-
-	UxCardMemDetach(card->hw, DivasIOBase);
-
-	return 0;
-}
-
-void DivasBriPatch(card_t *card)
-{
-	dword	PLXIOBase = 0;
-	dword	DivasIOBase = 0;
-
-	PLXIOBase = card->cfg.reset_base;
-	DivasIOBase = card->cfg.io_base;
-
-	if(card->hw == NULL)
-	{
-		DPRINTF(("Divas: BRI PATCH (PLX chip) card->hw is null"));
-		return;
-	}
-
-	if (PLXIOBase == 0)
-	{
-		DPRINTF(("Divas: BRI (PLX chip) cannot be patched. The BRI adapter may"));
-		DPRINTF(("Divas:   not function properly. If you do encounter problems,"));
-		DPRINTF(("Divas:   ensure that your machine is using the latest BIOS."));
-		return;
-	}
-
-	DPRINTF(("Divas: PLX I/O Base 0x%x", PLXIOBase));
-	DPRINTF(("Divas: Divas I/O Base 0x%x", DivasIOBase));
-
-	if (PLXIOBase & 0x80)
-	{
-		dword dwSize, dwSerialNum, dwCmd;
-		boolean_t bPLX9060;
-		word wSerHi, wSerLo;
-
-		DPRINTF(("Divas: Patch required"));
-		dwCmd = 0;
-		UxPciConfigWrite(card->hw, 4, PCI_COMMAND, &dwCmd);
-
-		PLXIOBase &= ~0x80;
-		UxPciConfigWrite(card->hw, 4, PCI_BADDR1, &PLXIOBase);
-
-		dwSize = 0xFFFFFFFF;
-		UxPciConfigWrite(card->hw, 4, PCI_BADDR1, &dwSize);
-		UxPciConfigRead(card->hw, 4, PCI_BADDR1, &dwSize);
-		
-		dwSize = (~ (dwSize & ~7)) + 1;
-
-		DivasIOBase = PLXIOBase + dwSize;
-
-		card->cfg.reset_base = PLXIOBase;
-		card->cfg.io_base = DivasIOBase;
-		UxPciConfigWrite(card->hw, 4, PCI_BADDR1, &card->cfg.reset_base);
-		UxPciConfigWrite(card->hw, 4, PCI_BADDR2, &card->cfg.io_base);
-
-		dwCmd = 5;
-		UxPciConfigWrite(card->hw, 4, PCI_COMMAND, &dwCmd);
-
-		bPLX9060 = UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x6C) | 
-			   UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x6E);
-
-		if (bPLX9060)
-		{
-			wSerHi = UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x1E);
-			wSerLo = UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x22);
-			dwSerialNum = (wSerHi << 16) | wSerLo;
-			UxCardLog(0);
-		}
-		else
-		{
-			wSerHi = UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x22);
-			wSerLo = UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x26);
-			dwSerialNum = (wSerHi << 16) | wSerLo;
-			UxCardLog(0);
-		}
-	}
-	else
-	{
-		word wSerHi, wSerLo;
-		boolean_t bPLX9060;
-		dword dwSerialNum;
-
-		DPRINTF(("divas: No patch required"));
-
-		bPLX9060 = UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x6C) | 
-			   UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x6E);
-
-		if (bPLX9060)
-		{
-			wSerHi = UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x1E);
-			wSerLo = UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x22);
-			dwSerialNum = (wSerHi << 16) | wSerLo;
-		}
-		else
-		{
-			wSerHi = UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x22);
-			wSerLo = UxCardPortIoInW(card->hw, (void *) card->cfg.reset_base, 0x26);
-			dwSerialNum = (wSerHi << 16) | wSerLo;
-		}
-	}
-	DPRINTF(("Divas: After patching:"));
-	DPRINTF(("Divas: PLX I/O Base 0x%x", PLXIOBase));
-	DPRINTF(("Divas: Divas I/O Base 0x%x", DivasIOBase));
-
-}
-
-#define TEST_INT_DIVAS_BRI	0x12
-static
-int	diva_server_bri_test_int(card_t *card)
-{
-	boolean_t bPLX9060 = FALSE;
-	byte *PLXIOBase = NULL, *DivasIOBase = NULL;
-
-	DPRINTF(("divas: test interrupt for Diva Server BRI card"));
-
-	PLXIOBase = UxCardMemAttach(card->hw, PLX_IOBASE);
-
-	bPLX9060 = UxCardPortIoInW(card->hw, PLXIOBase, 0x6C) || UxCardPortIoInW(card->hw, PLXIOBase, 0x6E);
-
-	if (bPLX9060)
-	{ /* PLX9060 */
-		UxCardPortIoOut(card->hw, PLXIOBase, 0x69, 0x09);
-	}
-	else
-	{ /* PLX9050 */
-		UxCardPortIoOut(card->hw, PLXIOBase, 0x4C, 0x41);
-	}
-
-	card->test_int_pend = TEST_INT_DIVAS_BRI;
-
-	UxCardMemDetach(card->hw, PLXIOBase);
-
-	DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE);
-
-	UxCardPortIoOut(card->hw, DivasIOBase, REG_IOCTRL, 0x89);
-
-	UxCardMemDetach(card->hw, DivasIOBase);
-	
-	return 0;
-}
-
-static
-int diva_server_bri_mem_get(card_t *card, mem_block_t *mem_block)
-{
-	dword user_addr = mem_block->addr;
-	word	length = 0;
-	dword	addr;
-	word	i;
-	byte *DivasIOBase;
-
-	DPRINTF(("divas: Retrieving memory from 0x%x", user_addr));
-
-	DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE);
-
-	addr = user_addr;
-
-	for (i=0; i < (16 * 8); i++)
-	{
-		addr = user_addr + i;
-
-		UxCardPortIoOut(card->hw, DivasIOBase, REG_ADDRHI, addr >> 16);
-		UxCardPortIoOutW(card->hw, DivasIOBase, REG_ADDRLO, (word) addr);
-
-		mem_block->data[i] = UxCardPortIoIn(card->hw, DivasIOBase, REG_DATA);
-		length++;
-	}
-
-	UxCardMemDetach(card->hw, DivasIOBase);
-
-	return length;
-}
-
-int DivasBriInit(card_t *card, dia_card_t *cfg)
-{
-	DPRINTF(("divas: initialise Diva Server BRI card"));
-
-	if (DivasBRIInitPCI(card, cfg) == -1)
-	{
-		return -1;
-	}
-
-	card->card_reset 		= diva_server_bri_reset;
-	card->card_start 		= diva_server_bri_start;
-	card->card_load  		= diva_server_bri_load;
-	card->card_config		= diva_server_bri_config;
-	card->reset_int 		= diva_server_bri_reset_int;
-	card->card_mem_get 		= diva_server_bri_mem_get;
-
-	card->xlog_offset 		= DIVAS_MAINT_OFFSET;
-
-	card->out 			= DivasOut;
-	card->test_int 			= DivasTestInt;
-	card->dpc 			= DivasDpc;
-	card->clear_int 		= DivasClearInt;
-	card->card_isr 			= bri_ISR;
-
-	card->a.ram_out 		= io_out;
-	card->a.ram_outw 		= io_outw;
-	card->a.ram_out_buffer 	= io_out_buffer;
-	card->a.ram_inc 		= io_inc;
-
-	card->a.ram_in 			= io_in;
-	card->a.ram_inw 		= io_inw;
-	card->a.ram_in_buffer 	= io_in_buffer;
-	card->a.ram_look_ahead	= io_look_ahead;
-
-	return 0;
-}
-
-word GetProtFeatureValue(char *sw_id)
-{
-	word features = 0;
-
-	while ((*sw_id) && (sw_id[0] != '['))
-		sw_id++;
-
-	if (sw_id == NULL)
-	{
-		DPRINTF(("divas: no feature string present"));
-		features = -1;
-	}
-	else
-	{
-		byte i, shifter;
-
-		sw_id += 3;
-
-		for (i=0, shifter=12; i<4; i++, shifter-=4)
-		{
-			if ((sw_id[i] >= '0') && (sw_id[i] <= '9'))
-			{
-				features |= (sw_id[i] - '0') << shifter;
-			}
-			else if ((sw_id[i] >= 'a') && (sw_id[i] <= 'f'))
-			{
-				features |= (sw_id[i] - 'a' + 10) << shifter;
-			}
-			else if ((sw_id[i] >= 'A') && (sw_id[i] <= 'F'))
-			{
-				features |= (sw_id[i] - 'A' + 10) << shifter;
-			}
-			else
-			{
-				DPRINTF(("divas: invalid feature string"));
-				return -1;
-			}
-		}
-	}
-
-	return features;
-}
-
-
-int bri_ISR (card_t* card) 
-{
-	int served = 0;
-	byte *DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE);
-
-	if (UxCardPortIoIn (card->hw, DivasIOBase, M_PCI_RESET) & 0x01) 
-	{
-		served = 1;
-		card->int_pend  += 1;
-		DivasDpcSchedule(); /* ISR DPC */
-		UxCardPortIoOut (card->hw, DivasIOBase, M_PCI_RESET, 0x08);
-	}
-
-	UxCardMemDetach(card->hw, DivasIOBase);
-
-	return (served != 0);
-}
-
-
diff -puN -L drivers/isdn/eicon/common.c drivers/isdn/eicon/common.c~linus /dev/null
--- 25/drivers/isdn/eicon/common.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,867 +0,0 @@
-/*
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.15  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#include "eicon.h"
-#include "sys.h"
-#include "idi.h"
-#include "constant.h"
-#include "divas.h"
-#include "pc.h"
-#include "pr_pc.h"
-
-#include "uxio.h"
-
-#define DIVAS_LOAD_CMD		0x02
-#define DIVAS_START_CMD		0x03
-#define DIVAS_IRQ_RESET		0xC18
-#define DIVAS_IRQ_RESET_VAL	0xFE
-
-#define TEST_INT_DIVAS		0x11
-#define TEST_INT_DIVAS_BRI	0x12
-#define TEST_INT_DIVAS_Q	0x13
-
-#define DIVAS_RESET	0x81
-#define DIVAS_LED1	0x04
-#define DIVAS_LED2	0x08
-#define DIVAS_LED3	0x20
-#define DIVAS_LED4	0x40
-
-#define DIVAS_SIGNATURE 0x4447
-
-#define MP_PROTOCOL_ADDR 0xA0011000
-
-#define PLX_IOBASE	0
-#define	DIVAS_IOBASE	1
-
-typedef struct {
-		dword cmd;
-		dword addr;
-		dword len;
-		dword err;
-		dword live;
-		dword reserved[(0x1020>>2)-6];
-		dword signature;
-		byte  data[1];
-} diva_server_boot_t;
-
-int		DivasCardNext;
-card_t	DivasCards[MAX_CARDS];
-
-dia_config_t *DivasConfig(card_t *, dia_config_t *);
-
-static
-DESCRIPTOR DIDD_Table[32];
-
-void    DIVA_DIDD_Read( DESCRIPTOR *table, int tablelength )
-{
-        memset(table, 0, tablelength);
-
-        if (tablelength > sizeof(DIDD_Table))
-          tablelength = sizeof(DIDD_Table);
-
-        if(tablelength % sizeof(DESCRIPTOR)) {
-          tablelength /= sizeof(DESCRIPTOR);
-          tablelength *= sizeof(DESCRIPTOR);
-        }
-
-        if (tablelength > 0)
-          memcpy((void *)table, (void *)DIDD_Table, tablelength);
-
-	return;
-}
-
-void 	DIVA_DIDD_Write(DESCRIPTOR *table, int tablelength)
-{
-        if (tablelength > sizeof(DIDD_Table))
-          tablelength = sizeof(DIDD_Table);
-
-	memcpy((void *)DIDD_Table, (void *)table, tablelength);
-
-	return;
-}
-
-static
-void    init_idi_tab(void)
-{
-    DESCRIPTOR d[32];
-
-    memset(d, 0, sizeof(d));
-
-    d[0].type = IDI_DIMAINT;  /* identify the DIMAINT entry */
-    d[0].channels = 0; /* zero channels associated with dimaint*/
-    d[0].features = 0; /* no features associated with dimaint */
-    d[0].request = (IDI_CALL) DivasPrintf;
-    
-    DIVA_DIDD_Write(d, sizeof(d));
-
-    return;
-}
-
-/*
- * I/O routines for memory mapped cards
- */
-
-byte mem_in(ADAPTER *a, void *adr)
-{
-	card_t			*card = a->io;
-	unsigned char	*b, *m;
-	byte			value;
-
-	m = b = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY);
-
-	m += (unsigned int) adr;
-
-	value = UxCardMemIn(card->hw, m);
-
-	UxCardMemDetach(card->hw, b);
-
-	return value;
-}
-
-word mem_inw(ADAPTER *a, void *adr)
-{
-	card_t			*card = a->io;
-	unsigned char	*b, *m;
-	word			value;
-
-	m = b = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY);
-
-	m += (unsigned int) adr;
-
-	value = UxCardMemInW(card->hw, m);
-
-	UxCardMemDetach(card->hw, b);
-
-	return value;
-}
-
-void mem_in_buffer(ADAPTER *a, void *adr, void *P, word length)
-{
-	card_t			*card = a->io;
-	unsigned char	*b, *m;
-
-	m = b = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY);
-
-	m += (unsigned int) adr;
-
-	UxCardMemInBuffer(card->hw, m, P, length);
-
-	UxCardMemDetach(card->hw, b);
-
-	return;
-}
-
-void mem_look_ahead(ADAPTER *a, PBUFFER *RBuffer, ENTITY *e)
-{
-	card_t			*card = a->io;
-	unsigned char	*b, *m;
-
-	m = b = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY);
-
-	m += (dword) &RBuffer->length;
-	card->RBuffer.length = UxCardMemInW(card->hw, m);
-
-	m = b;
-	m += (dword) &RBuffer->P;
-	UxCardMemInBuffer(card->hw, m, card->RBuffer.P, card->RBuffer.length);
-
-	e->RBuffer = (DBUFFER *) &card->RBuffer;
-
-	UxCardMemDetach(card->hw, b);
-
-	return;
-}
-
-void mem_out(ADAPTER *a, void *adr, byte data)
-{
-	card_t			*card = a->io;
-	unsigned char	*b, *m;
-
-	m = b = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY);
-
-	m += (unsigned int) adr;
-
-	UxCardMemOut(card->hw, m, data);
-
-	UxCardMemDetach(card->hw, b);
-
-	return;
-}
-
-void mem_outw(ADAPTER *a, void *adr, word data)
-{
-	card_t			*card = a->io;
-	unsigned char	*b, *m;
-
-	m = b = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY);
-
-	m += (unsigned int) adr;
-
-	UxCardMemOutW(card->hw, m, data);
-
-	UxCardMemDetach(card->hw, b);
-
-	return;
-}
-
-void mem_out_buffer(ADAPTER *a, void *adr, void *P, word length)
-{
-	card_t			*card = a->io;
-	unsigned char	*b, *m;
-
-	m = b = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY);
-
-	m += (unsigned int) adr;
-
-	UxCardMemOutBuffer(card->hw, m, P, length);
-
-	UxCardMemDetach(card->hw, b);
-
-	return;
-}
-
-void mem_inc(ADAPTER *a, void *adr)
-{
-	word			value;
-	card_t			*card = a->io;
-	unsigned char	*b, *m;
-
-	m = b = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY);
-
-	m += (unsigned int) adr;
-
-	value = UxCardMemInW(card->hw, m);
-	value++;
-	UxCardMemOutW(card->hw, m, value);
-
-	UxCardMemDetach(card->hw, b);
-
-	return;
-}
-
-/*
- * I/O routines for I/O mapped cards
- */
-
-byte io_in(ADAPTER *a, void *adr)
-{
-	card_t		    *card = a->io;
-	byte		    value;
-	byte	*DivasIOBase = NULL;
-
-	DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE);
-
-	value = UxCardIoIn(card->hw, DivasIOBase, adr);
-
-	UxCardMemDetach(card->hw, DivasIOBase);
-
-    return value;
-}
-
-word io_inw(ADAPTER *a, void *adr)
-{
-	card_t		*card = a->io;
-	word		value;
-	byte	*DivasIOBase = NULL;
-
-	DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE);
-
-	value = UxCardIoInW(card->hw, DivasIOBase, adr);
-
-	UxCardMemDetach(card->hw, DivasIOBase);
-
-	return value;
-}
-
-void io_in_buffer(ADAPTER *a, void *adr, void *P, word length)
-{
-	card_t *card = a->io;
-	byte *DivasIOBase = NULL;
-
-	DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE);
-
-	UxCardIoInBuffer(card->hw, DivasIOBase, adr, P,length);
-
-	UxCardMemDetach(card->hw, DivasIOBase);
-
-    return;
-}
-
-void io_look_ahead(ADAPTER *a, PBUFFER *RBuffer, ENTITY *e)
-{
-	card_t *card = a->io;
-	byte *DivasIOBase = NULL;
-
-	DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE);
-
-	card->RBuffer.length = UxCardIoInW(card->hw, DivasIOBase, (byte *) RBuffer);
-
-	UxCardIoInBuffer(card->hw, DivasIOBase, &RBuffer->P, card->RBuffer.P, card->RBuffer.length);
-
-	UxCardMemDetach(card->hw, DivasIOBase);
-
-	e->RBuffer = (DBUFFER *) &card->RBuffer;
-
-    return;
-}
-
-void io_out(ADAPTER *a, void *adr, byte data)
-{
-	card_t		*card = a->io;
-	byte	*DivasIOBase = NULL;
-
-	DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE);
-
-	UxCardIoOut(card->hw, DivasIOBase, adr, data);
-
-	UxCardMemDetach(card->hw, DivasIOBase);
-
-    return;
-}
-
-void io_outw(ADAPTER *a, void *adr, word data)
-{
-	card_t		*card = a->io;
-	byte	*DivasIOBase = NULL;
-
-	DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE);
-
-	UxCardIoOutW(card->hw, DivasIOBase, adr, data);
-
-	UxCardMemDetach(card->hw, DivasIOBase);
-
-    return;
-}
-
-void io_out_buffer(ADAPTER *a, void *adr, void *P, word length)
-{
-	card_t		*card = a->io;
-	byte *DivasIOBase = NULL;
-
-	DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE);
-
-	UxCardIoOutBuffer(card->hw, DivasIOBase, adr, P, length);
-
-	UxCardMemDetach(card->hw, DivasIOBase);
-
-    return;
-}
-
-void io_inc(ADAPTER *a, void *adr)
-{
-	word		value;
-	card_t		*card = a->io;
-	byte *DivasIOBase;
-
-	DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE);
-
-	value = UxCardIoInW(card->hw, DivasIOBase, adr);
-	
-	value++;
-
-	UxCardIoOutW(card->hw, DivasIOBase, adr, value);
-
-	UxCardMemDetach(card->hw, DivasIOBase);
-
-    return;
-}
-
-static
-void test_int(card_t *card)
-
-{
-	byte *shared, *DivasIOBase;
-
-	switch (card->test_int_pend)
-	{
-		case TEST_INT_DIVAS:
-			DPRINTF(("divas: test interrupt pending"));
-			shared = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY);
-
-			if (UxCardMemIn(card->hw, &shared[0x3FE]))
-			{
-				UxCardMemOut(card->hw, 
-								&(((struct pr_ram *)shared)->RcOutput), 0);
-				UxCardMemDetach(card->hw, shared);
-            	(*card->reset_int)(card);
-				shared = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY);
-				UxCardMemOut(card->hw, &shared[0x3FE], 0);
-				DPRINTF(("divas: test interrupt cleared"));
-			}
-
-			UxCardMemDetach(card->hw, shared);
-
-			card->test_int_pend = 0;
-			break;
-
-		case TEST_INT_DIVAS_BRI:
-			DPRINTF(("divas: BRI test interrupt pending"));
-			(*card->reset_int)(card);
-			DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE);
-			UxCardIoOutW(card->hw, DivasIOBase, (void *) 0x3FE, 0);
-			UxCardMemDetach(card->hw, DivasIOBase);
-			DPRINTF(("divas: test interrupt cleared"));
-			card->test_int_pend = 0;
-			break;
-
-		case TEST_INT_DIVAS_Q:
-			DPRINTF(("divas: 4BRI test interrupt pending"));
-			(*card->reset_int)(card);
-			card->test_int_pend = 0;
-			break;
-
-		default:
-			DPRINTF(("divas: unknown test interrupt pending"));
-			return;
-	}
-	return;
-}
-
-void card_isr (void *dev_id)
-{
-	card_t *card = (card_t *) dev_id;
-	ADAPTER *a = &card->a;
-	int ipl;
-
-	if (card->test_int_pend)
-	{
-		ipl = UxCardLock(card->hw);
-		card->int_pend=0;
-		test_int(card);
-		UxCardUnlock(card->hw,ipl);
-		return;
-	}
-	
-	if(card->card_isr)
-	{
-		(*(card->card_isr))(card);
-	}
-	else
-	{
-		ipl = UxCardLock(card->hw);
-	
-		if ((card->test_int)(a))
-		{
-			(card->reset_int)(card);
-		}
-		
-		UxCardUnlock(card->hw,ipl);
-		
-	}
-
-}
-
-int DivasCardNew(dia_card_t *card_info)
-{
-	card_t *card;
-	static boolean_t first_call = TRUE;
-	boolean_t NeedISRandReset = FALSE;
-
-	DPRINTF(("divas: new card "));
-
-	if (first_call)
-	{
-		first_call = FALSE;
-		init_idi_tab();
-	}
-
-	DivasConfigGet(card_info);
-	
-	if (DivasCardNext == DIM(DivasCards))
-	{
-		KDPRINTF((KERN_WARNING "Divas: no space available for new card"));
-		return -1;
-	}
-
-	card = &DivasCards[DivasCardNext];
-
-	card->state = DIA_UNKNOWN;
-
-	card->cfg = *card_info;
-
-	card->a.io = card;
-
-	if (UxCardHandleGet(&card->hw, card_info))
-	{
-		KDPRINTF((KERN_WARNING "Divas: cannot get OS specific handle for card"));
-		return -1;
-	}
-
-	if (card_info->card_type == DIA_CARD_TYPE_DIVA_SERVER_B)
-	{
-		DivasBriPatch(card);
-		card_info->io_base = card->cfg.io_base;
-	}
-
-	switch (card_info->card_type)
-	{
-		case DIA_CARD_TYPE_DIVA_SERVER:
-			if (DivasPriInit(card, card_info))
-			{
-				return -1;
-			}
-			NeedISRandReset = TRUE;
-			break;
-
-		case DIA_CARD_TYPE_DIVA_SERVER_B:
-			if (DivasBriInit(card, card_info))
-			{
-				return -1;
-			}
-			NeedISRandReset = TRUE;
-			break;
-
- 		case DIA_CARD_TYPE_DIVA_SERVER_Q:
-			if (Divas4BriInit(card, card_info))
-			{
-				return -1;
-			}
-
-			if (card_info->name[6] == '0')
-			{
-				NeedISRandReset = TRUE;
-			}
-			else // Need to set paramater for ISR anyway
-			{
-				card->hw->user_isr_arg = card;
-				card->hw->user_isr = card_isr;
-			}
-			break;   
-
-		default:
-			KDPRINTF((KERN_WARNING "Divas: unsupported card type (%d)", card_info->card_type));
-			return -1;
-	}
-
-	if (NeedISRandReset)
-	{
-		if (UxIsrInstall(card->hw, card_isr, card))
-		{
-			KDPRINTF((KERN_WARNING "Divas: Install ISR failed (IRQ %d)", card->cfg.irq));
-			UxCardHandleFree(card->hw);
-			return -1;
-		}
-
-		if (card_info->card_type != DIA_CARD_TYPE_DIVA_SERVER_Q)
-		{
-			if ((*card->card_reset)(card))
-			{
-				KDPRINTF((KERN_WARNING "Divas: Adapter reset failed"));
-				return -1;
-			}
-			card->state = DIA_RESET;
-		}
-
-		NeedISRandReset = FALSE;
-	}
-
-	DivasCardNext++;
-
-	return 0;
-}
-
-void	*get_card(int card_id)
-{
-	int i;
-
-	for (i=0; i < DivasCardNext; i++)
-	{
-		if (DivasCards[i].cfg.card_id == card_id)
-		{
-			return(&DivasCards[i]);
-		}
-	}
-
-	DPRINTF(("divas: get_card() : no such card id (%d)", card_id));
-
-	return NULL;
-}
-
-int DivasCardConfig(dia_config_t *config)
-{
-	card_t *card;
-	int status;
-
-	DPRINTF(("divas: configuring card"));
-
-	card = get_card(config->card_id);
-	if (!card)
-	{
-		return -1;
-	}
-
-	config = DivasConfig(card, config);
-
-	status = (*card->card_config)(card, config);
-
-	if (!status)
-	{
-		card->state = DIA_CONFIGURED;
-	}
-	return status;
-}
-
-int DivasCardLoad(dia_load_t *load)
-{
-	card_t *card;
-	int	status;
-
-	card = get_card(load->card_id);
-	if (!card)
-	{
-		return -1;
-	}
-
-	if (card->state == DIA_RUNNING)
-	{
-		(*card->card_reset)(card);
-	}
-
-	status = (*card->card_load)(card, load);
-	if (!status)
-	{
-		card->state = DIA_LOADED;
-	}
-	return status;
-}
-
-static int idi_register(card_t *card, byte channels)
-{
-    DESCRIPTOR d[32];
-    int length, num_entities;
-
-	DPRINTF(("divas: registering card with IDI"));
-
-	num_entities = (channels > 2) ? MAX_PENTITIES : MAX_ENTITIES;
-	card->e_tbl = UxAlloc(sizeof(E_INFO) * num_entities);
-
-	if (!card->e_tbl)
-	{
-		KDPRINTF((KERN_WARNING "Divas: IDI register failed - no memory available"));
-		return -1;
-	}
-
-	memset(card->e_tbl, 0, sizeof(E_INFO) * num_entities);
-	card->e_max = num_entities;
-
-    DIVA_DIDD_Read(d, sizeof(d));
-
-        for(length=0; length < DIM(d); length++)
-          if (d[length].type == 0) break;
-
-	if (length >= DIM(d))
-	{
-		KDPRINTF((KERN_WARNING "Divas: IDI register failed - table full"));
-		return -1;
-	}
-
-	switch (card->cfg.card_type)
-	{
-		case DIA_CARD_TYPE_DIVA_SERVER:
-		d[length].type = IDI_ADAPTER_PR;
-		/* d[length].serial = card->serial_no; */
-		break;
-
-		case DIA_CARD_TYPE_DIVA_SERVER_B:
-		d[length].type = IDI_ADAPTER_MAESTRA;
-		/* d[length].serial = card->serial_no; */
-		break;
-
-		// 4BRI is treated as 4 BRI adapters
-		case DIA_CARD_TYPE_DIVA_SERVER_Q:
-		d[length].type = IDI_ADAPTER_MAESTRA;
-		/* d[length].serial = card->cfg.serial; */
-	}
-
-	d[length].features = 0;
-	d[length].features |= DI_FAX3|DI_MODEM|DI_POST|DI_V110|DI_V120;
-
-	if ( card->hw->features & PROTCAP_MANIF )
-	{
-		d[length].features |= DI_MANAGE ;
-	}
-	if ( card->hw->features & PROTCAP_V_42 )
-	{
-		d[length].features |= DI_V_42 ;
-	}
-	if ( card->hw->features & PROTCAP_EXTD_FAX )
-	{
-		d[length].features |= DI_EXTD_FAX ;
-	}
-
-	d[length].channels = channels;
-	d[length].request = DivasIdiRequest[card - DivasCards];
-
-	length++;
-
-	DIVA_DIDD_Write(d, sizeof(d));
-
-    return 0;
-}
-
-int DivasCardStart(int card_id)
-{
-	card_t *card;
-	byte channels;
-	int status;
-
-	DPRINTF(("divas: starting card"));
-
-	card = get_card(card_id);
-	if (!card)
-	{
-		return -1;
-	}
-
-	status = (*card->card_start)(card, &channels);
-	if (status)
-	{
-		return status;
-	}
-
-	/* 4BRI == 4 x BRI so call idi_register 4 times each with 2 channels */
-	if (card->cfg.card_type == DIA_CARD_TYPE_DIVA_SERVER_Q)
-	{
-		int i;
-		card_t *FourBRISlave;
-
-		for (i=3; i >= 0; i--)
-		{
-			FourBRISlave = get_card(card_id - i); /* 0, 1, 2, 3 */
-			if (FourBRISlave)
-			{
-				idi_register(FourBRISlave, 2);
-				FourBRISlave->state = DIA_RUNNING;
-			}
-		}
-		card->serial_no = card->cfg.serial;
-
-		DPRINTF(("divas: card id %d (4BRI), serial no. 0x%x ready with %d channels", 
-				card_id - 3, card->serial_no, (int) channels));
-	}
-	else
-	{
-		status = idi_register(card, channels);
-		if (!status)
-		{
-			card->state = DIA_RUNNING;
-			DPRINTF(("divas: card id %d, serial no. 0x%x ready with %d channels", 
-						card_id, card->serial_no, (int) channels));
-		}
-	}
-
-	return status;
-}
-
-int DivasGetMem(mem_block_t *mem_block)
-{
-	card_t *card;
-	word	card_id = mem_block->card_id;
-
-	card = get_card(card_id);
-	if (!card)
-	{
-		return 0;
-	}
-
-	return (*card->card_mem_get)(card, mem_block);
-}
-
-
-/*
- * Deleyed Procedure Call for handling interrupts from card
- */
-
-void	DivaDoCardDpc(card_t *card)
-{
-	ADAPTER	*a;
-
-	a = &card->a;
-
-	if(UxInterlockedIncrement(card->hw, &card->dpc_reentered) > 1)
-	{
-		return;
-	}
-
-	do{
-		if((*(card->test_int))(a))
-		{
-			(*(card->dpc))(a);
-			(*(card->clear_int))(a);
-		}
-			(*(card->out))(a);
-	}while(UxInterlockedDecrement(card->hw, &card->dpc_reentered));
-			
-}
-
-void	DivasDoDpc(unsigned long dummy)
-{
-	card_t	*card = DivasCards;
-	int 	i = DivasCardNext;
-	
-	while(i--)
-	{
-            if (card->state == DIA_RUNNING)
-		DivaDoCardDpc(card);
-            card++;
-	}
-}
-
-/*
- * DivasGetNum
- * Returns the number of active adapters
- */
-
-int DivasGetNum(void)
-{
-	return(DivasCardNext);
-}
-
-/*
- * DivasGetList
- * Returns a list of active adapters
- */
-int DivasGetList(dia_card_list_t *card_list)
-{
-	int i;
-
-	memset(card_list, 0, sizeof(dia_card_list_t));
-
-	for(i = 0; i < DivasCardNext; i++)
-	{
-		card_list->card_type = DivasCards[i].cfg.card_type;
-		card_list->card_slot = DivasCards[i].cfg.slot;
-		card_list->state     = DivasCards[i].state;
-		card_list++;
-	}
-
-	return 0;
-
-}
-
-/*
- * control logging for specified card
- */
-
-void	DivasLog(dia_log_t *log)
-{
-	card_t *card;
-
-	card = get_card(log->card_id);
-	if (!card)
-	{
-		return;
-	}
-
-	card->log_types = log->log_types;
-
-	return;
-}
-
diff -puN -L drivers/isdn/eicon/constant.h drivers/isdn/eicon/constant.h~linus /dev/null
--- 25/drivers/isdn/eicon/constant.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,161 +0,0 @@
-/*
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.0  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-/*------------------------------------------------------------------*/
-/* Q.931 information elements maximum length                        */
-/* excluding the identifier, including the length field             */
-/*------------------------------------------------------------------*/
-
-#define MAX_LEN_BC      13
-#define MAX_LEN_LLC     19 /* ctr3 */
-#define MAX_LEN_HLC     6  /* ctr3 */
-#define MAX_LEN_UUI     200 /* Hicom USBS req */
-#define MAX_LEN_NUM     24
-#define MAX_LEN_DSP     83 /* ctr3 */
-#define MAX_LEN_NI      4
-#define MAX_LEN_PI      5
-#define MAX_LEN_SIN     3
-#define MAX_LEN_CST     4
-#define MAX_LEN_SIG     2
-#define MAX_LEN_SPID    32
-#define MAX_LEN_EID     3
-#define MAX_LEN_CHI     35  /* ctr3 */
-#define MAX_LEN_CAU     33
-#define MAX_LEN_FTY     130
-#define MAX_LEN_KEY     83  /* ctr3 */
-#define MAX_LEN_RSI     4
-#define MAX_LEN_CAI     11
-#define MAX_NUM_SPID    4
-#define MAX_LEN_USERID  9
-#define MAX_LEN_APPLID  5
-#define MAX_LEN_NTTCIF  15
-
-/*------------------------------------------------------------------*/
-/* decision return values                                           */
-/*------------------------------------------------------------------*/
-
-#define YES             1
-#define NO              0
-
-
-/*-------------------------------------------------------------------*/
-/* w element coding                                                  */
-/*-------------------------------------------------------------------*/
-
-#define NTTCIF          0x01
-#define BC              0x04
-#define CAU             0x08
-#define CAD             0x0c
-#define CAI             0x10
-#define CST             0x14
-#define CHI             0x18
-#define LLI             0x19
-#define CHA             0x1a
-#define FTY             0x1c
-#define PI              0x1e
-#define NFAC            0x20
-#define TC              0x24
-#define ATT_EID         0x26
-#define NI              0x27
-#define DSP             0x28
-#define DT              0x29
-#define KEY             0x2c
-#define KP              0x2c
-#define UID             0x2d
-#define SIG             0x34
-#define FI              0x39
-#define SPID            0x3a
-#define EID             0x3b
-#define DSPF            0x3c
-#define ECAD            0x4c
-#define OAD             0x6c
-#define OSA             0x6d
-#define DAD             0x70
-#define CPN             0x70
-#define DSA             0x71
-#define RDX             0x73
-#define RAD             0x74
-#define RDN             0x74
-#define RSI             0x79
-#define SCR             0x7A   /* internal unscreened CPN          */
-#define MIE             0x7a   /* internal management info element */
-#define LLC             0x7c
-#define HLC             0x7d
-#define UUI             0x7e
-#define ESC             0x7f
-
-#define SHIFT           0x90
-#define MORE            0xa0
-#define CL              0xb0
-
-/* information elements used on the spid interface */
-#define SPID_CMD        0xc0
-#define SPID_LINK       0x10
-#define SPID_DN         0x70
-#define SPID_BC         0x04
-#define SPID_SWITCH     0x11
-
-/*------------------------------------------------------------------*/
-/* global configuration parameters, defined in exec.c               */
-/* these parameters are configured with program loading             */
-/*------------------------------------------------------------------*/
-
-#define PROT_1TR6       0
-#define PROT_ETSI       1
-#define PROT_FRANC      2
-#define PROT_BELG       3
-#define PROT_SWED       4
-#define PROT_NI         5
-#define PROT_5ESS       6
-#define PROT_JAPAN      7
-#define PROT_ATEL       8
-#define PROT_US         9
-#define PROT_ITALY      10
-#define PROT_TWAN       11
-#define PROT_AUSTRAL    12
-
-#define INIT_PROT_1TR6    0x80|PROT_1TR6
-#define INIT_PROT_ETSI    0x80|PROT_ETSI
-#define INIT_PROT_FRANC   0x80|PROT_FRANC
-#define INIT_PROT_BELG    0x80|PROT_BELG
-#define INIT_PROT_SWED    0x80|PROT_SWED
-#define INIT_PROT_NI      0x80|PROT_NI
-#define INIT_PROT_5ESS    0x80|PROT_5ESS
-#define INIT_PROT_JAPAN   0x80|PROT_JAPAN
-#define INIT_PROT_ATEL    0x80|PROT_ATEL
-#define INIT_PROT_ITALY   0x80|PROT_ITALY
-#define INIT_PROT_TWAN    0x80|PROT_TWAN
-#define INIT_PROT_AUSTRAL 0x80|PROT_AUSTRAL
-
-
-/* -----------------------------------------------------------**
-** The PROTOCOL_FEATURE_STRING in feature.h (included         **
-** in prstart.sx and astart.sx) defines capabilities and      **
-** features of the actual protocol code. It's used as a bit   **
-** mask.                                                      **
-** The following Bits are defined:                            **
-** -----------------------------------------------------------*/
-                                           
-#define PROTCAP_TELINDUS  0x0001  /* Telindus Variant of protocol code   */
-#define PROTCAP_MANIF     0x0002  /* Management interface implemented    */
-#define PROTCAP_V_42      0x0004  /* V42 implemented                     */
-#define PROTCAP_V90D      0x0008  /* V.90D (implies up to 384k DSP code) */
-#define PROTCAP_EXTD_FAX  0x0010  /* Extended FAX (ECM, 2D, T6, Polling) */
-#define PROTCAP_FREE4     0x0020  /* not used                            */
-#define PROTCAP_FREE5     0x0040  /* not used                            */
-#define PROTCAP_FREE6     0x0080  /* not used                            */
-#define PROTCAP_FREE7     0x0100  /* not used                            */
-#define PROTCAP_FREE8     0x0200  /* not used                            */
-#define PROTCAP_FREE9     0x0400  /* not used                            */
-#define PROTCAP_FREE10    0x0800  /* not used                            */
-#define PROTCAP_FREE11    0x1000  /* not used                            */
-#define PROTCAP_FREE12    0x2000  /* not used                            */
-#define PROTCAP_FREE13    0x4000  /* not used                            */
-#define PROTCAP_EXTENSION 0x8000  /* used for future extentions          */
diff -puN -L drivers/isdn/eicon/divalog.h drivers/isdn/eicon/divalog.h~linus /dev/null
--- 25/drivers/isdn/eicon/divalog.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,38 +0,0 @@
-/*
- * Include file for defining the kernel logger messages
- * These definitions are shared between the klog driver and the
- * klogd daemon process
- *
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.0  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#if !defined(_KLOGMSG_H)
-#define _KLOGMSG_H
-
-/* define a type for a log entry */
-
-#define KLOG_TEXT_MSG   	(0)
-#define KLOG_XLOG_MSG   	(1)
-#define KLOG_XTXT_MSG   	(2)
-#define KLOG_IDI_REQ   		(4)
-#define KLOG_IDI_CALLBACK   (5)
-#define KLOG_CAPI_MSG   	(6)
-
-typedef struct
-{
-    unsigned long   time_stamp; /* in ms since last system boot */
-    int    			card;       /* card number (-1 for all) */
-    unsigned int    type;       /* type of log message (0 is text) */
-    unsigned int    length;     /* message length (non-text messages only) */
-    unsigned short  code;       /* message code (non-text messages only) */
-    char            buffer[110];/* text/data to log */
-} klog_t;
-
-void    DivasLogAdd(void *buffer, int length);
-#endif /* of _KLOGMSG_H */
diff -puN -L drivers/isdn/eicon/divas.h drivers/isdn/eicon/divas.h~linus /dev/null
--- 25/drivers/isdn/eicon/divas.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,214 +0,0 @@
-/*
- * External Diva Server driver include file
- *
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.5  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#if !defined(DIVAS_H)
-#define DIVAS_H
-
-#include "sys.h"
-
-
-/* IOCTL commands */
-
-#define	DIA_IOCTL_INIT				(0)
-#define	DIA_IOCTL_LOAD				(1)
-#define	DIA_IOCTL_CONFIG			(2)
-#define	DIA_IOCTL_START				(3)
-#define	DIA_IOCTL_GET_NUM			(4)
-#define	DIA_IOCTL_GET_LIST			(5)
-#define	DIA_IOCTL_LOG				(6)
-#define	DIA_IOCTL_DETECT			(7)
-#define	DIA_IOCTL_SPACE				(8)
-#define DIA_IOCTL_GET_MEM           (9)
-#define DIA_IOCTL_FLAVOUR			(10)
-#define	DIA_IOCTL_XLOG_REQ			(11)
-
-/* Error codes */
-
-#define XLOG_ERR_CARD_NUM	(13)
-#define XLOG_ERR_DONE		(14)
-#define XLOG_ERR_CMD		(15)
-#define XLOG_ERR_TIMEOUT	(16)
-#define XLOG_ERR_CARD_STATE	(17)
-#define XLOG_ERR_UNKNOWN	(18)
-#define XLOG_OK 			(0)
-
-/* Adapter states */
-
-#define DIA_UNKNOWN		(0)
-#define DIA_RESET		(1)
-#define DIA_LOADED		(2)
-#define DIA_CONFIGURED	(3)
-#define DIA_RUNNING		(4)
-
-/* Stucture for getting card specific information from active cad driver */
-
-typedef struct
-{
-	int card_type;
-	int card_slot;
-	int	state;
-} dia_card_list_t;
-
-/* use following to select which logging to have active */
-
-#define	DIVAS_LOG_DEBUG		(1 << 0)
-#define	DIVAS_LOG_XLOG		(1 << 1)
-#define	DIVAS_LOG_IDI		(1 << 2)
-#define	DIVAS_LOG_CAPI		(1 << 3)
-
-/* stucture for DIA_IOCTL_LOG to get information from adapter */
-
-typedef struct
-{
-	int		card_id;
-	int		log_types;	/* bit mask of log types: use DIVAS_LOG_XXX */
-} dia_log_t;
-
-/* list of cards supported by this driver */
-
-#define	DIA_CARD_TYPE_DIVA_SERVER	(0)	/* Diva Server PRI */
-#define	DIA_CARD_TYPE_DIVA_SERVER_B	(1)	/* Diva Server BRI */
-#define	DIA_CARD_TYPE_DIVA_SERVER_Q	(2)	/* Diva Server 4-BRI */
-
-/* bus types */
-
-#define	DIA_BUS_TYPE_ISA		(0)
-#define	DIA_BUS_TYPE_ISA_PNP	(1)
-#define	DIA_BUS_TYPE_PCI		(2)
-#define	DIA_BUS_TYPE_MCA		(3)
-
-/* types of memory used (index for memory array below) */
-
-#define DIVAS_RAM_MEMORY 	0
-#define DIVAS_REG_MEMORY 	1
-#define DIVAS_CFG_MEMORY 	2
-#define DIVAS_SHARED_MEMORY 3
-#define DIVAS_CTL_MEMORY	4
-/*
- * card config information
- * passed as parameter to DIA_IOCTL_INIT ioctl to initialise new card
- */
-
-typedef struct
-{
-	int		card_id;	/* unique id assigned to this card */
-	int		card_type;	/* use DIA_CARD_TYPE_xxx above */
-	int		bus_type;	/* use DIA_BUS_TYPE_xxx above */
-	struct pci_dev *pdev;
-	int		slot;		/* slot number in bus */
-	unsigned char	irq;		/* IRQ number */
-    int     reset_base; /* Reset register  for I/O mapped cards */
-	int		io_base;	/* I/O base for I/O mapped cards */
-	void	*memory[5];	/* memory base addresses for memory mapped cards */
-	char	name[9];	/* name of adapter */
-	int		serial;		/* serial number */
-	unsigned char	int_priority;	/* Interrupt priority */
-} dia_card_t;
-
-/*
- * protocol configuration information
- * passed as parameter to DIA_IOCTL_CONFIG ioctl to configure card
- */
-
-typedef struct
-{
-	int				card_id;			/* to identify particular card */
-	unsigned char	tei;
-	unsigned char	nt2;
-	unsigned char	watchdog;
-	unsigned char	permanent;
-	unsigned char	x_interface;
-	unsigned char	stable_l2;
-	unsigned char	no_order_check;
-	unsigned char	handset_type;
-	unsigned char	sig_flags;
-	unsigned char	low_channel;
-	unsigned char	prot_version;
-	unsigned char	crc4;
-	struct
-	{
-		unsigned char oad[32];
-		unsigned char osa[32];
-		unsigned char spid[32];
-	}terminal[2];
-} dia_config_t;
-
-/*
- * code configuration 
- * passed as parameter to DIA_IOCTL_LOAD ioctl
- * one of these ioctl per code file to load
- */
-
-typedef struct
-{
-	int				card_id;	/* card to load */
-	enum
-	{
-		DIA_CPU_CODE,			/* CPU code */
-		DIA_DSP_CODE,			/* DSP code */
-		DIA_CONT_CODE,			/* continuation of code */
-		DIA_TABLE_CODE,			/* code table */
-	        DIA_DLOAD_CNT,           /* number of downloads*/
-		DIA_FPGA_CODE
-	}				code_type;	/* code for CPU or DSP ? */
-	int				length;		/* length of code */
-	unsigned char	*code;		/* pointer (in user-space) to code */
-} dia_load_t;
-
-/*
- * start configuration 
- * passed as parameter to DIA_IOCTL_START ioctl
- */
-
-typedef struct
-{
-	int				card_id;	/* card to start */
-} dia_start_t;
-
-/* used for retrieving memory from the card */
-
-typedef struct {
-	word	card_id;
-	dword 	addr;
-	byte	data[16 * 8];
-} mem_block_t;
-
-/* DIVA Server specific addresses */
-
-#define DIVAS_CPU_START_ADDR    (0x0)
-#define	ORG_MAX_PROTOCOL_CODE_SIZE	0x000A0000
-#define	ORG_MAX_DSP_CODE_SIZE		(0x000F0000 - ORG_MAX_PROTOCOL_CODE_SIZE)
-#define	ORG_DSP_CODE_BASE		(0xBF7F0000 - ORG_MAX_DSP_CODE_SIZE)
-#define DIVAS_DSP_START_ADDR    (0xBF7A0000)
-#define DIVAS_SHARED_OFFSET     (0x1000)
-#define MP_DSP_CODE_BASE           0xa03a0000
-#define MQ_PROTCODE_OFFSET  0x100000
-#define MQ_SM_OFFSET		0X0f0000
-
-#define	V90D_MAX_PROTOCOL_CODE_SIZE	0x00090000
-#define V90D_MAX_DSP_CODE_SIZE		(0x000F0000 - V90D_MAX_PROTOCOL_CODE_SIZE)
-#define	V90D_DSP_CODE_BASE		(0xBF7F0000 - V90D_MAX_DSP_CODE_SIZE)
-
-#define MQ_ORG_MAX_PROTOCOL_CODE_SIZE   0x000a0000  /* max 640K Protocol-Code */
-#define MQ_ORG_MAX_DSP_CODE_SIZE        0x00050000  /* max 320K DSP-Code */
-#define MQ_ORG_DSP_CODE_BASE           (MQ_MAX_DSP_DOWNLOAD_ADDR \
-                                      - MQ_ORG_MAX_DSP_CODE_SIZE)
-#define MQ_V90D_MAX_PROTOCOL_CODE_SIZE  0x00090000  /* max 576K Protocol-Code */
-#define MQ_V90D_MAX_DSP_CODE_SIZE       0x00060000  /* max 384K DSP-Code if V.90D included */
-#define	MQ_MAX_DSP_DOWNLOAD_ADDR        0xa03f0000
-#define MQ_V90D_DSP_CODE_BASE          (MQ_MAX_DSP_DOWNLOAD_ADDR \
-                                      - MQ_V90D_MAX_DSP_CODE_SIZE)
-
-
-#define ALIGNMENT_MASK_MAESTRA        0xfffffffc
-
-#endif /* DIVAS_H */
diff -puN -L drivers/isdn/eicon/Divas_mod.c drivers/isdn/eicon/Divas_mod.c~linus /dev/null
--- 25/drivers/isdn/eicon/Divas_mod.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,134 +0,0 @@
-/*
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/fs.h>
-#undef N_DATA
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/ioport.h>
-#include <linux/slab.h>
-#include <linux/errno.h>
-
-#include "adapter.h"
-#include "uxio.h"
-
-
-MODULE_DESCRIPTION("ISDN4Linux: Driver for Eicon Diva Server cards");
-MODULE_AUTHOR("Armin Schindler");
-MODULE_LICENSE("GPL");
-
-void DivasInitDpc(void);
-
-#ifdef MODULE
-#include "idi.h"
-void DIVA_DIDD_Write(DESCRIPTOR *, int);
-EXPORT_SYMBOL_NOVERS(DIVA_DIDD_Read);
-EXPORT_SYMBOL_NOVERS(DIVA_DIDD_Write);
-EXPORT_SYMBOL_NOVERS(DivasPrintf);
-#endif
-
-int DivasCardsDiscover(void);
-
-static int __init
-divas_init(void)
-{
-	printk(KERN_DEBUG "DIVA Server Driver - initialising\n");
-	
-	printk(KERN_DEBUG "DIVA Server Driver - Version 2.0.16\n");
-
-#if !defined(CONFIG_PCI)
-	printk(KERN_WARNING "CONFIG_PCI is not defined!\n");
-	return -ENODEV;
-#endif
-
-	DivasInitDpc();
-
-	if (DivasCardsDiscover() < 0)
-	{
-		printk(KERN_WARNING "Divas: Not loaded\n");
-		return -ENODEV;
-	}
-
-    return 0;
-}
-
-static void __exit
-divas_exit(void)
-{
-	card_t *pCard;
-	word wCardIndex;
-	extern int Divas_major;
-
-	printk(KERN_DEBUG "DIVA Server Driver - unloading\n");
-
-	pCard = DivasCards;
-	for (wCardIndex = 0; wCardIndex < MAX_CARDS; wCardIndex++)
-	{
-		if ((pCard->hw) && (pCard->hw->in_use))
-		{
-
-			(*pCard->card_reset)(pCard);
-			
-			UxIsrRemove(pCard->hw, pCard);
-			UxCardHandleFree(pCard->hw);
-
-			if(pCard->e_tbl != NULL)
-			{
-				kfree(pCard->e_tbl);
-			}
-
-			
-			if(pCard->hw->card_type == DIA_CARD_TYPE_DIVA_SERVER_B)
-			{	
-				release_region(pCard->hw->io_base,0x20);		
-				release_region(pCard->hw->reset_base,0x80);		
-			}
-
-			// If this is a 4BRI ...
-			if (pCard->hw->card_type == DIA_CARD_TYPE_DIVA_SERVER_Q)
-			{
-				// Skip over the next 3 virtual adapters
-				wCardIndex += 3;
-
-				// But free their handles 
-				pCard++;
-				UxCardHandleFree(pCard->hw);
-			
-				if(pCard->e_tbl != NULL)
-				{
-					kfree(pCard->e_tbl);
-				}
-				
-				pCard++;
-				UxCardHandleFree(pCard->hw);
-				
-				if(pCard->e_tbl != NULL)
-				{
-					kfree(pCard->e_tbl);
-				}
-				
-				pCard++;
-				UxCardHandleFree(pCard->hw);
-				
-				if(pCard->e_tbl != NULL)
-				{
-					kfree(pCard->e_tbl);
-				}
-			}
-		}
-		pCard++;
-	}
-
-	unregister_chrdev(Divas_major, "Divas");
-}
-
-module_init(divas_init);
-module_exit(divas_exit);
-
diff -puN -L drivers/isdn/eicon/dsp_defs.h drivers/isdn/eicon/dsp_defs.h~linus /dev/null
--- 25/drivers/isdn/eicon/dsp_defs.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,286 +0,0 @@
-/*
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.0  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#ifndef DSP_DEFS_H_
-#define DSP_DEFS_H_
-
-#ifndef DSPDIDS_H_
-#include "dspdids.h"
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*---------------------------------------------------------------------------*/
-
-#ifndef NULL
-#define NULL 0
-#endif
-#ifndef TRUE
-#define TRUE (0 == 0)
-#endif
-#ifndef FALSE
-#define FALSE (0 != 0)
-#endif
-
-
-/*---------------------------------------------------------------------------*/
-
-#define DSP_MEMORY_TYPE_EXTERNAL_DM         0
-#define DSP_MEMORY_TYPE_EXTERNAL_PM         1
-#define DSP_MEMORY_TYPE_INTERNAL_DM         2
-#define DSP_MEMORY_TYPE_INTERNAL_PM         3
-
-#define DSP_DOWNLOAD_FLAG_BOOTABLE          0x0001
-#define DSP_DOWNLOAD_FLAG_2181              0x0002
-#define DSP_DOWNLOAD_FLAG_TIMECRITICAL      0x0004
-#define DSP_DOWNLOAD_FLAG_COMPAND           0x0008
-
-#define DSP_MEMORY_BLOCK_COUNT              16
-
-#define DSP_SEGMENT_PM_FLAG                 0x0001
-#define DSP_SEGMENT_SHARED_FLAG             0x0002
-
-#define DSP_SEGMENT_EXTERNAL_DM             DSP_MEMORY_TYPE_EXTERNAL_DM
-#define DSP_SEGMENT_EXTERNAL_PM             DSP_MEMORY_TYPE_EXTERNAL_PM
-#define DSP_SEGMENT_INTERNAL_DM             DSP_MEMORY_TYPE_INTERNAL_DM
-#define DSP_SEGMENT_INTERNAL_PM             DSP_MEMORY_TYPE_INTERNAL_PM
-#define DSP_SEGMENT_FIRST_RELOCATABLE       4
-
-#define DSP_DATA_BLOCK_PM_FLAG              0x0001
-#define DSP_DATA_BLOCK_DWORD_FLAG           0x0002
-#define DSP_DATA_BLOCK_RESOLVE_FLAG         0x0004
-
-#define DSP_RELOC_NONE                      0x00
-#define DSP_RELOC_SEGMENT_MASK              0x3f
-#define DSP_RELOC_TYPE_MASK                 0xc0
-#define DSP_RELOC_TYPE_0                    0x00  /* relocation of address in DM word / high part of PM word */
-#define DSP_RELOC_TYPE_1                    0x40  /* relocation of address in low part of PM data word */
-#define DSP_RELOC_TYPE_2                    0x80  /* relocation of address in standard command */
-#define DSP_RELOC_TYPE_3                    0xc0  /* relocation of address in call/jump on flag in */
-
-#define DSP_COMBIFILE_FORMAT_IDENTIFICATION_SIZE 48
-#define DSP_COMBIFILE_FORMAT_VERSION_BCD    0x0100
-
-#define DSP_FILE_FORMAT_IDENTIFICATION_SIZE 48
-#define DSP_FILE_FORMAT_VERSION_BCD         0x0100
-
-
-typedef struct tag_dsp_combifile_header
-{
-  char                  format_identification[DSP_COMBIFILE_FORMAT_IDENTIFICATION_SIZE];
-  word                  format_version_bcd;
-  word                  header_size;
-  word                  combifile_description_size;
-  word                  directory_entries;
-  word                  directory_size;
-  word                  download_count;
-  word                  usage_mask_size;
-} t_dsp_combifile_header;
-
-typedef struct tag_dsp_combifile_directory_entry
-{
-  word                  card_type_number;
-  word                  file_set_number;
-} t_dsp_combifile_directory_entry;
-
-typedef struct tag_dsp_file_header
-{
-  char                  format_identification[DSP_FILE_FORMAT_IDENTIFICATION_SIZE];
-  word                  format_version_bcd;
-  word                  download_id;
-  word                  download_flags;
-  word                  required_processing_power;
-  word                  interface_channel_count;
-  word                  header_size;
-  word                  download_description_size;
-  word                  memory_block_table_size;
-  word                  memory_block_count;
-  word                  segment_table_size;
-  word                  segment_count;
-  word                  symbol_table_size;
-  word                  symbol_count;
-  word                  total_data_size_dm;
-  word                  data_block_count_dm;
-  word                  total_data_size_pm;
-  word                  data_block_count_pm;
-} t_dsp_file_header;
-
-typedef struct tag_dsp_memory_block_desc
-{
-  word                  alias_memory_block;
-  word                  memory_type;
-  word                  address;
-  word                  size;             /* DSP words */
-} t_dsp_memory_block_desc;
-
-typedef struct tag_dsp_segment_desc
-{
-  word                  memory_block;
-  word                  attributes;
-  word                  base;
-  word                  size;
-  word                  alignment;        /* ==0 -> no other legal start address than base */
-} t_dsp_segment_desc;
-
-typedef struct tag_dsp_symbol_desc
-{
-  word                  symbol_id;
-  word                  segment;
-  word                  offset;
-  word                  size;             /* DSP words */
-} t_dsp_symbol_desc;
-
-typedef struct tag_dsp_data_block_header
-{
-  word                  attributes;
-  word                  segment;
-  word                  offset;
-  word                  size;             /* DSP words */
-} t_dsp_data_block_header;
-
-typedef struct tag_dsp_download_desc      /* be sure to keep native alignment for MAESTRA's */
-{
-  word                  download_id;
-  word                  download_flags;
-  word                  required_processing_power;
-  word                  interface_channel_count;
-  word                  excess_header_size;
-  word                  memory_block_count;
-  word                  segment_count;
-  word                  symbol_count;
-  word                  data_block_count_dm;
-  word                  data_block_count_pm;
-  byte              	*p_excess_header_data;
-  char 					*p_download_description;
-  t_dsp_memory_block_desc *p_memory_block_table;
-  t_dsp_segment_desc 	*p_segment_table;
-  t_dsp_symbol_desc 	*p_symbol_table;
-  word 					*p_data_blocks_dm;
-  word 					*p_data_blocks_pm;
-} t_dsp_download_desc;
-
-#define DSP_DOWNLOAD_INDEX_KERNEL               0
-#define DSP30TX_DOWNLOAD_INDEX_KERNEL           1
-#define DSP30RX_DOWNLOAD_INDEX_KERNEL           2
-#define DSP_MAX_DOWNLOAD_COUNT                  35
-
-
-#define DSP_DOWNLOAD_MAX_SEGMENTS         16
-
-#define DSP_UDATA_REQUEST_RECONFIGURE     0
-/*
-parameters:
-  <word> reconfigure delay (in 8kHz samples)
-  <word> reconfigure code
-  <byte> reconfigure hdlc preamble flags
-*/
-
-#define DSP_RECONFIGURE_TX_FLAG           0x8000
-#define DSP_RECONFIGURE_SHORT_TRAIN_FLAG  0x4000
-#define DSP_RECONFIGURE_ECHO_PROTECT_FLAG 0x2000
-#define DSP_RECONFIGURE_HDLC_FLAG         0x1000
-#define DSP_RECONFIGURE_SYNC_FLAG         0x0800
-#define DSP_RECONFIGURE_PROTOCOL_MASK     0x00ff
-#define DSP_RECONFIGURE_IDLE              0
-#define DSP_RECONFIGURE_V25               1
-#define DSP_RECONFIGURE_V21_CH2           2
-#define DSP_RECONFIGURE_V27_2400          3
-#define DSP_RECONFIGURE_V27_4800          4
-#define DSP_RECONFIGURE_V29_7200          5
-#define DSP_RECONFIGURE_V29_9600          6
-#define DSP_RECONFIGURE_V33_12000         7
-#define DSP_RECONFIGURE_V33_14400         8
-#define DSP_RECONFIGURE_V17_7200          9
-#define DSP_RECONFIGURE_V17_9600          10
-#define DSP_RECONFIGURE_V17_12000         11
-#define DSP_RECONFIGURE_V17_14400         12
-
-/*
-data indications if transparent framer
-  <byte> data 0
-  <byte> data 1
-  ...
-
-data indications if HDLC framer
-  <byte> data 0
-  <byte> data 1
-  ...
-  <byte> CRC 0
-  <byte> CRC 1
-  <byte> preamble flags
-*/
-
-#define DSP_UDATA_INDICATION_SYNC         0
-/*
-returns:
-  <word> time of sync (sampled from counter at 8kHz)
-*/
-
-#define DSP_UDATA_INDICATION_DCD_OFF      1
-/*
-returns:
-  <word> time of DCD off (sampled from counter at 8kHz)
-*/
-
-#define DSP_UDATA_INDICATION_DCD_ON       2
-/*
-returns:
-  <word> time of DCD on (sampled from counter at 8kHz)
-  <byte> connected norm
-  <word> connected options
-  <dword> connected speed (bit/s)
-*/
-
-#define DSP_UDATA_INDICATION_CTS_OFF      3
-/*
-returns:
-  <word> time of CTS off (sampled from counter at 8kHz)
-*/
-
-#define DSP_UDATA_INDICATION_CTS_ON       4
-/*
-returns:
-  <word> time of CTS on (sampled from counter at 8kHz)
-  <byte> connected norm
-  <word> connected options
-  <dword> connected speed (bit/s)
-*/
-
-#define DSP_CONNECTED_NORM_UNSPECIFIED      0
-#define DSP_CONNECTED_NORM_V21              1
-#define DSP_CONNECTED_NORM_V23              2
-#define DSP_CONNECTED_NORM_V22              3
-#define DSP_CONNECTED_NORM_V22_BIS          4
-#define DSP_CONNECTED_NORM_V32_BIS          5
-#define DSP_CONNECTED_NORM_V34              6
-#define DSP_CONNECTED_NORM_V8               7
-#define DSP_CONNECTED_NORM_BELL_212A        8
-#define DSP_CONNECTED_NORM_BELL_103         9
-#define DSP_CONNECTED_NORM_V29_LEASED_LINE  10
-#define DSP_CONNECTED_NORM_V33_LEASED_LINE  11
-#define DSP_CONNECTED_NORM_TFAST            12
-#define DSP_CONNECTED_NORM_V21_CH2          13
-#define DSP_CONNECTED_NORM_V27_TER          14
-#define DSP_CONNECTED_NORM_V29              15
-#define DSP_CONNECTED_NORM_V33              16
-#define DSP_CONNECTED_NORM_V17              17
-
-#define DSP_CONNECTED_OPTION_TRELLIS        0x0001
-
-
-/*---------------------------------------------------------------------------*/
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-/*---------------------------------------------------------------------------*/
diff -puN -L drivers/isdn/eicon/dspdids.h drivers/isdn/eicon/dspdids.h~linus /dev/null
--- 25/drivers/isdn/eicon/dspdids.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.0  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#ifndef DSPDIDS_H_
-#define DSPDIDS_H_
-
-
-/*---------------------------------------------------------------------------*/
-
-#define DSP_DID_INVALID			0
-#define DSP_DID_DIVA			1
-#define DSP_DID_DIVA_PRO		2
-#define DSP_DID_DIVA_PRO_20		3
-#define DSP_DID_DIVA_PRO_PCCARD		4
-#define DSP_DID_DIVA_SERVER_BRI_1M	5
-#define DSP_DID_DIVA_SERVER_BRI_2M	6
-#define DSP_DID_DIVA_SERVER_PRI_2M_TX	7
-#define DSP_DID_DIVA_SERVER_PRI_2M_RX	8
-#define DSP_DID_DIVA_SERVER_PRI_30M	9
-#define DSP_DID_TASK_HSCX		100
-#define DSP_DID_TASK_HSCX_PRI_2M_TX	101
-#define DSP_DID_TASK_HSCX_PRI_2M_RX	102
-#define DSP_DID_TASK_V110KRNL		200
-#define DSP_DID_OVERLAY_V1100		201
-#define DSP_DID_OVERLAY_V1101		202
-#define DSP_DID_OVERLAY_V1102		203
-#define DSP_DID_OVERLAY_V1103		204
-#define DSP_DID_OVERLAY_V1104		205
-#define DSP_DID_OVERLAY_V1105		206
-#define DSP_DID_OVERLAY_V1106		207
-#define DSP_DID_OVERLAY_V1107		208
-#define DSP_DID_OVERLAY_V1108		209
-#define DSP_DID_OVERLAY_V1109		210
-#define DSP_DID_TASK_V110_PRI_2M_TX	220
-#define DSP_DID_TASK_V110_PRI_2M_RX	221
-#define DSP_DID_TASK_MODEM		300
-#define DSP_DID_TASK_FAX05		400
-#define DSP_DID_TASK_VOICE		500
-#define DSP_DID_TASK_TIKRNL81		600
-#define DSP_DID_OVERLAY_DIAL		601
-#define DSP_DID_OVERLAY_V22		602
-#define DSP_DID_OVERLAY_V32		603
-#define DSP_DID_OVERLAY_FSK		604
-#define DSP_DID_OVERLAY_FAX		605
-#define DSP_DID_OVERLAY_VXX		606
-#define DSP_DID_OVERLAY_V8		607
-#define DSP_DID_OVERLAY_INFO		608
-#define DSP_DID_OVERLAY_V34		609
-#define DSP_DID_OVERLAY_DFX		610
-#define DSP_DID_PARTIAL_OVERLAY_DIAL	611
-#define DSP_DID_PARTIAL_OVERLAY_FSK	612
-#define DSP_DID_PARTIAL_OVERLAY_FAX	613
-#define DSP_DID_TASK_TIKRNL05		700
-
-
-/*---------------------------------------------------------------------------*/
-
-#endif
-
-/*---------------------------------------------------------------------------*/
diff -puN -L drivers/isdn/eicon/eicon_dsp.h drivers/isdn/eicon/eicon_dsp.h~linus /dev/null
--- 25/drivers/isdn/eicon/eicon_dsp.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,285 +0,0 @@
-/* $Id: eicon_dsp.h,v 1.1.4.1.2.2 2002/10/01 11:29:13 armin Exp $
- *
- * ISDN lowlevel-module for Eicon active cards.
- * DSP definitions
- *
- * Copyright 1999,2000  by Armin Schindler (mac@melware.de)
- * Copyright 1999,2000  Cytronics & Melware (info@melware.de)
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#ifndef DSP_H 
-#define DSP_H
-
-#include "dsp_defs.h"
-
-
-#define DSP_UDATA_REQUEST_SWITCH_FRAMER         1
-/*
-parameters:
-  <byte> transmit framer type
-  <byte> receive framer type
-*/
-
-#define DSP_REQUEST_SWITCH_FRAMER_HDLC          0
-#define DSP_REQUEST_SWITCH_FRAMER_TRANSPARENT   1
-#define DSP_REQUEST_SWITCH_FRAMER_ASYNC         2
-
-
-#define DSP_UDATA_REQUEST_CLEARDOWN             2
-/*
-parameters:
-  - none -
-*/
-
-
-#define DSP_UDATA_REQUEST_TX_CONFIRMATION_ON    3
-/*
-parameters:
-  - none -
-*/
-
-
-#define DSP_UDATA_REQUEST_TX_CONFIRMATION_OFF   4
-/*
-parameters:
-  - none -
-*/
-
-typedef struct eicon_dsp_ind {
-	__u16	time		__attribute__ ((packed));
-	__u8	norm		__attribute__ ((packed));
-	__u16	options		__attribute__ ((packed));
-	__u32	speed		__attribute__ ((packed));
-	__u16	delay		__attribute__ ((packed));
-	__u32	txspeed		__attribute__ ((packed));
-	__u32	rxspeed		__attribute__ ((packed));
-} eicon_dsp_ind;
-
-#define DSP_CONNECTED_OPTION_V42_TRANS           0x0002
-#define DSP_CONNECTED_OPTION_V42_LAPM            0x0004
-#define DSP_CONNECTED_OPTION_SHORT_TRAIN         0x0008
-#define DSP_CONNECTED_OPTION_TALKER_ECHO_PROTECT 0x0010
-
-#define DSP_UDATA_INDICATION_DISCONNECT         5
-/*
-returns:
-  <byte> cause
-*/
-
-#define DSP_DISCONNECT_CAUSE_NONE               0x00
-#define DSP_DISCONNECT_CAUSE_BUSY_TONE          0x01
-#define DSP_DISCONNECT_CAUSE_CONGESTION_TONE    0x02
-#define DSP_DISCONNECT_CAUSE_INCOMPATIBILITY    0x03
-#define DSP_DISCONNECT_CAUSE_CLEARDOWN          0x04
-#define DSP_DISCONNECT_CAUSE_TRAINING_TIMEOUT   0x05
-
-#define DSP_UDATA_INDICATION_TX_CONFIRMATION    6
-/*
-returns:
-  <word> confirmation number
-*/
-
-
-#define DSP_UDATA_REQUEST_SEND_DTMF_DIGITS      16
-/*
-parameters:
-  <word> tone duration (ms)
-  <word> gap duration (ms)
-  <byte> digit 0 tone code
-  ...
-  <byte> digit n tone code
-*/
-
-#define DSP_SEND_DTMF_DIGITS_HEADER_LENGTH      5
-
-#define DSP_DTMF_DIGIT_TONE_LOW_GROUP_697_HZ    0x00
-#define DSP_DTMF_DIGIT_TONE_LOW_GROUP_770_HZ    0x01
-#define DSP_DTMF_DIGIT_TONE_LOW_GROUP_852_HZ    0x02
-#define DSP_DTMF_DIGIT_TONE_LOW_GROUP_941_HZ    0x03
-#define DSP_DTMF_DIGIT_TONE_LOW_GROUP_MASK      0x03
-#define DSP_DTMF_DIGIT_TONE_HIGH_GROUP_1209_HZ  0x00
-#define DSP_DTMF_DIGIT_TONE_HIGH_GROUP_1336_HZ  0x04
-#define DSP_DTMF_DIGIT_TONE_HIGH_GROUP_1477_HZ  0x08
-#define DSP_DTMF_DIGIT_TONE_HIGH_GROUP_1633_HZ  0x0c
-#define DSP_DTMF_DIGIT_TONE_HIGH_GROUP_MASK     0x0c
-
-#define DSP_DTMF_DIGIT_TONE_CODE_0              0x07
-#define DSP_DTMF_DIGIT_TONE_CODE_1              0x00
-#define DSP_DTMF_DIGIT_TONE_CODE_2              0x04
-#define DSP_DTMF_DIGIT_TONE_CODE_3              0x08
-#define DSP_DTMF_DIGIT_TONE_CODE_4              0x01
-#define DSP_DTMF_DIGIT_TONE_CODE_5              0x05
-#define DSP_DTMF_DIGIT_TONE_CODE_6              0x09
-#define DSP_DTMF_DIGIT_TONE_CODE_7              0x02
-#define DSP_DTMF_DIGIT_TONE_CODE_8              0x06
-#define DSP_DTMF_DIGIT_TONE_CODE_9              0x0a
-#define DSP_DTMF_DIGIT_TONE_CODE_STAR           0x03
-#define DSP_DTMF_DIGIT_TONE_CODE_HASHMARK       0x0b
-#define DSP_DTMF_DIGIT_TONE_CODE_A              0x0c
-#define DSP_DTMF_DIGIT_TONE_CODE_B              0x0d
-#define DSP_DTMF_DIGIT_TONE_CODE_C              0x0e
-#define DSP_DTMF_DIGIT_TONE_CODE_D              0x0f
-
-
-#define DSP_UDATA_INDICATION_DTMF_DIGITS_SENT   16
-/*
-returns:
-  - none -
-  One indication will be sent for every request.
-*/
-
-
-#define DSP_UDATA_REQUEST_ENABLE_DTMF_RECEIVER  17
-/*
-parameters:
-  <word> tone duration (ms)
-  <word> gap duration (ms)
-*/
-typedef struct enable_dtmf_s {
-	__u16 tone;
-	__u16 gap;
-} enable_dtmf_s;
-
-#define DSP_UDATA_REQUEST_DISABLE_DTMF_RECEIVER 18
-/*
-parameters:
-  - none -
-*/
-
-#define DSP_UDATA_INDICATION_DTMF_DIGITS_RECEIVED 17
-/*
-returns:
-  <byte> digit 0 tone code
-  ...
-  <byte> digit n tone code
-*/
-
-#define DSP_DTMF_DIGITS_RECEIVED_HEADER_LENGTH  1
-
-
-#define DSP_UDATA_INDICATION_MODEM_CALLING_TONE 18
-/*
-returns:
-  - none -
-*/
-
-#define DSP_UDATA_INDICATION_FAX_CALLING_TONE   19
-/*
-returns:
-  - none -
-*/
-
-#define DSP_UDATA_INDICATION_ANSWER_TONE        20
-/*
-returns:
-  - none -
-*/
-
-/* ============= FAX ================ */
-
-#define EICON_FAXID_LEN 20
-
-typedef struct eicon_t30_s {
-  __u8          code;
-  __u8          rate;
-  __u8          resolution;
-  __u8          format;
-  __u8          pages_low;
-  __u8          pages_high;
-  __u8          atf;
-  __u8          control_bits_low;
-  __u8          control_bits_high;
-  __u8          feature_bits_low;
-  __u8          feature_bits_high;
-  __u8          universal_5;
-  __u8          universal_6;
-  __u8          universal_7;
-  __u8          station_id_len;
-  __u8          head_line_len;
-  __u8          station_id[EICON_FAXID_LEN];
-/* __u8          head_line[]; */
-} eicon_t30_s;
-
-        /* EDATA transmit messages */
-#define EDATA_T30_DIS       0x01
-#define EDATA_T30_FTT       0x02
-#define EDATA_T30_MCF       0x03
-
-        /* EDATA receive messages */
-#define EDATA_T30_DCS       0x81
-#define EDATA_T30_TRAIN_OK  0x82
-#define EDATA_T30_EOP       0x83
-#define EDATA_T30_MPS       0x84
-#define EDATA_T30_EOM       0x85
-#define EDATA_T30_DTC       0x86
-
-#define T30_FORMAT_SFF            0
-#define T30_FORMAT_ASCII          1
-#define T30_FORMAT_COUNT          2
-
-#define T30_CONTROL_BIT_DISABLE_FINE      0x0001
-#define T30_CONTROL_BIT_ENABLE_ECM        0x0002
-#define T30_CONTROL_BIT_ECM_64_BYTES      0x0004
-#define T30_CONTROL_BIT_ENABLE_2D_CODING  0x0008
-#define T30_CONTROL_BIT_ENABLE_T6_CODING  0x0010
-#define T30_CONTROL_BIT_ENABLE_UNCOMPR    0x0020
-#define T30_CONTROL_BIT_ACCEPT_POLLING    0x0040
-#define T30_CONTROL_BIT_REQUEST_POLLING   0x0080
-#define T30_CONTROL_BIT_MORE_DOCUMENTS    0x0100
-
-#define T30_CONTROL_BIT_ALL_FEATURES\
-  (T30_CONTROL_BIT_ENABLE_ECM | T30_CONTROL_BIT_ENABLE_2D_CODING |\
-   T30_CONTROL_BIT_ENABLE_T6_CODING | T30_CONTROL_BIT_ENABLE_UNCOMPR)
-
-#define T30_FEATURE_BIT_FINE              0x0001
-#define T30_FEATURE_BIT_ECM               0x0002
-#define T30_FEATURE_BIT_ECM_64_BYTES      0x0004
-#define T30_FEATURE_BIT_2D_CODING         0x0008
-#define T30_FEATURE_BIT_T6_CODING         0x0010
-#define T30_FEATURE_BIT_UNCOMPR_ENABLED   0x0020
-#define T30_FEATURE_BIT_POLLING           0x0040
-
-#define FAX_OBJECT_DOCU		1
-#define FAX_OBJECT_PAGE		2
-#define FAX_OBJECT_LINE		3
-
-#define T4_EOL			0x800
-#define T4_EOL_BITSIZE		12
-#define T4_EOL_DWORD		(T4_EOL << (32 - T4_EOL_BITSIZE))
-#define T4_EOL_MASK_DWORD	((__u32) -1 << (32 - T4_EOL_BITSIZE))
-
-#define SFF_LEN_FLD_SIZE	3
-
-#define _DLE_	0x10
-#define _ETX_	0x03
-
-typedef struct eicon_sff_dochead {
-	__u32	id		__attribute__ ((packed));
-	__u8	version		__attribute__ ((packed));
-	__u8	reserved1	__attribute__ ((packed));
-	__u16	userinfo	__attribute__ ((packed));
-	__u16	pagecount	__attribute__ ((packed));
-	__u16	off1pagehead	__attribute__ ((packed));
-	__u32	offnpagehead	__attribute__ ((packed));
-	__u32	offdocend	__attribute__ ((packed));
-} eicon_sff_dochead;
-
-typedef struct eicon_sff_pagehead {
-	__u8	pageheadid	__attribute__ ((packed));
-	__u8	pageheadlen	__attribute__ ((packed));
-	__u8	resvert		__attribute__ ((packed));
-	__u8	reshoriz	__attribute__ ((packed));
-	__u8	coding		__attribute__ ((packed));
-	__u8	reserved2	__attribute__ ((packed));
-	__u16	linelength	__attribute__ ((packed));
-	__u16	pagelength	__attribute__ ((packed));
-	__u32	offprevpage	__attribute__ ((packed));
-	__u32	offnextpage	__attribute__ ((packed));
-} eicon_sff_pagehead;
-
-#endif	/* DSP_H */
-
diff -puN -L drivers/isdn/eicon/eicon.h drivers/isdn/eicon/eicon.h~linus /dev/null
--- 25/drivers/isdn/eicon/eicon.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,386 +0,0 @@
-/* $Id: eicon.h,v 1.1.4.1.2.3 2002/10/01 11:29:13 armin Exp $
- *
- * ISDN low-level module for Eicon active ISDN-Cards.
- *
- * Copyright 1998       by Fritz Elfert (fritz@isdn4linux.de)
- * Copyright 1998-2000  by Armin Schindler (mac@melware.de) 
- * Copyright 1999,2000  Cytronics & Melware (info@melware.de)
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#ifndef eicon_h
-#define eicon_h
-
-#include <linux/interrupt.h>
-
-#define EICON_IOCTL_SETMMIO   0
-#define EICON_IOCTL_GETMMIO   1
-#define EICON_IOCTL_SETIRQ    2
-#define EICON_IOCTL_GETIRQ    3
-#define EICON_IOCTL_LOADBOOT  4
-#define EICON_IOCTL_ADDCARD   5
-#define EICON_IOCTL_GETTYPE   6
-#define EICON_IOCTL_LOADPCI   7 
-#define EICON_IOCTL_LOADISA   8 
-#define EICON_IOCTL_GETVER    9 
-#define EICON_IOCTL_GETXLOG  10 
-
-#define EICON_IOCTL_MANIF    90 
-
-#define EICON_IOCTL_FREEIT   97
-#define EICON_IOCTL_TEST     98
-#define EICON_IOCTL_DEBUGVAR 99
-
-#define EICON_IOCTL_DIA_OFFSET	100
-
-/* Bus types */
-#define EICON_BUS_ISA          1
-#define EICON_BUS_MCA          2
-#define EICON_BUS_PCI          3
-
-/* Constants for describing Card-Type */
-#define EICON_CTYPE_S            0
-#define EICON_CTYPE_SX           1
-#define EICON_CTYPE_SCOM         2
-#define EICON_CTYPE_QUADRO       3
-#define EICON_CTYPE_S2M          4
-#define EICON_CTYPE_MAESTRA      5
-#define EICON_CTYPE_MAESTRAQ     6
-#define EICON_CTYPE_MAESTRAQ_U   7
-#define EICON_CTYPE_MAESTRAP     8
-#define EICON_CTYPE_ISABRI       0x10
-#define EICON_CTYPE_ISAPRI       0x20
-#define EICON_CTYPE_MASK         0x0f
-#define EICON_CTYPE_QUADRO_NR(n) (n<<4)
-
-#define MAX_HEADER_LEN 10
-
-#define MAX_STATUS_BUFFER	150
-
-/* Struct for adding new cards */
-typedef struct eicon_cdef {
-        int membase;
-        int irq;
-        char id[10];
-} eicon_cdef;
-
-#define EICON_ISA_BOOT_MEMCHK 1
-#define EICON_ISA_BOOT_NORMAL 2
-
-/* Struct for downloading protocol via ioctl for ISA cards */
-/* same struct for downloading protocol via ioctl for MCA cards */
-typedef struct {
-	/* start-up parameters */
-	unsigned char tei;
-	unsigned char nt2;
-	unsigned char skip1;
-	unsigned char WatchDog;
-	unsigned char Permanent;
-	unsigned char XInterface;
-	unsigned char StableL2;
-	unsigned char NoOrderCheck;
-	unsigned char HandsetType;
-	unsigned char skip2;
-	unsigned char LowChannel;
-	unsigned char ProtVersion;
-	unsigned char Crc4;
-	unsigned char Loopback;
-	unsigned char oad[32];
-	unsigned char osa[32];
-	unsigned char spid[32];
-	unsigned char boot_opt;
-	unsigned long bootstrap_len;
-	unsigned long firmware_len;
-	unsigned char code[1]; /* Rest (bootstrap- and firmware code) will be allocated */
-} eicon_isa_codebuf;
-
-/* Data for downloading protocol via ioctl */
-typedef union {
-	eicon_isa_codebuf isa;
-	eicon_isa_codebuf mca;
-} eicon_codebuf;
-
-/* Data for Management interface */
-typedef struct {
-	int count;
-	int pos;
-	int length[50];
-	unsigned char data[700]; 
-} eicon_manifbuf;
-
-#define TRACE_OK                 (1)
-
-#ifdef __KERNEL__
-
-/* Kernel includes */
-#include <linux/config.h>
-#include <linux/sched.h>
-#include <linux/string.h>
-#include <linux/workqueue.h>
-#include <linux/interrupt.h>
-#include <linux/skbuff.h>
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/major.h>
-#include <asm/io.h>
-#include <linux/kernel.h>
-#include <linux/signal.h>
-#include <linux/slab.h>
-#include <linux/mm.h>
-#include <linux/mman.h>
-#include <linux/ioport.h>
-#include <linux/timer.h>
-#include <linux/wait.h>
-#include <linux/delay.h>
-#include <linux/ctype.h>
-#include <linux/pci.h>
-
-#include <linux/isdn.h>
-#include <linux/isdnif.h>
-
-
-typedef struct {
-  __u16 length __attribute__ ((packed)); /* length of data/parameter field */
-  __u8  P[1];                          /* data/parameter field */
-} eicon_PBUFFER;
-
-#include "eicon_isa.h"
-
-#include "idi.h"
-
-typedef struct {
-  __u16 NextReq  __attribute__ ((packed));  /* pointer to next Req Buffer */
-  __u16 NextRc   __attribute__ ((packed));  /* pointer to next Rc Buffer  */
-  __u16 NextInd  __attribute__ ((packed));  /* pointer to next Ind Buffer */
-  __u8 ReqInput  __attribute__ ((packed));  /* number of Req Buffers sent */
-  __u8 ReqOutput  __attribute__ ((packed)); /* number of Req Buffers returned */
-  __u8 ReqReserved  __attribute__ ((packed));/*number of Req Buffers reserved */
-  __u8 Int  __attribute__ ((packed));       /* ISDN-P interrupt           */
-  __u8 XLock  __attribute__ ((packed));     /* Lock field for arbitration */
-  __u8 RcOutput  __attribute__ ((packed));  /* number of Rc buffers received */
-  __u8 IndOutput  __attribute__ ((packed)); /* number of Ind buffers received */
-  __u8 IMask  __attribute__ ((packed));     /* Interrupt Mask Flag        */
-  __u8 Reserved1[2]  __attribute__ ((packed)); /* reserved field, do not use */
-  __u8 ReadyInt  __attribute__ ((packed));  /* request field for ready int */
-  __u8 Reserved2[12]  __attribute__ ((packed)); /* reserved field, do not use */
-  __u8 InterfaceType  __attribute__ ((packed)); /* interface type 1=16K    */
-  __u16 Signature  __attribute__ ((packed));    /* ISDN-P initialized ind  */
-  __u8 B[1];                            /* buffer space for Req,Ind and Rc */
-} eicon_pr_ram;
-
-/* Macro for delay via schedule() */
-#define SLEEP(j) {                     \
-  set_current_state(TASK_UNINTERRUPTIBLE); \
-  schedule_timeout(j);                 \
-}
-
-typedef struct {
-  __u8                  Req;            /* pending request          */
-  __u8                  Rc;             /* return code received     */
-  __u8                  Ind;            /* indication received      */
-  __u8                  ReqCh;          /* channel of current Req   */
-  __u8                  RcCh;           /* channel of current Rc    */
-  __u8                  IndCh;          /* channel of current Ind   */
-  __u8                  D3Id;           /* ID used by this entity   */
-  __u8                  B2Id;           /* ID used by this entity   */
-  __u8                  GlobalId;       /* reserved field           */
-  __u8                  XNum;           /* number of X-buffers      */
-  __u8                  RNum;           /* number of R-buffers      */
-  struct sk_buff_head   X;              /* X-buffer queue           */
-  struct sk_buff_head   R;              /* R-buffer queue           */
-  __u8                  RNR;            /* receive not ready flag   */
-  __u8                  complete;       /* receive complete status  */
-  __u8                  busy;           /* busy flag                */
-  __u16                 ref;            /* saved reference          */
-} entity;
-
-#define FAX_MAX_SCANLINE 256
-
-typedef struct {
-	__u8		PrevObject;
-	__u8		NextObject;
-	__u8		abLine[FAX_MAX_SCANLINE];
-	__u8		abFrame[FAX_MAX_SCANLINE];
-	unsigned int	LineLen;
-	unsigned int	LineDataLen;
-	__u32		LineData;
-	unsigned int	NullBytesPos;
-	__u8		NullByteExist;
-	int		PageCount;
-	__u8		Dle;
-	__u8		Eop;
-} eicon_ch_fax_buf;
-
-typedef struct {
-	int	       No;		 /* Channel Number	        */
-	unsigned short fsm_state;        /* Current D-Channel state     */
-	unsigned short statectrl;	 /* State controling bits	*/
-	unsigned short eazmask;          /* EAZ-Mask for this Channel   */
-	int		queued;          /* User-Data Bytes in TX queue */
-	int		pqueued;         /* User-Data Packets in TX queue */
-	int		waitq;           /* User-Data Bytes in wait queue */
-	int		waitpq;          /* User-Data Bytes in packet queue */
-	struct sk_buff *tskb1;           /* temp skb 1			*/
-	struct sk_buff *tskb2;           /* temp skb 2			*/
-	unsigned char  l2prot;           /* Layer 2 protocol            */
-	unsigned char  l3prot;           /* Layer 3 protocol            */
-#ifdef CONFIG_ISDN_TTY_FAX
-	T30_s		*fax;		 /* pointer to fax data in LL	*/
-	eicon_ch_fax_buf fax2;		 /* fax related struct		*/
-#endif
-	entity		e;		 /* Native Entity		*/
-	ENTITY		de;		 /* Divas D Entity 		*/
-	ENTITY		be;		 /* Divas B Entity 		*/
-	char		cpn[32];	 /* remember cpn		*/
-	char		oad[32];	 /* remember oad		*/
-	char		dsa[32];	 /* remember dsa		*/
-	char		osa[32];	 /* remember osa		*/
-	unsigned char   cause[2];	 /* Last Cause			*/
-	unsigned char	si1;
-	unsigned char	si2;
-	unsigned char	plan;
-	unsigned char	screen;
-} eicon_chan;
-
-typedef struct {
-	eicon_chan *ptr;
-} eicon_chan_ptr;
-
-#include "eicon_pci.h"
-
-#define EICON_FLAGS_RUNNING  1 /* Cards driver activated */
-#define EICON_FLAGS_PVALID   2 /* Cards port is valid    */
-#define EICON_FLAGS_IVALID   4 /* Cards irq is valid     */
-#define EICON_FLAGS_MVALID   8 /* Cards membase is valid */
-#define EICON_FLAGS_LOADED   8 /* Firmware loaded        */
-
-/* D-Channel states */
-#define EICON_STATE_NULL     0
-#define EICON_STATE_ICALL    1
-#define EICON_STATE_OCALL    2
-#define EICON_STATE_IWAIT    3
-#define EICON_STATE_OWAIT    4
-#define EICON_STATE_IBWAIT   5
-#define EICON_STATE_OBWAIT   6
-#define EICON_STATE_BWAIT    7
-#define EICON_STATE_BHWAIT   8
-#define EICON_STATE_BHWAIT2  9
-#define EICON_STATE_DHWAIT  10
-#define EICON_STATE_DHWAIT2 11
-#define EICON_STATE_BSETUP  12
-#define EICON_STATE_ACTIVE  13
-#define EICON_STATE_ICALLW  14
-#define EICON_STATE_LISTEN  15
-#define EICON_STATE_WMCONN  16
-
-#define EICON_MAX_QUEUE  2138
-
-typedef union {
-	eicon_isa_card isa;
-	eicon_pci_card pci;
-	eicon_isa_card mca;
-} eicon_hwif;
-
-typedef struct {
-	__u8 ret;
-	__u8 id;
-	__u8 ch;
-} eicon_ack;
-
-typedef struct {
-	__u8 code;
-	__u8 id;
-	__u8 ch;
-} eicon_req;
-
-typedef struct {
-	__u8 ret;
-	__u8 id;
-	__u8 ch;
-	__u8 more;
-} eicon_indhdr;
-
-/*
- * Per card driver data
- */
-typedef struct eicon_card {
-	eicon_hwif hwif;                 /* Hardware dependent interface     */
-	DESCRIPTOR *d;			 /* IDI Descriptor		     */
-        u_char ptype;                    /* Protocol type (1TR6 or Euro)     */
-        u_char bus;                      /* Bustype (ISA, MCA, PCI)          */
-        u_char type;                     /* Cardtype (EICON_CTYPE_...)       */
-	struct eicon_card *qnext;  	 /* Pointer to next quadro adapter   */
-        int Feature;                     /* Protocol Feature Value           */
-        struct eicon_card *next;	 /* Pointer to next device struct    */
-        int myid;                        /* Driver-Nr. assigned by linklevel */
-        unsigned long flags;             /* Statusflags                      */
-	struct sk_buff_head rcvq;        /* Receive-Message queue            */
-	struct sk_buff_head sndq;        /* Send-Message queue               */
-	struct sk_buff_head rackq;       /* Req-Ack-Message queue            */
-	struct sk_buff_head sackq;       /* Data-Ack-Message queue           */
-	struct sk_buff_head statq;       /* Status-Message queue             */
-	int statq_entries;
-	struct tasklet_struct snd_tq;    /* Task struct for xmit bh          */
-	struct tasklet_struct rcv_tq;    /* Task struct for rcv bh           */
-	struct tasklet_struct ack_tq;    /* Task struct for ack bh           */
-	eicon_chan*	IdTable[256];	 /* Table to find entity   */
-	__u16  ref_in;
-	__u16  ref_out;
-	int    nchannels;                /* Number of B-Channels             */
-	int    ReadyInt;		 /* Ready Interrupt		     */
-	eicon_chan *bch;                 /* B-Channel status/control         */
-	DBUFFER *dbuf;			 /* Dbuffer for Diva Server	     */
-	BUFFERS *sbuf;			 /* Buffer for Diva Server	     */
-	char *sbufp;			 /* Data Buffer for Diva Server	     */
-        isdn_if interface;               /* Interface to upper layer         */
-        char regname[35];                /* Drivers card name 		     */
-#ifdef CONFIG_MCA
-        int	mca_slot;	 	 /* # of cards MCA slot              */
-	int	mca_io;			 /* MCA cards IO port		     */
-#endif /* CONFIG_MCA */
-} eicon_card;
-
-#include "eicon_idi.h"
-
-extern eicon_card *cards;
-extern char *eicon_ctype_name[];
-
-
-extern __inline__ void eicon_schedule_tx(eicon_card *card)
-{
-	tasklet_schedule(&card->snd_tq);
-}
-
-extern __inline__ void eicon_schedule_rx(eicon_card *card)
-{
-	tasklet_schedule(&card->rcv_tq);
-}
-
-extern __inline__ void eicon_schedule_ack(eicon_card *card)
-{
-	tasklet_schedule(&card->ack_tq);
-}
-
-extern int eicon_addcard(int, int, int, char *, int);
-extern void eicon_io_transmit(eicon_card *card);
-extern irqreturn_t eicon_irq(int irq, void *dev_id, struct pt_regs *regs);
-extern void eicon_io_rcv_dispatch(eicon_card *ccard);
-extern void eicon_io_ack_dispatch(eicon_card *ccard);
-#ifdef CONFIG_MCA
-extern int eicon_mca_find_card(int, int, int, char *);
-extern int eicon_mca_probe(int, int, int, int, char *);
-extern int eicon_info(char *, int , void *);
-#endif /* CONFIG_MCA */
-
-extern ulong DebugVar;
-extern void eicon_log(eicon_card * card, int level, const char *fmt, ...);
-extern void eicon_putstatus(eicon_card * card, char * buf);
-
-extern spinlock_t eicon_lock;
-
-#endif  /* __KERNEL__ */
-
-#endif	/* eicon_h */
diff -puN -L drivers/isdn/eicon/eicon_idi.c drivers/isdn/eicon/eicon_idi.c~linus /dev/null
--- 25/drivers/isdn/eicon/eicon_idi.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,3197 +0,0 @@
-/* $Id: eicon_idi.c,v 1.1.4.1.2.4 2002/10/01 11:29:13 armin Exp $
- *
- * ISDN lowlevel-module for Eicon active cards.
- * IDI interface 
- *
- * Copyright 1998-2000  by Armin Schindler (mac@melware.de)
- * Copyright 1999,2000  Cytronics & Melware (info@melware.de)
- *
- * Thanks to	Deutsche Mailbox Saar-Lor-Lux GmbH
- *		for sponsoring and testing fax
- *		capabilities with Diva Server cards.
- *		(dor@deutschemailbox.de)
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#include <linux/config.h>
-#include "eicon.h"
-#include "eicon_idi.h"
-#include "eicon_dsp.h"
-#include "uxio.h"
-
-#undef EICON_FULL_SERVICE_OKTETT
-
-char *eicon_idi_revision = "$Revision: 1.1.4.1.2.4 $";
-
-eicon_manifbuf *manbuf;
-
-int eicon_idi_manage_assign(eicon_card *card);
-int eicon_idi_manage_remove(eicon_card *card);
-int idi_fill_in_T30(eicon_chan *chan, unsigned char *buffer);
-
-int
-idi_assign_req(eicon_REQ *reqbuf, int signet, eicon_chan *chan)
-{
-	int l = 0;
-	int tmp;
-
-	tmp = 0;
-  if (!signet) {
-	/* Signal Layer */
-	reqbuf->XBuffer.P[l++] = CAI;
-	reqbuf->XBuffer.P[l++] = 1;
-	reqbuf->XBuffer.P[l++] = 0;
-	reqbuf->XBuffer.P[l++] = KEY;
-	reqbuf->XBuffer.P[l++] = 3;
-	reqbuf->XBuffer.P[l++] = 'I';
-	reqbuf->XBuffer.P[l++] = '4';
-	reqbuf->XBuffer.P[l++] = 'L';
-	reqbuf->XBuffer.P[l++] = SHIFT|6;
-	reqbuf->XBuffer.P[l++] = SIN;
-	reqbuf->XBuffer.P[l++] = 2;
-	reqbuf->XBuffer.P[l++] = 0;
-	reqbuf->XBuffer.P[l++] = 0;
-	reqbuf->XBuffer.P[l++] = 0; /* end */
-	reqbuf->Req = ASSIGN;
-	reqbuf->ReqCh = 0;
-	reqbuf->ReqId = DSIG_ID;
-	reqbuf->XBuffer.length = l;
-	reqbuf->Reference = 0; /* Sig Entity */
-  }
-  else {
-	/* Network Layer */
-	reqbuf->XBuffer.P[l++] = CAI;
-	reqbuf->XBuffer.P[l++] = 1;
-	reqbuf->XBuffer.P[l++] = chan->e.D3Id;
-	reqbuf->XBuffer.P[l++] = LLC;
-	reqbuf->XBuffer.P[l++] = 2;
-	switch(chan->l2prot) {
-		case ISDN_PROTO_L2_V11096:
-		case ISDN_PROTO_L2_V11019:
-		case ISDN_PROTO_L2_V11038:
-		case ISDN_PROTO_L2_TRANS:
-			reqbuf->XBuffer.P[l++] = 2; /* transparent */
-			break;
-		case ISDN_PROTO_L2_X75I:
-		case ISDN_PROTO_L2_X75UI:
-		case ISDN_PROTO_L2_X75BUI:
-			reqbuf->XBuffer.P[l++] = 5; /* X.75 */ 
-			break;
-		case ISDN_PROTO_L2_MODEM:
-  			if (chan->fsm_state == EICON_STATE_IWAIT)
-				reqbuf->XBuffer.P[l++] = 9; /* V.42 incoming */
-			else
-				reqbuf->XBuffer.P[l++] = 10; /* V.42 */
-			break;
-		case ISDN_PROTO_L2_HDLC:
-		case ISDN_PROTO_L2_FAX:
-  			if (chan->fsm_state == EICON_STATE_IWAIT)
-				reqbuf->XBuffer.P[l++] = 3; /* autoconnect on incoming */
-			else
-				reqbuf->XBuffer.P[l++] = 2; /* transparent */
-			break;
-		default:
-			reqbuf->XBuffer.P[l++] = 1;
-	}
-	switch(chan->l3prot) {
-		case ISDN_PROTO_L3_FCLASS2:
-#ifdef CONFIG_ISDN_TTY_FAX
-			reqbuf->XBuffer.P[l++] = 6;
-			reqbuf->XBuffer.P[l++] = NLC;
-			tmp = idi_fill_in_T30(chan, &reqbuf->XBuffer.P[l+1]);
-			reqbuf->XBuffer.P[l++] = tmp; 
-			l += tmp;
-			break;
-#endif
-		case ISDN_PROTO_L3_TRANS:
-		default:
-			reqbuf->XBuffer.P[l++] = 4;
-	}
-	reqbuf->XBuffer.P[l++] = 0; /* end */
-	reqbuf->Req = ASSIGN;
-	reqbuf->ReqCh = 0;
-	reqbuf->ReqId = NL_ID;
-	reqbuf->XBuffer.length = l;
-	reqbuf->Reference = 1; /* Net Entity */
-  }
-   return(0);
-}
-
-int
-idi_put_req(eicon_REQ *reqbuf, int rq, int signet, int Ch)
-{
-	reqbuf->Req = rq;
-	reqbuf->ReqCh = Ch;
-	reqbuf->ReqId = 1;
-	reqbuf->XBuffer.length = 1;
-	reqbuf->XBuffer.P[0] = 0;
-	reqbuf->Reference = signet;
-   return(0);
-}
-
-int
-idi_put_suspend_req(eicon_REQ *reqbuf, eicon_chan *chan)
-{
-	reqbuf->Req = SUSPEND;
-	reqbuf->ReqCh = 0;
-	reqbuf->ReqId = 1;
-	reqbuf->XBuffer.P[0] = CAI;
-	reqbuf->XBuffer.P[1] = 1;
-	reqbuf->XBuffer.P[2] = chan->No;
-	reqbuf->XBuffer.P[3] = 0;
-	reqbuf->XBuffer.length = 4;
-	reqbuf->Reference = 0; /* Sig Entity */
-   return(0);
-}
-
-int
-idi_call_res_req(eicon_REQ *reqbuf, eicon_chan *chan)
-{
-	int l = 9;
-	reqbuf->Req = CALL_RES;
-	reqbuf->ReqCh = 0;
-	reqbuf->ReqId = 1;
-	reqbuf->XBuffer.P[0] = CAI;
-	reqbuf->XBuffer.P[1] = 6;
-	reqbuf->XBuffer.P[2] = 9;
-	reqbuf->XBuffer.P[3] = 0;
-	reqbuf->XBuffer.P[4] = 0;
-	reqbuf->XBuffer.P[5] = 0;
-	reqbuf->XBuffer.P[6] = 32;
-	reqbuf->XBuffer.P[7] = 0;
-	switch(chan->l2prot) {
-		case ISDN_PROTO_L2_X75I:
-		case ISDN_PROTO_L2_X75UI:
-		case ISDN_PROTO_L2_X75BUI:
-		case ISDN_PROTO_L2_HDLC:
-			reqbuf->XBuffer.P[1] = 1;
-			reqbuf->XBuffer.P[2] = 0x05;
-			l = 4;
-			break;
-		case ISDN_PROTO_L2_V11096:
-			reqbuf->XBuffer.P[2] = 0x0d;
-			reqbuf->XBuffer.P[3] = 5;
-			reqbuf->XBuffer.P[4] = 0;
-			break;
-		case ISDN_PROTO_L2_V11019:
-			reqbuf->XBuffer.P[2] = 0x0d;
-			reqbuf->XBuffer.P[3] = 6;
-			reqbuf->XBuffer.P[4] = 0;
-			break;
-		case ISDN_PROTO_L2_V11038:
-			reqbuf->XBuffer.P[2] = 0x0d;
-			reqbuf->XBuffer.P[3] = 7;
-			reqbuf->XBuffer.P[4] = 0;
-			break;
-		case ISDN_PROTO_L2_MODEM:
-			reqbuf->XBuffer.P[2] = 0x11;
-			reqbuf->XBuffer.P[3] = 7;
-			reqbuf->XBuffer.P[4] = 0;
-			reqbuf->XBuffer.P[5] = 0;
-			reqbuf->XBuffer.P[6] = 128;
-			reqbuf->XBuffer.P[7] = 0;
-			break;
-		case ISDN_PROTO_L2_FAX:
-			reqbuf->XBuffer.P[2] = 0x10;
-			reqbuf->XBuffer.P[3] = 0;
-			reqbuf->XBuffer.P[4] = 0;
-			reqbuf->XBuffer.P[5] = 0;
-			reqbuf->XBuffer.P[6] = 128;
-			reqbuf->XBuffer.P[7] = 0;
-			break;
-		case ISDN_PROTO_L2_TRANS:
-			switch(chan->l3prot) {
-				case ISDN_PROTO_L3_TRANSDSP:
-					reqbuf->XBuffer.P[2] = 22; /* DTMF, audio events on */
-			}
-			break;
-	}
-	reqbuf->XBuffer.P[8] = 0;
-	reqbuf->XBuffer.length = l;
-	reqbuf->Reference = 0; /* Sig Entity */
-	eicon_log(NULL, 8, "idi_req: Ch%d: Call_Res\n", chan->No);
-   return(0);
-}
-
-int
-idi_do_req(eicon_card *card, eicon_chan *chan, int cmd, int layer)
-{
-        struct sk_buff *skb;
-        struct sk_buff *skb2;
-	eicon_REQ *reqbuf;
-	eicon_chan_ptr *chan2;
-
-        skb = alloc_skb(270 + sizeof(eicon_REQ), GFP_ATOMIC);
-        skb2 = alloc_skb(sizeof(eicon_chan_ptr), GFP_ATOMIC);
-
-        if ((!skb) || (!skb2)) {
-               	eicon_log(card, 1, "idi_err: Ch%d: alloc_skb failed in do_req()\n", chan->No);
-		if (skb) 
-			dev_kfree_skb(skb);
-		if (skb2) 
-			dev_kfree_skb(skb2);
-                return -ENOMEM; 
-	}
-
-	chan2 = (eicon_chan_ptr *)skb_put(skb2, sizeof(eicon_chan_ptr));
-	chan2->ptr = chan;
-
-	reqbuf = (eicon_REQ *)skb_put(skb, 270 + sizeof(eicon_REQ));
-	eicon_log(card, 8, "idi_req: Ch%d: req %x (%s)\n", chan->No, cmd, (layer)?"Net":"Sig");
-	if (layer) cmd |= 0x700;
-	switch(cmd) {
-		case ASSIGN:
-		case ASSIGN|0x700:
-			idi_assign_req(reqbuf, layer, chan);
-			break;
-		case REMOVE:
-		case REMOVE|0x700:
-			idi_put_req(reqbuf, REMOVE, layer, 0);
-			break;
-		case INDICATE_REQ:
-			idi_put_req(reqbuf, INDICATE_REQ, 0, 0);
-			break;
-		case HANGUP:
-			idi_put_req(reqbuf, HANGUP, 0, 0);
-			break;
-		case SUSPEND:
-			idi_put_suspend_req(reqbuf, chan);
-			break;
-		case RESUME:
-			idi_put_req(reqbuf, RESUME, 0 ,0);
-			break;
-		case REJECT:
-			idi_put_req(reqbuf, REJECT, 0 ,0);
-			break;
-		case CALL_ALERT:
-			idi_put_req(reqbuf, CALL_ALERT, 0, 0);
-			break;
-		case CALL_RES:
-			idi_call_res_req(reqbuf, chan);
-			break;
-		case CALL_HOLD:
-			idi_put_req(reqbuf, CALL_HOLD, 0, 0);
-			break;
-		case N_CONNECT|0x700:
-			idi_put_req(reqbuf, N_CONNECT, 1, 0);
-			break;
-		case N_CONNECT_ACK|0x700:
-			idi_put_req(reqbuf, N_CONNECT_ACK, 1, 0);
-			break;
-		case N_DISC|0x700:
-			idi_put_req(reqbuf, N_DISC, 1, chan->e.IndCh);
-			break;
-		case N_DISC_ACK|0x700:
-			idi_put_req(reqbuf, N_DISC_ACK, 1, chan->e.IndCh);
-			break;
-		default:
-			eicon_log(card, 1, "idi_req: Ch%d: Unknown request\n", chan->No);
-			dev_kfree_skb(skb);
-			dev_kfree_skb(skb2);
-			return(-1);
-	}
-
-	skb_queue_tail(&chan->e.X, skb);
-	skb_queue_tail(&card->sndq, skb2); 
-	eicon_schedule_tx(card);
-	return(0);
-}
-
-int
-eicon_idi_listen_req(eicon_card *card, eicon_chan *chan)
-{
-	if ((!card) || (!chan))
-		return 1;
-
-	eicon_log(card, 16, "idi_req: Ch%d: Listen_Req eazmask=0x%x\n",chan->No, chan->eazmask);
-	if (!chan->e.D3Id) {
-		idi_do_req(card, chan, ASSIGN, 0); 
-	}
-	if (chan->fsm_state == EICON_STATE_NULL) {
-		if (!(chan->statectrl & HAVE_CONN_REQ)) {
-			idi_do_req(card, chan, INDICATE_REQ, 0);
-			chan->fsm_state = EICON_STATE_LISTEN;
-		}
-	}
-  return(0);
-}
-
-unsigned char
-idi_si2bc(int si1, int si2, char *bc, char *hlc)
-{
-  hlc[0] = 0;
-  switch(si1) {
-	case 1:
-		bc[0] = 0x90;		/* 3,1 kHz audio */
-		bc[1] = 0x90;		/* 64 kbit/s */
-		bc[2] = 0xa3;		/* G.711 A-law */
-#ifdef EICON_FULL_SERVICE_OKTETT
-		if (si2 == 1) {
-			bc[0] = 0x80;	/* Speech */
-			hlc[0] = 0x02;	/* hlc len */
-			hlc[1] = 0x91;	/* first hic */
-			hlc[2] = 0x81;	/* Telephony */
-		}
-#endif
-		return(3);
-	case 2:
-		bc[0] = 0x90;		/* 3,1 kHz audio */
-		bc[1] = 0x90;		/* 64 kbit/s */
-		bc[2] = 0xa3;		/* G.711 A-law */
-#ifdef EICON_FULL_SERVICE_OKTETT
-		if (si2 == 2) {
-			hlc[0] = 0x02;	/* hlc len */
-			hlc[1] = 0x91;	/* first hic */
-			hlc[2] = 0x84;	/* Fax Gr.2/3 */
-		}
-#endif
-		return(3);
-	case 5:
-	case 7:
-	default:
-		bc[0] = 0x88;
-		bc[1] = 0x90;
-		return(2);
-  }
- return (0);
-}
-
-int
-idi_hangup(eicon_card *card, eicon_chan *chan)
-{
-	if ((!card) || (!chan))
-		return 1;
-
-	if ((chan->fsm_state == EICON_STATE_ACTIVE) ||
-	    (chan->fsm_state == EICON_STATE_WMCONN)) {
-  		if (chan->e.B2Id) idi_do_req(card, chan, N_DISC, 1);
-	}
-	if (chan->e.B2Id) idi_do_req(card, chan, REMOVE, 1);
-	if (chan->fsm_state != EICON_STATE_NULL) {
-		chan->statectrl |= WAITING_FOR_HANGUP;
-		idi_do_req(card, chan, HANGUP, 0);
-		chan->fsm_state = EICON_STATE_NULL;
-	}
-	eicon_log(card, 8, "idi_req: Ch%d: Hangup\n", chan->No);
-#ifdef CONFIG_ISDN_TTY_FAX
-	chan->fax = 0;
-#endif
-  return(0);
-}
-
-int
-capipmsg(eicon_card *card, eicon_chan *chan, capi_msg *cm)
-{
-	if ((cm->para[0] != 3) || (cm->para[1] != 0))
-		return -1;
-	if (cm->para[2] < 3)
-		return -1;
-	if (cm->para[4] != 0)
-		return -1;
-	switch(cm->para[3]) {
-		case 4: /* Suspend */
-			eicon_log(card, 8, "idi_req: Ch%d: Call Suspend\n", chan->No);
-			if (cm->para[5]) {
-				idi_do_req(card, chan, SUSPEND, 0);
-			} else {
-				idi_do_req(card, chan, CALL_HOLD, 0);
-			}
-			break;
-		case 5: /* Resume */
-			eicon_log(card, 8, "idi_req: Ch%d: Call Resume\n", chan->No);
-			idi_do_req(card, chan, RESUME, 0);
-			break;
-        }
-	return 0;
-}
-
-int
-idi_connect_res(eicon_card *card, eicon_chan *chan)
-{
-	if ((!card) || (!chan))
-		return 1;
-
-	chan->fsm_state = EICON_STATE_IWAIT;
-	
-	/* check if old NetID has been removed */
-	if (chan->e.B2Id) {
-		eicon_log(card, 1, "eicon: Ch%d: old net_id %x still exist, removing.\n",
-			chan->No, chan->e.B2Id);
-		idi_do_req(card, chan, REMOVE, 1);
-	}
-
-	idi_do_req(card, chan, ASSIGN, 1);
-	idi_do_req(card, chan, CALL_RES, 0);
-	return(0);
-}
-
-int
-idi_connect_req(eicon_card *card, eicon_chan *chan, char *phone,
-                    char *eazmsn, int si1, int si2)
-{
-	int l = 0;
-	int i;
-	unsigned char tmp;
-	unsigned char *sub, *sp;
-	unsigned char bc[5];
-	unsigned char hlc[5];
-        struct sk_buff *skb;
-        struct sk_buff *skb2;
-	eicon_REQ *reqbuf;
-	eicon_chan_ptr *chan2;
-
-	if ((!card) || (!chan))
-		return 1;
-
-        skb = alloc_skb(270 + sizeof(eicon_REQ), GFP_ATOMIC);
-        skb2 = alloc_skb(sizeof(eicon_chan_ptr), GFP_ATOMIC);
-
-        if ((!skb) || (!skb2)) {
-               	eicon_log(card, 1, "idi_err: Ch%d: alloc_skb failed in connect_req()\n", chan->No);
-		if (skb) 
-			dev_kfree_skb(skb);
-		if (skb2) 
-			dev_kfree_skb(skb2);
-                return -ENOMEM; 
-	}
-
-	chan2 = (eicon_chan_ptr *)skb_put(skb2, sizeof(eicon_chan_ptr));
-	chan2->ptr = chan;
-
-	reqbuf = (eicon_REQ *)skb_put(skb, 270 + sizeof(eicon_REQ));
-	reqbuf->Req = CALL_REQ;
-	reqbuf->ReqCh = 0;
-	reqbuf->ReqId = 1;
-
-	sub = NULL;
-	sp = phone;
-	while (*sp) {
-		if (*sp == '.') {
-			sub = sp + 1;
-			*sp = 0;
-		} else
-			sp++;
-	}
-	reqbuf->XBuffer.P[l++] = CPN;
-	reqbuf->XBuffer.P[l++] = strlen(phone) + 1;
-	reqbuf->XBuffer.P[l++] = 0x81;
-	for(i=0; i<strlen(phone);i++) 
-		reqbuf->XBuffer.P[l++] = phone[i] & 0x7f;
-	if (sub) {
-		reqbuf->XBuffer.P[l++] = DSA;
-		reqbuf->XBuffer.P[l++] = strlen(sub) + 2;
-		reqbuf->XBuffer.P[l++] = 0x80; /* NSAP coded */
-		reqbuf->XBuffer.P[l++] = 0x50; /* local IDI format */
-		while (*sub)
-			reqbuf->XBuffer.P[l++] = *sub++ & 0x7f;
-	}
-
-	sub = NULL;
-	sp = eazmsn;
-	while (*sp) {
-		if (*sp == '.') {
-			sub = sp + 1;
-			*sp = 0;
-		} else
-			sp++;
-	}
-	reqbuf->XBuffer.P[l++] = OAD;
-	reqbuf->XBuffer.P[l++] = strlen(eazmsn) + 2;
-	reqbuf->XBuffer.P[l++] = 0x01;
-	reqbuf->XBuffer.P[l++] = 0x80;
-	for(i=0; i<strlen(eazmsn);i++) 
-		reqbuf->XBuffer.P[l++] = eazmsn[i] & 0x7f;
-	if (sub) {
-		reqbuf->XBuffer.P[l++] = OSA;
-		reqbuf->XBuffer.P[l++] = strlen(sub) + 2;
-		reqbuf->XBuffer.P[l++] = 0x80; /* NSAP coded */
-		reqbuf->XBuffer.P[l++] = 0x50; /* local IDI format */
-		while (*sub)
-			reqbuf->XBuffer.P[l++] = *sub++ & 0x7f;
-	}
-
-	if (si2 > 2) {
-		reqbuf->XBuffer.P[l++] = SHIFT|6;
-		reqbuf->XBuffer.P[l++] = SIN;
-		reqbuf->XBuffer.P[l++] = 2;
-		reqbuf->XBuffer.P[l++] = si1;
-		reqbuf->XBuffer.P[l++] = si2;
-	}
-	else if ((tmp = idi_si2bc(si1, si2, bc, hlc)) > 0) {
-		reqbuf->XBuffer.P[l++] = BC;
-		reqbuf->XBuffer.P[l++] = tmp;
-		for(i=0; i<tmp;i++) 
-			reqbuf->XBuffer.P[l++] = bc[i];
-		if ((tmp=hlc[0])) {
-			reqbuf->XBuffer.P[l++] = HLC;
-			reqbuf->XBuffer.P[l++] = tmp;
-			for(i=1; i<=tmp;i++) 
-				reqbuf->XBuffer.P[l++] = hlc[i];
-		}
-	}
-
-        reqbuf->XBuffer.P[l++] = CAI;
-        reqbuf->XBuffer.P[l++] = 6;
-        reqbuf->XBuffer.P[l++] = 0x09;
-	reqbuf->XBuffer.P[l++] = 0;
-	reqbuf->XBuffer.P[l++] = 0;
-	reqbuf->XBuffer.P[l++] = 0;
-	reqbuf->XBuffer.P[l++] = 32;
-	reqbuf->XBuffer.P[l++] = 0;
-        switch(chan->l2prot) {
-		case ISDN_PROTO_L2_X75I:
-		case ISDN_PROTO_L2_X75UI:
-		case ISDN_PROTO_L2_X75BUI:
-                case ISDN_PROTO_L2_HDLC:
-                        reqbuf->XBuffer.P[l-6] = 5;
-                        reqbuf->XBuffer.P[l-7] = 1;
-			l -= 5; 
-                        break;
-                case ISDN_PROTO_L2_V11096:
-                        reqbuf->XBuffer.P[l-7] = 3;
-                        reqbuf->XBuffer.P[l-6] = 0x0d;
-                        reqbuf->XBuffer.P[l-5] = 5;
-                        reqbuf->XBuffer.P[l-4] = 0;
-                        l -= 3;
-                        break;
-                case ISDN_PROTO_L2_V11019:
-                        reqbuf->XBuffer.P[l-7] = 3;
-                        reqbuf->XBuffer.P[l-6] = 0x0d;
-                        reqbuf->XBuffer.P[l-5] = 6;
-                        reqbuf->XBuffer.P[l-4] = 0;
-                        l -= 3;
-                        break;
-                case ISDN_PROTO_L2_V11038:
-                        reqbuf->XBuffer.P[l-7] = 3;
-                        reqbuf->XBuffer.P[l-6] = 0x0d;
-                        reqbuf->XBuffer.P[l-5] = 7;
-                        reqbuf->XBuffer.P[l-4] = 0;
-                        l -= 3;
-                        break;
-                case ISDN_PROTO_L2_MODEM:
-			reqbuf->XBuffer.P[l-6] = 0x11;
-			reqbuf->XBuffer.P[l-5] = 7;
-			reqbuf->XBuffer.P[l-4] = 0;
-			reqbuf->XBuffer.P[l-3] = 0;
-			reqbuf->XBuffer.P[l-2] = 128;
-			reqbuf->XBuffer.P[l-1] = 0;
-                        break;
-                case ISDN_PROTO_L2_FAX:
-			reqbuf->XBuffer.P[l-6] = 0x10;
-			reqbuf->XBuffer.P[l-5] = 0;
-			reqbuf->XBuffer.P[l-4] = 0;
-			reqbuf->XBuffer.P[l-3] = 0;
-			reqbuf->XBuffer.P[l-2] = 128;
-			reqbuf->XBuffer.P[l-1] = 0;
-                        break;
-		case ISDN_PROTO_L2_TRANS:
-			switch(chan->l3prot) {
-				case ISDN_PROTO_L3_TRANSDSP:
-					reqbuf->XBuffer.P[l-6] = 22; /* DTMF, audio events on */
-			}
-			break;
-        }
-	
-	reqbuf->XBuffer.P[l++] = 0; /* end */
-	reqbuf->XBuffer.length = l;
-	reqbuf->Reference = 0; /* Sig Entity */
-
-	if (chan->statectrl & WAITING_FOR_HANGUP) {
-		/*	If the line did not disconnect yet,
-			we have to delay this command		*/
-		eicon_log(card, 32, "idi_req: Ch%d: delaying conn_req\n", chan->No);
-		chan->statectrl |= HAVE_CONN_REQ;
-		chan->tskb1 = skb;
-		chan->tskb2 = skb2;
-	} else {
-		skb_queue_tail(&chan->e.X, skb);
-		skb_queue_tail(&card->sndq, skb2); 
-		eicon_schedule_tx(card);
-	}
-
-	eicon_log(card, 8, "idi_req: Ch%d: Conn_Req %s -> %s\n",chan->No, eazmsn, phone);
-   return(0);
-}
-
-
-void
-idi_IndParse(eicon_card *ccard, eicon_chan *chan, idi_ind_message *message, unsigned char *buffer, int len)
-{
-	int i,j;
-	int pos = 0;
-	int codeset = 0;
-	int wlen = 0;
-	int lock = 0;
-	__u8 w;
-	__u16 code;
-	isdn_ctrl cmd;
-
-	memset(message, 0, sizeof(idi_ind_message));
-
-	if ((!len) || (!buffer[pos])) return;
-
-  while(pos <= len) {
-	w = buffer[pos++];
-	if (!w) return;
-	if (w & 0x80) {
-		wlen = 0;
-	}
-	else {
-		wlen = buffer[pos++];
-	}
-
-	if (pos > len) return;
-
-	if (lock & 0x80) lock &= 0x7f;
-	else codeset = lock;
-
-	if((w&0xf0) == SHIFT) {
-		codeset = w;
-		if(!(codeset & 0x08)) lock = codeset & 7;
-		codeset &= 7;
-		lock |= 0x80;
-	}
-	else {
-		if (w==ESC && wlen >=2) {
-			code = buffer[pos++]|0x800;
-			wlen--;
-		}
-		else code = w;
-		code |= (codeset<<8);
-
-		if (pos + wlen > len) {
-			eicon_log(ccard, 1, "idi_err: Ch%d: IElen %d of %x exceeds Ind_Length (+%d)\n", chan->No, 
-					wlen, code, (pos + wlen) - len);
-			return;
-		}
-
-		switch(code) {
-			case OAD:
-				if (wlen > sizeof(message->oad)) {
-					pos += wlen;
-					break;
-				}
-				j = 1;
-				if (wlen) {
-					message->plan = buffer[pos++];
-					if (message->plan &0x80) 
-						message->screen = 0;
-					else {
-						message->screen = buffer[pos++];
-						j = 2;
-					}
-				}
-				for(i=0; i < wlen-j; i++) 
-					message->oad[i] = buffer[pos++];
-				eicon_log(ccard, 2, "idi_inf: Ch%d: OAD=(0x%02x,0x%02x) %s\n", chan->No, 
-					message->plan, message->screen, message->oad);
-				break;
-			case RDN:
-				if (wlen > sizeof(message->rdn)) {
-					pos += wlen;
-					break;
-				}
-				j = 1;
-				if (wlen) {
-					if (!(buffer[pos++] & 0x80)) {
-						pos++; 
-						j = 2;
-					}
-				}
-				for(i=0; i < wlen-j; i++) 
-					message->rdn[i] = buffer[pos++];
-				eicon_log(ccard, 2, "idi_inf: Ch%d: RDN= %s\n", chan->No, 
-						message->rdn);
-				break;
-			case CPN:
-				if (wlen > sizeof(message->cpn)) {
-					pos += wlen;
-					break;
-				}
-				for(i=0; i < wlen; i++) 
-					message->cpn[i] = buffer[pos++];
-				eicon_log(ccard, 2, "idi_inf: Ch%d: CPN=(0x%02x) %s\n", chan->No,
-					(__u8)message->cpn[0], message->cpn + 1);
-				break;
-			case DSA:
-				if (wlen > sizeof(message->dsa)) {
-					pos += wlen;
-					break;
-				}
-				pos += 2;
-				for(i=0; i < wlen-2; i++) 
-					message->dsa[i] = buffer[pos++];
-				eicon_log(ccard, 2, "idi_inf: Ch%d: DSA=%s\n", chan->No, message->dsa);
-				break;
-			case OSA:
-				if (wlen > sizeof(message->osa)) {
-					pos += wlen;
-					break;
-				}
-				pos += 2;
-				for(i=0; i < wlen-2; i++) 
-					message->osa[i] = buffer[pos++];
-				eicon_log(ccard, 2, "idi_inf: Ch%d: OSA=%s\n", chan->No, message->osa);
-				break;
-			case CAD:
-				pos += wlen;
-				eicon_log(ccard, 2, "idi_inf: Ch%d: Connected Address in ind, len:%x\n", 
-					chan->No, wlen);
-				break;
-			case BC:
-				if (wlen > sizeof(message->bc)) {
-					pos += wlen;
-					break;
-				}
-				for(i=0; i < wlen; i++) 
-					message->bc[i] = buffer[pos++];
-				eicon_log(ccard, 4, "idi_inf: Ch%d: BC = 0x%02x 0x%02x 0x%02x\n", chan->No,
-					message->bc[0],message->bc[1],message->bc[2]);
-				break;
-			case 0x800|BC:
-				if (wlen > sizeof(message->e_bc)) {
-					pos += wlen;
-					break;
-				}
-				for(i=0; i < wlen; i++) 
-					message->e_bc[i] = buffer[pos++];
-				eicon_log(ccard, 4, "idi_inf: Ch%d: ESC/BC=%d\n", chan->No, message->bc[0]);
-				break;
-			case LLC:
-				if (wlen > sizeof(message->llc)) {
-					pos += wlen;
-					break;
-				}
-				for(i=0; i < wlen; i++) 
-					message->llc[i] = buffer[pos++];
-				eicon_log(ccard, 4, "idi_inf: Ch%d: LLC=%d %d %d %d ...\n", chan->No, message->llc[0],
-					message->llc[1],message->llc[2],message->llc[3]);
-				break;
-			case HLC:
-				if (wlen > sizeof(message->hlc)) {
-					pos += wlen;
-					break;
-				}
-				for(i=0; i < wlen; i++) 
-					message->hlc[i] = buffer[pos++];
-				eicon_log(ccard, 4, "idi_inf: Ch%d: HLC=%x %x %x %x %x ...\n", chan->No,
-					message->hlc[0], message->hlc[1],
-					message->hlc[2], message->hlc[3], message->hlc[4]);
-				break;
-			case DSP:
-			case 0x600|DSP:
-				if (wlen > sizeof(message->display)) {
-					pos += wlen;
-					break;
-				}
-				for(i=0; i < wlen; i++) 
-					message->display[i] = buffer[pos++];
-				eicon_log(ccard, 4, "idi_inf: Ch%d: Display: %s\n", chan->No,
-					message->display);
-				break;
-			case 0x600|KEY:
-				if (wlen > sizeof(message->keypad)) {
-					pos += wlen;
-					break;
-				}
-				for(i=0; i < wlen; i++) 
-					message->keypad[i] = buffer[pos++];
-				eicon_log(ccard, 4, "idi_inf: Ch%d: Keypad: %s\n", chan->No,
-					message->keypad);
-				break;
-			case NI:
-			case 0x600|NI:
-				if (wlen) {
-					switch(buffer[pos] & 127) {
-						case 0:
-							eicon_log(ccard, 4, "idi_inf: Ch%d: User suspended.\n", chan->No);
-							break;
-						case 1:
-							eicon_log(ccard, 4, "idi_inf: Ch%d: User resumed.\n", chan->No);
-							break;
-						case 2:
-							eicon_log(ccard, 4, "idi_inf: Ch%d: Bearer service change.\n", chan->No);
-							break;
-						default:
-							eicon_log(ccard, 4, "idi_inf: Ch%d: Unknown Notification %x.\n", 
-									chan->No, buffer[pos] & 127);
-					}
-					pos += wlen;
-				}
-				break;
-			case PI:
-			case 0x600|PI:
-				if (wlen > 1) {
-					switch(buffer[pos+1] & 127) {
-						case 1:
-							eicon_log(ccard, 4, "idi_inf: Ch%d: Call is not end-to-end ISDN.\n", chan->No);
-							break;
-						case 2:
-							eicon_log(ccard, 4, "idi_inf: Ch%d: Destination address is non ISDN.\n", chan->No);
-							break;
-						case 3:
-							eicon_log(ccard, 4, "idi_inf: Ch%d: Origination address is non ISDN.\n", chan->No);
-							break;
-						case 4:
-							eicon_log(ccard, 4, "idi_inf: Ch%d: Call has returned to the ISDN.\n", chan->No);
-							break;
-						case 5:
-							eicon_log(ccard, 4, "idi_inf: Ch%d: Interworking has occurred.\n", chan->No);
-							break;
-						case 8:
-							eicon_log(ccard, 4, "idi_inf: Ch%d: In-band information available.\n", chan->No);
-							break;
-						default:
-							eicon_log(ccard, 4, "idi_inf: Ch%d: Unknown Progress %x.\n", 
-									chan->No, buffer[pos+1] & 127);
-					}
-				}
-				pos += wlen;
-				break;
-			case CAU:
-				if (wlen > sizeof(message->cau)) {
-					pos += wlen;
-					break;
-				}
-				for(i=0; i < wlen; i++) 
-					message->cau[i] = buffer[pos++];
-				memcpy(&chan->cause, &message->cau, 2);
-				eicon_log(ccard, 4, "idi_inf: Ch%d: CAU=%d %d\n", chan->No,
-					message->cau[0],message->cau[1]);
-				break;
-			case 0x800|CAU:
-				if (wlen > sizeof(message->e_cau)) {
-					pos += wlen;
-					break;
-				}
-				for(i=0; i < wlen; i++) 
-					message->e_cau[i] = buffer[pos++];
-				eicon_log(ccard, 4, "idi_inf: Ch%d: ECAU=%d %d\n", chan->No,
-					message->e_cau[0],message->e_cau[1]);
-				break;
-			case 0x800|CHI:
-				if (wlen > sizeof(message->e_chi)) {
-					pos += wlen;
-					break;
-				}
-				for(i=0; i < wlen; i++) 
-					message->e_chi[i] = buffer[pos++];
-				eicon_log(ccard, 4, "idi_inf: Ch%d: ESC/CHI=%d\n", chan->No,
-					message->e_cau[0]);
-				break;
-			case 0x800|0x7a:
-				pos ++;
-				message->e_mt=buffer[pos++];
-				eicon_log(ccard, 4, "idi_inf: Ch%d: EMT=0x%x\n", chan->No, message->e_mt);
-				break;
-			case DT:
-				if (wlen > sizeof(message->dt)) {
-					pos += wlen;
-					break;
-				}
-				for(i=0; i < wlen; i++) 
-					message->dt[i] = buffer[pos++];
-				eicon_log(ccard, 4, "idi_inf: Ch%d: DT: %02d.%02d.%02d %02d:%02d:%02d\n", chan->No,
-					message->dt[2], message->dt[1], message->dt[0],
-					message->dt[3], message->dt[4], message->dt[5]);
-				break;
-			case 0x600|SIN:
-				if (wlen > sizeof(message->sin)) {
-					pos += wlen;
-					break;
-				}
-				for(i=0; i < wlen; i++) 
-					message->sin[i] = buffer[pos++];
-				eicon_log(ccard, 2, "idi_inf: Ch%d: SIN=%d %d\n", chan->No,
-					message->sin[0],message->sin[1]);
-				break;
-			case 0x600|CPS:
-				eicon_log(ccard, 2, "idi_inf: Ch%d: Called Party Status in ind\n", chan->No);
-				pos += wlen;
-				break;
-			case 0x600|CIF:
-				for (i = 0; i < wlen; i++)
-					if (buffer[pos + i] != '0') break;
-				memcpy(&cmd.parm.num, &buffer[pos + i], wlen - i);
-				cmd.parm.num[wlen - i] = 0;
-				eicon_log(ccard, 2, "idi_inf: Ch%d: CIF=%s\n", chan->No, cmd.parm.num);
-				pos += wlen;
-				cmd.driver = ccard->myid;
-				cmd.command = ISDN_STAT_CINF;
-				cmd.arg = chan->No;
-				ccard->interface.statcallb(&cmd);
-				break;
-			case 0x600|DATE:
-				eicon_log(ccard, 2, "idi_inf: Ch%d: Date in ind\n", chan->No);
-				pos += wlen;
-				break;
-			case 0xa1: 
-				eicon_log(ccard, 2, "idi_inf: Ch%d: Sending Complete in ind.\n", chan->No);
-				pos += wlen;
-				break;
-			case 0xe08: 
-			case 0xe7a: 
-			case 0xe04: 
-			case 0xe00: 
-				/* *** TODO *** */
-			case CHA:
-				/* Charge advice */
-			case FTY:
-			case 0x600|FTY:
-			case CHI:
-			case 0x800:
-				/* Not yet interested in this */
-				pos += wlen;
-				break;
-			case 0x880:
-				/* Managment Information Element */
-				if (!manbuf) {
-					eicon_log(ccard, 1, "idi_err: manbuf not allocated\n");
-				}
-				else {
-					memcpy(&manbuf->data[manbuf->pos], &buffer[pos], wlen);
-					manbuf->length[manbuf->count] = wlen;
-					manbuf->count++;
-					manbuf->pos += wlen;
-				}
-				pos += wlen;
-				break;
-			default:
-				pos += wlen;
-				eicon_log(ccard, 6, "idi_inf: Ch%d: unknown information element 0x%x in ind, len:%x\n", 
-					chan->No, code, wlen);
-		}
-	}
-  }
-}
-
-void
-idi_bc2si(unsigned char *bc, unsigned char *hlc, unsigned char *sin, unsigned char *si1, unsigned char *si2)
-{
-	si1[0] = 0;
-	si2[0] = 0;
-
-	switch (bc[0] & 0x7f) {
-		case 0x00: /* Speech */
-			si1[0] = 1;
-#ifdef EICON_FULL_SERVICE_OKTETT
-			si1[0] = sin[0];
-			si2[0] = sin[1];
-#endif
-			break;
-		case 0x10: /* 3.1 Khz audio */
-			si1[0] = 1;
-#ifdef EICON_FULL_SERVICE_OKTETT
-			si1[0] = sin[0];
-			si2[0] = sin[1];
-#endif
-			break;
-		case 0x08: /* Unrestricted digital information */
-			si1[0] = 7;
-			si2[0] = sin[1];
-			break;
-		case 0x09: /* Restricted digital information */
-			si1[0] = 2;
-			break;
-		case 0x11:
-			/* Unrestr. digital information  with
-			 * tones/announcements ( or 7 kHz audio
-			 */
-			si1[0] = 3;
-			break;
-		case 0x18: /* Video */
-			si1[0] = 4;
-			break;
-	}
-	switch (bc[1] & 0x7f) {
-		case 0x40: /* packed mode */
-			si1[0] = 8;
-			break;
-		case 0x10: /* 64 kbit */
-		case 0x11: /* 2*64 kbit */
-		case 0x13: /* 384 kbit */
-		case 0x15: /* 1536 kbit */
-		case 0x17: /* 1920 kbit */
-			/* moderate = bc[1] & 0x7f; */
-			break;
-	}
-}
-
-/********************* FAX stuff ***************************/
-
-#ifdef CONFIG_ISDN_TTY_FAX
-
-int
-idi_fill_in_T30(eicon_chan *chan, unsigned char *buffer)
-{
-	eicon_t30_s	*t30 = (eicon_t30_s *) buffer;
-
-	if (!chan->fax) {
-		eicon_log(NULL, 1,"idi_T30: fill_in with NULL fax struct, ERROR\n");
-		return 0;
-	}
-	memset(t30, 0, sizeof(eicon_t30_s));
-	t30->station_id_len = EICON_FAXID_LEN;
-	memcpy(&t30->station_id[0], &chan->fax->id[0], EICON_FAXID_LEN);
-	t30->resolution = chan->fax->resolution;
-	t30->rate = chan->fax->rate + 1;	/* eicon rate starts with 1 */
-	t30->format = T30_FORMAT_SFF;
-	t30->pages_low = 0;
-	t30->pages_high = 0;
-	t30->atf = 1;				/* optimised for AT+F command set */
-	t30->code = 0;
-	t30->feature_bits_low = 0;
-	t30->feature_bits_high = 0;
-	t30->control_bits_low = 0;
-	t30->control_bits_high = 0;
-
-	if (chan->fax->nbc) {
-		/* set compression by DCC value */
-  	  switch(chan->fax->compression) {
-		case (0):	/* 1-D modified */
-			break;
-		case (1):	/* 2-D modified Read */
-			t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_2D_CODING;
-			t30->feature_bits_low |= T30_FEATURE_BIT_2D_CODING;
-			break;
-		case (2):	/* 2-D uncompressed */
-			t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_UNCOMPR;
-			t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_2D_CODING;
-			t30->feature_bits_low |= T30_FEATURE_BIT_UNCOMPR_ENABLED;
-			t30->feature_bits_low |= T30_FEATURE_BIT_2D_CODING;
-			break;
-		case (3):	/* 2-D modified Read */
-			t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_T6_CODING;
-			t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_2D_CODING;
-			t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_UNCOMPR;
-			t30->feature_bits_low |= T30_FEATURE_BIT_UNCOMPR_ENABLED;
-			t30->feature_bits_low |= T30_FEATURE_BIT_T6_CODING;
-			t30->feature_bits_low |= T30_FEATURE_BIT_2D_CODING;
-			t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_ECM;
-			t30->feature_bits_low |= T30_FEATURE_BIT_ECM;
-			break;
-	  }
-	} else {
-		/* set compression to best */
-		t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_T6_CODING;
-		t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_2D_CODING;
-		t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_UNCOMPR;
-		t30->feature_bits_low |= T30_FEATURE_BIT_UNCOMPR_ENABLED;
-		t30->feature_bits_low |= T30_FEATURE_BIT_T6_CODING;
-		t30->feature_bits_low |= T30_FEATURE_BIT_2D_CODING;
-		t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_ECM;
-		t30->feature_bits_low |= T30_FEATURE_BIT_ECM;
-	}
-	switch(chan->fax->ecm) {
-		case (0):	/* disable ECM */
-			break;
-		case (1):
-			t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_ECM;
-			t30->control_bits_low |= T30_CONTROL_BIT_ECM_64_BYTES;
-			t30->feature_bits_low |= T30_FEATURE_BIT_ECM;
-			t30->feature_bits_low |= T30_FEATURE_BIT_ECM_64_BYTES;
-			break;
-		case (2):
-			t30->control_bits_low |= T30_CONTROL_BIT_ENABLE_ECM;
-			t30->feature_bits_low |= T30_FEATURE_BIT_ECM;
-			break;
-	}
-
-	if (DebugVar & 128) {
-		char st[40];
-		eicon_log(NULL, 128, "sT30:code = %x\n", t30->code);
-		eicon_log(NULL, 128, "sT30:rate = %x\n", t30->rate);
-		eicon_log(NULL, 128, "sT30:res  = %x\n", t30->resolution);
-		eicon_log(NULL, 128, "sT30:format = %x\n", t30->format);
-		eicon_log(NULL, 128, "sT30:pages_low = %x\n", t30->pages_low);
-		eicon_log(NULL, 128, "sT30:pages_high = %x\n", t30->pages_high);
-		eicon_log(NULL, 128, "sT30:atf  = %x\n", t30->atf);
-		eicon_log(NULL, 128, "sT30:control_bits_low = %x\n", t30->control_bits_low);
-		eicon_log(NULL, 128, "sT30:control_bits_high = %x\n", t30->control_bits_high);
-		eicon_log(NULL, 128, "sT30:feature_bits_low = %x\n", t30->feature_bits_low);
-		eicon_log(NULL, 128, "sT30:feature_bits_high = %x\n", t30->feature_bits_high);
-		//eicon_log(NULL, 128, "sT30:universal_5 = %x\n", t30->universal_5);
-		//eicon_log(NULL, 128, "sT30:universal_6 = %x\n", t30->universal_6);
-		//eicon_log(NULL, 128, "sT30:universal_7 = %x\n", t30->universal_7);
-		eicon_log(NULL, 128, "sT30:station_id_len = %x\n", t30->station_id_len);
-		eicon_log(NULL, 128, "sT30:head_line_len = %x\n", t30->head_line_len);
-		strlcpy(st, t30->station_id, t30->station_id_len + 1);
-		eicon_log(NULL, 128, "sT30:station_id = <%s>\n", st);
-	}
-	return(sizeof(eicon_t30_s));
-}
-
-/* send fax struct */
-int
-idi_send_edata(eicon_card *card, eicon_chan *chan)
-{
-	struct sk_buff *skb;
-	struct sk_buff *skb2;
-	eicon_REQ *reqbuf;
-	eicon_chan_ptr *chan2;
-
-	if ((chan->fsm_state == EICON_STATE_NULL) || (chan->fsm_state == EICON_STATE_LISTEN)) {
-		eicon_log(card, 1, "idi_snd: Ch%d: send edata on state %d !\n", chan->No, chan->fsm_state);
-		return -ENODEV;
-	}
-	eicon_log(card, 128, "idi_snd: Ch%d: edata (fax)\n", chan->No);
-
-	skb = alloc_skb(sizeof(eicon_REQ) + sizeof(eicon_t30_s), GFP_ATOMIC);
-	skb2 = alloc_skb(sizeof(eicon_chan_ptr), GFP_ATOMIC);
-
-	if ((!skb) || (!skb2)) {
-		eicon_log(card, 1, "idi_err: Ch%d: alloc_skb failed in send_edata()\n", chan->No);
-		if (skb) 
-			dev_kfree_skb(skb);
-		if (skb2) 
-			dev_kfree_skb(skb2);
-		return -ENOMEM;
-	}
-
-	chan2 = (eicon_chan_ptr *)skb_put(skb2, sizeof(eicon_chan_ptr));
-	chan2->ptr = chan;
-
-	reqbuf = (eicon_REQ *)skb_put(skb, sizeof(eicon_t30_s) + sizeof(eicon_REQ));
-
-	reqbuf->Req = N_EDATA;
-	reqbuf->ReqCh = chan->e.IndCh;
-	reqbuf->ReqId = 1;
-
-	reqbuf->XBuffer.length = idi_fill_in_T30(chan, reqbuf->XBuffer.P);
-	reqbuf->Reference = 1; /* Net Entity */
-
-	skb_queue_tail(&chan->e.X, skb);
-	skb_queue_tail(&card->sndq, skb2);
-	eicon_schedule_tx(card);
-	return (0);
-}
-
-void
-idi_parse_edata(eicon_card *ccard, eicon_chan *chan, unsigned char *buffer, int len)
-{
-	eicon_t30_s *p = (eicon_t30_s *)buffer;
-	int i;
-
-	if (DebugVar & 128) {
-		char st[40];
-		eicon_log(ccard, 128, "rT30:len %d , size %d\n", len, sizeof(eicon_t30_s));
-		eicon_log(ccard, 128, "rT30:code = %x\n", p->code);
-		eicon_log(ccard, 128, "rT30:rate = %x\n", p->rate);
-		eicon_log(ccard, 128, "rT30:res  = %x\n", p->resolution);
-		eicon_log(ccard, 128, "rT30:format = %x\n", p->format);
-		eicon_log(ccard, 128, "rT30:pages_low = %x\n", p->pages_low);
-		eicon_log(ccard, 128, "rT30:pages_high = %x\n", p->pages_high);
-		eicon_log(ccard, 128, "rT30:atf  = %x\n", p->atf);
-		eicon_log(ccard, 128, "rT30:control_bits_low = %x\n", p->control_bits_low);
-		eicon_log(ccard, 128, "rT30:control_bits_high = %x\n", p->control_bits_high);
-		eicon_log(ccard, 128, "rT30:feature_bits_low = %x\n", p->feature_bits_low);
-		eicon_log(ccard, 128, "rT30:feature_bits_high = %x\n", p->feature_bits_high);
-		//eicon_log(ccard, 128, "rT30:universal_5 = %x\n", p->universal_5);
-		//eicon_log(ccard, 128, "rT30:universal_6 = %x\n", p->universal_6);
-		//eicon_log(ccard, 128, "rT30:universal_7 = %x\n", p->universal_7);
-		eicon_log(ccard, 128, "rT30:station_id_len = %x\n", p->station_id_len);
-		eicon_log(ccard, 128, "rT30:head_line_len = %x\n", p->head_line_len);
-		strlcpy(st, p->station_id, p->station_id_len + 1);
-		eicon_log(ccard, 128, "rT30:station_id = <%s>\n", st);
-	}
-	if (!chan->fax) {
-		eicon_log(ccard, 1, "idi_edata: parse to NULL fax struct, ERROR\n");
-		return;
-	}
-	chan->fax->code = p->code;
-	i = (p->station_id_len < FAXIDLEN) ? p->station_id_len : (FAXIDLEN - 1);
-	memcpy(chan->fax->r_id, p->station_id, i);
-	chan->fax->r_id[i] = 0;
-	chan->fax->r_resolution = p->resolution;
-	chan->fax->r_rate = p->rate - 1;
-	chan->fax->r_binary = 0; /* no binary support */
-	chan->fax->r_width = 0;
-	chan->fax->r_length = 2;
-	chan->fax->r_scantime = 0;
-	chan->fax->r_compression = 0;
-	chan->fax->r_ecm = 0;
-	if (p->feature_bits_low & T30_FEATURE_BIT_2D_CODING) {
-		chan->fax->r_compression = 1;
-		if (p->feature_bits_low & T30_FEATURE_BIT_UNCOMPR_ENABLED) {
-			chan->fax->r_compression = 2;
-		}
-	}
-	if (p->feature_bits_low & T30_FEATURE_BIT_T6_CODING) {
-		chan->fax->r_compression = 3;
-	}
-
-	if (p->feature_bits_low & T30_FEATURE_BIT_ECM) {
-		chan->fax->r_ecm = 2;
-		if (p->feature_bits_low & T30_FEATURE_BIT_ECM_64_BYTES)
-			chan->fax->r_ecm = 1;
-	}
-}
-
-void
-idi_fax_send_header(eicon_card *card, eicon_chan *chan, int header)
-{
-	static __u16 wd2sff[] = {
-		1728, 2048, 2432, 1216, 864
-	};
-	static __u16 ln2sff[2][3] = {
-		{ 1143, 1401, 0 } , { 2287, 2802, 0 }
-	};
-	struct sk_buff *skb;
-	eicon_sff_dochead *doc;
-	eicon_sff_pagehead *page;
-	u_char *docp;
-
-	if (!chan->fax) {
-		eicon_log(card, 1, "idi_fax: send head with NULL fax struct, ERROR\n");
-		return;
-	}
-	if (header == 2) { /* DocHeader + PageHeader */
-		skb = alloc_skb(sizeof(eicon_sff_dochead) + sizeof(eicon_sff_pagehead), GFP_ATOMIC);
-	} else {
-		skb = alloc_skb(sizeof(eicon_sff_pagehead), GFP_ATOMIC);
-	}
-	if (!skb) {
-		eicon_log(card, 1, "idi_err: Ch%d: alloc_skb failed in fax_send_header()\n", chan->No);
-		return;
-	}
-
-	if (header == 2) { /* DocHeader + PageHeader */
-		docp = skb_put(skb, sizeof(eicon_sff_dochead) + sizeof(eicon_sff_pagehead));
-		doc = (eicon_sff_dochead *) docp;
-		page = (eicon_sff_pagehead *) (docp + sizeof(eicon_sff_dochead));
-		memset(docp, 0,sizeof(eicon_sff_dochead)  + sizeof(eicon_sff_pagehead));
-		doc->id = 0x66666653;
-		doc->version = 0x01;
-		doc->off1pagehead = sizeof(eicon_sff_dochead);
-	} else {
-		page = (eicon_sff_pagehead *)skb_put(skb, sizeof(eicon_sff_pagehead));
-		memset(page, 0, sizeof(eicon_sff_pagehead));
-	}
-
-	switch(header) {
-		case 1:	/* PageHeaderEnd */
-			page->pageheadid = 254;
-			page->pageheadlen = 0; 
-			break;
-		case 0: /* PageHeader */
-		case 2: /* DocHeader + PageHeader */
-			page->pageheadid = 254;
-			page->pageheadlen = sizeof(eicon_sff_pagehead) - 2;
-			page->resvert = chan->fax->resolution;
-			page->reshoriz = 0; /* always 203 dpi */
-			page->coding = 0; /* always 1D */
-			page->linelength = wd2sff[chan->fax->width];
-			page->pagelength = ln2sff[chan->fax->resolution][chan->fax->length]; 
-			eicon_log(card, 128, "sSFF-Head: linelength = %d\n", page->linelength);
-			eicon_log(card, 128, "sSFF-Head: pagelength = %d\n", page->pagelength);
-			break;
-	}
-	idi_send_data(card, chan, 0, skb, 0, 0);
-}
-
-void
-idi_fax_cmd(eicon_card *card, eicon_chan *chan) 
-{
-	isdn_ctrl cmd;
-
-	if ((!card) || (!chan))
-		return;
-
-	if (!chan->fax) {
-		eicon_log(card, 1, "idi_fax: cmd with NULL fax struct, ERROR\n");
-		return;
-	}
-	switch (chan->fax->code) {
-		case ISDN_TTY_FAX_DT:
-			if (chan->fax->phase == ISDN_FAX_PHASE_B) {
-				idi_send_edata(card, chan);
-				break;
-			}
-			if (chan->fax->phase == ISDN_FAX_PHASE_D) {
-				idi_send_edata(card, chan);
-				break;
-			}
-			break;
-
-		case ISDN_TTY_FAX_DR:
-			if (chan->fax->phase == ISDN_FAX_PHASE_B) {
-				idi_send_edata(card, chan);
-
-				cmd.driver = card->myid;
-				cmd.command = ISDN_STAT_FAXIND;
-				cmd.arg = chan->No;
-				chan->fax->r_code = ISDN_TTY_FAX_CFR;
-				card->interface.statcallb(&cmd);
-
-				cmd.driver = card->myid;
-				cmd.command = ISDN_STAT_FAXIND;
-				cmd.arg = chan->No;
-				chan->fax->r_code = ISDN_TTY_FAX_RID;
-				card->interface.statcallb(&cmd);
-
-				/* telling 1-D compression */
-				chan->fax->r_compression = 0;
-				cmd.driver = card->myid;
-				cmd.command = ISDN_STAT_FAXIND;
-				cmd.arg = chan->No;
-				chan->fax->r_code = ISDN_TTY_FAX_DCS;
-				card->interface.statcallb(&cmd);
-
-				chan->fax2.NextObject = FAX_OBJECT_DOCU;
-				chan->fax2.PrevObject = FAX_OBJECT_DOCU;
-
-				break;
-			}
-			if (chan->fax->phase == ISDN_FAX_PHASE_D) {
-				idi_send_edata(card, chan);
-				break;
-			}
-			break;
-
-		case ISDN_TTY_FAX_ET:
-				switch(chan->fax->fet) {
-					case 0:
-					case 1:
-						idi_fax_send_header(card, chan, 0);
-						break;
-					case 2:
-						idi_fax_send_header(card, chan, 1);
-						break;
-				}
-			break;
-	}
-}
-
-void
-idi_edata_rcveop(eicon_card *card, eicon_chan *chan)
-{
-	isdn_ctrl cmd;
-
-	if (!chan->fax) {
-		eicon_log(card, 1, "idi_edata: rcveop with NULL fax struct, ERROR\n");
-		return;
-	}
-	cmd.driver = card->myid;
-	cmd.command = ISDN_STAT_FAXIND;
-	cmd.arg = chan->No;
-	chan->fax->r_code = ISDN_TTY_FAX_ET;
-	card->interface.statcallb(&cmd);
-}
-
-void
-idi_reset_fax_stat(eicon_chan *chan)
-{
-	chan->fax2.LineLen = 0;
-	chan->fax2.LineData = 0;
-	chan->fax2.LineDataLen = 0;
-	chan->fax2.NullByteExist = 0;
-	chan->fax2.Dle = 0;
-	chan->fax2.PageCount = 0;
-	chan->fax2.Eop = 0;
-}
-
-void
-idi_edata_action(eicon_card *ccard, eicon_chan *chan, char *buffer, int len)
-{
-	isdn_ctrl cmd;
-
-	if (!chan->fax) {
-		eicon_log(ccard, 1, "idi_edata: action with NULL fax struct, ERROR\n");
-		return;
-	}
-	if (chan->fax->direction == ISDN_TTY_FAX_CONN_OUT) {
-		idi_parse_edata(ccard, chan, buffer, len);
-
-		if (chan->fax->phase == ISDN_FAX_PHASE_A) {
-			idi_reset_fax_stat(chan);
-
-			chan->fsm_state = EICON_STATE_ACTIVE;
-			cmd.driver = ccard->myid;
-			cmd.command = ISDN_STAT_BCONN;
-			cmd.arg = chan->No;
-			strcpy(cmd.parm.num, "");
-			ccard->interface.statcallb(&cmd);
-
-			cmd.driver = ccard->myid;
-			cmd.command = ISDN_STAT_FAXIND;
-			cmd.arg = chan->No;
-			chan->fax->r_code = ISDN_TTY_FAX_FCON;
-			ccard->interface.statcallb(&cmd);
-
-			cmd.driver = ccard->myid;
-			cmd.command = ISDN_STAT_FAXIND;
-			cmd.arg = chan->No;
-			chan->fax->r_code = ISDN_TTY_FAX_RID;
-			ccard->interface.statcallb(&cmd);
-
-			cmd.driver = ccard->myid;
-			cmd.command = ISDN_STAT_FAXIND;
-			cmd.arg = chan->No;
-			chan->fax->r_code = ISDN_TTY_FAX_DIS;
-			ccard->interface.statcallb(&cmd);
-
-			if (chan->fax->r_compression != 0) {
-			/* telling fake compression in second DIS message */
-				chan->fax->r_compression = 0;
-				cmd.driver = ccard->myid;
-				cmd.command = ISDN_STAT_FAXIND;
-				cmd.arg = chan->No;
-				chan->fax->r_code = ISDN_TTY_FAX_DIS;
-				ccard->interface.statcallb(&cmd);
-			}
-
-			cmd.driver = ccard->myid;
-			cmd.command = ISDN_STAT_FAXIND;
-			cmd.arg = chan->No;
-			chan->fax->r_code = ISDN_TTY_FAX_SENT; /* OK message */
-			ccard->interface.statcallb(&cmd);
-		} else
-		if (chan->fax->phase == ISDN_FAX_PHASE_D) {
-
-			if ((chan->fax->code == EDATA_T30_MCF) &&
-			    (chan->fax->fet != 2)) {
-				cmd.driver = ccard->myid;
-				cmd.command = ISDN_STAT_FAXIND;
-				cmd.arg = chan->No;
-				chan->fax->r_code = ISDN_TTY_FAX_PTS;
-				ccard->interface.statcallb(&cmd);
-			}
-
-			switch(chan->fax->fet) {
-				case 0:	/* new page */
-					/* stay in phase D , wait on cmd +FDT */
-					break;
-				case 1:	/* new document */
-					/* link-level switch to phase B */
-					break;
-				case 2:	/* session end */
-				default:
-					/* send_edata produces error on some */
-					/* fax-machines here, so we don't */
-					/* idi_send_edata(ccard, chan); */
-					break;
-			}
-		}
-	}
-
-	if (chan->fax->direction == ISDN_TTY_FAX_CONN_IN) {
-		idi_parse_edata(ccard, chan, buffer, len);
-
-		if ((chan->fax->code == EDATA_T30_DCS) &&
-		    (chan->fax->phase == ISDN_FAX_PHASE_A)) {
-			idi_reset_fax_stat(chan);
-
-			cmd.driver = ccard->myid;
-			cmd.command = ISDN_STAT_BCONN;
-			cmd.arg = chan->No;
-			strcpy(cmd.parm.num, "");
-			ccard->interface.statcallb(&cmd);
-
-			cmd.driver = ccard->myid;
-			cmd.command = ISDN_STAT_FAXIND;
-			cmd.arg = chan->No;
-			chan->fax->r_code = ISDN_TTY_FAX_FCON_I;
-			ccard->interface.statcallb(&cmd);
-		} else
-		if ((chan->fax->code == EDATA_T30_TRAIN_OK) &&
-		    (chan->fax->phase == ISDN_FAX_PHASE_A)) {
-			cmd.driver = ccard->myid;
-			cmd.command = ISDN_STAT_FAXIND;
-			cmd.arg = chan->No;
-			chan->fax->r_code = ISDN_TTY_FAX_RID;
-			ccard->interface.statcallb(&cmd);
-
-			cmd.driver = ccard->myid;
-			cmd.command = ISDN_STAT_FAXIND;
-			cmd.arg = chan->No;
-			chan->fax->r_code = ISDN_TTY_FAX_TRAIN_OK;
-			ccard->interface.statcallb(&cmd);
-		} else
-		if ((chan->fax->code == EDATA_T30_TRAIN_OK) &&
-		    (chan->fax->phase == ISDN_FAX_PHASE_B)) {
-			cmd.driver = ccard->myid;
-			cmd.command = ISDN_STAT_FAXIND;
-			cmd.arg = chan->No;
-			chan->fax->r_code = ISDN_TTY_FAX_TRAIN_OK;
-			ccard->interface.statcallb(&cmd);
-		} else
-		if (chan->fax->phase == ISDN_FAX_PHASE_C) {
-			switch(chan->fax->code) {
-				case EDATA_T30_TRAIN_OK:
-					idi_send_edata(ccard, chan);
-					break;
-				case EDATA_T30_MPS:
-					chan->fax->fet = 0;
-					idi_edata_rcveop(ccard, chan);
-					break;
-				case EDATA_T30_EOM:
-					chan->fax->fet = 1;
-					idi_edata_rcveop(ccard, chan);
-					break;
-				case EDATA_T30_EOP:
-					chan->fax->fet = 2;
-					idi_edata_rcveop(ccard, chan);
-					break;
-			}
-		}
-	}
-}
-
-void
-fax_put_rcv(eicon_card *ccard, eicon_chan *chan, u_char *Data, int len)
-{
-	struct sk_buff *skb;
-	
-        skb = alloc_skb(len + MAX_HEADER_LEN, GFP_ATOMIC);
-	if (!skb) {
-		eicon_log(ccard, 1, "idi_err: Ch%d: alloc_skb failed in fax_put_rcv()\n", chan->No);
-		return;
-	}
-	skb_reserve(skb, MAX_HEADER_LEN);
-	memcpy(skb_put(skb, len), Data, len);
-	ccard->interface.rcvcallb_skb(ccard->myid, chan->No, skb);
-}
-
-void
-idi_faxdata_rcv(eicon_card *ccard, eicon_chan *chan, struct sk_buff *skb)
-{
-	eicon_OBJBUFFER InBuf;
-	eicon_OBJBUFFER LineBuf;
-	unsigned int Length = 0;
-	unsigned int aLength = 0;
-	unsigned int ObjectSize = 0;
-	unsigned int ObjHeadLen = 0;
-	unsigned int ObjDataLen = 0;
-	__u8 Recordtype;
-	__u8 PageHeaderLen;	
-	__u8 Event;
-	eicon_sff_pagehead *ob_page;
-
-	__u16 Cl2Eol = 0x8000;
-
-#	define EVENT_NONE	0
-#	define EVENT_NEEDDATA	1
-
-	if (!chan->fax) {
-		eicon_log(ccard, 1, "idi_fax: rcvdata with NULL fax struct, ERROR\n");
-		return;
-	}
-
-
-	
-	if (chan->fax->direction == ISDN_TTY_FAX_CONN_IN) {
-		InBuf.Data = skb->data;
-		InBuf.Size = skb->len;
-		InBuf.Len  = 0;
-		InBuf.Next = InBuf.Data;
-		LineBuf.Data = chan->fax2.abLine;
-		LineBuf.Size = sizeof(chan->fax2.abLine);
-		LineBuf.Len  = chan->fax2.LineLen;
-		LineBuf.Next = LineBuf.Data + LineBuf.Len;
-
-		Event = EVENT_NONE;
-		while (Event == EVENT_NONE) {
-			switch(chan->fax2.NextObject) {
-				case FAX_OBJECT_DOCU:
-						Length = LineBuf.Len + (InBuf.Size - InBuf.Len);
-						if (Length < sizeof(eicon_sff_dochead)) {
-							Event = EVENT_NEEDDATA;
-							break;
-						}
-						ObjectSize = sizeof(eicon_sff_dochead);
-						Length = ObjectSize;
-						if (LineBuf.Len < Length) {
-							Length -= LineBuf.Len;
-							LineBuf.Len = 0;
-							LineBuf.Next = LineBuf.Data;
-							InBuf.Len += Length;
-							InBuf.Next += Length;
-						} else {
-							LineBuf.Len -= Length;
-							LineBuf.Next = LineBuf.Data + LineBuf.Len;
-							memmove(LineBuf.Data, LineBuf.Data + Length, LineBuf.Len);
-						}
-						chan->fax2.PrevObject = FAX_OBJECT_DOCU;
-						chan->fax2.NextObject = FAX_OBJECT_PAGE;
-					break;
-
-				case FAX_OBJECT_PAGE:
-						Length = LineBuf.Len + (InBuf.Size - InBuf.Len);
-						if (Length < 2) {
-							Event = EVENT_NEEDDATA;
-							break;
-						}
-						if (LineBuf.Len == 0) {
-							*LineBuf.Next++ = *InBuf.Next++;
-							LineBuf.Len++;
-							InBuf.Len++;
-						}
-						if (LineBuf.Len == 1) {
-							*LineBuf.Next++ = *InBuf.Next++;
-							LineBuf.Len++;
-							InBuf.Len++;
-						}
-						PageHeaderLen = *(LineBuf.Data + 1);
-						ObjectSize = (PageHeaderLen == 0) ? 2 : sizeof(eicon_sff_pagehead);
-						if (Length < ObjectSize) {
-							Event = EVENT_NEEDDATA;
-							break;
-						}
-						Length = ObjectSize;
-						/* extract page dimensions */
-						if (LineBuf.Len < Length) {
-							aLength = Length - LineBuf.Len;
-							memcpy(LineBuf.Next, InBuf.Next, aLength);
-							LineBuf.Next += aLength;
-							InBuf.Next += aLength;
-							LineBuf.Len += aLength;
-							InBuf.Len += aLength;
-						}
-						if (Length > 2) {
-							ob_page = (eicon_sff_pagehead *)LineBuf.Data;
-							switch(ob_page->linelength) {
-								case 2048:
-									chan->fax->r_width = 1;
-									break;
-								case 2432:
-									chan->fax->r_width = 2;
-									break;
-								case 1216:
-									chan->fax->r_width = 3;
-									break;
-								case 864:
-									chan->fax->r_width = 4;
-									break;
-								case 1728:
-								default:
-									chan->fax->r_width = 0;
-							}
-							switch(ob_page->pagelength) {
-								case 1143:
-								case 2287:
-									chan->fax->r_length = 0;
-									break;
-								case 1401:
-								case 2802:
-									chan->fax->r_length = 1;
-									break;
-								default:
-									chan->fax->r_length = 2;
-							}
-							eicon_log(ccard, 128, "rSFF-Head: linelength = %d\n", ob_page->linelength);
-							eicon_log(ccard, 128, "rSFF-Head: pagelength = %d\n", ob_page->pagelength);
-						}
-						LineBuf.Len -= Length;
-						LineBuf.Next = LineBuf.Data + LineBuf.Len;
-						memmove(LineBuf.Data, LineBuf.Data + Length, LineBuf.Len);
-
-						chan->fax2.PrevObject = FAX_OBJECT_PAGE;
-						chan->fax2.NextObject = FAX_OBJECT_LINE;
-					break;
-
-				case FAX_OBJECT_LINE:
-						Length = LineBuf.Len + (InBuf.Size - InBuf.Len);
-						if (Length < 1) {
-							Event = EVENT_NEEDDATA;
-							break;
-						}
-						if (LineBuf.Len == 0) {
-							*LineBuf.Next++ = *InBuf.Next++;
-							LineBuf.Len++;
-							InBuf.Len++;
-						}
-						Recordtype = *LineBuf.Data;
-						if (Recordtype == 0) {
-							/* recordtype pixel row (2 byte length) */
-							ObjHeadLen = 3;
-							if (Length < ObjHeadLen) {
-								Event = EVENT_NEEDDATA;
-								break;
-							}
-							while (LineBuf.Len < ObjHeadLen) {
-								*LineBuf.Next++ = *InBuf.Next++;
-								LineBuf.Len++;
-								InBuf.Len++;
-							}
-							ObjDataLen = *((__u16*) (LineBuf.Data + 1));
-							ObjectSize = ObjHeadLen + ObjDataLen;
-							if (Length < ObjectSize) {
-								Event = EVENT_NEEDDATA;
-								break;
-							}
-						} else
-						if ((Recordtype >= 1) && (Recordtype <= 216)) {
-							/* recordtype pixel row (1 byte length) */
-							ObjHeadLen = 1;
-							ObjDataLen = Recordtype;
-							ObjectSize = ObjHeadLen + ObjDataLen;
-							if (Length < ObjectSize) {
-								Event = EVENT_NEEDDATA;
-								break;
-							}
-						} else
-						if ((Recordtype >= 217) && (Recordtype <= 253)) {
-							/* recordtype empty lines */
-							ObjHeadLen = 1;
-							ObjDataLen = 0;
-							ObjectSize = ObjHeadLen + ObjDataLen;
-							LineBuf.Len--;
-							LineBuf.Next = LineBuf.Data + LineBuf.Len;
-							memmove(LineBuf.Data, LineBuf.Data + 1, LineBuf.Len);
-							break;
-						} else
-						if (Recordtype == 254) {
-							/* recordtype page header */
-							chan->fax2.PrevObject = FAX_OBJECT_LINE;
-							chan->fax2.NextObject = FAX_OBJECT_PAGE;
-							break;
-						} else {
-							/* recordtype user information */
-							ObjHeadLen = 2;
-							if (Length < ObjHeadLen) {
-								Event = EVENT_NEEDDATA;
-								break;
-							}
-							while (LineBuf.Len < ObjHeadLen) {
-								*LineBuf.Next++ = *InBuf.Next++;
-								LineBuf.Len++;
-								InBuf.Len++;
-							}
-							ObjDataLen = *(LineBuf.Data + 1);
-							ObjectSize = ObjHeadLen + ObjDataLen;
-							if (ObjDataLen == 0) {
-								/* illegal line coding */
-								LineBuf.Len -= ObjHeadLen;
-								LineBuf.Next = LineBuf.Data + LineBuf.Len;
-								memmove(LineBuf.Data, LineBuf.Data + ObjHeadLen, LineBuf.Len);
-								break;
-							} else {
-								/* user information */
-								if (Length < ObjectSize) {
-									Event = EVENT_NEEDDATA;
-									break;
-								}
-								Length = ObjectSize;
-								if (LineBuf.Len < Length) {
-									Length -= LineBuf.Len;
-									LineBuf.Len = 0;
-									LineBuf.Next = LineBuf.Data;
-									InBuf.Len += Length;
-									InBuf.Next += Length;
-								} else {
-									LineBuf.Len -= Length;
-									LineBuf.Next = LineBuf.Data + LineBuf.Len;
-									memmove(LineBuf.Data, LineBuf.Data + Length, LineBuf.Len);
-								}
-							}
-							break;	
-						}
-						Length = ObjectSize;
-						if (LineBuf.Len > ObjHeadLen) {
-							fax_put_rcv(ccard, chan, LineBuf.Data + ObjHeadLen,
-									(LineBuf.Len - ObjHeadLen));
-						}
-						Length -= LineBuf.Len;
-						LineBuf.Len = 0;
-						LineBuf.Next = LineBuf.Data;
-						if (Length > 0) {
-							fax_put_rcv(ccard, chan, InBuf.Next, Length);
-							InBuf.Len += Length;
-							InBuf.Next += Length;
-						}
-						fax_put_rcv(ccard, chan, (__u8 *)&Cl2Eol, sizeof(Cl2Eol));
-					break;
-			} /* end of switch (chan->fax2.NextObject) */
-		} /* end of while (Event==EVENT_NONE) */
-		if (InBuf.Len < InBuf.Size) {
-			Length = InBuf.Size - InBuf.Len;
-			if ((LineBuf.Len + Length) > LineBuf.Size) {
-				eicon_log(ccard, 1, "idi_fax: Ch%d: %d bytes dropping, small buffer\n", chan->No,
-					Length);
-				} else {
-					memcpy(LineBuf.Next, InBuf.Next, Length);
-					LineBuf.Len += Length;
-				}
-		}
-		chan->fax2.LineLen = LineBuf.Len;
-	} else { /* CONN_OUT */
-		/* On CONN_OUT we do not need incoming data, drop it */
-		/* maybe later for polling */
-	}
-
-#	undef EVENT_NONE
-#	undef EVENT_NEEDDATA
-
-	return;
-}
-
-int
-idi_fax_send_outbuf(eicon_card *ccard, eicon_chan *chan, eicon_OBJBUFFER *OutBuf)
-{
-	struct sk_buff *skb;
-
-	skb = alloc_skb(OutBuf->Len, GFP_ATOMIC);
-	if (!skb) {
-		eicon_log(ccard, 1, "idi_err: Ch%d: alloc_skb failed in fax_send_outbuf()\n", chan->No);
-		return(-1);
-	}
-	memcpy(skb_put(skb, OutBuf->Len), OutBuf->Data, OutBuf->Len);
-
-	OutBuf->Len = 0;
-	OutBuf->Next = OutBuf->Data;
-
-	return(idi_send_data(ccard, chan, 0, skb, 1, 0));
-}
-
-int
-idi_faxdata_send(eicon_card *ccard, eicon_chan *chan, struct sk_buff *skb)
-{
-	isdn_ctrl cmd;
-	eicon_OBJBUFFER InBuf;
-	__u8 InData;
-	__u8 InMask;
-	eicon_OBJBUFFER OutBuf;
-	eicon_OBJBUFFER LineBuf;
-	__u32 LineData;
-	unsigned int LineDataLen;
-	__u8 Byte;
-	__u8 Event;
-	int ret = 1;
-
-#	define EVENT_NONE	0
-#	define EVENT_EOD	1
-#	define EVENT_EOL 	2
-#	define EVENT_EOP 	3
-
-	if ((!ccard) || (!chan))
-		return -1;
-
-	if (!chan->fax) {
-		eicon_log(ccard, 1, "idi_fax: senddata with NULL fax struct, ERROR\n");
-		return -1;
-	}
-
-	if (chan->fax->direction == ISDN_TTY_FAX_CONN_IN) {
-		/* Simply ignore any data written in data mode when receiving a fax.    */
-		/* This is not completely correct because only XON's should come here.  */
-        	dev_kfree_skb(skb);
-		return 1;
-	}
-
-	if (chan->fax->phase != ISDN_FAX_PHASE_C) {
-        	dev_kfree_skb(skb);
-		return 1;
-	}
-
-        if (chan->queued + skb->len > 1200)
-                return 0;
-	if (chan->pqueued > 1)
-		return 0;
-
-	InBuf.Data = skb->data;
-	InBuf.Size = skb->len;
-	InBuf.Len  = 0;
-	InBuf.Next = InBuf.Data;
-	InData = 0;
-	InMask = 0;
-
-	LineBuf.Data = chan->fax2.abLine;
-	LineBuf.Size = sizeof(chan->fax2.abLine);
-	LineBuf.Len  = chan->fax2.LineLen;
-	LineBuf.Next = LineBuf.Data + LineBuf.Len;
-	LineData = chan->fax2.LineData;
-	LineDataLen = chan->fax2.LineDataLen;
-
-	OutBuf.Data = chan->fax2.abFrame;
-	OutBuf.Size = sizeof(chan->fax2.abFrame);
-	OutBuf.Len = 0;
-	OutBuf.Next = OutBuf.Data;
-
-	Event = EVENT_NONE;
-
-	chan->fax2.Eop = 0;
-
-	for (;;) {
-	  for (;;) {
-		if (InMask == 0) {
-			if (InBuf.Len >= InBuf.Size) {
-				Event = EVENT_EOD;
-				break;
-			}
-			if ((chan->fax2.Dle != _DLE_) && *InBuf.Next == _DLE_) {
-				chan->fax2.Dle = _DLE_;
-				InBuf.Next++;
-				InBuf.Len++;
-				if (InBuf.Len >= InBuf.Size) {
-					Event = EVENT_EOD;
-					break;
-				}
-			}
-			if (chan->fax2.Dle == _DLE_) {
-				chan->fax2.Dle = 0;
-				if (*InBuf.Next == _ETX_) {
-					Event = EVENT_EOP;
-					break;
-				} else
-				if (*InBuf.Next == _DLE_) {
-					/* do nothing */
-				} else {
-					eicon_log(ccard, 1,
-						"idi_err: Ch%d: unknown DLE escape %02x found\n",
-							chan->No, *InBuf.Next);
-					InBuf.Next++;
-					InBuf.Len++;
-					if (InBuf.Len >= InBuf.Size) {
-						Event = EVENT_EOD;
-						break;
-					}
-				}
-			}
-			InBuf.Len++;
-			InData = *InBuf.Next++;
-			InMask = (chan->fax->bor) ? 0x80 : 0x01;
-		}
-		while (InMask) {
-			LineData >>= 1;
-			LineDataLen++;
-			if (InData & InMask)
-				LineData |= 0x80000000;
-			if (chan->fax->bor)
-				InMask >>= 1;
-			else
-				InMask <<= 1;
-
-			if ((LineDataLen >= T4_EOL_BITSIZE) &&
-			   ((LineData & T4_EOL_MASK_DWORD) == T4_EOL_DWORD)) {
-				Event = EVENT_EOL;
-				if (LineDataLen > T4_EOL_BITSIZE) {
-					Byte = (__u8)
-						((LineData & ~T4_EOL_MASK_DWORD) >>
-						(32 - LineDataLen));
-					if (Byte == 0) {
-						if (! chan->fax2.NullByteExist) {
-							chan->fax2.NullBytesPos = LineBuf.Len;
-							chan->fax2.NullByteExist = 1;
-						}
-					} else {
-						chan->fax2.NullByteExist = 0;
-					}
-					if (LineBuf.Len < LineBuf.Size) {
-						*LineBuf.Next++  = Byte;
-						LineBuf.Len++;
-					}
-				}
-				LineDataLen = 0;
-				break;
-			}
-			if (LineDataLen >= T4_EOL_BITSIZE + 8) {
-				Byte = (__u8)
-					((LineData & ~T4_EOL_MASK_DWORD) >>
-					(32 - T4_EOL_BITSIZE - 8));
-				LineData &= T4_EOL_MASK_DWORD;
-				LineDataLen = T4_EOL_BITSIZE;
-				if (Byte == 0) {
-					if (! chan->fax2.NullByteExist) {
-						chan->fax2.NullBytesPos = LineBuf.Len;
-						chan->fax2.NullByteExist = 1;
-					}
-				} else {
-					chan->fax2.NullByteExist = 0;
-				}
-				if (LineBuf.Len < LineBuf.Size) {
-					*LineBuf.Next++  = Byte; 
-					LineBuf.Len++;
-				}
-			}
-		}
-		if (Event != EVENT_NONE)
-			break;
-	  }
-
-		if ((Event != EVENT_EOL) && (Event != EVENT_EOP))
-			break;
-
-		if ((Event == EVENT_EOP) && (LineDataLen > 0)) {
-			LineData >>= 32 - LineDataLen;
-			LineDataLen = 0;
-			while (LineData != 0) {
-				Byte = (__u8) LineData;
-				LineData >>= 8;
-				if (Byte == 0) {
-					if (! chan->fax2.NullByteExist) {
-						chan->fax2.NullBytesPos = LineBuf.Len;
-						chan->fax2.NullByteExist = 1;
-					}
-				} else {
-					chan->fax2.NullByteExist = 0;
-				}
-				if (LineBuf.Len < LineBuf.Size) {
-					*LineBuf.Next++  = Byte;
-					LineBuf.Len++;
-				}
-				
-			}
-		}
-		if (chan->fax2.NullByteExist) {
-			if (chan->fax2.NullBytesPos == 0) {
-				LineBuf.Len = 0;
-			} else {
-				LineBuf.Len = chan->fax2.NullBytesPos + 1;
-			}
-		}
-		if (LineBuf.Len > 0) {
-			if (OutBuf.Len + LineBuf.Len + SFF_LEN_FLD_SIZE > OutBuf.Size) {
-				ret = idi_fax_send_outbuf(ccard, chan, &OutBuf);
-			}
-			if (LineBuf.Len <= 216) {
-				*OutBuf.Next++ = (__u8) LineBuf.Len;
-				OutBuf.Len++;
-			} else {
-				*OutBuf.Next++ = 0;
-				*((__u16 *) OutBuf.Next)++ = (__u16) LineBuf.Len;
-				OutBuf.Len += 3;
-			}
-			memcpy(OutBuf.Next, LineBuf.Data, LineBuf.Len);
-			OutBuf.Next += LineBuf.Len;
-			OutBuf.Len  += LineBuf.Len;
-		}
-		LineBuf.Len = 0;
-		LineBuf.Next = LineBuf.Data;
-		chan->fax2.NullByteExist = 0;
-		if (Event == EVENT_EOP)
-			break;
-
-		Event = EVENT_NONE;
-	}
-
-	if (Event == EVENT_EOP) {
-		chan->fax2.Eop = 1;
-		chan->fax2.PageCount++;
-		cmd.driver = ccard->myid;
-		cmd.command = ISDN_STAT_FAXIND;
-		cmd.arg = chan->No;
-		chan->fax->r_code = ISDN_TTY_FAX_EOP;
-		ccard->interface.statcallb(&cmd);
-	}
-	if (OutBuf.Len > 0) {
-		ret = idi_fax_send_outbuf(ccard, chan, &OutBuf);
-	}
-
-	chan->fax2.LineLen = LineBuf.Len;
-	chan->fax2.LineData = LineData;
-	chan->fax2.LineDataLen = LineDataLen;
-
-#	undef EVENT_NONE
-#	undef EVENT_EOD
-#	undef EVENT_EOL
-#	undef EVENT_EOP
-
-	if (ret >= 0)
-	        dev_kfree_skb(skb);
-	if (ret == 0)
-		ret = 1;
-	return(ret);
-}
-
-void
-idi_fax_hangup(eicon_card *ccard, eicon_chan *chan)
-{
-	isdn_ctrl cmd;
-
-	if (!chan->fax) {
-		eicon_log(ccard, 1, "idi_fax: hangup with NULL fax struct, ERROR\n");
-		return;
-	}
-	if ((chan->fax->direction == ISDN_TTY_FAX_CONN_OUT) &&
-	    (chan->fax->code == 0)) {
-		cmd.driver = ccard->myid;
-		cmd.command = ISDN_STAT_FAXIND;
-		cmd.arg = chan->No;
-		chan->fax->r_code = ISDN_TTY_FAX_PTS;
-		ccard->interface.statcallb(&cmd);
-	}
-	if ((chan->fax->code > 1) && (chan->fax->code < 120))
-		chan->fax->code += 120;
-	eicon_log(ccard, 8, "idi_fax: Ch%d: Hangup (code=%d)\n", chan->No, chan->fax->code);
-	chan->fax->r_code = ISDN_TTY_FAX_HNG;
-	cmd.driver = ccard->myid;
-	cmd.command = ISDN_STAT_FAXIND;
-	cmd.arg = chan->No;
-	ccard->interface.statcallb(&cmd);
-}
-
-#endif	/******** FAX ********/
-
-int
-idi_send_udata(eicon_card *card, eicon_chan *chan, int UReq, u_char *buffer, int len)
-{
-	struct sk_buff *skb;
-	struct sk_buff *skb2;
-	eicon_REQ *reqbuf;
-	eicon_chan_ptr *chan2;
-
-	if ((chan->fsm_state == EICON_STATE_NULL) || (chan->fsm_state == EICON_STATE_LISTEN)) {
-		eicon_log(card, 1, "idi_snd: Ch%d: send udata on state %d !\n", chan->No, chan->fsm_state);
-		return -ENODEV;
-	}
-	eicon_log(card, 8, "idi_snd: Ch%d: udata 0x%x: %d %d %d %d\n", chan->No,
-			UReq, buffer[0], buffer[1], buffer[2], buffer[3]);
-
-	skb = alloc_skb(sizeof(eicon_REQ) + len + 1, GFP_ATOMIC);
-	skb2 = alloc_skb(sizeof(eicon_chan_ptr), GFP_ATOMIC);
-
-	if ((!skb) || (!skb2)) {
-		eicon_log(card, 1, "idi_err: Ch%d: alloc_skb failed in send_udata()\n", chan->No);
-		if (skb) 
-			dev_kfree_skb(skb);
-		if (skb2) 
-			dev_kfree_skb(skb2);
-		return -ENOMEM;
-	}
-
-	chan2 = (eicon_chan_ptr *)skb_put(skb2, sizeof(eicon_chan_ptr));
-	chan2->ptr = chan;
-
-	reqbuf = (eicon_REQ *)skb_put(skb, 1 + len + sizeof(eicon_REQ));
-
-	reqbuf->Req = N_UDATA;
-	reqbuf->ReqCh = chan->e.IndCh;
-	reqbuf->ReqId = 1;
-
-	reqbuf->XBuffer.length = len + 1;
-	reqbuf->XBuffer.P[0] = UReq;
-	memcpy(&reqbuf->XBuffer.P[1], buffer, len);
-	reqbuf->Reference = 1; /* Net Entity */
-
-	skb_queue_tail(&chan->e.X, skb);
-	skb_queue_tail(&card->sndq, skb2);
-	eicon_schedule_tx(card);
-	return (0);
-}
-
-void
-idi_audio_cmd(eicon_card *ccard, eicon_chan *chan, int cmd, u_char *value)
-{
-	u_char buf[6];
-	struct enable_dtmf_s *dtmf_buf = (struct enable_dtmf_s *)buf;
-
-	if ((!ccard) || (!chan))
-		return;
-
-	memset(buf, 0, 6);
-	switch(cmd) {
-		case ISDN_AUDIO_SETDD:
-			if (value[0]) {
-				dtmf_buf->tone = (__u16) (value[1] * 5);
-				dtmf_buf->gap = (__u16) (value[1] * 5);
-				idi_send_udata(ccard, chan,
-					DSP_UDATA_REQUEST_ENABLE_DTMF_RECEIVER,
-					buf, 4);
-			} else {
-				idi_send_udata(ccard, chan,
-					DSP_UDATA_REQUEST_DISABLE_DTMF_RECEIVER,
-					buf, 0);
-			}
-			break;
-	}
-}
-
-void
-idi_parse_udata(eicon_card *ccard, eicon_chan *chan, unsigned char *buffer, int len)
-{
-	isdn_ctrl cmd;
-	eicon_dsp_ind *p = (eicon_dsp_ind *) (&buffer[1]);
-        static char *connmsg[] =
-        {"", "V.21", "V.23", "V.22", "V.22bis", "V.32bis", "V.34",
-         "V.8", "Bell 212A", "Bell 103", "V.29 Leased", "V.33 Leased", "V.90",
-         "V.21 CH2", "V.27ter", "V.29", "V.33", "V.17", "V.32", "K56Flex",
-         "X2", "V.18", "V.18LH", "V.18HL", "V.21LH", "V.21HL",
-         "Bell 103LH", "Bell 103HL", "V.23", "V.23", "EDT 110",
-         "Baudot45", "Baudot47", "Baudot50", "DTMF" };
-	static u_char dtmf_code[] = {
-	'1','4','7','*','2','5','8','0','3','6','9','#','A','B','C','D'
-	};
-
-	if ((!ccard) || (!chan))
-		return;
-
-	switch (buffer[0]) {
-		case DSP_UDATA_INDICATION_SYNC:
-			eicon_log(ccard, 16, "idi_ind: Ch%d: UDATA_SYNC time %d\n", chan->No, p->time);
-			break;
-		case DSP_UDATA_INDICATION_DCD_OFF:
-			eicon_log(ccard, 8, "idi_ind: Ch%d: UDATA_DCD_OFF time %d\n", chan->No, p->time);
-			break;
-		case DSP_UDATA_INDICATION_DCD_ON:
-			if ((chan->l2prot == ISDN_PROTO_L2_MODEM) &&
-			    (chan->fsm_state == EICON_STATE_WMCONN)) {
-				chan->fsm_state = EICON_STATE_ACTIVE;
-				cmd.driver = ccard->myid;
-				cmd.command = ISDN_STAT_BCONN;
-				cmd.arg = chan->No;
-                                if (p->norm > 34) {
-                                  sprintf(cmd.parm.num, "%d/(%d)", p->speed, p->norm);
-                                } else {
-                                  sprintf(cmd.parm.num, "%d/%s", p->speed, connmsg[p->norm]);
-                                }
-				ccard->interface.statcallb(&cmd);
-			}
-			eicon_log(ccard, 8, "idi_ind: Ch%d: UDATA_DCD_ON time %d\n", chan->No, p->time);
-			eicon_log(ccard, 8, "idi_ind: Ch%d: %d %d %d %d\n", chan->No,
-				p->norm, p->options, p->speed, p->delay); 
-			break;
-		case DSP_UDATA_INDICATION_CTS_OFF:
-			eicon_log(ccard, 8, "idi_ind: Ch%d: UDATA_CTS_OFF time %d\n", chan->No, p->time);
-			break;
-		case DSP_UDATA_INDICATION_CTS_ON:
-			eicon_log(ccard, 8, "idi_ind: Ch%d: UDATA_CTS_ON time %d\n", chan->No, p->time);
-			eicon_log(ccard, 8, "idi_ind: Ch%d: %d %d %d %d\n", chan->No,
-				p->norm, p->options, p->speed, p->delay); 
-			break;
-		case DSP_UDATA_INDICATION_DISCONNECT:
-			eicon_log(ccard, 8, "idi_ind: Ch%d: UDATA_DISCONNECT cause %d\n", chan->No, buffer[1]);
-			break;
-		case DSP_UDATA_INDICATION_DTMF_DIGITS_RECEIVED:
-			eicon_log(ccard, 8, "idi_ind: Ch%d: UDATA_DTMF_REC '%c'\n", chan->No,
-				dtmf_code[buffer[1]]);
-			cmd.driver = ccard->myid;
-			cmd.command = ISDN_STAT_AUDIO;
-			cmd.parm.num[0] = ISDN_AUDIO_DTMF;
-			cmd.parm.num[1] = dtmf_code[buffer[1]];
-			cmd.arg = chan->No;
-			ccard->interface.statcallb(&cmd);
-			break;
-		default:
-			eicon_log(ccard, 8, "idi_ind: Ch%d: UNHANDLED UDATA Indication 0x%02x\n", chan->No, buffer[0]);
-	}
-}
-
-void
-eicon_parse_trace(eicon_card *ccard, unsigned char *buffer, int len)
-{
-	int i,j,n;
-	int buflen = len * 3 + 30;
-	char *p;
-	struct trace_s {
-		unsigned long time;
-		unsigned short size;
-		unsigned short code;
-		unsigned char data[1];
-	} *q;
-
-	if (!(p = kmalloc(buflen, GFP_ATOMIC))) {
-		eicon_log(ccard, 1, "idi_err: Ch??: could not allocate trace buffer\n");
-		return;
-	}
-	memset(p, 0, buflen);
-	q = (struct trace_s *)buffer;
-
-	if (DebugVar & 512) {
-		if ((q->code == 3) || (q->code == 4)) {
-			n = (short) *(q->data);
-			if (n) {
-				j = sprintf(p, "DTRC:");
-				for (i = 0; i < n; i++) {
-					j += sprintf(p + j, "%02x ", q->data[i+2]);
-				}
-				j += sprintf(p + j, "\n");
-			}
-		}
-	} else {
-		j = sprintf(p, "XLOG: %lx %04x %04x ",
-			q->time, q->size, q->code);
-
-		for (i = 0; i < q->size; i++) {
-			j += sprintf(p + j, "%02x ", q->data[i]);
-		}
-		j += sprintf(p + j, "\n");
-	}
-	if (strlen(p))
-		eicon_putstatus(ccard, p);
-	kfree(p);
-}
-
-void
-idi_handle_ind(eicon_card *ccard, struct sk_buff *skb)
-{
-	int tmp;
-	char tnum[64];
-	int dlev;
-	int free_buff;
-	ulong flags;
-	struct sk_buff *skb2;
-        eicon_IND *ind = (eicon_IND *)skb->data;
-	eicon_chan *chan;
-	idi_ind_message message;
-	isdn_ctrl cmd;
-
-	if (!ccard) {
-		eicon_log(ccard, 1, "idi_err: Ch??: null card in handle_ind\n");
-  		dev_kfree_skb(skb);
-		return;
-	}
-
-	if ((chan = ccard->IdTable[ind->IndId]) == NULL) {
-		eicon_log(ccard, 1, "idi_err: Ch??: null chan in handle_ind\n");
-  		dev_kfree_skb(skb);
-		return;
-	}
-	
-	if ((ind->Ind != 8) && (ind->Ind != 0xc))
-		dlev = 144;
-	else
-		dlev = 128;
-
-       	eicon_log(ccard, dlev, "idi_hdl: Ch%d: Ind=%x Id=%x Ch=%x MInd=%x MLen=%x Len=%x\n", chan->No,
-	        ind->Ind,ind->IndId,ind->IndCh,ind->MInd,ind->MLength,ind->RBuffer.length);
-
-	free_buff = 1;
-	/* Signal Layer */
-	if (chan->e.D3Id == ind->IndId) {
-		idi_IndParse(ccard, chan, &message, ind->RBuffer.P, ind->RBuffer.length);
-		switch(ind->Ind) {
-			case HANGUP:
-				eicon_log(ccard, 8, "idi_ind: Ch%d: Hangup\n", chan->No);
-		                while((skb2 = skb_dequeue(&chan->e.X))) {
-					dev_kfree_skb(skb2);
-				}
-				spin_lock_irqsave(&eicon_lock, flags);
-				chan->queued = 0;
-				chan->pqueued = 0;
-				chan->waitq = 0;
-				chan->waitpq = 0;
-				spin_unlock_irqrestore(&eicon_lock, flags);
-				if (message.e_cau[0] & 0x7f) {
-					cmd.driver = ccard->myid;
-					cmd.arg = chan->No;
-					sprintf(cmd.parm.num,"E%02x%02x", 
-						chan->cause[0]&0x7f, message.e_cau[0]&0x7f); 
-					cmd.command = ISDN_STAT_CAUSE;
-					ccard->interface.statcallb(&cmd);
-				}
-				chan->cause[0] = 0; 
-				if (((chan->fsm_state == EICON_STATE_ACTIVE) ||
-				    (chan->fsm_state == EICON_STATE_WMCONN)) ||
-				    ((chan->l2prot == ISDN_PROTO_L2_FAX) &&
-				    (chan->fsm_state == EICON_STATE_OBWAIT))) {
-					chan->fsm_state = EICON_STATE_NULL;
-				} else {
-					if (chan->e.B2Id)
-						idi_do_req(ccard, chan, REMOVE, 1);
-					chan->statectrl &= ~WAITING_FOR_HANGUP;
-					chan->statectrl &= ~IN_HOLD;
-					if (chan->statectrl & HAVE_CONN_REQ) {
-						eicon_log(ccard, 32, "idi_req: Ch%d: queueing delayed conn_req\n", chan->No);
-						chan->statectrl &= ~HAVE_CONN_REQ;
-						if ((chan->tskb1) && (chan->tskb2)) {
-							skb_queue_tail(&chan->e.X, chan->tskb1);
-							skb_queue_tail(&ccard->sndq, chan->tskb2); 
-							eicon_schedule_tx(ccard);
-						}
-						chan->tskb1 = NULL;
-						chan->tskb2 = NULL;
-					} else {
-						chan->fsm_state = EICON_STATE_NULL;
-						cmd.driver = ccard->myid;
-						cmd.arg = chan->No;
-						cmd.command = ISDN_STAT_DHUP;
-						ccard->interface.statcallb(&cmd);
-						eicon_idi_listen_req(ccard, chan);
-#ifdef CONFIG_ISDN_TTY_FAX
-						chan->fax = 0;
-#endif
-					}
-				}
-				break;
-			case INDICATE_IND:
-				eicon_log(ccard, 8, "idi_ind: Ch%d: Indicate_Ind\n", chan->No);
-				if (chan->fsm_state != EICON_STATE_LISTEN) {
-					eicon_log(ccard, 1, "idi_err: Ch%d: Incoming call on wrong state (%d).\n",
-						chan->No, chan->fsm_state);
-					idi_do_req(ccard, chan, HANGUP, 0);
-					break;
-				}
-				chan->fsm_state = EICON_STATE_ICALL;
-				idi_bc2si(message.bc, message.hlc, message.sin, &chan->si1, &chan->si2);
-				strcpy(chan->cpn, message.cpn + 1);
-				strcpy(chan->oad, message.oad);
-				strcpy(chan->dsa, message.dsa);
-				strcpy(chan->osa, message.osa);
-				chan->plan = message.plan;
-				chan->screen = message.screen;
-				try_stat_icall_again: 
-				cmd.driver = ccard->myid;
-				cmd.command = ISDN_STAT_ICALL;
-				cmd.arg = chan->No;
-				cmd.parm.setup.si1 = chan->si1;
-				cmd.parm.setup.si2 = chan->si2;
-				strcpy(tnum, chan->cpn);
-				if (strlen(chan->dsa)) {
-					strcat(tnum, ".");
-					strcat(tnum, chan->dsa);
-				}
-				tnum[ISDN_MSNLEN - 1] = 0;
-				strcpy(cmd.parm.setup.eazmsn, tnum);
-				strcpy(tnum, chan->oad);
-				if (strlen(chan->osa)) {
-					strcat(tnum, ".");
-					strcat(tnum, chan->osa);
-				}
-				tnum[ISDN_MSNLEN - 1] = 0;
-				strcpy(cmd.parm.setup.phone, tnum);
-				cmd.parm.setup.plan = chan->plan;
-				cmd.parm.setup.screen = chan->screen;
-				tmp = ccard->interface.statcallb(&cmd);
-				switch(tmp) {
-					case 0: /* no user responding */
-						idi_do_req(ccard, chan, HANGUP, 0);
-						chan->fsm_state = EICON_STATE_NULL;
-						break;
-					case 1: /* alert */
-						eicon_log(ccard, 8, "idi_req: Ch%d: Call Alert\n", chan->No);
-						if ((chan->fsm_state == EICON_STATE_ICALL) || (chan->fsm_state == EICON_STATE_ICALLW)) {
-							chan->fsm_state = EICON_STATE_ICALL;
-							idi_do_req(ccard, chan, CALL_ALERT, 0);
-						}
-						break;
-					case 2: /* reject */
-						eicon_log(ccard, 8, "idi_req: Ch%d: Call Reject\n", chan->No);
-						idi_do_req(ccard, chan, REJECT, 0);
-						break;
-					case 3: /* incomplete number */
-						eicon_log(ccard, 8, "idi_req: Ch%d: Incomplete Number\n", chan->No);
-						chan->fsm_state = EICON_STATE_ICALLW;
-						break;
-				}
-				break;
-			case INFO_IND:
-				eicon_log(ccard, 8, "idi_ind: Ch%d: Info_Ind\n", chan->No);
-				if ((chan->fsm_state == EICON_STATE_ICALLW) &&
-				    (message.cpn[0])) {
-					strcat(chan->cpn, message.cpn + 1);
-					goto try_stat_icall_again;
-				}
-				break;
-			case CALL_IND:
-				eicon_log(ccard, 8, "idi_ind: Ch%d: Call_Ind\n", chan->No);
-				if ((chan->fsm_state == EICON_STATE_ICALL) || (chan->fsm_state == EICON_STATE_IWAIT)) {
-					chan->fsm_state = EICON_STATE_IBWAIT;
-					cmd.driver = ccard->myid;
-					cmd.command = ISDN_STAT_DCONN;
-					cmd.arg = chan->No;
-					ccard->interface.statcallb(&cmd);
-					switch(chan->l2prot) {
-						case ISDN_PROTO_L2_FAX:
-#ifdef CONFIG_ISDN_TTY_FAX
-							if (chan->fax)
-								chan->fax->phase = ISDN_FAX_PHASE_A;
-#endif
-							break;
-						case ISDN_PROTO_L2_MODEM:
-							/* do nothing, wait for connect */
-							break;
-						case ISDN_PROTO_L2_V11096:
-						case ISDN_PROTO_L2_V11019:
-						case ISDN_PROTO_L2_V11038:
-						case ISDN_PROTO_L2_TRANS:
-							idi_do_req(ccard, chan, N_CONNECT, 1);
-							break;
-						default:;
-							/* On most incoming calls we use automatic connect */
-							/* idi_do_req(ccard, chan, N_CONNECT, 1); */
-					}
-				} else {
-					if (chan->fsm_state != EICON_STATE_ACTIVE)
-						idi_hangup(ccard, chan);
-				}
-				break;
-			case CALL_CON:
-				eicon_log(ccard, 8, "idi_ind: Ch%d: Call_Con\n", chan->No);
-				if (chan->fsm_state == EICON_STATE_OCALL) {
-					/* check if old NetID has been removed */
-					if (chan->e.B2Id) {
-						eicon_log(ccard, 1, "eicon: Ch%d: old net_id %x still exist, removing.\n",
-							chan->No, chan->e.B2Id);
-						idi_do_req(ccard, chan, REMOVE, 1);
-					}
-#ifdef CONFIG_ISDN_TTY_FAX
-					if (chan->l2prot == ISDN_PROTO_L2_FAX) {
-						if (chan->fax) {
-							chan->fax->phase = ISDN_FAX_PHASE_A;
-						} else {
-							eicon_log(ccard, 1, "idi_ind: Call_Con with NULL fax struct, ERROR\n");
-							idi_hangup(ccard, chan);
-							break;
-						}
-					}
-#endif
-					chan->fsm_state = EICON_STATE_OBWAIT;
-					cmd.driver = ccard->myid;
-					cmd.command = ISDN_STAT_DCONN;
-					cmd.arg = chan->No;
-					ccard->interface.statcallb(&cmd);
-
-					idi_do_req(ccard, chan, ASSIGN, 1); 
-					idi_do_req(ccard, chan, N_CONNECT, 1);
-				} else
-					idi_hangup(ccard, chan);
-				break;
-			case AOC_IND:
-				eicon_log(ccard, 8, "idi_ind: Ch%d: Advice of Charge\n", chan->No);
-				break;
-			case CALL_HOLD_ACK:
-				chan->statectrl |= IN_HOLD;
-				eicon_log(ccard, 8, "idi_ind: Ch%d: Call Hold Ack\n", chan->No);
-				break;
-			case SUSPEND_REJ:
-				eicon_log(ccard, 8, "idi_ind: Ch%d: Suspend Rejected\n", chan->No);
-				break;
-			case SUSPEND:
-				eicon_log(ccard, 8, "idi_ind: Ch%d: Suspend Ack\n", chan->No);
-				break;
-			case RESUME:
-				eicon_log(ccard, 8, "idi_ind: Ch%d: Resume Ack\n", chan->No);
-				break;
-			default:
-				eicon_log(ccard, 8, "idi_ind: Ch%d: UNHANDLED SigIndication 0x%02x\n", chan->No, ind->Ind);
-		}
-	}
-	/* Network Layer */
-	else if (chan->e.B2Id == ind->IndId) {
-
-		if (chan->No == ccard->nchannels) {
-			/* Management Indication */
-			if (ind->Ind == 0x04) { /* Trace_Ind */
-				eicon_parse_trace(ccard, ind->RBuffer.P, ind->RBuffer.length);
-			} else {
-				idi_IndParse(ccard, chan, &message, ind->RBuffer.P, ind->RBuffer.length);
-				chan->fsm_state = 1;
-			}
-		} 
-		else
-		switch(ind->Ind) {
-			case N_CONNECT_ACK:
-				eicon_log(ccard, 16, "idi_ind: Ch%d: N_Connect_Ack\n", chan->No);
-				if (chan->l2prot == ISDN_PROTO_L2_MODEM) {
-					chan->fsm_state = EICON_STATE_WMCONN;
-					break;
-				}
-				if (chan->l2prot == ISDN_PROTO_L2_FAX) {
-#ifdef CONFIG_ISDN_TTY_FAX
-					chan->fsm_state = EICON_STATE_ACTIVE;
-					idi_parse_edata(ccard, chan, ind->RBuffer.P, ind->RBuffer.length);
-					if (chan->fax) {
-						if (chan->fax->phase == ISDN_FAX_PHASE_B) {
-							idi_fax_send_header(ccard, chan, 2);
-							cmd.driver = ccard->myid;
-							cmd.command = ISDN_STAT_FAXIND;
-							cmd.arg = chan->No;
-							chan->fax->r_code = ISDN_TTY_FAX_DCS;
-							ccard->interface.statcallb(&cmd);
-						}
-					}
-					else {
-						eicon_log(ccard, 1, "idi_ind: N_Connect_Ack with NULL fax struct, ERROR\n");
-					}
-#endif
-					break;
-				}
-				chan->fsm_state = EICON_STATE_ACTIVE;
-				cmd.driver = ccard->myid;
-				cmd.command = ISDN_STAT_BCONN;
-				cmd.arg = chan->No;
-				strcpy(cmd.parm.num, "64000");
-				ccard->interface.statcallb(&cmd);
-				break; 
-			case N_CONNECT:
-				eicon_log(ccard, 16,"idi_ind: Ch%d: N_Connect\n", chan->No);
-				chan->e.IndCh = ind->IndCh;
-				if (chan->e.B2Id) idi_do_req(ccard, chan, N_CONNECT_ACK, 1);
-				if (chan->l2prot == ISDN_PROTO_L2_FAX) {
-					break;
-				}
-				if (chan->l2prot == ISDN_PROTO_L2_MODEM) {
-					chan->fsm_state = EICON_STATE_WMCONN;
-					break;
-				}
-				chan->fsm_state = EICON_STATE_ACTIVE;
-				cmd.driver = ccard->myid;
-				cmd.command = ISDN_STAT_BCONN;
-				cmd.arg = chan->No;
-				strcpy(cmd.parm.num, "64000");
-				ccard->interface.statcallb(&cmd);
-				break; 
-			case N_DISC:
-				eicon_log(ccard, 16, "idi_ind: Ch%d: N_Disc\n", chan->No);
-				if (chan->e.B2Id) {
-		                	while((skb2 = skb_dequeue(&chan->e.X))) {
-						dev_kfree_skb(skb2);
-					}
-					idi_do_req(ccard, chan, N_DISC_ACK, 1);
-					idi_do_req(ccard, chan, REMOVE, 1);
-				}
-#ifdef CONFIG_ISDN_TTY_FAX
-				if ((chan->l2prot == ISDN_PROTO_L2_FAX) && (chan->fax)){
-					idi_parse_edata(ccard, chan, ind->RBuffer.P, ind->RBuffer.length);
-					idi_fax_hangup(ccard, chan);
-				}
-#endif
-				chan->e.IndCh = 0;
-				spin_lock_irqsave(&eicon_lock, flags);
-				chan->queued = 0;
-				chan->pqueued = 0;
-				chan->waitq = 0;
-				chan->waitpq = 0;
-				spin_unlock_irqrestore(&eicon_lock, flags);
-				if (!(chan->statectrl & IN_HOLD)) {
-					idi_do_req(ccard, chan, HANGUP, 0);
-				}
-				if (chan->fsm_state == EICON_STATE_ACTIVE) {
-					cmd.driver = ccard->myid;
-					cmd.command = ISDN_STAT_BHUP;
-					cmd.arg = chan->No;
-					ccard->interface.statcallb(&cmd);
-					chan->fsm_state = EICON_STATE_NULL;
-					if (!(chan->statectrl & IN_HOLD)) {
-						chan->statectrl |= WAITING_FOR_HANGUP;
-					}
-				}
-#ifdef CONFIG_ISDN_TTY_FAX
-				chan->fax = 0;
-#endif
-				break; 
-			case N_DISC_ACK:
-				eicon_log(ccard, 16, "idi_ind: Ch%d: N_Disc_Ack\n", chan->No);
-#ifdef CONFIG_ISDN_TTY_FAX
-				if (chan->l2prot == ISDN_PROTO_L2_FAX) {
-					idi_parse_edata(ccard, chan, ind->RBuffer.P, ind->RBuffer.length);
-					idi_fax_hangup(ccard, chan);
-				}
-#endif
-				break; 
-			case N_DATA_ACK:
-				eicon_log(ccard, 128, "idi_ind: Ch%d: N_Data_Ack\n", chan->No);
-				break;
-			case N_DATA:
-				skb_pull(skb, sizeof(eicon_IND) - 1);
-				eicon_log(ccard, 128, "idi_rcv: Ch%d: %d bytes\n", chan->No, skb->len);
-				if (chan->l2prot == ISDN_PROTO_L2_FAX) {
-#ifdef CONFIG_ISDN_TTY_FAX
-					idi_faxdata_rcv(ccard, chan, skb);
-#endif
-				} else {
-					ccard->interface.rcvcallb_skb(ccard->myid, chan->No, skb);
-					free_buff = 0; 
-				}
-				break; 
-			case N_UDATA:
-				idi_parse_udata(ccard, chan, ind->RBuffer.P, ind->RBuffer.length);
-				break; 
-#ifdef CONFIG_ISDN_TTY_FAX
-			case N_EDATA:
-				idi_edata_action(ccard, chan, ind->RBuffer.P, ind->RBuffer.length);
-				break; 
-#endif
-			default:
-				eicon_log(ccard, 8, "idi_ind: Ch%d: UNHANDLED NetIndication 0x%02x\n", chan->No, ind->Ind);
-		}
-	}
-	else {
-		eicon_log(ccard, 1, "idi_ind: Ch%d: Ind is neither SIG nor NET !\n", chan->No);
-	}
-   if (free_buff)
-	dev_kfree_skb(skb);
-}
-
-int
-idi_handle_ack_ok(eicon_card *ccard, eicon_chan *chan, eicon_RC *ack)
-{
-	ulong flags;
-	isdn_ctrl cmd;
-	int tqueued = 0;
-	int twaitpq = 0;
-
-	if (ack->RcId != ((chan->e.ReqCh) ? chan->e.B2Id : chan->e.D3Id)) {
-		/* I don't know why this happens, should not ! */
-		/* just ignoring this RC */
-		eicon_log(ccard, 16, "idi_ack: Ch%d: RcId %d not equal to last %d\n", chan->No, 
-			ack->RcId, (chan->e.ReqCh) ? chan->e.B2Id : chan->e.D3Id);
-		return 1;
-	}
-
-	/* Management Interface */	
-	if (chan->No == ccard->nchannels) {
-		/* Managementinterface: changing state */
-		if (chan->e.Req != 0x02)
-			chan->fsm_state = 1;
-	}
-
-	/* Remove an Id */
-	if (chan->e.Req == REMOVE) {
-		if (ack->Reference != chan->e.ref) {
-			/* This should not happen anymore */
-			eicon_log(ccard, 16, "idi_ack: Ch%d: Rc-Ref %d not equal to stored %d\n", chan->No,
-				ack->Reference, chan->e.ref);
-		}
-		spin_lock_irqsave(&eicon_lock, flags);
-		ccard->IdTable[ack->RcId] = NULL;
-		if (!chan->e.ReqCh) 
-			chan->e.D3Id = 0;
-		else
-			chan->e.B2Id = 0;
-		spin_unlock_irqrestore(&eicon_lock, flags);
-		eicon_log(ccard, 16, "idi_ack: Ch%d: Removed : Id=%x Ch=%d (%s)\n", chan->No,
-			ack->RcId, ack->RcCh, (chan->e.ReqCh)? "Net":"Sig");
-		return 1;
-	}
-
-	/* Signal layer */
-	if (!chan->e.ReqCh) {
-		eicon_log(ccard, 16, "idi_ack: Ch%d: RC OK Id=%x Ch=%d (ref:%d)\n", chan->No,
-			ack->RcId, ack->RcCh, ack->Reference);
-	} else {
-	/* Network layer */
-		switch(chan->e.Req & 0x0f) {
-			case N_CONNECT:
-				chan->e.IndCh = ack->RcCh;
-				eicon_log(ccard, 16, "idi_ack: Ch%d: RC OK Id=%x Ch=%d (ref:%d)\n", chan->No,
-					ack->RcId, ack->RcCh, ack->Reference);
-				break;
-			case N_MDATA:
-			case N_DATA:
-				tqueued = chan->queued;
-				twaitpq = chan->waitpq;
-				if ((chan->e.Req & 0x0f) == N_DATA) {
-					spin_lock_irqsave(&eicon_lock, flags);
-					chan->waitpq = 0;
-					if(chan->pqueued)
-						chan->pqueued--;
-					spin_unlock_irqrestore(&eicon_lock, flags);
-#ifdef CONFIG_ISDN_TTY_FAX
-					if (chan->l2prot == ISDN_PROTO_L2_FAX) {
-						if (((chan->queued - chan->waitq) < 1) &&
-						    (chan->fax2.Eop)) {
-							chan->fax2.Eop = 0;
-							if (chan->fax) {
-								cmd.driver = ccard->myid;
-								cmd.command = ISDN_STAT_FAXIND;
-								cmd.arg = chan->No;
-								chan->fax->r_code = ISDN_TTY_FAX_SENT;
-								ccard->interface.statcallb(&cmd);
-							}
-							else {
-								eicon_log(ccard, 1, "idi_ack: Sent with NULL fax struct, ERROR\n");
-							}
-						}
-					}
-#endif
-				}
-				spin_lock_irqsave(&eicon_lock, flags);
-				chan->queued -= chan->waitq;
-				if (chan->queued < 0) chan->queued = 0;
-				spin_unlock_irqrestore(&eicon_lock, flags);
-				if (((chan->e.Req & 0x0f) == N_DATA) && (tqueued)) {
-					cmd.driver = ccard->myid;
-					cmd.command = ISDN_STAT_BSENT;
-					cmd.arg = chan->No;
-					cmd.parm.length = twaitpq;
-					ccard->interface.statcallb(&cmd);
-				}
-				break;
-			default:
-				eicon_log(ccard, 16, "idi_ack: Ch%d: RC OK Id=%x Ch=%d (ref:%d)\n", chan->No,
-					ack->RcId, ack->RcCh, ack->Reference);
-		}
-	}
-	return 1;
-}
-
-void
-idi_handle_ack(eicon_card *ccard, struct sk_buff *skb)
-{
-	int j;
-	ulong flags;
-        eicon_RC *ack = (eicon_RC *)skb->data;
-	eicon_chan *chan;
-	isdn_ctrl cmd;
-	int dCh = -1;
-
-	if (!ccard) {
-		eicon_log(ccard, 1, "idi_err: Ch??: null card in handle_ack\n");
-		dev_kfree_skb(skb);
-		return;
-	}
-
-	spin_lock_irqsave(&eicon_lock, flags);
-	if ((chan = ccard->IdTable[ack->RcId]) != NULL)
-		dCh = chan->No;
-	spin_unlock_irqrestore(&eicon_lock, flags);
-
-	switch (ack->Rc) {
-		case OK_FC:
-		case N_FLOW_CONTROL:
-		case ASSIGN_RC:
-			eicon_log(ccard, 1, "idi_ack: Ch%d: unhandled RC 0x%x\n",
-				dCh, ack->Rc);
-			break;
-		case READY_INT:
-		case TIMER_INT:
-			/* we do nothing here */
-			break;
-
-		case OK:
-			if (!chan) {
-				eicon_log(ccard, 1, "idi_ack: Ch%d: OK on chan without Id\n", dCh);
-				break;
-			}
-			if (!idi_handle_ack_ok(ccard, chan, ack))
-				chan = NULL;
-			break;
-
-		case ASSIGN_OK:
-			if (chan) {
-				eicon_log(ccard, 1, "idi_ack: Ch%d: ASSIGN-OK on chan already assigned (%x,%x)\n",
-					chan->No, chan->e.D3Id, chan->e.B2Id);
-			}
-			spin_lock_irqsave(&eicon_lock, flags);
-			for(j = 0; j < ccard->nchannels + 1; j++) {
-				if ((ccard->bch[j].e.ref == ack->Reference) &&
-					(ccard->bch[j].e.Req == ASSIGN)) {
-					if (!ccard->bch[j].e.ReqCh) 
-						ccard->bch[j].e.D3Id  = ack->RcId;
-					else
-						ccard->bch[j].e.B2Id  = ack->RcId;
-					ccard->IdTable[ack->RcId] = &ccard->bch[j];
-					chan = &ccard->bch[j];
-					break;
-				}
-			}
-			spin_unlock_irqrestore(&eicon_lock, flags);
-			eicon_log(ccard, 16, "idi_ack: Ch%d: Id %x assigned (%s)\n", j, 
-				ack->RcId, (ccard->bch[j].e.ReqCh)? "Net":"Sig");
-			if (j > ccard->nchannels) {
-				eicon_log(ccard, 24, "idi_ack: Ch??: ref %d not found for Id %d\n", 
-					ack->Reference, ack->RcId);
-			}
-			break;
-
-		case OUT_OF_RESOURCES:
-		case UNKNOWN_COMMAND:
-		case WRONG_COMMAND:
-		case WRONG_ID:
-		case ADAPTER_DEAD:
-		case WRONG_CH:
-		case UNKNOWN_IE:
-		case WRONG_IE:
-		default:
-			if (!chan) {
-				eicon_log(ccard, 1, "idi_ack: Ch%d: Not OK !! on chan without Id\n", dCh);
-				break;
-			} else
-			switch (chan->e.Req) {
-				case 12:	/* Alert */
-					eicon_log(ccard, 2, "eicon_err: Ch%d: Alert Not OK : Rc=%d Id=%x Ch=%d\n",
-						dCh, ack->Rc, ack->RcId, ack->RcCh);
-					break;
-				default:
-					if (dCh != ccard->nchannels)
-						eicon_log(ccard, 1, "eicon_err: Ch%d: Ack Not OK !!: Rc=%d Id=%x Ch=%d Req=%d\n",
-							dCh, ack->Rc, ack->RcId, ack->RcCh, chan->e.Req);
-			}
-			if (dCh == ccard->nchannels) { /* Management */
-				chan->fsm_state = 2;
-				eicon_log(ccard, 8, "eicon_err: Ch%d: Ack Not OK !!: Rc=%d Id=%x Ch=%d Req=%d\n",
-					dCh, ack->Rc, ack->RcId, ack->RcCh, chan->e.Req);
-			} else if (dCh >= 0) {
-					/* any other channel */
-					/* card reports error: we hangup */
-				idi_hangup(ccard, chan);
-				cmd.driver = ccard->myid;
-				cmd.command = ISDN_STAT_DHUP;
-				cmd.arg = chan->No;
-				ccard->interface.statcallb(&cmd);
-			}
-	}
-	spin_lock_irqsave(&eicon_lock, flags);
-	if (chan) {
-		chan->e.ref = 0;
-		chan->e.busy = 0;
-	}
-	spin_unlock_irqrestore(&eicon_lock, flags);
-	dev_kfree_skb(skb);
-	eicon_schedule_tx(ccard);
-}
-
-int
-idi_send_data(eicon_card *card, eicon_chan *chan, int ack, struct sk_buff *skb, int que, int chk)
-{
-        struct sk_buff *xmit_skb;
-        struct sk_buff *skb2;
-        eicon_REQ *reqbuf;
-        eicon_chan_ptr *chan2;
-        int len, plen = 0, offset = 0;
-	unsigned long flags;
-
-	if ((!card) || (!chan)) {
-		eicon_log(card, 1, "idi_err: Ch??: null card/chan in send_data\n");
-		return -1;
-	}
-
-        if (chan->fsm_state != EICON_STATE_ACTIVE) {
-		eicon_log(card, 1, "idi_snd: Ch%d: send bytes on state %d !\n", chan->No, chan->fsm_state);
-                return -ENODEV;
-	}
-
-        len = skb->len;
-	if (len > EICON_MAX_QUEUE)	/* too much for the shared memory */
-		return -1;
-        if (!len)
-                return 0;
-
-	if ((chk) && (chan->pqueued > 1))
-		return 0;
-
-	eicon_log(card, 128, "idi_snd: Ch%d: %d bytes (Pqueue=%d)\n",
-		chan->No, len, chan->pqueued);
-
-	spin_lock_irqsave(&eicon_lock, flags);
-	while(offset < len) {
-
-		plen = ((len - offset) > 270) ? 270 : len - offset;
-
-	        xmit_skb = alloc_skb(plen + sizeof(eicon_REQ), GFP_ATOMIC);
-        	skb2 = alloc_skb(sizeof(eicon_chan_ptr), GFP_ATOMIC);
-
-	        if ((!xmit_skb) || (!skb2)) {
-			spin_unlock_irqrestore(&eicon_lock, flags);
-        	        eicon_log(card, 1, "idi_err: Ch%d: alloc_skb failed in send_data()\n", chan->No);
-			if (xmit_skb) 
-				dev_kfree_skb(xmit_skb);
-			if (skb2) 
-				dev_kfree_skb(skb2);
-                	return -ENOMEM;
-	        }
-
-	        chan2 = (eicon_chan_ptr *)skb_put(skb2, sizeof(eicon_chan_ptr));
-        	chan2->ptr = chan;
-
-	        reqbuf = (eicon_REQ *)skb_put(xmit_skb, plen + sizeof(eicon_REQ));
-		if ((len - offset) > 270) { 
-		        reqbuf->Req = N_MDATA;
-		} else {
-		        reqbuf->Req = N_DATA;
-			/* if (ack) reqbuf->Req |= N_D_BIT; */
-		}	
-        	reqbuf->ReqCh = chan->e.IndCh;
-	        reqbuf->ReqId = 1;
-		memcpy(&reqbuf->XBuffer.P, skb->data + offset, plen);
-		reqbuf->XBuffer.length = plen;
-		reqbuf->Reference = 1; /* Net Entity */
-
-		skb_queue_tail(&chan->e.X, xmit_skb);
-		skb_queue_tail(&card->sndq, skb2); 
-
-		offset += plen;
-	}
-	if (que) {
-		chan->queued += len;
-		chan->pqueued++;
-	}
-	spin_unlock_irqrestore(&eicon_lock, flags);
-	eicon_schedule_tx(card);
-        dev_kfree_skb(skb);
-        return len;
-}
-
-
-int
-eicon_idi_manage_assign(eicon_card *card)
-{
-        struct sk_buff *skb;
-        struct sk_buff *skb2;
-        eicon_REQ  *reqbuf;
-        eicon_chan     *chan;
-        eicon_chan_ptr *chan2;
-
-        chan = &(card->bch[card->nchannels]);
-
-        skb = alloc_skb(270 + sizeof(eicon_REQ), GFP_ATOMIC);
-        skb2 = alloc_skb(sizeof(eicon_chan_ptr), GFP_ATOMIC);
-
-        if ((!skb) || (!skb2)) {
-		eicon_log(card, 1, "idi_err: alloc_skb failed in manage_assign()\n");
-		if (skb) 
-			dev_kfree_skb(skb);
-		if (skb2) 
-			dev_kfree_skb(skb2);
-                return -ENOMEM;
-        }
-
-        chan2 = (eicon_chan_ptr *)skb_put(skb2, sizeof(eicon_chan_ptr));
-        chan2->ptr = chan;
-
-        reqbuf = (eicon_REQ *)skb_put(skb, 270 + sizeof(eicon_REQ));
-
-        reqbuf->XBuffer.P[0] = 0;
-        reqbuf->Req = ASSIGN;
-        reqbuf->ReqCh = 0;
-        reqbuf->ReqId = MAN_ID;
-        reqbuf->XBuffer.length = 1;
-        reqbuf->Reference = 2; /* Man Entity */
-
-        skb_queue_tail(&chan->e.X, skb);
-        skb_queue_tail(&card->sndq, skb2);
-        eicon_schedule_tx(card);
-        return(0);
-}
-
-
-int
-eicon_idi_manage_remove(eicon_card *card)
-{
-        struct sk_buff *skb;
-        struct sk_buff *skb2;
-        eicon_REQ  *reqbuf;
-        eicon_chan     *chan;
-        eicon_chan_ptr *chan2;
-
-        chan = &(card->bch[card->nchannels]);
-
-        skb = alloc_skb(270 + sizeof(eicon_REQ), GFP_ATOMIC);
-        skb2 = alloc_skb(sizeof(eicon_chan_ptr), GFP_ATOMIC);
-
-        if ((!skb) || (!skb2)) {
-               	eicon_log(card, 1, "idi_err: alloc_skb failed in manage_remove()\n");
-		if (skb) 
-			dev_kfree_skb(skb);
-		if (skb2) 
-			dev_kfree_skb(skb2);
-                return -ENOMEM;
-        }
-
-        chan2 = (eicon_chan_ptr *)skb_put(skb2, sizeof(eicon_chan_ptr));
-        chan2->ptr = chan;
-
-        reqbuf = (eicon_REQ *)skb_put(skb, 270 + sizeof(eicon_REQ));
-
-        reqbuf->Req = REMOVE;
-        reqbuf->ReqCh = 0;
-        reqbuf->ReqId = 1;
-        reqbuf->XBuffer.length = 0;
-        reqbuf->Reference = 2; /* Man Entity */
-
-        skb_queue_tail(&chan->e.X, skb);
-        skb_queue_tail(&card->sndq, skb2);
-        eicon_schedule_tx(card);
-        return(0);
-}
-
-
-int
-eicon_idi_manage(eicon_card *card, eicon_manifbuf *mb)
-{
-	int l = 0;
-	int ret = 0;
-	unsigned long timeout;
-	int i;
-        struct sk_buff *skb;
-        struct sk_buff *skb2;
-        eicon_REQ  *reqbuf;
-        eicon_chan     *chan;
-        eicon_chan_ptr *chan2;
-
-        chan = &(card->bch[card->nchannels]);
-
-	if (!(chan->e.D3Id)) {
-		chan->e.D3Id = 1;
-		while((skb2 = skb_dequeue(&chan->e.X)))
-			dev_kfree_skb(skb2);
-		chan->e.busy = 0;
- 
-		if ((ret = eicon_idi_manage_assign(card))) {
-			chan->e.D3Id = 0;
-			return(ret); 
-		}
-
-	        timeout = jiffies + HZ / 2;
-        	while (time_before(jiffies, timeout)) {
-	                if (chan->e.B2Id) break;
-        	        SLEEP(10);
-	        }
-	        if (!chan->e.B2Id) {
-			chan->e.D3Id = 0;
-			return -EIO;
-		}
-	}
-
-	chan->fsm_state = 0;
-
-	if (!(manbuf = kmalloc(sizeof(eicon_manifbuf), GFP_KERNEL))) {
-               	eicon_log(card, 1, "idi_err: alloc_manifbuf failed\n");
-		return -ENOMEM;
-	}
-	if (copy_from_user(manbuf, mb, sizeof(eicon_manifbuf))) {
-		kfree(manbuf);
-		return -EFAULT;
-	}
-
-        skb = alloc_skb(270 + sizeof(eicon_REQ), GFP_ATOMIC);
-        skb2 = alloc_skb(sizeof(eicon_chan_ptr), GFP_ATOMIC);
-
-        if ((!skb) || (!skb2)) {
-               	eicon_log(card, 1, "idi_err_manif: alloc_skb failed in manage()\n");
-		if (skb) 
-			dev_kfree_skb(skb);
-		if (skb2) 
-			dev_kfree_skb(skb2);
-		kfree(manbuf);
-                return -ENOMEM;
-        }
-
-        chan2 = (eicon_chan_ptr *)skb_put(skb2, sizeof(eicon_chan_ptr));
-        chan2->ptr = chan;
-
-        reqbuf = (eicon_REQ *)skb_put(skb, 270 + sizeof(eicon_REQ));
-
-        reqbuf->XBuffer.P[l++] = ESC;
-        reqbuf->XBuffer.P[l++] = 6;
-        reqbuf->XBuffer.P[l++] = 0x80;
-	for (i = 0; i < manbuf->length[0]; i++)
-	        reqbuf->XBuffer.P[l++] = manbuf->data[i];
-        reqbuf->XBuffer.P[1] = manbuf->length[0] + 1;
-
-        reqbuf->XBuffer.P[l++] = 0;
-        reqbuf->Req = (manbuf->count) ? manbuf->count : MAN_READ;
-        reqbuf->ReqCh = 0;
-        reqbuf->ReqId = 1;
-        reqbuf->XBuffer.length = l;
-        reqbuf->Reference = 2; /* Man Entity */
-
-        skb_queue_tail(&chan->e.X, skb);
-        skb_queue_tail(&card->sndq, skb2);
-
-	manbuf->count = 0;
-	manbuf->pos = 0;
-
-        eicon_schedule_tx(card);
-
-        timeout = jiffies + HZ / 2;
-        while (time_before(jiffies, timeout)) {
-                if (chan->fsm_state) break;
-                SLEEP(10);
-        }
-        if ((!chan->fsm_state) || (chan->fsm_state == 2)) {
-		kfree(manbuf);
-		return -EIO;
-	}
-	if (copy_to_user(mb, manbuf, sizeof(eicon_manifbuf))) {
-		kfree(manbuf);
-		return -EFAULT;
-	}
-
-	kfree(manbuf);
-  return(0);
-}
diff -puN -L drivers/isdn/eicon/eicon_idi.h drivers/isdn/eicon/eicon_idi.h~linus /dev/null
--- 25/drivers/isdn/eicon/eicon_idi.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,119 +0,0 @@
-/* $Id: eicon_idi.h,v 1.1.4.1.2.2 2002/10/01 11:29:13 armin Exp $
- *
- * ISDN lowlevel-module for the Eicon active cards.
- * IDI-Interface
- *
- * Copyright 1998-2000  by Armin Schindler (mac@melware.de)
- * Copyright 1999,2000  Cytronics & Melware (info@melware.de)
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#ifndef E_IDI_H
-#define E_IDI_H
-
-#include <linux/config.h>
-
-#undef N_DATA
-#undef ID_MASK
-
-#include "pc.h"
-
-#define AOC_IND  26		/* Advice of Charge                         */
-#define PI  0x1e                /* Progress Indicator               */
-#define NI  0x27                /* Notification Indicator           */
-
-#define CALL_HOLD	0x22
-#define CALL_HOLD_ACK	0x24
-
-/* defines for statectrl */
-#define WAITING_FOR_HANGUP	0x01
-#define HAVE_CONN_REQ		0x02
-#define IN_HOLD			0x04
-
-typedef struct {
-	char cpn[32];
-	char oad[32];
-	char dsa[32];
-	char osa[32];
-	__u8 plan;
-	__u8 screen;
-	__u8 sin[4];
-	__u8 chi[4];
-	__u8 e_chi[4];
-	__u8 bc[12];
-	__u8 e_bc[12];
- 	__u8 llc[18];
-	__u8 hlc[5];
-	__u8 cau[4];
-	__u8 e_cau[2];
-	__u8 e_mt;
-	__u8 dt[6];
-	char display[83];
-	char keypad[35];
-	char rdn[32];
-} idi_ind_message;
-
-typedef struct { 
-  __u16 next            __attribute__ ((packed));
-  __u8  Req             __attribute__ ((packed));
-  __u8  ReqId           __attribute__ ((packed));
-  __u8  ReqCh           __attribute__ ((packed));
-  __u8  Reserved1       __attribute__ ((packed));
-  __u16 Reference       __attribute__ ((packed));
-  __u8  Reserved[8]     __attribute__ ((packed));
-  eicon_PBUFFER XBuffer; 
-} eicon_REQ;
-
-typedef struct {
-  __u16 next            __attribute__ ((packed));
-  __u8  Rc              __attribute__ ((packed));
-  __u8  RcId            __attribute__ ((packed));
-  __u8  RcCh            __attribute__ ((packed));
-  __u8  Reserved1       __attribute__ ((packed));
-  __u16 Reference       __attribute__ ((packed));
-  __u8  Reserved2[8]    __attribute__ ((packed));
-} eicon_RC;
-
-typedef struct {
-  __u16 next            __attribute__ ((packed));
-  __u8  Ind             __attribute__ ((packed));
-  __u8  IndId           __attribute__ ((packed));
-  __u8  IndCh           __attribute__ ((packed));
-  __u8  MInd            __attribute__ ((packed));
-  __u16 MLength         __attribute__ ((packed));
-  __u16 Reference       __attribute__ ((packed));
-  __u8  RNR             __attribute__ ((packed));
-  __u8  Reserved        __attribute__ ((packed));
-  __u32 Ack             __attribute__ ((packed));
-  eicon_PBUFFER RBuffer;
-} eicon_IND;
-
-typedef struct {
-	__u8		*Data;
-	unsigned int	Size;
-	unsigned int	Len;
-	__u8		*Next;
-} eicon_OBJBUFFER;
-
-extern int idi_do_req(eicon_card *card, eicon_chan *chan, int cmd, int layer);
-extern int idi_hangup(eicon_card *card, eicon_chan *chan);
-extern int idi_connect_res(eicon_card *card, eicon_chan *chan);
-extern int eicon_idi_listen_req(eicon_card *card, eicon_chan *chan);
-extern int idi_connect_req(eicon_card *card, eicon_chan *chan, char *phone,
-	                    char *eazmsn, int si1, int si2);
-
-extern void idi_handle_ack(eicon_card *card, struct sk_buff *skb);
-extern void idi_handle_ind(eicon_card *card, struct sk_buff *skb);
-extern int eicon_idi_manage(eicon_card *card, eicon_manifbuf *mb);
-extern int idi_send_data(eicon_card *card, eicon_chan *chan, int ack, struct sk_buff *skb, int que, int chk);
-extern void idi_audio_cmd(eicon_card *ccard, eicon_chan *chan, int cmd, u_char *value);
-extern int capipmsg(eicon_card *card, eicon_chan *chan, capi_msg *cm);
-#ifdef CONFIG_ISDN_TTY_FAX
-extern void idi_fax_cmd(eicon_card *card, eicon_chan *chan);
-extern int idi_faxdata_send(eicon_card *ccard, eicon_chan *chan, struct sk_buff *skb);
-#endif
-
-#endif
diff -puN -L drivers/isdn/eicon/eicon_io.c drivers/isdn/eicon/eicon_io.c~linus /dev/null
--- 25/drivers/isdn/eicon/eicon_io.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,749 +0,0 @@
-/* $Id: eicon_io.c,v 1.1.4.1.2.2 2002/10/01 11:29:13 armin Exp $
- *
- * ISDN low-level module for Eicon active ISDN-Cards.
- * Code for communicating with hardware.
- *
- * Copyright 1999,2000  by Armin Schindler (mac@melware.de)
- * Copyright 1999,2000  Cytronics & Melware (info@melware.de)
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- * Thanks to	Eicon Networks for 
- *		documents, informations and hardware. 
- *
- */
-
-#include <linux/config.h>
-#include "eicon.h"
-#include "uxio.h"
-
-void
-eicon_io_rcv_dispatch(eicon_card *ccard) {
-	ulong flags;
-        struct sk_buff *skb, *skb2, *skb_new;
-        eicon_IND *ind, *ind2, *ind_new;
-        eicon_chan *chan;
-
-        if (!ccard) {
-	        eicon_log(ccard, 1, "eicon_err: NULL card in rcv_dispatch !\n");
-                return;
-        }
-
-	while((skb = skb_dequeue(&ccard->rcvq))) {
-        	ind = (eicon_IND *)skb->data;
-
-		spin_lock_irqsave(&eicon_lock, flags);
-        	if ((chan = ccard->IdTable[ind->IndId]) == NULL) {
-			spin_unlock_irqrestore(&eicon_lock, flags);
-			if (DebugVar & 1) {
-				switch(ind->Ind) {
-					case N_DISC_ACK: 
-						/* doesn't matter if this happens */ 
-						break;
-					default: 
-						eicon_log(ccard, 1, "idi: Indication for unknown channel Ind=%d Id=%x\n", ind->Ind, ind->IndId);
-						eicon_log(ccard, 1, "idi_hdl: Ch??: Ind=%d Id=%x Ch=%d MInd=%d MLen=%d Len=%d\n",
-							ind->Ind,ind->IndId,ind->IndCh,ind->MInd,ind->MLength,ind->RBuffer.length);
-				}
-			}
-	                dev_kfree_skb(skb);
-	                continue;
-	        }
-		spin_unlock_irqrestore(&eicon_lock, flags);
-
-		if (chan->e.complete) { /* check for rec-buffer chaining */
-			if (ind->MLength == ind->RBuffer.length) {
-				chan->e.complete = 1;
-				idi_handle_ind(ccard, skb);
-				continue;
-			}
-			else {
-				chan->e.complete = 0;
-				ind->Ind = ind->MInd;
-				skb_queue_tail(&chan->e.R, skb);
-				continue;
-			}
-		}
-		else {
-			if (!(skb2 = skb_dequeue(&chan->e.R))) {
-				chan->e.complete = 1;
-                		eicon_log(ccard, 1, "eicon: buffer incomplete, but 0 in queue\n");
-	                	dev_kfree_skb(skb);
-				continue;	
-			}
-	        	ind2 = (eicon_IND *)skb2->data;
-			skb_new = alloc_skb(((sizeof(eicon_IND)-1)+ind->RBuffer.length+ind2->RBuffer.length),
-					GFP_ATOMIC);
-			if (!skb_new) {
-                		eicon_log(ccard, 1, "eicon_io: skb_alloc failed in rcv_dispatch()\n");
-	                	dev_kfree_skb(skb);
-	                	dev_kfree_skb(skb2);
-				continue;	
-			}
-			ind_new = (eicon_IND *)skb_put(skb_new,
-					((sizeof(eicon_IND)-1)+ind->RBuffer.length+ind2->RBuffer.length));
-			ind_new->Ind = ind2->Ind;
-			ind_new->IndId = ind2->IndId;
-			ind_new->IndCh = ind2->IndCh;
-			ind_new->MInd = ind2->MInd;
-			ind_new->MLength = ind2->MLength;
-			ind_new->RBuffer.length = ind2->RBuffer.length + ind->RBuffer.length;
-			memcpy(&ind_new->RBuffer.P, &ind2->RBuffer.P, ind2->RBuffer.length);
-			memcpy((&ind_new->RBuffer.P)+ind2->RBuffer.length, &ind->RBuffer.P, ind->RBuffer.length);
-                	dev_kfree_skb(skb);
-                	dev_kfree_skb(skb2);
-			if (ind->MLength == ind->RBuffer.length) {
-				chan->e.complete = 2;
-				idi_handle_ind(ccard, skb_new);
-				continue;
-			}
-			else {
-				chan->e.complete = 0;
-				skb_queue_tail(&chan->e.R, skb_new);
-				continue;
-			}
-		}
-	}
-}
-
-void
-eicon_io_ack_dispatch(eicon_card *ccard) {
-        struct sk_buff *skb;
-
-        if (!ccard) {
-		eicon_log(ccard, 1, "eicon_err: NULL card in ack_dispatch!\n");
-                return;
-        }
-	while((skb = skb_dequeue(&ccard->rackq))) {
-		idi_handle_ack(ccard, skb);
-	}
-}
-
-
-/*
- *  IO-Functions for ISA cards
- */
-
-u8 ram_inb(eicon_card *card, void *adr) {
-        u32 addr = (u32) adr;
-	
-	return(readb(addr));
-}
-
-u16 ram_inw(eicon_card *card, void *adr) {
-        u32 addr = (u32) adr;
-
-	return(readw(addr));
-}
-
-void ram_outb(eicon_card *card, void *adr, u8 data) {
-        u32 addr = (u32) adr;
-
-	writeb(data, addr);
-}
-
-void ram_outw(eicon_card *card, void *adr , u16 data) {
-        u32 addr = (u32) adr;
-
-	writew(data, addr);
-}
-
-void ram_copyfromcard(eicon_card *card, void *adrto, void *adr, int len) {
-	memcpy_fromio(adrto, adr, len);
-}
-
-void ram_copytocard(eicon_card *card, void *adrto, void *adr, int len) {
-	memcpy_toio(adrto, adr, len);
-}
-
-
-#ifdef CONFIG_ISDN_DRV_EICON_PCI
-/*
- *  IDI-Callback function
- */
-void
-eicon_idi_callback(ENTITY *de)
-{
-	eicon_card *ccard = (eicon_card *)de->R;
-	struct sk_buff *skb;
-	eicon_RC *ack;
-	eicon_IND *ind;
-	int len = 0;
-
-	if (de->complete == 255) {
-		/* Return Code */
-		skb = alloc_skb(sizeof(eicon_RC), GFP_ATOMIC);
-		if (!skb) {
-			eicon_log(ccard, 1, "eicon_io: skb_alloc failed in _idi_callback()\n");
-		} else {
-			ack = (eicon_RC *)skb_put(skb, sizeof(eicon_RC));
-			ack->Rc = de->Rc;
-			if (de->Rc == ASSIGN_OK) {
-				ack->RcId = de->Id;
-				de->user[1] = de->Id;
-			} else {
-				ack->RcId = de->user[1];
-			}
-			ack->RcCh = de->RcCh;
-			ack->Reference = de->user[0];
-			skb_queue_tail(&ccard->rackq, skb);
-			eicon_schedule_ack(ccard);
-			eicon_log(ccard, 128, "idi_cbk: Ch%d: Rc=%x Id=%x RLen=%x compl=%x\n",
-				de->user[0], de->Rc, ack->RcId, de->RLength, de->complete);
-		}
-	} else {
-		/* Indication */
-		if (de->complete) {
-			len = de->RLength;
-		} else {
-			len = 270;
-			if (de->RLength <= 270)
-				eicon_log(ccard, 1, "eicon_cbk: ind not complete but <= 270\n");
-		}
-		skb = alloc_skb((sizeof(eicon_IND) + len - 1), GFP_ATOMIC);
-		if (!skb) {
-			eicon_log(ccard, 1, "eicon_io: skb_alloc failed in _idi_callback()\n");
-		} else {
-			ind = (eicon_IND *)skb_put(skb, (sizeof(eicon_IND) + len - 1));
-			ind->Ind = de->Ind;
-			ind->IndId = de->user[1];
-			ind->IndCh = de->IndCh;
-			ind->MInd  = de->Ind;
-			ind->RBuffer.length = len;
-			ind->MLength = de->RLength;
-			memcpy(&ind->RBuffer.P, &de->RBuffer->P, len);
-			skb_queue_tail(&ccard->rcvq, skb);
-			eicon_schedule_rx(ccard);
-			eicon_log(ccard, 128, "idi_cbk: Ch%d: Ind=%x Id=%x RLen=%x compl=%x\n",
-				de->user[0], de->Ind, ind->IndId, de->RLength, de->complete);
-		}
-	}
-
-	de->RNum = 0;
-	de->RNR = 0;
-	de->Rc = 0;
-	de->Ind = 0;
-}
-#endif /* CONFIG_ISDN_DRV_EICON_PCI */
-
-/*
- *  Transmit-Function
- */
-void
-eicon_io_transmit(eicon_card *ccard) {
-        eicon_isa_card *isa_card;
-        struct sk_buff *skb;
-        struct sk_buff *skb2;
-        unsigned long flags;
-	eicon_pr_ram  *prram = 0;
-	eicon_isa_com	*com = 0;
-	eicon_REQ *ReqOut = 0;
-	eicon_REQ *reqbuf = 0;
-	eicon_chan *chan;
-	eicon_chan_ptr *chan2;
-	int ReqCount;
-	int scom = 0;
-	int tmp = 0;
-	int tmpid = 0;
-	int quloop = 1;
-	int dlev = 0;
-	ENTITY *ep = 0;
-
-	isa_card = &ccard->hwif.isa;
-
-        if (!ccard) {
-               	eicon_log(ccard, 1, "eicon_transmit: NULL card!\n");
-                return;
-        }
-
-	switch(ccard->type) {
-#ifdef CONFIG_ISDN_DRV_EICON_ISA
-		case EICON_CTYPE_S:
-		case EICON_CTYPE_SX:
-		case EICON_CTYPE_SCOM:
-		case EICON_CTYPE_QUADRO:
-			scom = 1;
-			com = (eicon_isa_com *)isa_card->shmem;
-			break;
-		case EICON_CTYPE_S2M:
-			scom = 0;
-			prram = (eicon_pr_ram *)isa_card->shmem;
-			break;
-#endif
-#ifdef CONFIG_ISDN_DRV_EICON_PCI
-		case EICON_CTYPE_MAESTRAP:
-			scom = 2;
-			break;
-		case EICON_CTYPE_MAESTRAQ:
-			scom = 2;
-			break;
-		case EICON_CTYPE_MAESTRA:
-			scom = 2;
-			break;
-#endif
-		default:
-                	eicon_log(ccard, 1, "eicon_transmit: unsupported card-type!\n");
-			return;
-	}
-
-	ReqCount = 0;
-	if (!(skb2 = skb_dequeue(&ccard->sndq)))
-		quloop = 0; 
-	while(quloop) { 
-		spin_lock_irqsave(&eicon_lock, flags);
-		switch (scom) {
-		  case 1:
-			if ((ram_inb(ccard, &com->Req)) || (ccard->ReadyInt)) {
-				if (!ccard->ReadyInt) {
-					tmp = ram_inb(ccard, &com->ReadyInt) + 1;
-					ram_outb(ccard, &com->ReadyInt, tmp);
-					ccard->ReadyInt++;
-				}
-				spin_unlock_irqrestore(&eicon_lock, flags);
-                	        skb_queue_head(&ccard->sndq, skb2);
-       	                	eicon_log(ccard, 32, "eicon: transmit: Card not ready\n");
-	                        return;
-			}
-			break;
-		  case 0:
-	                if (!(ram_inb(ccard, &prram->ReqOutput) - ram_inb(ccard, &prram->ReqInput))) {
-				spin_unlock_irqrestore(&eicon_lock, flags);
-                	        skb_queue_head(&ccard->sndq, skb2);
-       	                	eicon_log(ccard, 32, "eicon: transmit: Card not ready\n");
-	                        return;
-        	        }
-			break;
-		}
-		spin_unlock_irqrestore(&eicon_lock, flags);
-
-		chan2 = (eicon_chan_ptr *)skb2->data;
-		chan = chan2->ptr;
-		if (!chan->e.busy) {
-		 if((skb = skb_dequeue(&chan->e.X))) { 
-
-		  reqbuf = (eicon_REQ *)skb->data;
-		  if ((reqbuf->Reference) && (chan->e.B2Id == 0) && (reqbuf->ReqId & 0x1f)) {
-			eicon_log(ccard, 16, "eicon: transmit: error Id=0 on %d (Net)\n", chan->No); 
-		  } else {
-			spin_lock_irqsave(&eicon_lock, flags);
-
-			switch (scom) {
-			  case 1:
-				ram_outw(ccard, &com->XBuffer.length, reqbuf->XBuffer.length);
-				ram_copytocard(ccard, &com->XBuffer.P, &reqbuf->XBuffer.P, reqbuf->XBuffer.length);
-				ram_outb(ccard, &com->ReqCh, reqbuf->ReqCh);
-				break;	
-			  case 0:
-				/* get address of next available request buffer */
-				ReqOut = (eicon_REQ *)&prram->B[ram_inw(ccard, &prram->NextReq)];
-				ram_outw(ccard, &ReqOut->XBuffer.length, reqbuf->XBuffer.length);
-				ram_copytocard(ccard, &ReqOut->XBuffer.P, &reqbuf->XBuffer.P, reqbuf->XBuffer.length);
-				ram_outb(ccard, &ReqOut->ReqCh, reqbuf->ReqCh);
-				ram_outb(ccard, &ReqOut->Req, reqbuf->Req); 
-				break;
-			}
-
-			dlev = 160;
-
-			if (reqbuf->ReqId & 0x1f) { /* if this is no ASSIGN */
-
-				if (!reqbuf->Reference) { /* Signal Layer */
-					switch (scom) {
-					  case 1:
-						ram_outb(ccard, &com->ReqId, chan->e.D3Id); 
-						break;
-					  case 0:
-						ram_outb(ccard, &ReqOut->ReqId, chan->e.D3Id); 
-						break;
-					  case 2:
-						ep = &chan->de;
-						break;
-					}
-					tmpid = chan->e.D3Id;
-					chan->e.ReqCh = 0; 
-				}
-				else {			/* Net Layer */
-					switch(scom) {
-					  case 1:
-						ram_outb(ccard, &com->ReqId, chan->e.B2Id); 
-						break;
-					  case 0:
-						ram_outb(ccard, &ReqOut->ReqId, chan->e.B2Id); 
-						break;
-					  case 2:
-						ep = &chan->be;
-						break;
-					}
-					tmpid = chan->e.B2Id;
-					chan->e.ReqCh = 1;
-					if (((reqbuf->Req & 0x0f) == 0x08) ||
-					   ((reqbuf->Req & 0x0f) == 0x01)) { /* Send Data */
-						chan->waitq = reqbuf->XBuffer.length;
-						chan->waitpq += reqbuf->XBuffer.length;
-						dlev = 128;
-					}
-				}
-
-			} else {	/* It is an ASSIGN */
-
-				switch(scom) {
-				  case 1:
-					ram_outb(ccard, &com->ReqId, reqbuf->ReqId); 
-					break;
-				  case 0:
-					ram_outb(ccard, &ReqOut->ReqId, reqbuf->ReqId); 
-					break;
-				  case 2:
-					if (!reqbuf->Reference) 
-						ep = &chan->de;
-					else
-						ep = &chan->be;
-					ep->Id = reqbuf->ReqId;
-					break;
-				}
-				tmpid = reqbuf->ReqId;
-
-				if (!reqbuf->Reference) 
-					chan->e.ReqCh = 0; 
-				 else
-					chan->e.ReqCh = 1; 
-			} 
-
-			switch(scom) {
-			  case 1:
-			 	chan->e.ref = ccard->ref_out++;
-				break;
-			  case 0:
-			 	chan->e.ref = ram_inw(ccard, &ReqOut->Reference);
-				break;
-			  case 2:
-				chan->e.ref = chan->No;
-				break;
-			}
-
-			chan->e.Req = reqbuf->Req;
-			ReqCount++; 
-
-			switch (scom) {
-			  case 1:
-				ram_outb(ccard, &com->Req, reqbuf->Req); 
-				break;
-			  case 0:
-				ram_outw(ccard, &prram->NextReq, ram_inw(ccard, &ReqOut->next)); 
-				break;
-			  case 2:
-#ifdef CONFIG_ISDN_DRV_EICON_PCI
-				if (!ep) break;
-				ep->callback = eicon_idi_callback;
-				ep->R = (BUFFERS *)ccard;
-				ep->user[0] = (word)chan->No;
-				ep->user[1] = (word)tmpid;
-				ep->XNum = 1;
-				ep->RNum = 0;
-				ep->RNR = 0;
-				ep->Rc = 0;
-				ep->Ind = 0;
-				ep->X->PLength = reqbuf->XBuffer.length;
-				memcpy(ep->X->P, &reqbuf->XBuffer.P, reqbuf->XBuffer.length);
-				ep->ReqCh = reqbuf->ReqCh;
-				ep->Req = reqbuf->Req;
-#endif
-				break;
-			}
-
-			chan->e.busy = 1;
-			spin_unlock_irqrestore(&eicon_lock, flags);
-	               	eicon_log(ccard, dlev, "eicon: Req=%d Id=%x Ch=%d Len=%d Ref=%d\n", 
-					reqbuf->Req, tmpid, 
-					reqbuf->ReqCh, reqbuf->XBuffer.length,
-					chan->e.ref); 
-#ifdef CONFIG_ISDN_DRV_EICON_PCI
-			if (scom == 2) {
-				if (ep) {
-					ccard->d->request(ep);
-					if (ep->Rc)
-						eicon_idi_callback(ep);
-				}
-			}
-#endif
-		  }
-		  dev_kfree_skb(skb);
-		 }
-		 dev_kfree_skb(skb2);
-		} 
-		else {
-			skb_queue_tail(&ccard->sackq, skb2);
-        	       	eicon_log(ccard, 128, "eicon: transmit: busy chan %d\n", chan->No); 
-		}
-
-		switch(scom) {
-			case 1:
-				quloop = 0;
-				break;
-			case 0:
-			case 2:
-				if (!(skb2 = skb_dequeue(&ccard->sndq)))
-					quloop = 0;
-				break;
-		}
-
-	}
-	if (!scom)
-		ram_outb(ccard, &prram->ReqInput, (__u8)(ram_inb(ccard, &prram->ReqInput) + ReqCount)); 
-
-	while((skb = skb_dequeue(&ccard->sackq))) { 
-		skb_queue_tail(&ccard->sndq, skb);
-	}
-}
-
-#ifdef CONFIG_ISDN_DRV_EICON_ISA
-/*
- * IRQ handler 
- */
-irqreturn_t
-eicon_irq(int irq, void *dev_id, struct pt_regs *regs) {
-	eicon_card *ccard = (eicon_card *)dev_id;
-        eicon_isa_card *isa_card;
-	eicon_pr_ram  *prram = 0;
-	eicon_isa_com	*com = 0;
-        eicon_RC *RcIn;
-        eicon_IND *IndIn;
-	struct sk_buff *skb;
-        int Count = 0;
-	int Rc = 0;
-	int Ind = 0;
-	unsigned char *irqprobe = 0;
-	int scom = 0;
-	int tmp = 0;
-	int dlev = 0;
-
-
-        if (!ccard) {
-                eicon_log(ccard, 1, "eicon_irq: spurious interrupt %d\n", irq);
-                return IRQ_NONE;
-        }
-
-	if (ccard->type == EICON_CTYPE_QUADRO) {
-		tmp = 4;
-		while(tmp) {
-			com = (eicon_isa_com *)ccard->hwif.isa.shmem;
-			if ((readb(ccard->hwif.isa.intack))) { /* quadro found */
-				break;
-			}
-			ccard = ccard->qnext;
-			tmp--;
-		}
-	}
-
-	isa_card = &ccard->hwif.isa;
-
-	switch(ccard->type) {
-		case EICON_CTYPE_S:
-		case EICON_CTYPE_SX:
-		case EICON_CTYPE_SCOM:
-		case EICON_CTYPE_QUADRO:
-			scom = 1;
-			com = (eicon_isa_com *)isa_card->shmem;
-			irqprobe = &isa_card->irqprobe;
-			break;
-		case EICON_CTYPE_S2M:
-			scom = 0;
-			prram = (eicon_pr_ram *)isa_card->shmem;
-			irqprobe = &isa_card->irqprobe;
-			break;
-		default:
-                	eicon_log(ccard, 1, "eicon_irq: unsupported card-type!\n");
-			return IRQ_NONE;
-	}
-
-	if (*irqprobe) {
-		switch(ccard->type) {
-			case EICON_CTYPE_S:
-			case EICON_CTYPE_SX:
-			case EICON_CTYPE_SCOM:
-			case EICON_CTYPE_QUADRO:
-				if (readb(isa_card->intack)) {
-        		               	writeb(0, &com->Rc);
-					writeb(0, isa_card->intack);
-				}
-				(*irqprobe)++;
-				break;
-			case EICON_CTYPE_S2M:
-				if (readb(isa_card->intack)) {
-        		               	writeb(0, &prram->RcOutput);
-					writeb(0, isa_card->intack);
-				}
-				(*irqprobe)++;
-				break;
-		}
-		return IRQ_HANDLED;
-	}
-
-	switch(ccard->type) {
-		case EICON_CTYPE_S:
-		case EICON_CTYPE_SX:
-		case EICON_CTYPE_SCOM:
-		case EICON_CTYPE_QUADRO:
-		case EICON_CTYPE_S2M:
-			if (!(readb(isa_card->intack))) { /* card did not interrupt */
-				eicon_log(ccard, 1, "eicon: IRQ: card reports no interrupt!\n");
-				return IRQ_NONE;
-			} 
-			break;
-	}
-
-    if (scom) {
-
-        /* if a return code is available ...  */
-	if ((tmp = ram_inb(ccard, &com->Rc))) {
-		eicon_RC *ack;
-		if (tmp == READY_INT) {
-                       	eicon_log(ccard, 64, "eicon: IRQ Rc=READY_INT\n");
-			if (ccard->ReadyInt) {
-				ccard->ReadyInt--;
-				ram_outb(ccard, &com->Rc, 0);
-				eicon_schedule_tx(ccard);
-			}
-		} else {
-			skb = alloc_skb(sizeof(eicon_RC), GFP_ATOMIC);
-			if (!skb) {
-                		eicon_log(ccard, 1, "eicon_io: skb_alloc failed in _irq()\n");
-			} else {
-				ack = (eicon_RC *)skb_put(skb, sizeof(eicon_RC));
-				ack->Rc = tmp;
-				ack->RcId = ram_inb(ccard, &com->RcId);
-				ack->RcCh = ram_inb(ccard, &com->RcCh);
-				ack->Reference = ccard->ref_in++;
-               	        	eicon_log(ccard, 128, "eicon: IRQ Rc=%d Id=%x Ch=%d Ref=%d\n",
-					tmp,ack->RcId,ack->RcCh,ack->Reference);
-				skb_queue_tail(&ccard->rackq, skb);
-				eicon_schedule_ack(ccard);
-			}
-			ram_outb(ccard, &com->Req, 0);
-			ram_outb(ccard, &com->Rc, 0);
-		}
-
-	} else {
-
-	        /* if an indication is available ...  */
-		if ((tmp = ram_inb(ccard, &com->Ind))) {
-			eicon_IND *ind;
-			int len = ram_inw(ccard, &com->RBuffer.length);
-			skb = alloc_skb((sizeof(eicon_IND) + len - 1), GFP_ATOMIC);
-			if (!skb) {
-                		eicon_log(ccard, 1, "eicon_io: skb_alloc failed in _irq()\n");
-			} else {
-				ind = (eicon_IND *)skb_put(skb, (sizeof(eicon_IND) + len - 1));
-				ind->Ind = tmp;
-				ind->IndId = ram_inb(ccard, &com->IndId);
-				ind->IndCh = ram_inb(ccard, &com->IndCh);
-				ind->MInd  = ram_inb(ccard, &com->MInd);
-				ind->MLength = ram_inw(ccard, &com->MLength);
-				ind->RBuffer.length = len;
-				if ((tmp == 1) || (tmp == 8))
-					dlev = 128;
-				else
-					dlev = 192;
-                       		eicon_log(ccard, dlev, "eicon: IRQ Ind=%d Id=%x Ch=%d MInd=%d MLen=%d Len=%d\n",
-					tmp,ind->IndId,ind->IndCh,ind->MInd,ind->MLength,len);
-				ram_copyfromcard(ccard, &ind->RBuffer.P, &com->RBuffer.P, len);
-				skb_queue_tail(&ccard->rcvq, skb);
-				eicon_schedule_rx(ccard);
-			}
-			ram_outb(ccard, &com->Ind, 0);
-		}
-	}
-
-    } else {
-
-        /* if return codes are available ...  */
-        if((Count = ram_inb(ccard, &prram->RcOutput))) {
-		eicon_RC *ack;
-                /* get the buffer address of the first return code */
-                RcIn = (eicon_RC *)&prram->B[ram_inw(ccard, &prram->NextRc)];
-                /* for all return codes do ...  */
-                while(Count--) {
-
-                        if((Rc=ram_inb(ccard, &RcIn->Rc))) {
-				skb = alloc_skb(sizeof(eicon_RC), GFP_ATOMIC);
-				if (!skb) {
-                			eicon_log(ccard, 1, "eicon_io: skb_alloc failed in _irq()\n");
-				} else {
-					ack = (eicon_RC *)skb_put(skb, sizeof(eicon_RC));
-					ack->Rc = Rc;
-					ack->RcId = ram_inb(ccard, &RcIn->RcId);
-					ack->RcCh = ram_inb(ccard, &RcIn->RcCh);
-					ack->Reference = ram_inw(ccard, &RcIn->Reference);
-        	                	eicon_log(ccard, 128, "eicon: IRQ Rc=%d Id=%x Ch=%d Ref=%d\n",
-						Rc,ack->RcId,ack->RcCh,ack->Reference);
-					skb_queue_tail(&ccard->rackq, skb);
-					eicon_schedule_ack(ccard);
-				}
-                       		ram_outb(ccard, &RcIn->Rc, 0);
-                        }
-                        /* get buffer address of next return code   */
-                        RcIn = (eicon_RC *)&prram->B[ram_inw(ccard, &RcIn->next)];
-                }
-                /* clear all return codes (no chaining!) */
-                ram_outb(ccard, &prram->RcOutput, 0);
-        }
-
-        /* if indications are available ... */
-        if((Count = ram_inb(ccard, &prram->IndOutput))) {
-		eicon_IND *ind;
-                /* get the buffer address of the first indication */
-                IndIn = (eicon_IND *)&prram->B[ram_inw(ccard, &prram->NextInd)];
-                /* for all indications do ... */
-                while(Count--) {
-			Ind = ram_inb(ccard, &IndIn->Ind);
-			if(Ind) {
-				int len = ram_inw(ccard, &IndIn->RBuffer.length);
-				skb = alloc_skb((sizeof(eicon_IND) + len - 1), GFP_ATOMIC);
-				if (!skb) {
-                			eicon_log(ccard, 1, "eicon_io: skb_alloc failed in _irq()\n");
-				} else {
-					ind = (eicon_IND *)skb_put(skb, (sizeof(eicon_IND) + len - 1));
-					ind->Ind = Ind;
-					ind->IndId = ram_inb(ccard, &IndIn->IndId);
-					ind->IndCh = ram_inb(ccard, &IndIn->IndCh);
-					ind->MInd  = ram_inb(ccard, &IndIn->MInd);
-					ind->MLength = ram_inw(ccard, &IndIn->MLength);
-					ind->RBuffer.length = len;
-					if ((Ind == 1) || (Ind == 8))
-						dlev = 128;
-					else
-						dlev = 192;
-                	        	eicon_log(ccard, dlev, "eicon: IRQ Ind=%d Id=%x Ch=%d MInd=%d MLen=%d Len=%d\n",
-						Ind,ind->IndId,ind->IndCh,ind->MInd,ind->MLength,len);
-	                                ram_copyfromcard(ccard, &ind->RBuffer.P, &IndIn->RBuffer.P, len);
-					skb_queue_tail(&ccard->rcvq, skb);
-					eicon_schedule_rx(ccard);
-				}
-				ram_outb(ccard, &IndIn->Ind, 0);
-                        }
-                        /* get buffer address of next indication  */
-                        IndIn = (eicon_IND *)&prram->B[ram_inw(ccard, &IndIn->next)];
-                }
-                ram_outb(ccard, &prram->IndOutput, 0);
-        }
-
-    } 
-
-	/* clear interrupt */
-	switch(ccard->type) {
-		case EICON_CTYPE_QUADRO:
-			writeb(0, isa_card->intack);
-			writeb(0, &com[0x401]);
-			break;
-		case EICON_CTYPE_S:
-		case EICON_CTYPE_SX:
-		case EICON_CTYPE_SCOM:
-		case EICON_CTYPE_S2M:
-			writeb(0, isa_card->intack);
-			break;
-	}
-
-  return IRQ_HANDLED;
-}
-#endif
diff -puN -L drivers/isdn/eicon/eicon_isa.c drivers/isdn/eicon/eicon_isa.c~linus /dev/null
--- 25/drivers/isdn/eicon/eicon_isa.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,454 +0,0 @@
-/* $Id: eicon_isa.c,v 1.1.4.1.2.3 2002/10/01 11:29:13 armin Exp $
- *
- * ISDN low-level module for Eicon active ISDN-Cards.
- * Hardware-specific code for old ISA cards.
- *
- * Copyright 1998      by Fritz Elfert (fritz@isdn4linux.de)
- * Copyright 1998-2000 by Armin Schindler (mac@melware.de)
- * Copyright 1999,2000 Cytronics & Melware (info@melware.de)
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#include <linux/config.h>
-#include "eicon.h"
-#include "eicon_isa.h"
-
-#define check_shmem   check_region
-#define release_shmem release_region
-#define request_shmem request_region
-
-char *eicon_isa_revision = "$Revision: 1.1.4.1.2.3 $";
-
-#undef EICON_MCA_DEBUG
-
-#ifdef CONFIG_ISDN_DRV_EICON_ISA
-
-/* Mask for detecting invalid IRQ parameter */
-static int eicon_isa_valid_irq[] = {
-	0x1c1c, /* 2, 3, 4, 10, 11, 12 (S)*/
-	0x1c1c, /* 2, 3, 4, 10, 11, 12 (SX) */
-	0x1cbc, /* 2, 3, 4, 5, 7, 10, 11, 12 (SCOM) */
-	0x1cbc, /* 2, 3, 4, 5, 6, 10, 11, 12 (Quadro) */
-	0x1cbc  /* 2, 3, 4, 5, 7, 10, 11, 12 (S2M) */
-};
-
-static void
-eicon_isa_release_shmem(eicon_isa_card *card) {
-	if (card->mvalid) {
-		iounmap(card->shmem);
-		release_mem_region(card->physmem, card->ramsize);
-	}
-	card->mvalid = 0;
-}
-
-static void
-eicon_isa_release_irq(eicon_isa_card *card) {
-	if (!card->master)
-		return;
-	if (card->ivalid)
-		free_irq(card->irq, card);
-	card->ivalid = 0;
-}
-
-void
-eicon_isa_release(eicon_isa_card *card) {
-	eicon_isa_release_irq(card);
-	eicon_isa_release_shmem(card);
-}
-
-void
-eicon_isa_printpar(eicon_isa_card *card) {
-	switch (card->type) {
-		case EICON_CTYPE_S:
-		case EICON_CTYPE_SX:
-		case EICON_CTYPE_SCOM:
-		case EICON_CTYPE_QUADRO:
-		case EICON_CTYPE_S2M:
-			printk(KERN_INFO "Eicon %s at 0x%lx, irq %d.\n",
-			       eicon_ctype_name[card->type],
-			       card->physmem,
-			       card->irq);
-	}
-}
-
-int
-eicon_isa_find_card(int Mem, int Irq, char * Id)
-{
-	int primary = 1;
-	unsigned long amem;
-
-	if (!strlen(Id))
-		return -1;
-
-	if (Mem == -1)
-		return -1;
-
-	/* Check for valid membase address */
-	if ((Mem < 0x0c0000) ||
-	    (Mem > 0x0fc000) ||
-	    (Mem & 0xfff)) { 
-		printk(KERN_WARNING "eicon_isa: invalid membase 0x%x for %s\n",
-			 Mem, Id);
-		return -1;
-	}
-	if (check_mem_region(Mem, RAMSIZE)) {
-		printk(KERN_WARNING "eicon_isa_boot: memory at 0x%x already in use.\n", Mem);
-		return -1;
-	}
-
-	amem = (unsigned long) ioremap(Mem, RAMSIZE);
-        writew(0x55aa, amem + 0x402);
-        if (readw(amem + 0x402) != 0x55aa) primary = 0;
-	writew(0, amem + 0x402);
-	if (readw(amem + 0x402) != 0) primary = 0;
-
-	printk(KERN_INFO "Eicon: Driver-ID: %s\n", Id);
-	if (primary) {
-		printk(KERN_INFO "Eicon: assuming pri card at 0x%x\n", Mem);
-		writeb(0, amem + 0x3ffe);
-		iounmap((unsigned char *)amem);
-		return EICON_CTYPE_ISAPRI;
-	} else {
-		printk(KERN_INFO "Eicon: assuming bri card at 0x%x\n", Mem);
-		writeb(0, amem + 0x400);
-		iounmap((unsigned char *)amem);
-		return EICON_CTYPE_ISABRI;
-	}
-	return -1;
-}
-
-int
-eicon_isa_bootload(eicon_isa_card *card, eicon_isa_codebuf *cb) {
-	int	tmp;
-	unsigned long     timeout;
-	eicon_isa_codebuf cbuf;
-	unsigned char     *code;
-	eicon_isa_boot    *boot;
-
-	if (copy_from_user(&cbuf, cb, sizeof(eicon_isa_codebuf)))
-		return -EFAULT;
-
-	/* Allocate code-buffer and copy code from userspace */
-	if (cbuf.bootstrap_len > 1024) {
-		printk(KERN_WARNING "eicon_isa_boot: Invalid startup-code size %ld\n",
-		       cbuf.bootstrap_len);
-		return -EINVAL;
-	}
-	if (!(code = kmalloc(cbuf.bootstrap_len, GFP_KERNEL))) {
-		printk(KERN_WARNING "eicon_isa_boot: Couldn't allocate code buffer\n");
-		return -ENOMEM;
-	}
-	if (copy_from_user(code, &cb->code, cbuf.bootstrap_len)) {
-		kfree(code);
-		return -EFAULT;
-	}
-
-	if (card->type == EICON_CTYPE_ISAPRI)
-		card->ramsize  = RAMSIZE_P;
-	else
-		card->ramsize  = RAMSIZE;
-
-	if (check_mem_region(card->physmem, card->ramsize)) {
-		printk(KERN_WARNING "eicon_isa_boot: memory at 0x%lx already in use.\n",
-			card->physmem);
-		kfree(code);
-		return -EBUSY;
-	}
-	request_mem_region(card->physmem, card->ramsize, "Eicon ISA ISDN");
-	card->shmem = (eicon_isa_shmem *) ioremap(card->physmem, card->ramsize);
-#ifdef EICON_MCA_DEBUG
-	printk(KERN_INFO "eicon_isa_boot: card->ramsize = %d.\n", card->ramsize);
-#endif
-	card->mvalid = 1;
-
-	switch(card->type) {
-		case EICON_CTYPE_S:
-		case EICON_CTYPE_SX:
-		case EICON_CTYPE_SCOM:
-		case EICON_CTYPE_QUADRO:
-		case EICON_CTYPE_ISABRI:
-			card->intack   = (__u8 *)card->shmem + INTACK;
-			card->startcpu = (__u8 *)card->shmem + STARTCPU;
-			card->stopcpu  = (__u8 *)card->shmem + STOPCPU;
-			break;
-		case EICON_CTYPE_S2M:
-		case EICON_CTYPE_ISAPRI:
-			card->intack   = (__u8 *)card->shmem + INTACK_P;
-			card->startcpu = (__u8 *)card->shmem + STARTCPU_P;
-			card->stopcpu  = (__u8 *)card->shmem + STOPCPU_P;
-			break;
-		default:
-			printk(KERN_WARNING "eicon_isa_boot: Invalid card type %d\n", card->type);
-			eicon_isa_release_shmem(card);
-			kfree(code);
-			return -EINVAL;
-	}
-
-	/* clear any pending irq's */
-	readb(card->intack);
-#ifdef CONFIG_MCA
-	if (MCA_bus) {
-		if (card->type == EICON_CTYPE_SCOM) {
-			outb_p(0,card->io+1);
-		}
-		else {
-			printk(KERN_WARNING "eicon_isa_boot: Card type not supported yet.\n");
-			eicon_isa_release_shmem(card);
-			return -EINVAL;
-		};
-
-#ifdef EICON_MCA_DEBUG
-	printk(KERN_INFO "eicon_isa_boot: card->io      = %x.\n", card->io);
-	printk(KERN_INFO "eicon_isa_boot: card->irq     = %d.\n", (int)card->irq);
-#endif
-	}
-#else
-	/* set reset-line active */
-	writeb(0, card->stopcpu); 
-#endif  /* CONFIG_MCA */
-	/* clear irq-requests */
-	writeb(0, card->intack);
-	readb(card->intack);
-
-	/* Copy code into card */
-	memcpy_toio(&card->shmem->c, code, cbuf.bootstrap_len);
-
-	/* Check for properly loaded code */
-	if (!check_signature((unsigned long)&card->shmem->c, code, 1020)) {
-		printk(KERN_WARNING "eicon_isa_boot: Could not load startup-code\n");
-		eicon_isa_release_shmem(card);
-		kfree(code);
-		return -EIO;
-	}
-	/* if 16k-ramsize, duplicate the reset-jump-code */
-	if (card->ramsize == RAMSIZE_P)
-		memcpy_toio((__u8 *)card->shmem + 0x3ff0, &code[0x3f0], 12);
-
-	kfree(code);
-	boot = &card->shmem->boot;
-
-	/* Delay 0.2 sec. */
-	SLEEP(HZ / 5);
-
-	/* Start CPU */
-	writeb(cbuf.boot_opt, &boot->ctrl);
-#ifdef CONFIG_MCA
-	if (MCA_bus) {
-		outb_p(0, card->io);
-	}
-#else 
-	writeb(0, card->startcpu); 
-#endif /* CONFIG_MCA */
-
-	/* Delay 0.2 sec. */
-	SLEEP(HZ / 5);
-
-	timeout = jiffies + (HZ * 22);
-	while (time_before(jiffies, timeout)) {
-		if (readb(&boot->ctrl) == 0)
-			break;
-		SLEEP(10);
-	}
-	if (readb(&boot->ctrl) != 0) {
-		printk(KERN_WARNING "eicon_isa_boot: CPU test failed.\n");
-#ifdef EICON_MCA_DEBUG
-		printk(KERN_INFO "eicon_isa_boot: &boot->ctrl = %d.\n",
-			readb(&boot->ctrl));
-#endif
-		eicon_isa_release_shmem(card);
-		return -EIO;
-	}
-
-	/* Check for memory-test errors */
-	if (readw(&boot->ebit)) {
-		printk(KERN_WARNING "eicon_isa_boot: memory test failed (bit 0x%04x at 0x%08x)\n",
-		       readw(&boot->ebit), readl(&boot->eloc));
-		eicon_isa_release_shmem(card);
-		return -EIO;
-	}
-
-        /* Check card type and memory size */
-        tmp = readb(&boot->card);
-	if ((tmp < 0) || (tmp > 4)) {
-		printk(KERN_WARNING "eicon_isa_boot: Type detect failed\n");
-		eicon_isa_release_shmem(card);
-		return -EIO;
-	}
-	card->type = tmp;
-	((eicon_card *)card->card)->type = tmp;
-
-        tmp = readb(&boot->msize);
-        if (tmp != 8 && tmp != 16 && tmp != 24 &&
-            tmp != 32 && tmp != 48 && tmp != 60) {
-                printk(KERN_WARNING "eicon_isa_boot: invalid memsize\n");
-		eicon_isa_release_shmem(card);
-                return -EIO;
-        }
-	printk(KERN_INFO "%s: startup-code loaded\n", eicon_ctype_name[card->type]); 
-	if ((card->type == EICON_CTYPE_QUADRO) && (card->master)) {
-		tmp = eicon_addcard(card->type, card->physmem, card->irq, 
-				((eicon_card *)card->card)->regname, 0);
-		printk(KERN_INFO "Eicon: %d adapters added\n", tmp);
-	}
-	return 0;
-}
-
-int
-eicon_isa_load(eicon_isa_card *card, eicon_isa_codebuf *cb) {
-	eicon_isa_boot    *boot;
-	int               tmp;
-	unsigned long     timeout;
-	int 		  j;
-	eicon_isa_codebuf cbuf;
-	unsigned char     *code;
-	unsigned char     *p;
-
-	if (copy_from_user(&cbuf, cb, sizeof(eicon_isa_codebuf)))
-		return -EFAULT;
-
-	if (!(code = kmalloc(cbuf.firmware_len, GFP_KERNEL))) {
-		printk(KERN_WARNING "eicon_isa_load: Couldn't allocate code buffer\n");
-		return -ENOMEM;
-	}
-
-	if (copy_from_user(code, &cb->code, cbuf.firmware_len)) {
-		kfree(code);
-		return -EFAULT;
-	}
-
-	boot = &card->shmem->boot;
-
-	if ((!card->ivalid) && card->master) {
-		card->irqprobe = 1;
-		/* Check for valid IRQ */
-		if ((card->irq < 0) || (card->irq > 15) || 
-		    (!((1 << card->irq) & eicon_isa_valid_irq[card->type & 0x0f]))) {
-			printk(KERN_WARNING "eicon_isa_load: invalid irq: %d\n", card->irq);
-			eicon_isa_release_shmem(card);
-			kfree(code);
-			return -EINVAL;
-		}
-		/* Register irq */
-		if (!request_irq(card->irq, &eicon_irq, 0, "Eicon ISA ISDN", card))
-			card->ivalid = 1;
-		else {
-			printk(KERN_WARNING "eicon_isa_load: irq %d already in use.\n",
-			       card->irq);
-			eicon_isa_release_shmem(card);
-			kfree(code);
-			return -EBUSY;
-		}
-	}
-
-        tmp = readb(&boot->msize);
-        if (tmp != 8 && tmp != 16 && tmp != 24 &&
-            tmp != 32 && tmp != 48 && tmp != 60) {
-                printk(KERN_WARNING "eicon_isa_load: invalid memsize\n");
-		eicon_isa_release_shmem(card);
-                return -EIO;
-        }
-
-	eicon_isa_printpar(card);
-
-	/* Download firmware */
-	printk(KERN_INFO "%s %dkB, loading firmware ...\n", 
-	       eicon_ctype_name[card->type],
-	       tmp * 16);
-	tmp = cbuf.firmware_len >> 8;
-	p = code;
-	while (tmp--) {
-		memcpy_toio(&boot->b, p, 256);
-		writeb(1, &boot->ctrl);
-		timeout = jiffies + HZ / 10;
-		while (time_before(jiffies, timeout)) {
-			if (readb(&boot->ctrl) == 0)
-				break;
-			SLEEP(2);
-		}
-		if (readb(&boot->ctrl)) {
-			printk(KERN_WARNING "eicon_isa_load: download timeout at 0x%x\n", p-code);
-			eicon_isa_release(card);
-			kfree(code);
-			return -EIO;
-		}
-		p += 256;
-	}
-	kfree(code);
-
-	/* Initialize firmware parameters */
-	memcpy_toio(&card->shmem->c[8], &cbuf.tei, 14);
-	memcpy_toio(&card->shmem->c[32], &cbuf.oad, 96);
-	memcpy_toio(&card->shmem->c[128], &cbuf.oad, 96);
-	
-	/* Start firmware, wait for signature */
-	writeb(2, &boot->ctrl);
-	timeout = jiffies + (5*HZ);
-	while (time_before(jiffies, timeout)) {
-		if (readw(&boot->signature) == 0x4447)
-			break;
-		SLEEP(2);
-	}
-	if (readw(&boot->signature) != 0x4447) {
-		printk(KERN_WARNING "eicon_isa_load: firmware selftest failed %04x\n",
-		       readw(&boot->signature));
-		eicon_isa_release(card);
-		return -EIO;
-	}
-
-	card->channels = readb(&card->shmem->c[0x3f6]);
-
-	/* clear irq-requests, reset irq-count */
-	readb(card->intack);
-	writeb(0, card->intack);
-
-	if (card->master) {
-		card->irqprobe = 1;
-		/* Trigger an interrupt and check if it is delivered */
-		tmp = readb(&card->shmem->com.ReadyInt);
-		tmp ++;
-		writeb(tmp, &card->shmem->com.ReadyInt);
-		timeout = jiffies + HZ / 5;
-		while (time_before(jiffies, timeout)) {
-			if (card->irqprobe > 1)
-				break;
-			SLEEP(2);
-		}
-		if (card->irqprobe == 1) {
-			printk(KERN_WARNING "eicon_isa_load: IRQ # %d test failed\n", card->irq);
-			eicon_isa_release(card);
-			return -EIO;
-		}
-	}
-#ifdef EICON_MCA_DEBUG
-	printk(KERN_INFO "eicon_isa_load: IRQ # %d test succeeded.\n", card->irq);
-#endif
-
-	writeb(card->irq, &card->shmem->com.Int);
-
-	/* initializing some variables */
-	((eicon_card *)card->card)->ReadyInt = 0;
-	((eicon_card *)card->card)->ref_in  = 1;
-	((eicon_card *)card->card)->ref_out = 1;
-	for(j=0; j<256; j++) ((eicon_card *)card->card)->IdTable[j] = NULL;
-	for(j=0; j< (card->channels + 1); j++) {
-		((eicon_card *)card->card)->bch[j].e.busy = 0;
-		((eicon_card *)card->card)->bch[j].e.D3Id = 0;
-		((eicon_card *)card->card)->bch[j].e.B2Id = 0;
-		((eicon_card *)card->card)->bch[j].e.ref = 0;
-		((eicon_card *)card->card)->bch[j].e.Req = 0;
-		((eicon_card *)card->card)->bch[j].e.complete = 1;
-		((eicon_card *)card->card)->bch[j].fsm_state = EICON_STATE_NULL;
-	}
-
-	printk(KERN_INFO "Eicon: Supported channels: %d\n", card->channels); 
-	printk(KERN_INFO "%s successfully started\n", eicon_ctype_name[card->type]);
-
-	/* Enable normal IRQ processing */
-	card->irqprobe = 0;
-	return 0;
-}
-
-#endif /* CONFIG_ISDN_DRV_EICON_ISA */
diff -puN -L drivers/isdn/eicon/eicon_isa.h drivers/isdn/eicon/eicon_isa.h~linus /dev/null
--- 25/drivers/isdn/eicon/eicon_isa.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,121 +0,0 @@
-/* $Id: eicon_isa.h,v 1.1.4.1.2.2 2002/10/01 11:29:13 armin Exp $
- *
- * ISDN low-level module for Eicon active ISDN-Cards.
- *
- * Copyright 1998      by Fritz Elfert (fritz@isdn4linux.de)
- * Copyright 1998-2000 by Armin Schindler (mac@melware.de)
- * Copyright 1999,2000 Cytronics & Melware (info@melware.de)
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#ifndef eicon_isa_h
-#define eicon_isa_h
-
-#ifdef __KERNEL__
-#include <linux/config.h>
-
-/* Factory defaults for ISA-Cards */
-#define EICON_ISA_MEMBASE 0xd0000
-#define EICON_ISA_IRQ     3
-/* shmem offset for Quadro parts */
-#define EICON_ISA_QOFFSET 0x0800
-
-typedef struct {
-        __u16 length __attribute__ ((packed));   /* length of data/parameter field         */
-        __u8  P[270];                            /* data/parameter field                   */
-} eicon_scom_PBUFFER;
-
-/* General communication buffer */
-typedef struct {
-        __u8   Req;                                /* request register                       */
-	__u8   ReqId;                              /* request task/entity identification     */
-	__u8   Rc;                                 /* return code register                   */
-	__u8   RcId;                               /* return code task/entity identification */
-	__u8   Ind;                                /* Indication register                    */
-	__u8   IndId;                              /* Indication task/entity identification  */
-	__u8   IMask;                              /* Interrupt Mask Flag                    */
-	__u8   RNR;                                /* Receiver Not Ready (set by PC)         */
-	__u8   XLock;                              /* XBuffer locked Flag                    */
-	__u8   Int;                                /* ISDN interrupt                         */
-	__u8   ReqCh;                              /* Channel field for layer-3 Requests     */
-	__u8   RcCh;                               /* Channel field for layer-3 Returncodes  */
-	__u8   IndCh;                              /* Channel field for layer-3 Indications  */
-	__u8   MInd;                               /* more data indication field             */
-	__u16  MLength;                            /* more data total packet length          */
-	__u8   ReadyInt;                           /* request field for ready interrupt      */
-	__u8   Reserved[12];                       /* reserved space                         */
-	__u8   IfType;                             /* 1 = 16k-Interface                      */
-	__u16  Signature __attribute__ ((packed)); /* ISDN adapter Signature                 */
-	eicon_scom_PBUFFER XBuffer;                /* Transmit Buffer                        */
-	eicon_scom_PBUFFER RBuffer;                /* Receive Buffer                         */
-} eicon_isa_com;
-
-/* struct for downloading firmware */
-typedef struct {
-	__u8  ctrl;
-	__u8  card;
-	__u8  msize;
-	__u8  fill0;
-	__u16 ebit __attribute__ ((packed));
-	__u32 eloc __attribute__ ((packed));
-	__u8  reserved[20];
-	__u16 signature __attribute__ ((packed));
-	__u8  fill[224];
-	__u8  b[256];
-} eicon_isa_boot;
-
-/* Shared memory */
-typedef union {
-	unsigned char  c[0x400];
-	eicon_isa_com  com;
-	eicon_isa_boot boot;
-} eicon_isa_shmem;
-
-/*
- * card's description
- */
-typedef struct {
-	int               ramsize;
-	int               irq;	    /* IRQ                        */
-	unsigned long	  physmem;  /* physical memory address	  */
-#ifdef CONFIG_MCA
-	int		  io;	    /* IO-port for MCA brand      */
-#endif /* CONFIG_MCA */
-	void*             card;
-	eicon_isa_shmem*  shmem;    /* Shared-memory area         */
-	unsigned char*    intack;   /* Int-Acknowledge            */
-	unsigned char*    stopcpu;  /* Writing here stops CPU     */
-	unsigned char*    startcpu; /* Writing here starts CPU    */
-	unsigned char     type;     /* card type                  */
-	int		  channels; /* No. of channels		  */
-	unsigned char     irqprobe; /* Flag: IRQ-probing          */
-	unsigned char     mvalid;   /* Flag: Memory is valid      */
-	unsigned char     ivalid;   /* Flag: IRQ is valid         */
-	unsigned char     master;   /* Flag: Card ist Quadro 1/4  */
-} eicon_isa_card;
-
-/* Offsets for special locations on standard cards */
-#define INTACK     0x03fe 
-#define STOPCPU    0x0400
-#define STARTCPU   0x0401
-#define RAMSIZE    0x0400
-/* Offsets for special location on PRI card */
-#define INTACK_P   0x3ffc
-#define STOPCPU_P  0x3ffe
-#define STARTCPU_P 0x3fff
-#define RAMSIZE_P  0x4000
-
-
-extern int eicon_isa_load(eicon_isa_card *card, eicon_isa_codebuf *cb);
-extern int eicon_isa_bootload(eicon_isa_card *card, eicon_isa_codebuf *cb);
-extern void eicon_isa_release(eicon_isa_card *card);
-extern void eicon_isa_printpar(eicon_isa_card *card);
-extern void eicon_isa_transmit(eicon_isa_card *card);
-extern int eicon_isa_find_card(int Mem, int Irq, char * Id);
-
-#endif  /* __KERNEL__ */
-
-#endif	/* eicon_isa_h */
diff -puN -L drivers/isdn/eicon/eicon_mod.c drivers/isdn/eicon/eicon_mod.c~linus /dev/null
--- 25/drivers/isdn/eicon/eicon_mod.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,1642 +0,0 @@
-/* $Id: eicon_mod.c,v 1.1.4.1.2.4 2002/10/01 11:29:13 armin Exp $
- *
- * ISDN lowlevel-module for Eicon active cards.
- * 
- * Copyright 1997      by Fritz Elfert (fritz@isdn4linux.de)
- * Copyright 1998-2000 by Armin Schindler (mac@melware.de) 
- * Copyright 1999,2000 Cytronics & Melware (info@melware.de)
- * 
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- * Thanks to    Eicon Networks for
- *              documents, informations and hardware.
- *
- *		Deutsche Mailbox Saar-Lor-Lux GmbH
- *		for sponsoring and testing fax
- *		capabilities with Diva Server cards.
- *		(dor@deutschemailbox.de)
- *
- */
-
-#define DRIVERNAME "Eicon active ISDN driver"
-#define DRIVERRELEASE "2.0"
-#define DRIVERPATCH ".16"
-
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#ifdef CONFIG_MCA
-#include <linux/mca.h>
-#include <linux/mca-legacy.h>
-#endif /* CONFIG_MCA */
-
-#include "eicon.h"
-
-#include <linux/isdn/capicmd.h>
-
-#undef N_DATA
-#include "adapter.h"
-#include "uxio.h"
-
-#define INCLUDE_INLINE_FUNCS
-
-static eicon_card *cards = (eicon_card *) NULL;   /* glob. var , contains
-                                                     start of card-list   */
-
-static char *eicon_revision = "$Revision: 1.1.4.1.2.4 $";
-
-extern char *eicon_pci_revision;
-extern char *eicon_isa_revision;
-extern char *eicon_idi_revision;
-
-extern int do_ioctl(struct inode *pDivasInode, struct file *pDivasFile,
-			unsigned int command, unsigned long arg);
-extern void eicon_pci_init_conf(eicon_card *card);
-
-#define EICON_CTRL_VERSION 2 
-
-ulong DebugVar;
-
-spinlock_t eicon_lock;
-
-DESCRIPTOR idi_d[32];
-
-/* Parameters to be set by insmod */
-#ifdef CONFIG_ISDN_DRV_EICON_ISA
-static int   membase      = -1;
-static int   irq          = -1;
-#endif
-static char *id           = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
-
-MODULE_DESCRIPTION(             "ISDN4Linux: Driver for Eicon active ISDN cards");
-MODULE_AUTHOR(                  "Armin Schindler");
-MODULE_LICENSE(                 "GPL");
-MODULE_PARM_DESC(id,   		"ID-String of first card");
-MODULE_PARM(id,           	"s");
-#ifdef CONFIG_ISDN_DRV_EICON_ISA
-MODULE_PARM_DESC(membase,	"Base address of first ISA card");
-MODULE_PARM_DESC(irq,    	"IRQ of first card");
-MODULE_PARM(membase,    	"i");
-MODULE_PARM(irq,          	"i");
-#endif
-
-char *eicon_ctype_name[] = {
-        "ISDN-S",
-        "ISDN-SX",
-        "ISDN-SCOM",
-        "ISDN-QUADRO",
-        "ISDN-S2M",
-        "DIVA Server BRI/PCI",
-        "DIVA Server 4BRI/PCI",
-        "DIVA Server 4BRI/PCI",
-        "DIVA Server PRI/PCI"
-};
-
-static char *
-eicon_getrev(const char *revision)
-{
-	char *rev;
-	char *p;
-	if ((p = strchr(revision, ':'))) {
-		rev = p + 2;
-		p = strchr(rev, '$');
-		*--p = 0;
-	} else rev = "?.??";
-	return rev;
-
-}
-
-static eicon_chan *
-find_channel(eicon_card *card, int channel)
-{
-	if ((channel >= 0) && (channel < card->nchannels))
-        	return &(card->bch[channel]);
-	eicon_log(card, 1, "eicon: Invalid channel %d\n", channel);
-	return NULL;
-}
-
-#ifdef CONFIG_PCI
-#ifdef CONFIG_ISDN_DRV_EICON_PCI
-/*
- * Find pcicard with given card number 
- */
-static inline eicon_card *
-eicon_findnpcicard(int driverid)
-{
-        eicon_card *p = cards;
-
-        while (p) {
-                if ((p->regname[strlen(p->regname)-1] == (driverid + '0')) &&
-			(p->bus == EICON_BUS_PCI))
-                        return p;
-                p = p->next;
-        }
-        return (eicon_card *) 0;
-}
-#endif
-#endif /* CONFIG_PCI */
-
-static void
-eicon_rcv_dispatch(unsigned long context)
-{
-	struct eicon_card *card = (struct eicon_card *)context;
-
-	switch (card->bus) {
-		case EICON_BUS_ISA:
-		case EICON_BUS_MCA:
-		case EICON_BUS_PCI:
-			eicon_io_rcv_dispatch(card);
-			break;
-		default:
-			eicon_log(card, 1,
-			       "eicon_rcv_dispatch: Illegal bustype %d\n", card->bus);
-	}
-}
-
-static void
-eicon_ack_dispatch(unsigned long context)
-{
-	struct eicon_card *card = (struct eicon_card *)context;
-
-	switch (card->bus) {
-		case EICON_BUS_ISA:
-		case EICON_BUS_MCA:
-		case EICON_BUS_PCI:
-			eicon_io_ack_dispatch(card);
-			break;
-		default:
-			eicon_log(card, 1,
-		       		"eicon_ack_dispatch: Illegal bustype %d\n", card->bus);
-	}
-}
-
-static void
-eicon_transmit(unsigned long context)
-{
-	struct eicon_card *card = (struct eicon_card *)context;
-
-	switch (card->bus) {
-		case EICON_BUS_ISA:
-		case EICON_BUS_MCA:
-		case EICON_BUS_PCI:
-			eicon_io_transmit(card);
-			break;
-		default:
-			eicon_log(card, 1,
-			       "eicon_transmit: Illegal bustype %d\n", card->bus);
-	}
-}
-
-static int
-eicon_command(eicon_card * card, isdn_ctrl * c)
-{
-        ulong a;
-        eicon_chan *chan;
-	eicon_cdef cdef;
-#ifdef CONFIG_PCI
-#ifdef CONFIG_ISDN_DRV_EICON_PCI
-	dia_start_t dstart;
-        int idi_length = 0;
-#endif
-#endif
-	isdn_ctrl cmd;
-	int ret = 0;
-	unsigned long flags;
- 
-	eicon_log(card, 16, "eicon_cmd 0x%x with arg 0x%lx (0x%lx)\n",
-		c->command, c->arg, (ulong) *c->parm.num);
-
-        switch (c->command) {
-		case ISDN_CMD_IOCTL:
-			memcpy(&a, c->parm.num, sizeof(ulong));
-			switch (c->arg) {
-				case EICON_IOCTL_GETVER:
-					return(EICON_CTRL_VERSION);
-				case EICON_IOCTL_GETTYPE:
-					if (card->bus == EICON_BUS_PCI) {
-						if (copy_to_user((char *)a,
-							&card->hwif.pci.master,
-								 sizeof(int)))
-							return -EFAULT;
-					}
-					return(card->type);
-				case EICON_IOCTL_GETMMIO:
-					switch (card->bus) {
-						case EICON_BUS_ISA:
-						case EICON_BUS_MCA:
-							return (int)card->hwif.isa.shmem;
-						default:
-							eicon_log(card, 1,
-							       "eicon: Illegal BUS type %d\n",
-							       card->bus);
-							ret = -ENODEV;
-					}
-#ifdef CONFIG_ISDN_DRV_EICON_ISA
-				case EICON_IOCTL_SETMMIO:
-					if (card->flags & EICON_FLAGS_LOADED)
-						return -EBUSY;
-					switch (card->bus) {
-						case EICON_BUS_ISA:
-							if (eicon_isa_find_card(a,
-								card->hwif.isa.irq,
-								card->regname) < 0)
-								return -EFAULT;
-							card->hwif.isa.shmem = (eicon_isa_shmem *)a;
-							return 0;
-						case EICON_BUS_MCA:
-#ifdef CONFIG_MCA
-							if (eicon_mca_find_card(
-								0, a,
-								card->hwif.isa.irq,
-								card->regname) < 0)
-								return -EFAULT;
-							card->hwif.isa.shmem = (eicon_isa_shmem *)a;
-							return 0;
-#endif /* CONFIG_MCA */
-						default:
-							eicon_log(card, 1,
-						      		"eicon: Illegal BUS type %d\n",
-							       card->bus);
-							ret = -ENODEV;
-					}					
-#endif
-				case EICON_IOCTL_GETIRQ:
-					switch (card->bus) {
-						case EICON_BUS_ISA:
-						case EICON_BUS_MCA:
-							return card->hwif.isa.irq;
-						default:
-							eicon_log(card, 1,
-							       "eicon: Illegal BUS type %d\n",
-							       card->bus);
-							ret = -ENODEV;
-					}
-				case EICON_IOCTL_SETIRQ:
-					if (card->flags & EICON_FLAGS_LOADED)
-						return -EBUSY;
-					if ((a < 2) || (a > 15))
-						return -EFAULT;
-					switch (card->bus) {
-						case EICON_BUS_ISA:
-						case EICON_BUS_MCA:
-							card->hwif.isa.irq = a;
-							return 0;
-						default:
-							eicon_log(card, 1,
-						      		"eicon: Illegal BUS type %d\n",
-							       card->bus);
-							ret = -ENODEV;
-					}					
-#ifdef CONFIG_ISDN_DRV_EICON_ISA
-				case EICON_IOCTL_LOADBOOT:
-					if (card->flags & EICON_FLAGS_RUNNING)
-						return -EBUSY;  
-					switch (card->bus) {
-						case EICON_BUS_ISA:
-						case EICON_BUS_MCA:
-							ret = eicon_isa_bootload(
-								&(card->hwif.isa),
-								&(((eicon_codebuf *)a)->isa));
-							break;
-						default:
-							eicon_log(card, 1,
-							       "eicon: Illegal BUS type %d\n",
-							       card->bus);
-							ret = -ENODEV;
-					}
-					return ret;
-#endif
-#ifdef CONFIG_ISDN_DRV_EICON_ISA
-				case EICON_IOCTL_LOADISA:
-					if (card->flags & EICON_FLAGS_RUNNING)
-						return -EBUSY;  
-					switch (card->bus) {
-						case EICON_BUS_ISA:
-						case EICON_BUS_MCA:
-							ret = eicon_isa_load(
-								&(card->hwif.isa),
-								&(((eicon_codebuf *)a)->isa));
-							if (!ret) {
-                                                                card->flags |= EICON_FLAGS_LOADED;
-                                                                card->flags |= EICON_FLAGS_RUNNING;
-								if (card->hwif.isa.channels > 1) {
-									cmd.command = ISDN_STAT_ADDCH;
-									cmd.driver = card->myid;
-									cmd.arg = card->hwif.isa.channels - 1;
-									card->interface.statcallb(&cmd);
-								}
-								cmd.command = ISDN_STAT_RUN;    
-								cmd.driver = card->myid;        
-								cmd.arg = 0;                    
-								card->interface.statcallb(&cmd);
-							}
-							break;
-						default:
-							eicon_log(card, 1,
-							       "eicon: Illegal BUS type %d\n",
-							       card->bus);
-							ret = -ENODEV;
-					}
-					return ret;
-#endif
-				case EICON_IOCTL_MANIF:
-					if (!card->flags & EICON_FLAGS_RUNNING)
-						return -ENODEV;
-					if (!card->d)
-						return -ENODEV;
-					if (!card->d->features & DI_MANAGE)
-						return -ENODEV;
-					ret = eicon_idi_manage(
-						card, 
-						(eicon_manifbuf *)a);
-					return ret;
-
-				case EICON_IOCTL_GETXLOG:
-					return -ENODEV;
-
-				case EICON_IOCTL_ADDCARD:
-					if (copy_from_user(&cdef, (char *)a,
-							   sizeof(cdef)))
-						return -EFAULT;
-					if (!(eicon_addcard(0, cdef.membase, cdef.irq, cdef.id, 0)))
-						return -EIO;
-					return 0;
-				case EICON_IOCTL_DEBUGVAR:
-					DebugVar = a;
-					eicon_log(card, 1, "Eicon: Debug Value set to %ld\n", DebugVar);
-					return 0;
-				case EICON_IOCTL_LOADPCI:
-					eicon_log(card, 1, "Eicon: Wrong version of load-utility,\n");
-					eicon_log(card, 1, "Eicon: re-compile eiconctrl !\n");
-					eicon_log(card, 1, "Eicon: Maybe update of utility is necessary !\n");
-					return -EINVAL;
-				default:	
-#ifdef CONFIG_PCI
-#ifdef CONFIG_ISDN_DRV_EICON_PCI
-					if (c->arg < EICON_IOCTL_DIA_OFFSET)
-						return -EINVAL;
-					if (copy_from_user(&dstart, (char *)a,
-							   sizeof(dstart)))
-						return -EFAULT;
-					if (!(card = eicon_findnpcicard(dstart.card_id)))
-						return -EINVAL;
-					ret = do_ioctl(NULL, NULL,
-						c->arg - EICON_IOCTL_DIA_OFFSET,
-						(unsigned long) a);
-					if (((c->arg - EICON_IOCTL_DIA_OFFSET)==DIA_IOCTL_START) && (!ret)) {
-						if (card->type != EICON_CTYPE_MAESTRAQ) {
-							DIVA_DIDD_Read(idi_d, sizeof(idi_d));
-                                                        for(idi_length = 0; idi_length < 32; idi_length++) {
-                                                          if (idi_d[idi_length].type == 0) break;
-                                                        }
-                                                        if ((idi_length < 1) || (idi_length >= 32)) {
-					                  eicon_log(card, 1, "eicon: invalid idi table length.\n");
-                                                          break;
-                                                        }
-							card->d = &idi_d[idi_length - 1];
-							card->flags |= EICON_FLAGS_LOADED;
-							card->flags |= EICON_FLAGS_RUNNING;
-							eicon_pci_init_conf(card);
-							if (card->d->channels > 1) {
-								cmd.command = ISDN_STAT_ADDCH;
-								cmd.driver = card->myid;
-								cmd.arg = card->d->channels - 1;
-								card->interface.statcallb(&cmd);
-							}
-							cmd.command = ISDN_STAT_RUN;    
-							cmd.driver = card->myid;        
-							cmd.arg = 0;                    
-							card->interface.statcallb(&cmd);
-							eicon_log(card, 1, "Eicon: %s started, %d channels (feat. 0x%x)\n",
-								(card->type == EICON_CTYPE_MAESTRA) ? "BRI" : "PRI",
-								card->d->channels, card->d->features);
-						} else {
-							int i;
-							DIVA_DIDD_Read(idi_d, sizeof(idi_d));
-                                                        for(idi_length = 0; idi_length < 32; idi_length++)
-                                                          if (idi_d[idi_length].type == 0) break;
-                                                        if ((idi_length < 1) || (idi_length >= 32)) {
-					                  eicon_log(card, 1, "eicon: invalid idi table length.\n");
-                                                          break;
-                                                        }
-        						for(i = 3; i >= 0; i--) {
-								if (!(card = eicon_findnpcicard(dstart.card_id - i)))
-									return -EINVAL;
-	
-								card->flags |= EICON_FLAGS_LOADED;
-								card->flags |= EICON_FLAGS_RUNNING;
-								card->d = &idi_d[idi_length - (i+1)];
-								eicon_pci_init_conf(card);
-								if (card->d->channels > 1) {
-									cmd.command = ISDN_STAT_ADDCH;
-									cmd.driver = card->myid;
-									cmd.arg = card->d->channels - 1;
-									card->interface.statcallb(&cmd);
-								}
-								cmd.command = ISDN_STAT_RUN;    
-								cmd.driver = card->myid;        
-								cmd.arg = 0;                    
-								card->interface.statcallb(&cmd);
-								eicon_log(card, 1, "Eicon: %d/4BRI started, %d channels (feat. 0x%x)\n",
-									4-i, card->d->channels, card->d->features);
-							}
-						}
-					}
-					return ret;
-#else
-					return -EINVAL;
-#endif
-#endif /* CONFIG_PCI */
-			}
-			break;
-		case ISDN_CMD_DIAL:
-			if (!card->flags & EICON_FLAGS_RUNNING)
-				return -ENODEV;
-			if (!(chan = find_channel(card, c->arg & 0x1f)))
-				break;
-			spin_lock_irqsave(&eicon_lock, flags);
-			if ((chan->fsm_state != EICON_STATE_NULL) && (chan->fsm_state != EICON_STATE_LISTEN)) {
-				spin_unlock_irqrestore(&eicon_lock, flags);
-				eicon_log(card, 1, "Dial on channel %d with state %d\n",
-					chan->No, chan->fsm_state);
-				return -EBUSY;
-			}
-			chan->fsm_state = EICON_STATE_OCALL;
-			spin_unlock_irqrestore(&eicon_lock, flags);
-			
-			ret = idi_connect_req(card, chan, c->parm.setup.phone,
-						     c->parm.setup.eazmsn,
-						     c->parm.setup.si1,
-						     c->parm.setup.si2);
-			if (ret) {
-				cmd.driver = card->myid;
-				cmd.command = ISDN_STAT_DHUP;
-				cmd.arg &= 0x1f;
-				card->interface.statcallb(&cmd);
-			}
-			return ret;
-		case ISDN_CMD_ACCEPTD:
-			if (!card->flags & EICON_FLAGS_RUNNING)
-				return -ENODEV;
-			if (!(chan = find_channel(card, c->arg & 0x1f)))
-				break;
-			if (chan->fsm_state == EICON_STATE_ICALL) { 
-				idi_connect_res(card, chan);
-			}
-			return 0;
-		case ISDN_CMD_ACCEPTB:
-			if (!card->flags & EICON_FLAGS_RUNNING)
-				return -ENODEV;
-			return 0;
-		case ISDN_CMD_HANGUP:
-			if (!card->flags & EICON_FLAGS_RUNNING)
-				return -ENODEV;
-			if (!(chan = find_channel(card, c->arg & 0x1f)))
-				break;
-			idi_hangup(card, chan);
-			return 0;
-		case ISDN_CMD_SETEAZ:
-			if (!card->flags & EICON_FLAGS_RUNNING)
-				return -ENODEV;
-			if (!(chan = find_channel(card, c->arg & 0x1f)))
-				break;
-			chan->eazmask = 0x3ff;
-			eicon_idi_listen_req(card, chan);
-			return 0;
-		case ISDN_CMD_CLREAZ:
-			if (!card->flags & EICON_FLAGS_RUNNING)
-				return -ENODEV;
-			if (!(chan = find_channel(card, c->arg & 0x1f)))
-				break;
-			chan->eazmask = 0;
-			eicon_idi_listen_req(card, chan);
-			return 0;
-		case ISDN_CMD_SETL2:
-			if (!card->flags & EICON_FLAGS_RUNNING)
-				return -ENODEV;
-			if (!(chan = find_channel(card, c->arg & 0x1f)))
-				break;
-			chan->l2prot = (c->arg >> 8);
-			return 0;
-		case ISDN_CMD_SETL3:
-			if (!card->flags & EICON_FLAGS_RUNNING)
-				return -ENODEV;
-			if (!(chan = find_channel(card, c->arg & 0x1f)))
-				break;
-			chan->l3prot = (c->arg >> 8);
-#ifdef CONFIG_ISDN_TTY_FAX
-			if (chan->l3prot == ISDN_PROTO_L3_FCLASS2) {
-				chan->fax = c->parm.fax;
-				eicon_log(card, 128, "idi_cmd: Ch%d: SETL3 struct fax=0x%x\n",chan->No, chan->fax);
-			}
-#endif
-			return 0;
-#ifdef CONFIG_ISDN_TTY_FAX
-		case ISDN_CMD_FAXCMD:
-			if (!card->flags & EICON_FLAGS_RUNNING)
-				return -ENODEV;
-			if (!(chan = find_channel(card, c->arg & 0x1f)))
-				break;
-			if (!chan->fax)
-				break;
-			idi_fax_cmd(card, chan);
-			return 0;
-#endif
-		case ISDN_CMD_AUDIO:
-			if (!card->flags & EICON_FLAGS_RUNNING)
-				return -ENODEV;
-			if (!(chan = find_channel(card, c->arg & 0x1f)))
-				break;
-			idi_audio_cmd(card, chan, c->arg >> 8, c->parm.num);
-			return 0;
-		case CAPI_PUT_MESSAGE:
-			if (!card->flags & EICON_FLAGS_RUNNING)
-				return -ENODEV;
-			if (!(chan = find_channel(card, c->arg & 0x1f)))
-				break;
-			if (c->parm.cmsg.Length < 8)
-				break;
-			switch(c->parm.cmsg.Command) {
-				case CAPI_FACILITY:
-					if (c->parm.cmsg.Subcommand == CAPI_REQ)
-						return(capipmsg(card, chan, &c->parm.cmsg));
-					break;
-				case CAPI_MANUFACTURER:
-				default:
-					break;
-			}
-			return 0;
-        }
-	
-        return -EINVAL;
-}
-
-/*
- * Find card with given driverId
- */
-static inline eicon_card *
-eicon_findcard(int driverid)
-{
-        eicon_card *p = cards;
-
-        while (p) {
-                if (p->myid == driverid)
-                        return p;
-                p = p->next;
-        }
-        return (eicon_card *) 0;
-}
-
-/*
- * Wrapper functions for interface to linklevel
- */
-static int
-if_command(isdn_ctrl * c)
-{
-        eicon_card *card = eicon_findcard(c->driver);
-
-        if (card)
-                return (eicon_command(card, c));
-        printk(KERN_ERR
-             "eicon: if_command %d called with invalid driverId %d!\n",
-               c->command, c->driver);
-        return -ENODEV;
-}
-
-static int
-if_writecmd(const u_char * buf, int len, int user, int id, int channel)
-{
-        return (len);
-}
-
-static int
-if_readstatus(u_char * buf, int len, int user, int id, int channel)
-{
-	int count = 0;
-	int cnt = 0;
-	ulong flags = 0;
-	u_char *p = buf;
-	struct sk_buff *skb;
-
-        eicon_card *card = eicon_findcard(id);
-	
-        if (card) {
-                if (!card->flags & EICON_FLAGS_RUNNING)
-                        return -ENODEV;
-	
-		spin_lock_irqsave(&eicon_lock, flags);
-		while((skb = skb_dequeue(&card->statq))) {
-
-			if ((skb->len + count) > len)
-				cnt = len - count;
-			else
-				cnt = skb->len;
-
-			if (user) {
-				spin_unlock_irqrestore(&eicon_lock, flags);
-				if (copy_to_user(p, skb->data, cnt))
-					return -EFAULT;
-				spin_lock_irqsave(&eicon_lock, flags);
-			}
-			else
-				memcpy(p, skb->data, cnt);
-
-			count += cnt;
-			p += cnt;
-
-			if (cnt == skb->len) {
-				dev_kfree_skb(skb);
-				if (card->statq_entries > 0)
-					card->statq_entries--;
-			} else {
-				skb_pull(skb, cnt);
-				skb_queue_head(&card->statq, skb);
-				spin_unlock_irqrestore(&eicon_lock, flags);
-				return count;
-			}
-		}
-		card->statq_entries = 0;
-		spin_unlock_irqrestore(&eicon_lock, flags);
-		return count;
-        }
-        printk(KERN_ERR
-               "eicon: if_readstatus called with invalid driverId!\n");
-        return 0;
-}
-
-static int
-if_sendbuf(int id, int channel, int ack, struct sk_buff *skb)
-{
-        eicon_card *card = eicon_findcard(id);
-	eicon_chan *chan;
-	int ret = 0;
-	int len;
-
-	len = skb->len;
-	
-        if (card) {
-                if (!card->flags & EICON_FLAGS_RUNNING)
-                        return -ENODEV;
-        	if (!(chan = find_channel(card, channel)))
-			return -ENODEV;
-
-		if (chan->fsm_state == EICON_STATE_ACTIVE) {
-#ifdef CONFIG_ISDN_TTY_FAX
-			if (chan->l2prot == ISDN_PROTO_L2_FAX) {
-				if ((ret = idi_faxdata_send(card, chan, skb)) > 0)
-					ret = len;
-			}
-			else
-#endif
-				ret = idi_send_data(card, chan, ack, skb, 1, 1);
-			return (ret);
-		} else {
-			return -ENODEV;
-		}
-        }
-        printk(KERN_ERR
-               "eicon: if_sendbuf called with invalid driverId!\n");
-        return -ENODEV;
-}
-
-/* jiftime() copied from HiSax */
-static inline int jiftime(char *s, long mark)
-{
-        s += 8;
-
-        *s-- = '\0';
-        *s-- = mark % 10 + '0';
-        mark /= 10;
-        *s-- = mark % 10 + '0';
-        mark /= 10;
-        *s-- = '.';
-        *s-- = mark % 10 + '0';
-        mark /= 10;
-        *s-- = mark % 6 + '0';
-        mark /= 6;
-        *s-- = ':';
-        *s-- = mark % 10 + '0';
-        mark /= 10;
-        *s-- = mark % 10 + '0';
-        return(8);
-}
-
-void
-eicon_putstatus(eicon_card * card, char * buf)
-{
-	ulong flags;
-	int count;
-	isdn_ctrl cmd;
-	u_char *p;
-	struct sk_buff *skb;
-
-	if (!card) {
-		if (!(card = cards))
-			return;
-	}
-
-	spin_lock_irqsave(&eicon_lock, flags);
-	count = strlen(buf);
-	skb = alloc_skb(count, GFP_ATOMIC);
-	if (!skb) {
-		spin_unlock_irqrestore(&eicon_lock, flags);
-		printk(KERN_ERR "eicon: could not alloc skb in putstatus\n");
-		return;
-	}
-	p = skb_put(skb, count);
-	memcpy(p, buf, count);
-
-	skb_queue_tail(&card->statq, skb);
-
-	if (card->statq_entries >= MAX_STATUS_BUFFER) {
-		if ((skb = skb_dequeue(&card->statq))) {
-			count -= skb->len;
-			dev_kfree_skb(skb);
-		} else
-			count = 0;
-	} else
-		card->statq_entries++;
-
-	spin_unlock_irqrestore(&eicon_lock, flags);
-        if (count) {
-                cmd.command = ISDN_STAT_STAVAIL;
-                cmd.driver = card->myid;
-                cmd.arg = count;
-		card->interface.statcallb(&cmd);
-        }
-}
-
-/*
- * Debug and Log 
- */
-void
-eicon_log(eicon_card * card, int level, const char *fmt, ...)
-{
-	va_list args;
-	char Line[160];
-	u_char *p;
-
-
-	if ((DebugVar & level) || (DebugVar & 256)) {
-		va_start(args, fmt);
-
-		if (DebugVar & level) {
-			if (DebugVar & 256) {
-				/* log-buffer */
-				p = Line;
-				p += jiftime(p, jiffies);
-				*p++ = 32;
-				p += vsprintf(p, fmt, args);
-				*p = 0;	
-				eicon_putstatus(card, Line);
-			} else {
-				/* printk, syslogd */
-				vsprintf(Line, fmt, args);
-				printk(KERN_DEBUG "%s", Line);
-			}
-		}
-
-		va_end(args);
-	}
-}
-
-
-/*
- * Allocate a new card-struct, initialize it
- * link it into cards-list.
- */
-static void
-eicon_alloccard(int Type, int membase, int irq, char *id, int card_id)
-{
-	int i;
-	int j;
-	int qloop;
-#ifdef CONFIG_ISDN_DRV_EICON_ISA
-	char qid[5];
-#endif
-        eicon_card *card;
-
-	qloop = (Type == EICON_CTYPE_QUADRO)?2:0;
-	for (i = 0; i <= qloop; i++) {
-		if (!(card = (eicon_card *) kmalloc(sizeof(eicon_card), GFP_KERNEL))) {
-			eicon_log(card, 1,
-			       "eicon: (%s) Could not allocate card-struct.\n", id);
-			return;
-		}
-		memset((char *) card, 0, sizeof(eicon_card));
-		skb_queue_head_init(&card->sndq);
-		skb_queue_head_init(&card->rcvq);
-		skb_queue_head_init(&card->rackq);
-		skb_queue_head_init(&card->sackq);
-		skb_queue_head_init(&card->statq);
-		card->statq_entries = 0;
-		tasklet_init(&card->snd_tq, eicon_transmit, (unsigned long)card);
-		tasklet_init(&card->rcv_tq, eicon_rcv_dispatch, (unsigned long)card);
-		tasklet_init(&card->ack_tq, eicon_ack_dispatch, (unsigned long)card);
-		card->interface.owner = THIS_MODULE;
-		card->interface.maxbufsize = 4000;
-		card->interface.command = if_command;
-		card->interface.writebuf_skb = if_sendbuf;
-		card->interface.writecmd = if_writecmd;
-		card->interface.readstat = if_readstatus;
-		card->interface.features =
-			ISDN_FEATURE_L2_X75I |
-			ISDN_FEATURE_L2_HDLC |
-			ISDN_FEATURE_L2_TRANS |
-			ISDN_FEATURE_L3_TRANS |
-			ISDN_FEATURE_P_UNKNOWN;
-		card->interface.hl_hdrlen = 20;
-		card->ptype = ISDN_PTYPE_UNKNOWN;
-		strlcpy(card->interface.id, id, sizeof(card->interface.id));
-		card->myid = -1;
-		card->type = Type;
-		switch (Type) {
-#ifdef CONFIG_ISDN_DRV_EICON_ISA
-#ifdef CONFIG_MCA /* only needed for MCA */
-                        case EICON_CTYPE_S:
-                        case EICON_CTYPE_SX:
-                        case EICON_CTYPE_SCOM:
-				if (MCA_bus) {
-	                                if (membase == -1)
-        	                                membase = EICON_ISA_MEMBASE;
-                	                if (irq == -1)
-                        	                irq = EICON_ISA_IRQ;
-	                                card->bus = EICON_BUS_MCA;
-        	                        card->hwif.isa.card = (void *)card;
-                	                card->hwif.isa.shmem = (eicon_isa_shmem *)membase;
-					card->hwif.isa.physmem = (unsigned long)membase;
-                        	        card->hwif.isa.master = 1;
-
-	                                card->hwif.isa.irq = irq;
-        	                        card->hwif.isa.type = Type;
-                	                card->nchannels = 2;
-                        	        card->interface.channels = 1;
-				} else {
-					printk(KERN_WARNING
-						"eicon (%s): no MCA bus detected.\n",
-						card->interface.id);
-					kfree(card);
-					return;
-				}
-                                break;
-#endif /* CONFIG_MCA */
-			case EICON_CTYPE_QUADRO:
-				if (membase == -1)
-					membase = EICON_ISA_MEMBASE;
-				if (irq == -1)
-					irq = EICON_ISA_IRQ;
-                                card->bus = EICON_BUS_ISA;
-				card->hwif.isa.card = (void *)card;
-				card->hwif.isa.shmem = (eicon_isa_shmem *)(membase + (i+1) * EICON_ISA_QOFFSET);
-				card->hwif.isa.physmem = (unsigned long)(membase + (i+1) * EICON_ISA_QOFFSET);
-				card->hwif.isa.master = 0;
-				strcpy(card->interface.id, id);
-				if (id[strlen(id) - 1] == 'a') {
-					card->interface.id[strlen(id) - 1] = 'a' + i + 1;
-				} else {
-					sprintf(qid, "_%c",'2' + i);
-					strcat(card->interface.id, qid);
-				}
-				printk(KERN_INFO "Eicon: Quadro: Driver-Id %s added.\n",
-					card->interface.id);
-				if (i == 0) {
-					eicon_card *p = cards;
-					while(p) {
-						if ((p->hwif.isa.master) && (p->hwif.isa.irq == irq)) {
-							p->qnext = card;
-							break;
-						}
-						p = p->next;
-					}
-					if (!p) {
-						eicon_log(card, 1, "eicon_alloccard: Quadro Master not found.\n");
-						kfree(card);
-						return;
-					}
-				} else {
-					cards->qnext = card;
-				}
-				card->hwif.isa.irq = irq;
-				card->hwif.isa.type = Type;
-				card->nchannels = 2;
-				card->interface.channels = 1;
-				break;
-#endif
-#ifdef CONFIG_PCI
-#ifdef CONFIG_ISDN_DRV_EICON_PCI
-			case EICON_CTYPE_MAESTRA:
-                                card->bus = EICON_BUS_PCI;
-				card->interface.features |=
-					ISDN_FEATURE_L2_V11096 |
-					ISDN_FEATURE_L2_V11019 |
-					ISDN_FEATURE_L2_V11038 |
-					ISDN_FEATURE_L2_MODEM |
-					ISDN_FEATURE_L2_FAX | 
-					ISDN_FEATURE_L3_TRANSDSP |
-					ISDN_FEATURE_L3_FCLASS2;
-                                card->hwif.pci.card = (void *)card;
-                                card->hwif.pci.master = card_id;
-                                card->hwif.pci.irq = irq;
-                                card->hwif.pci.type = Type;
-				card->flags = 0;
-                                card->nchannels = 2;
-				card->interface.channels = 1;
-				break;
-
-			case EICON_CTYPE_MAESTRAQ:
-                                card->bus = EICON_BUS_PCI;
-				card->interface.features |=
-					ISDN_FEATURE_L2_V11096 |
-					ISDN_FEATURE_L2_V11019 |
-					ISDN_FEATURE_L2_V11038 |
-					ISDN_FEATURE_L2_MODEM |
-					ISDN_FEATURE_L2_FAX | 
-					ISDN_FEATURE_L3_TRANSDSP |
-					ISDN_FEATURE_L3_FCLASS2;
-                                card->hwif.pci.card = (void *)card;
-                                card->hwif.pci.master = card_id;
-                                card->hwif.pci.irq = irq;
-                                card->hwif.pci.type = Type;
-				card->flags = 0;
-                                card->nchannels = 2;
-				card->interface.channels = 1;
-				break;
-
-			case EICON_CTYPE_MAESTRAP:
-                                card->bus = EICON_BUS_PCI;
-				card->interface.features |=
-					ISDN_FEATURE_L2_V11096 |
-					ISDN_FEATURE_L2_V11019 |
-					ISDN_FEATURE_L2_V11038 |
-					ISDN_FEATURE_L2_MODEM |
-					ISDN_FEATURE_L2_FAX |
-					ISDN_FEATURE_L3_TRANSDSP |
-					ISDN_FEATURE_L3_FCLASS2;
-                                card->hwif.pci.card = (void *)card;
-                                card->hwif.pci.master = card_id;
-                                card->hwif.pci.irq = irq;
-                                card->hwif.pci.type = Type;
-				card->flags = 0;
-                                card->nchannels = 30;
-				card->interface.channels = 1;
-				break;
-#endif
-#endif
-#ifdef CONFIG_ISDN_DRV_EICON_ISA
-			case EICON_CTYPE_ISABRI:
-				if (membase == -1)
-					membase = EICON_ISA_MEMBASE;
-				if (irq == -1)
-					irq = EICON_ISA_IRQ;
-				card->bus = EICON_BUS_ISA;
-				card->hwif.isa.card = (void *)card;
-				card->hwif.isa.shmem = (eicon_isa_shmem *)membase;
-				card->hwif.isa.physmem = (unsigned long)membase;
-				card->hwif.isa.master = 1;
-				card->hwif.isa.irq = irq;
-				card->hwif.isa.type = Type;
-				card->nchannels = 2;
-				card->interface.channels = 1;
-				break;
-			case EICON_CTYPE_ISAPRI:
-				if (membase == -1)
-					membase = EICON_ISA_MEMBASE;
-				if (irq == -1)
-					irq = EICON_ISA_IRQ;
-                                card->bus = EICON_BUS_ISA;
-				card->hwif.isa.card = (void *)card;
-				card->hwif.isa.shmem = (eicon_isa_shmem *)membase;
-				card->hwif.isa.physmem = (unsigned long)membase;
-				card->hwif.isa.master = 1;
-				card->hwif.isa.irq = irq;
-				card->hwif.isa.type = Type;
-				card->nchannels = 30;
-				card->interface.channels = 1;
-				break;
-#endif
-			default:
-				eicon_log(card, 1, "eicon_alloccard: Invalid type %d\n", Type);
-				kfree(card);
-				return;
-		}
-		if (!(card->bch = (eicon_chan *) kmalloc(sizeof(eicon_chan) * (card->nchannels + 1)
-							 , GFP_KERNEL))) {
-			eicon_log(card, 1,
-			       "eicon: (%s) Could not allocate bch-struct.\n", id);
-			kfree(card);
-			return;
-		}
-		for (j=0; j< (card->nchannels + 1); j++) {
-			memset((char *)&card->bch[j], 0, sizeof(eicon_chan));
-			card->bch[j].statectrl = 0;
-			card->bch[j].l2prot = ISDN_PROTO_L2_X75I;
-			card->bch[j].l3prot = ISDN_PROTO_L3_TRANS;
-			card->bch[j].e.D3Id = 0;
-			card->bch[j].e.B2Id = 0;
-			card->bch[j].e.Req = 0;
-			card->bch[j].No = j;
-			card->bch[j].tskb1 = NULL;
-			card->bch[j].tskb2 = NULL;
-			skb_queue_head_init(&card->bch[j].e.X);
-			skb_queue_head_init(&card->bch[j].e.R);
-		}
-
-#ifdef CONFIG_ISDN_DRV_EICON_PCI
-		/* *** Diva Server *** */
-		if (!(card->dbuf = (DBUFFER *) kmalloc((sizeof(DBUFFER) * (card->nchannels + 1))*2
-							 , GFP_KERNEL))) {
-			eicon_log(card, 1,
-			       "eicon: (%s) Could not allocate DBUFFER-struct.\n", id);
-			kfree(card);
-			kfree(card->bch);
-			return;
-		}
-		if (!(card->sbuf = (BUFFERS *) kmalloc((sizeof(BUFFERS) * (card->nchannels + 1)) * 2, GFP_KERNEL))) {
-			eicon_log(card, 1,
-			       "eicon: (%s) Could not allocate BUFFERS-struct.\n", id);
-			kfree(card);
-			kfree(card->bch);
-			kfree(card->dbuf);
-			return;
-		}
-		if (!(card->sbufp = (char *) kmalloc((270 * (card->nchannels + 1)) * 2, GFP_KERNEL))) {
-			eicon_log(card, 1,
-			       "eicon: (%s) Could not allocate BUFFERSP-struct.\n", id);
-			kfree(card);
-			kfree(card->bch);
-			kfree(card->dbuf);
-			kfree(card->sbuf);
-			return;
-		}
-		for (j=0; j< (card->nchannels + 1); j++) {
-			memset((char *)&card->dbuf[j], 0, sizeof(DBUFFER));
-			card->bch[j].de.RBuffer = (DBUFFER *)&card->dbuf[j];
-			memset((char *)&card->dbuf[j+(card->nchannels+1)], 0, sizeof(BUFFERS));
-			card->bch[j].be.RBuffer = (DBUFFER *)&card->dbuf[j+(card->nchannels+1)];
-
-			memset((char *)&card->sbuf[j], 0, sizeof(BUFFERS));
-			card->bch[j].de.X = (BUFFERS *)&card->sbuf[j];
-			memset((char *)&card->sbuf[j+(card->nchannels+1)], 0, sizeof(BUFFERS));
-			card->bch[j].be.X = (BUFFERS *)&card->sbuf[j+(card->nchannels+1)];
-
-			memset((char *)&card->sbufp[j], 0, 270);
-			card->bch[j].de.X->P = (char *)&card->sbufp[j * 270];
-			memset((char *)&card->sbufp[j+(card->nchannels+1)], 0, 270);
-			card->bch[j].be.X->P = (char *)&card->sbufp[(j+(card->nchannels+1)) * 270];
-		}
-		/* *** */
-#endif /* CONFIG_ISDN_DRV_EICON_PCI */
-
-		card->next = cards;
-		cards = card;
-	}
-}
-
-/*
- * register card at linklevel
- */
-static int
-eicon_registercard(eicon_card * card)
-{
-        switch (card->bus) {
-#ifdef CONFIG_ISDN_DRV_EICON_ISA
-		case EICON_BUS_ISA:
-			/* TODO something to print */
-			break;
-#ifdef CONFIG_MCA
-		case EICON_BUS_MCA:
-			eicon_isa_printpar(&card->hwif.isa);
-			break;
-#endif /* CONFIG_MCA */
-#endif
-		case EICON_BUS_PCI:
-			break;
-		default:
-			eicon_log(card, 1,
-			       "eicon_registercard: Illegal BUS type %d\n",
-			       card->bus);
-			return -1;
-        }
-        if (!register_isdn(&card->interface)) {
-                printk(KERN_WARNING
-                       "eicon_registercard: Unable to register %s\n",
-                       card->interface.id);
-                return -1;
-        }
-        card->myid = card->interface.channels;
-        sprintf(card->regname, "%s", card->interface.id);
-        return 0;
-}
-
-static void __exit
-unregister_card(eicon_card * card)
-{
-        isdn_ctrl cmd;
-
-        cmd.command = ISDN_STAT_UNLOAD;
-        cmd.driver = card->myid;
-        card->interface.statcallb(&cmd);
-        switch (card->bus) {
-#ifdef CONFIG_ISDN_DRV_EICON_ISA
-		case EICON_BUS_ISA:
-#ifdef CONFIG_MCA
-		case EICON_BUS_MCA:
-#endif /* CONFIG_MCA */
-			eicon_isa_release(&card->hwif.isa);
-			break;
-#endif
-		case EICON_BUS_PCI:
-			break;
-		default:
-			eicon_log(card, 1,
-			       "eicon: Invalid BUS type %d\n",
-			       card->bus);
-			break;
-        }
-}
-
-static void
-eicon_freecard(eicon_card *card) {
-	int i;
-
-	for(i = 0; i < (card->nchannels + 1); i++) {
-		skb_queue_purge(&card->bch[i].e.X);
-		skb_queue_purge(&card->bch[i].e.R);
-	}
-	skb_queue_purge(&card->sndq);
-	skb_queue_purge(&card->rcvq);
-	skb_queue_purge(&card->rackq);
-	skb_queue_purge(&card->sackq);
-	skb_queue_purge(&card->statq);
-
-#ifdef CONFIG_ISDN_DRV_EICON_PCI
-	kfree(card->sbufp);
-	kfree(card->sbuf);
-	kfree(card->dbuf);
-#endif
-	kfree(card->bch);
-	kfree(card);
-}
-
-int
-eicon_addcard(int Type, int membase, int irq, char *id, int card_id)
-{
-	eicon_card *p;
-	eicon_card *q = NULL;
-	int registered;
-	int added = 0;
-	int failed = 0;
-
-#ifdef CONFIG_ISDN_DRV_EICON_ISA
-	if (!Type) /* ISA */
-		if ((Type = eicon_isa_find_card(membase, irq, id)) < 0)
-			return 0;
-#endif
-	eicon_alloccard(Type, membase, irq, id, card_id);
-        p = cards;
-        while (p) {
-		registered = 0;
-		if (!p->interface.statcallb) {
-			/* Not yet registered.
-			 * Try to register and activate it.
-			 */
-			added++;
-			switch (p->bus) {
-#ifdef CONFIG_ISDN_DRV_EICON_ISA
-				case EICON_BUS_ISA:
-				case EICON_BUS_MCA:
-					if (eicon_registercard(p))
-						break;
-					registered = 1;
-					break;
-#endif
-				case EICON_BUS_PCI:
-#ifdef CONFIG_PCI
-#ifdef CONFIG_ISDN_DRV_EICON_PCI
-					if (eicon_registercard(p))
-						break;
-					registered = 1;
-					break;
-#endif
-#endif
-				default:
-					printk(KERN_ERR
-					       "eicon: addcard: Invalid BUS type %d\n",
-					       p->bus);
-			}
-		} else
-			/* Card already registered */
-			registered = 1;
-                if (registered) {
-			/* Init OK, next card ... */
-                        q = p;
-                        p = p->next;
-                } else {
-                        /* registering failed, remove card from list, free memory */
-                        printk(KERN_ERR
-                               "eicon: Initialization of %s failed\n",
-                               p->interface.id);
-                        if (q) {
-                                q->next = p->next;
-                                eicon_freecard(p);
-                                p = q->next;
-                        } else {
-                                cards = p->next;
-                                eicon_freecard(p);
-                                p = cards;
-                        }
-			failed++;
-                }
-	}
-        return (added - failed);
-}
-
-
-static int __init
-eicon_init(void)
-{
-	int card_count = 0;
-	char tmprev[50];
-
-	DebugVar = 1;
-	eicon_lock = (spinlock_t) SPIN_LOCK_UNLOCKED;
-
-        printk(KERN_INFO "%s Rev: ", DRIVERNAME);
-	strcpy(tmprev, eicon_revision);
-	printk("%s/", eicon_getrev(tmprev));
-	strcpy(tmprev, eicon_pci_revision);
-#ifdef CONFIG_ISDN_DRV_EICON_PCI
-	printk("%s/", eicon_getrev(tmprev));
-#else
-	printk("---/");
-#endif
-	strcpy(tmprev, eicon_isa_revision);
-#ifdef CONFIG_ISDN_DRV_EICON_ISA
-	printk("%s/", eicon_getrev(tmprev));
-#else
-	printk("---/");
-#endif
-	strcpy(tmprev, eicon_idi_revision);
-	printk("%s\n", eicon_getrev(tmprev));
-        printk(KERN_INFO "%s Release: %s%s\n", DRIVERNAME,
-		DRIVERRELEASE, DRIVERPATCH);
-
-#ifdef CONFIG_ISDN_DRV_EICON_ISA
-#ifdef CONFIG_MCA
-	/* Check if we have MCA-bus */
-        if (!MCA_bus)
-                {
-                printk(KERN_INFO
-                        "eicon: No MCA bus, ISDN-interfaces  not probed.\n");
-        } else {
-		eicon_log(NULL, 8,
-			"eicon_mca_find_card, irq=%d.\n", 
-				irq);
-               	if (!eicon_mca_find_card(0, membase, irq, id))
-                       card_count++;
-        };
-#else
-	card_count = eicon_addcard(0, membase, irq, id, 0);
-#endif /* CONFIG_MCA */
-#endif /* CONFIG_ISDN_DRV_EICON_ISA */
- 
-#ifdef CONFIG_PCI
-#ifdef CONFIG_ISDN_DRV_EICON_PCI
-	DivasCardsDiscover();
-	card_count += eicon_pci_find_card(id);
-#endif
-#endif
-
-        if (!cards) {
-#ifdef MODULE
-#ifndef CONFIG_ISDN_DRV_EICON_PCI
-#ifndef CONFIG_ISDN_DRV_EICON_ISA
-                printk(KERN_INFO "Eicon: Driver is neither ISA nor PCI compiled !\n");
-                printk(KERN_INFO "Eicon: Driver not loaded !\n");
-#else
-                printk(KERN_INFO "Eicon: No cards defined, driver not loaded !\n");
-#endif
-#else
-                printk(KERN_INFO "Eicon: No PCI-cards found, driver not loaded !\n");
-#endif
-#endif /* MODULE */
-		return -ENODEV;
-
-	} else
-		printk(KERN_INFO "Eicon: %d card%s added\n", card_count, 
-                       (card_count>1)?"s":"");
-        return 0;
-}
-
-#ifdef CONFIG_ISDN_DRV_EICON_PCI
-void DIVA_DIDD_Write(DESCRIPTOR *, int);
-EXPORT_SYMBOL_NOVERS(DIVA_DIDD_Read);
-EXPORT_SYMBOL_NOVERS(DIVA_DIDD_Write);
-EXPORT_SYMBOL_NOVERS(DivasPrintf);
-#else
-int DivasCardNext;
-card_t DivasCards[1];
-#endif
-
-static void __exit
-eicon_exit(void)
-{
-#ifdef CONFIG_PCI	
-#ifdef CONFIG_ISDN_DRV_EICON_PCI
-	card_t *pCard;
-	word wCardIndex;
-	extern int Divas_major;
-	int iTmp = 0;
-#endif
-#endif
-	
-        eicon_card *card = cards;
-        eicon_card *last;
-
-        while (card) {
-#ifdef CONFIG_ISDN_DRV_EICON_ISA
-#ifdef CONFIG_MCA
-        	if (MCA_bus)
-                        {
-                        mca_mark_as_unused (card->mca_slot);
-                        mca_set_adapter_procfn(card->mca_slot, NULL, NULL);
-                        };
-#endif /* CONFIG_MCA */
-#endif
-                unregister_card(card); 
-                card = card->next;
-        }
-        card = cards;
-        while (card) {
-                last = card;
-                card = card->next;
-		eicon_freecard(last);
-        }
-
-#ifdef CONFIG_PCI	
-#ifdef CONFIG_ISDN_DRV_EICON_PCI
-	pCard = DivasCards;
-	for (wCardIndex = 0; wCardIndex < MAX_CARDS; wCardIndex++)
-	{
-		if ((pCard->hw) && (pCard->hw->in_use))
-		{
-			(*pCard->card_reset)(pCard);
-			
-			UxIsrRemove(pCard->hw, pCard);
-			UxCardHandleFree(pCard->hw);
-
-			if(pCard->e_tbl != NULL)
-			{
-				kfree(pCard->e_tbl);
-			}
-
-			if(pCard->hw->card_type == DIA_CARD_TYPE_DIVA_SERVER_B)
-			{
-				release_region(pCard->hw->io_base,0x20);
-				release_region(pCard->hw->reset_base,0x80);
-			}
-
-                        // If this is a 4BRI ...
-                        if (pCard->hw->card_type == DIA_CARD_TYPE_DIVA_SERVER_Q)
-                        {
-                                // Skip over the next 3 virtual adapters
-                                wCardIndex += 3;
-
-                                // But free their handles
-				for (iTmp = 0; iTmp < 3; iTmp++)
-				{
-					pCard++;
-					UxCardHandleFree(pCard->hw);
-
-					if(pCard->e_tbl != NULL)
-					{
-						kfree(pCard->e_tbl);
-					}
-				}
-                        }
-		}
-		pCard++;
-	}
-	unregister_chrdev(Divas_major, "Divas");
-#endif
-#endif /* CONFIG_PCI */
-        printk(KERN_INFO "%s unloaded\n", DRIVERNAME);
-}
-
-#ifndef MODULE
-
-static int __init
-eicon_setup(char *line)
-{
-        int i, argc;
-	int ints[5];
-	char *str;
-
-	str = get_options(line, 4, ints);
-
-        argc = ints[0];
-        i = 1;
-#ifdef CONFIG_ISDN_DRV_EICON_ISA
-        if (argc) {
-		membase = irq = -1;
-		if (argc) {
-			membase = ints[i];
-			i++;
-			argc--;
-		}
-		if (argc) {
-			irq = ints[i];
-			i++;
-			argc--;
-		}
-		if (strlen(str)) {
-			strcpy(id, str);
-		} else {
-			strcpy(id, "eicon");
-		} 
-       		printk(KERN_INFO "Eicon ISDN active driver setup (id=%s membase=0x%x irq=%d)\n",
-			id, membase, irq);
-	}
-#else
-	printk(KERN_INFO "Eicon ISDN active driver setup\n");
-#endif
-	return(1);
-}
-__setup("eicon=", eicon_setup);
-
-#endif /* MODULE */
-
-#ifdef CONFIG_ISDN_DRV_EICON_ISA
-#ifdef CONFIG_MCA
-
-struct eicon_mca_adapters_struct {
-	char * name;
-	int adf_id;
-};
-/* possible MCA-brands of eicon cards                                         */
-struct eicon_mca_adapters_struct eicon_mca_adapters[] = {
-	{ "ISDN-P/2 Adapter", 0x6abb },
-	{ "ISDN-[S|SX|SCOM]/2 Adapter", 0x6a93 },
-	{ "DIVA /MCA", 0x6336 },
-	{ NULL, 0 },
-};
-
-int eicon_mca_find_card(int type,          /* type-idx of eicon-card          */
-                        int membase,
-		        int irq,
-			char * id)         /* name of eicon-isdn-dev          */
-{
-	int j, curr_slot = 0;
-
-       	eicon_log(NULL, 8,
-		"eicon_mca_find_card type: %d, membase: %#x, irq %d \n",
-		type, membase, irq);
-	/* find a no-driver-assigned eicon card                               */
-	for (j=0; eicon_mca_adapters[j].adf_id != 0; j++) 
-		{
-		for ( curr_slot=0; curr_slot<=MCA_MAX_SLOT_NR; curr_slot++) 
-			{
-			curr_slot = mca_find_unused_adapter(
-				         eicon_mca_adapters[j].adf_id, curr_slot);
-			if (curr_slot != MCA_NOTFOUND) 
-				{
-				/* check if pre-set parameters match
-				   these of the card, check cards memory      */
-				if (!(int) eicon_mca_probe(curr_slot,
-                                                           j,
-                                                	   membase, 
-                                                           irq,
-                                                           id))
-					{
-					return 0;
-					/* means: adapter parms did match     */
-					};
-			};
-			break;
-			/* MCA_NOTFOUND-branch: no matching adapter of
-			   THIS flavor found, next flavor                     */
-
-            	};
-	};
-	/* all adapter flavors checked without match, finito with:            */
-        return -ENODEV;
-};
-
-
-/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- *  stolen from 3c523.c/elmc_getinfo, ewe, 10.5.1999 
- */
-int eicon_info(char * buf, int slot, void *d)
-{
-	int len = 0;
-	struct eicon_card *dev;
-
-        dev = (struct eicon_card *) d;
-
-	if (dev == NULL)
-		return len;
-	len += sprintf(buf+len, "eicon ISDN adapter, type %d.\n",dev->type);
-	len += sprintf(buf+len, "IRQ: %d\n", dev->hwif.isa.irq);
-	len += sprintf(buf+len, "MEMBASE: %#lx\n", (unsigned long)dev->hwif.isa.shmem);
-
-	return len;
-};
-
-int eicon_mca_probe(int slot,  /* slot-nr where the card was detected         */
-		    int a_idx, /* idx-nr of probed card in eicon_mca_adapters */
-                    int membase,
-                    int irq,
-		    char * id) /* name of eicon-isdn-dev                      */
-{				
-	unsigned char adf_pos0;
-	int cards_irq, cards_membase, cards_io;
-	int type = EICON_CTYPE_S;
-	int irq_array[]={0,3,4,2};
-	int irq_array1[]={3,4,0,0,2,10,11,12};
-
-        adf_pos0 = mca_read_stored_pos(slot,2);
-	eicon_log(NULL, 8,
-		"eicon_mca_probe irq=%d, membase=%d\n", 
-		irq,
-		membase);
-	switch (a_idx) {
-		case 0:                /* P/2-Adapter (== PRI/S2M ? )         */
-			cards_membase= 0xC0000+((adf_pos0>>4)*0x4000);
-			if (membase == -1) { 
-				membase = cards_membase;
-			} else {
-				if (membase != cards_membase)
-					return -ENODEV;
-			};
-			cards_irq=irq_array[((adf_pos0 & 0xC)>>2)];
-			if (irq == -1) { 
-				irq = cards_irq;
-			} else {
-				if (irq != cards_irq)
-					return -ENODEV;
-			};
-			cards_io= 0xC00 + ((adf_pos0>>4)*0x10);
-			type = EICON_CTYPE_ISAPRI; 
-			break;
-
-		case 1:                /* [S|SX|SCOM]/2                       */
-			cards_membase= 0xC0000+((adf_pos0>>4)*0x2000);
-			if (membase == -1) { 
-				membase = cards_membase;
-			} else {
-				if (membase != cards_membase)
-					return -ENODEV;
-			};
-			cards_irq=irq_array[((adf_pos0 & 0xC)>>2)];
-			if (irq == -1) { 
-				irq = cards_irq;
-			} else {
-				if (irq != cards_irq)
-					return -ENODEV;
-			};
-
-			cards_io= 0xC00 + ((adf_pos0>>4)*0x10);
-			type = EICON_CTYPE_SCOM; 
-		 	break;	
-
-		case 2:                /* DIVA/MCA                            */
-			cards_io = 0x200+ ((adf_pos0>>4)* 0x20);
-			cards_irq = irq_array1[(adf_pos0 & 0x7)];
-			if (irq == -1) { 
-				irq = cards_irq;
-			} else {
-				if (irq != cards_irq)
-					return -ENODEV;
-			};
-			type = 0; 
-			break;
-		default:
-			return -ENODEV;
-	};
-	/* matching membase & irq */
-	if ( 1 == eicon_addcard(type, membase, irq, id, 0)) { 
-		mca_set_adapter_name(slot, eicon_mca_adapters[a_idx].name);
-  		mca_set_adapter_procfn(slot, (MCA_ProcFn) eicon_info, cards);
-
-        	mca_mark_as_used(slot);
-		cards->mca_slot = slot; 
-		/* card->io noch setzen  oder ?? */
-		cards->mca_io = cards_io;
-		cards->hwif.isa.io = cards_io;
-		/* reset card */
-		outb_p(0,cards_io+1);
-
-		eicon_log(NULL, 8, "eicon_addcard: successful for slot # %d.\n", 
-			cards->mca_slot+1);
-		return  0 ; /* eicon_addcard added a card */
-	} else {
-		return -ENODEV;
-	};
-};
-#endif /* CONFIG_MCA */
-#endif /* CONFIG_ISDN_DRV_EICON_ISA */
-
-module_init(eicon_init);
-module_exit(eicon_exit);
diff -puN -L drivers/isdn/eicon/eicon_pci.c drivers/isdn/eicon/eicon_pci.c~linus /dev/null
--- 25/drivers/isdn/eicon/eicon_pci.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,109 +0,0 @@
-/* $Id: eicon_pci.c,v 1.1.4.1.2.3 2002/10/01 11:29:13 armin Exp $
- *
- * ISDN low-level module for Eicon active ISDN-Cards.
- * Hardware-specific code for PCI cards.
- *
- * Copyright 1998-2000 by Armin Schindler (mac@melware.de)
- * Copyright 1999,2000 Cytronics & Melware (info@melware.de)
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- * Thanks to	Eicon Networks for 
- *		documents, informations and hardware. 
- *
- */
-
-#include <linux/config.h>
-#include <linux/pci.h>
-
-#include "eicon.h"
-#include "eicon_pci.h"
-
-#undef N_DATA
-#include "adapter.h"
-#include "uxio.h"
-
-char *eicon_pci_revision = "$Revision: 1.1.4.1.2.3 $";
-
-#ifdef CONFIG_PCI	         /* entire stuff is only for PCI */
-#ifdef CONFIG_ISDN_DRV_EICON_PCI
-
-int eicon_pci_find_card(char *ID)
-{
-	int pci_cards = 0;
-	int card_id = 0;
-	int had_q = 0;
-	int ctype = 0;
-	char did[20];
-	card_t *pCard;
-	word wCardIndex;
-
-	pCard = DivasCards;
-	for (wCardIndex = 0; wCardIndex < MAX_CARDS; wCardIndex++)
-	{
-	if ((pCard->hw) && (pCard->hw->in_use))
-		{
-			switch(pCard->hw->card_type) {
-				case DIA_CARD_TYPE_DIVA_SERVER:
-					ctype = EICON_CTYPE_MAESTRAP;
-					card_id++;
-					had_q = 0;
-					break;
-				case DIA_CARD_TYPE_DIVA_SERVER_B:
-					ctype = EICON_CTYPE_MAESTRA;
-					card_id++;
-					had_q = 0;
-					break;
-				case DIA_CARD_TYPE_DIVA_SERVER_Q:
-					ctype = EICON_CTYPE_MAESTRAQ;
-					if (!had_q)
-						card_id++;
-					if (++had_q >=4)
-						had_q = 0;
-					break;
-				default:
-					printk(KERN_ERR "eicon_pci: unknown card type %d !\n",
-						pCard->hw->card_type);
-					goto err;
-			}
-			sprintf(did, "%s%d", (strlen(ID) < 1) ? "eicon":ID, pci_cards);
-			if ((!ctype) || (!(eicon_addcard(ctype, 0, pCard->hw->irq, did, card_id)))) {
-				printk(KERN_ERR "eicon_pci: Card could not be added !\n");
-			} else {
-				pci_cards++;
-				printk(KERN_INFO "%s: DriverID='%s' CardID=%d\n",
-					eicon_ctype_name[ctype], did, card_id);
-			}
-err:;
-		}
-		pCard++;
-	}
-	return pci_cards;
-}
-
-void
-eicon_pci_init_conf(eicon_card *card)
-{
-	int j;
-
-	/* initializing some variables */
-	card->ReadyInt = 0;
-
-	for(j = 0; j < 256; j++)
-		card->IdTable[j] = NULL;
-
-	for(j = 0; j < (card->d->channels + 1); j++) {
-		card->bch[j].e.busy = 0;
-		card->bch[j].e.D3Id = 0;
-		card->bch[j].e.B2Id = 0;
-		card->bch[j].e.ref = 0;
-		card->bch[j].e.Req = 0;
-		card->bch[j].e.complete = 1;
-		card->bch[j].fsm_state = EICON_STATE_NULL;
-	}
-}
-
-#endif
-#endif	/* CONFIG_PCI */
-
diff -puN -L drivers/isdn/eicon/eicon_pci.h drivers/isdn/eicon/eicon_pci.h~linus /dev/null
--- 25/drivers/isdn/eicon/eicon_pci.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,34 +0,0 @@
-/* $Id: eicon_pci.h,v 1.1.4.1.2.2 2002/10/01 11:29:13 armin Exp $
- *
- * ISDN low-level module for Eicon active ISDN-Cards (PCI part).
- *
- * Copyright 1998-2000 by Armin Schindler (mac@melware.de)
- * Copyright 1999,2000 Cytronics & Melware (info@melware.de)
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#ifndef eicon_pci_h
-#define eicon_pci_h
-
-#ifdef __KERNEL__
-
-/*
- * card's description
- */
-typedef struct {
-	int   		  irq;	    /* IRQ		          */
-	int		  channels; /* No. of supported channels  */
-        void*             card;
-        unsigned char     type;     /* card type                  */
-        unsigned char     master;   /* Flag: Card is Quadro 1/4   */
-} eicon_pci_card;
-
-extern int eicon_pci_find_card(char *ID);
-
-#endif  /* __KERNEL__ */
-
-#endif	/* eicon_pci_h */
-
diff -puN -L drivers/isdn/eicon/fourbri.c drivers/isdn/eicon/fourbri.c~linus /dev/null
--- 25/drivers/isdn/eicon/fourbri.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,560 +0,0 @@
-/*
- * Diva Server 4BRI specific part of initialisation
- *
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.7  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#include "sys.h"
-#include "idi.h"
-#include "divas.h"
-#include "pc.h"
-#include "pr_pc.h"
-#include "dsp_defs.h"
-#include "constant.h"
-#include "adapter.h"
-#include "uxio.h"
-
-#define TEST_INT_DIVAS_Q	0x13
-
-#define	DIVAS_MAINT_OFFSET	0xff00	/* value for 4BRI card */
-#define MQ_BOARD_DSP_OFFSET 0x00a00000
-#define MQ_DSP1_ADDR_OFFSET 0x00000008
-#define MQ_DSP_JUNK_OFFSET  0x00000400
-#define MQ_DSP1_DATA_OFFSET 0x00000000
-#define MQ_BOARD_ISAC_DSP_RESET  0x00800028
-#define MQ_BREG_RISC  0x1200      /* RISC Reset */
-#define MQ_ISAC_DSP_RESET 0x0028 /* ISAC and DSP reset address offset */
-#define MQ_RISC_COLD_RESET_MASK         0x0001      /* RISC Cold reset                        */
-#define MQ_RISC_WARM_RESET_MASK         0x0002      /* RISC Warm reset                        */
-#define MQ_IRQ_REQ_ON                   0x1
-#define MQ_IRQ_REQ_OFF                  0x0
-#define MQ_BREG_IRQ_TEST                0x0608
-#define PLX9054_INTCSR      0x69 
-#define PLX9054_INT_ENA     0x09
-
-#define DIVAS_IOBASE	0x01
-#define M_PCI_RESET	0x10
-
-byte mem_in(ADAPTER *a, void *adr);
-word mem_inw(ADAPTER *a, void *adr);
-void mem_in_buffer(ADAPTER *a, void *adr, void *P, word length);
-void mem_look_ahead(ADAPTER *a, PBUFFER *RBuffer, ENTITY *e);
-void mem_out(ADAPTER *a, void *adr, byte data);
-void mem_outw(ADAPTER *a, void *adr, word data);
-void mem_out_buffer(ADAPTER *a, void *adr, void *P, word length);
-void mem_inc(ADAPTER *a, void *adr);
-
-int Divas4BRIInitPCI(card_t *card, dia_card_t *cfg);
-static int fourbri_ISR (card_t* card);
-
-int FPGA_Download(word, dword, byte *, byte *, int);
-extern byte FPGA_Bytes[];
-extern void *get_card(int);
-
-byte UxCardPortIoIn(ux_diva_card_t *card, byte *base, int offset);
-void UxCardPortIoOut(ux_diva_card_t *card, byte *base, int offset, byte);
-word GetProtFeatureValue(char *sw_id);
-
-void memcp(byte *dst, byte *src, dword dwLen);
-int memcm(byte *dst, byte *src, dword dwLen);
-
-static int diva_server_4bri_reset(card_t *card)
-{
-	byte *ctl;
-
-	DPRINTF(("divas: reset Diva Server 4BRI"));
-
-	ctl = UxCardMemAttach(card->hw, DIVAS_CTL_MEMORY);
-
-	/* stop RISC, DSP's and ISAC  */
-   UxCardMemOut(card->hw, &ctl[MQ_BREG_RISC], 0);
-   UxCardMemOut(card->hw, &ctl[MQ_ISAC_DSP_RESET], 0);
-
-	UxCardMemDetach(card->hw, ctl);
-
-	return 0;
-}
-
-static int diva_server_4bri_config(card_t *card, dia_config_t *config)
-{
-	byte *shared;
-	int i, j;
-
-	DPRINTF(("divas: configure Diva Server 4BRI"));
-
-	shared = (byte *) UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY);
-	
-	for (i=0; i<256; i++)
-	{
-		UxCardMemOut(card->hw, &shared[i], 0);
-	}
-
-	UxCardMemOut(card->hw, &shared[ 8], config->tei);
-	UxCardMemOut(card->hw, &shared[ 9], config->nt2);
-	UxCardMemOut(card->hw, &shared[10], config->sig_flags);
-	UxCardMemOut(card->hw, &shared[11], config->watchdog);
-	UxCardMemOut(card->hw, &shared[12], config->permanent);
-	UxCardMemOut(card->hw, &shared[13], config->x_interface);
-	UxCardMemOut(card->hw, &shared[14], config->stable_l2);
-	UxCardMemOut(card->hw, &shared[15], config->no_order_check);
-	UxCardMemOut(card->hw, &shared[16], config->handset_type);
-	UxCardMemOut(card->hw, &shared[17], 0);
-	UxCardMemOut(card->hw, &shared[18], config->low_channel);
-	UxCardMemOut(card->hw, &shared[19], config->prot_version);
-	UxCardMemOut(card->hw, &shared[20], config->crc4);
-
-	if ((card->hw->features) && (card->hw->features & PROTCAP_V90D))
-	{
-		DPRINTF(("divas: Signifying V.90"));
-		UxCardMemOut(card->hw, &shared[22], 4);
-	}
-	else
-	{
-		UxCardMemOut(card->hw, &shared[22], 0);
-	}
-
-	for (i=0; i<2; i++)
-	{
-		for (j=0; j<32; j++)
-		{
-			UxCardMemOut(card->hw, &shared[32+(i*96)+j],config->terminal[i].oad[j]);
-		}
-
-		for (j=0; j<32; j++)
-		{
-			UxCardMemOut(card->hw, &shared[64+(i*96)+j],config->terminal[i].osa[j]);
-		}
-
-		for (j=0; j<32; j++)
-		{
-			UxCardMemOut(card->hw, &shared[96+(i*96)+j],config->terminal[i].spid[j]);
-		}
-	}
-
-	UxCardMemDetach(card->hw, shared);
-
-	return 0;
-}
-
-static
-void diva_server_4bri_reset_int(card_t *card)
-{
-	byte *ctl;
-
-	ctl = UxCardMemAttach(card->hw, DIVAS_CTL_MEMORY);
-
-	UxCardMemOut(card->hw, &ctl[MQ_BREG_IRQ_TEST], MQ_IRQ_REQ_OFF);
-
-	UxCardMemDetach(card->hw, ctl);
-
-	return;
-}
-
- 
-static int diva_server_4bri_test_int(card_t *card)
-{
-	byte *ctl, i;
-	byte *reg;
-
-	DPRINTF(("divas: test interrupt for Diva Server 4BRI"));
-
-	/* We get the last (dummy) adapter in so we need to go back to the first */
-
-	card = get_card(card->cfg.card_id - 3);
-
-	/* Enable interrupts on PLX chip */
-
-	reg = UxCardMemAttach(card->hw, DIVAS_REG_MEMORY);
-
-	UxCardPortIoOut(card->hw, reg, PLX9054_INTCSR, PLX9054_INT_ENA);
-
-	UxCardMemDetach(card->hw, reg);
-
-	/* Set the test interrupt flag */
-	card->test_int_pend = TEST_INT_DIVAS_Q;
-
-	/* Now to trigger the interrupt */
-
-	ctl = UxCardMemAttach(card->hw, DIVAS_CTL_MEMORY);
-
-	UxCardMemOut(card->hw, &ctl[MQ_BREG_IRQ_TEST], MQ_IRQ_REQ_ON);
-
-	UxCardMemDetach(card->hw, ctl);
-
-	for (i = 0; i < 50; i++)
-	{
-		if (!card->test_int_pend)
-		{
-			break;
-		}
-		UxPause(10);
-	}
-
-	if (card->test_int_pend)
-	{
-		DPRINTF(("active: timeout waiting for card to interrupt"));
-		return (-1);
-	}
-	
-	return 0;
-}
-
-
-static void print_hdr(unsigned char *code, int offset)
-{
-	unsigned char hdr[80];
-	int i;
-
-	i = 0;
-
-	while ((i < (DIM(hdr) -1)) && 
-		(code[offset + i] != '\0') &&
-		(code[offset + i] != '\r') &&
-		(code[offset + i] != '\n'))
-	{
-		hdr[i] = code[offset + i];
-		i++;
-	}
-
-	hdr[i] = '\0';
-
-	DPRINTF(("divas: loading %s", hdr));
-}
-
-static int diva_server_4bri_load(card_t *card, dia_load_t *load)
-{
-	byte *pRAM=NULL;
-	int download_offset=0;
-	card_t *FirstCard;
-	byte sw_id[80];
-
-	DPRINTF(("divas: loading Diva Server 4BRI[%d]", load->card_id));
-
-	switch(load->code_type)
-	{
-		case DIA_CPU_CODE:
-			DPRINTF(("divas: RISC code"));
-			print_hdr(load->code, 0x80);
-			card->hw->features = GetProtFeatureValue((char *)&load->code[0x80]);
-			download_offset = 0; // Protocol code written to offset 0
-			pRAM = UxCardMemAttach(card->hw, DIVAS_RAM_MEMORY);
-			break;
-
-		case DIA_DSP_CODE:
-			DPRINTF(("divas: DSP code"));
-			print_hdr(load->code, 0x0); 
-			FirstCard = get_card(load->card_id - 3);
-			if ((card->hw->features) && (card->hw->features & PROTCAP_V90D))
-			{
-				download_offset = MQ_V90D_DSP_CODE_BASE;
-			}
-			else
-			{
-				download_offset = MQ_ORG_DSP_CODE_BASE;
-			}
-			pRAM = UxCardMemAttach(FirstCard->hw, DIVAS_RAM_MEMORY);
-			download_offset += (((sizeof(dword) + (sizeof(t_dsp_download_desc)* DSP_MAX_DOWNLOAD_COUNT)) + 3) & 0xFFFFFFFC);
-
-			break;
-
-		case DIA_TABLE_CODE:
-			DPRINTF(("divas: TABLE code"));
-			FirstCard = get_card(load->card_id - 3);
-			if ((card->hw->features) && (card->hw->features & PROTCAP_V90D))
-			{
-				download_offset = MQ_V90D_DSP_CODE_BASE + sizeof(dword);
-			}
-			else
-			{
-				download_offset = MQ_ORG_DSP_CODE_BASE + sizeof(dword);
-			}
-			pRAM = UxCardMemAttach(FirstCard->hw, DIVAS_RAM_MEMORY);
-			break;
-
-		case DIA_CONT_CODE:
-			DPRINTF(("divas: continuation code"));
-			break;
-
-        case DIA_DLOAD_CNT:
-			DPRINTF(("divas: COUNT code"));
-			FirstCard = get_card(load->card_id - 3);
-			if ((card->hw->features) && (card->hw->features & PROTCAP_V90D))
-			{
-				download_offset = MQ_V90D_DSP_CODE_BASE;
-			}
-			else
-			{
-				download_offset = MQ_ORG_DSP_CODE_BASE;
-			}
-			pRAM = UxCardMemAttach(FirstCard->hw, DIVAS_RAM_MEMORY);
-			break;
-
-		case DIA_FPGA_CODE:
-			DPRINTF(("divas: 4BRI FPGA download - %d bytes", load->length));
-			if (FPGA_Download(IDI_ADAPTER_MAESTRAQ,
- 			card->hw->io_base,
-			 sw_id,
-			 load->code,
-			 load->length
-			) == -1)
-			{
-				DPRINTF(("divas: FPGA download failed"));
-				return -1;
-			}
-
-			/* NOW reset the 4BRI */
-			diva_server_4bri_reset(card);
-			return 0; // No need for anything further loading
-
-		default:
-			DPRINTF(("divas: unknown code type"));
-			return -1;
-	}
-
-   memcp(pRAM + (download_offset & 0x3FFFFF), load->code, load->length);
-
-	{
-		int mism_off;
-	if ((mism_off = memcm(pRAM + (download_offset & 0x3FFFFF), load->code, load->length)))
-	{
-		DPRINTF(("divas: memory mismatch at offset %d", mism_off));
-		UxCardMemDetach(card->hw, pRAM);
-		return -1;
-	}
-	}
-
-	UxCardMemDetach(card->hw, pRAM);
-
-	return 0;
-}
-
-static int diva_server_4bri_start(card_t *card, byte *channels)
-{
-	byte *ctl;
-	byte *shared, i;
-	int adapter_num;
-
-	DPRINTF(("divas: start Diva Server 4BRI"));
-	*channels = 0;
-	card->is_live = FALSE;
-
-	ctl = UxCardMemAttach(card->hw, DIVAS_CTL_MEMORY);
-
-	UxCardMemOutW(card->hw, &ctl[MQ_BREG_RISC], MQ_RISC_COLD_RESET_MASK);
-
-	UxPause(2);
-
-	UxCardMemOutW(card->hw, &ctl[MQ_BREG_RISC], MQ_RISC_WARM_RESET_MASK | MQ_RISC_COLD_RESET_MASK);
-
-	UxPause(10);
-	
-	UxCardMemDetach(card->hw, ctl);
-
-	shared = (byte *) UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY);
-
-	for ( i = 0 ; i < 300 ; ++i )
-	{
-		UxPause (10) ;
-
-		if ( UxCardMemInW(card->hw, &shared[0x1E]) == 0x4447 )
-		{
-			DPRINTF(("divas: Protocol startup time %d.%02d seconds",
-			         (i / 100), (i % 100) ));
-
-			break;
-		}
-	}
-
-	if (i==300)
-	{
-		DPRINTF(("divas: Timeout starting card"));
-		DPRINTF(("divas: Signature == 0x%04X", UxCardMemInW(card->hw, &shared[0x1E])));
-
-		UxCardMemDetach(card->hw, shared);
-		return -1;
-	}
-
-	UxCardMemDetach(card->hw, shared);
-
-	for (adapter_num=3; adapter_num >= 0; adapter_num--)
-	{
-		card_t *qbri_card;
-
-		qbri_card = get_card(card->cfg.card_id - adapter_num);
-
-		if (qbri_card)
-		{
-			qbri_card->is_live = TRUE;
-			shared = UxCardMemAttach(qbri_card->hw, DIVAS_SHARED_MEMORY);
-			*channels += UxCardMemIn(qbri_card->hw, &shared[0x3F6]);
-			UxCardMemDetach(qbri_card->hw, shared);
-		}
-		else
-		{
-			DPRINTF(("divas: Couldn't get card info %d", card->cfg.card_id));
-		}
-	}
-
-	diva_server_4bri_test_int(card);
-
-	return 0;
-}
-
-static
-int 	diva_server_4bri_mem_get(card_t *card, mem_block_t *mem_block)
-
-{
-	byte	*a;
-	byte	*card_addr;
-	word	length = 0;
-	int		i;
-
-	a = UxCardMemAttach(card->hw, DIVAS_RAM_MEMORY);
-
-	card_addr = a;
-	card_addr += mem_block->addr;
-
-	for (i=0; i < sizeof(mem_block->data); i++)
-	{
-		mem_block->data[i] = UxCardMemIn(card->hw, card_addr);
-		card_addr++;
-		length++;
-	}
-
-	UxCardMemDetach(card->hw, a);
-
-	return length;
-}
-
-/*
- * Initialise 4BRI specific entry points
- */
-
-int Divas4BriInit(card_t *card, dia_card_t *cfg)
-{
-//	byte sw_id[80];
-//	extern int FPGA_Done;
-
-	DPRINTF(("divas: initialise Diva Server 4BRI"));
-
-	if (Divas4BRIInitPCI(card, cfg) == -1)
-	{
-		return -1;
-	}
-
-	/* Need to download the FPGA */
-/*	if (!FPGA_Done)
-	{
-		int retVal;
-
-		retVal=FPGA_Download(IDI_ADAPTER_MAESTRAQ,
- 			cfg->io_base,
-			 sw_id,
-			 FPGA_Bytes
-			);
-		if(retVal==-1)
-		{
-		
-			DPRINTF(("divas: FPGA Download Failed"));
-			return -1;
-
-		}
-		FPGA_Done = 1;
-	} */
-
-	card->card_reset = diva_server_4bri_reset;
-	card->card_load = diva_server_4bri_load;
-	card->card_config = diva_server_4bri_config;
-	card->card_start = diva_server_4bri_start;
-	card->reset_int = diva_server_4bri_reset_int;
-	card->card_mem_get = diva_server_4bri_mem_get;
-
-	card->xlog_offset = DIVAS_MAINT_OFFSET;
-
-	card->out = DivasOut;
-	card->test_int = DivasTestInt;
-	card->dpc = DivasDpc;
-	card->clear_int = DivasClearInt;
-	card->card_isr = fourbri_ISR;
-
-	card->a.ram_out = mem_out;
-	card->a.ram_outw = mem_outw;
-	card->a.ram_out_buffer = mem_out_buffer;
-	card->a.ram_inc = mem_inc;
-
-	card->a.ram_in = mem_in;
-	card->a.ram_inw = mem_inw;
-	card->a.ram_in_buffer = mem_in_buffer;
-	card->a.ram_look_ahead = mem_look_ahead;
-
-	return 0;
-}
-
-void memcp(byte *dst, byte *src, dword dwLen)
-{
-	while (dwLen)
-	{
-		*dst = *src;
-		dst++; src++;
-		dwLen--;
-	}
-}
-
-int memcm(byte *dst, byte *src, dword dwLen)
-{
-	int offset = 0;
-
-	while (offset < dwLen)
-	{
-		if(*dst != *src)
-			return (offset+1);
-
-		offset++;
-		src++;
-		dst++;
-	}
-
-	return 0;
-}
-
-
-
-/*int fourbri_ISR (card_t* card) 
-{
-	int served = 0;
-	byte *DivasIOBase = UxCardMemAttach(card->hw, DIVAS_IOBASE);
-	
-
-	if (UxCardPortIoIn (card->hw, DivasIOBase, M_PCI_RESET) & 0x01) 
-	{
-		served = 1;
-		card->int_pend  += 1;
-		DivasDpcSchedule(); 
-		UxCardPortIoOut (card->hw, DivasIOBase, M_PCI_RESET, 0x08);
-	}
-
-	UxCardMemDetach(card->hw, DivasIOBase);
-
-	return (served != 0);
-}*/
-
-
-static int fourbri_ISR (card_t* card) 
-{
-	byte *ctl;
-
-	card->int_pend  += 1;
-	DivasDpcSchedule(); /* ISR DPC */
-
-	ctl = UxCardMemAttach(card->hw, DIVAS_CTL_MEMORY);
-	UxCardMemOut(card->hw, &ctl[MQ_BREG_IRQ_TEST], MQ_IRQ_REQ_OFF);
-	UxCardMemDetach(card->hw, ctl);
-
-	return (1);
-}
diff -puN -L drivers/isdn/eicon/fpga.c drivers/isdn/eicon/fpga.c~linus /dev/null
--- 25/drivers/isdn/eicon/fpga.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.2  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#include "sys.h"
-#include "idi.h"
-#include "uxio.h"
-
-#define FPGA_PORT		0x6E
-#define FPGA_DLOAD_BUFLEN   	256
-#define NAME_OFFSET         	0x10
-#define NAME_MAXLEN         	12
-#define DATE_OFFSET         	0x2c
-#define DATE_MAXLEN         	10
-
-word UxCardPortIoInW(ux_diva_card_t *card, byte *base, int offset);
-void UxCardPortIoOutW(ux_diva_card_t *card, byte *base, int offset, word);
-void UxPause(long int);
-
-/*-------------------------------------------------------------------------*/
-/* Loads the FPGA configuration file onto the hardware.                    */
-/* Function returns 0 on success, else an error number.                    */
-/* On success, an identifier string is returned in the buffer              */
-/*                                                                         */
-/* A buffer of FPGA_BUFSIZE, a handle to the already opened bitstream      */
-/* file and a file read function has to be provided by the operating       */
-/* system part.                                                            */
-/* ----------------------------------------------------------------------- */
-int FPGA_Download( word      cardtype,
-                        dword     RegBase,
-                        byte *strbuf,
-                        byte FPGA_SRC[],
-			int FPGA_LEN
-                      )
-{
-  word        i, j, k;
-  word        baseval, Mask_PROGRAM, Mask_DONE, Mask_CCLK, Mask_DIN;
-  dword       addr;
-  byte        *pFPGA;
-
-  //--- check for legal cardtype
-  switch (cardtype)
-  {
-    case IDI_ADAPTER_MAESTRAQ:
-      addr          = RegBase ; // address where to access FPGA
-      Mask_PROGRAM  = 0x0001;         // FPGA pins at address
-      Mask_DONE     = 0x0002;
-      Mask_CCLK     = 0x0100;
-      Mask_DIN      = 0x0400;
-      baseval       = 0x000d;         // PROGRAM hi, CCLK lo, DIN lo by default
-    break;
-      
-    default:
-	
-  	DPRINTF(("divas: FPGA Download ,Illegal Card"));
-      	return -1; // illegal card 
-  }
-
-  //--- generate id string from file content
-  for (j=NAME_OFFSET, k=0; j<(NAME_OFFSET+NAME_MAXLEN); j++, k++) //name
-  {
-    if (!FPGA_SRC[j]) break;
-    strbuf[k] = FPGA_SRC[j];
-  } 
-  strbuf[k++] = ' ';
-  for (j=DATE_OFFSET; j<(DATE_OFFSET+DATE_MAXLEN); j++, k++) // date
-  {
-    if (!FPGA_SRC[j]) break;
-    strbuf[k] = FPGA_SRC[j];
-  } 
-  strbuf[k] = 0;
-
-  DPRINTF(("divas: FPGA Download - %s", strbuf));
-
-  //--- prepare download, Pulse PROGRAM pin down.
-  UxCardPortIoOutW(NULL, (byte *) addr, FPGA_PORT, baseval &~Mask_PROGRAM);  // PROGRAM low pulse
-  UxCardPortIoOutW(NULL, (byte *) addr, FPGA_PORT, baseval);                 // release
-  UxPause(50);  // wait until FPGA finised internal memory clear
-  
-  //--- check done pin, must be low
-  if (UxCardPortIoInW(NULL, (byte *) addr, FPGA_PORT) &Mask_DONE) 
-  {
-    DPRINTF(("divas: FPGA_ERR_DONE_WRONG_LEVEL"));
-    return -1;
-  }
-
-  pFPGA = FPGA_SRC;
-
-  i = 0; 
-  /* Move past the header */
-  while ((FPGA_SRC[i] != 0xFF) && (i < FPGA_LEN)) 
-  {
-    i++;
-  }
-
-  // We've hit the 0xFF so move on to the next byte
-  // i++;
-  DPRINTF(("divas: FPGA Code starts at offset %d", i));
-
-  //--- put data onto the FPGA
-  for (;i<FPGA_LEN; i++)
-  {
-    //--- put byte onto FPGA
-    for (j=0; j<8; j++)
-    {
-      if (FPGA_SRC[i] &(0x80>>j)) baseval |= Mask_DIN; // write a hi
-      else                      baseval &=~Mask_DIN; // write a lo
-      UxCardPortIoOutW(NULL, (byte *) addr, FPGA_PORT, baseval);
-      UxCardPortIoOutW(NULL, (byte *) addr, FPGA_PORT, baseval | Mask_CCLK);     // set CCLK hi
-      UxCardPortIoOutW(NULL, (byte *) addr, FPGA_PORT, baseval);                 // set CCLK lo
-    }
-  }
-
-  //--- add some additional startup clock cycles and check done pin
-  for (i=0; i<5; i++) 
-  {
-    UxCardPortIoOutW(NULL, (byte *) addr, FPGA_PORT, baseval | Mask_CCLK);     // set CCLK hi
-    UxCardPortIoOutW(NULL, (byte *) addr, FPGA_PORT, baseval);                 // set CCLK lo
-  }
-
-  UxPause(100);
-
-  if (UxCardPortIoInW(NULL, (byte *) addr, FPGA_PORT) &Mask_DONE) 
-  {
-    DPRINTF(("divas: FPGA download successful"));
-  }
-  else
-  {
-    DPRINTF(("divas: FPGA download failed - 0x%x", UxCardPortIoInW(NULL, (byte *) addr, FPGA_PORT)));
-	return -1;
-  }
-
-return 0;
-}
-
diff -puN -L drivers/isdn/eicon/idi.c drivers/isdn/eicon/idi.c~linus /dev/null
--- 25/drivers/isdn/eicon/idi.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,854 +0,0 @@
-/*
- * Core driver for Diva Server cards
- * Implements the IDI interface
- *
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.8  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#include "idi.h"
-#include "adapter.h"
-#include "pc.h"
-#include "pr_pc.h"
-#include "sys.h"
-#include "uxio.h"
-
-/* IDI request functions */
-
-static void	request(card_t *card, ENTITY *e);
-
-static void req_0(ENTITY *e)	{ request(&DivasCards[ 0], e); }
-static void req_1(ENTITY *e)	{ request(&DivasCards[ 1], e); }
-static void req_2(ENTITY *e)	{ request(&DivasCards[ 2], e); }
-static void req_3(ENTITY *e)	{ request(&DivasCards[ 3], e); }
-static void req_4(ENTITY *e)	{ request(&DivasCards[ 4], e); }
-static void req_5(ENTITY *e)	{ request(&DivasCards[ 5], e); }
-static void req_6(ENTITY *e)	{ request(&DivasCards[ 6], e); }
-static void req_7(ENTITY *e)	{ request(&DivasCards[ 7], e); }
-static void req_8(ENTITY *e)	{ request(&DivasCards[ 8], e); }
-static void req_9(ENTITY *e)	{ request(&DivasCards[ 9], e); }
-static void req_10(ENTITY *e)	{ request(&DivasCards[10], e); }
-static void req_11(ENTITY *e)	{ request(&DivasCards[11], e); }
-static void req_12(ENTITY *e)	{ request(&DivasCards[12], e); }
-static void req_13(ENTITY *e)	{ request(&DivasCards[13], e); }
-static void req_14(ENTITY *e)	{ request(&DivasCards[14], e); }
-static void req_15(ENTITY *e)	{ request(&DivasCards[15], e); }
-
-IDI_CALL DivasIdiRequest[16] =
-{
-    &req_0,		&req_1,		&req_2,		&req_3,
-    &req_4,		&req_5,		&req_6,		&req_7,
-    &req_8,		&req_9,		&req_10,	&req_11,
-	&req_12,	&req_13,	&req_14,	&req_15
-};
-
-#define PR_RAM  ((struct pr_ram *)0)
-#define RAM ((struct dual *)0)
-
-/*------------------------------------------------------------------*/
-/* local function prototypes                                        */
-/*------------------------------------------------------------------*/
-
-static byte isdn_rc(ADAPTER *, byte, byte, byte, word);
-static byte isdn_ind(ADAPTER *, byte, byte, byte, PBUFFER *, byte, word);
-
-/*
- * IDI related functions
- */
-
-static
-ENTITY	*entity_ptr(ADAPTER *a, byte e_no)
-{
-	card_t	*card;
-
-	card = a->io;
-
-	return card->e_tbl[e_no].e;
-}
-
-static
-void	CALLBACK(ADAPTER *a, ENTITY *e)
-{
-	card_t	*card = a->io;
-
-	if (card->log_types & DIVAS_LOG_IDI)
-	{
-		DivasLogIdi(card, e, FALSE);
-	}
-
-	(*e->callback)(e);
-}
-
-static
-void	*PTR_P(ADAPTER *a, ENTITY *e, void *P)
-{
-	return(P);
-}
-
-static
-void	*PTR_R(ADAPTER *a, ENTITY *e)
-{
-	return((void*)e->R);
-}
-
-static
-void	*PTR_X(ADAPTER *a, ENTITY *e)
-{
-	return((void*)e->X);
-}
-
-static
-void	free_entity(ADAPTER *a, byte e_no) 
-{
-	card_t	*card;
-	int		ipl;
-
-	card = a->io;
-
-	ipl = UxCardLock(card->hw);
-
-	card->e_tbl[e_no].e = NULL;
-	card->e_count--;
-
-	UxCardUnlock(card->hw, ipl);
-
-	return;
-}
-
-static
-void	assign_queue(ADAPTER * a, byte e_no, word ref)
-{
-	card_t	*card;
-	int		ipl;
-
-	card = a->io;
-
-	ipl = UxCardLock(card->hw);
-
-	card->e_tbl[e_no].assign_ref = ref;
-	card->e_tbl[e_no].next = card->assign;
-	card->assign = e_no;
-
-	UxCardUnlock(card->hw, ipl);
-
-	return;
-}
-
-static
-byte	get_assign(ADAPTER *a, word ref)
-{
-	card_t	*card;
-	byte	e_no;
-	int		ipl;
-
-	card = a->io;
-
-	ipl = UxCardLock(card->hw);
-
-	e_no = (byte)card->assign;
-	while (e_no)
-	{
-		if (card->e_tbl[e_no].assign_ref == ref)
-		{
-			break;
-		}
-		e_no = card->e_tbl[e_no].next;
-	}
-
-	UxCardUnlock(card->hw, ipl);
-
-	return e_no;
-}
-
-static
-void	req_queue(ADAPTER * a, byte e_no)
-{
-	card_t	*card;
-	int		ipl;
-
-	card = a->io;
-
-	ipl = UxCardLock(card->hw);
-
-	card->e_tbl[e_no].next = 0;
-
-	if (card->e_head)
-	{
-		card->e_tbl[card->e_tail].next = e_no;
-		card->e_tail = e_no;
-	}
-	else
-	{
-		card->e_head = e_no;
-		card->e_tail = e_no;
-	}
-
-	UxCardUnlock(card->hw, ipl);
-
-	return;
-}
-
-static
-byte	look_req(ADAPTER * a)
-{
-	card_t	*card;
-
-	card = a->io;
-
-	return(card->e_head);
-}
-
-static
-void	next_req(ADAPTER * a)
-{
-	card_t	*card;
-	int		ipl;
-
-
-	card = a->io;
-
-	ipl = UxCardLock(card->hw);
-
-	card->e_head = card->e_tbl[card->e_head].next;
-	if (!card->e_head)
-	{
-		card->e_tail = 0;
-	}
-
-	UxCardUnlock(card->hw, ipl);
-
-	return;
-}
-
-
-/*
- * IDI request function for active cards
- */
-static
-void	request(card_t *card, ENTITY *e)
-{
-	word	*special_req;
-	int		i;
-	int		ipl;
-
-
-	if (card->log_types & DIVAS_LOG_IDI)
-	{
-		DivasLogIdi(card, e, TRUE);
-	}
-
-	if (!e->Req)
-	{
-		special_req = (word *) e;
-
-		switch (*special_req)
-		{
-		case REQ_REMOVE:
-			return;
-
-		case REQ_NAME:
-			for (i=0; i < DIM(card->cfg.name); i++)
-			{
-				((struct get_name_s *) e)->name[i] = card->cfg.name[i];
-			}
-			return;
-
-		case REQ_SERIAL:
-		case REQ_XLOG:
-			DPRINTF(("IDI: attempted REQ_SERIAL or REQ_XLOG"));
-			return;
-
-		default:
-			return;
-		}
-	}
-
-	ipl = UxCardLock(card->hw);
-
-   	if (!(e->Id & 0x1f))
-	{
-		DPRINTF(("IDI: ASSIGN req"));
-
-		for (i = 1; i < card->e_max; i++)
-		{
-			if (!card->e_tbl[i].e)
-			{
-				break;
-			}
-		}
-
-		if (i == card->e_max)
-		{
-			DPRINTF(("IDI: request all ids in use (IDI req ignored)"));
-			UxCardUnlock(card->hw, ipl);
-			e->Rc = OUT_OF_RESOURCES;
-			return;
-		}
-
-		card->e_tbl[i].e = e;
-		card->e_count++;
-
-		e->No = (byte) i;
-		e->More = 0;
-		e->RCurrent = 0xff;
-	}
-	else
-	{
-		i = e->No;
-	}
-    
-    if (e->More & XBUSY)
-	{
-		DPRINTF(("IDI: request - entity is busy"));
-		UxCardUnlock(card->hw, ipl);
-		return;
-	}
-
-	e->More |= XBUSY;
-	e->More &= ~ XMOREF;
-	e->XCurrent = 0;
-	e->XOffset = 0;
-
-	card->e_tbl[i].next = 0;
-
-	if(card->e_head)
-	{
-		card->e_tbl[card->e_tail].next = i;
-		card->e_tail = i;
-	}
-	else
-	{
-		card->e_head = i;
-		card->e_tail = i;
-	}
-
-	UxCardUnlock(card->hw, ipl);
-
-	DivasScheduleRequestDpc();
-
-	return;
-}
-
-static byte pr_ready(ADAPTER * a)
-{
-  byte ReadyCount;
-
-  ReadyCount = (byte)(a->ram_in(a, &PR_RAM->ReqOutput) -
-                      a->ram_in(a, &PR_RAM->ReqInput));
-
-  if(!ReadyCount) {
-    if(!a->ReadyInt) {
-      a->ram_inc(a, &PR_RAM->ReadyInt);
-      a->ReadyInt++;
-    }
-  }
-  return ReadyCount;
-}
-
-/*------------------------------------------------------------------*/
-/* output function                                                  */
-/*------------------------------------------------------------------*/
-
-void DivasOut(ADAPTER * a)
-{
-  byte e_no;
-  ENTITY  * this = NULL;
-  BUFFERS  *X;
-  word length;
-  word i;
-  word clength;
-  REQ * ReqOut;
-  byte more;
-  byte ReadyCount;
-  byte ReqCount;
-  byte Id;
-
-        /* while a request is pending ...                           */
-  e_no = look_req(a);
-  if(!e_no)
-  {
-    return;
-  }
-
-  ReadyCount = pr_ready(a);
-  if(!ReadyCount)
-  {
-    DPRINTF(("IDI: card not ready for next request"));
-    return;
-  }
-
-  ReqCount = 0;
-  while(e_no && ReadyCount) {
-
-    next_req(a);
-
-    this = entity_ptr(a, e_no);
-
-#ifdef	USE_EXTENDED_DEBUGS
-	if ( !this )
-	{
-		ISDN_ADAPTER *io = (ISDN_ADAPTER *)a->io ;
-		DBG_FTL(("!A%d ==> NULL entity ptr - try to ignore", (int)io->ANum))
-		e_no = look_req(a) ;
-		ReadyCount-- ;
-		continue ;
-	}
-	{
-		ISDN_ADAPTER *io = (ISDN_ADAPTER *)a->io ;
-		DPRINTF(("IDI: >A%d Id=0x%x Req=0x%x", io->ANum, this->Id, this->Req))
-	}
-#else
-    DPRINTF(("IDI: >REQ=%x,Id=%x,Ch=%x",this->Req,this->Id,this->ReqCh));
-#endif
-
-        /* get address of next available request buffer             */
-    ReqOut = (REQ *)&PR_RAM->B[a->ram_inw(a, &PR_RAM->NextReq)];
-
-        /* now copy the data from the current data buffer into the  */
-        /* adapters request buffer                                  */
-    length = 0;
-    i = this->XCurrent;
-    X = PTR_X(a,this);
-    while(i<this->XNum && length<270) {
-      clength = (word)(270-length);
-      if (clength > X[i].PLength-this->XOffset)
-	      clength = X[i].PLength-this->XOffset;
-      a->ram_out_buffer(a,
-                        &ReqOut->XBuffer.P[length],
-                        PTR_P(a,this,&X[i].P[this->XOffset]),
-                        clength);
-
-      length +=clength;
-      this->XOffset +=clength;
-      if(this->XOffset==X[i].PLength) {
-        this->XCurrent = (byte)++i;
-        this->XOffset = 0;
-      }
-    }
-
-    a->ram_outw(a, &ReqOut->XBuffer.length, length);
-    a->ram_out(a, &ReqOut->ReqId, this->Id);
-    a->ram_out(a, &ReqOut->ReqCh, this->ReqCh);
-
-        /* if it's a specific request (no ASSIGN) ...                */
-
-    if(this->Id &0x1f) {
-
-        /* if buffers are left in the list of data buffers do       */
-        /* do chaining (LL_MDATA, N_MDATA)                          */
-
-      this->More++;
-      if(i<this->XNum && this->MInd) {
-        a->ram_out(a, &ReqOut->Req, this->MInd);
-        more = TRUE;
-      }
-      else {
-        this->More |=XMOREF;
-        a->ram_out(a, &ReqOut->Req, this->Req);
-        more = FALSE;
-      }
-
-        /* if we did chaining, this entity is put back into the     */
-        /* request queue                                            */
-
-      if(more) {
-        req_queue(a,this->No);
-      }
-    }
-
-        /* else it's a ASSIGN                                       */
-
-    else {
-
-        /* save the request code used for buffer chaining           */
-
-      this->MInd = 0;
-      if (this->Id==BLLC_ID) this->MInd = LL_MDATA;
-      if (this->Id==NL_ID   ||
-          this->Id==TASK_ID ||
-          this->Id==MAN_ID
-        ) this->MInd = N_MDATA;
-
-        /* send the ASSIGN                                          */
-
-      this->More |=XMOREF;
-      a->ram_out(a, &ReqOut->Req, this->Req);
-
-        /* save the reference of the ASSIGN                         */
-
-      assign_queue(a, this->No, a->ram_inw(a, &ReqOut->Reference));
-    }
-    a->ram_outw(a, &PR_RAM->NextReq, a->ram_inw(a, &ReqOut->next));
-    ReadyCount--;
-    ReqCount++;
-
-    e_no = look_req(a);
-  }
-
-        /* send the filled request buffers to the ISDN adapter      */
-
-  a->ram_out(a, &PR_RAM->ReqInput,
-             (byte)(a->ram_in(a, &PR_RAM->ReqInput) + ReqCount));
-
-        /* if it is a 'unreturncoded' UREMOVE request, remove the  */
-        /* Id from our table after sending the request             */
-  if(this->Req==UREMOVE && this->Id) {
-    Id = this->Id;
-    e_no = a->IdTable[Id];
-    free_entity(a, e_no);
-    a->IdTable[Id] = 0;
-    this->Id = 0;
-  }
-
-}
-
-/*------------------------------------------------------------------*/
-/* isdn interrupt handler                                           */
-/*------------------------------------------------------------------*/
-
-byte DivasDpc(ADAPTER * a)
-{
-  byte Count;
-  RC * RcIn;
-  IND * IndIn;
-  byte c;
-  byte RNRId;
-  byte Rc;
-  byte Ind;
-
-        /* if return codes are available ...                        */
-  if((Count = a->ram_in(a, &PR_RAM->RcOutput))) {
-
-    DPRINTF(("IDI: #Rc=%x",Count));
-
-        /* get the buffer address of the first return code          */
-    RcIn = (RC *)&PR_RAM->B[a->ram_inw(a, &PR_RAM->NextRc)];
-
-        /* for all return codes do ...                              */
-    while(Count--) {
-
-      if((Rc=a->ram_in(a, &RcIn->Rc))) {
-
-        /* call return code handler, if it is not our return code   */
-        /* the handler returns 2                                    */
-        /* for all return codes we process, we clear the Rc field   */
-        isdn_rc(a,
-                Rc,
-                a->ram_in(a, &RcIn->RcId),
-                a->ram_in(a, &RcIn->RcCh),
-                a->ram_inw(a, &RcIn->Reference));
-
-        a->ram_out(a, &RcIn->Rc, 0);
-      }
-
-        /* get buffer address of next return code                   */
-      RcIn = (RC *)&PR_RAM->B[a->ram_inw(a, &RcIn->next)];
-    }
-
-        /* clear all return codes (no chaining!)                    */
-    a->ram_out(a, &PR_RAM->RcOutput ,0);
-
-        /* call output function                                     */
-    DivasOut(a);
-  }
-
-        /* clear RNR flag                                           */
-  RNRId = 0;
-
-        /* if indications are available ...                         */
-  if((Count = a->ram_in(a, &PR_RAM->IndOutput))) {
-
-    DPRINTF(("IDI: #Ind=%x",Count));
-
-        /* get the buffer address of the first indication           */
-    IndIn = (IND *)&PR_RAM->B[a->ram_inw(a, &PR_RAM->NextInd)];
-
-        /* for all indications do ...                               */
-    while(Count--) {
-
-        /* if the application marks an indication as RNR, all       */
-        /* indications from the same Id delivered in this interrupt */
-        /* are marked RNR                                           */
-      if(RNRId && RNRId==a->ram_in(a, &IndIn->IndId)) {
-        a->ram_out(a, &IndIn->Ind, 0);
-        a->ram_out(a, &IndIn->RNR, TRUE);
-      }
-      else {
-        Ind = a->ram_in(a, &IndIn->Ind);
-        if(Ind) {
-          RNRId = 0;
-
-        /* call indication handler, a return value of 2 means chain */
-        /* a return value of 1 means RNR                            */
-        /* for all indications we process, we clear the Ind field   */
-          c = isdn_ind(a,
-                       Ind,
-                       a->ram_in(a, &IndIn->IndId),
-                       a->ram_in(a, &IndIn->IndCh),
-                       &IndIn->RBuffer,
-                       a->ram_in(a, &IndIn->MInd),
-                       a->ram_inw(a, &IndIn->MLength));
-
-          if(c==1) {
-            DPRINTF(("IDI: RNR"));
-            a->ram_out(a, &IndIn->Ind, 0);
-            RNRId = a->ram_in(a, &IndIn->IndId);
-            a->ram_out(a, &IndIn->RNR, TRUE);
-          }
-        }
-      }
-
-        /* get buffer address of next indication                    */
-      IndIn = (IND *)&PR_RAM->B[a->ram_inw(a, &IndIn->next)];
-    }
-
-    a->ram_out(a, &PR_RAM->IndOutput, 0);
-  }
-  return FALSE;
-}
-
-byte DivasTestInt(ADAPTER * a)
-{
-  return a->ram_in(a,(void *)0x3fe);
-}
-
-void DivasClearInt(ADAPTER * a)
-{
-  a->ram_out(a,(void *)0x3fe,0); 
-}
-
-/*------------------------------------------------------------------*/
-/* return code handler                                              */
-/*------------------------------------------------------------------*/
-
-static
-byte isdn_rc(ADAPTER * a,
-             byte Rc,
-             byte Id,
-             byte Ch,
-             word Ref)
-{
-  ENTITY  * this;
-  byte e_no;
-
-#ifdef	USE_EXTENDED_DEBUGS
-	{
-		ISDN_ADAPTER *io = (ISDN_ADAPTER *)a->io ;
-		DPRINTF(("IDI: <A%d Id=0x%x Rc=0x%x", io->ANum, Id, Rc))
-	}
-#else
-  DPRINTF(("IDI: <RC(Rc=%x,Id=%x,Ch=%x)",Rc,Id,Ch));
-#endif
-
-        /* check for ready interrupt                                */
-  if(Rc==READY_INT) {
-    if(a->ReadyInt) {
-      a->ReadyInt--;
-      return 0;
-    }
-    return 2;
-  }
-
-        /* if we know this Id ...                                   */
-  e_no = a->IdTable[Id];
-  if(e_no) {
-
-    this = entity_ptr(a,e_no);
-
-    this->RcCh = Ch;
-
-        /* if it is a return code to a REMOVE request, remove the   */
-        /* Id from our table                                        */
-    if(this->Req==REMOVE && Rc==OK) {
-      free_entity(a, e_no);
-      a->IdTable[Id] = 0;
-      this->Id = 0;
-/**************************************************************/
-      if ((this->More & XMOREC) > 1) {
-        this->More &= ~XMOREC;
-	this->More |= 1;
-	DPRINTF(("isdn_rc, Id=%x, correct More on REMOVE", Id));
-      }
-    }
-
-    if (Rc==OK_FC) {
-      this->Rc = Rc;
-      this->More = (this->More & (~XBUSY | XMOREC)) | 1;
-      this->complete = 0xFF;
-      CALLBACK(a, this);
-      return 0;
-    }
-    if(this->More &XMOREC)
-      this->More--;
-
-        /* call the application callback function                   */
-    if(this->More &XMOREF && !(this->More &XMOREC)) {
-      this->Rc = Rc;
-      this->More &=~XBUSY;
-      this->complete=0xff;
-      CALLBACK(a, this);
-    }
-    return 0;
-  }
-
-        /* if it's an ASSIGN return code check if it's a return     */
-        /* code to an ASSIGN request from us                        */
-  if((Rc &0xf0)==ASSIGN_RC) {
-
-    e_no = get_assign(a, Ref);
-
-    if(e_no) {
-
-      this = entity_ptr(a,e_no);
-
-      this->Id = Id;
-
-        /* call the application callback function                   */
-      this->Rc = Rc;
-      this->More &=~XBUSY;
-      this->complete=0xff;
-      CALLBACK(a, this);
-
-      if(Rc==ASSIGN_OK) {
-        a->IdTable[Id] = e_no;
-      }
-      else
-      {
-        free_entity(a, e_no);
-        a->IdTable[Id] = 0;
-        this->Id = 0;
-      }
-      return 1;
-    }
-  }
-  return 2;
-}
-
-/*------------------------------------------------------------------*/
-/* indication handler                                               */
-/*------------------------------------------------------------------*/
-
-static
-byte isdn_ind(ADAPTER * a,
-              byte Ind,
-              byte Id,
-              byte Ch,
-              PBUFFER * RBuffer,
-              byte MInd,
-              word MLength)
-{
-  ENTITY  * this;
-  word clength;
-  word offset;
-  BUFFERS  *R;
-
-#ifdef	USE_EXTENDED_DEBUGS
-	{
-		ISDN_ADAPTER *io = (ISDN_ADAPTER *)a->io ;
-		DPRINTF(("IDI: <A%d Id=0x%x Ind=0x%x", io->ANum, Id, Ind))
-	}
-#else
-  DPRINTF(("IDI: <IND(Ind=%x,Id=%x,Ch=%x)",Ind,Id,Ch));
-#endif
-
-  if(a->IdTable[Id]) {
-
-    this = entity_ptr(a,a->IdTable[Id]);
-
-    this->IndCh = Ch;
-
-        /* if the Receive More flag is not yet set, this is the     */
-        /* first buffer of the packet                               */
-    if(this->RCurrent==0xff) {
-
-        /* check for receive buffer chaining                        */
-      if(Ind==this->MInd) {
-        this->complete = 0;
-        this->Ind = MInd;
-      }
-      else {
-        this->complete = 1;
-        this->Ind = Ind;
-      }
-
-        /* call the application callback function for the receive   */
-        /* look ahead                                               */
-      this->RLength = MLength;
-
-      a->ram_look_ahead(a, RBuffer, this);
-
-      this->RNum = 0;
-      CALLBACK(a, this);
-
-        /* map entity ptr, selector could be re-mapped by call to   */
-        /* IDI from within callback                                 */
-      this = entity_ptr(a,a->IdTable[Id]);
-
-        /* check for RNR                                            */
-      if(this->RNR==1) {
-        this->RNR = 0;
-        return 1;
-      }
-
-        /* if no buffers are provided by the application, the       */
-        /* application want to copy the data itself including       */
-        /* N_MDATA/LL_MDATA chaining                                */
-      if(!this->RNR && !this->RNum) {
-        return 0;
-      }
-
-        /* if there is no RNR, set the More flag                    */
-      this->RCurrent = 0;
-      this->ROffset = 0;
-    }
-
-    if(this->RNR==2) {
-      if(Ind!=this->MInd) {
-        this->RCurrent = 0xff;
-        this->RNR = 0;
-      }
-      return 0;
-    }
-        /* if we have received buffers from the application, copy   */
-        /* the data into these buffers                              */
-    offset = 0;
-    R = PTR_R(a,this);
-    do {
-      if(this->ROffset==R[this->RCurrent].PLength) {
-        this->ROffset = 0;
-        this->RCurrent++;
-      }
-      clength = a->ram_inw(a, &RBuffer->length)-offset;
-      if (clength > R[this->RCurrent].PLength-this->ROffset)
-	      clength = R[this->RCurrent].PLength-this->ROffset;
-      if(R[this->RCurrent].P) {
-        a->ram_in_buffer(a,
-                         &RBuffer->P[offset],
-                         PTR_P(a,this,&R[this->RCurrent].P[this->ROffset]),
-                         clength);
-      }
-      offset +=clength;
-      this->ROffset +=clength;
-    } while(offset<(a->ram_inw(a, &RBuffer->length)));
-
-        /* if it's the last buffer of the packet, call the          */
-        /* application callback function for the receive complete   */
-        /* call                                                     */
-    if(Ind!=this->MInd) {
-      R[this->RCurrent].PLength = this->ROffset;
-      if(this->ROffset) this->RCurrent++;
-      this->RNum = this->RCurrent;
-      this->RCurrent = 0xff;
-      this->Ind = Ind;
-      this->complete = 2;
-      CALLBACK(a, this);
-    }
-    return 0;
-  }
-  return 2;
-}
diff -puN -L drivers/isdn/eicon/idi.h drivers/isdn/eicon/idi.h~linus /dev/null
--- 25/drivers/isdn/eicon/idi.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,129 +0,0 @@
-/*
- * External IDI interface
- *
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.0  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#if !defined(IDI_H)
-#define IDI_H
-
-#include "sys.h"
-
-/* typedefs for our data structures */
-
-typedef struct get_name_s GET_NAME;
-typedef struct entity_s ENTITY;
-typedef struct buffers_s BUFFERS;
-
-/* IDI request/callback function pointer */
-
-typedef void (* IDI_CALL)(ENTITY *);
-
-typedef struct {
-  word length;          /* length of data/parameter field           */
-  byte P[270];          /* data/parameter field                     */
-} DBUFFER;
-
-#define REQ_NAME	0x0100
-#define BOARD_NAME_LENGTH 9
-struct get_name_s {
-  word command;         /* command = 0x0100 */
-  byte name[BOARD_NAME_LENGTH];
-};
-
-#define REQ_REMOVE    0x0000    /* pointer to word which is 0 */
-#define REQ_SERIAL    0x0200  
-struct get_serial_s {
-  word      command;            /* command = 0x0200 */
-  dword     serial;             /* serial number */
-};
-
-#define REQ_POSTCALL  0x0300  
-struct postcall_s {
-  word        command;         /* command = 0x0300 */
-  word        dummy;           /* not used */
-  IDI_CALL    callback;        /* routine address to call back */
-  ENTITY      *contxt;         /* ptr to entity to use */
-};
-
-#define REQ_XLOG      0x0400   /* structure is card dependent/defined locally */
-
-struct buffers_s {
-  word PLength;
-  byte *P;
-};
-
-struct entity_s {
-  byte                  Req;            /* pending request          */
-  byte                  Rc;             /* return code received     */
-  byte                  Ind;            /* indication received      */
-  byte                  ReqCh;          /* channel of current Req   */
-  byte                  RcCh;           /* channel of current Rc    */
-  byte                  IndCh;          /* channel of current Ind   */
-  byte                  Id;             /* ID used by this entity   */
-  byte                  GlobalId;       /* reserved field           */
-  byte                  XNum;           /* number of X-buffers      */
-  byte                  RNum;           /* number of R-buffers      */
-  BUFFERS               *X;        		/* pointer to X-buffer list */
-  BUFFERS               *R;        		/* pointer to R-buffer list */
-  word                  RLength;        /* length of current R-data */
-  DBUFFER               *RBuffer;       /* buffer of current R-data */
-  byte                  RNR;            /* receive not ready flag   */
-  byte                  complete;       /* receive complete status  */
-  IDI_CALL              callback;
-
-  word                  user[2];
-
-        /* fields used by the driver internally                     */
-  byte                  No;             /* entity number            */
-  byte                  reserved2;      /* reserved field           */
-  byte                  More;           /* R/X More flags           */
-  byte                  MInd;           /* MDATA coding for this ID */
-  byte                  XCurrent;       /* current transmit buffer  */
-  byte                  RCurrent;       /* current receive buffer   */
-  word                  XOffset;        /* offset in x-buffer       */
-  word                  ROffset;        /* offset in r-buffer       */
-};
-
-typedef struct {
-  byte                  type;
-  byte                  channels;
-  word                  features;
-  /* dword		serial; */
-  IDI_CALL              request;
-} DESCRIPTOR;
-
-extern void    DIVA_DIDD_Read(DESCRIPTOR *, int);
-
-        /* descriptor type field coding */
-#define IDI_ADAPTER_S           1
-#define IDI_ADAPTER_PR          2
-#define IDI_ADAPTER_DIVA        3
-#define IDI_ADAPTER_MAESTRA     4
-#define IDI_ADAPTER_MAESTRAQ    5
-#define IDI_ADAPTER_MAESTRAP    6
-#define IDI_VADAPTER            0x40
-#define IDI_DRIVER              0x80
-#define IDI_DIMAINT             0xff
-
-/* feature bit mask values */
-
-#define DI_VOICE        0x0 /* obsolete define */
-#define DI_FAX3         0x1
-#define DI_MODEM        0x2
-#define DI_POST         0x4
-#define DI_V110         0x8
-#define DI_V120         0x10
-#define DI_POTS         0x20
-#define DI_CODEC        0x40
-#define DI_MANAGE       0x80
-#define DI_V_42         0x0100
-#define DI_EXTD_FAX     0x0200 /* Extended FAX (ECM, 2D, T.6, Polling) */
-
-#endif /* IDI_H */
diff -puN -L drivers/isdn/eicon/Kconfig drivers/isdn/eicon/Kconfig~linus /dev/null
--- 25/drivers/isdn/eicon/Kconfig
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,53 +0,0 @@
-#
-# Config.in for Eicon active ISDN support
-#
-config ISDN_DRV_EICON
-	bool "Eicon active card support"
-	help
-	  Say Y here if you have an Eicon active ISDN card. In order to use
-	  this card, additional firmware is necessary, which has to be loaded
-	  into the card using the eiconctrl utility which is part of the
-	  latest isdn4k-utils package. Please read the file
-	  <file:Documentation/isdn/README.eicon> for more information.
-
-choice
-	prompt "Eicon active card support"
-	optional
-	depends on ISDN_DRV_EICON && ISDN && m
-
-config ISDN_DRV_EICON_DIVAS
-	tristate "Eicon driver"
-	depends on PCI
-	help
-	  Enable this option if you want the eicon driver as standalone
-	  version with no interface to the ISDN4Linux isdn module. If you
-	  say Y here, the eicon module only supports the Diva Server PCI
-	  cards and will provide its own IDI interface. You should say N
-	  here.
-
-config ISDN_DRV_EICON_OLD
-	tristate "Legacy driver"
-	help
-	  Say Y here to use your Eicon active ISDN card with ISDN4Linux
-	  isdn module.
-
-config ISDN_DRV_EICON_PCI
-	bool "Eicon PCI DIVA Server BRI/PRI/4BRI support"
-	depends on ISDN_DRV_EICON_OLD && PCI
-	help
-	  Say Y here if you have an Eicon Diva Server (BRI/PRI/4BRI) ISDN
-	  card.  Please read <file:Documentation/isdn/README.eicon> for more
-	  information.
-
-config ISDN_DRV_EICON_ISA
-	bool "Eicon S,SX,SCOM,Quadro,S2M support"
-	depends on ISDN_DRV_EICON_OLD
-	help
-	  Say Y here if you have an old-type Eicon active ISDN card. In order
-	  to use this card, additional firmware is necessary, which has to be
-	  loaded into the card using the eiconctrl utility which is part of
-	  the latest isdn4k-utils package. Please read the file
-	  <file:Documentation/isdn/README.eicon> for more information.
-
-endchoice
-
diff -puN -L drivers/isdn/eicon/kprintf.c drivers/isdn/eicon/kprintf.c~linus /dev/null
--- 25/drivers/isdn/eicon/kprintf.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,52 +0,0 @@
-/*
- * Source file for kernel interface to kernel log facility
- *
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.3  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#include "eicon.h"
-#include "sys.h"
-#include <stdarg.h>
-
-#include "divas.h"
-#include "divalog.h"
-#include "uxio.h"
-
-void    DivasPrintf(char  *fmt, ...)
-
-{
-    klog_t      log;            /* log entry buffer */
-
-    va_list     argptr;         /* pointer to additional args */
-
-    va_start(argptr, fmt);
-
-    /* clear log entry */
-
-    memset((void *) &log, 0, sizeof(klog_t));
-
-    log.card = -1;
-    log.type = KLOG_TEXT_MSG;
-
-    /* time stamp the entry */
-
-    log.time_stamp = UxTimeGet();
-
-    /* call vsprintf to format the user's information */
-
-    vsnprintf(log.buffer, DIM(log.buffer), fmt, argptr);
-
-    va_end(argptr);
-
-    /* send to the log streams driver and return */
-
-    DivasLogAdd(&log, sizeof(klog_t));
-
-    return;
-}
diff -puN -L drivers/isdn/eicon/lincfg.c drivers/isdn/eicon/lincfg.c~linus /dev/null
--- 25/drivers/isdn/eicon/lincfg.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,257 +0,0 @@
-/*
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.9  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#include <linux/fs.h>
-#undef N_DATA   /* Because we have our own definition */
-
-#include <asm/io.h>
-
-#include "sys.h"
-#include "idi.h"
-#include "constant.h"
-#include "divas.h"
-#undef ID_MASK
-#include "pc.h"
-#include "pr_pc.h"
-
-#include "adapter.h"
-#include "uxio.h"
-
-#include <linux/pci.h>
-#include <linux/kernel.h>
-#include <linux/ioport.h>
-
-struct file_operations Divas_fops;
-int Divas_major;
-
-extern int do_ioctl(struct inode *pDivasInode, struct file *pDivasFile, 
-			 unsigned int command, unsigned long arg);
-extern unsigned int do_poll(struct file *pFile, struct poll_table_struct *pPollTable);
-extern ssize_t do_read(struct file *pFile, char *pUserBuffer, size_t BufferSize, loff_t *pOffset);
-extern int do_open(struct inode *, struct file *);
-extern int do_release(struct inode *, struct file *);
-
-int FPGA_Done=0;
-
-int DivasCardsDiscover(void)
-{
-	struct pci_dev *pdev = NULL;
-	word wNumCards = 0, wDeviceIndex = 0;
-	word PCItmp;
-	dword j, i;
-	unsigned int PCIserial;
-	dia_card_t Card;
-	byte *b;
-	
-	while ((pdev = pci_find_device(PCI_VENDOR_ID_EICON, 
-				      PCI_DEVICE_ID_EICON_MAESTRAQ, 
-				      pdev))) {
-		dword dwRAM, dwDivasIOBase, dwCFG, dwCTL;
-			
-		printk(KERN_DEBUG "Divas: DIVA Server 4BRI Found\n");
-
-		dwRAM = pci_resource_start(pdev, 2);
-		dwDivasIOBase = pci_resource_start(pdev, 1);
-		dwCFG = pci_resource_start(pdev, 0);
-		dwCTL = pci_resource_start(pdev, 3);
-
-		/* Retrieve the serial number */
-		pci_write_config_word(pdev, 0x4E, 0x00FC);
-		for (j=0, PCItmp=0; j<10000 && !PCItmp; j++) {
-			pci_read_config_word(pdev, 0x4E, &PCItmp);
-			PCItmp &= 0x8000;  // extract done flag
-		}
-		pci_read_config_dword(pdev, 0x50, &PCIserial);
-		
-		Card.memory[DIVAS_RAM_MEMORY] = ioremap(dwRAM, 0x400000);
-		Card.memory[DIVAS_CTL_MEMORY] = ioremap(dwCTL, 0x2000);
-		Card.memory[DIVAS_CFG_MEMORY] = ioremap(dwCFG, 0x100);
-		Card.io_base=dwDivasIOBase;
-
-		Card.card_type = DIA_CARD_TYPE_DIVA_SERVER_Q;
-		Card.bus_type = DIA_BUS_TYPE_PCI;
-		Card.pdev = pdev;
-		Card.irq = pdev->irq;
-			
-		FPGA_Done = 0;
-
-		/* Create four virtual card structures as we want to treat 
-		   the 4Bri card as 4 Bri cards*/
-		for(i=0;i<4;i++) {
-			b=Card.memory[DIVAS_RAM_MEMORY];
-			b+=(MQ_PROTCODE_OFFSET) * (i==0?0:1); 
-			DPRINTF(("divas: offset = 0x%x", i* MQ_PROTCODE_OFFSET));
-			Card.memory[DIVAS_RAM_MEMORY]=b;
- 
-			b = Card.memory[DIVAS_RAM_MEMORY];
-			b += MQ_SM_OFFSET;
-			Card.memory[DIVAS_SHARED_MEMORY] = b;
-
-			Card.slot = -1;
-
-			sprintf(Card.name, "DIVASQ%ld", i);
-
-			Card.serial = PCIserial;
-
-			Card.card_id = wNumCards;
-
-			if (DivasCardNew(&Card) != 0) {
-				break;
-			}
-			wNumCards++;
-
-		}
-	}
-
-	pdev = NULL;
-	while ((pdev = pci_find_device(PCI_VENDOR_ID_EICON, 
-				      PCI_DEVICE_ID_EICON_MAESTRA, 
-				      pdev))) {
-		dword dwPLXIOBase, dwDivasIOBase;
-
-		printk(KERN_DEBUG "Divas: DIVA Server BRI (S/T) Found\n");
-		dwPLXIOBase = pci_resource_start(pdev, 1);
-		dwDivasIOBase = pci_resource_start(pdev, 2);
-		
-		Card.card_id = wNumCards;
-		Card.card_type = DIA_CARD_TYPE_DIVA_SERVER_B;
-		Card.bus_type = DIA_BUS_TYPE_PCI;
-		Card.pdev = pdev;
-		Card.irq = pdev->irq;
-		Card.reset_base = dwPLXIOBase;
-		Card.io_base = dwDivasIOBase;
-		Card.slot = -1;
-		strcpy(Card.name, "DIVASB");
-
-		if (check_region(Card.io_base, 0x20)) {
-			printk(KERN_WARNING "Divas: DIVA I/O Base already in use 0x%x-0x%x\n", Card.io_base, Card.io_base + 0x1F);
-		}
-
-		if (check_region(Card.reset_base, 0x80)) {
-			printk(KERN_WARNING "Divas: PLX I/O Base already in use 0x%x-0x%x\n", Card.reset_base, Card.reset_base + 0x7F);
-			continue;
-		}
-		
-		if (DivasCardNew(&Card) != 0) {
-			continue;
-		}
-		wNumCards++;
-	}
-
-	pdev = NULL;
-	while ((pdev = pci_find_device(PCI_VENDOR_ID_EICON, 
-				      PCI_DEVICE_ID_EICON_MAESTRAQ_U, 
-				      pdev))) {
-		dword dwPLXIOBase, dwDivasIOBase;
-
-		printk(KERN_DEBUG "Divas: DIVA Server BRI (U) Found\n");
-
-		dwPLXIOBase = pci_resource_start(pdev, 1);
-		dwDivasIOBase = pci_resource_start(pdev, 2);
-		
-		Card.card_id = wNumCards;
-		Card.card_type = DIA_CARD_TYPE_DIVA_SERVER_B;
-		Card.bus_type = DIA_BUS_TYPE_PCI;
-		Card.pdev = pdev;
-		Card.irq = pdev->irq;
-		Card.reset_base = dwPLXIOBase;
-		Card.io_base = dwDivasIOBase;
-		Card.slot = -1;
-		strcpy(Card.name, "DIVASB");
-
-		if (check_region(Card.io_base, 0x20)) {
-			printk(KERN_WARNING "Divas: DIVA I/O Base already in use 0x%x-0x%x\n", Card.io_base, Card.io_base + 0x1F);	
-			continue;
-		}
-
-		if (check_region(Card.reset_base, 0x80)) {
-			printk(KERN_WARNING "Divas: PLX I/O Base already in use 0x%x-0x%x\n", Card.reset_base, Card.reset_base + 0x7F);
-			continue;
-		}
-
-		if (DivasCardNew(&Card) != 0) {
-			continue;
-		}
-		wNumCards++;
-	}
-
-	wDeviceIndex = 0;
-
-	pdev = NULL;
-	while ((pdev = pci_find_device(PCI_VENDOR_ID_EICON, 
-				      PCI_DEVICE_ID_EICON_MAESTRAQ_U, 
-				      pdev))) {
-		dword dwRAM, dwREG, dwCFG;
-
-		printk(KERN_DEBUG "Divas: DIVA Server PRI Found\n");
-		
-		dwRAM = pci_resource_start(pdev, 0);
-		dwREG = pci_resource_start(pdev, 2);
-		dwCFG = pci_resource_start(pdev, 4);
-		
-		Card.memory[DIVAS_RAM_MEMORY] = ioremap(dwRAM, 0x10000);
-		Card.memory[DIVAS_REG_MEMORY] = ioremap(dwREG, 0x4000);
-		Card.memory[DIVAS_CFG_MEMORY] = ioremap(dwCFG, 0x1000);
-		Card.memory[DIVAS_SHARED_MEMORY] = Card.memory[DIVAS_RAM_MEMORY] + DIVAS_SHARED_OFFSET;
-		
-		Card.card_id = wNumCards;
-		Card.card_type = DIA_CARD_TYPE_DIVA_SERVER;
-		Card.bus_type = DIA_BUS_TYPE_PCI;
-		Card.pdev = pdev;
-		Card.irq = pdev->irq;
-		Card.slot = -1;
-		strcpy(Card.name, "DIVASP");
-		if (DivasCardNew(&Card) != 0) {
-			continue;
-		}
-		wNumCards++;
-	}
-
-
-	printk(KERN_INFO "Divas: %d cards detected\n", wNumCards);
-
-	if(wNumCards == 0) {
-		return -1;
-	}
-
-	Divas_fops.ioctl = do_ioctl;
-	Divas_fops.poll = do_poll;
-	Divas_fops.read = do_read;
-	Divas_fops.open = do_open;
-	Divas_fops.release = do_release;
-
-	Divas_major = register_chrdev(0, "Divas", &Divas_fops);
-
-	if (Divas_major < 0) {
-		printk(KERN_WARNING "Divas: Unable to register character driver\n");
-		return -1;
-	}
-
-	return 0;
-}
-
-/* Error return -1 */
-int DivasConfigGet(dia_card_t *card)
-{
-	/* Retrieve Config from O/S? Not in Linux */
-	return 0;
-}
-
-dia_config_t *DivasConfig(card_t *card, dia_config_t *config)
-{
-	/*	If config retrieved from OS then copy the data into a dia_config_t structure here
-		and return the pointer here. If the config 'came from above' then just 
-
-			return config;
-	*/
-
-	return config;
-}
-
diff -puN -L drivers/isdn/eicon/linchr.c drivers/isdn/eicon/linchr.c~linus /dev/null
--- 25/drivers/isdn/eicon/linchr.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,198 +0,0 @@
-/*
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.12  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#include <linux/module.h>
-
-#include <linux/kernel.h>
-#include <linux/poll.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-
-#undef N_DATA
-
-#include "adapter.h"
-#include "divas.h"
-#include "divalog.h"
-
-extern int DivasCardNext;
-void UxPause(long ms);
-int DivasGetMem(mem_block_t *);
-
-#define DIA_IOCTL_UNLOCK 12
-void UnlockDivas(void);
-
-int do_ioctl(struct inode *pDivasInode, struct file *pDivasFile, 
-			 unsigned int command, unsigned long arg)
-{
-	byte *pUserCards, card_i;
-	word wCardNum;
-
-	switch (command)
-	{
-		case DIA_IOCTL_CONFIG:
-		{
-			dia_config_t DivaConfig;
-			if (copy_from_user(&DivaConfig, (void *)arg, sizeof(dia_config_t)))
-				return -EFAULT;
-			DivasCardConfig(&DivaConfig);
-			return 0;
-		}
-
-		case DIA_IOCTL_DETECT:
-			pUserCards = (byte *) arg;
-
-			if (!verify_area(VERIFY_WRITE, pUserCards, 20))
-			{
-				if(__put_user(DivasCardNext, pUserCards++))
-					return -EFAULT;
-
-				for (card_i=1; card_i < 20; card_i++)
-				{
-					if(__put_user((byte) DivasCards[card_i - 1].cfg.card_type, pUserCards++))
-						return -EFAULT;
-				}
-			}
-			else return -EFAULT;
-
-			return 0;
-
-		case DIA_IOCTL_START:
-		{
-			dia_start_t DivaStart;
-			if (copy_from_user(&DivaStart, (void *)arg, sizeof(dia_start_t)))
-				return -EFAULT;
-			return DivasCardStart(DivaStart.card_id);
-		}
-
-		case DIA_IOCTL_FLAVOUR:
-			return 0;
-
-		case DIA_IOCTL_LOAD:
-		{
-			dia_load_t DivaLoad;
-			if(copy_from_user(&DivaLoad, (void *)arg, sizeof(dia_load_t)))
-				return -EFAULT;
-			if (!verify_area(VERIFY_READ, DivaLoad.code,DivaLoad.length))
-			{
-				if (DivasCardLoad(&DivaLoad))
-				{
-					printk(KERN_WARNING "Divas: Error loading DIVA Server adapter\n");
-					return -EINVAL;
-				}
-				return 0;
-			}
-			return -EFAULT;
-		}
-		case DIA_IOCTL_LOG:
-		{
-			dia_log_t DivaLog;
-			if (copy_from_user(&DivaLog, (void *) arg, sizeof(dia_log_t)))
-				return -EFAULT;
-			DivasLog(&DivaLog);
-			return 0;
-		}
-
-		case DIA_IOCTL_XLOG_REQ:
-			if(get_user(wCardNum, (word *) arg))
-				return -EFAULT;
-			DivasXlogReq(wCardNum);
-			return 0;
-
-		case DIA_IOCTL_GET_NUM:
-			if(put_user(DivasCardNext, (int *)arg))
-				return -EFAULT;
-			return 0;
-
-		case DIA_IOCTL_GET_LIST:
-		{
-			dia_card_list_t cards;
-			DPRINTF(("divas: DIA_IOCTL_GET_LIST"));
-			DivasGetList(&cards);
-			if(copy_to_user((void *)arg, &cards, sizeof(cards)))
-				return -EFAULT;
-			return 0;
-		}
-		case DIA_IOCTL_GET_MEM:
-		{
-			mem_block_t mem_block;
-			if (copy_from_user(&mem_block, (void *)arg, sizeof(mem_block_t)))
-				return -EFAULT;
-			DivasGetMem(&mem_block);
-			return 0;
-		}
-
-		case DIA_IOCTL_UNLOCK:
-			UnlockDivas();
-			return 0;
-
-		default:
-			return -EINVAL;
-	}
-	return -EINVAL;
-}
-
-unsigned int do_poll(struct file *pFile, struct poll_table_struct *pPollTable)
-{
-	word wMask = 0;
-
-	if (!DivasLogFifoEmpty())
-		wMask |= POLLIN | POLLRDNORM;
-	return wMask;
-}
-
-ssize_t do_read(struct file *pFile, char *pUserBuffer, size_t BufferSize, loff_t *pOffset)
-{
-	klog_t *pClientLogBuffer = (klog_t *) pUserBuffer;
-	klog_t *pHeadItem;
-
-	if (BufferSize < sizeof(klog_t))
-		return -EIO;
-
-	pHeadItem = (klog_t *) DivasLogFifoRead();
-
-	if (pHeadItem) {
-		if (copy_to_user(pClientLogBuffer, pHeadItem, sizeof(klog_t))) {
-			kfree(pHeadItem);
-			return -EFAULT;
-		}
-		kfree(pHeadItem);
-		return sizeof(klog_t);
-	}
-
-	return 0;
-}
-static int private_usage_count;
-
-int do_open(struct inode *pInode, struct file *pFile)
-{
-	MOD_INC_USE_COUNT;
-#ifdef MODULE
-	private_usage_count++;
-#endif
-	return 0;
-}
-
-int do_release(struct inode *pInode, struct file *pFile)
-{
-	MOD_DEC_USE_COUNT;
-#ifdef MODULE
-	private_usage_count--;
-#endif
-	return 0;
-}
-
-void UnlockDivas(void)
-{
-	while (private_usage_count > 0)
-	{
-		private_usage_count--;
-		MOD_DEC_USE_COUNT;
-	}
-}
diff -puN -L drivers/isdn/eicon/linio.c drivers/isdn/eicon/linio.c~linus /dev/null
--- 25/drivers/isdn/eicon/linio.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,729 +0,0 @@
-/*
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.16  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#define N_DATA
-
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/interrupt.h>
-#include <linux/smp_lock.h>
-#include <asm/io.h>
-#include <asm/system.h>
-#include <linux/slab.h>
-#include <linux/pci.h>
-#include <linux/delay.h>
-#undef N_DATA
-
-#include "uxio.h"
-
-static
-int log_on=0;
-
-int		Divasdevflag = 0;
-
-spinlock_t diva_lock = SPIN_LOCK_UNLOCKED;
-
-static
-ux_diva_card_t card_pool[MAX_CARDS];
-
-void UxPause(long int ms)
-{
-	unsigned long timeout = jiffies + ((ms * HZ) / 1000);
-
-	while (time_before(jiffies, timeout));
-}
-
-int UxCardHandleGet(ux_diva_card_t **card, dia_card_t *cfg)
-{
-	int 		i;
-	ux_diva_card_t	*c;
-
-	if (cfg->bus_type != DIA_BUS_TYPE_PCI)
-	{
-		DPRINTF(("divas hw: type not PCI (%d)", cfg->bus_type));
-		return -1;
-	}
-
-	for (i = 0; (i < DIM(card_pool)) && (card_pool[i].in_use); i++)
-	{
-		;
-	}
-
-	if (i == DIM(card_pool))
-	{
-		DPRINTF(("divas hw: card_pool exhausted"));
-		return -1;
-	}
-
-	c = *card = &card_pool[i];
-
-	switch (cfg->bus_type)
-	{
-	case DIA_BUS_TYPE_PCI:
-		c->pdev = cfg->pdev;
-		c->io_base = cfg->io_base;
-		c->reset_base = cfg->reset_base;
-		c->card_type    = cfg->card_type;
-		c->mapped = NULL;
-		c->slot 	= cfg->slot;
-		c->irq 		= (int) cfg->irq;
-		c->pDRAM    	= cfg->memory[DIVAS_RAM_MEMORY];
-		c->pDEVICES 	= cfg->memory[DIVAS_REG_MEMORY];
-		c->pCONFIG  	= cfg->memory[DIVAS_CFG_MEMORY];
-		c->pSHARED  	= cfg->memory[DIVAS_SHARED_MEMORY];
-		c->pCONTROL  	= cfg->memory[DIVAS_CTL_MEMORY];
-
-	/*		c->bus_type 	= DIA_BUS_TYPE_PCI;
-		c->bus_num 	= cfg->bus_num & 0x3f;
-		c->slot 	= cfg->slot;
-		c->irq 		= (int) cfg->irq;
-		c->int_priority = (int) cfg->int_priority;
-		c->card_type    = cfg->card_type;
-		c->io_base      = cfg->io_base;
-		c->reset_base   = cfg->reset_base;
-		c->pDRAM    	= cfg->memory[DIVAS_RAM_MEMORY];
-		c->pDEVICES 	= cfg->memory[DIVAS_REG_MEMORY];
-		c->pCONFIG  	= cfg->memory[DIVAS_CFG_MEMORY];
-		c->pSHARED  	= cfg->memory[DIVAS_SHARED_MEMORY];
-		DPRINTF(("divas hw: pDRAM is 0x%x", c->pDRAM));
-		DPRINTF(("divas hw: pSHARED is 0x%x", c->pSHARED));
-		DPRINTF(("divas hw: pCONFIG is 0x%x", c->pCONFIG));
-		c->cm_key		= cm_getbrdkey("Divas", cfg->card_id);*/
-		break;
-	default:
-		break;
-	}
-
-	c->in_use = TRUE;
-
-	return 0;
-}
-
-void UxCardHandleFree(ux_diva_card_t *card)
-{
-	card->in_use = FALSE;
-}
-
-
-#define PLX_IOBASE 0
-#define DIVAS_IOBASE 1
-void *UxCardMemAttach(ux_diva_card_t *card, int id)
-{
-	if (card->card_type == DIA_CARD_TYPE_DIVA_SERVER)
-	{
-		switch (id)
-		{
-		case DIVAS_SHARED_MEMORY:
-			card->mapped = card->pSHARED;
-			return card->pSHARED;
-			break;
-		case DIVAS_RAM_MEMORY:
-			card->mapped = card->pDRAM;
-			return card->pDRAM;
-			break;
-		case DIVAS_REG_MEMORY:
-			card->mapped = card->pDEVICES;
-			return card->pDEVICES;
-			break;
-		case DIVAS_CFG_MEMORY:
-			card->mapped = card->pCONFIG;
-			return card->pCONFIG;
-			break;
-		default:
-			ASSERT(FALSE);
-			card->mapped = NULL;
-			return (void *) 0;
-		}
-	}
-	else if (card->card_type == DIA_CARD_TYPE_DIVA_SERVER_B)
-	{
-		switch (id)
-		{
-		case PLX_IOBASE:
-			return (void *) card->reset_base;
-			break;
-		case DIVAS_IOBASE:
-			return (void *) card->io_base;
-			break;
-		default:
-			ASSERT(FALSE);
-			return 0;
-		}
-	}
-	
-	else if (card->card_type == DIA_CARD_TYPE_DIVA_SERVER_Q)
-	{
-		switch (id)
-		{
-		case DIVAS_SHARED_MEMORY:
-			card->mapped = card->pSHARED;
-			return card->pSHARED;
-			break;
-		case DIVAS_RAM_MEMORY:
-			card->mapped = card->pDRAM;
-			return card->pDRAM;
-			break;
-		case DIVAS_REG_MEMORY:
-			card->mapped = (void *) card->io_base;
-			return (void *) card->io_base;
-			break;
-		case DIVAS_CTL_MEMORY:
-			card->mapped = card->pCONTROL;
-			return card->pCONTROL;
-			break;
-		default:
-			// ASSERT(FALSE);
-			DPRINTF(("divas: Trying to attach to mem %d", id));
-			card->mapped = NULL;
-			return (void *) 0;
-		}
-	} else
-		DPRINTF(("divas: Tried to attach to unknown card"));
-
-	/* Unknown card type */
-	return NULL;
-}
-
-void UxCardMemDetach(ux_diva_card_t *card, void *address)
-{
-	return; // Just a place holder. No un-mapping done.
-}
-
-void UxCardLog(int turn_on)
-{
-	log_on = turn_on;
-}
-
-/*
- * Control Register I/O Routines to be performed on Attached I/O ports
- */
-
-void UxCardPortIoOut(ux_diva_card_t *card, void *AttachedBase, int offset, byte the_byte)
-{
-	word base = (word) (dword) AttachedBase;
-
-	base += offset;
-
-	outb(the_byte, base);
-}
-
-void UxCardPortIoOutW(ux_diva_card_t *card, void *AttachedBase, int offset, word the_word)
-{
-	word base = (word) (dword) AttachedBase;
-
-	base += offset;
-
-	outw(the_word, base);
-}
-
-void UxCardPortIoOutD(ux_diva_card_t *card, void *AttachedBase, int offset, dword the_dword)
-{
-	word base = (word) (dword) AttachedBase;
-
-	base += offset;
-
-	outl(the_dword, base);
-}
-
-byte UxCardPortIoIn(ux_diva_card_t *card, void *AttachedBase, int offset)
-{
-	word base = (word) (dword) AttachedBase;
-
-	base += offset;
-
-	return inb(base);
-}
-
-word UxCardPortIoInW(ux_diva_card_t *card, void *AttachedBase, int offset)
-{
-	word base = (word) (dword) AttachedBase;
-
-	base += offset;
-
-	return inw(base);
-}
-
-/*
- * Memory mapped card I/O functions
- */
-
-byte UxCardMemIn(ux_diva_card_t *card, void *address)
-{
-	byte	b;
-	volatile byte* t = (byte*)address;
-
-	b = *t;
-
-	if (log_on)
-	{
-		byte *a = address;
-		a -= (int) card->mapped;
-		DPRINTF(("divas hw: read 0x%02x from 0x%x (memory mapped)", b & 0xff, a));
-    	}
-
-    return(b); 
-}
-
-word UxCardMemInW(ux_diva_card_t *card, void *address)
-{
-	word	w;
-	volatile word* t = (word*)address;
-
-    w = *t;
-
-	if (log_on)
-    {
-		byte *a = address;
-		a -= (int) card->mapped;
-		DPRINTF(("divas hw: read 0x%04x from 0x%x (memory mapped)", w & 0xffff, a));
-    }
-
-    return (w);
-}
-
-dword UxCardMemInD(ux_diva_card_t *card, void *address)
-{
-	dword	dw;
-	volatile dword* t = (dword*)address;
-
-    dw = *t;
-
-	if (log_on)
-    {
-		byte *a = address;
-		a -= (int) card->mapped;
-		DPRINTF(("divas hw: read 0x%08x from 0x%x (memory mapped)", dw, a));
-    }
-
-    return (dw);
-}
-
-void UxCardMemInBuffer(ux_diva_card_t *card, void *address, void *buffer, int length)
-{
-	volatile byte *pSource = address;
-	byte *pDest = buffer;
-
-	while (length--)
-	{
-		*pDest++ = *pSource++;
-	}
-
-	if (log_on)
-    {
-		byte *a = address;
-		a -= (int) card->mapped;
-		pDest = buffer;
-		DPRINTF(("divas hw: read %02x %02x %02x %02x %02x %02x %02x %02x from 0x%x (memory mapped)", 
-		pDest[0] & 0xff, pDest[1] & 0xff, pDest[2] & 0xff, pDest[3] & 0xff,
-		pDest[4] & 0xff, pDest[5] & 0xff, pDest[6] & 0xff, pDest[7] & 0xff,
-		a));
-    }
-
-    return;
-}
-
-void UxCardMemOut(ux_diva_card_t *card, void *address, byte data)
-{
-	volatile byte* t = (byte*)address;
-
-	if (log_on)
-	{
-		byte *a = address;
-		a -= (int) card->mapped;
-		DPRINTF(("divas hw: wrote 0x%02x to 0x%x (memory mapped)", data & 0xff, a));
-	}
-
-	*t = data;
-
-    	return;
-}
-
-void UxCardMemOutW(ux_diva_card_t *card, void *address, word data)
-{
-	volatile word* t = (word*)address;
-
-	if (log_on)
-	{
-		byte *a = address;
-		a -= (int) card->mapped;
-		DPRINTF(("divas hw: wrote 0x%04x to 0x%x (memory mapped)", data & 0xffff, a));
-	}
-
-	*t = data;
-    return;
-}
-
-void UxCardMemOutD(ux_diva_card_t *card, void *address, dword data)
-{
-	volatile dword* t = (dword*)address;
-
-	if (log_on)
-	{
-		byte *a = address;
-		a -= (int) card->mapped;
-		DPRINTF(("divas hw: wrote 0x%08x to 0x%x (memory mapped)", data, a));
-	}
-
-	*t = data;
-    return;
-}
-
-void UxCardMemOutBuffer(ux_diva_card_t *card, void *address, void *buffer, int length)
-{
-	byte 	*pSource = buffer;
-	byte	*pDest = address;
-
-	while (length--)
-	{
-		*pDest++ = *pSource++;
-	}
-
-	if (log_on)
-    {
-		byte *a = address;
-		a -= (int) card->mapped;
-		pDest = buffer;
-		DPRINTF(("divas hw: wrote %02x %02x %02x %02x %02x %02x %02x %02x to 0x%x (memory mapped)", 
-		pDest[0] & 0xff, pDest[1] & 0xff, pDest[2] & 0xff, pDest[3] & 0xff,
-		pDest[4] & 0xff, pDest[5] & 0xff, pDest[6] & 0xff, pDest[7] & 0xff,
-		a));
-    }
-
-    return;
-}
-
-/*
- * Memory mapped card I/O functions
- */
-
-byte UxCardIoIn(ux_diva_card_t *card, void *AttachedDivasIOBase, void *address)
-
-{
-	byte the_byte;
-
-    outb(0xFF, card->io_base + 0xC);
-	outw((word) (dword) address, card->io_base + 4);
-
-	the_byte = inb(card->io_base);
-
-	if (log_on)
-    {
-		DPRINTF(("divas hw: read 0x%02x from 0x%x (I/O mapped)", 
-					the_byte & 0xff, address));
-    }
-    
-	return the_byte;
-}
-
-word UxCardIoInW(ux_diva_card_t *card, void *AttachedDivasIOBase, void *address)
-
-{
-	word the_word;
-
-	outb(0xFF, card->io_base + 0xC);
-	outw((word) (dword) address, card->io_base + 4);
-	the_word = inw(card->io_base);
-
-	if (log_on)
-    {
-		DPRINTF(("divas hw: read 0x%04x from 0x%x (I/O mapped)", 
-					the_word & 0xffff, address));
-    }
-
-	return the_word;
-}
-
-dword UxCardIoInD(ux_diva_card_t *card, void *AttachedDivasIOBase, void *address)
-
-{
-	dword the_dword;
-
-	outb(0xFF, card->io_base + 0xC);
-	outw((word) (dword) address, card->io_base + 4);
-	the_dword = inl(card->io_base);
-
-	if (log_on)
-    {
-		DPRINTF(("divas hw: read 0x%08x from 0x%x (I/O mapped)", 
-					the_dword, address));
-    }
-
-    return the_dword;
-}
-
-void UxCardIoInBuffer(ux_diva_card_t *card, void *AttachedDivasIOBase, void *address, void *buffer, int length)
-
-{
-	byte *pSource = address;
-	byte *pDest = buffer;
-
-	if ((word) (dword) address & 0x1)
-	{
-		outb(0xFF, card->io_base + 0xC);
-		outw((word) (dword) pSource, card->io_base + 4);
-		*pDest = (byte) inb(card->io_base);
-		pDest++;
-		pSource++;
-		length--;
-		if (!length)
-        {
-            return;
-        }
-    }
-
-	outb(0xFF, card->io_base + 0xC);
-	outw((word) (dword) pSource, card->io_base + 4);
-	insw(card->io_base, (word *)pDest,length%2 ? (length+1)>>1 : length>>1);
-
-	if (log_on)
-    {
-		pDest = buffer;
-		DPRINTF(("divas hw: read %02x %02x %02x %02x %02x %02x %02x %02x from 0x%x (I/O mapped)", 
-		pDest[0] & 0xff, pDest[1] & 0xff, pDest[2] & 0xff, pDest[3] & 0xff,
-		pDest[4] & 0xff, pDest[5] & 0xff, pDest[6] & 0xff, pDest[7] & 0xff,
-		address));
-    }
-
-    return;
-}
-
-/* Output */
-
-void UxCardIoOut(ux_diva_card_t *card, void *AttachedDivasIOBase, void *address, byte data)
-{
-	if (log_on)
-    {
-		DPRINTF(("divas hw: wrote 0x%02x to 0x%x (I/O mapped)", 
-					data & 0xff, address));
-    }
-
-	outb(0xFF, card->io_base + 0xC);
-	outw((word) (dword) address, card->io_base + 4);
-	outb((byte) data & 0xFF, card->io_base);
-
-    return;
-}
-
-void UxCardIoOutW(ux_diva_card_t *card, void *AttachedDivasIOBase, void *address, word data)
-{
-	if (log_on)
-    {
-		DPRINTF(("divas hw: wrote 0x%04x to 0x%x (I/O mapped)", 
-					data & 0xffff, address));
-    }
-
-	outb(0xFF, card->io_base + 0xC);
-	outw((word) (dword) address, card->io_base + 4);
-	outw((word) data & 0xFFFF, card->io_base);
-
-    return;
-}
-
-void UxCardIoOutD(ux_diva_card_t *card, void *AttachedDivasIOBase, void *address, dword data)
-{
-	if (log_on)
-    {
-		DPRINTF(("divas hw: wrote 0x%08x to 0x%x (I/O mapped)", data, address));
-    }
-
-	outb(0xFF, card->io_base + 0xC);
-	outw((word) (dword) address, card->io_base + 4);
-	outl((dword) data & 0xFFFFFFFF, card->io_base);
-
-    return;
-}
-
-void UxCardIoOutBuffer(ux_diva_card_t *card, void *AttachedDivasIOBase, void *address, void *buffer, int length)
-
-{
-	byte 	*pSource = buffer;
-	byte	*pDest = address;
-
-	if ((word) (dword) address & 1)
-	{
-		outb(0xFF, card->io_base + 0xC);
-		outw((word) (dword) pDest, card->io_base + 4);
-		outb(*pSource, card->io_base);
-		pSource++;
-		pDest++;
-		length--;
-		if (!length)
-        {
-			return;
-        }
-	}
-
-    outb(0xFF, card->io_base + 0xC);
-	outw((word) (dword) pDest, card->io_base + 4);
-	outsw(card->io_base, (word *)pSource, length%2 ? (length+1)>>1 : length>>1);
-
-	if (log_on)
-    {
-		pDest = buffer;
-		DPRINTF(("divas hw: wrote %02x %02x %02x %02x %02x %02x %02x %02x to 0x%x (I/O mapped)", 
-		pDest[0] & 0xff, pDest[1] & 0xff, pDest[2] & 0xff, pDest[3] & 0xff,
-		pDest[4] & 0xff, pDest[5] & 0xff, pDest[6] & 0xff, pDest[7] & 0xff,
-		address));
-    }
-
-    return;
-}
-
-irqreturn_t Divasintr(int arg, void *unused, struct pt_regs *unused_regs)
-{
-	int i;
-	card_t *card = NULL;
-	ux_diva_card_t *ux_ref = NULL;
-
-	for (i = 0; i < DivasCardNext; i++)
-	{
-
-		if (arg == DivasCards[i].cfg.irq)
-		{
-			card = &DivasCards[i];
-			ux_ref = card->hw;
-	
-			if ((ux_ref) && (card->is_live))
-			{
-				(*ux_ref->user_isr)(ux_ref->user_isr_arg);	
-			}
-			else 
-			{
-				DPRINTF(("divas: ISR couldn't locate card"));
-			}
-		}
-	}
-
-	return IRQ_HANDLED;
-}
-
-
-int UxIsrInstall(ux_diva_card_t *card, isr_fn_t *isr_fn, void *isr_arg)
-{
-	int result;
-
-        card->user_isr = isr_fn;
-        card->user_isr_arg = isr_arg;
-
-	result = request_irq(card->irq, Divasintr, SA_INTERRUPT | SA_SHIRQ, "Divas", (void *) isr_arg);
-
-	return result;
-}
-
-void UxIsrRemove(ux_diva_card_t *card, void *dev_id)
-{
-	free_irq(card->irq, card->user_isr_arg);
-}
-
-void UxPciConfigWrite(ux_diva_card_t *card, int size, int offset, void *value)
-{
-	switch (size) {
-	case sizeof(byte):
-		pci_write_config_byte(card->pdev, offset, * (byte *) value);
-		break;
-	case sizeof(word):
-		pci_write_config_word(card->pdev, offset, * (word *) value);
-		break;
-	case sizeof(dword):
-		pci_write_config_dword(card->pdev, offset, * (dword *) value);
-		break;
-	default:
-		printk(KERN_WARNING "Divas: Invalid size in UxPciConfigWrite\n");
-	}
-}
-
-void UxPciConfigRead(ux_diva_card_t *card, int size, int offset, void *value)
-{
-	switch (size) {
-	case sizeof(byte):
-		pci_read_config_byte(card->pdev, offset, (byte *) value);
-		break;
-	case sizeof(word):
-		pci_read_config_word(card->pdev, offset, (word *) value);
-		break;
-	case sizeof(dword):
-		pci_read_config_dword(card->pdev, offset, (unsigned int *) value);
-		break;
-	default:
-		printk(KERN_WARNING "Divas: Invalid size in UxPciConfigRead\n");
-	}
-}
-
-void *UxAlloc(unsigned int size)
-{
-	void *m;
-
-	m = kmalloc(size, GFP_ATOMIC);
-
-	return m;
-}
-
-void UxFree(void *ptr)
-{
-	kfree(ptr);
-}
-
-long UxCardLock(ux_diva_card_t *card)
-{
-	unsigned long flags;
-
- 	spin_lock_irqsave(&diva_lock, flags);
-	
-	return flags;
-}
-
-void UxCardUnlock(ux_diva_card_t *card, unsigned long ipl)
-{
-	spin_unlock_irqrestore(&diva_lock, ipl);
-}
-
-dword UxTimeGet(void)
-{
-	return jiffies;
-}
-
-long UxInterlockedIncrement(ux_diva_card_t *card, long *dst)
-{
-	register volatile long *p;
-	register long ret;
-	int ipl;
-
-	p =dst;
-	
-	ipl = UxCardLock(card);
-
-	*p += 1;
-	ret = *p;
-
-	UxCardUnlock(card,ipl);
-
-	return(ret);
-
-}
-
-long UxInterlockedDecrement(ux_diva_card_t *card, long *dst)
-{
-	register volatile long *p;
-	register long ret;
-	int ipl;
-
-	p =dst;
-	
-	ipl = UxCardLock(card);
-
-	*p -= 1;
-	ret = *p;
-
-	UxCardUnlock(card,ipl);
-
-	return(ret);
-
-}
diff -puN -L drivers/isdn/eicon/linsys.c drivers/isdn/eicon/linsys.c~linus /dev/null
--- 25/drivers/isdn/eicon/linsys.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,136 +0,0 @@
-/*
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.10  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#include <linux/sched.h>
-#undef N_DATA
-#include <linux/workqueue.h>
-
-#include <linux/smp.h>
-struct pt_regs;
-#include <linux/interrupt.h>
-#include <linux/ioport.h>
-
-#include "sys.h"
-#include "divas.h"
-#include "adapter.h"
-#include "divalog.h"
-
-#include "uxio.h"
-
-static struct tasklet_struct DivasTask;
-
-int Divas4BRIInitPCI(card_t *card, dia_card_t *cfg)
-{
-	/* Use UxPciConfigWrite	routines to initialise PCI config space */
-
-/*	wPCIcommand = 0x03;
-	cm_write_devconfig16(CMKey, PCI_COMMAND, &wPCIcommand);
-
-	wPCIcommand = 0x280;
-	cm_write_devconfig16(CMKey, PCI_STATUS, &wPCIcommand);
-
-	bPCIcommand = 0x30;
-	cm_write_devconfig16(CMKey, PCI_STATUS, &wPCIcommand);
-*/
-	return 0; 
-}
-
-int DivasPRIInitPCI(card_t *card, dia_card_t *cfg)
-{
-	/* Use UxPciConfigWrite	routines to initialise PCI config space */
-
-/*		wPCIcommand = 0x03;
-	cm_write_devconfig16(CMKey, PCI_COMMAND, &wPCIcommand);
-	
-	wPCIcommand = 0x280;
-	cm_write_devconfig16(CMKey, PCI_STATUS, &wPCIcommand);
-	
-	bPCIcommand = 0x30;
-	cm_write_devconfig8(CMKey, PCI_LATENCY, &bPCIcommand);*/
-
-	return 0;  
-}
-
-int DivasBRIInitPCI(card_t *card, dia_card_t *cfg)
-{
-	/* Need to set these platform dependent values after patching */
-
-	card->hw->reset_base = card->cfg.reset_base;
-	card->hw->io_base = card->cfg.io_base;
-
-	request_region(card->hw->reset_base,0x80,"Divas");
-	request_region(card->hw->io_base,0x20,"Divas");
-
-
-	/* Same as for PRI */
-	return DivasPRIInitPCI(card, cfg);
-}
-
-/* ######################### Stubs of routines that are not done yet ################## */
-/*void DivasLogIdi(card_t *card, ENTITY *e, int request)
-{
-}
-*/
-
-int	DivasDpcSchedule(void)
-{
-	tasklet_schedule(&DivasTask);
-
-	return 0;
-}
-
-int	DivasScheduleRequestDpc(void)
-{
-	tasklet_schedule(&DivasTask);
-
-	return 0;
-}
-
-void DivasInitDpc(void)
-{
-	tasklet_init(&DivasTask, DivasDoDpc, 0);
-}
-
-void    DivasLogAdd(void *buffer, int length)
-{
-    static
-    boolean_t   overflow = FALSE;
-    static
-    boolean_t   busy = FALSE;
-
-    /* make sure we're not interrupting ourselves */
-
-    if (busy)
-    {
-        printk(KERN_DEBUG "Divas: Logging interrupting self !\n");
-        return;
-    }
-    busy = TRUE;
-
-    /* ignore call if daemon isn't running and we've reached limit */
-
-    if (DivasLogFifoFull())
-    {
-        if (!overflow)
-        {
-            printk(KERN_DEBUG "Divas: Trace buffer full\n");
-            overflow = TRUE;
-        }
-        busy = FALSE;
-        return;
-    }
-
-	DivasLogFifoWrite(buffer, length);
-
-    busy = FALSE;
-    return;
-}
-
-/* #################################################################################### */
diff -puN -L drivers/isdn/eicon/log.c drivers/isdn/eicon/log.c~linus /dev/null
--- 25/drivers/isdn/eicon/log.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,160 +0,0 @@
-/*
- * Source file for diva log facility
- *
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.5  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#include "sys.h"
-#include "idi.h"
-#include "divas.h"
-#include "adapter.h"
-#include "divalog.h"
-
-#include "uxio.h"
-
-/*Counter to monitor number of messages */ 
-static int m_count;
- 
-#define     MAX_BUFFERED_MSGS   (1000)
-
-/* Our Linked List Structure to hold message */
-typedef struct klog_link{
-  klog_t klog;
-  struct klog_link *next;
-}KNODE;
-
-/* First & Last structures in list*/
-KNODE *head;
-KNODE *tail;
-
-/* 
- * retrieve message from FIFO buffer
- * returns NULL if buffer empty
- * otherwise returns pointer to entry 
- */
-
-char	*DivasLogFifoRead(void)
-
-{
-	KNODE *old_head;
-
-	if(head==NULL) 
-	{
-		/* Buffer Empty - No Messages */
-		return NULL;	
-	}
-
-	m_count--;
-	/* Keep track of message to be read & increment to next message*/
-	old_head = head;
-	head = head->next;
-    /*Return ptr to Msg */	
-    return((char *)old_head);
-}
-
-/* 
- * write message into FIFO buffer
- */
-
-void	DivasLogFifoWrite(char *entry, int length)
-
-{
-    KNODE *new_klog;
-
-    if(head == NULL) 
-    {
-	/* No Entries in Log */
-	tail=NULL;
-	m_count=0;
-	new_klog=UxAlloc(sizeof(KNODE));
-
-	if(new_klog==NULL)
-	{
-		return;
-	}
-
-	m_count++;
-	memset(new_klog, 0, sizeof(KNODE));
-
-	/* Set head & tail to point to the new Msg Struct */
-	head=tail=new_klog;
-	tail->next=NULL;
-    }
-    else
-    {
-	new_klog=UxAlloc(sizeof(KNODE));
-	
-	if(new_klog==NULL)
-	{
-		return;
-	}
-
-	m_count++;
-	memset(new_klog, 0, sizeof(KNODE));
-
-	/* Let last Msg Struct point to new Msg Struct & inc tail */
-	tail->next=new_klog;
-	tail=new_klog;
-	tail->next=NULL;
-    }
-
-    if (length > sizeof(klog_t))
-    {
-        length = sizeof(klog_t);
-    }
-
-    memcpy(&tail->klog, entry, length);
-
-    return;
-}
-
-/*
- * DivaslogFifoEmpty:return TRUE if FIFO buffer is empty,otherwise FALSE
- */
-int DivasLogFifoEmpty(void)
-{
-	return (m_count == 0);
-}
-
-/*
- *DivasLogFifoFull:return TRUE if FIFO buffer is full,otherwise FALSE
- */
-int DivasLogFifoFull(void)
-{
-	return (m_count == MAX_BUFFERED_MSGS);
-}
-
-/*
- * generate an IDI log entry
- */
-
-void	DivasLogIdi(card_t *card, ENTITY *e, int request)
-
-{
-	klog_t		klog;
-
-	memset(&klog, 0, sizeof(klog));
-
-	klog.time_stamp = UxTimeGet();
-
-	klog.length = sizeof(ENTITY) > sizeof(klog.buffer) ?
-						sizeof(klog.buffer) : sizeof(ENTITY);
-
-	klog.card = (int) (card - DivasCards);
-
-	klog.type = request ? KLOG_IDI_REQ : KLOG_IDI_CALLBACK;
-	klog.code = 0;
-	memcpy(klog.buffer, e, klog.length);
-
-    /* send to the log driver and return */
-
-    DivasLogAdd(&klog, sizeof(klog));
-
-	return;
-}
diff -puN -L drivers/isdn/eicon/Makefile drivers/isdn/eicon/Makefile~linus /dev/null
--- 25/drivers/isdn/eicon/Makefile
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,19 +0,0 @@
-# Makefile for the eicon ISDN device driver
-
-# Each configuration option enables a list of files.
-
-obj-$(CONFIG_ISDN_DRV_EICON_OLD)    	+= eicon.o
-obj-$(CONFIG_ISDN_DRV_EICON_DIVAS)	+= divas.o
-
-# Multipart objects.
-
-eicon-y					:= eicon_mod.o eicon_isa.o eicon_pci.o \
-					   eicon_idi.o eicon_io.o
-eicon-$(CONFIG_ISDN_DRV_EICON_PCI)	+= common.o idi.o bri.o pri.o log.o \
-		   			   xlog.o kprintf.o fpga.o fourbri.o lincfg.o \
-					   linchr.o linsys.o linio.o
-
-divas-y					:= common.o idi.o bri.o pri.o log.o xlog.o \
-					   kprintf.o fpga.o fourbri.o lincfg.o \
-					   linchr.o linsys.o linio.o Divas_mod.o
-
diff -puN -L drivers/isdn/eicon/pc.h drivers/isdn/eicon/pc.h~linus /dev/null
--- 25/drivers/isdn/eicon/pc.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,292 +0,0 @@
-/*
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.2  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#ifndef PC_H_INCLUDED
-#define PC_H_INCLUDED
-
-/*------------------------------------------------------------------*/
-/* buffer definition                                                */
-/*------------------------------------------------------------------*/
-
-typedef struct {
-  word length;          /* length of data/parameter field           */
-  byte P[270];          /* data/parameter field                     */
-} PBUFFER;
-
-/*------------------------------------------------------------------*/
-/* dual port ram structure                                          */
-/*------------------------------------------------------------------*/
-
-struct dual
-{
-  byte Req;             /* request register                         */
-  byte ReqId;           /* request task/entity identification       */
-  byte Rc;              /* return code register                     */
-  byte RcId;            /* return code task/entity identification   */
-  byte Ind;             /* Indication register                      */
-  byte IndId;           /* Indication task/entity identification    */
-  byte IMask;           /* Interrupt Mask Flag                      */
-  byte RNR;             /* Receiver Not Ready (set by PC)           */
-  byte XLock;           /* XBuffer locked Flag                      */
-  byte Int;             /* ISDN-S interrupt                         */
-  byte ReqCh;           /* Channel field for layer-3 Requests       */
-  byte RcCh;            /* Channel field for layer-3 Returncodes    */
-  byte IndCh;           /* Channel field for layer-3 Indications    */
-  byte MInd;            /* more data indication field               */
-  word MLength;         /* more data total packet length            */
-  byte ReadyInt;        /* request field for ready interrupt        */
-  byte SWReg;           /* Software register for special purposes   */  
-  byte Reserved[11];    /* reserved space                           */
-  byte InterfaceType;   /* interface type 1=16K interface           */
-  word Signature;       /* ISDN-S adapter Signature (GD)            */
-  PBUFFER XBuffer;      /* Transmit Buffer                          */
-  PBUFFER RBuffer;      /* Receive Buffer                           */
-};
-
-/*------------------------------------------------------------------*/
-/* SWReg Values (0 means no command)                                */
-/*------------------------------------------------------------------*/
-#define SWREG_DIE_WITH_LEDON  0x01
-#define SWREG_HALT_CPU        0x02 /* Push CPU into a while(1) loop */         
-
-/*------------------------------------------------------------------*/
-/* Id Fields Coding                                                 */
-/*------------------------------------------------------------------*/
-
-#define ID_MASK 0xe0    /* Mask for the ID field                    */
-#define GL_ERR_ID 0x1f  /* ID for error reporting on global requests*/
-
-#define DSIG_ID  0x00   /* ID for D-channel signaling               */
-#define NL_ID    0x20   /* ID for network-layer access (B or D)     */
-#define BLLC_ID  0x60   /* ID for B-channel link level access       */
-#define TASK_ID  0x80   /* ID for dynamic user tasks                */
-#define TIMER_ID 0xa0   /* ID for timer task                        */
-#define TEL_ID   0xc0   /* ID for telephone support                 */
-#define MAN_ID   0xe0   /* ID for management                        */
-
-/*------------------------------------------------------------------*/
-/* ASSIGN and REMOVE requests are the same for all entities         */
-/*------------------------------------------------------------------*/
-
-#define ASSIGN  0x01
-#define UREMOVE  0xfe   /* without returncode */  
-#define REMOVE  0xff
-
-/*------------------------------------------------------------------*/
-/* Timer Interrupt Task Interface                                   */
-/*------------------------------------------------------------------*/
-
-#define ASSIGN_TIM 0x01
-#define REMOVE_TIM 0xff
-
-/*------------------------------------------------------------------*/
-/* dynamic user task interface                                      */
-/*------------------------------------------------------------------*/
-
-#define ASSIGN_TSK 0x01
-#define REMOVE_TSK 0xff
-
-#define LOAD 0xf0
-#define RELOCATE 0xf1
-#define START 0xf2
-#define LOAD2 0xf3
-#define RELOCATE2 0xf4
-
-/*------------------------------------------------------------------*/
-/* dynamic user task messages                                       */
-/*------------------------------------------------------------------*/
-
-#define TSK_B2          0x0000
-#define TSK_WAKEUP      0x2000
-#define TSK_TIMER       0x4000
-#define TSK_TSK         0x6000
-#define TSK_PC          0xe000
-
-/*------------------------------------------------------------------*/
-/* LL management primitives                                         */
-/*------------------------------------------------------------------*/
-
-#define ASSIGN_LL 1     /* assign logical link                      */
-#define REMOVE_LL 0xff  /* remove logical link                      */
-
-/*------------------------------------------------------------------*/
-/* LL service primitives                                            */
-/*------------------------------------------------------------------*/
-
-#define LL_UDATA 1      /* link unit data request/indication        */
-#define LL_ESTABLISH 2  /* link establish request/indication        */
-#define LL_RELEASE 3    /* link release request/indication          */
-#define LL_DATA 4       /* data request/indication                  */
-#define LL_LOCAL 5      /* switch to local operation (COM only)     */
-#define LL_DATA_PEND 5  /* data pending indication (SDLC SHM only)  */
-#define LL_REMOTE 6     /* switch to remote operation (COM only)    */
-#define LL_TEST 8       /* link test request                        */
-#define LL_MDATA 9      /* more data request/indication             */
-#define LL_BUDATA 10    /* broadcast unit data request/indication   */
-#define LL_XID 12       /* XID command request/indication           */
-#define LL_XID_R 13     /* XID response request/indication          */
-
-/*------------------------------------------------------------------*/
-/* NL service primitives                                            */
-/*------------------------------------------------------------------*/
-
-#define N_MDATA         1       /* more data to come REQ/IND        */
-#define N_CONNECT       2       /* OSI N-CONNECT REQ/IND            */
-#define N_CONNECT_ACK   3       /* OSI N-CONNECT CON/RES            */
-#define N_DISC          4       /* OSI N-DISC REQ/IND               */
-#define N_DISC_ACK      5       /* OSI N-DISC CON/RES               */
-#define N_RESET         6       /* OSI N-RESET REQ/IND              */
-#define N_RESET_ACK     7       /* OSI N-RESET CON/RES              */
-#define N_DATA          8       /* OSI N-DATA REQ/IND               */
-#define N_EDATA         9       /* OSI N-EXPEDITED DATA REQ/IND     */
-#define N_UDATA         10      /* OSI D-UNIT-DATA REQ/IND          */
-#define N_BDATA         11      /* BROADCAST-DATA REQ/IND           */
-#define N_DATA_ACK      12      /* data ack ind for D-bit procedure */
-#define N_EDATA_ACK     13      /* data ack ind for INTERRUPT       */
-
-#define N_Q_BIT         0x10    /* Q-bit for req/ind                */
-#define N_M_BIT         0x20    /* M-bit for req/ind                */
-#define N_D_BIT         0x40    /* D-bit for req/ind                */
-
-/*------------------------------------------------------------------*/
-/* Signaling management primitives                                  */
-/*------------------------------------------------------------------*/
-
-#define ASSIGN_SIG 1    /* assign signaling task                    */
-#define UREMOVE_SIG 0xfe /* remove signaling task without returncode */
-#define REMOVE_SIG 0xff /* remove signaling task                    */
-
-/*------------------------------------------------------------------*/
-/* Signaling service primitives                                     */
-/*------------------------------------------------------------------*/
-
-#define CALL_REQ 1      /* call request                             */
-#define CALL_CON 1      /* call confirmation                        */
-#define CALL_IND 2      /* incoming call connected                  */
-#define LISTEN_REQ 2    /* listen request                           */
-#define HANGUP 3        /* hangup request/indication                */
-#define SUSPEND 4       /* call suspend request/confirm             */
-#define RESUME 5        /* call resume request/confirm              */
-#define SUSPEND_REJ 6   /* suspend rejected indication              */
-#define USER_DATA 8     /* user data for user to user signaling     */
-#define CONGESTION 9    /* network congestion indication            */
-#define INDICATE_REQ 10 /* request to indicate an incoming call     */
-#define INDICATE_IND 10 /* indicates that there is an incoming call */
-#define CALL_RES 11     /* accept an incoming call                  */
-#define CALL_ALERT 12   /* send ALERT for incoming call             */
-#define INFO_REQ 13     /* INFO request                             */
-#define INFO_IND 13     /* INFO indication                          */
-#define REJECT 14       /* reject an incoming call                  */
-#define RESOURCES 15    /* reserve B-Channel hardware resources     */
-#define TEL_CTRL 16     /* Telephone control request/indication     */
-#define STATUS_REQ 17   /* Request D-State (returned in INFO_IND)   */
-#define FAC_REG_REQ 18  /* connection idependent fac registration   */
-#define FAC_REG_ACK 19  /* fac registration acknowledge             */
-#define FAC_REG_REJ 20  /* fac registration reject                  */
-#define CALL_COMPLETE 21/* send a CALL_PROC for incoming call       */
-#define FACILITY_REQ 22 /* send a Facility Message type             */
-#define FACILITY_IND 22 /* Facility Message type indication         */
-#define SIG_CTRL     29 /* Control for signalling hardware          */
-#define DSP_CTRL     30 /* Control for DSPs                         */
-#define LAW_REQ      31 /* Law config request for (returns info_i)  */ 
-
- 
-/*------------------------------------------------------------------*/
-/* management service primitives                                    */
-/*------------------------------------------------------------------*/
-
-#define MAN_READ        2
-#define MAN_WRITE       3
-#define MAN_EXECUTE     4
-#define MAN_EVENT_ON    5
-#define MAN_EVENT_OFF   6
-#define MAN_LOCK        7
-#define MAN_UNLOCK      8   
-
-#define MAN_INFO_IND    2
-#define MAN_EVENT_IND   3
-#define MAN_TRACE_IND   4  
-
-#define MAN_ESC         0x80
-
-/*------------------------------------------------------------------*/
-/* return code coding                                               */
-/*------------------------------------------------------------------*/
-
-#define UNKNOWN_COMMAND         0x01    /* unknown command          */
-#define WRONG_COMMAND           0x02    /* wrong command            */
-#define WRONG_ID                0x03    /* unknown task/entity id   */
-#define WRONG_CH                0x04    /* wrong task/entity id     */
-#define UNKNOWN_IE              0x05    /* unknown information el.  */
-#define WRONG_IE                0x06    /* wrong information el.    */
-#define OUT_OF_RESOURCES        0x07    /* ISDN-S card out of res.  */
-#define ADAPTER_DEAD            0x08    /* ISDN card CPU halted     */ 
-#define N_FLOW_CONTROL          0x10    /* Flow-Control, retry      */
-#define ASSIGN_RC               0xe0    /* ASSIGN acknowledgement   */
-#define ASSIGN_OK               0xef    /* ASSIGN OK                */
-#define OK_FC                   0xfc    /* Flow-Control RC          */
-#define READY_INT               0xfd    /* Ready interrupt          */
-#define TIMER_INT               0xfe    /* timer interrupt          */
-#define OK                      0xff    /* command accepted         */
-
-/*------------------------------------------------------------------*/
-/* information elements                                             */
-/*------------------------------------------------------------------*/
-
-#define SHIFT 0x90              /* codeset shift                    */
-#define MORE 0xa0               /* more data                        */
-#define CL 0xb0                 /* congestion level                 */
-
-        /* codeset 0                                                */
-
-#define BC  0x04                /* Bearer Capability                */
-#define CAU 0x08                /* cause                            */
-#define CAD 0x0c                /* Connected address                */
-#define CAI 0x10                /* call identity                    */
-#define CHI 0x18                /* channel identification           */
-#define LLI 0x19                /* logical link id                  */
-#define CHA 0x1a                /* charge advice                    */
-#define DT  0x29                /* ETSI date/time                   */
-#define KEY 0x2c                /* keypad information element       */
-#define FTY 0x1c                /* facility information element     */ 
-#define DSP 0x28                /* display                          */
-#define OAD 0x6c                /* origination address              */
-#define OSA 0x6d                /* origination sub-address          */
-#define CPN 0x70                /* called party number              */
-#define DSA 0x71                /* destination sub-address          */
-#define RDX 0x73                /* redirected number extended       */
-#define RDN 0x74                /* redirected number                */  
-#define LLC 0x7c                /* low layer compatibility          */
-#define HLC 0x7d                /* high layer compatibility         */
-#define UUI 0x7e                /* user user information            */
-#define ESC 0x7f                /* escape extension                 */
-
-#define DLC 0x20                /* data link layer configuration    */
-#define NLC 0x21                /* network layer configuration      */
-
-        /* codeset 6                                                */
-
-#define SIN 0x01                /* service indicator                */
-#define CIF 0x02                /* charging information             */
-#define DATE 0x03               /* date                             */
-#define CPS 0x07                /* called party status              */
-
-/*------------------------------------------------------------------*/
-/* TEL_CTRL contents                                                */
-/*------------------------------------------------------------------*/
-
-#define RING_ON         0x01
-#define RING_OFF        0x02
-#define HANDS_FREE_ON   0x03
-#define HANDS_FREE_OFF  0x04
-#define ON_HOOK         0x80
-#define OFF_HOOK        0x90
-
-#endif
diff -puN -L drivers/isdn/eicon/pc_maint.h drivers/isdn/eicon/pc_maint.h~linus /dev/null
--- 25/drivers/isdn/eicon/pc_maint.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.0  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#ifndef PC_MAINT_H
-#define PC_MAINT_H
-
-#if !defined(MIPS_SCOM)
-#define BUFFER_SZ  48
-#define MAINT_OFFS 0x380
-#else
-#define BUFFER_SZ  128
-#define MAINT_OFFS 0xff00
-#endif
-
-#define MIPS_BUFFER_SZ  128
-#define MIPS_MAINT_OFFS 0xff00
-
-#define DO_LOG                     1
-#define MEMR                    2
-#define MEMW                    3
-#define IOR                     4
-#define IOW                     5
-#define B1TEST                  6
-#define B2TEST                  7
-#define BTESTOFF                8
-#define DSIG_STATS              9
-#define B_CH_STATS              10
-#define D_CH_STATS              11
-#define BL1_STATS               12
-#define BL1_STATS_C             13
-#define GET_VERSION             14
-#define OS_STATS                15
-#define XLOG_SET_MASK           16
-#define XLOG_GET_MASK           17
-#define DSP_READ                20
-#define DSP_WRITE               21
-
-#define OK 0xff
-#define MORE_EVENTS 0xfe
-#define NO_EVENT 1
-
-struct DSigStruc
-{
-  byte Id;
-  byte uX;
-  byte listen;
-  byte active;
-  byte sin[3];
-  byte bc[6];
-  byte llc[6];
-  byte hlc[6];
-  byte oad[20];
-};
-
-struct BL1Struc {
-  dword cx_b1;
-  dword cx_b2;
-  dword cr_b1;
-  dword cr_b2;
-  dword px_b1;
-  dword px_b2;
-  dword pr_b1;
-  dword pr_b2;
-  word er_b1;
-  word er_b2;
-};
-
-struct L2Struc {
-  dword XTotal;
-  dword RTotal;
-  word XError;
-  word RError;
-};
-
-struct OSStruc {
-  word free_n;
-};
-
-typedef union
-{
-  struct DSigStruc DSigStats;
-  struct BL1Struc BL1Stats;
-  struct L2Struc L2Stats;
-  struct OSStruc OSStats;
-  byte   b[BUFFER_SZ];
-  word   w[BUFFER_SZ>>1];
-  word   l[BUFFER_SZ>>2]; /* word is wrong, do not use! Use 'd' instead. */
-  dword  d[BUFFER_SZ>>2];
-} BUFFER;
-
-typedef union
-{
-  struct DSigStruc DSigStats;
-  struct BL1Struc BL1Stats;
-  struct L2Struc L2Stats;
-  struct OSStruc OSStats;
-  byte   b[MIPS_BUFFER_SZ];
-  word   w[MIPS_BUFFER_SZ>>1];
-  word   l[BUFFER_SZ>>2]; /* word is wrong, do not use! Use 'd' instead. */
-  dword  d[MIPS_BUFFER_SZ>>2];
-} MIPS_BUFFER;
-
-
-#if !defined(MIPS_SCOM)
-struct pc_maint
-{
-  byte req;
-  byte rc;
-  byte *mem;  /*far*/
-  short length;
-  word port;
-  byte fill[6];
-  BUFFER data;
-};
-#else
-struct pc_maint
-{
-  byte req;
-  byte rc;
-  byte reserved[2];     /* R3000 alignment ... */
-  byte far *mem;
-  short length;
-  word port;
-  byte fill[4];         /* data at offset 16   */
-  BUFFER data;
-};
-#endif
-
-struct mi_pc_maint
-{
-  byte req;
-  byte rc;
-  byte reserved[2];     /* R3000 alignment ... */
-  byte *mem; /*far*/
-  short length;
-  word port;
-  byte fill[4];         /* data at offset 16   */
-  MIPS_BUFFER data;
-};
-
-#endif /* PC_MAINT_H */
diff -puN -L drivers/isdn/eicon/pri.c drivers/isdn/eicon/pri.c~linus /dev/null
--- 25/drivers/isdn/eicon/pri.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,517 +0,0 @@
-/*
- * Diva Server PRI specific part of initialisation
- *
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.5  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#include "sys.h"
-#include "idi.h"
-#include "divas.h"
-#include "pc.h"
-#include "pr_pc.h"
-#include "dsp_defs.h"
-
-#include "adapter.h"
-#include "uxio.h"
-
-#define	DIVAS_LOAD_CMD		0x02
-#define	DIVAS_START_CMD		0x03
-#define	DIVAS_IRQ_RESET		0xC18
-#define DIVAS_IRQ_RESET_VAL	0xFE
-
-#define	TEST_INT_DIVAS		0x11
-#define TEST_INT_DIVAS_BRI	0x12
-
-#define DIVAS_RESET	0x81
-#define DIVAS_LED1	0x04
-#define DIVAS_LED2	0x08
-#define DIVAS_LED3	0x20
-#define DIVAS_LED4	0x40
-
-#define	DIVAS_RESET_REG		0x20
-
-#define	DIVAS_SIGNATURE	0x4447
-
-/* offset to start of MAINT area (used by xlog) */
-
-#define	DIVAS_MAINT_OFFSET	0xef00	/* value for PRI card */
-
-#define MP_PROTOCOL_ADDR		0xA0011000
-#define MP_DSP_CODE_BASE		0xa03a0000  
-
-typedef struct {
-		dword cmd;
-		dword addr;
-		dword len;
-		dword err;
-		dword live;
-		dword reserved[(0x1020>>2)-6];
-		dword signature;
-		byte  data[1];
-} diva_server_boot_t;
-
-byte mem_in(ADAPTER *a, void *adr);
-word mem_inw(ADAPTER *a, void *adr);
-void mem_in_buffer(ADAPTER *a, void *adr, void *P, word length);
-void mem_look_ahead(ADAPTER *a, PBUFFER *RBuffer, ENTITY *e);
-void mem_out(ADAPTER *a, void *adr, byte data);
-void mem_outw(ADAPTER *a, void *adr, word data);
-void mem_out_buffer(ADAPTER *a, void *adr, void *P, word length);
-void mem_inc(ADAPTER *a, void *adr);
-
-int DivasPRIInitPCI(card_t *card, dia_card_t *cfg);
-static int pri_ISR (card_t* card);
-
-static int diva_server_reset(card_t *card)
-{
-	byte *reg;
-	diva_server_boot_t *boot = NULL;
-	dword live = 0;
-	int	i = 0;
-	dword	dwWait;
-
-	DPRINTF(("divas: reset Diva Server PRI"));
-
-	reg = UxCardMemAttach(card->hw, DIVAS_REG_MEMORY);
-
-	UxCardMemOut(card->hw, &reg[DIVAS_RESET_REG], DIVAS_RESET | 
-						DIVAS_LED1 | DIVAS_LED2 | DIVAS_LED3 | DIVAS_LED4);
-
-	for (dwWait = 0x000fffff; dwWait; dwWait--)
-		;
-
-	UxCardMemOut(card->hw, &reg[DIVAS_RESET_REG], 0x00);
-
-	for (dwWait = 0x000fffff; dwWait; dwWait--)
-		;
-
-	UxCardMemDetach(card->hw, reg);
-
-	boot = UxCardMemAttach(card->hw, DIVAS_RAM_MEMORY);
-
-	UxCardMemOutD(card->hw, boot->reserved, 0);
-
-	live = UxCardMemInD(card->hw, &boot->live);
-
-	for (i=0; i<5; i++)
-	{
-		if (live != UxCardMemInD(card->hw, &boot->live))
-		{
-			break;
-		}
-		UxPause(10);
-	}
-
-	if (i == 5)
-	{
-		UxCardMemDetach(card->hw, boot);
-
-		DPRINTF(("divas: card is reset but CPU not running"));
-		return -1;
-	}
-
-	UxCardMemDetach(card->hw, boot);
-
-	DPRINTF(("divas: card reset after %d ms", i * 10));
-
-	return 0;
-}
-
-static int diva_server_config(card_t *card, dia_config_t *config)
-{
-	byte *shared;
-	int i, j;
-
-	DPRINTF(("divas: configure Diva Server PRI"));
-
-	shared = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY);
-
-	UxCardLog(0);
-	for (i=0; i<256; i++)
-	{
-		UxCardMemOut(card->hw, &shared[i], 0);
-	}
-
-	UxCardMemOut(card->hw, &shared[ 8], config->tei);
-	UxCardMemOut(card->hw, &shared[ 9], config->nt2);
-	UxCardMemOut(card->hw, &shared[10], config->sig_flags);
-	UxCardMemOut(card->hw, &shared[11], config->watchdog);
-	UxCardMemOut(card->hw, &shared[12], config->permanent);
-	UxCardMemOut(card->hw, &shared[13], config->x_interface);
-	UxCardMemOut(card->hw, &shared[14], config->stable_l2);
-	UxCardMemOut(card->hw, &shared[15], config->no_order_check);
-	UxCardMemOut(card->hw, &shared[16], config->handset_type);
-	UxCardMemOut(card->hw, &shared[17], 0);
-	UxCardMemOut(card->hw, &shared[18], config->low_channel);
-	UxCardMemOut(card->hw, &shared[19], config->prot_version);
-	UxCardMemOut(card->hw, &shared[20], config->crc4);
-
-	for (i=0; i<2; i++)
-	{
-		for (j=0; j<32; j++)
-		{
-			UxCardMemOut(card->hw, &shared[32+(i*96)+j],config->terminal[i].oad[j]);
-		}
-
-		for (j=0; j<32; j++)
-		{
-			UxCardMemOut(card->hw, &shared[64+(i*96)+j],config->terminal[i].osa[j]);
-		}
-
-		for (j=0; j<32; j++)
-		{
-			UxCardMemOut(card->hw, &shared[96+(i*96)+j],config->terminal[i].spid[j]);
-		}
-	}
-
-	UxCardMemDetach(card->hw, shared);
-
-	return 0;
-}
-
-static
-void diva_server_reset_int(card_t *card)
-{
-	byte *cfg;
-
-	cfg = UxCardMemAttach(card->hw, DIVAS_CFG_MEMORY);
-
-	UxCardMemOutW(card->hw, &cfg[DIVAS_IRQ_RESET], DIVAS_IRQ_RESET_VAL);
-	UxCardMemOutW(card->hw, &cfg[DIVAS_IRQ_RESET + 2], 0);
-	UxCardMemDetach(card->hw, cfg);
-
-	return;
-}
-
- 
-static int diva_server_test_int(card_t *card)
-{
-	int i;
-	byte *shared;
-	byte req_int;
-
-	DPRINTF(("divas: test interrupt for Diva Server PRI"));
-
-	shared = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY);
-
-	UxCardMemIn(card->hw, &shared[0x3FE]);
-	UxCardMemOut(card->hw, &shared[0x3FE], 0);
-	UxCardMemIn(card->hw, &shared[0x3FE]);
-
-	UxCardMemDetach(card->hw, shared);
-
-	diva_server_reset_int(card);
-
-	shared = UxCardMemAttach(card->hw, DIVAS_SHARED_MEMORY);
-
-	card->test_int_pend = TEST_INT_DIVAS;
-
-	req_int = UxCardMemIn(card->hw, &(((struct pr_ram *)shared)->ReadyInt));
-
-	req_int++;
-
-	UxCardMemOut(card->hw, &(((struct pr_ram *)shared)->ReadyInt), req_int);
-
-	UxCardMemDetach(card->hw, shared);
-
-	UxCardLog(0);
-	for (i = 0; i < 50; i++)
-	{
-		if (!card->test_int_pend)
-		{
-			break;
-		}
-		UxPause(10);
-	}
-
-
-	if (card->test_int_pend)
-	{
-
-		DPRINTF(("active: timeout waiting for card to interrupt"));
-		return (-1);
-	
-	}
-	
-	return 0;
-}
-
-
-static void print_hdr(unsigned char *code, int offset)
-{
-	unsigned char hdr[80];
-		int i;
-
-	i = 0;
-
-	while ((i < (DIM(hdr) -1)) && 
-		(code[offset + i] != '\0') &&
-		(code[offset + i] != '\r') &&
-		(code[offset + i] != '\n'))
-	{
-		hdr[i] = code[offset + i];
-		i++;
-	}
-
-	hdr[i] = '\0';
-
-	DPRINTF(("divas: loading %s", hdr));
-}
-
-static int diva_server_load(card_t *card, dia_load_t *load)
-{
-	diva_server_boot_t *boot;
-	int i, offset, length;
-	dword cmd = 0;
-
-	DPRINTF(("divas: loading Diva Server PRI"));
-
-	boot = UxCardMemAttach(card->hw, DIVAS_RAM_MEMORY);
-
-	switch(load->code_type)
-	{
-		case DIA_CPU_CODE:
-			DPRINTF(("divas: RISC code"));
-			print_hdr(load->code, 0x80);
-
-			UxCardMemOutD(card->hw, &boot->addr, MP_PROTOCOL_ADDR);
-			break;
-
-		case DIA_DSP_CODE:
-			DPRINTF(("divas: DSP code"));
-			print_hdr(load->code, 0x0);
-
-			UxCardMemOutD(card->hw, &boot->addr,  
-				(MP_DSP_CODE_BASE + (((sizeof(dword) +
-				(sizeof(t_dsp_download_desc) * DSP_MAX_DOWNLOAD_COUNT))
-				+ ~ALIGNMENT_MASK_MAESTRA) & ALIGNMENT_MASK_MAESTRA)));
-			break;
-
-		case DIA_TABLE_CODE:
-			DPRINTF(("divas: TABLE code"));
-			UxCardMemOutD(card->hw, &boot->addr,
-				(MP_DSP_CODE_BASE + sizeof(dword)));
-			break;
-
-		case DIA_CONT_CODE:
-			DPRINTF(("divas: continuation code"));
-			break;
-
-        case DIA_DLOAD_CNT:
-			DPRINTF(("divas: COUNT code"));
-			UxCardMemOutD(card->hw, &boot->addr, MP_DSP_CODE_BASE);
-			break;
-
-		default:
-			DPRINTF(("divas: unknown code type"));
-			UxCardMemDetach(card->hw, boot);
-			return -1;
-	}
-
-	UxCardLog(0);
-	offset = 0;
-
-	do
-	{
-		length = (load->length - offset >= 400) ? 400 : load->length - offset;
-
-		for (i=0; i<length; i++)
-		{
-			UxCardMemOut(card->hw, &boot->data[i], load->code[offset+i]);
-		}
-
-        for (i=0; i<length; i++)
-		{
-			if (load->code[offset + i] != UxCardMemIn(card->hw, &boot->data[i]))
-			{
-				UxCardMemDetach(card->hw, boot);
-
-				DPRINTF(("divas: card code block verify failed"));
-				return -1;
-			}
-		}
-	
-		UxCardMemOutD(card->hw, &boot->len, (length + 3) / 4);
-		UxCardMemOutD(card->hw, &boot->cmd, DIVAS_LOAD_CMD);
-
-		for (i=0; i<50000; i++)
-		{
-			cmd = UxCardMemInD(card->hw, &boot->cmd);
-			if (!cmd)
-			{
-				break;
-			}
-			/*UxPause(1);*/
-		}
-
-		if (cmd)
-		{
-			DPRINTF(("divas: timeout waiting for card to ACK load (offset = %d)", offset));
-			UxCardMemDetach(card->hw, boot);
-			return -1;
-		}
-
-		offset += length;
-
-	} while (offset < load->length);
-
-	UxCardMemDetach(card->hw, boot);
-
-	DPRINTF(("divas: DIVA Server card loaded"));
-
-	return 0;
-}
-
-static int diva_server_start(card_t *card, byte *channels)
-{
-	diva_server_boot_t *boot;
-	byte *ram;
-	int	i;
-	dword signature = 0;
-
-	DPRINTF(("divas: start Diva Server PRI"));
-
-	card->is_live = FALSE;
-
-	boot = UxCardMemAttach(card->hw, DIVAS_RAM_MEMORY);
-
-	UxCardMemOutD(card->hw, &boot->addr, MP_PROTOCOL_ADDR);
-	UxCardMemOutD(card->hw, &boot->cmd, DIVAS_START_CMD);
-
-	UxCardLog(0);
-
-	for (i = 0; i < 300; i++)
-	{
-		signature = UxCardMemInD(card->hw, &boot->signature);
-		if ((signature >> 16) == DIVAS_SIGNATURE)
-		{
-			DPRINTF(("divas: started card after %d ms", i * 10));
-			break;
-		}
-		UxPause(10);
-	}
-
-	if ((signature >> 16) != DIVAS_SIGNATURE)
-	{
-		UxCardMemDetach(card->hw, boot);
-		DPRINTF(("divas: timeout waiting for card to run protocol code (sig = 0x%x)", signature));
-		return -1;
-	}
-
-	card->is_live = TRUE;
-
-	ram = (byte *) boot;
-	ram += DIVAS_SHARED_OFFSET;
-
-	*channels = UxCardMemIn(card->hw, &ram[0x3F6]);
-	card->serial_no = UxCardMemInD(card->hw, &ram[0x3F0]);
-
-	UxCardMemDetach(card->hw, boot);
-
-	if (diva_server_test_int(card))
-	{
-		DPRINTF(("divas: interrupt test failed"));
-		return -1;	
-	}
-
-	DPRINTF(("divas: DIVA Server card started"));
-
-	return 0;
-}
-
-static
-int 	diva_server_mem_get(card_t *card, mem_block_t *mem_block)
-
-{
-	byte	*a;
-	byte	*card_addr;
-	word	length = 0;
-	int		i;
-
-	a = UxCardMemAttach(card->hw, DIVAS_RAM_MEMORY);
-
-	card_addr = a;
-	card_addr += mem_block->addr;
-
-	for (i=0; i < sizeof(mem_block->data); i++)
-	{
-		mem_block->data[i] = UxCardMemIn(card->hw, card_addr);
-		card_addr++;
-		length++;
-	}
-
-	UxCardMemDetach(card->hw, a);
-
-	return length;
-}
-
-/*
- * Initialise PRI specific entry points
- */
-
-int DivasPriInit(card_t *card, dia_card_t *cfg)
-{
-	DPRINTF(("divas: initialise Diva Server PRI"));
-
-	if (DivasPRIInitPCI(card, cfg) == -1)
-	{
-		return -1;
-	}
-
-	card->card_reset = diva_server_reset;
-	card->card_load = diva_server_load;
-	card->card_config = diva_server_config;
-	card->card_start = diva_server_start;
-	card->reset_int = diva_server_reset_int;
-	card->card_mem_get = diva_server_mem_get;
-
-	card->xlog_offset = DIVAS_MAINT_OFFSET;
-
-	card->out = DivasOut;
-	card->test_int = DivasTestInt;
-	card->dpc = DivasDpc;
-	card->clear_int = DivasClearInt;
-	card->card_isr  = pri_ISR;
-
-	card->a.ram_out = mem_out;
-	card->a.ram_outw = mem_outw;
-	card->a.ram_out_buffer = mem_out_buffer;
-	card->a.ram_inc = mem_inc;
-
-	card->a.ram_in = mem_in;
-	card->a.ram_inw = mem_inw;
-	card->a.ram_in_buffer = mem_in_buffer;
-	card->a.ram_look_ahead = mem_look_ahead;
-
-	return 0;
-}
-
-
-static int pri_ISR (card_t* card) 
-{
-	int served = 0;
-	byte* cfg = UxCardMemAttach(card->hw, DIVAS_CFG_MEMORY);
-	volatile unsigned long* isr = (unsigned long*)&cfg[DIVAS_IRQ_RESET];
-	register unsigned long val = *isr;
-	
-	if (val & 0x80000000)  /* our card had caused interrupt ??? */
-	{
-		served = 1;
-		card->int_pend  += 1;
-		DivasDpcSchedule(); /* ISR DPC */
-
-		*isr = (unsigned long)~0x03E00000; /* Clear interrupt line */
-	}
-
-	UxCardMemDetach(card->hw, cfg);
-
-	return (served != 0);
-}
-
-
diff -puN -L drivers/isdn/eicon/pr_pc.h drivers/isdn/eicon/pr_pc.h~linus /dev/null
--- 25/drivers/isdn/eicon/pr_pc.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.0  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-
-#if !defined(PR_PC_H)
-#define PR_PC_H
-
-struct pr_ram {
-  word NextReq;         /* pointer to next Req Buffer               */
-  word NextRc;          /* pointer to next Rc Buffer                */
-  word NextInd;         /* pointer to next Ind Buffer               */
-  byte ReqInput;        /* number of Req Buffers sent               */
-  byte ReqOutput;       /* number of Req Buffers returned           */
-  byte ReqReserved;     /* number of Req Buffers reserved           */
-  byte Int;             /* ISDN-P interrupt                         */
-  byte XLock;           /* Lock field for arbitration               */
-  byte RcOutput;        /* number of Rc buffers received            */
-  byte IndOutput;       /* number of Ind buffers received           */
-  byte IMask;           /* Interrupt Mask Flag                      */
-  byte Reserved1[2];    /* reserved field, do not use               */
-  byte ReadyInt;        /* request field for ready interrupt        */
-  byte Reserved2[12];   /* reserved field, do not use               */
-  byte InterfaceType;   /* interface type 1=16K interface           */
-  word Signature;       /* ISDN-P initialized indication            */
-  byte B[1];            /* buffer space for Req,Ind and Rc          */
-};
-
-typedef struct {
-  word next;
-  byte Req;
-  byte ReqId;
-  byte ReqCh;
-  byte Reserved1;
-  word Reference;
-  byte Reserved[8];
-  PBUFFER XBuffer;
-} REQ;
-
-typedef struct {
-  word next;
-  byte Rc;
-  byte RcId;
-  byte RcCh;
-  byte Reserved1;
-  word Reference;
-  byte Reserved2[8];
-} RC;
-
-typedef struct {
-  word next;
-  byte Ind;
-  byte IndId;
-  byte IndCh;
-  byte MInd;
-  word MLength;
-  word Reference;
-  byte RNR;
-  byte Reserved;
-  dword Ack;
-  PBUFFER RBuffer;
-} IND;
-
-#endif
diff -puN -L drivers/isdn/eicon/sys.h drivers/isdn/eicon/sys.h~linus /dev/null
--- 25/drivers/isdn/eicon/sys.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,95 +0,0 @@
-/*
- * Environment provided by system and miscellaneous definitions
- *
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.2  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#if !defined(SYS_H)
-#define SYS_H
-
-/* abreviations for unsigned types */
-typedef int boolean_t;
-
-typedef unsigned char byte;
-
-typedef unsigned long dword;
-typedef unsigned short word;
-
-/* abreviations for volatile types */
-
-typedef volatile byte	vbyte;
-typedef volatile word	vword;
-typedef volatile dword	vdword;
-
-/* Booleans */
-
-#if !defined(TRUE)
-#define TRUE    (1)
-#define FALSE   (0)
-#endif
-
-/* NULL pointer */
-
-#if !defined(NULL)
-#define NULL    ((void *) 0)
-#endif
-
-/* Return the dimension of an array */
-
-#if !defined(DIM)
-#define DIM(array)  (sizeof (array)/sizeof ((array)[0]))
-#endif
-
-/*
- * Return the number of milliseconds since last boot
- */
-
-extern	dword	UxTimeGet(void);
-
-extern	void 	DivasSprintf(char *buffer, char *format, ...);
-extern	void 	DivasPrintf(char *format, ...);
-
-/* fatal errors, asserts and tracing */
-
-void HwFatalErrorFrom(char *file, int line);
-void HwFatalError(void);
-/* void HwAssert(char *file, int line, char *condition); */
-
-#include <linux/kernel.h>
-#include <linux/string.h>
-
-#define _PRINTK printk
-
-#define _PRINTF	DivasPrintf
-void _PRINTF(char *format, ...);
-#define PRINTF(arg_list)	_PRINTF arg_list
-#if defined DTRACE
-# define DPRINTF(arg_list)	_PRINTF arg_list
-# define KDPRINTF(arg_list)	_PRINTF arg_list ; _PRINTK arg_list ; _PRINTK("\n");
-#else
-# define DPRINTF(arg_list)	(void)0
-# define KDPRINTF(arg_list)	_PRINTK arg_list ; _PRINTK("\n");
-#endif
-
-#if !defined(ASSERT)
-#if defined DEBUG || defined DBG
-# define HwFatalError()	HwFatalErrorFrom(__FILE__, __LINE__)
-# define ASSERT(cond)								\
-		if (!(cond)) 								\
-		{											\
-/*			HwAssert(__FILE__, __LINE__, #cond);*/	\
-		}
-#else
-# define ASSERT(cond)	((void)0)
-#endif
-#endif /* !defined(ASSERT) */
-
-#define TRACE	(_PRINTF(__FILE__"@%d\n", __LINE__))
-
-#endif /* SYS_H */
diff -puN -L drivers/isdn/eicon/uxio.h drivers/isdn/eicon/uxio.h~linus /dev/null
--- 25/drivers/isdn/eicon/uxio.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,196 +0,0 @@
-/*
- * Interface to Unix specific code for performing card I/O
- *
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.6  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#if !defined(UXIO_H)
-#define UXIO_H
-
-#include "sys.h"
-#include "adapter.h"
-
-
-struct pt_regs;
-
-/* user callback, returns zero if interrupt was from this card */
-typedef	void		isr_fn_t(void *);
-struct ux_diva_card_s
-{
-	word	in_use;
-	int		io_base;
-	int		reset_base;
-	int		card_type;
-	byte		*mapped;
-	struct pci_dev  *pdev;
-	int		slot;
-	int		irq;
-	byte		*pDRAM;
-	byte		*pDEVICES;
-	byte		*pCONFIG;
-	byte		*pSHARED;
-	byte		*pCONTROL;
-	word		features;
-	void		*user_isr_arg;
-	isr_fn_t	*user_isr;
-};
-
-/*
- * Get a card handle to enable card to be accessed
- */
-
-int		UxCardHandleGet(	ux_diva_card_t	**card,
-							dia_card_t		*cfg);
-
-/*
- * Free a card handle as no longer needed
- */
-
-void	UxCardHandleFree(ux_diva_card_t *card);
-
-/*
- * Lock and unlock access to a card
- */
-
-long		UxCardLock(ux_diva_card_t *card);
-void	UxCardUnlock(ux_diva_card_t *card, unsigned long ipl);
-
-/*
- * Set the mapping address for PCI cards
- */
-
-int		UxCardAddrMappingSet(ux_diva_card_t	*card,
-							int				id,
-							void			*address,
-							int				size);
-
-/*
- * Attach card to memory to enable it to be accessed
- * Returns the mapped address
- */
-
-void	*UxCardMemAttach(ux_diva_card_t *card, int id);
-
-/*
- * map card out of memory after completion of access
- */
-
-void	UxCardMemDetach(ux_diva_card_t *card, void *address);
-
-/*
- * input functions for memory-mapped cards
- */
-
-byte	UxCardMemIn(ux_diva_card_t *card, void *address);
-
-word	UxCardMemInW(ux_diva_card_t *card, void *address);
-
-dword	UxCardMemInD(ux_diva_card_t *card, void *address);
-
-void	UxCardMemInBuffer(	ux_diva_card_t *card,
-							void			*address,
-							void			*buffer,
-							int				length);
-
-/*
- * output functions for memory-mapped cards
- */
-
-void UxCardMemOut(ux_diva_card_t *card, void *address, byte data);
-
-void UxCardMemOutW(ux_diva_card_t *card, void *address, word data);
-
-void UxCardMemOutD(ux_diva_card_t *card, void *address, dword data);
-
-void UxCardMemOutBuffer(	ux_diva_card_t	*card,
-							void			*address,
-							void			*buffer,
-							int				length);
-
-/*
- * input functions for I/O-mapped cards
- */
-
-byte	UxCardIoIn(ux_diva_card_t *card, void *, void *address);
-
-word	UxCardIoInW(ux_diva_card_t *card, void *, void *address);
-
-dword	UxCardIoInD(ux_diva_card_t *card, void *, void *address);
-
-void	UxCardIoInBuffer(	ux_diva_card_t *card,
-							void *, void			*address,
-							void			*buffer,
-							int				length);
-
-/*
- * output functions for I/O-mapped cards
- */
-
-void UxCardIoOut(ux_diva_card_t *card, void *, void *address, byte data);
-
-void UxCardIoOutW(ux_diva_card_t *card, void *, void *address, word data);
-
-void UxCardIoOutD(ux_diva_card_t *card, void *, void *address, dword data);
-
-void UxCardIoOutBuffer(	ux_diva_card_t	*card,
-							void *, void			*address,
-							void			*buffer,
-							int				length);
-
-/*
- * Get specified PCI config
- */
-
-void	UxPciConfigRead(ux_diva_card_t	*card, 
-						int				size,
-						int				offset,
-						void			*value);
-
-/*
- * Set specified PCI config
- */
-
-void	UxPciConfigWrite(ux_diva_card_t	*card, 
-						int				size,
-						int				offset,
-						void			*value);
-
-/* allocate memory, returning NULL if none available */
-
-void	*UxAlloc(unsigned int size);
-
-void	UxFree(void *);
-
-/*
- * Pause for specified number of milli-seconds 
- */
-
-void	UxPause(long ms);
-
-/*
- * Install an ISR for the specified card
- */
-
-int		UxIsrInstall(ux_diva_card_t *card, isr_fn_t *isr_fn, void *isr_arg);
-
-/*
- * Remove an ISR for the specified card
- */
-void	UxIsrRemove(ux_diva_card_t *card, void *);
-
-/*
- * DEBUG function to turn logging ON or OFF
- */
-
-void	UxCardLog(int turn_on);
-
-long	UxInterlockedIncrement(ux_diva_card_t *card, long *dst);
-long	UxInterlockedDecrement(ux_diva_card_t *card, long *dst);
-
-#endif /* of UXIO_H */
diff -puN -L drivers/isdn/eicon/xlog.c drivers/isdn/eicon/xlog.c~linus /dev/null
--- 25/drivers/isdn/eicon/xlog.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,164 +0,0 @@
-/*
- * Unix Eicon active card driver
- * XLOG related functions
- *
- * Copyright (C) Eicon Technology Corporation, 2000.
- *
- * Eicon File Revision :    1.2  
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#include "sys.h"
-#include "idi.h"
-#include "pc.h"
-#include "pc_maint.h"
-#include "divalog.h"
-
-#include "adapter.h"
-#include "uxio.h"
-
-/*
- * convert/copy XLOG info into a KLOG entry
- */
-
-static
-void	xlog_to_klog(byte *b, int size, int card_num)
-
-{
-	typedef struct
-	{
-		word	code;
-		word	time_hi;
-		word	time_lo;
-		word	xcode;
-		byte	data[2];
-	} card_xlog_t;
-
-	card_xlog_t	*x;
-
-	klog_t		klog;
-
-	x = (card_xlog_t *) b;
-
-	memset(&klog, 0, sizeof(klog));
-
-	klog.time_stamp = (dword) x->time_hi;
-	klog.time_stamp = (klog.time_stamp << 16) | (dword) x->time_lo;
-
-	klog.length = size > sizeof(klog.buffer) ? sizeof(klog.buffer) : size;
-
-	klog.card = card_num;
-	if (x->code == 1)
-	{
-		klog.type = KLOG_XTXT_MSG;
-		klog.code = 0;
-		memcpy(klog.buffer, &x->xcode, klog.length);
-	}
-	else if (x->code == 2)
-	{
-		klog.type = KLOG_XLOG_MSG;
-		klog.code = x->xcode;
-		memcpy(klog.buffer, &x->data, klog.length);
-	}
-	else
-	{
-		char	*c; int i;
-		klog.type = KLOG_TEXT_MSG;
-		klog.code = 0;
-		c = "divas: invalid xlog message code from card";
-		i = 0;
-		while (*c)
-		{
-			klog.buffer[i] = *c;
-			c++;
-			i++;
-		}
-		klog.buffer[i] = *c;
-	}
-
-    /* send to the log driver and return */
-
-    DivasLogAdd(&klog, sizeof(klog));
-
-	return;
-}
-
-/*
- * send an XLOG request down to specified card
- * if response available from previous request then read it
- * if not then just send down new request, ready for next time
- */
-
-void	DivasXlogReq(int card_num)
-
-{
-	card_t				*card;
-	ADAPTER 			*a;
-
-	if ((card_num < 0) || (card_num > DivasCardNext))
-	{
-		DPRINTF(("xlog: invalid card number"));
-		return;
-	}
-
-	card = &DivasCards[card_num];
-
-	if (DivasXlogRetrieve(card))
-	{
-		return;
-	}
-
-	/* send down request for next time */
-
-	a = &card->a;
-
-	a->ram_out(a, (word *) (card->xlog_offset + 1), 0);
-	a->ram_out(a, (word *) (dword) (card->xlog_offset), DO_LOG);
-
-	return;
-}
-
-/*
- * retrieve XLOG request from specified card
- * returns non-zero if new request sent to card
- */
-
-int		DivasXlogRetrieve(card_t *card)
-
-{
-	ADAPTER 			*a;
-	struct mi_pc_maint	pcm;
-
-	a = &card->a;
-
-	/* get status of last request */
-
-	pcm.rc = a->ram_in(a, (word *)(card->xlog_offset + 1));
-
-	/* if nothing there from previous request, send down a new one */
-
-	if (pcm.rc == OK)
-	{
-		/* read in response */
-
-		a->ram_in_buffer(a, (word *) (dword) card->xlog_offset, &pcm, sizeof(pcm)); 
-
-		xlog_to_klog((byte *) &pcm.data, sizeof(pcm.data), 
-						(int) (card - DivasCards));
-	}
-
-	/* if any response received from card, re-send request */
-
-	if (pcm.rc)
-	{
-		a->ram_out(a, (word *) (card->xlog_offset + 1), 0);
-		a->ram_out(a, (word *) (dword) (card->xlog_offset), DO_LOG);
-
-		return 1;
-	} 
-
-	return 0;
-}
diff -puN drivers/isdn/hardware/avm/avm_cs.c~linus drivers/isdn/hardware/avm/avm_cs.c
--- 25/drivers/isdn/hardware/avm/avm_cs.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/isdn/hardware/avm/avm_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -186,7 +186,7 @@ static dev_link_t *avmcs_attach(void)
     client_reg.event_handler = &avmcs_event;
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
-    ret = CardServices(RegisterClient, &link->handle, &client_reg);
+    ret = pcmcia_register_client(&link->handle, &client_reg);
     if (ret != 0) {
 	cs_error(link->handle, RegisterClient, ret);
 	avmcs_detach(link);
@@ -232,7 +232,7 @@ static void avmcs_detach(dev_link_t *lin
 
     /* Break the link with Card Services */
     if (link->handle)
-	CardServices(DeregisterClient, link->handle);
+	pcmcia_deregister_client(link->handle);
     
     /* Unlink device structure, free pieces */
     *linkp = link->next;
@@ -251,19 +251,29 @@ static void avmcs_detach(dev_link_t *lin
     
 ======================================================================*/
 
-static int get_tuple(int fn, client_handle_t handle, tuple_t *tuple,
+static int get_tuple(client_handle_t handle, tuple_t *tuple,
 		     cisparse_t *parse)
 {
-    int i;
-    i = CardServices(fn, handle, tuple);
+    int i = pcmcia_get_tuple_data(handle, tuple);
     if (i != CS_SUCCESS) return i;
-    i = CardServices(GetTupleData, handle, tuple);
+    return pcmcia_parse_tuple(handle, tuple, parse);
+}
+
+static int first_tuple(client_handle_t handle, tuple_t *tuple,
+		     cisparse_t *parse)
+{
+    int i = pcmcia_get_first_tuple(handle, tuple);
     if (i != CS_SUCCESS) return i;
-    return CardServices(ParseTuple, handle, tuple, parse);
+    return get_tuple(handle, tuple, parse);
 }
 
-#define first_tuple(a, b, c) get_tuple(GetFirstTuple, a, b, c)
-#define next_tuple(a, b, c) get_tuple(GetNextTuple, a, b, c)
+static int next_tuple(client_handle_t handle, tuple_t *tuple,
+		     cisparse_t *parse)
+{
+    int i = pcmcia_get_next_tuple(handle, tuple);
+    if (i != CS_SUCCESS) return i;
+    return get_tuple(handle, tuple, parse);
+}
 
 static void avmcs_config(dev_link_t *link)
 {
@@ -287,14 +297,14 @@ static void avmcs_config(dev_link_t *lin
     */
     do {
 	tuple.DesiredTuple = CISTPL_CONFIG;
-	i = CardServices(GetFirstTuple, handle, &tuple);
+	i = pcmcia_get_first_tuple(handle, &tuple);
 	if (i != CS_SUCCESS) break;
 	tuple.TupleData = buf;
 	tuple.TupleDataMax = 64;
 	tuple.TupleOffset = 0;
-	i = CardServices(GetTupleData, handle, &tuple);
+	i = pcmcia_get_tuple_data(handle, &tuple);
 	if (i != CS_SUCCESS) break;
-	i = CardServices(ParseTuple, handle, &tuple, &parse);
+	i = pcmcia_parse_tuple(handle, &tuple, &parse);
 	if (i != CS_SUCCESS) break;
 	link->conf.ConfigBase = parse.config.base;
     } while (0);
@@ -337,7 +347,7 @@ static void avmcs_config(dev_link_t *lin
                 printk(KERN_INFO "avm_cs: testing i/o %#x-%#x\n",
 			link->io.BasePort1,
 		        link->io.BasePort1+link->io.NumPorts1-1);
-		i = CardServices(RequestIO, link->handle, &link->io);
+		i = pcmcia_request_io(link->handle, &link->io);
 		if (i == CS_SUCCESS) goto found_port;
 	    }
 	    i = next_tuple(handle, &tuple, &parse);
@@ -352,21 +362,21 @@ found_port:
 	/*
 	 * allocate an interrupt line
 	 */
-	i = CardServices(RequestIRQ, link->handle, &link->irq);
+	i = pcmcia_request_irq(link->handle, &link->irq);
 	if (i != CS_SUCCESS) {
 	    cs_error(link->handle, RequestIRQ, i);
-	    CardServices(ReleaseIO, link->handle, &link->io);
+	    pcmcia_release_io(link->handle, &link->io);
 	    break;
 	}
 	
 	/*
          * configure the PCMCIA socket
 	  */
-	i = CardServices(RequestConfiguration, link->handle, &link->conf);
+	i = pcmcia_request_configuration(link->handle, &link->conf);
 	if (i != CS_SUCCESS) {
 	    cs_error(link->handle, RequestConfiguration, i);
-	    CardServices(ReleaseIO, link->handle, &link->io);
-	    CardServices(ReleaseIRQ, link->handle, &link->irq);
+	    pcmcia_release_io(link->handle, &link->io);
+	    pcmcia_release_irq(link->handle, &link->irq);
 	    break;
 	}
 
@@ -437,9 +447,9 @@ static void avmcs_release(dev_link_t *li
     link->dev = NULL;
     
     /* Don't bother checking to see if these succeed or not */
-    CardServices(ReleaseConfiguration, link->handle);
-    CardServices(ReleaseIO, link->handle, &link->io);
-    CardServices(ReleaseIRQ, link->handle, &link->irq);
+    pcmcia_release_configuration(link->handle);
+    pcmcia_release_io(link->handle, &link->io);
+    pcmcia_release_irq(link->handle, &link->irq);
     link->state &= ~DEV_CONFIG;
     
     if (link->state & DEV_STALE_LINK)
@@ -481,14 +491,14 @@ static int avmcs_event(event_t event, in
 	/* Fall through... */
     case CS_EVENT_RESET_PHYSICAL:
 	if (link->state & DEV_CONFIG)
-	    CardServices(ReleaseConfiguration, link->handle);
+	    pcmcia_release_configuration(link->handle);
 	break;
     case CS_EVENT_PM_RESUME:
 	link->state &= ~DEV_SUSPEND;
 	/* Fall through... */
     case CS_EVENT_CARD_RESET:
 	if (link->state & DEV_CONFIG)
-	    CardServices(RequestConfiguration, link->handle, &link->conf);
+	    pcmcia_request_configuration(link->handle, &link->conf);
 	break;
     }
     return 0;
diff -puN drivers/isdn/hardware/eicon/capifunc.c~linus drivers/isdn/hardware/eicon/capifunc.c
--- 25/drivers/isdn/hardware/eicon/capifunc.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/isdn/hardware/eicon/capifunc.c	2004-01-19 22:17:22.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: capifunc.c,v 1.47 2003/09/09 06:52:29 schindler Exp $
+/* $Id: capifunc.c,v 1.48 2004/01/11 19:20:54 armin Exp $
  *
  * ISDN interface module for Eicon active cards DIVA.
  * CAPI Interface common functions
@@ -776,7 +776,7 @@ static void diva_register_appl(struct ca
 	}
 
 	if (application[appl - 1].Id == appl) {
-		DBG_ERR(("CAPI_REGISTER - appl already registered"))
+		DBG_LOG(("CAPI_REGISTER - appl already registered"))
 		return;	/* appl already registered */
 	}
 
diff -puN drivers/isdn/hardware/eicon/divamnt.c~linus drivers/isdn/hardware/eicon/divamnt.c
--- 25/drivers/isdn/hardware/eicon/divamnt.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/isdn/hardware/eicon/divamnt.c	2004-01-19 22:17:22.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: divamnt.c,v 1.28 2003/09/18 06:57:18 schindler Exp $
+/* $Id: divamnt.c,v 1.32 2004/01/15 09:48:13 armin Exp $
  *
  * Driver for Eicon DIVA Server ISDN cards.
  * Maint module
@@ -26,7 +26,7 @@
 #include "divasync.h"
 #include "debug_if.h"
 
-static char *main_revision = "$Revision: 1.28 $";
+static char *main_revision = "$Revision: 1.32 $";
 
 static int major;
 
@@ -53,7 +53,7 @@ static struct timeval start_time;
 
 extern int mntfunc_init(int *, void **, unsigned long);
 extern void mntfunc_finit(void);
-extern int maint_read_write(void *buf);
+extern int maint_read_write(void *buf, int count);
 
 /*
  *  helper functions
@@ -363,13 +363,13 @@ static void remove_maint_proc(void)
 static ssize_t divas_maint_write(struct file *file, const char *buf,
 				 size_t count, loff_t * ppos)
 {
-	return (maint_read_write((char *) buf));
+	return (maint_read_write((char *) buf, (int) count));
 }
 
 static ssize_t divas_maint_read(struct file *file, char *buf,
 				size_t count, loff_t * ppos)
 {
-	return (maint_read_write(buf));
+	return (maint_read_write(buf, (int) count));
 }
 
 static struct file_operations divas_maint_fops = {
diff -puN drivers/isdn/hardware/eicon/mntfunc.c~linus drivers/isdn/hardware/eicon/mntfunc.c
--- 25/drivers/isdn/hardware/eicon/mntfunc.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/isdn/hardware/eicon/mntfunc.c	2004-01-19 22:17:22.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: mntfunc.c,v 1.16 2003/09/18 06:57:17 schindler Exp $
+/* $Id: mntfunc.c,v 1.19 2004/01/09 21:22:03 armin Exp $
  *
  * Driver for Eicon DIVA Server ISDN cards.
  * Maint module
@@ -148,12 +148,15 @@ static void DIVA_EXIT_FUNCTION disconnec
 /*
  * read/write maint
  */
-int maint_read_write(void *buf)
+int maint_read_write(void *buf, int count)
 {
 	byte data[128];
 	dword cmd, id, mask;
 	int ret = 0;
 
+	if (count < (3 * sizeof(dword)))
+		return (-EFAULT);
+
 	if (diva_os_copy_from_user(NULL, (void *) &data[0],
 				   buf, 3 * sizeof(dword))) {
 		return (-EFAULT);
@@ -166,7 +169,7 @@ int maint_read_write(void *buf)
 	switch (cmd) {
 	case DITRACE_CMD_GET_DRIVER_INFO:
 		if ((ret = diva_get_driver_info(id, data, sizeof(data))) > 0) {
-			if (diva_os_copy_to_user
+			if ((count < ret) || diva_os_copy_to_user
 			    (NULL, buf, (void *) &data[0], ret))
 				ret = -EFAULT;
 		} else {
@@ -176,7 +179,7 @@ int maint_read_write(void *buf)
 
 	case DITRACE_READ_DRIVER_DBG_MASK:
 		if ((ret = diva_get_driver_dbg_mask(id, (byte *) data)) > 0) {
-			if (diva_os_copy_to_user
+			if ((count < ret) || diva_os_copy_to_user
 			    (NULL, buf, (void *) &data[0], ret))
 				ret = -EFAULT;
 		} else {
@@ -209,7 +212,7 @@ int maint_read_write(void *buf)
 						ret = size;
 						memcpy(pbuf, pmsg, size);
 						diva_maint_ack_message(1, &old_irql);
-						if (diva_os_copy_to_user (NULL, buf,
+						if ((count < size) || diva_os_copy_to_user (NULL, buf,
 						     (void *) pbuf, size))
 							ret = -EFAULT;
 						diva_os_free_tbuffer(0, pbuf);
@@ -265,7 +268,7 @@ int maint_read_write(void *buf)
 			pbuf[written++] = 0;
 			pbuf[written++] = 0;
 
-			if (diva_os_copy_to_user(NULL, buf, (void *) pbuf, written)) {
+			if ((count < written) || diva_os_copy_to_user(NULL, buf, (void *) pbuf, written)) {
 				ret = -EFAULT;
 			} else {
 				ret = written;
diff -puN drivers/isdn/hardware/eicon/platform.h~linus drivers/isdn/hardware/eicon/platform.h
--- 25/drivers/isdn/hardware/eicon/platform.h~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/isdn/hardware/eicon/platform.h	2004-01-19 22:17:22.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: platform.h,v 1.32 2003/09/18 06:59:59 schindler Exp $
+/* $Id: platform.h,v 1.35 2003/12/05 18:45:05 armin Exp $
  *
  * platform.h
  * 
@@ -117,6 +117,8 @@
 #define MEM_TYPE_CONFIG		7
 #define MEM_TYPE_CONTROL	8
 
+#define MAX_MEM_TYPE		10
+
 #define DIVA_OS_MEM_ATTACH_RAM(a)	((a)->ram)
 #define DIVA_OS_MEM_ATTACH_PORT(a)	((a)->port)
 #define DIVA_OS_MEM_ATTACH_PROM(a)	((a)->prom)
diff -puN drivers/isdn/hardware/eicon/s_bri.c~linus drivers/isdn/hardware/eicon/s_bri.c
--- 25/drivers/isdn/hardware/eicon/s_bri.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/isdn/hardware/eicon/s_bri.c	2004-01-19 22:17:22.000000000 -0800
@@ -61,7 +61,7 @@ static void bri_cpu_trapped (PISDN_ADAPT
 /*
  * check for trapped MIPS 3xxx CPU, dump only exception frame
  */
- if ( READ_WORD(&Xlog[0x80 / sizeof(Xlog[0])]) == 0x99999999 )
+ if ( READ_DWORD(&Xlog[0x80 / sizeof(Xlog[0])]) == 0x99999999 )
  {
   dump_trap_frame (IoAdapter, &((byte *)Xlog)[0x90]) ;
   IoAdapter->trapped = 1 ;
diff -puN drivers/isdn/hardware/eicon/um_idi.c~linus drivers/isdn/hardware/eicon/um_idi.c
--- 25/drivers/isdn/hardware/eicon/um_idi.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/isdn/hardware/eicon/um_idi.c	2004-01-19 22:17:22.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: um_idi.c,v 1.9 2003/09/09 06:00:47 schindler Exp $ */
+/* $Id: um_idi.c,v 1.12 2004/01/12 18:00:09 armin Exp $ */
 
 #include "platform.h"
 #include "di_defs.h"
@@ -252,7 +252,7 @@ void *divas_um_idi_create_entity(dword a
 			diva_os_free(0, e);
 			return (0);
 		}
-		if ((diva_data_q_init(&e->rc, 64, 2))) {
+		if ((diva_data_q_init(&e->rc, sizeof(diva_um_idi_ind_hdr_t), 2))) {
 			diva_data_q_finit(&e->data);
 			diva_os_free(0, e->os_context);
 			diva_os_free(0, e);
diff -puN drivers/isdn/hardware/eicon/xdi_adapter.h~linus drivers/isdn/hardware/eicon/xdi_adapter.h
--- 25/drivers/isdn/hardware/eicon/xdi_adapter.h~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/isdn/hardware/eicon/xdi_adapter.h	2004-01-19 22:17:22.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: xdi_adapter.h,v 1.5 2003/06/21 17:06:08 schindler Exp $ */
+/* $Id: xdi_adapter.h,v 1.6 2003/12/05 18:45:05 armin Exp $ */
 
 #ifndef __DIVA_OS_XDI_ADAPTER_H__
 #define __DIVA_OS_XDI_ADAPTER_H__
@@ -14,7 +14,7 @@ typedef struct _divas_pci_card_resources
 	dword bar[8];		/* contains context of appropriate BAR Register */
 	void *addr[8];		/* same bar, but mapped into memory */
 	dword length[8];	/* bar length */
-	int mem_type_id[10];
+	int mem_type_id[MAX_MEM_TYPE];
 	unsigned int qoffset;
 	byte irq;
 } divas_pci_card_resources_t;
diff -puN drivers/isdn/hardware/Kconfig~linus drivers/isdn/hardware/Kconfig
--- 25/drivers/isdn/hardware/Kconfig~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/isdn/hardware/Kconfig	2004-01-19 22:17:22.000000000 -0800
@@ -25,8 +25,6 @@ source "drivers/isdn/sc/Kconfig"
 
 source "drivers/isdn/act2000/Kconfig"
 
-source "drivers/isdn/eicon/Kconfig"
-
 source "drivers/isdn/tpam/Kconfig"
 
 source "drivers/isdn/hysdn/Kconfig"
diff -puN drivers/isdn/hisax/avma1_cs.c~linus drivers/isdn/hisax/avma1_cs.c
--- 25/drivers/isdn/hisax/avma1_cs.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/isdn/hisax/avma1_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -204,7 +204,7 @@ static dev_link_t *avma1cs_attach(void)
     client_reg.event_handler = &avma1cs_event;
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
-    ret = CardServices(RegisterClient, &link->handle, &client_reg);
+    ret = pcmcia_register_client(&link->handle, &client_reg);
     if (ret != 0) {
 	cs_error(link->handle, RegisterClient, ret);
 	avma1cs_detach(link);
@@ -252,7 +252,7 @@ static void avma1cs_detach(dev_link_t *l
 
     /* Break the link with Card Services */
     if (link->handle)
-	CardServices(DeregisterClient, link->handle);
+	pcmcia_deregister_client(link->handle);
     
     /* Unlink device structure, free pieces */
     *linkp = link->next;
@@ -271,19 +271,29 @@ static void avma1cs_detach(dev_link_t *l
     
 ======================================================================*/
 
-static int get_tuple(int fn, client_handle_t handle, tuple_t *tuple,
+static int get_tuple(client_handle_t handle, tuple_t *tuple,
 		     cisparse_t *parse)
 {
-    int i;
-    i = CardServices(fn, handle, tuple);
+    int i = pcmcia_get_tuple_data(handle, tuple);
     if (i != CS_SUCCESS) return i;
-    i = CardServices(GetTupleData, handle, tuple);
+    return pcmcia_parse_tuple(handle, tuple, parse);
+}
+
+static int first_tuple(client_handle_t handle, tuple_t *tuple,
+		     cisparse_t *parse)
+{
+    int i = pcmcia_get_first_tuple(handle, tuple);
     if (i != CS_SUCCESS) return i;
-    return CardServices(ParseTuple, handle, tuple, parse);
+    return get_tuple(handle, tuple, parse);
 }
 
-#define first_tuple(a, b, c) get_tuple(GetFirstTuple, a, b, c)
-#define next_tuple(a, b, c) get_tuple(GetNextTuple, a, b, c)
+static int next_tuple(client_handle_t handle, tuple_t *tuple,
+		     cisparse_t *parse)
+{
+    int i = pcmcia_get_next_tuple(handle, tuple);
+    if (i != CS_SUCCESS) return i;
+    return get_tuple(handle, tuple, parse);
+}
 
 static void avma1cs_config(dev_link_t *link)
 {
@@ -308,14 +318,14 @@ static void avma1cs_config(dev_link_t *l
     */
     do {
 	tuple.DesiredTuple = CISTPL_CONFIG;
-	i = CardServices(GetFirstTuple, handle, &tuple);
+	i = pcmcia_get_first_tuple(handle, &tuple);
 	if (i != CS_SUCCESS) break;
 	tuple.TupleData = buf;
 	tuple.TupleDataMax = 64;
 	tuple.TupleOffset = 0;
-	i = CardServices(GetTupleData, handle, &tuple);
+	i = pcmcia_get_tuple_data(handle, &tuple);
 	if (i != CS_SUCCESS) break;
-	i = CardServices(ParseTuple, handle, &tuple, &parse);
+	i = pcmcia_parse_tuple(handle, &tuple, &parse);
 	if (i != CS_SUCCESS) break;
 	link->conf.ConfigBase = parse.config.base;
     } while (0);
@@ -358,7 +368,7 @@ static void avma1cs_config(dev_link_t *l
                 printk(KERN_INFO "avma1_cs: testing i/o %#x-%#x\n",
 			link->io.BasePort1,
 		        link->io.BasePort1+link->io.NumPorts1 - 1);
-		i = CardServices(RequestIO, link->handle, &link->io);
+		i = pcmcia_request_io(link->handle, &link->io);
 		if (i == CS_SUCCESS) goto found_port;
 	    }
 	    i = next_tuple(handle, &tuple, &parse);
@@ -373,21 +383,21 @@ found_port:
 	/*
 	 * allocate an interrupt line
 	 */
-	i = CardServices(RequestIRQ, link->handle, &link->irq);
+	i = pcmcia_request_irq(link->handle, &link->irq);
 	if (i != CS_SUCCESS) {
 	    cs_error(link->handle, RequestIRQ, i);
-	    CardServices(ReleaseIO, link->handle, &link->io);
+	    pcmcia_release_io(link->handle, &link->io);
 	    break;
 	}
 	
 	/*
          * configure the PCMCIA socket
 	  */
-	i = CardServices(RequestConfiguration, link->handle, &link->conf);
+	i = pcmcia_request_configuration(link->handle, &link->conf);
 	if (i != CS_SUCCESS) {
 	    cs_error(link->handle, RequestConfiguration, i);
-	    CardServices(ReleaseIO, link->handle, &link->io);
-	    CardServices(ReleaseIRQ, link->handle, &link->irq);
+	    pcmcia_release_io(link->handle, &link->io);
+	    pcmcia_release_irq(link->handle, &link->irq);
 	    break;
 	}
 
@@ -445,9 +455,9 @@ static void avma1cs_release(dev_link_t *
     link->dev = NULL;
     
     /* Don't bother checking to see if these succeed or not */
-    CardServices(ReleaseConfiguration, link->handle);
-    CardServices(ReleaseIO, link->handle, &link->io);
-    CardServices(ReleaseIRQ, link->handle, &link->irq);
+    pcmcia_release_configuration(link->handle);
+    pcmcia_release_io(link->handle, &link->io);
+    pcmcia_release_irq(link->handle, &link->irq);
     link->state &= ~DEV_CONFIG;
     
     if (link->state & DEV_STALE_LINK)
@@ -490,14 +500,14 @@ static int avma1cs_event(event_t event, 
 	/* Fall through... */
     case CS_EVENT_RESET_PHYSICAL:
 	if (link->state & DEV_CONFIG)
-	    CardServices(ReleaseConfiguration, link->handle);
+	    pcmcia_release_configuration(link->handle);
 	break;
     case CS_EVENT_PM_RESUME:
 	link->state &= ~DEV_SUSPEND;
 	/* Fall through... */
     case CS_EVENT_CARD_RESET:
 	if (link->state & DEV_CONFIG)
-	    CardServices(RequestConfiguration, link->handle, &link->conf);
+	    pcmcia_request_configuration(link->handle, &link->conf);
 	break;
     }
     return 0;
diff -puN drivers/isdn/hisax/elsa_cs.c~linus drivers/isdn/hisax/elsa_cs.c
--- 25/drivers/isdn/hisax/elsa_cs.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/isdn/hisax/elsa_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -235,7 +235,7 @@ static dev_link_t *elsa_cs_attach(void)
     client_reg.event_handler = &elsa_cs_event;
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
-    ret = CardServices(RegisterClient, &link->handle, &client_reg);
+    ret = pcmcia_register_client(&link->handle, &client_reg);
     if (ret != CS_SUCCESS) {
         cs_error(link->handle, RegisterClient, ret);
         elsa_cs_detach(link);
@@ -286,7 +286,7 @@ static void elsa_cs_detach(dev_link_t *l
 
     /* Break the link with Card Services */
     if (link->handle) {
-        ret = CardServices(DeregisterClient, link->handle);
+        ret = pcmcia_deregister_client(link->handle);
 	if (ret != CS_SUCCESS)
 	    cs_error(link->handle, DeregisterClient, ret);
     }
@@ -304,19 +304,29 @@ static void elsa_cs_detach(dev_link_t *l
     device available to the system.
 
 ======================================================================*/
-static int get_tuple(int fn, client_handle_t handle, tuple_t *tuple,
+static int get_tuple(client_handle_t handle, tuple_t *tuple,
                      cisparse_t *parse)
 {
-    int i;
-    i = CardServices(fn, handle, tuple);
+    int i = pcmcia_get_tuple_data(handle, tuple);
     if (i != CS_SUCCESS) return i;
-    i = CardServices(GetTupleData, handle, tuple);
+    return pcmcia_parse_tuple(handle, tuple, parse);
+}
+
+static int first_tuple(client_handle_t handle, tuple_t *tuple,
+                     cisparse_t *parse)
+{
+    int i = pcmcia_get_first_tuple(handle, tuple);
     if (i != CS_SUCCESS) return i;
-    return CardServices(ParseTuple, handle, tuple, parse);
+    return get_tuple(handle, tuple, parse);
 }
 
-#define first_tuple(a, b, c) get_tuple(GetFirstTuple, a, b, c)
-#define next_tuple(a, b, c) get_tuple(GetNextTuple, a, b, c)
+static int next_tuple(client_handle_t handle, tuple_t *tuple,
+                     cisparse_t *parse)
+{
+    int i = pcmcia_get_next_tuple(handle, tuple);
+    if (i != CS_SUCCESS) return i;
+    return get_tuple(handle, tuple, parse);
+}
 
 static void elsa_cs_config(dev_link_t *link)
 {
@@ -362,14 +372,14 @@ static void elsa_cs_config(dev_link_t *l
             printk(KERN_INFO "(elsa_cs: looks like the 96 model)\n");
             link->conf.ConfigIndex = cf->index;
             link->io.BasePort1 = cf->io.win[0].base;
-            i = CardServices(RequestIO, link->handle, &link->io);
+            i = pcmcia_request_io(link->handle, &link->io);
             if (i == CS_SUCCESS) break;
         } else {
           printk(KERN_INFO "(elsa_cs: looks like the 97 model)\n");
           link->conf.ConfigIndex = cf->index;
           for (i = 0, j = 0x2f0; j > 0x100; j -= 0x10) {
             link->io.BasePort1 = j;
-            i = CardServices(RequestIO, link->handle, &link->io);
+            i = pcmcia_request_io(link->handle, &link->io);
             if (i == CS_SUCCESS) break;
           }
           break;
@@ -382,14 +392,14 @@ static void elsa_cs_config(dev_link_t *l
 	goto cs_failed;
     }
 
-    i = CardServices(RequestIRQ, link->handle, &link->irq);
+    i = pcmcia_request_irq(link->handle, &link->irq);
     if (i != CS_SUCCESS) {
         link->irq.AssignedIRQ = 0;
 	last_fn = RequestIRQ;
         goto cs_failed;
     }
 
-    i = CardServices(RequestConfiguration, link->handle, &link->conf);
+    i = pcmcia_request_configuration(link->handle, &link->conf);
     if (i != CS_SUCCESS) {
       last_fn = RequestConfiguration;
       goto cs_failed;
@@ -447,10 +457,10 @@ static void elsa_cs_release(dev_link_t *
 
     /* Don't bother checking to see if these succeed or not */
     if (link->win)
-        CardServices(ReleaseWindow, link->win);
-    CardServices(ReleaseConfiguration, link->handle);
-    CardServices(ReleaseIO, link->handle, &link->io);
-    CardServices(ReleaseIRQ, link->handle, &link->irq);
+        pcmcia_release_window(link->win);
+    pcmcia_release_configuration(link->handle);
+    pcmcia_release_io(link->handle, &link->io);
+    pcmcia_release_irq(link->handle, &link->irq);
     link->state &= ~DEV_CONFIG;
 
     if (link->state & DEV_STALE_LINK)
@@ -499,14 +509,14 @@ static int elsa_cs_event(event_t event, 
         /* Mark the device as stopped, to block IO until later */
         dev->busy = 1;
         if (link->state & DEV_CONFIG)
-            CardServices(ReleaseConfiguration, link->handle);
+            pcmcia_release_configuration(link->handle);
         break;
     case CS_EVENT_PM_RESUME:
         link->state &= ~DEV_SUSPEND;
         /* Fall through... */
     case CS_EVENT_CARD_RESET:
         if (link->state & DEV_CONFIG)
-            CardServices(RequestConfiguration, link->handle, &link->conf);
+            pcmcia_request_configuration(link->handle, &link->conf);
         dev->busy = 0;
         break;
     }
diff -puN drivers/isdn/hisax/sedlbauer_cs.c~linus drivers/isdn/hisax/sedlbauer_cs.c
--- 25/drivers/isdn/hisax/sedlbauer_cs.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/isdn/hisax/sedlbauer_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -247,7 +247,7 @@ static dev_link_t *sedlbauer_attach(void
     client_reg.event_handler = &sedlbauer_event;
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
-    ret = CardServices(RegisterClient, &link->handle, &client_reg);
+    ret = pcmcia_register_client(&link->handle, &client_reg);
     if (ret != CS_SUCCESS) {
 	cs_error(link->handle, RegisterClient, ret);
 	sedlbauer_detach(link);
@@ -295,7 +295,7 @@ static void sedlbauer_detach(dev_link_t 
 
     /* Break the link with Card Services */
     if (link->handle)
-	CardServices(DeregisterClient, link->handle);
+	pcmcia_deregister_client(link->handle);
     
     /* Unlink device structure, and free it */
     *linkp = link->next;
@@ -310,12 +310,8 @@ static void sedlbauer_detach(dev_link_t 
     device available to the system.
     
 ======================================================================*/
-
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn),args))!=0) goto cs_failed
-
-#define CFG_CHECK(fn, args...) \
-if (CardServices(fn, args) != 0) goto next_entry
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static void sedlbauer_config(dev_link_t *link)
 {
@@ -341,9 +337,9 @@ static void sedlbauer_config(dev_link_t 
     tuple.TupleData = buf;
     tuple.TupleDataMax = sizeof(buf);
     tuple.TupleOffset = 0;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
-    CS_CHECK(GetTupleData, handle, &tuple);
-    CS_CHECK(ParseTuple, handle, &tuple, &parse);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+    CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+    CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
     link->conf.ConfigBase = parse.config.base;
     link->conf.Present = parse.config.rmask[0];
     
@@ -351,7 +347,7 @@ static void sedlbauer_config(dev_link_t 
     link->state |= DEV_CONFIG;
 
     /* Look up the current Vcc */
-    CS_CHECK(GetConfigurationInfo, handle, &conf);
+    CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf));
     link->conf.Vcc = conf.Vcc;
 
     /*
@@ -367,12 +363,13 @@ static void sedlbauer_config(dev_link_t 
       will only use the CIS to fill in implementation-defined details.
     */
     tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
     while (1) {
 	cistpl_cftable_entry_t dflt = { 0 };
 	cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
-	CFG_CHECK(GetTupleData, handle, &tuple);
-	CFG_CHECK(ParseTuple, handle, &tuple, &parse);
+	if (pcmcia_get_tuple_data(handle, &tuple) != 0 ||
+		pcmcia_parse_tuple(handle, &tuple, &parse) != 0)
+	    goto next_entry;
 
 	if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg;
 	if (cfg->index == 0) goto next_entry;
@@ -425,7 +422,8 @@ static void sedlbauer_config(dev_link_t 
 		link->io.NumPorts2 = io->win[1].len;
 	    }
 	    /* This reserves IO space but doesn't actually enable it */
-	    CFG_CHECK(RequestIO, link->handle, &link->io);
+	    if (pcmcia_request_io(link->handle, &link->io) != 0)
+		goto next_entry;
 	}
 
 	/*
@@ -451,10 +449,11 @@ static void sedlbauer_config(dev_link_t 
                 req.Size = 0x1000;
 */
 	    req.AccessSpeed = 0;
-	    link->win = (window_handle_t)link->handle;
-	    CFG_CHECK(RequestWindow, &link->win, &req);
+	    if (pcmcia_request_window(&link->handle, &req, &link->win) != 0)
+		goto next_entry;
 	    map.Page = 0; map.CardOffset = mem->win[0].card_addr;
-	    CFG_CHECK(MapMemPage, link->win, &map);
+	    if (pcmcia_map_mem_page(link->win, &map) != 0)
+		goto next_entry;
 	}
 	/* If we got this far, we're cool! */
 	break;
@@ -462,9 +461,9 @@ static void sedlbauer_config(dev_link_t 
     next_entry:
 /* new in dummy.cs 2001/01/28 MN 
         if (link->io.NumPorts1)
-           CardServices(ReleaseIO, link->handle, &link->io);
+           pcmcia_release_io(link->handle, &link->io);
 */
-	CS_CHECK(GetNextTuple, handle, &tuple);
+	CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple));
     }
     
     /*
@@ -473,14 +472,14 @@ static void sedlbauer_config(dev_link_t 
        irq structure is initialized.
     */
     if (link->conf.Attributes & CONF_ENABLE_IRQ)
-	CS_CHECK(RequestIRQ, link->handle, &link->irq);
+	CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
 	
     /*
        This actually configures the PCMCIA socket -- setting up
        the I/O windows and the interrupt mapping, and putting the
        card and host interface into "Memory and IO" mode.
     */
-    CS_CHECK(RequestConfiguration, link->handle, &link->conf);
+    CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
 
     /*
       At this point, the dev_node_t structure(s) need to be
@@ -545,12 +544,12 @@ static void sedlbauer_release(dev_link_t
     
     /* Don't bother checking to see if these succeed or not */
     if (link->win)
-	CardServices(ReleaseWindow, link->win);
-    CardServices(ReleaseConfiguration, link->handle);
+	pcmcia_release_window(link->win);
+    pcmcia_release_configuration(link->handle);
     if (link->io.NumPorts1)
-	CardServices(ReleaseIO, link->handle, &link->io);
+	pcmcia_release_io(link->handle, &link->io);
     if (link->irq.AssignedIRQ)
-	CardServices(ReleaseIRQ, link->handle, &link->irq);
+	pcmcia_release_irq(link->handle, &link->irq);
     link->state &= ~DEV_CONFIG;
     
     if (link->state & DEV_STALE_LINK)
@@ -597,14 +596,14 @@ static int sedlbauer_event(event_t event
 	/* Mark the device as stopped, to block IO until later */
 	dev->stop = 1;
 	if (link->state & DEV_CONFIG)
-	    CardServices(ReleaseConfiguration, link->handle);
+	    pcmcia_release_configuration(link->handle);
 	break;
     case CS_EVENT_PM_RESUME:
 	link->state &= ~DEV_SUSPEND;
 	/* Fall through... */
     case CS_EVENT_CARD_RESET:
 	if (link->state & DEV_CONFIG)
-	    CardServices(RequestConfiguration, link->handle, &link->conf);
+	    pcmcia_request_configuration(link->handle, &link->conf);
 	dev->stop = 0;
 	/*
 	  In a normal driver, additional code may go here to restore
diff -puN drivers/isdn/Makefile~linus drivers/isdn/Makefile
--- 25/drivers/isdn/Makefile~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/isdn/Makefile	2004-01-19 22:17:22.000000000 -0800
@@ -12,6 +12,5 @@ obj-$(CONFIG_ISDN_DRV_PCBIT)		+= pcbit/
 obj-$(CONFIG_ISDN_DRV_SC)		+= sc/
 obj-$(CONFIG_ISDN_DRV_LOOP)		+= isdnloop/
 obj-$(CONFIG_ISDN_DRV_ACT2000)		+= act2000/
-obj-$(CONFIG_ISDN_DRV_EICON)		+= eicon/
 obj-$(CONFIG_HYSDN)			+= hysdn/
 obj-$(CONFIG_ISDN_DRV_TPAM)		+= tpam/
diff -puN drivers/Kconfig~linus drivers/Kconfig
--- 25/drivers/Kconfig~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/Kconfig	2004-01-19 22:17:21.000000000 -0800
@@ -38,6 +38,8 @@ source "drivers/input/Kconfig"
 
 source "drivers/char/Kconfig"
 
+source "drivers/i2c/Kconfig"
+
 # source "drivers/misc/Kconfig"
 
 source "drivers/media/Kconfig"
diff -puN drivers/macintosh/adb-iop.c~linus drivers/macintosh/adb-iop.c
--- 25/drivers/macintosh/adb-iop.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/macintosh/adb-iop.c	2004-01-19 22:17:22.000000000 -0800
@@ -105,18 +105,19 @@ static void adb_iop_listen(struct iop_ms
 	struct adb_iopmsg *amsg = (struct adb_iopmsg *) msg->message;
 	struct adb_request *req;
 	uint flags;
+#ifdef DEBUG_ADB_IOP
+	int i;
+#endif
 
 	local_irq_save(flags);
 
 	req = current_req;
 
 #ifdef DEBUG_ADB_IOP
-	printk("adb_iop_listen: rcvd packet, %d bytes: %02X %02X",
+	printk("adb_iop_listen %p: rcvd packet, %d bytes: %02X %02X", req,
 		(uint) amsg->count + 2, (uint) amsg->flags, (uint) amsg->cmd);
-	i = 0;
-	while (i < amsg->count) {
-		printk(" %02X", (uint) amsg->data[i++]);
-	}
+	for (i = 0; i < amsg->count; i++)
+		printk(" %02X", (uint) amsg->data[i]);
 	printk("\n");
 #endif
 
@@ -134,7 +135,7 @@ static void adb_iop_listen(struct iop_ms
 			adb_iop_end_req(req, idle);
 		}
 	} else {
-		/* TODO: is it possible for more tha one chunk of data  */
+		/* TODO: is it possible for more than one chunk of data  */
 		/*       to arrive before the timeout? If so we need to */
 		/*       use reply_ptr here like the other drivers do.  */
 		if ((adb_iop_state == awaiting_reply) &&
@@ -163,6 +164,9 @@ static void adb_iop_start(void)
 	unsigned long flags;
 	struct adb_request *req;
 	struct adb_iopmsg amsg;
+#ifdef DEBUG_ADB_IOP
+	int i;
+#endif
 
 	/* get the packet to send */
 	req = current_req;
@@ -171,7 +175,7 @@ static void adb_iop_start(void)
 	local_irq_save(flags);
 
 #ifdef DEBUG_ADB_IOP
-	printk("adb_iop_start: sending packet, %d bytes:", req->nbytes);
+	printk("adb_iop_start %p: sending packet, %d bytes:", req, req->nbytes);
 	for (i = 0 ; i < req->nbytes ; i++)
 		printk(" %02X", (uint) req->data[i]);
 	printk("\n");
@@ -267,13 +271,17 @@ void adb_iop_poll(void)
 
 int adb_iop_reset_bus(void)
 {
-	struct adb_request req;
+	struct adb_request req = {
+		.reply_expected = 0,
+		.nbytes = 2,
+		.data = { ADB_PACKET, 0 },
+	};
 
-	req.reply_expected = 0;
-	req.nbytes = 2;
-	req.data[0] = ADB_PACKET;
-	req.data[1] = 0; /* RESET */
 	adb_iop_write(&req);
-	while (!req.complete) adb_iop_poll();
+	while (!req.complete) {
+		adb_iop_poll();
+		schedule();
+	}
+
 	return 0;
 }
diff -puN drivers/macintosh/via-macii.c~linus drivers/macintosh/via-macii.c
--- 25/drivers/macintosh/via-macii.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/macintosh/via-macii.c	2004-01-19 22:17:22.000000000 -0800
@@ -22,13 +22,13 @@
 #include <linux/sched.h>
 #include <linux/adb.h>
 #include <linux/interrupt.h>
+#include <linux/init.h>
 #include <asm/macintosh.h>
 #include <asm/macints.h>
 #include <asm/machw.h>
 #include <asm/mac_via.h>
 #include <asm/io.h>
 #include <asm/system.h>
-#include <asm/init.h>
 
 static volatile unsigned char *via;
 
diff -puN /dev/null drivers/media/common/ir-common.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/media/common/ir-common.c	2004-01-19 22:17:22.000000000 -0800
@@ -0,0 +1,218 @@
+/*
+ * some common structs and functions to handle infrared remotes via
+ * input layer ...
+ *
+ * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <linux/module.h>
+
+#include <media/ir-common.h>
+
+/* -------------------------------------------------------------------------- */
+
+MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
+MODULE_LICENSE("GPL");
+
+static int repeat = 1;
+MODULE_PARM(repeat,"i");
+MODULE_PARM_DESC(repeat,"auto-repeat for IR keys (default: on)");
+
+static int debug = 0;    /* debug level (0,1,2) */
+MODULE_PARM(debug,"i");
+
+#define dprintk(level, fmt, arg...)	if (debug >= level) \
+	printk(KERN_DEBUG fmt , ## arg)
+
+/* -------------------------------------------------------------------------- */
+
+/* generic RC5 keytable                                          */
+/* see http://users.pandora.be/nenya/electronics/rc5/codes00.htm */
+IR_KEYTAB_TYPE ir_codes_rc5_tv[IR_KEYTAB_SIZE] = {
+	[ 0x00 ] = KEY_KP0,             // 0
+	[ 0x01 ] = KEY_KP1,             // 1
+	[ 0x02 ] = KEY_KP2,             // 2
+	[ 0x03 ] = KEY_KP3,             // 3
+	[ 0x04 ] = KEY_KP4,             // 4
+	[ 0x05 ] = KEY_KP5,             // 5
+	[ 0x06 ] = KEY_KP6,             // 6
+	[ 0x07 ] = KEY_KP7,             // 7
+	[ 0x08 ] = KEY_KP8,             // 8
+	[ 0x09 ] = KEY_KP9,             // 9
+
+	[ 0x0b ] = KEY_CHANNEL,         // channel / program (japan: 11)
+	[ 0x0c ] = KEY_POWER,           // standby
+	[ 0x0d ] = KEY_MUTE,            // mute / demute
+	[ 0x0f ] = KEY_TV,              // display
+	[ 0x10 ] = KEY_VOLUMEUP,        // volume +
+	[ 0x11 ] = KEY_VOLUMEDOWN,      // volume -
+	[ 0x12 ] = KEY_BRIGHTNESSUP,    // brightness +
+	[ 0x13 ] = KEY_BRIGHTNESSDOWN,  // brightness -
+	[ 0x1e ] = KEY_SEARCH,          // search +
+	[ 0x20 ] = KEY_CHANNELUP,       // channel / program +
+	[ 0x21 ] = KEY_CHANNELDOWN,     // channel / program -
+	[ 0x22 ] = KEY_CHANNEL,         // alt / channel
+	[ 0x23 ] = KEY_LANGUAGE,        // 1st / 2nd language
+	[ 0x26 ] = KEY_SLEEP,           // sleeptimer
+	[ 0x2e ] = KEY_MENU,            // 2nd controls (USA: menu)
+	[ 0x30 ] = KEY_PAUSE,           // pause
+	[ 0x32 ] = KEY_REWIND,          // rewind
+	[ 0x33 ] = KEY_GOTO,            // go to
+	[ 0x35 ] = KEY_PLAY,            // play
+	[ 0x36 ] = KEY_STOP,            // stop
+	[ 0x37 ] = KEY_RECORD,          // recording
+
+#if 0 /* FIXME */
+	[ 0x0a ] = KEY_RESERVED,        // 1/2/3 digits (japan: 10)
+	[ 0x0e ] = KEY_RESERVED,        // P.P. (personal preference)
+	[ 0x14 ] = KEY_RESERVED,        // colour saturation +
+	[ 0x15 ] = KEY_RESERVED,        // colour saturation -
+	[ 0x16 ] = KEY_RESERVED,        // bass +
+	[ 0x17 ] = KEY_RESERVED,        // bass -
+	[ 0x18 ] = KEY_RESERVED,        // treble +
+	[ 0x19 ] = KEY_RESERVED,        // treble -
+	[ 0x1a ] = KEY_RESERVED,        // balance right
+	[ 0x1b ] = KEY_RESERVED,        // balance left
+	[ 0x1c ] = KEY_RESERVED,        // contrast +
+	[ 0x1d ] = KEY_RESERVED,        // contrast -
+	[ 0x1f ] = KEY_RESERVED,        // tint/hue +
+	[ 0x24 ] = KEY_RESERVED,        // spacial stereo on/off
+	[ 0x25 ] = KEY_RESERVED,        // mono / stereo (USA)
+	[ 0x27 ] = KEY_RESERVED,        // tint / hue -
+	[ 0x28 ] = KEY_RESERVED,        // RF switch/PIP select
+	[ 0x29 ] = KEY_RESERVED,        // vote
+	[ 0x2a ] = KEY_RESERVED,        // timed page/channel clck
+	[ 0x2b ] = KEY_RESERVED,        // increment (USA)
+	[ 0x2c ] = KEY_RESERVED,        // decrement (USA)
+	[ 0x2d ] = KEY_RESERVED,        // 
+	[ 0x2f ] = KEY_RESERVED,        // PIP shift
+	[ 0x31 ] = KEY_RESERVED,        // erase
+	[ 0x34 ] = KEY_RESERVED,        // wind
+	[ 0x38 ] = KEY_RESERVED,        // external 1
+	[ 0x39 ] = KEY_RESERVED,        // external 2
+	[ 0x3a ] = KEY_RESERVED,        // PIP display mode
+	[ 0x3b ] = KEY_RESERVED,        // view data mode / advance
+	[ 0x3c ] = KEY_RESERVED,        // teletext submode (Japan: 12)
+	[ 0x3d ] = KEY_RESERVED,        // system standby
+	[ 0x3e ] = KEY_RESERVED,        // crispener on/off
+	[ 0x3f ] = KEY_RESERVED,        // system select
+#endif
+};
+EXPORT_SYMBOL_GPL(ir_codes_rc5_tv);
+
+/* empty keytable, can be used as placeholder for not-yet created keytables */
+IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE] = {
+	[ 42 ] = KEY_COFFEE,
+};
+EXPORT_SYMBOL_GPL(ir_codes_empty);
+
+/* -------------------------------------------------------------------------- */
+
+static void ir_input_key_event(struct input_dev *dev, struct ir_input_state *ir)
+{
+	if (KEY_RESERVED == ir->keycode) {
+		printk(KERN_INFO "%s: unknown key: key=0x%02x raw=0x%02x down=%d\n",
+		       dev->name,ir->ir_key,ir->ir_raw,ir->keypressed);
+		return;
+	}
+	dprintk(1,"%s: key event code=%d down=%d\n",
+		dev->name,ir->keycode,ir->keypressed);
+	input_report_key(dev,ir->keycode,ir->keypressed);
+        input_sync(dev);
+}
+
+/* -------------------------------------------------------------------------- */
+
+void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
+		   int ir_type, IR_KEYTAB_TYPE *ir_codes)
+{
+	int i;
+	
+	ir->ir_type = ir_type;
+	if (ir_codes)
+		memcpy(ir->ir_codes, ir_codes, sizeof(ir->ir_codes));
+
+        init_input_dev(dev);
+	dev->keycode     = ir->ir_codes;
+	dev->keycodesize = sizeof(IR_KEYTAB_TYPE);
+	dev->keycodemax  = IR_KEYTAB_SIZE;
+	for (i = 0; i < IR_KEYTAB_SIZE; i++)
+		set_bit(ir->ir_codes[i], dev->keybit);
+	clear_bit(0, dev->keybit);
+
+	set_bit(EV_KEY, dev->evbit);
+	if (repeat)
+		set_bit(EV_REP, dev->evbit);
+}
+
+void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir)
+{
+	if (ir->keypressed) {
+		ir->keypressed = 0;
+		ir_input_key_event(dev,ir);
+	}
+}
+
+void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
+		      u32 ir_key, u32 ir_raw)
+{
+	u32 keycode = IR_KEYCODE(ir->ir_codes, ir_key);
+	
+	if (ir->keypressed && ir->keycode != keycode) {
+		ir->keypressed = 0;
+		ir_input_key_event(dev,ir);
+	}
+	if (!ir->keypressed) {
+		ir->ir_key  = ir_key;
+		ir->ir_raw  = ir_raw;
+		ir->keycode = keycode;
+		ir->keypressed = 1;
+		ir_input_key_event(dev,ir);
+	}
+#if 0
+	/* maybe do something like this ??? */
+	input_event(a, EV_IR, ir->ir_type, ir->ir_raw);
+#endif
+}
+
+u32 ir_extract_bits(u32 data, u32 mask)
+{
+	int mbit, vbit;
+	u32 value;
+
+	value = 0;
+	vbit  = 0;
+	for (mbit = 0; mbit < 32; mbit++) {
+		if (!(mask & ((u32)1 << mbit)))
+			continue;
+		if (data & ((u32)1 << mbit))
+			value |= (1 << vbit);
+		vbit++;
+	}
+	return value;
+}
+
+EXPORT_SYMBOL_GPL(ir_input_init);
+EXPORT_SYMBOL_GPL(ir_input_nokey);
+EXPORT_SYMBOL_GPL(ir_input_keydown);
+EXPORT_SYMBOL_GPL(ir_extract_bits);
+
+/*
+ * Local variables:
+ * c-basic-offset: 8
+ * End:
+ */
diff -puN drivers/media/common/Makefile~linus drivers/media/common/Makefile
--- 25/drivers/media/common/Makefile~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/common/Makefile	2004-01-19 22:17:22.000000000 -0800
@@ -3,4 +3,4 @@ saa7146_vv-objs := saa7146_vv_ksyms.o sa
 
 obj-$(CONFIG_VIDEO_SAA7146) += saa7146.o
 obj-$(CONFIG_VIDEO_SAA7146_VV) += saa7146_vv.o
-
+obj-$(CONFIG_VIDEO_IR) += ir-common.o
diff -puN drivers/media/Kconfig~linus drivers/media/Kconfig
--- 25/drivers/media/Kconfig~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/Kconfig	2004-01-19 22:17:22.000000000 -0800
@@ -34,19 +34,26 @@ source "drivers/media/common/Kconfig"
 
 config VIDEO_TUNER
 	tristate
-	default y if VIDEO_BT848=y || VIDEO_SAA7134=y || VIDEO_MXB=y
-	default m if VIDEO_BT848=m || VIDEO_SAA7134=m || VIDEO_MXB=m
+	default y if VIDEO_BT848=y || VIDEO_SAA7134=y || VIDEO_MXB=y || VIDEO_CX88=y
+	default m if VIDEO_BT848=m || VIDEO_SAA7134=m || VIDEO_MXB=m || VIDEO_CX88=m
 	depends on VIDEO_DEV
 
 config VIDEO_BUF
 	tristate
-	default y if VIDEO_BT848=y || VIDEO_SAA7134=y || VIDEO_SAA7146=y
-	default m if VIDEO_BT848=m || VIDEO_SAA7134=m || VIDEO_SAA7146=m
+	default y if VIDEO_BT848=y || VIDEO_SAA7134=y || VIDEO_SAA7146=y || VIDEO_CX88=y
+	default m if VIDEO_BT848=m || VIDEO_SAA7134=m || VIDEO_SAA7146=m || VIDEO_CX88=m
 	depends on VIDEO_DEV
 
 config VIDEO_BTCX
 	tristate
-	default VIDEO_BT848
+	default y if VIDEO_BT848=y || VIDEO_CX88=y
+	default m if VIDEO_BT848=m || VIDEO_CX88=m
+	depends on VIDEO_DEV
+
+config VIDEO_IR
+	tristate
+	default y if VIDEO_BT848=y || VIDEO_SAA7134=y
+	default m if VIDEO_BT848=m || VIDEO_SAA7134=m
 	depends on VIDEO_DEV
 
 endmenu
diff -puN drivers/media/video/bt848.h~linus drivers/media/video/bt848.h
--- 25/drivers/media/video/bt848.h~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/bt848.h	2004-01-19 22:17:22.000000000 -0800
@@ -158,6 +158,9 @@
 #define BT848_ADC_C_SLEEP      (1<<1)
 #define BT848_ADC_CRUSH        (1<<0)
 
+#define BT848_WC_UP            0x044
+#define BT848_WC_DOWN          0x078
+
 #define BT848_E_VTC            0x06C
 #define BT848_O_VTC            0x0EC
 #define BT848_VTC_HSFMT        (1<<7)
diff -puN drivers/media/video/bttv-cards.c~linus drivers/media/video/bttv-cards.c
--- 25/drivers/media/video/bttv-cards.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/bttv-cards.c	2004-01-19 22:17:22.000000000 -0800
@@ -53,6 +53,8 @@ static void winview_audio(struct bttv *b
 static void lt9415_audio(struct bttv *btv, struct video_audio *v, int set);
 static void avermedia_tvphone_audio(struct bttv *btv, struct video_audio *v,
 				    int set);
+static void avermedia_tv_stereo_audio(struct bttv *btv, struct video_audio *v,
+				      int set);
 static void terratv_audio(struct bttv *btv, struct video_audio *v, int set);
 static void gvbctv3pci_audio(struct bttv *btv, struct video_audio *v, int set);
 static void winfast2000_audio(struct bttv *btv, struct video_audio *v, int set);
@@ -64,6 +66,7 @@ static void rv605_muxsel(struct bttv *bt
 static void eagle_muxsel(struct bttv *btv, unsigned int input);
 static void xguard_muxsel(struct bttv *btv, unsigned int input);
 static void ivc120_muxsel(struct bttv *btv, unsigned int input);
+static void gvc1100_muxsel(struct bttv *btv, unsigned int input);
 
 static int terratec_active_radio_upgrade(struct bttv *btv);
 static int tea5757_read(struct bttv *btv);
@@ -77,10 +80,11 @@ static unsigned int vsfx=0;
 static unsigned int latency = UNSET;
 unsigned int no_overlay=-1;
 
-static unsigned int card[BTTV_MAX]  = { [ 0 ... (BTTV_MAX-1) ] = UNSET};
-static unsigned int pll[BTTV_MAX]   = { [ 0 ... (BTTV_MAX-1) ] = UNSET};
-static unsigned int tuner[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET};
-static unsigned int svhs[BTTV_MAX]  = { [ 0 ... (BTTV_MAX-1) ] = UNSET};
+static unsigned int card[BTTV_MAX]   = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
+static unsigned int pll[BTTV_MAX]    = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
+static unsigned int tuner[BTTV_MAX]  = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
+static unsigned int svhs[BTTV_MAX]   = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
+static unsigned int remote[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET };
 #ifdef MODULE
 static unsigned int autoload = 1;
 #else
@@ -108,6 +112,10 @@ MODULE_PARM(tuner,"1-" __stringify(BTTV_
 MODULE_PARM_DESC(tuner,"specify installed tuner type");
 MODULE_PARM(autoload,"i");
 MODULE_PARM_DESC(autoload,"automatically load i2c modules like tuner.o, default is 1 (yes)");
+
+MODULE_PARM(svhs,"1-" __stringify(BTTV_MAX) "i");
+MODULE_PARM(remote,"1-" __stringify(BTTV_MAX) "i");
+
 MODULE_PARM(gpiomask,"i");
 MODULE_PARM(audioall,"i");
 MODULE_PARM(audiomux,"1-5i");
@@ -155,12 +163,13 @@ static struct CARD {
 	{ 0x00031002, BTTV_ATI_TVWONDERVE,"ATI TV Wonder/VE" },
 
 	{ 0x6606107d, BTTV_WINFAST2000,   "Leadtek WinFast TV 2000" },
-	{ 0x6607107d, BTTV_WINFAST2000,   "Leadtek WinFast VC 100" },
+	{ 0x6607107d, BTTV_WINFASTVC100,  "Leadtek WinFast VC 100" },
 	{ 0x263610b4, BTTV_STB2,          "STB TV PCI FM, Gateway P/N 6000704" },
 	{ 0x264510b4, BTTV_STB2,          "STB TV PCI FM, Gateway P/N 6000704" },
  	{ 0x402010fc, BTTV_GVBCTV3PCI,    "I-O Data Co. GV-BCTV3/PCI" },
 	{ 0x405010fc, BTTV_GVBCTV4PCI,    "I-O Data Co. GV-BCTV4/PCI" },
 	{ 0x407010fc, BTTV_GVBCTV5PCI,    "I-O Data Co. GV-BCTV5/PCI" },
+ 	{ 0xd01810fc, BTTV_GVBCTV3PCI,    "I-O Data Co. GV-BCTV3/PCI" },
 
 	{ 0x001211bd, BTTV_PINNACLE,      "Pinnacle PCTV" },
 	{ 0x001c11bd, BTTV_PINNACLESAT,   "Pinnacle PCTV Sat" },
@@ -175,16 +184,15 @@ static struct CARD {
 	{ 0x3002144f, BTTV_MAGICTVIEW061, "(Askey Magic/others) TView99 CPH05x" },
 	{ 0x3005144f, BTTV_MAGICTVIEW061, "(Askey Magic/others) TView99 CPH061/06L (T1/LC)" },
 	{ 0x5000144f, BTTV_MAGICTVIEW061, "Askey CPH050" },
-	
+	{ 0x300014ff, BTTV_MAGICTVIEW061, "TView 99 (CPH061)" },
+	{ 0x300214ff, BTTV_PHOEBE_TVMAS,  "Phoebe TV Master (CPH060)" },
+
 	{ 0x00011461, BTTV_AVPHONE98,     "AVerMedia TVPhone98" },
 	{ 0x00021461, BTTV_AVERMEDIA98,   "AVermedia TVCapture 98" },
 	{ 0x00031461, BTTV_AVPHONE98,     "AVerMedia TVPhone98" },
 	{ 0x00041461, BTTV_AVERMEDIA98,   "AVerMedia TVCapture 98" },
 	{ 0x03001461, BTTV_AVERMEDIA98,   "VDOMATE TV TUNER CARD" },
 
-	{ 0x300014ff, BTTV_MAGICTVIEW061, "TView 99 (CPH061)" },
-	{ 0x300214ff, BTTV_PHOEBE_TVMAS,  "Phoebe TV Master (CPH060)" },
-
 	{ 0x1117153b, BTTV_TERRATVALUE,   "Terratec TValue (Philips PAL B/G)" },
 	{ 0x1118153b, BTTV_TERRATVALUE,   "Terratec TValue (Temic PAL B/G)" },
 	{ 0x1119153b, BTTV_TERRATVALUE,   "Terratec TValue (Philips PAL I)" },
@@ -253,16 +261,27 @@ static struct CARD {
 	{ 0x18501851, BTTV_CHRONOS_VS2,   "FlyVideo 98 (LR50)/ Chronos Video Shuttle II" },
 	{ 0x18511851, BTTV_FLYVIDEO98EZ,  "FlyVideo 98EZ (LR51)/ CyberMail AV" },
 	{ 0x18521852, BTTV_TYPHOON_TVIEW, "FlyVideo 98FM (LR50)/ Typhoon TView TV/FM Tuner" },
+	{ 0x41a0a051, BTTV_FLYVIDEO_98FM, "Lifeview FlyVideo 98 LR50 Rev Q" },
 	{ 0x10b42636, BTTV_HAUPPAUGE878,  "STB ???" },
 	{ 0x217d6606, BTTV_WINFAST2000,   "Leadtek WinFast TV 2000" },
+	{ 0xfff6f6ff, BTTV_WINFAST2000,   "Leadtek WinFast TV 2000" },
 	{ 0x03116000, BTTV_SENSORAY311,   "Sensoray 311" },
 	{ 0x00790e11, BTTV_WINDVR,        "Canopus WinDVR PCI" },
 	{ 0xa0fca1a0, BTTV_ZOLTRIX,       "Face to Face Tvmax" },
-	{ 0x01010071, BTTV_NEBULA_DIGITV, "Nebula Electronics DigiTV" },
+	{ 0x20007063, BTTV_PC_HDTV,       "pcHDTV HD-2000 TV"},
+	{ 0x82b2aa6a, BTTV_SIMUS_GVC1100, "SIMUS GVC1100" },
+
+	{ 0x40111554, BTTV_PV_BT878P_9B,  "Prolink Pixelview PV-BT" },
+	{ 0x17de0a01, BTTV_KWORLD,        "Mecer TV/FM/Video Tuner" },
 
 	// likely broken, vendor id doesn't match the other magic views ...
 	//{ 0xa0fca04f, BTTV_MAGICTVIEW063, "Guillemot Maxi TV Video 3" },
 	
+	// DVB cards (using pci function .1 for mpeg data xfer)
+	{ 0x01010071, BTTV_NEBULA_DIGITV, "Nebula Electronics DigiTV" },
+	{ 0x002611bd, BTTV_TWINHAN_DST,   "Pinnacle PCTV SAT CI" },
+	{ 0x00011822, BTTV_TWINHAN_DST,   "Twinhan VisionPlus DVB-T" },
+	
 	{ 0, -1, NULL }
 };
 
@@ -352,6 +371,7 @@ struct tvcard bttv_tvcards[] = {
 	.needs_tvaudio	= 1,
 	.tuner_type	= -1,
 	.audio_hook	= avermedia_tvphone_audio,
+	.has_remote     = 1,
 },{
 	.name		= "MATRIX-Vision MV-Delta",
 	.video_inputs	= 5,
@@ -438,6 +458,7 @@ struct tvcard bttv_tvcards[] = {
 	.msp34xx_alt    = 1,
 	.pll		= PLL_28,
 	.tuner_type	= TUNER_PHILIPS_PAL,
+	.audio_hook     = avermedia_tv_stereo_audio,
 },{
 	.name		= "Aimslab Video Highway Xtreme (VHX)",
 	.video_inputs	= 3,
@@ -471,7 +492,13 @@ struct tvcard bttv_tvcards[] = {
 	.svhs		= 2,
 	.gpiomask	= 0x01fe00,
 	.muxsel		= { 2, 3, 1, 1},
+#if 0
+	// old
 	.audiomux	= { 0x01c000, 0, 0x018000, 0x014000, 0x002000, 0 },
+#else
+	// 2003-10-20 by "Anton A. Arapov" <arapov@mail.ru>
+	.audiomux       = { 0x001e00, 0, 0x018000, 0x014000, 0x002000, 0 },
+#endif
 	.needs_tvaudio	= 1,
 	.pll		= PLL_28,
 	.tuner_type	= -1,
@@ -733,6 +760,7 @@ struct tvcard bttv_tvcards[] = {
 	.has_radio	= 1,
 	.tuner_type	= 5, // default for now, gpio reads BFFF06 for Pal bg+dk
 	.audio_hook	= winfast2000_audio,
+	.has_remote     = 1,
 },{
 	.name		= "Lifeview FlyVideo 98 LR50 / Chronos Video Shuttle II",
 	.video_inputs	= 4,
@@ -988,7 +1016,7 @@ struct tvcard bttv_tvcards[] = {
 	/* Claas Langbehn <claas@bigfoot.com>,
 	   Sven Grothklags <sven@upb.de> */
 	.name		= "Typhoon TView RDS + FM Stereo / KNC1 TV Station RDS",
-	.video_inputs	= 3,
+	.video_inputs	= 4,
 	.audio_inputs	= 3,
 	.tuner		= 0,
 	.svhs		= 2,
@@ -997,7 +1025,7 @@ struct tvcard bttv_tvcards[] = {
 	.audiomux	= { 0, 0, 0x10, 8, 4 },
 	.needs_tvaudio	= 1,
 	.pll		= PLL_28,
-	.tuner_type	= TUNER_PHILIPS_PAL_I,
+	.tuner_type	= TUNER_PHILIPS_PAL,
 	.has_radio	= 1,
 },{
 	/* Tim Röstermundt <rosterm@uni-muenster.de>
@@ -1248,6 +1276,7 @@ struct tvcard bttv_tvcards[] = {
         .needs_tvaudio  = 1,
         .pll            = PLL_28,
         .tuner_type     = 25,
+	.has_remote     = 1,
 	/* GPIO wiring:
 		GPIO0: U4.A0 (hef4052bt)
 		GPIO1: U4.A1
@@ -1283,6 +1312,7 @@ struct tvcard bttv_tvcards[] = {
 	.tuner_type	= 5,
 	.audio_hook	= pvbt878p9b_audio, // Note: not all cards have stereo
 	.has_radio	= 1,  // Note: not all cards have radio
+	.has_remote     = 1,
 	/* GPIO wiring:
 		GPIO0: A0 hef4052
 		GPIO1: A1 hef4052
@@ -1751,7 +1781,8 @@ struct tvcard bttv_tvcards[] = {
 	.no_tda7432     = 1,
 	.pll            = PLL_28,
 	.tuner_type     = -1,
-	.no_video       = 1,
+	.has_dvb        = 1,
+	.no_gpioirq     = 1,
 },{
 	/* Jorge Boncompte - DTI2 <jorge@dti2.net> */
 	.name           = "ProVideo PV143",
@@ -1850,6 +1881,86 @@ struct tvcard bttv_tvcards[] = {
 			    0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 },
 	.muxsel_hook    = ivc120_muxsel,
 	.pll            = PLL_28,
+},{
+
+	/* ---- card 0x70 ---------------------------------- */
+	.name           = "pcHDTV HD-2000 TV",
+	.video_inputs   = 4,
+	.audio_inputs   = 1,
+	.tuner          = 0,
+	.svhs           = 2,
+	.muxsel         = { 2, 3, 1, 0},
+	.tuner_type     = TUNER_PHILIPS_ATSC,
+},{
+	.name           = "Twinhan DST + clones",
+	.no_msp34xx     = 1,
+	.no_tda9875     = 1,
+	.no_tda7432     = 1,
+	.tuner_type     = TUNER_ABSENT,
+	.no_video       = 1,
+	.has_dvb        = 1,
+},{
+        .name           = "Winfast VC100",
+	.video_inputs   = 3,
+	.audio_inputs   = 0,
+	.svhs           = 1,
+	.tuner          = -1, // no tuner
+	.muxsel         = { 3, 1, 1, 3}, // Vid In, SVid In, Vid over SVid in connector
+        .no_msp34xx     = 1,
+        .no_tda9875     = 1,
+        .no_tda7432     = 1,
+        .tuner_type     = TUNER_ABSENT,
+        .no_video       = 1,
+	.pll            = PLL_28,
+},{
+	.name           = "Teppro TEV-560/InterVision IV-560",
+	.video_inputs   = 3,
+	.audio_inputs   = 1,
+	.tuner          = 0,
+	.svhs           = 2,
+	.gpiomask       = 3,
+	.muxsel         = { 2, 3, 1, 1},
+	.audiomux       = { 1, 1, 1, 1, 0},
+	.needs_tvaudio  = 1,
+	.tuner_type     = TUNER_PHILIPS_PAL,
+	.pll            = PLL_35,
+},{
+
+	/* ---- card 0x74 ---------------------------------- */
+        .name           = "SIMUS GVC1100",
+        .video_inputs   = 4,
+        .audio_inputs   = 0,
+        .tuner          = -1,
+        .svhs           = -1,
+        .tuner_type     = -1,
+        .pll            = PLL_28,
+        .muxsel         = { 2, 2, 2, 2},
+        .gpiomask       = 0x3F,
+	.muxsel_hook    = gvc1100_muxsel,
+},{
+        /* Carlos Silva r3pek@r3pek.homelinux.org || card 0x75 */
+        .name           = "NGS NGSTV+",
+        .video_inputs   = 3,
+        .tuner          = 0,
+        .svhs           = 2,
+        .gpiomask       = 0x008007,
+        .muxsel         = {2, 3, 0, 0},
+        .audiomux       = {0, 0, 0, 0, 0x000003, 0},
+        .pll            = PLL_28,
+        .tuner_type     = TUNER_PHILIPS_PAL,
+        .has_remote     = 1,
+},{
+        /* http://linuxmedialabs.com */
+        .name           = "LMLBT4",
+        .video_inputs   = 4, /* IN1,IN2,IN3,IN4 */
+        .audio_inputs   = 0,
+        .tuner          = -1,
+        .svhs           = -1,
+        .muxsel         = { 2, 3, 1, 0 },
+        .no_msp34xx     = 1,
+        .no_tda9875     = 1,
+        .no_tda7432     = 1,
+        .needs_tvaudio  = 0,
 }};
 
 const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards);
@@ -1868,9 +1979,9 @@ void __devinit bttv_idcard(struct bttv *
 	unsigned short tmp;
 
 	/* read PCI subsystem ID */
-	pci_read_config_word(btv->dev, PCI_SUBSYSTEM_ID, &tmp);
+	pci_read_config_word(btv->c.pci, PCI_SUBSYSTEM_ID, &tmp);
 	btv->cardid = tmp << 16;
-	pci_read_config_word(btv->dev, PCI_SUBSYSTEM_VENDOR_ID, &tmp);
+	pci_read_config_word(btv->c.pci, PCI_SUBSYSTEM_VENDOR_ID, &tmp);
 	btv->cardid |= tmp;
 
 	if (0 != btv->cardid && 0xffffffff != btv->cardid) {
@@ -1883,14 +1994,14 @@ void __devinit bttv_idcard(struct bttv *
 			/* found it */
 			printk(KERN_INFO "bttv%d: detected: %s [card=%d], "
 			       "PCI subsystem ID is %04x:%04x\n",
-			       btv->nr,cards[type].name,cards[type].cardnr,
+			       btv->c.nr,cards[type].name,cards[type].cardnr,
 			       btv->cardid & 0xffff,
 			       (btv->cardid >> 16) & 0xffff);
-			btv->type = cards[type].cardnr;
+			btv->c.type = cards[type].cardnr;
 		} else {
 			/* 404 */
 			printk(KERN_INFO "bttv%d: subsystem: %04x:%04x (UNKNOWN)\n",
-			       btv->nr, btv->cardid & 0xffff,
+			       btv->c.nr, btv->cardid & 0xffff,
 			       (btv->cardid >> 16) & 0xffff);
 			printk(KERN_DEBUG "please mail id, board name and "
 			       "the correct card= insmod option to kraxel@bytesex.org\n");
@@ -1898,13 +2009,13 @@ void __devinit bttv_idcard(struct bttv *
 	} 
 
 	/* let the user override the autodetected type */
-	if (card[btv->nr] < bttv_num_tvcards)
-		btv->type=card[btv->nr];
+	if (card[btv->c.nr] < bttv_num_tvcards)
+		btv->c.type=card[btv->c.nr];
 	
 	/* print which card config we are using */
-	printk(KERN_INFO "bttv%d: using: %s [card=%d,%s]\n",btv->nr,
-	       bttv_tvcards[btv->type].name, btv->type,
-	       card[btv->nr] < bttv_num_tvcards
+	printk(KERN_INFO "bttv%d: using: %s [card=%d,%s]\n",btv->c.nr,
+	       bttv_tvcards[btv->c.type].name, btv->c.type,
+	       card[btv->c.nr] < bttv_num_tvcards
 	       ? "insmod option" : "autodetected");
 
 	/* overwrite gpio stuff ?? */
@@ -1914,20 +2025,20 @@ void __devinit bttv_idcard(struct bttv *
 	if (UNSET != audiomux[0]) {
 		gpiobits = 0;
 		for (i = 0; i < 5; i++) {
-			bttv_tvcards[btv->type].audiomux[i] = audiomux[i];
+			bttv_tvcards[btv->c.type].audiomux[i] = audiomux[i];
 			gpiobits |= audiomux[i];
 		}
 	} else {
 		gpiobits = audioall;
 		for (i = 0; i < 5; i++) {
-			bttv_tvcards[btv->type].audiomux[i] = audioall;
+			bttv_tvcards[btv->c.type].audiomux[i] = audioall;
 		}
 	}
-	bttv_tvcards[btv->type].gpiomask = (UNSET != gpiomask) ? gpiomask : gpiobits;
+	bttv_tvcards[btv->c.type].gpiomask = (UNSET != gpiomask) ? gpiomask : gpiobits;
 	printk(KERN_INFO "bttv%d: gpio config override: mask=0x%x, mux=",
-	       btv->nr,bttv_tvcards[btv->type].gpiomask);
+	       btv->c.nr,bttv_tvcards[btv->c.type].gpiomask);
 	for (i = 0; i < 5; i++) {
-		printk("%s0x%x", i ? "," : "", bttv_tvcards[btv->type].audiomux[i]);
+		printk("%s0x%x", i ? "," : "", bttv_tvcards[btv->c.type].audiomux[i]);
 	}
 	printk("\n");
 }
@@ -1941,7 +2052,7 @@ void identify_by_eeprom(struct bttv *btv
 {
 	int type = -1;
 	
-	if (0 == strncmp(eeprom_data,"GET.MM20xPCTV",13))
+	if (0 == strncmp(eeprom_data,"GET MM20xPCTV",13))
 		type = BTTV_MODTEC_205;
 	else if (0 == strncmp(eeprom_data+20,"Picolo",7))
 		type = BTTV_EURESYS_PICOLO;
@@ -1949,22 +2060,22 @@ void identify_by_eeprom(struct bttv *btv
                 type = BTTV_HAUPPAUGE; /* old bt848 */
 
 	if (-1 != type) {
-		btv->type = type;
+		btv->c.type = type;
 		printk("bttv%d: detected by eeprom: %s [card=%d]\n",
-		       btv->nr, bttv_tvcards[btv->type].name, btv->type);
+		       btv->c.nr, bttv_tvcards[btv->c.type].name, btv->c.type);
 	}
 }
 
 static void flyvideo_gpio(struct bttv *btv)
 { 
-	int gpio,outbits,has_remote,has_radio,is_capture_only,is_lr90,has_tda9820_tda9821;
+	int gpio,has_remote,has_radio,is_capture_only,is_lr90,has_tda9820_tda9821;
 	int tuner=-1,ttype;
-	
-	outbits = btread(BT848_GPIO_OUT_EN);
-	btwrite(0x00, BT848_GPIO_OUT_EN);
+
+	gpio_inout(0xffffff, 0);
 	udelay(8);  // without this we would see the 0x1800 mask
-	gpio=btread(BT848_GPIO_DATA);
-	btwrite(outbits, BT848_GPIO_OUT_EN);
+	gpio = gpio_read();
+	/* FIXME: must restore OUR_EN ??? */
+
 	// all cards provide GPIO info, some have an additional eeprom
 	// LR50: GPIO coding can be found lower right CP1 .. CP9
 	//       CP9=GPIO23 .. CP1=GPIO15; when OPEN, the corresponding GPIO reads 1.
@@ -1989,7 +2100,7 @@ static void flyvideo_gpio(struct bttv *b
 	case 0xC: tuner=3; // Philips SECAM(+PAL) FQ1216ME or FI1216MF
 		break;
 	default:
-		printk(KERN_INFO "bttv%d: FlyVideo_gpio: unknown tuner type.\n", btv->nr);
+		printk(KERN_INFO "bttv%d: FlyVideo_gpio: unknown tuner type.\n", btv->c.nr);
 	}
 
 	has_remote          =   gpio & 0x800000;
@@ -2005,9 +2116,9 @@ static void flyvideo_gpio(struct bttv *b
 		tuner=4; // No tuner present 
 
 	printk(KERN_INFO "bttv%d: FlyVideo Radio=%s RemoteControl=%s Tuner=%d gpio=0x%06x\n", 
-	       btv->nr, has_radio? "yes":"no ", has_remote? "yes":"no ", tuner, gpio); 
+	       btv->c.nr, has_radio? "yes":"no ", has_remote? "yes":"no ", tuner, gpio); 
 	printk(KERN_INFO "bttv%d: FlyVideo  LR90=%s tda9821/tda9820=%s capture_only=%s\n",
-		btv->nr, is_lr90?"yes":"no ", has_tda9820_tda9821?"yes":"no ", 
+		btv->c.nr, is_lr90?"yes":"no ", has_tda9820_tda9821?"yes":"no ", 
 		is_capture_only?"yes":"no ");
 
 	if(tuner!= -1) // only set if known tuner autodetected, else let insmod option through
@@ -2031,8 +2142,8 @@ static void miro_pinnacle_gpio(struct bt
 	int id,msp,gpio;
 	char *info;
 
-	btwrite(0,BT848_GPIO_OUT_EN);
-        gpio = btread(BT848_GPIO_DATA);
+	gpio_inout(0xffffff, 0);
+        gpio = gpio_read();
 	id   = ((gpio>>10) & 63) -1;
 	msp  = bttv_I2CRead(btv, I2C_MSP3400, "MSP34xx");
 	if (id < 32) {
@@ -2051,14 +2162,14 @@ static void miro_pinnacle_gpio(struct bt
 			btv->has_radio = 0;
 		}
 		if (-1 != msp) {
-			if (btv->type == BTTV_MIRO)
-				btv->type = BTTV_MIROPRO;
-			if (btv->type == BTTV_PINNACLE)
-				btv->type = BTTV_PINNACLEPRO;
+			if (btv->c.type == BTTV_MIRO)
+				btv->c.type = BTTV_MIROPRO;
+			if (btv->c.type == BTTV_PINNACLE)
+				btv->c.type = BTTV_PINNACLEPRO;
 		}
 		printk(KERN_INFO
 		       "bttv%d: miro: id=%d tuner=%d radio=%s stereo=%s\n",
-		       btv->nr, id+1, btv->tuner_type,
+		       btv->c.nr, id+1, btv->tuner_type,
 		       !btv->has_radio ? "no" :
 		       (btv->has_matchbox ? "matchbox" : "fmtuner"),
 		       (-1 == msp) ? "no" : "yes");
@@ -2087,15 +2198,18 @@ static void miro_pinnacle_gpio(struct bt
 		case 6:
 			info = "NTSC / stereo";
 			break;
+		case 7:
+			info = "PAL / stereo";
+			break;
 		default:
 			info = "oops: unknown card";
 			break;
 		}
 		if (-1 != msp)
-			btv->type = BTTV_PINNACLEPRO;
+			btv->c.type = BTTV_PINNACLEPRO;
 		printk(KERN_INFO
 		       "bttv%d: pinnacle/mt: id=%d info=\"%s\" radio=%s\n",
-		       btv->nr, id, info, btv->has_radio ? "yes" : "no");
+		       btv->c.nr, id, info, btv->has_radio ? "yes" : "no");
 		btv->tuner_type  = 33;
 		btv->pinnacle_id = id;
 	}
@@ -2106,16 +2220,14 @@ static void miro_pinnacle_gpio(struct bt
 
 static void init_ids_eagle(struct bttv *btv)
 {
-	btwrite(0xFFFF37, BT848_GPIO_OUT_EN);
-	btwrite(0x000000, BT848_GPIO_REG_INP);
-	
-	btwrite(0x200020, BT848_GPIO_DATA);
+	gpio_inout(0xffffff,0xFFFF37);
+	gpio_write(0x200020);
 	
 	/* flash strobe inverter ?! */
-	btwrite(0x200024, BT848_GPIO_DATA);
+	gpio_write(0x200024);
 	
 	/* switch sync drive off */
-	btor(LM1882_SYNC_DRIVE, BT848_GPIO_DATA);
+	gpio_bits(LM1882_SYNC_DRIVE,LM1882_SYNC_DRIVE);
 	
 	/* set BT848 muxel to 2 */
 	btaor((2)<<5, ~(2<<5), BT848_IFORM);
@@ -2127,8 +2239,7 @@ static void init_ids_eagle(struct bttv *
 static void eagle_muxsel(struct bttv *btv, unsigned int input)
 {
 	btaor((2)<<5, ~(3<<5), BT848_IFORM);
-	btaor((bttv_tvcards[btv->type].muxsel[input&7]&3),
-	      ~3, BT848_GPIO_DATA);
+	gpio_bits(3,bttv_tvcards[btv->c.type].muxsel[input&7]);
 
 #if 0
        /* svhs */
@@ -2147,9 +2258,37 @@ static void eagle_muxsel(struct bttv *bt
 #endif
 
        /* switch sync drive off */
-       btor(LM1882_SYNC_DRIVE, BT848_GPIO_DATA);
+       gpio_bits(LM1882_SYNC_DRIVE,LM1882_SYNC_DRIVE);
+}
+
+static void gvc1100_muxsel(struct bttv *btv, unsigned int input)
+{
+        static const int masks[] = {0x30, 0x01, 0x12, 0x23};
+	gpio_write(masks[input%4]);
 }
 
+/* LMLBT4x initialization - to allow access to GPIO bits for sensors input and
+   alarms output
+
+   GPIObit    | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
+   assignment | TI | O3|INx| O2| O1|IN4|IN3|IN2|IN1|   |   |
+
+   IN - sensor inputs, INx - sensor inputs and TI XORed together
+   O1,O2,O3 - alarm outputs (relays)
+
+   OUT ENABLE   1    1   0  . 1  1   0   0 . 0   0   0    0   = 0x6C0
+
+*/
+
+static void init_lmlbt4x(struct bttv *btv)
+{
+	printk(KERN_DEBUG "LMLBT4x init\n");
+	btwrite(0x000000, BT848_GPIO_REG_INP);
+	gpio_inout(0xffffff, 0x0006C0);
+	gpio_write(0x000000);
+}
+
+
 /* ----------------------------------------------------------------------- */
 
 void bttv_reset_audio(struct bttv *btv)
@@ -2167,7 +2306,7 @@ void bttv_reset_audio(struct bttv *btv)
 		return;
 	
 	if (bttv_debug)
-		printk("bttv%d: BT878A ARESET\n",btv->nr);
+		printk("bttv%d: BT878A ARESET\n",btv->c.nr);
 	btwrite((1<<7), 0x058);
 	udelay(10);
 	btwrite(     0, 0x058);
@@ -2176,7 +2315,7 @@ void bttv_reset_audio(struct bttv *btv)
 /* initialization part one -- before registering i2c bus */
 void __devinit bttv_init_card1(struct bttv *btv)
 {
-	switch (btv->type) {
+	switch (btv->c.type) {
 	case BTTV_HAUPPAUGE:
 	case BTTV_HAUPPAUGE878:
                 boot_msp34xx(btv,5);
@@ -2198,12 +2337,12 @@ void __devinit bttv_init_card2(struct bt
 {
         btv->tuner_type = -1;
 
-	if (BTTV_UNKNOWN == btv->type) {
+	if (BTTV_UNKNOWN == btv->c.type) {
 		bttv_readee(btv,eeprom_data,0xa0);
 		identify_by_eeprom(btv,eeprom_data);
 	}
 
-	switch (btv->type) {
+	switch (btv->c.type) {
 	case BTTV_MIRO:
 	case BTTV_MIROPRO:
 	case BTTV_PINNACLE:
@@ -2255,7 +2394,7 @@ void __devinit bttv_init_card2(struct bt
 	case BTTV_MAGICTVIEW061:
 		if (btv->cardid == 0x3002144f) {
 			btv->has_radio=1;
-			printk("bttv%d: radio detected by subsystem id (CPH05x)\n",btv->nr);
+			printk("bttv%d: radio detected by subsystem id (CPH05x)\n",btv->c.nr);
 		}
 		break;
        case BTTV_STB2:
@@ -2287,21 +2426,24 @@ void __devinit bttv_init_card2(struct bt
 		bttv_readee(btv,eeprom_data,0xa0);
 		modtec_eeprom(btv);
 		break;
+	case BTTV_LMLBT4:
+		init_lmlbt4x(btv);
+		break;
 	}
 
 	/* pll configuration */
         if (!(btv->id==848 && btv->revision==0x11)) {
 		/* defaults from card list */
-		if (PLL_28 == bttv_tvcards[btv->type].pll) {
+		if (PLL_28 == bttv_tvcards[btv->c.type].pll) {
 			btv->pll.pll_ifreq=28636363;
 			btv->pll.pll_crystal=BT848_IFORM_XT0;
 		}
-		if (PLL_35 == bttv_tvcards[btv->type].pll) {
+		if (PLL_35 == bttv_tvcards[btv->c.type].pll) {
 			btv->pll.pll_ifreq=35468950;
 			btv->pll.pll_crystal=BT848_IFORM_XT1;
 		}
 		/* insmod options can override */
-                switch (pll[btv->nr]) {
+                switch (pll[btv->c.nr]) {
                 case 0: /* none */
 			btv->pll.pll_crystal = 0;
 			btv->pll.pll_ifreq   = 0;
@@ -2324,27 +2466,33 @@ void __devinit bttv_init_card2(struct bt
 	btv->pll.pll_current = -1;
 
 	/* tuner configuration (from card list / autodetect / insmod option) */
- 	if (UNSET != bttv_tvcards[btv->type].tuner_type)
+ 	if (UNSET != bttv_tvcards[btv->c.type].tuner_type)
 		if(UNSET == btv->tuner_type) 
-                	btv->tuner_type = bttv_tvcards[btv->type].tuner_type;
-	if (UNSET != tuner[btv->nr])
-		btv->tuner_type = tuner[btv->nr];
-	printk("bttv%d: using tuner=%d\n",btv->nr,btv->tuner_type);
+                	btv->tuner_type = bttv_tvcards[btv->c.type].tuner_type;
+	if (UNSET != tuner[btv->c.nr])
+		btv->tuner_type = tuner[btv->c.nr];
+	printk("bttv%d: using tuner=%d\n",btv->c.nr,btv->tuner_type);
 	if (btv->pinnacle_id != UNSET)
 		bttv_call_i2c_clients(btv,AUDC_CONFIG_PINNACLE,
 				      &btv->pinnacle_id);
 	if (btv->tuner_type != UNSET)
 		bttv_call_i2c_clients(btv,TUNER_SET_TYPE,&btv->tuner_type);
-	btv->svhs = bttv_tvcards[btv->type].svhs;
-	if (svhs[btv->nr] != UNSET)
-		btv->svhs = svhs[btv->nr];
+	btv->svhs = bttv_tvcards[btv->c.type].svhs;
+	if (svhs[btv->c.nr] != UNSET)
+		btv->svhs = svhs[btv->c.nr];
+	if (remote[btv->c.nr] != UNSET)
+		btv->has_remote = remote[btv->c.nr];
 
-	if (bttv_tvcards[btv->type].has_radio)
+	if (bttv_tvcards[btv->c.type].has_radio)
 		btv->has_radio=1;
-	if (bttv_tvcards[btv->type].audio_hook)
-		btv->audio_hook=bttv_tvcards[btv->type].audio_hook;
+	if (bttv_tvcards[btv->c.type].has_remote)
+		btv->has_remote=1;
+	if (bttv_tvcards[btv->c.type].no_gpioirq)
+		btv->gpioirq=0;
+	if (bttv_tvcards[btv->c.type].audio_hook)
+		btv->audio_hook=bttv_tvcards[btv->c.type].audio_hook;
 
-	if (bttv_tvcards[btv->type].digital_mode == DIGITAL_MODE_CAMERA) {
+	if (bttv_tvcards[btv->c.type].digital_mode == DIGITAL_MODE_CAMERA) {
 		/* detect Bt832 chip for quartzsight digital camera */
 		if ((bttv_I2CRead(btv, I2C_BT832_ALT1, "Bt832") >=0) ||
 		    (bttv_I2CRead(btv, I2C_BT832_ALT2, "Bt832") >=0))
@@ -2352,31 +2500,31 @@ void __devinit bttv_init_card2(struct bt
 	}
 
 	/* try to detect audio/fader chips */
-	if (!bttv_tvcards[btv->type].no_msp34xx &&
+	if (!bttv_tvcards[btv->c.type].no_msp34xx &&
 	    bttv_I2CRead(btv, I2C_MSP3400, "MSP34xx") >=0) {
 		if (autoload)
 			request_module("msp3400");
 	}
 
-	if (bttv_tvcards[btv->type].msp34xx_alt &&
+	if (bttv_tvcards[btv->c.type].msp34xx_alt &&
 	    bttv_I2CRead(btv, I2C_MSP3400_ALT, "MSP34xx (alternate address)") >=0) {
 		if (autoload)
 			request_module("msp3400");
 	}
 
-	if (!bttv_tvcards[btv->type].no_tda9875 &&
+	if (!bttv_tvcards[btv->c.type].no_tda9875 &&
 	    bttv_I2CRead(btv, I2C_TDA9875, "TDA9875") >=0) {
 		if (autoload)
 			request_module("tda9875");
 	}
 
-	if (!bttv_tvcards[btv->type].no_tda7432 && 
+	if (!bttv_tvcards[btv->c.type].no_tda7432 && 
 	    bttv_I2CRead(btv, I2C_TDA7432, "TDA7432") >=0) {
 		if (autoload)
 			request_module("tda7432");
 	}
 
-	if (bttv_tvcards[btv->type].needs_tvaudio) {
+	if (bttv_tvcards[btv->c.type].needs_tvaudio) {
 		if (autoload)
 			request_module("tvaudio");
 	}
@@ -2460,11 +2608,15 @@ static void modtec_eeprom(struct bttv *b
 {
 	if( strncmp(&(eeprom_data[0x1e]),"Temic 4066 FY5",14) ==0) {
 		btv->tuner_type=TUNER_TEMIC_4066FY5_PAL_I;
-		printk("bttv Modtec: Tuner autodetected %s\n",
-		       &eeprom_data[0x1e]);
+		printk("bttv%d: Modtec: Tuner autodetected by eeprom: %s\n",
+		       btv->c.nr,&eeprom_data[0x1e]);
+	} else if (strncmp(&(eeprom_data[0x1e]),"Alps TSBB5",10) ==0) {
+		btv->tuner_type=TUNER_ALPS_TSBB5_PAL_I;
+		printk("bttv%d: Modtec: Tuner autodetected by eeprom: %s\n",
+                       btv->c.nr,&eeprom_data[0x1e]);
 	} else {
-		printk("bttv Modtec: Unknown TunerString:%s\n",
-		       &eeprom_data[0x1e]);
+		printk("bttv%d: Modtec: Unknown TunerString: %s\n",
+		       btv->c.nr,&eeprom_data[0x1e]);
 	}
 }
 
@@ -2474,7 +2626,7 @@ static void __devinit hauppauge_eeprom(s
 
 	if (eeprom_data[0] != 0x84 || eeprom_data[2] != 0)
 		printk(KERN_WARNING "bttv%d: Hauppauge eeprom: invalid\n",
-		       btv->nr);
+		       btv->c.nr);
 
 	/* Block 2 starts after len+3 bytes header */
 	blk2 = eeprom_data[1] + 3;
@@ -2492,7 +2644,7 @@ static void __devinit hauppauge_eeprom(s
 	if (bttv_verbose)
 		printk(KERN_INFO "bttv%d: Hauppauge eeprom: model=%d, "
 		       "tuner=%s (%d), radio=%s\n",
-		       btv->nr, model, hauppauge_tuner[tuner].name,
+		       btv->c.nr, model, hauppauge_tuner[tuner].name,
 		       btv->tuner_type, radio ? "yes" : "no");
 }
 
@@ -2516,7 +2668,7 @@ static int terratec_active_radio_upgrade
 	tea5757_write(btv, 5 * freq + 0x358); // write 0x1ed8
 	if (0x1ed8 == tea5757_read(btv)) {
 		printk("bttv%d: Terratec Active Radio Upgrade found.\n",
-		       btv->nr);
+		       btv->c.nr);
 		btv->has_radio    = 1;
 		btv->has_matchbox = 1;
 	} else {
@@ -2547,36 +2699,35 @@ static int __devinit pvr_altera_load(str
 	u32 n;
   	u8 bits;
 	int i;
- 
-	btwrite(BTTV_ALT_DATA|BTTV_ALT_DCLK|BTTV_ALT_NCONFIG,
-		BT848_GPIO_OUT_EN);
-	btwrite(0,BT848_GPIO_DATA);
+
+	gpio_inout(0xffffff,BTTV_ALT_DATA|BTTV_ALT_DCLK|BTTV_ALT_NCONFIG);
+	gpio_write(0);
 	udelay(PVR_GPIO_DELAY);
 	
-	btwrite(BTTV_ALT_NCONFIG,BT848_GPIO_DATA);
+	gpio_write(BTTV_ALT_NCONFIG);
 	udelay(PVR_GPIO_DELAY);
 
 	for (n = 0; n < microlen; n++) {
 		bits = micro[n];
 		for ( i = 0 ; i < 8 ; i++ ) {
-			btand(~BTTV_ALT_DCLK,BT848_GPIO_DATA);
-			if (bits & 0x01) 
-				btor(BTTV_ALT_DATA,BT848_GPIO_DATA);
+			gpio_bits(BTTV_ALT_DCLK,0);
+			if (bits & 0x01)
+				gpio_bits(BTTV_ALT_DATA,BTTV_ALT_DATA);
 			else 
-				btand(~BTTV_ALT_DATA,BT848_GPIO_DATA);
-			btor(BTTV_ALT_DCLK,BT848_GPIO_DATA);
+				gpio_bits(BTTV_ALT_DATA,0);
+			gpio_bits(BTTV_ALT_DCLK,BTTV_ALT_DCLK);
 			bits >>= 1;
 		}
 	}
-	btand(~BTTV_ALT_DCLK,BT848_GPIO_DATA);
+	gpio_bits(BTTV_ALT_DCLK,0);
 	udelay(PVR_GPIO_DELAY);
 	
 	/* begin Altera init loop (Not necessary,but doesn't hurt) */
 	for (i = 0 ; i < 30 ; i++) {
-		btand(~BTTV_ALT_DCLK,BT848_GPIO_DATA);
-		btor(BTTV_ALT_DCLK,BT848_GPIO_DATA);
+		gpio_bits(BTTV_ALT_DCLK,0);
+		gpio_bits(BTTV_ALT_DCLK,BTTV_ALT_DCLK);
 	}
-	btand(~BTTV_ALT_DCLK,BT848_GPIO_DATA);
+	gpio_bits(BTTV_ALT_DCLK,0);
 	return 0;
 }
 
@@ -2599,15 +2750,15 @@ int __devinit pvr_boot(struct bttv *btv)
 	microlen = mod_firmware_load(firm_altera, (char**) &micro);
 	if (!microlen) {
 		printk(KERN_WARNING "bttv%d: altera firmware not found [%s]\n",
-		       btv->nr, firm_altera);
+		       btv->c.nr, firm_altera);
 		return -1;
 	}
 	
 	printk(KERN_INFO "bttv%d: uploading altera firmware [%s] ...\n",
-	       btv->nr, firm_altera);
+	       btv->c.nr, firm_altera);
 	result = pvr_altera_load(btv, micro, microlen);
 	printk(KERN_INFO "bttv%d: ... upload %s\n",
-	       btv->nr, (result < 0) ? "failed" : "ok");
+	       btv->c.nr, (result < 0) ? "failed" : "ok");
 	vfree(micro);
 	return result;
 }
@@ -2619,15 +2770,15 @@ int __devinit pvr_boot(struct bttv *btv)
         const struct firmware *fw_entry;
 	int rc;
 
-	rc = request_firmware(&fw_entry, "hcwamc.rbf", &btv->dev->dev);
+	rc = request_firmware(&fw_entry, "hcwamc.rbf", &btv->c.pci->dev);
 	if (rc != 0) {
 		printk(KERN_WARNING "bttv%d: no altera firmware [via hotplug]\n",
-		       btv->nr);
+		       btv->c.nr);
                 return rc;
         }
 	rc = pvr_altera_load(btv, fw_entry->data, fw_entry->size);
 	printk(KERN_INFO "bttv%d: altera firmware upload %s\n",
-	       btv->nr, (rc < 0) ? "failed" : "ok");
+	       btv->c.nr, (rc < 0) ? "failed" : "ok");
         release_firmware(fw_entry);
 	return rc;
 }	
@@ -2642,7 +2793,7 @@ static void __devinit osprey_eeprom(stru
        unsigned char *ee = eeprom_data;
        unsigned long serial = 0;
     
-       if (btv->type == 0) {
+       if (btv->c.type == 0) {
                /* this might be an antique... check for MMAC label in eeprom */
                if ((ee[0]=='M') && (ee[1]=='M') && (ee[2]=='A') && (ee[3]=='C')) {
                        unsigned char checksum = 0;
@@ -2650,7 +2801,7 @@ static void __devinit osprey_eeprom(stru
 			       checksum += ee[i];
                        if (checksum != ee[21])
 			       return;
-		       btv->type = BTTV_OSPREY1x0_848;
+		       btv->c.type = BTTV_OSPREY1x0_848;
 		       for (i = 12; i < 21; i++)
 			       serial *= 10, serial += ee[i] - '0';
                }
@@ -2679,49 +2830,49 @@ static void __devinit osprey_eeprom(stru
 
 	       /* 848 based */
 	       case 0x0004:
-		       btv->type = BTTV_OSPREY1x0_848;
+		       btv->c.type = BTTV_OSPREY1x0_848;
 		       break;
 	       case 0x0005:
-		       btv->type = BTTV_OSPREY101_848;
+		       btv->c.type = BTTV_OSPREY101_848;
 		       break;
 		       
                /* 878 based */
 	       case 0x0012:
 	       case 0x0013:
-		       btv->type = BTTV_OSPREY1x0;
+		       btv->c.type = BTTV_OSPREY1x0;
 		       break;
 	       case 0x0014:
 	       case 0x0015:
-		       btv->type = BTTV_OSPREY1x1;
+		       btv->c.type = BTTV_OSPREY1x1;
 		       break;
 	       case 0x0016:
 	       case 0x0017:
 	       case 0x0020:
-		       btv->type = BTTV_OSPREY1x1_SVID;
+		       btv->c.type = BTTV_OSPREY1x1_SVID;
 		       break;
 	       case 0x0018:
 	       case 0x0019:
 	       case 0x001E:
 	       case 0x001F:
-		       btv->type = BTTV_OSPREY2xx;
+		       btv->c.type = BTTV_OSPREY2xx;
 		       break;
 	       case 0x001A:
 	       case 0x001B:
-		       btv->type = BTTV_OSPREY2x0_SVID;
+		       btv->c.type = BTTV_OSPREY2x0_SVID;
 		       break;
 	       case 0x0040:
-		       btv->type = BTTV_OSPREY500;
+		       btv->c.type = BTTV_OSPREY500;
 		       break;
 	       case 0x0050:
 	       case 0x0056:
-		       btv->type = BTTV_OSPREY540;
+		       btv->c.type = BTTV_OSPREY540;
 		       /* bttv_osprey_540_init(btv); */
 		       break;
 	       case 0x0060:
 	       case 0x0070:
-		       btv->type = BTTV_OSPREY2x0;
+		       btv->c.type = BTTV_OSPREY2x0;
 		       //enable output on select control lines
-		       btwrite(0x000303, BT848_GPIO_OUT_EN);
+		       gpio_inout(0xffffff,0x000303);
 		       break;
 	       default:
 		       /* unknown...leave generic, but get serial # */
@@ -2734,7 +2885,7 @@ static void __devinit osprey_eeprom(stru
        }
        
        printk(KERN_INFO "bttv%d: osprey eeprom: card=%d name=%s serial=%ld\n",
-	      btv->nr, btv->type, bttv_tvcards[btv->type].name,serial);
+	      btv->c.nr, btv->c.type, bttv_tvcards[btv->c.type].name,serial);
 }	
 
 /* ----------------------------------------------------------------------- */
@@ -2779,7 +2930,7 @@ static void __devinit avermedia_eeprom(s
 			tuner = tuner_1_table[tuner_format];
 	
 	printk(KERN_INFO "bttv%d: Avermedia eeprom[0x%02x%02x]: tuner=",
-		btv->nr,eeprom_data[0x41],eeprom_data[0x42]);
+		btv->c.nr,eeprom_data[0x41],eeprom_data[0x42]);
 	if(tuner) {
 		btv->tuner_type=tuner;
 		printk("%d",tuner);
@@ -2805,8 +2956,8 @@ void bttv_tda9880_setnorm(struct bttv *b
 		dprintk("bttv_tda9880_setnorm to PAL\n");
 	}
 	// set GPIO according
-	btaor(bttv_tvcards[btv->type].audiomux[btv->audio],
-              ~bttv_tvcards[btv->type].gpiomask, BT848_GPIO_DATA);
+	gpio_bits(bttv_tvcards[btv->c.type].gpiomask,
+		  bttv_tvcards[btv->c.type].audiomux[btv->audio]);
 }
 
 
@@ -2821,23 +2972,23 @@ static void __devinit boot_msp34xx(struc
 {
 	int mask = (1 << pin);
 
-        btaor(mask, ~mask, BT848_GPIO_OUT_EN);
-        btaor(0, ~mask, BT848_GPIO_DATA);
+	gpio_inout(mask,mask);
+	gpio_bits(mask,0);
         udelay(2500);
-        btaor(mask, ~mask, BT848_GPIO_DATA);
+	gpio_bits(mask,mask);
+
 	if (bttv_gpio)
 		bttv_gpio_tracking(btv,"msp34xx");
-
 	if (bttv_verbose)
 		printk(KERN_INFO "bttv%d: Hauppauge/Voodoo msp34xx: reset line "
-		       "init [%d]\n", btv->nr, pin);
+		       "init [%d]\n", btv->c.nr, pin);
 }
 
 static void __devinit boot_bt832(struct bttv *btv)
 {
-	int outbits,databits,resetbit=0;
+	int resetbit=0;
 
-	switch (btv->type) {
+	switch (btv->c.type) {
 	case BTTV_PXELVWPLTVPAK:
 		resetbit = 0x400000;
 		break;
@@ -2851,18 +3002,14 @@ static void __devinit boot_bt832(struct 
 	request_module("bt832");
 	bttv_call_i2c_clients(btv, BT832_HEXDUMP, NULL);
 
-	printk("bttv%d: Reset Bt832 [line=0x%x]\n",btv->nr,resetbit);
-	btwrite(0, BT848_GPIO_DATA);
-	outbits = btread(BT848_GPIO_OUT_EN);
-	databits= btread(BT848_GPIO_DATA);
-	btwrite(resetbit, BT848_GPIO_OUT_EN);
+	printk("bttv%d: Reset Bt832 [line=0x%x]\n",btv->c.nr,resetbit);
+	gpio_write(0);
+	gpio_inout(resetbit, resetbit);
 	udelay(5);
-	btwrite(resetbit, BT848_GPIO_DATA);
+	gpio_bits(resetbit, resetbit);
 	udelay(5);
-	btwrite(0, BT848_GPIO_DATA);
+	gpio_bits(resetbit, 0);
 	udelay(5);
-	btwrite(outbits, BT848_GPIO_OUT_EN);
-	btwrite(databits, BT848_GPIO_DATA);
 
 	// bt832 on pixelview changes from i2c 0x8a to 0x88 after
 	// being reset as above. So we must follow by this:
@@ -2885,13 +3032,13 @@ static void __devinit init_PXC200(struct
 	u32 val;
 	
 	/* Initialise GPIO-connevted stuff */
-	btwrite(1<<13,BT848_GPIO_OUT_EN); /* Reset pin only */
-	btwrite(0,BT848_GPIO_DATA);
+	gpio_bits(0xffffff, (1<<13));
+	gpio_write(0);
 	udelay(3);
-	btwrite(1<<13,BT848_GPIO_DATA);
+	gpio_write(1<<13);
 	/* GPIO inputs are pulled up, so no need to drive 
 	 * reset pin any longer */
-	btwrite(0,BT848_GPIO_OUT_EN);
+	gpio_bits(0xffffff, 0);
 	if (bttv_gpio)
 		bttv_gpio_tracking(btv,"pxc200");
 
@@ -2926,10 +3073,10 @@ static void __devinit init_PXC200(struct
 	 * device same as above for the reset line, but not the same
 	 * value sent to the GPIO-connected stuff
 	 * which one is the good one? */
-	btwrite( (1<<2), BT848_GPIO_OUT_EN); /* only the reset pin */
-	btwrite(0, BT848_GPIO_DATA);
+	gpio_inout(0xffffff,(1<<2));
+	gpio_write(0);
 	udelay(10);
-	btwrite(1<<2, BT848_GPIO_DATA);
+	gpio_write(1<<2);
 
        	for (i = 0; i < ARRAY_SIZE(vals); i++) {
 		tmp=bttv_I2CWrite(btv,0x1E,0,vals[i],1);
@@ -2956,17 +3103,16 @@ static void __devinit init_PXC200(struct
 void bus_low(struct bttv *btv, int bit)
 {
 	if (btv->mbox_ior) {
-		btor(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
-		     BT848_GPIO_DATA);
+		gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
+			  btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
 		udelay(5);
 	}
 
-	btand(~(bit), BT848_GPIO_DATA);
+	gpio_bits(bit,0);
 	udelay(5);
 
 	if (btv->mbox_ior) {
-		btand(~(btv->mbox_iow | btv->mbox_csel),
-		      BT848_GPIO_DATA);
+		gpio_bits(btv->mbox_iow | btv->mbox_csel, 0);
 		udelay(5);
 	}
 }
@@ -2974,17 +3120,16 @@ void bus_low(struct bttv *btv, int bit)
 void bus_high(struct bttv *btv, int bit)
 {
 	if (btv->mbox_ior) {
-		btor(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
-		     BT848_GPIO_DATA);
+		gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
+			  btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
 		udelay(5);
 	}
 
-	btor((bit), BT848_GPIO_DATA);
+	gpio_bits(bit,bit);
 	udelay(5);
 
 	if (btv->mbox_ior) {
-		btand(~(btv->mbox_iow | btv->mbox_csel),
-		      BT848_GPIO_DATA);
+		gpio_bits(btv->mbox_iow | btv->mbox_csel, 0);
 		udelay(5);
 	}
 }
@@ -2992,15 +3137,14 @@ void bus_high(struct bttv *btv, int bit)
 int bus_in(struct bttv *btv, int bit)
 {
 	if (btv->mbox_ior) {
-		btor(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
-		     BT848_GPIO_DATA);
+		gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
+			  btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
 		udelay(5);
 
-		btand(~(btv->mbox_ior | btv->mbox_csel),
-		      BT848_GPIO_DATA);
+		gpio_bits(btv->mbox_iow | btv->mbox_csel, 0);
 		udelay(5);
 	}
-	return btread(BT848_GPIO_DATA) & (bit);
+	return gpio_read() & (bit);
 }
 
 /* TEA5757 register bits */
@@ -3038,12 +3182,11 @@ static int tea5757_read(struct bttv *btv
 	int i;
 	
 	/* better safe than sorry */
-	btaor((btv->mbox_clk | btv->mbox_we),
-	      ~btv->mbox_mask, BT848_GPIO_OUT_EN);
+	gpio_inout(btv->mbox_mask, btv->mbox_clk | btv->mbox_we);
 
 	if (btv->mbox_ior) {
-		btor(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
-		     BT848_GPIO_DATA);
+		gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
+			  btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
 		udelay(5);
 	}
 
@@ -3060,11 +3203,11 @@ static int tea5757_read(struct bttv *btv
 	while (bus_in(btv,btv->mbox_data) && time_before(jiffies, timeout))
 		schedule();
 	if (bus_in(btv,btv->mbox_data)) {
-		printk(KERN_WARNING "bttv%d: tea5757: read timeout\n",btv->nr);
+		printk(KERN_WARNING "bttv%d: tea5757: read timeout\n",btv->c.nr);
 		return -1;
 	}
 
-	dprintk("bttv%d: tea5757:",btv->nr);
+	dprintk("bttv%d: tea5757:",btv->c.nr);
 	for(i = 0; i < 24; i++)
 	{
 		udelay(5);
@@ -3076,7 +3219,7 @@ static int tea5757_read(struct bttv *btv
 		value |= (bus_in(btv,btv->mbox_data) == 0)?0:1;  /* MSB first */
 		dprintk("%c", (bus_in(btv,btv->mbox_most) == 0)?'S':'M');
 	}
-	dprintk("\nbttv%d: tea5757: read 0x%X\n", btv->nr, value);
+	dprintk("\nbttv%d: tea5757: read 0x%X\n", btv->c.nr, value);
 	return value;
 }
 
@@ -3085,18 +3228,17 @@ static int tea5757_write(struct bttv *bt
 	int i;
 	int reg = value;
 	
-	btaor(btv->mbox_clk | btv->mbox_we | btv->mbox_data,
-	      ~btv->mbox_mask, BT848_GPIO_OUT_EN);
+	gpio_inout(btv->mbox_mask, btv->mbox_clk | btv->mbox_we | btv->mbox_data);
 
 	if (btv->mbox_ior) {
-		btor(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
-		     BT848_GPIO_DATA);
+		gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
+			  btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
 		udelay(5);
 	}
 	if (bttv_gpio)
 		bttv_gpio_tracking(btv,"tea5757 write");
 
-	dprintk("bttv%d: tea5757: write 0x%X\n", btv->nr, value);
+	dprintk("bttv%d: tea5757: write 0x%X\n", btv->c.nr, value);
 	bus_low(btv,btv->mbox_clk);
 	bus_high(btv,btv->mbox_we);
 	for(i = 0; i < 25; i++)
@@ -3122,7 +3264,7 @@ void tea5757_set_freq(struct bttv *btv, 
 #if 0
 	/* breaks Miro PCTV */
 	value = tea5757_read(btv);
-	dprintk("bttv%d: tea5757 readback=0x%x\n",btv->nr,value);
+	dprintk("bttv%d: tea5757 readback=0x%x\n",btv->c.nr,value);
 #endif
 }
 
@@ -3148,7 +3290,7 @@ void winview_audio(struct bttv *btv, str
 	/* tens */
 	bits_out |= (PT2254_DBS_IN_10>>(vol/5));
 	bits_out |= PT2254_L_CHANNEL | PT2254_R_CHANNEL;
-	data = btread(BT848_GPIO_DATA);
+	data = gpio_read();
 	data &= ~(WINVIEW_PT2254_CLK| WINVIEW_PT2254_DATA|
 		  WINVIEW_PT2254_STROBE);
 	for (loops = 17; loops >= 0 ; loops--) {
@@ -3156,20 +3298,20 @@ void winview_audio(struct bttv *btv, str
 			data |=  WINVIEW_PT2254_DATA;
 		else
 			data &= ~WINVIEW_PT2254_DATA;
-		btwrite(data, BT848_GPIO_DATA);
+		gpio_write(data);
 		udelay(5);
 		data |= WINVIEW_PT2254_CLK;
-		btwrite(data, BT848_GPIO_DATA);
+		gpio_write(data);
 		udelay(5);
 		data &= ~WINVIEW_PT2254_CLK;
-		btwrite(data, BT848_GPIO_DATA);
+		gpio_write(data);
 	}
 	data |=  WINVIEW_PT2254_STROBE;
 	data &= ~WINVIEW_PT2254_DATA;
-	btwrite(data, BT848_GPIO_DATA);
+	gpio_write(data);
 	udelay(10);                     
 	data &= ~WINVIEW_PT2254_STROBE;
-	btwrite(data, BT848_GPIO_DATA);
+	gpio_write(data);
 }
 
 /* ----------------------------------------------------------------------- */
@@ -3182,7 +3324,7 @@ gvbctv3pci_audio(struct bttv *btv, struc
 	unsigned int con = 0;
 
 	if (set) {
-		btor(0x300, BT848_GPIO_OUT_EN);
+		gpio_inout(0x300, 0x300);
 		if (v->mode & VIDEO_SOUND_LANG1)
 			con = 0x000;
 		if (v->mode & VIDEO_SOUND_LANG2)
@@ -3191,7 +3333,7 @@ gvbctv3pci_audio(struct bttv *btv, struc
 			con = 0x200;
 //		if (v->mode & VIDEO_SOUND_MONO)
 //			con = 0x100;
-		btaor(con, ~0x300, BT848_GPIO_DATA);
+		gpio_bits(0x300, con);
 	} else {
 		v->mode = VIDEO_SOUND_STEREO |
 			  VIDEO_SOUND_LANG1  | VIDEO_SOUND_LANG2;
@@ -3217,12 +3359,12 @@ avermedia_tvphone_audio(struct bttv *btv
 	int val = 0;
 
 	if (set) {
-		if (v->mode & VIDEO_SOUND_LANG1)   /* SAP */
+		if (v->mode & VIDEO_SOUND_LANG2)   /* SAP */
 			val = 0x02;
 		if (v->mode & VIDEO_SOUND_STEREO)
 			val = 0x01;
 		if (val) {
-			btaor(val, ~0x03, BT848_GPIO_DATA);
+			gpio_bits(0x03,val);
 			if (bttv_gpio)
 				bttv_gpio_tracking(btv,"avermedia");
 		}
@@ -3233,13 +3375,33 @@ avermedia_tvphone_audio(struct bttv *btv
 	}
 }
 
+static void
+avermedia_tv_stereo_audio(struct bttv *btv, struct video_audio *v, int set)
+{
+	int val = 0;
+	
+	if (set) {
+		if (v->mode & VIDEO_SOUND_LANG2)   /* SAP */
+			val = 0x01;
+		if (v->mode & VIDEO_SOUND_STEREO)  /* STEREO */
+			val = 0x02;
+		btaor(val, ~0x03, BT848_GPIO_DATA);
+		if (bttv_gpio)
+			bttv_gpio_tracking(btv,"avermedia");
+	} else {
+		v->mode = VIDEO_SOUND_MONO | VIDEO_SOUND_STEREO |
+			VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
+		return;
+	}
+}
+
 /* Lifetec 9415 handling */
 static void
 lt9415_audio(struct bttv *btv, struct video_audio *v, int set)
 {
         int val = 0;
 
-        if (btread(BT848_GPIO_DATA) & 0x4000) {
+        if (gpio_read() & 0x4000) {
 		v->mode = VIDEO_SOUND_MONO;
 		return;
 	}
@@ -3252,7 +3414,7 @@ lt9415_audio(struct bttv *btv, struct vi
                 if ((v->mode & VIDEO_SOUND_LANG1) ||
 		    (v->mode & VIDEO_SOUND_MONO))
 			val = 0;
-                btaor(val, ~0x0880, BT848_GPIO_DATA);
+		gpio_bits(0x0880, val);
                 if (bttv_gpio)
                         bttv_gpio_tracking(btv,"lt9415");
         } else {
@@ -3270,12 +3432,12 @@ terratv_audio(struct bttv *btv, struct v
 	unsigned int con = 0;
 
 	if (set) {
-		btor(0x180000, BT848_GPIO_OUT_EN);
+		gpio_inout(0x180000,0x180000);
 		if (v->mode & VIDEO_SOUND_LANG2)
 			con = 0x080000;
 		if (v->mode & VIDEO_SOUND_STEREO)
 			con = 0x180000;
-		btaor(con, ~0x180000, BT848_GPIO_DATA);
+		gpio_bits(0x180000, con);
 		if (bttv_gpio)
 			bttv_gpio_tracking(btv,"terratv");
 	} else {
@@ -3300,7 +3462,7 @@ winfast2000_audio(struct bttv *btv, stru
 		if (v->mode & VIDEO_SOUND_STEREO)	/* Stereo */
 			val = 0x020000;
 		if (val) {
-			btaor(val, ~0x430000, BT848_GPIO_DATA);
+			gpio_bits(0x430000, val);
 			if (bttv_gpio)
 				bttv_gpio_tracking(btv,"winfast2000");
 		}
@@ -3340,7 +3502,7 @@ pvbt878p9b_audio(struct bttv *btv, struc
 			val = 0x02;
 		}
 		if (val) {
-			btaor(val, ~0x03, BT848_GPIO_DATA);
+			gpio_bits(0x03,val);
 			if (bttv_gpio)
 				bttv_gpio_tracking(btv,"pvbt878p9b");
 		}
@@ -3376,7 +3538,7 @@ fv2000s_audio(struct bttv *btv, struct v
 			val = 0x1080; //-dk-???: 0x0880, 0x0080, 0x1800 ...
 		}
 		if (val != 0xffff) {
-			btaor(val, ~0x1800, BT848_GPIO_DATA);
+			gpio_bits(0x1800, val);
 			if (bttv_gpio)
 				bttv_gpio_tracking(btv,"fv2000s");
 		}
@@ -3405,7 +3567,7 @@ windvr_audio(struct bttv *btv, struct vi
                 if (v->mode & VIDEO_SOUND_STEREO)
                         val = 0;
                 if (val) {
-                        btaor(val, ~0x140000, BT848_GPIO_DATA);
+			gpio_bits(0x140000, val);
                         if (bttv_gpio)
                                 bttv_gpio_tracking(btv,"windvr");
                 }
@@ -3437,7 +3599,7 @@ adtvk503_audio(struct bttv *btv, struct 
 		if (v->mode & VIDEO_SOUND_MONO)
 			con = 0x00060000;
 		if (con != 0xffffff) {
-			btaor(con, ~0x1e0000, BT848_GPIO_DATA);
+			gpio_bits(0x1e0000,con);
 			if (bttv_gpio)
 				bttv_gpio_tracking(btv, "adtvk503");
 		}
@@ -3474,16 +3636,16 @@ adtvk503_audio(struct bttv *btv, struct 
 static void rv605_muxsel(struct bttv *btv, unsigned int input)
 {
 	/* reset all conections */
-	btaor(0x200,~0x200, BT848_GPIO_DATA);
+	gpio_bits(0x200,0x200);
 	mdelay(1);
-	btaor(0x000,~0x200, BT848_GPIO_DATA);
+	gpio_bits(0x200,0x000);
 	mdelay(1);
 
 	/* create a new conection */
-	btaor(0x080,~0x480, BT848_GPIO_DATA);
-	btaor(0x480,~0x480, BT848_GPIO_DATA);
+	gpio_bits(0x480,0x080);
+	gpio_bits(0x480,0x480);
 	mdelay(1);
-	btaor(0x080,~0x480, BT848_GPIO_DATA);
+	gpio_bits(0x480,0x080);
 	mdelay(1);
 }
 
@@ -3513,7 +3675,7 @@ static void xguard_muxsel(struct bttv *b
                 ENB1, ENB1|IN01, ENB1|IN11, ENB1|IN01|IN11,
                 ENA1, ENA1|IN01, ENA1|IN11, ENA1|IN01|IN11,
 	};
-        btwrite(masks[input%16], BT848_GPIO_DATA);
+	gpio_write(masks[input%16]);
 }
 
 /*
@@ -3555,7 +3717,7 @@ static void ivc120_muxsel(struct bttv *b
 	int matrix = input / 4;
 	
 	dprintk("bttv%d: ivc120_muxsel: Input - %02d | TDA - %02d | In - %02d\n",
-		btv->nr, input, matrix, key);
+		btv->c.nr, input, matrix, key);
 	
 	// Handles the input selection on the TDA8540's
 	bttv_I2CWrite(btv, I2C_TDA8540_ALT3, 0x00,
@@ -3641,12 +3803,12 @@ int __devinit bttv_handle_chipset(struct
 
 	if (bttv_verbose) {
 		if (triton1)
-			printk(KERN_INFO "bttv%d: enabling ETBF (430FX/VP3 compatibilty)\n",btv->nr);
+			printk(KERN_INFO "bttv%d: enabling ETBF (430FX/VP3 compatibilty)\n",btv->c.nr);
 		if (vsfx && btv->id >= 878)
-			printk(KERN_INFO "bttv%d: enabling VSFX\n",btv->nr);
+			printk(KERN_INFO "bttv%d: enabling VSFX\n",btv->c.nr);
 		if (UNSET != latency)
 			printk(KERN_INFO "bttv%d: setting pci timer to %d\n",
-			       btv->nr,latency);
+			       btv->c.nr,latency);
 	}
 
 	if (btv->id < 878) {
@@ -3655,15 +3817,15 @@ int __devinit bttv_handle_chipset(struct
 			btv->triton1 = BT848_INT_ETBF;
 	} else {
 		/* bt878 has a bit in the pci config space for it */
-                pci_read_config_byte(btv->dev, BT878_DEVCTRL, &command);
+                pci_read_config_byte(btv->c.pci, BT878_DEVCTRL, &command);
 		if (triton1)
 			command |= BT878_EN_TBFX;
 		if (vsfx)
 			command |= BT878_EN_VSFX;
-                pci_write_config_byte(btv->dev, BT878_DEVCTRL, command);
+                pci_write_config_byte(btv->c.pci, BT878_DEVCTRL, command);
         }
 	if (UNSET != latency)
-		pci_write_config_byte(btv->dev, PCI_LATENCY_TIMER, latency);
+		pci_write_config_byte(btv->c.pci, PCI_LATENCY_TIMER, latency);
 	return 0;
 }
 
diff -puN drivers/media/video/bttv-driver.c~linus drivers/media/video/bttv-driver.c
--- 25/drivers/media/video/bttv-driver.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/bttv-driver.c	2004-01-19 22:17:22.000000000 -0800
@@ -68,11 +68,12 @@ static unsigned int lumafilter  = 0;
 static unsigned int automute    = 1;
 static unsigned int chroma_agc  = 0;
 static unsigned int adc_crush   = 1;
+static unsigned int whitecrush_upper = 0xCF;
+static unsigned int whitecrush_lower = 0x7F;
 static unsigned int vcr_hack    = 0;
 static unsigned int irq_iswitch = 0;
 
 /* API features (turn on/off stuff for testing) */
-static unsigned int sloppy     = 0;
 static unsigned int v4l2       = 1;
 
 
@@ -108,12 +109,15 @@ MODULE_PARM(chroma_agc,"i");
 MODULE_PARM_DESC(chroma_agc,"enables the AGC of chroma signal, default is 0 (no)");
 MODULE_PARM(adc_crush,"i");
 MODULE_PARM_DESC(adc_crush,"enables the luminance ADC crush, default is 1 (yes)");
+MODULE_PARM(whitecrush_upper,"i");
+MODULE_PARM_DESC(whitecrush_upper,"sets the white crush upper value, default is 207");
+MODULE_PARM(whitecrush_lower,"i");
+MODULE_PARM_DESC(whitecrush_lower,"sets the white crush lower value, default is 127");
 MODULE_PARM(vcr_hack,"i");
 MODULE_PARM_DESC(vcr_hack,"enables the VCR hack (improves synch on poor VCR tapes), default is 0 (no)");
 MODULE_PARM(irq_iswitch,"i");
 MODULE_PARM_DESC(irq_iswitch,"switch inputs in irq handler");
 
-MODULE_PARM(sloppy,"i");
 MODULE_PARM(v4l2,"i");
 
 MODULE_DESCRIPTION("bttv - v4l/v4l2 driver module for bt848/878 based cards");
@@ -133,7 +137,7 @@ static ssize_t show_card(struct class_de
 {
 	struct video_device *vfd = to_video_device(cd);
 	struct bttv *btv = dev_get_drvdata(vfd->dev);
-	return sprintf(buf, "%d\n", btv ? btv->type : UNSET);
+	return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET);
 }
 static CLASS_DEVICE_ATTR(card, S_IRUGO, show_card, NULL);
 
@@ -479,7 +483,9 @@ const unsigned int BTTV_FORMATS = ARRAY_
 #define V4L2_CID_PRIVATE_LUMAFILTER  (V4L2_CID_PRIVATE_BASE + 3)
 #define V4L2_CID_PRIVATE_AGC_CRUSH   (V4L2_CID_PRIVATE_BASE + 4)
 #define V4L2_CID_PRIVATE_VCR_HACK    (V4L2_CID_PRIVATE_BASE + 5)
-#define V4L2_CID_PRIVATE_LASTP1      (V4L2_CID_PRIVATE_BASE + 6)
+#define V4L2_CID_PRIVATE_WHITECRUSH_UPPER   (V4L2_CID_PRIVATE_BASE + 6)
+#define V4L2_CID_PRIVATE_WHITECRUSH_LOWER   (V4L2_CID_PRIVATE_BASE + 7)
+#define V4L2_CID_PRIVATE_LASTP1      (V4L2_CID_PRIVATE_BASE + 8)
 
 static const struct v4l2_queryctrl no_ctl = {
 	.name  = "42",
@@ -597,7 +603,24 @@ static const struct v4l2_queryctrl bttv_
 		.minimum       = 0,
 		.maximum       = 1,
 		.type          = V4L2_CTRL_TYPE_BOOLEAN,
+	},{
+		.id            = V4L2_CID_PRIVATE_WHITECRUSH_UPPER,
+		.name          = "whitecrush upper",
+		.minimum       = 0,
+		.maximum       = 255,
+		.step          = 1,
+		.default_value = 0xCF,
+		.type          = V4L2_CTRL_TYPE_INTEGER,
+	},{
+		.id            = V4L2_CID_PRIVATE_WHITECRUSH_LOWER,
+		.name          = "whitecrush lower",
+		.minimum       = 0,
+		.maximum       = 255,
+		.step          = 1,
+		.default_value = 0x7F,
+		.type          = V4L2_CTRL_TYPE_INTEGER,
 	}
+
 };
 const int BTTV_CTLS = ARRAY_SIZE(bttv_ctls);
 
@@ -695,7 +718,7 @@ static void set_pll(struct bttv *btv)
                 return;
 
 	if (btv->pll.pll_ofreq == btv->pll.pll_current) {
-		dprintk("bttv%d: PLL: no change required\n",btv->nr);
+		dprintk("bttv%d: PLL: no change required\n",btv->c.nr);
                 return;
         }
 
@@ -704,22 +727,22 @@ static void set_pll(struct bttv *btv)
                 if (btv->pll.pll_current == 0)
                         return;
 		vprintk(KERN_INFO "bttv%d: PLL can sleep, using XTAL (%d).\n",
-			btv->nr,btv->pll.pll_ifreq);
+			btv->c.nr,btv->pll.pll_ifreq);
                 btwrite(0x00,BT848_TGCTRL);
                 btwrite(0x00,BT848_PLL_XCI);
                 btv->pll.pll_current = 0;
                 return;
         }
 
-	vprintk(KERN_INFO "bttv%d: PLL: %d => %d ",btv->nr,
+	vprintk(KERN_INFO "bttv%d: PLL: %d => %d ",btv->c.nr,
 		btv->pll.pll_ifreq, btv->pll.pll_ofreq);
 	set_pll_freq(btv, btv->pll.pll_ifreq, btv->pll.pll_ofreq);
 
         for (i=0; i<10; i++) {
 		/*  Let other people run while the PLL stabilizes */
 		vprintk(".");
-		current->state = TASK_INTERRUPTIBLE;
-		schedule_timeout(HZ/10);
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(HZ/50);
 		
                 if (btread(BT848_DSTATUS) & BT848_DSTATUS_PLOCK) {
 			btwrite(0,BT848_DSTATUS);
@@ -742,9 +765,9 @@ void bt848A_set_timing(struct bttv *btv)
 	int table_idx = bttv_tvnorms[btv->tvnorm].sram;
 	int fsc       = bttv_tvnorms[btv->tvnorm].Fsc;
 
-	if (UNSET == bttv_tvcards[btv->type].muxsel[btv->input]) {
+	if (UNSET == bttv_tvcards[btv->c.type].muxsel[btv->input]) {
 		dprintk("bttv%d: load digital timing table (table_idx=%d)\n",
-			btv->nr,table_idx);
+			btv->c.nr,table_idx);
 
 		/* timing change...reset timing generator address */
        		btwrite(0x00, BT848_TGCTRL);
@@ -828,13 +851,13 @@ video_mux(struct bttv *btv, unsigned int
 {
 	int mux,mask2;
 
-	if (input >= bttv_tvcards[btv->type].video_inputs)
+	if (input >= bttv_tvcards[btv->c.type].video_inputs)
 		return -EINVAL;
 
         /* needed by RemoteVideo MX */
-	mask2 = bttv_tvcards[btv->type].gpiomask2;
+	mask2 = bttv_tvcards[btv->c.type].gpiomask2;
 	if (mask2)
-		btaor(mask2,~mask2,BT848_GPIO_OUT_EN);
+		gpio_inout(mask2,mask2);
 
 	if (input == btv->svhs)  {
 		btor(BT848_CONTROL_COMP, BT848_E_CONTROL);
@@ -843,14 +866,14 @@ video_mux(struct bttv *btv, unsigned int
 		btand(~BT848_CONTROL_COMP, BT848_E_CONTROL);
 		btand(~BT848_CONTROL_COMP, BT848_O_CONTROL);
 	}
-	mux = bttv_tvcards[btv->type].muxsel[input] & 3;
+	mux = bttv_tvcards[btv->c.type].muxsel[input] & 3;
 	btaor(mux<<5, ~(3<<5), BT848_IFORM);
 	dprintk(KERN_DEBUG "bttv%d: video mux: input=%d mux=%d\n",
-		btv->nr,input,mux);
+		btv->c.nr,input,mux);
 
 	/* card specific hook */
-	if(bttv_tvcards[btv->type].muxsel_hook)
-		bttv_tvcards[btv->type].muxsel_hook (btv, input);
+	if(bttv_tvcards[btv->c.type].muxsel_hook)
+		bttv_tvcards[btv->c.type].muxsel_hook (btv, input);
 	return 0;
 }
 
@@ -863,9 +886,9 @@ static int
 audio_mux(struct bttv *btv, int mode)
 {
 	int val,mux,i2c_mux,signal;
-	
-	btaor(bttv_tvcards[btv->type].gpiomask,
-	      ~bttv_tvcards[btv->type].gpiomask,BT848_GPIO_OUT_EN);
+
+	gpio_inout(bttv_tvcards[btv->c.type].gpiomask,
+		   bttv_tvcards[btv->c.type].gpiomask);
 	signal = btread(BT848_DSTATUS) & BT848_DSTATUS_HLOC;
 
 	switch (mode) {
@@ -887,12 +910,12 @@ audio_mux(struct bttv *btv, int mode)
 		mux = AUDIO_OFF;
 #if 0
 	printk("bttv%d: amux: mode=%d audio=%d signal=%s mux=%d/%d irq=%s\n",
-	       btv->nr, mode, btv->audio, signal ? "yes" : "no",
+	       btv->c.nr, mode, btv->audio, signal ? "yes" : "no",
 	       mux, i2c_mux, in_interrupt() ? "yes" : "no");
 #endif
 
-	val = bttv_tvcards[btv->type].audiomux[mux];
-	btaor(val,~bttv_tvcards[btv->type].gpiomask, BT848_GPIO_DATA);
+	val = bttv_tvcards[btv->c.type].audiomux[mux];
+	gpio_bits(bttv_tvcards[btv->c.type].gpiomask,val);
 	if (bttv_gpio)
 		bttv_gpio_tracking(btv,audio_modes[mux]);
 	if (!in_interrupt())
@@ -909,7 +932,7 @@ i2c_vidiocschan(struct bttv *btv)
 	c.norm    = btv->tvnorm;
 	c.channel = btv->input;
 	bttv_call_i2c_clients(btv,VIDIOCSCHAN,&c);
-	if (btv->type == BTTV_VOODOOTV_FM)
+	if (btv->c.type == BTTV_VOODOOTV_FM)
 		bttv_tda9880_setnorm(btv,c.norm);
 }
 
@@ -932,7 +955,7 @@ set_tvnorm(struct bttv *btv, unsigned in
 	btwrite(1, BT848_VBI_PACK_DEL);
 	bt848A_set_timing(btv);
 
-	switch (btv->type) {
+	switch (btv->c.type) {
 	case BTTV_VOODOOTV_FM:
 		bttv_tda9880_setnorm(btv,norm);
 		break;
@@ -963,16 +986,43 @@ set_input(struct bttv *btv, unsigned int
 	} else {
 		video_mux(btv,input);
 	}
-	audio_mux(btv,(input == bttv_tvcards[btv->type].tuner ?
+	audio_mux(btv,(input == bttv_tvcards[btv->c.type].tuner ?
 		       AUDIO_TUNER : AUDIO_EXTERN));
 	set_tvnorm(btv,btv->tvnorm);
 }
 
+static void init_irqreg(struct bttv *btv)
+{
+	/* clear status */
+	btwrite(0xfffffUL, BT848_INT_STAT);
+
+	if (bttv_tvcards[btv->c.type].no_video) {
+		/* i2c only */
+		btwrite(BT848_INT_I2CDONE,
+			BT848_INT_MASK);
+	} else {
+		/* full video */
+		btwrite((btv->triton1)  |
+			(btv->gpioirq ? BT848_INT_GPINT : 0) |
+			BT848_INT_SCERR |
+			(fdsr ? BT848_INT_FDSR : 0) |
+			BT848_INT_RISCI|BT848_INT_OCERR|BT848_INT_VPRES|
+			BT848_INT_FMTCHG|BT848_INT_HLOCK|
+			BT848_INT_I2CDONE,
+			BT848_INT_MASK);
+	}
+}
+
 static void init_bt848(struct bttv *btv)
 {
 	int val;
 	
-	btwrite(0, BT848_SRESET);
+	if (bttv_tvcards[btv->c.type].no_video) {
+		/* very basic init only */
+		init_irqreg(btv);
+		return;
+	}
+
 	btwrite(0x00, BT848_CAP_CTL);
 	btwrite(BT848_COLOR_CTL_GAMMA, BT848_COLOR_CTL);
 	btwrite(BT848_IFORM_XTAUTO | BT848_IFORM_AUTO, BT848_IFORM);
@@ -995,6 +1045,9 @@ static void init_bt848(struct bttv *btv)
         btwrite(BT848_ADC_RESERVED | (btv->opt_adc_crush ? BT848_ADC_CRUSH : 0),
 		BT848_ADC);
 
+	btwrite(whitecrush_upper, BT848_WC_UP);
+	btwrite(whitecrush_lower, BT848_WC_DOWN);
+
 	if (btv->opt_lumafilter) {
 		btwrite(0, BT848_E_CONTROL);
 		btwrite(0, BT848_O_CONTROL);
@@ -1004,14 +1057,7 @@ static void init_bt848(struct bttv *btv)
 	}
 
         /* interrupt */
-        btwrite(0xfffffUL, BT848_INT_STAT);
-        btwrite((btv->triton1)  |
-                BT848_INT_GPINT |
-                BT848_INT_SCERR |
-                (fdsr ? BT848_INT_FDSR : 0) |
-                BT848_INT_RISCI|BT848_INT_OCERR|BT848_INT_VPRES|
-                BT848_INT_FMTCHG|BT848_INT_HLOCK,
-                BT848_INT_MASK);
+	init_irqreg(btv);
 }
 
 extern void bttv_reinit_bt848(struct bttv *btv)
@@ -1019,7 +1065,7 @@ extern void bttv_reinit_bt848(struct btt
 	unsigned long flags;
 
 	if (bttv_verbose)
-		printk(KERN_INFO "bttv%d: reset, reinitialize\n",btv->nr);
+		printk(KERN_INFO "bttv%d: reset, reinitialize\n",btv->c.nr);
 	spin_lock_irqsave(&btv->s_lock,flags);
 	btv->errors=0;
 	bttv_set_dma(btv,0,0);
@@ -1094,6 +1140,12 @@ static int get_control(struct bttv *btv,
 	case V4L2_CID_PRIVATE_VCR_HACK:
 		c->value = btv->opt_vcr_hack;
 		break;
+	case V4L2_CID_PRIVATE_WHITECRUSH_UPPER:
+		c->value = btv->opt_whitecrush_upper;
+		break;
+	case V4L2_CID_PRIVATE_WHITECRUSH_LOWER:
+		c->value = btv->opt_whitecrush_lower;
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -1182,6 +1234,14 @@ static int set_control(struct bttv *btv,
 	case V4L2_CID_PRIVATE_VCR_HACK:
 		btv->opt_vcr_hack = c->value;
 		break;
+	case V4L2_CID_PRIVATE_WHITECRUSH_UPPER:
+		btv->opt_whitecrush_upper = c->value;
+		btwrite(c->value, BT848_WC_UP);
+		break;
+	case V4L2_CID_PRIVATE_WHITECRUSH_LOWER:
+		btv->opt_whitecrush_lower = c->value;
+		btwrite(c->value, BT848_WC_DOWN);
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -1201,7 +1261,7 @@ void bttv_gpio_tracking(struct bttv *btv
 	outbits = btread(BT848_GPIO_OUT_EN);
 	data    = btread(BT848_GPIO_DATA);
 	printk(KERN_DEBUG "bttv%d: gpio: en=%08x, out=%08x in=%08x [%s]\n",
-	       btv->nr,outbits,data & outbits, data & ~outbits, comment);
+	       btv->c.nr,outbits,data & outbits, data & ~outbits, comment);
 }
 
 void bttv_field_count(struct bttv *btv)
@@ -1325,7 +1385,7 @@ static int bttv_prepare_buffer(struct bt
 	/* alloc risc memory */
 	if (STATE_NEEDS_INIT == buf->vb.state) {
 		redo_dma_risc = 1;
-		if (0 != (rc = videobuf_iolock(btv->dev,&buf->vb,&btv->fbuf)))
+		if (0 != (rc = videobuf_iolock(btv->c.pci,&buf->vb,&btv->fbuf)))
 			goto fail;
 	}
 
@@ -1428,7 +1488,7 @@ int bttv_common_ioctls(struct bttv *btv,
 	{
 		struct video_tuner *v = arg;
 		
-		if (UNSET == bttv_tvcards[btv->type].tuner)
+		if (UNSET == bttv_tvcards[btv->c.type].tuner)
 			return -EINVAL;
 		if (v->tuner) /* Only tuner 0 */
 			return -EINVAL;
@@ -1462,13 +1522,13 @@ int bttv_common_ioctls(struct bttv *btv,
                 struct video_channel *v = arg;
 		unsigned int channel = v->channel;
 
-                if (channel >= bttv_tvcards[btv->type].video_inputs)
+                if (channel >= bttv_tvcards[btv->c.type].video_inputs)
                         return -EINVAL;
                 v->tuners=0;
                 v->flags = VIDEO_VC_AUDIO;
                 v->type = VIDEO_TYPE_CAMERA;
                 v->norm = btv->tvnorm;
-		if (channel == bttv_tvcards[btv->type].tuner)  {
+		if (channel == bttv_tvcards[btv->c.type].tuner)  {
                         strcpy(v->name,"Television");
                         v->flags|=VIDEO_VC_TUNER;
                         v->type=VIDEO_TYPE_TV;
@@ -1485,7 +1545,7 @@ int bttv_common_ioctls(struct bttv *btv,
                 struct video_channel *v = arg;
 		unsigned int channel = v->channel;
 
-		if (channel >= bttv_tvcards[btv->type].video_inputs)
+		if (channel >= bttv_tvcards[btv->c.type].video_inputs)
 			return -EINVAL;
 		if (v->norm >= BTTV_TVNORMS)
 			return -EINVAL;
@@ -1528,7 +1588,7 @@ int bttv_common_ioctls(struct bttv *btv,
 		struct video_audio *v = arg;
 		unsigned int audio = v->audio;
 
-		if (audio >= bttv_tvcards[btv->type].audio_inputs)
+		if (audio >= bttv_tvcards[btv->c.type].audio_inputs)
 			return -EINVAL;
 
 		down(&btv->lock);
@@ -1596,13 +1656,13 @@ int bttv_common_ioctls(struct bttv *btv,
 		unsigned int n;
 		
 		n = i->index;
-		if (n >= bttv_tvcards[btv->type].video_inputs)
+		if (n >= bttv_tvcards[btv->c.type].video_inputs)
 			return -EINVAL;
 		memset(i,0,sizeof(*i));
 		i->index    = n;
 		i->type     = V4L2_INPUT_TYPE_CAMERA;
 		i->audioset = 1;
-		if (i->index == bttv_tvcards[btv->type].tuner) {
+		if (i->index == bttv_tvcards[btv->c.type].tuner) {
 			sprintf(i->name, "Television");
 			i->type  = V4L2_INPUT_TYPE_TUNER;
 			i->tuner = 0;
@@ -1632,7 +1692,7 @@ int bttv_common_ioctls(struct bttv *btv,
 	{
 		unsigned int *i = arg;
 		
-		if (*i > bttv_tvcards[btv->type].video_inputs)
+		if (*i > bttv_tvcards[btv->c.type].video_inputs)
 			return -EINVAL;
 		down(&btv->lock);
 		set_input(btv,*i);
@@ -1645,7 +1705,7 @@ int bttv_common_ioctls(struct bttv *btv,
 	{
 		struct v4l2_tuner *t = arg;
 
-		if (UNSET == bttv_tvcards[btv->type].tuner)
+		if (UNSET == bttv_tvcards[btv->c.type].tuner)
 			return -EINVAL;
 		if (0 != t->index)
 			return -EINVAL;
@@ -1683,7 +1743,7 @@ int bttv_common_ioctls(struct bttv *btv,
 	{
 		struct v4l2_tuner *t = arg;
 
-		if (UNSET == bttv_tvcards[btv->type].tuner)
+		if (UNSET == bttv_tvcards[btv->c.type].tuner)
 			return -EINVAL;
 		if (0 != t->index)
 			return -EINVAL;
@@ -2061,16 +2121,16 @@ static int bttv_do_ioctl(struct inode *i
 		switch (_IOC_TYPE(cmd)) {
 		case 'v':
 			printk("bttv%d: ioctl 0x%x (v4l1, VIDIOC%s)\n",
-			       btv->nr, cmd, (_IOC_NR(cmd) < V4L1_IOCTLS) ?
+			       btv->c.nr, cmd, (_IOC_NR(cmd) < V4L1_IOCTLS) ?
 			       v4l1_ioctls[_IOC_NR(cmd)] : "???");
 			break;
 		case 'V':
 			printk("bttv%d: ioctl 0x%x (v4l2, %s)\n",
-			       btv->nr, cmd,  v4l2_ioctl_names[_IOC_NR(cmd)]);
+			       btv->c.nr, cmd,  v4l2_ioctl_names[_IOC_NR(cmd)]);
 			break;
 		default:
 			printk("bttv%d: ioctl 0x%x (???)\n",
-			       btv->nr, cmd);
+			       btv->c.nr, cmd);
 		}
 	}
 	if (btv->errors)
@@ -2110,8 +2170,8 @@ static int bttv_do_ioctl(struct inode *i
 				VID_TYPE_OVERLAY|
 				VID_TYPE_CLIPPING|
 				VID_TYPE_SCALES;
-			cap->channels  = bttv_tvcards[btv->type].video_inputs;
-			cap->audios    = bttv_tvcards[btv->type].audio_inputs;
+			cap->channels  = bttv_tvcards[btv->c.type].video_inputs;
+			cap->audios    = bttv_tvcards[btv->c.type].audio_inputs;
 			cap->maxwidth  = bttv_tvnorms[btv->tvnorm].swidth;
 			cap->maxheight = bttv_tvnorms[btv->tvnorm].sheight;
 			cap->minwidth  = 48;
@@ -2144,7 +2204,7 @@ static int bttv_do_ioctl(struct inode *i
 		if (NULL == fmt)
 			return -EINVAL;
 		down(&fh->cap.lock);
-		if (fmt->depth != pic->depth && !sloppy) {
+		if (fmt->depth != pic->depth) {
 			retval = -EINVAL;
 			goto fh_unlock_and_return;
 		}
@@ -2228,43 +2288,35 @@ static int bttv_do_ioctl(struct inode *i
 			fbuf->height * fbuf->bytesperline;
 		down(&fh->cap.lock);
 		retval = -EINVAL;
-		if (sloppy) {
-			/* also set the default palette -- for backward
-			   compatibility with older versions */
-			switch (fbuf->depth) {
-			case 8:
-				fmt = format_by_palette(VIDEO_PALETTE_HI240);
-				break;
-			case 16:
-				fmt = format_by_palette(VIDEO_PALETTE_RGB565);
-				break;
-			case 24:
-				fmt = format_by_palette(VIDEO_PALETTE_RGB24);
-				break;
-			case 32:
-				fmt = format_by_palette(VIDEO_PALETTE_RGB32);
-				break;
-			case 15:
-				fbuf->depth = 16;
-				fmt = format_by_palette(VIDEO_PALETTE_RGB555);
-				break;
-			default:
-				fmt = NULL;
-				break;
-			}
-			if (NULL == fmt)
-				goto fh_unlock_and_return;
-			fh->ovfmt = fmt;
-			fh->fmt   = fmt;
-			btv->init.ovfmt = fmt;
-			btv->init.fmt   = fmt;
-		} else {
-			if (15 == fbuf->depth)
-				fbuf->depth = 16;
-			if (fbuf->depth !=  8 && fbuf->depth != 16 &&
-			    fbuf->depth != 24 && fbuf->depth != 32)
-				goto fh_unlock_and_return;
+
+		switch (fbuf->depth) {
+		case 8:
+			fmt = format_by_palette(VIDEO_PALETTE_HI240);
+			break;
+		case 16:
+			fmt = format_by_palette(VIDEO_PALETTE_RGB565);
+			break;
+		case 24:
+			fmt = format_by_palette(VIDEO_PALETTE_RGB24);
+			break;
+		case 32:
+			fmt = format_by_palette(VIDEO_PALETTE_RGB32);
+			break;
+		case 15:
+			fbuf->depth = 16;
+			fmt = format_by_palette(VIDEO_PALETTE_RGB555);
+			break;
+		default:
+			fmt = NULL;
+			break;
 		}
+		if (NULL == fmt)
+			goto fh_unlock_and_return;
+
+		fh->ovfmt = fmt;
+		fh->fmt   = fmt;
+		btv->init.ovfmt = fmt;
+		btv->init.fmt   = fmt;
 		btv->fbuf.base             = fbuf->base;
 		btv->fbuf.fmt.width        = fbuf->width;
 		btv->fbuf.fmt.height       = fbuf->height;
@@ -2287,7 +2339,7 @@ static int bttv_do_ioctl(struct inode *i
 			if (NULL == btv->fbuf.base)
 				return -EINVAL;
 			if (!fh->ov.setup_ok) {
-				dprintk("bttv%d: overlay: !setup_ok\n",btv->nr);
+				dprintk("bttv%d: overlay: !setup_ok\n",btv->c.nr);
 				return -EINVAL;
 			}
 		}
@@ -2383,7 +2435,7 @@ static int bttv_do_ioctl(struct inode *i
 			retval = -EIO;
 			/* fall through */
 		case STATE_DONE:
-			videobuf_dma_pci_sync(btv->dev,&buf->vb.dma);
+			videobuf_dma_pci_sync(btv->c.pci,&buf->vb.dma);
 			bttv_dma_free(btv,buf);
 			break;
 		default:
@@ -2464,7 +2516,7 @@ static int bttv_do_ioctl(struct inode *i
 			return -EINVAL;
                 strcpy(cap->driver,"bttv");
                 strlcpy(cap->card,btv->video_dev->name,sizeof(cap->card));
-		sprintf(cap->bus_info,"PCI:%s",pci_name(btv->dev));
+		sprintf(cap->bus_info,"PCI:%s",pci_name(btv->c.pci));
 		cap->version = BTTV_VERSION_CODE;
 		cap->capabilities =
 			V4L2_CAP_VIDEO_CAPTURE |
@@ -2768,7 +2820,7 @@ static ssize_t bttv_read(struct file *fi
 	if (fh->btv->errors)
 		bttv_reinit_bt848(fh->btv);
 	dprintk("bttv%d: read count=%d type=%s\n",
-		fh->btv->nr,(int)count,v4l2_type_names[fh->type]);
+		fh->btv->c.nr,(int)count,v4l2_type_names[fh->type]);
 
 	switch (fh->type) {
 	case V4L2_BUF_TYPE_VIDEO_CAPTURE:
@@ -2849,12 +2901,14 @@ static int bttv_open(struct inode *inode
 	dprintk(KERN_DEBUG "bttv: open minor=%d\n",minor);
 
 	for (i = 0; i < bttv_num; i++) {
-		if (bttvs[i].video_dev->minor == minor) {
+		if (bttvs[i].video_dev &&
+		    bttvs[i].video_dev->minor == minor) {
 			btv = &bttvs[i];
 			type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 			break;
 		}
-		if (bttvs[i].vbi_dev->minor == minor) {
+		if (bttvs[i].vbi_dev &&
+		    bttvs[i].vbi_dev->minor == minor) {
 			btv = &bttvs[i];
 			type = V4L2_BUF_TYPE_VBI_CAPTURE;
 			break;
@@ -2864,7 +2918,7 @@ static int bttv_open(struct inode *inode
 		return -ENODEV;
 
 	dprintk(KERN_DEBUG "bttv%d: open called (type=%s)\n",
-		btv->nr,v4l2_type_names[type]);
+		btv->c.nr,v4l2_type_names[type]);
 
 	/* allocate per filehandle data */
 	fh = kmalloc(sizeof(*fh),GFP_KERNEL);
@@ -2879,12 +2933,12 @@ static int bttv_open(struct inode *inode
 #endif
 
 	videobuf_queue_init(&fh->cap, &bttv_video_qops,
-			    btv->dev, &btv->s_lock,
+			    btv->c.pci, &btv->s_lock,
 			    V4L2_BUF_TYPE_VIDEO_CAPTURE,
 			    V4L2_FIELD_INTERLACED,
 			    sizeof(struct bttv_buffer));
 	videobuf_queue_init(&fh->vbi, &bttv_vbi_qops,
-			    btv->dev, &btv->s_lock,
+			    btv->c.pci, &btv->s_lock,
 			    V4L2_BUF_TYPE_VBI_CAPTURE,
 			    V4L2_FIELD_SEQ_TB,
 			    sizeof(struct bttv_buffer));
@@ -2942,7 +2996,7 @@ bttv_mmap(struct file *file, struct vm_a
 	struct bttv_fh *fh = file->private_data;
 
 	dprintk("bttv%d: mmap type=%s 0x%lx+%ld\n",
-		fh->btv->nr, v4l2_type_names[fh->type],
+		fh->btv->c.nr, v4l2_type_names[fh->type],
 		vma->vm_start, vma->vm_end - vma->vm_start);
 	return videobuf_mmap_mapper(vma,bttv_queue(fh));
 }
@@ -2998,7 +3052,7 @@ static int radio_open(struct inode *inod
 	if (NULL == btv)
 		return -ENODEV;
 
-	dprintk("bttv%d: open called (radio)\n",btv->nr);
+	dprintk("bttv%d: open called (radio)\n",btv->c.nr);
 	down(&btv->lock);
 	if (btv->radio_user) {
 		up(&btv->lock);
@@ -3196,7 +3250,7 @@ bttv_irq_next_set(struct bttv *btv, stru
 
 	dprintk("bttv%d: next set: top=%p bottom=%p vbi=%p "
 		"[screen=%p,irq=%d,%d]\n",
-		btv->nr,set->top, set->bottom, set->vbi,
+		btv->c.nr,set->top, set->bottom, set->vbi,
 		btv->screen,set->irqflags,set->topirq);
 	return 0;
 }
@@ -3218,7 +3272,7 @@ bttv_irq_wakeup_set(struct bttv *btv, st
 	if (wakeup->top == wakeup->bottom) {
 		if (NULL != wakeup->top && curr->top != wakeup->top) {
 			if (irq_debug > 1)
-				printk("bttv%d: wakeup: both=%p\n",btv->nr,wakeup->top);
+				printk("bttv%d: wakeup: both=%p\n",btv->c.nr,wakeup->top);
 			wakeup->top->vb.ts = ts;
 			wakeup->top->vb.field_count = btv->field_count;
 			wakeup->top->vb.state = state;
@@ -3227,7 +3281,7 @@ bttv_irq_wakeup_set(struct bttv *btv, st
 	} else {
 		if (NULL != wakeup->top && curr->top != wakeup->top) {
 			if (irq_debug > 1)
-				printk("bttv%d: wakeup: top=%p\n",btv->nr,wakeup->top);
+				printk("bttv%d: wakeup: top=%p\n",btv->c.nr,wakeup->top);
 			wakeup->top->vb.ts = ts;
 			wakeup->top->vb.field_count = btv->field_count;
 			wakeup->top->vb.state = state;
@@ -3235,7 +3289,7 @@ bttv_irq_wakeup_set(struct bttv *btv, st
 		}
 		if (NULL != wakeup->bottom && curr->bottom != wakeup->bottom) {
 			if (irq_debug > 1)
-				printk("bttv%d: wakeup: bottom=%p\n",btv->nr,wakeup->bottom);
+				printk("bttv%d: wakeup: bottom=%p\n",btv->c.nr,wakeup->bottom);
 			wakeup->bottom->vb.ts = ts;
 			wakeup->bottom->vb.field_count = btv->field_count;
 			wakeup->bottom->vb.state = state;
@@ -3249,15 +3303,17 @@ static void bttv_irq_timeout(unsigned lo
 	struct bttv *btv = (struct bttv *)data;
 	struct bttv_buffer_set old,new;
 	struct bttv_buffer *item;
+	unsigned long flags;
 	
 	if (bttv_verbose) {
-		printk(KERN_INFO "bttv%d: timeout: risc=%08x, ",
-		       btv->nr,btread(BT848_RISC_COUNT));
+		printk(KERN_INFO "bttv%d: timeout: irq=%d/%d, risc=%08x, ",
+		       btv->c.nr, btv->irq_me, btv->irq_total,
+		       btread(BT848_RISC_COUNT));
 		bttv_print_irqbits(btread(BT848_INT_STAT),0);
 		printk("\n");
 	}
 
-	spin_lock(&btv->s_lock);
+	spin_lock_irqsave(&btv->s_lock,flags);
 	
 	/* deactivate stuff */
 	memset(&new,0,sizeof(new));
@@ -3284,7 +3340,7 @@ static void bttv_irq_timeout(unsigned lo
 	}
 	
 	btv->errors++;
-	spin_unlock(&btv->s_lock);	
+	spin_unlock_irqrestore(&btv->s_lock,flags);
 }
 
 static void
@@ -3321,8 +3377,13 @@ bttv_irq_switch_fields(struct bttv *btv)
 	rc = btread(BT848_RISC_COUNT);
 	if (rc < btv->main.dma || rc > btv->main.dma + 0x100) {
 		if (1 /* irq_debug */)
-			printk("bttv%d: skipped frame. no signal? high irq latency?\n",
-			       btv->nr);
+			printk("bttv%d: skipped frame. no signal? high irq latency? "
+			       "[main=%lx,o_vbi=%lx,o_field=%lx,rc=%lx]\n",
+			       btv->c.nr,
+			       (unsigned long)btv->main.dma,
+			       (unsigned long)btv->main.cpu[RISC_SLOT_O_VBI+1],
+			       (unsigned long)btv->main.cpu[RISC_SLOT_O_FIELD+1],
+			       (unsigned long)rc);
 		spin_unlock(&btv->s_lock);
 		return;
 	}
@@ -3369,7 +3430,7 @@ static irqreturn_t bttv_irq(int irq, voi
 		if (irq_debug) {
 			printk(KERN_DEBUG "bttv%d: irq loop=%d fc=%d "
 			       "riscs=%x, riscc=%08x, ",
-			       btv->nr, count, btv->field_count,
+			       btv->c.nr, count, btv->field_count,
 			       stat>>28, btread(BT848_RISC_COUNT));
 			bttv_print_irqbits(stat,astat);
 			if (stat & BT848_INT_HLOCK)
@@ -3388,11 +3449,13 @@ static irqreturn_t bttv_irq(int irq, voi
                         btv->field_count++;
 
 		if (astat & BT848_INT_GPINT) {
-#ifdef CONFIG_VIDEO_IR
-			if (btv->remote)
-				bttv_input_irq(btv);
-#endif
 			wake_up(&btv->gpioq);
+			bttv_gpio_irq(&btv->c);
+		}
+
+		if (astat & BT848_INT_I2CDONE) {
+			btv->i2c_done = stat;
+			wake_up(&btv->i2c_queue);
 		}
 
                 if ((astat & BT848_INT_RISCI)  &&  (stat & (2<<28)))
@@ -3405,7 +3468,7 @@ static irqreturn_t bttv_irq(int irq, voi
 			audio_mux(btv, -1);
 
 		if (astat & (BT848_INT_SCERR|BT848_INT_OCERR)) {
-			printk(KERN_INFO "bttv%d: %s%s @ %08x,",btv->nr,
+			printk(KERN_INFO "bttv%d: %s%s @ %08x,",btv->c.nr,
 			       (astat & BT848_INT_SCERR) ? "SCERR" : "",
 			       (astat & BT848_INT_OCERR) ? "OCERR" : "",
 			       btread(BT848_RISC_COUNT));
@@ -3416,7 +3479,7 @@ static irqreturn_t bttv_irq(int irq, voi
 		}
 		if (fdsr && astat & BT848_INT_FDSR) {
 			printk(KERN_INFO "bttv%d: FDSR @ %08x\n",
-			       btv->nr,btread(BT848_RISC_COUNT));
+			       btv->c.nr,btread(BT848_RISC_COUNT));
 			if (bttv_debug)
 				bttv_print_riscaddr(btv);
 		}
@@ -3425,11 +3488,14 @@ static irqreturn_t bttv_irq(int irq, voi
 		if (count > 4) {
 			btwrite(0, BT848_INT_MASK);
 			printk(KERN_ERR 
-			       "bttv%d: IRQ lockup, cleared int mask [", btv->nr);
+			       "bttv%d: IRQ lockup, cleared int mask [", btv->c.nr);
 			bttv_print_irqbits(stat,astat);
 			printk("]\n");
 		}
 	}
+	btv->irq_total++;
+	if (handled)
+		btv->irq_me++;
 	return IRQ_RETVAL(handled);
 }
 
@@ -3448,11 +3514,11 @@ static struct video_device *vdev_init(st
 		return NULL;
 	*vfd = *template;
 	vfd->minor   = -1;
-	vfd->dev     = &btv->dev->dev;
+	vfd->dev     = &btv->c.pci->dev;
 	vfd->release = video_device_release;
 	snprintf(vfd->name, sizeof(vfd->name), "BT%d%s %s (%s)",
 		 btv->id, (btv->id==848 && btv->revision==0x12) ? "A" : "",
-		 type, bttv_tvcards[btv->type].name);
+		 type, bttv_tvcards[btv->c.type].name);
 	return vfd;
 }
 
@@ -3491,7 +3557,7 @@ static int __devinit bttv_register_video
 	if (video_register_device(btv->video_dev,VFL_TYPE_GRABBER,video_nr)<0)
 		goto err;
 	printk(KERN_INFO "bttv%d: registered device video%d\n",
-	       btv->nr,btv->video_dev->minor & 0x1f);
+	       btv->c.nr,btv->video_dev->minor & 0x1f);
 	video_device_create_file(btv->video_dev, &class_device_attr_card);
 
 	/* vbi */
@@ -3501,7 +3567,7 @@ static int __devinit bttv_register_video
         if (video_register_device(btv->vbi_dev,VFL_TYPE_VBI,vbi_nr)<0)
 		goto err;
 	printk(KERN_INFO "bttv%d: registered device vbi%d\n",
-	       btv->nr,btv->vbi_dev->minor & 0x1f);
+	       btv->c.nr,btv->vbi_dev->minor & 0x1f);
 
         if (!btv->has_radio)
 		return 0;
@@ -3512,7 +3578,7 @@ static int __devinit bttv_register_video
 	if (video_register_device(btv->radio_dev, VFL_TYPE_RADIO,radio_nr)<0)
 		goto err;
 	printk(KERN_INFO "bttv%d: registered device radio%d\n",
-	       btv->nr,btv->radio_dev->minor & 0x1f);
+	       btv->c.nr,btv->radio_dev->minor & 0x1f);
 
 	/* all done */
 	return 0;
@@ -3548,14 +3614,17 @@ static int __devinit bttv_probe(struct p
 	printk(KERN_INFO "bttv: Bt8xx card found (%d).\n", bttv_num);
         btv=&bttvs[bttv_num];
 	memset(btv,0,sizeof(*btv));
-	btv->nr  = bttv_num;
-	sprintf(btv->name,"bttv%d",btv->nr);
+	btv->c.nr  = bttv_num;
+	sprintf(btv->c.name,"bttv%d",btv->c.nr);
 
 	/* initialize structs / fill in defaults */
         init_MUTEX(&btv->lock);
         init_MUTEX(&btv->reslock);
-        btv->s_lock = SPIN_LOCK_UNLOCKED;
+        btv->s_lock    = SPIN_LOCK_UNLOCKED;
+        btv->gpio_lock = SPIN_LOCK_UNLOCKED;
         init_waitqueue_head(&btv->gpioq);
+        init_waitqueue_head(&btv->i2c_queue);
+        INIT_LIST_HEAD(&btv->c.subs);
         INIT_LIST_HEAD(&btv->capture);
         INIT_LIST_HEAD(&btv->vcapture);
 #ifdef VIDIOC_G_PRIORITY
@@ -3570,33 +3639,34 @@ static int __devinit bttv_probe(struct p
         btv->tuner_type  = UNSET;
         btv->pinnacle_id = UNSET;
 	btv->new_input   = UNSET;
-	btv->has_radio=radio[btv->nr];
+	btv->gpioirq     = 1;
+	btv->has_radio=radio[btv->c.nr];
 	
 	/* pci stuff (init, get irq/mmio, ... */
-	btv->dev = dev;
+	btv->c.pci = dev;
         btv->id  = dev->device;
 	if (pci_enable_device(dev)) {
                 printk(KERN_WARNING "bttv%d: Can't enable device.\n",
-		       btv->nr);
+		       btv->c.nr);
 		return -EIO;
 	}
         if (pci_set_dma_mask(dev, 0xffffffff)) {
                 printk(KERN_WARNING "bttv%d: No suitable DMA available.\n",
-		       btv->nr);
+		       btv->c.nr);
 		return -EIO;
         }
 	if (!request_mem_region(pci_resource_start(dev,0),
 				pci_resource_len(dev,0),
-				btv->name)) {
+				btv->c.name)) {
                 printk(KERN_WARNING "bttv%d: can't request iomem (0x%lx).\n",
-		       btv->nr, pci_resource_start(dev,0));
+		       btv->c.nr, pci_resource_start(dev,0));
 		return -EBUSY;
 	}
         pci_set_master(dev);
 	pci_set_command(dev);
 	pci_set_drvdata(dev,btv);
 	if (!pci_dma_supported(dev,0xffffffff)) {
-		printk("bttv%d: Oops: no 32bit PCI DMA ???\n", btv->nr);
+		printk("bttv%d: Oops: no 32bit PCI DMA ???\n", btv->c.nr);
 		result = -EIO;
 		goto fail1;
 	}
@@ -3606,12 +3676,12 @@ static int __devinit bttv_probe(struct p
         printk(KERN_INFO "bttv%d: Bt%d (rev %d) at %s, ",
                bttv_num,btv->id, btv->revision, pci_name(dev));
         printk("irq: %d, latency: %d, mmio: 0x%lx\n",
-	       btv->dev->irq, lat, pci_resource_start(dev,0));
+	       btv->c.pci->irq, lat, pci_resource_start(dev,0));
 	schedule();
 	
 	btv->bt848_mmio=ioremap(pci_resource_start(dev,0), 0x1000);
 	if (NULL == ioremap(pci_resource_start(dev,0), 0x1000)) {
-		printk("bttv%d: ioremap() failed\n", btv->nr);
+		printk("bttv%d: ioremap() failed\n", btv->c.nr);
 		result = -EIO;
 		goto fail1;
 	}
@@ -3621,11 +3691,11 @@ static int __devinit bttv_probe(struct p
 
         /* disable irqs, register irq handler */
 	btwrite(0, BT848_INT_MASK);
-        result = request_irq(btv->dev->irq, bttv_irq,
-                             SA_SHIRQ | SA_INTERRUPT,btv->name,(void *)btv);
+        result = request_irq(btv->c.pci->irq, bttv_irq,
+                             SA_SHIRQ | SA_INTERRUPT,btv->c.name,(void *)btv);
         if (result < 0) {
                 printk(KERN_ERR "bttv%d: can't get IRQ %d\n",
-		       bttv_num,btv->dev->irq);
+		       bttv_num,btv->c.pci->irq);
 		goto fail1;
         }
 
@@ -3641,6 +3711,8 @@ static int __devinit bttv_probe(struct p
 	btv->opt_chroma_agc = chroma_agc;
 	btv->opt_adc_crush  = adc_crush;
 	btv->opt_vcr_hack   = vcr_hack;
+	btv->opt_whitecrush_upper  = whitecrush_upper;
+	btv->opt_whitecrush_lower  = whitecrush_lower;
 	
 	/* fill struct bttv with some useful defaults */
 	btv->init.btv         = btv;
@@ -3657,31 +3729,27 @@ static int __devinit bttv_probe(struct p
                 bttv_gpio_tracking(btv,"pre-init");
 
 	bttv_risc_init_main(btv);
-	if (!bttv_tvcards[btv->type].no_video)
-		init_bt848(btv);
+	init_bt848(btv);
 
 	/* gpio */
         btwrite(0x00, BT848_GPIO_REG_INP);
         btwrite(0x00, BT848_GPIO_OUT_EN);
-        if (bttv_gpio)
+        if (bttv_verbose)
                 bttv_gpio_tracking(btv,"init");
 
         /* needs to be done before i2c is registered */
         bttv_init_card1(btv);
 
-        /* register i2c */
+        /* register i2c + gpio */
         init_bttv_i2c(btv);
 
         /* some card-specific stuff (needs working i2c) */
         bttv_init_card2(btv);
+	init_irqreg(btv);
 
         /* register video4linux + input */
-	if (!bttv_tvcards[btv->type].no_video) {
+	if (!bttv_tvcards[btv->c.type].no_video) {
 		bttv_register_video(btv);
-#ifdef CONFIG_VIDEO_IR
-		bttv_input_init(btv);
-#endif
-
 		bt848_bright(btv,32768);
 		bt848_contrast(btv,32768);
 		bt848_hue(btv,32768);
@@ -3690,18 +3758,24 @@ static int __devinit bttv_probe(struct p
 		set_input(btv,0);
 	}
 
+	/* add subdevices */
+	if (btv->has_remote)
+		bttv_sub_add_device(&btv->c, "remote");
+	if (bttv_tvcards[btv->c.type].has_dvb)
+		bttv_sub_add_device(&btv->c, "dvb");
+
 	/* everything is fine */
 	bttv_num++;
         return 0;
 
  fail2:
-        free_irq(btv->dev->irq,btv);
+        free_irq(btv->c.pci->irq,btv);
 	
  fail1:
 	if (btv->bt848_mmio)
 		iounmap(btv->bt848_mmio);
-	release_mem_region(pci_resource_start(btv->dev,0),
-			   pci_resource_len(btv->dev,0));
+	release_mem_region(pci_resource_start(btv->c.pci,0),
+			   pci_resource_len(btv->c.pci,0));
 	pci_set_drvdata(dev,NULL);
 	return result;
 }
@@ -3711,7 +3785,7 @@ static void __devexit bttv_remove(struct
         struct bttv *btv = pci_get_drvdata(pci_dev);
 
 	if (bttv_verbose)
-		printk("bttv%d: unloading\n",btv->nr);
+		printk("bttv%d: unloading\n",btv->c.nr);
 
         /* shutdown everything (DMA+IRQs) */
 	btand(~15, BT848_GPIO_DMA_CTL);
@@ -3724,29 +3798,92 @@ static void __devexit bttv_remove(struct
 	/* tell gpio modules we are leaving ... */
 	btv->shutdown=1;
 	wake_up(&btv->gpioq);
-
+	bttv_sub_del_devices(&btv->c);
+	
         /* unregister i2c_bus + input */
 	fini_bttv_i2c(btv);
-#ifdef CONFIG_VIDEO_IR
-	bttv_input_fini(btv);
-#endif
 
 	/* unregister video4linux */
 	bttv_unregister_video(btv);
 
 	/* free allocated memory */
-	btcx_riscmem_free(btv->dev,&btv->main);
+	btcx_riscmem_free(btv->c.pci,&btv->main);
 
 	/* free ressources */
-        free_irq(btv->dev->irq,btv);
+        free_irq(btv->c.pci->irq,btv);
 	iounmap(btv->bt848_mmio);
-        release_mem_region(pci_resource_start(btv->dev,0),
-                           pci_resource_len(btv->dev,0));
+        release_mem_region(pci_resource_start(btv->c.pci,0),
+                           pci_resource_len(btv->c.pci,0));
 
 	pci_set_drvdata(pci_dev, NULL);
         return;
 }
 
+static int bttv_suspend(struct pci_dev *pci_dev, u32 state)
+{
+        struct bttv *btv = pci_get_drvdata(pci_dev);
+	struct bttv_buffer_set idle;
+	unsigned long flags;
+
+	printk("bttv%d: suspend %d\n", btv->c.nr, state);
+
+	/* stop dma + irqs */
+	spin_lock_irqsave(&btv->s_lock,flags);
+	memset(&idle, 0, sizeof(idle));
+	btv->state.set = btv->curr;
+	btv->curr = idle;
+	bttv_buffer_set_activate(btv, &idle);
+	bttv_set_dma(btv, 0, 0);
+	btwrite(0, BT848_INT_MASK);
+	spin_unlock_irqrestore(&btv->s_lock,flags);
+
+	/* save bt878 state */
+	btv->state.gpio_enable = btread(BT848_GPIO_OUT_EN);
+	btv->state.gpio_data   = gpio_read();
+
+	/* save pci state */
+	pci_save_state(pci_dev, btv->state.pci_cfg);
+	if (0 != pci_set_power_state(pci_dev, state)) {
+		pci_disable_device(pci_dev);
+		btv->state.disabled = 1;
+	}
+	return 0;
+}
+
+static int bttv_resume(struct pci_dev *pci_dev)
+{
+        struct bttv *btv = pci_get_drvdata(pci_dev);
+	unsigned long flags;
+
+	printk("bttv%d: resume\n", btv->c.nr);
+
+	/* restore pci state */
+	if (btv->state.disabled) {
+		pci_enable_device(pci_dev);
+		btv->state.disabled = 0;
+	}
+	pci_set_power_state(pci_dev, 0);
+	pci_restore_state(pci_dev, btv->state.pci_cfg);
+
+	/* restore bt878 state */
+	bttv_reinit_bt848(btv);
+	gpio_inout(0xffffff, btv->state.gpio_enable);
+	gpio_write(btv->state.gpio_data);
+
+	bt848_bright(btv,   btv->bright);
+	bt848_hue(btv,      btv->hue);
+	bt848_contrast(btv, btv->contrast);
+	bt848_sat(btv,      btv->saturation);
+
+	/* restart dma */
+	spin_lock_irqsave(&btv->s_lock,flags);
+	btv->curr = btv->state.set;
+	bttv_buffer_set_activate(btv, &btv->curr);
+	bttv_set_dma(btv, 0, btv->curr.irqflags);
+	spin_unlock_irqrestore(&btv->s_lock,flags);
+	return 0;
+}
+
 static struct pci_device_id bttv_pci_tbl[] = {
         {PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT848,
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
@@ -3766,6 +3903,9 @@ static struct pci_driver bttv_pci_driver
         .id_table = bttv_pci_tbl,
         .probe    = bttv_probe,
         .remove   = __devexit_p(bttv_remove),
+
+	.suspend    = bttv_suspend,
+	.resume     = bttv_resume,
 };
 
 static int bttv_init_module(void)
@@ -3777,6 +3917,10 @@ static int bttv_init_module(void)
 	       (BTTV_VERSION_CODE >> 16) & 0xff,
 	       (BTTV_VERSION_CODE >> 8) & 0xff,
 	       BTTV_VERSION_CODE & 0xff);
+#ifdef SNAPSHOT
+	printk(KERN_INFO "bttv: snapshot date %04d-%02d-%02d\n",
+	       SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
+#endif
 	if (gbuffers < 2 || gbuffers > VIDEO_MAX_FRAME)
 		gbuffers = 2;
 	if (gbufsize < 0 || gbufsize > BTTV_MAX_FBUF)
@@ -3788,6 +3932,7 @@ static int bttv_init_module(void)
 
 	bttv_check_chipset();
 
+	bus_register(&bttv_sub_bus_type);
 	rc = pci_module_init(&bttv_pci_driver);
 	if (-ENODEV == rc) {
 		/* plenty of people trying to use bttv for the cx2388x ... */
@@ -3800,6 +3945,7 @@ static int bttv_init_module(void)
 static void bttv_cleanup_module(void)
 {
 	pci_unregister_driver(&bttv_pci_driver);
+	bus_unregister(&bttv_sub_bus_type);
 	return;
 }
 
diff -puN /dev/null drivers/media/video/bttv-gpio.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/media/video/bttv-gpio.c	2004-01-19 22:17:22.000000000 -0800
@@ -0,0 +1,183 @@
+/*
+    bttv-gpio.c  --  gpio sub drivers
+
+    sysfs-based sub driver interface for bttv
+    mainly intented for gpio access
+
+
+    Copyright (C) 1996,97,98 Ralph  Metzler (rjkm@thp.uni-koeln.de)
+                           & Marcus Metzler (mocm@thp.uni-koeln.de)
+    (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+    
+*/
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <asm/io.h>
+
+#include "bttvp.h"
+
+/* ----------------------------------------------------------------------- */
+/* internal: the bttv "bus"                                                */
+
+static int bttv_sub_bus_match(struct device *dev, struct device_driver *drv)
+{
+	struct bttv_sub_driver *sub = to_bttv_sub_drv(drv);
+	int len = strlen(sub->wanted);
+
+	if (0 == strncmp(dev->bus_id, sub->wanted, len))
+		return 1;
+	return 0;
+}
+
+struct bus_type bttv_sub_bus_type = {
+	.name  = "bttv-sub",
+	.match = &bttv_sub_bus_match,
+};
+EXPORT_SYMBOL(bttv_sub_bus_type);
+
+static void release_sub_device(struct device *dev)
+{
+	struct bttv_sub_device *sub = to_bttv_sub_dev(dev);
+	kfree(sub);
+}
+
+int bttv_sub_add_device(struct bttv_core *core, char *name)
+{
+	struct bttv_sub_device *sub;
+
+	sub = kmalloc(sizeof(*sub),GFP_KERNEL);
+	if (NULL == sub)
+		return -ENOMEM;
+	memset(sub,0,sizeof(*sub));
+
+	sub->core        = core;
+	sub->dev.parent  = &core->pci->dev;
+	sub->dev.bus     = &bttv_sub_bus_type;
+	sub->dev.release = release_sub_device;
+	snprintf(sub->dev.bus_id,sizeof(sub->dev.bus_id),"%s%d",
+		 name, core->nr);
+
+	printk("bttv%d: add subdevice \"%s\"\n", core->nr, sub->dev.bus_id);
+	list_add_tail(&sub->list,&core->subs);
+	device_register(&sub->dev);
+	return 0;
+}
+
+int bttv_sub_del_devices(struct bttv_core *core)
+{
+	struct bttv_sub_device *sub;
+	struct list_head *item,*save;
+
+	list_for_each_safe(item,save,&core->subs) {
+		sub = list_entry(item,struct bttv_sub_device,list);
+		device_unregister(&sub->dev);
+	}
+	return 0;
+}
+
+void bttv_gpio_irq(struct bttv_core *core)
+{
+	struct bttv_sub_driver *drv;
+	struct bttv_sub_device *dev;
+	struct list_head *item;
+
+	list_for_each(item,&core->subs) {
+		dev = list_entry(item,struct bttv_sub_device,list);
+		drv = to_bttv_sub_drv(dev->dev.driver);
+		if (drv && drv->gpio_irq)
+			drv->gpio_irq(dev);
+	}
+}
+
+/* ----------------------------------------------------------------------- */
+/* external: sub-driver register/unregister                                */
+
+int bttv_sub_register(struct bttv_sub_driver *sub, char *wanted)
+{
+	sub->drv.bus = &bttv_sub_bus_type;
+	snprintf(sub->wanted,sizeof(sub->wanted),"%s",wanted);
+	driver_register(&sub->drv);
+	return 0;
+}
+EXPORT_SYMBOL(bttv_sub_register);
+
+int bttv_sub_unregister(struct bttv_sub_driver *sub)
+{
+	driver_unregister(&sub->drv);
+	return 0;
+}
+EXPORT_SYMBOL(bttv_sub_unregister);
+
+/* ----------------------------------------------------------------------- */
+/* external: gpio access functions                                         */
+
+void bttv_gpio_inout(struct bttv_core *core, u32 mask, u32 outbits)
+{
+	struct bttv *btv = container_of(core, struct bttv, c);
+	unsigned long flags;
+	u32 data;
+
+	spin_lock_irqsave(&btv->gpio_lock,flags);
+	data = btread(BT848_GPIO_OUT_EN);
+	data = data & ~mask;
+	data = data | (mask & outbits);
+	btwrite(data,BT848_GPIO_OUT_EN);
+	spin_unlock_irqrestore(&btv->gpio_lock,flags);
+}
+EXPORT_SYMBOL(bttv_gpio_inout);
+
+u32 bttv_gpio_read(struct bttv_core *core)
+{
+	struct bttv *btv = container_of(core, struct bttv, c);
+	u32 value;
+
+	value = btread(BT848_GPIO_DATA);
+	return value;
+}
+EXPORT_SYMBOL(bttv_gpio_read);
+
+void bttv_gpio_write(struct bttv_core *core, u32 value)
+{
+	struct bttv *btv = container_of(core, struct bttv, c);
+
+	btwrite(value,BT848_GPIO_DATA);
+}
+EXPORT_SYMBOL(bttv_gpio_write);
+
+void bttv_gpio_bits(struct bttv_core *core, u32 mask, u32 bits)
+{
+	struct bttv *btv = container_of(core, struct bttv, c);
+	unsigned long flags;
+	u32 data;
+
+	spin_lock_irqsave(&btv->gpio_lock,flags);
+	data = btread(BT848_GPIO_DATA);
+	data = data & ~mask;
+	data = data | (mask & bits);
+	btwrite(data,BT848_GPIO_DATA);
+	spin_unlock_irqrestore(&btv->gpio_lock,flags);
+}
+EXPORT_SYMBOL(bttv_gpio_bits);
+
+/*
+ * Local variables:
+ * c-basic-offset: 8
+ * End:
+ */
diff -puN drivers/media/video/bttv.h~linus drivers/media/video/bttv.h
--- 25/drivers/media/video/bttv.h~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/bttv.h	2004-01-19 22:17:22.000000000 -0800
@@ -14,6 +14,7 @@
 #define _BTTV_H_
 
 #include <linux/videodev.h>
+#include <linux/i2c.h>
 
 /* ---------------------------------------------------------- */
 /* exported by bttv-cards.c                                   */
@@ -117,6 +118,12 @@
 #define BTTV_PV143          0x69
 #define BTTV_IVC100         0x6e
 #define BTTV_IVC120         0x6f
+#define BTTV_PC_HDTV        0x70
+#define BTTV_TWINHAN_DST    0x71
+#define BTTV_WINFASTVC100   0x72
+#define BTTV_SIMUS_GVC1100  0x74
+#define BTTV_NGSTV_PLUS     0x75
+#define BTTV_LMLBT4         0x76
 
 /* i2c address list */
 #define I2C_TSA5522        0xc2
@@ -150,6 +157,18 @@
 #define DIGITAL_MODE_VIDEO 1
 #define DIGITAL_MODE_CAMERA 2
 
+struct bttv_core {
+	/* device structs */
+	struct pci_dev       *pci;
+	struct i2c_adapter   i2c_adap;
+	struct list_head     subs;     /* struct bttv_sub_device */
+
+	/* device config */
+        unsigned int         nr;       /* dev nr (for printk("bttv%d: ...");  */
+	unsigned int         type;     /* card type (pointer into tvcards[])  */
+	char                 name[8];  /* dev name */
+};
+
 struct bttv;
 
 struct tvcard
@@ -173,7 +192,10 @@ struct tvcard
 	unsigned int msp34xx_alt:1;
 
 	/* flag: video pci function is unused */
-	unsigned int no_video;
+	unsigned int no_video:1;
+	unsigned int has_dvb:1;
+	unsigned int has_remote:1;
+	unsigned int no_gpioirq:1;
 
 	/* other settings */
 	unsigned int pll;
@@ -208,7 +230,9 @@ extern int bttv_handle_chipset(struct bt
 
 /* ---------------------------------------------------------- */
 /* exported by bttv-if.c                                      */
-/* interface for gpio access by other modules                 */
+
+/* this obsolete -- please use the sysfs-based
+   interface below for new code */
 
 /* returns card type + card ID (for bt878-based ones)
    for possible values see lines below beginning with #define BTTV_UNKNOWN
@@ -256,7 +280,43 @@ extern wait_queue_head_t* bttv_get_gpio_
 extern void bttv_i2c_call(unsigned int card, unsigned int cmd, void *arg);
 
 
-/* i2c */
+
+/* ---------------------------------------------------------- */
+/* sysfs/driver-moded based gpio access interface             */
+
+
+struct bttv_sub_device {
+	struct device    dev;
+	struct bttv_core *core;
+	struct list_head list;
+};
+#define to_bttv_sub_dev(x) container_of((x), struct bttv_sub_device, dev)
+
+struct bttv_sub_driver {
+	struct device_driver   drv;
+	char                   wanted[BUS_ID_SIZE];
+	void                   (*gpio_irq)(struct bttv_sub_device *sub);
+};
+#define to_bttv_sub_drv(x) container_of((x), struct bttv_sub_driver, drv)
+
+int bttv_sub_register(struct bttv_sub_driver *drv, char *wanted);
+int bttv_sub_unregister(struct bttv_sub_driver *drv);
+
+/* gpio access functions */
+void bttv_gpio_inout(struct bttv_core *core, u32 mask, u32 outbits);
+u32 bttv_gpio_read(struct bttv_core *core);
+void bttv_gpio_write(struct bttv_core *core, u32 value);
+void bttv_gpio_bits(struct bttv_core *core, u32 mask, u32 bits);
+
+#define gpio_inout(mask,bits)  bttv_gpio_inout(&btv->c, mask, bits)
+#define gpio_read()            bttv_gpio_read(&btv->c)
+#define gpio_write(value)      bttv_gpio_write(&btv->c, value)
+#define gpio_bits(mask,bits)   bttv_gpio_bits(&btv->c, mask, bits)
+
+
+/* ---------------------------------------------------------- */
+/* i2c                                                        */
+
 extern void bttv_bit_setscl(void *data, int state);
 extern void bttv_bit_setsda(void *data, int state);
 extern void bttv_call_i2c_clients(struct bttv *btv, unsigned int cmd, void *arg);
diff -puN /dev/null drivers/media/video/bttv-i2c.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/media/video/bttv-i2c.c	2004-01-19 22:17:22.000000000 -0800
@@ -0,0 +1,471 @@
+/*
+    bttv-i2c.c  --  all the i2c code is here
+
+    bttv - Bt848 frame grabber driver
+
+    Copyright (C) 1996,97,98 Ralph  Metzler (rjkm@thp.uni-koeln.de)
+                           & Marcus Metzler (mocm@thp.uni-koeln.de)
+    (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+    
+*/
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+
+#include "bttvp.h"
+
+static struct i2c_algo_bit_data bttv_i2c_algo_bit_template;
+static struct i2c_adapter bttv_i2c_adap_sw_template;
+static struct i2c_adapter bttv_i2c_adap_hw_template;
+static struct i2c_client bttv_i2c_client_template;
+
+#ifndef I2C_PEC
+static void bttv_inc_use(struct i2c_adapter *adap);
+static void bttv_dec_use(struct i2c_adapter *adap);
+#endif
+static int attach_inform(struct i2c_client *client);
+
+static int i2c_debug = 0;
+static int i2c_hw = 0;
+MODULE_PARM(i2c_debug,"i");
+MODULE_PARM(i2c_hw,"i");
+
+/* ----------------------------------------------------------------------- */
+/* I2C functions - bitbanging adapter (software i2c)                       */
+
+void bttv_bit_setscl(void *data, int state)
+{
+	struct bttv *btv = (struct bttv*)data;
+
+	if (state)
+		btv->i2c_state |= 0x02;
+	else
+		btv->i2c_state &= ~0x02;
+	btwrite(btv->i2c_state, BT848_I2C);
+	btread(BT848_I2C);
+}
+
+void bttv_bit_setsda(void *data, int state)
+{
+	struct bttv *btv = (struct bttv*)data;
+
+	if (state)
+		btv->i2c_state |= 0x01;
+	else
+		btv->i2c_state &= ~0x01;
+	btwrite(btv->i2c_state, BT848_I2C);
+	btread(BT848_I2C);
+}
+
+static int bttv_bit_getscl(void *data)
+{
+	struct bttv *btv = (struct bttv*)data;
+	int state;
+	
+	state = btread(BT848_I2C) & 0x02 ? 1 : 0;
+	return state;
+}
+
+static int bttv_bit_getsda(void *data)
+{
+	struct bttv *btv = (struct bttv*)data;
+	int state;
+
+	state = btread(BT848_I2C) & 0x01;
+	return state;
+}
+
+static struct i2c_algo_bit_data bttv_i2c_algo_bit_template = {
+	.setsda  = bttv_bit_setsda,
+	.setscl  = bttv_bit_setscl,
+	.getsda  = bttv_bit_getsda,
+	.getscl  = bttv_bit_getscl,
+	.udelay  = 16,
+	.mdelay  = 10,
+	.timeout = 200,
+};
+
+static struct i2c_adapter bttv_i2c_adap_sw_template = {
+#ifdef I2C_PEC
+	.owner             = THIS_MODULE,
+#else
+	.inc_use           = bttv_inc_use,
+	.dec_use           = bttv_dec_use,
+#endif
+#ifdef I2C_ADAP_CLASS_TV_ANALOG
+	.class             = I2C_ADAP_CLASS_TV_ANALOG,
+#endif
+	I2C_DEVNAME("bt848"),
+	.id                = I2C_HW_B_BT848,
+	.client_register   = attach_inform,
+};
+
+/* ----------------------------------------------------------------------- */
+/* I2C functions - hardware i2c                                            */
+
+static int algo_control(struct i2c_adapter *adapter, 
+			unsigned int cmd, unsigned long arg)
+{
+	return 0;
+}
+
+static u32 functionality(struct i2c_adapter *adap)
+{
+	return I2C_FUNC_SMBUS_EMUL;
+}
+
+static int
+bttv_i2c_wait_done(struct bttv *btv)
+{
+	DECLARE_WAITQUEUE(wait, current);
+	int rc = 0;
+	
+	add_wait_queue(&btv->i2c_queue, &wait);
+	set_current_state(TASK_INTERRUPTIBLE);
+	if (0 == btv->i2c_done)
+		schedule_timeout(HZ/50+1);
+	set_current_state(TASK_RUNNING);
+	remove_wait_queue(&btv->i2c_queue, &wait);
+
+	if (0 == btv->i2c_done)
+		/* timeout */
+		rc = -EIO;
+	if (btv->i2c_done & BT848_INT_RACK)
+		rc = 1;
+	btv->i2c_done = 0;
+	return rc;
+}
+
+#define I2C_HW (BT878_I2C_MODE  | BT848_I2C_SYNC |\
+		BT848_I2C_SCL | BT848_I2C_SDA)
+
+static int
+bttv_i2c_sendbytes(struct bttv *btv, const struct i2c_msg *msg, int last)
+{
+	u32 xmit;
+	int retval,cnt;
+
+	/* sanity checks */
+	if (0 == msg->len)
+		return -EINVAL;
+
+	/* start, address + first byte */
+	xmit = (msg->addr << 25) | (msg->buf[0] << 16) | I2C_HW;
+	if (msg->len > 1 || !last)
+		xmit |= BT878_I2C_NOSTOP;
+	btwrite(xmit, BT848_I2C);
+	retval = bttv_i2c_wait_done(btv);
+	if (retval < 0)
+		goto err;
+	if (retval == 0)
+		goto eio;
+	if (i2c_debug) {
+		printk(" <W %02x %02x", msg->addr << 1, msg->buf[0]);
+		if (!(xmit & BT878_I2C_NOSTOP))
+			printk(" >\n");
+	}
+
+	for (cnt = 1; cnt < msg->len; cnt++ ) {
+		/* following bytes */
+		xmit = (msg->buf[cnt] << 24) | I2C_HW | BT878_I2C_NOSTART;
+		if (cnt < msg->len-1 || !last)
+			xmit |= BT878_I2C_NOSTOP;
+		btwrite(xmit, BT848_I2C);
+		retval = bttv_i2c_wait_done(btv);
+		if (retval < 0)
+			goto err;
+		if (retval == 0)
+			goto eio;
+		if (i2c_debug) {
+			printk(" %02x", msg->buf[cnt]);
+			if (!(xmit & BT878_I2C_NOSTOP))
+				printk(" >\n");
+		}
+	}
+	return msg->len;
+
+ eio:
+	retval = -EIO;
+ err:
+	if (i2c_debug)
+		printk(" ERR: %d\n",retval);
+	return retval;
+}
+
+static int
+bttv_i2c_readbytes(struct bttv *btv, const struct i2c_msg *msg, int last)
+{
+	u32 xmit;
+	u32 cnt;
+	int retval;
+
+	for(cnt = 0; cnt < msg->len; cnt++) {
+		xmit = (msg->addr << 25) | (1 << 24) | I2C_HW;
+		if (cnt < msg->len-1)
+			xmit |= BT848_I2C_W3B;
+		if (cnt < msg->len-1 || !last)
+			xmit |= BT878_I2C_NOSTOP;
+		if (cnt)
+			xmit |= BT878_I2C_NOSTART;
+		btwrite(xmit, BT848_I2C);
+		retval = bttv_i2c_wait_done(btv);
+		if (retval < 0)
+			goto err;
+		if (retval == 0)
+			goto eio;
+		msg->buf[cnt] = ((u32)btread(BT848_I2C) >> 8) & 0xff;
+		if (i2c_debug) {
+			if (!(xmit & BT878_I2C_NOSTART))
+				printk(" <R %02x", (msg->addr << 1) +1);
+			printk(" =%02x", msg->buf[cnt]);
+			if (!(xmit & BT878_I2C_NOSTOP))
+				printk(" >\n");
+		}
+	}
+	return msg->len;
+
+ eio:
+	retval = -EIO;
+ err:
+	if (i2c_debug)
+		printk(" ERR: %d\n",retval);
+       	return retval;
+}
+
+int bttv_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num)
+{
+	struct bttv *btv = i2c_get_adapdata(i2c_adap);
+	int retval = 0;
+	int i;
+
+	if (i2c_debug)
+		printk("bt-i2c:");
+	btwrite(BT848_INT_I2CDONE|BT848_INT_RACK, BT848_INT_STAT);
+	for (i = 0 ; i < num; i++) {
+		if (msgs[i].flags & I2C_M_RD) {
+			/* read */
+			retval = bttv_i2c_readbytes(btv, &msgs[i], i+1 == num);
+			if (retval < 0)
+				goto err;
+		} else {
+			/* write */
+			retval = bttv_i2c_sendbytes(btv, &msgs[i], i+1 == num);
+			if (retval < 0)
+				goto err;
+		}
+	}
+	return num;
+
+ err:
+	return retval;
+}
+
+static struct i2c_algorithm bttv_algo = {
+	.name          = "bt878",
+	.id            = I2C_ALGO_BIT | I2C_HW_B_BT848 /* FIXME */,
+	.master_xfer   = bttv_i2c_xfer,
+	.algo_control  = algo_control,
+	.functionality = functionality,
+};
+
+static struct i2c_adapter bttv_i2c_adap_hw_template = {
+#ifdef I2C_PEC
+	.owner         = THIS_MODULE,
+#else
+	.inc_use       = bttv_inc_use,
+	.dec_use       = bttv_dec_use,
+#endif
+#ifdef I2C_ADAP_CLASS_TV_ANALOG
+	.class         = I2C_ADAP_CLASS_TV_ANALOG,
+#endif
+	I2C_DEVNAME("bt878"),
+	.id            = I2C_ALGO_BIT | I2C_HW_B_BT848 /* FIXME */,
+	.algo          = &bttv_algo,
+	.client_register = attach_inform,
+};
+
+/* ----------------------------------------------------------------------- */
+/* I2C functions - common stuff                                            */
+
+#ifndef I2C_PEC
+static void bttv_inc_use(struct i2c_adapter *adap)
+{
+	MOD_INC_USE_COUNT;
+}
+
+static void bttv_dec_use(struct i2c_adapter *adap)
+{
+	MOD_DEC_USE_COUNT;
+}
+#endif
+
+static int attach_inform(struct i2c_client *client)
+{
+        struct bttv *btv = i2c_get_adapdata(client->adapter);
+
+	if (btv->tuner_type != UNSET)
+		bttv_call_i2c_clients(btv,TUNER_SET_TYPE,&btv->tuner_type);
+	if (btv->pinnacle_id != UNSET)
+		bttv_call_i2c_clients(btv,AUDC_CONFIG_PINNACLE,
+				      &btv->pinnacle_id);
+
+        if (bttv_debug)
+		printk("bttv%d: i2c attach [client=%s]\n",
+		       btv->c.nr, i2c_clientname(client));
+        return 0;
+}
+
+void bttv_call_i2c_clients(struct bttv *btv, unsigned int cmd, void *arg)
+{
+	if (0 != btv->i2c_rc)
+		return;
+	i2c_clients_command(&btv->c.i2c_adap, cmd, arg);
+}
+
+void bttv_i2c_call(unsigned int card, unsigned int cmd, void *arg)
+{
+	if (card >= bttv_num)
+		return;
+	bttv_call_i2c_clients(&bttvs[card], cmd, arg);
+}
+
+static struct i2c_client bttv_i2c_client_template = {
+	I2C_DEVNAME("bttv internal"),
+        .id       = -1,
+};
+
+
+/* read I2C */
+int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for) 
+{
+        unsigned char buffer = 0;
+
+	if (0 != btv->i2c_rc)
+		return -1;
+	if (bttv_verbose && NULL != probe_for)
+		printk(KERN_INFO "bttv%d: i2c: checking for %s @ 0x%02x... ",
+		       btv->c.nr,probe_for,addr);
+        btv->i2c_client.addr = addr >> 1;
+        if (1 != i2c_master_recv(&btv->i2c_client, &buffer, 1)) {
+		if (NULL != probe_for) {
+			if (bttv_verbose)
+				printk("not found\n");
+		} else
+			printk(KERN_WARNING "bttv%d: i2c read 0x%x: error\n",
+			       btv->c.nr,addr);
+                return -1;
+	}
+	if (bttv_verbose && NULL != probe_for)
+		printk("found\n");
+        return buffer;
+}
+
+/* write I2C */
+int bttv_I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1,
+                    unsigned char b2, int both)
+{
+        unsigned char buffer[2];
+        int bytes = both ? 2 : 1;
+
+	if (0 != btv->i2c_rc)
+		return -1;
+        btv->i2c_client.addr = addr >> 1;
+        buffer[0] = b1;
+        buffer[1] = b2;
+        if (bytes != i2c_master_send(&btv->i2c_client, buffer, bytes))
+		return -1;
+        return 0;
+}
+
+/* read EEPROM content */
+void __devinit bttv_readee(struct bttv *btv, unsigned char *eedata, int addr)
+{
+	int i;
+        
+	if (bttv_I2CWrite(btv, addr, 0, -1, 0)<0) {
+		printk(KERN_WARNING "bttv: readee error\n");
+		return;
+	}
+	btv->i2c_client.addr = addr >> 1;
+	for (i=0; i<256; i+=16) {
+		if (16 != i2c_master_recv(&btv->i2c_client,eedata+i,16)) {
+			printk(KERN_WARNING "bttv: readee error\n");
+			break;
+		}
+	}
+}
+
+/* init + register i2c algo-bit adapter */
+int __devinit init_bttv_i2c(struct bttv *btv)
+{
+	int use_hw = (btv->id == 878) && i2c_hw;
+
+	memcpy(&btv->i2c_client, &bttv_i2c_client_template,
+	       sizeof(bttv_i2c_client_template));
+
+	if (use_hw) {
+		/* bt878 */
+		memcpy(&btv->c.i2c_adap, &bttv_i2c_adap_hw_template,
+		       sizeof(bttv_i2c_adap_hw_template));
+	} else {
+		/* bt848 */
+		memcpy(&btv->c.i2c_adap, &bttv_i2c_adap_sw_template,
+		       sizeof(bttv_i2c_adap_sw_template));
+		memcpy(&btv->i2c_algo, &bttv_i2c_algo_bit_template,
+		       sizeof(bttv_i2c_algo_bit_template));
+		btv->i2c_algo.data = btv;
+		btv->c.i2c_adap.algo_data = &btv->i2c_algo;
+	}
+
+	btv->c.i2c_adap.dev.parent = &btv->c.pci->dev;
+	snprintf(btv->c.i2c_adap.name, sizeof(btv->c.i2c_adap.name),
+		 "bt%d #%d [%s]", btv->id, btv->c.nr, use_hw ? "hw" : "sw");
+
+        i2c_set_adapdata(&btv->c.i2c_adap, btv);
+        btv->i2c_client.adapter = &btv->c.i2c_adap;
+
+	if (use_hw) {
+		btv->i2c_rc = i2c_add_adapter(&btv->c.i2c_adap);
+	} else {
+		bttv_bit_setscl(btv,1);
+		bttv_bit_setsda(btv,1);
+		btv->i2c_rc = i2c_bit_add_bus(&btv->c.i2c_adap);
+	}
+	return btv->i2c_rc;
+}
+
+int __devexit fini_bttv_i2c(struct bttv *btv)
+{
+	int use_hw = (btv->id == 878) && i2c_hw;
+
+	if (0 != btv->i2c_rc)
+		return 0;
+
+	if (use_hw) {
+		return i2c_del_adapter(&btv->c.i2c_adap);
+	} else {
+		return i2c_bit_del_bus(&btv->c.i2c_adap);
+	}
+}
+
+/*
+ * Local variables:
+ * c-basic-offset: 8
+ * End:
+ */
diff -puN drivers/media/video/bttv-if.c~linus drivers/media/video/bttv-if.c
--- 25/drivers/media/video/bttv-if.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/bttv-if.c	2004-01-19 22:17:22.000000000 -0800
@@ -1,7 +1,7 @@
 /*
-    bttv-if.c  --  interfaces to other kernel modules
-	all the i2c code is here
-	also the gpio interface exported by bttv (used by lirc)
+    bttv-if.c  --  old gpio interface to other kernel modules
+                   don't use in new code, will go away in 2.7
+		   have a look at bttv-gpio.c instead.
 
     bttv - Bt848 frame grabber driver
 
@@ -28,22 +28,10 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/delay.h>
-
 #include <asm/io.h>
 
 #include "bttvp.h"
 
-static struct i2c_algo_bit_data bttv_i2c_algo_bit_template;
-static struct i2c_adapter bttv_i2c_adap_sw_template;
-static struct i2c_adapter bttv_i2c_adap_hw_template;
-static struct i2c_client bttv_i2c_client_template;
-
-#ifndef I2C_PEC
-static void bttv_inc_use(struct i2c_adapter *adap);
-static void bttv_dec_use(struct i2c_adapter *adap);
-#endif
-static int attach_inform(struct i2c_client *client);
-
 EXPORT_SYMBOL(bttv_get_cardinfo);
 EXPORT_SYMBOL(bttv_get_pcidev);
 EXPORT_SYMBOL(bttv_get_id);
@@ -53,11 +41,6 @@ EXPORT_SYMBOL(bttv_write_gpio);
 EXPORT_SYMBOL(bttv_get_gpio_queue);
 EXPORT_SYMBOL(bttv_i2c_call);
 
-static int i2c_debug = 0;
-static int i2c_hw = 0;
-MODULE_PARM(i2c_debug,"i");
-MODULE_PARM(i2c_hw,"i");
-
 /* ----------------------------------------------------------------------- */
 /* Exported functions - for other modules which want to access the         */
 /*                      gpio ports (IR for example)                        */
@@ -68,7 +51,7 @@ int bttv_get_cardinfo(unsigned int card,
 	if (card >= bttv_num) {
 		return -1;
 	}
-	*type   = bttvs[card].type;
+	*type   = bttvs[card].c.type;
 	*cardid = bttvs[card].cardid;
 	return 0;
 }
@@ -77,7 +60,7 @@ struct pci_dev* bttv_get_pcidev(unsigned
 {
 	if (card >= bttv_num)
 		return NULL;
-	return bttvs[card].dev;
+	return bttvs[card].c.pci;
 }
 
 int bttv_get_id(unsigned int card)
@@ -86,7 +69,7 @@ int bttv_get_id(unsigned int card)
 	if (card >= bttv_num) {
 		return -1;
 	}
-	return bttvs[card].type;
+	return bttvs[card].c.type;
 }
 
 
@@ -99,7 +82,7 @@ int bttv_gpio_enable(unsigned int card, 
 	}
 	
 	btv = &bttvs[card];
-	btaor(data, ~mask, BT848_GPIO_OUT_EN);
+	gpio_inout(mask,data);
 	if (bttv_gpio)
 		bttv_gpio_tracking(btv,"extern enable");
 	return 0;
@@ -121,7 +104,7 @@ int bttv_read_gpio(unsigned int card, un
 
 /* prior setting BT848_GPIO_REG_INP is (probably) not needed 
    because we set direct input on init */
-	*data = btread(BT848_GPIO_DATA);
+	*data = gpio_read();
 	return 0;
 }
 
@@ -137,7 +120,7 @@ int bttv_write_gpio(unsigned int card, u
 
 /* prior setting BT848_GPIO_REG_INP is (probably) not needed 
    because direct input is set on init */
-	btaor(data & mask, ~mask, BT848_GPIO_DATA);
+	gpio_bits(mask,data);
 	if (bttv_gpio)
 		bttv_gpio_tracking(btv,"extern write");
 	return 0;
@@ -158,418 +141,6 @@ wait_queue_head_t* bttv_get_gpio_queue(u
 	return &btv->gpioq;
 }
 
-
-/* ----------------------------------------------------------------------- */
-/* I2C functions - bitbanging adapter (software i2c)                       */
-
-void bttv_bit_setscl(void *data, int state)
-{
-	struct bttv *btv = (struct bttv*)data;
-
-	if (state)
-		btv->i2c_state |= 0x02;
-	else
-		btv->i2c_state &= ~0x02;
-	btwrite(btv->i2c_state, BT848_I2C);
-	btread(BT848_I2C);
-}
-
-void bttv_bit_setsda(void *data, int state)
-{
-	struct bttv *btv = (struct bttv*)data;
-
-	if (state)
-		btv->i2c_state |= 0x01;
-	else
-		btv->i2c_state &= ~0x01;
-	btwrite(btv->i2c_state, BT848_I2C);
-	btread(BT848_I2C);
-}
-
-static int bttv_bit_getscl(void *data)
-{
-	struct bttv *btv = (struct bttv*)data;
-	int state;
-	
-	state = btread(BT848_I2C) & 0x02 ? 1 : 0;
-	return state;
-}
-
-static int bttv_bit_getsda(void *data)
-{
-	struct bttv *btv = (struct bttv*)data;
-	int state;
-
-	state = btread(BT848_I2C) & 0x01;
-	return state;
-}
-
-static struct i2c_algo_bit_data bttv_i2c_algo_bit_template = {
-	.setsda  = bttv_bit_setsda,
-	.setscl  = bttv_bit_setscl,
-	.getsda  = bttv_bit_getsda,
-	.getscl  = bttv_bit_getscl,
-	.udelay  = 16,
-	.mdelay  = 10,
-	.timeout = 200,
-};
-
-static struct i2c_adapter bttv_i2c_adap_sw_template = {
-#ifdef I2C_PEC
-	.owner             = THIS_MODULE,
-#else
-	.inc_use           = bttv_inc_use,
-	.dec_use           = bttv_dec_use,
-#endif
-#ifdef I2C_ADAP_CLASS_TV_ANALOG
-	.class             = I2C_ADAP_CLASS_TV_ANALOG,
-#endif
-	I2C_DEVNAME("bt848"),
-	.id                = I2C_HW_B_BT848,
-	.client_register   = attach_inform,
-};
-
-/* ----------------------------------------------------------------------- */
-/* I2C functions - hardware i2c                                            */
-
-static int algo_control(struct i2c_adapter *adapter, 
-			unsigned int cmd, unsigned long arg)
-{
-	return 0;
-}
-
-static u32 functionality(struct i2c_adapter *adap)
-{
-	return I2C_FUNC_SMBUS_EMUL;
-}
-
-static int
-bttv_i2c_wait_done(struct bttv *btv)
-{
-	u32 stat;
-	unsigned long timeout;
-
-	timeout = jiffies + HZ/100 + 1; /* 10ms */
-	for (;;) {
-		stat = btread(BT848_INT_STAT);
-		if (stat & BT848_INT_I2CDONE)
-			break;
-		if (time_after(jiffies,timeout))
-			return -EIO;
-		udelay(10);
-	}
-	btwrite(BT848_INT_I2CDONE|BT848_INT_RACK, BT848_INT_STAT);
-	return ((stat & BT848_INT_RACK) ? 1 : 0);
-}
-
-#define I2C_HW (BT878_I2C_MODE  | BT848_I2C_SYNC |\
-		BT848_I2C_SCL | BT848_I2C_SDA)
-
-static int
-bttv_i2c_sendbytes(struct bttv *btv, const struct i2c_msg *msg, int last)
-{
-	u32 xmit;
-	int retval,cnt;
-
-	/* start, address + first byte */
-	xmit = (msg->addr << 25) | (msg->buf[0] << 16) | I2C_HW;
-	if (msg->len > 1 || !last)
-		xmit |= BT878_I2C_NOSTOP;
-	btwrite(xmit, BT848_I2C);
-	retval = bttv_i2c_wait_done(btv);
-	if (retval < 0)
-		goto err;
-	if (retval == 0)
-		goto eio;
-	if (i2c_debug) {
-		printk(" <W %02x %02x", msg->addr << 1, msg->buf[0]);
-		if (!(xmit & BT878_I2C_NOSTOP))
-			printk(" >\n");
-	}
-
-	for (cnt = 1; cnt < msg->len; cnt++ ) {
-		/* following bytes */
-		xmit = (msg->buf[cnt] << 24) | I2C_HW | BT878_I2C_NOSTART;
-		if (cnt < msg->len-1 || !last)
-			xmit |= BT878_I2C_NOSTOP;
-		btwrite(xmit, BT848_I2C);
-		retval = bttv_i2c_wait_done(btv);
-		if (retval < 0)
-			goto err;
-		if (retval == 0)
-			goto eio;
-		if (i2c_debug) {
-			printk(" %02x", msg->buf[cnt]);
-			if (!(xmit & BT878_I2C_NOSTOP))
-				printk(" >\n");
-		}
-	}
-	return msg->len;
-
- eio:
-	retval = -EIO;
- err:
-	if (i2c_debug)
-		printk(" ERR: %d\n",retval);
-	return retval;
-}
-
-static int
-bttv_i2c_readbytes(struct bttv *btv, const struct i2c_msg *msg, int last)
-{
-	u32 xmit;
-	u32 cnt;
-	int retval;
-
-	for(cnt = 0; cnt < msg->len; cnt++) {
-		xmit = (msg->addr << 25) | (1 << 24) | I2C_HW;
-		if (cnt < msg->len-1)
-			xmit |= BT848_I2C_W3B;
-		if (cnt < msg->len-1 || !last)
-			xmit |= BT878_I2C_NOSTOP;
-		if (cnt)
-			xmit |= BT878_I2C_NOSTART;
-		btwrite(xmit, BT848_I2C);
-		retval = bttv_i2c_wait_done(btv);
-		if (retval < 0)
-			goto err;
-		if (retval == 0)
-			goto eio;
-		msg->buf[cnt] = ((u32)btread(BT848_I2C) >> 8) & 0xff;
-		if (i2c_debug) {
-			if (!(xmit & BT878_I2C_NOSTART))
-				printk(" <R %02x", (msg->addr << 1) +1);
-			printk(" =%02x", msg->buf[cnt]);
-			if (!(xmit & BT878_I2C_NOSTOP))
-				printk(" >\n");
-		}
-	}
-	return msg->len;
-
- eio:
-	retval = -EIO;
- err:
-	if (i2c_debug)
-		printk(" ERR: %d\n",retval);
-       	return retval;
-}
-
-int bttv_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num)
-{
-	struct bttv *btv = i2c_get_adapdata(i2c_adap);
-	int retval = 0;
-	int i;
-
-	if (i2c_debug)
-		printk("bt-i2c:");
-	btwrite(BT848_INT_I2CDONE|BT848_INT_RACK, BT848_INT_STAT);
-	for (i = 0 ; i < num; i++) {
-		if (msgs[i].flags & I2C_M_RD) {
-			/* read */
-			retval = bttv_i2c_readbytes(btv, &msgs[i], i+1 == num);
-			if (retval < 0)
-				goto err;
-		} else {
-			/* write */
-			retval = bttv_i2c_sendbytes(btv, &msgs[i], i+1 == num);
-			if (retval < 0)
-				goto err;
-		}
-	}
-	return num;
-
- err:
-	return retval;
-}
-
-static struct i2c_algorithm bttv_algo = {
-	.name          = "bt878",
-	.id            = I2C_ALGO_BIT | I2C_HW_B_BT848 /* FIXME */,
-	.master_xfer   = bttv_i2c_xfer,
-	.algo_control  = algo_control,
-	.functionality = functionality,
-};
-
-static struct i2c_adapter bttv_i2c_adap_hw_template = {
-#ifdef I2C_PEC
-	.owner         = THIS_MODULE,
-#else
-	.inc_use       = bttv_inc_use,
-	.dec_use       = bttv_dec_use,
-#endif
-#ifdef I2C_ADAP_CLASS_TV_ANALOG
-	.class         = I2C_ADAP_CLASS_TV_ANALOG,
-#endif
-	I2C_DEVNAME("bt878"),
-	.id            = I2C_ALGO_BIT | I2C_HW_B_BT848 /* FIXME */,
-	.algo          = &bttv_algo,
-	.client_register = attach_inform,
-};
-
-/* ----------------------------------------------------------------------- */
-/* I2C functions - common stuff                                            */
-
-#ifndef I2C_PEC
-static void bttv_inc_use(struct i2c_adapter *adap)
-{
-	MOD_INC_USE_COUNT;
-}
-
-static void bttv_dec_use(struct i2c_adapter *adap)
-{
-	MOD_DEC_USE_COUNT;
-}
-#endif
-
-static int attach_inform(struct i2c_client *client)
-{
-        struct bttv *btv = i2c_get_adapdata(client->adapter);
-
-	if (btv->tuner_type != UNSET)
-		bttv_call_i2c_clients(btv,TUNER_SET_TYPE,&btv->tuner_type);
-	if (btv->pinnacle_id != UNSET)
-		bttv_call_i2c_clients(btv,AUDC_CONFIG_PINNACLE,
-				      &btv->pinnacle_id);
-
-        if (bttv_debug)
-		printk("bttv%d: i2c attach [client=%s]\n",
-		       btv->nr, i2c_clientname(client));
-        return 0;
-}
-
-void bttv_call_i2c_clients(struct bttv *btv, unsigned int cmd, void *arg)
-{
-	if (0 != btv->i2c_rc)
-		return;
-	i2c_clients_command(&btv->i2c_adap, cmd, arg);
-}
-
-void bttv_i2c_call(unsigned int card, unsigned int cmd, void *arg)
-{
-	if (card >= bttv_num)
-		return;
-	bttv_call_i2c_clients(&bttvs[card], cmd, arg);
-}
-
-static struct i2c_client bttv_i2c_client_template = {
-	I2C_DEVNAME("bttv internal"),
-        .id       = -1,
-};
-
-
-/* read I2C */
-int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for) 
-{
-        unsigned char buffer = 0;
-
-	if (0 != btv->i2c_rc)
-		return -1;
-	if (bttv_verbose && NULL != probe_for)
-		printk(KERN_INFO "bttv%d: i2c: checking for %s @ 0x%02x... ",
-		       btv->nr,probe_for,addr);
-        btv->i2c_client.addr = addr >> 1;
-        if (1 != i2c_master_recv(&btv->i2c_client, &buffer, 1)) {
-		if (NULL != probe_for) {
-			if (bttv_verbose)
-				printk("not found\n");
-		} else
-			printk(KERN_WARNING "bttv%d: i2c read 0x%x: error\n",
-			       btv->nr,addr);
-                return -1;
-	}
-	if (bttv_verbose && NULL != probe_for)
-		printk("found\n");
-        return buffer;
-}
-
-/* write I2C */
-int bttv_I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1,
-                    unsigned char b2, int both)
-{
-        unsigned char buffer[2];
-        int bytes = both ? 2 : 1;
-
-	if (0 != btv->i2c_rc)
-		return -1;
-        btv->i2c_client.addr = addr >> 1;
-        buffer[0] = b1;
-        buffer[1] = b2;
-        if (bytes != i2c_master_send(&btv->i2c_client, buffer, bytes))
-		return -1;
-        return 0;
-}
-
-/* read EEPROM content */
-void __devinit bttv_readee(struct bttv *btv, unsigned char *eedata, int addr)
-{
-	int i;
-        
-	if (bttv_I2CWrite(btv, addr, 0, -1, 0)<0) {
-		printk(KERN_WARNING "bttv: readee error\n");
-		return;
-	}
-	btv->i2c_client.addr = addr >> 1;
-	for (i=0; i<256; i+=16) {
-		if (16 != i2c_master_recv(&btv->i2c_client,eedata+i,16)) {
-			printk(KERN_WARNING "bttv: readee error\n");
-			break;
-		}
-	}
-}
-
-/* init + register i2c algo-bit adapter */
-int __devinit init_bttv_i2c(struct bttv *btv)
-{
-	int use_hw = (btv->id == 878) && i2c_hw;
-
-	memcpy(&btv->i2c_client, &bttv_i2c_client_template,
-	       sizeof(bttv_i2c_client_template));
-
-	if (use_hw) {
-		/* bt878 */
-		memcpy(&btv->i2c_adap, &bttv_i2c_adap_hw_template,
-		       sizeof(bttv_i2c_adap_hw_template));
-	} else {
-		/* bt848 */
-		memcpy(&btv->i2c_adap, &bttv_i2c_adap_sw_template,
-		       sizeof(bttv_i2c_adap_sw_template));
-		memcpy(&btv->i2c_algo, &bttv_i2c_algo_bit_template,
-		       sizeof(bttv_i2c_algo_bit_template));
-		btv->i2c_algo.data = btv;
-		btv->i2c_adap.algo_data = &btv->i2c_algo;
-	}
-
-	btv->i2c_adap.dev.parent = &btv->dev->dev;
-	snprintf(btv->i2c_adap.name, sizeof(btv->i2c_adap.name),
-		 "bt%d #%d [%s]", btv->id, btv->nr, use_hw ? "hw" : "sw");
-
-        i2c_set_adapdata(&btv->i2c_adap, btv);
-        btv->i2c_client.adapter = &btv->i2c_adap;
-
-	if (use_hw) {
-		btv->i2c_rc = i2c_add_adapter(&btv->i2c_adap);
-	} else {
-		bttv_bit_setscl(btv,1);
-		bttv_bit_setsda(btv,1);
-		btv->i2c_rc = i2c_bit_add_bus(&btv->i2c_adap);
-	}
-	return btv->i2c_rc;
-}
-
-int __devexit fini_bttv_i2c(struct bttv *btv)
-{
-	int use_hw = (btv->id == 878) && i2c_hw;
-
-	if (0 != btv->i2c_rc)
-		return 0;
-
-	if (use_hw) {
-		return i2c_del_adapter(&btv->i2c_adap);
-	} else {
-		return i2c_bit_del_bus(&btv->i2c_adap);
-	}
-}
-
 /*
  * Local variables:
  * c-basic-offset: 8
diff -puN drivers/media/video/bttvp.h~linus drivers/media/video/bttvp.h
--- 25/drivers/media/video/bttvp.h~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/bttvp.h	2004-01-19 22:17:22.000000000 -0800
@@ -41,13 +41,11 @@
 #include <media/video-buf.h>
 #include <media/audiochip.h>
 #include <media/tuner.h>
+#include <media/ir-common.h>
 
 #include "bt848.h"
 #include "bttv.h"
 #include "btcx-risc.h"
-#ifdef CONFIG_VIDEO_IR
-#include "ir-common.h"
-#endif
 
 #ifdef __KERNEL__
 
@@ -219,11 +217,14 @@ void bttv_vbi_setlines(struct bttv_fh *f
 extern struct videobuf_queue_ops bttv_vbi_qops;
 
 /* ---------------------------------------------------------- */
-/* bttv-input.c                                               */
+/* bttv-gpio.c */
+
+
+extern struct bus_type bttv_sub_bus_type;
+int bttv_sub_add_device(struct bttv_core *core, char *name);
+int bttv_sub_del_devices(struct bttv_core *core);
+void bttv_gpio_irq(struct bttv_core *core);
 
-int bttv_input_init(struct bttv *btv);
-void bttv_input_fini(struct bttv *btv);
-void bttv_input_irq(struct bttv *btv);
 
 /* ---------------------------------------------------------- */
 /* bttv-driver.c                                              */
@@ -263,7 +264,6 @@ struct bttv_pll_info {
 	unsigned int pll_current;  /* Currently programmed ofreq */
 };
 
-#ifdef CONFIG_VIDEO_IR
 /* for gpio-connected remote control */
 struct bttv_input {
 	struct input_dev      dev;
@@ -273,36 +273,46 @@ struct bttv_input {
 	u32                   mask_keycode;
 	u32                   mask_keydown;
 };
-#endif
+
+struct bttv_suspend_state {
+	u32  pci_cfg[64 / sizeof(u32)];
+	u32  gpio_enable;
+	u32  gpio_data;
+	int  disabled;
+	struct bttv_buffer_set set;
+};
 
 struct bttv {
+	struct bttv_core c;
+
 	/* pci device config */
-	struct pci_dev *dev;
 	unsigned short id;
 	unsigned char revision;
 	unsigned char *bt848_mmio;   /* pointer to mmio */
 
 	/* card configuration info */
-        unsigned int nr;       /* dev nr (for printk("bttv%d: ...");  */
-	char name[8];          /* dev name */
 	unsigned int cardid;   /* pci subsystem id (bt878 based ones) */
-	unsigned int type;     /* card type (pointer into tvcards[])  */
         unsigned int tuner_type;  /* tuner chip type */
         unsigned int pinnacle_id;
 	unsigned int svhs;
 	struct bttv_pll_info pll;
 	int triton1;
+	int gpioirq;
 
-	/* gpio interface */
+	/* old gpio interface */
 	wait_queue_head_t gpioq;
 	int shutdown;
 	void (*audio_hook)(struct bttv *btv, struct video_audio *v, int set);
-	
+
+	/* new gpio interface */
+	spinlock_t gpio_lock;
+
 	/* i2c layer */
-	struct i2c_adapter         i2c_adap;
 	struct i2c_algo_bit_data   i2c_algo;
 	struct i2c_client          i2c_client;
 	int                        i2c_state, i2c_rc;
+	int                        i2c_done;
+	wait_queue_head_t          i2c_queue;
 
 	/* video4linux (1) */
 	struct video_device *video_dev;
@@ -311,9 +321,7 @@ struct bttv {
 
 	/* infrared remote */
 	int has_remote;
-#ifdef CONFIG_VIDEO_IR
 	struct bttv_input *remote;
-#endif
 
 	/* locking */
 	spinlock_t s_lock;
@@ -339,6 +347,8 @@ struct bttv {
 	int opt_chroma_agc;
 	int opt_adc_crush;
 	int opt_vcr_hack;
+	int opt_whitecrush_upper;
+	int opt_whitecrush_lower;
 
 	/* radio data/state */
 	int has_radio;
@@ -371,6 +381,11 @@ struct bttv {
 	unsigned long cap_ctl;
 	unsigned long dma_on;
 	struct timer_list timeout;
+	struct bttv_suspend_state state;
+
+	/* stats */
+	unsigned int irq_total;
+	unsigned int irq_me;
 	unsigned int errors;
 
 	unsigned int users;
diff -puN drivers/media/video/bttv-risc.c~linus drivers/media/video/bttv-risc.c
--- 25/drivers/media/video/bttv-risc.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/bttv-risc.c	2004-01-19 22:17:22.000000000 -0800
@@ -5,7 +5,7 @@
 	- memory management
 	- generation
 
-    (c) 2000 Gerd Knorr <kraxel@bytesex.org>
+    (c) 2000-2003 Gerd Knorr <kraxel@bytesex.org>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -53,7 +53,7 @@ bttv_risc_packed(struct bttv *btv, struc
 	   one write per scan line + sync + jump (all 2 dwords) */
 	instructions  = (bpl * lines) / PAGE_SIZE + lines;
 	instructions += 2;
-	if ((rc = btcx_riscmem_alloc(btv->dev,risc,instructions*8)) < 0)
+	if ((rc = btcx_riscmem_alloc(btv->c.pci,risc,instructions*8)) < 0)
 		return rc;
 
 	/* sync instruction */
@@ -67,7 +67,7 @@ bttv_risc_packed(struct bttv *btv, struc
 		if ((btv->opt_vcr_hack) &&
 		    (line >= (lines - VCR_HACK_LINES)))
 			continue;
-		while (offset >= sg_dma_len(sg)) {
+		while (offset && offset >= sg_dma_len(sg)) {
 			offset -= sg_dma_len(sg);
 			sg++;
 		}
@@ -100,7 +100,7 @@ bttv_risc_packed(struct bttv *btv, struc
 		}
 		offset += padding;
 	}
-	dprintk("bttv%d: risc planar: %d sglist elems\n", btv->nr, (int)(sg-sglist));
+	dprintk("bttv%d: risc planar: %d sglist elems\n", btv->c.nr, (int)(sg-sglist));
 
 	/* save pointer to jmp instruction address */
 	risc->jmp = rp;
@@ -128,7 +128,7 @@ bttv_risc_planar(struct bttv *btv, struc
 	   plus sync + jump (2 dwords) */
 	instructions  = (ybpl * ylines * 2) / PAGE_SIZE + ylines;
 	instructions += 2;
-	if ((rc = btcx_riscmem_alloc(btv->dev,risc,instructions*4*5)) < 0)
+	if ((rc = btcx_riscmem_alloc(btv->c.pci,risc,instructions*4*5)) < 0)
 		return rc;
 
 	/* sync instruction */
@@ -152,15 +152,15 @@ bttv_risc_planar(struct bttv *btv, struc
 		}
 		for (todo = ybpl; todo > 0; todo -= ylen) {
 			/* go to next sg entry if needed */
-			while (yoffset >= sg_dma_len(ysg)) {
+			while (yoffset && yoffset >= sg_dma_len(ysg)) {
 				yoffset -= sg_dma_len(ysg);
 				ysg++;
 			}
-			while (uoffset >= sg_dma_len(usg)) {
+			while (uoffset && uoffset >= sg_dma_len(usg)) {
 				uoffset -= sg_dma_len(usg);
 				usg++;
 			}
-			while (voffset >= sg_dma_len(vsg)) {
+			while (voffset && voffset >= sg_dma_len(vsg)) {
 				voffset -= sg_dma_len(vsg);
 				vsg++;
 			}
@@ -227,7 +227,7 @@ bttv_risc_overlay(struct bttv *btv, stru
 	instructions  = (ov->nclips + 1) *
 		((skip_even || skip_odd) ? ov->w.height>>1 :  ov->w.height);
 	instructions += 2;
-	if ((rc = btcx_riscmem_alloc(btv->dev,risc,instructions*8)) < 0) {
+	if ((rc = btcx_riscmem_alloc(btv->c.pci,risc,instructions*8)) < 0) {
 		kfree(skips);
 		return rc;
 	}
@@ -247,9 +247,6 @@ bttv_risc_overlay(struct bttv *btv, stru
 		if ((btv->opt_vcr_hack) &&
 		     (line >= (ov->w.height - VCR_HACK_LINES)))
 			continue;
- 		if ((line%2) == 0  &&  skip_even)
- 			continue;
- 		if ((line%2) == 1  &&  skip_odd)
 		if ((line%2) == 0  &&  skip_even)
 			continue;
 		if ((line%2) == 1  &&  skip_odd)
@@ -310,7 +307,7 @@ bttv_calc_geo(struct bttv *btv, struct b
 	int totalwidth   = tvnorm->totalwidth;
 	int scaledtwidth = tvnorm->scaledtwidth;
 
-	if (bttv_tvcards[btv->type].muxsel[btv->input] < 0) {
+	if (bttv_tvcards[btv->c.type].muxsel[btv->input] < 0) {
 		swidth       = 720;
 		totalwidth   = 858;
 		scaledtwidth = 858;
@@ -391,7 +388,7 @@ bttv_set_dma(struct bttv *btv, int overr
 
 	d2printk(KERN_DEBUG
 		 "bttv%d: capctl=%x irq=%d top=%08Lx/%08Lx even=%08Lx/%08Lx\n",
-		 btv->nr,capctl,irqflags,
+		 btv->c.nr,capctl,irqflags,
 		 btv->curr.vbi     ? (unsigned long long)btv->curr.vbi->top.dma        : 0,
 		 btv->curr.top     ? (unsigned long long)btv->curr.top->top.dma        : 0,
 		 btv->curr.vbi     ? (unsigned long long)btv->curr.vbi->bottom.dma     : 0,
@@ -429,10 +426,10 @@ bttv_risc_init_main(struct bttv *btv)
 {
 	int rc;
 	
-	if ((rc = btcx_riscmem_alloc(btv->dev,&btv->main,PAGE_SIZE)) < 0)
+	if ((rc = btcx_riscmem_alloc(btv->c.pci,&btv->main,PAGE_SIZE)) < 0)
 		return rc;
 	dprintk(KERN_DEBUG "bttv%d: risc main @ %08Lx\n",
-		btv->nr,(unsigned long long)btv->main.dma);
+		btv->c.nr,(unsigned long long)btv->main.dma);
 
 	btv->main.cpu[0] = cpu_to_le32(BT848_RISC_SYNC | BT848_RISC_RESYNC |
 				       BT848_FIFO_STATUS_VRE);
@@ -472,11 +469,11 @@ bttv_risc_hook(struct bttv *btv, int slo
 
 	if (NULL == risc) {
 		d2printk(KERN_DEBUG "bttv%d: risc=%p slot[%d]=NULL\n",
-			 btv->nr,risc,slot);
+			 btv->c.nr,risc,slot);
 		btv->main.cpu[slot+1] = cpu_to_le32(next);
 	} else {
 		d2printk(KERN_DEBUG "bttv%d: risc=%p slot[%d]=%08Lx irq=%d\n",
-			 btv->nr,risc,slot,(unsigned long long)risc->dma,irqflags);
+			 btv->c.nr,risc,slot,(unsigned long long)risc->dma,irqflags);
 		cmd = BT848_RISC_JUMP;
 		if (irqflags) {
 			cmd |= BT848_RISC_IRQ;
@@ -496,10 +493,10 @@ bttv_dma_free(struct bttv *btv, struct b
 	if (in_interrupt())
 		BUG();
 	videobuf_waiton(&buf->vb,0,0);
-	videobuf_dma_pci_unmap(btv->dev, &buf->vb.dma);
+	videobuf_dma_pci_unmap(btv->c.pci, &buf->vb.dma);
 	videobuf_dma_free(&buf->vb.dma);
-	btcx_riscmem_free(btv->dev,&buf->bottom);
-	btcx_riscmem_free(btv->dev,&buf->top);
+	btcx_riscmem_free(btv->c.pci,&buf->bottom);
+	btcx_riscmem_free(btv->c.pci,&buf->top);
 	buf->vb.state = STATE_NEEDS_INIT;
 }
 
@@ -577,7 +574,7 @@ bttv_buffer_risc(struct bttv *btv, struc
 
 	dprintk(KERN_DEBUG
 		"bttv%d: buffer field: %s  format: %s  size: %dx%d\n",
-		btv->nr, v4l2_field_names[buf->vb.field],
+		btv->c.nr, v4l2_field_names[buf->vb.field],
 		buf->fmt->name, buf->vb.width, buf->vb.height);
 
 	/* packed pixel modes */
@@ -731,7 +728,7 @@ bttv_overlay_risc(struct bttv *btv,
 	/* check interleave, bottom+top fields */
 	dprintk(KERN_DEBUG
 		"bttv%d: overlay fields: %s format: %s  size: %dx%d\n",
-		btv->nr, v4l2_field_names[buf->vb.field],
+		btv->c.nr, v4l2_field_names[buf->vb.field],
 		fmt->name,ov->w.width,ov->w.height);
 
 	/* calculate geometry */
diff -puN drivers/media/video/bttv-vbi.c~linus drivers/media/video/bttv-vbi.c
--- 25/drivers/media/video/bttv-vbi.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/bttv-vbi.c	2004-01-19 22:17:22.000000000 -0800
@@ -44,7 +44,7 @@ MODULE_PARM_DESC(vbi_debug,"vbi code deb
 # undef dprintk
 #endif
 #define dprintk(fmt, arg...)	if (vbi_debug) \
-	printk(KERN_DEBUG "bttv%d/vbi: " fmt, btv->nr, ## arg)
+	printk(KERN_DEBUG "bttv%d/vbi: " fmt, btv->c.nr , ## arg)
 
 /* ----------------------------------------------------------------------- */
 /* vbi risc code + mm                                                      */
@@ -87,7 +87,7 @@ static int vbi_buffer_prepare(struct fil
 		return -EINVAL;
 
 	if (STATE_NEEDS_INIT == buf->vb.state) {
-		if (0 != (rc = videobuf_iolock(btv->dev, &buf->vb, NULL)))
+		if (0 != (rc = videobuf_iolock(btv->c.pci, &buf->vb, NULL)))
 			goto fail;
 		if (0 != (rc = vbi_buffer_risc(btv,buf,fh->lines)))
 			goto fail;
diff -puN /dev/null drivers/media/video/cx88/cx88-cards.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/media/video/cx88/cx88-cards.c	2004-01-19 22:17:22.000000000 -0800
@@ -0,0 +1,396 @@
+/*
+ * device driver for Conexant 2388x based TV cards
+ * card-specific stuff.
+ *
+ * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+
+#include "cx88.h"
+
+/* ------------------------------------------------------------------ */
+/* board config info                                                  */
+
+struct cx88_board cx88_boards[] = {
+	[CX88_BOARD_UNKNOWN] = {
+		.name		= "UNKNOWN/GENERIC",
+		.tuner_type     = UNSET,
+		.input          = {{
+			.type   = CX88_VMUX_COMPOSITE1,
+			.vmux   = 0,
+		},{
+			.type   = CX88_VMUX_COMPOSITE2,
+			.vmux   = 1,
+		},{
+			.type   = CX88_VMUX_COMPOSITE3,
+			.vmux   = 2,
+		},{
+			.type   = CX88_VMUX_COMPOSITE4,
+			.vmux   = 3,
+		}},
+	},
+	[CX88_BOARD_HAUPPAUGE] = {
+		.name		= "Hauppauge WinTV 34xxx models",
+		.tuner_type     = UNSET,
+		.input          = {{
+			.type   = CX88_VMUX_TELEVISION,
+			.vmux   = 0,
+			//.gpio0  = 0xff03,
+			.gpio0  = 0xff01,
+		},{
+			.type   = CX88_VMUX_DEBUG,
+			.vmux   = 0,
+			.gpio0  = 0xff00,
+		},{
+			.type   = CX88_VMUX_COMPOSITE1,
+			.vmux   = 1,
+			.gpio0  = 0xff02,
+		}},
+		.radio = {
+			.type   = CX88_RADIO,
+			.gpio0  = 0xff01,
+		},
+	},
+	[CX88_BOARD_GDI] = {
+		.name		= "GDI Black Gold",
+		.tuner_type     = UNSET,
+		.input          = {{
+			.type   = CX88_VMUX_TELEVISION,
+			.vmux   = 0,
+		}},
+	},
+	[CX88_BOARD_PIXELVIEW] = {
+		.name           = "PixelView",
+		.tuner_type     = UNSET,
+		.input          = {{
+			.type   = CX88_VMUX_TELEVISION,
+			.vmux   = 0,
+		},{
+			.type   = CX88_VMUX_COMPOSITE1,
+			.vmux   = 1,
+		},{
+			.type   = CX88_VMUX_SVIDEO,
+			.vmux   = 2,
+		}},
+	},
+	[CX88_BOARD_ATI_WONDER_PRO] = {
+		.name           = "ATI TV Wonder Pro",
+		.tuner_type     = UNSET,
+		.input          = {{
+			.type   = CX88_VMUX_TELEVISION,
+			.vmux   = 0,
+		}},
+	},
+        [CX88_BOARD_WINFAST2000XP] = {
+                .name           = "Leadtek Winfast 2000XP Expert",
+                .tuner_type     = 38,
+                .input          = {{
+                        .type   = CX88_VMUX_TELEVISION,
+                        .vmux   = 0,
+                }},
+                .radio = {
+                        .type   = CX88_RADIO,
+                },
+        },
+	[CX88_BOARD_AVERTV_303] = {
+		.name           = "AverTV Studio 303 (M126)",
+		.tuner_type     = TUNER_PHILIPS_PAL_DK,
+		.input          = {{
+			.type   = CX88_VMUX_TELEVISION,
+			.vmux   = 0,
+		}},
+	},
+	[CX88_BOARD_MSI_TVANYWHERE] = {
+		.name           = "MSI TV-@nywhere Master",
+		.tuner_type     = 33,
+		.input          = {{
+			.type   = CX88_VMUX_TELEVISION,
+			.vmux   = 0,
+		},{
+                        .type   = CX88_VMUX_COMPOSITE1,
+                        .vmux   = 1,
+		},{
+                        .type   = CX88_VMUX_SVIDEO,
+                        .vmux   = 2,
+                }},
+                .radio = {
+                        .type   = CX88_RADIO,
+                },
+	},
+	[CX88_BOARD_WINFAST_DV2000] = {
+                .name           = "Leadtek Winfast DV2000",
+                .tuner_type     = 38,
+                .input          = {{
+                        .type   = CX88_VMUX_TELEVISION,
+                        .vmux   = 0,
+                }},
+                .radio = {
+                        .type   = CX88_RADIO,
+                },
+        },
+
+};
+const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards);
+
+/* ------------------------------------------------------------------ */
+/* PCI subsystem IDs                                                  */
+
+struct cx88_subid cx88_subids[] = {
+	{
+		.subvendor = 0x0070,
+		.subdevice = 0x3400,
+		.card      = CX88_BOARD_HAUPPAUGE,
+	},{
+		.subvendor = 0x0070,
+		.subdevice = 0x3401,
+		.card      = CX88_BOARD_HAUPPAUGE,
+	},{
+		.subvendor = 0x14c7,
+		.subdevice = 0x0106,
+		.card      = CX88_BOARD_GDI,
+	},{
+		.subvendor = 0x14c7,
+		.subdevice = 0x0107, /* with mpeg encoder */
+		.card      = CX88_BOARD_GDI,
+	},{
+		.subvendor = PCI_VENDOR_ID_ATI,
+		.subdevice = 0x00f8,
+		.card      = CX88_BOARD_ATI_WONDER_PRO,
+	},{
+                .subvendor = 0x107d,
+                .subdevice = 0x6611,
+                .card      = CX88_BOARD_WINFAST2000XP,
+	},{
+		.subvendor = 0x107d,
+                .subdevice = 0x6620,
+                .card      = CX88_BOARD_WINFAST_DV2000,
+        },{
+		.subvendor = 0x1461,
+		.subdevice = 0x000b,
+		.card      = CX88_BOARD_AVERTV_303,
+	},{
+		.subvendor = 0x1462,
+		.subdevice = 0x8606,
+		.card      = CX88_BOARD_MSI_TVANYWHERE,
+	}
+};
+const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
+
+/* ----------------------------------------------------------------------- */
+/* some hauppauge specific stuff                                           */
+
+static struct {
+        int  id;
+        char *name;
+} hauppauge_tuner[] __devinitdata = {
+        { TUNER_ABSENT,        "" },
+        { TUNER_ABSENT,        "External" },
+        { TUNER_ABSENT,        "Unspecified" },
+        { TUNER_PHILIPS_PAL,   "Philips FI1216" },
+        { TUNER_PHILIPS_SECAM, "Philips FI1216MF" },
+        { TUNER_PHILIPS_NTSC,  "Philips FI1236" },
+        { TUNER_PHILIPS_PAL_I, "Philips FI1246" },
+        { TUNER_PHILIPS_PAL_DK,"Philips FI1256" },
+        { TUNER_PHILIPS_PAL,   "Philips FI1216 MK2" },
+        { TUNER_PHILIPS_SECAM, "Philips FI1216MF MK2" },
+        { TUNER_PHILIPS_NTSC,  "Philips FI1236 MK2" },
+        { TUNER_PHILIPS_PAL_I, "Philips FI1246 MK2" },
+        { TUNER_PHILIPS_PAL_DK,"Philips FI1256 MK2" },
+        { TUNER_TEMIC_NTSC,    "Temic 4032FY5" },
+        { TUNER_TEMIC_PAL,     "Temic 4002FH5" },
+        { TUNER_TEMIC_PAL_I,   "Temic 4062FY5" },
+        { TUNER_PHILIPS_PAL,   "Philips FR1216 MK2" },
+        { TUNER_PHILIPS_SECAM, "Philips FR1216MF MK2" },
+        { TUNER_PHILIPS_NTSC,  "Philips FR1236 MK2" },
+        { TUNER_PHILIPS_PAL_I, "Philips FR1246 MK2" },
+        { TUNER_PHILIPS_PAL_DK,"Philips FR1256 MK2" },
+        { TUNER_PHILIPS_PAL,   "Philips FM1216" },
+        { TUNER_PHILIPS_SECAM, "Philips FM1216MF" },
+        { TUNER_PHILIPS_NTSC,  "Philips FM1236" },
+        { TUNER_PHILIPS_PAL_I, "Philips FM1246" },
+        { TUNER_PHILIPS_PAL_DK,"Philips FM1256" },
+        { TUNER_TEMIC_4036FY5_NTSC, "Temic 4036FY5" },
+        { TUNER_ABSENT,        "Samsung TCPN9082D" },
+        { TUNER_ABSENT,        "Samsung TCPM9092P" },
+        { TUNER_TEMIC_4006FH5_PAL, "Temic 4006FH5" },
+        { TUNER_ABSENT,        "Samsung TCPN9085D" },
+        { TUNER_ABSENT,        "Samsung TCPB9085P" },
+        { TUNER_ABSENT,        "Samsung TCPL9091P" },
+        { TUNER_TEMIC_4039FR5_NTSC, "Temic 4039FR5" },
+        { TUNER_PHILIPS_FQ1216ME,   "Philips FQ1216 ME" },
+        { TUNER_TEMIC_4066FY5_PAL_I, "Temic 4066FY5" },
+        { TUNER_PHILIPS_NTSC,        "Philips TD1536" },
+        { TUNER_PHILIPS_NTSC,        "Philips TD1536D" },
+	{ TUNER_PHILIPS_NTSC,  "Philips FMR1236" }, /* mono radio */
+        { TUNER_ABSENT,        "Philips FI1256MP" },
+        { TUNER_ABSENT,        "Samsung TCPQ9091P" },
+        { TUNER_TEMIC_4006FN5_MULTI_PAL, "Temic 4006FN5" },
+        { TUNER_TEMIC_4009FR5_PAL, "Temic 4009FR5" },
+        { TUNER_TEMIC_4046FM5,     "Temic 4046FM5" },
+	{ TUNER_TEMIC_4009FN5_MULTI_PAL_FM, "Temic 4009FN5" },
+	{ TUNER_ABSENT,        "Philips TD1536D_FH_44"},
+	{ TUNER_LG_NTSC_FM,    "LG TPI8NSR01F"},
+	{ TUNER_LG_PAL_FM,     "LG TPI8PSB01D"},
+	{ TUNER_LG_PAL,        "LG TPI8PSB11D"},	
+	{ TUNER_LG_PAL_I_FM,   "LG TAPC-I001D"},
+	{ TUNER_LG_PAL_I,      "LG TAPC-I701D"}
+};
+
+static void __devinit hauppauge_eeprom(struct cx8800_dev *dev, u8 *eeprom_data)
+{
+	unsigned int blk2,tuner,radio,model;
+
+	if (eeprom_data[0] != 0x84 || eeprom_data[2] != 0) {
+		printk(KERN_WARNING "%s: Hauppauge eeprom: invalid\n",
+		       dev->name);
+		return;
+	}
+
+	/* Block 2 starts after len+3 bytes header */
+	blk2 = eeprom_data[1] + 3;
+
+	/* decode + use some config infos */
+	model = eeprom_data[12] << 8 | eeprom_data[11];
+	tuner = eeprom_data[9];
+	radio = eeprom_data[blk2-1] & 0x01;
+	
+        if (tuner < ARRAY_SIZE(hauppauge_tuner))
+                dev->tuner_type = hauppauge_tuner[tuner].id;
+	if (radio)
+		dev->has_radio = 1;
+	
+	printk(KERN_INFO "%s: hauppauge eeprom: model=%d, "
+	       "tuner=%s (%d), radio=%s\n",
+	       dev->name, model, hauppauge_tuner[tuner].name,
+	       dev->tuner_type, radio ? "yes" : "no");
+}
+
+/* ----------------------------------------------------------------------- */
+/* some GDI (was: Modular Technology) specific stuff                       */
+
+static struct {
+	int  id;
+	int  fm;
+	char *name;
+} gdi_tuner[] = {
+	[ 0x01 ] = { .id   = TUNER_ABSENT,
+		     .name = "NTSC_M" },
+	[ 0x02 ] = { .id   = TUNER_ABSENT,
+		     .name = "PAL_B" },
+	[ 0x03 ] = { .id   = TUNER_ABSENT,
+		     .name = "BAL_I" },
+	[ 0x04 ] = { .id   = TUNER_ABSENT,
+		     .name = "PAL_D" },
+	[ 0x05 ] = { .id   = TUNER_ABSENT,
+		     .name = "SECAM" },
+
+	[ 0x10 ] = { .id   = TUNER_ABSENT, .fm = 1, 
+		     .name = "TEMIC_4049" },
+	[ 0x11 ] = { .id   = TUNER_TEMIC_4136FY5,
+		     .name = "TEMIC_4136" },
+	[ 0x12 ] = { .id   = TUNER_ABSENT,
+		     .name = "TEMIC_4146" },
+
+	[ 0x20 ] = { .id   = TUNER_PHILIPS_FQ1216ME, .fm = 1,
+		     .name = "PHILIPS_FQ1216_MK3" },
+	[ 0x21 ] = { .id   = TUNER_ABSENT, .fm = 1,
+		     .name = "PHILIPS_FQ1236_MK3" },
+	[ 0x22 ] = { .id   = TUNER_ABSENT,
+		     .name = "PHILIPS_FI1236_MK3" },
+	[ 0x23 ] = { .id   = TUNER_ABSENT,
+		     .name = "PHILIPS_FI1216_MK3" },
+};
+
+static void __devinit gdi_eeprom(struct cx8800_dev *dev, u8 *eeprom_data)
+{
+	char *name = (eeprom_data[0x0d] < ARRAY_SIZE(gdi_tuner))
+		? gdi_tuner[eeprom_data[0x0d]].name : NULL;
+
+	printk(KERN_INFO "%s: GDI: tuner=%s\n", dev->name,
+	       name ? name : "unknown");
+	if (NULL == name)
+		return;
+	dev->tuner_type = gdi_tuner[eeprom_data[0x0d]].id;
+	dev->has_radio  = gdi_tuner[eeprom_data[0x0d]].fm;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int
+i2c_eeprom(struct i2c_client *c, unsigned char *eedata, int len)
+{
+	unsigned char buf;
+	int err;
+
+	c->addr = 0xa0 >> 1;
+	buf = 0;
+	if (1 != (err = i2c_master_send(c,&buf,1))) {
+		printk(KERN_INFO "cx88: Huh, no eeprom present (err=%d)?\n",
+		       err);
+		return -1;
+	}
+	if (len != (err = i2c_master_recv(c,eedata,len))) {
+		printk(KERN_WARNING "cx88: i2c eeprom read error (err=%d)\n",
+		       err);
+		return -1;
+	}
+#if 0
+	for (i = 0; i < len; i++) {
+		if (0 == (i % 16))
+			printk(KERN_INFO "cx88 ee: %02x:",i);
+		printk(" %02x",eedata[i]);
+		if (15 == (i % 16))
+			printk("\n");
+	}
+#endif
+	return 0;
+}
+
+void __devinit cx88_card_setup(struct cx8800_dev *dev)
+{
+	static u8 eeprom[128];
+		
+	switch (dev->board) {
+	case CX88_BOARD_HAUPPAUGE:
+		if (0 == dev->i2c_rc)
+			i2c_eeprom(&dev->i2c_client,eeprom,sizeof(eeprom));
+		hauppauge_eeprom(dev,eeprom+8);
+		break;
+	case CX88_BOARD_GDI:
+		if (0 == dev->i2c_rc)
+			i2c_eeprom(&dev->i2c_client,eeprom,sizeof(eeprom));
+		gdi_eeprom(dev,eeprom);
+		break;
+	}
+}
+
+/* ------------------------------------------------------------------ */
+
+EXPORT_SYMBOL(cx88_boards);
+EXPORT_SYMBOL(cx88_bcount);
+EXPORT_SYMBOL(cx88_subids);
+EXPORT_SYMBOL(cx88_idcount);
+EXPORT_SYMBOL(cx88_card_setup);
+
+/*
+ * Local variables:
+ * c-basic-offset: 8
+ * End:
+ */
diff -puN /dev/null drivers/media/video/cx88/cx88-core.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/media/video/cx88/cx88-core.c	2004-01-19 22:17:22.000000000 -0800
@@ -0,0 +1,612 @@
+/*
+ * device driver for Conexant 2388x based TV cards
+ * driver core
+ *
+ * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/init.h>
+#include <linux/list.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/kmod.h>
+#include <linux/sound.h>
+#include <linux/interrupt.h>
+#include <linux/pci.h>
+#include <linux/videodev.h>
+
+#include "cx88.h"
+
+MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards");
+MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
+MODULE_LICENSE("GPL");
+
+/* ------------------------------------------------------------------ */
+
+#if 0
+static unsigned int gpio_tracking = 0;
+MODULE_PARM(gpio_tracking,"i");
+MODULE_PARM_DESC(gpio_tracking,"enable debug messages [gpio]");
+
+static unsigned int ts_nr = -1;
+MODULE_PARM(ts_nr,"i");
+MODULE_PARM_DESC(ts_nr,"ts device number");
+
+static unsigned int vbi_nr = -1;
+MODULE_PARM(vbi_nr,"i");
+MODULE_PARM_DESC(vbi_nr,"vbi device number");
+
+static unsigned int radio_nr = -1;
+MODULE_PARM(radio_nr,"i");
+MODULE_PARM_DESC(radio_nr,"radio device number");
+
+static unsigned int oss = 0;
+MODULE_PARM(oss,"i");
+MODULE_PARM_DESC(oss,"register oss devices (default: no)");
+
+static unsigned int dsp_nr = -1;
+MODULE_PARM(dsp_nr,"i");
+MODULE_PARM_DESC(dsp_nr,"oss dsp device number");
+
+static unsigned int mixer_nr = -1;
+MODULE_PARM(mixer_nr,"i");
+MODULE_PARM_DESC(mixer_nr,"oss mixer device number");
+#endif
+
+static unsigned int core_debug = 0;
+MODULE_PARM(core_debug,"i");
+MODULE_PARM_DESC(core_debug,"enable debug messages [core]");
+
+#define dprintk(fmt, arg...)	if (core_debug) \
+	printk(KERN_DEBUG "%s/core: " fmt, dev->name , ## arg)
+
+/* ------------------------------------------------------------------ */
+/* debug help functions                                               */
+
+static const char *v4l1_ioctls[] = {
+	"0", "CGAP", "GCHAN", "SCHAN", "GTUNER", "STUNER", "GPICT", "SPICT",
+	"CCAPTURE", "GWIN", "SWIN", "GFBUF", "SFBUF", "KEY", "GFREQ",
+	"SFREQ", "GAUDIO", "SAUDIO", "SYNC", "MCAPTURE", "GMBUF", "GUNIT",
+	"GCAPTURE", "SCAPTURE", "SPLAYMODE", "SWRITEMODE", "GPLAYINFO",
+	"SMICROCODE", "GVBIFMT", "SVBIFMT" };
+#define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls)
+
+static const char *v4l2_ioctls[] = {
+	"QUERYCAP", "1", "ENUM_PIXFMT", "ENUM_FBUFFMT", "G_FMT", "S_FMT",
+	"G_COMP", "S_COMP", "REQBUFS", "QUERYBUF", "G_FBUF", "S_FBUF",
+	"G_WIN", "S_WIN", "PREVIEW", "QBUF", "16", "DQBUF", "STREAMON",
+	"STREAMOFF", "G_PERF", "G_PARM", "S_PARM", "G_STD", "S_STD",
+	"ENUMSTD", "ENUMINPUT", "G_CTRL", "S_CTRL", "G_TUNER", "S_TUNER",
+	"G_FREQ", "S_FREQ", "G_AUDIO", "S_AUDIO", "35", "QUERYCTRL",
+	"QUERYMENU", "G_INPUT", "S_INPUT", "ENUMCVT", "41", "42", "43",
+	"44", "45",  "G_OUTPUT", "S_OUTPUT", "ENUMOUTPUT", "G_AUDOUT",
+	"S_AUDOUT", "ENUMFX", "G_EFFECT", "S_EFFECT", "G_MODULATOR",
+	"S_MODULATOR"
+};
+#define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
+
+static const char *osspcm_ioctls[] = {
+	"RESET", "SYNC", "SPEED", "STEREO", "GETBLKSIZE", "SETFMT",
+	"CHANNELS", "?", "POST", "SUBDIVIDE", "SETFRAGMENT", "GETFMTS",
+	"GETOSPACE", "GETISPACE", "NONBLOCK", "GETCAPS", "GET/SETTRIGGER",
+	"GETIPTR", "GETOPTR", "MAPINBUF", "MAPOUTBUF", "SETSYNCRO",
+	"SETDUPLEX", "GETODELAY"
+};
+#define OSSPCM_IOCTLS ARRAY_SIZE(v4l2_ioctls)
+
+void cx88_print_ioctl(char *name, unsigned int cmd)
+{
+	char *dir;
+
+	switch (_IOC_DIR(cmd)) {
+	case _IOC_NONE:              dir = "--"; break;
+	case _IOC_READ:              dir = "r-"; break;
+	case _IOC_WRITE:             dir = "-w"; break;
+	case _IOC_READ | _IOC_WRITE: dir = "rw"; break;
+	default:                     dir = "??"; break;
+	}
+	switch (_IOC_TYPE(cmd)) {
+	case 'v':
+		printk(KERN_DEBUG "%s: ioctl 0x%08x (v4l1, %s, VIDIOC%s)\n",
+		       name, cmd, dir, (_IOC_NR(cmd) < V4L1_IOCTLS) ?
+		       v4l1_ioctls[_IOC_NR(cmd)] : "???");
+		break;
+	case 'V':
+		printk(KERN_DEBUG "%s: ioctl 0x%08x (v4l2, %s, VIDIOC_%s)\n",
+		       name, cmd, dir, (_IOC_NR(cmd) < V4L2_IOCTLS) ?
+		       v4l2_ioctls[_IOC_NR(cmd)] : "???");
+		break;
+	case 'P':
+		printk(KERN_DEBUG "%s: ioctl 0x%08x (oss dsp, %s, SNDCTL_DSP_%s)\n",
+		       name, cmd, dir, (_IOC_NR(cmd) < OSSPCM_IOCTLS) ?
+		       osspcm_ioctls[_IOC_NR(cmd)] : "???");
+		break;
+	case 'M':
+		printk(KERN_DEBUG "%s: ioctl 0x%08x (oss mixer, %s, #%d)\n",
+		       name, cmd, dir, _IOC_NR(cmd));
+		break;
+	default:
+		printk(KERN_DEBUG "%s: ioctl 0x%08x (???, %s, #%d)\n",
+		       name, cmd, dir, _IOC_NR(cmd));
+	}
+}
+
+/* ------------------------------------------------------------------ */
+
+static u32* cx88_risc_field(u32 *rp, struct scatterlist *sglist,
+			    unsigned int offset, u32 sync_line,
+			    unsigned int bpl, unsigned int padding,
+			    unsigned int lines)
+{
+	struct scatterlist *sg;
+	unsigned int line,todo;
+
+	/* sync instruction */
+	*(rp++) = cpu_to_le32(RISC_RESYNC | sync_line);
+	
+	/* scan lines */
+	sg = sglist;
+	for (line = 0; line < lines; line++) {
+		while (offset && offset >= sg_dma_len(sg)) {
+			offset -= sg_dma_len(sg);
+			sg++;
+		}
+		if (bpl <= sg_dma_len(sg)-offset) {
+			/* fits into current chunk */
+                        *(rp++)=cpu_to_le32(RISC_WRITE|RISC_SOL|RISC_EOL|bpl);
+                        *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset);
+                        offset+=bpl;
+		} else {
+			/* scanline needs to be splitted */
+                        todo = bpl;
+                        *(rp++)=cpu_to_le32(RISC_WRITE|RISC_SOL|
+					    (sg_dma_len(sg)-offset));
+                        *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset);
+                        todo -= (sg_dma_len(sg)-offset);
+                        offset = 0;
+                        sg++;
+                        while (todo > sg_dma_len(sg)) {
+                                *(rp++)=cpu_to_le32(RISC_WRITE|
+						    sg_dma_len(sg));
+                                *(rp++)=cpu_to_le32(sg_dma_address(sg));
+				todo -= sg_dma_len(sg);
+				sg++;
+			}
+                        *(rp++)=cpu_to_le32(RISC_WRITE|RISC_EOL|todo);
+			*(rp++)=cpu_to_le32(sg_dma_address(sg));
+			offset += todo;
+		}
+		offset += padding;
+	}
+
+	return rp;
+}
+
+int cx88_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
+		     struct scatterlist *sglist,
+		     unsigned int top_offset, unsigned int bottom_offset,
+		     unsigned int bpl, unsigned int padding, unsigned int lines)
+{
+	u32 instructions,fields;
+	u32 *rp;
+	int rc;
+
+	fields = 0;
+	if (UNSET != top_offset)
+		fields++;
+	if (UNSET != bottom_offset)
+		fields++;
+
+	/* estimate risc mem: worst case is one write per page border +
+	   one write per scan line + syncs + jump (all 2 dwords) */
+	instructions  = (bpl * lines * fields) / PAGE_SIZE + lines * fields;
+	instructions += 3 + 4;
+	if ((rc = btcx_riscmem_alloc(pci,risc,instructions*8)) < 0)
+		return rc;
+
+	/* write risc instructions */
+	rp = risc->cpu;
+	if (UNSET != top_offset)
+		rp = cx88_risc_field(rp, sglist, top_offset, 0,
+				     bpl, padding, lines);
+	if (UNSET != bottom_offset)
+		rp = cx88_risc_field(rp, sglist, bottom_offset, 0x200,
+				     bpl, padding, lines);
+
+	/* save pointer to jmp instruction address */
+	risc->jmp = rp;
+	return 0;
+}
+
+int cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
+		      u32 reg, u32 mask, u32 value)
+{
+	u32 *rp;
+	int rc;
+
+	if ((rc = btcx_riscmem_alloc(pci, risc, 4*16)) < 0)
+		return rc;
+
+	/* write risc instructions */
+	rp = risc->cpu;
+	*(rp++) = cpu_to_le32(RISC_WRITECR  | RISC_IRQ2 | RISC_IMM);
+	*(rp++) = cpu_to_le32(reg);
+	*(rp++) = cpu_to_le32(value);
+	*(rp++) = cpu_to_le32(mask);
+	*(rp++) = cpu_to_le32(RISC_JUMP);
+	*(rp++) = cpu_to_le32(risc->dma);
+	return 0;
+}
+
+void
+cx88_free_buffer(struct pci_dev *pci, struct cx88_buffer *buf)
+{
+	if (in_interrupt())
+		BUG();
+	videobuf_waiton(&buf->vb,0,0);
+	videobuf_dma_pci_unmap(pci, &buf->vb.dma);
+	videobuf_dma_free(&buf->vb.dma);
+	btcx_riscmem_free(pci, &buf->risc);
+	buf->vb.state = STATE_NEEDS_INIT;
+}
+
+/* ------------------------------------------------------------------ */
+/* our SRAM memory layout                                             */
+
+/* we are going to put all thr risc programs into host memory, so we
+ * can use the whole SDRAM for the DMA fifos.  To simplify things, we
+ * use a static memory layout.  That surely will waste memory in case
+ * we don't use all DMA channels at the same time (which will be the
+ * case most of the time).  But that still gives us enougth FIFO space
+ * to be able to deal with insane long pci latencies ...
+ *
+ * FIFO space allocations:
+ *    channel  21    (y video)  - 10.0k
+ *    channel  24    (vbi)      -  4.0k
+ *    channels 25+26 (audio)    -  0.5k
+ *    everything else           -  2.0k
+ *    TOTAL                     = 29.0k
+ *
+ * Every channel has 160 bytes control data (64 bytes instruction
+ * queue and 6 CDT entries), which is close to 2k total.
+ * 
+ * Address layout:
+ *    0x0000 - 0x03ff    CMDs / reserved
+ *    0x0400 - 0x0bff    instruction queues + CDs
+ *    0x0c00 -           FIFOs
+ */
+
+struct sram_channel cx88_sram_channels[] = {
+	[SRAM_CH21] = {
+		.name       = "video y / packed",
+		.cmds_start = 0x180040,
+		.ctrl_start = 0x180400,
+		.fifo_start = 0x180c00,
+		.fifo_size  = 0x002800,
+		.ptr1_reg   = MO_DMA21_PTR1,
+		.ptr2_reg   = MO_DMA21_PTR2,
+		.cnt1_reg   = MO_DMA21_CNT1,
+		.cnt2_reg   = MO_DMA21_CNT2,
+	},
+	[SRAM_CH22] = {
+		.name       = "video u",
+		.cmds_start = 0x180080,
+		.ctrl_start = 0x1804a0,
+		.fifo_start = 0x183400,
+		.fifo_size  = 0x000800,
+		.ptr1_reg   = MO_DMA22_PTR1,
+		.ptr2_reg   = MO_DMA22_PTR2,
+		.cnt1_reg   = MO_DMA22_CNT1,
+		.cnt2_reg   = MO_DMA22_CNT2,
+	},
+	[SRAM_CH23] = {
+		.name       = "video v",
+		.cmds_start = 0x1800c0,
+		.ctrl_start = 0x180540,
+		.fifo_start = 0x183c00,
+		.fifo_size  = 0x000800,
+		.ptr1_reg   = MO_DMA23_PTR1,
+		.ptr2_reg   = MO_DMA23_PTR2,
+		.cnt1_reg   = MO_DMA23_CNT1,
+		.cnt2_reg   = MO_DMA23_CNT2,
+	},
+	[SRAM_CH24] = {
+		.name       = "vbi",
+		.cmds_start = 0x180100,
+		.ctrl_start = 0x1805e0,
+		.fifo_start = 0x184400,
+		.fifo_size  = 0x001000,
+		.ptr1_reg   = MO_DMA24_PTR1,
+		.ptr2_reg   = MO_DMA24_PTR2,
+		.cnt1_reg   = MO_DMA24_CNT1,
+		.cnt2_reg   = MO_DMA24_CNT2,
+	},
+	[SRAM_CH25] = {
+		.name       = "audio from",
+		.cmds_start = 0x180140,
+		.ctrl_start = 0x180680,
+		.fifo_start = 0x185400,
+		.fifo_size  = 0x000200,
+		.ptr1_reg   = MO_DMA25_PTR1,
+		.ptr2_reg   = MO_DMA25_PTR2,
+		.cnt1_reg   = MO_DMA25_CNT1,
+		.cnt2_reg   = MO_DMA25_CNT2,
+	},
+	[SRAM_CH26] = {
+		.name       = "audio to",
+		.cmds_start = 0x180180,
+		.ctrl_start = 0x180720,
+		.fifo_start = 0x185600,
+		.fifo_size  = 0x000200,
+		.ptr1_reg   = MO_DMA26_PTR1,
+		.ptr2_reg   = MO_DMA26_PTR2,
+		.cnt1_reg   = MO_DMA26_CNT1,
+		.cnt2_reg   = MO_DMA26_CNT2,
+	},
+};
+
+int cx88_sram_channel_setup(struct cx8800_dev *dev,
+			    struct sram_channel *ch,
+			    unsigned int bpl, u32 risc)
+{
+	unsigned int i,lines;
+	u32 cdt;
+
+	bpl   = (bpl + 7) & ~7; /* alignment */
+	cdt   = ch->ctrl_start + 64;
+	lines = ch->fifo_size / bpl;
+	if (lines > 6)
+		lines = 6;
+	BUG_ON(lines < 2);
+
+	/* write CDT */
+	for (i = 0; i < lines; i++)
+		cx_write(cdt + 16*i, ch->fifo_start + bpl*i);
+
+	/* write CMDS */
+	cx_write(ch->cmds_start +  0, risc);
+	cx_write(ch->cmds_start +  4, cdt);
+	cx_write(ch->cmds_start +  8, (lines*16) >> 3);
+	cx_write(ch->cmds_start + 12, ch->ctrl_start);
+	cx_write(ch->cmds_start + 16, 64 >> 2);
+	for (i = 20; i < 64; i += 4)
+		cx_write(ch->cmds_start + i, 0);
+
+	/* fill registers */
+	cx_write(ch->ptr1_reg, ch->fifo_start);
+	cx_write(ch->ptr2_reg, cdt);
+	cx_write(ch->cnt1_reg, bpl >> 3);
+	cx_write(ch->cnt2_reg, (lines*16) >> 3);
+
+	dprintk("sram setup %s: bpl=%d lines=%d\n", ch->name, bpl, lines);
+	return 0;
+}
+
+/* ------------------------------------------------------------------ */
+/* debug helper code                                                  */
+
+int cx88_risc_decode(u32 risc)
+{
+	static char *instr[16] = {
+		[ RISC_SYNC    >> 28 ] = "sync",
+		[ RISC_WRITE   >> 28 ] = "write",
+		[ RISC_WRITEC  >> 28 ] = "writec",
+		[ RISC_READ    >> 28 ] = "read",
+		[ RISC_READC   >> 28 ] = "readc",
+		[ RISC_JUMP    >> 28 ] = "jump",
+		[ RISC_SKIP    >> 28 ] = "skip",
+		[ RISC_WRITERM >> 28 ] = "writerm",
+		[ RISC_WRITECM >> 28 ] = "writecm",
+		[ RISC_WRITECR >> 28 ] = "writecr",
+	};
+	static int incr[16] = {
+		[ RISC_WRITE   >> 28 ] = 2,
+		[ RISC_JUMP    >> 28 ] = 2,
+		[ RISC_WRITERM >> 28 ] = 3,
+		[ RISC_WRITECM >> 28 ] = 3,
+		[ RISC_WRITECR >> 28 ] = 4,
+	};
+	static char *bits[] = {
+		"12",   "13",   "14",   "resync",
+		"cnt0", "cnt1", "18",   "19",
+		"20",   "21",   "22",   "23",
+		"irq1", "irq2", "eol",  "sol",
+	};
+	int i;
+
+	printk("0x%08x [ %s", risc, instr[risc >> 28] ?
+				instr[risc >> 28] : "INVALID");
+	for (i = ARRAY_SIZE(bits)-1; i >= 0; i--)
+		if (risc & (1 << (i + 12)))
+			printk(" %s",bits[i]);
+	printk(" count=%d ]\n", risc & 0xfff);
+	return incr[risc >> 28] ? 1 : incr[risc >> 28];
+}
+
+void cx88_risc_disasm(struct cx8800_dev *dev,
+		      struct btcx_riscmem *risc)
+{
+	unsigned int i,j,n;
+	
+	printk("%s: risc disasm: %p [dma=0x%08lx]\n",
+	       dev->name, risc->cpu, (unsigned long)risc->dma);
+	for (i = 0; i < (risc->size >> 2); i += n) {
+		printk("%s:   %04d: ", dev->name, i);
+		n = cx88_risc_decode(risc->cpu[i]);
+		for (j = 1; j < n; j++)
+			printk("%s:   %04d: 0x%08x [ arg #%d ]\n",
+			       dev->name, i+j, risc->cpu[i+j], j);
+		if (risc->cpu[i] == RISC_JUMP)
+			break;
+	}
+}
+
+void cx88_sram_channel_dump(struct cx8800_dev *dev,
+			    struct sram_channel *ch)
+{
+	static char *name[] = {
+		"initial risc",
+		"cdt base",
+		"cdt size",
+		"iq base",
+		"iq size",
+		"risc pc",
+		"iq wr ptr",
+		"iq rd ptr",
+		"cdt current",
+		"pci target",
+		"line / byte",
+	};
+	u32 risc;
+	unsigned int i,j,n;
+
+	printk("%s: %s - dma channel status dump\n",dev->name,ch->name);
+	for (i = 0; i < ARRAY_SIZE(name); i++)
+		printk("%s:   cmds: %-12s: 0x%08x\n",
+		       dev->name,name[i],
+		       cx_read(ch->cmds_start + 4*i));
+	for (i = 0; i < 4; i++) {
+		risc = cx_read(ch->cmds_start + 4 * (i+11));
+		printk("%s:   risc%d: ", dev->name, i);
+		cx88_risc_decode(risc);
+	}
+	for (i = 0; i < 16; i += n) {
+		risc = cx_read(ch->ctrl_start + 4 * i);
+		printk("%s:   iq %x: ", dev->name, i);
+		n = cx88_risc_decode(risc);
+		for (j = 1; j < n; j++) {
+			risc = cx_read(ch->ctrl_start + 4 * (i+j));
+			printk("%s:   iq %x: 0x%08x [ arg #%d ]\n",
+			       dev->name, i+j, risc, j);
+		}
+	}
+
+	printk("%s: fifo: 0x%08x -> 0x%x\n",
+	       dev->name, ch->fifo_start, ch->fifo_start+ch->fifo_size);
+	printk("%s: ctrl: 0x%08x -> 0x%x\n",
+	       dev->name, ch->ctrl_start, ch->ctrl_start+6*16);
+	printk("%s:   ptr1_reg: 0x%08x\n",
+	       dev->name,cx_read(ch->ptr1_reg));
+	printk("%s:   ptr2_reg: 0x%08x\n",
+	       dev->name,cx_read(ch->ptr2_reg));
+	printk("%s:   cnt1_reg: 0x%08x\n",
+	       dev->name,cx_read(ch->cnt1_reg));
+	printk("%s:   cnt2_reg: 0x%08x\n",
+	       dev->name,cx_read(ch->cnt2_reg));
+}
+
+char *cx88_pci_irqs[32] = {
+	"vid", "aud", "ts", "vip", "hst", "5", "6", "tm1", 
+	"src_dma", "dst_dma", "risc_rd_err", "risc_wr_err",
+	"brdg_err", "src_dma_err", "dst_dma_err", "ipb_dma_err",
+	"i2c", "i2c_rack", "ir_smp", "gpio0", "gpio1"
+};
+char *cx88_vid_irqs[32] = {
+	"y_risci1", "u_risci1", "v_risci1", "vbi_risc1", 
+	"y_risci2", "u_risci2", "v_risci2", "vbi_risc2",
+	"y_oflow",  "u_oflow",  "v_oflow",  "vbi_oflow",
+	"y_sync",   "u_sync",   "v_sync",   "vbi_sync",
+	"opc_err",  "par_err",  "rip_err",  "pci_abort",
+};
+
+void cx88_print_irqbits(char *name, char *tag, char **strings,
+			u32 bits, u32 mask)
+{
+	unsigned int i;
+
+	printk(KERN_DEBUG "%s: %s [0x%x]", name, tag, bits);
+	for (i = 0; i < 32; i++) {
+		if (!(bits & (1 << i)))
+			continue;
+		printk(" %s",strings[i]);
+		if (!(mask & (1 << i)))
+			continue;
+		printk("*");
+	}
+	printk("\n");
+}
+
+/* ------------------------------------------------------------------ */
+
+int cx88_pci_quirks(char *name, struct pci_dev *pci, unsigned int *latency)
+{
+	u8 ctrl = 0;
+	u8 value;
+
+	if (0 == pci_pci_problems)
+		return 0;
+
+	if (pci_pci_problems & PCIPCI_TRITON) {
+		printk(KERN_INFO "%s: quirk: PCIPCI_TRITON -- set TBFX\n",
+		       name);
+		ctrl |= CX88X_EN_TBFX;
+	}
+	if (pci_pci_problems & PCIPCI_NATOMA) {
+		printk(KERN_INFO "%s: quirk: PCIPCI_NATOMA -- set TBFX\n",
+		       name);
+		ctrl |= CX88X_EN_TBFX;
+	}
+	if (pci_pci_problems & PCIPCI_VIAETBF) {
+		printk(KERN_INFO "%s: quirk: PCIPCI_VIAETBF -- set TBFX\n",
+		       name);
+		ctrl |= CX88X_EN_TBFX;
+	}
+	if (pci_pci_problems & PCIPCI_VSFX) {
+		printk(KERN_INFO "%s: quirk: PCIPCI_VSFX -- set VSFX\n",
+		       name);
+		ctrl |= CX88X_EN_VSFX;
+	}
+#ifdef PCIPCI_ALIMAGIK
+	if (pci_pci_problems & PCIPCI_ALIMAGIK) {
+		printk(KERN_INFO "%s: quirk: PCIPCI_ALIMAGIK -- latency fixup\n",
+		       name);
+		*latency = 0x0A;
+	}
+#endif
+	if (ctrl) {
+		pci_read_config_byte(pci, CX88X_DEVCTRL, &value);
+		value |= ctrl;
+		pci_write_config_byte(pci, CX88X_DEVCTRL, value);
+	}
+	return 0;
+}
+
+/* ------------------------------------------------------------------ */
+
+EXPORT_SYMBOL(cx88_print_ioctl);
+EXPORT_SYMBOL(cx88_pci_irqs);
+EXPORT_SYMBOL(cx88_vid_irqs);
+EXPORT_SYMBOL(cx88_print_irqbits);
+
+EXPORT_SYMBOL(cx88_risc_buffer);
+EXPORT_SYMBOL(cx88_risc_stopper);
+EXPORT_SYMBOL(cx88_free_buffer);
+
+EXPORT_SYMBOL(cx88_risc_disasm);
+
+EXPORT_SYMBOL(cx88_sram_channels);
+EXPORT_SYMBOL(cx88_sram_channel_setup);
+EXPORT_SYMBOL(cx88_sram_channel_dump);
+
+EXPORT_SYMBOL(cx88_pci_quirks);
+
+/*
+ * Local variables:
+ * c-basic-offset: 8
+ * End:
+ */
diff -puN /dev/null drivers/media/video/cx88/cx88.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/media/video/cx88/cx88.h	2004-01-19 22:17:22.000000000 -0800
@@ -0,0 +1,339 @@
+/*
+ * v4l2 device driver for philips saa7134 based TV cards
+ *
+ * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/pci.h>
+#include <linux/i2c.h>
+#include <linux/i2c-algo-bit.h>
+#include <linux/videodev.h>
+#include <linux/kdev_t.h>
+
+#include <media/video-buf.h>
+#include <media/tuner.h>
+#include <media/audiochip.h>
+
+#include "btcx-risc.h"
+#include "cx88-reg.h"
+
+#include <linux/version.h>
+#define CX88_VERSION_CODE KERNEL_VERSION(0,0,1)
+
+#ifndef TRUE
+# define TRUE (1==1)
+#endif
+#ifndef FALSE
+# define FALSE (1==0)
+#endif
+#define UNSET (-1U)
+
+#define CX88_MAXBOARDS 8
+
+/* ----------------------------------------------------------- */
+/* defines and enums                                           */
+
+#define FORMAT_FLAGS_PACKED       0x01
+#define FORMAT_FLAGS_PLANAR       0x02
+
+/* ----------------------------------------------------------- */
+/* static data                                                 */
+
+struct cx8800_tvnorm {
+	char                   *name;
+	v4l2_std_id            id;
+	u32                    cxiformat;
+	u32                    cxoformat;
+};
+
+struct cx8800_fmt {
+	char  *name;
+	u32   fourcc;          /* v4l2 format id */
+	int   depth;
+	int   flags;
+	u32   cxformat;
+};
+
+struct cx88_ctrl {
+	struct v4l2_queryctrl  v;
+	u32                    off;
+	u32                    reg;
+	u32                    mask;
+	u32                    shift;
+};
+
+/* ----------------------------------------------------------- */
+/* SRAM memory management data (see cx88-core.c)               */
+
+#define SRAM_CH21 0   /* video */
+#define SRAM_CH22 1
+#define SRAM_CH23 2
+#define SRAM_CH24 3   /* vbi   */
+#define SRAM_CH25 4   /* audio */
+#define SRAM_CH26 5
+/* more */
+
+struct sram_channel {
+	char *name;
+	u32  cmds_start;
+	u32  ctrl_start;
+	u32  fifo_start;
+	u32  fifo_size;
+	u32  ptr1_reg;
+	u32  ptr2_reg;
+	u32  cnt1_reg;
+	u32  cnt2_reg;
+};
+extern struct sram_channel cx88_sram_channels[];
+
+/* ----------------------------------------------------------- */
+/* card configuration                                          */
+
+#define CX88_BOARD_NOAUTO        UNSET
+#define CX88_BOARD_UNKNOWN           0
+#define CX88_BOARD_HAUPPAUGE         1
+#define CX88_BOARD_GDI               2
+#define CX88_BOARD_PIXELVIEW         3
+#define CX88_BOARD_ATI_WONDER_PRO    4
+#define CX88_BOARD_WINFAST2000XP     5
+#define CX88_BOARD_AVERTV_303        6
+#define CX88_BOARD_MSI_TVANYWHERE    7
+#define CX88_BOARD_WINFAST_DV2000    8
+
+
+enum cx88_itype {
+	CX88_VMUX_COMPOSITE1 = 1,
+	CX88_VMUX_COMPOSITE2 = 2,
+	CX88_VMUX_COMPOSITE3 = 3,
+	CX88_VMUX_COMPOSITE4 = 4,
+	CX88_VMUX_TELEVISION = 5,
+	CX88_VMUX_SVIDEO     = 6,
+	CX88_VMUX_DEBUG      = 7,
+	CX88_RADIO           = 8,
+};
+
+struct cx88_input {
+	enum cx88_itype type;
+	unsigned int    vmux;
+	u32             gpio0;
+};
+
+struct cx88_board {
+	char                    *name;
+	unsigned int            tuner_type;
+	struct cx88_input       input[8];
+	struct cx88_input       radio;
+};
+
+struct cx88_subid {
+	u16     subvendor;
+	u16     subdevice;
+	u32     card;
+};
+
+#define INPUT(nr) (&cx88_boards[dev->board].input[nr])
+
+/* ----------------------------------------------------------- */
+/* device / file handle status                                 */
+
+#define RESOURCE_OVERLAY       1
+#define RESOURCE_VIDEO         2
+#define RESOURCE_VBI           4
+
+//#define BUFFER_TIMEOUT     (HZ/2)  /* 0.5 seconds */
+#define BUFFER_TIMEOUT     (HZ*2)
+
+struct cx8800_dev;
+
+/* buffer for one video frame */
+struct cx88_buffer {
+	/* common v4l buffer stuff -- must be first */
+	struct videobuf_buffer vb;
+
+	/* cx88 specific */
+	unsigned int           bpl;
+	struct btcx_riscmem    risc;
+	struct cx8800_fmt      *fmt;
+	u32                    count;
+};
+
+struct cx88_dmaqueue {
+	struct list_head       active;
+	struct list_head       queued;
+	struct timer_list      timeout;
+	struct btcx_riscmem    stopper;
+	u32                    count;
+};
+
+/* video filehandle status */
+struct cx8800_fh {
+	struct cx8800_dev          *dev;
+	enum v4l2_buf_type         type;
+	int                        radio;
+	unsigned int               resources;
+
+	/* video overlay */
+	struct v4l2_window         win;
+	struct v4l2_clip           *clips;
+	unsigned int               nclips;
+
+	/* video capture */
+	struct cx8800_fmt          *fmt;
+	unsigned int               width,height;
+	struct videobuf_queue      vidq;
+};
+
+struct cx8800_suspend_state {
+	u32                        pci_cfg[64 / sizeof(u32)];
+	int                        disabled;
+};
+
+/* global device status */
+struct cx8800_dev {
+	struct list_head           devlist;
+        struct semaphore           lock;
+       	spinlock_t                 slock;
+
+	/* various device info */
+	unsigned int               resources;
+	struct video_device        *video_dev;
+	struct video_device        *radio_dev;
+
+	/* pci i/o */
+	char                       name[32];
+	struct pci_dev             *pci;
+	unsigned char              pci_rev,pci_lat;
+        u32                        *lmmio;
+
+	/* config info */
+	unsigned int               board;
+	unsigned int               tuner_type;
+	unsigned int               has_radio;
+
+	/* i2c i/o */
+	struct i2c_adapter         i2c_adap;
+	struct i2c_algo_bit_data   i2c_algo;
+	struct i2c_client          i2c_client;
+	u32                        i2c_state, i2c_rc;
+
+	/* video overlay */
+	struct v4l2_framebuffer    fbuf;
+	struct cx88_buffer         *screen;
+
+	/* capture queues */
+	struct cx88_dmaqueue       vidq;
+
+	/* various v4l controls */
+	struct cx8800_tvnorm       *tvnorm;
+	u32                        tvaudio;
+	u32                        input;
+	u32                        freq;
+
+	/* other global state info */
+	struct cx8800_suspend_state state;
+};
+
+/* ----------------------------------------------------------- */
+
+#define cx_read(reg)             readl(dev->lmmio + ((reg)>>2))
+#define cx_write(reg,value)      writel((value), dev->lmmio + ((reg)>>2));
+
+#define cx_andor(reg,mask,value) \
+  writel((readl(dev->lmmio+((reg)>>2)) & ~(mask)) |\
+  ((value) & (mask)), dev->lmmio+((reg)>>2))
+#define cx_set(reg,bit)          cx_andor((reg),(bit),(bit))
+#define cx_clear(reg,bit)        cx_andor((reg),(bit),0)
+
+#define cx_wait(d) { if (need_resched()) schedule(); else udelay(d);}
+
+
+/* ----------------------------------------------------------- */
+/* cx88-core.c                                                 */
+
+extern char *cx88_pci_irqs[32];
+extern char *cx88_vid_irqs[32];
+extern void cx88_print_irqbits(char *name, char *tag, char **strings,
+			       u32 bits, u32 mask);
+extern void cx88_print_ioctl(char *name, unsigned int cmd);
+
+extern int
+cx88_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
+		 struct scatterlist *sglist,
+		 unsigned int top_offset, unsigned int bottom_offset,
+		 unsigned int bpl, unsigned int padding, unsigned int lines);
+extern int
+cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
+		  u32 reg, u32 mask, u32 value);
+extern void
+cx88_free_buffer(struct pci_dev *pci, struct cx88_buffer *buf);
+
+extern void cx88_risc_disasm(struct cx8800_dev *dev,
+			     struct btcx_riscmem *risc);
+
+extern int cx88_sram_channel_setup(struct cx8800_dev *dev,
+				   struct sram_channel *ch,
+				   unsigned int bpl, u32 risc);
+extern void cx88_sram_channel_dump(struct cx8800_dev *dev,
+				   struct sram_channel *ch);
+
+extern int cx88_pci_quirks(char *name, struct pci_dev *pci,
+			   unsigned int *latency);
+
+/* ----------------------------------------------------------- */
+/* cx88-i2c.c                                                  */
+
+extern int cx8800_i2c_init(struct cx8800_dev *dev);
+extern void cx8800_call_i2c_clients(struct cx8800_dev *dev,
+				    unsigned int cmd, void *arg);
+
+
+/* ----------------------------------------------------------- */
+/* cx88-cards.c                                                */
+
+extern struct cx88_board cx88_boards[];
+extern const unsigned int cx88_bcount;
+
+extern struct cx88_subid cx88_subids[];
+extern const unsigned int cx88_idcount;
+
+extern void cx88_card_setup(struct cx8800_dev *dev);
+
+/* ----------------------------------------------------------- */
+/* cx88-tvaudio.c                                              */
+
+#define WW_NONE		 1
+#define WW_BTSC		 2
+#define WW_NICAM_I	 3
+#define WW_NICAM_BGDKL	 4
+#define WW_A1		 5
+#define WW_A2_BG	 6
+#define WW_A2_DK	 7
+#define WW_A2_M		 8
+#define WW_EIAJ		 9
+#define WW_SYSTEM_L_AM	10
+#define WW_I2SPT	11
+#define WW_FM		12
+
+void cx88_set_tvaudio(struct cx8800_dev *dev);
+void cx88_get_stereo(struct cx8800_dev *dev, struct v4l2_tuner *t);
+void cx88_set_stereo(struct cx8800_dev *dev, u32 mode);
+
+/*
+ * Local variables:
+ * c-basic-offset: 8
+ * End:
+ */
diff -puN /dev/null drivers/media/video/cx88/cx88-i2c.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/media/video/cx88/cx88-i2c.c	2004-01-19 22:17:22.000000000 -0800
@@ -0,0 +1,172 @@
+/*
+    cx88-i2c.c  --  all the i2c code is here
+
+    Copyright (C) 1996,97,98 Ralph  Metzler (rjkm@thp.uni-koeln.de)
+                           & Marcus Metzler (mocm@thp.uni-koeln.de)
+    (c) 2002 Yurij Sysoev <yurij@naturesoft.net>
+    (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+    
+*/
+
+#define __NO_VERSION__ 1
+
+#include <linux/module.h>
+#include <linux/init.h>
+
+#include <asm/io.h>
+
+#include "cx88.h"
+
+/* ----------------------------------------------------------------------- */
+
+void cx8800_bit_setscl(void *data, int state)
+{
+	struct cx8800_dev *dev = data;
+
+	if (state)
+		dev->i2c_state |= 0x02;
+	else
+		dev->i2c_state &= ~0x02;
+	cx_write(MO_I2C, dev->i2c_state);
+	cx_read(MO_I2C);
+}
+
+void cx8800_bit_setsda(void *data, int state)
+{
+	struct cx8800_dev *dev = data;
+
+	if (state)
+		dev->i2c_state |= 0x01;
+	else
+		dev->i2c_state &= ~0x01;
+	cx_write(MO_I2C, dev->i2c_state);
+	cx_read(MO_I2C);
+}
+
+static int cx8800_bit_getscl(void *data)
+{
+	struct cx8800_dev *dev = data;
+	u32 state;
+	
+	state = cx_read(MO_I2C);
+	return state & 0x02 ? 1 : 0;
+}
+
+static int cx8800_bit_getsda(void *data)
+{
+	struct cx8800_dev *dev = data;
+	u32 state;
+
+	state = cx_read(MO_I2C);
+	return state & 0x01;
+}
+
+/* ----------------------------------------------------------------------- */
+
+#ifndef I2C_PEC
+static void cx8800_inc_use(struct i2c_adapter *adap)
+{
+	MOD_INC_USE_COUNT;
+}
+
+static void cx8800_dec_use(struct i2c_adapter *adap)
+{
+	MOD_DEC_USE_COUNT;
+}
+#endif
+
+static int attach_inform(struct i2c_client *client)
+{
+        struct cx8800_dev *dev = i2c_get_adapdata(client->adapter);
+
+	if (dev->tuner_type != UNSET)
+		cx8800_call_i2c_clients(dev,TUNER_SET_TYPE,&dev->tuner_type);
+
+        if (1 /* fixme: debug */)
+		printk("%s: i2c attach [client=%s]\n",
+		       dev->name, i2c_clientname(client));
+        return 0;
+}
+
+void cx8800_call_i2c_clients(struct cx8800_dev *dev, unsigned int cmd, void *arg)
+{
+	if (0 != dev->i2c_rc)
+		return;
+	i2c_clients_command(&dev->i2c_adap, cmd, arg);
+}
+
+static struct i2c_algo_bit_data cx8800_i2c_algo_template = {
+	.setsda  = cx8800_bit_setsda,
+	.setscl  = cx8800_bit_setscl,
+	.getsda  = cx8800_bit_getsda,
+	.getscl  = cx8800_bit_getscl,
+	.udelay  = 16,
+	.mdelay  = 10,
+	.timeout = 200,
+};
+
+/* ----------------------------------------------------------------------- */
+
+static struct i2c_adapter cx8800_i2c_adap_template = {
+#ifdef I2C_PEC
+	.owner             = THIS_MODULE,
+#else
+	.inc_use           = cx8800_inc_use,
+	.dec_use           = cx8800_dec_use,
+#endif
+#ifdef I2C_ADAP_CLASS_TV_ANALOG
+	.class             = I2C_ADAP_CLASS_TV_ANALOG,
+#endif
+	I2C_DEVNAME("cx2388x"),
+	.id                = I2C_HW_B_BT848,
+	.client_register   = attach_inform,
+};
+
+static struct i2c_client cx8800_i2c_client_template = {
+        I2C_DEVNAME("cx88xx internal"),
+        .id   = -1,
+};
+
+/* init + register i2c algo-bit adapter */
+int __devinit cx8800_i2c_init(struct cx8800_dev *dev)
+{
+	memcpy(&dev->i2c_adap, &cx8800_i2c_adap_template,
+	       sizeof(dev->i2c_adap));
+	memcpy(&dev->i2c_algo, &cx8800_i2c_algo_template,
+	       sizeof(dev->i2c_algo));
+	memcpy(&dev->i2c_client, &cx8800_i2c_client_template,
+	       sizeof(dev->i2c_client));
+
+	dev->i2c_adap.dev.parent = &dev->pci->dev;
+	strcpy(dev->i2c_adap.name,dev->name);
+        dev->i2c_algo.data = dev;
+        i2c_set_adapdata(&dev->i2c_adap,dev);
+        dev->i2c_adap.algo_data = &dev->i2c_algo;
+        dev->i2c_client.adapter = &dev->i2c_adap;
+
+	cx8800_bit_setscl(dev,1);
+	cx8800_bit_setsda(dev,1);
+
+	dev->i2c_rc = i2c_bit_add_bus(&dev->i2c_adap);
+	return dev->i2c_rc;
+}
+
+/*
+ * Local variables:
+ * c-basic-offset: 8
+ * End:
+ */
diff -puN /dev/null drivers/media/video/cx88/cx88-reg.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/media/video/cx88/cx88-reg.h	2004-01-19 22:17:22.000000000 -0800
@@ -0,0 +1,770 @@
+/* 
+    cx88x-hw.h - CX2388x register offsets
+
+    Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)
+                  2001 Michael Eskin
+                  2002 Yurij Sysoev <yurij@naturesoft.net>
+                  2003 Gerd Knorr <kraxel@bytesex.org>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef _CX88_REG_H_
+#define _CX88_REG_H_
+
+/* ---------------------------------------------------------------------- */
+/* PCI IDs and config space                                               */
+
+#ifndef PCI_VENDOR_ID_CONEXANT
+# define PCI_VENDOR_ID_CONEXANT		0x14F1
+#endif
+#ifndef PCI_DEVICE_ID_CX2300_VID
+# define PCI_DEVICE_ID_CX2300_VID	0x8800
+#endif
+
+#define CX88X_DEVCTRL 0x40
+#define CX88X_EN_TBFX 0x02
+#define CX88X_EN_VSFX 0x04
+
+
+/* ---------------------------------------------------------------------- */
+/* DMA Controller registers                                               */
+
+#define MO_PDMA_STHRSH      0x200000 // Source threshold
+#define MO_PDMA_STADRS      0x200004 // Source target address
+#define MO_PDMA_SIADRS      0x200008 // Source internal address
+#define MO_PDMA_SCNTRL      0x20000C // Source control
+#define MO_PDMA_DTHRSH      0x200010 // Destination threshold
+#define MO_PDMA_DTADRS      0x200014 // Destination target address
+#define MO_PDMA_DIADRS      0x200018 // Destination internal address
+#define MO_PDMA_DCNTRL      0x20001C // Destination control
+#define MO_LD_SSID          0x200030 // Load subsystem ID
+#define MO_DEV_CNTRL2       0x200034 // Device control
+#define MO_PCI_INTMSK       0x200040 // PCI interrupt mask
+#define MO_PCI_INTSTAT      0x200044 // PCI interrupt status
+#define MO_PCI_INTMSTAT     0x200048 // PCI interrupt masked status
+#define MO_VID_INTMSK       0x200050 // Video interrupt mask
+#define MO_VID_INTSTAT      0x200054 // Video interrupt status
+#define MO_VID_INTMSTAT     0x200058 // Video interrupt masked status
+#define MO_VID_INTSSTAT     0x20005C // Video interrupt set status
+#define MO_AUD_INTMSK       0x200060 // Audio interrupt mask
+#define MO_AUD_INTSTAT      0x200064 // Audio interrupt status
+#define MO_AUD_INTMSTAT     0x200068 // Audio interrupt masked status
+#define MO_AUD_INTSSTAT     0x20006C // Audio interrupt set status
+#define MO_TS_INTMSK        0x200070 // Transport stream interrupt mask
+#define MO_TS_INTSTAT       0x200074 // Transport stream interrupt status
+#define MO_TS_INTMSTAT      0x200078 // Transport stream interrupt mask status
+#define MO_TS_INTSSTAT      0x20007C // Transport stream interrupt set status
+#define MO_VIP_INTMSK       0x200080 // VIP interrupt mask
+#define MO_VIP_INTSTAT      0x200084 // VIP interrupt status
+#define MO_VIP_INTMSTAT     0x200088 // VIP interrupt masked status
+#define MO_VIP_INTSSTAT     0x20008C // VIP interrupt set status
+#define MO_GPHST_INTMSK     0x200090 // Host interrupt mask
+#define MO_GPHST_INTSTAT    0x200094 // Host interrupt status
+#define MO_GPHST_INTMSTAT   0x200098 // Host interrupt masked status
+#define MO_GPHST_INTSSTAT   0x20009C // Host interrupt set status
+
+// DMA Channels 1-6 belong to SPIPE
+#define MO_DMA7_PTR1        0x300018 // {24}RW* DMA Current Ptr : Ch#7
+#define MO_DMA8_PTR1        0x30001C // {24}RW* DMA Current Ptr : Ch#8
+
+// DMA Channels 9-20 belong to SPIPE
+#define MO_DMA21_PTR1       0x300080 // {24}R0* DMA Current Ptr : Ch#21
+#define MO_DMA22_PTR1       0x300084 // {24}R0* DMA Current Ptr : Ch#22
+#define MO_DMA23_PTR1       0x300088 // {24}R0* DMA Current Ptr : Ch#23
+#define MO_DMA24_PTR1       0x30008C // {24}R0* DMA Current Ptr : Ch#24
+#define MO_DMA25_PTR1       0x300090 // {24}R0* DMA Current Ptr : Ch#25
+#define MO_DMA26_PTR1       0x300094 // {24}R0* DMA Current Ptr : Ch#26
+#define MO_DMA27_PTR1       0x300098 // {24}R0* DMA Current Ptr : Ch#27
+#define MO_DMA28_PTR1       0x30009C // {24}R0* DMA Current Ptr : Ch#28
+#define MO_DMA29_PTR1       0x3000A0 // {24}R0* DMA Current Ptr : Ch#29
+#define MO_DMA30_PTR1       0x3000A4 // {24}R0* DMA Current Ptr : Ch#30
+#define MO_DMA31_PTR1       0x3000A8 // {24}R0* DMA Current Ptr : Ch#31
+#define MO_DMA32_PTR1       0x3000AC // {24}R0* DMA Current Ptr : Ch#32
+
+#define MO_DMA21_PTR2       0x3000C0 // {24}RW* DMA Tab Ptr : Ch#21
+#define MO_DMA22_PTR2       0x3000C4 // {24}RW* DMA Tab Ptr : Ch#22
+#define MO_DMA23_PTR2       0x3000C8 // {24}RW* DMA Tab Ptr : Ch#23
+#define MO_DMA24_PTR2       0x3000CC // {24}RW* DMA Tab Ptr : Ch#24
+#define MO_DMA25_PTR2       0x3000D0 // {24}RW* DMA Tab Ptr : Ch#25
+#define MO_DMA26_PTR2       0x3000D4 // {24}RW* DMA Tab Ptr : Ch#26
+#define MO_DMA27_PTR2       0x3000D8 // {24}RW* DMA Tab Ptr : Ch#27
+#define MO_DMA28_PTR2       0x3000DC // {24}RW* DMA Tab Ptr : Ch#28
+#define MO_DMA29_PTR2       0x3000E0 // {24}RW* DMA Tab Ptr : Ch#29
+#define MO_DMA30_PTR2       0x3000E4 // {24}RW* DMA Tab Ptr : Ch#30
+#define MO_DMA31_PTR2       0x3000E8 // {24}RW* DMA Tab Ptr : Ch#31
+#define MO_DMA32_PTR2       0x3000EC // {24}RW* DMA Tab Ptr : Ch#32
+
+#define MO_DMA21_CNT1       0x300100 // {11}RW* DMA Buffer Size : Ch#21
+#define MO_DMA22_CNT1       0x300104 // {11}RW* DMA Buffer Size : Ch#22
+#define MO_DMA23_CNT1       0x300108 // {11}RW* DMA Buffer Size : Ch#23
+#define MO_DMA24_CNT1       0x30010C // {11}RW* DMA Buffer Size : Ch#24
+#define MO_DMA25_CNT1       0x300110 // {11}RW* DMA Buffer Size : Ch#25
+#define MO_DMA26_CNT1       0x300114 // {11}RW* DMA Buffer Size : Ch#26
+#define MO_DMA27_CNT1       0x300118 // {11}RW* DMA Buffer Size : Ch#27
+#define MO_DMA28_CNT1       0x30011C // {11}RW* DMA Buffer Size : Ch#28
+#define MO_DMA29_CNT1       0x300120 // {11}RW* DMA Buffer Size : Ch#29
+#define MO_DMA30_CNT1       0x300124 // {11}RW* DMA Buffer Size : Ch#30
+#define MO_DMA31_CNT1       0x300128 // {11}RW* DMA Buffer Size : Ch#31
+#define MO_DMA32_CNT1       0x30012C // {11}RW* DMA Buffer Size : Ch#32
+
+#define MO_DMA21_CNT2       0x300140 // {11}RW* DMA Table Size : Ch#21
+#define MO_DMA22_CNT2       0x300144 // {11}RW* DMA Table Size : Ch#22
+#define MO_DMA23_CNT2       0x300148 // {11}RW* DMA Table Size : Ch#23
+#define MO_DMA24_CNT2       0x30014C // {11}RW* DMA Table Size : Ch#24
+#define MO_DMA25_CNT2       0x300150 // {11}RW* DMA Table Size : Ch#25
+#define MO_DMA26_CNT2       0x300154 // {11}RW* DMA Table Size : Ch#26
+#define MO_DMA27_CNT2       0x300158 // {11}RW* DMA Table Size : Ch#27
+#define MO_DMA28_CNT2       0x30015C // {11}RW* DMA Table Size : Ch#28
+#define MO_DMA29_CNT2       0x300160 // {11}RW* DMA Table Size : Ch#29
+#define MO_DMA30_CNT2       0x300164 // {11}RW* DMA Table Size : Ch#30
+#define MO_DMA31_CNT2       0x300168 // {11}RW* DMA Table Size : Ch#31
+#define MO_DMA32_CNT2       0x30016C // {11}RW* DMA Table Size : Ch#32
+
+
+/* ---------------------------------------------------------------------- */
+/* Video registers                                                        */
+
+#define MO_VIDY_DMA         0x310000 // {64}RWp Video Y
+#define MO_VIDU_DMA         0x310008 // {64}RWp Video U
+#define MO_VIDV_DMA         0x310010 // {64}RWp Video V
+#define MO_VBI_DMA          0x310018 // {64}RWp VBI (Vertical blanking interval)
+
+#define MO_DEVICE_STATUS    0x310100
+#define MO_INPUT_FORMAT     0x310104
+#define MO_AGC_BURST        0x31010c
+#define MO_CONTR_BRIGHT     0x310110
+#define MO_HTOTAL           0x310120
+#define MO_HDELAY_EVEN      0x310124
+#define MO_HDELAY_ODD       0x310128
+#define MO_VDELAY_ODD       0x31012c
+#define MO_VDELAY_EVEN      0x310130
+#define MO_HACTIVE_EVEN     0x31013c
+#define MO_HACTIVE_ODD      0x310140
+#define MO_VACTIVE_EVEN     0x310144
+#define MO_VACTIVE_ODD      0x310148
+#define MO_HSCALE_EVEN      0x31014c
+#define MO_HSCALE_ODD       0x310150
+#define MO_VSCALE_EVEN      0x310154
+#define MO_FILTER_EVEN      0x31015c
+#define MO_VSCALE_ODD       0x310158
+#define MO_FILTER_ODD       0x310160
+#define MO_OUTPUT_FORMAT    0x310164
+
+#define MO_PLL_REG          0x310168 // PLL register
+#define MO_PLL_ADJ_CTRL     0x31016c // PLL adjust control register
+#define MO_SCONV_REG        0x310170 // sample rate conversion register
+#define MO_SCONV_FIFO       0x310174 // sample rate conversion fifo
+#define MO_SUB_STEP         0x310178 // subcarrier step size
+#define MO_SUB_STEP_DR      0x31017c // subcarrier step size for DR line
+
+#define MO_CAPTURE_CTRL     0x310180 // capture control
+#define MO_COLOR_CTRL       0x310184
+#define MO_VBI_PACKET       0x310188 // vbi packet size / delay
+#define MO_FIELD_COUNT      0x310190 // field counter
+#define MO_VIP_CONFIG       0x310194
+
+#define MO_AGC_BACK_VBI     0x310200
+#define MO_AGC_SYNC_TIP1    0x310208
+
+#define MO_VIDY_GPCNT       0x31C020 // {16}RO Video Y general purpose counter
+#define MO_VIDU_GPCNT       0x31C024 // {16}RO Video U general purpose counter
+#define MO_VIDV_GPCNT       0x31C028 // {16}RO Video V general purpose counter
+#define MO_VBI_GPCNT        0x31C02C // {16}RO VBI general purpose counter
+#define MO_VIDY_GPCNTRL     0x31C030 // {2}WO Video Y general purpose control
+#define MO_VIDU_GPCNTRL     0x31C034 // {2}WO Video U general purpose control
+#define MO_VIDV_GPCNTRL     0x31C038 // {2}WO Video V general purpose control
+#define MO_VBI_GPCNTRL      0x31C03C // {2}WO VBI general purpose counter
+#define MO_VID_DMACNTRL     0x31C040 // {8}RW Video DMA control
+#define MO_VID_XFR_STAT     0x31C044 // {1}RO Video transfer status
+
+
+/* ---------------------------------------------------------------------- */
+/* audio registers                                                        */
+
+#define MO_AUDD_DMA         0x320000 // {64}RWp Audio downstream
+#define MO_AUDU_DMA         0x320008 // {64}RWp Audio upstream
+#define MO_AUDR_DMA         0x320010 // {64}RWp Audio RDS (downstream)
+#define MO_AUDD_GPCNT       0x32C020 // {16}RO Audio down general purpose counter
+#define MO_AUDU_GPCNT       0x32C024 // {16}RO Audio up general purpose counter
+#define MO_AUDR_GPCNT       0x32C028 // {16}RO Audio RDS general purpose counter
+#define MO_AUDD_GPCNTRL     0x32C030 // {2}WO Audio down general purpose control
+#define MO_AUDU_GPCNTRL     0x32C034 // {2}WO Audio up general purpose control
+#define MO_AUDR_GPCNTRL     0x32C038 // {2}WO Audio RDS general purpose control
+#define MO_AUD_DMACNTRL     0x32C040 // {6}RW Audio DMA control
+#define MO_AUD_XFR_STAT     0x32C044 // {1}RO Audio transfer status
+#define MO_AUDD_LNGTH       0x32C048 // {12}RW Audio down line length
+#define MO_AUDR_LNGTH       0x32C04C // {12}RW Audio RDS line length
+
+#define AUD_INIT                 0x320100
+#define AUD_INIT_LD              0x320104
+#define AUD_SOFT_RESET           0x320108
+#define AUD_I2SINPUTCNTL         0x320120
+#define AUD_BAUDRATE             0x320124
+#define AUD_I2SOUTPUTCNTL        0x320128
+#define AAGC_HYST                0x320134
+#define AAGC_GAIN                0x320138
+#define AAGC_DEF                 0x32013c
+#define AUD_IIR1_0_SEL           0x320150
+#define AUD_IIR1_0_SHIFT         0x320154
+#define AUD_IIR1_1_SEL           0x320158
+#define AUD_IIR1_1_SHIFT         0x32015c
+#define AUD_IIR1_2_SEL           0x320160
+#define AUD_IIR1_2_SHIFT         0x320164
+#define AUD_IIR1_3_SEL           0x320168
+#define AUD_IIR1_3_SHIFT         0x32016c
+#define AUD_IIR1_4_SEL           0x320170
+#define AUD_IIR1_4_SHIFT         0x32017c
+#define AUD_IIR1_5_SEL           0x320180
+#define AUD_IIR1_5_SHIFT         0x320184
+#define AUD_IIR2_0_SEL           0x320190
+#define AUD_IIR2_0_SHIFT         0x320194
+#define AUD_IIR2_1_SEL           0x320198
+#define AUD_IIR2_1_SHIFT         0x32019c
+#define AUD_IIR2_2_SEL           0x3201a0
+#define AUD_IIR2_2_SHIFT         0x3201a4
+#define AUD_IIR2_3_SEL           0x3201a8
+#define AUD_IIR2_3_SHIFT         0x3201ac
+#define AUD_IIR3_0_SEL           0x3201c0
+#define AUD_IIR3_0_SHIFT         0x3201c4
+#define AUD_IIR3_1_SEL           0x3201c8
+#define AUD_IIR3_1_SHIFT         0x3201cc
+#define AUD_IIR3_2_SEL           0x3201d0
+#define AUD_IIR3_2_SHIFT         0x3201d4
+#define AUD_IIR4_0_SEL           0x3201e0
+#define AUD_IIR4_0_SHIFT         0x3201e4
+#define AUD_IIR4_1_SEL           0x3201e8
+#define AUD_IIR4_1_SHIFT         0x3201ec
+#define AUD_IIR4_2_SEL           0x3201f0
+#define AUD_IIR4_2_SHIFT         0x3201f4
+#define AUD_IIR4_0_CA0           0x320200
+#define AUD_IIR4_0_CA1           0x320204
+#define AUD_IIR4_0_CA2           0x320208
+#define AUD_IIR4_0_CB0           0x32020c
+#define AUD_IIR4_0_CB1           0x320210
+#define AUD_IIR4_1_CA0           0x320214
+#define AUD_IIR4_1_CA1           0x320218
+#define AUD_IIR4_1_CA2           0x32021c
+#define AUD_IIR4_1_CB0           0x320220
+#define AUD_IIR4_1_CB1           0x320224
+#define AUD_IIR4_2_CA0           0x320228
+#define AUD_IIR4_2_CA1           0x32022c
+#define AUD_IIR4_2_CA2           0x320230
+#define AUD_IIR4_2_CB0           0x320234
+#define AUD_IIR4_2_CB1           0x320238
+#define AUD_HP_MD_IIR4_1         0x320250
+#define AUD_HP_PROG_IIR4_1       0x320254
+#define AUD_FM_MODE_ENABLE       0x320258
+#define AUD_POLY0_DDS_CONSTANT   0x320270
+#define AUD_DN0_FREQ             0x320274
+#define AUD_DN1_FREQ             0x320278
+#define AUD_DN1_FREQ_SHIFT       0x32027c
+#define AUD_DN1_AFC              0x320280
+#define AUD_DN1_SRC_SEL          0x320284
+#define AUD_DN1_SHFT             0x320288
+#define AUD_DN2_FREQ             0x32028c
+#define AUD_DN2_FREQ_SHIFT       0x320290
+#define AUD_DN2_AFC              0x320294
+#define AUD_DN2_SRC_SEL          0x320298
+#define AUD_DN2_SHFT             0x32029c
+#define AUD_CRDC0_SRC_SEL        0x320300
+#define AUD_CRDC0_SHIFT          0x320304
+#define AUD_CORDIC_SHIFT_0       0x320308
+#define AUD_CRDC1_SRC_SEL        0x32030c
+#define AUD_CRDC1_SHIFT          0x320310
+#define AUD_CORDIC_SHIFT_1       0x320314
+#define AUD_DCOC_0_SRC           0x320320
+#define AUD_DCOC0_SHIFT          0x320324
+#define AUD_DCOC_0_SHIFT_IN0     0x320328
+#define AUD_DCOC_0_SHIFT_IN1     0x32032c
+#define AUD_DCOC_1_SRC           0x320330
+#define AUD_DCOC1_SHIFT          0x320334
+#define AUD_DCOC_1_SHIFT_IN0     0x320338
+#define AUD_DCOC_1_SHIFT_IN1     0x32033c
+#define AUD_DCOC_2_SRC           0x320340
+#define AUD_DCOC2_SHIFT          0x320344
+#define AUD_DCOC_2_SHIFT_IN0     0x320348
+#define AUD_DCOC_2_SHIFT_IN1     0x32034c
+#define AUD_DCOC_PASS_IN         0x320350
+#define AUD_PDET_SRC             0x320370
+#define AUD_PDET_SHIFT           0x320374
+#define AUD_PILOT_BQD_1_K0       0x320380
+#define AUD_PILOT_BQD_1_K1       0x320384
+#define AUD_PILOT_BQD_1_K2       0x320388
+#define AUD_PILOT_BQD_1_K3       0x32038c
+#define AUD_PILOT_BQD_1_K4       0x320390
+#define AUD_PILOT_BQD_2_K0       0x320394
+#define AUD_PILOT_BQD_2_K1       0x320398
+#define AUD_PILOT_BQD_2_K2       0x32039c
+#define AUD_PILOT_BQD_2_K3       0x3203a0
+#define AUD_PILOT_BQD_2_K4       0x3203a4
+#define AUD_THR_FR               0x3203c0
+#define AUD_X_PROG               0x3203c4
+#define AUD_Y_PROG               0x3203c8
+#define AUD_HARMONIC_MULT        0x3203cc
+#define AUD_C1_UP_THR            0x3203d0
+#define AUD_C1_LO_THR            0x3203d4
+#define AUD_C2_UP_THR            0x3203d8
+#define AUD_C2_LO_THR            0x3203dc
+#define AUD_PLL_EN               0x320400
+#define AUD_PLL_SRC              0x320404
+#define AUD_PLL_SHIFT            0x320408
+#define AUD_PLL_IF_SEL           0x32040c
+#define AUD_PLL_IF_SHIFT         0x320410
+#define AUD_BIQUAD_PLL_K0        0x320414
+#define AUD_BIQUAD_PLL_K1        0x320418
+#define AUD_BIQUAD_PLL_K2        0x32041c
+#define AUD_BIQUAD_PLL_K3        0x320420
+#define AUD_BIQUAD_PLL_K4        0x320424
+#define AUD_DEEMPH0_SRC_SEL      0x320440
+#define AUD_DEEMPH0_SHIFT        0x320444
+#define AUD_DEEMPH0_G0           0x320448
+#define AUD_DEEMPH0_A0           0x32044c
+#define AUD_DEEMPH0_B0           0x320450
+#define AUD_DEEMPH0_A1           0x320454
+#define AUD_DEEMPH0_B1           0x320458
+#define AUD_DEEMPH1_SRC_SEL      0x32045c
+#define AUD_DEEMPH1_SHIFT        0x320460
+#define AUD_DEEMPH1_G0           0x320464
+#define AUD_DEEMPH1_A0           0x320468
+#define AUD_DEEMPH1_B0           0x32046c
+#define AUD_DEEMPH1_A1           0x320470
+#define AUD_DEEMPH1_B1           0x320474
+#define AUD_OUT0_SEL             0x320490
+#define AUD_OUT0_SHIFT           0x320494
+#define AUD_OUT1_SEL             0x320498
+#define AUD_OUT1_SHIFT           0x32049c
+#define AUD_RDSI_SEL             0x3204a0
+#define AUD_RDSI_SHIFT           0x3204a4
+#define AUD_RDSQ_SEL             0x3204a8
+#define AUD_RDSQ_SHIFT           0x3204ac
+#define AUD_DBX_IN_GAIN          0x320500
+#define AUD_DBX_WBE_GAIN         0x320504
+#define AUD_DBX_SE_GAIN          0x320508
+#define AUD_DBX_RMS_WBE          0x32050c
+#define AUD_DBX_RMS_SE           0x320510
+#define AUD_DBX_SE_BYPASS        0x320514
+#define AUD_FAWDETCTL            0x320530
+#define AUD_FAWDETWINCTL         0x320534
+#define AUD_DEEMPHGAIN_R         0x320538
+#define AUD_DEEMPHNUMER1_R       0x32053c
+#define AUD_DEEMPHNUMER2_R       0x320540
+#define AUD_DEEMPHDENOM1_R       0x320544
+#define AUD_DEEMPHDENOM2_R       0x320548
+#define AUD_ERRLOGPERIOD_R       0x32054c
+#define AUD_ERRINTRPTTHSHLD1_R   0x320550
+#define AUD_ERRINTRPTTHSHLD2_R   0x320554
+#define AUD_ERRINTRPTTHSHLD3_R   0x320558
+#define AUD_NICAM_STATUS1        0x32055c
+#define AUD_NICAM_STATUS2        0x320560
+#define AUD_ERRLOG1              0x320564
+#define AUD_ERRLOG2              0x320568
+#define AUD_ERRLOG3              0x32056c
+#define AUD_DAC_BYPASS_L         0x320580
+#define AUD_DAC_BYPASS_R         0x320584
+#define AUD_DAC_BYPASS_CTL       0x320588
+#define AUD_CTL                  0x32058c
+#define AUD_STATUS               0x320590
+#define AUD_VOL_CTL              0x320594
+#define AUD_BAL_CTL              0x320598
+#define AUD_START_TIMER          0x3205b0
+#define AUD_MODE_CHG_TIMER       0x3205b4
+#define AUD_POLYPH80SCALEFAC     0x3205b8
+#define AUD_DMD_RA_DDS           0x3205bc
+#define AUD_I2S_RA_DDS           0x3205c0
+#define AUD_RATE_THRES_DMD       0x3205d0
+#define AUD_RATE_THRES_I2S       0x3205d4
+#define AUD_RATE_ADJ1            0x3205d8
+#define AUD_RATE_ADJ2            0x3205dc
+#define AUD_RATE_ADJ3            0x3205e0
+#define AUD_RATE_ADJ4            0x3205e4
+#define AUD_RATE_ADJ5            0x3205e8
+#define AUD_APB_IN_RATE_ADJ      0x3205ec
+#define AUD_PHASE_FIX_CTL        0x3205f0
+#define AUD_PLL_PRESCALE         0x320600
+#define AUD_PLL_DDS              0x320604
+#define AUD_PLL_INT              0x320608
+#define AUD_PLL_FRAC             0x32060c
+#define AUD_PLL_JTAG             0x320620
+#define AUD_PLL_SPMP             0x320624
+#define AUD_AFE_12DB_EN          0x320628
+
+// Audio QAM Register Addresses
+#define AUD_PDF_DDS_CNST_BYTE2   0x320d01
+#define AUD_PDF_DDS_CNST_BYTE1   0x320d02
+#define AUD_PDF_DDS_CNST_BYTE0   0x320d03
+#define AUD_PHACC_FREQ_8MSB      0x320d2a
+#define AUD_PHACC_FREQ_8LSB      0x320d23
+#define AUD_QAM_MODE             0x320d04
+
+
+/* ---------------------------------------------------------------------- */
+/* transport stream registers                                             */
+
+#define MO_TS_DMA           0x330000 // {64}RWp Transport stream downstream
+#define MO_TS_GPCNT         0x33C020 // {16}RO TS general purpose counter
+#define MO_TS_GPCNTRL       0x33C030 // {2}WO TS general purpose control
+#define MO_TS_DMACNTRL      0x33C040 // {6}RW TS DMA control
+#define MO_TS_XFR_STAT      0x33C044 // {1}RO TS transfer status
+#define MO_TS_LNGTH         0x33C048 // {12}RW TS line length
+
+#define TS_HW_SOP_CNTRL     0x33C04C
+#define TS_GEN_CNTRL        0x33C050
+#define TS_BD_PKT_STAT      0x33C054
+#define TS_SOP_STAT         0x33C058
+#define TS_FIFO_OVFL_STAT   0x33C05C
+#define TS_VALERR_CNTRL     0x33C060
+
+
+/* ---------------------------------------------------------------------- */
+/* VIP registers                                                          */
+
+#define MO_VIPD_DMA         0x340000 // {64}RWp VIP downstream
+#define MO_VIPU_DMA         0x340008 // {64}RWp VIP upstream
+#define MO_VIPD_GPCNT       0x34C020 // {16}RO VIP down general purpose counter
+#define MO_VIPU_GPCNT       0x34C024 // {16}RO VIP up general purpose counter
+#define MO_VIPD_GPCNTRL     0x34C030 // {2}WO VIP down general purpose control
+#define MO_VIPU_GPCNTRL     0x34C034 // {2}WO VIP up general purpose control
+#define MO_VIP_DMACNTRL     0x34C040 // {6}RW VIP DMA control
+#define MO_VIP_XFR_STAT     0x34C044 // {1}RO VIP transfer status
+#define MO_VIP_CFG          0x340048 // VIP configuration
+#define MO_VIPU_CNTRL       0x34004C // VIP upstream control #1
+#define MO_VIPD_CNTRL       0x340050 // VIP downstream control #2
+#define MO_VIPD_LNGTH       0x340054 // VIP downstream line length
+#define MO_VIP_BRSTLN       0x340058 // VIP burst length
+#define MO_VIP_INTCNTRL     0x34C05C // VIP Interrupt Control
+#define MO_VIP_XFTERM       0x340060 // VIP transfer terminate
+
+
+/* ---------------------------------------------------------------------- */
+/* misc registers                                                         */
+
+#define MO_M2M_DMA          0x350000 // {64}RWp Mem2Mem DMA Bfr
+#define MO_GP0_IO           0x350010 // {32}RW* GPIOoutput enablesdata I/O
+#define MO_GP1_IO           0x350014 // {32}RW* GPIOoutput enablesdata I/O
+#define MO_GP2_IO           0x350018 // {32}RW* GPIOoutput enablesdata I/O
+#define MO_GP3_IO           0x35001C // {32}RW* GPIO Mode/Ctrloutput enables
+#define MO_GPIO             0x350020 // {32}RW* GPIO I2C Ctrldata I/O
+#define MO_GPOE             0x350024 // {32}RW  GPIO I2C Ctrloutput enables
+#define MO_GP_ISM           0x350028 // {16}WO  GPIO Intr Sens/Pol
+
+#define MO_PLL_B            0x35C008 // {32}RW* PLL Control for ASB bus clks
+#define MO_M2M_CNT          0x35C024 // {32}RW  Mem2Mem DMA Cnt
+#define MO_M2M_XSUM         0x35C028 // {32}RO  M2M XOR-Checksum
+#define MO_CRC              0x35C02C // {16}RW  CRC16 init/result
+#define MO_CRC_D            0x35C030 // {32}WO  CRC16 new data in
+#define MO_TM_CNT_LDW       0x35C034 // {32}RO  Timer : Counter low dword
+#define MO_TM_CNT_UW        0x35C038 // {16}RO  Timer : Counter high word
+#define MO_TM_LMT_LDW       0x35C03C // {32}RW  Timer : Limit low dword
+#define MO_TM_LMT_UW        0x35C040 // {32}RW  Timer : Limit high word
+#define MO_PINMUX_IO        0x35C044 // {8}RW  Pin Mux Control
+#define MO_TSTSEL_IO        0x35C048 // {2}RW  Pin Mux Control
+#define MO_AFECFG_IO        0x35C04C // AFE configuration reg
+#define MO_DDS_IO           0x35C050 // DDS Increment reg
+#define MO_DDSCFG_IO        0x35C054 // DDS Configuration reg
+#define MO_SAMPLE_IO        0x35C058 // IRIn sample reg
+#define MO_SRST_IO          0x35C05C // Output system reset reg
+
+#define MO_INT1_MSK         0x35C060 // DMA RISC interrupt mask
+#define MO_INT1_STAT        0x35C064 // DMA RISC interrupt status
+#define MO_INT1_MSTAT       0x35C068 // DMA RISC interrupt masked status
+
+
+/* ---------------------------------------------------------------------- */
+/* i2c bus registers                                                      */
+
+#define MO_I2C              0x368000 // I2C data/control
+#define MO_I2C_DIV          (0xf<<4)
+#define MO_I2C_SYNC         (1<<3)
+#define MO_I2C_W3B          (1<<2)
+#define MO_I2C_SCL          (1<<1)
+#define MO_I2C_SDA          (1<<0)
+
+
+/* ---------------------------------------------------------------------- */
+/* general purpose host registers                                         */
+/* FIXME: tyops?  s/0x35/0x38/ ??                                         */
+
+#define MO_GPHSTD_DMA       0x350000 // {64}RWp Host downstream
+#define MO_GPHSTU_DMA       0x350008 // {64}RWp Host upstream
+#define MO_GPHSTD_GPCNT     0x35C020 // Host down general purpose counter
+#define MO_GPHSTU_GPCNT     0x35C024 // Host up general purpose counter
+#define MO_GPHSTD_GPCNTRL   0x38C030 // Host down general purpose control
+#define MO_GPHSTU_GPCNTRL   0x38C034 // Host up general purpose control
+#define MO_GPHST_DMACNTRL   0x38C040 // Host DMA control
+#define MO_GPHST_XFR_STAT   0x38C044 // Host transfer status
+#define MO_GPHSTU_CNTRL     0x380048 // Host upstream control #1
+#define MO_GPHSTD_CNTRL     0x38004C // Host downstream control #2
+#define MO_GPHSTD_LNGTH     0x380050 // Host downstream line length
+#define MO_GPHST_WSC        0x380054 // Host wait state control
+#define MO_GPHST_XFR        0x380058 // Host transfer control
+#define MO_GPHST_WDTH       0x38005C // Host interface width
+#define MO_GPHST_HDSHK      0x380060 // Host peripheral handshake
+#define MO_GPHST_MUX16      0x380064 // Host muxed 16-bit transfer parameters
+#define MO_GPHST_MODE       0x380068 // Host mode select
+
+
+/* ---------------------------------------------------------------------- */
+/* RISC instructions                                                      */
+
+#define RISC_SYNC		 0x80000000
+#define RISC_SYNC_ODD		 0x80000000
+#define RISC_SYNC_EVEN		 0x80000200
+#define RISC_RESYNC		 0x80008000
+#define RISC_RESYNC_ODD		 0x80008000
+#define RISC_RESYNC_EVEN	 0x80008200
+#define RISC_WRITE		 0x10000000
+#define RISC_WRITEC		 0x50000000
+#define RISC_READ		 0x90000000
+#define RISC_READC		 0xA0000000
+#define RISC_JUMP		 0x70000000
+#define RISC_SKIP		 0x20000000
+#define RISC_WRITERM		 0xB0000000
+#define RISC_WRITECM		 0xC0000000
+#define RISC_WRITECR		 0xD0000000
+#define RISC_IMM		 0x00000001
+
+#define RISC_SOL		 0x08000000
+#define RISC_EOL		 0x04000000
+
+#define RISC_IRQ2		 0x02000000
+#define RISC_IRQ1		 0x01000000
+
+#define RISC_CNT_NONE		 0x00000000
+#define RISC_CNT_INC		 0x00010000
+#define RISC_CNT_RSVR		 0x00020000
+#define RISC_CNT_RESET		 0x00030000
+#define RISC_JMP_SRP         	 0x01
+
+
+/* ---------------------------------------------------------------------- */
+/* various constants                                                      */
+
+#define SEL_BTSC     0x01 
+#define SEL_EIAJ     0x02 
+#define SEL_A2       0x04 
+#define SEL_SAP      0x08
+#define SEL_NICAM    0x10 
+#define SEL_FMRADIO  0x20
+
+// AUD_CTL
+#define EN_BTSC_FORCE_MONO      0
+#define EN_BTSC_FORCE_STEREO    1
+#define EN_BTSC_FORCE_SAP       2
+#define EN_BTSC_AUTO_STEREO     3
+#define EN_BTSC_AUTO_SAP        4
+
+#define EN_A2_FORCE_MONO1       8
+#define EN_A2_FORCE_MONO2       9
+#define EN_A2_FORCE_STEREO      10
+#define EN_A2_AUTO_MONO2        11
+#define EN_A2_AUTO_STEREO       12
+
+#define EN_EIAJ_FORCE_MONO1     16
+#define EN_EIAJ_FORCE_MONO2     17
+#define EN_EIAJ_FORCE_STEREO    18
+#define EN_EIAJ_AUTO_MONO2      19
+#define EN_EIAJ_AUTO_STEREO     20
+
+#define EN_NICAM_FORCE_MONO1    32
+#define EN_NICAM_FORCE_MONO2    33
+#define EN_NICAM_FORCE_STEREO   34
+#define EN_NICAM_AUTO_MONO2     35
+#define EN_NICAM_AUTO_STEREO    36
+
+#define EN_FMRADIO_FORCE_MONO   24
+#define EN_FMRADIO_FORCE_STEREO 25
+#define EN_FMRADIO_AUTO_STEREO  26
+
+#define EN_NICAM_AUTO_FALLBACK  0x00000040
+#define EN_FMRADIO_EN_RDS       0x00000200
+#define EN_NICAM_TRY_AGAIN_BIT  0x00000400
+#define EN_DAC_ENABLE           0x00001000
+#define EN_I2SOUT_ENABLE        0x00002000
+#define EN_I2SIN_STR2DAC        0x00004000
+#define EN_I2SIN_ENABLE         0x00008000
+
+#define EN_DMTRX_SUMDIFF        0x00000800
+#define EN_DMTRX_SUMR           0x00000880
+#define EN_DMTRX_LR             0x00000900
+#define EN_DMTRX_MONO           0x00000980
+
+// Video 
+#define VID_CAPTURE_CONTROL		0x310180
+
+#define CX23880_CAP_CTL_CAPTURE_VBI_ODD  (1<<3)
+#define CX23880_CAP_CTL_CAPTURE_VBI_EVEN (1<<2)
+#define CX23880_CAP_CTL_CAPTURE_ODD      (1<<1)
+#define CX23880_CAP_CTL_CAPTURE_EVEN     (1<<0)
+
+#define VideoInputMux0		 0x0
+#define VideoInputMux1		 0x1
+#define VideoInputMux2		 0x2
+#define VideoInputMux3		 0x3
+#define VideoInputTuner		 0x0 
+#define VideoInputComposite	 0x1 
+#define VideoInputSVideo	 0x2
+#define VideoInputOther		 0x3 
+
+#define Xtal0		 0x1
+#define Xtal1		 0x2
+#define XtalAuto	 0x3
+
+#define VideoFormatAuto		 0x0
+#define VideoFormatNTSC		 0x1
+#define VideoFormatNTSCJapan	 0x2
+#define VideoFormatNTSC443	 0x3
+#define VideoFormatPAL		 0x4
+#define VideoFormatPALB		 0x4 
+#define VideoFormatPALD		 0x4 
+#define VideoFormatPALG		 0x4 
+#define VideoFormatPALH		 0x4 
+#define VideoFormatPALI		 0x4 
+#define VideoFormatPALBDGHI	 0x4 
+#define VideoFormatPALM		 0x5
+#define VideoFormatPALN		 0x6
+#define VideoFormatPALNC	 0x7
+#define VideoFormatPAL60	 0x8
+#define VideoFormatSECAM	 0x9
+
+#define VideoFormatAuto27MHz		 0x10
+#define VideoFormatNTSC27MHz		 0x11
+#define VideoFormatNTSCJapan27MHz	 0x12
+#define VideoFormatNTSC44327MHz		 0x13
+#define VideoFormatPAL27MHz		 0x14
+#define VideoFormatPALB27MHz		 0x14 
+#define VideoFormatPALD27MHz		 0x14 
+#define VideoFormatPALG27MHz		 0x14 
+#define VideoFormatPALH27MHz		 0x14 
+#define VideoFormatPALI27MHz		 0x14 
+#define VideoFormatPALBDGHI27MHz	 0x14 
+#define VideoFormatPALM27MHz		 0x15
+#define VideoFormatPALN27MHz		 0x16
+#define VideoFormatPALNC27MHz		 0x17
+#define VideoFormatPAL6027MHz		 0x18
+#define VideoFormatSECAM27MHz		 0x19
+
+#define NominalUSECAM	 0x87
+#define NominalVSECAM	 0x85
+#define NominalUNTSC	 0xFE
+#define NominalVNTSC	 0xB4
+
+#define NominalContrast  0xD8
+
+#define HFilterAutoFormat	 0x0
+#define HFilterCIF		 0x1
+#define HFilterQCIF		 0x2
+#define HFilterICON		 0x3
+
+#define VFilter2TapInterpolate  0
+#define VFilter3TapInterpolate  1
+#define VFilter4TapInterpolate  2
+#define VFilter5TapInterpolate  3
+#define VFilter2TapNoInterpolate  4
+#define VFilter3TapNoInterpolate  5
+#define VFilter4TapNoInterpolate  6
+#define VFilter5TapNoInterpolate  7
+
+#define ColorFormatRGB32	 0x0000
+#define ColorFormatRGB24	 0x0011
+#define ColorFormatRGB16	 0x0022
+#define ColorFormatRGB15	 0x0033
+#define ColorFormatYUY2		 0x0044
+#define ColorFormatBTYUV	 0x0055
+#define ColorFormatY8		 0x0066
+#define ColorFormatRGB8		 0x0077
+#define ColorFormatPL422	 0x0088
+#define ColorFormatPL411	 0x0099
+#define ColorFormatYUV12	 0x00AA
+#define ColorFormatYUV9		 0x00BB
+#define ColorFormatRAW		 0x00EE
+#define ColorFormatBSWAP         0x0300
+#define ColorFormatWSWAP         0x0c00
+#define ColorFormatEvenMask      0x050f
+#define ColorFormatOddMask       0x0af0
+#define ColorFormatGamma         0x1000
+
+#define Interlaced		 0x1
+#define NonInterlaced	 	 0x0
+
+#define FieldEven		 0x1
+#define FieldOdd		 0x0
+
+#define TGReadWriteMode	 	 0x0
+#define TGEnableMode	 	 0x1
+
+#define DV_CbAlign		 0x0
+#define DV_Y0Align		 0x1
+#define DV_CrAlign		 0x2
+#define DV_Y1Align		 0x3
+
+#define DVF_Analog		 0x0
+#define DVF_CCIR656		 0x1
+#define DVF_ByteStream		 0x2
+#define DVF_ExtVSYNC		 0x4
+#define DVF_ExtField		 0x5
+
+#define CHANNEL_VID_Y		 0x1
+#define CHANNEL_VID_U		 0x2
+#define CHANNEL_VID_V		 0x3
+#define CHANNEL_VID_VBI		 0x4
+#define CHANNEL_AUD_DN		 0x5
+#define CHANNEL_AUD_UP		 0x6
+#define CHANNEL_AUD_RDS_DN	 0x7
+#define CHANNEL_MPEG_DN		 0x8
+#define CHANNEL_VIP_DN		 0x9
+#define CHANNEL_VIP_UP		 0xA
+#define CHANNEL_HOST_DN		 0xB
+#define CHANNEL_HOST_UP		 0xC
+#define CHANNEL_FIRST		 0x1 
+#define CHANNEL_LAST		 0xC 
+
+#define GP_COUNT_CONTROL_NONE		 0x0
+#define GP_COUNT_CONTROL_INC		 0x1
+#define GP_COUNT_CONTROL_RESERVED	 0x2
+#define GP_COUNT_CONTROL_RESET		 0x3
+
+#define PLL_PRESCALE_BY_2  2
+#define PLL_PRESCALE_BY_3  3
+#define PLL_PRESCALE_BY_4  4
+#define PLL_PRESCALE_BY_5  5
+
+#define HLNotchFilter4xFsc	 0
+#define HLNotchFilterSquare	 1
+#define HLNotchFilter135NTSC	 2
+#define HLNotchFilter135PAL	 3
+
+#define NTSC_8x_SUB_CARRIER  28.63636E6
+#define PAL_8x_SUB_CARRIER  35.46895E6
+
+// Default analog settings
+#define DEFAULT_HUE_NTSC			0x00
+#define DEFAULT_BRIGHTNESS_NTSC			0x00
+#define DEFAULT_CONTRAST_NTSC			0x39
+#define DEFAULT_SAT_U_NTSC			0x7F
+#define DEFAULT_SAT_V_NTSC			0x5A
+
+typedef enum                                                                          
+{                                                                                     
+	SOURCE_TUNER = 0,                                                             
+	SOURCE_COMPOSITE,                                                             
+	SOURCE_SVIDEO,                                                                
+	SOURCE_OTHER1,                                                                
+	SOURCE_OTHER2,                                                                
+	SOURCE_COMPVIASVIDEO,                                                         
+	SOURCE_CCIR656                                                                    
+} VIDEOSOURCETYPE;
+
+#endif /* _CX88_REG_H_ */
diff -puN /dev/null drivers/media/video/cx88/cx88-tvaudio.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/media/video/cx88/cx88-tvaudio.c	2004-01-19 22:17:22.000000000 -0800
@@ -0,0 +1,472 @@
+/*
+    cx88x-audio.c - Conexant CX23880/23881 audio downstream driver driver
+
+     (c) 2001 Michael Eskin, Tom Zakrajsek [Windows version]
+     (c) 2002 Yurij Sysoev <yurij@naturesoft.net>
+     (c) 2003 Gerd Knorr <kraxel@bytesex.org>
+
+    -----------------------------------------------------------------------
+
+    Lot of voodoo here.  Even the data sheet doesn't help to
+    understand what is going on here, the documentation for the audio
+    part of the cx2388x chip is *very* bad.
+
+    Some of this comes from party done linux driver sources I got from
+    [undocumented].
+
+    Some comes from the dscaler sources, the dscaler driver guy works
+    for Conexant ...
+    
+    -----------------------------------------------------------------------
+    
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You 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/errno.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/mm.h>
+#include <linux/poll.h>
+#include <linux/pci.h>
+#include <linux/signal.h>
+#include <linux/ioport.h>
+#include <linux/sched.h>
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/vmalloc.h>
+#include <linux/init.h>
+
+#include "cx88.h"
+
+static unsigned int audio_debug = UNSET;
+MODULE_PARM(audio_debug,"i");
+MODULE_PARM_DESC(audio_debug,"enable debug messages [audio]");
+
+#define dprintk(fmt, arg...)	if (audio_debug) \
+	printk(KERN_DEBUG "%s: " fmt, dev->name , ## arg)
+
+/* ----------------------------------------------------------- */
+
+struct rlist {
+	u32 reg;
+	u32 val;
+};
+
+static void set_audio_registers(struct cx8800_dev *dev,
+				const struct rlist *l)
+{
+	int i;
+
+	for (i = 0; l[i].reg; i++)
+		cx_write(l[i].reg, l[i].val);
+}
+
+static void set_audio_standard_BTSC(struct cx8800_dev *dev, unsigned int sap)
+{
+	dprintk("set_audio_standard_BTSC() [TODO]\n");
+}
+
+static void set_audio_standard_NICAM(struct cx8800_dev *dev)
+{
+	static const struct rlist nicam[] = {
+		//  increase level of input by 12dB
+		{ AUD_AFE_12DB_EN,         0x00000001 },
+
+    		// initialize NICAM                 
+    		{ AUD_INIT,                0x00000010 },
+    		{ AUD_INIT_LD,             0x00000001 },
+    		{ AUD_SOFT_RESET,          0x00000001 },
+    
+   		// WARNING!!!! Stereo mode is FORCED!!!!
+    		{ AUD_CTL,                 EN_DAC_ENABLE | EN_DMTRX_LR | EN_NICAM_FORCE_STEREO },
+    
+    		{ AUD_SOFT_RESET,          0x00000001 },
+    		{ AUD_RATE_ADJ1,           0x00000010 },
+    		{ AUD_RATE_ADJ2,           0x00000040 },
+    		{ AUD_RATE_ADJ3,           0x00000100 },
+    		{ AUD_RATE_ADJ4,           0x00000400 },
+    		{ AUD_RATE_ADJ5,           0x00001000 },
+    //		{ AUD_DMD_RA_DDS,          0x00c0d5ce },
+
+                { /* end of list */ },
+        };
+
+        printk("set_audio_standard_NICAM()\n");
+        set_audio_registers(dev, nicam);
+
+    	// setup QAM registers
+    	cx_write(0x320d01,                0x06);
+    	cx_write(0x320d02,                0x82);
+    	cx_write(0x320d03,                0x16);
+    	cx_write(0x320d04,                0x05);
+    	cx_write(0x320d2a,                0x34);
+    	cx_write(0x320d2b,                0x4c);
+
+    	// setup Audio PLL
+    	//cx_write(AUD_PLL_PRESCALE,        0x0002);
+    	//cx_write(AUD_PLL_INT,             0x001f);
+
+    	// de-assert Audio soft reset
+    	cx_write(AUD_SOFT_RESET,          0x00000000);  // Causes a pop every time
+}
+
+static void set_audio_standard_A2(struct cx8800_dev *dev)
+{
+	static const struct rlist a2[] = {
+		//  increase level of input by 12dB
+		{ AUD_AFE_12DB_EN,         0x00000001 },
+
+		//  initialize A2
+		{ AUD_INIT,                0x00000004 },
+		{ AUD_INIT_LD,             0x00000001 },
+		{ AUD_SOFT_RESET,          0x00000001 },
+    
+		// ; WARNING!!! A2 STEREO DEMATRIX HAS TO BE
+		// ; SET MANUALLY!!!  Value sould be 0x100c
+		{ AUD_CTL, EN_DAC_ENABLE | EN_DMTRX_SUMR | EN_A2_AUTO_STEREO },
+
+		{ AUD_DN0_FREQ,            0x0000312b },
+		{ AUD_POLY0_DDS_CONSTANT,  0x000a62b4 },
+		{ AUD_IIR1_0_SEL,          0x00000000 },
+		{ AUD_IIR1_1_SEL,          0x00000001 },
+		{ AUD_IIR1_2_SEL,          0x0000001f },
+		{ AUD_IIR1_3_SEL,          0x00000020 },
+		{ AUD_IIR1_4_SEL,          0x00000023 },
+		{ AUD_IIR1_5_SEL,          0x00000007 },
+		{ AUD_IIR1_0_SHIFT,        0x00000000 },
+		{ AUD_IIR1_1_SHIFT,        0x00000000 },
+		{ AUD_IIR1_2_SHIFT,        0x00000007 },
+		{ AUD_IIR1_3_SHIFT,        0x00000007 },
+		{ AUD_IIR1_4_SHIFT,        0x00000007 },
+		{ AUD_IIR1_5_SHIFT,        0x00000000 },
+		{ AUD_IIR2_0_SEL,          0x00000002 },
+		{ AUD_IIR2_1_SEL,          0x00000003 },
+		{ AUD_IIR2_2_SEL,          0x00000004 },
+		{ AUD_IIR2_3_SEL,          0x00000005 },
+		{ AUD_IIR3_0_SEL,          0x00000021 },
+		{ AUD_IIR3_1_SEL,          0x00000023 },
+		{ AUD_IIR3_2_SEL,          0x00000016 },
+		{ AUD_IIR3_0_SHIFT,        0x00000000 },
+		{ AUD_IIR3_1_SHIFT,        0x00000000 },
+		{ AUD_IIR3_2_SHIFT,        0x00000000 },
+		{ AUD_IIR4_0_SEL,          0x0000001d },
+		{ AUD_IIR4_1_SEL,          0x00000019 },
+		{ AUD_IIR4_2_SEL,          0x00000008 },
+		{ AUD_IIR4_0_SHIFT,        0x00000000 },
+		{ AUD_IIR4_1_SHIFT,        0x00000000 },
+		{ AUD_IIR4_2_SHIFT,        0x00000001 },
+		{ AUD_IIR4_0_CA0,          0x0003e57e },
+		{ AUD_IIR4_0_CA1,          0x00005e11 },
+		{ AUD_IIR4_0_CA2,          0x0003a7cf },
+		{ AUD_IIR4_0_CB0,          0x00002368 },
+		{ AUD_IIR4_0_CB1,          0x0003bf1b },
+		{ AUD_IIR4_1_CA0,          0x00006349 },
+		{ AUD_IIR4_1_CA1,          0x00006f27 },
+		{ AUD_IIR4_1_CA2,          0x0000e7a3 },
+		{ AUD_IIR4_1_CB0,          0x00005653 },
+		{ AUD_IIR4_1_CB1,          0x0000cf97 },
+		{ AUD_IIR4_2_CA0,          0x00006349 },
+		{ AUD_IIR4_2_CA1,          0x00006f27 },
+		{ AUD_IIR4_2_CA2,          0x0000e7a3 },
+		{ AUD_IIR4_2_CB0,          0x00005653 },
+		{ AUD_IIR4_2_CB1,          0x0000cf97 },
+		{ AUD_HP_MD_IIR4_1,        0x00000001 },
+		{ AUD_HP_PROG_IIR4_1,      0x00000017 },
+		{ AUD_DN1_FREQ,            0x00003618 },
+		{ AUD_DN1_SRC_SEL,         0x00000017 },
+		{ AUD_DN1_SHFT,            0x00000007 },
+		{ AUD_DN1_AFC,             0x00000000 },
+		{ AUD_DN1_FREQ_SHIFT,      0x00000000 },
+		{ AUD_DN2_SRC_SEL,         0x00000040 },
+		{ AUD_DN2_SHFT,            0x00000000 },
+		{ AUD_DN2_AFC,             0x00000002 },
+		{ AUD_DN2_FREQ,            0x0000caaf },
+		{ AUD_DN2_FREQ_SHIFT,      0x00000000 },
+		{ AUD_PDET_SRC,            0x00000014 },
+		{ AUD_PDET_SHIFT,          0x00000000 },
+		{ AUD_DEEMPH0_SRC_SEL,     0x00000011 },
+		{ AUD_DEEMPH1_SRC_SEL,     0x00000013 },
+		{ AUD_DEEMPH0_SHIFT,       0x00000000 },
+		{ AUD_DEEMPH1_SHIFT,       0x00000000 },
+		{ AUD_DEEMPH0_G0,          0x000004da },
+		{ AUD_DEEMPH0_A0,          0x0000777a },
+		{ AUD_DEEMPH0_B0,          0x00000000 },
+		{ AUD_DEEMPH0_A1,          0x0003f062 },
+		{ AUD_DEEMPH0_B1,          0x00000000 },
+		{ AUD_DEEMPH1_G0,          0x000004da },
+		{ AUD_DEEMPH1_A0,          0x0000777a },
+		{ AUD_DEEMPH1_B0,          0x00000000 },
+		{ AUD_DEEMPH1_A1,          0x0003f062 },
+		{ AUD_DEEMPH1_B1,          0x00000000 },
+		{ AUD_PLL_EN,              0x00000000 },
+		{ AUD_DMD_RA_DDS,          0x002a4efb },
+		{ AUD_RATE_ADJ1,           0x00001000 },
+		{ AUD_RATE_ADJ2,           0x00002000 },
+		{ AUD_RATE_ADJ3,           0x00003000 },
+		{ AUD_RATE_ADJ4,           0x00004000 },
+		{ AUD_RATE_ADJ5,           0x00005000 },
+		{ AUD_C2_UP_THR,           0x0000ffff },
+		{ AUD_C2_LO_THR,           0x0000e800 },
+		{ AUD_C1_UP_THR,           0x00008c00 },
+		{ AUD_C1_LO_THR,           0x00006c00 },
+
+		//   ; Completely ditch AFC feedback
+		{ AUD_DCOC_0_SRC,          0x00000021 },
+		{ AUD_DCOC_1_SRC,          0x0000001a },
+		{ AUD_DCOC1_SHIFT,         0x00000000 },
+		{ AUD_DCOC_1_SHIFT_IN0,    0x0000000a },
+		{ AUD_DCOC_1_SHIFT_IN1,    0x00000008 },
+		{ AUD_DCOC_PASS_IN,        0x00000000 },
+		{ AUD_IIR4_0_SEL,          0x00000023 },
+
+		//  ; Completely ditc FM-2 AFC feedback
+		{ AUD_DN1_AFC,             0x00000000 },
+		{ AUD_DCOC_2_SRC,          0x0000001b },
+		{ AUD_IIR4_1_SEL,          0x00000025 },
+
+		// ; WARNING!!! THIS CHANGE WAS NOT EXPECTED!!!
+		// ; Swap I & Q inputs into second rotator
+		// ; to reverse frequency and therefor invert
+		// ; phase from the cordic FM demodulator
+		// ; (frequency rotation must also be reversed
+		{ AUD_DN2_SRC_SEL,         0x00000001 },
+		{ AUD_DN2_FREQ,            0x00003551 },
+
+
+		//  setup Audio PLL
+		{ AUD_PLL_PRESCALE,        0x00000002 },
+		{ AUD_PLL_INT,             0x0000001f },
+
+		//  de-assert Audio soft reset
+		{ AUD_SOFT_RESET,          0x00000000 },
+
+		{ /* end of list */ },
+	};
+
+	dprintk("set_audio_standard_A2()\n");
+	set_audio_registers(dev, a2);
+}
+
+static void set_audio_standard_EIAJ(struct cx8800_dev *dev)
+{
+	dprintk("set_audio_standard_EIAJ() [TODO]\n");
+}
+
+static void set_audio_standard_FM(struct cx8800_dev *dev)
+{
+	dprintk("set_audio_standard_FM\n");
+
+	// initialize FM Radio
+	cx_write(AUD_INIT,0x0020);
+	cx_write(AUD_INIT_LD,0x0001);
+	cx_write(AUD_SOFT_RESET,0x0001);
+
+#if 0 /* FIXME */
+	switch (dev->audio_properties.FM_deemphasis)
+	{
+		case WW_FM_DEEMPH_50:
+			//Set De-emphasis filter coefficients for 50 usec
+			cx_write(AUD_DEEMPH0_G0, 0x0C45);
+			cx_write(AUD_DEEMPH0_A0, 0x6262);
+			cx_write(AUD_DEEMPH0_B0, 0x1C29);
+			cx_write(AUD_DEEMPH0_A1, 0x3FC66);
+			cx_write(AUD_DEEMPH0_B1, 0x399A);
+
+			cx_write(AUD_DEEMPH1_G0, 0x0D80);
+			cx_write(AUD_DEEMPH1_A0, 0x6262);
+			cx_write(AUD_DEEMPH1_B0, 0x1C29);
+			cx_write(AUD_DEEMPH1_A1, 0x3FC66);
+			cx_write(AUD_DEEMPH1_B1, 0x399A);
+			
+			break;
+
+		case WW_FM_DEEMPH_75:
+			//Set De-emphasis filter coefficients for 75 usec
+			cx_write(AUD_DEEMPH0_G0, 0x91B );
+			cx_write(AUD_DEEMPH0_A0, 0x6B68);
+			cx_write(AUD_DEEMPH0_B0, 0x11EC);
+			cx_write(AUD_DEEMPH0_A1, 0x3FC66);
+			cx_write(AUD_DEEMPH0_B1, 0x399A);
+
+			cx_write(AUD_DEEMPH1_G0, 0xAA0 );
+			cx_write(AUD_DEEMPH1_A0, 0x6B68);
+			cx_write(AUD_DEEMPH1_B0, 0x11EC);
+			cx_write(AUD_DEEMPH1_A1, 0x3FC66);
+			cx_write(AUD_DEEMPH1_B1, 0x399A);
+
+			break;
+	}
+#endif
+
+	// de-assert Audio soft reset
+	cx_write(AUD_SOFT_RESET,0x0000);
+
+	// AB: 10/2/01: this register is not being reset appropriately on occasion.
+	cx_write(AUD_POLYPH80SCALEFAC,3);
+}
+
+/* ----------------------------------------------------------- */
+
+void cx88_set_tvaudio(struct cx8800_dev *dev)
+{
+	cx_write(AUD_CTL, 0x00);
+
+	switch (dev->tvaudio) {
+	case WW_BTSC:
+		set_audio_standard_BTSC(dev,0);
+		break;
+	case WW_NICAM_I:
+	case WW_NICAM_BGDKL:
+		set_audio_standard_NICAM(dev);
+		break;
+	case WW_A2_BG:
+	case WW_A2_DK:
+	case WW_A2_M:
+		set_audio_standard_A2(dev);
+		break;
+	case WW_EIAJ:
+		set_audio_standard_EIAJ(dev);
+		break;
+	case WW_FM:
+		set_audio_standard_FM(dev);
+		break;
+	case WW_NONE:
+	default:
+		printk("%s: unknown tv audio mode [%d]\n",
+		       dev->name, dev->tvaudio);
+		break;
+	}
+
+	// unmute
+	cx_set(AUD_CTL, EN_DAC_ENABLE);
+	cx_write(AUD_VOL_CTL, 0x00);
+	return;
+}
+
+void cx88_get_stereo(struct cx8800_dev *dev, struct v4l2_tuner *t)
+{
+	static char *m[] = {"mono", "dual mono", "stereo", "sap"};
+	static char *p[] = {"no pilot", "pilot c1", "pilot c2", "?"};
+	u32 reg,mode,pilot;
+
+	reg   = cx_read(AUD_STATUS);
+	mode  = reg & 0x03;
+	pilot = (reg >> 2) & 0x03;
+	dprintk("AUD_STATUS: %s / %s [status=0x%x,ctl=0x%x,vol=0x%x]\n",
+		m[mode], p[pilot], reg,
+		cx_read(AUD_CTL), cx_read(AUD_VOL_CTL));
+
+	t->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_SAP |
+		V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2;
+	t->rxsubchans = V4L2_TUNER_SUB_MONO;
+	t->audmode    = V4L2_TUNER_MODE_MONO;
+
+	switch (dev->tvaudio) {
+	case WW_A2_BG:
+ 		if (2 == pilot) {
+			/* stereo */
+			t->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
+			if (2 == mode)
+				t->audmode = V4L2_TUNER_MODE_STEREO;
+		}
+ 		if (1 == pilot) {
+			/* dual language -- FIXME */
+			t->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
+			t->audmode = V4L2_TUNER_MODE_LANG1;
+		}
+		break;
+	case WW_NICAM_BGDKL:
+		if (2 == mode)
+			t->audmode = V4L2_TUNER_MODE_STEREO;
+		break;
+	default:
+		t->rxsubchans = V4L2_TUNER_SUB_MONO;
+		t->audmode    = V4L2_TUNER_MODE_MONO;
+		break;
+	}
+	return;
+}
+
+void cx88_set_stereo(struct cx8800_dev *dev, u32 mode)
+{
+	u32 ctl  = UNSET;
+	u32 mask = UNSET;
+
+	switch (dev->tvaudio) {
+	case WW_A2_BG:
+		switch (mode) {
+		case V4L2_TUNER_MODE_MONO:   
+		case V4L2_TUNER_MODE_LANG1:
+			ctl  = EN_A2_FORCE_MONO1;
+			mask = 0x3f;
+			break;
+		case V4L2_TUNER_MODE_LANG2:
+			ctl  = EN_A2_AUTO_MONO2;
+			mask = 0x3f;
+			break;
+		case V4L2_TUNER_MODE_STEREO:
+			ctl  = EN_A2_AUTO_STEREO | EN_DMTRX_SUMR;
+			mask = 0x8bf;
+			break;
+		}
+		break;
+	case WW_NICAM_BGDKL:
+		switch (mode) {
+		case V4L2_TUNER_MODE_MONO:   
+			ctl  = EN_NICAM_FORCE_MONO1;
+			mask = 0x3f;
+			break;
+		case V4L2_TUNER_MODE_LANG1:
+			ctl  = EN_NICAM_AUTO_MONO2;
+			mask = 0x3f;
+			break;
+		case V4L2_TUNER_MODE_STEREO:
+			ctl  = EN_NICAM_FORCE_STEREO | EN_DMTRX_LR;
+			mask = 0x93f;
+			break;
+		}
+		break;	
+	case WW_FM:
+		switch (mode) {
+		case V4L2_TUNER_MODE_MONO:   
+			ctl  = EN_FMRADIO_FORCE_MONO;
+			mask = 0x3f;
+			break;
+		case V4L2_TUNER_MODE_STEREO:
+			ctl  = EN_FMRADIO_AUTO_STEREO;
+			mask = 0x3f;
+			break;
+		}
+		break;	
+	}
+
+	if (UNSET != ctl) {
+		cx_write(AUD_SOFT_RESET, 0x0001);
+		cx_andor(AUD_CTL, mask, ctl);
+		cx_write(AUD_SOFT_RESET, 0x0000);
+		dprintk("cx88_set_stereo: mask 0x%x, ctl 0x%x "
+			"[status=0x%x,ctl=0x%x,vol=0x%x]\n",
+			mask, ctl, cx_read(AUD_STATUS),
+			cx_read(AUD_CTL), cx_read(AUD_VOL_CTL));
+	}
+	return;
+}
+
+/*
+ * Local variables:
+ * c-basic-offset: 8
+ * End:
+ */
diff -puN /dev/null drivers/media/video/cx88/cx88-video.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/media/video/cx88/cx88-video.c	2004-01-19 22:17:22.000000000 -0800
@@ -0,0 +1,2246 @@
+/*
+ * device driver for Conexant 2388x based TV cards
+ * video4linux video interface
+ *
+ * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#define __NO_VERSION__ 1
+
+#include <linux/init.h>
+#include <linux/list.h>
+#include <linux/module.h>
+#include <linux/kmod.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/interrupt.h>
+#include <asm/div64.h>
+
+#include "cx88.h"
+
+MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards");
+MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
+MODULE_LICENSE("GPL");
+
+/* ------------------------------------------------------------------ */
+
+static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
+MODULE_PARM(video_nr,"1-" __stringify(CX88_MAXBOARDS) "i");
+MODULE_PARM_DESC(video_nr,"video device numbers");
+
+static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
+MODULE_PARM(radio_nr,"1-" __stringify(CX88_MAXBOARDS) "i");
+MODULE_PARM_DESC(radio_nr,"radio device numbers");
+
+static unsigned int latency = UNSET;
+MODULE_PARM(latency,"i");
+MODULE_PARM_DESC(latency,"pci latency timer");
+
+static unsigned int video_debug = 0;
+MODULE_PARM(video_debug,"i");
+MODULE_PARM_DESC(video_debug,"enable debug messages [video]");
+
+static unsigned int irq_debug = 0;
+MODULE_PARM(irq_debug,"i");
+MODULE_PARM_DESC(irq_debug,"enable debug messages [IRQ handler]");
+
+static unsigned int vid_limit = 16;
+MODULE_PARM(vid_limit,"i");
+MODULE_PARM_DESC(vid_limit,"capture memory limit in megabytes");
+
+static unsigned int tuner[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
+MODULE_PARM(tuner,"1-" __stringify(CX88_MAXBOARDS) "i");
+MODULE_PARM_DESC(tuner,"tuner type");
+
+static unsigned int card[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
+MODULE_PARM(card,"1-" __stringify(CX88_MAXBOARDS) "i");
+MODULE_PARM_DESC(card,"card type");
+
+static unsigned int nicam = 0;
+MODULE_PARM(nicam,"i");
+MODULE_PARM_DESC(nicam,"tv audio is nicam");
+
+#define dprintk(level,fmt, arg...)	if (video_debug >= level) \
+	printk(KERN_DEBUG "%s: " fmt, dev->name , ## arg)
+
+/* ------------------------------------------------------------------ */
+
+static struct list_head  cx8800_devlist;
+static unsigned int      cx8800_devcount;
+
+/* ------------------------------------------------------------------- */
+/* static data                                                         */
+
+static unsigned int inline norm_swidth(struct cx8800_tvnorm *norm)
+{
+	return (norm->id & V4L2_STD_625_50) ? 922 : 754;
+}
+
+static unsigned int inline norm_hdelay(struct cx8800_tvnorm *norm)
+{
+	return (norm->id & V4L2_STD_625_50) ? 186 : 135;
+}
+
+static unsigned int inline norm_vdelay(struct cx8800_tvnorm *norm)
+{
+	return (norm->id & V4L2_STD_625_50) ? 0x24 : 0x18;
+}
+
+static unsigned int inline norm_maxw(struct cx8800_tvnorm *norm)
+{
+	return (norm->id & V4L2_STD_625_50) ? 768 : 640;
+//	return (norm->id & V4L2_STD_625_50) ? 720 : 640;
+}
+
+static unsigned int inline norm_maxh(struct cx8800_tvnorm *norm)
+{
+	return (norm->id & V4L2_STD_625_50) ? 576 : 480;
+}
+
+static unsigned int inline norm_fsc8(struct cx8800_tvnorm *norm)
+{
+	static const unsigned int ntsc = 28636360;
+	static const unsigned int pal  = 35468950;
+	
+	return (norm->id & V4L2_STD_625_50) ? pal : ntsc;
+}
+
+static unsigned int inline norm_notchfilter(struct cx8800_tvnorm *norm)
+{
+	return (norm->id & V4L2_STD_625_50)
+		? HLNotchFilter135PAL
+		: HLNotchFilter135NTSC;
+}
+
+static unsigned int inline norm_htotal(struct cx8800_tvnorm *norm)
+{
+	return (norm->id & V4L2_STD_625_50) ? 1135 : 910;
+}
+
+static struct cx8800_tvnorm tvnorms[] = {
+	{
+		.name      = "NTSC-M",
+		.id        = V4L2_STD_NTSC_M,
+		.cxiformat = VideoFormatNTSC,
+	},{
+		.name      = "NTSC-JP",
+		.id        = V4L2_STD_NTSC_M_JP,
+		.cxiformat = VideoFormatNTSCJapan,
+#if 0
+	},{
+		.name      = "NTSC-4.43",
+		.id        = FIXME,
+		.cxiformat = VideoFormatNTSC443,
+#endif
+	},{
+		.name      = "PAL",
+		.id        = V4L2_STD_PAL,
+		.cxiformat = VideoFormatPAL,
+        },{
+		.name      = "PAL-M",
+		.id        = V4L2_STD_PAL_M,
+		.cxiformat = VideoFormatPALM,
+	},{
+		.name      = "PAL-N",
+		.id        = V4L2_STD_PAL_N,
+		.cxiformat = VideoFormatPALN,
+	},{
+		.name      = "PAL-Nc",
+		.id        = V4L2_STD_PAL_Nc,
+		.cxiformat = VideoFormatPALNC,
+	},{
+		.name      = "PAL-60",
+		.id        = V4L2_STD_PAL_60,
+		.cxiformat = VideoFormatPAL60,
+	},{
+		.name      = "SECAM",
+		.id        = V4L2_STD_SECAM,
+		.cxiformat = VideoFormatSECAM,
+	}
+};
+
+static struct cx8800_fmt formats[] = {
+	{
+		.name     = "8 bpp, gray",
+		.fourcc   = V4L2_PIX_FMT_GREY,
+		.cxformat = ColorFormatY8,
+		.depth    = 8,
+		.flags    = FORMAT_FLAGS_PACKED,
+	},{
+		.name     = "15 bpp RGB, le",
+		.fourcc   = V4L2_PIX_FMT_RGB555,
+		.cxformat = ColorFormatRGB15,
+		.depth    = 16,
+		.flags    = FORMAT_FLAGS_PACKED,
+	},{
+		.name     = "15 bpp RGB, be",
+		.fourcc   = V4L2_PIX_FMT_RGB555X,
+		.cxformat = ColorFormatRGB15 | ColorFormatBSWAP,
+		.depth    = 16,
+		.flags    = FORMAT_FLAGS_PACKED,
+	},{
+		.name     = "16 bpp RGB, le",
+		.fourcc   = V4L2_PIX_FMT_RGB565,
+		.cxformat = ColorFormatRGB16,
+		.depth    = 16,
+		.flags    = FORMAT_FLAGS_PACKED,
+	},{
+		.name     = "16 bpp RGB, be",
+		.fourcc   = V4L2_PIX_FMT_RGB565X,
+		.cxformat = ColorFormatRGB16 | ColorFormatBSWAP,
+		.depth    = 16,
+		.flags    = FORMAT_FLAGS_PACKED,
+	},{
+		.name     = "24 bpp RGB, le",
+		.fourcc   = V4L2_PIX_FMT_BGR24,
+		.cxformat = ColorFormatRGB24,
+		.depth    = 24,
+		.flags    = FORMAT_FLAGS_PACKED,
+	},{
+		.name     = "32 bpp RGB, le",
+		.fourcc   = V4L2_PIX_FMT_BGR32,
+		.cxformat = ColorFormatRGB32,
+		.depth    = 32,
+		.flags    = FORMAT_FLAGS_PACKED,
+	},{
+		.name     = "32 bpp RGB, be",
+		.fourcc   = V4L2_PIX_FMT_RGB32,
+		.cxformat = ColorFormatRGB32 | ColorFormatBSWAP | ColorFormatWSWAP,
+		.depth    = 32,
+		.flags    = FORMAT_FLAGS_PACKED,
+	},{
+		.name     = "4:2:2, packed, YUYV",
+		.fourcc   = V4L2_PIX_FMT_YUYV,
+		.cxformat = ColorFormatYUY2,
+		.depth    = 16,
+		.flags    = FORMAT_FLAGS_PACKED,
+	},{
+		.name     = "4:2:2, packed, UYVY",
+		.fourcc   = V4L2_PIX_FMT_UYVY,
+		.cxformat = ColorFormatYUY2 | ColorFormatBSWAP,
+		.depth    = 16,
+		.flags    = FORMAT_FLAGS_PACKED,
+	},
+};
+
+static struct cx8800_fmt* format_by_fourcc(unsigned int fourcc)
+{
+	unsigned int i;
+	
+	for (i = 0; i < ARRAY_SIZE(formats); i++)
+		if (formats[i].fourcc == fourcc)
+			return formats+i;
+	return NULL;
+}
+
+/* ------------------------------------------------------------------- */
+
+static const struct v4l2_queryctrl no_ctl = {
+	.name  = "42",
+	.flags = V4L2_CTRL_FLAG_DISABLED,
+};
+
+static struct cx88_ctrl cx8800_ctls[] = {
+	/* --- video --- */
+	{
+		.v = {
+			.id            = V4L2_CID_BRIGHTNESS,
+			.name          = "Brightness",
+			.minimum       = 0x00,
+			.maximum       = 0xff,
+			.step          = 1,
+			.default_value = 0,
+			.type          = V4L2_CTRL_TYPE_INTEGER,
+		},
+		.off             = 128,
+		.reg             = MO_CONTR_BRIGHT,
+		.mask            = 0x00ff,
+		.shift           = 0,
+	},{
+		.v = {
+			.id            = V4L2_CID_CONTRAST,
+			.name          = "Contrast",
+			.minimum       = 0,
+			.maximum       = 0xff,
+			.step          = 1,
+			.default_value = 0,
+			.type          = V4L2_CTRL_TYPE_INTEGER,
+		},
+		.reg             = MO_CONTR_BRIGHT,
+		.mask            = 0xff00,
+		.shift           = 8,
+	},{
+	/* --- audio --- */
+#if 0
+		.v = {
+			.id            = V4L2_CID_AUDIO_MUTE,
+			.name          = "Mute",
+			.minimum       = 0,
+			.maximum       = 1,
+			.type          = V4L2_CTRL_TYPE_BOOLEAN,
+		},
+		.reg             = AUD_VOL_CTL,
+		.mask            = (1 << 6),
+		.shift           = 6,
+	},{
+#endif
+		.v = {
+			.id            = V4L2_CID_AUDIO_VOLUME,
+			.name          = "Volume",
+			.minimum       = 0,
+			.maximum       = 0x3f,
+			.step          = 1,
+			.default_value = 0,
+			.type          = V4L2_CTRL_TYPE_INTEGER,
+		},
+		.reg             = AUD_VOL_CTL,
+		.mask            = 0x3f,
+		.shift           = 0,
+	}
+};
+const int CX8800_CTLS = ARRAY_SIZE(cx8800_ctls);
+
+/* ------------------------------------------------------------------- */
+/* resource management                                                 */
+
+static int res_get(struct cx8800_dev *dev, struct cx8800_fh *fh, unsigned int bit)
+{
+	if (fh->resources & bit)
+		/* have it already allocated */
+		return 1;
+
+	/* is it free? */
+	down(&dev->lock);
+	if (dev->resources & bit) {
+		/* no, someone else uses it */
+		up(&dev->lock);
+		return 0;
+	}
+	/* it's free, grab it */
+	fh->resources  |= bit;
+	dev->resources |= bit;
+	dprintk(1,"res: get %d\n",bit);
+	up(&dev->lock);
+	return 1;
+}
+
+static
+int res_check(struct cx8800_fh *fh, unsigned int bit)
+{
+	return (fh->resources & bit);
+}
+
+#if 0
+static
+int res_locked(struct cx8800_dev *dev, unsigned int bit)
+{
+	return (dev->resources & bit);
+}
+#endif
+
+static
+void res_free(struct cx8800_dev *dev, struct cx8800_fh *fh, unsigned int bits)
+{
+	if ((fh->resources & bits) != bits)
+		BUG();
+
+	down(&dev->lock);
+	fh->resources  &= ~bits;
+	dev->resources &= ~bits;
+	dprintk(1,"res: put %d\n",bits);
+	up(&dev->lock);
+}
+
+/* ------------------------------------------------------------------ */
+
+static const u32 xtal = 28636363;
+
+static int set_pll(struct cx8800_dev *dev, int prescale, u32 ofreq)
+{
+	static u32 pre[] = { 0, 0, 0, 3, 2, 1 };
+	u64 pll;
+	u32 reg;
+	int i;
+
+	if (prescale < 2)
+		prescale = 2;
+	if (prescale > 5)
+		prescale = 5;
+
+	pll = ofreq * 8 * prescale * (u64)(1 << 20);
+	do_div(pll,xtal);
+	reg = (pll & 0x3ffffff) | (pre[prescale] << 26);
+	if (((reg >> 20) & 0x3f) < 14) {
+		printk("%s: pll out of range\n",dev->name);
+		return -1;
+	}
+		
+	dprintk(1,"set_pll:    MO_PLL_REG       0x%08x [old=0x%08x,freq=%d]\n",
+		reg, cx_read(MO_PLL_REG), ofreq);
+	cx_write(MO_PLL_REG, reg);
+	for (i = 0; i < 10; i++) {
+		reg = cx_read(MO_DEVICE_STATUS);
+		if (reg & (1<<2)) {
+			dprintk(1,"pll locked [pre=%d,ofreq=%d]\n",
+				prescale,ofreq);
+			return 0;
+		}
+		dprintk(1,"pll not locked yet, waiting ...\n");
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(HZ/10);
+	}
+	dprintk(1,"pll NOT locked [pre=%d,ofreq=%d]\n",prescale,ofreq);
+	return -1;
+}
+
+static int set_tvaudio(struct cx8800_dev *dev)
+{
+	if (CX88_VMUX_TELEVISION != INPUT(dev->input)->type)
+		return 0;
+
+
+	dev->tvaudio = 0;
+	if (dev->tvnorm->id & V4L2_STD_PAL) {
+		if (nicam)
+			dev->tvaudio = WW_NICAM_BGDKL;
+		else
+			dev->tvaudio = WW_A2_BG;
+	}
+	if (0 == dev->tvaudio)
+		return 0;
+
+	cx_andor(MO_AFECFG_IO,    0x1f, 0x0);
+	cx88_set_tvaudio(dev);
+	//cx88_set_stereo(dev,norm->tvaudio, V4L2_TUNER_MODE_MONO);
+	//cx_write(MO_AUD_DMACNTRL, 0x03); /* need audio fifo */
+	return 0;
+}
+
+static int set_tvnorm(struct cx8800_dev *dev, struct cx8800_tvnorm *norm)
+{
+	u32 fsc8;
+	u32 adc_clock;
+	u32 vdec_clock;
+	u64 tmp64;
+	u32 bdelay,agcdelay,htotal;
+	struct video_channel c;
+	
+	dev->tvnorm = norm;
+	fsc8       = norm_fsc8(norm);
+	adc_clock  = xtal;
+	vdec_clock = fsc8;
+
+	dprintk(1,"set_tvnorm: \"%s\" fsc8=%d adc=%d vdec=%d\n",
+		norm->name, fsc8, adc_clock, vdec_clock);
+	set_pll(dev,2,vdec_clock);
+	
+	dprintk(1,"set_tvnorm: MO_INPUT_FORMAT  0x%08x [old=0x%08x]\n",
+		norm->cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f);
+	cx_andor(MO_INPUT_FORMAT, 0xf, norm->cxiformat);
+
+#if 1
+	// FIXME: as-is from DScaler
+	dprintk(1,"set_tvnorm: MO_OUTPUT_FORMAT 0x%08x [old=0x%08x]\n",
+		0x1c1f0008, cx_read(MO_OUTPUT_FORMAT));
+	cx_write(MO_OUTPUT_FORMAT, 0x1c1f0008);
+#endif
+
+	// MO_SCONV_REG = adc clock / video dec clock * 2^17
+	tmp64  = adc_clock * (u64)(1 << 17);
+	do_div(tmp64, vdec_clock);
+	dprintk(1,"set_tvnorm: MO_SCONV_REG     0x%08x [old=0x%08x]\n",
+		(u32)tmp64, cx_read(MO_SCONV_REG));
+	cx_write(MO_SCONV_REG, (u32)tmp64);
+
+	// MO_SUB_STEP = 8 * fsc / video dec clock * 2^22
+	tmp64  = fsc8 * (u64)(1 << 22);
+	do_div(tmp64, vdec_clock);
+	dprintk(1,"set_tvnorm: MO_SUB_STEP      0x%08x [old=0x%08x]\n",
+		(u32)tmp64, cx_read(MO_SUB_STEP));
+	cx_write(MO_SUB_STEP, (u32)tmp64);
+
+	// MO_SUB_STEP_DR = 8 * 4406250 / video dec clock * 2^22
+	tmp64  = 4406250 * 8 * (u64)(1 << 22);
+	do_div(tmp64, vdec_clock);
+	dprintk(1,"set_tvnorm: MO_SUB_STEP_DR   0x%08x [old=0x%08x]\n",
+		(u32)tmp64, cx_read(MO_SUB_STEP_DR));
+	cx_write(MO_SUB_STEP_DR, (u32)tmp64);
+
+	// bdelay + agcdelay
+	bdelay   = vdec_clock * 65 / 20000000 + 21;
+	agcdelay = vdec_clock * 68 / 20000000 + 15;
+	dprintk(1,"set_tvnorm: MO_AGC_BURST     0x%08x [old=0x%08x,bdelay=%d,agcdelay=%d]\n",
+		(bdelay << 8) | agcdelay, cx_read(MO_AGC_BURST), bdelay, agcdelay);
+	cx_write(MO_AGC_BURST, (bdelay << 8) | agcdelay);
+
+	// htotal
+	tmp64 = norm_htotal(norm) * (u64)vdec_clock;
+	do_div(tmp64, fsc8);
+	htotal = (u32)tmp64 | (norm_notchfilter(norm) << 11);
+	dprintk(1,"set_tvnorm: MO_HTOTAL        0x%08x [old=0x%08x,htotal=%d]\n",
+		htotal, cx_read(MO_HTOTAL), (u32)tmp64);
+	cx_write(MO_HTOTAL, htotal);
+	
+	// audio
+	set_tvaudio(dev);
+
+	// tell i2c chips
+	memset(&c,0,sizeof(c));
+	c.channel = dev->input;
+	c.norm = VIDEO_MODE_PAL;
+	if ((norm->id & (V4L2_STD_NTSC_M|V4L2_STD_NTSC_M_JP)))
+		c.norm = VIDEO_MODE_NTSC;
+	if (norm->id & V4L2_STD_SECAM)
+		c.norm = VIDEO_MODE_SECAM;
+	cx8800_call_i2c_clients(dev,VIDIOCSCHAN,&c);
+
+	// done
+	return 0;
+}
+
+static int set_scale(struct cx8800_dev *dev, unsigned int width, unsigned int height,
+		     int interlaced)
+{
+	unsigned int swidth  = norm_swidth(dev->tvnorm);
+	unsigned int sheight = norm_maxh(dev->tvnorm);
+	u32 value;
+
+	dprintk(1,"set_scale: %dx%d [%s]\n", width, height, dev->tvnorm->name);
+
+	// recalc H delay and scale registers
+	value = (width * norm_hdelay(dev->tvnorm)) / swidth;
+	cx_write(MO_HDELAY_EVEN,  value);
+	cx_write(MO_HDELAY_ODD,   value);
+	dprintk(1,"set_scale: hdelay  0x%04x\n", value);
+	
+	value = (swidth * 4096 / width) - 4096;
+	cx_write(MO_HSCALE_EVEN,  value);
+	cx_write(MO_HSCALE_ODD,   value);
+	dprintk(1,"set_scale: hscale  0x%04x\n", value);
+
+	cx_write(MO_HACTIVE_EVEN, width);
+	cx_write(MO_HACTIVE_ODD,  width);
+	dprintk(1,"set_scale: hactive 0x%04x\n", width);
+	
+	// recalc V scale Register (delay is constant)
+	cx_write(MO_VDELAY_EVEN, norm_vdelay(dev->tvnorm));
+	cx_write(MO_VDELAY_ODD,  norm_vdelay(dev->tvnorm));
+	dprintk(1,"set_scale: vdelay  0x%04x\n", norm_vdelay(dev->tvnorm));
+	
+	value = (0x10000 - (sheight * 512 / height - 512)) & 0x1fff;
+	cx_write(MO_VSCALE_EVEN,  value);
+	cx_write(MO_VSCALE_ODD,   value);
+	dprintk(1,"set_scale: vscale  0x%04x\n", value);
+
+	cx_write(MO_VACTIVE_EVEN, sheight);
+	cx_write(MO_VACTIVE_ODD,  sheight);
+	dprintk(1,"set_scale: vactive 0x%04x\n", sheight);
+
+	// setup filters
+	value = 0;
+	value |= (1 << 19);  // CFILT (default)
+	if (interlaced)
+		value |= (1 << 3); // VINT (interlaced vertical scaling)
+	cx_write(MO_FILTER_EVEN,  value);
+	cx_write(MO_FILTER_ODD,   value);
+	dprintk(1,"set_scale: filter  0x%04x\n", value);
+	
+	return 0;
+}
+
+static int video_mux(struct cx8800_dev *dev, unsigned int input)
+{
+	dprintk(1,"video_mux: %d [vmux=%d,gpio=0x%x]\n",
+		input, INPUT(input)->vmux, INPUT(input)->gpio0);
+	dev->input = input;
+	cx_andor(MO_INPUT_FORMAT, 0x03 << 14, INPUT(input)->vmux << 14);
+	cx_write(MO_GP0_IO, INPUT(input)->gpio0);
+	return 0;
+}
+
+/* ------------------------------------------------------------------ */
+
+static int start_video_dma(struct cx8800_dev    *dev,
+			   struct cx88_dmaqueue *q,
+			   struct cx88_buffer   *buf)
+{
+	/* setup fifo + format */
+	cx88_sram_channel_setup(dev, &cx88_sram_channels[SRAM_CH21],
+				buf->bpl, buf->risc.dma);
+	set_scale(dev, buf->vb.width, buf->vb.height, 1);
+	cx_write(MO_COLOR_CTRL, buf->fmt->cxformat | ColorFormatGamma);
+
+	/* reset counter */
+	cx_write(MO_VIDY_GPCNTRL,0x3);
+	q->count = 1;
+
+	/* enable irqs */
+	cx_set(MO_PCI_INTMSK, 0x00fc01);
+	cx_set(MO_VID_INTMSK, 0x0f0011);
+	
+	/* enable capture */
+	cx_set(VID_CAPTURE_CONTROL,0x06);
+	
+	/* start dma */
+	cx_set(MO_DEV_CNTRL2, (1<<5));
+	cx_set(MO_VID_DMACNTRL, 0x11);
+
+	return 0;
+}
+
+static int restart_video_queue(struct cx8800_dev    *dev,
+			       struct cx88_dmaqueue *q)
+{
+	struct cx88_buffer *buf, *prev;
+	struct list_head *item;
+	
+	if (!list_empty(&q->active)) {
+	        buf = list_entry(q->active.next, struct cx88_buffer, vb.queue);
+		dprintk(2,"restart_queue [%p/%d]: restart dma\n",
+			buf, buf->vb.i);
+		start_video_dma(dev, q, buf);
+		list_for_each(item,&q->active) {
+			buf = list_entry(item, struct cx88_buffer, vb.queue);
+			buf->count    = q->count++;
+		}
+		mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
+		return 0;
+	}
+
+	prev = NULL;
+	for (;;) {
+		if (list_empty(&q->queued))
+			return 0;
+	        buf = list_entry(q->queued.next, struct cx88_buffer, vb.queue);
+		if (NULL == prev) {
+			list_del(&buf->vb.queue);
+			list_add_tail(&buf->vb.queue,&q->active);
+			start_video_dma(dev, q, buf);
+			buf->vb.state = STATE_ACTIVE;
+			buf->count    = q->count++;
+			mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
+			dprintk(2,"[%p/%d] restart_queue - first active\n",
+				buf,buf->vb.i);
+
+		} else if (prev->vb.width  == buf->vb.width  &&
+			   prev->vb.height == buf->vb.height &&
+			   prev->fmt       == buf->fmt) {
+			list_del(&buf->vb.queue);
+			list_add_tail(&buf->vb.queue,&q->active);
+			buf->vb.state = STATE_ACTIVE;
+			buf->count    = q->count++;
+			prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
+			dprintk(2,"[%p/%d] restart_queue - move to active\n",
+				buf,buf->vb.i);
+		} else {
+			return 0;
+		}
+		prev = buf;
+	}
+}
+
+/* ------------------------------------------------------------------ */
+
+static int
+buffer_setup(struct file *file, unsigned int *count, unsigned int *size)
+{
+	struct cx8800_fh *fh = file->private_data;
+	
+	*size = fh->fmt->depth*fh->width*fh->height >> 3;
+	if (0 == *count)
+		*count = 32;
+	while (*size * *count > vid_limit * 1024 * 1024)
+		(*count)--;
+	return 0;
+}
+
+static int
+buffer_prepare(struct file *file, struct videobuf_buffer *vb,
+	       enum v4l2_field field)
+{
+	struct cx8800_fh   *fh  = file->private_data;
+	struct cx8800_dev  *dev = fh->dev;
+	struct cx88_buffer *buf = (struct cx88_buffer*)vb;
+	int rc, init_buffer = 0;
+
+	BUG_ON(NULL == fh->fmt);
+	if (fh->width  < 48 || fh->width  > norm_maxw(dev->tvnorm) ||
+	    fh->height < 32 || fh->height > norm_maxh(dev->tvnorm))
+		return -EINVAL;
+	buf->vb.size = (fh->width * fh->height * fh->fmt->depth) >> 3;
+	if (0 != buf->vb.baddr  &&  buf->vb.bsize < buf->vb.size)
+		return -EINVAL;
+
+	if (buf->fmt       != fh->fmt    ||
+	    buf->vb.width  != fh->width  ||
+	    buf->vb.height != fh->height ||
+	    buf->vb.field  != field) {
+		buf->fmt       = fh->fmt;
+		buf->vb.width  = fh->width;
+		buf->vb.height = fh->height;
+		buf->vb.field  = field;
+		init_buffer = 1;
+	}
+
+	if (STATE_NEEDS_INIT == buf->vb.state) {
+		init_buffer = 1;
+		if (0 != (rc = videobuf_iolock(dev->pci,&buf->vb,NULL)))
+			goto fail;
+	}
+
+	if (init_buffer) {
+		buf->bpl = buf->vb.width * buf->fmt->depth >> 3;
+		switch (buf->vb.field) {
+		case V4L2_FIELD_TOP:
+			cx88_risc_buffer(dev->pci, &buf->risc,
+					 buf->vb.dma.sglist, 0, UNSET,
+					 buf->bpl, 0, buf->vb.height);
+			break;
+		case V4L2_FIELD_BOTTOM:
+			cx88_risc_buffer(dev->pci, &buf->risc,
+					 buf->vb.dma.sglist, UNSET, 0,
+					 buf->bpl, 0, buf->vb.height);
+			break;
+		case V4L2_FIELD_INTERLACED:
+			cx88_risc_buffer(dev->pci, &buf->risc,
+					 buf->vb.dma.sglist, 0, buf->bpl,
+					 buf->bpl, buf->bpl,
+					 buf->vb.height >> 1);
+			break;
+		default:
+			BUG();
+		}
+	}
+	dprintk(2,"[%p/%d] buffer_prepare - %dx%d %dbpp \"%s\" - dma=0x%08lx\n",
+		buf, buf->vb.i,
+		fh->width, fh->height, fh->fmt->depth, fh->fmt->name,
+		(unsigned long)buf->risc.dma);
+
+	buf->vb.state = STATE_PREPARED;
+	return 0;
+
+ fail:
+	cx88_free_buffer(dev->pci,buf);
+	return rc;
+}
+
+static void
+buffer_queue(struct file *file, struct videobuf_buffer *vb)
+{
+	struct cx88_buffer    *buf  = (struct cx88_buffer*)vb;
+	struct cx88_buffer    *prev;
+	struct cx8800_fh      *fh   = file->private_data;
+	struct cx8800_dev     *dev  = fh->dev;
+	struct cx88_dmaqueue  *q    = &dev->vidq;
+
+	/* add jump to stopper */
+	buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | 0x10000);
+	buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma);
+
+	if (!list_empty(&q->queued)) {
+		list_add_tail(&buf->vb.queue,&q->queued);
+		buf->vb.state = STATE_QUEUED;
+		dprintk(2,"[%p/%d] buffer_queue - append to queued\n",
+			buf, buf->vb.i);
+
+	} else if (list_empty(&q->active)) {
+		list_add_tail(&buf->vb.queue,&q->active);
+		start_video_dma(dev, q, buf);
+		buf->vb.state = STATE_ACTIVE;
+		buf->count    = q->count++;
+		mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
+		dprintk(2,"[%p/%d] buffer_queue - first active\n",
+			buf, buf->vb.i);
+
+	} else {
+		prev = list_entry(q->active.prev, struct cx88_buffer, vb.queue);
+		if (prev->vb.width  == buf->vb.width  &&
+		    prev->vb.height == buf->vb.height &&
+		    prev->fmt       == buf->fmt) {
+			list_add_tail(&buf->vb.queue,&q->active);
+			buf->vb.state = STATE_ACTIVE;
+			buf->count    = q->count++;
+			prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
+			dprintk(2,"[%p/%d] buffer_queue - append to active\n",
+				buf, buf->vb.i);
+
+		} else {
+			list_add_tail(&buf->vb.queue,&q->queued);
+			buf->vb.state = STATE_QUEUED;
+			dprintk(2,"[%p/%d] buffer_queue - first queued\n",
+				buf, buf->vb.i);
+		}
+	}
+}
+
+static void buffer_release(struct file *file, struct videobuf_buffer *vb)
+{
+	struct cx88_buffer *buf = (struct cx88_buffer*)vb;
+	struct cx8800_fh   *fh  = file->private_data;
+
+	cx88_free_buffer(fh->dev->pci,buf);
+}
+
+static struct videobuf_queue_ops cx8800_video_qops = {
+	.buf_setup    = buffer_setup,
+	.buf_prepare  = buffer_prepare,
+	.buf_queue    = buffer_queue,
+	.buf_release  = buffer_release,
+};
+
+/* ------------------------------------------------------------------ */
+
+#if 0 /* overlay support not finished yet */
+static u32* ov_risc_field(struct cx8800_dev *dev, struct cx8800_fh *fh,
+			  u32 *rp, struct btcx_skiplist *skips,
+			  u32 sync_line, int skip_even, int skip_odd)
+{
+	int line,maxy,start,end,skip,nskips;
+	u32 ri,ra;
+	u32 addr;
+
+	/* sync instruction */
+	*(rp++) = cpu_to_le32(RISC_RESYNC | sync_line);
+
+	addr  = (unsigned long)dev->fbuf.base;
+	addr += dev->fbuf.fmt.bytesperline * fh->win.w.top;
+	addr += (fh->fmt->depth >> 3)      * fh->win.w.left;
+
+	/* scan lines */
+	for (maxy = -1, line = 0; line < fh->win.w.height;
+	     line++, addr += dev->fbuf.fmt.bytesperline) {
+		if ((line%2) == 0  &&  skip_even)
+			continue;
+		if ((line%2) == 1  &&  skip_odd)
+			continue;
+
+		/* calculate clipping */
+		if (line > maxy)
+			btcx_calc_skips(line, fh->win.w.width, &maxy,
+					skips, &nskips, fh->clips, fh->nclips);
+
+		/* write out risc code */
+		for (start = 0, skip = 0; start < fh->win.w.width; start = end) {
+			if (skip >= nskips) {
+				ri  = RISC_WRITE;
+				end = fh->win.w.width;
+			} else if (start < skips[skip].start) {
+				ri  = RISC_WRITE;
+				end = skips[skip].start;
+			} else {
+				ri  = RISC_SKIP;
+				end = skips[skip].end;
+				skip++;
+			}
+			if (RISC_WRITE == ri)
+				ra = addr + (fh->fmt->depth>>3)*start;
+			else
+				ra = 0;
+				
+			if (0 == start)
+				ri |= RISC_SOL;
+			if (fh->win.w.width == end)
+				ri |= RISC_EOL;
+			ri |= (fh->fmt->depth>>3) * (end-start);
+
+			*(rp++)=cpu_to_le32(ri);
+			if (0 != ra)
+				*(rp++)=cpu_to_le32(ra);
+		}
+	}
+	kfree(skips);
+	return rp;
+}
+
+static int ov_risc_frame(struct cx8800_dev *dev, struct cx8800_fh *fh,
+			 struct cx88_buffer *buf)
+{
+	struct btcx_skiplist *skips;
+	u32 instructions,fields;
+	u32 *rp;
+	int rc;
+	
+	/* skip list for window clipping */
+	if (NULL == (skips = kmalloc(sizeof(*skips) * fh->nclips,GFP_KERNEL)))
+		return -ENOMEM;
+	
+	fields = 0;
+	if (V4L2_FIELD_HAS_TOP(fh->win.field))
+		fields++;
+	if (V4L2_FIELD_HAS_BOTTOM(fh->win.field))
+		fields++;
+
+        /* estimate risc mem: worst case is (clip+1) * lines instructions
+           + syncs + jump (all 2 dwords) */
+	instructions  = (fh->nclips+1) * fh->win.w.height;
+	instructions += 3 + 4;
+	if ((rc = btcx_riscmem_alloc(dev->pci,&buf->risc,instructions*8)) < 0) {
+		kfree(skips);
+		return rc;
+	}
+
+	/* write risc instructions */
+	rp = buf->risc.cpu;
+	switch (fh->win.field) {
+	case V4L2_FIELD_TOP:
+		rp = ov_risc_field(dev, fh, rp, skips, 0,     0, 0);
+		break;
+	case V4L2_FIELD_BOTTOM:
+		rp = ov_risc_field(dev, fh, rp, skips, 0x200, 0, 0);
+		break;
+	case V4L2_FIELD_INTERLACED:
+		rp = ov_risc_field(dev, fh, rp, skips, 0,     0, 1);
+		rp = ov_risc_field(dev, fh, rp, skips, 0x200, 1, 0);
+		break;
+	default:
+		BUG();
+	}
+
+	/* save pointer to jmp instruction address */
+	buf->risc.jmp = rp;
+	kfree(skips);
+	return 0;
+}
+
+static int verify_window(struct cx8800_dev *dev, struct v4l2_window *win)
+{
+	enum v4l2_field field;
+	int maxw, maxh;
+
+	if (NULL == dev->fbuf.base)
+		return -EINVAL;
+	if (win->w.width < 48 || win->w.height <  32)
+		return -EINVAL;
+	if (win->clipcount > 2048)
+		return -EINVAL;
+
+	field = win->field;
+	maxw  = norm_maxw(dev->tvnorm);
+	maxh  = norm_maxh(dev->tvnorm);
+
+	if (V4L2_FIELD_ANY == field) {
+                field = (win->w.height > maxh/2)
+                        ? V4L2_FIELD_INTERLACED
+                        : V4L2_FIELD_TOP;
+        }
+        switch (field) {
+        case V4L2_FIELD_TOP:
+        case V4L2_FIELD_BOTTOM:
+                maxh = maxh / 2;
+                break;
+        case V4L2_FIELD_INTERLACED:
+                break;
+        default:
+                return -EINVAL;
+        }
+
+	win->field = field;
+	if (win->w.width > maxw)
+		win->w.width = maxw;
+	if (win->w.height > maxh)
+		win->w.height = maxh;
+	return 0;
+}
+
+static int setup_window(struct cx8800_dev *dev, struct cx8800_fh *fh,
+			struct v4l2_window *win)
+{
+	struct v4l2_clip *clips = NULL;
+	int n,size,retval = 0;
+
+	if (NULL == fh->fmt)
+		return -EINVAL;
+	retval = verify_window(dev,win);
+	if (0 != retval)
+		return retval;
+
+	/* copy clips  --  luckily v4l1 + v4l2 are binary
+	   compatible here ...*/
+	n = win->clipcount;
+	size = sizeof(*clips)*(n+4);
+	clips = kmalloc(size,GFP_KERNEL);
+	if (NULL == clips)
+		return -ENOMEM;
+	if (n > 0) {
+		if (copy_from_user(clips,win->clips,sizeof(struct v4l2_clip)*n)) {
+			kfree(clips);
+			return -EFAULT;
+		}
+	}
+
+	/* clip against screen */
+	if (NULL != dev->fbuf.base)
+		n = btcx_screen_clips(dev->fbuf.fmt.width, dev->fbuf.fmt.height,
+				      &win->w, clips, n);
+	btcx_sort_clips(clips,n);
+
+	/* 4-byte alignments */
+	switch (fh->fmt->depth) {
+	case 8:
+	case 24:
+		btcx_align(&win->w, clips, n, 3);
+		break;
+	case 16:
+		btcx_align(&win->w, clips, n, 1);
+		break;
+	case 32:
+		/* no alignment fixups needed */
+		break;
+	default:
+		BUG();
+	}
+	
+	down(&fh->vidq.lock);
+	if (fh->clips)
+		kfree(fh->clips);
+	fh->clips    = clips;
+	fh->nclips   = n;
+	fh->win      = *win;
+#if 0
+	fh->ov.setup_ok = 1;
+#endif
+	
+	/* update overlay if needed */
+	retval = 0;
+#if 0
+	if (check_btres(fh, RESOURCE_OVERLAY)) {
+		struct bttv_buffer *new;
+		
+		new = videobuf_alloc(sizeof(*new));
+		bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
+		retval = bttv_switch_overlay(btv,fh,new);
+	}
+#endif
+	up(&fh->vidq.lock);
+	return retval;
+}
+#endif
+
+/* ------------------------------------------------------------------ */
+
+static int video_open(struct inode *inode, struct file *file)
+{
+	int minor = iminor(inode);
+	struct cx8800_dev *h,*dev = NULL;
+	struct cx8800_fh *fh;
+	struct list_head *list;
+	enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+	int radio = 0;
+	
+	list_for_each(list,&cx8800_devlist) {
+		h = list_entry(list, struct cx8800_dev, devlist);
+		if (h->video_dev->minor == minor)
+			dev = h;
+		if (h->radio_dev &&
+		    h->radio_dev->minor == minor) {
+			radio = 1;
+			dev   = h;
+		}
+	}
+	if (NULL == dev)
+		return -ENODEV;
+
+	dprintk(1,"open minor=%d radio=%d type=%s\n",
+		minor,radio,v4l2_type_names[type]);
+
+	/* allocate + initialize per filehandle data */
+	fh = kmalloc(sizeof(*fh),GFP_KERNEL);
+	if (NULL == fh)
+		return -ENOMEM;
+	memset(fh,0,sizeof(*fh));
+	file->private_data = fh;
+	fh->dev      = dev;
+	fh->radio    = radio;
+	fh->type     = type;
+	fh->width    = 320;
+	fh->height   = 240;
+	fh->fmt      = format_by_fourcc(V4L2_PIX_FMT_BGR24);
+
+	videobuf_queue_init(&fh->vidq, &cx8800_video_qops,
+			    dev->pci, &dev->slock,
+			    V4L2_BUF_TYPE_VIDEO_CAPTURE,
+			    V4L2_FIELD_INTERLACED,
+			    sizeof(struct cx88_buffer));
+	init_MUTEX(&fh->vidq.lock);
+
+	if (fh->radio) {
+		dprintk(1,"video_open: setting radio device\n");
+		cx_write(MO_GP0_IO, cx88_boards[dev->board].radio.gpio0);
+		dev->tvaudio = WW_FM;
+		cx88_set_tvaudio(dev);
+		cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO);
+		cx8800_call_i2c_clients(dev,AUDC_SET_RADIO,NULL);
+	}
+
+        return 0;
+}
+
+static ssize_t
+video_read(struct file *file, char *data, size_t count, loff_t *ppos)
+{
+	struct cx8800_fh *fh = file->private_data;
+
+	return videobuf_read_one(file, &fh->vidq, data, count, ppos);
+}
+
+static unsigned int
+video_poll(struct file *file, struct poll_table_struct *wait)
+{
+	return POLLERR;
+}
+
+static int video_release(struct inode *inode, struct file *file)
+{
+	struct cx8800_fh  *fh  = file->private_data;
+	struct cx8800_dev *dev = fh->dev;
+
+	/* turn off overlay */
+	if (res_check(fh, RESOURCE_OVERLAY)) {
+		/* FIXME */
+		res_free(dev,fh,RESOURCE_OVERLAY);
+	}
+
+	/* stop video capture */
+	if (res_check(fh, RESOURCE_VIDEO)) {
+		videobuf_queue_cancel(file,&fh->vidq);
+		res_free(dev,fh,RESOURCE_VIDEO);
+	}
+	if (fh->vidq.read_buf) {
+		buffer_release(file,fh->vidq.read_buf);
+		kfree(fh->vidq.read_buf);
+	}
+
+	file->private_data = NULL;
+	kfree(fh);
+	return 0;
+}
+
+static int
+video_mmap(struct file *file, struct vm_area_struct * vma)
+{
+	struct cx8800_fh *fh = file->private_data;
+
+	return videobuf_mmap_mapper(vma,&fh->vidq);
+}
+
+/* ------------------------------------------------------------------ */
+
+static int get_control(struct cx8800_dev *dev, struct v4l2_control *ctl)
+{
+	struct cx88_ctrl *c = NULL;
+	u32 value;
+	int i;
+	
+	for (i = 0; i < CX8800_CTLS; i++)
+		if (cx8800_ctls[i].v.id == ctl->id)
+			c = &cx8800_ctls[i];
+	if (NULL == c)
+		return -EINVAL;
+
+	value = cx_read(c->reg);
+	ctl->value = ((value + (c->off << c->shift)) & c->mask) >> c->shift;
+	return 0;
+}
+
+static int set_control(struct cx8800_dev *dev, struct v4l2_control *ctl)
+{
+	struct cx88_ctrl *c = NULL;
+	u32 value;
+	int i;
+
+	for (i = 0; i < CX8800_CTLS; i++)
+		if (cx8800_ctls[i].v.id == ctl->id)
+			c = &cx8800_ctls[i];
+	if (NULL == c)
+		return -EINVAL;
+
+	if (ctl->value < c->v.minimum)
+		return -ERANGE;
+	if (ctl->value > c->v.maximum)
+		return -ERANGE;
+	value = ((ctl->value - c->off) << c->shift) & c->mask;
+	cx_andor(c->reg, c->mask, value);
+	return 0;
+}
+
+/* ------------------------------------------------------------------ */
+
+static int cx8800_g_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh,
+			struct v4l2_format *f)
+{
+	switch (f->type) {
+	case V4L2_BUF_TYPE_VIDEO_CAPTURE:
+		memset(&f->fmt.pix,0,sizeof(f->fmt.pix));
+		f->fmt.pix.width        = fh->width;
+		f->fmt.pix.height       = fh->height;
+		f->fmt.pix.field        = fh->vidq.field;
+		f->fmt.pix.pixelformat  = fh->fmt->fourcc;
+		f->fmt.pix.bytesperline =
+			(f->fmt.pix.width * fh->fmt->depth) >> 3;
+		f->fmt.pix.sizeimage =
+			f->fmt.pix.height * f->fmt.pix.bytesperline;
+		return 0;
+	default:
+		return -EINVAL;
+	}
+}
+
+static int cx8800_try_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh,
+			  struct v4l2_format *f)
+{
+	switch (f->type) {
+	case V4L2_BUF_TYPE_VIDEO_CAPTURE:
+	{
+		struct cx8800_fmt *fmt;
+		enum v4l2_field field;
+		unsigned int maxw, maxh;
+
+		fmt = format_by_fourcc(f->fmt.pix.pixelformat);
+		if (NULL == fmt)
+			return -EINVAL;
+
+		field = f->fmt.pix.field;
+		maxw  = norm_maxw(dev->tvnorm);
+		maxh  = norm_maxh(dev->tvnorm);
+
+#if 0
+		if (V4L2_FIELD_ANY == field) {
+			field = (f->fmt.pix.height > maxh/2)
+				? V4L2_FIELD_INTERLACED
+				: V4L2_FIELD_BOTTOM;
+		}
+#else
+		field = V4L2_FIELD_INTERLACED;
+#endif
+		switch (field) {
+		case V4L2_FIELD_TOP:
+		case V4L2_FIELD_BOTTOM:
+			maxh = maxh / 2;
+			break;
+		case V4L2_FIELD_INTERLACED:
+			break;
+		default:
+			return -EINVAL;
+		}
+
+		f->fmt.pix.field = field;
+		if (f->fmt.pix.width < 48)
+			f->fmt.pix.width = 48;
+		if (f->fmt.pix.height < 32)
+			f->fmt.pix.height = 32;
+		if (f->fmt.pix.width > maxw)
+			f->fmt.pix.width = maxw;
+		if (f->fmt.pix.height > maxh)
+			f->fmt.pix.height = maxh;
+		f->fmt.pix.bytesperline =
+			(f->fmt.pix.width * fmt->depth) >> 3;
+		f->fmt.pix.sizeimage =
+			f->fmt.pix.height * f->fmt.pix.bytesperline;
+
+		return 0;
+	}
+	default:
+		return -EINVAL;
+	}
+}
+
+static int cx8800_s_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh,
+			struct v4l2_format *f)
+{
+	int err;
+	
+	switch (f->type) {
+	case V4L2_BUF_TYPE_VIDEO_CAPTURE:
+		err = cx8800_try_fmt(dev,fh,f);
+		if (0 != err)
+			return err;
+
+		fh->fmt        = format_by_fourcc(f->fmt.pix.pixelformat);
+		fh->width      = f->fmt.pix.width;
+		fh->height     = f->fmt.pix.height;
+		fh->vidq.field = f->fmt.pix.field;
+		return 0;
+	default:
+		return -EINVAL;
+	}
+}
+
+/*
+ * This function is _not_ called directly, but from
+ * video_generic_ioctl (and maybe others).  userspace
+ * copying is done already, arg is a kernel pointer.
+ */
+static int video_do_ioctl(struct inode *inode, struct file *file,
+			  unsigned int cmd, void *arg)
+{
+	struct cx8800_fh  *fh  = file->private_data;
+	struct cx8800_dev *dev = fh->dev;
+#if 0
+	unsigned long flags;
+#endif
+	int err;
+
+	if (video_debug > 1)
+		cx88_print_ioctl(dev->name,cmd);
+	switch (cmd) {
+	case VIDIOC_QUERYCAP:
+	{
+		struct v4l2_capability *cap = arg;
+		
+		memset(cap,0,sizeof(*cap));
+                strcpy(cap->driver, "cx8800");
+		strlcpy(cap->card, cx88_boards[dev->board].name,
+			sizeof(cap->card));
+		sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci));
+		cap->version = CX88_VERSION_CODE;
+		cap->capabilities =
+			V4L2_CAP_VIDEO_CAPTURE |
+			V4L2_CAP_READWRITE     |
+			V4L2_CAP_STREAMING     |
+#if 0
+			V4L2_CAP_VIDEO_OVERLAY |
+			V4L2_CAP_VBI_CAPTURE   |
+#endif
+			0;
+		if (UNSET != dev->tuner_type)
+			cap->capabilities |= V4L2_CAP_TUNER;
+
+		return 0;
+	}
+
+	/* ---------- tv norms ---------- */
+	case VIDIOC_ENUMSTD:
+	{
+		struct v4l2_standard *e = arg;
+		unsigned int i;
+
+		i = e->index;
+		if (i >= ARRAY_SIZE(tvnorms))
+			return -EINVAL;
+		err = v4l2_video_std_construct(e, tvnorms[e->index].id,
+					       tvnorms[e->index].name);
+		e->index = i;
+		if (err < 0)
+			return err;
+		return 0;
+	}
+	case VIDIOC_G_STD:
+	{
+		v4l2_std_id *id = arg;
+
+		*id = dev->tvnorm->id;
+		return 0;
+	}
+	case VIDIOC_S_STD:
+	{
+		v4l2_std_id *id = arg;
+		unsigned int i;
+
+		for(i = 0; i < ARRAY_SIZE(tvnorms); i++)
+			if (*id & tvnorms[i].id)
+				break;
+		if (i == ARRAY_SIZE(tvnorms))
+			return -EINVAL;
+
+		down(&dev->lock);
+		set_tvnorm(dev,&tvnorms[i]);
+		up(&dev->lock);
+		return 0;
+	}
+
+	/* ------ input switching ---------- */
+	case VIDIOC_ENUMINPUT:
+	{
+		static const char *iname[] = {
+			[ CX88_VMUX_COMPOSITE1 ] = "Composite1",
+			[ CX88_VMUX_COMPOSITE2 ] = "Composite2",
+			[ CX88_VMUX_COMPOSITE3 ] = "Composite3",
+			[ CX88_VMUX_COMPOSITE4 ] = "Composite4",
+			[ CX88_VMUX_TELEVISION ] = "Television",
+			[ CX88_VMUX_SVIDEO     ] = "S-Video",
+			[ CX88_VMUX_DEBUG      ] = "for debug only",
+		};
+		struct v4l2_input *i = arg;
+		unsigned int n;
+
+		n = i->index;
+		if (n >= 4)
+			return -EINVAL;
+		if (0 == INPUT(n)->type)
+			return -EINVAL;
+		memset(i,0,sizeof(*i));
+		i->index = n;
+		i->type  = V4L2_INPUT_TYPE_CAMERA;
+		strcpy(i->name,iname[INPUT(n)->type]);
+		if (CX88_VMUX_TELEVISION == INPUT(n)->type)
+			i->type = V4L2_INPUT_TYPE_TUNER;
+		for (n = 0; n < ARRAY_SIZE(tvnorms); n++)
+			i->std |= tvnorms[n].id;
+		return 0;
+	}
+	case VIDIOC_G_INPUT:
+	{
+		unsigned int *i = arg;
+
+		*i = dev->input;
+		return 0;
+	}
+	case VIDIOC_S_INPUT:
+	{
+		unsigned int *i = arg;
+		
+		if (*i >= 4)
+			return -EINVAL;
+		down(&dev->lock);
+		video_mux(dev,*i);
+		up(&dev->lock);
+		return 0;
+	}
+
+	/* --- capture ioctls ---------------------------------------- */
+	case VIDIOC_ENUM_FMT:
+	{
+		struct v4l2_fmtdesc *f = arg;
+		enum v4l2_buf_type type;
+		unsigned int index;
+
+		index = f->index;
+		type  = f->type;
+		switch (type) {
+		case V4L2_BUF_TYPE_VIDEO_CAPTURE:
+			if (index >= ARRAY_SIZE(formats))
+				return -EINVAL;
+			memset(f,0,sizeof(*f));
+			f->index = index;
+			f->type  = type;
+			strlcpy(f->description,formats[index].name,sizeof(f->description));
+			f->pixelformat = formats[index].fourcc;
+			break;
+		default:
+			return -EINVAL;
+		}
+		return 0;
+	}
+	case VIDIOC_G_FMT:
+	{
+		struct v4l2_format *f = arg;
+		return cx8800_g_fmt(dev,fh,f);
+	}
+	case VIDIOC_S_FMT:
+	{
+		struct v4l2_format *f = arg;
+		return cx8800_s_fmt(dev,fh,f);
+	}
+	case VIDIOC_TRY_FMT:
+	{
+		struct v4l2_format *f = arg;
+		return cx8800_try_fmt(dev,fh,f);
+	}
+
+	/* --- controls ---------------------------------------------- */
+	case VIDIOC_QUERYCTRL:
+	{
+		struct v4l2_queryctrl *c = arg;
+		int i;
+
+		if (c->id <  V4L2_CID_BASE ||
+		    c->id >= V4L2_CID_LASTP1)
+			return -EINVAL;
+		for (i = 0; i < CX8800_CTLS; i++)
+			if (cx8800_ctls[i].v.id == c->id)
+				break;
+		if (i == CX8800_CTLS) {
+			*c = no_ctl;
+			return 0;
+		}
+		*c = cx8800_ctls[i].v;
+		return 0;
+	}
+	case VIDIOC_G_CTRL:
+		return get_control(dev,arg);
+	case VIDIOC_S_CTRL:
+		return set_control(dev,arg);
+		
+	/* --- tuner ioctls ------------------------------------------ */
+	case VIDIOC_G_TUNER:
+	{
+		struct v4l2_tuner *t = arg;
+		u32 reg;
+		
+		if (UNSET == dev->tuner_type)
+			return -EINVAL;
+		if (0 != t->index)
+			return -EINVAL;
+
+		memset(t,0,sizeof(*t));
+		strcpy(t->name, "Television");
+		t->type       = V4L2_TUNER_ANALOG_TV;
+		t->capability = V4L2_TUNER_CAP_NORM;
+		t->rangehigh  = 0xffffffffUL;
+
+		cx88_get_stereo(dev ,t);
+		reg = cx_read(MO_DEVICE_STATUS);
+                t->signal = (reg & (1<<5)) ? 0xffff : 0x0000;
+		return 0;
+	}
+	case VIDIOC_S_TUNER:
+	{
+		struct v4l2_tuner *t = arg;
+
+		if (UNSET == dev->tuner_type)
+			return -EINVAL;
+		if (0 != t->index)
+			return -EINVAL;
+		cx88_set_stereo(dev,t->audmode);
+		return 0;
+	}
+	case VIDIOC_G_FREQUENCY:
+	{
+		struct v4l2_frequency *f = arg;
+
+		if (UNSET == dev->tuner_type)
+			return -EINVAL;
+		if (f->tuner != 0)
+			return -EINVAL;
+		memset(f,0,sizeof(*f));
+		f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
+		f->frequency = dev->freq;
+		return 0;
+	}
+	case VIDIOC_S_FREQUENCY:
+	{
+		struct v4l2_frequency *f = arg;
+
+		if (UNSET == dev->tuner_type)
+			return -EINVAL;
+		if (f->tuner != 0)
+			return -EINVAL;
+		if (0 == fh->radio && f->type != V4L2_TUNER_ANALOG_TV)
+			return -EINVAL;
+		if (1 == fh->radio && f->type != V4L2_TUNER_RADIO)
+			return -EINVAL;
+		down(&dev->lock);
+		dev->freq = f->frequency;
+		cx8800_call_i2c_clients(dev,VIDIOCSFREQ,&dev->freq);
+		up(&dev->lock);
+		return 0;
+	}
+
+	/* --- streaming capture ------------------------------------- */
+	case VIDIOC_REQBUFS:
+		return videobuf_reqbufs(file,&fh->vidq,arg);
+
+	case VIDIOC_QUERYBUF:
+		return videobuf_querybuf(&fh->vidq,arg);
+
+	case VIDIOC_QBUF:
+		return videobuf_qbuf(file,&fh->vidq,arg);
+
+	case VIDIOC_DQBUF:
+		return videobuf_dqbuf(file,&fh->vidq,arg);
+
+	case VIDIOC_STREAMON:
+	{
+                if (!res_get(dev,fh,RESOURCE_VIDEO))
+			return -EBUSY;
+		return videobuf_streamon(file,&fh->vidq);
+	}
+	case VIDIOC_STREAMOFF:
+	{
+		err = videobuf_streamoff(file,&fh->vidq);
+		if (err < 0)
+			return err;
+		res_free(dev,fh,RESOURCE_VIDEO);
+		return 0;
+	}
+
+	default:
+		return v4l_compat_translate_ioctl(inode,file,cmd,arg,
+						  video_do_ioctl);
+	}
+	return 0;
+}
+
+static int video_ioctl(struct inode *inode, struct file *file,
+		       unsigned int cmd, unsigned long arg)
+{
+	return video_usercopy(inode, file, cmd, arg, video_do_ioctl);
+}
+
+/* ----------------------------------------------------------- */
+
+static int radio_do_ioctl(struct inode *inode, struct file *file,
+			unsigned int cmd, void *arg)
+{
+	struct cx8800_fh *fh = file->private_data;
+	struct cx8800_dev *dev = fh->dev;
+	
+	if (video_debug > 1)
+		cx88_print_ioctl(dev->name,cmd);
+
+	switch (cmd) {
+	case VIDIOC_QUERYCAP:
+	{
+		struct v4l2_capability *cap = arg;
+		
+		memset(cap,0,sizeof(*cap));
+                strcpy(cap->driver, "cx8800");
+		strlcpy(cap->card, cx88_boards[dev->board].name,
+			sizeof(cap->card));
+		sprintf(cap->bus_info,"PCI:%s", pci_name(dev->pci));
+		cap->version = CX88_VERSION_CODE;
+		cap->capabilities = V4L2_CAP_TUNER;
+		return 0;
+	}
+	case VIDIOC_G_TUNER:
+	{
+		struct v4l2_tuner *t = arg;
+		struct video_tuner vt;
+
+		if (t->index > 0)
+			return -EINVAL;
+
+		memset(t,0,sizeof(*t));
+		strcpy(t->name, "Radio");
+                t->rangelow  = (int)(65*16);
+                t->rangehigh = (int)(108*16);
+		
+		memset(&vt,0,sizeof(vt));
+		cx8800_call_i2c_clients(dev,VIDIOCGTUNER,&vt);
+		t->signal = vt.signal;
+		return 0;
+	}
+	case VIDIOC_ENUMINPUT:
+	{
+		struct v4l2_input *i = arg;
+		
+		if (i->index != 0)
+			return -EINVAL;
+		strcpy(i->name,"Radio");
+		i->type = V4L2_INPUT_TYPE_TUNER;
+		return 0;
+	}
+	case VIDIOC_G_INPUT:
+	{
+		int *i = arg;
+		*i = 0;
+		return 0;
+	}
+	case VIDIOC_G_AUDIO:
+	{
+		struct v4l2_audio *a = arg;
+
+		memset(a,0,sizeof(*a));
+		strcpy(a->name,"Radio");
+		return 0;
+	}
+	case VIDIOC_G_STD:
+	{
+		v4l2_std_id *id = arg;
+		*id = 0;
+		return 0;
+	}
+	case VIDIOC_S_AUDIO:
+	case VIDIOC_S_TUNER:
+	case VIDIOC_S_INPUT:
+	case VIDIOC_S_STD:
+		return 0;
+
+	case VIDIOC_QUERYCTRL:
+	{
+		struct v4l2_queryctrl *c = arg;
+		int i;
+
+		if (c->id <  V4L2_CID_BASE ||
+		    c->id >= V4L2_CID_LASTP1)
+			return -EINVAL;
+		if (c->id == V4L2_CID_AUDIO_MUTE) {
+			for (i = 0; i < CX8800_CTLS; i++)
+				if (cx8800_ctls[i].v.id == c->id)
+					break;
+			*c = cx8800_ctls[i].v;
+		} else
+			*c = no_ctl;
+		return 0;
+	}
+
+
+	case VIDIOC_G_CTRL:
+	case VIDIOC_S_CTRL:
+	case VIDIOC_G_FREQUENCY:
+	case VIDIOC_S_FREQUENCY:
+		return video_do_ioctl(inode,file,cmd,arg);
+		
+	default:
+		return v4l_compat_translate_ioctl(inode,file,cmd,arg,
+						  radio_do_ioctl);
+	}
+	return 0;
+};
+
+static int radio_ioctl(struct inode *inode, struct file *file,
+			unsigned int cmd, unsigned long arg)
+{
+	return video_usercopy(inode, file, cmd, arg, radio_do_ioctl);
+};
+
+/* ----------------------------------------------------------- */
+
+static void cx8800_vid_timeout(unsigned long data)
+{
+	struct cx8800_dev *dev = (struct cx8800_dev*)data;
+	struct cx88_dmaqueue *q = &dev->vidq;
+	struct cx88_buffer *buf;
+	unsigned long flags;
+
+	cx88_sram_channel_dump(dev, &cx88_sram_channels[SRAM_CH21]);
+	//cx88_risc_disasm(dev,&dev->vidq.stopper);
+	
+	cx_clear(MO_VID_DMACNTRL, 0x11);
+	cx_clear(VID_CAPTURE_CONTROL, 0x06);
+
+	spin_lock_irqsave(&dev->slock,flags);
+	while (!list_empty(&q->active)) {
+		buf = list_entry(q->active.next, struct cx88_buffer, vb.queue);
+		list_del(&buf->vb.queue);
+		buf->vb.state = STATE_ERROR;
+		wake_up(&buf->vb.done);
+		printk("%s: [%p/%d] timeout - dma=0x%08lx\n", dev->name,
+		       buf, buf->vb.i, (unsigned long)buf->risc.dma);
+	}
+	restart_video_queue(dev,q);
+	spin_unlock_irqrestore(&dev->slock,flags);
+}
+
+static void cx8800_vid_irq(struct cx8800_dev *dev)
+{
+	struct cx88_buffer *buf;
+	u32 status, mask, count;
+
+	status = cx_read(MO_VID_INTSTAT);
+	mask   = cx_read(MO_VID_INTMSK);
+	if (0 == (status & mask))
+		return;
+	cx_write(MO_VID_INTSTAT, status);
+	if (irq_debug  ||  (status & mask & ~0xff))
+		cx88_print_irqbits(dev->name, "irq vid",
+				   cx88_vid_irqs, status, mask);
+
+	/* risc op code error */
+	if (status & (1 << 16)) {
+		printk(KERN_WARNING "%s: video risc op code error\n",dev->name);
+		cx_clear(MO_VID_DMACNTRL, 0x11);
+		cx_clear(VID_CAPTURE_CONTROL, 0x06);
+		cx88_sram_channel_dump(dev, &cx88_sram_channels[SRAM_CH21]);
+	}
+	
+	/* risc1 y */
+	if (status & 0x01) {
+		spin_lock(&dev->slock);
+		count = cx_read(MO_VIDY_GPCNT);
+		for (;;) {
+			if (list_empty(&dev->vidq.active))
+				break;
+			buf = list_entry(dev->vidq.active.next,
+					 struct cx88_buffer, vb.queue);
+			if (buf->count > count)
+				break;
+			do_gettimeofday(&buf->vb.ts);
+			dprintk(2,"[%p/%d] wakeup reg=%d buf=%d\n",buf,buf->vb.i,
+				count, buf->count);
+			buf->vb.state = STATE_DONE;
+			list_del(&buf->vb.queue);
+			wake_up(&buf->vb.done);
+		}
+		if (list_empty(&dev->vidq.active)) {
+			del_timer(&dev->vidq.timeout);
+		} else {
+			mod_timer(&dev->vidq.timeout, jiffies+BUFFER_TIMEOUT);
+		}
+		spin_unlock(&dev->slock);
+	}
+
+	/* risc2 y */
+	if (status & 0x10) {
+		dprintk(2,"stopper\n");
+		spin_lock(&dev->slock);
+		restart_video_queue(dev,&dev->vidq);
+		spin_unlock(&dev->slock);
+	}
+}
+
+static irqreturn_t cx8800_irq(int irq, void *dev_id, struct pt_regs *regs)
+{
+	struct cx8800_dev *dev = dev_id;
+	u32 status, mask;
+	int loop, handled = 0;
+
+	for (loop = 0; loop < 10; loop++) {
+		status = cx_read(MO_PCI_INTSTAT);
+		mask   = cx_read(MO_PCI_INTMSK);
+		if (0 == (status & mask))
+			goto out;
+		handled = 1;
+		cx_write(MO_PCI_INTSTAT, status);
+		if (irq_debug  ||  (status & mask & ~0x1f))
+			cx88_print_irqbits(dev->name, "irq pci",
+					   cx88_pci_irqs, status, mask);
+
+		if (status & 1)
+			cx8800_vid_irq(dev);
+	};
+	if (10 == loop) {
+		printk(KERN_WARNING "%s: irq loop -- clearing mask\n",
+		       dev->name);
+		cx_write(MO_PCI_INTMSK,0);
+	}
+	
+ out:
+	return IRQ_RETVAL(handled);
+}
+
+/* ----------------------------------------------------------- */
+/* exported stuff                                              */
+
+static struct file_operations video_fops =
+{
+	.owner	       = THIS_MODULE,
+	.open	       = video_open,
+	.release       = video_release,
+	.read	       = video_read,
+	.poll          = video_poll,
+	.mmap	       = video_mmap,
+	.ioctl	       = video_ioctl,
+	.llseek        = no_llseek,
+};
+
+struct video_device cx8800_video_template =
+{
+	.name          = "cx8800-video",
+	.type          = VID_TYPE_CAPTURE|VID_TYPE_TUNER|VID_TYPE_OVERLAY|
+	                 VID_TYPE_CLIPPING|VID_TYPE_SCALES,
+	.hardware      = 0,
+	.fops          = &video_fops,
+	.minor         = -1,
+};
+
+static struct file_operations radio_fops =
+{
+	.owner         = THIS_MODULE,
+	.open          = video_open,
+	.release       = video_release,
+	.ioctl         = radio_ioctl,
+	.llseek        = no_llseek,
+};
+
+struct video_device cx8800_radio_template =
+{
+	.name          = "cx8800-radio",
+	.type          = VID_TYPE_TUNER,
+	.hardware      = 0,
+	.fops          = &radio_fops,
+	.minor         = -1,
+};
+
+/* ----------------------------------------------------------- */
+
+static void cx8800_shutdown(struct cx8800_dev *dev)
+{
+	/* disable RISC controller + IRQs */
+	cx_write(MO_DEV_CNTRL2, 0);
+
+	/* stop dma transfers */
+	cx_write(MO_VID_DMACNTRL, 0x0);
+	cx_write(MO_AUD_DMACNTRL, 0x0);
+	cx_write(MO_TS_DMACNTRL, 0x0);
+	cx_write(MO_VIP_DMACNTRL, 0x0);
+	cx_write(MO_GPHST_DMACNTRL, 0x0);
+
+	/* stop interupts */
+	cx_write(MO_PCI_INTMSK, 0x0);
+	cx_write(MO_VID_INTMSK, 0x0);
+	cx_write(MO_AUD_INTMSK, 0x0);
+	cx_write(MO_TS_INTMSK, 0x0);
+	cx_write(MO_VIP_INTMSK, 0x0);
+	cx_write(MO_GPHST_INTMSK, 0x0);
+
+	/* stop capturing */
+	cx_write(VID_CAPTURE_CONTROL, 0);
+}
+
+static int cx8800_reset(struct cx8800_dev *dev)
+{
+	dprintk(1,"cx8800_reset\n");
+
+	cx8800_shutdown(dev);
+	
+	/* clear irq status */
+	cx_write(MO_VID_INTSTAT, 0xFFFFFFFF); // Clear PIV int
+	cx_write(MO_PCI_INTSTAT, 0xFFFFFFFF); // Clear PCI int
+	cx_write(MO_INT1_STAT,   0xFFFFFFFF); // Clear RISC int
+
+	/* wait a bit */
+	set_current_state(TASK_INTERRUPTIBLE);
+	schedule_timeout(HZ/10);
+	
+	/* init sram */
+	cx88_sram_channel_setup(dev, &cx88_sram_channels[SRAM_CH21], 720*4, 0);
+	cx88_sram_channel_setup(dev, &cx88_sram_channels[SRAM_CH22], 128, 0);
+	cx88_sram_channel_setup(dev, &cx88_sram_channels[SRAM_CH23], 128, 0);
+	cx88_sram_channel_setup(dev, &cx88_sram_channels[SRAM_CH24], 128, 0);
+	cx88_sram_channel_setup(dev, &cx88_sram_channels[SRAM_CH25], 128, 0);
+	cx88_sram_channel_setup(dev, &cx88_sram_channels[SRAM_CH26], 128, 0);
+	
+	/* misc init ... */
+	cx_write(MO_INPUT_FORMAT, ((1 << 13) |   // agc enable
+				   (1 << 12) |   // agc gain
+				   (1 << 11) |   // adaptibe agc
+				   (0 << 10) |   // chroma agc
+				   (0 <<  9) |   // ckillen
+				   (7)));
+
+	/* setup image format */
+	cx_andor(MO_COLOR_CTRL, 0x4000, 0x4000);
+
+	/* setup FIFO Threshholds */
+	cx_write(MO_PDMA_STHRSH,   0x0807);
+	cx_write(MO_PDMA_DTHRSH,   0x0807);
+
+	/* fixes flashing of image */
+	cx_write(MO_AGC_SYNC_TIP1, 0x0380000F);
+	cx_write(MO_AGC_BACK_VBI,  0x00E00555);
+	
+	cx_write(MO_VID_INTSTAT,   0xFFFFFFFF); // Clear PIV int
+	cx_write(MO_PCI_INTSTAT,   0xFFFFFFFF); // Clear PCI int
+	cx_write(MO_INT1_STAT,     0xFFFFFFFF); // Clear RISC int
+
+	return 0;
+}
+
+static struct video_device *vdev_init(struct cx8800_dev *dev,
+				      struct video_device *template,
+				      char *type)
+{
+	struct video_device *vfd;
+
+	vfd = video_device_alloc();
+	if (NULL == vfd)
+		return NULL;
+	*vfd = *template;
+	vfd->minor   = -1;
+	vfd->dev     = &dev->pci->dev;
+	vfd->release = video_device_release;
+	snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
+		 dev->name, type, cx88_boards[dev->board].name);
+	return vfd;
+}
+
+static void cx8800_unregister_video(struct cx8800_dev *dev)
+{
+	if (dev->radio_dev) {
+		if (-1 != dev->radio_dev->minor)
+			video_unregister_device(dev->radio_dev);
+		else
+			video_device_release(dev->radio_dev);
+		dev->radio_dev = NULL;
+	}
+	if (dev->video_dev) {
+		if (-1 != dev->video_dev->minor)
+			video_unregister_device(dev->video_dev);
+		else
+			video_device_release(dev->video_dev);
+		dev->video_dev = NULL;
+	}
+}
+
+static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
+				    const struct pci_device_id *pci_id)
+{
+	struct cx8800_dev *dev;
+	unsigned int i;
+	int err;
+
+	dev = kmalloc(sizeof(*dev),GFP_KERNEL);
+	if (NULL == dev)
+		return -ENOMEM;
+	memset(dev,0,sizeof(*dev));
+
+	/* pci init */
+	dev->pci = pci_dev;
+	if (pci_enable_device(pci_dev)) {
+		err = -EIO;
+		goto fail1;
+	}
+	sprintf(dev->name,"cx%x[%d]",pci_dev->device,cx8800_devcount);
+
+	/* pci quirks */
+	cx88_pci_quirks(dev->name, dev->pci, &latency);
+	if (UNSET != latency) {
+		printk(KERN_INFO "%s: setting pci latency timer to %d\n",
+		       dev->name,latency);
+		pci_write_config_byte(pci_dev, PCI_LATENCY_TIMER, latency);
+	}
+
+	/* print pci info */
+	pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &dev->pci_rev);
+        pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER,  &dev->pci_lat);
+        printk(KERN_INFO "%s: found at %s, rev: %d, irq: %d, "
+	       "latency: %d, mmio: 0x%lx\n", dev->name,
+	       pci_name(pci_dev), dev->pci_rev, pci_dev->irq,
+	       dev->pci_lat,pci_resource_start(pci_dev,0));
+
+	pci_set_master(pci_dev);
+	if (!pci_dma_supported(pci_dev,0xffffffff)) {
+		printk("%s: Oops: no 32bit PCI DMA ???\n",dev->name);
+		err = -EIO;
+		goto fail1;
+	}
+
+	/* board config */
+	dev->board = card[cx8800_devcount];
+	for (i = 0; UNSET == dev->board  &&  i < cx88_idcount; i++) 
+		if (pci_dev->subsystem_vendor == cx88_subids[i].subvendor &&
+		    pci_dev->subsystem_device == cx88_subids[i].subdevice)
+			dev->board = cx88_subids[i].card;
+	if (UNSET == dev->board)
+		dev->board = CX88_BOARD_UNKNOWN;
+        printk(KERN_INFO "%s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n",
+	       dev->name,pci_dev->subsystem_vendor,
+	       pci_dev->subsystem_device,cx88_boards[dev->board].name,
+	       dev->board, card[cx8800_devcount] == dev->board ?
+	       "insmod option" : "autodetected");
+
+	dev->tuner_type = tuner[cx8800_devcount];
+	if (UNSET == dev->tuner_type)
+		dev->tuner_type = cx88_boards[dev->board].tuner_type;
+
+	/* get mmio */
+	if (!request_mem_region(pci_resource_start(pci_dev,0),
+				pci_resource_len(pci_dev,0),
+				dev->name)) {
+		err = -EBUSY;
+		printk(KERN_ERR "%s: can't get MMIO memory @ 0x%lx\n",
+		       dev->name,pci_resource_start(pci_dev,0));
+		goto fail1;
+	}
+	dev->lmmio = ioremap(pci_resource_start(pci_dev,0),
+			     pci_resource_len(pci_dev,0));
+
+	/* initialize driver struct */
+        init_MUTEX(&dev->lock);
+	dev->slock = SPIN_LOCK_UNLOCKED;
+	dev->tvnorm = tvnorms;
+
+	/* init dma queues */
+	INIT_LIST_HEAD(&dev->vidq.active);
+	INIT_LIST_HEAD(&dev->vidq.queued);
+	dev->vidq.timeout.function = cx8800_vid_timeout;
+	dev->vidq.timeout.data     = (unsigned long)dev;
+	init_timer(&dev->vidq.timeout);
+	cx88_risc_stopper(dev->pci,&dev->vidq.stopper,
+			  MO_VID_DMACNTRL,0x11,0x00);
+	
+	/* initialize hardware */
+	cx8800_reset(dev);
+
+	/* get irq */
+	err = request_irq(pci_dev->irq, cx8800_irq,
+			  SA_SHIRQ | SA_INTERRUPT, dev->name, dev);
+	if (err < 0) {
+		printk(KERN_ERR "%s: can't get IRQ %d\n",
+		       dev->name,pci_dev->irq);
+		goto fail2;
+	}
+
+	/* register i2c bus + load i2c helpers */
+	cx8800_i2c_init(dev);
+	cx88_card_setup(dev);
+
+	/* load and configure helper modules */
+	if (TUNER_ABSENT != dev->tuner_type)
+		request_module("tuner");
+	if (dev->tuner_type != UNSET)
+		cx8800_call_i2c_clients(dev,TUNER_SET_TYPE,&dev->tuner_type);
+
+	/* register v4l devices */
+	dev->video_dev = vdev_init(dev,&cx8800_video_template,"video");
+	err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER,
+				    video_nr[cx8800_devcount]);
+	if (err < 0) {
+		printk(KERN_INFO "%s: can't register video device\n",
+		       dev->name);
+		goto fail3;
+	}
+	printk(KERN_INFO "%s: registered device video%d [v4l2]\n",
+	       dev->name,dev->video_dev->minor & 0x1f);
+
+	if (dev->has_radio) {
+		dev->radio_dev = vdev_init(dev,&cx8800_radio_template,"radio");
+		err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO,
+					    radio_nr[cx8800_devcount]);
+		if (err < 0) {
+			printk(KERN_INFO "%s: can't register radio device\n",
+			       dev->name);
+			goto fail3;
+		}
+		printk(KERN_INFO "%s: registered device radio%d\n",
+		       dev->name,dev->radio_dev->minor & 0x1f);
+	}
+
+	/* everything worked */
+	list_add_tail(&dev->devlist,&cx8800_devlist);
+	pci_set_drvdata(pci_dev,dev);
+	cx8800_devcount++;
+
+	/* initial device configuration */
+	down(&dev->lock);
+	set_tvnorm(dev,tvnorms);
+	video_mux(dev,0);
+	up(&dev->lock);
+	return 0;
+
+ fail3:
+	cx8800_unregister_video(dev);
+	if (0 == dev->i2c_rc)
+		i2c_bit_del_bus(&dev->i2c_adap);
+	free_irq(pci_dev->irq, dev);
+ fail2:
+	release_mem_region(pci_resource_start(pci_dev,0),
+			   pci_resource_len(pci_dev,0));
+ fail1:
+	kfree(dev);
+	return err;
+}
+
+static void __devexit cx8800_finidev(struct pci_dev *pci_dev)
+{
+        struct cx8800_dev *dev = pci_get_drvdata(pci_dev);
+
+	cx8800_shutdown(dev);
+	pci_disable_device(pci_dev);
+
+	/* unregister stuff */	
+	if (0 == dev->i2c_rc)
+		i2c_bit_del_bus(&dev->i2c_adap);
+
+	free_irq(pci_dev->irq, dev);
+	release_mem_region(pci_resource_start(pci_dev,0),
+			   pci_resource_len(pci_dev,0));
+
+	cx8800_unregister_video(dev);
+	pci_set_drvdata(pci_dev, NULL);
+
+	/* free memory */
+	btcx_riscmem_free(dev->pci,&dev->vidq.stopper);
+	list_del(&dev->devlist);
+	cx8800_devcount--;
+	kfree(dev);
+}
+
+static int cx8800_suspend(struct pci_dev *pci_dev, u32 state)
+{
+        struct cx8800_dev *dev = pci_get_drvdata(pci_dev);
+
+	printk("%s: suspend %d\n", dev->name, state);
+
+	cx8800_shutdown(dev);
+	del_timer(&dev->vidq.timeout);
+	
+	pci_save_state(pci_dev, dev->state.pci_cfg);
+	if (0 != pci_set_power_state(pci_dev, state)) {
+		pci_disable_device(pci_dev);
+		dev->state.disabled = 1;
+	}
+	return 0;
+}
+
+static int cx8800_resume(struct pci_dev *pci_dev)
+{
+        struct cx8800_dev *dev = pci_get_drvdata(pci_dev);
+
+	printk("%s: resume\n", dev->name);
+
+	if (dev->state.disabled) {
+		pci_enable_device(pci_dev);
+		dev->state.disabled = 0;
+	}
+	pci_set_power_state(pci_dev, 0);
+	pci_restore_state(pci_dev, dev->state.pci_cfg);
+
+	/* re-initialize hardware */
+	cx8800_reset(dev);
+
+	/* restart video capture */
+	spin_lock(&dev->slock);
+	restart_video_queue(dev,&dev->vidq);
+	spin_unlock(&dev->slock);
+
+	return 0;
+}
+
+/* ----------------------------------------------------------- */
+
+struct pci_device_id cx8800_pci_tbl[] = {
+	{
+		.vendor       = 0x14f1,
+		.device       = 0x8800,
+                .subvendor    = PCI_ANY_ID,
+                .subdevice    = PCI_ANY_ID,
+	},{
+		/* --- end of list --- */
+	}
+};
+MODULE_DEVICE_TABLE(pci, cx8800_pci_tbl);
+
+static struct pci_driver cx8800_pci_driver = {
+        .name     = "cx8800",
+        .id_table = cx8800_pci_tbl,
+        .probe    = cx8800_initdev,
+        .remove   = cx8800_finidev,
+
+	.suspend  = cx8800_suspend,
+	.resume   = cx8800_resume,
+};
+
+static int cx8800_init(void)
+{
+	INIT_LIST_HEAD(&cx8800_devlist);
+	printk(KERN_INFO "cx2388x v4l2 driver version %d.%d.%d loaded\n",
+	       (CX88_VERSION_CODE >> 16) & 0xff,
+	       (CX88_VERSION_CODE >>  8) & 0xff,
+	       CX88_VERSION_CODE & 0xff);
+#ifdef SNAPSHOT
+	printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
+	       SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
+#endif
+	return pci_module_init(&cx8800_pci_driver);
+}
+
+static void cx8800_fini(void)
+{
+	pci_unregister_driver(&cx8800_pci_driver);
+}
+
+module_init(cx8800_init);
+module_exit(cx8800_fini);
+
+/* ----------------------------------------------------------- */
+/*
+ * Local variables:
+ * c-basic-offset: 8
+ * End:
+ */
diff -puN /dev/null drivers/media/video/cx88/Makefile
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/media/video/cx88/Makefile	2004-01-19 22:17:22.000000000 -0800
@@ -0,0 +1,6 @@
+cx88xx-objs	:= cx88-cards.o cx88-core.o
+cx8800-objs	:= cx88-video.o cx88-tvaudio.o cx88-i2c.o
+
+obj-$(CONFIG_VIDEO_CX88) += cx88xx.o cx8800.o
+
+EXTRA_CFLAGS = -I$(src)/..
diff -puN /dev/null drivers/media/video/ir-kbd-gpio.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/media/video/ir-kbd-gpio.c	2004-01-19 22:17:22.000000000 -0800
@@ -0,0 +1,379 @@
+/*
+ * Copyright (c) 2003 Gerd Knorr
+ * Copyright (c) 2003 Pavel Machek
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/input.h>
+#include <linux/pci.h>
+
+#include <media/ir-common.h>
+
+#include "bttv.h"
+
+/* ---------------------------------------------------------------------- */
+
+static IR_KEYTAB_TYPE ir_codes_avermedia[IR_KEYTAB_SIZE] = {
+	[ 17 ] = KEY_KP0, 
+	[ 20 ] = KEY_KP1, 
+	[ 12 ] = KEY_KP2, 
+	[ 28 ] = KEY_KP3, 
+	[ 18 ] = KEY_KP4, 
+	[ 10 ] = KEY_KP5, 
+	[ 26 ] = KEY_KP6, 
+	[ 22 ] = KEY_KP7, 
+	[ 14 ] = KEY_KP8, 
+	[ 30 ] = KEY_KP9, 
+
+	[ 24 ] = KEY_EJECTCD,     // Unmarked on my controller
+	[  0 ] = KEY_POWER, 
+	[  9 ] = BTN_LEFT,        // DISPLAY/L
+	[ 25 ] = BTN_RIGHT,       // LOOP/R
+	[  5 ] = KEY_MUTE, 
+	[ 19 ] = KEY_RECORD, 
+	[ 11 ] = KEY_PAUSE, 
+	[ 27 ] = KEY_STOP, 
+	[ 15 ] = KEY_VOLUMEDOWN, 
+	[ 31 ] = KEY_VOLUMEUP, 
+
+	[ 16 ] = KEY_TUNER,       // TV/FM
+	[  8 ] = KEY_CD, 
+	[  4 ] = KEY_VIDEO, 
+	[  2 ] = KEY_AUDIO, 
+	[  6 ] = KEY_ZOOM,        // full screen
+	[  1 ] = KEY_INFO,        // preview 
+	[ 21 ] = KEY_SEARCH,      // autoscan
+	[ 13 ] = KEY_STOP,        // freeze 
+	[ 29 ] = KEY_RECORD,      // capture 
+	[  3 ] = KEY_PLAY,        // unmarked
+	[ 24 ] = KEY_RED,         // unmarked
+	[  7 ] = KEY_GREEN,       // unmarked
+
+#if 0
+	[ 16 ] = KEY_YELLOW,      // unmarked
+	[  8 ] = KEY_CHANNELDOWN, 
+	[ 24 ] = KEY_CHANNELUP, 
+	[  0 ] = KEY_BLUE,        // unmarked
+#endif
+};
+
+static IR_KEYTAB_TYPE winfast_codes[IR_KEYTAB_SIZE] = {
+	[  5 ] = KEY_KP1,
+	[  6 ] = KEY_KP2,
+	[  7 ] = KEY_KP3,
+	[  9 ] = KEY_KP4,
+	[ 10 ] = KEY_KP5,
+	[ 11 ] = KEY_KP6,
+	[ 13 ] = KEY_KP7,
+	[ 14 ] = KEY_KP8,
+	[ 15 ] = KEY_KP9,
+	[ 18 ] = KEY_KP0,
+
+	[  0 ] = KEY_POWER,
+//      [ 27 ] = MTS button
+	[  2 ] = KEY_TUNER,     // TV/FM
+	[ 30 ] = KEY_VIDEO,
+//      [ 22 ] = display button
+	[  4 ] = KEY_VOLUMEUP,
+	[  8 ] = KEY_VOLUMEDOWN,
+	[ 12 ] = KEY_CHANNELUP,
+	[ 16 ] = KEY_CHANNELDOWN,
+	[  3 ] = KEY_ZOOM,      // fullscreen
+	[ 31 ] = KEY_SUBTITLE,  // closed caption/teletext
+	[ 32 ] = KEY_SLEEP,
+//      [ 41 ] = boss key
+	[ 20 ] = KEY_MUTE,
+	[ 43 ] = KEY_RED,
+	[ 44 ] = KEY_GREEN,
+	[ 45 ] = KEY_YELLOW,
+	[ 46 ] = KEY_BLUE,
+	[ 24 ] = KEY_KPPLUS,    //fine tune +
+	[ 25 ] = KEY_KPMINUS,   //fine tune -
+//      [ 42 ] = picture in picture
+        [ 33 ] = KEY_KPDOT,
+	[ 19 ] = KEY_KPENTER,
+//      [ 17 ] = recall
+	[ 34 ] = KEY_BACK,
+	[ 35 ] = KEY_PLAYPAUSE,
+	[ 36 ] = KEY_NEXT,
+//      [ 37 ] = time shifting
+	[ 38 ] = KEY_STOP,
+	[ 39 ] = KEY_RECORD
+//      [ 40 ] = snapshot
+};
+
+static IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE] = {
+	[  2 ] = KEY_KP0,
+	[  1 ] = KEY_KP1,
+	[ 11 ] = KEY_KP2,
+	[ 27 ] = KEY_KP3,
+	[  5 ] = KEY_KP4,
+	[  9 ] = KEY_KP5,
+	[ 21 ] = KEY_KP6,
+	[  6 ] = KEY_KP7,
+	[ 10 ] = KEY_KP8,
+	[ 18 ] = KEY_KP9,
+	
+	[  3 ] = KEY_TUNER,       // TV/FM
+	[  7 ] = KEY_SEARCH,      // scan
+	[ 28 ] = KEY_ZOOM,        // full screen
+	[ 30 ] = KEY_POWER,
+	[ 23 ] = KEY_VOLUMEDOWN,
+	[ 31 ] = KEY_VOLUMEUP,
+	[ 20 ] = KEY_CHANNELDOWN,
+	[ 22 ] = KEY_CHANNELUP,
+	[ 24 ] = KEY_MUTE,
+	
+	[  0 ] = KEY_LIST,        // source
+	[ 19 ] = KEY_INFO,        // loop
+	[ 16 ] = KEY_LAST,        // +100
+	[ 13 ] = KEY_CLEAR,       // reset
+	[ 12 ] = BTN_RIGHT,       // fun++
+	[  4 ] = BTN_LEFT,        // fun--
+	[ 14 ] = KEY_GOTO,        // function
+	[ 15 ] = KEY_STOP,         // freeze
+};
+
+/* ---------------------------------------------------------------------- */
+
+struct IR {
+	struct bttv_sub_device  *sub;
+	struct input_dev        input;
+	struct ir_input_state   ir;
+	char                    name[32];
+	char                    phys[32];
+	u32                     mask_keycode;
+	u32                     mask_keydown;
+	u32                     mask_keyup;
+
+	int                     polling;
+	u32                     last_gpio;
+	struct work_struct      work;
+	struct timer_list       timer;
+};
+
+static int debug = 0;    /* debug level (0,1,2) */
+MODULE_PARM(debug,"i");
+
+#define DEVNAME "ir-kbd-gpio"
+#define dprintk(fmt, arg...)	if (debug) \
+	printk(KERN_DEBUG DEVNAME ": " fmt , ## arg)
+
+static void ir_irq(struct bttv_sub_device *sub);
+static int ir_probe(struct device *dev);
+static int ir_remove(struct device *dev);
+
+static struct bttv_sub_driver driver = {
+	.drv = {
+		.name	= DEVNAME,
+		.probe	= ir_probe,
+		.remove	= ir_remove,
+	},
+	.gpio_irq       = ir_irq,
+};
+
+/* ---------------------------------------------------------------------- */
+
+static void ir_handle_key(struct IR *ir)
+{
+	u32 gpio,data;
+
+	/* read gpio value */
+	gpio = bttv_gpio_read(ir->sub->core);
+	if (ir->polling) {
+		if (ir->last_gpio == gpio)
+			return;
+		ir->last_gpio = gpio;
+	}
+	
+	/* extract data */
+	data = ir_extract_bits(gpio, ir->mask_keycode);
+	dprintk(DEVNAME ": irq gpio=0x%x code=%d | %s%s%s\n",
+		gpio, data,
+		ir->polling               ? "poll"  : "irq",
+		(gpio & ir->mask_keydown) ? " down" : "",
+		(gpio & ir->mask_keyup)   ? " up"   : "");
+
+	if (ir->mask_keydown) {
+		/* bit set on keydown */
+		if (gpio & ir->mask_keydown) {
+			ir_input_keydown(&ir->input,&ir->ir,data,data);
+		} else {
+			ir_input_nokey(&ir->input,&ir->ir);
+		}
+
+	} else if (ir->mask_keyup) {
+		/* bit cleared on keydown */
+		if (0 == (gpio & ir->mask_keyup)) {
+			ir_input_keydown(&ir->input,&ir->ir,data,data);
+		} else {
+			ir_input_nokey(&ir->input,&ir->ir);
+		}
+
+	} else {
+		/* can't disturgissh keydown/up :-/ */
+		ir_input_keydown(&ir->input,&ir->ir,data,data);
+		ir_input_nokey(&ir->input,&ir->ir);
+	}
+}
+
+static void ir_irq(struct bttv_sub_device *sub)
+{
+	struct IR *ir = dev_get_drvdata(&sub->dev);
+
+	if (!ir->polling)
+		ir_handle_key(ir);
+}
+
+static void ir_timer(unsigned long data)
+{
+	struct IR *ir = (struct IR*)data;
+
+	schedule_work(&ir->work);
+}
+
+static void ir_work(void *data)
+{
+	struct IR *ir = data;
+	unsigned long timeout;
+
+	ir_handle_key(ir);
+	timeout = jiffies + (ir->polling * HZ / 1000);
+	mod_timer(&ir->timer, timeout);
+}
+
+/* ---------------------------------------------------------------------- */
+
+static int ir_probe(struct device *dev)
+{
+	struct bttv_sub_device *sub = to_bttv_sub_dev(dev);
+	struct IR *ir;
+	IR_KEYTAB_TYPE *ir_codes = NULL;
+	int ir_type = IR_TYPE_OTHER;
+
+	ir = kmalloc(sizeof(*ir),GFP_KERNEL);
+	if (NULL == ir)
+		return -ENOMEM;
+	memset(ir,0,sizeof(*ir));
+
+	/* detect & configure */
+	switch (sub->core->type) {
+	case BTTV_AVERMEDIA:
+	case BTTV_AVPHONE98:
+		ir_codes         = ir_codes_avermedia;
+		ir->mask_keycode = 0xf80000;
+		ir->mask_keydown = 0x010000;
+		break;
+	case BTTV_WINFAST2000:
+		ir_codes         = winfast_codes;
+		ir->mask_keycode = 0x8f8;
+		break;
+	case BTTV_PV_BT878P_9B:
+	case BTTV_PV_BT878P_PLUS:
+		ir_codes         = ir_codes_pixelview;
+		ir->mask_keycode = 0x001f00;
+		ir->mask_keyup   = 0x008000;
+		ir->polling      = 50; // ms
+                break;
+	}
+	if (NULL == ir_codes) {
+		kfree(ir);
+		return -ENODEV;
+	}
+
+	/* init hardware-specific stuff */
+	bttv_gpio_inout(sub->core, ir->mask_keycode | ir->mask_keydown, 0);
+	ir->sub = sub;
+	
+	/* init input device */
+	snprintf(ir->name, sizeof(ir->name), "bttv IR (card=%d)",
+		 sub->core->type);
+	snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
+		 pci_name(sub->core->pci));
+
+	ir_input_init(&ir->input, &ir->ir, ir_type, ir_codes);
+	ir->input.name = ir->name;
+	ir->input.phys = ir->phys;
+	ir->input.id.bustype = BUS_PCI;
+	ir->input.id.version = 1;
+	if (sub->core->pci->subsystem_vendor) {
+		ir->input.id.vendor  = sub->core->pci->subsystem_vendor;
+		ir->input.id.product = sub->core->pci->subsystem_device;
+	} else {
+		ir->input.id.vendor  = sub->core->pci->vendor;
+		ir->input.id.product = sub->core->pci->device;
+	}
+
+	if (ir->polling) {
+		INIT_WORK(&ir->work, ir_work, ir);
+		init_timer(&ir->timer);
+		ir->timer.function = ir_timer;
+		ir->timer.data     = (unsigned long)ir;
+		schedule_work(&ir->work);
+	}
+
+	/* all done */
+	dev_set_drvdata(dev,ir);
+	input_register_device(&ir->input);
+	printk(DEVNAME ": %s detected at %s\n",ir->input.name,ir->input.phys);
+
+	return 0;
+}
+
+static int ir_remove(struct device *dev)
+{
+	struct IR *ir = dev_get_drvdata(dev);
+
+	if (ir->polling) {
+		del_timer(&ir->timer);
+		flush_scheduled_work();
+	}
+
+	input_unregister_device(&ir->input);
+	kfree(ir);
+	return 0;
+}
+
+/* ---------------------------------------------------------------------- */
+
+MODULE_AUTHOR("Gerd Knorr, Pavel Machek");
+MODULE_DESCRIPTION("input driver for bt8x8 gpio IR remote controls");
+MODULE_LICENSE("GPL");
+
+static int ir_init(void)
+{
+	return bttv_sub_register(&driver, "remote");
+}
+
+static void ir_fini(void)
+{
+	bttv_sub_unregister(&driver);
+}
+
+module_init(ir_init);
+module_exit(ir_fini);
+
+
+/*
+ * Local variables:
+ * c-basic-offset: 8
+ * End:
+ */
diff -puN /dev/null drivers/media/video/ir-kbd-i2c.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/media/video/ir-kbd-i2c.c	2004-01-19 22:17:22.000000000 -0800
@@ -0,0 +1,372 @@
+/*
+ * keyboard input driver for i2c IR remote controls
+ *
+ * Copyright (c) 2000-2003 Gerd Knorr <kraxel@bytesex.org>
+ * modified for PixelView (BT878P+W/FM) by
+ *      Michal Kochanowicz <mkochano@pld.org.pl>
+ *      Christoph Bartelmus <lirc@bartelmus.de>
+ * modified for KNC ONE TV Station/Anubis Typhoon TView Tuner by
+ *      Ulrich Mueller <ulrich.mueller42@web.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/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/string.h>
+#include <linux/timer.h>
+#include <linux/delay.h>
+#include <linux/errno.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/workqueue.h>
+
+#include <asm/semaphore.h>
+
+#include <media/ir-common.h>
+
+struct IR;
+struct IR {
+	struct i2c_client      c;
+	struct input_dev       input;
+	struct ir_input_state  ir;
+
+	struct work_struct     work;
+	struct timer_list      timer;
+	char                   phys[32];
+	int                    (*get_key)(struct IR*, u32*, u32*);
+};
+
+/* ----------------------------------------------------------------------- */
+/* insmod parameters                                                       */
+
+static int debug = 0;    /* debug level (0,1,2) */
+MODULE_PARM(debug,"i");
+
+#define DEVNAME "ir-kbd-i2c"
+#define dprintk(level, fmt, arg...)	if (debug >= level) \
+	printk(KERN_DEBUG DEVNAME ": " fmt , ## arg)
+
+/* ----------------------------------------------------------------------- */
+
+static inline int reverse(int data, int bits)
+{
+	int i,c;
+	
+	for (c=0,i=0; i<bits; i++) {
+		c |= (((data & (1<<i)) ? 1:0)) << (bits-1-i);
+	}
+	return c;
+}
+
+static int get_key_haup(struct IR *ir, u32 *ir_key, u32 *ir_raw)
+{
+	unsigned char buf[3];
+	int start, toggle, dev, code;
+
+	/* poll IR chip */
+	if (3 != i2c_master_recv(&ir->c,buf,3))
+		return -EIO;
+
+	/* split rc5 data block ... */
+	start  = (buf[0] >> 6) &    3;
+	toggle = (buf[0] >> 5) &    1;
+	dev    =  buf[0]       & 0x1f;
+	code   = (buf[1] >> 2) & 0x3f;
+
+	if (3 != start)
+		/* no key pressed */
+		return 0;
+	dprintk(1,"ir hauppauge (rc5): s%d t%d dev=%d code=%d\n",
+		start, toggle, dev, code);
+
+	/* return key */
+	*ir_key = code;
+	*ir_raw = (start << 12) | (toggle << 11) | (dev << 6) | code;
+	return 1;
+}
+
+static int get_key_pixelview(struct IR *ir, u32 *ir_key, u32 *ir_raw)
+{
+        unsigned char b;
+	
+	/* poll IR chip */
+	if (1 != i2c_master_recv(&ir->c,&b,1)) {
+		dprintk(1,"read error\n");
+		return -EIO;
+	}
+	*ir_key = b;
+	*ir_raw = b;
+	return 1;
+}
+
+static int get_key_pv951(struct IR *ir, u32 *ir_key, u32 *ir_raw)
+{
+        unsigned char b;
+	
+	/* poll IR chip */
+	if (1 != i2c_master_recv(&ir->c,&b,1)) {
+		dprintk(1,"read error\n");
+		return -EIO;
+	}
+
+	/* ignore 0xaa */
+	if (b==0xaa)
+		return 0;
+	dprintk(2,"key %02x\n", b);
+	
+	*ir_key = b;
+	*ir_raw = b;
+	return 1;
+}
+
+static int get_key_knc1(struct IR *ir, u32 *ir_key, u32 *ir_raw)
+{
+	unsigned char b;
+	
+	/* poll IR chip */
+	if (1 != i2c_master_recv(&ir->c,&b,1)) {
+		dprintk(1,"read error\n");
+		return -EIO;
+	}
+	
+	/* it seems that 0xFE indicates that a button is still hold
+	   down, while 0xFF indicates that no button is hold
+	   down. 0xFE sequences are sometimes interrupted by 0xFF */
+	
+	dprintk(2,"key %02x\n", b);
+	
+	if (b == 0xFF)
+		return 0;
+	
+	if (b == 0xFE)
+		/* keep old data */
+		return 1;
+	
+	*ir_key = b;
+	*ir_raw = b;
+	return 1;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static void ir_key_poll(struct IR *ir)
+{
+	u32 ir_key, ir_raw;
+	int rc;
+
+	dprintk(2,"ir_poll_key\n");
+	rc = ir->get_key(ir, &ir_key, &ir_raw);
+	if (rc < 0) {
+		dprintk(2,"error\n");
+		return;
+	}
+
+	if (0 == rc) {
+		ir_input_nokey(&ir->input,&ir->ir);
+	} else {
+		ir_input_keydown(&ir->input,&ir->ir, ir_key, ir_raw);
+	}
+}
+
+static void ir_timer(unsigned long data)
+{
+	struct IR *ir = (struct IR*)data;
+	schedule_work(&ir->work);
+}
+
+static void ir_work(void *data)
+{
+	struct IR *ir = data;
+	ir_key_poll(ir);
+	mod_timer(&ir->timer, jiffies+HZ/10);
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int ir_attach(struct i2c_adapter *adap, int addr,
+		      unsigned short flags, int kind);
+static int ir_detach(struct i2c_client *client);
+static int ir_probe(struct i2c_adapter *adap);
+
+static struct i2c_driver driver = {
+        .name           = "ir remote kbd driver",
+        .id             = I2C_DRIVERID_EXP3, /* FIXME */
+        .flags          = I2C_DF_NOTIFY,
+        .attach_adapter = ir_probe,
+        .detach_client  = ir_detach,
+};
+
+static struct i2c_client client_template = 
+{
+        I2C_DEVNAME("unset"),
+        .driver = &driver
+};
+
+static int ir_attach(struct i2c_adapter *adap, int addr,
+		     unsigned short flags, int kind)
+{
+	IR_KEYTAB_TYPE *ir_codes = NULL;
+	char *name;
+	int ir_type;
+        struct IR *ir;
+		
+        if (NULL == (ir = kmalloc(sizeof(struct IR),GFP_KERNEL)))
+                return -ENOMEM;
+	memset(ir,0,sizeof(*ir));
+	ir->c = client_template;
+
+	i2c_set_clientdata(&ir->c, ir);
+	ir->c.adapter = adap;
+	ir->c.addr    = addr;
+
+	switch(addr) {
+	case 0x64:
+		name        = "Pixelview";
+		ir->get_key = get_key_pixelview;
+		ir_type     = IR_TYPE_OTHER;
+		ir_codes    = ir_codes_empty;
+		break;
+	case 0x4b:
+		name        = "PV951";
+		ir->get_key = get_key_pv951;
+		ir_type     = IR_TYPE_OTHER;
+		ir_codes    = ir_codes_empty;
+		break;
+	case 0x18:
+	case 0x1a:
+		name        = "Hauppauge";
+		ir->get_key = get_key_haup;
+		ir_type     = IR_TYPE_RC5;
+		ir_codes    = ir_codes_rc5_tv;
+		break;
+	case 0x30:
+		name        = "KNC One";
+		ir->get_key = get_key_knc1;
+		ir_type     = IR_TYPE_OTHER;
+		ir_codes    = ir_codes_empty;
+		break;
+	default:
+		/* shouldn't happen */
+		printk(DEVNAME ": Huh? unknown i2c address (0x%02x)?\n",addr);
+		kfree(ir);
+		return -1;
+	}
+
+	/* register i2c device */
+	i2c_attach_client(&ir->c);
+	snprintf(ir->c.name, sizeof(ir->c.name), "i2c IR (%s)", name);
+	snprintf(ir->phys, sizeof(ir->phys), "%s/%s/ir0",
+		 ir->c.adapter->dev.bus_id,
+		 ir->c.dev.bus_id);
+
+	/* init + register input device */
+	ir_input_init(&ir->input,&ir->ir,ir_type,ir_codes);
+	ir->input.id.bustype = BUS_I2C;
+	ir->input.name       = ir->c.name;
+	ir->input.phys       = ir->phys;
+	input_register_device(&ir->input);
+	printk(DEVNAME ": %s detected at %s\n",ir->input.name,ir->input.phys);
+	       
+	/* start polling via eventd */
+	INIT_WORK(&ir->work, ir_work, ir);
+	init_timer(&ir->timer);
+	ir->timer.function = ir_timer;
+	ir->timer.data     = (unsigned long)ir;
+	schedule_work(&ir->work);
+	
+	return 0;
+}
+
+static int ir_detach(struct i2c_client *client)
+{
+        struct IR *ir = i2c_get_clientdata(client);
+
+	/* kill outstanding polls */
+	del_timer(&ir->timer);
+	flush_scheduled_work();
+
+	/* unregister devices */
+	input_unregister_device(&ir->input);
+	i2c_detach_client(&ir->c);
+
+	/* free memory */
+	kfree(ir);
+	return 0;
+}
+
+static int ir_probe(struct i2c_adapter *adap)
+{
+	
+	/* The external IR receiver is at i2c address 0x34 (0x35 for
+	   reads).  Future Hauppauge cards will have an internal
+	   receiver at 0x30 (0x31 for reads).  In theory, both can be
+	   fitted, and Hauppauge suggest an external overrides an
+	   internal. 
+	   
+	   That's why we probe 0x1a (~0x34) first. CB 
+	*/
+	
+	static const int probe[] = { 0x1a, 0x18, 0x4b, 0x64, 0x30, -1};
+	struct i2c_client c; char buf; int i,rc;
+
+	if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848)) {
+		memset(&c,0,sizeof(c));
+		c.adapter = adap;
+		for (i = 0; -1 != probe[i]; i++) {
+			c.addr = probe[i];
+			rc = i2c_master_recv(&c,&buf,1);
+			dprintk(1,"probe 0x%02x @ %s: %s\n",
+				probe[i], adap->name, 
+				(1 == rc) ? "yes" : "no");
+			if (1 == rc) {
+				ir_attach(adap,probe[i],0,0);
+				break;
+			}
+		}
+	}
+	return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+MODULE_AUTHOR("Gerd Knorr, Michal Kochanowicz, Christoph Bartelmus, Ulrich Mueller");
+MODULE_DESCRIPTION("input driver for i2c IR remote controls");
+MODULE_LICENSE("GPL");
+
+static int ir_init(void)
+{
+	i2c_add_driver(&driver);
+	return 0;
+}
+
+static void ir_fini(void)
+{
+	i2c_del_driver(&driver);
+}
+
+module_init(ir_init);
+module_exit(ir_fini);
+
+/*
+ * Overrides for Emacs so that we follow Linus's tabbing style.
+ * ---------------------------------------------------------------------------
+ * Local variables:
+ * c-basic-offset: 8
+ * End:
+ */
diff -puN drivers/media/video/Kconfig~linus drivers/media/video/Kconfig
--- 25/drivers/media/video/Kconfig~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/Kconfig	2004-01-19 22:17:22.000000000 -0800
@@ -9,7 +9,8 @@ comment "Video Adapters"
 
 config VIDEO_BT848
 	tristate "BT848 Video For Linux"
-	depends on VIDEO_DEV && PCI && I2C_ALGOBIT && SOUND
+	depends on VIDEO_DEV && PCI && I2C && SOUND
+	select I2C_ALGOBIT
 	---help---
 	  Support for BT848 based frame grabber/overlay boards. This includes
 	  the Miro, Hauppauge and STB boards. Please read the material in
@@ -274,5 +275,15 @@ config VIDEO_HEXIUM_GEMINI
 	  To compile this driver as a module, choose M here: the
 	  module will be called hexium_gemini.
 
+config VIDEO_CX88
+	tristate "Conexant 2388x (bt878 successor) support"
+	depends on VIDEO_DEV && PCI && I2C_ALGOBIT && EXPERIMENTAL
+	---help---
+	  This is a video4linux driver for Conexant 2388x based
+	  TV cards.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called cx8800
+
 endmenu
 
diff -puN drivers/media/video/Makefile~linus drivers/media/video/Makefile
--- 25/drivers/media/video/Makefile~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/Makefile	2004-01-19 22:17:22.000000000 -0800
@@ -3,7 +3,7 @@
 #
 
 bttv-objs	:=	bttv-driver.o bttv-cards.o bttv-if.o \
-			bttv-risc.o bttv-vbi.o
+			bttv-risc.o bttv-vbi.o bttv-i2c.o bttv-gpio.o
 zoran-objs      :=	zr36120.o zr36120_i2c.o zr36120_mem.o
 zr36067-objs	:=	zoran_procfs.o zoran_device.o \
 			zoran_driver.o zoran_card.o
@@ -11,7 +11,7 @@ zr36067-objs	:=	zoran_procfs.o zoran_dev
 obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-common.o v4l1-compat.o
 
 obj-$(CONFIG_VIDEO_BT848) += bttv.o msp3400.o tvaudio.o \
-	tda7432.o tda9875.o
+	tda7432.o tda9875.o ir-kbd-i2c.o ir-kbd-gpio.o
 obj-$(CONFIG_SOUND_TVMIXER) += tvmixer.o
 
 obj-$(CONFIG_VIDEO_ZR36120) += zoran.o
@@ -35,6 +35,7 @@ obj-$(CONFIG_VIDEO_CPIA_PP) += cpia_pp.o
 obj-$(CONFIG_VIDEO_CPIA_USB) += cpia_usb.o
 obj-$(CONFIG_VIDEO_MEYE) += meye.o
 obj-$(CONFIG_VIDEO_SAA7134) += saa7134/
+obj-$(CONFIG_VIDEO_CX88) += cx88/
 obj-$(CONFIG_VIDEO_MXB) += saa7111.o tuner.o tda9840.o tea6415c.o tea6420.o mxb.o
 obj-$(CONFIG_VIDEO_HEXIUM_ORION) += hexium_orion.o
 obj-$(CONFIG_VIDEO_HEXIUM_GEMINI) += hexium_gemini.o
diff -puN drivers/media/video/msp3400.c~linus drivers/media/video/msp3400.c
--- 25/drivers/media/video/msp3400.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/msp3400.c	2004-01-19 22:17:22.000000000 -0800
@@ -50,10 +50,6 @@
 #include <asm/semaphore.h>
 #include <asm/pgtable.h>
 
-/* kernel_thread */
-#define __KERNEL_SYSCALLS__
-#include <linux/unistd.h>
-
 #include <media/audiochip.h>
 #include "msp3400.h"
 
@@ -194,7 +190,7 @@ msp3400c_read(struct i2c_client *client,
 		err++;
 		printk(KERN_WARNING "msp34xx: I/O error #%d (read 0x%02x/0x%02x)\n",
 		       err, dev, addr);
-		current->state = TASK_INTERRUPTIBLE;
+		set_current_state(TASK_INTERRUPTIBLE);
 		schedule_timeout(HZ/10);
 	}
 	if (3 == err) {
@@ -223,7 +219,7 @@ msp3400c_write(struct i2c_client *client
 		err++;
 		printk(KERN_WARNING "msp34xx: I/O error #%d (write 0x%02x/0x%02x)\n",
 		       err, dev, addr);
-		current->state = TASK_INTERRUPTIBLE;
+		set_current_state(TASK_INTERRUPTIBLE);
 		schedule_timeout(HZ/10);
 	}
 	if (3 == err) {
@@ -804,7 +800,7 @@ static int msp3400c_thread(void *data)
 		}
 
 		/* some time for the tuner to sync */
-		current->state   = TASK_INTERRUPTIBLE;
+		set_current_state(TASK_INTERRUPTIBLE);
 		schedule_timeout(HZ/5);
 		if (signal_pending(current))
 			goto done;
@@ -839,7 +835,7 @@ static int msp3400c_thread(void *data)
 		for (this = 0; this < count; this++) {
 			msp3400c_setcarrier(client, cd[this].cdo,cd[this].cdo);
 
-			current->state   = TASK_INTERRUPTIBLE;
+			set_current_state(TASK_INTERRUPTIBLE);
 			schedule_timeout(HZ/10);
 			if (signal_pending(current))
 				goto done;
@@ -876,7 +872,7 @@ static int msp3400c_thread(void *data)
 		for (this = 0; this < count; this++) {
 			msp3400c_setcarrier(client, cd[this].cdo,cd[this].cdo);
 
-			current->state   = TASK_INTERRUPTIBLE;
+			set_current_state(TASK_INTERRUPTIBLE);
 			schedule_timeout(HZ/10);
 			if (signal_pending(current))
 				goto done;
@@ -1052,7 +1048,7 @@ static int msp3410d_thread(void *data)
 		}
 	
 		/* some time for the tuner to sync */
-		current->state   = TASK_INTERRUPTIBLE;
+		set_current_state(TASK_INTERRUPTIBLE);
 		schedule_timeout(HZ/5);
 		if (signal_pending(current))
 			goto done;
@@ -1113,7 +1109,7 @@ static int msp3410d_thread(void *data)
 		} else {
 			/* triggered autodetect */
 			for (;;) {
-				current->state   = TASK_INTERRUPTIBLE;
+				set_current_state(TASK_INTERRUPTIBLE);
 				schedule_timeout(HZ/10);
 				if (signal_pending(current))
 					goto done;
@@ -1204,6 +1200,8 @@ static int msp3410d_thread(void *data)
 #endif
 			break;
 		case 0x0003:
+		case 0x0004:
+		case 0x0005:
 			msp->mode   = MSP_MODE_FM_TERRA;
 			msp->stereo = VIDEO_SOUND_MONO;
 			msp->nicam_on = 0;
@@ -1262,7 +1260,7 @@ static int msp_attach(struct i2c_adapter
 	DECLARE_MUTEX_LOCKED(sem);
 	struct msp3400c *msp;
         struct i2c_client *c;
-	int i;
+	int i, rc;
 
         client_template.adapter = adap;
         client_template.addr = addr;
@@ -1316,7 +1314,7 @@ static int msp_attach(struct i2c_adapter
 #endif
 	msp3400c_setvolume(c,msp->muted,msp->left,msp->right);
 
-	snprintf(c->name, I2C_NAME_SIZE, "MSP34%02d%c-%c%d",
+	snprintf(c->name, sizeof(c->name), "MSP34%02d%c-%c%d",
 		 (msp->rev2>>8)&0xff, (msp->rev1&0xff)+'@',
 		 ((msp->rev1>>8)&0xff)+'@', msp->rev2&0x1f);
 
@@ -1345,9 +1343,12 @@ static int msp_attach(struct i2c_adapter
 
 	/* startup control thread */
 	msp->notify = &sem;
-	kernel_thread(msp->simple ? msp3410d_thread : msp3400c_thread,
-		      (void *)c, 0);
-	down(&sem);
+	rc = kernel_thread(msp->simple ? msp3410d_thread : msp3400c_thread,
+			   (void *)c, 0);
+	if (rc < 0)
+		printk(KERN_WARNING "msp34xx: kernel_thread() failed\n");
+	else
+		down(&sem);
 	msp->notify = NULL;
 	wake_up_interruptible(&msp->wq);
 
@@ -1398,8 +1399,13 @@ static int msp_detach(struct i2c_client 
 
 static int msp_probe(struct i2c_adapter *adap)
 {
+#ifdef I2C_ADAP_CLASS_TV_ANALOG
 	if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
 		return i2c_probe(adap, &addr_data, msp_attach);
+#else
+	if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848))
+		return i2c_probe(adap, &addr_data, msp_attach);
+#endif
 	return 0;
 }
 
diff -puN drivers/media/video/saa7134/Makefile~linus drivers/media/video/saa7134/Makefile
--- 25/drivers/media/video/saa7134/Makefile~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/saa7134/Makefile	2004-01-19 22:17:22.000000000 -0800
@@ -1,7 +1,7 @@
 
 saa7134-objs :=	saa7134-cards.o saa7134-core.o saa7134-i2c.o	\
 		saa7134-oss.o saa7134-ts.o saa7134-tvaudio.o	\
-		saa7134-vbi.o saa7134-video.o
+		saa7134-vbi.o saa7134-video.o saa7134-input.o
 
 obj-$(CONFIG_VIDEO_SAA7134) += saa7134.o
 
diff -puN drivers/media/video/saa7134/saa6752hs.c~linus drivers/media/video/saa7134/saa6752hs.c
--- 25/drivers/media/video/saa7134/saa6752hs.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/saa7134/saa6752hs.c	2004-01-19 22:17:22.000000000 -0800
@@ -168,13 +168,13 @@ static int saa6752hs_chip_command(struct
 		}
 	
 		// wait a bit
-		current->state = TASK_INTERRUPTIBLE;
-		schedule_timeout(1);
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(HZ/100);
 	}
 
 	// delay a bit to let encoder settle
-	current->state = TASK_INTERRUPTIBLE;
-	schedule_timeout(5);
+	set_current_state(TASK_INTERRUPTIBLE);
+	schedule_timeout(HZ/20);
 	
 	// done
   	return status;
@@ -230,6 +230,7 @@ static int saa6752hs_set_bitrate(struct 
 static int saa6752hs_init(struct i2c_client* client, struct mpeg_params* params)
 {  
 	unsigned char buf[3];
+	void *data;
 
 	// check the bitrate parameters first
 	if (params != NULL) {
@@ -281,12 +282,13 @@ static int saa6752hs_init(struct i2c_cli
 	i2c_master_send(client,buf,3);
   
         // setup bitrate settings
+	data = i2c_get_clientdata(client);
 	if (params) {
 		saa6752hs_set_bitrate(client, params);
-		memcpy(client->data, params, sizeof(struct mpeg_params));
+		memcpy(data, params, sizeof(struct mpeg_params));
 	} else {
 		// parameters were not supplied. use the previous set
-   		saa6752hs_set_bitrate(client, (struct mpeg_params*) client->data);
+   		saa6752hs_set_bitrate(client, (struct mpeg_params*) data);
 	}
 	  
 	// Send SI tables
@@ -324,7 +326,7 @@ static int saa6752hs_attach(struct i2c_a
 	if (NULL == (params = kmalloc(sizeof(struct mpeg_params), GFP_KERNEL)))
 		return -ENOMEM;
 	memcpy(params,&mpeg_params_template,sizeof(struct mpeg_params));
-	client->data = params;
+	i2c_set_clientdata(client, params);
 
         i2c_attach_client(client);
   
@@ -341,8 +343,11 @@ static int saa6752hs_probe(struct i2c_ad
 
 static int saa6752hs_detach(struct i2c_client *client)
 {
+	void *data;
+
+	data = i2c_get_clientdata(client);
 	i2c_detach_client(client);
-	kfree(client->data);
+	kfree(data);
 	kfree(client);
 	return 0;
 }
diff -puN drivers/media/video/saa7134/saa7134-cards.c~linus drivers/media/video/saa7134/saa7134-cards.c
--- 25/drivers/media/video/saa7134/saa7134-cards.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/saa7134/saa7134-cards.c	2004-01-19 22:17:22.000000000 -0800
@@ -2,7 +2,7 @@
  * device driver for philips saa7134 based TV cards
  * card-specific stuff.
  *
- * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
+ * (c) 2001-03 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -70,6 +70,10 @@ struct saa7134_board saa7134_boards[] = 
 			.amux = LINE2,
 			.tv   = 1,
 		}},
+		.radio = {
+			.name = name_radio,
+			.amux = LINE2,
+		},
 	},
 	[SAA7134_BOARD_FLYVIDEO3000] = {
 		/* "Marco d'Itri" <md@Linux.IT> */
@@ -235,7 +239,8 @@ struct saa7134_board saa7134_boards[] = 
 		},
 	},
 	[SAA7134_BOARD_TVSTATION_RDS] = {
-		.name		= "KNC One TV-Station RDS",
+                /* Typhoon TV Tuner RDS: Art.Nr. 50694 */
+		.name		= "KNC One TV-Station RDS / Typhoon TV Tuner RDS",
 		.audio_clock	= 0x00200000,
 		.tuner_type	= TUNER_PHILIPS_FM1216ME_MK3,
 		.need_tda9887   = 1,
@@ -245,18 +250,61 @@ struct saa7134_board saa7134_boards[] = 
 			.amux = TV,
 			.tv   = 1,
 		},{
+			.name = name_tv_mono,
+                        .vmux = 1,
+                        .amux   = LINE2,
+                        .tv   = 1,
+                },{
+
+			.name = name_svideo,
+			.vmux = 8,
+			.amux = LINE1,
+		},{
 			.name = name_comp1,
-			.vmux = 2,
+			.vmux = 3,
 			.amux = LINE1,
 		},{
-			.name = name_comp2,
+
+                        .name = "CVid over SVid",
+                        .vmux = 0,
+                        .amux = LINE1,
+                }},
+		.radio = {
+			.name = name_radio,
+			.amux = LINE2,
+		},
+	},
+	[SAA7134_BOARD_TVSTATION_DVR] = {
+		.name		= "KNC One TV-Station DVR",
+		.audio_clock	= 0x00200000,
+		.tuner_type	= TUNER_PHILIPS_FM1216ME_MK3,
+		.need_tda9887	= 1,
+		.gpiomask	= 0x820000,
+		.inputs		= {{
+			.name = name_tv,
+			.vmux = 1,
+			.amux = LINE2,
+			.tv   = 1,
+			.gpio = 0x20000,
+		},{
+			.name = name_svideo,
+			.vmux = 8,
+			.amux = LINE1,
+			.gpio = 0x20000,
+		},{
+			.name = name_comp1,
 			.vmux = 3,
 			.amux = LINE1,
+			.gpio = 0x20000,
 		}},
-		.radio = {
+		.radio		= {
 			.name = name_radio,
 			.amux = LINE2,
+			.gpio = 0x20000,
 		},
+		.i2s_rate	= 48000,
+		.has_ts		= 1,
+		.video_out	= CCIR656,
 	},
 	[SAA7134_BOARD_CINERGY400] = {
                 .name           = "Terratec Cinergy 400 TV",
@@ -283,7 +331,7 @@ struct saa7134_board saa7134_boards[] = 
         },
 	[SAA7134_BOARD_MD5044] = {
 		.name           = "Medion 5044",
-		.audio_clock    = 0x00200000,
+		.audio_clock    = 0x00187de7, // was: 0x00200000,
 		.tuner_type     = TUNER_PHILIPS_FM1216ME_MK3,
 		.need_tda9887   = 1,
 		.inputs         = {{
@@ -393,11 +441,11 @@ struct saa7134_board saa7134_boards[] = 
 		},
 	},
 	[SAA7134_BOARD_TYPHOON_90031] = {
-		/* Christian Rothlï¿½nder <Christian@Rothlaender.net> */
+		/* aka Typhoon "TV+Radio", Art.Nr 90031 */
+		/* Tom Zoerner <tomzo at users sourceforge net> */
 		.name           = "Typhoon TV+Radio 90031",
 		.audio_clock    = 0x00200000,
-		//.tuner_type     = TUNER_PHILIPS_PAL,
-		.tuner_type     = TUNER_PHILIPS_FM1216ME_MK3,
+		.tuner_type     = TUNER_PHILIPS_PAL,
 		.need_tda9887   = 1,
 		.inputs         = {{
 			.name   = name_tv,
@@ -450,6 +498,11 @@ struct saa7134_board saa7134_boards[] = 
 			.vmux = 8,
 			.amux = TV,
 			.tv   = 1,
+		},{
+			.name = name_tv_mono,
+			.vmux = 8,
+			.amux = LINE2,
+			.tv   = 1,
 		}},
         },
 	[SAA7134_BOARD_ASUSTeK_TVFM7134] = {
@@ -505,6 +558,45 @@ struct saa7134_board saa7134_boards[] = 
                         .tv   = 1,
                 }},
 	},
+	[SAA7134_BOARD_10MOONSTVMASTER] = {
+		/* "lilicheng" <llc@linuxfans.org> */
+		.name           = "10MOONS PCI TV CAPTURE CARD",
+		.audio_clock    = 0x00200000,
+		.tuner_type     = TUNER_LG_PAL_NEW_TAPC,
+		.gpiomask       = 0xe000,
+		.inputs         = {{
+			.name = name_tv,
+			.vmux = 1,
+			.amux = LINE2,
+			.gpio = 0x0000,
+			.tv   = 1,
+		},{
+			.name = name_comp1,
+			.vmux = 0,
+			.amux = LINE2,
+			.gpio = 0x4000,
+		},{
+			.name = name_comp2,
+			.vmux = 3,
+			.amux = LINE2,
+			.gpio = 0x4000,
+		},{
+			.name = name_svideo,
+			.vmux = 8,
+			.amux = LINE2,
+			.gpio = 0x4000,
+		}},
+                .radio = {
+                        .name = name_radio,
+                        .amux = LINE2,
+			.gpio = 0x2000,
+                },
+		.mute = {
+			.name = name_mute,
+                        .amux = LINE2,
+			.gpio = 0x8000,
+		},
+	},
 	[SAA7134_BOARD_BMK_MPEX_NOTUNER] = {
 		/* "Andrew de Quincey" <adq@lidskialf.net> */
 		.name		= "BMK MPEX No Tuner",
@@ -555,13 +647,224 @@ struct saa7134_board saa7134_boards[] = 
                 }},
         },
 	[SAA7134_BOARD_CRONOS_PLUS] = {
+		/* gpio pins:
+		   0  .. 3   BASE_ID
+		   4  .. 7   PROTECT_ID
+		   8  .. 11  USER_OUT
+		   12 .. 13  USER_IN
+		   14 .. 15  VIDIN_SEL */
 		.name           = "Matrox CronosPlus",
 		.tuner_type     = TUNER_ABSENT,
+		.gpiomask       = 0xcf00,
+                .inputs         = {{
+                        .name = name_comp1,
+                        .vmux = 0,
+			.gpio = 2 << 14,
+		},{
+                        .name = name_comp2,
+                        .vmux = 0,
+			.gpio = 1 << 14,
+		},{
+                        .name = name_comp3,
+                        .vmux = 0,
+			.gpio = 0 << 14,
+		},{
+                        .name = name_comp4,
+                        .vmux = 0,
+			.gpio = 3 << 14,
+		},{
+			.name = name_svideo,
+			.vmux = 8,
+			.gpio = 2 << 14,
+                }},
+        },
+	[SAA7134_BOARD_MD2819] = {
+		.name           = "Medion 2819/ AverMedia M156",
+		.audio_clock    = 0x00187de7,
+		.tuner_type     = TUNER_PHILIPS_FM1216ME_MK3,
+		.need_tda9887   = 1,
+		.inputs         = {{
+			.name = name_tv,
+			.vmux = 1,
+			.amux = TV,
+			.tv   = 1,
+		},{
+			.name = name_comp1,
+			.vmux = 0,
+			.amux = LINE2,
+		},{
+			.name = name_comp2,
+			.vmux = 3,
+			.amux = LINE2,
+		},{
+			.name = name_svideo,
+			.vmux = 8,
+			.amux = LINE2,
+		}},
+		.radio = {
+			.name = name_radio,
+			.amux = LINE2,
+		},
+	},
+	[SAA7134_BOARD_BMK_MPEX_TUNER] = {
+		/* "Greg Wickham <greg.wickham@grangenet.net> */
+		.name           = "BMK MPEX Tuner",
+		.audio_clock    = 0x200000,
+		.tuner_type     = TUNER_PHILIPS_PAL,
+		.inputs         = {{
+			.name = name_comp1,
+			.vmux = 1,
+			.amux = LINE1,
+		},{
+			.name = name_svideo,
+			.vmux = 8,
+			.amux = LINE1,
+		},{
+			.name = name_tv,
+			.vmux = 3,
+			.amux = LINE2,
+			.tv   = 1,
+		}},
+		.i2s_rate  = 48000,
+		.has_ts    = 1,
+		.video_out = CCIR656,
+        },
+        [SAA7134_BOARD_ASUSTEK_TVFM7133] = {
+                .name           = "ASUS TV-FM 7133",
+                .audio_clock    = 0x00187de7,
+                .tuner_type     = TUNER_PHILIPS_FM1236_MK3,
+                .need_tda9887   = 1,
+                .inputs         = {{
+                        .name = name_tv,
+                        .vmux = 1,
+                        .amux = TV,
+                        .tv   = 1,
+                }},
+                .radio = {
+                        .name = name_radio,
+                        .amux = LINE1,
+                },
+        },
+	[SAA7134_BOARD_PINNACLE_PCTV_STEREO] = {
+                .name           = "Pinnacle PCTV Stereo (saa7134)",
+                .audio_clock    = 0x00187de7,
+                .tuner_type     = TUNER_MT2032,
+                .need_tda9887   = 1,
                 .inputs         = {{
+                        .name = name_tv,
+                        .vmux = 3,
+                        .amux = TV,
+                        .tv   = 1,
+                },{
                         .name = name_comp1,
                         .vmux = 0,
+                        .amux = LINE2,
+                },{
+                        .name = name_comp2,
+                        .vmux = 1,
+                        .amux = LINE2,
+                },{
+                        .name = name_svideo,
+                        .vmux = 8,
+                        .amux = LINE2,
                 }},
         },
+	[SAA7134_BOARD_MANLI_MTV002] = {
+		/* Ognjen Nastic <ognjen@logosoft.ba> */
+		.name           = "Manli MuchTV M-TV002",
+		.audio_clock    = 0x00200000,
+		.tuner_type     = TUNER_PHILIPS_PAL,
+		.inputs         = {{
+			.name = name_svideo,
+			.vmux = 8,
+			.amux = LINE1,
+		},{
+			.name   = name_comp1,
+			.vmux   = 1,
+			.amux   = LINE1,
+		},{
+			.name = name_tv,
+			.vmux = 3,
+			.amux = LINE2,
+			.tv   = 1,
+		}},
+		.radio = {
+			.name = name_radio,
+			.amux = LINE2,
+		},
+	},
+	[SAA7134_BOARD_MANLI_MTV001] = {
+		/* Ognjen Nastic <ognjen@logosoft.ba> UNTESTED */
+		.name           = "Manli MuchTV M-TV001",
+		.audio_clock    = 0x00200000,
+		.tuner_type     = TUNER_PHILIPS_PAL,
+		.inputs         = {{
+			.name = name_svideo,
+			.vmux = 8,
+			.amux = LINE1,
+		},{			
+			.name = name_comp1,
+			.vmux = 1,
+			.amux = LINE1,
+		},{
+			.name = name_tv,
+			.vmux = 3,
+			.amux = LINE2,
+			.tv   = 1,
+		}},
+        },
+	[SAA7134_BOARD_TG3000TV] = {
+		/* TransGear 3000TV */
+		.name           = "Nagase Sangyo TransGear 3000TV",
+		.audio_clock    = 0x00187de7,
+		.tuner_type     = TUNER_PHILIPS_NTSC_M,
+		.inputs         = {{
+			.name = name_tv,
+			.vmux = 1,
+			.amux = LINE2,
+			.tv   = 1,
+		},{
+			.name = name_comp1,
+			.vmux = 3,
+			.amux = LINE2,
+		},{
+			.name = name_svideo,
+			.vmux = 8,
+			.amux = LINE2,
+		}},
+	},
+        [SAA7134_BOARD_ECS_TVP3XP] = {
+                .name           = "Elitegroup ECS TVP3XP FM1216 Tuner Card",
+                .audio_clock    = 0x187de7,  // xtal 32.1 MHz
+                .tuner_type     = TUNER_PHILIPS_PAL,
+                .inputs         = {{
+                        .name   = name_tv,
+                        .vmux   = 1,
+                        .amux   = TV,
+                        .tv     = 1,
+                },{
+                        .name   = name_tv_mono,
+                        .vmux   = 1,
+                        .amux   = LINE2,
+                        .tv     = 1,
+                },{
+                        .name   = name_comp1,
+                        .vmux   = 3,
+                        .amux   = LINE1,
+                },{
+                        .name   = name_svideo,
+                        .vmux   = 8,
+                        .amux   = LINE1,
+		},{
+			.name   = "CVid over SVid",
+			.vmux   = 0,
+			.amux   = LINE1,
+		}},
+                .radio = {
+                        .name   = name_radio,
+                        .amux   = LINE2,
+                },
+        },
 };
 const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);
 
@@ -613,6 +916,12 @@ struct pci_device_id saa7134_pci_tbl[] =
 		.driver_data  = SAA7134_BOARD_FLYVIDEO3000,
         },{
 		.vendor       = PCI_VENDOR_ID_PHILIPS,
+                .device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
+                .subvendor    = 0x4e42,				//"Typhoon PCI Capture TV Card" Art.No. 50673
+                .subdevice    = 0x0138,
+                .driver_data  = SAA7134_BOARD_FLYVIDEO3000,
+        },{
+		.vendor       = PCI_VENDOR_ID_PHILIPS,
 		.device       = PCI_DEVICE_ID_PHILIPS_SAA7130,
 		.subvendor    = 0x5168,
 		.subdevice    = 0x0138,
@@ -648,11 +957,35 @@ struct pci_device_id saa7134_pci_tbl[] =
                 .subdevice    = 0x4830,
                 .driver_data  = SAA7134_BOARD_ASUSTeK_TVFM7134,
         },{
+                .vendor       = PCI_VENDOR_ID_PHILIPS,
+                .device       = PCI_DEVICE_ID_PHILIPS_SAA7133,
+                .subvendor    = PCI_VENDOR_ID_ASUSTEK,
+                .subdevice    = 0x4843,
+                .driver_data  = SAA7134_BOARD_ASUSTEK_TVFM7133,
+	},{
+                .vendor       = PCI_VENDOR_ID_PHILIPS,
+                .device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
+                .subvendor    = PCI_VENDOR_ID_ASUSTEK,
+                .subdevice    = 0x4840,
+                .driver_data  = SAA7134_BOARD_ASUSTeK_TVFM7134,
+        },{
 		.vendor       = PCI_VENDOR_ID_PHILIPS,
 		.device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
 		.subvendor    = PCI_VENDOR_ID_PHILIPS,
 		.subdevice    = 0xfe01,
-		.driver_data  = SAA7134_BOARD_TYPHOON_90031,
+		.driver_data  = SAA7134_BOARD_TVSTATION_RDS,
+	},{
+		.vendor       = PCI_VENDOR_ID_PHILIPS,
+		.device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
+		.subvendor    = 0x1894,
+		.subdevice    = 0xfe01,
+		.driver_data  = SAA7134_BOARD_TVSTATION_RDS,
+	},{
+		.vendor       = PCI_VENDOR_ID_PHILIPS,
+		.device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
+		.subvendor    = 0x1894,
+		.subdevice    = 0xa006,
+		.driver_data  = SAA7134_BOARD_TVSTATION_DVR,
 	},{
 		.vendor       = PCI_VENDOR_ID_PHILIPS,
 		.device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
@@ -661,6 +994,12 @@ struct pci_device_id saa7134_pci_tbl[] =
 		.driver_data  = SAA7134_BOARD_VA1000POWER,
         },{
 		.vendor       = PCI_VENDOR_ID_PHILIPS,
+		.device       = PCI_DEVICE_ID_PHILIPS_SAA7130,
+                .subvendor    = PCI_VENDOR_ID_PHILIPS,
+                .subdevice    = 0x2001,
+		.driver_data  = SAA7134_BOARD_10MOONSTVMASTER,
+        },{
+		.vendor       = PCI_VENDOR_ID_PHILIPS,
 		.device       = PCI_DEVICE_ID_PHILIPS_SAA7133,
                 .subvendor    = 0x185b,
                 .subdevice    = 0xc100,
@@ -672,6 +1011,38 @@ struct pci_device_id saa7134_pci_tbl[] =
                 .subdevice    = 0x48d0,
 		.driver_data  = SAA7134_BOARD_CRONOS_PLUS,
 	},{
+		.vendor       = PCI_VENDOR_ID_PHILIPS,
+		.device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
+                .subvendor    = 0x1461, /* Avermedia Technologies Inc */
+                .subdevice    = 0xa70b,
+		.driver_data  = SAA7134_BOARD_MD2819,
+	},{
+		/* AverMedia Studio 305, using AverMedia M156 entry for now */
+		.vendor       = PCI_VENDOR_ID_PHILIPS,
+		.device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
+                .subvendor    = 0x1461, /* Avermedia Technologies Inc */
+                .subdevice    = 0x2115,
+		.driver_data  = SAA7134_BOARD_MD2819,
+        },{
+		/* TransGear 3000TV */
+		.vendor       = PCI_VENDOR_ID_PHILIPS,
+		.device       = PCI_DEVICE_ID_PHILIPS_SAA7130,
+                .subvendor    = 0x1461, /* Avermedia Technologies Inc */
+                .subdevice    = 0x050c,
+		.driver_data  = SAA7134_BOARD_TG3000TV,
+	},{
+                .vendor       = PCI_VENDOR_ID_PHILIPS,
+                .device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
+                .subvendor    = 0x11bd,
+                .subdevice    = 0x002b,
+                .driver_data  = SAA7134_BOARD_PINNACLE_PCTV_STEREO,
+        },{
+                .vendor       = PCI_VENDOR_ID_PHILIPS,
+                .device       = PCI_DEVICE_ID_PHILIPS_SAA7134,
+                .subvendor    = 0x1019,
+                .subdevice    = 0x4cb4,
+                .driver_data  = SAA7134_BOARD_ECS_TVP3XP,
+        },{
 		
 		/* --- boards without eeprom + subsystem ID --- */
                 .vendor       = PCI_VENDOR_ID_PHILIPS,
@@ -777,6 +1148,7 @@ int saa7134_board_init(struct saa7134_de
 		dev->has_remote = 1;
 		break;
 	case SAA7134_BOARD_CINERGY400:
+	case SAA7134_BOARD_CINERGY600:
 		dev->has_remote = 1;
 		break;
 	}
diff -puN drivers/media/video/saa7134/saa7134-core.c~linus drivers/media/video/saa7134/saa7134-core.c
--- 25/drivers/media/video/saa7134/saa7134-core.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/saa7134/saa7134-core.c	2004-01-19 22:17:22.000000000 -0800
@@ -599,12 +599,10 @@ static irqreturn_t saa7134_irq(int irq, 
 		if ((report & SAA7134_IRQ_REPORT_DONE_RA3))
 			saa7134_irq_oss_done(dev,status);
 
-#ifdef CONFIG_VIDEO_IR
 		if ((report & (SAA7134_IRQ_REPORT_GPIO16 |
 			       SAA7134_IRQ_REPORT_GPIO18)) &&
 		    dev->remote)
 			saa7134_input_irq(dev);
-#endif
 
 	};
 	if (10 == loop) {
@@ -636,9 +634,7 @@ static int saa7134_hwinit1(struct saa713
 	saa7134_vbi_init1(dev);
 	if (card_has_ts(dev))
 		saa7134_ts_init1(dev);
-#ifdef CONFIG_VIDEO_IR
 	saa7134_input_init1(dev);
-#endif
 
 	switch (dev->pci->device) {
 	case PCI_DEVICE_ID_PHILIPS_SAA7134:
@@ -714,9 +710,7 @@ static int saa7134_hwfini(struct saa7134
 	}
 	if (card_has_ts(dev))
 		saa7134_ts_fini(dev);
-#ifdef CONFIG_VIDEO_IR
 	saa7134_input_fini(dev);
-#endif
 	saa7134_vbi_fini(dev);
 	saa7134_video_fini(dev);
 	saa7134_tvaudio_fini(dev);
@@ -907,7 +901,7 @@ static int __devinit saa7134_initdev(str
 	}
 
 	/* wait a bit, register i2c bus */
-	current->state = TASK_INTERRUPTIBLE;
+	set_current_state(TASK_INTERRUPTIBLE);
 	schedule_timeout(HZ/10);
 	saa7134_i2c_register(dev);
 
@@ -922,6 +916,10 @@ static int __devinit saa7134_initdev(str
   	if (card_has_ts(dev))
 		request_module("saa6752hs");
 
+#ifdef VIDIOC_G_PRIORITY
+	v4l2_prio_init(&dev->prio);
+#endif
+
 	/* register v4l devices */
 	dev->video_dev = vdev_init(dev,&saa7134_video_template,"video");
 	err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER,
@@ -1041,18 +1039,7 @@ static void __devexit saa7134_finidev(st
 	saa_writel(SAA7134_MAIN_CTRL,0);
 
 	/* shutdown subsystems */
-	switch (dev->pci->device) {
-	case PCI_DEVICE_ID_PHILIPS_SAA7134:
-	case PCI_DEVICE_ID_PHILIPS_SAA7133:
-	case PCI_DEVICE_ID_PHILIPS_SAA7135:
-		saa7134_oss_fini(dev);
-		break;
-	}
-	if (card_has_ts(dev))
-		saa7134_ts_fini(dev);
-	saa7134_vbi_fini(dev);
-	saa7134_video_fini(dev);
-	saa7134_tvaudio_fini(dev);
+	saa7134_hwfini(dev);
 
 	/* unregister */
 	saa7134_i2c_unregister(dev);
@@ -1099,6 +1086,10 @@ static int saa7134_init(void)
 	       (SAA7134_VERSION_CODE >> 16) & 0xff,
 	       (SAA7134_VERSION_CODE >>  8) & 0xff,
 	       SAA7134_VERSION_CODE & 0xff);
+#ifdef SNAPSHOT
+	printk(KERN_INFO "saa7130/34: snapshot date %04d-%02d-%02d\n",
+	       SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
+#endif
 	return pci_module_init(&saa7134_pci_driver);
 }
 
diff -puN drivers/media/video/saa7134/saa7134.h~linus drivers/media/video/saa7134/saa7134.h
--- 25/drivers/media/video/saa7134/saa7134.h~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/saa7134/saa7134.h	2004-01-19 22:17:22.000000000 -0800
@@ -29,14 +29,11 @@
 
 #include <asm/io.h>
 
-#ifdef CONFIG_VIDEO_IR
-#include "ir-common.h"
-#endif
-
 #include <media/video-buf.h>
 #include <media/tuner.h>
 #include <media/audiochip.h>
 #include <media/id.h>
+#include <media/ir-common.h>
 
 #ifndef TRUE
 # define TRUE (1==1)
@@ -116,6 +113,7 @@ struct saa7134_format {
 	unsigned int   wswap:1;
 	unsigned int   yuv:1;
 	unsigned int   planar:1;
+	unsigned int   uvswap:1;
 };
 
 /* ----------------------------------------------------------- */
@@ -143,6 +141,16 @@ struct saa7134_format {
 #define SAA7134_BOARD_BMK_MPEX_NOTUNER 18
 #define SAA7134_BOARD_VIDEOMATE_TV     19
 #define SAA7134_BOARD_CRONOS_PLUS      20
+#define SAA7134_BOARD_10MOONSTVMASTER  21
+#define SAA7134_BOARD_MD2819           22
+#define SAA7134_BOARD_BMK_MPEX_TUNER   23
+#define SAA7134_BOARD_TVSTATION_DVR    24
+#define SAA7134_BOARD_ASUSTEK_TVFM7133	25
+#define SAA7134_BOARD_PINNACLE_PCTV_STEREO 26
+#define SAA7134_BOARD_MANLI_MTV002     27
+#define SAA7134_BOARD_MANLI_MTV001     28
+#define SAA7134_BOARD_TG3000TV         29
+#define SAA7134_BOARD_ECS_TVP3XP       30
 
 #define SAA7134_INPUT_MAX 8
 
@@ -242,11 +250,15 @@ struct saa7134_fh {
 	struct saa7134_dev         *dev;
 	unsigned int               radio;
 	enum v4l2_buf_type         type;
+	unsigned int               resources;
+#ifdef VIDIOC_G_PRIORITY 
+	enum v4l2_priority	   prio;
+#endif
 
+	/* video overlay */
 	struct v4l2_window         win;
 	struct v4l2_clip           clips[8];
 	unsigned int               nclips;
-	unsigned int               resources;
 
 	/* video capture */
 	struct saa7134_format      *fmt;
@@ -298,7 +310,6 @@ struct saa7134_oss {
 	unsigned int               read_count;
 };
 
-#ifdef CONFIG_VIDEO_IR
 /* IR input */
 struct saa7134_ir {
 	struct input_dev           dev;
@@ -307,14 +318,17 @@ struct saa7134_ir {
 	char                       phys[32];
 	u32                        mask_keycode;
 	u32                        mask_keydown;
+	u32                        mask_keyup;
 };
-#endif
 
 /* global device status */
 struct saa7134_dev {
 	struct list_head           devlist;
         struct semaphore           lock;
        	spinlock_t                 slock;
+#ifdef VIDIOC_G_PRIORITY 
+	struct v4l2_prio_state     prio;
+#endif
 
 	/* various device info */
 	unsigned int               resources;
@@ -327,9 +341,7 @@ struct saa7134_dev {
 
 	/* infrared remote */
 	int                        has_remote;
-#ifdef CONFIG_VIDEO_IR
 	struct saa7134_ir          *remote;
-#endif
 
 	/* pci i/o */
 	char                       name[32];
@@ -358,6 +370,7 @@ struct saa7134_dev {
 	struct saa7134_dmaqueue    video_q;
 	struct saa7134_dmaqueue    ts_q;
 	struct saa7134_dmaqueue    vbi_q;
+	unsigned int               video_fieldcount;
 	unsigned int               vbi_fieldcount;
 
 	/* various v4l controls */
@@ -403,9 +416,7 @@ struct saa7134_dev {
 #define saa_setb(reg,bit)          saa_andorb((reg),(bit),(bit))
 #define saa_clearb(reg,bit)        saa_andorb((reg),(bit),0)
 
-//#define saa_wait(d) { if (need_resched()) schedule(); else udelay(d);}
 #define saa_wait(d) { udelay(d); }
-//#define saa_wait(d) { schedule_timeout(HZ*d/1000 ?:1); }
 
 /* ----------------------------------------------------------- */
 /* saa7134-core.c                                              */
diff -puN /dev/null drivers/media/video/saa7134/saa7134-input.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/media/video/saa7134/saa7134-input.c	2004-01-19 22:17:22.000000000 -0800
@@ -0,0 +1,218 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Should you need to contact me, the author, you can do so either by
+ * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
+ * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/input.h>
+
+#include "saa7134-reg.h"
+#include "saa7134.h"
+
+/* ---------------------------------------------------------------------- */
+
+static IR_KEYTAB_TYPE flyvideo_codes[IR_KEYTAB_SIZE] = {
+	[   15 ] = KEY_KP0,
+	[    3 ] = KEY_KP1,
+	[    4 ] = KEY_KP2,
+	[    5 ] = KEY_KP3,
+	[    7 ] = KEY_KP4,
+	[    8 ] = KEY_KP5,
+	[    9 ] = KEY_KP6,
+	[   11 ] = KEY_KP7,
+	[   12 ] = KEY_KP8,
+	[   13 ] = KEY_KP9,
+
+	[   14 ] = KEY_TUNER,        // Air/Cable
+	[   17 ] = KEY_VIDEO,        // Video
+	[   21 ] = KEY_AUDIO,        // Audio
+	[    0 ] = KEY_POWER,        // Pover
+	[    2 ] = KEY_ZOOM,         // Fullscreen
+	[   27 ] = KEY_MUTE,         // Mute
+	[   20 ] = KEY_VOLUMEUP,
+	[   23 ] = KEY_VOLUMEDOWN,
+	[   18 ] = KEY_CHANNELUP,    // Channel +
+	[   19 ] = KEY_CHANNELDOWN,  // Channel - 
+	[    6 ] = KEY_AGAIN,        // Recal
+	[   16 ] = KEY_KPENTER,      // Enter
+
+#if 1 /* FIXME */
+	[   26 ] = KEY_F22,          // Stereo
+	[   24 ] = KEY_EDIT,         // AV Source
+#endif
+};
+
+static IR_KEYTAB_TYPE cinergy_codes[IR_KEYTAB_SIZE] = {
+	[    0 ] = KEY_KP0,
+	[    1 ] = KEY_KP1,
+	[    2 ] = KEY_KP2,
+	[    3 ] = KEY_KP3,
+	[    4 ] = KEY_KP4,
+	[    5 ] = KEY_KP5,
+	[    6 ] = KEY_KP6,
+	[    7 ] = KEY_KP7,
+	[    8 ] = KEY_KP8,
+	[    9 ] = KEY_KP9,
+
+	[ 0x0a ] = KEY_POWER,
+	[ 0x0b ] = KEY_PROG1,           // app
+	[ 0x0c ] = KEY_ZOOM,            // zoom/fullscreen
+	[ 0x0d ] = KEY_CHANNELUP,       // channel
+	[ 0x0e ] = KEY_CHANNELDOWN,     // channel-
+	[ 0x0f ] = KEY_VOLUMEUP,
+	[ 0x10 ] = KEY_VOLUMEDOWN,
+	[ 0x11 ] = KEY_TUNER,           // AV
+	[ 0x12 ] = KEY_NUMLOCK,         // -/--
+	[ 0x13 ] = KEY_AUDIO,           // audio
+	[ 0x14 ] = KEY_MUTE,
+	[ 0x15 ] = KEY_UP,
+	[ 0x16 ] = KEY_DOWN,
+	[ 0x17 ] = KEY_LEFT,
+	[ 0x18 ] = KEY_RIGHT,
+	[ 0x19 ] = BTN_LEFT,
+	[ 0x1a ] = BTN_RIGHT,
+	[ 0x1b ] = KEY_WWW,             // text
+	[ 0x1c ] = KEY_REWIND,
+	[ 0x1d ] = KEY_FORWARD,
+	[ 0x1e ] = KEY_RECORD,
+	[ 0x1f ] = KEY_PLAY,
+	[ 0x20 ] = KEY_PREVIOUSSONG,
+	[ 0x21 ] = KEY_NEXTSONG,
+	[ 0x22 ] = KEY_PAUSE,
+	[ 0x23 ] = KEY_STOP,
+};
+
+/* ---------------------------------------------------------------------- */
+
+static int build_key(struct saa7134_dev *dev)
+{
+	struct saa7134_ir *ir = dev->remote;
+	u32 gpio, data;
+
+	/* rising SAA7134_GPIO_GPRESCAN reads the status */
+	saa_clearb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN);
+	saa_setb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN);
+	gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
+	data = ir_extract_bits(gpio, ir->mask_keycode);
+
+	printk("%s: build_key gpio=0x%x mask=0x%x data=%d\n",
+	       dev->name, gpio, ir->mask_keycode, data);
+
+	if ((ir->mask_keydown  &&  (0 != (gpio & ir->mask_keydown))) ||
+	    (ir->mask_keyup    &&  (0 == (gpio & ir->mask_keyup)))) {
+		ir_input_keydown(&ir->dev,&ir->ir,data,data);
+	} else {
+		ir_input_nokey(&ir->dev,&ir->ir);
+	}
+	return 0;
+}
+
+/* ---------------------------------------------------------------------- */
+
+void saa7134_input_irq(struct saa7134_dev *dev)
+{
+	build_key(dev);
+}
+
+int saa7134_input_init1(struct saa7134_dev *dev)
+{
+	struct saa7134_ir *ir;
+	IR_KEYTAB_TYPE *ir_codes = NULL;
+	u32 mask_keycode = 0;
+	u32 mask_keydown = 0;
+	u32 mask_keyup   = 0;
+	int ir_type      = IR_TYPE_OTHER;
+
+	/* detect & configure */
+	if (!dev->has_remote)
+		return -ENODEV;
+	switch (dev->board) {
+	case SAA7134_BOARD_FLYVIDEO2000:
+	case SAA7134_BOARD_FLYVIDEO3000:
+		ir_codes     = flyvideo_codes;
+		mask_keycode = 0xEC00000;
+		mask_keydown = 0x0040000;
+		break;
+	case SAA7134_BOARD_CINERGY400:
+	case SAA7134_BOARD_CINERGY600:
+		ir_codes     = cinergy_codes;
+		mask_keycode = 0x00003f;
+		mask_keyup   = 0x040000;
+		break;
+	}
+	if (NULL == ir_codes) {
+		printk("%s: Oops: IR config error [card=%d]\n",
+		       dev->name, dev->board);
+		return -ENODEV;
+	}
+
+	ir = kmalloc(sizeof(*ir),GFP_KERNEL);
+	if (NULL == ir)
+		return -ENOMEM;
+	memset(ir,0,sizeof(*ir));
+
+	/* init hardware-specific stuff */
+	ir->mask_keycode = mask_keycode;
+	ir->mask_keydown = mask_keydown;
+	ir->mask_keyup   = mask_keyup;
+	
+	/* init input device */
+	snprintf(ir->name, sizeof(ir->name), "saa7134 IR (%s)",
+		 saa7134_boards[dev->board].name);
+	snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
+		 pci_name(dev->pci));
+
+	ir_input_init(&ir->dev, &ir->ir, ir_type, ir_codes);
+	ir->dev.name = ir->name;
+	ir->dev.phys = ir->phys;
+	ir->dev.id.bustype = BUS_PCI;
+	ir->dev.id.version = 1;
+	if (dev->pci->subsystem_vendor) {
+		ir->dev.id.vendor  = dev->pci->subsystem_vendor;
+		ir->dev.id.product = dev->pci->subsystem_device;
+	} else {
+		ir->dev.id.vendor  = dev->pci->vendor;
+		ir->dev.id.product = dev->pci->device;
+	}
+
+	/* all done */
+	dev->remote = ir;
+	input_register_device(&dev->remote->dev);
+	printk("%s: registered input device for IR\n",dev->name);
+	return 0;
+}
+
+void saa7134_input_fini(struct saa7134_dev *dev)
+{
+	if (NULL == dev->remote)
+		return;
+	
+	input_unregister_device(&dev->remote->dev);
+	kfree(dev->remote);
+	dev->remote = NULL;
+}
+
+/* ----------------------------------------------------------------------
+ * Local variables:
+ * c-basic-offset: 8
+ * End:
+ */
diff -puN drivers/media/video/saa7134/saa7134-oss.c~linus drivers/media/video/saa7134/saa7134-oss.c
--- 25/drivers/media/video/saa7134/saa7134-oss.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/saa7134/saa7134-oss.c	2004-01-19 22:17:22.000000000 -0800
@@ -40,7 +40,7 @@ MODULE_PARM(oss_rate,"i");
 MODULE_PARM_DESC(oss_rate,"sample rate (valid are: 32000,48000)");
 
 #define dprintk(fmt, arg...)	if (oss_debug) \
-	printk(KERN_DEBUG "%s/oss: " fmt, dev->name, ## arg)
+	printk(KERN_DEBUG "%s/oss: " fmt, dev->name , ## arg)
 
 /* ------------------------------------------------------------------ */
 
@@ -295,8 +295,10 @@ static ssize_t dsp_read(struct file *fil
 				break;
 			}
 			up(&dev->oss.lock);
-			current->state = TASK_INTERRUPTIBLE;
-			schedule();
+			set_current_state(TASK_INTERRUPTIBLE);
+			if (0 == dev->oss.read_count)
+				schedule();
+			set_current_state(TASK_RUNNING);
 			down(&dev->oss.lock);
 			if (signal_pending(current)) {
 				if (0 == ret)
@@ -328,7 +330,6 @@ static ssize_t dsp_read(struct file *fil
 	}
 	up(&dev->oss.lock);
 	remove_wait_queue(&dev->oss.wq, &wait);
-	current->state = TASK_RUNNING;
 	return ret;
 }
 
@@ -777,7 +778,7 @@ void saa7134_irq_oss_done(struct saa7134
 
 	spin_lock(&dev->slock);
 	if (UNSET == dev->oss.dma_blk) {
-		dprintk("irq: recording stopped%s\n","");
+		dprintk("irq: recording stopped\n");
 		goto done;
 	}
 	if (0 != (status & 0x0f000000))
diff -puN drivers/media/video/saa7134/saa7134-ts.c~linus drivers/media/video/saa7134/saa7134-ts.c
--- 25/drivers/media/video/saa7134/saa7134-ts.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/saa7134/saa7134-ts.c	2004-01-19 22:17:22.000000000 -0800
@@ -45,7 +45,7 @@ MODULE_PARM_DESC(tsbufs,"number of ts bu
 #define TS_NR_PACKETS 312
 
 #define dprintk(fmt, arg...)	if (ts_debug) \
-	printk(KERN_DEBUG "%s/ts: " fmt, dev->name, ## arg)
+	printk(KERN_DEBUG "%s/ts: " fmt, dev->name , ## arg)
 
 /* ------------------------------------------------------------------ */
 
@@ -173,7 +173,7 @@ static void ts_reset_encoder(struct saa7
 	saa_writeb(SAA7134_SPECIAL_MODE, 0x00);
 	mdelay(10);
    	saa_writeb(SAA7134_SPECIAL_MODE, 0x01);
-   	current->state = TASK_INTERRUPTIBLE;
+   	set_current_state(TASK_INTERRUPTIBLE);
 	schedule_timeout(HZ/10);
 }
 
@@ -196,7 +196,7 @@ static int ts_open(struct inode *inode, 
 	
 	list_for_each(list,&saa7134_devlist) {
 		h = list_entry(list, struct saa7134_dev, devlist);
-		if (h->ts_dev->minor == minor)
+		if (h->ts_dev && h->ts_dev->minor == minor)
 			dev = h;
 	}
 	if (NULL == dev)
diff -puN drivers/media/video/saa7134/saa7134-tvaudio.c~linus drivers/media/video/saa7134/saa7134-tvaudio.c
--- 25/drivers/media/video/saa7134/saa7134-tvaudio.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/saa7134/saa7134-tvaudio.c	2004-01-19 22:17:22.000000000 -0800
@@ -41,8 +41,16 @@ static unsigned int audio_carrier = 0;
 MODULE_PARM(audio_carrier,"i");
 MODULE_PARM_DESC(audio_carrier,"audio carrier location");
 
+static unsigned int audio_ddep = 0;
+MODULE_PARM(audio_ddep,"i");
+MODULE_PARM_DESC(audio_ddep,"audio ddep overwrite");
+
+static int audio_clock_tweak = 0;
+MODULE_PARM(audio_clock_tweak, "i");
+MODULE_PARM_DESC(audio_clock_tweak, "Audio clock tick fine tuning for cards with audio crystal that's slightly off (range [-1024 .. 1024])");
+
 #define dprintk(fmt, arg...)	if (audio_debug) \
-	printk(KERN_DEBUG "%s/audio: " fmt, dev->name, ## arg)
+	printk(KERN_DEBUG "%s/audio: " fmt, dev->name , ## arg)
 #define d2printk(fmt, arg...)	if (audio_debug > 1) \
 	printk(KERN_DEBUG "%s/audio: " fmt, dev->name, ## arg)
 
@@ -50,7 +58,7 @@ MODULE_PARM_DESC(audio_carrier,"audio ca
 		dev->name,(SAA7134_##reg),(#reg),saa_readb((SAA7134_##reg)))
 
 #define SCAN_INITIAL_DELAY  (HZ)
-#define SCAN_SAMPLE_DELAY   (HZ/10)
+#define SCAN_SAMPLE_DELAY   (HZ/5)
 
 /* ------------------------------------------------------------------ */
 /* saa7134 code                                                       */
@@ -186,8 +194,11 @@ static void mute_input_7134(struct saa71
 			in = &card(dev).mute;
 	}
 	if (dev->hw_mute  == mute &&
-	    dev->hw_input == in)
+	    dev->hw_input == in) {
+		dprintk("mute/input: nothing to do [mute=%d,input=%s]\n",
+			mute,in->name);
 		return;
+	}
 
 	dprintk("ctl_mute=%d automute=%d input=%s  =>  mute=%d input=%s\n",
 		dev->ctl_mute,dev->automute,dev->input->name,mute,in->name);
@@ -221,21 +232,27 @@ static void tvaudio_setmode(struct saa71
 			    struct saa7134_tvaudio *audio,
 			    char *note)
 {
-	if (note)
-		dprintk("tvaudio_setmode: %s %s [%d.%03d/%d.%03d MHz]\n",
-			note,audio->name,
-			audio->carr1 / 1000, audio->carr1 % 1000,
-			audio->carr2 / 1000, audio->carr2 % 1000);
+	int acpf, tweak = 0;
 
 	if (dev->tvnorm->id == V4L2_STD_NTSC) {
-		saa_writeb(SAA7134_AUDIO_CLOCKS_PER_FIELD0, 0xde);
-		saa_writeb(SAA7134_AUDIO_CLOCKS_PER_FIELD1, 0x15);
-		saa_writeb(SAA7134_AUDIO_CLOCKS_PER_FIELD2, 0x02);
+		acpf = 0x19066;
 	} else {
-		saa_writeb(SAA7134_AUDIO_CLOCKS_PER_FIELD0, 0x00);
-		saa_writeb(SAA7134_AUDIO_CLOCKS_PER_FIELD1, 0x80);
-		saa_writeb(SAA7134_AUDIO_CLOCKS_PER_FIELD2, 0x02);
+		acpf = 0x1e000;
 	}
+	if (audio_clock_tweak > -1024 && audio_clock_tweak < 1024)
+		tweak = audio_clock_tweak;
+
+	if (note)
+		dprintk("tvaudio_setmode: %s %s [%d.%03d/%d.%03d MHz] acpf=%d%+d\n",
+			note,audio->name,
+			audio->carr1 / 1000, audio->carr1 % 1000,
+			audio->carr2 / 1000, audio->carr2 % 1000,
+			acpf, tweak);
+
+	acpf += tweak;
+	saa_writeb(SAA7134_AUDIO_CLOCKS_PER_FIELD0, (acpf & 0x0000ff) >> 0);
+	saa_writeb(SAA7134_AUDIO_CLOCKS_PER_FIELD1, (acpf & 0x00ff00) >> 8);
+	saa_writeb(SAA7134_AUDIO_CLOCKS_PER_FIELD2, (acpf & 0x030000) >> 16);
 	tvaudio_setcarrier(dev,audio->carr1,audio->carr2);
 	
 	switch (audio->mode) {
@@ -259,18 +276,19 @@ static void tvaudio_setmode(struct saa71
 		saa_writeb(SAA7134_DCXO_IDENT_CTRL,           0x00);
 		saa_writeb(SAA7134_FM_DEEMPHASIS,             0x44);
 		saa_writeb(SAA7134_STEREO_DAC_OUTPUT_SELECT,  0xa1);
+		saa_writeb(SAA7134_NICAM_CONFIG,              0x00);
 		break;
 	case TVAUDIO_NICAM_AM:
 		saa_writeb(SAA7134_DEMODULATOR,               0x12);
 		saa_writeb(SAA7134_DCXO_IDENT_CTRL,           0x00);
 		saa_writeb(SAA7134_FM_DEEMPHASIS,             0x44);
 		saa_writeb(SAA7134_STEREO_DAC_OUTPUT_SELECT,  0xa1);
+		saa_writeb(SAA7134_NICAM_CONFIG,              0x00);
 		break;
 	case TVAUDIO_FM_SAT_STEREO:
 		/* not implemented (yet) */
 		break;
 	}
-	saa_writel(0x174 >> 2, 0x0001e000); /* FIXME */
 }
 
 static int tvaudio_sleep(struct saa7134_dev *dev, int timeout)
@@ -278,7 +296,7 @@ static int tvaudio_sleep(struct saa7134_
 	DECLARE_WAITQUEUE(wait, current);
 	
 	add_wait_queue(&dev->thread.wq, &wait);
-	current->state = TASK_INTERRUPTIBLE;
+	set_current_state(TASK_INTERRUPTIBLE);
 	schedule_timeout(timeout);
 	remove_wait_queue(&dev->thread.wq, &wait);
 	return dev->thread.scan1 != dev->thread.scan2;
@@ -437,7 +455,7 @@ static int tvaudio_thread(void *data)
 	const int *carr_scan;
 	int carr_vals[4];
 	unsigned int i, audio;
-	int max1,max2,carrier,rx,mode;
+	int max1,max2,carrier,rx,mode,lastmode;
 
 	lock_kernel();
 	daemonize("%s", dev->name);
@@ -535,7 +553,7 @@ static int tvaudio_thread(void *data)
 			if (UNSET == audio)
 				audio = i;
 			tvaudio_setmode(dev,&tvaudio[i],"trying");
-			if (tvaudio_sleep(dev,HZ))
+			if (tvaudio_sleep(dev,HZ*2))
 				goto restart;
 			if (-1 != tvaudio_getstereo(dev,&tvaudio[i])) {
 				audio = i;
@@ -549,8 +567,9 @@ static int tvaudio_thread(void *data)
 		tvaudio_setstereo(dev,&tvaudio[audio],V4L2_TUNER_MODE_MONO);
 		dev->tvaudio = &tvaudio[audio];
 
+		lastmode = 42;
 		for (;;) {
-			if (tvaudio_sleep(dev,3*HZ))
+			if (tvaudio_sleep(dev,5*HZ))
 				goto restart;
 			if (dev->thread.exit || signal_pending(current))
 				break;
@@ -560,7 +579,10 @@ static int tvaudio_thread(void *data)
 			} else {
 				mode = dev->thread.mode;
 			}
-			tvaudio_setstereo(dev,&tvaudio[audio],mode);
+			if (lastmode != mode) {
+				tvaudio_setstereo(dev,&tvaudio[audio],mode);
+				lastmode = mode;
+			}
 		}
 	}
 
@@ -602,8 +624,8 @@ static char *stdres[0x20] = {
 	[0x1f] = "??? [in progress]",
 };
 
-#define DSP_RETRY 30
-#define DSP_DELAY 10
+#define DSP_RETRY 32
+#define DSP_DELAY 16
 
 static inline int saa_dsp_wait_bit(struct saa7134_dev *dev, int bit)
 {
@@ -721,15 +743,34 @@ static int tvaudio_thread_ddep(void *dat
 		dev->thread.scan1 = dev->thread.scan2;
 		dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1);
 
-		norms = 0;
-		if (dev->tvnorm->id & V4L2_STD_PAL)
-			norms |= 0x2c; /* B/G + D/K + I */
-		if (dev->tvnorm->id & V4L2_STD_NTSC)
-			norms |= 0x40; /* M */
-		if (dev->tvnorm->id & V4L2_STD_SECAM)
-			norms |= 0x18; /* L + D/K */
-		if (0 == norms)
-			norms = 0x0000007c;
+		if (audio_ddep >= 0x04 && audio_ddep <= 0x0e) {
+			/* insmod option override */
+			norms = (audio_ddep << 2) | 0x01;
+			dprintk("ddep override: %s\n",stdres[audio_ddep]);
+		} else{
+			/* (let chip) scan for sound carrier */
+			norms = 0;
+			if (dev->tvnorm->id & V4L2_STD_PAL) {
+				dprintk("PAL scan\n");
+				norms |= 0x2c; /* B/G + D/K + I */
+			}
+			if (dev->tvnorm->id & V4L2_STD_NTSC) {
+				dprintk("NTSC scan\n");
+				norms |= 0x40; /* M */
+			}
+			if (dev->tvnorm->id & V4L2_STD_SECAM) {
+				dprintk("SECAM scan\n");
+				norms |= 0x18; /* L + D/K */
+			}
+			if (0 == norms)
+				norms = 0x7c; /* all */
+			dprintk("scanning:%s%s%s%s%s\n",
+				(norms & 0x04) ? " B/G"  : "",
+				(norms & 0x08) ? " D/K"  : "",
+				(norms & 0x10) ? " L/L'" : "",
+				(norms & 0x20) ? " I"    : "",
+				(norms & 0x40) ? " M"    : "");
+		}
 
 		/* quick & dirty -- to be fixed up later ... */
 		saa_dsp_writel(dev, 0x454 >> 2, 0);
@@ -856,17 +897,12 @@ int saa7134_tvaudio_init2(struct saa7134
 
 	/* enable I2S audio output */
 	if (saa7134_boards[dev->board].i2s_rate) {
-		int rate = (32000 == saa7134_boards[dev->board].i2s_rate)
-			? 0x01 : 0x03;
+		int i2sform = (32000 == saa7134_boards[dev->board].i2s_rate) ? 0x00 : 0x01;
 		
-		/* set rate */ 
-		saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, rate);
-
 		/* enable I2S output */
-		saa_writeb(SAA7134_DSP_OUTPUT_SELECT,  0x80);
-		saa_writeb(SAA7134_I2S_OUTPUT_SELECT,  0x80);
-		saa_writeb(SAA7134_I2S_OUTPUT_FORMAT,  0x01);
-		saa_writeb(SAA7134_I2S_OUTPUT_LEVEL,   0x00);	
+		saa_writeb(SAA7134_I2S_OUTPUT_SELECT,  0x80); 
+		saa_writeb(SAA7134_I2S_OUTPUT_FORMAT,  i2sform); 
+		saa_writeb(SAA7134_I2S_OUTPUT_LEVEL,   0x0F);	
 		saa_writeb(SAA7134_I2S_AUDIO_OUTPUT,   0x01);
 	}
 
diff -puN drivers/media/video/saa7134/saa7134-vbi.c~linus drivers/media/video/saa7134/saa7134-vbi.c
--- 25/drivers/media/video/saa7134/saa7134-vbi.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/saa7134/saa7134-vbi.c	2004-01-19 22:17:22.000000000 -0800
@@ -39,7 +39,7 @@ MODULE_PARM(vbibufs,"i");
 MODULE_PARM_DESC(vbibufs,"number of vbi buffers, range 2-32");
 
 #define dprintk(fmt, arg...)	if (vbi_debug) \
-	printk(KERN_DEBUG "%s/vbi: " fmt, dev->name, ## arg)
+	printk(KERN_DEBUG "%s/vbi: " fmt, dev->name , ## arg)
 
 /* ------------------------------------------------------------------ */
 
diff -puN drivers/media/video/saa7134/saa7134-video.c~linus drivers/media/video/saa7134/saa7134-video.c
--- 25/drivers/media/video/saa7134/saa7134-video.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/saa7134/saa7134-video.c	2004-01-19 22:17:22.000000000 -0800
@@ -40,7 +40,7 @@ MODULE_PARM(gbuffers,"i");
 MODULE_PARM_DESC(gbuffers,"number of capture buffers, range 2-32");
 
 #define dprintk(fmt, arg...)	if (video_debug) \
-	printk(KERN_DEBUG "%s/video: " fmt, dev->name, ## arg)
+	printk(KERN_DEBUG "%s/video: " fmt, dev->name , ## arg)
 
 /* ------------------------------------------------------------------ */
 /* data structs for video                                             */
@@ -83,6 +83,12 @@ static struct saa7134_format formats[] =
 		.depth    = 24,
 		.pm       = 0x11,
 	},{
+		.name     = "24 bpp RGB, be",
+		.fourcc   = V4L2_PIX_FMT_RGB24,
+		.depth    = 24,
+		.pm       = 0x11,
+		.bswap    = 1,
+	},{
 		.name     = "32 bpp RGB, le",
 		.fourcc   = V4L2_PIX_FMT_BGR32,
 		.depth    = 32,
@@ -125,6 +131,16 @@ static struct saa7134_format formats[] =
 		.planar   = 1,
 		.hshift   = 1,
 		.vshift   = 1,
+	},{
+		.name     = "4:2:0 planar, Y-Cb-Cr",
+		.fourcc   = V4L2_PIX_FMT_YVU420,
+		.depth    = 12,
+		.pm       = 0x0a,
+		.yuv      = 1,
+		.planar   = 1,
+		.uvswap   = 1,
+		.hshift   = 1,
+		.vshift   = 1,
 	}
 };
 #define FORMATS ARRAY_SIZE(formats)
@@ -788,7 +804,7 @@ static int buffer_activate(struct saa713
 			   struct saa7134_buf *next)
 {
 	unsigned long base,control,bpl;
-	unsigned long bpl_uv,lines_uv,base2,base3; /* planar */
+	unsigned long bpl_uv,lines_uv,base2,base3,tmp; /* planar */
 
 	dprintk("buffer_activate buf=%p\n",buf);
 	buf->vb.state = STATE_ACTIVE;
@@ -834,6 +850,8 @@ static int buffer_activate(struct saa713
 		lines_uv = buf->vb.height >> buf->fmt->vshift;
 		base2    = base + bpl * buf->vb.height;
 		base3    = base2 + bpl_uv * lines_uv;
+		if (buf->fmt->uvswap)
+			tmp = base2, base2 = base3, base3 = tmp;
 		dprintk("uv: bpl=%ld lines=%ld base2/3=%ld/%ld\n",
 			bpl_uv,lines_uv,base2,base3);
 		if (V4L2_FIELD_HAS_BOTH(buf->vb.field)) {
@@ -1160,6 +1178,9 @@ static int video_open(struct inode *inod
 	fh->fmt      = format_by_fourcc(V4L2_PIX_FMT_BGR24);
 	fh->width    = 768;
 	fh->height   = 576;
+#ifdef VIDIOC_G_PRIORITY
+	v4l2_prio_open(&dev->prio,&fh->prio);
+#endif
 
 	videobuf_queue_init(&fh->cap, &video_qops,
 			    dev->pci, &dev->slock,
@@ -1268,7 +1289,7 @@ static int video_release(struct inode *i
 
 	/* stop video capture */
 	if (res_check(fh, RESOURCE_VIDEO)) {
-		videobuf_queue_cancel(file,&fh->cap);
+		videobuf_streamoff(file,&fh->cap);
 		res_free(dev,fh,RESOURCE_VIDEO);
 	}
 	if (fh->cap.read_buf) {
@@ -1287,7 +1308,10 @@ static int video_release(struct inode *i
 
 	saa7134_pgtable_free(dev->pci,&fh->pt_cap);
 	saa7134_pgtable_free(dev->pci,&fh->pt_vbi);
-	
+
+#ifdef VIDIOC_G_PRIORITY
+	v4l2_prio_close(&dev->prio,&fh->prio);
+#endif
 	file->private_data = NULL;
 	kfree(fh);
 	return 0;
@@ -1568,6 +1592,20 @@ static int video_do_ioctl(struct inode *
 
 	if (video_debug > 1)
 		saa7134_print_ioctl(dev->name,cmd);
+
+#ifdef VIDIOC_G_PRIORITY
+	switch (cmd) {
+	case VIDIOC_S_CTRL:
+	case VIDIOC_S_STD:
+	case VIDIOC_S_INPUT:
+	case VIDIOC_S_TUNER:
+	case VIDIOC_S_FREQUENCY:
+		err = v4l2_prio_check(&dev->prio,&fh->prio);
+		if (0 != err)
+			return err;
+	}
+#endif
+
 	switch (cmd) {
 	case VIDIOC_QUERYCAP:
 	{
@@ -1697,6 +1735,7 @@ static int video_do_ioctl(struct inode *
 		down(&dev->lock);
 		dev->ctl_freq = f->frequency;
 		saa7134_i2c_call_clients(dev,VIDIOCSFREQ,&dev->ctl_freq);
+		saa7134_tvaudio_do_scan(dev);
 		up(&dev->lock);
 		return 0;
 	}
@@ -1727,6 +1766,22 @@ static int video_do_ioctl(struct inode *
                 return 0;
         }
 
+#ifdef VIDIOC_G_PRIORITY
+        case VIDIOC_G_PRIORITY:
+        {
+                enum v4l2_priority *p = arg;
+
+                *p = v4l2_prio_max(&dev->prio);
+                return 0;
+        }
+        case VIDIOC_S_PRIORITY:
+        {
+                enum v4l2_priority *prio = arg;
+
+                return v4l2_prio_change(&dev->prio, &fh->prio, *prio);
+        }
+#endif
+
 	/* --- preview ioctls ---------------------------------------- */
 	case VIDIOC_ENUM_FMT:
 	{
@@ -2148,8 +2203,8 @@ void saa7134_irq_video_done(struct saa71
 	
 	spin_lock(&dev->slock);
 	if (dev->video_q.curr) {
+		dev->video_fieldcount++;
 		field = dev->video_q.curr->vb.field;
-		
 		if (V4L2_FIELD_HAS_BOTH(field)) {
 			/* make sure we have seen both fields */
 			if ((status & 0x10) == 0x00) {
@@ -2165,6 +2220,7 @@ void saa7134_irq_video_done(struct saa71
 			if ((status & 0x10) != 0x00)
 				goto done;
 		}
+		dev->video_q.curr->vb.field_count = dev->video_fieldcount;
 		saa7134_buffer_finish(dev,&dev->video_q,STATE_DONE);
 	}
 	saa7134_buffer_next(dev,&dev->video_q);
diff -puN drivers/media/video/saa7146.h~linus drivers/media/video/saa7146.h
--- 25/drivers/media/video/saa7146.h~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/saa7146.h	2004-01-19 22:17:22.000000000 -0800
@@ -25,7 +25,6 @@
 #include <linux/types.h>
 #include <linux/wait.h>
 
-#include <linux/i2c.h>
 #include <linux/videodev.h>
 
 #ifndef O_NONCAP  
diff -puN drivers/media/video/tda7432.c~linus drivers/media/video/tda7432.c
--- 25/drivers/media/video/tda7432.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/tda7432.c	2004-01-19 22:17:22.000000000 -0800
@@ -338,8 +338,13 @@ static int tda7432_attach(struct i2c_ada
 
 static int tda7432_probe(struct i2c_adapter *adap)
 {
+#ifdef I2C_ADAP_CLASS_TV_ANALOG
 	if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
 		return i2c_probe(adap, &addr_data, tda7432_attach);
+#else
+	if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848))
+		return i2c_probe(adap, &addr_data, tda7432_attach);
+#endif
 	return 0;
 }
 
diff -puN drivers/media/video/tda9875.c~linus drivers/media/video/tda9875.c
--- 25/drivers/media/video/tda9875.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/tda9875.c	2004-01-19 22:17:22.000000000 -0800
@@ -272,8 +272,13 @@ static int tda9875_attach(struct i2c_ada
 
 static int tda9875_probe(struct i2c_adapter *adap)
 {
+#ifdef I2C_ADAP_CLASS_TV_ANALOG
 	if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
 		return i2c_probe(adap, &addr_data, tda9875_attach);
+#else
+	if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848))
+		return i2c_probe(adap, &addr_data, tda9875_attach);
+#endif
 	return 0;
 }
 
diff -puN drivers/media/video/tda9887.c~linus drivers/media/video/tda9887.c
--- 25/drivers/media/video/tda9887.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/tda9887.c	2004-01-19 22:17:22.000000000 -0800
@@ -169,7 +169,7 @@ static int tda9887_miro(struct tda9887 *
 		bDeEmphVal   = cDeemphasis50;
 		bModulation  = cNegativeFmTV;
 		bOutPort1    = cOutputPort1Inactive;
-		if (1 == t->pinnacle_id) {
+		if ((1 == t->pinnacle_id) || (7 == t->pinnacle_id)) {
 			bCarrierMode = cIntercarrier;
 		} else {
 			// stereo boards
@@ -366,8 +366,18 @@ static int tda9887_attach(struct i2c_ada
 
 static int tda9887_probe(struct i2c_adapter *adap)
 {
+#ifdef I2C_ADAP_CLASS_TV_ANALOG
 	if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
 		return i2c_probe(adap, &addr_data, tda9887_attach);
+#else
+	switch (adap->id) {
+	case I2C_ALGO_BIT | I2C_HW_B_BT848:
+	case I2C_ALGO_BIT | I2C_HW_B_RIVA:
+	case I2C_ALGO_SAA7134:
+		return i2c_probe(adap, &addr_data, tda9887_attach);
+		break;
+	}
+#endif
 	return 0;
 }
 
@@ -439,9 +449,9 @@ static struct i2c_driver driver = {
 };
 static struct i2c_client client_template =
 {
-	.flags  = I2C_CLIENT_ALLOW_USE,
-        .driver = &driver,
-	.name	= "tda9887",
+	I2C_DEVNAME("tda9887"),
+	.flags     = I2C_CLIENT_ALLOW_USE,
+        .driver    = &driver,
 };
 
 static int tda9887_init_module(void)
diff -puN drivers/media/video/tuner.c~linus drivers/media/video/tuner.c
--- 25/drivers/media/video/tuner.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/tuner.c	2004-01-19 22:17:22.000000000 -0800
@@ -45,18 +45,21 @@ MODULE_LICENSE("GPL");
 static int this_adap;
 #define dprintk     if (debug) printk
 
-struct tuner
-{
+struct tuner {
 	unsigned int type;            /* chip type */
 	unsigned int freq;            /* keep track of the current settings */
 	unsigned int std;
 	
 	unsigned int radio;
 	unsigned int mode;            /* current norm for multi-norm tuners */
+	unsigned int input;
 	
 	// only for MT2032
 	unsigned int xogc;
 	unsigned int radio_if2;
+
+	void (*tv_freq)(struct i2c_client *c, unsigned int freq);
+	void (*radio_freq)(struct i2c_client *c, unsigned int freq);
 };
 
 static struct i2c_driver driver;
@@ -207,7 +210,7 @@ static struct tunertype tuners[] = {
 
 	{ "Samsung PAL TCPM9091PD27", Samsung, PAL,  /* from sourceforge v3tv */
           16*169,16*464,0xA0,0x90,0x30,0x8e,623},
-	{ "MT2032 universal", Microtune,PAL|NTSC,
+	{ "MT20xx universal", Microtune,PAL|NTSC,
                0,0,0,0,0,0,0},
 	{ "Temic PAL_BG (4106 FH5)", TEMIC, PAL,
           16*141.00, 16*464.00, 0xa0,0x90,0x30,0x8e,623},
@@ -225,6 +228,12 @@ static struct tunertype tuners[] = {
 
 	{ "HITACHI V7-J180AT", HITACHI, NTSC,
 	  16*170.00, 16*450.00, 0x01,0x02,0x00,0x8e,940 },
+	{ "Philips PAL_MK (FI1216 MK)", Philips, PAL,
+	  16*140.25,16*463.25,0x01,0xc2,0xcf,0x8e,623},
+	{ "Philips 1236D ATSC/NTSC daul in",Philips,ATSC,
+	  16*157.25,16*454.00,0xa0,0x90,0x30,0x8e,732},
+        { "Philips NTSC MK3 (FM1236MK3 or FM1236/F)", Philips, NTSC,
+          16*160.00,16*442.00,0x01,0x02,0x04,0x8,732},
 };
 #define TUNERS ARRAY_SIZE(tuners)
 
@@ -279,86 +288,19 @@ static int tuner_mode (struct i2c_client
 }
 #endif
 
-// Initalization as described in "MT203x Programming Procedures", Rev 1.2, Feb.2001
-static int mt2032_init(struct i2c_client *c)
-{
-        unsigned char buf[21];
-        int ret,xogc,xok=0;
-	struct tuner *t = i2c_get_clientdata(c);
-
-        buf[0]=0;
-        ret=i2c_master_send(c,buf,1);
-        i2c_master_recv(c,buf,21);
-
-        printk("MT2032: Companycode=%02x%02x Part=%02x Revision=%02x\n",
-                buf[0x11],buf[0x12],buf[0x13],buf[0x14]);
-
-        if(debug) {
-                int i;
-                printk("MT2032 hexdump:\n");
-                for(i=0;i<21;i++) {
-                        printk(" %02x",buf[i]);
-                        if(((i+1)%8)==0) printk(" ");
-                        if(((i+1)%16)==0) printk("\n ");
-                }
-                printk("\n ");
-        }
-	// Look for MT2032 id:
-	// part= 0x04(MT2032), 0x06(MT2030), 0x07(MT2040)
-        if((buf[0x11] != 0x4d) || (buf[0x12] != 0x54) || (buf[0x13] != 0x04)) {
-                printk("not a MT2032.\n");
-                return 0;
-        }
-
-
-        // Initialize Registers per spec.
-        buf[1]=2; // Index to register 2
-        buf[2]=0xff;
-        buf[3]=0x0f;
-        buf[4]=0x1f;
-        ret=i2c_master_send(c,buf+1,4);
-
-        buf[5]=6; // Index register 6
-        buf[6]=0xe4;
-        buf[7]=0x8f;
-        buf[8]=0xc3;
-        buf[9]=0x4e;
-        buf[10]=0xec;
-        ret=i2c_master_send(c,buf+5,6);
-
-        buf[12]=13;  // Index register 13
-        buf[13]=0x32;
-        ret=i2c_master_send(c,buf+12,2);
-
-        // Adjust XOGC (register 7), wait for XOK
-        xogc=7;
-        do {
-		dprintk("mt2032: xogc = 0x%02x\n",xogc&0x07);
-                mdelay(10);
-                buf[0]=0x0e;
-                i2c_master_send(c,buf,1);
-                i2c_master_recv(c,buf,1);
-                xok=buf[0]&0x01;
-                dprintk("mt2032: xok = 0x%02x\n",xok);
-                if (xok == 1) break;
-
-                xogc--;
-                dprintk("mt2032: xogc = 0x%02x\n",xogc&0x07);
-                if (xogc == 3) {
-                        xogc=4; // min. 4 per spec
-                        break;
-                }
-                buf[0]=0x07;
-                buf[1]=0x88 + xogc;
-                ret=i2c_master_send(c,buf,2);
-                if (ret!=2)
-                        printk("mt2032_init failed with %d\n",ret);
-        } while (xok != 1 );
-	t->xogc=xogc;
-
-        return(1);
-}
+/* ---------------------------------------------------------------------- */
 
+#define MT2032 0x04
+#define MT2030 0x06
+#define MT2040 0x07
+#define MT2050 0x42
+
+static char *microtune_part[] = {
+	[ MT2030 ] = "MT2030",
+	[ MT2032 ] = "MT2032",
+	[ MT2040 ] = "MT2040",
+	[ MT2050 ] = "MT2050",
+};
 
 // IsSpurInBand()?
 static int mt2032_spurcheck(int f1, int f2, int spectrum_from,int spectrum_to)
@@ -583,13 +525,13 @@ static void mt2032_set_if_freq(struct i2
 }
 
 
-static void mt2032_set_tv_freq(struct i2c_client *c,
-			       unsigned int freq, unsigned int norm)
+static void mt2032_set_tv_freq(struct i2c_client *c, unsigned int freq)
 {
+	struct tuner *t = i2c_get_clientdata(c);
 	int if2,from,to;
 
 	// signal bandwidth and picture carrier
-	if (norm==VIDEO_MODE_NTSC) {
+	if (t->mode == VIDEO_MODE_NTSC) {
 		from=40750*1000;
 		to=46750*1000;
 		if2=45750*1000; 
@@ -604,36 +546,248 @@ static void mt2032_set_tv_freq(struct i2
 			   1090*1000*1000, if2, from, to);
 }
 
+static void mt2032_set_radio_freq(struct i2c_client *c, unsigned int freq)
+{
+	struct tuner *t = i2c_get_clientdata(c);
+	int if2 = t->radio_if2;
 
-// Set tuner frequency,  freq in Units of 62.5kHz = 1/16MHz
-static void set_tv_freq(struct i2c_client *c, unsigned int freq)
+	// per Manual for FM tuning: first if center freq. 1085 MHz
+        mt2032_set_if_freq(c, freq*62500 /* freq*1000*1000/16 */,
+			   1085*1000*1000,if2,if2,if2);
+}
+
+// Initalization as described in "MT203x Programming Procedures", Rev 1.2, Feb.2001
+static int mt2032_init(struct i2c_client *c)
 {
-	u8 config;
-	u16 div;
-	struct tunertype *tun;
 	struct tuner *t = i2c_get_clientdata(c);
-        unsigned char buffer[4];
-	int rc;
+        unsigned char buf[21];
+        int ret,xogc,xok=0;
 
-	if (t->type == UNSET) {
-		printk("tuner: tuner type not set\n");
-		return;
-	}
-	if (t->type == TUNER_MT2032) {
-		mt2032_set_tv_freq(c,freq,t->mode);
-		return;
+	// Initialize Registers per spec.
+        buf[1]=2; // Index to register 2
+        buf[2]=0xff;
+        buf[3]=0x0f;
+        buf[4]=0x1f;
+        ret=i2c_master_send(c,buf+1,4);
+
+        buf[5]=6; // Index register 6
+        buf[6]=0xe4;
+        buf[7]=0x8f;
+        buf[8]=0xc3;
+        buf[9]=0x4e;
+        buf[10]=0xec;
+        ret=i2c_master_send(c,buf+5,6);
+
+        buf[12]=13;  // Index register 13
+        buf[13]=0x32;
+        ret=i2c_master_send(c,buf+12,2);
+
+        // Adjust XOGC (register 7), wait for XOK
+        xogc=7;
+        do {
+		dprintk("mt2032: xogc = 0x%02x\n",xogc&0x07);
+                mdelay(10);
+                buf[0]=0x0e;
+                i2c_master_send(c,buf,1);
+                i2c_master_recv(c,buf,1);
+                xok=buf[0]&0x01;
+                dprintk("mt2032: xok = 0x%02x\n",xok);
+                if (xok == 1) break;
+
+                xogc--;
+                dprintk("mt2032: xogc = 0x%02x\n",xogc&0x07);
+                if (xogc == 3) {
+                        xogc=4; // min. 4 per spec
+                        break;
+                }
+                buf[0]=0x07;
+                buf[1]=0x88 + xogc;
+                ret=i2c_master_send(c,buf,2);
+                if (ret!=2)
+                        printk("mt2032_init failed with %d\n",ret);
+        } while (xok != 1 );
+	t->xogc=xogc;
+
+	t->tv_freq    = mt2032_set_tv_freq;
+	t->radio_freq = mt2032_set_radio_freq;
+        return(1);
+}
+
+static void mt2050_set_if_freq(struct i2c_client *c,unsigned int freq, unsigned int if2)
+{
+	unsigned int if1=1218*1000*1000;
+	unsigned int f_lo1,f_lo2,lo1,lo2,f_lo1_modulo,f_lo2_modulo,num1,num2,div1a,div1b,div2a,div2b;
+	int ret;
+	unsigned char buf[6];
+	
+	dprintk("mt2050_set_if_freq freq=%d\n",freq);
+	
+	f_lo1=freq+if1;
+	f_lo1=(f_lo1/1000000)*1000000;
+	
+	f_lo2=f_lo1-freq-if2;
+	f_lo2=(f_lo2/50000)*50000;
+	
+	lo1=f_lo1/4000000;
+	lo2=f_lo2/4000000;
+	
+	f_lo1_modulo= f_lo1-(lo1*4000000);
+	f_lo2_modulo= f_lo2-(lo2*4000000);
+	
+	num1=4*f_lo1_modulo/4000000;
+	num2=4096*(f_lo2_modulo/1000)/4000;
+	
+	// todo spurchecks
+	
+	div1a=(lo1/12)-1;
+	div1b=lo1-(div1a+1)*12;
+	
+	div2a=(lo2/8)-1;
+	div2b=lo2-(div2a+1)*8;
+	
+	dprintk("lo1 lo2 = %d %d\n", lo1, lo2);
+        dprintk("num1 num2 div1a div1b div2a div2b= %x %x %x %x %x %x\n",num1,num2,div1a,div1b,div2a,div2b);
+	
+	
+	buf[0]=1;
+	buf[1]= 4*div1b + num1;
+	if(freq<275*1000*1000) buf[1] = buf[1]|0x80;
+	
+	buf[2]=div1a;
+	buf[3]=32*div2b + num2/256;
+	buf[4]=num2-(num2/256)*256;
+	buf[5]=div2a;
+	if(num2!=0) buf[5]=buf[5]|0x40;
+	
+	if(debug) {
+		int i;
+		printk("bufs is: ");
+		for(i=0;i<6;i++)
+			printk("%x ",buf[i]);
+		printk("\n");
 	}
+	
+	ret=i2c_master_send(c,buf,6);
+        if (ret!=6)
+                printk("mt2050_set_if_freq failed with %d\n",ret);
+}
 
-	if (freq < tv_range[0]*16 || freq > tv_range[1]*16) {
-		/* FIXME: better do that chip-specific, but
-		   right now we don't have that in the config
-		   struct and this way is still better than no
-		   check at all */
-		printk("tuner: TV freq (%d.%02d) out of range (%d-%d)\n",
-		       freq/16,freq%16*100/16,tv_range[0],tv_range[1]);
-		return;
+static void mt2050_set_tv_freq(struct i2c_client *c, unsigned int freq)
+{
+	struct tuner *t = i2c_get_clientdata(c);
+	unsigned int if2;
+	
+	if (t->mode == VIDEO_MODE_NTSC) {
+                if2=45750*1000;
+        } else {
+                // Pal
+                if2=38900*1000;
+        }
+	mt2050_set_if_freq(c,freq*62500,if2);
+}
+
+static void mt2050_set_radio_freq(struct i2c_client *c, unsigned int freq)
+{
+	struct tuner *t = i2c_get_clientdata(c);
+	int if2 = t->radio_if2;
+	
+	mt2050_set_if_freq(c, freq*62500, if2);
+}
+
+static int mt2050_init(struct i2c_client *c)
+{
+	struct tuner *t = i2c_get_clientdata(c);
+	unsigned char buf[2];
+	int ret;
+	
+	buf[0]=6;
+	buf[1]=0x10;
+	ret=i2c_master_send(c,buf,2); //  power
+	
+	buf[0]=0x0f;
+	buf[1]=0x0f;
+	ret=i2c_master_send(c,buf,2); // m1lo
+	
+	buf[0]=0x0d;
+	ret=i2c_master_send(c,buf,1);
+	i2c_master_recv(c,buf,1);
+	
+	dprintk("mt2050: sro is %x\n",buf[0]);
+	t->tv_freq    = mt2050_set_tv_freq;
+	t->radio_freq = mt2050_set_radio_freq;
+	return 0;
+}
+
+static int microtune_init(struct i2c_client *c)
+{
+	struct tuner *t = i2c_get_clientdata(c);
+	char *name;
+        unsigned char buf[21];
+	int company_code;
+	
+        buf[0] = 0;
+	t->tv_freq = NULL;
+	t->radio_freq = NULL;
+	name = "unknown";
+
+        i2c_master_send(c,buf,1);
+        i2c_master_recv(c,buf,21);
+        if(debug) {
+                int i;
+                printk(KERN_DEBUG "tuner: MT2032 hexdump:\n");
+                for(i=0;i<21;i++) {
+                        printk(" %02x",buf[i]);
+                        if(((i+1)%8)==0) printk(" ");
+                        if(((i+1)%16)==0) printk("\n ");
+                }
+                printk("\n ");
+        }
+	company_code = buf[0x11] << 8 | buf[0x12];
+        printk("tuner: microtune: companycode=%04x part=%02x rev=%02x\n",
+	       company_code,buf[0x13],buf[0x14]);
+	switch (company_code) {
+	case 0x3cbf:
+	case 0x3dbf:
+	case 0x4d54:
+	case 0x8e81:
+	case 0x8e91:
+		/* ok (?) */
+		break;
+	default:
+		printk("tuner: microtune: unknown companycode\n");
+		return 0;
 	}
 
+	if (buf[0x13] < ARRAY_SIZE(microtune_part) &&
+	    NULL != microtune_part[buf[0x13]])
+		name = microtune_part[buf[0x13]];
+	switch (buf[0x13]) {
+	case MT2032:
+		mt2032_init(c);
+		break;
+	case MT2050:
+		mt2050_init(c);
+		break;
+	default:
+		printk("tuner: microtune %s found, not (yet?) supported, sorry :-/\n",
+		       name);
+                return 0;
+        }
+	printk("tuner: microtune %s found, OK\n",name);
+	return 0;
+}
+
+/* ---------------------------------------------------------------------- */
+
+static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
+{
+	struct tuner *t = i2c_get_clientdata(c);
+	u8 config;
+	u16 div;
+	struct tunertype *tun;
+        unsigned char buffer[4];
+	int rc;
+
 	tun=&tuners[t->type];
 	if (freq < tun->thresh1) 
 		config = tun->VHF_L;
@@ -700,6 +854,20 @@ static void set_tv_freq(struct i2c_clien
 			break;
 		}
 		break;
+
+	case TUNER_PHILIPS_ATSC:
+		/* 0x00 -> ATSC antenna input 1 */
+		/* 0x01 -> ATSC antenna input 2 */
+		/* 0x02 -> NTSC antenna input 1 */
+		/* 0x03 -> NTSC antenna input 2 */
+		
+		config &= ~0x03;
+#ifdef VIDEO_MODE_ATSC
+		if (VIDEO_MODE_ATSC != t->mode)
+			config |= 2;
+#endif
+		/* FIXME: input */
+		break;
 	}
 
 	
@@ -737,17 +905,7 @@ static void set_tv_freq(struct i2c_clien
 
 }
 
-static void mt2032_set_radio_freq(struct i2c_client *c, unsigned int freq)
-{
-	struct tuner *t = i2c_get_clientdata(c);
-	int if2 = t->radio_if2;
-
-	// per Manual for FM tuning: first if center freq. 1085 MHz
-        mt2032_set_if_freq(c, freq*62500 /* freq*1000*1000/16 */,
-			   1085*1000*1000,if2,if2,if2);
-}
-
-static void set_radio_freq(struct i2c_client *c, unsigned int freq)
+static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
 {
 	struct tunertype *tun;
 	struct tuner *t = i2c_get_clientdata(c);
@@ -755,22 +913,6 @@ static void set_radio_freq(struct i2c_cl
 	unsigned div;
 	int rc;
 
-	if (freq < radio_range[0]*16 || freq > radio_range[1]*16) {
-		printk("tuner: radio freq (%d.%02d) out of range (%d-%d)\n",
-		       freq/16,freq%16*100/16,
-		       radio_range[0],radio_range[1]);
-		return;
-	}
-	if (t->type == UNSET) {
-		printk("tuner: tuner type not set\n");
-		return;
-	}
-
-        if (t->type == TUNER_MT2032) {
-                mt2032_set_radio_freq(c,freq);
-		return;
-	}
-
 	tun=&tuners[t->type];
 	div = freq + (int)(16*10.7);
         buffer[0] = (div>>8) & 0x7f;
@@ -778,6 +920,7 @@ static void set_radio_freq(struct i2c_cl
 	buffer[2] = tun->config;
 	switch (t->type) {
 	case TUNER_PHILIPS_FM1216ME_MK3:
+	case TUNER_PHILIPS_FM1236_MK3:
 		buffer[3] = 0x19;
 		break;
 	default:
@@ -794,6 +937,80 @@ static void set_radio_freq(struct i2c_cl
 
 /* ---------------------------------------------------------------------- */
 
+// Set tuner frequency,  freq in Units of 62.5kHz = 1/16MHz
+static void set_tv_freq(struct i2c_client *c, unsigned int freq)
+{
+	struct tuner *t = i2c_get_clientdata(c);
+
+	if (t->type == UNSET) {
+		printk("tuner: tuner type not set\n");
+		return;
+	}
+	if (NULL == t->tv_freq) {
+		printk("tuner: Huh? tv_set is NULL?\n");
+		return;
+	}
+	if (freq < tv_range[0]*16 || freq > tv_range[1]*16) {
+		/* FIXME: better do that chip-specific, but
+		   right now we don't have that in the config
+		   struct and this way is still better than no
+		   check at all */
+		printk("tuner: TV freq (%d.%02d) out of range (%d-%d)\n",
+		       freq/16,freq%16*100/16,tv_range[0],tv_range[1]);
+		return;
+	}
+	t->tv_freq(c,freq);
+}
+
+static void set_radio_freq(struct i2c_client *c, unsigned int freq)
+{
+	struct tuner *t = i2c_get_clientdata(c);
+
+	if (t->type == UNSET) {
+		printk("tuner: tuner type not set\n");
+		return;
+	}
+	if (NULL == t->radio_freq) {
+		printk("tuner: no radio tuning for this one, sorry.\n");
+		return;
+	}
+	if (freq < radio_range[0]*16 || freq > radio_range[1]*16) {
+		printk("tuner: radio freq (%d.%02d) out of range (%d-%d)\n",
+		       freq/16,freq%16*100/16,
+		       radio_range[0],radio_range[1]);
+		return;
+	}
+	t->radio_freq(c,freq);
+}
+
+static void set_type(struct i2c_client *c, unsigned int type)
+{
+	struct tuner *t = i2c_get_clientdata(c);
+
+	if (t->type != UNSET) {
+		printk("tuner: type already set (%d)\n",t->type);
+		return;
+	}
+	if (type >= TUNERS)
+		return;
+
+	t->type = type;
+	printk("tuner: type set to %d (%s)\n", t->type,tuners[t->type].name);
+	strlcpy(c->name, tuners[t->type].name, sizeof(c->name));
+
+	switch (t->type) {
+	case TUNER_MT2032:
+		microtune_init(c);
+		break;
+	default:
+		t->tv_freq    = default_set_tv_freq;
+		t->radio_freq = default_set_radio_freq;
+		break;
+	}
+}
+
+/* ---------------------------------------------------------------------- */
+
 static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
 {
 	struct tuner *t;
@@ -821,15 +1038,12 @@ static int tuner_attach(struct i2c_adapt
 	t->type       = UNSET;
 	t->radio_if2  = 10700*1000; // 10.7MHz - FM radio
 
+        i2c_attach_client(client);
 	if (type < TUNERS) {
-		t->type = type;
-		printk("tuner(bttv): type forced to %d (%s) [insmod]\n",t->type,tuners[t->type].name);
-		strlcpy(client->name, tuners[t->type].name, I2C_NAME_SIZE);
+		printk("tuner: type forced to %d (%s) [insmod]\n",
+		       t->type,tuners[t->type].name);
+		set_type(client,type);
 	}
-        i2c_attach_client(client);
-        if (t->type == TUNER_MT2032)
-                 mt2032_init(client);
-
 	return 0;
 }
 
@@ -841,8 +1055,19 @@ static int tuner_probe(struct i2c_adapte
 	}
 	this_adap = 0;
 
+#ifdef I2C_ADAP_CLASS_TV_ANALOG
 	if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
 		return i2c_probe(adap, &addr_data, tuner_attach);
+#else
+	switch (adap->id) {
+	case I2C_ALGO_BIT | I2C_HW_B_BT848:
+	case I2C_ALGO_BIT | I2C_HW_B_RIVA:
+	case I2C_ALGO_SAA7134:
+	case I2C_ALGO_SAA7146:
+		return i2c_probe(adap, &addr_data, tuner_attach);
+		break;
+	}
+#endif
 	return 0;
 }
 
@@ -866,21 +1091,13 @@ tuner_command(struct i2c_client *client,
 
 	/* --- configuration --- */
 	case TUNER_SET_TYPE:
-		if (t->type != UNSET) {
-			printk("tuner: type already set (%d)\n",t->type);
-			return 0;
-		}
-		if (*iarg >= TUNERS)
-			return 0;
-		t->type = *iarg;
-		printk("tuner: type set to %d (%s)\n",
-                        t->type,tuners[t->type].name);
-		strlcpy(client->name, tuners[t->type].name, I2C_NAME_SIZE);
-		if (t->type == TUNER_MT2032)
-                        mt2032_init(client);
+		set_type(client,*iarg);
 		break;
 	case AUDC_SET_RADIO:
-		t->radio = 1;
+		if (!t->radio) {
+			set_tv_freq(client,400 * 16);
+			t->radio = 1;
+		}
 		break;
 	case AUDC_CONFIG_PINNACLE:
 		switch (*iarg) {
@@ -913,12 +1130,12 @@ tuner_command(struct i2c_client *client,
 		unsigned long *v = arg;
 
 		if (t->radio) {
-			dprintk("tuner: radio freq set to %d.%02d\n",
-				(*iarg)/16,(*iarg)%16*100/16);
+			dprintk("tuner: radio freq set to %lu.%02lu\n",
+				(*v)/16,(*v)%16*100/16);
 			set_radio_freq(client,*v);
 		} else {
-			dprintk("tuner: tv freq set to %d.%02d\n",
-				(*iarg)/16,(*iarg)%16*100/16);
+			dprintk("tuner: tv freq set to %lu.%02lu\n",
+				(*v)/16,(*v)%16*100/16);
 			set_tv_freq(client,*v);
 		}
 		t->freq = *v;
@@ -960,9 +1177,9 @@ static struct i2c_driver driver = {
 };
 static struct i2c_client client_template =
 {
-	.flags  = I2C_CLIENT_ALLOW_USE,
-	.driver = &driver,
-	.name   = "(tuner unset)",
+	I2C_DEVNAME("(tuner unset)"),
+	.flags      = I2C_CLIENT_ALLOW_USE,
+        .driver     = &driver,
 };
 
 static int tuner_init_module(void)
diff -puN drivers/media/video/tvaudio.c~linus drivers/media/video/tvaudio.c
--- 25/drivers/media/video/tvaudio.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/tvaudio.c	2004-01-19 22:17:22.000000000 -0800
@@ -1420,6 +1420,7 @@ static int chip_attach(struct i2c_adapte
 {
 	struct CHIPSTATE *chip;
 	struct CHIPDESC  *desc;
+	int rc;
 
 	chip = kmalloc(sizeof(*chip),GFP_KERNEL);
 	if (!chip)
@@ -1487,8 +1488,12 @@ static int chip_attach(struct i2c_adapte
 		chip->wt.function = chip_thread_wake;
 		chip->wt.data     = (unsigned long)chip;
 		init_waitqueue_head(&chip->wq);
-		kernel_thread(chip_thread,(void *)chip,0);
-		down(&sem);
+		rc = kernel_thread(chip_thread,(void *)chip,0);
+		if (rc < 0)
+			printk(KERN_WARNING "%s: kernel_thread() failed\n",
+			       i2c_clientname(&chip->c));
+		else
+			down(&sem);
 		chip->notify = NULL;
 		wake_up_interruptible(&chip->wq);
 	}
@@ -1497,8 +1502,17 @@ static int chip_attach(struct i2c_adapte
 
 static int chip_probe(struct i2c_adapter *adap)
 {
+#ifdef I2C_ADAP_CLASS_TV_ANALOG
 	if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
 		return i2c_probe(adap, &addr_data, chip_attach);
+#else
+	switch (adap->id) {
+	case I2C_ALGO_BIT | I2C_HW_B_BT848:
+	case I2C_ALGO_BIT | I2C_HW_B_RIVA:
+	case I2C_ALGO_SAA7134:
+		return i2c_probe(adap, &addr_data, chip_attach);
+	}
+#endif
 	return 0;
 }
 
diff -puN drivers/media/video/tvmixer.c~linus drivers/media/video/tvmixer.c
--- 25/drivers/media/video/tvmixer.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/tvmixer.c	2004-01-19 22:17:22.000000000 -0800
@@ -190,6 +190,10 @@ static int tvmixer_open(struct inode *in
 
 	/* lock bttv in memory while the mixer is in use  */
 	file->private_data = mix;
+#ifndef I2C_PEC
+	if (client->adapter->inc_use)
+		client->adapter->inc_use(client->adapter);
+#endif
 	if (client->adapter->owner)
 		try_module_get(client->adapter->owner);
         return 0;
@@ -205,17 +209,27 @@ static int tvmixer_release(struct inode 
 		return -ENODEV;
 	}
 
+#ifndef I2C_PEC
+	if (client->adapter->dec_use)
+		client->adapter->dec_use(client->adapter);
+#endif
 	if (client->adapter->owner)
 		module_put(client->adapter->owner);
 	return 0;
 }
 
 static struct i2c_driver driver = {
+#ifdef I2C_PEC
 	.owner           = THIS_MODULE,
+#endif
 	.name            = "tv card mixer driver",
         .id              = I2C_DRIVERID_TVMIXER,
+#ifdef I2C_DF_DUMMY
+	.flags           = I2C_DF_DUMMY,
+#else
 	.flags           = I2C_DF_NOTIFY,
         .detach_adapter  = tvmixer_adapters,
+#endif
         .attach_adapter  = tvmixer_adapters,
         .detach_client   = tvmixer_clients,
 };
@@ -247,8 +261,21 @@ static int tvmixer_clients(struct i2c_cl
 	struct video_audio va;
 	int i,minor;
 
+#ifdef I2C_ADAP_CLASS_TV_ANALOG
 	if (!(client->adapter->class & I2C_ADAP_CLASS_TV_ANALOG))
 		return -1;
+#else
+	/* TV card ??? */
+	switch (client->adapter->id) {
+	case I2C_ALGO_BIT | I2C_HW_B_BT848:
+	case I2C_ALGO_BIT | I2C_HW_B_RIVA:
+		/* ok, have a look ... */
+		break;
+	default:
+		/* ignore that one */
+		return -1;
+	}
+#endif
 
 	/* unregister ?? */
 	for (i = 0; i < DEV_MAX; i++) {
diff -puN drivers/media/video/v4l1-compat.c~linus drivers/media/video/v4l1-compat.c
--- 25/drivers/media/video/v4l1-compat.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/v4l1-compat.c	2004-01-19 22:17:22.000000000 -0800
@@ -21,7 +21,6 @@
 
 #include <linux/config.h>
 
-#include <linux/version.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/types.h>
@@ -52,7 +51,7 @@ MODULE_DESCRIPTION("v4l(1) compatibility
 MODULE_LICENSE("GPL");
 
 #define dprintk(fmt, arg...)	if (debug) \
-	printk(KERN_DEBUG "v4l1-compat: " fmt, ## arg)
+	printk(KERN_DEBUG "v4l1-compat: " fmt , ## arg)
 
 /*
  *	I O C T L   T R A N S L A T I O N
@@ -80,8 +79,10 @@ get_v4l_control(struct inode            
 	{
 		ctrl2.id = qctrl2.id;
 		err = drv(inode, file, VIDIOC_G_CTRL, &ctrl2);
-		if (err < 0)
+		if (err < 0) {
 			dprintk("VIDIOC_G_CTRL: %d\n",err);
+			return 0;
+		}
 		return ((ctrl2.value - qctrl2.minimum) * 65535
 			 + (qctrl2.maximum - qctrl2.minimum) / 2)
 			/ (qctrl2.maximum - qctrl2.minimum);
@@ -207,17 +208,10 @@ static int poll_one(struct file *file)
 {
 	int retval = 1;
 	poll_table *table;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,48)
-	poll_table wait_table;
-
-	poll_initwait(&wait_table);
-	table = &wait_table;
-#else
 	struct poll_wqueues pwq;
 
 	poll_initwait(&pwq);
 	table = &pwq.pt;
-#endif
 	for (;;) {
 		int mask;
 		set_current_state(TASK_INTERRUPTIBLE);
@@ -231,12 +225,8 @@ static int poll_one(struct file *file)
 		}
 		schedule();
 	}
-	current->state = TASK_RUNNING;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,48)
-	poll_freewait(&wait_table);
-#else
+	set_current_state(TASK_RUNNING);
 	poll_freewait(&pwq);
-#endif
 	return retval;
 }
 
@@ -482,6 +472,7 @@ v4l_compat_translate_ioctl(struct inode 
 			fmt2->fmt.pix.width  = win->width;
 			fmt2->fmt.pix.height = win->height;
 			fmt2->fmt.pix.field  = V4L2_FIELD_ANY;
+			fmt2->fmt.pix.bytesperline = 0;
 			err = drv(inode, file, VIDIOC_S_FMT, fmt2);
 			if (err < 0)
 				dprintk("VIDIOCSWIN / VIDIOC_S_FMT #1: %d\n",
@@ -509,6 +500,14 @@ v4l_compat_translate_ioctl(struct inode 
 	}
 	case VIDIOCCAPTURE: /*  turn on/off preview  */
 	{
+		int *on = arg;
+
+		if (0 == *on) {
+			/* dirty hack time.  But v4l1 has no STREAMOFF
+			 * equivalent in the API, and this one at
+			 * least comes close ... */
+			drv(inode, file, VIDIOC_STREAMOFF, NULL);
+		}
 		err = drv(inode, file, VIDIOC_OVERLAY, arg);
 		if (err < 0)
 			dprintk("VIDIOCCAPTURE / VIDIOC_PREVIEW: %d\n",err);
@@ -719,7 +718,8 @@ v4l_compat_translate_ioctl(struct inode 
 	case VIDIOCGFREQ: /*  get frequency  */
 	{
 		int *freq = arg;
-		
+
+		freq2.tuner = 0;
 		err = drv(inode, file, VIDIOC_G_FREQUENCY, &freq2);
 		if (err < 0)
 			dprintk("VIDIOCGFREQ / VIDIOC_G_FREQUENCY: %d\n",err);
@@ -731,6 +731,7 @@ v4l_compat_translate_ioctl(struct inode 
 	{
 		int *freq = arg;
 
+		freq2.tuner = 0;
 		drv(inode, file, VIDIOC_G_FREQUENCY, &freq2);
 		freq2.frequency = *freq;
 		err = drv(inode, file, VIDIOC_S_FREQUENCY, &freq2);
@@ -877,6 +878,7 @@ v4l_compat_translate_ioctl(struct inode 
 			fmt2->fmt.pix.pixelformat =
 				palette_to_pixelformat(mm->format);
 			fmt2->fmt.pix.field = V4L2_FIELD_ANY;
+			fmt2->fmt.pix.bytesperline = 0;
 			err = drv(inode, file, VIDIOC_S_FMT, fmt2);
 			if (err < 0) {
 				dprintk("VIDIOCMCAPTURE / VIDIOC_S_FMT: %d\n",err);
@@ -895,7 +897,7 @@ v4l_compat_translate_ioctl(struct inode 
 			dprintk("VIDIOCMCAPTURE / VIDIOC_QBUF: %d\n",err);
 			break;
 		}
-		err = drv(inode, file, VIDIOC_STREAMON, &buf2.type);
+		err = drv(inode, file, VIDIOC_STREAMON, NULL);
 		if (err < 0)
 			dprintk("VIDIOCMCAPTURE / VIDIOC_STREAMON: %d\n",err);
 		break;
@@ -989,7 +991,7 @@ v4l_compat_translate_ioctl(struct inode 
 
 		if (fmt2->fmt.vbi.samples_per_line != fmt->samples_per_line ||
 		    fmt2->fmt.vbi.sampling_rate    != fmt->sampling_rate    ||
-		    fmt2->fmt.vbi.sample_format    != V4L2_PIX_FMT_GREY     ||
+		    VIDEO_PALETTE_RAW              != fmt->sample_format    ||
 		    fmt2->fmt.vbi.start[0]         != fmt->start[0]         ||
 		    fmt2->fmt.vbi.count[0]         != fmt->count[0]         ||
 		    fmt2->fmt.vbi.start[1]         != fmt->start[1]         ||
@@ -999,10 +1001,9 @@ v4l_compat_translate_ioctl(struct inode 
 			break;
 		}
 		err = drv(inode, file, VIDIOC_S_FMT, fmt2);
-		if (err < 0) {
+		if (err < 0)
 			dprintk("VIDIOCSVBIFMT / VIDIOC_S_FMT: %d\n", err);
-			break;
-		}
+		break;
 	}
 	
 	default:
diff -puN drivers/media/video/v4l2-common.c~linus drivers/media/video/v4l2-common.c
--- 25/drivers/media/video/v4l2-common.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/v4l2-common.c	2004-01-19 22:17:22.000000000 -0800
@@ -67,6 +67,7 @@
 #include <linux/ust.h>
 #endif
 
+
 #include <linux/videodev.h>
 
 MODULE_AUTHOR("Bill Dirks, Justin Schoeman, Gerd Knorr");
@@ -100,9 +101,11 @@ v4l2_video_std_fps(struct v4l2_standard 
 int v4l2_video_std_construct(struct v4l2_standard *vs,
 			     int id, char *name)
 {
-	memset(vs, 0, sizeof(struct v4l2_standard));
+	u32 index = vs->index;
 
-	vs->id = id;
+	memset(vs, 0, sizeof(struct v4l2_standard));
+	vs->index = index;
+	vs->id    = id;
 	if (id & (V4L2_STD_NTSC | V4L2_STD_PAL_M)) {
 		vs->frameperiod.numerator = 1001;
 		vs->frameperiod.denominator = 30000;
@@ -118,6 +121,66 @@ int v4l2_video_std_construct(struct v4l2
 
 
 /* ----------------------------------------------------------------- */
+/* priority handling                                                 */
+
+#define V4L2_PRIO_VALID(val) (val == V4L2_PRIORITY_BACKGROUND   || \
+			      val == V4L2_PRIORITY_INTERACTIVE  || \
+			      val == V4L2_PRIORITY_RECORD)
+
+int v4l2_prio_init(struct v4l2_prio_state *global)
+{
+	memset(global,0,sizeof(*global));
+	return 0;
+}
+	
+int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
+		     enum v4l2_priority new)
+{
+	if (!V4L2_PRIO_VALID(new))
+		return -EINVAL;
+	if (*local == new)
+		return 0;
+
+	atomic_inc(&global->prios[new]);
+	if (V4L2_PRIO_VALID(*local))
+		atomic_dec(&global->prios[*local]);
+	*local = new;
+	return 0;
+}
+
+int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local)
+{
+	return v4l2_prio_change(global,local,V4L2_PRIORITY_DEFAULT);
+}
+
+int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local)
+{
+	if (V4L2_PRIO_VALID(*local))
+		atomic_dec(&global->prios[*local]);
+	return 0;
+}
+
+enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global)
+{
+	if (atomic_read(&global->prios[V4L2_PRIORITY_RECORD]) > 0)
+		return V4L2_PRIORITY_RECORD;
+	if (atomic_read(&global->prios[V4L2_PRIORITY_INTERACTIVE]) > 0)
+		return V4L2_PRIORITY_INTERACTIVE;
+	if (atomic_read(&global->prios[V4L2_PRIORITY_BACKGROUND]) > 0)
+		return V4L2_PRIORITY_BACKGROUND;
+	return V4L2_PRIORITY_UNSET;
+}
+
+int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local)
+{
+	if (*local < v4l2_prio_max(global))
+		return -EBUSY;
+	return 0;
+}
+
+
+/* ----------------------------------------------------------------- */
+/* some arrays for pretty-printing debug messages                    */
 
 char *v4l2_field_names[] = {
 	[V4L2_FIELD_ANY]        = "any",
@@ -199,6 +262,13 @@ char *v4l2_ioctl_names[256] = {
 EXPORT_SYMBOL(v4l2_video_std_fps);
 EXPORT_SYMBOL(v4l2_video_std_construct);
 
+EXPORT_SYMBOL(v4l2_prio_init);
+EXPORT_SYMBOL(v4l2_prio_change);
+EXPORT_SYMBOL(v4l2_prio_open);
+EXPORT_SYMBOL(v4l2_prio_close);
+EXPORT_SYMBOL(v4l2_prio_max);
+EXPORT_SYMBOL(v4l2_prio_check);
+
 EXPORT_SYMBOL(v4l2_field_names);
 EXPORT_SYMBOL(v4l2_type_names);
 EXPORT_SYMBOL(v4l2_ioctl_names);
diff -puN drivers/media/video/video-buf.c~linus drivers/media/video/video-buf.c
--- 25/drivers/media/video/video-buf.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/video-buf.c	2004-01-19 22:17:22.000000000 -0800
@@ -26,11 +26,6 @@
 #include <asm/page.h>
 #include <asm/pgtable.h>
 
-#ifndef TryLockPage
-# include "linux/page-flags.h"
-# define TryLockPage TestSetPageLocked
-#endif
-
 #include <media/video-buf.h>
 
 static int debug = 0;
@@ -41,7 +36,7 @@ MODULE_LICENSE("GPL");
 MODULE_PARM(debug,"i");
 
 #define dprintk(level, fmt, arg...)	if (debug >= level) \
-	printk(KERN_DEBUG "vbuf: " fmt, ## arg)
+	printk(KERN_DEBUG "vbuf: " fmt , ## arg)
 
 struct scatterlist*
 videobuf_vmalloc_to_sg(unsigned char *virt, int nr_pages)
@@ -112,36 +107,6 @@ videobuf_pages_to_sg(struct page **pages
 	return NULL;
 }
 
-int videobuf_lock(struct page **pages, int nr_pages)
-{
-	int i;
-
-	dprintk(2,"lock start ...\n");
-	for (i = 0; i < nr_pages; i++)
-		if (TryLockPage(pages[i]))
-			goto err;
-	dprintk(2,"lock ok [%d pages]\n",nr_pages);
-	return 0;
-
- err:
-	dprintk(2,"lock failed, unlock ...\n");
-	while (i > 0)
-		unlock_page(pages[--i]);
-	dprintk(2,"lock quit\n");
-	return -EINVAL;
-}
-
-int videobuf_unlock(struct page **pages, int nr_pages)
-{
-	int i;
-
-	dprintk(2,"unlock start ...\n");
-	for (i = 0; i < nr_pages; i++)
-		unlock_page(pages[i]);
-	dprintk(2,"unlock ok [%d pages]\n",nr_pages);
-	return 0;
-}
-
 /* --------------------------------------------------------------------- */
 
 int videobuf_dma_init_user(struct videobuf_dmabuf *dma, int direction,
@@ -213,20 +178,12 @@ int videobuf_dma_init_overlay(struct vid
 
 int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma)
 {
-	int err;
-
 	if (0 == dma->nr_pages)
 		BUG();
 	
 	if (dma->pages) {
-		if (0 != (err = videobuf_lock(dma->pages, dma->nr_pages))) {
-			dprintk(1,"videobuf_lock: %d\n",err);
-			return err;
-		}
 		dma->sglist = videobuf_pages_to_sg(dma->pages, dma->nr_pages,
 						   dma->offset);
-		if (NULL == dma->sglist)
-			videobuf_unlock(dma->pages, dma->nr_pages);
 	}
 	if (dma->vmalloc) {
 		dma->sglist = videobuf_vmalloc_to_sg
@@ -236,8 +193,8 @@ int videobuf_dma_pci_map(struct pci_dev 
 		dma->sglist = kmalloc(sizeof(struct scatterlist), GFP_KERNEL);
 		if (NULL != dma->sglist) {
 			dma->sglen  = 1;
-			sg_dma_address(&dma->sglist[0]) = dma->bus_addr & ~PAGE_MASK;
-			dma->sglist[0].offset           = dma->bus_addr & PAGE_MASK;
+			sg_dma_address(&dma->sglist[0]) = dma->bus_addr & PAGE_MASK;
+			dma->sglist[0].offset           = dma->bus_addr & ~PAGE_MASK;
 			sg_dma_len(&dma->sglist[0])     = dma->nr_pages * PAGE_SIZE;
 		}
 	}
@@ -272,8 +229,6 @@ int videobuf_dma_pci_unmap(struct pci_de
 	kfree(dma->sglist);
 	dma->sglist = NULL;
 	dma->sglen = 0;
-	if (dma->pages)
-		videobuf_unlock(dma->pages, dma->nr_pages);
 	return 0;
 }
 
@@ -325,8 +280,8 @@ int videobuf_waiton(struct videobuf_buff
 			retval = -EAGAIN;
 			break;
 		}
-		set_current_state(intr ? TASK_INTERRUPTIBLE :
-					TASK_UNINTERRUPTIBLE);
+		set_current_state(intr  ? TASK_INTERRUPTIBLE
+					: TASK_UNINTERRUPTIBLE);
 		if (vb->state == STATE_ACTIVE || vb->state == STATE_QUEUED)
 			schedule();
 		set_current_state(TASK_RUNNING);
@@ -969,8 +924,10 @@ ssize_t videobuf_read_stream(struct file
 			retval      += bytes;
 			q->read_off += bytes;
 		} else {
-			/* some error -- skip buffer */
+			/* some error */
 			q->read_off = q->read_buf->size;
+			if (0 == retval)
+				retval = -EIO;
 		}
 
 		/* requeue buffer when done with copying */
@@ -982,6 +939,8 @@ ssize_t videobuf_read_stream(struct file
 			spin_unlock_irqrestore(q->irqlock,flags);
 			q->read_buf = NULL;
 		}
+		if (retval < 0)
+			break;
 	}
 
  done:
@@ -1078,7 +1037,7 @@ videobuf_vm_close(struct vm_area_struct 
  */
 static struct page*
 videobuf_vm_nopage(struct vm_area_struct *vma, unsigned long vaddr,
-		  int *type)
+		   int *type)
 {
 	struct page *page;
 
@@ -1232,8 +1191,6 @@ int videobuf_mmap_mapper(struct vm_area_
 /* --------------------------------------------------------------------- */
 
 EXPORT_SYMBOL_GPL(videobuf_vmalloc_to_sg);
-EXPORT_SYMBOL_GPL(videobuf_lock);
-EXPORT_SYMBOL_GPL(videobuf_unlock);
 
 EXPORT_SYMBOL_GPL(videobuf_dma_init_user);
 EXPORT_SYMBOL_GPL(videobuf_dma_init_kernel);
diff -puN drivers/media/video/videodev.c~linus drivers/media/video/videodev.c
--- 25/drivers/media/video/videodev.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/media/video/videodev.c	2004-01-19 22:17:22.000000000 -0800
@@ -140,6 +140,30 @@ static int video_open(struct inode *inod
 /*
  * helper function -- handles userspace copying for ioctl arguments
  */
+
+static unsigned int
+video_fix_command(unsigned int cmd)
+{
+	switch (cmd) {
+	case VIDIOC_OVERLAY_OLD:
+		cmd = VIDIOC_OVERLAY;
+		break;
+	case VIDIOC_S_PARM_OLD:
+		cmd = VIDIOC_S_PARM;
+		break;
+	case VIDIOC_S_CTRL_OLD:
+		cmd = VIDIOC_S_CTRL;
+		break;
+	case VIDIOC_G_AUDIO_OLD:
+		cmd = VIDIOC_G_AUDIO;
+		break;
+	case VIDIOC_G_AUDOUT_OLD:
+		cmd = VIDIOC_G_AUDOUT;
+		break;
+	}
+	return cmd;
+}
+
 int
 video_usercopy(struct inode *inode, struct file *file,
 	       unsigned int cmd, unsigned long arg,
@@ -151,12 +175,14 @@ video_usercopy(struct inode *inode, stru
 	void	*parg = NULL;
 	int	err  = -EINVAL;
 
+	cmd = video_fix_command(cmd);
+
 	/*  Copy arguments into temp kernel buffer  */
 	switch (_IOC_DIR(cmd)) {
 	case _IOC_NONE:
 		parg = (void *)arg;
 		break;
-	case _IOC_READ: /* some v4l ioctls are marked wrong ... */
+	case _IOC_READ:
 	case _IOC_WRITE:
 	case (_IOC_WRITE | _IOC_READ):
 		if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {
@@ -170,8 +196,9 @@ video_usercopy(struct inode *inode, stru
 		}
 		
 		err = -EFAULT;
-		if (copy_from_user(parg, (void *)arg, _IOC_SIZE(cmd)))
-			goto out;
+		if (_IOC_DIR(cmd) & _IOC_WRITE)
+			if (copy_from_user(parg, (void *)arg, _IOC_SIZE(cmd)))
+				goto out;
 		break;
 	}
 
diff -puN drivers/message/fusion/mptbase.h~linus drivers/message/fusion/mptbase.h
--- 25/drivers/message/fusion/mptbase.h~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/message/fusion/mptbase.h	2004-01-19 22:17:22.000000000 -0800
@@ -80,8 +80,8 @@
 #define COPYRIGHT	"Copyright (c) 1999-2003 " MODULEAUTHOR
 #endif
 
-#define MPT_LINUX_VERSION_COMMON	"2.05.00.05"
-#define MPT_LINUX_PACKAGE_NAME		"@(#)mptlinux-2.05.00.05"
+#define MPT_LINUX_VERSION_COMMON	"2.05.00.06"
+#define MPT_LINUX_PACKAGE_NAME		"@(#)mptlinux-2.05.00.06"
 #define WHAT_MAGIC_STRING		"@" "(" "#" ")"
 
 #define show_mptmod_ver(s,ver)  \
diff -puN drivers/message/fusion/mptscsih.c~linus drivers/message/fusion/mptscsih.c
--- 25/drivers/message/fusion/mptscsih.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/message/fusion/mptscsih.c	2004-01-19 22:17:22.000000000 -0800
@@ -1231,7 +1231,9 @@ mptscsih_initChainBuffers (MPT_SCSI_HOST
 	} else {
 		mem = (u8 *) hd->ReqToChain;
 	}
-	memset(mem, 0xFF, sz);
+/*	memset(mem, 0xFF, sz); */
+	for(ii=0;ii<hd->ioc->req_depth;ii++)
+		hd->ReqToChain[ii] = MPT_HOST_NO_CHAIN;
 
 
 	/* ChainToChain size must equal the total number
diff -puN drivers/mtd/maps/pcmciamtd.c~linus drivers/mtd/maps/pcmciamtd.c
--- 25/drivers/mtd/maps/pcmciamtd.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/mtd/maps/pcmciamtd.c	2004-01-19 22:17:22.000000000 -0800
@@ -125,7 +125,7 @@ static caddr_t remap_window(struct map_i
 		DEBUG(2, "Remapping window from 0x%8.8x to 0x%8.8x",
 		      dev->offset, mrq.CardOffset);
 		mrq.Page = 0;
-		if( (ret = CardServices(MapMemPage, win, &mrq)) != CS_SUCCESS) {
+		if( (ret = pcmcia_map_mem_page(win, &mrq)) != CS_SUCCESS) {
 			cs_error(dev->link.handle, MapMemPage, ret);
 			return NULL;
 		}
@@ -332,7 +332,7 @@ static void pcmciamtd_set_vpp(struct map
 	mod.Vpp1 = mod.Vpp2 = on ? dev->vpp : 0;
 
 	DEBUG(2, "dev = %p on = %d vpp = %d\n", dev, on, dev->vpp);
-	ret = CardServices(ModifyConfiguration, link->handle, &mod);
+	ret = pcmcia_modify_configuration(link->handle, &mod);
 	if(ret != CS_SUCCESS) {
 		cs_error(link->handle, ModifyConfiguration, ret);
 	}
@@ -355,9 +355,9 @@ static void pcmciamtd_release(dev_link_t
 			iounmap(dev->win_base);
 			dev->win_base = NULL;
 		}
-		CardServices(ReleaseWindow, link->win);
+		pcmcia_release_window(link->win);
 	}
-	CardServices(ReleaseConfiguration, link->handle);
+	pcmcia_release_configuration(link->handle);
 	link->state &= ~DEV_CONFIG;
 }
 
@@ -375,14 +375,14 @@ static void card_settings(struct pcmciam
 	tuple.TupleOffset = 0;
 	tuple.DesiredTuple = RETURN_FIRST_TUPLE;
 
-	rc = CardServices(GetFirstTuple, link->handle, &tuple);
+	rc = pcmcia_get_first_tuple(link->handle, &tuple);
 	while(rc == CS_SUCCESS) {
-		rc = CardServices(GetTupleData, link->handle, &tuple);
+		rc = pcmcia_get_tuple_data(link->handle, &tuple);
 		if(rc != CS_SUCCESS) {
 			cs_error(link->handle, GetTupleData, rc);
 			break;
 		}
-		rc = CardServices(ParseTuple, link->handle, &tuple, &parse);
+		rc = pcmcia_parse_tuple(link->handle, &tuple, &parse);
 		if(rc != CS_SUCCESS) {
 			cs_error(link->handle, ParseTuple, rc);
 			break;
@@ -455,7 +455,7 @@ static void card_settings(struct pcmciam
 			DEBUG(2, "Unknown tuple code %d", tuple.TupleCode);
 		}
 		
-		rc = CardServices(GetNextTuple, link->handle, &tuple, &parse);
+		rc = pcmcia_get_next_tuple(link->handle, &tuple);
 	}
 	if(!dev->pcmcia_map.size)
 		dev->pcmcia_map.size = MAX_PCMCIA_ADDR;
@@ -489,8 +489,8 @@ static void card_settings(struct pcmciam
  * MTD device available to the system.
  */
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static void pcmciamtd_config(dev_link_t *link)
 {
@@ -512,7 +512,7 @@ static void pcmciamtd_config(dev_link_t 
 	link->state |= DEV_CONFIG;
 
 	DEBUG(2, "Validating CIS");
-	ret = CardServices(ValidateCIS, link->handle, &cisinfo);
+	ret = pcmcia_validate_cis(link->handle, &cisinfo);
 	if(ret != CS_SUCCESS) {
 		cs_error(link->handle, GetTupleData, ret);
 	} else {
@@ -547,8 +547,7 @@ static void pcmciamtd_config(dev_link_t 
 		int ret;
 		DEBUG(2, "requesting window with size = %dKiB memspeed = %d",
 		      req.Size >> 10, req.AccessSpeed);
-		link->win = (window_handle_t)link->handle;
-		ret = CardServices(RequestWindow, &link->win, &req);
+		ret = pcmcia_request_window(&link->handle, &req, &link->win);
 		DEBUG(2, "ret = %d dev->win_size = %d", ret, dev->win_size);
 		if(ret) {
 			req.Size >>= 1;
@@ -569,7 +568,7 @@ static void pcmciamtd_config(dev_link_t 
 	DEBUG(1, "Allocated a window of %dKiB", dev->win_size >> 10);
 		
 	/* Get write protect status */
-	CS_CHECK(GetStatus, link->handle, &status);
+	CS_CHECK(GetStatus, pcmcia_get_status(link->handle, &status));
 	DEBUG(2, "status value: 0x%x window handle = 0x%8.8lx",
 	      status.CardState, (unsigned long)link->win);
 	dev->win_base = ioremap(req.Base, req.Size);
@@ -586,7 +585,7 @@ static void pcmciamtd_config(dev_link_t 
 	dev->pcmcia_map.map_priv_2 = (unsigned long)link->win;
 
 	DEBUG(2, "Getting configuration");
-	CS_CHECK(GetConfigurationInfo, link->handle, &t);
+	CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link->handle, &t));
 	DEBUG(2, "Vcc = %d Vpp1 = %d Vpp2 = %d", t.Vcc, t.Vpp1, t.Vpp2);
 	dev->vpp = (vpp) ? vpp : t.Vpp1;
 	link->conf.Attributes = 0;
@@ -608,7 +607,7 @@ static void pcmciamtd_config(dev_link_t 
 	link->conf.ConfigIndex = 0;
 	link->conf.Present = t.Present;
 	DEBUG(2, "Setting Configuration");
-	ret = CardServices(RequestConfiguration, link->handle, &link->conf);
+	ret = pcmcia_request_configuration(link->handle, &link->conf);
 	if(ret != CS_SUCCESS) {
 		cs_error(link->handle, RequestConfiguration, ret);
 	}
@@ -757,7 +756,7 @@ static void pcmciamtd_detach(dev_link_t 
 	if (link->handle) {
 		int ret;
 		DEBUG(2, "Deregistering with card services");
-		ret = CardServices(DeregisterClient, link->handle);
+		ret = pcmcia_deregister_client(link->handle);
 		if (ret != CS_SUCCESS)
 			cs_error(link->handle, DeregisterClient, ret);
 	}
@@ -804,7 +803,7 @@ static dev_link_t *pcmciamtd_attach(void
 	client_reg.Version = 0x0210;
 	client_reg.event_callback_args.client_data = link;
 	DEBUG(2, "Calling RegisterClient");
-	ret = CardServices(RegisterClient, &link->handle, &client_reg);
+	ret = pcmcia_register_client(&link->handle, &client_reg);
 	if (ret != 0) {
 		cs_error(link->handle, RegisterClient, ret);
 		pcmciamtd_detach(link);
diff -puN drivers/net/3c527.c~linus drivers/net/3c527.c
--- 25/drivers/net/3c527.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/net/3c527.c	2004-01-19 22:17:22.000000000 -0800
@@ -1,9 +1,10 @@
-/* 3c527.c: 3Com Etherlink/MC32 driver for Linux 2.4
+/* 3c527.c: 3Com Etherlink/MC32 driver for Linux 2.4 and 2.6.
  *
  *	(c) Copyright 1998 Red Hat Software Inc
  *	Written by Alan Cox. 
  *	Further debugging by Carl Drougge.
- *      Modified by Richard Procter (rnp@netlink.co.nz)
+ *      Initial SMP support by Felipe W Damasio <felipewd@terra.com.br>
+ *      Heavily modified by Richard Procter <rnp@paradise.net.nz>
  *
  *	Based on skeleton.c written 1993-94 by Donald Becker and ne2.c
  *	(for the MCA stuff) written by Wim Dumon.
@@ -17,11 +18,11 @@
  */
 
 #define DRV_NAME		"3c527"
-#define DRV_VERSION		"0.6a"
-#define DRV_RELDATE		"2001/11/17"
+#define DRV_VERSION		"0.7-SMP"
+#define DRV_RELDATE		"2003/09/21"
 
 static const char *version =
-DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Richard Proctor (rnp@netlink.co.nz)\n";
+DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Richard Procter <rnp@paradise.net.nz>\n";
 
 /**
  * DOC: Traps for the unwary
@@ -100,7 +101,9 @@ DRV_NAME ".c:v" DRV_VERSION " " DRV_RELD
 #include <linux/string.h>
 #include <linux/wait.h>
 #include <linux/ethtool.h>
+#include <linux/completion.h>
 
+#include <asm/semaphore.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #include <asm/bitops.h>
@@ -143,19 +146,19 @@ static unsigned int mc32_debug = NET_DEB
 static const int WORKAROUND_82586=1;
 
 /* Pointers to buffers and their on-card records */
-
 struct mc32_ring_desc 
 {
 	volatile struct skb_header *p;                    
 	struct sk_buff *skb;          
 };
 
-
 /* Information that needs to be kept for each board. */
 struct mc32_local 
 {
-	struct net_device_stats net_stats;
 	int slot;
+
+	u32 base;
+	struct net_device_stats net_stats;
 	volatile struct mc32_mailbox *rx_box;
 	volatile struct mc32_mailbox *tx_box;
 	volatile struct mc32_mailbox *exec_box;
@@ -165,22 +168,23 @@ struct mc32_local 
         u16 tx_len;             /* Transmit list count */ 
         u16 rx_len;             /* Receive list count */
 
-	u32 base;
-	u16 exec_pending;
-	u16 mc_reload_wait;	/* a multicast load request is pending */
+	u16 xceiver_desired_state; /* HALTED or RUNNING */
+	u16 cmd_nonblocking;    /* Thread is uninterested in command result */
+	u16 mc_reload_wait;	/* A multicast load request is pending */
 	u32 mc_list_valid;	/* True when the mclist is set */
-	u16 xceiver_state;      /* Current transceiver state. bitmapped */ 
-	u16 desired_state;      /* The state we want the transceiver to be in */ 
-	atomic_t tx_count;	/* buffers left */
-	wait_queue_head_t event;
 
 	struct mc32_ring_desc tx_ring[TX_RING_LEN];	/* Host Transmit ring */
 	struct mc32_ring_desc rx_ring[RX_RING_LEN];	/* Host Receive ring */
 
+	atomic_t tx_count;	/* buffers left */
+	atomic_t tx_ring_head;  /* index to tx en-queue end */
 	u16 tx_ring_tail;       /* index to tx de-queue end */
-	u16 tx_ring_head;       /* index to tx en-queue end */
 
 	u16 rx_ring_tail;       /* index to rx de-queue end */ 
+
+	struct semaphore cmd_mutex;    /* Serialises issuing of execute commands */
+        struct completion execution_cmd; /* Card has completed an execute command */
+	struct completion xceiver_cmd;   /* Card has completed a tx or rx command */
 };
 
 /* The station (ethernet) address prefix, used for a sanity check. */
@@ -236,7 +240,6 @@ int __init mc32_probe(struct net_device 
 {
 	static int current_mca_slot = -1;
 	int i;
-	int adapter_found = 0;
 
 	SET_MODULE_OWNER(dev);
 
@@ -247,11 +250,11 @@ int __init mc32_probe(struct net_device 
 	   Autodetecting MCA cards is extremely simple. 
 	   Just search for the card. */
 
-	for(i = 0; (mc32_adapters[i].name != NULL) && !adapter_found; i++) {
+	for(i = 0; (mc32_adapters[i].name != NULL); i++) {
 		current_mca_slot = 
 			mca_find_unused_adapter(mc32_adapters[i].id, 0);
 
-		if((current_mca_slot != MCA_NOTFOUND) && !adapter_found) {
+		if(current_mca_slot != MCA_NOTFOUND) {
 			if(!mc32_probe1(dev, current_mca_slot))
 			{
 				mca_set_adapter_name(current_mca_slot, 
@@ -409,7 +412,7 @@ static int __init mc32_probe1(struct net
 	 *	Grab the IRQ
 	 */
 
-	i = request_irq(dev->irq, &mc32_interrupt, SA_SHIRQ, dev->name, dev);
+	i = request_irq(dev->irq, &mc32_interrupt, SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
 	if (i) {
 		release_region(dev->base_addr, MC32_IO_EXTENT);
 		printk(KERN_ERR "%s: unable to get IRQ %d.\n", dev->name, dev->irq);
@@ -498,7 +501,9 @@ static int __init mc32_probe1(struct net
 	lp->tx_len 		= lp->exec_box->data[9];   /* Transmit list count */ 
 	lp->rx_len 		= lp->exec_box->data[11];  /* Receive list count */
 
-	init_waitqueue_head(&lp->event);
+	init_MUTEX_LOCKED(&lp->cmd_mutex);
+	init_completion(&lp->execution_cmd);
+	init_completion(&lp->xceiver_cmd);
 	
 	printk("%s: Firmware Rev %d. %d RX buffers, %d TX buffers. Base of 0x%08X.\n",
 		dev->name, lp->exec_box->data[12], lp->rx_len, lp->tx_len, lp->base);
@@ -511,10 +516,6 @@ static int __init mc32_probe1(struct net
 	dev->tx_timeout		= mc32_timeout;
 	dev->watchdog_timeo	= HZ*5;	/* Board does all the work */
 	dev->ethtool_ops	= &netdev_ethtool_ops;
-	
-	lp->xceiver_state = HALTED; 
-	
-	lp->tx_ring_tail=lp->tx_ring_head=0;
 
 	/* Fill in the fields of the device structure with ethernet values. */
 	ether_setup(dev);
@@ -539,7 +540,7 @@ err_exit_irq:
  *	status of any pending commands and takes very little time at all.
  */
  
-static void mc32_ready_poll(struct net_device *dev)
+static inline void mc32_ready_poll(struct net_device *dev)
 {
 	int ioaddr = dev->base_addr;
 	while(!(inb(ioaddr+HOST_STATUS)&HOST_STATUS_CRR));
@@ -554,31 +555,38 @@ static void mc32_ready_poll(struct net_d
  *	@len: Length of the data block
  *
  *	Send a command from interrupt state. If there is a command
- *	currently being executed then we return an error of -1. It simply
- *	isn't viable to wait around as commands may be slow. Providing we
- *	get in, we busy wait for the board to become ready to accept the
- *	command and issue it. We do not wait for the command to complete
- *	--- the card will interrupt us when it's done.
+ *	currently being executed then we return an error of -1. It
+ *	simply isn't viable to wait around as commands may be
+ *	slow. This can theoretically be starved on SMP, but it's hard
+ *	to see a realistic situation.  We do not wait for the command
+ *	to complete --- we rely on the interrupt handler to tidy up
+ *	after us.
  */
 
 static int mc32_command_nowait(struct net_device *dev, u16 cmd, void *data, int len)
 {
 	struct mc32_local *lp = (struct mc32_local *)dev->priv;
 	int ioaddr = dev->base_addr;
+	int ret = -1;
 
-	if(lp->exec_pending)
-		return -1;
-	
-	lp->exec_pending=3;
-	lp->exec_box->mbox=0;
-	lp->exec_box->mbox=cmd;
-	memcpy((void *)lp->exec_box->data, data, len);
-	barrier();	/* the memcpy forgot the volatile so be sure */
+	if (down_trylock(&lp->cmd_mutex) == 0)
+	{
+		lp->cmd_nonblocking=1;
+		lp->exec_box->mbox=0;
+		lp->exec_box->mbox=cmd;
+		memcpy((void *)lp->exec_box->data, data, len);
+		barrier();	/* the memcpy forgot the volatile so be sure */
+
+		/* Send the command */
+		mc32_ready_poll(dev);
+		outb(1<<6, ioaddr+HOST_CMD);
 
-	/* Send the command */
-	while(!(inb(ioaddr+HOST_STATUS)&HOST_STATUS_CRR));
-	outb(1<<6, ioaddr+HOST_CMD);	
-	return 0;
+		ret = 0;
+
+		/* Interrupt handler will signal mutex on completion */
+	}
+
+	return ret;
 }
 
 
@@ -592,76 +600,47 @@ static int mc32_command_nowait(struct ne
  *	Sends exec commands in a user context. This permits us to wait around
  *	for the replies and also to wait for the command buffer to complete
  *	from a previous command before we execute our command. After our 
- *	command completes we will complete any pending multicast reload
+ *	command completes we will attempt any pending multicast reload
  *	we blocked off by hogging the exec buffer.
  *
  *	You feed the card a command, you wait, it interrupts you get a 
  *	reply. All well and good. The complication arises because you use
  *	commands for filter list changes which come in at bh level from things
  *	like IPV6 group stuff.
- *
- *	We have a simple state machine
- *
- *	0	- nothing issued
- *
- *	1	- command issued, wait reply
- *
- *	2	- reply waiting - reader then goes to state 0
- *
- *	3	- command issued, trash reply. In which case the irq
- *		  takes it back to state 0
- *
  */
   
 static int mc32_command(struct net_device *dev, u16 cmd, void *data, int len)
 {
 	struct mc32_local *lp = (struct mc32_local *)dev->priv;
 	int ioaddr = dev->base_addr;
-	unsigned long flags;
 	int ret = 0;
 	
+	down(&lp->cmd_mutex);
+
 	/*
-	 *	Wait for a command
-	 */
-	 
-	save_flags(flags);
-	cli();
-	 
-	while(lp->exec_pending)
-		sleep_on(&lp->event);
-		
-	/*
-	 *	Issue mine
+	 *     My Turn
 	 */
 
-	lp->exec_pending=1;
-	
-	restore_flags(flags);
-	
+	lp->cmd_nonblocking=0;
 	lp->exec_box->mbox=0;
 	lp->exec_box->mbox=cmd;
 	memcpy((void *)lp->exec_box->data, data, len);
 	barrier();	/* the memcpy forgot the volatile so be sure */
 
-	/* Send the command */
-	while(!(inb(ioaddr+HOST_STATUS)&HOST_STATUS_CRR));
-	outb(1<<6, ioaddr+HOST_CMD);	
-
-	save_flags(flags);
-	cli();
+	mc32_ready_poll(dev);
+	outb(1<<6, ioaddr+HOST_CMD);
 
-	while(lp->exec_pending!=2)
-		sleep_on(&lp->event);
-	lp->exec_pending=0;
-	restore_flags(flags);
+	wait_for_completion(&lp->execution_cmd);
 	
 	if(lp->exec_box->mbox&(1<<13))
 		ret = -1;
 
+	up(&lp->cmd_mutex);
+
 	/*
-	 *	A multicast set got blocked - do it now
-	 */
-		
+	 *	A multicast set got blocked - try it now
+         */
+
 	if(lp->mc_reload_wait)
 	{
 		mc32_reset_multicast_list(dev);
@@ -678,11 +657,9 @@ static int mc32_command(struct net_devic
  *	This may be called from the interrupt state, where it is used
  *	to restart the rx ring if the card runs out of rx buffers. 
  *	
- * 	First, we check if it's ok to start the transceiver. We then show
- * 	the card where to start in the rx ring and issue the
- * 	commands to start reception and transmission. We don't wait
- * 	around for these to complete.
- */ 
+ * 	We must first check if it's ok to (re)start the transceiver. See
+ *      mc32_close for details.
+ */
 
 static void mc32_start_transceiver(struct net_device *dev) {
 
@@ -690,24 +667,20 @@ static void mc32_start_transceiver(struc
 	int ioaddr = dev->base_addr;
 
 	/* Ignore RX overflow on device closure */ 
-	if (lp->desired_state==HALTED)  
+	if (lp->xceiver_desired_state==HALTED)
 		return; 
 
+	/* Give the card the offset to the post-EOL-bit RX descriptor */
 	mc32_ready_poll(dev); 
-
-	lp->tx_box->mbox=0;
 	lp->rx_box->mbox=0;
-
-	/* Give the card the offset to the post-EOL-bit RX descriptor */ 
 	lp->rx_box->data[0]=lp->rx_ring[prev_rx(lp->rx_ring_tail)].p->next; 
-
 	outb(HOST_CMD_START_RX, ioaddr+HOST_CMD);      
 
 	mc32_ready_poll(dev); 
+	lp->tx_box->mbox=0;
 	outb(HOST_CMD_RESTRT_TX, ioaddr+HOST_CMD);   /* card ignores this on RX restart */ 
 	
 	/* We are not interrupted on start completion */ 
-	lp->xceiver_state=RUNNING; 
 }
 
 
@@ -727,25 +700,17 @@ static void mc32_halt_transceiver(struct
 {
 	struct mc32_local *lp = (struct mc32_local *)dev->priv;
 	int ioaddr = dev->base_addr;
-	unsigned long flags;
 
 	mc32_ready_poll(dev);	
-
-	lp->tx_box->mbox=0;
 	lp->rx_box->mbox=0;
-
 	outb(HOST_CMD_SUSPND_RX, ioaddr+HOST_CMD);			
+	wait_for_completion(&lp->xceiver_cmd);
+
 	mc32_ready_poll(dev); 
+	lp->tx_box->mbox=0;
 	outb(HOST_CMD_SUSPND_TX, ioaddr+HOST_CMD);	
-		
-	save_flags(flags);
-	cli();
-		
-	while(lp->xceiver_state!=HALTED) 
-		sleep_on(&lp->event); 
-		
-	restore_flags(flags);	
-} 
+	wait_for_completion(&lp->xceiver_cmd);
+}
 
 
 /**
@@ -756,7 +721,7 @@ static void mc32_halt_transceiver(struct
  *	the point where mc32_start_transceiver() can be called.
  *
  *	The card sets up the receive ring for us. We are required to use the
- *	ring it provides although we can change the size of the ring.
+ *	ring it provides, although the size of the ring is configurable.
  *
  * 	We allocate an sk_buff for each ring entry in turn and
  * 	initalise its house-keeping info. At the same time, we read
@@ -777,7 +742,7 @@ static int mc32_load_rx_ring(struct net_
 	
 	rx_base=lp->rx_chain;
 
-	for(i=0;i<RX_RING_LEN;i++)
+	for(i=0; i<RX_RING_LEN; i++)
 	{
 		lp->rx_ring[i].skb=alloc_skb(1532, GFP_KERNEL);
 		skb_reserve(lp->rx_ring[i].skb, 18);  
@@ -814,21 +779,19 @@ static int mc32_load_rx_ring(struct net_
  *
  *	Free the buffer for each ring slot. This may be called 
  *      before mc32_load_rx_ring(), eg. on error in mc32_open().
+ *      Requires rx skb pointers to point to a valid skb, or NULL.
  */
 
 static void mc32_flush_rx_ring(struct net_device *dev)
 {
 	struct mc32_local *lp = (struct mc32_local *)dev->priv;
-	
-	struct sk_buff *skb;
 	int i; 
 
 	for(i=0; i < RX_RING_LEN; i++) 
 	{ 
-		skb = lp->rx_ring[i].skb;
-		if (skb!=NULL) {
-			kfree_skb(skb);
-			skb=NULL; 
+		if (lp->rx_ring[i].skb) {
+			dev_kfree_skb(lp->rx_ring[i].skb);
+			lp->rx_ring[i].skb = NULL;
 		}
 		lp->rx_ring[i].p=NULL; 
 	} 
@@ -860,7 +823,7 @@ static void mc32_load_tx_ring(struct net
 
 	tx_base=lp->tx_box->data[0]; 
 
-	for(i=0;i<lp->tx_len;i++) 
+	for(i=0 ; i<TX_RING_LEN ; i++)
 	{
 		p=isa_bus_to_virt(lp->base+tx_base);
 		lp->tx_ring[i].p=p; 
@@ -869,11 +832,12 @@ static void mc32_load_tx_ring(struct net
 		tx_base=p->next;
 	}
 
-	/* -1 so that tx_ring_head cannot "lap" tx_ring_tail,           */
-	/* which would be bad news for mc32_tx_ring as cur. implemented */ 
+	/* -1 so that tx_ring_head cannot "lap" tx_ring_tail */
+	/* see mc32_tx_ring */
 
 	atomic_set(&lp->tx_count, TX_RING_LEN-1); 
-	lp->tx_ring_head=lp->tx_ring_tail=0; 
+	atomic_set(&lp->tx_ring_head, 0); 
+	lp->tx_ring_tail=0; 
 } 
 
 
@@ -881,47 +845,29 @@ static void mc32_load_tx_ring(struct net
  *	mc32_flush_tx_ring 	-	free transmit ring
  *	@lp: Local data of 3c527 to flush the tx ring of
  *
- *	We have to consider two cases here. We want to free the pending
- *	buffers only. If the ring buffer head is past the start then the
- *	ring segment we wish to free wraps through zero. The tx ring 
- *	house-keeping variables are then reset.
+ *      If the ring is non-empty, zip over the it, freeing any
+ *      allocated skb_buffs.  The tx ring house-keeping variables are
+ *      then reset. Requires rx skb pointers to point to a valid skb,
+ *      or NULL.
  */
 
 static void mc32_flush_tx_ring(struct net_device *dev)
 {
 	struct mc32_local *lp = (struct mc32_local *)dev->priv;
-	
-	if(lp->tx_ring_tail!=lp->tx_ring_head)
+	int i;
+
+	for (i=0; i < TX_RING_LEN; i++)
 	{
-		int i;	
-		if(lp->tx_ring_tail < lp->tx_ring_head)
+		if (lp->tx_ring[i].skb)
 		{
-			for(i=lp->tx_ring_tail;i<lp->tx_ring_head;i++)
-			{
-				dev_kfree_skb(lp->tx_ring[i].skb);
-				lp->tx_ring[i].skb=NULL;
-				lp->tx_ring[i].p=NULL; 
-			}
-		}
-		else
-		{
-			for(i=lp->tx_ring_tail; i<TX_RING_LEN; i++) 
-			{
-				dev_kfree_skb(lp->tx_ring[i].skb);
-				lp->tx_ring[i].skb=NULL;
-				lp->tx_ring[i].p=NULL; 
-			}
-			for(i=0; i<lp->tx_ring_head; i++) 
-			{
-				dev_kfree_skb(lp->tx_ring[i].skb);
-				lp->tx_ring[i].skb=NULL;
-				lp->tx_ring[i].p=NULL; 
-			}
+			dev_kfree_skb(lp->tx_ring[i].skb);
+			lp->tx_ring[i].skb = NULL;
 		}
 	}
-	
+
 	atomic_set(&lp->tx_count, 0); 
-	lp->tx_ring_tail=lp->tx_ring_head=0;
+	atomic_set(&lp->tx_ring_head, 0); 
+	lp->tx_ring_tail=0;
 }
  	
 
@@ -958,6 +904,12 @@ static int mc32_open(struct net_device *
 	regs|=HOST_CTRL_INTE;
 	outb(regs, ioaddr+HOST_CTRL);
 	
+	/*
+	 *      Allow ourselves to issue commands
+	 */
+
+	up(&lp->cmd_mutex);
+
 
 	/*
 	 *	Send the indications on command
@@ -1010,7 +962,7 @@ static int mc32_open(struct net_device *
 		return -ENOBUFS;
 	}
 
-	lp->desired_state = RUNNING; 
+	lp->xceiver_desired_state = RUNNING;
 	
 	/* And finally, set the ball rolling... */
 	mc32_start_transceiver(dev);
@@ -1047,61 +999,64 @@ static void mc32_timeout(struct net_devi
  *	Transmit a buffer. This normally means throwing the buffer onto
  *	the transmit queue as the queue is quite large. If the queue is
  *	full then we set tx_busy and return. Once the interrupt handler
- *	gets messages telling it to reclaim transmit queue entries we will
+ *	gets messages telling it to reclaim transmit queue entries, we will
  *	clear tx_busy and the kernel will start calling this again.
  *
- *	We use cli rather than spinlocks. Since I have no access to an SMP
- *	MCA machine I don't plan to change it. It is probably the top 
- *	performance hit for this driver on SMP however.
+ *      We do not disable interrupts or acquire any locks; this can
+ *      run concurrently with mc32_tx_ring(), and the function itself
+ *      is serialised at a higher layer. However, similarly for the
+ *      card itself, we must ensure that we update tx_ring_head only
+ *      after we've established a valid packet on the tx ring (and
+ *      before we let the card "see" it, to prevent it racing with the
+ *      irq handler).
+ * 
  */
 
 static int mc32_send_packet(struct sk_buff *skb, struct net_device *dev)
 {
 	struct mc32_local *lp = (struct mc32_local *)dev->priv;
-	unsigned long flags;
-
+	u32 head = atomic_read(&lp->tx_ring_head);
+	
 	volatile struct skb_header *p, *np;
 
 	netif_stop_queue(dev);
 
-	save_flags(flags);
-	cli();
-		
-	if(atomic_read(&lp->tx_count)==0)
-	{
-		restore_flags(flags);
+	if(atomic_read(&lp->tx_count)==0) {
 		return 1;
 	}
 
+	skb = skb_padto(skb, ETH_ZLEN);
+	if (skb == NULL) {
+		netif_wake_queue(dev);
+		return 0;
+	}
+
 	atomic_dec(&lp->tx_count); 
 
 	/* P is the last sending/sent buffer as a pointer */
-	p=lp->tx_ring[lp->tx_ring_head].p; 
+	p=lp->tx_ring[head].p;
 		
-	lp->tx_ring_head=next_tx(lp->tx_ring_head); 
+	head = next_tx(head);
 
 	/* NP is the buffer we will be loading */
-	np=lp->tx_ring[lp->tx_ring_head].p; 
-
-   	if (skb->len < ETH_ZLEN) {
-   		skb = skb_padto(skb, ETH_ZLEN);
-   		if (skb == NULL)
-   			goto out;
-   	}
-
+	np=lp->tx_ring[head].p; 
+	
 	/* We will need this to flush the buffer out */
-	lp->tx_ring[lp->tx_ring_head].skb = skb;
-   	   
-	np->length = (skb->len < ETH_ZLEN) ? ETH_ZLEN : skb->len; 
-			
+	lp->tx_ring[head].skb=skb;
+
+	np->length      = unlikely(skb->len < ETH_ZLEN) ? ETH_ZLEN : skb->len;			
 	np->data	= isa_virt_to_bus(skb->data);
 	np->status	= 0;
 	np->control     = CONTROL_EOP | CONTROL_EOL;     
 	wmb();
 		
-	p->control     &= ~CONTROL_EOL;     /* Clear EOL on p */ 
-out:	
-	restore_flags(flags);
+	/*
+	 * The new frame has been setup; we can now
+	 * let the interrupt handler and card "see" it
+	 */
+
+	atomic_set(&lp->tx_ring_head, head); 
+	p->control     &= ~CONTROL_EOL;
 
 	netif_wake_queue(dev);
 	return 0;
@@ -1182,10 +1137,11 @@ static void mc32_rx_ring(struct net_devi
 {
 	struct mc32_local *lp=dev->priv;		
 	volatile struct skb_header *p;
-	u16 rx_ring_tail = lp->rx_ring_tail;
-	u16 rx_old_tail = rx_ring_tail; 
-
+	u16 rx_ring_tail;
+	u16 rx_old_tail;
 	int x=0;
+
+	rx_old_tail = rx_ring_tail = lp->rx_ring_tail;
 	
 	do
 	{ 
@@ -1275,9 +1231,14 @@ static void mc32_tx_ring(struct net_devi
 	struct mc32_local *lp=(struct mc32_local *)dev->priv;
 	volatile struct skb_header *np;
 
-	/* NB: lp->tx_count=TX_RING_LEN-1 so that tx_ring_head cannot "lap" tail here */
+	/*
+	 * We rely on head==tail to mean 'queue empty'.
+	 * This is why lp->tx_count=TX_RING_LEN-1: in order to prevent
+	 * tx_ring_head wrapping to tail and confusing a 'queue empty'
+	 * condition with 'queue full'
+	 */
 
-	while (lp->tx_ring_tail != lp->tx_ring_head)  
+	while (lp->tx_ring_tail != atomic_read(&lp->tx_ring_head))  
 	{   
 		u16 t; 
 
@@ -1388,8 +1349,7 @@ static irqreturn_t mc32_interrupt(int ir
 				break;
 			case 3: /* Halt */
 			case 4: /* Abort */
-				lp->xceiver_state |= TX_HALTED; 
-				wake_up(&lp->event);
+				complete(&lp->xceiver_cmd);
 				break;
 			default:
 				printk("%s: strange tx ack %d\n", dev->name, status&7);
@@ -1404,8 +1364,7 @@ static irqreturn_t mc32_interrupt(int ir
 				break;
 			case 3: /* Halt */
 			case 4: /* Abort */
-				lp->xceiver_state |= RX_HALTED;
-				wake_up(&lp->event);
+				complete(&lp->xceiver_cmd);
 				break;
 			case 6:
 				/* Out of RX buffers stat */
@@ -1421,26 +1380,17 @@ static irqreturn_t mc32_interrupt(int ir
 		status>>=3;
 		if(status&1)
 		{
-
-			/* 0=no 1=yes 2=replied, get cmd, 3 = wait reply & dump it */
-			
-			if(lp->exec_pending!=3) {
-				lp->exec_pending=2;
-				wake_up(&lp->event);
-			}
-			else 
-			{				
-			  	lp->exec_pending=0;
-
-				/* A new multicast set may have been
-				   blocked while the old one was
-				   running. If so, do it now. */
+			/*
+			 * No thread is waiting: we need to tidy
+			 * up ourself.
+			 */
 				   
+			if (lp->cmd_nonblocking) {
+				up(&lp->cmd_mutex);
 				if (lp->mc_reload_wait) 
 					mc32_reset_multicast_list(dev);
-				else 
-					wake_up(&lp->event);			       
 			}
+			else complete(&lp->execution_cmd);
 		}
 		if(status&2)
 		{
@@ -1493,12 +1443,12 @@ static irqreturn_t mc32_interrupt(int ir
 static int mc32_close(struct net_device *dev)
 {
 	struct mc32_local *lp = (struct mc32_local *)dev->priv;
-
 	int ioaddr = dev->base_addr;
+
 	u8 regs;
 	u16 one=1;
 	
-	lp->desired_state = HALTED;
+	lp->xceiver_desired_state = HALTED;
 	netif_stop_queue(dev);
 
 	/*
@@ -1511,11 +1461,10 @@ static int mc32_close(struct net_device 
 
 	mc32_halt_transceiver(dev); 
 	
-	/* Catch any waiting commands */
+	/* Ensure we issue no more commands beyond this point */
+
+	down(&lp->cmd_mutex);
 	
-	while(lp->exec_pending==1)
-		sleep_on(&lp->event);
-	       
 	/* Ok the card is now stopping */	
 	
 	regs=inb(ioaddr+HOST_CTRL);
@@ -1542,12 +1491,9 @@ static int mc32_close(struct net_device 
 
 static struct net_device_stats *mc32_get_stats(struct net_device *dev)
 {
-	struct mc32_local *lp;
+	struct mc32_local *lp = (struct mc32_local *)dev->priv;
 	
 	mc32_update_stats(dev); 
-
-	lp = (struct mc32_local *)dev->priv;
-
 	return &lp->net_stats;
 }
 
diff -puN drivers/net/3c527.h~linus drivers/net/3c527.h
--- 25/drivers/net/3c527.h~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/net/3c527.h	2004-01-19 22:17:22.000000000 -0800
@@ -27,10 +27,8 @@
 
 #define HOST_RAMPAGE		8
 
-#define RX_HALTED (1<<0)
-#define TX_HALTED (1<<1)  
-#define HALTED (RX_HALTED | TX_HALTED)
-#define RUNNING 0
+#define HALTED 0
+#define RUNNING 1
 
 struct mc32_mailbox
 {
diff -puN drivers/net/3c59x.c~linus drivers/net/3c59x.c
--- 25/drivers/net/3c59x.c~linus	2004-01-19 22:17:05.000000000 -0800
+++ 25-akpm/drivers/net/3c59x.c	2004-01-19 22:17:22.000000000 -0800
@@ -211,11 +211,11 @@
 /* Set the copy breakpoint for the copy-only-tiny-frames scheme.
    Setting to > 1512 effectively disables this feature. */
 #ifndef __arm__
-static const int rx_copybreak = 200;
+static int rx_copybreak = 200;
 #else
 /* ARM systems perform better by disregarding the bus-master
    transfer capability of these cards. -- rmk */
-static const int rx_copybreak = 1513;
+static int rx_copybreak = 1513;
 #endif
 /* Allow setting MTU to a larger size, bypassing the normal ethernet setup. */
 static const int mtu = 1500;
diff -puN -L drivers/net/68360enet.c drivers/net/68360enet.c~linus /dev/null
--- 25/drivers/net/68360enet.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,951 +0,0 @@
-/*
- * Ethernet driver for Motorola MPC8xx.
- * Copyright (c) 2000 Michael Leslie <mleslie@lineo.com>
- * Copyright (c) 1997 Dan Malek (dmalek@jlc.net)
- *
- * I copied the basic skeleton from the lance driver, because I did not
- * know how to write the Linux driver, but I did know how the LANCE worked.
- *
- * This version of the driver is somewhat selectable for the different
- * processor/board combinations.  It works for the boards I know about
- * now, and should be easily modified to include others.  Some of the
- * configuration information is contained in "commproc.h" and the
- * remainder is here.
- *
- * Buffer descriptors are kept in the CPM dual port RAM, and the frame
- * buffers are in the host memory.
- *
- * Right now, I am very watseful with the buffers.  I allocate memory
- * pages and then divide them into 2K frame buffers.  This way I know I
- * have buffers large enough to hold one frame within one buffer descriptor.
- * Once I get this working, I will use 64 or 128 byte CPM buffers, which
- * will be much more memory efficient and will easily handle lots of
- * small packets.
- *
- */
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/ptrace.h>
-#include <linux/errno.h>
-#include <linux/ioport.h>
-#include <linux/interrupt.h>
-#include <linux/pci.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/skbuff.h>
-#include <linux/spinlock.h> 
-
-#include <asm/irq.h>
-#include <asm/m68360.h>
-/* #include <asm/8xx_immap.h> */
-/* #include <asm/pgtable.h> */
-/* #include <asm/mpc8xx.h> */
-#include <asm/bitops.h>
-/* #include <asm/uaccess.h> */
-#include <asm/commproc.h>
-
-
-/*
- *				Theory of Operation
- *
- * The MPC8xx CPM performs the Ethernet processing on SCC1.  It can use
- * an aribtrary number of buffers on byte boundaries, but must have at
- * least two receive buffers to prevent constant overrun conditions.
- *
- * The buffer descriptors are allocated from the CPM dual port memory
- * with the data buffers allocated from host memory, just like all other
- * serial communication protocols.  The host memory buffers are allocated
- * from the free page pool, and then divided into smaller receive and
- * transmit buffers.  The size of the buffers should be a power of two,
- * since that nicely divides the page.  This creates a ring buffer
- * structure similar to the LANCE and other controllers.
- *
- * Like the LANCE driver:
- * The driver runs as two independent, single-threaded flows of control.  One
- * is the send-packet routine, which enforces single-threaded use by the
- * cep->tx_busy flag.  The other thread is the interrupt handler, which is
- * single threaded by the hardware and other software.
- *
- * The send packet thread has partial control over the Tx ring and the
- * 'cep->tx_busy' flag.  It sets the tx_busy flag whenever it's queuing a Tx
- * packet. If the next queue slot is empty, it clears the tx_busy flag when
- * finished otherwise it sets the 'lp->tx_full' flag.
- *
- * The MBX has a control register external to the MPC8xx that has some
- * control of the Ethernet interface.  Information is in the manual for
- * your board.
- *
- * The RPX boards have an external control/status register.  Consult the
- * programming documents for details unique to your board.
- *
- * For the TQM8xx(L) modules, there is no control register interface.
- * All functions are directly controlled using I/O pins.  See commproc.h.
- */
-
-
-/* The transmitter timeout
- */
-#define TX_TIMEOUT	(2*HZ)
-
-/* The number of Tx and Rx buffers.  These are allocated statically here.
- * We don't need to allocate pages for the transmitter.  We just use
- * the skbuffer directly.
- */
-#ifdef CONFIG_ENET_BIG_BUFFERS
-#define RX_RING_SIZE		64
-#define TX_RING_SIZE		64	/* Must be power of two */
-#define TX_RING_MOD_MASK	63	/*   for this to work */
-#else
-#define RX_RING_SIZE		8
-#define TX_RING_SIZE		8	/* Must be power of two */
-#define TX_RING_MOD_MASK	7	/*   for this to work */
-#endif
-
-#define CPM_ENET_RX_FRSIZE  2048 /* overkill left over from ppc page-based allocation */
-static char rx_buf_pool[RX_RING_SIZE * CPM_ENET_RX_FRSIZE];
-
-
-/* The CPM stores dest/src/type, data, and checksum for receive packets.
- */
-#define PKT_MAXBUF_SIZE		1518
-#define PKT_MINBUF_SIZE		64
-#define PKT_MAXBLR_SIZE		1520
-
-/* The CPM buffer descriptors track the ring buffers.  The rx_bd_base and
- * tx_bd_base always point to the base of the buffer descriptors.  The
- * cur_rx and cur_tx point to the currently available buffer.
- * The dirty_tx tracks the current buffer that is being sent by the
- * controller.  The cur_tx and dirty_tx are equal under both completely
- * empty and completely full conditions.  The empty/ready indicator in
- * the buffer descriptor determines the actual condition.
- */
-struct scc_enet_private {
-	/* The saved address of a sent-in-place packet/buffer, for skfree(). */
-	struct	sk_buff* tx_skbuff[TX_RING_SIZE];
-	ushort	skb_cur;
-	ushort	skb_dirty;
-
-	/* CPM dual port RAM relative addresses.
-	*/
-	QUICC_BD	*rx_bd_base;		/* Address of Rx and Tx buffers. */
-	QUICC_BD	*tx_bd_base;
-	QUICC_BD	*cur_rx, *cur_tx;		/* The next free ring entry */
-	QUICC_BD	*dirty_tx;	/* The ring entries to be free()ed. */
-	volatile struct scc_regs	*sccp;
-	/* struct	net_device_stats stats; */
-	struct	net_device_stats stats;
-	uint	tx_full;
-	/* spinlock_t lock; */
-	volatile unsigned int lock;
-};
-
-
-
-static int scc_enet_open(struct net_device *dev);
-static int scc_enet_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static int scc_enet_rx(struct net_device *dev);
-static irqreturn_t scc_enet_interrupt(int vec, void *dev_id, struct pt_regs *fp);
-static int scc_enet_close(struct net_device *dev);
-/* static struct net_device_stats *scc_enet_get_stats(struct net_device *dev); */
-static struct net_device_stats *scc_enet_get_stats(struct net_device *dev);
-static void set_multicast_list(struct net_device *dev);
-
-/* Get this from various configuration locations (depends on board).
-*/
-/*static	ushort	my_enet_addr[] = { 0x0800, 0x3e26, 0x1559 };*/
-
-/* Typically, 860(T) boards use SCC1 for Ethernet, and other 8xx boards
- * use SCC2.  This is easily extended if necessary.
- */
-
-#define CONFIG_SCC1_ENET /* by default */
-
-#ifdef CONFIG_SCC1_ENET
-#define CPM_CR_ENET CPM_CR_CH_SCC1
-#define PROFF_ENET	PROFF_SCC1
-#define SCC_ENET	0
-#define CPMVEC_ENET	CPMVEC_SCC1
-#endif
-
-#ifdef CONFIG_SCC2_ENET
-#define CPM_CR_ENET	CPM_CR_CH_SCC2
-#define PROFF_ENET	PROFF_SCC2
-#define SCC_ENET	1		/* Index, not number! */
-#define CPMVEC_ENET	CPMVEC_SCC2
-#endif
-
-static int
-scc_enet_open(struct net_device *dev)
-{
-
-	/* I should reset the ring buffers here, but I don't yet know
-	 * a simple way to do that.
-	 * mleslie: That's no biggie. Worth doing, too.
-	 */
-
-	/* netif_start_queue(dev); */
-	return 0;					/* Always succeed */
-}
-
-
-static int
-scc_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
-{
-	struct scc_enet_private *cep = (struct scc_enet_private *)dev->priv;
-	volatile QUICC_BD	*bdp;
-
-	/* Fill in a Tx ring entry */
-	bdp = cep->cur_tx;
-
-#ifndef final_version
-	if (bdp->status & BD_ENET_TX_READY) {
-		/* Ooops.  All transmit buffers are full.  Bail out.
-		 * This should not happen, since cep->tx_busy should be set.
-		 */
-		printk("%s: tx queue full!.\n", dev->name);
-		return 1;
-	}
-#endif
-
-	/* Clear all of the status flags.
-	 */
-	bdp->status &= ~BD_ENET_TX_STATS;
-
-	/* If the frame is short, tell CPM to pad it.
-	*/
-	if (skb->len <= ETH_ZLEN)
-		bdp->status |= BD_ENET_TX_PAD;
-	else
-		bdp->status &= ~BD_ENET_TX_PAD;
-
-	/* Set buffer length and buffer pointer.
-	*/
-	bdp->length = skb->len;
-	/* bdp->buf = __pa(skb->data); */
-	bdp->buf = skb->data;
-
-	/* Save skb pointer.
-	*/
-	cep->tx_skbuff[cep->skb_cur] = skb;
-
-	/* cep->stats.tx_bytes += skb->len; */ /* TODO: It would really be nice... */
-
-	cep->skb_cur = (cep->skb_cur+1) & TX_RING_MOD_MASK;
-	
-
-	/* Push the data cache so the CPM does not get stale memory
-	 * data.
-	 */
-/* 	flush_dcache_range((unsigned long)(skb->data), */
-/* 					(unsigned long)(skb->data + skb->len)); */
-
-	/* spin_lock_irq(&cep->lock); */ /* TODO: SPINLOCK */
-	local_irq_disable();
-	if (cep->lock > 0) {
-		printk ("scc_enet_start_xmit() lock == %d\n", cep->lock);
-	} else {
-		cep->lock++;
-	}
-
-	/* Send it on its way.  Tell CPM its ready, interrupt when done,
-	 * its the last BD of the frame, and to put the CRC on the end.
-	 */
-	bdp->status |= (BD_ENET_TX_READY | BD_ENET_TX_INTR | BD_ENET_TX_LAST | BD_ENET_TX_TC);
-
-	dev->trans_start = jiffies;
-
-	/* If this was the last BD in the ring, start at the beginning again.
-	*/
-	if (bdp->status & BD_ENET_TX_WRAP)
-		bdp = cep->tx_bd_base;
-	else
-		bdp++;
-
-	if (bdp->status & BD_ENET_TX_READY) {
-		/* netif_stop_queue(dev); */
-		cep->tx_full = 1;
-	}
-
-	cep->cur_tx = (QUICC_BD *)bdp;
-
-	/* spin_unlock_irq(&cep->lock); */ /* TODO: SPINLOCK */
-	cep->lock--;
-	sti();
-
-	return 0;
-}
-
-#if 0
-static void
-scc_enet_timeout(struct net_device *dev)
-{
-	struct scc_enet_private *cep = (struct scc_enet_private *)dev->priv;
-
-	printk("%s: transmit timed out.\n", dev->name);
-	cep->stats.tx_errors++;
-#ifndef final_version
-	{
-		int	i;
-		QUICC_BD	*bdp;
-		printk(" Ring data dump: cur_tx %p%s cur_rx %p.\n",
-		       cep->cur_tx, cep->tx_full ? " (full)" : "",
-		       cep->cur_rx);
-		bdp = cep->tx_bd_base;
-		for (i = 0 ; i < TX_RING_SIZE; i++, bdp++)
-			printk("%04x %04x %08x\n",
-			       bdp->status,
-			       bdp->length,
-			       (int)(bdp->buf));
-		bdp = cep->rx_bd_base;
-		for (i = 0 ; i < RX_RING_SIZE; i++, bdp++)
-			printk("%04x %04x %08x\n",
-			       bdp->status,
-			       bdp->length,
-			       (int)(bdp->buf));
-	}
-#endif
-/* 	if (!cep->tx_full) */
-/* 		netif_wake_queue(dev); */
-}
-#endif
-
-/* The interrupt handler.
- * This is called from the CPM handler, not the MPC core interrupt.
- */
-static irqreturn_t scc_enet_interrupt(int vec, void *dev_id, struct pt_regs *fp)
-{
-	struct	net_device *dev = (struct net_device *)dev_id;
-	volatile struct	scc_enet_private *cep;
-	volatile QUICC_BD	*bdp;
-	ushort	int_events;
-	int	must_restart;
-
-	cep = (struct scc_enet_private *)dev->priv;
-
-	/* Get the interrupt events that caused us to be here.
-	*/
-	int_events = cep->sccp->scc_scce;
-	cep->sccp->scc_scce = int_events;
-	must_restart = 0;
-
-	/* Handle receive event in its own function.
-	*/
-	if (int_events & SCCE_ENET_RXF)
-		scc_enet_rx(dev_id);
-
-	/* Check for a transmit error.  The manual is a little unclear
-	 * about this, so the debug code until I get it figured out.  It
-	 * appears that if TXE is set, then TXB is not set.  However,
-	 * if carrier sense is lost during frame transmission, the TXE
-	 * bit is set, "and continues the buffer transmission normally."
-	 * I don't know if "normally" implies TXB is set when the buffer
-	 * descriptor is closed.....trial and error :-).
-	 */
-
-	/* Transmit OK, or non-fatal error.  Update the buffer descriptors.
-	*/
-	if (int_events & (SCCE_ENET_TXE | SCCE_ENET_TXB)) {
-	    /* spin_lock(&cep->lock); */ /* TODO: SPINLOCK */
-		/* local_irq_disable(); */
-		if (cep->lock > 0) {
-			printk ("scc_enet_interrupt() lock == %d\n", cep->lock);
-		} else {
-			cep->lock++;
-		}
-
-	    bdp = cep->dirty_tx;
-	    while ((bdp->status&BD_ENET_TX_READY)==0) {
-		if ((bdp==cep->cur_tx) && (cep->tx_full == 0))
-		    break;
-
-		if (bdp->status & BD_ENET_TX_HB)	/* No heartbeat */
-			cep->stats.tx_heartbeat_errors++;
-		if (bdp->status & BD_ENET_TX_LC)	/* Late collision */
-			cep->stats.tx_window_errors++;
-		if (bdp->status & BD_ENET_TX_RL)	/* Retrans limit */
-			cep->stats.tx_aborted_errors++;
-		if (bdp->status & BD_ENET_TX_UN)	/* Underrun */
-			cep->stats.tx_fifo_errors++;
-		if (bdp->status & BD_ENET_TX_CSL)	/* Carrier lost */
-			cep->stats.tx_carrier_errors++;
-
-
-		/* No heartbeat or Lost carrier are not really bad errors.
-		 * The others require a restart transmit command.
-		 */
-		if (bdp->status &
-		    (BD_ENET_TX_LC | BD_ENET_TX_RL | BD_ENET_TX_UN)) {
-			must_restart = 1;
-			cep->stats.tx_errors++;
-		}
-
-		cep->stats.tx_packets++;
-
-		/* Deferred means some collisions occurred during transmit,
-		 * but we eventually sent the packet OK.
-		 */
-		if (bdp->status & BD_ENET_TX_DEF)
-			cep->stats.collisions++;
-
-		/* Free the sk buffer associated with this last transmit.
-		*/
-		/* dev_kfree_skb_irq(cep->tx_skbuff[cep->skb_dirty]); */
-		dev_kfree_skb (cep->tx_skbuff[cep->skb_dirty]);
-		cep->skb_dirty = (cep->skb_dirty + 1) & TX_RING_MOD_MASK;
-
-		/* Update pointer to next buffer descriptor to be transmitted.
-		*/
-		if (bdp->status & BD_ENET_TX_WRAP)
-			bdp = cep->tx_bd_base;
-		else
-			bdp++;
-
-		/* I don't know if we can be held off from processing these
-		 * interrupts for more than one frame time.  I really hope
-		 * not.  In such a case, we would now want to check the
-		 * currently available BD (cur_tx) and determine if any
-		 * buffers between the dirty_tx and cur_tx have also been
-		 * sent.  We would want to process anything in between that
-		 * does not have BD_ENET_TX_READY set.
-		 */
-
-		/* Since we have freed up a buffer, the ring is no longer
-		 * full.
-		 */
-		if (cep->tx_full) {
-			cep->tx_full = 0;
-/* 			if (netif_queue_stopped(dev)) */
-/* 				netif_wake_queue(dev); */
-		}
-
-		cep->dirty_tx = (QUICC_BD *)bdp;
-	    }
-
-	    if (must_restart) {
-			volatile QUICC *cp;
-
-		/* Some transmit errors cause the transmitter to shut
-		 * down.  We now issue a restart transmit.  Since the
-		 * errors close the BD and update the pointers, the restart
-		 * _should_ pick up without having to reset any of our
-		 * pointers either.
-		 */
-		cp = pquicc;
-		cp->cp_cr =
-		    mk_cr_cmd(CPM_CR_ENET, CPM_CR_RESTART_TX) | CPM_CR_FLG;
-		while (cp->cp_cr & CPM_CR_FLG);
-	    }
-	    /* spin_unlock(&cep->lock); */ /* TODO: SPINLOCK */
-		/* sti(); */
-		cep->lock--;
-	}
-
-	/* 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.
-	 */
-	if (int_events & SCCE_ENET_BSY) {
-		cep->stats.rx_dropped++;
-		printk("CPM ENET: BSY can't happen.\n");
-	}
-
-	return IRQ_HANDLED;
-}
-
-/* During a receive, the cur_rx points to the current incoming buffer.
- * When we update through the ring, if the next incoming buffer has
- * not been given to the system, we just set the empty indicator,
- * effectively tossing the packet.
- */
-static int
-scc_enet_rx(struct net_device *dev)
-{
-	struct	scc_enet_private *cep;
-	volatile QUICC_BD	*bdp;
-	struct	sk_buff *skb;
-	ushort	pkt_len;
-
-	cep = (struct scc_enet_private *)dev->priv;
-
-	/* First, grab all of the stats for the incoming packet.
-	 * These get messed up if we get called due to a busy condition.
-	 */
-	bdp = cep->cur_rx;
-
-	for (;;) {
-		if (bdp->status & BD_ENET_RX_EMPTY)
-			break;
-		
-#ifndef final_version
-		/* Since we have allocated space to hold a complete frame, both
-		 * the first and last indicators should be set.
-		 */
-		if ((bdp->status & (BD_ENET_RX_FIRST | BD_ENET_RX_LAST)) !=
-			(BD_ENET_RX_FIRST | BD_ENET_RX_LAST))
-			printk("CPM ENET: rcv is not first+last\n");
-#endif
-
-		/* Frame too long or too short.
-		 */
-		if (bdp->status & (BD_ENET_RX_LG | BD_ENET_RX_SH))
-			cep->stats.rx_length_errors++;
-		if (bdp->status & BD_ENET_RX_NO)	/* Frame alignment */
-			cep->stats.rx_frame_errors++;
-		if (bdp->status & BD_ENET_RX_CR)	/* CRC Error */
-			cep->stats.rx_crc_errors++;
-		if (bdp->status & BD_ENET_RX_OV)	/* FIFO overrun */
-			cep->stats.rx_crc_errors++;
-
-		/* Report late collisions as a frame error.
-		 * On this error, the BD is closed, but we don't know what we
-		 * have in the buffer.  So, just drop this frame on the floor.
-		 */
-		if (bdp->status & BD_ENET_RX_CL) {
-			cep->stats.rx_frame_errors++;
-		}
-		else {
-			
-			/* Process the incoming frame.
-			 */
-			cep->stats.rx_packets++;
-			pkt_len = bdp->length;
-			/* cep->stats.rx_bytes += pkt_len; */  /* TODO: It would really be nice... */
-
-			/* This does 16 byte alignment, much more than we need.
-			 * The packet length includes FCS, but we don't want to
-			 * include that when passing upstream as it messes up
-			 * bridging applications.
-			 */
-			skb = dev_alloc_skb(pkt_len-4);
-
-			if (skb == NULL) {
-				printk("%s: Memory squeeze, dropping packet.\n", dev->name);
-				cep->stats.rx_dropped++;
-			}
-			else {
-				skb->dev = dev;
-				skb_put(skb,pkt_len-4);	/* Make room */
-				eth_copy_and_sum(skb, (unsigned char *)bdp->buf, pkt_len-4, 0);
-				skb->protocol=eth_type_trans(skb,dev);
-				netif_rx(skb);
-			}
-		}
-
-		/* Clear the status flags for this buffer.
-		 */
-		bdp->status &= ~BD_ENET_RX_STATS;
-
-		/* Mark the buffer empty.
-		 */
-		bdp->status |= BD_ENET_RX_EMPTY;
-
-		/* Update BD pointer to next entry.
-		 */
-		if (bdp->status & BD_ENET_RX_WRAP)
-			bdp = cep->rx_bd_base;
-		else
-			bdp++;
-
-	}
-	cep->cur_rx = (QUICC_BD *)bdp;
-
-	return 0;
-}
-
-static int
-scc_enet_close(struct net_device *dev)
-{
-	/* Don't know what to do yet.
-	*/
-	/* netif_stop_queue(dev); */
-
-	return 0;
-}
-
-/* static struct net_device_stats *scc_enet_get_stats(struct net_device *dev) */
-static struct net_device_stats *scc_enet_get_stats(struct net_device *dev)
-{
-	struct scc_enet_private *cep = (struct scc_enet_private *)dev->priv;
-
-	return &cep->stats;
-}
-
-/* Set or clear the multicast filter for this adaptor.
- * Skeleton taken from sunlance driver.
- * The CPM Ethernet implementation allows Multicast as well as individual
- * MAC address filtering.  Some of the drivers check to make sure it is
- * a group multicast address, and discard those that are not.  I guess I
- * will do the same for now, but just remove the test if you want
- * individual filtering as well (do the upper net layers want or support
- * this kind of feature?).
- */
-
-static void set_multicast_list(struct net_device *dev)
-{
-	struct	scc_enet_private *cep;
-	struct	dev_mc_list *dmi;
-	u_char	*mcptr, *tdptr;
-	volatile scc_enet_t *ep;
-	int	i, j;
-	volatile QUICC *cp = pquicc;
-
-	cep = (struct scc_enet_private *)dev->priv;
-
-	/* Get pointer to SCC area in parameter RAM.
-	*/
-	ep = (scc_enet_t *)dev->base_addr;
-
-	if (dev->flags&IFF_PROMISC) {
-	  
-		/* Log any net taps. */
-		printk("%s: Promiscuous mode enabled.\n", dev->name);
-		cep->sccp->scc_psmr |= ETHER_PRO; 
-	} else {
-
-		cep->sccp->scc_psmr &= ~ETHER_PRO;
-
-		if (dev->flags & IFF_ALLMULTI) {
-			/* Catch all multicast addresses, so set the
-			 * filter to all 1's.
-			 */
-			ep->sen_gaddr1 = 0xffff;
-			ep->sen_gaddr2 = 0xffff;
-			ep->sen_gaddr3 = 0xffff;
-			ep->sen_gaddr4 = 0xffff;
-		}
-		else {
-			/* Clear filter and add the addresses in the list.
-			*/
-			ep->sen_gaddr1 = 0;
-			ep->sen_gaddr2 = 0;
-			ep->sen_gaddr3 = 0;
-			ep->sen_gaddr4 = 0;
-
-			dmi = dev->mc_list;
-
-			for (i=0; i<dev->mc_count; i++) {
-				
-				/* Only support group multicast for now.
-				*/
-				if (!(dmi->dmi_addr[0] & 1))
-					continue;
-
-				/* The address in dmi_addr is LSB first,
-				 * and taddr is MSB first.  We have to
-				 * copy bytes MSB first from dmi_addr.
-				 */
-				mcptr = (u_char *)dmi->dmi_addr + 5;
-				tdptr = (u_char *)&ep->sen_taddrh;
-				for (j=0; j<6; j++)
-					*tdptr++ = *mcptr--;
-
-				/* Ask CPM to run CRC and set bit in
-				 * filter mask.
-				 */
-				cp->cp_cr = mk_cr_cmd(CPM_CR_ENET, CPM_CR_SET_GADDR) | CPM_CR_FLG;
-				/* this delay is necessary here -- Cort */
-				udelay(10);
-				while (cp->cp_cr & CPM_CR_FLG);
-			}
-		}
-	}
-}
-
-
-/* Initialize the CPM Ethernet on SCC.
- */
-int scc_enet_init(void)
-{
-	struct net_device *dev;
-	struct scc_enet_private *cep;
-	int i, j;
-	unsigned char	*eap;
-	/* unsigned long	mem_addr; */
-	/* pte_t		*pte; */
-	/* bd_t		*bd; */ /* `board tag' used by ppc - TODO: integrate uC bootloader vars */
-	volatile	QUICC_BD	*bdp;
-	volatile	QUICC	*cp;
-	volatile struct scc_regs	*sccp;
-	volatile struct	ethernet_pram	*ep;
-	/* volatile	immap_t		*immap; */
-
-	cp = pquicc;	/* Get pointer to Communication Processor */
-
-	/* immap = (immap_t *)IMAP_ADDR; */	/* and to internal registers */
-
-	/* bd = (bd_t *)__res; */
-
-	/* Allocate some private information.
-	*/
-	cep = (struct scc_enet_private *)kmalloc(sizeof(*cep), GFP_KERNEL);
-	memset(cep, 0, sizeof(*cep));
-	/* __clear_user(cep,sizeof(*cep)); */
-	/* spin_lock_init(&cep->lock); */ /* TODO: SPINLOCK */
-
-	/* Create an Ethernet device instance.
-	 */
-	dev = init_etherdev(0, 0);
-
-	/* Get pointer to SCC area in parameter RAM.
-	*/
-	/* ep = (ethernet_pram *)(&cp->cp_dparam[PROFF_ENET]); */
-	ep = &pquicc->pram[SCC_ENET].enet_scc;
-
-	/* And another to the SCC register area.
-	*/
-	sccp = &pquicc->scc_regs[SCC_ENET];
-	cep->sccp = sccp;		/* Keep the pointer handy */
-
-	/* Disable receive and transmit in case EPPC-Bug started it.
-	*/
-	sccp->scc_gsmr.w.low &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-
-	/* Set up 360 pins for SCC interface to ethernet transceiver.
-	 * Pin mappings (PA_xx and PC_xx) are defined in commproc.h
-	 */
-
-	/* Configure port A pins for Txd and Rxd.
-	 */
-	pquicc->pio_papar |= (PA_ENET_RXD | PA_ENET_TXD);
-	pquicc->pio_padir &= ~(PA_ENET_RXD | PA_ENET_TXD);
-	pquicc->pio_paodr &= ~PA_ENET_TXD;
-
-	/* Configure port C pins to enable CLSN and RENA.
-	 */
-	pquicc->pio_pcpar &= ~(PC_ENET_CLSN | PC_ENET_RENA);
-	pquicc->pio_pcdir &= ~(PC_ENET_CLSN | PC_ENET_RENA);
-	pquicc->pio_pcso |= (PC_ENET_CLSN | PC_ENET_RENA);
-
-	/* Configure port A for TCLK and RCLK.
-	*/
-	pquicc->pio_papar |= (PA_ENET_TCLK | PA_ENET_RCLK);
-	pquicc->pio_padir &= ~(PA_ENET_TCLK | PA_ENET_RCLK);
-
-	/* Configure Serial Interface clock routing.
-	 * First, clear all SCC bits to zero, then set the ones we want.
-	 */
-	pquicc->si_sicr &= ~SICR_ENET_MASK;
-	pquicc->si_sicr |= SICR_ENET_CLKRT;
-
-
-	/* Allocate space for the buffer descriptors in the DP ram.
-	 * These are relative offsets in the DP ram address space.
-	 * Initialize base addresses for the buffer descriptors.
-	 */
-	i = m360_cpm_dpalloc(sizeof(QUICC_BD) * RX_RING_SIZE);
-	ep->rbase = i;
-	cep->rx_bd_base = (QUICC_BD *)((uint)pquicc + i);
-
-	i = m360_cpm_dpalloc(sizeof(QUICC_BD) * TX_RING_SIZE);
-	ep->tbase = i;
-	cep->tx_bd_base = (QUICC_BD *)((uint)pquicc + i);
-
-	cep->dirty_tx = cep->cur_tx = cep->tx_bd_base;
-	cep->cur_rx = cep->rx_bd_base;
-
-	/* Issue init Rx BD command for SCC.
-	 * Manual says to perform an Init Rx parameters here.  We have
-	 * to perform both Rx and Tx because the SCC may have been
-	 * already running. [In uCquicc's case, I don't think that is so - mles]
-	 * In addition, we have to do it later because we don't yet have
-	 * all of the BD control/status set properly.
-	cp->cp_cpcr = mk_cr_cmd(CPM_CR_ENET, CPM_CR_INIT_RX) | CPM_CR_FLG;
-	while (cp->cp_cpcr & CPM_CR_FLG);
-	 */
-
-	/* Initialize function code registers for big-endian.
-	*/
-	ep->rfcr = (SCC_EB | SCC_FC_DMA);
-	ep->tfcr = (SCC_EB | SCC_FC_DMA);
-
-	/* Set maximum bytes per receive buffer.
-	 * This appears to be an Ethernet frame size, not the buffer
-	 * fragment size.  It must be a multiple of four.
-	 */
-	ep->mrblr  = PKT_MAXBLR_SIZE;
-
-	/* Set CRC preset and mask.
-	 */
-	ep->c_pres = 0xffffffff;
-	ep->c_mask = 0xdebb20e3; /* see 360UM p. 7-247 */
-
-	ep->crcec  = 0;	/* CRC Error counter */
-	ep->alec   = 0;	/* alignment error counter */
-	ep->disfc  = 0;	/* discard frame counter */
-
-	ep->pads   = 0x8888;	/* Tx short frame pad character */
-	ep->ret_lim = 0x000f;	/* Retry limit threshold */
-
-	ep->mflr   = PKT_MAXBUF_SIZE;	/* maximum frame length register */
-	ep->minflr = PKT_MINBUF_SIZE;	/* minimum frame length register */
-
-	ep->maxd1 = PKT_MAXBLR_SIZE;	/* maximum DMA1 length */
-	ep->maxd2 = PKT_MAXBLR_SIZE;	/* maximum DMA2 length */
-
-	/* Clear hash tables, group and individual.
-	 */
-	ep->gaddr1 = ep->gaddr2 = ep->gaddr3 = ep->gaddr4 = 0;
-	ep->iaddr1 = ep->iaddr2 = ep->iaddr3 = ep->iaddr4 = 0;
-
-	/* Set Ethernet station address.
-	 *
-	 * The uCbootloader provides a hook to the kernel to retrieve
-	 * stuff like the MAC address. This is retrieved in config_BSP()
-	 */
-#if defined (CONFIG_UCQUICC)
-	{
- 		extern unsigned char *scc1_hwaddr;
-
-		eap = (char *)ep->paddr.b;
-		for (i=5; i>=0; i--)
-			*eap++ = dev->dev_addr[i] = scc1_hwaddr[i];
-	}
-#endif
-
-
-/* #ifndef CONFIG_MBX */
-/* 	eap = (unsigned char *)&(ep->paddrh); */
-
-/* 	for (i=5; i>=0; i--) */
-/* 		*eap++ = dev->dev_addr[i] = bd->bi_enetaddr[i]; */
-/* #else */
-/* 	for (i=5; i>=0; i--) */
-/* 		dev->dev_addr[i] = *eap++; */
-/* #endif */
-
-	ep->p_per   = 0;	/* 'cause the book says so */
-	ep->taddr_l = 0;	/* temp address (LSB) */
-	ep->taddr_m = 0;
-	ep->taddr_h = 0;	/* temp address (MSB) */
-
-	/* Now allocate the host memory pages and initialize the
-	 * buffer descriptors.
-	 */
-	/* initialize rx buffer descriptors */
-	bdp = cep->tx_bd_base;
-	for (j=0; j<(TX_RING_SIZE-1); j++) {
-		bdp->buf = 0;
-		bdp->status = 0;
-		bdp++;
-	}
-	bdp->buf = 0;
-	bdp->status = BD_SC_WRAP;
-
-
-	/* initialize rx buffer descriptors */
-	bdp = cep->rx_bd_base;
-	for (j=0; j<(RX_RING_SIZE-1); j++) {
-		bdp->buf = &rx_buf_pool[j * CPM_ENET_RX_FRSIZE];
-		bdp->status = BD_SC_EMPTY | BD_SC_INTRPT;
-		bdp++;
-	}
-	bdp->buf = &rx_buf_pool[j * CPM_ENET_RX_FRSIZE];
-	bdp->status = BD_SC_WRAP | BD_SC_EMPTY | BD_SC_INTRPT;
-
-
-
-	/* Let's re-initialize the channel now.  We have to do it later
-	 * than the manual describes because we have just now finished
-	 * the BD initialization.
-	 */
-	cp->cp_cr = mk_cr_cmd(CPM_CR_ENET, CPM_CR_INIT_TRX) | CPM_CR_FLG;
-	while (cp->cp_cr & CPM_CR_FLG);
-
-	cep->skb_cur = cep->skb_dirty = 0;
-
-	sccp->scc_scce = 0xffff;	/* Clear any pending events */
-
-	/* Enable interrupts for transmit error, complete frame
-	 * received, and any transmit buffer we have also set the
-	 * interrupt flag.
-	 */
-	sccp->scc_sccm = (SCCE_ENET_TXE | SCCE_ENET_RXF | SCCE_ENET_TXB);
-
-	/* Install our interrupt handler.
-	 */
-	/* cpm_install_handler(CPMVEC_ENET, scc_enet_interrupt, dev); */
-	request_irq(CPMVEC_ENET, scc_enet_interrupt,
-		IRQ_FLG_LOCK, dev->name, (void *)dev);
-
-	/* Set GSMR_H to enable all normal operating modes.
-	 * Set GSMR_L to enable Ethernet to MC68160.
-	 */
-	sccp->scc_gsmr.w.high = 0;
-	sccp->scc_gsmr.w.low  = (SCC_GSMRL_TCI | SCC_GSMRL_TPL_48 |
-							 SCC_GSMRL_TPP_10 | SCC_GSMRL_MODE_ENET);
-
-	/* Set sync/delimiters.
-	 */
-	sccp->scc_dsr = 0xd555;
-
-	/* Set processing mode.  Use Ethernet CRC, catch broadcast, and
-	 * start frame search 22 bit times after RENA.
-	 */
-	sccp->scc_psmr = (SCC_PMSR_ENCRC       /* Ethernet CRC mode */
-			  /* | SCC_PSMR_HBC */ /* Enable heartbeat */
-			  /* | SCC_PMSR_PRO */ /* Promiscuous mode */
-			  /* | SCC_PMSR_FDE */ /* Full duplex enable */
-			  | ETHER_NIB_22);
-	/* sccp->scc_psmr = (SCC_PMSR_PRO | ETHER_CRC_32 | ETHER_NIB_22); */
-
-
-	/* It is now OK to enable the Ethernet transmitter.
-	 * Unfortunately, there are board implementation differences here.
-	 */
-#if defined(CONFIG_UCQUICC)
-/* 	 immap->im_ioport.iop_pcpar |= PC_ENET_TENA; */
-/* 	 immap->im_ioport.iop_pcdir &= ~PC_ENET_TENA; */
-	 cp->pio_pcpar |=  PC_ENET_TENA; /* t_en */
-	 cp->pio_pcdir &= ~PC_ENET_TENA;
-
-	 cp->pip_pbpar &= ~(0x00000200); /* power up ethernet transceiver */
-	 cp->pip_pbdir |=  (0x00000200);
-	 cp->pip_pbdat |=  (0x00000200);
-#endif
-
-
-	dev->base_addr = (unsigned long)ep;
-	dev->priv = cep;
-#if 0
-	dev->name = "CPM_ENET";
-#endif
-
-	/* The CPM Ethernet specific entries in the device structure. */
-	dev->open = scc_enet_open;
-	dev->hard_start_xmit = scc_enet_start_xmit;
-	/* dev->tx_timeout = scc_enet_timeout; */
-	/* dev->watchdog_timeo = TX_TIMEOUT; */
-	dev->stop = scc_enet_close;
-	dev->get_stats = scc_enet_get_stats;
-	dev->set_multicast_list = set_multicast_list;
-
-	/* And last, enable the transmit and receive processing.
-	*/
-	sccp->scc_gsmr.w.low |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-
-	printk("%s: CPM ENET Version 0.3, ", dev->name);
-	for (i=0; i<5; i++)
-		printk("%02x:", dev->dev_addr[i]);
-	printk("%02x\n", dev->dev_addr[5]);
-
-	return 0;
-}
-
-
-
-int m68360_enet_probe(struct device *dev)
-{
-	return(scc_enet_init ());
-}
-
-
-/*
- * Local variables:
- *  c-indent-level: 4
- *  c-basic-offset: 4
- *  tab-width: 4
- * End:
- */
diff -puN drivers/net/dummy.c~linus drivers/net/dummy.c
--- 25/drivers/net/dummy.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/dummy.c	2004-01-19 22:17:22.000000000 -0800
@@ -33,6 +33,9 @@
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
 #include <linux/init.h>
+#include <linux/moduleparam.h>
+
+static int numdummies = 1;
 
 static int dummy_xmit(struct sk_buff *skb, struct net_device *dev);
 static struct net_device_stats *dummy_get_stats(struct net_device *dev);
@@ -83,10 +86,14 @@ static struct net_device_stats *dummy_ge
 	return dev->priv;
 }
 
-static struct net_device *dev_dummy;
+static struct net_device **dummies;
 
-static int __init dummy_init_module(void)
+/* Number of dummy devices to be set up by this module. */
+module_param(numdummies, int, 0);
+
+static int __init dummy_init_one(int index)
 {
+	struct net_device *dev_dummy;
 	int err;
 
 	dev_dummy = alloc_netdev(sizeof(struct net_device_stats),
@@ -98,15 +105,40 @@ static int __init dummy_init_module(void
 	if ((err = register_netdev(dev_dummy))) {
 		kfree(dev_dummy);
 		dev_dummy = NULL;
+	} else {
+		dummies[index] = dev_dummy; 
 	}
+
 	return err;
 }
 
+static void __exit dummy_free_one(int index) 
+{
+	unregister_netdev(dummies[index]);
+	free_netdev(dummies[index]);
+} 
+
+static int __init dummy_init_module(void)
+{ 
+	int i, err = 0;
+	dummies = kmalloc(numdummies * sizeof(void *), GFP_KERNEL); 
+	if (!dummies)
+		return -ENOMEM; 
+	for (i = 0; i < numdummies && !err; i++)
+		err = dummy_init_one(i); 
+	if (err) { 
+		while (--i >= 0)
+			dummy_free_one(i);
+	}
+	return err;
+} 
+
 static void __exit dummy_cleanup_module(void)
 {
-	unregister_netdev(dev_dummy);
-	free_netdev(dev_dummy);
-	dev_dummy = NULL;
+	int i;
+	for (i = 0; i < numdummies; i++) 
+		dummy_free_one(i); 
+	kfree(dummies);	
 }
 
 module_init(dummy_init_module);
diff -puN /dev/null drivers/net/forcedeth.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/net/forcedeth.c	2004-01-19 22:17:22.000000000 -0800
@@ -0,0 +1,1501 @@
+/*
+ * forcedeth: Ethernet driver for NVIDIA nForce media access controllers.
+ *
+ * Note: This driver is a cleanroom reimplementation based on reverse
+ *      engineered documentation written by Carl-Daniel Hailfinger
+ *      and Andrew de Quincey. It's neither supported nor endorsed
+ *      by NVIDIA Corp. Use at your own risk.
+ *
+ * NVIDIA, nForce and other NVIDIA marks are trademarks or registered
+ * trademarks of NVIDIA Corporation in the United States and other
+ * countries.
+ *
+ * Copyright (C) 2003 Manfred Spraul
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Changelog:
+ * 	0.01: 05 Oct 2003: First release that compiles without warnings.
+ * 	0.02: 05 Oct 2003: Fix bug for drain_tx: do not try to free NULL skbs.
+ * 			   Check all PCI BARs for the register window.
+ * 			   udelay added to mii_rw.
+ * 	0.03: 06 Oct 2003: Initialize dev->irq.
+ * 	0.04: 07 Oct 2003: Initialize np->lock, reduce handled irqs, add printks.
+ * 	0.05: 09 Oct 2003: printk removed again, irq status print tx_timeout.
+ * 	0.06: 10 Oct 2003: MAC Address read updated, pff flag generation updated,
+ * 			   irq mask updated
+ * 	0.07: 14 Oct 2003: Further irq mask updates.
+ * 	0.08: 20 Oct 2003: rx_desc.Length initialization added, alloc_rx refill
+ * 			   added into irq handler, NULL check for drain_ring.
+ * 	0.09: 20 Oct 2003: Basic link speed irq implementation. Only handle the
+ * 			   requested interrupt sources.
+ * 	0.10: 20 Oct 2003: First cleanup for release.
+ * 	0.11: 21 Oct 2003: hexdump for tx added, rx buffer sizes increased.
+ * 			   MAC Address init fix, set_multicast cleanup.
+ * 	0.12: 23 Oct 2003: Cleanups for release.
+ * 	0.13: 25 Oct 2003: Limit for concurrent tx packets increased to 10.
+ * 			   Set link speed correctly. start rx before starting
+ * 			   tx (start_rx sets the link speed).
+ * 	0.14: 25 Oct 2003: Nic dependant irq mask.
+ * 	0.15: 08 Nov 2003: fix smp deadlock with set_multicast_list during
+ * 			   open.
+ * 	0.16: 15 Nov 2003: include file cleanup for ppc64, rx buffer size
+ * 			   increased to 1628 bytes.
+ * 	0.17: 16 Nov 2003: undo rx buffer size increase. Substract 1 from
+ * 			   the tx length.
+ * 	0.18: 17 Nov 2003: fix oops due to late initialization of dev_stats
+ * 	0.19: 29 Nov 2003: Handle RxNoBuf, detect & handle invalid mac
+ * 			   addresses, really stop rx if already running
+ * 			   in start_rx, clean up a bit.
+ * 				(C) Carl-Daniel Hailfinger
+ * 	0.20: 07 Dev 2003: alloc fixes
+ *
+ * Known bugs:
+ * The irq handling is wrong - no tx done interrupts are generated.
+ * This means recovery from netif_stop_queue only happens in the hw timer
+ * interrupt (1/2 second on nForce2, 1/100 second on nForce3), or if an
+ * rx packet arrives by chance.
+ */
+#define FORCEDETH_VERSION		"0.19"
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/interrupt.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/delay.h>
+#include <linux/spinlock.h>
+#include <linux/ethtool.h>
+#include <linux/timer.h>
+#include <linux/skbuff.h>
+#include <linux/mii.h>
+#include <linux/random.h>
+#include <linux/init.h>
+
+#include <asm/irq.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <asm/system.h>
+
+#if 0
+#define dprintk			printk
+#else
+#define dprintk(x...)		do { } while (0)
+#endif
+
+
+/*
+ * Hardware access:
+ */
+
+#define DEV_NEED_LASTPACKET1	0x0001
+#define DEV_IRQMASK_1		0x0002
+#define DEV_IRQMASK_2		0x0004
+
+enum {
+	NvRegIrqStatus = 0x000,
+#define NVREG_IRQSTAT_MIIEVENT	0x040
+#define NVREG_IRQSTAT_MASK		0x1ff
+	NvRegIrqMask = 0x004,
+#define NVREG_IRQ_RX			0x0002
+#define NVREG_IRQ_RX_NOBUF		0x0004
+#define NVREG_IRQ_TX_ERR		0x0008
+#define NVREG_IRQ_TX2			0x0010
+#define NVREG_IRQ_TIMER			0x0020
+#define NVREG_IRQ_LINK			0x0040
+#define NVREG_IRQ_TX1			0x0100
+#define NVREG_IRQMASK_WANTED_1		0x005f
+#define NVREG_IRQMASK_WANTED_2		0x0147
+#define NVREG_IRQ_UNKNOWN		(~(NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_TX_ERR|NVREG_IRQ_TX2|NVREG_IRQ_TIMER|NVREG_IRQ_LINK|NVREG_IRQ_TX1))
+
+	NvRegUnknownSetupReg6 = 0x008,
+#define NVREG_UNKSETUP6_VAL		3
+
+	NvRegPollingInterval = 0x00c,
+	NvRegMisc1 = 0x080,
+#define NVREG_MISC1_HD		0x02
+#define NVREG_MISC1_FORCE	0x3b0f3c
+
+	NvRegTransmitterControl = 0x084,
+#define NVREG_XMITCTL_START	0x01
+	NvRegTransmitterStatus = 0x088,
+#define NVREG_XMITSTAT_BUSY	0x01
+
+	NvRegPacketFilterFlags = 0x8c,
+#define NVREG_PFF_ALWAYS	0x7F0008
+#define NVREG_PFF_PROMISC	0x80
+#define NVREG_PFF_MYADDR	0x20
+
+	NvRegOffloadConfig = 0x90,
+#define NVREG_OFFLOAD_HOMEPHY	0x601
+#define NVREG_OFFLOAD_NORMAL	0x5ee
+	NvRegReceiverControl = 0x094,
+#define NVREG_RCVCTL_START	0x01
+	NvRegReceiverStatus = 0x98,
+#define NVREG_RCVSTAT_BUSY	0x01
+
+	NvRegRandomSeed = 0x9c,
+#define NVREG_RNDSEED_MASK	0x00ff
+#define NVREG_RNDSEED_FORCE	0x7f00
+
+	NvRegUnknownSetupReg1 = 0xA0,
+#define NVREG_UNKSETUP1_VAL	0x16070f
+	NvRegUnknownSetupReg2 = 0xA4,
+#define NVREG_UNKSETUP2_VAL	0x16
+	NvRegMacAddrA = 0xA8,
+	NvRegMacAddrB = 0xAC,
+	NvRegMulticastAddrA = 0xB0,
+#define NVREG_MCASTADDRA_FORCE	0x01
+	NvRegMulticastAddrB = 0xB4,
+	NvRegMulticastMaskA = 0xB8,
+	NvRegMulticastMaskB = 0xBC,
+
+	NvRegTxRingPhysAddr = 0x100,
+	NvRegRxRingPhysAddr = 0x104,
+	NvRegRingSizes = 0x108,
+#define NVREG_RINGSZ_TXSHIFT 0
+#define NVREG_RINGSZ_RXSHIFT 16
+	NvRegUnknownTransmitterReg = 0x10c,
+	NvRegLinkSpeed = 0x110,
+#define NVREG_LINKSPEED_FORCE 0x10000
+#define NVREG_LINKSPEED_10	10
+#define NVREG_LINKSPEED_100	100
+#define NVREG_LINKSPEED_1000	1000
+	NvRegUnknownSetupReg5 = 0x130,
+#define NVREG_UNKSETUP5_BIT31	(1<<31)
+	NvRegUnknownSetupReg3 = 0x134,
+#define NVREG_UNKSETUP3_VAL1	0x200010
+	NvRegTxRxControl = 0x144,
+#define NVREG_TXRXCTL_KICK	0x0001
+#define NVREG_TXRXCTL_BIT1	0x0002
+#define NVREG_TXRXCTL_BIT2	0x0004
+#define NVREG_TXRXCTL_IDLE	0x0008
+#define NVREG_TXRXCTL_RESET	0x0010
+	NvRegMIIStatus = 0x180,
+#define NVREG_MIISTAT_ERROR		0x0001
+#define NVREG_MIISTAT_LINKCHANGE	0x0008
+#define NVREG_MIISTAT_MASK		0x000f
+#define NVREG_MIISTAT_MASK2		0x000f
+	NvRegUnknownSetupReg4 = 0x184,
+#define NVREG_UNKSETUP4_VAL	8
+
+	NvRegAdapterControl = 0x188,
+#define NVREG_ADAPTCTL_START	0x02
+#define NVREG_ADAPTCTL_LINKUP	0x04
+#define NVREG_ADAPTCTL_PHYVALID	0x4000
+#define NVREG_ADAPTCTL_RUNNING	0x100000
+#define NVREG_ADAPTCTL_PHYSHIFT	24
+	NvRegMIISpeed = 0x18c,
+#define NVREG_MIISPEED_BIT8	(1<<8)
+#define NVREG_MIIDELAY	5
+	NvRegMIIControl = 0x190,
+#define NVREG_MIICTL_INUSE	0x10000
+#define NVREG_MIICTL_WRITE	0x08000
+#define NVREG_MIICTL_ADDRSHIFT	5
+	NvRegMIIData = 0x194,
+	NvRegWakeUpFlags = 0x200,
+#define NVREG_WAKEUPFLAGS_VAL		0x7770
+#define NVREG_WAKEUPFLAGS_BUSYSHIFT	24
+#define NVREG_WAKEUPFLAGS_ENABLESHIFT	16
+#define NVREG_WAKEUPFLAGS_D3SHIFT	12
+#define NVREG_WAKEUPFLAGS_D2SHIFT	8
+#define NVREG_WAKEUPFLAGS_D1SHIFT	4
+#define NVREG_WAKEUPFLAGS_D0SHIFT	0
+#define NVREG_WAKEUPFLAGS_ACCEPT_MAGPAT		0x01
+#define NVREG_WAKEUPFLAGS_ACCEPT_WAKEUPPAT	0x02
+#define NVREG_WAKEUPFLAGS_ACCEPT_LINKCHANGE	0x04
+
+	NvRegPatternCRC = 0x204,
+	NvRegPatternMask = 0x208,
+	NvRegPowerCap = 0x268,
+#define NVREG_POWERCAP_D3SUPP	(1<<30)
+#define NVREG_POWERCAP_D2SUPP	(1<<26)
+#define NVREG_POWERCAP_D1SUPP	(1<<25)
+	NvRegPowerState = 0x26c,
+#define NVREG_POWERSTATE_POWEREDUP	0x8000
+#define NVREG_POWERSTATE_VALID		0x0100
+#define NVREG_POWERSTATE_MASK		0x0003
+#define NVREG_POWERSTATE_D0		0x0000
+#define NVREG_POWERSTATE_D1		0x0001
+#define NVREG_POWERSTATE_D2		0x0002
+#define NVREG_POWERSTATE_D3		0x0003
+};
+
+struct ring_desc {
+	u32 PacketBuffer;
+	u16 Length;
+	u16 Flags;
+};
+
+#define NV_TX_LASTPACKET	(1<<0)
+#define NV_TX_RETRYERROR	(1<<3)
+#define NV_TX_LASTPACKET1	(1<<8)
+#define NV_TX_DEFERRED		(1<<10)
+#define NV_TX_CARRIERLOST	(1<<11)
+#define NV_TX_LATECOLLISION	(1<<12)
+#define NV_TX_UNDERFLOW		(1<<13)
+#define NV_TX_ERROR		(1<<14)
+#define NV_TX_VALID		(1<<15)
+
+#define NV_RX_DESCRIPTORVALID	(1<<0)
+#define NV_RX_MISSEDFRAME	(1<<1)
+#define NV_RX_SUBSTRACT1	(1<<3)
+#define NV_RX_ERROR1		(1<<7)
+#define NV_RX_ERROR2		(1<<8)
+#define NV_RX_ERROR3		(1<<9)
+#define NV_RX_ERROR4		(1<<10)
+#define NV_RX_CRCERR		(1<<11)
+#define NV_RX_OVERFLOW		(1<<12)
+#define NV_RX_FRAMINGERR	(1<<13)
+#define NV_RX_ERROR		(1<<14)
+#define NV_RX_AVAIL		(1<<15)
+
+/* Miscelaneous hardware related defines: */
+#define NV_PCI_REGSZ		0x270
+
+/* various timeout delays: all in usec */
+#define NV_TXRX_RESET_DELAY	4
+#define NV_TXSTOP_DELAY1	10
+#define NV_TXSTOP_DELAY1MAX	500000
+#define NV_TXSTOP_DELAY2	100
+#define NV_RXSTOP_DELAY1	10
+#define NV_RXSTOP_DELAY1MAX	500000
+#define NV_RXSTOP_DELAY2	100
+#define NV_SETUP5_DELAY		5
+#define NV_SETUP5_DELAYMAX	50000
+#define NV_POWERUP_DELAY	5
+#define NV_POWERUP_DELAYMAX	5000
+#define NV_MIIBUSY_DELAY	50
+#define NV_MIIPHY_DELAY	10
+#define NV_MIIPHY_DELAYMAX	10000
+
+#define NV_WAKEUPPATTERNS	5
+#define NV_WAKEUPMASKENTRIES	4
+
+/* General driver defaults */
+#define NV_WATCHDOG_TIMEO	(2*HZ)
+#define DEFAULT_MTU		1500	/* also maximum supported, at least for now */
+
+#define RX_RING		128
+#define TX_RING		16
+/* limited to 1 packet until we understand NV_TX_LASTPACKET */
+#define TX_LIMIT_STOP	10
+#define TX_LIMIT_START	5
+
+/* rx/tx mac addr + type + vlan + align + slack*/
+#define RX_NIC_BUFSIZE		(DEFAULT_MTU + 64)
+/* even more slack */
+#define RX_ALLOC_BUFSIZE	(DEFAULT_MTU + 128)
+
+#define OOM_REFILL	(1+HZ/20)
+#define POLL_WAIT	(1+HZ/100)
+
+/*
+ * SMP locking:
+ * All hardware access under dev->priv->lock, except the performance
+ * critical parts:
+ * - rx is (pseudo-) lockless: it relies on the single-threading provided
+ * 	by the arch code for interrupts.
+ * - tx setup is lockless: it relies on dev->xmit_lock. Actual submission
+ *	needs dev->priv->lock :-(
+ * - set_multicast_list: preparation lockless, relies on dev->xmit_lock.
+ */
+
+/* in dev: base, irq */
+struct fe_priv {
+	spinlock_t lock;
+
+	/* General data:
+	 * Locking: spin_lock(&np->lock); */
+	struct net_device_stats stats;
+	int in_shutdown;
+	u32 linkspeed;
+	int duplex;
+	int phyaddr;
+
+	/* General data: RO fields */
+	dma_addr_t ring_addr;
+	struct pci_dev *pci_dev;
+	u32 orig_mac[2];
+	u32 irqmask;
+
+	/* rx specific fields.
+	 * Locking: Within irq hander or disable_irq+spin_lock(&np->lock);
+	 */
+	struct ring_desc *rx_ring;
+	unsigned int cur_rx, refill_rx;
+	struct sk_buff *rx_skbuff[RX_RING];
+	dma_addr_t rx_dma[RX_RING];
+	unsigned int rx_buf_sz;
+	struct timer_list oom_kick;
+	struct timer_list nic_poll;
+
+	/*
+	 * tx specific fields.
+	 */
+	struct ring_desc *tx_ring;
+	unsigned int next_tx, nic_tx;
+	struct sk_buff *tx_skbuff[TX_RING];
+	dma_addr_t tx_dma[TX_RING];
+	u16 tx_flags;
+};
+
+/*
+ * Maximum number of loops until we assume that a bit in the irq mask
+ * is stuck. Overridable with module param.
+ */
+static int max_interrupt_work = 5;
+
+static inline struct fe_priv *get_nvpriv(struct net_device *dev)
+{
+	return (struct fe_priv *) dev->priv;
+}
+
+static inline u8 *get_hwbase(struct net_device *dev)
+{
+	return (u8 *) dev->base_addr;
+}
+
+static inline void pci_push(u8 * base)
+{
+	/* force out pending posted writes */
+	readl(base);
+}
+
+static int reg_delay(struct net_device *dev, int offset, u32 mask, u32 target,
+				int delay, int delaymax, const char *msg)
+{
+	u8 *base = get_hwbase(dev);
+
+	pci_push(base);
+	do {
+		udelay(delay);
+		delaymax -= delay;
+		if (delaymax < 0) {
+			if (msg)
+				printk(msg);
+			return 1;
+		}
+	} while ((readl(base + offset) & mask) != target);
+	return 0;
+}
+
+#define MII_READ	(-1)
+/* mii_rw: read/write a register on the PHY.
+ *
+ * Caller must guarantee serialization
+ */
+static int mii_rw(struct net_device *dev, int addr, int miireg, int value)
+{
+	u8 *base = get_hwbase(dev);
+	int was_running;
+	u32 reg;
+	int retval;
+
+	writel(NVREG_MIISTAT_MASK, base + NvRegMIIStatus);
+	was_running = 0;
+	reg = readl(base + NvRegAdapterControl);
+	if (reg & NVREG_ADAPTCTL_RUNNING) {
+		was_running = 1;
+		writel(reg & ~NVREG_ADAPTCTL_RUNNING, base + NvRegAdapterControl);
+	}
+	reg = readl(base + NvRegMIIControl);
+	if (reg & NVREG_MIICTL_INUSE) {
+		writel(NVREG_MIICTL_INUSE, base + NvRegMIIControl);
+		udelay(NV_MIIBUSY_DELAY);
+	}
+
+	reg = NVREG_MIICTL_INUSE | (addr << NVREG_MIICTL_ADDRSHIFT) | miireg;
+	if (value != MII_READ) {
+		writel(value, base + NvRegMIIData);
+		reg |= NVREG_MIICTL_WRITE;
+	}
+	writel(reg, base + NvRegMIIControl);
+
+	if (reg_delay(dev, NvRegMIIControl, NVREG_MIICTL_INUSE, 0,
+			NV_MIIPHY_DELAY, NV_MIIPHY_DELAYMAX, NULL)) {
+		dprintk(KERN_DEBUG "%s: mii_rw of reg %d at PHY %d timed out.\n",
+				dev->name, miireg, addr);
+		retval = -1;
+	} else if (value != MII_READ) {
+		/* it was a write operation - fewer failures are detectable */
+		dprintk(KERN_DEBUG "%s: mii_rw wrote 0x%x to reg %d at PHY %d\n",
+				dev->name, value, miireg, addr);
+		retval = 0;
+	} else if (readl(base + NvRegMIIStatus) & NVREG_MIISTAT_ERROR) {
+		dprintk(KERN_DEBUG "%s: mii_rw of reg %d at PHY %d failed.\n",
+				dev->name, miireg, addr);
+		retval = -1;
+	} else {
+		/* FIXME: why is that required? */
+		udelay(50);
+		retval = readl(base + NvRegMIIData);
+		dprintk(KERN_DEBUG "%s: mii_rw read from reg %d at PHY %d: 0x%x.\n",
+				dev->name, miireg, addr, retval);
+	}
+	if (was_running) {
+		reg = readl(base + NvRegAdapterControl);
+		writel(reg | NVREG_ADAPTCTL_RUNNING, base + NvRegAdapterControl);
+	}
+	return retval;
+}
+
+static void start_rx(struct net_device *dev)
+{
+	struct fe_priv *np = get_nvpriv(dev);
+	u8 *base = get_hwbase(dev);
+
+	dprintk(KERN_DEBUG "%s: start_rx\n", dev->name);
+	/* Already running? Stop it. */
+	if (readl(base + NvRegReceiverControl) & NVREG_RCVCTL_START) {
+		writel(0, base + NvRegReceiverControl);
+		pci_push(base);
+	}
+	writel(np->linkspeed, base + NvRegLinkSpeed);
+	pci_push(base);
+	writel(NVREG_RCVCTL_START, base + NvRegReceiverControl);
+	pci_push(base);
+}
+
+static void stop_rx(struct net_device *dev)
+{
+	u8 *base = get_hwbase(dev);
+
+	dprintk(KERN_DEBUG "%s: stop_rx\n", dev->name);
+	writel(0, base + NvRegReceiverControl);
+	reg_delay(dev, NvRegReceiverStatus, NVREG_RCVSTAT_BUSY, 0,
+		       NV_RXSTOP_DELAY1, NV_RXSTOP_DELAY1MAX,
+		       KERN_INFO "stop_rx: ReceiverStatus remained busy");
+
+	udelay(NV_RXSTOP_DELAY2);
+	writel(0, base + NvRegLinkSpeed);
+}
+
+static void start_tx(struct net_device *dev)
+{
+	u8 *base = get_hwbase(dev);
+
+	dprintk(KERN_DEBUG "%s: start_tx\n", dev->name);
+	writel(NVREG_XMITCTL_START, base + NvRegTransmitterControl);
+	pci_push(base);
+}
+
+static void stop_tx(struct net_device *dev)
+{
+	u8 *base = get_hwbase(dev);
+
+	dprintk(KERN_DEBUG "%s: stop_tx\n", dev->name);
+	writel(0, base + NvRegTransmitterControl);
+	reg_delay(dev, NvRegTransmitterStatus, NVREG_XMITSTAT_BUSY, 0,
+		       NV_TXSTOP_DELAY1, NV_TXSTOP_DELAY1MAX,
+		       KERN_INFO "stop_tx: TransmitterStatus remained busy");
+
+	udelay(NV_TXSTOP_DELAY2);
+	writel(0, base + NvRegUnknownTransmitterReg);
+}
+
+static void txrx_reset(struct net_device *dev)
+{
+	u8 *base = get_hwbase(dev);
+
+	dprintk(KERN_DEBUG "%s: txrx_reset\n", dev->name);
+	writel(NVREG_TXRXCTL_BIT2 | NVREG_TXRXCTL_RESET, base + NvRegTxRxControl);
+	pci_push(base);
+	udelay(NV_TXRX_RESET_DELAY);
+	writel(NVREG_TXRXCTL_BIT2, base + NvRegTxRxControl);
+	pci_push(base);
+}
+
+/*
+ * get_stats: dev->get_stats function
+ * Get latest stats value from the nic.
+ * Called with read_lock(&dev_base_lock) held for read -
+ * only synchronized against unregister_netdevice.
+ */
+static struct net_device_stats *get_stats(struct net_device *dev)
+{
+	struct fe_priv *np = get_nvpriv(dev);
+
+	/* It seems that the nic always generates interrupts and doesn't
+	 * accumulate errors internally. Thus the current values in np->stats
+	 * are already up to date.
+	 */
+	return &np->stats;
+}
+
+
+/*
+ * nic_ioctl: dev->do_ioctl function
+ * Called with rtnl_lock held.
+ */
+static int nic_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
+{
+	return -EOPNOTSUPP;
+}
+
+/*
+ * alloc_rx: fill rx ring entries.
+ * Return 1 if the allocations for the skbs failed and the
+ * rx engine is without Available descriptors
+ */
+static int alloc_rx(struct net_device *dev)
+{
+	struct fe_priv *np = get_nvpriv(dev);
+	unsigned int refill_rx = np->refill_rx;
+
+	while (np->cur_rx != refill_rx) {
+		int nr = refill_rx % RX_RING;
+		struct sk_buff *skb;
+
+		if (np->rx_skbuff[nr] == NULL) {
+
+			skb = dev_alloc_skb(RX_ALLOC_BUFSIZE);
+			if (!skb)
+				break;
+
+			skb->dev = dev;
+			np->rx_skbuff[nr] = skb;
+		} else {
+			skb = np->rx_skbuff[nr];
+		}
+		np->rx_dma[nr] = pci_map_single(np->pci_dev, skb->data, skb->len,
+						PCI_DMA_FROMDEVICE);
+		np->rx_ring[nr].PacketBuffer = cpu_to_le32(np->rx_dma[nr]);
+		np->rx_ring[nr].Length = cpu_to_le16(RX_NIC_BUFSIZE);
+		wmb();
+		np->rx_ring[nr].Flags = cpu_to_le16(NV_RX_AVAIL);
+		dprintk(KERN_DEBUG "%s: alloc_rx: Packet  %d marked as Available\n",
+					dev->name, refill_rx);
+		refill_rx++;
+	}
+	np->refill_rx = refill_rx;
+	if (np->cur_rx - refill_rx == RX_RING)
+		return 1;
+	return 0;
+}
+
+static void do_rx_refill(unsigned long data)
+{
+	struct net_device *dev = (struct net_device *) data;
+	struct fe_priv *np = get_nvpriv(dev);
+
+	disable_irq(dev->irq);
+	if (alloc_rx(dev)) {
+		spin_lock(&np->lock);
+		if (!np->in_shutdown)
+			mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
+		spin_unlock(&np->lock);
+	}
+	enable_irq(dev->irq);
+}
+
+static int init_ring(struct net_device *dev)
+{
+	struct fe_priv *np = get_nvpriv(dev);
+	int i;
+
+	np->next_tx = np->nic_tx = 0;
+	for (i = 0; i < TX_RING; i++) {
+		np->tx_ring[i].Flags = 0;
+	}
+
+	np->cur_rx = RX_RING;
+	np->refill_rx = 0;
+	for (i = 0; i < RX_RING; i++) {
+		np->rx_ring[i].Flags = 0;
+	}
+	return alloc_rx(dev);
+}
+
+static void drain_tx(struct net_device *dev)
+{
+	struct fe_priv *np = get_nvpriv(dev);
+	int i;
+	for (i = 0; i < TX_RING; i++) {
+		np->tx_ring[i].Flags = 0;
+		if (np->tx_skbuff[i]) {
+			pci_unmap_single(np->pci_dev, np->tx_dma[i],
+						np->tx_skbuff[i]->len,
+						PCI_DMA_TODEVICE);
+			dev_kfree_skb(np->tx_skbuff[i]);
+			np->tx_skbuff[i] = NULL;
+			np->stats.tx_dropped++;
+		}
+	}
+}
+
+static void drain_rx(struct net_device *dev)
+{
+	struct fe_priv *np = get_nvpriv(dev);
+	int i;
+	for (i = 0; i < RX_RING; i++) {
+		np->rx_ring[i].Flags = 0;
+		wmb();
+		if (np->rx_skbuff[i]) {
+			pci_unmap_single(np->pci_dev, np->rx_dma[i],
+						np->rx_skbuff[i]->len,
+						PCI_DMA_FROMDEVICE);
+			dev_kfree_skb(np->rx_skbuff[i]);
+			np->rx_skbuff[i] = NULL;
+		}
+	}
+}
+
+static void drain_ring(struct net_device *dev)
+{
+	drain_tx(dev);
+	drain_rx(dev);
+}
+
+/*
+ * start_xmit: dev->hard_start_xmit function
+ * Called with dev->xmit_lock held.
+ */
+static int start_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+	struct fe_priv *np = get_nvpriv(dev);
+	int nr = np->next_tx % TX_RING;
+
+	np->tx_skbuff[nr] = skb;
+	np->tx_dma[nr] = pci_map_single(np->pci_dev, skb->data,skb->len,
+					PCI_DMA_TODEVICE);
+
+	np->tx_ring[nr].PacketBuffer = cpu_to_le32(np->tx_dma[nr]);
+	np->tx_ring[nr].Length = cpu_to_le16(skb->len-1);
+
+	spin_lock_irq(&np->lock);
+	wmb();
+	np->tx_ring[nr].Flags = np->tx_flags;
+	dprintk(KERN_DEBUG "%s: start_xmit: packet packet %d queued for transmission.\n",
+				dev->name, np->next_tx);
+	{
+		int j;
+		for (j=0; j<64; j++) {
+			if ((j%16) == 0)
+				dprintk("\n%03x:", j);
+			dprintk(" %02x", ((unsigned char*)skb->data)[j]);
+		}
+		dprintk("\n");
+	}
+
+	np->next_tx++;
+
+	dev->trans_start = jiffies;
+	if (np->next_tx - np->nic_tx >= TX_LIMIT_STOP)
+		netif_stop_queue(dev);
+	spin_unlock_irq(&np->lock);
+	writel(NVREG_TXRXCTL_KICK, get_hwbase(dev) + NvRegTxRxControl);
+	return 0;
+}
+
+/*
+ * tx_done: check for completed packets, release the skbs.
+ *
+ * Caller must own np->lock.
+ */
+static void tx_done(struct net_device *dev)
+{
+	struct fe_priv *np = get_nvpriv(dev);
+
+	while (np->nic_tx < np->next_tx) {
+		struct ring_desc *prd;
+		int i = np->nic_tx % TX_RING;
+
+		prd = &np->tx_ring[i];
+
+		dprintk(KERN_DEBUG "%s: tx_done: looking at packet %d, Flags 0x%x.\n",
+					dev->name, np->nic_tx, prd->Flags);
+		if (prd->Flags & cpu_to_le16(NV_TX_VALID))
+			break;
+		if (prd->Flags & cpu_to_le16(NV_TX_RETRYERROR|NV_TX_CARRIERLOST|NV_TX_LATECOLLISION|
+						NV_TX_UNDERFLOW|NV_TX_ERROR)) {
+			if (prd->Flags & cpu_to_le16(NV_TX_UNDERFLOW))
+				np->stats.tx_fifo_errors++;
+			if (prd->Flags & cpu_to_le16(NV_TX_CARRIERLOST))
+				np->stats.tx_carrier_errors++;
+			np->stats.tx_errors++;
+		} else {
+			np->stats.tx_packets++;
+			np->stats.tx_bytes += np->tx_skbuff[i]->len;
+		}
+		pci_unmap_single(np->pci_dev, np->tx_dma[i],
+					np->tx_skbuff[i]->len,
+					PCI_DMA_TODEVICE);
+		dev_kfree_skb_irq(np->tx_skbuff[i]);
+		np->tx_skbuff[i] = NULL;
+		np->nic_tx++;
+	}
+	if (np->next_tx - np->nic_tx < TX_LIMIT_START)
+		netif_wake_queue(dev);
+}
+
+/*
+ * tx_timeout: dev->tx_timeout function
+ * Called with dev->xmit_lock held.
+ */
+static void tx_timeout(struct net_device *dev)
+{
+	struct fe_priv *np = get_nvpriv(dev);
+	u8 *base = get_hwbase(dev);
+
+	dprintk(KERN_DEBUG "%s: Got tx_timeout. irq: %08x\n", dev->name,
+			readl(base + NvRegIrqStatus) & NVREG_IRQSTAT_MASK);
+
+	spin_lock_irq(&np->lock);
+
+	/* 1) stop tx engine */
+	stop_tx(dev);
+
+	/* 2) check that the packets were not sent already: */
+	tx_done(dev);
+
+	/* 3) if there are dead entries: clear everything */
+	if (np->next_tx != np->nic_tx) {
+		printk(KERN_DEBUG "%s: tx_timeout: dead entries!\n", dev->name);
+		drain_tx(dev);
+		np->next_tx = np->nic_tx = 0;
+		writel((u32) (np->ring_addr + RX_RING*sizeof(struct ring_desc)), base + NvRegTxRingPhysAddr);
+		netif_wake_queue(dev);
+	}
+
+	/* 4) restart tx engine */
+	start_tx(dev);
+	spin_unlock_irq(&np->lock);
+}
+
+static void rx_process(struct net_device *dev)
+{
+	struct fe_priv *np = get_nvpriv(dev);
+
+	for (;;) {
+		struct ring_desc *prd;
+		struct sk_buff *skb;
+		int len;
+		int i;
+		if (np->cur_rx - np->refill_rx >= RX_RING)
+			break;	/* we scanned the whole ring - do not continue */
+
+		i = np->cur_rx % RX_RING;
+		prd = &np->rx_ring[i];
+		dprintk(KERN_DEBUG "%s: rx_process: looking at packet %d, Flags 0x%x.\n",
+					dev->name, np->cur_rx, prd->Flags);
+
+		if (prd->Flags & cpu_to_le16(NV_RX_AVAIL))
+			break;	/* still owned by hardware, */
+
+		/*
+		 * the packet is for us - immediately tear down the pci mapping, and
+		 * prefetch the first cacheline of the packet.
+		 */
+		pci_unmap_single(np->pci_dev, np->rx_dma[i],
+				np->rx_skbuff[i]->len,
+				PCI_DMA_FROMDEVICE);
+		prefetch(np->rx_skbuff[i]->data);
+
+		{
+			int j;
+			dprintk(KERN_DEBUG "Dumping packet (flags 0x%x).",prd->Flags);
+			for (j=0; j<64; j++) {
+				if ((j%16) == 0)
+					dprintk("\n%03x:", j);
+				dprintk(" %02x", ((unsigned char*)np->rx_skbuff[i]->data)[j]);
+			}
+			dprintk("\n");
+		}
+		/* look at what we actually got: */
+		if (!(prd->Flags & cpu_to_le16(NV_RX_DESCRIPTORVALID)))
+			goto next_pkt;
+
+
+		len = le16_to_cpu(prd->Length);
+
+		if (prd->Flags & cpu_to_le16(NV_RX_MISSEDFRAME)) {
+			np->stats.rx_missed_errors++;
+			np->stats.rx_errors++;
+			goto next_pkt;
+		}
+		if (prd->Flags & cpu_to_le16(NV_RX_ERROR1|NV_RX_ERROR2|NV_RX_ERROR3|NV_RX_ERROR4)) {
+			np->stats.rx_errors++;
+			goto next_pkt;
+		}
+		if (prd->Flags & cpu_to_le16(NV_RX_CRCERR)) {
+			np->stats.rx_crc_errors++;
+			np->stats.rx_errors++;
+			goto next_pkt;
+		}
+		if (prd->Flags & cpu_to_le16(NV_RX_OVERFLOW)) {
+			np->stats.rx_over_errors++;
+			np->stats.rx_errors++;
+			goto next_pkt;
+		}
+		if (prd->Flags & cpu_to_le16(NV_RX_ERROR)) {
+			/* framing errors are soft errors, the rest is fatal. */
+			if (prd->Flags & cpu_to_le16(NV_RX_FRAMINGERR)) {
+				if (prd->Flags & cpu_to_le16(NV_RX_SUBSTRACT1)) {
+					len--;
+				}
+			} else {
+				np->stats.rx_errors++;
+				goto next_pkt;
+			}
+		}
+		/* got a valid packet - forward it to the network core */
+		skb = np->rx_skbuff[i];
+		np->rx_skbuff[i] = NULL;
+
+		skb_put(skb, len);
+		skb->protocol = eth_type_trans(skb, dev);
+		dprintk(KERN_DEBUG "%s: rx_process: packet %d with %d bytes, proto %d accepted.\n",
+					dev->name, np->cur_rx, len, skb->protocol);
+		netif_rx(skb);
+		dev->last_rx = jiffies;
+		np->stats.rx_packets++;
+		np->stats.rx_bytes += len;
+next_pkt:
+		np->cur_rx++;
+	}
+}
+
+/*
+ * change_mtu: dev->change_mtu function
+ * Called with dev_base_lock held for read.
+ */
+static int change_mtu(struct net_device *dev, int new_mtu)
+{
+	if (new_mtu > DEFAULT_MTU)
+		return -EINVAL;
+	dev->mtu = new_mtu;
+	return 0;
+}
+
+/*
+ * change_mtu: dev->change_mtu function
+ * Called with dev->xmit_lock held.
+ */
+static void set_multicast(struct net_device *dev)
+{
+	struct fe_priv *np = get_nvpriv(dev);
+	u8 *base = get_hwbase(dev);
+	u32 addr[2];
+	u32 mask[2];
+	u32 pff;
+
+	memset(addr, 0, sizeof(addr));
+	memset(mask, 0, sizeof(mask));
+
+	if (dev->flags & IFF_PROMISC) {
+		printk(KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name);
+		pff = NVREG_PFF_PROMISC;
+	} else {
+		pff = NVREG_PFF_MYADDR;
+
+		if (dev->flags & IFF_ALLMULTI || dev->mc_list) {
+			u32 alwaysOff[2];
+			u32 alwaysOn[2];
+
+			alwaysOn[0] = alwaysOn[1] = alwaysOff[0] = alwaysOff[1] = 0xffffffff;
+			if (dev->flags & IFF_ALLMULTI) {
+				alwaysOn[0] = alwaysOn[1] = alwaysOff[0] = alwaysOff[1] = 0;
+			} else {
+				struct dev_mc_list *walk;
+
+				walk = dev->mc_list;
+				while (walk != NULL) {
+					u32 a, b;
+					a = le32_to_cpu(*(u32 *) walk->dmi_addr);
+					b = le16_to_cpu(*(u16 *) (&walk->dmi_addr[4]));
+					alwaysOn[0] &= a;
+					alwaysOff[0] &= ~a;
+					alwaysOn[1] &= b;
+					alwaysOff[1] &= ~b;
+					walk = walk->next;
+				}
+			}
+			addr[0] = alwaysOn[0];
+			addr[1] = alwaysOn[1];
+			mask[0] = alwaysOn[0] | alwaysOff[0];
+			mask[1] = alwaysOn[1] | alwaysOff[1];
+		}
+	}
+	addr[0] |= NVREG_MCASTADDRA_FORCE;
+	pff |= NVREG_PFF_ALWAYS;
+	spin_lock_irq(&np->lock);
+	stop_rx(dev);
+	writel(addr[0], base + NvRegMulticastAddrA);
+	writel(addr[1], base + NvRegMulticastAddrB);
+	writel(mask[0], base + NvRegMulticastMaskA);
+	writel(mask[1], base + NvRegMulticastMaskB);
+	writel(pff, base + NvRegPacketFilterFlags);
+	start_rx(dev);
+	spin_unlock_irq(&np->lock);
+}
+
+static int update_linkspeed(struct net_device *dev)
+{
+	struct fe_priv *np = get_nvpriv(dev);
+	int adv, lpa, newls, newdup;
+
+	adv = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ);
+	lpa = mii_rw(dev, np->phyaddr, MII_LPA, MII_READ);
+	dprintk(KERN_DEBUG "%s: update_linkspeed: PHY advertises 0x%04x, lpa 0x%04x.\n",
+				dev->name, adv, lpa);
+
+	/* FIXME: handle parallel detection properly, handle gigabit ethernet */
+	lpa = lpa & adv;
+	if (lpa  & LPA_100FULL) {
+		newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_100;
+		newdup = 1;
+	} else if (lpa & LPA_100HALF) {
+		newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_100;
+		newdup = 0;
+	} else if (lpa & LPA_10FULL) {
+		newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
+		newdup = 1;
+	} else if (lpa & LPA_10HALF) {
+		newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
+		newdup = 0;
+	} else {
+		dprintk(KERN_DEBUG "%s: bad ability %04x - falling back to 10HD.\n", dev->name, lpa);
+		newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
+		newdup = 0;
+	}
+	if (np->duplex != newdup || np->linkspeed != newls) {
+		np->duplex = newdup;
+		np->linkspeed = newls;
+		return 1;
+	}
+	return 0;
+}
+
+static void link_irq(struct net_device *dev)
+{
+	struct fe_priv *np = get_nvpriv(dev);
+	u8 *base = get_hwbase(dev);
+	u32 miistat;
+	int miival;
+
+	miistat = readl(base + NvRegMIIStatus);
+	writel(NVREG_MIISTAT_MASK, base + NvRegMIIStatus);
+	printk(KERN_DEBUG "%s: link change notification, status 0x%x.\n", dev->name, miistat);
+
+	miival = mii_rw(dev, np->phyaddr, MII_BMSR, MII_READ);
+	if (miival & BMSR_ANEGCOMPLETE) {
+		update_linkspeed(dev);
+
+		if (netif_carrier_ok(dev)) {
+			stop_rx(dev);
+		} else {
+			netif_carrier_on(dev);
+			printk(KERN_INFO "%s: link up.\n", dev->name);
+		}
+		writel(NVREG_MISC1_FORCE | ( np->duplex ? 0 : NVREG_MISC1_HD),
+					base + NvRegMisc1);
+		start_rx(dev);
+	} else {
+		if (netif_carrier_ok(dev)) {
+			netif_carrier_off(dev);
+			printk(KERN_INFO "%s: link down.\n", dev->name);
+			stop_rx(dev);
+		}
+		writel(np->linkspeed, base + NvRegLinkSpeed);
+		pci_push(base);
+	}
+}
+
+static irqreturn_t nic_irq(int foo, void *data, struct pt_regs *regs)
+{
+	struct net_device *dev = (struct net_device *) data;
+	struct fe_priv *np = get_nvpriv(dev);
+	u8 *base = get_hwbase(dev);
+	u32 events;
+	int i;
+
+	dprintk(KERN_DEBUG "%s: nic_irq\n", dev->name);
+
+	for (i=0; ; i++) {
+		events = readl(base + NvRegIrqStatus) & NVREG_IRQSTAT_MASK;
+		writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus);
+		pci_push(base);
+		dprintk(KERN_DEBUG "%s: irq: %08x\n", dev->name, events);
+		if (!(events & np->irqmask))
+			break;
+
+		if (events & (NVREG_IRQ_TX1|NVREG_IRQ_TX2|NVREG_IRQ_TX_ERR)) {
+			spin_lock(&np->lock);
+			tx_done(dev);
+			spin_unlock(&np->lock);
+		}
+
+		if (events & (NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF)) {
+			rx_process(dev);
+			if (alloc_rx(dev)) {
+				spin_lock(&np->lock);
+				if (!np->in_shutdown)
+					mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
+				spin_unlock(&np->lock);
+			}
+		}
+
+		if (events & NVREG_IRQ_LINK) {
+			spin_lock(&np->lock);
+			link_irq(dev);
+			spin_unlock(&np->lock);
+		}
+		if (events & (NVREG_IRQ_TX_ERR)) {
+			dprintk(KERN_DEBUG "%s: received irq with events 0x%x. Probably TX fail.\n",
+						dev->name, events);
+		}
+		if (events & (NVREG_IRQ_UNKNOWN)) {
+			printk(KERN_DEBUG "%s: received irq with unknown events 0x%x. Please report\n",
+						dev->name, events);
+ 		}
+		if (i > max_interrupt_work) {
+			spin_lock(&np->lock);
+			/* disable interrupts on the nic */
+			writel(0, base + NvRegIrqMask);
+			pci_push(base);
+
+			if (!np->in_shutdown)
+				mod_timer(&np->nic_poll, jiffies + POLL_WAIT);
+			printk(KERN_DEBUG "%s: too many iterations (%d) in nic_irq.\n", dev->name, i);
+			spin_unlock(&np->lock);
+			break;
+		}
+
+	}
+	dprintk(KERN_DEBUG "%s: nic_irq completed\n", dev->name);
+
+	return IRQ_RETVAL(i);
+}
+
+static void do_nic_poll(unsigned long data)
+{
+	struct net_device *dev = (struct net_device *) data;
+	struct fe_priv *np = get_nvpriv(dev);
+	u8 *base = get_hwbase(dev);
+
+	disable_irq(dev->irq);
+	/*
+	 * reenable interrupts on the nic, we have to do this before calling
+	 * nic_irq because that may decide to do otherwise
+	 */
+	writel(np->irqmask, base + NvRegIrqMask);
+	pci_push(base);
+	nic_irq((int) 0, (void *) data, (struct pt_regs *) NULL);
+	enable_irq(dev->irq);
+}
+
+static int open(struct net_device *dev)
+{
+	struct fe_priv *np = get_nvpriv(dev);
+	u8 *base = get_hwbase(dev);
+	int ret, oom, i;
+
+	dprintk(KERN_DEBUG "forcedeth: open\n");
+
+	/* 1) erase previous misconfiguration */
+	/* 4.1-1: stop adapter: ignored, 4.3 seems to be overkill */
+	writel(NVREG_MCASTADDRA_FORCE, base + NvRegMulticastAddrA);
+	writel(0, base + NvRegMulticastAddrB);
+	writel(0, base + NvRegMulticastMaskA);
+	writel(0, base + NvRegMulticastMaskB);
+	writel(0, base + NvRegPacketFilterFlags);
+	writel(0, base + NvRegAdapterControl);
+	writel(0, base + NvRegLinkSpeed);
+	writel(0, base + NvRegUnknownTransmitterReg);
+	txrx_reset(dev);
+	writel(0, base + NvRegUnknownSetupReg6);
+
+	/* 2) initialize descriptor rings */
+	np->in_shutdown = 0;
+	oom = init_ring(dev);
+
+	/* 3) set mac address */
+	{
+		u32 mac[2];
+
+		mac[0] = (dev->dev_addr[0] <<  0) + (dev->dev_addr[1] <<  8) +
+				(dev->dev_addr[2] << 16) + (dev->dev_addr[3] << 24);
+		mac[1] = (dev->dev_addr[4] << 0) + (dev->dev_addr[5] << 8);
+
+		writel(mac[0], base + NvRegMacAddrA);
+		writel(mac[1], base + NvRegMacAddrB);
+	}
+
+	/* 4) continue setup */
+	np->linkspeed = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
+	np->duplex = 0;
+	writel(NVREG_UNKSETUP3_VAL1, base + NvRegUnknownSetupReg3);
+	writel(0, base + NvRegTxRxControl);
+	pci_push(base);
+	writel(NVREG_TXRXCTL_BIT1, base + NvRegTxRxControl);
+	reg_delay(dev, NvRegUnknownSetupReg5, NVREG_UNKSETUP5_BIT31, NVREG_UNKSETUP5_BIT31,
+			NV_SETUP5_DELAY, NV_SETUP5_DELAYMAX,
+			KERN_INFO "open: SetupReg5, Bit 31 remained off\n");
+	writel(0, base + NvRegUnknownSetupReg4);
+
+	/* 5) Find a suitable PHY */
+	writel(NVREG_MIISPEED_BIT8|NVREG_MIIDELAY, base + NvRegMIISpeed);
+	for (i = 1; i < 32; i++) {
+		int id1, id2;
+
+		id1 = mii_rw(dev, i, MII_PHYSID1, MII_READ);
+		if (id1 < 0)
+			continue;
+		id2 = mii_rw(dev, i, MII_PHYSID2, MII_READ);
+		if (id2 < 0)
+			continue;
+		dprintk(KERN_DEBUG "%s: open: Found PHY %04x:%04x at address %d.\n",
+				dev->name, id1, id2, i);
+		np->phyaddr = i;
+
+		update_linkspeed(dev);
+
+		break;
+	}
+	if (i == 32) {
+		printk(KERN_INFO "%s: open: failing due to lack of suitable PHY.\n",
+				dev->name);
+		ret = -EINVAL;
+		goto out_drain;
+	}
+
+	/* 6) continue setup */
+	writel(NVREG_MISC1_FORCE | ( np->duplex ? 0 : NVREG_MISC1_HD),
+				base + NvRegMisc1);
+	writel(readl(base + NvRegTransmitterStatus), base + NvRegTransmitterStatus);
+	writel(NVREG_PFF_ALWAYS, base + NvRegPacketFilterFlags);
+	writel(NVREG_OFFLOAD_NORMAL, base + NvRegOffloadConfig);
+
+	writel(readl(base + NvRegReceiverStatus), base + NvRegReceiverStatus);
+	get_random_bytes(&i, sizeof(i));
+	writel(NVREG_RNDSEED_FORCE | (i&NVREG_RNDSEED_MASK), base + NvRegRandomSeed);
+	writel(NVREG_UNKSETUP1_VAL, base + NvRegUnknownSetupReg1);
+	writel(NVREG_UNKSETUP2_VAL, base + NvRegUnknownSetupReg2);
+	writel(NVREG_UNKSETUP6_VAL, base + NvRegUnknownSetupReg6);
+	writel((np->phyaddr << NVREG_ADAPTCTL_PHYSHIFT)|NVREG_ADAPTCTL_PHYVALID,
+			base + NvRegAdapterControl);
+	writel(NVREG_UNKSETUP4_VAL, base + NvRegUnknownSetupReg4);
+	writel(NVREG_WAKEUPFLAGS_VAL, base + NvRegWakeUpFlags);
+
+	/* 7) start packet processing */
+	writel((u32) np->ring_addr, base + NvRegRxRingPhysAddr);
+	writel((u32) (np->ring_addr + RX_RING*sizeof(struct ring_desc)), base + NvRegTxRingPhysAddr);
+	writel( ((RX_RING-1) << NVREG_RINGSZ_RXSHIFT) + ((TX_RING-1) << NVREG_RINGSZ_TXSHIFT),
+			base + NvRegRingSizes);
+
+	i = readl(base + NvRegPowerState);
+	if ( (i & NVREG_POWERSTATE_POWEREDUP) == 0) {
+		writel(NVREG_POWERSTATE_POWEREDUP|i, base + NvRegPowerState);
+	}
+	pci_push(base);
+	udelay(10);
+	writel(readl(base + NvRegPowerState) | NVREG_POWERSTATE_VALID, base + NvRegPowerState);
+	writel(NVREG_ADAPTCTL_RUNNING, base + NvRegAdapterControl);
+
+
+	writel(0, base + NvRegIrqMask);
+	pci_push(base);
+	writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus);
+	pci_push(base);
+	writel(NVREG_MIISTAT_MASK2, base + NvRegMIIStatus);
+	writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus);
+	pci_push(base);
+
+	ret = request_irq(dev->irq, &nic_irq, SA_SHIRQ, dev->name, dev);
+	if (ret)
+		goto out_drain;
+
+	writel(np->irqmask, base + NvRegIrqMask);
+
+	spin_lock_irq(&np->lock);
+	writel(NVREG_MCASTADDRA_FORCE, base + NvRegMulticastAddrA);
+	writel(0, base + NvRegMulticastAddrB);
+	writel(0, base + NvRegMulticastMaskA);
+	writel(0, base + NvRegMulticastMaskB);
+	writel(NVREG_PFF_ALWAYS|NVREG_PFF_MYADDR, base + NvRegPacketFilterFlags);
+	start_rx(dev);
+	start_tx(dev);
+	netif_start_queue(dev);
+	if (oom)
+		mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
+	if (!(mii_rw(dev, np->phyaddr, MII_BMSR, MII_READ) & BMSR_ANEGCOMPLETE)) {
+		printk("%s: no link during initialization.\n", dev->name);
+		netif_carrier_off(dev);
+	}
+
+	spin_unlock_irq(&np->lock);
+
+	return 0;
+out_drain:
+	drain_ring(dev);
+	return ret;
+}
+
+static int close(struct net_device *dev)
+{
+	struct fe_priv *np = get_nvpriv(dev);
+
+	spin_lock_irq(&np->lock);
+	np->in_shutdown = 1;
+	spin_unlock_irq(&np->lock);
+	synchronize_irq(dev->irq);
+
+	del_timer_sync(&np->oom_kick);
+	del_timer_sync(&np->nic_poll);
+
+	netif_stop_queue(dev);
+	spin_lock_irq(&np->lock);
+	stop_tx(dev);
+	stop_rx(dev);
+	spin_unlock_irq(&np->lock);
+
+	free_irq(dev->irq, dev);
+
+	drain_ring(dev);
+
+	/* FIXME: power down nic */
+
+	return 0;
+}
+
+static int __devinit probe_nic(struct pci_dev *pci_dev, const struct pci_device_id *id)
+{
+	struct net_device *dev;
+	struct fe_priv *np;
+	unsigned long addr;
+	u8 *base;
+	int err, i;
+
+	dev = alloc_etherdev(sizeof(struct fe_priv));
+	np = get_nvpriv(dev);
+	err = -ENOMEM;
+	if (!dev)
+		goto out;
+
+	np->pci_dev = pci_dev;
+	spin_lock_init(&np->lock);
+	SET_MODULE_OWNER(dev);
+	SET_NETDEV_DEV(dev, &pci_dev->dev);
+
+	init_timer(&np->oom_kick);
+	np->oom_kick.data = (unsigned long) dev;
+	np->oom_kick.function = &do_rx_refill;	/* timer handler */
+	init_timer(&np->nic_poll);
+	np->nic_poll.data = (unsigned long) dev;
+	np->nic_poll.function = &do_nic_poll;	/* timer handler */
+
+	err = pci_enable_device(pci_dev);
+	if (err) {
+		printk(KERN_INFO "forcedeth: pci_enable_dev failed (%d) for device %s\n",
+				err, pci_name(pci_dev));
+		goto out_free;
+	}
+
+	pci_set_master(pci_dev);
+
+	err = pci_request_regions(pci_dev, dev->name);
+	if (err < 0)
+		goto out_disable;
+
+	err = -EINVAL;
+	addr = 0;
+	for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
+		dprintk(KERN_DEBUG "%s: resource %d start %p len %ld flags 0x%08lx.\n",
+				pci_name(pci_dev), i, (void*)pci_resource_start(pci_dev, i),
+				pci_resource_len(pci_dev, i),
+				pci_resource_flags(pci_dev, i));
+		if (pci_resource_flags(pci_dev, i) & IORESOURCE_MEM &&
+				pci_resource_len(pci_dev, i) >= NV_PCI_REGSZ) {
+			addr = pci_resource_start(pci_dev, i);
+			break;
+		}
+	}
+	if (i == DEVICE_COUNT_RESOURCE) {
+		printk(KERN_INFO "forcedeth: Couldn't find register window for device %s.\n",
+					pci_name(pci_dev));
+		goto out_relreg;
+	}
+
+	err = -ENOMEM;
+	dev->base_addr = (unsigned long) ioremap(addr, NV_PCI_REGSZ);
+	if (!dev->base_addr)
+		goto out_disable;
+	dev->irq = pci_dev->irq;
+	np->rx_ring = pci_alloc_consistent(pci_dev, sizeof(struct ring_desc) * (RX_RING + TX_RING),
+						&np->ring_addr);
+	if (!np->rx_ring)
+		goto out_unmap;
+	np->tx_ring = &np->rx_ring[RX_RING];
+
+	dev->open = open;
+	dev->stop = close;
+	dev->hard_start_xmit = start_xmit;
+	dev->get_stats = get_stats;
+	dev->change_mtu = change_mtu;
+	dev->set_multicast_list = set_multicast;
+	dev->do_ioctl = nic_ioctl;
+	dev->tx_timeout = tx_timeout;
+	dev->watchdog_timeo = NV_WATCHDOG_TIMEO;
+
+	pci_set_drvdata(pci_dev, dev);
+
+
+	/* read the mac address */
+	base = get_hwbase(dev);
+	np->orig_mac[0] = readl(base + NvRegMacAddrA);
+	np->orig_mac[1] = readl(base + NvRegMacAddrB);
+
+	dev->dev_addr[0] = (np->orig_mac[1] >>  8) & 0xff;
+	dev->dev_addr[1] = (np->orig_mac[1] >>  0) & 0xff;
+	dev->dev_addr[2] = (np->orig_mac[0] >> 24) & 0xff;
+	dev->dev_addr[3] = (np->orig_mac[0] >> 16) & 0xff;
+	dev->dev_addr[4] = (np->orig_mac[0] >>  8) & 0xff;
+	dev->dev_addr[5] = (np->orig_mac[0] >>  0) & 0xff;
+
+	if (!is_valid_ether_addr(dev->dev_addr)) {
+		/*
+		 * Bad mac address. At least one bios sets the mac address
+		 * to 01:23:45:67:89:ab
+		 */
+		printk(KERN_ERR "%s: Invalid Mac address detected: %02x:%02x:%02x:%02x:%02x:%02x\n",
+			pci_name(pci_dev),
+			dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
+			dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
+		printk(KERN_ERR "Please complain to your hardware vendor. Switching to a random MAC.\n");
+		dev->dev_addr[0] = 0x00;
+		dev->dev_addr[1] = 0x00;
+		dev->dev_addr[2] = 0x6c;
+		get_random_bytes(&dev->dev_addr[3], 3);
+	}
+
+	dprintk(KERN_DEBUG "%s: MAC Address %02x:%02x:%02x:%02x:%02x:%02x\n", pci_name(pci_dev),
+			dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
+			dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
+
+	np->tx_flags = cpu_to_le16(NV_TX_LASTPACKET|NV_TX_LASTPACKET1|NV_TX_VALID);
+	if (id->driver_data & DEV_NEED_LASTPACKET1)
+		np->tx_flags |= cpu_to_le16(NV_TX_LASTPACKET1);
+	if (id->driver_data & DEV_IRQMASK_1)
+		np->irqmask = NVREG_IRQMASK_WANTED_1;
+	if (id->driver_data & DEV_IRQMASK_2)
+		np->irqmask = NVREG_IRQMASK_WANTED_2;
+
+	err = register_netdev(dev);
+	if (err) {
+		printk(KERN_INFO "forcedeth: unable to register netdev: %d\n", err);
+		goto out_freering;
+	}
+	printk(KERN_INFO "%s: forcedeth.c: subsystem: %05x:%04x bound to %s\n",
+			dev->name, pci_dev->subsystem_vendor, pci_dev->subsystem_device,
+			pci_name(pci_dev));
+
+	return 0;
+
+out_freering:
+	pci_free_consistent(np->pci_dev, sizeof(struct ring_desc) * (RX_RING + TX_RING),
+				np->rx_ring, np->ring_addr);
+out_unmap:
+	iounmap(get_hwbase(dev));
+out_relreg:
+	pci_release_regions(pci_dev);
+out_disable:
+	pci_disable_device(pci_dev);
+out_free:
+	free_netdev(dev);
+	pci_set_drvdata(pci_dev, NULL);
+out:
+	return err;
+}
+
+static void __devexit remove_nic(struct pci_dev *pci_dev)
+{
+	struct net_device *dev = pci_get_drvdata(pci_dev);
+	struct fe_priv *np = get_nvpriv(dev);
+	u8 *base = get_hwbase(dev);
+
+	unregister_netdev(dev);
+
+	/* special op: write back the misordered MAC address - otherwise
+	 * the next probe_nic would see a wrong address.
+	 */
+	writel(np->orig_mac[0], base + NvRegMacAddrA);
+	writel(np->orig_mac[1], base + NvRegMacAddrB);
+
+	/* free all structures */
+	pci_free_consistent(np->pci_dev, sizeof(struct ring_desc) * (RX_RING + TX_RING), np->rx_ring, np->ring_addr);
+	iounmap(get_hwbase(dev));
+	pci_release_regions(pci_dev);
+	pci_disable_device(pci_dev);
+	free_netdev(dev);
+	pci_set_drvdata(pci_dev, NULL);
+}
+
+static struct pci_device_id pci_tbl[] = {
+	{	/* nForce Ethernet Controller */
+		.vendor = PCI_VENDOR_ID_NVIDIA,
+		.device = 0x1C3,
+		.subvendor = PCI_ANY_ID,
+		.subdevice = PCI_ANY_ID,
+		.driver_data = DEV_IRQMASK_1,
+	},
+	{	/* nForce2 Ethernet Controller */
+		.vendor = PCI_VENDOR_ID_NVIDIA,
+		.device = 0x0066,
+		.subvendor = PCI_ANY_ID,
+		.subdevice = PCI_ANY_ID,
+		.driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2,
+	},
+	{	/* nForce3 Ethernet Controller */
+		.vendor = PCI_VENDOR_ID_NVIDIA,
+		.device = 0x00D6,
+		.subvendor = PCI_ANY_ID,
+		.subdevice = PCI_ANY_ID,
+		.driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2,
+	},
+	{0,},
+};
+
+static struct pci_driver driver = {
+	.name = "forcedeth",
+	.id_table = pci_tbl,
+	.probe = probe_nic,
+	.remove = __devexit_p(remove_nic),
+};
+
+
+static int __init init_nic(void)
+{
+	printk(KERN_INFO "forcedeth.c: Reverse Engineered nForce ethernet driver. Version %s.\n", FORCEDETH_VERSION);
+	return pci_module_init(&driver);
+}
+
+static void __exit exit_nic(void)
+{
+	pci_unregister_driver(&driver);
+}
+
+MODULE_PARM(max_interrupt_work, "i");
+MODULE_PARM_DESC(max_interrupt_work, "forcedeth maximum events handled per interrupt");
+ 
+MODULE_AUTHOR("Manfred Spraul <manfred@colorfullife.com>");
+MODULE_DESCRIPTION("Reverse Engineered nForce ethernet driver");
+MODULE_LICENSE("GPL");
+
+MODULE_DEVICE_TABLE(pci, pci_tbl);
+
+module_init(init_nic);
+module_exit(exit_nic);
diff -puN drivers/net/hamradio/bpqether.c~linus drivers/net/hamradio/bpqether.c
--- 25/drivers/net/hamradio/bpqether.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/hamradio/bpqether.c	2004-01-19 22:17:22.000000000 -0800
@@ -606,33 +606,20 @@ static int bpq_device_event(struct notif
  */
 static int __init bpq_init_driver(void)
 {
-	struct net_device *dev;
-
-	dev_add_pack(&bpq_packet_type);
-
-	register_netdevice_notifier(&bpq_dev_notifier);
-
-	printk(banner);
-
 #ifdef CONFIG_PROC_FS
 	if (!proc_net_fops_create("bpqether", S_IRUGO, &bpq_info_fops)) {
 		printk(KERN_ERR
 			"bpq: cannot create /proc/net/bpqether entry.\n");
-		unregister_netdevice_notifier(&bpq_dev_notifier);
-		dev_remove_pack(&bpq_packet_type);
 		return -ENOENT;
 	}
 #endif  /* CONFIG_PROC_FS */
 
-	rtnl_lock();
-	for (dev = dev_base; dev != NULL; dev = dev->next) {
-		if (dev_is_ethdev(dev) && bpq_new_device(dev)) {
-			printk(KERN_ERR
-			       "bpq: cannot setup dev for '%s'\n",
-			       dev->name);
-		}
-	}
-	rtnl_unlock();
+	dev_add_pack(&bpq_packet_type);
+
+	register_netdevice_notifier(&bpq_dev_notifier);
+
+	printk(banner);
+
 	return 0;
 }
 
diff -puN drivers/net/irda/sir_dev.c~linus drivers/net/irda/sir_dev.c
--- 25/drivers/net/irda/sir_dev.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/irda/sir_dev.c	2004-01-19 22:17:22.000000000 -0800
@@ -31,7 +31,9 @@ void sirdev_enable_rx(struct sir_dev *de
 
 	/* flush rx-buffer - should also help in case of problems with echo cancelation */
 	dev->rx_buff.data = dev->rx_buff.head;
-	dev->tx_buff.len = 0;
+	dev->rx_buff.len = 0;
+	dev->rx_buff.in_frame = FALSE;
+	dev->rx_buff.state = OUTSIDE_FRAME;
 	atomic_set(&dev->enable_rx, 1);
 }
 
@@ -62,24 +64,34 @@ int sirdev_set_dongle(struct sir_dev *de
 
 int sirdev_raw_write(struct sir_dev *dev, const char *buf, int len)
 {
+	unsigned long flags;
 	int ret;
 
 	if (unlikely(len > dev->tx_buff.truesize))
 		return -ENOSPC;
 
-	spin_lock_bh(&dev->tx_lock);		/* serialize with other tx operations */
-	while (dev->tx_buff.len > 0) {		/* wait until tx idle */
-		spin_unlock_bh(&dev->tx_lock);
+	spin_lock_irqsave(&dev->tx_lock, flags);	/* serialize with other tx operations */
+	while (dev->tx_buff.len > 0) {			/* wait until tx idle */
+		spin_unlock_irqrestore(&dev->tx_lock, flags);
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_timeout(MSECS_TO_JIFFIES(10));
-		spin_lock_bh(&dev->tx_lock);
+		spin_lock_irqsave(&dev->tx_lock, flags);
 	}
 
 	dev->tx_buff.data = dev->tx_buff.head;
 	memcpy(dev->tx_buff.data, buf, len);	
+	dev->tx_buff.len = len;
 
 	ret = dev->drv->do_write(dev, dev->tx_buff.data, dev->tx_buff.len);
-	spin_unlock_bh(&dev->tx_lock);
+	if (ret > 0) {
+		IRDA_DEBUG(3, "%s(), raw-tx started\n", __FUNCTION__);
+
+		dev->tx_buff.data += ret;
+		dev->tx_buff.len -= ret;
+		dev->raw_tx = 1;
+		ret = len;		/* all data is going to be sent */
+	}
+	spin_unlock_irqrestore(&dev->tx_lock, flags);
 	return ret;
 }
 
@@ -94,13 +106,13 @@ int sirdev_raw_read(struct sir_dev *dev,
 
 	count = (len < dev->rx_buff.len) ? len : dev->rx_buff.len;
 
-	if (count > 0)
-		memcpy(buf, dev->rx_buff.head, count);
+	if (count > 0) {
+		memcpy(buf, dev->rx_buff.data, count);
+		dev->rx_buff.data += count;
+		dev->rx_buff.len -= count;
+	}
 
-	/* forget trailing stuff */
-	dev->rx_buff.data = dev->rx_buff.head;
-	dev->rx_buff.len = 0;
-	dev->rx_buff.state = OUTSIDE_FRAME;
+	/* remaining stuff gets flushed when re-enabling normal rx */
 
 	return count;
 }
@@ -114,11 +126,12 @@ int sirdev_raw_read(struct sir_dev *dev,
 
 void sirdev_write_complete(struct sir_dev *dev)
 {
+	unsigned long flags;
 	struct sk_buff *skb;
 	int actual = 0;
 	int err;
 	
-	spin_lock_bh(&dev->tx_lock);
+	spin_lock_irqsave(&dev->tx_lock, flags);
 
 	IRDA_DEBUG(3, "%s() - dev->tx_buff.len = %d\n",
 		   __FUNCTION__, dev->tx_buff.len);
@@ -143,11 +156,24 @@ void sirdev_write_complete(struct sir_de
 			dev->tx_buff.len = 0;
 		}
 		if (dev->tx_buff.len > 0) {
-			spin_unlock_bh(&dev->tx_lock);
+			spin_unlock_irqrestore(&dev->tx_lock, flags);
 			return;
 		}
 	}
 
+	if (unlikely(dev->raw_tx != 0)) {
+		/* in raw mode we are just done now after the buffer was sent
+		 * completely. Since this was requested by some dongle driver
+		 * running under the control of the irda-thread we must take
+		 * care here not to re-enable the queue. The queue will be
+		 * restarted when the irda-thread has completed the request.
+		 */
+
+		IRDA_DEBUG(3, "%s(), raw-tx done\n", __FUNCTION__);
+		dev->raw_tx = 0;
+		return;
+	}
+
 	/* we have finished now sending this skb.
 	 * update statistics and free the skb.
 	 * finally we check and trigger a pending speed change, if any.
@@ -190,7 +216,7 @@ void sirdev_write_complete(struct sir_de
 		netif_wake_queue(dev->netdev);
 	}
 
-	spin_unlock_bh(&dev->tx_lock);
+	spin_unlock_irqrestore(&dev->tx_lock, flags);
 }
 
 /* called from client driver - likely with bh-context - to give us
@@ -258,6 +284,7 @@ static struct net_device_stats *sirdev_g
 static int sirdev_hard_xmit(struct sk_buff *skb, struct net_device *ndev)
 {
 	struct sir_dev *dev = ndev->priv;
+	unsigned long flags;
 	int actual = 0;
 	int err;
 	s32 speed;
@@ -307,7 +334,7 @@ static int sirdev_hard_xmit(struct sk_bu
 	}
 
 	/* serialize with write completion */
-	spin_lock_bh(&dev->tx_lock);
+	spin_lock_irqsave(&dev->tx_lock, flags);
 
         /* Copy skb to tx_buff while wrapping, stuffing and making CRC */
 	dev->tx_buff.len = async_wrap_skb(skb, dev->tx_buff.data, dev->tx_buff.truesize); 
@@ -337,7 +364,7 @@ static int sirdev_hard_xmit(struct sk_bu
 		dev->stats.tx_dropped++;		      
 		netif_wake_queue(ndev);
 	}
-	spin_unlock_bh(&dev->tx_lock);
+	spin_unlock_irqrestore(&dev->tx_lock, flags);
 
 	return 0;
 }
@@ -479,6 +506,7 @@ static int sirdev_open(struct net_device
 		goto errout_free;
 
 	sirdev_enable_rx(dev);
+	dev->raw_tx = 0;
 
 	netif_start_queue(ndev);
 	dev->irlap = irlap_open(ndev, &dev->qos, dev->hwname);
diff -puN drivers/net/irda/sir-dev.h~linus drivers/net/irda/sir-dev.h
--- 25/drivers/net/irda/sir-dev.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/irda/sir-dev.h	2004-01-19 22:17:22.000000000 -0800
@@ -179,6 +179,7 @@ struct sir_dev {
 
 	struct sir_fsm fsm;
 	atomic_t enable_rx;
+	int raw_tx;
 	spinlock_t tx_lock;
 
 	u32 new_speed;
diff -puN drivers/net/irda/sir_kthread.c~linus drivers/net/irda/sir_kthread.c
--- 25/drivers/net/irda/sir_kthread.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/irda/sir_kthread.c	2004-01-19 22:17:22.000000000 -0800
@@ -436,14 +436,13 @@ int sirdev_schedule_request(struct sir_d
 
 	IRDA_DEBUG(2, "%s - state=0x%04x / param=%u\n", __FUNCTION__, initial_state, param);
 
-	if (in_interrupt()) {
-		if (down_trylock(&fsm->sem)) {
+	if (down_trylock(&fsm->sem)) {
+		if (in_interrupt()  ||  in_atomic()  ||  irqs_disabled()) {
 			IRDA_DEBUG(1, "%s(), state machine busy!\n", __FUNCTION__);
 			return -EWOULDBLOCK;
-		}
+		} else
+			down(&fsm->sem);
 	}
-	else
-		down(&fsm->sem);
 
 	if (fsm->state == SIRDEV_STATE_DEAD) {
 		/* race with sirdev_close should never happen */
diff -puN drivers/net/Kconfig~linus drivers/net/Kconfig
--- 25/drivers/net/Kconfig~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/Kconfig	2004-01-19 22:17:22.000000000 -0800
@@ -657,7 +657,7 @@ config ELMC
 
 config ELMC_II
 	tristate "3c527 \"EtherLink/MC 32\" support (EXPERIMENTAL)"
-	depends on NET_VENDOR_3COM && MCA && EXPERIMENTAL && BROKEN_ON_SMP
+	depends on NET_VENDOR_3COM && MCA && MCA_LEGACY
 	help
 	  If you have a network (Ethernet) card of this type, say Y and read
 	  the Ethernet-HOWTO, available from
@@ -1283,6 +1283,19 @@ config B44
 	  <file:Documentation/networking/net-modules.txt>.  The module will be
 	  called b44.
 
+config FORCEDETH
+	tristate "Reverse Engineered nForce Ethernet support (EXPERIMENTAL)"
+	depends on NET_PCI && PCI && EXPERIMENTAL
+	help
+	  If you have a network (Ethernet) controller of this type, say Y and
+	  read the Ethernet-HOWTO, available from
+	  <http://www.tldp.org/docs.html#howto>.
+
+	  To compile this driver as a module, choose M here and read
+	  <file:Documentation/networking/net-modules.txt>.  The module will be
+	  called forcedeth.
+
+
 config CS89x0
 	tristate "CS89x0 support"
 	depends on NET_PCI && ISA
@@ -1957,9 +1970,11 @@ config SK98LIN
 	    - EG1032 v2 Instant Gigabit Network Adapter
 	    - EG1064 v2 Instant Gigabit Network Adapter
 	    - Marvell 88E8001 Gigabit LOM Ethernet Adapter (Abit)
+	    - Marvell 88E8001 Gigabit LOM Ethernet Adapter (Albatron)
 	    - Marvell 88E8001 Gigabit LOM Ethernet Adapter (Asus)
 	    - Marvell 88E8001 Gigabit LOM Ethernet Adapter (ECS)
 	    - Marvell 88E8001 Gigabit LOM Ethernet Adapter (Epox)
+	    - Marvell 88E8001 Gigabit LOM Ethernet Adapter (Foxconn)
 	    - Marvell 88E8001 Gigabit LOM Ethernet Adapter (Gigabyte)
 	    - Marvell 88E8001 Gigabit LOM Ethernet Adapter (Iwill)
 	    - Marvell RDK-8001 Adapter
@@ -2005,8 +2020,10 @@ config SK98LIN
 	  Questions concerning this driver may be addressed to:
 	      linux@syskonnect.de
 	  
-	  To compile this driver as a module, choose M here: the module
-	  will be called sk98lin.  This is recommended.
+	  If you want to compile this driver as a module ( = code which can be
+	  inserted in and removed from the running kernel whenever you want),
+	  say M here and read Documentation/modules.txt. This is recommended.
+	  The module will be called sk98lin. This is recommended.
 
 config TIGON3
 	tristate "Broadcom Tigon3 support"
diff -puN drivers/net/Makefile~linus drivers/net/Makefile
--- 25/drivers/net/Makefile~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/Makefile	2004-01-19 22:17:22.000000000 -0800
@@ -95,6 +95,7 @@ obj-$(CONFIG_LNE390) += lne390.o 8390.o
 obj-$(CONFIG_NE3210) += ne3210.o 8390.o
 obj-$(CONFIG_NET_SB1250_MAC) += sb1250-mac.o
 obj-$(CONFIG_B44) += b44.o
+obj-$(CONFIG_FORCEDETH) += forcedeth.o
 
 obj-$(CONFIG_PPP) += ppp_generic.o slhc.o
 obj-$(CONFIG_PPP_ASYNC) += ppp_async.o
diff -puN drivers/net/natsemi.c~linus drivers/net/natsemi.c
--- 25/drivers/net/natsemi.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/natsemi.c	2004-01-19 22:17:22.000000000 -0800
@@ -765,19 +765,13 @@ static int __devinit natsemi_probe1 (str
 	SET_NETDEV_DEV(dev, &pdev->dev);
 
 	i = pci_request_regions(pdev, dev->name);
-	if (i) {
-		free_netdev(dev);
-		return i;
-	}
+	if (i)
+		goto err_pci_request_regions;
 
-	{
-		void *mmio = ioremap (ioaddr, iosize);
-		if (!mmio) {
-			pci_release_regions(pdev);
-			free_netdev(dev);
-			return -ENOMEM;
-		}
-		ioaddr = (unsigned long) mmio;
+	ioaddr = (unsigned long) ioremap (ioaddr, iosize);
+	if (!ioaddr) {
+		i = -ENOMEM;
+		goto err_ioremap;
 	}
 
 	/* Work around the dropped serial bit. */
@@ -835,13 +829,9 @@ static int __devinit natsemi_probe1 (str
 		dev->mtu = mtu;
 
 	i = register_netdev(dev);
-	if (i) {
-		pci_release_regions(pdev);
-		unregister_netdev(dev);
-		free_netdev(dev);
-		pci_set_drvdata(pdev, NULL);
-		return i;
-	}
+	if (i)
+		goto err_register_netdev;
+
 	netif_carrier_off(dev);
 
 	if (netif_msg_drv(np)) {
@@ -878,6 +868,17 @@ static int __devinit natsemi_probe1 (str
 
 
 	return 0;
+
+ err_register_netdev:
+	iounmap ((void *) dev->base_addr);
+
+ err_ioremap:
+	pci_release_regions(pdev);
+	pci_set_drvdata(pdev, NULL);
+
+ err_pci_request_regions:
+	free_netdev(dev);
+	return i;
 }
 
 
diff -puN drivers/net/ne2k-pci.c~linus drivers/net/ne2k-pci.c
--- 25/drivers/net/ne2k-pci.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/ne2k-pci.c	2004-01-19 22:17:22.000000000 -0800
@@ -115,6 +115,7 @@ enum ne2k_pci_chipsets {
 	CH_Winbond_W89C940F,
 	CH_Holtek_HT80232,
 	CH_Holtek_HT80229,
+	CH_Winbond_89C940_8c4a,
 };
 
 
@@ -132,6 +133,7 @@ static struct {
 	{"Winbond W89C940F", 0},
 	{"Holtek HT80232", ONLY_16BIT_IO | HOLTEK_FDX},
 	{"Holtek HT80229", ONLY_32BIT_IO | HOLTEK_FDX | STOP_PG_0x60 },
+	{"Winbond W89C940(misprogrammed)", 0},
 	{0,}
 };
 
@@ -147,6 +149,7 @@ static struct pci_device_id ne2k_pci_tbl
 	{ 0x1050, 0x5a5a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_Winbond_W89C940F },
 	{ 0x12c3, 0x0058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_Holtek_HT80232 },
 	{ 0x12c3, 0x5598, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_Holtek_HT80229 },
+	{ 0x8c4a, 0x1980, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_Winbond_89C940_8c4a },
 	{ 0, }
 };
 MODULE_DEVICE_TABLE(pci, ne2k_pci_tbl);
diff -puN drivers/net/pcmcia/3c574_cs.c~linus drivers/net/pcmcia/3c574_cs.c
--- 25/drivers/net/pcmcia/3c574_cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/pcmcia/3c574_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -330,7 +330,7 @@ static dev_link_t *tc574_attach(void)
 	client_reg.event_handler = &tc574_event;
 	client_reg.Version = 0x0210;
 	client_reg.event_callback_args.client_data = link;
-	ret = CardServices(RegisterClient, &link->handle, &client_reg);
+	ret = pcmcia_register_client(&link->handle, &client_reg);
 	if (ret != 0) {
 		cs_error(link->handle, RegisterClient, ret);
 		tc574_detach(link);
@@ -369,7 +369,7 @@ static void tc574_detach(dev_link_t *lin
 	}
 
 	if (link->handle)
-		CardServices(DeregisterClient, link->handle);
+		pcmcia_deregister_client(link->handle);
 
 	/* Unlink device structure, free bits */
 	*linkp = link->next;
@@ -387,8 +387,8 @@ static void tc574_detach(dev_link_t *lin
 	ethernet device available to the system.
 */
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
+#define CS_CHECK(fn, ret) \
+  do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static void tc574_config(dev_link_t *link)
 {
@@ -409,12 +409,12 @@ static void tc574_config(dev_link_t *lin
 
 	tuple.Attributes = 0;
 	tuple.DesiredTuple = CISTPL_CONFIG;
-	CS_CHECK(GetFirstTuple, handle, &tuple);
+	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
 	tuple.TupleData = (cisdata_t *)buf;
 	tuple.TupleDataMax = 64;
 	tuple.TupleOffset = 0;
-	CS_CHECK(GetTupleData, handle, &tuple);
-	CS_CHECK(ParseTuple, handle, &tuple, &parse);
+	CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+	CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
 	link->conf.ConfigBase = parse.config.base;
 	link->conf.Present = parse.config.rmask[0];
 
@@ -424,15 +424,15 @@ static void tc574_config(dev_link_t *lin
 	link->io.IOAddrLines = 16;
 	for (i = j = 0; j < 0x400; j += 0x20) {
 		link->io.BasePort1 = j ^ 0x300;
-		i = CardServices(RequestIO, link->handle, &link->io);
+		i = pcmcia_request_io(link->handle, &link->io);
 		if (i == CS_SUCCESS) break;
 	}
 	if (i != CS_SUCCESS) {
 		cs_error(link->handle, RequestIO, i);
 		goto failed;
 	}
-	CS_CHECK(RequestIRQ, link->handle, &link->irq);
-	CS_CHECK(RequestConfiguration, link->handle, &link->conf);
+	CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
+	CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
 
 	dev->irq = link->irq.AssignedIRQ;
 	dev->base_addr = link->io.BasePort1;
@@ -451,8 +451,8 @@ static void tc574_config(dev_link_t *lin
 	   the hardware address.  The future products may include a modem chip
 	   and put the address in the CIS. */
 	tuple.DesiredTuple = 0x88;
-	if (CardServices(GetFirstTuple, handle, &tuple) == CS_SUCCESS) {
-		CardServices(GetTupleData, handle, &tuple);
+	if (pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) {
+		pcmcia_get_tuple_data(handle, &tuple);
 		for (i = 0; i < 3; i++)
 			phys_addr[i] = htons(buf[i]);
 	} else {
@@ -466,9 +466,9 @@ static void tc574_config(dev_link_t *lin
 		}
 	}
 	tuple.DesiredTuple = CISTPL_VERS_1;
-	if (CardServices(GetFirstTuple, handle, &tuple) == CS_SUCCESS &&
-		CardServices(GetTupleData, handle, &tuple) == CS_SUCCESS &&
-		CardServices(ParseTuple, handle, &tuple, &parse) == CS_SUCCESS) {
+	if (pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS &&
+		pcmcia_get_tuple_data(handle, &tuple) == CS_SUCCESS &&
+		pcmcia_parse_tuple(handle, &tuple, &parse) == CS_SUCCESS) {
 		cardname = parse.version_1.str + parse.version_1.ofs[1];
 	} else
 		cardname = "3Com 3c574";
@@ -564,9 +564,9 @@ static void tc574_release(dev_link_t *li
 		return;
 	}
 
-	CardServices(ReleaseConfiguration, link->handle);
-	CardServices(ReleaseIO, link->handle, &link->io);
-	CardServices(ReleaseIRQ, link->handle, &link->irq);
+	pcmcia_release_configuration(link->handle);
+	pcmcia_release_io(link->handle, &link->io);
+	pcmcia_release_irq(link->handle, &link->irq);
 
 	link->state &= ~DEV_CONFIG;
 
@@ -608,7 +608,7 @@ static int tc574_event(event_t event, in
 		if (link->state & DEV_CONFIG) {
 			if (link->open)
 				netif_device_detach(dev);
-			CardServices(ReleaseConfiguration, link->handle);
+			pcmcia_release_configuration(link->handle);
 		}
 		break;
 	case CS_EVENT_PM_RESUME:
@@ -616,7 +616,7 @@ static int tc574_event(event_t event, in
 		/* Fall through... */
 	case CS_EVENT_CARD_RESET:
 		if (link->state & DEV_CONFIG) {
-			CardServices(RequestConfiguration, link->handle, &link->conf);
+			pcmcia_request_configuration(link->handle, &link->conf);
 			if (link->open) {
 				tc574_reset(dev);
 				netif_device_attach(dev);
diff -puN drivers/net/pcmcia/3c589_cs.c~linus drivers/net/pcmcia/3c589_cs.c
--- 25/drivers/net/pcmcia/3c589_cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/pcmcia/3c589_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -244,7 +244,7 @@ static dev_link_t *tc589_attach(void)
     client_reg.event_handler = &tc589_event;
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
-    ret = CardServices(RegisterClient, &link->handle, &client_reg);
+    ret = pcmcia_register_client(&link->handle, &client_reg);
     if (ret != 0) {
 	cs_error(link->handle, RegisterClient, ret);
 	tc589_detach(link);
@@ -283,7 +283,7 @@ static void tc589_detach(dev_link_t *lin
     }
     
     if (link->handle)
-	CardServices(DeregisterClient, link->handle);
+	pcmcia_deregister_client(link->handle);
     
     /* Unlink device structure, free bits */
     *linkp = link->next;
@@ -303,8 +303,8 @@ static void tc589_detach(dev_link_t *lin
     
 ======================================================================*/
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static void tc589_config(dev_link_t *link)
 {
@@ -323,20 +323,20 @@ static void tc589_config(dev_link_t *lin
     phys_addr = (u16 *)dev->dev_addr;
     tuple.Attributes = 0;
     tuple.DesiredTuple = CISTPL_CONFIG;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
     tuple.TupleData = (cisdata_t *)buf;
     tuple.TupleDataMax = sizeof(buf);
     tuple.TupleOffset = 0;
-    CS_CHECK(GetTupleData, handle, &tuple);
-    CS_CHECK(ParseTuple, handle, &tuple, &parse);
+    CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+    CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
     link->conf.ConfigBase = parse.config.base;
     link->conf.Present = parse.config.rmask[0];
     
     /* Is this a 3c562? */
     tuple.DesiredTuple = CISTPL_MANFID;
     tuple.Attributes = TUPLE_RETURN_COMMON;
-    if ((CardServices(GetFirstTuple, handle, &tuple) == CS_SUCCESS) &&
-	(CardServices(GetTupleData, handle, &tuple) == CS_SUCCESS)) {
+    if ((pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) &&
+	(pcmcia_get_tuple_data(handle, &tuple) == CS_SUCCESS)) {
 	if (le16_to_cpu(buf[0]) != MANFID_3COM)
 	    printk(KERN_INFO "3c589_cs: hmmm, is this really a "
 		   "3Com card??\n");
@@ -351,15 +351,15 @@ static void tc589_config(dev_link_t *lin
     for (i = j = 0; j < 0x400; j += 0x10) {
 	if (multi && (j & 0x80)) continue;
 	link->io.BasePort1 = j ^ 0x300;
-	i = CardServices(RequestIO, link->handle, &link->io);
+	i = pcmcia_request_io(link->handle, &link->io);
 	if (i == CS_SUCCESS) break;
     }
     if (i != CS_SUCCESS) {
 	cs_error(link->handle, RequestIO, i);
 	goto failed;
     }
-    CS_CHECK(RequestIRQ, link->handle, &link->irq);
-    CS_CHECK(RequestConfiguration, link->handle, &link->conf);
+    CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
+    CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
 	
     dev->irq = link->irq.AssignedIRQ;
     dev->base_addr = link->io.BasePort1;
@@ -374,8 +374,8 @@ static void tc589_config(dev_link_t *lin
     /* The 3c589 has an extra EEPROM for configuration info, including
        the hardware address.  The 3c562 puts the address in the CIS. */
     tuple.DesiredTuple = 0x88;
-    if (CardServices(GetFirstTuple, handle, &tuple) == CS_SUCCESS) {
-	CardServices(GetTupleData, handle, &tuple);
+    if (pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) {
+	pcmcia_get_tuple_data(handle, &tuple);
 	for (i = 0; i < 3; i++)
 	    phys_addr[i] = htons(buf[i]);
     } else {
@@ -440,9 +440,9 @@ static void tc589_release(dev_link_t *li
 	return;
     }
     
-    CardServices(ReleaseConfiguration, link->handle);
-    CardServices(ReleaseIO, link->handle, &link->io);
-    CardServices(ReleaseIRQ, link->handle, &link->irq);
+    pcmcia_release_configuration(link->handle);
+    pcmcia_release_io(link->handle, &link->io);
+    pcmcia_release_irq(link->handle, &link->irq);
     
     link->state &= ~DEV_CONFIG;
 
@@ -486,7 +486,7 @@ static int tc589_event(event_t event, in
 	if (link->state & DEV_CONFIG) {
 	    if (link->open)
 		netif_device_detach(dev);
-	    CardServices(ReleaseConfiguration, link->handle);
+	    pcmcia_release_configuration(link->handle);
 	}
 	break;
     case CS_EVENT_PM_RESUME:
@@ -494,7 +494,7 @@ static int tc589_event(event_t event, in
 	/* Fall through... */
     case CS_EVENT_CARD_RESET:
 	if (link->state & DEV_CONFIG) {
-	    CardServices(RequestConfiguration, link->handle, &link->conf);
+	    pcmcia_request_configuration(link->handle, &link->conf);
 	    if (link->open) {
 		tc589_reset(dev);
 		netif_device_attach(dev);
diff -puN drivers/net/pcmcia/axnet_cs.c~linus drivers/net/pcmcia/axnet_cs.c
--- 25/drivers/net/pcmcia/axnet_cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/pcmcia/axnet_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -205,7 +205,7 @@ static dev_link_t *axnet_attach(void)
     client_reg.event_handler = &axnet_event;
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
-    ret = CardServices(RegisterClient, &link->handle, &client_reg);
+    ret = pcmcia_register_client(&link->handle, &client_reg);
     if (ret != CS_SUCCESS) {
 	cs_error(link->handle, RegisterClient, ret);
 	axnet_detach(link);
@@ -244,7 +244,7 @@ static void axnet_detach(dev_link_t *lin
     }
 
     if (link->handle)
-	CardServices(DeregisterClient, link->handle);
+	pcmcia_deregister_client(link->handle);
 
     /* Unlink device structure, free bits */
     *linkp = link->next;
@@ -313,11 +313,8 @@ static int get_prom(dev_link_t *link)
 
 ======================================================================*/
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
-
-#define CFG_CHECK(fn, args...) \
-if (CardServices(fn, args) != 0) goto next_entry
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static int try_io_port(dev_link_t *link)
 {
@@ -340,12 +337,12 @@ static int try_io_port(dev_link_t *link)
 	for (j = 0; j < 0x400; j += 0x20) {
 	    link->io.BasePort1 = j ^ 0x300;
 	    link->io.BasePort2 = (j ^ 0x300) + 0x10;
-	    ret = CardServices(RequestIO, link->handle, &link->io);
+	    ret = pcmcia_request_io(link->handle, &link->io);
 	    if (ret == CS_SUCCESS) return ret;
 	}
 	return ret;
     } else {
-	return CardServices(RequestIO, link->handle, &link->io);
+	return pcmcia_request_io(link->handle, &link->io);
     }
 }
 
@@ -367,9 +364,9 @@ static void axnet_config(dev_link_t *lin
     tuple.TupleDataMax = sizeof(buf);
     tuple.TupleOffset = 0;
     tuple.DesiredTuple = CISTPL_CONFIG;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
-    CS_CHECK(GetTupleData, handle, &tuple);
-    CS_CHECK(ParseTuple, handle, &tuple, &parse);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+    CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+    CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
     link->conf.ConfigBase = parse.config.base;
     /* don't trust the CIS on this; Linksys got it wrong */
     link->conf.Present = 0x63;
@@ -378,19 +375,19 @@ static void axnet_config(dev_link_t *lin
     link->state |= DEV_CONFIG;
 
     /* Look up current Vcc */
-    CS_CHECK(GetConfigurationInfo, handle, &conf);
+    CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf));
     link->conf.Vcc = conf.Vcc;
 
     tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
     tuple.Attributes = 0;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
     while (last_ret == CS_SUCCESS) {
 	cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
 	cistpl_io_t *io = &(parse.cftable_entry.io);
 	
-	CFG_CHECK(GetTupleData, handle, &tuple);
-	CFG_CHECK(ParseTuple, handle, &tuple, &parse);
-	if ((cfg->index == 0) || (cfg->io.nwin == 0))
+	if (pcmcia_get_tuple_data(handle, &tuple) != 0 ||
+		pcmcia_parse_tuple(handle, &tuple, &parse) != 0 ||
+		cfg->index == 0 || cfg->io.nwin == 0)
 	    goto next_entry;
 	
 	link->conf.ConfigIndex = 0x05;
@@ -411,21 +408,21 @@ static void axnet_config(dev_link_t *lin
 	    if (last_ret == CS_SUCCESS) break;
 	}
     next_entry:
-	last_ret = CardServices(GetNextTuple, handle, &tuple);
+	last_ret = pcmcia_get_next_tuple(handle, &tuple);
     }
     if (last_ret != CS_SUCCESS) {
 	cs_error(handle, RequestIO, last_ret);
 	goto failed;
     }
 
-    CS_CHECK(RequestIRQ, handle, &link->irq);
+    CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq));
     
     if (link->io.NumPorts2 == 8) {
 	link->conf.Attributes |= CONF_ENABLE_SPKR;
 	link->conf.Status = CCSR_AUDIO_ENA;
     }
     
-    CS_CHECK(RequestConfiguration, handle, &link->conf);
+    CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf));
     dev->irq = link->irq.AssignedIRQ;
     dev->base_addr = link->io.BasePort1;
     if (register_netdev(dev) != 0) {
@@ -476,7 +473,7 @@ static void axnet_config(dev_link_t *lin
        Bit 2 of CCSR is active low. */ 
     if (i == 32) {
 	conf_reg_t reg = { 0, CS_WRITE, CISREG_CCSR, 0x04 };
- 	CardServices(AccessConfigurationRegister, link->handle, &reg);
+ 	pcmcia_access_configuration_register(link->handle, &reg);
 	for (i = 0; i < 32; i++) {
 	    j = mdio_read(dev->base_addr + AXNET_MII_EEP, i, 1);
 	    if ((j != 0) && (j != 0xffff)) break;
@@ -520,9 +517,9 @@ static void axnet_release(dev_link_t *li
 	return;
     }
 
-    CardServices(ReleaseConfiguration, link->handle);
-    CardServices(ReleaseIO, link->handle, &link->io);
-    CardServices(ReleaseIRQ, link->handle, &link->irq);
+    pcmcia_release_configuration(link->handle);
+    pcmcia_release_io(link->handle, &link->io);
+    pcmcia_release_irq(link->handle, &link->irq);
 
     link->state &= ~DEV_CONFIG;
 
@@ -566,7 +563,7 @@ static int axnet_event(event_t event, in
 	if (link->state & DEV_CONFIG) {
 	    if (link->open)
 		netif_device_detach(&info->dev);
-	    CardServices(ReleaseConfiguration, link->handle);
+	    pcmcia_release_configuration(link->handle);
 	}
 	break;
     case CS_EVENT_PM_RESUME:
@@ -574,7 +571,7 @@ static int axnet_event(event_t event, in
 	/* Fall through... */
     case CS_EVENT_CARD_RESET:
 	if (link->state & DEV_CONFIG) {
-	    CardServices(RequestConfiguration, link->handle, &link->conf);
+	    pcmcia_request_configuration(link->handle, &link->conf);
 	    if (link->open) {
 		axnet_reset_8390(&info->dev);
 		AX88190_init(&info->dev, 1);
diff -puN drivers/net/pcmcia/com20020_cs.c~linus drivers/net/pcmcia/com20020_cs.c
--- 25/drivers/net/pcmcia/com20020_cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/pcmcia/com20020_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -227,7 +227,7 @@ static dev_link_t *com20020_attach(void)
     client_reg.event_handler = &com20020_event;
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
-    ret = CardServices(RegisterClient, &link->handle, &client_reg);
+    ret = pcmcia_register_client(&link->handle, &client_reg);
     if (ret != 0) {
         cs_error(link->handle, RegisterClient, ret);
         com20020_detach(link);
@@ -277,7 +277,7 @@ static void com20020_detach(dev_link_t *
     }
 
     if (link->handle)
-        CardServices(DeregisterClient, link->handle);
+        pcmcia_deregister_client(link->handle);
 
     /* Unlink device structure, free bits */
     DEBUG(1,"unlinking...\n");
@@ -325,8 +325,8 @@ static void com20020_detach(dev_link_t *
 
 ======================================================================*/
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static void com20020_config(dev_link_t *link)
 {
@@ -353,9 +353,9 @@ static void com20020_config(dev_link_t *
     tuple.TupleDataMax = 64;
     tuple.TupleOffset = 0;
     tuple.DesiredTuple = CISTPL_CONFIG;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
-    CS_CHECK(GetTupleData, handle, &tuple);
-    CS_CHECK(ParseTuple, handle, &tuple, &parse);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+    CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+    CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
     link->conf.ConfigBase = parse.config.base;
 
     /* Configure card */
@@ -368,13 +368,13 @@ static void com20020_config(dev_link_t *
 	for (ioaddr = 0x100; ioaddr < 0x400; ioaddr += 0x10)
 	{
 	    link->io.BasePort1 = ioaddr;
-	    i = CardServices(RequestIO, link->handle, &link->io);
+	    i = pcmcia_request_io(link->handle, &link->io);
 	    if (i == CS_SUCCESS)
 		break;
 	}
     }
     else
-	i = CardServices(RequestIO, link->handle, &link->io);
+	i = pcmcia_request_io(link->handle, &link->io);
     
     if (i != CS_SUCCESS)
     {
@@ -388,7 +388,7 @@ static void com20020_config(dev_link_t *
     DEBUG(1,"arcnet: request IRQ %d (%Xh/%Xh)\n",
 	   link->irq.AssignedIRQ,
 	   link->irq.IRQInfo1, link->irq.IRQInfo2);
-    i = CardServices(RequestIRQ, link->handle, &link->irq);
+    i = pcmcia_request_irq(link->handle, &link->irq);
     if (i != CS_SUCCESS)
     {
 	DEBUG(1,"arcnet: requestIRQ failed totally!\n");
@@ -397,7 +397,7 @@ static void com20020_config(dev_link_t *
 
     dev->irq = link->irq.AssignedIRQ;
 
-    CS_CHECK(RequestConfiguration, link->handle, &link->conf);
+    CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
 
     if (com20020_check(dev))
     {
@@ -454,9 +454,9 @@ static void com20020_release(dev_link_t 
         return;
     }
 
-    CardServices(ReleaseConfiguration, link->handle);
-    CardServices(ReleaseIO, link->handle, &link->io);
-    CardServices(ReleaseIRQ, link->handle, &link->irq);
+    pcmcia_release_configuration(link->handle);
+    pcmcia_release_io(link->handle, &link->io);
+    pcmcia_release_irq(link->handle, &link->irq);
 
     link->state &= ~(DEV_CONFIG | DEV_RELEASE_PENDING);
 
@@ -502,7 +502,7 @@ static int com20020_event(event_t event,
             if (link->open) {
                 netif_device_detach(dev);
             }
-            CardServices(ReleaseConfiguration, link->handle);
+            pcmcia_release_configuration(link->handle);
         }
         break;
     case CS_EVENT_PM_RESUME:
@@ -510,7 +510,7 @@ static int com20020_event(event_t event,
         /* Fall through... */
     case CS_EVENT_CARD_RESET:
         if (link->state & DEV_CONFIG) {
-            CardServices(RequestConfiguration, link->handle, &link->conf);
+            pcmcia_request_configuration(link->handle, &link->conf);
             if (link->open) {
 		int ioaddr = dev->base_addr;
 		struct arcnet_local *lp = (struct arcnet_local *)dev->priv;
diff -puN drivers/net/pcmcia/fmvj18x_cs.c~linus drivers/net/pcmcia/fmvj18x_cs.c
--- 25/drivers/net/pcmcia/fmvj18x_cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/pcmcia/fmvj18x_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -307,7 +307,7 @@ static dev_link_t *fmvj18x_attach(void)
     client_reg.event_handler = &fmvj18x_event;
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
-    ret = CardServices(RegisterClient, &link->handle, &client_reg);
+    ret = pcmcia_register_client(&link->handle, &client_reg);
     if (ret != 0) {
 	cs_error(link->handle, RegisterClient, ret);
 	fmvj18x_detach(link);
@@ -340,7 +340,7 @@ static void fmvj18x_detach(dev_link_t *l
 
     /* Break the link with Card Services */
     if (link->handle)
-	CardServices(DeregisterClient, link->handle);
+	pcmcia_deregister_client(link->handle);
     
     /* Unlink device structure, free pieces */
     *linkp = link->next;
@@ -354,8 +354,8 @@ static void fmvj18x_detach(dev_link_t *l
 
 /*====================================================================*/
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static int mfc_try_io_port(dev_link_t *link)
 {
@@ -369,7 +369,7 @@ static int mfc_try_io_port(dev_link_t *l
 	    link->io.NumPorts2 = 0;
 	    printk(KERN_NOTICE "fmvj18x_cs: out of resource for serial\n");
 	}
-	ret = CardServices(RequestIO, link->handle, &link->io);
+	ret = pcmcia_request_io(link->handle, &link->io);
 	if (ret == CS_SUCCESS) return ret;
     }
     return ret;
@@ -385,7 +385,7 @@ static int ungermann_try_io_port(dev_lin
     */
     for (ioaddr = 0x300; ioaddr < 0x3e0; ioaddr += 0x20) {
 	link->io.BasePort1 = ioaddr;
-	ret = CardServices(RequestIO, link->handle, &link->io);
+	ret = pcmcia_request_io(link->handle, &link->io);
 	if (ret == CS_SUCCESS) {
 	    /* calculate ConfigIndex value */
 	    link->conf.ConfigIndex = 
@@ -417,12 +417,12 @@ static void fmvj18x_config(dev_link_t *l
        registers.
     */
     tuple.DesiredTuple = CISTPL_CONFIG;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
     tuple.TupleData = (u_char *)buf;
     tuple.TupleDataMax = 64;
     tuple.TupleOffset = 0;
-    CS_CHECK(GetTupleData, handle, &tuple);
-    CS_CHECK(ParseTuple, handle, &tuple, &parse);
+    CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+    CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
     
     /* Configure card */
     link->state |= DEV_CONFIG;
@@ -432,16 +432,16 @@ static void fmvj18x_config(dev_link_t *l
 
     tuple.DesiredTuple = CISTPL_FUNCE;
     tuple.TupleOffset = 0;
-    if (CardServices(GetFirstTuple, handle, &tuple) == CS_SUCCESS) {
+    if (pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) {
 	/* Yes, I have CISTPL_FUNCE. Let's check CISTPL_MANFID */
 	tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
-	CS_CHECK(GetFirstTuple, handle, &tuple);
-	CS_CHECK(GetTupleData, handle, &tuple);
-	CS_CHECK(ParseTuple, handle, &tuple, &parse);
+	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+	CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+	CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
 	link->conf.ConfigIndex = parse.cftable_entry.index;
 	tuple.DesiredTuple = CISTPL_MANFID;
-	if (CardServices(GetFirstTuple, handle, &tuple) == CS_SUCCESS)
-	    CS_CHECK(GetTupleData, handle, &tuple);
+	if (pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS)
+	    CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
 	else
 	    buf[0] = 0xffff;
 	switch (le16_to_cpu(buf[0])) {
@@ -449,7 +449,7 @@ static void fmvj18x_config(dev_link_t *l
 	    cardtype = TDK;
 	    if (le16_to_cpu(buf[1]) == PRODID_TDK_CF010) {
 		cs_status_t status;
-		CardServices(GetStatus, handle, &status);
+		pcmcia_get_status(handle, &status);
 		if (status.CardState & CS_EVENT_3VCARD)
 		    link->conf.Vcc = 33; /* inserted in 3.3V slot */
 	    } else if (le16_to_cpu(buf[1]) == PRODID_TDK_GN3410) {
@@ -478,8 +478,8 @@ static void fmvj18x_config(dev_link_t *l
     } else {
 	/* old type card */
 	tuple.DesiredTuple = CISTPL_MANFID;
-	if (CardServices(GetFirstTuple, handle, &tuple) == CS_SUCCESS)
-	    CS_CHECK(GetTupleData, handle, &tuple);
+	if (pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS)
+	    CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
 	else
 	    buf[0] = 0xffff;
 	switch (le16_to_cpu(buf[0])) {
@@ -510,10 +510,10 @@ static void fmvj18x_config(dev_link_t *l
 	ret = ungermann_try_io_port(link);
 	if (ret != CS_SUCCESS) goto cs_failed;
     } else { 
-	CS_CHECK(RequestIO, link->handle, &link->io);
+	CS_CHECK(RequestIO, pcmcia_request_io(link->handle, &link->io));
     }
-    CS_CHECK(RequestIRQ, link->handle, &link->irq);
-    CS_CHECK(RequestConfiguration, link->handle, &link->conf);
+    CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
+    CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
     dev->irq = link->irq.AssignedIRQ;
     dev->base_addr = link->io.BasePort1;
     if (register_netdev(dev) != 0) {
@@ -546,17 +546,17 @@ static void fmvj18x_config(dev_link_t *l
     case CONTEC:
 	tuple.DesiredTuple = CISTPL_FUNCE;
 	tuple.TupleOffset = 0;
-	CS_CHECK(GetFirstTuple, handle, &tuple);
+	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
 	tuple.TupleOffset = 0;
-	CS_CHECK(GetTupleData, handle, &tuple);
+	CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
 	if (cardtype == MBH10304) {
 	    /* MBH10304's CIS_FUNCE is corrupted */
 	    node_id = &(tuple.TupleData[5]);
 	    card_name = "FMV-J182";
 	} else {
 	    while (tuple.TupleData[0] != CISTPL_FUNCE_LAN_NODE_ID ) {
-		CS_CHECK(GetNextTuple, handle, &tuple) ;
-		CS_CHECK(GetTupleData, handle, &tuple) ;
+		CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple));
+		CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
 	    }
 	    node_id = &(tuple.TupleData[2]);
 	    if( cardtype == TDK ) {
@@ -633,8 +633,7 @@ static int fmvj18x_get_hwinfo(dev_link_t
     req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
     req.Base = 0; req.Size = 0;
     req.AccessSpeed = 0;
-    link->win = (window_handle_t)link->handle;
-    i = CardServices(RequestWindow, &link->win, &req);
+    i = pcmcia_request_window(&link->handle, &req, &link->win);
     if (i != CS_SUCCESS) {
 	cs_error(link->handle, RequestWindow, i);
 	return -1;
@@ -643,7 +642,7 @@ static int fmvj18x_get_hwinfo(dev_link_t
     base = ioremap(req.Base, req.Size);
     mem.Page = 0;
     mem.CardOffset = 0;
-    CardServices(MapMemPage, link->win, &mem);
+    pcmcia_map_mem_page(link->win, &mem);
 
     /*
      *  MBH10304 CISTPL_FUNCE_LAN_NODE_ID format
@@ -668,7 +667,7 @@ static int fmvj18x_get_hwinfo(dev_link_t
     }
 
     iounmap(base);
-    j = CardServices(ReleaseWindow, link->win);
+    j = pcmcia_release_window(link->win);
     if (j != CS_SUCCESS)
 	cs_error(link->handle, ReleaseWindow, j);
     return (i != 0x200) ? 0 : -1;
@@ -689,8 +688,7 @@ static int fmvj18x_setup_mfc(dev_link_t 
     req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
     req.Base = 0; req.Size = 0;
     req.AccessSpeed = 0;
-    link->win = (window_handle_t)link->handle;
-    i = CardServices(RequestWindow, &link->win, &req);
+    i = pcmcia_request_window(&link->handle, &req, &link->win);
     if (i != CS_SUCCESS) {
 	cs_error(link->handle, RequestWindow, i);
 	return -1;
@@ -699,7 +697,7 @@ static int fmvj18x_setup_mfc(dev_link_t 
     base = ioremap(req.Base, req.Size);
     mem.Page = 0;
     mem.CardOffset = 0;
-    CardServices(MapMemPage, link->win, &mem);
+    pcmcia_map_mem_page(link->win, &mem);
 
     ioaddr = dev->base_addr;
     writeb(0x47, base+0x800);	/* Config Option Register of LAN */
@@ -712,7 +710,7 @@ static int fmvj18x_setup_mfc(dev_link_t 
     writeb(0x8, base+0x822);	/* Config and Status Register */
 
     iounmap(base);
-    j = CardServices(ReleaseWindow, link->win);
+    j = pcmcia_release_window(link->win);
     if (j != CS_SUCCESS)
 	cs_error(link->handle, ReleaseWindow, j);
     return 0;
@@ -737,10 +735,10 @@ static void fmvj18x_release(dev_link_t *
     }
 
     /* Don't bother checking to see if these succeed or not */
-    CardServices(ReleaseWindow, link->win);
-    CardServices(ReleaseConfiguration, link->handle);
-    CardServices(ReleaseIO, link->handle, &link->io);
-    CardServices(ReleaseIRQ, link->handle, &link->irq);
+    pcmcia_release_window(link->win);
+    pcmcia_release_configuration(link->handle);
+    pcmcia_release_io(link->handle, &link->io);
+    pcmcia_release_irq(link->handle, &link->irq);
     
     link->state &= ~DEV_CONFIG;
 
@@ -777,7 +775,7 @@ static int fmvj18x_event(event_t event, 
 	if (link->state & DEV_CONFIG) {
 	    if (link->open)
 		netif_device_detach(dev);
-	    CardServices(ReleaseConfiguration, link->handle);
+	    pcmcia_release_configuration(link->handle);
 	}
 	break;
     case CS_EVENT_PM_RESUME:
@@ -785,7 +783,7 @@ static int fmvj18x_event(event_t event, 
 	/* Fall through... */
     case CS_EVENT_CARD_RESET:
 	if (link->state & DEV_CONFIG) {
-	    CardServices(RequestConfiguration, link->handle, &link->conf);
+	    pcmcia_request_configuration(link->handle, &link->conf);
 	    if (link->open) {
 		fjn_reset(dev);
 		netif_device_attach(dev);
diff -puN drivers/net/pcmcia/ibmtr_cs.c~linus drivers/net/pcmcia/ibmtr_cs.c
--- 25/drivers/net/pcmcia/ibmtr_cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/pcmcia/ibmtr_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -214,7 +214,7 @@ static dev_link_t *ibmtr_attach(void)
     client_reg.event_handler = &ibmtr_event;
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
-    ret = CardServices(RegisterClient, &link->handle, &client_reg);
+    ret = pcmcia_register_client(&link->handle, &client_reg);
     if (ret != 0) {
         cs_error(link->handle, RegisterClient, ret);
 	goto out_detach;
@@ -264,7 +264,7 @@ static void ibmtr_detach(dev_link_t *lin
     }
 
     if (link->handle)
-        CardServices(DeregisterClient, link->handle);
+        pcmcia_deregister_client(link->handle);
 
     /* Unlink device structure, free bits */
     *linkp = link->next;
@@ -281,8 +281,8 @@ static void ibmtr_detach(dev_link_t *lin
 
 ======================================================================*/
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static void ibmtr_config(dev_link_t *link)
 {
@@ -304,9 +304,9 @@ static void ibmtr_config(dev_link_t *lin
     tuple.TupleDataMax = 64;
     tuple.TupleOffset = 0;
     tuple.DesiredTuple = CISTPL_CONFIG;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
-    CS_CHECK(GetTupleData, handle, &tuple);
-    CS_CHECK(ParseTuple, handle, &tuple, &parse);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+    CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+    CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
     link->conf.ConfigBase = parse.config.base;
 
     /* Configure card */
@@ -318,18 +318,18 @@ static void ibmtr_config(dev_link_t *lin
 
     /* Try PRIMARY card at 0xA20-0xA23 */
     link->io.BasePort1 = 0xA20;
-    i = CardServices(RequestIO, link->handle, &link->io);
+    i = pcmcia_request_io(link->handle, &link->io);
     if (i == CS_SUCCESS) {
 	memcpy(info->node.dev_name, "tr0\0", 4);
     } else {
 	/* Couldn't get 0xA20-0xA23.  Try ALTERNATE at 0xA24-0xA27. */
 	link->io.BasePort1 = 0xA24;
-	CS_CHECK(RequestIO, link->handle, &link->io);
+	CS_CHECK(RequestIO, pcmcia_request_io(link->handle, &link->io));
 	memcpy(info->node.dev_name, "tr1\0", 4);
     }
     dev->base_addr = link->io.BasePort1;
 
-    CS_CHECK(RequestIRQ, link->handle, &link->irq);
+    CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
     dev->irq = link->irq.AssignedIRQ;
     ti->irq = link->irq.AssignedIRQ;
     ti->global_int_enable=GLOBAL_INT_ENABLE+((dev->irq==9) ? 2 : dev->irq);
@@ -340,12 +340,11 @@ static void ibmtr_config(dev_link_t *lin
     req.Base = 0; 
     req.Size = 0x2000;
     req.AccessSpeed = 250;
-    link->win = (window_handle_t)link->handle;
-    CS_CHECK(RequestWindow, &link->win, &req);
+    CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &link->win));
 
     mem.CardOffset = mmiobase;
     mem.Page = 0;
-    CS_CHECK(MapMemPage, link->win, &mem);
+    CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem));
     ti->mmio = ioremap(req.Base, req.Size);
 
     /* Allocate the SRAM memory window */
@@ -354,17 +353,16 @@ static void ibmtr_config(dev_link_t *lin
     req.Base = 0;
     req.Size = sramsize * 1024;
     req.AccessSpeed = 250;
-    info->sram_win_handle = (window_handle_t)link->handle;
-    CS_CHECK(RequestWindow, &info->sram_win_handle, &req);
+    CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &info->sram_win_handle));
 
     mem.CardOffset = srambase;
     mem.Page = 0;
-    CS_CHECK(MapMemPage, info->sram_win_handle, &mem);
+    CS_CHECK(MapMemPage, pcmcia_map_mem_page(info->sram_win_handle, &mem));
 
     ti->sram_base = mem.CardOffset >> 12;
     ti->sram_virt = (u_long)ioremap(req.Base, req.Size);
 
-    CS_CHECK(RequestConfiguration, link->handle, &link->conf);
+    CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
 
     /*  Set up the Token-Ring Controller Configuration Register and
         turn on the card.  Check the "Local Area Network Credit Card
@@ -419,14 +417,14 @@ static void ibmtr_release(dev_link_t *li
         return;
     }
 
-    CardServices(ReleaseConfiguration, link->handle);
-    CardServices(ReleaseIO, link->handle, &link->io);
-    CardServices(ReleaseIRQ, link->handle, &link->irq);
+    pcmcia_release_configuration(link->handle);
+    pcmcia_release_io(link->handle, &link->io);
+    pcmcia_release_irq(link->handle, &link->irq);
     if (link->win) {
 	struct tok_info *ti = dev->priv;
 	iounmap((void *)ti->mmio);
-	CardServices(ReleaseWindow, link->win);
-	CardServices(ReleaseWindow, info->sram_win_handle);
+	pcmcia_release_window(link->win);
+	pcmcia_release_window(info->sram_win_handle);
     }
 
     link->state &= ~DEV_CONFIG;
@@ -474,7 +472,7 @@ static int ibmtr_event(event_t event, in
         if (link->state & DEV_CONFIG) {
             if (link->open)
 		netif_device_detach(dev);
-            CardServices(ReleaseConfiguration, link->handle);
+            pcmcia_release_configuration(link->handle);
         }
         break;
     case CS_EVENT_PM_RESUME:
@@ -482,7 +480,7 @@ static int ibmtr_event(event_t event, in
         /* Fall through... */
     case CS_EVENT_CARD_RESET:
         if (link->state & DEV_CONFIG) {
-            CardServices(RequestConfiguration, link->handle, &link->conf);
+            pcmcia_request_configuration(link->handle, &link->conf);
             if (link->open) {
 		(dev->init)(dev);
 		netif_device_attach(dev);
diff -puN drivers/net/pcmcia/Kconfig~linus drivers/net/pcmcia/Kconfig
--- 25/drivers/net/pcmcia/Kconfig~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/pcmcia/Kconfig	2004-01-19 22:17:22.000000000 -0800
@@ -119,7 +119,7 @@ config ARCNET_COM20020_CS
 
 config PCMCIA_IBMTR
 	tristate "IBM PCMCIA tokenring adapter support"
-	depends on NET_PCMCIA && IBMTR!=y && TR && PCMCIA
+	depends on NET_PCMCIA && IBMTR!=y && TR && PCMCIA && !64BIT
 	help
 	  Say Y here if you intend to attach this type of Token Ring PCMCIA
 	  card to your computer. You then also need to say Y to "Token Ring
diff -puN drivers/net/pcmcia/nmclan_cs.c~linus drivers/net/pcmcia/nmclan_cs.c
--- 25/drivers/net/pcmcia/nmclan_cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/pcmcia/nmclan_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -520,7 +520,7 @@ static dev_link_t *nmclan_attach(void)
     client_reg.event_handler = &nmclan_event;
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
-    ret = CardServices(RegisterClient, &link->handle, &client_reg);
+    ret = pcmcia_register_client(&link->handle, &client_reg);
     if (ret != 0) {
 	cs_error(link->handle, RegisterClient, ret);
 	nmclan_detach(link);
@@ -558,7 +558,7 @@ static void nmclan_detach(dev_link_t *li
     }
 
     if (link->handle)
-	CardServices(DeregisterClient, link->handle);
+	pcmcia_deregister_client(link->handle);
 
     /* Unlink device structure, free bits */
     *linkp = link->next;
@@ -706,8 +706,8 @@ nmclan_config
 	ethernet device available to the system.
 ---------------------------------------------------------------------------- */
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
+#define CS_CHECK(fn, ret) \
+  do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static void nmclan_config(dev_link_t *link)
 {
@@ -727,17 +727,17 @@ static void nmclan_config(dev_link_t *li
   tuple.TupleDataMax = 64;
   tuple.TupleOffset = 0;
   tuple.DesiredTuple = CISTPL_CONFIG;
-  CS_CHECK(GetFirstTuple, handle, &tuple);
-  CS_CHECK(GetTupleData, handle, &tuple);
-  CS_CHECK(ParseTuple, handle, &tuple, &parse);
+  CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+  CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+  CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
   link->conf.ConfigBase = parse.config.base;
 
   /* Configure card */
   link->state |= DEV_CONFIG;
 
-  CS_CHECK(RequestIO, handle, &link->io);
-  CS_CHECK(RequestIRQ, handle, &link->irq);
-  CS_CHECK(RequestConfiguration, handle, &link->conf);
+  CS_CHECK(RequestIO, pcmcia_request_io(handle, &link->io));
+  CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq));
+  CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf));
   dev->irq = link->irq.AssignedIRQ;
   dev->base_addr = link->io.BasePort1;
   i = register_netdev(dev);
@@ -753,8 +753,8 @@ static void nmclan_config(dev_link_t *li
   tuple.TupleData = buf;
   tuple.TupleDataMax = 64;
   tuple.TupleOffset = 0;
-  CS_CHECK(GetFirstTuple, handle, &tuple);
-  CS_CHECK(GetTupleData, handle, &tuple);
+  CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+  CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
   memcpy(dev->dev_addr, tuple.TupleData, ETHER_ADDR_LEN);
 
   /* Verify configuration by reading the MACE ID. */
@@ -819,9 +819,9 @@ static void nmclan_release(dev_link_t *l
     return;
   }
 
-  CardServices(ReleaseConfiguration, link->handle);
-  CardServices(ReleaseIO, link->handle, &link->io);
-  CardServices(ReleaseIRQ, link->handle, &link->irq);
+  pcmcia_release_configuration(link->handle);
+  pcmcia_release_io(link->handle, &link->io);
+  pcmcia_release_irq(link->handle, &link->irq);
 
   link->state &= ~DEV_CONFIG;
 
@@ -863,7 +863,7 @@ static int nmclan_event(event_t event, i
       if (link->state & DEV_CONFIG) {
 	if (link->open)
 	  netif_device_detach(dev);
-	CardServices(ReleaseConfiguration, link->handle);
+	pcmcia_release_configuration(link->handle);
       }
       break;
     case CS_EVENT_PM_RESUME:
@@ -871,7 +871,7 @@ static int nmclan_event(event_t event, i
       /* Fall through... */
     case CS_EVENT_CARD_RESET:
       if (link->state & DEV_CONFIG) {
-	CardServices(RequestConfiguration, link->handle, &link->conf);
+	pcmcia_request_configuration(link->handle, &link->conf);
 	if (link->open) {
 	  nmclan_reset(dev);
 	  netif_device_attach(dev);
@@ -903,7 +903,7 @@ static void nmclan_reset(struct net_devi
   reg.Action = CS_READ;
   reg.Offset = CISREG_COR;
   reg.Value = 0;
-  CardServices(AccessConfigurationRegister, link->handle, &reg);
+  pcmcia_access_configuration_register(link->handle, &reg);
   OrigCorValue = reg.Value;
 
   /* Reset Xilinx */
@@ -912,12 +912,12 @@ static void nmclan_reset(struct net_devi
   DEBUG(1, "nmclan_reset: OrigCorValue=0x%lX, resetting...\n",
 	OrigCorValue);
   reg.Value = COR_SOFT_RESET;
-  CardServices(AccessConfigurationRegister, link->handle, &reg);
+  pcmcia_access_configuration_register(link->handle, &reg);
   /* Need to wait for 20 ms for PCMCIA to finish reset. */
 
   /* Restore original COR configuration index */
   reg.Value = COR_LEVEL_REQ | (OrigCorValue & COR_CONFIG_MASK);
-  CardServices(AccessConfigurationRegister, link->handle, &reg);
+  pcmcia_access_configuration_register(link->handle, &reg);
   /* Xilinx is now completely reset along with the MACE chip. */
   lp->tx_free_frames=AM2150_MAX_TX_FRAMES;
 
@@ -1046,7 +1046,7 @@ static void mace_tx_timeout(struct net_d
   printk(KERN_NOTICE "%s: transmit timed out -- ", dev->name);
 #if RESET_ON_TIMEOUT
   printk("resetting card\n");
-  CardServices(ResetCard, link->handle);
+  pcmcia_reset_card(link->handle, NULL);
 #else /* #if RESET_ON_TIMEOUT */
   printk("NOT resetting card\n");
 #endif /* #if RESET_ON_TIMEOUT */
diff -puN drivers/net/pcmcia/pcnet_cs.c~linus drivers/net/pcmcia/pcnet_cs.c
--- 25/drivers/net/pcmcia/pcnet_cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/pcmcia/pcnet_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -303,7 +303,7 @@ static dev_link_t *pcnet_attach(void)
     client_reg.event_handler = &pcnet_event;
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
-    ret = CardServices(RegisterClient, &link->handle, &client_reg);
+    ret = pcmcia_register_client(&link->handle, &client_reg);
     if (ret != CS_SUCCESS) {
 	cs_error(link->handle, RegisterClient, ret);
 	pcnet_detach(link);
@@ -342,7 +342,7 @@ static void pcnet_detach(dev_link_t *lin
     }
 
     if (link->handle)
-	CardServices(DeregisterClient, link->handle);
+	pcmcia_deregister_client(link->handle);
 
     /* Unlink device structure, free bits */
     *linkp = link->next;
@@ -373,8 +373,7 @@ static hw_info_t *get_hwinfo(dev_link_t 
     req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
     req.Base = 0; req.Size = 0;
     req.AccessSpeed = 0;
-    link->win = (window_handle_t)link->handle;
-    i = CardServices(RequestWindow, &link->win, &req);
+    i = pcmcia_request_window(&link->handle, &req, &link->win);
     if (i != CS_SUCCESS) {
 	cs_error(link->handle, RequestWindow, i);
 	return NULL;
@@ -384,7 +383,7 @@ static hw_info_t *get_hwinfo(dev_link_t 
     mem.Page = 0;
     for (i = 0; i < NR_INFO; i++) {
 	mem.CardOffset = hw_info[i].offset & ~(req.Size-1);
-	CardServices(MapMemPage, link->win, &mem);
+	pcmcia_map_mem_page(link->win, &mem);
 	base = &virt[hw_info[i].offset & (req.Size-1)];
 	if ((readb(base+0) == hw_info[i].a0) &&
 	    (readb(base+2) == hw_info[i].a1) &&
@@ -397,7 +396,7 @@ static hw_info_t *get_hwinfo(dev_link_t 
     }
     
     iounmap(virt);
-    j = CardServices(ReleaseWindow, link->win);
+    j = pcmcia_release_window(link->win);
     if (j != CS_SUCCESS)
 	cs_error(link->handle, ReleaseWindow, j);
     return (i < NR_INFO) ? hw_info+i : NULL;
@@ -544,11 +543,8 @@ static hw_info_t *get_hwired(dev_link_t 
 
 ======================================================================*/
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
-
-#define CFG_CHECK(fn, args...) \
-if (CardServices(fn, args) != 0) goto next_entry
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static int try_io_port(dev_link_t *link)
 {
@@ -571,12 +567,12 @@ static int try_io_port(dev_link_t *link)
 	for (j = 0; j < 0x400; j += 0x20) {
 	    link->io.BasePort1 = j ^ 0x300;
 	    link->io.BasePort2 = (j ^ 0x300) + 0x10;
-	    ret = CardServices(RequestIO, link->handle, &link->io);
+	    ret = pcmcia_request_io(link->handle, &link->io);
 	    if (ret == CS_SUCCESS) return ret;
 	}
 	return ret;
     } else {
-	return CardServices(RequestIO, link->handle, &link->io);
+	return pcmcia_request_io(link->handle, &link->io);
     }
 }
 
@@ -600,9 +596,9 @@ static void pcnet_config(dev_link_t *lin
     tuple.TupleDataMax = sizeof(buf);
     tuple.TupleOffset = 0;
     tuple.DesiredTuple = CISTPL_CONFIG;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
-    CS_CHECK(GetTupleData, handle, &tuple);
-    CS_CHECK(ParseTuple, handle, &tuple, &parse);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+    CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+    CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
     link->conf.ConfigBase = parse.config.base;
     link->conf.Present = parse.config.rmask[0];
 
@@ -610,28 +606,28 @@ static void pcnet_config(dev_link_t *lin
     link->state |= DEV_CONFIG;
 
     /* Look up current Vcc */
-    CS_CHECK(GetConfigurationInfo, handle, &conf);
+    CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf));
     link->conf.Vcc = conf.Vcc;
 
     tuple.DesiredTuple = CISTPL_MANFID;
     tuple.Attributes = TUPLE_RETURN_COMMON;
-    if ((CardServices(GetFirstTuple, handle, &tuple) == CS_SUCCESS) &&
- 	(CardServices(GetTupleData, handle, &tuple) == CS_SUCCESS)) {
+    if ((pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) &&
+ 	(pcmcia_get_tuple_data(handle, &tuple) == CS_SUCCESS)) {
 	manfid = le16_to_cpu(buf[0]);
 	prodid = le16_to_cpu(buf[1]);
     }
     
     tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
     tuple.Attributes = 0;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
     while (last_ret == CS_SUCCESS) {
 	cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
 	cistpl_io_t *io = &(parse.cftable_entry.io);
 	
-	CFG_CHECK(GetTupleData, handle, &tuple);
-	CFG_CHECK(ParseTuple, handle, &tuple, &parse);
-	if ((cfg->index == 0) || (cfg->io.nwin == 0))
-	    goto next_entry;
+	if (pcmcia_get_tuple_data(handle, &tuple) != 0 ||
+			pcmcia_parse_tuple(handle, &tuple, &parse) != 0 ||
+			cfg->index == 0 || cfg->io.nwin == 0)
+		goto next_entry;
 	
 	link->conf.ConfigIndex = cfg->index;
 	/* For multifunction cards, by convention, we configure the
@@ -653,14 +649,14 @@ static void pcnet_config(dev_link_t *lin
 	    if (last_ret == CS_SUCCESS) break;
 	}
     next_entry:
-	last_ret = CardServices(GetNextTuple, handle, &tuple);
+	last_ret = pcmcia_get_next_tuple(handle, &tuple);
     }
     if (last_ret != CS_SUCCESS) {
 	cs_error(handle, RequestIO, last_ret);
 	goto failed;
     }
 
-    CS_CHECK(RequestIRQ, handle, &link->irq);
+    CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq));
     
     if (link->io.NumPorts2 == 8) {
 	link->conf.Attributes |= CONF_ENABLE_SPKR;
@@ -670,7 +666,7 @@ static void pcnet_config(dev_link_t *lin
 	(prodid == PRODID_IBM_HOME_AND_AWAY))
 	link->conf.ConfigIndex |= 0x10;
     
-    CS_CHECK(RequestConfiguration, handle, &link->conf);
+    CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf));
     dev->irq = link->irq.AssignedIRQ;
     dev->base_addr = link->io.BasePort1;
     if (info->flags & HAS_MISC_REG) {
@@ -799,11 +795,11 @@ static void pcnet_release(dev_link_t *li
 
     if (info->flags & USE_SHMEM) {
 	iounmap(info->base);
-	CardServices(ReleaseWindow, link->win);
+	pcmcia_release_window(link->win);
     }
-    CardServices(ReleaseConfiguration, link->handle);
-    CardServices(ReleaseIO, link->handle, &link->io);
-    CardServices(ReleaseIRQ, link->handle, &link->irq);
+    pcmcia_release_configuration(link->handle);
+    pcmcia_release_io(link->handle, &link->io);
+    pcmcia_release_irq(link->handle, &link->irq);
 
     link->state &= ~DEV_CONFIG;
 
@@ -847,7 +843,7 @@ static int pcnet_event(event_t event, in
 	if (link->state & DEV_CONFIG) {
 	    if (link->open)
 		netif_device_detach(&info->dev);
-	    CardServices(ReleaseConfiguration, link->handle);
+	    pcmcia_release_configuration(link->handle);
 	}
 	break;
     case CS_EVENT_PM_RESUME:
@@ -855,7 +851,7 @@ static int pcnet_event(event_t event, in
 	/* Fall through... */
     case CS_EVENT_CARD_RESET:
 	if (link->state & DEV_CONFIG) {
-	    CardServices(RequestConfiguration, link->handle, &link->conf);
+	    pcmcia_request_configuration(link->handle, &link->conf);
 	    if (link->open) {
 		pcnet_reset_8390(&info->dev);
 		NS8390_init(&info->dev, 1);
@@ -1620,14 +1616,13 @@ static int setup_shmem_window(dev_link_t
     req.Attributes |= WIN_USE_WAIT;
     req.Base = 0; req.Size = window_size;
     req.AccessSpeed = mem_speed;
-    link->win = (window_handle_t)link->handle;
-    CS_CHECK(RequestWindow, &link->win, &req);
+    CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &link->win));
 
     mem.CardOffset = (start_pg << 8) + cm_offset;
     offset = mem.CardOffset % window_size;
     mem.CardOffset -= offset;
     mem.Page = 0;
-    CS_CHECK(MapMemPage, link->win, &mem);
+    CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem));
 
     /* Try scribbling on the buffer */
     info->base = ioremap(req.Base, window_size);
@@ -1639,7 +1634,7 @@ static int setup_shmem_window(dev_link_t
     pcnet_reset_8390(dev);
     if (i != (TX_PAGES<<8)) {
 	iounmap(info->base);
-	CardServices(ReleaseWindow, link->win);
+	pcmcia_release_window(link->win);
 	info->base = NULL; link->win = NULL;
 	goto failed;
     }
diff -puN drivers/net/pcmcia/smc91c92_cs.c~linus drivers/net/pcmcia/smc91c92_cs.c
--- 25/drivers/net/pcmcia/smc91c92_cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/pcmcia/smc91c92_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -379,7 +379,7 @@ static dev_link_t *smc91c92_attach(void)
     client_reg.event_handler = &smc91c92_event;
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
-    ret = CardServices(RegisterClient, &link->handle, &client_reg);
+    ret = pcmcia_register_client(&link->handle, &client_reg);
     if (ret != 0) {
 	cs_error(link->handle, RegisterClient, ret);
 	smc91c92_detach(link);
@@ -418,7 +418,7 @@ static void smc91c92_detach(dev_link_t *
     }
 
     if (link->handle)
-	CardServices(DeregisterClient, link->handle);
+	pcmcia_deregister_client(link->handle);
 
     /* Unlink device structure, free bits */
     *linkp = link->next;
@@ -453,19 +453,27 @@ static int cvt_ascii_address(struct net_
 
 /*====================================================================*/
 
-static int get_tuple(int fn, client_handle_t handle, tuple_t *tuple,
-		     cisparse_t *parse)
+static int first_tuple(client_handle_t handle, tuple_t *tuple,
+		cisparse_t *parse)
 {
-    int i;
-    i = CardServices(fn, handle, tuple);
-    if (i != CS_SUCCESS) return i;
-    i = CardServices(GetTupleData, handle, tuple);
-    if (i != CS_SUCCESS) return i;
-    return CardServices(ParseTuple, handle, tuple, parse);
+	int i;
+
+	if ((i = pcmcia_get_first_tuple(handle, tuple)) != CS_SUCCESS ||
+			(i = pcmcia_get_tuple_data(handle, tuple)) != CS_SUCCESS)
+		return i;
+	return pcmcia_parse_tuple(handle, tuple, parse);
 }
 
-#define first_tuple(a, b, c) get_tuple(GetFirstTuple, a, b, c)
-#define next_tuple(a, b, c) get_tuple(GetNextTuple, a, b, c)
+static int next_tuple(client_handle_t handle, tuple_t *tuple,
+		cisparse_t *parse)
+{
+	int i;
+
+	if ((i = pcmcia_get_next_tuple(handle, tuple)) != CS_SUCCESS ||
+			(i = pcmcia_get_tuple_data(handle, tuple)) != CS_SUCCESS)
+		return i;
+	return pcmcia_parse_tuple(handle, tuple, parse);
+}
 
 /*======================================================================
 
@@ -534,7 +542,7 @@ static int mhz_mfc_config(dev_link_t *li
 	for (k = 0; k < 0x400; k += 0x10) {
 	    if (k & 0x80) continue;
 	    link->io.BasePort1 = k ^ 0x300;
-	    i = CardServices(RequestIO, link->handle, &link->io);
+	    i = pcmcia_request_io(link->handle, &link->io);
 	    if (i == CS_SUCCESS) break;
 	}
 	if (i == CS_SUCCESS) break;
@@ -548,15 +556,14 @@ static int mhz_mfc_config(dev_link_t *li
     req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
     req.Base = req.Size = 0;
     req.AccessSpeed = 0;
-    link->win = (window_handle_t)link->handle;
-    i = CardServices(RequestWindow, &link->win, &req);
+    i = pcmcia_request_window(&link->handle, &req, &link->win);
     if (i != CS_SUCCESS)
 	return i;
     smc->base = ioremap(req.Base, req.Size);
     mem.CardOffset = mem.Page = 0;
     if (smc->manfid == MANFID_MOTOROLA)
 	mem.CardOffset = link->conf.ConfigBase;
-    i = CardServices(MapMemPage, link->win, &mem);
+    i = pcmcia_map_mem_page(link->win, &mem);
 
     if ((i == CS_SUCCESS)
 	&& (smc->manfid == MANFID_MEGAHERTZ)
@@ -594,9 +601,9 @@ static int mhz_setup(dev_link_t *link)
 
     /* Another possibility: for the EM3288, in a special tuple */
     tuple.DesiredTuple = 0x81;
-    if (CardServices(GetFirstTuple, handle, &tuple) != CS_SUCCESS)
+    if (pcmcia_get_first_tuple(handle, &tuple) != CS_SUCCESS)
 	return -1;
-    if (CardServices(GetTupleData, handle, &tuple) != CS_SUCCESS)
+    if (pcmcia_get_tuple_data(handle, &tuple) != CS_SUCCESS)
 	return -1;
     buf[12] = '\0';
     if (cvt_ascii_address(dev, buf) == 0)
@@ -690,7 +697,7 @@ static int smc_config(dev_link_t *link)
 	    link->conf.ConfigIndex = cf->index;
 	    link->io.BasePort1 = cf->io.win[0].base;
 	    link->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK;
-	    i = CardServices(RequestIO, link->handle, &link->io);
+	    i = pcmcia_request_io(link->handle, &link->io);
 	    if (i == CS_SUCCESS) break;
 	}
 	i = next_tuple(link->handle, &tuple, &parse);
@@ -763,14 +770,14 @@ static int osi_config(dev_link_t *link)
 
     for (i = j = 0; j < 4; j++) {
 	link->io.BasePort2 = com[j];
-	i = CardServices(RequestIO, link->handle, &link->io);
+	i = pcmcia_request_io(link->handle, &link->io);
 	if (i == CS_SUCCESS) break;
     }
     if (i != CS_SUCCESS) {
 	/* Fallback: turn off hard decode */
 	link->conf.ConfigIndex = 0x03;
 	link->io.NumPorts2 = 0;
-	i = CardServices(RequestIO, link->handle, &link->io);
+	i = pcmcia_request_io(link->handle, &link->io);
     }
     dev->base_addr = link->io.BasePort1 + 0x10;
     return i;
@@ -791,12 +798,12 @@ static int osi_setup(dev_link_t *link, u
 
     /* Read the station address from tuple 0x90, subtuple 0x04 */
     tuple.DesiredTuple = 0x90;
-    i = CardServices(GetFirstTuple, handle, &tuple);
+    i = pcmcia_get_first_tuple(handle, &tuple);
     while (i == CS_SUCCESS) {
-	i = CardServices(GetTupleData, handle, &tuple);
+	i = pcmcia_get_tuple_data(handle, &tuple);
 	if ((i != CS_SUCCESS) || (buf[0] == 0x04))
 	    break;
-	i = CardServices(GetNextTuple, handle, &tuple);
+	i = pcmcia_get_next_tuple(handle, &tuple);
     }
     if (i != CS_SUCCESS)
 	return -1;
@@ -869,9 +876,9 @@ static int check_sig(dev_link_t *link)
 	printk(KERN_INFO "smc91c92_cs: using 8-bit IO window.\n");
 	args.client_data = link;
 	smc91c92_event(CS_EVENT_RESET_PHYSICAL, 0, &args);
-	CardServices(ReleaseIO, link->handle, &link->io);
+	pcmcia_release_io(link->handle, &link->io);
 	link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
-	CardServices(RequestIO, link->handle, &link->io);
+	pcmcia_request_io(link->handle, &link->io);
 	smc91c92_event(CS_EVENT_CARD_RESET, 0, &args);
 	return check_sig(link);
     }
@@ -936,9 +943,9 @@ static void smc91c92_config(dev_link_t *
     }
     CS_EXIT_TEST(i, RequestIO, config_failed);
 
-    i = CardServices(RequestIRQ, link->handle, &link->irq);
+    i = pcmcia_request_irq(link->handle, &link->irq);
     CS_EXIT_TEST(i, RequestIRQ, config_failed);
-    i = CardServices(RequestConfiguration, link->handle, &link->conf);
+    i = pcmcia_request_configuration(link->handle, &link->conf);
     CS_EXIT_TEST(i, RequestConfiguration, config_failed);
 
     if (smc->manfid == MANFID_MOTOROLA)
@@ -1070,14 +1077,14 @@ static void smc91c92_release(dev_link_t 
 	return;
     }
 
-    CardServices(ReleaseConfiguration, link->handle);
-    CardServices(ReleaseIO, link->handle, &link->io);
-    CardServices(ReleaseIRQ, link->handle, &link->irq);
+    pcmcia_release_configuration(link->handle);
+    pcmcia_release_io(link->handle, &link->io);
+    pcmcia_release_irq(link->handle, &link->irq);
     if (link->win) {
 	struct net_device *dev = link->priv;
 	struct smc_private *smc = dev->priv;
 	iounmap(smc->base);
-	CardServices(ReleaseWindow, link->win);
+	pcmcia_release_window(link->win);
     }
 
     link->state &= ~DEV_CONFIG;
@@ -1124,7 +1131,7 @@ static int smc91c92_event(event_t event,
 	if (link->state & DEV_CONFIG) {
 	    if (link->open)
 		netif_device_detach(dev);
-	    CardServices(ReleaseConfiguration, link->handle);
+	    pcmcia_release_configuration(link->handle);
 	}
 	break;
     case CS_EVENT_PM_RESUME:
@@ -1135,7 +1142,7 @@ static int smc91c92_event(event_t event,
 	    if ((smc->manfid == MANFID_MEGAHERTZ) &&
 		(smc->cardid == PRODID_MEGAHERTZ_EM3288))
 		mhz_3288_power(link);
-	    CardServices(RequestConfiguration, link->handle, &link->conf);
+	    pcmcia_request_configuration(link->handle, &link->conf);
 	    if (smc->manfid == MANFID_MOTOROLA)
 		mot_config(link);
 	    if ((smc->manfid == MANFID_OSITECH) &&
diff -puN drivers/net/pcmcia/xirc2ps_cs.c~linus drivers/net/pcmcia/xirc2ps_cs.c
--- 25/drivers/net/pcmcia/xirc2ps_cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/pcmcia/xirc2ps_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -391,28 +391,27 @@ static int do_stop(struct net_device *de
 
 /*=============== Helper functions =========================*/
 static int
-get_tuple_data(int fn, client_handle_t handle, tuple_t *tuple)
+first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
 {
-    int err;
+	int err;
 
-    if ((err=CardServices(fn, handle, tuple)))
+	if ((err = pcmcia_get_first_tuple(handle, tuple)) == 0 &&
+			(err = pcmcia_get_tuple_data(handle, tuple)) == 0)
+		err = pcmcia_parse_tuple(handle, tuple, parse);
 	return err;
-    return CardServices(GetTupleData, handle, tuple);
 }
 
 static int
-get_tuple(int fn, client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
+next_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
 {
-    int err;
+	int err;
 
-    if ((err=get_tuple_data(fn, handle, tuple)))
+	if ((err = pcmcia_get_next_tuple(handle, tuple)) == 0 &&
+			(err = pcmcia_get_tuple_data(handle, tuple)) == 0)
+		err = pcmcia_parse_tuple(handle, tuple, parse);
 	return err;
-    return CardServices(ParseTuple, handle, tuple, parse);
 }
 
-#define first_tuple(a, b, c) get_tuple(GetFirstTuple, a, b, c)
-#define next_tuple(a, b, c)  get_tuple(GetNextTuple, a, b, c)
-
 #define SelectPage(pgnr)   outb((pgnr), ioaddr + XIRCREG_PR)
 #define GetByte(reg)	   ((unsigned)inb(ioaddr + (reg)))
 #define GetWord(reg)	   ((unsigned)inw(ioaddr + (reg)))
@@ -636,7 +635,7 @@ xirc2ps_attach(void)
     client_reg.event_handler = &xirc2ps_event;
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
-    if ((err = CardServices(RegisterClient, &link->handle, &client_reg))) {
+    if ((err = pcmcia_register_client(&link->handle, &client_reg))) {
 	cs_error(link->handle, RegisterClient, err);
 	xirc2ps_detach(link);
 	return NULL;
@@ -680,7 +679,7 @@ xirc2ps_detach(dev_link_t * link)
 
     /* Break the link with Card Services */
     if (link->handle)
-	CardServices(DeregisterClient, link->handle);
+	pcmcia_deregister_client(link->handle);
 
     /* Unlink device structure, free it */
     *linkp = link->next;
@@ -887,7 +886,8 @@ xirc2ps_config(dev_link_t * link)
     }
     if (err) { /* not found: try to get the node-id from tuple 0x89 */
 	tuple.DesiredTuple = 0x89;  /* data layout looks like tuple 0x22 */
-	if (!(err = get_tuple_data(GetFirstTuple, handle, &tuple))) {
+	if ((err = pcmcia_get_first_tuple(handle, &tuple)) == 0 &&
+		(err = pcmcia_get_tuple_data(handle, &tuple)) == 0) {
 	    if (tuple.TupleDataLen == 8 && *buf == CISTPL_FUNCE_LAN_NODE_ID)
 		memcpy(&parse, buf, 8);
 	    else
@@ -953,8 +953,7 @@ xirc2ps_config(dev_link_t * link)
 			link->conf.ConfigIndex = cf->index ;
 			link->io.BasePort2 = cf->io.win[0].base;
 			link->io.BasePort1 = ioaddr;
-			if (!(err=CardServices(RequestIO, link->handle,
-								&link->io)))
+			if (!(err=pcmcia_request_io(link->handle, &link->io)))
 			    goto port_found;
 		    }
 		}
@@ -976,8 +975,7 @@ xirc2ps_config(dev_link_t * link)
 			link->io.BasePort1 = link->io.BasePort2
 				    + (pass ? (cf->index & 0x20 ? -24:8)
 					    : (cf->index & 0x20 ?   8:-24));
-			if (!(err=CardServices(RequestIO, link->handle,
-								&link->io)))
+			if (!(err=pcmcia_request_io(link->handle, &link->io)))
 			    goto port_found;
 		    }
 		}
@@ -992,11 +990,11 @@ xirc2ps_config(dev_link_t * link)
 	link->io.NumPorts1 = 16;
 	for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) {
 	    link->io.BasePort1 = ioaddr;
-	    if (!(err=CardServices(RequestIO, link->handle, &link->io)))
+	    if (!(err=pcmcia_request_io(link->handle, &link->io)))
 		goto port_found;
 	}
 	link->io.BasePort1 = 0; /* let CS decide */
-	if ((err=CardServices(RequestIO, link->handle, &link->io))) {
+	if ((err=pcmcia_request_io(link->handle, &link->io))) {
 	    cs_error(link->handle, RequestIO, err);
 	    goto config_error;
 	}
@@ -1009,7 +1007,7 @@ xirc2ps_config(dev_link_t * link)
      * Now allocate an interrupt line.	Note that this does not
      * actually assign a handler to the interrupt.
      */
-    if ((err=CardServices(RequestIRQ, link->handle, &link->irq))) {
+    if ((err=pcmcia_request_irq(link->handle, &link->irq))) {
 	cs_error(link->handle, RequestIRQ, err);
 	goto config_error;
     }
@@ -1018,8 +1016,7 @@ xirc2ps_config(dev_link_t * link)
      * This actually configures the PCMCIA socket -- setting up
      * the I/O windows and the interrupt mapping.
      */
-    if ((err=CardServices(RequestConfiguration,
-			  link->handle, &link->conf))) {
+    if ((err=pcmcia_request_configuration(link->handle, &link->conf))) {
 	cs_error(link->handle, RequestConfiguration, err);
 	goto config_error;
     }
@@ -1037,16 +1034,14 @@ xirc2ps_config(dev_link_t * link)
 	reg.Action = CS_WRITE;
 	reg.Offset = CISREG_IOBASE_0;
 	reg.Value = link->io.BasePort2 & 0xff;
-	if ((err = CardServices(AccessConfigurationRegister, link->handle,
-				&reg))) {
+	if ((err = pcmcia_access_configuration_register(link->handle, &reg))) {
 	    cs_error(link->handle, AccessConfigurationRegister, err);
 	    goto config_error;
 	}
 	reg.Action = CS_WRITE;
 	reg.Offset = CISREG_IOBASE_1;
 	reg.Value = (link->io.BasePort2 >> 8) & 0xff;
-	if ((err = CardServices(AccessConfigurationRegister, link->handle,
-				&reg))) {
+	if ((err = pcmcia_access_configuration_register(link->handle, &reg))) {
 	    cs_error(link->handle, AccessConfigurationRegister, err);
 	    goto config_error;
 	}
@@ -1058,15 +1053,14 @@ xirc2ps_config(dev_link_t * link)
 	req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
 	req.Base = req.Size = 0;
 	req.AccessSpeed = 0;
-	link->win = (window_handle_t)link->handle;
-	if ((err = CardServices(RequestWindow, &link->win, &req))) {
+	if ((err = pcmcia_request_window(&link->handle, &req, &link->win))) {
 	    cs_error(link->handle, RequestWindow, err);
 	    goto config_error;
 	}
 	local->dingo_ccr = ioremap(req.Base,0x1000) + 0x0800;
 	mem.CardOffset = 0x0;
 	mem.Page = 0;
-	if ((err = CardServices(MapMemPage, link->win, &mem))) {
+	if ((err = pcmcia_map_mem_page(link->win, &mem))) {
 	    cs_error(link->handle, MapMemPage, err);
 	    goto config_error;
 	}
@@ -1171,11 +1165,11 @@ xirc2ps_release(dev_link_t *link)
 	local_info_t *local = dev->priv;
 	if (local->dingo)
 	    iounmap(local->dingo_ccr - 0x0800);
-	CardServices(ReleaseWindow, link->win);
+	pcmcia_release_window(link->win);
     }
-    CardServices(ReleaseConfiguration, link->handle);
-    CardServices(ReleaseIO, link->handle, &link->io);
-    CardServices(ReleaseIRQ, link->handle, &link->irq);
+    pcmcia_release_configuration(link->handle);
+    pcmcia_release_io(link->handle, &link->io);
+    pcmcia_release_irq(link->handle, &link->irq);
     link->state &= ~DEV_CONFIG;
 
 } /* xirc2ps_release */
@@ -1227,7 +1221,7 @@ xirc2ps_event(event_t event, int priorit
 		netif_device_detach(dev);
 		do_powerdown(dev);
 	    }
-	    CardServices(ReleaseConfiguration, link->handle);
+	    pcmcia_release_configuration(link->handle);
 	}
 	break;
     case CS_EVENT_PM_RESUME:
@@ -1235,7 +1229,7 @@ xirc2ps_event(event_t event, int priorit
 	/* Fall through... */
     case CS_EVENT_CARD_RESET:
 	if (link->state & DEV_CONFIG) {
-	    CardServices(RequestConfiguration, link->handle, &link->conf);
+	    pcmcia_request_configuration(link->handle, &link->conf);
 	    if (link->open) {
 		do_reset(dev,1);
 		netif_device_attach(dev);
diff -puN drivers/net/ppp_async.c~linus drivers/net/ppp_async.c
--- 25/drivers/net/ppp_async.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/ppp_async.c	2004-01-19 22:17:22.000000000 -0800
@@ -16,8 +16,6 @@
  * Part of the code in this driver was inspired by the old async-only
  * PPP driver, written by Michael Callahan and Al Longyear, and
  * subsequently hacked by Paul Mackerras.
- *
- * ==FILEVERSION 20020125==
  */
 
 #include <linux/module.h>
@@ -61,6 +59,9 @@ struct asyncppp {
 
 	struct sk_buff	*rpkt;
 	int		lcp_fcs;
+	struct sk_buff_head rqueue;
+
+	struct tasklet_struct tsk;
 
 	atomic_t	refcnt;
 	struct semaphore dead_sem;
@@ -74,8 +75,9 @@ struct asyncppp {
 #define XMIT_BUSY	2
 
 /* State bits */
-#define SC_TOSS		0x20000000
-#define SC_ESCAPE	0x40000000
+#define SC_TOSS		1
+#define SC_ESCAPE	2
+#define SC_PREV_ERROR	4
 
 /* Bits in rbits */
 #define SC_RCV_BITS	(SC_RCV_B7_1|SC_RCV_B7_0|SC_RCV_ODDP|SC_RCV_EVNP)
@@ -97,6 +99,8 @@ static void ppp_async_input(struct async
 			    char *flags, int count);
 static int ppp_async_ioctl(struct ppp_channel *chan, unsigned int cmd,
 			   unsigned long arg);
+static void ppp_async_process(unsigned long arg);
+
 static void async_lcp_peek(struct asyncppp *ap, unsigned char *data,
 			   int len, int inbound);
 
@@ -165,6 +169,9 @@ ppp_asynctty_open(struct tty_struct *tty
 	ap->olim = ap->obuf;
 	ap->lcp_fcs = -1;
 
+	skb_queue_head_init(&ap->rqueue);
+	tasklet_init(&ap->tsk, ppp_async_process, (unsigned long) ap);
+
 	atomic_set(&ap->refcnt, 1);
 	init_MUTEX_LOCKED(&ap->dead_sem);
 
@@ -214,10 +221,12 @@ ppp_asynctty_close(struct tty_struct *tt
 	 */
 	if (!atomic_dec_and_test(&ap->refcnt))
 		down(&ap->dead_sem);
+	tasklet_kill(&ap->tsk);
 
 	ppp_unregister_channel(&ap->chan);
 	if (ap->rpkt != 0)
 		kfree_skb(ap->rpkt);
+	skb_queue_purge(&ap->rqueue);
 	if (ap->tpkt != 0)
 		kfree_skb(ap->tpkt);
 	kfree(ap);
@@ -316,17 +325,24 @@ ppp_asynctty_room(struct tty_struct *tty
 	return 65535;
 }
 
+/*
+ * This can now be called from hard interrupt level as well
+ * as soft interrupt level or mainline.
+ */
 static void
 ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf,
-		  char *flags, int count)
+		  char *cflags, int count)
 {
 	struct asyncppp *ap = ap_get(tty);
+	unsigned long flags;
 
 	if (ap == 0)
 		return;
-	spin_lock_bh(&ap->recv_lock);
-	ppp_async_input(ap, buf, flags, count);
-	spin_unlock_bh(&ap->recv_lock);
+	spin_lock_irqsave(&ap->recv_lock, flags);
+	ppp_async_input(ap, buf, cflags, count);
+	spin_unlock_irqrestore(&ap->recv_lock, flags);
+	if (skb_queue_len(&ap->rqueue))
+		tasklet_schedule(&ap->tsk);
 	ap_put(ap);
 	if (test_and_clear_bit(TTY_THROTTLED, &tty->flags)
 	    && tty->driver->unthrottle)
@@ -341,8 +357,8 @@ ppp_asynctty_wakeup(struct tty_struct *t
 	clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
 	if (ap == 0)
 		return;
-	if (ppp_async_push(ap))
-		ppp_output_wakeup(&ap->chan);
+	set_bit(XMIT_WAKEUP, &ap->xmit_flags);
+	tasklet_schedule(&ap->tsk);
 	ap_put(ap);
 }
 
@@ -396,9 +412,9 @@ ppp_async_ioctl(struct ppp_channel *chan
 		if (get_user(val, (int *) arg))
 			break;
 		ap->flags = val & ~SC_RCV_BITS;
-		spin_lock_bh(&ap->recv_lock);
+		spin_lock_irq(&ap->recv_lock);
 		ap->rbits = val & SC_RCV_BITS;
-		spin_unlock_bh(&ap->recv_lock);
+		spin_unlock_irq(&ap->recv_lock);
 		err = 0;
 		break;
 
@@ -460,6 +476,28 @@ ppp_async_ioctl(struct ppp_channel *chan
 }
 
 /*
+ * This is called at softirq level to deliver received packets
+ * to the ppp_generic code, and to tell the ppp_generic code
+ * if we can accept more output now.
+ */
+static void ppp_async_process(unsigned long arg)
+{
+	struct asyncppp *ap = (struct asyncppp *) arg;
+	struct sk_buff *skb;
+
+	/* process received packets */
+	while ((skb = skb_dequeue(&ap->rqueue)) != NULL) {
+		if (skb->cb[0])
+			ppp_input_error(&ap->chan, 0);
+		ppp_input(&ap->chan, skb);
+	}
+
+	/* try to push more stuff out */
+	if (test_bit(XMIT_WAKEUP, &ap->xmit_flags) && ppp_async_push(ap))
+		ppp_output_wakeup(&ap->chan);
+}
+
+/*
  * Procedures for encapsulation and framing.
  */
 
@@ -641,7 +679,6 @@ ppp_async_push(struct asyncppp *ap)
 	struct tty_struct *tty = ap->tty;
 	int tty_stuffed = 0;
 
-	set_bit(XMIT_WAKEUP, &ap->xmit_flags);
 	/*
 	 * We can get called recursively here if the tty write
 	 * function calls our wakeup function.  This can happen
@@ -752,22 +789,19 @@ scan_ordinary(struct asyncppp *ap, const
 }
 
 /* called when a flag is seen - do end-of-packet processing */
-static inline void
+static void
 process_input_packet(struct asyncppp *ap)
 {
 	struct sk_buff *skb;
 	unsigned char *p;
 	unsigned int len, fcs, proto;
-	int code = 0;
 
 	skb = ap->rpkt;
-	ap->rpkt = 0;
-	if ((ap->state & (SC_TOSS | SC_ESCAPE)) || skb == 0) {
-		ap->state &= ~(SC_TOSS | SC_ESCAPE);
-		if (skb != 0)
-			kfree_skb(skb);
-		return;
-	}
+	if (ap->state & (SC_TOSS | SC_ESCAPE))
+		goto err;
+
+	if (skb == NULL)
+		return;		/* 0-length packet */
 
 	/* check the FCS */
 	p = skb->data;
@@ -801,20 +835,18 @@ process_input_packet(struct asyncppp *ap
 			async_lcp_peek(ap, p, skb->len, 1);
 	}
 
-	/* all OK, give it to the generic layer */
-	ppp_input(&ap->chan, skb);
+	/* queue the frame to be processed */
+	skb->cb[0] = ap->state;
+	skb_queue_tail(&ap->rqueue, skb);
+	ap->rpkt = 0;
+	ap->state = 0;
 	return;
 
  err:
-	kfree_skb(skb);
-	ppp_input_error(&ap->chan, code);
-}
-
-static inline void
-input_error(struct asyncppp *ap, int code)
-{
-	ap->state |= SC_TOSS;
-	ppp_input_error(&ap->chan, code);
+	/* frame had an error, remember that, reset SC_TOSS & SC_ESCAPE */
+	ap->state = SC_PREV_ERROR;
+	if (skb)
+		skb_trim(skb, 0);
 }
 
 /* called when the tty driver has data for us. */
@@ -856,7 +888,7 @@ ppp_async_input(struct asyncppp *ap, con
 		}
 		if (f != 0) {
 			/* start tossing */
-			input_error(ap, f);
+			ap->state |= SC_TOSS;
 
 		} else if (n > 0 && (ap->state & SC_TOSS) == 0) {
 			/* stuff the chars in the skb */
@@ -872,7 +904,7 @@ ppp_async_input(struct asyncppp *ap, con
 			}
 			if (n > skb_tailroom(skb)) {
 				/* packet overflowed MRU */
-				input_error(ap, 1);
+				ap->state |= SC_TOSS;
 			} else {
 				sp = skb_put(skb, n);
 				memcpy(sp, buf, n);
@@ -909,7 +941,7 @@ ppp_async_input(struct asyncppp *ap, con
 
  nomem:
 	printk(KERN_ERR "PPPasync: no memory (input pkt)\n");
-	input_error(ap, 0);
+	ap->state |= SC_TOSS;
 }
 
 /*
diff -puN drivers/net/pppoe.c~linus drivers/net/pppoe.c
--- 25/drivers/net/pppoe.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/pppoe.c	2004-01-19 22:17:22.000000000 -0800
@@ -775,8 +775,8 @@ static int pppoe_ioctl(struct socket *so
 }
 
 
-static int pppoe_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
-		  int total_len)
+static int pppoe_sendmsg(struct kiocb *iocb, struct socket *sock, 
+		  struct msghdr *m, size_t total_len)
 {
 	struct sk_buff *skb = NULL;
 	struct sock *sk = sock->sk;
@@ -939,7 +939,7 @@ static struct ppp_channel_ops pppoe_chan
 };
 
 static int pppoe_recvmsg(struct kiocb *iocb, struct socket *sock,
-		  struct msghdr *m, int total_len, int flags)
+		  struct msghdr *m, size_t total_len, int flags)
 {
 	struct sock *sk = sock->sk;
 	struct sk_buff *skb = NULL;
diff -puN drivers/net/sk98lin/h/skcsum.h~linus drivers/net/sk98lin/h/skcsum.h
--- 25/drivers/net/sk98lin/h/skcsum.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/h/skcsum.h	2004-01-19 22:17:22.000000000 -0800
@@ -2,8 +2,8 @@
  *
  * Name:	skcsum.h
  * Project:	GEnesis - SysKonnect SK-NET Gigabit Ethernet (SK-98xx)
- * Version:	$Revision: 1.9 $
- * Date:	$Date: 2001/02/06 11:21:39 $
+ * Version:	$Revision: 1.10 $
+ * Date:	$Date: 2003/08/20 13:59:57 $
  * Purpose:	Store/verify Internet checksum in send/receive packets.
  *
  ******************************************************************************/
@@ -26,6 +26,10 @@
  * History:
  *
  *	$Log: skcsum.h,v $
+ *	Revision 1.10  2003/08/20 13:59:57  mschmid
+ *	Changed notation of #ifndef SkCsCalculateChecksum to
+ *	#ifndef SK_CS_CALCULATE_CHECKSUM
+ *	
  *	Revision 1.9  2001/02/06 11:21:39  rassmann
  *	Editorial changes.
  *	
@@ -226,11 +230,11 @@ typedef struct s_CsPacketInfo {
 
 /* function prototypes ********************************************************/
 
-#ifndef SkCsCalculateChecksum
+#ifndef SK_CS_CALCULATE_CHECKSUM
 extern unsigned SkCsCalculateChecksum(
 	void		*pData,
 	unsigned	Length);
-#endif
+#endif /* SK_CS_CALCULATE_CHECKSUM */
 
 extern int SkCsEvent(
 	SK_AC		*pAc,
diff -puN drivers/net/sk98lin/h/skdrv1st.h~linus drivers/net/sk98lin/h/skdrv1st.h
--- 25/drivers/net/sk98lin/h/skdrv1st.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/h/skdrv1st.h	2004-01-19 22:17:22.000000000 -0800
@@ -2,15 +2,16 @@
  *
  * Name:	skdrv1st.h
  * Project:	GEnesis, PCI Gigabit Ethernet Adapter
- * Version:	$Revision: 1.1 $
- * Date:	$Date: 2003/07/21 07:22:43 $
+ * Version:	$Revision: 1.4 $
+ * Date:	$Date: 2003/11/12 14:28:14 $
  * Purpose:	First header file for driver and all other modules
  *
  ******************************************************************************/
 
 /******************************************************************************
  *
- *	(C)Copyright 1998-2003 SysKonnect GmbH.
+ *	(C)Copyright 1998-2002 SysKonnect GmbH.
+ *	(C)Copyright 2002-2003 Marvell.
  *
  *	This program is free software; you can redistribute it and/or modify
  *	it under the terms of the GNU General Public License as published by
@@ -26,6 +27,15 @@
  * History:
  *
  *	$Log: skdrv1st.h,v $
+ *	Revision 1.4  2003/11/12 14:28:14  rroesler
+ *	Fix: use dedicated ip_fast_csum() on X86_64 systems
+ *	
+ *	Revision 1.3  2003/10/07 08:16:52  mlindner
+ *	Fix: Copyright changes
+ *	
+ *	Revision 1.2  2003/09/29 12:05:59  mlindner
+ *	Fix: Added define SK_CS_CALCULSTE_CHECKSUM
+ *	
  *	Revision 1.1  2003/07/21 07:22:43  rroesler
  *	Fix: Re-Enter after CVS crash
  *	
@@ -110,6 +120,9 @@
 #ifndef __INC_SKDRV1ST_H
 #define __INC_SKDRV1ST_H
 
+/* Check kernel version */
+#include <linux/version.h>
+
 typedef struct s_AC	SK_AC;
 
 /* Set card versions */
@@ -124,17 +137,15 @@ typedef struct s_AC	SK_AC;
 #define SK_PNMI_READ_U32(p,v)		memcpy((char*)&(v),(char*)(p),4)
 #define SK_PNMI_READ_U64(p,v)		memcpy((char*)&(v),(char*)(p),8)
 
-#define SkCsCalculateChecksum(p,l)	((~ip_compute_csum(p, l)) & 0xffff)
-
 #define SK_ADDR_EQUAL(a1,a2)		(!memcmp(a1,a2,6))
 
-
 #if !defined(__OPTIMIZE__)  ||  !defined(__KERNEL__)
 #warning  You must compile this file with the correct options!
 #warning  See the last lines of the source file.
 #error You must compile this driver with "-O".
 #endif
 
+#include <linux/version.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
@@ -154,6 +165,13 @@ typedef struct s_AC	SK_AC;
 #include <asm/uaccess.h>
 #include <net/checksum.h>
 
+#define SK_CS_CALCULATE_CHECKSUM
+#ifndef CONFIG_X86_64
+#define SkCsCalculateChecksum(p,l)	((~ip_compute_csum(p, l)) & 0xffff)
+#else
+#define SkCsCalculateChecksum(p,l)	((~ip_fast_csum(p, l)) & 0xffff)
+#endif
+
 #include	"h/sktypes.h"
 #include	"h/skerror.h"
 #include	"h/skdebug.h"
diff -puN drivers/net/sk98lin/h/skdrv2nd.h~linus drivers/net/sk98lin/h/skdrv2nd.h
--- 25/drivers/net/sk98lin/h/skdrv2nd.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/h/skdrv2nd.h	2004-01-19 22:17:22.000000000 -0800
@@ -2,15 +2,16 @@
  *
  * Name:	skdrv2nd.h
  * Project:	GEnesis, PCI Gigabit Ethernet Adapter
- * Version:	$Revision: 1.3 $
- * Date:	$Date: 2003/08/12 16:51:18 $
+ * Version:	$Revision: 1.10 $
+ * Date:	$Date: 2003/12/11 16:04:45 $
  * Purpose:	Second header file for driver and all other modules
  *
  ******************************************************************************/
 
 /******************************************************************************
  *
- *	(C)Copyright 1998-2003 SysKonnect GmbH.
+ *	(C)Copyright 1998-2002 SysKonnect GmbH.
+ *	(C)Copyright 2002-2003 Marvell.
  *
  *	This program is free software; you can redistribute it and/or modify
  *	it under the terms of the GNU General Public License as published by
@@ -26,6 +27,27 @@
  * History:
  *
  *	$Log: skdrv2nd.h,v $
+ *	Revision 1.10  2003/12/11 16:04:45  mlindner
+ *	Add: New pnmi data backup structure
+ *	
+ *	Revision 1.9  2003/11/10 09:31:37  rroesler
+ *	Add: pnmiBackup structure for DIAG backup restore
+ *	
+ *	Revision 1.8  2003/10/22 14:18:32  rroesler
+ *	Fix: DIAG handling for DualNet cards
+ *	
+ *	Revision 1.7  2003/10/07 09:34:59  mlindner
+ *	Add: New defines for lower and upper range values (interrupt moderation)
+ *	
+ *	Revision 1.6  2003/10/07 08:16:51  mlindner
+ *	Fix: Copyright changes
+ *	
+ *	Revision 1.5  2003/09/01 13:10:39  rroesler
+ *	Add: Prototypes for DIAG Attach/Detach functions
+ *	
+ *	Revision 1.4  2003/09/01 12:33:38  rroesler
+ *	Add: Defines for optimized DIAG interaction
+ *	
  *	Revision 1.3  2003/08/12 16:51:18  mlindner
  *	Fix: UDP and TCP Proto checks
  *	Fix: UDP header offset
@@ -206,6 +228,11 @@ extern int		SkPciWriteCfgWord(SK_AC*, in
 extern int		SkPciWriteCfgByte(SK_AC*, int, SK_U8);
 extern int		SkDrvEvent(SK_AC*, SK_IOC IoC, SK_U32, SK_EVPARA);
 
+#ifdef SK_DIAG_SUPPORT
+extern int		SkDrvEnterDiagMode(SK_AC *pAc);
+extern int		SkDrvLeaveDiagMode(SK_AC *pAc);
+#endif
+
 struct s_DrvRlmtMbuf {
 	SK_MBUF		*pNext;		/* Pointer to next RLMT Mbuf. */
 	SK_U8		*pData;		/* Data buffer (virtually contig.). */
@@ -247,6 +274,7 @@ struct s_DrvRlmtMbuf {
 #define		SK_IOCTL_SETMIB		(SK_IOCTL_BASE + 1)
 #define		SK_IOCTL_PRESETMIB	(SK_IOCTL_BASE + 2)
 #define		SK_IOCTL_GEN		(SK_IOCTL_BASE + 3)
+#define		SK_IOCTL_DIAG		(SK_IOCTL_BASE + 4)
 
 typedef struct s_IOCTL	SK_GE_IOCTL;
 
@@ -462,6 +490,9 @@ struct s_RxPort {
 #define C_INTS_PER_SEC_DEFAULT      2000 
 #define C_INT_MOD_ENABLE_PERCENTAGE   50 /* if higher 50% enable */
 #define C_INT_MOD_DISABLE_PERCENTAGE  50 /* if lower 50% disable */
+#define C_INT_MOD_IPS_LOWER_RANGE     30
+#define C_INT_MOD_IPS_UPPER_RANGE     40000
+
 
 typedef struct s_DynIrqModInfo  DIM_INFO;
 struct s_DynIrqModInfo {
@@ -493,6 +524,11 @@ typedef struct s_PerStrm	PER_STRM;
 
 #define SK_ALLOC_IRQ	0x00000001
 
+#ifdef SK_DIAG_SUPPORT
+#define	DIAG_ACTIVE		1
+#define	DIAG_NOTACTIVE		0
+#endif
+
 /****************************************************************************
  * Per board structure / Adapter Context structure:
  *	Allocated within attach(9e) and freed within detach(9e).
@@ -563,9 +599,18 @@ struct s_AC  {
 	int		PortUp;
 	int		PortDown;
 	int		ChipsetType;	/*  Chipset family type 
-							 *  0 == Genesis family support
-							 *  1 == Yukon family support
-							 */
+					 *  0 == Genesis family support
+					 *  1 == Yukon family support
+					 */
+#ifdef SK_DIAG_SUPPORT
+	SK_U32		DiagModeActive;		/* is diag active?	*/
+	SK_BOOL		DiagFlowCtrl;		/* for control purposes	*/
+	SK_PNMI_STRUCT_DATA PnmiBackup;		/* backup structure for all Pnmi-Data */
+	SK_BOOL         WasIfUp[SK_MAX_MACS];   /* for OpenClose while 
+						 * DIAG is busy with NIC 
+						 */
+#endif
+
 };
 
 
diff -puN drivers/net/sk98lin/h/skgehw.h~linus drivers/net/sk98lin/h/skgehw.h
--- 25/drivers/net/sk98lin/h/skgehw.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/h/skgehw.h	2004-01-19 22:17:22.000000000 -0800
@@ -2,8 +2,8 @@
  *
  * Name:	skgehw.h
  * Project:	Gigabit Ethernet Adapters, Common Modules
- * Version:	$Revision: 1.53 $
- * Date:	$Date: 2003/07/04 12:39:01 $
+ * Version:	$Revision: 1.56 $
+ * Date:	$Date: 2003/09/23 09:01:00 $
  * Purpose:	Defines and Macros for the Gigabit Ethernet Adapter Product Family
  *
  ******************************************************************************/
@@ -26,6 +26,17 @@
  *
  * History:
  * $Log: skgehw.h,v $
+ * Revision 1.56  2003/09/23 09:01:00  malthoff
+ * Minor change: Define I2C device size constants as long.
+ *
+ * Revision 1.55  2003/09/16 14:03:34  rschmidt
+ * Added define for YUKON-Lite Rev. A1,A2 Chip Revision
+ * Moved defines for PHY power down modes to skgeinit.h
+ * Editorial changes
+ *
+ * Revision 1.54  2003/09/16 07:37:58  mschmid
+ * Added defines for Marvell PHY low power modes
+ *
  * Revision 1.53  2003/07/04 12:39:01  rschmidt
  * Added SK_FAR to pointers in XM_IN32() and GM_IN32() macros (for PXE)
  * Editorial changes
@@ -84,7 +95,7 @@
  * Editorial changes
  *
  * Revision 1.39  2002/06/10 09:37:07  rschmidt
- * Added macros for the ADDR-Modul
+ * Added macros for the ADDR-Module
  *
  * Revision 1.38  2002/06/05 08:15:19  rschmidt
  * Added defines for WOL Registers
@@ -628,12 +639,12 @@ extern "C" {
 #define B2_FAR			0x0120	/* 32 bit	Flash-Prom Addr Reg/Cnt */
 #define B2_FDP			0x0124	/*  8 bit	Flash-Prom Data Port */
 	/* 0x0125 - 0x0127:	reserved */
-#define B2_LD_CRTL		0x0128	/*  8 bit	EPROM loader control register */
+#define B2_LD_CTRL		0x0128	/*  8 bit	EPROM loader control register */
 #define B2_LD_TEST		0x0129	/*  8 bit	EPROM loader test register */
 	/* 0x012a - 0x012f:	reserved */
 #define B2_TI_INI		0x0130	/* 32 bit	Timer Init Value */
 #define B2_TI_VAL		0x0134	/* 32 bit	Timer Value */
-#define B2_TI_CRTL		0x0138	/*  8 bit	Timer Control */
+#define B2_TI_CTRL		0x0138	/*  8 bit	Timer Control */
 #define B2_TI_TEST		0x0139	/*  8 Bit	Timer Test */
 	/* 0x013a - 0x013f:	reserved */
 #define B2_IRQM_INI		0x0140	/* 32 bit	IRQ Moderation Timer Init Reg.*/
@@ -1021,7 +1032,7 @@ extern "C" {
 								/* Bit 7:	reserved */
 #define RAP_RAP			0x3f	/* Bit 6..0:	0 = block 0,..,6f = block 6f */
 
-/*	B0_CTST		16 bit	Control/Status register */
+/*	B0_CTST			16 bit	Control/Status register */
 								/* Bit 15..14:	reserved */
 #define CS_CLK_RUN_HOT	BIT_13S		/* CLK_RUN hot m. (YUKON-Lite only) */
 #define CS_CLK_RUN_RST	BIT_12S		/* CLK_RUN reset  (YUKON-Lite only) */
@@ -1038,7 +1049,7 @@ extern "C" {
 #define CS_RST_CLR		BIT_1S		/* Clear Software reset	*/
 #define CS_RST_SET		BIT_0S		/* Set   Software reset	*/
 
-/*	B0_LED		 8 Bit	LED register */
+/*	B0_LED			 8 Bit	LED register */
 								/* Bit  7.. 2:	reserved */
 #define LED_STAT_ON		BIT_1S		/* Status LED on	*/
 #define LED_STAT_OFF	BIT_0S		/* Status LED off	*/
@@ -1053,9 +1064,9 @@ extern "C" {
 #define PC_VCC_ON		BIT_1       /* Switch VCC On  */
 #define PC_VCC_OFF		BIT_0       /* Switch VCC Off */
 
-/*	B0_ISRC		32 bit	Interrupt Source Register */
-/*	B0_IMSK		32 bit	Interrupt Mask Register */
-/*	B0_SP_ISRC	32 bit	Special Interrupt Source Reg */
+/*	B0_ISRC			32 bit	Interrupt Source Register */
+/*	B0_IMSK			32 bit	Interrupt Mask Register */
+/*	B0_SP_ISRC		32 bit	Special Interrupt Source Reg */
 /*	B2_IRQM_MSK 	32 bit	IRQ Moderation Mask */
 #define IS_ALL_MSK		0xbfffffffUL	/* All Interrupt bits */
 #define IS_HW_ERR		BIT_31		/* Interrupt HW Error */
@@ -1099,9 +1110,9 @@ extern "C" {
 #define IS_XA2_C		BIT_0		/* Q_XA2 Encoding Error */
 
 
-/*	B0_HWE_ISRC	32 bit	HW Error Interrupt Src Reg */
-/*	B0_HWE_IMSK	32 bit	HW Error Interrupt Mask Reg */
-/*	B2_IRQM_HWE_MSK 32 bit	IRQ Moderation HW Error Mask */
+/*	B0_HWE_ISRC		32 bit	HW Error Interrupt Src Reg */
+/*	B0_HWE_IMSK		32 bit	HW Error Interrupt Mask Reg */
+/*	B2_IRQM_HWE_MSK	32 bit	IRQ Moderation HW Error Mask */
 #define IS_ERR_MSK		0x00000fffL	/* 		All Error bits */
 								/* Bit 31..14:	reserved */
 #define IS_IRQ_TIST_OV	BIT_13	/* Time Stamp Timer Overflow (YUKON only) */
@@ -1119,29 +1130,32 @@ extern "C" {
 #define IS_R1_PAR_ERR	BIT_1	/* Queue R1 Parity Error */
 #define IS_R2_PAR_ERR	BIT_0	/* Queue R2 Parity Error */
 
-/*	B2_CONN_TYP	 8 bit	Connector type */
-/*	B2_PMD_TYP	 8 bit	PMD type */
+/*	B2_CONN_TYP		 8 bit	Connector type */
+/*	B2_PMD_TYP		 8 bit	PMD type */
 /*	Values of connector and PMD type comply to SysKonnect internal std */
 
-/*	B2_MAC_CFG	 8 bit	MAC Configuration / Chip Revision */
+/*	B2_MAC_CFG		 8 bit	MAC Configuration / Chip Revision */
 #define CFG_CHIP_R_MSK	(0xf<<4)	/* Bit 7.. 4: Chip Revision */
 									/* Bit 3.. 2:	reserved */
 #define CFG_DIS_M2_CLK	BIT_1S		/* Disable Clock for 2nd MAC */
 #define CFG_SNG_MAC		BIT_0S		/* MAC Config: 0=2 MACs / 1=1 MAC*/
 
-/*	B2_CHIP_ID	 8 bit 	Chip Identification Number */
+/*	B2_CHIP_ID		 8 bit 	Chip Identification Number */
 #define CHIP_ID_GENESIS		0x0a	/* Chip ID for GENESIS */
 #define CHIP_ID_YUKON		0xb0	/* Chip ID for YUKON */
-#define CHIP_ID_YUKON_LITE	0xb1	/* Chip ID for YUKON-Lite (Rev. A1) */
+#define CHIP_ID_YUKON_LITE	0xb1	/* Chip ID for YUKON-Lite (Rev. A1-A3) */
 #define CHIP_ID_YUKON_LP	0xb2	/* Chip ID for YUKON-LP */
 
-/*	B2_FAR		32 bit	Flash-Prom Addr Reg/Cnt */
+#define CHIP_REV_YU_LITE_A1	3		/* Chip Rev. for YUKON-Lite A1,A2 */
+#define CHIP_REV_YU_LITE_A3	7		/* Chip Rev. for YUKON-Lite A3 */
+
+/*	B2_FAR			32 bit	Flash-Prom Addr Reg/Cnt */
 #define FAR_ADDR		0x1ffffL	/* Bit 16.. 0:	FPROM Address mask */
 
-/*	B2_LD_CRTL	 8 bit	EPROM loader control register */
+/*	B2_LD_CTRL		 8 bit	EPROM loader control register */
 /*	Bits are currently reserved */
 
-/*	B2_LD_TEST	 8 bit	EPROM loader test register */
+/*	B2_LD_TEST		 8 bit	EPROM loader test register */
 								/* Bit 7.. 4:	reserved */
 #define LD_T_ON			BIT_3S	/* Loader Test mode on */
 #define LD_T_OFF		BIT_2S	/* Loader Test mode off */
@@ -1151,16 +1165,16 @@ extern "C" {
 /*
  *	Timer Section
  */
-/*	B2_TI_CRTL	 8 bit	Timer control */
+/*	B2_TI_CTRL		 8 bit	Timer control */
 /*	B2_IRQM_CTRL	 8 bit	IRQ Moderation Timer Control */
 								/* Bit 7.. 3:	reserved */
 #define TIM_START		BIT_2S	/* Start Timer */
 #define TIM_STOP		BIT_1S	/* Stop  Timer */
 #define TIM_CLR_IRQ		BIT_0S	/* Clear Timer IRQ (!IRQM) */
 
-/*	B2_TI_TEST	 8 Bit	Timer Test */
+/*	B2_TI_TEST		 8 Bit	Timer Test */
 /*	B2_IRQM_TEST	 8 bit	IRQ Moderation Timer Test */
-/*	B28_DPT_TST	 8 bit	Descriptor Poll Timer Test Reg */
+/*	B28_DPT_TST		 8 bit	Descriptor Poll Timer Test Reg */
 								/* Bit 7.. 3:	reserved */
 #define TIM_T_ON		BIT_2S	/* Test mode on */
 #define TIM_T_OFF		BIT_1S	/* Test mode off */
@@ -1197,7 +1211,7 @@ extern "C" {
 #define TST_FRC_APERR_1M64	BIT_1S	/* AddrPERR on 1. phase */
 #define TST_FRC_APERR_2M64	BIT_0S	/* AddrPERR on 2. phase */
 
-/*	B2_GP_IO	32 bit	General Purpose I/O Register */
+/*	B2_GP_IO		32 bit	General Purpose I/O Register */
 							/* Bit 31..26:	reserved */
 #define GP_DIR_9	BIT_25	/* IO_9 direct, 0=In/1=Out */
 #define GP_DIR_8	BIT_24	/* IO_8 direct, 0=In/1=Out */
@@ -1221,28 +1235,28 @@ extern "C" {
 #define GP_IO_1		BIT_1	/* IO_1 pin */
 #define GP_IO_0		BIT_0	/* IO_0 pin */
 
-/*	B2_I2C_CTRL	32 bit	I2C HW Control Register */
+/*	B2_I2C_CTRL		32 bit	I2C HW Control Register */
 #define I2C_FLAG		BIT_31		/* Start read/write if WR */
 #define I2C_ADDR		(0x7fffL<<16)	/* Bit 30..16:	Addr to be RD/WR */
 #define I2C_DEV_SEL		(0x7fL<<9)		/* Bit 15.. 9:	I2C Device Select */
 								/* Bit	8.. 5:	reserved	*/
 #define I2C_BURST_LEN	BIT_4		/* Burst Len, 1/4 bytes */
-#define I2C_DEV_SIZE	(7L<<1)		/* Bit	3.. 1:	I2C Device Size	*/
-#define I2C_025K_DEV	(0L<<1)		/*		0: 256 Bytes or smal. */
-#define I2C_05K_DEV		(1L<<1)		/* 		1: 512	Bytes	*/
-#define I2C_1K_DEV		(2L<<1)		/*		2: 1024 Bytes	*/
-#define I2C_2K_DEV		(3L<<1)		/*		3: 2048	Bytes	*/
-#define I2C_4K_DEV		(4L<<1)		/*		4: 4096 Bytes	*/
-#define I2C_8K_DEV		(5L<<1)		/*		5: 8192 Bytes	*/
-#define I2C_16K_DEV		(6L<<1)		/*		6: 16384 Bytes	*/
-#define I2C_32K_DEV		(7L<<1)		/*		7: 32768 Bytes	*/
+#define I2C_DEV_SIZE	(7<<1)		/* Bit	3.. 1:	I2C Device Size	*/
+#define I2C_025K_DEV	(0<<1)		/*		0: 256 Bytes or smal. */
+#define I2C_05K_DEV		(1<<1)		/* 		1: 512	Bytes	*/
+#define I2C_1K_DEV		(2<<1)		/*		2: 1024 Bytes	*/
+#define I2C_2K_DEV		(3<<1)		/*		3: 2048	Bytes	*/
+#define I2C_4K_DEV		(4<<1)		/*		4: 4096 Bytes	*/
+#define I2C_8K_DEV		(5<<1)		/*		5: 8192 Bytes	*/
+#define I2C_16K_DEV		(6<<1)		/*		6: 16384 Bytes	*/
+#define I2C_32K_DEV		(7<<1)		/*		7: 32768 Bytes	*/
 #define I2C_STOP		BIT_0		/* Interrupt I2C transfer */
 
-/*	B2_I2C_IRQ	32 bit	I2C HW IRQ Register */
+/*	B2_I2C_IRQ		32 bit	I2C HW IRQ Register */
 								/* Bit 31.. 1	reserved */
 #define I2C_CLR_IRQ		BIT_0	/* Clear I2C IRQ */
 
-/*	B2_I2C_SW	32 bit (8 bit access)	I2C HW SW Port Register */
+/*	B2_I2C_SW		32 bit (8 bit access)	I2C HW SW Port Register */
 								/* Bit  7.. 3:	reserved */
 #define I2C_DATA_DIR	BIT_2S		/* direction of I2C_DATA */
 #define I2C_DATA		BIT_1S		/* I2C Data Port	*/
@@ -1254,27 +1268,27 @@ extern "C" {
 #define I2C_SENS_ADDR	LM80_ADDR	/* I2C Sensor Address, (Volt and Temp)*/
 
 
-/*	B2_BSC_CTRL	 8 bit	Blink Source Counter Control */
+/*	B2_BSC_CTRL		 8 bit	Blink Source Counter Control */
 							/* Bit  7.. 2:	reserved */
 #define BSC_START	BIT_1S		/* Start Blink Source Counter */
 #define BSC_STOP	BIT_0S		/* Stop  Blink Source Counter */
 
-/*	B2_BSC_STAT	 8 bit	Blink Source Counter Status */
+/*	B2_BSC_STAT		 8 bit	Blink Source Counter Status */
 							/* Bit  7.. 1:	reserved */
 #define BSC_SRC		BIT_0S		/* Blink Source, 0=Off / 1=On */
 
-/*	B2_BSC_TST	16 bit	Blink Source Counter Test Reg */
+/*	B2_BSC_TST		16 bit	Blink Source Counter Test Reg */
 #define BSC_T_ON	BIT_2S		/* Test mode on */
 #define BSC_T_OFF	BIT_1S		/* Test mode off */
 #define BSC_T_STEP	BIT_0S		/* Test step */
 
 
-/*	B3_RAM_ADDR	32 bit	RAM Address, to read or write */
+/*	B3_RAM_ADDR		32 bit	RAM Address, to read or write */
 					/* Bit 31..19:	reserved */
 #define RAM_ADR_RAN	0x0007ffffL	/* Bit 18.. 0:	RAM Address Range */
 
 /* RAM Interface Registers */
-/*	B3_RI_CTRL	16 bit	RAM Iface Control Register */
+/*	B3_RI_CTRL		16 bit	RAM Iface Control Register */
 								/* Bit 15..10:	reserved */
 #define RI_CLR_RD_PERR	BIT_9S	/* Clear IRQ RAM Read Parity Err */
 #define RI_CLR_WR_PERR	BIT_8S	/* Clear IRQ RAM Write Parity Err*/
@@ -1282,7 +1296,7 @@ extern "C" {
 #define RI_RST_CLR		BIT_1S	/* Clear RAM Interface Reset */
 #define RI_RST_SET		BIT_0S	/* Set   RAM Interface Reset */
 
-/*	B3_RI_TEST	 8 bit	RAM Iface Test Register */
+/*	B3_RI_TEST		 8 bit	RAM Iface Test Register */
 								/* Bit 15.. 4:	reserved */
 #define RI_T_EV			BIT_3S	/* Timeout Event occured */
 #define RI_T_ON			BIT_2S	/* Timeout Timer Test On */
@@ -1309,7 +1323,7 @@ extern "C" {
 #define MA_DIS_REC_RX1	BIT_0S	/* Disable Recovery Timer RX1 */
 
 /* Packet Arbiter Registers */
-/*	B3_PA_CTRL	16 bit	Packet Arbiter Ctrl Register */
+/*	B3_PA_CTRL		16 bit	Packet Arbiter Ctrl Register */
 								/* Bit 15..14:	reserved */
 #define PA_CLR_TO_TX2	BIT_13S	/* Clear IRQ Packet Timeout TX2 */
 #define PA_CLR_TO_TX1	BIT_12S	/* Clear IRQ Packet Timeout TX1 */
@@ -1332,7 +1346,7 @@ extern "C" {
 /* Rx/Tx Path related Arbiter Test Registers */
 /*	B3_MA_TO_TEST	16 bit	MAC Arbiter Timeout Test Reg */
 /*	B3_MA_RC_TEST	16 bit	MAC Arbiter Recovery Test Reg */
-/*	B3_PA_TEST	16 bit	Packet Arbiter Test Register */
+/*	B3_PA_TEST		16 bit	Packet Arbiter Test Register */
 /*			Bit 15, 11, 7, and 3 are reserved in B3_PA_TEST */
 #define TX2_T_EV	BIT_15S		/* TX2 Timeout/Recv Event occured */
 #define TX2_T_ON	BIT_14S		/* TX2 Timeout/Recv Timer Test On */
@@ -1353,14 +1367,14 @@ extern "C" {
 
 
 /* Transmit Arbiter Registers MAC 1 and 2, use MR_ADDR() to access */
-/*	TXA_ITI_INI	32 bit	Tx Arb Interval Timer Init Val */
-/*	TXA_ITI_VAL	32 bit	Tx Arb Interval Timer Value */
-/*	TXA_LIM_INI	32 bit	Tx Arb Limit Counter Init Val */
-/*	TXA_LIM_VAL	32 bit	Tx Arb Limit Counter Value */
+/*	TXA_ITI_INI		32 bit	Tx Arb Interval Timer Init Val */
+/*	TXA_ITI_VAL		32 bit	Tx Arb Interval Timer Value */
+/*	TXA_LIM_INI		32 bit	Tx Arb Limit Counter Init Val */
+/*	TXA_LIM_VAL		32 bit	Tx Arb Limit Counter Value */
 								/* Bit 31..24:	reserved */
 #define TXA_MAX_VAL	0x00ffffffUL/* Bit 23.. 0:	Max TXA Timer/Cnt Val */
 
-/*	TXA_CTRL	 8 bit	Tx Arbiter Control Register */
+/*	TXA_CTRL		 8 bit	Tx Arbiter Control Register */
 #define TXA_ENA_FSYNC	BIT_7S	/* Enable  force of sync Tx queue */
 #define TXA_DIS_FSYNC	BIT_6S	/* Disable force of sync Tx queue */
 #define TXA_ENA_ALLOC	BIT_5S	/* Enable  alloc of free bandwidth */
@@ -1370,7 +1384,7 @@ extern "C" {
 #define TXA_ENA_ARB		BIT_1S	/* Enable  Tx Arbiter */
 #define TXA_DIS_ARB		BIT_0S	/* Disable Tx Arbiter */
 
-/*	TXA_TEST	 8 bit	Tx Arbiter Test Register */
+/*	TXA_TEST		 8 bit	Tx Arbiter Test Register */
 								/* Bit 7.. 6:	reserved */
 #define TXA_INT_T_ON	BIT_5S	/* Tx Arb Interval Timer Test On */
 #define TXA_INT_T_OFF	BIT_4S	/* Tx Arb Interval Timer Test Off */
@@ -1379,22 +1393,22 @@ extern "C" {
 #define TXA_LIM_T_OFF	BIT_1S	/* Tx Arb Limit Timer Test Off */
 #define TXA_LIM_T_STEP	BIT_0S	/* Tx Arb Limit Timer Step */
 
-/*	TXA_STAT	 8 bit	Tx Arbiter Status Register */
+/*	TXA_STAT		 8 bit	Tx Arbiter Status Register */
 								/* Bit 7.. 1:	reserved */
 #define TXA_PRIO_XS		BIT_0S	/* sync queue has prio to send */
 
-/*	Q_BC	32 bit	Current Byte Counter */
+/*	Q_BC			32 bit	Current Byte Counter */
 								/* Bit 31..16:	reserved */
 #define BC_MAX			0xffff	/* Bit 15.. 0:	Byte counter */
 
 /* BMU Control Status Registers */
-/*	B0_R1_CSR	32 bit	BMU Ctrl/Stat Rx Queue 1 */
-/*	B0_R2_CSR	32 bit	BMU Ctrl/Stat Rx Queue 2 */
-/*	B0_XA1_CSR	32 bit	BMU Ctrl/Stat Sync Tx Queue 1 */
-/*	B0_XS1_CSR	32 bit	BMU Ctrl/Stat Async Tx Queue 1 */
-/*	B0_XA2_CSR	32 bit	BMU Ctrl/Stat Sync Tx Queue 2 */
-/*	B0_XS2_CSR	32 bit	BMU Ctrl/Stat Async Tx Queue 2 */
-/*	Q_CSR		32 bit	BMU Control/Status Register */
+/*	B0_R1_CSR		32 bit	BMU Ctrl/Stat Rx Queue 1 */
+/*	B0_R2_CSR		32 bit	BMU Ctrl/Stat Rx Queue 2 */
+/*	B0_XA1_CSR		32 bit	BMU Ctrl/Stat Sync Tx Queue 1 */
+/*	B0_XS1_CSR		32 bit	BMU Ctrl/Stat Async Tx Queue 1 */
+/*	B0_XA2_CSR		32 bit	BMU Ctrl/Stat Sync Tx Queue 2 */
+/*	B0_XS2_CSR		32 bit	BMU Ctrl/Stat Async Tx Queue 2 */
+/*	Q_CSR			32 bit	BMU Control/Status Register */
 								/* Bit 31..25:	reserved */
 #define CSR_SV_IDLE		BIT_24		/* BMU SM Idle */
 								/* Bit 23..22:	reserved */
@@ -1428,7 +1442,7 @@ extern "C" {
 						CSR_SV_RUN | CSR_DREAD_RUN | CSR_DWRITE_RUN |\
 						CSR_TRANS_RUN)
 
-/*	Q_F	32 bit	Flag Register */
+/*	Q_F				32 bit	Flag Register */
 									/* Bit 31..28:	reserved */
 #define F_ALM_FULL		BIT_27		/* Rx FIFO: almost full */
 #define F_EMPTY			BIT_27		/* Tx FIFO: empty flag */
@@ -1439,17 +1453,17 @@ extern "C" {
 									/* Bit 15..11: 	reserved */
 #define F_WATER_MARK	0x0007ffL	/* Bit 10.. 0:	Watermark */
 
-/*	Q_T1	32 bit	Test Register 1 */
+/*	Q_T1			32 bit	Test Register 1 */
 /*		Holds four State Machine control Bytes */
-#define SM_CRTL_SV_MSK	(0xffL<<24)	/* Bit 31..24:	Control Supervisor SM */
-#define SM_CRTL_RD_MSK	(0xffL<<16)	/* Bit 23..16:	Control Read Desc SM */
-#define SM_CRTL_WR_MSK	(0xffL<<8)	/* Bit 15.. 8:	Control Write Desc SM */
-#define SM_CRTL_TR_MSK	0xffL		/* Bit	7.. 0:	Control Transfer SM */
-
-/*	Q_T1_TR	 8 bit	Test Register 1 Transfer SM */
-/*	Q_T1_WR	 8 bit	Test Register 1 Write Descriptor SM */
-/*	Q_T1_RD	 8 bit	Test Register 1 Read Descriptor SM */
-/*	Q_T1_SV	 8 bit	Test Register 1 Supervisor SM */
+#define SM_CTRL_SV_MSK	(0xffL<<24)	/* Bit 31..24:	Control Supervisor SM */
+#define SM_CTRL_RD_MSK	(0xffL<<16)	/* Bit 23..16:	Control Read Desc SM */
+#define SM_CTRL_WR_MSK	(0xffL<<8)	/* Bit 15.. 8:	Control Write Desc SM */
+#define SM_CTRL_TR_MSK	0xffL		/* Bit	7.. 0:	Control Transfer SM */
+
+/*	Q_T1_TR			 8 bit	Test Register 1 Transfer SM */
+/*	Q_T1_WR			 8 bit	Test Register 1 Write Descriptor SM */
+/*	Q_T1_RD			 8 bit	Test Register 1 Read Descriptor SM */
+/*	Q_T1_SV			 8 bit	Test Register 1 Supervisor SM */
 
 /* The control status byte of each machine looks like ... */
 #define SM_STATE		0xf0	/* Bit 7.. 4:	State which shall be loaded */
@@ -1459,7 +1473,7 @@ extern "C" {
 #define SM_STEP			BIT_0S	/* Step the State Machine */
 /* The encoding of the states is not supported by the Diagnostics Tool */
 
-/*	Q_T2	32 bit	Test Register 2	*/
+/*	Q_T2			32 bit	Test Register 2	*/
 								/* Bit 31.. 8:	reserved */
 #define T2_AC_T_ON		BIT_7	/* Address Counter Test Mode on */
 #define T2_AC_T_OFF		BIT_6	/* Address Counter Test Mode off */
@@ -1470,23 +1484,23 @@ extern "C" {
 #define T2_STEP02		BIT_1	/* Inc AC/Dec BC by 2 */
 #define T2_STEP01		BIT_0	/* Inc AC/Dec BC by 1 */
 
-/*	Q_T3	32 bit	Test Register 3	*/
+/*	Q_T3			32 bit	Test Register 3	*/
 								/* Bit 31.. 7:	reserved */
 #define T3_MUX_MSK		(7<<4)	/* Bit  6.. 4:	Mux Position */
 								/* Bit  3:	reserved */
 #define T3_VRAM_MSK		7		/* Bit  2.. 0:	Virtual RAM Buffer Address */
 
 /* RAM Buffer Register Offsets, use RB_ADDR(Queue, Offs) to access */
-/*	RB_START	32 bit	RAM Buffer Start Address */
-/*	RB_END		32 bit	RAM Buffer End Address */
-/*	RB_WP		32 bit	RAM Buffer Write Pointer */
-/*	RB_RP		32 bit	RAM Buffer Read Pointer */
-/*	RB_RX_UTPP	32 bit	Rx Upper Threshold, Pause Pack */
-/*	RB_RX_LTPP	32 bit	Rx Lower Threshold, Pause Pack */
-/*	RB_RX_UTHP	32 bit	Rx Upper Threshold, High Prio */
-/*	RB_RX_LTHP	32 bit	Rx Lower Threshold, High Prio */
-/*	RB_PC		32 bit	RAM Buffer Packet Counter */
-/*	RB_LEV		32 bit	RAM Buffer Level Register */
+/*	RB_START		32 bit	RAM Buffer Start Address */
+/*	RB_END			32 bit	RAM Buffer End Address */
+/*	RB_WP			32 bit	RAM Buffer Write Pointer */
+/*	RB_RP			32 bit	RAM Buffer Read Pointer */
+/*	RB_RX_UTPP		32 bit	Rx Upper Threshold, Pause Pack */
+/*	RB_RX_LTPP		32 bit	Rx Lower Threshold, Pause Pack */
+/*	RB_RX_UTHP		32 bit	Rx Upper Threshold, High Prio */
+/*	RB_RX_LTHP		32 bit	Rx Lower Threshold, High Prio */
+/*	RB_PC			32 bit	RAM Buffer Packet Counter */
+/*	RB_LEV			32 bit	RAM Buffer Level Register */
 				/* Bit 31..19:	reserved */
 #define RB_MSK	0x0007ffff	/* Bit 18.. 0:	RAM Buffer Pointer Bits */
 
@@ -1519,17 +1533,17 @@ extern "C" {
 
 /* Receive and Transmit MAC FIFO Registers (GENESIS only) */
 
-/*	RX_MFF_EA	32 bit	Receive MAC FIFO End Address */
-/*	RX_MFF_WP	32 bit 	Receive MAC FIFO Write Pointer */
-/*	RX_MFF_RP	32 bit	Receive MAC FIFO Read Pointer */
-/*	RX_MFF_PC	32 bit	Receive MAC FIFO Packet Counter */
-/*	RX_MFF_LEV	32 bit	Receive MAC FIFO Level */
-/*	TX_MFF_EA	32 bit	Transmit MAC FIFO End Address */
-/*	TX_MFF_WP	32 bit 	Transmit MAC FIFO Write Pointer */
-/*	TX_MFF_WSP	32 bit	Transmit MAC FIFO WR Shadow Pointer */
-/*	TX_MFF_RP	32 bit	Transmit MAC FIFO Read Pointer */
-/*	TX_MFF_PC	32 bit	Transmit MAC FIFO Packet Cnt */
-/*	TX_MFF_LEV	32 bit	Transmit MAC FIFO Level */
+/*	RX_MFF_EA		32 bit	Receive MAC FIFO End Address */
+/*	RX_MFF_WP		32 bit 	Receive MAC FIFO Write Pointer */
+/*	RX_MFF_RP		32 bit	Receive MAC FIFO Read Pointer */
+/*	RX_MFF_PC		32 bit	Receive MAC FIFO Packet Counter */
+/*	RX_MFF_LEV		32 bit	Receive MAC FIFO Level */
+/*	TX_MFF_EA		32 bit	Transmit MAC FIFO End Address */
+/*	TX_MFF_WP		32 bit 	Transmit MAC FIFO Write Pointer */
+/*	TX_MFF_WSP		32 bit	Transmit MAC FIFO WR Shadow Pointer */
+/*	TX_MFF_RP		32 bit	Transmit MAC FIFO Read Pointer */
+/*	TX_MFF_PC		32 bit	Transmit MAC FIFO Packet Cnt */
+/*	TX_MFF_LEV		32 bit	Transmit MAC FIFO Level */
 								/* Bit 31.. 6:	reserved */
 #define MFF_MSK			0x007fL	/* Bit	5.. 0:	MAC FIFO Address/Ptr Bits */
 
@@ -1682,7 +1696,7 @@ extern "C" {
 
 #define RX_GMF_FL_THR_DEF	0x0a	/* Rx GMAC FIFO Flush Threshold default */
 
-/*	GMAC_TI_ST_CTRL		  8 bit	Time Stamp Timer Ctrl Reg (YUKON only) */
+/*	GMAC_TI_ST_CTRL	 8 bit	Time Stamp Timer Ctrl Reg (YUKON only) */
 								/* Bit 7.. 3:	reserved */
 #define GMT_ST_START	BIT_2S		/* Start Time Stamp Timer */
 #define GMT_ST_STOP		BIT_1S		/* Stop  Time Stamp Timer */
@@ -1766,13 +1780,13 @@ extern "C" {
 #define GMAC_DEF_MSK	(GM_IS_TX_CO_OV | GM_IS_RX_CO_OV | \
 						GM_IS_TX_FF_UR)
 
-/*	GMAC_LINK_CTRL		16 bit	GMAC Link Control Reg (YUKON only) */
+/*	GMAC_LINK_CTRL	16 bit	GMAC Link Control Reg (YUKON only) */
 						/* Bits 15.. 2:	reserved */
 #define GMLC_RST_CLR	BIT_1S		/* Clear GMAC Link Reset */
 #define GMLC_RST_SET	BIT_0S		/* Set   GMAC Link Reset */
 
 
-/*	WOL_CTRL_STAT		16 bit	WOL Control/Status Reg */
+/*	WOL_CTRL_STAT	16 bit	WOL Control/Status Reg */
 #define WOL_CTL_LINK_CHG_OCC			BIT_15S
 #define WOL_CTL_MAGIC_PKT_OCC			BIT_14S
 #define WOL_CTL_PATTERN_OCC				BIT_13S
@@ -1801,7 +1815,7 @@ extern "C" {
 	WOL_CTL_DIS_PATTERN_UNIT |		\
 	WOL_CTL_DIS_MAGIC_PKT_UNIT)
 
-/*	WOL_MATCH_CTL		 8 bit	WOL Match Control Reg */
+/*	WOL_MATCH_CTL	 8 bit	WOL Match Control Reg */
 #define WOL_CTL_PATT_ENA(x)				(BIT_0 << (x))
 
 #define SK_NUM_WOL_PATTERN		7
diff -puN drivers/net/sk98lin/h/skgehwt.h~linus drivers/net/sk98lin/h/skgehwt.h
--- 25/drivers/net/sk98lin/h/skgehwt.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/h/skgehwt.h	2004-01-19 22:17:22.000000000 -0800
@@ -1,9 +1,9 @@
 /******************************************************************************
  *
  * Name:	skhwt.h
- * Project:	Gigabit Ethernet Adapters, Schedule-Modul
- * Version:	$Revision: 1.6 $
- * Date:	$Date: 2003/05/13 17:57:48 $
+ * Project:	Gigabit Ethernet Adapters, Event Scheduler Module
+ * Version:	$Revision: 1.7 $
+ * Date:	$Date: 2003/09/16 12:55:08 $
  * Purpose:	Defines for the hardware timer functions
  *
  ******************************************************************************/
@@ -27,6 +27,9 @@
  * History:
  *
  *	$Log: skgehwt.h,v $
+ *	Revision 1.7  2003/09/16 12:55:08  rschmidt
+ *	Editorial changes
+ *	
  *	Revision 1.6  2003/05/13 17:57:48  mkarl
  *	Editorial changes.
  *	
@@ -34,7 +37,7 @@
  *	Changed license header to GPL.
  *	
  *	Revision 1.4  1998/08/19 09:50:58  gklug
- *	fix: remove struct keyword from c-code (see CCC) add typedefs
+ *	fix: remove struct keyword from C-code (see CCC) add typedefs
  *	
  *	Revision 1.3  1998/08/14 07:09:29  gklug
  *	fix: chg pAc -> pAC
@@ -44,10 +47,6 @@
  *	
  *	Revision 1.1  1998/08/07 09:32:58  gklug
  *	first version
- *	
- *	
- *	
- *	
  *
  ******************************************************************************/
 
@@ -64,14 +63,14 @@
  * - use in Adapters context name pAC->Hwt
  */
 typedef	struct s_Hwt {
-	SK_U32		TStart ;	/* HWT start */
-	SK_U32		TStop ;		/* HWT stop */
-	int		TActive ;	/* HWT: flag : active/inactive */
+	SK_U32		TStart;	/* HWT start */
+	SK_U32		TStop;	/* HWT stop */
+	int		TActive;	/* HWT: flag : active/inactive */
 } SK_HWT;
 
 extern void SkHwtInit(SK_AC *pAC, SK_IOC Ioc);
 extern void SkHwtStart(SK_AC *pAC, SK_IOC Ioc, SK_U32 Time);
 extern void SkHwtStop(SK_AC *pAC, SK_IOC Ioc);
-extern SK_U32 SkHwtRead(SK_AC *pAC,SK_IOC Ioc);
+extern SK_U32 SkHwtRead(SK_AC *pAC, SK_IOC Ioc);
 extern void SkHwtIsr(SK_AC *pAC, SK_IOC Ioc);
 #endif	/* _SKGEHWT_H_ */
diff -puN drivers/net/sk98lin/h/skgei2c.h~linus drivers/net/sk98lin/h/skgei2c.h
--- 25/drivers/net/sk98lin/h/skgei2c.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/h/skgei2c.h	2004-01-19 22:17:22.000000000 -0800
@@ -1,16 +1,17 @@
 /******************************************************************************
  *
  * Name:	skgei2c.h
- * Project:	GEnesis, PCI Gigabit Ethernet Adapter
- * Version:	$Revision: 1.23 $
- * Date:	$Date: 2002/12/19 14:34:27 $
- * Purpose:	Special GEnesis defines for TWSI
+ * Project:	Gigabit Ethernet Adapters, TWSI-Module
+ * Version:	$Revision: 1.25 $
+ * Date:	$Date: 2003/10/20 09:06:05 $
+ * Purpose:	Special defines for TWSI
  *
  ******************************************************************************/
 
 /******************************************************************************
  *
- *	(C)Copyright 1998-2002 SysKonnect GmbH.
+ *	(C)Copyright 1998-2002 SysKonnect.
+ *	(C)Copyright 2002-2003 Marvell.
  *
  *	This program is free software; you can redistribute it and/or modify
  *	it under the terms of the GNU General Public License as published by
@@ -26,6 +27,12 @@
  * History:
  *
  *	$Log: skgei2c.h,v $
+ *	Revision 1.25  2003/10/20 09:06:05  rschmidt
+ *	Editorial changes.
+ *	
+ *	Revision 1.24  2003/09/23 09:31:15  malthoff
+ *	Parameter dev_size added to macro definition of SK_I2C_CTL.
+ *	
  *	Revision 1.23  2002/12/19 14:34:27  rschmidt
  *	Added cast in macros SK_I2C_SET_BIT() and SK_I2C_CLR_BIT()
  *	Editorial changes (TWSI)
@@ -107,8 +114,6 @@
  *	Revision 1.1  1998/07/17 11:27:56  gklug
  *	Created.
  *
- *
- *
  ******************************************************************************/
 
 /*
@@ -121,12 +126,13 @@
 /*
  * Macros to access the B2_I2C_CTRL
  */
-#define SK_I2C_CTL(IoC, flag, dev, reg, burst) \
+#define SK_I2C_CTL(IoC, flag, dev, dev_size, reg, burst) \
 	SK_OUT32(IoC, B2_I2C_CTRL,\
 		(flag ? 0x80000000UL : 0x0L) | \
-		(((SK_U32) reg << 16) & I2C_ADDR) | \
-		(((SK_U32) dev << 9) & I2C_DEV_SEL) | \
-		(( burst << 4) & I2C_BURST_LEN))
+		(((SK_U32)reg << 16) & I2C_ADDR) | \
+		(((SK_U32)dev << 9) & I2C_DEV_SEL) | \
+		(dev_size & I2C_DEV_SIZE) | \
+		((burst << 4) & I2C_BURST_LEN))
 
 #define SK_I2C_STOP(IoC) {				\
 	SK_U32	I2cCtrl;				\
@@ -166,42 +172,42 @@
  */
 #define	SK_LM80_VT_LSB		22	/* 22mV LSB resolution */
 #define	SK_LM80_TEMP_LSB	10	/* 1 degree LSB resolution */
-#define	SK_LM80_TEMPEXT_LSB	5	/* 0.5 degree LSB resolution for the
-					 * extension value
-					 */
-#define SK_LM80_FAN_FAKTOR	((22500L*60)/(1*2))
-/* formula: counter = (22500*60)/(rpm * divisor * pulses/2)
+#define	SK_LM80_TEMPEXT_LSB	 5	/* 0.5 degree LSB resolution for ext. val. */
+
+/*
+ * formula: counter = (22500*60)/(rpm * divisor * pulses/2)
  * assuming: 6500rpm, 4 pulses, divisor 1
  */
+#define SK_LM80_FAN_FAKTOR	((22500L*60)/(1*2))
 
 /*
  * Define sensor management data
- * Maximum is reached on copperfield with dual Broadcom.
+ * Maximum is reached on Genesis copper dual port and Yukon-64
  * Board specific maximum is in pAC->I2c.MaxSens
  */
 #define	SK_MAX_SENSORS	8	/* maximal no. of installed sensors */
 #define	SK_MIN_SENSORS	5	/* minimal no. of installed sensors */
 
 /*
- * To watch the statemachine (JS) use the timer in two ways instead of one as hitherto
+ * To watch the state machine (SM) use the timer in two ways
+ * instead of one as hitherto
  */
-#define	SK_TIMER_WATCH_STATEMACHINE	0	/* Watch the statemachine to finish in a specific time */
-#define	SK_TIMER_NEW_GAUGING    	1	/* Start a new gauging when timer expires */
-
+#define	SK_TIMER_WATCH_SM		0	/* Watch the SM to finish in a spec. time */
+#define	SK_TIMER_NEW_GAUGING	1	/* Start a new gauging when timer expires */
 
 /*
- * Defines for the individual Thresholds
+ * Defines for the individual thresholds
  */
 
 /* Temperature sensor */
-#define	SK_SEN_TEMP_HIGH_ERR    800	/* Temperature High Err  Threshold */
+#define	SK_SEN_TEMP_HIGH_ERR	800	/* Temperature High Err  Threshold */
 #define	SK_SEN_TEMP_HIGH_WARN	700	/* Temperature High Warn Threshold */
 #define	SK_SEN_TEMP_LOW_WARN	100	/* Temperature Low  Warn Threshold */
-#define	SK_SEN_TEMP_LOW_ERR       0	/* Temperature Low  Err  Threshold */
+#define	SK_SEN_TEMP_LOW_ERR		  0	/* Temperature Low  Err  Threshold */
 
 /* VCC which should be 5 V */
-#define	SK_SEN_PCI_5V_HIGH_ERR  	5588	/* Voltage PCI High Err  Threshold */
-#define	SK_SEN_PCI_5V_HIGH_WARN     5346	/* Voltage PCI High Warn Threshold */
+#define	SK_SEN_PCI_5V_HIGH_ERR		5588	/* Voltage PCI High Err  Threshold */
+#define	SK_SEN_PCI_5V_HIGH_WARN		5346	/* Voltage PCI High Warn Threshold */
 #define	SK_SEN_PCI_5V_LOW_WARN		4664	/* Voltage PCI Low  Warn Threshold */
 #define	SK_SEN_PCI_5V_LOW_ERR		4422	/* Voltage PCI Low  Err  Threshold */
 
@@ -229,17 +235,16 @@
 #define	SK_SEN_PCI_IO_3V3_HIGH_ERR	3850	/* + 15% V PCI-IO High Err Threshold */
 #define	SK_SEN_PCI_IO_3V3_HIGH_WARN	3674	/* + 10% V PCI-IO High Warn Threshold */
 					/*		3300	mVolt */
-#define	SK_SEN_PCI_IO_3V3_LOW_WARN  2926	/* - 10% V PCI-IO Low Warn Threshold */
-#define	SK_SEN_PCI_IO_3V3_LOW_ERR   2772	/* - 15% V PCI-IO Low Err  Threshold */
-
+#define	SK_SEN_PCI_IO_3V3_LOW_WARN	2926	/* - 10% V PCI-IO Low Warn Threshold */
+#define	SK_SEN_PCI_IO_3V3_LOW_ERR	2772	/* - 15% V PCI-IO Low Err  Threshold */
 
 /*
  * VDD voltage
  */
-#define	SK_SEN_VDD_HIGH_ERR	    3630	/* Voltage ASIC High Err  Threshold */
-#define	SK_SEN_VDD_HIGH_WARN    3476	/* Voltage ASIC High Warn Threshold */
-#define	SK_SEN_VDD_LOW_WARN     3146	/* Voltage ASIC Low  Warn Threshold */
-#define	SK_SEN_VDD_LOW_ERR      2970	/* Voltage ASIC Low  Err  Threshold */
+#define	SK_SEN_VDD_HIGH_ERR		3630	/* Voltage ASIC High Err  Threshold */
+#define	SK_SEN_VDD_HIGH_WARN	3476	/* Voltage ASIC High Warn Threshold */
+#define	SK_SEN_VDD_LOW_WARN		3146	/* Voltage ASIC Low  Warn Threshold */
+#define	SK_SEN_VDD_LOW_ERR		2970	/* Voltage ASIC Low  Err  Threshold */
 
 /*
  * PHY PLL 3V3 voltage
@@ -255,8 +260,8 @@
 #define	SK_SEN_VAUX_3V3_HIGH_ERR	3630	/* Voltage VAUX High Err Threshold */
 #define	SK_SEN_VAUX_3V3_HIGH_WARN	3476	/* Voltage VAUX High Warn Threshold */
 #define	SK_SEN_VAUX_3V3_LOW_WARN	3146	/* Voltage VAUX Low Warn Threshold */
-#define	SK_SEN_VAUX_3V3_LOW_ERR	    2970	/* Voltage VAUX Low Err Threshold */
-#define	SK_SEN_VAUX_0V_WARN_ERR	       0	/* if VAUX not present */
+#define	SK_SEN_VAUX_3V3_LOW_ERR		2970	/* Voltage VAUX Low Err Threshold */
+#define	SK_SEN_VAUX_0V_WARN_ERR		   0	/* if VAUX not present */
 #define	SK_SEN_VAUX_RANGE_LIMITER	1000	/* 1000 mV range delimiter */
 
 /*
@@ -270,7 +275,7 @@
 /*
  * ASIC Core 1V5 voltage (YUKON only)
  */
-#define	SK_SEN_CORE_1V5_HIGH_ERR    1650	/* Voltage ASIC Core High Err Threshold */
+#define	SK_SEN_CORE_1V5_HIGH_ERR	1650	/* Voltage ASIC Core High Err Threshold */
 #define	SK_SEN_CORE_1V5_HIGH_WARN	1575	/* Voltage ASIC Core High Warn Threshold */
 #define	SK_SEN_CORE_1V5_LOW_WARN	1425	/* Voltage ASIC Core Low Warn Threshold */
 #define	SK_SEN_CORE_1V5_LOW_ERR 	1350	/* Voltage ASIC Core Low Err Threshold */
@@ -285,8 +290,8 @@
  */
 #define	SK_SEN_FAN_HIGH_ERR		20000	/* FAN Speed High Err Threshold */
 #define	SK_SEN_FAN_HIGH_WARN	20000	/* FAN Speed High Warn Threshold */
-#define	SK_SEN_FAN_LOW_WARN 	5200	/* FAN Speed Low Warn Threshold */
-#define	SK_SEN_FAN_LOW_ERR		4550	/* FAN Speed Low Err Threshold */
+#define	SK_SEN_FAN_LOW_WARN		 5200	/* FAN Speed Low Warn Threshold */
+#define	SK_SEN_FAN_LOW_ERR		 4550	/* FAN Speed Low Err Threshold */
 
 /*
  * Some Voltages need dynamic thresholds
diff -puN drivers/net/sk98lin/h/skgeinit.h~linus drivers/net/sk98lin/h/skgeinit.h
--- 25/drivers/net/sk98lin/h/skgeinit.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/h/skgeinit.h	2004-01-19 22:17:22.000000000 -0800
@@ -2,8 +2,8 @@
  *
  * Name:	skgeinit.h
  * Project:	Gigabit Ethernet Adapters, Common Modules
- * Version:	$Revision: 1.81 $
- * Date:	$Date: 2003/07/04 12:30:38 $
+ * Version:	$Revision: 1.83 $
+ * Date:	$Date: 2003/09/16 14:07:37 $
  * Purpose:	Structures and prototypes for the GE Init Module
  *
  ******************************************************************************/
@@ -27,6 +27,23 @@
  * History:
  *
  *	$Log: skgeinit.h,v $
+ *	Revision 1.83  2003/09/16 14:07:37  rschmidt
+ *	Moved defines for PHY power down modes from skgehw.h
+ *	Added prototypes for SkMacClearRst()
+ *	Editorial changes
+ *	
+ *	Revision 1.82  2003/09/16 07:18:36  mschmid
+ *	Added members to port structure for MAC control
+ *	- PMacColThres
+ *	- PMacJamLen
+ *	- PMacJamIpgVal
+ *	- PMacJamIpgData
+ *	- PMacIpgData
+ *	- PMacLimit4
+ *	Added PHY power state to port structure
+ *	- PPhyPowerState
+ *	Added function prototypes to enter and leave low power modes
+ *	
  *	Revision 1.81  2003/07/04 12:30:38  rschmidt
  *	Added SK_FAR to pointers in MAC statistic functions (for PXE)
  *	Editorial changes
@@ -594,6 +611,13 @@ extern "C" {
 #define SK_PRT_INIT		2	/* the port is initialized */
 #define SK_PRT_RUN		3	/* the port has an active link */
 
+/* PHY power down modes */
+#define PHY_PM_OPERATIONAL_MODE		0	/* PHY operational mode */
+#define PHY_PM_DEEP_SLEEP			1	/* coma mode --> minimal power */
+#define PHY_PM_IEEE_POWER_DOWN		2	/* IEEE 22.2.4.1.5 compl. power down */
+#define PHY_PM_ENERGY_DETECT		3	/* energy detect */
+#define PHY_PM_ENERGY_DETECT_PLUS	4	/* energy detect plus */
+
 /* Default receive frame limit for Workaround of XMAC Errata */
 #define SK_DEF_RX_WA_LIM	SK_CONSTU64(100)
 
@@ -685,6 +709,13 @@ typedef	struct s_GePort {
 	SK_U8	PCableLen;		/* Cable Length */
 	SK_U8	PMdiPairLen[4];	/* MDI[0..3] Pair Length */
 	SK_U8	PMdiPairSts[4];	/* MDI[0..3] Pair Diagnostic Status */
+	SK_U8	PPhyPowerState;	/* PHY current power state */
+	int		PMacColThres;	/* MAC Collision Threshold */
+	int		PMacJamLen;		/* MAC Jam length */
+	int		PMacJamIpgVal;	/* MAC Jam IPG */
+	int		PMacJamIpgData;	/* MAC IPG Jam to Data */
+	int		PMacIpgData;	/* MAC Data IPG */
+	SK_BOOL PMacLimit4;		/* reset collision counter and backoff algorithm */
 } SK_GEPORT;
 
 /*
@@ -865,6 +896,11 @@ extern void	SkMacHardRst(
 	SK_IOC	IoC,
 	int		Port);
 
+extern void	SkMacClearRst(
+	SK_AC	*pAC,
+	SK_IOC	IoC,
+	int		Port);
+
 extern void	SkXmInitMac(
 	SK_AC	*pAC,
 	SK_IOC	IoC,
@@ -1040,6 +1076,17 @@ extern int SkGmCableDiagStatus(
 	int		Port,
 	SK_BOOL	StartTest);
 
+extern int SkGmEnterLowPowerMode(
+	SK_AC	*pAC,
+	SK_IOC	IoC,
+	int		Port,
+	SK_U8	Mode);
+
+extern int SkGmLeaveLowPowerMode(
+	SK_AC	*pAC,
+	SK_IOC	IoC,
+	int		Port);
+
 #ifdef SK_DIAG
 extern void	SkGePhyRead(
 	SK_AC	*pAC,
@@ -1101,6 +1148,7 @@ extern int	SkGeInitAssignRamToQueues();
 extern void SkMacRxTxDisable();
 extern void	SkMacSoftRst();
 extern void	SkMacHardRst();
+extern void	SkMacClearRst();
 extern void SkMacInitPhy();
 extern int  SkMacRxTxEnable();
 extern void SkMacPromiscMode();
@@ -1131,6 +1179,8 @@ extern int	SkGmResetCounter();
 extern int	SkXmOverflowStatus();
 extern int	SkGmOverflowStatus();
 extern int	SkGmCableDiagStatus();
+extern int	SkGmEnterLowPowerMode();
+extern int	SkGmLeaveLowPowerMode();
 
 #ifdef SK_DIAG
 extern void	SkGePhyRead();
diff -puN drivers/net/sk98lin/h/skgepnmi.h~linus drivers/net/sk98lin/h/skgepnmi.h
--- 25/drivers/net/sk98lin/h/skgepnmi.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/h/skgepnmi.h	2004-01-19 22:17:22.000000000 -0800
@@ -2,8 +2,8 @@
  *
  * Name:	skgepnmi.h
  * Project:	GEnesis, PCI Gigabit Ethernet Adapter
- * Version:	$Revision: 1.61 $
- * Date:	$Date: 2003/05/23 12:53:52 $
+ * Version:	$Revision: 1.62 $
+ * Date:	$Date: 2003/08/15 12:31:52 $
  * Purpose:	Defines for Private Network Management Interface
  *
  ****************************************************************************/
@@ -27,6 +27,18 @@
  * History:
  *
  *	$Log: skgepnmi.h,v $
+ *	Revision 1.62  2003/08/15 12:31:52  tschilli
+ *	Added new OIDs:
+ *	OID_SKGE_DRIVER_RELDATE
+ *	OID_SKGE_DRIVER_FILENAME
+ *	OID_SKGE_CHIPID
+ *	OID_SKGE_RAMSIZE
+ *	OID_SKGE_VAUXAVAIL
+ *	OID_SKGE_PHY_TYPE
+ *	OID_SKGE_PHY_LP_MODE
+ *	
+ *	Added new define SK_DIAG_ATTACHED for OID_SKGE_DIAG_MODE handling.
+ *	
  *	Revision 1.61  2003/05/23 12:53:52  tschilli
  *	Generic PNMI IOCTL subcommands added.
  *	Function prototype SkPnmiGenIoctl() added.
@@ -568,15 +580,23 @@
 #define OID_SKGE_ALL_DATA				0xFF020190
 
 /* Defines for VCT. */
-#define OID_SKGE_VCT_GET			0xFF020200
-#define OID_SKGE_VCT_SET			0xFF020201
-#define OID_SKGE_VCT_STATUS			0xFF020202
+#define OID_SKGE_VCT_GET				0xFF020200
+#define OID_SKGE_VCT_SET				0xFF020201
+#define OID_SKGE_VCT_STATUS				0xFF020202
 
 #ifdef SK_DIAG_SUPPORT
 /* Defines for driver DIAG mode. */
-#define OID_SKGE_DIAG_MODE			0xFF020204
+#define OID_SKGE_DIAG_MODE				0xFF020204
 #endif /* SK_DIAG_SUPPORT */
 
+/* New OIDs */
+#define OID_SKGE_DRIVER_RELDATE			0xFF020210
+#define OID_SKGE_DRIVER_FILENAME		0xFF020211
+#define OID_SKGE_CHIPID					0xFF020212
+#define OID_SKGE_RAMSIZE				0xFF020213
+#define OID_SKGE_VAUXAVAIL				0xFF020214
+#define OID_SKGE_PHY_TYPE				0xFF020215
+#define OID_SKGE_PHY_LP_MODE			0xFF020216
 
 /* VCT struct to store a backup copy of VCT data after a port reset. */
 typedef struct s_PnmiVct {
@@ -613,6 +633,12 @@ typedef struct s_PnmiVct {
 #define OID_SKGE_TRAP_RLMT_PORT_UP		523
 #define OID_SKGE_TRAP_RLMT_SEGMENTATION	524
 
+#ifdef SK_DIAG_SUPPORT
+/* Defines for driver DIAG mode. */
+#define SK_DIAG_ATTACHED	2
+#define SK_DIAG_RUNNING		1
+#define SK_DIAG_IDLE		0
+#endif /* SK_DIAG_SUPPORT */
 
 /*
  * Generic PNMI IOCTL subcommand definitions.
@@ -730,6 +756,14 @@ typedef struct s_PnmiVct {
 #define SK_PNMI_ERR051MSG	"SkPnmiEvent: Port switch suspicious"
 #define SK_PNMI_ERR052		(SK_ERRBASE_PNMI + 52)
 #define SK_PNMI_ERR052MSG	""
+#define SK_PNMI_ERR053		(SK_ERRBASE_PNMI + 53)
+#define SK_PNMI_ERR053MSG	"General: Driver release date not initialized"
+#define SK_PNMI_ERR054		(SK_ERRBASE_PNMI + 54)
+#define SK_PNMI_ERR054MSG	"General: Driver release date string too long"
+#define SK_PNMI_ERR055		(SK_ERRBASE_PNMI + 55)
+#define SK_PNMI_ERR055MSG	"General: Driver file name not initialized"
+#define SK_PNMI_ERR056		(SK_ERRBASE_PNMI + 56)
+#define SK_PNMI_ERR056MSG	"General: Driver file name string too long"
 
 /*
  * Management counter macros called by the driver
@@ -740,6 +774,11 @@ typedef struct s_PnmiVct {
 #define SK_PNMI_SET_DRIVER_VER(pAC,v)	((pAC)->Pnmi.pDriverVersion = \
 	(char *)(v))
 
+#define SK_PNMI_SET_DRIVER_RELDATE(pAC,v)	((pAC)->Pnmi.pDriverReleaseDate = \
+	(char *)(v))
+
+#define SK_PNMI_SET_DRIVER_FILENAME(pAC,v)	((pAC)->Pnmi.pDriverFileName = \
+	(char *)(v))
 
 #define SK_PNMI_CNT_TX_QUEUE_LEN(pAC,v,p) \
 	{ \
@@ -916,6 +955,8 @@ typedef struct s_PnmiConf {
 	char			ConfMacFactoryAddr[6];
 	SK_U8			ConfPMD;
 	SK_U8			ConfConnector;
+	SK_U32			ConfPhyType;
+	SK_U32			ConfPhyMode;
 	SK_U8			ConfLinkCapability;
 	SK_U8			ConfLinkMode;
 	SK_U8			ConfLinkModeStatus;
@@ -964,9 +1005,14 @@ typedef struct s_PnmiStrucData {
 	SK_U32			DeviceType;
 	char			DriverDescr[SK_PNMI_STRINGLEN1];
 	char			DriverVersion[SK_PNMI_STRINGLEN2];
+	char			DriverReleaseDate[SK_PNMI_STRINGLEN1];
+	char			DriverFileName[SK_PNMI_STRINGLEN1];
 	char			HwDescr[SK_PNMI_STRINGLEN1];
 	char			HwVersion[SK_PNMI_STRINGLEN2];
 	SK_U16			Chipset;
+	SK_U32			ChipId;
+	SK_U8			VauxAvail;
+	SK_U32			RamSize;
 	SK_U32			MtuSize;
 	SK_U32			Action;
 	SK_U32			TestResult;
@@ -1090,6 +1136,8 @@ typedef struct s_PnmiData {
 
 	char			*pDriverDescription;
 	char			*pDriverVersion;
+	char			*pDriverReleaseDate;
+	char			*pDriverFileName;
 
 	int				MacUpdatedFlag;
 	int				RlmtUpdatedFlag;
@@ -1119,6 +1167,9 @@ typedef struct s_PnmiData {
 	SK_U8		VctStatus[SK_MAX_MACS];
 	SK_PNMI_VCT	VctBackup[SK_MAX_MACS];
 	SK_PNMI_VCT_TIMER VctTimeout[SK_MAX_MACS];
+#ifdef SK_DIAG_SUPPORT
+	SK_U32			DiagAttached;
+#endif /* SK_DIAG_SUPPORT */
 } SK_PNMI;
 
 
diff -puN drivers/net/sk98lin/h/ski2c.h~linus drivers/net/sk98lin/h/ski2c.h
--- 25/drivers/net/sk98lin/h/ski2c.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/h/ski2c.h	2004-01-19 22:17:22.000000000 -0800
@@ -1,16 +1,17 @@
 /******************************************************************************
  *
  * Name:	ski2c.h
- * Project:	GEnesis, PCI Gigabit Ethernet Adapter
- * Version:	$Revision: 1.34 $
- * Date:	$Date: 2003/01/28 09:11:21 $
+ * Project:	Gigabit Ethernet Adapters, TWSI-Module
+ * Version:	$Revision: 1.35 $
+ * Date:	$Date: 2003/10/20 09:06:30 $
  * Purpose:	Defines to access Voltage and Temperature Sensor
  *
  ******************************************************************************/
 
 /******************************************************************************
  *
- *	(C)Copyright 1998-2003 SysKonnect GmbH.
+ *	(C)Copyright 1998-2002 SysKonnect.
+ *	(C)Copyright 2002-2003 Marvell.
  *
  *	This program is free software; you can redistribute it and/or modify
  *	it under the terms of the GNU General Public License as published by
@@ -26,6 +27,10 @@
  * History:
  *
  *	$Log: ski2c.h,v $
+ *	Revision 1.35  2003/10/20 09:06:30  rschmidt
+ *	Added prototypes for SkI2cRead() and SkI2cWrite().
+ *	Editorial changes.
+ *	
  *	Revision 1.34  2003/01/28 09:11:21  rschmidt
  *	Editorial changes
  *	
@@ -137,7 +142,6 @@
  *	Revision 1.1  1998/06/19 14:30:10  malthoff
  *	Created. Sources taken from ML Project.
  *
- *
  ******************************************************************************/
 
 /*
@@ -252,7 +256,7 @@ struct	s_Sensor {
 	SK_I32	SenThreWarnLow;		/* Lower warning Threshold of the sensor */
 	int		SenErrFlag;			/* Sensor indicated an error */
 	SK_BOOL	SenInit;			/* Is sensor initialized ? */
-	SK_U64	SenErrCts;			/* Error  trap counter */
+	SK_U64	SenErrCts;			/* Error trap counter */
 	SK_U64	SenWarnCts;			/* Warning trap counter */
 	SK_U64	SenBegErrTS;		/* Begin error timestamp */
 	SK_U64	SenBegWarnTS;		/* Begin warning timestamp */
@@ -279,13 +283,17 @@ typedef	struct	s_I2c {
 #endif /* !SK_DIAG */
 } SK_I2C;
 
+extern int SkI2cInit(SK_AC *pAC, SK_IOC IoC, int Level);
+extern int SkI2cWrite(SK_AC *pAC, SK_IOC IoC, SK_U32 Data, int Dev, int Size,
+					   int Reg, int Burst);
 extern int SkI2cReadSensor(SK_AC *pAC, SK_IOC IoC, SK_SENSOR *pSen);
-#ifndef SK_DIAG
+#ifdef SK_DIAG
+extern	SK_U32 SkI2cRead(SK_AC *pAC, SK_IOC IoC, int Dev, int Size, int Reg,
+						 int Burst);
+#else /* !SK_DIAG */
 extern int SkI2cEvent(SK_AC *pAC, SK_IOC IoC, SK_U32 Event, SK_EVPARA Para);
-extern int SkI2cInit(SK_AC *pAC, SK_IOC IoC, int Level);
 extern void SkI2cWaitIrq(SK_AC *pAC, SK_IOC IoC);
 extern void SkI2cIsr(SK_AC *pAC, SK_IOC IoC);
-
-#endif
+#endif /* !SK_DIAG */
 #endif /* n_SKI2C_H */
 
diff -puN drivers/net/sk98lin/h/skqueue.h~linus drivers/net/sk98lin/h/skqueue.h
--- 25/drivers/net/sk98lin/h/skqueue.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/h/skqueue.h	2004-01-19 22:17:22.000000000 -0800
@@ -1,9 +1,9 @@
 /******************************************************************************
  *
  * Name:	skqueue.h
- * Project:	Gigabit Ethernet Adapters, Schedule-Modul
- * Version:	$Revision: 1.15 $
- * Date:	$Date: 2003/05/13 17:54:57 $
+ * Project:	Gigabit Ethernet Adapters, Event Scheduler Module
+ * Version:	$Revision: 1.16 $
+ * Date:	$Date: 2003/09/16 12:50:32 $
  * Purpose:	Defines for the Event queue
  *
  ******************************************************************************/
@@ -27,6 +27,9 @@
  * History:
  *
  *	$Log: skqueue.h,v $
+ *	Revision 1.16  2003/09/16 12:50:32  rschmidt
+ *	Editorial changes
+ *	
  *	Revision 1.15  2003/05/13 17:54:57  mkarl
  *	Editorial changes.
  *	
@@ -47,7 +50,7 @@
  *	add: typedef SK_QUEUE
  *	
  *	Revision 1.9  1998/08/19 09:50:59  gklug
- *	fix: remove struct keyword from c-code (see CCC) add typedefs
+ *	fix: remove struct keyword from C-code (see CCC) add typedefs
  *	
  *	Revision 1.8  1998/08/18 07:00:01  gklug
  *	fix: SK_PTR not defined use void * instead.
@@ -74,8 +77,6 @@
  *	Revision 1.1  1998/07/30 14:52:12  gklug
  *	Initial version.
  *	Defines Event Classes, Event structs and queue management variables.
- *	
- *	
  *
  ******************************************************************************/
 
@@ -92,7 +93,7 @@
  */
 #define	SKGE_DRV	1	/* Driver Event Class */
 #define	SKGE_RLMT	2	/* RLMT Event Class */
-#define	SKGE_I2C	3	/* i2C Event Class */
+#define	SKGE_I2C	3	/* I2C Event Class */
 #define	SKGE_PNMI	4	/* PNMI Event Class */
 #define	SKGE_CSUM	5	/* Checksum Event Class */
 #define	SKGE_HWAC	6	/* Hardware Access Event Class */
@@ -121,25 +122,25 @@ typedef	union u_EvPara {
  * Event Queue
  *	skqueue.c
  * events are class/value pairs
- *	class	is addressee, e.g. RMT, PCM etc.
+ *	class	is addressee, e.g. RLMT, PNMI etc.
  *	value	is command, e.g. line state change, ring op change etc.
  */
 typedef	struct s_EventElem {
-	SK_U32		Class ;			/* Event class */
-	SK_U32		Event ;			/* Event value */
-	SK_EVPARA	Para ;			/* Event parameter */
+	SK_U32		Class;			/* Event class */
+	SK_U32		Event;			/* Event value */
+	SK_EVPARA	Para;			/* Event parameter */
 } SK_EVENTELEM;
 
 typedef	struct s_Queue {
 	SK_EVENTELEM	EvQueue[SK_MAX_EVENT];
-	SK_EVENTELEM	*EvPut ;
-	SK_EVENTELEM	*EvGet ;
+	SK_EVENTELEM	*EvPut;
+	SK_EVENTELEM	*EvGet;
 } SK_QUEUE;
 
 extern	void SkEventInit(SK_AC *pAC, SK_IOC Ioc, int Level);
 extern	void SkEventQueue(SK_AC *pAC, SK_U32 Class, SK_U32 Event,
 	SK_EVPARA Para);
-extern	int SkEventDispatcher(SK_AC *pAC,SK_IOC Ioc);
+extern	int SkEventDispatcher(SK_AC *pAC, SK_IOC Ioc);
 
 
 /* Define Error Numbers and messages */
diff -puN drivers/net/sk98lin/h/sktimer.h~linus drivers/net/sk98lin/h/sktimer.h
--- 25/drivers/net/sk98lin/h/sktimer.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/h/sktimer.h	2004-01-19 22:17:22.000000000 -0800
@@ -1,9 +1,9 @@
 /******************************************************************************
  *
  * Name:	sktimer.h
- * Project:	Gigabit Ethernet Adapters, Schedule-Modul
- * Version:	$Revision: 1.10 $
- * Date:	$Date: 2003/05/13 17:56:44 $
+ * Project:	Gigabit Ethernet Adapters, Event Scheduler Module
+ * Version:	$Revision: 1.11 $
+ * Date:	$Date: 2003/09/16 12:58:18 $
  * Purpose:	Defines for the timer functions
  *
  ******************************************************************************/
@@ -27,6 +27,9 @@
  * History:
  *
  *	$Log: sktimer.h,v $
+ *	Revision 1.11  2003/09/16 12:58:18  rschmidt
+ *	Editorial changes
+ *	
  *	Revision 1.10  2003/05/13 17:56:44  mkarl
  *	Editorial changes.
  *	
@@ -40,7 +43,7 @@
  *	fix: SK_TIMCTRL needs to be defined
  *	
  *	Revision 1.6  1998/08/19 09:51:00  gklug
- *	fix: remove struct keyword from c-code (see CCC) add typedefs
+ *	fix: remove struct keyword from C-code (see CCC) add typedefs
  *	
  *	Revision 1.5  1998/08/17 13:43:21  gklug
  *	chg: Parameter will be union of 64bit para, 2 times SK_U32 or SK_PTR
@@ -78,25 +81,25 @@
 typedef	struct s_Timer SK_TIMER;
 
 struct s_Timer {
-	SK_TIMER	*TmNext ;	/* linked list */
-	SK_U32		TmClass ;	/* Timer Event class */
-	SK_U32		TmEvent ;	/* Timer Event value */
-	SK_EVPARA	TmPara ;	/* Timer Event parameter */
-	SK_U32		TmDelta ;	/* delta time */
-	int		TmActive ;	/* flag : active/inactive */
-} ;
+	SK_TIMER	*TmNext;	/* linked list */
+	SK_U32		TmClass;	/* Timer Event class */
+	SK_U32		TmEvent;	/* Timer Event value */
+	SK_EVPARA	TmPara;		/* Timer Event parameter */
+	SK_U32		TmDelta;	/* delta time */
+	int			TmActive;	/* flag: active/inactive */
+};
 
 /*
  * Timer control struct.
  * - use in Adapters context name pAC->Tim
  */
 typedef	struct s_TimCtrl {
-	SK_TIMER	*StQueue ;	/* Head of Timer queue */
-} SK_TIMCTRL ;
+	SK_TIMER	*StQueue;	/* Head of Timer queue */
+} SK_TIMCTRL;
 
-extern void SkTimerInit(SK_AC *pAC,SK_IOC Ioc, int Level);
-extern void SkTimerStop(SK_AC *pAC,SK_IOC Ioc,SK_TIMER *pTimer);
-extern void SkTimerStart(SK_AC *pAC,SK_IOC Ioc,SK_TIMER *pTimer,
-	SK_U32 Time,SK_U32 Class,SK_U32 Event,SK_EVPARA Para);
-extern void SkTimerDone(SK_AC *pAC,SK_IOC Ioc);
+extern void SkTimerInit(SK_AC *pAC, SK_IOC Ioc, int Level);
+extern void SkTimerStop(SK_AC *pAC, SK_IOC Ioc, SK_TIMER *pTimer);
+extern void SkTimerStart(SK_AC *pAC, SK_IOC Ioc, SK_TIMER *pTimer,
+	SK_U32 Time, SK_U32 Class, SK_U32 Event, SK_EVPARA Para);
+extern void SkTimerDone(SK_AC *pAC, SK_IOC Ioc);
 #endif	/* _SKTIMER_H_ */
diff -puN drivers/net/sk98lin/h/sktypes.h~linus drivers/net/sk98lin/h/sktypes.h
--- 25/drivers/net/sk98lin/h/sktypes.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/h/sktypes.h	2004-01-19 22:17:22.000000000 -0800
@@ -2,15 +2,16 @@
  *
  * Name:	sktypes.h
  * Project:	GEnesis, PCI Gigabit Ethernet Adapter
- * Version:	$Revision: 1.1 $
- * Date:	$Date: 2003/07/21 07:26:01 $
+ * Version:	$Revision: 1.2 $
+ * Date:	$Date: 2003/10/07 08:16:51 $
  * Purpose:	Define data types for Linux
  *
  ******************************************************************************/
 
 /******************************************************************************
  *
- *	(C)Copyright 1998-2003 SysKonnect GmbH.
+ *	(C)Copyright 1998-2002 SysKonnect GmbH.
+ *	(C)Copyright 2002-2003 Marvell.
  *
  *	This program is free software; you can redistribute it and/or modify
  *	it under the terms of the GNU General Public License as published by
@@ -26,6 +27,9 @@
  * History:
  *
  *	$Log: sktypes.h,v $
+ *	Revision 1.2  2003/10/07 08:16:51  mlindner
+ *	Fix: Copyright changes
+ *	
  *	Revision 1.1  2003/07/21 07:26:01  rroesler
  *	Fix: Re-Enter after CVS crash
  *	
diff -puN drivers/net/sk98lin/h/skversion.h~linus drivers/net/sk98lin/h/skversion.h
--- 25/drivers/net/sk98lin/h/skversion.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/h/skversion.h	2004-01-19 22:17:22.000000000 -0800
@@ -2,15 +2,16 @@
  *
  * Name:	version.h
  * Project:	GEnesis, PCI Gigabit Ethernet Adapter
- * Version:	$Revision: 1.3 $
- * Date:	$Date: 2003/08/25 13:34:48 $
+ * Version:	$Revision: 1.5 $
+ * Date:	$Date: 2003/10/07 08:16:51 $
  * Purpose:	SK specific Error log support
  *
  ******************************************************************************/
 
 /******************************************************************************
  *
- *	(C)Copyright 1998-2003 SysKonnect GmbH.
+ *	(C)Copyright 1998-2002 SysKonnect GmbH.
+ *	(C)Copyright 2002-2003 Marvell.
  *
  *	This program is free software; you can redistribute it and/or modify
  *	it under the terms of the GNU General Public License as published by
@@ -25,6 +26,12 @@
  *
  * History:
  *	$Log: skversion.h,v $
+ *	Revision 1.5  2003/10/07 08:16:51  mlindner
+ *	Fix: Copyright changes
+ *	
+ *	Revision 1.4  2003/09/22 08:40:10  mlindner
+ *	Add: Added DRIVER_FILE_NAME and DRIVER_REL_DATE
+ *	
  *	Revision 1.3  2003/08/25 13:34:48  mlindner
  *	Fix: Lint changes
  *	
@@ -54,12 +61,14 @@
 #ifdef	lint
 static const char SysKonnectFileId[] = "@(#) (C) SysKonnect GmbH.";
 static const char SysKonnectBuildNumber[] =
-	"@(#)SK-BUILD: 6.18 PL: 01"; 
+	"@(#)SK-BUILD: 6.21 PL: 01"; 
 #endif	/* !defined(lint) */
 
-#define BOOT_STRING	"sk98lin: Network Device Driver v6.18\n" \
+#define BOOT_STRING	"sk98lin: Network Device Driver v6.21\n" \
 			"(C)Copyright 1999-2003 Marvell(R)."
 
-#define VER_STRING	"6.18"
+#define VER_STRING	"6.21"
+#define DRIVER_FILE_NAME	"sk98lin"
+#define DRIVER_REL_DATE		"Dec-15-2003"
 
 
diff -puN drivers/net/sk98lin/h/xmac_ii.h~linus drivers/net/sk98lin/h/xmac_ii.h
--- 25/drivers/net/sk98lin/h/xmac_ii.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/h/xmac_ii.h	2004-01-19 22:17:22.000000000 -0800
@@ -2,8 +2,8 @@
  *
  * Name:	xmac_ii.h
  * Project:	Gigabit Ethernet Adapters, Common Modules
- * Version:	$Revision: 1.48 $
- * Date:	$Date: 2003/05/13 17:17:55 $
+ * Version:	$Revision: 1.52 $
+ * Date:	$Date: 2003/10/02 16:35:50 $
  * Purpose:	Defines and Macros for Gigabit Ethernet Controller
  *
  ******************************************************************************/
@@ -27,6 +27,22 @@
  * History:
  *
  *	$Log: xmac_ii.h,v $
+ *	Revision 1.52  2003/10/02 16:35:50  rschmidt
+ *	Added defines for default values of GMAC parameters
+ *	Changed defines for setting GMAC parameters
+ *	Editorial changes
+ *	
+ *	Revision 1.51  2003/09/23 09:04:27  malthoff
+ *	Add bit definitions for PHY_MARV_EXT_P_STAT.
+ *	
+ *	Revision 1.50  2003/09/16 14:15:07  rschmidt
+ *	Added defines for Extended PHY Specific Control
+ *	Editorial changes
+ *	
+ *	Revision 1.49  2003/09/16 07:22:46  mschmid
+ *	Added defines for Marvell PHY energy detect modes
+ *	Added macros for MAC parameter setting in port structure
+ *	
  *	Revision 1.48  2003/05/13 17:17:55  mkarl
  *	Editorial changes.
  *	
@@ -676,7 +692,7 @@ extern "C" {
 #define PHY_XMAC_AUNE_LP	0x05	/* 16 bit r/o	Link Partner Abi Reg */
 #define PHY_XMAC_AUNE_EXP	0x06	/* 16 bit r/o	Auto-Neg. Expansion Reg */
 #define PHY_XMAC_NEPG		0x07	/* 16 bit r/w	Next Page Register */
-#define PHY_XMAC_NEPG_LP	0x08	/* 16 bit r/o	Next Page Link P Reg */
+#define PHY_XMAC_NEPG_LP	0x08	/* 16 bit r/o	Next Page Link Partner */
 	/* 0x09 - 0x0e:		reserved */
 #define PHY_XMAC_EXT_STAT	0x0f	/* 16 bit r/o	Ext Status Register */
 #define PHY_XMAC_RES_ABI	0x10	/* 16 bit r/o	PHY Resolved Ability */
@@ -693,7 +709,7 @@ extern "C" {
 #define PHY_BCOM_AUNE_LP	0x05	/* 16 bit r/o	Link Part Ability Reg */
 #define PHY_BCOM_AUNE_EXP	0x06	/* 16 bit r/o	Auto-Neg. Expansion Reg */
 #define PHY_BCOM_NEPG		0x07	/* 16 bit r/w	Next Page Register */
-#define PHY_BCOM_NEPG_LP	0x08	/* 16 bit r/o	Next Page Link P Reg */
+#define PHY_BCOM_NEPG_LP	0x08	/* 16 bit r/o	Next Page Link Partner */
 	/* Broadcom-specific registers */
 #define PHY_BCOM_1000T_CTRL	0x09	/* 16 bit r/w	1000Base-T Ctrl Reg */
 #define PHY_BCOM_1000T_STAT	0x0a	/* 16 bit r/o	1000Base-T Status Reg */
@@ -702,7 +718,7 @@ extern "C" {
 #define PHY_BCOM_P_EXT_CTRL	0x10	/* 16 bit r/w	PHY Extended Ctrl Reg */
 #define PHY_BCOM_P_EXT_STAT	0x11	/* 16 bit r/o	PHY Extended Stat Reg */
 #define PHY_BCOM_RE_CTR		0x12	/* 16 bit r/w	Receive Error Counter */
-#define PHY_BCOM_FC_CTR		0x13	/* 16 bit r/w	False Carr Sense Cnt */
+#define PHY_BCOM_FC_CTR		0x13	/* 16 bit r/w	False Carrier Sense Cnt */
 #define PHY_BCOM_RNO_CTR	0x14	/* 16 bit r/w	Receiver NOT_OK Cnt */
 	/* 0x15 - 0x17:		reserved */
 #define PHY_BCOM_AUX_CTRL	0x18	/* 16 bit r/w	Auxiliary Control Reg */
@@ -724,7 +740,7 @@ extern "C" {
 #define PHY_MARV_AUNE_LP	0x05	/* 16 bit r/o	Link Part Ability Reg */
 #define PHY_MARV_AUNE_EXP	0x06	/* 16 bit r/o	Auto-Neg. Expansion Reg */
 #define PHY_MARV_NEPG		0x07	/* 16 bit r/w	Next Page Register */
-#define PHY_MARV_NEPG_LP	0x08	/* 16 bit r/o	Next Page Link P Reg */
+#define PHY_MARV_NEPG_LP	0x08	/* 16 bit r/o	Next Page Link Partner */
 	/* Marvel-specific registers */
 #define PHY_MARV_1000T_CTRL	0x09	/* 16 bit r/w	1000Base-T Ctrl Reg */
 #define PHY_MARV_1000T_STAT	0x0a	/* 16 bit r/o	1000Base-T Status Reg */
@@ -757,7 +773,7 @@ extern "C" {
 #define PHY_LONE_AUNE_LP	0x05	/* 16 bit r/o	Link Part Ability Reg */
 #define PHY_LONE_AUNE_EXP	0x06	/* 16 bit r/o	Auto-Neg. Expansion Reg */
 #define PHY_LONE_NEPG		0x07	/* 16 bit r/w	Next Page Register */
-#define PHY_LONE_NEPG_LP	0x08	/* 16 bit r/o	Next Page Link Partner*/
+#define PHY_LONE_NEPG_LP	0x08	/* 16 bit r/o	Next Page Link Partner */
 	/* Level One-specific registers */
 #define PHY_LONE_1000T_CTRL	0x09	/* 16 bit r/w	1000Base-T Control Reg*/
 #define PHY_LONE_1000T_STAT	0x0a	/* 16 bit r/o	1000Base-T Status Reg */
@@ -804,12 +820,13 @@ extern "C" {
 /*
  * PHY bit definitions
  * Bits defined as PHY_X_..., PHY_B_..., PHY_L_... or PHY_N_... are
- * Xmac/Broadcom/LevelOne/National-specific.
+ * XMAC/Broadcom/LevelOne/National/Marvell-specific.
  * All other are general.
  */
 
 /*****  PHY_XMAC_CTRL	16 bit r/w	PHY Control Register *****/
 /*****  PHY_BCOM_CTRL	16 bit r/w	PHY Control Register *****/
+/*****  PHY_MARV_CTRL	16 bit r/w	PHY Status Register *****/
 /*****  PHY_LONE_CTRL	16 bit r/w	PHY Control Register *****/
 #define PHY_CT_RESET	(1<<15)	/* Bit 15: (sc)	clear all PHY related regs */
 #define PHY_CT_LOOP		(1<<14)	/* Bit 14:	enable Loopback over PHY */
@@ -909,27 +926,20 @@ extern "C" {
 
 /*****  PHY_XMAC_AUNE_EXP	16 bit r/o	Auto-Negotiation Expansion Reg *****/
 								/* Bit 15..4:	reserved */
-#define PHY_AN_LP_NP	(1<<3)	/* Bit  3:	Link Partner can Next Page */
-#define PHY_AN_LOC_NP	(1<<2)	/* Bit  2:	Local PHY can Next Page */
-#define PHY_AN_RX_PG	(1<<1)	/* Bit  1:	Page Received */
+#define PHY_ANE_LP_NP	(1<<3)	/* Bit  3:	Link Partner can Next Page */
+#define PHY_ANE_LOC_NP	(1<<2)	/* Bit  2:	Local PHY can Next Page */
+#define PHY_ANE_RX_PG	(1<<1)	/* Bit  1:	Page Received */
 								/* Bit  0:	reserved */
 
 /*****  PHY_BCOM_AUNE_EXP	16 bit r/o	Auto-Negotiation Expansion Reg *****/
-								/* Bit 15..5:	reserved */
-#define PHY_B_AN_PDF	(1<<4)	/* Bit  4:	Parallel Detection Fault */
-/*	PHY_AN_LP_NP		(see XMAC) Bit  3:	Link Partner can Next Page */
-/*	PHY_AN_LOC_NP		(see XMAC) Bit  2:	Local PHY can Next Page */
-/*	PHY_AN_RX_PG		(see XMAC) Bit  1:	Page Received */
-#define PHY_B_AN_LP_CAP	(1<<0)	/* Bit  0:	Link Partner Auto-Neg. Cap. */ 	
-
 /*****  PHY_LONE_AUNE_EXP	16 bit r/o	Auto-Negotiation Expansion Reg *****/
-#define PHY_L_AN_BP		(1<<5)	/* Bit  5:	Base Page Indication */
-#define PHY_L_AN_PDF	(1<<4)	/* Bit  4:	Parallel Detection Fault */
-/*	PHY_AN_LP_NP		(see XMAC) Bit  3:	Link Partner can Next Page */
-/*	PHY_AN_LOC_NP		(see XMAC) Bit  2:	Local PHY can Next Page */
-/*	PHY_AN_RX_PG		(see XMAC) Bit  1:	Page Received */
-#define PHY_B_AN_LP_CAP	(1<<0)	/* Bit  0:	Link Partner Auto-Neg. Cap. */ 	
-
+/*****  PHY_MARV_AUNE_EXP	16 bit r/o	Auto-Negotiation Expansion Reg *****/
+								/* Bit 15..5:	reserved */
+#define PHY_ANE_PAR_DF	(1<<4)	/* Bit  4:	Parallel Detection Fault */
+/*	PHY_ANE_LP_NP		(see XMAC) Bit  3:	Link Partner can Next Page */
+/*	PHY_ANE_LOC_NP		(see XMAC) Bit  2:	Local PHY can Next Page */
+/*	PHY_ANE_RX_PG		(see XMAC) Bit  1:	Page Received */
+#define PHY_ANE_LP_CAP	(1<<0)	/* Bit  0:	Link Partner Auto-Neg. Cap. */ 	
 
 /*****  PHY_XMAC_NEPG		16 bit r/w	Next Page Register *****/
 /*****  PHY_BCOM_NEPG		16 bit r/w	Next Page Register *****/
@@ -958,7 +968,7 @@ extern "C" {
 #define PHY_X_RS_HD		(1<<6)	/* Bit  6:	Half Duplex Mode selected */
 #define PHY_X_RS_FD		(1<<5)	/* Bit  5:	Full Duplex Mode selected */
 #define PHY_X_RS_ABLMIS (1<<4)	/* Bit  4:	duplex or pause cap mismatch */
-#define PHY_X_RS_PAUMIS (1<<3)	/* Bit  3:	pause capability missmatch */
+#define PHY_X_RS_PAUMIS (1<<3)	/* Bit  3:	pause capability mismatch */
 								/* Bit  2..0:	reserved */
 /*
  * Remote Fault Bits (PHY_X_AN_RFB) encoding
@@ -990,6 +1000,7 @@ extern "C" {
 									/* Bit  7..0:	reserved */
 
 /*****  PHY_BCOM_1000T_STAT	16 bit r/o	1000Base-T Status Reg *****/
+/*****  PHY_MARV_1000T_STAT	16 bit r/o	1000Base-T Status Reg *****/
 #define PHY_B_1000S_MSF		(1<<15)	/* Bit 15:	Master/Slave Fault */
 #define PHY_B_1000S_MSR		(1<<14)	/* Bit 14:	Master/Slave Result */
 #define PHY_B_1000S_LRS		(1<<13)	/* Bit 13:	Local Receiver Status */
@@ -1309,7 +1320,6 @@ extern "C" {
 									/* Bit  7..0:	reserved */
 
 /*****  PHY_MARV_PHY_CTRL	16 bit r/w	PHY Specific Ctrl Reg *****/
-
 #define PHY_M_PC_TX_FFD_MSK	(3<<14)	/* Bit 15..14:	Tx FIFO Depth Mask */
 #define PHY_M_PC_RX_FFD_MSK	(3<<12)	/* Bit 13..12:	Rx FIFO Depth Mask */
 #define PHY_M_PC_ASS_CRS_TX	(1<<11)	/* Bit 11:	Assert CRS on Transmit */
@@ -1323,6 +1333,9 @@ extern "C" {
 #define PHY_M_PC_POL_R_DIS	(1<<1)	/* Bit  1:	Polarity Reversal Disabled */
 #define PHY_M_PC_DIS_JABBER	(1<<0)	/* Bit  0:	Disable Jabber */
 
+#define PHY_M_PC_EN_DET			SHIFT8(2)	/* Energy Detect (Mode 1) */
+#define PHY_M_PC_EN_DET_PLUS	SHIFT8(3)	/* Energy Detect Plus (Mode 2) */
+
 #define PHY_M_PC_MDI_XMODE(x)	SHIFT5(x)	
 #define PHY_M_PC_MAN_MDI	0    	/* 00 = Manual MDI configuration */
 #define PHY_M_PC_MAN_MDIX	1		/* 01 = Manual MDIX configuration */
@@ -1373,6 +1386,7 @@ extern "C" {
 #define PHY_M_EC_M_DSC_MSK	(3<<10)	/* Bit 11..10:	Master downshift counter */
 #define PHY_M_EC_S_DSC_MSK	(3<<8)	/* Bit  9.. 8:	Slave  downshift counter */
 #define PHY_M_EC_MAC_S_MSK	(7<<4)	/* Bit  6.. 4:	Def. MAC interface speed */
+#define PHY_M_EC_FIB_AN_ENA	(1<<3)	/* Bit  3:	Fiber Auto-Neg. Enable */
 
 #define PHY_M_EC_M_DSC(x)		SHIFT10(x)	/* 00=1x; 01=2x; 10=3x; 11=4x */
 #define PHY_M_EC_S_DSC(x)		SHIFT8(x)	/* 00=dis; 01=1x; 10=2x; 11=3x */
@@ -1434,6 +1448,18 @@ extern "C" {
 #define PHY_M_EC2_FO_BOOST	(1<<3)	/* Bit  3:	Fiber Output Boost */
 #define PHY_M_EC2_FO_AM_MSK	7		/* Bit  2.. 0:	Fiber Output Amplitude */
 
+/*****	PHY_MARV_EXT_P_STAT 16 bit r/w	Ext. PHY Specific Status *****/
+#define PHY_M_FC_AUTO_SEL	(1<<15)	/* Bit 15:	Fiber/Copper Auto Sel. dis. */
+#define PHY_M_FC_AN_REG_ACC (1<<14) /* Bit 14:	Fiber/Copper Autoneg. reg acc */
+#define PHY_M_FC_RESULUTION (1<<13)	/* Bit 13:	Fiber/Copper Resulution */
+#define PHY_M_SER_IF_AN_BP  (1<<12) /* Bit 12:	Ser IF autoneg. bypass enable */
+#define PHY_M_SER_IF_BP_ST	(1<<11) /* Bit 11:	Ser IF autoneg. bypass status */
+#define PHY_M_IRQ_POLARITY	(1<<10) /* Bit 10:	IRQ polarity */
+									/* Bit 9..4: reserved */
+#define PHY_M_UNDOC1		(1<< 7) /* undocumented bit !! */
+#define PHY_M_MODE_MASK		(0xf<<0)/* Bit 3..0: copy of HWCFG MODE[3:0] */
+
+
 /*****  PHY_MARV_CABLE_DIAG	16 bit r/o	Cable Diagnostic Reg *****/
 #define PHY_M_CABD_ENA_TEST	(1<<15)	/* Bit 15:	Enable Test */
 #define PHY_M_CABD_STAT_MSK	(3<<13)	/* Bit 14..13:	Status */
@@ -1531,7 +1557,7 @@ extern "C" {
 #define GM_RXF_SHT \
 			(GM_MIB_CNT_BASE + 80)	/* Frames <64 Byte Received OK */
 #define GM_RXE_FRAG \
-			(GM_MIB_CNT_BASE + 88)	/* Frames <64 Byte Receeived with FCS Err */
+			(GM_MIB_CNT_BASE + 88)	/* Frames <64 Byte Received with FCS Err */
 #define GM_RXF_64B \
 			(GM_MIB_CNT_BASE + 96)	/* 64 Byte Rx Frame */
 #define GM_RXF_127B \
@@ -1606,7 +1632,6 @@ extern "C" {
  */
 
 /*	GM_GP_STAT	16 bit r/o	General Purpose Status Register */
-
 #define GM_GPSR_SPEED		(1<<15) /* Bit 15:	Port Speed (1 = 100 Mbps) */
 #define GM_GPSR_DUPLEX		(1<<14) /* Bit 14:	Duplex Mode (1 = Full) */
 #define GM_GPSR_FC_TX_DIS	(1<<13) /* Bit 13:	Tx Flow-Control Mode Disabled */
@@ -1646,11 +1671,14 @@ extern "C" {
 							 GM_GPCR_AU_SPD_DIS)
 	
 /*	GM_TX_CTRL				16 bit r/w	Transmit Control Register */
-
 #define GM_TXCR_FORCE_JAM	(1<<15)	/* Bit 15:	Force Jam / Flow-Control */
 #define GM_TXCR_CRC_DIS		(1<<14)	/* Bit 14:	Disable insertion of CRC */
 #define GM_TXCR_PAD_DIS		(1<<13)	/* Bit 13:	Disable padding of packets */
-#define GM_TXCR_COL_THR		(4<<10)	/* Bit 12..10:	Collision Threshold */
+#define GM_TXCR_COL_THR_MSK	(1<<10)	/* Bit 12..10:	Collision Threshold */
+
+#define TX_COL_THR(x)		(SHIFT10(x) & GM_TXCR_COL_THR_MSK)
+
+#define TX_COL_DEF			0x04
 	
 /*	GM_RX_CTRL				16 bit r/w	Receive Control Register */
 #define GM_RXCR_UCF_ENA		(1<<15)	/* Bit 15:	Enable Unicast filtering */
@@ -1663,35 +1691,41 @@ extern "C" {
 #define GM_TXPA_JAMIPG_MSK	(0x1f<<9)	/* Bit 13..9:	Jam IPG */
 #define GM_TXPA_JAMDAT_MSK	(0x1f<<4)	/* Bit  8..4:	IPG Jam to Data */
 								/* Bit  3..0:	reserved */
-#define JAM_LEN_VAL(x)		SHIFT14(x)
-#define JAM_IPG_VAL(x)		SHIFT9(x)
-#define IPG_JAM_DATA(x)		SHIFT4(x)
+
+#define TX_JAM_LEN_VAL(x)	(SHIFT14(x) & GM_TXPA_JAMLEN_MSK)
+#define TX_JAM_IPG_VAL(x)	(SHIFT9(x) & GM_TXPA_JAMIPG_MSK)
+#define TX_IPG_JAM_DATA(x)	(SHIFT4(x) & GM_TXPA_JAMDAT_MSK)
+
+#define TX_JAM_LEN_DEF		0x03
+#define TX_JAM_IPG_DEF		0x0b
+#define TX_IPG_JAM_DEF		0x1c
 
 /*	GM_SERIAL_MODE			16 bit r/w	Serial Mode Register */
-#define GM_SMOD_DATABL_MSK	(0x1f<<11)	/* Bit 15..11:	Data Blinder */
+#define GM_SMOD_DATABL_MSK	(0x1f<<11)	/* Bit 15..11:	Data Blinder (r/o) */
 #define GM_SMOD_LIMIT_4		(1<<10)	/* Bit 10:	4 consecutive Tx trials */
 #define GM_SMOD_VLAN_ENA	(1<<9)	/* Bit  9:	Enable VLAN  (Max. Frame Len) */
 #define GM_SMOD_JUMBO_ENA	(1<<8)	/* Bit  8:	Enable Jumbo (Max. Frame Len) */
 								/* Bit  7..5:	reserved */
 #define GM_SMOD_IPG_MSK		0x1f	/* Bit 4..0:	Inter-Packet Gap (IPG) */
 	
-#define DATA_BLIND_VAL(x)	SHIFT11(x)
-#define DATA_BLIND_FAST_ETH	0x1c
-#define DATA_BLIND_GIGABIT	4
+#define DATA_BLIND_VAL(x)	(SHIFT11(x) & GM_SMOD_DATABL_MSK)
+#define DATA_BLIND_DEF		0x04
 
-#define IPG_VAL_FAST_ETH	0x1e
-#define IPG_VAL_GIGABIT		6
+#define IPG_DATA_VAL(x)		(x & GM_SMOD_IPG_MSK)
+#define IPG_DATA_DEF		0x1e
 
 /*	GM_SMI_CTRL				16 bit r/w	SMI Control Register */
-
-#define GM_SMI_CT_PHY_AD(x)	SHIFT11(x)
-#define GM_SMI_CT_REG_AD(x)	SHIFT6(x)
+#define GM_SMI_CT_PHY_A_MSK	(0x1f<<11)	/* Bit 15..11:	PHY Device Address */
+#define GM_SMI_CT_REG_A_MSK	(0x1f<<6)	/* Bit 10.. 6:	PHY Register Address */
 #define GM_SMI_CT_OP_RD		(1<<5)	/* Bit  5:	OpCode Read (0=Write)*/
 #define GM_SMI_CT_RD_VAL	(1<<4)	/* Bit  4:	Read Valid (Read completed) */
 #define GM_SMI_CT_BUSY		(1<<3)	/* Bit  3:	Busy (Operation in progress) */
 								/* Bit   2..0:	reserved */
 	
-/*	GM_PHY_ADDR				16 bit r/w	GPHY Address Register */
+#define GM_SMI_CT_PHY_AD(x)	(SHIFT11(x) & GM_SMI_CT_PHY_A_MSK)
+#define GM_SMI_CT_REG_AD(x)	(SHIFT6(x) & GM_SMI_CT_REG_A_MSK)
+
+	/*	GM_PHY_ADDR				16 bit r/w	GPHY Address Register */
 								/* Bit  15..6:	reserved */
 #define GM_PAR_MIB_CLR		(1<<5)	/* Bit  5:	Set MIB Clear Counter Mode */
 #define GM_PAR_MIB_TST		(1<<4)	/* Bit  4:	MIB Load Counter (Test Mode) */
diff -puN drivers/net/sk98lin/Makefile~linus drivers/net/sk98lin/Makefile
--- 25/drivers/net/sk98lin/Makefile~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/Makefile	2004-01-19 22:17:22.000000000 -0800
@@ -76,7 +76,7 @@ endif
 # SK_DBGCAT_DRV_INT_SRC         0x04000000      interrupts sources
 # SK_DBGCAT_DRV_EVENT           0x08000000      driver events
 
-EXTRA_CFLAGS += -Idrivers/net/sk98lin -DSK_USE_CSUM -DGENESIS -DYUKON $(DBGDEF) $(SKPARAM)
+EXTRA_CFLAGS += -Idrivers/net/sk98lin -DSK_DIAG_SUPPORT -DSK_USE_CSUM -DGENESIS -DYUKON $(DBGDEF) $(SKPARAM)
 
 clean:
 	rm -f core *.o *.a *.s
diff -puN drivers/net/sk98lin/skcsum.c~linus drivers/net/sk98lin/skcsum.c
--- 25/drivers/net/sk98lin/skcsum.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/skcsum.c	2004-01-19 22:17:22.000000000 -0800
@@ -2,8 +2,8 @@
  *
  * Name:	skcsum.c
  * Project:	GEnesis, PCI Gigabit Ethernet Adapter
- * Version:	$Revision: 1.11 $
- * Date:	$Date: 2003/03/11 14:05:55 $
+ * Version:	$Revision: 1.12 $
+ * Date:	$Date: 2003/08/20 13:55:53 $
  * Purpose:	Store/verify Internet checksum in send/receive packets.
  *
  ******************************************************************************/
@@ -26,6 +26,10 @@
  * History:
  *
  *	$Log: skcsum.c,v $
+ *	Revision 1.12  2003/08/20 13:55:53  mschmid
+ *	Changed notation of #ifndef SkCsCalculateChecksum to
+ *	#ifndef SK_CS_CALCULATE_CHECKSUM
+ *	
  *	Revision 1.11  2003/03/11 14:05:55  rschmidt
  *	Replaced memset() by macro SK_MEMSET()
  *	Editorial changes
@@ -78,7 +82,7 @@
 
 #ifndef lint
 static const char SysKonnectFileId[] =
-	"@(#) $Id: skcsum.c,v 1.11 2003/03/11 14:05:55 rschmidt Exp $ (C) SysKonnect.";
+	"@(#) $Id: skcsum.c,v 1.12 2003/08/20 13:55:53 mschmid Exp $ (C) SysKonnect.";
 #endif	/* !lint */
 
 /******************************************************************************
@@ -791,7 +795,7 @@ int			NetNumber)
 	*pChecksum2Offset = SKCS_MAC_HEADER_SIZE + SKCS_IP_HEADER_SIZE;
 }	/* SkCsSetReceiveFlags */
 
-#ifndef SkCsCalculateChecksum
+#ifndef SK_CS_CALCULATE_CHECKSUM
 
 /******************************************************************************
  *
@@ -856,7 +860,7 @@ unsigned	Length)		/* Length of data. */
 	return ((unsigned) Checksum);
 }	/* SkCsCalculateChecksum */
 
-#endif /* SkCsCalculateChecksum */
+#endif /* SK_CS_CALCULATE_CHECKSUM */
 
 /******************************************************************************
  *
diff -puN drivers/net/sk98lin/skdim.c~linus drivers/net/sk98lin/skdim.c
--- 25/drivers/net/sk98lin/skdim.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/skdim.c	2004-01-19 22:17:22.000000000 -0800
@@ -2,8 +2,8 @@
  *
  * Name:	skdim.c
  * Project:	GEnesis, PCI Gigabit Ethernet Adapter
- * Version:	$Revision: 1.2 $
- * Date:	$Date: 2003/08/21 12:35:05 $
+ * Version:	$Revision: 1.5 $
+ * Date:	$Date: 2003/11/28 12:55:40 $
  * Purpose:	All functions to maintain interrupt moderation
  *
  ******************************************************************************/
@@ -11,6 +11,7 @@
 /******************************************************************************
  *
  *	(C)Copyright 1998-2002 SysKonnect GmbH.
+ *	(C)Copyright 2002-2003 Marvell.
  *
  *	This program is free software; you can redistribute it and/or modify
  *	it under the terms of the GNU General Public License as published by
@@ -26,6 +27,15 @@
  * History:
  *	
  *	$Log: skdim.c,v $
+ *	Revision 1.5  2003/11/28 12:55:40  rroesler
+ *	Fix: support for new process timing interface added
+ *	
+ *	Revision 1.4  2003/10/10 10:58:56  mlindner
+ *	Fix: CPU detection under the kernel 2.6
+ *	
+ *	Revision 1.3  2003/10/07 08:17:08  mlindner
+ *	Fix: Copyright changes
+ *	
  *	Revision 1.2  2003/08/21 12:35:05  mlindner
  *	Fix: Corrected CPU detection and compile errors on single CPU machines
  *	
@@ -62,7 +72,7 @@
 
 #ifndef	lint
 static const char SysKonnectFileId[] =
-	"@(#) $Id: skdim.c,v 1.2 2003/08/21 12:35:05 mlindner Exp $ (C) SysKonnect.";
+	"@(#) $Id: skdim.c,v 1.5 2003/11/28 12:55:40 rroesler Exp $ (C) SysKonnect.";
 #endif
 
 #define __SKADDR_C
@@ -327,7 +337,9 @@ GetCurrentSystemLoad(SK_AC *pAC) {
 	**
 	**      struct kernel_stat kstat
 	**
-	** is not marked as an exported symbol
+	** is not marked as an exported symbol in the file
+	**
+	**      kernel/ksyms.c 
 	**
 	** As a consequence, using this driver as KLM is not possible
 	** and any access of the structure kernel_stat via the 
diff -puN drivers/net/sk98lin/skge.c~linus drivers/net/sk98lin/skge.c
--- 25/drivers/net/sk98lin/skge.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/skge.c	2004-01-19 22:17:22.000000000 -0800
@@ -1,35 +1,20 @@
 /******************************************************************************
  *
- * Name:    skge.c
+ * Name:	skge.c
  * Project:	GEnesis, PCI Gigabit Ethernet Adapter
- * Version:	$Revision: 1.11 $
- * Date:       	$Date: 2003/08/26 16:05:19 $
+ * Version:	$Revision: 1.42 $
+ * Date:       	$Date: 2003/12/12 10:05:43 $
  * Purpose:	The main driver source module
  *
  ******************************************************************************/
 
 /******************************************************************************
  *
- *	(C)Copyright 1998-2003 SysKonnect GmbH.
+ *	(C)Copyright 1998-2002 SysKonnect GmbH.
+ *	(C)Copyright 2002-2003 Marvell.
  *
- *	Driver for SysKonnect Gigabit Ethernet Server Adapters:
- *
- *	SK-9871 (single link 1000Base-ZX)
- *	SK-9872 (dual link   1000Base-ZX)
- *	SK-9861 (single link 1000Base-SX, VF45 Volition Plug)
- *	SK-9862 (dual link   1000Base-SX, VF45 Volition Plug)
- *	SK-9841 (single link 1000Base-LX)
- *	SK-9842 (dual link   1000Base-LX)
- *	SK-9843 (single link 1000Base-SX)
- *	SK-9844 (dual link   1000Base-SX)
- *	SK-9821 (single link 1000Base-T)
- *	SK-9822 (dual link   1000Base-T)
- *	SK-9881 (single link 1000Base-SX V2 LC)
- *	SK-9871 (single link 1000Base-ZX V2)
- *	SK-9861 (single link 1000Base-SX V2, VF45 Volition Plug)
- *	SK-9841 (single link 1000Base-LX V2)
- *	SK-9843 (single link 1000Base-SX V2)
- *	SK-9821 (single link 1000Base-T V2)
+ *	Driver for Marvell Yukon chipset and SysKonnect Gigabit Ethernet 
+ *      Server Adapters.
  *
  *	Created 10-Feb-1999, based on Linux' acenic.c, 3c59x.c and
  *	SysKonnects GEnesis Solaris driver
@@ -56,6 +41,87 @@
  * History:
  *
  *	$Log: skge.c,v $
+ *	Revision 1.42  2003/12/12 10:05:43  mlindner
+ *	Fix: Format of error message corrected
+ *	
+ *	Revision 1.41  2003/12/11 16:03:57  mlindner
+ *	Fix: Create backup from pnmi data structure
+ *	
+ *	Revision 1.40  2003/12/11 12:14:48  mlindner
+ *	Fix: Initalize Board before network configuration
+ *	Fix: Change device names to driver name
+ *	
+ *	Revision 1.39  2003/12/10 08:57:38  rroesler
+ *	Fix: Modifications regarding try_module_get() and capable()
+ *	
+ *	Revision 1.38  2003/12/01 17:16:50  mlindner
+ *	Fix: Remove useless register_netdev
+ *	
+ *	Revision 1.37  2003/12/01 17:11:30  mlindner
+ *	Fix: Register net device before SkGeBoardInit
+ *	
+ *	Revision 1.36  2003/11/28 13:04:27  rroesler
+ *	Fix: do not print interface status in case DIAG is used
+ *	
+ *	Revision 1.35  2003/11/17 14:41:06  mlindner
+ *	Fix: Endif command
+ *	
+ *	Revision 1.34  2003/11/17 13:29:05  mlindner
+ *	Fix: Editorial changes
+ *	
+ *	Revision 1.33  2003/11/14 14:56:54  rroesler
+ *	Fix: corrected compilation warnings kernel 2.2
+ *	
+ *	Revision 1.32  2003/11/13 14:18:47  rroesler
+ *	Fix: added latest changes regarding the use of the proc system
+ *	
+ *	Revision 1.31  2003/11/13 09:28:35  rroesler
+ *	Fix: removed kernel warning 'driver changed get_stats after register'
+ *	
+ *	Revision 1.30  2003/11/11 13:15:27  rroesler
+ *	Fix: use suitables kernel usage count macros when using the diag
+ *	
+ *	Revision 1.29  2003/11/10 09:38:26  rroesler
+ *	Fix: restore PNMI structure backup for DIAG actions
+ *	
+ *	Revision 1.28  2003/11/07 17:28:45  rroesler
+ *	Fix: Additions for the LeaveDiagMode
+ *	
+ *	Revision 1.27  2003/11/03 13:21:14  mlindner
+ *	Add: SkGeBuffPad function for padding to ensure the trailing bytes exist
+ *	
+ *	Revision 1.26  2003/10/30 09:20:40  mlindner
+ *	Fix: Control bit check
+ *	
+ *	Revision 1.25  2003/10/29 07:43:37  rroesler
+ *	Fix: Implemented full None values handling for parameter Moderation
+ *	
+ *	Revision 1.24  2003/10/22 14:18:12  rroesler
+ *	Fix: DIAG handling for DualNet cards
+ *	
+ *	Revision 1.23  2003/10/17 10:05:13  mlindner
+ *	Add: New blinkmode for Morvell cards
+ *	
+ *	Revision 1.22  2003/10/15 12:31:25  rroesler
+ *	Fix: Corrected bugreport #10954 (Linux System crash when using vlans)
+ *	
+ *	Revision 1.21  2003/10/07 12:32:28  mlindner
+ *	Fix: Editorial changes
+ *	
+ *	Revision 1.20  2003/10/07 12:22:40  mlindner
+ *	Fix: Compiler warnings
+ *	
+ *	Revision 1.19  2003/10/07 09:33:40  mlindner
+ *	Fix: No warnings for illegal values of Mod and IntsPerSec
+ *	Fix: Speed 100 in Half Duplex not allowed for Yukon
+ *	Fix: PrefPort=B not allowed on single NICs
+ *	
+ *	Revision 1.18  2003/10/07 08:17:08  mlindner
+ *	Fix: Copyright changes
+ *	
+ *	Revision 1.17  2003/09/29 12:06:59  mlindner
+ *	*** empty log message ***
+ *	
  *	Revision 1.16  2003/09/23 11:07:35  mlindner
  *	Fix: IO-control return race condition
  *	Fix: Interrupt moderation value check
@@ -68,6 +134,12 @@
  *	Add: Yukon Plus changes (ChipID, PCI...)
  *	Fix: TCP and UDP Checksum calculation
  *	
+ *	Revision 1.13  2003/09/01 13:30:08  rroesler
+ *	Fix: Corrected missing defines
+ *	
+ *	Revision 1.12  2003/09/01 13:12:02  rroesler
+ *	Add: Code for improved DIAG Attach/Detach interface
+ *	
  *	Revision 1.11  2003/08/26 16:05:19  mlindner
  *	Fix: Compiler warnings (void *)
  *	
@@ -406,7 +478,6 @@
  *	<linux/module.h>
  *
  *	"h/skdrv1st.h"
- *		<linux/version.h>
  *		<linux/types.h>
  *		<linux/kernel.h>
  *		<linux/string.h>
@@ -568,6 +639,12 @@ static void	StartDrvCleanupTimer(SK_AC *
 static void	StopDrvCleanupTimer(SK_AC *pAC);
 static int	XmitFrameSG(SK_AC*, TX_PORT*, struct sk_buff*);
 
+#ifdef SK_DIAG_SUPPORT
+static SK_U32   ParseDeviceNbrFromSlotName(const char *SlotName);
+static int      SkDrvInitAdapter(SK_AC *pAC, int devNbr);
+static int      SkDrvDeInitAdapter(SK_AC *pAC, int devNbr);
+#endif
+
 /*******************************************************************************
  *
  * Extern Function Prototypes
@@ -576,8 +653,8 @@ static int	XmitFrameSG(SK_AC*, TX_PORT*,
 
 #ifdef CONFIG_PROC_FS
 static const char 	SK_Root_Dir_entry[] = "sk98lin";
-static struct		proc_dir_entry *pSkRootDir;
-extern struct		file_operations sk_proc_fops;
+static struct		proc_dir_entry *pSkRootDir = NULL;
+extern struct	file_operations sk_proc_fops;
 #endif
 
 extern void SkDimEnableModerationIfNeeded(SK_AC *pAC);	
@@ -595,12 +672,19 @@ static void	DumpLong(char*, int);
 static const char *BootString = BOOT_STRING;
 struct SK_NET_DEVICE *SkGeRootDev = NULL;
 static int probed __initdata = 0;
+static SK_BOOL DoPrintInterfaceChange = SK_TRUE;
 
 /* local variables **********************************************************/
 static uintptr_t TxQueueAddr[SK_MAX_MACS][2] = {{0x680, 0x600},{0x780, 0x700}};
 static uintptr_t RxQueueAddr[SK_MAX_MACS] = {0x400, 0x480};
 
 
+#ifdef CONFIG_PROC_FS
+static struct proc_dir_entry	*pSkRootDir;
+#endif
+
+
+
 /*****************************************************************************
  *
  * 	skge_probe - find all SK-98xx adapters
@@ -626,6 +710,7 @@ static int __init skge_probe (void)
 	SK_BOOL BootStringCount = SK_FALSE;
 	int			retval;
 #ifdef CONFIG_PROC_FS
+	int			proc_root_initialized = 0;
 	struct proc_dir_entry	*pProcFile;
 #endif
 
@@ -700,6 +785,7 @@ static int __init skge_probe (void)
 		dev->stop =		&SkGeClose;
 		dev->hard_start_xmit =	&SkGeXmit;
 		dev->get_stats =	&SkGeStats;
+		dev->last_stats =	&SkGeStats;
 		dev->set_multicast_list = &SkGeSetRxMode;
 		dev->set_mac_address =	&SkGeSetMacAddr;
 		dev->do_ioctl =		&SkGeIoctl;
@@ -718,15 +804,13 @@ static int __init skge_probe (void)
 #endif
 
 		pAC->Index = boards_found;
+
 		if (SkGeBoardInit(dev, pAC)) {
-			FreeResources(dev);
 			free_netdev(dev);
 			continue;
 		}
 
-		memcpy((caddr_t) &dev->dev_addr,
-			(caddr_t) &pAC->Addr.Net[0].CurrentMacAddress, 6);
-
+		/* Register net device */
 		if (register_netdev(dev)) {
 			printk(KERN_ERR "SKGE: Could not register device.\n");
 			FreeResources(dev);
@@ -734,6 +818,25 @@ static int __init skge_probe (void)
 			continue;
 		}
 
+		/* Print adapter specific string from vpd */
+		ProductStr(pAC);
+		printk("%s: %s\n", dev->name, pAC->DeviceStr);
+
+		/* Print configuration settings */
+		printk("      PrefPort:%c  RlmtMode:%s\n",
+			'A' + pAC->Rlmt.Net[0].Port[pAC->Rlmt.Net[0].PrefPort]->PortNumber,
+			(pAC->RlmtMode==0)  ? "Check Link State" :
+			((pAC->RlmtMode==1) ? "Check Link State" :
+			((pAC->RlmtMode==3) ? "Check Local Port" :
+			((pAC->RlmtMode==7) ? "Check Segmentation" :
+			((pAC->RlmtMode==17) ? "Dual Check Link State" :"Error")))));
+
+		SkGeYellowLED(pAC, pAC->IoBase, 1);
+
+
+		memcpy((caddr_t) &dev->dev_addr,
+			(caddr_t) &pAC->Addr.Net[0].CurrentMacAddress, 6);
+
 		/* First adapter... Create proc and print message */
 #ifdef CONFIG_PROC_FS
 		if (!DeviceFound) {
@@ -744,25 +847,27 @@ static int __init skge_probe (void)
 			/*Create proc (directory)*/
 			if(!pSkRootDir) {
 				pSkRootDir = proc_mkdir(SK_Root_Dir_entry, proc_net);
-				if (!pSkRootDir) 
+				if (!pSkRootDir) {
 					printk(KERN_WARNING "%s: Unable to create /proc/net/%s",
-					       dev->name, SK_Root_Dir_entry);
-				else
+						dev->name, SK_Root_Dir_entry);
+				} else {
 					pSkRootDir->owner = THIS_MODULE;
+				}
 			}
 		}
-		
+
 		/* Create proc file */
-		if (pSkRootDir 
-		    && (pProcFile = create_proc_entry(dev->name, S_IRUGO,
-						      pSkRootDir))) {
+		if (pSkRootDir && 
+			(pProcFile = create_proc_entry(dev->name, S_IRUGO,
+				pSkRootDir))) {
 			pProcFile->proc_fops = &sk_proc_fops;
-			pProcFile->data = dev;
+			pProcFile->data      = dev;
 		}
+
 #endif
 
 		pNet->PortNr = 0;
-		pNet->NetNr = 0;
+		pNet->NetNr  = 0;
 
 		boards_found++;
 
@@ -774,23 +879,24 @@ static int __init skge_probe (void)
 				break;
 			}
 
-			pAC->dev[1] = dev;
-			pNet = dev->priv;
-			pNet->PortNr = 1;
-			pNet->NetNr = 1;
-			pNet->pAC = pAC;
-			pNet->Mtu = 1500;
-			pNet->Up = 0;
-
-			dev->open =		&SkGeOpen;
-			dev->stop =		&SkGeClose;
-			dev->hard_start_xmit =	&SkGeXmit;
-			dev->get_stats =	&SkGeStats;
+			pAC->dev[1]   = dev;
+			pNet          = dev->priv;
+			pNet->PortNr  = 1;
+			pNet->NetNr   = 1;
+			pNet->pAC     = pAC;
+			pNet->Mtu     = 1500;
+			pNet->Up      = 0;
+
+			dev->open               = &SkGeOpen;
+			dev->stop               = &SkGeClose;
+			dev->hard_start_xmit    = &SkGeXmit;
+			dev->get_stats          = &SkGeStats;
+			dev->last_stats         = &SkGeStats;
 			dev->set_multicast_list = &SkGeSetRxMode;
-			dev->set_mac_address =	&SkGeSetMacAddr;
-			dev->do_ioctl =		&SkGeIoctl;
-			dev->change_mtu =	&SkGeChangeMtu;
-			dev->flags &= 		~IFF_RUNNING;
+			dev->set_mac_address    = &SkGeSetMacAddr;
+			dev->do_ioctl           = &SkGeIoctl;
+			dev->change_mtu         = &SkGeChangeMtu;
+			dev->flags             &= ~IFF_RUNNING;
 
 #ifdef SK_ZEROCOPY
 #ifdef USE_SK_TX_CHECKSUM
@@ -802,34 +908,39 @@ static int __init skge_probe (void)
 #endif
 
 			if (register_netdev(dev)) {
-				printk(KERN_ERR "SKGE: Could not register "
-				       "second port.\n");
+				printk(KERN_ERR "SKGE: Could not register device.\n");
 				free_netdev(dev);
 				pAC->dev[1] = pAC->dev[0];
 			} else {
 #ifdef CONFIG_PROC_FS
 				if (pSkRootDir 
 				    && (pProcFile = create_proc_entry(dev->name, 
-								      S_IRUGO,
-								      pSkRootDir))) {
+								S_IRUGO, pSkRootDir))) {
 					pProcFile->proc_fops = &sk_proc_fops;
-					pProcFile->data = dev;
+					pProcFile->data      = dev;
 				}
 #endif
 
-				memcpy((caddr_t) &dev->dev_addr,
-				       (caddr_t) &pAC->Addr.Net[1].CurrentMacAddress, 6);
+			memcpy((caddr_t) &dev->dev_addr,
+			(caddr_t) &pAC->Addr.Net[1].CurrentMacAddress, 6);
 	
-				printk("%s: %s\n", dev->name, pAC->DeviceStr);
-				printk("      PrefPort:B  RlmtMode:Dual Check Link State\n");
+			printk("%s: %s\n", dev->name, pAC->DeviceStr);
+			printk("      PrefPort:B  RlmtMode:Dual Check Link State\n");
 			}
 		}
 
-
 		/* Save the hardware revision */
 		pAC->HWRevision = (((pAC->GIni.GIPciHwRev >> 4) & 0x0F)*10) +
 			(pAC->GIni.GIPciHwRev & 0x0F);
 
+		/* Set driver globals */
+		pAC->Pnmi.pDriverFileName    = DRIVER_FILE_NAME;
+		pAC->Pnmi.pDriverReleaseDate = DRIVER_REL_DATE;
+
+		SK_MEMSET(&(pAC->PnmiBackup), 0, sizeof(SK_PNMI_STRUCT_DATA));
+		SK_MEMCPY(&(pAC->PnmiBackup), &(pAC->PnmiStruct), 
+				sizeof(SK_PNMI_STRUCT_DATA));
+
 		/*
 		 * This is bollocks, but we need to tell the net-init
 		 * code that it shall go for the next device.
@@ -849,7 +960,6 @@ static int __init skge_probe (void)
 } /* skge_probe */
 
 
-
 /*****************************************************************************
  *
  * 	SkGeInitPCI - Init the PCI resources
@@ -1161,8 +1271,7 @@ SK_EVPARA EvPara;
 
 #ifdef CONFIG_PROC_FS
 	/* clear proc-dir */
-	if (pSkRootDir) 
-		remove_proc_entry(pSkRootDir->name, proc_net);
+	remove_proc_entry(pSkRootDir->name, proc_net);
 #endif
 
 } /* skge_cleanup_module */
@@ -1224,7 +1333,7 @@ SK_BOOL	DualNet;
 	SkAddrInit( pAC, pAC->IoBase, SK_INIT_DATA);
 	SkRlmtInit( pAC, pAC->IoBase, SK_INIT_DATA);
 	SkTimerInit(pAC, pAC->IoBase, SK_INIT_DATA);
-	
+
 	pAC->BoardLevel = SK_INIT_DATA;
 	pAC->RxBufSize  = ETH_BUF_SIZE;
 
@@ -1236,7 +1345,7 @@ SK_BOOL	DualNet;
 	/* level 1 init common modules here (HW init) */
 	spin_lock_irqsave(&pAC->SlowPathLock, Flags);
 	if (SkGeInit(pAC, pAC->IoBase, SK_INIT_IO) != 0) {
-		printk("HWInit (1) failed.\n");
+		printk("sk98lin: HWInit (1) failed.\n");
 		spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
 		return(-EAGAIN);
 	}
@@ -1268,14 +1377,14 @@ SK_BOOL	DualNet;
 		Ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ,
 			pAC->Name, dev);
 	} else {
-		printk(KERN_WARNING "%s: Illegal number of ports: %d\n",
-		       dev->name, pAC->GIni.GIMacsFound);
+		printk(KERN_WARNING "sk98lin: Illegal number of ports: %d\n",
+		       pAC->GIni.GIMacsFound);
 		return -EAGAIN;
 	}
 
 	if (Ret) {
-		printk(KERN_WARNING "%s: Requested IRQ %d is busy.\n",
-		       dev->name, dev->irq);
+		printk(KERN_WARNING "sk98lin: Requested IRQ %d is busy.\n",
+		       dev->irq);
 		return -EAGAIN;
 	}
 	pAC->AllocFlag |= SK_ALLOC_IRQ;
@@ -1303,25 +1412,10 @@ SK_BOOL	DualNet;
 		pAC->ActivePort,
 		DualNet)) {
 		BoardFreeMem(pAC);
-		printk("SkGeInitAssignRamToQueues failed.\n");
+		printk("sk98lin: SkGeInitAssignRamToQueues failed.\n");
 		return(-EAGAIN);
 	}
 
-	/* Print adapter specific string from vpd */
-	ProductStr(pAC);
-	printk("%s: %s\n", dev->name, pAC->DeviceStr);
-
-	/* Print configuration settings */
-	printk("      PrefPort:%c  RlmtMode:%s\n",
-		'A' + pAC->Rlmt.Net[0].Port[pAC->Rlmt.Net[0].PrefPort]->PortNumber,
-		(pAC->RlmtMode==0)  ? "Check Link State" :
-		((pAC->RlmtMode==1) ? "Check Link State" :
-		((pAC->RlmtMode==3) ? "Check Local Port" :
-		((pAC->RlmtMode==7) ? "Check Segmentation" :
-		((pAC->RlmtMode==17) ? "Dual Check Link State" :"Error")))));
-
-	SkGeYellowLED(pAC, pAC->IoBase, 1);
-
 	/*
 	 * Register the device here
 	 */
@@ -1879,14 +1973,26 @@ struct SK_NET_DEVICE	*dev)
 	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
 		("SkGeOpen: pAC=0x%lX:\n", (unsigned long)pAC));
 
+#ifdef SK_DIAG_SUPPORT
+	if (pAC->DiagModeActive == DIAG_ACTIVE) {
+		if (pAC->Pnmi.DiagAttached == SK_DIAG_RUNNING) {
+			return (-1);   /* still in use by diag; deny actions */
+		} 
+	}
+#endif
+
+	if (!try_module_get(THIS_MODULE)) {
+		return (-1);	/* increase of usage count not possible */
+	}
 
 	/* Set blink mode */
-	if (pAC->PciDev->vendor == 0x1186)
+	if ((pAC->PciDev->vendor == 0x1186) || (pAC->PciDev->vendor == 0x11ab ))
 		pAC->GIni.GILedBlinkCtrl = OEM_CONFIG_VALUE;
 
 	if (pAC->BoardLevel == SK_INIT_DATA) {
 		/* level 1 init common modules here */
 		if (SkGeInit(pAC, pAC->IoBase, SK_INIT_IO) != 0) {
+			module_put(THIS_MODULE); /* decrease usage count */
 			printk("%s: HWInit (1) failed.\n", pAC->dev[pNet->PortNr]->name);
 			return (-1);
 		}
@@ -1902,6 +2008,7 @@ struct SK_NET_DEVICE	*dev)
 	if (pAC->BoardLevel != SK_INIT_RUN) {
 		/* tschilling: Level 2 init modules here, check return value. */
 		if (SkGeInit(pAC, pAC->IoBase, SK_INIT_RUN) != 0) {
+			module_put(THIS_MODULE); /* decrease usage count */
 			printk("%s: HWInit (2) failed.\n", pAC->dev[pNet->PortNr]->name);
 			return (-1);
 		}
@@ -1953,7 +2060,6 @@ struct SK_NET_DEVICE	*dev)
 	pAC->MaxPorts++;
 	pNet->Up = 1;
 
-	try_module_get(THIS_MODULE);
 
 	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
 		("SkGeOpen suceeded\n"));
@@ -1976,26 +2082,50 @@ struct SK_NET_DEVICE	*dev)
 static int SkGeClose(
 struct SK_NET_DEVICE	*dev)
 {
-	DEV_NET			*pNet;
-	SK_AC			*pAC;
+	DEV_NET		*pNet;
+	DEV_NET		*newPtrNet;
+	SK_AC		*pAC;
 
 	unsigned long	Flags;		/* for spin lock */
-	int				i;
-	int				PortIdx;
-	SK_EVPARA		EvPara;
+	int		i;
+	int		PortIdx;
+	SK_EVPARA	EvPara;
+
+	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
+		("SkGeClose: pAC=0x%lX ", (unsigned long)pAC));
 
-	netif_stop_queue(dev);
 	pNet = (DEV_NET*) dev->priv;
 	pAC = pNet->pAC;
 
+#ifdef SK_DIAG_SUPPORT
+	if (pAC->DiagModeActive == DIAG_ACTIVE) {
+		if (pAC->DiagFlowCtrl == SK_FALSE) {
+			module_put(THIS_MODULE);
+			/* 
+			** notify that the interface which has been closed
+			** by operator interaction must not be started up 
+			** again when the DIAG has finished. 
+			*/
+			newPtrNet = (DEV_NET *) pAC->dev[0]->priv;
+			if (newPtrNet == pNet) {
+				pAC->WasIfUp[0] = SK_FALSE;
+			} else {
+				pAC->WasIfUp[1] = SK_FALSE;
+			}
+			return 0; /* return to system everything is fine... */
+		} else {
+			pAC->DiagFlowCtrl = SK_FALSE;
+		}
+	}
+#endif
+
+	netif_stop_queue(dev);
+
 	if (pAC->RlmtNets == 1)
 		PortIdx = pAC->ActivePort;
 	else
 		PortIdx = pNet->NetNr;
 
-	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
-		("SkGeClose: pAC=0x%lX ", (unsigned long)pAC));
-
         StopDrvCleanupTimer(pAC);
 
 	/*
@@ -2053,6 +2183,10 @@ struct SK_NET_DEVICE	*dev)
 	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
 		("SkGeClose: done "));
 
+	SK_MEMSET(&(pAC->PnmiBackup), 0, sizeof(SK_PNMI_STRUCT_DATA));
+	SK_MEMCPY(&(pAC->PnmiBackup), &(pAC->PnmiStruct), 
+			sizeof(SK_PNMI_STRUCT_DATA));
+
 	pAC->MaxPorts--;
 	pNet->Up = 0;
 
@@ -2199,9 +2333,10 @@ struct sk_buff	*pMessage)	/* pointer to 
 	** This is to resolve faulty padding by the HW with 0xaa bytes.
 	*/
 	if (BytesSend < C_LEN_ETHERNET_MINSIZE) {
-	    skb_put(pMessage, (C_LEN_ETHERNET_MINSIZE-BytesSend));
-	    SK_MEMSET( ((char *)(pMessage->data))+BytesSend,
-	            0, C_LEN_ETHERNET_MINSIZE-BytesSend);
+		if ((pMessage = skb_padto(pMessage, C_LEN_ETHERNET_MINSIZE)) == NULL) {
+			return 0;
+		}
+		pMessage->len = C_LEN_ETHERNET_MINSIZE;
 	}
 
 	/* 
@@ -3318,6 +3453,16 @@ SK_EVPARA 	EvPara;
 		return -EINVAL;
 	}
 
+#ifdef SK_DIAG_SUPPORT
+	if (pAC->DiagModeActive == DIAG_ACTIVE) {
+		if (pAC->DiagFlowCtrl == SK_FALSE) {
+			return -1; /* still in use, deny any actions of MTU */
+		} else {
+			pAC->DiagFlowCtrl = SK_FALSE;
+		}
+	}
+#endif
+
 	pNet->Mtu = NewMtu;
 	pOtherNet = (DEV_NET*)pAC->dev[1 - pNet->NetNr]->priv;
 	if ((pOtherNet->Mtu>1500) && (NewMtu<=1500) && (pOtherNet->Up==1)) {
@@ -3537,11 +3682,20 @@ unsigned long	Flags;			/* for spin lock 
 	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
 		("SkGeStats starts now...\n"));
 	pPnmiStruct = &pAC->PnmiStruct;
-        memset(pPnmiStruct, 0, sizeof(SK_PNMI_STRUCT_DATA));
+
+#ifdef SK_DIAG_SUPPORT
+        if ((pAC->DiagModeActive == DIAG_NOTACTIVE) &&
+                (pAC->BoardLevel == SK_INIT_RUN)) {
+#endif
+        SK_MEMSET(pPnmiStruct, 0, sizeof(SK_PNMI_STRUCT_DATA));
         spin_lock_irqsave(&pAC->SlowPathLock, Flags);
         Size = SK_PNMI_STRUCT_SIZE;
 		SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, pNet->NetNr);
         spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
+#ifdef SK_DIAG_SUPPORT
+	}
+#endif
+
         pPnmiStat = &pPnmiStruct->Stat[0];
         pPnmiConf = &pPnmiStruct->Conf[0];
 
@@ -3604,7 +3758,7 @@ static int SkGeIoctl(struct SK_NET_DEVIC
 DEV_NET		*pNet;
 SK_AC		*pAC;
 void		*pMemBuf;
-
+struct pci_dev  *pdev = NULL;
 SK_GE_IOCTL	Ioctl;
 unsigned int	Err = 0;
 int		Size = 0;
@@ -3671,6 +3825,45 @@ int		HeaderLength = sizeof(SK_U32) + siz
 fault_gen:
 		kfree(pMemBuf); /* cleanup everything */
 		break;
+#ifdef SK_DIAG_SUPPORT
+       case SK_IOCTL_DIAG:
+		if (!capable(CAP_NET_ADMIN)) return -EPERM;
+		if (Ioctl.Len < (sizeof(pAC->PnmiStruct) + HeaderLength)) {
+			Length = Ioctl.Len;
+		} else {
+			Length = sizeof(pAC->PnmiStruct) + HeaderLength;
+		}
+		if (NULL == (pMemBuf = kmalloc(Length, GFP_KERNEL))) {
+			return -ENOMEM;
+		}
+		if(copy_from_user(pMemBuf, Ioctl.pData, Length)) {
+			Err = -EFAULT;
+			goto fault_diag;
+		}
+		pdev = pAC->PciDev;
+		Length = 3 * sizeof(SK_U32);  /* Error, Bus and Device */
+		/* 
+		** While coding this new IOCTL interface, only a few lines of code
+		** are to to be added. Therefore no dedicated function has been 
+		** added. If more functionality is added, a separate function 
+		** should be used...
+		*/
+		* ((SK_U32 *)pMemBuf) = 0;
+		* ((SK_U32 *)pMemBuf + 1) = pdev->bus->number;
+		* ((SK_U32 *)pMemBuf + 2) = ParseDeviceNbrFromSlotName(pdev->slot_name);
+		if(copy_to_user(Ioctl.pData, pMemBuf, Length) ) {
+			Err = -EFAULT;
+			goto fault_diag;
+		}
+		Ioctl.Len = Length;
+		if(copy_to_user(rq->ifr_data, &Ioctl, sizeof(SK_GE_IOCTL))) {
+			Err = -EFAULT;
+			goto fault_diag;
+		}
+fault_diag:
+		kfree(pMemBuf); /* cleanup everything */
+		break;
+#endif
 	default:
 		Err = -EOPNOTSUPP;
 	}
@@ -3826,10 +4019,9 @@ int	Capabilities[3][3] =
 				(strcmp(ConType[pAC->Index],"Auto")!=0) &&
 				(strcmp(ConType[pAC->Index],"")!=0)) {
 				/* Set the speed parameter back */
-					printk("%s: Illegal value \"%s\" " 
+					printk("sk98lin: Illegal value \"%s\" " 
 							"for ConType."
 							" Using Auto.\n", 
-							pAC->dev[0]->name, 
 							ConType[pAC->Index]);
 
 					sprintf(ConType[pAC->Index], "Auto");	
@@ -3873,8 +4065,8 @@ int	Capabilities[3][3] =
 			M_CurrPort.PLinkSpeed    = SK_LSPEED_10MBPS;
 		    }
                 } else { 
-		    printk("%s: Illegal value \"%s\" for ConType\n", 
-			pAC->dev[0]->name, ConType[pAC->Index]);
+		    printk("sk98lin: Illegal value \"%s\" for ConType\n", 
+			ConType[pAC->Index]);
 		    IsConTypeDefined = SK_FALSE; /* Wrong ConType defined */
 		}
         } else {
@@ -3898,8 +4090,8 @@ int	Capabilities[3][3] =
 		} else if (strcmp(Speed_A[pAC->Index],"1000")==0) {
 		    LinkSpeed = SK_LSPEED_1000MBPS;
 		} else {
-		    printk("%s: Illegal value \"%s\" for Speed_A\n",
-			pAC->dev[0]->name, Speed_A[pAC->Index]);
+		    printk("sk98lin: Illegal value \"%s\" for Speed_A\n",
+			Speed_A[pAC->Index]);
 		    IsLinkSpeedDefined = SK_FALSE;
 		}
 	} else {
@@ -3913,9 +4105,9 @@ int	Capabilities[3][3] =
 	if (((!pAC->ChipsetType) || (pAC->GIni.GICopperType != SK_TRUE)) &&
 		((LinkSpeed != SK_LSPEED_AUTO) &&
 		(LinkSpeed != SK_LSPEED_1000MBPS))) {
-		printk("%s: Illegal value for Speed_A. "
+		printk("sk98lin: Illegal value for Speed_A. "
 			"Not a copper card or GE V2 card\n    Using "
-			"speed 1000\n", pAC->dev[0]->name);
+			"speed 1000\n");
 		LinkSpeed = SK_LSPEED_1000MBPS;
 	}
 	
@@ -3945,8 +4137,8 @@ int	Capabilities[3][3] =
 		} else if (strcmp(AutoNeg_A[pAC->Index],"Sense")==0) {
 		    AutoNeg = AN_SENS;
 		} else {
-		    printk("%s: Illegal value \"%s\" for AutoNeg_A\n",
-			pAC->dev[0]->name, AutoNeg_A[pAC->Index]);
+		    printk("sk98lin: Illegal value \"%s\" for AutoNeg_A\n",
+			AutoNeg_A[pAC->Index]);
 		}
 	}
 
@@ -3964,33 +4156,32 @@ int	Capabilities[3][3] =
 		} else if (strcmp(DupCap_A[pAC->Index],"Half")==0) {
 		    DuplexCap = DC_HALF;
 		} else {
-		    printk("%s: Illegal value \"%s\" for DupCap_A\n",
-			pAC->dev[0]->name, DupCap_A[pAC->Index]);
+		    printk("sk98lin: Illegal value \"%s\" for DupCap_A\n",
+			DupCap_A[pAC->Index]);
 		}
 	}
-	
+
 	/* 
 	** Check for illegal combinations 
 	*/
-	if ((LinkSpeed = SK_LSPEED_1000MBPS) &&
+	if ((LinkSpeed == SK_LSPEED_1000MBPS) &&
 		((DuplexCap == SK_LMODE_STAT_AUTOHALF) ||
 		(DuplexCap == SK_LMODE_STAT_HALF)) &&
 		(pAC->ChipsetType)) {
-		    printk("%s: Half Duplex not possible with Gigabit speed!\n"
-					"    Using Full Duplex.\n",
-				pAC->dev[0]->name);
+		    printk("sk98lin: Half Duplex not possible with Gigabit speed!\n"
+					"    Using Full Duplex.\n");
 				DuplexCap = DC_FULL;
 	}
 
 	if ( AutoSet && AutoNeg==AN_SENS && DupSet) {
-		printk("%s, Port A: DuplexCapabilities"
-			" ignored using Sense mode\n", pAC->dev[0]->name);
+		printk("sk98lin, Port A: DuplexCapabilities"
+			" ignored using Sense mode\n");
 	}
 
 	if (AutoSet && AutoNeg==AN_OFF && DupSet && DuplexCap==DC_BOTH){
-		printk("%s, Port A: Illegal combination"
+		printk("sk98lin: Port A: Illegal combination"
 			" of values AutoNeg. and DuplexCap.\n    Using "
-			"Full Duplex\n", pAC->dev[0]->name);
+			"Full Duplex\n");
 		DuplexCap = DC_FULL;
 	}
 
@@ -3999,10 +4190,9 @@ int	Capabilities[3][3] =
 	}
 	
 	if (!AutoSet && DupSet) {
-		printk("%s, Port A: Duplex setting not"
+		printk("sk98lin: Port A: Duplex setting not"
 			" possible in\n    default AutoNegotiation mode"
-			" (Sense).\n    Using AutoNegotiation On\n",
-			pAC->dev[0]->name);
+			" (Sense).\n    Using AutoNegotiation On\n");
 		AutoNeg = AN_ON;
 	}
 	
@@ -4029,8 +4219,8 @@ int	Capabilities[3][3] =
 		} else if (strcmp(FlowCtrl_A[pAC->Index],"None")==0) {
 		    FlowCtrl = SK_FLOW_MODE_NONE;
 		} else {
-		    printk("%s: Illegal value \"%s\" for FlowCtrl_A\n",
-                        pAC->dev[0]->name, FlowCtrl_A[pAC->Index]);
+		    printk("sk98lin: Illegal value \"%s\" for FlowCtrl_A\n",
+                        FlowCtrl_A[pAC->Index]);
 		    IsFlowCtrlDefined = SK_FALSE;
 		}
 	} else {
@@ -4039,9 +4229,9 @@ int	Capabilities[3][3] =
 
 	if (IsFlowCtrlDefined) {
 	    if ((AutoNeg == AN_OFF) && (FlowCtrl != SK_FLOW_MODE_NONE)) {
-		printk("%s, Port A: FlowControl"
+		printk("sk98lin: Port A: FlowControl"
 			" impossible without AutoNegotiation,"
-			" disabled\n", pAC->dev[0]->name);
+			" disabled\n");
 		FlowCtrl = SK_FLOW_MODE_NONE;
 	    }
 	    pAC->GIni.GP[0].PFlowCtrlMode = FlowCtrl;
@@ -4061,8 +4251,8 @@ int	Capabilities[3][3] =
 		} else if (strcmp(Role_A[pAC->Index],"Slave")==0) {
 		    MSMode = SK_MS_MODE_SLAVE;
 		} else {
-		    printk("%s: Illegal value \"%s\" for Role_A\n",
-			pAC->dev[0]->name, Role_A[pAC->Index]);
+		    printk("sk98lin: Illegal value \"%s\" for Role_A\n",
+			Role_A[pAC->Index]);
 		    IsRoleDefined = SK_FALSE;
 		}
 	} else {
@@ -4097,8 +4287,8 @@ int	Capabilities[3][3] =
 		} else if (strcmp(Speed_B[pAC->Index],"1000")==0) {
 		    LinkSpeed = SK_LSPEED_1000MBPS;
 		} else {
-		    printk("%s: Illegal value \"%s\" for Speed_B\n",
-			pAC->dev[1]->name, Speed_B[pAC->Index]);
+		    printk("sk98lin: Illegal value \"%s\" for Speed_B\n",
+			Speed_B[pAC->Index]);
 		    IsLinkSpeedDefined = SK_FALSE;
 		}
 	} else {
@@ -4112,9 +4302,9 @@ int	Capabilities[3][3] =
 	if (((!pAC->ChipsetType) || (pAC->GIni.GICopperType != SK_TRUE)) &&
 		((LinkSpeed != SK_LSPEED_AUTO) &&
 		(LinkSpeed != SK_LSPEED_1000MBPS))) {
-		printk("%s: Illegal value for Speed_B. "
+		printk("sk98lin: Illegal value for Speed_B. "
 			"Not a copper card or GE V2 card\n    Using "
-			"speed 1000\n", pAC->dev[1]->name);
+			"speed 1000\n");
 		LinkSpeed = SK_LSPEED_1000MBPS;
 	}
 
@@ -4144,8 +4334,8 @@ int	Capabilities[3][3] =
 		} else if (strcmp(AutoNeg_B[pAC->Index],"Sense")==0) {
 		    AutoNeg = AN_SENS;
 		} else {
-		    printk("%s: Illegal value \"%s\" for AutoNeg_B\n",
-			pAC->dev[0]->name, AutoNeg_B[pAC->Index]);
+		    printk("sk98lin: Illegal value \"%s\" for AutoNeg_B\n",
+			AutoNeg_B[pAC->Index]);
 		}
 	}
 
@@ -4163,8 +4353,8 @@ int	Capabilities[3][3] =
 		} else if (strcmp(DupCap_B[pAC->Index],"Half")==0) {
 		    DuplexCap = DC_HALF;
 		} else {
-		    printk("%s: Illegal value \"%s\" for DupCap_B\n",
-			pAC->dev[0]->name, DupCap_B[pAC->Index]);
+		    printk("sk98lin: Illegal value \"%s\" for DupCap_B\n",
+			DupCap_B[pAC->Index]);
 		}
 	}
 
@@ -4172,25 +4362,24 @@ int	Capabilities[3][3] =
 	/* 
 	** Check for illegal combinations 
 	*/
-	if ((LinkSpeed = SK_LSPEED_1000MBPS) &&
+	if ((LinkSpeed == SK_LSPEED_1000MBPS) &&
 		((DuplexCap == SK_LMODE_STAT_AUTOHALF) ||
 		(DuplexCap == SK_LMODE_STAT_HALF)) &&
 		(pAC->ChipsetType)) {
-		    printk("%s: Half Duplex not possible with Gigabit speed!\n"
-					"    Using Full Duplex.\n",
-				pAC->dev[1]->name);
+		    printk("sk98lin: Half Duplex not possible with Gigabit speed!\n"
+					"    Using Full Duplex.\n");
 				DuplexCap = DC_FULL;
 	}
 
 	if (AutoSet && AutoNeg==AN_SENS && DupSet) {
-		printk("%s, Port B: DuplexCapabilities"
-			" ignored using Sense mode\n", pAC->dev[1]->name);
+		printk("sk98lin, Port B: DuplexCapabilities"
+			" ignored using Sense mode\n");
 	}
 
 	if (AutoSet && AutoNeg==AN_OFF && DupSet && DuplexCap==DC_BOTH){
-		printk("%s, Port B: Illegal combination"
+		printk("sk98lin: Port B: Illegal combination"
 			" of values AutoNeg. and DuplexCap.\n    Using "
-			"Full Duplex\n", pAC->dev[1]->name);
+			"Full Duplex\n");
 		DuplexCap = DC_FULL;
 	}
 
@@ -4199,10 +4388,9 @@ int	Capabilities[3][3] =
 	}
 	
 	if (!AutoSet && DupSet) {
-		printk("%s, Port B: Duplex setting not"
+		printk("sk98lin: Port B: Duplex setting not"
 			" possible in\n    default AutoNegotiation mode"
-			" (Sense).\n    Using AutoNegotiation On\n",
-			pAC->dev[1]->name);
+			" (Sense).\n    Using AutoNegotiation On\n");
 		AutoNeg = AN_ON;
 	}
 
@@ -4229,8 +4417,8 @@ int	Capabilities[3][3] =
 		} else if (strcmp(FlowCtrl_B[pAC->Index],"None")==0) {
 		    FlowCtrl = SK_FLOW_MODE_NONE;
 		} else {
-		    printk("%s: Illegal value \"%s\" for FlowCtrl_B\n",
-			pAC->dev[0]->name, FlowCtrl_B[pAC->Index]);
+		    printk("sk98lin: Illegal value \"%s\" for FlowCtrl_B\n",
+			FlowCtrl_B[pAC->Index]);
 		    IsFlowCtrlDefined = SK_FALSE;
 		}
 	} else {
@@ -4239,9 +4427,9 @@ int	Capabilities[3][3] =
 
 	if (IsFlowCtrlDefined) {
 	    if ((AutoNeg == AN_OFF) && (FlowCtrl != SK_FLOW_MODE_NONE)) {
-		printk("%s, Port B: FlowControl"
+		printk("sk98lin: Port B: FlowControl"
 			" impossible without AutoNegotiation,"
-			" disabled\n", pAC->dev[1]->name);
+			" disabled\n");
 		FlowCtrl = SK_FLOW_MODE_NONE;
 	    }
 	    pAC->GIni.GP[1].PFlowCtrlMode = FlowCtrl;
@@ -4261,8 +4449,8 @@ int	Capabilities[3][3] =
 		} else if (strcmp(Role_B[pAC->Index],"Slave")==0) {
 		    MSMode = SK_MS_MODE_SLAVE;
 		} else {
-		    printk("%s: Illegal value \"%s\" for Role_B\n",
-			pAC->dev[1]->name, Role_B[pAC->Index]);
+		    printk("sk98lin: Illegal value \"%s\" for Role_B\n",
+			Role_B[pAC->Index]);
 		    IsRoleDefined = SK_FALSE;
 		}
 	} else {
@@ -4280,28 +4468,37 @@ int	Capabilities[3][3] =
 	if (PrefPort != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
 		PrefPort[pAC->Index] != NULL) {
 		if (strcmp(PrefPort[pAC->Index],"") == 0) { /* Auto */
-		    pAC->ActivePort             =  0;
-		    pAC->Rlmt.Net[0].Preference = -1; /* auto */
-		    pAC->Rlmt.Net[0].PrefPort   =  0;
+			pAC->ActivePort             =  0;
+			pAC->Rlmt.Net[0].Preference = -1; /* auto */
+			pAC->Rlmt.Net[0].PrefPort   =  0;
 		} else if (strcmp(PrefPort[pAC->Index],"A") == 0) {
-		    /*
-		    ** do not set ActivePort here, thus a port
-		    ** switch is issued after net up.
-		    */
-		    Port                        = 0;
-		    pAC->Rlmt.Net[0].Preference = Port;
-		    pAC->Rlmt.Net[0].PrefPort   = Port;
+			/*
+			** do not set ActivePort here, thus a port
+			** switch is issued after net up.
+			*/
+			Port                        = 0;
+			pAC->Rlmt.Net[0].Preference = Port;
+			pAC->Rlmt.Net[0].PrefPort   = Port;
 		} else if (strcmp(PrefPort[pAC->Index],"B") == 0) {
-		    /*
-		    ** do not set ActivePort here, thus a port
-		    ** switch is issued after net up.
-		    */
-		    Port                        = 1;
-		    pAC->Rlmt.Net[0].Preference = Port;
-		    pAC->Rlmt.Net[0].PrefPort   = Port;
+			/*
+			** do not set ActivePort here, thus a port
+			** switch is issued after net up.
+			*/
+			if (pAC->GIni.GIMacsFound == 1) {
+				printk("sk98lin: Illegal value \"B\" for PrefPort.\n"
+					"      Port B not available on single port adapters.\n");
+
+				pAC->ActivePort             =  0;
+				pAC->Rlmt.Net[0].Preference = -1; /* auto */
+				pAC->Rlmt.Net[0].PrefPort   =  0;
+			} else {
+				Port                        = 1;
+				pAC->Rlmt.Net[0].Preference = Port;
+				pAC->Rlmt.Net[0].PrefPort   = Port;
+			}
 		} else {
-		    printk("%s: Illegal value \"%s\" for PrefPort\n",
-			pAC->dev[0]->name, PrefPort[pAC->Index]);
+		    printk("sk98lin: Illegal value \"%s\" for PrefPort\n",
+			PrefPort[pAC->Index]);
 		}
 	}
 
@@ -4325,9 +4522,9 @@ int	Capabilities[3][3] =
 			pAC->RlmtMode = SK_RLMT_CHECK_LINK;
 			pAC->RlmtNets = 2;
 		} else {
-		    printk("%s: Illegal value \"%s\" for"
+		    printk("sk98lin: Illegal value \"%s\" for"
 			" RlmtMode, using default\n", 
-			pAC->dev[0]->name, RlmtMode[pAC->Index]);
+			RlmtMode[pAC->Index]);
 			pAC->RlmtMode = 0;
 		}
 	} else {
@@ -4338,97 +4535,111 @@ int	Capabilities[3][3] =
 	** Check the interrupt moderation parameters
 	*/
 	if (Moderation[pAC->Index] != NULL) {
-	    if (strcmp(Moderation[pAC->Index], "Static") == 0) {
-                pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_STATIC;
-	    } else if (strcmp(Moderation[pAC->Index], "Dynamic") == 0) {
-	        pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_DYNAMIC;
-	    } else {
-	        pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_NONE;
-	    }
+		if (strcmp(Moderation[pAC->Index], "") == 0) {
+			pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_NONE;
+		} else if (strcmp(Moderation[pAC->Index], "Static") == 0) {
+			pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_STATIC;
+		} else if (strcmp(Moderation[pAC->Index], "Dynamic") == 0) {
+			pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_DYNAMIC;
+		} else if (strcmp(Moderation[pAC->Index], "None") == 0) {
+			pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_NONE;
+		} else {
+	   		printk("sk98lin: Illegal value \"%s\" for Moderation.\n"
+				"      Disable interrupt moderation.\n",
+				Moderation[pAC->Index]);
+			pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_NONE;
+		}
 	} else {
-	    pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_NONE;
+		pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_NONE;
 	}
 
 	if (Stats[pAC->Index] != NULL) {
-	    if (strcmp(Stats[pAC->Index], "Yes") == 0) {
-	        pAC->DynIrqModInfo.DisplayStats = SK_TRUE;
-	    } else {
-		pAC->DynIrqModInfo.DisplayStats = SK_FALSE;
-	    }
+		if (strcmp(Stats[pAC->Index], "Yes") == 0) {
+			pAC->DynIrqModInfo.DisplayStats = SK_TRUE;
+		} else {
+			pAC->DynIrqModInfo.DisplayStats = SK_FALSE;
+		}
 	} else {
-	    pAC->DynIrqModInfo.DisplayStats = SK_FALSE;
+		pAC->DynIrqModInfo.DisplayStats = SK_FALSE;
 	}
 
-        if (ModerationMask[pAC->Index] != NULL) {
-           if (strcmp(ModerationMask[pAC->Index], "Rx") == 0) {
-               pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_ONLY;
-           } else if (strcmp(ModerationMask[pAC->Index], "Tx") == 0) {
-               pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_TX_ONLY;
-           } else if (strcmp(ModerationMask[pAC->Index], "Sp") == 0) {
-               pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_SP_ONLY;
-           } else if (strcmp(ModerationMask[pAC->Index], "RxSp") == 0) {
-               pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_SP_RX;
-           } else if (strcmp(ModerationMask[pAC->Index], "SpRx") == 0) {
-               pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_SP_RX;
-           } else if (strcmp(ModerationMask[pAC->Index], "RxTx") == 0) {
-               pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_TX_RX;
-           } else if (strcmp(ModerationMask[pAC->Index], "TxRx") == 0) {
-               pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_TX_RX;
-           } else if (strcmp(ModerationMask[pAC->Index], "TxSp") == 0) {
-               pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_SP_TX;
-           } else if (strcmp(ModerationMask[pAC->Index], "SpTx") == 0) {
-               pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_SP_TX;
-           } else if (strcmp(ModerationMask[pAC->Index], "RxTxSp") == 0) {
-               pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP;
-           } else if (strcmp(ModerationMask[pAC->Index], "RxSpTx") == 0) {
-               pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP;
-           } else if (strcmp(ModerationMask[pAC->Index], "TxRxSp") == 0) {
-               pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP;
-           } else if (strcmp(ModerationMask[pAC->Index], "TxSpRx") == 0) {
-               pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP;
-           } else if (strcmp(ModerationMask[pAC->Index], "SpTxRx") == 0) {
-               pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP;
-           } else if (strcmp(ModerationMask[pAC->Index], "SpRxTx") == 0) {
-               pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP;
-           } else { /* some rubbish */
-               pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_ONLY;
-           }
-        } else {  /* operator has stated nothing */
-           pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_TX_RX;
-        }
-
-        if (AutoSizing[pAC->Index] != NULL) {
-           if (strcmp(AutoSizing[pAC->Index], "On") == 0) {
-               pAC->DynIrqModInfo.AutoSizing = SK_FALSE;
-           } else {
-               pAC->DynIrqModInfo.AutoSizing = SK_FALSE;
-           }
-        } else {  /* operator has stated nothing */
-           pAC->DynIrqModInfo.AutoSizing = SK_FALSE;
-        }
+	if (ModerationMask[pAC->Index] != NULL) {
+		if (strcmp(ModerationMask[pAC->Index], "Rx") == 0) {
+			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_ONLY;
+		} else if (strcmp(ModerationMask[pAC->Index], "Tx") == 0) {
+			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_TX_ONLY;
+		} else if (strcmp(ModerationMask[pAC->Index], "Sp") == 0) {
+			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_SP_ONLY;
+		} else if (strcmp(ModerationMask[pAC->Index], "RxSp") == 0) {
+			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_SP_RX;
+		} else if (strcmp(ModerationMask[pAC->Index], "SpRx") == 0) {
+			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_SP_RX;
+		} else if (strcmp(ModerationMask[pAC->Index], "RxTx") == 0) {
+			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_TX_RX;
+		} else if (strcmp(ModerationMask[pAC->Index], "TxRx") == 0) {
+			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_TX_RX;
+		} else if (strcmp(ModerationMask[pAC->Index], "TxSp") == 0) {
+			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_SP_TX;
+		} else if (strcmp(ModerationMask[pAC->Index], "SpTx") == 0) {
+			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_SP_TX;
+		} else if (strcmp(ModerationMask[pAC->Index], "RxTxSp") == 0) {
+			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP;
+		} else if (strcmp(ModerationMask[pAC->Index], "RxSpTx") == 0) {
+			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP;
+		} else if (strcmp(ModerationMask[pAC->Index], "TxRxSp") == 0) {
+			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP;
+		} else if (strcmp(ModerationMask[pAC->Index], "TxSpRx") == 0) {
+			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP;
+		} else if (strcmp(ModerationMask[pAC->Index], "SpTxRx") == 0) {
+			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP;
+		} else if (strcmp(ModerationMask[pAC->Index], "SpRxTx") == 0) {
+			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP;
+		} else { /* some rubbish */
+			pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_ONLY;
+		}
+	} else {  /* operator has stated nothing */
+		pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_TX_RX;
+	}
+
+	if (AutoSizing[pAC->Index] != NULL) {
+		if (strcmp(AutoSizing[pAC->Index], "On") == 0) {
+			pAC->DynIrqModInfo.AutoSizing = SK_FALSE;
+		} else {
+			pAC->DynIrqModInfo.AutoSizing = SK_FALSE;
+		}
+	} else {  /* operator has stated nothing */
+		pAC->DynIrqModInfo.AutoSizing = SK_FALSE;
+	}
 
-        if (IntsPerSec[pAC->Index] != 0) {
-           if ((IntsPerSec[pAC->Index]< 30) || (IntsPerSec[pAC->Index]> 40000)) {
-              pAC->DynIrqModInfo.MaxModIntsPerSec = C_INTS_PER_SEC_DEFAULT;
-           } else {
-              pAC->DynIrqModInfo.MaxModIntsPerSec = IntsPerSec[pAC->Index];
-           }
-        } else {
-           pAC->DynIrqModInfo.MaxModIntsPerSec = C_INTS_PER_SEC_DEFAULT;
-        }
+	if (IntsPerSec[pAC->Index] != 0) {
+		if ((IntsPerSec[pAC->Index]< C_INT_MOD_IPS_LOWER_RANGE) || 
+			(IntsPerSec[pAC->Index] > C_INT_MOD_IPS_UPPER_RANGE)) {
+	   		printk("sk98lin: Illegal value \"%d\" for IntsPerSec. (Range: %d - %d)\n"
+				"      Using default value of %i.\n", 
+				IntsPerSec[pAC->Index],
+				C_INT_MOD_IPS_LOWER_RANGE,
+				C_INT_MOD_IPS_UPPER_RANGE,
+				C_INTS_PER_SEC_DEFAULT);
+			pAC->DynIrqModInfo.MaxModIntsPerSec = C_INTS_PER_SEC_DEFAULT;
+		} else {
+			pAC->DynIrqModInfo.MaxModIntsPerSec = IntsPerSec[pAC->Index];
+		}
+	} else {
+		pAC->DynIrqModInfo.MaxModIntsPerSec = C_INTS_PER_SEC_DEFAULT;
+	}
 
-        /*
+	/*
 	** Evaluate upper and lower moderation threshold
 	*/
-        pAC->DynIrqModInfo.MaxModIntsPerSecUpperLimit =
-            pAC->DynIrqModInfo.MaxModIntsPerSec +
-            (pAC->DynIrqModInfo.MaxModIntsPerSec / 2);
-
-        pAC->DynIrqModInfo.MaxModIntsPerSecLowerLimit =
-            pAC->DynIrqModInfo.MaxModIntsPerSec -
-            (pAC->DynIrqModInfo.MaxModIntsPerSec / 2);
+	pAC->DynIrqModInfo.MaxModIntsPerSecUpperLimit =
+		pAC->DynIrqModInfo.MaxModIntsPerSec +
+		(pAC->DynIrqModInfo.MaxModIntsPerSec / 2);
+
+	pAC->DynIrqModInfo.MaxModIntsPerSecLowerLimit =
+		pAC->DynIrqModInfo.MaxModIntsPerSec -
+		(pAC->DynIrqModInfo.MaxModIntsPerSec / 2);
 
-        pAC->DynIrqModInfo.PrevTimeVal = jiffies;  /* initial value */
+	pAC->DynIrqModInfo.PrevTimeVal = jiffies;  /* initial value */
 
 
 } /* GetConfiguration */
@@ -4826,6 +5037,10 @@ SK_BOOL		DualNet;
 		FromPort = Param.Para32[0];
 		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
 			("NET UP EVENT, Port: %d ", Param.Para32[0]));
+		/* Mac update */
+		SkAddrMcUpdate(pAC,IoC, FromPort);
+
+		if (DoPrintInterfaceChange) {
 		printk("%s: network connection up using"
 			" port %c\n", pAC->dev[Param.Para32[0]]->name, 'A'+Param.Para32[0]);
 
@@ -4841,8 +5056,6 @@ SK_BOOL		DualNet;
 			printk("    speed:           unknown\n");
 		}
 
-		/* Mac update */
-		SkAddrMcUpdate(pAC,IoC, FromPort);
 
 		Stat = pAC->GIni.GP[FromPort].PLinkModeStatus;
 		if (Stat == SK_LMODE_STAT_AUTOHALF ||
@@ -4920,6 +5133,9 @@ SK_BOOL		DualNet;
 			printk("    rx-checksum:     disabled\n");
 #endif
 
+		} else {
+                        DoPrintInterfaceChange = SK_TRUE;
+                }
 	
 		if ((Param.Para32[0] != pAC->ActivePort) &&
 			(pAC->RlmtNets == 1)) {
@@ -4937,7 +5153,12 @@ SK_BOOL		DualNet;
 		/* action list 7 */
 		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
 			("NET DOWN EVENT "));
-		printk("%s: network connection down\n", pAC->dev[Param.Para32[1]]->name);
+		if (DoPrintInterfaceChange) {
+			printk("%s: network connection down\n", 
+				pAC->dev[Param.Para32[1]]->name);
+		} else {
+			DoPrintInterfaceChange = SK_TRUE;
+		}
 		pAC->dev[Param.Para32[1]]->flags &= ~IFF_RUNNING;
 		break;
 	case SK_DRV_SWITCH_HARD: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */
@@ -5122,6 +5343,231 @@ char	ClassStr[80];
 
 } /* SkErrorLog */
 
+#ifdef SK_DIAG_SUPPORT
+
+/*****************************************************************************
+ *
+ *	SkDrvEnterDiagMode - handles DIAG attach request
+ *
+ * Description:
+ *	Notify the kernel to NOT access the card any longer due to DIAG
+ *	Deinitialize the Card
+ *
+ * Returns:
+ *	int
+ */
+int SkDrvEnterDiagMode(
+SK_AC   *pAc)   /* pointer to adapter context */
+{
+	SK_AC   *pAC  = NULL;
+	DEV_NET *pNet = NULL;
+
+	pNet = (DEV_NET *) pAc->dev[0]->priv;
+	pAC = pNet->pAC;
+
+	SK_MEMCPY(&(pAc->PnmiBackup), &(pAc->PnmiStruct), 
+			sizeof(SK_PNMI_STRUCT_DATA));
+
+	pAC->DiagModeActive = DIAG_ACTIVE;
+	if (pAC->BoardLevel > SK_INIT_DATA) {
+		if (pNet->Up) {
+			pAC->WasIfUp[0] = SK_TRUE;
+			pAC->DiagFlowCtrl = SK_TRUE; /* for SkGeClose      */
+			DoPrintInterfaceChange = SK_FALSE;
+			SkDrvDeInitAdapter(pAC, 0);  /* performs SkGeClose */
+		} else {
+			pAC->WasIfUp[0] = SK_FALSE;
+		}
+		if (pNet != (DEV_NET *) pAc->dev[1]->priv) {
+			pNet = (DEV_NET *) pAc->dev[1]->priv;
+			if (pNet->Up) {
+				pAC->WasIfUp[1] = SK_TRUE;
+				pAC->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */
+				DoPrintInterfaceChange = SK_FALSE;
+				SkDrvDeInitAdapter(pAC, 1);  /* do SkGeClose  */
+			} else {
+				pAC->WasIfUp[1] = SK_FALSE;
+			}
+		}
+		pAC->BoardLevel = SK_INIT_DATA;
+	}
+	return(0);
+}
+
+/*****************************************************************************
+ *
+ *	SkDrvLeaveDiagMode - handles DIAG detach request
+ *
+ * Description:
+ *	Notify the kernel to may access the card again after use by DIAG
+ *	Initialize the Card
+ *
+ * Returns:
+ * 	int
+ */
+int SkDrvLeaveDiagMode(
+SK_AC   *pAc)   /* pointer to adapter control context */
+{ 
+	SK_MEMCPY(&(pAc->PnmiStruct), &(pAc->PnmiBackup), 
+			sizeof(SK_PNMI_STRUCT_DATA));
+	pAc->DiagModeActive    = DIAG_NOTACTIVE;
+	pAc->Pnmi.DiagAttached = SK_DIAG_IDLE;
+        if (pAc->WasIfUp[0] == SK_TRUE) {
+                pAc->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */
+		DoPrintInterfaceChange = SK_FALSE;
+                SkDrvInitAdapter(pAc, 0);    /* first device  */
+        }
+        if (pAc->WasIfUp[1] == SK_TRUE) {
+                pAc->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */
+		DoPrintInterfaceChange = SK_FALSE;
+                SkDrvInitAdapter(pAc, 1);    /* second device */
+        }
+	return(0);
+}
+
+/*****************************************************************************
+ *
+ *	ParseDeviceNbrFromSlotName - Evaluate PCI device number
+ *
+ * Description:
+ * 	This function parses the PCI slot name information string and will
+ *	retrieve the devcie number out of it. The slot_name maintianed by
+ *	linux is in the form of '02:0a.0', whereas the first two characters 
+ *	represent the bus number in hex (in the sample above this is 
+ *	pci bus 0x02) and the next two characters the device number (0x0a).
+ *
+ * Returns:
+ *	SK_U32: The device number from the PCI slot name
+ */ 
+
+static SK_U32 ParseDeviceNbrFromSlotName(
+const char *SlotName)   /* pointer to pci slot name eg. '02:0a.0' */
+{
+	char	*CurrCharPos	= (char *) SlotName;
+	int	FirstNibble	= -1;
+	int	SecondNibble	= -1;
+	SK_U32	Result		=  0;
+
+	while (*CurrCharPos != '\0') {
+		if (*CurrCharPos == ':') { 
+			while (*CurrCharPos != '.') {
+				CurrCharPos++;  
+				if (	(*CurrCharPos >= '0') && 
+					(*CurrCharPos <= '9')) {
+					if (FirstNibble == -1) {
+						/* dec. value for '0' */
+						FirstNibble = *CurrCharPos - 48;
+					} else {
+						SecondNibble = *CurrCharPos - 48;
+					}  
+				} else if (	(*CurrCharPos >= 'a') && 
+						(*CurrCharPos <= 'f')  ) {
+					if (FirstNibble == -1) {
+						FirstNibble = *CurrCharPos - 87; 
+					} else {
+						SecondNibble = *CurrCharPos - 87; 
+					}
+				} else {
+					Result = 0;
+				}
+			}
+
+			Result = FirstNibble;
+			Result = Result << 4; /* first nibble is higher one */
+			Result = Result | SecondNibble;
+		}
+		CurrCharPos++;   /* next character */
+	}
+	return (Result);
+}
+
+/****************************************************************************
+ *
+ *	SkDrvDeInitAdapter - deinitialize adapter (this function is only 
+ *				called if Diag attaches to that card)
+ *
+ * Description:
+ *	Close initialized adapter.
+ *
+ * Returns:
+ *	0 - on success
+ *	error code - on error
+ */
+static int SkDrvDeInitAdapter(
+SK_AC   *pAC,		/* pointer to adapter context   */
+int      devNbr)	/* what device is to be handled */
+{
+	struct SK_NET_DEVICE *dev;
+
+	dev = pAC->dev[devNbr];
+
+	/*
+	** Function SkGeClose() uses MOD_DEC_USE_COUNT (2.2/2.4)
+	** or module_put() (2.6) to decrease the number of users for
+	** a device, but if a device is to be put under control of 
+	** the DIAG, that count is OK already and does not need to 
+	** be adapted! Hence the opposite MOD_INC_USE_COUNT or 
+	** try_module_get() needs to be used again to correct that.
+	*/
+	if (!try_module_get(THIS_MODULE)) {
+		return (-1);
+	}
+
+	if (SkGeClose(dev) != 0) {
+		module_put(THIS_MODULE);
+		return (-1);
+	}
+	return (0);
+
+} /* SkDrvDeInitAdapter() */
+
+/****************************************************************************
+ *
+ *	SkDrvInitAdapter - Initialize adapter (this function is only 
+ *				called if Diag deattaches from that card)
+ *
+ * Description:
+ *	Close initialized adapter.
+ *
+ * Returns:
+ *	0 - on success
+ *	error code - on error
+ */
+static int SkDrvInitAdapter(
+SK_AC   *pAC,		/* pointer to adapter context   */
+int      devNbr)	/* what device is to be handled */
+{
+	struct SK_NET_DEVICE *dev;
+
+	dev = pAC->dev[devNbr];
+
+	if (SkGeOpen(dev) != 0) {
+		return (-1);
+	} else {
+		/*
+		** Function SkGeOpen() uses MOD_INC_USE_COUNT (2.2/2.4) 
+		** or try_module_get() (2.6) to increase the number of 
+		** users for a device, but if a device was just under 
+		** control of the DIAG, that count is OK already and 
+		** does not need to be adapted! Hence the opposite 
+		** MOD_DEC_USE_COUNT or module_put() needs to be used 
+		** again to correct that.
+		*/
+		module_put(THIS_MODULE);
+	}
+
+	/*
+	** Use correct MTU size and indicate to kernel TX queue can be started
+	*/ 
+	if (SkGeChangeMtu(dev, dev->mtu) != 0) {
+		return (-1);
+	} 
+	return (0);
+
+} /* SkDrvInitAdapter */
+
+#endif
+
 #ifdef DEBUG
 /****************************************************************************/
 /* "debug only" section *****************************************************/
diff -puN drivers/net/sk98lin/skgehwt.c~linus drivers/net/sk98lin/skgehwt.c
--- 25/drivers/net/sk98lin/skgehwt.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/skgehwt.c	2004-01-19 22:17:22.000000000 -0800
@@ -1,10 +1,10 @@
 /******************************************************************************
  *
  * Name:	skgehwt.c
- * Project:	Gigabit Ethernet Adapters, Common Modules
- * Version:	$Revision: 1.14 $
- * Date:	$Date: 2003/05/13 18:01:58 $
- * Purpose:	Hardware Timer.
+ * Project:	Gigabit Ethernet Adapters, Event Scheduler Module
+ * Version:	$Revision: 1.15 $
+ * Date:	$Date: 2003/09/16 13:41:23 $
+ * Purpose:	Hardware Timer
  *
  ******************************************************************************/
 
@@ -27,6 +27,10 @@
  * History:
  *
  *	$Log: skgehwt.c,v $
+ *	Revision 1.15  2003/09/16 13:41:23  rschmidt
+ *	Added (C) Marvell to SysKonnectFileId
+ *	Editorial changes
+ *	
  *	Revision 1.14  2003/05/13 18:01:58  mkarl
  *	Editorial changes.
  *	
@@ -69,19 +73,15 @@
  *	
  *	Revision 1.1  1998/08/05 11:28:36  gklug
  *	first version: adapted from SMT/FDDI
- *	
- *	
- *	
  *
  ******************************************************************************/
 
-
 /*
-	Event queue and dispatcher
-*/
+ *	Event queue and dispatcher
+ */
 #if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
 static const char SysKonnectFileId[] =
-	"$Header: /usr56/projects/ge/schedule/skgehwt.c,v 1.14 2003/05/13 18:01:58 mkarl Exp $" ;
+	"@(#) $Id: skgehwt.c,v 1.15 2003/09/16 13:41:23 rschmidt Exp $ (C) Marvell.";
 #endif
 
 #include "h/skdrv1st.h"		/* Driver Specific Definitions */
@@ -89,10 +89,7 @@ static const char SysKonnectFileId[] =
 
 #ifdef __C2MAN__
 /*
-	Hardware Timer function queue management.
-
-	General Description:
-
+ *   Hardware Timer function queue management.
  */
 intro()
 {}
@@ -117,9 +114,9 @@ SK_IOC	Ioc)	/* IoContext */
 {
 	pAC->Hwt.TStart = 0 ;
 	pAC->Hwt.TStop	= 0 ;
-	pAC->Hwt.TActive = SK_FALSE ;
+	pAC->Hwt.TActive = SK_FALSE;
 
-	SkHwtStop(pAC,Ioc) ;
+	SkHwtStop(pAC, Ioc);
 }
 
 /*
@@ -132,28 +129,29 @@ SK_AC	*pAC,	/* Adapters context */
 SK_IOC	Ioc,	/* IoContext */
 SK_U32	Time)	/* Time in units of 16us to load the timer with. */
 {
-	SK_U32	Cnt ;
+	SK_U32	Cnt;
 
 	if (Time > SK_HWT_MAX)
-		Time = SK_HWT_MAX ;
+		Time = SK_HWT_MAX;
 
-	pAC->Hwt.TStart = Time ;
-	pAC->Hwt.TStop = 0L ;
+	pAC->Hwt.TStart = Time;
+	pAC->Hwt.TStop = 0L;
 
-	Cnt = Time ;
+	Cnt = Time;
 
 	/*
 	 * if time < 16 us
 	 *	time = 16 us
 	 */
 	if (!Cnt) {
-		Cnt++ ;
+		Cnt++;
 	}
 
-	SK_OUT32(Ioc, B2_TI_INI, Cnt * SK_HWT_FAC) ;
-	SK_OUT16(Ioc, B2_TI_CRTL, TIM_START) ;	/* Start timer. */
+	SK_OUT32(Ioc, B2_TI_INI, Cnt * SK_HWT_FAC);
+	
+	SK_OUT16(Ioc, B2_TI_CTRL, TIM_START);	/* Start timer. */
 
-	pAC->Hwt.TActive = SK_TRUE ;
+	pAC->Hwt.TActive = SK_TRUE;
 }
 
 /*
@@ -164,10 +162,11 @@ void	SkHwtStop(
 SK_AC	*pAC,	/* Adapters context */
 SK_IOC	Ioc)	/* IoContext */
 {
-	SK_OUT16(Ioc, B2_TI_CRTL, TIM_STOP) ;
-	SK_OUT16(Ioc, B2_TI_CRTL, TIM_CLR_IRQ) ;
+	SK_OUT16(Ioc, B2_TI_CTRL, TIM_STOP);
+	
+	SK_OUT16(Ioc, B2_TI_CTRL, TIM_CLR_IRQ);
 
-	pAC->Hwt.TActive = SK_FALSE ;
+	pAC->Hwt.TActive = SK_FALSE;
 }
 
 
@@ -182,26 +181,31 @@ SK_U32	SkHwtRead(
 SK_AC	*pAC,	/* Adapters context */
 SK_IOC	Ioc)	/* IoContext */
 {
-	SK_U32	TRead ;
-	SK_U32	IStatus ;
+	SK_U32	TRead;
+	SK_U32	IStatus;
 
 	if (pAC->Hwt.TActive) {
-		SkHwtStop(pAC,Ioc) ;
+		
+		SkHwtStop(pAC, Ioc);
 
 		SK_IN32(Ioc, B2_TI_VAL, &TRead);
 		TRead /= SK_HWT_FAC;
 
 		SK_IN32(Ioc, B0_ISRC, &IStatus);
 
-		/* Check if timer expired (or wraparound). */
+		/* Check if timer expired (or wraped around) */
 		if ((TRead > pAC->Hwt.TStart) || (IStatus & IS_TIMINT)) {
-			SkHwtStop(pAC,Ioc) ;
-			pAC->Hwt.TStop = pAC->Hwt.TStart ;
-		} else {
-			pAC->Hwt.TStop = pAC->Hwt.TStart - TRead ;
+			
+			SkHwtStop(pAC, Ioc);
+			
+			pAC->Hwt.TStop = pAC->Hwt.TStart;
+		}
+		else {
+			
+			pAC->Hwt.TStop = pAC->Hwt.TStart - TRead;
 		}
 	}
-	return (pAC->Hwt.TStop) ;
+	return(pAC->Hwt.TStop);
 }
 
 /*
@@ -211,9 +215,11 @@ void	SkHwtIsr(
 SK_AC	*pAC,	/* Adapters context */
 SK_IOC	Ioc)	/* IoContext */
 {
-	SkHwtStop(pAC,Ioc);
+	SkHwtStop(pAC, Ioc);
+	
 	pAC->Hwt.TStop = pAC->Hwt.TStart;
-	SkTimerDone(pAC,Ioc) ;
+	
+	SkTimerDone(pAC, Ioc);
 }
 
 /* End of file */
diff -puN drivers/net/sk98lin/skgeinit.c~linus drivers/net/sk98lin/skgeinit.c
--- 25/drivers/net/sk98lin/skgeinit.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/skgeinit.c	2004-01-19 22:17:22.000000000 -0800
@@ -2,8 +2,8 @@
  *
  * Name:	skgeinit.c
  * Project:	Gigabit Ethernet Adapters, Common Modules
- * Version:	$Revision: 1.93 $
- * Date:	$Date: 2003/05/28 15:44:43 $
+ * Version:	$Revision: 1.97 $
+ * Date:	$Date: 2003/10/02 16:45:31 $
  * Purpose:	Contains functions to initialize the adapter
  *
  ******************************************************************************/
@@ -27,6 +27,32 @@
  * History:
  *
  *	$Log: skgeinit.c,v $
+ *	Revision 1.97  2003/10/02 16:45:31  rschmidt
+ *	Replaced default values of GMAC parameters with defines.
+ *	Removed hard reset of MACs in SkGeDeInit().
+ *	Added define SK_PHY_LP_MODE around power saving mode in SkGeDeInit().
+ *	Added check for VAUX available before switch power to VAUX.
+ *	
+ *	Revision 1.96  2003/09/18 14:02:41  rroesler
+ *	Add: Perform a hardreset of MACs in GeDeInit()
+ *	
+ *	Revision 1.95  2003/09/16 14:26:59  rschmidt
+ *	Added switch power to VCC (WA for VAUX problem) in SkGeInit1().
+ *	Fixed setting PHY to coma mode and D3 power state in SkGeDeInit().
+ *	Editorial changes.
+ *	
+ *	Revision 1.94  2003/09/16 07:17:10  mschmid
+ *	Added init for new members in port structure for MAC control
+ *	- PMacColThres
+ *	- PMacJamLen
+ *	- PMacJamIpgVal
+ *	- PMacJamIpgData
+ *	- PMacIpgData
+ *	- PMacLimit4
+ *	Added init for PHY power state in port structure
+ *	- PPhyPowerState
+ *	Added shutdown handling for Yukon Plus in SkGeDeInit()
+ *	
  *	Revision 1.93  2003/05/28 15:44:43  rschmidt
  *	Added check for chip Id on WOL WA for chip Rev. A.
  *	Added setting of GILevel in SkGeDeInit().
@@ -446,7 +472,7 @@
 
 #if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
 static const char SysKonnectFileId[] =
-	"@(#) $Id: skgeinit.c,v 1.93 2003/05/28 15:44:43 rschmidt Exp $ (C) Marvell.";
+	"@(#) $Id: skgeinit.c,v 1.97 2003/10/02 16:45:31 rschmidt Exp $ (C) Marvell.";
 #endif
 
 struct s_QOffTab {
@@ -1013,8 +1039,6 @@ int		Port)		/* Port Index (MAC_1 + n) */
 	 *	- enable the FIFO
 	 */
 	
-	Word = (SK_U16)GMF_RX_CTRL_DEF;
-	
 #ifdef GENESIS
 	if (pAC->GIni.GIGenesis) {
 		/* Configure Rx MAC FIFO */
@@ -1039,6 +1063,8 @@ int		Port)		/* Port Index (MAC_1 + n) */
 		/* set Rx GMAC FIFO Flush Mask */
 		SK_OUT16(IoC, MR_ADDR(Port, RX_GMF_FL_MSK), (SK_U16)RX_FF_FL_DEF_MSK);
 		
+		Word = (SK_U16)GMF_RX_CTRL_DEF;
+
 		/* disable Rx GMAC FIFO Flush for YUKON-Lite Rev. A0 only */
 		if (pAC->GIni.GIYukonLite && pAC->GIni.GIChipId == CHIP_ID_YUKON) {
 
@@ -1809,6 +1835,13 @@ SK_IOC	IoC)		/* IO context */
 		pPrt->PAutoNegFail = SK_FALSE;
 		pPrt->PHWLinkUp = SK_FALSE;
 		pPrt->PLinkBroken = SK_TRUE; /* See WA code */
+		pPrt->PPhyPowerState = PHY_PM_OPERATIONAL_MODE;
+		pPrt->PMacColThres = TX_COL_DEF;
+		pPrt->PMacJamLen = TX_JAM_LEN_DEF;
+		pPrt->PMacJamIpgVal	= TX_JAM_IPG_DEF;
+		pPrt->PMacJamIpgData = TX_IPG_JAM_DEF;
+		pPrt->PMacIpgData = IPG_DATA_DEF;
+		pPrt->PMacLimit4 = SK_FALSE;
 	}
 
 	pAC->GIni.GIPortUsage = SK_RED_LINK;
@@ -1963,7 +1996,7 @@ SK_IOC	IoC)		/* IO context */
 	/* restore CLK_RUN bits */
 	SK_OUT16(IoC, B0_CTST, (SK_U16)(CtrlStat &
 		(CS_CLK_RUN_HOT | CS_CLK_RUN_RST | CS_CLK_RUN_ENA)));
-	
+
 	/* read Chip Identification Number */
 	SK_IN8(IoC, B2_CHIP_ID, &Byte);
 	pAC->GIni.GIChipId = Byte;
@@ -2053,6 +2086,10 @@ SK_IOC	IoC)		/* IO context */
 			}
 		}
 
+		/* switch power to VCC (WA for VAUX problem) */
+		SK_OUT8(IoC, B0_POWER_CTRL, (SK_U8)(PC_VAUX_ENA | PC_VCC_ENA |
+			PC_VAUX_OFF | PC_VCC_ON));
+
 		/* read the Interrupt source */
 		SK_IN32(IoC, B0_ISRC, &DWord);
 		
@@ -2395,6 +2432,11 @@ SK_IOC	IoC)		/* IO context */
 	int	i;
 	SK_U16	Word;
 
+#ifdef SK_PHY_LP_MODE
+	SK_U8	Byte;
+	SK_U16	PmCtlSts;
+#endif /* SK_PHY_LP_MODE */
+
 #if (!defined(SK_SLIM) && !defined(VCPU))
 	/* ensure I2C is ready */
 	SkI2cWaitIrq(pAC, IoC);
@@ -2409,6 +2451,38 @@ SK_IOC	IoC)		/* IO context */
 		}
 	}
 
+#ifdef SK_PHY_LP_MODE
+    /*
+	 * for power saving purposes within mobile environments
+	 * we set the PHY to coma mode and switch to D3 power state.
+	 */
+	if (pAC->GIni.GIYukonLite &&
+		pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) {
+
+		/* for all ports switch PHY to coma mode */
+		for (i = 0; i < pAC->GIni.GIMacsFound; i++) {
+			
+			SkGmEnterLowPowerMode(pAC, IoC, i, PHY_PM_DEEP_SLEEP);
+		}
+
+		if (pAC->GIni.GIVauxAvail) {
+			/* switch power to VAUX */
+			Byte = PC_VAUX_ENA | PC_VCC_ENA | PC_VAUX_ON | PC_VCC_OFF;
+
+			SK_OUT8(IoC, B0_POWER_CTRL, Byte);
+		}
+		
+		/* switch to D3 state */
+		SK_IN16(IoC, PCI_C(PCI_PM_CTL_STS), &PmCtlSts);
+
+		PmCtlSts |= PCI_PM_STATE_D3;
+
+		SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
+
+		SK_OUT16(IoC, PCI_C(PCI_PM_CTL_STS), PmCtlSts);
+	}
+#endif /* SK_PHY_LP_MODE */
+
 	/* Reset all bits in the PCI STATUS register */
 	/*
 	 * Note: PCI Cfg cycles cannot be used, because they are not
diff -puN drivers/net/sk98lin/skgemib.c~linus drivers/net/sk98lin/skgemib.c
--- 25/drivers/net/sk98lin/skgemib.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/skgemib.c	2004-01-19 22:17:22.000000000 -0800
@@ -2,8 +2,8 @@
  *
  * Name:	skgemib.c
  * Project:	GEnesis, PCI Gigabit Ethernet Adapter
- * Version:	$Revision: 1.9 $
- * Date:	$Date: 2003/05/23 12:55:20 $
+ * Version:	$Revision: 1.11 $
+ * Date:	$Date: 2003/09/15 13:38:12 $
  * Purpose:	Private Network Management Interface Management Database
  *
  ****************************************************************************/
@@ -27,6 +27,19 @@
  * History:
  *
  *	$Log: skgemib.c,v $
+ *	Revision 1.11  2003/09/15 13:38:12  tschilli
+ *	OID_SKGE_PHY_LP_MODE included only after using #define SK_PHY_LP_MODE.
+ *	
+ *	Revision 1.10  2003/08/15 12:28:59  tschilli
+ *	Added new OIDs:
+ *	OID_SKGE_DRIVER_RELDATE
+ *	OID_SKGE_DRIVER_FILENAME
+ *	OID_SKGE_CHIPID
+ *	OID_SKGE_RAMSIZE
+ *	OID_SKGE_VAUXAVAIL
+ *	OID_SKGE_PHY_TYPE
+ *	OID_SKGE_PHY_LP_MODE
+ *	
  *	Revision 1.9  2003/05/23 12:55:20  tschilli
  *	OID_SKGE_BOARDLEVEL added.
  *	
@@ -356,6 +369,16 @@ PNMI_STATIC const SK_PNMI_TAB_ENTRY IdTa
 		0,
 		SK_PNMI_MAI_OFF(DriverVersion),
 		SK_PNMI_RO, General, 0},
+	{OID_SKGE_DRIVER_RELDATE,
+		1,
+		0,
+		SK_PNMI_MAI_OFF(DriverReleaseDate),
+		SK_PNMI_RO, General, 0},
+	{OID_SKGE_DRIVER_FILENAME,
+		1,
+		0,
+		SK_PNMI_MAI_OFF(DriverFileName),
+		SK_PNMI_RO, General, 0},
 	{OID_SKGE_HW_DESCR,
 		1,
 		0,
@@ -371,6 +394,21 @@ PNMI_STATIC const SK_PNMI_TAB_ENTRY IdTa
 		0,
 		SK_PNMI_MAI_OFF(Chipset),
 		SK_PNMI_RO, General, 0},
+	{OID_SKGE_CHIPID,
+		1,
+		0,
+		SK_PNMI_MAI_OFF(ChipId),
+		SK_PNMI_RO, General, 0},
+	{OID_SKGE_RAMSIZE,
+		1,
+		0,
+		SK_PNMI_MAI_OFF(RamSize),
+		SK_PNMI_RO, General, 0},
+	{OID_SKGE_VAUXAVAIL,
+		1,
+		0,
+		SK_PNMI_MAI_OFF(VauxAvail),
+		SK_PNMI_RO, General, 0},
 	{OID_SKGE_ACTION,
 		1,
 		0,
@@ -876,6 +914,18 @@ PNMI_STATIC const SK_PNMI_TAB_ENTRY IdTa
 		sizeof(SK_PNMI_CONF),
 		SK_PNMI_OFF(Conf) + SK_PNMI_CNF_OFF(ConfConnector),
 		SK_PNMI_RO, MacPrivateConf, 0},
+	{OID_SKGE_PHY_TYPE,
+		SK_PNMI_MAC_ENTRIES,
+		sizeof(SK_PNMI_CONF),
+		SK_PNMI_OFF(Conf) + SK_PNMI_CNF_OFF(ConfPhyType),
+		SK_PNMI_RO, MacPrivateConf, 0},
+#ifdef SK_PHY_LP_MODE
+		{OID_SKGE_PHY_LP_MODE,
+		SK_PNMI_MAC_ENTRIES,
+		sizeof(SK_PNMI_CONF),
+		SK_PNMI_OFF(Conf) + SK_PNMI_CNF_OFF(ConfPhyMode),
+		SK_PNMI_RW, MacPrivateConf, 0},
+#endif	
 	{OID_SKGE_LINK_CAP,
 		SK_PNMI_MAC_ENTRIES,
 		sizeof(SK_PNMI_CONF),
diff -puN drivers/net/sk98lin/skgepnmi.c~linus drivers/net/sk98lin/skgepnmi.c
--- 25/drivers/net/sk98lin/skgepnmi.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/skgepnmi.c	2004-01-19 22:17:22.000000000 -0800
@@ -2,8 +2,8 @@
  *
  * Name:	skgepnmi.c
  * Project:	GEnesis, PCI Gigabit Ethernet Adapter
- * Version:	$Revision: 1.109 $
- * Date:	$Date: 2003/07/17 14:15:24 $
+ * Version:	$Revision: 1.111 $
+ * Date:	$Date: 2003/09/15 13:35:35 $
  * Purpose:	Private Network Management Interface
  *
  ****************************************************************************/
@@ -27,6 +27,22 @@
  * History:
  *
  *	$Log: skgepnmi.c,v $
+ *	Revision 1.111  2003/09/15 13:35:35  tschilli
+ *	Code for OID_SKGE_PHY_LP_MODE completed (using #define SK_PHY_LP_MODE).
+ *	SK_DIAG_ATTACHED handling for OID_SKGE_DIAG_MODE in DiagActions() changed.
+ *	
+ *	Revision 1.110  2003/08/15 12:28:04  tschilli
+ *	Added new OIDs:
+ *	OID_SKGE_DRIVER_RELDATE
+ *	OID_SKGE_DRIVER_FILENAME
+ *	OID_SKGE_CHIPID
+ *	OID_SKGE_RAMSIZE
+ *	OID_SKGE_VAUXAVAIL
+ *	OID_SKGE_PHY_TYPE
+ *	OID_SKGE_PHY_LP_MODE
+ *	
+ *	Added SK_DIAG_ATTACHED handling for OID_SKGE_DIAG_MODE in DiagActions().
+ *	
  *	Revision 1.109  2003/07/17 14:15:24  tschilli
  *	Bug in SkPnmiGenIoctl() fixed.
  *	
@@ -471,7 +487,7 @@
 
 #ifndef _lint
 static const char SysKonnectFileId[] =
-	"@(#) $Id: skgepnmi.c,v 1.109 2003/07/17 14:15:24 tschilli Exp $ (C) Marvell.";
+	"@(#) $Id: skgepnmi.c,v 1.111 2003/09/15 13:35:35 tschilli Exp $ (C) Marvell.";
 #endif /* !_lint */
 
 #include "h/skdrv1st.h"
@@ -4008,14 +4024,6 @@ SK_U32 NetIndex)	/* NetIndex (0..n), in 
 #endif /* SK_NDIS_64BIT_CTR */
 		break;
 
-	case OID_SKGE_BOARDLEVEL:
-		if (*pLen < sizeof(SK_U32)) {
-
-			*pLen = sizeof(SK_U32);
-			return (SK_PNMI_ERR_TOO_SHORT);
-		}
-		break;
-
 	case OID_SKGE_PORT_NUMBER:
 	case OID_SKGE_DEVICE_TYPE:
 	case OID_SKGE_RESULT:
@@ -4023,6 +4031,9 @@ SK_U32 NetIndex)	/* NetIndex (0..n), in 
 	case OID_GEN_TRANSMIT_QUEUE_LENGTH:
 	case OID_SKGE_TRAP_NUMBER:
 	case OID_SKGE_MDB_VERSION:
+	case OID_SKGE_BOARDLEVEL:
+	case OID_SKGE_CHIPID:
+	case OID_SKGE_RAMSIZE:
 		if (*pLen < sizeof(SK_U32)) {
 
 			*pLen = sizeof(SK_U32);
@@ -4043,6 +4054,7 @@ SK_U32 NetIndex)	/* NetIndex (0..n), in 
 	case OID_SKGE_BUS_WIDTH:
 	case OID_SKGE_SENSOR_NUMBER:
 	case OID_SKGE_CHKSM_NUMBER:
+	case OID_SKGE_VAUXAVAIL:
 		if (*pLen < sizeof(SK_U8)) {
 
 			*pLen = sizeof(SK_U8);
@@ -4234,6 +4246,66 @@ SK_U32 NetIndex)	/* NetIndex (0..n), in 
 		*pLen = Len;
 		break;
 
+	case OID_SKGE_DRIVER_RELDATE:
+		if (pAC->Pnmi.pDriverReleaseDate == NULL) {
+
+			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR030,
+				SK_PNMI_ERR053MSG);
+
+			*pLen = 0;
+			return (SK_PNMI_ERR_GENERAL);
+		}
+
+		Len = SK_STRLEN(pAC->Pnmi.pDriverReleaseDate) + 1;
+		if (Len > SK_PNMI_STRINGLEN1) {
+
+			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR031,
+				SK_PNMI_ERR054MSG);
+
+			*pLen = 0;
+			return (SK_PNMI_ERR_GENERAL);
+		}
+
+		if (*pLen < Len) {
+
+			*pLen = Len;
+			return (SK_PNMI_ERR_TOO_SHORT);
+		}
+		*pBuf = (char)(Len - 1);
+		SK_MEMCPY(pBuf + 1, pAC->Pnmi.pDriverReleaseDate, Len - 1);
+		*pLen = Len;
+		break;
+
+	case OID_SKGE_DRIVER_FILENAME:
+		if (pAC->Pnmi.pDriverFileName == NULL) {
+
+			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR030,
+				SK_PNMI_ERR055MSG);
+
+			*pLen = 0;
+			return (SK_PNMI_ERR_GENERAL);
+		}
+
+		Len = SK_STRLEN(pAC->Pnmi.pDriverFileName) + 1;
+		if (Len > SK_PNMI_STRINGLEN1) {
+
+			SK_ERR_LOG(pAC, SK_ERRCL_SW, SK_PNMI_ERR031,
+				SK_PNMI_ERR056MSG);
+
+			*pLen = 0;
+			return (SK_PNMI_ERR_GENERAL);
+		}
+
+		if (*pLen < Len) {
+
+			*pLen = Len;
+			return (SK_PNMI_ERR_TOO_SHORT);
+		}
+		*pBuf = (char)(Len - 1);
+		SK_MEMCPY(pBuf + 1, pAC->Pnmi.pDriverFileName, Len - 1);
+		*pLen = Len;
+		break;
+
 	case OID_SKGE_HW_DESCR:
 		/*
 		 * The hardware description is located in the VPD. This
@@ -4291,8 +4363,25 @@ SK_U32 NetIndex)	/* NetIndex (0..n), in 
 		*pLen = sizeof(SK_U16);
 		break;
 
+	case OID_SKGE_CHIPID:
+		Val32 = pAC->GIni.GIChipId;
+		SK_PNMI_STORE_U32(pBuf, Val32);
+		*pLen = sizeof(SK_U32);
+		break;
+
+	case OID_SKGE_RAMSIZE:
+		Val32 = pAC->GIni.GIRamSize;
+		SK_PNMI_STORE_U32(pBuf, Val32);
+		*pLen = sizeof(SK_U32);
+		break;
+
+	case OID_SKGE_VAUXAVAIL:
+		*pBuf = (char) pAC->GIni.GIVauxAvail;
+		*pLen = sizeof(char);
+		break;
+
 	case OID_SKGE_BUS_TYPE:
-		*pBuf = (char)SK_PNMI_BUS_PCI;
+		*pBuf = (char) SK_PNMI_BUS_PCI;
 		*pLen = sizeof(char);
 		break;
 
@@ -5435,6 +5524,9 @@ SK_U32 NetIndex)	/* NetIndex (0..n), in 
 		case OID_SKGE_SPEED_CAP:
 		case OID_SKGE_SPEED_MODE:
 		case OID_SKGE_SPEED_STATUS:
+#ifdef SK_PHY_LP_MODE
+		case OID_SKGE_PHY_LP_MODE:
+#endif
 			if (*pLen < (Limit - LogPortIndex) * sizeof(SK_U8)) {
 
 				*pLen = (Limit - LogPortIndex) * sizeof(SK_U8);
@@ -5443,6 +5535,7 @@ SK_U32 NetIndex)	/* NetIndex (0..n), in 
 			break;
 
         case OID_SKGE_MTU:
+        case OID_SKGE_PHY_TYPE:
 			if (*pLen < (Limit - LogPortIndex) * sizeof(SK_U32)) {
 
 				*pLen = (Limit - LogPortIndex) * sizeof(SK_U32);
@@ -5488,6 +5581,49 @@ SK_U32 NetIndex)	/* NetIndex (0..n), in 
 				Offset += sizeof(char);
 				break;
 
+			case OID_SKGE_PHY_TYPE:
+				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
+					if (LogPortIndex == 0) {
+						continue;
+					}
+					else {
+						/* Get value for physical ports */
+						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(
+							pAC, LogPortIndex);
+						Val32 = pAC->GIni.GP[PhysPortIndex].PhyType;
+						SK_PNMI_STORE_U32(pBufPtr, Val32);
+					}
+				}
+				else { /* DualNetMode */
+					
+					Val32 = pAC->GIni.GP[NetIndex].PhyType;
+					SK_PNMI_STORE_U32(pBufPtr, Val32);
+				}
+				Offset += sizeof(SK_U32);
+				break;
+
+#ifdef SK_PHY_LP_MODE
+			case OID_SKGE_PHY_LP_MODE:
+				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
+					if (LogPortIndex == 0) {
+						continue;
+					}
+					else {
+						/* Get value for physical ports */
+						PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(pAC, LogPortIndex);
+						Val8 = (SK_U8) pAC->GIni.GP[PhysPortIndex].PPhyPowerState;
+						*pBufPtr = Val8;
+					}
+				}
+				else { /* DualNetMode */
+					
+					Val8 = (SK_U8) pAC->GIni.GP[PhysPortIndex].PPhyPowerState;
+					*pBufPtr = Val8;
+				}
+				Offset += sizeof(SK_U8);
+				break;
+#endif
+
 			case OID_SKGE_LINK_CAP:
 				if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
 					if (LogPortIndex == 0) {
@@ -5804,6 +5940,16 @@ SK_U32 NetIndex)	/* NetIndex (0..n), in 
 		}
 		break;
 
+#ifdef SK_PHY_LP_MODE
+	case OID_SKGE_PHY_LP_MODE:
+		if (*pLen < Limit - LogPortIndex) {
+
+			*pLen = Limit - LogPortIndex;
+			return (SK_PNMI_ERR_TOO_SHORT);
+		}
+		break;
+#endif
+
 	case OID_SKGE_MTU:
 		if (*pLen < sizeof(SK_U32)) {
 
@@ -6160,6 +6306,116 @@ SK_U32 NetIndex)	/* NetIndex (0..n), in 
 
 			Offset += sizeof(SK_U32);
 			break;
+		
+#ifdef SK_PHY_LP_MODE
+		case OID_SKGE_PHY_LP_MODE:
+			/* The preset ends here */
+			if (Action == SK_PNMI_PRESET) {
+
+				return (SK_PNMI_ERR_OK);
+			}
+
+			if (!pAC->Pnmi.DualNetActiveFlag) { /* SingleNetMode */
+				if (LogPortIndex == 0) {
+					Offset = 0;
+					continue;
+				}
+				else {
+					/* Set value for physical ports */
+					PhysPortIndex = SK_PNMI_PORT_LOG2PHYS(pAC, LogPortIndex);
+
+					switch (*(pBuf + Offset)) {
+						case 0:
+							/* If LowPowerMode is active, we can leave it. */
+							if (pAC->GIni.GP[PhysPortIndex].PPhyPowerState) {
+
+								Val32 = SkGmLeaveLowPowerMode(pAC, IoC, PhysPortIndex);
+								
+								if (pAC->GIni.GP[PhysPortIndex].PPhyPowerState < 3)	{
+									
+									SkDrvInitAdapter(pAC);
+								}
+								break;
+							}
+							else {
+								*pLen = 0;
+								return (SK_PNMI_ERR_GENERAL);
+							}
+						case 1:
+						case 2:
+						case 3:
+						case 4:
+							/* If no LowPowerMode is active, we can enter it. */
+							if (!pAC->GIni.GP[PhysPortIndex].PPhyPowerState) {
+
+								if ((*(pBuf + Offset)) < 3)	{
+								
+									SkDrvDeInitAdapter(pAC);
+								}
+
+								Val32 = SkGmEnterLowPowerMode(pAC, IoC, PhysPortIndex, *pBuf);
+								break;
+							}
+							else {
+								*pLen = 0;
+								return (SK_PNMI_ERR_GENERAL);
+							}
+						default:
+							*pLen = 0;
+							return (SK_PNMI_ERR_BAD_VALUE);
+					}
+				}
+			}
+			else { /* DualNetMode */
+				
+				switch (*(pBuf + Offset)) {
+					case 0:
+						/* If we are in a LowPowerMode, we can leave it. */
+						if (pAC->GIni.GP[PhysPortIndex].PPhyPowerState) {
+
+							Val32 = SkGmLeaveLowPowerMode(pAC, IoC, PhysPortIndex);
+							
+							if (pAC->GIni.GP[PhysPortIndex].PPhyPowerState < 3)	{
+
+								SkDrvInitAdapter(pAC);
+							}
+							break;
+						}
+						else {
+							*pLen = 0;
+							return (SK_PNMI_ERR_GENERAL);
+						}
+					
+					case 1:
+					case 2:
+					case 3:
+					case 4:
+						/* If we are not already in LowPowerMode, we can enter it. */
+						if (!pAC->GIni.GP[PhysPortIndex].PPhyPowerState) {
+
+							if ((*(pBuf + Offset)) < 3)	{
+
+								SkDrvDeInitAdapter(pAC);
+							}
+							else {
+
+								Val32 = SkGmEnterLowPowerMode(pAC, IoC, PhysPortIndex, *pBuf);
+							}
+							break;
+						}
+						else {
+							*pLen = 0;
+							return (SK_PNMI_ERR_GENERAL);
+						}
+					
+					default:
+						*pLen = 0;
+						return (SK_PNMI_ERR_BAD_VALUE);
+				}
+			}
+			Offset += sizeof(SK_U8);
+			break;
+#endif
 
 		default:
             SK_DBG_MSG(pAC, SK_DBGMOD_PNMI, SK_DBGCAT_ERR,
@@ -6318,6 +6574,7 @@ char *pBuf)		/* Buffer used for the mana
 	unsigned int	PhysPortMax;
 	unsigned int	PhysPortIndex;
 	SK_U8		Val8;
+	SK_U32		Val32;
 	SK_BOOL		PortActiveFlag;
 	SK_GEPORT	*pPrt;
 
@@ -6340,6 +6597,14 @@ char *pBuf)		/* Buffer used for the mana
 
 		switch (Id) {
 
+		case OID_SKGE_PHY_TYPE:
+			/* Check if it is the first active port */
+			if (*pBuf == 0) {
+				Val32 = pPrt->PhyType;
+				SK_PNMI_STORE_U32(pBuf, Val32);
+				continue;
+			}
+
 		case OID_SKGE_LINK_CAP:
 
 			/*
@@ -7974,6 +8239,7 @@ unsigned int TableIndex, /* Index to the
 SK_U32 NetIndex)	/* NetIndex (0..n), in single net mode always zero */
 {
 
+	SK_U32	DiagStatus;
 	SK_U32	RetCode = SK_PNMI_ERR_GENERAL;
 
 	/*
@@ -8012,7 +8278,8 @@ SK_U32 NetIndex)	/* NetIndex (0..n), in 
 		switch (Id) {
 
 		case OID_SKGE_DIAG_MODE:
-			SK_PNMI_STORE_U32(pBuf, pAC->DiagModeActive);
+			DiagStatus = pAC->Pnmi.DiagAttached;
+			SK_PNMI_STORE_U32(pBuf, DiagStatus);
 			*pLen = sizeof(SK_U32);	
 			RetCode = SK_PNMI_ERR_OK;
 			break;
@@ -8022,7 +8289,6 @@ SK_U32 NetIndex)	/* NetIndex (0..n), in 
 			RetCode = SK_PNMI_ERR_GENERAL;
 			break;
 		}
-
 		return (RetCode); 
 	}
 
@@ -8039,23 +8305,84 @@ SK_U32 NetIndex)	/* NetIndex (0..n), in 
 
 			/* Handle the SET. */
 			switch (*pBuf) {
-		
+
+				/* Attach the DIAG to this adapter. */
+				case SK_DIAG_ATTACHED:
+					/* Check if we come from running */
+					if (pAC->Pnmi.DiagAttached == SK_DIAG_RUNNING) {
+
+						RetCode = SkDrvLeaveDiagMode(pAC);
+
+					}
+					else if (pAC->Pnmi.DiagAttached == SK_DIAG_IDLE) {
+
+						RetCode = SK_PNMI_ERR_OK;
+					}	
+					
+					else {
+
+						RetCode = SK_PNMI_ERR_GENERAL;
+
+					}
+					
+					if (RetCode == SK_PNMI_ERR_OK) {
+
+						pAC->Pnmi.DiagAttached = SK_DIAG_ATTACHED;
+					}
+					break;
+
 				/* Enter the DIAG mode in the driver. */
-				case 1:
-					/* If DiagMode is not active, we can enter it. */
-					if (!pAC->DiagModeActive) {
+				case SK_DIAG_RUNNING:
+					RetCode = SK_PNMI_ERR_OK;
+					
+					/*
+					 * If DiagAttached is set, we can tell the driver
+					 * to enter the DIAG mode.
+					 */
+					if (pAC->Pnmi.DiagAttached == SK_DIAG_ATTACHED) {
+						/* If DiagMode is not active, we can enter it. */
+						if (!pAC->DiagModeActive) {
 
-						RetCode = SkDrvEnterDiagMode(pAC);	
+							RetCode = SkDrvEnterDiagMode(pAC); 
+						}
+						else {
+
+							RetCode = SK_PNMI_ERR_GENERAL;
+						}
 					}
 					else {
 
 						RetCode = SK_PNMI_ERR_GENERAL;
 					}
+					
+					if (RetCode == SK_PNMI_ERR_OK) {
+
+						pAC->Pnmi.DiagAttached = SK_DIAG_RUNNING;
+					}
 					break;
 
-				/* Leave the DIAG mode in the driver. */
-				case 0:
-					RetCode = SkDrvLeaveDiagMode(pAC);	
+				case SK_DIAG_IDLE:
+					/* Check if we come from running */
+					if (pAC->Pnmi.DiagAttached == SK_DIAG_RUNNING) {
+
+						RetCode = SkDrvLeaveDiagMode(pAC);
+
+					}
+					else if (pAC->Pnmi.DiagAttached == SK_DIAG_ATTACHED) {
+
+						RetCode = SK_PNMI_ERR_OK;
+					}	
+					
+					else {
+
+						RetCode = SK_PNMI_ERR_GENERAL;
+
+					}
+
+					if (RetCode == SK_PNMI_ERR_OK) {
+
+						pAC->Pnmi.DiagAttached = SK_DIAG_IDLE;
+					}
 					break;
 
 				default:
diff -puN drivers/net/sk98lin/skgesirq.c~linus drivers/net/sk98lin/skgesirq.c
--- 25/drivers/net/sk98lin/skgesirq.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/skgesirq.c	2004-01-19 22:17:22.000000000 -0800
@@ -2,8 +2,8 @@
  *
  * Name:	skgesirq.c
  * Project:	Gigabit Ethernet Adapters, Common Modules
- * Version:	$Revision: 1.91 $
- * Date:	$Date: 2003/07/04 12:46:22 $
+ * Version:	$Revision: 1.92 $
+ * Date:	$Date: 2003/09/16 14:37:07 $
  * Purpose:	Special IRQ module
  *
  ******************************************************************************/
@@ -27,6 +27,12 @@
  * History:
  *
  *	$Log: skgesirq.c,v $
+ *	Revision 1.92  2003/09/16 14:37:07  rschmidt
+ *	Added debug messages in some SkGePortCheckUp...() routines.
+ *	Fixed compiler warnings for different types.
+ *	Avoided port check up in reset state (eg. coma mode).
+ *	Editorial changes.
+ *	
  *	Revision 1.91  2003/07/04 12:46:22  rschmidt
  *	Added debug messages in SkGePortCheckUpGmac().
  *	Added error log message and new driver event SK_DRV_DOWNSHIFT_DET
@@ -410,7 +416,7 @@
 
 #if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
 static const char SysKonnectFileId[] =
-	"@(#) $Id: skgesirq.c,v 1.91 2003/07/04 12:46:22 rschmidt Exp $ (C) Marvell.";
+	"@(#) $Id: skgesirq.c,v 1.92 2003/09/16 14:37:07 rschmidt Exp $ (C) Marvell.";
 #endif
 
 #include "h/skdrv1st.h"		/* Driver Specific Definitions */
@@ -490,7 +496,7 @@ int		Port)	/* Port Index (MAC_1 + n) */
 		("AutoSensing: First mode %d on Port %d\n",
 		(int)SK_LMODE_AUTOFULL, Port));
 
-	pPrt->PLinkMode = SK_LMODE_AUTOFULL;
+	pPrt->PLinkMode = (SK_U8)SK_LMODE_AUTOFULL;
 
 	return;
 }	/* SkHWInitDefSense */
@@ -606,7 +612,7 @@ int		Port)		/* Port Index (MAC_1 + n) */
 	/* Reset Port stati */
     pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_UNKNOWN;
     pPrt->PFlowCtrlStatus = (SK_U8)SK_FLOW_STAT_NONE;
-	pPrt->PLinkSpeedUsed = SK_LSPEED_STAT_INDETERMINATED;
+	pPrt->PLinkSpeedUsed = (SK_U8)SK_LSPEED_STAT_INDETERMINATED;
 
 	/* Re-init Phy especially when the AutoSense default is set now */
 	SkMacInitPhy(pAC, IoC, Port, SK_FALSE);
@@ -655,19 +661,19 @@ int		Port)	/* Port Index (MAC_1 + n) */
 		case SK_LSPEED_AUTO:
 			/* default is 1000 Mbps */
 		case SK_LSPEED_1000MBPS:
-			pPrt->PLinkSpeedUsed = SK_LSPEED_STAT_1000MBPS;
+			pPrt->PLinkSpeedUsed = (SK_U8)SK_LSPEED_STAT_1000MBPS;
 			break;
 		case SK_LSPEED_100MBPS:
-			pPrt->PLinkSpeedUsed = SK_LSPEED_STAT_100MBPS;
+			pPrt->PLinkSpeedUsed = (SK_U8)SK_LSPEED_STAT_100MBPS;
 			break;
 		case SK_LSPEED_10MBPS:
-			pPrt->PLinkSpeedUsed = SK_LSPEED_STAT_10MBPS;
+			pPrt->PLinkSpeedUsed = (SK_U8)SK_LSPEED_STAT_10MBPS;
 			break;
 		}
 
 		/* Set Link Mode Status */
 		if (pPrt->PLinkMode == SK_LMODE_FULL) {
-			pPrt->PLinkModeStatus = SK_LMODE_STAT_FULL;
+			pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_FULL;
 		}
 		else {
             pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_HALF;
@@ -1598,8 +1604,7 @@ SK_BOOL	AutoNeg)	/* Is Auto-negotiation 
 			 * (clear Page Received bit if set)
 			 */
 			SkXmPhyRead(pAC, IoC, Port, PHY_XMAC_AUNE_EXP, &ExtStat);
-			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
-				("AutoNeg done Port %d\n", Port));
+			
 			return(SK_HW_PS_LINK);
 		}
 		
@@ -1870,7 +1875,7 @@ SK_BOOL	AutoNeg)	/* Is Auto-negotiation 
 	SkMacAutoNegLipaPhy(pAC, IoC, Port, PhyStat);
 	
 	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
-		("AutoNeg: %d, PhyStat: 0x%04X\n", AutoNeg, PhyStat));
+		("CheckUp Port %d, PhyStat: 0x%04X\n", Port, PhyStat));
 
 	SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_1000T_STAT, &ResAb);
 
@@ -1897,8 +1902,11 @@ SK_BOOL	AutoNeg)	/* Is Auto-negotiation 
 
 	if (AutoNeg) {
 		if ((PhyStat & PHY_ST_AN_OVER) != 0) {
+			
 			SkHWLinkUp(pAC, IoC, Port);
+			
 			Done = SkMacAutoNegDone(pAC, IoC, Port);
+			
 			if (Done != SK_AND_OK) {
 #ifdef DEBUG
 				/* Get PHY parameters, for debugging only */
@@ -1924,9 +1932,6 @@ SK_BOOL	AutoNeg)	/* Is Auto-negotiation 
 						(void *)NULL);
 				}
 #endif /* DEBUG */
-				
-				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
-					("AutoNeg done Port %d\n", Port));
 				return(SK_HW_PS_LINK);
 			}
 		}
@@ -1989,9 +1994,22 @@ SK_BOOL	AutoNeg)	/* Is Auto-negotiation 
 	SK_U16		PhySpecStat;/* PHY Specific Status */
 	SK_U16		ResAb;		/* Master/Slave resolution */
 	SK_EVPARA	Para;
+#ifdef DEBUG
+	SK_U16		Word;		/* I/O helper */
+#endif /* DEBUG */
 
 	pPrt = &pAC->GIni.GP[Port];
 
+	if (pPrt->PHWLinkUp) {
+		return(SK_HW_PS_NONE);
+	}
+
+	/* Read PHY Status */
+	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_STAT, &PhyStat);
+
+	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
+		("CheckUp Port %d, PhyStat: 0x%04X\n", Port, PhyStat));
+
 	/* Read PHY Interrupt Status */
 	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_INT_STAT, &PhyIsrc);
 
@@ -2005,16 +2023,6 @@ SK_BOOL	AutoNeg)	/* Is Auto-negotiation 
 			("Link Speed Changed, PhyIsrc: 0x%04X\n", PhyIsrc));
 	}
 
-	if (pPrt->PHWLinkUp) {
-		return(SK_HW_PS_NONE);
-	}
-
-	/* Read PHY Status */
-	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_STAT, &PhyStat);
-
-	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
-		("AutoNeg: %d, PhyStat: 0x%04X\n", AutoNeg, PhyStat));
-
 	SkMacAutoNegLipaPhy(pAC, IoC, Port, PhyStat);
 	
 	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_1000T_STAT, &ResAb);
@@ -2034,7 +2042,20 @@ SK_BOOL	AutoNeg)	/* Is Auto-negotiation 
 	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_STAT, &PhySpecStat);
 	
 	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
-		("AutoNeg: %d, PhySpecStat: 0x%04X\n", AutoNeg, PhySpecStat));
+		("Phy1000BT: 0x%04X, PhySpecStat: 0x%04X\n", ResAb, PhySpecStat));
+
+#ifdef DEBUG
+	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_AUNE_EXP, &Word);
+
+	if ((PhyIsrc & PHY_M_IS_AN_PR) != 0 || (Word & PHY_ANE_RX_PG) != 0 ||
+		(PhySpecStat & PHY_M_PS_PAGE_REC) != 0)  {
+		/* Read PHY Next Page Link Partner */
+		SkGmPhyRead(pAC, IoC, Port, PHY_MARV_NEPG_LP, &Word);
+
+		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
+			("Page Received, NextPage: 0x%04X\n", Word));
+	}
+#endif /* DEBUG */
 
 	if ((PhySpecStat & PHY_M_PS_LINK_UP) == 0) {
 		return(SK_HW_PS_NONE);
@@ -2069,8 +2090,6 @@ SK_BOOL	AutoNeg)	/* Is Auto-negotiation 
 				return(SK_HW_PS_RESTART);
 			}
 			
-			SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
-				("AutoNeg done Port %d\n", Port));
 			return(SK_HW_PS_LINK);
 		}
 	}
@@ -2179,8 +2198,6 @@ SK_BOOL	AutoNeg)	/* Is Auto-negotiation 
 				 * extra link down/ups
 				 */
 				SkXmPhyRead(pAC, IoC, Port, PHY_LONE_INT_STAT, &ExtStat);
-				SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
-					("AutoNeg done Port %d\n", Port));
 				return(SK_HW_PS_LINK);
 			}
 		}
@@ -2278,8 +2295,14 @@ SK_EVPARA	Para)		/* Event specific Param
 
 	switch (Event) {
 	case SK_HWEV_WATIM:
-		/* Check whether port came up */
-		PortStat = SkGePortCheckUp(pAC, IoC, (int)Port);
+		if (pPrt->PState == SK_PRT_RESET) {
+		
+			PortStat = SK_HW_PS_NONE;
+		}
+		else {
+			/* Check whether port came up */
+			PortStat = SkGePortCheckUp(pAC, IoC, (int)Port);
+		}
 
 		switch (PortStat) {
 		case SK_HW_PS_RESTART:
diff -puN drivers/net/sk98lin/ski2c.c~linus drivers/net/sk98lin/ski2c.c
--- 25/drivers/net/sk98lin/ski2c.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/ski2c.c	2004-01-19 22:17:22.000000000 -0800
@@ -1,16 +1,17 @@
 /******************************************************************************
  *
  * Name:	ski2c.c
- * Project:	GEnesis, PCI Gigabit Ethernet Adapter
- * Version:	$Revision: 1.57 $
- * Date:	$Date: 2003/01/28 09:17:38 $
+ * Project:	Gigabit Ethernet Adapters, TWSI-Module
+ * Version:	$Revision: 1.59 $
+ * Date:	$Date: 2003/10/20 09:07:25 $
  * Purpose:	Functions to access Voltage and Temperature Sensor
  *
  ******************************************************************************/
 
 /******************************************************************************
  *
- *	(C)Copyright 1998-2003 SysKonnect GmbH.
+ *	(C)Copyright 1998-2002 SysKonnect.
+ *	(C)Copyright 2002-2003 Marvell.
  *
  *	This program is free software; you can redistribute it and/or modify
  *	it under the terms of the GNU General Public License as published by
@@ -26,6 +27,14 @@
  * History:
  *
  *	$Log: ski2c.c,v $
+ *	Revision 1.59  2003/10/20 09:07:25  rschmidt
+ *	Added cast SK_U32 in SkI2cWrite() to avoid compiler warning.
+ *	Editorial changes.
+ *	
+ *	Revision 1.58  2003/09/23 09:22:53  malthoff
+ *	Parameter I2cDevSize added in SkI2cRead and SkI2cWrite to
+ *	support larger devices on the TWSI bus.
+ *	
  *	Revision 1.57  2003/01/28 09:17:38  rschmidt
  *	Fixed handling for sensors on YUKON Fiber.
  *	Editorial changes.
@@ -224,15 +233,15 @@
  *	Created. Sources taken from ML Projekt.
  *	Sources have to be reworked for GE.
  *
- *
  ******************************************************************************/
 
-
 /*
  *	I2C Protocol
  */
+#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
 static const char SysKonnectFileId[] =
-	"$Id: ski2c.c,v 1.57 2003/01/28 09:17:38 rschmidt Exp $";
+	"@(#) $Id: ski2c.c,v 1.59 2003/10/20 09:07:25 rschmidt Exp $ (C) Marvell. ";
+#endif
 
 #include "h/skdrv1st.h"		/* Driver Specific Definitions */
 #include "h/lm80.h"
@@ -312,7 +321,7 @@ intro()
 {}
 #endif
 
-#ifdef	SK_DIAG
+#ifdef SK_DIAG
 /*
  * I2C Fast Mode timing values used by the LM80.
  * If new devices are added to the I2C bus the timing values have to be checked.
@@ -516,7 +525,6 @@ SK_IOC IoC)	/* I/O Context */
 {
 	/*
 	 * Received bit must be zero.
-	 *
 	 */
 	SkI2cSndBit(IoC, 0);
 }	/* SkI2cSndAck */
@@ -590,7 +598,7 @@ int		Rw)		/* Read / Write Flag */
 	return(SkI2cSndByte(IoC, (Addr<<1) | Rw));
 }	/* SkI2cSndDev */
 
-#endif	/* SK_DIAG */
+#endif /* SK_DIAG */
 
 /*----------------- I2C CTRL Register Functions ----------*/
 
@@ -620,7 +628,7 @@ int		Event)	/* complete event to wait fo
 			SK_I2C_STOP(IoC);
 #ifndef SK_DIAG
 			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_I2C_E002, SKERR_I2C_E002MSG);
-#endif	/* !SK_DIAG */
+#endif /* !SK_DIAG */
 			return(1);
 		}
 		
@@ -661,15 +669,19 @@ SK_IOC	IoC)	/* I/O Context */
 	}
 
 	StartTime = SkOsGetTime(pAC);
+	
 	do {
 		if (SkOsGetTime(pAC) - StartTime > SK_TICKS_PER_SEC / 8) {
+			
 			SK_I2C_STOP(IoC);
 #ifndef SK_DIAG
 			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_I2C_E016, SKERR_I2C_E016MSG);
-#endif	/* !SK_DIAG */
+#endif /* !SK_DIAG */
 			return;
 		}
+		
 		SK_IN32(IoC, B0_ISRC, &IrqSrc);
+
 	} while ((IrqSrc & IS_I2C_READY) == 0);
 
 	pSen->SenState = SK_SEN_IDLE;
@@ -687,18 +699,19 @@ SK_AC	*pAC,		/* Adapter Context */
 SK_IOC	IoC,		/* I/O Context */
 SK_U32	I2cData,	/* I2C Data to write */
 int		I2cDev,		/* I2C Device Address */
+int		I2cDevSize, /* I2C Device Size (e.g. I2C_025K_DEV or I2C_2K_DEV) */
 int		I2cReg,		/* I2C Device Register Address */
 int		I2cBurst)	/* I2C Burst Flag */
 {
 	SK_OUT32(IoC, B2_I2C_DATA, I2cData);
-	SK_I2C_CTL(IoC, I2C_WRITE, I2cDev, I2cReg, I2cBurst);
+	
+	SK_I2C_CTL(IoC, I2C_WRITE, I2cDev, I2cDevSize, I2cReg, I2cBurst);
 	
 	return(SkI2cWait(pAC, IoC, I2C_WRITE));
 }	/* SkI2cWrite*/
 
 
 #ifdef	SK_DIAG
-
 /*
  * reads a single byte or 4 bytes from the I2C device
  *
@@ -708,23 +721,24 @@ SK_U32 SkI2cRead(
 SK_AC	*pAC,		/* Adapter Context */
 SK_IOC	IoC,		/* I/O Context */
 int		I2cDev,		/* I2C Device Address */
+int		I2cDevSize, /* I2C Device Size (e.g. I2C_025K_DEV or I2C_2K_DEV) */
 int		I2cReg,		/* I2C Device Register Address */
 int		I2cBurst)	/* I2C Burst Flag */
 {
 	SK_U32	Data;
 
 	SK_OUT32(IoC, B2_I2C_DATA, 0);
-	SK_I2C_CTL(IoC, I2C_READ, I2cDev, I2cReg, I2cBurst);
+	SK_I2C_CTL(IoC, I2C_READ, I2cDev, I2cDevSize, I2cReg, I2cBurst);
 	
 	if (SkI2cWait(pAC, IoC, I2C_READ) != 0) {
 		w_print("%s\n", SKERR_I2C_E002MSG);
 	}
 	
 	SK_IN32(IoC, B2_I2C_DATA, &Data);
+	
 	return(Data);
 }	/* SkI2cRead */
-
-#endif	/* SK_DIAG */
+#endif /* SK_DIAG */
 
 
 /*
@@ -745,9 +759,10 @@ SK_SENSOR	*pSen)	/* Sensor to be read */
     if (pSen->SenRead != NULL) {
         return((*pSen->SenRead)(pAC, IoC, pSen));
     }
-    else
+	else {
         return(0); /* no success */
-}	/* SkI2cReadSensor*/
+	}
+}	/* SkI2cReadSensor */
 
 /*
  * Do the Init state 0 initialization
@@ -761,12 +776,12 @@ SK_AC	*pAC)	/* Adapter Context */
 	pAC->I2c.CurrSens = 0;
 	
 	/* Begin with timeout control for state machine */
-	pAC->I2c.TimerMode = SK_TIMER_WATCH_STATEMACHINE;
+	pAC->I2c.TimerMode = SK_TIMER_WATCH_SM;
 	
 	/* Set sensor number to zero */
 	pAC->I2c.MaxSens = 0;
 
-#ifndef	SK_DIAG
+#ifndef SK_DIAG
 	/* Initialize Number of Dummy Reads */
 	pAC->I2c.DummyReads = SK_MAX_SENSORS;
 #endif
@@ -840,19 +855,20 @@ SK_IOC	IoC)	/* I/O Context */
     }
 
 	/* Check for 64 Bit Yukon without sensors */
-	if (SkI2cWrite(pAC, IoC, 0, LM80_ADDR, LM80_CFG, 0) != 0) {
+	if (SkI2cWrite(pAC, IoC, 0, LM80_ADDR, I2C_025K_DEV, LM80_CFG, 0) != 0) {
         return(0);
     }
 
-	(void)SkI2cWrite(pAC, IoC, 0xff, LM80_ADDR, LM80_IMSK_1, 0);
+	(void)SkI2cWrite(pAC, IoC, 0xffUL, LM80_ADDR, I2C_025K_DEV, LM80_IMSK_1, 0);
 	
-	(void)SkI2cWrite(pAC, IoC, 0xff, LM80_ADDR, LM80_IMSK_2, 0);
+	(void)SkI2cWrite(pAC, IoC, 0xffUL, LM80_ADDR, I2C_025K_DEV, LM80_IMSK_2, 0);
 	
-	(void)SkI2cWrite(pAC, IoC, 0, LM80_ADDR, LM80_FAN_CTRL, 0);
+	(void)SkI2cWrite(pAC, IoC, 0, LM80_ADDR, I2C_025K_DEV, LM80_FAN_CTRL, 0);
 	
-	(void)SkI2cWrite(pAC, IoC, 0, LM80_ADDR, LM80_TEMP_CTRL, 0);
+	(void)SkI2cWrite(pAC, IoC, 0, LM80_ADDR, I2C_025K_DEV, LM80_TEMP_CTRL, 0);
 	
-	(void)SkI2cWrite(pAC, IoC, LM80_CFG_START, LM80_ADDR, LM80_CFG, 0);
+	(void)SkI2cWrite(pAC, IoC, (SK_U32)LM80_CFG_START, LM80_ADDR, I2C_025K_DEV,
+		LM80_CFG, 0);
 	
 	/*
 	 * MaxSens has to be updated here, because PhyType is not
@@ -957,7 +973,7 @@ SK_IOC	IoC)	/* I/O Context */
 				pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PHY_2V5_LOW_ERR;
 			}
 			else {
-				pAC->I2c.SenTable[i].SenDesc = "Voltage ASIC-Co 1V5";
+				pAC->I2c.SenTable[i].SenDesc = "Voltage Core 1V5";
 				pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_CORE_1V5_HIGH_ERR;
 				pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_CORE_1V5_HIGH_WARN;
 				pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_CORE_1V5_LOW_WARN;
@@ -1015,9 +1031,9 @@ SK_IOC	IoC)	/* I/O Context */
 		pAC->I2c.SenTable[i].SenDev = LM80_ADDR;
 	}
 
-#ifndef	SK_DIAG
+#ifndef SK_DIAG
 	pAC->I2c.DummyReads = pAC->I2c.MaxSens;
-#endif	/* !SK_DIAG */
+#endif /* !SK_DIAG */
 	
 	/* Clear I2C IRQ */
 	SK_OUT32(IoC, B2_I2C_IRQ, I2C_CLR_IRQ);
@@ -1208,15 +1224,13 @@ SK_SENSOR	*pSen)
 			pSen->SenLastErrLogTS = CurrTime;
 
 			if (pSen->SenType == SK_SEN_TEMP) {
-				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E011,
-					SKERR_I2C_E011MSG);
-			} else if (pSen->SenType == SK_SEN_VOLT) {
-				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E012,
-					SKERR_I2C_E012MSG);
-			} else
-			{
-				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E015,
-					SKERR_I2C_E015MSG);
+				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E011, SKERR_I2C_E011MSG);
+			}
+			else if (pSen->SenType == SK_SEN_VOLT) {
+				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E012, SKERR_I2C_E012MSG);
+			}
+			else {
+				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E015, SKERR_I2C_E015MSG);
 			}
 		}
 	}
@@ -1235,8 +1249,7 @@ SK_SENSOR	*pSen)
 			/* This state is the former one */
 
 			/* So check first whether we have to send a trap */
-			if (pSen->SenLastWarnTrapTS + SK_SEN_WARN_TR_HOLD >
-			    CurrTime) {
+			if (pSen->SenLastWarnTrapTS + SK_SEN_WARN_TR_HOLD > CurrTime) {
 				/*
 				 * Do NOT send the Trap. The hold back time
 				 * has to run out first.
@@ -1245,8 +1258,7 @@ SK_SENSOR	*pSen)
 			}
 
 			/* Check now whether we have to log an Error */
-			if (pSen->SenLastWarnLogTS + SK_SEN_WARN_LOG_HOLD >
-			    CurrTime) {
+			if (pSen->SenLastWarnLogTS + SK_SEN_WARN_LOG_HOLD > CurrTime) {
 				/*
 				 * Do NOT log the error. The hold back time
 				 * has to run out first.
@@ -1277,15 +1289,13 @@ SK_SENSOR	*pSen)
 			pSen->SenLastWarnLogTS = CurrTime;
 
 			if (pSen->SenType == SK_SEN_TEMP) {
-				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E009,
-					SKERR_I2C_E009MSG);
-			} else if (pSen->SenType == SK_SEN_VOLT) {
-				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E010,
-					SKERR_I2C_E010MSG);
-			} else
-			{
-				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E014,
-					SKERR_I2C_E014MSG);
+				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E009, SKERR_I2C_E009MSG);
+			}
+			else if (pSen->SenType == SK_SEN_VOLT) {
+				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E010, SKERR_I2C_E010MSG);
+			}
+			else {
+				SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E014, SKERR_I2C_E014MSG);
 			}
 		}
 	}
@@ -1317,7 +1327,7 @@ SK_SENSOR	*pSen)
 		}
 	}
 	
-#if 0
+#ifdef TEST_ONLY
     /* Dynamic thresholds also for VAUX of LM80 sensor */
 	if (pSen->SenInit == SK_SEN_DYN_INIT_VAUX) {
 
@@ -1359,7 +1369,7 @@ SK_SENSOR	*pSen)
 	if (pSen->SenInit != SK_SEN_DYN_INIT_NONE) {
 		SK_ERR_LOG(pAC, SK_ERRCL_HW, SKERR_I2C_E013, SKERR_I2C_E013MSG);
 	}
-}	/* SkI2cCheckSensor*/
+}	/* SkI2cCheckSensor */
 
 
 /*
@@ -1390,7 +1400,7 @@ SK_EVPARA	Para)	/* Event specific Parame
 
 		if (ReadComplete) {
 			/* Check sensor against defined thresholds */
-			SkI2cCheckSensor (pAC, pSen);
+			SkI2cCheckSensor(pAC, pSen);
 
 			/* Increment Current sensor and set appropriate Timeout */
 			pAC->I2c.CurrSens++;
@@ -1414,7 +1424,7 @@ SK_EVPARA	Para)	/* Event specific Parame
 			/* Start Timer */
 			ParaLocal.Para64 = (SK_U64)0;
 
-			pAC->I2c.TimerMode = SK_TIMER_WATCH_STATEMACHINE;
+			pAC->I2c.TimerMode = SK_TIMER_WATCH_SM;
 
             SkTimerStart(pAC, IoC, &pAC->I2c.SenTimer, SK_I2C_TIM_WATCH,
 				SKGE_I2C, SK_I2CEV_TIM, ParaLocal);
@@ -1431,7 +1441,7 @@ SK_EVPARA	Para)	/* Event specific Parame
 
 			if (ReadComplete) {
 				/* Check sensor against defined thresholds */
-				SkI2cCheckSensor (pAC, pSen);
+				SkI2cCheckSensor(pAC, pSen);
 
 				/* Increment Current sensor and set appropriate Timeout */
 				pAC->I2c.CurrSens++;
@@ -1496,4 +1506,4 @@ SK_EVPARA	Para)	/* Event specific Parame
 	return(0);
 }	/* SkI2cEvent*/
 
-#endif	/* !SK_DIAG */
+#endif /* !SK_DIAG */
diff -puN drivers/net/sk98lin/sklm80.c~linus drivers/net/sk98lin/sklm80.c
--- 25/drivers/net/sk98lin/sklm80.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/sklm80.c	2004-01-19 22:17:22.000000000 -0800
@@ -1,16 +1,17 @@
 /******************************************************************************
  *
  * Name:	sklm80.c
- * Project:	GEnesis, PCI Gigabit Ethernet Adapter
- * Version:	$Revision: 1.20 $
- * Date:	$Date: 2002/08/13 09:16:27 $
- * Purpose:	Funktions to access Voltage and Temperature Sensor (LM80)
+ * Project:	Gigabit Ethernet Adapters, TWSI-Module
+ * Version:	$Revision: 1.22 $
+ * Date:	$Date: 2003/10/20 09:08:21 $
+ * Purpose:	Functions to access Voltage and Temperature Sensor (LM80)
  *
  ******************************************************************************/
 
 /******************************************************************************
  *
- *	(C)Copyright 1998-2002 SysKonnect GmbH.
+ *	(C)Copyright 1998-2002 SysKonnect.
+ *	(C)Copyright 2002-2003 Marvell.
  *
  *	This program is free software; you can redistribute it and/or modify
  *	it under the terms of the GNU General Public License as published by
@@ -26,15 +27,21 @@
  * History:
  *
  *	$Log: sklm80.c,v $
+ *	Revision 1.22  2003/10/20 09:08:21  rschmidt
+ *	Editorial changes.
+ *	
+ *	Revision 1.21  2003/09/23 09:29:04  malthoff
+ *	Parameter Dev_Size added to macro SK_I2C_CTL.
+ *	
  *	Revision 1.20  2002/08/13 09:16:27  rschmidt
  *	Changed return value for SkLm80ReadSensor() back to 'int'
- *	Editorial changes
+ *	Editorial changes.
  *	
  *	Revision 1.19  2002/08/06 09:43:31  jschmalz
- *	Extensions and changes for Yukon
+ *	Extensions and changes for Yukon.
  *	
  *	Revision 1.18  2002/08/02 12:26:57  rschmidt
- *	Editorial changes
+ *	Editorial changes.
  *	
  *	Revision 1.17  1999/11/22 13:35:51  cgoos
  *	Changed license header to GPL.
@@ -93,16 +100,15 @@
  *	Revision 1.1  1998/07/17 09:57:12  gklug
  *	initial version
  *
- *
- *
  ******************************************************************************/
 
-
 /*
 	LM80 functions
 */
+#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
 static const char SysKonnectFileId[] =
-	"$Id: sklm80.c,v 1.20 2002/08/13 09:16:27 rschmidt Exp $" ;
+	"@(#) $Id: sklm80.c,v 1.22 2003/10/20 09:08:21 rschmidt Exp $ (C) Marvell. ";
+#endif
 
 #include "h/skdrv1st.h"		/* Driver Specific Definitions */
 #include "h/lm80.h"
@@ -202,7 +208,7 @@ SK_SENSOR	*pSen)	/* Sensor to be read */
 	switch (pSen->SenState) {
 	case SK_SEN_IDLE:
 		/* Send address to ADDR register */
-		SK_I2C_CTL(IoC, I2C_READ, pSen->SenDev, pSen->SenReg, 0);
+		SK_I2C_CTL(IoC, I2C_READ, pSen->SenDev, I2C_025K_DEV, pSen->SenReg, 0);
 
 		pSen->SenState = SK_SEN_VALUE ;
 		BREAK_OR_WAIT(pAC, IoC, I2C_READ);
@@ -250,7 +256,7 @@ SK_SENSOR	*pSen)	/* Sensor to be read */
 			(pSen->SenValue % SK_LM80_TEMP_LSB);
 
 		/* Send address to ADDR register */
-		SK_I2C_CTL(IoC, I2C_READ, pSen->SenDev, LM80_TEMP_CTRL, 0);
+		SK_I2C_CTL(IoC, I2C_READ, pSen->SenDev, I2C_025K_DEV, LM80_TEMP_CTRL, 0);
 
 		pSen->SenState = SK_SEN_VALEXT ;
 		BREAK_OR_WAIT(pAC, IoC, I2C_READ);
@@ -284,3 +290,4 @@ SK_SENSOR	*pSen)	/* Sensor to be read */
 	/* Not completed */
 	return(0);
 }
+
diff -puN drivers/net/sk98lin/skproc.c~linus drivers/net/sk98lin/skproc.c
--- 25/drivers/net/sk98lin/skproc.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/skproc.c	2004-01-19 22:17:22.000000000 -0800
@@ -1,16 +1,17 @@
 /******************************************************************************
  *
- * Name:    skproc.c
+ * Name:	skproc.c
  * Project:	GEnesis, PCI Gigabit Ethernet Adapter
- * Version:	$Revision: 1.2 $
- * Date:    $Date: 2003/08/12 16:45:29 $
+ * Version:	$Revision: 1.11 $
+ * Date:	$Date: 2003/12/11 16:03:57 $
  * Purpose:	Funktions to display statictic data
  *
  ******************************************************************************/
  
 /******************************************************************************
  *
- *	(C)Copyright 1998-2003 SysKonnect GmbH.
+ *	(C)Copyright 1998-2002 SysKonnect GmbH.
+ *	(C)Copyright 2002-2003 Marvell.
  *
  *	This program is free software; you can redistribute it and/or modify
  *	it under the terms of the GNU General Public License as published by
@@ -28,6 +29,33 @@
  * History:
  *
  *	$Log: skproc.c,v $
+ *	Revision 1.11  2003/12/11 16:03:57  mlindner
+ *	Fix: Create backup from pnmi data structure
+ *	
+ *	Revision 1.10  2003/11/19 16:25:36  mlindner
+ *	Fix: Print output as 64-bit digit
+ *	
+ *	Revision 1.9  2003/11/17 13:29:05  mlindner
+ *	Fix: Editorial changes
+ *	
+ *	Revision 1.8  2003/11/13 14:18:48  rroesler
+ *	Fix: added latest changes regarding the use of the proc system
+ *	
+ *	Revision 1.7  2003/11/10 09:35:07  rroesler
+ *	Fix: diag backup restore of PNMI structure
+ *	
+ *	Revision 1.6  2003/11/07 17:31:39  rroesler
+ *	Add: security counter for the proc file system
+ *	
+ *	Revision 1.5  2003/10/07 08:17:08  mlindner
+ *	Fix: Copyright changes
+ *	
+ *	Revision 1.4  2003/09/01 15:29:24  mlindner
+ *	Fix: Editorial changes
+ *	
+ *	Revision 1.3  2003/08/29 12:30:58  mlindner
+ *	Add: Version entry in the proc file system
+ *	
  *	Revision 1.2  2003/08/12 16:45:29  mlindner
  *	Add: Removed SkNumber and SkDoDiv
  *	Add: Counter output as (unsigned long long)
@@ -94,223 +122,350 @@
 
 #include "h/skdrv1st.h"
 #include "h/skdrv2nd.h"
+#include "h/skversion.h"
 
-#ifdef CONFIG_PROC_FS
+extern struct SK_NET_DEVICE *SkGeRootDev;
+static int sk_proc_print(void *writePtr, char *format, ...);
+static void sk_gen_browse(void *buffer);
+int len;
 
-extern struct net_device	*SkGeRootDev;
+static int sk_seq_show(struct seq_file *seq, void *v);
+static int sk_proc_open(struct inode *inode, struct file *file);
+struct file_operations sk_proc_fops = {
+	.owner		= THIS_MODULE,
+	.open		= sk_proc_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+struct net_device *currDev = NULL;
 
-static int sk_seq_show(struct seq_file *seq, void *v)
+/*****************************************************************************
+ *
+ * 	sk_gen_browse -generic  print "summaries" entry 
+ *
+ * Description:
+ *  This function fills the proc entry with statistic data about 
+ *  the ethernet device.
+ *  
+ * Returns: -
+ *	
+ */
+static void sk_gen_browse(void *buffer)
 {
-	struct net_device *dev = seq->private;
-	DEV_NET		*pNet = dev->priv;
-	SK_AC		*pAC = pNet->pAC;
-	SK_PNMI_STRUCT_DATA *pPnmiStruct = &pAC->PnmiStruct;
-	SK_PNMI_STAT	*pPnmiStat = &pPnmiStruct->Stat[0];
-	int unit = !(pAC->dev[0] == dev);
-	int i;
-	char sens_msg[50];
-
-	seq_printf(seq,
-		   "\nDetailed statistic for device %s\n",
-		   dev->name);
-	seq_printf(seq,
-		   "=======================================\n");
-	
-	/* Board statistics */
-	seq_printf(seq, 
-		   "\nBoard statistics\n\n");
-	seq_printf(seq,
-		   "Active Port                    %c\n",
-		   'A' + pAC->Rlmt.Net[unit].Port[pAC->Rlmt.
-						 Net[unit].PrefPort]->PortNumber);
-	seq_printf(seq,
-		   "Preferred Port                 %c\n",
-		   'A' + pAC->Rlmt.Net[unit].Port[pAC->Rlmt.
-						 Net[unit].PrefPort]->PortNumber);
-
-	seq_printf(seq,
-		   "Bus speed (MHz)                %d\n",
-		   pPnmiStruct->BusSpeed);
-
-	seq_printf(seq,
-		   "Bus width (Bit)                %d\n",
-		   pPnmiStruct->BusWidth);
-	seq_printf(seq,
-		   "Hardware revision              v%d.%d\n",
-		   (pAC->GIni.GIPciHwRev >> 4) & 0x0F,
-		   pAC->GIni.GIPciHwRev & 0x0F);
-
-	/* Print sensor informations */
-	for (i=0; i < pAC->I2c.MaxSens; i ++) {
-		/* Check type */
-		switch (pAC->I2c.SenTable[i].SenType) {
-		case 1:
-			strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
-			strcat(sens_msg, " (C)");
-			seq_printf(seq,
-				   "%-25s      %d.%02d\n",
-				   sens_msg,
-				   pAC->I2c.SenTable[i].SenValue / 10,
-				   pAC->I2c.SenTable[i].SenValue % 10);
-
-			strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
-			strcat(sens_msg, " (F)");
-			seq_printf(seq,
-				   "%-25s      %d.%02d\n",
-				   sens_msg,
-				   ((((pAC->I2c.SenTable[i].SenValue)
-				      *10)*9)/5 + 3200)/100,
-				   ((((pAC->I2c.SenTable[i].SenValue)
-				      *10)*9)/5 + 3200) % 10);
-			break;
-		case 2:
-			strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
-			strcat(sens_msg, " (V)");
-			seq_printf(seq,
-				   "%-25s      %d.%03d\n",
-				   sens_msg,
-				   pAC->I2c.SenTable[i].SenValue / 1000,
-				   pAC->I2c.SenTable[i].SenValue % 1000);
-			break;
-		case 3:
-			strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
-			strcat(sens_msg, " (rpm)");
-			seq_printf(seq,
-				   "%-25s      %d\n",
-				   sens_msg,
-				   pAC->I2c.SenTable[i].SenValue);
-			break;
-		default:
-			break;
+	struct SK_NET_DEVICE	*SkgeProcDev = SkGeRootDev;
+	struct SK_NET_DEVICE	*next;
+	SK_PNMI_STRUCT_DATA 	*pPnmiStruct;
+	SK_PNMI_STAT		*pPnmiStat;
+	unsigned long		Flags;	
+	unsigned int		Size;
+	DEV_NET			*pNet;
+	SK_AC			*pAC;
+	char			sens_msg[50];
+	int			MaxSecurityCount = 0;
+	int 			t;
+	int 			i;
+
+	while (SkgeProcDev) {
+		MaxSecurityCount++;
+		if (MaxSecurityCount > 100) {
+			printk("Max limit for sk_proc_read security counter!\n");
+			return;
 		}
-	}
+		pNet = (DEV_NET*) SkgeProcDev->priv;
+		pAC = pNet->pAC;
+		next = pAC->Next;
+		pPnmiStruct = &pAC->PnmiStruct;
+		/* NetIndex in GetStruct is now required, zero is only dummy */
+
+		for (t=pAC->GIni.GIMacsFound; t > 0; t--) {
+			if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 1)
+				t--;
+
+			spin_lock_irqsave(&pAC->SlowPathLock, Flags);
+			Size = SK_PNMI_STRUCT_SIZE;
+#ifdef SK_DIAG_SUPPORT
+			if (pAC->BoardLevel == SK_INIT_DATA) {
+				SK_MEMCPY(&(pAC->PnmiStruct), &(pAC->PnmiBackup), sizeof(SK_PNMI_STRUCT_DATA));
+				if (pAC->DiagModeActive == DIAG_NOTACTIVE) {
+					pAC->Pnmi.DiagAttached = SK_DIAG_IDLE;
+				}
+			} else {
+				SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, t-1);
+			}
+#else
+			SkPnmiGetStruct(pAC, pAC->IoBase, 
+				pPnmiStruct, &Size, t-1);
+#endif
+			spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
+	
+			if (strcmp(pAC->dev[t-1]->name, currDev->name) == 0) {
+				pPnmiStat = &pPnmiStruct->Stat[0];
+				len = sk_proc_print(buffer, 
+					"\nDetailed statistic for device %s\n",
+					pAC->dev[t-1]->name);
+				len += sk_proc_print(buffer,
+					"=======================================\n");
+	
+				/* Board statistics */
+				len += sk_proc_print(buffer, 
+					"\nBoard statistics\n\n");
+				len += sk_proc_print(buffer,
+					"Active Port                    %c\n",
+					'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
+					Net[t-1].PrefPort]->PortNumber);
+				len += sk_proc_print(buffer,
+					"Preferred Port                 %c\n",
+					'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
+					Net[t-1].PrefPort]->PortNumber);
+
+				len += sk_proc_print(buffer,
+					"Bus speed (MHz)                %d\n",
+					pPnmiStruct->BusSpeed);
+
+				len += sk_proc_print(buffer,
+					"Bus width (Bit)                %d\n",
+					pPnmiStruct->BusWidth);
+				len += sk_proc_print(buffer,
+					"Driver version                 %s\n",
+					VER_STRING);
+				len += sk_proc_print(buffer,
+					"Hardware revision              v%d.%d\n",
+					(pAC->GIni.GIPciHwRev >> 4) & 0x0F,
+					pAC->GIni.GIPciHwRev & 0x0F);
+
+				/* Print sensor informations */
+				for (i=0; i < pAC->I2c.MaxSens; i ++) {
+					/* Check type */
+					switch (pAC->I2c.SenTable[i].SenType) {
+					case 1:
+						strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
+						strcat(sens_msg, " (C)");
+						len += sk_proc_print(buffer,
+							"%-25s      %d.%02d\n",
+							sens_msg,
+							pAC->I2c.SenTable[i].SenValue / 10,
+							pAC->I2c.SenTable[i].SenValue % 10);
+
+						strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
+						strcat(sens_msg, " (F)");
+						len += sk_proc_print(buffer,
+							"%-25s      %d.%02d\n",
+							sens_msg,
+							((((pAC->I2c.SenTable[i].SenValue)
+							*10)*9)/5 + 3200)/100,
+							((((pAC->I2c.SenTable[i].SenValue)
+							*10)*9)/5 + 3200) % 10);
+						break;
+					case 2:
+						strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
+						strcat(sens_msg, " (V)");
+						len += sk_proc_print(buffer,
+							"%-25s      %d.%03d\n",
+							sens_msg,
+							pAC->I2c.SenTable[i].SenValue / 1000,
+							pAC->I2c.SenTable[i].SenValue % 1000);
+						break;
+					case 3:
+						strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
+						strcat(sens_msg, " (rpm)");
+						len += sk_proc_print(buffer,
+							"%-25s      %d\n",
+							sens_msg,
+							pAC->I2c.SenTable[i].SenValue);
+						break;
+					default:
+						break;
+					}
+				}
 				
-	/*Receive statistics */
-	seq_printf(seq, 
-		   "\nReceive statistics\n\n");
-
-	seq_printf(seq,
-		   "Received bytes                 %Ld\n",
-		   (unsigned long long) pPnmiStat->StatRxOctetsOkCts);
-	seq_printf(seq,
-		   "Received packets               %Ld\n",
-		   (unsigned long long) pPnmiStat->StatRxOkCts);
+				/*Receive statistics */
+				len += sk_proc_print(buffer, 
+				"\nReceive statistics\n\n");
+
+				len += sk_proc_print(buffer,
+					"Received bytes                 %Lu\n",
+					(unsigned long long) pPnmiStat->StatRxOctetsOkCts);
+				len += sk_proc_print(buffer,
+					"Received packets               %Lu\n",
+					(unsigned long long) pPnmiStat->StatRxOkCts);
 #if 0
-	if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC && 
-	    pAC->HWRevision < 12) {
-		pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts - 
-			pPnmiStat->StatRxShortsCts;
-		pPnmiStat->StatRxShortsCts = 0;
-	}
+				if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC && 
+					pAC->HWRevision < 12) {
+					pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts - 
+						pPnmiStat->StatRxShortsCts;
+					pPnmiStat->StatRxShortsCts = 0;
+				}
 #endif
-	if (pNet->Mtu > 1500) 
-		pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
-			pPnmiStat->StatRxTooLongCts;
-
-	seq_printf(seq,
-		   "Receive errors                 %Ld\n",
-		   (unsigned long long) pPnmiStruct->InErrorsCts);
-	seq_printf(seq,
-		   "Receive dropped                %Ld\n",
-		   (unsigned long long) pPnmiStruct->RxNoBufCts);
-	seq_printf(seq,
-		   "Received multicast             %Ld\n",
-		   (unsigned long long) pPnmiStat->StatRxMulticastOkCts);
-	seq_printf(seq,
-		   "Receive error types\n");
-	seq_printf(seq,
-		   "   length                      %Ld\n",
-		   (unsigned long long) pPnmiStat->StatRxRuntCts);
-	seq_printf(seq,
-		   "   buffer overflow             %Ld\n",
-		   (unsigned long long) pPnmiStat->StatRxFifoOverflowCts);
-	seq_printf(seq,
-		   "   bad crc                     %Ld\n",
-		   (unsigned long long) pPnmiStat->StatRxFcsCts);
-	seq_printf(seq,
-		   "   framing                     %Ld\n",
-		   (unsigned long long) pPnmiStat->StatRxFramingCts);
-	seq_printf(seq,
-		   "   missed frames               %Ld\n",
-		   (unsigned long long) pPnmiStat->StatRxMissedCts);
-
-	if (pNet->Mtu > 1500)
-		pPnmiStat->StatRxTooLongCts = 0;
-
-	seq_printf(seq,
-		   "   too long                    %Ld\n",
-		   (unsigned long long) pPnmiStat->StatRxTooLongCts);					
-	seq_printf(seq,
-		   "   carrier extension           %Ld\n",
-		   (unsigned long long) pPnmiStat->StatRxCextCts);				
-	seq_printf(seq,
-		   "   too short                   %Ld\n",
-		   (unsigned long long) pPnmiStat->StatRxShortsCts);				
-	seq_printf(seq,
-		   "   symbol                      %Ld\n",
-		   (unsigned long long) pPnmiStat->StatRxSymbolCts);				
-	seq_printf(seq,
-		   "   LLC MAC size                %Ld\n",
-		   (unsigned long long) pPnmiStat->StatRxIRLengthCts);				
-	seq_printf(seq,
-		   "   carrier event               %Ld\n",
-		   (unsigned long long) pPnmiStat->StatRxCarrierCts);				
-	seq_printf(seq,
-		   "   jabber                      %Ld\n",
-		   (unsigned long long) pPnmiStat->StatRxJabberCts);				
-
-
-	/*Transmit statistics */
-	seq_printf(seq, 
-		   "\nTransmit statistics\n\n");
+				if (pNet->Mtu > 1500) 
+					pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
+						pPnmiStat->StatRxTooLongCts;
+
+				len += sk_proc_print(buffer,
+					"Receive errors                 %Lu\n",
+					(unsigned long long) pPnmiStruct->InErrorsCts);
+				len += sk_proc_print(buffer,
+					"Receive dropped                %Lu\n",
+					(unsigned long long) pPnmiStruct->RxNoBufCts);
+				len += sk_proc_print(buffer,
+					"Received multicast             %Lu\n",
+					(unsigned long long) pPnmiStat->StatRxMulticastOkCts);
+				len += sk_proc_print(buffer,
+					"Receive error types\n");
+				len += sk_proc_print(buffer,
+					"   length                      %Lu\n",
+					(unsigned long long) pPnmiStat->StatRxRuntCts);
+				len += sk_proc_print(buffer,
+					"   buffer overflow             %Lu\n",
+					(unsigned long long) pPnmiStat->StatRxFifoOverflowCts);
+				len += sk_proc_print(buffer,
+					"   bad crc                     %Lu\n",
+					(unsigned long long) pPnmiStat->StatRxFcsCts);
+				len += sk_proc_print(buffer,
+					"   framing                     %Lu\n",
+					(unsigned long long) pPnmiStat->StatRxFramingCts);
+				len += sk_proc_print(buffer,
+					"   missed frames               %Lu\n",
+					(unsigned long long) pPnmiStat->StatRxMissedCts);
+
+				if (pNet->Mtu > 1500)
+					pPnmiStat->StatRxTooLongCts = 0;
+
+				len += sk_proc_print(buffer,
+					"   too long                    %Lu\n",
+					(unsigned long long) pPnmiStat->StatRxTooLongCts);					
+				len += sk_proc_print(buffer,
+					"   carrier extension           %Lu\n",
+					(unsigned long long) pPnmiStat->StatRxCextCts);				
+				len += sk_proc_print(buffer,
+					"   too short                   %Lu\n",
+					(unsigned long long) pPnmiStat->StatRxShortsCts);				
+				len += sk_proc_print(buffer,
+					"   symbol                      %Lu\n",
+					(unsigned long long) pPnmiStat->StatRxSymbolCts);				
+				len += sk_proc_print(buffer,
+					"   LLC MAC size                %Lu\n",
+					(unsigned long long) pPnmiStat->StatRxIRLengthCts);				
+				len += sk_proc_print(buffer,
+					"   carrier event               %Lu\n",
+					(unsigned long long) pPnmiStat->StatRxCarrierCts);				
+				len += sk_proc_print(buffer,
+					"   jabber                      %Lu\n",
+					(unsigned long long) pPnmiStat->StatRxJabberCts);				
+
+
+				/*Transmit statistics */
+				len += sk_proc_print(buffer, 
+				"\nTransmit statistics\n\n");
 				
-	seq_printf(seq,
-		   "Transmited bytes               %Ld\n",
-		   (unsigned long long) pPnmiStat->StatTxOctetsOkCts);
-	seq_printf(seq,
-		   "Transmited packets             %Ld\n",
-		   (unsigned long long) pPnmiStat->StatTxOkCts);
-	seq_printf(seq,
-		   "Transmit errors                %Ld\n",
-		   (unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
-	seq_printf(seq,
-		   "Transmit dropped               %Ld\n",
-		   (unsigned long long) pPnmiStruct->TxNoBufCts);
-	seq_printf(seq,
-		   "Transmit collisions            %Ld\n",
-		   (unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
-	seq_printf(seq,
-		   "Transmit error types\n");
-	seq_printf(seq,
-		   "   excessive collision         %ld\n",
-		   pAC->stats.tx_aborted_errors);
-	seq_printf(seq,
-		   "   carrier                     %Ld\n",
-		   (unsigned long long) pPnmiStat->StatTxCarrierCts);
-	seq_printf(seq,
-		   "   fifo underrun               %Ld\n",
-		   (unsigned long long) pPnmiStat->StatTxFifoUnderrunCts);
-	seq_printf(seq,
-		   "   heartbeat                   %Ld\n",
-		   (unsigned long long) pPnmiStat->StatTxCarrierCts);
-	seq_printf(seq,
-		   "   window                      %ld\n",
-		   pAC->stats.tx_window_errors);
+				len += sk_proc_print(buffer,
+					"Transmited bytes               %Lu\n",
+					(unsigned long long) pPnmiStat->StatTxOctetsOkCts);
+				len += sk_proc_print(buffer,
+					"Transmited packets             %Lu\n",
+					(unsigned long long) pPnmiStat->StatTxOkCts);
+				len += sk_proc_print(buffer,
+					"Transmit errors                %Lu\n",
+					(unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
+				len += sk_proc_print(buffer,
+					"Transmit dropped               %Lu\n",
+					(unsigned long long) pPnmiStruct->TxNoBufCts);
+				len += sk_proc_print(buffer,
+					"Transmit collisions            %Lu\n",
+					(unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
+				len += sk_proc_print(buffer,
+					"Transmit error types\n");
+				len += sk_proc_print(buffer,
+					"   excessive collision         %ld\n",
+					pAC->stats.tx_aborted_errors);
+				len += sk_proc_print(buffer,
+					"   carrier                     %Lu\n",
+					(unsigned long long) pPnmiStat->StatTxCarrierCts);
+				len += sk_proc_print(buffer,
+					"   fifo underrun               %Lu\n",
+					(unsigned long long) pPnmiStat->StatTxFifoUnderrunCts);
+				len += sk_proc_print(buffer,
+					"   heartbeat                   %Lu\n",
+					(unsigned long long) pPnmiStat->StatTxCarrierCts);
+				len += sk_proc_print(buffer,
+					"   window                      %ld\n",
+					pAC->stats.tx_window_errors);
 				
-	return 0;
+			} /* if (strcmp(pACname, currDeviceName) == 0) */
+		}
+		SkgeProcDev = next;
+	}
 }
 
+/*****************************************************************************
+ *
+ *      sk_proc_print -generic line print  
+ *
+ * Description:
+ *  This function fills the proc entry with statistic data about 
+ *  the ethernet device.
+ *  
+ * Returns: number of bytes written
+ *      
+ */ 
+static int sk_proc_print(void *writePtr, char *format, ...)
+{   
+#define MAX_LEN_SINGLE_LINE 256
+	char     str[MAX_LEN_SINGLE_LINE];
+	va_list  a_start;
+	int      lenght = 0;
+
+	struct seq_file *seq = (struct seq_file *) writePtr;
+
+	SK_MEMSET(str, 0, MAX_LEN_SINGLE_LINE);
+
+	va_start(a_start, format);
+	vsprintf(str, format, a_start);
+	va_end(a_start);
+
+	lenght = strlen(str);
 
+	seq_printf(seq, str);
+	return lenght;
+}
+
+/*****************************************************************************
+ *
+ *      sk_seq_show - show proc information of a particular adapter
+ *
+ * Description:
+ *  This function fills the proc entry with statistic data about 
+ *  the ethernet device. It invokes the generic sk_gen_browse() to
+ *  print out all items one per one.
+ *  
+ * Returns: number of bytes written
+ *      
+ */
+static int sk_seq_show(struct seq_file *seq, void *v)
+{
+    void *castedBuffer = (void *) seq;
+    currDev = seq->private;
+    sk_gen_browse(castedBuffer);
+    return 0;
+}
+
+/*****************************************************************************
+ *
+ *      sk_proc_open - register the show function when proc is open'ed
+ *  
+ * Description:
+ *  This function is called whenever a sk98lin proc file is queried.
+ *  
+ * Returns: the return value of single_open()
+ *      
+ */
 static int sk_proc_open(struct inode *inode, struct file *file)
 {
-	return single_open(file, sk_seq_show, PDE(inode)->data);
+    return single_open(file, sk_seq_show, PDE(inode)->data);
 }
 
-struct file_operations sk_proc_fops = {
-	.owner = THIS_MODULE,
-	.open  = sk_proc_open,
-	.read  = seq_read,
-	.llseek = seq_lseek,
-	.release = single_release,
-};
-#endif
+/*******************************************************************************
+ *
+ * End of file
+ *
+ ******************************************************************************/
diff -puN drivers/net/sk98lin/skqueue.c~linus drivers/net/sk98lin/skqueue.c
--- 25/drivers/net/sk98lin/skqueue.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/skqueue.c	2004-01-19 22:17:22.000000000 -0800
@@ -1,9 +1,9 @@
 /******************************************************************************
  *
  * Name:	skqueue.c
- * Project:	Gigabit Ethernet Adapters, Schedule-Modul
- * Version:	$Revision: 1.19 $
- * Date:	$Date: 2003/05/13 18:00:07 $
+ * Project:	Gigabit Ethernet Adapters, Event Scheduler Module
+ * Version:	$Revision: 1.20 $
+ * Date:	$Date: 2003/09/16 13:44:00 $
  * Purpose:	Management of an event queue.
  *
  ******************************************************************************/
@@ -27,6 +27,10 @@
  * History:
  *
  *	$Log: skqueue.c,v $
+ *	Revision 1.20  2003/09/16 13:44:00  rschmidt
+ *	Added (C) Marvell to SysKonnectFileId
+ *	Editorial changes
+ *	
  *	Revision 1.19  2003/05/13 18:00:07  mkarl
  *	Removed calls to RLMT, TWSI, and PNMI for SLIM driver (SK_SLIM).
  *	Editorial changes.
@@ -85,18 +89,16 @@
  *	
  *	Revision 1.1  1998/07/30 15:14:01  gklug
  *	Initial version. Adapted from SMT
- *	
- *	
  *
  ******************************************************************************/
 
 
 /*
-	Event queue and dispatcher
-*/
+ *	Event queue and dispatcher
+ */
 #if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
 static const char SysKonnectFileId[] =
-	"$Header: /usr56/projects/ge/schedule/skqueue.c,v 1.19 2003/05/13 18:00:07 mkarl Exp $" ;
+	"@(#) $Id: skqueue.c,v 1.20 2003/09/16 13:44:00 rschmidt Exp $ (C) Marvell.";
 #endif
 
 #include "h/skdrv1st.h"		/* Driver Specific Definitions */
@@ -124,11 +126,11 @@ intro()
 void	SkEventInit(
 SK_AC	*pAC,	/* Adapter context */
 SK_IOC	Ioc,	/* IO context */
-int	Level)	/* Init level */
+int		Level)	/* Init level */
 {
 	switch (Level) {
 	case SK_INIT_DATA:
-		pAC->Event.EvPut = pAC->Event.EvGet = pAC->Event.EvQueue ;
+		pAC->Event.EvPut = pAC->Event.EvGet = pAC->Event.EvQueue;
 		break;
 	default:
 		break;
@@ -144,14 +146,15 @@ SK_U32		Class,	/* Event Class */
 SK_U32		Event,	/* Event to be queued */
 SK_EVPARA	Para)	/* Event parameter */
 {
-	pAC->Event.EvPut->Class = Class ;
-	pAC->Event.EvPut->Event = Event ;
-	pAC->Event.EvPut->Para = Para ;
+	pAC->Event.EvPut->Class = Class;
+	pAC->Event.EvPut->Event = Event;
+	pAC->Event.EvPut->Para = Para;
+	
 	if (++pAC->Event.EvPut == &pAC->Event.EvQueue[SK_MAX_EVENT])
-		pAC->Event.EvPut = pAC->Event.EvQueue ;
+		pAC->Event.EvPut = pAC->Event.EvQueue;
 
 	if (pAC->Event.EvPut == pAC->Event.EvGet) {
-		SK_ERR_LOG(pAC, SK_ERRCL_NORES, SKERR_Q_E001, SKERR_Q_E001MSG) ;
+		SK_ERR_LOG(pAC, SK_ERRCL_NORES, SKERR_Q_E001, SKERR_Q_E001MSG);
 	}
 }
 
@@ -168,77 +171,79 @@ int	SkEventDispatcher(
 SK_AC	*pAC,	/* Adapters Context */
 SK_IOC	Ioc)	/* Io context */
 {
-	SK_EVENTELEM	*pEv ;	/* pointer into queue */
-	SK_U32			Class ;
-	int			Rtv ;
-
-	pEv = pAC->Event.EvGet ;
-	PRINTF("dispatch get %x put %x\n",pEv,pAC->Event.ev_put) ;
+	SK_EVENTELEM	*pEv;	/* pointer into queue */
+	SK_U32			Class;
+	int			Rtv;
+
+	pEv = pAC->Event.EvGet;
+	
+	PRINTF("dispatch get %x put %x\n", pEv, pAC->Event.ev_put);
+	
 	while (pEv != pAC->Event.EvPut) {
-		PRINTF("dispatch Class %d Event %d\n",pEv->Class,pEv->Event) ;
-		switch(Class = pEv->Class) {
+		PRINTF("dispatch Class %d Event %d\n", pEv->Class, pEv->Event);
+
+		switch (Class = pEv->Class) {
 #ifndef SK_USE_LAC_EV
 #ifndef SK_SLIM
-		case SKGE_RLMT :	/* RLMT Event */
-			Rtv = SkRlmtEvent(pAC,Ioc,pEv->Event,pEv->Para);
-			break ;
-		case SKGE_I2C :		/* I2C Event */
-			Rtv = SkI2cEvent(pAC,Ioc,pEv->Event,pEv->Para);
-			break ;
-		case SKGE_PNMI :
-			Rtv = SkPnmiEvent(pAC,Ioc,pEv->Event,pEv->Para);
-			break ;
+		case SKGE_RLMT:		/* RLMT Event */
+			Rtv = SkRlmtEvent(pAC, Ioc, pEv->Event, pEv->Para);
+			break;
+		case SKGE_I2C:		/* I2C Event */
+			Rtv = SkI2cEvent(pAC, Ioc, pEv->Event, pEv->Para);
+			break;
+		case SKGE_PNMI:		/* PNMI Event */
+			Rtv = SkPnmiEvent(pAC, Ioc, pEv->Event, pEv->Para);
+			break;
 #endif	/* not SK_SLIM */
 #endif	/* not SK_USE_LAC_EV */
-		case SKGE_DRV :		/* Driver Event */
-			Rtv = SkDrvEvent(pAC,Ioc,pEv->Event,pEv->Para);
-			break ;
-#ifndef SK_USE_SW_TIMER        
-		case SKGE_HWAC :
-			Rtv = SkGeSirqEvent(pAC,Ioc,pEv->Event,pEv->Para);
-			break ;
+		case SKGE_DRV:		/* Driver Event */
+			Rtv = SkDrvEvent(pAC, Ioc, pEv->Event, pEv->Para);
+			break;
+#ifndef SK_USE_SW_TIMER
+		case SKGE_HWAC:
+			Rtv = SkGeSirqEvent(pAC, Ioc, pEv->Event, pEv->Para);
+			break;
 #else /* !SK_USE_SW_TIMER */
-        case SKGE_SWT : 
-			Rtv = SkSwtEvent(pAC,Ioc,pEv->Event,pEv->Para);
-			break ;
+        case SKGE_SWT :
+			Rtv = SkSwtEvent(pAC, Ioc, pEv->Event, pEv->Para);
+			break;
 #endif /* !SK_USE_SW_TIMER */
-#ifdef SK_USE_LAC_EV        
+#ifdef SK_USE_LAC_EV
 		case SKGE_LACP :
-			Rtv = SkLacpEvent(pAC,Ioc,pEv->Event,pEv->Para);
-			break ;
+			Rtv = SkLacpEvent(pAC, Ioc, pEv->Event, pEv->Para);
+			break;
 		case SKGE_RSF :
-			Rtv = SkRsfEvent(pAC,Ioc,pEv->Event,pEv->Para);
-			break ;
+			Rtv = SkRsfEvent(pAC, Ioc, pEv->Event, pEv->Para);
+			break;
 		case SKGE_MARKER :
-			Rtv = SkMarkerEvent(pAC,Ioc,pEv->Event,pEv->Para);
-			break ;
+			Rtv = SkMarkerEvent(pAC, Ioc, pEv->Event, pEv->Para);
+			break;
 		case SKGE_FD :
-			Rtv = SkFdEvent(pAC,Ioc,pEv->Event,pEv->Para);
-			break ;
+			Rtv = SkFdEvent(pAC, Ioc, pEv->Event, pEv->Para);
+			break;
 #endif /* SK_USE_LAC_EV */
 #ifdef	SK_USE_CSUM
 		case SKGE_CSUM :
-			Rtv = SkCsEvent(pAC,Ioc,pEv->Event,pEv->Para);
-			break ;
+			Rtv = SkCsEvent(pAC, Ioc, pEv->Event, pEv->Para);
+			break;
 #endif	/* SK_USE_CSUM */
 		default :
-			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_Q_E002,
-				SKERR_Q_E002MSG) ;
+			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_Q_E002, SKERR_Q_E002MSG);
 			Rtv = 0;
 		}
 
 		if (Rtv != 0) {
-			return(Rtv) ;
+			return(Rtv);
 		}
 
 		if (++pEv == &pAC->Event.EvQueue[SK_MAX_EVENT])
-			pEv = pAC->Event.EvQueue ;
+			pEv = pAC->Event.EvQueue;
 
 		/* Renew get: it is used in queue_events to detect overruns */
 		pAC->Event.EvGet = pEv;
 	}
 
-	return(0) ;
+	return(0);
 }
 
 /* End of file */
diff -puN drivers/net/sk98lin/sktimer.c~linus drivers/net/sk98lin/sktimer.c
--- 25/drivers/net/sk98lin/sktimer.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/sktimer.c	2004-01-19 22:17:22.000000000 -0800
@@ -1,9 +1,9 @@
 /******************************************************************************
  *
  * Name:	sktimer.c
- * Project:	Gigabit Ethernet Adapters, Schedule-Modul
- * Version:	$Revision: 1.13 $
- * Date:	$Date: 2003/05/13 18:01:01 $
+ * Project:	Gigabit Ethernet Adapters, Event Scheduler Module
+ * Version:	$Revision: 1.14 $
+ * Date:	$Date: 2003/09/16 13:46:51 $
  * Purpose:	High level timer functions.
  *
  ******************************************************************************/
@@ -27,6 +27,10 @@
  * History:
  *
  *	$Log: sktimer.c,v $
+ *	Revision 1.14  2003/09/16 13:46:51  rschmidt
+ *	Added (C) Marvell to SysKonnectFileId
+ *	Editorial changes
+ *	
  *	Revision 1.13  2003/05/13 18:01:01  mkarl
  *	Editorial changes.
  *	
@@ -68,19 +72,16 @@
  *	
  *	Revision 1.1  1998/08/05 11:27:55  gklug
  *	first version: adapted from SMT
- *	
- *	
- *	
  *
  ******************************************************************************/
 
 
 /*
-	Event queue and dispatcher
-*/
+ *	Event queue and dispatcher
+ */
 #if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
 static const char SysKonnectFileId[] =
-	"$Header: /usr56/projects/ge/schedule/sktimer.c,v 1.13 2003/05/13 18:01:01 mkarl Exp $" ;
+	"@(#) $Id: sktimer.c,v 1.14 2003/09/16 13:46:51 rschmidt Exp $ (C) Marvell.";
 #endif
 
 #include "h/skdrv1st.h"		/* Driver Specific Definitions */
@@ -110,14 +111,14 @@ static void timer_done(SK_AC *pAC,SK_IOC
 void	SkTimerInit(
 SK_AC	*pAC,		/* Adapters context */
 SK_IOC	Ioc,		/* IoContext */
-int	Level)		/* Init Level */
+int		Level)		/* Init Level */
 {
 	switch (Level) {
 	case SK_INIT_DATA:
-		pAC->Tim.StQueue = 0 ;
+		pAC->Tim.StQueue = 0;
 		break;
 	case SK_INIT_IO:
-		SkHwtInit(pAC,Ioc) ;
+		SkHwtInit(pAC, Ioc);
 		SkTimerDone(pAC, Ioc);
 		break;
 	default:
@@ -134,31 +135,34 @@ SK_AC		*pAC,		/* Adapters context */
 SK_IOC		Ioc,		/* IoContext */
 SK_TIMER	*pTimer)	/* Timer Pointer to be started */
 {
-	SK_TIMER	**ppTimPrev ;
-	SK_TIMER	*pTm ;
+	SK_TIMER	**ppTimPrev;
+	SK_TIMER	*pTm;
 
 	/*
 	 * remove timer from queue
 	 */
-	pTimer->TmActive = SK_FALSE ;
+	pTimer->TmActive = SK_FALSE;
+	
 	if (pAC->Tim.StQueue == pTimer && !pTimer->TmNext) {
-		SkHwtStop(pAC,Ioc) ;
+		SkHwtStop(pAC, Ioc);
 	}
-	for (ppTimPrev = &pAC->Tim.StQueue ; (pTm = *ppTimPrev) ;
+	
+	for (ppTimPrev = &pAC->Tim.StQueue; (pTm = *ppTimPrev);
 		ppTimPrev = &pTm->TmNext ) {
+		
 		if (pTm == pTimer) {
 			/*
 			 * Timer found in queue
 			 * - dequeue it and
 			 * - correct delta of the next timer
 			 */
-			*ppTimPrev = pTm->TmNext ;
+			*ppTimPrev = pTm->TmNext;
 
 			if (pTm->TmNext) {
 				/* correct delta of next timer in queue */
-				pTm->TmNext->TmDelta += pTm->TmDelta ;
+				pTm->TmNext->TmDelta += pTm->TmDelta;
 			}
-			return ;
+			return;
 		}
 	}
 }
@@ -175,65 +179,67 @@ SK_U32		Class,		/* Event Class for this 
 SK_U32		Event,		/* Event Value for this timer */
 SK_EVPARA	Para)		/* Event Parameter for this timer */
 {
-	SK_TIMER	**ppTimPrev ;
-	SK_TIMER	*pTm ;
-	SK_U32		Delta ;
+	SK_TIMER	**ppTimPrev;
+	SK_TIMER	*pTm;
+	SK_U32		Delta;
 
-	Time /= 16 ;		/* input is uS, clock ticks are 16uS */
+	Time /= 16;		/* input is uS, clock ticks are 16uS */
+	
 	if (!Time)
-		Time = 1 ;
+		Time = 1;
 
-	SkTimerStop(pAC,Ioc,pTimer) ;
+	SkTimerStop(pAC, Ioc, pTimer);
 
-	pTimer->TmClass = Class ;
-	pTimer->TmEvent = Event ;
-	pTimer->TmPara = Para ;
-	pTimer->TmActive = SK_TRUE ;
+	pTimer->TmClass = Class;
+	pTimer->TmEvent = Event;
+	pTimer->TmPara = Para;
+	pTimer->TmActive = SK_TRUE;
 
 	if (!pAC->Tim.StQueue) {
 		/* First Timer to be started */
-		pAC->Tim.StQueue = pTimer ;
-		pTimer->TmNext = 0 ;
-		pTimer->TmDelta = Time ;
-		SkHwtStart(pAC,Ioc,Time) ;
-		return ;
+		pAC->Tim.StQueue = pTimer;
+		pTimer->TmNext = 0;
+		pTimer->TmDelta = Time;
+		
+		SkHwtStart(pAC, Ioc, Time);
+		
+		return;
 	}
 
 	/*
 	 * timer correction
 	 */
-	timer_done(pAC,Ioc,0) ;
+	timer_done(pAC, Ioc, 0);
 
 	/*
 	 * find position in queue
 	 */
-	Delta = 0 ;
-	for (ppTimPrev = &pAC->Tim.StQueue ; (pTm = *ppTimPrev) ;
+	Delta = 0;
+	for (ppTimPrev = &pAC->Tim.StQueue; (pTm = *ppTimPrev);
 		ppTimPrev = &pTm->TmNext ) {
+		
 		if (Delta + pTm->TmDelta > Time) {
 			/* Position found */
 			/* Here the timer needs to be inserted. */
-			break ;
+			break;
 		}
-		Delta += pTm->TmDelta ;
+		Delta += pTm->TmDelta;
 	}
 
 	/* insert in queue */
-	*ppTimPrev = pTimer ;
-	pTimer->TmNext = pTm ;
-	pTimer->TmDelta = Time - Delta ;
+	*ppTimPrev = pTimer;
+	pTimer->TmNext = pTm;
+	pTimer->TmDelta = Time - Delta;
 
 	if (pTm) {
 		/* There is a next timer
 		 * -> correct its Delta value.
 		 */
-		pTm->TmDelta -= pTimer->TmDelta ;
+		pTm->TmDelta -= pTimer->TmDelta;
 	}
 
-	/*
-	 * start new with first
-	 */
-	SkHwtStart(pAC,Ioc,pAC->Tim.StQueue->TmDelta) ;
+	/* restart with first */
+	SkHwtStart(pAC, Ioc, pAC->Tim.StQueue->TmDelta);
 }
 
 
@@ -241,55 +247,56 @@ void	SkTimerDone(
 SK_AC	*pAC,		/* Adapters context */
 SK_IOC	Ioc)		/* IoContext */
 {
-	timer_done(pAC,Ioc,1) ;
+	timer_done(pAC, Ioc, 1);
 }
 
 
 static void	timer_done(
 SK_AC	*pAC,		/* Adapters context */
 SK_IOC	Ioc,		/* IoContext */
-int	Restart)	/* Do we need to restart the Hardware timer ? */
+int		Restart)	/* Do we need to restart the Hardware timer ? */
 {
-	SK_U32		Delta ;
-	SK_TIMER	*pTm ;
-	SK_TIMER	*pTComp ;	/* Timer completed now now */
-	SK_TIMER	**ppLast ;	/* Next field of Last timer to be deq */
-	int		Done = 0 ;
-
-	Delta = SkHwtRead(pAC,Ioc) ;
-	ppLast = &pAC->Tim.StQueue ;
-	pTm = pAC->Tim.StQueue ;
+	SK_U32		Delta;
+	SK_TIMER	*pTm;
+	SK_TIMER	*pTComp;	/* Timer completed now now */
+	SK_TIMER	**ppLast;	/* Next field of Last timer to be deq */
+	int		Done = 0;
+
+	Delta = SkHwtRead(pAC, Ioc);
+	
+	ppLast = &pAC->Tim.StQueue;
+	pTm = pAC->Tim.StQueue;
 	while (pTm && !Done) {
 		if (Delta >= pTm->TmDelta) {
 			/* Timer ran out */
-			pTm->TmActive = SK_FALSE ;
-			Delta -= pTm->TmDelta ;
-			ppLast = &pTm->TmNext ;
-			pTm = pTm->TmNext ;
-		} else {
+			pTm->TmActive = SK_FALSE;
+			Delta -= pTm->TmDelta;
+			ppLast = &pTm->TmNext;
+			pTm = pTm->TmNext;
+		}
+		else {
 			/* We found the first timer that did not run out */
-			pTm->TmDelta -= Delta ;
-			Delta = 0 ;
-			Done = 1 ;
+			pTm->TmDelta -= Delta;
+			Delta = 0;
+			Done = 1;
 		}
 	}
-	*ppLast = 0 ;
+	*ppLast = 0;
 	/*
 	 * pTm points to the first Timer that did not run out.
 	 * StQueue points to the first Timer that run out.
 	 */
 
-	for ( pTComp = pAC->Tim.StQueue ; pTComp ; pTComp = pTComp->TmNext) {
-		SkEventQueue(pAC,pTComp->TmClass, pTComp->TmEvent,
-			pTComp->TmPara) ;
+	for ( pTComp = pAC->Tim.StQueue; pTComp; pTComp = pTComp->TmNext) {
+		SkEventQueue(pAC,pTComp->TmClass, pTComp->TmEvent, pTComp->TmPara);
 	}
 
 	/* Set head of timer queue to the first timer that did not run out */
-	pAC->Tim.StQueue = pTm ;
+	pAC->Tim.StQueue = pTm;
 
 	if (Restart && pAC->Tim.StQueue) {
 		/* Restart HW timer */
-		SkHwtStart(pAC,Ioc,pAC->Tim.StQueue->TmDelta) ;
+		SkHwtStart(pAC, Ioc, pAC->Tim.StQueue->TmDelta);
 	}
 }
 
diff -puN drivers/net/sk98lin/skxmac2.c~linus drivers/net/sk98lin/skxmac2.c
--- 25/drivers/net/sk98lin/skxmac2.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/sk98lin/skxmac2.c	2004-01-19 22:17:22.000000000 -0800
@@ -2,8 +2,8 @@
  *
  * Name:	skxmac2.c
  * Project:	Gigabit Ethernet Adapters, Common Modules
- * Version:	$Revision: 1.99 $
- * Date:	$Date: 2003/07/11 12:19:33 $
+ * Version:	$Revision: 1.102 $
+ * Date:	$Date: 2003/10/02 16:53:58 $
  * Purpose:	Contains functions to initialize the MACs and PHYs
  *
  ******************************************************************************/
@@ -27,6 +27,23 @@
  * History:
  *
  *	$Log: skxmac2.c,v $
+ *	Revision 1.102  2003/10/02 16:53:58  rschmidt
+ *	Changed setting of GMAC parameters with new macros.
+ *	Added define SLIM around SkGm...LowPowerMode().
+ *	Editorial changes.
+ *	
+ *	Revision 1.101  2003/09/16 14:49:07  rschmidt
+ *	Added routines SkGmClearRst(), SkXmClearRst, SkMacClearRst().
+ *	Added WA code for Yukon-Lite's COMA mode in SkGmHardRst().
+ *	Replaced PCI-Config R/W through internal access.
+ *	Fixed return from coma mode in SkGmLeaveLowPowerMode().
+ *	Fixed compiler warnings for different types.
+ *	Editorial changes.
+ *	
+ *	Revision 1.100  2003/09/16 07:09:11  mschmid
+ *	Added functions SkGmEnterLowPowerMode() and
+ *	SkGmLeaveLowPowerMode()
+ *	
  *	Revision 1.99  2003/07/11 12:19:33  rschmidt
  *	Reduced init values for Master & Slave downshift counters to
  *	minimum values.
@@ -164,7 +181,7 @@
  *	Revision 1.74  2002/08/12 14:00:17  rschmidt
  *	Replaced usage of Broadcom PHY Ids with defines.
  *	Corrected error messages in SkGmMacStatistic().
- *	Made SkMacPromiscMode() public for ADDR-Modul.
+ *	Made SkMacPromiscMode() public for ADDR-Module.
  *	Editorial changes.
  *	
  *	Revision 1.73  2002/08/08 16:26:24  rschmidt
@@ -475,7 +492,7 @@ typedef struct s_PhyHack {
 
 #if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
 static const char SysKonnectFileId[] =
-	"@(#) $Id: skxmac2.c,v 1.99 2003/07/11 12:19:33 rschmidt Exp $ (C) Marvell.";
+	"@(#) $Id: skxmac2.c,v 1.102 2003/10/02 16:53:58 rschmidt Exp $ (C) Marvell.";
 #endif
 
 #ifdef GENESIS
@@ -1343,7 +1360,7 @@ int		Port)	/* Port Index (MAC_1 + n) */
  * Description:
  *	The XMAC of the specified 'Port' and all connected devices
  *	(PHY and SERDES) will receive a reset signal on its *Reset pins.
- *	External PHYs must be reset be clearing a bit in the GPIO register
+ *	External PHYs must be reset by clearing a bit in the GPIO register
  *  (Timing requirements: Broadcom: 400ns, Level One: none, National: 80ns).
  *
  * ATTENTION:
@@ -1386,23 +1403,62 @@ int		Port)	/* Port Index (MAC_1 + n) */
 
 	/* For external PHYs there must be special handling */
 	if (pAC->GIni.GP[Port].PhyType != SK_PHY_XMAC) {
-		/* reset external PHY */
+		
 		SK_IN32(IoC, B2_GP_IO, &Reg);
+		
 		if (Port == 0) {
-			Reg |= GP_DIR_0; /* set to output */
-			Reg &= ~GP_IO_0;
+			Reg |= GP_DIR_0; 	/* set to output */
+			Reg &= ~GP_IO_0;	/* set PHY reset (active low) */
 		}
 		else {
-			Reg |= GP_DIR_2; /* set to output */
-			Reg &= ~GP_IO_2;
+			Reg |= GP_DIR_2;	/* set to output */
+			Reg &= ~GP_IO_2;	/* set PHY reset (active low) */
 		}
+		/* reset external PHY */
 		SK_OUT32(IoC, B2_GP_IO, Reg);
 
 		/* short delay */
 		SK_IN32(IoC, B2_GP_IO, &Reg);
 	}
-
 }	/* SkXmHardRst */
+
+
+/******************************************************************************
+ *
+ *	SkXmClearRst() - Release the PHY & XMAC reset
+ *
+ * Description:
+ *
+ * Returns:
+ *	nothing
+ */
+static void SkXmClearRst(
+SK_AC	*pAC,	/* adapter context */
+SK_IOC	IoC,	/* IO context */
+int		Port)	/* Port Index (MAC_1 + n) */
+{
+	SK_U32	DWord;
+	
+	/* clear HW reset */
+	SK_OUT16(IoC, MR_ADDR(Port, TX_MFF_CTRL1), MFF_CLR_MAC_RST);
+
+	if (pAC->GIni.GP[Port].PhyType != SK_PHY_XMAC) {
+
+		SK_IN32(IoC, B2_GP_IO, &DWord);
+
+		if (Port == 0) {
+			DWord |= (GP_DIR_0 | GP_IO_0); /* set to output */
+		}
+		else {
+			DWord |= (GP_DIR_2 | GP_IO_2); /* set to output */
+		}
+		/* Clear PHY reset */
+		SK_OUT32(IoC, B2_GP_IO, DWord);
+
+		/* Enable GMII interface */
+		XM_OUT16(IoC, Port, XM_HW_CFG, XM_HW_GMII_MD);
+	}
+}	/* SkXmClearRst */
 #endif /* GENESIS */
 
 
@@ -1452,10 +1508,6 @@ int		Port)	/* Port Index (MAC_1 + n) */
  *
  * Description:
  *
- * ATTENTION:
- * 	It is absolutely necessary to reset the SW_RST Bit first
- *	before calling this function.
- *
  * Returns:
  *	nothing
  */
@@ -1464,6 +1516,20 @@ SK_AC	*pAC,	/* adapter context */
 SK_IOC	IoC,	/* IO context */
 int		Port)	/* Port Index (MAC_1 + n) */
 {
+	SK_U32	DWord;
+	
+	/* WA code for COMA mode */
+	if (pAC->GIni.GIYukonLite &&
+		pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) {
+		
+		SK_IN32(IoC, B2_GP_IO, &DWord);
+
+		DWord |= (GP_DIR_9 | GP_IO_9);
+
+		/* set PHY reset */
+		SK_OUT32(IoC, B2_GP_IO, DWord);
+	}
+
 	/* set GPHY Control reset */
 	SK_OUT32(IoC, MR_ADDR(Port, GPHY_CTRL), GPC_RST_SET);
 
@@ -1471,6 +1537,73 @@ int		Port)	/* Port Index (MAC_1 + n) */
 	SK_OUT32(IoC, MR_ADDR(Port, GMAC_CTRL), GMC_RST_SET);
 
 }	/* SkGmHardRst */
+
+
+/******************************************************************************
+ *
+ *	SkGmClearRst() - Release the GPHY & GMAC reset
+ *
+ * Description:
+ *
+ * Returns:
+ *	nothing
+ */
+static void SkGmClearRst(
+SK_AC	*pAC,	/* adapter context */
+SK_IOC	IoC,	/* IO context */
+int		Port)	/* Port Index (MAC_1 + n) */
+{
+	SK_U32	DWord;
+	
+#ifdef XXX
+		/* clear GMAC Control reset */
+		SK_OUT32(IoC, MR_ADDR(Port, GMAC_CTRL), GMC_RST_CLR);
+
+		/* set GMAC Control reset */
+		SK_OUT32(IoC, MR_ADDR(Port, GMAC_CTRL), GMC_RST_SET);
+#endif /* XXX */
+
+	/* WA code for COMA mode */
+	if (pAC->GIni.GIYukonLite &&
+		pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) {
+		
+		SK_IN32(IoC, B2_GP_IO, &DWord);
+
+		DWord |= GP_DIR_9;		/* set to output */
+		DWord &= ~GP_IO_9;		/* clear PHY reset (active high) */
+
+		/* clear PHY reset */
+		SK_OUT32(IoC, B2_GP_IO, DWord);
+	}
+
+	/* set HWCFG_MODE */
+	DWord = GPC_INT_POL_HI | GPC_DIS_FC | GPC_DIS_SLEEP |
+		GPC_ENA_XC | GPC_ANEG_ADV_ALL_M | GPC_ENA_PAUSE |
+		(pAC->GIni.GICopperType ? GPC_HWCFG_GMII_COP :
+		GPC_HWCFG_GMII_FIB);
+
+	/* set GPHY Control reset */
+	SK_OUT32(IoC, MR_ADDR(Port, GPHY_CTRL), DWord | GPC_RST_SET);
+
+	/* release GPHY Control reset */
+	SK_OUT32(IoC, MR_ADDR(Port, GPHY_CTRL), DWord | GPC_RST_CLR);
+
+#ifdef VCPU
+	VCpuWait(9000);
+#endif /* VCPU */
+
+	/* clear GMAC Control reset */
+	SK_OUT32(IoC, MR_ADDR(Port, GMAC_CTRL), GMC_PAUSE_ON | GMC_RST_CLR);
+
+#ifdef VCPU
+	VCpuWait(2000);
+	
+	SK_IN32(IoC, MR_ADDR(Port, GPHY_CTRL), &DWord);
+			
+	SK_IN32(IoC, B0_ISRC, &DWord);
+#endif /* VCPU */
+
+}	/* SkGmClearRst */
 #endif /* YUKON */
 
 
@@ -1553,6 +1686,38 @@ int		Port)	/* Port Index (MAC_1 + n) */
 }	/* SkMacHardRst */
 
 
+/******************************************************************************
+ *
+ *	SkMacClearRst() - Clear the MAC reset
+ *
+ * Description:	calls a clear MAC reset routine dep. on board type
+ *
+ * Returns:
+ *	nothing
+ */
+void SkMacClearRst(
+SK_AC	*pAC,	/* adapter context */
+SK_IOC	IoC,	/* IO context */
+int		Port)	/* Port Index (MAC_1 + n) */
+{
+	
+#ifdef GENESIS
+	if (pAC->GIni.GIGenesis) {
+		
+		SkXmClearRst(pAC, IoC, Port);
+	}
+#endif /* GENESIS */
+	
+#ifdef YUKON
+	if (pAC->GIni.GIYukon) {
+		
+		SkGmClearRst(pAC, IoC, Port);
+	}
+#endif /* YUKON */
+
+}	/* SkMacClearRst */
+
+
 #ifdef GENESIS
 /******************************************************************************
  *
@@ -1574,7 +1739,6 @@ SK_IOC	IoC,		/* IO context */
 int		Port)		/* Port Index (MAC_1 + n) */
 {
 	SK_GEPORT	*pPrt;
-	SK_U32		Reg;
 	int			i;
 	SK_U16		SWord;
 
@@ -1594,32 +1758,10 @@ int		Port)		/* Port Index (MAC_1 + n) */
 	}
 
 	if (pPrt->PState == SK_PRT_RESET) {
-		/*
-		 * clear HW reset
-		 * Note: The SW reset is self clearing, therefore there is
-		 *	 nothing to do here.
-		 */
-		SK_OUT16(IoC, MR_ADDR(Port, TX_MFF_CTRL1), MFF_CLR_MAC_RST);
 
-		/* Ensure that XMAC reset release is done (errata from LReinbold?) */
-		SK_IN16(IoC, MR_ADDR(Port, TX_MFF_CTRL1), &SWord);
+		SkXmClearRst(pAC, IoC, Port);
 
-		/* Clear PHY reset */
 		if (pPrt->PhyType != SK_PHY_XMAC) {
-
-			SK_IN32(IoC, B2_GP_IO, &Reg);
-			
-			if (Port == 0) {
-				Reg |= (GP_DIR_0 | GP_IO_0); /* set to output */
-			}
-			else {
-				Reg |= (GP_DIR_2 | GP_IO_2); /* set to output */
-			}
-			SK_OUT32(IoC, B2_GP_IO, Reg);
-
-			/* Enable GMII interface */
-			XM_OUT16(IoC, Port, XM_HW_CFG, XM_HW_GMII_MD);
-
 			/* read Id from external PHY (all have the same address) */
 			SkXmPhyRead(pAC, IoC, Port, PHY_XMAC_ID1, &pPrt->PhyId1);
 
@@ -1831,43 +1973,11 @@ int		Port)		/* Port Index (MAC_1 + n) */
 	}
 
 	if (pPrt->PState == SK_PRT_RESET) {
-		/* set GPHY Control reset */
-		SK_OUT32(IoC, MR_ADDR(Port, GPHY_CTRL), GPC_RST_SET);
-
-		/* set GMAC Control reset */
-		SK_OUT32(IoC, MR_ADDR(Port, GMAC_CTRL), GMC_RST_SET);
-
-#ifdef XXX
-		/* clear GMAC Control reset */
-		SK_OUT32(IoC, MR_ADDR(Port, GMAC_CTRL), GMC_RST_CLR);
-
-		/* set GMAC Control reset */
-		SK_OUT32(IoC, MR_ADDR(Port, GMAC_CTRL), GMC_RST_SET);
-#endif /* XXX */
-
-		/* set HWCFG_MODE */
-		DWord = GPC_INT_POL_HI | GPC_DIS_FC | GPC_DIS_SLEEP |
-			GPC_ENA_XC | GPC_ANEG_ADV_ALL_M | GPC_ENA_PAUSE |
-			(pAC->GIni.GICopperType ? GPC_HWCFG_GMII_COP :
-			GPC_HWCFG_GMII_FIB);
-
-		/* set GPHY Control reset */
-		SK_OUT32(IoC, MR_ADDR(Port, GPHY_CTRL), DWord | GPC_RST_SET);
-
-		/* release GPHY Control reset */
-		SK_OUT32(IoC, MR_ADDR(Port, GPHY_CTRL), DWord | GPC_RST_CLR);
-
-#ifdef VCPU
-		VCpuWait(9000);
-#endif /* VCPU */
-
-		/* clear GMAC Control reset */
-		SK_OUT32(IoC, MR_ADDR(Port, GMAC_CTRL), GMC_PAUSE_ON | GMC_RST_CLR);
-
-#ifdef VCPU
-		VCpuWait(2000);
-#endif /* VCPU */
+		
+		SkGmHardRst(pAC, IoC, Port);
 
+		SkGmClearRst(pAC, IoC, Port);
+		
 		/* Auto-negotiation ? */
 		if (pPrt->PLinkMode == SK_LMODE_HALF || pPrt->PLinkMode == SK_LMODE_FULL) {
 			/* Auto-negotiation disabled */
@@ -1906,6 +2016,7 @@ int		Port)		/* Port Index (MAC_1 + n) */
 			SWord |= GM_GPCR_DUP_FULL;
 		}
 
+		/* flow-control settings */
 		switch (pPrt->PFlowCtrlMode) {
 		case SK_FLOW_MODE_NONE:
 			/* set Pause Off */
@@ -1940,7 +2051,7 @@ int		Port)		/* Port Index (MAC_1 + n) */
 	(void)SkGmResetCounter(pAC, IoC, Port);
 
 	/* setup Transmit Control Register */
-	GM_OUT16(IoC, Port, GM_TX_CTRL, GM_TXCR_COL_THR);
+	GM_OUT16(IoC, Port, GM_TX_CTRL, TX_COL_THR(pPrt->PMacColThres));
 
 	/* setup Receive Control Register */
 	GM_OUT16(IoC, Port, GM_RX_CTRL, GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA |
@@ -1954,7 +2065,9 @@ int		Port)		/* Port Index (MAC_1 + n) */
 	GM_IN16(IoC, Port, GM_TX_PARAM, &SWord);
 #endif /* VCPU */
 
-    SWord = (SK_U16)(JAM_LEN_VAL(3) | JAM_IPG_VAL(11) | IPG_JAM_DATA(26));
+    SWord = TX_JAM_LEN_VAL(pPrt->PMacJamLen) |
+			TX_JAM_IPG_VAL(pPrt->PMacJamIpgVal) |
+			TX_IPG_JAM_DATA(pPrt->PMacJamIpgData);
 	
 	GM_OUT16(IoC, Port, GM_TX_PARAM, SWord);
 
@@ -1963,7 +2076,12 @@ int		Port)		/* Port Index (MAC_1 + n) */
 	GM_IN16(IoC, Port, GM_SERIAL_MODE, &SWord);
 #endif /* VCPU */
 	
-	SWord = GM_SMOD_VLAN_ENA | IPG_VAL_FAST_ETH;
+	SWord = GM_SMOD_VLAN_ENA | IPG_DATA_VAL(pPrt->PMacIpgData);
+
+	if (pPrt->PMacLimit4) {
+		/* reset of collision counter after 4 consecutive collisions */
+		SWord |= GM_SMOD_LIMIT_4;
+	}
 
 	if (pAC->GIni.GIPortUsage == SK_JUMBO_LINK) {
 		/* enable jumbo mode (Max. Frame Length = 9018) */
@@ -2021,11 +2139,13 @@ int		Port)		/* Port Index (MAC_1 + n) */
 	GM_OUT16(IoC, Port, GM_RX_IRQ_MSK, 0);
 	GM_OUT16(IoC, Port, GM_TR_IRQ_MSK, 0);
 
+#if defined(SK_DIAG) || defined(DEBUG)
 	/* read General Purpose Status */
 	GM_IN16(IoC, Port, GM_GP_STAT, &SWord);
 	
 	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
-		("MAC Stat Reg=0x%04X\n", SWord));
+		("MAC Stat Reg.=0x%04X\n", SWord));
+#endif /* SK_DIAG || DEBUG */
 
 #ifdef SK_DIAG
 	c_print("MAC Stat Reg=0x%04X\n", SWord);
@@ -2226,6 +2346,7 @@ SK_BOOL	DoLoop)		/* Should a Phy LoopBac
 				SKERR_HWI_E015MSG);
 		}
 
+		/* Set Flow-control capabilities */
 		switch (pPrt->PFlowCtrlMode) {
 		case SK_FLOW_MODE_NONE:
 			Ctrl |= PHY_X_P_NO_PAUSE;
@@ -2306,7 +2427,9 @@ SK_BOOL	DoLoop)		/* Should a Phy LoopBac
 		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
 			("InitPhyBcom: no auto-negotiation Port %d\n", Port));
 		/* Set DuplexMode in Config register */
-		Ctrl1 |= (pPrt->PLinkMode == SK_LMODE_FULL ? PHY_CT_DUP_MD : 0);
+		if (pPrt->PLinkMode == SK_LMODE_FULL) {
+			Ctrl1 |= PHY_CT_DUP_MD;
+		}
 
 		/* Determine Master/Slave manually if not already done */
 		if (pPrt->PMSMode == SK_MS_MODE_AUTO) {
@@ -2346,6 +2469,7 @@ SK_BOOL	DoLoop)		/* Should a Phy LoopBac
 				SKERR_HWI_E015MSG);
 		}
 
+		/* Set Flow-control capabilities */
 		switch (pPrt->PFlowCtrlMode) {
 		case SK_FLOW_MODE_NONE:
 			Ctrl3 |= PHY_B_P_NO_PAUSE;
@@ -2375,12 +2499,12 @@ SK_BOOL	DoLoop)		/* Should a Phy LoopBac
 	/* Write 1000Base-T Control Register */
 	SkXmPhyWrite(pAC, IoC, Port, PHY_BCOM_1000T_CTRL, Ctrl2);
 	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
-		("1000B-T Ctrl Reg=0x%04X\n", Ctrl2));
+		("Set 1000B-T Ctrl Reg=0x%04X\n", Ctrl2));
 	
 	/* Write AutoNeg Advertisement Register */
 	SkXmPhyWrite(pAC, IoC, Port, PHY_BCOM_AUNE_ADV, Ctrl3);
 	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
-		("Auto-Neg.Adv.Reg=0x%04X\n", Ctrl3));
+		("Set Auto-Neg.Adv.Reg=0x%04X\n", Ctrl3));
 	
 	if (DoLoop) {
 		/* Set the Phy Loopback bit, too */
@@ -2409,6 +2533,281 @@ SK_BOOL	DoLoop)		/* Should a Phy LoopBac
 
 
 #ifdef YUKON
+#ifndef SK_SLIM
+/******************************************************************************
+ *
+ *	SkGmEnterLowPowerMode()
+ *
+ * Description:	
+ *	This function sets the Marvell Alaska PHY to the low power mode
+ *	given by parameter mode.
+ *	The following low power modes are available:
+ *		
+ *		- Coma Mode (Deep Sleep):
+ *			Power consumption: ~15 - 30 mW
+ *			The PHY cannot wake up on its own.
+ *
+ *		- IEEE 22.2.4.1.5 compatible power down mode
+ *			Power consumption: ~240 mW
+ *			The PHY cannot wake up on its own.
+ *
+ *		- energy detect mode
+ *			Power consumption: ~160 mW
+ *			The PHY can wake up on its own by detecting activity
+ *			on the CAT 5 cable.
+ *
+ *		- energy detect plus mode
+ *			Power consumption: ~150 mW
+ *			The PHY can wake up on its own by detecting activity
+ *			on the CAT 5 cable.
+ *			Connected devices can be woken up by sending normal link
+ *			pulses every one second.
+ *
+ * Note:
+ *
+ * Returns:
+ *		0: ok
+ *		1: error
+ */
+int SkGmEnterLowPowerMode(
+SK_AC	*pAC,		/* adapter context */
+SK_IOC	IoC,		/* IO context */
+int		Port,		/* Port Index (e.g. MAC_1) */
+SK_U8	Mode)		/* low power mode */
+{
+	SK_U16	Word;
+	SK_U32	DWord;
+	SK_U8	LastMode;
+	int		Ret = 0;
+
+	if (pAC->GIni.GIYukonLite &&
+	    pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) {
+
+		/* save current power mode */
+		LastMode = pAC->GIni.GP[Port].PPhyPowerState;
+		pAC->GIni.GP[Port].PPhyPowerState = Mode;
+
+		switch (Mode) {
+			/* coma mode (deep sleep) */
+			case PHY_PM_DEEP_SLEEP:
+				/* setup General Purpose Control Register */
+				GM_OUT16(IoC, 0, GM_GP_CTRL, GM_GPCR_FL_PASS |
+					GM_GPCR_SPEED_100 | GM_GPCR_AU_ALL_DIS);
+
+				/* apply COMA mode workaround */
+				SkGmPhyWrite(pAC, IoC, Port, 29, 0x001f);
+				SkGmPhyWrite(pAC, IoC, Port, 30, 0xfff3);
+
+				SK_IN32(IoC, PCI_C(PCI_OUR_REG_1), &DWord);
+
+				SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
+				
+				/* Set PHY to Coma Mode */
+				SK_OUT32(IoC, PCI_C(PCI_OUR_REG_1), DWord | PCI_PHY_COMA);
+				
+				SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
+
+			break;
+			
+			/* IEEE 22.2.4.1.5 compatible power down mode */
+			case PHY_PM_IEEE_POWER_DOWN:
+				/*
+				 * - disable MAC 125 MHz clock
+				 * - allow MAC power down
+				 */
+				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
+				Word |= PHY_M_PC_DIS_125CLK;
+				Word &=	~PHY_M_PC_MAC_POW_UP;
+				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
+
+				/*
+				 * register changes must be followed by a software
+				 * reset to take effect
+				 */
+				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &Word);
+				Word |= PHY_CT_RESET;
+				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, Word);
+
+				/* switch IEEE compatible power down mode on */
+				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &Word);
+				Word |= PHY_CT_PDOWN;
+				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, Word);
+			break;
+
+			/* energy detect and energy detect plus mode */
+			case PHY_PM_ENERGY_DETECT:
+			case PHY_PM_ENERGY_DETECT_PLUS:
+				/*
+				 * - disable MAC 125 MHz clock
+				 */
+				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
+				Word |= PHY_M_PC_DIS_125CLK;
+				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
+				
+				/* activate energy detect mode 1 */
+				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
+
+				/* energy detect mode */
+				if (Mode == PHY_PM_ENERGY_DETECT) {
+					Word |= PHY_M_PC_EN_DET;
+				}
+				/* energy detect plus mode */
+				else {
+					Word |= PHY_M_PC_EN_DET_PLUS;
+				}
+
+				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
+
+				/*
+				 * reinitialize the PHY to force a software reset
+				 * which is necessary after the register settings
+				 * for the energy detect modes.
+				 * Furthermore reinitialisation prevents that the
+				 * PHY is running out of a stable state.
+				 */
+				SkGmInitPhyMarv(pAC, IoC, Port, SK_FALSE);
+			break;
+
+			/* don't change current power mode */
+			default:
+				pAC->GIni.GP[Port].PPhyPowerState = LastMode;
+				Ret = 1;
+			break;
+		}
+	}
+	/* low power modes are not supported by this chip */
+	else {
+		Ret = 1;
+	}
+
+	return(Ret);
+
+}	/* SkGmEnterLowPowerMode */
+
+/******************************************************************************
+ *
+ *	SkGmLeaveLowPowerMode()
+ *
+ * Description:	
+ *	Leave the current low power mode and switch to normal mode
+ *
+ * Note:
+ *
+ * Returns:
+ *		0:	ok
+ *		1:	error
+ */
+int SkGmLeaveLowPowerMode(
+SK_AC	*pAC,		/* adapter context */
+SK_IOC	IoC,		/* IO context */
+int		Port)		/* Port Index (e.g. MAC_1) */
+{
+	SK_U32	DWord;
+	SK_U16	Word;
+	SK_U8	LastMode;
+	int		Ret = 0;
+
+	if (pAC->GIni.GIYukonLite &&
+		pAC->GIni.GIChipRev == CHIP_REV_YU_LITE_A3) {
+
+		/* save current power mode */
+		LastMode = pAC->GIni.GP[Port].PPhyPowerState;
+		pAC->GIni.GP[Port].PPhyPowerState = PHY_PM_OPERATIONAL_MODE;
+
+		switch (LastMode) {
+			/* coma mode (deep sleep) */
+			case PHY_PM_DEEP_SLEEP:
+				SK_IN32(IoC, PCI_C(PCI_OUR_REG_1), &DWord);
+
+				SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_ON);
+				
+				/* Release PHY from Coma Mode */
+				SK_OUT32(IoC, PCI_C(PCI_OUR_REG_1), DWord & ~PCI_PHY_COMA);
+				
+				SK_OUT8(IoC, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
+				
+				SK_IN32(IoC, B2_GP_IO, &DWord);
+
+				/* set to output */
+				DWord |= (GP_DIR_9 | GP_IO_9);
+
+				/* set PHY reset */
+				SK_OUT32(IoC, B2_GP_IO, DWord);
+
+				DWord &= ~GP_IO_9; /* clear PHY reset (active high) */
+
+				/* clear PHY reset */
+				SK_OUT32(IoC, B2_GP_IO, DWord);
+			break;
+			
+			/* IEEE 22.2.4.1.5 compatible power down mode */
+			case PHY_PM_IEEE_POWER_DOWN:
+				/*
+				 * - enable MAC 125 MHz clock
+				 * - set MAC power up
+				 */
+				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
+				Word &= ~PHY_M_PC_DIS_125CLK;
+				Word |=	PHY_M_PC_MAC_POW_UP;
+				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
+
+				/*
+				 * register changes must be followed by a software
+				 * reset to take effect
+				 */
+				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &Word);
+				Word |= PHY_CT_RESET;
+				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, Word);
+
+				/* switch IEEE compatible power down mode off */
+				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &Word);
+				Word &= ~PHY_CT_PDOWN;
+				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, Word);
+			break;
+
+			/* energy detect and energy detect plus mode */
+			case PHY_PM_ENERGY_DETECT:
+			case PHY_PM_ENERGY_DETECT_PLUS:
+				/*
+				 * - enable MAC 125 MHz clock
+				 */
+				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
+				Word &= ~PHY_M_PC_DIS_125CLK;
+				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
+				
+				/* disable energy detect mode */
+				SkGmPhyRead(pAC, IoC, Port, PHY_MARV_PHY_CTRL, &Word);
+				Word &= ~PHY_M_PC_EN_DET_MSK;
+				SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL, Word);
+
+				/*
+				 * reinitialize the PHY to force a software reset
+				 * which is necessary after the register settings
+				 * for the energy detect modes.
+				 * Furthermore reinitialisation prevents that the
+				 * PHY is running out of a stable state.
+				 */
+				SkGmInitPhyMarv(pAC, IoC, Port, SK_FALSE);
+			break;
+
+			/* don't change current power mode */
+			default:
+				pAC->GIni.GP[Port].PPhyPowerState = LastMode;
+				Ret = 1;
+			break;
+		}
+	}
+	/* low power modes are not supported by this chip */
+	else {
+		Ret = 1;
+	}
+
+	return(Ret);
+
+}	/* SkGmLeaveLowPowerMode */
+#endif /* !SK_SLIM */
+
+
 /******************************************************************************
  *
  *	SkGmInitPhyMarv() - Initialize the Marvell Phy registers
@@ -2457,7 +2856,6 @@ SK_BOOL	DoLoop)		/* Should a Phy LoopBac
 	VCPUprintf(0, "SkGmInitPhyMarv(), Port=%u, DoLoop=%u\n",
 		Port, DoLoop);
 #else /* VCPU */
-	
 	if (DoLoop) {
 		/* Set 'MAC Power up'-bit, set Manual MDI configuration */
 		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_PHY_CTRL,
@@ -2475,16 +2873,20 @@ SK_BOOL	DoLoop)		/* Should a Phy LoopBac
 	
 		SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_EXT_CTRL, ExtPhyCtrl);
 		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
-			("Ext. PHY Ctrl=0x%04X\n", ExtPhyCtrl));
+			("Set Ext. PHY Ctrl=0x%04X\n", ExtPhyCtrl));
 	}
 
 	/* Read PHY Control */
 	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_CTRL, &PhyCtrl);
 
+	if (!AutoNeg) {
+		/* Disable Auto-negotiation */
+		PhyCtrl &= ~PHY_CT_ANE;
+	}
+
 	PhyCtrl |= PHY_CT_RESET;
 	/* Assert software reset */
 	SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, PhyCtrl);
-
 #endif /* VCPU */
 
 	PhyCtrl = 0 /* PHY_CT_COL_TST */;
@@ -2533,13 +2935,9 @@ SK_BOOL	DoLoop)		/* Should a Phy LoopBac
 		if (!DoLoop) {
 			PhyCtrl |= PHY_CT_RESET;
 		}
-		/*
-		 * Do NOT enable Auto-negotiation here. This would hold
-		 * the link down because no IDLES are transmitted
-		 */
 	}
 	else {
-		PhyCtrl |= PHY_CT_ANE;
+		/* Set Auto-negotiation advertisement */
 		
 		if (pAC->GIni.GICopperType) {
 			/* Set Speed capabilities */
@@ -2554,6 +2952,7 @@ SK_BOOL	DoLoop)		/* Should a Phy LoopBac
 				break;
 			case SK_LSPEED_100MBPS:
 				AutoNegAdv |= PHY_M_AN_100_FD | PHY_M_AN_100_HD |
+					/* advertise 10Base-T also */
 					PHY_M_AN_10_FD | PHY_M_AN_10_HD;
 				break;
 			case SK_LSPEED_10MBPS:
@@ -2581,7 +2980,7 @@ SK_BOOL	DoLoop)		/* Should a Phy LoopBac
 					SKERR_HWI_E015MSG);
 			}
 			
-			/* Set Auto-negotiation advertisement */
+			/* Set Flow-control capabilities */
 			switch (pPrt->PFlowCtrlMode) {
 			case SK_FLOW_MODE_NONE:
 				AutoNegAdv |= PHY_B_P_NO_PAUSE;
@@ -2618,7 +3017,7 @@ SK_BOOL	DoLoop)		/* Should a Phy LoopBac
 					SKERR_HWI_E015MSG);
 			}
 			
-			/* Set Auto-negotiation advertisement */
+			/* Set Flow-control capabilities */
 			switch (pPrt->PFlowCtrlMode) {
 			case SK_FLOW_MODE_NONE:
 				AutoNegAdv |= PHY_M_P_NO_PAUSE_X;
@@ -2640,7 +3039,7 @@ SK_BOOL	DoLoop)		/* Should a Phy LoopBac
 
 		if (!DoLoop) {
 			/* Restart Auto-negotiation */
-			PhyCtrl |= PHY_CT_RE_CFG;
+			PhyCtrl |= PHY_CT_ANE | PHY_CT_RE_CFG;
 		}
 	}
 	
@@ -2659,12 +3058,12 @@ SK_BOOL	DoLoop)		/* Should a Phy LoopBac
 	/* Write 1000Base-T Control Register */
 	SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_1000T_CTRL, C1000BaseT);
 	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
-		("1000B-T Ctrl=0x%04X\n", C1000BaseT));
+		("Set 1000B-T Ctrl =0x%04X\n", C1000BaseT));
 	
 	/* Write AutoNeg Advertisement Register */
 	SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_AUNE_ADV, AutoNegAdv);
 	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
-		("Auto-Neg.Ad.=0x%04X\n", AutoNegAdv));
+		("Set Auto-Neg.Adv.=0x%04X\n", AutoNegAdv));
 #endif /* VCPU */
 	
 	if (DoLoop) {
@@ -2694,6 +3093,8 @@ SK_BOOL	DoLoop)		/* Should a Phy LoopBac
 
 	/* Write to the PHY Control register */
 	SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_CTRL, PhyCtrl);
+	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
+		("Set PHY Ctrl Reg.=0x%04X\n", PhyCtrl));
 
 #ifdef VCPU
 	VCpuWait(2000);
@@ -2712,7 +3113,7 @@ SK_BOOL	DoLoop)		/* Should a Phy LoopBac
 	SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_LED_CTRL, LedCtrl);
 
 	if ((pAC->GIni.GILedBlinkCtrl & SK_LED_LINK100_ON) != 0) {
-		/* only in forced 100Mbps mode */
+		/* only in forced 100 Mbps mode */
 		if (!AutoNeg && pPrt->PLinkSpeed == SK_LSPEED_100MBPS) {
 
 			SkGmPhyWrite(pAC, IoC, Port, PHY_MARV_LED_OVER,
@@ -2741,7 +3142,7 @@ SK_BOOL	DoLoop)		/* Should a Phy LoopBac
 	/* Read AutoNeg Advertisement Register */
 	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_AUNE_ADV, &AutoNegAdv);
 	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
-		("Auto-Neg. Ad.=0x%04X\n", AutoNegAdv));
+		("Auto-Neg.Adv.=0x%04X\n", AutoNegAdv));
 	
 	/* Read Ext. PHY Specific Control */
 	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_EXT_CTRL, &ExtPhyCtrl);
@@ -2818,13 +3219,15 @@ SK_BOOL	DoLoop)		/* Should a Phy LoopBac
 	/* Auto-negotiation ? */
 	if (pPrt->PLinkMode == SK_LMODE_HALF || pPrt->PLinkMode == SK_LMODE_FULL) {
 		/*
-		 * level one spec say: "1000Mbps: manual mode not allowed"
+		 * level one spec say: "1000 Mbps: manual mode not allowed"
 		 * but lets see what happens...
 		 */
 		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
 			("InitPhyLone: no auto-negotiation Port %d\n", Port));
 		/* Set DuplexMode in Config register */
-		Ctrl1 = (pPrt->PLinkMode == SK_LMODE_FULL ? PHY_CT_DUP_MD : 0);
+		if (pPrt->PLinkMode == SK_LMODE_FULL) {
+			Ctrl1 |= PHY_CT_DUP_MD;
+		}
 
 		/* Determine Master/Slave manually if not already done */
 		if (pPrt->PMSMode == SK_MS_MODE_AUTO) {
@@ -2857,6 +3260,7 @@ SK_BOOL	DoLoop)		/* Should a Phy LoopBac
 				SKERR_HWI_E015MSG);
 		}
 
+		/* Set Flow-control capabilities */
 		switch (pPrt->PFlowCtrlMode) {
 		case SK_FLOW_MODE_NONE:
 			Ctrl3 |= PHY_L_P_NO_PAUSE;
@@ -2877,7 +3281,6 @@ SK_BOOL	DoLoop)		/* Should a Phy LoopBac
 
 		/* Restart Auto-negotiation */
 		Ctrl1 = PHY_CT_ANE | PHY_CT_RE_CFG;
-
 	}
 	
 	/* Write 1000Base-T Control Register */
@@ -3019,10 +3422,10 @@ int		Port)		/* Port Index (MAC_1 + n) */
 
 	/* Check Duplex mismatch */
 	if ((ResAb & (PHY_X_RS_HD | PHY_X_RS_FD)) == PHY_X_RS_FD) {
-		pPrt->PLinkModeStatus = SK_LMODE_STAT_AUTOFULL;
+		pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_AUTOFULL;
 	}
 	else if ((ResAb & (PHY_X_RS_HD | PHY_X_RS_FD)) == PHY_X_RS_HD) {
-		pPrt->PLinkModeStatus = SK_LMODE_STAT_AUTOHALF;
+		pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_AUTOHALF;
 	}
 	else {
 		/* Error */
@@ -3055,7 +3458,7 @@ int		Port)		/* Port Index (MAC_1 + n) */
 		/* PAUSE mismatch -> no PAUSE */
 		pPrt->PFlowCtrlStatus = SK_FLOW_STAT_NONE;
 	}
-	pPrt->PLinkSpeedUsed = SK_LSPEED_STAT_1000MBPS;
+	pPrt->PLinkSpeedUsed = (SK_U8)SK_LSPEED_STAT_1000MBPS;
 
 	return(SK_AND_OK);
 }	/* SkXmAutoNegDoneXmac */
@@ -3110,10 +3513,10 @@ int		Port)		/* Port Index (MAC_1 + n) */
 
 	/* Check Duplex mismatch */
 	if ((AuxStat & PHY_B_AS_AN_RES_MSK) == PHY_B_RES_1000FD) {
-		pPrt->PLinkModeStatus = SK_LMODE_STAT_AUTOFULL;
+		pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_AUTOFULL;
 	}
 	else if ((AuxStat & PHY_B_AS_AN_RES_MSK) == PHY_B_RES_1000HD) {
-		pPrt->PLinkModeStatus = SK_LMODE_STAT_AUTOHALF;
+		pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_AUTOHALF;
 	}
 	else {
 		/* Error */
@@ -3156,7 +3559,7 @@ int		Port)		/* Port Index (MAC_1 + n) */
 		/* PAUSE mismatch -> no PAUSE */
 		pPrt->PFlowCtrlStatus = SK_FLOW_STAT_NONE;
 	}
-	pPrt->PLinkSpeedUsed = SK_LSPEED_STAT_1000MBPS;
+	pPrt->PLinkSpeedUsed = (SK_U8)SK_LSPEED_STAT_1000MBPS;
 
 	return(SK_AND_OK);
 }	/* SkXmAutoNegDoneBcom */
@@ -3192,6 +3595,8 @@ int		Port)		/* Port Index (MAC_1 + n) */
 
 	/* Get PHY parameters */
 	SkGmPhyRead(pAC, IoC, Port, PHY_MARV_AUNE_LP, &LPAb);
+	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
+		("Link P.Abil.=0x%04X\n", LPAb));
 	
 	if ((LPAb & PHY_M_AN_RF) != 0) {
 		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
@@ -3222,15 +3627,15 @@ int		Port)		/* Port Index (MAC_1 + n) */
 		SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
 			("AutoNegFail: Speed & Duplex not resolved, Port %d\n", Port));
 		pPrt->PAutoNegFail = SK_TRUE;
-		pPrt->PLinkModeStatus = SK_LMODE_STAT_UNKNOWN;
+		pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_UNKNOWN;
 		return(SK_AND_DUP_CAP);
 	}
 	
 	if ((AuxStat & PHY_M_PS_FULL_DUP) != 0) {
-		pPrt->PLinkModeStatus = SK_LMODE_STAT_AUTOFULL;
+		pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_AUTOFULL;
 	}
 	else {
-		pPrt->PLinkModeStatus = SK_LMODE_STAT_AUTOHALF;
+		pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_AUTOHALF;
 	}
 	
 	/* Check PAUSE mismatch ??? */
@@ -3255,13 +3660,13 @@ int		Port)		/* Port Index (MAC_1 + n) */
 	/* set used link speed */
 	switch ((unsigned)(AuxStat & PHY_M_PS_SPEED_MSK)) {
 	case (unsigned)PHY_M_PS_SPEED_1000:
-		pPrt->PLinkSpeedUsed = SK_LSPEED_STAT_1000MBPS;
+		pPrt->PLinkSpeedUsed = (SK_U8)SK_LSPEED_STAT_1000MBPS;
 		break;
 	case PHY_M_PS_SPEED_100:
-		pPrt->PLinkSpeedUsed = SK_LSPEED_STAT_100MBPS;
+		pPrt->PLinkSpeedUsed = (SK_U8)SK_LSPEED_STAT_100MBPS;
 		break;
 	default:
-		pPrt->PLinkSpeedUsed = SK_LSPEED_STAT_10MBPS;
+		pPrt->PLinkSpeedUsed = (SK_U8)SK_LSPEED_STAT_10MBPS;
 	}
 
 	return(SK_AND_OK);
@@ -3312,10 +3717,10 @@ int		Port)		/* Port Index (MAC_1 + n) */
 
 	/* Check Duplex mismatch */
 	if ((QuickStat & PHY_L_QS_DUP_MOD) != 0) {
-		pPrt->PLinkModeStatus = SK_LMODE_STAT_AUTOFULL;
+		pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_AUTOFULL;
 	}
 	else {
-		pPrt->PLinkModeStatus = SK_LMODE_STAT_AUTOHALF;
+		pPrt->PLinkModeStatus = (SK_U8)SK_LMODE_STAT_AUTOHALF;
 	}
 	
 	/* Check Master/Slave resolution */
@@ -3338,6 +3743,7 @@ int		Port)		/* Port Index (MAC_1 + n) */
 	/* We are using IEEE 802.3z/D5.0 Table 37-4 */
 	/* we must manually resolve the abilities here */
 	pPrt->PFlowCtrlStatus = SK_FLOW_STAT_NONE;
+	
 	switch (pPrt->PFlowCtrlMode) {
 	case SK_FLOW_MODE_NONE:
 		/* default */
@@ -3457,6 +3863,9 @@ int		Port)		/* Port Index (MAC_1 + n) */
 		return(Rtv);
 	}
 
+	SK_DBG_MSG(pAC, SK_DBGMOD_HWM, SK_DBGCAT_CTRL,
+		("AutoNeg done Port %d\n", Port));
+	
 	/* We checked everything and may now enable the link */
 	pPrt->PAutoNegFail = SK_FALSE;
 
diff -puN drivers/net/starfire.c~linus drivers/net/starfire.c
--- 25/drivers/net/starfire.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/starfire.c	2004-01-19 22:17:22.000000000 -0800
@@ -139,7 +139,6 @@ TODO:	bugfixes (no bugs known as of righ
 #include <linux/config.h>
 #include <linux/version.h>
 #include <linux/module.h>
-#include <asm/io.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/netdevice.h>
diff -puN drivers/net/stnic.c~linus drivers/net/stnic.c
--- 25/drivers/net/stnic.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/stnic.c	2004-01-19 22:17:22.000000000 -0800
@@ -306,12 +306,12 @@ stnic_init (struct net_device *dev)
 }
 
 /* Hardware interrupt handler.  */
-extern void ei_interrupt (int irq, void *dev_id, struct pt_regs *regs);
+irqreturn_t ei_interrupt (int irq, void *dev_id, struct pt_regs *regs);
 
-void
+irqreturn_t
 do_stnic_intr (int irq, void *dev_id, struct pt_regs *regs)
 {
-  ei_interrupt (0, stnic_dev, regs);
+  return ei_interrupt (0, stnic_dev, regs);
 }
 
 module_init(stnic_probe);
diff -puN drivers/net/tokenring/olympic.c~linus drivers/net/tokenring/olympic.c
--- 25/drivers/net/tokenring/olympic.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/tokenring/olympic.c	2004-01-19 22:17:22.000000000 -0800
@@ -468,14 +468,7 @@ static int olympic_open(struct net_devic
 	printk("Before the open command \n");
 #endif	
 	do {
-		int i;
-
-		for(i=0;i<SRB_COMMAND_SIZE;i+=4)
-			writel(0,init_srb+i);
-		if(SRB_COMMAND_SIZE & 2)
-			writew(0,init_srb+(SRB_COMMAND_SIZE & ~3));
-		if(SRB_COMMAND_SIZE & 1)
-			writeb(0,init_srb+(SRB_COMMAND_SIZE & ~1));
+		memset_io(init_srb,0,SRB_COMMAND_SIZE);
 
 		writeb(SRB_OPEN_ADAPTER,init_srb) ; 	/* open */
 		writeb(OLYMPIC_CLEAR_RET_CODE,init_srb+2);
diff -puN drivers/net/tokenring/smctr.c~linus drivers/net/tokenring/smctr.c
--- 25/drivers/net/tokenring/smctr.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/tokenring/smctr.c	2004-01-19 22:17:22.000000000 -0800
@@ -729,10 +729,6 @@ static int smctr_close(struct net_device
 
 	netif_stop_queue(dev);
 	
-#ifdef MODULE
-        MOD_DEC_USE_COUNT;
-#endif
-
 	tp->cleanup = 1;
 
         /* Check to see if adapter is already in a closed state. */
@@ -3490,10 +3486,6 @@ static int smctr_open(struct net_device 
         if(err < 0)
                 return (err);
 
-#ifdef MODULE
-        MOD_INC_USE_COUNT;
-#endif
-
         return (err);
 }
 
diff -puN drivers/net/wan/farsync.c~linus drivers/net/wan/farsync.c
--- 25/drivers/net/wan/farsync.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/wan/farsync.c	2004-01-19 22:17:22.000000000 -0800
@@ -1313,8 +1313,6 @@ fst_open ( struct net_device *dev )
         if ( err )
                 return err;
 
-        MOD_INC_USE_COUNT;
-
         fst_openport ( dev_to_port ( dev ));
         netif_wake_queue ( dev );
         return 0;
@@ -1326,7 +1324,6 @@ fst_close ( struct net_device *dev )
         netif_stop_queue ( dev );
         fst_closeport ( dev_to_port ( dev ));
         hdlc_close ( dev_to_hdlc  ( dev ));
-        MOD_DEC_USE_COUNT;
         return 0;
 }
 
diff -puN drivers/net/wan/hd64572.h~linus drivers/net/wan/hd64572.h
--- 25/drivers/net/wan/hd64572.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/wan/hd64572.h	2004-01-19 22:17:22.000000000 -0800
@@ -23,8 +23,8 @@
  *
  */
 
-#ifndef _HD64572_H
-#define _HD64572_H
+#ifndef __HD64572_H
+#define __HD64572_H
 
 /* Illegal Access Register */
 #define	ILAR	0x00
@@ -59,6 +59,9 @@
 #define IR0_M(val, chan)	((val)<<(8*(chan)))		/* Int MSCI */
 
 /* MSCI Channel Registers */
+#define MSCI0_OFFSET 0x00
+#define MSCI1_OFFSET 0x80
+
 #define MD0	0x138	/* Mode reg 0 */
 #define MD1	0x139	/* Mode reg 1 */
 #define MD2	0x13a	/* Mode reg 2 */
@@ -107,6 +110,11 @@
 #define RCR	0x156	/* Rx DMA Critical Request Reg */
 
 /* Timer Registers */
+#define TIMER0RX_OFFSET 0x00
+#define TIMER0TX_OFFSET 0x10
+#define TIMER1RX_OFFSET 0x20
+#define TIMER1TX_OFFSET 0x30
+
 #define TCNTL	0x200	/* Timer Upcounter L */
 #define TCNTH	0x201	/* Timer Upcounter H */
 #define TCONRL	0x204	/* Timer Constant Register L */
@@ -132,6 +140,11 @@
 #define DCR_TX(chan)	(0x59 + 2*chan)	/* DMA Command Reg (Tx) */
 
 /* DMA Channel Registers */
+#define DMAC0RX_OFFSET 0x00
+#define DMAC0TX_OFFSET 0x20
+#define DMAC1RX_OFFSET 0x40
+#define DMAC1TX_OFFSET 0x60
+
 #define DARL	0x80	/* Dest Addr Register L (single-block, RX only) */
 #define DARH	0x81	/* Dest Addr Register H (single-block, RX only) */
 #define DARB	0x82	/* Dest Addr Register B (single-block, RX only) */
@@ -166,7 +179,17 @@ typedef struct {
 	unsigned char	filler[5];	/* alignment filler (16 bytes) */ 
 } pcsca_bd_t;
 
-/* 
+/* Block Descriptor Structure */
+typedef struct {
+	u32 cp;			/* pointer to next block descriptor */
+	u32 bp;			/* buffer pointer */
+	u16 len;		/* data length */
+	u8 stat;		/* status */
+	u8 unused;		/* pads to 4-byte boundary */
+}pkt_desc;
+
+
+/*
 	Descriptor Status definitions:
 
 	Bit	Transmission	Reception
@@ -190,6 +213,23 @@ typedef struct {
 #define DST_SHRT	0x40	/* Short Frame  */
 #define DST_EOM		0x80	/* End of Message  */
 
+/* Packet Descriptor Status bits */
+
+#define ST_TX_EOM     0x80	/* End of frame */
+#define ST_TX_UNDRRUN 0x08
+#define ST_TX_OWNRSHP 0x02
+#define ST_TX_EOT     0x01	/* End of transmition */
+
+#define ST_RX_EOM     0x80	/* End of frame */
+#define ST_RX_SHORT   0x40	/* Short frame */
+#define ST_RX_ABORT   0x20	/* Abort */
+#define ST_RX_RESBIT  0x10	/* Residual bit */
+#define ST_RX_OVERRUN 0x08	/* Overrun */
+#define ST_RX_CRC     0x04	/* CRC */
+#define ST_RX_OWNRSHP 0x02
+
+#define ST_ERROR_MASK 0x7C
+
 /* Status Counter Registers */
 #define CMCR	0x158	/* Counter Master Ctl Reg */
 #define TECNTL	0x160	/* Tx EOM Counter L */
@@ -246,11 +286,25 @@ typedef struct {
 #define MD0_BIT_SYNC	0x80
 #define MD0_TRANSP	0xc0
 
+#define MD0_HDLC        0x80	/* Bit-sync HDLC mode */
+
+#define MD0_CRC_NONE	0x00
+#define MD0_CRC_16_0	0x04
+#define MD0_CRC_16	0x05
+#define MD0_CRC_ITU32	0x06
+#define MD0_CRC_ITU	0x07
+
 #define MD1_NOADDR	0x00
 #define MD1_SADDR1	0x40
 #define MD1_SADDR2	0x80
 #define MD1_DADDR	0xc0
 
+#define MD2_NRZI_IEEE	0x40
+#define MD2_MANCHESTER	0x80
+#define MD2_FM_MARK	0xA0
+#define MD2_FM_SPACE	0xC0
+#define MD2_LOOPBACK	0x03	/* Local data Loopback */
+
 #define MD2_F_DUPLEX	0x00
 #define MD2_AUTO_ECHO	0x01
 #define MD2_LOOP_HI_Z	0x02
@@ -274,6 +328,10 @@ typedef struct {
 #define CTL_URSKP	0x40
 #define CTL_URCT	0x80
 
+#define CTL_NORTS	0x01
+#define CTL_NODTR	0x02
+#define CTL_IDLE	0x10
+
 #define	RXS_BR0		0x01
 #define	RXS_BR1		0x02
 #define	RXS_BR2		0x04
@@ -302,6 +360,12 @@ typedef struct {
 #define	EXS_TES1	0x20
 #define	EXS_TES2	0x40
 
+#define CLK_BRG_MASK	0x0F
+#define CLK_PIN_OUT	0x80
+#define CLK_LINE    	0x00	/* clock line input */
+#define CLK_BRG     	0x40	/* internal baud rate generator */
+#define CLK_TX_RXCLK	0x60	/* TX clock from RX clock */
+
 #define CMD_RX_RST	0x11
 #define CMD_RX_ENA	0x12
 #define CMD_RX_DIS	0x13
@@ -324,6 +388,10 @@ typedef struct {
 #define CMD_SRCH_MODE	0x31
 #define CMD_NOP		0x00
 
+#define CMD_RESET	0x21
+#define CMD_TX_ENABLE	0x02
+#define CMD_RX_ENABLE	0x12
+
 #define ST0_RXRDY	0x01
 #define ST0_TXRDY	0x02
 #define ST0_RXINTB	0x20
@@ -374,6 +442,8 @@ typedef struct {
 #define IE0_RXINTB	0x20
 #define IE0_RXINTA	0x40
 #define IE0_TXINT	0x80
+#define IE0_UDRN	0x00008000 /* TX underrun MSCI interrupt enable */
+#define IE0_CDCD	0x00000400 /* CD level change interrupt enable */
 
 #define IE1_IDLD	0x01
 #define IE1_ABTD	0x02
@@ -424,14 +494,28 @@ typedef struct {
 #define DIR_EOM		0x40
 #define DIR_EOT		0x80
 
+#define DIR_REFE	0x04
+#define DIR_UDRFE	0x04
+#define DIR_COAE	0x08
+#define DIR_COFE	0x10
+#define DIR_BOFE	0x20
+#define DIR_EOME	0x40
+#define DIR_EOTE	0x80
+
 #define DMR_CNTE	0x02
 #define DMR_NF		0x04
 #define DMR_SEOME	0x08
 #define DMR_TMOD	0x10
 
+#define DMER_DME        0x80	/* DMA Master Enable */
+
 #define DCR_SW_ABT	0x01
 #define DCR_FCT_CLR	0x02
 
+#define DCR_ABORT	0x01
+#define DCR_CLEAR_EOF	0x02
+
+#define PCR_COTE	0x80
 #define PCR_PR0		0x01
 #define PCR_PR1		0x02
 #define PCR_PR2		0x04
@@ -440,4 +524,4 @@ typedef struct {
 #define PCR_OSB		0x40
 #define PCR_BURST	0x80
 
-#endif /* (_HD64572_H) */
+#endif /* (__HD64572_H) */
diff -puN drivers/net/wan/Kconfig~linus drivers/net/wan/Kconfig
--- 25/drivers/net/wan/Kconfig~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/wan/Kconfig	2004-01-19 22:17:22.000000000 -0800
@@ -325,6 +325,21 @@ config HDLC_X25
 comment "X.25/LAPB support is disabled"
 	depends on WAN && HDLC && (LAPB!=m || HDLC!=m) && LAPB!=y
 
+config PCI200SYN
+	tristate "Goramo PCI200SYN support"
+	depends on HDLC && PCI
+	help
+	  This driver is for PCI200SYN cards made by Goramo sp. j.
+	  If you have such a card, say Y here and see
+	  <http://hq.pm.waw.pl/pub/hdlc/>
+
+	  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 pci200syn.
+
+	  If unsure, say N here.
+
 config WANXL
 	tristate "SBE Inc. wanXL support"
 	depends on HDLC && PCI
diff -puN drivers/net/wan/lapbether.c~linus drivers/net/wan/lapbether.c
--- 25/drivers/net/wan/lapbether.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/wan/lapbether.c	2004-01-19 22:17:22.000000000 -0800
@@ -448,22 +448,12 @@ static char banner[] __initdata = KERN_I
 
 static int __init lapbeth_init_driver(void)
 {
-	struct net_device *dev;
-
 	dev_add_pack(&lapbeth_packet_type);
 
 	register_netdevice_notifier(&lapbeth_dev_notifier);
 
 	printk(banner);
 
-	rtnl_lock();
-	for (dev = dev_base; dev; dev = dev->next) {
-		if (dev_is_ethdev(dev)) {
-			lapbeth_new_device(dev);
-		}
-	}
-	rtnl_unlock();
-
 	return 0;
 }
 module_init(lapbeth_init_driver);
diff -puN drivers/net/wan/Makefile~linus drivers/net/wan/Makefile
--- 25/drivers/net/wan/Makefile~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/wan/Makefile	2004-01-19 22:17:22.000000000 -0800
@@ -67,6 +67,7 @@ endif
 obj-$(CONFIG_N2)		+= n2.o
 obj-$(CONFIG_C101)		+= c101.o
 obj-$(CONFIG_WANXL)		+= wanxl.o
+obj-$(CONFIG_PCI200SYN)		+= pci200syn.o
 
 ifeq ($(CONFIG_WANXL_BUILD_FIRMWARE),y)
 ifeq ($(ARCH),m68k)
diff -puN drivers/net/wan/pc300_drv.c~linus drivers/net/wan/pc300_drv.c
--- 25/drivers/net/wan/pc300_drv.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/wan/pc300_drv.c	2004-01-19 22:17:22.000000000 -0800
@@ -3165,7 +3165,6 @@ int cpc_open(struct net_device *dev)
 		return result;
 	}
 
-	MOD_INC_USE_COUNT;
 	sprintf(ifr.ifr_name, "%s", dev->name);
 	cpc_opench(d);
 	netif_start_queue(dev);
@@ -3201,7 +3200,6 @@ int cpc_close(struct net_device *dev)
 	}
 #endif
 
-	MOD_DEC_USE_COUNT;
 	return 0;
 }
 
diff -puN /dev/null drivers/net/wan/pci200syn.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/net/wan/pci200syn.c	2004-01-19 22:17:22.000000000 -0800
@@ -0,0 +1,475 @@
+/*
+ * Goramo PCI200SYN synchronous serial card driver for Linux
+ *
+ * Copyright (C) 2002-2003 Krzysztof Halasa <khc@pm.waw.pl>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * For information see http://hq.pm.waw.pl/hdlc/
+ *
+ * Sources of information:
+ *    Hitachi HD64572 SCA-II User's Manual
+ *    PLX Technology Inc. PCI9052 Data Book
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include <linux/types.h>
+#include <linux/fcntl.h>
+#include <linux/in.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/moduleparam.h>
+#include <linux/netdevice.h>
+#include <linux/hdlc.h>
+#include <linux/pci.h>
+#include <asm/delay.h>
+#include <asm/io.h>
+
+#include "hd64572.h"
+
+static const char* version = "Goramo PCI200SYN driver version: 1.16";
+static const char* devname = "PCI200SYN";
+
+#undef DEBUG_PKT
+#define DEBUG_RINGS
+
+#define PCI200SYN_PLX_SIZE	0x80	/* PLX control window size (128b) */
+#define PCI200SYN_SCA_SIZE	0x400	/* SCA window size (1Kb) */
+#define ALL_PAGES_ALWAYS_MAPPED
+#define NEED_DETECT_RAM
+#define NEED_SCA_MSCI_INTR
+#define MAX_TX_BUFFERS		10
+
+static int pci_clock_freq = 33000000;
+#define CLOCK_BASE pci_clock_freq
+
+#define PCI_VENDOR_ID_GORAMO	0x10B5	/* uses PLX:9050 ID - this card	*/
+#define PCI_DEVICE_ID_PCI200SYN	0x9050	/* doesn't have its own ID	*/
+
+
+/*
+ *      PLX PCI9052 local configuration and shared runtime registers.
+ *      This structure can be used to access 9052 registers (memory mapped).
+ */
+typedef struct {
+	u32 loc_addr_range[4];	/* 00-0Ch : Local Address Ranges */
+	u32 loc_rom_range;	/* 10h : Local ROM Range */
+	u32 loc_addr_base[4];	/* 14-20h : Local Address Base Addrs */
+	u32 loc_rom_base;	/* 24h : Local ROM Base */
+	u32 loc_bus_descr[4];	/* 28-34h : Local Bus Descriptors */
+	u32 rom_bus_descr;	/* 38h : ROM Bus Descriptor */
+	u32 cs_base[4];		/* 3C-48h : Chip Select Base Addrs */
+	u32 intr_ctrl_stat;	/* 4Ch : Interrupt Control/Status */
+	u32 init_ctrl;		/* 50h : EEPROM ctrl, Init Ctrl, etc */
+}plx9052;
+
+
+
+typedef struct port_s {
+	hdlc_device hdlc;	/* HDLC device struct - must be first */
+	struct card_s *card;
+	spinlock_t lock;	/* TX lock */
+	sync_serial_settings settings;
+	int rxpart;		/* partial frame received, next frame invalid*/
+	unsigned short encoding;
+	unsigned short parity;
+	u16 rxin;		/* rx ring buffer 'in' pointer */
+	u16 txin;		/* tx ring buffer 'in' and 'last' pointers */
+	u16 txlast;
+	u8 rxs, txs, tmc;	/* SCA registers */
+	u8 phy_node;		/* physical port # - 0 or 1 */
+}port_t;
+
+
+
+typedef struct card_s {
+	u8* rambase;		/* buffer memory base (virtual) */
+	u8* scabase;		/* SCA memory base (virtual) */
+	plx9052* plxbase;	/* PLX registers memory base (virtual) */
+	u16 rx_ring_buffers;	/* number of buffers in a ring */
+	u16 tx_ring_buffers;
+	u16 buff_offset;	/* offset of first buffer of first channel */
+	u8 irq;			/* interrupt request level */
+
+	port_t ports[2];
+}card_t;
+
+
+#define sca_in(reg, card)	     readb(card->scabase + (reg))
+#define sca_out(value, reg, card)    writeb(value, card->scabase + (reg))
+#define sca_inw(reg, card)	     readw(card->scabase + (reg))
+#define sca_outw(value, reg, card)   writew(value, card->scabase + (reg))
+#define sca_inl(reg, card)	     readl(card->scabase + (reg))
+#define sca_outl(value, reg, card)   writel(value, card->scabase + (reg))
+
+#define port_to_card(port)	     (port->card)
+#define log_node(port)		     (port->phy_node)
+#define phy_node(port)		     (port->phy_node)
+#define winbase(card)		     (card->rambase)
+#define get_port(card, port)	     (&card->ports[port])
+#define sca_flush(card)		     (sca_in(IER0, card));
+
+static inline void new_memcpy_toio(char *dest, char *src, int length)
+{
+	int len;
+	do {
+		len = length > 256 ? 256 : length;
+		memcpy_toio(dest, src, len);
+		dest += len;
+		src += len;
+		length -= len;
+		readb(dest);
+	} while (len);
+}
+
+#undef memcpy_toio
+#define memcpy_toio new_memcpy_toio
+
+#include "hd6457x.c"
+
+
+static void pci200_set_iface(port_t *port)
+{
+	card_t *card = port->card;
+	u16 msci = get_msci(port);
+	u8 rxs = port->rxs & CLK_BRG_MASK;
+	u8 txs = port->txs & CLK_BRG_MASK;
+
+	sca_out(EXS_TES1, (phy_node(port) ? MSCI1_OFFSET : MSCI0_OFFSET) + EXS,
+		port_to_card(port));
+	switch(port->settings.clock_type) {
+	case CLOCK_INT:
+		rxs |= CLK_BRG; /* BRG output */
+		txs |= CLK_PIN_OUT | CLK_TX_RXCLK; /* RX clock */
+		break;
+
+	case CLOCK_TXINT:
+		rxs |= CLK_LINE; /* RXC input */
+		txs |= CLK_PIN_OUT | CLK_BRG; /* BRG output */
+		break;
+
+	case CLOCK_TXFROMRX:
+		rxs |= CLK_LINE; /* RXC input */
+		txs |= CLK_PIN_OUT | CLK_TX_RXCLK; /* RX clock */
+		break;
+
+	default:		/* EXTernal clock */
+		rxs |= CLK_LINE; /* RXC input */
+		txs |= CLK_PIN_OUT | CLK_LINE; /* TXC input */
+		break;
+	}
+
+	port->rxs = rxs;
+	port->txs = txs;
+	sca_out(rxs, msci + RXS, card);
+	sca_out(txs, msci + TXS, card);
+	sca_set_port(port);
+}
+
+
+
+static int pci200_open(struct net_device *dev)
+{
+	hdlc_device *hdlc = dev_to_hdlc(dev);
+	port_t *port = hdlc_to_port(hdlc);
+
+	int result = hdlc_open(hdlc);
+	if (result)
+		return result;
+
+	sca_open(hdlc);
+	pci200_set_iface(port);
+	sca_flush(port_to_card(port));
+	return 0;
+}
+
+
+
+static int pci200_close(struct net_device *dev)
+{
+	hdlc_device *hdlc = dev_to_hdlc(dev);
+	sca_close(hdlc);
+	sca_flush(port_to_card(dev_to_port(dev)));
+	hdlc_close(hdlc);
+	return 0;
+}
+
+
+
+static int pci200_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+{
+	const size_t size = sizeof(sync_serial_settings);
+	sync_serial_settings new_line, *line = ifr->ifr_settings.ifs_ifsu.sync;
+	hdlc_device *hdlc = dev_to_hdlc(dev);
+	port_t *port = hdlc_to_port(hdlc);
+
+#ifdef DEBUG_RINGS
+	if (cmd == SIOCDEVPRIVATE) {
+		sca_dump_rings(hdlc);
+		return 0;
+	}
+#endif
+	if (cmd != SIOCWANDEV)
+		return hdlc_ioctl(dev, ifr, cmd);
+
+	switch(ifr->ifr_settings.type) {
+	case IF_GET_IFACE:
+		ifr->ifr_settings.type = IF_IFACE_V35;
+		if (ifr->ifr_settings.size < size) {
+			ifr->ifr_settings.size = size; /* data size wanted */
+			return -ENOBUFS;
+		}
+		if (copy_to_user(line, &port->settings, size))
+			return -EFAULT;
+		return 0;
+
+	case IF_IFACE_V35:
+	case IF_IFACE_SYNC_SERIAL:
+		if (!capable(CAP_NET_ADMIN))
+			return -EPERM;
+
+		if (copy_from_user(&new_line, line, size))
+			return -EFAULT;
+
+		if (new_line.clock_type != CLOCK_EXT &&
+		    new_line.clock_type != CLOCK_TXFROMRX &&
+		    new_line.clock_type != CLOCK_INT &&
+		    new_line.clock_type != CLOCK_TXINT)
+		return -EINVAL;	/* No such clock setting */
+
+		if (new_line.loopback != 0 && new_line.loopback != 1)
+			return -EINVAL;
+
+		memcpy(&port->settings, &new_line, size); /* Update settings */
+		pci200_set_iface(port);
+		sca_flush(port_to_card(port));
+		return 0;
+
+	default:
+		return hdlc_ioctl(dev, ifr, cmd);
+	}
+}
+
+
+
+static void pci200_pci_remove_one(struct pci_dev *pdev)
+{
+	int i;
+	card_t *card = pci_get_drvdata(pdev);
+
+	for(i = 0; i < 2; i++)
+		if (card->ports[i].card)
+			unregister_hdlc_device(&card->ports[i].hdlc);
+
+	if (card->irq)
+		free_irq(card->irq, card);
+
+	if (card->rambase)
+		iounmap(card->rambase);
+	if (card->scabase)
+		iounmap(card->scabase);
+	if (card->plxbase)
+		iounmap(card->plxbase);
+
+	pci_release_regions(pdev);
+	pci_disable_device(pdev);
+	pci_set_drvdata(pdev, NULL);
+	kfree(card);
+}
+
+
+
+static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
+					 const struct pci_device_id *ent)
+{
+	card_t *card;
+	u8 rev_id;
+	u32 *p;
+	int i;
+	u32 ramsize;
+	u32 ramphys;		/* buffer memory base */
+	u32 scaphys;		/* SCA memory base */
+	u32 plxphys;		/* PLX registers memory base */
+
+#ifndef MODULE
+	static int printed_version;
+	if (!printed_version++)
+		printk(KERN_INFO "%s\n", version);
+#endif
+
+	i = pci_enable_device(pdev);
+	if (i)
+		return i;
+
+	i = pci_request_regions(pdev, "PCI200SYN");
+	if (i) {
+		pci_disable_device(pdev);
+		return i;
+	}
+
+	card = kmalloc(sizeof(card_t), GFP_KERNEL);
+	if (card == NULL) {
+		printk(KERN_ERR "pci200syn: unable to allocate memory\n");
+		pci_release_regions(pdev);
+		pci_disable_device(pdev);
+		return -ENOBUFS;
+	}
+	memset(card, 0, sizeof(card_t));
+	pci_set_drvdata(pdev, card);
+
+	pci_read_config_byte(pdev, PCI_REVISION_ID, &rev_id);
+	if (pci_resource_len(pdev, 0) != PCI200SYN_PLX_SIZE ||
+	    pci_resource_len(pdev, 2) != PCI200SYN_SCA_SIZE ||
+	    pci_resource_len(pdev, 3) < 16384) {
+		printk(KERN_ERR "pci200syn: invalid card EEPROM parameters\n");
+		pci200_pci_remove_one(pdev);
+		return -EFAULT;
+	}
+
+	plxphys = pci_resource_start(pdev,0) & PCI_BASE_ADDRESS_MEM_MASK;
+	card->plxbase = ioremap(plxphys, PCI200SYN_PLX_SIZE);
+
+	scaphys = pci_resource_start(pdev,2) & PCI_BASE_ADDRESS_MEM_MASK;
+	card->scabase = ioremap(scaphys, PCI200SYN_SCA_SIZE);
+
+	ramphys = pci_resource_start(pdev,3) & PCI_BASE_ADDRESS_MEM_MASK;
+	card->rambase = ioremap(ramphys, pci_resource_len(pdev,3));
+
+	if (card->plxbase == NULL ||
+	    card->scabase == NULL ||
+	    card->rambase == NULL) {
+		printk(KERN_ERR "pci200syn: ioremap() failed\n");
+		pci200_pci_remove_one(pdev);
+	}
+
+	/* Reset PLX */
+	p = &card->plxbase->init_ctrl;
+	writel(readl(p) | 0x40000000, p);
+	readl(p);		/* Flush the write - do not use sca_flush */
+	udelay(1);
+
+	writel(readl(p) & ~0x40000000, p);
+	readl(p);		/* Flush the write - do not use sca_flush */
+	udelay(1);
+
+	ramsize = sca_detect_ram(card, card->rambase,
+				 pci_resource_len(pdev, 3));
+
+	/* number of TX + RX buffers for one port - this is dual port card */
+	i = ramsize / (2 * (sizeof(pkt_desc) + HDLC_MAX_MRU));
+	card->tx_ring_buffers = min(i / 2, MAX_TX_BUFFERS);
+	card->rx_ring_buffers = i - card->tx_ring_buffers;
+
+	card->buff_offset = 2 * sizeof(pkt_desc) * (card->tx_ring_buffers +
+						    card->rx_ring_buffers);
+
+	printk(KERN_INFO "pci200syn: %u KB RAM at 0x%x, IRQ%u, using %u TX +"
+	       " %u RX packets rings\n", ramsize / 1024, ramphys,
+	       pdev->irq, card->tx_ring_buffers, card->rx_ring_buffers);
+
+	if (card->tx_ring_buffers < 1) {
+		printk(KERN_ERR "pci200syn: RAM test failed\n");
+		pci200_pci_remove_one(pdev);
+		return -EFAULT;
+	}
+
+	/* Enable interrupts on the PCI bridge */
+	p = &card->plxbase->intr_ctrl_stat;
+	writew(readw(p) | 0x0040, p);
+
+	/* Allocate IRQ */
+	if(request_irq(pdev->irq, sca_intr, SA_SHIRQ, devname, card)) {
+		printk(KERN_WARNING "pci200syn: could not allocate IRQ%d.\n",
+		       pdev->irq);
+		pci200_pci_remove_one(pdev);
+		return -EBUSY;
+	}
+	card->irq = pdev->irq;
+
+	sca_init(card, 0);
+
+	for(i = 0; i < 2; i++) {
+		port_t *port = &card->ports[i];
+		struct net_device *dev = hdlc_to_dev(&port->hdlc);
+		port->phy_node = i;
+
+		spin_lock_init(&port->lock);
+		SET_MODULE_OWNER(dev);
+		dev->irq = card->irq;
+		dev->mem_start = ramphys;
+		dev->mem_end = ramphys + ramsize - 1;
+		dev->tx_queue_len = 50;
+		dev->do_ioctl = pci200_ioctl;
+		dev->open = pci200_open;
+		dev->stop = pci200_close;
+		port->hdlc.attach = sca_attach;
+		port->hdlc.xmit = sca_xmit;
+		port->settings.clock_type = CLOCK_EXT;
+		if(register_hdlc_device(&port->hdlc)) {
+			printk(KERN_ERR "pci200syn: unable to register hdlc "
+			       "device\n");
+			pci200_pci_remove_one(pdev);
+			return -ENOBUFS;
+		}
+		port->card = card;
+		sca_init_sync_port(port);	/* Set up SCA memory */
+
+		printk(KERN_INFO "%s: PCI200SYN node %d\n",
+		       hdlc_to_name(&port->hdlc), port->phy_node);
+	}
+
+	sca_flush(card);
+	return 0;
+}
+
+
+
+static struct pci_device_id pci200_pci_tbl[] __devinitdata = {
+	{ PCI_VENDOR_ID_GORAMO, PCI_DEVICE_ID_PCI200SYN, PCI_ANY_ID,
+	  PCI_ANY_ID, 0, 0, 0 },
+	{ 0, }
+};
+
+
+static struct pci_driver pci200_pci_driver = {
+	name:	  "PCI200SYN",
+	id_table: pci200_pci_tbl,
+	probe:	  pci200_pci_init_one,
+	remove:	  pci200_pci_remove_one,
+};
+
+
+static int __init pci200_init_module(void)
+{
+#ifdef MODULE
+	printk(KERN_INFO "%s\n", version);
+#endif
+	if (pci_clock_freq < 1000000 || pci_clock_freq > 80000000) {
+		printk(KERN_ERR "pci200syn: Invalid PCI clock frequency\n");
+		return -EINVAL;
+	}
+	return pci_module_init(&pci200_pci_driver);
+}
+
+
+
+static void __exit pci200_cleanup_module(void)
+{
+	pci_unregister_driver(&pci200_pci_driver);
+}
+
+MODULE_AUTHOR("Krzysztof Halasa <khc@pm.waw.pl>");
+MODULE_DESCRIPTION("Goramo PCI200SYN serial port driver");
+MODULE_LICENSE("GPL v2");
+MODULE_DEVICE_TABLE(pci, pci200_pci_tbl);
+module_param(pci_clock_freq, int, 0444);
+MODULE_PARM_DESC(pci_clock_freq, "System PCI clock frequency in Hz");
+module_init(pci200_init_module);
+module_exit(pci200_cleanup_module);
diff -puN drivers/net/wireless/airo.c~linus drivers/net/wireless/airo.c
--- 25/drivers/net/wireless/airo.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/wireless/airo.c	2004-01-19 22:17:22.000000000 -0800
@@ -1027,7 +1027,6 @@ struct airo_info {
 #define FLAG_802_11	7
 #define FLAG_PENDING_XMIT 9
 #define FLAG_PENDING_XMIT11 10
-#define FLAG_PCI	11
 #define JOB_MASK	0x1ff0000
 #define JOB_DIE		16
 #define JOB_XMIT	17
@@ -4623,7 +4622,6 @@ static int __devinit airo_pci_probe(stru
 		return -ENODEV;
 
 	pci_set_drvdata(pdev, dev);
-	set_bit (FLAG_PCI, &((struct airo_info *)dev->priv)->flags);
 	return 0;
 }
 
@@ -4653,7 +4651,7 @@ static int __init airo_init_module( void
 
 #ifdef CONFIG_PCI
 	printk( KERN_INFO "airo:  Probing for PCI adapters\n" );
-	pci_module_init(&airo_driver);
+	pci_register_driver(&airo_driver);
 	printk( KERN_INFO "airo:  Finished probing for PCI adapters\n" );
 #endif
 
@@ -4665,22 +4663,15 @@ static int __init airo_init_module( void
 
 static void __exit airo_cleanup_module( void )
 {
-	int is_pci = 0;
 	while( airo_devices ) {
 		printk( KERN_INFO "airo: Unregistering %s\n", airo_devices->dev->name );
-#ifdef CONFIG_PCI
-		if (test_bit(FLAG_PCI, &((struct airo_info *)airo_devices->dev->priv)->flags))
-			is_pci = 1;
-#endif
 		stop_airo_card( airo_devices->dev, 1 );
 	}
 	remove_proc_entry("aironet", proc_root_driver);
 
-	if (is_pci) {
 #ifdef CONFIG_PCI
-		pci_unregister_driver(&airo_driver);
+	pci_unregister_driver(&airo_driver);
 #endif
-	}
 }
 
 #ifdef WIRELESS_EXT
diff -puN drivers/net/wireless/airo_cs.c~linus drivers/net/wireless/airo_cs.c
--- 25/drivers/net/wireless/airo_cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/wireless/airo_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -233,7 +233,7 @@ static dev_link_t *airo_attach(void)
 	client_reg.event_handler = &airo_event;
 	client_reg.Version = 0x0210;
 	client_reg.event_callback_args.client_data = link;
-	ret = CardServices(RegisterClient, &link->handle, &client_reg);
+	ret = pcmcia_register_client(&link->handle, &client_reg);
 	if (ret != 0) {
 		cs_error(link->handle, RegisterClient, ret);
 		airo_detach(link);
@@ -277,7 +277,7 @@ static void airo_detach(dev_link_t *link
 	
 	/* Break the link with Card Services */
 	if (link->handle)
-		CardServices(DeregisterClient, link->handle);
+		pcmcia_deregister_client(link->handle);
 	
 	
 	
@@ -298,11 +298,8 @@ static void airo_detach(dev_link_t *link
   
   ======================================================================*/
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn),args))!=0) goto cs_failed
-
-#define CFG_CHECK(fn, args...) \
-if (CardServices(fn, args) != 0) goto next_entry
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static void airo_config(dev_link_t *link)
 {
@@ -329,9 +326,9 @@ static void airo_config(dev_link_t *link
 	tuple.TupleData = buf;
 	tuple.TupleDataMax = sizeof(buf);
 	tuple.TupleOffset = 0;
-	CS_CHECK(GetFirstTuple, handle, &tuple);
-	CS_CHECK(GetTupleData, handle, &tuple);
-	CS_CHECK(ParseTuple, handle, &tuple, &parse);
+	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+	CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+	CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
 	link->conf.ConfigBase = parse.config.base;
 	link->conf.Present = parse.config.rmask[0];
 	
@@ -351,12 +348,13 @@ static void airo_config(dev_link_t *link
 	  will only use the CIS to fill in implementation-defined details.
 	*/
 	tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
-	CS_CHECK(GetFirstTuple, handle, &tuple);
+	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
 	while (1) {
 		cistpl_cftable_entry_t dflt = { 0 };
 		cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
-		CFG_CHECK(GetTupleData, handle, &tuple);
-		CFG_CHECK(ParseTuple, handle, &tuple, &parse);
+		if (pcmcia_get_tuple_data(handle, &tuple) != 0 ||
+				pcmcia_parse_tuple(handle, &tuple, &parse) != 0)
+			goto next_entry;
 		
 		if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg;
 		if (cfg->index == 0) goto next_entry;
@@ -405,7 +403,8 @@ static void airo_config(dev_link_t *link
 		}
 		
 		/* This reserves IO space but doesn't actually enable it */
-		CFG_CHECK(RequestIO, link->handle, &link->io); 
+		if (pcmcia_request_io(link->handle, &link->io) != 0)
+			goto next_entry;
 		
 		/*
 		  Now set up a common memory window, if needed.  There is room
@@ -425,16 +424,17 @@ static void airo_config(dev_link_t *link
 			req.Base = mem->win[0].host_addr;
 			req.Size = mem->win[0].len;
 			req.AccessSpeed = 0;
-			link->win = (window_handle_t)link->handle;
-			CFG_CHECK(RequestWindow, &link->win, &req);
+			if (pcmcia_request_window(&link->handle, &req, &link->win) != 0)
+				goto next_entry;
 			map.Page = 0; map.CardOffset = mem->win[0].card_addr;
-			CFG_CHECK(MapMemPage, link->win, &map);
+			if (pcmcia_map_mem_page(link->win, &map) != 0)
+				goto next_entry;
 		}
 		/* If we got this far, we're cool! */
 		break;
 		
 	next_entry:
-		CS_CHECK(GetNextTuple, handle, &tuple);
+		CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple));
 	}
 	
     /*
@@ -443,14 +443,14 @@ static void airo_config(dev_link_t *link
       irq structure is initialized.
     */
 	if (link->conf.Attributes & CONF_ENABLE_IRQ)
-		CS_CHECK(RequestIRQ, link->handle, &link->irq);
+		CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
 	
 	/*
 	  This actually configures the PCMCIA socket -- setting up
 	  the I/O windows and the interrupt mapping, and putting the
 	  card and host interface into "Memory and IO" mode.
 	*/
-	CS_CHECK(RequestConfiguration, link->handle, &link->conf);
+	CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
 	((local_info_t*)link->priv)->eth_dev = 
 		init_airo_card( link->irq.AssignedIRQ,
 				link->io.BasePort1, 1 );
@@ -526,12 +526,12 @@ static void airo_release(dev_link_t *lin
 	
 	/* Don't bother checking to see if these succeed or not */
 	if (link->win)
-		CardServices(ReleaseWindow, link->win);
-	CardServices(ReleaseConfiguration, link->handle);
+		pcmcia_release_window(link->win);
+	pcmcia_release_configuration(link->handle);
 	if (link->io.NumPorts1)
-		CardServices(ReleaseIO, link->handle, &link->io);
+		pcmcia_release_io(link->handle, &link->io);
 	if (link->irq.AssignedIRQ)
-		CardServices(ReleaseIRQ, link->handle, &link->irq);
+		pcmcia_release_irq(link->handle, &link->irq);
 	link->state &= ~DEV_CONFIG;
 
 	if (link->state & DEV_STALE_CONFIG)
@@ -576,7 +576,7 @@ static int airo_event(event_t event, int
 	case CS_EVENT_RESET_PHYSICAL:
 		if (link->state & DEV_CONFIG) {
 			netif_device_detach(local->eth_dev);
-			CardServices(ReleaseConfiguration, link->handle);
+			pcmcia_release_configuration(link->handle);
 		}
 		break;
 	case CS_EVENT_PM_RESUME:
@@ -584,7 +584,7 @@ static int airo_event(event_t event, int
 		/* Fall through... */
 	case CS_EVENT_CARD_RESET:
 		if (link->state & DEV_CONFIG) {
-			CardServices(RequestConfiguration, link->handle, &link->conf);
+			pcmcia_request_configuration(link->handle, &link->conf);
 			reset_airo_card(local->eth_dev);
 			netif_device_attach(local->eth_dev);
 		}
diff -puN drivers/net/wireless/atmel.c~linus drivers/net/wireless/atmel.c
--- 25/drivers/net/wireless/atmel.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/wireless/atmel.c	2004-01-19 22:17:22.000000000 -0800
@@ -67,7 +67,7 @@
 #include "ieee802_11.h"
 
 #define DRIVER_MAJOR 0
-#define DRIVER_MINOR 8
+#define DRIVER_MINOR 9
 
 MODULE_AUTHOR("Simon Kelley");
 MODULE_DESCRIPTION("Support for Atmel at76c50x 802.11 wireless ethernet cards.");
@@ -153,12 +153,15 @@ module_param(firmware, charp, 0);
 #define C80211_MGMT_ElementID_ChallengeText     16
 #define C80211_MGMT_CAPABILITY_ShortPreamble    0x0020
 
+#define MIB_MAX_DATA_BYTES    212
+#define MIB_HEADER_SIZE       4    /* first four fields */
+
 struct get_set_mib {
         u8 type;
         u8 size;
         u8 index;
         u8 reserved;
-        u8 data[72];
+        u8 data[MIB_MAX_DATA_BYTES];
 };
 
 struct rx_desc {
@@ -195,32 +198,40 @@ struct rx_desc {
 
 
 struct tx_desc {
-   u32       NextDescriptor;
-   u16       TxStartOfFrame;
-   u16       TxLength;
-   
-   u8        TxState;
-   u8        TxStatus;
-   u8        RetryCount;
-
-   u8        TxRate;
-   u32       TxTime;
-   u8        Reserved;
-   u8        PacketType;
-   u16       HostTxLength;
-
+	u32       NextDescriptor;
+	u16       TxStartOfFrame;
+	u16       TxLength;
+	
+	u8        TxState;
+	u8        TxStatus;
+	u8        RetryCount;
+	
+	u8        TxRate;
+
+	u8        KeyIndex;
+	u8        ChiperType;
+	u8        ChipreLength;
+        u8        Reserved1;
+
+	u8        Reserved;
+	u8        PacketType;
+	u16       HostTxLength;
+	
 };
 
 
-#define TX_DESC_NEXT_OFFSET        0
-#define TX_DESC_POS_OFFSET         4
-#define TX_DESC_SIZE_OFFSET        6
-#define TX_DESC_FLAGS_OFFSET       8
-#define TX_DESC_STATUS_OFFSET      9
-#define TX_DESC_RETRY_OFFSET       10
-#define TX_DESC_RATE_OFFSET        11
-#define TX_DESC_PACKET_TYPE_OFFSET 17
-#define TX_DESC_HOST_LENGTH_OFFSET 18
+#define TX_DESC_NEXT_OFFSET          0
+#define TX_DESC_POS_OFFSET           4
+#define TX_DESC_SIZE_OFFSET          6
+#define TX_DESC_FLAGS_OFFSET         8
+#define TX_DESC_STATUS_OFFSET        9
+#define TX_DESC_RETRY_OFFSET         10
+#define TX_DESC_RATE_OFFSET          11
+#define TX_DESC_KEY_INDEX_OFFSET     12
+#define TX_DESC_CIPHER_TYPE_OFFSET   13
+#define TX_DESC_CIPHER_LENGTH_OFFSET 14
+#define TX_DESC_PACKET_TYPE_OFFSET   17
+#define TX_DESC_HOST_LENGTH_OFFSET   18
 
 
 
@@ -324,6 +335,9 @@ struct tx_desc {
 #define ACTIVE_MODE 	1
 #define PS_MODE 	2
 
+#define MAX_ENCRYPTION_KEYS 4
+#define MAX_ENCRYPTION_KEY_SIZE 40
+
 ///////////////////////////////////////////////////////////////////////////
 // 802.11 related definitions
 ///////////////////////////////////////////////////////////////////////////
@@ -370,6 +384,14 @@ struct tx_desc {
 #define IFACE_FUNC_CTRL_OFFSET		28
 #define IFACE_MAC_STAT_OFFSET		30
 #define IFACE_GENERIC_INT_TYPE_OFFSET	32
+
+#define CIPHER_SUITE_NONE     0 
+#define CIPHER_SUITE_WEP_64   1
+#define CIPHER_SUITE_TKIP     2
+#define CIPHER_SUITE_AES      3
+#define CIPHER_SUITE_CCX      4
+#define CIPHER_SUITE_WEP_128  5
+
 //
 // IFACE MACROS & definitions
 //
@@ -432,6 +454,7 @@ struct atmel_private {
 	void *card; /* Bus dependent stucture varies for PCcard */
 	int (*present_callback)(void *); /* And callback which uses it */
 	char firmware_id[32];
+	char firmware_template[32];
 	unsigned char *firmware;
 	int firmware_length;
 	struct timer_list management_timer;
@@ -457,20 +480,11 @@ struct atmel_private {
 	u16 frag_seq, frag_len, frag_no;
 	u8 frag_source[6]; 
 	
-	int wep_key_len[4]; /* need to know these and not stored in Mib. */
-	struct { /* NB this is matched to the hardware, don't change. */
-		u8 wep_is_on;                 
-		u8 default_key; /* 0..3 */
-		u8 reserved;
-		u8 exclude_unencrypted;
-		
-		u32 WEPICV_error_count;
-		u32 WEP_excluded_count;
-		
-		u8 wep_keys[4][13];
-		u8 encryption_level; /* 0, 1, 2 */
-		u8 reserved2[3];
-	} wep;
+	u8 wep_is_on, default_key, exclude_unencrypted, encryption_level;
+	u8 group_cipher_suite, pairwise_cipher_suite;
+	u8 wep_keys[MAX_ENCRYPTION_KEYS][MAX_ENCRYPTION_KEY_SIZE];
+	int wep_key_len[MAX_ENCRYPTION_KEYS]; 
+	int use_wpa;
 
 	u16 host_info_base;
 	struct host_info_struct { 
@@ -510,8 +524,6 @@ struct atmel_private {
 		STATION_STATE_ASSOCIATING,
 		STATION_STATE_READY,
 		STATION_STATE_REASSOCIATING,
-		STATION_STATE_FORCED_JOINNING,
-		STATION_STATE_FORCED_JOIN_FAILURE,
 		STATION_STATE_DOWN,
 		STATION_STATE_NO_CARD,
 		STATION_STATE_MGMT_ERROR 
@@ -564,6 +576,7 @@ struct atmel_private {
 
 static u8 atmel_basic_rates[4] = {0x82,0x84,0x0b,0x16};
 
+static void build_wpa_mib(struct atmel_private *priv);
 static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static void atmel_copy_to_card(struct net_device *dev, u16 dest, unsigned char *src, u16 len);
 static void atmel_copy_to_host(struct net_device *dev, unsigned char *dest, u16 src, u16 len);
@@ -717,14 +730,54 @@ static u16 find_tx_buff(struct atmel_pri
 	return 0;
 }
 
-static void tx_update_descriptor(struct atmel_private *priv, u16 len, u16 buff, u8 type)
+static void tx_update_descriptor(struct atmel_private *priv, int is_bcast, u16 len, u16 buff, u8 type)
 {
 	atmel_wmem16(priv, atmel_tx(priv, TX_DESC_POS_OFFSET, priv->tx_desc_tail), buff);
 	atmel_wmem16(priv, atmel_tx(priv, TX_DESC_SIZE_OFFSET, priv->tx_desc_tail), len);
-	atmel_wmem16(priv, atmel_tx(priv, TX_DESC_HOST_LENGTH_OFFSET, priv->tx_desc_tail), len);
+	if (!priv->use_wpa)
+		atmel_wmem16(priv, atmel_tx(priv, TX_DESC_HOST_LENGTH_OFFSET, priv->tx_desc_tail), len);
 	atmel_wmem8(priv, atmel_tx(priv, TX_DESC_PACKET_TYPE_OFFSET, priv->tx_desc_tail), type);
 	atmel_wmem8(priv, atmel_tx(priv, TX_DESC_RATE_OFFSET, priv->tx_desc_tail), priv->tx_rate);
 	atmel_wmem8(priv, atmel_tx(priv, TX_DESC_RETRY_OFFSET, priv->tx_desc_tail), 0);
+	if (priv->use_wpa) {
+		int cipher_type, cipher_length;
+		if (is_bcast) {
+			cipher_type = priv->group_cipher_suite;
+			if (cipher_type == CIPHER_SUITE_WEP_64 || 
+			    cipher_type == CIPHER_SUITE_WEP_128 )
+				cipher_length = 8;
+			else if (cipher_type == CIPHER_SUITE_TKIP)
+				cipher_length = 12;
+			else if (priv->pairwise_cipher_suite == CIPHER_SUITE_WEP_64 ||
+				 priv->pairwise_cipher_suite == CIPHER_SUITE_WEP_128) {
+				cipher_type = priv->pairwise_cipher_suite;
+				cipher_length = 8;
+			} else {
+				cipher_type = CIPHER_SUITE_NONE;
+				cipher_length = 0;
+			}
+		} else {
+			cipher_type = priv->pairwise_cipher_suite;
+			if (cipher_type == CIPHER_SUITE_WEP_64 || 
+			    cipher_type == CIPHER_SUITE_WEP_128 )
+				cipher_length = 8;
+			else if (cipher_type == CIPHER_SUITE_TKIP)
+				cipher_length = 12;
+			else if (priv->group_cipher_suite == CIPHER_SUITE_WEP_64 ||
+				 priv->group_cipher_suite == CIPHER_SUITE_WEP_128) {
+				cipher_type = priv->group_cipher_suite;
+				cipher_length = 8;
+			} else {
+				cipher_type = CIPHER_SUITE_NONE;
+				cipher_length = 0;
+			}
+		}
+		
+		atmel_wmem8(priv, atmel_tx(priv, TX_DESC_CIPHER_TYPE_OFFSET, priv->tx_desc_tail),
+			    cipher_type);	
+		atmel_wmem8(priv, atmel_tx(priv, TX_DESC_CIPHER_LENGTH_OFFSET, priv->tx_desc_tail),
+			    cipher_length);
+	}
 	atmel_wmem32(priv, atmel_tx(priv, TX_DESC_NEXT_OFFSET, priv->tx_desc_tail), 0x80000000L);
 	atmel_wmem8(priv, atmel_tx(priv, TX_DESC_FLAGS_OFFSET, priv->tx_desc_tail), TX_FIRM_OWN);
 	if (priv->tx_desc_previous != priv->tx_desc_tail)
@@ -745,16 +798,19 @@ static int start_tx (struct sk_buff *skb
 	struct ieee802_11_hdr header;
 	unsigned long flags;
 	u16 buff, frame_ctl, len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
-	
-	if(priv->station_state != STATION_STATE_READY) {
+	u8 SNAP_RFC1024[6] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
+ 
+	if (priv->station_state != STATION_STATE_READY) {
 		priv->stats.tx_errors++;
-		goto done;
+		dev_kfree_skb(skb);
+		return 0;
 	}
 	
 	if (priv->card && priv->present_callback && 
 	    !(*priv->present_callback)(priv->card)) {
 		priv->stats.tx_errors++;
-		goto done;
+		dev_kfree_skb(skb);
+		return 0;
 	}
 	
 	/* first ensure the timer func cannot run */
@@ -778,7 +834,7 @@ static int start_tx (struct sk_buff *skb
 	frame_ctl = IEEE802_11_FTYPE_DATA;
 	header.duration_id = 0;
 	header.seq_ctl = 0;
-	if (priv->wep.wep_is_on)
+	if (priv->wep_is_on)
 		frame_ctl |= IEEE802_11_FCTL_WEP;
 	if (priv->operating_mode == IW_MODE_ADHOC) {
 		memcpy(&header.addr1, skb->data, 6);
@@ -791,6 +847,9 @@ static int start_tx (struct sk_buff *skb
 		memcpy(&header.addr3, skb->data, 6);
 	}
 	
+	if (priv->use_wpa)
+		memcpy(&header.addr4, SNAP_RFC1024, 6);
+
 	header.frame_ctl = cpu_to_le16(frame_ctl);
 	/* Copy the wireless header into the card */
 	atmel_copy_to_card(dev, buff, (unsigned char *)&header, DATA_FRAME_WS_HEADER_SIZE);
@@ -798,14 +857,13 @@ static int start_tx (struct sk_buff *skb
 	atmel_copy_to_card(dev, buff + DATA_FRAME_WS_HEADER_SIZE, skb->data + 12, len - 12);
 	priv->tx_buff_tail += len - 12 + DATA_FRAME_WS_HEADER_SIZE;
 	
-	tx_update_descriptor(priv, len + 18, buff, TX_PACKET_TYPE_DATA);
+	/* low bit of first byte of destination tells us if broadcast */
+	tx_update_descriptor(priv, *(skb->data) & 0x01, len + 18, buff, TX_PACKET_TYPE_DATA);
 	dev->trans_start = jiffies;
 	priv->stats.tx_bytes += len;
 	
 	spin_unlock_irqrestore(&priv->irqlock, flags);
 	spin_unlock_bh(&priv->timerlock);
-
-done:
 	dev_kfree_skb(skb);
 	
 	return 0;	
@@ -824,7 +882,7 @@ static void atmel_transmit_management_fr
 	atmel_copy_to_card(priv->dev, buff, (u8 *)header, MGMT_FRAME_BODY_OFFSET);
 	atmel_copy_to_card(priv->dev, buff + MGMT_FRAME_BODY_OFFSET, body, body_len);
 	priv->tx_buff_tail += len;
-	tx_update_descriptor(priv, len, buff, TX_PACKET_TYPE_MGMT);
+	tx_update_descriptor(priv, header->addr1[0] & 0x01, len, buff, TX_PACKET_TYPE_MGMT);
 }
 	
 static void fast_rx_path(struct atmel_private *priv, struct ieee802_11_hdr *header, 
@@ -1027,7 +1085,7 @@ static void rx_done_irq(struct atmel_pri
 		/* probe for CRC use here if needed  once five packets have arrived with
 		   the same crc status, we assume we know what's happening and stop probing */
 		if (priv->probe_crc) {
-			if (!priv->wep.wep_is_on || !(frame_ctl & IEEE802_11_FCTL_WEP)) {
+			if (!priv->wep_is_on || !(frame_ctl & IEEE802_11_FCTL_WEP)) {
 				priv->do_rx_crc = probe_crc(priv, rx_packet_loc, msdu_size);
 			} else {
 				priv->do_rx_crc = probe_crc(priv, rx_packet_loc + 24, msdu_size - 24);
@@ -1042,7 +1100,7 @@ static void rx_done_irq(struct atmel_pri
 		}
 		    
 		/* don't CRC header when WEP in use */
-		if (priv->do_rx_crc && (!priv->wep.wep_is_on || !(frame_ctl & IEEE802_11_FCTL_WEP))) {
+		if (priv->do_rx_crc && (!priv->wep_is_on || !(frame_ctl & IEEE802_11_FCTL_WEP))) {
 			crc = crc32_le(0xffffffff, (unsigned char *)&header, 24);
 		}
 		msdu_size -= 24; /* header */
@@ -1158,6 +1216,9 @@ static irqreturn_t service_interrupt(int
 			reset_irq_status(priv, ISR_IBSS_MERGE);
 			atmel_get_mib(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_CUR_BSSID_POS, 
 				      priv->CurrentBSSID, 6);
+			/* The WPA stuff cares about the current AP address */
+			if (priv->use_wpa)
+				build_wpa_mib(priv);
 		} else if (isr & ISR_GENERIC_IRQ) {
 			reset_irq_status(priv, ISR_GENERIC_IRQ);
 			printk(KERN_INFO "%s: Generic_irq recieved.\n", dev->name);
@@ -1237,6 +1298,7 @@ static int atmel_close (struct net_devic
 {
 	struct atmel_private *priv = (struct atmel_private *) dev->priv;
 		
+	netif_carrier_off(dev);	
 	if (netif_running(dev))
 		netif_stop_queue(dev);
 	
@@ -1255,17 +1317,17 @@ static int atmel_proc_output (char *buf,
 	p += sprintf(p, "Driver version:\t\t%d.%d\n", DRIVER_MAJOR, DRIVER_MINOR);
 	
 	if (priv->station_state != STATION_STATE_DOWN) {
-		p += sprintf(p, "Firmware version:\t%d.%d build %d ", 
+		p += sprintf(p, "Firmware version:\t%d.%d build %d\nFirmware location:\t", 
 			     priv->host_info.major_version,
 			     priv->host_info.minor_version,
 			     priv->host_info.build_version);
 		
 		if (priv->card_type != CARD_TYPE_EEPROM) 
-			p += sprintf(p, "[built-in]\n");
+			p += sprintf(p, "on card\n");
 		else if (priv->firmware) 
-			p += sprintf(p, "[%s loaded by host]\n", priv->firmware_id);
+			p += sprintf(p, "%s loaded by host\n", priv->firmware_id);
 		else
-			p += sprintf(p, "[%s loaded by hotplug]\n", priv->firmware_id);
+			p += sprintf(p, "%s loaded by hotplug\n", priv->firmware_id);
 		
 		switch(priv->card_type) {
 		case CARD_TYPE_PARALLEL_FLASH: c = "Parallel flash"; break;
@@ -1289,6 +1351,8 @@ static int atmel_proc_output (char *buf,
 		p += sprintf(p, "Regulatory domain:\t%s\n", r);
 		p += sprintf(p, "Host CRC checking:\t%s\n", 
 			     priv->do_rx_crc ? "On" : "Off");
+		p += sprintf(p, "WPA-capable firmware:\t%s\n",
+			     priv->use_wpa ? "Yes" : "No");
 	}
 	
 	switch(priv->station_state) {
@@ -1299,8 +1363,6 @@ static int atmel_proc_output (char *buf,
 	case STATION_STATE_ASSOCIATING: s = "Associating"; break;
 	case STATION_STATE_READY: s = "Ready"; break;
 	case STATION_STATE_REASSOCIATING: s = "Reassociating"; break;
-	case STATION_STATE_FORCED_JOINNING: s = "Forced joining"; break;
-	case STATION_STATE_FORCED_JOIN_FAILURE: s = "Forced join failure"; break;
 	case STATION_STATE_NO_CARD: s = "No card"; break;
 	case STATION_STATE_MGMT_ERROR: s = "Management error"; break;
 	case STATION_STATE_DOWN: s = "Down"; break;
@@ -1348,12 +1410,12 @@ struct net_device *init_atmel_card( unsi
 	priv->present_callback = card_present;
 	priv->card = card;
 	priv->firmware = NULL;
+	priv->firmware_id[0] = '\0';
+	priv->firmware_template[0] = '\0';
 	if (firmware) /* module parameter */
 		strcpy(priv->firmware_id, firmware);
 	else if (firmware_id) /* from PCMCIA card-matching or PCI */
-		strcpy(priv->firmware_id, firmware_id);
-	else
-		priv->firmware_id[0] = '\0';
+		strcpy(priv->firmware_template, firmware_id);
 	priv->bus_type = card_present ? BUS_TYPE_PCCARD : BUS_TYPE_PCI;
 	priv->station_state = STATION_STATE_DOWN;
 	priv->is3com = is3com;
@@ -1389,9 +1451,16 @@ struct net_device *init_atmel_card( unsi
 	priv->rts_threshold = 2347;
 	priv->short_retry = 7;
 	priv->long_retry = 4;
-	priv->wep.wep_is_on = 0;
-	priv->wep.default_key = 0;
-	priv->wep.encryption_level = 0;
+
+	priv->wep_is_on = 0;
+	priv->default_key = 0;
+	priv->encryption_level = 0;
+	priv->exclude_unencrypted = 0;
+	priv->group_cipher_suite = priv->pairwise_cipher_suite = CIPHER_SUITE_NONE;
+	priv->use_wpa = 0;
+	memset(priv->wep_keys, 0, sizeof(priv->wep_keys));
+	memset(priv->wep_key_len, 0, sizeof(priv->wep_key_len));
+
 	priv->default_beacon_period = priv->beacon_period = 100;
 	priv->listen_interval = 1;
 
@@ -1426,8 +1495,12 @@ struct net_device *init_atmel_card( unsi
 	if (register_netdev(dev))
 		goto err_out_res;
 	
-	if (!probe_atmel_card(dev))
+	if (!probe_atmel_card(dev)){
+		unregister_netdev(dev);
 		goto err_out_res;
+	}
+	
+	netif_carrier_off(dev);
 	
 	create_proc_read_entry ("driver/atmel", 0, 0, atmel_read_proc, priv);	
 	
@@ -1443,7 +1516,7 @@ struct net_device *init_atmel_card( unsi
  err_out_irq:
 	free_irq(dev->irq, dev);
  err_out_free:
-	kfree(dev);
+	free_netdev(dev);
 	return NULL;
 }
 
@@ -1582,7 +1655,7 @@ static int atmel_set_encode(struct net_d
 	 * don't do it. - Jean II */
 	if (dwrq->length > 0) {
 		int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
-		int current_index = priv->wep.default_key;
+		int current_index = priv->default_key;
 		/* Check the size of the key */
 		if (dwrq->length > 13) {
 			return -EINVAL;
@@ -1591,7 +1664,7 @@ static int atmel_set_encode(struct net_d
 		if (index < 0 || index >= 4)
 			index = current_index;
 		else
-			priv->wep.default_key = index;
+			priv->default_key = index;
 		/* Set the length */
 		if (dwrq->length > 5)
 			priv->wep_key_len[index] = 13;
@@ -1604,27 +1677,30 @@ static int atmel_set_encode(struct net_d
 		/* Check if the key is not marked as invalid */
 		if(!(dwrq->flags & IW_ENCODE_NOKEY)) {
 			/* Cleanup */
-			memset(priv->wep.wep_keys[index], 0, 13);
+			memset(priv->wep_keys[index], 0, 13);
 			/* Copy the key in the driver */
-			memcpy(priv->wep.wep_keys[index], extra, dwrq->length);
+			memcpy(priv->wep_keys[index], extra, dwrq->length);
 		}
 		/* WE specify that if a valid key is set, encryption
 		 * should be enabled (user may turn it off later)
 		 * This is also how "iwconfig ethX key on" works */
 		if (index == current_index && 
 		    priv->wep_key_len[index] > 0) {
-			priv->wep.wep_is_on = 1;
-			priv->wep.exclude_unencrypted = 1;
-			if (priv->wep_key_len[index] > 5)
-				priv->wep.encryption_level = 2;
-			else
-				priv->wep.encryption_level = 1;
+			priv->wep_is_on = 1;
+			priv->exclude_unencrypted = 1;
+			if (priv->wep_key_len[index] > 5) {
+				priv->pairwise_cipher_suite = CIPHER_SUITE_WEP_64;
+				priv->encryption_level = 2;
+			} else {
+				priv->pairwise_cipher_suite = CIPHER_SUITE_WEP_128;
+				priv->encryption_level = 1;
+			}
 		}
 	} else {
 		/* Do we want to just set the transmit key index ? */
 		int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
 		if ( index>=0 && index < 4 ) {
-			priv->wep.default_key = index;
+			priv->default_key = index;
 		} else
 			/* Don't complain if only change the mode */
 			if(!dwrq->flags & IW_ENCODE_MODE) {
@@ -1633,19 +1709,23 @@ static int atmel_set_encode(struct net_d
 	}
 	/* Read the flags */
 	if(dwrq->flags & IW_ENCODE_DISABLED) {
-		priv->wep.wep_is_on = 0;
-		priv->wep.encryption_level = 0; 
+		priv->wep_is_on = 0;
+		priv->encryption_level = 0; 	
+		priv->pairwise_cipher_suite = CIPHER_SUITE_NONE;
 	} else {
-		priv->wep.wep_is_on = 1;
-		if (priv->wep_key_len[priv->wep.default_key] > 5)
-			priv->wep.encryption_level = 2;
-		else
-			priv->wep.encryption_level = 1;
+		priv->wep_is_on = 1;
+		if (priv->wep_key_len[priv->default_key] > 5) {
+			priv->pairwise_cipher_suite = CIPHER_SUITE_WEP_128;
+			priv->encryption_level = 2;
+		} else {
+			priv->pairwise_cipher_suite = CIPHER_SUITE_WEP_64;
+			priv->encryption_level = 1;
+		}
 	}
 	if(dwrq->flags & IW_ENCODE_RESTRICTED)
-		priv->wep.exclude_unencrypted = 1;
+		priv->exclude_unencrypted = 1;
 	if(dwrq->flags & IW_ENCODE_OPEN)
-		priv->wep.exclude_unencrypted = 0;
+		priv->exclude_unencrypted = 0;
 	
 	return -EINPROGRESS;		/* Call commit handler */
 }
@@ -1659,16 +1739,16 @@ static int atmel_get_encode(struct net_d
 	struct atmel_private *priv = dev->priv;
 	int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
 	
-	if (!priv->wep.wep_is_on)
+	if (!priv->wep_is_on)
 		dwrq->flags = IW_ENCODE_DISABLED;
-	else if (priv->wep.exclude_unencrypted)
+	else if (priv->exclude_unencrypted)
 		dwrq->flags = IW_ENCODE_RESTRICTED;
 	else
 		dwrq->flags = IW_ENCODE_OPEN;
 		
 		/* Which key do we want ? -1 -> tx index */
 	if (index < 0 || index >= 4)
-		index = priv->wep.default_key;
+		index = priv->default_key;
 	dwrq->flags |= index + 1;
 	/* Copy the key to the user buffer */
 	dwrq->length = priv->wep_key_len[index];
@@ -1676,7 +1756,7 @@ static int atmel_get_encode(struct net_d
 		dwrq->length=0;
 	} else {
 		memset(extra, 0, 16);
-		memcpy(extra, priv->wep.wep_keys[index], dwrq->length);
+		memcpy(extra, priv->wep_keys[index], dwrq->length);
 	}
 	
 	return 0;
@@ -1711,10 +1791,10 @@ static int atmel_set_rate(struct net_dev
 		} else {
 		/* Setting by frequency value */
 			switch (vwrq->value) {
-			case (int)1e6: priv->tx_rate = 0; break;
-			case (int)2e6: priv->tx_rate = 1; break;
-			case (int)5.5e6: priv->tx_rate = 2; break;
-			case (int)11e6:  priv->tx_rate = 3; break;
+			case  1000000: priv->tx_rate = 0; break;
+			case  2000000: priv->tx_rate = 1; break;
+			case  5500000: priv->tx_rate = 2; break;
+			case 11000000: priv->tx_rate = 3; break;
 			default: return -EINVAL;
 			}
 		}
@@ -1757,14 +1837,14 @@ static int atmel_get_rate(struct net_dev
 
 	if (priv->auto_tx_rate) {
 		vwrq->fixed = 0;
-		vwrq->value = 11e6;
+		vwrq->value = 11000000;
 	} else {
 		vwrq->fixed = 1;
 		switch(priv->tx_rate) {
-		case 0: vwrq->value = 1e6; break;
-		case 1: vwrq->value = 2e6; break;
-		case 2: vwrq->value = 5.5e6; break;
-		case 3: vwrq->value = 11e6; break;
+		case 0: vwrq->value =  1000000; break;
+		case 1: vwrq->value =  2000000; break;
+		case 2: vwrq->value =  5500000; break;
+		case 3: vwrq->value = 11000000; break;
 		}
 	}
 	return 0;
@@ -1982,6 +2062,7 @@ static int atmel_set_scan(struct net_dev
 	
 	atmel_clear_gcr(dev, GCR_ENINT); /* disable interrupts */
 	del_timer_sync(&priv->management_timer);
+	priv->fast_scan = 0;
 	atmel_scan(priv, 0);
 	atmel_set_gcr(dev, GCR_ENINT); /* enable interrupts */
 	
@@ -2073,10 +2154,10 @@ static int atmel_get_range(struct net_de
 	range->max_qual.noise = 0;
 	range->sensitivity = 0;
 
-	range->bitrate[0] = 1e6;
-	range->bitrate[1] = 2e6;
-	range->bitrate[2] = 5.5e6;
-	range->bitrate[3] = 11e6;
+	range->bitrate[0] =  1000000;
+	range->bitrate[1] =  2000000;
+	range->bitrate[2] =  5500000;
+	range->bitrate[3] = 11000000;
 	range->num_bitrates = 4;
 
 	range->min_rts = 0;
@@ -2129,9 +2210,9 @@ static int atmel_set_wap(struct net_devi
 	
 	for(i=0; i<priv->BSS_list_entries; i++) {
 		if (memcmp(priv->BSSinfo[i].BSSID, awrq->sa_data, 6) == 0) {
-			if (!priv->wep.wep_is_on && priv->BSSinfo[i].UsingWEP) {
+			if (!priv->wep_is_on && priv->BSSinfo[i].UsingWEP) {
 				return -EINVAL;
-			} else if  (priv->wep.wep_is_on && !priv->BSSinfo[i].UsingWEP) {
+			} else if  (priv->wep_is_on && !priv->BSSinfo[i].UsingWEP) {
 				return -EINVAL;
 			} else 
 				atmel_join_bss(priv, i);  
@@ -2313,10 +2394,13 @@ static void atmel_enter_state(struct atm
 	if (new_state == old_state)
 		return;
 
-	if (new_state == STATION_STATE_READY)
+	if (new_state == STATION_STATE_READY) {
 		netif_start_queue(priv->dev);
+		netif_carrier_on(priv->dev);
+	}
 
 	if (old_state == STATION_STATE_READY) {
+		netif_carrier_off(priv->dev);
 		netif_stop_queue(priv->dev);
 		priv->last_beacon_timestamp = 0;
 	}
@@ -2453,7 +2537,7 @@ static void send_authentication_request(
 	memcpy(header.addr2, priv->dev->dev_addr, 6);
 	memcpy(header.addr3, priv->CurrentBSSID, 6);
 	
-	if (priv->wep.wep_is_on) {
+	if (priv->wep_is_on) {
 		auth.alg = C80211_MGMT_AAN_SHAREDKEY; 
 		/* no WEP for authentication frames with TrSeqNo 1 */
 		if (priv->CurrentAuthentTransactionSeqNum != 1)
@@ -2504,7 +2588,7 @@ static void send_association_request(str
 	memcpy(header.addr3, priv->CurrentBSSID, 6); 
 
 	body.capability = cpu_to_le16(C80211_MGMT_CAPABILITY_ESS);
-	if (priv->wep.wep_is_on)
+	if (priv->wep_is_on)
 		body.capability |= cpu_to_le16(C80211_MGMT_CAPABILITY_Privacy);
 	if (priv->preamble == SHORT_PREAMBLE)
 		body.capability |= cpu_to_le16(C80211_MGMT_CAPABILITY_ShortPreamble);
@@ -2555,8 +2639,8 @@ static int retrieve_bss(struct atmel_pri
 		priv->current_BSS = 0;
 		for(i=0; i<priv->BSS_list_entries; i++) { 
 			if (priv->operating_mode == priv->BSSinfo[i].BSStype &&
-			    ((!priv->wep.wep_is_on && !priv->BSSinfo[i].UsingWEP) || 
-			     (priv->wep.wep_is_on && priv->BSSinfo[i].UsingWEP)) &&
+			    ((!priv->wep_is_on && !priv->BSSinfo[i].UsingWEP) || 
+			     (priv->wep_is_on && priv->BSSinfo[i].UsingWEP)) &&
 			    !(priv->BSSinfo[i].channel & 0x80)) {
 				max_rssi = priv->BSSinfo[i].RSSI;
 				priv->current_BSS = max_index = i;
@@ -2630,7 +2714,7 @@ static void authenticate(struct atmel_pr
 	u16 status = le16_to_cpu(auth->status);
 	u16 trans_seq_no = le16_to_cpu(auth->trans_seq);
 	
-	if (status == C80211_MGMT_SC_Success && !priv->wep.wep_is_on) { 
+	if (status == C80211_MGMT_SC_Success && !priv->wep_is_on) { 
 		/* no WEP */
 		if (priv->station_was_associated) {
 			atmel_enter_state(priv, STATION_STATE_REASSOCIATING);
@@ -2643,7 +2727,7 @@ static void authenticate(struct atmel_pr
 		} 
 	}
 		
-	if (status == C80211_MGMT_SC_Success && priv->wep.wep_is_on) { 
+	if (status == C80211_MGMT_SC_Success && priv->wep_is_on) { 
 		/* WEP */
 		if (trans_seq_no != priv->ExpectedAuthentTransactionSeqNum)
 			return;
@@ -2765,6 +2849,10 @@ void atmel_join_bss(struct atmel_private
 
 	memcpy(priv->CurrentBSSID, bss->BSSID, 6);
 	memcpy(priv->SSID, bss->SSID, priv->SSID_size = bss->SSIDsize);
+
+	/* The WPA stuff cares about the current AP address */
+	if (priv->use_wpa)
+		build_wpa_mib(priv);
 	
 	/* When switching to AdHoc turn OFF Power Save if needed */
 
@@ -2786,13 +2874,13 @@ void atmel_join_bss(struct atmel_private
 		atmel_set_mib8(priv, Local_Mib_Type, LOCAL_MIB_PREAMBLE_TYPE, bss->preamble);
 	}
 	
-	if (!priv->wep.wep_is_on && bss->UsingWEP) {
+	if (!priv->wep_is_on && bss->UsingWEP) {
 		atmel_enter_state(priv, STATION_STATE_MGMT_ERROR);
 		priv->station_is_associated = 0;
 		return;
 	}
 		
-	if (priv->wep.wep_is_on && !bss->UsingWEP) {
+	if (priv->wep_is_on && !bss->UsingWEP) {
 		atmel_enter_state(priv, STATION_STATE_MGMT_ERROR);
 		priv->station_is_associated = 0;
 		return;
@@ -3071,6 +3159,7 @@ static void atmel_command_irq(struct atm
 				priv->fast_scan = !fast_scan;
 				atmel_scan(priv, 1);
 			}
+			priv->site_survey_state = SITE_SURVEY_COMPLETED;
 		}
 		break;
 		
@@ -3104,12 +3193,8 @@ static void atmel_command_irq(struct atm
 			return;
 		}
 		
-
-		if (priv->station_state == STATION_STATE_FORCED_JOINNING) {
-			atmel_enter_state(priv, STATION_STATE_FORCED_JOIN_FAILURE); 
-		} else {
-			atmel_scan(priv, 1);
-		}
+		atmel_scan(priv, 1);
+		
 	}
 }
 
@@ -3275,7 +3360,7 @@ static int probe_atmel_card(struct net_d
 			printk(KERN_ALERT "%s: *** Invalid MAC address. UPGRADE Firmware ****\n", dev->name);
 			memcpy(dev->dev_addr, default_mac, 6);
 		}
-		printk(KERN_INFO "%s: MAC address %x:%x:%x:%x:%x:%x\n",
+		printk(KERN_INFO "%s: MAC address %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
 		       dev->name,
 		       dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
 		       dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5] );
@@ -3285,6 +3370,105 @@ static int probe_atmel_card(struct net_d
 	return rc;
 }
 
+static void build_wep_mib(struct atmel_private *priv)
+/* Move the encyption information on the MIB structure.
+   This routine is for the pre-WPA firmware: later firmware has
+   a different format MIB and a different routine. */
+{
+	struct { /* NB this is matched to the hardware, don't change. */
+		u8 wep_is_on;                 
+		u8 default_key; /* 0..3 */
+		u8 reserved;
+		u8 exclude_unencrypted;
+		
+		u32 WEPICV_error_count;
+		u32 WEP_excluded_count;
+		
+		u8 wep_keys[MAX_ENCRYPTION_KEYS][13];
+ 		u8 encryption_level; /* 0, 1, 2 */
+		u8 reserved2[3]; 
+	} mib;
+	int i;
+
+	mib.wep_is_on = priv->wep_is_on;
+	if (priv->wep_is_on) {
+		if (priv->wep_key_len[priv->default_key] > 5)
+			mib.encryption_level = 2;
+		else
+			mib.encryption_level = 1;	
+	} else {
+		mib.encryption_level = 0;
+	}
+
+	mib.default_key = priv->default_key;
+	mib.exclude_unencrypted = priv->exclude_unencrypted;
+	
+	for(i = 0; i < MAX_ENCRYPTION_KEYS;  i++)
+		memcpy(mib.wep_keys[i], priv->wep_keys[i], 13);
+		
+	atmel_set_mib(priv, Mac_Wep_Mib_Type, 0, (u8 *)&mib, sizeof(mib));
+}
+
+static void build_wpa_mib(struct atmel_private *priv)
+{
+	/* This is for the later (WPA enabled) firmware. */	   
+
+	struct { /* NB this is matched to the hardware, don't change. */
+		u8 cipher_default_key_value[MAX_ENCRYPTION_KEYS][MAX_ENCRYPTION_KEY_SIZE];
+		u8 receiver_address[6];
+		u8 wep_is_on;                 
+		u8 default_key; /* 0..3 */
+		u8 group_key;
+		u8 exclude_unencrypted;
+		u8 encryption_type;
+		u8 reserved;
+		
+		u32 WEPICV_error_count;
+		u32 WEP_excluded_count;
+		
+		u8 key_RSC[4][8];
+	} mib;
+	
+	int i;
+
+	mib.wep_is_on = priv->wep_is_on;
+	mib.exclude_unencrypted = priv->exclude_unencrypted;
+	memcpy(mib.receiver_address, priv->CurrentBSSID, 6);
+	
+	/* zero all the keys before adding in valid ones. */
+	memset(mib.cipher_default_key_value, 0, sizeof(mib.cipher_default_key_value));
+	
+	if (priv->wep_is_on) {
+		/* There's a comment in the Atmel code to the effect that this is only valid
+		   when still using WEP, it may need to be set to something to use WPA */
+		memset(mib.key_RSC, 0, sizeof(mib.key_RSC));
+		
+		mib.default_key = mib.group_key = 255;
+		for (i = 0; i < MAX_ENCRYPTION_KEYS; i++) {
+			if (priv->wep_key_len[i] > 0) {
+				memcpy(mib.cipher_default_key_value[i], priv->wep_keys[i], MAX_ENCRYPTION_KEY_SIZE);
+				if (i == priv->default_key) {
+					mib.default_key = i;
+					mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-1] = 7;
+					mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-2] = priv->pairwise_cipher_suite; 
+				} else {
+					mib.group_key = i;
+					priv->group_cipher_suite = priv->pairwise_cipher_suite;
+				        mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-1] = 1;
+					mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-2] = priv->group_cipher_suite;	
+				}
+			}
+		}
+		if (mib.default_key == 255)
+			mib.default_key = mib.group_key != 255 ? mib.group_key : 0;
+		if (mib.group_key == 255)
+			mib.group_key = mib.default_key;
+		
+	}
+	
+	atmel_set_mib(priv, Mac_Wep_Mib_Type, 0, (u8 *)&mib, sizeof(mib));
+}
+					
 int reset_atmel_card(struct net_device *dev) 
 {
 	/* do everything necessary to wake up the hardware, including
@@ -3305,6 +3489,15 @@ int reset_atmel_card(struct net_device *
 	struct atmel_private *priv = dev->priv;
 	u8 configuration;
 	
+	/* data to add to the firmware names, in priority order
+	   this implemenents firmware versioning */
+	
+	static char *firmware_modifier[] = {
+		"-wpa",
+		"",
+		NULL
+	};
+	
 	if (priv->station_state == STATION_STATE_NO_CARD ||
 	    priv->station_state == STATION_STATE_DOWN)
 		return 0;
@@ -3341,21 +3534,41 @@ int reset_atmel_card(struct net_device *
 		unsigned char *fw;
 		int len = priv->firmware_length;
 		if (!(fw = priv->firmware)) { 
-			if (strlen(priv->firmware_id) == 0) {
-				printk(KERN_INFO
-				       "%s: card type is unknown: assuming at76c502 firmware is OK.\n",
-				       dev->name);
-				printk(KERN_INFO
-				       "%s: if not, use the firmware= module parameter.\n", 
-				       dev->name);
-				strcpy(priv->firmware_id, "atmel_at76c502.bin");
-			}
-			if (request_firmware(&fw_entry, priv->firmware_id, priv->sys_dev) != 0) {
-				printk(KERN_ALERT 
-				       "%s: firmware %s is missing, cannot start.\n", 
-				       dev->name, priv->firmware_id);
-				return 0;
+			if (strlen(priv->firmware_template) == 0) {	
+				if (strlen(priv->firmware_id) == 0) {
+					printk(KERN_INFO
+					       "%s: card type is unknown: assuming at76c502 firmware is OK.\n",
+					       dev->name);
+					printk(KERN_INFO
+					       "%s: if not, use the firmware= module parameter.\n", 
+					       dev->name);
+					strcpy(priv->firmware_id, "atmel_at76c502.bin");
+				}
+				if (request_firmware(&fw_entry, priv->firmware_id, priv->sys_dev) != 0) {
+					printk(KERN_ALERT 
+					       "%s: firmware %s is missing, cannot continue.\n", 
+					       dev->name, priv->firmware_id);
+					return 0;
+					
+				} 
+			} else {
+				int i;
+				
+				for (i = 0; firmware_modifier[i]; i++) {
+					sprintf(priv->firmware_id, priv->firmware_template, firmware_modifier[i]);
+					if (request_firmware(&fw_entry, priv->firmware_id, priv->sys_dev) == 0) 
+						break;
+				}
+				if (!firmware_modifier[i]) {
+					printk(KERN_ALERT 
+					       "%s: firmware %s is missing, cannot start.\n", 
+					       dev->name, priv->firmware_id);
+					priv->firmware_id[0] = '\0';
+					return 0;	
+				}
+				priv->firmware_template[0] = '\0';	
 			}
+			
 			fw = fw_entry->data;
 			len = fw_entry->size;
 		}
@@ -3379,6 +3592,10 @@ int reset_atmel_card(struct net_device *
 
 	if (!atmel_wakeup_firmware(priv))
 		return 0;
+
+	/* Check the version and set the correct flag for wpa stuff,
+	   old and new firmware is incompatible. */
+	priv->use_wpa = (priv->host_info.major_version >= 4);
 	
         /* unmask all irq sources */
 	atmel_wmem8(priv, atmel_hi(priv, IFACE_INT_MASK_OFFSET), 0xff);
@@ -3447,9 +3664,12 @@ int reset_atmel_card(struct net_device *
 	atmel_set_mib16(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_LISTEN_INTERVAL_POS, 1);
 	atmel_set_mib16(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_BEACON_PER_POS, priv->default_beacon_period);
 	atmel_set_mib(priv, Phy_Mib_Type, PHY_MIB_RATE_SET_POS, atmel_basic_rates, 4);
-	atmel_set_mib8(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_CUR_PRIVACY_POS, priv->wep.wep_is_on);
-	atmel_set_mib(priv, Mac_Wep_Mib_Type, 0, (u8 *)&priv->wep, sizeof(priv->wep));
-		
+	atmel_set_mib8(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_CUR_PRIVACY_POS, priv->wep_is_on);
+	if (priv->use_wpa)
+		build_wpa_mib(priv);
+	else
+		build_wep_mib(priv);
+	
 	atmel_scan(priv, 1);
 	
 	atmel_set_gcr(priv->dev, GCR_ENINT); /* enable interrupts */
@@ -3500,8 +3720,8 @@ static u8 atmel_get_mib8(struct atmel_pr
 	m.size = 1;
 	m.index = index;
 
-	atmel_send_command_wait(priv, CMD_Get_MIB_Vars, &m, sizeof(m));
-	return atmel_rmem8(priv, atmel_co(priv, CMD_BLOCK_PARAMETERS_OFFSET + 4));
+	atmel_send_command_wait(priv, CMD_Get_MIB_Vars, &m, MIB_HEADER_SIZE + 1);
+	return atmel_rmem8(priv, atmel_co(priv, CMD_BLOCK_PARAMETERS_OFFSET + MIB_HEADER_SIZE));
 }
 
 static void atmel_set_mib8(struct atmel_private *priv, u8 type, u8 index, u8 data)
@@ -3512,7 +3732,7 @@ static void atmel_set_mib8(struct atmel_
 	m.index = index;
 	m.data[0] = data;
 
-	atmel_send_command_wait(priv, CMD_Set_MIB_Vars, &m, sizeof(m));
+	atmel_send_command_wait(priv, CMD_Set_MIB_Vars, &m, MIB_HEADER_SIZE + 1);
 }
 
 static void atmel_set_mib16(struct atmel_private *priv, u8 type, u8 index, u16 data)
@@ -3524,7 +3744,7 @@ static void atmel_set_mib16(struct atmel
 	m.data[0] = data;
 	m.data[1] = data >> 8;
 
-	atmel_send_command_wait(priv, CMD_Set_MIB_Vars, &m, sizeof(m));
+	atmel_send_command_wait(priv, CMD_Set_MIB_Vars, &m, MIB_HEADER_SIZE + 2);
 }
 
 static void atmel_set_mib(struct atmel_private *priv, u8 type, u8 index, u8 *data, int data_len)
@@ -3534,8 +3754,11 @@ static void atmel_set_mib(struct atmel_p
 	m.size = data_len;
 	m.index = index;
 
+	if (data_len > MIB_MAX_DATA_BYTES)
+		printk(KERN_ALERT "%s: MIB buffer too small.\n", priv->dev->name);
+	
 	memcpy(m.data, data, data_len);
-	atmel_send_command_wait(priv, CMD_Set_MIB_Vars, &m, sizeof(m));
+	atmel_send_command_wait(priv, CMD_Set_MIB_Vars, &m, MIB_HEADER_SIZE + data_len);
 }
 
 static void atmel_get_mib(struct atmel_private *priv, u8 type, u8 index, u8 *data, int data_len)
@@ -3545,10 +3768,14 @@ static void atmel_get_mib(struct atmel_p
 	m.size = data_len;
 	m.index = index;
 	
-	atmel_send_command_wait(priv, CMD_Get_MIB_Vars, &m, sizeof(m));
-	atmel_copy_to_host(priv->dev, data, atmel_co(priv, CMD_BLOCK_PARAMETERS_OFFSET + 4), data_len);
-}
+	if (data_len > MIB_MAX_DATA_BYTES)
+		printk(KERN_ALERT "%s: MIB buffer too small.\n", priv->dev->name);
 	
+	atmel_send_command_wait(priv, CMD_Get_MIB_Vars, &m, MIB_HEADER_SIZE + data_len);
+	atmel_copy_to_host(priv->dev, data, 
+			   atmel_co(priv, CMD_BLOCK_PARAMETERS_OFFSET + MIB_HEADER_SIZE), data_len);
+}
+
 static void atmel_writeAR(struct net_device *dev, u16 data)
 {
 	int i;
diff -puN drivers/net/wireless/atmel_cs.c~linus drivers/net/wireless/atmel_cs.c
--- 25/drivers/net/wireless/atmel_cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/wireless/atmel_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -246,7 +246,7 @@ static dev_link_t *atmel_attach(void)
 	client_reg.event_handler = &atmel_event;
 	client_reg.Version = 0x0210;
 	client_reg.event_callback_args.client_data = link;
-	ret = CardServices(RegisterClient, &link->handle, &client_reg);
+	ret = pcmcia_register_client(&link->handle, &client_reg);
 	if (ret != 0) {
 		cs_error(link->handle, RegisterClient, ret);
 		atmel_detach(link);
@@ -282,7 +282,7 @@ static void atmel_detach(dev_link_t *lin
 		
 	/* Break the link with Card Services */
 	if (link->handle)
-		CardServices(DeregisterClient, link->handle);
+		pcmcia_deregister_client(link->handle);
 
 	/* Unlink device structure, free pieces */
 	*linkp = link->next;
@@ -299,11 +299,8 @@ static void atmel_detach(dev_link_t *lin
   
   ======================================================================*/
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn),args))!=0) goto cs_failed
-
-#define CFG_CHECK(fn, args...) \
-if (CardServices(fn, args) != 0) goto next_entry
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 /* Call-back function to interrogate PCMCIA-specific information
    about the current existance of the card */
@@ -330,20 +327,20 @@ static struct { 
 	char *firmware;
 	char *name;
 } card_table[] = {
-	{ 0, 0, "WLAN/802.11b PC CARD", "atmel_at76c502d.bin", "Actiontec 802CAT1" },  
-	{ 0, 0, "ATMEL/AT76C502AR", "atmel_at76c502.bin", "NoName-RFMD" }, 
-	{ 0, 0, "ATMEL/AT76C502AR_D", "atmel_at76c502d.bin", "NoName-revD" }, 
-	{ 0, 0, "ATMEL/AT76C502AR_E", "atmel_at76c502e.bin", "NoName-revE" },
-	{ 0, 0, "ATMEL/AT76C504", "atmel_at76c504.bin", "NoName-504" },
-	{ MANFID_3COM, 0x0620, NULL, "atmel_at76c502_3com.bin", "3com 3CRWE62092B" }, 
-	{ MANFID_3COM, 0x0696, NULL, "atmel_at76c502_3com.bin", "3com 3CRSHPW_96" }, 
-	{ 0, 0, "SMC/2632W-V2", "atmel_at76c502.bin", "SMC 2632W-V2" },
-        { 0, 0, "SMC/2632W", "atmel_at76c502d.bin", "SMC 2632W-V3" },
-	{ 0xd601, 0x0007, NULL, "atmel_at76c502.bin", "Sitecom WLAN-011"}, /* suspect - from a usenet posting. */
-	{ 0x01bf, 0x3302, NULL, "atmel_at76c502d.bin", "Belkin F5D6060u"},  /*    "        "  "    "      "     */
-	{ 0, 0, "BT/Voyager 1020 Laptop Adapter", "atmel_at76c502.bin", "BT Voyager 1020"},
-        { 0, 0, "IEEE 802.11b/Wireless LAN PC Card", "atmel_at76c502.bin", "Siemens Gigaset PC Card II" },
-	{ 0, 0, "CNet/CNWLC 11Mbps Wireless PC Card V-5", "atmel_at76c502e.bin", "CNet CNWLC-811ARL" }
+	{ 0, 0, "WLAN/802.11b PC CARD", "atmel_at76c502d%s.bin", "Actiontec 802CAT1" },  
+	{ 0, 0, "ATMEL/AT76C502AR", "atmel_at76c502%s.bin", "NoName-RFMD" }, 
+	{ 0, 0, "ATMEL/AT76C502AR_D", "atmel_at76c502d%s.bin", "NoName-revD" }, 
+	{ 0, 0, "ATMEL/AT76C502AR_E", "atmel_at76c502e%s.bin", "NoName-revE" },
+	{ 0, 0, "ATMEL/AT76C504", "atmel_at76c504%s.bin", "NoName-504" },
+	{ MANFID_3COM, 0x0620, NULL, "atmel_at76c502_3com%s.bin", "3com 3CRWE62092B" }, 
+	{ MANFID_3COM, 0x0696, NULL, "atmel_at76c502_3com%s.bin", "3com 3CRSHPW_96" }, 
+	{ 0, 0, "SMC/2632W-V2", "atmel_at76c502%s.bin", "SMC 2632W-V2" },
+        { 0, 0, "SMC/2632W", "atmel_at76c502d%s.bin", "SMC 2632W-V3" },
+	{ 0xd601, 0x0007, NULL, "atmel_at76c502%s.bin", "Sitecom WLAN-011"}, /* suspect - from a usenet posting. */
+	{ 0x01bf, 0x3302, NULL, "atmel_at76c502d%s.bin", "Belkin F5D6060u"},  /*    "        "  "    "      "     */
+	{ 0, 0, "BT/Voyager 1020 Laptop Adapter", "atmel_at76c502%s.bin", "BT Voyager 1020"},
+        { 0, 0, "IEEE 802.11b/Wireless LAN PC Card", "atmel_at76c502%s.bin", "Siemens Gigaset PC Card II" },
+	{ 0, 0, "CNet/CNWLC 11Mbps Wireless PC Card V-5", "atmel_at76c502e%s.bin", "CNet CNWLC-811ARL" }
 };
 
 /* This is strictly temporary, until PCMCIA devices get integrated into the device model. */
@@ -372,11 +369,11 @@ static void atmel_config(dev_link_t *lin
 	tuple.TupleOffset = 0;
 	
 	tuple.DesiredTuple = CISTPL_MANFID;
-	if (CardServices(GetFirstTuple, handle, &tuple) == 0) {
+	if (pcmcia_get_first_tuple(handle, &tuple) == 0) {
 		int i;
 		cistpl_manfid_t *manfid;
-		CS_CHECK(GetTupleData, handle, &tuple);
-		CS_CHECK(ParseTuple, handle, &tuple, &parse);
+		CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+		CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
 		manfid = &(parse.manfid);
 		for (i = 0; i < sizeof(card_table)/sizeof(card_table[0]); i++) {
 			if (!card_table[i].ver1 &&
@@ -389,11 +386,11 @@ static void atmel_config(dev_link_t *lin
 	}
 
 	tuple.DesiredTuple = CISTPL_VERS_1;
-	if (!done && (CardServices(GetFirstTuple, handle, &tuple) == 0)) {
+	if (!done && (pcmcia_get_first_tuple(handle, &tuple) == 0)) {
 		int i, j, k;
 		cistpl_vers_1_t *ver1;
-		CS_CHECK(GetTupleData, handle, &tuple);
-		CS_CHECK(ParseTuple, handle, &tuple, &parse);
+		CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+		CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
 		ver1 = &(parse.version_1);
 		
 		for (i = 0; i < sizeof(card_table)/sizeof(card_table[0]); i++) {
@@ -429,9 +426,9 @@ static void atmel_config(dev_link_t *lin
 	  registers.
 	*/
 	tuple.DesiredTuple = CISTPL_CONFIG;
-	CS_CHECK(GetFirstTuple, handle, &tuple);
-	CS_CHECK(GetTupleData, handle, &tuple);
-	CS_CHECK(ParseTuple, handle, &tuple, &parse);
+	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+	CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+	CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
 	link->conf.ConfigBase = parse.config.base;
 	link->conf.Present = parse.config.rmask[0];
 	
@@ -451,12 +448,13 @@ static void atmel_config(dev_link_t *lin
 	  will only use the CIS to fill in implementation-defined details.
 	*/
 	tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
-	CS_CHECK(GetFirstTuple, handle, &tuple);
+	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
 	while (1) {
 		cistpl_cftable_entry_t dflt = { 0 };
 		cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
-		CFG_CHECK(GetTupleData, handle, &tuple);
-		CFG_CHECK(ParseTuple, handle, &tuple, &parse);
+		if (pcmcia_get_tuple_data(handle, &tuple) != 0 ||
+				pcmcia_parse_tuple(handle, &tuple, &parse) != 0)
+			goto next_entry;
 		
 		if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg;
 		if (cfg->index == 0) goto next_entry;
@@ -505,12 +503,14 @@ static void atmel_config(dev_link_t *lin
 		}
 		
 		/* This reserves IO space but doesn't actually enable it */
-		CFG_CHECK(RequestIO, link->handle, &link->io); 
+		if (pcmcia_request_io(link->handle, &link->io) != 0)
+			goto next_entry;
+
 		/* If we got this far, we're cool! */
 		break;
 		
 	next_entry:
-		CS_CHECK(GetNextTuple, handle, &tuple);
+		CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple));
 	}
 	
 	/*
@@ -519,14 +519,14 @@ static void atmel_config(dev_link_t *lin
 	  irq structure is initialized.
 	*/
 	if (link->conf.Attributes & CONF_ENABLE_IRQ)
-		CS_CHECK(RequestIRQ, link->handle, &link->irq);
+		CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
 	
 	/*
 	  This actually configures the PCMCIA socket -- setting up
 	  the I/O windows and the interrupt mapping, and putting the
 	  card and host interface into "Memory and IO" mode.
 	*/
-	CS_CHECK(RequestConfiguration, link->handle, &link->conf);
+	CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
 	
 	if (link->irq.AssignedIRQ == 0) {
 		printk(KERN_ALERT 
@@ -602,11 +602,11 @@ static void atmel_release(dev_link_t *li
 	((local_info_t*)link->priv)->eth_dev = 0; 
 	
 	/* Don't bother checking to see if these succeed or not */
-	CardServices(ReleaseConfiguration, link->handle);
+	pcmcia_release_configuration(link->handle);
 	if (link->io.NumPorts1)
-		CardServices(ReleaseIO, link->handle, &link->io);
+		pcmcia_release_io(link->handle, &link->io);
 	if (link->irq.AssignedIRQ)
-		CardServices(ReleaseIRQ, link->handle, &link->irq);
+		pcmcia_release_irq(link->handle, &link->irq);
 	link->state &= ~DEV_CONFIG;
 }
 
@@ -648,7 +648,7 @@ static int atmel_event(event_t event, in
 	case CS_EVENT_RESET_PHYSICAL:
 		if (link->state & DEV_CONFIG) {
 			netif_device_detach(local->eth_dev);
-			CardServices(ReleaseConfiguration, link->handle);
+			pcmcia_release_configuration(link->handle);
 		}
 		break;
 	case CS_EVENT_PM_RESUME:
@@ -656,7 +656,7 @@ static int atmel_event(event_t event, in
 		/* Fall through... */
 	case CS_EVENT_CARD_RESET:
 		if (link->state & DEV_CONFIG) {
-			CardServices(RequestConfiguration, link->handle, &link->conf);
+			pcmcia_request_configuration(link->handle, &link->conf);
 			reset_atmel_card(local->eth_dev);
 			netif_device_attach(local->eth_dev);
 		}
diff -puN drivers/net/wireless/Kconfig~linus drivers/net/wireless/Kconfig
--- 25/drivers/net/wireless/Kconfig~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/wireless/Kconfig	2004-01-19 22:17:22.000000000 -0800
@@ -282,7 +282,7 @@ config PCMCIA_ATMEL
          one of these, you will need to provide a firmware image
 	 to be loaded into the card by the driver. The Atmel
 	 firmware package can be downloaded from
-	 http://www.thekelleys.org.uk/atmel/atmel_firmware.tar.gz
+	 http://www.thekelleys.org.uk/atmel
 
 config PCMCIA_WL3501
       tristate "Planet WL3501 PCMCIA cards"
diff -puN drivers/net/wireless/netwave_cs.c~linus drivers/net/wireless/netwave_cs.c
--- 25/drivers/net/wireless/netwave_cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/wireless/netwave_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -513,7 +513,7 @@ static dev_link_t *netwave_attach(void)
     client_reg.event_handler = &netwave_event;
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
-    ret = CardServices(RegisterClient, &link->handle, &client_reg);
+    ret = pcmcia_register_client(&link->handle, &client_reg);
     if (ret != 0) {
 	cs_error(link->handle, RegisterClient, ret);
 	netwave_detach(link);
@@ -555,7 +555,7 @@ static void netwave_detach(dev_link_t *l
 	
     /* Break the link with Card Services */
     if (link->handle)
-	CardServices(DeregisterClient, link->handle);
+	pcmcia_deregister_client(link->handle);
     
     /* Locate device structure */
     for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
@@ -998,8 +998,8 @@ static int netwave_ioctl(struct net_devi
  *
  */
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static void netwave_pcmcia_config(dev_link_t *link) {
     client_handle_t handle = link->handle;
@@ -1024,9 +1024,9 @@ static void netwave_pcmcia_config(dev_li
     tuple.TupleDataMax = 64;
     tuple.TupleOffset = 0;
     tuple.DesiredTuple = CISTPL_CONFIG;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
-    CS_CHECK(GetTupleData, handle, &tuple);
-    CS_CHECK(ParseTuple, handle, &tuple, &parse);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+    CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+    CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
     link->conf.ConfigBase = parse.config.base;
     link->conf.Present = parse.config.rmask[0];
 
@@ -1040,7 +1040,7 @@ static void netwave_pcmcia_config(dev_li
      */
     for (i = j = 0x0; j < 0x400; j += 0x20) {
 	link->io.BasePort1 = j ^ 0x300;
-	i = CardServices(RequestIO, link->handle, &link->io);
+	i = pcmcia_request_io(link->handle, &link->io);
 	if (i == CS_SUCCESS) break;
     }
     if (i != CS_SUCCESS) {
@@ -1052,13 +1052,13 @@ static void netwave_pcmcia_config(dev_li
      *  Now allocate an interrupt line.  Note that this does not
      *  actually assign a handler to the interrupt.
      */
-    CS_CHECK(RequestIRQ, handle, &link->irq);
+    CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq));
 
     /*
      *  This actually configures the PCMCIA socket -- setting up
      *  the I/O windows and the interrupt mapping.
      */
-    CS_CHECK(RequestConfiguration, handle, &link->conf);
+    CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf));
 
     /*
      *  Allocate a 32K memory window.  Note that the dev_link_t
@@ -1071,10 +1071,9 @@ static void netwave_pcmcia_config(dev_li
     req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_CM|WIN_ENABLE;
     req.Base = 0; req.Size = 0x8000;
     req.AccessSpeed = mem_speed;
-    link->win = (window_handle_t)link->handle;
-    CS_CHECK(RequestWindow, &link->win, &req);
+    CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &link->win));
     mem.CardOffset = 0x20000; mem.Page = 0; 
-    CS_CHECK(MapMemPage, link->win, &mem);
+    CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem));
 
     /* Store base address of the common window frame */
     ramBase = ioremap(req.Base, 0x8000);
@@ -1145,11 +1144,11 @@ static void netwave_release(dev_link_t *
     /* Don't bother checking to see if these succeed or not */
     if (link->win) {
 	iounmap(priv->ramBase);
-	CardServices(ReleaseWindow, link->win);
+	pcmcia_release_window(link->win);
     }
-    CardServices(ReleaseConfiguration, link->handle);
-    CardServices(ReleaseIO, link->handle, &link->io);
-    CardServices(ReleaseIRQ, link->handle, &link->irq);
+    pcmcia_release_configuration(link->handle);
+    pcmcia_release_io(link->handle, &link->io);
+    pcmcia_release_irq(link->handle, &link->irq);
 
     link->state &= ~DEV_CONFIG;
 
@@ -1201,7 +1200,7 @@ static int netwave_event(event_t event, 
 	if (link->state & DEV_CONFIG) {
 	    if (link->open)
 		netif_device_detach(dev);
-	    CardServices(ReleaseConfiguration, link->handle);
+	    pcmcia_release_configuration(link->handle);
 	}
 	break;
     case CS_EVENT_PM_RESUME:
@@ -1209,7 +1208,7 @@ static int netwave_event(event_t event, 
 	/* Fall through... */
     case CS_EVENT_CARD_RESET:
 	if (link->state & DEV_CONFIG) {
-	    CardServices(RequestConfiguration, link->handle, &link->conf);
+	    pcmcia_request_configuration(link->handle, &link->conf);
 	    if (link->open) {
 		netwave_reset(dev);
 		netif_device_attach(dev);
diff -puN drivers/net/wireless/orinoco_cs.c~linus drivers/net/wireless/orinoco_cs.c
--- 25/drivers/net/wireless/orinoco_cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/wireless/orinoco_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -131,7 +131,7 @@ orinoco_cs_hard_reset(struct orinoco_pri
 	/* We need atomic ops here, because we're not holding the lock */
 	set_bit(0, &card->hard_reset_in_progress);
 
-	err = CardServices(ResetCard, link->handle, NULL);
+	err = pcmcia_reset_card(link->handle, NULL);
 	if (err)
 		return err;
 
@@ -150,7 +150,7 @@ static void
 orinoco_cs_error(client_handle_t handle, int func, int ret)
 {
 	error_info_t err = { func, ret };
-	CardServices(ReportError, handle, &err);
+	pcmcia_report_error(handle, &err);
 }
 
 /*
@@ -214,7 +214,7 @@ orinoco_cs_attach(void)
 	client_reg.Version = 0x0210; /* FIXME: what does this mean? */
 	client_reg.event_callback_args.client_data = link;
 
-	ret = CardServices(RegisterClient, &link->handle, &client_reg);
+	ret = pcmcia_register_client(&link->handle, &client_reg);
 	if (ret != CS_SUCCESS) {
 		orinoco_cs_error(link->handle, RegisterClient, ret);
 		orinoco_cs_detach(link);
@@ -250,7 +250,7 @@ orinoco_cs_detach(dev_link_t * link)
 
 	/* Break the link with Card Services */
 	if (link->handle)
-		CardServices(DeregisterClient, link->handle);
+		pcmcia_deregister_client(link->handle);
 
 	/* Unlink device structure, and free it */
 	*linkp = link->next;
@@ -269,11 +269,8 @@ orinoco_cs_detach(dev_link_t * link)
  * device available to the system.
  */
 
-#define CS_CHECK(fn, args...) \
-	while ((last_ret=CardServices(last_fn=(fn),args))!=0) goto cs_failed
-
-#define CFG_CHECK(fn, args...) \
-	if (CardServices(fn, args) != 0) goto next_entry
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static void
 orinoco_cs_config(dev_link_t *link)
@@ -290,7 +287,7 @@ orinoco_cs_config(dev_link_t *link)
 	tuple_t tuple;
 	cisparse_t parse;
 
-	CS_CHECK(ValidateCIS, handle, &info);
+	CS_CHECK(ValidateCIS, pcmcia_validate_cis(handle, &info));
 
 	/*
 	 * This reads the card's CONFIG tuple to find its
@@ -301,9 +298,9 @@ orinoco_cs_config(dev_link_t *link)
 	tuple.TupleData = buf;
 	tuple.TupleDataMax = sizeof(buf);
 	tuple.TupleOffset = 0;
-	CS_CHECK(GetFirstTuple, handle, &tuple);
-	CS_CHECK(GetTupleData, handle, &tuple);
-	CS_CHECK(ParseTuple, handle, &tuple, &parse);
+	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+	CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+	CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
 	link->conf.ConfigBase = parse.config.base;
 	link->conf.Present = parse.config.rmask[0];
 
@@ -311,7 +308,7 @@ orinoco_cs_config(dev_link_t *link)
 	link->state |= DEV_CONFIG;
 
 	/* Look up the current Vcc */
-	CS_CHECK(GetConfigurationInfo, handle, &conf);
+	CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf));
 	link->conf.Vcc = conf.Vcc;
 
 	/*
@@ -329,13 +326,14 @@ orinoco_cs_config(dev_link_t *link)
 	 * implementation-defined details.
 	 */
 	tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
-	CS_CHECK(GetFirstTuple, handle, &tuple);
+	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
 	while (1) {
 		cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
 		cistpl_cftable_entry_t dflt = { .index = 0 };
 
-		CFG_CHECK(GetTupleData, handle, &tuple);
-		CFG_CHECK(ParseTuple, handle, &tuple, &parse);
+		if (pcmcia_get_tuple_data(handle, &tuple) != 0 ||
+				pcmcia_parse_tuple(handle, &tuple, &parse) != 0)
+			goto next_entry;
 
 		if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
 			dflt = *cfg;
@@ -400,7 +398,8 @@ orinoco_cs_config(dev_link_t *link)
 			}
 
 			/* This reserves IO space but doesn't actually enable it */
-			CFG_CHECK(RequestIO, link->handle, &link->io);
+			if (pcmcia_request_io(link->handle, &link->io) != 0)
+				goto next_entry;
 		}
 
 
@@ -410,8 +409,8 @@ orinoco_cs_config(dev_link_t *link)
 		
 	next_entry:
 		if (link->io.NumPorts1)
-			CardServices(ReleaseIO, link->handle, &link->io);
-		last_ret = CardServices(GetNextTuple, handle, &tuple);
+			pcmcia_release_io(link->handle, &link->io);
+		last_ret = pcmcia_get_next_tuple(handle, &tuple);
 		if (last_ret  == CS_NO_MORE_ITEMS) {
 			printk(KERN_ERR "GetNextTuple().  No matching CIS configuration, "
 			       "maybe you need the ignore_cis_vcc=1 parameter.\n");
@@ -438,7 +437,7 @@ orinoco_cs_config(dev_link_t *link)
   		link->irq.Handler = orinoco_interrupt; 
   		link->irq.Instance = dev; 
 		
-		CS_CHECK(RequestIRQ, link->handle, &link->irq);
+		CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
 	}
 
 	/* We initialize the hermes structure before completing PCMCIA
@@ -452,7 +451,7 @@ orinoco_cs_config(dev_link_t *link)
 	 * the I/O windows and the interrupt mapping, and putting the
 	 * card and host interface into "Memory and IO" mode.
 	 */
-	CS_CHECK(RequestConfiguration, link->handle, &link->conf);
+	CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
 
 	/* Ok, we have the configuration, prepare to register the netdev */
 	dev->base_addr = link->io.BasePort1;
@@ -521,11 +520,11 @@ orinoco_cs_release(dev_link_t *link)
 	spin_unlock_irqrestore(&priv->lock, flags);
 
 	/* Don't bother checking to see if these succeed or not */
-	CardServices(ReleaseConfiguration, link->handle);
+	pcmcia_release_configuration(link->handle);
 	if (link->io.NumPorts1)
-		CardServices(ReleaseIO, link->handle, &link->io);
+		pcmcia_release_io(link->handle, &link->io);
 	if (link->irq.AssignedIRQ)
-		CardServices(ReleaseIRQ, link->handle, &link->irq);
+		pcmcia_release_irq(link->handle, &link->irq);
 	link->state &= ~DEV_CONFIG;
 }				/* orinoco_cs_release */
 
@@ -587,7 +586,7 @@ orinoco_cs_event(event_t event, int prio
 				spin_unlock_irqrestore(&priv->lock, flags);
 			}
 
-			CardServices(ReleaseConfiguration, link->handle);
+			pcmcia_release_configuration(link->handle);
 		}
 		break;
 
@@ -598,8 +597,7 @@ orinoco_cs_event(event_t event, int prio
 		if (link->state & DEV_CONFIG) {
 			/* FIXME: should we double check that this is
 			 * the same card as we had before */
-			CardServices(RequestConfiguration, link->handle,
-				     &link->conf);
+			pcmcia_request_configuration(link->handle, &link->conf);
 
 			if (! test_bit(0, &card->hard_reset_in_progress)) {
 				err = orinoco_reinit_firmware(dev);
diff -puN drivers/net/wireless/orinoco_pci.c~linus drivers/net/wireless/orinoco_pci.c
--- 25/drivers/net/wireless/orinoco_pci.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/wireless/orinoco_pci.c	2004-01-19 22:17:22.000000000 -0800
@@ -360,6 +360,7 @@ static int orinoco_pci_resume(struct pci
 }
 
 static struct pci_device_id orinoco_pci_pci_id_table[] = {
+	{0x1260, 0x3872, PCI_ANY_ID, PCI_ANY_ID,},
 	{0x1260, 0x3873, PCI_ANY_ID, PCI_ANY_ID,},
 	{0,},
 };
diff -puN drivers/net/wireless/ray_cs.c~linus drivers/net/wireless/ray_cs.c
--- 25/drivers/net/wireless/ray_cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/wireless/ray_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -420,7 +420,7 @@ static dev_link_t *ray_attach(void)
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
 
-    DEBUG(2,"ray_cs ray_attach calling CardServices(RegisterClient...)\n");
+    DEBUG(2,"ray_cs ray_attach calling pcmcia_register_client(...)\n");
 
     init_timer(&local->timer);
 
@@ -490,8 +490,8 @@ static void ray_detach(dev_link_t *link)
     is received, to configure the PCMCIA socket, and to make the
     ethernet device available to the system.
 =============================================================================*/
-#define CS_CHECK(fn, args...) \
-while ((last_ret=fn(args))!=0) goto cs_failed
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 #define MAX_TUPLE_SIZE 128
 static void ray_config(dev_link_t *link)
 {
@@ -510,23 +510,23 @@ static void ray_config(dev_link_t *link)
 
     /* This reads the card's CONFIG tuple to find its configuration regs */
     tuple.DesiredTuple = CISTPL_CONFIG;
-    CS_CHECK(pcmcia_get_first_tuple, handle, &tuple);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
     tuple.TupleData = buf;
     tuple.TupleDataMax = MAX_TUPLE_SIZE;
     tuple.TupleOffset = 0;
-    CS_CHECK(pcmcia_get_tuple_data, handle, &tuple);
-    CS_CHECK(pcmcia_parse_tuple, handle, &tuple, &parse);
+    CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+    CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
     link->conf.ConfigBase = parse.config.base;
     link->conf.Present = parse.config.rmask[0];
 
     /* Determine card type and firmware version */
     buf[0] = buf[MAX_TUPLE_SIZE - 1] = 0;
     tuple.DesiredTuple = CISTPL_VERS_1;
-    CS_CHECK(pcmcia_get_first_tuple, handle, &tuple);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
     tuple.TupleData = buf;
     tuple.TupleDataMax = MAX_TUPLE_SIZE;
     tuple.TupleOffset = 2;
-    CS_CHECK(pcmcia_get_tuple_data, handle, &tuple);
+    CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
 
     for (i=0; i<tuple.TupleDataLen - 4; i++) 
         if (buf[i] == 0) buf[i] = ' ';
@@ -538,22 +538,22 @@ static void ray_config(dev_link_t *link)
     /* Now allocate an interrupt line.  Note that this does not
        actually assign a handler to the interrupt.
     */
-    CS_CHECK(pcmcia_request_irq, link->handle, &link->irq);
+    CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
     dev->irq = link->irq.AssignedIRQ;
     
     /* This actually configures the PCMCIA socket -- setting up
        the I/O windows and the interrupt mapping.
     */
-    CS_CHECK(pcmcia_request_configuration, link->handle, &link->conf);
+    CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
 
 /*** Set up 32k window for shared memory (transmit and control) ************/
     req.Attributes = WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
     req.Base = 0;
     req.Size = 0x8000;
     req.AccessSpeed = ray_mem_speed;
-    CS_CHECK(pcmcia_request_window, &link->handle, &req, &link->win);
+    CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &link->win));
     mem.CardOffset = 0x0000; mem.Page = 0;
-    CS_CHECK(pcmcia_map_mem_page, link->win, &mem);
+    CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem));
     local->sram = (UCHAR *)(ioremap(req.Base,req.Size));
 
 /*** Set up 16k window for shared memory (receive buffer) ***************/
@@ -561,9 +561,9 @@ static void ray_config(dev_link_t *link)
     req.Base = 0;
     req.Size = 0x4000;
     req.AccessSpeed = ray_mem_speed;
-    CS_CHECK(pcmcia_request_window, &link->handle, &req, &local->rmem_handle);
+    CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &local->rmem_handle));
     mem.CardOffset = 0x8000; mem.Page = 0;
-    CS_CHECK(pcmcia_map_mem_page, local->rmem_handle, &mem);
+    CS_CHECK(MapMemPage, pcmcia_map_mem_page(local->rmem_handle, &mem));
     local->rmem = (UCHAR *)(ioremap(req.Base,req.Size));
 
 /*** Set up window for attribute memory ***********************************/
@@ -571,9 +571,9 @@ static void ray_config(dev_link_t *link)
     req.Base = 0;
     req.Size = 0x1000;
     req.AccessSpeed = ray_mem_speed;
-    CS_CHECK(pcmcia_request_window, &link->handle, &req, &local->amem_handle);
+    CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &local->amem_handle));
     mem.CardOffset = 0x0000; mem.Page = 0;
-    CS_CHECK(pcmcia_map_mem_page, local->amem_handle, &mem);
+    CS_CHECK(MapMemPage, pcmcia_map_mem_page(local->amem_handle, &mem));
     local->amem = (UCHAR *)(ioremap(req.Base,req.Size));
 
     DEBUG(3,"ray_config sram=%p\n",local->sram);
diff -puN drivers/net/wireless/wavelan_cs.c~linus drivers/net/wireless/wavelan_cs.c
--- 25/drivers/net/wireless/wavelan_cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/wireless/wavelan_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -3802,7 +3802,7 @@ wv_pcmcia_reset(device *	dev)
   printk(KERN_DEBUG "%s: ->wv_pcmcia_reset()\n", dev->name);
 #endif
 
-  i = CardServices(AccessConfigurationRegister, link->handle, &reg);
+  i = pcmcia_access_configuration_register(link->handle, &reg);
   if(i != CS_SUCCESS)
     {
       cs_error(link->handle, AccessConfigurationRegister, i);
@@ -3816,7 +3816,7 @@ wv_pcmcia_reset(device *	dev)
 
   reg.Action = CS_WRITE;
   reg.Value = reg.Value | COR_SW_RESET;
-  i = CardServices(AccessConfigurationRegister, link->handle, &reg);
+  i = pcmcia_access_configuration_register(link->handle, &reg);
   if(i != CS_SUCCESS)
     {
       cs_error(link->handle, AccessConfigurationRegister, i);
@@ -3825,7 +3825,7 @@ wv_pcmcia_reset(device *	dev)
       
   reg.Action = CS_WRITE;
   reg.Value = COR_LEVEL_IRQ | COR_CONFIG;
-  i = CardServices(AccessConfigurationRegister, link->handle, &reg);
+  i = pcmcia_access_configuration_register(link->handle, &reg);
   if(i != CS_SUCCESS)
     {
       cs_error(link->handle, AccessConfigurationRegister, i);
@@ -4018,16 +4018,16 @@ wv_pcmcia_config(dev_link_t *	link)
     {
       tuple.Attributes = 0;
       tuple.DesiredTuple = CISTPL_CONFIG;
-      i = CardServices(GetFirstTuple, handle, &tuple);
+      i = pcmcia_get_first_tuple(handle, &tuple);
       if(i != CS_SUCCESS)
 	break;
       tuple.TupleData = (cisdata_t *)buf;
       tuple.TupleDataMax = 64;
       tuple.TupleOffset = 0;
-      i = CardServices(GetTupleData, handle, &tuple);
+      i = pcmcia_get_tuple_data(handle, &tuple);
       if(i != CS_SUCCESS)
 	break;
-      i = CardServices(ParseTuple, handle, &tuple, &parse);
+      i = pcmcia_parse_tuple(handle, &tuple, &parse);
       if(i != CS_SUCCESS)
 	break;
       link->conf.ConfigBase = parse.config.base;
@@ -4045,7 +4045,7 @@ wv_pcmcia_config(dev_link_t *	link)
   link->state |= DEV_CONFIG;
   do
     {
-      i = CardServices(RequestIO, link->handle, &link->io);
+      i = pcmcia_request_io(link->handle, &link->io);
       if(i != CS_SUCCESS)
 	{
 	  cs_error(link->handle, RequestIO, i);
@@ -4056,7 +4056,7 @@ wv_pcmcia_config(dev_link_t *	link)
        * Now allocate an interrupt line.  Note that this does not
        * actually assign a handler to the interrupt.
        */
-      i = CardServices(RequestIRQ, link->handle, &link->irq);
+      i = pcmcia_request_irq(link->handle, &link->irq);
       if(i != CS_SUCCESS)
 	{
 	  cs_error(link->handle, RequestIRQ, i);
@@ -4068,7 +4068,7 @@ wv_pcmcia_config(dev_link_t *	link)
        * the I/O windows and the interrupt mapping.
        */
       link->conf.ConfigIndex = 1;
-      i = CardServices(RequestConfiguration, link->handle, &link->conf);
+      i = pcmcia_request_configuration(link->handle, &link->conf);
       if(i != CS_SUCCESS)
 	{
 	  cs_error(link->handle, RequestConfiguration, i);
@@ -4084,8 +4084,7 @@ wv_pcmcia_config(dev_link_t *	link)
       req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
       req.Base = req.Size = 0;
       req.AccessSpeed = mem_speed;
-      link->win = (window_handle_t)link->handle;
-      i = CardServices(RequestWindow, &link->win, &req);
+      i = pcmcia_request_window(&link->handle, &req, &link->win);
       if(i != CS_SUCCESS)
 	{
 	  cs_error(link->handle, RequestWindow, i);
@@ -4096,7 +4095,7 @@ wv_pcmcia_config(dev_link_t *	link)
       dev->mem_end = dev->mem_start + req.Size;
 
       mem.CardOffset = 0; mem.Page = 0;
-      i = CardServices(MapMemPage, link->win, &mem);
+      i = pcmcia_map_mem_page(link->win, &mem);
       if(i != CS_SUCCESS)
 	{
 	  cs_error(link->handle, MapMemPage, i);
@@ -4170,10 +4169,10 @@ wv_pcmcia_release(dev_link_t *link)
 
   /* Don't bother checking to see if these succeed or not */
   iounmap((u_char *)dev->mem_start);
-  CardServices(ReleaseWindow, link->win);
-  CardServices(ReleaseConfiguration, link->handle);
-  CardServices(ReleaseIO, link->handle, &link->io);
-  CardServices(ReleaseIRQ, link->handle, &link->irq);
+  pcmcia_release_window(link->win);
+  pcmcia_release_configuration(link->handle);
+  pcmcia_release_io(link->handle, &link->io);
+  pcmcia_release_irq(link->handle, &link->irq);
 
   link->state &= ~DEV_CONFIG;
 
@@ -4772,10 +4771,10 @@ wavelan_attach(void)
   client_reg.event_callback_args.client_data = link;
 
 #ifdef DEBUG_CONFIG_INFO
-  printk(KERN_DEBUG "wavelan_attach(): almost done, calling CardServices\n");
+  printk(KERN_DEBUG "wavelan_attach(): almost done, calling pcmcia_register_client\n");
 #endif
 
-  ret = CardServices(RegisterClient, &link->handle, &client_reg);
+  ret = pcmcia_register_client(&link->handle, &client_reg);
   if(ret != 0)
     {
       cs_error(link->handle, RegisterClient, ret);
@@ -4826,7 +4825,7 @@ wavelan_detach(dev_link_t *	link)
 
   /* Break the link with Card Services */
   if(link->handle)
-    CardServices(DeregisterClient, link->handle);
+    pcmcia_deregister_client(link->handle);
     
   /* Remove the interface data from the linked list */
   if(dev_list == link)
@@ -4955,7 +4954,7 @@ wavelan_event(event_t		event,		/* The ev
 	  {
       	    if(link->open)
 	      netif_device_detach(dev);
-      	    CardServices(ReleaseConfiguration, link->handle);
+      	    pcmcia_release_configuration(link->handle);
 	  }
 	break;
 
@@ -4965,7 +4964,7 @@ wavelan_event(event_t		event,		/* The ev
       case CS_EVENT_CARD_RESET:
 	if(link->state & DEV_CONFIG)
 	  {
-      	    CardServices(RequestConfiguration, link->handle, &link->conf);
+      	    pcmcia_request_configuration(link->handle, &link->conf);
       	    if(link->open)	/* If RESET -> True, If RESUME -> False ? */
 	      {
 		wv_hw_reset(dev);
diff -puN drivers/net/wireless/wl3501_cs.c~linus drivers/net/wireless/wl3501_cs.c
--- 25/drivers/net/wireless/wl3501_cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/net/wireless/wl3501_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -1586,7 +1586,7 @@ static void wl3501_detach(dev_link_t *li
 
 	/* Break the link with Card Services */
 	if (link->handle)
-		CardServices(DeregisterClient, link->handle);
+		pcmcia_deregister_client(link->handle);
 
 	/* Unlink device structure, free pieces */
 	*linkp = link->next;
@@ -2083,7 +2083,7 @@ static dev_link_t *wl3501_attach(void)
 	client_reg.event_handler = wl3501_event;
 	client_reg.Version	 = 0x0210;
 	client_reg.event_callback_args.client_data = link;
-	ret = CardServices(RegisterClient, &link->handle, &client_reg);
+	ret = pcmcia_register_client(&link->handle, &client_reg);
 	if (ret) {
 		cs_error(link->handle, RegisterClient, ret);
 		wl3501_detach(link);
@@ -2097,8 +2097,8 @@ out_link:
 	goto out;
 }
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret = CardServices(last_fn = (fn), args)) != 0) goto cs_failed
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 /**
  * wl3501_config - configure the PCMCIA socket and make eth device available
@@ -2121,12 +2121,12 @@ static void wl3501_config(dev_link_t *li
 	/* This reads the card's CONFIG tuple to find its config registers. */
 	tuple.Attributes	= 0;
 	tuple.DesiredTuple	= CISTPL_CONFIG;
-	CS_CHECK(GetFirstTuple, handle, &tuple);
+	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
 	tuple.TupleData		= bf;
 	tuple.TupleDataMax	= sizeof(bf);
 	tuple.TupleOffset	= 0;
-	CS_CHECK(GetTupleData, handle, &tuple);
-	CS_CHECK(ParseTuple, handle, &tuple, &parse);
+	CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+	CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
 	link->conf.ConfigBase	= parse.config.base;
 	link->conf.Present	= parse.config.rmask[0];
 
@@ -2142,7 +2142,7 @@ static void wl3501_config(dev_link_t *li
 		 * 0x200-0x2ff, and so on, because this seems safer */
 		link->io.BasePort1 = j;
 		link->io.BasePort2 = link->io.BasePort1 + 0x10;
-		i = CardServices(RequestIO, link->handle, &link->io);
+		i = pcmcia_request_io(link->handle, &link->io);
 		if (i == CS_SUCCESS)
 			break;
 	}
@@ -2154,12 +2154,12 @@ static void wl3501_config(dev_link_t *li
 	/* Now allocate an interrupt line. Note that this does not actually
 	 * assign a handler to the interrupt. */
 
-	CS_CHECK(RequestIRQ, link->handle, &link->irq);
+	CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
 
 	/* This actually configures the PCMCIA socket -- setting up the I/O
 	 * windows and the interrupt mapping.  */
 
-	CS_CHECK(RequestConfiguration, link->handle, &link->conf);
+	CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
 
 	dev->irq = link->irq.AssignedIRQ;
 	dev->base_addr = link->io.BasePort1;
@@ -2249,9 +2249,9 @@ static void wl3501_release(dev_link_t *l
 	}
 
 	/* Don't bother checking to see if these succeed or not */
-	CardServices(ReleaseConfiguration, link->handle);
-	CardServices(ReleaseIO, link->handle, &link->io);
-	CardServices(ReleaseIRQ, link->handle, &link->irq);
+	pcmcia_release_configuration(link->handle);
+	pcmcia_release_io(link->handle, &link->io);
+	pcmcia_release_irq(link->handle, &link->irq);
 	link->state &= ~DEV_CONFIG;
 
 	if (link->state & DEV_STALE_CONFIG)
@@ -2301,7 +2301,7 @@ static int wl3501_event(event_t event, i
 		if (link->state & DEV_CONFIG) {
 			if (link->open)
 				netif_device_detach(dev);
-			CardServices(ReleaseConfiguration, link->handle);
+			pcmcia_release_configuration(link->handle);
 		}
 		break;
 	case CS_EVENT_PM_RESUME:
@@ -2310,8 +2310,7 @@ static int wl3501_event(event_t event, i
 		/* Fall through... */
 	case CS_EVENT_CARD_RESET:
 		if (link->state & DEV_CONFIG) {
-			CardServices(RequestConfiguration, link->handle,
-				     &link->conf);
+			pcmcia_request_configuration(link->handle, &link->conf);
 			if (link->open) {
 				wl3501_reset(dev);
 				netif_device_attach(dev);
diff -puN drivers/oprofile/oprofile_stats.c~linus drivers/oprofile/oprofile_stats.c
--- 25/drivers/oprofile/oprofile_stats.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/oprofile/oprofile_stats.c	2004-01-19 22:17:22.000000000 -0800
@@ -9,6 +9,7 @@
 
 #include <linux/oprofile.h>
 #include <linux/smp.h>
+#include <linux/cpumask.h>
 #include <linux/threads.h>
  
 #include "oprofile_stats.h"
diff -puN drivers/parport/parport_cs.c~linus drivers/parport/parport_cs.c
--- 25/drivers/parport/parport_cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/parport/parport_cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -151,7 +151,7 @@ static dev_link_t *parport_attach(void)
     client_reg.event_handler = &parport_event;
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
-    ret = CardServices(RegisterClient, &link->handle, &client_reg);
+    ret = pcmcia_register_client(&link->handle, &client_reg);
     if (ret != CS_SUCCESS) {
 	cs_error(link->handle, RegisterClient, ret);
 	parport_detach(link);
@@ -187,7 +187,7 @@ static void parport_detach(dev_link_t *l
 	parport_cs_release(link);
     
     if (link->handle) {
-	ret = CardServices(DeregisterClient, link->handle);
+	ret = pcmcia_deregister_client(link->handle);
 	if (ret != CS_SUCCESS)
 	    cs_error(link->handle, DeregisterClient, ret);
     }
@@ -206,11 +206,8 @@ static void parport_detach(dev_link_t *l
 
 ======================================================================*/
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
-
-#define CFG_CHECK(fn, args...) \
-if (CardServices(fn, args) != 0) goto next_entry
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 void parport_config(dev_link_t *link)
 {
@@ -231,9 +228,9 @@ void parport_config(dev_link_t *link)
     tuple.TupleOffset = 0; tuple.TupleDataMax = 255;
     tuple.Attributes = 0;
     tuple.DesiredTuple = CISTPL_CONFIG;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
-    CS_CHECK(GetTupleData, handle, &tuple);
-    CS_CHECK(ParseTuple, handle, &tuple, &parse);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+    CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+    CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
     link->conf.ConfigBase = parse.config.base;
     link->conf.Present = parse.config.rmask[0];
     
@@ -241,14 +238,15 @@ void parport_config(dev_link_t *link)
     link->state |= DEV_CONFIG;
 
     /* Not sure if this is right... look up the current Vcc */
-    CS_CHECK(GetConfigurationInfo, handle, &conf);
+    CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf));
     
     tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
     tuple.Attributes = 0;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
     while (1) {
-	CFG_CHECK(GetTupleData, handle, &tuple);
-	CFG_CHECK(ParseTuple, handle, &tuple, &parse);
+	if (pcmcia_get_tuple_data(handle, &tuple) != 0 ||
+		pcmcia_parse_tuple(handle, &tuple, &parse) != 0)
+	    goto next_entry;
 
 	if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
 	    cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io;
@@ -262,18 +260,19 @@ void parport_config(dev_link_t *link)
 		link->io.BasePort2 = io->win[1].base;
 		link->io.NumPorts2 = io->win[1].len;
 	    }
-	    CFG_CHECK(RequestIO, link->handle, &link->io);
+	    if (pcmcia_request_io(link->handle, &link->io) != 0)
+		goto next_entry;
 	    /* If we've got this far, we're done */
 	    break;
 	}
 	
     next_entry:
 	if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg;
-	CS_CHECK(GetNextTuple, handle, &tuple);
+	CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple));
     }
     
-    CS_CHECK(RequestIRQ, handle, &link->irq);
-    CS_CHECK(RequestConfiguration, handle, &link->conf);
+    CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq));
+    CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf));
 
     release_region(link->io.BasePort1, link->io.NumPorts1);
     if (link->io.NumPorts2)
@@ -335,9 +334,9 @@ void parport_cs_release(dev_link_t *link
     info->ndev = 0;
     link->dev = NULL;
     
-    CardServices(ReleaseConfiguration, link->handle);
-    CardServices(ReleaseIO, link->handle, &link->io);
-    CardServices(ReleaseIRQ, link->handle, &link->irq);
+    pcmcia_release_configuration(link->handle);
+    pcmcia_release_io(link->handle, &link->io);
+    pcmcia_release_irq(link->handle, &link->irq);
     
     link->state &= ~DEV_CONFIG;
 
@@ -372,14 +371,14 @@ int parport_event(event_t event, int pri
 	/* Fall through... */
     case CS_EVENT_RESET_PHYSICAL:
 	if (link->state & DEV_CONFIG)
-	    CardServices(ReleaseConfiguration, link->handle);
+	    pcmcia_release_configuration(link->handle);
 	break;
     case CS_EVENT_PM_RESUME:
 	link->state &= ~DEV_SUSPEND;
 	/* Fall through... */
     case CS_EVENT_CARD_RESET:
 	if (DEV_OK(link))
-	    CardServices(RequestConfiguration, link->handle, &link->conf);
+	    pcmcia_request_configuration(link->handle, &link->conf);
 	break;
     }
     return 0;
diff -puN drivers/pci/pci.ids~linus drivers/pci/pci.ids
--- 25/drivers/pci/pci.ids~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/pci/pci.ids	2004-01-19 22:17:22.000000000 -0800
@@ -3539,6 +3539,7 @@
 11aa  Actel
 11ab  Galileo Technology Ltd.
 	0146  GT-64010/64010A System Controller
+	4146  GT-64111 System Controller
 	4320  Gigabit Ethernet Adapter
 		11ab 9521  Marvell Yukon Gigabit Ethernet 10/100/1000Base-T Adapter
 	4611  GT-64115 System Controller
@@ -3725,6 +3726,7 @@
 11d9  TEC Corporation
 11da  Novell
 11db  Sega Enterprises Ltd
+	1234  Broadband Adapter
 11dc  Questra Corporation
 11dd  Crosfield Electronics Limited
 11de  Zoran Corporation
diff -puN drivers/pci/quirks.c~linus drivers/pci/quirks.c
--- 25/drivers/pci/quirks.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/pci/quirks.c	2004-01-19 22:17:22.000000000 -0800
@@ -858,6 +858,7 @@ static struct pci_fixup pci_fixups[] __d
 	{ PCI_FIXUP_FINAL,	PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C586_0,	quirk_isa_dma_hangs },
 	{ PCI_FIXUP_FINAL,	PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C596,	quirk_isa_dma_hangs },
 	{ PCI_FIXUP_FINAL,      PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_82371SB_0,  quirk_isa_dma_hangs },
+	{ PCI_FIXUP_FINAL,	PCI_VENDOR_ID_AL,	PCI_DEVICE_ID_AL_M1533, 	quirk_isa_dma_hangs },
 	{ PCI_FIXUP_FINAL,	PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_82454NX,	quirk_disable_pxb },
 	{ PCI_FIXUP_FINAL,	PCI_VENDOR_ID_NEC,	PCI_DEVICE_ID_NEC_CBUS_1,	quirk_isa_dma_hangs },
 	{ PCI_FIXUP_FINAL,	PCI_VENDOR_ID_NEC,	PCI_DEVICE_ID_NEC_CBUS_2,	quirk_isa_dma_hangs },
diff -puN drivers/pcmcia/cs.c~linus drivers/pcmcia/cs.c
--- 25/drivers/pcmcia/cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/pcmcia/cs.c	2004-01-19 22:17:22.000000000 -0800
@@ -2289,149 +2289,6 @@ int pcmcia_report_error(client_handle_t 
     return CS_SUCCESS;
 } /* report_error */
 
-/*====================================================================*/
-
-int CardServices(int func, void *a1, void *a2, void *a3)
-{
-
-#ifdef PCMCIA_DEBUG
-    if (pc_debug > 2) {
-	int i;
-	for (i = 0; i < SERVICE_COUNT; i++)
-	    if (service_table[i].key == func) break;
-	if (i < SERVICE_COUNT)
-	    printk(KERN_DEBUG "cs: CardServices(%s, 0x%p, 0x%p)\n",
-		   service_table[i].msg, a1, a2);
-	else
-	    printk(KERN_DEBUG "cs: CardServices(Unknown func %d, "
-		   "0x%p, 0x%p)\n", func, a1, a2);
-    }
-#endif
-    switch (func) {
-    case AccessConfigurationRegister:
-	return pcmcia_access_configuration_register(a1, a2); break;
-    case AdjustResourceInfo:
-	return pcmcia_adjust_resource_info(a1, a2); break;
-    case CheckEraseQueue:
-	return pcmcia_check_erase_queue(a1); break;
-    case CloseMemory:
-	return pcmcia_close_memory(a1); break;
-    case CopyMemory:
-	return pcmcia_copy_memory(a1, a2); break;
-    case DeregisterClient:
-	return pcmcia_deregister_client(a1); break;
-    case DeregisterEraseQueue:
-	return pcmcia_deregister_erase_queue(a1); break;
-    case GetFirstClient:
-	return pcmcia_get_first_client(a1, a2); break;
-    case GetCardServicesInfo:
-	return pcmcia_get_card_services_info(a1); break;
-    case GetConfigurationInfo:
-	return pcmcia_get_configuration_info(a1, a2); break;
-    case GetNextClient:
-	return pcmcia_get_next_client(a1, a2); break;
-    case GetFirstRegion:
-	return pcmcia_get_first_region(a1, a2); break;
-    case GetFirstTuple:
-	return pcmcia_get_first_tuple(a1, a2); break;
-    case GetNextRegion:
-	return pcmcia_get_next_region(a1, a2); break;
-    case GetNextTuple:
-	return pcmcia_get_next_tuple(a1, a2); break;
-    case GetStatus:
-	return pcmcia_get_status(a1, a2); break;
-    case GetTupleData:
-	return pcmcia_get_tuple_data(a1, a2); break;
-    case MapMemPage:
-	return pcmcia_map_mem_page(a1, a2); break;
-    case ModifyConfiguration:
-	return pcmcia_modify_configuration(a1, a2); break;
-    case ModifyWindow:
-	return pcmcia_modify_window(a1, a2); break;
-    case OpenMemory:
-/*	return pcmcia_open_memory(a1, a2); */
-    {
-	memory_handle_t m;
-        int ret = pcmcia_open_memory(a1, a2, &m);
-        *(memory_handle_t *)a1 = m;
-	return  ret;
-    }
-        break;
-    case ParseTuple:
-	return pcmcia_parse_tuple(a1, a2, a3); break;
-    case ReadMemory:
-	return pcmcia_read_memory(a1, a2, a3); break;
-    case RegisterClient:
-	return pcmcia_register_client(a1, a2); break;
-    case RegisterEraseQueue:
-    {
-	eraseq_handle_t w;
-        int ret = pcmcia_register_erase_queue(a1, a2, &w);
-        *(eraseq_handle_t *)a1 = w;
-	return  ret;
-    }
-        break;
-/*	return pcmcia_register_erase_queue(a1, a2); break; */
-
-	return pcmcia_register_mtd(a1, a2); break;
-    case ReleaseConfiguration:
-	return pcmcia_release_configuration(a1); break;
-    case ReleaseIO:
-	return pcmcia_release_io(a1, a2); break;
-    case ReleaseIRQ:
-	return pcmcia_release_irq(a1, a2); break;
-    case ReleaseWindow:
-	return pcmcia_release_window(a1); break;
-    case RequestConfiguration:
-	return pcmcia_request_configuration(a1, a2); break;
-    case RequestIO:
-	return pcmcia_request_io(a1, a2); break;
-    case RequestIRQ:
-	return pcmcia_request_irq(a1, a2); break;
-    case RequestWindow:
-    {
-	window_handle_t w;
-        int ret = pcmcia_request_window(a1, a2, &w);
-        *(window_handle_t *)a1 = w;
-	return  ret;
-    }
-        break;
-    case ResetCard:
-	return pcmcia_reset_card(a1, a2); break;
-    case SetEventMask:
-	return pcmcia_set_event_mask(a1, a2); break;
-    case ValidateCIS:
-	return pcmcia_validate_cis(a1, a2); break;
-    case WriteMemory:
-	return pcmcia_write_memory(a1, a2, a3); break;
-    case BindDevice:
-	return pcmcia_bind_device(a1); break;
-    case BindMTD:
-	return pcmcia_bind_mtd(a1); break;
-    case ReportError:
-	return pcmcia_report_error(a1, a2); break;
-    case SuspendCard:
-	return pcmcia_suspend_card(a1, a2); break;
-    case ResumeCard:
-	return pcmcia_resume_card(a1, a2); break;
-    case EjectCard:
-	return pcmcia_eject_card(a1, a2); break;
-    case InsertCard:
-	return pcmcia_insert_card(a1, a2); break;
-    case ReplaceCIS:
-	return pcmcia_replace_cis(a1, a2); break;
-    case GetFirstWindow:
-	return pcmcia_get_first_window(a1, a2); break;
-    case GetNextWindow:
-	return pcmcia_get_next_window(a1, a2); break;
-    case GetMemPage:
-	return pcmcia_get_mem_page(a1, a2); break;
-    default:
-	return CS_UNSUPPORTED_FUNCTION; break;
-    }
-    
-} /* CardServices */
-
 /*======================================================================
 
     OS-specific module glue goes here
@@ -2489,7 +2346,6 @@ EXPORT_SYMBOL(pcmcia_validate_cis);
 EXPORT_SYMBOL(pcmcia_write_memory);
 
 EXPORT_SYMBOL(dead_socket);
-EXPORT_SYMBOL(CardServices);
 EXPORT_SYMBOL(MTDHelperEntry);
 EXPORT_SYMBOL(pcmcia_parse_events);
 
diff -puN drivers/s390/block/dasd_3990_erp.c~linus drivers/s390/block/dasd_3990_erp.c
--- 25/drivers/s390/block/dasd_3990_erp.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/block/dasd_3990_erp.c	2004-01-19 22:17:22.000000000 -0800
@@ -5,7 +5,7 @@
  * Bugreports.to..: <Linux390@de.ibm.com>
  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000, 2001
  *
- * $Revision: 1.25 $
+ * $Revision: 1.26 $
  */
 
 #include <linux/timer.h>
@@ -312,7 +312,8 @@ dasd_3990_erp_alternate_path(struct dasd
 			    erp->lpm, erp->dstat->esw.esw0.sublog.lpum, opm);
 
 		/* reset status to queued to handle the request again... */
-		erp->status = DASD_CQR_QUEUED;
+		if (erp->status > DASD_CQR_QUEUED)
+			erp->status = DASD_CQR_QUEUED;
 		erp->retries = 1;
 	} else {
 		DEV_MESSAGE(KERN_ERR, device,
@@ -321,7 +322,8 @@ dasd_3990_erp_alternate_path(struct dasd
 			    erp->dstat->esw.esw0.sublog.lpum, opm);
 
 		/* post request with permanent error */
-		erp->status = DASD_CQR_FAILED;
+		if (erp->status > DASD_CQR_QUEUED)
+			erp->status = DASD_CQR_FAILED;
 	}
 }				/* end dasd_3990_erp_alternate_path */
 
diff -puN drivers/s390/block/dasd.c~linus drivers/s390/block/dasd.c
--- 25/drivers/s390/block/dasd.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/block/dasd.c	2004-01-19 22:17:22.000000000 -0800
@@ -7,7 +7,7 @@
  * Bugreports.to..: <Linux390@de.ibm.com>
  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
  *
- * $Revision: 1.114 $
+ * $Revision: 1.123 $
  */
 
 #include <linux/config.h>
@@ -43,7 +43,6 @@ MODULE_DESCRIPTION("Linux on S/390 DASD 
 		   " Copyright 2000 IBM Corporation");
 MODULE_SUPPORTED_DEVICE("dasd");
 MODULE_PARM(dasd, "1-" __MODULE_STRING(256) "s");
-MODULE_PARM(dasd_disciplines, "1-" __MODULE_STRING(8) "s");
 MODULE_LICENSE("GPL");
 
 /*
@@ -57,7 +56,6 @@ static void dasd_int_handler(struct ccw_
 static void dasd_flush_ccw_queue(struct dasd_device *, int);
 static void dasd_tasklet(struct dasd_device *);
 static void do_kick_device(void *data);
-static int  dasd_add_sysfs_files(struct ccw_device *cdev);
 
 /*
  * SECTION: Operations on the device structure.
@@ -93,6 +91,7 @@ dasd_alloc_device(void)
 
 	dasd_init_chunklist(&device->ccw_chunks, device->ccw_mem, PAGE_SIZE*2);
 	dasd_init_chunklist(&device->erp_chunks, device->erp_mem, PAGE_SIZE);
+	spin_lock_init(&device->mem_lock);
 	spin_lock_init(&device->request_queue_lock);
 	atomic_set (&device->tasklet_scheduled, 0);
 	tasklet_init(&device->tasklet, 
@@ -860,7 +859,7 @@ dasd_handle_killed_request(struct ccw_de
 
 	device = (struct dasd_device *) cqr->device;
 	if (device == NULL ||
-	    device != cdev->dev.driver_data ||
+	    device != dasd_device_from_cdev(cdev) ||
 	    strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) {
 		MESSAGE(KERN_DEBUG, "invalid device in request: bus_id %s",
 			cdev->dev.bus_id);
@@ -872,6 +871,7 @@ dasd_handle_killed_request(struct ccw_de
 
 	dasd_clear_timer(device);
 	dasd_schedule_bh(device);
+	dasd_put_device(device);
 }
 
 static void
@@ -931,7 +931,11 @@ dasd_int_handler(struct ccw_device *cdev
 	/* first of all check for state change pending interrupt */
 	mask = DEV_STAT_ATTENTION | DEV_STAT_DEV_END | DEV_STAT_UNIT_EXCEP;
 	if ((irb->scsw.dstat & mask) == mask) {
-		dasd_handle_state_change_pending(cdev->dev.driver_data);
+		device = dasd_device_from_cdev(cdev);
+		if (!IS_ERR(device)) {
+			dasd_handle_state_change_pending(device);
+			dasd_put_device(device);
+		}
 		return;
 	}
 
@@ -949,7 +953,6 @@ dasd_int_handler(struct ccw_device *cdev
 
 	device = (struct dasd_device *) cqr->device;
 	if (device == NULL ||
-	    device != cdev->dev.driver_data ||
 	    strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) {
 		MESSAGE(KERN_DEBUG, "invalid device in request: bus_id %s",
 			cdev->dev.bus_id);
@@ -959,17 +962,19 @@ dasd_int_handler(struct ccw_device *cdev
 	DBF_DEV_EVENT(DBF_DEBUG, device, "Int: CS/DS 0x%04x",
 		      ((irb->scsw.cstat << 8) | irb->scsw.dstat));
 
-	/* Find out the appropriate era_action. */
-	era = dasd_era_none;
-	if (irb->scsw.dstat & ~(DEV_STAT_CHN_END | DEV_STAT_DEV_END) ||
-	    irb->esw.esw0.erw.cons) {
-		/* The request did end abnormally. */
-		if (irb->scsw.fctl & SCSW_FCTL_HALT_FUNC)
-			era = dasd_era_fatal;
-		else
-			era = device->discipline->examine_error(cqr, irb);
-		DBF_EVENT(DBF_NOTICE, "era_code %d", era);
-	}
+ 	/* Find out the appropriate era_action. */
+	if (irb->scsw.fctl & SCSW_FCTL_HALT_FUNC) 
+		era = dasd_era_fatal;
+	else if (irb->scsw.dstat == (DEV_STAT_CHN_END | DEV_STAT_DEV_END) &&
+		 irb->scsw.cstat == 0 &&
+		 !irb->esw.esw0.erw.cons)
+		era = dasd_era_none;
+	else if (irb->esw.esw0.erw.cons)
+		era = device->discipline->examine_error(cqr, irb);
+	else 
+		era = dasd_era_recover;
+
+	DBF_DEV_EVENT(DBF_DEBUG, device, "era_code %d", era);
 	expires = 0;
 	if (era == dasd_era_none) {
 		cqr->status = DASD_CQR_DONE;
@@ -1149,6 +1154,11 @@ __dasd_process_blk_queue(struct dasd_dev
 			dasd_end_request(req, 0);
 			continue;
 		}
+		if (device->stopped & DASD_STOPPED_DC_EIO) {
+			blkdev_dequeue_request(req);
+			dasd_end_request(req, 0);
+			continue;
+		}
 		cqr = device->discipline->build_cp(device, req);
 		if (IS_ERR(cqr)) {
 			if (PTR_ERR(cqr) == -ENOMEM)
@@ -1728,17 +1738,10 @@ int
 dasd_generic_probe (struct ccw_device *cdev,
 		    struct dasd_discipline *discipline)
 {
-	int ret = 0;
-
-	if (dasd_autodetect &&
-	    (ret = dasd_add_busid(cdev->dev.bus_id, DASD_FEATURE_DEFAULT))) {
-		printk (KERN_WARNING
-			"dasd_generic_probe: cannot autodetect %s\n",
-			cdev->dev.bus_id);
-		return ret;
-	}
+	int ret;
 
-	if (!ret && (ret = dasd_add_sysfs_files(cdev))) {
+	ret = dasd_add_sysfs_files(cdev);
+	if (ret) {
 		printk(KERN_WARNING
 		       "dasd_generic_probe: could not add driverfs entries"
 		       "for %s\n", cdev->dev.bus_id);
@@ -1751,16 +1754,17 @@ dasd_generic_probe (struct ccw_device *c
 
 /* this will one day be called from a global not_oper handler.
  * It is also used by driver_unregister during module unload */
-int
+void
 dasd_generic_remove (struct ccw_device *cdev)
 {
 	struct dasd_device *device;
 
-	device = cdev->dev.driver_data;
-	cdev->dev.driver_data = NULL;
-	if (device)
-		kfree(device);
-	return 0;
+	device = dasd_device_from_cdev(cdev);
+	if (!IS_ERR(device)) {
+		dasd_set_target_state(device, DASD_STATE_NEW);
+		/* dasd_delete_device destroys the device reference. */
+		dasd_delete_device(device);
+	}
 }
 
 /* activate a device. This is called from dasd_{eckd,fba}_probe() when either
@@ -1779,24 +1783,14 @@ dasd_generic_set_online (struct ccw_devi
 		return PTR_ERR(device);
 
 	if (device->use_diag_flag)
-		device->discipline = dasd_diag_discipline_pointer;
-
-	rc = 0;
-	if (!device->discipline ||
-	    (rc = device->discipline->check_device(device))) {
-		pr_debug("device %s is not diag (%d)\n", 
-			 cdev->dev.bus_id, rc);
-		if (device->private != NULL) {
-			kfree(device->private);
-			device->private = NULL;
-		}
-		device->discipline = discipline;
-		rc = discipline->check_device(device);
-	}
-
+		discipline = dasd_diag_discipline_pointer;
+	device->discipline = discipline;
+	rc = discipline->check_device(device);
 	if (rc) {
-		printk (KERN_WARNING "dasd_generic found a bad device %s\n", 
-			cdev->dev.bus_id);
+		printk (KERN_WARNING
+			"dasd_generic couldn't online device %s "
+			"with discipline %s\n", 
+			cdev->dev.bus_id, discipline->name);
 		dasd_delete_device(device);
 		return rc;
 	}
@@ -1809,16 +1803,16 @@ dasd_generic_set_online (struct ccw_devi
 		rc = -ENODEV;
 		dasd_set_target_state(device, DASD_STATE_NEW);
 		dasd_delete_device(device);
-	} else {
+	} else
 		pr_debug("dasd_generic device %s found\n",
 				cdev->dev.bus_id);
-		cdev->dev.driver_data = device;
-	}
 
 	/* FIXME: we have to wait for the root device but we don't want
 	 * to wait for each single device but for all at once. */
 	wait_event(dasd_init_waitq, _wait_for_device(device));
 
+	dasd_put_device(device);
+
 	return rc;
 }
 
@@ -1827,18 +1821,68 @@ dasd_generic_set_offline (struct ccw_dev
 {
 	struct dasd_device *device;
 
-	device = cdev->dev.driver_data;
-	dasd_set_target_state(device, DASD_STATE_NEW);
-	dasd_delete_device(device);
-	
+	device = dasd_device_from_cdev(cdev);
+	if (atomic_read(&device->open_count) > 0) {
+		printk (KERN_WARNING "Can't offline dasd device with open"
+			" count = %i.\n",
+			atomic_read(&device->open_count));
+		dasd_put_device(device);
+		return -EBUSY;
+	}
+	dasd_put_device(device);
+	dasd_generic_remove (cdev);
 	return 0;
 }
 
+int
+dasd_generic_notify(struct ccw_device *cdev, int event)
+{
+	struct dasd_device *device;
+	struct dasd_ccw_req *cqr;
+	unsigned long flags;
+	int ret;
+
+	device = dasd_device_from_cdev(cdev);
+	if (IS_ERR(device))
+		return 0;
+	spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
+	ret = 0;
+	switch (event) {
+	case CIO_GONE:
+	case CIO_NO_PATH:
+		if (device->state < DASD_STATE_BASIC)
+			break;
+		/* Device is active. We want to keep it. */
+		if (device->disconnect_error_flag) {
+			list_for_each_entry(cqr, &device->ccw_queue, list)
+				if (cqr->status == DASD_CQR_IN_IO)
+					cqr->status = DASD_CQR_FAILED;
+			device->stopped |= DASD_STOPPED_DC_EIO;
+			dasd_schedule_bh(device);
+		} else {
+			list_for_each_entry(cqr, &device->ccw_queue, list)
+				if (cqr->status == DASD_CQR_IN_IO)
+					cqr->status = DASD_CQR_QUEUED;
+			device->stopped |= DASD_STOPPED_DC_WAIT;
+			dasd_set_timer(device, 0);
+		}
+		ret = 1;
+		break;
+	case CIO_OPER:
+		/* FIXME: add a sanity check. */
+		device->stopped &= ~(DASD_STOPPED_DC_WAIT|DASD_STOPPED_DC_EIO);
+		dasd_schedule_bh(device);
+		ret = 1;
+		break;
+	}
+	spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
+	dasd_put_device(device);
+	return ret;
+}
+
 /*
  * Automatically online either all dasd devices (dasd_autodetect) or
- * all devices specified with dasd= parameters. For dasd_autodetect
- * dasd_generic_probe has added devmaps for all dasd devices. We
- * scan all present dasd devmaps and call ccw_device_set_online.
+ * all devices specified with dasd= parameters.
  */
 void
 dasd_generic_auto_online (struct ccw_driver *dasd_discipline_driver)
@@ -1863,97 +1907,6 @@ dasd_generic_auto_online (struct ccw_dri
 	put_driver(drv);
 }
 
-/*
- * SECTION: files in sysfs
- */
-
-/*
- * readonly controls the readonly status of a dasd
- */
-static ssize_t
-dasd_ro_show(struct device *dev, char *buf)
-{
-	struct dasd_device *device;
-
-	device = dev->driver_data;
-	if (!device)
-		return snprintf(buf, PAGE_SIZE, "n/a\n");
-
-	return snprintf(buf, PAGE_SIZE, device->ro_flag ? "1\n" : "0\n");
-}
-
-static ssize_t
-dasd_ro_store(struct device *dev, const char *buf, size_t count)
-{
-	struct dasd_device *device = dev->driver_data;
-
-	if (device)
-		device->ro_flag = (buf[0] == '1') ? 1 : 0;
-	return count;
-}
-
-static DEVICE_ATTR(readonly, 0644, dasd_ro_show, dasd_ro_store);
-
-/*
- * use_diag controls whether the driver should use diag rather than ssch
- * to talk to the device
- */
-/* TODO: Implement */
-static ssize_t 
-dasd_use_diag_show(struct device *dev, char *buf)
-{
-	struct dasd_device *device;
-
-	device = dev->driver_data;
-	if (!device)
-		return sprintf(buf, "n/a\n");
-
-	return sprintf(buf, device->use_diag_flag ? "1\n" : "0\n");
-}
-
-static ssize_t
-dasd_use_diag_store(struct device *dev, const char *buf, size_t count)
-{
-	struct dasd_device *device = dev->driver_data;
-
-	if (device)
-		device->use_diag_flag = (buf[0] == '1') ? 1 : 0;
-	return count;
-}
-
-static
-DEVICE_ATTR(use_diag, 0644, dasd_use_diag_show, dasd_use_diag_store);
-
-static ssize_t
-dasd_discipline_show(struct device *dev, char *buf)
-{
-	struct dasd_device *device;
-
-	device = dev->driver_data;
-	if (!device || !device->discipline)
-		return sprintf(buf, "none\n");
-	return snprintf(buf, PAGE_SIZE, "%s\n", device->discipline->name);
-}
-
-static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, NULL);
-
-static struct attribute * dasd_attrs[] = {
-	&dev_attr_readonly.attr,
-	&dev_attr_discipline.attr,
-	&dev_attr_use_diag.attr,
-	NULL,
-};
-
-static struct attribute_group dasd_attr_group = {
-	.attrs = dasd_attrs,
-};
-
-static int
-dasd_add_sysfs_files(struct ccw_device *cdev)
-{
-	return sysfs_create_group(&cdev->dev.kobj, &dasd_attr_group);
-}
-
 static int __init
 dasd_init(void)
 {
diff -puN drivers/s390/block/dasd_devmap.c~linus drivers/s390/block/dasd_devmap.c
--- 25/drivers/s390/block/dasd_devmap.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/block/dasd_devmap.c	2004-01-19 22:17:22.000000000 -0800
@@ -11,7 +11,7 @@
  * functions may not be called from interrupt context. In particular
  * dasd_get_device is a no-no from interrupt context.
  *
- * $Revision: 1.19 $
+ * $Revision: 1.25 $
  */
 
 #include <linux/config.h>
@@ -79,6 +79,8 @@ static spinlock_t dasd_devmap_lock = SPI
 static struct list_head dasd_hashlists[256];
 int dasd_max_devindex;
 
+static struct dasd_devmap *dasd_add_busid(char *, int);
+
 static inline int
 dasd_hash_busid(char *bus_id)
 {
@@ -168,12 +170,16 @@ dasd_feature_list(char *str, char **endp
 		*endp = str;
 		return DASD_FEATURE_DEFAULT;
 	}
+	str++;
 	features = 0;
+
 	while (1) {
 		for (len = 0; 
 		     str[len] && str[len] != ':' && str[len] != ')'; len++);
 		if (len == 2 && !strncmp(str, "ro", 2))
 			features |= DASD_FEATURE_READONLY;
+		else if (len == 4 && !strncmp(str, "diag", 4))
+			features |= DASD_FEATURE_USEDIAG;
 		else {
 			MESSAGE(KERN_WARNING,
 				"unsupported feature: %*s, "
@@ -203,6 +209,7 @@ dasd_feature_list(char *str, char **endp
 static inline int
 dasd_ranges_list(char *str)
 {
+	struct dasd_devmap *devmap;
 	int from, from_id0, from_id1;
 	int to, to_id0, to_id1;
 	int features, rc;
@@ -233,9 +240,9 @@ dasd_ranges_list(char *str)
 		while (from <= to) {
 			sprintf(bus_id, "%01x.%01x.%04x",
 				from_id0, from_id1, from++);
-			rc = dasd_add_busid(bus_id, features);
-			if (rc)
-				return rc;
+			devmap = dasd_add_busid(bus_id, features);
+			if (IS_ERR(devmap))
+				return PTR_ERR(devmap);
 		}
 		if (*str != ',')
 			break;
@@ -299,7 +306,7 @@ dasd_parse(void)
  * added through this function will define the kdevs for the individual
  * devices. 
  */
-int
+static struct dasd_devmap *
 dasd_add_busid(char *bus_id, int features)
 {
 	struct dasd_devmap *devmap, *new, *tmp;
@@ -308,7 +315,7 @@ dasd_add_busid(char *bus_id, int feature
 	new = (struct dasd_devmap *)
 		kmalloc(sizeof(struct dasd_devmap), GFP_KERNEL);
 	if (!new)
-		return -ENOMEM;
+		return ERR_PTR(-ENOMEM);
 	spin_lock(&dasd_devmap_lock);
 	devmap = 0;
 	hash = dasd_hash_busid(bus_id);
@@ -330,7 +337,7 @@ dasd_add_busid(char *bus_id, int feature
 	spin_unlock(&dasd_devmap_lock);
 	if (new)
 		kfree(new);
-	return 0;
+	return devmap;
 }
 
 /*
@@ -343,7 +350,7 @@ dasd_find_busid(char *bus_id)
 	int hash;
 
 	spin_lock(&dasd_devmap_lock);
-	devmap = 0;
+	devmap = ERR_PTR(-ENODEV);
 	hash = dasd_hash_busid(bus_id);
 	list_for_each_entry(tmp, &dasd_hashlists[hash], list) {
 		if (strncmp(tmp->bus_id, bus_id, BUS_ID_SIZE) == 0) {
@@ -361,7 +368,7 @@ dasd_find_busid(char *bus_id)
 int
 dasd_busid_known(char *bus_id)
 {
-	return dasd_find_busid(bus_id) ? 0 : -ENOENT;
+	return IS_ERR(dasd_find_busid(bus_id)) ? -ENOENT : 0;
 }
 
 /*
@@ -415,6 +422,28 @@ dasd_device_from_devindex(int devindex)
 }
 
 /*
+ * Return devmap for cdev. If no devmap exists yet, create one and
+ * connect it to the cdev.
+ */
+static struct dasd_devmap *
+dasd_devmap_from_cdev(struct ccw_device *cdev)
+{
+	struct dasd_devmap *devmap;
+
+	if (cdev->dev.driver_data)
+		return (struct dasd_devmap *) cdev->dev.driver_data;
+	devmap = dasd_find_busid(cdev->dev.bus_id);
+	if (!IS_ERR(devmap)) {
+		cdev->dev.driver_data = devmap;
+		return devmap;
+	}
+	devmap = dasd_add_busid(cdev->dev.bus_id, DASD_FEATURE_DEFAULT);
+	if (!IS_ERR(devmap))
+		cdev->dev.driver_data = devmap;
+	return devmap;
+}
+
+/*
  * Create a dasd device structure for cdev.
  */
 struct dasd_device *
@@ -424,41 +453,35 @@ dasd_create_device(struct ccw_device *cd
 	struct dasd_device *device;
 	int rc;
 
-	rc = dasd_add_busid(cdev->dev.bus_id, DASD_FEATURE_DEFAULT);
-	if (rc)
-		return ERR_PTR(rc);
-
-	devmap = dasd_find_busid(cdev->dev.bus_id);
+	devmap = dasd_devmap_from_cdev(cdev);
 	if (IS_ERR(devmap))
 		return (void *) devmap;
 
 	device = dasd_alloc_device();
 	if (IS_ERR(device))
 		return device;
-	atomic_set(&device->ref_count, 1);
-	device->devindex = devmap->devindex;
-	device->ro_flag = (devmap->features & DASD_FEATURE_READONLY) ? 1 : 0;
-	device->use_diag_flag = 1;
+	atomic_set(&device->ref_count, 2);
 
-	spin_lock_irq(get_ccwdev_lock(cdev));
-	if (cdev->dev.driver_data == NULL) {
+	spin_lock(&dasd_devmap_lock);
+	if (!devmap->device) {
+		devmap->device = device;
+		device->devindex = devmap->devindex;
+		device->ro_flag = 
+			(devmap->features & DASD_FEATURE_READONLY) != 0;
+		device->use_diag_flag = 
+			(devmap->features & DASD_FEATURE_USEDIAG) != 0;
 		get_device(&cdev->dev);
-		cdev->dev.driver_data = device;
 		device->cdev = cdev;
 		rc = 0;
 	} else
 		/* Someone else was faster. */
 		rc = -EBUSY;
-	spin_unlock_irq(get_ccwdev_lock(cdev));
+	spin_unlock(&dasd_devmap_lock);
+
 	if (rc) {
 		dasd_free_device(device);
 		return ERR_PTR(rc);
 	}
-	/* Device created successfully. Make it known via devmap. */
-	spin_lock(&dasd_devmap_lock);
-	devmap->device = device;
-	spin_unlock(&dasd_devmap_lock);
-
 	return device;
 }
 
@@ -468,7 +491,8 @@ dasd_create_device(struct ccw_device *cd
 static DECLARE_WAIT_QUEUE_HEAD(dasd_delete_wq);
 
 /*
- * Remove a dasd device structure.
+ * Remove a dasd device structure. The passed referenced
+ * is destroyed.
  */
 void
 dasd_delete_device(struct dasd_device *device)
@@ -479,17 +503,24 @@ dasd_delete_device(struct dasd_device *d
 	/* First remove device pointer from devmap. */
 	devmap = dasd_find_busid(device->cdev->dev.bus_id);
 	spin_lock(&dasd_devmap_lock);
+	if (devmap->device != device) {
+		spin_unlock(&dasd_devmap_lock);
+		dasd_put_device(device);
+		return;
+	}
 	devmap->device = NULL;
 	spin_unlock(&dasd_devmap_lock);
 
+	/* Drop ref_count by 2, one for the devmap reference and
+	 * one for the passed reference. */
+	atomic_sub(2, &device->ref_count);
+
 	/* Wait for reference counter to drop to zero. */
-	atomic_dec(&device->ref_count);
 	wait_event(dasd_delete_wq, atomic_read(&device->ref_count) == 0);
 
 	/* Disconnect dasd_device structure from ccw_device structure. */
 	cdev = device->cdev;
 	device->cdev = NULL;
-	cdev->dev.driver_data = NULL;
 
 	/* Put ccw_device structure. */
 	put_device(&cdev->dev);
@@ -508,6 +539,148 @@ dasd_put_device_wake(struct dasd_device 
 	wake_up(&dasd_delete_wq);
 }
 
+/*
+ * Return dasd_device structure associated with cdev.
+ */
+struct dasd_device *
+dasd_device_from_cdev(struct ccw_device *cdev)
+{
+	struct dasd_devmap *devmap;
+	struct dasd_device *device;
+
+	device = ERR_PTR(-ENODEV);
+	spin_lock(&dasd_devmap_lock);
+	devmap = cdev->dev.driver_data;
+	if (devmap && devmap->device) {
+		device = devmap->device;
+		dasd_get_device(device);
+	}
+	spin_unlock(&dasd_devmap_lock);
+	return device;
+}
+
+/*
+ * SECTION: files in sysfs
+ */
+
+/*
+ * readonly controls the readonly status of a dasd
+ */
+static ssize_t
+dasd_ro_show(struct device *dev, char *buf)
+{
+	struct dasd_devmap *devmap;
+	int ro_flag;
+
+	devmap = dev->driver_data;
+	if (devmap)
+		ro_flag = (devmap->features & DASD_FEATURE_READONLY) != 0;
+	else
+		ro_flag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_READONLY) != 0;
+	return snprintf(buf, PAGE_SIZE, ro_flag ? "1\n" : "0\n");
+}
+
+static ssize_t
+dasd_ro_store(struct device *dev, const char *buf, size_t count)
+{
+	struct dasd_devmap *devmap;
+	int ro_flag;
+
+	devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
+	ro_flag = buf[0] == '1';
+	spin_lock(&dasd_devmap_lock);
+	if (ro_flag)
+		devmap->features |= DASD_FEATURE_READONLY;
+	else
+		devmap->features &= ~DASD_FEATURE_READONLY;
+	if (devmap->device) {
+		if (devmap->device->gdp)
+			set_disk_ro(devmap->device->gdp, ro_flag);
+		devmap->device->ro_flag = ro_flag;
+	}
+	spin_unlock(&dasd_devmap_lock);
+	return count;
+}
+
+static DEVICE_ATTR(readonly, 0644, dasd_ro_show, dasd_ro_store);
+
+/*
+ * use_diag controls whether the driver should use diag rather than ssch
+ * to talk to the device
+ */
+/* TODO: Implement */
+static ssize_t 
+dasd_use_diag_show(struct device *dev, char *buf)
+{
+	struct dasd_devmap *devmap;
+	int use_diag;
+
+	devmap = dev->driver_data;
+	if (devmap)
+		use_diag = (devmap->features & DASD_FEATURE_USEDIAG) != 0;
+	else
+		use_diag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_USEDIAG) != 0;
+	return sprintf(buf, use_diag ? "1\n" : "0\n");
+}
+
+static ssize_t
+dasd_use_diag_store(struct device *dev, const char *buf, size_t count)
+{
+	struct dasd_devmap *devmap;
+	int use_diag;
+
+	devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
+	use_diag = buf[0] == '1';
+	spin_lock(&dasd_devmap_lock);
+	/* Changing diag discipline flag is only allowed in offline state. */
+	if (!devmap->device) {
+		if (use_diag)
+			devmap->features |= DASD_FEATURE_USEDIAG;
+		else
+			devmap->features &= ~DASD_FEATURE_USEDIAG;
+	} else
+		count = -EPERM;
+	spin_unlock(&dasd_devmap_lock);
+	return count;
+}
+
+static
+DEVICE_ATTR(use_diag, 0644, dasd_use_diag_show, dasd_use_diag_store);
+
+static ssize_t
+dasd_discipline_show(struct device *dev, char *buf)
+{
+	struct dasd_devmap *devmap;
+	char *dname;
+
+	spin_lock(&dasd_devmap_lock);
+	dname = "none";
+	devmap = dev->driver_data;
+	if (devmap && devmap->device && devmap->device->discipline)
+		dname = devmap->device->discipline->name;
+	spin_unlock(&dasd_devmap_lock);
+	return snprintf(buf, PAGE_SIZE, "%s\n", dname);
+}
+
+static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, NULL);
+
+static struct attribute * dasd_attrs[] = {
+	&dev_attr_readonly.attr,
+	&dev_attr_discipline.attr,
+	&dev_attr_use_diag.attr,
+	NULL,
+};
+
+static struct attribute_group dasd_attr_group = {
+	.attrs = dasd_attrs,
+};
+
+int
+dasd_add_sysfs_files(struct ccw_device *cdev)
+{
+	return sysfs_create_group(&cdev->dev.kobj, &dasd_attr_group);
+}
+
 int
 dasd_devmap_init(void)
 {
diff -puN drivers/s390/block/dasd_diag.c~linus drivers/s390/block/dasd_diag.c
--- 25/drivers/s390/block/dasd_diag.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/block/dasd_diag.c	2004-01-19 22:17:22.000000000 -0800
@@ -6,7 +6,7 @@
  * Bugreports.to..: <Linux390@de.ibm.com>
  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
  *
- * $Revision: 1.32 $
+ * $Revision: 1.33 $
  */
 
 #include <linux/config.h>
@@ -393,7 +393,7 @@ dasd_diag_build_cp(struct dasd_device * 
 	recid = first_rec;
 	rq_for_each_bio(bio, req) {
 		bio_for_each_segment(bv, bio, i) {
-			dst = kmap(bv->bv_page) + bv->bv_offset;
+			dst = page_address(bv->bv_page) + bv->bv_offset;
 			for (off = 0; off < bv->bv_len; off += blksize) {
 				memset(dbio, 0, sizeof (struct dasd_diag_bio));
 				dbio->type = rw_cmd;
diff -puN drivers/s390/block/dasd_eckd.c~linus drivers/s390/block/dasd_eckd.c
--- 25/drivers/s390/block/dasd_eckd.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/block/dasd_eckd.c	2004-01-19 22:17:22.000000000 -0800
@@ -7,7 +7,7 @@
  * Bugreports.to..: <Linux390@de.ibm.com>
  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
  *
- * $Revision: 1.47 $
+ * $Revision: 1.49 $
  */
 
 #include <linux/config.h>
@@ -103,6 +103,7 @@ static struct ccw_driver dasd_eckd_drive
 	.remove      = dasd_generic_remove,
 	.set_offline = dasd_generic_set_offline,
 	.set_online  = dasd_eckd_set_online,
+	.notify      = dasd_generic_notify,
 };
 
 static const int sizes_trk0[] = { 28, 148, 84 };
@@ -460,8 +461,8 @@ dasd_eckd_check_characteristics(struct d
 	/* Invalidate status of initial analysis. */
 	private->init_cqr_status = -1;
 	/* Set default cache operations. */
-	private->attrib.operation = DASD_SEQ_ACCESS;
-	private->attrib.nr_cyl = 0x02;
+	private->attrib.operation = DASD_NORMAL_CACHE;
+	private->attrib.nr_cyl = 0;
 
 	/* Read Device Characteristics */
 	rdc_data = (void *) &(private->rdc_data);
@@ -1292,6 +1293,36 @@ dasd_eckd_performance(struct block_devic
 }
 
 /*
+ * Get attributes (cache operations)
+ * Returnes the cache attributes used in Define Extend (DE).
+ */
+static int
+dasd_eckd_get_attrib (struct block_device *bdev, int no, long args)
+{
+	struct dasd_device *device;
+        struct dasd_eckd_private *private;
+        struct attrib_data_t attrib;
+	int rc;
+
+        if (!capable(CAP_SYS_ADMIN))
+                return -EACCES;
+        if (!args)
+                return -EINVAL;
+
+        device = bdev->bd_disk->private_data;
+        if (device == NULL)
+                return -ENODEV;
+
+        private = (struct dasd_eckd_private *) device->private;
+        attrib = private->attrib;
+	
+        rc = copy_to_user((long *) args, (long *) &attrib,
+			  sizeof (struct attrib_data_t));
+	
+	return rc;
+}
+
+/*
  * Set attributes (cache operations)
  * Stores the attributes for cache operation to be used in Define Extend (DE).
  */
@@ -1433,6 +1464,8 @@ dasd_eckd_init(void)
 {
 	int ret;
 
+	dasd_ioctl_no_register(THIS_MODULE, BIODASDGATTR,
+			       dasd_eckd_get_attrib);
 	dasd_ioctl_no_register(THIS_MODULE, BIODASDSATTR,
 			       dasd_eckd_set_attrib);
 	dasd_ioctl_no_register(THIS_MODULE, BIODASDPSRD,
@@ -1448,6 +1481,8 @@ dasd_eckd_init(void)
 
 	ret = ccw_driver_register(&dasd_eckd_driver);
 	if (ret) {
+		dasd_ioctl_no_unregister(THIS_MODULE, BIODASDGATTR,
+					 dasd_eckd_get_attrib);
 		dasd_ioctl_no_unregister(THIS_MODULE, BIODASDSATTR,
 					 dasd_eckd_set_attrib);
 		dasd_ioctl_no_unregister(THIS_MODULE, BIODASDPSRD,
@@ -1470,6 +1505,8 @@ dasd_eckd_cleanup(void)
 {
 	ccw_driver_unregister(&dasd_eckd_driver);
 
+	dasd_ioctl_no_unregister(THIS_MODULE, BIODASDGATTR,
+				 dasd_eckd_get_attrib);
 	dasd_ioctl_no_unregister(THIS_MODULE, BIODASDSATTR,
 				 dasd_eckd_set_attrib);
 	dasd_ioctl_no_unregister(THIS_MODULE, BIODASDPSRD,
diff -puN drivers/s390/block/dasd_fba.c~linus drivers/s390/block/dasd_fba.c
--- 25/drivers/s390/block/dasd_fba.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/block/dasd_fba.c	2004-01-19 22:17:22.000000000 -0800
@@ -4,7 +4,7 @@
  * Bugreports.to..: <Linux390@de.ibm.com>
  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
  *
- * $Revision: 1.30 $
+ * $Revision: 1.32 $
  */
 
 #include <linux/config.h>
@@ -80,6 +80,7 @@ static struct ccw_driver dasd_fba_driver
 	.remove      = dasd_generic_remove,
 	.set_offline = dasd_generic_set_offline,
 	.set_online  = dasd_fba_set_online,
+	.notify      = dasd_generic_notify,
 };
 
 static inline void
@@ -269,7 +270,7 @@ dasd_fba_build_cp(struct dasd_device * d
 				return ERR_PTR(-EINVAL);
 			count += bv->bv_len >> (device->s2b_shift + 9);
 #if defined(CONFIG_ARCH_S390X)
-			cidaw += idal_nr_words(kmap(bv->bv_page) +
+			cidaw += idal_nr_words(page_address(bv->bv_page) +
 					       bv->bv_offset, bv->bv_len);
 #endif
 		}
@@ -309,7 +310,7 @@ dasd_fba_build_cp(struct dasd_device * d
 	}
 	recid = first_rec;
 	rq_for_each_bio(bio, req) bio_for_each_segment(bv, bio, i) {
-		dst = kmap(bv->bv_page) + bv->bv_offset;
+		dst = page_address(bv->bv_page) + bv->bv_offset;
 		for (off = 0; off < bv->bv_len; off += blksize) {
 			/* Locate record for stupid devices. */
 			if (private->rdc_data.mode.bits.data_chain == 0) {
diff -puN drivers/s390/block/dasd_genhd.c~linus drivers/s390/block/dasd_genhd.c
--- 25/drivers/s390/block/dasd_genhd.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/block/dasd_genhd.c	2004-01-19 22:17:22.000000000 -0800
@@ -9,7 +9,7 @@
  *
  * gendisk related functions for the dasd driver.
  *
- * $Revision: 1.41 $
+ * $Revision: 1.42 $
  */
 
 #include <linux/config.h>
@@ -31,7 +31,6 @@ int
 dasd_gendisk_alloc(struct dasd_device *device)
 {
 	struct gendisk *gdp;
-	int len;
 
 	/* Make sure the minor for this device exists. */
 	if (device->devindex >= DASD_PER_MAJOR)
@@ -47,22 +46,8 @@ dasd_gendisk_alloc(struct dasd_device *d
 	gdp->fops = &dasd_device_operations;
 	gdp->driverfs_dev = &device->cdev->dev;
 
-	/*
-	 * Set device name.
-	 *   dasda - dasdz : 26 devices
-	 *   dasdaa - dasdzz : 676 devices, added up = 702
-	 *   dasdaaa - dasdzzz : 17576 devices, added up = 18278
-	 */
-	len = sprintf(gdp->disk_name, "dasd");
-	if (device->devindex > 25) {
-		if (device->devindex > 701)
-			len += sprintf(gdp->disk_name + len, "%c",
-				       'a'+(((device->devindex-702)/676)%26));
-		len += sprintf(gdp->disk_name + len, "%c",
-			       'a'+(((device->devindex-26)/26)%26));
-	}
-	len += sprintf(gdp->disk_name + len, "%c", 'a'+(device->devindex%26));
-
+	/* Set device name */
+ 	sprintf(gdp->disk_name, "dasd_%s_", device->cdev->dev.bus_id);
  	sprintf(gdp->devfs_name, "dasd/%s", device->cdev->dev.bus_id);
 
 	if (device->ro_flag)
diff -puN drivers/s390/block/dasd_int.h~linus drivers/s390/block/dasd_int.h
--- 25/drivers/s390/block/dasd_int.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/block/dasd_int.h	2004-01-19 22:17:22.000000000 -0800
@@ -6,7 +6,7 @@
  * Bugreports.to..: <Linux390@de.ibm.com>
  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
  *
- * $Revision: 1.48 $
+ * $Revision: 1.52 $
  */
 
 #ifndef DASD_INT_H
@@ -268,6 +268,7 @@ struct dasd_device {
 	unsigned int s2b_shift;		/* log2 (bp_block/512) */
 	int ro_flag;			/* read-only flag */
 	int use_diag_flag;		/* diag allowed flag */
+	int disconnect_error_flag;	/* return -EIO when disconnected */
 
 
 	/* Device discipline stuff. */
@@ -308,6 +309,8 @@ struct dasd_device {
 #define DASD_STOPPED_NOT_ACC 1         /* not accessible */
 #define DASD_STOPPED_QUIESCE 2         /* Quiesced */
 #define DASD_STOPPED_PENDING 4         /* long busy */
+#define DASD_STOPPED_DC_WAIT 8         /* disconnected, wait */
+#define DASD_STOPPED_DC_EIO  16        /* disconnected, return -EIO */
 
 
 void dasd_put_device_wake(struct dasd_device *);
@@ -458,9 +461,10 @@ void dasd_set_timer(struct dasd_device *
 void dasd_clear_timer(struct dasd_device *);
 int  dasd_cancel_req(struct dasd_ccw_req *);
 int dasd_generic_probe (struct ccw_device *, struct dasd_discipline *);
-int dasd_generic_remove (struct ccw_device *cdev);
+void dasd_generic_remove (struct ccw_device *cdev);
 int dasd_generic_set_online(struct ccw_device *, struct dasd_discipline *);
 int dasd_generic_set_offline (struct ccw_device *cdev);
+int dasd_generic_notify(struct ccw_device *, int);
 void dasd_generic_auto_online (struct ccw_driver *);
 
 /* externals in dasd_devmap.c */
@@ -474,10 +478,11 @@ void dasd_devmap_exit(void);
 struct dasd_device *dasd_create_device(struct ccw_device *);
 void dasd_delete_device(struct dasd_device *);
 
+int dasd_add_sysfs_files(struct ccw_device *);
+struct dasd_device *dasd_device_from_cdev(struct ccw_device *);
 struct dasd_device *dasd_device_from_devindex(int);
 
 int dasd_parse(void);
-int dasd_add_busid(char *, int);
 int dasd_busid_known(char *);
 
 /* externals in dasd_gendisk.c */
diff -puN drivers/s390/block/dasd_proc.c~linus drivers/s390/block/dasd_proc.c
--- 25/drivers/s390/block/dasd_proc.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/block/dasd_proc.c	2004-01-19 22:17:22.000000000 -0800
@@ -9,7 +9,7 @@
  *
  * /proc interface for the dasd driver.
  *
- * $Revision: 1.23 $
+ * $Revision: 1.24 $
  */
 
 #include <linux/config.h>
@@ -67,15 +67,10 @@ dasd_devices_show(struct seq_file *m, vo
 		seq_printf(m, "(none)");
 	/* Print kdev. */
 	if (device->gdp)
-		seq_printf(m, " at (%3d:%3d)",
+		seq_printf(m, " at (%3d:%7d)",
 			   device->gdp->major, device->gdp->first_minor);
 	else
-		seq_printf(m, "  at (???:???)");
-	/* Print device name. */
-	if (device->gdp)
-		seq_printf(m, " is %-7s", device->gdp->disk_name);
-	else
-		seq_printf(m, " is ???????");
+		seq_printf(m, "  at (???:???????)");
 	/* Print devices features. */
 	substr = device->ro_flag ? "(ro)" : " ";
 	seq_printf(m, "%4s: ", substr);
diff -puN drivers/s390/char/con3215.c~linus drivers/s390/char/con3215.c
--- 25/drivers/s390/char/con3215.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/char/con3215.c	2004-01-19 22:17:22.000000000 -0800
@@ -96,6 +96,7 @@ struct raw3215_info {
 	int msg_dstat;		      /* dstat for pending message */
 	int msg_cstat;		      /* cstat for pending message */
 	int line_pos;		      /* position on the line (for tabs) */
+	char ubuffer[80];	      /* copy_from_user buffer */
 };
 
 /* array of 3215 devices structures */
@@ -532,15 +533,12 @@ raw3215_make_room(struct raw3215_info *r
 /*
  * String write routine for 3215 devices
  */
-static int
-raw3215_write(struct raw3215_info *raw, const char *str,
-	      int from_user, unsigned int length)
+static void
+raw3215_write(struct raw3215_info *raw, const char *str, unsigned int length)
 {
 	unsigned long flags;
-	int ret, c;
-	int count;
+	int c, count;
 
-	ret = 0;
 	while (length > 0) {
 		spin_lock_irqsave(raw->lock, flags);
 		count = (length > RAW3215_BUFFER_SIZE) ?
@@ -550,46 +548,19 @@ raw3215_write(struct raw3215_info *raw, 
 		raw3215_make_room(raw, count);
 
 		/* copy string to output buffer and convert it to EBCDIC */
-		if (from_user) {
-			while (1) {
-				c = min_t(int, count,
-					min(RAW3215_BUFFER_SIZE - raw->count,
-					    RAW3215_BUFFER_SIZE - raw->head));
-				if (c <= 0)
-					break;
-				c -= copy_from_user(raw->buffer + raw->head,
-						    str, c);
-				if (c == 0) {
-					if (!ret)
-						ret = -EFAULT;
-					break;
-				}
-				ASCEBC(raw->buffer + raw->head, c);
-				raw->head = (raw->head + c) &
-					    (RAW3215_BUFFER_SIZE - 1);
-				raw->count += c;
-				raw->line_pos += c;
-				str += c;
-				count -= c;
-				ret += c;
-			}
-		} else {
-			while (1) {
-				c = min_t(int, count,
-					min(RAW3215_BUFFER_SIZE - raw->count,
-					    RAW3215_BUFFER_SIZE - raw->head));
-				if (c <= 0)
-					break;
-				memcpy(raw->buffer + raw->head, str, c);
-				ASCEBC(raw->buffer + raw->head, c);
-				raw->head = (raw->head + c) &
-					    (RAW3215_BUFFER_SIZE - 1);
-				raw->count += c;
-				raw->line_pos += c;
-				str += c;
-				count -= c;
-				ret += c;
-			}
+		while (1) {
+			c = min_t(int, count,
+				  min(RAW3215_BUFFER_SIZE - raw->count,
+				      RAW3215_BUFFER_SIZE - raw->head));
+			if (c <= 0)
+				break;
+			memcpy(raw->buffer + raw->head, str, c);
+			ASCEBC(raw->buffer + raw->head, c);
+			raw->head = (raw->head + c) & (RAW3215_BUFFER_SIZE - 1);
+			raw->count += c;
+			raw->line_pos += c;
+			str += c;
+			count -= c;
 		}
 		if (!(raw->flags & RAW3215_WORKING)) {
 			raw3215_mk_write_req(raw);
@@ -598,8 +569,6 @@ raw3215_write(struct raw3215_info *raw, 
 		}
 		spin_unlock_irqrestore(raw->lock, flags);
 	}
-
-	return ret;
 }
 
 /*
@@ -752,11 +721,12 @@ raw3215_probe (struct ccw_device *cdev)
 	return 0;
 }
 
-static int
+static void
 raw3215_remove (struct ccw_device *cdev)
 {
 	struct raw3215_info *raw;
 
+	ccw_device_set_offline(cdev);
 	raw = cdev->dev.driver_data;
 	if (raw) {
 		cdev->dev.driver_data = NULL;
@@ -764,7 +734,6 @@ raw3215_remove (struct ccw_device *cdev)
 			kfree(raw->buffer);
 		kfree(raw);
 	}
-	return 0;
 }
 
 static int
@@ -825,7 +794,7 @@ con3215_write(struct console *co, const 
 		for (i = 0; i < count; i++)
 			if (str[i] == '\t' || str[i] == '\n')
 				break;
-		raw3215_write(raw, str, 0, i);
+		raw3215_write(raw, str, i);
 		count -= i;
 		str += i;
 		if (count > 0) {
@@ -1021,12 +990,29 @@ tty3215_write(struct tty_struct * tty, i
 	      const unsigned char *buf, int count)
 {
 	struct raw3215_info *raw;
-	int ret = 0;
+	int length, ret;
 
 	if (!tty)
 		return 0;
 	raw = (struct raw3215_info *) tty->driver_data;
-	ret = raw3215_write(raw, buf, from_user, count);
+	if (!from_user) {
+		raw3215_write(raw, buf, count);
+		return count;
+	}
+	ret = 0;
+	while (count > 0) {
+		length = count < 80 ? count : 80;
+		length -= copy_from_user(raw->ubuffer, buf, length);
+		if (length == 0) {
+			if (!ret)
+				ret = -EFAULT;
+			break;
+		}
+		raw3215_write(raw, raw->ubuffer, count);
+		buf += length;
+		count -= length;
+		ret += length;
+	}
 	return ret;
 }
 
diff -puN /dev/null drivers/s390/char/con3270.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/s390/char/con3270.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,639 @@
+/*
+ *  drivers/s390/char/con3270.c
+ *    IBM/3270 Driver - console view.
+ *
+ *  Author(s):
+ *    Original 3270 Code for 2.4 written by Richard Hitt (UTS Global)
+ *    Rewritten for 2.5 by Martin Schwidefsky <schwidefsky@de.ibm.com>
+ *	-- Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ */
+
+#include <linux/config.h>
+#include <linux/bootmem.h>
+#include <linux/console.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/list.h>
+#include <linux/types.h>
+
+#include <asm/ccwdev.h>
+#include <asm/cio.h>
+#include <asm/cpcmd.h>
+#include <asm/ebcdic.h>
+
+#include "raw3270.h"
+#include "ctrlchar.h"
+
+#define CON3270_OUTPUT_BUFFER_SIZE 1024
+#define CON3270_STRING_PAGES 4
+
+static struct raw3270_fn con3270_fn;
+
+/*
+ * Main 3270 console view data structure.
+ */
+struct con3270 {
+	struct raw3270_view view;
+	spinlock_t lock;
+	struct list_head freemem;	/* list of free memory for strings. */
+
+	/* Output stuff. */
+	struct list_head lines;		/* list of lines. */
+	struct list_head update;	/* list of lines to update. */
+	int line_nr;			/* line number for next update. */
+	int nr_lines;			/* # lines in list. */
+	int nr_up;			/* # lines up in history. */
+	unsigned long update_flags;	/* Update indication bits. */
+	struct string *cline;		/* current output line. */
+	struct string *status;		/* last line of display. */
+	struct raw3270_request *write;	/* single write request. */
+	struct timer_list timer;
+
+	/* Input stuff. */
+	struct string *input;		/* input string for read request. */
+	struct raw3270_request *read;	/* single read request. */
+	struct raw3270_request *kreset;	/* single keyboard reset request. */
+	struct tasklet_struct readlet;	/* tasklet to issue read request. */
+};
+
+static struct con3270 *condev;
+
+/* con3270->update_flags. See con3270_update for details. */
+#define CON_UPDATE_ERASE	1	/* Use EWRITEA instead of WRITE. */
+#define CON_UPDATE_LIST		2	/* Update lines in tty3270->update. */
+#define CON_UPDATE_STATUS	4	/* Update status line. */
+#define CON_UPDATE_ALL		7
+
+static void con3270_update(struct con3270 *);
+
+/*
+ * Setup timeout for a device. On timeout trigger an update.
+ */
+void
+con3270_set_timer(struct con3270 *cp, int expires)
+{
+	if (expires == 0) {
+		if (timer_pending(&cp->timer))
+			del_timer(&cp->timer);
+		return;
+	}
+	if (timer_pending(&cp->timer)) {
+		if (mod_timer(&cp->timer, jiffies + expires))
+			return;
+	}
+	cp->timer.function = (void (*)(unsigned long)) con3270_update;
+	cp->timer.data = (unsigned long) cp;
+	cp->timer.expires = jiffies + expires;
+	add_timer(&cp->timer);
+}
+
+/*
+ * The status line is the last line of the screen. It shows the string
+ * "console view" in the lower left corner and "Running"/"More..."/"Holding"
+ * in the lower right corner of the screen.
+ */
+static void
+con3270_update_status(struct con3270 *cp)
+{
+	char *str;
+
+	str = (cp->nr_up != 0) ? "History" : "Running";
+	memcpy(cp->status->string + 24, str, 7);
+	codepage_convert(cp->view.ascebc, cp->status->string + 24, 7);
+	cp->update_flags |= CON_UPDATE_STATUS;
+}
+
+static void
+con3270_create_status(struct con3270 *cp)
+{
+	static const unsigned char blueprint[] =
+		{ TO_SBA, 0, 0, TO_SF,TF_LOG,TO_SA,TAT_COLOR, TAC_GREEN,
+		  'c','o','n','s','o','l','e',' ','v','i','e','w',
+		  TO_RA,0,0,0,'R','u','n','n','i','n','g',TO_SF,TF_LOG };
+
+	cp->status = alloc_string(&cp->freemem, sizeof(blueprint));
+	/* Copy blueprint to status line */
+	memcpy(cp->status->string, blueprint, sizeof(blueprint));
+	/* Set TO_RA addresses. */
+	raw3270_buffer_address(cp->view.dev, cp->status->string + 1,
+			       cp->view.cols * (cp->view.rows - 1));
+	raw3270_buffer_address(cp->view.dev, cp->status->string + 21,
+			       cp->view.cols * cp->view.rows - 8);
+	/* Convert strings to ebcdic. */
+	codepage_convert(cp->view.ascebc, cp->status->string + 8, 12);
+	codepage_convert(cp->view.ascebc, cp->status->string + 24, 7);
+}
+
+/*
+ * Set output offsets to 3270 datastream fragment of a console string.
+ */
+static void
+con3270_update_string(struct con3270 *cp, struct string *s, int nr)
+{
+	if (s->len >= cp->view.cols - 5)
+		return;
+	raw3270_buffer_address(cp->view.dev, s->string + s->len - 3,
+			       cp->view.cols * (nr + 1));
+}
+
+/*
+ * Rebuild update list to print all lines.
+ */
+static void
+con3270_rebuild_update(struct con3270 *cp)
+{
+	struct string *s, *n;
+	int nr;
+
+	/* 
+	 * Throw away update list and create a new one,
+	 * containing all lines that will fit on the screen.
+	 */
+	list_for_each_entry_safe(s, n, &cp->update, update)
+		list_del_init(&s->update);
+	nr = cp->view.rows - 2 + cp->nr_up;
+	list_for_each_entry_reverse(s, &cp->lines, list) {
+		if (nr < cp->view.rows - 1)
+			list_add(&s->update, &cp->update);
+		if (--nr < 0)
+			break;
+	}
+	cp->line_nr = 0;
+	cp->update_flags |= CON_UPDATE_LIST;
+}
+
+/*
+ * Alloc string for size bytes. Free strings from history if necessary.
+ */
+static struct string *
+con3270_alloc_string(struct con3270 *cp, size_t size)
+{
+	struct string *s, *n;
+
+	s = alloc_string(&cp->freemem, size);
+	if (s)
+		return s;
+	list_for_each_entry_safe(s, n, &cp->lines, list) {
+		list_del(&s->list);
+		if (!list_empty(&s->update))
+			list_del(&s->update);
+		cp->nr_lines--;
+		if (free_string(&cp->freemem, s) >= size)
+			break;
+	}
+	s = alloc_string(&cp->freemem, size);
+	BUG_ON(!s);
+	if (cp->nr_up != 0 && cp->nr_up + cp->view.rows > cp->nr_lines) {
+		cp->nr_up = cp->nr_lines - cp->view.rows + 1;
+		con3270_rebuild_update(cp);
+		con3270_update_status(cp);
+	}
+	return s;
+}
+
+/*
+ * Write completion callback.
+ */
+static void
+con3270_write_callback(struct raw3270_request *rq, void *data)
+{
+	raw3270_request_reset(rq);
+	xchg(&((struct con3270 *) rq->view)->write, rq);
+}
+
+/*
+ * Update console display.
+ */
+static void
+con3270_update(struct con3270 *cp)
+{
+	struct raw3270_request *wrq;
+	char wcc, prolog[6];
+	unsigned long flags;
+	unsigned long updated;
+	struct string *s, *n;
+	int rc;
+
+	wrq = xchg(&cp->write, 0);
+	if (!wrq) {
+		con3270_set_timer(cp, 1);
+		return;
+	}
+
+	spin_lock_irqsave(&cp->view.lock, flags);
+	updated = 0;
+	if (cp->update_flags & CON_UPDATE_ERASE) {
+		/* Use erase write alternate to initialize display. */
+		raw3270_request_set_cmd(wrq, TC_EWRITEA);
+		updated |= CON_UPDATE_ERASE;
+	} else
+		raw3270_request_set_cmd(wrq, TC_WRITE);
+
+	wcc = TW_NONE;
+	raw3270_request_add_data(wrq, &wcc, 1);
+
+	/*
+	 * Update status line.
+	 */
+	if (cp->update_flags & CON_UPDATE_STATUS)
+		if (raw3270_request_add_data(wrq, cp->status->string,
+					     cp->status->len) == 0)
+			updated |= CON_UPDATE_STATUS;
+
+	if (cp->update_flags & CON_UPDATE_LIST) {
+		prolog[0] = TO_SBA;
+		prolog[3] = TO_SA;
+		prolog[4] = TAT_COLOR;
+		prolog[5] = TAC_TURQ;
+		raw3270_buffer_address(cp->view.dev, prolog + 1,
+				       cp->view.cols * cp->line_nr);
+		raw3270_request_add_data(wrq, prolog, 6);
+		/* Write strings in the update list to the screen. */
+		list_for_each_entry_safe(s, n, &cp->update, update) {
+			if (s != cp->cline)
+				con3270_update_string(cp, s, cp->line_nr);
+			if (raw3270_request_add_data(wrq, s->string,
+						     s->len) != 0)
+				break;
+			list_del_init(&s->update);
+			if (s != cp->cline)
+				cp->line_nr++;
+		}
+		if (list_empty(&cp->update))
+			updated |= CON_UPDATE_LIST;
+	}
+	wrq->callback = con3270_write_callback;
+	rc = raw3270_start(&cp->view, wrq);
+	if (rc == 0) {
+		cp->update_flags &= ~updated;
+		if (cp->update_flags)
+			con3270_set_timer(cp, 1);
+	} else {
+		raw3270_request_reset(wrq);
+		xchg(&cp->write, wrq);
+	}
+	spin_unlock_irqrestore(&cp->view.lock, flags);
+}
+
+/*
+ * Read tasklet.
+ */
+static void
+con3270_read_tasklet(struct raw3270_request *rrq)
+{
+	static char kreset_data = TW_KR;
+	struct con3270 *cp;
+	unsigned long flags;
+	int nr_up, deactivate;
+
+	cp = (struct con3270 *) rrq->view;
+	spin_lock_irqsave(&cp->view.lock, flags);
+	nr_up = cp->nr_up;
+	deactivate = 0;
+	/* Check aid byte. */
+	switch (cp->input->string[0]) {
+	case 0x7d:	/* enter: jump to bottom. */
+		nr_up = 0;
+		break;
+	case 0xf3:	/* PF3: deactivate the console view. */
+		deactivate = 1;
+		break;
+	case 0x6d:	/* clear: start from scratch. */
+		con3270_rebuild_update(cp);
+		cp->update_flags = CON_UPDATE_ALL;
+		con3270_set_timer(cp, 1);
+		break;
+	case 0xf7:	/* PF7: do a page up in the console log. */
+		nr_up += cp->view.rows - 2;
+		if (nr_up + cp->view.rows - 1 > cp->nr_lines) {
+			nr_up = cp->nr_lines - cp->view.rows + 1;
+			if (nr_up < 0)
+				nr_up = 0;
+		}
+		break;
+	case 0xf8:	/* PF8: do a page down in the console log. */
+		nr_up -= cp->view.rows - 2;
+		if (nr_up < 0)
+			nr_up = 0;
+		break;
+	}
+	if (nr_up != cp->nr_up) {
+		cp->nr_up = nr_up;
+		con3270_rebuild_update(cp);
+		con3270_update_status(cp);
+		con3270_set_timer(cp, 1);
+	}
+	spin_unlock_irqrestore(&cp->view.lock, flags);
+
+	/* Start keyboard reset command. */
+	raw3270_request_reset(cp->kreset);
+	raw3270_request_set_cmd(cp->kreset, TC_WRITE);
+	raw3270_request_add_data(cp->kreset, &kreset_data, 1);
+	raw3270_start(&cp->view, cp->kreset);
+
+	if (deactivate)
+		raw3270_deactivate_view(&cp->view);
+
+	raw3270_request_reset(rrq);
+	xchg(&cp->read, rrq);
+	raw3270_put_view(&cp->view);
+}
+
+/*
+ * Read request completion callback.
+ */
+static void
+con3270_read_callback(struct raw3270_request *rq, void *data)
+{
+	raw3270_get_view(rq->view);
+	/* Schedule tasklet to pass input to tty. */
+	tasklet_schedule(&((struct con3270 *) rq->view)->readlet);
+}
+
+/*
+ * Issue a read request. Called only from interrupt function.
+ */
+static void
+con3270_issue_read(struct con3270 *cp)
+{
+	struct raw3270_request *rrq;
+	int rc;
+
+	rrq = xchg(&cp->read, 0);
+	if (!rrq)
+		/* Read already scheduled. */
+		return;
+	rrq->callback = con3270_read_callback;
+	rrq->callback_data = cp;
+	raw3270_request_set_cmd(rrq, TC_READMOD);
+	raw3270_request_set_data(rrq, cp->input->string, cp->input->len);
+	/* Issue the read modified request. */
+	rc = raw3270_start_irq(&cp->view, rrq);
+	if (rc)
+		raw3270_request_reset(rrq);
+}
+
+/*
+ * Switch to the console view.
+ */
+static int
+con3270_activate(struct raw3270_view *view)
+{
+	unsigned long flags;
+	struct con3270 *cp;
+
+	cp = (struct con3270 *) view;
+	spin_lock_irqsave(&cp->view.lock, flags);
+	cp->nr_up = 0;
+	con3270_rebuild_update(cp);
+	con3270_update_status(cp);
+	cp->update_flags = CON_UPDATE_ALL;
+	con3270_set_timer(cp, 1);
+	spin_unlock_irqrestore(&cp->view.lock, flags);
+	return 0;
+}
+
+static void
+con3270_deactivate(struct raw3270_view *view)
+{
+	unsigned long flags;
+	struct con3270 *cp;
+
+	cp = (struct con3270 *) view;
+	spin_lock_irqsave(&cp->view.lock, flags);
+	del_timer(&cp->timer);
+	spin_unlock_irqrestore(&cp->view.lock, flags);
+}
+
+static int
+con3270_irq(struct con3270 *cp, struct raw3270_request *rq, struct irb *irb)
+{
+	/* Handle ATTN. Schedule tasklet to read aid. */
+	if (irb->scsw.dstat & DEV_STAT_ATTENTION)
+		con3270_issue_read(cp);
+
+	if (rq) {
+		if (irb->scsw.dstat & DEV_STAT_UNIT_CHECK)
+			rq->rc = -EIO;
+		else
+			/* Normal end. Copy residual count. */
+			rq->rescnt = irb->scsw.count;
+	}
+	return RAW3270_IO_DONE;
+}
+
+/* Console view to a 3270 device. */
+static struct raw3270_fn con3270_fn = {
+	.activate = con3270_activate,
+	.deactivate = con3270_deactivate,
+	.intv = (void *) con3270_irq
+};
+
+static inline void
+con3270_cline_add(struct con3270 *cp)
+{
+	if (!list_empty(&cp->cline->list))
+		/* Already added. */
+		return;
+	list_add_tail(&cp->cline->list, &cp->lines);
+	cp->nr_lines++;
+	con3270_rebuild_update(cp);
+}
+
+static inline void
+con3270_cline_insert(struct con3270 *cp, unsigned char c)
+{
+	cp->cline->string[cp->cline->len++] = 
+		cp->view.ascebc[(c < ' ') ? ' ' : c];
+	if (list_empty(&cp->cline->update)) {
+		list_add_tail(&cp->cline->update, &cp->update);
+		cp->update_flags |= CON_UPDATE_LIST;
+	}
+}
+
+static inline void
+con3270_cline_end(struct con3270 *cp)
+{
+	struct string *s;
+	unsigned int size;
+
+	/* Copy cline. */
+	size = (cp->cline->len < cp->view.cols - 5) ?
+		cp->cline->len + 4 : cp->view.cols;
+	s = con3270_alloc_string(cp, size);
+	memcpy(s->string, cp->cline->string, cp->cline->len);
+	if (s->len < cp->view.cols - 5) {
+		s->string[s->len - 4] = TO_RA;
+		s->string[s->len - 1] = 0;
+	} else {
+		while (--size > cp->cline->len)
+			s->string[size] = cp->view.ascebc[' '];
+	}
+	/* Replace cline with allocated line s and reset cline. */
+	list_add(&s->list, &cp->cline->list);
+	list_del_init(&cp->cline->list);
+	if (!list_empty(&cp->cline->update)) {
+		list_add(&s->update, &cp->cline->update);
+		list_del_init(&cp->cline->update);
+	}
+	cp->cline->len = 0;
+}
+
+/*
+ * Write a string to the 3270 console
+ */
+static void
+con3270_write(struct console *co, const char *str, unsigned int count)
+{
+	struct con3270 *cp;
+	unsigned long flags;
+	unsigned char c;
+
+	cp = condev;
+	if (cp->view.dev)
+		raw3270_activate_view(&cp->view);
+	spin_lock_irqsave(&cp->view.lock, flags);
+	while (count-- > 0) {
+		c = *str++;
+		if (cp->cline->len == 0)
+			con3270_cline_add(cp);
+		if (c != '\n')
+			con3270_cline_insert(cp, c);
+		if (c == '\n' || cp->cline->len >= cp->view.cols)
+			con3270_cline_end(cp);
+	}
+	/* Setup timer to output current console buffer after 1/10 second */
+	if (cp->view.dev && !timer_pending(&cp->timer))
+		con3270_set_timer(cp, HZ/10);
+	spin_unlock_irqrestore(&cp->view.lock,flags);
+}
+
+extern struct tty_driver *tty3270_driver;
+
+static struct tty_driver *
+con3270_device(struct console *c, int *index)
+{
+	*index = c->index;
+	return tty3270_driver;
+}
+
+/*
+ * Wait for end of write request.
+ */
+static void
+con3270_wait_write(struct con3270 *cp)
+{
+	while (!cp->write) {
+		raw3270_wait_cons_dev(cp->view.dev);
+		barrier();
+	}
+}
+
+/*
+ * panic() calls console_unblank before the system enters a
+ * disabled, endless loop.
+ */
+static void
+con3270_unblank(void)
+{
+	struct con3270 *cp;
+	unsigned long flags;
+
+	cp = condev;
+	if (!cp->view.dev)
+		return;
+	spin_lock_irqsave(&cp->view.lock, flags);
+	con3270_wait_write(cp);
+	cp->nr_up = 0;
+	con3270_rebuild_update(cp);
+	con3270_update_status(cp);
+	while (cp->update_flags != 0) {
+		spin_unlock_irqrestore(&cp->view.lock, flags);
+		con3270_update(cp);
+		spin_lock_irqsave(&cp->view.lock, flags);
+		con3270_wait_write(cp);
+	}
+	spin_unlock_irqrestore(&cp->view.lock, flags);
+}
+
+static int __init 
+con3270_consetup(struct console *co, char *options)
+{
+	return 0;
+}
+
+/*
+ *  The console structure for the 3270 console
+ */
+static struct console con3270 = {
+	.name	 = "tty3270",
+	.write	 = con3270_write,
+	.device	 = con3270_device,
+	.unblank = con3270_unblank,
+	.setup	 = con3270_consetup,
+	.flags	 = CON_PRINTBUFFER,
+};
+
+/*
+ * 3270 console initialization code called from console_init().
+ * NOTE: This is called before kmalloc is available.
+ */
+static int __init
+con3270_init(void)
+{
+	struct ccw_device *cdev;
+	struct raw3270 *rp;
+	void *cbuf;
+	int i;
+
+	/* Check if 3270 is to be the console */
+	if (!CONSOLE_IS_3270)
+		return -ENODEV;
+
+	/* Set the console mode for VM */
+	if (MACHINE_IS_VM) {
+		cpcmd("TERM CONMODE 3270", 0, 0);
+		cpcmd("TERM AUTOCR OFF", 0, 0);
+	}
+
+	cdev = ccw_device_probe_console();
+	if (!cdev)
+		return -ENODEV;
+	rp = raw3270_setup_console(cdev);
+	if (IS_ERR(rp))
+		return PTR_ERR(rp);
+
+	condev = (struct con3270 *) alloc_bootmem_low(sizeof(struct con3270));
+	memset(condev, 0, sizeof(struct con3270));
+	condev->view.dev = rp;
+
+	condev->read = raw3270_request_alloc_bootmem(0);
+	condev->read->callback = con3270_read_callback;
+	condev->read->callback_data = condev;
+	condev->write = 
+		raw3270_request_alloc_bootmem(CON3270_OUTPUT_BUFFER_SIZE);
+	condev->kreset = raw3270_request_alloc_bootmem(1);
+
+	INIT_LIST_HEAD(&condev->lines);
+	INIT_LIST_HEAD(&condev->update);
+	init_timer(&condev->timer);
+	tasklet_init(&condev->readlet, 
+		     (void (*)(unsigned long)) con3270_read_tasklet,
+		     (unsigned long) condev->read);
+
+	raw3270_add_view(&condev->view, &con3270_fn, 0);
+
+	INIT_LIST_HEAD(&condev->freemem);
+	for (i = 0; i < CON3270_STRING_PAGES; i++) {
+		cbuf = (void *) alloc_bootmem_low_pages(PAGE_SIZE);
+		add_string_memory(&condev->freemem, cbuf, PAGE_SIZE);
+	}
+	condev->cline = alloc_string(&condev->freemem, condev->view.cols);
+	condev->cline->len = 0;
+	con3270_create_status(condev);
+	condev->input = alloc_string(&condev->freemem, 80);
+	register_console(&con3270);
+	return 0;
+}
+
+console_initcall(con3270_init);
diff -puN /dev/null drivers/s390/char/defkeymap.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/s390/char/defkeymap.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,156 @@
+
+/* Do not edit this file! It was automatically generated by   */
+/*    loadkeys --mktable defkeymap.map > defkeymap.c          */
+
+#include <linux/types.h>
+#include <linux/keyboard.h>
+#include <linux/kd.h>
+
+u_short plain_map[NR_KEYS] = {
+	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,
+	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,
+	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,
+	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,
+	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,
+	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,
+	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,
+	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,	0xf000,
+	0xf020,	0xf000,	0xf0e2,	0xf0e4,	0xf0e0,	0xf0e1,	0xf0e3,	0xf0e5,
+	0xf0e7,	0xf0f1,	0xf0a2,	0xf02e,	0xf03c,	0xf028,	0xf02b,	0xf07c,
+	0xf026,	0xf0e9,	0xf0e2,	0xf0eb,	0xf0e8,	0xf0ed,	0xf0ee,	0xf0ef,
+	0xf0ec,	0xf0df,	0xf021,	0xf024,	0xf02a,	0xf029,	0xf03b,	0xf0ac,
+	0xf02d,	0xf02f,	0xf0c2,	0xf0c4,	0xf0c0,	0xf0c1,	0xf0c3,	0xf0c5,
+	0xf0c7,	0xf0d1,	0xf0a6,	0xf02c,	0xf025,	0xf05f,	0xf03e,	0xf03f,
+	0xf0f8,	0xf0c9,	0xf0ca,	0xf0cb,	0xf0c8,	0xf0cd,	0xf0ce,	0xf0cf,
+	0xf0cc,	0xf060,	0xf03a,	0xf023,	0xf040,	0xf027,	0xf03d,	0xf022,
+};
+
+static u_short shift_map[NR_KEYS] = {
+	0xf0d8,	0xf061,	0xf062,	0xf063,	0xf064,	0xf065,	0xf066,	0xf067,
+	0xf068,	0xf069,	0xf0ab,	0xf0bb,	0xf0f0,	0xf0fd,	0xf0fe,	0xf0b1,
+	0xf0b0,	0xf06a,	0xf06b,	0xf06c,	0xf06d,	0xf06e,	0xf06f,	0xf070,
+	0xf071,	0xf072,	0xf000,	0xf000,	0xf0e6,	0xf0b8,	0xf0c6,	0xf0a4,
+	0xf0b5,	0xf07e,	0xf073,	0xf074,	0xf075,	0xf076,	0xf077,	0xf078,
+	0xf079,	0xf07a,	0xf0a1,	0xf0bf,	0xf0d0,	0xf0dd,	0xf0de,	0xf0ae,
+	0xf402,	0xf0a3,	0xf0a5,	0xf0b7,	0xf0a9,	0xf0a7,	0xf0b6,	0xf0bc,
+	0xf0bd,	0xf0be,	0xf05b,	0xf05d,	0xf000,	0xf0a8,	0xf0b4,	0xf0d7,
+	0xf07b,	0xf041,	0xf042,	0xf043,	0xf044,	0xf045,	0xf046,	0xf047,
+	0xf048,	0xf049,	0xf000,	0xf0f4,	0xf0f6,	0xf0f2,	0xf0f3,	0xf0f5,
+	0xf07d,	0xf04a,	0xf04b,	0xf04c,	0xf04d,	0xf04e,	0xf04f,	0xf050,
+	0xf051,	0xf052,	0xf0b9,	0xf0fb,	0xf0fc,	0xf0f9,	0xf0fa,	0xf0ff,
+	0xf05c,	0xf0f7,	0xf053,	0xf054,	0xf055,	0xf056,	0xf057,	0xf058,
+	0xf059,	0xf05a,	0xf0b2,	0xf0d4,	0xf0d6,	0xf0d2,	0xf0d3,	0xf0d5,
+	0xf030,	0xf031,	0xf032,	0xf033,	0xf034,	0xf035,	0xf036,	0xf037,
+	0xf038,	0xf039,	0xf0b3,	0xf0db,	0xf0dc,	0xf0d9,	0xf0da,	0xf000,
+};
+
+static u_short ctrl_map[NR_KEYS] = {
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf11f,	0xf120,	0xf121,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf01a,	0xf003,	0xf212,	0xf004,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf109,	0xf10a,	0xf206,	0xf00a,	0xf200,	0xf200,
+};
+
+static u_short shift_ctrl_map[NR_KEYS] = {
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf10c,	0xf10d,	0xf10e,	0xf10f,	0xf110,	0xf111,	0xf112,
+	0xf113,	0xf11e,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+	0xf200,	0xf100,	0xf101,	0xf211,	0xf103,	0xf104,	0xf105,	0xf20b,
+	0xf20a,	0xf108,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
+};
+
+ushort *key_maps[MAX_NR_KEYMAPS] = {
+	plain_map, shift_map, 0, 0,
+	ctrl_map, shift_ctrl_map,	0
+};
+
+unsigned int keymap_count = 4;
+
+
+/*
+ * Philosophy: most people do not define more strings, but they who do
+ * often want quite a lot of string space. So, we statically allocate
+ * the default and allocate dynamically in chunks of 512 bytes.
+ */
+
+char func_buf[] = {
+	'\033', '[', '[', 'A', 0, 
+	'\033', '[', '[', 'B', 0, 
+	'\033', '[', '[', 'C', 0, 
+	'\033', '[', '[', 'D', 0, 
+	'\033', '[', '[', 'E', 0, 
+	'\033', '[', '1', '7', '~', 0, 
+	'\033', '[', '1', '8', '~', 0, 
+	'\033', '[', '1', '9', '~', 0, 
+	'\033', '[', '2', '0', '~', 0, 
+	'\033', '[', '2', '1', '~', 0, 
+	'\033', '[', '2', '3', '~', 0, 
+	'\033', '[', '2', '4', '~', 0, 
+	'\033', '[', '2', '5', '~', 0, 
+	'\033', '[', '2', '6', '~', 0, 
+	'\033', '[', '2', '8', '~', 0, 
+	'\033', '[', '2', '9', '~', 0, 
+	'\033', '[', '3', '1', '~', 0, 
+	'\033', '[', '3', '2', '~', 0, 
+	'\033', '[', '3', '3', '~', 0, 
+	'\033', '[', '3', '4', '~', 0, 
+};
+
+
+char *funcbufptr = func_buf;
+int funcbufsize = sizeof(func_buf);
+int funcbufleft = 0;          /* space left */
+
+char *func_table[MAX_NR_FUNC] = {
+	func_buf + 0,
+	func_buf + 5,
+	func_buf + 10,
+	func_buf + 15,
+	func_buf + 20,
+	func_buf + 25,
+	func_buf + 31,
+	func_buf + 37,
+	func_buf + 43,
+	func_buf + 49,
+	func_buf + 55,
+	func_buf + 61,
+	func_buf + 67,
+	func_buf + 73,
+	func_buf + 79,
+	func_buf + 85,
+	func_buf + 91,
+	func_buf + 97,
+	func_buf + 103,
+	func_buf + 109,
+	0,
+};
+
+struct kbdiacr accent_table[MAX_DIACR] = {
+	{'^', 'c', '\003'},	{'^', 'd', '\004'},
+	{'^', 'z', '\032'},	{'^', '\012', '\000'},
+};
+
+unsigned int accent_table_size = 4;
diff -puN /dev/null drivers/s390/char/defkeymap.map
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/s390/char/defkeymap.map	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,191 @@
+# Default keymap for 3270 (ebcdic codepage 037).
+keymaps 0-1,4-5
+
+keycode   0 = nul		Oslash
+keycode   1 = nul		a
+keycode   2 = nul		b
+keycode   3 = nul		c
+keycode   4 = nul		d
+keycode   5 = nul		e
+keycode   6 = nul		f
+keycode   7 = nul		g
+keycode   8 = nul		h
+keycode   9 = nul		i
+keycode  10 = nul		guillemotleft
+keycode  11 = nul		guillemotright
+keycode  12 = nul		eth
+keycode  13 = nul		yacute
+keycode  14 = nul		thorn
+keycode  15 = nul		plusminus
+keycode  16 = nul		degree
+keycode  17 = nul		j
+keycode  18 = nul		k
+keycode  19 = nul		l
+keycode  20 = nul		m
+keycode  21 = nul		n
+keycode  22 = nul		o
+keycode  23 = nul		p
+keycode  24 = nul		q
+keycode  25 = nul		r
+keycode  26 = nul		nul
+keycode  27 = nul		nul
+keycode  28 = nul		ae
+keycode  29 = nul		cedilla
+keycode  30 = nul		AE
+keycode  31 = nul		currency
+keycode  32 = nul		mu
+keycode  33 = nul		tilde
+keycode  34 = nul		s
+keycode  35 = nul		t
+keycode  36 = nul		u
+keycode  37 = nul		v
+keycode  38 = nul		w
+keycode  39 = nul		x
+keycode  40 = nul		y
+keycode  41 = nul		z
+keycode  42 = nul		exclamdown
+keycode  43 = nul		questiondown
+keycode  44 = nul		ETH
+keycode  45 = nul		Yacute
+keycode  46 = nul		THORN
+keycode  47 = nul		registered
+keycode  48 = nul		dead_circumflex
+keycode  49 = nul		sterling
+keycode  50 = nul		yen
+keycode  51 = nul		periodcentered
+keycode  52 = nul		copyright
+keycode  53 = nul		section
+keycode  54 = nul		paragraph
+keycode  55 = nul		onequarter
+keycode  56 = nul		onehalf
+keycode  57 = nul		threequarters
+keycode  58 = nul		bracketleft
+keycode  59 = nul		bracketright
+keycode  60 = nul		nul
+keycode  61 = nul		diaeresis
+keycode  62 = nul		acute
+keycode  63 = nul		multiply
+keycode  64 = space		braceleft
+keycode  65 = nul		A
+keycode  66 = acircumflex	B
+keycode  67 = adiaeresis	C
+keycode  68 = agrave		D
+keycode  69 = aacute		E
+keycode  70 = atilde		F
+keycode  71 = aring		G
+keycode  72 = ccedilla		H
+keycode  73 = ntilde		I
+keycode  74 = cent		nul
+keycode  75 = period		ocircumflex
+keycode  76 = less		odiaeresis
+keycode  77 = parenleft		ograve
+keycode  78 = plus		oacute
+keycode  79 = bar		otilde
+keycode  80 = ampersand		braceright
+keycode  81 = eacute		J
+keycode  82 = acircumflex	K
+keycode  83 = ediaeresis	L
+keycode  84 = egrave		M
+keycode  85 = iacute		N
+keycode  86 = icircumflex	O
+keycode  87 = idiaeresis	P
+keycode  88 = igrave		Q
+keycode  89 = ssharp		R
+keycode  90 = exclam		onesuperior
+keycode  91 = dollar		ucircumflex
+keycode  92 = asterisk		udiaeresis
+keycode  93 = parenright	ugrave
+keycode  94 = semicolon		uacute
+keycode  95 = notsign		ydiaeresis
+keycode  96 = minus		backslash
+keycode  97 = slash		division
+keycode  98 = Acircumflex	S
+keycode  99 = Adiaeresis	T
+keycode 100 = Agrave		U
+keycode 101 = Aacute		V
+keycode 102 = Atilde		W
+keycode 103 = Aring		X
+keycode 104 = Ccedilla		Y
+keycode 105 = Ntilde		Z
+keycode 106 = brokenbar		twosuperior
+keycode 107 = comma		Ocircumflex
+keycode 108 = percent		Odiaeresis
+keycode 109 = underscore	Ograve
+keycode 110 = greater		Oacute
+keycode 111 = question		Otilde
+keycode 112 = oslash		zero
+keycode 113 = Eacute		one
+keycode 114 = Ecircumflex	two
+keycode 115 = Ediaeresis	three
+keycode 116 = Egrave		four
+keycode 117 = Iacute		five
+keycode 118 = Icircumflex	six
+keycode 119 = Idiaeresis	seven
+keycode 120 = Igrave		eight
+keycode 121 = grave		nine
+keycode 122 = colon		threesuperior
+keycode 123 = numbersign	Ucircumflex
+keycode 124 = at		Udiaeresis
+keycode 125 = apostrophe	Ugrave
+keycode 126 = equal		Uacute
+keycode 127 = quotedbl		nul
+
+# AID keys
+control keycode  74 = F22
+control keycode  75 = F23
+control keycode  76 = F24
+control keycode 107 = Control_z		# PA3
+control keycode 108 = Control_c		# PA1
+control keycode 109 = KeyboardSignal	# Clear
+control keycode 110 = Control_d		# PA2
+control keycode 122 = F10
+control keycode 123 = F11		# F11
+control keycode 124 = Last_Console	# F12
+control keycode 125 = Linefeed
+shift control keycode  65 = F13
+shift control keycode  66 = F14
+shift control keycode  67 = F15
+shift control keycode  68 = F16
+shift control keycode  69 = F17
+shift control keycode  70 = F18
+shift control keycode  71 = F19
+shift control keycode  72 = F20
+shift control keycode  73 = F21
+shift control keycode 113 = F1
+shift control keycode 114 = F2
+shift control keycode 115 = Incr_Console
+shift control keycode 116 = F4
+shift control keycode 117 = F5
+shift control keycode 118 = F6
+shift control keycode 119 = Scroll_Backward
+shift control keycode 120 = Scroll_Forward
+shift control keycode 121 = F9
+
+string F1 = "\033[[A"
+string F2 = "\033[[B"
+string F3 = "\033[[C"
+string F4 = "\033[[D"
+string F5 = "\033[[E"
+string F6 = "\033[17~"
+string F7 = "\033[18~"
+string F8 = "\033[19~"
+string F9 = "\033[20~"
+string F10 = "\033[21~"
+string F11 = "\033[23~"
+string F12 = "\033[24~"
+string F13 = "\033[25~"
+string F14 = "\033[26~"
+string F15 = "\033[28~"
+string F16 = "\033[29~"
+string F17 = "\033[31~"
+string F18 = "\033[32~"
+string F19 = "\033[33~"
+string F20 = "\033[34~"
+# string F21 ??
+# string F22 ??
+# string F23 ??
+# string F24 ??
+compose '^' 'c' to Control_c
+compose '^' 'd' to Control_d
+compose '^' 'z' to Control_z
+compose '^' '\012' to nul
diff -puN /dev/null drivers/s390/char/fs3270.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/s390/char/fs3270.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,373 @@
+/*
+ *  drivers/s390/char/fs3270.c
+ *    IBM/3270 Driver - fullscreen driver.
+ *
+ *  Author(s):
+ *    Original 3270 Code for 2.4 written by Richard Hitt (UTS Global)
+ *    Rewritten for 2.5/2.6 by Martin Schwidefsky <schwidefsky@de.ibm.com>
+ *	-- Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ */
+
+#include <linux/config.h>
+#include <linux/bootmem.h>
+#include <linux/console.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/list.h>
+#include <linux/types.h>
+
+#include <asm/ccwdev.h>
+#include <asm/cio.h>
+#include <asm/cpcmd.h>
+#include <asm/ebcdic.h>
+#include <asm/idals.h>
+
+#include "raw3270.h"
+#include "ctrlchar.h"
+
+struct raw3270_fn fs3270_fn;
+
+struct fs3270 {
+	struct raw3270_view view;
+	pid_t fs_pid;			/* Pid of controlling program. */
+	int read_command;		/* ccw command to use for reads. */
+	int write_command;		/* ccw command to use for writes. */
+	int attention;			/* Got attention. */
+	struct raw3270_request *clear;	/* single clear request. */
+	wait_queue_head_t attn_wait;	/* Attention wait queue. */
+};
+
+static void
+fs3270_wake_up(struct raw3270_request *rq, void *data)
+{
+	wake_up((wait_queue_head_t *) data);
+}
+
+static int
+fs3270_do_io(struct raw3270_view *view, struct raw3270_request *rq)
+{
+	wait_queue_head_t wq;
+	int rc;
+
+	init_waitqueue_head(&wq);
+	rq->callback = fs3270_wake_up;
+	rq->callback_data = &wq;
+	rc = raw3270_start(view, rq);
+	if (rc)
+		return rc;
+	/* Started sucessfully. Now wait for completion. */
+	wait_event(wq, raw3270_request_final(rq));
+	return rq->rc;
+}
+
+static void
+fs3270_reset_callback(struct raw3270_request *rq, void *data)
+{
+	raw3270_request_reset(rq);
+}
+
+/*
+ * Switch to the fullscreen view.
+ */
+static int
+fs3270_activate(struct raw3270_view *view)
+{
+	struct fs3270 *fp;
+
+	fp = (struct fs3270 *) view;
+	raw3270_request_set_cmd(fp->clear, TC_EWRITEA);
+	fp->clear->callback = fs3270_reset_callback;
+	return raw3270_start(view, fp->clear);
+}
+
+/*
+ * Shutdown fullscreen view.
+ */
+static void
+fs3270_deactivate(struct raw3270_view *view)
+{
+	// FIXME: is this a good idea? The user program using fullscreen 3270
+	// will die just because a console message appeared. On the other
+	// hand the fullscreen device is unoperational now.
+	struct fs3270 *fp;
+
+	fp = (struct fs3270 *) view;
+	if (fp->fs_pid != 0)
+		kill_proc(fp->fs_pid, SIGHUP, 1);
+	fp->fs_pid = 0;
+}
+
+static int
+fs3270_irq(struct fs3270 *fp, struct raw3270_request *rq, struct irb *irb)
+{
+	/* Handle ATTN. Set indication and wake waiters for attention. */
+	if (irb->scsw.dstat & DEV_STAT_ATTENTION) {
+		fp->attention = 1;
+		wake_up(&fp->attn_wait);
+	}
+
+	if (rq) {
+		if (irb->scsw.dstat & DEV_STAT_UNIT_CHECK)
+			rq->rc = -EIO;
+		else
+			/* Normal end. Copy residual count. */
+			rq->rescnt = irb->scsw.count;
+	}
+	return RAW3270_IO_DONE;
+}
+
+/*
+ * Process reads from fullscreen 3270.
+ */
+static ssize_t
+fs3270_read(struct file *filp, char *data, size_t count, loff_t *off)
+{
+	struct fs3270 *fp;
+	struct raw3270_request *rq;
+	struct idal_buffer *ib;
+	int rc;
+	
+	if (count == 0 || count > 65535)
+		return -EINVAL;
+	fp = filp->private_data;
+	if (!fp)
+		return -ENODEV;
+	ib = idal_buffer_alloc(count, 0);
+	if (!ib)
+		return -ENOMEM;
+	rq = raw3270_request_alloc(0);
+	if (!IS_ERR(rq)) {
+		if (fp->read_command == 0 && fp->write_command != 0)
+			fp->read_command = 6;
+		raw3270_request_set_cmd(rq, fp->read_command ? : 2);
+		raw3270_request_set_idal(rq, ib);
+		wait_event(fp->attn_wait, fp->attention);
+		rc = fs3270_do_io(&fp->view, rq);
+		if (rc == 0 && idal_buffer_to_user(ib, data, count))
+			rc = -EFAULT;
+		raw3270_request_free(rq);
+	} else
+		rc = PTR_ERR(rq);
+	idal_buffer_free(ib);
+	return rc;
+}
+
+/*
+ * Process writes to fullscreen 3270.
+ */
+static ssize_t
+fs3270_write(struct file *filp, const char *data, size_t count, loff_t *off)
+{
+	struct fs3270 *fp;
+	struct raw3270_request *rq;
+	struct idal_buffer *ib;
+	int write_command;
+	int rc;
+
+	fp = filp->private_data;
+	if (!fp)
+		return -ENODEV;
+	ib = idal_buffer_alloc(count, 0);
+	if (!ib)
+		return -ENOMEM;
+	rq = raw3270_request_alloc(0);
+	if (!IS_ERR(rq)) {
+		if (idal_buffer_from_user(ib, data, count) == 0) {
+			write_command = fp->write_command ? : 1;
+			if (write_command == 5)
+				write_command = 13;
+			raw3270_request_set_cmd(rq, write_command);
+			raw3270_request_set_idal(rq, ib);
+			rc = fs3270_do_io(&fp->view, rq);
+		} else
+			rc = -EFAULT;
+		raw3270_request_free(rq);
+	} else
+		rc = PTR_ERR(rq);
+	idal_buffer_free(ib);
+	return rc;
+}
+
+/*
+ * process ioctl commands for the tube driver
+ */
+static int
+fs3270_ioctl(struct inode *inode, struct file *filp,
+	     unsigned int cmd, unsigned long arg)
+{
+	struct fs3270 *fp;
+	struct raw3270_iocb iocb;
+	int rc;
+
+	fp = filp->private_data;
+	if (!fp)
+		return -ENODEV;
+	rc = 0;
+	switch (cmd) {
+	case TUBICMD:
+		fp->read_command = arg;
+		break;
+	case TUBOCMD:
+		fp->write_command = arg;
+		break;
+	case TUBGETI:
+		rc = put_user(fp->read_command, (char *) arg);
+		break;
+	case TUBGETO:
+		rc = put_user(fp->write_command,(char *) arg);
+		break;
+	case TUBGETMOD:
+		iocb.model = fp->view.model;
+		iocb.line_cnt = fp->view.rows;
+		iocb.col_cnt = fp->view.cols;
+		iocb.pf_cnt = 24;
+		iocb.re_cnt = 20;
+		iocb.map = 0;
+		if (copy_to_user((char *) arg, &iocb,
+				 sizeof(struct raw3270_iocb)))
+			rc = -EFAULT;
+		break;
+	}
+	return rc;
+}
+
+/*
+ * Allocate tty3270 structure.
+ */
+static struct fs3270 *
+fs3270_alloc_view(void)
+{
+	struct fs3270 *fp;
+
+	fp = (struct fs3270 *) kmalloc(sizeof(struct fs3270),GFP_KERNEL);
+	if (!fp)
+		return ERR_PTR(-ENOMEM);
+	memset(fp, 0, sizeof(struct fs3270));
+	fp->clear = raw3270_request_alloc(0);
+	if (!IS_ERR(fp->clear)) {
+		kfree(fp);
+		return ERR_PTR(-ENOMEM);
+	}
+	return fp;
+}
+
+/*
+ * Free tty3270 structure.
+ */
+static void
+fs3270_free_view(struct raw3270_view *view)
+{
+	raw3270_request_free(((struct fs3270 *) view)->clear);
+	kfree(view);
+}
+
+/*
+ * Unlink fs3270 data structure from filp.
+ */
+static void
+fs3270_release(struct raw3270_view *view)
+{
+}
+
+/* View to a 3270 device. Can be console, tty or fullscreen. */
+struct raw3270_fn fs3270_fn = {
+	.activate = fs3270_activate,
+	.deactivate = fs3270_deactivate,
+	.intv = (void *) fs3270_irq,
+	.release = fs3270_release,
+	.free = fs3270_free_view
+};
+
+/*
+ * This routine is called whenever a 3270 fullscreen device is opened.
+ */
+static int
+fs3270_open(struct inode *inode, struct file *filp)
+{
+	struct fs3270 *fp;
+	int minor, rc;
+
+	if (imajor(filp->f_dentry->d_inode) != IBM_FS3270_MAJOR)
+		return -ENODEV;
+	minor = iminor(filp->f_dentry->d_inode);
+	/* Check if some other program is already using fullscreen mode. */
+	fp = (struct fs3270 *) raw3270_find_view(&fs3270_fn, minor);
+	if (!IS_ERR(fp)) {
+		raw3270_put_view(&fp->view);
+		return -EBUSY;
+	}
+	/* Allocate fullscreen view structure. */
+	fp = fs3270_alloc_view();
+	if (IS_ERR(fp))
+		return PTR_ERR(fp);
+
+	init_waitqueue_head(&fp->attn_wait);
+	fp->fs_pid = current->pid;
+	rc = raw3270_add_view(&fp->view, &fs3270_fn, minor);
+	if (rc) {
+		fs3270_free_view(&fp->view);
+		return rc;
+	}
+
+	rc = raw3270_activate_view(&fp->view);
+	if (rc) {
+		raw3270_del_view(&fp->view);
+		return rc;
+	}
+	filp->private_data = fp;
+	return 0;
+}
+
+/*
+ * This routine is called when the 3270 tty is closed. We wait
+ * for the remaining request to be completed. Then we clean up.
+ */
+static int
+fs3270_close(struct inode *inode, struct file *filp)
+{
+	struct fs3270 *fp;
+
+	fp = filp->private_data;
+	filp->private_data = 0;
+	if (fp)
+		raw3270_del_view(&fp->view);
+	return 0;
+}
+
+static struct file_operations fs3270_fops = {
+	.owner	 = THIS_MODULE,		/* owner */
+	.read	 = fs3270_read,		/* read */
+	.write	 = fs3270_write,	/* write */
+	.ioctl	 = fs3270_ioctl,	/* ioctl */
+	.open	 = fs3270_open,		/* open */
+	.release = fs3270_close,	/* release */
+};
+
+/*
+ * 3270 fullscreen driver initialization.
+ */
+static int __init
+fs3270_init(void)
+{
+	int rc;
+
+	rc = register_chrdev(IBM_FS3270_MAJOR, "fs3270", &fs3270_fops);
+	if (rc) {
+		printk(KERN_ERR "fs3270 can't get major number %d: errno %d\n",
+		       IBM_FS3270_MAJOR, rc);
+		return rc;
+	}
+	return 0;
+}
+
+static void __exit
+fs3270_exit(void)
+{
+	unregister_chrdev(IBM_FS3270_MAJOR, "fs3270");
+}
+
+MODULE_LICENSE("GPL");
+MODULE_ALIAS_CHARDEV_MAJOR(IBM_FS3270_MAJOR);
+
+module_init(fs3270_init);
+module_exit(fs3270_exit);
diff -puN /dev/null drivers/s390/char/keyboard.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/s390/char/keyboard.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,516 @@
+/*
+ *  drivers/s390/char/keyboard.c
+ *    ebcdic keycode functions for s390 console drivers
+ *
+ *  S390 version
+ *    Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/sysrq.h>
+
+#include <linux/kbd_kern.h>
+#include <linux/kbd_diacr.h>
+#include <asm/uaccess.h>
+
+#include "keyboard.h"
+
+/*
+ * Handler Tables.
+ */
+#define K_HANDLERS\
+	k_self,		k_fn,		k_spec,		k_ignore,\
+	k_dead,		k_ignore,	k_ignore,	k_ignore,\
+	k_ignore,	k_ignore,	k_ignore,	k_ignore,\
+	k_ignore,	k_ignore,	k_ignore,	k_ignore
+
+typedef void (k_handler_fn)(struct kbd_data *, unsigned char);
+static k_handler_fn K_HANDLERS;
+static k_handler_fn *k_handler[16] = { K_HANDLERS };
+
+/* maximum values each key_handler can handle */
+static const int max_vals[] = {
+	255, ARRAY_SIZE(func_table) - 1, NR_FN_HANDLER - 1, 0,
+	NR_DEAD - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+static const int NR_TYPES = ARRAY_SIZE(max_vals);
+
+static unsigned char ret_diacr[NR_DEAD] = {
+	'`', '\'', '^', '~', '"', ','
+};
+
+/*
+ * Alloc/free of kbd_data structures.
+ */
+struct kbd_data *
+kbd_alloc(void) {
+	struct kbd_data *kbd;
+	int i, len;
+
+	kbd = kmalloc(sizeof(struct kbd_data), GFP_KERNEL);
+	if (!kbd)
+		goto out;
+	memset(kbd, 0, sizeof(struct kbd_data));
+	kbd->key_maps = kmalloc(sizeof(key_maps), GFP_KERNEL);
+	if (!key_maps)
+		goto out_kbd;
+	memset(kbd->key_maps, 0, sizeof(key_maps));
+	for (i = 0; i < ARRAY_SIZE(key_maps); i++) {
+		if (key_maps[i]) {
+			kbd->key_maps[i] =
+				kmalloc(sizeof(u_short)*NR_KEYS, GFP_KERNEL);
+			if (!kbd->key_maps[i])
+				goto out_maps;
+			memcpy(kbd->key_maps[i], key_maps[i],
+			       sizeof(u_short)*NR_KEYS);
+		}
+	}
+	kbd->func_table = kmalloc(sizeof(func_table), GFP_KERNEL);
+	if (!kbd->func_table)
+		goto out_maps;
+	memset(kbd->func_table, 0, sizeof(func_table));
+	for (i = 0; i < ARRAY_SIZE(func_table); i++) {
+		if (func_table[i]) {
+			len = strlen(func_table[i]) + 1;
+			kbd->func_table[i] = kmalloc(len, GFP_KERNEL);
+			if (!kbd->func_table[i])
+				goto out_func;
+			memcpy(kbd->func_table[i], func_table[i], len);
+		}
+	}
+	kbd->fn_handler =
+		kmalloc(sizeof(fn_handler_fn *) * NR_FN_HANDLER, GFP_KERNEL);
+	if (!kbd->fn_handler)
+		goto out_func;
+	memset(kbd->fn_handler, 0, sizeof(fn_handler_fn *) * NR_FN_HANDLER);
+	kbd->accent_table =
+		kmalloc(sizeof(struct kbdiacr)*MAX_DIACR, GFP_KERNEL);
+	if (!kbd->accent_table)
+		goto out_fn_handler;
+	memcpy(kbd->accent_table, accent_table,
+	       sizeof(struct kbdiacr)*MAX_DIACR);
+	kbd->accent_table_size = accent_table_size;
+	return kbd;
+
+out_fn_handler:
+	kfree(kbd->fn_handler);
+out_func:
+	for (i = 0; i < ARRAY_SIZE(func_table); i++)
+		if (kbd->func_table[i])
+			kfree(kbd->func_table[i]);
+	kfree(kbd->func_table);
+out_maps:
+	for (i = 0; i < ARRAY_SIZE(key_maps); i++)
+		if (kbd->key_maps[i])
+			kfree(kbd->key_maps[i]);
+	kfree(kbd->key_maps);
+out_kbd:
+	kfree(kbd);
+out:
+	return 0;
+}
+
+void
+kbd_free(struct kbd_data *kbd)
+{
+	int i;
+
+	kfree(kbd->accent_table);
+	kfree(kbd->fn_handler);
+	for (i = 0; i < ARRAY_SIZE(func_table); i++)
+		if (kbd->func_table[i])
+			kfree(kbd->func_table[i]);
+	kfree(kbd->func_table);
+	for (i = 0; i < ARRAY_SIZE(key_maps); i++)
+		if (kbd->key_maps[i])
+			kfree(kbd->key_maps[i]);
+	kfree(kbd->key_maps);
+	kfree(kbd);
+}
+
+/*
+ * Generate ascii -> ebcdic translation table from kbd_data.
+ */
+void
+kbd_ascebc(struct kbd_data *kbd, unsigned char *ascebc)
+{
+	unsigned short *keymap, keysym;
+	int i, j, k;
+
+	memset(ascebc, 0x40, 256);
+	for (i = 0; i < ARRAY_SIZE(key_maps); i++) {
+		keymap = kbd->key_maps[i];
+		if (!keymap)
+			continue;
+		for (j = 0; j < NR_KEYS; j++) {
+			k = ((i & 1) << 7) + j;
+			keysym = keymap[j];
+			if (KTYP(keysym) == (KT_LATIN | 0xf0) ||
+			    KTYP(keysym) == (KT_LETTER | 0xf0))
+				ascebc[KVAL(keysym)] = k;
+			else if (KTYP(keysym) == (KT_DEAD | 0xf0))
+				ascebc[ret_diacr[KVAL(keysym)]] = k;
+		}
+	}
+}
+
+/*
+ * Generate ebcdic -> ascii translation table from kbd_data.
+ */
+void
+kbd_ebcasc(struct kbd_data *kbd, unsigned char *ebcasc)
+{
+	unsigned short *keymap, keysym;
+	int i, j, k;
+
+	memset(ebcasc, ' ', 256);
+	for (i = 0; i < ARRAY_SIZE(key_maps); i++) {
+		keymap = kbd->key_maps[i];
+		if (!keymap)
+			continue;
+		for (j = 0; j < NR_KEYS; j++) {
+			keysym = keymap[j];
+			k = ((i & 1) << 7) + j;
+			if (KTYP(keysym) == (KT_LATIN | 0xf0) ||
+			    KTYP(keysym) == (KT_LETTER | 0xf0))
+				ebcasc[k] = KVAL(keysym);
+			else if (KTYP(keysym) == (KT_DEAD | 0xf0))
+				ebcasc[k] = ret_diacr[KVAL(keysym)];
+		}
+	}
+}
+
+/*
+ * We have a combining character DIACR here, followed by the character CH.
+ * If the combination occurs in the table, return the corresponding value.
+ * Otherwise, if CH is a space or equals DIACR, return DIACR.
+ * Otherwise, conclude that DIACR was not combining after all,
+ * queue it and return CH.
+ */
+static unsigned char
+handle_diacr(struct kbd_data *kbd, unsigned char ch)
+{
+	int i, d;
+
+	d = kbd->diacr;
+	kbd->diacr = 0;
+
+	for (i = 0; i < kbd->accent_table_size; i++) {
+		if (kbd->accent_table[i].diacr == d &&
+		    kbd->accent_table[i].base == ch)
+			return kbd->accent_table[i].result;
+	}
+
+	if (ch == ' ' || ch == d)
+		return d;
+
+	kbd_put_queue(kbd->tty, d);
+	return ch;
+}
+
+/*
+ * Handle dead key.
+ */
+static void
+k_dead(struct kbd_data *kbd, unsigned char value)
+{
+	value = ret_diacr[value];
+	kbd->diacr = (kbd->diacr ? handle_diacr(kbd, value) : value);
+}
+
+/*
+ * Normal character handler.
+ */
+static void
+k_self(struct kbd_data *kbd, unsigned char value)
+{
+	if (kbd->diacr)
+		value = handle_diacr(kbd, value);
+	kbd_put_queue(kbd->tty, value);
+}
+
+/*
+ * Special key handlers
+ */
+static void
+k_ignore(struct kbd_data *kbd, unsigned char value)
+{
+}
+
+/*
+ * Function key handler.
+ */
+static void
+k_fn(struct kbd_data *kbd, unsigned char value)
+{
+	if (kbd->func_table[value])
+		kbd_puts_queue(kbd->tty, kbd->func_table[value]);
+}
+
+static void
+k_spec(struct kbd_data *kbd, unsigned char value)
+{
+	if (value >= NR_FN_HANDLER)
+		return;
+	if (kbd->fn_handler[value])
+		kbd->fn_handler[value](kbd);
+}
+
+/*
+ * Put utf8 character to tty flip buffer.
+ * UTF-8 is defined for words of up to 31 bits,
+ * but we need only 16 bits here
+ */
+static void
+to_utf8(struct tty_struct *tty, ushort c) 
+{
+	if (c < 0x80)
+		/*  0******* */
+		kbd_put_queue(tty, c);
+	else if (c < 0x800) {
+		/* 110***** 10****** */
+		kbd_put_queue(tty, 0xc0 | (c >> 6));
+		kbd_put_queue(tty, 0x80 | (c & 0x3f));
+	} else {
+		/* 1110**** 10****** 10****** */
+		kbd_put_queue(tty, 0xe0 | (c >> 12));
+		kbd_put_queue(tty, 0x80 | ((c >> 6) & 0x3f));
+		kbd_put_queue(tty, 0x80 | (c & 0x3f));
+	}
+}
+
+/*
+ * Process keycode.
+ */
+void
+kbd_keycode(struct kbd_data *kbd, unsigned int keycode)
+{
+	unsigned short keysym;
+	unsigned char type, value;
+
+	if (!kbd || !kbd->tty)
+		return;
+
+	if (keycode >= 384)
+		keysym = kbd->key_maps[5][keycode - 384];
+	else if (keycode >= 256)
+		keysym = kbd->key_maps[4][keycode - 256];
+	else if (keycode >= 128)
+		keysym = kbd->key_maps[1][keycode - 128];
+	else
+		keysym = kbd->key_maps[0][keycode];
+
+	type = KTYP(keysym);
+	if (type >= 0xf0) {
+		type -= 0xf0;
+		if (type == KT_LETTER)
+			type = KT_LATIN;
+		value = KVAL(keysym);
+#ifdef CONFIG_MAGIC_SYSRQ	       /* Handle the SysRq Hack */
+		if (kbd->sysrq) {
+			if (kbd->sysrq == K(KT_LATIN, '-')) {
+				kbd->sysrq = 0;
+				handle_sysrq(value, 0, kbd->tty);
+				return;
+			}
+			if (value == '-') {
+				kbd->sysrq = K(KT_LATIN, '-');
+				return;
+			}
+			/* Incomplete sysrq sequence. */
+			(*k_handler[KTYP(kbd->sysrq)])(kbd, KVAL(kbd->sysrq));
+			kbd->sysrq = 0;
+		} else if ((type == KT_LATIN && value == '^') ||
+			   (type == KT_DEAD && ret_diacr[value] == '^')) {
+			kbd->sysrq = K(type, value);
+			return;
+		}
+#endif
+		(*k_handler[type])(kbd, value);
+	} else
+		to_utf8(kbd->tty, keysym);
+}
+
+/*
+ * Ioctl stuff.
+ */
+static int
+do_kdsk_ioctl(struct kbd_data *kbd, struct kbentry *user_kbe,
+	      int cmd, int perm)
+{
+	struct kbentry tmp;
+	ushort *key_map, val, ov;
+
+	if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
+		return -EFAULT;
+#if NR_KEYS < 256
+	if (tmp.kb_index >= NR_KEYS)
+		return -EINVAL;
+#endif
+#if MAX_NR_KEYMAPS < 256
+	if (tmp.kb_table >= MAX_NR_KEYMAPS)
+		return -EINVAL;	
+#endif
+
+	switch (cmd) {
+	case KDGKBENT:
+		key_map = kbd->key_maps[tmp.kb_table];
+		if (key_map) {
+		    val = U(key_map[tmp.kb_index]);
+		    if (KTYP(val) >= NR_TYPES)
+			val = K_HOLE;
+		} else
+		    val = (tmp.kb_index ? K_HOLE : K_NOSUCHMAP);
+		return put_user(val, &user_kbe->kb_value);
+	case KDSKBENT:
+		if (!perm)
+			return -EPERM;
+		if (!tmp.kb_index && tmp.kb_value == K_NOSUCHMAP) {
+			/* disallocate map */
+			key_map = kbd->key_maps[tmp.kb_table];
+			if (key_map) {
+			    kbd->key_maps[tmp.kb_table] = 0;
+			    kfree(key_map);
+			}
+			break;
+		}
+
+		if (KTYP(tmp.kb_value) >= NR_TYPES)
+			return -EINVAL;
+		if (KVAL(tmp.kb_value) > max_vals[KTYP(tmp.kb_value)])
+			return -EINVAL;
+
+		if (!(key_map = kbd->key_maps[tmp.kb_table])) {
+			int j;
+
+			key_map = (ushort *) kmalloc(sizeof(plain_map),
+						     GFP_KERNEL);
+			if (!key_map)
+				return -ENOMEM;
+			kbd->key_maps[tmp.kb_table] = key_map;
+			for (j = 0; j < NR_KEYS; j++)
+				key_map[j] = U(K_HOLE);
+		}
+		ov = U(key_map[tmp.kb_index]);
+		if (tmp.kb_value == ov)
+			break;	/* nothing to do */
+		/*
+		 * Attention Key.
+		 */
+		if (((ov == K_SAK) || (tmp.kb_value == K_SAK)) &&
+		    !capable(CAP_SYS_ADMIN))
+			return -EPERM;
+		key_map[tmp.kb_index] = U(tmp.kb_value);
+		break;
+	}
+	return 0;
+}
+
+static int
+do_kdgkb_ioctl(struct kbd_data *kbd, struct kbsentry *u_kbs,
+	       int cmd, int perm)
+{
+	unsigned char kb_func;
+	char *p;
+	int len;
+
+	/* Get u_kbs->kb_func. */
+	if (get_user(kb_func, &u_kbs->kb_func))
+		return -EFAULT;
+#if MAX_NR_FUNC < 256
+	if (kb_func >= MAX_NR_FUNC)
+		return -EINVAL;
+#endif
+
+	switch (cmd) {
+	case KDGKBSENT:
+		p = kbd->func_table[kb_func];
+		if (p) {
+			len = strlen(p);
+			if (len >= sizeof(u_kbs->kb_string))
+				len = sizeof(u_kbs->kb_string) - 1;
+			if (copy_to_user(u_kbs->kb_string, p, len))
+				return -EFAULT;
+		} else
+			len = 0;
+		if (put_user('\0', u_kbs->kb_string + len))
+			return -EFAULT;
+		break;
+	case KDSKBSENT:
+		if (!perm)
+			return -EPERM;
+		len = strnlen_user(u_kbs->kb_string,
+				   sizeof(u_kbs->kb_string) - 1);
+		p = kmalloc(len, GFP_KERNEL);
+		if (!p)
+			return -ENOMEM;
+		if (copy_from_user(p, u_kbs->kb_string, len)) {
+			kfree(p);
+			return -EFAULT;
+		}
+		p[len] = 0;
+		if (kbd->func_table[kb_func])
+			kfree(kbd->func_table[kb_func]);
+		kbd->func_table[kb_func] = p;
+		break;
+	}
+	return 0;
+}
+
+int
+kbd_ioctl(struct kbd_data *kbd, struct file *file,
+	  unsigned int cmd, unsigned long arg)
+{
+	struct kbdiacrs *a;
+	int ct, perm;
+
+	/*
+	 * To have permissions to do most of the vt ioctls, we either have
+	 * to be the owner of the tty, or have CAP_SYS_TTY_CONFIG.
+	 */
+	perm = current->tty == kbd->tty || capable(CAP_SYS_TTY_CONFIG);
+	switch (cmd) {
+	case KDGKBTYPE:
+		return put_user(KB_101, (char*) arg);
+	case KDGKBENT:
+	case KDSKBENT:
+		return do_kdsk_ioctl(kbd, (struct kbentry *)arg, cmd, perm);
+	case KDGKBSENT:
+	case KDSKBSENT:
+		return do_kdgkb_ioctl(kbd, (struct kbsentry *)arg, cmd, perm);
+	case KDGKBDIACR:
+		a = (struct kbdiacrs *) arg;
+
+		if (put_user(kbd->accent_table_size, &a->kb_cnt))
+			return -EFAULT;
+		ct = kbd->accent_table_size;
+		if (copy_to_user(a->kbdiacr, kbd->accent_table,
+				 ct * sizeof(struct kbdiacr)))
+			return -EFAULT;
+		return 0;
+	case KDSKBDIACR:
+		a = (struct kbdiacrs *) arg;
+		if (!perm)
+			return -EPERM;
+		if (get_user(ct, &a->kb_cnt))
+			return -EFAULT;
+		if (ct >= MAX_DIACR)
+			return -EINVAL;
+		kbd->accent_table_size = ct;
+		if (copy_from_user(kbd->accent_table, a->kbdiacr,
+				   ct * sizeof(struct kbdiacr)))
+			return -EFAULT;
+		return 0;
+	default:
+		return -ENOIOCTLCMD;
+	}
+}
+
+EXPORT_SYMBOL(kbd_ioctl);
+EXPORT_SYMBOL(kbd_ascebc);
+EXPORT_SYMBOL(kbd_free);
+EXPORT_SYMBOL(kbd_alloc);
+EXPORT_SYMBOL(kbd_keycode);
diff -puN /dev/null drivers/s390/char/keyboard.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/s390/char/keyboard.h	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,57 @@
+/*
+ *  drivers/s390/char/keyboard.h
+ *    ebcdic keycode functions for s390 console drivers
+ *
+ *    Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
+ */
+
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/keyboard.h>
+
+#define NR_FN_HANDLER	20
+
+struct kbd_data;
+
+typedef void (fn_handler_fn)(struct kbd_data *);
+
+/*
+ * FIXME: explain key_maps tricks.
+ */
+
+struct kbd_data {
+	struct tty_struct *tty;
+	unsigned short **key_maps;
+	char **func_table;
+	fn_handler_fn **fn_handler;
+	struct kbdiacr *accent_table;
+	unsigned int accent_table_size;
+	unsigned char diacr;
+	unsigned short sysrq;
+};
+
+struct kbd_data *kbd_alloc(void);
+void kbd_free(struct kbd_data *);
+void kbd_ascebc(struct kbd_data *, unsigned char *);
+
+void kbd_keycode(struct kbd_data *, unsigned int);
+int kbd_ioctl(struct kbd_data *, struct file *, unsigned int, unsigned long);
+
+/*
+ * Helper Functions.
+ */
+extern inline void
+kbd_put_queue(struct tty_struct *tty, int ch)
+{
+	tty_insert_flip_char(tty, ch, 0);
+	tty_schedule_flip(tty);
+}
+
+extern inline void
+kbd_puts_queue(struct tty_struct *tty, char *cp)
+{
+	while (*cp)
+		tty_insert_flip_char(tty, *cp++, 0);
+	tty_schedule_flip(tty);
+}
diff -puN drivers/s390/char/Makefile~linus drivers/s390/char/Makefile
--- 25/drivers/s390/char/Makefile~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/char/Makefile	2004-01-19 22:17:22.000000000 -0800
@@ -2,18 +2,20 @@
 # S/390 character devices
 #
 
-tub3270-objs := tuball.o tubfs.o tubtty.o \
-                     tubttyaid.o tubttybld.o tubttyscl.o \
-                     tubttyrcl.o tubttysiz.o
+obj-y += ctrlchar.o keyboard.o defkeymap.o
+
+tub3270-objs := raw3270.o tty3270.o fs3270.o
+obj-$(CONFIG_TN3270) += tub3270.o
+obj-$(CONFIG_TN3270_CONSOLE) += con3270.o
 
-obj-y += ctrlchar.o
 obj-$(CONFIG_TN3215) += con3215.o
+
 obj-$(CONFIG_SCLP) += sclp.o sclp_rw.o
 obj-$(CONFIG_SCLP_TTY) += sclp_tty.o
 obj-$(CONFIG_SCLP_CONSOLE) += sclp_con.o
 obj-$(CONFIG_SCLP_VT220_TTY) += sclp_vt220.o
 obj-$(CONFIG_SCLP_CPI) += sclp_cpi.o
-obj-$(CONFIG_TN3270) += tub3270.o
+
 tape-$(CONFIG_S390_TAPE_BLOCK) += tape_block.o
 tape-$(CONFIG_PROC_FS) += tape_proc.o
 tape-objs := tape_core.o tape_std.o tape_char.o $(tape-y)
diff -puN /dev/null drivers/s390/char/raw3270.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/s390/char/raw3270.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,1256 @@
+/*
+ *  drivers/s390/char/raw3270.c
+ *    IBM/3270 Driver - core functions.
+ *
+ *  Author(s):
+ *    Original 3270 Code for 2.4 written by Richard Hitt (UTS Global)
+ *    Rewritten for 2.5 by Martin Schwidefsky <schwidefsky@de.ibm.com>
+ *	-- Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ */
+
+#include <linux/config.h>
+#include <linux/bootmem.h>
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/list.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+#include <linux/wait.h>
+
+#include <asm/ccwdev.h>
+#include <asm/cio.h>
+#include <asm/ebcdic.h>
+
+#include "raw3270.h"
+
+/* The main 3270 data structure. */
+struct raw3270 {
+	struct list_head list;
+	struct ccw_device *cdev;
+	int minor;
+
+	short model, rows, cols;
+	unsigned long flags;
+
+	struct list_head req_queue;	/* Request queue. */
+	struct list_head view_list;	/* List of available views. */
+	struct raw3270_view *view;	/* Active view. */
+
+	struct timer_list timer;	/* Device timer. */
+
+	unsigned char *ascebc;		/* ascii -> ebcdic table */
+};
+
+/* raw3270->flags */
+#define RAW3270_FLAGS_14BITADDR	0	/* 14-bit buffer addresses */
+#define RAW3270_FLAGS_BUSY	1	/* Device busy, leave it alone */
+#define RAW3270_FLAGS_ATTN	2	/* Device sent an ATTN interrupt */
+#define RAW3270_FLAGS_SHUTDOWN	4	/* Device is in offline processing */
+#define RAW3270_FLAGS_CONSOLE	8	/* Device is the console. */
+
+/* Lock to protect global data of raw3270 (devices, views, etc). */
+static spinlock_t raw3270_lock = SPIN_LOCK_UNLOCKED;
+
+/* List of 3270 devices. */
+static struct list_head raw3270_devices = LIST_HEAD_INIT(raw3270_devices);
+
+/*
+ * Flag to indicate if the driver has been registered. Some operations
+ * like waiting for the end of i/o need to be done differently as long
+ * as the kernel is still starting up (console support).
+ */
+static int raw3270_registered;
+
+/* Module parameters */
+static int tubxcorrect = 0;
+MODULE_PARM(tubxcorrect, "i");
+
+/*
+ * Wait queue for device init/delete, view delete.
+ */
+DECLARE_WAIT_QUEUE_HEAD(raw3270_wait_queue);
+
+/*
+ * Encode array for 12 bit 3270 addresses.
+ */
+unsigned char raw3270_ebcgraf[64] =	{
+	0x40, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+	0xc8, 0xc9, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+	0x50, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+	0xd8, 0xd9, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+	0x60, 0x61, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+	0xe8, 0xe9, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+	0xf8, 0xf9, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f
+};
+
+void
+raw3270_buffer_address(struct raw3270 *rp, char *cp, unsigned short addr)
+{
+	if (test_bit(RAW3270_FLAGS_14BITADDR, &rp->flags)) {
+		cp[0] = (addr >> 8) & 0x3f;
+		cp[1] = addr & 0xff;
+	} else {
+		cp[0] = raw3270_ebcgraf[(addr >> 6) & 0x3f];
+		cp[1] = raw3270_ebcgraf[addr & 0x3f];
+	}
+}
+
+/*
+ * Allocate a new 3270 ccw request
+ */
+struct raw3270_request *
+raw3270_request_alloc(size_t size)
+{
+	struct raw3270_request *rq;
+
+	/* Allocate request structure */
+	rq = kmalloc(sizeof(struct raw3270_request), GFP_KERNEL | GFP_DMA);
+	if (!rq)
+		return ERR_PTR(-ENOMEM);
+	memset(rq, 0, sizeof(struct raw3270_request));
+
+	/* alloc output buffer. */
+	if (size > 0) {
+		rq->buffer = kmalloc(size, GFP_KERNEL | GFP_DMA);
+		if (!rq->buffer) {
+			kfree(rq);
+			return ERR_PTR(-ENOMEM);
+		}
+	}
+	rq->size = size;
+	INIT_LIST_HEAD(&rq->list);
+
+	/*
+	 * Setup ccw.
+	 */
+	rq->ccw.cda = __pa(rq->buffer);
+	rq->ccw.flags = CCW_FLAG_SLI;
+
+	return rq;
+}
+
+#ifdef CONFIG_TN3270_CONSOLE
+/*
+ * Allocate a new 3270 ccw request from bootmem. Only works very
+ * early in the boot process. Only con3270.c should be using this.
+ */
+struct raw3270_request *
+raw3270_request_alloc_bootmem(size_t size)
+{
+	struct raw3270_request *rq;
+
+	rq = alloc_bootmem_low(sizeof(struct raw3270));
+	if (!rq)
+		return ERR_PTR(-ENOMEM);
+	memset(rq, 0, sizeof(struct raw3270_request));
+
+	/* alloc output buffer. */
+	if (size > 0) {
+		rq->buffer = alloc_bootmem_low(size);
+		if (!rq->buffer) {
+			free_bootmem((unsigned long) rq,
+				     sizeof(struct raw3270));
+			return ERR_PTR(-ENOMEM);
+		}
+	}
+	rq->size = size;
+	INIT_LIST_HEAD(&rq->list);
+
+	/*
+	 * Setup ccw.
+	 */
+	rq->ccw.cda = __pa(rq->buffer);
+	rq->ccw.flags = CCW_FLAG_SLI;
+
+	return rq;
+}
+#endif
+
+/*
+ * Free 3270 ccw request
+ */
+void
+raw3270_request_free (struct raw3270_request *rq)
+{
+	if (rq->buffer)
+		kfree(rq->buffer);
+	kfree(rq);
+}
+
+/*
+ * Reset request to initial state.
+ */
+void
+raw3270_request_reset(struct raw3270_request *rq)
+{
+	BUG_ON(!list_empty(&rq->list));
+	rq->ccw.cmd_code = 0;
+	rq->ccw.count = 0;
+	rq->ccw.cda = __pa(rq->buffer);
+	rq->ccw.flags = CCW_FLAG_SLI;
+	rq->rescnt = 0;
+	rq->rc = 0;
+}
+
+/*
+ * Set command code to ccw of a request.
+ */
+void
+raw3270_request_set_cmd(struct raw3270_request *rq, u8 cmd)
+{
+	rq->ccw.cmd_code = cmd;
+}
+
+/*
+ * Add data fragment to output buffer.
+ */
+int
+raw3270_request_add_data(struct raw3270_request *rq, void *data, size_t size)
+{
+	if (size + rq->ccw.count > rq->size)
+		return -E2BIG;
+	memcpy(rq->buffer + rq->ccw.count, data, size);
+	rq->ccw.count += size;
+	return 0;
+}
+
+/*
+ * Set address/length pair to ccw of a request.
+ */
+void
+raw3270_request_set_data(struct raw3270_request *rq, void *data, size_t size)
+{
+	rq->ccw.cda = __pa(data);
+	rq->ccw.count = size;
+}
+
+/*
+ * Set idal buffer to ccw of a request.
+ */
+void
+raw3270_request_set_idal(struct raw3270_request *rq, struct idal_buffer *ib)
+{
+	rq->ccw.cda = __pa(ib->data);
+	rq->ccw.count = ib->size;
+	rq->ccw.flags |= CCW_FLAG_IDA;
+}
+
+/*
+ * Stop running ccw.
+ */
+static int
+raw3270_halt_io_nolock(struct raw3270 *rp, struct raw3270_request *rq)
+{
+	int retries;
+	int rc;
+
+	if (raw3270_request_final(rq))
+		return 0;
+	/* Check if interrupt has already been processed */
+	for (retries = 0; retries < 5; retries++) {
+		if (retries < 2)
+			rc = ccw_device_halt(rp->cdev, (long) rq);
+		else
+			rc = ccw_device_clear(rp->cdev, (long) rq);
+		if (rc == 0)
+			break;		/* termination successful */
+	}
+	return rc;
+}
+
+static int
+raw3270_halt_io(struct raw3270 *rp, struct raw3270_request *rq)
+{
+	unsigned long flags;
+	int rc;
+
+	spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags);
+	rc = raw3270_halt_io_nolock(rp, rq);
+	spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
+	return rc;
+}
+
+/*
+ * Add the request to the request queue, try to start it if the
+ * 3270 device is idle. Return without waiting for end of i/o.
+ */
+static int
+__raw3270_start(struct raw3270 *rp, struct raw3270_view *view,
+		struct raw3270_request *rq)
+{
+	rq->view = view;
+	raw3270_get_view(view);
+	if (list_empty(&rp->req_queue) &&
+	    !test_bit(RAW3270_FLAGS_BUSY, &rp->flags)) {
+		/* No other requests are on the queue. Start this one. */
+		rq->rc = ccw_device_start(rp->cdev, &rq->ccw,
+					       (unsigned long) rq, 0, 0);
+		if (rq->rc) {
+			raw3270_put_view(view);
+			return rq->rc;
+		}
+	}
+	list_add_tail(&rq->list, &rp->req_queue);
+	return 0;
+}
+
+int
+raw3270_start(struct raw3270_view *view, struct raw3270_request *rq)
+{
+	unsigned long flags;
+	struct raw3270 *rp;
+	int rc;
+
+	spin_lock_irqsave(get_ccwdev_lock(view->dev->cdev), flags);
+	rp = view->dev;
+	if (!rp || rp->view != view)
+		rc = -EACCES;
+	else if (test_bit(RAW3270_FLAGS_SHUTDOWN, &rp->flags))
+		rc = -ENODEV;
+	else
+		rc =  __raw3270_start(rp, view, rq);
+	spin_unlock_irqrestore(get_ccwdev_lock(view->dev->cdev), flags);
+	return rc;
+}
+
+int
+raw3270_start_irq(struct raw3270_view *view, struct raw3270_request *rq)
+{
+	struct raw3270 *rp;
+
+	rp = view->dev;
+	rq->view = view;
+	raw3270_get_view(view);
+	list_add_tail(&rq->list, &rp->req_queue);
+	return 0;
+}
+
+/*
+ * 3270 interrupt routine, called from the ccw_device layer
+ */
+static void
+raw3270_irq (struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
+{
+	struct raw3270 *rp;
+	struct raw3270_view *view;
+	struct raw3270_request *rq;
+	int rc;
+
+	rp = (struct raw3270 *) cdev->dev.driver_data;
+	if (!rp)
+		return;
+	rq = (struct raw3270_request *) intparm;
+	view = rq ? rq->view : rp->view;
+
+	if (irb->scsw.dstat == 
+	    (DEV_STAT_CHN_END | DEV_STAT_DEV_END | DEV_STAT_UNIT_EXCEP)) {
+		/* Handle CE-DE-UE and subsequent UDE */
+		set_bit(RAW3270_FLAGS_BUSY, &rp->flags);
+		rc = RAW3270_IO_BUSY;
+	} else if (test_bit(RAW3270_FLAGS_BUSY, &rp->flags)) {
+		/* Wait for UDE if busy flag is set. */
+		if (irb->scsw.dstat & DEV_STAT_DEV_END) {
+			clear_bit(RAW3270_FLAGS_BUSY, &rp->flags);
+			/* Got it, now retry. */
+			rc = RAW3270_IO_RETRY;
+		} else
+			rc = RAW3270_IO_BUSY;
+	} else if (view)
+		rc = view->fn->intv(view, rq, irb);
+	else
+		rc = RAW3270_IO_DONE;
+
+	switch (rc) {
+	case RAW3270_IO_DONE:
+		break;
+	case RAW3270_IO_BUSY:
+		/* 
+		 * Intervention required by the operator. We have to wait
+		 * for unsolicited device end.
+		 */
+		return;
+	case RAW3270_IO_RETRY:
+		if (!rq)
+			break;
+		rq->rc = ccw_device_start(rp->cdev, &rq->ccw,
+					  (unsigned long) rq, 0, 0);
+		if (rq->rc == 0)
+			return;	/* Sucessfully restarted. */
+		break;
+	case RAW3270_IO_STOP:
+		raw3270_halt_io_nolock(rp, rq);
+		rq->rc = -EIO;
+		break;
+	default:
+		BUG();
+	}
+	if (rq) {
+		BUG_ON(list_empty(&rq->list));
+		/* The request completed, remove from queue and do callback. */
+		list_del_init(&rq->list);
+		if (rq->callback)
+			rq->callback(rq, rq->callback_data);
+		/* Do put_device for get_device in raw3270_start. */
+		raw3270_put_view(view);
+	}
+	/*
+	 * Try to start each request on request queue until one is
+	 * started successful.
+	 */
+	while (!list_empty(&rp->req_queue)) {
+		rq = list_entry(rp->req_queue.next,struct raw3270_request,list);
+		rq->rc = ccw_device_start(rp->cdev, &rq->ccw,
+					  (unsigned long) rq, 0, 0);
+		if (rq->rc == 0)
+			break;
+		/* Start failed. Remove request and do callback. */
+		list_del_init(&rq->list);
+		if (rq->callback)
+			rq->callback(rq, rq->callback_data);
+		/* Do put_device for get_device in raw3270_start. */
+		raw3270_put_view(view);
+	}
+}
+
+/*
+ * Size sensing.
+ */
+
+struct raw3270_ua {	/* Query Reply structure for Usable Area */
+	struct {	/* Usable Area Query Reply Base */
+		short l;	/* Length of this structured field */
+		char  sfid;	/* 0x81 if Query Reply */
+		char  qcode;	/* 0x81 if Usable Area */
+		char  flags0;
+		char  flags1;
+		short w;	/* Width of usable area */
+		short h;	/* Heigth of usavle area */
+		char  units;	/* 0x00:in; 0x01:mm */
+		int   xr;
+		int   yr;
+		char  aw;
+		char  ah;
+		short buffsz;	/* Character buffer size, bytes */
+		char  xmin;
+		char  ymin;
+		char  xmax;
+		char  ymax;
+	} __attribute__ ((packed)) uab;
+	struct {	/* Alternate Usable Area Self-Defining Parameter */
+		char  l;	/* Length of this Self-Defining Parm */
+		char  sdpid;	/* 0x02 if Alternate Usable Area */
+		char  res;
+		char  auaid;	/* 0x01 is Id for the A U A */
+		short wauai;	/* Width of AUAi */
+		short hauai;	/* Height of AUAi */
+		char  auaunits;	/* 0x00:in, 0x01:mm */
+		int   auaxr;
+		int   auayr;
+		char  awauai;
+		char  ahauai;
+	} __attribute__ ((packed)) aua;
+} __attribute__ ((packed));
+
+static unsigned char raw3270_init_data[256];
+static struct raw3270_request raw3270_init_request;
+static struct diag210 raw3270_init_diag210;
+static DECLARE_MUTEX(raw3270_init_sem);
+
+static int
+raw3270_init_irq(struct raw3270_view *view, struct raw3270_request *rq,
+		 struct irb *irb)
+{
+	/*
+	 * Unit-Check Processing:
+	 * Expect Command Reject or Intervention Required.
+	 */
+	if (irb->scsw.dstat & DEV_STAT_UNIT_CHECK) {
+		/* Request finished abnormally. */
+		if (irb->ecw[0] & SNS0_INTERVENTION_REQ) {
+			set_bit(RAW3270_FLAGS_BUSY, &view->dev->flags);
+			return RAW3270_IO_BUSY;
+		}
+	}
+	if (rq) {
+		if (irb->scsw.dstat & DEV_STAT_UNIT_CHECK) {
+			if (irb->ecw[0] & SNS0_CMD_REJECT)
+				rq->rc = -EOPNOTSUPP;
+			else
+				rq->rc = -EIO;
+		} else
+			/* Request finished normally. Copy residual count. */
+			rq->rescnt = irb->scsw.count;
+	}
+	if (irb->scsw.dstat & DEV_STAT_ATTENTION) {
+		set_bit(RAW3270_FLAGS_ATTN, &view->dev->flags);
+		wake_up(&raw3270_wait_queue);
+	}
+	return RAW3270_IO_DONE;
+}
+
+static struct raw3270_fn raw3270_init_fn = {
+	.intv = raw3270_init_irq
+};
+
+static struct raw3270_view raw3270_init_view = {
+	.fn = &raw3270_init_fn
+};
+
+/*
+ * raw3270_wait/raw3270_wait_interruptible/__raw3270_wakeup
+ * Wait for end of request. The request must have been started
+ * with raw3270_start, rc = 0. The device lock may NOT have been
+ * released between calling raw3270_start and raw3270_wait.
+ */
+static void
+raw3270_wake_init(struct raw3270_request *rq, void *data)
+{
+	wake_up((wait_queue_head_t *) data);
+}
+
+/*
+ * Special wait function that can cope with console initialization.
+ */
+static int
+raw3270_start_init(struct raw3270 *rp, struct raw3270_view *view,
+		   struct raw3270_request *rq)
+{
+	unsigned long flags;
+	wait_queue_head_t wq;
+	int rc;
+
+#ifdef CONFIG_TN3270_CONSOLE
+	if (raw3270_registered == 0) {
+		spin_lock_irqsave(get_ccwdev_lock(view->dev->cdev), flags);
+		rq->callback = 0;
+		rc = __raw3270_start(rp, view, rq);
+		if (rc == 0)
+			while (!raw3270_request_final(rq)) {
+				wait_cons_dev();
+				barrier();
+			}
+		spin_unlock_irqrestore(get_ccwdev_lock(view->dev->cdev), flags);
+		return rq->rc;
+	}
+#endif
+	init_waitqueue_head(&wq);
+	rq->callback = raw3270_wake_init;
+	rq->callback_data = &wq;
+	spin_lock_irqsave(get_ccwdev_lock(view->dev->cdev), flags);
+	rc = __raw3270_start(rp, view, rq);
+	spin_unlock_irqrestore(get_ccwdev_lock(view->dev->cdev), flags);
+	if (rc)
+		return rc;
+	/* Now wait for the completion. */
+	rc = wait_event_interruptible(wq, raw3270_request_final(rq));
+	if (rc == -ERESTARTSYS) {	/* Interrupted by a signal. */
+		raw3270_halt_io(view->dev, rq);
+		return -ERESTARTSYS;
+	}
+	return rq->rc;
+}
+
+static int
+__raw3270_size_device_vm(struct raw3270 *rp)
+{
+	int rc, model;
+
+	raw3270_init_diag210.vrdcdvno = 
+		_ccw_device_get_device_number(rp->cdev);
+	raw3270_init_diag210.vrdclen = sizeof(struct diag210);
+	rc = diag210(&raw3270_init_diag210);
+	if (rc)
+		return rc;
+	model = raw3270_init_diag210.vrdccrmd;
+	switch (model) {
+	case 2:
+		rp->model = model;
+		rp->rows = 24;
+		rp->cols = 80;
+		break;
+	case 3:
+		rp->model = model;
+		rp->rows = 32;
+		rp->cols = 80;
+		break;
+	case 4:
+		rp->model = model;
+		rp->rows = 43;
+		rp->cols = 80;
+		break;
+	case 5:
+		rp->model = model;
+		rp->rows = 27;
+		rp->cols = 132;
+		break;
+	default:
+		printk(KERN_WARNING "vrdccrmd is 0x%.8x\n", model);
+		rc = -EOPNOTSUPP;
+		break;
+	}
+	return rc;
+}
+
+static int
+__raw3270_size_device(struct raw3270 *rp)
+{
+	static const unsigned char wbuf[] =
+		{ 0x00, 0x07, 0x01, 0xff, 0x03, 0x00, 0x81 };
+	unsigned long flags;
+	struct raw3270_ua *uap;
+	unsigned short count;
+	int rc;
+
+	/*
+	 * To determine the size of the 3270 device we need to do:
+	 * 1) send a 'read partition' data stream to the device
+	 * 2) wait for the attn interrupt that preceeds the query reply
+	 * 3) do a read modified to get the query reply
+	 * To make things worse we have to cope with intervention
+	 * required (3270 device switched to 'stand-by') and command
+	 * rejects (old devices that can't do 'read partition').
+	 */
+	memset(&raw3270_init_request, 0, sizeof(raw3270_init_request));
+	memset(raw3270_init_data, 0, sizeof(raw3270_init_data));
+	/* Store 'read partition' data stream to raw3270_init_data */
+	memcpy(raw3270_init_data, wbuf, sizeof(wbuf));
+	INIT_LIST_HEAD(&raw3270_init_request.list);
+	raw3270_init_request.ccw.cmd_code = TC_WRITESF;
+	raw3270_init_request.ccw.flags = CCW_FLAG_SLI;
+	raw3270_init_request.ccw.count = sizeof(wbuf);
+	raw3270_init_request.ccw.cda = (__u32) __pa(raw3270_init_data);
+
+	rc = raw3270_start_init(rp, &raw3270_init_view, &raw3270_init_request);
+	if (rc) {
+		/* Check error cases: -ERESTARTSYS, -EIO and -EOPNOTSUPP */
+		if (rc == -EOPNOTSUPP && MACHINE_IS_VM)
+			return __raw3270_size_device_vm(rp);
+		return rc;
+	}
+
+	/* Wait for attention interrupt. */
+#ifdef CONFIG_TN3270_CONSOLE
+	if (raw3270_registered == 0) {
+		spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags);
+		while (!test_and_clear_bit(RAW3270_FLAGS_ATTN, &rp->flags))
+			wait_cons_dev();
+		spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
+	} else
+#endif
+		rc = wait_event_interruptible(raw3270_wait_queue,
+			test_and_clear_bit(RAW3270_FLAGS_ATTN, &rp->flags));
+	if (rc)
+		return rc;
+
+	/*
+	 * The device accepted the 'read partition' command. Now
+	 * set up a read ccw and issue it.
+	 */
+	raw3270_init_request.ccw.cmd_code = TC_READMOD;
+	raw3270_init_request.ccw.flags = CCW_FLAG_SLI;
+	raw3270_init_request.ccw.count = sizeof(raw3270_init_data);
+	raw3270_init_request.ccw.cda = (__u32) __pa(raw3270_init_data);
+	rc = raw3270_start_init(rp, &raw3270_init_view, &raw3270_init_request);
+	if (rc)
+		return rc;
+	/* Got a Query Reply */
+	count = sizeof(raw3270_init_data) - raw3270_init_request.rescnt;
+	uap = (struct raw3270_ua *) (raw3270_init_data + 1);
+	/* Paranoia check. */
+	if (raw3270_init_data[0] != 0x88 || uap->uab.qcode != 0x81)
+		return -EOPNOTSUPP;
+	/* Copy rows/columns of default Usable Area */
+	rp->rows = uap->uab.h;
+	rp->cols = uap->uab.w;
+	/* Check for 14 bit addressing */
+	if ((uap->uab.flags0 & 0x0d) == 0x01)
+		set_bit(RAW3270_FLAGS_14BITADDR, &rp->flags);
+	/* Check for Alternate Usable Area */
+	if (uap->uab.l == sizeof(struct raw3270_ua) &&
+	    uap->aua.sdpid == 0x02) {
+		rp->rows = uap->aua.hauai;
+		rp->cols = uap->aua.wauai;
+	}
+	return 0;
+}
+
+static int
+raw3270_size_device(struct raw3270 *rp)
+{
+	int rc;
+
+	down(&raw3270_init_sem);
+	rp->view = &raw3270_init_view;
+	raw3270_init_view.dev = rp;
+	rc = __raw3270_size_device(rp);
+	raw3270_init_view.dev = 0;
+	rp->view = 0;
+	up(&raw3270_init_sem);
+	if (rc == 0) {	/* Found something. */
+		/* Try to find a model. */
+		rp->model = 0;
+		if (rp->rows == 24 && rp->cols == 80)
+			rp->model = 2;
+		if (rp->rows == 32 && rp->cols == 80)
+			rp->model = 3;
+		if (rp->rows == 43 && rp->cols == 80)
+			rp->model = 4;
+		if (rp->rows == 27 && rp->cols == 132)
+			rp->model = 5;
+	}
+	return rc;
+}
+
+static int
+raw3270_reset_device(struct raw3270 *rp)
+{
+	int rc;
+
+	down(&raw3270_init_sem);
+	memset(&raw3270_init_request, 0, sizeof(raw3270_init_request));
+	memset(raw3270_init_data, 0, sizeof(raw3270_init_data));
+	/* Store reset data stream to raw3270_init_data/raw3270_init_request */
+	raw3270_init_data[0] = TW_KR;
+	INIT_LIST_HEAD(&raw3270_init_request.list);
+	raw3270_init_request.ccw.cmd_code = TC_EWRITEA;
+	raw3270_init_request.ccw.flags = CCW_FLAG_SLI;
+	raw3270_init_request.ccw.count = 1;
+	raw3270_init_request.ccw.cda = (__u32) __pa(raw3270_init_data);
+	rp->view = &raw3270_init_view;
+	raw3270_init_view.dev = rp;
+	rc = raw3270_start_init(rp, &raw3270_init_view, &raw3270_init_request);
+	raw3270_init_view.dev = 0;
+	rp->view = 0;
+	up(&raw3270_init_sem);
+	return rc;
+}
+
+/*
+ * Setup new 3270 device.
+ */
+static int
+raw3270_setup_device(struct ccw_device *cdev, struct raw3270 *rp, char *ascebc)
+{
+	struct list_head *l;
+	struct raw3270 *tmp;
+	int minor;
+
+	memset(rp, 0, sizeof(struct raw3270));
+	/* Copy ebcdic -> ascii translation table. */
+	memcpy(ascebc, _ascebc, 256);
+	if (tubxcorrect) {
+		/* correct brackets and circumflex */
+		ascebc['['] = 0xad;
+		ascebc[']'] = 0xbd;
+		ascebc['^'] = 0xb0;
+	}
+	rp->ascebc = ascebc;
+
+	/* Set defaults. */
+	rp->rows = 24;
+	rp->cols = 80;
+
+	INIT_LIST_HEAD(&rp->req_queue);
+	INIT_LIST_HEAD(&rp->view_list);
+
+	/*
+	 * Add device to list and find the smallest unused minor
+	 * number for it.
+	 */
+	spin_lock(&raw3270_lock);
+	/* Keep the list sorted. */
+	minor = 0;
+	rp->minor = -1;
+	list_for_each(l, &raw3270_devices) {
+		tmp = list_entry(l, struct raw3270, list);
+		if (tmp->minor > minor) {
+			rp->minor = minor;
+			__list_add(&rp->list, l->prev, l);
+			break;
+		}
+		minor++;
+	}
+	if (rp->minor == -1 && minor < RAW3270_MAXDEVS) {
+		rp->minor = minor;
+		list_add_tail(&rp->list, &raw3270_devices);
+	}
+	spin_unlock(&raw3270_lock);
+	/* No free minor number? Then give up. */
+	if (rp->minor == -1)
+		return -EUSERS;
+	rp->cdev = cdev;
+	cdev->dev.driver_data = rp;
+	cdev->handler = raw3270_irq;
+	return 0;
+}
+
+#ifdef CONFIG_TN3270_CONSOLE
+/*
+ * Setup 3270 device configured as console.
+ */
+struct raw3270 *
+raw3270_setup_console(struct ccw_device *cdev)
+{
+	struct raw3270 *rp;
+	char *ascebc;
+	int rc;
+
+	rp = (struct raw3270 *) alloc_bootmem(sizeof(struct raw3270));
+	ascebc = (char *) alloc_bootmem(256);
+	rc = raw3270_setup_device(cdev, rp, ascebc);
+	if (rc)
+		return ERR_PTR(rc);
+	set_bit(RAW3270_FLAGS_CONSOLE, &rp->flags);
+	raw3270_reset_device(rp);
+	raw3270_size_device(rp);
+	raw3270_reset_device(rp);
+	return rp;
+}
+
+void
+raw3270_wait_cons_dev(struct raw3270 *rp)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags);
+	wait_cons_dev();
+	spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
+}
+
+#endif
+
+/*
+ * Create a 3270 device structure.
+ */
+static struct raw3270 *
+raw3270_create_device(struct ccw_device *cdev)
+{
+	struct raw3270 *rp;
+	char *ascebc;
+	int rc;
+
+	rp = kmalloc(sizeof(struct raw3270), GFP_KERNEL);
+	if (!rp)
+		return ERR_PTR(-ENOMEM);
+	ascebc = kmalloc(256, GFP_KERNEL);
+	if (!ascebc) {
+		kfree(rp);
+		return ERR_PTR(-ENOMEM);
+	}
+	rc = raw3270_setup_device(cdev, rp, ascebc);
+	if (rc) {
+		kfree(rp->ascebc);
+		kfree(rp);
+		rp = ERR_PTR(rc);
+	}
+	/* Get reference to ccw_device structure. */
+	get_device(&cdev->dev);
+	return rp;
+}
+
+/*
+ * Activate a view.
+ */
+int
+raw3270_activate_view(struct raw3270_view *view)
+{
+	struct raw3270 *rp;
+	struct raw3270_view *oldview, *nv;
+	unsigned long flags;
+	int rc;
+
+	rp = view->dev;
+	if (!rp)
+		return -ENODEV;
+	spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags);
+	if (rp->view == view)
+		rc = 0;
+	else if (test_bit(RAW3270_FLAGS_SHUTDOWN, &rp->flags))
+		rc = -ENODEV;
+	else {
+		oldview = 0;
+		if (rp->view) {
+			oldview = rp->view;
+			oldview->fn->deactivate(oldview);
+		}
+		rp->view = view;
+		rc = view->fn->activate(view);
+		if (rc) {
+			/* Didn't work. Try to reactivate the old view. */
+			rp->view = oldview;
+			if (oldview->fn->activate(oldview) != 0) {
+				/* Didn't work as well. Try any other view. */
+				list_for_each_entry(nv, &rp->view_list, list)
+					if (nv != view && nv != oldview) {
+						rp->view = nv;
+						if (nv->fn->activate(nv) == 0)
+							break;
+						rp->view = 0;
+					}
+			}
+		}
+	}
+	spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
+	return rc;
+}
+
+/*
+ * Deactivate current view.
+ */
+void
+raw3270_deactivate_view(struct raw3270_view *view)
+{
+	unsigned long flags;
+	struct raw3270 *rp;
+
+	rp = view->dev;
+	if (!rp)
+		return;
+	spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags);
+	if (rp->view == view) {
+		view->fn->deactivate(view);
+		rp->view = 0;
+		/* Move deactivated view to end of list. */
+		list_del_init(&view->list);
+		list_add_tail(&view->list, &rp->view_list);
+		/* Try to activate another view. */
+		if (!test_bit(RAW3270_FLAGS_SHUTDOWN, &rp->flags)) {
+			list_for_each_entry(view, &rp->view_list, list)
+				if (view->fn->activate(view) == 0) {
+					rp->view = view;
+					break;
+				}
+		}
+	}
+	spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
+}
+
+/*
+ * Add view to device with minor "minor".
+ */
+int
+raw3270_add_view(struct raw3270_view *view, struct raw3270_fn *fn, int minor)
+{
+	unsigned long flags;
+	struct raw3270 *rp;
+	int rc;
+
+	spin_lock(&raw3270_lock);
+	rc = -ENODEV;
+	list_for_each_entry(rp, &raw3270_devices, list) {
+		if (rp->minor != minor)
+			continue;
+		spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags);
+		if (!test_bit(RAW3270_FLAGS_SHUTDOWN, &rp->flags)) {
+			atomic_set(&view->ref_count, 2);
+			view->dev = rp;
+			view->fn = fn;
+			view->model = rp->model;
+			view->rows = rp->rows;
+			view->cols = rp->cols;
+			view->ascebc = rp->ascebc;
+			spin_lock_init(&view->lock);
+			list_add_tail(&view->list, &rp->view_list);
+			rc = 0;
+		}
+		spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
+		break;
+	}
+	spin_unlock(&raw3270_lock);
+	return rc;
+}
+
+/*
+ * Find specific view of device with minor "minor".
+ */
+struct raw3270_view *
+raw3270_find_view(struct raw3270_fn *fn, int minor)
+{
+	struct raw3270 *rp;
+	struct raw3270_view *view, *tmp;
+	unsigned long flags;
+
+	spin_lock(&raw3270_lock);
+	view = ERR_PTR(-ENODEV);
+	list_for_each_entry(rp, &raw3270_devices, list) {
+		if (rp->minor != minor)
+			continue;
+		spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags);
+		if (!test_bit(RAW3270_FLAGS_SHUTDOWN, &rp->flags)) {
+			list_for_each_entry(tmp, &rp->view_list, list) {
+				if (tmp->fn == fn) {
+					raw3270_get_view(tmp);
+					view = tmp;
+				}
+			}
+		} else
+			view = ERR_PTR(-ENOENT);
+		spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
+		break;
+	}
+	spin_unlock(&raw3270_lock);
+	return view;
+}
+
+/*
+ * Remove view from device and free view structure via call to view->fn->free.
+ */
+void
+raw3270_del_view(struct raw3270_view *view)
+{
+	unsigned long flags;
+	struct raw3270 *rp;
+
+	rp = view->dev;
+	spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags);
+	if (rp->view == view) {
+		view->fn->deactivate(view);
+		rp->view = 0;
+	}
+	list_del_init(&view->list);
+	if (!rp->view && !test_bit(RAW3270_FLAGS_SHUTDOWN, &rp->flags)) {
+		/* Try to activate another view. */
+		list_for_each_entry(view, &rp->view_list, list)
+			if (view->fn->activate(view) == 0) {
+				rp->view = view;
+				break;
+			}
+	}
+	spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags);
+	/* Wait for reference counter to drop to zero. */
+	atomic_dec(&view->ref_count);
+	wait_event(raw3270_wait_queue, atomic_read(&view->ref_count) == 0);
+	if (view->fn->free)
+		view->fn->free(view);
+}
+
+/*
+ * Remove a 3270 device structure.
+ */
+static void
+raw3270_delete_device(struct raw3270 *rp)
+{
+	struct ccw_device *cdev;
+
+	/* Remove from device chain. */
+	spin_lock(&raw3270_lock);
+	list_del_init(&rp->list);
+	spin_unlock(&raw3270_lock);
+
+	/* Disconnect from ccw_device. */
+	cdev = rp->cdev;
+	rp->cdev = 0;
+	cdev->dev.driver_data = 0;
+	cdev->handler = 0;
+
+	/* Put ccw_device structure. */
+	put_device(&cdev->dev);
+
+	/* Now free raw3270 structure. */
+	kfree(rp->ascebc);
+	kfree(rp);
+}
+
+static int
+raw3270_probe (struct ccw_device *cdev)
+{
+	return 0;
+}
+
+/*
+ * Additional attributes for a 3270 device
+ */
+static ssize_t
+raw3270_model_show(struct device *dev, char *buf)
+{
+	return snprintf(buf, PAGE_SIZE, "%i\n",
+			((struct raw3270 *) dev->driver_data)->model);
+}
+static DEVICE_ATTR(model, 0444, raw3270_model_show, 0);
+
+static ssize_t
+raw3270_rows_show(struct device *dev, char *buf)
+{
+	return snprintf(buf, PAGE_SIZE, "%i\n",
+			((struct raw3270 *) dev->driver_data)->rows);
+}
+static DEVICE_ATTR(rows, 0444, raw3270_rows_show, 0);
+
+static ssize_t
+raw3270_columns_show(struct device *dev, char *buf)
+{
+	return snprintf(buf, PAGE_SIZE, "%i\n",
+			((struct raw3270 *) dev->driver_data)->cols);
+}
+static DEVICE_ATTR(columns, 0444, raw3270_columns_show, 0);
+
+static struct attribute * raw3270_attrs[] = {
+	&dev_attr_model.attr,
+	&dev_attr_rows.attr,
+	&dev_attr_columns.attr,
+	NULL,
+};
+
+static struct attribute_group raw3270_attr_group = {
+	.attrs = raw3270_attrs,
+};
+
+static void
+raw3270_create_attributes(struct raw3270 *rp)
+{
+	//FIXME: check return code
+	sysfs_create_group(&rp->cdev->dev.kobj, &raw3270_attr_group);
+}
+
+/* Hackish. A notifier chain would be cleaner. */
+extern void tty3270_notifier(int index, int active);
+
+/*
+ * Set 3270 device online.
+ */
+static int
+raw3270_set_online (struct ccw_device *cdev)
+{
+	struct raw3270 *rp;
+
+	rp = raw3270_create_device(cdev);
+	if (IS_ERR(rp))
+		return PTR_ERR(rp);
+	raw3270_reset_device(rp);
+	raw3270_size_device(rp);
+	raw3270_reset_device(rp);
+	raw3270_create_attributes(rp);
+	tty3270_notifier(rp->minor, 1);
+	return 0;
+}
+
+/*
+ * Remove 3270 device structure.
+ */
+static void
+raw3270_remove (struct ccw_device *cdev)
+{
+	unsigned long flags;
+	struct raw3270 *rp;
+	struct raw3270_view *v;
+
+	rp = cdev->dev.driver_data;
+	set_bit(RAW3270_FLAGS_SHUTDOWN, &rp->flags);
+
+	sysfs_remove_group(&cdev->dev.kobj, &raw3270_attr_group);
+
+	/* Deactivate current view and remove all views. */
+	spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
+	if (rp->view) {
+		rp->view->fn->deactivate(rp->view);
+		rp->view = 0;
+	}
+	while (!list_empty(&rp->view_list)) {
+		v = list_entry(rp->view_list.next, struct raw3270_view, list);
+		if (v->fn->release)
+			v->fn->release(v);
+		spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
+		raw3270_del_view(v);
+		spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
+	}
+	spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
+
+	tty3270_notifier(rp->minor, 0);
+
+	/* Reset 3270 device. */
+	raw3270_reset_device(rp);
+	/* And finally remove it. */
+	raw3270_delete_device(rp);
+}
+
+/*
+ * Set 3270 device offline.
+ */
+static int
+raw3270_set_offline (struct ccw_device *cdev)
+{
+	struct raw3270 *rp;
+
+	rp = cdev->dev.driver_data;
+	if (test_bit(RAW3270_FLAGS_CONSOLE, &rp->flags))
+		return -EBUSY;
+	raw3270_remove(cdev);
+	return 0;
+}
+
+static struct ccw_device_id raw3270_id[] = {
+	{ CCW_DEVICE(0x3270, 0) },
+	{ CCW_DEVICE(0x3271, 0) },
+	{ CCW_DEVICE(0x3272, 0) },
+	{ CCW_DEVICE(0x3273, 0) },
+	{ CCW_DEVICE(0x3274, 0) },
+	{ CCW_DEVICE(0x3275, 0) },
+	{ CCW_DEVICE(0x3276, 0) },
+	{ CCW_DEVICE(0x3277, 0) },
+	{ CCW_DEVICE(0x3278, 0) },
+	{ CCW_DEVICE(0x3279, 0) },
+	{ CCW_DEVICE(0x3174, 0) },
+	{ /* end of list */ },
+};
+
+static struct ccw_driver raw3270_ccw_driver = {
+	.name		= "3270",
+	.owner		= THIS_MODULE,
+	.ids		= raw3270_id,
+	.probe		= &raw3270_probe,
+	.remove		= &raw3270_remove,
+	.set_online	= &raw3270_set_online,
+	.set_offline	= &raw3270_set_offline,
+};
+
+int
+raw3270_init(void)
+{
+	struct raw3270 *rp;
+	int rc;
+
+	if (raw3270_registered)
+		return 0;
+	raw3270_registered = 1;
+	rc = ccw_driver_register(&raw3270_ccw_driver);
+	if (rc == 0) {
+		/* Create attributes for early (= console) device. */
+		spin_lock(&raw3270_lock);
+		list_for_each_entry(rp, &raw3270_devices, list) {
+			get_device(&rp->cdev->dev);
+			raw3270_create_attributes(rp);
+			tty3270_notifier(rp->minor, 1);
+		}
+		spin_unlock(&raw3270_lock);
+	}
+	return rc;
+}
+
+void
+raw3270_exit(void)
+{
+	ccw_driver_unregister(&raw3270_ccw_driver);
+}
+
+MODULE_LICENSE("GPL");
+
+EXPORT_SYMBOL(raw3270_init);
+EXPORT_SYMBOL(raw3270_exit);
+EXPORT_SYMBOL(raw3270_request_alloc);
+EXPORT_SYMBOL(raw3270_request_free);
+EXPORT_SYMBOL(raw3270_request_reset);
+EXPORT_SYMBOL(raw3270_request_set_cmd);
+EXPORT_SYMBOL(raw3270_request_add_data);
+EXPORT_SYMBOL(raw3270_request_set_data);
+EXPORT_SYMBOL(raw3270_request_set_idal);
+EXPORT_SYMBOL(raw3270_buffer_address);
+EXPORT_SYMBOL(raw3270_add_view);
+EXPORT_SYMBOL(raw3270_del_view);
+EXPORT_SYMBOL(raw3270_find_view);
+EXPORT_SYMBOL(raw3270_activate_view);
+EXPORT_SYMBOL(raw3270_deactivate_view);
+EXPORT_SYMBOL(raw3270_start);
+EXPORT_SYMBOL(raw3270_start_irq);
diff -puN /dev/null drivers/s390/char/raw3270.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/s390/char/raw3270.h	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,273 @@
+/*
+ *  drivers/s390/char/raw3270.h
+ *    IBM/3270 Driver
+ *
+ *  Author(s):
+ *    Original 3270 Code for 2.4 written by Richard Hitt (UTS Global)
+ *    Rewritten for 2.5 by Martin Schwidefsky <schwidefsky@de.ibm.com>
+ *	-- Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ */
+
+#include <asm/idals.h>
+#include <asm/ioctl.h>
+
+/* ioctls for fullscreen 3270 */
+#define TUBICMD		_IO('3', 3)	/* set ccw command for fs reads. */
+#define TUBOCMD		_IO('3', 4)	/* set ccw command for fs writes. */
+#define TUBGETI		_IO('3', 7)	/* get ccw command for fs reads. */
+#define TUBGETO		_IO('3', 8)	/* get ccw command for fs writes. */
+#define TUBSETMOD	_IO('3',12)	/* FIXME: what does it do ?*/
+#define TUBGETMOD	_IO('3',13)	/* FIXME: what does it do ?*/
+
+/* Local Channel Commands */
+#define TC_WRITE	0x01		/* Write */
+#define TC_EWRITE	0x05		/* Erase write */
+#define TC_READMOD	0x06		/* Read modified */
+#define TC_EWRITEA	0x0d		/* Erase write alternate */
+#define TC_WRITESF	0x11		/* Write structured field */
+
+/* Buffer Control Orders */
+#define TO_SF		0x1d		/* Start field */
+#define TO_SBA		0x11		/* Set buffer address */
+#define TO_IC		0x13		/* Insert cursor */
+#define TO_PT		0x05		/* Program tab */
+#define TO_RA		0x3c		/* Repeat to address */
+#define TO_SFE		0x29		/* Start field extended */
+#define TO_EUA		0x12		/* Erase unprotected to address */
+#define TO_MF		0x2c		/* Modify field */
+#define TO_SA		0x28		/* Set attribute */
+
+/* Field Attribute Bytes */
+#define TF_INPUT	0x40		/* Visible input */
+#define TF_INPUTN	0x4c		/* Invisible input */
+#define TF_INMDT	0xc1		/* Visible, Set-MDT */
+#define TF_LOG		0x60
+
+/* Character Attribute Bytes */
+#define TAT_RESET	0x00
+#define TAT_FIELD	0xc0
+#define TAT_EXTHI	0x41
+#define TAT_COLOR	0x42
+#define TAT_CHARS	0x43
+#define TAT_TRANS	0x46
+
+/* Extended-Highlighting Bytes */
+#define TAX_RESET	0x00
+#define TAX_BLINK	0xf1
+#define TAX_REVER	0xf2
+#define TAX_UNDER	0xf4
+
+/* Reset value */
+#define TAR_RESET	0x00
+
+/* Color values */
+#define TAC_RESET	0x00
+#define TAC_BLUE	0xf1
+#define TAC_RED		0xf2
+#define TAC_PINK	0xf3
+#define TAC_GREEN	0xf4
+#define TAC_TURQ	0xf5
+#define TAC_YELLOW	0xf6
+#define TAC_WHITE	0xf7
+#define TAC_DEFAULT	0x00
+
+/* Write Control Characters */
+#define TW_NONE		0x40		/* No particular action */
+#define TW_KR		0xc2		/* Keyboard restore */
+#define TW_PLUSALARM	0x04		/* Add this bit for alarm */
+
+#define RAW3270_MAXDEVS	256
+
+int raw3270_init(void);
+void raw3270_exit(void);
+
+/* For TUBGETMOD and TUBSETMOD. Should include. */
+struct raw3270_iocb {
+	short model;
+	short line_cnt;
+	short col_cnt;
+	short pf_cnt;
+	short re_cnt;
+	short map;
+};
+
+struct raw3270;
+struct raw3270_view;
+
+/* 3270 CCW request */
+struct raw3270_request {
+	struct list_head list;		/* list head for request queueing. */
+	struct raw3270_view *view;	/* view of this request */
+	struct ccw1 ccw;		/* single ccw. */
+	void *buffer;			/* output buffer. */
+	size_t size;			/* size of output buffer. */
+	int rescnt;			/* residual count from devstat. */
+	int rc;				/* return code for this request. */
+
+	/* Callback for delivering final status. */
+	void (*callback)(struct raw3270_request *, void *);
+	void *callback_data;
+};
+
+struct raw3270_request *raw3270_request_alloc(size_t size);
+struct raw3270_request *raw3270_request_alloc_bootmem(size_t size);
+void raw3270_request_free(struct raw3270_request *);
+void raw3270_request_reset(struct raw3270_request *);
+void raw3270_request_set_cmd(struct raw3270_request *, u8 cmd);
+int  raw3270_request_add_data(struct raw3270_request *, void *, size_t);
+void raw3270_request_set_data(struct raw3270_request *, void *, size_t);
+void raw3270_request_set_idal(struct raw3270_request *, struct idal_buffer *);
+
+static inline int
+raw3270_request_final(struct raw3270_request *rq)
+{
+	return list_empty(&rq->list);
+}
+
+void raw3270_buffer_address(struct raw3270 *, char *, unsigned short);
+
+/* Return value of *intv (see raw3270_fn below) can be one of the following: */
+#define RAW3270_IO_DONE		0	/* request finished */
+#define RAW3270_IO_BUSY		1	/* request still active */
+#define RAW3270_IO_RETRY	2	/* retry current request */
+#define RAW3270_IO_STOP		3	/* kill current request */
+
+/*
+ * Functions of a 3270 view.
+ */
+struct raw3270_fn {
+	int  (*activate)(struct raw3270_view *);
+	void (*deactivate)(struct raw3270_view *);
+	int  (*intv)(struct raw3270_view *,
+		     struct raw3270_request *, struct irb *);
+	void (*release)(struct raw3270_view *);
+	void (*free)(struct raw3270_view *);
+};
+
+/*
+ * View structure chaining. The raw3270_view structure is meant to
+ * be embedded at the start of the real view data structure, e.g.:
+ *   struct example {
+ *     struct raw3270_view view;
+ *     ...
+ *   };
+ */
+struct raw3270_view {
+	struct list_head list;
+	spinlock_t lock;
+	atomic_t ref_count;
+	struct raw3270 *dev;
+	struct raw3270_fn *fn;
+	unsigned int model;
+	unsigned int rows, cols;	/* # of rows & colums of the view */
+	unsigned char *ascebc;		/* ascii -> ebcdic table */
+};
+
+int raw3270_add_view(struct raw3270_view *, struct raw3270_fn *, int);
+int raw3270_activate_view(struct raw3270_view *);
+void raw3270_del_view(struct raw3270_view *);
+void raw3270_deactivate_view(struct raw3270_view *);
+struct raw3270_view *raw3270_find_view(struct raw3270_fn *, int);
+int raw3270_start(struct raw3270_view *, struct raw3270_request *);
+int raw3270_start_irq(struct raw3270_view *, struct raw3270_request *);
+
+/* Reference count inliner for view structures. */
+static inline void
+raw3270_get_view(struct raw3270_view *view)
+{
+	atomic_inc(&view->ref_count);
+}
+
+extern wait_queue_head_t raw3270_wait_queue;
+
+static inline void
+raw3270_put_view(struct raw3270_view *view)
+{
+	if (atomic_dec_return(&view->ref_count) == 0)
+		wake_up(&raw3270_wait_queue);
+}
+
+struct raw3270 *raw3270_setup_console(struct ccw_device *cdev);
+void raw3270_wait_cons_dev(struct raw3270 *);
+
+/*
+ * Little memory allocator for string objects. 
+ */
+struct string
+{
+	struct list_head list;
+	struct list_head update;
+	unsigned long size;
+	unsigned long len;
+	char string[0];
+} __attribute__ ((aligned(8)));
+
+static inline struct string *
+alloc_string(struct list_head *free_list, unsigned long len)
+{
+	struct string *cs, *tmp;
+	unsigned long size;
+
+	size = (len + 7L) & -8L;
+	list_for_each_entry(cs, free_list, list) {
+		if (cs->size < size)
+			continue;
+		if (cs->size > size + sizeof(struct string)) {
+			char *endaddr = (char *) (cs + 1) + cs->size;
+			tmp = (struct string *) (endaddr - size) - 1;
+			tmp->size = size;
+			cs->size -= size + sizeof(struct string);
+			cs = tmp;
+		} else
+			list_del(&cs->list);
+		cs->len = len;
+		INIT_LIST_HEAD(&cs->list);
+		INIT_LIST_HEAD(&cs->update);
+		return cs;
+	}
+	return 0;
+}
+
+static inline unsigned long
+free_string(struct list_head *free_list, struct string *cs)
+{
+	struct string *tmp;
+	struct list_head *p, *left;
+
+	/* Find out the left neighbour in free memory list. */
+	left = free_list;
+	list_for_each(p, free_list) {
+		if (list_entry(p, struct string, list) > cs)
+			break;
+		left = p;
+	}
+	/* Try to merge with right neighbour = next element from left. */
+	if (left->next != free_list) {
+		tmp = list_entry(left->next, struct string, list);
+		if ((char *) (cs + 1) + cs->size == (char *) tmp) {
+			list_del(&tmp->list);
+			cs->size += tmp->size + sizeof(struct string);
+		}
+	}
+	/* Try to merge with left neighbour. */
+	if (left != free_list) {
+		tmp = list_entry(left, struct string, list);
+		if ((char *) (tmp + 1) + tmp->size == (char *) cs) {
+			tmp->size += cs->size + sizeof(struct string);
+			return tmp->size;
+		}
+	}
+	__list_add(&cs->list, left, left->next);
+	return cs->size;
+}
+
+static inline void
+add_string_memory(struct list_head *free_list, void *mem, unsigned long size)
+{
+	struct string *cs;
+
+	cs = (struct string *) mem;
+	cs->size = size - sizeof(struct string);
+	free_string(free_list, cs);
+}
+
diff -puN drivers/s390/char/sclp_con.c~linus drivers/s390/char/sclp_con.c
--- 25/drivers/s390/char/sclp_con.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/char/sclp_con.c	2004-01-19 22:17:23.000000000 -0800
@@ -134,8 +134,8 @@ sclp_console_write(struct console *conso
 		}
 		/* try to write the string to the current output buffer */
 		written = sclp_write(sclp_conbuf, (const unsigned char *)
-				     message, count, 0);
-		if (written == -EFAULT || written == count)
+				     message, count);
+		if (written == count)
 			break;
 		/*
 		 * Not all characters could be written to the current
diff -puN drivers/s390/char/sclp_rw.c~linus drivers/s390/char/sclp_rw.c
--- 25/drivers/s390/char/sclp_rw.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/char/sclp_rw.c	2004-01-19 22:17:23.000000000 -0800
@@ -175,11 +175,9 @@ sclp_finalize_mto(struct sclp_buffer *bu
  *  is not busy)
  */
 int
-sclp_write(struct sclp_buffer *buffer,
-	   const unsigned char *msg, int count, int from_user)
+sclp_write(struct sclp_buffer *buffer, const unsigned char *msg, int count)
 {
 	int spaces, i_msg;
-	char ch;
 	int rc;
 
 	/*
@@ -206,13 +204,7 @@ sclp_write(struct sclp_buffer *buffer,
 	 * This is in order to a slim and quick implementation.
 	 */
 	for (i_msg = 0; i_msg < count; i_msg++) {
-		if (from_user) {
-			if (get_user(ch, msg + i_msg) != 0)
-				return -EFAULT;
-		} else
-			ch = msg[i_msg];
-
-		switch (ch) {
+		switch (msg[i_msg]) {
 		case '\n':	/* new line, line feed (ASCII)	*/
 			/* check if new mto needs to be created */
 			if (buffer->current_line == NULL) {
@@ -286,7 +278,7 @@ sclp_write(struct sclp_buffer *buffer,
 			break;
 		default:	/* no escape character	*/
 			/* do not output unprintable characters */
-			if (!isprint(ch))
+			if (!isprint(msg[i_msg]))
 				break;
 			/* check if new mto needs to be created */
 			if (buffer->current_line == NULL) {
@@ -295,7 +287,7 @@ sclp_write(struct sclp_buffer *buffer,
 				if (rc)
 					return i_msg;
 			}
-			*buffer->current_line++ = sclp_ascebc(ch);
+			*buffer->current_line++ = sclp_ascebc(msg[i_msg]);
 			buffer->current_length++;
 			break;
 		}
diff -puN drivers/s390/char/sclp_rw.h~linus drivers/s390/char/sclp_rw.h
--- 25/drivers/s390/char/sclp_rw.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/char/sclp_rw.h	2004-01-19 22:17:23.000000000 -0800
@@ -89,7 +89,7 @@ int sclp_rw_init(void);
 struct sclp_buffer *sclp_make_buffer(void *, unsigned short, unsigned short);
 void *sclp_unmake_buffer(struct sclp_buffer *);
 int sclp_buffer_space(struct sclp_buffer *);
-int sclp_write(struct sclp_buffer *buffer, const unsigned char *, int, int);
+int sclp_write(struct sclp_buffer *buffer, const unsigned char *, int);
 void sclp_emit_buffer(struct sclp_buffer *,void (*)(struct sclp_buffer *,int));
 void sclp_set_columns(struct sclp_buffer *, unsigned short);
 void sclp_set_htab(struct sclp_buffer *, unsigned short);
diff -puN drivers/s390/char/sclp_tty.c~linus drivers/s390/char/sclp_tty.c
--- 25/drivers/s390/char/sclp_tty.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/char/sclp_tty.c	2004-01-19 22:17:23.000000000 -0800
@@ -322,7 +322,7 @@ sclp_tty_timeout(unsigned long data)
  * Write a string to the sclp tty.
  */
 static void
-sclp_tty_write_string(const unsigned char *str, int count, int from_user)
+sclp_tty_write_string(const unsigned char *str, int count)
 {
 	unsigned long flags;
 	void *page;
@@ -348,8 +348,8 @@ sclp_tty_write_string(const unsigned cha
 						       sclp_ioctls.htab);
 		}
 		/* try to write the string to the current output buffer */
-		written = sclp_write(sclp_ttybuf, str, count, from_user);
-		if (written == -EFAULT || written == count)
+		written = sclp_write(sclp_ttybuf, str, count);
+		if (written == count)
 			break;
 		/*
 		 * Not all characters could be written to the current
@@ -389,12 +389,32 @@ static int
 sclp_tty_write(struct tty_struct *tty, int from_user,
 	       const unsigned char *buf, int count)
 {
+	int length, ret;
+
 	if (sclp_tty_chars_count > 0) {
-		sclp_tty_write_string(sclp_tty_chars, sclp_tty_chars_count, 0);
+		sclp_tty_write_string(sclp_tty_chars, sclp_tty_chars_count);
 		sclp_tty_chars_count = 0;
 	}
-	sclp_tty_write_string(buf, count, from_user);
-	return count;
+	if (!from_user) {
+		sclp_tty_write_string(buf, count);
+		return count;
+	}
+	ret = 0;
+	while (count > 0) {
+		length = count < SCLP_TTY_BUF_SIZE ?
+			count : SCLP_TTY_BUF_SIZE;
+		length -= copy_from_user(sclp_tty_chars, buf, length);
+		if (length == 0) {
+			if (!ret)
+				ret = -EFAULT;
+			break;
+		}
+		sclp_tty_write_string(sclp_tty_chars, length);
+		buf += length;
+		count -= length;
+		ret += length;
+	}
+	return ret;
 }
 
 /*
@@ -412,7 +432,7 @@ sclp_tty_put_char(struct tty_struct *tty
 {
 	sclp_tty_chars[sclp_tty_chars_count++] = ch;
 	if (ch == '\n' || sclp_tty_chars_count >= SCLP_TTY_BUF_SIZE) {
-		sclp_tty_write_string(sclp_tty_chars, sclp_tty_chars_count, 0);
+		sclp_tty_write_string(sclp_tty_chars, sclp_tty_chars_count);
 		sclp_tty_chars_count = 0;
 	}
 }
@@ -425,7 +445,7 @@ static void
 sclp_tty_flush_chars(struct tty_struct *tty)
 {
 	if (sclp_tty_chars_count > 0) {
-		sclp_tty_write_string(sclp_tty_chars, sclp_tty_chars_count, 0);
+		sclp_tty_write_string(sclp_tty_chars, sclp_tty_chars_count);
 		sclp_tty_chars_count = 0;
 	}
 }
@@ -464,7 +484,7 @@ static void
 sclp_tty_flush_buffer(struct tty_struct *tty)
 {
 	if (sclp_tty_chars_count > 0) {
-		sclp_tty_write_string(sclp_tty_chars, sclp_tty_chars_count, 0);
+		sclp_tty_write_string(sclp_tty_chars, sclp_tty_chars_count);
 		sclp_tty_chars_count = 0;
 	}
 }
diff -puN drivers/s390/char/tape_34xx.c~linus drivers/s390/char/tape_34xx.c
--- 25/drivers/s390/char/tape_34xx.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/char/tape_34xx.c	2004-01-19 22:17:23.000000000 -0800
@@ -14,31 +14,60 @@
 #include <linux/init.h>
 #include <linux/bio.h>
 #include <linux/workqueue.h>
-#include <asm/tape390.h>
 
 #include "tape.h"
 #include "tape_std.h"
 
-#define PRINTK_HEADER "T34xx:"
+#define PRINTK_HEADER "TAPE_34XX: "
 
-enum tape34xx_type {
+enum tape_34xx_type {
 	tape_3480,
 	tape_3490,
 };
 
+#define TAPE34XX_FMT_3480	0
+#define TAPE34XX_FMT_3480_2_XF	1
+#define TAPE34XX_FMT_3480_XF	2
+
+struct tape_34xx_block_id {
+	unsigned int	wrap		: 1;
+	unsigned int	segment		: 7;
+	unsigned int	format		: 2;
+	unsigned int	block		: 22;
+};
+
 /*
- * Medium sense (asynchronous with callback) for 34xx tapes. There is no 'real'
- * medium sense call. So we just do a normal sense.
+ * A list of block ID's is used to faster seek blocks.
  */
-static void
-__tape_34xx_medium_sense_callback(struct tape_request *request, void *data)
+struct tape_34xx_sbid {
+	struct list_head		list;
+	struct tape_34xx_block_id	bid;
+};
+
+static void tape_34xx_delete_sbid_from(struct tape_device *, int);
+
+/*
+ * Medium sense for 34xx tapes. There is no 'real' medium sense call.
+ * So we just do a normal sense.
+ */
+static int
+tape_34xx_medium_sense(struct tape_device *device)
 {
-	unsigned char      *sense;
-	struct tape_device *device;
+	struct tape_request *request;
+	unsigned char       *sense;
+	int                  rc;
 
-	request->callback = NULL;
+	request = tape_alloc_request(1, 32);
+	if (IS_ERR(request)) {
+		DBF_EXCEPTION(6, "MSEN fail\n");
+		return PTR_ERR(request);
+	}
 
-	if(request->rc == 0 && (device = request->device) != NULL) {
+	request->op = TO_MSEN;
+	tape_ccw_end(request->cpaddr, SENSE, 32, request->cpdata);
+
+	rc = tape_do_io_interruptible(device, request);
+	if (request->rc == 0) {
 		sense = request->cpdata;
 
 		/*
@@ -47,36 +76,20 @@ __tape_34xx_medium_sense_callback(struct
 		 * only slightly inaccurate to say there is no tape loaded if
 		 * the drive isn't online...
 		 */
-		if(sense[0] & SENSE_INTERVENTION_REQUIRED)
+		if (sense[0] & SENSE_INTERVENTION_REQUIRED)
 			tape_med_state_set(device, MS_UNLOADED);
 		else
 			tape_med_state_set(device, MS_LOADED);
 
-		if(sense[1] & SENSE_WRITE_PROTECT)
+		if (sense[1] & SENSE_WRITE_PROTECT)
 			device->tape_generic_status |= GMT_WR_PROT(~0);
 		else
 			device->tape_generic_status &= ~GMT_WR_PROT(~0);
+	} else {
+		DBF_EVENT(4, "tape_34xx: medium sense failed with rc=%d\n",
+			request->rc);
 	}
 	tape_free_request(request);
-}
-
-static int
-tape_34xx_medium_sense(struct tape_device *device)
-{
-	struct tape_request *request;
-	int                  rc;
-
-	request = tape_alloc_request(1, 32);
-	if(IS_ERR(request)) {
-		DBF_EXCEPTION(6, "MSEN fail\n");
-		return PTR_ERR(request);
-	}
-
-	request->op = TO_MSEN;
-	tape_ccw_end(request->cpaddr, SENSE, 32, request->cpdata);
-	request->callback = __tape_34xx_medium_sense_callback;
-
-	rc = tape_do_io_async(device, request);
 
 	return rc;
 }
@@ -104,7 +117,7 @@ tape_34xx_work_handler(void *data)
 			DBF_EVENT(3, "T34XX: internal error: unknown work\n");
 	}
 
-	tape_put_device(p->device);
+	p->device = tape_put_device(p->device);
 	kfree(p);
 }
 
@@ -117,14 +130,13 @@ tape_34xx_schedule_work(struct tape_devi
 		struct work_struct	 work;
 	} *p;
 
-	if((p = kmalloc(sizeof(*p), GFP_ATOMIC)) == NULL)
+	if ((p = kmalloc(sizeof(*p), GFP_ATOMIC)) == NULL)
 		return -ENOMEM;
 
 	memset(p, 0, sizeof(*p));
 	INIT_WORK(&p->work, tape_34xx_work_handler, p);
 
-	atomic_inc(&device->ref_count);
-	p->device = device;
+	p->device = tape_get_device_reference(device);
 	p->op     = op;
 
 	schedule_work(&p->work);
@@ -134,37 +146,46 @@ tape_34xx_schedule_work(struct tape_devi
 /*
  * Done Handler is called when dev stat = DEVICE-END (successful operation)
  */
-static int
-tape_34xx_done(struct tape_device *device, struct tape_request *request)
+static inline int
+tape_34xx_done(struct tape_request *request)
 {
 	DBF_EVENT(6, "%s done\n", tape_op_verbose[request->op]);
 
+	switch (request->op) {
+		case TO_DSE:
+		case TO_RUN:
+		case TO_WRI:
+		case TO_WTM:
+		case TO_ASSIGN:
+		case TO_UNASSIGN:
+			tape_34xx_delete_sbid_from(request->device, 0);
+			break;
+		default:
+			;
+	}
 	return TAPE_IO_SUCCESS;
 }
 
 static inline int
-tape_34xx_erp_failed(struct tape_device *device,
-		     struct tape_request *request, int rc)
+tape_34xx_erp_failed(struct tape_request *request, int rc)
 {
-	DBF_EVENT(3, "Error recovery failed for %s\n",
-		  tape_op_verbose[request->op]);
+	DBF_EVENT(3, "Error recovery failed for %s (RC=%d)\n",
+		  tape_op_verbose[request->op], rc);
 	return rc;
 }
 
 static inline int
-tape_34xx_erp_succeeded(struct tape_device *device,
-		       struct tape_request *request)
+tape_34xx_erp_succeeded(struct tape_request *request)
 {
 	DBF_EVENT(3, "Error Recovery successful for %s\n",
 		  tape_op_verbose[request->op]);
-	return tape_34xx_done(device, request);
+	return tape_34xx_done(request);
 }
 
 static inline int
-tape_34xx_erp_retry(struct tape_device *device, struct tape_request *request)
+tape_34xx_erp_retry(struct tape_request *request)
 {
-	DBF_EVENT(3, "xerp retr %s\n",
-		  tape_op_verbose[request->op]);
+	DBF_EVENT(3, "xerp retr %s\n", tape_op_verbose[request->op]);
 	return TAPE_IO_RETRY;
 }
 
@@ -178,6 +199,7 @@ tape_34xx_unsolicited_irq(struct tape_de
 	if (irb->scsw.dstat == 0x85 /* READY */) {
 		/* A medium was inserted in the drive. */
 		DBF_EVENT(6, "xuud med\n");
+		tape_34xx_delete_sbid_from(device, 0);
 		tape_34xx_schedule_work(device, TO_MSEN);
 	} else {
 		DBF_EVENT(3, "unsol.irq! dev end: %s\n",
@@ -203,7 +225,7 @@ tape_34xx_erp_read_opposite(struct tape_
 		 * and try again.
 		 */
 		tape_std_read_backward(device, request);
-		return tape_34xx_erp_retry(device, request);
+		return tape_34xx_erp_retry(request);
 	}
 	if (request->op != TO_RBA)
 		PRINT_ERR("read_opposite called with state:%s\n",
@@ -212,7 +234,7 @@ tape_34xx_erp_read_opposite(struct tape_
 	 * We tried to read forward and backward, but hat no
 	 * success -> failed.
 	 */
-	return tape_34xx_erp_failed(device, request, -EIO);
+	return tape_34xx_erp_failed(request, -EIO);
 }
 
 static int
@@ -228,7 +250,7 @@ tape_34xx_erp_bug(struct tape_device *de
 				   tape_op_verbose[request->op]);
 		tape_dump_sense(device, request, irb);
 	}
-	return tape_34xx_erp_failed(device, request, -EIO);
+	return tape_34xx_erp_failed(request, -EIO);
 }
 
 /*
@@ -243,7 +265,7 @@ tape_34xx_erp_overrun(struct tape_device
 		PRINT_WARN ("Data overrun error between control-unit "
 			    "and drive. Use a faster channel connection, "
 			    "if possible! \n");
-		return tape_34xx_erp_failed(device, request, -EIO);
+		return tape_34xx_erp_failed(request, -EIO);
 	}
 	return tape_34xx_erp_bug(device, request, irb, -1);
 }
@@ -260,7 +282,7 @@ tape_34xx_erp_sequence(struct tape_devic
 		 * cu detected incorrect block-id sequence on tape.
 		 */
 		PRINT_WARN("Illegal block-id sequence found!\n");
-		return tape_34xx_erp_failed(device, request, -EIO);
+		return tape_34xx_erp_failed(request, -EIO);
 	}
 	/*
 	 * Record sequence error bit is set, but erpa does not
@@ -281,6 +303,9 @@ tape_34xx_unit_check(struct tape_device 
 	int inhibit_cu_recovery;
 	__u8* sense;
 
+	inhibit_cu_recovery = (*device->modeset_byte & 0x80) ? 1 : 0;
+	sense = irb->ecw;
+
 #ifdef CONFIG_S390_TAPE_BLOCK
 	if (request->op == TO_BLOCK) {
 		/*
@@ -289,51 +314,95 @@ tape_34xx_unit_check(struct tape_device 
 		 */
 		device->blk_data.block_position = -1;
 		if (request->retries-- <= 0)
-			return tape_34xx_erp_failed(device, request, -EIO);
+			return tape_34xx_erp_failed(request, -EIO);
 		else
-			return tape_34xx_erp_retry(device, request);
+			return tape_34xx_erp_retry(request);
 	}
 #endif
 
-	inhibit_cu_recovery = (*device->modeset_byte & 0x80) ? 1 : 0;
-	sense = irb->ecw;
-
-	if (sense[0] & SENSE_COMMAND_REJECT) {
-		if ((sense[1] & SENSE_WRITE_PROTECT) &&
-		    (request->op == TO_DSE ||
-		     request->op == TO_WRI ||
-		     request->op == TO_WTM))
+	if (
+		sense[0] & SENSE_COMMAND_REJECT &&
+		sense[1] & SENSE_WRITE_PROTECT
+	) {
+		if (
+			request->op == TO_DSE ||
+			request->op == TO_WRI ||
+			request->op == TO_WTM
+		) {
 			/* medium is write protected */
-			return tape_34xx_erp_failed(device, request, -EACCES);
-		else
+			return tape_34xx_erp_failed(request, -EACCES);
+		} else {
 			return tape_34xx_erp_bug(device, request, irb, -3);
+		}
 	}
 
 	/*
-	 * special cases for various tape-states when reaching
+	 * Special cases for various tape-states when reaching
 	 * end of recorded area
+	 *
+	 * FIXME: Maybe a special case of the special case:
+	 *        sense[0] == SENSE_EQUIPMENT_CHECK &&
+	 *        sense[1] == SENSE_DRIVE_ONLINE    &&
+	 *        sense[3] == 0x47 (Volume Fenced)
+	 *
+	 *        This was caused by continued FSF or FSR after an
+	 *        'End Of Data'.
 	 */
-	if ((sense[0] == 0x08 || sense[0] == 0x10 || sense[0] == 0x12) &&
-	    (sense[1] == 0x40 || sense[1] == 0x0c))
+	if ((
+		sense[0] == SENSE_DATA_CHECK      ||
+		sense[0] == SENSE_EQUIPMENT_CHECK ||
+		sense[0] == SENSE_EQUIPMENT_CHECK + SENSE_DEFERRED_UNIT_CHECK
+	) && (
+		sense[1] == SENSE_DRIVE_ONLINE ||
+		sense[1] == SENSE_BEGINNING_OF_TAPE + SENSE_WRITE_MODE
+	)) {
 		switch (request->op) {
+		/*
+		 * sense[0] == SENSE_DATA_CHECK   &&
+		 * sense[1] == SENSE_DRIVE_ONLINE
+		 * sense[3] == 0x36 (End Of Data)
+		 *
+		 * Further seeks might return a 'Volume Fenced'.
+		 */
 		case TO_FSF:
+		case TO_FSB:
 			/* Trying to seek beyond end of recorded area */
-			return tape_34xx_erp_failed(device, request, -ENOSPC);
+			return tape_34xx_erp_failed(request, -ENOSPC);
+		case TO_BSB:
+			return tape_34xx_erp_retry(request);
+
+		/*
+		 * sense[0] == SENSE_DATA_CHECK   &&
+		 * sense[1] == SENSE_DRIVE_ONLINE &&
+		 * sense[3] == 0x36 (End Of Data)
+		 */
 		case TO_LBL:
 			/* Block could not be located. */
-			return tape_34xx_erp_failed(device, request, -EIO);
+			tape_34xx_delete_sbid_from(device, 0);
+			return tape_34xx_erp_failed(request, -EIO);
+
 		case TO_RFO:
 			/* Read beyond end of recorded area -> 0 bytes read */
-			return tape_34xx_erp_failed(device, request, 0);
+			return tape_34xx_erp_failed(request, 0);
+
+		/*
+		 * sense[0] == SENSE_EQUIPMENT_CHECK &&
+		 * sense[1] == SENSE_DRIVE_ONLINE    &&
+		 * sense[3] == 0x38 (Physical End Of Volume)
+		 */
+		case TO_WRI:
+			/* Writing at physical end of volume */
+			return tape_34xx_erp_failed(request, -ENOSPC);
 		default:
 			PRINT_ERR("Invalid op in %s:%i\n",
 				  __FUNCTION__, __LINE__);
-			return tape_34xx_erp_failed(device, request, 0);
+			return tape_34xx_erp_failed(request, 0);
 		}
+	}
 
 	/* Sensing special bits */
 	if (sense[0] & SENSE_BUS_OUT_CHECK)
-		return tape_34xx_erp_retry(device, request);
+		return tape_34xx_erp_retry(request);
 
 	if (sense[0] & SENSE_DATA_CHECK) {
 		/*
@@ -353,7 +422,7 @@ tape_34xx_unit_check(struct tape_device 
 
 			/* data check is permanent, CU recovery has failed */
 			PRINT_WARN("Permanent read error\n");
-			return tape_34xx_erp_failed(device, request, -EIO);
+			return tape_34xx_erp_failed(request, -EIO);
 		case 0x25:
 			// a write data check occurred
 			if ((sense[2] & SENSE_TAPE_SYNC_MODE) ||
@@ -366,22 +435,22 @@ tape_34xx_unit_check(struct tape_device 
 
 			// data check is permanent, cu-recovery has failed
 			PRINT_WARN("Permanent write error\n");
-			return tape_34xx_erp_failed(device, request, -EIO);
+			return tape_34xx_erp_failed(request, -EIO);
 		case 0x26:
 			/* Data Check (read opposite) occurred. */
 			return tape_34xx_erp_read_opposite(device, request);
 		case 0x28:
 			/* ID-Mark at tape start couldn't be written */
 			PRINT_WARN("ID-Mark could not be written.\n");
-			return tape_34xx_erp_failed(device, request, -EIO);
+			return tape_34xx_erp_failed(request, -EIO);
 		case 0x31:
 			/* Tape void. Tried to read beyond end of device. */
 			PRINT_WARN("Read beyond end of recorded area.\n");
-			return tape_34xx_erp_failed(device, request, -ENOSPC);
+			return tape_34xx_erp_failed(request, -ENOSPC);
 		case 0x41:
 			/* Record sequence error. */
 			PRINT_WARN("Invalid block-id sequence found.\n");
-			return tape_34xx_erp_failed(device, request, -EIO);
+			return tape_34xx_erp_failed(request, -EIO);
 		default:
 			/* all data checks for 3480 should result in one of
 			 * the above erpa-codes. For 3490, other data-check
@@ -412,7 +481,7 @@ tape_34xx_unit_check(struct tape_device 
 		 */
 		PRINT_WARN("Data streaming not operational. "
 			   "Switching to interlock-mode.\n");
-		return tape_34xx_erp_retry(device, request);
+		return tape_34xx_erp_retry(request);
 	case 0x22:
 		/*
 		 * Path equipment check. Might be drive adapter error, buffer
@@ -424,14 +493,14 @@ tape_34xx_unit_check(struct tape_device 
 		PRINT_WARN("drive adapter error, buffer error on the lower "
 			   "interface, internal path not usable, error "
 			   "during cartridge load.\n");
-		return tape_34xx_erp_failed(device, request, -EIO);
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x24:
 		/*
 		 * Load display check. Load display was command was issued,
 		 * but the drive is displaying a drive check message. Can
 		 * be threated as "device end".
 		 */
-		return tape_34xx_erp_succeeded(device, request);
+		return tape_34xx_erp_succeeded(request);
 	case 0x27:
 		/*
 		 * Command reject. May indicate illegal channel program or
@@ -439,7 +508,7 @@ tape_34xx_unit_check(struct tape_device 
 		 * issued by this driver and ought be correct, we assume a
 		 * over/underrun situation and retry the channel program.
 		 */
-		return tape_34xx_erp_retry(device, request);
+		return tape_34xx_erp_retry(request);
 	case 0x29:
 		/*
 		 * Function incompatible. Either the tape is idrc compressed
@@ -447,13 +516,13 @@ tape_34xx_unit_check(struct tape_device 
 		 * subsystem func is issued and the CU is not on-line.
 		 */
 		PRINT_WARN ("Function incompatible. Try to switch off idrc\n");
-		return tape_34xx_erp_failed(device, request, -EIO);
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x2a:
 		/*
 		 * Unsolicited environmental data. An internal counter
 		 * overflows, we can ignore this and reissue the cmd.
 		 */
-		return tape_34xx_erp_retry(device, request);
+		return tape_34xx_erp_retry(request);
 	case 0x2b:
 		/*
 		 * Environmental data present. Indicates either unload
@@ -462,7 +531,7 @@ tape_34xx_unit_check(struct tape_device 
 		if (request->op == TO_RUN) {
 			/* Rewind unload completed ok. */
 			tape_med_state_set(device, MS_UNLOADED);
-			return tape_34xx_erp_succeeded(device, request);
+			return tape_34xx_erp_succeeded(request);
 		}
 		/* tape_34xx doesn't use read buffered log commands. */
 		return tape_34xx_erp_bug(device, request, irb, sense[3]);
@@ -471,11 +540,11 @@ tape_34xx_unit_check(struct tape_device 
 		 * Permanent equipment check. CU has tried recovery, but
 		 * did not succeed.
 		 */
-		return tape_34xx_erp_failed(device, request, -EIO);
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x2d:
 		/* Data security erase failure. */
 		if (request->op == TO_DSE)
-			return tape_34xx_erp_failed(device, request, -EIO);
+			return tape_34xx_erp_failed(request, -EIO);
 		/* Data security erase failure, but no such command issued. */
 		return tape_34xx_erp_bug(device, request, irb, sense[3]);
 	case 0x2e:
@@ -484,16 +553,16 @@ tape_34xx_unit_check(struct tape_device 
 		 * reading the format id mark or that that format specified
 		 * is not supported by the drive.
 		 */
-		PRINT_WARN("Drive not capable processing the tape format!");
-		return tape_34xx_erp_failed(device, request, -EMEDIUMTYPE);
+		PRINT_WARN("Drive not capable processing the tape format!\n");
+		return tape_34xx_erp_failed(request, -EMEDIUMTYPE);
 	case 0x30:
 		/* The medium is write protected. */
 		PRINT_WARN("Medium is write protected!\n");
-		return tape_34xx_erp_failed(device, request, -EACCES);
+		return tape_34xx_erp_failed(request, -EACCES);
 	case 0x32:
 		// Tension loss. We cannot recover this, it's an I/O error.
 		PRINT_WARN("The drive lost tape tension.\n");
-		return tape_34xx_erp_failed(device, request, -EIO);
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x33:
 		/*
 		 * Load Failure. The cartridge was not inserted correctly or
@@ -501,7 +570,8 @@ tape_34xx_unit_check(struct tape_device 
 		 */
 		PRINT_WARN("Cartridge load failure. Reload the cartridge "
 			   "and try again.\n");
-		return tape_34xx_erp_failed(device, request, -EIO);
+		tape_34xx_delete_sbid_from(device, 0);
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x34:
 		/*
 		 * Unload failure. The drive cannot maintain tape tension
@@ -510,7 +580,7 @@ tape_34xx_unit_check(struct tape_device 
 		PRINT_WARN("Failure during cartridge unload. "
 			   "Please try manually.\n");
 		if (request->op == TO_RUN)
-			return tape_34xx_erp_failed(device, request, -EIO);
+			return tape_34xx_erp_failed(request, -EIO);
 		return tape_34xx_erp_bug(device, request, irb, sense[3]);
 	case 0x35:
 		/*
@@ -522,11 +592,11 @@ tape_34xx_unit_check(struct tape_device 
 		 */
 		PRINT_WARN("Equipment check! Please check the drive and "
 			   "the cartridge loader.\n");
-		return tape_34xx_erp_failed(device, request, -EIO);
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x36:
 		if (device->cdev->id.driver_info == tape_3490)
 			/* End of data. */
-			return tape_34xx_erp_failed(device, request, -EIO);
+			return tape_34xx_erp_failed(request, -EIO);
 		/* This erpa is reserved for 3480 */
 		return tape_34xx_erp_bug(device, request, irb, sense[3]);
 	case 0x37:
@@ -535,7 +605,7 @@ tape_34xx_unit_check(struct tape_device 
 		 * the beginning-of-tape data.
 		 */
 		PRINT_WARN("Tape length error.\n");
-		return tape_34xx_erp_failed(device, request, -EIO);
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x38:
 		/*
 		 * Physical end of tape. A read/write operation reached
@@ -544,55 +614,58 @@ tape_34xx_unit_check(struct tape_device 
 		if (request->op==TO_WRI ||
 		    request->op==TO_DSE ||
 		    request->op==TO_WTM)
-			return tape_34xx_erp_failed(device, request, -ENOSPC);
-		return tape_34xx_erp_failed(device, request, -EIO);
+			return tape_34xx_erp_failed(request, -ENOSPC);
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x39:
 		/* Backward at Beginning of tape. */
-		return tape_34xx_erp_failed(device, request, -EIO);
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x3a:
 		/* Drive switched to not ready. */
 		PRINT_WARN("Drive not ready. Turn the ready/not ready switch "
 			   "to ready position and try again.\n");
-		return tape_34xx_erp_failed(device, request, -EIO);
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x3b:
 		/* Manual rewind or unload. This causes an I/O error. */
 		PRINT_WARN("Medium was rewound or unloaded manually.\n");
-		return tape_34xx_erp_failed(device, request, -EIO);
+		tape_34xx_delete_sbid_from(device, 0);
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x42:
 		/*
 		 * Degraded mode. A condition that can cause degraded
 		 * performance is detected.
 		 */
 		PRINT_WARN("Subsystem is running in degraded mode.\n");
-		return tape_34xx_erp_retry(device, request);
+		return tape_34xx_erp_retry(request);
 	case 0x43:
 		/* Drive not ready. */
+		tape_34xx_delete_sbid_from(device, 0);
 		tape_med_state_set(device, MS_UNLOADED);
 		/* Some commands commands are successful even in this case */
-		if(sense[1] & SENSE_DRIVE_ONLINE) {
+		if (sense[1] & SENSE_DRIVE_ONLINE) {
 			switch(request->op) {
 				case TO_ASSIGN:
 				case TO_UNASSIGN:
 				case TO_DIS:
-					return tape_34xx_done(device, request);
+				case TO_NOP:
+					return tape_34xx_done(request);
 					break;
 				default:
 					break;
 			}
 		}
 		PRINT_WARN("The drive is not ready.\n");
-		return tape_34xx_erp_failed(device, request, -ENOMEDIUM);
+		return tape_34xx_erp_failed(request, -ENOMEDIUM);
 	case 0x44:
 		/* Locate Block unsuccessful. */
 		if (request->op != TO_BLOCK && request->op != TO_LBL)
 			/* No locate block was issued. */
 			return tape_34xx_erp_bug(device, request,
 						 irb, sense[3]);
-		return tape_34xx_erp_failed(device, request, -EIO);
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x45:
 		/* The drive is assigned to a different channel path. */
 		PRINT_WARN("The drive is assigned elsewhere.\n");
-		return tape_34xx_erp_failed(device, request, -EIO);
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x46:
 		/*
 		 * Drive not on-line. Drive may be switched offline,
@@ -600,23 +673,24 @@ tape_34xx_unit_check(struct tape_device 
 		 * the drive address may not be set correctly.
 		 */
 		PRINT_WARN("The drive is not on-line.");
-		return tape_34xx_erp_failed(device, request, -EIO);
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x47:
 		/* Volume fenced. CU reports volume integrity is lost. */
 		PRINT_WARN("Volume fenced. The volume integrity is lost.\n");
-		return tape_34xx_erp_failed(device, request, -EIO);
+		tape_34xx_delete_sbid_from(device, 0);
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x48:
 		/* Log sense data and retry request. */
-		return tape_34xx_erp_retry(device, request);
+		return tape_34xx_erp_retry(request);
 	case 0x49:
 		/* Bus out check. A parity check error on the bus was found. */
 		PRINT_WARN("Bus out check. A data transfer over the bus "
 			   "has been corrupted.\n");
-		return tape_34xx_erp_failed(device, request, -EIO);
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x4a:
 		/* Control unit erp failed. */
 		PRINT_WARN("The control unit I/O error recovery failed.\n");
-		return tape_34xx_erp_failed(device, request, -EIO);
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x4b:
 		/*
 		 * CU and drive incompatible. The drive requests micro-program
@@ -624,13 +698,13 @@ tape_34xx_unit_check(struct tape_device 
 		 */
 		PRINT_WARN("The drive needs microprogram patches from the "
 			   "control unit, which are not available.\n");
-		return tape_34xx_erp_failed(device, request, -EIO);
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x4c:
 		/*
 		 * Recovered Check-One failure. Cu develops a hardware error,
 		 * but is able to recover.
 		 */
-		return tape_34xx_erp_retry(device, request);
+		return tape_34xx_erp_retry(request);
 	case 0x4d:
 		if (device->cdev->id.driver_info == tape_3490)
 			/*
@@ -638,7 +712,7 @@ tape_34xx_unit_check(struct tape_device 
 			 * not support resetting event recovery (which has to
 			 * be handled by the I/O Layer), retry our command.
 			 */
-			return tape_34xx_erp_retry(device, request);
+			return tape_34xx_erp_retry(request);
 		/* This erpa is reserved for 3480. */
 		return tape_34xx_erp_bug(device, request, irb, sense[3]);
 	case 0x4e:
@@ -650,7 +724,7 @@ tape_34xx_unit_check(struct tape_device 
 			 */
 			PRINT_WARN("Maximum block size for buffered "
 				   "mode exceeded.\n");
-			return tape_34xx_erp_failed(device, request, -ENOBUFS);
+			return tape_34xx_erp_failed(request, -ENOBUFS);
 		}
 		/* This erpa is reserved for 3480. */
 		return tape_34xx_erp_bug(device, request, irb, sense[3]);
@@ -661,7 +735,7 @@ tape_34xx_unit_check(struct tape_device 
 		 * never happen, since we're never running in extended
 		 * buffered log mode.
 		 */
-		return tape_34xx_erp_retry(device, request);
+		return tape_34xx_erp_retry(request);
 	case 0x51:
 		/*
 		 * Read buffered log (EOV). EOF processing occurs while the
@@ -669,73 +743,83 @@ tape_34xx_unit_check(struct tape_device 
 		 * happen, since we're never running in extended buffered
 		 * log mode.
 		 */
-		return tape_34xx_erp_retry(device, request);
+		return tape_34xx_erp_retry(request);
 	case 0x52:
 		/* End of Volume complete. Rewind unload completed ok. */
 		if (request->op == TO_RUN) {
 			tape_med_state_set(device, MS_UNLOADED);
-			return tape_34xx_erp_succeeded(device, request);
+			tape_34xx_delete_sbid_from(device, 0);
+			return tape_34xx_erp_succeeded(request);
 		}
 		return tape_34xx_erp_bug(device, request, irb, sense[3]);
 	case 0x53:
 		/* Global command intercept. */
-		return tape_34xx_erp_retry(device, request);
+		return tape_34xx_erp_retry(request);
 	case 0x54:
 		/* Channel interface recovery (temporary). */
-		return tape_34xx_erp_retry(device, request);
+		return tape_34xx_erp_retry(request);
 	case 0x55:
 		/* Channel interface recovery (permanent). */
 		PRINT_WARN("A permanent channel interface error occurred.\n");
-		return tape_34xx_erp_failed(device, request, -EIO);
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x56:
 		/* Channel protocol error. */
 		PRINT_WARN("A channel protocol error occurred.\n");
-		return tape_34xx_erp_failed(device, request, -EIO);
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x57:
 		if (device->cdev->id.driver_info == tape_3480) {
 			/* Attention intercept. */
 			PRINT_WARN("An attention intercept occurred, "
 				   "which will be recovered.\n");
-			return tape_34xx_erp_retry(device, request);
+			return tape_34xx_erp_retry(request);
 		} else {
 			/* Global status intercept. */
 			PRINT_WARN("An global status intercept was received, "
 				   "which will be recovered.\n");
-			return tape_34xx_erp_retry(device, request);
+			return tape_34xx_erp_retry(request);
 		}
 	case 0x5a:
 		/*
 		 * Tape length incompatible. The tape inserted is too long,
 		 * which could cause damage to the tape or the drive.
 		 */
-		PRINT_WARN("Tape length incompatible [should be IBM Cartridge "
-			   "System Tape]. May cause damage to drive or tape.\n");
-		return tape_34xx_erp_failed(device, request, -EIO);
+		PRINT_WARN("Tape Length Incompatible\n");
+		PRINT_WARN("Tape length exceeds IBM enhanced capacity "
+			"cartdridge length or a medium\n");
+		PRINT_WARN("with EC-CST identification mark has been mounted "
+			"in a device that writes\n");
+		PRINT_WARN("3480 or 3480 XF format.\n");
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x5b:
 		/* Format 3480 XF incompatible */
 		if (sense[1] & SENSE_BEGINNING_OF_TAPE)
 			/* The tape will get overwritten. */
-			return tape_34xx_erp_retry(device, request);
-		PRINT_WARN("Tape format is incompatible to the drive, "
-			   "which writes 3480-2 XF.\n");
-		return tape_34xx_erp_failed(device, request, -EIO);
+			return tape_34xx_erp_retry(request);
+		PRINT_WARN("Format 3480 XF Incompatible\n");
+		PRINT_WARN("Medium has been created in 3480 format. "
+			"To change the format writes\n");
+		PRINT_WARN("must be issued at BOT.\n");
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x5c:
 		/* Format 3480-2 XF incompatible */
-		PRINT_WARN("Tape format is incompatible to the drive. "
-			   "The drive cannot access 3480-2 XF volumes.\n");
-		return tape_34xx_erp_failed(device, request, -EIO);
+		PRINT_WARN("Format 3480-2 XF Incompatible\n");
+		PRINT_WARN("Device can only read 3480 or 3480 XF format.\n");
+		return tape_34xx_erp_failed(request, -EIO);
 	case 0x5d:
 		/* Tape length violation. */
-		PRINT_WARN("Tape length violation [should be IBM Enhanced "
-			   "Capacity Cartridge System Tape]. May cause "
-			   "damage to drive or tape.\n");
-		return tape_34xx_erp_failed(device, request, -EMEDIUMTYPE);
+		PRINT_WARN("Tape Length Violation\n");
+		PRINT_WARN("The mounted tape exceeds IBM Enhanced Capacity "
+			"Cartdridge System Tape length.\n");
+		PRINT_WARN("This may cause damage to the drive or tape when "
+			"processing to the EOV\n");
+		return tape_34xx_erp_failed(request, -EMEDIUMTYPE);
 	case 0x5e:
 		/* Compaction algorithm incompatible. */
+		PRINT_WARN("Compaction Algorithm Incompatible\n");
 		PRINT_WARN("The volume is recorded using an incompatible "
-			   "compaction algorithm, which is not supported by "
-			   "the control unit.\n");
-		return tape_34xx_erp_failed(device, request, -EMEDIUMTYPE);
+			"compaction algorithm,\n");
+		PRINT_WARN("which is not supported by the device.\n");
+		return tape_34xx_erp_failed(request, -EMEDIUMTYPE);
 
 		/* The following erpas should have been covered earlier. */
 	case 0x23: /* Read data check. */
@@ -766,14 +850,24 @@ tape_34xx_irq(struct tape_device *device
 	    (request->op == TO_WRI)) {
 		/* Write at end of volume */
 		PRINT_INFO("End of volume\n"); /* XXX */
-		return tape_34xx_erp_failed(device, request, -ENOSPC);
+		return tape_34xx_erp_failed(request, -ENOSPC);
 	}
 
 	if (irb->scsw.dstat & DEV_STAT_UNIT_CHECK)
 		return tape_34xx_unit_check(device, request, irb);
 
-	if (irb->scsw.dstat & DEV_STAT_DEV_END)
-		return tape_34xx_done(device, request);
+	if (irb->scsw.dstat & DEV_STAT_DEV_END) {
+		/*
+		 * A unit exception occurs on skipping over a tapemark block.
+		 */
+		if (irb->scsw.dstat & DEV_STAT_UNIT_EXCEP) {
+			if (request->op == TO_BSB || request->op == TO_FSB)
+				request->rescnt++;
+			else
+				DBF_EVENT(5, "Unit Exception!\n");
+		}
+		return tape_34xx_done(request);
+	}
 
 	DBF_EVENT(6, "xunknownirq\n");
 	PRINT_ERR("Unexpected interrupt.\n");
@@ -786,45 +880,217 @@ tape_34xx_irq(struct tape_device *device
  * ioctl_overload
  */
 static int
-tape_34xx_ioctl(struct tape_device *device,
-		unsigned int cmd, unsigned long arg)
+tape_34xx_ioctl(struct tape_device *device, unsigned int cmd, unsigned long arg)
 {
-	if (cmd == TAPE390_DISPLAY)
-		return tape_std_display(device, cmd, arg);
-	else
+	if (cmd == TAPE390_DISPLAY) {
+		struct display_struct disp;
+
+		if (copy_from_user(&disp, (char *) arg, sizeof(disp)) != 0)
+			return -EFAULT;
+
+		return tape_std_display(device, &disp);
+	} else
 		return -EINVAL;
 }
 
+static inline void
+tape_34xx_append_new_sbid(struct tape_34xx_block_id bid, struct list_head *l)
+{
+	struct tape_34xx_sbid *	new_sbid;
+
+	new_sbid = kmalloc(sizeof(*new_sbid), GFP_ATOMIC);
+	if (!new_sbid)
+		return;
+
+	new_sbid->bid = bid;
+	list_add(&new_sbid->list, l);
+}
+
+/*
+ * Build up the search block ID list. The block ID consists of a logical
+ * block number and a hardware specific part. The hardware specific part
+ * helps the tape drive to speed up searching for a specific block.
+ */
+static void
+tape_34xx_add_sbid(struct tape_device *device, struct tape_34xx_block_id bid)
+{
+	struct list_head *	sbid_list;
+	struct tape_34xx_sbid *	sbid;
+	struct list_head *	l;
+
+	/*
+	 * immediately return if there is no list at all or the block to add
+	 * is located in segment 1 of wrap 0 because this position is used
+	 * if no hardware position data is supplied.
+	 */
+	sbid_list = (struct list_head *) device->discdata;
+	if (!sbid_list || (bid.segment < 2 && bid.wrap == 0))
+		return;
+
+	/*
+	 * Search the position where to insert the new entry. Hardware
+	 * acceleration uses only the segment and wrap number. So we
+	 * need only one entry for a specific wrap/segment combination.
+	 * If there is a block with a lower number but the same hard-
+	 * ware position data we just update the block number in the
+	 * existing entry.
+	 */
+	list_for_each(l, sbid_list) {
+		sbid = list_entry(l, struct tape_34xx_sbid, list);
+
+		if (
+			(sbid->bid.segment == bid.segment) &&
+			(sbid->bid.wrap    == bid.wrap)
+		) {
+			if (bid.block < sbid->bid.block)
+				sbid->bid = bid;
+			else return;
+			break;
+		}
+
+		/* Sort in according to logical block number. */
+		if (bid.block < sbid->bid.block) {
+			tape_34xx_append_new_sbid(bid, l->prev);
+			break;
+		}
+	}
+	/* List empty or new block bigger than last entry. */
+	if (l == sbid_list)
+		tape_34xx_append_new_sbid(bid, l->prev);
+
+	DBF_LH(4, "Current list is:\n");
+	list_for_each(l, sbid_list) {
+		sbid = list_entry(l, struct tape_34xx_sbid, list);
+		DBF_LH(4, "%d:%03d@%05d\n",
+			sbid->bid.wrap,
+			sbid->bid.segment,
+			sbid->bid.block
+		);
+	}
+}
+
+/*
+ * Delete all entries from the search block ID list that belong to tape blocks
+ * equal or higher than the given number.
+ */
+static void
+tape_34xx_delete_sbid_from(struct tape_device *device, int from)
+{
+	struct list_head *	sbid_list;
+	struct tape_34xx_sbid *	sbid;
+	struct list_head *	l;
+	struct list_head *	n;
+
+	sbid_list = (struct list_head *) device->discdata;
+	if (!sbid_list)
+		return;
+
+	list_for_each_safe(l, n, sbid_list) {
+		sbid = list_entry(l, struct tape_34xx_sbid, list);
+		if (sbid->bid.block >= from) {
+			DBF_LH(4, "Delete sbid %d:%03d@%05d\n",
+				sbid->bid.wrap,
+				sbid->bid.segment,
+				sbid->bid.block
+			);
+			list_del(l);
+			kfree(sbid);
+		}
+	}
+}
+
+/*
+ * Merge hardware position data into a block id.
+ */
+static void
+tape_34xx_merge_sbid(
+	struct tape_device *		device,
+	struct tape_34xx_block_id *	bid
+) {
+	struct tape_34xx_sbid *	sbid;
+	struct tape_34xx_sbid *	sbid_to_use;
+	struct list_head *	sbid_list;
+	struct list_head *	l;
+
+	sbid_list = (struct list_head *) device->discdata;
+	bid->wrap    = 0;
+	bid->segment = 1;
+
+	if (!sbid_list || list_empty(sbid_list))
+		return;
+
+	sbid_to_use = NULL;
+	list_for_each(l, sbid_list) {
+		sbid = list_entry(l, struct tape_34xx_sbid, list);
+
+		if (sbid->bid.block >= bid->block)
+			break;
+		sbid_to_use = sbid;
+	}
+	if (sbid_to_use) {
+		bid->wrap    = sbid_to_use->bid.wrap;
+		bid->segment = sbid_to_use->bid.segment;
+		DBF_LH(4, "Use %d:%03d@%05d for %05d\n",
+			sbid_to_use->bid.wrap,
+			sbid_to_use->bid.segment,
+			sbid_to_use->bid.block,
+			bid->block
+		);
+	}
+}
+
 static int
 tape_34xx_setup_device(struct tape_device * device)
 {
-	DBF_EVENT(6, "34xx minor1: %x\n", device->first_minor);
-	tape_34xx_medium_sense(device);
-	return 0;
+	int			rc;
+	struct list_head *	discdata;
+
+	DBF_EVENT(6, "34xx device setup\n");
+	if ((rc = tape_std_assign(device)) == 0) {
+		if ((rc = tape_34xx_medium_sense(device)) != 0) {
+			DBF_LH(3, "34xx medium sense returned %d\n", rc);
+		}
+	}
+	discdata = kmalloc(sizeof(struct list_head), GFP_KERNEL);
+	if (discdata) {
+			INIT_LIST_HEAD(discdata);
+			device->discdata = discdata;
+	}
+
+	return rc;
 }
 
 static void
-tape_34xx_cleanup_device(struct tape_device * device)
+tape_34xx_cleanup_device(struct tape_device *device)
 {
+	tape_std_unassign(device);
+	
 	if (device->discdata) {
+		tape_34xx_delete_sbid_from(device, 0);
 		kfree(device->discdata);
 		device->discdata = NULL;
 	}
 }
 
+
 /*
  * MTTELL: Tell block. Return the number of block relative to current file.
  */
 static int
 tape_34xx_mttell(struct tape_device *device, int mt_count)
 {
-	__u64 block_id;
+	struct {
+		struct tape_34xx_block_id	cbid;
+		struct tape_34xx_block_id	dbid;
+	} __attribute__ ((packed)) block_id;
 	int rc;
 
-	rc = tape_std_read_block_id(device, &block_id);
+	rc = tape_std_read_block_id(device, (__u64 *) &block_id);
 	if (rc)
 		return rc;
-	return (block_id >> 32) & 0x3fffff;
+
+	tape_34xx_add_sbid(device, block_id.cbid);
+	return block_id.cbid.block;
 }
 
 /*
@@ -834,21 +1100,28 @@ static int
 tape_34xx_mtseek(struct tape_device *device, int mt_count)
 {
 	struct tape_request *request;
+	struct tape_34xx_block_id *	bid;
 
-	if (mt_count > 0x400000) {
+	if (mt_count > 0x3fffff) {
 		DBF_EXCEPTION(6, "xsee parm\n");
 		return -EINVAL;
 	}
 	request = tape_alloc_request(3, 4);
 	if (IS_ERR(request))
 		return PTR_ERR(request);
-	request->op = TO_LBL;
+
 	/* setup ccws */
+	request->op = TO_LBL;
+	bid         = (struct tape_34xx_block_id *) request->cpdata;
+	bid->format = (*device->modeset_byte & 0x08) ?
+			TAPE34XX_FMT_3480_XF : TAPE34XX_FMT_3480;
+	bid->block  = mt_count;
+	tape_34xx_merge_sbid(device, bid);
+
 	tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
-	*(__u32 *) request->cpdata = mt_count |
-		((*device->modeset_byte & 0x08) ? 0x01800000 : 0x01000000);
 	tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
 	tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL);
+
 	/* execute it */
 	return tape_do_io_free(device, request);
 }
@@ -862,15 +1135,14 @@ tape_34xx_bread(struct tape_device *devi
 {
 	struct tape_request *request;
 	struct ccw1 *ccw;
-	int count = 0,start_block,i;
+	int count = 0, i;
 	unsigned off;
 	char *dst;
 	struct bio_vec *bv;
 	struct bio *bio;
+	struct tape_34xx_block_id *	start_block;
 
 	DBF_EVENT(6, "xBREDid:");
-	start_block = req->sector >> TAPEBLOCK_HSEC_S2B;
-	DBF_EVENT(6, "start_block = %i\n", start_block);
 
 	/* Count the number of blocks for the request. */
 	rq_for_each_bio(bio, req) {
@@ -878,14 +1150,18 @@ tape_34xx_bread(struct tape_device *devi
 			count += bv->bv_len >> (TAPEBLOCK_HSEC_S2B + 9);
 		}
 	}
+
 	/* Allocate the ccw request. */
-	request = tape_alloc_request(2+count+1, 4);
+	request = tape_alloc_request(3+count+1, 8);
 	if (IS_ERR(request))
 		return request;
+
 	/* Setup ccws. */
 	request->op = TO_BLOCK;
-	*(__u32 *) request->cpdata = (start_block & 0x3fffff) |
-		((*device->modeset_byte & 0x08) ? 0x81000000 : 0x01000000);
+	start_block = (struct tape_34xx_block_id *) request->cpdata;
+	start_block->block = req->sector >> TAPEBLOCK_HSEC_S2B;
+	DBF_EVENT(6, "start_block = %i\n", start_block->block);
+
 	ccw = request->cpaddr;
 	ccw = tape_ccw_cc(ccw, MODE_SET_DB, 1, device->modeset_byte);
 
@@ -893,8 +1169,12 @@ tape_34xx_bread(struct tape_device *devi
 	 * We always setup a nop after the mode set ccw. This slot is
 	 * used in tape_std_check_locate to insert a locate ccw if the
 	 * current tape position doesn't match the start block to be read.
+	 * The second nop will be filled with a read block id which is in
+	 * turn used by tape_34xx_free_bread to populate the segment bid
+	 * table.
 	 */
 	ccw = tape_ccw_cc(ccw, NOP, 0, NULL);
+	ccw = tape_ccw_cc(ccw, NOP, 0, NULL);
 
 	rq_for_each_bio(bio, req) {
 		bio_for_each_segment(bv, bio, i) {
@@ -921,8 +1201,21 @@ tape_34xx_free_bread (struct tape_reques
 {
 	struct ccw1* ccw;
 
+	ccw = request->cpaddr;
+	if ((ccw + 2)->cmd_code == READ_BLOCK_ID) {
+		struct {
+			struct tape_34xx_block_id	cbid;
+			struct tape_34xx_block_id	dbid;
+		} __attribute__ ((packed)) *rbi_data;
+
+		rbi_data = request->cpdata;
+
+		if (request->device)
+			tape_34xx_add_sbid(request->device, rbi_data->cbid);
+	}
+
 	/* Last ccw is a nop and doesn't need clear_normalized_cda */
-	for (ccw = request->cpaddr; ccw->flags & CCW_FLAG_CC; ccw++)
+	for (; ccw->flags & CCW_FLAG_CC; ccw++)
 		if (ccw->cmd_code == READ_FORWARD)
 			clear_normalized_cda(ccw);
 	tape_free_request(request);
@@ -935,14 +1228,24 @@ tape_34xx_free_bread (struct tape_reques
  * start block for the request.
  */
 static void
-tape_34xx_check_locate (struct tape_device *device,
-			struct tape_request *request)
+tape_34xx_check_locate(struct tape_device *device, struct tape_request *request)
 {
-	int start_block;
+	struct tape_34xx_block_id *	start_block;
 
-	start_block = *(__u32 *) request->cpdata & 0x3fffff;
-	if (start_block != device->blk_data.block_position)
-		tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
+	start_block = (struct tape_34xx_block_id *) request->cpdata;
+	if (start_block->block == device->blk_data.block_position)
+		return;
+
+	DBF_LH(4, "Block seek(%06d+%06d)\n", start_block->block, device->bof);
+	start_block->wrap    = 0;
+	start_block->segment = 1;
+	start_block->format  = (*device->modeset_byte & 0x08) ?
+				TAPE34XX_FMT_3480_XF :
+				TAPE34XX_FMT_3480;
+	start_block->block   = start_block->block + device->bof;
+	tape_34xx_merge_sbid(device, start_block);
+	tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
+	tape_ccw_cc(request->cpaddr + 2, READ_BLOCK_ID, 8, request->cpdata);
 }
 #endif
 
@@ -995,8 +1298,6 @@ static struct tape_discipline tape_disci
 	.irq = tape_34xx_irq,
 	.read_block = tape_std_read_block,
 	.write_block = tape_std_write_block,
-	.assign = tape_std_assign,
-	.unassign = tape_std_unassign,
 #ifdef CONFIG_S390_TAPE_BLOCK
 	.bread = tape_34xx_bread,
 	.free_bread = tape_34xx_free_bread,
@@ -1041,7 +1342,7 @@ tape_34xx_init (void)
 {
 	int rc;
 
-	DBF_EVENT(3, "34xx init: $Revision: 1.8 $\n");
+	DBF_EVENT(3, "34xx init: $Revision: 1.18 $\n");
 	/* Register driver for 3480/3490 tapes. */
 	rc = ccw_driver_register(&tape_34xx_driver);
 	if (rc)
@@ -1060,7 +1361,7 @@ tape_34xx_exit(void)
 MODULE_DEVICE_TABLE(ccw, tape_34xx_ids);
 MODULE_AUTHOR("(C) 2001-2002 IBM Deutschland Entwicklung GmbH");
 MODULE_DESCRIPTION("Linux on zSeries channel attached 3480 tape "
-		   "device driver ($Revision: 1.8 $)");
+		   "device driver ($Revision: 1.18 $)");
 MODULE_LICENSE("GPL");
 
 module_init(tape_34xx_init);
diff -puN drivers/s390/char/tape_block.c~linus drivers/s390/char/tape_block.c
--- 25/drivers/s390/char/tape_block.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/char/tape_block.c	2004-01-19 22:17:23.000000000 -0800
@@ -3,12 +3,14 @@
  *    block device frontend for tape device driver
  *
  *  S390 and zSeries version
- *    Copyright (C) 2001,2002 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ *    Copyright (C) 2001,2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
  *    Author(s): Carsten Otte <cotte@de.ibm.com>
  *		 Tuan Ngo-Anh <ngoanh@de.ibm.com>
  *		 Martin Schwidefsky <schwidefsky@de.ibm.com>
+ *		 Stefan Bader <shbader@de.ibm.com>
  */
 
+#include <linux/fs.h>
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/blkdev.h>
@@ -19,25 +21,53 @@
 
 #include "tape.h"
 
-#define PRINTK_HEADER "TBLOCK:"
+#define PRINTK_HEADER "TAPE_BLOCK: "
 
 #define TAPEBLOCK_MAX_SEC	100
 #define TAPEBLOCK_MIN_REQUEUE	3
 
 /*
+ * 2003/11/25  Stefan Bader <shbader@de.ibm.com>
+ *
+ * In 2.5/2.6 the block device request function is very likely to be called
+ * with disabled interrupts (e.g. generic_unplug_device). So the driver can't
+ * just call any function that tries to allocate CCW requests from that con-
+ * text since it might sleep. There are two choices to work around this:
+ *	a) do not allocate with kmalloc but use its own memory pool
+ *      b) take requests from the queue outside that context, knowing that
+ *         allocation might sleep
+ */
+
+/*
  * file operation structure for tape block frontend
  */
 static int tapeblock_open(struct inode *, struct file *);
 static int tapeblock_release(struct inode *, struct file *);
+static int tapeblock_ioctl(struct inode *, struct file *, unsigned int,
+				unsigned long);
+static int tapeblock_medium_changed(struct gendisk *);
+static int tapeblock_revalidate_disk(struct gendisk *);
 
 static struct block_device_operations tapeblock_fops = {
-	.owner		= THIS_MODULE,
-	.open		= tapeblock_open,
-	.release	= tapeblock_release,
+	.owner		 = THIS_MODULE,
+	.open		 = tapeblock_open,
+	.release	 = tapeblock_release,
+	.ioctl           = tapeblock_ioctl,
+	.media_changed   = tapeblock_medium_changed,
+	.revalidate_disk = tapeblock_revalidate_disk,
 };
 
 static int tapeblock_major = 0;
 
+static void
+tapeblock_trigger_requeue(struct tape_device *device)
+{
+	/* Protect against rescheduling. */
+	if (atomic_compare_and_swap(0, 1, &device->blk_data.requeue_scheduled))
+		return;
+	schedule_work(&device->blk_data.requeue_task);
+}
+
 /*
  * Post finished request.
  */
@@ -55,6 +85,8 @@ __tapeblock_end_request(struct tape_requ
 	struct tape_device *device;
 	struct request *req;
 
+	DBF_LH(6, "__tapeblock_end_request()\n");
+
 	device = ccw_req->device;
 	req = (struct request *) data;
 	tapeblock_end_request(req, ccw_req->rc == 0);
@@ -68,33 +100,75 @@ __tapeblock_end_request(struct tape_requ
 	device->discipline->free_bread(ccw_req);
 	if (!list_empty(&device->req_queue) ||
 	    elv_next_request(device->blk_data.request_queue))
-		tasklet_schedule(&device->blk_data.tasklet);
+		tapeblock_trigger_requeue(device);
 }
 
 /*
- * Fetch requests from block device queue.
+ * Feed the tape device CCW queue with requests supplied in a list.
  */
-static inline void
-__tape_process_blk_queue(struct tape_device *device, struct list_head *new_req)
+static inline int
+tapeblock_start_request(struct tape_device *device, struct request *req)
 {
-	request_queue_t *queue;
-	struct list_head *l;
-	struct request *req;
-	struct tape_request *ccw_req;
-	int nr_queued;
+	struct tape_request *	ccw_req;
+	int			rc;
+
+	DBF_LH(6, "tapeblock_start_request(%p, %p)\n", device, req);
 
-	/* FIXME: we have to make sure that the tapeblock frontend
-	   owns the device. tape_state != TS_IN_USE is NOT enough. */
-	if (device->tape_state != TS_IN_USE)
+	ccw_req = device->discipline->bread(device, req);
+	if (IS_ERR(ccw_req)) {
+		DBF_EVENT(1, "TBLOCK: bread failed\n");
+		tapeblock_end_request(req, 0);
+		return PTR_ERR(ccw_req);
+	}
+	ccw_req->callback = __tapeblock_end_request;
+	ccw_req->callback_data = (void *) req;
+	ccw_req->retries = TAPEBLOCK_RETRIES;
+
+	rc = tape_do_io_async(device, ccw_req);
+	if (rc) {
+		/*
+		 * Start/enqueueing failed. No retries in
+		 * this case.
+		 */
+		tapeblock_end_request(req, 0);
+		device->discipline->free_bread(ccw_req);
+	}
+
+	return rc;
+}
+
+/*
+ * Move requests from the block device request queue to the tape device ccw
+ * queue.
+ */
+static void
+tapeblock_requeue(void *data) {
+	struct tape_device *	device;
+	request_queue_t *	queue;
+	int			nr_queued;
+	struct request *	req;
+	struct list_head *	l;
+	int			rc;
+
+	device = (struct tape_device *) data;
+	if (!device)
 		return;
-	queue = device->blk_data.request_queue;
-	nr_queued = 0;
+
+	spin_lock_irq(get_ccwdev_lock(device->cdev));
+	queue  = device->blk_data.request_queue;
+
 	/* Count number of requests on ccw queue. */
+	nr_queued = 0;
 	list_for_each(l, &device->req_queue)
 		nr_queued++;
-	while (!blk_queue_plugged(queue) &&
-	       elv_next_request(queue) &&
-	       nr_queued < TAPEBLOCK_MIN_REQUEUE) {
+	spin_unlock(get_ccwdev_lock(device->cdev));
+
+	spin_lock(&device->blk_data.request_queue_lock);
+	while (
+		!blk_queue_plugged(queue) &&
+		elv_next_request(queue)   &&
+		nr_queued < TAPEBLOCK_MIN_REQUEUE
+	) {
 		req = elv_next_request(queue);
 		if (rq_data_dir(req) == WRITE) {
 			DBF_EVENT(1, "TBLOCK: Rejecting write request\n");
@@ -102,52 +176,14 @@ __tape_process_blk_queue(struct tape_dev
 			tapeblock_end_request(req, 0);
 			continue;
 		}
-		ccw_req = device->discipline->bread(device, req);
-		if (IS_ERR(ccw_req)) {
-			if (PTR_ERR(ccw_req) == -ENOMEM)
-				break; /* don't try again */
-			DBF_EVENT(1, "TBLOCK: bread failed\n");
-			blkdev_dequeue_request(req);
-			tapeblock_end_request(req, 0);
-			continue;
-		}
-		ccw_req->callback = __tapeblock_end_request;
-		ccw_req->callback_data = (void *) req;
-		ccw_req->retries = TAPEBLOCK_RETRIES;
+		spin_unlock_irq(&device->blk_data.request_queue_lock);
+		rc = tapeblock_start_request(device, req);
+		spin_lock_irq(&device->blk_data.request_queue_lock);
 		blkdev_dequeue_request(req);
-		list_add_tail(new_req, &ccw_req->list);
 		nr_queued++;
 	}
-}
-
-/*
- * Feed requests to the tape device.
- */
-static inline int
-tape_queue_requests(struct tape_device *device, struct list_head *new_req)
-{
-	struct list_head *l, *n;
-	struct tape_request *ccw_req;
-	struct request *req;
-	int rc, fail;
-
-	fail = 0;
-	list_for_each_safe(l, n, new_req) {
-		ccw_req = list_entry(l, struct tape_request, list);
-		list_del(&ccw_req->list);
-		rc = tape_do_io_async(device, ccw_req);
-		if (rc) {
-			/*
-			 * Start/enqueueing failed. No retries in
-			 * this case.
-			 */
-			req = (struct request *) ccw_req->callback_data;
-			tapeblock_end_request(req, 0);
-			device->discipline->free_bread(ccw_req);
-			fail = 1;
-		}
-	}
-	return fail;
+	spin_unlock_irq(&device->blk_data.request_queue_lock);
+	atomic_set(&device->blk_data.requeue_scheduled, 0);
 }
 
 /*
@@ -156,48 +192,14 @@ tape_queue_requests(struct tape_device *
 static void
 tapeblock_request_fn(request_queue_t *queue)
 {
-	struct list_head new_req;
 	struct tape_device *device;
 
 	device = (struct tape_device *) queue->queuedata;
-	while (elv_next_request(queue)) {
-		INIT_LIST_HEAD(&new_req);
-		spin_lock(get_ccwdev_lock(device->cdev));
-		__tape_process_blk_queue(device, &new_req);
-		spin_unlock(get_ccwdev_lock(device->cdev));
-		/*
-		 * Now queue the new request to the tape. This needs to be
-		 * done without the device lock held.
-		 */
-		if (tape_queue_requests(device, &new_req) == 0)
-			/* All requests queued. Thats enough for now. */
-			break;
-	}
-}
-
-/*
- * Acquire the device lock and process queues for the device.
- */
-static void
-tapeblock_tasklet(unsigned long data)
-{
-	struct list_head new_req;
-	struct tape_device *device;
+	DBF_LH(6, "tapeblock_request_fn(device=%p)\n", device);
+	if (device == NULL)
+		BUG();
 
-	device = (struct tape_device *) data;
-	while (elv_next_request(device->blk_data.request_queue)) {
-		INIT_LIST_HEAD(&new_req);
-		spin_lock_irq(get_ccwdev_lock(device->cdev));
-		__tape_process_blk_queue(device, &new_req);
-		spin_unlock_irq(get_ccwdev_lock(device->cdev));
-		/*
-		 * Now queue the new request to the tape. This needs to be
-		 * done without the device lock held.
-		 */
-		if (tape_queue_requests(device, &new_req) == 0)
-			/* All requests queued. Thats enough for now. */
-			break;
-	}
+	tapeblock_trigger_requeue(device);
 }
 
 /*
@@ -206,126 +208,192 @@ tapeblock_tasklet(unsigned long data)
 int
 tapeblock_setup_device(struct tape_device * device)
 {
-	struct tape_blk_data *d = &device->blk_data;
-	request_queue_t *q;
-	struct gendisk *disk = alloc_disk(1);
-	int rc;
-
-	if (!disk)
+	struct tape_blk_data *	blkdat;
+	struct gendisk *	disk;
+	int			rc;
+
+	blkdat = &device->blk_data;
+	spin_lock_init(&blkdat->request_queue_lock);
+	atomic_set(&blkdat->requeue_scheduled, 0);
+
+	blkdat->request_queue = blk_init_queue(
+		tapeblock_request_fn,
+		&blkdat->request_queue_lock
+	);
+	if (!blkdat->request_queue)
 		return -ENOMEM;
 
-	tasklet_init(&d->tasklet, tapeblock_tasklet, (unsigned long)device);
-
-	spin_lock_init(&d->request_queue_lock);
-	q = blk_init_queue(tapeblock_request_fn, &d->request_queue_lock);
-	if (!q) {
-		rc = -ENXIO;
-		goto put_disk;
-	}
-	d->request_queue = q;
-	elevator_exit(q);
-	rc = elevator_init(q, &elevator_noop);
+	elevator_exit(blkdat->request_queue);
+	rc = elevator_init(blkdat->request_queue, &elevator_noop);
 	if (rc)
 		goto cleanup_queue;
 
-	/* FIXME: We should be able to sense the sectore size */
-	blk_queue_hardsect_size(q, TAPEBLOCK_HSEC_SIZE);
-	blk_queue_max_sectors(q, TAPEBLOCK_MAX_SEC);
-	blk_queue_max_phys_segments(q, -1L);
-	blk_queue_max_hw_segments(q, -1L);
-	blk_queue_max_segment_size(q, -1L);
-	blk_queue_segment_boundary(q, -1L);
+	blk_queue_hardsect_size(blkdat->request_queue, TAPEBLOCK_HSEC_SIZE);
+	blk_queue_max_sectors(blkdat->request_queue, TAPEBLOCK_MAX_SEC);
+	blk_queue_max_phys_segments(blkdat->request_queue, -1L);
+	blk_queue_max_hw_segments(blkdat->request_queue, -1L);
+	blk_queue_max_segment_size(blkdat->request_queue, -1L);
+	blk_queue_segment_boundary(blkdat->request_queue, -1L);
+
+	disk = alloc_disk(1);
+	if (!disk) {
+		rc = -ENOMEM;
+		goto cleanup_queue;
+	}
 
 	disk->major = tapeblock_major;
 	disk->first_minor = device->first_minor;
 	disk->fops = &tapeblock_fops;
-	disk->private_data = device;
-	disk->queue = q;
-	//set_capacity(disk, size);
-
-	sprintf(disk->disk_name, "tBLK/%d", device->first_minor / TAPE_MINORS_PER_DEV);
+	disk->private_data = tape_get_device_reference(device);
+	disk->queue = blkdat->request_queue;
+	set_capacity(disk, 0);
+	sprintf(disk->disk_name, "btibm%d",
+		device->first_minor / TAPE_MINORS_PER_DEV);
+
+	blkdat->disk = disk;
+	blkdat->medium_changed = 1;
+	blkdat->request_queue->queuedata = tape_get_device_reference(device);
 
 	add_disk(disk);
-	d->disk = disk;
+
+	INIT_WORK(&blkdat->requeue_task, tapeblock_requeue,
+		tape_get_device_reference(device));
+
+	/* Will vanish */
+	tape_hotplug_event(device, tapeblock_major, TAPE_HOTPLUG_BLOCK_ADD);
+
 	return 0;
 
- cleanup_queue:
-	blk_cleanup_queue(q);
- put_disk:
-	put_disk(disk);
+cleanup_queue:
+	blk_cleanup_queue(blkdat->request_queue);
+	blkdat->request_queue = NULL;
+
 	return rc;
 }
 
 void
 tapeblock_cleanup_device(struct tape_device *device)
 {
-	struct tape_blk_data *d = &device->blk_data;
+	tape_hotplug_event(device, tapeblock_major, TAPE_HOTPLUG_BLOCK_REMOVE);
+
+	flush_scheduled_work();
+	device->blk_data.requeue_task.data = tape_put_device(device);
 
-	del_gendisk(d->disk);
-	put_disk(d->disk);
-	blk_cleanup_queue(d->request_queue);
+	del_gendisk(device->blk_data.disk);
+	device->blk_data.disk->private_data =
+		tape_put_device(device->blk_data.disk->private_data);
+	put_disk(device->blk_data.disk);
 
-	tasklet_kill(&d->tasklet);
+	device->blk_data.disk = NULL;
+	device->blk_data.request_queue->queuedata = tape_put_device(device);
+
+	blk_cleanup_queue(device->blk_data.request_queue);
+	device->blk_data.request_queue = NULL;
 }
 
 /*
  * Detect number of blocks of the tape.
  * FIXME: can we extent this to detect the blocks size as well ?
  */
-static int tapeblock_mediumdetect(struct tape_device *device)
+static int
+tapeblock_revalidate_disk(struct gendisk *disk)
 {
-	unsigned int nr_of_blks;
-	int rc;
+	struct tape_device *	device;
+	unsigned int		nr_of_blks;
+	int			rc;
+
+	device = (struct tape_device *) disk->private_data;
+	if (!device)
+		BUG();
+
+	if (!device->blk_data.medium_changed)
+		return 0;
 
 	PRINT_INFO("Detecting media size...\n");
-	rc = tape_mtop(device, MTREW, 1);
-	if (rc)
-		return rc;
-	rc = tape_mtop(device, MTFSF, 1);
+	rc = tape_mtop(device, MTFSFM, 1);
 	if (rc)
 		return rc;
+
 	rc = tape_mtop(device, MTTELL, 1);
-	if (rc)
+	if (rc < 0)
 		return rc;
-	nr_of_blks = rc - 1; /* don't count FM */
-	rc = tape_mtop(device, MTREW, 1);
-	if (rc)
+
+	DBF_LH(3, "Image file ends at %d\n", rc);
+	nr_of_blks = rc;
+
+	/* This will fail for the first file. Catch the error by checking the
+	 * position. */
+	tape_mtop(device, MTBSF, 1);
+
+	rc = tape_mtop(device, MTTELL, 1);
+	if (rc < 0)
 		return rc;
+
+	if (rc > nr_of_blks)
+		return -EINVAL;
+
+	DBF_LH(3, "Image file starts at %d\n", rc);
+	device->bof = rc;
+	nr_of_blks -= rc;
+
 	PRINT_INFO("Found %i blocks on media\n", nr_of_blks);
+	set_capacity(device->blk_data.disk,
+		nr_of_blks*(TAPEBLOCK_HSEC_SIZE/512));
+
+	device->blk_data.block_position = 0;
+	device->blk_data.medium_changed = 0;
 	return 0;
 }
 
+static int
+tapeblock_medium_changed(struct gendisk *disk)
+{
+	struct tape_device *device;
+
+	device = (struct tape_device *) disk->private_data;
+	DBF_LH(6, "tapeblock_medium_changed(%p) = %d\n",
+		device, device->blk_data.medium_changed);
+
+	return device->blk_data.medium_changed;
+}
+
 /*
  * Block frontend tape device open function.
  */
 static int
 tapeblock_open(struct inode *inode, struct file *filp)
 {
-	struct gendisk *disk = inode->i_bdev->bd_disk;
-	struct tape_device *device = disk->private_data;
-	int rc;
+	struct gendisk *	disk;
+	struct tape_device *	device;
+	int			rc;
+
+	disk   = inode->i_bdev->bd_disk;
+	device = tape_get_device_reference(disk->private_data);
+
+	if (device->required_tapemarks) {
+		DBF_EVENT(2, "TBLOCK: missing tapemarks\n");
+		PRINT_ERR("TBLOCK: Refusing to open tape with missing"
+			" end of file marks.\n");
+		rc = -EPERM;
+		goto put_device;
+	}
 
-	/*
-	 * FIXME: this new tapeblock_open function is from 2.5.69.
-	 * It doesn't do tape_get_device anymore but picks the device
-	 * pointer from disk->private_data. It is stored in 
-	 * tapeblock_setup_device but WITHOUT proper ref-counting.
-	 */
 	rc = tape_open(device);
 	if (rc)
 		goto put_device;
-	rc = tape_assign(device);
+
+	rc = tapeblock_revalidate_disk(disk);
 	if (rc)
 		goto release;
-	device->blk_data.block_position = -1;
-	rc = tapeblock_mediumdetect(device);
-	if (rc)
-		goto unassign;
+
+	/*
+	 * Note: The reference to <device> is hold until the release function
+	 *       is called.
+	 */
+	tape_state_set(device, TS_BLKUSE);
 	return 0;
 
- unassign:
-	tape_unassign(device);
- release:
+release:
 	tape_release(device);
  put_device:
 	tape_put_device(device);
@@ -334,6 +402,9 @@ tapeblock_open(struct inode *inode, stru
 
 /*
  * Block frontend tape device release function.
+ *
+ * Note: One reference to the tape device was made by the open function. So
+ *       we just get the pointer here and release the reference.
  */
 static int
 tapeblock_release(struct inode *inode, struct file *filp)
@@ -341,14 +412,54 @@ tapeblock_release(struct inode *inode, s
 	struct gendisk *disk = inode->i_bdev->bd_disk;
 	struct tape_device *device = disk->private_data;
 
+	tape_state_set(device, TS_IN_USE);
 	tape_release(device);
-	tape_unassign(device);
 	tape_put_device(device);
 
 	return 0;
 }
 
 /*
+ * Support of some generic block device IOCTLs.
+ */
+static int
+tapeblock_ioctl(
+	struct inode *		inode,
+	struct file *		file,
+	unsigned int		command,
+	unsigned long		arg
+) {
+	int rc;
+	int minor;
+	struct gendisk *disk = inode->i_bdev->bd_disk;
+	struct tape_device *device = disk->private_data;
+
+	rc     = 0;
+	disk   = inode->i_bdev->bd_disk;
+	if (!disk)
+		BUG();
+	device = disk->private_data;
+	if (!device)
+		BUG();
+	minor  = iminor(inode);
+
+	DBF_LH(6, "tapeblock_ioctl(0x%0x)\n", command);
+	DBF_LH(6, "device = %d:%d\n", tapeblock_major, minor);
+
+	switch (command) {
+		/* Refuse some IOCTL calls without complaining (mount). */
+		case 0x5310:		/* CDROMMULTISESSION */
+			rc = -EINVAL;
+			break;
+		default:
+			PRINT_WARN("invalid ioctl 0x%x\n", command);
+			rc = -EINVAL;
+	}
+
+	return rc;
+}
+
+/*
  * Initialize block device frontend.
  */
 int
diff -puN drivers/s390/char/tape_char.c~linus drivers/s390/char/tape_char.c
--- 25/drivers/s390/char/tape_char.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/char/tape_char.c	2004-01-19 22:17:23.000000000 -0800
@@ -19,8 +19,9 @@
 #include <asm/uaccess.h>
 
 #include "tape.h"
+#include "tape_std.h"
 
-#define PRINTK_HEADER "TCHAR:"
+#define PRINTK_HEADER "TAPE_CHAR: "
 
 #define TAPECHAR_MAJOR		0	/* get dynamic major */
 
@@ -52,12 +53,14 @@ static int tapechar_major = TAPECHAR_MAJ
 int
 tapechar_setup_device(struct tape_device * device)
 {
+	tape_hotplug_event(device, tapechar_major, TAPE_HOTPLUG_CHAR_ADD);
 	return 0;
 }
 
 void
 tapechar_cleanup_device(struct tape_device *device)
 {
+	tape_hotplug_event(device, tapechar_major, TAPE_HOTPLUG_CHAR_REMOVE);
 }
 
 /*
@@ -81,15 +84,27 @@ tapechar_check_idalbuffer(struct tape_de
 	struct idal_buffer *new;
 
 	if (device->char_data.idal_buf != NULL &&
-	    device->char_data.idal_buf->size >= block_size)
+	    device->char_data.idal_buf->size == block_size)
 		return 0;
-	/* The current idal buffer is not big enough. Allocate a new one. */
+
+	if (block_size > MAX_BLOCKSIZE) {
+		DBF_EVENT(3, "Invalid blocksize (%zd > %d)\n",
+			block_size, MAX_BLOCKSIZE);
+		PRINT_ERR("Invalid blocksize (%zd> %d)\n",
+			block_size, MAX_BLOCKSIZE);
+		return -EINVAL;
+	}
+
+	/* The current idal buffer is not correct. Allocate a new one. */
 	new = idal_buffer_alloc(block_size, 0);
 	if (new == NULL)
 		return -ENOMEM;
+
 	if (device->char_data.idal_buf != NULL)
 		idal_buffer_free(device->char_data.idal_buf);
+
 	device->char_data.idal_buf = new;
+
 	return 0;
 }
 
@@ -116,6 +131,16 @@ tapechar_read (struct file *filp, char *
 		DBF_EVENT(6, "TCHAR:ppos wrong\n");
 		return -EOVERFLOW;
 	}
+
+	/*
+	 * If the tape isn't terminated yet, do it now. And since we then
+	 * are at the end of the tape there wouldn't be anything to read
+	 * anyways. So we return immediatly.
+	 */
+	if(device->required_tapemarks) {
+		return tape_std_terminate_write(device);
+	}
+
 	/* Find out block size to use */
 	if (device->char_data.block_size != 0) {
 		if (count < device->char_data.block_size) {
@@ -126,10 +151,17 @@ tapechar_read (struct file *filp, char *
 		block_size = device->char_data.block_size;
 	} else {
 		block_size = count;
-		rc = tapechar_check_idalbuffer(device, block_size);
-		if (rc)
-			return rc;
 	}
+
+	rc = tapechar_check_idalbuffer(device, block_size);
+	if (rc)
+		return rc;
+
+#ifdef CONFIG_S390_TAPE_BLOCK
+	/* Changes position. */
+	device->blk_data.medium_changed = 1;
+#endif
+
 	DBF_EVENT(6, "TCHAR:nbytes: %lx\n", block_size);
 	/* Let the discipline build the ccw chain. */
 	request = device->discipline->read_block(device, block_size);
@@ -182,11 +214,18 @@ tapechar_write(struct file *filp, const 
 		nblocks = count / block_size;
 	} else {
 		block_size = count;
-		rc = tapechar_check_idalbuffer(device, block_size);
-		if (rc)
-			return rc;
 		nblocks = 1;
 	}
+
+	rc = tapechar_check_idalbuffer(device, block_size);
+	if (rc)
+		return rc;
+
+#ifdef CONFIG_S390_TAPE_BLOCK
+	/* Changes position. */
+	device->blk_data.medium_changed = 1;
+#endif
+
 	DBF_EVENT(6,"TCHAR:nbytes: %lx\n", block_size);
 	DBF_EVENT(6, "TCHAR:nblocks: %x\n", nblocks);
 	/* Let the discipline build the ccw chain. */
@@ -225,6 +264,17 @@ tapechar_write(struct file *filp, const 
 			rc = 0;
 
 	}
+
+	/*
+	 * After doing a write we always need two tapemarks to correctly
+	 * terminate the tape (one to terminate the file, the second to
+	 * flag the end of recorded data.
+	 * Since process_eov positions the tape in front of the written
+	 * tapemark it doesn't hurt to write two marks again.
+	 */
+	if (!rc)
+		device->required_tapemarks = 2;
+
 	return rc ? rc : written;
 }
 
@@ -237,24 +287,28 @@ tapechar_open (struct inode *inode, stru
 	struct tape_device *device;
 	int minor, rc;
 
+	DBF_EVENT(6, "TCHAR:open: %i:%i\n",
+		imajor(filp->f_dentry->d_inode),
+		iminor(filp->f_dentry->d_inode));
+
 	if (imajor(filp->f_dentry->d_inode) != tapechar_major)
 		return -ENODEV;
+
 	minor = iminor(filp->f_dentry->d_inode);
 	device = tape_get_device(minor / TAPE_MINORS_PER_DEV);
 	if (IS_ERR(device)) {
+		DBF_EVENT(3, "TCHAR:open: tape_get_device() failed\n");
 		return PTR_ERR(device);
 	}
-	DBF_EVENT(6, "TCHAR:open: %x\n", iminor(inode));
+
+
 	rc = tape_open(device);
 	if (rc == 0) {
-		rc = tape_assign(device);
-		if (rc == 0) {
-			filp->private_data = device;
-			return 0;
-		}
-		tape_release(device);
+		filp->private_data = device;
+		return 0;
 	}
 	tape_put_device(device);
+
 	return rc;
 }
 
@@ -267,29 +321,32 @@ tapechar_release(struct inode *inode, st
 {
 	struct tape_device *device;
 
-	device = (struct tape_device *) filp->private_data;
 	DBF_EVENT(6, "TCHAR:release: %x\n", iminor(inode));
-#if 0
-	// FIXME: this is broken. Either MTWEOF/MTWEOF/MTBSR is done
-	// EVERYTIME the user switches from write to something different
-	// or it is not done at all. The second is IMHO better because
-	// we should NEVER do something the user didn't request.
-	if (device->last_op == TO_WRI)
-		tapechar_terminate_write(device);
-#endif
+	device = (struct tape_device *) filp->private_data;
+
 	/*
-	 * If this is the rewinding tape minor then rewind.
+	 * If this is the rewinding tape minor then rewind. In that case we
+	 * write all required tapemarks. Otherwise only one to terminate the
+	 * file.
 	 */
-	if ((iminor(inode) & 1) != 0)
+	if ((iminor(inode) & 1) != 0) {
+		if (device->required_tapemarks)
+			tape_std_terminate_write(device);
 		tape_mtop(device, MTREW, 1);
+	} else {
+		if (device->required_tapemarks > 1) {
+			if (tape_mtop(device, MTWEOF, 1) == 0)
+				device->required_tapemarks--;
+		}
+	}
+
 	if (device->char_data.idal_buf != NULL) {
 		idal_buffer_free(device->char_data.idal_buf);
 		device->char_data.idal_buf = NULL;
 	}
-	device->char_data.block_size = 0;
 	tape_release(device);
-	tape_unassign(device);
-	tape_put_device(device);
+	filp->private_data = tape_put_device(device);
+
 	return 0;
 }
 
@@ -314,7 +371,40 @@ tapechar_ioctl(struct inode *inp, struct
 			return -EFAULT;
 		if (op.mt_count < 0)
 			return -EINVAL;
-		return tape_mtop(device, op.mt_op, op.mt_count);
+
+		/*
+		 * Operations that change tape position should write final
+		 * tapemarks.
+		 */
+		switch (op.mt_op) {
+			case MTFSF:
+			case MTBSF:
+			case MTFSR:
+			case MTBSR:
+			case MTREW:
+			case MTOFFL:
+			case MTEOM:
+			case MTRETEN:
+			case MTBSFM:
+			case MTFSFM:
+			case MTSEEK:
+#ifdef CONFIG_S390_TAPE_BLOCK
+				device->blk_data.medium_changed = 1;
+#endif
+				if (device->required_tapemarks)
+					tape_std_terminate_write(device);
+			default:
+				;
+		}
+		rc = tape_mtop(device, op.mt_op, op.mt_count);
+
+		if (op.mt_op == MTWEOF && rc == 0) {
+			if (op.mt_count > device->required_tapemarks)
+				device->required_tapemarks = 0;
+			else
+				device->required_tapemarks -= op.mt_count;
+		}
+		return rc;
 	}
 	if (no == MTIOCPOS) {
 		/* MTIOCPOS: query the tape position. */
@@ -333,19 +423,30 @@ tapechar_ioctl(struct inode *inp, struct
 		struct mtget get;
 
 		memset(&get, 0, sizeof(get));
-		rc = tape_mtop(device, MTTELL, 1);
-		if (rc < 0)
-			return rc;
 		get.mt_type = MT_ISUNKNOWN;
+		get.mt_resid = 0 /* device->devstat.rescnt */;
 		get.mt_dsreg = device->tape_state;
 		/* FIXME: mt_gstat, mt_erreg, mt_fileno */
-		get.mt_resid = 0 /* device->devstat.rescnt */;
 		get.mt_gstat = 0;
 		get.mt_erreg = 0;
 		get.mt_fileno = 0;
-		get.mt_blkno = rc;
+		get.mt_gstat  = device->tape_generic_status;
+
+		if (device->medium_state == MS_LOADED) {
+			rc = tape_mtop(device, MTTELL, 1);
+
+			if (rc < 0)
+				return rc;
+
+			if (rc == 0)
+				get.mt_gstat |= GMT_BOT(~0);
+
+			get.mt_blkno = rc;
+		}
+
 		if (copy_to_user((char *) data, &get, sizeof(get)) != 0)
 			return -EFAULT;
+
 		return 0;
 	}
 	/* Try the discipline ioctl function. */
diff -puN drivers/s390/char/tape_core.c~linus drivers/s390/char/tape_core.c
--- 25/drivers/s390/char/tape_core.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/char/tape_core.c	2004-01-19 22:17:23.000000000 -0800
@@ -23,9 +23,10 @@
 #include "tape.h"
 #include "tape_std.h"
 
-#define PRINTK_HEADER "T390:"
+#define PRINTK_HEADER "TAPE_CORE: "
 
-static void tape_do_irq (struct ccw_device *, unsigned long, struct irb *);
+static void __tape_do_irq (struct ccw_device *, unsigned long, struct irb *);
+static void __tape_remove_request(struct tape_device *, struct tape_request *);
 
 /*
  * One list to contain all tape devices of all disciplines, so
@@ -36,11 +37,6 @@ static struct list_head tape_device_list
 static rwlock_t tape_device_lock = RW_LOCK_UNLOCKED;
 
 /*
- * Wait queue for tape_delete_device waits.
- */
-static DECLARE_WAIT_QUEUE_HEAD(tape_delete_wq);
-
-/*
  * Pointer to debug area.
  */
 debug_info_t *tape_dbf_area = NULL;
@@ -50,8 +46,11 @@ debug_info_t *tape_dbf_area = NULL;
  */
 const char *tape_state_verbose[TS_SIZE] =
 {
-	[TS_UNUSED] = "UNUSED",	[TS_IN_USE] = "IN_USE",
-	[TS_INIT] = "INIT  ",	[TS_NOT_OPER] = "NOT_OP"
+	[TS_UNUSED]   = "UNUSED",
+	[TS_IN_USE]   = "IN_USE",
+	[TS_BLKUSE]   = "BLKUSE",
+	[TS_INIT]     = "INIT  ",
+	[TS_NOT_OPER] = "NOT_OP"
 };
 
 const char *tape_op_verbose[TO_SIZE] =
@@ -71,9 +70,105 @@ const char *tape_op_verbose[TO_SIZE] =
 };
 
 /*
+ * Some channel attached tape specific attributes.
+ *
+ * FIXME: In the future the first_minor and blocksize attribute should be
+ *        replaced by a link to the cdev tree.
+ */
+static ssize_t
+tape_medium_state_show(struct device *dev, char *buf)
+{
+	struct tape_device *tdev;
+
+	tdev = (struct tape_device *) dev->driver_data;
+	return snprintf(buf, PAGE_SIZE, "%i\n", tdev->medium_state);
+}
+
+static
+DEVICE_ATTR(medium_state, 0444, tape_medium_state_show, NULL);
+
+static ssize_t
+tape_first_minor_show(struct device *dev, char *buf)
+{
+	struct tape_device *tdev;
+
+	tdev = (struct tape_device *) dev->driver_data;
+	return snprintf(buf, PAGE_SIZE, "%i\n", tdev->first_minor);
+}
+
+static
+DEVICE_ATTR(first_minor, 0444, tape_first_minor_show, NULL);
+
+static ssize_t
+tape_state_show(struct device *dev, char *buf)
+{
+	struct tape_device *tdev;
+
+	tdev = (struct tape_device *) dev->driver_data;
+	return snprintf(buf, PAGE_SIZE, "%s\n", (tdev->first_minor < 0) ?
+		"OFFLINE" : tape_state_verbose[tdev->tape_state]);
+}
+
+static
+DEVICE_ATTR(state, 0444, tape_state_show, NULL);
+
+static ssize_t
+tape_operation_show(struct device *dev, char *buf)
+{
+	struct tape_device *tdev;
+	ssize_t rc;
+
+	tdev = (struct tape_device *) dev->driver_data;
+	if (tdev->first_minor < 0)
+		return snprintf(buf, PAGE_SIZE, "N/A\n");
+
+	spin_lock_irq(get_ccwdev_lock(tdev->cdev));
+	if (list_empty(&tdev->req_queue))
+		rc = snprintf(buf, PAGE_SIZE, "---\n");
+	else {
+		struct tape_request *req;
+
+		req = list_entry(tdev->req_queue.next, struct tape_request,
+			list);
+		rc = snprintf(buf, PAGE_SIZE, "%s\n", tape_op_verbose[req->op]);
+	}
+	spin_unlock_irq(get_ccwdev_lock(tdev->cdev));
+	return rc;
+}
+
+static
+DEVICE_ATTR(operation, 0444, tape_operation_show, NULL);
+
+static ssize_t
+tape_blocksize_show(struct device *dev, char *buf)
+{
+	struct tape_device *tdev;
+
+	tdev = (struct tape_device *) dev->driver_data;
+
+	return snprintf(buf, PAGE_SIZE, "%i\n", tdev->char_data.block_size);
+}
+
+static
+DEVICE_ATTR(blocksize, 0444, tape_blocksize_show, NULL);
+
+static struct attribute *tape_attrs[] = {
+	&dev_attr_medium_state.attr,
+	&dev_attr_first_minor.attr,
+	&dev_attr_state.attr,
+	&dev_attr_operation.attr,
+	&dev_attr_blocksize.attr,
+	NULL
+};
+
+static struct attribute_group tape_attr_group = {
+	.attrs = tape_attrs,
+};
+
+/*
  * Tape state functions
  */
-static void
+void
 tape_state_set(struct tape_device *device, enum tape_state newstate)
 {
 	const char *str;
@@ -139,14 +234,20 @@ __tape_halt_io(struct tape_device *devic
 	/* Check if interrupt has already been processed */
 	if (request->callback == NULL)
 		return 0;
+
 	rc = 0;
 	for (retries = 0; retries < 5; retries++) {
 		if (retries < 2)
 			rc = ccw_device_halt(device->cdev, (long) request);
 		else
 			rc = ccw_device_clear(device->cdev, (long) request);
-		if (rc == 0)
-			break;		/* termination successful */
+
+		if (rc == 0) {                     /* Termination successful */
+			request->rc     = -EIO;
+			request->status = TAPE_REQUEST_DONE;
+			return 0;
+		}
+
 		if (rc == -ENODEV)
 			DBF_EXCEPTION(2, "device gone, retry\n");
 		else if (rc == -EIO)
@@ -156,8 +257,7 @@ __tape_halt_io(struct tape_device *devic
 		else
 			BUG();
 	}
-	if (rc == 0)
-		request->status = TAPE_REQUEST_DONE;
+
 	return rc;
 }
 
@@ -207,8 +307,12 @@ tape_enable_device(struct tape_device *d
 {
 	int rc;
 
-	if (device->tape_state != TS_INIT)
+	DBF_LH(6, "tape_enable_device(%p, %p)\n", device, discipline);
+
+	if (device->tape_state != TS_INIT) {
+		DBF_LH(3, "Tapestate not INIT (%d)\n", device->tape_state);
 		return -EINVAL;
+	}
 
 	/* Let the discipline have a go at the device. */
 	device->discipline = discipline;
@@ -218,6 +322,7 @@ tape_enable_device(struct tape_device *d
 	rc = tape_assign_minor(device);
 	if (rc)
 		goto out_discipline;
+
 	rc = tapechar_setup_device(device);
 	if (rc)
 		goto out_minor;
@@ -250,7 +355,6 @@ tape_disable_device(struct tape_device *
 	struct tape_request *request;
 
 	spin_lock_irq(get_ccwdev_lock(device->cdev));
-	tape_state_set(device, TS_NOT_OPER);
 	/* Post remaining requests with -EIO */
 	list_for_each_safe(l, n, &device->req_queue) {
 		request = list_entry(l, struct tape_request, list);
@@ -258,7 +362,7 @@ tape_disable_device(struct tape_device *
 			__tape_halt_io(device, request);
 		list_del(&request->list);
 		/* Decrease ref_count for removed request. */
-		tape_put_device(device);
+		request->device = tape_put_device(device);
 		request->rc = -EIO;
 		if (request->callback != NULL)
 			request->callback(request, request->callback_data);
@@ -269,6 +373,9 @@ tape_disable_device(struct tape_device *
 	tapechar_cleanup_device(device);
 	device->discipline->cleanup_device(device);
 	tape_remove_minor(device);
+
+	tape_med_state_set(device, MS_UNKNOWN);
+	device->tape_state = TS_INIT;
 }
 
 /*
@@ -301,17 +408,51 @@ tape_alloc_device(void)
 	device->tape_state = TS_INIT;
 	device->medium_state = MS_UNKNOWN;
 	*device->modeset_byte = 0;
+	device->first_minor = -1;
+	atomic_set(&device->ref_count, 1);
+
 	return device;
 }
 
 /*
- * Free memory of a device structure.
+ * Get a reference to an existing device structure. This will automatically
+ * increment the reference count.
  */
-static void
-tape_free_device(struct tape_device *device)
+struct tape_device *
+tape_get_device_reference(struct tape_device *device)
 {
-	kfree(device->modeset_byte);
-	kfree(device);
+	DBF_EVENT(4, "tape_get_device_reference(%p) = %i\n", device,
+		atomic_inc_return(&device->ref_count));
+
+	return device;
+}
+
+/*
+ * Decrease the reference counter of a devices structure. If the
+ * reference counter reaches zero free the device structure.
+ * The function returns a NULL pointer to be used by the caller
+ * for clearing reference pointers.
+ */
+struct tape_device *
+tape_put_device(struct tape_device *device)
+{
+	int remain;
+
+	remain = atomic_dec_return(&device->ref_count);
+	if (remain > 0) {
+		DBF_EVENT(4, "tape_put_device(%p) -> %i\n", device, remain);
+	} else {
+		if (remain < 0) {
+			DBF_EVENT(4, "put device without reference\n");
+			PRINT_ERR("put device without reference\n");
+		} else {
+			DBF_EVENT(4, "tape_free_device(%p)\n", device);
+			kfree(device->modeset_byte);
+			kfree(device);
+		}
+	}
+
+	return NULL;			
 }
 
 /*
@@ -325,9 +466,8 @@ tape_get_device(int devindex)
 	device = ERR_PTR(-ENODEV);
 	read_lock(&tape_device_lock);
 	list_for_each_entry(tmp, &tape_device_list, node) {
-		if (tmp->first_minor * TAPE_MINORS_PER_DEV == devindex) {
-			device = tmp;
-			atomic_inc(&device->ref_count);
+		if (tmp->first_minor / TAPE_MINORS_PER_DEV == devindex) {
+			device = tape_get_device_reference(tmp);
 			break;
 		}
 	}
@@ -336,25 +476,6 @@ tape_get_device(int devindex)
 }
 
 /*
- * Decrease the reference counter of a devices structure. If the
- * reference counter reaches zero free the device structure and
- * wake up sleepers.
- */
-void
-tape_put_device(struct tape_device *device)
-{
-	if (atomic_dec_return(&device->ref_count) > 0)
-		return;
-	/*
-	 * Reference counter dropped to zero. This means
-	 * that the device is deleted and the last user
-	 * of the device structure is gone. That is what
-	 * tape_delete_device is waiting for. Do a wake up.
-	 */
-	wake_up(&tape_delete_wq);
-}
-
-/*
  * Driverfs tape probe function.
  */
 int
@@ -367,12 +488,12 @@ tape_generic_probe(struct ccw_device *cd
 	if (IS_ERR(device))
 		return -ENODEV;
 	PRINT_INFO("tape device %s found\n", bus_id);
-	atomic_inc(&device->ref_count);
 	cdev->dev.driver_data = device;
 	device->cdev = cdev;
-	cdev->handler = tape_do_irq;
+	cdev->handler = __tape_do_irq;
 
 	ccw_device_set_options(cdev, CCWDEV_DO_PATHGROUP);
+	sysfs_create_group(&cdev->dev.kobj, &tape_attr_group);
 
 	return 0;
 }
@@ -380,19 +501,14 @@ tape_generic_probe(struct ccw_device *cd
 /*
  * Driverfs tape remove function.
  */
-int
+void
 tape_generic_remove(struct ccw_device *cdev)
 {
-	struct tape_device *device;
-
-	device = cdev->dev.driver_data;
-	cdev->dev.driver_data = NULL;
-	if (device != NULL) {
-		tape_put_device(device);
-		wait_event(tape_delete_wq, atomic_read(&device->ref_count) == 0);
-		tape_free_device(device);
+	ccw_device_set_offline(cdev);
+	if (cdev->dev.driver_data != NULL) {
+		sysfs_remove_group(&cdev->dev.kobj, &tape_attr_group);
+		cdev->dev.driver_data = tape_put_device(cdev->dev.driver_data);
 	}
-	return 0;
 }
 
 /*
@@ -406,6 +522,8 @@ tape_alloc_request(int cplength, int dat
 	if (datasize > PAGE_SIZE || (cplength*sizeof(struct ccw1)) > PAGE_SIZE)
 		BUG();
 
+	DBF_LH(6, "tape_alloc_request(%d, %d)\n", cplength, datasize);
+
 	request = (struct tape_request *) kmalloc(sizeof(struct tape_request),
 						  GFP_KERNEL);
 	if (request == NULL) {
@@ -436,6 +554,9 @@ tape_alloc_request(int cplength, int dat
 		}
 		memset(request->cpdata, 0, datasize);
 	}
+	DBF_LH(6, "New request %p(%p/%p)\n", request, request->cpaddr,
+		request->cpdata);
+
 	return request;
 }
 
@@ -445,9 +566,10 @@ tape_alloc_request(int cplength, int dat
 void
 tape_free_request (struct tape_request * request)
 {
+	DBF_LH(6, "Free request %p\n", request);
+
 	if (request->device != NULL) {
-		tape_put_device(request->device);
-		request->device = NULL;
+		request->device = tape_put_device(request->device);
 	}
 	if (request->cpdata != NULL)
 		kfree(request->cpdata);
@@ -456,6 +578,56 @@ tape_free_request (struct tape_request *
 	kfree(request);
 }
 
+static inline void
+__tape_do_io_list(struct tape_device *device)
+{
+	struct list_head *l, *n;
+	struct tape_request *request;
+	int rc;
+
+	DBF_LH(6, "__tape_do_io_list(%p)\n", device);
+	/*
+	 * Try to start each request on request queue until one is
+	 * started successful.
+	 */
+	list_for_each_safe(l, n, &device->req_queue) {
+		request = list_entry(l, struct tape_request, list);
+#ifdef CONFIG_S390_TAPE_BLOCK
+		if (request->op == TO_BLOCK)
+			device->discipline->check_locate(device, request);
+#endif
+		rc = ccw_device_start(device->cdev, request->cpaddr,
+				      (unsigned long) request, 0x00,
+				      request->options);
+		if (rc == 0) {
+			request->status = TAPE_REQUEST_IN_IO;
+			break;
+		}
+		/* Start failed. Remove request and indicate failure. */
+		DBF_EVENT(1, "tape: DOIO failed with er = %i\n", rc);
+
+		/* Set ending status and do callback. */
+		request->rc = rc;
+		request->status = TAPE_REQUEST_DONE;
+		__tape_remove_request(device, request);
+	}
+}
+
+static void
+__tape_remove_request(struct tape_device *device, struct tape_request *request)
+{
+	/* Remove from request queue. */
+	list_del(&request->list);
+
+	/* Do callback. */
+	if (request->callback != NULL)
+		request->callback(request, request->callback_data);
+
+	/* Start next request. */
+	if (!list_empty(&device->req_queue))
+		__tape_do_io_list(device);
+}
+
 /*
  * Write sense data to console/dbf
  */
@@ -514,12 +686,24 @@ __tape_do_io(struct tape_device *device,
 {
 	int rc;
 
-	if (device->tape_state != TS_IN_USE)
-		return -ENODEV;
+	switch (request->op) {
+		case TO_MSEN:
+		case TO_ASSIGN:
+		case TO_UNASSIGN:
+		case TO_READ_ATTMSG:
+			if (device->tape_state == TS_INIT)
+				break;
+			if (device->tape_state == TS_UNUSED)
+				break;
+		default:
+			if (device->tape_state == TS_BLKUSE)
+				break;
+			if (device->tape_state != TS_IN_USE)
+				return -ENODEV;
+	}
 
 	/* Increase use count of device for the added request. */
-	atomic_inc(&device->ref_count);
-	request->device = device;
+	request->device = tape_get_device_reference(device);
 
 	if (list_empty(&device->req_queue)) {
 		/* No other requests are on the queue. Start this one. */
@@ -534,9 +718,11 @@ __tape_do_io(struct tape_device *device,
 			DBF_EVENT(1, "tape: DOIO failed with rc = %i\n", rc);
 			return rc;
 		}
+		DBF_LH(5, "Request %p added for execution.\n", request);
 		list_add(&request->list, &device->req_queue);
 		request->status = TAPE_REQUEST_IN_IO;
 	} else {
+		DBF_LH(5, "Request %p add to queue.\n", request);
 		list_add_tail(&request->list, &device->req_queue);
 		request->status = TAPE_REQUEST_QUEUED;
 	}
@@ -552,6 +738,8 @@ tape_do_io_async(struct tape_device *dev
 {
 	int rc;
 
+	DBF_LH(6, "tape_do_io_async(%p, %p)\n", device, request);
+
 	spin_lock_irq(get_ccwdev_lock(device->cdev));
 	/* Add request to request queue and try to start it. */
 	rc = __tape_do_io(device, request);
@@ -637,48 +825,11 @@ tape_do_io_interruptible(struct tape_dev
 	return rc;
 }
 
-static inline void
-__tape_do_io_list(struct tape_device *device)
-{
-	struct list_head *l, *n;
-	struct tape_request *request;
-	int rc;
-
-	if (device->tape_state != TS_IN_USE)
-		return;
-	/*
-	 * Try to start each request on request queue until one is
-	 * started successful.
-	 */
-	list_for_each_safe(l, n, &device->req_queue) {
-		request = list_entry(l, struct tape_request, list);
-#ifdef CONFIG_S390_TAPE_BLOCK
-		if (request->op == TO_BLOCK)
-			device->discipline->check_locate(device, request);
-#endif
-		rc = ccw_device_start(device->cdev, request->cpaddr,
-				      (unsigned long) request, 0x00,
-				      request->options);
-		if (rc == 0) {
-			request->status = TAPE_REQUEST_IN_IO;
-			break;
-		}
-		/* Start failed. Remove request and indicate failure. */
-		DBF_EVENT(1, "tape: DOIO failed with er = %i\n", rc);
-		list_del(&request->list);
-		/* Set ending status and do callback. */
-		request->rc = rc;
-		request->status = TAPE_REQUEST_DONE;
-		if (request->callback != NULL)
-			request->callback(request, request->callback_data);
-	}
-}
-
 /*
  * Tape interrupt routine, called from the ccw_device layer
  */
 static void
-tape_do_irq (struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
+__tape_do_irq (struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
 {
 	struct tape_device *device;
 	struct tape_request *request;
@@ -693,11 +844,13 @@ tape_do_irq (struct ccw_device *cdev, un
 	}
 	request = (struct tape_request *) intparm;
 
+	DBF_LH(6, "__tape_do_irq(device=%p, request=%p)\n", device, request);
+
 	/* May be an unsolicited irq */
 	if(request != NULL)
 		request->rescnt = irb->scsw.count;
 
-	if (irb->scsw.dstat != 0x0c){
+	if (irb->scsw.dstat != 0x0c) {
 		/* Set the 'ONLINE' flag depending on sense byte 1 */
 		if(*(((__u8 *) irb->ecw) + 1) & SENSE_DRIVE_ONLINE)
 			device->tape_generic_status |= GMT_ONLINE(~0);
@@ -718,6 +871,16 @@ tape_do_irq (struct ccw_device *cdev, un
 		DBF_EVENT(6, "tape:device is not operational\n");
 		return;
 	}
+
+	/*
+	 * Request that were canceled still come back with an interrupt.
+	 * To detect these request the state will be set to TAPE_REQUEST_DONE.
+	 */
+	if(request != NULL && request->status == TAPE_REQUEST_DONE) {
+		__tape_remove_request(device, request);
+		return;
+	}
+
 	rc = device->discipline->irq(device, request, irb);
 	/*
 	 * rc < 0 : request finished unsuccessfully.
@@ -729,6 +892,8 @@ tape_do_irq (struct ccw_device *cdev, un
 	final = 0;
 	switch (rc) {
 	case TAPE_IO_SUCCESS:
+		/* Upon normal completion the device _is_ online */
+		device->tape_generic_status |= GMT_ONLINE(~0);
 		final = 1;
 		break;
 	case TAPE_IO_PENDING:
@@ -748,8 +913,6 @@ tape_do_irq (struct ccw_device *cdev, un
 		break;
 	case TAPE_IO_STOP:
 		__tape_halt_io(device, request);
-		rc = -EIO;
-		final = 1;
 		break;
 	default:
 		if (rc > 0) {
@@ -767,59 +930,11 @@ tape_do_irq (struct ccw_device *cdev, un
 			/* Set ending status. */
 			request->rc = rc;
 			request->status = TAPE_REQUEST_DONE;
-			/* Remove from request queue. */
-			list_del(&request->list);
-			/* Do callback. */
-			if (request->callback != NULL)
-				request->callback(request, request->callback_data);
+			__tape_remove_request(device, request);
+		} else {
+			__tape_do_io_list(device);
 		}
-		/* Start next request. */
-		__tape_do_io_list(device);
-	}
-}
-
-/*
- * Lock a shared tape for our exclusive use.
- */
-int
-tape_assign(struct tape_device *device)
-{
-	int rc;
-
-	rc = device->discipline->assign(device);
-	if (rc) {
-		PRINT_WARN("(%s): assign failed - device might be busy\n",
-			   device->cdev->dev.bus_id);
-		DBF_EVENT(3, "(%s): assign failed - device might be busy\n",
-			  device->cdev->dev.bus_id);
-		return rc;
-	}
-	DBF_EVENT(3, "(%s): assign lpum = %02x\n",
-		  device->cdev->dev.bus_id, 
-		  0 /* FIXME: device->devstat.lpum */ );
-	return 0;
-}
-
-/*
- * Unlock a shared tape.
- */
-int
-tape_unassign(struct tape_device *device)
-{
-	int rc;
-
-	rc = device->discipline->unassign(device);
-	if (rc) {
-		PRINT_WARN("(%s): unassign failed\n",
-			   device->cdev->dev.bus_id);
-		DBF_EVENT(3, "(%s): unassign failed\n",
-			  device->cdev->dev.bus_id);
-		return rc;
 	}
-	DBF_EVENT(3, "(%s): unassign lpum = %02x\n",
-		  device->cdev->dev.bus_id,
-		  0 /* FIXME: device->devstat.lpum */ );
-	return 0;
 }
 
 /*
@@ -837,6 +952,9 @@ tape_open(struct tape_device *device)
 	} else if (device->tape_state == TS_IN_USE) {
 		DBF_EVENT(6, "TAPE:dbusy\n");
 		rc = -EBUSY;
+	} else if (device->tape_state == TS_BLKUSE) {
+		DBF_EVENT(6, "TAPE:dbusy\n");
+		rc = -EBUSY;
 	} else if (device->discipline != NULL &&
 		   !try_module_get(device->discipline->owner)) {
 		DBF_EVENT(6, "TAPE:nodisc\n");
@@ -884,7 +1002,7 @@ tape_mtop(struct tape_device *device, in
 
 	/* We assume that the backends can handle count up to 500. */
 	if (mt_op == MTBSR  || mt_op == MTFSR  || mt_op == MTFSF  ||
-	    mt_op == MTBSR  || mt_op == MTFSFM || mt_op == MTBSFM) {
+	    mt_op == MTBSF  || mt_op == MTFSFM || mt_op == MTBSFM) {
 		rc = 0;
 		for (; mt_count > 500; mt_count -= 500)
 			if ((rc = fn(device, 500)) != 0)
@@ -898,14 +1016,74 @@ tape_mtop(struct tape_device *device, in
 }
 
 /*
+ * Hutplug event support.
+ */
+void
+tape_hotplug_event(struct tape_device *device, int devmaj, int action) {
+#ifdef CONFIG_HOTPLUG
+	char *argv[3];
+	char *envp[8];
+	char  busid[20];
+	char  major[20];
+	char  minor[20];
+
+	/* Call the busid DEVNO to be compatible with old tape.agent. */
+	sprintf(busid, "DEVNO=%s",   device->cdev->dev.bus_id);
+	sprintf(major, "MAJOR=%d",   devmaj);
+	sprintf(minor, "MINOR=%d",   device->first_minor);
+
+	argv[0] = hotplug_path;
+	argv[1] = "tape";
+	argv[2] = NULL;
+
+	envp[0] = "HOME=/";
+	envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
+
+	switch (action) {
+		case TAPE_HOTPLUG_CHAR_ADD:
+		case TAPE_HOTPLUG_BLOCK_ADD:
+			envp[2] = "ACTION=add";
+			break;
+		case TAPE_HOTPLUG_CHAR_REMOVE:
+		case TAPE_HOTPLUG_BLOCK_REMOVE:
+			envp[2] = "ACTION=remove";
+			break;
+		default:
+			BUG();
+	}
+	switch (action) {
+		case TAPE_HOTPLUG_CHAR_ADD:
+		case TAPE_HOTPLUG_CHAR_REMOVE:
+			envp[3] = "INTERFACE=char";
+			break;
+		case TAPE_HOTPLUG_BLOCK_ADD:
+		case TAPE_HOTPLUG_BLOCK_REMOVE:
+			envp[3] = "INTERFACE=block";
+			break;
+		default:
+			BUG();
+	}
+	envp[4] = busid;
+	envp[5] = major;
+	envp[6] = minor;
+	envp[7] = NULL;
+
+	call_usermodehelper(argv[0], argv, envp, 0);
+#endif
+}
+
+/*
  * Tape init function.
  */
 static int
 tape_init (void)
 {
-	tape_dbf_area = debug_register ( "tape", 1, 2, 3*sizeof(long));
+	tape_dbf_area = debug_register ( "tape", 1, 2, 4*sizeof(long));
 	debug_register_view(tape_dbf_area, &debug_sprintf_view);
-	DBF_EVENT(3, "tape init: ($Revision: 1.26 $)\n");
+#ifdef DBF_LIKE_HELL
+	debug_set_level(tape_dbf_area, 6);
+#endif
+	DBF_EVENT(3, "tape init: ($Revision: 1.41 $)\n");
 	tape_proc_init();
 	tapechar_init ();
 	tapeblock_init ();
@@ -930,7 +1108,8 @@ tape_exit(void)
 MODULE_AUTHOR("(C) 2001 IBM Deutschland Entwicklung GmbH by Carsten Otte and "
 	      "Michael Holzheu (cotte@de.ibm.com,holzheu@de.ibm.com)");
 MODULE_DESCRIPTION("Linux on zSeries channel attached "
-		   "tape device driver ($Revision: 1.26 $)");
+		   "tape device driver ($Revision: 1.41 $)");
+MODULE_LICENSE("GPL");
 
 module_init(tape_init);
 module_exit(tape_exit);
@@ -941,6 +1120,7 @@ EXPORT_SYMBOL(tape_disable_device);
 EXPORT_SYMBOL(tape_generic_probe);
 EXPORT_SYMBOL(tape_enable_device);
 EXPORT_SYMBOL(tape_put_device);
+EXPORT_SYMBOL(tape_get_device_reference);
 EXPORT_SYMBOL(tape_state_verbose);
 EXPORT_SYMBOL(tape_op_verbose);
 EXPORT_SYMBOL(tape_state_set);
diff -puN drivers/s390/char/tape.h~linus drivers/s390/char/tape.h
--- 25/drivers/s390/char/tape.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/char/tape.h	2004-01-19 22:17:23.000000000 -0800
@@ -12,19 +12,33 @@
 #ifndef _TAPE_H
 #define _TAPE_H
 
+#include <asm/ccwdev.h>
+#include <asm/debug.h>
+#include <asm/idals.h>
 #include <linux/config.h>
 #include <linux/blkdev.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mtio.h>
 #include <linux/interrupt.h>
-#include <asm/ccwdev.h>
-#include <asm/debug.h>
-#include <asm/idals.h>
+#include <linux/workqueue.h>
 
 struct gendisk;
 
 /*
+ * Define DBF_LIKE_HELL for lots of messages in the debug feature.
+ */
+#define DBF_LIKE_HELL
+#ifdef  DBF_LIKE_HELL
+#define DBF_LH(level, str, ...) \
+do { \
+	debug_sprintf_event(tape_dbf_area, level, str, ## __VA_ARGS__); \
+} while (0)
+#else
+#define DBF_LH(level, str, ...) do {} while(0)
+#endif
+
+/*
  * macros s390 debug feature (dbf)
  */
 #define DBF_EVENT(d_level, d_str...) \
@@ -46,7 +60,11 @@ do { \
 #define TAPEBLOCK_HSEC_S2B	2
 #define TAPEBLOCK_RETRIES	5
 
-#define TAPE_BUSY(td) (td->treq != NULL)
+/* Event types for hotplug */
+#define TAPE_HOTPLUG_CHAR_ADD     1
+#define TAPE_HOTPLUG_BLOCK_ADD    2
+#define TAPE_HOTPLUG_CHAR_REMOVE  3
+#define TAPE_HOTPLUG_BLOCK_REMOVE 4
 
 enum tape_medium_state {
 	MS_UNKNOWN,
@@ -58,6 +76,7 @@ enum tape_medium_state {
 enum tape_state {
 	TS_UNUSED=0,
 	TS_IN_USE,
+	TS_BLKUSE,
 	TS_INIT,
 	TS_NOT_OPER,
 	TS_SIZE
@@ -130,8 +149,6 @@ struct tape_discipline {
 	struct module *owner;
 	int  (*setup_device)(struct tape_device *);
 	void (*cleanup_device)(struct tape_device *);
-	int (*assign)(struct tape_device *);
-	int (*unassign)(struct tape_device *);
 	int (*irq)(struct tape_device *, struct tape_request *, struct irb *);
 	struct tape_request *(*read_block)(struct tape_device *, size_t);
 	struct tape_request *(*write_block)(struct tape_device *, size_t);
@@ -168,48 +185,60 @@ struct tape_char_data {
 struct tape_blk_data
 {
 	/* Block device request queue. */
-	request_queue_t *request_queue;
-	spinlock_t request_queue_lock;
-	/* Block frontend tasklet */
-	struct tasklet_struct tasklet;
+	request_queue_t *	request_queue;
+	spinlock_t		request_queue_lock;
+
+	/* Task to move entries from block request to CCS request queue. */
+	struct work_struct	requeue_task;
+	atomic_t		requeue_scheduled;
+
 	/* Current position on the tape. */
-	long block_position;
-	struct gendisk *disk;
+	long			block_position;
+	int			medium_changed;
+	struct gendisk *	disk;
 };
 #endif
 
 /* Tape Info */
 struct tape_device {
 	/* entry in tape_device_list */
-	struct list_head node;
+	struct list_head		node;
 
-	struct ccw_device *cdev;
+	struct ccw_device *		cdev;
 
 	/* Device discipline information. */
-	struct tape_discipline *discipline;
-	void *discdata;
+	struct tape_discipline *	discipline;
+	void *				discdata;
 
 	/* Generic status flags */
-	long                    tape_generic_status;
+	long				tape_generic_status;
 
 	/* Device state information. */
-	wait_queue_head_t       state_change_wq;
-	enum tape_state         tape_state;
-	enum tape_medium_state  medium_state;
-	unsigned char          *modeset_byte;
+	wait_queue_head_t		state_change_wq;
+	enum tape_state			tape_state;
+	enum tape_medium_state		medium_state;
+	unsigned char *			modeset_byte;
 
 	/* Reference count. */
-	atomic_t ref_count;
+	atomic_t			ref_count;
 
 	/* Request queue. */
-	struct list_head req_queue;
+	struct list_head		req_queue;
+
+	/* Each tape device has (currently) two minor numbers. */
+	int				first_minor;
+
+	/* Number of tapemarks required for correct termination. */
+	int				required_tapemarks;
+
+	/* Block ID of the BOF */
+	unsigned int			bof;
 
-	int first_minor;	       /* each tape device has two minors */
 	/* Character device frontend data */
-	struct tape_char_data char_data;
+	struct tape_char_data		char_data;
 #ifdef CONFIG_S390_TAPE_BLOCK
 	/* Block dev frontend data */
-	struct tape_blk_data blk_data;
+	struct tape_blk_data		blk_data;
 #endif
 };
 
@@ -219,6 +248,7 @@ extern void tape_free_request(struct tap
 extern int tape_do_io(struct tape_device *, struct tape_request *);
 extern int tape_do_io_async(struct tape_device *, struct tape_request *);
 extern int tape_do_io_interruptible(struct tape_device *, struct tape_request *);
+void tape_hotplug_event(struct tape_device *, int major, int action);
 
 static inline int
 tape_do_io_free(struct tape_device *device, struct tape_request *request)
@@ -234,19 +264,19 @@ extern int tape_oper_handler(int irq, in
 extern void tape_noper_handler(int irq, int status);
 extern int tape_open(struct tape_device *);
 extern int tape_release(struct tape_device *);
-extern int tape_assign(struct tape_device *);
-extern int tape_unassign(struct tape_device *);
 extern int tape_mtop(struct tape_device *, int, int);
+extern void tape_state_set(struct tape_device *, enum tape_state);
 
 extern int tape_enable_device(struct tape_device *, struct tape_discipline *);
 extern void tape_disable_device(struct tape_device *device);
 
 /* Externals from tape_devmap.c */
 extern int tape_generic_probe(struct ccw_device *);
-extern int tape_generic_remove(struct ccw_device *);
+extern void tape_generic_remove(struct ccw_device *);
 
 extern struct tape_device *tape_get_device(int devindex);
-extern void tape_put_device(struct tape_device *);
+extern struct tape_device *tape_get_device_reference(struct tape_device *);
+extern struct tape_device *tape_put_device(struct tape_device *);
 
 /* Externals from tape_char.c */
 extern int tapechar_init(void);
diff -puN drivers/s390/char/tape_proc.c~linus drivers/s390/char/tape_proc.c
--- 25/drivers/s390/char/tape_proc.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/char/tape_proc.c	2004-01-19 22:17:23.000000000 -0800
@@ -18,7 +18,7 @@
 
 #include "tape.h"
 
-#define PRINTK_HEADER "T390:"
+#define PRINTK_HEADER "TAPE_PROC: "
 
 static const char *tape_med_st_verbose[MS_SIZE] =
 {
@@ -42,19 +42,19 @@ static int tape_proc_show(struct seq_fil
 
 	n = (unsigned long) v - 1;
 	if (!n) {
-		seq_printf(m, "TapeNo\tDevNo\tCuType\tCuModel\tDevType\t"
-			   "DevMod\tBlkSize\tState\tOp\tMedState\n");
+		seq_printf(m, "TapeNo\tBusID      CuType/Model\t"
+			"DevType/Model\tBlkSize\tState\tOp\tMedState\n");
 	}
 	device = tape_get_device(n);
 	if (IS_ERR(device))
 		return 0;
 	spin_lock_irq(get_ccwdev_lock(device->cdev));
 	seq_printf(m, "%d\t", (int) n);
-	seq_printf(m, "%s\t", device->cdev->dev.bus_id);
-	seq_printf(m, "%04X\t", device->cdev->id.cu_type);
+	seq_printf(m, "%-10.10s ", device->cdev->dev.bus_id);
+	seq_printf(m, "%04X/", device->cdev->id.cu_type);
 	seq_printf(m, "%02X\t", device->cdev->id.cu_model);
-	seq_printf(m, "%04X\t", device->cdev->id.dev_type);
-	seq_printf(m, "%02X\t", device->cdev->id.dev_model);
+	seq_printf(m, "%04X/", device->cdev->id.dev_type);
+	seq_printf(m, "%02X\t\t", device->cdev->id.dev_model);
 	if (device->char_data.block_size == 0)
 		seq_printf(m, "auto\t");
 	else
diff -puN drivers/s390/char/tape_std.c~linus drivers/s390/char/tape_std.c
--- 25/drivers/s390/char/tape_std.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/char/tape_std.c	2004-01-19 22:17:23.000000000 -0800
@@ -8,12 +8,14 @@
  *		 Michael Holzheu <holzheu@de.ibm.com>
  *		 Tuan Ngo-Anh <ngoanh@de.ibm.com>
  *		 Martin Schwidefsky <schwidefsky@de.ibm.com>
+ *		 Stefan Bader <shbader@de.ibm.com>
  */
 
 #include <linux/config.h>
 #include <linux/stddef.h>
 #include <linux/kernel.h>
 #include <linux/bio.h>
+#include <linux/timer.h>
 
 #include <asm/types.h>
 #include <asm/idals.h>
@@ -23,23 +25,72 @@
 #include "tape.h"
 #include "tape_std.h"
 
-#define PRINTK_HEADER "T3xxx:"
+#define PRINTK_HEADER "TAPE_STD: "
 
 /*
  * tape_std_assign
  */
+static void
+tape_std_assign_timeout(unsigned long data)
+{
+	struct tape_request *	request;
+	struct tape_device *	device;
+
+	request = (struct tape_request *) data;
+	if ((device = request->device) == NULL)
+		BUG();
+
+	spin_lock_irq(get_ccwdev_lock(device->cdev));
+	if (request->callback != NULL) {
+		DBF_EVENT(3, "%s: Assignment timeout. Device busy.\n",
+			device->cdev->dev.bus_id);
+		PRINT_ERR("%s: Assignment timeout. Device busy.\n",
+			device->cdev->dev.bus_id);
+		ccw_device_clear(device->cdev, (long) request);
+	}
+	spin_unlock_irq(get_ccwdev_lock(device->cdev));
+}
+
 int
 tape_std_assign(struct tape_device *device)
 {
+	int                  rc;
+	struct timer_list    timeout;
 	struct tape_request *request;
 
 	request = tape_alloc_request(2, 11);
 	if (IS_ERR(request))
 		return PTR_ERR(request);
+
 	request->op = TO_ASSIGN;
 	tape_ccw_cc(request->cpaddr, ASSIGN, 11, request->cpdata);
 	tape_ccw_end(request->cpaddr + 1, NOP, 0, NULL);
-	return tape_do_io_free(device, request);
+
+	/*
+	 * The assign command sometimes blocks if the device is assigned
+	 * to another host (actually this shouldn't happen but it does).
+	 * So we set up a timeout for this call.
+	 */
+	init_timer(&timeout);
+	timeout.function = tape_std_assign_timeout;
+	timeout.data     = (unsigned long) request;
+	timeout.expires  = jiffies + 2 * HZ;
+	add_timer(&timeout);
+
+	rc = tape_do_io_interruptible(device, request);
+
+	del_timer(&timeout);
+
+	if (rc != 0) {
+		PRINT_WARN("%s: assign failed - device might be busy\n",
+			device->cdev->dev.bus_id);
+		DBF_EVENT(3, "%s: assign failed - device might be busy\n",
+			device->cdev->dev.bus_id);
+	} else {
+		DBF_EVENT(3, "%s: Tape assigned\n", device->cdev->dev.bus_id);
+	}
+	tape_free_request(request);
+	return rc;
 }
 
 /*
@@ -48,30 +99,36 @@ tape_std_assign(struct tape_device *devi
 int
 tape_std_unassign (struct tape_device *device)
 {
+	int                  rc;
 	struct tape_request *request;
 
 	request = tape_alloc_request(2, 11);
 	if (IS_ERR(request))
 		return PTR_ERR(request);
+
 	request->op = TO_UNASSIGN;
 	tape_ccw_cc(request->cpaddr, UNASSIGN, 11, request->cpdata);
 	tape_ccw_end(request->cpaddr + 1, NOP, 0, NULL);
-	return tape_do_io_free(device, request);
+
+	if ((rc = tape_do_io(device, request)) != 0) {
+		DBF_EVENT(3, "%s: Unassign failed\n", device->cdev->dev.bus_id);
+		PRINT_WARN("%s: Unassign failed\n", device->cdev->dev.bus_id);
+	} else {
+		DBF_EVENT(3, "%s: Tape unassigned\n", device->cdev->dev.bus_id);
+	}
+	tape_free_request(request);
+	return rc;
 }
 
 /*
  * TAPE390_DISPLAY: Show a string on the tape display.
  */
 int
-tape_std_display(struct tape_device *device, int cmd, unsigned long arg)
+tape_std_display(struct tape_device *device, struct display_struct *disp)
 {
-	struct display_struct d_struct;
 	struct tape_request *request;
 	int rc;
 
-	if (copy_from_user(&d_struct, (char *) arg, sizeof(d_struct)) != 0)
-		return -EFAULT;
-
 	request = tape_alloc_request(2, 17);
 	if (IS_ERR(request)) {
 		DBF_EVENT(3, "TAPE: load display failed\n");
@@ -79,9 +136,10 @@ tape_std_display(struct tape_device *dev
 	}
 	request->op = TO_DIS;
 
-	*(unsigned char *) request->cpdata = d_struct.cntrl;
-	memcpy(((unsigned char *) request->cpdata) + 1, d_struct.message1, 8);
-	memcpy(((unsigned char *) request->cpdata) + 9, d_struct.message2, 8);
+	*(unsigned char *) request->cpdata = disp->cntrl;
+	DBF_EVENT(5, "TAPE: display cntrl=%04x\n", disp->cntrl);
+	memcpy(((unsigned char *) request->cpdata) + 1, disp->message1, 8);
+	memcpy(((unsigned char *) request->cpdata) + 9, disp->message2, 8);
 	ASCEBC(((unsigned char*) request->cpdata) + 1, 16);
 
 	tape_ccw_cc(request->cpaddr, LOAD_DISPLAY, 17, request->cpdata);
@@ -118,6 +176,25 @@ tape_std_read_block_id(struct tape_devic
 	return rc;
 }
 
+int
+tape_std_terminate_write(struct tape_device *device)
+{
+	int rc;
+
+	if(device->required_tapemarks == 0)
+		return 0;
+
+	DBF_LH(5, "tape%d: terminate write %dxEOF\n", device->first_minor,
+		device->required_tapemarks);
+
+	rc = tape_mtop(device, MTWEOF, device->required_tapemarks);
+	if (rc)
+		return rc;
+
+	device->required_tapemarks = 0;
+	return tape_mtop(device, MTBSR, 1);
+}
+
 /*
  * MTLOAD: Loads the tape.
  * The default implementation just wait until the tape medium state changes
@@ -138,6 +215,7 @@ tape_std_mtsetblk(struct tape_device *de
 {
 	struct idal_buffer *new;
 
+	DBF_LH(6, "tape_std_mtsetblk(%d)\n", count);
 	if (count <= 0) {
 		/*
 		 * Just set block_size to 0. tapechar_read/tapechar_write
@@ -151,6 +229,15 @@ tape_std_mtsetblk(struct tape_device *de
 	    device->char_data.idal_buf->size == count)
 		/* We already have a idal buffer of that size. */
 		return 0;
+
+	if (count > MAX_BLOCKSIZE) {
+		DBF_EVENT(3, "Invalid block size (%d > %d) given.\n",
+			count, MAX_BLOCKSIZE);
+		PRINT_ERR("Invalid block size (%d > %d) given.\n",
+			count, MAX_BLOCKSIZE);
+		return -EINVAL;
+	}
+
 	/* Allocate a new idal buffer. */
 	new = idal_buffer_alloc(count, 0);
 	if (new == NULL)
@@ -159,6 +246,9 @@ tape_std_mtsetblk(struct tape_device *de
 		idal_buffer_free(device->char_data.idal_buf);
 	device->char_data.idal_buf = new;
 	device->char_data.block_size = count;
+
+	DBF_LH(6, "new blocksize is %d\n", device->char_data.block_size);
+
 	return 0;
 }
 
@@ -192,6 +282,7 @@ tape_std_mtfsf(struct tape_device *devic
 			  device->modeset_byte);
 	ccw = tape_ccw_repeat(ccw, FORSPACEFILE, mt_count);
 	ccw = tape_ccw_end(ccw, NOP, 0, NULL);
+
 	/* execute it */
 	return tape_do_io_free(device, request);
 }
@@ -205,6 +296,7 @@ tape_std_mtfsr(struct tape_device *devic
 {
 	struct tape_request *request;
 	struct ccw1 *ccw;
+	int rc;
 
 	request = tape_alloc_request(mt_count + 2, 0);
 	if (IS_ERR(request))
@@ -215,8 +307,16 @@ tape_std_mtfsr(struct tape_device *devic
 			  device->modeset_byte);
 	ccw = tape_ccw_repeat(ccw, FORSPACEBLOCK, mt_count);
 	ccw = tape_ccw_end(ccw, NOP, 0, NULL);
+
 	/* execute it */
-	return tape_do_io_free(device, request);
+	rc = tape_do_io(device, request);
+	if (rc == 0 && request->rescnt > 0) {
+		DBF_LH(3, "FSR over tapemark\n");
+		rc = 1;
+	}
+	tape_free_request(request);
+
+	return rc;
 }
 
 /*
@@ -228,6 +328,7 @@ tape_std_mtbsr(struct tape_device *devic
 {
 	struct tape_request *request;
 	struct ccw1 *ccw;
+	int rc;
 
 	request = tape_alloc_request(mt_count + 2, 0);
 	if (IS_ERR(request))
@@ -238,8 +339,16 @@ tape_std_mtbsr(struct tape_device *devic
 			  device->modeset_byte);
 	ccw = tape_ccw_repeat(ccw, BACKSPACEBLOCK, mt_count);
 	ccw = tape_ccw_end(ccw, NOP, 0, NULL);
+
 	/* execute it */
-	return tape_do_io_free(device, request);
+	rc = tape_do_io(device, request);
+	if (rc == 0 && request->rescnt > 0) {
+		DBF_LH(3, "BSR over tapemark\n");
+		rc = 1;
+	}
+	tape_free_request(request);
+
+	return rc;
 }
 
 /*
@@ -260,6 +369,7 @@ tape_std_mtweof(struct tape_device *devi
 			  device->modeset_byte);
 	ccw = tape_ccw_repeat(ccw, WRITETAPEMARK, mt_count);
 	ccw = tape_ccw_end(ccw, NOP, 0, NULL);
+
 	/* execute it */
 	return tape_do_io_free(device, request);
 }
@@ -284,6 +394,7 @@ tape_std_mtbsfm(struct tape_device *devi
 			  device->modeset_byte);
 	ccw = tape_ccw_repeat(ccw, BACKSPACEFILE, mt_count);
 	ccw = tape_ccw_end(ccw, NOP, 0, NULL);
+
 	/* execute it */
 	return tape_do_io_free(device, request);
 }
@@ -309,18 +420,12 @@ tape_std_mtbsf(struct tape_device *devic
 	ccw = tape_ccw_repeat(ccw, BACKSPACEFILE, mt_count);
 	ccw = tape_ccw_end(ccw, NOP, 0, NULL);
 	/* execute it */
-	rc = tape_do_io(device, request);
+	rc = tape_do_io_free(device, request);
 	if (rc == 0) {
-		request->op = TO_FSF;
-		/* need to skip forward over the filemark. */
-		tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1,
-			    device->modeset_byte);
-		tape_ccw_cc(request->cpaddr + 1, FORSPACEFILE, 0, NULL);
-		tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL);
-		/* execute it */
-		rc = tape_do_io(device, request);
+		rc = tape_mtop(device, MTFSR, 1);
+		if (rc > 0)
+			rc = 0;
 	}
-	tape_free_request(request);
 	return rc;
 }
 
@@ -346,18 +451,13 @@ tape_std_mtfsfm(struct tape_device *devi
 	ccw = tape_ccw_repeat(ccw, FORSPACEFILE, mt_count);
 	ccw = tape_ccw_end(ccw, NOP, 0, NULL);
 	/* execute it */
-	rc = tape_do_io(device, request);
+	rc = tape_do_io_free(device, request);
 	if (rc == 0) {
-		request->op = TO_BSF;
-		/* need to skip forward over the filemark. */
-		tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1,
-			    device->modeset_byte);
-		tape_ccw_cc(request->cpaddr + 1, BACKSPACEFILE, 0, NULL);
-		tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL);
-		/* execute it */
-		rc = tape_do_io(device, request);
+		rc = tape_mtop(device, MTBSR, 1);
+		if (rc > 0)
+			rc = 0;
 	}
-	tape_free_request(request);
+
 	return rc;
 }
 
@@ -378,6 +478,7 @@ tape_std_mtrew(struct tape_device *devic
 		    device->modeset_byte);
 	tape_ccw_cc(request->cpaddr + 1, REWIND, 0, NULL);
 	tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL);
+
 	/* execute it */
 	return tape_do_io_free(device, request);
 }
@@ -399,6 +500,7 @@ tape_std_mtoffl(struct tape_device *devi
 	tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
 	tape_ccw_cc(request->cpaddr + 1, REWIND_UNLOAD, 0, NULL);
 	tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL);
+
 	/* execute it */
 	return tape_do_io_free(device, request);
 }
@@ -430,22 +532,28 @@ tape_std_mtnop(struct tape_device *devic
 int
 tape_std_mteom(struct tape_device *device, int mt_count)
 {
-	struct tape_request *request;
+	int rc;
 
-	request = tape_alloc_request(4, 0);
-	if (IS_ERR(request))
-		return PTR_ERR(request);
-	request->op = TO_FSF;
-	/* setup ccws */
-	tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
-	tape_ccw_cc(request->cpaddr + 1,FORSPACEFILE, 0, NULL);
-	tape_ccw_cc(request->cpaddr + 2, NOP, 0, NULL);
-	tape_ccw_end(request->cpaddr + 3, CCW_CMD_TIC, 0, request->cpaddr);
-	/* execute it */
-	tape_do_io_interruptible(device, request);
-	tape_free_request(request);
-	/* MTEOM/MTRETEN errors get ignored. */
-	return 0;
+	/*
+	 * Seek from the beginning of tape (rewind).
+	 */
+	if ((rc = tape_mtop(device, MTREW, 1)) < 0)
+		return rc;
+
+	/*
+	 * The logical end of volume is given by two sewuential tapemarks.
+	 * Look for this by skipping to the next file (over one tapemark)
+	 * and then test for another one (fsr returns 1 if a tapemark was
+	 * encountered).
+	 */
+	do {
+		if ((rc = tape_mtop(device, MTFSF, 1)) < 0)
+			return rc;
+		if ((rc = tape_mtop(device, MTFSR, 1)) < 0)
+			return rc;
+	} while (rc == 0);
+
+	return tape_mtop(device, MTBSR, 1);
 }
 
 /*
@@ -469,7 +577,7 @@ tape_std_mtreten(struct tape_device *dev
 	/* execute it, MTRETEN rc gets ignored */
 	rc = tape_do_io_interruptible(device, request);
 	tape_free_request(request);
-	return tape_std_mtrew(device, 1);
+	return tape_mtop(device, MTREW, 1);
 }
 
 /*
@@ -480,7 +588,7 @@ tape_std_mterase(struct tape_device *dev
 {
 	struct tape_request *request;
 
-	request = tape_alloc_request(5, 0);
+	request = tape_alloc_request(6, 0);
 	if (IS_ERR(request))
 		return PTR_ERR(request);
 	request->op = TO_DSE;
@@ -489,7 +597,9 @@ tape_std_mterase(struct tape_device *dev
 	tape_ccw_cc(request->cpaddr + 1, REWIND, 0, NULL);
 	tape_ccw_cc(request->cpaddr + 2, ERASE_GAP, 0, NULL);
 	tape_ccw_cc(request->cpaddr + 3, DATA_SEC_ERASE, 0, NULL);
-	tape_ccw_end(request->cpaddr + 4, NOP, 0, NULL);
+	tape_ccw_cc(request->cpaddr + 4, REWIND, 0, NULL);
+	tape_ccw_end(request->cpaddr + 5, NOP, 0, NULL);
+
 	/* execute it */
 	return tape_do_io_free(device, request);
 }
@@ -500,18 +610,7 @@ tape_std_mterase(struct tape_device *dev
 int
 tape_std_mtunload(struct tape_device *device, int mt_count)
 {
-	struct tape_request *request;
-
-	request = tape_alloc_request(3, 32);
-	if (IS_ERR(request))
-		return PTR_ERR(request);
-	request->op = TO_RUN;
-	/* setup ccws */
-	tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
-	tape_ccw_cc(request->cpaddr + 1, REWIND_UNLOAD, 0, NULL);
-	tape_ccw_end(request->cpaddr + 2, SENSE, 32, request->cpdata);
-	/* execute it */
-	return tape_do_io_free(device, request);
+	return tape_mtop(device, MTOFFL, mt_count);
 }
 
 /*
diff -puN drivers/s390/char/tape_std.h~linus drivers/s390/char/tape_std.h
--- 25/drivers/s390/char/tape_std.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/char/tape_std.h	2004-01-19 22:17:23.000000000 -0800
@@ -10,9 +10,16 @@
  */
 
 #ifndef _TAPE_STD_H
-
 #define _TAPE_STD_H
 
+#include <asm/tape390.h>
+
+/*
+ * Biggest block size to handle. Currently 64K because we only build
+ * channel programs without data chaining.
+ */
+#define MAX_BLOCKSIZE   65535
+
 /*
  * The CCW commands for the Tape type of command.
  */
@@ -105,7 +112,8 @@ struct tape_request *tape_std_bwrite(str
 int tape_std_assign(struct tape_device *);
 int tape_std_unassign(struct tape_device *);
 int tape_std_read_block_id(struct tape_device *device, __u64 *id);
-int tape_std_display(struct tape_device *, int, unsigned long);
+int tape_std_display(struct tape_device *, struct display_struct *disp);
+int tape_std_terminate_write(struct tape_device *);
 
 /* Standard magnetic tape commands. */
 int tape_std_mtbsf(struct tape_device *, int);
diff -puN /dev/null drivers/s390/char/tty3270.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/s390/char/tty3270.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,1828 @@
+/*
+ *  drivers/s390/char/tty3270.c
+ *    IBM/3270 Driver - tty functions.
+ *
+ *  Author(s):
+ *    Original 3270 Code for 2.4 written by Richard Hitt (UTS Global)
+ *    Rewritten for 2.5 by Martin Schwidefsky <schwidefsky@de.ibm.com>
+ *	-- Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kdev_t.h>
+#include <linux/tty.h>
+#include <linux/vt_kern.h>
+#include <linux/init.h>
+#include <linux/console.h>
+#include <linux/interrupt.h>
+
+#include <linux/slab.h>
+#include <linux/bootmem.h>
+
+#include <asm/ccwdev.h>
+#include <asm/cio.h>
+#include <asm/ebcdic.h>
+#include <asm/uaccess.h>
+
+
+#include "raw3270.h"
+#include "keyboard.h"
+
+#define TTY3270_CHAR_BUF_SIZE 256
+#define TTY3270_OUTPUT_BUFFER_SIZE 1024
+#define TTY3270_STRING_PAGES 5
+
+struct tty_driver *tty3270_driver;
+
+struct raw3270_fn tty3270_fn;
+
+struct tty3270_cell {
+	unsigned char character;
+	unsigned char highlight;
+	unsigned char f_color;
+};
+
+struct tty3270_line {
+	struct tty3270_cell *cells;
+	int len;
+};
+
+#define ESCAPE_NPAR 8
+
+/*
+ * The main tty view data structure.
+ * FIXME:
+ * 1) describe line orientation & lines list concept against screen
+ * 2) describe conversion of screen to lines
+ * 3) describe line format.
+ */
+struct tty3270 {
+	struct raw3270_view view;
+	struct tty_struct *tty;		/* Pointer to tty structure */
+	void **freemem_pages;		/* Array of pages used for freemem. */
+	struct list_head freemem;	/* List of free memory for strings. */
+
+	/* Output stuff. */
+	struct list_head lines;		/* List of lines. */
+	struct list_head update;	/* List of lines to update. */
+	unsigned char wcc;		/* Write control character. */
+	int nr_lines;			/* # lines in list. */
+	int nr_up;			/* # lines up in history. */
+	unsigned long update_flags;	/* Update indication bits. */
+	struct string *status;		/* Lower right of display. */
+	struct raw3270_request *write;	/* Single write request. */
+	struct timer_list timer;	/* Output delay timer. */
+
+	/* Current tty screen. */
+	unsigned int cx, cy;		/* Current output position. */
+	unsigned int highlight;		/* Blink/reverse/underscore */
+	unsigned int f_color;		/* Foreground color */
+	struct tty3270_line *screen;
+
+	/* Input stuff. */
+	struct string *prompt;		/* Output string for input area. */
+	struct string *input;		/* Input string for read request. */
+	struct raw3270_request *read;	/* Single read request. */
+	struct raw3270_request *kreset;	/* Single keyboard reset request. */
+	unsigned char inattr;		/* Visible/invisible input. */
+	int throttle, attn;		/* tty throttle/unthrottle. */
+	struct tasklet_struct readlet;	/* Tasklet to issue read request. */
+	struct kbd_data *kbd;		/* key_maps stuff. */
+
+	/* Escape sequence parsing. */
+	int esc_state, esc_ques, esc_npar;
+	int esc_par[ESCAPE_NPAR];
+	unsigned int saved_cx, saved_cy;
+	unsigned int saved_highlight, saved_f_color;
+
+	/* Command recalling. */
+	struct list_head rcl_lines;	/* List of recallable lines. */
+	struct list_head *rcl_walk;	/* Point in rcl_lines list. */
+	int rcl_nr, rcl_max;		/* Number/max number of rcl_lines. */
+
+	/* Character array for put_char/flush_chars. */
+	unsigned int char_count;
+	char char_buf[TTY3270_CHAR_BUF_SIZE];
+};
+
+/* tty3270->update_flags. See tty3270_update for details. */
+#define TTY_UPDATE_ERASE	1	/* Use EWRITEA instead of WRITE. */
+#define TTY_UPDATE_LIST		2	/* Update lines in tty3270->update. */
+#define TTY_UPDATE_INPUT	4	/* Update input line. */
+#define TTY_UPDATE_STATUS	8	/* Update status line. */
+#define TTY_UPDATE_ALL		15
+
+static void tty3270_update(struct tty3270 *);
+
+/*
+ * Setup timeout for a device. On timeout trigger an update.
+ */
+void
+tty3270_set_timer(struct tty3270 *tp, int expires)
+{
+	if (expires == 0) {
+		if (timer_pending(&tp->timer)) {
+			raw3270_put_view(&tp->view);
+			del_timer(&tp->timer);
+		}
+		return;
+	}
+	if (timer_pending(&tp->timer)) {
+		if (mod_timer(&tp->timer, jiffies + expires))
+			return;
+	}
+	raw3270_get_view(&tp->view);
+	tp->timer.function = (void (*)(unsigned long)) tty3270_update;
+	tp->timer.data = (unsigned long) tp;
+	tp->timer.expires = jiffies + expires;
+	add_timer(&tp->timer);
+}
+
+/*
+ * The input line are the two last lines of the screen.
+ */
+static void
+tty3270_update_prompt(struct tty3270 *tp, char *input, int count)
+{
+	struct string *line;
+	unsigned int off;
+
+	line = tp->prompt;
+	if (count != 0)
+		line->string[5] = TF_INMDT;
+	else
+		line->string[5] = tp->inattr;
+	if (count > tp->view.cols * 2 - 11)
+		count = tp->view.cols * 2 - 11;
+	memcpy(line->string + 6, input, count);
+	line->string[6 + count] = TO_IC;
+	/* Clear to end of input line. */
+	if (count < tp->view.cols * 2 - 11) {
+		line->string[7 + count] = TO_RA;
+		line->string[10 + count] = 0;
+		off = tp->view.cols * tp->view.rows - 9;
+		raw3270_buffer_address(tp->view.dev, line->string+count+8, off);
+		line->len = 11 + count;
+	} else
+		line->len = 7 + count;
+	tp->update_flags |= TTY_UPDATE_INPUT;
+}
+
+static void
+tty3270_create_prompt(struct tty3270 *tp)
+{
+	static const unsigned char blueprint[] =
+		{ TO_SBA, 0, 0, 0x6e, TO_SF, TF_INPUT,
+		  /* empty input string */
+		  TO_IC, TO_RA, 0, 0, 0 };
+	struct string *line;
+	unsigned int offset;
+
+	line = alloc_string(&tp->freemem,
+			    sizeof(blueprint) + tp->view.cols * 2 - 9);
+	tp->prompt = line;
+	tp->inattr = TF_INPUT;
+	/* Copy blueprint to status line */
+	memcpy(line->string, blueprint, sizeof(blueprint));
+	line->len = sizeof(blueprint);
+	/* Set output offsets. */
+	offset = tp->view.cols * (tp->view.rows - 2);
+	raw3270_buffer_address(tp->view.dev, line->string + 1, offset);
+	offset = tp->view.cols * tp->view.rows - 9;
+	raw3270_buffer_address(tp->view.dev, line->string + 8, offset);
+
+	/* Allocate input string for reading. */
+	tp->input = alloc_string(&tp->freemem, tp->view.cols * 2 - 9 + 6);
+}
+
+/*
+ * The status line is the last line of the screen. It shows the string
+ * "Running"/"Holding" in the lower right corner of the screen.
+ */
+static void
+tty3270_update_status(struct tty3270 * tp)
+{
+	char *str;
+
+	str = (tp->nr_up != 0) ? "History" : "Running";
+	memcpy(tp->status->string + 8, str, 7);
+	codepage_convert(tp->view.ascebc, tp->status->string + 8, 7);
+	tp->update_flags |= TTY_UPDATE_STATUS;
+}
+
+static void
+tty3270_create_status(struct tty3270 * tp)
+{
+	static const unsigned char blueprint[] =
+		{ TO_SBA, 0, 0, TO_SF, TF_LOG, TO_SA, TAT_COLOR, TAC_GREEN,
+		  0, 0, 0, 0, 0, 0, 0, TO_SF, TF_LOG, TO_SA, TAT_COLOR,
+		  TAC_RESET };
+	struct string *line;
+	unsigned int offset;
+
+	line = alloc_string(&tp->freemem,sizeof(blueprint));
+	tp->status = line;
+	/* Copy blueprint to status line */
+	memcpy(line->string, blueprint, sizeof(blueprint));
+	/* Set address to start of status string (= last 9 characters). */
+	offset = tp->view.cols * tp->view.rows - 9;
+	raw3270_buffer_address(tp->view.dev, line->string + 1, offset);
+}
+
+/*
+ * Set output offsets to 3270 datastream fragment of a tty string.
+ * (TO_SBA offset at the start and TO_RA offset at the end of the string)
+ */
+static void
+tty3270_update_string(struct tty3270 *tp, struct string *line, int nr)
+{
+	unsigned char *cp;
+
+	raw3270_buffer_address(tp->view.dev, line->string + 1,
+			       tp->view.cols * nr);
+	cp = line->string + line->len - 4;
+	if (*cp == TO_RA)
+		raw3270_buffer_address(tp->view.dev, cp + 1,
+				       tp->view.cols * (nr + 1));
+}
+
+/*
+ * Rebuild update list to print all lines.
+ */
+static void
+tty3270_rebuild_update(struct tty3270 *tp)
+{
+	struct string *s, *n;
+	int line, nr_up;
+
+	/* 
+	 * Throw away update list and create a new one,
+	 * containing all lines that will fit on the screen.
+	 */
+	list_for_each_entry_safe(s, n, &tp->update, update)
+		list_del_init(&s->update);
+	line = tp->view.rows - 3;
+	nr_up = tp->nr_up;
+	list_for_each_entry_reverse(s, &tp->lines, list) {
+		if (nr_up > 0) {
+			nr_up--;
+			continue;
+		}
+		tty3270_update_string(tp, s, line);
+		list_add(&s->update, &tp->update);
+		if (--line < 0)
+			break;
+	}
+	tp->update_flags |= TTY_UPDATE_LIST;
+}
+
+/*
+ * Alloc string for size bytes. If there is not enough room in
+ * freemem, free strings until there is room.
+ */
+static struct string *
+tty3270_alloc_string(struct tty3270 *tp, size_t size)
+{
+	struct string *s, *n;
+
+	s = alloc_string(&tp->freemem, size);
+	if (s)
+		return s;
+	list_for_each_entry_safe(s, n, &tp->lines, list) {
+		BUG_ON(tp->nr_lines <= tp->view.rows - 2);
+		list_del(&s->list);
+		if (!list_empty(&s->update))
+			list_del(&s->update);
+		tp->nr_lines--;
+		if (free_string(&tp->freemem, s) >= size)
+			break;
+	}
+	s = alloc_string(&tp->freemem, size);
+	BUG_ON(!s);
+	if (tp->nr_up != 0 &&
+	    tp->nr_up + tp->view.rows - 2 >= tp->nr_lines) {
+		tp->nr_up = tp->nr_lines - tp->view.rows + 2;
+		tty3270_rebuild_update(tp);
+		tty3270_update_status(tp);
+	}
+	return s;
+}
+
+/*
+ * Add an empty line to the list.
+ */
+static void
+tty3270_blank_line(struct tty3270 *tp)
+{
+	static const unsigned char blueprint[] =
+		{ TO_SBA, 0, 0, TO_SA, TAT_EXTHI, TAX_RESET,
+		  TO_SA, TAT_COLOR, TAC_RESET, TO_RA, 0, 0, 0 };
+	struct string *s;
+
+	s = tty3270_alloc_string(tp, sizeof(blueprint));
+	memcpy(s->string, blueprint, sizeof(blueprint));
+	s->len = sizeof(blueprint);
+	list_add_tail(&s->list, &tp->lines);
+	tp->nr_lines++;
+	if (tp->nr_up != 0)
+		tp->nr_up++;
+}
+
+/*
+ * Write request completion callback.
+ */
+static void
+tty3270_write_callback(struct raw3270_request *rq, void *data)
+{
+	struct tty3270 *tp;
+
+	tp = (struct tty3270 *) rq->view;
+	if (rq->rc != 0) {
+		/* Write wasn't successfull. Refresh all. */
+		tty3270_rebuild_update(tp);
+		tp->update_flags = TTY_UPDATE_ALL;
+		tty3270_set_timer(tp, 1);
+	}
+	raw3270_request_reset(rq);
+	xchg(&tp->write, rq);
+}
+
+/*
+ * Update 3270 display.
+ */
+static void
+tty3270_update(struct tty3270 *tp)
+{
+	static char invalid_sba[2] = { 0xff, 0xff };
+	struct raw3270_request *wrq;
+	unsigned long updated;
+	struct string *s, *n;
+	char *sba, *str;
+	int rc, len;
+
+	wrq = xchg(&tp->write, 0);
+	if (!wrq) {
+		tty3270_set_timer(tp, 1);
+		return;
+	}
+
+	spin_lock(&tp->view.lock);
+	updated = 0;
+	if (tp->update_flags & TTY_UPDATE_ERASE) {
+		/* Use erase write alternate to erase display. */
+		raw3270_request_set_cmd(wrq, TC_EWRITEA);
+		updated |= TTY_UPDATE_ERASE;
+	} else
+		raw3270_request_set_cmd(wrq, TC_WRITE);
+
+	raw3270_request_add_data(wrq, &tp->wcc, 1);
+	tp->wcc = TW_NONE;
+
+	/*
+	 * Update status line.
+	 */
+	if (tp->update_flags & TTY_UPDATE_STATUS)
+		if (raw3270_request_add_data(wrq, tp->status->string,
+					     tp->status->len) == 0)
+			updated |= TTY_UPDATE_STATUS;
+
+	/*
+	 * Write input line.
+	 */
+	if (tp->update_flags & TTY_UPDATE_INPUT)
+		if (raw3270_request_add_data(wrq, tp->prompt->string,
+					     tp->prompt->len) == 0)
+			updated |= TTY_UPDATE_INPUT;
+
+	sba = invalid_sba;
+	
+	if (tp->update_flags & TTY_UPDATE_LIST) {
+		/* Write strings in the update list to the screen. */
+		list_for_each_entry_safe(s, n, &tp->update, update) {
+			str = s->string;
+			len = s->len;
+			/*
+			 * Skip TO_SBA at the start of the string if the
+			 * last output position matches the start address
+			 * of this line.
+			 */
+			if (s->string[1] == sba[0] && s->string[2] == sba[1])
+				str += 3, len -= 3;
+			if (raw3270_request_add_data(wrq, str, len) != 0)
+				break;
+			list_del_init(&s->update);
+			sba = s->string + s->len - 3;
+		}
+		if (list_empty(&tp->update))
+			updated |= TTY_UPDATE_LIST;
+	}
+	wrq->callback = tty3270_write_callback;
+	rc = raw3270_start(&tp->view, wrq);
+	if (rc == 0) {
+		tp->update_flags &= ~updated;
+		if (tp->update_flags)
+			tty3270_set_timer(tp, 1);
+	} else {
+		raw3270_request_reset(wrq);
+		xchg(&tp->write, wrq);
+	}
+	spin_unlock(&tp->view.lock);
+	raw3270_put_view(&tp->view);
+}
+
+/*
+ * Command recalling.
+ */
+static void
+tty3270_rcl_add(struct tty3270 *tp, char *input, int len)
+{
+	struct string *s;
+
+	tp->rcl_walk = 0;
+	if (len <= 0)
+		return;
+	if (tp->rcl_nr >= tp->rcl_max) {
+		s = list_entry(tp->rcl_lines.next, struct string, list);
+		list_del(&s->list);
+		free_string(&tp->freemem, s);
+		tp->rcl_nr--;
+	}
+	s = tty3270_alloc_string(tp, len);
+	memcpy(s->string, input, len);
+	list_add_tail(&s->list, &tp->rcl_lines);
+	tp->rcl_nr++;
+}
+
+static void
+tty3270_rcl_backward(struct kbd_data *kbd)
+{
+	struct tty3270 *tp;
+	struct string *s;
+
+	tp = kbd->tty->driver_data;
+	spin_lock_bh(&tp->view.lock);
+	if (tp->inattr == TF_INPUT) {
+		if (tp->rcl_walk && tp->rcl_walk->prev != &tp->rcl_lines)
+			tp->rcl_walk = tp->rcl_walk->prev;
+		else if (!list_empty(&tp->rcl_lines))
+			tp->rcl_walk = tp->rcl_lines.prev;
+		s = tp->rcl_walk ? 
+			list_entry(tp->rcl_walk, struct string, list) : 0;
+		if (tp->rcl_walk) {
+			s = list_entry(tp->rcl_walk, struct string, list);
+			tty3270_update_prompt(tp, s->string, s->len);
+		} else
+			tty3270_update_prompt(tp, 0, 0);
+		tty3270_set_timer(tp, 1);
+	}
+	spin_unlock_bh(&tp->view.lock);
+}
+
+/*
+ * Deactivate tty view.
+ */
+static void
+tty3270_exit_tty(struct kbd_data *kbd)
+{
+	struct tty3270 *tp;
+
+	tp = kbd->tty->driver_data;
+	raw3270_deactivate_view(&tp->view);
+}
+
+/*
+ * Scroll forward in history.
+ */
+static void
+tty3270_scroll_forward(struct kbd_data *kbd)
+{
+	struct tty3270 *tp;
+	int nr_up;
+
+	tp = kbd->tty->driver_data;
+	spin_lock_bh(&tp->view.lock);
+	nr_up = tp->nr_up - tp->view.rows + 2;
+	if (nr_up < 0)
+		nr_up = 0;
+	if (nr_up != tp->nr_up) {
+		tp->nr_up = nr_up;
+		tty3270_rebuild_update(tp);
+		tty3270_update_status(tp);
+		tty3270_set_timer(tp, 1);
+	}
+	spin_unlock_bh(&tp->view.lock);
+}
+
+/*
+ * Scroll backward in history.
+ */
+static void
+tty3270_scroll_backward(struct kbd_data *kbd)
+{
+	struct tty3270 *tp;
+	int nr_up;
+
+	tp = kbd->tty->driver_data;
+	spin_lock_bh(&tp->view.lock);
+	nr_up = tp->nr_up + tp->view.rows - 2;
+	if (nr_up + tp->view.rows - 2 > tp->nr_lines)
+		nr_up = tp->nr_lines - tp->view.rows + 2;
+	if (nr_up != tp->nr_up) {
+		tp->nr_up = nr_up;
+		tty3270_rebuild_update(tp);
+		tty3270_update_status(tp);
+		tty3270_set_timer(tp, 1);
+	}
+	spin_unlock_bh(&tp->view.lock);
+}
+
+/*
+ * Pass input line to tty.
+ */
+static void
+tty3270_read_tasklet(struct raw3270_request *rrq)
+{
+	static char kreset_data = TW_KR;
+	struct tty3270 *tp;
+	char *input;
+	int len;
+
+	tp = (struct tty3270 *) rrq->view;
+	spin_lock_bh(&tp->view.lock);
+	/*
+	 * Two AID keys are special: For 0x7d (enter) the input line
+	 * has to be emitted to the tty and for 0x6d the screen
+	 * needs to be redrawn.
+	 */
+	input = 0;
+	len = 0;
+	if (tp->input->string[0] == 0x7d) {
+		/* Enter: write input to tty. */
+		input = tp->input->string + 6;
+		len = tp->input->len - 6 - rrq->rescnt;
+		if (tp->inattr != TF_INPUTN)
+			tty3270_rcl_add(tp, input, len);
+		if (tp->nr_up > 0) {
+			tp->nr_up = 0;
+			tty3270_rebuild_update(tp);
+			tty3270_update_status(tp);
+		}
+		/* Clear input area. */
+		tty3270_update_prompt(tp, 0, 0);
+		tty3270_set_timer(tp, 1);
+	} else if (tp->input->string[0] == 0x6d) {
+		/* Display has been cleared. Redraw. */
+		tty3270_rebuild_update(tp);
+		tp->update_flags = TTY_UPDATE_ALL;
+		tty3270_set_timer(tp, 1);
+	}
+	spin_unlock_bh(&tp->view.lock);
+
+	/* Start keyboard reset command. */
+	raw3270_request_reset(tp->kreset);
+	raw3270_request_set_cmd(tp->kreset, TC_WRITE);
+	raw3270_request_add_data(tp->kreset, &kreset_data, 1);
+	raw3270_start(&tp->view, tp->kreset);
+
+	/* Emit input string. */
+	if (tp->tty) {
+		while (len-- > 0)
+			kbd_keycode(tp->kbd, *input++);
+		/* Emit keycode for AID byte. */
+		kbd_keycode(tp->kbd, 256 + tp->input->string[0]);
+	}
+
+	raw3270_request_reset(rrq);
+	xchg(&tp->read, rrq);
+	raw3270_put_view(&tp->view);
+}
+
+/*
+ * Read request completion callback.
+ */
+static void
+tty3270_read_callback(struct raw3270_request *rq, void *data)
+{
+	raw3270_get_view(rq->view);
+	/* Schedule tasklet to pass input to tty. */
+	tasklet_schedule(&((struct tty3270 *) rq->view)->readlet);
+}
+
+/*
+ * Issue a read request. Call with device lock.
+ */
+static void
+tty3270_issue_read(struct tty3270 *tp, int lock)
+{
+	struct raw3270_request *rrq;
+	int rc;
+
+	rrq = xchg(&tp->read, 0);
+	if (!rrq)
+		/* Read already scheduled. */
+		return;
+	rrq->callback = tty3270_read_callback;
+	rrq->callback_data = tp;
+	raw3270_request_set_cmd(rrq, TC_READMOD);
+	raw3270_request_set_data(rrq, tp->input->string, tp->input->len);
+	/* Issue the read modified request. */
+	if (lock) {
+		rc = raw3270_start(&tp->view, rrq);
+	} else
+		rc = raw3270_start_irq(&tp->view, rrq);
+	if (rc) {
+		raw3270_request_reset(rrq);
+		xchg(&tp->read, rrq);
+	}
+}
+
+/*
+ * Switch to the tty view.
+ */
+static int
+tty3270_activate(struct raw3270_view *view)
+{
+	struct tty3270 *tp;
+	unsigned long flags;
+
+	tp = (struct tty3270 *) view;
+	spin_lock_irqsave(&tp->view.lock, flags);
+	tp->nr_up = 0;
+	tty3270_rebuild_update(tp);
+	tty3270_update_status(tp);
+	tp->update_flags = TTY_UPDATE_ALL;
+	tty3270_set_timer(tp, 1);
+	spin_unlock_irqrestore(&tp->view.lock, flags);
+	start_tty(tp->tty);
+	return 0;
+}
+
+static void
+tty3270_deactivate(struct raw3270_view *view)
+{
+	struct tty3270 *tp;
+
+	tp = (struct tty3270 *) view;
+	if (tp && tp->tty)
+		stop_tty(tp->tty);
+}
+
+static int
+tty3270_irq(struct tty3270 *tp, struct raw3270_request *rq, struct irb *irb)
+{
+	/* Handle ATTN. Schedule tasklet to read aid. */
+	if (irb->scsw.dstat & DEV_STAT_ATTENTION) {
+		if (!tp->throttle)
+			tty3270_issue_read(tp, 0);
+		else
+			tp->attn = 1;
+	}
+
+	if (rq) {
+		if (irb->scsw.dstat & DEV_STAT_UNIT_CHECK)
+			rq->rc = -EIO;
+		else
+			/* Normal end. Copy residual count. */
+			rq->rescnt = irb->scsw.count;
+	}
+	return RAW3270_IO_DONE;
+}
+
+/*
+ * Allocate tty3270 structure.
+ */
+static struct tty3270 *
+tty3270_alloc_view(void)
+{
+	struct tty3270 *tp;
+	int pages;
+
+	tp = kmalloc(sizeof(struct tty3270),GFP_KERNEL);
+	if (!tp)
+		goto out_err;
+	memset(tp, 0, sizeof(struct tty3270));
+	tp->freemem_pages =
+		kmalloc(sizeof(void *) * TTY3270_STRING_PAGES, GFP_KERNEL);
+	if (!tp->freemem_pages)
+		goto out_tp;
+	INIT_LIST_HEAD(&tp->freemem);
+	for (pages = 0; pages < TTY3270_STRING_PAGES; pages++) {
+		tp->freemem_pages[pages] = (void *)
+			__get_free_pages(GFP_KERNEL|GFP_DMA, 0);
+		if (!tp->freemem_pages[pages])
+			goto out_pages;
+		add_string_memory(&tp->freemem,
+				  tp->freemem_pages[pages], PAGE_SIZE);
+	}
+	tp->write = raw3270_request_alloc(TTY3270_OUTPUT_BUFFER_SIZE);
+	if (!tp->write)
+		goto out_pages;
+	tp->read = raw3270_request_alloc(0);
+	if (!tp->read)
+		goto out_write;
+	tp->kreset = raw3270_request_alloc(1);
+	if (!tp->kreset)
+		goto out_read;
+	tp->kbd = kbd_alloc();
+	if (!tp->kbd)
+		goto out_reset;
+	return tp;
+
+out_reset:
+	raw3270_request_free(tp->kreset);
+out_read:
+	raw3270_request_free(tp->read);
+out_write:
+	raw3270_request_free(tp->write);
+out_pages:
+	while (pages--)
+		free_pages((unsigned long) tp->freemem_pages[pages], 0);
+	kfree(tp->freemem_pages);
+out_tp:
+	kfree(tp);
+out_err:
+	return ERR_PTR(-ENOMEM);
+}
+
+/*
+ * Free tty3270 structure.
+ */
+static void
+tty3270_free_view(struct tty3270 *tp)
+{
+	int pages;
+
+	kbd_free(tp->kbd);
+	raw3270_request_free(tp->kreset);
+	raw3270_request_free(tp->read);
+	raw3270_request_free(tp->write);
+	for (pages = 0; pages < TTY3270_STRING_PAGES; pages++)
+		free_pages((unsigned long) tp->freemem_pages[pages], 0);
+	kfree(tp->freemem_pages);
+	kfree(tp);
+}
+
+/*
+ * Allocate tty3270 screen.
+ */
+static int
+tty3270_alloc_screen(struct tty3270 *tp)
+{
+	unsigned long size;
+	int lines;
+
+	size = sizeof(struct tty3270_line) * (tp->view.rows - 2);
+	tp->screen = kmalloc(size, GFP_KERNEL);
+	if (!tp->screen)
+		goto out_err;
+	memset(tp->screen, 0, size);
+	for (lines = 0; lines < tp->view.rows - 2; lines++) {
+		size = sizeof(struct tty3270_cell) * tp->view.cols;
+		tp->screen[lines].cells = kmalloc(size, GFP_KERNEL);
+		if (!tp->screen[lines].cells)
+			goto out_screen;
+		memset(tp->screen[lines].cells, 0, size);
+	}
+	return 0;
+out_screen:
+	while (lines--)
+		kfree(tp->screen[lines].cells);
+	kfree(tp->screen);
+out_err:
+	return -ENOMEM;
+}
+
+/*
+ * Free tty3270 screen.
+ */
+static void
+tty3270_free_screen(struct tty3270 *tp)
+{
+	int lines;
+
+	for (lines = 0; lines < tp->view.rows - 2; lines++)
+		kfree(tp->screen[lines].cells);
+	kfree(tp->screen);
+}
+
+/*
+ * Unlink tty3270 data structure from tty.
+ */
+static void
+tty3270_release(struct raw3270_view *view)
+{
+	struct tty3270 *tp;
+	struct tty_struct *tty;
+
+	tp = (struct tty3270 *) view;
+	tty = tp->tty;
+	if (tty) {
+		tty->driver_data = 0;
+		tp->tty = tp->kbd->tty = 0;
+		tty_hangup(tty);
+		raw3270_put_view(&tp->view);
+	}
+}
+
+/*
+ * Free tty3270 data structure
+ */
+static void
+tty3270_free(struct raw3270_view *view)
+{
+	tty3270_free_screen((struct tty3270 *) view);
+	tty3270_free_view((struct tty3270 *) view);
+}
+
+struct raw3270_fn tty3270_fn = {
+	.activate = tty3270_activate,
+	.deactivate = tty3270_deactivate,
+	.intv = (void *) tty3270_irq,
+	.release = tty3270_release,
+	.free = tty3270_free
+};
+
+/*
+ * This routine is called whenever a 3270 tty is opened.
+ */
+static int
+tty3270_open(struct tty_struct *tty, struct file * filp)
+{
+	struct tty3270 *tp;
+	int i, rc;
+
+	if (tty->count > 1)
+		return 0;
+	/* Check if the tty3270 is already there. */
+	tp = (struct tty3270 *) raw3270_find_view(&tty3270_fn, tty->index);
+	if (!IS_ERR(tp)) {
+		tty->driver_data = tp;
+		tty->winsize.ws_row = tp->view.rows - 2;
+		tty->winsize.ws_col = tp->view.cols;
+		tty->low_latency = 0;
+		tp->tty = tty;
+		tp->kbd->tty = tty;
+		tp->inattr = TF_INPUT;
+		return 0;
+	}
+
+	/* Allocate tty3270 structure on first open. */
+	tp = tty3270_alloc_view();
+	if (IS_ERR(tp))
+		return PTR_ERR(tp);
+
+	INIT_LIST_HEAD(&tp->lines);
+	INIT_LIST_HEAD(&tp->update);
+	INIT_LIST_HEAD(&tp->rcl_lines);
+	tp->rcl_max = 20;
+	init_timer(&tp->timer);
+	tasklet_init(&tp->readlet, 
+		     (void (*)(unsigned long)) tty3270_read_tasklet,
+		     (unsigned long) tp->read);
+
+	rc = raw3270_add_view(&tp->view, &tty3270_fn, tty->index);
+	if (rc) {
+		tty3270_free_view(tp);
+		return rc;
+	}
+
+	rc = tty3270_alloc_screen(tp);
+	if (rc) {
+		raw3270_del_view(&tp->view);
+		raw3270_put_view(&tp->view);
+		return rc;
+	}
+
+	tp->tty = tty;
+	tty->low_latency = 0;
+	tty->driver_data = tp;
+	tty->winsize.ws_row = tp->view.rows - 2;
+	tty->winsize.ws_col = tp->view.cols;
+
+	tty3270_create_prompt(tp);
+	tty3270_create_status(tp);
+	tty3270_update_status(tp);
+
+	/* Create blank line for every line in the tty output area. */
+	for (i = 0; i < tp->view.rows - 2; i++)
+		tty3270_blank_line(tp);
+
+	tp->kbd->tty = tty;
+	tp->kbd->fn_handler[KVAL(K_INCRCONSOLE)] = tty3270_exit_tty;
+	tp->kbd->fn_handler[KVAL(K_SCROLLBACK)] = tty3270_scroll_backward;
+	tp->kbd->fn_handler[KVAL(K_SCROLLFORW)] = tty3270_scroll_forward;
+	tp->kbd->fn_handler[KVAL(K_CONS)] = tty3270_rcl_backward;
+	kbd_ascebc(tp->kbd, tp->view.ascebc);
+
+	raw3270_activate_view(&tp->view);
+	return 0;
+}
+
+/*
+ * This routine is called when the 3270 tty is closed. We wait
+ * for the remaining request to be completed. Then we clean up.
+ */
+static void
+tty3270_close(struct tty_struct *tty, struct file * filp)
+{
+	struct tty3270 *tp;
+
+	if (tty->count > 1)
+		return;
+	tp = (struct tty3270 *) tty->driver_data;
+	if (tp) {
+		tty->driver_data = 0;
+		tp->tty = tp->kbd->tty = 0;
+		raw3270_put_view(&tp->view);
+	}
+}
+
+/*
+ * We always have room.
+ */
+static int
+tty3270_write_room(struct tty_struct *tty)
+{
+	return INT_MAX;
+}
+
+/*
+ * Insert character into the screen at the current position with the
+ * current color and highlight. This function does NOT do cursor movement.
+ */
+static void
+tty3270_put_character(struct tty3270 *tp, char ch)
+{
+	struct tty3270_line *line;
+	struct tty3270_cell *cell;
+
+	line = tp->screen + tp->cy;
+	if (line->len <= tp->cx) {
+		while (line->len < tp->cx) {
+			cell = line->cells + line->len;
+			cell->character = tp->view.ascebc[' '];
+			cell->highlight = tp->highlight;
+			cell->f_color = tp->f_color;
+			line->len++;
+		}
+		line->len++;
+	}
+	cell = line->cells + tp->cx;
+	cell->character = tp->view.ascebc[(unsigned int) ch];
+	cell->highlight = tp->highlight;
+	cell->f_color = tp->f_color;
+}
+
+/*
+ * Convert a tty3270_line to a 3270 data fragment usable for output.
+ */
+static void
+tty3270_convert_line(struct tty3270 *tp, int line_nr)
+{
+	struct tty3270_line *line;
+	struct tty3270_cell *cell;
+	struct string *s, *n;
+	unsigned char highlight;
+	unsigned char f_color;
+	char *cp;
+	int flen, i;
+
+	/* Determine how long the fragment will be. */
+	flen = 3;		/* Prefix (TO_SBA). */
+	line = tp->screen + line_nr;
+	flen += line->len;
+	highlight = TAX_RESET;
+	f_color = TAC_RESET;
+	for (i = 0, cell = line->cells; i < line->len; i++, cell++) {
+		if (cell->highlight != highlight) {
+			flen += 3;	/* TO_SA to switch highlight. */
+			highlight = cell->highlight;
+		}
+		if (cell->f_color != f_color) {
+			flen += 3;	/* TO_SA to switch color. */
+			f_color = cell->f_color;
+		}
+	}
+	if (highlight != TAX_RESET)
+		flen += 3;	/* TO_SA to reset hightlight. */
+	if (f_color != TAC_RESET)
+		flen += 3;	/* TO_SA to reset color. */
+	if (line->len < tp->view.cols)
+		flen += 4;	/* Postfix (TO_RA). */
+
+	/* Find the line in the list. */
+	i = tp->view.rows - 2 - line_nr;
+	list_for_each_entry_reverse(s, &tp->lines, list)
+		if (--i <= 0)
+			break;
+	/*
+	 * Check if the line needs to get reallocated.
+	 */
+	if (s->len != flen) {
+		/* Reallocate string. */
+		n = tty3270_alloc_string(tp, flen);
+		list_add(&n->list, &s->list);
+		list_del_init(&s->list);
+		if (!list_empty(&s->update))
+			list_del_init(&s->update);
+		free_string(&tp->freemem, s);
+		s = n;
+	}
+
+	/* Write 3270 data fragment. */
+	cp = s->string;
+	*cp++ = TO_SBA;
+	*cp++ = 0;
+	*cp++ = 0;
+
+	highlight = TAX_RESET;
+	f_color = TAC_RESET;
+	for (i = 0, cell = line->cells; i < line->len; i++, cell++) {
+		if (cell->highlight != highlight) {
+			*cp++ = TO_SA;
+			*cp++ = TAT_EXTHI;
+			*cp++ = cell->highlight;
+			highlight = cell->highlight;
+		}
+		if (cell->f_color != f_color) {
+			*cp++ = TO_SA;
+			*cp++ = TAT_COLOR;
+			*cp++ = cell->f_color;
+			f_color = cell->f_color;
+		}
+		*cp++ = cell->character;
+	}
+	if (highlight != TAX_RESET) {
+		*cp++ = TO_SA;
+		*cp++ = TAT_EXTHI;
+		*cp++ = TAX_RESET;
+	}
+	if (f_color != TAC_RESET) {
+		*cp++ = TO_SA;
+		*cp++ = TAT_COLOR;
+		*cp++ = TAC_RESET;
+	}
+	if (line->len < tp->view.cols) {
+		*cp++ = TO_RA;
+		*cp++ = 0;
+		*cp++ = 0;
+		*cp++ = 0;
+	}
+
+	if (tp->nr_up + line_nr < tp->view.rows - 2) {
+		/* Line is currently visible on screen. */
+		tty3270_update_string(tp, s, line_nr);
+		/* Add line to update list. */
+		if (list_empty(&s->update)) {
+			list_add_tail(&s->update, &tp->update);
+			tp->update_flags |= TTY_UPDATE_LIST;
+		}
+	}
+}
+
+/*
+ * Do carriage return.
+ */
+static void
+tty3270_cr(struct tty3270 *tp)
+{
+	tp->cx = 0;
+}
+
+/*
+ * Do line feed.
+ */
+static void
+tty3270_lf(struct tty3270 *tp)
+{
+	struct tty3270_line temp;
+	int i;
+
+	tty3270_convert_line(tp, tp->cy);
+	if (tp->cy < tp->view.rows - 3) {
+		tp->cy++;
+		return;
+	}
+	/* Last line just filled up. Add new, blank line. */
+	tty3270_blank_line(tp);
+	temp = tp->screen[0];
+	temp.len = 0;
+	for (i = 0; i < tp->view.rows - 3; i++)
+		tp->screen[i] = tp->screen[i+1];
+	tp->screen[tp->view.rows - 3] = temp;
+	tty3270_rebuild_update(tp);
+}
+
+static void
+tty3270_ri(struct tty3270 *tp)
+{
+	if (tp->cy > 0) {
+	    tty3270_convert_line(tp, tp->cy);
+	    tp->cy--;
+	}
+}
+
+/*
+ * Insert characters at current position.
+ */
+static void
+tty3270_insert_characters(struct tty3270 *tp, int n)
+{
+	struct tty3270_line *line;
+	int k;
+
+	line = tp->screen + tp->cy;
+	while (line->len < tp->cx) {
+		line->cells[line->len].character = tp->view.ascebc[' '];
+		line->cells[line->len].highlight = TAX_RESET;
+		line->cells[line->len].f_color = TAC_RESET;
+		line->len++;
+	}
+	if (n > tp->view.cols - tp->cx)
+		n = tp->view.cols - tp->cx;
+	k = min_t(int, line->len - tp->cx, tp->view.cols - tp->cx - n);
+	while (k--)
+		line->cells[tp->cx + n + k] = line->cells[tp->cx + k];
+	line->len += n;
+	if (line->len > tp->view.cols)
+		line->len = tp->view.cols;
+	while (n-- > 0) {
+		line->cells[tp->cx + n].character = tp->view.ascebc[' '];
+		line->cells[tp->cx + n].highlight = tp->highlight;
+		line->cells[tp->cx + n].f_color = tp->f_color;
+	}
+}
+
+/*
+ * Delete characters at current position.
+ */
+static void
+tty3270_delete_characters(struct tty3270 *tp, int n)
+{
+	struct tty3270_line *line;
+	int i;
+
+	line = tp->screen + tp->cy;
+	if (line->len <= tp->cx)
+		return;
+	if (line->len - tp->cx <= n) {
+		line->len = tp->cx;
+		return;
+	}
+	for (i = tp->cx; i + n < line->len; i++)
+		line->cells[i] = line->cells[i + n];
+	line->len -= n;
+}
+
+/*
+ * Erase characters at current position.
+ */
+static void
+tty3270_erase_characters(struct tty3270 *tp, int n)
+{
+	struct tty3270_line *line;
+	struct tty3270_cell *cell;
+
+	line = tp->screen + tp->cy;
+	while (line->len > tp->cx && n-- > 0) {
+		cell = line->cells + tp->cx++;
+		cell->character = ' ';
+		cell->highlight = TAX_RESET;
+		cell->f_color = TAC_RESET;
+	}
+	tp->cx += n;
+	tp->cx = min_t(int, tp->cx, tp->view.cols - 1);
+}
+
+/*
+ * Erase line, 3 different cases:
+ *  Esc [ 0 K	Erase from current position to end of line inclusive
+ *  Esc [ 1 K	Erase from beginning of line to current position inclusive
+ *  Esc [ 2 K	Erase entire line (without moving cursor)
+ */
+static void
+tty3270_erase_line(struct tty3270 *tp, int mode)
+{
+	struct tty3270_line *line;
+	struct tty3270_cell *cell;
+	int i;
+
+	line = tp->screen + tp->cy;
+	if (mode == 0)
+		line->len = tp->cx;
+	else if (mode == 1) {
+		for (i = 0; i < tp->cx; i++) {
+			cell = line->cells + i;
+			cell->character = ' ';
+			cell->highlight = TAX_RESET;
+			cell->f_color = TAC_RESET;
+		}
+		if (line->len <= tp->cx)
+			line->len = tp->cx + 1;
+	} else if (mode == 2)
+		line->len = 0;
+	tty3270_convert_line(tp, tp->cy);
+}
+
+/*
+ * Erase display, 3 different cases:
+ *  Esc [ 0 J	Erase from current position to bottom of screen inclusive
+ *  Esc [ 1 J	Erase from top of screen to current position inclusive
+ *  Esc [ 2 J	Erase entire screen (without moving the cursor)
+ */
+static void
+tty3270_erase_display(struct tty3270 *tp, int mode)
+{
+	int i;
+
+	if (mode == 0) {
+		tty3270_erase_line(tp, 0);
+		for (i = tp->cy + 1; i < tp->view.rows - 2; i++) {
+			tp->screen[i].len = 0;
+			tty3270_convert_line(tp, i);
+		}
+	} else if (mode == 1) {
+		for (i = 0; i < tp->cy; i++) {
+			tp->screen[i].len = 0;
+			tty3270_convert_line(tp, i);
+		}
+		tty3270_erase_line(tp, 1);
+	} else if (mode == 2) {
+		for (i = 0; i < tp->view.rows - 2; i++) {
+			tp->screen[i].len = 0;
+			tty3270_convert_line(tp, i);
+		}
+	}
+	tty3270_rebuild_update(tp);
+}
+
+/*
+ * Set attributes found in an escape sequence.
+ *  Esc [ <attr> ; <attr> ; ... m
+ */
+static void
+tty3270_set_attributes(struct tty3270 *tp)
+{
+	static unsigned char f_colors[] = {
+		TAC_DEFAULT, TAC_RED, TAC_GREEN, TAC_YELLOW, TAC_BLUE,
+		TAC_PINK, TAC_TURQ, TAC_WHITE, 0, TAC_DEFAULT
+	};
+	int i, attr;
+
+	for (i = 0; i <= tp->esc_npar; i++) {
+		attr = tp->esc_par[i];
+		switch (attr) {
+		case 0:		/* Reset */
+			tp->highlight = TAX_RESET;
+			tp->f_color = TAC_RESET;
+			break;
+		/* Highlight. */
+		case 4:		/* Start underlining. */
+			tp->highlight = TAX_UNDER;
+			break;
+		case 5:		/* Start blink. */
+			tp->highlight = TAX_BLINK;
+			break;
+		case 7:		/* Start reverse. */
+			tp->highlight = TAX_REVER;
+			break;
+		case 24:	/* End underlining */
+			if (tp->highlight == TAX_UNDER)
+				tp->highlight = TAX_RESET;
+			break;
+		case 25:	/* End blink. */
+			if (tp->highlight == TAX_BLINK)
+				tp->highlight = TAX_RESET;
+			break;
+		case 27:	/* End reverse. */
+			if (tp->highlight == TAX_REVER)
+				tp->highlight = TAX_RESET;
+			break;
+		/* Foreground color. */
+		case 30:	/* Black */
+		case 31:	/* Red */
+		case 32:	/* Green */
+		case 33:	/* Yellow */
+		case 34:	/* Blue */
+		case 35:	/* Magenta */
+		case 36:	/* Cyan */
+		case 37:	/* White */
+		case 39:	/* Black */
+			tp->f_color = f_colors[attr - 30];
+			break;
+		}
+	}
+}
+
+static inline int
+tty3270_getpar(struct tty3270 *tp, int ix)
+{
+	return (tp->esc_par[ix] > 0) ? tp->esc_par[ix] : 1;
+}
+
+static void
+tty3270_goto_xy(struct tty3270 *tp, int cx, int cy)
+{
+	tp->cx = min_t(int, tp->view.cols - 1, max_t(int, 0, cx));
+	cy = min_t(int, tp->view.rows - 3, max_t(int, 0, cy));
+	if (cy != tp->cy) {
+		tty3270_convert_line(tp, tp->cy);
+		tp->cy = cy;
+	}
+}
+
+/*
+ * Process escape sequences. Known sequences:
+ *  Esc 7			Save Cursor Position
+ *  Esc 8			Restore Cursor Position
+ *  Esc [ Pn ; Pn ; .. m	Set attributes
+ *  Esc [ Pn ; Pn H		Cursor Position
+ *  Esc [ Pn ; Pn f		Cursor Position
+ *  Esc [ Pn A			Cursor Up
+ *  Esc [ Pn B			Cursor Down
+ *  Esc [ Pn C			Cursor Forward
+ *  Esc [ Pn D			Cursor Backward
+ *  Esc [ Pn G			Cursor Horizontal Absolute
+ *  Esc [ Pn X			Erase Characters
+ *  Esc [ Ps J			Erase in Display
+ *  Esc [ Ps K			Erase in Line
+ * // FIXME: add all the new ones.
+ *
+ *  Pn is a numeric parameter, a string of zero or more decimal digits.
+ *  Ps is a selective parameter.
+ */
+static void
+tty3270_escape_sequence(struct tty3270 *tp, char ch)
+{
+	enum { ESnormal, ESesc, ESsquare, ESgetpars };
+
+	if (tp->esc_state == ESnormal) {
+		if (ch == 0x1b)
+			/* Starting new escape sequence. */
+			tp->esc_state = ESesc;
+		return;
+	}
+	if (tp->esc_state == ESesc) {
+		tp->esc_state = ESnormal;
+		switch (ch) {
+		case '[':
+			tp->esc_state = ESsquare;
+			break;
+		case 'E':
+			tty3270_cr(tp);
+			tty3270_lf(tp);
+			break;
+		case 'M':
+			tty3270_ri(tp);
+			break;
+		case 'D':
+			tty3270_lf(tp);
+			break;
+		case 'Z':		/* Respond ID. */
+			kbd_puts_queue(tp->tty, "\033[?6c");
+			break;
+		case '7':		/* Save cursor position. */
+			tp->saved_cx = tp->cx;
+			tp->saved_cy = tp->cy;
+			tp->saved_highlight = tp->highlight;
+			tp->saved_f_color = tp->f_color;
+			break;
+		case '8':		/* Restore cursor position. */
+			tty3270_convert_line(tp, tp->cy);
+			tty3270_goto_xy(tp, tp->saved_cx, tp->saved_cy);
+			tp->highlight = tp->saved_highlight;
+			tp->f_color = tp->saved_f_color;
+			break;
+		case 'c':		/* Reset terminal. */
+			tp->cx = tp->saved_cx = 0;
+			tp->cy = tp->saved_cy = 0;
+			tp->highlight = tp->saved_highlight = TAX_RESET;
+			tp->f_color = tp->saved_f_color = TAC_RESET;
+			tty3270_erase_display(tp, 2);
+			break;
+		}
+		return;
+	}
+	if (tp->esc_state == ESsquare) {
+		tp->esc_state = ESgetpars;
+		memset(tp->esc_par, 0, sizeof(tp->esc_par));
+		tp->esc_npar = 0;
+		tp->esc_ques = (ch == '?');
+		if (tp->esc_ques)
+			return;
+	}
+	if (tp->esc_state == ESgetpars) {
+		if (ch == ';' && tp->esc_npar < ESCAPE_NPAR - 1) {
+			tp->esc_npar++;
+			return;
+		}
+		if (ch >= '0' && ch <= '9') {
+			tp->esc_par[tp->esc_npar] *= 10;
+			tp->esc_par[tp->esc_npar] += ch - '0';
+			return;
+		}
+	}
+	tp->esc_state = ESnormal;
+	if (ch == 'n' && !tp->esc_ques) {
+		if (tp->esc_par[0] == 5)		/* Status report. */
+			kbd_puts_queue(tp->tty, "\033[0n");
+		else if (tp->esc_par[0] == 6) {	/* Cursor report. */
+			char buf[40];
+			sprintf(buf, "\033[%d;%dR", tp->cy + 1, tp->cx + 1);
+			kbd_puts_queue(tp->tty, buf);
+		}
+		return;
+	}
+	if (tp->esc_ques)
+		return;
+	switch (ch) {
+	case 'm':
+		tty3270_set_attributes(tp);
+		break;
+	case 'H':	/* Set cursor position. */
+	case 'f':
+		tty3270_goto_xy(tp, tty3270_getpar(tp, 1) - 1,
+				tty3270_getpar(tp, 0) - 1);
+		break;
+	case 'd':	/* Set y position. */
+		tty3270_goto_xy(tp, tp->cx, tty3270_getpar(tp, 0) - 1);
+		break;
+	case 'A':	/* Cursor up. */
+	case 'F':
+		tty3270_goto_xy(tp, tp->cx, tp->cy - tty3270_getpar(tp, 0));
+		break;
+	case 'B':	/* Cursor down. */
+	case 'e':
+	case 'E':
+		tty3270_goto_xy(tp, tp->cx, tp->cy + tty3270_getpar(tp, 0));
+		break;
+	case 'C':	/* Cursor forward. */
+	case 'a':
+		tty3270_goto_xy(tp, tp->cx + tty3270_getpar(tp, 0), tp->cy);
+		break;
+	case 'D':	/* Cursor backward. */
+		tty3270_goto_xy(tp, tp->cx - tty3270_getpar(tp, 0), tp->cy);
+		break;
+	case 'G':	/* Set x position. */
+	case '`':
+		tty3270_goto_xy(tp, tty3270_getpar(tp, 0), tp->cy);
+		break;
+	case 'X':	/* Erase Characters. */
+		tty3270_erase_characters(tp, tty3270_getpar(tp, 0));
+		break;
+	case 'J':	/* Erase display. */
+		tty3270_erase_display(tp, tp->esc_par[0]);
+		break;
+	case 'K':	/* Erase line. */
+		tty3270_erase_line(tp, tp->esc_par[0]);
+		break;
+	case 'P':	/* Delete characters. */
+		tty3270_delete_characters(tp, tty3270_getpar(tp, 0));
+		break;
+	case '@':	/* Insert characters. */
+		tty3270_insert_characters(tp, tty3270_getpar(tp, 0));
+		break;
+	case 's':	/* Save cursor position. */
+		tp->saved_cx = tp->cx;
+		tp->saved_cy = tp->cy;
+		tp->saved_highlight = tp->highlight;
+		tp->saved_f_color = tp->f_color;
+		break;
+	case 'u':	/* Restore cursor position. */
+		tty3270_convert_line(tp, tp->cy);
+		tty3270_goto_xy(tp, tp->saved_cx, tp->saved_cy);
+		tp->highlight = tp->saved_highlight;
+		tp->f_color = tp->saved_f_color;
+		break;
+	}
+}
+
+/*
+ * String write routine for 3270 ttys
+ */
+static void
+tty3270_do_write(struct tty3270 *tp, const unsigned char *buf, int count)
+{
+	int i_msg, i;
+
+	spin_lock_bh(&tp->view.lock);
+	for (i_msg = 0; !tp->tty->stopped && i_msg < count; i_msg++) {
+		if (tp->esc_state != 0) {
+			/* Continue escape sequence. */
+			tty3270_escape_sequence(tp, buf[i_msg]);
+			continue;
+		}
+
+		switch (buf[i_msg]) {
+		case 0x07:		/* '\a' -- Alarm */
+			tp->wcc |= TW_PLUSALARM;
+			break;
+		case 0x08:		/* Backspace. */
+			if (tp->cx > 0) {
+				tp->cx--;
+				tty3270_put_character(tp, ' ');
+			}
+			break;
+		case 0x09:		/* '\t' -- Tabulate */
+			for (i = tp->cx % 8; i < 8; i++) {
+				if (tp->cx >= tp->view.cols) {
+					tty3270_cr(tp);
+					tty3270_lf(tp);
+					break;
+				}
+				tty3270_put_character(tp, ' ');
+				tp->cx++;
+			}
+			break;
+		case 0x0a:		/* '\n' -- New Line */
+			tty3270_cr(tp);
+			tty3270_lf(tp);
+			break;
+		case 0x0c:		/* '\f' -- Form Feed */
+			tty3270_erase_display(tp, 2);
+			tp->cx = tp->cy = 0;
+			break;
+		case 0x0d:		/* '\r' -- Carriage Return */
+			tp->cx = 0;
+			break;
+		case 0x0f:		/* SuSE "exit alternate mode" */
+			break;
+		case 0x1b:		/* Start escape sequence. */
+			tty3270_escape_sequence(tp, buf[i_msg]);
+			break;
+		default:		/* Insert normal character. */
+			if (tp->cx >= tp->view.cols) {
+				tty3270_cr(tp);
+				tty3270_lf(tp);
+			}
+			tty3270_put_character(tp, buf[i_msg]);
+			tp->cx++;
+			break;
+		}
+	}
+	/* Convert current line to 3270 data fragment. */
+	tty3270_convert_line(tp, tp->cy);
+
+	/* Setup timer to update display after 1/10 second */
+	if (!timer_pending(&tp->timer))
+		tty3270_set_timer(tp, HZ/10);
+
+	spin_unlock_bh(&tp->view.lock);
+}
+
+/*
+ * String write routine for 3270 ttys
+ */
+static int
+tty3270_write(struct tty_struct * tty, int from_user,
+	      const unsigned char *buf, int count)
+{
+	struct tty3270 *tp;
+	int length, ret;
+
+	tp = tty->driver_data;
+	if (!tp)
+		return 0;
+	if (tp->char_count > 0) {
+		tty3270_do_write(tp, tp->char_buf, tp->char_count);
+		tp->char_count = 0;
+	}
+	if (!from_user) {
+		tty3270_do_write(tp, buf, count);
+		return count;
+	}
+	ret = 0;
+	while (count > 0) {
+		length = count < TTY3270_CHAR_BUF_SIZE ?
+			count : TTY3270_CHAR_BUF_SIZE;
+		length -= copy_from_user(tp->char_buf, buf, length);
+		if (length == 0) {
+			if (!ret)
+				ret = -EFAULT;
+			break;
+		}
+		tty3270_do_write(tp, tp->char_buf, count);
+		buf += length;
+		count -= length;
+		ret += length;
+	}
+	return ret;
+}
+
+/*
+ * Put single characters to the ttys character buffer
+ */
+static void
+tty3270_put_char(struct tty_struct *tty, unsigned char ch)
+{
+	struct tty3270 *tp;
+
+	tp = tty->driver_data;
+	if (!tp)
+		return;
+	if (tp->char_count < TTY3270_CHAR_BUF_SIZE)
+		tp->char_buf[tp->char_count++] = ch;
+}
+
+/*
+ * Flush all characters from the ttys characeter buffer put there
+ * by tty3270_put_char.
+ */
+static void
+tty3270_flush_chars(struct tty_struct *tty)
+{
+	struct tty3270 *tp;
+
+	tp = tty->driver_data;
+	if (!tp)
+		return;
+	if (tp->char_count > 0) {
+		tty3270_do_write(tp, tp->char_buf, tp->char_count);
+		tp->char_count = 0;
+	}
+}
+
+/*
+ * Returns the number of characters in the output buffer. This is
+ * used in tty_wait_until_sent to wait until all characters have
+ * appeared on the screen.
+ */
+static int
+tty3270_chars_in_buffer(struct tty_struct *tty)
+{
+	return 0;
+}
+
+static void
+tty3270_flush_buffer(struct tty_struct *tty)
+{
+}
+
+/*
+ * Check for visible/invisible input switches
+ */
+static void
+tty3270_set_termios(struct tty_struct *tty, struct termios *old)
+{
+	struct tty3270 *tp;
+	int new;
+
+	tp = tty->driver_data;
+	if (!tp)
+		return;
+	spin_lock_bh(&tp->view.lock);
+	if (L_ICANON(tty)) {
+		new = L_ECHO(tty) ? TF_INPUT: TF_INPUTN;
+		if (new != tp->inattr) {
+			tp->inattr = new;
+			tty3270_update_prompt(tp, 0, 0);
+			tty3270_set_timer(tp, 1);
+		}
+	}
+	spin_unlock_bh(&tp->view.lock);
+}
+
+/*
+ * Disable reading from a 3270 tty
+ */
+static void
+tty3270_throttle(struct tty_struct * tty)
+{
+	struct tty3270 *tp;
+
+	tp = tty->driver_data;
+	if (!tp)
+		return;
+	tp->throttle = 1;
+}
+
+/*
+ * Enable reading from a 3270 tty
+ */
+static void
+tty3270_unthrottle(struct tty_struct * tty)
+{
+	struct tty3270 *tp;
+
+	tp = tty->driver_data;
+	if (!tp)
+		return;
+	tp->throttle = 0;
+	if (tp->attn)
+		tty3270_issue_read(tp, 1);
+}
+
+/*
+ * Hang up the tty device.
+ */
+static void
+tty3270_hangup(struct tty_struct *tty)
+{
+	// FIXME: implement
+}
+
+static void
+tty3270_wait_until_sent(struct tty_struct *tty, int timeout)
+{
+}
+
+static int
+tty3270_ioctl(struct tty_struct *tty, struct file *file,
+	      unsigned int cmd, unsigned long arg)
+{
+	struct tty3270 *tp;
+
+	tp = tty->driver_data;
+	if (!tp)
+		return -ENODEV;
+	if (tty->flags & (1 << TTY_IO_ERROR))
+		return -EIO;
+	return kbd_ioctl(tp->kbd, file, cmd, arg);
+}
+
+static struct tty_operations tty3270_ops = {
+	.open = tty3270_open,
+	.close = tty3270_close,
+	.write = tty3270_write,
+	.put_char = tty3270_put_char,
+	.flush_chars = tty3270_flush_chars,
+	.write_room = tty3270_write_room,
+	.chars_in_buffer = tty3270_chars_in_buffer,
+	.flush_buffer = tty3270_flush_buffer,
+	.throttle = tty3270_throttle,
+	.unthrottle = tty3270_unthrottle,
+	.hangup = tty3270_hangup,
+	.wait_until_sent = tty3270_wait_until_sent,
+	.ioctl = tty3270_ioctl,
+	.set_termios = tty3270_set_termios
+};
+
+void
+tty3270_notifier(int index, int active)
+{
+	if (active)
+		tty_register_device(tty3270_driver, index, 0);
+	else
+		tty_unregister_device(tty3270_driver, index);
+}
+
+/*
+ * 3270 tty registration code called from tty_init().
+ * Most kernel services (incl. kmalloc) are available at this poimt.
+ */
+int __init
+tty3270_init(void)
+{
+	struct tty_driver *driver;
+	int ret;
+
+	ret = raw3270_init();
+	if (ret)
+		return ret;
+	driver = alloc_tty_driver(256);
+	if (!driver)
+		return -ENOMEM;
+
+	/*
+	 * Initialize the tty_driver structure
+	 * Entries in tty3270_driver that are NOT initialized:
+	 * proc_entry, set_termios, flush_buffer, set_ldisc, write_proc
+	 */
+	driver->owner = THIS_MODULE;
+	driver->devfs_name = "ttyTUB/";
+	driver->driver_name = "ttyTUB";
+	driver->name = "ttyTUB";
+	driver->major = IBM_TTY3270_MAJOR;
+	driver->type = TTY_DRIVER_TYPE_SYSTEM;
+	driver->subtype = SYSTEM_TYPE_TTY;
+	driver->init_termios = tty_std_termios;
+	driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_NO_DEVFS;
+	tty_set_operations(driver, &tty3270_ops);
+	ret = tty_register_driver(driver);
+	if (ret) {
+		printk(KERN_ERR "tty3270 registration failed with %d\n", ret);
+		put_tty_driver(driver);
+		return ret;
+	}
+	tty3270_driver = driver;
+	return 0;
+}
+
+static void __exit
+tty3270_exit(void)
+{
+	struct tty_driver *driver;
+
+	driver = tty3270_driver;
+	tty3270_driver = 0;
+	tty_unregister_driver(driver);
+	raw3270_exit();
+}
+
+MODULE_LICENSE("GPL");
+MODULE_ALIAS_CHARDEV_MAJOR(IBM_TTY3270_MAJOR);
+
+module_init(tty3270_init);
+module_exit(tty3270_exit);
diff -puN -L drivers/s390/char/tuball.c drivers/s390/char/tuball.c~linus /dev/null
--- 25/drivers/s390/char/tuball.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,621 +0,0 @@
-/*
- *  IBM/3270 Driver -- Copyright (C) 2000 UTS Global LLC
- *
- *  tuball.c -- Initialization, termination, irq lookup
- *
- *
- *
- *
- *
- *  Author:  Richard Hitt
- */
-#include <linux/config.h>
-#include "tubio.h"
-#ifndef MODULE
-#include <linux/init.h>
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0))
-#include <asm/cpcmd.h>
-#include <linux/bootmem.h>
-#else
-#include "../../../../arch/s390/kernel/cpcmd.h"
-#endif
-#endif
-
-/* Module parameters */
-int tubdebug;
-int tubscrolltime = -1;
-static int tubxcorrect = 1;            /* Do correct ebc<->asc tables */
-#ifdef MODULE
-MODULE_PARM(tubdebug, "i");
-MODULE_PARM(tubscrolltime, "i");
-MODULE_PARM(tubxcorrect, "i");
-#endif
-/*
- * Values for tubdebug and their effects:
- * 1 - print in hex on console the first 16 bytes received
- * 2 - print address at which array tubminors is allocated
- * 4 - attempt to register tty3270_driver
- */
-int tubnummins;
-tub_t *(*tubminors)[TUBMAXMINS];
-static tub_t *(*(*tubirqs)[256])[256];
-unsigned char tub_ascebc[256];
-unsigned char tub_ebcasc[256];
-static int tubinitminors(void);
-static void tubfiniminors(void);
-static void tubint(int, void *, struct pt_regs *);
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
-static int tubmakemin(int, dev_info_t *);
-#else
-static int tubmakemin(int, s390_dev_info_t *);
-#endif
-
-
-/* Lookup-by-irq functions */
-static int tubaddbyirq(tub_t *, int);
-static tub_t *tubfindbyirq(int);
-static void tubdelbyirq(tub_t *, int);
-static void tubfiniirqs(void);
-
-/* FIXME: put extern declarations in a header */
-extern int fs3270_init(void);
-extern void fs3270_fini(void);
-extern int tty3270_init(void);
-extern void tty3270_fini(void);
-
-unsigned char tub_ebcgraf[64] =
-	{ 0x40, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
-	  0xc8, 0xc9, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
-	  0x50, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
-	  0xd8, 0xd9, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
-	  0x60, 0x61, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
-	  0xe8, 0xe9, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
-	  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
-	  0xf8, 0xf9, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f };
-
-#ifndef MODULE
-
-/*
- * Can't have this driver a module & support console at the same time
- */
-#ifdef CONFIG_TN3270_CONSOLE
-static struct tty_driver *tub3270_con_device(struct console *, int *);
-static void tub3270_con_unblank(void);
-static void tub3270_con_write(struct console *, const char *,
-	unsigned int);
-
-static struct console tub3270_con = {
-	"tub3270",		/* name */
-	tub3270_con_write,	/* write */
-	NULL,			/* read */
-	tub3270_con_device,	/* device */
-	tub3270_con_unblank,	/* unblank */
-	NULL,			/* setup */
-	CON_PRINTBUFFER,	/* flags */
-	0,			/* index */
-	0,			/* cflag */
-	NULL			/* next */
-};
-
-static bcb_t tub3270_con_bcb;		/* Buffer that receives con writes */
-static spinlock_t tub3270_con_bcblock;	/* Lock for the buffer */
-static int tub3270_con_irq = -1;		/* set nonneg by _activate() */
-tub_t *tub3270_con_tubp;		/* set nonzero by _activate() */
-struct tty_driver tty3270_con_driver;	/* for /dev/console at 4, 64 */
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
-int tub3270_con_devno = -1;		/* set by tub3270_con_setup() */
-__initfunc(void tub3270_con_setup(char *str, int *ints))
-{
-	int vdev;
-
-	vdev = simple_strtoul(str, 0, 16);
-	if (vdev >= 0 && vdev < 65536)
-		tub3270_con_devno = vdev;
-	return;
-}
-
-__initfunc (long tub3270_con_init(long kmem_start, long kmem_end))
-{
-	tub3270_con_bcb.bc_len = 65536;
-	if (!MACHINE_IS_VM && !MACHINE_IS_P390)
-		return kmem_start;
-	tub3270_con_bcb.bc_buf = (void *)kmem_start;
-	kmem_start += tub3270_con_bcb.bc_len;
-	register_console(&tub3270_con);
-	return kmem_start;
-}
-#else
-#define tub3270_con_devno console_device
-
-static void __init tub3270_con_init(void)
-{
-	tub3270_con_bcb.bc_len = 65536;
-	if (!CONSOLE_IS_3270)
-		return;
-	tub3270_con_bcb.bc_buf = (void *)alloc_bootmem_low(
-		tub3270_con_bcb.bc_len);
-	register_console(&tub3270_con);
-}
-console_initcall(tub3270_con_init);
-
-#endif
-
-static struct tty_driver *tub3270_con_device(struct console *conp, int *index)
-{
-	*index = conp->index + 1;
-	extern struct tty_driver *tty3270_driver;
-	return tty3270_driver;
-}
-
-static void
-tub3270_con_unblank(void)
-{
-	/* flush everything:  panic has occurred */
-}
-
-static void
-tub3270_con_write(struct console *conp,
-	const char *buf, unsigned int count)
-{
-	long flags;
-	tub_t *tubp = tub3270_con_tubp;
-	void tty3270_sched_bh(tub_t *);
-	int rc;
-	bcb_t obcb;
-
-	obcb.bc_buf = (char *)buf;
-	obcb.bc_len = obcb.bc_cnt = obcb.bc_wr =
-		MIN(count, tub3270_con_bcb.bc_len);
-	obcb.bc_rd = 0;
-
-	spin_lock_irqsave(&tub3270_con_bcblock, flags);
-	rc = tub3270_movedata(&obcb, &tub3270_con_bcb, 0);
-	spin_unlock_irqrestore(&tub3270_con_bcblock, flags);
-
-	if (tubp && rc && TUBTRYLOCK(tubp->irq, flags)) {
-		tty3270_sched_bh(tubp);
-		TUBUNLOCK(tubp->irq, flags);
-	}
-}
-	
-int tub3270_con_copy(tub_t *tubp)
-{
-	long flags;
-	int rc;
-
-	spin_lock_irqsave(&tub3270_con_bcblock, flags);
-	rc = tub3270_movedata(&tub3270_con_bcb, &tubp->tty_bcb, 0);
-	spin_unlock_irqrestore(&tub3270_con_bcblock, flags);
-	return rc;
-}
-#endif /* CONFIG_TN3270_CONSOLE */
-#endif
-
-/*
- * remove driver:  unregister the major number
- */
-static void __exit
-tub3270_exit(void)
-{
-	fs3270_fini();
-	tty3270_fini();
-	tubfiniminors();
-}
-
-static int
-tub3270_is_ours(s390_dev_info_t *dp)
-{
-	if ((dp->sid_data.cu_type & 0xfff0) == 0x3270)
-		return 1;
-	if (dp->sid_data.cu_type == 0x3174)
-		return 1;
-	return 0;
-}
-
-/*
- * tub3270_init() called by kernel or module initialization
- */
-static int __init
-tub3270_init(void)
-{
-	s390_dev_info_t d;
-	int i, rc;
-
-#ifdef MODULE
-	if (tubnummins != 0) {
-		printk(KERN_ERR "EEEK!!  Tube driver cobbigling!!\n");
-		return -1;
-	}
-#endif
-
-	/*
-	 * Copy and correct ebcdic - ascii translate tables
-	 */
-	memcpy(tub_ascebc, _ascebc, sizeof tub_ascebc);
-	memcpy(tub_ebcasc, _ebcasc, sizeof tub_ebcasc);
-	if (tubxcorrect) {
-		/* correct brackets and circumflex */
-		tub_ascebc['['] = 0xad;
-		tub_ascebc[']'] = 0xbd;
-		tub_ebcasc[0xad] = '[';
-		tub_ebcasc[0xbd] = ']';
-		tub_ascebc['^'] = 0xb0;
-		tub_ebcasc[0x5f] = '^';
-	}
-
-	rc = tubinitminors();
-	if (rc != 0)
-		return rc;
-
-	if (fs3270_init() || tty3270_init()) {
-		printk(KERN_ERR "fs3270_init() or tty3270_init() failed\n");
-		fs3270_fini();
-		tty3270_fini();
-		tubfiniminors();
-		return -1;
-	}
-
-	for (i = get_irq_first(); i >= 0; i = get_irq_next(i)) {
-		if ((rc = get_dev_info_by_irq(i, &d)))
-			continue;
-		if (d.status)
-			continue;
-
-#ifdef CONFIG_TN3270_CONSOLE
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
-		if (d.sid_data.cu_type == 0x3215 && MACHINE_IS_VM) {
-			cpcmd("TERM CONMODE 3270", NULL, 0);
-			d.sid_data.cu_type = 0x3270;
-		}
-#else
-		if (d.sid_data.cu_type == 0x3215 && CONSOLE_IS_3270) {
-			cpcmd("TERM CONMODE 3270", NULL, 0);
-			d.sid_data.cu_type = 0x3270;
-		}
-#endif /* LINUX_VERSION_CODE */
-#endif /* CONFIG_TN3270_CONSOLE */
-		if (!tub3270_is_ours(&d))
-			continue;
-
-		rc = tubmakemin(i, &d);
-		if (rc < 0) {
-			printk(KERN_WARNING 
-			       "3270 tube registration ran out of memory"
-			       " after %d devices\n", tubnummins - 1);
-			break;
-		} else {
-			printk(KERN_INFO "3270: %.4x on sch %d, minor %d\n",
-				d.devno, d.irq, rc);
-		}
-	}
-
-	return 0;
-}
-
-/*
- * tub3270_movedata(bcb_t *, bcb_t *) -- Move data stream
- */
-int
-tub3270_movedata(bcb_t *ib, bcb_t *ob, int fromuser)
-{
-	int count;			/* Total move length */
-	int rc;
-
-	rc = count = MIN(ib->bc_cnt, ob->bc_len - ob->bc_cnt);
-	while (count > 0) {
-		int len1;		/* Contig bytes avail in ib */
-
-		if (ib->bc_wr > ib->bc_rd)
-			len1 = ib->bc_wr - ib->bc_rd;
-		else
-			len1 = ib->bc_len - ib->bc_rd;
-		if (len1 > count)
-			len1 = count;
-
-		while (len1 > 0) {
-			int len2;	/* Contig space avail in ob */
-
-			if (ob->bc_rd > ob->bc_wr)
-				len2 = ob->bc_rd - ob->bc_wr;
-			else
-				len2 = ob->bc_len - ob->bc_wr;
-			if (len2 > len1)
-				len2 = len1;
-			
-			if (fromuser) {
-				len2 -= copy_from_user(ob->bc_buf + ob->bc_wr,
-						       ib->bc_buf + ib->bc_rd,
-						       len2);
-				if (len2 == 0) {
-					if (!rc)
-						rc = -EFAULT;
-					break;
-				}
-			} else
-				memcpy(ob->bc_buf + ob->bc_wr,
-				       ib->bc_buf + ib->bc_rd,
-				       len2);
-			
-			ib->bc_rd += len2;
-			if (ib->bc_rd == ib->bc_len)
-				ib->bc_rd = 0;
-			ib->bc_cnt -= len2;
-
-			ob->bc_wr += len2;
-			if (ob->bc_wr == ob->bc_len)
-				ob->bc_wr = 0;
-			ob->bc_cnt += len2;
-
-			len1 -= len2;
-			count -= len2;
-		}
-	}
-	return rc;
-}
-
-/*
- * receive an interrupt
- */
-static void
-tubint(int irq, void *ipp, struct pt_regs *prp)
-{
-	devstat_t *dsp = ipp;
-	tub_t *tubp;
-
-	if ((tubp = IRQ2TUB(irq)) && (tubp->intv))
-		(tubp->intv)(tubp, dsp);
-}
-
-/*
- * Initialize array of pointers to minor structures tub_t.
- * Returns 0 or -ENOMEM.
- */
-static int
-tubinitminors(void)
-{
-	tubminors = (tub_t *(*)[TUBMAXMINS])kmalloc(sizeof *tubminors,
-		GFP_KERNEL);
-	if (tubminors == NULL)
-		return -ENOMEM;
-	memset(tubminors, 0, sizeof *tubminors);
-	return 0;
-}
-
-/*
- * Add a minor 327x device.  Argument is an irq value.
- *
- * Point elements of two arrays to the newly created tub_t:
- * 1. (*tubminors)[minor]
- * 2. (*(*tubirqs)[irqhi])[irqlo]
- * The first looks up from minor number at context time; the second
- * looks up from irq at interrupt time.
- */
-static int
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
-tubmakemin(int irq, dev_info_t *dp)
-#else
-tubmakemin(int irq, s390_dev_info_t *dp)
-#endif
-{
-	tub_t *tubp;
-	int minor;
-	long flags;
-
-	if ((minor = ++tubnummins) == TUBMAXMINS)
-		return -ENODEV;
-
-	tubp = kmalloc(sizeof(tub_t), GFP_KERNEL);
-	if (tubp == NULL) {
-		return -ENOMEM;
-	}
-	if (tubaddbyirq(tubp, irq) != 0) {
-		kfree(tubp);
-		return -ENOMEM;
-	}
-	memset(tubp, 0, sizeof(tub_t));
-	tubp->minor = minor;
-	tubp->irq = irq;
-	TUBLOCK(tubp->irq, flags);
-	tubp->devno = dp->devno;
-	tubp->geom_rows = _GEOM_ROWS;
-	tubp->geom_cols = _GEOM_COLS;
-	init_waitqueue_head(&tubp->waitq);
-
-	tubp->tty_bcb.bc_len = TTY_OUTPUT_SIZE;
-	tubp->tty_bcb.bc_buf = (void *)kmalloc(tubp->tty_bcb.bc_len,
-		GFP_KERNEL|GFP_DMA);
-	if (tubp->tty_bcb.bc_buf == NULL) {
-		TUBUNLOCK(tubp->irq, flags);
-		tubdelbyirq(tubp, irq);
-		kfree(tubp);
-		return -ENOMEM;
-	}
-	tubp->tty_bcb.bc_cnt = 0;
-	tubp->tty_bcb.bc_wr = 0;
-	tubp->tty_bcb.bc_rd = 0;
-	(*tubminors)[minor] = tubp;
-
-#ifdef CONFIG_TN3270_CONSOLE
-	if (CONSOLE_IS_3270) {
-		if (tub3270_con_tubp == NULL && 
-		    tub3270_con_bcb.bc_buf != NULL &&
-		    (tub3270_con_devno == -1 ||
-		     tub3270_con_devno == dp->devno)) {
-			extern void tty3270_int(tub_t *, devstat_t *);
-			
-			tub3270_con_devno = dp->devno;
-			tubp->cmd = TBC_CONOPEN;
-			tubp->flags |= TUB_OPEN_STET | TUB_INPUT_HACK;
-			tty3270_size(tubp, &flags);
-			tty3270_aid_init(tubp);
-			tty3270_scl_init(tubp);
-			tub3270_con_irq = tubp->irq;
-			tub3270_con_tubp = tubp;
-			tubp->intv = tty3270_int;
-			tubp->cmd = TBC_UPDSTAT;
-			tty3270_build(tubp);
-		}
-	}
-#endif /* CONFIG_TN3270_CONSOLE */
-
-	devfs_mk_cdev(MKDEV(IBM_FS3270_MAJOR, tubp->minor),
-			S_IFCHR|S_IRUSR|S_IWUSR, "3270/tub%.4x");
-
-	TUBUNLOCK(tubp->irq, flags);
-	return minor;
-}
-
-/*
- * Release array of pointers to minor structures tub_t, but first
- * release any storage pointed to by them.
- */
-static void
-tubfiniminors(void)
-{
-	int i;
-	tub_t **tubpp, *tubp;
-
-	if (tubminors == NULL)
-		return;
-
-	for (i = 0; i < TUBMAXMINS; i++) {
-		tubpp = &(*tubminors)[i];
-		if ((tubp = *tubpp)) {
-			devfs_remove("3270/tub%.4x", tubp->devno);
-			tubdelbyirq(tubp, tubp->irq);
-			tty3270_rcl_fini(tubp);
-			kfree(tubp->tty_bcb.bc_buf);
-			tubp->tty_bcb.bc_buf = NULL;
-			if (tubp->tty_input) {
-				kfree(tubp->tty_input);
-				tubp->tty_input = NULL;
-			}
-			tubp->ttyscreen = NULL;
-			kfree(tubp);
-			*tubpp = NULL;
-		}
-	}
-	kfree(tubminors);
-	tubminors = NULL;
-	tubfiniirqs();
-}
-
-/*
- * tubaddbyirq() -- Add tub_t for irq lookup in tubint()
- */
-static int
-tubaddbyirq(tub_t *tubp, int irq)
-{
-	int irqhi = (irq >> 8) & 255;
-	int irqlo = irq & 255;
-	tub_t *(*itubpp)[256];
-
-	/* Allocate array (*tubirqs)[] if first time */
-	if (tubirqs == NULL) {
-		tubirqs = (tub_t *(*(*)[256])[256])
-			kmalloc(sizeof *tubirqs, GFP_KERNEL);
-		if (tubirqs == NULL)
-			return -ENOMEM;
-		memset(tubirqs, 0, sizeof *tubirqs);
-	}
-
-	/* Allocate subarray (*(*tubirqs)[])[] if first use */
-	if ((itubpp = (*tubirqs)[irqhi]) == NULL) {
-		itubpp = (tub_t *(*)[256])
-			kmalloc(sizeof(*itubpp), GFP_KERNEL);
-		if (itubpp == NULL) {
-			if (tubnummins == 1) {  /* if first time */
-				kfree(tubirqs);
-				tubirqs = NULL;
-			}
-			return -ENOMEM;
-		} else {
-			memset(itubpp, 0, sizeof(*itubpp));
-			(*tubirqs)[irqhi] = itubpp;
-		}
-	}
-
-	/* Request interrupt service */
-	if ((tubp->irqrc = request_irq(irq, tubint, SA_INTERRUPT,
-	    "3270 tube driver", &tubp->devstat)) != 0)
-		return tubp->irqrc;
-
-	/* Fill in the proper subarray element */
-	(*itubpp)[irqlo] = tubp;
-	return 0;
-}
-
-/*
- * tubfindbyirq(irq)
- */
-static tub_t *
-tubfindbyirq(int irq)
-{
-	int irqhi = (irq >> 8) & 255;
-	int irqlo = irq & 255;
-	tub_t *tubp;
-
-	if (tubirqs == NULL)
-		return NULL;
-	if ((*tubirqs)[irqhi] == NULL)
-		return NULL;
-	tubp = (*(*tubirqs)[irqhi])[irqlo];
-	if (tubp->irq == irq)
-		return tubp;
-	return NULL;
-}
-
-/*
- * tubdelbyirq(tub_t*, irq)
- */
-static void
-tubdelbyirq(tub_t *tubp, int irq)
-{
-	int irqhi = (irq >> 8) & 255;
-	int irqlo = irq & 255;
-	tub_t *(*itubpp)[256], *itubp;
-
-	if (tubirqs == NULL) {
-		printk(KERN_ERR "tubirqs is NULL\n");
-		return;
-	}
-	itubpp = (*tubirqs)[irqhi];
-	if (itubpp == NULL) {
-		printk(KERN_ERR "tubirqs[%d] is NULL\n", irqhi);
-		return;
-	}
-	itubp = (*itubpp)[irqlo];
-	if (itubp == NULL) {
-		printk(KERN_ERR "tubirqs[%d][%d] is NULL\n", irqhi, irqlo);
-		return;
-	}
-	if (itubp->irqrc == 0)
-		free_irq(irq, &itubp->devstat);
-	(*itubpp)[irqlo] = NULL;
-}
-
-/*
- * tubfiniirqs() -- clean up storage in tub_t *(*(*tubirqs)[256])[256]
- */
-static void
-tubfiniirqs(void)
-{
-	int i;
-	tub_t *(*itubpp)[256];
-
-	if (tubirqs != NULL) {
-		for (i = 0; i < 256; i++) {
-			if ((itubpp = (*tubirqs)[i])) {
-				kfree(itubpp);
-				(*tubirqs)[i] = NULL;
-			}
-		}
-		kfree(tubirqs);
-		tubirqs = NULL;
-	}
-}
-
-module_init(tub3270_init);
-module_exit(tub3270_exit);
diff -puN -L drivers/s390/char/tubfs.c drivers/s390/char/tubfs.c~linus /dev/null
--- 25/drivers/s390/char/tubfs.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,473 +0,0 @@
-/*
- *  IBM/3270 Driver -- Copyright (C) UTS Global LLC
- *
- *  tubfs.c -- Fullscreen driver
- *
- *
- *
- *
- *
- *  Author:  Richard Hitt
- */
-#include "tubio.h"
-
-int fs3270_major = -1;			/* init to impossible -1 */
-
-static int fs3270_open(struct inode *, struct file *);
-static int fs3270_close(struct inode *, struct file *);
-static int fs3270_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
-static ssize_t fs3270_read(struct file *, char *, size_t, loff_t *);
-static ssize_t fs3270_write(struct file *, const char *, size_t, loff_t *);
-static int fs3270_wait(tub_t *, long *);
-static void fs3270_int(tub_t *tubp, devstat_t *dsp);
-extern void tty3270_refresh(tub_t *);
-
-static struct file_operations fs3270_fops = {
-	.owner = THIS_MODULE,		/* owner */
-	.read 	= fs3270_read,	/* read */
-	.write	= fs3270_write,	/* write */
-	.ioctl	= fs3270_ioctl,	/* ioctl */
-	.open 	= fs3270_open,	/* open */
-	.release = fs3270_close,	/* release */
-};
-
-/*
- * fs3270_init() -- Initialize fullscreen tubes
- */
-int
-fs3270_init(void)
-{
-	int rc;
-
-	rc = register_chrdev(IBM_FS3270_MAJOR, "fs3270", &fs3270_fops);
-	if (rc) {
-		printk(KERN_ERR "tubmod can't get major nbr %d: error %d\n",
-			IBM_FS3270_MAJOR, rc);
-		return -1;
-	}
-	devfs_mk_dir("3270");
-	devfs_mk_cdev(MKDEV(IBM_FS3270_MAJOR, 0),
-			S_IFCHR|S_IRUGO|S_IWUGO, "3270/tub");
-	fs3270_major = IBM_FS3270_MAJOR;
-	return 0;
-}
-
-/*
- * fs3270_fini() -- Uninitialize fullscreen tubes
- */
-void
-fs3270_fini(void)
-{
-	if (fs3270_major != -1) {
-		devfs_remove("3270");
-		devfs_remove("3270/tub");
-		unregister_chrdev(fs3270_major, "fs3270");
-		fs3270_major = -1;
-	}
-}
-
-/*
- * fs3270_open
- */
-static int
-fs3270_open(struct inode *ip, struct file *fp)
-{
-	tub_t *tubp;
-	long flags;
-
-	/* See INODE2TUB(ip) for handling of "/dev/3270/tub" */
-	if ((tubp = INODE2TUB(ip)) == NULL)
-		return -ENOENT;
-
-	TUBLOCK(tubp->irq, flags);
-	if (tubp->mode == TBM_FS || tubp->mode == TBM_FSLN) {
-		TUBUNLOCK(tubp->irq, flags);
-		return -EBUSY;
-	}
-
-	fp->private_data = ip;
-	tubp->mode = TBM_FS;
-	tubp->intv = fs3270_int;
-	tubp->dstat = 0;
-	tubp->fs_pid = current->pid;
-	tubp->fsopen = 1;
-	TUBUNLOCK(tubp->irq, flags);
-	return 0;
-}
-
-/*
- * fs3270_close aka release:  free the irq
- */
-static int
-fs3270_close(struct inode *ip, struct file *fp)
-{
-	tub_t *tubp;
-	long flags;
-
-	if ((tubp = INODE2TUB(ip)) == NULL)
-		return -ENODEV;
-
-	fs3270_wait(tubp, &flags);
-	tubp->fsopen = 0;
-	tubp->fs_pid = 0;
-	tubp->intv = NULL;
-	tubp->mode = 0;
-	tty3270_refresh(tubp);
-	TUBUNLOCK(tubp->irq, flags);
-	return 0;
-}
-
-/*
- * fs3270_release() called from tty3270_hangup()
- */
-void
-fs3270_release(tub_t *tubp)
-{
-	long flags;
-
-	if (tubp->mode != TBM_FS)
-		return;
-	fs3270_wait(tubp, &flags);
-	tubp->fsopen = 0;
-	tubp->fs_pid = 0;
-	tubp->intv = NULL;
-	tubp->mode = 0;
-	/*tty3270_refresh(tubp);*/
-	TUBUNLOCK(tubp->irq, flags);
-}
-
-/*
- * fs3270_wait(tub_t *tubp, int *flags) -- Wait to use tube
- * Entered without irq lock
- * On return:
- *      * Lock is held
- *      * Value is 0 or -ERESTARTSYS
- */
-static int
-fs3270_wait(tub_t *tubp, long *flags)
-{
-	DECLARE_WAITQUEUE(wait, current);
-
-	TUBLOCK(tubp->irq, *flags);
-	add_wait_queue(&tubp->waitq, &wait);
-	while (!signal_pending(current) &&
-	    ((tubp->mode != TBM_FS) ||
-	     (tubp->flags & (TUB_WORKING | TUB_RDPENDING)) != 0)) {
-#warning FIXME: [kj] use set_current_state instead of current->state=
-		current->state = TASK_INTERRUPTIBLE;
-		TUBUNLOCK(tubp->irq, *flags);
-		schedule();
-#warning FIXME: [kj] use set_current_state instead of current->state=
-		current->state = TASK_RUNNING;
-		TUBLOCK(tubp->irq, *flags);
-	}
-	remove_wait_queue(&tubp->waitq, &wait);
-	return signal_pending(current)? -ERESTARTSYS: 0;
-}
-
-/*
- * fs3270_io(tubp, ccw1_t*) -- start I/O on the tube
- * Entered with irq lock held, WORKING off
- */
-static int
-fs3270_io(tub_t *tubp, ccw1_t *ccwp)
-{
-	int rc;
-
-	rc = do_IO(tubp->irq, ccwp, tubp->irq, 0, 0);
-	tubp->flags |= TUB_WORKING;
-	tubp->dstat = 0;
-	return rc;
-}
-
-/*
- * fs3270_tasklet(tubp) -- Perform back-half processing
- */
-static void
-fs3270_tasklet(unsigned long data)
-{
-	long flags;
-	tub_t *tubp;
-	addr_t *ip;
-
-	tubp = (tub_t *) data;
-	TUBLOCK(tubp->irq, flags);
-	tubp->flags &= ~TUB_BHPENDING;
-
-	if (tubp->wbuf) {       /* if we were writing */
-		for (ip = tubp->wbuf; ip < tubp->wbuf+33; ip++) {
-			if (*ip == 0)
-				break;
-			kfree(phys_to_virt(*ip));
-		}
-		kfree(tubp->wbuf);
-		tubp->wbuf = NULL;
-	}
-
-	if ((tubp->flags & (TUB_ATTN | TUB_RDPENDING)) ==
-	    (TUB_ATTN | TUB_RDPENDING)) {
-		fs3270_io(tubp, &tubp->rccw);
-		tubp->flags &= ~(TUB_ATTN | TUB_RDPENDING);
-	}
-
-	if ((tubp->flags & TUB_WORKING) == 0)
-		wake_up_interruptible(&tubp->waitq);
-
-	TUBUNLOCK(tubp->irq, flags);
-}
-
-/*
- * fs3270_sched_tasklet(tubp) -- Schedule the back half
- * Irq lock must be held on entry and remains held on exit.
- */
-static void
-fs3270_sched_tasklet(tub_t *tubp)
-{
-	if (tubp->flags & TUB_BHPENDING)
-		return;
-	tubp->flags |= TUB_BHPENDING;
-	tasklet_init(&tubp->tasklet, fs3270_tasklet,
-		     (unsigned long) tubp);
-	tasklet_schedule(&tubp->tasklet);
-}
-
-/*
- * fs3270_int(tubp, prp) -- Process interrupt from tube in FS mode
- * This routine is entered with irq lock held (see do_IRQ in s390io.c)
- */
-static void
-fs3270_int(tub_t *tubp, devstat_t *dsp)
-{
-#define	DEV_UE_BUSY \
-	(DEV_STAT_CHN_END | DEV_STAT_DEV_END | DEV_STAT_UNIT_EXCEP)
-
-#ifdef RBHNOTYET
-	/* XXX needs more work; must save 2d arg to fs370_io() */
-	/* Handle CE-DE-UE and subsequent UDE */
-	if (dsp->dstat == DEV_UE_BUSY) {
-		tubp->flags |= TUB_UE_BUSY;
-		return;
-	} else if (tubp->flags & TUB_UE_BUSY) {
-		tubp->flags &= ~TUB_UE_BUSY;
-		if (dsp->dstat == DEV_STAT_DEV_END &&
-		    (tubp->flags & TUB_WORKING) != 0) {
-			fs3270_io(tubp);
-			return;
-		}
-	}
-#endif
-
-	/* Handle ATTN */
-	if (dsp->dstat & DEV_STAT_ATTENTION)
-		tubp->flags |= TUB_ATTN;
-
-	if (dsp->dstat & DEV_STAT_CHN_END) {
-		tubp->cswl = dsp->rescnt;
-		if ((dsp->dstat & DEV_STAT_DEV_END) == 0)
-			tubp->flags |= TUB_EXPECT_DE;
-		else
-			tubp->flags &= ~TUB_EXPECT_DE;
-	} else if (dsp->dstat & DEV_STAT_DEV_END) {
-		if ((tubp->flags & TUB_EXPECT_DE) == 0)
-			tubp->flags |= TUB_UNSOL_DE;
-		tubp->flags &= ~TUB_EXPECT_DE;
-	}
-	if (dsp->dstat & DEV_STAT_DEV_END)
-		tubp->flags &= ~TUB_WORKING;
-
-	if ((tubp->flags & TUB_WORKING) == 0)
-		fs3270_sched_tasklet(tubp);
-}
-
-/*
- * process ioctl commands for the tube driver
- */
-static int
-fs3270_ioctl(struct inode *ip, struct file *fp,
-	unsigned int cmd, unsigned long arg)
-{
-	tub_t *tubp;
-	int rc = 0;
-	long flags;
-
-	if ((tubp = INODE2TUB(ip)) == NULL)
-		return -ENODEV;
-	if ((rc = fs3270_wait(tubp, &flags))) {
-		TUBUNLOCK(tubp->irq, flags);
-		return rc;
-	}
-
-	switch(cmd) {
-	case TUBICMD: tubp->icmd = arg; break;
-	case TUBOCMD: tubp->ocmd = arg; break;
-	case TUBGETI: put_user(tubp->icmd, (char *)arg); break;
-	case TUBGETO: put_user(tubp->ocmd, (char *)arg); break;
-	case TUBGETMOD:
-		if (copy_to_user((char *)arg, &tubp->tubiocb,
-		    sizeof tubp->tubiocb))
-			rc = -EFAULT;
-		break;
-	}
-	TUBUNLOCK(tubp->irq, flags);
-	return rc;
-}
-
-/*
- * process read commands for the tube driver
- */
-static ssize_t
-fs3270_read(struct file *fp, char *dp, size_t len, loff_t *off)
-{
-	tub_t *tubp;
-	char *kp;
-	ccw1_t *cp;
-	int rc;
-	long flags;
-	addr_t *idalp, *ip;
-	char *tp;
-	int count, piece;
-	int size;
-
-	if (len == 0 || len > 65535) {
-		return -EINVAL;
-	}
-
-	if ((tubp = INODE2TUB((struct inode *)fp->private_data)) == NULL)
-		return -ENODEV;
-
-	ip = idalp = kmalloc(33*sizeof(addr_t), GFP_ATOMIC|GFP_DMA);
-	if (idalp == NULL)
-		return -EFAULT;
-	memset(idalp, 0, 33 * sizeof *idalp);
-	count = len;
-	while (count) {
-		piece = MIN(count, 0x800);
-		size = count == len? piece: 0x800;
-		if ((kp = kmalloc(size, GFP_KERNEL|GFP_DMA)) == NULL) {
-			len = -ENOMEM;
-			goto do_cleanup;
-		}
-		*ip++ = virt_to_phys(kp);
-		count -= piece;
-	}
-
-	if ((rc = fs3270_wait(tubp, &flags)) != 0) {
-		TUBUNLOCK(tubp->irq, flags);
-		len = rc;
-		goto do_cleanup;
-	}
-	cp = &tubp->rccw;
-	if (tubp->icmd == 0 && tubp->ocmd != 0)  tubp->icmd = 6;
-	cp->cmd_code = tubp->icmd?:2;
-	cp->flags = CCW_FLAG_SLI | CCW_FLAG_IDA;
-	cp->count = len;
-	cp->cda = virt_to_phys(idalp);
-	tubp->flags |= TUB_RDPENDING;
-	TUBUNLOCK(tubp->irq, flags);
-
-	if ((rc = fs3270_wait(tubp, &flags)) != 0) {
-		tubp->flags &= ~TUB_RDPENDING;
-		len = rc;
-		TUBUNLOCK(tubp->irq, flags);
-		goto do_cleanup;
-	}
-	TUBUNLOCK(tubp->irq, flags);
-
-	len -= tubp->cswl;
-	count = len;
-	tp = dp;
-	ip = idalp;
-	while (count) {
-		piece = MIN(count, 0x800);
-		if (copy_to_user(tp, phys_to_virt(*ip), piece) != 0) {
-			len = -EFAULT;
-			goto do_cleanup;
-		}
-		count -= piece;
-		tp += piece;
-		ip++;
-	}
-
-do_cleanup:
-	for (ip = idalp; ip < idalp+33; ip++) {
-		if (*ip == 0)
-			break;
-		kfree(phys_to_virt(*ip));
-	}
-	kfree(idalp);
-	return len;
-}
-
-/*
- * process write commands for the tube driver
- */
-static ssize_t
-fs3270_write(struct file *fp, const char *dp, size_t len, loff_t *off)
-{
-	tub_t *tubp;
-	ccw1_t *cp;
-	int rc;
-	long flags;
-	void *kb;
-	addr_t *idalp, *ip;
-	int count, piece;
-	int index;
-	int size;
-
-	if (len > 65535 || len == 0)
-		return -EINVAL;
-
-	/* Locate the tube */
-	if ((tubp = INODE2TUB((struct inode *)fp->private_data)) == NULL)
-		return -ENODEV;
-
-	ip = idalp = kmalloc(33*sizeof(addr_t), GFP_ATOMIC|GFP_DMA);
-	if (idalp == NULL)
-		return -EFAULT;
-	memset(idalp, 0, 33 * sizeof *idalp);
-
-	count = len;
-	index = 0;
-	while (count) {
-		piece = MIN(count, 0x800);
-		size = count == len? piece: 0x800;
-		if ((kb = kmalloc(size, GFP_KERNEL|GFP_DMA)) == NULL) {
-			len = -ENOMEM;
-			goto do_cleanup;
-		}
-		*ip++ = virt_to_phys(kb);
-		if (copy_from_user(kb, &dp[index], piece) != 0) {
-			len = -EFAULT;
-			goto do_cleanup;
-		}
-		count -= piece;
-		index += piece;
-	}
-
-	/* Wait till tube's not working or signal is pending */
-	if ((rc = fs3270_wait(tubp, &flags))) {
-		len = rc;
-		TUBUNLOCK(tubp->irq, flags);
-		goto do_cleanup;
-	}
-
-	/* Make CCW and start I/O.  Back end will free buffers & idal. */
-	tubp->wbuf = idalp;
-	cp = &tubp->wccw;
-	cp->cmd_code = tubp->ocmd? tubp->ocmd == 5? 13: tubp->ocmd: 1;
-	cp->flags = CCW_FLAG_SLI | CCW_FLAG_IDA;
-	cp->count = len;
-	cp->cda = virt_to_phys(tubp->wbuf);
-	fs3270_io(tubp, cp);
-	TUBUNLOCK(tubp->irq, flags);
-	return len;
-
-do_cleanup:
-	for (ip = idalp; ip < idalp+33; ip++) {
-		if (*ip == 0)
-			break;
-		kfree(phys_to_virt(*ip));
-	}
-	kfree(idalp);
-	return len;
-}
diff -puN -L drivers/s390/char/tubio.h drivers/s390/char/tubio.h~linus /dev/null
--- 25/drivers/s390/char/tubio.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,417 +0,0 @@
-/*
- *  IBM/3270 Driver -- Copyright (C) 2000 UTS Global LLC
- *
- *  tubio.h -- All-Purpose header file
- *
- *
- *
- *
- *
- *  Author:  Richard Hitt
- */
-#include <linux/config.h>
-
-#include <linux/module.h>
-#include <linux/version.h>
-#include <linux/tty.h>
-
-#include <linux/major.h>
-#ifndef IBM_TTY3270_MAJOR
-#  define IBM_TTY3270_MAJOR 212
-#endif /* IBM_TTY3270_MAJOR */
-#ifndef IBM_FS3270_MAJOR
-#  define IBM_FS3270_MAJOR 213
-#endif /* IBM_FS3270_MAJOR */
-
-
-#include <linux/slab.h>
-#include <asm/irq.h>
-#include <asm/io.h>
-#include <asm/idals.h>
-#include <linux/console.h>
-#include <linux/interrupt.h>
-#include <asm/ebcdic.h>
-#include <asm/uaccess.h>
-#include <linux/proc_fs.h>
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0))
-#include <linux/devfs_fs_kernel.h>
-#endif
-
-#define TUB(x) (('3'<<8)|(x))
-#define TUBICMD TUB(3)
-#define TUBOCMD TUB(4)
-#define TUBGETI TUB(7)
-#define TUBGETO TUB(8)
-#define TUBSETMOD TUB(12)
-#define TUBGETMOD TUB(13)
-#define TIOPOLL TUB(32)
-#define TIOPOKE TUB(33)
-#define TIONPOKE TUB(34)
-#define TIOTNORM TUB(35)
-
-/* Local Channel Commands */
-#define TC_WRITE   0x01
-#define TC_EWRITE  0x05
-#define TC_READMOD 0x06
-#define TC_EWRITEA 0x0d
-#define TC_WRITESF 0x11
-
-/* Buffer Control Orders */
-#define TO_SF 0x1d
-#define TO_SBA 0x11
-#define TO_IC 0x13
-#define TO_PT 0x05
-#define TO_RA 0x3c
-#define TO_SFE 0x29
-#define TO_EUA 0x12
-#define TO_MF 0x2c
-#define TO_SA 0x28
-
-/* Field Attribute Bytes */
-#define TF_INPUT 0x40           /* Visible input */
-#define TF_INPUTN 0x4c          /* Invisible input */
-#define TF_INMDT 0xc1           /* Visible, Set-MDT */
-#define TF_LOG 0x60
-#define TF_STAT 0x60
-
-/* Character Attribute Bytes */
-#define TAT_RESET 0x00
-#define TAT_FIELD 0xc0
-#define TAT_EXTHI 0x41
-#define TAT_COLOR 0x42
-#define TAT_CHARS 0x43
-#define TAT_TRANS 0x46
-
-/* Extended-Highlighting Bytes */
-#define TAX_RESET 0x00
-#define TAX_BLINK 0xf1
-#define TAX_REVER 0xf2
-#define TAX_UNDER 0xf4
-
-/* Reset value */
-#define TAR_RESET 0x00
-
-/* Color values */
-#define TAC_RESET 0x00
-#define TAC_BLUE 0xf1
-#define TAC_RED 0xf2
-#define TAC_PINK 0xf3
-#define TAC_GREEN 0xf4
-#define TAC_TURQ 0xf5
-#define TAC_YELLOW 0xf6
-#define TAC_WHITE 0xf7
-#define TAC_DEFAULT 0x00
-
-/* Write Control Characters */
-#define TW_NONE 0x40            /* No particular action */
-#define TW_KR 0xc2              /* Keyboard restore */
-#define TW_PLUSALARM 0x04       /* Add this bit for alarm */
-
-/* Attention-ID (AID) Characters */
-#define TA_CLEAR 0x6d
-#define TA_PA2 0x6e
-#define TA_ENTER 0x7d
-/* more to come */
-
-#define MIN(a, b) ((a) < (b)? (a): (b))
-
-#define TUB_BUFADR(adr, cpp) \
-	tty3270_tub_bufadr(tubp, adr, cpp)
-
-#define TUB_EBCASC(addr, nr) codepage_convert(tub_ebcasc, addr, nr)
-#define TUB_ASCEBC(addr, nr) codepage_convert(tub_ascebc, addr, nr)
-
-/*
- *
- * General global values for the tube driver
- *
- */
-enum tubmode {
-	TBM_LN,                 /* Line mode */
-	TBM_FS,                 /* Fullscreen mode */
-	TBM_FSLN                /* Line mode shelled out of fullscreen */
-};
-enum tubstat {              /* normal-mode status */
-	TBS_RUNNING,            /* none of the following */
-	TBS_MORE,               /* timed "MORE..." in status */
-	TBS_HOLD                /* untimed "HOLDING" in status */
-};
-enum tubcmd {           /* normal-mode actions to do */
-	TBC_CONOPEN,		/* Erase-write the console */
-	TBC_OPEN,               /* Open the tty screen */
-	TBC_UPDATE,             /* Add lines to the log, clear cmdline */
-	TBC_UPDLOG,             /* Add lines to log */
-	TBC_KRUPDLOG,           /* Add lines to log, reset kbd */
-	TBC_CLEAR,              /* Build screen from scratch */
-	TBC_CLRUPDLOG,          /* Do log & status, not cmdline */
-	TBC_UPDSTAT,            /* Do status update only */
-	TBC_CLRINPUT,           /* Clear input area only */
-	TBC_UPDINPUT            /* Update input area only */
-};
-enum tubwhat {          /* echo what= proc actions */
-	TW_BOGUS,               /* Nothing at all */
-	TW_CONFIG               /* Output configuration info */
-};
-
-
-
-
-
-#define TUBMAXMINS      256
-#define _GEOM_ROWS 24
-#define _GEOM_COLS 80
-#define GEOM_ROWS (tubp->geom_rows)
-#define GEOM_COLS (tubp->geom_cols)
-#define GEOM_MAXROWS 127
-#define GEOM_MAXCOLS 132
-#define GEOM_INPLEN (GEOM_COLS * 2 - 20)
-#define GEOM_MAXINPLEN (GEOM_MAXCOLS * 2 - 20)
-#define GEOM_INPUT (GEOM_COLS * (GEOM_ROWS - 2) - 1)  /* input atr posn */
-#define GEOM_STAT (GEOM_INPUT + 1 + GEOM_INPLEN)
-#define GEOM_LOG   (GEOM_COLS * GEOM_ROWS - 1)   /* log atr posn */
-#define TS_RUNNING "Linux Running     "
-#define TS_MORE    "Linux More...     "
-#define DEFAULT_SCROLLTIME 5
-#define TS_HOLD    "Linux Holding     "
-/* data length used by tty3270_set_status_area: SBA (3), SF (2), data */
-#define TS_LENGTH (sizeof TS_RUNNING + 3 + 2)
-
-typedef struct {
-	int aid;                        /* What-to-do flags */
-	char *string;                   /* Optional input string */
-} aid_t;
-#define AIDENTRY(ch, tubp)  (&((tubp)->tty_aid[(ch) & 0x3f]))
-
-/* For TUBGETMOD and TUBSETMOD.  Should include. */
-typedef struct tubiocb {
-	short model;
-	short line_cnt;
-	short col_cnt;
-	short pf_cnt;
-	short re_cnt;
-	short map;
-} tubiocb_t;
-
-/* Flags that go in int aid, above */
-#define TA_CLEARKEY     0x01            /* Key does hardware CLEAR */
-#define TA_SHORTREAD    0x02            /* Key does hardware shortread */
-/* If both are off, key does hardware Read Modified. */
-#define TA_DOENTER      0x04            /* Treat key like ENTER */
-#define TA_DOSTRING     0x08            /* Use string and ENTER */
-#define TA_DOSTRINGD    0x10            /* Display string & set MDT */
-#define TA_CLEARLOG     0x20            /* Make key cause clear of log */
-
-/*
- * Tube driver buffer control block
- */
-typedef struct bcb_s {
-	char	*bc_buf;		/* Pointer to buffer */
-	int	bc_len;			/* Length of buffer */
-	int	bc_cnt;			/* Count of bytes buffered */
-	int	bc_wr;			/* Posn to write next byte into */
-	int	bc_rd;			/* Posn to read next byte from */
-} bcb_t;
-
-typedef struct tub_s {
-	int             minor;
-	int             irq;
-	int             irqrc;
-	int             devno;
-	int             geom_rows;
-	int             geom_cols;
-	tubiocb_t       tubiocb;
-	int             lnopen;
-	int             fsopen;
-	int             icmd;
-	int             ocmd;
-	devstat_t       devstat;
-	ccw1_t          rccw;
-	ccw1_t          wccw;
-	addr_t		*wbuf;
-	int             cswl;
-	void            (*intv)(struct tub_s *, devstat_t *);
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
-	struct wait_queue	*waitq;
-#else
-	wait_queue_head_t waitq;
-#endif
-	int             dstat;
-	sense_t         sense;
-	enum tubmode    mode;
-	enum tubstat    stat;
-	enum tubcmd     cmd;
-	int             flags;		/* See below for values */
-	struct tasklet_struct tasklet;
-
-	/* Stuff for fs-driver support */
-	pid_t           fs_pid;         /* Pid if TBM_FS */
-
-
-	/* Stuff for tty-driver support */
-	struct tty_struct *tty;
-	char *tty_input;		/* tty input area */
-	int tty_inattr;         	/* input-area field attribute */
-#define TTY_OUTPUT_SIZE 1024
-	bcb_t tty_bcb;			/* Output buffer control info */
-	int tty_oucol;                  /* Kludge */
-	int tty_nextlogx;               /* next screen-log position */
-	int tty_savecursor;		/* saved cursor position */
-	int tty_scrolltime;             /* scrollforward wait time, sec */
-	struct timer_list tty_stimer;   /* timer for scrolltime */
-	aid_t tty_aid[64];              /* Aid descriptors */
-	int tty_aidinit;                /* Boolean */
-	int tty_showaidx;               /* Last aid x to set_aid */
-	int tty_14bitadr;               /* 14-bit bufadrs okay */
-#define MAX_TTY_ESCA 24			/* Set-Attribute-Order array */
-	char tty_esca[MAX_TTY_ESCA];	/* SA array */
-	int tty_escx;			/* Current index within it */
-
-	/* For command recall --- */
-	char *(*tty_rclbufs)[];         /* Array of ptrs to recall bufs */
-	int tty_rclk;                   /* Size of array tty_rclbufs */
-	int tty_rclp;                   /* Index for most-recent cmd */
-	int tty_rclb;                   /* Index for backscrolling */
-
-	/* Work area to contain the hardware write stream */
-	char (*ttyscreen)[];            /* ptr to data stream area */
-	int ttyscreenl;			/* its length */
-	ccw1_t ttyccw;
-} tub_t;
-
-/* values for flags: */
-#define	TUB_WORKING	0x0001
-#define	TUB_BHPENDING	0x0002
-#define	TUB_RDPENDING	0x0004
-#define	TUB_ALARM	0x0008
-#define	TUB_SCROLLTIMING  0x0010
-#define	TUB_ATTN	0x0020
-#define	TUB_IACTIVE	0x0040
-#define	TUB_SIZED	0x0080
-#define	TUB_EXPECT_DE	0x0100
-#define	TUB_UNSOL_DE	0x0200
-#define	TUB_OPEN_STET	0x0400		/* No screen clear on open */
-#define	TUB_UE_BUSY	0x0800
-#define	TUB_INPUT_HACK	0x1000		/* Early init of command line */
-
-/*
- * Extra stuff for 3270 console support
- */
-#ifdef CONFIG_TN3270_CONSOLE
-extern int tub3270_con_devno;
-extern char (*tub3270_con_output)[];
-extern int tub3270_con_outputl;
-extern int tub3270_con_ouwr;
-extern int tub3270_con_oucount;
-extern int tub3270_con_irq;
-extern tub_t *tub3270_con_tubp;
-extern struct tty_driver tty3270_con_driver;
-#endif /* CONFIG_TN3270_CONSOLE */
-
-extern int tubnummins;
-extern tub_t *(*tubminors)[TUBMAXMINS];
-extern tub_t *(*(*tubirqs)[256])[256];
-extern unsigned char tub_ascebc[256];
-extern unsigned char tub_ebcasc[256];
-extern unsigned char tub_ebcgraf[64];
-extern int tubdebug;
-extern int fs3270_major;
-extern int tty3270_major;
-extern int tty3270_proc_misc;
-extern enum tubwhat tty3270_proc_what;
-extern struct tty_driver *tty3270_driver;
-
-#ifndef spin_trylock_irqsave
-#define spin_trylock_irqsave(lock, flags) \
-({ \
-	int success; \
-	local_irq_save(flags); \
-	success = spin_trylock(lock); \
-	if (success == 0) \
-		local_irq_restore(flags); \
-	success; \
-})
-#endif /* if not spin_trylock_irqsave */
-
-#ifndef s390irq_spin_trylock_irqsave
-#define s390irq_spin_trylock_irqsave(irq, flags) \
-	spin_trylock_irqsave(&(ioinfo[irq]->irq_lock), flags)
-#endif /* if not s390irq_spin_trylock_irqsave */
-
-#define TUBLOCK(irq, flags) \
-	s390irq_spin_lock_irqsave(irq, flags)
-
-#define TUBTRYLOCK(irq, flags) \
-	s390irq_spin_trylock_irqsave(irq, flags)
-
-#define TUBUNLOCK(irq, flags) \
-	s390irq_spin_unlock_irqrestore(irq, flags)
-
-/*
- * Find tub_t * given fullscreen device's irq (subchannel number)
- */
-#if 0
-extern tub_t *tubfindbyirq(int);
-#endif
-#define IRQ2TUB(irq) tubfindbyirq(irq)
-/*
- * Find tub_t * given fullscreen device's inode pointer
- * This algorithm takes into account /dev/3270/tub.
- */
-extern inline tub_t *INODE2TUB(struct inode *ip)
-{
-	unsigned int minor = iminor(ip);
-	tub_t *tubp = NULL;
-	if (minor == 0 && current->tty) {
-		if (current->tty->driver == tty3270_driver)
-			minor = current->tty->index;
-	}
-	if (minor <= tubnummins && minor > 0)
-		tubp = (*tubminors)[minor];
-	return tubp;
-}
-
-/*
- * Find tub_t * given non-fullscreen (tty) device's tty_struct pointer
- */
-extern inline tub_t *TTY2TUB(struct tty_struct *tty)
-{
-	unsigned index = tty->index;
-	tub_t *tubp = NULL;
-
-	if (index <= tubnummins && index > 0)
-		tubp = (*tubminors)[index];
-	return tubp;
-}
-
-extern int tub3270_movedata(bcb_t *, bcb_t *, int);
-#if 0
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0))
-extern int tubmakemin(int, dev_info_t *);
-#else
-extern int tubmakemin(int, s390_dev_info_t *);
-#endif
-#endif
-extern int tub3270_con_copy(tub_t *);
-extern int tty3270_rcl_init(tub_t *);
-extern int tty3270_rcl_set(tub_t *, char *, int);
-extern void tty3270_rcl_fini(tub_t *);
-extern int tty3270_rcl_get(tub_t *, char *, int, int);
-extern void tty3270_rcl_put(tub_t *, char *, int);
-extern void tty3270_rcl_purge(tub_t *);
-#if 0
-/* these appear to be unused outside of tubttyrcl */
-extern void tty3270_rcl_sync(tub_t *);
-extern int tty3270_rcl_resize(tub_t *, int);
-#endif
-extern int tty3270_size(tub_t *, long *);
-extern int tty3270_aid_init(tub_t *);
-extern void tty3270_aid_fini(tub_t *);
-extern void tty3270_aid_reinit(tub_t *);
-extern int tty3270_aid_get(tub_t *, int, int *, char **);
-extern int tty3270_aid_set(tub_t *, char *, int);
-extern int tty3270_build(tub_t *);
-extern void tty3270_scl_settimer(tub_t *);
-extern void tty3270_scl_resettimer(tub_t *);
-extern int tty3270_scl_set(tub_t *, char *, int);
-extern int tty3270_scl_init(tub_t *tubp);
-extern void tty3270_scl_fini(tub_t *tubp);
diff -puN -L drivers/s390/char/tubttyaid.c drivers/s390/char/tubttyaid.c~linus /dev/null
--- 25/drivers/s390/char/tubttyaid.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,205 +0,0 @@
-/*
- *  IBM/3270 Driver -- Copyright (C) 2000 UTS Global LLC
- *
- *  tubttyaid.c -- Linemode Attention-ID functionality
- *
- *
- *
- *
- *
- *  Author:  Richard Hitt
- */
-#include "tubio.h"
-
-#define PA1_STR "^C"
-#define PF3_STR "^D"
-#define PF9_STR "\033j"
-#define PF10_STR "\033k"
-#define PF11_STR "\033j"
-/* other AID-key default strings */
-
-static aid_t aidtab[64] = {
-/* 00         */	{ 0, 0 },
-/* C1 = PF13  */	{ TA_DOSTRING, 0 },
-/* C2 = PF14  */	{ TA_DOSTRING, 0 },
-/* C3 = PF15  */	{ TA_DOSTRING, 0 },
-/* C4 = PF16  */	{ TA_DOSTRING, 0 },
-/* C5 = PF17  */	{ TA_DOSTRING, 0 },
-/* C6 = PF18  */	{ TA_DOSTRING, 0 },
-/* C7 = PF19  */	{ TA_DOSTRING, 0 },
-/* C8 = PF20  */	{ TA_DOSTRING, 0 },
-/* C9 = PF21  */	{ TA_DOSTRING, 0 },
-/* 4A = PF22  */	{ TA_DOSTRING, 0 },
-/* 4B = PF23  */	{ TA_DOSTRING, 0 },
-/* 4C = PF24  */	{ TA_DOSTRING, 0 },
-/* 0D         */	{ 0, 0 },
-/* 0E         */	{ 0, 0 },
-/* 0F         */	{ 0, 0 },
-/* 10         */	{ 0, 0 },
-/* 11         */	{ 0, 0 },
-/* 12         */	{ 0, 0 },
-/* 13         */	{ 0, 0 },
-/* 14         */	{ 0, 0 },
-/* 15         */	{ 0, 0 },
-/* 16         */	{ 0, 0 },
-/* 17         */	{ 0, 0 },
-/* 18         */	{ 0, 0 },
-/* 19         */	{ 0, 0 },
-/* 1A         */	{ 0, 0 },
-/* 1B         */	{ 0, 0 },
-/* 1C         */	{ 0, 0 },
-/* 1D         */	{ 0, 0 },
-/* 1E         */	{ 0, 0 },
-/* 1F         */	{ 0, 0 },
-/* 60 = NoAID */	{ 0, 0 },
-/* 21         */	{ 0, 0 },
-/* 22         */	{ 0, 0 },
-/* 23         */	{ 0, 0 },
-/* 24         */	{ 0, 0 },
-/* 25         */	{ 0, 0 },
-/* E6 = OpRdr */	{ 0, 0 },
-/* E7 = MSRdr */	{ 0, 0 },
-/* E8 = NoAID */	{ 0, 0 },
-/* 29         */	{ 0, 0 },
-/* 2A         */	{ 0, 0 },
-/* 6B =  PA3  */        { TA_SHORTREAD, 0 },
-/* 6C =  PA1  */        { TA_SHORTREAD | TA_DOSTRING, PA1_STR },
-/* 6D = CLEAR */        { TA_SHORTREAD | TA_CLEARKEY, 0 },
-/* 6E =  PA2  */        { TA_SHORTREAD | TA_CLEARLOG, 0 },
-/* 2F         */	{ 0, 0 },
-/* F0 = TstRq */        { 0, 0 },
-/* F1 =  PF1  */	{ TA_DOSTRING, 0 },
-/* F2 =  PF2  */	{ TA_DOSTRING, 0 },
-/* F3 =  PF3  */        { TA_DOSTRING, PF3_STR },
-/* F4 =  PF4  */	{ TA_DOSTRING, 0 },
-/* F5 =  PF5  */	{ TA_DOSTRING, 0 },
-/* F6 =  PF6  */	{ TA_DOSTRING, 0 },
-/* F7 =  PF7  */	{ TA_DOSTRING, 0 },
-/* F8 =  PF8  */	{ TA_DOSTRING, 0 },
-/* F9 =  PF9  */        { TA_DOSTRING, PF9_STR },
-/* 7A = PF10  */        { TA_DOSTRING, PF10_STR },
-/* 7B = PF11  */        { TA_DOSTRING, PF11_STR },
-/* 7C = PF12  */	{ TA_DOSTRING, 0 },
-/* 7D = ENTER */        { TA_DOENTER, 0 },
-/* 7E = Pen   */        { 0, 0 },
-/* 3F         */	{ 0, 0 },
-};
-
-int
-tty3270_aid_init(tub_t *tubp)
-{
-	memcpy(tubp->tty_aid, aidtab, sizeof aidtab);
-	tubp->tty_aidinit = 1;
-	return 0;
-}
-
-void
-tty3270_aid_fini(tub_t *tubp)
-{
-	int i;
-	char *sp;
-
-	if (tubp->tty_aidinit == 0)
-		return;
-	for (i = 0; i < 64; i++) {
-		if ((sp = tubp->tty_aid[i].string) == NULL)
-			continue;
-		if (sp == aidtab[i].string)
-			continue;
-		kfree(sp);
-	}
-	tubp->tty_aidinit = 0;
-}
-
-void
-tty3270_aid_reinit(tub_t *tubp)
-{
-	tty3270_aid_fini(tubp);
-	tty3270_aid_init(tubp);
-}
-
-int
-tty3270_aid_get(tub_t *tubp, int aid, int *aidflags, char **aidstring)
-{
-	aid_t *ap;
-
-	ap = AIDENTRY(aid, tubp);
-	*aidflags = ap->aid;
-	*aidstring = ap->string;
-	return 0;
-}
-
-/*
- * tty3270_aid_set() -- write_proc extension
- * Parse written string as an AID name.  Return 0 if it's not.
- * Otherwise absorb the string and return count or -error.
- */
-int
-tty3270_aid_set(tub_t *tubp, char *buf, int count)
-{
-	char name[8];
-	char *sp;
-	int aidn, aidx;
-	aid_t *ap;
-	int len;
-	char *pfp;
-
-	if (tubp->tty_aidinit == 0)
-		return 0;
-	if (count < 3)          /* If AID-key name too short */
-		return 0;
-	name[0] = buf[0] < 0x60? buf[0]: (buf[0] & 0x5f);
-	name[1] = buf[1] < 0x60? buf[1]: (buf[1] & 0x5f);
-	if (name[0] == 'P' && name[1] == 'F') {
-		aidn = simple_strtoul(buf+2, &sp, 10);
-		if (aidn < 1 || aidn > 24)
-			return 0;
-		aidx = aidn > 12? aidn - 12: aidn + 0x30;
-		ap = &tubp->tty_aid[aidx];
-	} else if (name[0] == 'P' && name[1] == 'A') {
-		aidn = simple_strtoul(buf+2, &sp, 10);
-		if (aidn < 1 || aidn > 3)
-			return 0;
-		switch(aidn) {
-		case 1:  aidx = 0x2c; break;
-		case 2:  aidx = 0x2e; break;
-		case 3:  aidx = 0x2b; break;
-		default:  aidx = 0; break;
-		}
-		ap = &tubp->tty_aid[aidx];
-	} else {
-		return 0;
-	}
-
-	if (*sp == '\0') {
-		tubp->tty_showaidx = ap - tubp->tty_aid;
-		return count;
-	} else if (*sp == '=') {
-		len = strlen(++sp);
-		if (len == 0) {
-			if (ap->string != NULL &&
-			    ap->string != aidtab[aidx].string)
-				kfree(ap->string);
-			ap->string = aidtab[aidx].string;
-			ap->aid = aidtab[aidx].aid;
-			return count;
-		}
-		if ((pfp = kmalloc(len + 1, GFP_KERNEL)) == NULL)
-			return -ENOMEM;
-		if (ap->string != NULL &&
-		    ap->string != aidtab[aidx].string)
-			kfree(ap->string);
-		if (sp[len - 1] == '\n') {
-			ap->aid = TA_DOSTRING;
-			sp[len - 1] = '\0';
-			len--;
-		} else {
-			ap->aid = TA_DOSTRINGD;
-		}
-		memcpy(pfp, sp, len + 1);
-		ap->string = pfp;
-		return count;
-	} else {
-		return -EINVAL;
-	}
-}
diff -puN -L drivers/s390/char/tubttybld.c drivers/s390/char/tubttybld.c~linus /dev/null
--- 25/drivers/s390/char/tubttybld.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,587 +0,0 @@
-/*
- *  IBM/3270 Driver -- Copyright (C) 2000 UTS Global LLC
- *
- *  tubttybld.c -- Linemode tty driver screen-building functions
- *
- *
- *
- *
- *
- *  Author:  Richard Hitt
- */
-
-#include "tubio.h"
-
-extern int tty3270_io(tub_t *);
-static void tty3270_set_status_area(tub_t *, char **);
-static int tty3270_next_char(tub_t *);
-static void tty3270_unnext_char(tub_t *, char);
-static void tty3270_update_log_area(tub_t *, char **);
-static int tty3270_update_log_area_esc(tub_t *, char **, int *);
-static void tty3270_clear_log_area(tub_t *, char **);
-static void tty3270_tub_bufadr(tub_t *, int, char **);
-static void tty3270_set_bufadr(tub_t *, char **, int *);
-
-/*
- * tty3270_clear_log_area(tub_t *tubp, char **cpp)
- */
-static void
-tty3270_clear_log_area(tub_t *tubp, char **cpp)
-{
-	*(*cpp)++ = TO_SBA;
-	TUB_BUFADR(GEOM_LOG, cpp);
-	*(*cpp)++ = TO_SF;
-	*(*cpp)++ = TF_LOG;
-	*(*cpp)++ = TO_RA;
-	TUB_BUFADR(GEOM_INPUT, cpp);
-	*(*cpp)++ = '\0';
-	tubp->tty_oucol = tubp->tty_nextlogx = 0;
-	*(*cpp)++ = TO_SBA;
-	TUB_BUFADR(tubp->tty_nextlogx, cpp);
-}
-
-static void
-tty3270_update_log_area(tub_t *tubp, char **cpp)
-{
-	int lastx = GEOM_INPUT;
-	int c;
-	int next, fill, i;
-	int sba_needed = 1;
-	char *overrun = &(*tubp->ttyscreen)[tubp->ttyscreenl - TS_LENGTH];
-
-	/* Check for possible ESC sequence work to do */
-	if (tubp->tty_escx != 0) {
-		/* If compiling new escape sequence */
-		if (tubp->tty_esca[0] == 0x1b) {
-			if (tty3270_update_log_area_esc(tubp, cpp, &sba_needed))
-				return;
-		/* If esc seq needs refreshing after a write */
-		} else if (tubp->tty_esca[0] == TO_SA) {
-			tty3270_set_bufadr(tubp, cpp, &sba_needed);
-			for (i = 0; i < tubp->tty_escx; i++)
-				*(*cpp)++ = tubp->tty_esca[i];
-		} else {
-			printk(KERN_WARNING "tty3270_update_log_area esca "
-			"character surprising:  %.2x\n", tubp->tty_esca[0]);
-		}
-	}
-
-	/* Place characters */
-	while (tubp->tty_bcb.bc_cnt != 0) {
-		/* Check for room.  TAB could take up to 4 chars. */
-		if (&(*cpp)[4] >= overrun)
-			break;
-
-		/* Fetch a character */
-		if ((c = tty3270_next_char(tubp)) == -1)
-			break;
-
-		switch(c) {
-		default:
-			if (tubp->tty_nextlogx >= lastx) {
-				if (sba_needed == 0 ||
-				    tubp->stat == TBS_RUNNING) {
-					tty3270_unnext_char(tubp, c);
-					tubp->stat = TBS_MORE;
-					tty3270_set_status_area(tubp, cpp);
-					tty3270_scl_settimer(tubp);
-				}
-				goto do_return;
-			}
-			tty3270_set_bufadr(tubp, cpp, &sba_needed);
-			/* Use blank if we don't know the character */
-			*(*cpp)++ = tub_ascebc[(int)(c < ' '? ' ': c)];
-			tubp->tty_nextlogx++;
-			tubp->tty_oucol++;
-			break;
-		case 0x1b:              /* ESC */
-			tubp->tty_escx = 0;
-			if (tty3270_update_log_area_esc(tubp, cpp, &sba_needed))
-				return;
-			break;
-		case '\r':		/* 0x0d -- Carriage Return */
-			tubp->tty_nextlogx -=
-				tubp->tty_nextlogx % GEOM_COLS;
-			sba_needed = 1;
-			break;
-		case '\n':		/* 0x0a -- New Line */
-			if (tubp->tty_oucol == GEOM_COLS) {
-				tubp->tty_oucol = 0;
-				break;
-			}
-			next = (tubp->tty_nextlogx + GEOM_COLS) /
-				GEOM_COLS * GEOM_COLS;
-			tubp->tty_nextlogx = next;
-			tubp->tty_oucol = 0;
-			sba_needed = 1;
-			break;
-		case '\t':		/* 0x09 -- Tabulate */
-			fill = (tubp->tty_nextlogx % GEOM_COLS) % 8;
-			for (; fill < 8; fill++) {
-				if (tubp->tty_nextlogx >= lastx)
-					break;
-				*(*cpp)++ = tub_ascebc[' '];
-				tubp->tty_nextlogx++;
-				tubp->tty_oucol++;
-			}
-			break;
-		case '\a':		/* 0x07 -- Alarm */
-			tubp->flags |= TUB_ALARM;
-			break;
-		case '\f':		/* 0x0c -- Form Feed */
-			tty3270_clear_log_area(tubp, cpp);
-			break;
-		case 0xf:	/* SuSE "exit alternate mode" */
-			break;
-		}
-	}
-do_return:
-}
-
-#define NUMQUANT 8
-static int
-tty3270_update_log_area_esc(tub_t *tubp, char **cpp, int *sba_needed)
-{
-	int c;
-	int i, j;
-	int start, end, next;
-	int quant[NUMQUANT];
-	char *overrun = &(*tubp->ttyscreen)[tubp->ttyscreenl - TS_LENGTH];
-	char sabuf[NUMQUANT*3], *sap = sabuf, *cp;
-
-	/* If starting a sequence, stuff ESC at [0] */
-	if (tubp->tty_escx == 0)
-		tubp->tty_esca[tubp->tty_escx++] = 0x1b;
-
-	/* Now that sequence is started, see if room in buffer */
-	if (&(*cpp)[NUMQUANT * 3] >= overrun)
-		return tubp->tty_escx;
-
-	/* Gather the rest of the sequence's characters */
-	while (tubp->tty_escx < sizeof tubp->tty_esca) {
-		if ((c = tty3270_next_char(tubp)) == -1)
-			return tubp->tty_escx;
-		if (tubp->tty_escx == 1) {
-			switch(c) {
-			case '[':
-				tubp->tty_esca[tubp->tty_escx++] = c;
-				continue;
-			case '7':
-				tubp->tty_savecursor = tubp->tty_nextlogx;
-				goto done_return;
-			case '8':
-				next = tubp->tty_savecursor;
-				goto do_setcur;
-			default:
-				goto error_return;
-			}
-		}
-		tubp->tty_esca[tubp->tty_escx++] = c;
-		if (c != ';' && (c < '0' || c > '9'))
-			break;
-	}
-
-	/* Check for overrun */
-	if (tubp->tty_escx == sizeof tubp->tty_esca)
-		goto error_return;
-
-	/* Parse potentially empty string "nn;nn;nn..." */
-	i = -1;
-	j = 2;		/* skip ESC, [ */
-	c = ';';
-	do {
-		if (c == ';') {
-			if (++i == NUMQUANT)
-				goto error_return;
-			quant[i] = 0;
-		} else if (c < '0' || c > '9') {
-			break;
-		} else {
-			quant[i] = quant[i] * 10 + c - '0';
-		}
-		c = tubp->tty_esca[j];
-	} while (j++ < tubp->tty_escx);
-
-	/* Add 3270 data stream output to execute the sequence */
-	switch(c) {
-	case 'm':		/* Set Attribute */
-		for (next = 0; next <= i; next++) {
-			int type = -1, value = 0;
-
-			switch(quant[next]) {
-			case 0:		/* Reset */
-				next = tubp->tty_nextlogx;
-				tty3270_set_bufadr(tubp, cpp, sba_needed);
-				*(*cpp)++ = TO_SA;
-				*(*cpp)++ = TAT_EXTHI;
-				*(*cpp)++ = TAX_RESET;
-				*(*cpp)++ = TO_SA;
-				*(*cpp)++ = TAT_COLOR;
-				*(*cpp)++ = TAC_RESET;
-				tubp->tty_nextlogx = next;
-				*sba_needed = 1;
-				sap = sabuf;
-				break;
-			case 1:		/* Bright */
-				break;
-			case 2:		/* Dim */
-				break;
-			case 4:		/* Underscore */
-				type = TAT_EXTHI; value = TAX_UNDER;
-				break;
-			case 5:		/* Blink */
-				type = TAT_EXTHI; value = TAX_BLINK;
-				break;
-			case 7:		/* Reverse */
-				type = TAT_EXTHI; value = TAX_REVER;
-				break;
-			case 8:		/* Hidden */
-				break;		/* For now ... */
-			/* Foreground Colors */
-			case 30:	/* Black */
-				type = TAT_COLOR; value = TAC_DEFAULT;
-				break;
-			case 31:	/* Red */
-				type = TAT_COLOR; value = TAC_RED;
-				break;
-			case 32:	/* Green */
-				type = TAT_COLOR; value = TAC_GREEN;
-				break;
-			case 33:	/* Yellow */
-				type = TAT_COLOR; value = TAC_YELLOW;
-				break;
-			case 34:	/* Blue */
-				type = TAT_COLOR; value = TAC_BLUE;
-				break;
-			case 35:	/* Magenta */
-				type = TAT_COLOR; value = TAC_PINK;
-				break;
-			case 36:	/* Cyan */
-				type = TAT_COLOR; value = TAC_TURQ;
-				break;
-			case 37:	/* White */
-				type = TAT_COLOR; value = TAC_WHITE;
-				break;
-			case 39:	/* Black */
-				type = TAT_COLOR; value = TAC_DEFAULT;
-				break;
-			/* Background Colors */
-			case 40:	/* Black */
-			case 41:	/* Red */
-			case 42:	/* Green */
-			case 43:	/* Yellow */
-			case 44:	/* Blue */
-			case 45:	/* Magenta */
-			case 46:	/* Cyan */
-			case 47:	/* White */
-				break;		/* For now ... */
-			/* Oops */
-			default:
-				break;
-			}
-			if (type != -1) {
-				tty3270_set_bufadr(tubp, cpp, sba_needed);
-				*(*cpp)++ = TO_SA;
-				*(*cpp)++ = type;
-				*(*cpp)++ = value;
-				*sap++ = TO_SA;
-				*sap++ = type;
-				*sap++ = value;
-			}
-		}
-		break;
-
-	case 'H':		/* Cursor Home */
-	case 'f':		/* Force Cursor Position */
-		if (quant[0]) quant[0]--;
-		if (quant[1]) quant[1]--;
-		next = quant[0] * GEOM_COLS + quant[1];
-		goto do_setcur;
-	case 'A':		/* Cursor Up */
-		if (quant[i] == 0) quant[i] = 1;
-		next = tubp->tty_nextlogx - GEOM_COLS * quant[i];
-		goto do_setcur;
-	case 'B':		/* Cursor Down */
-		if (quant[i] == 0) quant[i] = 1;
-		next = tubp->tty_nextlogx + GEOM_COLS * quant[i];
-		goto do_setcur;
-	case 'C':		/* Cursor Forward */
-		if (quant[i] == 0) quant[i] = 1;
-		next = tubp->tty_nextlogx % GEOM_COLS;
-		start = tubp->tty_nextlogx - next;
-		next = start + MIN(next + quant[i], GEOM_COLS - 1);
-		goto do_setcur;
-	case 'D':		/* Cursor Backward */
-		if (quant[i] == 0) quant[i] = 1;
-		next = MIN(quant[i], tubp->tty_nextlogx % GEOM_COLS);
-		next = tubp->tty_nextlogx - next;
-		goto do_setcur;
-	case 'G':
-		if (quant[0]) quant[0]--;
-		next = tubp->tty_nextlogx / GEOM_COLS * GEOM_COLS + quant[0];
-do_setcur:
-		if (next < 0)
-			break;
-		tubp->tty_nextlogx = next;
-		tubp->tty_oucol = tubp->tty_nextlogx % GEOM_COLS;
-		*sba_needed = 1;
-		break;
-
-	case 'r':		/* Define scroll area */
-		start = quant[0];
-		if (start <= 0) start = 1;
-		if (start > GEOM_ROWS - 2) start = GEOM_ROWS - 2;
-		tubp->tty_nextlogx = (start - 1) * GEOM_COLS;
-		tubp->tty_oucol = 0;
-		*sba_needed = 1;
-		break;
-
-	case 'X':		/* Erase for n chars from cursor */
-		start = tubp->tty_nextlogx;
-		end = start + (quant[0]?: 1);
-		goto do_fill;
-	case 'J':		/* Erase to screen end from cursor */
-		*(*cpp)++ = TO_SBA;
-		TUB_BUFADR(tubp->tty_nextlogx, cpp);
-		*(*cpp)++ = TO_RA;
-		TUB_BUFADR(GEOM_INPUT, cpp);
-		*(*cpp)++ = tub_ascebc[' '];
-		*(*cpp)++ = TO_SBA;
-		TUB_BUFADR(tubp->tty_nextlogx, cpp);
-		break;
-	case 'K':
-		start = tubp->tty_nextlogx;
-		end = (start + GEOM_COLS) / GEOM_COLS * GEOM_COLS;
-do_fill:
-		if (start >= GEOM_INPUT)
-			break;
-		if (end > GEOM_INPUT)
-			end = GEOM_INPUT;
-		if (end <= start)
-			break;
-		*(*cpp)++ = TO_SBA;
-		TUB_BUFADR(start, cpp);
-		if (end - start > 4) {
-			*(*cpp)++ = TO_RA;
-			TUB_BUFADR(end, cpp);
-			*(*cpp)++ = tub_ascebc[' '];
-		} else while (start++ < end) {
-			*(*cpp)++ = tub_ascebc[' '];
-		}
-		tubp->tty_nextlogx = end;
-		tubp->tty_oucol = tubp->tty_nextlogx % GEOM_COLS;
-		*sba_needed = 1;
-		break;
-	}
-done_return:
-	tubp->tty_escx = 0;
-	cp = sabuf;
-	while (cp != sap)
-		tubp->tty_esca[tubp->tty_escx++] = *cp++;
-	return 0;
-error_return:
-	tubp->tty_escx = 0;
-	return 0;
-}
-
-static int
-tty3270_next_char(tub_t *tubp)
-{
-	int c;
-	bcb_t *ib;
-
-	ib = &tubp->tty_bcb;
-	if (ib->bc_cnt == 0)
-		return -1;
-	c = ib->bc_buf[ib->bc_rd++];
-	if (ib->bc_rd == ib->bc_len)
-		ib->bc_rd = 0;
-	ib->bc_cnt--;
-	return c;
-}
-
-static void
-tty3270_unnext_char(tub_t *tubp, char c)
-{
-	bcb_t *ib;
-
-	ib = &tubp->tty_bcb;
-	if (ib->bc_rd == 0)
-		ib->bc_rd = ib->bc_len;
-	ib->bc_buf[--ib->bc_rd] = c;
-	ib->bc_cnt++;
-}
-
-
-static void
-tty3270_clear_input_area(tub_t *tubp, char **cpp)
-{
-	*(*cpp)++ = TO_SBA;
-	TUB_BUFADR(GEOM_INPUT, cpp);
-	*(*cpp)++ = TO_SF;
-	*(*cpp)++ = tubp->tty_inattr;
-	*(*cpp)++ = TO_IC;
-	*(*cpp)++ = TO_RA;
-	TUB_BUFADR(GEOM_STAT, cpp);
-	*(*cpp)++ = '\0';
-}
-
-static void
-tty3270_update_input_area(tub_t *tubp, char **cpp)
-{
-	int len;
-
-	*(*cpp)++ = TO_SBA;
-	TUB_BUFADR(GEOM_INPUT, cpp);
-	*(*cpp)++ = TO_SF;
-	*(*cpp)++ = TF_INMDT;
-	len = strlen(tubp->tty_input);
-	memcpy(*cpp, tubp->tty_input, len);
-	*cpp += len;
-	*(*cpp)++ = TO_IC;
-	len = GEOM_INPLEN - len;
-	if (len > 4) {
-		*(*cpp)++ = TO_RA;
-		TUB_BUFADR(GEOM_STAT, cpp);
-		*(*cpp)++ = '\0';
-	} else {
-		for (; len > 0; len--)
-			*(*cpp)++ = '\0';
-	}
-}
-
-/*
- * tty3270_set_status_area(tub_t *tubp, char **cpp)
- */
-static void
-tty3270_set_status_area(tub_t *tubp, char **cpp)
-{
-	char *sp;
-
-	if (tubp->stat == TBS_RUNNING)
-		sp = TS_RUNNING;
-	else if (tubp->stat == TBS_MORE)
-		sp = TS_MORE;
-	else if (tubp->stat == TBS_HOLD)
-		sp = TS_HOLD;
-	else
-		sp = "Linux Whatstat";
-
-	*(*cpp)++ = TO_SBA;
-	TUB_BUFADR(GEOM_STAT, cpp);
-	*(*cpp)++ = TO_SF;
-	*(*cpp)++ = TF_STAT;
-	memcpy(*cpp, sp, sizeof TS_RUNNING);
-	TUB_ASCEBC(*cpp, sizeof TS_RUNNING);
-	*cpp += sizeof TS_RUNNING;
-}
-
-/*
- * tty3270_build() -- build an output stream
- */
-int
-tty3270_build(tub_t *tubp)
-{
-	char *cp, *startcp;
-	int chancmd;
-	int writecc = TW_KR;
-	int force = 0;
-
-	if (tubp->mode == TBM_FS)
-		return 0;
-
-	cp = startcp = *tubp->ttyscreen + 1;
-
-	switch(tubp->cmd) {
-	default:
-		printk(KERN_WARNING "tty3270_build unknown command %d\n", tubp->cmd);
-		return 0;
-	case TBC_OPEN:
-tbc_open:
-		tubp->flags &= ~TUB_INPUT_HACK;
-		chancmd = TC_EWRITEA;
-		tty3270_clear_input_area(tubp, &cp);
-		tty3270_set_status_area(tubp, &cp);
-		tty3270_clear_log_area(tubp, &cp);
-		break;
-	case TBC_UPDLOG:
-		if (tubp->flags & TUB_INPUT_HACK)
-			goto tbc_open;
-		chancmd = TC_WRITE;
-		writecc = TW_NONE;
-		tty3270_update_log_area(tubp, &cp);
-		break;
-	case TBC_KRUPDLOG:
-		chancmd = TC_WRITE;
-		force = 1;
-		tty3270_update_log_area(tubp, &cp);
-		break;
-	case TBC_CLRUPDLOG:
-		chancmd = TC_WRITE;
-		tty3270_set_status_area(tubp, &cp);
-		tty3270_clear_log_area(tubp, &cp);
-		tty3270_update_log_area(tubp, &cp);
-		break;
-	case TBC_UPDATE:
-		chancmd = TC_EWRITEA;
-		tubp->tty_oucol = tubp->tty_nextlogx = 0;
-		tty3270_clear_input_area(tubp, &cp);
-		tty3270_set_status_area(tubp, &cp);
-		tty3270_update_log_area(tubp, &cp);
-		break;
-	case TBC_UPDSTAT:
-		chancmd = TC_WRITE;
-		tty3270_set_status_area(tubp, &cp);
-		break;
-	case TBC_CLRINPUT:
-		chancmd = TC_WRITE;
-		tty3270_clear_input_area(tubp, &cp);
-		break;
-	case TBC_UPDINPUT:
-		chancmd = TC_WRITE;
-		tty3270_update_input_area(tubp, &cp);
-		break;
-	}
-
-	/* Set Write Control Character and start I/O */
-	if (force == 0 && cp == startcp &&
-	    (tubp->flags & TUB_ALARM) == 0)
-		return 0;
-	if (tubp->flags & TUB_ALARM) {
-		tubp->flags &= ~TUB_ALARM;
-		writecc |= TW_PLUSALARM;
-	}
-	**tubp->ttyscreen = writecc;
-	tubp->ttyccw.cmd_code = chancmd;
-	tubp->ttyccw.flags = CCW_FLAG_SLI;
-	tubp->ttyccw.cda = virt_to_phys(*tubp->ttyscreen);
-	tubp->ttyccw.count = cp - *tubp->ttyscreen;
-	tty3270_io(tubp);
-	return 1;
-}
-
-static void
-tty3270_tub_bufadr(tub_t *tubp, int adr, char **cpp)
-{
-	if (tubp->tty_14bitadr) {
-		*(*cpp)++ = (adr >> 8) & 0x3f;
-		*(*cpp)++ = adr & 0xff;
-	} else {
-		*(*cpp)++ = tub_ebcgraf[(adr >> 6) & 0x3f];
-		*(*cpp)++ = tub_ebcgraf[adr & 0x3f];
-	}
-}
-
-static void
-tty3270_set_bufadr(tub_t *tubp, char **cpp, int *sba_needed)
-{
-	if (!*sba_needed)
-		return;
-	if (tubp->tty_nextlogx >= GEOM_INPUT) {
-		tubp->tty_nextlogx = GEOM_INPUT - 1;
-		tubp->tty_oucol = tubp->tty_nextlogx % GEOM_COLS;
-	}
-	*(*cpp)++ = TO_SBA;
-	TUB_BUFADR(tubp->tty_nextlogx, cpp);
-	*sba_needed = 0;
-}
diff -puN -L drivers/s390/char/tubtty.c drivers/s390/char/tubtty.c~linus /dev/null
--- 25/drivers/s390/char/tubtty.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,955 +0,0 @@
-/*
- *  IBM/3270 Driver -- Copyright (C) 2000, 2001 UTS Global LLC
- *
- *  tubtty.c -- Linemode tty driver
- *
- *
- *
- *
- *
- *  Author:  Richard Hitt
- */
-#include <linux/config.h>
-#include "tubio.h"
-
-/* Initialization & uninitialization for tubtty */
-int tty3270_init(void);
-void tty3270_fini(void);
-
-/* Interface routines from the upper tty layer to the tty driver */
-static int tty3270_open(struct tty_struct *, struct file *);
-static void tty3270_close(struct tty_struct *, struct file *);
-static int tty3270_write(struct tty_struct *, int,
-        const unsigned char *, int);
-static void tty3270_put_char(struct tty_struct *, unsigned char);
-static void tty3270_flush_chars(struct tty_struct *);
-static int tty3270_write_room(struct tty_struct *);
-static int tty3270_chars_in_buffer(struct tty_struct *);
-static int tty3270_ioctl(struct tty_struct *, struct file *,
-	unsigned int cmd, unsigned long arg);
-static void tty3270_set_termios(struct tty_struct *, struct termios *);
-static void tty3270_hangup(struct tty_struct *);
-static void tty3270_flush_buffer(struct tty_struct *);
-static int tty3270_read_proc(char *, char **, off_t, int, int *, void *);
-static int tty3270_write_proc(struct file *, const char *,
-	unsigned long, void *);
-
-/* tty3270 utility functions */
-static void tty3270_tasklet(unsigned long);
-       void tty3270_sched_bh(tub_t *);
-static int tty3270_wait(tub_t *, long *);
-       void tty3270_int(tub_t *, devstat_t *);
-static int tty3270_try_logging(tub_t *);
-static void tty3270_start_input(tub_t *);
-static void tty3270_do_input(tub_t *);
-static void tty3270_do_enter(tub_t *, char *, int);
-static void tty3270_do_showi(tub_t *, char *, int);
-       int tty3270_io(tub_t *);
-static int tty3270_show_tube(int, char *, int);
-
-static int tty3270_major = -1;
-struct tty_driver *tty3270_driver;
-
-static int tty3270_proc_index;
-static int tty3270_proc_data;
-static int tty3270_proc_misc;
-static enum tubwhat tty3270_proc_what;
-
-static struct tty_operations tty3270_ops = {
-	.open = tty3270_open,
-	.close = tty3270_close,
-	.write = tty3270_write,
-	.put_char = tty3270_put_char,
-	.flush_chars = tty3270_flush_chars,
-	.write_room = tty3270_write_room,
-	.chars_in_buffer = tty3270_chars_in_buffer,
-#if 0
-	.ioctl = tty3270_ioctl,
-#endif
-	.set_termios = tty3270_set_termios,
-	.hangup = tty3270_hangup,
-	.flush_buffer = tty3270_flush_buffer,
-	.read_proc = tty3270_read_proc,
-	.write_proc = tty3270_write_proc,
-};
-
-/*
- * tty3270_init() -- Register the tty3270 driver
- */
-int
-tty3270_init(void)
-{
-	struct tty_driver *td = alloc_tty_driver(TUBMAXMINS);
-	int rc;
-
-	if (!td)
-		return -ENOMEM;
-
-	/* Initialize for tty driver */
-	td->owner = THIS_MODULE;
-	td->driver_name = "tty3270";
-	td->name = "tty3270";
-	td->major = IBM_TTY3270_MAJOR;
-	td->minor_start = 0;
-	td->type = TTY_DRIVER_TYPE_SYSTEM;
-	td->subtype = SYSTEM_TYPE_TTY;
-	td->init_termios = tty_std_termios;
-	td->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_NO_DEVFS;
-	tty_set_operations(td, &tty3270_ops);
-	rc = tty_register_driver(td);
-	if (rc) {
-		put_tty_driver(td);
-		printk(KERN_ERR "tty3270 registration failed with %d\n", rc);
-	} else {
-		tty3270_major = IBM_TTY3270_MAJOR;
-		if (td->proc_entry != NULL)
-			td->proc_entry->mode = S_IRUGO | S_IWUGO;
-		tty3270_driver = td;
-	}
-	return rc;
-}
-
-/*
- * tty3270_fini() -- Uninitialize linemode tubes
- */
-void
-tty3270_fini(void)
-{
-	if (tty3270_major != -1) {
-		tty_unregister_driver(tty3270_driver);
-		put_tty_driver(tty3270_driver);
-		tty3270_driver = NULL;
-		tty3270_major = -1;
-	}
-}
-
-static int 
-tty3270_open(struct tty_struct *tty, struct file *filp)
-{
-	tub_t *tubp;
-	long flags;
-	int rc;
-	int cmd;
-
-	if ((tubp = TTY2TUB(tty)) == NULL) {
-		return -ENODEV;
-	}
-
-	if ((rc = tty3270_wait(tubp, &flags)) != 0)
-		goto do_fail;
-	if (tubp->lnopen > 0) {
-		tubp->lnopen++;
-		TUBUNLOCK(tubp->irq, flags);
-		return 0;
-	}
-	if (tubp->flags & TUB_OPEN_STET) {
-		cmd = TBC_UPDLOG;
-	} else {
-		cmd = TBC_OPEN;
-		tubp->flags &= ~TUB_SIZED;
-	}
-	if ((rc = tty3270_size(tubp, &flags)) != 0)
-		goto do_fail;
-	if ((rc = tty3270_rcl_init(tubp)) != 0)
-		goto do_fail;
-	if ((rc = tty3270_aid_init(tubp)) != 0)
-		goto do_fail;
-	if ((rc = tty3270_scl_init(tubp)) != 0)
-		goto do_fail;
-	tubp->mode = TBM_LN;
-	tubp->intv = tty3270_int;
-	tubp->tty = tty;
-	tubp->lnopen = 1;
-	tty->driver_data = tubp;
-	tty->winsize.ws_row = tubp->geom_rows - 2;
-	tty->winsize.ws_col = tubp->geom_cols;
-	if (tubp->tty_input == NULL)
-		tubp->tty_input = kmalloc(GEOM_INPLEN, GFP_KERNEL|GFP_DMA);
-	tubp->tty_inattr = TF_INPUT;
-	tubp->cmd = cmd;
-	tty3270_build(tubp);
-	TUBUNLOCK(tubp->irq, flags);
-	return 0;
-
-do_fail:
-	tty3270_scl_fini(tubp);
-	tty3270_aid_fini(tubp);
-	tty3270_rcl_fini(tubp);
-	TUBUNLOCK(tubp->irq, flags);
-	return rc;
-}
-
-static void
-tty3270_close(struct tty_struct *tty, struct file *filp)
-{
-	tub_t *tubp;
-	long flags;
-
-	if ((tubp = tty->driver_data) == NULL)
-		return;
-
-	tty3270_wait(tubp, &flags);
-	if (--tubp->lnopen > 0)
-		goto do_return;
-	tubp->tty = NULL;
-	tty->driver_data = NULL;
-	tty3270_aid_fini(tubp);
-	tty3270_rcl_fini(tubp);
-	tty3270_scl_fini(tubp);
-do_return:
-	TUBUNLOCK(tubp->irq, flags);
-}
-
-static int 
-tty3270_write(struct tty_struct *tty, int fromuser,
-		const unsigned char *buf, int count)
-{
-	tub_t *tubp;
-	long flags;
-	bcb_t obcb;
-	int rc = 0;
-
-	if ((tubp = tty->driver_data) == NULL)
-		return -1;
-
-#ifdef CONFIG_TN3270_CONSOLE
-	if (CONSOLE_IS_3270 && tub3270_con_tubp == tubp)
-		tub3270_con_copy(tubp);
-#endif /* CONFIG_TN3270_CONSOLE */
-
-	obcb.bc_buf = (char *)buf;
-	obcb.bc_len = obcb.bc_cnt = obcb.bc_wr = count;
-	obcb.bc_rd = 0;
-
-	TUBLOCK(tubp->irq, flags);
-	rc = tub3270_movedata(&obcb, &tubp->tty_bcb, fromuser);
-	tty3270_try_logging(tubp);
-	TUBUNLOCK(tubp->irq, flags);
-	return rc;
-} 
-
-static void
-tty3270_put_char(struct tty_struct *tty, unsigned char ch)
-{
-	long flags;
-	tub_t *tubp;
-	bcb_t *ob;
-
-	if ((tubp = tty->driver_data) == NULL)
-		return;
-
-	TUBLOCK(tubp->irq, flags);
-	ob = &tubp->tty_bcb;
-	if (ob->bc_cnt < ob->bc_len) {
-		ob->bc_buf[ob->bc_wr++] = ch;
-		if (ob->bc_wr == ob->bc_len)
-			ob->bc_wr = 0;
-		ob->bc_cnt++;
-	}
-	tty3270_try_logging(tubp);
-	TUBUNLOCK(tubp->irq, flags);
-}
-
-static void
-tty3270_flush_chars(struct tty_struct *tty)
-{
-	tub_t *tubp;
-	long flags;
-
-	if ((tubp = tty->driver_data) == NULL)
-		return;
-
-	TUBLOCK(tubp->irq, flags);
-	tty3270_try_logging(tubp);
-	TUBUNLOCK(tubp->irq, flags);
-}
-
-static int 
-tty3270_write_room(struct tty_struct *tty)
-{
-	tub_t *tubp;
-	bcb_t *ob;
-
-	if ((tubp = tty->driver_data) == NULL)
-		return -1;
-
-	ob = &tubp->tty_bcb;
-	return ob->bc_len - ob->bc_cnt;
-}
-
-static int
-tty3270_chars_in_buffer(struct tty_struct *tty)
-{
-	tub_t *tubp;
-	bcb_t *ob;
-
-	if ((tubp = tty->driver_data) == NULL)
-		return -1;
-
-	ob = &tubp->tty_bcb;
-	return ob->bc_cnt;
-}
-
-static int
-tty3270_ioctl(struct tty_struct *tty, struct file *file,
-		unsigned int cmd, unsigned long arg)
-{
-	tub_t *tubp;
-	long flags;
-	int ret = 0;
-	struct termios termios;
-
-	if ((tubp = tty->driver_data) == NULL)
-		return -ENODEV;
-
-	TUBLOCK(tubp->irq, flags);
-	if (tty->flags * (1 << TTY_IO_ERROR)) {
-		ret = -EIO;
-		goto do_return;
-	}
-	switch(cmd) {
-	case TCGETS:
-		ret = -ENOIOCTLCMD;
-		goto do_return;
-	case TCFLSH:            /* arg:  2 or 0 */
-		ret = -ENOIOCTLCMD;
-		goto do_return;
-	case TCSETSF:
-		if (user_termios_to_kernel_termios(&termios,
-		    (struct termios *)arg)) {
-			ret = -EFAULT;
-			goto do_return;
-		}
-		ret = -ENOIOCTLCMD;
-		goto do_return;
-	case TCGETA:
-		ret = -ENOIOCTLCMD;
-		goto do_return;
-	case TCSETA:
-		if (user_termio_to_kernel_termios(&termios,
-		    (struct termio *)arg)) {
-			ret = -EFAULT;
-			goto do_return;
-		}
-		ret = -ENOIOCTLCMD;
-		goto do_return;
-	default:
-		ret = -ENOIOCTLCMD;
-		break;
-	}
-
-do_return:
-	TUBUNLOCK(tubp->irq, flags);
-	return ret;
-}
-
-static void
-tty3270_set_termios(struct tty_struct *tty, struct termios *old)
-{
-	tub_t *tubp;
-	long flags;
-	int new;
-
-	if ((tubp = tty->driver_data) == NULL)
-		return;
-
-	if (tty3270_wait(tubp, &flags) != 0) {
-		TUBUNLOCK(tubp->irq, flags);
-		return;
-	}
-	new = L_ICANON(tty)? L_ECHO(tty)? TF_INPUT: TF_INPUTN:
-		tubp->tty_inattr;
-	if (new != tubp->tty_inattr) {
-		tubp->tty_inattr = new;
-		tubp->cmd = TBC_CLRINPUT;
-		tty3270_build(tubp);
-	}
-
-	TUBUNLOCK(tubp->irq, flags);
-}
-
-static void
-tty3270_flush_buffer(struct tty_struct *tty)
-{
-	tub_t *tubp;
-	bcb_t *ob;
-	long flags;
-
-	if ((tubp = tty->driver_data) == NULL)
-		return;
-
-	if (tubp->mode == TBM_FS && tubp->fs_pid != 0) {
-		kill_proc(tubp->fs_pid, SIGHUP, 1);
-	}
-
-	if ((tubp->flags & TUB_OPEN_STET) == 0) {
-		ob = &tubp->tty_bcb;
-		TUBLOCK(tubp->irq, flags);
-		ob->bc_rd = 0;
-		ob->bc_wr = 0;
-		ob->bc_cnt = 0;
-		TUBUNLOCK(tubp->irq, flags);
-	}
-	wake_up_interruptible(&tty->write_wait);
-	if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-	    tty->ldisc.write_wakeup)
-		(tty->ldisc.write_wakeup)(tty);
-}
-
-static int
-tty3270_read_proc(char *buf, char **start, off_t off, int count,
-		int *eof, void *data)
-{
-	tub_t *tubp;
-	int begin = 0;
-	int i;
-	int rc;
-	int len = 0;
-
-	if (tty3270_proc_what == TW_CONFIG) {
-		/*
-		 * Describe the 3270 configuration in ascii lines.
-		 * Line 1:		0 <fsmajor> 0
-		 * Console line:	<devnum> CONSOLE <minor>
-		 * Other lines:		<devnum> <ttymajor> <minor>
-		 */
-		len += sprintf(buf + len, "0 %d 0\n", fs3270_major);
-		for (i = 1; i <= tubnummins; i++) {
-			tubp = (*tubminors)[i];
-#ifdef CONFIG_TN3270_CONSOLE
-			if (CONSOLE_IS_3270 && tubp == tub3270_con_tubp)
-				len += sprintf(buf + len, "%.4x CONSOLE %d\n",
-					       tubp->devno, i);
-			else
-#endif
-				len += sprintf(buf + len, "%.4x %d %d\n",
-					       tubp->devno, tty3270_major, i);
-			if (begin + len > off + count)
-				break;
-			if (begin + len < off) {
-				begin += len;
-				len = 0;
-			}
-		}
-		if (i > tubnummins)
-			*eof = 1;
-		if (off >= begin + len) {
-			rc = 0;
-		} else {
-			*start = buf + off - begin;
-			rc = MIN(count, begin + len - off);
-		}
-		if (*eof && rc == 0)
-			tty3270_proc_what = TW_BOGUS;
-		return rc;
-	}
-
-	len += sprintf(buf, "There are %d devices.  fs major is %d, "
-		"tty major is %d.\n", tubnummins, fs3270_major,
-		tty3270_major);
-	len += sprintf(buf+len, "        index=%d data=%d misc=%d\n",
-		tty3270_proc_index,
-		tty3270_proc_data,
-		tty3270_proc_misc);
-
-	/*
-	 * Display info for the tube with minor nr in index
-	 */
-	len += tty3270_show_tube(tty3270_proc_index, buf+len, count-len);
-
-	*eof = 1;
-	if (off >= begin + len)
-		return 0;
-	*start = buf + off - begin;
-	return MIN(count, begin + len - off);
-}
-
-static int
-tty3270_write_proc(struct file *file, const char *buffer,
-		unsigned long count, void *data)
-{
-	char mybuf[GEOM_MAXINPLEN];
-	int mycount;
-	tub_t *tubp;
-	struct tty_struct *tty;
-	int rc;
-
-	mycount = MIN(count, sizeof mybuf - 1);
-	if (copy_from_user(mybuf, buffer, mycount) != 0)
-		return -EFAULT;
-	mybuf[mycount] = '\0';
-
-	/*
-	 * User-mode settings affect only the current tty ---
-	 */
-	tubp = NULL;
-	tty = current->tty;
-	if (tty && tty->driver == tty3270_driver)
-		tubp = (*tubminors)[tty->index];
-	if (tubp) {
-		if ((rc = tty3270_aid_set(tubp, mybuf, mycount + 1)))
-			return rc > 0? count: rc;
-		if ((rc = tty3270_rcl_set(tubp, mybuf, mycount + 1)))
-			return rc > 0? count: rc;
-		if ((rc = tty3270_scl_set(tubp, mybuf, mycount + 1)))
-			return rc > 0? count: rc;
-	}
-
-	/*
-	 * Superuser-mode settings affect the driver overall ---
-	 */
-	if (!capable(CAP_SYS_TTY_CONFIG)) {
-		return -EPERM;
-	} else if (strncmp(mybuf, "index=", 6) == 0) {
-		tty3270_proc_index = simple_strtoul(mybuf + 6, 0,0);
-		return count;
-	} else if (strncmp(mybuf, "data=", 5) == 0) {
-		tty3270_proc_data = simple_strtoul(mybuf + 5, 0, 0);
-		return count;
-	} else if (strncmp(mybuf, "misc=", 5) == 0) {
-		tty3270_proc_misc = simple_strtoul(mybuf + 5, 0, 0);
-		return count;
-	} else if (strncmp(mybuf, "what=", 5) == 0) {
-		if (strcmp(mybuf+5, "bogus") == 0)
-			tty3270_proc_what = 0;
-		else if (strncmp(mybuf+5, "config", 6) == 0)
-			tty3270_proc_what = TW_CONFIG;
-		return count;
-	} else {
-		return -EINVAL;
-	}
-}
-
-static void
-tty3270_hangup(struct tty_struct *tty)
-{
-	tub_t *tubp;
-	extern void fs3270_release(tub_t *);
-
-	if ((tubp = tty->driver_data) == NULL)
-		return;
-	tty3270_rcl_purge(tubp);
-	tty3270_aid_reinit(tubp);
-	fs3270_release(tubp);
-}
-
-
-/*
- * tty3270_tasklet(tubp) -- Perform back-half processing
- */
-static void
-tty3270_tasklet(unsigned long data)
-{
-	tub_t *tubp;
-	ioinfo_t *ioinfop;
-	long flags;
-	struct tty_struct *tty;
-
-	tubp = (tub_t *) data;
-	ioinfop = ioinfo[tubp->irq];
-	while (TUBTRYLOCK(tubp->irq, flags) == 0) {
-		if (ioinfop->ui.flags.unready == 1)
-			return;
-	}
-	if (ioinfop->ui.flags.unready == 1 ||
-	    ioinfop->ui.flags.ready == 0)
-		goto do_unlock;
-
-	tubp->flags &= ~TUB_BHPENDING;
-	tty = tubp->tty;
-
-	if (tubp->flags & TUB_UNSOL_DE) {
-		tubp->flags &= ~TUB_UNSOL_DE;
-		if (tty != NULL) {
-			tty_hangup(tty);
-			wake_up_interruptible(&tubp->waitq);
-			goto do_unlock;
-		}
-	}
-
-	if (tubp->flags & TUB_IACTIVE) {        /* If read ended, */
-		tty3270_do_input(tubp);
-		tubp->flags &= ~TUB_IACTIVE;
-	}
-
-	if ((tubp->flags & TUB_WORKING) == 0) {
-		if (tubp->flags & TUB_ATTN) {
-			tty3270_start_input(tubp);
-			tubp->flags &= ~TUB_ATTN;
-		} else if (tty3270_try_logging(tubp) == 0) {
-			wake_up_interruptible(&tubp->waitq);
-		}
-	}
-
-	if (tty != NULL) {
-		if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-		    tty->ldisc.write_wakeup != NULL)
-			(tty->ldisc.write_wakeup)(tty);
-		wake_up_interruptible(&tty->write_wait);
-	}
-do_unlock:
-	TUBUNLOCK(tubp->irq, flags);
-}
-
-/*
- * tty3270_sched_bh(tubp) -- Schedule the back half
- * Irq lock must be held on entry and remains held on exit.
- */
-void
-tty3270_sched_bh(tub_t *tubp)
-{
-	if (tubp->flags & TUB_BHPENDING)
-		return;
-	tubp->flags |= TUB_BHPENDING;
-	tasklet_init(&tubp->tasklet, tty3270_tasklet,
-		     (unsigned long) tubp);
-	tasklet_schedule(&tubp->tasklet);
-}
-
-/*
- * tty3270_io() -- Perform line-mode reads and writes here
- */
-int 
-tty3270_io(tub_t *tubp)
-{
-	int rc;
-	ccw1_t *ccwp;
-
-	tubp->flags |= TUB_WORKING;
-	tubp->dstat = 0;
-	ccwp = &tubp->ttyccw;
-
-	rc = do_IO(tubp->irq, ccwp, tubp->irq, 0, 0);
-	return rc;
-}
-
-/*
- * tty3270_wait(tubp) -- Wait until TUB_WORKING is off
- * On entry the lock must not be held; on exit it is held.
- */
-static int
-tty3270_wait(tub_t *tubp, long *flags)
-{
-	DECLARE_WAITQUEUE(wait, current);
-
-	TUBLOCK(tubp->irq, *flags);
-	add_wait_queue(&tubp->waitq, &wait);
-	while (!signal_pending(current) &&
-	    (tubp->flags & TUB_WORKING) != 0) {
-#warning FIXME: [kj] use set_current_state instead of current->state=
-		current->state = TASK_INTERRUPTIBLE;
-		TUBUNLOCK(tubp->irq, *flags);
-		schedule();
-#warning FIXME: [kj] use set_current_state instead of current->state=
-		current->state = TASK_RUNNING;
-		TUBLOCK(tubp->irq, *flags);
-	}
-	remove_wait_queue(&tubp->waitq, &wait);
-	return signal_pending(current)? -ERESTARTSYS: 0;
-}
-
-void
-tty3270_int(tub_t *tubp, devstat_t *dsp)
-{
-#define	DEV_UE_BUSY \
-	(DEV_STAT_CHN_END | DEV_STAT_DEV_END | DEV_STAT_UNIT_EXCEP)
-#define DEV_NOT_WORKING \
-	(DEV_STAT_ATTENTION | DEV_STAT_DEV_END | DEV_STAT_UNIT_CHECK)
-
-	tubp->dstat = dsp->dstat;
-
-	/* Handle CE-DE-UE and subsequent UDE */
-	if (dsp->dstat == DEV_UE_BUSY) {
-		tubp->flags |= TUB_UE_BUSY;
-		return;
-	} else if (tubp->flags & TUB_UE_BUSY) {
-		tubp->flags &= ~TUB_UE_BUSY;
-		if (dsp->dstat == DEV_STAT_DEV_END &&
-		    (tubp->flags & TUB_WORKING) != 0) {
-			tty3270_io(tubp);
-			return;
-		}
-	}
-
-	/* Handle ATTN */
-	if (dsp->dstat & DEV_STAT_ATTENTION)
-		tubp->flags |= TUB_ATTN;
-
-	if (dsp->dstat & DEV_STAT_CHN_END) {
-		tubp->cswl = dsp->rescnt;
-		if ((dsp->dstat & DEV_STAT_DEV_END) == 0)
-			tubp->flags |= TUB_EXPECT_DE;
-		else
-			tubp->flags &= ~TUB_EXPECT_DE;
-	} else if (dsp->dstat & DEV_STAT_DEV_END) {
-		if ((tubp->flags & TUB_EXPECT_DE) == 0)
-			tubp->flags |= TUB_UNSOL_DE;
-		tubp->flags &= ~TUB_EXPECT_DE;
-	}
-	if (dsp->dstat & DEV_NOT_WORKING)
-		tubp->flags &= ~TUB_WORKING;
-	if (dsp->dstat & DEV_STAT_UNIT_CHECK)
-		tubp->sense = dsp->ii.sense;
-	if ((tubp->flags & TUB_WORKING) == 0)
-		tty3270_sched_bh(tubp);
-}
-
-/*
- * tty3270_refresh(), called by fs3270_close() when tubp->fsopen == 0.
- * On entry, lock is held.
- */
-void
-tty3270_refresh(tub_t *tubp)
-{
-	if (tubp->lnopen) {
-		tubp->mode = TBM_LN;
-		tubp->intv = tty3270_int;
-		tty3270_scl_resettimer(tubp);
-		tubp->cmd = TBC_UPDATE;
-		tty3270_build(tubp);
-	}
-}
-
-static int
-tty3270_try_logging(tub_t *tubp)
-{
-	if (tubp->flags & TUB_WORKING)
-		return 0;
-	if (tubp->mode == TBM_FS)
-		return 0;
-	if (tubp->stat == TBS_HOLD)
-		return 0;
-	if (tubp->stat == TBS_MORE)
-		return 0;
-#ifdef CONFIG_TN3270_CONSOLE
-	if (CONSOLE_IS_3270 && tub3270_con_tubp == tubp)
-		tub3270_con_copy(tubp);
-#endif /* CONFIG_TN3270_CONSOLE */
-	if (tubp->tty_bcb.bc_cnt == 0)
-		return 0;
-	if (tubp->intv != tty3270_int)
-		return 0;
-	tubp->cmd = TBC_UPDLOG;
-	return tty3270_build(tubp);
-}
-
-/* tty3270 utility functions */
-
-static void
-tty3270_start_input(tub_t *tubp)
-{
-	if (tubp->tty_input == NULL)
-		return;
-	tubp->ttyccw.cda = virt_to_phys(tubp->tty_input);
-	tubp->ttyccw.cmd_code = TC_READMOD;
-	tubp->ttyccw.count = GEOM_INPLEN;
-	tubp->ttyccw.flags = CCW_FLAG_SLI;
-	tty3270_io(tubp);
-	tubp->flags |= TUB_IACTIVE;
-}
-
-static void
-tty3270_do_input(tub_t *tubp)
-{
-	int count;
-	char *in;
-	int aidflags;
-	char *aidstring;
-
-	count = GEOM_INPLEN - tubp->cswl;
-	if ((in = tubp->tty_input) == NULL)
-		goto do_build;
-	tty3270_aid_get(tubp, in[0], &aidflags, &aidstring);
-
-	if (aidflags & TA_CLEARKEY) {
-		tubp->stat = TBS_RUNNING;
-		tty3270_scl_resettimer(tubp);
-		tubp->cmd = TBC_UPDATE;
-	} else if (aidflags & TA_CLEARLOG) {
-		tubp->stat = TBS_RUNNING;
-		tty3270_scl_resettimer(tubp);
-		tubp->cmd = TBC_CLRUPDLOG;
-	} else if (aidflags & TA_DOENTER) {
-		if (count <= 6) {
-			switch(tubp->stat) {
-			case TBS_MORE:
-				tubp->stat = TBS_HOLD;
-				tty3270_scl_resettimer(tubp);
-				break;
-			case TBS_HOLD:
-				tubp->stat = TBS_MORE;
-				tty3270_scl_settimer(tubp);
-				break;
-			case TBS_RUNNING:
-                                tty3270_do_enter(tubp, in + 6, 0);
-				break;
-			}
-			tubp->cmd = TBC_UPDSTAT;
-			goto do_build;
-		}
-		in += 6;
-		count -= 6;
-		TUB_EBCASC(in, count);
-		tubp->cmd = TBC_CLRINPUT;
-		tty3270_do_enter(tubp, in, count);
-	} else if ((aidflags & TA_DOSTRING) != 0 && aidstring != NULL) {
-		tubp->cmd = TBC_KRUPDLOG;
-		tty3270_do_enter(tubp, aidstring, strlen(aidstring));
-	} else if ((aidflags & TA_DOSTRINGD) != 0 && aidstring != NULL) {
-		tty3270_do_showi(tubp, aidstring, strlen(aidstring));
-		tubp->cmd = TBC_UPDINPUT;
-	} else {
-		if (in[0] != 0x60)
-			tubp->flags |= TUB_ALARM;
-		tubp->cmd = TBC_KRUPDLOG;
-	}
-do_build:
-	tty3270_build(tubp);
-}
-
-static void
-tty3270_do_enter(tub_t *tubp, char *cp, int count)
-{
-	struct tty_struct *tty;
-	int func = -1;
-
-	if ((tty = tubp->tty) == NULL)
-		return;
-	if (count < 0)
-		return;
-	if (count == 2 && (cp[0] == '^' || cp[0] == '\252')) {
-		switch(cp[1]) {
-		case 'c':  case 'C':
-			func = INTR_CHAR(tty);
-			break;
-		case 'd':  case 'D':
-			func = EOF_CHAR(tty);
-			break;
-		case 'z':  case 'Z':
-			func = SUSP_CHAR(tty);
-			break;
-		}
-	} else if (count == 2 && cp[0] == 0x1b) {        /* if ESC */
-		int inc = 0;
-		char buf[GEOM_INPLEN + 1];
-		int len;
-
-		switch(cp[1]) {
-		case 'k':  case 'K':
-			inc = -1;
-			break;
-		case 'j':  case 'J':
-			inc = 1;
-			break;
-		}
-		if (inc == 0)
-			goto not_rcl;
-		len = tty3270_rcl_get(tubp, buf, sizeof buf, inc);
-		if (len == 0) {
-			tubp->flags |= TUB_ALARM;
-			return;
-		}
-		tty3270_do_showi(tubp, buf, len);
-		tubp->cmd = TBC_UPDINPUT;
-		return;
-	}
-not_rcl:
-	if (func != -1) {
-		*tty->flip.flag_buf_ptr++ = TTY_NORMAL;
-		*tty->flip.char_buf_ptr++ = func;
-		tty->flip.count++;
-	} else {
-		tty3270_rcl_put(tubp, cp, count);
-		memcpy(tty->flip.char_buf_ptr, cp, count);
-		/* Add newline unless line ends with "^n" */
-		if (count < 2 || cp[count - 1] != 'n' ||
-		    (cp[count - 2] != '^' && cp[count - 2] != '\252')) {
-			tty->flip.char_buf_ptr[count] = '\n';
-			count++;
-		} else {
-			count -= 2;     /* Lop trailing "^n" from text */
-		}
-		memset(tty->flip.flag_buf_ptr, TTY_NORMAL, count);
-		tty->flip.char_buf_ptr += count;
-		tty->flip.flag_buf_ptr += count;
-		tty->flip.count += count;
-	}
-	tty_flip_buffer_push(tty);
-}
-
-static void
-tty3270_do_showi(tub_t *tubp, char *cp, int cl)
-{
-	if (cl > GEOM_INPLEN)
-		cl = GEOM_INPLEN;
-	memset(tubp->tty_input, 0, GEOM_INPLEN);
-	memcpy(tubp->tty_input, cp, cl);
-	TUB_ASCEBC(tubp->tty_input, cl);
-}
-
-
-
-/* Debugging routine */
-static int
-tty3270_show_tube(int minor, char *buf, int count)
-{
-	tub_t *tubp;
-	struct tty_struct *tty;
-	struct termios *mp;
-	int len;
-
-/*012345678901234567890123456789012345678901234567890123456789       */
-/*Info for tub_t[dd] at xxxxxxxx:                                    */
-/*    geom:  rows=dd cols=dd model=d                                 */
-/*    lnopen=dd     fsopen=dd   waitq=xxxxxxxx                       */
-/*    dstat=xx      mode=dd     stat=dd     flags=xxxx               */
-/*    oucount=dddd  ourd=ddddd  ouwr=ddddd  nextlogx=ddddd           */
-/*    tty=xxxxxxxx                                                   */
-/*    write_wait=xxxxxxxx read_wait=xxxxxxxx                         */
-/*    iflag=xxxxxxxx oflag=xxxxxxxx cflag=xxxxxxxx lflag=xxxxxxxx    */
-
-	if (minor < 0 || minor > tubnummins ||
-	    (tubp = (*tubminors)[minor]) == NULL)
-		return sprintf(buf, "No tube at index=%d\n", minor);
-	
-	tty = tubp->tty;
-	len = 0;
-
-	len += sprintf(buf+len, "Info for tub_t[%d] at %p:\n", minor, tubp);
-
-	len += sprintf(buf+len, "inattr is at %p\n", &tubp->tty_inattr);
-
-
-	len += sprintf(buf+len, "    geom:  rows=%.2d cols=%.2d model=%.1d\n",
-		       tubp->geom_rows, tubp->geom_cols, tubp->tubiocb.model);
-
-	len += sprintf(buf+len,
-		       "    lnopen=%-2d     fsopen=%-2d   waitq=%p\n",
-		       tubp->lnopen, tubp->fsopen, &tubp->waitq);
-
-	len += sprintf(buf+len, "    dstat=%.2x      mode=%-2d     "
-		       "stat=%-2d     flags=%-4x\n", tubp->dstat,
-		       tubp->mode, tubp->stat, tubp->flags);
-
-#ifdef RBH_FIXTHIS
-	len += sprintf(buf+len,
-		       "    oucount=%-4d  ourd=%-5d  ouwr=%-5d"
-		       "  nextlogx=%-5d\n", tubp->tty_oucount,
-		       tubp->tty_ourd, tubp->tty_ouwr, tubp->tty_nextlogx);
-#endif
-
-	len += sprintf(buf+len, "    tty=%p\n",tubp->tty);
-
-	if (tty)
-		len += sprintf(buf+len,
-				"    write_wait=%p read_wait=%p\n",
-				&tty->write_wait, &tty->read_wait);
-
-	if (tty && ((mp = tty->termios)))
-		len += sprintf(buf+len,"    iflag=%.8x oflag=%.8x "
-			       "cflag=%.8x lflag=%.8x\n", mp->c_iflag,
-			       mp->c_oflag, mp->c_cflag, mp->c_lflag);
-
-
-	return len;
-}
diff -puN -L drivers/s390/char/tubttyrcl.c drivers/s390/char/tubttyrcl.c~linus /dev/null
--- 25/drivers/s390/char/tubttyrcl.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,202 +0,0 @@
-/*
- *  IBM/3270 Driver -- Copyright (C) 2000 UTS Global LLC
- *
- *  tubttyrcl.c -- Linemode Command-recall functionality
- *
- *
- *
- *
- *
- *  Author:  Richard Hitt
- */
-#include "tubio.h"
-
-static void tty3270_rcl_sync(tub_t *);
-static int tty3270_rcl_resize(tub_t *, int);
-
-int
-tty3270_rcl_init(tub_t *tubp)
-{
-	return tty3270_rcl_resize(tubp, 20);
-}
-
-static int
-tty3270_rcl_resize(tub_t *tubp, int newrclk)
-{
-	char *(*newrclb)[];
-
-	if (newrclk > 1000)
-		return -EINVAL;
-	if (newrclk <= 0) {
-		tty3270_rcl_purge(tubp),
-		kfree(tubp->tty_rclbufs);
-		tubp->tty_rclbufs = NULL;
-		return 0;
-	}
-	if ((newrclb = (char *(*)[])kmalloc(
-	    newrclk * sizeof (char *), GFP_KERNEL)) == NULL)
-		return -ENOMEM;
-	memset(newrclb, 0, newrclk * sizeof (char *));
-	if (tubp->tty_rclbufs != NULL) {
-		int i, j, k;
-		char *data;
-
-		i = tubp->tty_rclp;
-		j = newrclk;
-		k = tubp->tty_rclk;
-		while (j-- && k--) {
-			if ((data = (*tubp->tty_rclbufs)[i]) == NULL)
-				break;
-			(*newrclb)[j] = data;
-			(*tubp->tty_rclbufs)[i] = NULL;
-			if (--i < 0)
-				i = tubp->tty_rclk - 1;
-		}
-		tty3270_rcl_purge(tubp);
-		kfree(tubp->tty_rclbufs);
-	}
-	tubp->tty_rclbufs = newrclb;
-	tubp->tty_rclk = newrclk;
-	tubp->tty_rclp = newrclk - 1;
-	tty3270_rcl_sync(tubp);
-	return 0;
-}
-
-int
-tty3270_rcl_set(tub_t *tubp, char *buf, int count)
-{
-#define RCL_SIZ "recallsize="
-#define L_RCL_SIZ (strlen(RCL_SIZ))
-	int newsize;
-	int len;
-	int rc;
-	char *rcl_siz = RCL_SIZ;
-	int l_rcl_siz = L_RCL_SIZ;
-
-	if (count < l_rcl_siz || strncmp(buf, rcl_siz, l_rcl_siz) != 0)
-		return 0;
-	if ((len = count - l_rcl_siz) == 0)
-		return count;
-	newsize = simple_strtoul(buf + l_rcl_siz, 0, 0);
-	rc = tty3270_rcl_resize(tubp, newsize);
-	return rc < 0? rc: count;
-}
-
-void
-tty3270_rcl_fini(tub_t *tubp)
-{
-	if (tubp->tty_rclbufs != NULL) {
-		tty3270_rcl_purge(tubp);
-		kfree(tubp->tty_rclbufs);
-		tubp->tty_rclbufs = NULL;
-	}
-}
-
-void
-tty3270_rcl_purge(tub_t *tubp)
-{
-	int i;
-	char *buf;
-
-	if (tubp->tty_rclbufs == NULL)
-		return;
-	for (i = 0; i < tubp->tty_rclk; i++) {
-		if ((buf = (*tubp->tty_rclbufs)[i]) == NULL)
-			continue;
-		kfree(buf);
-		(*tubp->tty_rclbufs)[i] = NULL;
-	}
-}
-
-int
-tty3270_rcl_get(tub_t *tubp, char *buf, int len, int inc)
-{
-	int iter;
-	int i;
-	char *data;
-
-	if (tubp->tty_rclbufs == NULL)
-		return 0;
-	if (tubp->tty_rclk <= 0)	/* overcautious */
-		return 0;
-	if (inc != 1 && inc != -1)	/* overcautious */
-		return 0;
-
-	if ((i = tubp->tty_rclb) == -1) {
-		i = tubp->tty_rclp;
-		if (inc == 1)
-			i++;
-	} else {
-		i += inc;
-	}
-	for (iter = tubp->tty_rclk; iter; iter--, i += inc) {
-		if (i < 0)
-			i = tubp->tty_rclk - 1;
-		else if (i >= tubp->tty_rclk)
-			i = 0;
-		if ((*tubp->tty_rclbufs)[i] != NULL)
-			break;
-	}
-	if (iter < 0 || (data = (*tubp->tty_rclbufs)[i]) == NULL)
-		return 0;
-	tubp->tty_rclb = i;
-	if ((len = MIN(len - 1, strlen(data))) <= 0)
-		return 0;
-	memcpy(buf, data, len);
-	buf[len] = '\0';
-	return len;
-}
-
-void
-tty3270_rcl_put(tub_t *tubp, char *data, int len)
-{
-	char *buf, **bufp;
-	int i;
-
-	if (tubp->tty_rclbufs == NULL)
-		return;
-
-	if (tubp->tty_rclk <= 0)        /* overcautious */
-		return;
-
-	/* If input area is invisible, don't log */
-	if (tubp->tty_inattr == TF_INPUTN)
-		return;
-
-	/* If this & most recent cmd text match, don't log */
-	if ((buf = (*tubp->tty_rclbufs)[tubp->tty_rclp]) != NULL &&
-	    strlen(buf) == len && memcmp(buf, data, len) == 0) {
-		tty3270_rcl_sync(tubp);
-		return;
-	}
-
-	/* Don't stack zero-length commands */
-	if (len == 0) {
-		tty3270_rcl_sync(tubp);
-		return;
-	}
-
-	i = tubp->tty_rclp;
-	if (++i == tubp->tty_rclk)
-		i = 0;
-	bufp = &(*tubp->tty_rclbufs)[i];
-	if (*bufp == NULL || strlen(*bufp) < len + 1) {
-		if (*bufp) {
-			kfree(*bufp);
-			*bufp = NULL;
-		}
-		if ((*bufp = kmalloc(len + 1, GFP_ATOMIC)) == NULL)
-			return;
-	}
-	memcpy(*bufp, data, len);
-	(*bufp)[len] = '\0';
-	tubp->tty_rclp = i;
-	tty3270_rcl_sync(tubp);
-}
-
-static void
-tty3270_rcl_sync(tub_t *tubp)
-{
-	tubp->tty_rclb = -1;
-}
-
diff -puN -L drivers/s390/char/tubttyscl.c drivers/s390/char/tubttyscl.c~linus /dev/null
--- 25/drivers/s390/char/tubttyscl.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,88 +0,0 @@
-/*
- *  IBM/3270 Driver -- Copyright (C) 2000, 2001 UTS Global LLC
- *
- *  tubttyscl.c -- Linemode tty driver scroll-timing functions
- *
- *
- *
- *
- *
- *  Author:  Richard Hitt
- */
-#include "tubio.h"
-       void tty3270_scl_settimer(tub_t *);
-       void tty3270_scl_resettimer(tub_t *);
-static void tty3270_scl_timeout(unsigned long);
-
-void
-tty3270_scl_settimer(tub_t *tubp)
-{
-	struct timer_list *tp = &tubp->tty_stimer;
-
-	if (tubp->flags & TUB_SCROLLTIMING)
-		return;
-	if (tubp->tty_scrolltime == 0)
-		return;
-
-	init_timer(tp);
-	tp->expires = jiffies + HZ * tubp->tty_scrolltime;
-	tp->data = (unsigned long)tubp;
-	tp->function = tty3270_scl_timeout;
-	add_timer(tp);
-	tubp->flags |= TUB_SCROLLTIMING;
-}
-
-void
-tty3270_scl_resettimer(tub_t *tubp)
-{
-	struct timer_list *tp = &tubp->tty_stimer;
-
-	if ((tubp->flags & TUB_SCROLLTIMING) == 0)
-		return;
-
-	del_timer(tp);
-	tubp->flags &= ~TUB_SCROLLTIMING;
-}
-
-static void
-tty3270_scl_timeout(unsigned long data)
-{
-	tub_t *tubp = (void *)data;
-	long flags;
-
-	TUBLOCK(tubp->irq, flags);
-	tubp->stat = TBS_RUNNING;
-	tty3270_scl_resettimer(tubp);
-	tubp->cmd = TBC_CLRUPDLOG;
-	tty3270_build(tubp);
-	TUBUNLOCK(tubp->irq, flags);
-}
-
-int
-tty3270_scl_set(tub_t *tubp, char *buf, int count)
-{
-	if (strncmp(buf, "scrolltime=", 11) == 0) {
-		tubp->tty_scrolltime =
-			simple_strtoul(buf + 11, 0, 0);
-		return count;
-	}
-	return 0;
-}
-
-int
-tty3270_scl_init(tub_t *tubp)
-{
-	extern int tubscrolltime;
-
-	tubp->tty_scrolltime = tubscrolltime;
-	if (tubp->tty_scrolltime < 0)
-		tubp->tty_scrolltime = DEFAULT_SCROLLTIME;
-	return 0;
-}
-
-void
-tty3270_scl_fini(tub_t *tubp)
-{
-	if ((tubp->flags & TUB_OPEN_STET) == 0)
-		tty3270_scl_resettimer(tubp);
-}
diff -puN -L drivers/s390/char/tubttysiz.c drivers/s390/char/tubttysiz.c~linus /dev/null
--- 25/drivers/s390/char/tubttysiz.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,306 +0,0 @@
-/*
- *  IBM/3270 Driver -- Copyright (C) 2000 UTS Global LLC
- *
- *  tubttysiz.c -- Linemode screen-size determiner
- *
- *
- *
- *
- *
- *  Author:  Richard Hitt
- */
-#include "tubio.h"
-static int tty3270_size_io(tub_t *tubp);
-static void tty3270_size_int(tub_t *tubp, devstat_t *dsp);
-static int tty3270_size_wait(tub_t *tubp, long *flags, int stat);
-
-/*
- * Structure representing Usable Area Query Reply Base
- */
-typedef struct {
-	short l;                /* Length of this structured field */
-	char sfid;              /* 0x81 if Query Reply */
-	char qcode;             /* 0x81 if Usable Area */
-#define QCODE_UA 0x81
-	char flags0;
-#define FLAGS0_ADDR 0x0f
-#define FLAGS0_ADDR_12_14       1       /* 12/14-bit adrs ok */
-#define FLAGS0_ADDR_12_14_16    3       /* 12/14/16-bit adrs ok */
-	char flags1;
-	short w;                /* Width of usable area */
-	short h;                /* Heigth of usavle area */
-	char units;             /* 0x00:in; 0x01:mm */
-	int xr;
-	int yr;
-	char aw;
-	char ah;
-	short buffsz;           /* Character buffer size, bytes */
-	char xmin;
-	char ymin;
-	char xmax;
-	char ymax;
-} __attribute__ ((packed)) uab_t;
-
-/*
- * Structure representing Alternate Usable Area Self-Defining Parameter
- */
-typedef struct {
-	char l;                 /* Length of this Self-Defining Parm */
-	char sdpid;             /* 0x02 if Alternate Usable Area */
-#define SDPID_AUA 0x02
-	char res;
-	char auaid;             /* 0x01 is Id for the A U A */
-	short wauai;            /* Width of AUAi */
-	short hauai;            /* Height of AUAi */
-	char auaunits;          /* 0x00:in, 0x01:mm */
-	int auaxr;
-	int auayr;
-	char awauai;
-	char ahauai;
-} __attribute__ ((packed)) aua_t;
-
-/*
- * Structure representing one followed by the other
- */
-typedef struct {
-	uab_t uab;
-	aua_t aua;
-} __attribute__ ((packed)) ua_t;
-
-/*
- * Try to determine screen size using Read Partition (Query)
- */
-int
-tty3270_size(tub_t *tubp, long *flags)
-{
-	char wbuf[7] = { 0x00, 0x07, 0x01, 0xff, 0x03, 0x00, 0x81 };
-	int     rc = 0;
-	int     count;
-	unsigned char *cp;
-	ua_t *uap;
-	char miniscreen[256];
-	char (*screen)[];
-	int screenl;
-	int geom_rows, geom_cols, fourteenbitadr;
-	void (*oldint)(struct tub_s *, devstat_t *);
-
-	if (tubp->flags & TUB_SIZED)
-		return 0;
-	fourteenbitadr = 0;
-	geom_rows = tubp->geom_rows;
-	geom_cols = tubp->geom_cols;
-
-	oldint = tubp->intv;
-	tubp->intv = tty3270_size_int;
-
-	if (tubp->cmd == TBC_CONOPEN) {
-		tubp->ttyccw.cmd_code = TC_EWRITEA;
-		cp = miniscreen;
-		*cp++ = TW_KR;
-		/* more? */
-		tubp->ttyccw.flags = CCW_FLAG_SLI;
-		tubp->ttyccw.cda = virt_to_phys(miniscreen);
-		tubp->ttyccw.count = (char *)cp - miniscreen;
-		rc = tty3270_size_io(tubp);
-		rc = tty3270_size_wait(tubp, flags, 0);
-	}
-
-	tubp->ttyccw.cmd_code = TC_WRITESF;
-	tubp->ttyccw.flags = CCW_FLAG_SLI;
-	tubp->ttyccw.cda = virt_to_phys(wbuf);
-	tubp->ttyccw.count = sizeof wbuf;
-
-try_again:
-	rc = tty3270_size_io(tubp);
-	if (rc)
-		printk("tty3270_size_io returned %d\n", rc);
-
-	rc = tty3270_size_wait(tubp, flags, 0);
-	if (rc != 0) {
-		goto do_return;
-	}
-
-	/*
-	 * Unit-Check Processing:
-	 * Expect Command Reject or Intervention Required.
-	 * For Command Reject assume old hdwe/software and
-	 * set a default size of 80x24.
-	 * For Intervention Required, wait for signal pending
-	 * or Unsolicited Device End; if the latter, retry.
-	 */
-	if (tubp->dstat & DEV_STAT_UNIT_CHECK) {
-		if (tubp->sense.data[0] & SNS0_CMD_REJECT) {
-			goto use_diag210; /* perhaps it's tn3270 */
-		} else if (tubp->sense.data[0] & SNS0_INTERVENTION_REQ) {
-			if ((rc = tty3270_size_wait(tubp, flags,
-			    DEV_STAT_DEV_END)))
-				goto do_return;
-			goto try_again;
-		} else {
-			printk("tty3270_size(): unkn sense %.2x\n",
-				tubp->sense.data[0]);
-			goto do_return;
-		}
-	}
-	if ((rc = tty3270_size_wait(tubp, flags, DEV_STAT_ATTENTION)))
-		goto do_return;
-
-	/* Set up a read ccw and issue it */
-	tubp->ttyccw.cmd_code = TC_READMOD;
-	tubp->ttyccw.flags = CCW_FLAG_SLI;
-	tubp->ttyccw.cda = virt_to_phys(miniscreen);
-	tubp->ttyccw.count = sizeof miniscreen;
-	tty3270_size_io(tubp);
-	rc = tty3270_size_wait(tubp, flags, 0);
-	if (rc != 0)
-		goto do_return;
-
-	count = sizeof miniscreen - tubp->cswl;
-	cp = miniscreen;
-	if (*cp++ != 0x88)
-		goto do_return;
-	uap = (void *)cp;
-	if (uap->uab.qcode != QCODE_UA)
-		goto do_return;
-	geom_rows = uap->uab.h;
-	geom_cols = uap->uab.w;
-	if ((uap->uab.flags0 & FLAGS0_ADDR) == FLAGS0_ADDR_12_14 ||
-	    (uap->uab.flags0 & FLAGS0_ADDR) == FLAGS0_ADDR_12_14_16)
-		fourteenbitadr = 1;
-	if (uap->uab.l <= sizeof uap->uab)
-		goto do_return;
-	if (uap->aua.sdpid != SDPID_AUA) {
-		printk("AUA sdpid was 0x%.2x, expecting 0x%.2x\n",
-			uap->aua.sdpid, SDPID_AUA);
-		goto do_return;
-	}
-	geom_rows = uap->aua.hauai;
-	geom_cols = uap->aua.wauai;
-	goto do_return;
-
-use_diag210:
-	if (MACHINE_IS_VM) {
-		diag210_t d210;
-
-		d210.vrdcdvno = tubp->devno;
-		d210.vrdclen = sizeof d210;
-		rc = diag210(&d210);
-		if (rc) {
-			printk("tty3270_size: diag210 for 0x%.4x "
-				"returned %d\n", tubp->devno, rc);
-			goto do_return;
-		}
-		switch(d210.vrdccrmd) {
-		case 2:
-			geom_rows = 24;
-			geom_cols = 80;
-			goto do_return;
-		case 3:
-			geom_rows = 32;
-			geom_cols = 80;
-			goto do_return;
-		case 4:
-			geom_rows = 43;
-			geom_cols = 80;
-			goto do_return;
-		case 5:
-			geom_rows = 27;
-			geom_cols = 132;
-			goto do_return;
-		default:
-			printk("vrdccrmd is 0x%.8x\n", d210.vrdccrmd);
-		}
-	}
-
-do_return:
-	if (geom_rows == 0) {
-		geom_rows = _GEOM_ROWS;
-		geom_cols = _GEOM_COLS;
-	}
-	tubp->tubiocb.pf_cnt = 24;
-	tubp->tubiocb.re_cnt = 20;
-	tubp->tubiocb.map = 0;
-
-	screenl = geom_rows * geom_cols + 100;
-	screen = (char (*)[])kmalloc(screenl, GFP_KERNEL);
-	if (screen == NULL) {
-		printk("ttyscreen size %d unavailable\n", screenl);
-	} else {
-		if (tubp->ttyscreen)
-			kfree(tubp->ttyscreen);
-		tubp->tubiocb.line_cnt = tubp->geom_rows = geom_rows;
-		tubp->tubiocb.col_cnt = tubp->geom_cols = geom_cols;
-		tubp->tty_14bitadr = fourteenbitadr;
-		tubp->ttyscreen = screen;
-		tubp->ttyscreenl = screenl;
-		if (geom_rows == 24 && geom_cols == 80)
-			tubp->tubiocb.model = 2;
-		else if (geom_rows == 32 && geom_cols == 80)
-			tubp->tubiocb.model = 3;
-		else if (geom_rows == 43 && geom_cols == 80)
-			tubp->tubiocb.model = 4;
-		else if (geom_rows == 27 && geom_cols == 132)
-			tubp->tubiocb.model = 5;
-		else
-			tubp->tubiocb.model = 0;
-		tubp->flags |= TUB_SIZED;
-	}
-	if (rc == 0 && tubp->ttyscreen == NULL)
-		rc = -ENOMEM;
-	tubp->intv = oldint;
-	return rc;
-}
-
-static int
-tty3270_size_io(tub_t *tubp)
-{
-	tubp->flags |= TUB_WORKING;
-	tubp->dstat = 0;
-
-	return do_IO(tubp->irq, &tubp->ttyccw, tubp->irq, 0, 0);
-}
-
-static void
-tty3270_size_int(tub_t *tubp, devstat_t *dsp)
-{
-#define DEV_NOT_WORKING \
-  (DEV_STAT_ATTENTION | DEV_STAT_DEV_END | DEV_STAT_UNIT_CHECK)
-
-	tubp->dstat = dsp->dstat;
-	if (dsp->dstat & DEV_STAT_CHN_END)
-		tubp->cswl = dsp->rescnt;
-	if (dsp->dstat & DEV_NOT_WORKING)
-		tubp->flags &= ~TUB_WORKING;
-	if (dsp->dstat & DEV_STAT_UNIT_CHECK)
-		tubp->sense = dsp->ii.sense;
-
-	wake_up_interruptible(&tubp->waitq);
-}
-
-/*
- * Wait for something.  If the third arg is zero, wait until
- * tty3270_size_int() turns off TUB_WORKING.  If the third arg
- * is not zero, it is a device-status bit; wait until dstat
- * has the bit turned on.  Never wait if signal is pending.
- * Return 0 unless signal pending, in which case -ERESTARTSYS.
- */
-static int
-tty3270_size_wait(tub_t *tubp, long *flags, int stat)
-{
-	DECLARE_WAITQUEUE(wait, current);
-
-	add_wait_queue(&tubp->waitq, &wait);
-	while (!signal_pending(current) &&
-	    (stat? (tubp->dstat & stat) == 0:
-	     (tubp->flags & TUB_WORKING) != 0)) {
-#warning FIXME: [kj] use set_current_state instead of current->state=
-		current->state = TASK_INTERRUPTIBLE;
-		TUBUNLOCK(tubp->irq, *flags);
-		schedule();
-#warning FIXME: [kj] use set_current_state instead of current->state=
-		current->state = TASK_RUNNING;
-		TUBLOCK(tubp->irq, *flags);
-	}
-	remove_wait_queue(&tubp->waitq, &wait);
-	return signal_pending(current)? -ERESTARTSYS: 0;
-}
diff -puN drivers/s390/cio/blacklist.c~linus drivers/s390/cio/blacklist.c
--- 25/drivers/s390/cio/blacklist.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/cio/blacklist.c	2004-01-19 22:17:23.000000000 -0800
@@ -1,7 +1,7 @@
 /*
  *  drivers/s390/cio/blacklist.c
  *   S/390 common I/O routines -- blacklisting of specific devices
- *   $Revision: 1.24 $
+ *   $Revision: 1.27 $
  *
  *    Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
  *			      IBM Corporation
@@ -62,51 +62,117 @@ blacklist_range (range_action action, un
 }
 
 /*
- * function: blacklist_strtoul
- * Strip leading '0x' and interpret the values as Hex
+ * Function: blacklist_busid
+ * Get devno/busid from given string.
+ * Shamelessly grabbed from dasd_devmap.c.
  */
 static inline int
-blacklist_strtoul (const char *str, char **stra)
+blacklist_busid(char **str, int *id0, int *id1, int *devno)
 {
-	if (*str == '0') {
-		if (*(++str) == 'x')  /* strip leading zero */
-			str++;	      /* strip leading x */
+	int val, old_style;
+ 
+	/* check for leading '0x' */
+	old_style = 0;
+	if ((*str)[0] == '0' && (*str)[1] == 'x') {
+		*str += 2;
+		old_style = 1;
 	}
-	return simple_strtoul (str, stra, 16); /* interpret anything as hex */
+	if (!isxdigit((*str)[0]))	/* We require at least one hex digit */
+		return -EINVAL;
+	val = simple_strtoul(*str, str, 16);
+	if (old_style || (*str)[0] != '.') {
+		*id0 = *id1 = 0;
+		if (val < 0 || val > 0xffff)
+			return -EINVAL;
+		*devno = val;
+		return 0;
+	}
+	/* New style x.y.z busid */
+	if (val < 0 || val > 0xff)
+		return -EINVAL;
+	*id0 = val;
+	(*str)++;
+	if (!isxdigit((*str)[0]))	/* We require at least one hex digit */
+		return -EINVAL;
+	val = simple_strtoul(*str, str, 16);
+	if (val < 0 || val > 0xff || (*str)++[0] != '.')
+		return -EINVAL;
+	*id1 = val;
+	if (!isxdigit((*str)[0]))	/* We require at least one hex digit */
+		return -EINVAL;
+	val = simple_strtoul(*str, str, 16);
+	if (val < 0 || val > 0xffff)
+		return -EINVAL;
+	*devno = val;
+	return 0;
 }
 
 static inline int
 blacklist_parse_parameters (char *str, range_action action)
 {
-	unsigned int from, to;
+	unsigned int from, to, from_id0, to_id0, from_id1, to_id1;
+	char *sav;
 
+	sav = str;
 	while (*str != 0 && *str != '\n') {
-		if (!isxdigit(*str)) {
-			printk(KERN_WARNING "blacklist_setup: error parsing "
-			       "\"%s\"\n", str);
-			return 0;
+		range_action ra = action;
+		if (*str == '!') {
+			ra = !action;
+			++str;
 		}
 
-		from = blacklist_strtoul (str, &str);
-		to = (*str == '-') ? blacklist_strtoul (str+1, &str) : from;
-
+		/*
+		 * Since we have to parse the proc commands and the
+		 * kernel arguments we have to check four cases
+		 */
+		if (strncmp(str,"all,",4) == 0 || strcmp(str,"all") == 0 ||
+		    strncmp(str,"all\n",4) == 0 || strncmp(str,"all ",4) == 0) {
+			from = 0;
+			to = __MAX_SUBCHANNELS;
+			str += 3;
+		} else {
+			int rc;
+
+			rc = blacklist_busid(&str, &from_id0,
+					     &from_id1, &from);
+			if (rc)
+				goto out_err;
+			to = from;
+			to_id0 = from_id0;
+			to_id1 = from_id1;
+			if (*str == '-') {
+				str++;
+				rc = blacklist_busid(&str, &to_id0, &to_id1,
+						     &to);
+				if (rc)
+					goto out_err;
+			}
+			if ((from_id0 != to_id0) || (from_id1 != to_id1))
+				goto out_err;
+		}
+		/* FIXME: ignoring id0 and id1 here. */
 		pr_debug("blacklist_setup: adding range "
-			 "from 0x%04x to 0x%04x\n", from, to);
-		blacklist_range (action, from, to);
+			 "from 0.0.%04x to 0.0.%04x\n", from, to);
+		blacklist_range (ra, from, to);
 
 		if (*str == ',')
 			str++;
 	}
 	return 1;
+out_err:
+	printk(KERN_WARNING "blacklist_setup: error parsing \"%s\"\n", sav);
+	return 0;
 }
 
 /* Parsing the commandline for blacklist parameters, e.g. to blacklist
- * device IDs 0x1234, 0x1235 and 0x1236, you could use any of:
+ * bus ids 0.0.1234, 0.0.1235 and 0.0.1236, you could use any of:
  * - cio_ignore=1234-1236
  * - cio_ignore=0x1234-0x1235,1236
  * - cio_ignore=0x1234,1235-1236
  * - cio_ignore=1236 cio_ignore=1234-0x1236
  * - cio_ignore=1234 cio_ignore=1236 cio_ignore=0x1235
+ * - cio_ignore=0.0.1234-0.0.1236
+ * - cio_ignore=0.0.1234,0x1235,1236
  * - ...
  */
 static int __init
@@ -134,6 +200,7 @@ is_blacklisted (int devno)
 
 #ifdef CONFIG_PROC_FS
 
+extern void css_reiterate_subchannels(void);
 /*
  * Function: s390_redo_validation
  * Look for no longer blacklisted devices
@@ -141,12 +208,9 @@ is_blacklisted (int devno)
 static inline void
 s390_redo_validation (void)
 {
-	int irq;
-
 	CIO_TRACE_EVENT (0, "redoval");
 
-	for (irq = 0; irq <= highest_subchannel; irq++)
-		css_probe_device(irq);
+	css_reiterate_subchannels();
 }
 
 /*
@@ -157,10 +221,7 @@ static inline void
 blacklist_parse_proc_parameters (char *buf)
 {
 	if (strncmp (buf, "free ", 5) == 0) {
-		if (strstr (buf + 5, "all"))
-			blacklist_range (free, 0, __MAX_SUBCHANNELS);
-		else
-			blacklist_parse_parameters (buf + 5, free);
+		blacklist_parse_parameters (buf + 5, free);
 	} else if (strncmp (buf, "add ", 4) == 0) {
 		/* 
 		 * We don't need to check for known devices since
@@ -179,10 +240,11 @@ blacklist_parse_proc_parameters (char *b
 	s390_redo_validation ();
 }
 
+/* FIXME: These should be real bus ids and not home-grown ones! */
 static int cio_ignore_read (char *page, char **start, off_t off,
 			    int count, int *eof, void *data)
 {
-	const unsigned int entry_size = 14; /* "0xABCD-0xEFGH\n" */
+	const unsigned int entry_size = 18; /* "0.0.ABCD-0.0.EFGH\n" */
 	long devno;
 	int len;
 
@@ -192,12 +254,12 @@ static int cio_ignore_read (char *page, 
 	     devno <= __MAX_SUBCHANNELS && len + entry_size < count; devno++) {
 		if (!test_bit(devno, bl_dev))
 			continue;
-		len += sprintf(page + len, "0x%04lx", devno);
+		len += sprintf(page + len, "0.0.%04lx", devno);
 		if (test_bit(devno + 1, bl_dev)) { /* print range */
 			while (++devno < __MAX_SUBCHANNELS)
 				if (!test_bit(devno, bl_dev))
 					break;
-			len += sprintf(page + len, "-0x%04lx", --devno);
+			len += sprintf(page + len, "-0.0.%04lx", --devno);
 		}
 		len += sprintf(page + len, "\n");
 	}
diff -puN drivers/s390/cio/ccwgroup.c~linus drivers/s390/cio/ccwgroup.c
--- 25/drivers/s390/cio/ccwgroup.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/cio/ccwgroup.c	2004-01-19 22:17:23.000000000 -0800
@@ -1,7 +1,7 @@
 /*
  *  drivers/s390/cio/ccwgroup.c
  *  bus driver for ccwgroup
- *   $Revision: 1.17 $
+ *   $Revision: 1.19 $
  *
  *    Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
  *                       IBM Corporation
@@ -337,7 +337,6 @@ ccwgroup_remove (struct device *dev)
 {
 	struct ccwgroup_device *gdev;
 	struct ccwgroup_driver *gdrv;
-	int ret;
 
 	gdev = to_ccwgroupdev(dev);
 	gdrv = to_ccwgroupdrv(dev->driver);
@@ -345,11 +344,10 @@ ccwgroup_remove (struct device *dev)
 	pr_debug("%s: device %s\n", __func__, gdev->dev.name);
 
 	device_remove_file(dev, &dev_attr_online);
-	ccwgroup_set_offline(gdev);
-
-	ret = (gdrv && gdrv->remove) ? gdrv->remove(gdev) : 0;
 
-	return ret;
+	if (gdrv && gdrv->remove)
+		gdrv->remove(gdev);
+	return 0;
 }
 
 int
@@ -418,20 +416,20 @@ __ccwgroup_get_gdev_by_cdev(struct ccw_d
 	return gdev;
 }
 
-int
+void
 ccwgroup_remove_ccwdev(struct ccw_device *cdev)
 {
 	struct ccwgroup_device *gdev;
 
+	/* Ignore offlining errors, device is gone anyway. */
+	ccw_device_set_offline(cdev);
 	/* If one of its devices is gone, the whole group is done for. */
 	gdev = __ccwgroup_get_gdev_by_cdev(cdev);
 	if (gdev) {
-		ccwgroup_set_offline(gdev);
 		__ccwgroup_remove_symlinks(gdev);
 		device_unregister(&gdev->dev);
 		put_device(&gdev->dev);
 	}
-	return 0;
 }
 
 MODULE_LICENSE("GPL");
diff -puN drivers/s390/cio/chsc.c~linus drivers/s390/cio/chsc.c
--- 25/drivers/s390/cio/chsc.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/cio/chsc.c	2004-01-19 22:17:23.000000000 -0800
@@ -1,7 +1,7 @@
 /*
  *  drivers/s390/cio/chsc.c
  *   S/390 common I/O routines -- channel subsystem call
- *   $Revision: 1.78 $
+ *   $Revision: 1.92 $
  *
  *    Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
  *			      IBM Corporation
@@ -17,40 +17,40 @@
 #include <linux/device.h>
 
 #include <asm/cio.h>
-#include <asm/ccwdev.h> // FIXME: layering violation, remove this
 
 #include "css.h"
 #include "cio.h"
 #include "cio_debug.h"
-#include "device.h" // FIXME: layering violation, remove this
 #include "ioasm.h"
 #include "chsc.h"
 
 #define CHPID_LONGS (256 / (8 * sizeof(long))) /* 256 chpids */
-static unsigned long chpids[CHPID_LONGS];
-static unsigned long chpids_logical[CHPID_LONGS] = {[0 ... CHPID_LONGS-1] -1};
-static unsigned long chpids_known[CHPID_LONGS];
-
 static struct channel_path *chps[NR_CHPIDS];
 
-static int cio_chsc_desc_avail;
-
 static int new_channel_path(int chpid, int status);
 
-static int
-set_chp_status(int chp, int status)
+static inline void
+set_chp_online(int chp, int onoff)
 {
-	if (chps[chp] == NULL)
-		return -EINVAL;
+	chps[chp]->state.online = onoff;
+}
 
-	chps[chp]->state = status;
-	return 0;
+static inline void
+set_chp_logically_online(int chp, int onoff)
+{
+	chps[chp]->state.logically_online = onoff;
 }
 
-static inline int
-chsc_chpid_logical (struct subchannel *sch, int chp)
+static int
+get_chp_status(int chp)
 {
-	return test_bit (sch->schib.pmcw.chpid[chp], chpids_logical);
+	int ret;
+
+	if (!chps[chp])
+		return 0;
+	ret = chps[chp]->state.online ? CHP_ONLINE : CHP_STANDBY;
+	return (chps[chp]->state.logically_online ?
+		ret : ret | CHP_LOGICALLY_OFFLINE);
 }
 
 void
@@ -58,24 +58,21 @@ chsc_validate_chpids(struct subchannel *
 {
 	int mask, chp;
 
-	if (sch->lpm == 0)
-		return;
-
 	for (chp = 0; chp <= 7; chp++) {
 		mask = 0x80 >> chp;
-		if (sch->lpm & mask)
-			if (!chsc_chpid_logical(sch, chp))
-				/* disable using this path */
-				sch->lpm &= ~mask;
+		if (get_chp_status(sch->schib.pmcw.chpid[chp])
+		    &  CHP_LOGICALLY_OFFLINE)
+			/* disable using this path */
+			sch->opm &= ~mask;
 	}
 }
 
 /* FIXME: this is _always_ called for every subchannel. shouldn't we
  *	  process more than one at a time? */
 static int
-chsc_get_sch_desc_irq(int irq, void *page)
+chsc_get_sch_desc_irq(struct subchannel *sch, void *page)
 {
-	int ccode, chpid, j;
+	int ccode, j;
 
 	struct {
 		struct chsc_header request;
@@ -106,8 +103,8 @@ chsc_get_sch_desc_irq(int irq, void *pag
 		.code   = 0x0004,
 	};
 
-	ssd_area->f_sch = irq;
-	ssd_area->l_sch = irq;
+	ssd_area->f_sch = sch->irq;
+	ssd_area->l_sch = sch->irq;
 
 	ccode = chsc(ssd_area);
 	if (ccode > 0) {
@@ -120,19 +117,17 @@ chsc_get_sch_desc_irq(int irq, void *pag
 		break;
 	case 0x0002:
 		CIO_CRW_EVENT(2, "Invalid command!\n");
+		return -EINVAL;
 	case 0x0003:
 		CIO_CRW_EVENT(2, "Error in chsc request block!\n");
 		return -EINVAL;
-		break;
 	case 0x0004:
 		CIO_CRW_EVENT(2, "Model does not provide ssd\n");
 		return -EOPNOTSUPP;
-		break;
 	default:
 		CIO_CRW_EVENT(2, "Unknown CHSC response %d\n",
 			      ssd_area->response.code);
 		return -EIO;
-		break;
 	}
 
 	/*
@@ -151,7 +146,7 @@ chsc_get_sch_desc_irq(int irq, void *pag
 	 */
 	if (ssd_area->st > 3) { /* uhm, that looks strange... */
 		CIO_CRW_EVENT(0, "Strange subchannel type %d"
-			      " for sch %x\n", ssd_area->st, irq);
+			      " for sch %s\n", ssd_area->st, sch->dev.bus_id);
 		/*
 		 * There may have been a new subchannel type defined in the
 		 * time since this code was written; since we don't know which
@@ -160,14 +155,11 @@ chsc_get_sch_desc_irq(int irq, void *pag
 		return 0;
 	} else {
 		const char *type[4] = {"I/O", "chsc", "message", "ADM"};
-		CIO_CRW_EVENT(6, "ssd: sch %x is %s subchannel\n",
-			      irq, type[ssd_area->st]);
-		if (ioinfo[irq] == NULL)
-			/* FIXME: we should do device rec. here... */
-			return 0;
+		CIO_CRW_EVENT(6, "ssd: sch %s is %s subchannel\n",
+			      sch->dev.bus_id, type[ssd_area->st]);
 
-		ioinfo[irq]->ssd_info.valid = 1;
-		ioinfo[irq]->ssd_info.type = ssd_area->st;
+		sch->ssd_info.valid = 1;
+		sch->ssd_info.type = ssd_area->st;
 	}
 
 	if (ssd_area->st == 0 || ssd_area->st == 2) {
@@ -175,89 +167,73 @@ chsc_get_sch_desc_irq(int irq, void *pag
 			if (!((0x80 >> j) & ssd_area->path_mask &
 			      ssd_area->fla_valid_mask))
 				continue;
-			chpid = ssd_area->chpid[j];
-			if (chpid
-			    && (!test_and_set_bit (chpid, chpids_known))
-			    && (test_bit (chpid, chpids_logical)))
-				set_bit	 (chpid, chpids);
-
-			ioinfo[irq]->ssd_info.chpid[j] = chpid;
-			ioinfo[irq]->ssd_info.fla[j]   = ssd_area->fla[j];
+			sch->ssd_info.chpid[j] = ssd_area->chpid[j];
+			sch->ssd_info.fla[j]   = ssd_area->fla[j];
 		}
 	}
-
 	return 0;
 }
 
-static int
-chsc_get_sch_descriptions(void)
+int
+css_get_ssd_info(struct subchannel *sch)
 {
-	int irq;
-	int err;
+	int ret;
 	void *page;
 
-	CIO_TRACE_EVENT( 4, "gsdesc");
-
-	/*
-	 * get information about chpids and link addresses
-	 * by executing the chsc command 'store subchannel description'
-	 */
 	page = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
 	if (!page)
 		return -ENOMEM;
-
-	err = 0;
-	for (irq = 0; irq <= highest_subchannel; irq++) {
-		/*
-		 * retrieve information for each sch
-		 */
-		err = chsc_get_sch_desc_irq(irq, page);
-		if (err) {
-			static int cio_chsc_err_msg;
-
-			if (!cio_chsc_err_msg) {
-				printk(KERN_ERR
-				       "chsc_get_sch_descriptions:"
-				       " Error %d while doing chsc; "
-				       "processing some machine checks may "
-				       "not work\n", err);
-				cio_chsc_err_msg = 1;
-			}
-			goto out;
+	spin_lock_irq(&sch->lock);
+	ret = chsc_get_sch_desc_irq(sch, page);
+	if (ret) {
+		static int cio_chsc_err_msg;
+		
+		if (!cio_chsc_err_msg) {
+			printk(KERN_ERR
+			       "chsc_get_sch_descriptions:"
+			       " Error %d while doing chsc; "
+			       "processing some machine checks may "
+			       "not work\n", ret);
+			cio_chsc_err_msg = 1;
 		}
-		clear_page(page);
 	}
-	cio_chsc_desc_avail = 1;
-out:
+	spin_unlock_irq(&sch->lock);
 	free_page((unsigned long)page);
-	return err;
+	if (!ret) {
+		int j, chpid;
+		/* Allocate channel path structures, if needed. */
+		for (j = 0; j < 8; j++) {
+			chpid = sch->ssd_info.chpid[j];
+			if (chpid && !get_chp_status(chpid))
+			    new_channel_path(chpid, CHP_ONLINE);
+		}
+	}
+	return ret;
 }
 
-__initcall(chsc_get_sch_descriptions);
-
-
-static inline void
-s390_subchannel_remove_chpid(struct subchannel *sch, __u8 chpid)
+static int
+s390_subchannel_remove_chpid(struct device *dev, void *data)
 {
 	int j;
 	int mask;
+	struct subchannel *sch;
+	__u8 *chpid;
 
+	sch = to_subchannel(dev);
+	chpid = data;
 	for (j = 0; j < 8; j++)
-		if (sch->schib.pmcw.chpid[j] == chpid)
+		if (sch->schib.pmcw.chpid[j] == *chpid)
 			break;
 	if (j >= 8)
-		return;
+		return 0;
 
 	mask = 0x80 >> j;
 	spin_lock(&sch->lock);
 
-	chsc_validate_chpids(sch);
-
 	stsch(sch->irq, &sch->schib);
-	if (sch->vpm == mask) {
-		dev_fsm_event(sch->dev.driver_data, DEV_EVENT_NOTOPER);
-		goto out_unlock;
-	}
+	if (sch->vpm == mask)
+		goto out_unreg;
+
 	if ((sch->schib.scsw.actl & (SCSW_ACTL_CLEAR_PEND |
 				     SCSW_ACTL_HALT_PEND |
 				     SCSW_ACTL_START_PEND |
@@ -265,83 +241,64 @@ s390_subchannel_remove_chpid(struct subc
 	    (sch->schib.pmcw.lpum == mask)) {
 		int cc = cio_cancel(sch);
 		
-		if (cc == -ENODEV) {
-			dev_fsm_event(sch->dev.driver_data, DEV_EVENT_NOTOPER);
-			goto out_unlock;
-		}
+		if (cc == -ENODEV)
+			goto out_unreg;
 
 		if (cc == -EINVAL) {
-			struct ccw_device *cdev;
-
 			cc = cio_clear(sch);
-			if (cc == -ENODEV) {
-				dev_fsm_event(sch->dev.driver_data,
-					      DEV_EVENT_NOTOPER);
-				goto out_unlock;
-			}
+			if (cc == -ENODEV)
+				goto out_unreg;
 			/* Call handler. */
-			cdev = sch->dev.driver_data;
-			cdev->private->state = DEV_STATE_CLEAR_VERIFY;
-			if (cdev->handler)
-				cdev->handler(cdev, cdev->private->intparm,
-					      ERR_PTR(-EIO));
+			if (sch->driver && sch->driver->termination)
+				sch->driver->termination(&sch->dev);
 			goto out_unlock;
 		}
 	} else if ((sch->schib.scsw.actl & SCSW_ACTL_DEVACT) &&
 		   (sch->schib.scsw.actl & SCSW_ACTL_SCHACT) &&
 		   (sch->schib.pmcw.lpum == mask)) {
-		struct ccw_device *cdev;
 		int cc;
 
 		cc = cio_clear(sch);
-		if (cc == -ENODEV) {
-			dev_fsm_event(sch->dev.driver_data, DEV_EVENT_NOTOPER);
-			goto out_unlock;
-		}
+		if (cc == -ENODEV)
+			goto out_unreg;
 		/* Call handler. */
-		cdev = sch->dev.driver_data;
-		cdev->private->state = DEV_STATE_CLEAR_VERIFY;
-		if (cdev->handler)
-			cdev->handler(cdev, cdev->private->intparm,
-				      ERR_PTR(-EIO));
+		if (sch->driver && sch->driver->termination)
+			sch->driver->termination(&sch->dev);
 		goto out_unlock;
 	}
 
 	/* trigger path verification. */
-	dev_fsm_event(sch->dev.driver_data, DEV_EVENT_VERIFY);
+	if (sch->driver && sch->driver->verify)
+		sch->driver->verify(&sch->dev);
 out_unlock:
 	spin_unlock(&sch->lock);
+	return 0;
+out_unreg:
+	spin_unlock(&sch->lock);
+	if (sch->driver && sch->driver->notify &&
+	    sch->driver->notify(&sch->dev, CIO_NO_PATH))
+		return 0;
+	device_unregister(&sch->dev);
+	sch->schib.pmcw.intparm = 0;
+	cio_modify(sch);
+	return 0;
 }
 
-/* FIXME: don't iterate all subchannels but use driver_for_each_dev */
 static inline void
 s390_set_chpid_offline( __u8 chpid)
 {
 	char dbf_txt[15];
-	struct subchannel *sch;
-	int irq;
 
 	sprintf(dbf_txt, "chpr%x", chpid);
 	CIO_TRACE_EVENT(2, dbf_txt);
 
-	clear_bit(chpid, chpids);
-	if (!test_and_clear_bit(chpid, chpids_known))
+	if (!get_chp_status(chpid))
 		return;	 /* we didn't know the chpid anyway */
 
-	set_chp_status(chpid, CHP_OFFLINE);
-
-#if 0
-	driver_for_each_dev(io_subchannel_driver, chpid, s390_subchannel_remove_chpid);
-#else
-
-	for (irq = 0; irq <= highest_subchannel; irq++) {
-		sch = ioinfo[irq];
-		if (sch == NULL)
-			continue;  /* we don't know the device anyway */
+	set_chp_online(chpid, 0);
 
-		s390_subchannel_remove_chpid(sch, chpid);
-	}
-#endif
+	bus_for_each_dev(&css_bus_type, NULL, &chpid,
+			 s390_subchannel_remove_chpid);
 }
 
 static int
@@ -353,7 +310,7 @@ s390_process_res_acc_sch(u8 chpid, __u16
 	int ccode;
 	
 	/* Update our ssd_info */
-	if (chsc_get_sch_desc_irq(sch->irq, page))
+	if (chsc_get_sch_desc_irq(sch, page))
 		return 0;
 	
 	found = 0;
@@ -407,7 +364,7 @@ s390_process_res_acc (u8 chpid, __u16 fl
 	 * will we have to do.
 	 */
 
-	if (!test_bit(chpid, chpids_logical))
+	if (get_chp_status(chpid) & CHP_LOGICALLY_OFFLINE)
 		return; /* no need to do the rest */
 
 	page = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
@@ -417,7 +374,7 @@ s390_process_res_acc (u8 chpid, __u16 fl
 	for (irq = 0; irq < __MAX_SUBCHANNELS; irq++) {
 		int chp_mask;
 
-		sch = ioinfo[irq];
+		sch = get_subchannel_by_schid(irq);
 		if (!sch) {
 			/*
 			 * We don't know the device yet, but since a path
@@ -450,17 +407,16 @@ s390_process_res_acc (u8 chpid, __u16 fl
 				continue;
 		}
 
-		sch->lpm = (sch->schib.pmcw.pim &
-			    sch->schib.pmcw.pam &
-			    sch->schib.pmcw.pom)
-			| chp_mask;
-
-		chsc_validate_chpids(sch);
+		sch->lpm = ((sch->schib.pmcw.pim &
+			     sch->schib.pmcw.pam &
+			     sch->schib.pmcw.pom)
+			    | chp_mask) & sch->opm;
 
-		dev_fsm_event(sch->dev.driver_data, DEV_EVENT_VERIFY);
+		if (sch->driver && sch->driver->verify)
+			sch->driver->verify(&sch->dev);
 
 		spin_unlock_irq(&sch->lock);
-
+		put_device(&sch->dev);
 		if (fla_mask != 0)
 			break;
 	}
@@ -497,8 +453,8 @@ __get_chpid_from_lir(void *data)
 	return (u16) (lir->indesc[0]&0x000000ff);
 }
 
-static void
-do_process_crw(void *ignore)
+void
+chsc_process_crw(void)
 {
 	int chpid;
 	struct {
@@ -608,7 +564,7 @@ do_process_crw(void *ignore)
 			if (chps[sei_area->rsid] == NULL)
 				new_channel_path(sei_area->rsid, CHP_ONLINE);
 			else
-				set_chp_status(sei_area->rsid, CHP_ONLINE);
+				set_chp_online(sei_area->rsid, 1);
 			
 			if ((sei_area->vf & 0x80) == 0) {
 				pr_debug("chpid: %x\n", sei_area->rsid);
@@ -639,14 +595,6 @@ out:
 	free_page((unsigned long)sei_area);
 }
 
-void
-chsc_process_crw(void)
-{
-	static DECLARE_WORK(work, do_process_crw, 0);
-
-	queue_work(ccw_device_work, &work);
-}
-
 static void
 chp_add(int chpid)
 {
@@ -654,7 +602,7 @@ chp_add(int chpid)
 	int irq, ret;
 	char dbf_txt[15];
 
-	if (!test_bit(chpid, chpids_logical))
+	if (get_chp_status(chpid) & CHP_LOGICALLY_OFFLINE)
 		return; /* no need to do the rest */
 	
 	sprintf(dbf_txt, "cadd%x", chpid);
@@ -663,7 +611,7 @@ chp_add(int chpid)
 	for (irq = 0; irq < __MAX_SUBCHANNELS; irq++) {
 		int i;
 
-		sch = ioinfo[irq];
+		sch = get_subchannel_by_schid(irq);
 		if (!sch) {
 			ret = css_probe_device(irq);
 			if (ret == -ENXIO)
@@ -686,16 +634,16 @@ chp_add(int chpid)
 			spin_unlock(&sch->lock);
 			return;
 		}
-		sch->lpm = (sch->schib.pmcw.pim &
-			    sch->schib.pmcw.pam &
-			    sch->schib.pmcw.pom)
-			| 0x80 >> i;
-
-		chsc_validate_chpids(sch);
+		sch->lpm = ((sch->schib.pmcw.pim &
+			     sch->schib.pmcw.pam &
+			     sch->schib.pmcw.pom)
+			    | 0x80 >> i) & sch->opm;
 
-		dev_fsm_event(sch->dev.driver_data, DEV_EVENT_VERIFY);
+		if (sch->driver && sch->driver->verify)
+			sch->driver->verify(&sch->dev);
 
 		spin_unlock(&sch->lock);
+		put_device(&sch->dev);
 	}
 }
 
@@ -716,12 +664,80 @@ chp_process_crw(int chpid, int on)
 		if (chps[chpid] == NULL)
 			new_channel_path(chpid, CHP_ONLINE);
 		else
-			set_chp_status(chpid, CHP_ONLINE);
+			set_chp_online(chpid, 1);
 		/* Avoid the extra overhead in process_rec_acc. */
 		chp_add(chpid);
 	}
 }
 
+static inline void
+__check_for_io_and_kill(struct subchannel *sch, int index)
+{
+	int cc;
+
+	cc = stsch(sch->irq, &sch->schib);
+	if (cc)
+		return;
+	if (sch->schib.scsw.actl && sch->schib.pmcw.lpum == (0x80 >> index))
+		device_set_waiting(sch);
+}
+
+static inline void
+__s390_subchannel_vary_chpid(struct subchannel *sch, __u8 chpid, int on)
+{
+	int chp;
+
+	if (!sch->ssd_info.valid)
+		return;
+	
+	for (chp = 0; chp < 8; chp++) {
+		if (sch->ssd_info.chpid[chp] == chpid) {
+			if (on) {
+				sch->opm |= (0x80 >> chp);
+				sch->lpm |= (0x80 >> chp);
+			} else {
+				sch->opm &= ~(0x80 >> chp);
+				sch->lpm &= ~(0x80 >> chp);
+				/*
+				 * Give running I/O a grace period in which it
+				 * can successfully terminate, even using the
+				 * just varied off path. Then kill it.
+				 */
+				__check_for_io_and_kill(sch, chp);
+			}
+			if (sch->driver && sch->driver->verify)
+				sch->driver->verify(&sch->dev);
+			break;
+		}
+	}
+}
+
+static int
+s390_subchannel_vary_chpid_off(struct device *dev, void *data)
+{
+	struct subchannel *sch;
+	__u8 *chpid;
+
+	sch = to_subchannel(dev);
+	chpid = data;
+
+	__s390_subchannel_vary_chpid(sch, *chpid, 0);
+	return 0;
+}
+
+static int
+s390_subchannel_vary_chpid_on(struct device *dev, void *data)
+{
+	struct subchannel *sch;
+	__u8 *chpid;
+
+	sch = to_subchannel(dev);
+	chpid = data;
+
+	__s390_subchannel_vary_chpid(sch, *chpid, 1);
+	return 0;
+}
+
 /*
  * Function: s390_vary_chpid
  * Varies the specified chpid online or offline
@@ -730,66 +746,33 @@ static int
 s390_vary_chpid( __u8 chpid, int on)
 {
 	char dbf_text[15];
-	struct subchannel *sch;
-	int irq;
+	int status;
 
 	sprintf(dbf_text, on?"varyon%x":"varyoff%x", chpid);
 	CIO_TRACE_EVENT( 2, dbf_text);
 
-	chsc_get_sch_descriptions();
-	if (!cio_chsc_desc_avail) {
-		printk(KERN_ERR "Could not get chpid status, "
-		       "vary on/off not available\n");
-		return -EPERM;
-	}
-
-	if (!test_bit(chpid, chpids_known)) {
+	status = get_chp_status(chpid);
+	if (!status) {
 		printk(KERN_ERR "Can't vary unknown chpid %02X\n", chpid);
 		return -EINVAL;
 	}
 
-	if (test_bit(chpid, chpids) == on) {
+	if ((on && !(status & CHP_LOGICALLY_OFFLINE)) ||
+	    (!on && (status & CHP_LOGICALLY_OFFLINE))) {
 		printk(KERN_ERR "chpid %x is "
 		       "already %sline\n", chpid, on ? "on" : "off");
 		return -EINVAL;
 	}
 
-	if (on) {
-		set_bit(chpid, chpids_logical);
-		set_bit(chpid, chpids);
-		set_chp_status(chpid, CHP_ONLINE);
-	} else {
-		clear_bit(chpid, chpids_logical);
-		clear_bit(chpid, chpids);
-		set_chp_status(chpid, CHP_LOGICALLY_OFFLINE);
-	}
+	set_chp_logically_online(chpid, on);
 
 	/*
 	 * Redo PathVerification on the devices the chpid connects to
 	 */
 
-	for (irq = 0; irq <= highest_subchannel; irq++) {
-		int chp;
-		/*
-		 * We don't need to adjust the lpm, as this will be done in
-		 * DevicePathVerification...
-		 */
-		sch = ioinfo[irq];
-		if (sch == NULL || sch->st || !sch->ssd_info.valid)
-			continue;
-
-		for (chp = 0; chp < 8; chp++) {
-			if (sch->ssd_info.chpid[chp] == chpid) {
-				if (on)
-					sch->lpm |= (0x80 >> chp);
-				else
-					sch->lpm &= ~(0x80 >> chp);
-				dev_fsm_event(sch->dev.driver_data,
-					      DEV_EVENT_VERIFY);
-				break;
-			}
-		}
-	}
+	bus_for_each_dev(&css_bus_type, NULL, &chpid, on ?
+			 s390_subchannel_vary_chpid_on :
+			 s390_subchannel_vary_chpid_off);
 	return 0;
 }
 
@@ -800,22 +783,16 @@ static ssize_t
 chp_status_show(struct device *dev, char *buf)
 {
 	struct channel_path *chp = container_of(dev, struct channel_path, dev);
+	int state;
 
 	if (!chp)
 		return 0;
-
-	switch(chp->state) {
-	case CHP_OFFLINE:
+	state = get_chp_status(chp->id);
+	if (state & CHP_STANDBY)
 		return sprintf(buf, "n/a\n");
-	case CHP_LOGICALLY_OFFLINE:
-		return sprintf(buf, "logically offline\n");
-	case CHP_STANDBY:
-		return sprintf(buf, "n/a\n");
-	case CHP_ONLINE:
-		return sprintf(buf, "online\n");
-	default:
-		return 0;
-	}
+	return (state & CHP_LOGICALLY_OFFLINE) ?
+		sprintf(buf, "logically offline\n") :
+		sprintf(buf, "online\n");
 }
 
 static ssize_t
@@ -847,6 +824,10 @@ static DEVICE_ATTR(status, 0644, chp_sta
 static void
 chp_release(struct device *dev)
 {
+	struct channel_path *cp;
+	
+	cp = container_of(dev, struct channel_path, dev);
+	kfree(cp);
 }
 
 /*
@@ -868,7 +849,19 @@ new_channel_path(int chpid, int status)
 
 	/* fill in status, etc. */
 	chp->id = chpid;
-	chp->state = status;
+	switch (status) {
+	case CHP_STANDBY:
+		chp->state.online = 0;
+		chp->state.logically_online = 1;
+		break;
+	case CHP_LOGICALLY_OFFLINE:
+		chp->state.logically_online = 0;
+		chp->state.online = 1;
+		break;
+	case CHP_ONLINE:
+		chp->state.online = 1;
+		chp->state.logically_online = 1;
+	}
 	chp->dev = (struct device) {
 		.parent  = &css_bus_device,
 		.release = chp_release,
@@ -889,32 +882,3 @@ new_channel_path(int chpid, int status)
 	return ret;
 }
 
-static int __init
-register_channel_paths(void)
-{
-	int i;
-	int ret;
-
-	/* walk through the chpids arrays */
-	for (i = 0; i < NR_CHPIDS; i++) {
-		/* we are only interested in known chpids */
-		if (!test_bit(i, chpids_known))
-			continue;
-		if (!test_bit(i, chpids))
-			/* standby */
-			ret = new_channel_path(i, CHP_STANDBY);
-
-		else if (test_bit(i, chpids_logical))
-			/* online */
-			ret = new_channel_path(i, CHP_ONLINE);
-		else
-			/* logically offline */
-			ret = new_channel_path(i, CHP_LOGICALLY_OFFLINE);
-
-		if (ret)
-			return ret;
-	}
-	return 0;
-}
-
-module_init(register_channel_paths);
diff -puN drivers/s390/cio/chsc.h~linus drivers/s390/cio/chsc.h
--- 25/drivers/s390/cio/chsc.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/cio/chsc.h	2004-01-19 22:17:23.000000000 -0800
@@ -3,10 +3,9 @@
 
 #define NR_CHPIDS 256
 
-#define CHP_OFFLINE 0
-#define CHP_LOGICALLY_OFFLINE 1
-#define CHP_STANDBY 2
-#define CHP_ONLINE 3
+#define CHP_STANDBY 1
+#define CHP_LOGICALLY_OFFLINE 2
+#define CHP_ONLINE 4
 
 #define CHSC_SEI_ACC_CHPID        1
 #define CHSC_SEI_ACC_LINKADDR     2
@@ -19,7 +18,10 @@ struct chsc_header {
 
 struct channel_path {
 	int id;
-	int state;
+	struct {
+		unsigned int online:1;
+		unsigned int logically_online:1;
+	}__attribute__((packed)) state;
 	struct device dev;
 };
 
diff -puN drivers/s390/cio/cio.c~linus drivers/s390/cio/cio.c
--- 25/drivers/s390/cio/cio.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/cio/cio.c	2004-01-19 22:17:23.000000000 -0800
@@ -1,7 +1,7 @@
 /*
  *  drivers/s390/cio/cio.c
  *   S/390 common I/O routines -- low level i/o calls
- *   $Revision: 1.105 $
+ *   $Revision: 1.114 $
  *
  *    Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
  *			      IBM Corporation
@@ -147,7 +147,7 @@ cio_tpi(void)
 	if (tsch (tpi_info->irq, irb) != 0)
 		/* Not status pending or not operational. */
 		return 1;
-	sch = ioinfo[tpi_info->irq];
+	sch = (struct subchannel *)(unsigned long)tpi_info->intparm;
 	if (!sch)
 		return 1;
 	irq_enter ();
@@ -184,22 +184,22 @@ cio_start_handle_notoper(struct subchann
 int
 cio_start (struct subchannel *sch,	/* subchannel structure */
 	   struct ccw1 * cpa,		/* logical channel prog addr */
-	   unsigned int intparm,	/* interruption parameter */
 	   __u8 lpm)			/* logical path mask */
 {
 	char dbf_txt[15];
 	int ccode;
 
-	sprintf (dbf_txt, "stIO%x", sch->irq);
-	CIO_TRACE_EVENT (4, dbf_txt);
+	CIO_TRACE_EVENT (4, "stIO");
+	CIO_TRACE_EVENT (4, sch->dev.bus_id);
 
-	sch->orb.intparm = intparm;
+	/* sch is always under 2G. */
+	sch->orb.intparm = (__u32)(unsigned long)sch;
 	sch->orb.fmt = 1;
 
 	sch->orb.pfch = sch->options.prefetch == 0;
 	sch->orb.spnd = sch->options.suspend;
 	sch->orb.ssic = sch->options.suspend && sch->options.inter;
-	sch->orb.lpm = (lpm != 0) ? lpm : sch->lpm;
+	sch->orb.lpm = (lpm != 0) ? (lpm & sch->opm) : sch->lpm;
 #ifdef CONFIG_ARCH_S390X
 	/*
 	 * for 64 bit we always support 64 bit IDAWs with 4k page size only
@@ -240,8 +240,8 @@ cio_resume (struct subchannel *sch)
 	char dbf_txt[15];
 	int ccode;
 
-	sprintf (dbf_txt, "resIO%x", sch->irq);
-	CIO_TRACE_EVENT (4, dbf_txt);
+	CIO_TRACE_EVENT (4, "resIO");
+	CIO_TRACE_EVENT (4, sch->dev.bus_id);
 
 	ccode = rsch (sch->irq);
 
@@ -277,8 +277,8 @@ cio_halt(struct subchannel *sch)
 	if (!sch)
 		return -ENODEV;
 
-	sprintf (dbf_txt, "haltIO%x", sch->irq);
-	CIO_TRACE_EVENT (2, dbf_txt);
+	CIO_TRACE_EVENT (2, "haltIO");
+	CIO_TRACE_EVENT (2, sch->dev.bus_id);
 
 	/*
 	 * Issue "Halt subchannel" and process condition code
@@ -312,8 +312,8 @@ cio_clear(struct subchannel *sch)
 	if (!sch)
 		return -ENODEV;
 
-	sprintf (dbf_txt, "clearIO%x", sch->irq);
-	CIO_TRACE_EVENT (2, dbf_txt);
+	CIO_TRACE_EVENT (2, "clearIO");
+	CIO_TRACE_EVENT (2, sch->dev.bus_id);
 
 	/*
 	 * Issue "Clear subchannel" and process condition code
@@ -348,8 +348,8 @@ cio_cancel (struct subchannel *sch)
 	if (!sch)
 		return -ENODEV;
 
-	sprintf (dbf_txt, "cancelIO%x", sch->irq);
-	CIO_TRACE_EVENT (2, dbf_txt);
+	CIO_TRACE_EVENT (2, "cancelIO");
+	CIO_TRACE_EVENT (2, sch->dev.bus_id);
 
 	ccode = xsch (sch->irq);
 
@@ -374,7 +374,7 @@ cio_cancel (struct subchannel *sch)
  * Function: cio_modify
  * Issues a "Modify Subchannel" on the specified subchannel
  */
-static int
+int
 cio_modify (struct subchannel *sch)
 {
 	int ccode, retry, ret;
@@ -411,8 +411,8 @@ cio_enable_subchannel (struct subchannel
 	int retry;
 	int ret;
 
-	sprintf (dbf_txt, "ensch%x", sch->irq);
-	CIO_TRACE_EVENT (2, dbf_txt);
+	CIO_TRACE_EVENT (2, "ensch");
+	CIO_TRACE_EVENT (2, sch->dev.bus_id);
 
 	ccode = stsch (sch->irq, &sch->schib);
 	if (ccode)
@@ -420,6 +420,7 @@ cio_enable_subchannel (struct subchannel
 
 	sch->schib.pmcw.ena = 1;
 	sch->schib.pmcw.isc = isc;
+	sch->schib.pmcw.intparm = (__u32)(unsigned long)sch;
 	for (retry = 5, ret = 0; retry > 0; retry--) {
 		ret = cio_modify(sch);
 		if (ret == -ENODEV)
@@ -457,8 +458,8 @@ cio_disable_subchannel (struct subchanne
 	int retry;
 	int ret;
 
-	sprintf (dbf_txt, "dissch%x", sch->irq);
-	CIO_TRACE_EVENT (2, dbf_txt);
+	CIO_TRACE_EVENT (2, "dissch");
+	CIO_TRACE_EVENT (2, sch->dev.bus_id);
 
 	ccode = stsch (sch->irq, &sch->schib);
 	if (ccode == 3)		/* Not operational. */
@@ -477,6 +478,13 @@ cio_disable_subchannel (struct subchanne
 		ret = cio_modify(sch);
 		if (ret == -ENODEV)
 			break;
+		if (ret == -EBUSY)
+			/*
+			 * The subchannel is busy or status pending.
+			 * We'll disable when the next interrupt was delivered
+			 * via the state machine.
+			 */
+			break;
 		if (ret == 0) {
 			stsch (sch->irq, &sch->schib);
 			if (!sch->schib.pmcw.ena)
@@ -512,6 +520,11 @@ cio_validate_subchannel (struct subchann
 	/* Nuke all fields. */
 	memset(sch, 0, sizeof(struct subchannel));
 
+	spin_lock_init(&sch->lock);
+
+	/* Set a name for the subchannel */
+	snprintf (sch->dev.bus_id, BUS_ID_SIZE, "0.0.%04x", irq);
+
 	/*
 	 * The first subchannel that is not-operational (ccode==3)
 	 *  indicates that there aren't any more devices available.
@@ -551,12 +564,12 @@ cio_validate_subchannel (struct subchann
 			      "at devno %04X\n", sch->schib.pmcw.dev);
 		return -ENODEV;
 	}
-
+	sch->opm = 0xff;
+	chsc_validate_chpids(sch);
 	sch->lpm = sch->schib.pmcw.pim &
 		sch->schib.pmcw.pam &
-		sch->schib.pmcw.pom;
-
-	chsc_validate_chpids(sch);
+		sch->schib.pmcw.pom &
+		sch->opm;
 
 	CIO_DEBUG(KERN_INFO, 0,
 		  "Detected device %04X on subchannel %s"
@@ -575,7 +588,6 @@ cio_validate_subchannel (struct subchann
 	sch->schib.pmcw.isc = 3;	/* could be smth. else */
 	sch->schib.pmcw.csense = 1;	/* concurrent sense */
 	sch->schib.pmcw.ena = 0;
-	sch->schib.pmcw.intparm = sch->schib.pmcw.dev;
 	if ((sch->lpm & (sch->lpm - 1)) != 0)
 		sch->schib.pmcw.mp = 1;	/* multipath mode */
 	return 0;
@@ -612,7 +624,7 @@ do_IRQ (struct pt_regs *regs)
 			do_adapter_IO();
 			continue;
 		}
-		sch = ioinfo[tpi_info->irq];
+		sch = (struct subchannel *)(unsigned long)tpi_info->intparm;
 		if (sch)
 			spin_lock(&sch->lock);
 		/* Store interrupt response block to lowcore. */
@@ -733,16 +745,40 @@ cio_probe_console(void)
 	 */
 	ctl_set_bit(6, 24);
 	console_subchannel.schib.pmcw.isc = 7;
-	ioinfo[irq] = &console_subchannel;
+	console_subchannel.schib.pmcw.intparm =
+		(__u32)(unsigned long)&console_subchannel;
+	ret = cio_modify(&console_subchannel);
+	if (ret) {
+		console_subchannel_in_use = 0;
+		return ERR_PTR(ret);
+	}
 	return &console_subchannel;
 }
 
 void
 cio_release_console(void)
 {
-	ioinfo[console_subchannel.irq] = NULL;
+	console_subchannel.schib.pmcw.intparm = 0;
+	cio_modify(&console_subchannel);
 	ctl_clear_bit(6, 24);
 	console_subchannel_in_use = 0;
 }
 
+/* Bah... hack to catch console special sausages. */
+int
+cio_is_console(int irq)
+{
+	if (!console_subchannel_in_use)
+		return 0;
+	return (irq == console_subchannel.irq);
+}
+
+struct subchannel *
+cio_get_console_subchannel(void)
+{
+	if (!console_subchannel_in_use)
+		return 0;
+	return &console_subchannel;
+}
+
 #endif
diff -puN drivers/s390/cio/cio.h~linus drivers/s390/cio/cio.h
--- 25/drivers/s390/cio/cio.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/cio/cio.h	2004-01-19 22:17:23.000000000 -0800
@@ -98,6 +98,7 @@ struct subchannel {
 
 	__u8 vpm;		/* verified path mask */
 	__u8 lpm;		/* logical path mask */
+	__u8 opm;               /* operational path mask */
 	struct schib schib;	/* subchannel information block */
 	struct orb orb;		/* operation request block */
 	struct ccw1 sense_ccw;	/* static ccw for sense command */
@@ -117,14 +118,16 @@ extern int cio_cancel (struct subchannel
 extern int cio_clear (struct subchannel *);
 extern int cio_resume (struct subchannel *);
 extern int cio_halt (struct subchannel *);
-extern int cio_start (struct subchannel *, struct ccw1 *, unsigned int, __u8);
+extern int cio_start (struct subchannel *, struct ccw1 *, __u8);
 extern int cio_cancel (struct subchannel *);
 extern int cio_set_options (struct subchannel *, int);
 extern int cio_get_options (struct subchannel *);
-
+extern int cio_modify (struct subchannel *);
 /* Use with care. */
 extern struct subchannel *cio_probe_console(void);
 extern void cio_release_console(void);
+extern int cio_is_console(int irq);
+extern struct subchannel *cio_get_console_subchannel(void);
 
 extern int cio_show_msg;
 
diff -puN drivers/s390/cio/css.c~linus drivers/s390/cio/css.c
--- 25/drivers/s390/cio/css.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/cio/css.c	2004-01-19 22:17:23.000000000 -0800
@@ -1,7 +1,7 @@
 /*
  *  drivers/s390/cio/css.c
  *  driver for channel subsystem
- *   $Revision: 1.49 $
+ *   $Revision: 1.65 $
  *
  *    Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
  *			 IBM Corporation
@@ -14,15 +14,11 @@
 #include <linux/slab.h>
 #include <linux/errno.h>
 
-#include <asm/ccwdev.h> // FIXME: layering violation, remove this
-
 #include "css.h"
 #include "cio.h"
 #include "cio_debug.h"
-#include "device.h" // FIXME: dito
 #include "ioasm.h"
 
-struct subchannel *ioinfo[__MAX_SUBCHANNELS];
 unsigned int highest_subchannel;
 int css_init_done = 0;
 
@@ -30,23 +26,19 @@ struct device css_bus_device = {
 	.bus_id = "css0",
 };
 
-static int
+static struct subchannel *
 css_alloc_subchannel(int irq)
 {
 	struct subchannel *sch;
 	int ret;
 
-	if (ioinfo[irq])
-		/* There already is a struct subchannel for this irq. */
-		return -EBUSY;
-
 	sch = kmalloc (sizeof (*sch), GFP_KERNEL | GFP_DMA);
 	if (sch == NULL)
-		return -ENOMEM;
+		return ERR_PTR(-ENOMEM);
 	ret = cio_validate_subchannel (sch, irq);
 	if (ret < 0) {
 		kfree(sch);
-		return ret;
+		return ERR_PTR(ret);
 	}
 	if (irq > highest_subchannel)
 		highest_subchannel = irq;
@@ -54,27 +46,47 @@ css_alloc_subchannel(int irq)
 	if (sch->st != SUBCHANNEL_TYPE_IO) {
 		/* For now we ignore all non-io subchannels. */
 		kfree(sch);
-		return -EINVAL;
+		return ERR_PTR(-EINVAL);
 	}
 
-	ioinfo[irq] = sch;
-
-	return 0;
+	/* 
+	 * Set intparm to subchannel address.
+	 * This is fine even on 64bit since the subchannel is always located
+	 * under 2G.
+	 */
+	sch->schib.pmcw.intparm = (__u32)(unsigned long)sch;
+	ret = cio_modify(sch);
+	if (ret) {
+		kfree(sch);
+		return ERR_PTR(ret);
+	}
+	return sch;
 }
 
 static void
-css_free_subchannel(int irq)
+css_free_subchannel(struct subchannel *sch)
 {
-	struct subchannel *sch;
-
-	sch = ioinfo[irq];
 	if (sch) {
-		ioinfo[irq] = NULL;
+		/* Reset intparm to zeroes. */
+		sch->schib.pmcw.intparm = 0;
+		cio_modify(sch);
 		kfree(sch);
 	}
 	
 }
 
+static void
+css_subchannel_release(struct device *dev)
+{
+	struct subchannel *sch;
+
+	sch = to_subchannel(dev);
+	if (!cio_is_console(sch->irq))
+		kfree(sch);
+}
+
+extern int css_get_ssd_info(struct subchannel *sch);
+
 static int
 css_register_subchannel(struct subchannel *sch)
 {
@@ -83,15 +95,15 @@ css_register_subchannel(struct subchanne
 	/* Initialize the subchannel structure */
 	sch->dev.parent = &css_bus_device;
 	sch->dev.bus = &css_bus_type;
-
-	/* Set a name for the subchannel */
-	snprintf (sch->dev.bus_id, BUS_ID_SIZE, "0.0.%04x", sch->irq);
-
+	sch->dev.release = &css_subchannel_release;
+	
 	/* make it known to the system */
 	ret = device_register(&sch->dev);
 	if (ret)
 		printk (KERN_WARNING "%s: could not register %s\n",
 			__func__, sch->dev.bus_id);
+	else
+		css_get_ssd_info(sch);
 	return ret;
 }
 
@@ -99,28 +111,159 @@ int
 css_probe_device(int irq)
 {
 	int ret;
+	struct subchannel *sch;
 
-	ret = css_alloc_subchannel(irq);
-	if (ret)
-		return ret;
-	ret = css_register_subchannel(ioinfo[irq]);
+	sch = css_alloc_subchannel(irq);
+	if (IS_ERR(sch))
+		return PTR_ERR(sch);
+	ret = css_register_subchannel(sch);
 	if (ret)
-		css_free_subchannel(irq);
+		css_free_subchannel(sch);
+	return ret;
+}
+
+static struct subchannel *
+__get_subchannel_by_stsch(int irq)
+{
+	struct subchannel *sch;
+	int cc;
+	struct schib schib;
+
+	cc = stsch(irq, &schib);
+	if (cc)
+		return NULL;
+	sch = (struct subchannel *)(unsigned long)schib.pmcw.intparm;
+	if (!sch)
+		return NULL;
+	if (get_device(&sch->dev))
+		return sch;
+	return NULL;
+}
+
+struct subchannel *
+get_subchannel_by_schid(int irq)
+{
+	struct subchannel *sch;
+	struct list_head *entry;
+	struct device *dev;
+
+	if (!get_bus(&css_bus_type))
+		return NULL;
+
+	/* Try to get subchannel from pmcw first. */ 
+	sch = __get_subchannel_by_stsch(irq);
+	if (sch)
+		goto out;
+	if (!get_driver(&io_subchannel_driver.drv))
+		goto out;
+	down_read(&css_bus_type.subsys.rwsem);
+
+	list_for_each(entry, &io_subchannel_driver.drv.devices) {
+		dev = get_device(container_of(entry,
+					      struct device, driver_list));
+		if (!dev)
+			continue;
+		sch = to_subchannel(dev);
+		if (sch->irq == irq)
+			break;
+		put_device(dev);
+		sch = NULL;
+	}
+	up_read(&css_bus_type.subsys.rwsem);
+	put_driver(&io_subchannel_driver.drv);
+out:
+	put_bus(&css_bus_type);
+
+	return sch;
+}
+
+static inline int
+css_get_subchannel_status(struct subchannel *sch, int schid)
+{
+	struct schib schib;
+	int cc;
+
+	cc = stsch(schid, &schib);
+	if (cc)
+		return CIO_GONE;
+	if (!schib.pmcw.dnv)
+		return CIO_GONE;
+	if (sch && (schib.pmcw.dev != sch->schib.pmcw.dev))
+		return CIO_REVALIDATE;
+	return CIO_OPER;
+}
+	
+static inline int
+css_evaluate_subchannel(int irq)
+{
+	int event, ret, disc;
+	struct subchannel *sch;
+
+	sch = get_subchannel_by_schid(irq);
+	disc = sch ? device_is_disconnected(sch) : 0;
+	event = css_get_subchannel_status(sch, irq);
+	switch (event) {
+	case CIO_GONE:
+		if (!sch) {
+			/* Never used this subchannel. Ignore. */
+			ret = 0;
+			break;
+		}
+		if (sch->driver && sch->driver->notify &&
+		    sch->driver->notify(&sch->dev, CIO_GONE)) {
+			device_set_disconnected(sch);
+			ret = 0;
+			break;
+		}
+		/*
+		 * Unregister subchannel.
+		 * The device will be killed automatically.
+		 */
+		device_unregister(&sch->dev);
+		/* Reset intparm to zeroes. */
+		sch->schib.pmcw.intparm = 0;
+		cio_modify(sch);
+		put_device(&sch->dev);
+		ret = 0;
+		break;
+	case CIO_REVALIDATE:
+		/* 
+		 * Revalidation machine check. Sick.
+		 * We don't notify the driver since we have to throw the device
+		 * away in any case.
+		 */
+		device_unregister(&sch->dev);
+		/* Reset intparm to zeroes. */
+		sch->schib.pmcw.intparm = 0;
+		cio_modify(sch);
+		put_device(&sch->dev);
+		ret = css_probe_device(irq);
+		break;
+	case CIO_OPER:
+		if (disc)
+			/* Get device operational again. */
+			device_trigger_reprobe(sch);
+		ret = sch ? 0 : css_probe_device(irq);
+		break;
+	default:
+		BUG();
+		ret = 0;
+	}
 	return ret;
 }
 
 /*
  * Rescan for new devices. FIXME: This is slow.
+ * This function is called when we have lost CRWs due to overflows and we have
+ * to do subchannel housekeeping.
  */
-static void
-do_process_crw(void *ignore)
+void
+css_reiterate_subchannels(void)
 {
 	int irq, ret;
 
-	for (irq = 0; irq < __MAX_SUBCHANNELS; irq++) {
-		if (ioinfo[irq])
-			continue;
-		ret = css_probe_device(irq);
+	for (irq = 0; irq <= __MAX_SUBCHANNELS; irq++) {
+		ret = css_evaluate_subchannel(irq);
 		/* No more memory. It doesn't make sense to continue. No
 		 * panic because this can happen in midflight and just
 		 * because we can't use a new device is no reason to crash
@@ -135,39 +278,25 @@ do_process_crw(void *ignore)
 
 /*
  * Called from the machine check handler for subchannel report words.
- * Note: this is called disabled from the machine check handler itself.
  */
 void
 css_process_crw(int irq)
 {
-	static DECLARE_WORK(work, do_process_crw, 0);
-	struct subchannel *sch;
-	int ccode, devno;
-
 	CIO_CRW_EVENT(2, "source is subchannel %04X\n", irq);
 
-	sch = ioinfo[irq];
-	if (sch == NULL) {
-		queue_work(ccw_device_work, &work);
-		return;
-	}
-	if (!sch->dev.driver_data)
-		return;
-	devno = sch->schib.pmcw.dev;
-	/* FIXME: css_process_crw must not know about ccw_device */
-	dev_fsm_event(sch->dev.driver_data, DEV_EVENT_NOTOPER);
-	ccode = stsch(irq, &sch->schib);
-	if (!ccode)
-		if (devno != sch->schib.pmcw.dev)
-			queue_work(ccw_device_work, &work);
+	/* 
+	 * Since we are always presented with IPI in the CRW, we have to
+	 * use stsch() to find out if the subchannel in question has come
+	 * or gone.
+	 */
+	css_evaluate_subchannel(irq);
 }
 
 /*
  * some of the initialization has already been done from init_IRQ(),
  * here we do the rest now that the driver core is running.
- * Currently, this functions scans all the subchannel structures for
- * devices. The long term plan is to remove ioinfo[] and then the
- * struct subchannel's will be created during probing. 
+ * The struct subchannel's are created during probing (except for the
+ * static console subchannel).
  */
 static int __init
 init_channel_subsystem (void)
@@ -184,8 +313,16 @@ init_channel_subsystem (void)
 	ctl_set_bit(6, 28);
 
 	for (irq = 0; irq < __MAX_SUBCHANNELS; irq++) {
-		if (!ioinfo[irq]) {
-			ret = css_alloc_subchannel(irq);
+		struct subchannel *sch;
+
+		if (cio_is_console(irq))
+			sch = cio_get_console_subchannel();
+		else {
+			sch = css_alloc_subchannel(irq);
+			if (IS_ERR(sch))
+				ret = PTR_ERR(sch);
+			else
+				ret = 0;
 			if (ret == -ENOMEM)
 				panic("Out of memory in "
 				      "init_channel_subsystem\n");
@@ -202,7 +339,7 @@ init_channel_subsystem (void)
 		 * not working) so we do it now. This is true e.g. for the
 		 * console subchannel.
 		 */
-		css_register_subchannel(ioinfo[irq]);
+		css_register_subchannel(sch);
 	}
 	return 0;
 
@@ -236,6 +373,46 @@ struct bus_type css_bus_type = {
 
 subsys_initcall(init_channel_subsystem);
 
+/*
+ * Register root devices for some drivers. The release function must not be
+ * in the device drivers, so we do it here.
+ */
+static void
+s390_root_dev_release(struct device *dev)
+{
+	kfree(dev);
+}
+
+struct device *
+s390_root_dev_register(const char *name)
+{
+	struct device *dev;
+	int ret;
+
+	if (!strlen(name))
+		return ERR_PTR(-EINVAL);
+	dev = kmalloc(sizeof(struct device), GFP_KERNEL);
+	if (!dev)
+		return ERR_PTR(-ENOMEM);
+	memset(dev, 0, sizeof(struct device));
+	strncpy(dev->bus_id, name, min(strlen(name), (size_t)BUS_ID_SIZE));
+	dev->release = s390_root_dev_release;
+	ret = device_register(dev);
+	if (ret) {
+		kfree(dev);
+		return ERR_PTR(ret);
+	}
+	return dev;
+}
+
+void
+s390_root_dev_unregister(struct device *dev)
+{
+	if (dev)
+		device_unregister(dev);
+}
+
 MODULE_LICENSE("GPL");
 EXPORT_SYMBOL(css_bus_type);
-
+EXPORT_SYMBOL(s390_root_dev_register);
+EXPORT_SYMBOL(s390_root_dev_unregister);
diff -puN drivers/s390/cio/css.h~linus drivers/s390/cio/css.h
--- 25/drivers/s390/cio/css.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/cio/css.h	2004-01-19 22:17:23.000000000 -0800
@@ -79,6 +79,7 @@ struct ccw_device_private {
 		unsigned int esid:1;        /* Ext. SenseID supported by HW */
 		unsigned int dosense:1;	    /* delayed SENSE required */
 		unsigned int doverify:1;    /* delayed path verification */
+		unsigned int donotify:1;    /* call notify function */
 	} __attribute__((packed)) flags;
 	unsigned long intparm;	/* user interruption parameter */
 	struct qdio_irq *qdio_data;
@@ -100,22 +101,32 @@ struct css_driver {
 	unsigned int subchannel_type;
 	struct device_driver drv;
 	void (*irq)(struct device *);
+	int (*notify)(struct device *, int);
+	void (*verify)(struct device *);
+	void (*termination)(struct device *);
 };
 
 /*
  * all css_drivers have the css_bus_type
  */
 extern struct bus_type css_bus_type;
+extern struct css_driver io_subchannel_driver;
 
 int css_probe_device(int irq);
-
+extern struct subchannel * get_subchannel_by_schid(int irq);
 extern unsigned int highest_subchannel;
 extern int css_init_done;
 
 #define __MAX_SUBCHANNELS 65536
-extern struct subchannel *ioinfo[__MAX_SUBCHANNELS];
 
 extern struct bus_type css_bus_type;
 extern struct device css_bus_device;
 
+/* Some helper functions for disconnected state. */
+int device_is_disconnected(struct subchannel *);
+void device_set_disconnected(struct subchannel *);
+void device_trigger_reprobe(struct subchannel *);
+
+/* Helper function for vary on/off. */
+void device_set_waiting(struct subchannel *);
 #endif
diff -puN drivers/s390/cio/device.c~linus drivers/s390/cio/device.c
--- 25/drivers/s390/cio/device.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/cio/device.c	2004-01-19 22:17:23.000000000 -0800
@@ -1,7 +1,7 @@
 /*
  *  drivers/s390/cio/device.c
  *  bus driver for ccw devices
- *   $Revision: 1.70 $
+ *   $Revision: 1.85 $
  *
  *    Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
  *			 IBM Corporation
@@ -115,16 +115,24 @@ struct bus_type ccw_bus_type = {
 };
 
 static int io_subchannel_probe (struct device *);
+static int io_subchannel_remove (struct device *);
 void io_subchannel_irq (struct device *);
+static int io_subchannel_notify(struct device *, int);
+static void io_subchannel_verify(struct device *);
+static void io_subchannel_ioterm(struct device *);
 
-static struct css_driver io_subchannel_driver = {
+struct css_driver io_subchannel_driver = {
 	.subchannel_type = SUBCHANNEL_TYPE_IO,
 	.drv = {
 		.name = "io_subchannel",
 		.bus  = &css_bus_type,
 		.probe = &io_subchannel_probe,
+		.remove = &io_subchannel_remove,
 	},
 	.irq = io_subchannel_irq,
+	.notify = io_subchannel_notify,
+	.verify = io_subchannel_verify,
+	.termination = io_subchannel_ioterm,
 };
 
 struct workqueue_struct *ccw_device_work;
@@ -232,41 +240,58 @@ online_show (struct device *dev, char *b
 	return sprintf(buf, cdev->online ? "1\n" : "0\n");
 }
 
-void
+int
 ccw_device_set_offline(struct ccw_device *cdev)
 {
 	int ret;
 
 	if (!cdev)
-		return;
+		return -ENODEV;
 	if (!cdev->online || !cdev->drv)
-		return;
-
-	if (cdev->drv->set_offline)
-		if (cdev->drv->set_offline(cdev) != 0)
-			return;
+		return -EINVAL;
 
+	if (cdev->private->state == DEV_STATE_DISCONNECTED) {
+		struct subchannel *sch;
+		/* 
+		 * Forced offline in disconnected state means 
+		 * 'throw away device'.
+		 */
+		sch = to_subchannel(cdev->dev.parent);
+		device_unregister(&sch->dev);
+		/* Reset intparm to zeroes. */
+		sch->schib.pmcw.intparm = 0;
+		cio_modify(sch);
+		put_device(&sch->dev);
+		return 0;
+	}
+	if (cdev->drv->set_offline) {
+		ret = cdev->drv->set_offline(cdev);
+		if (ret != 0)
+			return ret;
+	}
 	cdev->online = 0;
 	spin_lock_irq(cdev->ccwlock);
 	ret = ccw_device_offline(cdev);
 	spin_unlock_irq(cdev->ccwlock);
 	if (ret == 0)
 		wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev));
-	else
-		//FIXME: we can't fail!
+	else {
 		pr_debug("ccw_device_offline returned %d, device %s\n",
 			 ret, cdev->dev.bus_id);
+		cdev->online = 1;
+	}
+	return ret;
 }
 
-void
+int
 ccw_device_set_online(struct ccw_device *cdev)
 {
 	int ret;
 
 	if (!cdev)
-		return;
+		return -ENODEV;
 	if (cdev->online || !cdev->drv)
-		return;
+		return -EINVAL;
 
 	spin_lock_irq(cdev->ccwlock);
 	ret = ccw_device_online(cdev);
@@ -276,13 +301,13 @@ ccw_device_set_online(struct ccw_device 
 	else {
 		pr_debug("ccw_device_online returned %d, device %s\n",
 			 ret, cdev->dev.bus_id);
-		return;
+		return ret;
 	}
 	if (cdev->private->state != DEV_STATE_ONLINE)
-		return;
+		return -ENODEV;
 	if (!cdev->drv->set_online || cdev->drv->set_online(cdev) == 0) {
 		cdev->online = 1;
-		return;
+		return 0;
 	}
 	spin_lock_irq(cdev->ccwlock);
 	ret = ccw_device_offline(cdev);
@@ -292,6 +317,7 @@ ccw_device_set_online(struct ccw_device 
 	else 
 		pr_debug("ccw_device_offline returned %d, device %s\n",
 			 ret, cdev->dev.bus_id);
+	return (ret = 0) ? -ENODEV : ret;
 }
 
 static ssize_t
@@ -340,7 +366,7 @@ stlck_store(struct device *dev, const ch
 		  ccw_device_unbox_recog, (void *) cdev);
 	queue_work(ccw_device_work, &cdev->private->kick_work);
 	
-	return 0;
+	return count;
 }
 
 static DEVICE_ATTR(chpids, 0444, chpids_show, NULL);
@@ -430,7 +456,7 @@ ccw_device_add_stlck(void *data)
 
 /* this is a simple abstraction for device_register that sets the
  * correct bus type and adds the bus specific files */
-static int
+int
 ccw_device_register(struct ccw_device *cdev)
 {
 	struct device *dev = &cdev->dev;
@@ -448,16 +474,20 @@ ccw_device_register(struct ccw_device *c
 }
 
 void
-ccw_device_unregister(void *data)
+ccw_device_do_unreg_rereg(void *data)
 {
 	struct device *dev;
 
 	dev = (struct device *)data;
-
 	device_remove_files(dev);
-	device_unregister(dev);
+	device_del(dev);
+	if (device_add(dev)) {
+		put_device(dev);
+		return;
+	}
+	if (device_add_files(dev))
+		device_unregister(dev);
 }
-	
 
 static void
 ccw_device_release(struct device *dev)
@@ -482,6 +512,10 @@ io_subchannel_register(void *data)
 	cdev = (struct ccw_device *) data;
 	sch = to_subchannel(cdev->dev.parent);
 
+	if (!list_empty(&sch->dev.children)) {
+		bus_rescan_devices(&ccw_bus_type);
+		goto out;
+	}
 	/* make it known to the system */
 	ret = ccw_device_register(cdev);
 	if (ret) {
@@ -495,8 +529,8 @@ io_subchannel_register(void *data)
 
 	ret = subchannel_add_files(cdev->dev.parent);
 	if (ret)
-		printk(KERN_WARNING "%s: could not add attributes to %04x\n",
-		       __func__, sch->irq);
+		printk(KERN_WARNING "%s: could not add attributes to %s\n",
+		       __func__, sch->dev.bus_id);
 	if (cdev->private->state == DEV_STATE_BOXED)
 		device_create_file(&cdev->dev, &dev_attr_steal_lock);
 out:
@@ -562,9 +596,9 @@ io_subchannel_recog(struct ccw_device *c
 	atomic_inc(&ccw_device_init_count);
 
 	/* Start async. device sensing. */
-	spin_lock_irq(cdev->ccwlock);
+	spin_lock_irq(&sch->lock);
 	rc = ccw_device_recognition(cdev);
-	spin_unlock_irq(cdev->ccwlock);
+	spin_unlock_irq(&sch->lock);
 	if (rc) {
 		if (atomic_dec_and_test(&ccw_device_init_count))
 			wake_up(&ccw_device_init_wq);
@@ -637,6 +671,60 @@ io_subchannel_probe (struct device *pdev
 	return 0;
 }
 
+static int
+io_subchannel_remove (struct device *dev)
+{
+	struct ccw_device *cdev;
+
+	if (!dev->driver_data)
+		return 0;
+	cdev = dev->driver_data;
+	/* Set ccw device to not operational and drop reference. */
+	dev_fsm_event(cdev, DEV_EVENT_NOTOPER);
+	put_device(&cdev->dev);
+	dev->driver_data = NULL;
+	return 0;
+}
+
+static int
+io_subchannel_notify(struct device *dev, int event)
+{
+	struct ccw_device *cdev;
+
+	cdev = dev->driver_data;
+	if (!cdev)
+		return 0;
+	if (!cdev->drv)
+		return 0;
+	if (!cdev->online)
+		return 0;
+	return cdev->drv->notify ? cdev->drv->notify(cdev, event) : 0;
+}
+
+static void
+io_subchannel_verify(struct device *dev)
+{
+	struct ccw_device *cdev;
+
+	cdev = dev->driver_data;
+	if (cdev)
+		dev_fsm_event(cdev, DEV_EVENT_VERIFY);
+}
+
+static void
+io_subchannel_ioterm(struct device *dev)
+{
+	struct ccw_device *cdev;
+
+	cdev = dev->driver_data;
+	if (!cdev)
+		return;
+	cdev->private->state = DEV_STATE_CLEAR_VERIFY;
+	if (cdev->handler)
+		cdev->handler(cdev, cdev->private->intparm,
+			      ERR_PTR(-EIO));
+}
+
 #ifdef CONFIG_CCW_CONSOLE
 static struct ccw_device console_cdev;
 static struct ccw_device_private console_private;
@@ -652,25 +740,28 @@ ccw_device_console_enable (struct ccw_de
 		.parent = &sch->dev,
 	};
 	/* Initialize the subchannel structure */
-	sch->dev = (struct device) {
-		.parent = &css_bus_device,
-		.bus	= &css_bus_type,
-	};
+	sch->dev.parent = &css_bus_device;
+	sch->dev.bus = &css_bus_type;
 
 	rc = io_subchannel_recog(cdev, sch);
 	if (rc)
 		return rc;
 
 	/* Now wait for the async. recognition to come to an end. */
+	spin_lock_irq(cdev->ccwlock);
 	while (!dev_fsm_final_state(cdev))
 		wait_cons_dev();
+	rc = -EIO;
 	if (cdev->private->state != DEV_STATE_OFFLINE)
-		return -EIO;
+		goto out_unlock;
 	ccw_device_online(cdev);
 	while (!dev_fsm_final_state(cdev))
 		wait_cons_dev();
 	if (cdev->private->state != DEV_STATE_ONLINE)
-		return -EIO;
+		goto out_unlock;
+	rc = 0;
+out_unlock:
+	spin_unlock_irq(cdev->ccwlock);
 	return 0;
 }
 
@@ -767,18 +858,28 @@ ccw_device_remove (struct device *dev)
 {
 	struct ccw_device *cdev = to_ccwdev(dev);
 	struct ccw_driver *cdrv = cdev->drv;
+	int ret;
 
-	/*
-	 * Set device offline, so device drivers don't end up with
-	 * doubled code.
-	 * This is safe because of the checks in ccw_device_set_offline.
-	 */
 	pr_debug("removing device %s, sch %d, devno %x\n",
-		 cdev->dev.name,
+		 cdev->dev.bus_id,
 		 cdev->private->irq,
 		 cdev->private->devno);
-	ccw_device_set_offline(cdev);
-	return cdrv->remove ? cdrv->remove(cdev) : 0;
+	if (cdrv->remove)
+		cdrv->remove(cdev);
+	if (cdev->online) {
+		cdev->online = 0;
+		spin_lock_irq(cdev->ccwlock);
+		ret = ccw_device_offline(cdev);
+		spin_unlock_irq(cdev->ccwlock);
+		if (ret == 0)
+			wait_event(cdev->private->wait_q,
+				   dev_fsm_final_state(cdev));
+		else
+			//FIXME: we can't fail!
+			pr_debug("ccw_device_offline returned %d, device %s\n",
+				 ret, cdev->dev.bus_id);
+	}
+	return 0;
 }
 
 int
diff -puN drivers/s390/cio/device_fsm.c~linus drivers/s390/cio/device_fsm.c
--- 25/drivers/s390/cio/device_fsm.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/cio/device_fsm.c	2004-01-19 22:17:23.000000000 -0800
@@ -19,8 +19,44 @@
 #include "cio_debug.h"
 #include "css.h"
 #include "device.h"
+#include "ioasm.h"
 #include "qdio.h"
 
+int
+device_is_disconnected(struct subchannel *sch)
+{
+	struct ccw_device *cdev;
+
+	if (!sch->dev.driver_data)
+		return 0;
+	cdev = sch->dev.driver_data;
+	return (cdev->private->state == DEV_STATE_DISCONNECTED ||
+		cdev->private->state == DEV_STATE_DISCONNECTED_SENSE_ID);
+}
+
+void
+device_set_disconnected(struct subchannel *sch)
+{
+	struct ccw_device *cdev;
+
+	if (!sch->dev.driver_data)
+		return;
+	cdev = sch->dev.driver_data;
+	cdev->private->state = DEV_STATE_DISCONNECTED;
+}
+
+void
+device_set_waiting(struct subchannel *sch)
+{
+	struct ccw_device *cdev;
+
+	if (!sch->dev.driver_data)
+		return;
+	cdev = sch->dev.driver_data;
+	ccw_device_set_timeout(cdev, 10*HZ);
+	cdev->private->state = DEV_STATE_WAIT4IO;
+}
+
 /*
  * Timeout function. It just triggers a DEV_EVENT_TIMEOUT.
  */
@@ -60,39 +96,76 @@ ccw_device_set_timeout(struct ccw_device
  * Cancel running i/o. This is called repeatedly since halt/clear are
  * asynchronous operations. We do one try with cio_cancel, two tries
  * with cio_halt, 255 tries with cio_clear. If everythings fails panic.
+ * Returns 0 if device now idle, -ENODEV for device not operational and
+ * -EBUSY if an interrupt is expected (either from halt/clear or from a
+ * status pending).
  */
 static int
 ccw_device_cancel_halt_clear(struct ccw_device *cdev)
 {
 	struct subchannel *sch;
+	int ret;
 
 	sch = to_subchannel(cdev->dev.parent);
-	if (sch->schib.scsw.actl == 0)
+	ret = stsch(sch->irq, &sch->schib);
+	if (ret || !sch->schib.pmcw.dnv)
+		return -ENODEV; 
+	if (!sch->schib.pmcw.ena || sch->schib.scsw.actl == 0)
 		/* Not operational or no activity -> done. */
 		return 0;
 	/* Stage 1: cancel io. */
 	if (!(sch->schib.scsw.actl & SCSW_ACTL_HALT_PEND) &&
 	    !(sch->schib.scsw.actl & SCSW_ACTL_CLEAR_PEND)) {
-		if (cio_cancel (sch) == 0)
-			return 0;
+		ret = cio_cancel(sch);
+		if (ret != -EINVAL)
+			return ret;
 		/* cancel io unsuccessful. From now on it is asynchronous. */
 		cdev->private->iretry = 3;	/* 3 halt retries. */
 	}
 	if (!(sch->schib.scsw.actl & SCSW_ACTL_CLEAR_PEND)) {
 		/* Stage 2: halt io. */
-		while (cdev->private->iretry-- > 0)
-			if (cio_halt (sch) == 0)
-				return -EBUSY;
+		if (cdev->private->iretry) {
+			cdev->private->iretry--;
+			ret = cio_halt(sch);
+			return (ret == 0) ? -EBUSY : ret;
+		}
 		/* halt io unsuccessful. */
 		cdev->private->iretry = 255;	/* 255 clear retries. */
 	}
 	/* Stage 3: clear io. */
-	while (cdev->private->iretry-- > 0)
-		if (cio_clear (sch) == 0)
-			return -EBUSY;
+	if (cdev->private->iretry) {
+		cdev->private->iretry--;
+		ret = cio_clear (sch);
+		return (ret == 0) ? -EBUSY : ret;
+	}
 	panic("Can't stop i/o on subchannel.\n");
 }
 
+static void
+ccw_device_handle_oper(struct ccw_device *cdev)
+{
+	struct subchannel *sch;
+
+	sch = to_subchannel(cdev->dev.parent);
+	/*
+	 * Check if cu type and device type still match. If
+	 * not, it is certainly another device and we have to
+	 * de- and re-register.
+	 */
+	if (cdev->id.cu_type != cdev->private->senseid.cu_type ||
+	    cdev->id.cu_model != cdev->private->senseid.cu_model ||
+	    cdev->id.dev_type != cdev->private->senseid.dev_type ||
+	    cdev->id.dev_model != cdev->private->senseid.dev_model) {
+		PREPARE_WORK(&cdev->private->kick_work,
+			     ccw_device_do_unreg_rereg, (void *)&cdev->dev);
+		queue_work(ccw_device_work, &cdev->private->kick_work);
+		return;
+	}
+	cdev->private->flags.donotify = 1;
+	/* Get device online again. */
+	ccw_device_online(cdev);
+}
+
 /*
  * Stop device recognition.
  */
@@ -100,41 +173,54 @@ static void
 ccw_device_recog_done(struct ccw_device *cdev, int state)
 {
 	struct subchannel *sch;
+	int notify;
 
 	sch = to_subchannel(cdev->dev.parent);
 
 	ccw_device_set_timeout(cdev, 0);
 	cio_disable_subchannel(sch);
-	cdev->private->state = state;
-
+	if (cdev->private->state == DEV_STATE_DISCONNECTED_SENSE_ID) {
+		if (state == DEV_STATE_NOT_OPER) {
+			cdev->private->state = DEV_STATE_DISCONNECTED;
+			return;
+		}
+		/* Boxed devices don't need extra treatment. */
+	}
+	notify = 0;
 	switch (state) {
 	case DEV_STATE_NOT_OPER:
 		CIO_DEBUG(KERN_WARNING, 2,
-			  "SenseID : unknown device %04X on subchannel %04X\n",
-			  sch->schib.pmcw.dev, sch->irq);
+			  "SenseID : unknown device %s on subchannel %s\n",
+			  cdev->dev.bus_id, sch->dev.bus_id);
 		break;
 	case DEV_STATE_OFFLINE:
-		/* fill out sense information */
-		cdev->id = (struct ccw_device_id) {
-			.cu_type   = cdev->private->senseid.cu_type,
-			.cu_model  = cdev->private->senseid.cu_model,
-			.dev_type  = cdev->private->senseid.dev_type,
-			.dev_model = cdev->private->senseid.dev_model,
-		};
+		if (cdev->private->state == DEV_STATE_DISCONNECTED_SENSE_ID)
+			notify = 1;
+		else  /* fill out sense information */
+			cdev->id = (struct ccw_device_id) {
+				.cu_type   = cdev->private->senseid.cu_type,
+				.cu_model  = cdev->private->senseid.cu_model,
+				.dev_type  = cdev->private->senseid.dev_type,
+				.dev_model = cdev->private->senseid.dev_model,
+			};
 		/* Issue device info message. */
-		CIO_DEBUG(KERN_INFO, 2, "SenseID : device %04X reports: "
+		CIO_DEBUG(KERN_INFO, 2, "SenseID : device %s reports: "
 			  "CU  Type/Mod = %04X/%02X, Dev Type/Mod = "
-			  "%04X/%02X\n", sch->schib.pmcw.dev,
+			  "%04X/%02X\n", cdev->dev.bus_id,
 			  cdev->id.cu_type, cdev->id.cu_model,
 			  cdev->id.dev_type, cdev->id.dev_model);
 		break;
 	case DEV_STATE_BOXED:
 		CIO_DEBUG(KERN_WARNING, 2,
-			  "SenseID : boxed device %04X on subchannel %04X\n",
-			  sch->schib.pmcw.dev, sch->irq);
+			  "SenseID : boxed device %s on subchannel %s\n",
+			  cdev->dev.bus_id, sch->dev.bus_id);
 		break;
 	}
-	io_subchannel_recog_done(cdev);
+	cdev->private->state = state;
+	if (notify && state == DEV_STATE_OFFLINE)
+		ccw_device_handle_oper(cdev);
+	else
+		io_subchannel_recog_done(cdev);
 	if (state != DEV_STATE_NOT_OPER)
 		wake_up(&cdev->private->wait_q);
 }
@@ -158,6 +244,24 @@ ccw_device_sense_id_done(struct ccw_devi
 	}
 }
 
+static void
+ccw_device_oper_notify(void *data)
+{
+	struct ccw_device *cdev;
+	struct subchannel *sch;
+	int ret;
+
+	cdev = (struct ccw_device *)data;
+	sch = to_subchannel(cdev->dev.parent);
+	ret = (sch->driver && sch->driver->notify) ?
+		sch->driver->notify(&sch->dev, CIO_OPER) : 0;
+	if (!ret)
+		/* Driver doesn't want device back. */
+		ccw_device_do_unreg_rereg((void *)&cdev->dev);
+	else
+		wake_up(&cdev->private->wait_q);
+}
+
 /*
  * Finished with online/offline processing.
  */
@@ -179,13 +283,19 @@ ccw_device_done(struct ccw_device *cdev,
 
 	if (state == DEV_STATE_BOXED) {
 		CIO_DEBUG(KERN_WARNING, 2,
-			  "Boxed device %04X on subchannel %04X\n",
-			  sch->schib.pmcw.dev, sch->irq);
+			  "Boxed device %s on subchannel %s\n",
+			  cdev->dev.bus_id, sch->dev.bus_id);
 		INIT_WORK(&cdev->private->kick_work,
 			  ccw_device_add_stlck, (void *) cdev);
 		queue_work(ccw_device_work, &cdev->private->kick_work);
 	}
 
+	if (cdev->private->flags.donotify) {
+		cdev->private->flags.donotify = 0;
+		PREPARE_WORK(&cdev->private->kick_work, ccw_device_oper_notify,
+			     (void *)cdev);
+		queue_work(ccw_device_work, &cdev->private->kick_work);
+	}
 	wake_up(&cdev->private->wait_q);
 
 	if (css_init_done && state != DEV_STATE_ONLINE)
@@ -229,13 +339,15 @@ int
 ccw_device_recognition(struct ccw_device *cdev)
 {
 	struct subchannel *sch;
+	int ret;
 
 	if (cdev->private->state != DEV_STATE_NOT_OPER)
 		return -EINVAL;
 	sch = to_subchannel(cdev->dev.parent);
-	if (cio_enable_subchannel(sch, sch->schib.pmcw.isc) != 0)
+	ret = cio_enable_subchannel(sch, sch->schib.pmcw.isc);
+	if (ret != 0)
 		/* Couldn't enable the subchannel for i/o. Sick device. */
-		return -ENODEV;
+		return ret;
 
 	/* After 60s the device recognition is considered to have failed. */
 	ccw_device_set_timeout(cdev, 60*HZ);
@@ -259,10 +371,19 @@ ccw_device_recognition(struct ccw_device
 static void
 ccw_device_recog_timeout(struct ccw_device *cdev, enum dev_event dev_event)
 {
-	if (ccw_device_cancel_halt_clear(cdev) == 0)
+	int ret;
+
+	ret = ccw_device_cancel_halt_clear(cdev);
+	switch (ret) {
+	case 0:
 		ccw_device_recog_done(cdev, DEV_STATE_BOXED);
-	else
+		break;
+	case -ENODEV:
+		ccw_device_recog_done(cdev, DEV_STATE_NOT_OPER);
+		break;
+	default:
 		ccw_device_set_timeout(cdev, 3*HZ);
+	}
 }
 
 
@@ -290,16 +411,19 @@ int
 ccw_device_online(struct ccw_device *cdev)
 {
 	struct subchannel *sch;
+	int ret;
 
 	if (cdev->private->state != DEV_STATE_OFFLINE)
 		return -EINVAL;
 	sch = to_subchannel(cdev->dev.parent);
 	if (css_init_done && !get_device(&cdev->dev))
 		return -ENODEV;
-	if (cio_enable_subchannel(sch, sch->schib.pmcw.isc) != 0) {
+	ret = cio_enable_subchannel(sch, sch->schib.pmcw.isc);
+	if (ret != 0) {
 		/* Couldn't enable the subchannel for i/o. Sick device. */
-		dev_fsm_event(cdev, DEV_EVENT_NOTOPER);
-		return -ENODEV;
+		if (ret == -ENODEV)
+			dev_fsm_event(cdev, DEV_EVENT_NOTOPER);
+		return ret;
 	}
 	/* Do we want to do path grouping? */
 	if (!cdev->private->options.pgroup) {
@@ -363,10 +487,19 @@ ccw_device_offline(struct ccw_device *cd
 static void
 ccw_device_onoff_timeout(struct ccw_device *cdev, enum dev_event dev_event)
 {
-	if (ccw_device_cancel_halt_clear(cdev) == 0)
+	int ret;
+
+	ret = ccw_device_cancel_halt_clear(cdev);
+	switch (ret) {
+	case 0:
 		ccw_device_done(cdev, DEV_STATE_BOXED);
-	else
+		break;
+	case -ENODEV:
+		ccw_device_done(cdev, DEV_STATE_NOT_OPER);
+		break;
+	default:
 		ccw_device_set_timeout(cdev, 3*HZ);
+	}
 }
 
 /*
@@ -375,7 +508,10 @@ ccw_device_onoff_timeout(struct ccw_devi
 static void
 ccw_device_recog_notoper(struct ccw_device *cdev, enum dev_event dev_event)
 {
-	ccw_device_recog_done(cdev, DEV_STATE_NOT_OPER);
+	if (cdev->private->state == DEV_STATE_DISCONNECTED_SENSE_ID)
+		cdev->private->state = DEV_STATE_DISCONNECTED;
+	else
+		ccw_device_recog_done(cdev, DEV_STATE_NOT_OPER);
 }
 
 /*
@@ -385,9 +521,7 @@ static void
 ccw_device_offline_notoper(struct ccw_device *cdev, enum dev_event dev_event)
 {
 	cdev->private->state = DEV_STATE_NOT_OPER;
-	INIT_WORK(&cdev->private->kick_work,
-		  ccw_device_unregister, (void *) &cdev->dev);
-	queue_work(ccw_device_work, &cdev->private->kick_work);
+	device_unregister(&cdev->dev);
 	wake_up(&cdev->private->wait_q);
 }
 
@@ -406,9 +540,20 @@ ccw_device_online_notoper(struct ccw_dev
 		// FIXME: not-oper indication to device driver ?
 		ccw_device_call_handler(cdev);
 	}
-	INIT_WORK(&cdev->private->kick_work,
-		  ccw_device_unregister, (void *) &cdev->dev);
-	queue_work(ccw_device_work, &cdev->private->kick_work);
+	device_unregister(&cdev->dev);
+	wake_up(&cdev->private->wait_q);
+}
+
+static void
+ccw_device_disconnected_notoper(struct ccw_device *cdev,
+				enum dev_event dev_event)
+{
+	struct subchannel *sch;
+
+	sch = to_subchannel(cdev->dev.parent);
+	cdev->private->state = DEV_STATE_NOT_OPER;
+	cio_disable_subchannel(sch);
+	device_unregister(&cdev->dev);
 	wake_up(&cdev->private->wait_q);
 }
 
@@ -478,13 +623,18 @@ ccw_device_irq(struct ccw_device *cdev, 
 static void
 ccw_device_online_timeout(struct ccw_device *cdev, enum dev_event dev_event)
 {
+	int ret;
+
 	ccw_device_set_timeout(cdev, 0);
-	if (ccw_device_cancel_halt_clear(cdev) != 0) {
+	ret = ccw_device_cancel_halt_clear(cdev);
+	if (ret == -EBUSY) {
 		ccw_device_set_timeout(cdev, 3*HZ);
 		cdev->private->state = DEV_STATE_TIMEOUT_KILL;
 		return;
 	}
-	if (cdev->handler)
+	if (ret == -ENODEV)
+		dev_fsm_event(cdev, DEV_EVENT_NOTOPER);
+	else if (cdev->handler)
 		cdev->handler(cdev, cdev->private->intparm,
 			      ERR_PTR(-ETIMEDOUT));
 }
@@ -552,10 +702,17 @@ ccw_device_killing_irq(struct ccw_device
 static void
 ccw_device_killing_timeout(struct ccw_device *cdev, enum dev_event dev_event)
 {
-	if (ccw_device_cancel_halt_clear(cdev) != 0) {
+	int ret;
+
+	ret = ccw_device_cancel_halt_clear(cdev);
+	if (ret == -EBUSY) {
 		ccw_device_set_timeout(cdev, 3*HZ);
 		return;
 	}
+	if (ret == -ENODEV) {
+		dev_fsm_event(cdev, DEV_EVENT_NOTOPER);
+		return;
+	}
 	//FIXME: Can we get here?
 	cdev->private->state = DEV_STATE_ONLINE;
 	if (cdev->handler)
@@ -564,6 +721,68 @@ ccw_device_killing_timeout(struct ccw_de
 }
 
 static void
+ccw_device_wait4io_irq(struct ccw_device *cdev, enum dev_event dev_event)
+{
+	struct irb *irb;
+	struct subchannel *sch;
+
+	irb = (struct irb *) __LC_IRB;
+	/* Check for unsolicited interrupt. */
+	if (irb->scsw.stctl ==
+	    		(SCSW_STCTL_STATUS_PEND | SCSW_STCTL_ALERT_STATUS)) {
+		if (cdev->handler)
+			cdev->handler (cdev, 0, irb);
+		return;
+	}
+	/*
+	 * Accumulate status and find out if a basic sense is needed.
+	 * This is fine since we have already adapted the lpm.
+	 */
+	ccw_device_accumulate_irb(cdev, irb);
+	if (cdev->private->flags.dosense) {
+		if (ccw_device_do_sense(cdev, irb) == 0) {
+			cdev->private->state = DEV_STATE_W4SENSE;
+		}
+		return;
+	}
+	/* Iff device is idle, reset timeout. */
+	sch = to_subchannel(cdev->dev.parent);
+	if (!stsch(sch->irq, &sch->schib))
+		if (sch->schib.scsw.actl == 0)
+			ccw_device_set_timeout(cdev, 0);
+	/* Call the handler. */
+	if (ccw_device_call_handler(cdev) && cdev->private->flags.doverify)
+		ccw_device_online_verify(cdev, 0);
+}
+
+static void
+ccw_device_wait4io_timeout(struct ccw_device *cdev, enum dev_event dev_event)
+{
+	int ret;
+
+	ccw_device_set_timeout(cdev, 0);
+	ret = ccw_device_cancel_halt_clear(cdev);
+	if (ret == -EBUSY) {
+		ccw_device_set_timeout(cdev, 3*HZ);
+		cdev->private->state = DEV_STATE_TIMEOUT_KILL;
+		return;
+	}
+	if (ret == -ENODEV)
+		dev_fsm_event(cdev, DEV_EVENT_NOTOPER);
+	else if (cdev->handler)
+		cdev->handler(cdev, cdev->private->intparm,
+			      ERR_PTR(-ETIMEDOUT));
+}
+
+static void
+ccw_device_wait4io_verify(struct ccw_device *cdev, enum dev_event dev_event)
+{
+	/* When the I/O has terminated, we have to start verification. */
+	if (cdev->private->options.pgroup)
+		cdev->private->flags.doverify = 1;
+}
+
+static void
 ccw_device_stlck_done(struct ccw_device *cdev, enum dev_event dev_event)
 {
 	struct irb *irb;
@@ -586,6 +805,59 @@ out_wakeup:
 	wake_up(&cdev->private->wait_q);
 }
 
+static void
+ccw_device_start_id(struct ccw_device *cdev, enum dev_event dev_event)
+{
+	struct subchannel *sch;
+
+	sch = to_subchannel(cdev->dev.parent);
+	if (cio_enable_subchannel(sch, sch->schib.pmcw.isc) != 0)
+		/* Couldn't enable the subchannel for i/o. Sick device. */
+		return;
+
+	/* After 60s the device recognition is considered to have failed. */
+	ccw_device_set_timeout(cdev, 60*HZ);
+
+	cdev->private->state = DEV_STATE_DISCONNECTED_SENSE_ID;
+	ccw_device_sense_id_start(cdev);
+}
+
+void
+device_trigger_reprobe(struct subchannel *sch)
+{
+	struct ccw_device *cdev;
+	unsigned long flags;
+
+	if (!sch->dev.driver_data)
+		return;
+	cdev = sch->dev.driver_data;
+	if (cdev->private->state != DEV_STATE_DISCONNECTED)
+		return;
+	spin_lock_irqsave(&sch->lock, flags);
+	/* Re-set some bits in the pmcw that were lost. */
+	sch->schib.pmcw.isc = 3;
+	sch->schib.pmcw.csense = 1;
+	sch->schib.pmcw.ena = 0;
+	if ((sch->lpm & (sch->lpm - 1)) != 0)
+		sch->schib.pmcw.mp = 1;
+	sch->schib.pmcw.intparm = (__u32)(unsigned long)sch;
+	ccw_device_start_id(cdev, 0);
+	spin_unlock_irqrestore(&sch->lock, flags);
+}
+
+static void
+ccw_device_offline_irq(struct ccw_device *cdev, enum dev_event dev_event)
+{
+	struct subchannel *sch;
+
+	sch = to_subchannel(cdev->dev.parent);
+	/*
+	 * An interrupt in state offline means a previous disable was not
+	 * successful. Try again.
+	 */
+	cio_disable_subchannel(sch);
+}
+
 /*
  * No operation action. This is used e.g. to ignore a timeout event in
  * state offline.
@@ -630,7 +902,7 @@ fsm_func_t *dev_jumptable[NR_DEV_STATES]
 	},
 	[DEV_STATE_OFFLINE] {
 		[DEV_EVENT_NOTOPER]	ccw_device_offline_notoper,
-		[DEV_EVENT_INTERRUPT]	ccw_device_bug,
+		[DEV_EVENT_INTERRUPT]	ccw_device_offline_irq,
 		[DEV_EVENT_TIMEOUT]	ccw_device_nop,
 		[DEV_EVENT_VERIFY]	ccw_device_nop,
 	},
@@ -677,6 +949,25 @@ fsm_func_t *dev_jumptable[NR_DEV_STATES]
 		[DEV_EVENT_TIMEOUT]	ccw_device_killing_timeout,
 		[DEV_EVENT_VERIFY]	ccw_device_nop, //FIXME
 	},
+	[DEV_STATE_WAIT4IO] {
+		[DEV_EVENT_NOTOPER]	ccw_device_online_notoper,
+		[DEV_EVENT_INTERRUPT]	ccw_device_wait4io_irq,
+		[DEV_EVENT_TIMEOUT]	ccw_device_wait4io_timeout,
+		[DEV_EVENT_VERIFY]	ccw_device_wait4io_verify,
+	},
+	/* special states for devices gone not operational */
+	[DEV_STATE_DISCONNECTED] {
+		[DEV_EVENT_NOTOPER]	ccw_device_disconnected_notoper,
+		[DEV_EVENT_INTERRUPT]	ccw_device_start_id,
+		[DEV_EVENT_TIMEOUT]	ccw_device_bug,
+		[DEV_EVENT_VERIFY]	ccw_device_nop,
+	},
+	[DEV_STATE_DISCONNECTED_SENSE_ID] {
+		[DEV_EVENT_NOTOPER]	ccw_device_recog_notoper,
+		[DEV_EVENT_INTERRUPT]	ccw_device_sense_id_irq,
+		[DEV_EVENT_TIMEOUT]	ccw_device_recog_timeout,
+		[DEV_EVENT_VERIFY]	ccw_device_nop,
+	},
 };
 
 /*
@@ -686,13 +977,12 @@ fsm_func_t *dev_jumptable[NR_DEV_STATES]
 void
 io_subchannel_irq (struct device *pdev)
 {
-	char dbf_txt[15];
 	struct ccw_device *cdev;
 
 	cdev = to_subchannel(pdev)->dev.driver_data;
 
-	sprintf (dbf_txt, "IRQ%04x", cdev->private->irq);
-	CIO_TRACE_EVENT (3, dbf_txt);
+	CIO_TRACE_EVENT (3, "IRQ");
+	CIO_TRACE_EVENT (3, pdev->bus_id);
 
 	dev_fsm_event(cdev, DEV_EVENT_INTERRUPT);
 }
diff -puN drivers/s390/cio/device.h~linus drivers/s390/cio/device.h
--- 25/drivers/s390/cio/device.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/cio/device.h	2004-01-19 22:17:23.000000000 -0800
@@ -17,6 +17,10 @@ enum dev_state {
 	/* states to wait for i/o completion before doing something */
 	DEV_STATE_CLEAR_VERIFY,
 	DEV_STATE_TIMEOUT_KILL,
+	DEV_STATE_WAIT4IO,
+	/* special states for devices gone not operational */
+	DEV_STATE_DISCONNECTED,
+	DEV_STATE_DISCONNECTED_SENSE_ID,
 	/* last element! */
 	NR_DEV_STATES
 };
@@ -63,7 +67,9 @@ extern struct workqueue_struct *ccw_devi
 
 void io_subchannel_recog_done(struct ccw_device *cdev);
 
-void ccw_device_unregister(void *);
+int ccw_device_register(struct ccw_device *);
+void ccw_device_do_unreg_rereg(void *);
+
 
 int ccw_device_recognition(struct ccw_device *);
 int ccw_device_online(struct ccw_device *);
diff -puN drivers/s390/cio/device_id.c~linus drivers/s390/cio/device_id.c
--- 25/drivers/s390/cio/device_id.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/cio/device_id.c	2004-01-19 22:17:23.000000000 -0800
@@ -22,6 +22,7 @@
 #include "cio_debug.h"
 #include "css.h"
 #include "device.h"
+#include "ioasm.h"
 
 /*
  * diag210 is used under VM to get information about a virtual device
@@ -195,15 +196,11 @@ __ccw_device_sense_id_start(struct ccw_d
 	ret = -ENODEV;
 	while (cdev->private->imask != 0) {
 		if ((sch->lpm & cdev->private->imask) != 0 &&
-		    cdev->private->iretry-- > 0) {
-			/* 0x00E2C9C4 == ebcdic "SID" */
+		    cdev->private->iretry > 0) {
+			cdev->private->iretry--;
 			ret = cio_start (sch, cdev->private->iccws,
-					 0x00E2C9C4, cdev->private->imask);
+					 cdev->private->imask);
 			/* ret is 0, -EBUSY, -EACCES or -ENODEV */
-			if (ret == -EBUSY) {
-				udelay(100);
-				continue;
-			}
 			if (ret != -EACCES)
 				return ret;
 		}
@@ -223,7 +220,7 @@ ccw_device_sense_id_start(struct ccw_dev
 	cdev->private->imask = 0x80;
 	cdev->private->iretry = 5;
 	ret = __ccw_device_sense_id_start(cdev);
-	if (ret)
+	if (ret && ret != -EBUSY)
 		ccw_device_sense_id_done(cdev, ret);
 }
 
@@ -255,16 +252,16 @@ ccw_device_check_sense_id(struct ccw_dev
 		 * if the device doesn't support the SenseID
 		 *  command further retries wouldn't help ...
 		 */
-		CIO_MSG_EVENT(2, "SenseID : device %04X on Subchannel %04X "
+		CIO_MSG_EVENT(2, "SenseID : device %s on Subchannel %s "
 			      "reports cmd reject or intervention required\n",
-			      sch->schib.pmcw.dev, sch->irq);
+			      cdev->dev.bus_id, sch->dev.bus_id);
 		return -EOPNOTSUPP;
 	}
 	if (irb->esw.esw0.erw.cons) {
-		CIO_MSG_EVENT(2, "SenseID : UC on dev %04X, "
+		CIO_MSG_EVENT(2, "SenseID : UC on dev %s, "
 			      "lpum %02X, cnt %02d, sns :"
 			      " %02X%02X%02X%02X %02X%02X%02X%02X ...\n",
-			      sch->schib.pmcw.dev,
+			      cdev->dev.bus_id,
 			      irb->esw.esw0.sublog.lpum,
 			      irb->esw.esw0.erw.scnt,
 			      irb->ecw[0], irb->ecw[1],
@@ -274,15 +271,15 @@ ccw_device_check_sense_id(struct ccw_dev
 		return -EAGAIN;
 	}
 	if (irb->scsw.cc == 3) {
-		CIO_MSG_EVENT(2, "SenseID : path %02X for device %04X on "
-			      "subchannel %04X is 'not operational'\n",
-			      sch->orb.lpm, sch->schib.pmcw.dev, sch->irq);
+		CIO_MSG_EVENT(2, "SenseID : path %02X for device %s on "
+			      "subchannel %s is 'not operational'\n",
+			      sch->orb.lpm, cdev->dev.bus_id, sch->dev.bus_id);
 		return -EACCES;
 	}
 	/* Hmm, whatever happened, try again. */
-	CIO_MSG_EVENT(2, "SenseID : start_IO() for device %04X on "
-		      "subchannel %04X returns status %02X%02X\n",
-		      sch->schib.pmcw.dev, sch->irq,
+	CIO_MSG_EVENT(2, "SenseID : start_IO() for device %s on "
+		      "subchannel %s returns status %02X%02X\n",
+		      cdev->dev.bus_id, sch->dev.bus_id,
 		      irb->scsw.dstat, irb->scsw.cstat);
 	return -EAGAIN;
 }
@@ -299,11 +296,17 @@ ccw_device_sense_id_irq(struct ccw_devic
 
 	sch = to_subchannel(cdev->dev.parent);
 	irb = (struct irb *) __LC_IRB;
-	/* Ignore unsolicited interrupts. */
+	/*
+	 * Unsolicited interrupts may pertain to an earlier status pending or
+	 * busy condition on the subchannel. Retry sense id.
+	 */
 	if (irb->scsw.stctl ==
-	    		(SCSW_STCTL_STATUS_PEND | SCSW_STCTL_ALERT_STATUS))
+	    (SCSW_STCTL_STATUS_PEND | SCSW_STCTL_ALERT_STATUS)) {
+		ret = __ccw_device_sense_id_start(cdev);
+		if (ret && ret != -EBUSY)
+			ccw_device_sense_id_done(cdev, ret);
 		return;
-
+	}
 	if (ccw_device_accumulate_and_sense(cdev, irb) != 0)
 		return;
 	ret = ccw_device_check_sense_id(cdev);
diff -puN drivers/s390/cio/device_ops.c~linus drivers/s390/cio/device_ops.c
--- 25/drivers/s390/cio/device_ops.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/cio/device_ops.c	2004-01-19 22:17:23.000000000 -0800
@@ -49,6 +49,8 @@ ccw_device_clear(struct ccw_device *cdev
 
 	if (!cdev)
 		return -ENODEV;
+	if (cdev->private->state == DEV_STATE_NOT_OPER)
+		return -ENODEV;
 	if (cdev->private->state != DEV_STATE_ONLINE &&
 	    cdev->private->state != DEV_STATE_W4SENSE)
 		return -EINVAL;
@@ -73,6 +75,8 @@ ccw_device_start(struct ccw_device *cdev
 	sch = to_subchannel(cdev->dev.parent);
 	if (!sch)
 		return -ENODEV;
+	if (cdev->private->state == DEV_STATE_NOT_OPER)
+		return -ENODEV;
 	if (cdev->private->state != DEV_STATE_ONLINE ||
 	    sch->schib.scsw.actl != 0 ||
 	    cdev->private->flags.doverify)
@@ -80,8 +84,7 @@ ccw_device_start(struct ccw_device *cdev
 	ret = cio_set_options (sch, flags);
 	if (ret)
 		return ret;
-	/* 0xe4e2c5d9 == ebcdic "USER" */
-	ret = cio_start (sch, cpa, 0xe4e2c5d9, lpm);
+	ret = cio_start (sch, cpa, lpm);
 	if (ret == 0)
 		cdev->private->intparm = intparm;
 	return ret;
@@ -111,6 +114,8 @@ ccw_device_halt(struct ccw_device *cdev,
 
 	if (!cdev)
 		return -ENODEV;
+	if (cdev->private->state == DEV_STATE_NOT_OPER)
+		return -ENODEV;
 	if (cdev->private->state != DEV_STATE_ONLINE &&
 	    cdev->private->state != DEV_STATE_W4SENSE)
 		return -EINVAL;
@@ -133,6 +138,8 @@ ccw_device_resume(struct ccw_device *cde
 	sch = to_subchannel(cdev->dev.parent);
 	if (!sch)
 		return -ENODEV;
+	if (cdev->private->state == DEV_STATE_NOT_OPER)
+		return -ENODEV;
 	if (cdev->private->state != DEV_STATE_ONLINE ||
 	    !(sch->schib.scsw.actl & SCSW_ACTL_SUSPENDED))
 		return -EINVAL;
@@ -251,7 +258,7 @@ __ccw_device_retry_loop(struct ccw_devic
 
 	sch = to_subchannel(cdev->dev.parent);
 	do {
-		ret = cio_start (sch, ccw, magic, 0);
+		ret = cio_start (sch, ccw, 0);
 		if ((ret == -EBUSY) || (ret == -EACCES)) {
 			/* Try again later. */
 			spin_unlock_irq(&sch->lock);
@@ -302,7 +309,6 @@ int
 read_dev_chars (struct ccw_device *cdev, void **buffer, int length)
 {
 	void (*handler)(struct ccw_device *, unsigned long, struct irb *);
-	char dbf_txt[15];
 	struct subchannel *sch;
 	int ret;
 	struct ccw1 *rdc_ccw;
@@ -313,8 +319,8 @@ read_dev_chars (struct ccw_device *cdev,
 		return -EINVAL;
 	sch = to_subchannel(cdev->dev.parent);
 
-	sprintf (dbf_txt, "rddevch%x", sch->irq);
-	CIO_TRACE_EVENT (4, dbf_txt);
+	CIO_TRACE_EVENT (4, "rddevch");
+	CIO_TRACE_EVENT (4, sch->dev.bus_id);
 
 	rdc_ccw = kmalloc(sizeof(struct ccw1), GFP_KERNEL | GFP_DMA);
 	if (!rdc_ccw)
@@ -359,7 +365,6 @@ int
 read_conf_data (struct ccw_device *cdev, void **buffer, int *length)
 {
 	void (*handler)(struct ccw_device *, unsigned long, struct irb *);
-	char dbf_txt[15];
 	struct subchannel *sch;
 	struct ciw *ciw;
 	char *rcd_buf;
@@ -372,8 +377,8 @@ read_conf_data (struct ccw_device *cdev,
 		return -EINVAL;
 	sch = to_subchannel(cdev->dev.parent);
 
-	sprintf (dbf_txt, "rdconf%x", sch->irq);
-	CIO_TRACE_EVENT (4, dbf_txt);
+	CIO_TRACE_EVENT (4, "rdconf");
+	CIO_TRACE_EVENT (4, sch->dev.bus_id);
 
 	/*
 	 * scan for RCD command in extended SenseID data
@@ -449,21 +454,25 @@ ccw_device_stlck(struct ccw_device *cdev
 	CIO_TRACE_EVENT(2, "stl lock");
 	CIO_TRACE_EVENT(2, cdev->dev.bus_id);
 
+	spin_lock_irqsave(&sch->lock, flags);
+	ret = cio_enable_subchannel(sch, 3);
+	if (ret)
+		goto out_unlock;
 	/* Setup ccw. This cmd code seems not to be in use elsewhere. */
 	cdev->private->iccws[0].cmd_code = CCW_CMD_STLCK;
 	cdev->private->iccws[0].cda = (__u32) __pa(buf);
 	cdev->private->iccws[0].count = 32;
 	cdev->private->iccws[0].flags = CCW_FLAG_SLI;
 
-	spin_lock_irqsave(&sch->lock, flags);
-	ret = cio_start(sch, cdev->private->iccws, 0xE2D3C3D2, 0);
+	ret = cio_start(sch, cdev->private->iccws, 0);
+	if (ret) {
+		cio_disable_subchannel(sch); //FIXME: return code?
+		goto out_unlock;
+	}
 	spin_unlock_irqrestore(&sch->lock, flags);
-	if (ret)
-		return ret;
-
-	wait_event(cdev->private->wait_q, sch->schib.scsw.actl == 0);
+	wait_event(cdev->private->wait_q, cdev->private->irb.scsw.actl == 0);
 	spin_lock_irqsave(&sch->lock, flags);
-
+	cio_disable_subchannel(sch); //FIXME: return code?
 	if ((cdev->private->irb.scsw.dstat !=
 	     (DEV_STAT_CHN_END|DEV_STAT_DEV_END)) ||
 	    (cdev->private->irb.scsw.cstat != 0))
@@ -471,8 +480,8 @@ ccw_device_stlck(struct ccw_device *cdev
 
 	/* Clear irb. */
 	memset(&cdev->private->irb, 0, sizeof(struct irb));
+out_unlock:
 	spin_unlock_irqrestore(&sch->lock, flags);
-
 	return ret;
 }
 
diff -puN drivers/s390/cio/device_pgid.c~linus drivers/s390/cio/device_pgid.c
--- 25/drivers/s390/cio/device_pgid.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/cio/device_pgid.c	2004-01-19 22:17:23.000000000 -0800
@@ -48,25 +48,17 @@ __ccw_device_sense_pgid_start(struct ccw
 	ret = -ENODEV;
 	while (cdev->private->imask != 0) {
 		/* Try every path multiple times. */
-		if (cdev->private->iretry-- > 0) {
-			/* 0xe2d5c9c4 == ebcdic "SNID" */
+		if (cdev->private->iretry > 0) {
+			cdev->private->iretry--;
 			ret = cio_start (sch, cdev->private->iccws, 
-					 0xE2D5C9C4, cdev->private->imask);
+					 cdev->private->imask);
 			/* ret is 0, -EBUSY, -EACCES or -ENODEV */
-			if (ret == -EBUSY) {
-				CIO_MSG_EVENT(2, 
-					      "SNID - device %04X, start_io() "
-					      "reports rc : %d, retrying ...\n",
-					      sch->schib.pmcw.dev, ret);
-				udelay(100);
-				continue;
-			}
 			if (ret != -EACCES)
 				return ret;
-			CIO_MSG_EVENT(2, "SNID - Device %04X on Subchannel "
-				      "%04X, lpm %02X, became 'not "
+			CIO_MSG_EVENT(2, "SNID - Device %s on Subchannel "
+				      "%s, lpm %02X, became 'not "
 				      "operational'\n",
-				      sch->schib.pmcw.dev, sch->irq,
+				      cdev->dev.bus_id, sch->dev.bus_id,
 				      cdev->private->imask);
 
 		}
@@ -86,7 +78,7 @@ ccw_device_sense_pgid_start(struct ccw_d
 	cdev->private->iretry = 5;
 	memset (&cdev->private->pgid, 0, sizeof (struct pgid));
 	ret = __ccw_device_sense_pgid_start(cdev);
-	if (ret)
+	if (ret && ret != -EBUSY)
 		ccw_device_sense_pgid_done(cdev, ret);
 }
 
@@ -113,10 +105,10 @@ __ccw_device_check_sense_pgid(struct ccw
 		return -EOPNOTSUPP;
 	}
 	if (irb->esw.esw0.erw.cons) {
-		CIO_MSG_EVENT(2, "SNID - device %04X, unit check, "
+		CIO_MSG_EVENT(2, "SNID - device %s, unit check, "
 			      "lpum %02X, cnt %02d, sns : "
 			      "%02X%02X%02X%02X %02X%02X%02X%02X ...\n",
-			      sch->schib.pmcw.dev,
+			      cdev->dev.bus_id,
 			      irb->esw.esw0.sublog.lpum,
 			      irb->esw.esw0.erw.scnt,
 			      irb->ecw[0], irb->ecw[1],
@@ -126,16 +118,15 @@ __ccw_device_check_sense_pgid(struct ccw
 		return -EAGAIN;
 	}
 	if (irb->scsw.cc == 3) {
-		CIO_MSG_EVENT(2, "SNID - Device %04X on Subchannel "
-			      "%04X, lpm %02X, became 'not "
-			      "operational'\n",
-			      sch->schib.pmcw.dev, sch->irq, sch->orb.lpm);
+		CIO_MSG_EVENT(2, "SNID - Device %s on Subchannel "
+			      "%s, lpm %02X, became 'not operational'\n",
+			      cdev->dev.bus_id, sch->dev.bus_id, sch->orb.lpm);
 		return -EACCES;
 	}
 	if (cdev->private->pgid.inf.ps.state2 == SNID_STATE2_RESVD_ELSE) {
-		CIO_MSG_EVENT(2, "SNID - Device %04X on Subchannel %04X "
+		CIO_MSG_EVENT(2, "SNID - Device %s on Subchannel %s "
 			      "is reserved by someone else\n",
-			      sch->schib.pmcw.dev, sch->irq);
+			      cdev->dev.bus_id, sch->dev.bus_id);
 		return -EUSERS;
 	}
 	return 0;
@@ -150,34 +141,30 @@ ccw_device_sense_pgid_irq(struct ccw_dev
 	struct subchannel *sch;
 	struct irb *irb;
 	int ret;
-	int opm;
-	int i;
 
 	irb = (struct irb *) __LC_IRB;
-	/* Ignore unsolicited interrupts. */
+	/*
+	 * Unsolicited interrupts may pertain to an earlier status pending or
+	 * busy condition on the subchannel. Retry sense pgid.
+	 */
 	if (irb->scsw.stctl ==
-	    		(SCSW_STCTL_STATUS_PEND | SCSW_STCTL_ALERT_STATUS))
+	    (SCSW_STCTL_STATUS_PEND | SCSW_STCTL_ALERT_STATUS)) {
+		ret = __ccw_device_sense_pgid_start(cdev);
+		if (ret && ret != -EBUSY)
+			ccw_device_sense_pgid_done(cdev, ret);
 		return;
+	}
 	if (ccw_device_accumulate_and_sense(cdev, irb) != 0)
 		return;
 	sch = to_subchannel(cdev->dev.parent);
 	switch (__ccw_device_check_sense_pgid(cdev)) {
 	/* 0, -ETIME, -EOPNOTSUPP, -EAGAIN, -EACCES or -EUSERS */
 	case 0:			/* Sense Path Group ID successful. */
-		opm = sch->schib.pmcw.pim &
-			sch->schib.pmcw.pam &
-			sch->schib.pmcw.pom;
-		for (i=0;i<8;i++) {
-			if (opm == (0x80 << i)) {
-				/* Don't group single path devices. */
-				cdev->private->options.pgroup = 0;
-				break;
-			}
-		}
 		if (cdev->private->pgid.inf.ps.state1 == SNID_STATE1_RESET)
 			memcpy(&cdev->private->pgid, &global_pgid,
 			       sizeof(struct pgid));
-		/* fall through. */
+		ccw_device_sense_pgid_done(cdev, 0);
+		break;
 	case -EOPNOTSUPP:	/* Sense Path Group ID not supported */
 		ccw_device_sense_pgid_done(cdev, -EOPNOTSUPP);
 		break;
@@ -235,26 +222,20 @@ __ccw_device_do_pgid(struct ccw_device *
 
 	/* Try multiple times. */
 	ret = -ENODEV;
-	while (cdev->private->iretry-- > 0) {
-		/* 0xE2D7C9C4 == ebcdic "SPID" */
+	if (cdev->private->iretry > 0) {
+		cdev->private->iretry--;
 		ret = cio_start (sch, cdev->private->iccws,
-				 0xE2D7C9C4, cdev->private->imask);
+				 cdev->private->imask);
 		/* ret is 0, -EBUSY, -EACCES or -ENODEV */
-		if (ret == -EACCES)
-			break;
-		if (ret != -EBUSY)
+		if (ret != -EACCES)
 			return ret;
-		udelay(100);
-		continue;
 	}
 	/* PGID command failed on this path. Switch it off. */
 	sch->lpm &= ~cdev->private->imask;
 	sch->vpm &= ~cdev->private->imask;
-	CIO_MSG_EVENT(2, "SPID - Device %04X on Subchannel "
-		      "%04X, lpm %02X, became 'not "
-		      "operational'\n",
-		      sch->schib.pmcw.dev, sch->irq,
-		      cdev->private->imask);
+	CIO_MSG_EVENT(2, "SPID - Device %s on Subchannel "
+		      "%s, lpm %02X, became 'not operational'\n",
+		      cdev->dev.bus_id, sch->dev.bus_id, cdev->private->imask);
 	return ret;
 }
 
@@ -276,9 +257,9 @@ __ccw_device_check_pgid(struct ccw_devic
 		if (irb->ecw[0] & SNS0_CMD_REJECT)
 			return -EOPNOTSUPP;
 		/* Hmm, whatever happened, try again. */
-		CIO_MSG_EVENT(2, "SPID - device %04X, unit check, cnt %02d, "
+		CIO_MSG_EVENT(2, "SPID - device %s, unit check, cnt %02d, "
 			      "sns : %02X%02X%02X%02X %02X%02X%02X%02X ...\n",
-			      sch->schib.pmcw.dev, irb->esw.esw0.erw.scnt,
+			      cdev->dev.bus_id, irb->esw.esw0.erw.scnt,
 			      irb->ecw[0], irb->ecw[1],
 			      irb->ecw[2], irb->ecw[3],
 			      irb->ecw[4], irb->ecw[5],
@@ -286,10 +267,9 @@ __ccw_device_check_pgid(struct ccw_devic
 		return -EAGAIN;
 	}
 	if (irb->scsw.cc == 3) {
-		CIO_MSG_EVENT(2, "SPID - Device %04X on Subchannel "
-			      "%04X, lpm %02X, became 'not "
-			      "operational'\n",
-			      sch->schib.pmcw.dev, sch->irq,
+		CIO_MSG_EVENT(2, "SPID - Device %s on Subchannel "
+			      "%s, lpm %02X, became 'not operational'\n",
+			      cdev->dev.bus_id, sch->dev.bus_id,
 			      cdev->private->imask);
 		return -EACCES;
 	}
@@ -313,7 +293,7 @@ __ccw_device_verify_start(struct ccw_dev
 		func = (sch->vpm & imask) ?
 			SPID_FUNC_RESIGN : SPID_FUNC_ESTABLISH;
 		ret = __ccw_device_do_pgid(cdev, func);
-		if (ret == 0)
+		if (ret == 0 || ret == -EBUSY)
 			return;
 		cdev->private->iretry = 5;
 	}
@@ -330,10 +310,15 @@ ccw_device_verify_irq(struct ccw_device 
 	struct irb *irb;
 
 	irb = (struct irb *) __LC_IRB;
-	/* Ignore unsolicited interrupts. */
+	/*
+	 * Unsolicited interrupts may pertain to an earlier status pending or
+	 * busy condition on the subchannel. Restart path verification.
+	 */
 	if (irb->scsw.stctl ==
-	    		(SCSW_STCTL_STATUS_PEND | SCSW_STCTL_ALERT_STATUS))
+	    (SCSW_STCTL_STATUS_PEND | SCSW_STCTL_ALERT_STATUS)) {
+		__ccw_device_verify_start(cdev);
 		return;
+	}
 	if (ccw_device_accumulate_and_sense(cdev, irb) != 0)
 		return;
 	sch = to_subchannel(cdev->dev.parent);
diff -puN drivers/s390/cio/device_status.c~linus drivers/s390/cio/device_status.c
--- 25/drivers/s390/cio/device_status.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/cio/device_status.c	2004-01-19 22:17:23.000000000 -0800
@@ -62,8 +62,8 @@ ccw_device_path_notoper(struct ccw_devic
 	sch = to_subchannel(cdev->dev.parent);
 	stsch (sch->irq, &sch->schib);
 
-	CIO_MSG_EVENT(0, "%s(%04X) - path(s) %02x are "
-		      "not operational \n", __FUNCTION__, sch->irq,
+	CIO_MSG_EVENT(0, "%s(%s) - path(s) %02x are "
+		      "not operational \n", __FUNCTION__, sch->dev.bus_id,
 		      sch->schib.pmcw.pnom);
 
 	sch->lpm &= ~sch->schib.pmcw.pnom;
@@ -321,8 +321,7 @@ ccw_device_do_sense(struct ccw_device *c
 	sch->sense_ccw.count = SENSE_MAX_COUNT;
 	sch->sense_ccw.flags = CCW_FLAG_SLI;
 
-	/* 0xe2C5D5E2 == "SENS" in ebcdic */
-	return cio_start (sch, &sch->sense_ccw, 0xE2C5D5E2, 0xff);
+	return cio_start (sch, &sch->sense_ccw, 0xff);
 }
 
 /*
diff -puN drivers/s390/cio/qdio.c~linus drivers/s390/cio/qdio.c
--- 25/drivers/s390/cio/qdio.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/cio/qdio.c	2004-01-19 22:17:23.000000000 -0800
@@ -56,7 +56,7 @@
 #include "ioasm.h"
 #include "chsc.h"
 
-#define VERSION_QDIO_C "$Revision: 1.62 $"
+#define VERSION_QDIO_C "$Revision: 1.67 $"
 
 /****************** MODULE PARAMETER VARIABLES ********************/
 MODULE_AUTHOR("Utz Bacher <utz.bacher@de.ibm.com>");
@@ -80,6 +80,7 @@ static int hydra_thinints;
 static int indicator_used[INDICATORS_PER_CACHELINE];
 static __u32 * volatile indicators;
 static __u32 volatile spare_indicator;
+static atomic_t spare_indicator_usecount;
 
 static debug_info_t *qdio_dbf_setup;
 static debug_info_t *qdio_dbf_sbal;
@@ -238,7 +239,7 @@ qdio_get_indicator(void)
 			indicator_used[i]=1;
 			return indicators+i;
 		}
-
+	atomic_inc(&spare_indicator_usecount);
 	return (__u32 * volatile) &spare_indicator;
 }
 
@@ -252,6 +253,8 @@ qdio_put_indicator(__u32 *addr)
 		i=addr-indicators;
 		indicator_used[i]=0;
 	}
+	if (addr == &spare_indicator)
+		atomic_dec(&spare_indicator_usecount);
 }
 
 static inline volatile void 
@@ -622,7 +625,8 @@ qdio_outbound_processing(struct qdio_q *
 	if (q->is_iqdio_q) {
 		/* 
 		 * for asynchronous queues, we better check, if the fill
-		 * level is too high 
+		 * level is too high. for synchronous queues, the fill
+		 * level will never be that high. 
 		 */
 		if (atomic_read(&q->number_of_buffers_used)>
 		    IQDIO_FILL_LEVEL_TO_POLL)
@@ -920,7 +924,7 @@ qdio_kick_inbound_handler(struct qdio_q 
 }
 
 static inline void
-tiqdio_inbound_processing(struct qdio_q *q)
+__tiqdio_inbound_processing(struct qdio_q *q, int spare_ind_was_set)
 {
 	struct qdio_irq *irq_ptr;
 	struct qdio_q *oq;
@@ -954,10 +958,21 @@ tiqdio_inbound_processing(struct qdio_q 
 		goto out;
 	}
 
-	if (!(*(q->dev_st_chg_ind)))
-		goto out;
+	/* 
+	 * we reset spare_ind_was_set, when the queue does not use the
+	 * spare indicator
+	 */
+	if (spare_ind_was_set)
+		spare_ind_was_set = (q->dev_st_chg_ind == &spare_indicator);
 
-	tiqdio_clear_summary_bit((__u32*)q->dev_st_chg_ind);
+	if (!(*(q->dev_st_chg_ind)) && !spare_ind_was_set)
+		goto out;
+	/*
+	 * q->dev_st_chg_ind is the indicator, be it shared or not.
+	 * only clear it, if indicator is non-shared
+	 */
+	if (!spare_ind_was_set)
+		tiqdio_clear_summary_bit((__u32*)q->dev_st_chg_ind);
 
 	if (q->hydra_gives_outbound_pcis) {
 		if (!q->siga_sync_done_on_thinints) {
@@ -1004,6 +1019,12 @@ out:
 }
 
 static void
+tiqdio_inbound_processing(struct qdio_q *q)
+{
+	__tiqdio_inbound_processing(q, atomic_read(&spare_indicator_usecount));
+}
+
+static void
 qdio_inbound_processing(struct qdio_q *q)
 {
 	int q_laps=0;
@@ -1106,6 +1127,7 @@ static inline void
 tiqdio_inbound_checks(void)
 {
 	struct qdio_q *q;
+	int spare_ind_was_set=0;
 #ifdef QDIO_USE_PROCESSING_STATE
 	int q_laps=0;
 #endif /* QDIO_USE_PROCESSING_STATE */
@@ -1117,11 +1139,17 @@ tiqdio_inbound_checks(void)
 again:
 #endif /* QDIO_USE_PROCESSING_STATE */
 
+	/* when the spare indicator is used and set, save that and clear it */
+	if ((atomic_read(&spare_indicator_usecount)) && spare_indicator) {
+		spare_ind_was_set = 1;
+		tiqdio_clear_summary_bit((__u32*)&spare_indicator);
+	}
+
 	q=(struct qdio_q*)tiq_list;
 	do {
 		if (!q)
 			break;
-		tiqdio_inbound_processing(q);
+		__tiqdio_inbound_processing(q, spare_ind_was_set);
 		q=(struct qdio_q*)q->list_next;
 	} while (q!=(struct qdio_q*)tiq_list);
 
@@ -1583,6 +1611,16 @@ omit_handler_call:
 }
 
 static void
+qdio_call_shutdown(void *data)
+{
+	struct ccw_device *cdev;
+
+	cdev = (struct ccw_device *)data;
+	qdio_shutdown(cdev, QDIO_FLAG_CLEANUP_USING_CLEAR);
+	put_device(&cdev->dev);
+}
+
+static void
 qdio_timeout_handler(struct ccw_device *cdev)
 {
 	struct qdio_irq *irq_ptr;
@@ -1608,6 +1646,20 @@ qdio_timeout_handler(struct ccw_device *
 				irq_ptr->irq);
 		qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR);
 		break;
+	case QDIO_IRQ_STATE_ESTABLISHED:
+	case QDIO_IRQ_STATE_ACTIVE:
+		/* I/O has been terminated by common I/O layer. */
+		QDIO_PRINT_INFO("Queues on irq %04x killed by cio.\n",
+				irq_ptr->irq);
+		QDIO_DBF_TEXT2(1, trace, "cio:term");
+		qdio_set_state(irq_ptr, QDIO_IRQ_STATE_STOPPED);
+		if (get_device(&cdev->dev)) {
+			/* Can't call shutdown from interrupt context. */
+			PREPARE_WORK(&cdev->private->kick_work,
+				     qdio_call_shutdown, (void *)cdev);
+			queue_work(ccw_device_work, &cdev->private->kick_work);
+		}
+		break;
 	default:
 		BUG();
 	}
@@ -2098,7 +2150,7 @@ qdio_shutdown(struct ccw_device *cdev, i
 						 !atomic_read(&irq_ptr->
 							      input_qs[i]->
 							      use_count),
-						 QDIO_NO_USE_COUNT_TIMEOUT*HZ);
+						 QDIO_NO_USE_COUNT_TIMEOUT);
 		if (atomic_read(&irq_ptr->input_qs[i]->use_count))
 			/*
 			 * FIXME:
@@ -2116,7 +2168,7 @@ qdio_shutdown(struct ccw_device *cdev, i
 						 !atomic_read(&irq_ptr->
 							      output_qs[i]->
 							      use_count),
-						 QDIO_NO_USE_COUNT_TIMEOUT*HZ);
+						 QDIO_NO_USE_COUNT_TIMEOUT);
 		if (atomic_read(&irq_ptr->output_qs[i]->use_count))
 			/*
 			 * FIXME:
@@ -2134,23 +2186,34 @@ qdio_shutdown(struct ccw_device *cdev, i
 	/* cleanup subchannel */
 	spin_lock_irqsave(get_ccwdev_lock(cdev),flags);
 	if (how&QDIO_FLAG_CLEANUP_USING_CLEAR) {
-		ccw_device_clear(cdev, QDIO_DOING_CLEANUP);
+		result = ccw_device_clear(cdev, QDIO_DOING_CLEANUP);
 		timeout=QDIO_CLEANUP_CLEAR_TIMEOUT;
 	} else if (how&QDIO_FLAG_CLEANUP_USING_HALT) {
-		ccw_device_halt(cdev, QDIO_DOING_CLEANUP);
+		result = ccw_device_halt(cdev, QDIO_DOING_CLEANUP);
 		timeout=QDIO_CLEANUP_HALT_TIMEOUT;
 	} else { /* default behaviour */
-		ccw_device_halt(cdev, QDIO_DOING_CLEANUP);
+		result = ccw_device_halt(cdev, QDIO_DOING_CLEANUP);
 		timeout=QDIO_CLEANUP_HALT_TIMEOUT;
 	}
-	qdio_set_state(irq_ptr, QDIO_IRQ_STATE_CLEANUP);
-	ccw_device_set_timeout(cdev, timeout);
-	spin_unlock_irqrestore(get_ccwdev_lock(cdev),flags);
-
-	wait_event(cdev->private->wait_q,
-		   irq_ptr->state == QDIO_IRQ_STATE_INACTIVE ||
-		   irq_ptr->state == QDIO_IRQ_STATE_ERR);
-
+	if (result == -ENODEV) {
+		/* No need to wait for device no longer present. */
+		qdio_set_state(irq_ptr, QDIO_IRQ_STATE_INACTIVE);
+		result = 0; /* No error. */
+		spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
+	} else if (result == 0) {
+		qdio_set_state(irq_ptr, QDIO_IRQ_STATE_CLEANUP);
+		ccw_device_set_timeout(cdev, timeout);
+		spin_unlock_irqrestore(get_ccwdev_lock(cdev),flags);
+
+		wait_event(cdev->private->wait_q,
+			   irq_ptr->state == QDIO_IRQ_STATE_INACTIVE ||
+			   irq_ptr->state == QDIO_IRQ_STATE_ERR);
+	} else {
+		QDIO_PRINT_INFO("ccw_device_{halt,clear} returned %d for "
+				"device %s\n", result, cdev->dev.bus_id);
+		spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
+		goto out;
+	}
 	if (irq_ptr->is_thinint_irq) {
 		qdio_put_indicator((__u32*)irq_ptr->dev_st_chg_ind);
 		tiqdio_set_subchannel_ind(irq_ptr,1); 
@@ -2796,7 +2859,7 @@ qdio_activate(struct ccw_device *cdev, i
 					  QDIO_IRQ_STATE_STOPPED) ||
 					  (irq_ptr->state ==
 					   QDIO_IRQ_STATE_ERR)),
-					 (QDIO_ACTIVATE_TIMEOUT>>10)*HZ);
+					 QDIO_ACTIVATE_TIMEOUT);
 
 	switch (irq_ptr->state) {
 	case QDIO_IRQ_STATE_STOPPED:
diff -puN drivers/s390/cio/qdio.h~linus drivers/s390/cio/qdio.h
--- 25/drivers/s390/cio/qdio.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/cio/qdio.h	2004-01-19 22:17:23.000000000 -0800
@@ -1,7 +1,7 @@
 #ifndef _CIO_QDIO_H
 #define _CIO_QDIO_H
 
-#define VERSION_CIO_QDIO_H "$Revision: 1.20 $"
+#define VERSION_CIO_QDIO_H "$Revision: 1.22 $"
 
 //#define QDIO_DBF_LIKE_HELL
 
@@ -56,14 +56,14 @@
 #define QDIO_STATS_CLASSES 2
 #define QDIO_STATS_COUNT_NEEDED 2*/
 
-#define QDIO_NO_USE_COUNT_TIMEOUT 1000 /* wait for 1 sec on each q before
-					  exiting without having use_count
-					  of the queue to 0 */
-
-#define QDIO_ESTABLISH_TIMEOUT 1000
-#define QDIO_ACTIVATE_TIMEOUT 5
-#define QDIO_CLEANUP_CLEAR_TIMEOUT 20000
-#define QDIO_CLEANUP_HALT_TIMEOUT 10000
+#define QDIO_NO_USE_COUNT_TIMEOUT (1*HZ) /* wait for 1 sec on each q before
+					    exiting without having use_count
+					    of the queue to 0 */
+
+#define QDIO_ESTABLISH_TIMEOUT (1*HZ)
+#define QDIO_ACTIVATE_TIMEOUT ((5*HZ)>>10)
+#define QDIO_CLEANUP_CLEAR_TIMEOUT (20*HZ)
+#define QDIO_CLEANUP_HALT_TIMEOUT (10*HZ)
 
 enum qdio_irq_states {
 	QDIO_IRQ_STATE_INACTIVE,
diff -puN drivers/s390/net/ctcmain.c~linus drivers/s390/net/ctcmain.c
--- 25/drivers/s390/net/ctcmain.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/net/ctcmain.c	2004-01-19 22:17:23.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * $Id: ctcmain.c,v 1.47 2003/09/22 13:40:51 cohuck Exp $
+ * $Id: ctcmain.c,v 1.50 2003/12/02 15:18:50 cohuck Exp $
  *
  * CTC / ESCON network driver
  *
@@ -36,7 +36,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * RELEASE-TAG: CTC/ESCON network driver $Revision: 1.47 $
+ * RELEASE-TAG: CTC/ESCON network driver $Revision: 1.50 $
  *
  */
 
@@ -272,7 +272,7 @@ static void
 print_banner(void)
 {
 	static int printed = 0;
-	char vbuf[] = "$Revision: 1.47 $";
+	char vbuf[] = "$Revision: 1.50 $";
 	char *version = vbuf;
 
 	if (printed)
@@ -2441,14 +2441,12 @@ ctc_tx(struct sk_buff *skb, struct net_d
 
 	/**
 	 * If channels are not running, try to restart them
-	 * notify anybody about a link failure and throw
-	 * away packet. 
+	 * and throw away packet. 
 	 */
 	if (fsm_getstate(privptr->fsm) != DEV_STATE_RUNNING) {
 		fsm_event(privptr->fsm, DEV_EVENT_START, dev);
 		if (privptr->protocol == CTC_PROTO_LINUX_TTY)
 			return -EBUSY;
-		dst_link_failure(skb);
 		dev_kfree_skb(skb);
 		privptr->stats.tx_dropped++;
 		privptr->stats.tx_errors++;
@@ -2994,20 +2992,20 @@ ctc_shutdown_device(struct ccwgroup_devi
 
 }
 
-static int
+static void
 ctc_remove_device(struct ccwgroup_device *cgdev)
 {
 	struct ctc_priv *priv;
 
 	priv = cgdev->dev.driver_data;
 	if (!priv)
-		return 0;
-
+		return;
+	if (cgdev->state == CCWGROUP_ONLINE)
+		ctc_shutdown_device(cgdev);
 	ctc_remove_files(&cgdev->dev);
 	cgdev->dev.driver_data = NULL;
 	kfree(priv);
 	put_device(&cgdev->dev);
-	return 0;
 }
 
 static struct ccwgroup_driver ctc_group_driver = {
diff -puN drivers/s390/net/ctctty.c~linus drivers/s390/net/ctctty.c
--- 25/drivers/s390/net/ctctty.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/net/ctctty.c	2004-01-19 22:17:23.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * $Id: ctctty.c,v 1.13 2003/09/26 14:48:36 mschwide Exp $
+ * $Id: ctctty.c,v 1.14 2003/10/06 11:33:33 mschwide Exp $
  *
  * CTC / ESCON network driver, tty interface.
  *
@@ -761,7 +761,6 @@ ctc_tty_ioctl(struct tty_struct *tty, st
 			error = put_user(C_CLOCAL(tty) ? 1 : 0, (ulong *) arg);
 			if (error)
 				return error;
-			put_user(C_CLOCAL(tty) ? 1 : 0, (ulong *) arg);
 			return 0;
 		case TIOCSSOFTCAR:
 #ifdef CTC_DEBUG_MODEM_IOCTL
diff -puN drivers/s390/net/cu3088.c~linus drivers/s390/net/cu3088.c
--- 25/drivers/s390/net/cu3088.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/net/cu3088.c	2004-01-19 22:17:23.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * $Id: cu3088.c,v 1.31 2003/09/29 15:24:27 cohuck Exp $
+ * $Id: cu3088.c,v 1.33 2003/10/14 12:10:19 cohuck Exp $
  *
  * CTC / LCS ccw_device driver
  *
@@ -25,6 +25,7 @@
 
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/err.h>
 
 #include <asm/ccwdev.h>
 #include <asm/ccwgroup.h>
@@ -55,15 +56,7 @@ static struct ccw_device_id cu3088_ids[]
 
 static struct ccw_driver cu3088_driver;
 
-static void
-cu3088_root_dev_release (struct device *dev)
-{
-}
-
-struct device cu3088_root_dev = {
-	.bus_id = "cu3088",
-	.release = cu3088_root_dev_release,
-};
+struct device *cu3088_root_dev;
 
 static ssize_t
 group_write(struct device_driver *drv, const char *buf, size_t count)
@@ -90,7 +83,7 @@ group_write(struct device_driver *drv, c
 		start = end + 1;
 	}
 
-	ret = ccwgroup_create(&cu3088_root_dev, cdrv->driver_id,
+	ret = ccwgroup_create(cu3088_root_dev, cdrv->driver_id,
 			      &cu3088_driver, 2, argv);
 
 	return (ret == 0) ? count : ret;
@@ -144,12 +137,12 @@ cu3088_init (void)
 {
 	int rc;
 	
-	rc = device_register(&cu3088_root_dev);
-	if (rc)
-		return rc;
+	cu3088_root_dev = s390_root_dev_register("cu3088");
+	if (IS_ERR(cu3088_root_dev))
+		return PTR_ERR(cu3088_root_dev);
 	rc = ccw_driver_register(&cu3088_driver);
 	if (rc)
-		device_unregister(&cu3088_root_dev);
+		s390_root_dev_unregister(cu3088_root_dev);
 
 	return rc;
 }
@@ -158,7 +151,7 @@ static void __exit
 cu3088_exit (void)
 {
 	ccw_driver_unregister(&cu3088_driver);
-	device_unregister(&cu3088_root_dev);
+	s390_root_dev_unregister(cu3088_root_dev);
 }
 
 MODULE_DEVICE_TABLE(ccw,cu3088_ids);
diff -puN drivers/s390/net/fsm.c~linus drivers/s390/net/fsm.c
--- 25/drivers/s390/net/fsm.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/net/fsm.c	2004-01-19 22:17:23.000000000 -0800
@@ -1,5 +1,5 @@
 /**
- * $Id: fsm.c,v 1.4 2003/03/28 08:54:40 mschwide Exp $
+ * $Id: fsm.c,v 1.6 2003/10/15 11:37:29 mschwide Exp $
  *
  * A generic FSM based on fsm used in isdn4linux
  *
@@ -10,6 +10,10 @@
 #include <linux/module.h>
 #include <linux/timer.h>
 
+MODULE_AUTHOR("(C) 2000 IBM Corp. by Fritz Elfert (felfert@millenux.com)");
+MODULE_DESCRIPTION("Finite state machine helper functions");
+MODULE_LICENSE("GPL");
+
 fsm_instance *
 init_fsm(char *name, const char **state_names, const char **event_names, int nr_states,
 		int nr_events, const fsm_node *tmpl, int tmpl_len, int order)
diff -puN drivers/s390/net/iucv.c~linus drivers/s390/net/iucv.c
--- 25/drivers/s390/net/iucv.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/net/iucv.c	2004-01-19 22:17:23.000000000 -0800
@@ -1,5 +1,5 @@
 /* 
- * $Id: iucv.c,v 1.15 2003/10/01 09:25:15 mschwide Exp $
+ * $Id: iucv.c,v 1.19 2003/12/18 15:28:49 braunu Exp $
  *
  * IUCV network driver
  *
@@ -29,7 +29,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * RELEASE-TAG: IUCV lowlevel driver $Revision: 1.15 $
+ * RELEASE-TAG: IUCV lowlevel driver $Revision: 1.19 $
  *
  */
 
@@ -44,12 +44,14 @@
 #include <linux/interrupt.h>
 #include <linux/list.h>
 #include <linux/errno.h>
+#include <linux/err.h>
 #include <linux/device.h>
 #include <asm/atomic.h>
 #include "iucv.h"
 #include <asm/io.h>
 #include <asm/s390_ext.h>
 #include <asm/ebcdic.h>
+#include <asm/ccwdev.h> //for root device stuff
 
 #define DEBUG
 
@@ -79,20 +81,12 @@ iucv_bus_match (struct device *dev, stru
 	return 0;
 }
 
-static void
-iucv_root_release (struct device *dev)
-{
-}
-
 struct bus_type iucv_bus = {
 	.name = "iucv",
 	.match = iucv_bus_match,
 };	
 
-struct device iucv_root = {
-	.bus_id = "iucv",
-	.release = iucv_root_release,
-};
+struct device *iucv_root;
 
 /* General IUCV interrupt structure */
 typedef struct {
@@ -355,7 +349,7 @@ do { \
 static void
 iucv_banner(void)
 {
-	char vbuf[] = "$Revision: 1.15 $";
+	char vbuf[] = "$Revision: 1.19 $";
 	char *version = vbuf;
 
 	if ((version = strchr(version, ':'))) {
@@ -378,6 +372,11 @@ iucv_init(void)
 {
 	int ret;
 
+	if (!MACHINE_IS_VM) {
+		printk(KERN_ERR "IUCV: IUCV connection needs VM as base\n");
+		return -EPROTONOSUPPORT;
+	}
+
 	if (iucv_external_int_buffer)
 		return 0;
 
@@ -387,11 +386,11 @@ iucv_init(void)
 		return ret;
 	}
 
-	ret = device_register(&iucv_root);
-	if (ret != 0) {
+	iucv_root = s390_root_dev_register("iucv");
+	if (IS_ERR(iucv_root)) {
 		printk(KERN_ERR "IUCV: failed to register iucv root.\n");
 		bus_unregister(&iucv_bus);
-		return ret;
+		return PTR_ERR(iucv_root);
 	}
 
 	/* Note: GFP_DMA used used to get memory below 2G */
@@ -401,6 +400,7 @@ iucv_init(void)
 		printk(KERN_WARNING
 		       "%s: Could not allocate external interrupt buffer\n",
 		       __FUNCTION__);
+		s390_root_dev_unregister(iucv_root);
 		return -ENOMEM;
 	}
 	memset(iucv_external_int_buffer, 0, sizeof(iucv_GeneralInterrupt));
@@ -413,6 +413,7 @@ iucv_init(void)
 		       __FUNCTION__);
 		kfree(iucv_external_int_buffer);
 		iucv_external_int_buffer = NULL;
+		s390_root_dev_unregister(iucv_root);
 		return -ENOMEM;
 	}
 	memset(iucv_param_pool, 0, sizeof(iucv_param) * PARAM_POOL_SIZE);
@@ -439,7 +440,7 @@ iucv_exit(void)
 		kfree(iucv_external_int_buffer);
 	if (iucv_param_pool)
 		kfree(iucv_param_pool);
-	device_unregister(&iucv_root);
+	s390_root_dev_unregister(iucv_root);
 	bus_unregister(&iucv_bus);
 	printk(KERN_INFO "IUCV lowlevel driver unloaded\n");
 }
@@ -772,7 +773,7 @@ iucv_register_program (__u8 pgmname[16],
 	}
 
 	/* Allocate handler entry */
-	new_handler = (handler *)kmalloc(sizeof(handler), GFP_KERNEL);
+	new_handler = (handler *)kmalloc(sizeof(handler), GFP_ATOMIC);
 	if (new_handler == NULL) {
 		printk(KERN_WARNING "%s: storage allocation for new handler "
 		       "failed.\n", __FUNCTION__);
@@ -787,7 +788,7 @@ iucv_register_program (__u8 pgmname[16],
 
 		max_connections = iucv_query_maxconn();
 		iucv_pathid_table = kmalloc(max_connections * sizeof(handler *),
-				       GFP_KERNEL);
+				       GFP_ATOMIC);
 		if (iucv_pathid_table == NULL) {
 			printk(KERN_WARNING "%s: iucv_pathid_table storage "
 			       "allocation failed\n", __FUNCTION__);
diff -puN drivers/s390/net/iucv.h~linus drivers/s390/net/iucv.h
--- 25/drivers/s390/net/iucv.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/net/iucv.h	2004-01-19 22:17:23.000000000 -0800
@@ -203,7 +203,7 @@ typedef struct {
 } iucv_array_t __attribute__ ((aligned (8)));
 
 extern struct bus_type iucv_bus;
-extern struct device iucv_root;
+extern struct device *iucv_root;
 
 /*   -prototypes-    */
 /*                                                                
diff -puN drivers/s390/net/lcs.c~linus drivers/s390/net/lcs.c
--- 25/drivers/s390/net/lcs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/net/lcs.c	2004-01-19 22:17:23.000000000 -0800
@@ -11,7 +11,7 @@
  *			  Frank Pavlic (pavlic@de.ibm.com) and
  *		 	  Martin Schwidefsky <schwidefsky@de.ibm.com>
  *
- *    $Revision: 1.58 $	 $Date: 2003/09/22 13:33:56 $
+ *    $Revision: 1.61 $	 $Date: 2003/12/02 15:18:50 $
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -58,7 +58,7 @@
 /**
  * initialization string for output
  */
-#define VERSION_LCS_C  "$Revision: 1.58 $"
+#define VERSION_LCS_C  "$Revision: 1.61 $"
 
 static char version[] __initdata = "LCS driver ("VERSION_LCS_C "/" VERSION_LCS_H ")";
 
@@ -1168,7 +1168,6 @@ __lcs_start_xmit(struct lcs_card *card, 
 		return -EIO;
 	}
 	if (card->state != DEV_STATE_UP) {
-		dst_link_failure(skb);
 		dev_kfree_skb(skb);
 		card->stats.tx_dropped++;
 		card->stats.tx_errors++;
@@ -1891,7 +1890,7 @@ lcs_shutdown_device(struct ccwgroup_devi
 /**
  * lcs_remove_device, free buffers and card
  */
-static int
+static void
 lcs_remove_device(struct ccwgroup_device *ccwgdev)
 {
 	struct lcs_card *card;
@@ -1899,12 +1898,18 @@ lcs_remove_device(struct ccwgroup_device
 	LCS_DBF_TEXT(3, setup, "remdev");
 	card = (struct lcs_card *)ccwgdev->dev.driver_data;
 	if (!card)
-		return 0;
+		return;
+	if (ccwgdev->state == CCWGROUP_ONLINE) {
+		lcs_stop_device(card->dev); /* Ignore rc. */
+		sysfs_remove_link(&card->dev->class_dev.kobj,
+				  ccwgdev->dev.bus_id);
+		sysfs_remove_link(&ccwgdev->dev.kobj, card->dev->name);
+		unregister_netdev(card->dev);
+	}
 	sysfs_remove_group(&ccwgdev->dev.kobj, &lcs_attr_group);
 	lcs_cleanup_card(card);
 	lcs_free_card(card);
 	put_device(&ccwgdev->dev);
-	return 0;
 }
 
 /**
diff -puN drivers/s390/net/netiucv.c~linus drivers/s390/net/netiucv.c
--- 25/drivers/s390/net/netiucv.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/net/netiucv.c	2004-01-19 22:17:23.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * $Id: netiucv.c,v 1.26 2003/09/23 16:48:17 mschwide Exp $
+ * $Id: netiucv.c,v 1.30 2003/12/02 12:29:32 braunu Exp $
  *
  * IUCV network driver
  *
@@ -30,7 +30,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * RELEASE-TAG: IUCV network driver $Revision: 1.26 $
+ * RELEASE-TAG: IUCV network driver $Revision: 1.30 $
  *
  */
 
@@ -1177,12 +1177,10 @@ static int netiucv_tx(struct sk_buff *sk
 
 	/**
 	 * If connection is not running, try to restart it
-	 * notify anybody about a link failure and throw
-	 * away packet. 
+	 * and throw away packet. 
 	 */
 	if (fsm_getstate(privptr->fsm) != DEV_STATE_RUNNING) {
 		fsm_event(privptr->fsm, DEV_EVENT_START, dev);
-		dst_link_failure(skb);
 		dev_kfree_skb(skb);
 		privptr->stats.tx_dropped++;
 		privptr->stats.tx_errors++;
@@ -1464,7 +1462,7 @@ netiucv_add_files(struct device *dev)
 		return ret;
 	ret = sysfs_create_group(&dev->kobj, &netiucv_stat_attr_group);
 	if (ret)
-		sysfs_remove_group(&dev->kobj, &netiucv_stat_attr_group);
+		sysfs_remove_group(&dev->kobj, &netiucv_attr_group);
 	return ret;
 }
 
@@ -1472,7 +1470,7 @@ static inline void
 netiucv_remove_files(struct device *dev)
 {
 	sysfs_remove_group(&dev->kobj, &netiucv_stat_attr_group);
-	sysfs_remove_group(&dev->kobj, &netiucv_stat_attr_group);
+	sysfs_remove_group(&dev->kobj, &netiucv_attr_group);
 }
 
 static int
@@ -1485,7 +1483,7 @@ netiucv_register_device(struct net_devic
 
 	snprintf(dev->bus_id, BUS_ID_SIZE, "%s%x", str, ifno);
 	dev->bus = &iucv_bus;
-	dev->parent = &iucv_root;
+	dev->parent = iucv_root;
 
 	ret = device_register(dev);
 
@@ -1731,7 +1729,7 @@ static struct device_driver netiucv_driv
 static void
 netiucv_banner(void)
 {
-	char vbuf[] = "$Revision: 1.26 $";
+	char vbuf[] = "$Revision: 1.30 $";
 	char *version = vbuf;
 
 	if ((version = strchr(version, ':'))) {
diff -puN drivers/s390/net/qeth.c~linus drivers/s390/net/qeth.c
--- 25/drivers/s390/net/qeth.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/net/qeth.c	2004-01-19 22:17:23.000000000 -0800
@@ -1,6 +1,6 @@
 /*
  *
- * linux/drivers/s390/net/qeth.c ($Revision: 1.160 $)
+ * linux/drivers/s390/net/qeth.c ($Revision: 1.177 $)
  *
  * Linux on zSeries OSA Express and HiperSockets support
  *
@@ -11,6 +11,7 @@
  *                                               numerous bugfixes)
  *            Frank Pavlic <pavlic@de.ibm.com>  (query/purge ARP, SNMP, fixes)
  *            Andreas Herrmann <aherrman@de.ibm.com> (bugfixes)
+ *            Thomas Spatzier <tspat@de.ibm.com> (bugfixes)
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -165,7 +166,7 @@ MODULE_PARM_DESC(qeth_sparebufs, "the nu
 		 "reserved for low memory situations");
 
 /****************** MODULE STUFF **********************************/
-#define VERSION_QETH_C "$Revision: 1.160 $"
+#define VERSION_QETH_C "$Revision: 1.177 $"
 static const char *version = "qeth S/390 OSA-Express driver ("
     VERSION_QETH_C "/" VERSION_QETH_H "/" VERSION_QETH_MPC_H
     QETH_VERSION_IPV6 QETH_VERSION_VLAN ")";
@@ -314,6 +315,21 @@ my_spin_lock_nonbusy(struct qeth_card *c
 	}
 }
 
+static int inline
+my_down_trylock_nonbusy(struct qeth_card *card, struct semaphore  *sema)
+{
+	for (;;) {
+		if (card) {
+			if (atomic_read(&card->shutdown_phase))
+				return -1;
+		}
+		if (down_trylock(sema))
+			return 0;
+		qeth_wait_nonbusy(QETH_IDLE_WAIT_TIME);
+	}
+}
+
+
 #ifdef CONFIG_ARCH_S390X
 #define QETH_GET_ADDR(x) ((__u32)(unsigned long)x)
 #else /* CONFIG_ARCH_S390X */
@@ -612,6 +628,10 @@ static int
 qeth_is_multicast_skb_at_all(struct sk_buff *skb, int version)
 {
 	int i;
+	struct qeth_card *card;
+
+	i = RTN_UNSPEC;
+	card = (struct qeth_card *)skb->dev->priv;
 	if (skb->dst && skb->dst->neighbour) {
 		i = skb->dst->neighbour->type;
 		return ((i == RTN_BROADCAST) ||
@@ -622,20 +642,38 @@ qeth_is_multicast_skb_at_all(struct sk_b
 		return ((skb->nh.raw[16] & 0xf0) == 0xe0) ? RTN_MULTICAST : 0;
 	} else if (version == 6) {
 		return (skb->nh.raw[24] == 0xff) ? RTN_MULTICAST : 0;
-	} else {
-		PRINT_STUPID("QETH_IP_VERSION is %x\n", version);
-		PRINT_STUPID("skb->protocol=x%x=%i\n",
-			     skb->protocol, skb->protocol);
-		HEXDUMP16(STUPID, "skb:", skb->data);
 	}
-	return 0;
+	if (!memcmp(skb->nh.raw, skb->dev->broadcast, 6)) {
+		i = RTN_BROADCAST;
+	} else {
+		__u16 hdr_mac;
+
+	        hdr_mac = *((__u16*)skb->nh.raw);
+	        /* tr multicast? */
+	        switch (card->link_type) {
+	        case QETH_MPC_LINK_TYPE_HSTR:
+	        case QETH_MPC_LINK_TYPE_LANE_TR:
+	        	if ((hdr_mac == QETH_TR_MAC_NC) ||
+			    (hdr_mac == QETH_TR_MAC_C))
+				i = RTN_MULTICAST;
+			break;
+	        /* eth or so multicast? */
+                default:
+                      	if ((hdr_mac == QETH_ETH_MAC_V4) ||
+			    (hdr_mac == QETH_ETH_MAC_V6))
+			        i = RTN_MULTICAST;
+	        }
+        }
+	return ((i == RTN_BROADCAST)||
+	        (i == RTN_MULTICAST)||
+	        (i == RTN_ANYCAST)) ? i : 0;
 }
 
 static int
 qeth_get_prioqueue(struct qeth_card *card, struct sk_buff *skb,
 		   int multicast, int version)
 {
-	if (!version)
+	if (!version && (card->type == QETH_CARD_TYPE_OSAE))
 		return QETH_DEFAULT_QUEUE;
 	switch (card->no_queues) {
 	case 1:
@@ -1327,7 +1365,7 @@ __qeth_rebuild_skb_fake_ll(struct qeth_c
 		       QETH_FAKE_LL_ADDR_LEN);
 	} else {
 		/* clear source MAC for security reasons */
-		memset(skb->mac.raw + QETH_FAKE_LL_DEST_MAC_POS,
+		memset(skb->mac.raw + QETH_FAKE_LL_SRC_MAC_POS,
 		       0, QETH_FAKE_LL_ADDR_LEN);
 	}
 	memcpy(skb->mac.raw + QETH_FAKE_LL_PROT_POS,
@@ -1947,7 +1985,6 @@ qeth_free_buffer(struct qeth_card *card,
 			case ERROR_LINK_FAILURE:
 			case ERROR_KICK_THAT_PUPPY:
 				QETH_DBF_TEXT4(0, trace, "endeglnd");
-				dst_link_failure(skb);
 				atomic_dec(&skb->users);
 				dev_kfree_skb_irq(skb);
 				break;
@@ -2425,7 +2462,6 @@ qeth_hard_start_xmit(struct sk_buff *skb
 
 	if (!card) {
 		QETH_DBF_TEXT2(0, trace, "XMNSNOCD");
-		dst_link_failure(skb);
 		dev_kfree_skb_irq(skb);
 		return 0;
 	}
@@ -2436,7 +2472,6 @@ qeth_hard_start_xmit(struct sk_buff *skb
 	if (!atomic_read(&card->is_startlaned)) {
 		card->stats->tx_carrier_errors++;
 		QETH_DBF_CARD2(0, trace, "XMNS", card);
-		dst_link_failure(skb);
 		dev_kfree_skb_irq(skb);
 		return 0;
 	}
@@ -2548,7 +2583,8 @@ static void
 qeth_wakeup_procfile(void)
 {
 	QETH_DBF_TEXT5(0, trace, "procwkup");
-	if (atomic_read(&qeth_procfile_ioctl_sem.count) <
+	/* is this if statement correct? */
+	if (atomic_read(&qeth_procfile_ioctl_sem.count) <=
 	    PROCFILE_SLEEP_SEM_MAX_VALUE)
 		up(&qeth_procfile_ioctl_sem);
 }
@@ -2558,7 +2594,6 @@ qeth_sleepon_procfile(void)
 {
 	QETH_DBF_TEXT5(0, trace, "procslp");
 	if (down_interruptible(&qeth_procfile_ioctl_sem)) {
-		up(&qeth_procfile_ioctl_sem);
 		return -ERESTARTSYS;
 	}
 	return 0;
@@ -2634,6 +2669,8 @@ again:
 		QETH_DBF_TEXT2(0, trace, "scd:doio");
 		sprintf(dbf_text, "%4x", (__s16) result);
 		QETH_DBF_TEXT2(0, trace, dbf_text);
+		/* re-enable qeth_send_control_data again */
+		atomic_set(&card->write_busy,0);
 		return NULL;
 	}
 
@@ -2644,7 +2681,7 @@ again:
 			atomic_set(&card->write_busy, 0);
 			return NULL;
 		}
-		rec_buf = card->ipa_buf;
+		rec_buf = card->dma_stuff->recbuf;
 		QETH_DBF_CARD2(0, trace, "scro", card);
 	} else {
 		if (qeth_sleepon(card, (setip) ? QETH_IPA_TIMEOUT :
@@ -3350,6 +3387,11 @@ qeth_send_setdelipm(struct qeth_card *ca
 			  (result==0xe00e)?"unsupported arp assist cmd": \
 			  (result==0xe00f)?"arp assist not enabled": \
 			  (result==0xe080)?"startlan disabled": \
+			  (result==0xf012)?"unicast IP address invalid": \
+			  (result==0xf013)?"multicast router limit reached": \
+			  (result==0xf014)?"stop assist not supported": \
+			  (result==0xf015)?"multicast assist not set": \
+			  (result==0xf080)?"VM: startlan disabled": \
 			  (result==-1)?"IPA communication timeout": \
 			  "unknown return code")
 
@@ -3392,7 +3434,8 @@ retry:
 		QETH_DBF_TEXT2(0, trace, dbf_text);
 	}
 
-	if (((result == -1) || (result == 0xe080)) && (retries--)) {
+	if (((result == -1) || (result == 0xe080) ||(result==0xf080)) &&
+	    (retries--)) {
 		QETH_DBF_CARD2(0, trace, "sipr", card);
 		if (ip_vers == 4) {
 			*((__u32 *) (&dbf_text[0])) = *((__u32 *) ip);
@@ -3557,8 +3600,8 @@ qeth_set_vipas(struct qeth_card *card, i
 							   le is last entry */
 	char dbf_text[15];
 	int result;
-	__u8 netmask[16] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+	__u8 netmask[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 	};
 	struct qeth_vipa_entry *priv_add_list = NULL;
 	struct qeth_vipa_entry *priv_del_list = NULL;
@@ -3576,9 +3619,10 @@ qeth_set_vipas(struct qeth_card *card, i
 			 * so we clone the entry */
 			ne = (struct qeth_vipa_entry *)
 			    kmalloc(sizeof (struct qeth_vipa_entry),
-				    GFP_KERNEL);
+				    GFP_ATOMIC);
 			if (ne) {
 				ne->version = e->version;
+				ne->flag = e->flag;
 				memcpy(ne->ip, e->ip, 16);
 				ne->next = priv_add_list;
 				priv_add_list = ne;
@@ -3613,6 +3657,7 @@ qeth_set_vipas(struct qeth_card *card, i
 				    GFP_KERNEL);
 			if (ne) {
 				ne->version = e->version;
+				ne->flag = e->flag;
 				memcpy(ne->ip, e->ip, 16);
 				ne->next = priv_del_list;
 				priv_del_list = ne;
@@ -3645,7 +3690,7 @@ qeth_set_vipas(struct qeth_card *card, i
 			sprintf(dbf_text, "%4x", result);
 			QETH_DBF_TEXT2(0, trace, dbf_text);
 			if (priv_add_list->version == 4) {
-				PRINT_ERR("going to leave vipa/rxip %08x"
+				PRINT_ERR("going to leave vipa/rxip x%08x"
 					  "unset...\n",
 					  *((__u32 *) & priv_add_list->ip[0]));
 				sprintf(dbf_text, "%08x",
@@ -4085,6 +4130,9 @@ __qeth_setipms_ipv6(struct qeth_card *ca
 	while (addr) {
 		if (qeth_is_ipma_in_list(addr,
 					 card->ip_mc_current_state.ipm6_ifa)) {
+			qeth_remove_mc_ifa_from_list(
+					&card->ip_mc_new_state.ipm6_ifa,
+					addr);
 			addr = addr->next;
 			continue;
 		}
@@ -4118,8 +4166,13 @@ __qeth_setipms_ipv6(struct qeth_card *ca
 				  CARD_BUS_ID(card), result);
  			sprintf(dbf_text, "sms6%4x", result);
  			QETH_DBF_TEXT3(0, trace, dbf_text);
-			qeth_remove_mc_ifa_from_list
-				(&card->ip_mc_current_state.ipm6_ifa, addr);
+		} else {
+			qeth_remove_mc_ifa_from_list(
+					&card->ip_mc_new_state.ipm6_ifa,
+					addr);
+			qeth_add_mc_ifa_to_list(
+					&card->ip_mc_current_state.ipm6_ifa,
+					addr);
 		}
 		addr = addr->next;
 	}
@@ -4555,7 +4608,7 @@ __qeth_takeover_ip_ipms6_mc(struct qeth_
 			ndisc_mc_map(&im6->mca_addr, buf, card->dev, 0);
 			ipmanew =
 			    (struct qeth_ipm_mac *)
-			    kmalloc(sizeof (struct qeth_ipm_mac), GFP_KERNEL);
+			    kmalloc(sizeof (struct qeth_ipm_mac), GFP_ATOMIC);
 			if (!ipmanew) {
 				PRINT_WARN("No memory for IPM address "
 					   "handling. Multicast IP "
@@ -4630,7 +4683,7 @@ qeth_takeover_ip_ipms6(struct qeth_card 
 
 		while (ifa) {
 			ifanew =
-			    kmalloc(sizeof (struct inet6_ifaddr), GFP_KERNEL);
+			    kmalloc(sizeof (struct inet6_ifaddr), GFP_ATOMIC);
 			if (!ifanew) {
 				PRINT_WARN("No memory for IP address "
 					   "handling. Some of the IPs "
@@ -4864,7 +4917,7 @@ __qeth_takeover_ip_ipms_mc(struct qeth_c
 			qeth_get_mac_for_ipm(im4->multiaddr, buf, in4_dev->dev);
 			ipmanew =
 			    (struct qeth_ipm_mac *)
-			    kmalloc(sizeof (struct qeth_ipm_mac), GFP_KERNEL);
+			    kmalloc(sizeof (struct qeth_ipm_mac), GFP_ATOMIC);
 			if (!ipmanew) {
 				PRINT_WARN("No memory for IPM address "
 					   "handling. Multicast IP %08x"
@@ -4930,7 +4983,7 @@ qeth_takeover_ip_ipms(struct qeth_card *
 		ifa = ((struct in_device *) card->dev->ip_ptr)->ifa_list;
 
 		while (ifa) {
-			ifanew = kmalloc(sizeof (struct in_ifaddr), GFP_KERNEL);
+			ifanew = kmalloc(sizeof (struct in_ifaddr), GFP_ATOMIC);
 			if (!ifanew) {
 				PRINT_WARN("No memory for IP address "
 					   "handling. Some of the IPs "
@@ -5212,7 +5265,7 @@ __qeth_softsetup_enable_ipv6(struct qeth
 			QETH_DBF_TEXT2(0, trace, dbf_text);
 			atomic_set(&card->is_softsetup, 0);
 			/* do not return an error */
-			if (result == 0xe080)
+			if ((result == 0xe080) || (result == 0xf080))
 				result = 0;
 			return result;
 		}
@@ -5300,13 +5353,17 @@ __qeth_softsetup_start_assists(struct qe
 				   "failure -- please check the "
 				   "network, plug in the cable or "
 				   "enable the OSA port" :
+				   (result==0xf080) ?
+				   "startlan disabled (VM: LAN " \
+				   "is offline for functions " \
+				   "requiring LAN access.":
 				   "unknown return code");
 			sprintf(dbf_text, "stln%4x", result);
 			QETH_DBF_TEXT2(0, trace, dbf_text);
 			atomic_set(&card->is_softsetup, 0);
 			atomic_set(&card->is_startlaned, 0);
 			/* do not return an error */
-			if (result == 0xe080) {
+			if ((result == 0xe080) || (result == 0xf080)) {
 				result = 0;
 			}
 			return result;
@@ -5527,7 +5584,10 @@ __qeth_softsetup_routingv6(struct qeth_c
 	if (!atomic_read(&card->enable_routing_attempts6))
 		return;
 
-	if (!card->options.routing_type6) {
+	if (!card->options.routing_type6 ||
+	    ((card->type == QETH_CARD_TYPE_OSAE) &&
+	    ((card->options.routing_type6&ROUTER_MASK) == MULTICAST_ROUTER) &&
+	    !qeth_is_supported6(IPA_OSA_MC_ROUTER_AVAIL))) {
 		atomic_set(&card->enable_routing_attempts6, 0);
 		atomic_set(&card->rt6fld, 0);
 		return;
@@ -5580,9 +5640,9 @@ qeth_softsetup_card(struct qeth_card *ca
 	int use_setip_retries = 1;
 
 	if (wait_for_lock == QETH_WAIT_FOR_LOCK) {
-		spin_lock(&card->softsetup_lock);
+		down(&card->softsetup_sema);
 	} else if (wait_for_lock == QETH_DONT_WAIT_FOR_LOCK) {
-		if (!spin_trylock(&card->softsetup_lock)) {
+		if (!down_trylock(&card->softsetup_sema)) {
 			return -EAGAIN;
 		}
 	} else if (wait_for_lock == QETH_LOCK_ALREADY_HELD) {
@@ -5634,7 +5694,7 @@ out:
 		netif_wake_queue(card->dev);
 	}
 	if (wait_for_lock != QETH_LOCK_ALREADY_HELD)
-		spin_unlock(&card->softsetup_lock);
+		up(&card->softsetup_sema);
 	return result;
 }
 
@@ -7835,7 +7895,7 @@ qeth_hardsetup_card(struct qeth_card *ca
 	cleanup_qdio = in_recovery;	/* if we are in recovery, we clean
 					   the qdio stuff up */
 
-	spin_lock(&card->hardsetup_lock);
+	down(&card->hardsetup_sema);
 	atomic_set(&card->write_busy, 0);
 
 	do {
@@ -8146,7 +8206,7 @@ qeth_hardsetup_card(struct qeth_card *ca
 	}
 
 exit:
-	spin_unlock(&card->hardsetup_lock);
+	up(&card->hardsetup_sema);
 	return result;
 }
 
@@ -8198,13 +8258,13 @@ qeth_reinit_thread(void *param)
 
 		atomic_set(&card->escape_softsetup, 1);
 
-		if (-1 == my_spin_lock_nonbusy(card, &card->softsetup_lock)) {
+		if (-1 == my_down_trylock_nonbusy(card, &card->softsetup_sema)) {
 			atomic_set(&card->escape_softsetup, 0);
 			goto out;
 		}
 		atomic_set(&card->escape_softsetup, 0);
 		if (atomic_read(&card->shutdown_phase)) {
-			spin_unlock(&card->softsetup_lock);
+			up(&card->softsetup_sema);
 			goto out_wakeup;
 		}
 		if (!qeth_verify_card(card))
@@ -8248,7 +8308,7 @@ qeth_reinit_thread(void *param)
 		} else {
 			QETH_DBF_TEXT1(0, trace, "ri-sftst");
 			qeth_softsetup_card(card, QETH_LOCK_ALREADY_HELD);
-			spin_unlock(&card->softsetup_lock);
+			up(&card->softsetup_sema);
 
 			if (!already_registered) {
 				QETH_DBF_TEXT1(0, trace, "ri-regcd");
@@ -8374,8 +8434,8 @@ qeth_alloc_card(void)
 
 	qeth_fill_qeth_card_options(card);
 
-	spin_lock_init(&card->softsetup_lock);
-	spin_lock_init(&card->hardsetup_lock);
+	init_MUTEX(&card->softsetup_sema);
+	init_MUTEX(&card->hardsetup_sema);
 	spin_lock_init(&card->ioctl_lock);
 #ifdef QETH_VLAN
 	spin_lock_init(&card->vlan_lock);
@@ -8571,7 +8631,8 @@ __qeth_correct_routing_status_v4(struct 
 		card->options.do_prio_queueing = NO_PRIO_QUEUEING;
 	} else {
 		/* if it's a mc router, it's no router */
-		if ((card->options.routing_type4 == MULTICAST_ROUTER) ||
+		if ((!qeth_is_supported(IPA_OSA_MC_ROUTER_AVAIL) &&
+		     (card->options.routing_type4 == MULTICAST_ROUTER)) ||
 		    (card->options.routing_type4 == PRIMARY_CONNECTOR) ||
 		    (card->options.routing_type4 == SECONDARY_CONNECTOR)) {
 			PRINT_WARN("routing not applicable, reset "
@@ -8599,7 +8660,8 @@ __qeth_correct_routing_status_v6(struct 
 		card->options.do_prio_queueing = NO_PRIO_QUEUEING;
 	} else {
 		/* if it's a mc router, it's no router */
-		if ((card->options.routing_type6 == MULTICAST_ROUTER) ||
+		if ((!qeth_is_supported(IPA_OSA_MC_ROUTER_AVAIL) &&
+		     (card->options.routing_type6 == MULTICAST_ROUTER)) ||
 		    (card->options.routing_type6 == PRIMARY_CONNECTOR) ||
 		    (card->options.routing_type6 == SECONDARY_CONNECTOR)) {
 			PRINT_WARN("routing not applicable, reset "
@@ -8851,11 +8913,11 @@ qeth_procfile_open(struct inode *inode, 
 
 	QETH_DBF_TEXT2(0, trace, "procread");
 	length += sprintf(buffer + length,
-			  "devices            CHPID     "
+			  "devices                  CHPID     "
 			  "device     cardtype port chksum prio-q'ing "
 			  "rtr fsz cnt\n");
 	length += sprintf(buffer + length,
-			  "-------------------- --- ----"
+			  "-------------------------- --- ----"
 			  "------ -------------- --     -- ---------- "
 			  "--- --- ---\n");
 	card = firstcard;
@@ -9509,19 +9571,20 @@ qeth_procfile_ioctl(struct inode *inode,
 {
 
 	int result;
-	down_interruptible(&qeth_procfile_ioctl_lock);
-	switch (cmd) {
-
-	case QETH_IOCPROC_OSAEINTERFACES:
-		result = qeth_procfile_getinterfaces(arg);
-		break;
-	case QETH_IOCPROC_INTERFACECHANGES:
-		result = qeth_procfile_interfacechanges(arg);
-		break;
-	default:
-		result = -EOPNOTSUPP;
-	}
-	up(&qeth_procfile_ioctl_lock);
+	if (!down_interruptible(&qeth_procfile_ioctl_lock)) {
+		switch (cmd) {
+			case QETH_IOCPROC_OSAEINTERFACES:
+				result = qeth_procfile_getinterfaces(arg);
+				break;
+			case QETH_IOCPROC_INTERFACECHANGES:
+				result = qeth_procfile_interfacechanges(arg);
+				break;
+			default:
+				result = -EOPNOTSUPP;
+		}
+		up(&qeth_procfile_ioctl_lock);
+	} else
+		result = -ERESTARTSYS;
 	return result;
 };
 
@@ -9779,15 +9842,7 @@ static struct ccw_driver qeth_ccw_driver
 	.remove = ccwgroup_remove_ccwdev,
 };
 
-static void
-qeth_root_dev_release (struct device *dev)
-{
-}
-
-static struct device qeth_root_dev = {
-	.bus_id = "qeth",
-	.release = qeth_root_dev_release,
-};
+static struct device *qeth_root_dev;
 
 static struct ccwgroup_driver qeth_ccwgroup_driver;
 static ssize_t
@@ -9813,7 +9868,7 @@ qeth_group_store(struct device_driver *d
 	}
 	pr_debug("creating qeth group device from '%s', '%s' and '%s'\n",
 		 bus_ids[0], bus_ids[1], bus_ids[2]);
-	ccwgroup_create(&qeth_root_dev, qeth_ccwgroup_driver.driver_id,
+	ccwgroup_create(qeth_root_dev, qeth_ccwgroup_driver.driver_id,
 			&qeth_ccw_driver, 3, argv);
 	return count;
 }
@@ -10675,19 +10730,6 @@ out:
 }
 
 static int
-qeth_remove_device(struct ccwgroup_device *gdev)
-{
-	struct qeth_card *card = gdev->dev.driver_data;
-
-	__qeth_remove_attributes(&gdev->dev);
-	gdev->dev.driver_data = NULL;
-	if (card)
-		qeth_free_card(card);
-	put_device(&gdev->dev);
-	return 0;
-}
-
-static int
 qeth_set_online(struct ccwgroup_device *gdev)
 {
 	int rc;
@@ -10723,6 +10765,21 @@ qeth_set_offline(struct ccwgroup_device 
 	return 0;
 }
 
+static void
+qeth_remove_device(struct ccwgroup_device *gdev)
+{
+	struct qeth_card *card = gdev->dev.driver_data;
+
+	if (card && qeth_does_card_exist(card))
+		/* Means that card is already in list. */
+		qeth_set_offline(gdev);
+	__qeth_remove_attributes(&gdev->dev);
+	gdev->dev.driver_data = NULL;
+	if (card)
+		qeth_free_card(card);
+	put_device(&gdev->dev);
+}
+
 static struct ccwgroup_driver qeth_ccwgroup_driver = {
 	.name = "qeth",
 	.driver_id = 0xD8C5E3C8,
@@ -10773,10 +10830,11 @@ qeth_init(void)
 	if (result)
 		goto out_cdrv;
 
-	result = device_register(&qeth_root_dev);
-	if (result)
+	qeth_root_dev = s390_root_dev_register("qeth");
+	if (IS_ERR(qeth_root_dev)) {
+		result = PTR_ERR(qeth_root_dev);
 		goto out_file;
-
+	}
 	qeth_register_notifiers();
 	qeth_add_procfs_entries();
 
@@ -10815,7 +10873,7 @@ qeth_exit(void)
 	driver_remove_file(&qeth_ccwgroup_driver.driver, &driver_attr_group);
 	ccw_driver_unregister(&qeth_ccw_driver);
 	ccwgroup_driver_unregister(&qeth_ccwgroup_driver);
-	device_unregister(&qeth_root_dev);
+	s390_root_dev_unregister(qeth_root_dev);
 
 	while (firstcard) {
 		struct qeth_card *card = firstcard;
diff -puN drivers/s390/net/qeth.h~linus drivers/s390/net/qeth.h
--- 25/drivers/s390/net/qeth.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/net/qeth.h	2004-01-19 22:17:23.000000000 -0800
@@ -14,7 +14,7 @@
 
 #define QETH_NAME " qeth"
 
-#define VERSION_QETH_H "$Revision: 1.58 $"
+#define VERSION_QETH_H "$Revision: 1.60 $"
 
 /******************** CONFIG STUFF ***********************/
 //#define QETH_DBF_LIKE_HELL
@@ -288,6 +288,12 @@
 #define QETH_HEADER_PASSTHRU	0x10
 #define QETH_HEADER_IPV6	0x80
 
+#define QETH_ETH_MAC_V4      0x0100 /* like v4 */
+#define QETH_ETH_MAC_V6      0x3333 /* like v6 */
+/* tr mc mac is longer, but that will be enough to detect mc frames */
+#define QETH_TR_MAC_NC       0xc000 /* non-canonical */
+#define QETH_TR_MAC_C        0x0300 /* canonical */
+
 #define QETH_CAST_FLAGS		0x07
 #define QETH_CAST_UNICAST	6
 #define QETH_CAST_MULTICAST	4
@@ -888,8 +894,8 @@ struct qeth_card {	/* pointed to by dev-
 	atomic_t is_open;	/* card is in use */
 
 	/* prevents deadlocks :-O */
-	spinlock_t softsetup_lock;
-	spinlock_t hardsetup_lock;
+	struct semaphore softsetup_sema;
+	struct semaphore hardsetup_sema;
 	spinlock_t ioctl_lock;
 	atomic_t softsetup_thread_is_running;
 	struct semaphore softsetup_thread_sem;
diff -puN drivers/s390/net/qeth_mpc.h~linus drivers/s390/net/qeth_mpc.h
--- 25/drivers/s390/net/qeth_mpc.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/net/qeth_mpc.h	2004-01-19 22:17:23.000000000 -0800
@@ -10,7 +10,7 @@
 #ifndef __QETH_MPC_H__
 #define __QETH_MPC_H__
 
-#define VERSION_QETH_MPC_H "$Revision: 1.16 $"
+#define VERSION_QETH_MPC_H "$Revision: 1.18 $"
 
 #define QETH_IPA_TIMEOUT (card->ipa_timeout)
 #define QETH_MPC_TIMEOUT 2000
@@ -143,6 +143,7 @@ extern unsigned char DM_ACT[];
 #define IPA_PASSTHRU 0x00001000L
 #define IPA_FULL_VLAN 0x00004000L
 #define IPA_SOURCE_MAC_AVAIL 0x00010000L
+#define IPA_OSA_MC_ROUTER_AVAIL 0x00020000L
 
 #define IPA_SETADP_QUERY_COMMANDS_SUPPORTED 0x01
 #define IPA_SETADP_ALTER_MAC_ADDRESS 0x02
@@ -319,8 +320,9 @@ struct ipa_cmd{
 }__attribute__ ((packed));
 
 #define QETH_IOC_MAGIC 0x22
-#define QETH_IOCPROC_OSAEINTERFACES _IOWR(QETH_IOC_MAGIC, 1, arg)
-#define QETH_IOCPROC_INTERFACECHANGES _IOWR(QETH_IOC_MAGIC, 2, arg)
+/* these don't really have 'unsigned long' arguments but were defined that way */
+#define QETH_IOCPROC_OSAEINTERFACES _IOWR(QETH_IOC_MAGIC, 1, unsigned long)
+#define QETH_IOCPROC_INTERFACECHANGES _IOWR(QETH_IOC_MAGIC, 2, unsigned long)
 
 #define SNMP_QUERY_CARD_INFO 0x00000002L
 #define SNMP_REGISETER_MIB   0x00000004L
diff -puN drivers/s390/s390mach.c~linus drivers/s390/s390mach.c
--- 25/drivers/s390/s390mach.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/s390mach.c	2004-01-19 22:17:23.000000000 -0800
@@ -19,9 +19,12 @@
 #define DBG printk
 // #define DBG(args,...) do {} while (0);
 
+static struct semaphore s_sem;
+
 extern void css_process_crw(int);
 extern void chsc_process_crw(void);
 extern void chp_process_crw(int, int);
+extern void css_reiterate_subchannels(void);
 
 static void
 s390_handle_damage(char *msg)
@@ -38,12 +41,19 @@ s390_handle_damage(char *msg)
  *
  * Note : we currently process CRWs for io and chsc subchannels only
  */
-static void
-s390_collect_crw_info(void)
+static int
+s390_collect_crw_info(void *param)
 {
 	struct crw crw;
 	int ccode;
+	struct semaphore *sem;
 
+	sem = (struct semaphore *)param;
+	/* Set a nice name. */
+	daemonize("kmcheck");
+
+repeat:
+	down_interruptible(sem);
 	while (1) {
 		ccode = stcrw(&crw);
 		if (ccode != 0)
@@ -52,6 +62,12 @@ s390_collect_crw_info(void)
 		    "chn=%d, rsc=%X, anc=%d, erc=%X, rsid=%X\n",
 		    crw.slct, crw.oflw, crw.chn, crw.rsc, crw.anc,
 		    crw.erc, crw.rsid);
+		/* Check for overflows. */
+		if (crw.oflw) {
+			pr_debug("%s: crw overflow detected!\n", __FUNCTION__);
+			css_reiterate_subchannels();
+			continue;
+		}
 		switch (crw.rsc) {
 		case CRW_RSC_SCH:
 			pr_debug("source is subchannel %04X\n", crw.rsid);
@@ -86,6 +102,8 @@ s390_collect_crw_info(void)
 			break;
 		}
 	}
+	goto repeat;
+	return 0;
 }
 
 /*
@@ -122,7 +140,7 @@ s390_do_machine_check(void)
 				   "check\n");
 
 	if (mci->cp)		/* channel report word pending */
-		s390_collect_crw_info();
+		up(&s_sem);
 
 #ifdef CONFIG_MACHCHK_WARNING
 /*
@@ -154,6 +172,7 @@ s390_do_machine_check(void)
 static int
 machine_check_init(void)
 {
+	init_MUTEX_LOCKED( &s_sem );
 	ctl_clear_bit(14, 25);	/* disable damage MCH */
 	ctl_set_bit(14, 26);	/* enable degradation MCH */
 	ctl_set_bit(14, 27);	/* enable system recovery MCH */
@@ -176,6 +195,7 @@ arch_initcall(machine_check_init);
 static int __init
 machine_check_crw_init (void)
 {
+	kernel_thread(s390_collect_crw_info, &s_sem, CLONE_FS|CLONE_FILES);
 	ctl_set_bit(14, 28);	/* enable channel report MCH */
 	return 0;
 }
diff -puN drivers/s390/scsi/zfcp_aux.c~linus drivers/s390/scsi/zfcp_aux.c
--- 25/drivers/s390/scsi/zfcp_aux.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/scsi/zfcp_aux.c	2004-01-19 22:17:23.000000000 -0800
@@ -28,7 +28,7 @@
  */
 
 /* this drivers version (do not edit !!! generated and updated by cvs) */
-#define ZFCP_AUX_REVISION "$Revision: 1.65 $"
+#define ZFCP_AUX_REVISION "$Revision: 1.79 $"
 
 /********************** INCLUDES *********************************************/
 
@@ -63,6 +63,7 @@
 
 /* accumulated log level (module parameter) */
 static u32 loglevel = ZFCP_LOG_LEVEL_DEFAULTS;
+static char *device;
 /*********************** FUNCTION PROTOTYPES *********************************/
 
 /* written against the module interface */
@@ -94,13 +95,14 @@ MODULE_AUTHOR("Heiko Carstens <heiko.car
 	      "Wolfgang Taphorn <taphorn@de.ibm.com>, "
 	      "Aron Zeh <arzeh@de.ibm.com>, "
 	      "IBM Deutschland Entwicklung GmbH");
-/* what this driver module is about */
 MODULE_DESCRIPTION
     ("FCP (SCSI over Fibre Channel) HBA driver for IBM eServer zSeries");
 MODULE_LICENSE("GPL");
-/* log level may be provided as a module parameter */
+
+module_param(device, charp, 0);
+MODULE_PARM_DESC(device, "specify initial device");
+
 module_param(loglevel, uint, 0);
-/* short explaination of the previous module parameter */
 MODULE_PARM_DESC(loglevel,
 		 "log levels, 8 nibbles: "
 		 "(unassigned) ERP QDIO DIO Config FSF SCSI Other, "
@@ -285,7 +287,7 @@ zfcp_cmd_dbf_event_scsi(const char *text
 	debug_event(adapter->cmd_dbf, level, &scsi_cmnd->result, sizeof (u32));
 	debug_event(adapter->cmd_dbf, level, &scsi_cmnd,
 		    sizeof (unsigned long));
-	if (fsf_req) {
+	if (likely(fsf_req)) {
 		debug_event(adapter->cmd_dbf, level, &fsf_req,
 			    sizeof (unsigned long));
 		debug_event(adapter->cmd_dbf, level, &fsf_req->seq_no,
@@ -316,6 +318,84 @@ zfcp_in_els_dbf_event(struct zfcp_adapte
 #endif
 }
 
+/**
+ * zfcp_device_setup - setup function
+ * @str: pointer to parameter string
+ *
+ * Parse "device=..." parameter string.
+ */
+static int __init
+zfcp_device_setup(char *str)
+{
+	char *tmp;
+
+	if (!str)
+		return 0;
+
+	tmp = strchr(str, ',');
+	if (!tmp)
+		goto err_out;
+	*tmp++ = '\0';
+	strncpy(zfcp_data.init_busid, str, BUS_ID_SIZE);
+	zfcp_data.init_busid[BUS_ID_SIZE-1] = '\0';
+
+	zfcp_data.init_wwpn = simple_strtoull(tmp, &tmp, 0);
+	if (*tmp++ != ',')
+		goto err_out;
+	if (*tmp == '\0')
+		goto err_out;
+
+	zfcp_data.init_fcp_lun = simple_strtoull(tmp, &tmp, 0);
+	if (*tmp != '\0')
+		goto err_out;
+	return 1;
+
+ err_out:
+	ZFCP_LOG_NORMAL("Parse error for device parameter string %s\n", str);
+	return 0;
+}
+
+static void __init
+zfcp_init_device_configure(void)
+{
+	int found = 0;
+	unsigned long flags;
+	struct zfcp_adapter *adapter;
+	struct zfcp_port *port;
+	struct zfcp_unit *unit;
+
+	down(&zfcp_data.config_sema);
+	read_lock_irqsave(&zfcp_data.config_lock, flags);
+	list_for_each_entry(adapter, &zfcp_data.adapter_list_head, list)
+		if (strcmp(zfcp_data.init_busid,
+			   zfcp_get_busid_by_adapter(adapter)) == 0) {
+			zfcp_adapter_get(adapter);
+			found = 1;
+			break;
+		}
+	read_unlock_irqrestore(&zfcp_data.config_lock, flags);
+	if (!found)
+		goto out_adapter;
+	port = zfcp_port_enqueue(adapter, zfcp_data.init_wwpn, 0);
+	if (!port)
+		goto out_port;
+	unit = zfcp_unit_enqueue(port, zfcp_data.init_fcp_lun);
+	if (!unit)
+		goto out_unit;
+	up(&zfcp_data.config_sema);
+	ccw_device_set_online(adapter->ccw_device);
+	down(&zfcp_data.config_sema);
+	wait_event(unit->scsi_add_wq, atomic_read(&unit->scsi_add_work) == 0);
+	zfcp_unit_put(unit);
+ out_unit:
+	zfcp_port_put(port);
+ out_port:
+	zfcp_adapter_put(adapter);
+ out_adapter:
+	up(&zfcp_data.config_sema);
+	return;
+}
+
 static int __init
 zfcp_module_init(void)
 {
@@ -357,9 +437,14 @@ zfcp_module_init(void)
 		ZFCP_LOG_NORMAL("Registering with common I/O layer failed.\n");
 		goto out_ccw_register;
 	}
+
+	if (zfcp_device_setup(device))
+		zfcp_init_device_configure();
+
 	goto out;
 
  out_ccw_register:
+	unregister_reboot_notifier(&zfcp_data.reboot_notifier);
 #ifdef ZFCP_STAT_REQSIZES
 	zfcp_statistics_clear_all();
 #endif
@@ -391,13 +476,8 @@ int
 zfcp_reboot_handler(struct notifier_block *notifier, unsigned long code,
 		    void *ptr)
 {
-	int retval = NOTIFY_DONE;
-
-	/* block access to config (for rest of lifetime of this Linux) */
-	down(&zfcp_data.config_sema);
-	zfcp_erp_adapter_shutdown_all();
-
-	return retval;
+	zfcp_ccw_unregister();
+	return NOTIFY_DONE;
 }
 
 #undef ZFCP_LOG_AREA
@@ -410,19 +490,6 @@ zfcp_reboot_handler(struct notifier_bloc
 #define ZFCP_LOG_AREA			ZFCP_LOG_AREA_CONFIG
 #define ZFCP_LOG_AREA_PREFIX		ZFCP_LOG_AREA_PREFIX_CONFIG
 
-#ifndef MODULE
-/* zfcp_loglevel boot_parameter */
-static int __init
-zfcp_loglevel_setup(char *str)
-{
-	loglevel = simple_strtoul(str, NULL, 0);
-	ZFCP_LOG_TRACE("loglevel is 0x%x\n", loglevel);
-	return 1;		/* why just 1? */
-}
-
-__setup("zfcp_loglevel=", zfcp_loglevel_setup);
-#endif				/* not MODULE */
-
 /**
  * zfcp_get_unit_by_lun - find unit in unit list of port by fcp lun
  * @port: pointer to port to search for unit
@@ -503,6 +570,7 @@ zfcp_unit_enqueue(struct zfcp_port *port
 		return NULL;
 	memset(unit, 0, sizeof (struct zfcp_unit));
 
+	init_waitqueue_head(&unit->scsi_add_wq);
 	/* initialise reference count stuff */
 	atomic_set(&unit->refcount, 0);
 	init_waitqueue_head(&unit->remove_wq);
@@ -571,6 +639,7 @@ zfcp_unit_enqueue(struct zfcp_port *port
 	write_unlock_irq(&zfcp_data.config_lock);
 
 	port->units++;
+	zfcp_port_get(port);
 
 	return unit;
 }
@@ -763,17 +832,10 @@ zfcp_adapter_enqueue(struct ccw_device *
 	/* initialize abort lock */
 	rwlock_init(&adapter->abort_lock);
 
-	/* initialise scsi faking structures */
-	rwlock_init(&adapter->fake_list_lock);
-	init_timer(&adapter->fake_scsi_timer);
-
 	/* initialise some erp stuff */
 	init_waitqueue_head(&adapter->erp_thread_wqh);
 	init_waitqueue_head(&adapter->erp_done_wqh);
 
-	/* notification when there are no outstanding SCSI commands */
-	init_waitqueue_head(&adapter->scsi_reqs_active_wq);
-
 	/* initialize lock of associated request queue */
 	rwlock_init(&adapter->request_queue.queue_lock);
 
@@ -904,7 +966,6 @@ zfcp_adapter_enqueue(struct ccw_device *
 	/* put allocated adapter at list tail */
 	write_lock_irq(&zfcp_data.config_lock);
 	atomic_clear_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status);
-	atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING, &adapter->status);
 	list_add_tail(&adapter->list, &zfcp_data.adapter_list_head);
 	write_unlock_irq(&zfcp_data.config_lock);
 
@@ -1149,6 +1210,7 @@ zfcp_port_enqueue(struct zfcp_adapter *a
 	write_unlock_irq(&zfcp_data.config_lock);
 
 	adapter->ports++;
+	zfcp_adapter_get(adapter);
 
 	return port;
 }
@@ -1193,7 +1255,6 @@ zfcp_nameserver_enqueue(struct zfcp_adap
 	/* set special D_ID */
 	port->d_id = ZFCP_DID_NAMESERVER;
 	adapter->nameserver_port = port;
-	zfcp_adapter_get(adapter);
 	zfcp_port_put(port);
 
 	return 0;
@@ -1216,9 +1277,9 @@ zfcp_fsf_incoming_els_rscn(struct zfcp_a
 	struct fcp_rscn_head *fcp_rscn_head;
 	struct fcp_rscn_element *fcp_rscn_element;
 	struct zfcp_port *port;
-	int i;
-	int reopen_unknown = 0;
-	int no_entries;
+	u16 i;
+	u16 no_entries;
+	u32 range_mask;
 	unsigned long flags;
 
 	fcp_rscn_head = (struct fcp_rscn_head *) status_buffer->payload;
@@ -1232,56 +1293,57 @@ zfcp_fsf_incoming_els_rscn(struct zfcp_a
 
 	debug_text_event(adapter->erp_dbf, 1, "unsol_els_rscn:");
 	for (i = 1; i < no_entries; i++) {
-		int known;
-		int range_mask;
-		int no_notifications;
-
-		range_mask = 0;
-		no_notifications = 0;
-		known = 0;
 		/* skip head and start with 1st element */
 		fcp_rscn_element++;
 		switch (fcp_rscn_element->addr_format) {
 		case ZFCP_PORT_ADDRESS:
 			ZFCP_LOG_FLAGS(1, "ZFCP_PORT_ADDRESS\n");
 			range_mask = ZFCP_PORTS_RANGE_PORT;
-			no_notifications = 1;
 			break;
 		case ZFCP_AREA_ADDRESS:
 			ZFCP_LOG_FLAGS(1, "ZFCP_AREA_ADDRESS\n");
-			/* skip head and start with 1st element */
 			range_mask = ZFCP_PORTS_RANGE_AREA;
-			no_notifications = ZFCP_NO_PORTS_PER_AREA;
 			break;
 		case ZFCP_DOMAIN_ADDRESS:
 			ZFCP_LOG_FLAGS(1, "ZFCP_DOMAIN_ADDRESS\n");
 			range_mask = ZFCP_PORTS_RANGE_DOMAIN;
-			no_notifications = ZFCP_NO_PORTS_PER_DOMAIN;
 			break;
 		case ZFCP_FABRIC_ADDRESS:
 			ZFCP_LOG_FLAGS(1, "ZFCP_FABRIC_ADDRESS\n");
 			range_mask = ZFCP_PORTS_RANGE_FABRIC;
-			no_notifications = ZFCP_NO_PORTS_PER_FABRIC;
 			break;
 		default:
-			/* cannot happen */
-			break;
+			ZFCP_LOG_INFO("Received RSCN with unknown "
+				      "address format.\n");
+			continue;
 		}
 		read_lock_irqsave(&zfcp_data.config_lock, flags);
 		list_for_each_entry(port, &adapter->port_list_head, list) {
+			if (atomic_test_mask
+			    (ZFCP_STATUS_PORT_NAMESERVER, &port->status))
+				continue;
 			/* Do we know this port? If not skip it. */
 			if (!atomic_test_mask
-			    (ZFCP_STATUS_PORT_DID_DID, &port->status))
+			    (ZFCP_STATUS_PORT_DID_DID, &port->status)) {
+				ZFCP_LOG_INFO
+					("Received state change notification."
+					 "Trying to open the port with wwpn "
+					 "0x%Lx. Hope it's there now.\n",
+					 port->wwpn);
+				debug_text_event(adapter->erp_dbf, 1,
+						 "unsol_els_rscnu:");
+				zfcp_erp_port_reopen(port,
+						     ZFCP_STATUS_COMMON_ERP_FAILED);
 				continue;
+			}
+
 			/*
 			 * FIXME: race: d_id might being invalidated
 			 * (...DID_DID reset)
 			 */
 			if ((port->d_id & range_mask)
 			    == (fcp_rscn_element->nport_did & range_mask)) {
-				known++;
-				ZFCP_LOG_TRACE("known=%d, reopen did 0x%x\n",
-					       known,
+				ZFCP_LOG_TRACE("reopen did 0x%x\n",
 					       fcp_rscn_element->nport_did);
 				/*
 				 * Unfortunately, an RSCN does not specify the
@@ -1303,36 +1365,6 @@ zfcp_fsf_incoming_els_rscn(struct zfcp_a
 			}
 		}
 		read_unlock_irqrestore(&zfcp_data.config_lock, flags);
-		ZFCP_LOG_TRACE("known %d, no_notifications %d\n",
-			       known, no_notifications);
-		if (known < no_notifications) {
-			ZFCP_LOG_DEBUG
-			    ("At least one unknown port changed state. "
-			     "Unknown ports need to be reopened.\n");
-			reopen_unknown = 1;
-		}
-	}			// for (i=1; i < no_entries; i++)
-
-	if (reopen_unknown) {
-		ZFCP_LOG_DEBUG("At least one unknown did "
-			       "underwent a state change.\n");
-		read_lock_irqsave(&zfcp_data.config_lock, flags);
-		list_for_each_entry(port, &adapter->port_list_head, list) {
-			if (!atomic_test_mask((ZFCP_STATUS_PORT_DID_DID
-					       | ZFCP_STATUS_PORT_NAMESERVER),
-					      &port->status)) {
-				ZFCP_LOG_INFO
-				    ("Received state change notification."
-				     "Trying to open the port with wwpn "
-				     "0x%Lx. Hope it's there now.\n",
-				     port->wwpn);
-				debug_text_event(adapter->erp_dbf, 1,
-						 "unsol_els_rscnu:");
-				zfcp_erp_port_reopen(port,
-						     ZFCP_STATUS_COMMON_ERP_FAILED);
-			}
-		}
-		read_unlock_irqrestore(&zfcp_data.config_lock, flags);
 	}
 }
 
@@ -1469,7 +1501,7 @@ zfcp_get_nameserver_buffers(struct zfcp_
 	struct zfcp_adapter *adapter = fsf_req->adapter;
 	int retval = 0;
 
-	data->outbuf = kmalloc(2 * sizeof (struct fc_ct_iu), GFP_KERNEL);
+	data->outbuf = kmalloc(2 * sizeof (struct fc_ct_iu), GFP_ATOMIC);
 	if (data->outbuf) {
 		memset(data->outbuf, 0, 2 * sizeof (struct fc_ct_iu));
 	} else {
@@ -1479,7 +1511,7 @@ zfcp_get_nameserver_buffers(struct zfcp_
 			       "adapter %s directly.. trying emergency pool\n",
 			       zfcp_get_busid_by_adapter(adapter));
 		data->outbuf =
-		    mempool_alloc(adapter->pool.nameserver, GFP_KERNEL);
+		    mempool_alloc(adapter->pool.nameserver, GFP_ATOMIC);
 		if (!data->outbuf) {
 			ZFCP_LOG_DEBUG
 				("Out of memory. Could not get emergency "
diff -puN drivers/s390/scsi/zfcp_ccw.c~linus drivers/s390/scsi/zfcp_ccw.c
--- 25/drivers/s390/scsi/zfcp_ccw.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/scsi/zfcp_ccw.c	2004-01-19 22:17:23.000000000 -0800
@@ -25,7 +25,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#define ZFCP_CCW_C_REVISION "$Revision: 1.33 $"
+#define ZFCP_CCW_C_REVISION "$Revision: 1.36 $"
 
 #include <linux/init.h>
 #include <linux/module.h>
@@ -37,7 +37,7 @@
 #define ZFCP_LOG_AREA_PREFIX            ZFCP_LOG_AREA_PREFIX_CONFIG
 
 static int zfcp_ccw_probe(struct ccw_device *);
-static int zfcp_ccw_remove(struct ccw_device *);
+static void zfcp_ccw_remove(struct ccw_device *);
 static int zfcp_ccw_set_online(struct ccw_device *);
 static int zfcp_ccw_set_offline(struct ccw_device *);
 
@@ -90,16 +90,17 @@ zfcp_ccw_probe(struct ccw_device *ccw_de
  *
  * This function gets called by the common i/o layer and removes an adapter
  * from the system. Task of this function is to get rid of all units and
- * ports that belong to this adapter. And addition all resources of this
+ * ports that belong to this adapter. And in addition all resources of this
  * adapter will be freed too.
  */
-static int
+static void
 zfcp_ccw_remove(struct ccw_device *ccw_device)
 {
 	struct zfcp_adapter *adapter;
 	struct zfcp_port *port, *p;
 	struct zfcp_unit *unit, *u;
 
+	ccw_device_set_offline(ccw_device);
 	down(&zfcp_data.config_sema);
 	adapter = dev_get_drvdata(&ccw_device->dev);
 
@@ -119,16 +120,18 @@ zfcp_ccw_remove(struct ccw_device *ccw_d
 	list_for_each_entry_safe(port, p, &adapter->port_remove_lh, list) {
 		list_for_each_entry_safe(unit, u, &port->unit_remove_lh, list) {
 			zfcp_unit_wait(unit);
+			zfcp_sysfs_unit_remove_files(&unit->sysfs_device);
 			device_unregister(&unit->sysfs_device);
 		}
 		zfcp_port_wait(port);
+		zfcp_sysfs_port_remove_files(&port->sysfs_device,
+					     atomic_read(&port->status));
 		device_unregister(&port->sysfs_device);
 	}
 	zfcp_adapter_wait(adapter);
 	zfcp_adapter_dequeue(adapter);
 
 	up(&zfcp_data.config_sema);
-	return 0;
 }
 
 /**
@@ -155,6 +158,7 @@ zfcp_ccw_set_online(struct ccw_device *c
 	zfcp_erp_modify_adapter_status(adapter, ZFCP_STATUS_COMMON_RUNNING,
 				       ZFCP_SET);
 	zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED);
+	zfcp_erp_wait(adapter);
  out:
 	up(&zfcp_data.config_sema);
 	return retval;
diff -puN drivers/s390/scsi/zfcp_def.h~linus drivers/s390/scsi/zfcp_def.h
--- 25/drivers/s390/scsi/zfcp_def.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/scsi/zfcp_def.h	2004-01-19 22:17:23.000000000 -0800
@@ -31,10 +31,8 @@
 #ifndef ZFCP_DEF_H
 #define ZFCP_DEF_H
 
-#ifdef __KERNEL__
-
 /* this drivers version (do not edit !!! generated and updated by cvs) */
-#define ZFCP_DEF_REVISION "$Revision: 1.41 $"
+#define ZFCP_DEF_REVISION "$Revision: 1.48 $"
 
 /*************************** INCLUDES *****************************************/
 
@@ -64,7 +62,6 @@
 typedef u32 scsi_id_t;
 typedef u32 scsi_lun_t;
 
-#define ZFCP_FAKE_SCSI_COMPLETION_TIME	        (HZ / 3)
 #define ZFCP_ERP_SCSI_LOW_MEM_TIMEOUT           (100*HZ)
 #define ZFCP_SCSI_ER_TIMEOUT                    (100*HZ)
 #define ZFCP_SCSI_HOST_FLUSH_TIMEOUT            (1*HZ)
@@ -470,7 +467,6 @@ extern u32 flags_dump;
 #define ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL	0x00000080
 #define ZFCP_STATUS_ADAPTER_ERP_PENDING		0x00000100
 #define ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED	0x00000200
-#define ZFCP_STATUS_ADAPTER_QUEUECOMMAND_BLOCK	0x00000400 
 
 #define ZFCP_STATUS_ADAPTER_SCSI_UP			\
 		(ZFCP_STATUS_COMMON_UNBLOCKED |	\
@@ -676,10 +672,7 @@ struct zfcp_adapter {
 	u32			hydra_version;	   /* Hydra version */
 	u32			fsf_lic_version;
 	struct Scsi_Host	*scsi_host;	   /* Pointer to mid-layer */
-        Scsi_Cmnd               *first_fake_cmnd;  /* Packets in flight list */
-	rwlock_t		fake_list_lock;    /* Lock for the above */
-	struct timer_list       fake_scsi_timer;   /* Starts processing of
-						      faked commands */
+
 	unsigned char		name[9];
 	struct list_head	port_list_head;	   /* remote port list */
 	struct list_head        port_remove_lh;    /* head of ports to be
@@ -692,9 +685,6 @@ struct zfcp_adapter {
 	rwlock_t		fsf_req_list_lock; /* lock for ops on list of
 						      FSF requests */
         atomic_t       		fsf_reqs_active;   /* # active FSF reqs */
-        atomic_t       		scsi_reqs_active;  /* # active SCSI reqs */
-	wait_queue_head_t	scsi_reqs_active_wq; /* can be used to wait for
-							fsf_reqs_active chngs */
 	struct zfcp_qdio_queue	request_queue;	   /* request queue */
 	u32			fsf_req_seq_no;	   /* FSF cmnd seq number */
 	wait_queue_head_t	request_wq;	   /* can be used to wait for
@@ -765,6 +755,8 @@ struct zfcp_unit {
 	struct zfcp_erp_action erp_action;     /* pending error recovery */
         atomic_t               erp_counter;
 	struct device          sysfs_device;   /* sysfs device */
+	atomic_t               scsi_add_work;  /* used to synchronize */
+	wait_queue_head_t      scsi_add_wq;    /* wait for scsi_add_device */
 };
 
 /* FSF request */
@@ -809,6 +801,9 @@ struct zfcp_data {
 	struct notifier_block	reboot_notifier;     /* used to register cleanup
 							functions */
 	atomic_t		loglevel;            /* current loglevel */
+	char                    init_busid[BUS_ID_SIZE];
+	wwn_t                   init_wwpn;
+	fcp_lun_t               init_fcp_lun;
 #ifdef ZFCP_STAT_REQSIZES                            /* Statistical accounting
 							of processed data */
 	struct list_head	read_req_head;
@@ -857,7 +852,7 @@ struct zfcp_statistics {
 
 #ifndef atomic_test_mask
 #define atomic_test_mask(mask, target) \
-           (atomic_read(target) & mask)
+           ((atomic_read(target) & mask) == mask)
 #endif
 
 extern void _zfcp_hex_dump(char *, int);
@@ -957,5 +952,4 @@ zfcp_adapter_wait(struct zfcp_adapter *a
 	wait_event(adapter->remove_wq, atomic_read(&adapter->refcount) == 0);
 }
 
-#endif /* __KERNEL_- */
 #endif /* ZFCP_DEF_H */
diff -puN drivers/s390/scsi/zfcp_erp.c~linus drivers/s390/scsi/zfcp_erp.c
--- 25/drivers/s390/scsi/zfcp_erp.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/scsi/zfcp_erp.c	2004-01-19 22:17:23.000000000 -0800
@@ -30,7 +30,7 @@
 #define ZFCP_LOG_AREA			ZFCP_LOG_AREA_ERP
 #define ZFCP_LOG_AREA_PREFIX		ZFCP_LOG_AREA_PREFIX_ERP
 /* this drivers version (do not edit !!! generated and updated by cvs) */
-#define ZFCP_ERP_REVISION "$Revision: 1.33 $"
+#define ZFCP_ERP_REVISION "$Revision: 1.39 $"
 
 #include "zfcp_ext.h"
 
@@ -108,6 +108,9 @@ static int zfcp_erp_action_dismiss(struc
 static int zfcp_erp_action_enqueue(int, struct zfcp_adapter *,
 				   struct zfcp_port *, struct zfcp_unit *);
 static int zfcp_erp_action_dequeue(struct zfcp_erp_action *);
+static void zfcp_erp_action_cleanup(int, struct zfcp_adapter *,
+				    struct zfcp_port *, struct zfcp_unit *,
+				    int);
 
 static void zfcp_erp_action_ready(struct zfcp_erp_action *);
 static int  zfcp_erp_action_exists(struct zfcp_erp_action *);
@@ -1160,6 +1163,9 @@ zfcp_erp_strategy(struct zfcp_erp_action
 	write_unlock(&adapter->erp_lock);
 	read_unlock_irqrestore(&zfcp_data.config_lock, flags);
 	
+	if (retval != ZFCP_ERP_CONTINUES)
+		zfcp_erp_action_cleanup(action, adapter, port, unit, retval);
+
 	/*
 	 * a few tasks remain when the erp queues are empty
 	 * (don't do that if the last action evaluated was dismissed
@@ -1451,6 +1457,66 @@ zfcp_erp_strategy_statechange_detected(a
 	     !(ZFCP_STATUS_ERP_CLOSE_ONLY & erp_status));
 }
 
+/**
+ * zfcp_erp_scsi_add_device
+ * @data: pointer to a struct zfcp_unit
+ *
+ * Registers a logical unit with the SCSI stack.
+ */
+static void
+zfcp_erp_scsi_add_device(void *data)
+{
+	struct {
+		struct zfcp_unit  *unit;
+		struct work_struct work;
+	} *p;
+
+	p = data;
+	scsi_add_device(p->unit->port->adapter->scsi_host,
+			0, p->unit->port->scsi_id, p->unit->scsi_lun);
+	atomic_set(&p->unit->scsi_add_work, 0);
+	wake_up(&p->unit->scsi_add_wq);
+	zfcp_unit_put(p->unit);
+	kfree(p);
+}
+
+/**
+ * zfcp_erp_schedule_work
+ * @unit: pointer to unit which should be registered with SCSI stack
+ *
+ * Schedules work which registers a unit with the SCSI stack
+ */
+static int
+zfcp_erp_schedule_work(struct zfcp_unit *unit)
+{
+	struct {
+		struct zfcp_unit * unit;
+		struct work_struct work;
+	} *p;
+
+	if (atomic_compare_and_swap(0, 1, &unit->scsi_add_work))
+		return 0;
+
+	if ((p = kmalloc(sizeof(*p), GFP_KERNEL)) == NULL) {
+		ZFCP_LOG_NORMAL("error: Out of resources. Could not register "
+			      "the FCP-LUN 0x%Lx connected to "
+			      "the port with WWPN 0x%Lx connected to "
+			      "the adapter %s with the SCSI stack.\n",
+			      unit->fcp_lun,
+			      unit->port->wwpn,
+			      zfcp_get_busid_by_unit(unit));
+		atomic_set(&p->unit->scsi_add_work, 0);
+		return -ENOMEM;
+	}
+
+	zfcp_unit_get(unit);
+	memset(p, 0, sizeof(*p));
+	INIT_WORK(&p->work, zfcp_erp_scsi_add_device, p);
+	p->unit = unit;
+	schedule_work(&p->work);
+	return 0;
+}
+
 /*
  * function:	
  *
@@ -1468,10 +1534,6 @@ zfcp_erp_strategy_check_unit(struct zfcp
 	if (result == ZFCP_ERP_SUCCEEDED) {
 		atomic_set(&unit->erp_counter, 0);
 		zfcp_erp_unit_unblock(unit);
-		/* register unit with scsi stack */
-		if (!unit->device)
-			scsi_add_device(unit->port->adapter->scsi_host,
-					0, unit->port->scsi_id, unit->scsi_lun);
 	} else {
 		/* ZFCP_ERP_FAILED or ZFCP_ERP_EXIT */
 		atomic_inc(&unit->erp_counter);
@@ -1773,9 +1835,8 @@ zfcp_erp_port_reopen_all_internal(struct
 	struct zfcp_port *port;
 
 	list_for_each_entry(port, &adapter->port_list_head, list)
-	    if (atomic_test_mask(ZFCP_STATUS_PORT_NAMESERVER, &port->status)
-		!= ZFCP_STATUS_PORT_NAMESERVER)
-		zfcp_erp_port_reopen_internal(port, clear_mask);
+		if (!atomic_test_mask(ZFCP_STATUS_PORT_NAMESERVER, &port->status))
+			zfcp_erp_port_reopen_internal(port, clear_mask);
 
 	return retval;
 }
@@ -2333,8 +2394,8 @@ zfcp_erp_port_forced_strategy(struct zfc
 		 * open flag is unset - however, this is for readabilty ...
 		 */
 		if (atomic_test_mask((ZFCP_STATUS_PORT_PHYS_OPEN |
-				      ZFCP_STATUS_COMMON_OPEN), &port->status)
-		    == (ZFCP_STATUS_PORT_PHYS_OPEN | ZFCP_STATUS_COMMON_OPEN)) {
+				      ZFCP_STATUS_COMMON_OPEN),
+			             &port->status)) {
 			ZFCP_LOG_DEBUG("Port wwpn=0x%Lx is open -> trying "
 				       " close physical\n",
 				       port->wwpn);
@@ -2433,8 +2494,7 @@ zfcp_erp_port_strategy_open(struct zfcp_
 	int retval;
 
 	if (atomic_test_mask(ZFCP_STATUS_PORT_NAMESERVER,
-			     &erp_action->port->status)
-	    == ZFCP_STATUS_PORT_NAMESERVER)
+			     &erp_action->port->status))
 		retval = zfcp_erp_port_strategy_open_nameserver(erp_action);
 	else
 		retval = zfcp_erp_port_strategy_open_common(erp_action);
@@ -3041,6 +3101,12 @@ zfcp_erp_action_enqueue(int action,
 			goto out;
 		}
 		if (!atomic_test_mask
+		    (ZFCP_STATUS_COMMON_RUNNING, &port->status) ||
+		    atomic_test_mask
+		    (ZFCP_STATUS_COMMON_ERP_FAILED, &port->status)) {
+			goto out;
+		}
+		if (!atomic_test_mask
 		    (ZFCP_STATUS_COMMON_UNBLOCKED, &port->status)) {
 			stronger_action = ZFCP_ERP_ACTION_REOPEN_PORT;
 			unit = NULL;
@@ -3068,6 +3134,12 @@ zfcp_erp_action_enqueue(int action,
 			goto out;
 		}
 		if (!atomic_test_mask
+		    (ZFCP_STATUS_COMMON_RUNNING, &adapter->status) ||
+		    atomic_test_mask
+		    (ZFCP_STATUS_COMMON_ERP_FAILED, &adapter->status)) {
+			goto out;
+		}
+		if (!atomic_test_mask
 		    (ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status)) {
 			stronger_action = ZFCP_ERP_ACTION_REOPEN_ADAPTER;
 			port = NULL;
@@ -3178,18 +3250,15 @@ zfcp_erp_action_dequeue(struct zfcp_erp_
 	case ZFCP_ERP_ACTION_REOPEN_UNIT:
 		atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
 				  &erp_action->unit->status);
-		zfcp_unit_put(erp_action->unit);
 		break;
 	case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
 	case ZFCP_ERP_ACTION_REOPEN_PORT:
 		atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
 				  &erp_action->port->status);
-		zfcp_port_put(erp_action->port);
 		break;
 	case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
 		atomic_clear_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
 				  &erp_action->adapter->status);
-		zfcp_adapter_put(adapter);
 		break;
 	default:
 		/* bug */
@@ -3198,6 +3267,39 @@ zfcp_erp_action_dequeue(struct zfcp_erp_
 	return retval;
 }
 
+/**
+ * zfcp_erp_action_cleanup
+ *
+ * registers unit with scsi stack if appropiate and fixes reference counts
+ */
+
+static void
+zfcp_erp_action_cleanup(int action, struct zfcp_adapter *adapter,
+			struct zfcp_port *port, struct zfcp_unit *unit,
+			int result)
+{
+	if ((action == ZFCP_ERP_ACTION_REOPEN_UNIT)
+	    && (result == ZFCP_ERP_SUCCEEDED)
+	    && (!unit->device)) {
+		zfcp_erp_schedule_work(unit);
+	}
+	switch (action) {
+	case ZFCP_ERP_ACTION_REOPEN_UNIT:
+		zfcp_unit_put(unit);
+		break;
+	case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
+	case ZFCP_ERP_ACTION_REOPEN_PORT:
+		zfcp_port_put(port);
+		break;
+	case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
+		zfcp_adapter_put(adapter);
+		break;
+	default:
+		break;
+	}
+}
+
+
 /*
  * function:	
  *
diff -puN drivers/s390/scsi/zfcp_ext.h~linus drivers/s390/scsi/zfcp_ext.h
--- 25/drivers/s390/scsi/zfcp_ext.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/scsi/zfcp_ext.h	2004-01-19 22:17:23.000000000 -0800
@@ -30,9 +30,7 @@
 #ifndef ZFCP_EXT_H
 #define ZFCP_EXT_H
 /* this drivers version (do not edit !!! generated and updated by cvs) */
-#define ZFCP_EXT_REVISION "$Revision: 1.33 $"
-
-#ifdef __KERNEL__
+#define ZFCP_EXT_REVISION "$Revision: 1.38 $"
 
 #include "zfcp_def.h"
 
@@ -44,7 +42,9 @@ extern void zfcp_sysfs_driver_remove_fil
 extern int  zfcp_sysfs_adapter_create_files(struct device *);
 extern void zfcp_sysfs_adapter_remove_files(struct device *);
 extern int  zfcp_sysfs_port_create_files(struct device *, u32);
+extern void zfcp_sysfs_port_remove_files(struct device *, u32);
 extern int  zfcp_sysfs_unit_create_files(struct device *);
+extern void zfcp_sysfs_unit_remove_files(struct device *);
 extern void zfcp_sysfs_port_release(struct device *);
 extern int  zfcp_sysfs_port_shutdown(struct zfcp_port *);
 extern void zfcp_sysfs_unit_release(struct device *);
@@ -112,9 +112,6 @@ extern void zfcp_fsf_els_processing(stru
 extern int  zfcp_adapter_scsi_register(struct zfcp_adapter *);
 extern void zfcp_adapter_scsi_unregister(struct zfcp_adapter *);
 extern void zfcp_scsi_block_requests(struct Scsi_Host *);
-extern void zfcp_scsi_insert_into_fake_queue(struct zfcp_adapter *,
-					     Scsi_Cmnd *);
-extern void zfcp_scsi_process_and_clear_fake_queue(unsigned long);
 extern int  zfcp_create_sbals_from_sg(struct zfcp_fsf_req *,
 				     Scsi_Cmnd *, char, int, int);
 extern void zfcp_set_fcp_dl(struct fcp_cmnd_iu *, fcp_dl_t);
@@ -159,5 +156,4 @@ extern void zfcp_in_els_dbf_event(struct
 #ifdef ZFCP_STAT_REQSIZES
 extern int  zfcp_statistics_inc(struct list_head *, u32);
 #endif
-#endif	/* __KERNEL__ */
 #endif	/* ZFCP_EXT_H */
diff -puN drivers/s390/scsi/zfcp_fsf.c~linus drivers/s390/scsi/zfcp_fsf.c
--- 25/drivers/s390/scsi/zfcp_fsf.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/scsi/zfcp_fsf.c	2004-01-19 22:17:23.000000000 -0800
@@ -28,7 +28,7 @@
  */
 
 /* this drivers version (do not edit !!! generated and updated by cvs) */
-#define ZFCP_FSF_C_REVISION "$Revision: 1.12 $"
+#define ZFCP_FSF_C_REVISION "$Revision: 1.16 $"
 
 #include "zfcp_ext.h"
 
@@ -101,7 +101,8 @@ zfcp_fsf_req_alloc(struct zfcp_adapter *
 	case FSF_QTCB_ABORT_FCP_CMND:
 		fsf_req = zfcp_fsf_req_get(kmalloc_flags,
 					   adapter->pool.fcp_command_fsf);
-		if (fsf_req && (fsf_req->status & ZFCP_STATUS_FSFREQ_POOL)) {
+		if (unlikely(fsf_req &&
+		             (fsf_req->status & ZFCP_STATUS_FSFREQ_POOL))) {
 			/*
 			 * watch low mem buffer
 			 * Note: If the command is reset or aborted, two
@@ -116,7 +117,8 @@ zfcp_fsf_req_alloc(struct zfcp_adapter *
 		}
 #ifdef ZFCP_DEBUG_REQUESTS
 		debug_text_event(adapter->req_dbf, 5, "fsfa_fcp");
-		if (fsf_req && (fsf_req->status & ZFCP_STATUS_FSFREQ_POOL))
+		if (unlikely(fsf_req &&
+		             (fsf_req->status & ZFCP_STATUS_FSFREQ_POOL)))
 			debug_text_event(adapter->req_dbf, 5, "fsfa_pl");
 #endif /* ZFCP_DEBUG_REQUESTS */
 		break;
@@ -158,7 +160,7 @@ zfcp_fsf_req_alloc(struct zfcp_adapter *
 				"(debug info 0x%x)\n", fsf_cmd);
 	}			//switch(fsf_cmd)
 
-	if (!fsf_req) {
+	if (unlikely(!fsf_req)) {
 		ZFCP_LOG_DEBUG("error: Out of memory. Allocation of FSF "
 			       "request structure failed\n");
 	} else {
@@ -171,7 +173,7 @@ zfcp_fsf_req_alloc(struct zfcp_adapter *
 
 #ifdef ZFCP_DEBUG_REQUESTS
 	debug_event(adapter->req_dbf, 5, &fsf_req, sizeof (unsigned long));
-	if (fsf_req->qtcb)
+	if (likely(fsf_req->qtcb))
 		debug_event(adapter->req_dbf, 5, &fsf_req->qtcb,
 			    sizeof (unsigned long));
 #endif				/* ZFCP_DEBUG_REQUESTS */
@@ -198,7 +200,7 @@ zfcp_fsf_req_free(struct zfcp_fsf_req *f
 
 	case FSF_QTCB_FCP_CMND:
 	case FSF_QTCB_ABORT_FCP_CMND:
-		if (fsf_req->status & ZFCP_STATUS_FSFREQ_POOL) {
+		if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_POOL)) {
 			del_timer(&adapter->pool.fcp_command_fsf_timer);
 			mempool_free(fsf_req, adapter->pool.fcp_command_fsf);
 		} else
@@ -299,7 +301,7 @@ zfcp_fsf_req_complete(struct zfcp_fsf_re
 	/* do some statistics */
 	atomic_dec(&adapter->fsf_reqs_active);
 
-	if (fsf_req->fsf_command == FSF_QTCB_UNSOLICITED_STATUS) {
+	if (unlikely(fsf_req->fsf_command == FSF_QTCB_UNSOLICITED_STATUS)) {
 		ZFCP_LOG_DEBUG("Status read response received\n");
 		/*
 		 * Note: all cleanup handling is done in the callchain of
@@ -314,7 +316,7 @@ zfcp_fsf_req_complete(struct zfcp_fsf_re
 	 * fsf_req may be deleted due to waking up functions, so 
 	 * cleanup is saved here and used later 
 	 */
-	if (fsf_req->status & ZFCP_STATUS_FSFREQ_CLEANUP)
+	if (likely(fsf_req->status & ZFCP_STATUS_FSFREQ_CLEANUP))
 		cleanup = 1;
 	else
 		cleanup = 0;
@@ -322,7 +324,7 @@ zfcp_fsf_req_complete(struct zfcp_fsf_re
 	fsf_req->status |= ZFCP_STATUS_FSFREQ_COMPLETED;
 
 	/* cleanup request if requested by initiator */
-	if (cleanup) {
+	if (likely(cleanup)) {
 		ZFCP_LOG_TRACE("removing FSF request 0x%lx\n",
 			       (unsigned long) fsf_req);
 		/*
@@ -334,6 +336,16 @@ zfcp_fsf_req_complete(struct zfcp_fsf_re
 		/* notify initiator waiting for the requests completion */
 		ZFCP_LOG_TRACE("waking initiator of FSF request 0x%lx\n",
 			       (unsigned long) fsf_req);
+		/*
+		 * FIXME: Race! We must not access fsf_req here as it might have been
+		 * cleaned up already due to the set ZFCP_STATUS_FSFREQ_COMPLETED
+		 * flag. It's an improbable case. But, we have the same paranoia for
+		 * the cleanup flag already.
+		 * Might better be handled using complete()?
+		 * (setting the flag and doing wakeup ought to be atomic
+		 *  with regard to checking the flag as long as waitqueue is
+		 *  part of the to be released structure)
+		 */
 		wake_up(&fsf_req->completion_wq);
 	}
 
@@ -372,7 +384,7 @@ zfcp_fsf_protstatus_eval(struct zfcp_fsf
 	}
 
 	/* log additional information provided by FSF (if any) */
-	if (fsf_req->qtcb->header.log_length) {
+	if (unlikely(fsf_req->qtcb->header.log_length)) {
 		/* do not trust them ;-) */
 		if (fsf_req->qtcb->header.log_start > ZFCP_QTCB_SIZE) {
 			ZFCP_LOG_NORMAL
@@ -686,7 +698,7 @@ zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_
 {
 	int retval = 0;
 
-	if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
+	if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
 		goto skip_fsfstatus;
 	}
 
@@ -835,7 +847,7 @@ zfcp_fsf_req_dispatch(struct zfcp_fsf_re
 {
 	int retval = 0;
 
-	if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
+	if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
 		ZFCP_LOG_TRACE("fsf_req=0x%lx, QTCB=0x%lx\n",
 			       (unsigned long) fsf_req,
 			       (unsigned long) (fsf_req->qtcb));
@@ -1996,6 +2008,20 @@ zfcp_fsf_open_port_handler(struct zfcp_f
 				ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
 		retval = 0;
 		/* check whether D_ID has changed during open */
+		/*
+		 * FIXME: This check is not airtight, as the FCP channel does
+		 * not monitor closures of target port connections caused on
+		 * the remote side. Thus, they might miss out on invalidating
+		 * locally cached WWPNs (and other N_Port parameters) of gone
+		 * target ports. So, our heroic attempt to make things safe
+		 * could be undermined by 'open port' response data tagged with
+		 * obsolete WWPNs. Another reason to monitor potential
+		 * connection closures ourself at least (by interpreting
+		 * incoming ELS' and unsolicited status). It just crosses my
+		 * mind that one should be able to cross-check by means of
+		 * another GID_PN straight after a port has been opened.
+		 * Alternately, an ADISC/PDISC ELS should suffice, as well.
+		 */
 		plogi = (struct fsf_plogi *) fsf_req->qtcb->bottom.support.els;
 		if (!atomic_test_mask(ZFCP_STATUS_PORT_NO_WWPN, &port->status))
 		{
@@ -2398,9 +2424,9 @@ zfcp_fsf_open_unit(struct zfcp_erp_actio
 	}
 
 	erp_action->fsf_req->qtcb->header.port_handle =
-	    erp_action->port->handle;
-	*(fcp_lun_t *) & (erp_action->fsf_req->qtcb->bottom.support.fcp_lun)
-	    = erp_action->unit->fcp_lun;
+		erp_action->port->handle;
+	erp_action->fsf_req->qtcb->bottom.support.fcp_lun =
+		erp_action->unit->fcp_lun;
 	atomic_set_mask(ZFCP_STATUS_COMMON_OPENING, &erp_action->unit->status);
 	erp_action->fsf_req->data.open_unit.unit = erp_action->unit;
 	erp_action->fsf_req->erp_action = erp_action;
@@ -2835,7 +2861,7 @@ zfcp_fsf_send_fcp_command_task(struct zf
 	retval = zfcp_fsf_req_create(adapter,
 				     FSF_QTCB_FCP_CMND,
 				     &lock_flags, req_flags, &(fsf_req));
-	if (retval < 0) {
+	if (unlikely(retval < 0)) {
 		ZFCP_LOG_DEBUG("error: Out of resources. Could not create an "
 			       "FCP command request for FCP-LUN 0x%Lx "
 			       "connected to the port with WWPN 0x%Lx "
@@ -2928,7 +2954,7 @@ zfcp_fsf_send_fcp_command_task(struct zf
 	fcp_cmnd_iu->fcp_lun = unit->fcp_lun;
 
 	/* set task attributes in FCP_CMND IU in QTCB */
-	if (scsi_cmnd->device->simple_tags) {
+	if (likely(scsi_cmnd->device->simple_tags)) {
 		fcp_cmnd_iu->task_attribute = SIMPLE_Q;
 		ZFCP_LOG_TRACE("setting SIMPLE_Q task attribute\n");
 	} else {
@@ -2937,7 +2963,7 @@ zfcp_fsf_send_fcp_command_task(struct zf
 	}
 
 	/* set additional length of FCP_CDB in FCP_CMND IU in QTCB, if needed */
-	if (scsi_cmnd->cmd_len > FCP_CDB_LENGTH) {
+	if (unlikely(scsi_cmnd->cmd_len > FCP_CDB_LENGTH)) {
 		fcp_cmnd_iu->add_fcp_cdb_length
 		    = (scsi_cmnd->cmd_len - FCP_CDB_LENGTH) >> 2;
 		ZFCP_LOG_TRACE("SCSI CDB length is 0x%x, "
@@ -2965,9 +2991,9 @@ zfcp_fsf_send_fcp_command_task(struct zf
 	/* Note: >= and not = because the combined scatter-gather entries
 	 * may be larger than request_bufflen according to the mailing list
 	 */
-	if (real_bytes >= scsi_cmnd->request_bufflen) {
+	if (likely(real_bytes >= scsi_cmnd->request_bufflen)) {
 		ZFCP_LOG_TRACE("Data fits\n");
-	} else if (real_bytes == 0) {
+	} else if (likely(real_bytes == 0)) {
 		ZFCP_LOG_DEBUG("Data did not fit into available buffer(s), "
 			       "waiting for more...\n");
 		retval = -EIO;
@@ -2996,7 +3022,7 @@ zfcp_fsf_send_fcp_command_task(struct zf
 	 *  covered by an SBALE)
 	 */
 	retval = zfcp_fsf_req_send(fsf_req, NULL);
-	if (retval < 0) {
+	if (unlikely(retval < 0)) {
 		ZFCP_LOG_INFO("error: Could not send an FCP command request "
 			      "for a command on the adapter %s, "
 			      "port WWPN 0x%Lx and unit LUN 0x%Lx\n",
@@ -3139,12 +3165,12 @@ zfcp_fsf_send_fcp_command_handler(struct
 	int retval = -EINVAL;
 	struct zfcp_unit *unit;
 
-	if (fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT)
+	if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT))
 		unit = fsf_req->data.send_fcp_command_task_management.unit;
 	else
 		unit = fsf_req->data.send_fcp_command_task.unit;
 
-	if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
+	if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
 		/* go directly to calls of special handlers */
 		goto skip_fsfstatus;
 	}
@@ -3445,7 +3471,6 @@ static int
 zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *fsf_req)
 {
 	int retval = 0;
-	struct zfcp_adapter *adapter = fsf_req->adapter;
 
 	Scsi_Cmnd *scpnt;
 	struct fcp_rsp_iu *fcp_rsp_iu = (struct fcp_rsp_iu *)
@@ -3459,14 +3484,14 @@ zfcp_fsf_send_fcp_command_task_handler(s
 
 	read_lock_irqsave(&fsf_req->adapter->abort_lock, flags);
 	scpnt = fsf_req->data.send_fcp_command_task.scsi_cmnd;
-	if (!scpnt) {
+	if (unlikely(!scpnt)) {
 		ZFCP_LOG_DEBUG
 		    ("Command with fsf_req 0x%lx is not associated to "
 		     "a scsi command anymore. Aborted?\n",
 		     (unsigned long) fsf_req);
 		goto out;
 	}
-	if (fsf_req->status & ZFCP_STATUS_FSFREQ_ABORTED) {
+	if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ABORTED)) {
 		/* FIXME: (design) mid-layer should handle DID_ABORT like
 		 *        DID_SOFT_ERROR by retrying the request for devices
 		 *        that allow retries.
@@ -3477,7 +3502,7 @@ zfcp_fsf_send_fcp_command_task_handler(s
 		goto skip_fsfstatus;
 	}
 
-	if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
+	if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
 		ZFCP_LOG_DEBUG("Setting DID_ERROR\n");
 		set_host_byte(&scpnt->result, DID_ERROR);
 		goto skip_fsfstatus;
@@ -3491,7 +3516,7 @@ zfcp_fsf_send_fcp_command_task_handler(s
 	 * of result in SCSI command
 	 */
 	scpnt->result |= fcp_rsp_iu->scsi_status;
-	if (fcp_rsp_iu->scsi_status) {
+	if (unlikely(fcp_rsp_iu->scsi_status)) {
 		/* DEBUG */
 		ZFCP_LOG_NORMAL("status for SCSI Command:\n");
 		ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL,
@@ -3507,7 +3532,7 @@ zfcp_fsf_send_fcp_command_task_handler(s
 	}
 
 	/* check FCP_RSP_INFO */
-	if (fcp_rsp_iu->validity.bits.fcp_rsp_len_valid) {
+	if (unlikely(fcp_rsp_iu->validity.bits.fcp_rsp_len_valid)) {
 		ZFCP_LOG_DEBUG("rsp_len is valid\n");
 		switch (fcp_rsp_info[3]) {
 		case RSP_CODE_GOOD:
@@ -3600,7 +3625,7 @@ zfcp_fsf_send_fcp_command_task_handler(s
 	}
 
 	/* check for sense data */
-	if (fcp_rsp_iu->validity.bits.fcp_sns_len_valid) {
+	if (unlikely(fcp_rsp_iu->validity.bits.fcp_sns_len_valid)) {
 		sns_len = FSF_FCP_RSP_SIZE -
 		    sizeof (struct fcp_rsp_iu) + fcp_rsp_iu->fcp_rsp_len;
 		ZFCP_LOG_TRACE("room for %i bytes sense data in QTCB\n",
@@ -3623,7 +3648,7 @@ zfcp_fsf_send_fcp_command_task_handler(s
 	}
 
 	/* check for overrun */
-	if (fcp_rsp_iu->validity.bits.fcp_resid_over) {
+	if (unlikely(fcp_rsp_iu->validity.bits.fcp_resid_over)) {
 		ZFCP_LOG_INFO("A data overrun was detected for a command. "
 			      "This happened for a command to the unit "
 			      "with FCP LUN 0x%Lx connected to the "
@@ -3638,7 +3663,7 @@ zfcp_fsf_send_fcp_command_task_handler(s
 	}
 
 	/* check for underrun */
-	if (fcp_rsp_iu->validity.bits.fcp_resid_under) {
+	if (unlikely(fcp_rsp_iu->validity.bits.fcp_resid_under)) {
 		ZFCP_LOG_DEBUG("A data underrun was detected for a command. "
 			       "This happened for a command to the unit "
 			       "with FCP LUN 0x%Lx connected to the "
@@ -3755,9 +3780,6 @@ zfcp_fsf_send_fcp_command_task_handler(s
 	 * the new eh
 	 */
 	/* always call back */
-	(scpnt->scsi_done) (scpnt);
-	atomic_dec(&adapter->scsi_reqs_active);
-	wake_up(&adapter->scsi_reqs_active_wq);
 #ifdef ZFCP_DEBUG_REQUESTS
 	debug_text_event(fsf_req->adapter->req_dbf, 2, "ok_done:");
 	debug_event(fsf_req->adapter->req_dbf, 2, &scpnt,
@@ -3768,8 +3790,6 @@ zfcp_fsf_send_fcp_command_task_handler(s
 		    sizeof (unsigned long));
 #endif /* ZFCP_DEBUG_REQUESTS */
 	(scpnt->scsi_done) (scpnt);
-	atomic_dec(&adapter->scsi_reqs_active);
-	wake_up(&adapter->scsi_reqs_active_wq);
 	/*
 	 * We must hold this lock until scsi_done has been called.
 	 * Otherwise we may call scsi_done after abort regarding this
@@ -3904,7 +3924,7 @@ zfcp_fsf_req_create_sbal_check(unsigned 
 			       struct zfcp_qdio_queue *queue, int needed)
 {
 	write_lock_irqsave(&queue->queue_lock, *flags);
-	if (atomic_read(&queue->free_count) >= needed)
+	if (likely(atomic_read(&queue->free_count) >= needed))
 		return 1;
 	write_unlock_irqrestore(&queue->queue_lock, *flags);
 	return 0;
@@ -3942,7 +3962,7 @@ zfcp_fsf_req_create(struct zfcp_adapter 
 
 	/* allocate new FSF request */
 	fsf_req = zfcp_fsf_req_alloc(adapter, fsf_cmd, GFP_ATOMIC);
-	if (!fsf_req) {
+	if (unlikely(!fsf_req)) {
 		ZFCP_LOG_DEBUG("error: Could not put an FSF request into"
 			       "the outbound (send) queue.\n");
 		retval = -ENOMEM;
@@ -3960,11 +3980,11 @@ zfcp_fsf_req_create(struct zfcp_adapter 
 	fsf_req->specific_magic = ZFCP_MAGIC_FSFREQ;
 
 	fsf_req->fsf_command = fsf_cmd;
-	if (req_flags & ZFCP_REQ_AUTO_CLEANUP)
+	if (likely(req_flags & ZFCP_REQ_AUTO_CLEANUP))
 		fsf_req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
 
 	/* initialize QTCB */
-	if (fsf_cmd != FSF_QTCB_UNSOLICITED_STATUS) {
+	if (likely(fsf_cmd != FSF_QTCB_UNSOLICITED_STATUS)) {
 		ZFCP_LOG_TRACE("fsf_req->qtcb=0x%lx\n",
 			       (unsigned long) fsf_req->qtcb);
 		fsf_req->qtcb->prefix.req_id = (unsigned long) fsf_req;
@@ -3983,7 +4003,7 @@ zfcp_fsf_req_create(struct zfcp_adapter 
 	 * try to get needed SBALs in request queue (get queue lock on success)
 	 */
 	ZFCP_LOG_TRACE("try to get free BUFFER in request queue\n");
-	if (req_flags & ZFCP_WAIT_FOR_SBAL) {
+	if (unlikely(req_flags & ZFCP_WAIT_FOR_SBAL)) {
 		timeout = ZFCP_SBAL_TIMEOUT;
 		ZFCP_WAIT_EVENT_TIMEOUT(adapter->request_wq,
 					timeout,
@@ -4009,7 +4029,7 @@ zfcp_fsf_req_create(struct zfcp_adapter 
 	/* setup common SBALE fields */
 	buffere[0].addr = fsf_req;
 	buffere[0].flags |= SBAL_FLAGS0_COMMAND;
-	if (fsf_cmd != FSF_QTCB_UNSOLICITED_STATUS) {
+	if (likely(fsf_cmd != FSF_QTCB_UNSOLICITED_STATUS)) {
 		buffere[1].addr = (void *) fsf_req->qtcb;
 		buffere[1].length = ZFCP_QTCB_SIZE;
 	}
@@ -4116,7 +4136,7 @@ zfcp_fsf_req_send(struct zfcp_fsf_req *f
 		      buffere->length);
 
 	/* set sequence counter in QTCB */
-	if (fsf_req->qtcb) {
+	if (likely(fsf_req->qtcb)) {
 		fsf_req->qtcb->prefix.req_seq_no = adapter->fsf_req_seq_no;
 		fsf_req->seq_no = adapter->fsf_req_seq_no;
 		ZFCP_LOG_TRACE("FSF request 0x%lx of adapter 0x%lx gets "
@@ -4133,7 +4153,7 @@ zfcp_fsf_req_send(struct zfcp_fsf_req *f
 	write_unlock_irqrestore(&adapter->fsf_req_list_lock, flags);
 
 	/* figure out expiration time of timeout and start timeout */
-	if (timer) {
+	if (unlikely(timer)) {
 		timer->expires += jiffies;
 		add_timer(timer);
 	}
@@ -4167,7 +4187,7 @@ zfcp_fsf_req_send(struct zfcp_fsf_req *f
 			 QDIO_FLAG_SYNC_OUTPUT,
 			 0, fsf_req->sbal_index, fsf_req->sbal_count, NULL);
 
-	if (retval) {
+	if (unlikely(retval)) {
 		/* Queues are down..... */
 		retval = -EIO;
 		/*
@@ -4198,7 +4218,7 @@ zfcp_fsf_req_send(struct zfcp_fsf_req *f
 		debug_text_event(adapter->req_dbf, 1, "o:a/seq");
 		debug_event(adapter->req_dbf, 1, &fsf_req,
 			    sizeof (unsigned long));
-		if (inc_seq_no) {
+		if (likely(inc_seq_no)) {
 			debug_event(adapter->req_dbf, 1,
 				    &adapter->fsf_req_seq_no, sizeof (u32));
 		} else {
@@ -4213,7 +4233,7 @@ zfcp_fsf_req_send(struct zfcp_fsf_req *f
 		 * otherwise,
 		 */
 		/* Don't increase for unsolicited status */
-		if (inc_seq_no) {
+		if (likely(inc_seq_no)) {
 			adapter->fsf_req_seq_no++;
 			ZFCP_LOG_TRACE
 			    ("FSF sequence counter value of adapter 0x%lx "
@@ -4263,16 +4283,16 @@ zfcp_fsf_req_get(int kmalloc_flags, memp
 	struct zfcp_fsf_req *fsf_req;
 
 	fsf_req = kmalloc(ZFCP_QTCB_AND_REQ_SIZE, kmalloc_flags);
-	if (fsf_req) {
+	if (likely(fsf_req)) {
 		memset(fsf_req, 0, ZFCP_QTCB_AND_REQ_SIZE);
 	} else {
 		fsf_req = mempool_alloc(pool, kmalloc_flags);
-		if (fsf_req) {
+		if (likely(fsf_req)) {
 			memset(fsf_req, 0, ZFCP_QTCB_AND_REQ_SIZE);
 			fsf_req->status |= ZFCP_STATUS_FSFREQ_POOL;
 		}
 	}
-	if (fsf_req)
+	if (likely(fsf_req))
 		fsf_req->qtcb =
 		    (struct fsf_qtcb *) ((unsigned long) fsf_req +
 					 sizeof (struct zfcp_fsf_req));
diff -puN drivers/s390/scsi/zfcp_fsf.h~linus drivers/s390/scsi/zfcp_fsf.h
--- 25/drivers/s390/scsi/zfcp_fsf.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/scsi/zfcp_fsf.h	2004-01-19 22:17:23.000000000 -0800
@@ -30,8 +30,6 @@
 #ifndef FSF_H
 #define FSF_H
 
-#ifdef __KERNEL__
-
 #define FSF_QTCB_VERSION1			0x00000001
 #define FSF_QTCB_CURRENT_VERSION		FSF_QTCB_VERSION1
 
@@ -354,5 +352,4 @@ struct fsf_qtcb {
 	union  fsf_qtcb_bottom bottom;
 } __attribute__ ((packed));
 
-#endif				/* __KERNEL__ */
 #endif				/* FSF_H */
diff -puN drivers/s390/scsi/zfcp_qdio.c~linus drivers/s390/scsi/zfcp_qdio.c
--- 25/drivers/s390/scsi/zfcp_qdio.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/scsi/zfcp_qdio.c	2004-01-19 22:17:23.000000000 -0800
@@ -27,7 +27,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#define ZFCP_QDIO_C_REVISION "$Revision: 1.7 $"
+#define ZFCP_QDIO_C_REVISION "$Revision: 1.10 $"
 
 #include "zfcp_ext.h"
 
@@ -214,7 +214,7 @@ zfcp_qdio_handler_error_check(struct zfc
 				       " QDIO_STATUS_OUTBOUND_INT \n");
 		}
 	}			// if (ZFCP_LOG_CHECK(ZFCP_LOG_LEVEL_TRACE))
-	if (status & QDIO_STATUS_LOOK_FOR_ERROR) {
+	if (unlikely(status & QDIO_STATUS_LOOK_FOR_ERROR)) {
 		retval = -EIO;
 
 		ZFCP_LOG_FLAGS(1, "QDIO_STATUS_LOOK_FOR_ERROR \n");
@@ -261,7 +261,17 @@ zfcp_qdio_handler_error_check(struct zfc
 		}
 		/* Restarting IO on the failed adapter from scratch */
 		debug_text_event(adapter->erp_dbf, 1, "qdio_err");
-		zfcp_erp_adapter_reopen(adapter, 0);
+               /*
+                * Since we have been using this adapter, it is save to assume
+                * that it is not failed but recoverable. The card seems to
+                * report link-up events by self-initiated queue shutdown.
+                * That is why we need to clear the the link-down flag
+                * which is set again in case we have missed by a mile.
+                */
+               zfcp_erp_adapter_reopen(
+                       adapter, 
+                       ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED |
+                       ZFCP_STATUS_COMMON_ERP_FAILED);
 	}
 	return retval;
 }
@@ -293,8 +303,8 @@ zfcp_qdio_request_handler(struct ccw_dev
 		       zfcp_get_busid_by_adapter(adapter),
 		       first_element, elements_processed);
 
-	if (zfcp_qdio_handler_error_check(adapter, status, qdio_error,
-					  siga_error))
+	if (unlikely(zfcp_qdio_handler_error_check(adapter, status, qdio_error,
+					           siga_error)))
 		goto out;
 	/*
 	 * we stored address of struct zfcp_adapter  data structure
@@ -345,8 +355,8 @@ zfcp_qdio_response_handler(struct ccw_de
 	adapter = (struct zfcp_adapter *) int_parm;
 	queue = &adapter->response_queue;
 
-	if (zfcp_qdio_handler_error_check(adapter, status, qdio_error,
-					  siga_error))
+	if (unlikely(zfcp_qdio_handler_error_check(adapter, status, qdio_error,
+					           siga_error)))
 		goto out;
 
 	/*
@@ -394,11 +404,17 @@ zfcp_qdio_response_handler(struct ccw_de
 				ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL,
 					      (char *) buffer, SBAL_SIZE);
 			}
-			if (buffere->flags & SBAL_FLAGS_LAST_ENTRY)
+			/*
+			 * A single used SBALE per inbound SBALE has been
+			 * implemented by QDIO so far. Hope they will
+			 * do some optimisation. Will need to change to
+			 * unlikely() then.
+			 */
+			if (likely(buffere->flags & SBAL_FLAGS_LAST_ENTRY))
 				break;
 		};
 
-		if (!buffere->flags & SBAL_FLAGS_LAST_ENTRY) {
+		if (unlikely(!(buffere->flags & SBAL_FLAGS_LAST_ENTRY))) {
 			ZFCP_LOG_NORMAL("bug: End of inbound data "
 					"not marked!\n");
 		}
@@ -421,7 +437,7 @@ zfcp_qdio_response_handler(struct ccw_de
 			 QDIO_FLAG_SYNC_INPUT | QDIO_FLAG_UNDER_INTERRUPT,
 			 0, start, count, NULL);
 
-	if (retval) {
+	if (unlikely(retval)) {
 		atomic_set(&queue->free_count, count);
 		ZFCP_LOG_DEBUG("Inbound data regions could not be cleared "
 			       "Transfer queues may be down. "
@@ -458,7 +474,7 @@ zfcp_qdio_reqid_check(struct zfcp_adapte
 #endif				/* ZFCP_DEBUG_REQUESTS */
 
 	/* invalid (per convention used in this driver) */
-	if (!sbale_addr) {
+	if (unlikely(!sbale_addr)) {
 		ZFCP_LOG_NORMAL
 		    ("bug: Inbound data faulty, contains null-pointer!\n");
 		retval = -EINVAL;
@@ -468,8 +484,8 @@ zfcp_qdio_reqid_check(struct zfcp_adapte
 	/* valid request id and thus (hopefully :) valid fsf_req address */
 	fsf_req = (struct zfcp_fsf_req *) sbale_addr;
 
-	if ((fsf_req->common_magic != ZFCP_MAGIC) ||
-	    (fsf_req->specific_magic != ZFCP_MAGIC_FSFREQ)) {
+	if (unlikely((fsf_req->common_magic != ZFCP_MAGIC) ||
+	             (fsf_req->specific_magic != ZFCP_MAGIC_FSFREQ))) {
 		ZFCP_LOG_NORMAL("bug: An inbound FSF acknowledgement was "
 				"faulty (debug info 0x%x, 0x%x, 0x%lx)\n",
 				fsf_req->common_magic,
@@ -479,7 +495,7 @@ zfcp_qdio_reqid_check(struct zfcp_adapte
 		goto out;
 	}
 
-	if (adapter != fsf_req->adapter) {
+	if (unlikely(adapter != fsf_req->adapter)) {
 		ZFCP_LOG_NORMAL("bug: An inbound FSF acknowledgement was not "
 				"correct (debug info 0x%lx, 0x%lx, 0%lx) \n",
 				(unsigned long) fsf_req,
@@ -490,7 +506,7 @@ zfcp_qdio_reqid_check(struct zfcp_adapte
 	}
 #ifdef ZFCP_DEBUG_REQUESTS
 	/* debug feature stuff (test for QTCB: remember new unsol. status!) */
-	if (fsf_req->qtcb) {
+	if (likely(fsf_req->qtcb)) {
 		debug_event(adapter->req_dbf, 1,
 			    &fsf_req->qtcb->prefix.req_seq_no, sizeof (u32));
 	}
@@ -498,7 +514,7 @@ zfcp_qdio_reqid_check(struct zfcp_adapte
 
 	ZFCP_LOG_TRACE("fsf_req at 0x%lx, QTCB at 0x%lx\n",
 		       (unsigned long) fsf_req, (unsigned long) fsf_req->qtcb);
-	if (fsf_req->qtcb) {
+	if (likely(fsf_req->qtcb)) {
 		ZFCP_LOG_TRACE("HEX DUMP OF 1ST BUFFERE PAYLOAD (QTCB):\n");
 		ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE,
 			      (char *) fsf_req->qtcb, ZFCP_QTCB_SIZE);
@@ -518,8 +534,8 @@ zfcp_qdio_determine_pci(struct zfcp_qdio
 	int pci_pos;
 
 	new_distance_from_int = req_queue->distance_from_int +
-	    fsf_req->sbal_count;
-	if (new_distance_from_int >= ZFCP_QDIO_PCI_INTERVAL) {
+				fsf_req->sbal_count;
+	if (unlikely(new_distance_from_int >= ZFCP_QDIO_PCI_INTERVAL)) {
 		new_distance_from_int %= ZFCP_QDIO_PCI_INTERVAL;
 		pci_pos = fsf_req->sbal_index;
 		pci_pos += fsf_req->sbal_count;
diff -puN drivers/s390/scsi/zfcp_scsi.c~linus drivers/s390/scsi/zfcp_scsi.c
--- 25/drivers/s390/scsi/zfcp_scsi.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/scsi/zfcp_scsi.c	2004-01-19 22:17:23.000000000 -0800
@@ -30,7 +30,7 @@
 #define ZFCP_LOG_AREA			ZFCP_LOG_AREA_SCSI
 #define ZFCP_LOG_AREA_PREFIX		ZFCP_LOG_AREA_PREFIX_SCSI
 /* this drivers version (do not edit !!! generated and updated by cvs) */
-#define ZFCP_SCSI_REVISION "$Revision: 1.38 $"
+#define ZFCP_SCSI_REVISION "$Revision: 1.42 $"
 
 #include <linux/blkdev.h>
 
@@ -225,99 +225,6 @@ zfcp_scsi_slave_destroy(struct scsi_devi
 	}
 }
 
-/*
- * function:    zfcp_scsi_insert_into_fake_queue
- *
- * purpose:
- *		
- *
- * returns:
- *
- * FIXME:	Is the following scenario possible and - even more interesting -
- *		a problem? It reminds me of the famous 'no retry for tape' fix
- *		(no problem for disks, but what is about tapes...)
- *
- *		device is unaccessable,
- *		command A is put into the fake queue,
- *		device becomes accessable again,
- *		command B is queued to the device,
- *		fake queue timer expires
- *		command A is returned to the mid-layer
- *		command A is queued to the device
- */
-void
-zfcp_scsi_insert_into_fake_queue(struct zfcp_adapter *adapter,
-				 Scsi_Cmnd * new_cmnd)
-{
-	unsigned long flags;
-	Scsi_Cmnd *current_cmnd;
-
-	ZFCP_LOG_DEBUG("Faking SCSI command:\n");
-	ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
-		      (char *) new_cmnd->cmnd, new_cmnd->cmd_len);
-
-	new_cmnd->host_scribble = NULL;
-
-	write_lock_irqsave(&adapter->fake_list_lock, flags);
-	if (adapter->first_fake_cmnd == NULL) {
-		adapter->first_fake_cmnd = new_cmnd;
-		adapter->fake_scsi_timer.function =
-		    zfcp_scsi_process_and_clear_fake_queue;
-		adapter->fake_scsi_timer.data = (unsigned long) adapter;
-		adapter->fake_scsi_timer.expires =
-		    jiffies + ZFCP_FAKE_SCSI_COMPLETION_TIME;
-		add_timer(&adapter->fake_scsi_timer);
-	} else {
-		for (current_cmnd = adapter->first_fake_cmnd;
-		     current_cmnd->host_scribble != NULL;
-		     current_cmnd =
-		     (Scsi_Cmnd *) (current_cmnd->host_scribble)) ;
-		current_cmnd->host_scribble = (char *) new_cmnd;
-	}
-	write_unlock_irqrestore(&adapter->fake_list_lock, flags);
-}
-
-/*
- * function:    zfcp_scsi_process_and_clear_fake_queue
- *
- * purpose:
- *		
- *
- * returns:
- */
-void
-zfcp_scsi_process_and_clear_fake_queue(unsigned long data)
-{
-	unsigned long flags;
-	struct zfcp_adapter *adapter = (struct zfcp_adapter *) data;
-	Scsi_Cmnd *cur = adapter->first_fake_cmnd;
-	Scsi_Cmnd *next;
-
-	/*
-	 * We need a common lock for scsi_req on command completion
-	 * as well as on command abort to avoid race conditions
-	 * during completions and aborts taking place at the same time.
-	 * It needs to be the outer lock as in the eh_abort_handler.
-	 */
-	read_lock_irqsave(&adapter->abort_lock, flags);
-	write_lock(&adapter->fake_list_lock);
-	while (cur) {
-		next = (Scsi_Cmnd *) cur->host_scribble;
-		cur->host_scribble = NULL;
-		zfcp_cmd_dbf_event_scsi("clrfake", cur);
-		cur->scsi_done(cur);
-		cur = next;
-#ifdef ZFCP_DEBUG_REQUESTS
-		debug_text_event(adapter->req_dbf, 2, "fk_done:");
-		debug_event(adapter->req_dbf, 2, &cur, sizeof (unsigned long));
-#endif
-	}
-	adapter->first_fake_cmnd = NULL;
-	write_unlock(&adapter->fake_list_lock);
-	read_unlock_irqrestore(&adapter->abort_lock, flags);
-	return;
-}
-
 void
 zfcp_scsi_block_requests(struct Scsi_Host *shpnt)
 {
@@ -383,25 +290,6 @@ zfcp_scsi_slave_configure(struct scsi_de
 	return 0;
 }
 
-/* Sends command on a round-trip using SCSI stack */
-static void
-zfcp_scsi_queuecommand_fake(Scsi_Cmnd * scpnt, struct zfcp_adapter *adapter)
-{
-	ZFCP_LOG_DEBUG("Looping SCSI IO on the adapter %s.\n",
-		       zfcp_get_busid_by_adapter(adapter));
-	/* 
-	 * Reset everything for devices with retries, allow at least one retry
-	 * for others, e.g. tape.
-	 */
-	scpnt->retries = 0;
-	if (scpnt->allowed == 1) {
-		scpnt->allowed = 2;
-	}
-	set_host_byte(&scpnt->result, DID_SOFT_ERROR);
-	set_driver_byte(&scpnt->result, SUGGEST_RETRY);
-	zfcp_scsi_insert_into_fake_queue(adapter, scpnt);
-}
-
 /* Complete a command immediately handing back DID_ERROR */
 static void
 zfcp_scsi_queuecommand_stop(Scsi_Cmnd * scpnt,
@@ -460,10 +348,12 @@ zfcp_scsi_queuecommand_stop(Scsi_Cmnd * 
 int
 zfcp_scsi_queuecommand(Scsi_Cmnd * scpnt, void (*done) (Scsi_Cmnd *))
 {
+	int retval;
 	int temp_ret;
 	struct zfcp_unit *unit;
 	struct zfcp_adapter *adapter;
 
+	retval = 0;
 	/* reset the status for this request */
 	scpnt->result = 0;
 	/* save address of mid layer call back function */
@@ -475,47 +365,38 @@ zfcp_scsi_queuecommand(Scsi_Cmnd * scpnt
 	 */
 	adapter = (struct zfcp_adapter *) scpnt->device->host->hostdata[0];
 	/* NULL when the adapter was removed from the zfcp list */
-	if (adapter == NULL) {
+	if (unlikely(adapter == NULL)) {
 		zfcp_scsi_queuecommand_stop(scpnt, NULL, NULL);
 		goto out;
 	}
 
-	/* set when we have a unit/port list modification */
-	if (atomic_test_mask(ZFCP_STATUS_ADAPTER_QUEUECOMMAND_BLOCK,
-			     &adapter->status)) {
-		zfcp_scsi_queuecommand_fake(scpnt, adapter);
-		goto out;
-	}
-
 	unit = zfcp_scsi_determine_unit(adapter, scpnt);
-	if (unit == NULL)
+	if (unlikely(unit == NULL))
 		goto out;
 
-	if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &unit->status)
-	    || !atomic_test_mask(ZFCP_STATUS_COMMON_RUNNING, &unit->status)) {
+	if (unlikely(
+	      atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &unit->status) ||
+	     !atomic_test_mask(ZFCP_STATUS_COMMON_RUNNING, &unit->status))) {
 		zfcp_scsi_queuecommand_stop(scpnt, adapter, unit);
 		goto out;
 	}
-	if (!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status)) {
+	if (unlikely(
+	     !atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &unit->status))) {
 		ZFCP_LOG_DEBUG("adapter %s not ready or unit with LUN 0x%Lx "
 			       "on the port with WWPN 0x%Lx in recovery.\n",
 			       zfcp_get_busid_by_adapter(adapter),
 			       unit->fcp_lun, unit->port->wwpn);
-		zfcp_scsi_queuecommand_fake(scpnt, adapter);
+		retval = SCSI_MLQUEUE_DEVICE_BUSY;
 		goto out;
 	}
 
-	atomic_inc(&adapter->scsi_reqs_active);
-
 	temp_ret = zfcp_fsf_send_fcp_command_task(adapter,
 						  unit,
 						  scpnt, ZFCP_REQ_AUTO_CLEANUP);
 
-	if (temp_ret < 0) {
+	if (unlikely(temp_ret < 0)) {
 		ZFCP_LOG_DEBUG("error: Could not send a Send FCP Command\n");
-		atomic_dec(&adapter->scsi_reqs_active);
-		wake_up(&adapter->scsi_reqs_active_wq);
-		zfcp_scsi_queuecommand_fake(scpnt, adapter);
+		retval = SCSI_MLQUEUE_HOST_BUSY;
 	} else {
 #ifdef ZFCP_DEBUG_REQUESTS
 		debug_text_event(adapter->req_dbf, 3, "q_scpnt");
@@ -524,7 +405,7 @@ zfcp_scsi_queuecommand(Scsi_Cmnd * scpnt
 #endif				/* ZFCP_DEBUG_REQUESTS */
 	}
  out:
-	return 0;
+	return retval;
 }
 
 /*
@@ -557,45 +438,6 @@ zfcp_unit_lookup(struct zfcp_adapter *ad
 }
 
 /*
- * function:    zfcp_scsi_potential_abort_on_fake
- *
- * purpose:
- *
- * returns:     0 - no fake request aborted
- *              1 - fake request was aborted
- *
- * context:	both the adapter->abort_lock and the 
- *              adapter->fake_list_lock are assumed to be held write lock
- *              irqsave
- */
-int
-zfcp_scsi_potential_abort_on_fake(struct zfcp_adapter *adapter,
-				  Scsi_Cmnd * cmnd)
-{
-	Scsi_Cmnd *cur = adapter->first_fake_cmnd;
-	Scsi_Cmnd *pre = NULL;
-	int retval = 0;
-
-	while (cur) {
-		if (cur == cmnd) {
-			if (pre)
-				pre->host_scribble = cur->host_scribble;
-			else
-				adapter->first_fake_cmnd =
-				    (Scsi_Cmnd *) cur->host_scribble;
-			cur->host_scribble = NULL;
-			if (!adapter->first_fake_cmnd)
-				del_timer(&adapter->fake_scsi_timer);
-			retval = 1;
-			break;
-		}
-		pre = cur;
-		cur = (Scsi_Cmnd *) cur->host_scribble;
-	}
-	return retval;
-}
-
-/*
  * function:	zfcp_scsi_eh_abort_handler
  *
  * purpose:	tries to abort the specified (timed out) SCSI command
@@ -663,34 +505,12 @@ zfcp_scsi_eh_abort_handler(Scsi_Cmnd * s
 	 * Race condition between normal (late) completion and abort has
 	 * to be avoided.
 	 * The entirity of all accesses to scsi_req have to be atomic.
-	 * scsi_req is usually part of the fsf_req (for requests which
-	 * are not faked) and thus we block the release of fsf_req
-	 * as long as we need to access scsi_req.
-	 * For faked commands we use the same lock even if they are not
-	 * put into the fsf_req queue. This makes implementation
-	 * easier. 
+	 * scsi_req is usually part of the fsf_req and thus we block the
+	 * release of fsf_req as long as we need to access scsi_req.
 	 */
 	write_lock_irqsave(&adapter->abort_lock, flags);
 
 	/*
-	 * Check if we deal with a faked command, which we may just forget
-	 * about from now on
-	 */
-	write_lock(&adapter->fake_list_lock);
-	/* only need to go through list if there are faked requests */
-	if (adapter->first_fake_cmnd != NULL) {
-		if (zfcp_scsi_potential_abort_on_fake(adapter, scpnt)) {
-			write_unlock(&adapter->fake_list_lock);
-			write_unlock_irqrestore(&adapter->abort_lock, flags);
-			ZFCP_LOG_INFO("A faked command was aborted\n");
-			retval = SUCCESS;
-			strncpy(dbf_result, "##faked", ZFCP_ABORT_DBF_LENGTH);
-			goto out;
-		}
-	}
-	write_unlock(&adapter->fake_list_lock);
-
-	/*
 	 * Check whether command has just completed and can not be aborted.
 	 * Even if the command has just been completed late, we can access
 	 * scpnt since the SCSI stack does not release it at least until
@@ -845,11 +665,6 @@ zfcp_scsi_eh_device_reset_handler(Scsi_C
 
 	spin_unlock_irq(scsi_host->host_lock);
 
-	/*
-	 * We should not be called to reset a target which we 'sent' faked SCSI
-	 * commands since the abort of faked SCSI commands should always
-	 * succeed (simply delete timer). 
-	 */
 	if (!unit) {
 		ZFCP_LOG_NORMAL("bug: Tried to reset a non existant unit.\n");
 		retval = SUCCESS;
@@ -1023,7 +838,6 @@ zfcp_adapter_scsi_register(struct zfcp_a
 		retval = -EIO;
 		goto out;
 	}
-	atomic_set_mask(ZFCP_STATUS_ADAPTER_REGISTERED, &adapter->status);
 	ZFCP_LOG_DEBUG("host registered, scsi_host at 0x%lx\n",
 		       (unsigned long) adapter->scsi_host);
 
@@ -1039,7 +853,12 @@ zfcp_adapter_scsi_register(struct zfcp_a
 	 */
 	adapter->scsi_host->hostdata[0] = (unsigned long) adapter;
 
-	scsi_add_host(adapter->scsi_host, &adapter->ccw_device->dev);
+	if (scsi_add_host(adapter->scsi_host, &adapter->ccw_device->dev)) {
+		scsi_host_put(adapter->scsi_host);
+		retval = -EIO;
+		goto out;
+	}
+	atomic_set_mask(ZFCP_STATUS_ADAPTER_REGISTERED, &adapter->status);
  out:
 	return retval;
 }
@@ -1061,8 +880,9 @@ zfcp_adapter_scsi_unregister(struct zfcp
 		return;
 	scsi_remove_host(shost);
 	scsi_host_put(shost);
-
 	adapter->scsi_host = NULL;
+	atomic_clear_mask(ZFCP_STATUS_ADAPTER_REGISTERED, &adapter->status);
+
 	return;
 }
 
diff -puN drivers/s390/scsi/zfcp_sysfs_adapter.c~linus drivers/s390/scsi/zfcp_sysfs_adapter.c
--- 25/drivers/s390/scsi/zfcp_sysfs_adapter.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/scsi/zfcp_sysfs_adapter.c	2004-01-19 22:17:23.000000000 -0800
@@ -25,7 +25,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#define ZFCP_SYSFS_ADAPTER_C_REVISION "$Revision: 1.21 $"
+#define ZFCP_SYSFS_ADAPTER_C_REVISION "$Revision: 1.26 $"
 
 #include <asm/ccwdev.h>
 #include "zfcp_ext.h"
@@ -155,11 +155,8 @@ zfcp_sysfs_port_add_store(struct device 
 
 	retval = 0;
 
-	zfcp_adapter_get(adapter);
-
-	/* try to open port only if adapter is online */
-	if (adapter->ccw_device->online == 1)
-		zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED);
+	zfcp_erp_port_reopen(port, 0);
+	zfcp_erp_wait(port->adapter);
 	zfcp_port_put(port);
  out:
 	up(&zfcp_data.config_sema);
@@ -219,6 +216,8 @@ zfcp_sysfs_port_remove_store(struct devi
 	zfcp_erp_port_shutdown(port, 0);
 	zfcp_erp_wait(adapter);
 	zfcp_port_put(port);
+	zfcp_sysfs_port_remove_files(&port->sysfs_device,
+				     atomic_read(&port->status));
 	device_unregister(&port->sysfs_device);
  out:
 	up(&zfcp_data.config_sema);
@@ -268,6 +267,7 @@ zfcp_sysfs_adapter_failed_store(struct d
 	zfcp_erp_modify_adapter_status(adapter, ZFCP_STATUS_COMMON_RUNNING,
 				       ZFCP_SET);
 	zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED);
+	zfcp_erp_wait(adapter);
  out:
 	up(&zfcp_data.config_sema);
 	return retval ? retval : count;
diff -puN drivers/s390/scsi/zfcp_sysfs_port.c~linus drivers/s390/scsi/zfcp_sysfs_port.c
--- 25/drivers/s390/scsi/zfcp_sysfs_port.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/scsi/zfcp_sysfs_port.c	2004-01-19 22:17:23.000000000 -0800
@@ -25,7 +25,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#define ZFCP_SYSFS_PORT_C_REVISION "$Revision: 1.26 $"
+#define ZFCP_SYSFS_PORT_C_REVISION "$Revision: 1.32 $"
 
 #include <linux/init.h>
 #include <linux/module.h>
@@ -110,11 +110,9 @@ zfcp_sysfs_unit_add_store(struct device 
 
 	retval = 0;
 
-	zfcp_port_get(port);
-
-	/* try to open unit only if adapter is online */
-	if (port->adapter->ccw_device->online == 1)
-		zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED);
+	zfcp_erp_unit_reopen(unit, 0);
+	zfcp_erp_wait(unit->port->adapter);
+	wait_event(unit->scsi_add_wq, atomic_read(&unit->scsi_add_work) == 0);
 	zfcp_unit_put(unit);
  out:
 	up(&zfcp_data.config_sema);
@@ -170,6 +168,7 @@ zfcp_sysfs_unit_remove_store(struct devi
 	zfcp_erp_unit_shutdown(unit, 0);
 	zfcp_erp_wait(unit->port->adapter);
 	zfcp_unit_put(unit);
+	zfcp_sysfs_unit_remove_files(&unit->sysfs_device);
 	device_unregister(&unit->sysfs_device);
  out:
 	up(&zfcp_data.config_sema);
@@ -217,6 +216,7 @@ zfcp_sysfs_port_failed_store(struct devi
 	}
 	zfcp_erp_modify_port_status(port, ZFCP_STATUS_COMMON_RUNNING, ZFCP_SET);
 	zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED);
+	zfcp_erp_wait(port->adapter);
  out:
 	up(&zfcp_data.config_sema);
 	return retval ? retval : count;
@@ -293,7 +293,7 @@ static struct attribute_group zfcp_port_
 };
 
 /**
- * zfcp_sysfs_create_port_files - create sysfs port files
+ * zfcp_sysfs_port_create_files - create sysfs port files
  * @dev: pointer to belonging device
  *
  * Create all attributes of the sysfs representation of a port.
@@ -315,5 +315,19 @@ zfcp_sysfs_port_create_files(struct devi
 	return retval;
 }
 
+/**
+ * zfcp_sysfs_port_remove_files - remove sysfs port files
+ * @dev: pointer to belonging device
+ *
+ * Remove all attributes of the sysfs representation of a port.
+ */
+void
+zfcp_sysfs_port_remove_files(struct device *dev, u32 flags)
+{
+	sysfs_remove_group(&dev->kobj, &zfcp_port_common_attr_group);
+	if (!(flags & ZFCP_STATUS_PORT_NAMESERVER))
+		sysfs_remove_group(&dev->kobj, &zfcp_port_no_ns_attr_group);
+}
+
 #undef ZFCP_LOG_AREA
 #undef ZFCP_LOG_AREA_PREFIX
diff -puN drivers/s390/scsi/zfcp_sysfs_unit.c~linus drivers/s390/scsi/zfcp_sysfs_unit.c
--- 25/drivers/s390/scsi/zfcp_sysfs_unit.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/s390/scsi/zfcp_sysfs_unit.c	2004-01-19 22:17:23.000000000 -0800
@@ -25,7 +25,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#define ZFCP_SYSFS_UNIT_C_REVISION "$Revision: 1.17 $"
+#define ZFCP_SYSFS_UNIT_C_REVISION "$Revision: 1.19 $"
 
 #include <linux/init.h>
 #include <linux/module.h>
@@ -186,5 +186,17 @@ zfcp_sysfs_unit_create_files(struct devi
 	return sysfs_create_group(&dev->kobj, &zfcp_unit_attr_group);
 }
 
+/** 
+ * zfcp_sysfs_remove_unit_files - remove sysfs unit files
+ * @dev: pointer to belonging device
+ *
+ * Remove all attributes of the sysfs representation of a unit.
+ */
+void
+zfcp_sysfs_unit_remove_files(struct device *dev)
+{
+	sysfs_remove_group(&dev->kobj, &zfcp_unit_attr_group);
+}
+
 #undef ZFCP_LOG_AREA
 #undef ZFCP_LOG_AREA_PREFIX
diff -puN drivers/sbus/char/rtc.c~linus drivers/sbus/char/rtc.c
--- 25/drivers/sbus/char/rtc.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/sbus/char/rtc.c	2004-01-19 22:17:23.000000000 -0800
@@ -89,6 +89,7 @@ static int rtc_ioctl(struct inode *inode
 	switch (cmd)
 	{
 	case RTCGET:
+		memset(&rtc_tm, 0, sizeof(struct rtc_time));
 		get_rtc_time(&rtc_tm);
 
 		if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time)))
diff -puN drivers/scsi/53c7xx.c~linus drivers/scsi/53c7xx.c
--- 25/drivers/scsi/53c7xx.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/53c7xx.c	2004-01-19 22:17:23.000000000 -0800
@@ -1102,8 +1102,8 @@ NCR53c7x0_init (struct Scsi_Host *host) 
 }
 
 /* 
- * Function : static int ncr53c7xx_init(Scsi_Host_Template *tpnt, int board, 
- *	int chip, u32 base, int io_port, int irq, int dma, long long options,
+ * Function : int ncr53c7xx_init(Scsi_Host_Template *tpnt, int board, int chip,
+ *	unsigned long base, int io_port, int irq, int dma, long long options,
  *	int clock);
  *
  * Purpose : initializes a NCR53c7,8x0 based on base addresses,
diff -puN drivers/scsi/53c7xx.h~linus drivers/scsi/53c7xx.h
--- 25/drivers/scsi/53c7xx.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/53c7xx.h	2004-01-19 22:17:23.000000000 -0800
@@ -1600,5 +1600,9 @@ struct NCR53c7x0_hostdata {
 /* Paranoid people could use panic() here. */
 #define FATAL(host) shutdown((host));
 
+extern int ncr53c7xx_init(Scsi_Host_Template *tpnt, int board, int chip,
+			  unsigned long base, int io_port, int irq, int dma,
+			  long long options, int clock);
+
 #endif /* NCR53c710_C */
 #endif /* NCR53c710_H */
diff -puN drivers/scsi/aacraid/aachba.c~linus drivers/scsi/aacraid/aachba.c
--- 25/drivers/scsi/aacraid/aachba.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/aacraid/aachba.c	2004-01-19 22:17:23.000000000 -0800
@@ -1427,6 +1427,7 @@ static int aac_send_srb_fib(struct scsi_
 		flag = SRB_DataIn;
 		break;
 	case DMA_NONE:
+	default:	/* shuts up some versions of gcc */
 		flag = SRB_NoDataXfer;
 		break;
 	}
diff -puN drivers/scsi/aha152x.c~linus drivers/scsi/aha152x.c
--- 25/drivers/scsi/aha152x.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/aha152x.c	2004-01-19 22:17:23.000000000 -0800
@@ -860,9 +860,6 @@ static int aha152x_porttest(int io_port)
 {
 	int i;
 
-	if (check_region(io_port, IO_RANGE))
-		return 0;
-
 	SETPORT(io_port + O_DMACNTRL1, 0);	/* reset stack pointer */
 	for (i = 0; i < 16; i++)
 		SETPORT(io_port + O_STACK, i);
@@ -878,9 +875,6 @@ static int tc1550_porttest(int io_port)
 {
 	int i;
 
-	if (check_region(io_port, IO_RANGE))
-		return 0;
-
 	SETPORT(io_port + O_TC_DMACNTRL1, 0);	/* reset stack pointer */
 	for (i = 0; i < 16; i++)
 		SETPORT(io_port + O_STACK, i);
@@ -903,13 +897,20 @@ static int checksetup(struct aha152x_set
 	if (i == ARRAY_SIZE(ports))
 		return 0;
 #endif
+	if (!request_region(setup->io_port, IO_RANGE, "aha152x"))
+		return 0;
 
 	if(aha152x_porttest(setup->io_port)) {
-          setup->tc1550=0;
+		setup->tc1550=0;
         } else if(tc1550_porttest(setup->io_port)) {
-          setup->tc1550=1;
-        } else
-          return 0;
+		setup->tc1550=1;
+	} else {
+		release_region(setup->io_port, IO_RANGE);
+		return 0;
+	}
+
+	release_region(setup->io_port, IO_RANGE);
+
 
 	if ((setup->irq < IRQ_MIN) || (setup->irq > IRQ_MAX))
 		return 0;
@@ -965,7 +966,7 @@ struct Scsi_Host *aha152x_probe_one(stru
 {
 	struct Scsi_Host *shpnt;
 
-	shpnt = scsi_register(&aha152x_driver_template, sizeof(struct aha152x_hostdata));
+	shpnt = scsi_host_alloc(&aha152x_driver_template, sizeof(struct aha152x_hostdata));
 	if (!shpnt) {
 		printk(KERN_ERR "aha152x: scsi_register failed\n");
 		return NULL;
@@ -1080,6 +1081,9 @@ struct Scsi_Host *aha152x_probe_one(stru
 		printk(KERN_ERR "aha152x%d: failed to reassign interrupt.\n", shpnt->host_no);
 		goto out_unregister_host;
 	}
+
+	scsi_add_host(shpnt, 0);
+	scsi_scan_host(shpnt);
 	return shpnt;	/* the pcmcia stub needs the return value; */
 
 out_unregister_host:
@@ -1087,11 +1091,11 @@ out_unregister_host:
 out_release_region:
 	release_region(shpnt->io_port, IO_RANGE);
 out_unregister:
-	scsi_unregister(shpnt);
+	scsi_host_put(shpnt);
 	return NULL;
 }
 
-static int aha152x_detect(Scsi_Host_Template * tpnt)
+static int __init aha152x_init(void)
 {
 	int i, j, ok;
 #if defined(AUTOCONF)
@@ -1360,7 +1364,6 @@ static int aha152x_detect(Scsi_Host_Temp
 	return registered_count>0;
 }
 
-
 static int aha152x_release(struct Scsi_Host *shpnt)
 {
 	if (shpnt->irq)
@@ -1374,11 +1377,25 @@ static int aha152x_release(struct Scsi_H
 		pnp_device_detach(HOSTDATA(shpnt)->pnpdev);
 #endif
 
-	scsi_unregister(shpnt);
+	scsi_host_put(shpnt);
 
 	return 0;
 }
 
+static void __exit aha152x_exit(void)
+{
+	int i;
+
+	for(i=0; i<ARRAY_SIZE(setup); i++) {
+		if(aha152x_host[i]) {
+			scsi_remove_host(aha152x_host[i]);
+			aha152x_release(aha152x_host[i]);
+			aha152x_host[i]=0;
+		}
+	}
+}
+
+
 /*
  * setup controller to generate interrupts depending
  * on current state (lock has to be acquired)
@@ -3880,26 +3897,24 @@ static int aha152x_proc_info(struct Scsi
 }
 
 static Scsi_Host_Template aha152x_driver_template = {
-	.module			= THIS_MODULE,
-	.name			= AHA152X_REVID,
-	.proc_name		= "aha152x",
-	.proc_info		= aha152x_proc_info,
-	.detect			= aha152x_detect,
-	.queuecommand		= aha152x_queue,
-	.eh_abort_handler	= aha152x_abort,
-	.eh_device_reset_handler = aha152x_device_reset,
-	.eh_bus_reset_handler	= aha152x_bus_reset,
-	.eh_host_reset_handler	= aha152x_host_reset,
-	.release		= aha152x_release,
-	.bios_param		= aha152x_biosparam,
-	.can_queue		= 1,
-	.this_id		= 7,
-	.sg_tablesize		= SG_ALL,
-	.cmd_per_lun		= 1,
-	.use_clustering		= DISABLE_CLUSTERING,
+	.module				= THIS_MODULE,
+	.name				= AHA152X_REVID,
+	.proc_name			= "aha152x",
+	.proc_info			= aha152x_proc_info,
+	.queuecommand			= aha152x_queue,
+	.eh_abort_handler		= aha152x_abort,
+	.eh_device_reset_handler	= aha152x_device_reset,
+	.eh_bus_reset_handler		= aha152x_bus_reset,
+	.eh_host_reset_handler		= aha152x_host_reset,
+	.bios_param			= aha152x_biosparam,
+	.can_queue			= 1,
+	.this_id			= 7,
+	.sg_tablesize			= SG_ALL,
+	.cmd_per_lun			= 1,
+	.use_clustering			= DISABLE_CLUSTERING,
 };
 
 #ifndef PCMCIA
-#define driver_template aha152x_driver_template
-#include "scsi_module.c"
+module_init(aha152x_init);
+module_exit(aha152x_exit);
 #endif
diff -puN drivers/scsi/aic7xxx/aic79xx_osm.c~linus drivers/scsi/aic7xxx/aic79xx_osm.c
--- 25/drivers/scsi/aic7xxx/aic79xx_osm.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/aic7xxx/aic79xx_osm.c	2004-01-19 22:17:23.000000000 -0800
@@ -1776,12 +1776,18 @@ ahd_dmamem_alloc(struct ahd_softc *ahd, 
 	 * our dma mask when doing allocations.
 	 */
 	if (ahd->dev_softc != NULL)
-		ahd_pci_set_dma_mask(ahd->dev_softc, 0xFFFFFFFF);
+		if (ahd_pci_set_dma_mask(ahd->dev_softc, 0xFFFFFFFF)) {
+			printk(KERN_WARNING "aic79xx: No suitable DMA available.\n");
+			return (ENODEV);
+		}
 	*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);
+		if (ahd_pci_set_dma_mask(ahd->dev_softc,
+				     ahd->platform_data->hw_dma_mask)) {
+			printk(KERN_WARNING "aic79xx: No suitable DMA available.\n");
+			return (ENODEV);
+		}
 #else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */
 	/*
 	 * At least in 2.2.14, malloc is a slab allocator so all
diff -puN drivers/scsi/aic7xxx/aic7xxx_osm.c~linus drivers/scsi/aic7xxx/aic7xxx_osm.c
--- 25/drivers/scsi/aic7xxx/aic7xxx_osm.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/aic7xxx/aic7xxx_osm.c	2004-01-19 22:17:23.000000000 -0800
@@ -1411,12 +1411,18 @@ ahc_dmamem_alloc(struct ahc_softc *ahc, 
 	 * our dma mask when doing allocations.
 	 */
 	if (ahc->dev_softc != NULL)
-		ahc_pci_set_dma_mask(ahc->dev_softc, 0xFFFFFFFF);
+		if (ahc_pci_set_dma_mask(ahc->dev_softc, 0xFFFFFFFF)) {
+			printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n");
+			return (ENODEV);
+		}
 	*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);
+		if (ahc_pci_set_dma_mask(ahc->dev_softc,
+				     ahc->platform_data->hw_dma_mask)) {
+			printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n");
+			return (ENODEV);
+		}
 #else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */
 	/*
 	 * At least in 2.2.14, malloc is a slab allocator so all
diff -puN drivers/scsi/aic7xxx/aic7xxx_osm_pci.c~linus drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
--- 25/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c	2004-01-19 22:17:23.000000000 -0800
@@ -166,7 +166,10 @@ ahc_linux_pci_dev_probe(struct pci_dev *
 		ahc->flags |= AHC_39BIT_ADDRESSING;
 		ahc->platform_data->hw_dma_mask = mask_39bit;
 	} else {
-		ahc_pci_set_dma_mask(pdev, 0xFFFFFFFF);
+		if (ahc_pci_set_dma_mask(pdev, 0xFFFFFFFF)) {
+			printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n");
+                	return (-ENODEV);
+		}
 		ahc->platform_data->hw_dma_mask = 0xFFFFFFFF;
 	}
 #endif
diff -puN drivers/scsi/aic7xxx_old/aic7xxx_proc.c~linus drivers/scsi/aic7xxx_old/aic7xxx_proc.c
--- 25/drivers/scsi/aic7xxx_old/aic7xxx_proc.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/aic7xxx_old/aic7xxx_proc.c	2004-01-19 22:17:23.000000000 -0800
@@ -90,9 +90,7 @@ aic7xxx_proc_info ( struct Scsi_Host *HB
   unsigned char i;
   unsigned char tindex;
 
-  HBAptr = NULL;
-
-  for(p=first_aic7xxx; p->host != HBAptr; p=p->next)
+  for(p=first_aic7xxx; p && p->host != HBAptr; p=p->next)
     ;
 
   if (!p)
diff -puN drivers/scsi/amiga7xx.c~linus drivers/scsi/amiga7xx.c
--- 25/drivers/scsi/amiga7xx.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/amiga7xx.c	2004-01-19 22:17:23.000000000 -0800
@@ -1,6 +1,6 @@
 /*
  * Detection routine for the NCR53c710 based Amiga SCSI Controllers for Linux.
- *  		Amiga MacroSystemUS WarpEngine SCSI controller.
+ *		Amiga MacroSystemUS WarpEngine SCSI controller.
  *		Amiga Technologies A4000T SCSI controller.
  *		Amiga Technologies/DKB A4091 SCSI controller.
  *
@@ -14,13 +14,14 @@
 #include <linux/version.h>
 #include <linux/config.h>
 #include <linux/zorro.h>
+#include <linux/stat.h>
 
 #include <asm/setup.h>
 #include <asm/page.h>
 #include <asm/pgtable.h>
 #include <asm/amigaints.h>
 #include <asm/amigahw.h>
-
+#include <asm/dma.h>
 #include <asm/irq.h>
 
 #include "scsi.h"
@@ -28,107 +29,83 @@
 #include "53c7xx.h"
 #include "amiga7xx.h"
 
-#include<linux/stat.h>
-
-extern int ncr53c7xx_init (Scsi_Host_Template *tpnt, int board, int chip, 
-			   unsigned long base, int io_port, int irq, int dma,
-			   long long options, int clock);
 
-int __init amiga7xx_detect(Scsi_Host_Template *tpnt)
+static int amiga7xx_register_one(Scsi_Host_Template *tpnt,
+				 unsigned long address)
 {
-    static unsigned char called = 0;
-    int num = 0, clock;
     long long options;
-    struct zorro_dev *z = NULL;
-    unsigned long address;
+    int clock;
 
-    if (called || !MACH_IS_AMIGA)
+    if (!request_mem_region(address, 0x1000, "ncr53c710"))
 	return 0;
 
-    tpnt->proc_name = "Amiga7xx";
+    address = (unsigned long)z_ioremap(address, 0x1000);
+    options = OPTION_MEMORY_MAPPED | OPTION_DEBUG_TEST1 | OPTION_INTFLY |
+	      OPTION_SYNCHRONOUS | OPTION_ALWAYS_SYNCHRONOUS |
+	      OPTION_DISCONNECT;
+    clock = 50000000;	/* 50 MHz SCSI Clock */
+    ncr53c7xx_init(tpnt, 0, 710, address, 0, IRQ_AMIGA_PORTS, DMA_NONE,
+		   options, clock);
+    return 1;
+}
 
-#ifdef CONFIG_A4000T_SCSI
-    if (AMIGAHW_PRESENT(A4000_SCSI)) {
-	address = 0xdd0040;
-	if (request_mem_region(address, 0x1000, "ncr53c710")) { 
-	    address = ZTWO_VADDR(address);
-	    options = OPTION_MEMORY_MAPPED | OPTION_DEBUG_TEST1 |
-		      OPTION_INTFLY | OPTION_SYNCHRONOUS |
-		      OPTION_ALWAYS_SYNCHRONOUS | OPTION_DISCONNECT;
-	    clock = 50000000;	/* 50MHz SCSI Clock */
-	    ncr53c7xx_init(tpnt, 0, 710, address, 0, IRQ_AMIGA_PORTS, DMA_NONE,
-			   options, clock);
-	    num++;
-	}
-    }
-#endif
+
+#ifdef CONFIG_ZORRO
+
+static struct {
+    zorro_id id;
+    unsigned long offset;
+    int absolute;	/* offset is absolute address */
+} amiga7xx_table[] = {
+    { .id = ZORRO_PROD_PHASE5_BLIZZARD_603E_PLUS, .offset = 0xf40000,
+      .absolute = 1 },
+    { .id = ZORRO_PROD_MACROSYSTEMS_WARP_ENGINE_40xx, .offset = 0x40000 },
+    { .id = ZORRO_PROD_CBM_A4091_1, .offset = 0x800000 },
+    { .id = ZORRO_PROD_CBM_A4091_2, .offset = 0x800000 },
+    { .id = ZORRO_PROD_GVP_GFORCE_040_060, .offset = 0x40000 },
+    { 0 }
+};
+
+static int __init amiga7xx_zorro_detect(Scsi_Host_Template *tpnt)
+{
+    int num = 0, i;
+    struct zorro_dev *z = NULL;
+    unsigned long address;
 
     while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
-	unsigned long address = z->resource.start;
-	unsigned long size = z->resource.end-z->resource.start+1;
-	switch (z->id) {
-#ifdef CONFIG_BLZ603EPLUS_SCSI
-	    case ZORRO_PROD_PHASE5_BLIZZARD_603E_PLUS:
-		address = 0xf40000;
-		if (request_mem_region(address, 0x1000, "ncr53c710")) {
-		    address = ZTWO_VADDR(address);
-		    options = OPTION_MEMORY_MAPPED | OPTION_DEBUG_TEST1 |
-			      OPTION_INTFLY | OPTION_SYNCHRONOUS | 
-			      OPTION_ALWAYS_SYNCHRONOUS | OPTION_DISCONNECT;
-		    clock = 50000000;	/* 50MHz SCSI Clock */
-		    ncr53c7xx_init(tpnt, 0, 710, address, 0, IRQ_AMIGA_PORTS,
-				   DMA_NONE, options, clock);
-		    num++;
-		}
+	for (i = 0; amiga7xx_table[i].id; i++)
+	    if (z->id == amiga7xx_table[i].id)
 		break;
-#endif
+	if (!amiga7xx_table[i].id)
+	    continue;
+	if (amiga7xx_table[i].absolute)
+	    address = amiga7xx_table[i].offset;
+	else
+	    address = z->resource.start + amiga7xx_table[i].offset;
+	num += amiga7xx_register_one(tpnt, address);
+    }
+    return num;
+}
 
-#ifdef CONFIG_WARPENGINE_SCSI
-    	    case ZORRO_PROD_MACROSYSTEMS_WARP_ENGINE_40xx:
-		if (request_mem_region(address+0x40000, 0x1000, "ncr53c710")) {
-		    address = (unsigned long)z_ioremap(address, size);
-		    options = OPTION_MEMORY_MAPPED | OPTION_DEBUG_TEST1 |
-			      OPTION_INTFLY | OPTION_SYNCHRONOUS |
-			      OPTION_ALWAYS_SYNCHRONOUS | OPTION_DISCONNECT;
-		    clock = 50000000;	/* 50MHz SCSI Clock */
-		    ncr53c7xx_init(tpnt, 0, 710, address+0x40000, 0,
-				   IRQ_AMIGA_PORTS, DMA_NONE, options, clock);
-		    num++;
-		}
-		break;
-#endif
+#endif /* CONFIG_ZORRO */
 
-#ifdef CONFIG_A4091_SCSI
-	    case ZORRO_PROD_CBM_A4091_1:
-	    case ZORRO_PROD_CBM_A4091_2:
-		if (request_mem_region(address+0x800000, 0x1000, "ncr53c710")) {
-		    address = (unsigned long)z_ioremap(address, size);
-		    options = OPTION_MEMORY_MAPPED | OPTION_DEBUG_TEST1 |
-			      OPTION_INTFLY | OPTION_SYNCHRONOUS |
-			      OPTION_ALWAYS_SYNCHRONOUS | OPTION_DISCONNECT;
-		    clock = 50000000;	/* 50MHz SCSI Clock */
-		    ncr53c7xx_init(tpnt, 0, 710, address+0x800000, 0,
-				   IRQ_AMIGA_PORTS, DMA_NONE, options, clock);
-		    num++;
-		}
-		break;
-#endif
 
-#ifdef CONFIG_GVP_TURBO_SCSI
-    	    case ZORRO_PROD_GVP_GFORCE_040_060:
-		if (request_mem_region(address+0x40000, 0x1000, "ncr53c710")) {
-		    address = ZTWO_VADDR(address);
-		    options = OPTION_MEMORY_MAPPED | OPTION_DEBUG_TEST1 |
-			      OPTION_INTFLY | OPTION_SYNCHRONOUS |
-			      OPTION_ALWAYS_SYNCHRONOUS | OPTION_DISCONNECT;
-		    clock = 50000000;	/* 50MHz SCSI Clock */
-		    ncr53c7xx_init(tpnt, 0, 710, address+0x40000, 0,
-				   IRQ_AMIGA_PORTS, DMA_NONE, options, clock);
-		    num++;
-		}
+int __init amiga7xx_detect(Scsi_Host_Template *tpnt)
+{
+    static unsigned char called = 0;
+    int num = 0;
+
+    if (called || !MACH_IS_AMIGA)
+	return 0;
+
+    tpnt->proc_name = "Amiga7xx";
+
+    if (AMIGAHW_PRESENT(A4000_SCSI))
+	num += amiga7xx_register_one(tpnt, 0xdd0040);
+
+#ifdef CONFIG_ZORRO
+    num += amiga7xx_zorro_detect(tpnt);
 #endif
-	}
-    }
 
     called = 1;
     return num;
diff -puN drivers/scsi/atp870u.c~linus drivers/scsi/atp870u.c
--- 25/drivers/scsi/atp870u.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/atp870u.c	2004-01-19 22:17:23.000000000 -0800
@@ -42,50 +42,6 @@
 
 static unsigned short int sync_idu;
 
-#define MAX_ATP		16
-
-struct atp_unit {
-	unsigned long ioport;
-	unsigned long irq;
-	unsigned long pciport;
-	unsigned char last_cmd;
-	unsigned char in_snd;
-	unsigned char in_int;
-	unsigned char quhdu;
-	unsigned char quendu;
-	unsigned char scam_on;
-	unsigned char global_map;
-	unsigned char chip_veru;
-	unsigned char host_idu;
-	int working;
-	unsigned short wide_idu;
-	unsigned short active_idu;
-	unsigned short ultra_map;
-	unsigned short async;
-	unsigned short deviceid;
-	unsigned char ata_cdbu[16];
-	unsigned char sp[16];
-	Scsi_Cmnd *querequ[qcnt];
-	struct atp_id {
-		unsigned char dirctu;
-		unsigned char devspu;
-		unsigned char devtypeu;
-		unsigned long prdaddru;
-		unsigned long tran_lenu;
-		unsigned long last_lenu;
-		unsigned char *prd_posu;
-		unsigned char *prd_tableu;
-		dma_addr_t prd_phys;
-		Scsi_Cmnd *curr_req;
-	} id[16];
-	struct Scsi_Host *host;
-	struct pci_dev *pdev;
-};
-
-static struct Scsi_Host *atp_host[MAX_ATP];
-
-static void send_s870(struct Scsi_Host *);
-
 static irqreturn_t atp870u_intr_handle(int irq, void *dev_id,
 					struct pt_regs *regs)
 {
@@ -878,7 +834,7 @@ static void tscam(struct Scsi_Host *host
 	unsigned long n;
 	unsigned short int m, assignid_map, val;
 	unsigned char mbuf[33], quintet[2];
-	struct atp_unit *dev = (struct atp_unit *)host->hostdata;
+	struct atp_unit *dev = (struct atp_unit *)&host->hostdata;
 	static unsigned char g2q_tab[8] = {
 		0x38, 0x31, 0x32, 0x2b, 0x34, 0x2d, 0x2e, 0x27
 	};
@@ -2253,15 +2209,31 @@ set_syn_ok:
 	}
 }
 
-
-static void atp870u_init_tables(struct Scsi_Host *host)
+static void atp870u_free_tables(struct Scsi_Host *host)
 {
-	struct atp_unit *dev = (struct atp_unit *)&host->hostdata;
+	struct atp_unit *atp_dev = (struct atp_unit *)&host->hostdata;
 	int k;
 
 	for (k = 0; k < 16; k++) {
-		/* FIXME */
+		if (!atp_dev->id[k].prd_tableu)
+			continue;
+		pci_free_consistent(atp_dev->pdev, 1024, atp_dev->id[k].prd_tableu,
+					atp_dev->id[k].prd_phys);
+		atp_dev->id[k].prd_tableu = NULL;
+	}
+}
+
+static int atp870u_init_tables(struct Scsi_Host *host)
+{
+	struct atp_unit *dev = (struct atp_unit *)&host->hostdata;
+	int k, i;
+
+	for (i = k = 0; k < 16; k++) {
 		dev->id[k].prd_tableu = pci_alloc_consistent(dev->pdev, 1024, &dev->id[k].prd_phys);
+		if (!dev->id[k].prd_tableu) {
+			atp870u_free_tables(host);
+			return -ENOMEM;
+		}
 		dev->id[k].devspu = 0x20;
 		dev->id[k].devtypeu = 0;
 		dev->id[k].curr_req = NULL;
@@ -2282,293 +2254,294 @@ static void atp870u_init_tables(struct S
 		dev->id[k].curr_req = 0;
 		dev->sp[k] = 0x04;
 	}
+	return 0;
 }			
 
 /* return non-zero on detection */
-static int atp870u_detect(Scsi_Host_Template * tpnt)
+static int atp870u_probe(struct pci_dev *dev, const struct pci_device_id *ent)
 {
-	unsigned char irq, h, k, m;
+	unsigned char k, m;
 	unsigned long flags;
 	unsigned int base_io, error, tmport;
-	struct pci_dev *pdev[MAX_ATP];
-	unsigned char chip_ver[MAX_ATP], host_id;
-	unsigned short dev_id[MAX_ATP], n;
-	struct Scsi_Host *shpnt = NULL;
-	int card = 0;
-	int count = 0;
-
-	static unsigned short devid[9] = {
-		0x8081, 0x8002, 0x8010, 0x8020, 0x8030, 0x8040, 0x8050, 0x8060, 0
-	};
-
-	printk(KERN_INFO "aec671x_detect: \n");
-	tpnt->proc_name = "atp870u";
+	unsigned char host_id;
+	unsigned short n;
+	struct Scsi_Host *shpnt;
+	struct atp_unit atp_dev, *p;
+	static int count;
+
+	if (pci_enable_device(dev))
+		return -EIO;
+
+	if (pci_set_dma_mask(dev, 0xFFFFFFFFUL)) {
+		printk(KERN_ERR "atp870u: 32bit DMA mask required but not available.\n");
+		return -EIO;
+	}
+	
+	memset(&atp_dev, 0, sizeof atp_dev);
+ 
+	/*
+	 * It's probably easier to weed out some revisions like
+	 * this than via the PCI device table
+	 */
+	if (ent->device == PCI_DEVICE_ID_ARTOP_AEC7610) {
+		error = pci_read_config_byte(dev, PCI_CLASS_REVISION, &atp_dev.chip_veru);
+		if (atp_dev.chip_veru < 2)
+			return -EIO;
+	}
+
+	switch (ent->device) {
+	case 0x8081:
+	case PCI_DEVICE_ID_ARTOP_AEC7612UW:
+	case PCI_DEVICE_ID_ARTOP_AEC7612SUW:
+		atp_dev.chip_veru = 0x04;
+	default:
+		break;
+	}
+
+	base_io = pci_resource_start(dev, 0);
+
+	if (ent->device != 0x8081) {
+		error = pci_read_config_byte(dev, 0x49, &host_id);
+		base_io &= 0xfffffff8;
+
+		printk(KERN_INFO "   ACARD AEC-671X PCI Ultra/W SCSI-3 Host Adapter: %d "
+			"IO:%x, IRQ:%d.\n", count, base_io, dev->irq);
+
+		atp_dev.unit = count;	
+		atp_dev.ioport = base_io;
+		atp_dev.pciport = base_io + 0x20;
+		atp_dev.deviceid = ent->device;
+		host_id &= 0x07;
+		atp_dev.host_idu = host_id;
+		tmport = base_io + 0x22;
+		atp_dev.scam_on = inb(tmport);
+		tmport += 0x0b;
+		atp_dev.global_map = inb(tmport++);
+		atp_dev.ultra_map = inw(tmport);
+
+		if (atp_dev.ultra_map == 0) {
+			atp_dev.scam_on = 0x00;
+			atp_dev.global_map = 0x20;
+			atp_dev.ultra_map = 0xffff;
+		}
+
+		shpnt = scsi_host_alloc(&atp870u_template, sizeof(struct atp_unit));
+		if (!shpnt)
+			return -ENOMEM;
 
-	for (h = 0; devid[h]; h++) {
-		struct pci_dev *dev = NULL;
+		p = (struct atp_unit *)&shpnt->hostdata;
 		
-		while((dev = pci_find_device(0x1191, devid[h], dev))!=NULL)
-		{
-			if(pci_enable_device(dev))
-				continue;
-
-			if(pci_set_dma_mask(dev, 0xFFFFFFFFUL))
-			{
-				printk(KERN_ERR "atp870u: 32bit DMA mask required but not available.\n");
-				continue;
-			}
-			chip_ver[card] = 0;
-			dev_id[card] = devid[h];
-
-			if (devid[h] == 0x8002) {
-				error = pci_read_config_byte(dev, 0x08, &chip_ver[card]);
-				if (chip_ver[card] < 2) {
-					continue;
-				}
-			}
-			if (devid[h] == 0x8010 || devid[h] == 0x8081 || devid[h] == 0x8050) {
-				chip_ver[card] = 0x04;
-			}
-			pdev[card] = dev;
-			card++;
-			if (card == MAX_ATP)
-				break;
-		}
-	}
-	for (h = 0; h < card; h++) {
-		struct atp_unit tmp, *dev;
-
-		/* Found an atp870u/w. */
-		base_io = pci_resource_start(pdev[h], 0);
-		irq = pdev[h]->irq;
-
-		if (dev_id[h] != 0x8081) {
-			error = pci_read_config_byte(pdev[h], 0x49, &host_id);
-
-			base_io &= 0xfffffff8;
-
-			if (check_region(base_io, 0x40) != 0) {
-				return 0;
-			}
-			printk(KERN_INFO "   ACARD AEC-671X PCI Ultra/W SCSI-3 Host Adapter: %d    IO:%x, IRQ:%d.\n", h, base_io, irq);
-			
-			tmp.ioport = base_io;
-			tmp.pciport = base_io + 0x20;
-			tmp.deviceid = dev_id[h];
-			host_id &= 0x07;
-			tmp.host_idu = host_id;
-			tmp.chip_veru = chip_ver[h];
-
-			tmport = base_io + 0x22;
-			tmp.scam_on = inb(tmport);
-			tmport += 0x0b;
-			tmp.global_map = inb(tmport++);
-			tmp.ultra_map = inw(tmport);
-			if (tmp.ultra_map == 0) {
-				tmp.scam_on = 0x00;
-				tmp.global_map = 0x20;
-				tmp.ultra_map = 0xffff;
-			}
-			shpnt = scsi_register(tpnt, sizeof(struct atp_unit));
-			if (shpnt == NULL)
-				return count;
-			tmp.host = shpnt;
-			tmp.pdev = pdev[h];
-			/* Save the atp_unit data */
-			memcpy(&shpnt->hostdata, &tmp, sizeof(tmp));
-
-			atp870u_init_tables(shpnt);
-			spin_lock_irqsave(shpnt->host_lock, flags);
-			if (request_irq(irq, atp870u_intr_handle, SA_SHIRQ, "atp870u", shpnt)) {
-				printk(KERN_ERR "Unable to allocate IRQ for Acard controller.\n");
-				goto unregister;
-			}
-
-			if (chip_ver[h] > 0x07) {	/* check if atp876 chip   *//* then enable terminator */
-				tmport = base_io + 0x3e;
-				outb(0x00, tmport);
-			}
+		atp_dev.host = shpnt;
+		atp_dev.pdev = dev;
+		pci_set_drvdata(dev, p);
+		memcpy(p, &atp_dev, sizeof atp_dev);
+		if (atp870u_init_tables(shpnt) < 0)
+			goto unregister;
+
+		if (request_irq(dev->irq, atp870u_intr_handle, SA_SHIRQ, "atp870u", shpnt)) {
+			printk(KERN_ERR "Unable to allocate IRQ%d for Acard controller.\n", dev->irq);
+			goto free_tables;
+		}
 
-			tmport = base_io + 0x3a;
-			k = (inb(tmport) & 0xf3) | 0x10;
-			outb(k, tmport);
-			outb((k & 0xdf), tmport);
-			mdelay(32);
-			outb(k, tmport);
-			mdelay(32);
-			tmport = base_io;
-			outb((host_id | 0x08), tmport);
-			tmport += 0x18;
-			outb(0, tmport);
-			tmport += 0x07;
-			while ((inb(tmport) & 0x80) == 0);
-			tmport -= 0x08;
-			inb(tmport);
-			tmport = base_io + 1;
-			outb(8, tmport++);
-			outb(0x7f, tmport);
-			tmport = base_io + 0x11;
-			outb(0x20, tmport);
-
-			tscam(shpnt);
-			is870(shpnt, base_io);
-			tmport = base_io + 0x3a;
-			outb((inb(tmport) & 0xef), tmport);
-			tmport++;
-			outb((inb(tmport) | 0x20), tmport);
-		} else {
-			base_io &= 0xfffffff8;
+		spin_lock_irqsave(shpnt->host_lock, flags);
+		if (atp_dev.chip_veru > 0x07) {	/* check if atp876 chip then enable terminator */
+			tmport = base_io + 0x3e;
+			outb(0x00, tmport);
+		}
+ 
+		tmport = base_io + 0x3a;
+		k = (inb(tmport) & 0xf3) | 0x10;
+		outb(k, tmport);
+		outb((k & 0xdf), tmport);
+		mdelay(32);
+		outb(k, tmport);
+		mdelay(32);
+		tmport = base_io;
+		outb((host_id | 0x08), tmport);
+		tmport += 0x18;
+		outb(0, tmport);
+		tmport += 0x07;
+		while ((inb(tmport) & 0x80) == 0)
+			mdelay(1);
 
-			if (check_region(base_io, 0x60) != 0) {
-				return 0;
-			}
-			host_id = inb(base_io + 0x39);
-			host_id >>= 0x04;
+		tmport -= 0x08;
+		inb(tmport);
+		tmport = base_io + 1;
+		outb(8, tmport++);
+		outb(0x7f, tmport);
+		tmport = base_io + 0x11;
+		outb(0x20, tmport);
 
-			printk(KERN_INFO "   ACARD AEC-67160 PCI Ultra3 LVD Host Adapter: %d    IO:%x, IRQ:%d.\n", h, base_io, irq);
-			tmp.ioport = base_io + 0x40;
-			tmp.pciport = base_io + 0x28;
-			tmp.deviceid = dev_id[h];
-			tmp.host_idu = host_id;
-			tmp.chip_veru = chip_ver[h];
-
-			tmport = base_io + 0x22;
-			tmp.scam_on = inb(tmport);
-			tmport += 0x13;
-			tmp.global_map = inb(tmport);
-			tmport += 0x07;
-			tmp.ultra_map = inw(tmport);
+		tscam(shpnt);
+		is870(shpnt, base_io);
+		tmport = base_io + 0x3a;
+		outb((inb(tmport) & 0xef), tmport);
+		tmport++;
+		outb((inb(tmport) | 0x20), tmport);
+	} else {
+		base_io &= 0xfffffff8;
+		host_id = inb(base_io + 0x39);
+		host_id >>= 0x04;
+
+		printk(KERN_INFO "   ACARD AEC-67160 PCI Ultra3 LVD Host Adapter: %d"
+			"    IO:%x, IRQ:%d.\n", count, base_io, dev->irq);
+		atp_dev.ioport = base_io + 0x40;
+		atp_dev.pciport = base_io + 0x28;
+		atp_dev.deviceid = ent->device;
+		atp_dev.host_idu = host_id;
+
+		tmport = base_io + 0x22;
+		atp_dev.scam_on = inb(tmport);
+		tmport += 0x13;
+		atp_dev.global_map = inb(tmport);
+		tmport += 0x07;
+		atp_dev.ultra_map = inw(tmport);
 
-			n = 0x3f09;
+		n = 0x3f09;
 next_fblk:
-			if (n >= 0x4000) {
-				goto flash_ok;
-			}
-			m = 0;
-			outw(n, base_io + 0x34);
-			n += 0x0002;
-			if (inb(base_io + 0x30) == 0xff) {
-				goto flash_ok;
-			}
-			tmp.sp[m++] = inb(base_io + 0x30);
-			tmp.sp[m++] = inb(base_io + 0x31);
-			tmp.sp[m++] = inb(base_io + 0x32);
-			tmp.sp[m++] = inb(base_io + 0x33);
-			outw(n, base_io + 0x34);
-			n += 0x0002;
-			tmp.sp[m++] = inb(base_io + 0x30);
-			tmp.sp[m++] = inb(base_io + 0x31);
-			tmp.sp[m++] = inb(base_io + 0x32);
-			tmp.sp[m++] = inb(base_io + 0x33);
-			outw(n, base_io + 0x34);
-			n += 0x0002;
-			tmp.sp[m++] = inb(base_io + 0x30);
-			tmp.sp[m++] = inb(base_io + 0x31);
-			tmp.sp[m++] = inb(base_io + 0x32);
-			tmp.sp[m++] = inb(base_io + 0x33);
-			outw(n, base_io + 0x34);
-			n += 0x0002;
-			tmp.sp[m++] = inb(base_io + 0x30);
-			tmp.sp[m++] = inb(base_io + 0x31);
-			tmp.sp[m++] = inb(base_io + 0x32);
-			tmp.sp[m++] = inb(base_io + 0x33);
-			n += 0x0018;
-			goto next_fblk;
+		if (n >= 0x4000)
+			goto flash_ok;
+
+		m = 0;
+		outw(n, base_io + 0x34);
+		n += 0x0002;
+		if (inb(base_io + 0x30) == 0xff)
+			goto flash_ok;
+
+		atp_dev.sp[m++] = inb(base_io + 0x30);
+		atp_dev.sp[m++] = inb(base_io + 0x31);
+		atp_dev.sp[m++] = inb(base_io + 0x32);
+		atp_dev.sp[m++] = inb(base_io + 0x33);
+		outw(n, base_io + 0x34);
+		n += 0x0002;
+		atp_dev.sp[m++] = inb(base_io + 0x30);
+		atp_dev.sp[m++] = inb(base_io + 0x31);
+		atp_dev.sp[m++] = inb(base_io + 0x32);
+		atp_dev.sp[m++] = inb(base_io + 0x33);
+		outw(n, base_io + 0x34);
+		n += 0x0002;
+		atp_dev.sp[m++] = inb(base_io + 0x30);
+		atp_dev.sp[m++] = inb(base_io + 0x31);
+		atp_dev.sp[m++] = inb(base_io + 0x32);
+		atp_dev.sp[m++] = inb(base_io + 0x33);
+		outw(n, base_io + 0x34);
+		n += 0x0002;
+		atp_dev.sp[m++] = inb(base_io + 0x30);
+		atp_dev.sp[m++] = inb(base_io + 0x31);
+		atp_dev.sp[m++] = inb(base_io + 0x32);
+		atp_dev.sp[m++] = inb(base_io + 0x33);
+		n += 0x0018;
+		goto next_fblk;
 flash_ok:
-			outw(0, base_io + 0x34);
-			tmp.ultra_map = 0;
-			tmp.async = 0;
-			for (k = 0; k < 16; k++) {
-				n = 1;
-				n = n << k;
-				if (tmp.sp[k] > 1) {
-					tmp.ultra_map |= n;
-				} else {
-					if (tmp.sp[k] == 0) {
-						tmp.async |= n;
-					}
-				}
-			}
-			tmp.async = ~(tmp.async);
-			outb(tmp.global_map, base_io + 0x35);
+		outw(0, base_io + 0x34);
+		atp_dev.ultra_map = 0;
+		atp_dev.async = 0;
+		for (k = 0; k < 16; k++) {
+			n = 1;
+			n = n << k;
+			if (atp_dev.sp[k] > 1) {
+				atp_dev.ultra_map |= n;
+			} else {
+				if (atp_dev.sp[k] == 0)
+					atp_dev.async |= n;
+ 			}
+	 	}
+		atp_dev.async = ~(atp_dev.async);
+		outb(atp_dev.global_map, base_io + 0x35);
+ 
+		shpnt = scsi_host_alloc(&atp870u_template, sizeof(struct atp_unit));
+		if (!shpnt)
+			return -ENOMEM;
+
+		p = (struct atp_unit *)&shpnt->hostdata;
+
+		atp_dev.host = shpnt;
+		atp_dev.pdev = dev;
+		pci_set_drvdata(dev, p);
+		memcpy(p, &atp_dev, sizeof atp_dev);
+		if (atp870u_init_tables(shpnt) < 0) {
+			printk(KERN_ERR "Unable to allocate tables for Acard controller\n");
+			goto unregister;
+		}
+
+		if (request_irq(dev->irq, atp870u_intr_handle, SA_SHIRQ, "atp870u", shpnt)) {
+ 			printk(KERN_ERR "Unable to allocate IRQ%d for Acard controller.\n", dev->irq);
+			goto free_tables;
+		}
+
+		spin_lock_irqsave(shpnt->host_lock, flags);
+		tmport = base_io + 0x38;
+		k = inb(tmport) & 0x80;
+		outb(k, tmport);
+		tmport += 0x03;
+		outb(0x20, tmport);
+		mdelay(32);
+		outb(0, tmport);
+		mdelay(32);
+		tmport = base_io + 0x5b;
+		inb(tmport);
+		tmport -= 0x04;
+		inb(tmport);
+		tmport = base_io + 0x40;
+		outb((host_id | 0x08), tmport);
+		tmport += 0x18;
+		outb(0, tmport);
+		tmport += 0x07;
+		while ((inb(tmport) & 0x80) == 0)
+			mdelay(1);
+		tmport -= 0x08;
+		inb(tmport);
+		tmport = base_io + 0x41;
+		outb(8, tmport++);
+		outb(0x7f, tmport);
+		tmport = base_io + 0x51;
+		outb(0x20, tmport);
 
-			shpnt = scsi_register(tpnt, sizeof(struct atp_unit));
-			if (shpnt == NULL)
-				return count;
-				
-			tmp.pdev = pdev[h];
-			memcpy(&shpnt->hostdata, &tmp, sizeof(tmp));
-			
-			atp870u_init_tables(shpnt);
-
-			spin_lock_irqsave(shpnt->host_lock, flags);
-			if (request_irq(irq, atp870u_intr_handle, SA_SHIRQ, "atp870u", shpnt)) {
-				printk(KERN_ERR "Unable to allocate IRQ for Acard controller.\n");
-				goto unregister;
-			}
-
-			tmport = base_io + 0x38;
-			k = inb(tmport) & 0x80;
-			outb(k, tmport);
-			tmport += 0x03;
-			outb(0x20, tmport);
-			mdelay(32);
-			outb(0, tmport);
-			mdelay(32);
-			tmport = base_io + 0x5b;
-			inb(tmport);
-			tmport -= 0x04;
-			inb(tmport);
-			tmport = base_io + 0x40;
-			outb((host_id | 0x08), tmport);
-			tmport += 0x18;
-			outb(0, tmport);
-			tmport += 0x07;
-			while ((inb(tmport) & 0x80) == 0);
-			tmport -= 0x08;
-			inb(tmport);
-			tmport = base_io + 0x41;
-			outb(8, tmport++);
-			outb(0x7f, tmport);
-			tmport = base_io + 0x51;
-			outb(0x20, tmport);
-
-			tscam(shpnt);
-			is880(shpnt, base_io);
-			tmport = base_io + 0x38;
-			outb(0xb0, tmport);
-		}
+		tscam(shpnt);
+		is880(shpnt, base_io);
+		tmport = base_io + 0x38;
+		outb(0xb0, tmport);
+	}
 
-		dev = (struct atp_unit *)&shpnt->hostdata;
-		
-		atp_host[h] = shpnt;
-		if (dev->chip_veru == 4) {
-			shpnt->max_id = 16;
-		}
-		shpnt->this_id = host_id;
-		shpnt->unique_id = base_io;
-		shpnt->io_port = base_io;
-		if (dev_id[h] == 0x8081) {
-			shpnt->n_io_port = 0x60;	/* Number of bytes of I/O space used */
-		} else {
-			shpnt->n_io_port = 0x40;	/* Number of bytes of I/O space used */
-		}
-		shpnt->irq = irq;
-		spin_unlock_irqrestore(shpnt->host_lock, flags);
-		if (dev_id[h] == 0x8081) {
-			request_region(base_io, 0x60, "atp870u");	/* Register the IO ports that we use */
-		} else {
-			request_region(base_io, 0x40, "atp870u");	/* Register the IO ports that we use */
-		}
-		count++;
-		continue;
-unregister:
-		scsi_unregister(shpnt);
-		spin_unlock_irqrestore(shpnt->host_lock, flags);
-		continue;
+	if (p->chip_veru == 4)
+		shpnt->max_id = 16;
+
+	shpnt->this_id = host_id;
+	shpnt->unique_id = base_io;
+	shpnt->io_port = base_io;
+	if (ent->device == 0x8081) {
+		shpnt->n_io_port = 0x60;	/* Number of bytes of I/O space used */
+	} else {
+		shpnt->n_io_port = 0x40;	/* Number of bytes of I/O space used */
+	}
+	shpnt->irq = dev->irq;
+	spin_unlock_irqrestore(shpnt->host_lock, flags);
+	if (ent->device == 0x8081) {
+		if (!request_region(base_io, 0x60, "atp870u"))
+			goto request_io_fail;
+	} else {
+		if (!request_region(base_io, 0x40, "atp870u"))
+			goto request_io_fail;
 	}
 
-	return count;
+	count++;
+	if (scsi_add_host(shpnt, &dev->dev))
+		goto scsi_add_fail;
+	scsi_scan_host(shpnt);
+	return 0;
+  
+scsi_add_fail:
+	if (ent->device == 0x8081)
+		release_region(base_io, 0x60);
+	else
+		release_region(base_io, 0x40);
+request_io_fail:
+	free_irq(dev->irq, shpnt);
+free_tables:
+	atp870u_free_tables(shpnt);
+unregister:
+	scsi_host_put(shpnt);
+	return -1;
 }
 
 /* The abort command does not leave the device in a clean state where
@@ -2684,25 +2657,26 @@ static int atp870u_biosparam(struct scsi
 	return 0;
 }
 
-
-static int atp870u_release(struct Scsi_Host *pshost)
+static void atp870u_remove(struct pci_dev *pdev)
 {
-	struct atp_unit *dev = (struct atp_unit *)&pshost->hostdata;
-	int k;
+	struct atp_unit *atp_dev = pci_get_drvdata(pdev);
+	struct Scsi_Host *pshost = atp_dev->host;
+
+	scsi_remove_host(pshost);
 	free_irq(pshost->irq, pshost);
 	release_region(pshost->io_port, pshost->n_io_port);
-	scsi_unregister(pshost);
-	for (k = 0; k < 16; k++)
-		pci_free_consistent(dev->pdev, 1024, dev->id[k].prd_tableu, dev->id[k].prd_phys);
-	return 0;
+	atp870u_free_tables(pshost);
+	scsi_host_put(pshost);
+	pci_set_drvdata(pdev, NULL);
 }
 
 MODULE_LICENSE("GPL");
 
-static Scsi_Host_Template driver_template = {
+static Scsi_Host_Template atp870u_template = {
+	.module			= THIS_MODULE,
+	.name			= "atp870u",
+	.proc_name		= "atp870u",
 	.proc_info		= atp870u_proc_info,
-	.detect			= atp870u_detect,
-	.release		= atp870u_release,
 	.info			= atp870u_info,
 	.queuecommand		= atp870u_queuecommand,
 	.eh_abort_handler	= atp870u_abort,
@@ -2713,4 +2687,39 @@ static Scsi_Host_Template driver_templat
 	.cmd_per_lun		= ATP870U_CMDLUN,
 	.use_clustering		= ENABLE_CLUSTERING,
 };
-#include "scsi_module.c"
+
+static struct pci_device_id atp870u_id_table[] = {
+	{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, 0x8081)			  },
+	{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_AEC7610)    },
+	{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_AEC7612UW)  },
+	{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_AEC7612U)   },
+	{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_AEC7612S)   },
+	{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_AEC7612D)	  },
+	{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_AEC7612SUW) },
+	{ PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_8060)	  },
+	{ 0, },
+};
+
+MODULE_DEVICE_TABLE(pci, atp870u_id_table);
+
+static struct pci_driver atp870u_driver = {	
+	.id_table	= atp870u_id_table,
+	.name		= "atp870u",
+	.probe		= atp870u_probe,
+	.remove		= __devexit_p(atp870u_remove),
+};
+
+static int __init atp870u_init(void)
+{
+	pci_register_driver(&atp870u_driver);
+	return 0;
+}
+
+static void __exit atp870u_exit(void)
+{
+	pci_unregister_driver(&atp870u_driver);
+}
+
+module_init(atp870u_init);
+module_exit(atp870u_exit);
+
diff -puN drivers/scsi/atp870u.h~linus drivers/scsi/atp870u.h
--- 25/drivers/scsi/atp870u.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/atp870u.h	2004-01-19 22:17:23.000000000 -0800
@@ -1,4 +1,5 @@
 #ifndef _ATP870U_H
+#define _ATP870U_H
 
 /* $Id: atp870u.h,v 1.0 1997/05/07 15:09:00 root Exp root $
 
@@ -14,20 +15,57 @@
 
 /* I/O Port */
 
-#define MAX_CDB 12
-#define MAX_SENSE 14
+#define MAX_CDB		12
+#define MAX_SENSE	14
+#define qcnt		32
+#define ATP870U_SCATTER 128
+#define ATP870U_CMDLUN 	1
+
+struct atp_unit {
+	unsigned long ioport;
+	unsigned long pciport;
+	unsigned char last_cmd;
+	unsigned char in_snd;
+	unsigned char in_int;
+	unsigned char quhdu;
+	unsigned char quendu;
+	unsigned char scam_on;
+	unsigned char global_map;
+	unsigned char chip_veru;
+	unsigned char host_idu;
+	volatile int working;
+	unsigned short wide_idu;
+	unsigned short active_idu;
+	unsigned short ultra_map;
+	unsigned short async;
+	unsigned short deviceid;
+	unsigned char ata_cdbu[16];
+	unsigned char sp[16];
+	Scsi_Cmnd *querequ[qcnt];
+	struct atp_id {
+		unsigned char dirctu;
+		unsigned char devspu;
+		unsigned char devtypeu;
+		unsigned long prdaddru;
+		unsigned long tran_lenu;
+		unsigned long last_lenu;
+		unsigned char *prd_posu;
+		unsigned char *prd_tableu;
+		dma_addr_t prd_phys;
+		Scsi_Cmnd *curr_req;
+	} id[16];
+	struct Scsi_Host *host;
+	struct pci_dev *pdev;
+	unsigned int unit;
+};
 
-static int atp870u_detect(Scsi_Host_Template *);
 static int atp870u_queuecommand(Scsi_Cmnd *, void (*done) (Scsi_Cmnd *));
 static int atp870u_abort(Scsi_Cmnd *);
 static int atp870u_biosparam(struct scsi_device *, struct block_device *,
 		sector_t, int *);
-static int atp870u_release(struct Scsi_Host *);
-
-#define qcnt		32
-#define ATP870U_SCATTER 128
-#define ATP870U_CMDLUN 1
+static void send_s870(struct Scsi_Host *);
 
 extern const char *atp870u_info(struct Scsi_Host *);
+static Scsi_Host_Template atp870u_template;
 
 #endif
diff -puN drivers/scsi/bvme6000.c~linus drivers/scsi/bvme6000.c
--- 25/drivers/scsi/bvme6000.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/bvme6000.c	2004-01-19 22:17:23.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * Detection routine for the NCR53c710 based MVME16x SCSI Controllers for Linux.
+ * Detection routine for the NCR53c710 based BVME6000 SCSI Controllers for Linux.
  *
  * Based on work by Alan Hourihane
  */
@@ -23,9 +23,6 @@
 
 #include<linux/stat.h>
 
-extern int ncr53c7xx_init(Scsi_Host_Template *tpnt, int board, int chip,
-			  unsigned long base, int io_port, int irq, int dma,
-			  long long options, int clock);
 
 int bvme6000_scsi_detect(Scsi_Host_Template *tpnt)
 {
@@ -51,7 +48,7 @@ int bvme6000_scsi_detect(Scsi_Host_Templ
     return 1;
 }
 
-static int mvme6000_scsi_release(struct Scsi_Host *shost)
+static int bvme6000_scsi_release(struct Scsi_Host *shost)
 {
 	if (shost->irq)
 		free_irq(shost->irq, NULL);
diff -puN drivers/scsi/g_NCR5380.c~linus drivers/scsi/g_NCR5380.c
--- 25/drivers/scsi/g_NCR5380.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/g_NCR5380.c	2004-01-19 22:17:23.000000000 -0800
@@ -290,6 +290,7 @@ int __init generic_NCR5380_detect(Scsi_H
 	static int current_override = 0;
 	int count, i;
 	unsigned int *ports;
+	unsigned long region_size = 16;
 	static unsigned int __initdata ncr_53c400a_ports[] = {
 		0x280, 0x290, 0x300, 0x310, 0x330, 0x340, 0x348, 0x350, 0
 	};
@@ -420,6 +421,7 @@ int __init generic_NCR5380_detect(Scsi_H
 			/* Not a 53C400A style setup - just grab */
 			if(!(request_region(overrides[current_override].NCR5380_map_name, NCR5380_region_size, "ncr5380")))
 				continue;
+			region_size = NCR5380_region_size;
 		}
 #else
 		if(!request_mem_region(overrides[current_override].NCR5380_map_name, NCR5380_region_size, "ncr5380"))
@@ -428,7 +430,7 @@ int __init generic_NCR5380_detect(Scsi_H
 		instance = scsi_register(tpnt, sizeof(struct NCR5380_hostdata));
 		if (instance == NULL) {
 #ifndef CONFIG_SCSI_G_NCR5380_MEM
-			release_region(overrides[current_override].NCR5380_map_name, NCR5380_region_size);
+			release_region(overrides[current_override].NCR5380_map_name, region_size);
 #else
 			release_mem_region(overrides[current_override].NCR5380_map_name, NCR5380_region_size);
 #endif
@@ -436,6 +438,9 @@ int __init generic_NCR5380_detect(Scsi_H
 		}
 
 		instance->NCR5380_instance_name = overrides[current_override].NCR5380_map_name;
+#ifndef CONFIG_SCSI_G_NCR5380_MEM
+		instance->n_io_port = region_size;
+#endif
 
 		NCR5380_init(instance, flags);
 
@@ -498,7 +503,7 @@ int generic_NCR5380_release_resources(st
 	NCR5380_setup(instance);
 
 #ifndef CONFIG_SCSI_G_NCR5380_MEM
-	release_region(instance->NCR5380_instance_name, NCR5380_region_size);
+	release_region(instance->NCR5380_instance_name, instance->n_io_port);
 #else
 	release_mem_region(instance->NCR5380_instance_name, NCR5380_region_size);
 #endif
diff -puN drivers/scsi/ini9100u.c~linus drivers/scsi/ini9100u.c
--- 25/drivers/scsi/ini9100u.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/ini9100u.c	2004-01-19 22:17:23.000000000 -0800
@@ -484,7 +484,7 @@ static void i91uBuildSCB(HCS * pHCB, SCB
 	dma_addr = dma_map_single(&pHCB->pci_dev->dev, SCpnt->sense_buffer,
 				  SENSE_SIZE, DMA_FROM_DEVICE);
 	pSCB->SCB_SensePtr = cpu_to_le32((u32)dma_addr);
-	pSCB->SCB_SenseLen = SENSE_SIZE;
+	pSCB->SCB_SenseLen = cpu_to_le32(SENSE_SIZE);
 	SCpnt->SCp.ptr = (char *)(unsigned long)dma_addr;
 
 	pSCB->SCB_CDBLen = SCpnt->cmd_len;
@@ -502,7 +502,7 @@ static void i91uBuildSCB(HCS * pHCB, SCB
 		dma_addr = dma_map_single(&pHCB->pci_dev->dev, &pSCB->SCB_SGList[0],
 					  sizeof(struct SG_Struc) * TOTAL_SG_ENTRY,
 					  DMA_BIDIRECTIONAL);
-		pSCB->SCB_BufPtr = dma_addr;
+		pSCB->SCB_BufPtr = cpu_to_le32((u32)dma_addr);
 		SCpnt->SCp.dma_handle = dma_addr;
 
 		pSrbSG = (struct scatterlist *) SCpnt->request_buffer;
@@ -512,8 +512,8 @@ static void i91uBuildSCB(HCS * pHCB, SCB
 		pSCB->SCB_Flags |= SCF_SG;	/* Turn on SG list flag       */
 		for (i = 0, TotalLen = 0, pSG = &pSCB->SCB_SGList[0];	/* 1.01g */
 		     i < pSCB->SCB_SGLen; i++, pSG++, pSrbSG++) {
-			pSG->SG_Ptr = (u32)sg_dma_address(pSrbSG);
-			TotalLen += pSG->SG_Len = (u32)sg_dma_len(pSrbSG);
+			pSG->SG_Ptr = cpu_to_le32((u32)sg_dma_address(pSrbSG));
+			TotalLen += pSG->SG_Len = cpu_to_le32((u32)sg_dma_len(pSrbSG));
 		}
 
 		pSCB->SCB_BufLen = (SCpnt->request_bufflen > TotalLen) ?
@@ -523,8 +523,8 @@ static void i91uBuildSCB(HCS * pHCB, SCB
 					  SCpnt->request_bufflen,
 					  SCpnt->sc_data_direction);
 		SCpnt->SCp.dma_handle = dma_addr;
-		pSCB->SCB_BufPtr = (u32)dma_addr;
-		pSCB->SCB_BufLen = (u32)SCpnt->request_bufflen;
+		pSCB->SCB_BufPtr = cpu_to_le32((u32)dma_addr);
+		pSCB->SCB_BufLen = cpu_to_le32((u32)SCpnt->request_bufflen);
 		pSCB->SCB_SGLen = 0;
 	} else {
 		pSCB->SCB_BufLen = 0;
diff -puN drivers/scsi/inia100.c~linus drivers/scsi/inia100.c
--- 25/drivers/scsi/inia100.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/inia100.c	2004-01-19 22:17:23.000000000 -0800
@@ -420,7 +420,7 @@ static int __devinit inia100_probe_one(s
 	struct Scsi_Host *shost;
 	ORC_HCS *pHCB;
 	unsigned long port, bios;
-	int ok = -ENODEV;
+	int error = -ENODEV;
 	u32 sz;
 	unsigned long dBiosAdr;
 	char *pbBiosAdr;
@@ -433,17 +433,17 @@ static int __devinit inia100_probe_one(s
 		goto out_disable_device;
 	}
 
+	pci_set_master(pdev);
+
 	port = pci_resource_start(pdev, 0);
-	if (!request_region(pHCB->HCS_Base, 256, "inia100")) {
-		printk(KERN_WARNING "inia100: io port 0x%x, is busy.\n", 
-		       pHCB->HCS_Base);
-		goto out_disable_device; /* XXX: undo init_orchid() ?? */
+	if (!request_region(port, 256, "inia100")) {
+		printk(KERN_WARNING "inia100: io port 0x%lx, is busy.\n", port);
+		goto out_disable_device;
 	}
 
 	/* <02> read from base address + 0x50 offset to get the bios balue. */
 	bios = ORC_RDWORD(port, 0x50);
 
-	pci_set_master(pdev);
 
 	shost = scsi_host_alloc(&inia100_template, sizeof(ORC_HCS));
 	if (!shost)
@@ -460,7 +460,8 @@ static int __devinit inia100_probe_one(s
 
 	/* Get total memory needed for SCB */
 	sz = ORC_MAXQUEUE * sizeof(ORC_SCB);
-	pHCB->HCS_virScbArray = pci_alloc_consistent(pdev, sz, &pHCB->HCS_physScbArray);
+	pHCB->HCS_virScbArray = pci_alloc_consistent(pdev, sz,
+			&pHCB->HCS_physScbArray);
 	if (!pHCB->HCS_virScbArray) {
 		printk("inia100: SCB memory allocation error\n");
 		goto out_host_put;
@@ -469,7 +470,8 @@ static int __devinit inia100_probe_one(s
 
 	/* Get total memory needed for ESCB */
 	sz = ORC_MAXQUEUE * sizeof(ESCB);
-	pHCB->HCS_virEscbArray = pci_alloc_consistent(pdev, sz, &pHCB->HCS_physEscbArray);
+	pHCB->HCS_virEscbArray = pci_alloc_consistent(pdev, sz,
+			&pHCB->HCS_physEscbArray);
 	if (!pHCB->HCS_virEscbArray) {
 		printk("inia100: ESCB memory allocation error\n");
 		goto out_free_scb_array;
@@ -490,21 +492,23 @@ static int __devinit inia100_probe_one(s
 	shost->unique_id = shost->io_port;
 	shost->max_id = pHCB->HCS_MaxTar;
 	shost->max_lun = 16;
-	shost->irq = pHCB->HCS_Intr;
+	shost->irq = pHCB->HCS_Intr = pdev->irq;
 	shost->this_id = pHCB->HCS_SCSI_ID;	/* Assign HCS index */
 	shost->sg_tablesize = TOTAL_SG_ENTRY;
 
 	/* Initial orc chip           */
-	ok = request_irq(pHCB->HCS_Intr, inia100_intr, SA_SHIRQ, "inia100", shost);
-	if (ok < 0) {
-		printk(KERN_WARNING "inia100: unable to get irq %d\n", pHCB->HCS_Intr);
+	error = request_irq(pdev->irq, inia100_intr, SA_SHIRQ,
+			"inia100", shost);
+	if (error < 0) {
+		printk(KERN_WARNING "inia100: unable to get irq %d\n",
+				pdev->irq);
 		goto out_free_escb_array;
 	}
 
 	pci_set_drvdata(pdev, shost);
 
-	ok = scsi_add_host(shost, &pdev->dev);
-	if (!ok)
+	error = scsi_add_host(shost, &pdev->dev);
+	if (error)
 		goto out_free_irq;
 
 	scsi_scan_host(shost);
@@ -521,11 +525,11 @@ static int __devinit inia100_probe_one(s
  out_host_put:
 	scsi_host_put(shost);
  out_release_region:
-        release_region(pHCB->HCS_Base, 256);
+        release_region(port, 256);
  out_disable_device:
 	pci_disable_device(pdev);
  out:
-	return ok;
+	return error;
 }
 
 static void __devexit inia100_remove_one(struct pci_dev *pdev)
diff -puN drivers/scsi/ips.c~linus drivers/scsi/ips.c
--- 25/drivers/scsi/ips.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/ips.c	2004-01-19 22:17:23.000000000 -0800
@@ -131,6 +131,8 @@
 /* 5.30.00  - use __devexit_p()                                              */
 /* 6.00.00  - Add 6x Adapters and Battery Flash                              */
 /* 6.10.00  - Remove 1G Addressing Limitations                               */
+/* 6.11.xx  - Get VersionInfo buffer off the stack !              DDTS 60401 */
+/* 6.11.xx  - Make Logical Drive Info structure safe for DMA      DDTS 60639 */
 /*****************************************************************************/
 
 /*
@@ -195,8 +197,8 @@ MODULE_PARM(ips, "s");
 /*
  * DRIVER_VER
  */
-#define IPS_VERSION_HIGH        "6.10"
-#define IPS_VERSION_LOW         ".90-BETA"
+#define IPS_VERSION_HIGH        "7.00"
+#define IPS_VERSION_LOW         ".00 "
 
 #if !defined(__i386__) && !defined(__ia64__) && !defined(__x86_64__)
 #warning "This driver has only been tested on the x86/ia64/x86_64 platforms"
@@ -497,8 +499,7 @@ int ips_proc_info(struct Scsi_Host *, ch
 static int ips_host_info(ips_ha_t *, char *, off_t, int);
 static void copy_mem_info(IPS_INFOSTR *, char *, int);
 static int copy_info(IPS_INFOSTR *, char *, ...);
-static int ips_get_version_info(ips_ha_t * ha, IPS_VERSION_DATA * Buffer,
-				int intr);
+static int ips_get_version_info(ips_ha_t * ha, dma_addr_t, int intr);
 static void ips_version_check(ips_ha_t * ha, int intr);
 static int ips_abort_init(ips_ha_t * ha, int index);
 static int ips_init_phase2(int index);
@@ -2159,27 +2160,60 @@ ips_host_info(ips_ha_t * ha, char *ptr, 
 
 	copy_info(&info, "\tIRQ number                        : %d\n", ha->irq);
 
-	if (le32_to_cpu(ha->nvram->signature) == IPS_NVRAM_P5_SIG)
-		copy_info(&info,
-			  "\tBIOS Version                      : %c%c%c%c%c%c%c%c\n",
-			  ha->nvram->bios_high[0], ha->nvram->bios_high[1],
-			  ha->nvram->bios_high[2], ha->nvram->bios_high[3],
-			  ha->nvram->bios_low[0], ha->nvram->bios_low[1],
-			  ha->nvram->bios_low[2], ha->nvram->bios_low[3]);
-
-	copy_info(&info,
-		  "\tFirmware Version                  : %c%c%c%c%c%c%c%c\n",
-		  ha->enq->CodeBlkVersion[0], ha->enq->CodeBlkVersion[1],
-		  ha->enq->CodeBlkVersion[2], ha->enq->CodeBlkVersion[3],
-		  ha->enq->CodeBlkVersion[4], ha->enq->CodeBlkVersion[5],
-		  ha->enq->CodeBlkVersion[6], ha->enq->CodeBlkVersion[7]);
-
-	copy_info(&info,
-		  "\tBoot Block Version                : %c%c%c%c%c%c%c%c\n",
-		  ha->enq->BootBlkVersion[0], ha->enq->BootBlkVersion[1],
-		  ha->enq->BootBlkVersion[2], ha->enq->BootBlkVersion[3],
-		  ha->enq->BootBlkVersion[4], ha->enq->BootBlkVersion[5],
-		  ha->enq->BootBlkVersion[6], ha->enq->BootBlkVersion[7]);
+    /* For the Next 3 lines Check for Binary 0 at the end and don't include it if it's there. */
+    /* That keeps everything happy for "text" operations on the proc file.                    */
+
+	if (le32_to_cpu(ha->nvram->signature) == IPS_NVRAM_P5_SIG) {
+        if (ha->nvram->bios_low[3] == 0) { 
+            copy_info(&info,
+			          "\tBIOS Version                      : %c%c%c%c%c%c%c\n",
+			          ha->nvram->bios_high[0], ha->nvram->bios_high[1],
+			          ha->nvram->bios_high[2], ha->nvram->bios_high[3],
+			          ha->nvram->bios_low[0], ha->nvram->bios_low[1],
+			          ha->nvram->bios_low[2]);
+
+        } else {
+		    copy_info(&info,
+			          "\tBIOS Version                      : %c%c%c%c%c%c%c%c\n",
+			          ha->nvram->bios_high[0], ha->nvram->bios_high[1],
+			          ha->nvram->bios_high[2], ha->nvram->bios_high[3],
+			          ha->nvram->bios_low[0], ha->nvram->bios_low[1],
+			          ha->nvram->bios_low[2], ha->nvram->bios_low[3]);
+        }
+
+    }
+
+    if (ha->enq->CodeBlkVersion[7] == 0) {
+        copy_info(&info,
+		          "\tFirmware Version                  : %c%c%c%c%c%c%c\n",
+		          ha->enq->CodeBlkVersion[0], ha->enq->CodeBlkVersion[1],
+		          ha->enq->CodeBlkVersion[2], ha->enq->CodeBlkVersion[3],
+		          ha->enq->CodeBlkVersion[4], ha->enq->CodeBlkVersion[5],
+		          ha->enq->CodeBlkVersion[6]);
+    } else {
+        copy_info(&info,
+		          "\tFirmware Version                  : %c%c%c%c%c%c%c%c\n",
+		          ha->enq->CodeBlkVersion[0], ha->enq->CodeBlkVersion[1],
+		          ha->enq->CodeBlkVersion[2], ha->enq->CodeBlkVersion[3],
+		          ha->enq->CodeBlkVersion[4], ha->enq->CodeBlkVersion[5],
+		          ha->enq->CodeBlkVersion[6], ha->enq->CodeBlkVersion[7]);
+    }
+
+    if (ha->enq->BootBlkVersion[7] == 0) {
+        copy_info(&info,
+		          "\tBoot Block Version                : %c%c%c%c%c%c%c\n",
+		          ha->enq->BootBlkVersion[0], ha->enq->BootBlkVersion[1],
+		          ha->enq->BootBlkVersion[2], ha->enq->BootBlkVersion[3],
+		          ha->enq->BootBlkVersion[4], ha->enq->BootBlkVersion[5],
+		          ha->enq->BootBlkVersion[6]);
+    } else {
+        copy_info(&info,
+		          "\tBoot Block Version                : %c%c%c%c%c%c%c%c\n",
+		          ha->enq->BootBlkVersion[0], ha->enq->BootBlkVersion[1],
+		          ha->enq->BootBlkVersion[2], ha->enq->BootBlkVersion[3],
+		          ha->enq->BootBlkVersion[4], ha->enq->BootBlkVersion[5],
+		          ha->enq->BootBlkVersion[6], ha->enq->BootBlkVersion[7]);
+    }
 
 	copy_info(&info, "\tDriver Version                    : %s%s\n",
 		  IPS_VERSION_HIGH, IPS_VERSION_LOW);
@@ -2841,6 +2875,11 @@ ips_next(ips_ha_t * ha, int intr)
 		scb->dcdb.cmd_attribute =
 		    ips_command_direction[scb->scsi_cmd->cmnd[0]];
 
+        /* Allow a WRITE BUFFER Command to Have no Data */
+        /* This is Used by Tape Flash Utilites          */
+        if ((scb->scsi_cmd->cmnd[0] == WRITE_BUFFER) && (scb->data_len == 0)) 
+            scb->dcdb.cmd_attribute = 0;                  
+
 		if (!(scb->dcdb.cmd_attribute & 0x3))
 			scb->dcdb.transfer_length = 0;
 
@@ -3820,23 +3859,14 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * 
 					scb->scsi_cmd->result = DID_OK << 16;
 				}
 			} else {
-				scb->cmd.logical_info.op_code =
-				    IPS_CMD_GET_LD_INFO;
-				scb->cmd.logical_info.command_id =
-				    IPS_COMMAND_ID(ha, scb);
+				scb->cmd.logical_info.op_code = IPS_CMD_GET_LD_INFO;
+				scb->cmd.logical_info.command_id = IPS_COMMAND_ID(ha, scb);
 				scb->cmd.logical_info.reserved = 0;
 				scb->cmd.logical_info.reserved2 = 0;
-				scb->data_len =
-				    sizeof (ha->adapt->logical_drive_info);
-				scb->data_busaddr =
-				    pci_map_single(ha->pcidev,
-						   &ha->adapt->
-						   logical_drive_info,
-						   scb->data_len,
-						   IPS_DMA_DIR(scb));
-				scb->flags |= IPS_SCB_MAP_SINGLE;
-				scb->cmd.logical_info.buffer_addr =
-				    scb->data_busaddr;
+				scb->data_len = sizeof (IPS_LD_INFO);
+				scb->data_busaddr = ha->logical_drive_info_dma_addr;
+				scb->flags = 0;
+				scb->cmd.logical_info.buffer_addr = scb->data_busaddr;
 				ret = IPS_SUCCESS;
 			}
 
@@ -3967,18 +3997,13 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * 
 
 		case READ_CAPACITY:
 			scb->cmd.logical_info.op_code = IPS_CMD_GET_LD_INFO;
-			scb->cmd.logical_info.command_id =
-			    IPS_COMMAND_ID(ha, scb);
+			scb->cmd.logical_info.command_id = IPS_COMMAND_ID(ha, scb);
 			scb->cmd.logical_info.reserved = 0;
 			scb->cmd.logical_info.reserved2 = 0;
 			scb->cmd.logical_info.reserved3 = 0;
-			scb->data_len = sizeof (ha->adapt->logical_drive_info);
-			scb->data_busaddr = pci_map_single(ha->pcidev,
-							   &ha->adapt->
-							   logical_drive_info,
-							   scb->data_len,
-							   IPS_DMA_DIR(scb));
-			scb->flags |= IPS_SCB_MAP_SINGLE;
+			scb->data_len = sizeof (IPS_LD_INFO);
+			scb->data_busaddr = ha->logical_drive_info_dma_addr;
+			scb->flags = 0;
 			scb->cmd.logical_info.buffer_addr = scb->data_busaddr;
 			ret = IPS_SUCCESS;
 			break;
@@ -4302,19 +4327,17 @@ ips_online(ips_ha_t * ha, ips_scb_t * sc
 		return (0);
 
 	if ((scb->basic_status & IPS_GSC_STATUS_MASK) > 1) {
-		memset(&ha->adapt->logical_drive_info, 0,
-		       sizeof (ha->adapt->logical_drive_info));
-
+		memset(ha->logical_drive_info, 0, sizeof (IPS_LD_INFO));
 		return (0);
 	}
 
-	if (ha->adapt->logical_drive_info.drive_info[scb->target_id].state !=
+	if (ha->logical_drive_info->drive_info[scb->target_id].state !=
 	    IPS_LD_OFFLINE
-	    && ha->adapt->logical_drive_info.drive_info[scb->target_id].state !=
+	    && ha->logical_drive_info->drive_info[scb->target_id].state !=
 	    IPS_LD_FREE
-	    && ha->adapt->logical_drive_info.drive_info[scb->target_id].state !=
+	    && ha->logical_drive_info->drive_info[scb->target_id].state !=
 	    IPS_LD_CRS
-	    && ha->adapt->logical_drive_info.drive_info[scb->target_id].state !=
+	    && ha->logical_drive_info->drive_info[scb->target_id].state !=
 	    IPS_LD_SYS)
 		return (1);
 	else
@@ -4377,7 +4400,7 @@ ips_rdcap(ips_ha_t * ha, ips_scb_t * scb
 
 	cap.lba =
 	    cpu_to_be32(le32_to_cpu
-			(ha->adapt->logical_drive_info.
+			(ha->logical_drive_info->
 			 drive_info[scb->target_id].sector_count) - 1);
 	cap.len = cpu_to_be32((uint32_t) IPS_BLKSIZE);
 
@@ -4541,6 +4564,14 @@ ips_free(ips_ha_t * ha)
 			ha->adapt = NULL;
 		}
 
+		if (ha->logical_drive_info) {
+			pci_free_consistent(ha->pcidev,
+					    sizeof (IPS_LD_INFO),
+					    ha->logical_drive_info,
+					    ha->logical_drive_info_dma_addr);
+			ha->logical_drive_info = NULL;
+		}
+
 		if (ha->nvram) {
 			kfree(ha->nvram);
 			ha->nvram = NULL;
@@ -4730,6 +4761,7 @@ ips_getscb(ips_ha_t * ha)
 	}
 
 	ha->scb_freelist = scb->q_next;
+	scb->flags = 0;
 	scb->q_next = NULL;
 
 	ips_init_scb(ha, scb);
@@ -6777,7 +6809,7 @@ ips_verify_bios_memio(ips_ha_t * ha, cha
 static void
 ips_version_check(ips_ha_t * ha, int intr)
 {
-	IPS_VERSION_DATA VersionInfo;
+	IPS_VERSION_DATA *VersionInfo;
 	uint8_t FirmwareVersion[IPS_COMPAT_ID_LENGTH + 1];
 	uint8_t BiosVersion[IPS_COMPAT_ID_LENGTH + 1];
 	int MatchError;
@@ -6787,6 +6819,8 @@ ips_version_check(ips_ha_t * ha, int int
 
 	METHOD_TRACE("ips_version_check", 1);
 
+	VersionInfo = ( IPS_VERSION_DATA * ) ha->ioctl_data;
+
 	memset(FirmwareVersion, 0, IPS_COMPAT_ID_LENGTH + 1);
 	memset(BiosVersion, 0, IPS_COMPAT_ID_LENGTH + 1);
 
@@ -6797,9 +6831,10 @@ ips_version_check(ips_ha_t * ha, int int
 	rc = IPS_FAILURE;
 	if (ha->subsys->param[4] & IPS_GET_VERSION_SUPPORT) {	/* If Versioning is Supported */
 		/* Get the Version Info with a Get Version Command */
-		rc = ips_get_version_info(ha, &VersionInfo, intr);
+		memset( VersionInfo, 0, sizeof (IPS_VERSION_DATA));
+		rc = ips_get_version_info(ha, ha->ioctl_busaddr, intr);
 		if (rc == IPS_SUCCESS)
-			memcpy(FirmwareVersion, VersionInfo.compatibilityId,
+			memcpy(FirmwareVersion, VersionInfo->compatibilityId,
 			       IPS_COMPAT_ID_LENGTH);
 	}
 
@@ -6862,14 +6897,13 @@ ips_version_check(ips_ha_t * ha, int int
 /*     0 if Successful, else non-zero                                        */
 /*---------------------------------------------------------------------------*/
 static int
-ips_get_version_info(ips_ha_t * ha, IPS_VERSION_DATA * Buffer, int intr)
+ips_get_version_info(ips_ha_t * ha, dma_addr_t Buffer, int intr)
 {
 	ips_scb_t *scb;
 	int rc;
 
 	METHOD_TRACE("ips_get_version_info", 1);
 
-	memset(Buffer, 0, sizeof (IPS_VERSION_DATA));
 	scb = &ha->scbs[ha->max_cmds - 1];
 
 	ips_init_scb(ha, scb);
@@ -6881,11 +6915,10 @@ ips_get_version_info(ips_ha_t * ha, IPS_
 	scb->cmd.version_info.reserved = 0;
 	scb->cmd.version_info.count = sizeof (IPS_VERSION_DATA);
 	scb->cmd.version_info.reserved2 = 0;
-	scb->data_len = sizeof (*Buffer);
-	scb->data_busaddr = pci_map_single(ha->pcidev, Buffer,
-					   scb->data_len, IPS_DMA_DIR(scb));
-	scb->cmd.version_info.buffer_addr = scb->data_busaddr;
-	scb->flags |= IPS_SCB_MAP_SINGLE;
+	scb->data_len = sizeof (IPS_VERSION_DATA);
+	scb->data_busaddr = Buffer;
+	scb->cmd.version_info.buffer_addr = Buffer;
+	scb->flags = 0;
 
 	/* issue command */
 	rc = ips_send_wait(ha, scb, ips_cmd_timeout, intr);
@@ -7356,6 +7389,17 @@ ips_init_phase1(struct pci_dev *pci_dev,
 	ha->adapt->hw_status_start = dma_address;
 	ha->dummy = (void *) (ha->adapt + 1);
 
+
+
+	ha->logical_drive_info = pci_alloc_consistent(pci_dev, sizeof (IPS_LD_INFO), &dma_address);
+	if (!ha->logical_drive_info) {
+		IPS_PRINTK(KERN_WARNING, pci_dev,
+			   "Unable to allocate logical drive info structure\n");
+		return ips_abort_init(ha, index);
+	}
+	ha->logical_drive_info_dma_addr = dma_address;
+
+
 	ha->conf = kmalloc(sizeof (IPS_CONF), GFP_KERNEL);
 
 	if (!ha->conf) {
diff -puN drivers/scsi/ips.h~linus drivers/scsi/ips.h
--- 25/drivers/scsi/ips.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/ips.h	2004-01-19 22:17:23.000000000 -0800
@@ -711,7 +711,6 @@ typedef struct {
    volatile PIPS_STATUS p_status_tail;
    volatile uint32_t    hw_status_start;
    volatile uint32_t    hw_status_tail;
-   IPS_LD_INFO          logical_drive_info;
 } IPS_ADAPTER, *PIPS_ADAPTER;
 
 typedef struct {
@@ -1084,6 +1083,8 @@ typedef struct ips_ha {
    ips_scb_queue_t    scb_activelist;     /* Active SCB list            */
    IPS_IO_CMD        *dummy;              /* dummy command              */
    IPS_ADAPTER       *adapt;              /* Adapter status area        */
+   IPS_LD_INFO       *logical_drive_info; /* Adapter Logical Drive Info */
+   dma_addr_t         logical_drive_info_dma_addr; /* Logical Drive Info DMA Address */
    IPS_ENQ           *enq;                /* Adapter Enquiry data       */
    IPS_CONF          *conf;               /* Adapter config data        */
    IPS_NVRAM_P5      *nvram;              /* NVRAM page 5 data          */
@@ -1132,7 +1133,7 @@ typedef struct ips_scb {
    uint8_t           lun;
    uint8_t           cdb[12];
    uint32_t          scb_busaddr;
-   uint32_t          data_busaddr;
+   uint32_t          old_data_busaddr;  // Obsolete, but kept for old utility compatibility
    uint32_t          timeout;
    uint8_t           basic_status;
    uint8_t           extended_status;
@@ -1148,6 +1149,7 @@ typedef struct ips_scb {
    ips_scb_callback  callback;
    uint32_t          sg_busaddr;
    int               sg_count;
+   dma_addr_t        data_busaddr;
 } ips_scb_t;
 
 typedef struct ips_scb_pt {
@@ -1201,15 +1203,15 @@ typedef struct {
 *
 *************************************************************************/
 
-#define IPS_VER_MAJOR 6
-#define IPS_VER_MAJOR_STRING "6"
-#define IPS_VER_MINOR 10
-#define IPS_VER_MINOR_STRING "10"
-#define IPS_VER_BUILD 90
-#define IPS_VER_BUILD_STRING "90"
-#define IPS_VER_STRING "6.10.90"
-#define IPS_RELEASE_ID 0x00010000
-#define IPS_BUILD_IDENT 364
+#define IPS_VER_MAJOR 7
+#define IPS_VER_MAJOR_STRING "7"
+#define IPS_VER_MINOR 00
+#define IPS_VER_MINOR_STRING "00"
+#define IPS_VER_BUILD 00
+#define IPS_VER_BUILD_STRING "00"
+#define IPS_VER_STRING "7.00.00"
+#define IPS_RELEASE_ID 0x00010001
+#define IPS_BUILD_IDENT 475
 #define IPS_LEGALCOPYRIGHT_STRING "(C) Copyright IBM Corp. 1994, 2003. All Rights Reserved."
 #define IPS_ADAPTECCOPYRIGHT_STRING "(c) Copyright Adaptec, Inc. 2002 to present. All Rights Reserved."
 #define IPS_NT_LEGALCOPYRIGHT_STRING "(C) Copyright IBM Corp. 1994, 2003."
@@ -1219,11 +1221,11 @@ typedef struct {
 #define IPS_VER_SERVERAID2 "2.88.13"
 #define IPS_VER_NAVAJO "2.88.13"
 #define IPS_VER_SERVERAID3 "6.10.24"
-#define IPS_VER_SERVERAID4H "6.10.24"
-#define IPS_VER_SERVERAID4MLx "6.10.24"
-#define IPS_VER_SARASOTA "6.10.24"
-#define IPS_VER_MARCO "6.10.24"
-#define IPS_VER_SEBRING "6.10.24"
+#define IPS_VER_SERVERAID4H "6.11.07"
+#define IPS_VER_SERVERAID4MLx "6.11.07"
+#define IPS_VER_SARASOTA "6.11.07"
+#define IPS_VER_MARCO "6.11.07"
+#define IPS_VER_SEBRING "6.11.07"
 
 /* Compatability IDs for various adapters */
 #define IPS_COMPAT_UNKNOWN ""
diff -puN drivers/scsi/Kconfig~linus drivers/scsi/Kconfig
--- 25/drivers/scsi/Kconfig~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/Kconfig	2004-01-19 22:17:23.000000000 -0800
@@ -1210,6 +1210,8 @@ config SCSI_QLOGICPTI
 	  To compile this driver as a module, choose M here: the
 	  module will be called qlogicpti.
 
+source "drivers/scsi/qla2xxx/Kconfig"
+
 config SCSI_SEAGATE
 	tristate "Seagate ST-02 and Future Domain TMC-8xx SCSI support"
 	depends on X86 && ISA && SCSI && BROKEN
@@ -1473,12 +1475,6 @@ config A3000_SCSI
 	  To compile this driver as a module, choose M here: the
 	  module will be called wd33c93.
 
-config A4000T_SCSI
-	bool "A4000T SCSI support (EXPERIMENTAL)"
-	depends on AMIGA && SCSI && EXPERIMENTAL && BROKEN
-	help
-	  Support for the NCR53C710 SCSI controller on the Amiga 4000T.
-
 config A2091_SCSI
 	tristate "A2091/A590 WD33C93A support"
 	depends on ZORRO && SCSI
@@ -1541,28 +1537,24 @@ config FASTLANE_SCSI
 	  If you have the Phase5 Fastlane Z3 SCSI controller, or plan to use
 	  one in the near future, say Y to this question. Otherwise, say N.
 
-config A4091_SCSI
-	bool "A4091 SCSI support (EXPERIMENTAL)"
-	depends on ZORRO && SCSI && EXPERIMENTAL && BROKEN
-	help
-	  Support for the NCR53C710 chip on the Amiga 4091 Z3 SCSI2 controller
-	  (1993).  Very obscure -- the 4091 was part of an Amiga 4000 upgrade
-	  plan at the time the Amiga business was sold to DKB.
-
-config WARPENGINE_SCSI
-	bool "WarpEngine SCSI support (EXPERIMENTAL)"
-	depends on ZORRO && SCSI && EXPERIMENTAL && BROKEN
-	help
-	  Support for MacroSystem Development's WarpEngine Amiga SCSI-2
-	  controller. Info at
-	  <http://www.lysator.liu.se/amiga/ar/guide/ar310.guide?FEATURE5>.
-
-config BLZ603EPLUS_SCSI
-	bool "Blizzard PowerUP 603e+ SCSI (EXPERIMENTAL)"
-	depends on ZORRO && SCSI && EXPERIMENTAL && BROKEN
+config SCSI_AMIGA7XX
+	bool "Amiga NCR53c710 SCSI support (EXPERIMENTAL)"
+	depends on AMIGA && SCSI && EXPERIMENTAL && BROKEN
 	help
-	  If you have an Amiga 1200 with a Phase5 Blizzard PowerUP 603e+
-	  accelerator, say Y. Otherwise, say N.
+	  Support for various NCR53c710-based SCSI controllers on the Amiga.
+	  This includes:
+	    - the builtin SCSI controller on the Amiga 4000T,
+	    - the Amiga 4091 Zorro III SCSI-2 controller,
+	    - the MacroSystem Development's WarpEngine Amiga SCSI-2 controller
+	      (info at
+	      <http://www.lysator.liu.se/amiga/ar/guide/ar310.guide?FEATURE5>),
+	    - the SCSI controller on the Phase5 Blizzard PowerUP 603e+
+	      accelerator card for the Amiga 1200,
+	    - the SCSI controller on the GVP Turbo 040/060 accelerator.
+	  Note that all of the above SCSI controllers, except for the builtin
+	  SCSI controller on the Amiga 4000T, reside on the Zorro expansion
+	  bus, so you also have to enable Zorro bus support if you want to use
+	  them.
 
 config OKTAGON_SCSI
 	tristate "BSC Oktagon SCSI support (EXPERIMENTAL)"
@@ -1660,7 +1652,7 @@ config BVME6000_SCSI
 
 config SCSI_NCR53C7xx_FAST
 	bool "allow FAST-SCSI [10MHz]"
-	depends on A4000T_SCSI || A4091_SCSI || BLZ603EPLUS_SCSI || WARPENGINE_SCSI || MVME16x_SCSI || BVME6000_SCSI
+	depends on SCSI_AMIGA7XX || MVME16x_SCSI || BVME6000_SCSI
 	help
 	  This will enable 10MHz FAST-SCSI transfers with your host
 	  adapter. Some systems have problems with that speed, so it's safest
@@ -1706,7 +1698,6 @@ config WD33C93_PIO
 	default y
 
 #      bool 'Cyberstorm Mk III SCSI support (EXPERIMENTAL)' CONFIG_CYBERSTORMIII_SCSI
-#      bool 'GVP Turbo 040/060 SCSI support (EXPERIMENTAL)' CONFIG_GVP_TURBO_SCSI
 
 config ZFCP
 	tristate "IBM z900 OpenFCP/SCSI support"
diff -puN drivers/scsi/mac_esp.c~linus drivers/scsi/mac_esp.c
--- 25/drivers/scsi/mac_esp.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/mac_esp.c	2004-01-19 22:17:23.000000000 -0800
@@ -46,7 +46,7 @@
 #define mac_turnon_irq(x)	mac_enable_irq(x)
 #define mac_turnoff_irq(x)	mac_disable_irq(x)
 
-extern inline void esp_handle(struct NCR_ESP *esp);
+extern void esp_handle(struct NCR_ESP *esp);
 extern void mac_esp_intr(int irq, void *dev_id, struct pt_regs *pregs);
 
 static int  dma_bytes_sent(struct NCR_ESP * esp, int fifo_count);
@@ -151,92 +151,98 @@ irqreturn_t fake_drq(int irq, void *dev_
 #define DRIVER_SETUP
 
 /*
- * Function : mac_esp_setup(char *str, int *ints)
+ * Function : mac_esp_setup(char *str)
  *
  * Purpose : booter command line initialization of the overrides array,
  *
- * Inputs : str - unused, ints - array of integer parameters with ints[0]
- *	equal to the number of ints.
+ * Inputs : str - parameters, separated by commas.
  *
  * Currently unused in the new driver; need to add settable parameters to the 
  * detect function.
  *
  */
 
-static int __init mac_esp_setup(char *str, int *ints) {
+static int __init mac_esp_setup(char *str) {
 #ifdef DRIVER_SETUP
 	/* Format of mac53c9x parameter is:
 	 *   mac53c9x=<num_esps>,<disconnect>,<nosync>,<can_queue>,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags>
 	 * Negative values mean don't change.
 	 */
 	
-	/* Grmbl... the standard parameter parsing can't handle negative numbers
-	 * :-( So let's do it ourselves!
-	 */
+	char *this_opt;
+	long opt;
 
-	int i = ints[0]+1, fact;
+	this_opt = strsep (&str, ",");
+	if(this_opt) {
+		opt = simple_strtol( this_opt, NULL, 0 );
+
+		if (opt >= 0 && opt <= 2)
+			setup_num_esps = opt;
+		else if (opt > 2)
+			printk( "mac_esp_setup: invalid number of hosts %ld !\n", opt );
 
-	while( str && (isdigit(*str) || *str == '-') && i <= 10) {
-		if (*str == '-')
-			fact = -1, ++str;
-		else
-			fact = 1;
-		ints[i++] = simple_strtoul( str, NULL, 0 ) * fact;
-		if ((str = strchr( str, ',' )) != NULL)
-			++str;
+		this_opt = strsep (&str, ",");
 	}
-	ints[0] = i-1;
+	if(this_opt) {
+		opt = simple_strtol( this_opt, NULL, 0 );
 	
-	if (ints[0] < 1) {
-		printk( "mac_esp_setup: no arguments!\n" );
-		return 0;
+		if (opt > 0)
+			setup_disconnect = opt;
+
+		this_opt = strsep (&str, ",");
 	}
+	if(this_opt) {
+		opt = simple_strtol( this_opt, NULL, 0 );
 
-	if (ints[0] >= 1) {
-		if (ints[1] > 0)
-			/* no limits on this, just > 0 */
-		if (ints[1] >= 0 && ints[1] <= 2)
-			setup_num_esps = ints[1];
-		else if (ints[1] > 2)
-			printk( "mac_esp_setup: invalid number of hosts %d !\n", ints[1] );
-	}
-	if (ints[0] >= 2) {
-		if (ints[2] > 0)
-			setup_disconnect = ints[2];
-	}
-	if (ints[0] >= 3) {
-		if (ints[3] >= 0) {
-			setup_nosync = ints[3];
-		}
+		if (opt >= 0)
+			setup_nosync = opt;
+
+		this_opt = strsep (&str, ",");
+	}
+	if(this_opt) {
+		opt = simple_strtol( this_opt, NULL, 0 );
+
+		if (opt > 0)
+			setup_can_queue = opt;
+
+		this_opt = strsep (&str, ",");
 	}
-	if (ints[0] >= 4) {
-		if (ints[4] > 0)
-			/* no limits on this, just > 0 */
-			setup_can_queue = ints[4];
-	}
-	if (ints[0] >= 5) {
-		if (ints[5] > 0)
-			setup_cmd_per_lun = ints[5];
-	}
-	if (ints[0] >= 6) {
-		if (ints[6] >= 0) {
-			setup_sg_tablesize = ints[6];
+	if(this_opt) {
+		opt = simple_strtol( this_opt, NULL, 0 );
+
+		if (opt > 0)
+			setup_cmd_per_lun = opt;
+
+		this_opt = strsep (&str, ",");
+	}
+	if(this_opt) {
+		opt = simple_strtol( this_opt, NULL, 0 );
+
+		if (opt >= 0) {
+			setup_sg_tablesize = opt;
 			/* Must be <= SG_ALL (255) */
 			if (setup_sg_tablesize > SG_ALL)
 				setup_sg_tablesize = SG_ALL;
 		}
+
+		this_opt = strsep (&str, ",");
 	}
-	if (ints[0] >= 7) {
+	if(this_opt) {
+		opt = simple_strtol( this_opt, NULL, 0 );
+
 		/* Must be between 0 and 7 */
-		if (ints[7] >= 0 && ints[7] <= 7)
-			setup_hostid = ints[7];
-		else if (ints[7] > 7)
-			printk( "mac_esp_setup: invalid host ID %d !\n", ints[7] );
+		if (opt >= 0 && opt <= 7)
+			setup_hostid = opt;
+		else if (opt > 7)
+			printk( "mac_esp_setup: invalid host ID %ld !\n", opt);
+
+		this_opt = strsep (&str, ",");
 	}
 #ifdef SUPPORT_TAGS
-	if (ints[0] >= 8) {
-		if (ints[8] >= 0)
-			setup_use_tagged_queuing = !!ints[8];
+	if(this_opt) {
+		opt = simple_strtol( this_opt, NULL, 0 );
+		if (opt >= 0)
+			setup_use_tagged_queuing = !!opt;
 	}
 #endif
 #endif
@@ -245,6 +251,7 @@ static int __init mac_esp_setup(char *st
 
 __setup("mac53c9x=", mac_esp_setup);
 
+
 /*
  * ESP address 'detection'
  */
diff -puN drivers/scsi/mac_scsi.c~linus drivers/scsi/mac_scsi.c
--- 25/drivers/scsi/mac_scsi.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/mac_scsi.c	2004-01-19 22:17:23.000000000 -0800
@@ -74,9 +74,6 @@ extern void via_scsi_clear(void);
 static void mac_scsi_reset_boot(struct Scsi_Host *instance);
 #endif
 
-static __inline__ char macscsi_read(struct Scsi_Host *instance, int reg);
-static __inline__ void macscsi_write(struct Scsi_Host *instance, int reg, int value);
-
 static int setup_called = 0;
 static int setup_can_queue = -1;
 static int setup_cmd_per_lun = -1;
@@ -102,6 +99,52 @@ static volatile unsigned char *mac_scsi_
 static volatile unsigned char *mac_scsi_drq  = NULL;
 static volatile unsigned char *mac_scsi_nodrq = NULL;
 
+
+/*
+ * NCR 5380 register access functions
+ */
+
+#if 0
+/* Debug versions */
+#define CTRL(p,v) (*ctrl = (v))
+
+static char macscsi_read(struct Scsi_Host *instance, int reg)
+{
+  int iobase = instance->io_port;
+  int i;
+  int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
+
+  CTRL(iobase, 0);
+  i = in_8(iobase + (reg<<4));
+  CTRL(iobase, 0x40);
+
+  return i;
+}
+
+static void macscsi_write(struct Scsi_Host *instance, int reg, int value)
+{
+  int iobase = instance->io_port;
+  int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
+
+  CTRL(iobase, 0);
+  out_8(iobase + (reg<<4), value);
+  CTRL(iobase, 0x40);
+}
+#else
+
+/* Fast versions */
+static __inline__ char macscsi_read(struct Scsi_Host *instance, int reg)
+{
+  return in_8(instance->io_port + (reg<<4));
+}
+
+static __inline__ void macscsi_write(struct Scsi_Host *instance, int reg, int value)
+{
+  out_8(instance->io_port + (reg<<4), value);
+}
+#endif
+
+
 /*
  * Function : mac_scsi_setup(char *str)
  *
@@ -163,18 +206,20 @@ static int __init mac_scsi_setup(char *s
 	    if (ints[5] >= 0)
 		setup_use_pdma = ints[5];
 	}
-#endif
+#endif /* SUPPORT_TAGS */
 	
-#endif
+#endif /* DRIVER_SETUP */
 	return 1;
 }
 
 __setup("mac5380=", mac_scsi_setup);
 
 /*
- * XXX: status debug
+ * If you want to find the instance with (k)gdb ...
  */
+#if NDEBUG
 static struct Scsi_Host *default_instance;
+#endif
 
 /*
  * Function : int macscsi_detect(Scsi_Host_Template * tpnt)
@@ -223,7 +268,9 @@ int macscsi_detect(Scsi_Host_Template * 
     /* Once we support multiple 5380s (e.g. DuoDock) we'll do
        something different here */
     instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
+#if NDEBUG
     default_instance = instance;
+#endif
     
     if (macintosh_config->ident == MAC_MODEL_IIFX) {
 	mac_scsi_regp  = via1+0x8000;
@@ -331,49 +378,6 @@ const char * macscsi_info (struct Scsi_H
 	return "";
 }
 
-/*
- * NCR 5380 register access functions
- */
-
-/* Debug versions
-#define CTRL(p,v) (*ctrl = (v))
-
-static char macscsi_read(struct Scsi_Host *instance, int reg)
-{
-  int iobase = instance->io_port;
-  int i;
-  int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
-
-  CTRL(iobase, 0);
-  i = in_8(iobase + (reg<<4));
-  CTRL(iobase, 0x40);
-
-  return i;
-}
-
-static void macscsi_write(struct Scsi_Host *instance, int reg, int value)
-{
-  int iobase = instance->io_port;
-  int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
-
-  CTRL(iobase, 0);
-  out_8(value, iobase + (reg<<4));
-  CTRL(iobase, 0x40);
-}
-*/
-
-/* Fast versions */
-static __inline__ char macscsi_read(struct Scsi_Host *instance, int reg)
-{
-  return in_8(instance->io_port + (reg<<4));
-}
-
-static __inline__ void macscsi_write(struct Scsi_Host *instance, int reg, int value)
-{
-  out_8(value, instance->io_port + (reg<<4));
-}
-
-
 /* 
    Pseudo-DMA: (Ove Edlund)
    The code attempts to catch bus errors that occur if one for example
diff -puN drivers/scsi/Makefile~linus drivers/scsi/Makefile
--- 25/drivers/scsi/Makefile~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/Makefile	2004-01-19 22:17:23.000000000 -0800
@@ -22,10 +22,7 @@ subdir-$(CONFIG_PCMCIA)		+= pcmcia
 
 obj-$(CONFIG_SCSI)		+= scsi_mod.o
 
-obj-$(CONFIG_A4000T_SCSI)	+= amiga7xx.o	53c7xx.o
-obj-$(CONFIG_A4091_SCSI)	+= amiga7xx.o	53c7xx.o
-obj-$(CONFIG_BLZ603EPLUS_SCSI)	+= amiga7xx.o	53c7xx.o
-obj-$(CONFIG_WARPENGINE_SCSI)	+= amiga7xx.o	53c7xx.o
+obj-$(CONFIG_SCSI_AMIGA7XX)	+= amiga7xx.o	53c7xx.o
 obj-$(CONFIG_A3000_SCSI)	+= a3000.o	wd33c93.o
 obj-$(CONFIG_A2091_SCSI)	+= a2091.o	wd33c93.o
 obj-$(CONFIG_GVP11_SCSI)	+= gvp11.o	wd33c93.o
@@ -74,6 +71,7 @@ obj-$(CONFIG_SCSI_QLOGIC_FAS)	+= qlogicf
 obj-$(CONFIG_SCSI_QLOGIC_ISP)	+= qlogicisp.o 
 obj-$(CONFIG_SCSI_QLOGIC_FC)	+= qlogicfc.o 
 obj-$(CONFIG_SCSI_QLOGIC_1280)	+= qla1280.o 
+obj-$(CONFIG_SCSI_QLA2XXX)	+= qla2xxx/
 obj-$(CONFIG_SCSI_PAS16)	+= pas16.o
 obj-$(CONFIG_SCSI_SEAGATE)	+= seagate.o
 obj-$(CONFIG_SCSI_FD_8xx)	+= seagate.o
diff -puN drivers/scsi/mvme16x.c~linus drivers/scsi/mvme16x.c
--- 25/drivers/scsi/mvme16x.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/mvme16x.c	2004-01-19 22:17:23.000000000 -0800
@@ -21,9 +21,6 @@
 
 #include<linux/stat.h>
 
-extern int ncr53c7xx_init(Scsi_Host_Template *tpnt, int board, int chip,
-			  unsigned long base, int io_port, int irq, int dma,
-			  long long options, int clock);
 
 int mvme16x_scsi_detect(Scsi_Host_Template *tpnt)
 {
diff -puN drivers/scsi/NCR53C9x.h~linus drivers/scsi/NCR53C9x.h
--- 25/drivers/scsi/NCR53C9x.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/NCR53C9x.h	2004-01-19 22:17:23.000000000 -0800
@@ -652,8 +652,7 @@ extern int nesps, esps_in_use, esps_runn
 
 
 /* External functions */
-extern inline void esp_cmd(struct NCR_ESP *esp, struct ESP_regs *eregs,
-			   unchar cmd);
+extern void esp_cmd(struct NCR_ESP *esp, struct ESP_regs *eregs, unchar cmd);
 extern struct NCR_ESP *esp_allocate(Scsi_Host_Template *, void *);
 extern void esp_deallocate(struct NCR_ESP *);
 extern void esp_release(void);
diff -puN drivers/scsi/nsp32.h~linus drivers/scsi/nsp32.h
--- 25/drivers/scsi/nsp32.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/nsp32.h	2004-01-19 22:17:23.000000000 -0800
@@ -667,10 +667,5 @@ static inline struct Scsi_Host *scsi_hos
 }
 #endif
 
-/* for Kernel 2.6 */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
-# define __devinitdata /* */
-#endif
-
 #endif /* _NSP32_H */
 /* end */
diff -puN drivers/scsi/nsp32_io.h~linus drivers/scsi/nsp32_io.h
--- 25/drivers/scsi/nsp32_io.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/nsp32_io.h	2004-01-19 22:17:23.000000000 -0800
@@ -173,7 +173,7 @@ static inline void nsp32_index_write4(un
 
 /*==============================================*/
 
-static inline unsigned char nsp32_mmio_index_read1(unsigned int base,
+static inline unsigned char nsp32_mmio_index_read1(unsigned long base,
 						   unsigned int reg)
 {
 	volatile unsigned short *index_ptr, *data_ptr;
@@ -185,7 +185,7 @@ static inline unsigned char nsp32_mmio_i
 	return readb(data_ptr);
 }
 
-static inline void nsp32_mmio_index_write1(unsigned int  base,
+static inline void nsp32_mmio_index_write1(unsigned long base,
 					   unsigned int  reg,
 					   unsigned char val)
 {
@@ -198,8 +198,8 @@ static inline void nsp32_mmio_index_writ
 	writeb(val, data_ptr );
 }
 
-static inline unsigned short nsp32_mmio_index_read2(unsigned int base,
-						    unsigned int reg)
+static inline unsigned short nsp32_mmio_index_read2(unsigned long base,
+						    unsigned int  reg)
 {
 	volatile unsigned short *index_ptr, *data_ptr;
 
@@ -210,7 +210,7 @@ static inline unsigned short nsp32_mmio_
 	return le16_to_cpu(readw(data_ptr));
 }
 
-static inline void nsp32_mmio_index_write2(unsigned int   base,
+static inline void nsp32_mmio_index_write2(unsigned long  base,
 					   unsigned int   reg,
 					   unsigned short val)
 {
diff -puN drivers/scsi/pcmcia/aha152x_stub.c~linus drivers/scsi/pcmcia/aha152x_stub.c
--- 25/drivers/scsi/pcmcia/aha152x_stub.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/pcmcia/aha152x_stub.c	2004-01-19 22:17:23.000000000 -0800
@@ -153,7 +153,7 @@ static dev_link_t *aha152x_attach(void)
 	CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
-    ret = CardServices(RegisterClient, &link->handle, &client_reg);
+    ret = pcmcia_register_client(&link->handle, &client_reg);
     if (ret != 0) {
 	cs_error(link->handle, RegisterClient, ret);
 	aha152x_detach(link);
@@ -181,7 +181,7 @@ static void aha152x_detach(dev_link_t *l
 	aha152x_release_cs(link);
 
     if (link->handle)
-	CardServices(DeregisterClient, link->handle);
+	pcmcia_deregister_client(link->handle);
     
     /* Unlink device structure, free bits */
     *linkp = link->next;
@@ -191,11 +191,8 @@ static void aha152x_detach(dev_link_t *l
 
 /*====================================================================*/
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
-
-#define CFG_CHECK(fn, args...) \
-if (CardServices(fn, args) != 0) goto next_entry
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static void aha152x_config_cs(dev_link_t *link)
 {
@@ -214,19 +211,20 @@ static void aha152x_config_cs(dev_link_t
     tuple.TupleData = tuple_data;
     tuple.TupleDataMax = 64;
     tuple.TupleOffset = 0;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
-    CS_CHECK(GetTupleData, handle, &tuple);
-    CS_CHECK(ParseTuple, handle, &tuple, &parse);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+    CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+    CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
     link->conf.ConfigBase = parse.config.base;
 
     /* Configure card */
     link->state |= DEV_CONFIG;
 
     tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
     while (1) {
-	CFG_CHECK(GetTupleData, handle, &tuple);
-	CFG_CHECK(ParseTuple, handle, &tuple, &parse);
+	if (pcmcia_get_tuple_data(handle, &tuple) != 0 ||
+		pcmcia_parse_tuple(handle, &tuple, &parse) != 0)
+	    goto next_entry;
 	/* For New Media T&J, look for a SCSI window */
 	if (parse.cftable_entry.io.win[0].len >= 0x20)
 	    link->io.BasePort1 = parse.cftable_entry.io.win[0].base;
@@ -236,15 +234,15 @@ static void aha152x_config_cs(dev_link_t
 	if ((parse.cftable_entry.io.nwin > 0) &&
 	    (link->io.BasePort1 < 0xffff)) {
 	    link->conf.ConfigIndex = parse.cftable_entry.index;
-	    i = CardServices(RequestIO, handle, &link->io);
+	    i = pcmcia_request_io(handle, &link->io);
 	    if (i == CS_SUCCESS) break;
 	}
     next_entry:
-	CS_CHECK(GetNextTuple, handle, &tuple);
+	CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple));
     }
     
-    CS_CHECK(RequestIRQ, handle, &link->irq);
-    CS_CHECK(RequestConfiguration, handle, &link->conf);
+    CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq));
+    CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf));
     
     /* A bad hack... */
     release_region(link->io.BasePort1, link->io.NumPorts1);
@@ -291,9 +289,9 @@ static void aha152x_release_cs(dev_link_
 	scsi_remove_host(info->host);
 	link->dev = NULL;
     
-	CardServices(ReleaseConfiguration, link->handle);
-	CardServices(ReleaseIO, link->handle, &link->io);
-	CardServices(ReleaseIRQ, link->handle, &link->irq);
+	pcmcia_release_configuration(link->handle);
+	pcmcia_release_io(link->handle, &link->io);
+	pcmcia_release_irq(link->handle, &link->irq);
     
 	link->state &= ~DEV_CONFIG;
 	scsi_unregister(info->host);
@@ -322,7 +320,7 @@ static int aha152x_event(event_t event, 
 	/* Fall through... */
     case CS_EVENT_RESET_PHYSICAL:
 	if (link->state & DEV_CONFIG)
-	    CardServices(ReleaseConfiguration, link->handle);
+	    pcmcia_release_configuration(link->handle);
 	break;
     case CS_EVENT_PM_RESUME:
 	link->state &= ~DEV_SUSPEND;
@@ -330,7 +328,7 @@ static int aha152x_event(event_t event, 
     case CS_EVENT_CARD_RESET:
 	if (link->state & DEV_CONFIG) {
 	    Scsi_Cmnd tmp;
-	    CardServices(RequestConfiguration, link->handle, &link->conf);
+	    pcmcia_request_configuration(link->handle, &link->conf);
 	    tmp.device->host = info->host;
 	    aha152x_host_reset(&tmp);
 	}
diff -puN drivers/scsi/pcmcia/fdomain_stub.c~linus drivers/scsi/pcmcia/fdomain_stub.c
--- 25/drivers/scsi/pcmcia/fdomain_stub.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/pcmcia/fdomain_stub.c	2004-01-19 22:17:23.000000000 -0800
@@ -142,7 +142,7 @@ static dev_link_t *fdomain_attach(void)
 	CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
-    ret = CardServices(RegisterClient, &link->handle, &client_reg);
+    ret = pcmcia_register_client(&link->handle, &client_reg);
     if (ret != 0) {
 	cs_error(link->handle, RegisterClient, ret);
 	fdomain_detach(link);
@@ -170,7 +170,7 @@ static void fdomain_detach(dev_link_t *l
 	fdomain_release(link);
 
     if (link->handle)
-	CardServices(DeregisterClient, link->handle);
+	pcmcia_deregister_client(link->handle);
     
     /* Unlink device structure, free bits */
     *linkp = link->next;
@@ -180,11 +180,8 @@ static void fdomain_detach(dev_link_t *l
 
 /*====================================================================*/
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
-
-#define CFG_CHECK(fn, args...) \
-if (CardServices(fn, args) != 0) goto next_entry
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static void fdomain_config(dev_link_t *link)
 {
@@ -203,29 +200,30 @@ static void fdomain_config(dev_link_t *l
     tuple.TupleData = tuple_data;
     tuple.TupleDataMax = 64;
     tuple.TupleOffset = 0;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
-    CS_CHECK(GetTupleData, handle, &tuple);
-    CS_CHECK(ParseTuple, handle, &tuple, &parse);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+    CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+    CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
     link->conf.ConfigBase = parse.config.base;
 
     /* Configure card */
     link->state |= DEV_CONFIG;
     
     tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
     while (1) {
-	CFG_CHECK(GetTupleData, handle, &tuple);
-	CFG_CHECK(ParseTuple, handle, &tuple, &parse);
+	if (pcmcia_get_tuple_data(handle, &tuple) != 0 ||
+		pcmcia_parse_tuple(handle, &tuple, &parse) != 0)
+	    goto next_entry;
 	link->conf.ConfigIndex = parse.cftable_entry.index;
 	link->io.BasePort1 = parse.cftable_entry.io.win[0].base;
-	i = CardServices(RequestIO, handle, &link->io);
+	i = pcmcia_request_io(handle, &link->io);
 	if (i == CS_SUCCESS) break;
     next_entry:
-	CS_CHECK(GetNextTuple, handle, &tuple);
+	CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple));
     }
 
-    CS_CHECK(RequestIRQ, handle, &link->irq);
-    CS_CHECK(RequestConfiguration, handle, &link->conf);
+    CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq));
+    CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf));
     
     /* A bad hack... */
     release_region(link->io.BasePort1, link->io.NumPorts1);
@@ -271,9 +269,9 @@ static void fdomain_release(dev_link_t *
     scsi_remove_host(info->host);
     link->dev = NULL;
     
-    CardServices(ReleaseConfiguration, link->handle);
-    CardServices(ReleaseIO, link->handle, &link->io);
-    CardServices(ReleaseIRQ, link->handle, &link->irq);
+    pcmcia_release_configuration(link->handle);
+    pcmcia_release_io(link->handle, &link->io);
+    pcmcia_release_irq(link->handle, &link->irq);
 
     scsi_unregister(info->host);
 
@@ -304,14 +302,14 @@ static int fdomain_event(event_t event, 
 	/* Fall through... */
     case CS_EVENT_RESET_PHYSICAL:
 	if (link->state & DEV_CONFIG)
-	    CardServices(ReleaseConfiguration, link->handle);
+	    pcmcia_release_configuration(link->handle);
 	break;
     case CS_EVENT_PM_RESUME:
 	link->state &= ~DEV_SUSPEND;
 	/* Fall through... */
     case CS_EVENT_CARD_RESET:
 	if (link->state & DEV_CONFIG) {
-	    CardServices(RequestConfiguration, link->handle, &link->conf);
+	    pcmcia_request_configuration(link->handle, &link->conf);
 	    fdomain_16x0_bus_reset(NULL);
 	}
 	break;
diff -puN drivers/scsi/pcmcia/nsp_cs.c~linus drivers/scsi/pcmcia/nsp_cs.c
--- 25/drivers/scsi/pcmcia/nsp_cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/pcmcia/nsp_cs.c	2004-01-19 22:17:23.000000000 -0800
@@ -1681,7 +1681,7 @@ static dev_link_t *nsp_cs_attach(void)
 	client_reg.event_handler = &nsp_cs_event;
 	client_reg.Version	 = 0x0210;
 	client_reg.event_callback_args.client_data = link;
-	ret = CardServices(RegisterClient, &link->handle, &client_reg);
+	ret = pcmcia_register_client(&link->handle, &client_reg);
 	if (ret != CS_SUCCESS) {
 		cs_error(link->handle, RegisterClient, ret);
 		nsp_cs_detach(link);
@@ -1721,7 +1721,7 @@ static void nsp_cs_detach(dev_link_t *li
 
 	/* Break the link with Card Services */
 	if (link->handle) {
-		CardServices(DeregisterClient, link->handle);
+		pcmcia_deregister_client(link->handle);
 	}
 
 	/* Unlink device structure, free bits */
@@ -1737,10 +1737,8 @@ static void nsp_cs_detach(dev_link_t *li
     is received, to configure the PCMCIA socket, and to make the
     ethernet device available to the system.
 ======================================================================*/
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn),args))!=0) goto cs_failed
-#define CFG_CHECK(fn, args...) \
-if (CardServices(fn, args) != 0) goto next_entry
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 /*====================================================================*/
 static void nsp_cs_config(dev_link_t *link)
 {
@@ -1768,9 +1766,9 @@ static void nsp_cs_config(dev_link_t *li
 	tuple.TupleData	      = tuple_data;
 	tuple.TupleDataMax    = sizeof(tuple_data);
 	tuple.TupleOffset     = 0;
-	CS_CHECK(GetFirstTuple, handle, &tuple);
-	CS_CHECK(GetTupleData,	handle, &tuple);
-	CS_CHECK(ParseTuple,	handle, &tuple, &parse);
+	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+	CS_CHECK(GetTupleData,	pcmcia_get_tuple_data(handle, &tuple));
+	CS_CHECK(ParseTuple,	pcmcia_parse_tuple(handle, &tuple, &parse));
 	link->conf.ConfigBase = parse.config.base;
 	link->conf.Present    = parse.config.rmask[0];
 
@@ -1778,16 +1776,17 @@ static void nsp_cs_config(dev_link_t *li
 	link->state	      |= DEV_CONFIG;
 
 	/* Look up the current Vcc */
-	CS_CHECK(GetConfigurationInfo, handle, &conf);
+	CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf));
 	link->conf.Vcc = conf.Vcc;
 
 	tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
-	CS_CHECK(GetFirstTuple, handle, &tuple);
+	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
 	while (1) {
 		cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
 
-		CFG_CHECK(GetTupleData, handle, &tuple);
-		CFG_CHECK(ParseTuple,	handle, &tuple, &parse);
+		if (pcmcia_get_tuple_data(handle, &tuple) != 0 ||
+				pcmcia_parse_tuple(handle, &tuple, &parse) != 0)
+			goto next_entry;
 
 		if (cfg->flags & CISTPL_CFTABLE_DEFAULT) { dflt = *cfg; }
 		if (cfg->index == 0) { goto next_entry; }
@@ -1842,7 +1841,8 @@ static void nsp_cs_config(dev_link_t *li
 				link->io.NumPorts2 = io->win[1].len;
 			}
 			/* This reserves IO space but doesn't actually enable it */
-			CFG_CHECK(RequestIO, link->handle, &link->io);
+			if (pcmcia_request_io(link->handle, &link->io) != 0)
+				goto next_entry;
 		}
 
 		if ((cfg->mem.nwin > 0) || (dflt.mem.nwin > 0)) {
@@ -1856,10 +1856,11 @@ static void nsp_cs_config(dev_link_t *li
 				req.Size = 0x1000;
 			}
 			req.AccessSpeed = 0;
-			link->win = (window_handle_t)link->handle;
-			CFG_CHECK(RequestWindow, &link->win, &req);
+			if (pcmcia_request_window(&link->handle, &req, &link->win) != 0)
+				goto next_entry;
 			map.Page = 0; map.CardOffset = mem->win[0].card_addr;
-			CFG_CHECK(MapMemPage, link->win, &map);
+			if (pcmcia_map_mem_page(link->win, &map) != 0)
+				goto next_entry;
 
 			data->MmioAddress = (unsigned long)ioremap_nocache(req.Base, req.Size);
 			data->MmioLength  = req.Size;
@@ -1871,15 +1872,15 @@ static void nsp_cs_config(dev_link_t *li
 		nsp_dbg(NSP_DEBUG_INIT, "next");
 
 		if (link->io.NumPorts1) {
-			CardServices(ReleaseIO, link->handle, &link->io);
+			pcmcia_release_io(link->handle, &link->io);
 		}
-		CS_CHECK(GetNextTuple, handle, &tuple);
+		CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple));
 	}
 
 	if (link->conf.Attributes & CONF_ENABLE_IRQ) {
-		CS_CHECK(RequestIRQ, link->handle, &link->irq);
+		CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
 	}
-	CS_CHECK(RequestConfiguration, handle, &link->conf);
+	CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf));
 
 	if (free_ports) {
 		if (link->io.BasePort1) {
@@ -2007,7 +2008,6 @@ static void nsp_cs_config(dev_link_t *li
 	return;
 } /* nsp_cs_config */
 #undef CS_CHECK
-#undef CFG_CHECK
 
 
 /*======================================================================
@@ -2042,14 +2042,14 @@ static void nsp_cs_release(dev_link_t *l
 		if (data != NULL) {
 			iounmap((void *)(data->MmioAddress));
 		}
-		CardServices(ReleaseWindow, link->win);
+		pcmcia_release_window(link->win);
 	}
-	CardServices(ReleaseConfiguration,  link->handle);
+	pcmcia_release_configuration(link->handle);
 	if (link->io.NumPorts1) {
-		CardServices(ReleaseIO,     link->handle, &link->io);
+		pcmcia_release_io(link->handle, &link->io);
 	}
 	if (link->irq.AssignedIRQ) {
-		CardServices(ReleaseIRQ,    link->handle, &link->irq);
+		pcmcia_release_irq(link->handle, &link->irq);
 	}
 	link->state &= ~DEV_CONFIG;
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,2))
@@ -2119,7 +2119,7 @@ static int nsp_cs_event(event_t		       
 
 		info->stop = 1;
 		if (link->state & DEV_CONFIG) {
-			CardServices(ReleaseConfiguration, link->handle);
+			pcmcia_release_configuration(link->handle);
 		}
 		break;
 
@@ -2130,7 +2130,7 @@ static int nsp_cs_event(event_t		       
 	case CS_EVENT_CARD_RESET:
 		nsp_dbg(NSP_DEBUG_INIT, "event: reset");
 		if (link->state & DEV_CONFIG) {
-			CardServices(RequestConfiguration, link->handle, &link->conf);
+			pcmcia_request_configuration(link->handle, &link->conf);
 		}
 		info->stop = 0;
 
@@ -2177,7 +2177,7 @@ static int __init nsp_cs_init(void)
 	servinfo_t serv;
 
 	nsp_msg(KERN_INFO, "loading...");
-	CardServices(GetCardServicesInfo, &serv);
+	pcmcia_get_card_services_info(&serv);
 	if (serv.Revision != CS_RELEASE_CODE) {
 		nsp_msg(KERN_DEBUG, "Card Services release does not match!");
 		return -EINVAL;
diff -puN drivers/scsi/pcmcia/nsp_cs.h~linus drivers/scsi/pcmcia/nsp_cs.h
--- 25/drivers/scsi/pcmcia/nsp_cs.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/pcmcia/nsp_cs.h	2004-01-19 22:17:23.000000000 -0800
@@ -457,7 +457,7 @@ static inline struct Scsi_Host *scsi_hos
 static void cs_error(client_handle_t handle, int func, int ret)
 {
 	error_info_t err = { func, ret };
-	CardServices(ReportError, handle, &err);
+	pcmcia_report_error(handle, &err);
 }
 
 /* scatter-gather table */
diff -puN drivers/scsi/pcmcia/qlogic_stub.c~linus drivers/scsi/pcmcia/qlogic_stub.c
--- 25/drivers/scsi/pcmcia/qlogic_stub.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/pcmcia/qlogic_stub.c	2004-01-19 22:17:23.000000000 -0800
@@ -140,7 +140,7 @@ static dev_link_t *qlogic_attach(void)
 	client_reg.EventMask = CS_EVENT_RESET_REQUEST | CS_EVENT_CARD_RESET | CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL | CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
 	client_reg.Version = 0x0210;
 	client_reg.event_callback_args.client_data = link;
-	ret = CardServices(RegisterClient, &link->handle, &client_reg);
+	ret = pcmcia_register_client(&link->handle, &client_reg);
 	if (ret != 0) {
 		cs_error(link->handle, RegisterClient, ret);
 		qlogic_detach(link);
@@ -169,7 +169,7 @@ static void qlogic_detach(dev_link_t * l
 		qlogic_release(link);
 
 	if (link->handle)
-		CardServices(DeregisterClient, link->handle);
+		pcmcia_deregister_client(link->handle);
 
 	/* Unlink device structure, free bits */
 	*linkp = link->next;
@@ -179,11 +179,8 @@ static void qlogic_detach(dev_link_t * l
 
 /*====================================================================*/
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
-
-#define CFG_CHECK(fn, args...) \
-if (CardServices(fn, args) != 0) goto next_entry
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static void qlogic_config(dev_link_t * link)
 {
@@ -201,37 +198,38 @@ static void qlogic_config(dev_link_t * l
 	tuple.TupleDataMax = 64;
 	tuple.TupleOffset = 0;
 	tuple.DesiredTuple = CISTPL_CONFIG;
-	CS_CHECK(GetFirstTuple, handle, &tuple);
-	CS_CHECK(GetTupleData, handle, &tuple);
-	CS_CHECK(ParseTuple, handle, &tuple, &parse);
+	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+	CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+	CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
 	link->conf.ConfigBase = parse.config.base;
 
 	tuple.DesiredTuple = CISTPL_MANFID;
-	if ((CardServices(GetFirstTuple, handle, &tuple) == CS_SUCCESS) && (CardServices(GetTupleData, handle, &tuple) == CS_SUCCESS))
+	if ((pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) && (pcmcia_get_tuple_data(handle, &tuple) == CS_SUCCESS))
 		info->manf_id = le16_to_cpu(tuple.TupleData[0]);
 
 	/* Configure card */
 	link->state |= DEV_CONFIG;
 
 	tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
-	CS_CHECK(GetFirstTuple, handle, &tuple);
+	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
 	while (1) {
-		CFG_CHECK(GetTupleData, handle, &tuple);
-		CFG_CHECK(ParseTuple, handle, &tuple, &parse);
+		if (pcmcia_get_tuple_data(handle, &tuple) != 0 ||
+				pcmcia_parse_tuple(handle, &tuple, &parse) != 0)
+			goto next_entry;
 		link->conf.ConfigIndex = parse.cftable_entry.index;
 		link->io.BasePort1 = parse.cftable_entry.io.win[0].base;
 		link->io.NumPorts1 = parse.cftable_entry.io.win[0].len;
 		if (link->io.BasePort1 != 0) {
-			i = CardServices(RequestIO, handle, &link->io);
+			i = pcmcia_request_io(handle, &link->io);
 			if (i == CS_SUCCESS)
 				break;
 		}
 	      next_entry:
-		CS_CHECK(GetNextTuple, handle, &tuple);
+		CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple));
 	}
 
-	CS_CHECK(RequestIRQ, handle, &link->irq);
-	CS_CHECK(RequestConfiguration, handle, &link->conf);
+	CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq));
+	CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf));
 
 	if ((info->manf_id == MANFID_MACNICA) || (info->manf_id == MANFID_PIONEER) || (info->manf_id == 0x0098)) {
 		/* set ATAcmd */
@@ -284,9 +282,9 @@ static void qlogic_release(dev_link_t *l
 	scsi_remove_host(info->host);
 	link->dev = NULL;
 
-	CardServices(ReleaseConfiguration, link->handle);
-	CardServices(ReleaseIO, link->handle, &link->io);
-	CardServices(ReleaseIRQ, link->handle, &link->irq);
+	pcmcia_release_configuration(link->handle);
+	pcmcia_release_io(link->handle, &link->io);
+	pcmcia_release_irq(link->handle, &link->irq);
 
 	scsi_unregister(info->host);
 
@@ -316,7 +314,7 @@ static int qlogic_event(event_t event, i
 		/* Fall through... */
 	case CS_EVENT_RESET_PHYSICAL:
 		if (link->state & DEV_CONFIG)
-			CardServices(ReleaseConfiguration, link->handle);
+			pcmcia_release_configuration(link->handle);
 		break;
 	case CS_EVENT_PM_RESUME:
 		link->state &= ~DEV_SUSPEND;
@@ -324,7 +322,7 @@ static int qlogic_event(event_t event, i
 	case CS_EVENT_CARD_RESET:
 		if (link->state & DEV_CONFIG) {
 			scsi_info_t *info = link->priv;
-			CardServices(RequestConfiguration, link->handle, &link->conf);
+			pcmcia_request_configuration(link->handle, &link->conf);
 			if ((info->manf_id == MANFID_MACNICA) || (info->manf_id == MANFID_PIONEER) || (info->manf_id == 0x0098)) {
 				outb(0x80, link->io.BasePort1 + 0xd);
 				outb(0x24, link->io.BasePort1 + 0x9);
diff -puN drivers/scsi/qla1280.c~linus drivers/scsi/qla1280.c
--- 25/drivers/scsi/qla1280.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/qla1280.c	2004-01-19 22:17:23.000000000 -0800
@@ -3,7 +3,8 @@
 *
 * QLogic  QLA1280 (Ultra2)  and  QLA12160 (Ultra3) SCSI driver
 * Copyright (C) 2000 Qlogic Corporation (www.qlogic.com)
-* Copyright (C) 2001-2003 Jes Sorensen, Wild Open Source Inc.
+* Copyright (C) 2001-2004 Jes Sorensen, Wild Open Source Inc.
+* Copyright (C) 2003 Christoph Hellwig
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
@@ -16,13 +17,37 @@
 * General Public License for more details.
 *
 ******************************************************************************/
-#define QLA1280_VERSION      "3.23.37.1"
+#define QLA1280_VERSION      "3.24.3"
 /*****************************************************************************
     Revision History:
-    Rev  3.23.37.1 December 17, 2003, Jes Sorensen
+    Rev  3.24.3 January 19, 2004, Jes Sorensen
+	- Handle PCI DMA mask settings correctly
+	- Correct order of error handling in probe_one, free_irq should not
+	  be called if request_irq failed
+    Rev  3.24.2 January 19, 2004, James Bottomley & Andrew Vasquez
+	- Big endian fixes (James)
+	- Remove bogus IOCB content on zero data transfer commands (Andrew)
+    Rev  3.24.1 January 5, 2004, Jes Sorensen
+	- Initialize completion queue to avoid OOPS on probe
+	- Handle interrupts during mailbox testing
+    Rev  3.24 November 17, 2003, Christoph Hellwig
+    	- use struct list_head for completion queue
+	- avoid old Scsi_FOO typedefs
+	- cleanup 2.4 compat glue a bit
+	- use <scsi/scsi_*.h> headers on 2.6 instead of "scsi.h"
+	- make initialization for memory mapped vs port I/O more similar
+	- remove broken pci config space manipulation
+	- kill more cruft
+	- this is an almost perfect 2.6 scsi driver now! ;)
+    Rev  3.23.39 December 17, 2003, Jes Sorensen
 	- Delete completion queue from srb if mailbox command failed to
 	  to avoid qla1280_done completeting qla1280_error_action's
 	  obsolete context
+	- Reduce arguments for qla1280_done
+    Rev  3.23.38 October 18, 2003, Christoph Hellwig
+	- Convert to new-style hotplugable driver for 2.6
+	- Fix missing scsi_unregister/scsi_host_put on HBA removal
+	- Kill some more cruft
     Rev  3.23.37 October 1, 2003, Jes Sorensen
 	- Make MMIO depend on CONFIG_X86_VISWS instead of yet another
 	  random CONFIG option
@@ -323,7 +348,12 @@
 #include <asm/system.h>
 
 #if LINUX_VERSION_CODE >= 0x020545
+#include <asm/cacheflush.h>	/* for flush_cache_all() */
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_device.h>
 #include <scsi/scsi_host.h>
+#include <scsi/scsi_tcq.h>
 #include "scsi.h"
 #else
 #include <linux/blk.h>
@@ -341,9 +371,6 @@
  * Compile time Options:
  *            0 - Disable and 1 - Enable
  */
-#define  QL1280_LUN_SUPPORT	0
-#define  WATCHDOGTIMER		0
-
 #define  DEBUG_QLA1280_INTR	0
 #define  DEBUG_PRINT_NVRAM	0
 #define  DEBUG_QLA1280		0
@@ -414,8 +441,18 @@ extern int snia_pcibr_rrb_alloc(struct p
 #define irqreturn_t			void
 #define IRQ_RETVAL(foo)
 #define MSG_ORDERED_TAG			1
+
+#define DMA_BIDIRECTIONAL	SCSI_DATA_UNKNOWN
+#define DMA_TO_DEVICE		SCSI_DATA_WRITE
+#define DMA_FROM_DEVICE		SCSI_DATA_READ
+#define DMA_NONE		SCSI_DATA_NONE
+
+#ifndef HAVE_SECTOR_T
+typedef unsigned int sector_t;
+#endif
+
 static inline void
-scsi_adjust_queue_depth(Scsi_Device *device, int tag, int depth)
+scsi_adjust_queue_depth(struct scsi_device *device, int tag, int depth)
 {
 	if (tag) {
 		device->tagged_queue = tag;
@@ -423,11 +460,25 @@ scsi_adjust_queue_depth(Scsi_Device *dev
 	}
 	device->queue_depth = depth;
 }
+static inline struct Scsi_Host *scsi_host_alloc(Scsi_Host_Template *t, size_t s)
+{
+	return scsi_register(t, s);
+}
+static inline void scsi_host_put(struct Scsi_Host *h)
+{
+	scsi_unregister(h);
+}
 #else
 #define HOST_LOCK			ha->host->host_lock
 #endif
 #if LINUX_VERSION_CODE < 0x020600
 #define DEV_SIMPLE_TAGS(device)		device->tagged_queue
+/*
+ * Hack around that qla1280_remove_one is called from
+ * qla1280_release in 2.4
+ */
+#undef __devexit
+#define __devexit
 #else
 #define DEV_SIMPLE_TAGS(device)		device->simple_tags
 #endif
@@ -435,30 +486,23 @@ scsi_adjust_queue_depth(Scsi_Device *dev
 #define ia64_platform_is(foo)		(!strcmp(x, platform_name))
 #endif
 
+static int qla1280_probe_one(struct pci_dev *, const struct pci_device_id *);
+static void qla1280_remove_one(struct pci_dev *);
+
 /*
  *  QLogic Driver Support Function Prototypes.
  */
-static void qla1280_done(struct scsi_qla_host *, struct srb **, struct srb **);
-static void qla1280_done_q_put(struct srb *, struct srb **, struct srb **);
-static int qla1280_slave_configure(Scsi_Device *);
+static void qla1280_done(struct scsi_qla_host *);
 #if LINUX_VERSION_CODE < 0x020545
-static void qla1280_select_queue_depth(struct Scsi_Host *, Scsi_Device *);
 static void qla1280_get_target_options(struct scsi_cmnd *, struct scsi_qla_host *);
 #endif
-
-static int qla1280_return_status(struct response * sts, Scsi_Cmnd * cp);
-static void qla1280_mem_free(struct scsi_qla_host *ha);
 static int qla1280_get_token(char *);
 static int qla1280_setup(char *s) __init;
-static inline void qla1280_enable_intrs(struct scsi_qla_host *);
-static inline void qla1280_disable_intrs(struct scsi_qla_host *);
 
 /*
  *  QLogic ISP1280 Hardware Support Function Prototypes.
  */
-static int qla1280_initialize_adapter(struct scsi_qla_host *ha);
 static int qla1280_isp_firmware(struct scsi_qla_host *);
-static int qla1280_pci_config(struct scsi_qla_host *);
 static int qla1280_chip_diag(struct scsi_qla_host *);
 static int qla1280_setup_chip(struct scsi_qla_host *);
 static int qla1280_init_rings(struct scsi_qla_host *);
@@ -470,31 +514,31 @@ static int qla1280_device_reset(struct s
 static int qla1280_abort_device(struct scsi_qla_host *, int, int, int);
 static int qla1280_abort_command(struct scsi_qla_host *, struct srb *, int);
 static int qla1280_abort_isp(struct scsi_qla_host *);
+#ifdef QLA_64BIT_PTR
 static int qla1280_64bit_start_scsi(struct scsi_qla_host *, struct srb *);
+#else
 static int qla1280_32bit_start_scsi(struct scsi_qla_host *, struct srb *);
+#endif
 static void qla1280_nv_write(struct scsi_qla_host *, uint16_t);
 static void qla1280_poll(struct scsi_qla_host *);
 static void qla1280_reset_adapter(struct scsi_qla_host *);
 static void qla1280_marker(struct scsi_qla_host *, int, int, int, u8);
 static void qla1280_isp_cmd(struct scsi_qla_host *);
-irqreturn_t qla1280_intr_handler(int, void *, struct pt_regs *);
-static void qla1280_isr(struct scsi_qla_host *, struct srb **, struct srb **);
+static void qla1280_isr(struct scsi_qla_host *, struct list_head *);
 static void qla1280_rst_aen(struct scsi_qla_host *);
 static void qla1280_status_entry(struct scsi_qla_host *, struct response *,
-				 struct srb **, struct srb **);
+				 struct list_head *);
 static void qla1280_error_entry(struct scsi_qla_host *, struct response *,
-				struct srb **, struct srb **);
+				struct list_head *);
 static uint16_t qla1280_get_nvram_word(struct scsi_qla_host *, uint32_t);
 static uint16_t qla1280_nvram_request(struct scsi_qla_host *, uint32_t);
 static uint16_t qla1280_debounce_register(volatile uint16_t *);
 static request_t *qla1280_req_pkt(struct scsi_qla_host *);
 static int qla1280_check_for_dead_scsi_bus(struct scsi_qla_host *,
 					   unsigned int);
-static int qla1280_mem_alloc(struct scsi_qla_host *ha);
-
-static void qla12160_get_target_parameters(struct scsi_qla_host *,
-					   Scsi_Device *);
-static int qla12160_set_target_parameters(struct scsi_qla_host *, int, int);
+static void qla1280_get_target_parameters(struct scsi_qla_host *,
+					   struct scsi_device *);
+static int qla1280_set_target_parameters(struct scsi_qla_host *, int, int);
 
 
 static struct qla_driver_setup driver_setup __initdata;
@@ -505,36 +549,26 @@ static struct qla_driver_setup driver_se
 static inline uint16_t
 qla1280_data_direction(struct scsi_cmnd *cmnd)
 {
-	uint16_t flags = 0;
-
 	switch(cmnd->sc_data_direction) {
-
-	case SCSI_DATA_NONE:
-		flags = 0;
-		break;
-
-	case SCSI_DATA_READ:
-		flags = BIT_5;
-		break;
-
-	case SCSI_DATA_WRITE:
-		flags = BIT_6;
-		break;
-
-	case SCSI_DATA_UNKNOWN:
+	case DMA_FROM_DEVICE:
+		return BIT_5;
+	case DMA_TO_DEVICE:
+		return BIT_6;
+	case DMA_BIDIRECTIONAL:
+		return BIT_5 | BIT_6;
+	/*
+	 * We could BUG() on default here if one of the four cases aren't
+	 * met, but then again if we receive something like that from the
+	 * SCSI layer we have more serious problems. This shuts up GCC.
+	 */
+	case DMA_NONE:
 	default:
-		flags = BIT_5 | BIT_6;
-		break;
+		return 0;
 	}
-	return flags;
 }
 		
-#if QL1280_LUN_SUPPORT
-static void qla1280_enable_lun(struct scsi_qla_host *, int, int);
-#endif
-
 #if DEBUG_QLA1280
-static void __qla1280_print_scsi_cmd(Scsi_Cmnd * cmd);
+static void __qla1280_print_scsi_cmd(struct scsi_cmnd * cmd);
 static void __qla1280_dump_buffer(char *, int);
 #endif
 
@@ -551,21 +585,11 @@ MODULE_PARM(qla1280, "s");
 __setup("qla1280=", qla1280_setup);
 #endif
 
-MODULE_LICENSE("GPL");
-
 
-/* We use the Scsi_Pointer structure that's included with each command
- * SCSI_Cmnd as a scratchpad for our SRB.
- *
- * SCp will always point to the SRB structure (defined in qla1280.h).
- * It is define as follows:
- *  - SCp.ptr  -- > pointer back to the cmd
- *  - SCp.this_residual --> used as forward pointer to next srb
- *  - SCp.buffer --> used as backward pointer to next srb
- *  - SCp.buffers_residual --> used as flags field
- *  - SCp.have_data_in --> not used
- *  - SCp.sent_command --> not used
- *  - SCp.phase --> not used
+/*
+ * We use the scsi_pointer structure that's included with each scsi_command
+ * to overlay our struct srb over it. qla1280_init() checks that a srb is not
+ * bigger than a scsi_pointer.
  */
 
 #define	CMD_SP(Cmnd)		&Cmnd->SCp
@@ -576,28 +600,23 @@ MODULE_LICENSE("GPL");
 #define	CMD_RESULT(Cmnd)	Cmnd->result
 #define	CMD_HANDLE(Cmnd)	Cmnd->host_scribble
 #if LINUX_VERSION_CODE < 0x020545
-#define	CMD_HOST(Cmnd)		Cmnd->host
 #define CMD_REQUEST(Cmnd)	Cmnd->request.cmd
-#define SCSI_BUS_32(Cmnd)	Cmnd->channel
-#define SCSI_TCN_32(Cmnd)	Cmnd->target
-#define SCSI_LUN_32(Cmnd)	Cmnd->lun
 #else
-#define	CMD_HOST(Cmnd)		Cmnd->device->host
 #define CMD_REQUEST(Cmnd)	Cmnd->request->cmd
+#endif
+
+#define CMD_HOST(Cmnd)		Cmnd->device->host
 #define SCSI_BUS_32(Cmnd)	Cmnd->device->channel
 #define SCSI_TCN_32(Cmnd)	Cmnd->device->id
 #define SCSI_LUN_32(Cmnd)	Cmnd->device->lun
-#endif
+
 
 /*****************************************/
 /*   ISP Boards supported by this driver */
 /*****************************************/
 
-#define NUM_OF_ISP_DEVICES	6
-
 struct qla_boards {
 	unsigned char name[9];	/* Board ID String */
-	unsigned long device_id;	/* Device PCI ID   */
 	int numPorts;		/* Number of SCSI ports */
 	unsigned short *fwcode;	/* pointer to FW array         */
 	unsigned short *fwlen;	/* number of words in array    */
@@ -605,28 +624,38 @@ struct qla_boards {
 	unsigned char *fwver;	/* Ptr to F/W version array    */
 };
 
-struct qla_boards ql1280_board_tbl[NUM_OF_ISP_DEVICES] = {
-	/* Name ,  Board PCI Device ID,         Number of ports */
-	{"QLA12160", PCI_DEVICE_ID_QLOGIC_ISP12160, 2,
-	 &fw12160i_code01[0], &fw12160i_length01,
+/* NOTE: qla1280_pci_tbl and ql1280_board_tbl must be in the same order */
+static struct pci_device_id qla1280_pci_tbl[] = {
+	{PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP12160,
+		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1080,
+		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
+	{PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1240,
+		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2},
+	{PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1280,
+		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3},
+	{PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP10160,
+		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4},
+	{0,}
+};
+MODULE_DEVICE_TABLE(pci, qla1280_pci_tbl);
+
+static struct qla_boards ql1280_board_tbl[] = {
+	/* Name ,  Number of ports, FW details */
+	{"QLA12160", 2, &fw12160i_code01[0], &fw12160i_length01,
 	 &fw12160i_addr01, &fw12160i_version_str[0]},
-	{"QLA1080", PCI_DEVICE_ID_QLOGIC_ISP1080, 1,
-	 &fw1280ei_code01[0], &fw1280ei_length01,
+	{"QLA1080", 1, &fw1280ei_code01[0], &fw1280ei_length01,
 	 &fw1280ei_addr01, &fw1280ei_version_str[0]},
-	{"QLA1240", PCI_DEVICE_ID_QLOGIC_ISP1240, 2,
-	 &fw1280ei_code01[0], &fw1280ei_length01,
+	{"QLA1240", 2, &fw1280ei_code01[0], &fw1280ei_length01,
 	 &fw1280ei_addr01, &fw1280ei_version_str[0]},
-	{"QLA1280", PCI_DEVICE_ID_QLOGIC_ISP1280, 2,
-	 &fw1280ei_code01[0], &fw1280ei_length01,
+	{"QLA1280", 2, &fw1280ei_code01[0], &fw1280ei_length01,
 	 &fw1280ei_addr01, &fw1280ei_version_str[0]},
-	{"QLA10160", PCI_DEVICE_ID_QLOGIC_ISP10160, 1,
-	 &fw12160i_code01[0], &fw12160i_length01,
+	{"QLA10160", 1, &fw12160i_code01[0], &fw12160i_length01,
 	 &fw12160i_addr01, &fw12160i_version_str[0]},
-	{"        ", 0, 0}
+	{"        ", 0}
 };
 
 static int qla1280_verbose = 1;
-static struct scsi_qla_host *qla1280_hostlist;
 static int qla1280_buffer_size;
 static char *qla1280_buffer;
 
@@ -663,43 +692,13 @@ static int ql_debug_level = 1;
  *************************************************************************/
 #define	PROC_BUF	&qla1280_buffer[len]
 
-#if LINUX_VERSION_CODE < 0x020600
-static int qla1280_proc_info(char *buffer, char **start, off_t offset,
-			     int length, int hostno, int inout)
-#else
 static int qla1280_proc_info(struct Scsi_Host *host, char *buffer,
 			     char **start, off_t offset, int length, int inout)
-#endif
 {
-	struct scsi_qla_host *ha;
+	struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata;
+	struct qla_boards *bdp = &ql1280_board_tbl[ha->devnum];
 	int size = 0;
 	int len = 0;
-	struct qla_boards *bdp;
-#ifdef BOGUS_QUEUE
-	struct scsi_lu *up;
-	uint32_t b, t, l;
-#endif
-#if LINUX_VERSION_CODE >= 0x020600
-	ha = (struct scsi_qla_host *)host->hostdata;
-#else
-	struct Scsi_Host *host;
-	/* Find the host that was specified */
-	for (ha = qla1280_hostlist; (ha != NULL)
-		     && ha->host->host_no != hostno; ha = ha->next) ;
-
-	/* if host wasn't found then exit */
-	if (!ha) {
-		size =  sprintf(buffer, "Can't find adapter for host "
-				"number %d\n", hostno);
-		if (size > length) {
-			return size;
-		} else {
-			return 0;
-		}
-	}
-
-	host = ha->host;
-#endif
 
 	if (inout)
 		return -ENOSYS;
@@ -728,7 +727,6 @@ static int qla1280_proc_info(struct Scsi
 	memset(qla1280_buffer, 0, PAGE_SIZE);
 
 	/* start building the print buffer */
-	bdp = &ql1280_board_tbl[ha->devnum];
 	size = sprintf(PROC_BUF,
 		       "QLogic PCI to SCSI Adapter for ISP 1280/12160:\n"
 		       "        Firmware version: %2d.%02d.%02d, Driver version %s\n",
@@ -753,51 +751,6 @@ static int qla1280_proc_info(struct Scsi
 	size = sprintf(PROC_BUF, "\n");	/* 1       */
 	len += size;
 
-	size = sprintf(PROC_BUF, "SCSI device Information:\n");
-	len += size;
-#ifdef BOGUS_QUEUE
-	/* scan for all equipment stats */
-	for (b = 0; b < MAX_BUSES; b++)
-		for (t = 0; t < MAX_TARGETS; t++) {
-			for (l = 0; l < MAX_LUNS; l++) {
-				up = LU_Q(ha, b, t, l);
-				if (up == NULL)
-					continue;
-				/* unused device/lun */
-				if (up->io_cnt == 0 || up->io_cnt < 2)
-					continue;
-				/* total reads since boot */
-				/* total writes since boot */
-				/* total requests since boot  */
-				size = sprintf (PROC_BUF,
-						"(%2d:%2d:%2d): Total reqs %ld,",
-						b, t, l, up->io_cnt);
-				len += size;
-				/* current number of pending requests */
-				size =	sprintf(PROC_BUF, " Pend reqs %d,",
-						up->q_outcnt);
-				len += size;
-#if 0
-				/* avg response time */
-				size = sprintf(PROC_BUF, " Avg resp time %ld%%,",
-					       (up->resp_time / up->io_cnt) *
-					       100);
-				len += size;
-
-				/* avg active time */
-				size = sprintf(PROC_BUF,
-					       " Avg active time %ld%%\n",
-					       (up->act_time / up->io_cnt) * 100);
-#else
-				size = sprintf(PROC_BUF, "\n");
-#endif
-				len += size;
-			}
-			if (len >= qla1280_buffer_size)
-				break;
-		}
-#endif
-
 	if (len >= qla1280_buffer_size) {
 		printk(KERN_WARNING
 		       "qla1280: Overflow buffer in qla1280_proc.c\n");
@@ -822,7 +775,7 @@ static int qla1280_read_nvram(struct scs
 {
 	uint16_t *wptr;
 	uint8_t chksum;
-	int cnt;
+	int cnt, i;
 	struct nvram *nv;
 
 	ENTER("qla1280_read_nvram");
@@ -869,318 +822,34 @@ static int qla1280_read_nvram(struct scs
 	} else
 		ha->nvram_valid = 1;
 
+	/* The firmware interface is, um, interesting, in that the
+	 * actual firmware image on the chip is little endian, thus,
+	 * the process of taking that image to the CPU would end up
+	 * little endian.  However, the firmare interface requires it
+	 * to be read a word (two bytes) at a time.
+	 *
+	 * The net result of this would be that the word (and
+	 * doubleword) quantites in the firmware would be correct, but
+	 * the bytes would be pairwise reversed.  Since most of the
+	 * firmware quantites are, in fact, bytes, we do an extra
+	 * le16_to_cpu() in the firmware read routine.
+	 *
+	 * The upshot of all this is that the bytes in the firmware
+	 * are in the correct places, but the 16 and 32 bit quantites
+	 * are still in little endian format.  We fix that up below by
+	 * doing extra reverses on them */
+	nv->isp_parameter = cpu_to_le16(nv->isp_parameter);
+	nv->firmware_feature.w = cpu_to_le16(nv->firmware_feature.w);
+	for(i = 0; i < MAX_BUSES; i++) {
+		nv->bus[i].selection_timeout = cpu_to_le16(nv->bus[i].selection_timeout);
+		nv->bus[i].max_queue_depth = cpu_to_le16(nv->bus[i].max_queue_depth);
+	}
 	dprintk(1, "qla1280_read_nvram: Completed Reading NVRAM\n");
 	LEAVE("qla1280_read_nvram");
 
 	return chksum;
 }
 
-
-/**************************************************************************
- * qla1280_do_device_init
- *    This routine will register the device with the SCSI subsystem,
- *    initialize the host adapter structure and call the device init
- *    routines.
- *
- * Input:
- *     pdev      - pointer to struct pci_dev for adapter
- *     template  - pointer to SCSI template
- *     devnum    - the device number
- *     bdp       - pointer to struct _qlaboards
- *     num_hosts - the host number
- *
- * Returns:
- *  host - pointer to SCSI host structure
- **************************************************************************/
-struct Scsi_Host *
-qla1280_do_device_init(struct pci_dev *pdev, Scsi_Host_Template * template,
-		       int devnum, struct qla_boards *bdp, int num_hosts)
-{
-	struct Scsi_Host *host;
-	struct scsi_qla_host *ha;
-
-	printk(KERN_INFO "qla1280: %s found on PCI bus %i, dev %i\n",
-	       bdp->name, pdev->bus->number, PCI_SLOT(pdev->devfn));
-
-	host = scsi_register(template, sizeof(struct scsi_qla_host));
-	if (!host) {
-		printk(KERN_WARNING
-		       "qla1280: Failed to register host, aborting.\n");
-		goto error;
-	}
-
-#if LINUX_VERSION_CODE < 0x020545
-	scsi_set_pci_device(host, pdev);
-#else
-	scsi_set_device(host, &pdev->dev);
-#endif
-	ha = (struct scsi_qla_host *)host->hostdata;
-	/* Clear our data area */
-	memset(ha, 0, sizeof(struct scsi_qla_host));
-	/* Sanitize the information from PCI BIOS.  */
-	host->irq = pdev->irq;
-	ha->pci_bus = pdev->bus->number;
-	ha->pci_device_fn = pdev->devfn;
-	ha->pdev = pdev;
-	ha->device_id = bdp->device_id;
-	ha->devnum = devnum;	/* specifies microcode load address */
-
-	if (qla1280_mem_alloc(ha)) {
-		printk(KERN_INFO "qla1x160: Failed to get memory\n");
-		goto error_scsi_unregister;
-	}
-
-	ha->ports = bdp->numPorts;
-	/* following needed for all cases of OS versions */
-	ha->host = host;
-	ha->host_no = host->host_no;
-
-	host->can_queue = 0xfffff;	/* unlimited  */
-	host->cmd_per_lun = 1;
-	host->base = (unsigned long)ha->mmpbase;
-	host->max_channel = bdp->numPorts - 1;
-	host->max_lun = MAX_LUNS - 1;
-	host->max_id = MAX_TARGETS;
-	host->max_sectors = 1024;
-#if LINUX_VERSION_CODE < 0x020545
-	host->select_queue_depths = qla1280_select_queue_depth;
-#endif
-
-	ha->instance = num_hosts;
-	host->unique_id = ha->instance;
-
-	if (qla1280_pci_config(ha)) {
-		printk(KERN_INFO "qla1x160: Unable to configure PCI\n");
-		goto error_mem_alloced;
-	}
-
-	/* Disable ISP interrupts. */
-	qla1280_disable_intrs(ha);
-
-	/* Register the IRQ with Linux (sharable) */
-	if (request_irq(host->irq, qla1280_intr_handler, SA_SHIRQ,
-			"qla1280", ha)) {
-		printk("qla1280 : Failed to reserve interrupt %d already "
-		       "in use\n", host->irq);
-		goto error_iounmap;
-	}
-#if !MEMORY_MAPPED_IO
-	/* Register the I/O space with Linux */
-	if (!request_region(host->io_port, 0xff, "qla1280")) {
-		printk("qla1280: Failed to reserve i/o region 0x%04lx-0x%04lx"
-		       " already in use\n",
-		       host->io_port, host->io_port + 0xff);
-		goto error_free_irq;
-	}
-#endif
-
-	/* load the F/W, read paramaters, and init the H/W */
-	if (qla1280_initialize_adapter(ha)) {
-		printk(KERN_INFO "qla1x160: Failed to initialize adapter\n");
-		goto error_release_region;
-	}
-
-	/* set our host ID  (need to do something about our two IDs) */
-	host->this_id = ha->bus_settings[0].id;
-
-	return host;
-
- error_release_region:
-#if !MEMORY_MAPPED_IO
-	release_region(host->io_port, 0xff);
- error_free_irq:
-#endif
-	free_irq(host->irq, ha);
- error_iounmap:
-#if MEMORY_MAPPED_IO
-	if (ha->mmpbase)
-		iounmap((void *)(((unsigned long) ha->mmpbase) & PAGE_MASK));
-#endif
- error_mem_alloced:
-	qla1280_mem_free(ha);
- error_scsi_unregister:
-	scsi_unregister(host);
- error:
-	return NULL;
-}
-
-/**************************************************************************
- * qla1280_detect
- *    This routine will probe for Qlogic 1280 SCSI host adapters.
- *    It returns the number of host adapters of a particular
- *    type that were found.	 It also initialize all data necessary for
- *    the driver.  It is passed-in the host number, so that it
- *    knows where its first entry is in the scsi_hosts[] array.
- *
- * Input:
- *     template - pointer to SCSI template
- *
- * Returns:
- *  num - number of host adapters found.
- **************************************************************************/
-static int
-qla1280_detect(Scsi_Host_Template * template)
-{
-	struct pci_dev *pdev = NULL;
-	struct Scsi_Host *host;
-	struct scsi_qla_host *ha, *cur_ha;
-	struct qla_boards *bdp;
-	uint16_t subsys_vendor, subsys_device;
-	int num_hosts = 0;
-	int devnum = 0;
-
-	ENTER("qla1280_detect");
-
-	if (sizeof(struct srb) > sizeof(Scsi_Pointer)) {
-		printk(KERN_WARNING
-		       "qla1280_detect: [WARNING] struct srb too big\n");
-		return 0;
-	}
-#ifdef MODULE
-	/*
-	 * If we are called as a module, the qla1280 pointer may not be null
-	 * and it would point to our bootup string, just like on the lilo
-	 * command line.  IF not NULL, then process this config string with
-	 * qla1280_setup
-	 *
-	 * Boot time Options
-	 * To add options at boot time add a line to your lilo.conf file like:
-	 * append="qla1280=verbose,max_tags:{{255,255,255,255},{255,255,255,255}}"
-	 * which will result in the first four devices on the first two
-	 * controllers being set to a tagged queue depth of 32.
-	 */
-	if (qla1280)
-		qla1280_setup(qla1280);
-#endif
-
-	bdp = &ql1280_board_tbl[0];
-	qla1280_hostlist = NULL;
-	template->proc_name = "qla1280";
-
-	/* First Initialize QLA12160 on PCI Bus 1 Dev 2 */
-	while ((pdev = pci_find_subsys(PCI_VENDOR_ID_QLOGIC, bdp->device_id,
-				       PCI_ANY_ID, PCI_ANY_ID, pdev))) {
-
-		/* find QLA12160 device on PCI bus=1 slot=2 */
-		if ((pdev->bus->number != 1) || (PCI_SLOT(pdev->devfn) != 2))
-			continue;
-
-		/* Bypass all AMI SUBSYS VENDOR IDs */
-		if (pdev->subsystem_vendor == PCI_VENDOR_ID_AMI) {
-			printk(KERN_INFO
-			       "qla1x160: Skip AMI SubSys Vendor ID Chip\n");
-			continue;
-		}
-
-		if (pci_enable_device(pdev))
-			goto find_devices;
-
-		host = qla1280_do_device_init(pdev, template, devnum,
-					      bdp, num_hosts);
-		if (!host)
-			continue;
-		ha = (struct scsi_qla_host *)host->hostdata;
-
-		/* this preferred device will always be the first one found */
-		cur_ha = qla1280_hostlist = ha;
-		num_hosts++;
-	}
-
- find_devices:
-
-	pdev = NULL;
-	/* Try and find each different type of adapter we support */
-	for (devnum = 0; bdp->device_id != 0 && devnum < NUM_OF_ISP_DEVICES;
-	     devnum++, bdp++) {
-		/* PCI_SUBSYSTEM_IDS supported */
-		while ((pdev = pci_find_subsys(PCI_VENDOR_ID_QLOGIC,
-					       bdp->device_id, PCI_ANY_ID,
-					       PCI_ANY_ID, pdev))) {
-			if (pci_enable_device(pdev))
-				continue;
-			/* found an adapter */
-			subsys_vendor = pdev->subsystem_vendor;
-			subsys_device = pdev->subsystem_device;
-
-			/*
-			 * skip QLA12160 already initialized on
-			 * PCI Bus 1 Dev 2 since we already initialized
-			 * and presented it
-			 */
-			if ((bdp->device_id == PCI_DEVICE_ID_QLOGIC_ISP12160)&&
-			    (pdev->bus->number == 1) &&
-			    (PCI_SLOT(pdev->devfn) == 2))
-				continue;
-
-			/* Bypass all AMI SUBSYS VENDOR IDs */
-			if (subsys_vendor == PCI_VENDOR_ID_AMI) {
-				printk(KERN_INFO
-				       "qla1x160: Skip AMI SubSys Vendor ID Chip\n");
-				continue;
-			}
-			dprintk(1, "qla1x160: Supported Device Found VID=%x "
-			       "DID=%x SSVID=%x SSDID=%x\n", pdev->vendor,
-			       pdev->device, subsys_vendor, subsys_device);
-
-			host = qla1280_do_device_init(pdev, template,
-						      devnum, bdp, num_hosts);
-			if (!host)
-				continue;
-			ha = (struct scsi_qla_host *)host->hostdata;
-
-			if (qla1280_hostlist == NULL) {
-				cur_ha = qla1280_hostlist = ha;
-			} else {
-				cur_ha = qla1280_hostlist;
-				while (cur_ha->next != NULL)
-					cur_ha = cur_ha->next;
-				cur_ha->next = ha;
-			}
-			num_hosts++;
-		}		/* end of WHILE */
-	}			/* end of FOR */
-
-	LEAVE("qla1280_detect");
-	return num_hosts;
-}
-
-/**************************************************************************
- *   qla1280_release
- *   Free the passed in Scsi_Host memory structures prior to unloading the
- *   module.
- **************************************************************************/
-static int
-qla1280_release(struct Scsi_Host *host)
-{
-	struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata;
-
-	ENTER("qla1280_release");
-
-	if (!ha->flags.online)
-		return 0;
-
-	/* turn-off interrupts on the card */
-	WRT_REG_WORD(&ha->iobase->ictrl, 0);
-
-	/* Detach interrupts */
-	if (host->irq)
-		free_irq(host->irq, ha);
-
-#if MEMORY_MAPPED_IO
-	if (ha->mmpbase)
-		iounmap(ha->mmpbase);
-#else
-	/* release io space registers  */
-	if (host->io_port)
-		release_region(host->io_port, 0xff);
-#endif				/* MEMORY_MAPPED_IO */
-
-	qla1280_mem_free(ha);
-
-	ENTER("qla1280_release");
-	return 0;
-}
-
 /**************************************************************************
  *   qla1280_info
  *     Return a string describing the driver.
@@ -1197,11 +866,11 @@ qla1280_info(struct Scsi_Host *host)
 	ha = (struct scsi_qla_host *)host->hostdata;
 	bdp = &ql1280_board_tbl[ha->devnum];
 	memset(bp, 0, sizeof(qla1280_scsi_name_buffer));
+
 	sprintf (bp,
-		 "QLogic %s PCI to SCSI Host Adapter: bus %d device %d irq %d\n"
+		 "QLogic %s PCI to SCSI Host Adapter\n"
 		 "       Firmware version: %2d.%02d.%02d, Driver version %s",
-		 &bdp->name[0], ha->pci_bus, (ha->pci_device_fn & 0xf8) >> 3,
-		 host->irq, bdp->fwver[0], bdp->fwver[1], bdp->fwver[2],
+		 &bdp->name[0], bdp->fwver[0], bdp->fwver[1], bdp->fwver[2],
 		 QLA1280_VERSION);
 	return bp;
 }
@@ -1218,39 +887,30 @@ qla1280_info(struct Scsi_Host *host)
  * context which is a big NO! NO!.
  **************************************************************************/
 static int
-qla1280_queuecommand(Scsi_Cmnd * cmd, void (*fn) (Scsi_Cmnd *))
+qla1280_queuecommand(struct scsi_cmnd *cmd, void (*fn)(struct scsi_cmnd *))
 {
-	struct scsi_qla_host *ha;
-	struct srb *sp;
-	struct Scsi_Host *host;
-	int bus, target, lun;
+	struct Scsi_Host *host = cmd->device->host;
+	struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata;
+	struct srb *sp = (struct srb *)&cmd->SCp;
 	int status;
 
-	/*ENTER("qla1280_queuecommand");
-	 */
-	dprintk(2, "qla1280_queuecommand(): jiffies %li\n", jiffies);
-
-	host = CMD_HOST(cmd);
-	ha = (struct scsi_qla_host *)host->hostdata;
-
-	/* send command to adapter */
-	sp = (struct srb *)CMD_SP(cmd);
-	sp->cmd = cmd;
 	cmd->scsi_done = fn;
+	sp->cmd = cmd;
 	sp->flags = 0;
 
 	qla1280_print_scsi_cmd(5, cmd);
 
-	/* Generate LU queue on bus, target, LUN */
-	bus = SCSI_BUS_32(cmd);
-	target = SCSI_TCN_32(cmd);
-	lun = SCSI_LUN_32(cmd);
-	if (ha->flags.enable_64bit_addressing)
-		status = qla1280_64bit_start_scsi(ha, sp);
-	else
-		status = qla1280_32bit_start_scsi(ha, sp);
-
-	/*LEAVE("qla1280_queuecommand"); */
+#ifdef QLA_64BIT_PTR
+	/*
+	 * Using 64 bit commands if the PCI bridge doesn't support it is a
+	 * bit wasteful, however this should really only happen if one's
+	 * PCI controller is completely broken, like the BCM1250. For
+	 * sane hardware this is not an issue.
+	 */
+	status = qla1280_64bit_start_scsi(ha, sp);
+#else
+	status = qla1280_32bit_start_scsi(ha, sp);
+#endif
 	return status;
 }
 
@@ -1305,7 +965,7 @@ static void qla1280_mailbox_timeout(unsi
  *      the SCSI bus reset line.
  **************************************************************************/
 static int
-qla1280_error_action(Scsi_Cmnd * cmd, enum action action)
+qla1280_error_action(struct scsi_cmnd *cmd, enum action action)
 {
 	struct scsi_qla_host *ha;
 	int bus, target, lun;
@@ -1350,7 +1010,7 @@ qla1280_error_action(Scsi_Cmnd * cmd, en
 	 * grabs the lock. /Jes
 	 */
 	if (data & RISC_INT)
-		qla1280_isr(ha, &ha->done_q_first, &ha->done_q_last);
+		qla1280_isr(ha, &ha->done_q);
 
 	/*
 	 * Determine the suggested action that the mid-level driver wants
@@ -1461,8 +1121,8 @@ qla1280_error_action(Scsi_Cmnd * cmd, en
 		ha->flags.reset_active = 0;
 	}
 
-	if (ha->done_q_first)
-		qla1280_done(ha, &ha->done_q_first, &ha->done_q_last);
+	if (!list_empty(&ha->done_q))
+		qla1280_done(ha);
 	ha->flags.in_reset = 0;
 
 	/* If we didn't manage to issue the action, or we have no
@@ -1547,22 +1207,11 @@ qla1280_eh_adapter_reset(struct scsi_cmn
 	return qla1280_error_action(cmd, ADAPTER_RESET);
 }
 
-/**************************************************************************
- * qla1280_biosparam
- *   Return the disk geometry for the given SCSI device.
- **************************************************************************/
 static int
-#if LINUX_VERSION_CODE < 0x020545
-qla1280_biosparam(Disk * disk, kdev_t dev, int geom[])
-#else
 qla1280_biosparam(struct scsi_device *sdev, struct block_device *bdev,
 		  sector_t capacity, int geom[])
-#endif
 {
 	int heads, sectors, cylinders;
-#if LINUX_VERSION_CODE < 0x020545
-	unsigned long capacity = disk->capacity;
-#endif
 
 	heads = 64;
 	sectors = 32;
@@ -1582,11 +1231,118 @@ qla1280_biosparam(struct scsi_device *sd
 	return 0;
 }
 
+#if LINUX_VERSION_CODE < 0x020600
+static int
+qla1280_detect(Scsi_Host_Template *template)
+{
+	struct pci_device_id *id = &qla1280_pci_tbl[0];
+	struct pci_dev *pdev = NULL;
+	int num_hosts = 0;
+
+	if (sizeof(struct srb) > sizeof(Scsi_Pointer)) {
+		printk(KERN_WARNING
+		       "qla1280: struct srb too big, aborting\n");
+		return 0;
+	}
+
+	if ((DMA_BIDIRECTIONAL != PCI_DMA_BIDIRECTIONAL) ||
+	    (DMA_TO_DEVICE != PCI_DMA_TODEVICE) ||
+	    (DMA_FROM_DEVICE != PCI_DMA_FROMDEVICE) ||
+	    (DMA_NONE != PCI_DMA_NONE)) {
+		printk(KERN_WARNING
+		       "qla1280: dma direction bits don't match\n");
+		return 0;
+	}
+
+#ifdef MODULE
+	/*
+	 * If we are called as a module, the qla1280 pointer may not be null
+	 * and it would point to our bootup string, just like on the lilo
+	 * command line.  IF not NULL, then process this config string with
+	 * qla1280_setup
+	 *
+	 * Boot time Options
+	 * To add options at boot time add a line to your lilo.conf file like:
+	 * append="qla1280=verbose,max_tags:{{255,255,255,255},{255,255,255,255}}"
+	 * which will result in the first four devices on the first two
+	 * controllers being set to a tagged queue depth of 32.
+	 */
+	if (qla1280)
+		qla1280_setup(qla1280);
+#endif
+
+	/* First Initialize QLA12160 on PCI Bus 1 Dev 2 */
+	while ((pdev = pci_find_device(id->vendor, id->device, pdev))) {
+		if (pdev->bus->number == 1 && PCI_SLOT(pdev->devfn) == 2) {
+			if (!qla1280_probe_one(pdev, id))
+				num_hosts++;
+		}
+	}
+
+	pdev = NULL;
+	/* Try and find each different type of adapter we support */
+	for (id = &qla1280_pci_tbl[0]; id->device; id++) {
+		while ((pdev = pci_find_device(id->vendor, id->device, pdev))) {
+			/*
+			 * skip QLA12160 already initialized on
+			 * PCI Bus 1 Dev 2 since we already initialized
+			 * and presented it
+			 */
+			if (id->device == PCI_DEVICE_ID_QLOGIC_ISP12160 &&
+			    pdev->bus->number == 1 &&
+			    PCI_SLOT(pdev->devfn) == 2)
+				continue;
+
+			if (!qla1280_probe_one(pdev, id))
+				num_hosts++;
+		}
+	}
+
+	return num_hosts;
+}
+
+/*
+ * This looks a bit ugly as we could just pass down host to
+ * qla1280_remove_one, but I want to keep qla1280_release purely a wrapper
+ * around pci_driver::remove as used from 2.6 onwards.
+ */
+static int
+qla1280_release(struct Scsi_Host *host)
+{
+	struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata;
+
+	qla1280_remove_one(ha->pdev);
+	return 0;
+}
+
+static int
+qla1280_biosparam_old(Disk * disk, kdev_t dev, int geom[])
+{
+	return qla1280_biosparam(disk->device, NULL, disk->capacity, geom);
+}
+
+static int
+qla1280_proc_info_old(char *buffer, char **start, off_t offset, int length,
+		      int hostno, int inout)
+{
+	struct Scsi_Host *host;
+
+	for (host = scsi_hostlist; host; host = host->next) {
+		if (host->host_no == hostno) {
+			return qla1280_proc_info(host, buffer, start,
+						 offset, length, inout);
+		}
+	}
+
+	return -ESRCH;
+}
+#endif
+
 /**************************************************************************
  * qla1280_intr_handler
  *   Handles the H/W interrupt
  **************************************************************************/
-irqreturn_t
+static irqreturn_t
 qla1280_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct scsi_qla_host *ha;
@@ -1606,12 +1362,12 @@ qla1280_intr_handler(int irq, void *dev_
 
 	data = qla1280_debounce_register(&reg->istatus);
 	/* Check for pending interrupts. */
-	if (data & RISC_INT) {
-		qla1280_isr(ha, &ha->done_q_first, &ha->done_q_last);
+	if (data & RISC_INT) {	
+		qla1280_isr(ha, &ha->done_q);
 		handled = 1;
 	}
-	if (ha->done_q_first)
-		qla1280_done(ha, &ha->done_q_first, &ha->done_q_last);
+	if (!list_empty(&ha->done_q))
+		qla1280_done(ha);
 
 	spin_unlock(HOST_LOCK);
 
@@ -1624,7 +1380,7 @@ qla1280_intr_handler(int irq, void *dev_
 
 
 static int
-qla12160_set_target_parameters(struct scsi_qla_host *ha, int bus, int target)
+qla1280_set_target_parameters(struct scsi_qla_host *ha, int bus, int target)
 {
 	uint8_t mr;
 	uint16_t mb[MAILBOX_REGISTER_COUNT];
@@ -1633,8 +1389,8 @@ qla12160_set_target_parameters(struct sc
 
 	nv = &ha->nvram;
 
-	if (ha->device_id == PCI_DEVICE_ID_QLOGIC_ISP12160 ||
-	    ha->device_id == PCI_DEVICE_ID_QLOGIC_ISP10160)
+	if (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP12160 ||
+	    ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP10160)
 		is1x160 = 1;
 	else
 		is1x160 = 0;
@@ -1683,7 +1439,7 @@ qla12160_set_target_parameters(struct sc
  *   default queue depth (dependent on the number of hardware SCBs).
  **************************************************************************/
 static int
-qla1280_slave_configure(Scsi_Device *device)
+qla1280_slave_configure(struct scsi_device *device)
 {
 	struct scsi_qla_host *ha;
 	int default_depth = 3;
@@ -1721,8 +1477,8 @@ qla1280_slave_configure(Scsi_Device *dev
 	    (driver_setup.wide_mask &&
 	     (~driver_setup.wide_mask & (1 << target))))
 		nv->bus[bus].target[target].parameter.f.enable_wide = 0;
-	if (ha->device_id == PCI_DEVICE_ID_QLOGIC_ISP12160 ||
-	    ha->device_id == PCI_DEVICE_ID_QLOGIC_ISP10160) {
+	if (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP12160 ||
+	    ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP10160) {
 		if (driver_setup.no_ppr ||
 		    (driver_setup.ppr_mask &&
 		     (~driver_setup.ppr_mask & (1 << target))))
@@ -1730,11 +1486,9 @@ qla1280_slave_configure(Scsi_Device *dev
 	}
 
 	spin_lock_irqsave(HOST_LOCK, flags);
-	if (nv->bus[bus].target[target].parameter.f.enable_sync) {
-		status = qla12160_set_target_parameters(ha, bus, target);
-	}
-
-	qla12160_get_target_parameters(ha, device);
+	if (nv->bus[bus].target[target].parameter.f.enable_sync)
+		status = qla1280_set_target_parameters(ha, bus, target);
+	qla1280_get_target_parameters(ha, device);
 	spin_unlock_irqrestore(HOST_LOCK, flags);
 	return status;
 }
@@ -1748,55 +1502,47 @@ qla1280_slave_configure(Scsi_Device *dev
  *   support tagged queueing.
  **************************************************************************/
 static void
-qla1280_select_queue_depth(struct Scsi_Host *host, Scsi_Device *scsi_devs)
+qla1280_select_queue_depth(struct Scsi_Host *host, struct scsi_device *sdev_q)
 {
-	Scsi_Device *device;
 	struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata;
+	struct scsi_device *sdev;
 
 	ENTER("qla1280_select_queue_depth");
-	for (device = scsi_devs; device != NULL; device = device->next) {
-		if (device->host == host)
-			qla1280_slave_configure(device);
-	}
-
-	if (scsi_devs)
-		qla1280_check_for_dead_scsi_bus(ha, scsi_devs->channel);
+	for (sdev = sdev_q; sdev; sdev = sdev->next)
+		if (sdev->host == host)
+			qla1280_slave_configure(sdev);
 
+	if (sdev_q)
+		qla1280_check_for_dead_scsi_bus(ha, sdev_q->channel);
 	LEAVE("qla1280_select_queue_depth");
 }
 #endif
 
 /*
- * Driver Support Routines
- */
-
-/*
  * qla1280_done
  *      Process completed commands.
  *
  * Input:
  *      ha           = adapter block pointer.
- *      done_q_first = done queue first pointer.
- *      done_q_last  = done queue last pointer.
+ *      done_q       = done queue.
  */
 static void
-qla1280_done(struct scsi_qla_host *ha, struct srb ** done_q_first,
-	     struct srb ** done_q_last)
+qla1280_done(struct scsi_qla_host *ha)
 {
 	struct srb *sp;
+	struct list_head *done_q;
 	int bus, target, lun;
-	Scsi_Cmnd *cmd;
+	struct scsi_cmnd *cmd;
 
 	ENTER("qla1280_done");
 
-	while (*done_q_first != NULL) {
-		/* remove command from done list */
-		sp = *done_q_first;
-		if (!(*done_q_first = sp->s_next))
-			*done_q_last = NULL;
-		else
-			(*done_q_first)->s_prev = NULL;
+	done_q = &ha->done_q;
 
+	while (!list_empty(done_q)) {
+		sp = list_entry(done_q->next, struct srb, list);
+
+		list_del(&sp->list);
+	
 		cmd = sp->cmd;
 		bus = SCSI_BUS_32(cmd);
 		target = SCSI_TCN_32(cmd);
@@ -1822,15 +1568,13 @@ qla1280_done(struct scsi_qla_host *ha, s
 			dprintk(3, "S/G unmap_sg cmd=%p\n", cmd);
 
 			pci_unmap_sg(ha->pdev, cmd->request_buffer,
-				     cmd->use_sg,
-				     scsi_to_pci_dma_dir(cmd->sc_data_direction));
+				     cmd->use_sg, cmd->sc_data_direction);
 		} else if (cmd->request_bufflen) {
 			/*dprintk(1, "No S/G unmap_single cmd=%x saved_dma_handle=%lx\n",
 			  cmd, sp->saved_dma_handle); */
 
 			pci_unmap_page(ha->pdev, sp->saved_dma_handle,
-				       cmd->request_bufflen,
-				       scsi_to_pci_dma_dir(cmd->sc_data_direction));
+				       cmd->request_bufflen, cmd->sc_data_direction);
 		}
 
 		/* Call the mid-level driver interrupt handler */
@@ -1845,7 +1589,6 @@ qla1280_done(struct scsi_qla_host *ha, s
 
 		if(sp->wait != NULL)
 			complete(sp->wait);
-
 	}
 	LEAVE("qla1280_done");
 }
@@ -1854,9 +1597,13 @@ qla1280_done(struct scsi_qla_host *ha, s
  * Translates a ISP error to a Linux SCSI error
  */
 static int
-qla1280_return_status(struct response * sts, Scsi_Cmnd * cp)
+qla1280_return_status(struct response * sts, struct scsi_cmnd *cp)
 {
 	int host_status = DID_ERROR;
+	uint16_t comp_status = le16_to_cpu(sts->comp_status);
+	uint16_t state_flags = le16_to_cpu(sts->state_flags);
+	uint16_t residual_length = le16_to_cpu(sts->residual_length);
+	uint16_t scsi_status = le16_to_cpu(sts->scsi_status);
 #if DEBUG_QLA1280_INTR
 	static char *reason[] = {
 		"DID_OK",
@@ -1877,26 +1624,27 @@ qla1280_return_status(struct response * 
 #if DEBUG_QLA1280_INTR
 	/*
 	  dprintk(1, "qla1280_return_status: compl status = 0x%04x\n",
-	  sts->comp_status);
+	  comp_status);
 	*/
 #endif
-	switch (sts->comp_status) {
+
+	switch (comp_status) {
 	case CS_COMPLETE:
 		host_status = DID_OK;
 		break;
 
 	case CS_INCOMPLETE:
-		if (!(sts->state_flags & SF_GOT_BUS))
+		if (!(state_flags & SF_GOT_BUS))
 			host_status = DID_NO_CONNECT;
-		else if (!(sts->state_flags & SF_GOT_TARGET))
+		else if (!(state_flags & SF_GOT_TARGET))
 			host_status = DID_BAD_TARGET;
-		else if (!(sts->state_flags & SF_SENT_CDB))
+		else if (!(state_flags & SF_SENT_CDB))
 			host_status = DID_ERROR;
-		else if (!(sts->state_flags & SF_TRANSFERRED_DATA))
+		else if (!(state_flags & SF_TRANSFERRED_DATA))
 			host_status = DID_ERROR;
-		else if (!(sts->state_flags & SF_GOT_STATUS))
+		else if (!(state_flags & SF_GOT_STATUS))
 			host_status = DID_ERROR;
-		else if (!(sts->state_flags & SF_GOT_SENSE))
+		else if (!(state_flags & SF_GOT_SENSE))
 			host_status = DID_ERROR;
 		break;
 
@@ -1913,14 +1661,14 @@ qla1280_return_status(struct response * 
 		break;
 
 	case CS_DATA_OVERRUN:
-		dprintk(2, "Data overrun 0x%x\n", sts->residual_length);
+		dprintk(2, "Data overrun 0x%x\n", residual_length);
 		dprintk(2, "qla1280_isr: response packet data\n");
 		qla1280_dump_buffer(2, (char *)sts, RESPONSE_ENTRY_SIZE);
 		host_status = DID_ERROR;
 		break;
 
 	case CS_DATA_UNDERRUN:
-		if ((cp->request_bufflen - sts->residual_length) <
+		if ((cp->request_bufflen - residual_length) <
 		    cp->underflow) {
 			printk(KERN_WARNING
 			       "scsi: Underflow detected - retrying "
@@ -1935,122 +1683,14 @@ qla1280_return_status(struct response * 
 		break;
 	}
 
-#if DEBUG_QLA1280_INTR
-	dprintk(1, "qla1280 ISP status: host status (%s) scsi status %x\n",
-		reason[host_status], sts->scsi_status);
-#endif
-
-	LEAVE("qla1280_return_status");
-
-	return (sts->scsi_status & 0xff) | (host_status << 16);
-}
-
-/*
- * qla1280_done_q_put
- *      Place SRB command on done queue.
- *
- * Input:
- *      sp           = srb pointer.
- *      done_q_first = done queue first pointer.
- *      done_q_last  = done queue last pointer.
- */
-static void
-qla1280_done_q_put(struct srb * sp, struct srb ** done_q_first,
-		   struct srb ** done_q_last)
-{
-	ENTER("qla1280_put_done_q");
-
-	/* Place block on done queue */
-	sp->s_next = NULL;
-	sp->s_prev = *done_q_last;
-	if (!*done_q_first)
-		*done_q_first = sp;
-	else
-		(*done_q_last)->s_next = sp;
-	*done_q_last = sp;
-
-	LEAVE("qla1280_put_done_q");
-}
-
-
-/*
-* qla1280_mem_alloc
-*      Allocates adapter memory.
-*
-* Returns:
-*      0  = success.
-*      1  = failure.
-*/
-static int
-qla1280_mem_alloc(struct scsi_qla_host *ha)
-{
-	int status = 1;
-	dma_addr_t dma_handle;
-
-	ENTER("qla1280_mem_alloc");
-
-	/* get consistent memory allocated for request and response rings */
-	ha->request_ring = pci_alloc_consistent(ha->pdev,
-						((REQUEST_ENTRY_CNT + 1) *
-						 (sizeof(request_t))),
-						&dma_handle);
-	if (!ha->request_ring)
-		goto error;
-	ha->request_dma = dma_handle;
-	ha->response_ring = pci_alloc_consistent(ha->pdev,
-						 ((RESPONSE_ENTRY_CNT + 1) *
-						  (sizeof(struct response))),
-						 &dma_handle);
-	if (!ha->response_ring)
-		goto error;
-	ha->response_dma = dma_handle;
-	status = 0;
-	goto finish;
-
- error:
-	if (status)
-		dprintk(2, "qla1280_mem_alloc: **** FAILED ****\n");
-
-	if (ha->request_ring)
-		pci_free_consistent(ha->pdev,
-                                    ((REQUEST_ENTRY_CNT + 1) *
-				     (sizeof(request_t))),
-                                    ha->request_ring, ha->request_dma);
- finish:
-	LEAVE("qla1280_mem_alloc");
-	return status;
-}
-
-/*
- * qla1280_mem_free
- *      Frees adapter allocated memory.
- *
- * Input:
- *      ha = adapter block pointer.
- */
-static void
-qla1280_mem_free(struct scsi_qla_host *ha)
-{
-	ENTER("qlc1280_mem_free");
-	/* free consistent memory allocated for request and response rings */
-	if (ha->request_ring)
-		pci_free_consistent(ha->pdev,
-				    ((REQUEST_ENTRY_CNT + 1) *
-				     (sizeof(request_t))),
-				    ha->request_ring, ha->request_dma);
-
-	if (ha->response_ring)
-		pci_free_consistent(ha->pdev,
-				    ((RESPONSE_ENTRY_CNT + 1) *
-				     (sizeof(struct response))),
-				    ha->response_ring, ha->response_dma);
-
-	if (qla1280_buffer) {
-		free_page((unsigned long) qla1280_buffer);
-		qla1280_buffer = NULL;
-	}
-
-	LEAVE("qlc1280_mem_free");
+#if DEBUG_QLA1280_INTR
+	dprintk(1, "qla1280 ISP status: host status (%s) scsi status %x\n",
+		reason[host_status], scsi_status);
+#endif
+
+	LEAVE("qla1280_return_status");
+
+	return (scsi_status & 0xff) | (host_status << 16);
 }
 
 /****************************************************************************/
@@ -2058,14 +1698,14 @@ qla1280_mem_free(struct scsi_qla_host *h
 /****************************************************************************/
 
  /*
-    * qla2100_enable_intrs
-    * qla2100_disable_intrs
-    *
-    * Input:
-    *      ha = adapter block pointer.
-    *
-    * Returns:
-    *      None
+  * qla2100_enable_intrs
+  * qla2100_disable_intrs
+  *
+  * Input:
+  *      ha = adapter block pointer.
+  *
+  * Returns:
+  *      None
   */
 static inline void
 qla1280_enable_intrs(struct scsi_qla_host *ha)
@@ -2101,7 +1741,7 @@ qla1280_disable_intrs(struct scsi_qla_ho
  * Returns:
  *      0 = success
  */
-static int
+static int __devinit
 qla1280_initialize_adapter(struct scsi_qla_host *ha)
 {
 	struct device_reg *reg;
@@ -2132,7 +1772,8 @@ qla1280_initialize_adapter(struct scsi_q
 		if ((c = snia_pcibr_rrb_alloc(ha->pdev, &count1, &count2)) < 0)
 			printk(KERN_ERR "scsi(%li): Unable to allocate SN2 "
 			       "virtual DMA channels\n", ha->host_no);
-		ha->flags.use_pci_vchannel = 1;
+		else
+			ha->flags.use_pci_vchannel = 1;
 
 		driver_setup.no_nvram = 1;
 	}
@@ -2164,7 +1805,7 @@ qla1280_initialize_adapter(struct scsi_q
 #endif
 	/* If firmware needs to be loaded */
 	if (qla1280_isp_firmware(ha)) {
-		if (!(status = qla1280_chip_diag (ha))) {
+		if (!(status = qla1280_chip_diag(ha))) {
 			status = qla1280_setup_chip(ha);
 		}
 	} else {
@@ -2288,72 +1929,6 @@ qla1280_isp_firmware(struct scsi_qla_hos
 }
 
 /*
- * PCI configuration
- *      Setup device PCI configuration registers.
- *
- * Input:
- *      ha = adapter block pointer.
- *
- * Returns:
- *      0 = success.
- */
-static int
-qla1280_pci_config(struct scsi_qla_host *ha)
-{
-#if MEMORY_MAPPED_IO
-	unsigned long base;
-	int size;
-#endif
-	uint16_t buf_wd;
-	int status = 1;
-
-	ENTER("qla1280_pci_config");
-
-	pci_set_master(ha->pdev);
-	/*
-	 * Set Bus Master Enable, Memory Address Space Enable and
-	 * reset any error bits, in the command register.
-	 */
-	pci_read_config_word (ha->pdev, PCI_COMMAND, &buf_wd);
-#if MEMORY_MAPPED_IO
-	buf_wd |= PCI_COMMAND_MEMORY;
-#endif
-	buf_wd |= PCI_COMMAND_IO;
-	pci_write_config_word (ha->pdev, PCI_COMMAND, buf_wd);
-	/*
-	 * Reset expansion ROM address decode enable.
-	 */
-	pci_read_config_word(ha->pdev, PCI_ROM_ADDRESS, &buf_wd);
-	buf_wd &= ~PCI_ROM_ADDRESS_ENABLE;
-	pci_write_config_word (ha->pdev, PCI_ROM_ADDRESS, buf_wd);
-
-	ha->host->io_port = pci_resource_start(ha->pdev, 0);
-	ha->host->io_port &= PCI_BASE_ADDRESS_IO_MASK;
-	ha->iobase = (struct device_reg *) ha->host->io_port;
-
-#if MEMORY_MAPPED_IO
-	/*
-	 * Find proper memory chunk for memory map I/O reg.
-	 */
-	base = pci_resource_start(ha->pdev, 1);
-	size = pci_resource_len(ha->pdev, 1);
-	/*
-	 * Get virtual address for I/O registers.
-	 */
-	ha->mmpbase = ioremap(base, size);
-	if (ha->mmpbase) {
-		ha->iobase = (struct device_reg *)ha->mmpbase;
-		status = 0;
-	}
-#else				/* MEMORY_MAPPED_IO */
-	status = 0;
-#endif				/* MEMORY_MAPPED_IO */
-
-	LEAVE("qla1280_pci_config");
-	return status;
-}
-
-/*
  * Chip diagnostics
  *      Test chip for proper operation.
  *
@@ -2724,8 +2299,8 @@ qla1280_nvram_config(struct scsi_qla_hos
 
 	ENTER("qla1280_nvram_config");
 
-	if (ha->device_id == PCI_DEVICE_ID_QLOGIC_ISP12160 ||
-	    ha->device_id == PCI_DEVICE_ID_QLOGIC_ISP10160)
+	if (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP12160 ||
+	    ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP10160)
 		is1x160 = 1;
 	else
 		is1x160 = 0;
@@ -2866,23 +2441,6 @@ qla1280_nvram_config(struct scsi_qla_hos
 	ha->flags.disable_risc_code_load =
 		nv->cntr_flags_1.disable_loading_risc_code;
 
-#ifdef QLA_64BIT_PTR
-	/* Enable 64bit addressing for OS/System combination supporting it   */
-	/* actual NVRAM bit is: nv->cntr_flags_1.enable_64bit_addressing     */
-	/* but we will ignore it and use BITS_PER_LONG macro to setup for    */
-	/* 64 or 32 bit access of host memory in all x86/ia-64/Alpha systems */
-	ha->flags.enable_64bit_addressing = 1;
-#else
-	ha->flags.enable_64bit_addressing = 0;
-#endif
-
-	if (ha->flags.enable_64bit_addressing) {
-		dprintk(2, "scsi(%li): 64 Bit PCI Addressing Enabled\n",
-			ha->host_no);
-
-		pci_set_dma_mask(ha->pdev, (dma_addr_t) ~ 0ULL);
-	}
-
 	/* Set ISP hardware DMA burst */
 	mb[0] = nv->isp_config.c;
 	/* Enable DMA arbitration on dual channel controllers */
@@ -3196,8 +2754,7 @@ qla1280_mailbox_command(struct scsi_qla_
 {
 	struct device_reg *reg = ha->iobase;
 #if 0
-	struct srb *done_q_first = 0;
-	struct srb *done_q_last = 0;
+	LIST_HEAD(done_q);
 #endif
 	int status = 0;
 	int cnt;
@@ -3208,8 +2765,6 @@ qla1280_mailbox_command(struct scsi_qla_
 
 	ENTER("qla1280_mailbox_command");
 
-	ha->flags.mbox_busy = 1;
-
 	if (ha->mailbox_wait) {
 		printk(KERN_ERR "Warning mailbox wait already in use!\n");
 	}
@@ -3233,7 +2788,6 @@ qla1280_mailbox_command(struct scsi_qla_
 	}
 
 	/* Issue set host interrupt command. */
-	ha->flags.mbox_busy = 0;
 
 	/* set up a timer just in case we're really jammed */
 	init_timer(&timer);
@@ -3276,15 +2830,15 @@ qla1280_mailbox_command(struct scsi_qla_
 
 #if 0
 	/* Go check for any response interrupts pending. */
-	qla1280_isr(ha, &done_q_first, &done_q_last);
+	qla1280_isr(ha, &done_q);
 #endif
 
 	if (ha->flags.reset_marker)
 		qla1280_rst_aen(ha);
 
 #if 0
-	if (done_q_first)
-		qla1280_done (ha, &done_q_first, &done_q_last);
+	if (!list_empty(&done_q))
+		qla1280_done(ha, &done_q);
 #endif
 
 	if (status)
@@ -3307,23 +2861,22 @@ qla1280_poll(struct scsi_qla_host *ha)
 {
 	struct device_reg *reg = ha->iobase;
 	uint16_t data;
-	struct srb *done_q_first = 0;
-	struct srb *done_q_last = 0;
+	LIST_HEAD(done_q);
 
 	/* ENTER("qla1280_poll"); */
 
 	/* Check for pending interrupts. */
 	data = RD_REG_WORD(&reg->istatus);
 	if (data & RISC_INT)
-		qla1280_isr(ha, &done_q_first, &done_q_last);
+		qla1280_isr(ha, &done_q);
 
-	if (!ha->flags.mbox_busy) {
+	if (!ha->mailbox_wait) {
 		if (ha->flags.reset_marker)
 			qla1280_rst_aen(ha);
 	}
 
-	if (done_q_first)
-		qla1280_done(ha, &done_q_first, &done_q_last);
+	if (!list_empty(&done_q))
+		qla1280_done(ha);
 
 	/* LEAVE("qla1280_poll"); */
 }
@@ -3573,7 +3126,7 @@ static int
 qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
 {
 	struct device_reg *reg = ha->iobase;
-	Scsi_Cmnd *cmd = sp->cmd;
+	struct scsi_cmnd *cmd = sp->cmd;
 	cmd_a64_entry_t *pkt;
 	struct scatterlist *sg = NULL;
 	u32 *dword_ptr;
@@ -3582,6 +3135,7 @@ qla1280_64bit_start_scsi(struct scsi_qla
 	int cnt;
 	int req_cnt;
 	u16 seg_cnt;
+	u8 dir;
 
 	ENTER("qla1280_64bit_start_scsi:");
 
@@ -3590,7 +3144,7 @@ qla1280_64bit_start_scsi(struct scsi_qla
 	if (cmd->use_sg) {
 		sg = (struct scatterlist *) cmd->request_buffer;
 		seg_cnt = pci_map_sg(ha->pdev, sg, cmd->use_sg,
-				     scsi_to_pci_dma_dir(cmd->sc_data_direction));
+				     cmd->sc_data_direction);
 
 		if (seg_cnt > 2) {
 			req_cnt += (seg_cnt - 2) / 5;
@@ -3675,8 +3229,8 @@ qla1280_64bit_start_scsi(struct scsi_qla
 	/* dprintk(1, "Build packet for command[0]=0x%x\n",pkt->scsi_cdb[0]); */
 
 	/* Set transfer direction. */
-	sp->dir = qla1280_data_direction(cmd);
-	pkt->control_flags |= cpu_to_le16(sp->dir);
+	dir = qla1280_data_direction(cmd);
+	pkt->control_flags |= cpu_to_le16(dir);
 
 	/* Set total data segment count. */
 	pkt->dseg_count = cpu_to_le16(seg_cnt);
@@ -3780,7 +3334,7 @@ qla1280_64bit_start_scsi(struct scsi_qla
 
 			dma_handle = pci_map_page(ha->pdev, page, off,
 						  cmd->request_bufflen,
-						  scsi_to_pci_dma_dir(cmd->sc_data_direction));
+						  cmd->sc_data_direction);
 
 			/* save dma_handle for pci_unmap_page */
 			sp->saved_dma_handle = dma_handle;
@@ -3791,7 +3345,7 @@ qla1280_64bit_start_scsi(struct scsi_qla
 #endif
 			*dword_ptr++ = cpu_to_le32(pci_dma_lo32(dma_handle));
 			*dword_ptr++ = cpu_to_le32(pci_dma_hi32(dma_handle));
-			*dword_ptr = (uint32_t)cmd->request_bufflen;
+			*dword_ptr = cpu_to_le32(cmd->request_bufflen);
 
 			dprintk(5, "qla1280_64bit_start_scsi: No scatter/"
 				"gather command packet data - b %i, t %i, "
@@ -3801,10 +3355,6 @@ qla1280_64bit_start_scsi(struct scsi_qla
 					    REQUEST_ENTRY_SIZE);
 		}
 	} else {	/* No data transfer */
-		dword_ptr = (uint32_t *)(pkt + 1);
-		*dword_ptr++ = 0;
-		*dword_ptr++ = 0;
-		*dword_ptr = 0;
 		dprintk(5, "qla1280_64bit_start_scsi: No data, command "
 			"packet data - b %i, t %i, l %i \n",
 			SCSI_BUS_32(cmd), SCSI_TCN_32(cmd), SCSI_LUN_32(cmd));
@@ -3835,6 +3385,7 @@ qla1280_64bit_start_scsi(struct scsi_qla
 }
 
 
+#ifndef QLA_64BIT_PTR
 /*
  * qla1280_32bit_start_scsi
  *      The start SCSI is responsible for building request packets on
@@ -3858,7 +3409,7 @@ static int
 qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
 {
 	struct device_reg *reg = ha->iobase;
-	Scsi_Cmnd *cmd = sp->cmd;
+	struct scsi_cmnd *cmd = sp->cmd;
 	struct cmd_entry *pkt;
 	struct scatterlist *sg = NULL;
 	uint32_t *dword_ptr;
@@ -3867,6 +3418,7 @@ qla1280_32bit_start_scsi(struct scsi_qla
 	int req_cnt;
 	uint16_t seg_cnt;
 	dma_addr_t dma_handle;
+	u8 dir;
 
 	ENTER("qla1280_32bit_start_scsi");
 
@@ -3884,7 +3436,7 @@ qla1280_32bit_start_scsi(struct scsi_qla
 		 */
 		sg = (struct scatterlist *) cmd->request_buffer;
 		seg_cnt = pci_map_sg(ha->pdev, sg, cmd->use_sg,
-				     scsi_to_pci_dma_dir(cmd->sc_data_direction));
+				     cmd->sc_data_direction);
 
 		/*
 		 * if greater than four sg entries then we need to allocate
@@ -3975,8 +3527,8 @@ qla1280_32bit_start_scsi(struct scsi_qla
 
 	/*dprintk(1, "Build packet for command[0]=0x%x\n",pkt->scsi_cdb[0]); */
 	/* Set transfer direction. */
-	sp->dir = qla1280_data_direction(cmd);
-	pkt->control_flags |= cpu_to_le16(sp->dir);
+	dir = qla1280_data_direction(cmd);
+	pkt->control_flags |= cpu_to_le16(dir);
 
 	/* Set total data segment count. */
 	pkt->dseg_count = cpu_to_le16(seg_cnt);
@@ -4061,16 +3613,13 @@ qla1280_32bit_start_scsi(struct scsi_qla
 			unsigned long off = (unsigned long)cmd->request_buffer & ~PAGE_MASK;
 			dma_handle = pci_map_page(ha->pdev, page, off,
 						  cmd->request_bufflen,
-						  scsi_to_pci_dma_dir(cmd->sc_data_direction));
+						  cmd->sc_data_direction);
 			sp->saved_dma_handle = dma_handle;
 
 			*dword_ptr++ = cpu_to_le32(pci_dma_lo32(dma_handle));
 			*dword_ptr = cpu_to_le32(cmd->request_bufflen);
 		}
 	} else {	/* No data transfer at all */
-		dword_ptr = (uint32_t *)(pkt + 1);
-		*dword_ptr++ = 0;
-		*dword_ptr = 0;
 		dprintk(5, "qla1280_32bit_start_scsi: No data, command "
 			"packet data - \n");
 		qla1280_dump_buffer(5, (char *)pkt, REQUEST_ENTRY_SIZE);
@@ -4102,6 +3651,7 @@ out:
 
 	return status;
 }
+#endif
 
 /*
  * qla1280_req_pkt
@@ -4207,48 +3757,6 @@ qla1280_isp_cmd(struct scsi_qla_host *ha
 	LEAVE("qla1280_isp_cmd");
 }
 
-#if QL1280_LUN_SUPPORT
-/*
- * qla1280_enable_lun
- *      Issue enable LUN entry IOCB.
- *
- * Input:
- *      ha  = adapter block pointer.
- *      bus = SCSI BUS number.
- *      lun  = LUN number.
- */
-static void
-qla1280_enable_lun(struct scsi_qla_host *ha, int bus, int lun)
-{
-	struct elun_entry *pkt;
-
-	ENTER("qla1280_enable_lun");
-
-	/* Get request packet. */
-	/*
-	  if (pkt = (struct elun_entry *)qla1280_req_pkt(ha))
-	  {
-	  pkt->entry_type = ENABLE_LUN_TYPE;
-	  pkt->lun = cpu_to_le16(bus ? lun | BIT_15 : lun);
-	  pkt->command_count = 32;
-	  pkt->immed_notify_count = 1;
-	  pkt->group_6_length = MAX_CMDSZ;
-	  pkt->group_7_length = MAX_CMDSZ;
-	  pkt->timeout = cpu_to_le16(0x30);
-
-	  qla1280_isp_cmd(ha);
-	  }
-	*/
-	pkt = (struct elun_entry *) 1;
-
-	if (!pkt)
-		dprintk(2, "qla1280_enable_lun: **** FAILED ****\n");
-	else
-		dprintk(3, "qla1280_enable_lun: exiting normally\n");
-}
-#endif
-
-
 /****************************************************************************/
 /*                        Interrupt Service Routine.                        */
 /****************************************************************************/
@@ -4259,12 +3767,10 @@ qla1280_enable_lun(struct scsi_qla_host 
  *
  * Input:
  *      ha           = adapter block pointer.
- *      done_q_first = done queue first pointer.
- *      done_q_last  = done queue last pointer.
+ *      done_q       = done queue.
  ****************************************************************************/
 static void
-qla1280_isr(struct scsi_qla_host *ha, struct srb ** done_q_first,
-	    struct srb ** done_q_last)
+qla1280_isr(struct scsi_qla_host *ha, struct list_head *done_q)
 {
 	struct device_reg *reg = ha->iobase;
 	struct response *pkt;
@@ -4336,13 +3842,7 @@ qla1280_isr(struct scsi_qla_host *ha, st
 					CMD_RESULT(sp->cmd) = 0;
 
 					/* Place block on done queue */
-					sp->s_next = NULL;
-					sp->s_prev = *done_q_last;
-					if (!*done_q_first)
-						*done_q_first = sp;
-					else
-						(*done_q_last)->s_next = sp;
-					*done_q_last = sp;
+					list_add_tail(&sp->list, done_q);
 				} else {
 					/*
 					 * If we get here we have a real problem!
@@ -4420,15 +3920,10 @@ qla1280_isr(struct scsi_qla_host *ha, st
 	}
 
 	/*
-	 * Response ring - waiting for the mbox_busy flag here seems
-	 * unnecessary as the mailbox data has been copied to ha->mailbox_out
-	 * by the time we actually get here!
+	 * We will receive interrupts during mailbox testing prior to
+	 * the card being marked online, hence the double check.
 	 */
-	if (!(ha->flags.online
-#if 0
-	    && !ha->flags.mbox_busy
-#endif
-		)) {
+	if (!(ha->flags.online && !ha->mailbox_wait)) {
 		dprintk(2, "qla1280_isr: Response pointer Error\n");
 		goto out;
 	}
@@ -4468,12 +3963,9 @@ qla1280_isr(struct scsi_qla_host *ha, st
 				ha->outstanding_cmds[pkt->handle]->cmd,
 				pkt->handle);
 			if (pkt->entry_type == STATUS_TYPE)
-				qla1280_status_entry(ha, pkt, done_q_first,
-						     done_q_last);
+				qla1280_status_entry(ha, pkt, done_q);
 			else
-				qla1280_error_entry(ha, pkt, done_q_first,
-						    done_q_last);
-
+				qla1280_error_entry(ha, pkt, done_q);
 			/* Adjust ring index. */
 			ha->rsp_ring_index++;
 			if (ha->rsp_ring_index == RESPONSE_ENTRY_CNT) {
@@ -4575,17 +4067,16 @@ qla1280_get_target_options(struct scsi_c
  * Input:
  *      ha           = adapter block pointer.
  *      pkt          = entry pointer.
- *      done_q_first = done queue first pointer.
- *      done_q_last  = done queue last pointer.
+ *      done_q       = done queue.
  */
 static void
 qla1280_status_entry(struct scsi_qla_host *ha, struct response *pkt,
-		     struct srb **done_q_first, struct srb **done_q_last)
+		     struct list_head *done_q)
 {
 	unsigned int bus, target, lun;
 	int sense_sz;
 	struct srb *sp;
-	Scsi_Cmnd *cmd;
+	struct scsi_cmnd *cmd;
 	uint32_t handle = le32_to_cpu(pkt->handle);
 	uint16_t scsi_status = le16_to_cpu(pkt->scsi_status);
 	uint16_t comp_status = le16_to_cpu(pkt->comp_status);
@@ -4637,7 +4128,7 @@ qla1280_status_entry(struct scsi_qla_hos
 					sense_sz = req_sense_length;
 				else
 					/*
-					 * Scsi_Cmnd->sense_buffer is
+					 * scsi_cmnd->sense_buffer is
 					 * 64 bytes, why only copy 63?
 					 * This looks wrong! /Jes
 					 */
@@ -4659,9 +4150,9 @@ qla1280_status_entry(struct scsi_qla_hos
 						    sense_sz);
 		}
 	}
-	/* Place command on done queue. */
-	qla1280_done_q_put(sp, done_q_first, done_q_last);
 
+	/* Place command on done queue. */
+	list_add_tail(&sp->list, done_q);
  out:
 	LEAVE("qla1280_status_entry");
 }
@@ -4673,12 +4164,11 @@ qla1280_status_entry(struct scsi_qla_hos
  * Input:
  *      ha           = adapter block pointer.
  *      pkt          = entry pointer.
- *      done_q_first = done queue first pointer.
- *      done_q_last  = done queue last pointer.
+ *      done_q       = done queue.
  */
 static void
-qla1280_error_entry(struct scsi_qla_host *ha, struct response * pkt,
-		    struct srb ** done_q_first, struct srb ** done_q_last)
+qla1280_error_entry(struct scsi_qla_host *ha, struct response *pkt,
+		    struct list_head *done_q)
 {
 	struct srb *sp;
 	uint32_t handle = le32_to_cpu(pkt->handle);
@@ -4715,8 +4205,9 @@ qla1280_error_entry(struct scsi_qla_host
 			/* Set error status. */
 			CMD_RESULT(sp->cmd) = DID_ERROR << 16;
 		}
+
 		/* Place command on done queue. */
-		qla1280_done_q_put(sp, done_q_first, done_q_last);
+		list_add_tail(&sp->list, done_q);
 	}
 #ifdef QLA_64BIT_PTR
 	else if (pkt->entry_type == COMMAND_A64_TYPE) {
@@ -4760,7 +4251,7 @@ qla1280_abort_isp(struct scsi_qla_host *
 		       ha->host_no);
 		/* Dequeue all commands in outstanding command list. */
 		for (cnt = 0; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
-			Scsi_Cmnd *cmd;
+			struct scsi_cmnd *cmd;
 			sp = ha->outstanding_cmds[cnt];
 			if (sp) {
 
@@ -4894,7 +4385,8 @@ qla1280_check_for_dead_scsi_bus(struct s
 }
 
 static void
-qla12160_get_target_parameters(struct scsi_qla_host *ha, Scsi_Device *device)
+qla1280_get_target_parameters(struct scsi_qla_host *ha,
+			      struct scsi_device *device)
 {
 	uint16_t mb[MAILBOX_REGISTER_COUNT];
 	int bus, target, lun;
@@ -4959,7 +4451,7 @@ __qla1280_dump_buffer(char *b, int size)
  *
  **************************************************************************/
 static void
-__qla1280_print_scsi_cmd(Scsi_Cmnd * cmd)
+__qla1280_print_scsi_cmd(struct scsi_cmnd *cmd)
 {
 	struct scsi_qla_host *ha;
 	struct Scsi_Host *host = CMD_HOST(cmd);
@@ -4987,11 +4479,11 @@ __qla1280_print_scsi_cmd(Scsi_Cmnd * cmd
 	   printk("  SG buffer: \n");
 	   qla1280_dump_buffer(1, (char *)sg, (cmd->use_sg*sizeof(struct scatterlist)));
 	   } */
-	printk("  tag=%d, flags=0x%x, transfersize=0x%x \n",
-	       cmd->tag, cmd->flags, cmd->transfersize);
+	printk("  tag=%d, transfersize=0x%x \n",
+	       cmd->tag, cmd->transfersize);
 	printk("  Pid=%li, SP=0x%p\n", cmd->pid, CMD_SP(cmd));
 	printk(" underflow size = 0x%x, direction=0x%x\n",
-	       cmd->underflow, sp->dir);
+	       cmd->underflow, cmd->sc_data_direction);
 }
 
 /**************************************************************************
@@ -5002,7 +4494,7 @@ static void
 ql1280_dump_device(struct scsi_qla_host *ha)
 {
 
-	Scsi_Cmnd *cp;
+	struct scsi_cmnd *cp;
 	struct srb *sp;
 	int i;
 
@@ -5136,34 +4628,314 @@ qla1280_get_token(char *str)
 	return ret;
 }
 
-
-static Scsi_Host_Template driver_template = {
+#if LINUX_VERSION_CODE >= 0x020600
+static struct scsi_host_template qla1280_driver_template = {
+	.proc_name		= "qla1280",
+	.name			= "Qlogic ISP 1280/12160",
+	.info			= qla1280_info,
+	.slave_configure	= qla1280_slave_configure,
+	.queuecommand		= qla1280_queuecommand,
+	.eh_abort_handler	= qla1280_eh_abort,
+	.eh_device_reset_handler= qla1280_eh_device_reset,
+	.eh_bus_reset_handler	= qla1280_eh_bus_reset,
+	.eh_host_reset_handler	= qla1280_eh_adapter_reset,
+	.bios_param		= qla1280_biosparam,
 	.proc_info		= qla1280_proc_info,
+	.can_queue		= 0xfffff,
+	.this_id		= -1,
+	.sg_tablesize		= SG_ALL,
+	.cmd_per_lun		= 1,
+	.use_clustering		= ENABLE_CLUSTERING,
+};
+#else
+static Scsi_Host_Template qla1280_driver_template = {
+	.proc_name		= "qla1280",
 	.name			= "Qlogic ISP 1280/12160",
 	.detect			= qla1280_detect,
 	.release		= qla1280_release,
 	.info			= qla1280_info,
 	.queuecommand		= qla1280_queuecommand,
-#if LINUX_VERSION_CODE >= 0x020545
-	.slave_configure	= qla1280_slave_configure,
-#endif
 	.eh_abort_handler	= qla1280_eh_abort,
 	.eh_device_reset_handler= qla1280_eh_device_reset,
 	.eh_bus_reset_handler	= qla1280_eh_bus_reset,
 	.eh_host_reset_handler	= qla1280_eh_adapter_reset,
-	.bios_param		= qla1280_biosparam,
-	.can_queue		= 255,
+	.bios_param		= qla1280_biosparam_old,
+	.proc_info		= qla1280_proc_info_old,
+	.can_queue		= 0xfffff,
 	.this_id		= -1,
 	.sg_tablesize		= SG_ALL,
-	.cmd_per_lun		= 3,
+	.cmd_per_lun		= 1,
 	.use_clustering		= ENABLE_CLUSTERING,
-#if LINUX_VERSION_CODE < 0x020545
 	.use_new_eh_code	= 1,
+};
+#endif
+
+static int __devinit
+qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+	int devnum = id->driver_data;
+	struct qla_boards *bdp = &ql1280_board_tbl[devnum];
+	struct Scsi_Host *host;
+	struct scsi_qla_host *ha;
+	int error = -ENODEV;
+
+	/* Bypass all AMI SUBSYS VENDOR IDs */
+	if (pdev->subsystem_vendor == PCI_VENDOR_ID_AMI) {
+		printk(KERN_INFO
+		       "qla1280: Skipping AMI SubSys Vendor ID Chip\n");
+		goto error;
+	}
+
+	printk(KERN_INFO "qla1280: %s found on PCI bus %i, dev %i\n",
+	       bdp->name, pdev->bus->number, PCI_SLOT(pdev->devfn));
+	
+	if (pci_enable_device(pdev)) {
+		printk(KERN_WARNING
+		       "qla1280: Failed to enabled pci device, aborting.\n");
+		goto error;
+	}
+
+	pci_set_master(pdev);
+
+	error = -ENOMEM;
+	host = scsi_host_alloc(&qla1280_driver_template, sizeof(*ha));
+	if (!host) {
+		printk(KERN_WARNING
+		       "qla1280: Failed to register host, aborting.\n");
+		goto error_disable_device;
+	}
+
+	ha = (struct scsi_qla_host *)host->hostdata;
+	memset(ha, 0, sizeof(struct scsi_qla_host));
+
+	ha->pdev = pdev;
+	ha->devnum = devnum;	/* specifies microcode load address */
+
+#ifdef QLA_64BIT_PTR
+	if (pci_set_dma_mask(ha->pdev, (dma_addr_t) ~ 0ULL)) {
+		if (pci_set_dma_mask(ha->pdev, 0xffffffff)) {
+			printk(KERN_WARNING "scsi(%li): Unable to set a "
+			       " suitable DMA mask - aboring\n", ha->host_no);
+			error = -ENODEV;
+			goto error_free_irq;
+		}
+	} else
+		dprintk(2, "scsi(%li): 64 Bit PCI Addressing Enabled\n",
+			ha->host_no);
+#else
+	if (pci_set_dma_mask(ha->pdev, 0xffffffff)) {
+		printk(KERN_WARNING "scsi(%li): Unable to set a "
+		       " suitable DMA mask - aboring\n", ha->host_no);
+		error = -ENODEV;
+		goto error_free_irq;
+	}
+#endif
+
+	ha->request_ring = pci_alloc_consistent(ha->pdev,
+			((REQUEST_ENTRY_CNT + 1) * (sizeof(request_t))),
+			&ha->request_dma);
+	if (!ha->request_ring) {
+		printk(KERN_INFO "qla1280: Failed to get request memory\n");
+		goto error_put_host;
+	}
+
+	ha->response_ring = pci_alloc_consistent(ha->pdev,
+			((RESPONSE_ENTRY_CNT + 1) * (sizeof(struct response))),
+			&ha->response_dma);
+	if (!ha->response_ring) {
+		printk(KERN_INFO "qla1280: Failed to get response memory\n");
+		goto error_free_request_ring;
+	}
+
+	ha->ports = bdp->numPorts;
+
+	ha->host = host;
+	ha->host_no = host->host_no;
+
+	host->irq = pdev->irq;
+	host->max_channel = bdp->numPorts - 1;
+	host->max_lun = MAX_LUNS - 1;
+	host->max_id = MAX_TARGETS;
+	host->max_sectors = 1024;
+	host->unique_id = host->host_no;
+
+#if LINUX_VERSION_CODE < 0x020545
+	host->select_queue_depths = qla1280_select_queue_depth;
+#endif
+
+	error = -ENODEV;
+
+#if MEMORY_MAPPED_IO
+	ha->mmpbase = ioremap(pci_resource_start(ha->pdev, 1),
+			      pci_resource_len(ha->pdev, 1));
+	if (!ha->mmpbase) {
+		printk(KERN_INFO "qla1280: Unable to map I/O memory\n");
+		goto error_free_response_ring;
+	}
+
+	host->base = (unsigned long)ha->mmpbase;
+	ha->iobase = (struct device_reg *)ha->mmpbase;
+#else
+	host->io_port = pci_resource_start(ha->pdev, 0);
+	if (!request_region(host->io_port, 0xff, "qla1280")) {
+		printk(KERN_INFO "qla1280: Failed to reserve i/o region "
+				 "0x%04lx-0x%04lx - already in use\n",
+		       host->io_port, host->io_port + 0xff);
+		goto error_free_response_ring;
+	}
+
+	ha->iobase = (struct device_reg *)host->io_port;
+#endif
+
+	INIT_LIST_HEAD(&ha->done_q);
+
+	/* Disable ISP interrupts. */
+	qla1280_disable_intrs(ha);
+
+	if (request_irq(pdev->irq, qla1280_intr_handler, SA_SHIRQ,
+				"qla1280", ha)) {
+		printk("qla1280 : Failed to reserve interrupt %d already "
+		       "in use\n", pdev->irq);
+		goto error_release_region;
+	}
+
+	/* load the F/W, read paramaters, and init the H/W */
+	if (qla1280_initialize_adapter(ha)) {
+		printk(KERN_INFO "qla1x160: Failed to initialize adapter\n");
+		goto error_free_irq;
+	}
+
+	/* set our host ID  (need to do something about our two IDs) */
+	host->this_id = ha->bus_settings[0].id;
+
+	pci_set_drvdata(pdev, host);
+
+#if LINUX_VERSION_CODE >= 0x020600
+	error = scsi_add_host(host, &pdev->dev);
+	if (error)
+		goto error_disable_adapter;
+	scsi_scan_host(host);
+#else
+	scsi_set_pci_device(host, pdev);
+#endif
+
+	return 0;
+
+#if LINUX_VERSION_CODE >= 0x020600
+ error_disable_adapter:
+	WRT_REG_WORD(&ha->iobase->ictrl, 0);
+#endif
+ error_free_irq:
+	free_irq(pdev->irq, ha);
+ error_release_region:
+#if MEMORY_MAPPED_IO
+	iounmap(ha->mmpbase);
+#else
+	release_region(host->io_port, 0xff);
+#endif
+ error_free_response_ring:
+	pci_free_consistent(ha->pdev,
+			((RESPONSE_ENTRY_CNT + 1) * (sizeof(struct response))),
+			ha->response_ring, ha->response_dma);
+ error_free_request_ring:
+	pci_free_consistent(ha->pdev,
+			((REQUEST_ENTRY_CNT + 1) * (sizeof(request_t))),
+			ha->request_ring, ha->request_dma);
+ error_put_host:
+	scsi_host_put(host);
+ error_disable_device:
+	pci_disable_device(pdev);
+ error:
+	return error;
+}
+
+
+static void __devexit
+qla1280_remove_one(struct pci_dev *pdev)
+{
+	struct Scsi_Host *host = pci_get_drvdata(pdev);
+	struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata;
+
+#if LINUX_VERSION_CODE >= 0x020600
+	scsi_remove_host(host);
+#endif
+
+	WRT_REG_WORD(&ha->iobase->ictrl, 0);
+
+	free_irq(pdev->irq, ha);
+
+#if MEMORY_MAPPED_IO
+	iounmap(ha->mmpbase);
+#else
+	release_region(host->io_port, 0xff);
 #endif
+
+	pci_free_consistent(ha->pdev,
+			((REQUEST_ENTRY_CNT + 1) * (sizeof(request_t))),
+			ha->request_ring, ha->request_dma);
+	pci_free_consistent(ha->pdev,
+			((RESPONSE_ENTRY_CNT + 1) * (sizeof(struct response))),
+			ha->response_ring, ha->response_dma);
+
+	pci_disable_device(pdev);
+
+	scsi_host_put(host);
+}
+
+#if LINUX_VERSION_CODE >= 0x020600
+static struct pci_driver qla1280_pci_driver = {
+	.name		= "qla1280",
+	.id_table	= qla1280_pci_tbl,
+	.probe		= qla1280_probe_one,
+	.remove		= __devexit_p(qla1280_remove_one),
 };
 
-#include "scsi_module.c"
+static int __init
+qla1280_init(void)
+{
+	if (sizeof(struct srb) > sizeof(struct scsi_pointer)) {
+		printk(KERN_WARNING
+		       "qla1280: struct srb too big, aborting\n");
+		return -EINVAL;
+	}
+
+#ifdef MODULE
+	/*
+	 * If we are called as a module, the qla1280 pointer may not be null
+	 * and it would point to our bootup string, just like on the lilo
+	 * command line.  IF not NULL, then process this config string with
+	 * qla1280_setup
+	 *
+	 * Boot time Options
+	 * To add options at boot time add a line to your lilo.conf file like:
+	 * append="qla1280=verbose,max_tags:{{255,255,255,255},{255,255,255,255}}"
+	 * which will result in the first four devices on the first two
+	 * controllers being set to a tagged queue depth of 32.
+	 */
+	if (qla1280)
+		qla1280_setup(qla1280);
+#endif
+
+	return pci_module_init(&qla1280_pci_driver);
+}
+
+static void __exit
+qla1280_exit(void)
+{
+	pci_unregister_driver(&qla1280_pci_driver);
+}
+
+module_init(qla1280_init);
+module_exit(qla1280_exit);
 
+#else
+# define driver_template qla1280_driver_template
+# include "scsi_module.c"
+#endif
+
+MODULE_AUTHOR("Qlogic & Jes Sorensen");
+MODULE_DESCRIPTION("Qlogic ISP SCSI (qla1x80/qla1x160) driver");
+MODULE_LICENSE("GPL");
 
 /*
  * Overrides for Emacs so that we almost follow Linus's tabbing style.
diff -puN drivers/scsi/qla1280.h~linus drivers/scsi/qla1280.h
--- 25/drivers/scsi/qla1280.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/qla1280.h	2004-01-19 22:17:23.000000000 -0800
@@ -17,8 +17,8 @@
 *
 ******************************************************************************/
 
-#ifndef	_IO_HBA_QLA1280_H	/* wrapper symbol for kernel use */
-#define	_IO_HBA_QLA1280_H	/* subject to change without notice */
+#ifndef	_QLA1280_H
+#define	_QLA1280_H
 
 /*
  * Data bit definitions.
@@ -100,55 +100,23 @@
  * on cmd->SCp location of every I/O
  */
 struct srb {
-	Scsi_Cmnd *cmd;		/* (4/8) SCSI command block */
-	struct srb *s_next;	/* (4/8) Next block on LU queue */
-	struct srb *s_prev;	/* (4/8) Previous block on LU queue */
-	uint8_t flags;		/* (1) Status flags. */
-	uint8_t dir;		/* direction of transfer */
-	/*
-	 * This should be moved around to save space.
-	 */
-	dma_addr_t saved_dma_handle;	/* for unmap of single transfers */
+	struct list_head list;		/* (8/16) LU queue */
+	struct scsi_cmnd *cmd;	/* (4/8) SCSI command block */
 	/* NOTE: the sp->cmd will be NULL when this completion is
 	 * called, so you should know the scsi_cmnd when using this */
 	struct completion *wait;
+	dma_addr_t saved_dma_handle;	/* for unmap of single transfers */
+	uint8_t flags;		/* (1) Status flags. */
+	uint8_t dir;		/* direction of transfer */
 };
 
 /*
  * SRB flag definitions
  */
-#define SRB_TIMEOUT		BIT_0	/* Command timed out */
-#define SRB_SENT		BIT_1	/* Command sent to ISP */
-#define SRB_ABORT_PENDING	BIT_2	/* Command abort sent to device */
-#define SRB_ABORTED		BIT_3	/* Command aborted command already */
-
-/*
- * Logical Unit Queue structure
- */
-struct scsi_lu {
-	struct srb *q_first;	/* First block on LU queue */
-	struct srb *q_last;	/* Last block on LU queue */
-	uint8_t q_flag;		/* LU queue state flags */
-	uint8_t q_sense[16];	/* sense data */
-	unsigned long io_cnt;	/* total xfer count */
-	unsigned long resp_time;/* total response time (start - finish) */
-	unsigned long act_time;	/* total actived time (minus queuing time) */
-	unsigned long w_cnt;	/* total writes */
-	unsigned long r_cnt;	/* total reads */
-	uint16_t q_outcnt;	/* Pending jobs for this LU */
-};
-
-/*
- * Logical Unit flags
- */
-#define QLA1280_QBUSY	BIT_0
-#define QLA1280_QWAIT	BIT_1
-#define QLA1280_QSUSP	BIT_2
-#define QLA1280_QSENSE	BIT_3	/* Sense data cache valid */
-#define QLA1280_QRESET	BIT_4
-#define QLA1280_QHBA	BIT_5
-#define QLA1280_BSUSP	BIT_6	/* controller is suspended */
-#define QLA1280_BREM	BIT_7	/* controller is removed */
+#define SRB_TIMEOUT		(1 << 0)	/* Command timed out */
+#define SRB_SENT		(1 << 1)	/* Command sent to ISP */
+#define SRB_ABORT_PENDING	(1 << 2)	/* Command abort sent to device */
+#define SRB_ABORTED		(1 << 3)	/* Command aborted command already */
 
 /*
  *  ISP I/O Register Set structure definitions.
@@ -341,16 +309,19 @@ struct nvram {
 	} cntr_flags_1;		/* 5 */
 
 	struct {
-		uint16_t boot_lun_number:5;
-		uint16_t scsi_bus_number:1;
-		uint16_t unused_6:1;
-		uint16_t unused_7:1;
-		uint16_t boot_target_number:4;
-		uint16_t unused_12:1;
-		uint16_t unused_13:1;
-		uint16_t unused_14:1;
-		uint16_t unused_15:1;
-	} cntr_flags_2;		/* 6, 7 */
+		uint8_t boot_lun_number:5;
+		uint8_t scsi_bus_number:1;
+		uint8_t unused_6:1;
+		uint8_t unused_7:1;
+	} cntr_flags_2l;	/* 7 */
+
+	struct {
+		uint8_t boot_target_number:4;
+		uint8_t unused_12:1;
+		uint8_t unused_13:1;
+		uint8_t unused_14:1;
+		uint8_t unused_15:1;
+	} cntr_flags_2h;	/* 8 */
 
 	uint16_t unused_8;	/* 8, 9 */
 	uint16_t unused_10;	/* 10, 11 */
@@ -1021,11 +992,7 @@ struct scsi_qla_host {
 
 	unsigned char *mmpbase;	/* memory mapped address */
 	unsigned long host_no;
-	unsigned long instance;
 	struct pci_dev *pdev;
-	uint32_t device_id;
-	uint8_t pci_bus;
-	uint8_t pci_device_fn;
 	uint8_t devnum;
 	uint8_t revision;
 	uint8_t ports;
@@ -1040,18 +1007,9 @@ struct scsi_qla_host {
 	/* BUS configuration data */
 	struct bus_param bus_settings[MAX_BUSES];
 
-#if 0
-	/* bottom half run queue */
-	struct tq_struct run_qla_bh;
-#endif
-
 	/* Received ISP mailbox data. */
 	volatile uint16_t mailbox_out[MAILBOX_REGISTER_COUNT];
 
-#ifdef UNUSED
-	struct timer_list dev_timer[MAX_TARGETS];
-#endif
-
 	dma_addr_t request_dma;		/* Physical Address */
 	request_t *request_ring;	/* Base virtual address */
 	request_t *request_ring_ptr;	/* Current address. */
@@ -1063,30 +1021,19 @@ struct scsi_qla_host {
 	struct response *response_ring_ptr;	/* Current address. */
 	uint16_t rsp_ring_index;	/* Current index. */
 
-#if WATCHDOGTIMER
-	/* Watchdog queue, lock and total timer */
-	uint8_t watchdog_q_lock;	/* Lock for watchdog queue */
-	struct srb *wdg_q_first;	/* First job on watchdog queue */
-	struct srb *wdg_q_last;	/* Last job on watchdog queue */
-	uint32_t total_timeout;	/* Total timeout (quantum count) */
-	uint32_t watchdogactive;
-#endif
-
-	struct srb *done_q_first;	/* First job on done queue */
-	struct srb *done_q_last;	/* Last job on done queue */
+	struct list_head done_q;	/* Done queue */
 
 	struct completion *mailbox_wait;
 
 	volatile struct {
-		uint32_t mbox_busy:1;			/* 0 */
-		uint32_t online:1;			/* 1 */
-		uint32_t reset_marker:1;		/* 2 */
-		uint32_t disable_host_adapter:1;	/* 4 */
-		uint32_t reset_active:1;		/* 5 */
-		uint32_t abort_isp_active:1;		/* 6 */
-		uint32_t disable_risc_code_load:1;	/* 7 */
-		uint32_t enable_64bit_addressing:1;	/* 8 */
-		uint32_t in_reset:1;			/* 9 */
+		uint32_t online:1;			/* 0 */
+		uint32_t reset_marker:1;		/* 1 */
+		uint32_t disable_host_adapter:1;	/* 2 */
+		uint32_t reset_active:1;		/* 3 */
+		uint32_t abort_isp_active:1;		/* 4 */
+		uint32_t disable_risc_code_load:1;	/* 5 */
+		uint32_t enable_64bit_addressing:1;	/* 6 */
+		uint32_t in_reset:1;			/* 7 */
 		uint32_t ints_enabled:1;
 		uint32_t ignore_nvram:1;
 #ifdef __ia64__
@@ -1098,10 +1045,4 @@ struct scsi_qla_host {
 	int nvram_valid;
 };
 
-/*
- * Macros to help code, maintain, etc.
- */
-#define SUBDEV(b, t, l)		((b << (MAX_T_BITS + MAX_L_BITS)) | (t << MAX_L_BITS) | l)
-#define LU_Q(ha, b, t, l)	(ha->dev[SUBDEV(b, t, l)])
-
-#endif				/* _IO_HBA_QLA1280_H */
+#endif /* _QLA1280_H */
diff -puN /dev/null drivers/scsi/qla2xxx/Kconfig
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/Kconfig	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,29 @@
+config SCSI_QLA2XXX_CONFIG
+	tristate
+	default (SCSI && PCI)
+	depends on SCSI && PCI
+
+config SCSI_QLA2XXX
+	tristate
+
+config SCSI_QLA21XX
+	tristate "Qlogic ISP2100 host adapter family support"
+	select SCSI_QLA2XXX
+	depends on SCSI_QLA2XXX_CONFIG
+	---help---
+	This driver supports the QLogic 21xx (ISP2100) host adapter family.
+
+config SCSI_QLA22XX
+	tristate "Qlogic ISP2200 host adapter family support"
+	select SCSI_QLA2XXX
+	depends on SCSI_QLA2XXX_CONFIG
+	---help---
+	This driver supports the QLogic 22xx (ISP2200) host adapter family.
+
+config SCSI_QLA23XX
+	tristate "Qlogic ISP23xx host adapter family support"
+	select SCSI_QLA2XXX
+	depends on SCSI_QLA2XXX_CONFIG
+	---help---
+	This driver supports the QLogic 23xx (ISP2300, ISP2312, and ISP2322)
+	host adapter family.
diff -puN /dev/null drivers/scsi/qla2xxx/Makefile
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/Makefile	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,12 @@
+EXTRA_CFLAGS += -g -Idrivers/scsi -DUNIQUE_FW_NAME
+
+qla2xxx-y := qla_os.o qla_init.o qla_mbx.o qla_iocb.o qla_isr.o qla_gs.o \
+		qla_dbg.o qla_sup.o qla_rscn.o
+
+qla2100-y := ql2100.o ql2100_fw.o
+qla2200-y := ql2200.o ql2200_fw.o
+qla2300-y := ql2300.o ql2300_fw.o #ql2322_fw.o
+
+obj-$(CONFIG_SCSI_QLA21XX) += qla2xxx.o qla2100.o
+obj-$(CONFIG_SCSI_QLA22XX) += qla2xxx.o qla2200.o
+obj-$(CONFIG_SCSI_QLA23XX) += qla2xxx.o qla2300.o
diff -puN /dev/null drivers/scsi/qla2xxx/ql2100.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/ql2100.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,92 @@
+/*
+ * QLogic ISP2100 device driver for Linux 2.6.x
+ * Copyright (C) 2003 Christoph Hellwig.
+ * Copyright (C) 2003 QLogic Corporation (www.qlogic.com)
+ *
+ * Released under GPL v2.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+
+#include "qla_os.h"
+#include "qla_def.h"
+
+static char qla_driver_name[] = "qla2100";
+
+extern unsigned char  fw2100tp_version[];
+extern unsigned char  fw2100tp_version_str[];
+extern unsigned short fw2100tp_addr01;
+extern unsigned short fw2100tp_code01[];
+extern unsigned short fw2100tp_length01;
+
+static struct qla_fw_info qla_fw_tbl[] = {
+	{
+		.addressing	= FW_INFO_ADDR_NORMAL,
+		.fwcode		= &fw2100tp_code01[0],
+		.fwlen		= &fw2100tp_length01,
+		.fwstart	= &fw2100tp_addr01,
+	},
+
+	{ FW_INFO_ADDR_NOMORE, },
+};
+
+static struct qla_board_info qla_board_tbl = {
+	.drv_name	= qla_driver_name,
+
+	.isp_name	= "ISP2100",
+	.fw_info	= qla_fw_tbl,
+};
+
+static struct pci_device_id qla2100_pci_tbl[] = {
+	{
+		.vendor		= PCI_VENDOR_ID_QLOGIC,
+		.device		= PCI_DEVICE_ID_QLOGIC_ISP2100,
+		.subvendor	= PCI_ANY_ID,
+		.subdevice	= PCI_ANY_ID,
+		.driver_data	= (unsigned long)&qla_board_tbl,
+	},
+
+	{0, 0},
+};
+MODULE_DEVICE_TABLE(pci, qla2100_pci_tbl);
+
+static int __devinit
+qla2100_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+	return qla2x00_probe_one(pdev,
+	    (struct qla_board_info *)id->driver_data);
+}
+
+static void __devexit
+qla2100_remove_one(struct pci_dev *pdev)
+{
+	qla2x00_remove_one(pdev);
+}
+
+static struct pci_driver qla2100_pci_driver = {
+	.name		= "qla2100",
+	.id_table	= qla2100_pci_tbl,
+	.probe		= qla2100_probe_one,
+	.remove		= __devexit_p(qla2100_remove_one),
+};
+
+static int __init
+qla2100_init(void)
+{
+	return pci_module_init(&qla2100_pci_driver);
+}
+
+static void __exit
+qla2100_exit(void)
+{
+	pci_unregister_driver(&qla2100_pci_driver);
+}
+
+module_init(qla2100_init);
+module_exit(qla2100_exit);
+
+MODULE_AUTHOR("QLogic Corporation");
+MODULE_DESCRIPTION("QLogic ISP21xx FC-SCSI Host Bus Adapter driver");
+MODULE_LICENSE("GPL");
diff -puN /dev/null drivers/scsi/qla2xxx/ql2100_fw.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/ql2100_fw.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,4858 @@
+/******************************************************************************
+ *                  QLOGIC LINUX SOFTWARE
+ *
+ * QLogic ISP2x00 device driver for Linux 2.6.x
+ * Copyright (C) 2003 QLogic Corporation
+ * (www.qlogic.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ *************************************************************************/
+
+/*
+ *	Firmware Version 1.19.24 (14:02 Jul 16, 2002)
+ */
+
+#ifdef UNIQUE_FW_NAME
+unsigned short fw2100tp_version = 1*1024+19;
+#else
+unsigned short risc_code_version = 1*1024+19;
+#endif
+
+#ifdef UNIQUE_FW_NAME
+unsigned char fw2100tp_version_str[] = {1,19,24};
+#else
+unsigned char firmware_version[] = {1,19,24};
+#endif
+
+#ifdef UNIQUE_FW_NAME
+#define fw2100tp_VERSION_STRING "1.19.24"
+#else
+#define FW_VERSION_STRING "1.19.24"
+#endif
+
+#ifdef UNIQUE_FW_NAME
+unsigned short fw2100tp_addr01 = 0x1000 ;
+#else
+unsigned short risc_code_addr01 = 0x1000 ;
+#endif
+
+#ifdef UNIQUE_FW_NAME
+unsigned short fw2100tp_code01[] = { 
+#else
+unsigned short risc_code01[] = { 
+#endif
+	0x0078, 0x102d, 0x0000, 0x95f1, 0x0000, 0x0001, 0x0013, 0x0018,
+	0x0017, 0x2043, 0x4f50, 0x5952, 0x4947, 0x4854, 0x2032, 0x3030,
+	0x3120, 0x514c, 0x4f47, 0x4943, 0x2043, 0x4f52, 0x504f, 0x5241,
+	0x5449, 0x4f4e, 0x2049, 0x5350, 0x3231, 0x3030, 0x2046, 0x6972,
+	0x6d77, 0x6172, 0x6520, 0x2056, 0x6572, 0x7369, 0x6f6e, 0x2030,
+	0x312e, 0x3139, 0x2020, 0x2020, 0x2400, 0x2091, 0x2000, 0x20c1,
+	0x0021, 0x2039, 0xffff, 0x2019, 0xaaaa, 0x2760, 0x2069, 0x7fff,
+	0x20c1, 0x0020, 0x2c2c, 0x2d34, 0x2762, 0x236a, 0x2c24, 0x2d04,
+	0x266a, 0x2562, 0xa406, 0x00c0, 0x1052, 0x20c1, 0x0021, 0x2c2c,
+	0x2362, 0x2c04, 0x2562, 0xa306, 0x0040, 0x1052, 0x20c1, 0x0020,
+	0x2039, 0x8fff, 0x20a1, 0xad00, 0x2708, 0x810d, 0x810d, 0x810d,
+	0x810d, 0xa18c, 0x000f, 0x2001, 0x000a, 0xa112, 0xa00e, 0x21a8,
+	0x41a4, 0x3400, 0x8211, 0x00c0, 0x105f, 0x2708, 0x3400, 0xa102,
+	0x0040, 0x106f, 0x0048, 0x106f, 0x20a8, 0xa00e, 0x41a4, 0x20a1,
+	0xa5f1, 0x2009, 0x0000, 0x20a9, 0x070f, 0x41a4, 0x3400, 0x20c9,
+	0xaaff, 0x2059, 0x0000, 0x2b78, 0x7823, 0x0004, 0x2089, 0x25c7,
+	0x2051, 0xa600, 0x2a70, 0x7762, 0xa786, 0x8fff, 0x0040, 0x1092,
+	0x705f, 0xcd00, 0x705b, 0xccf1, 0x7067, 0x0200, 0x706b, 0x0200,
+	0x0078, 0x109a, 0x705b, 0xbd01, 0x7067, 0x0100, 0x706b, 0x0100,
+	0x705f, 0xbd00, 0x1078, 0x12df, 0x1078, 0x13ca, 0x1078, 0x1577,
+	0x1078, 0x1ce9, 0x1078, 0x42ec, 0x1078, 0x76bf, 0x1078, 0x1355,
+	0x1078, 0x2ac0, 0x1078, 0x4e93, 0x1078, 0x49a3, 0x1078, 0x594a,
+	0x1078, 0x2263, 0x1078, 0x5c43, 0x1078, 0x5485, 0x1078, 0x2162,
+	0x1078, 0x2240, 0x2091, 0x3009, 0x7823, 0x0000, 0x0090, 0x10cf,
+	0x7820, 0xa086, 0x0002, 0x00c0, 0x10cf, 0x7823, 0x4000, 0x0068,
+	0x10c7, 0x781b, 0x0001, 0x2091, 0x5000, 0x2091, 0x4080, 0x2a70,
+	0x7003, 0x0000, 0x2001, 0x017f, 0x2003, 0x0000, 0x2a70, 0x7000,
+	0xa08e, 0x0003, 0x00c0, 0x10ef, 0x1078, 0x365e, 0x1078, 0x2ae8,
+	0x1078, 0x4ee3, 0x1078, 0x4b66, 0x2009, 0x0100, 0x2104, 0xa082,
+	0x0002, 0x0048, 0x10f3, 0x1078, 0x5966, 0x0078, 0x10d6, 0x1079,
+	0x10f7, 0x0078, 0x10dc, 0x1078, 0x7197, 0x0078, 0x10eb, 0x1101,
+	0x1102, 0x11be, 0x10ff, 0x1246, 0x12dc, 0x12dd, 0x12de, 0x1078,
+	0x1332, 0x007c, 0x127e, 0x0f7e, 0x2091, 0x8000, 0x7000, 0xa086,
+	0x0001, 0x00c0, 0x1198, 0x1078, 0x3aec, 0x2079, 0x0100, 0x7844,
+	0xa005, 0x00c0, 0x1198, 0x2011, 0x41dc, 0x1078, 0x5a45, 0x1078,
+	0x1adf, 0x780f, 0x00ff, 0x7840, 0xa084, 0xfffb, 0x7842, 0x2011,
+	0x8010, 0x73c4, 0x1078, 0x361b, 0x2001, 0xffff, 0x1078, 0x5ae6,
+	0x723c, 0xc284, 0x723e, 0x2001, 0xa60c, 0x2014, 0xc2ac, 0x2202,
+	0x1078, 0x6f9f, 0x2011, 0x0004, 0x1078, 0x8d1b, 0x1078, 0x489e,
+	0x1078, 0x42d4, 0x0040, 0x1144, 0x7087, 0x0001, 0x70bf, 0x0000,
+	0x1078, 0x3c9e, 0x0078, 0x1198, 0x1078, 0x4967, 0x0040, 0x114d,
+	0x7a0c, 0xc2b4, 0x7a0e, 0x0078, 0x1159, 0x1078, 0x90a6, 0x70cc,
+	0xd09c, 0x00c0, 0x1159, 0x7098, 0xa005, 0x0040, 0x1159, 0x1078,
+	0x42b8, 0x70d7, 0x0000, 0x70d3, 0x0000, 0x72cc, 0x2079, 0xa652,
+	0x7804, 0xd0ac, 0x0040, 0x1165, 0xc295, 0x72ce, 0xa296, 0x0004,
+	0x0040, 0x1186, 0x2011, 0x0001, 0x1078, 0x8d1b, 0x7093, 0x0000,
+	0x7097, 0xffff, 0x7003, 0x0002, 0x0f7f, 0x1078, 0x2677, 0x2011,
+	0x0005, 0x1078, 0x70e0, 0x1078, 0x62d1, 0x0c7e, 0x2061, 0x0100,
+	0x60e3, 0x0008, 0x0c7f, 0x127f, 0x0078, 0x119a, 0x7093, 0x0000,
+	0x7097, 0xffff, 0x7003, 0x0002, 0x2011, 0x0005, 0x1078, 0x70e0,
+	0x1078, 0x62d1, 0x0c7e, 0x2061, 0x0100, 0x60e3, 0x0008, 0x0c7f,
+	0x0f7f, 0x127f, 0x007c, 0x0c7e, 0x20a9, 0x0082, 0x2009, 0x007e,
+	0x017e, 0x027e, 0x037e, 0x2110, 0x027e, 0x2019, 0x0029, 0x1078,
+	0x73d0, 0x027f, 0x1078, 0xa4f1, 0x037f, 0x027f, 0x017f, 0x1078,
+	0x298e, 0x8108, 0x00f0, 0x11a0, 0x0c7f, 0x706f, 0x0000, 0x7070,
+	0xa084, 0x00ff, 0x7072, 0x709b, 0x0000, 0x007c, 0x127e, 0x2091,
+	0x8000, 0x7000, 0xa086, 0x0002, 0x00c0, 0x1244, 0x7094, 0xa086,
+	0xffff, 0x0040, 0x11d1, 0x1078, 0x2677, 0x1078, 0x62d1, 0x0078,
+	0x1244, 0x70cc, 0xd09c, 0x0040, 0x11fd, 0xd084, 0x0040, 0x11fd,
+	0x0f7e, 0x2079, 0x0100, 0x790c, 0xc1b5, 0x790e, 0x0f7f, 0xd08c,
+	0x0040, 0x11fd, 0x70d0, 0xa086, 0xffff, 0x0040, 0x11f9, 0x1078,
+	0x27f7, 0x1078, 0x62d1, 0x70cc, 0xd094, 0x00c0, 0x1244, 0x2011,
+	0x0001, 0x2019, 0x0000, 0x1078, 0x282f, 0x1078, 0x62d1, 0x0078,
+	0x1244, 0x70d4, 0xa005, 0x00c0, 0x1244, 0x7090, 0xa005, 0x00c0,
+	0x1244, 0x1078, 0x4967, 0x00c0, 0x1244, 0x2001, 0xa653, 0x2004,
+	0xd0ac, 0x0040, 0x1227, 0x157e, 0x0c7e, 0x20a9, 0x007f, 0x2009,
+	0x0000, 0x017e, 0x1078, 0x45c4, 0x00c0, 0x121a, 0x6000, 0xd0ec,
+	0x00c0, 0x1222, 0x017f, 0x8108, 0x00f0, 0x1211, 0x0c7f, 0x157f,
+	0x0078, 0x1227, 0x017f, 0x0c7f, 0x157f, 0x0078, 0x1244, 0x7003,
+	0x0003, 0x7097, 0xffff, 0x2001, 0x0000, 0x1078, 0x24e8, 0x1078,
+	0x3699, 0x2001, 0xa8b2, 0x2004, 0xa086, 0x0005, 0x00c0, 0x123c,
+	0x2011, 0x0000, 0x1078, 0x70e0, 0x2011, 0x0000, 0x1078, 0x70ea,
+	0x1078, 0x62d1, 0x1078, 0x639b, 0x127f, 0x007c, 0x017e, 0x0f7e,
+	0x127e, 0x2091, 0x8000, 0x2079, 0x0100, 0x2009, 0x00f7, 0x1078,
+	0x42a1, 0x7940, 0xa18c, 0x0010, 0x7942, 0x7924, 0xd1b4, 0x0040,
+	0x125b, 0x7827, 0x0040, 0xd19c, 0x0040, 0x1260, 0x7827, 0x0008,
+	0x007e, 0x037e, 0x157e, 0xa006, 0x1078, 0x5ae6, 0x7900, 0xa18a,
+	0x0003, 0x0050, 0x1289, 0x7954, 0xd1ac, 0x00c0, 0x1289, 0x2009,
+	0x00f8, 0x1078, 0x42a1, 0x7843, 0x0090, 0x7843, 0x0010, 0x20a9,
+	0x09c4, 0x7820, 0xd09c, 0x00c0, 0x1281, 0x7824, 0xd0ac, 0x00c0,
+	0x12ca, 0x00f0, 0x1279, 0x2001, 0x0001, 0x1078, 0x24e8, 0x0078,
+	0x12d5, 0x7853, 0x0000, 0x782f, 0x0020, 0x20a9, 0x0050, 0x00e0,
+	0x128f, 0x2091, 0x6000, 0x00f0, 0x128f, 0x7853, 0x0400, 0x782f,
+	0x0000, 0x2009, 0x00f8, 0x1078, 0x42a1, 0x20a9, 0x000e, 0x0005,
+	0x00f0, 0x129f, 0x7853, 0x1400, 0x7843, 0x0090, 0x7843, 0x0010,
+	0x2019, 0x61a8, 0x7854, 0x0005, 0x0005, 0xd08c, 0x0040, 0x12b4,
+	0x7824, 0xd0ac, 0x00c0, 0x12ca, 0x8319, 0x00c0, 0x12aa, 0x2009,
+	0xa632, 0x2104, 0x8000, 0x200a, 0xa084, 0xfff0, 0x0040, 0x12c4,
+	0x200b, 0x0000, 0x1078, 0x2588, 0x2001, 0x0001, 0x1078, 0x24e8,
+	0x0078, 0x12d3, 0x2001, 0xa632, 0x2003, 0x0000, 0x7828, 0xc09d,
+	0x782a, 0x7827, 0x0048, 0x7853, 0x0400, 0x157f, 0x037f, 0x007f,
+	0x127f, 0x0f7f, 0x017f, 0x007c, 0x007c, 0x007c, 0x007c, 0x2a70,
+	0x2061, 0xa8ad, 0x2063, 0x0001, 0x6007, 0x0013, 0x600b, 0x0018,
+	0x600f, 0x0017, 0x2009, 0x0100, 0x2104, 0xa082, 0x0002, 0x0048,
+	0x12f5, 0x7053, 0xffff, 0x0078, 0x12f7, 0x7053, 0x0000, 0x7057,
+	0xffff, 0x706f, 0x0000, 0x7073, 0x0000, 0x1078, 0x90a6, 0x2061,
+	0xa88d, 0x6003, 0x0909, 0x6007, 0x0000, 0x600b, 0x8800, 0x600f,
+	0x0200, 0x6013, 0x00ff, 0x6017, 0x0003, 0x601b, 0x0000, 0x601f,
+	0x07d0, 0x2061, 0xa895, 0x6003, 0x8000, 0x6007, 0x0000, 0x600b,
+	0x0000, 0x600f, 0x0200, 0x6013, 0x00ff, 0x6017, 0x0000, 0x601b,
+	0x0001, 0x601f, 0x0000, 0x2061, 0xa8a5, 0x6003, 0x514c, 0x6007,
+	0x4f47, 0x600b, 0x4943, 0x600f, 0x2020, 0x2001, 0xa626, 0x2003,
+	0x0000, 0x007c, 0x2091, 0x8000, 0x0068, 0x1334, 0x007e, 0x017e,
+	0x2079, 0x0000, 0x7818, 0xd084, 0x00c0, 0x133a, 0x017f, 0x792e,
+	0x007f, 0x782a, 0x007f, 0x7826, 0x3900, 0x783a, 0x7823, 0x8002,
+	0x781b, 0x0001, 0x2091, 0x5000, 0x2091, 0x4080, 0x2079, 0xa600,
+	0x7803, 0x0005, 0x0078, 0x1352, 0x007c, 0x2071, 0xa600, 0x715c,
+	0x712e, 0x2021, 0x0001, 0xa190, 0x002d, 0xa298, 0x002d, 0x0048,
+	0x136b, 0x7060, 0xa302, 0x00c8, 0x136b, 0x220a, 0x2208, 0x2310,
+	0x8420, 0x0078, 0x135d, 0x200b, 0x0000, 0x74aa, 0x74ae, 0x007c,
+	0x0e7e, 0x127e, 0x2091, 0x8000, 0x2071, 0xa600, 0x70ac, 0xa0ea,
+	0x0010, 0x00c8, 0x137e, 0xa06e, 0x0078, 0x1388, 0x8001, 0x70ae,
+	0x702c, 0x2068, 0x2d04, 0x702e, 0x206b, 0x0000, 0x6807, 0x0000,
+	0x127f, 0x0e7f, 0x007c, 0x0e7e, 0x2071, 0xa600, 0x127e, 0x2091,
+	0x8000, 0x70ac, 0x8001, 0x00c8, 0x1398, 0xa06e, 0x0078, 0x13a1,
+	0x70ae, 0x702c, 0x2068, 0x2d04, 0x702e, 0x206b, 0x0000, 0x6807,
+	0x0000, 0x127f, 0x0e7f, 0x007c, 0x0e7e, 0x127e, 0x2091, 0x8000,
+	0x2071, 0xa600, 0x702c, 0x206a, 0x2d00, 0x702e, 0x70ac, 0x8000,
+	0x70ae, 0x127f, 0x0e7f, 0x007c, 0x8dff, 0x0040, 0x13c0, 0x6804,
+	0x6807, 0x0000, 0x007e, 0x1078, 0x13a4, 0x0d7f, 0x0078, 0x13b4,
+	0x007c, 0x0e7e, 0x2071, 0xa600, 0x70ac, 0xa08a, 0x0010, 0xa00d,
+	0x0e7f, 0x007c, 0x0e7e, 0x2071, 0xa8d6, 0x7007, 0x0000, 0x701b,
+	0x0000, 0x701f, 0x0000, 0x2071, 0x0000, 0x7010, 0xa085, 0x8004,
+	0x7012, 0x0e7f, 0x007c, 0x127e, 0x2091, 0x8000, 0x0e7e, 0x2270,
+	0x700b, 0x0000, 0x2071, 0xa8d6, 0x7018, 0xa088, 0xa8df, 0x220a,
+	0x8000, 0xa084, 0x0007, 0x701a, 0x7004, 0xa005, 0x00c0, 0x13f6,
+	0x0f7e, 0x2079, 0x0010, 0x1078, 0x1408, 0x0f7f, 0x0e7f, 0x127f,
+	0x007c, 0x0e7e, 0x2071, 0xa8d6, 0x7004, 0xa005, 0x00c0, 0x1406,
+	0x0f7e, 0x2079, 0x0010, 0x1078, 0x1408, 0x0f7f, 0x0e7f, 0x007c,
+	0x7000, 0x0079, 0x140b, 0x140f, 0x1479, 0x1496, 0x1496, 0x7018,
+	0x711c, 0xa106, 0x00c0, 0x1417, 0x7007, 0x0000, 0x007c, 0x0d7e,
+	0xa180, 0xa8df, 0x2004, 0x700a, 0x2068, 0x8108, 0xa18c, 0x0007,
+	0x711e, 0x7803, 0x0026, 0x6824, 0x7832, 0x6828, 0x7836, 0x682c,
+	0x783a, 0x6830, 0x783e, 0x6810, 0x700e, 0x680c, 0x7016, 0x6804,
+	0x0d7f, 0xd084, 0x0040, 0x1439, 0x7007, 0x0001, 0x1078, 0x143e,
+	0x007c, 0x7007, 0x0002, 0x1078, 0x1454, 0x007c, 0x017e, 0x027e,
+	0x710c, 0x2011, 0x0040, 0xa182, 0x0040, 0x00c8, 0x1449, 0x2110,
+	0xa006, 0x700e, 0x7212, 0x8203, 0x7822, 0x7803, 0x0020, 0x7803,
+	0x0041, 0x027f, 0x017f, 0x007c, 0x017e, 0x027e, 0x137e, 0x147e,
+	0x157e, 0x7014, 0x2098, 0x20a1, 0x0014, 0x7803, 0x0026, 0x710c,
+	0x2011, 0x0040, 0xa182, 0x0040, 0x00c8, 0x1468, 0x2110, 0xa006,
+	0x700e, 0x22a8, 0x53a6, 0x8203, 0x7822, 0x7803, 0x0020, 0x3300,
+	0x7016, 0x7803, 0x0001, 0x157f, 0x147f, 0x137f, 0x027f, 0x017f,
+	0x007c, 0x137e, 0x147e, 0x157e, 0x2099, 0xa6fa, 0x20a1, 0x0018,
+	0x20a9, 0x0008, 0x53a3, 0x7803, 0x0020, 0x127e, 0x2091, 0x8000,
+	0x7803, 0x0041, 0x7007, 0x0003, 0x7000, 0xc084, 0x7002, 0x700b,
+	0xa6f5, 0x127f, 0x157f, 0x147f, 0x137f, 0x007c, 0x137e, 0x147e,
+	0x157e, 0x2001, 0xa729, 0x209c, 0x20a1, 0x0014, 0x7803, 0x0026,
+	0x2001, 0xa72a, 0x20ac, 0x53a6, 0x2099, 0xa72b, 0x20a1, 0x0018,
+	0x20a9, 0x0008, 0x53a3, 0x7803, 0x0020, 0x127e, 0x2091, 0x8000,
+	0x7803, 0x0001, 0x7007, 0x0004, 0x7000, 0xc08c, 0x7002, 0x700b,
+	0xa726, 0x127f, 0x157f, 0x147f, 0x137f, 0x007c, 0x017e, 0x0e7e,
+	0x2071, 0xa8d6, 0x0f7e, 0x2079, 0x0010, 0x7904, 0x7803, 0x0002,
+	0xd1fc, 0x0040, 0x14d0, 0xa18c, 0x0700, 0x7004, 0x1079, 0x14d4,
+	0x0f7f, 0x0e7f, 0x017f, 0x007c, 0x1408, 0x14dc, 0x1509, 0x1531,
+	0x1564, 0x14da, 0x0078, 0x14da, 0xa18c, 0x0700, 0x00c0, 0x1502,
+	0x137e, 0x147e, 0x157e, 0x7014, 0x20a0, 0x2099, 0x0014, 0x7803,
+	0x0040, 0x7010, 0x20a8, 0x53a5, 0x3400, 0x7016, 0x157f, 0x147f,
+	0x137f, 0x700c, 0xa005, 0x0040, 0x151e, 0x1078, 0x143e, 0x007c,
+	0x7008, 0xa080, 0x0002, 0x2003, 0x0100, 0x7007, 0x0000, 0x1078,
+	0x1408, 0x007c, 0x7008, 0xa080, 0x0002, 0x2003, 0x0200, 0x0078,
+	0x14fd, 0xa18c, 0x0700, 0x00c0, 0x1514, 0x700c, 0xa005, 0x0040,
+	0x151e, 0x1078, 0x1454, 0x007c, 0x7008, 0xa080, 0x0002, 0x2003,
+	0x0200, 0x7007, 0x0000, 0x1078, 0x1408, 0x007c, 0x0d7e, 0x7008,
+	0x2068, 0x7830, 0x6826, 0x7834, 0x682a, 0x7838, 0x682e, 0x783c,
+	0x6832, 0x680b, 0x0100, 0x0d7f, 0x7007, 0x0000, 0x1078, 0x1408,
+	0x007c, 0xa18c, 0x0700, 0x00c0, 0x155e, 0x137e, 0x147e, 0x157e,
+	0x2001, 0xa6f8, 0x2004, 0xa080, 0x000d, 0x20a0, 0x2099, 0x0014,
+	0x7803, 0x0040, 0x20a9, 0x0020, 0x53a5, 0x2001, 0xa6fa, 0x2004,
+	0xd0bc, 0x0040, 0x1554, 0x2001, 0xa703, 0x2004, 0xa080, 0x000d,
+	0x20a0, 0x20a9, 0x0020, 0x53a5, 0x157f, 0x147f, 0x137f, 0x7007,
+	0x0000, 0x1078, 0x4f8c, 0x1078, 0x1408, 0x007c, 0x2011, 0x8003,
+	0x1078, 0x361b, 0x0078, 0x1562, 0xa18c, 0x0700, 0x00c0, 0x1571,
+	0x2001, 0xa728, 0x2003, 0x0100, 0x7007, 0x0000, 0x1078, 0x1408,
+	0x007c, 0x2011, 0x8004, 0x1078, 0x361b, 0x0078, 0x1575, 0x127e,
+	0x2091, 0x2100, 0x2079, 0x0030, 0x2071, 0xa8e7, 0x7803, 0x0004,
+	0x7003, 0x0000, 0x700f, 0xa8ed, 0x7013, 0xa8ed, 0x780f, 0x0076,
+	0x7803, 0x0004, 0x127f, 0x007c, 0x6934, 0xa184, 0x0007, 0x0079,
+	0x1591, 0x1599, 0x15df, 0x1599, 0x1599, 0x1599, 0x15c4, 0x15a8,
+	0x159d, 0xa085, 0x0001, 0x0078, 0x15f9, 0x684c, 0xd0bc, 0x0040,
+	0x1599, 0x6860, 0x682e, 0x685c, 0x682a, 0x6858, 0x0078, 0x15e7,
+	0xa18c, 0x00ff, 0xa186, 0x001e, 0x00c0, 0x1599, 0x684c, 0xd0bc,
+	0x0040, 0x1599, 0x6860, 0x682e, 0x685c, 0x682a, 0x6804, 0x681a,
+	0xa080, 0x000d, 0x2004, 0xa084, 0x000f, 0xa080, 0x206a, 0x2004,
+	0x6832, 0x6858, 0x0078, 0x15ef, 0xa18c, 0x00ff, 0xa186, 0x0015,
+	0x00c0, 0x1599, 0x684c, 0xd0ac, 0x0040, 0x1599, 0x6804, 0x681a,
+	0xa080, 0x000d, 0x2004, 0xa084, 0x000f, 0xa080, 0x206a, 0x2004,
+	0x6832, 0xa006, 0x682e, 0x682a, 0x6858, 0x0078, 0x15ef, 0x684c,
+	0xd0ac, 0x0040, 0x1599, 0xa006, 0x682e, 0x682a, 0x6858, 0xa18c,
+	0x000f, 0xa188, 0x206a, 0x210c, 0x6932, 0x2d08, 0x691a, 0x6826,
+	0x684c, 0xc0dd, 0x684e, 0xa006, 0x680a, 0x697c, 0x6912, 0x6980,
+	0x6916, 0x007c, 0x20e1, 0x0007, 0x20e1, 0x2000, 0x2001, 0x020a,
+	0x2004, 0x82ff, 0x0040, 0x161c, 0xa280, 0x0004, 0x0d7e, 0x206c,
+	0x684c, 0xd0dc, 0x00c0, 0x1618, 0x1078, 0x158c, 0x0040, 0x1618,
+	0x0d7f, 0xa280, 0x0000, 0x2003, 0x0002, 0xa016, 0x0078, 0x161c,
+	0x6808, 0x8000, 0x680a, 0x0d7f, 0x127e, 0x047e, 0x037e, 0x027e,
+	0x2091, 0x2100, 0x027f, 0x037f, 0x047f, 0x7000, 0xa005, 0x00c0,
+	0x1630, 0x7206, 0x2001, 0x1651, 0x007e, 0x2260, 0x0078, 0x17e0,
+	0x710c, 0x220a, 0x8108, 0x230a, 0x8108, 0x240a, 0x8108, 0xa182,
+	0xa908, 0x0048, 0x163d, 0x2009, 0xa8ed, 0x710e, 0x7010, 0xa102,
+	0xa082, 0x0009, 0x0040, 0x1648, 0xa080, 0x001b, 0x00c0, 0x164b,
+	0x2009, 0x0138, 0x200a, 0x7000, 0xa005, 0x00c0, 0x1651, 0x1078,
+	0x17c1, 0x127f, 0x007c, 0x127e, 0x027e, 0x037e, 0x0c7e, 0x007e,
+	0x2091, 0x2100, 0x007f, 0x047f, 0x037f, 0x027f, 0x0d7e, 0x0c7e,
+	0x2460, 0x6110, 0x2168, 0x6a62, 0x6b5e, 0xa005, 0x0040, 0x16dd,
+	0x6808, 0xa005, 0x0040, 0x174a, 0x7000, 0xa005, 0x00c0, 0x1672,
+	0x0078, 0x16d2, 0x700c, 0x7110, 0xa106, 0x00c0, 0x1753, 0x7004,
+	0xa406, 0x00c0, 0x16d2, 0x2001, 0x0005, 0x2004, 0xd08c, 0x0040,
+	0x168f, 0x047e, 0x1078, 0x1913, 0x047f, 0x2460, 0x6010, 0xa080,
+	0x0002, 0x2004, 0xa005, 0x0040, 0x174a, 0x0078, 0x166c, 0x2001,
+	0x0207, 0x2004, 0xd09c, 0x00c0, 0x167b, 0x7804, 0xa084, 0x6000,
+	0x0040, 0x16a0, 0xa086, 0x6000, 0x0040, 0x16a0, 0x0078, 0x167b,
+	0x7100, 0xa186, 0x0002, 0x00c0, 0x16c0, 0x0e7e, 0x2b68, 0x6818,
+	0x2060, 0x1078, 0x203f, 0x2804, 0xac70, 0x6034, 0xd09c, 0x00c0,
+	0x16b5, 0x7108, 0x720c, 0x0078, 0x16b7, 0x7110, 0x7214, 0x6810,
+	0xa100, 0x6812, 0x6814, 0xa201, 0x6816, 0x0e7f, 0x0078, 0x16c4,
+	0xa186, 0x0001, 0x00c0, 0x16cc, 0x7820, 0x6910, 0xa100, 0x6812,
+	0x7824, 0x6914, 0xa101, 0x6816, 0x7803, 0x0004, 0x7003, 0x0000,
+	0x7004, 0x2060, 0x6100, 0xa18e, 0x0004, 0x00c0, 0x1753, 0x2009,
+	0x0048, 0x1078, 0x775c, 0x0078, 0x1753, 0x6808, 0xa005, 0x0040,
+	0x174a, 0x7000, 0xa005, 0x00c0, 0x16e7, 0x0078, 0x174a, 0x700c,
+	0x7110, 0xa106, 0x00c0, 0x16f0, 0x7004, 0xa406, 0x00c0, 0x174a,
+	0x2001, 0x0005, 0x2004, 0xd08c, 0x0040, 0x1704, 0x047e, 0x1078,
+	0x1913, 0x047f, 0x2460, 0x6010, 0xa080, 0x0002, 0x2004, 0xa005,
+	0x0040, 0x174a, 0x0078, 0x16e1, 0x2001, 0x0207, 0x2004, 0xd09c,
+	0x00c0, 0x16f0, 0x2001, 0x0005, 0x2004, 0xd08c, 0x00c0, 0x16f6,
+	0x7804, 0xa084, 0x6000, 0x0040, 0x171b, 0xa086, 0x6000, 0x0040,
+	0x171b, 0x0078, 0x16f0, 0x7007, 0x0000, 0xa016, 0x2218, 0x7000,
+	0xa08e, 0x0001, 0x0040, 0x173c, 0xa08e, 0x0002, 0x00c0, 0x174a,
+	0x0c7e, 0x0e7e, 0x6818, 0x2060, 0x1078, 0x203f, 0x2804, 0xac70,
+	0x6034, 0xd09c, 0x00c0, 0x1738, 0x7308, 0x720c, 0x0078, 0x173a,
+	0x7310, 0x7214, 0x0e7f, 0x0c7f, 0x7820, 0xa318, 0x7824, 0xa211,
+	0x6810, 0xa300, 0x6812, 0x6814, 0xa201, 0x6816, 0x7803, 0x0004,
+	0x7003, 0x0000, 0x6100, 0xa18e, 0x0004, 0x00c0, 0x1753, 0x2009,
+	0x0048, 0x1078, 0x775c, 0x0c7f, 0x0d7f, 0x127f, 0x007c, 0x0f7e,
+	0x0e7e, 0x027e, 0x037e, 0x047e, 0x057e, 0x2071, 0xa8e7, 0x7000,
+	0xa086, 0x0000, 0x0040, 0x17ba, 0x7004, 0xac06, 0x00c0, 0x17ab,
+	0x2079, 0x0030, 0x7000, 0xa086, 0x0003, 0x0040, 0x17ab, 0x7804,
+	0xd0fc, 0x00c0, 0x17a7, 0x20e1, 0x6000, 0x2011, 0x0032, 0x2001,
+	0x0208, 0x200c, 0x2001, 0x0209, 0x2004, 0xa106, 0x00c0, 0x176f,
+	0x8211, 0x00c0, 0x1777, 0x7804, 0xd0fc, 0x00c0, 0x17a7, 0x1078,
+	0x1b22, 0x027e, 0x057e, 0x7803, 0x0004, 0x7804, 0xd0ac, 0x00c0,
+	0x178d, 0x7803, 0x0002, 0x7803, 0x0009, 0x7003, 0x0003, 0x7007,
+	0x0000, 0x057f, 0x027f, 0x2001, 0x015d, 0x2003, 0x0000, 0x2001,
+	0x0160, 0x2502, 0x2001, 0x0138, 0x2202, 0x0078, 0x17ab, 0x1078,
+	0x1913, 0x0078, 0x175f, 0x157e, 0x20a9, 0x0009, 0x2009, 0xa8ed,
+	0x2104, 0xac06, 0x00c0, 0x17b5, 0x200a, 0xa188, 0x0003, 0x00f0,
+	0x17b0, 0x157f, 0x057f, 0x047f, 0x037f, 0x027f, 0x0e7f, 0x0f7f,
+	0x007c, 0x700c, 0x7110, 0xa106, 0x00c0, 0x17c9, 0x7003, 0x0000,
+	0x007c, 0x2104, 0x7006, 0x2060, 0x8108, 0x211c, 0x8108, 0x2124,
+	0x8108, 0xa182, 0xa908, 0x0048, 0x17d7, 0x2009, 0xa8ed, 0x7112,
+	0x700c, 0xa106, 0x00c0, 0x17e0, 0x2001, 0x0138, 0x2003, 0x0008,
+	0x8cff, 0x00c0, 0x17e7, 0x1078, 0x1b4d, 0x0078, 0x1854, 0x6010,
+	0x2068, 0x2d58, 0x6828, 0xa406, 0x00c0, 0x17f2, 0x682c, 0xa306,
+	0x0040, 0x182f, 0x601c, 0xa086, 0x0008, 0x0040, 0x182f, 0x6024,
+	0xd0f4, 0x00c0, 0x181c, 0xd0d4, 0x0040, 0x1818, 0x6038, 0xa402,
+	0x6034, 0xa303, 0x0040, 0x1806, 0x00c8, 0x1818, 0x643a, 0x6336,
+	0x6c2a, 0x6b2e, 0x047e, 0x037e, 0x2400, 0x6c7c, 0xa402, 0x6812,
+	0x2300, 0x6b80, 0xa303, 0x6816, 0x037f, 0x047f, 0x0078, 0x181c,
+	0x1078, 0x9053, 0x0040, 0x17e3, 0x2001, 0xa674, 0x2004, 0xd0b4,
+	0x00c0, 0x182b, 0x6018, 0x2004, 0xd0bc, 0x00c0, 0x182b, 0x6817,
+	0x7fff, 0x6813, 0xffff, 0x1078, 0x208a, 0x00c0, 0x17e3, 0x0c7e,
+	0x7004, 0x2060, 0x6024, 0xc0d4, 0x6026, 0x0c7f, 0x684c, 0xd0f4,
+	0x0040, 0x1840, 0x6817, 0xffff, 0x6813, 0xffff, 0x0078, 0x17e3,
+	0x6824, 0x2050, 0x6818, 0x2060, 0x6830, 0x2040, 0x6034, 0xa0cc,
+	0x000f, 0x2009, 0x0011, 0x1078, 0x1855, 0x0040, 0x1853, 0x2009,
+	0x0001, 0x1078, 0x1855, 0x2d58, 0x007c, 0x8aff, 0x0040, 0x18ec,
+	0xa03e, 0x2730, 0x6850, 0xd0fc, 0x00c0, 0x1877, 0xd0f4, 0x00c0,
+	0x1887, 0x0d7e, 0x2804, 0xac68, 0x2900, 0x0079, 0x1867, 0x18ce,
+	0x188e, 0x188e, 0x18ce, 0x18ce, 0x18c6, 0x18ce, 0x188e, 0x18ce,
+	0x1894, 0x1894, 0x18ce, 0x18ce, 0x18ce, 0x18bd, 0x1894, 0xc0fc,
+	0x6852, 0x6b6c, 0x6a70, 0x6d1c, 0x6c20, 0x0d7e, 0xd99c, 0x0040,
+	0x18d1, 0x2804, 0xac68, 0x6f08, 0x6e0c, 0x0078, 0x18d1, 0xc0f4,
+	0x6852, 0x6b6c, 0x6a70, 0x0d7e, 0x0078, 0x18d8, 0x6b08, 0x6a0c,
+	0x6d00, 0x6c04, 0x0078, 0x18d1, 0x7b0c, 0xd3bc, 0x0040, 0x18b5,
+	0x7004, 0x0e7e, 0x2070, 0x701c, 0x0e7f, 0xa086, 0x0008, 0x00c0,
+	0x18b5, 0x7b08, 0xa39c, 0x0fff, 0x2d20, 0x0d7f, 0x0d7e, 0x6a14,
+	0x82ff, 0x00c0, 0x18b0, 0x6810, 0xa302, 0x0048, 0x18b0, 0x6b10,
+	0x2011, 0x0000, 0x2468, 0x0078, 0x18b7, 0x6b10, 0x6a14, 0x6d00,
+	0x6c04, 0x6f08, 0x6e0c, 0x0078, 0x18d1, 0x0d7f, 0x0d7e, 0x6834,
+	0xa084, 0x00ff, 0xa086, 0x001e, 0x00c0, 0x18ce, 0x0d7f, 0x1078,
+	0x2026, 0x00c0, 0x1855, 0xa00e, 0x0078, 0x18ec, 0x0d7f, 0x1078,
+	0x1332, 0x7b22, 0x7a26, 0x7d32, 0x7c36, 0x7f3a, 0x7e3e, 0x7902,
+	0x7000, 0x8000, 0x7002, 0x0d7f, 0x6828, 0xa300, 0x682a, 0x682c,
+	0xa201, 0x682e, 0x2300, 0x6b10, 0xa302, 0x6812, 0x2200, 0x6a14,
+	0xa203, 0x6816, 0x1078, 0x2026, 0x007c, 0x1078, 0x1332, 0x1078,
+	0x1c97, 0x7004, 0x2060, 0x0d7e, 0x6010, 0x2068, 0x7003, 0x0000,
+	0x1078, 0x1af4, 0x1078, 0x8d06, 0x0040, 0x190c, 0x6808, 0x8001,
+	0x680a, 0x697c, 0x6912, 0x6980, 0x6916, 0x682b, 0xffff, 0x682f,
+	0xffff, 0x6850, 0xc0bd, 0x6852, 0x0d7f, 0x1078, 0x8a01, 0x0078,
+	0x1adb, 0x1078, 0x1332, 0x127e, 0x2091, 0x2100, 0x007e, 0x017e,
+	0x2b68, 0x6818, 0x2060, 0x7904, 0x7803, 0x0002, 0xa184, 0x0700,
+	0x00c0, 0x18ef, 0xa184, 0x0003, 0xa086, 0x0003, 0x0040, 0x1911,
+	0x7000, 0x0079, 0x192b, 0x1933, 0x1935, 0x1a34, 0x1ab2, 0x1ac9,
+	0x1933, 0x1933, 0x1933, 0x1078, 0x1332, 0x8001, 0x7002, 0xa184,
+	0x0880, 0x00c0, 0x194a, 0x8aff, 0x0040, 0x19d4, 0x2009, 0x0001,
+	0x1078, 0x1855, 0x0040, 0x1adb, 0x2009, 0x0001, 0x1078, 0x1855,
+	0x0078, 0x1adb, 0x7803, 0x0004, 0x7003, 0x0000, 0xd1bc, 0x00c0,
+	0x19b2, 0x027e, 0x037e, 0x017e, 0x7808, 0xd0ec, 0x00c0, 0x1962,
+	0x7c20, 0x7d24, 0x7e30, 0x7f34, 0x7803, 0x0009, 0x7003, 0x0004,
+	0x0078, 0x1964, 0x1078, 0x1bd7, 0x017f, 0xd194, 0x0040, 0x196b,
+	0x8aff, 0x0040, 0x19a1, 0x6b28, 0x6a2c, 0x2400, 0x686e, 0xa31a,
+	0x2500, 0x6872, 0xa213, 0x6b2a, 0x6a2e, 0x0c7e, 0x7004, 0x2060,
+	0x6024, 0xd0f4, 0x00c0, 0x197e, 0x633a, 0x6236, 0x0c7f, 0x2400,
+	0x6910, 0xa100, 0x6812, 0x2500, 0x6914, 0xa101, 0x6816, 0x037f,
+	0x027f, 0x2600, 0x681e, 0x2700, 0x6822, 0x1078, 0x203f, 0x2a00,
+	0x6826, 0x2c00, 0x681a, 0x2800, 0x6832, 0x6850, 0xc0fd, 0x6852,
+	0x6808, 0x8001, 0x680a, 0x00c0, 0x19a7, 0x684c, 0xd0e4, 0x0040,
+	0x19a7, 0x7004, 0x2060, 0x2009, 0x0048, 0x1078, 0x775c, 0x7000,
+	0xa086, 0x0004, 0x0040, 0x1adb, 0x7003, 0x0000, 0x1078, 0x17c1,
+	0x0078, 0x1adb, 0x057e, 0x7d0c, 0xd5bc, 0x00c0, 0x19b9, 0x1078,
+	0xa57e, 0x057f, 0x1078, 0x1af4, 0x0f7e, 0x7004, 0x2078, 0x1078,
+	0x4963, 0x0040, 0x19c6, 0x7824, 0xc0f5, 0x7826, 0x0f7f, 0x682b,
+	0xffff, 0x682f, 0xffff, 0x6808, 0x8001, 0x680a, 0x697c, 0x6912,
+	0x6980, 0x6916, 0x0078, 0x1adb, 0x7004, 0x0c7e, 0x2060, 0x6024,
+	0x0c7f, 0xd0f4, 0x0040, 0x19e1, 0x6808, 0x8001, 0x680a, 0x0078,
+	0x19f5, 0x684c, 0xc0f5, 0x684e, 0x7814, 0xa005, 0x00c0, 0x19f9,
+	0x7003, 0x0000, 0x6808, 0x8001, 0x680a, 0x00c0, 0x19f5, 0x7004,
+	0x2060, 0x2009, 0x0048, 0x1078, 0x775c, 0x1078, 0x17c1, 0x0078,
+	0x1adb, 0x7814, 0x6910, 0xa102, 0x6812, 0x6914, 0xa183, 0x0000,
+	0x6816, 0x7814, 0x7908, 0xa18c, 0x0fff, 0xa192, 0x0841, 0x00c8,
+	0x18ef, 0xa188, 0x0007, 0x8114, 0x8214, 0x8214, 0xa10a, 0x8104,
+	0x8004, 0x8004, 0xa20a, 0x810b, 0x810b, 0x810b, 0x1078, 0x1b5e,
+	0x7803, 0x0004, 0x780f, 0xffff, 0x7803, 0x0001, 0x7804, 0xd0fc,
+	0x0040, 0x1a1e, 0x7803, 0x0002, 0x7803, 0x0004, 0x780f, 0x0076,
+	0x7004, 0x7007, 0x0000, 0x2060, 0x2009, 0x0048, 0x1078, 0x775c,
+	0x1078, 0x1b92, 0x0040, 0x19f5, 0x8001, 0x7002, 0xd194, 0x0040,
+	0x1a46, 0x7804, 0xd0fc, 0x00c0, 0x191b, 0x8aff, 0x0040, 0x1adb,
+	0x2009, 0x0001, 0x1078, 0x1855, 0x0078, 0x1adb, 0xa184, 0x0880,
+	0x00c0, 0x1a53, 0x8aff, 0x0040, 0x1adb, 0x2009, 0x0001, 0x1078,
+	0x1855, 0x0078, 0x1adb, 0x7803, 0x0004, 0x7003, 0x0000, 0xd1bc,
+	0x00c0, 0x1a93, 0x027e, 0x037e, 0x7808, 0xd0ec, 0x00c0, 0x1a66,
+	0x7803, 0x0009, 0x7003, 0x0004, 0x0078, 0x1a68, 0x1078, 0x1bd7,
+	0x6b28, 0x6a2c, 0x1078, 0x203f, 0x0d7e, 0x0f7e, 0x2d78, 0x2804,
+	0xac68, 0x6034, 0xd09c, 0x00c0, 0x1a83, 0x6808, 0x2008, 0xa31a,
+	0x680c, 0xa213, 0x7810, 0xa100, 0x7812, 0x690c, 0x7814, 0xa101,
+	0x7816, 0x0078, 0x1a8f, 0x6810, 0x2008, 0xa31a, 0x6814, 0xa213,
+	0x7810, 0xa100, 0x7812, 0x6914, 0x7814, 0xa101, 0x7816, 0x0f7f,
+	0x0d7f, 0x0078, 0x196d, 0x057e, 0x7d0c, 0x1078, 0xa57e, 0x057f,
+	0x1078, 0x1af4, 0x0f7e, 0x7004, 0x2078, 0x1078, 0x4963, 0x0040,
+	0x1aa4, 0x7824, 0xc0f5, 0x7826, 0x0f7f, 0x682b, 0xffff, 0x682f,
+	0xffff, 0x6808, 0x8001, 0x680a, 0x697c, 0x6912, 0x6980, 0x6916,
+	0x0078, 0x1adb, 0x7803, 0x0004, 0x7003, 0x0000, 0x7004, 0xa00d,
+	0x0040, 0x1ac5, 0x6808, 0x8001, 0x680a, 0x00c0, 0x1ac5, 0x7004,
+	0x2060, 0x2009, 0x0048, 0x1078, 0x775c, 0x1078, 0x17c1, 0x0078,
+	0x1adb, 0x7803, 0x0004, 0x7003, 0x0000, 0x7004, 0x2060, 0x6010,
+	0xa005, 0x0040, 0x1ac5, 0x2068, 0x6808, 0x8000, 0x680a, 0x6c28,
+	0x6b2c, 0x1078, 0x17e0, 0x017f, 0x007f, 0x127f, 0x007c, 0x127e,
+	0x2091, 0x2100, 0x7000, 0xa086, 0x0003, 0x00c0, 0x1af2, 0x700c,
+	0x7110, 0xa106, 0x0040, 0x1af2, 0x20e1, 0x9028, 0x700f, 0xa8ed,
+	0x7013, 0xa8ed, 0x127f, 0x007c, 0x0c7e, 0x1078, 0x1b22, 0x20e1,
+	0x9028, 0x700c, 0x7110, 0xa106, 0x0040, 0x1b19, 0x2104, 0xa005,
+	0x0040, 0x1b08, 0x2060, 0x6010, 0x2060, 0x6008, 0x8001, 0x600a,
+	0xa188, 0x0003, 0xa182, 0xa908, 0x0048, 0x1b10, 0x2009, 0xa8ed,
+	0x7112, 0x700c, 0xa106, 0x00c0, 0x1af9, 0x2011, 0x0008, 0x0078,
+	0x1af9, 0x2001, 0x015d, 0x2003, 0x0000, 0x2001, 0x0138, 0x2202,
+	0x0c7f, 0x007c, 0x2001, 0x0138, 0x2014, 0x2003, 0x0000, 0x2021,
+	0xb015, 0x2001, 0x0141, 0x201c, 0xd3dc, 0x00c0, 0x1b3f, 0x2001,
+	0x0109, 0x201c, 0xa39c, 0x0048, 0x00c0, 0x1b3f, 0x2001, 0x0111,
+	0x201c, 0x83ff, 0x00c0, 0x1b3f, 0x8421, 0x00c0, 0x1b29, 0x007c,
+	0x2011, 0x0201, 0x2009, 0x003c, 0x2204, 0xa005, 0x00c0, 0x1b4c,
+	0x8109, 0x00c0, 0x1b44, 0x007c, 0x007c, 0x1078, 0x1b40, 0x0040,
+	0x1b55, 0x780c, 0xd0a4, 0x0040, 0x1b5b, 0x1078, 0x1af4, 0xa085,
+	0x0001, 0x0078, 0x1b5d, 0x1078, 0x1b92, 0x007c, 0x0e7e, 0x2071,
+	0x0200, 0x7808, 0xa084, 0xf000, 0xa10d, 0x1078, 0x1b22, 0x2019,
+	0x5000, 0x8319, 0x0040, 0x1b7c, 0x2001, 0xa908, 0x2004, 0xa086,
+	0x0000, 0x0040, 0x1b7c, 0x2001, 0x0021, 0xd0fc, 0x0040, 0x1b69,
+	0x1078, 0x1eaa, 0x0078, 0x1b67, 0x20e1, 0x7000, 0x7324, 0x7420,
+	0x7028, 0x7028, 0x7426, 0x7037, 0x0001, 0x810f, 0x712e, 0x702f,
+	0x0100, 0x7037, 0x0008, 0x7326, 0x7422, 0x2001, 0x0138, 0x2202,
+	0x0e7f, 0x007c, 0x027e, 0x2001, 0x015d, 0x2001, 0x0000, 0x7908,
+	0xa18c, 0x0fff, 0xa182, 0x0ffd, 0x0048, 0x1ba0, 0x2009, 0x0000,
+	0xa190, 0x0007, 0xa294, 0x1ff8, 0x8214, 0x8214, 0x8214, 0x2001,
+	0x020a, 0x82ff, 0x0040, 0x1bb5, 0x20e1, 0x6000, 0x200c, 0x200c,
+	0x200c, 0x200c, 0x8211, 0x00c0, 0x1bae, 0x20e1, 0x7000, 0x200c,
+	0x200c, 0x7003, 0x0000, 0x20e1, 0x6000, 0x2001, 0x0208, 0x200c,
+	0x2001, 0x0209, 0x2004, 0xa106, 0x0040, 0x1bd4, 0x1078, 0x1b40,
+	0x0040, 0x1bd2, 0x7908, 0xd1ec, 0x00c0, 0x1bd4, 0x790c, 0xd1a4,
+	0x0040, 0x1b97, 0x1078, 0x1af4, 0xa006, 0x027f, 0x007c, 0x7c20,
+	0x7d24, 0x7e30, 0x7f34, 0x700c, 0x7110, 0xa106, 0x0040, 0x1c69,
+	0x7004, 0x017e, 0x210c, 0xa106, 0x017f, 0x0040, 0x1c69, 0x0d7e,
+	0x0c7e, 0x216c, 0x2d00, 0xa005, 0x0040, 0x1c67, 0x681c, 0xa086,
+	0x0008, 0x0040, 0x1c67, 0x6824, 0xd0d4, 0x00c0, 0x1c67, 0x6810,
+	0x2068, 0x6850, 0xd0fc, 0x0040, 0x1c29, 0x8108, 0x2104, 0x6b2c,
+	0xa306, 0x00c0, 0x1c67, 0x8108, 0x2104, 0x6a28, 0xa206, 0x00c0,
+	0x1c67, 0x6850, 0xc0fc, 0xc0f5, 0x6852, 0x686c, 0x7822, 0x6870,
+	0x7826, 0x681c, 0x7832, 0x6820, 0x7836, 0x6818, 0x2060, 0x6034,
+	0xd09c, 0x0040, 0x1c24, 0x6830, 0x2004, 0xac68, 0x6808, 0x783a,
+	0x680c, 0x783e, 0x0078, 0x1c65, 0xa006, 0x783a, 0x783e, 0x0078,
+	0x1c65, 0x8108, 0x2104, 0xa005, 0x00c0, 0x1c67, 0x6b2c, 0xa306,
+	0x00c0, 0x1c67, 0x8108, 0x2104, 0xa005, 0x00c0, 0x1c67, 0x6a28,
+	0xa206, 0x00c0, 0x1c67, 0x6850, 0xc0f5, 0x6852, 0x6830, 0x2004,
+	0x6918, 0xa160, 0xa180, 0x000d, 0x2004, 0xd09c, 0x00c0, 0x1c57,
+	0x6008, 0x7822, 0x686e, 0x600c, 0x7826, 0x6872, 0x6000, 0x7832,
+	0x6004, 0x7836, 0xa006, 0x783a, 0x783e, 0x0078, 0x1c65, 0x6010,
+	0x7822, 0x686e, 0x6014, 0x7826, 0x6872, 0x6000, 0x7832, 0x6004,
+	0x7836, 0x6008, 0x783a, 0x600c, 0x783e, 0x7803, 0x0011, 0x0c7f,
+	0x0d7f, 0x007c, 0x0f7e, 0x0e7e, 0x017e, 0x027e, 0x2071, 0xa8e7,
+	0x2079, 0x0030, 0x2011, 0x0050, 0x7000, 0xa086, 0x0000, 0x0040,
+	0x1c92, 0x8211, 0x0040, 0x1c90, 0x2001, 0x0005, 0x2004, 0xd08c,
+	0x0040, 0x1c79, 0x7904, 0xa18c, 0x0780, 0x017e, 0x1078, 0x1913,
+	0x017f, 0x81ff, 0x00c0, 0x1c90, 0x2011, 0x0050, 0x0078, 0x1c74,
+	0xa085, 0x0001, 0x027f, 0x017f, 0x0e7f, 0x0f7f, 0x007c, 0x7803,
+	0x0004, 0x2009, 0x0064, 0x7804, 0xd0ac, 0x0040, 0x1ce8, 0x8109,
+	0x00c0, 0x1c9b, 0x2009, 0x0100, 0x210c, 0xa18a, 0x0003, 0x1048,
+	0x1332, 0x1078, 0x1fca, 0x0e7e, 0x0f7e, 0x2071, 0xa8d6, 0x2079,
+	0x0010, 0x7004, 0xa086, 0x0000, 0x0040, 0x1ce0, 0x7800, 0x007e,
+	0x7820, 0x007e, 0x7830, 0x007e, 0x7834, 0x007e, 0x7838, 0x007e,
+	0x783c, 0x007e, 0x7803, 0x0004, 0x7823, 0x0000, 0x0005, 0x0005,
+	0x2079, 0x0030, 0x7804, 0xd0ac, 0x10c0, 0x1332, 0x2079, 0x0010,
+	0x007f, 0x783e, 0x007f, 0x783a, 0x007f, 0x7836, 0x007f, 0x7832,
+	0x007f, 0x7822, 0x007f, 0x7802, 0x0f7f, 0x0e7f, 0x0078, 0x1ce6,
+	0x0f7f, 0x0e7f, 0x7804, 0xd0ac, 0x10c0, 0x1332, 0x1078, 0x639b,
+	0x007c, 0x0e7e, 0x2071, 0xa908, 0x7003, 0x0000, 0x0e7f, 0x007c,
+	0x0d7e, 0xa280, 0x0004, 0x206c, 0x694c, 0xd1dc, 0x00c0, 0x1d6b,
+	0x6934, 0xa184, 0x0007, 0x0079, 0x1cfd, 0x1d05, 0x1d56, 0x1d05,
+	0x1d05, 0x1d05, 0x1d3b, 0x1d18, 0x1d07, 0x1078, 0x1332, 0x684c,
+	0xd0b4, 0x0040, 0x1e79, 0x6860, 0x682e, 0x6816, 0x685c, 0x682a,
+	0x6812, 0x687c, 0x680a, 0x6880, 0x680e, 0x6958, 0x0078, 0x1d5e,
+	0x6834, 0xa084, 0x00ff, 0xa086, 0x001e, 0x00c0, 0x1d05, 0x684c,
+	0xd0b4, 0x0040, 0x1e79, 0x6860, 0x682e, 0x6816, 0x685c, 0x682a,
+	0x6812, 0x687c, 0x680a, 0x6880, 0x680e, 0x6804, 0x681a, 0xa080,
+	0x000d, 0x2004, 0xa084, 0x000f, 0xa080, 0x206a, 0x2004, 0x6832,
+	0x6958, 0x0078, 0x1d67, 0xa18c, 0x00ff, 0xa186, 0x0015, 0x00c0,
+	0x1d6b, 0x684c, 0xd0b4, 0x0040, 0x1e79, 0x6804, 0x681a, 0xa080,
+	0x000d, 0x2004, 0xa084, 0x000f, 0xa080, 0x206a, 0x2004, 0x6832,
+	0x6958, 0xa006, 0x682e, 0x682a, 0x0078, 0x1d67, 0x684c, 0xd0b4,
+	0x0040, 0x18ed, 0x6958, 0xa006, 0x682e, 0x682a, 0x2d00, 0x681a,
+	0x6834, 0xa084, 0x000f, 0xa080, 0x206a, 0x2004, 0x6832, 0x6926,
+	0x684c, 0xc0dd, 0x684e, 0x0d7f, 0x007c, 0x0f7e, 0x2079, 0x0020,
+	0x7804, 0xd0fc, 0x10c0, 0x1eaa, 0x0e7e, 0x0d7e, 0x2071, 0xa908,
+	0x7000, 0xa005, 0x00c0, 0x1df0, 0x0c7e, 0x7206, 0xa280, 0x0004,
+	0x205c, 0x7004, 0x2068, 0x7803, 0x0004, 0x6818, 0x0d7e, 0x2068,
+	0x686c, 0x7812, 0x6890, 0x0f7e, 0x20e1, 0x9040, 0x2079, 0x0200,
+	0x781a, 0x2079, 0x0100, 0x8004, 0x78d6, 0x0f7f, 0x0d7f, 0x2b68,
+	0x6824, 0x2050, 0x6818, 0x2060, 0x6830, 0x2040, 0x6034, 0xa0cc,
+	0x000f, 0x6908, 0x2001, 0x04fd, 0x2004, 0xa086, 0x0007, 0x0040,
+	0x1db2, 0xa184, 0x0007, 0x0040, 0x1db2, 0x017e, 0x2009, 0x0008,
+	0xa102, 0x017f, 0xa108, 0x791a, 0x7116, 0x701e, 0x680c, 0xa081,
+	0x0000, 0x781e, 0x701a, 0xa006, 0x700e, 0x7012, 0x7004, 0x692c,
+	0x6814, 0xa106, 0x00c0, 0x1dc9, 0x6928, 0x6810, 0xa106, 0x0040,
+	0x1dd6, 0x037e, 0x047e, 0x6b14, 0x6c10, 0x1078, 0x208a, 0x047f,
+	0x037f, 0x0040, 0x1dd6, 0x0c7f, 0x0078, 0x1df0, 0x8aff, 0x00c0,
+	0x1dde, 0x0c7f, 0xa085, 0x0001, 0x0078, 0x1df0, 0x127e, 0x2091,
+	0x8000, 0x2079, 0x0020, 0x2009, 0x0001, 0x1078, 0x1df4, 0x0040,
+	0x1ded, 0x2009, 0x0001, 0x1078, 0x1df4, 0x127f, 0x0c7f, 0xa006,
+	0x0d7f, 0x0e7f, 0x0f7f, 0x007c, 0x077e, 0x067e, 0x057e, 0x047e,
+	0x037e, 0x027e, 0x8aff, 0x0040, 0x1e72, 0x700c, 0x7214, 0xa23a,
+	0x7010, 0x7218, 0xa203, 0x0048, 0x1e71, 0xa705, 0x0040, 0x1e71,
+	0xa03e, 0x2730, 0x6850, 0xd0fc, 0x00c0, 0x1e24, 0x0d7e, 0x2804,
+	0xac68, 0x2900, 0x0079, 0x1e14, 0x1e53, 0x1e34, 0x1e34, 0x1e53,
+	0x1e53, 0x1e4b, 0x1e53, 0x1e34, 0x1e53, 0x1e3a, 0x1e3a, 0x1e53,
+	0x1e53, 0x1e53, 0x1e42, 0x1e3a, 0xc0fc, 0x6852, 0x6b6c, 0x6a70,
+	0x6d1c, 0x6c20, 0xd99c, 0x0040, 0x1e57, 0x0d7e, 0x2804, 0xac68,
+	0x6f08, 0x6e0c, 0x0078, 0x1e56, 0x6b08, 0x6a0c, 0x6d00, 0x6c04,
+	0x0078, 0x1e56, 0x6b10, 0x6a14, 0x6d00, 0x6c04, 0x6f08, 0x6e0c,
+	0x0078, 0x1e56, 0x0d7f, 0x0d7e, 0x6834, 0xa084, 0x00ff, 0xa086,
+	0x001e, 0x00c0, 0x1e53, 0x0d7f, 0x1078, 0x2026, 0x00c0, 0x1dfa,
+	0xa00e, 0x0078, 0x1e72, 0x0d7f, 0x1078, 0x1332, 0x0d7f, 0x7b22,
+	0x7a26, 0x7d32, 0x7c36, 0x7f3a, 0x7e3e, 0x7902, 0x7000, 0x8000,
+	0x7002, 0x6828, 0xa300, 0x682a, 0x682c, 0xa201, 0x682e, 0x700c,
+	0xa300, 0x700e, 0x7010, 0xa201, 0x7012, 0x1078, 0x2026, 0x0078,
+	0x1e72, 0xa006, 0x027f, 0x037f, 0x047f, 0x057f, 0x067f, 0x077f,
+	0x007c, 0x1078, 0x1332, 0x027e, 0x2001, 0x0105, 0x2003, 0x0010,
+	0x20e1, 0x9040, 0x7803, 0x0004, 0x7003, 0x0000, 0x7004, 0x2060,
+	0x0d7e, 0x6010, 0x2068, 0x1078, 0x8d06, 0x0040, 0x1e92, 0x6850,
+	0xc0bd, 0x6852, 0x0d7f, 0x0c7e, 0x1078, 0x8a01, 0x0c7f, 0x2001,
+	0xa8c0, 0x2004, 0xac06, 0x00c0, 0x1ea7, 0x20e1, 0x9040, 0x1078,
+	0x738a, 0x2011, 0x0000, 0x1078, 0x70ea, 0x1078, 0x639b, 0x027f,
+	0x0078, 0x1f76, 0x127e, 0x2091, 0x2200, 0x007e, 0x017e, 0x0f7e,
+	0x0e7e, 0x0d7e, 0x0c7e, 0x2079, 0x0020, 0x2071, 0xa908, 0x2b68,
+	0x6818, 0x2060, 0x7904, 0x7803, 0x0002, 0xa184, 0x0700, 0x00c0,
+	0x1e7b, 0x7000, 0x0079, 0x1ec4, 0x1f76, 0x1ec8, 0x1f43, 0x1f74,
+	0x8001, 0x7002, 0xd19c, 0x00c0, 0x1edc, 0x8aff, 0x0040, 0x1efb,
+	0x2009, 0x0001, 0x1078, 0x1df4, 0x0040, 0x1f76, 0x2009, 0x0001,
+	0x1078, 0x1df4, 0x0078, 0x1f76, 0x7803, 0x0004, 0xd194, 0x0040,
+	0x1eec, 0x6850, 0xc0fc, 0x6852, 0x8aff, 0x00c0, 0x1ef1, 0x684c,
+	0xc0f5, 0x684e, 0x0078, 0x1ef1, 0x1078, 0x203f, 0x6850, 0xc0fd,
+	0x6852, 0x2a00, 0x6826, 0x2c00, 0x681a, 0x2800, 0x6832, 0x7003,
+	0x0000, 0x0078, 0x1f76, 0x711c, 0x81ff, 0x0040, 0x1f11, 0x7918,
+	0x7922, 0x7827, 0x0000, 0x7803, 0x0001, 0x7000, 0x8000, 0x7002,
+	0x700c, 0xa100, 0x700e, 0x7010, 0xa081, 0x0000, 0x7012, 0x0078,
+	0x1f76, 0x0f7e, 0x027e, 0x781c, 0x007e, 0x7818, 0x007e, 0x2079,
+	0x0100, 0x7a14, 0xa284, 0x0004, 0xa085, 0x0012, 0x7816, 0x037e,
+	0x2019, 0x1000, 0x8319, 0x1040, 0x1332, 0x7820, 0xd0bc, 0x00c0,
+	0x1f22, 0x037f, 0x79c8, 0x007f, 0xa102, 0x017f, 0x007e, 0x017e,
+	0x79c4, 0x007f, 0xa103, 0x78c6, 0x007f, 0x78ca, 0xa284, 0x0004,
+	0xa085, 0x0012, 0x7816, 0x027f, 0x0f7f, 0x7803, 0x0008, 0x7003,
+	0x0000, 0x0078, 0x1f76, 0x8001, 0x7002, 0xd194, 0x0040, 0x1f58,
+	0x7804, 0xd0fc, 0x00c0, 0x1eba, 0xd19c, 0x00c0, 0x1f72, 0x8aff,
+	0x0040, 0x1f76, 0x2009, 0x0001, 0x1078, 0x1df4, 0x0078, 0x1f76,
+	0x027e, 0x037e, 0x6b28, 0x6a2c, 0x1078, 0x203f, 0x0d7e, 0x2804,
+	0xac68, 0x6034, 0xd09c, 0x00c0, 0x1f6b, 0x6808, 0xa31a, 0x680c,
+	0xa213, 0x0078, 0x1f6f, 0x6810, 0xa31a, 0x6814, 0xa213, 0x0d7f,
+	0x0078, 0x1eec, 0x0078, 0x1eec, 0x1078, 0x1332, 0x0c7f, 0x0d7f,
+	0x0e7f, 0x0f7f, 0x017f, 0x007f, 0x127f, 0x007c, 0x0f7e, 0x0e7e,
+	0x2071, 0xa908, 0x7000, 0xa086, 0x0000, 0x0040, 0x1fc7, 0x2079,
+	0x0020, 0x017e, 0x2009, 0x0207, 0x210c, 0xd194, 0x0040, 0x1fa4,
+	0x2009, 0x020c, 0x210c, 0xa184, 0x0003, 0x0040, 0x1fa4, 0x1078,
+	0xa5d2, 0x2001, 0x0133, 0x2004, 0xa005, 0x1040, 0x1332, 0x20e1,
+	0x9040, 0x2001, 0x020c, 0x2102, 0x2009, 0x0206, 0x2104, 0x2009,
+	0x0203, 0x210c, 0xa106, 0x00c0, 0x1faf, 0x20e1, 0x9040, 0x7804,
+	0xd0fc, 0x0040, 0x1f8a, 0x1078, 0x1eaa, 0x7000, 0xa086, 0x0000,
+	0x00c0, 0x1f8a, 0x017f, 0x7803, 0x0004, 0x7804, 0xd0ac, 0x00c0,
+	0x1fbd, 0x20e1, 0x9040, 0x7803, 0x0002, 0x7003, 0x0000, 0x0e7f,
+	0x0f7f, 0x007c, 0x027e, 0x0c7e, 0x0d7e, 0x0e7e, 0x0f7e, 0x2071,
+	0xa908, 0x2079, 0x0020, 0x7000, 0xa086, 0x0000, 0x0040, 0x2003,
+	0x7004, 0x2060, 0x6010, 0x2068, 0x1078, 0x8d06, 0x0040, 0x1fed,
+	0x6850, 0xc0b5, 0x6852, 0x680c, 0x7a1c, 0xa206, 0x00c0, 0x1fed,
+	0x6808, 0x7a18, 0xa206, 0x0040, 0x2009, 0x2001, 0x0105, 0x2003,
+	0x0010, 0x20e1, 0x9040, 0x7803, 0x0004, 0x7003, 0x0000, 0x7004,
+	0x2060, 0x1078, 0x8a01, 0x20e1, 0x9040, 0x1078, 0x738a, 0x2011,
+	0x0000, 0x1078, 0x70ea, 0x0f7f, 0x0e7f, 0x0d7f, 0x0c7f, 0x027f,
+	0x007c, 0x6810, 0x6a14, 0xa205, 0x00c0, 0x1fed, 0x684c, 0xc0dc,
+	0x684e, 0x2c10, 0x1078, 0x1cf0, 0x2001, 0x0105, 0x2003, 0x0010,
+	0x20e1, 0x9040, 0x7803, 0x0004, 0x7003, 0x0000, 0x2069, 0xa8b1,
+	0x6833, 0x0000, 0x683f, 0x0000, 0x0078, 0x2003, 0x8840, 0x2804,
+	0xa005, 0x00c0, 0x203a, 0x6004, 0xa005, 0x0040, 0x203c, 0x681a,
+	0x2060, 0x6034, 0xa084, 0x000f, 0xa080, 0x206a, 0x2044, 0x88ff,
+	0x1040, 0x1332, 0x8a51, 0x007c, 0x2051, 0x0000, 0x007c, 0x8a50,
+	0x8841, 0x2804, 0xa005, 0x00c0, 0x2059, 0x2c00, 0xad06, 0x0040,
+	0x204e, 0x6000, 0xa005, 0x00c0, 0x204e, 0x2d00, 0x2060, 0x681a,
+	0x6034, 0xa084, 0x000f, 0xa080, 0x207a, 0x2044, 0x88ff, 0x1040,
+	0x1332, 0x007c, 0x0000, 0x0011, 0x0015, 0x0019, 0x001d, 0x0021,
+	0x0025, 0x0029, 0x0000, 0x000f, 0x0015, 0x001b, 0x0021, 0x0027,
+	0x0000, 0x0000, 0x0000, 0x205f, 0x205b, 0x0000, 0x0000, 0x2069,
+	0x0000, 0x205f, 0x0000, 0x2066, 0x2063, 0x0000, 0x0000, 0x0000,
+	0x2069, 0x2066, 0x0000, 0x2061, 0x2061, 0x0000, 0x0000, 0x2069,
+	0x0000, 0x2061, 0x0000, 0x2067, 0x2067, 0x0000, 0x0000, 0x0000,
+	0x2069, 0x2067, 0x0a7e, 0x097e, 0x087e, 0x6b2e, 0x6c2a, 0x6858,
+	0xa055, 0x0040, 0x212d, 0x2d60, 0x6034, 0xa0cc, 0x000f, 0xa9c0,
+	0x206a, 0xa986, 0x0007, 0x0040, 0x20a5, 0xa986, 0x000e, 0x0040,
+	0x20a5, 0xa986, 0x000f, 0x00c0, 0x20a9, 0x605c, 0xa422, 0x6060,
+	0xa31a, 0x2804, 0xa045, 0x00c0, 0x20b7, 0x0050, 0x20b1, 0x0078,
+	0x212d, 0x6004, 0xa065, 0x0040, 0x212d, 0x0078, 0x2094, 0x2804,
+	0xa005, 0x0040, 0x20d5, 0xac68, 0xd99c, 0x00c0, 0x20c5, 0x6808,
+	0xa422, 0x680c, 0xa31b, 0x0078, 0x20c9, 0x6810, 0xa422, 0x6814,
+	0xa31b, 0x0048, 0x20f4, 0x2300, 0xa405, 0x0040, 0x20db, 0x8a51,
+	0x0040, 0x212d, 0x8840, 0x0078, 0x20b7, 0x6004, 0xa065, 0x0040,
+	0x212d, 0x0078, 0x2094, 0x8a51, 0x0040, 0x212d, 0x8840, 0x2804,
+	0xa005, 0x00c0, 0x20ee, 0x6004, 0xa065, 0x0040, 0x212d, 0x6034,
+	0xa0cc, 0x000f, 0xa9c0, 0x206a, 0x2804, 0x2040, 0x2b68, 0x6850,
+	0xc0fc, 0x6852, 0x0078, 0x2121, 0x8422, 0x8420, 0x831a, 0xa399,
+	0x0000, 0x0d7e, 0x2b68, 0x6c6e, 0x6b72, 0x0d7f, 0xd99c, 0x00c0,
+	0x210f, 0x6908, 0x2400, 0xa122, 0x690c, 0x2300, 0xa11b, 0x1048,
+	0x1332, 0x6800, 0xa420, 0x6804, 0xa319, 0x0078, 0x211b, 0x6910,
+	0x2400, 0xa122, 0x6914, 0x2300, 0xa11b, 0x1048, 0x1332, 0x6800,
+	0xa420, 0x6804, 0xa319, 0x2b68, 0x6c1e, 0x6b22, 0x6850, 0xc0fd,
+	0x6852, 0x2c00, 0x681a, 0x2800, 0x6832, 0x2a00, 0x6826, 0x007f,
+	0x007f, 0x007f, 0xa006, 0x0078, 0x2132, 0x087f, 0x097f, 0x0a7f,
+	0xa085, 0x0001, 0x007c, 0x2001, 0x0005, 0x2004, 0xa084, 0x0007,
+	0x0079, 0x213a, 0x2142, 0x2143, 0x2146, 0x2149, 0x214e, 0x2151,
+	0x2156, 0x215b, 0x007c, 0x1078, 0x1eaa, 0x007c, 0x1078, 0x1913,
+	0x007c, 0x1078, 0x1913, 0x1078, 0x1eaa, 0x007c, 0x1078, 0x14be,
+	0x007c, 0x1078, 0x1eaa, 0x1078, 0x14be, 0x007c, 0x1078, 0x1913,
+	0x1078, 0x14be, 0x007c, 0x1078, 0x1913, 0x1078, 0x1eaa, 0x1078,
+	0x14be, 0x007c, 0x127e, 0x2091, 0x2300, 0x2079, 0x0200, 0x2071,
+	0xab80, 0x2069, 0xa600, 0x2009, 0x0004, 0x7912, 0x7817, 0x0004,
+	0x1078, 0x251f, 0x781b, 0x0002, 0x20e1, 0x8700, 0x127f, 0x007c,
+	0x127e, 0x2091, 0x2300, 0x781c, 0xa084, 0x0007, 0x0079, 0x2180,
+	0x21a4, 0x2188, 0x218c, 0x2190, 0x2196, 0x219a, 0x219e, 0x21a2,
+	0x1078, 0x548e, 0x0078, 0x21a4, 0x1078, 0x54da, 0x0078, 0x21a4,
+	0x1078, 0x548e, 0x1078, 0x54da, 0x0078, 0x21a4, 0x1078, 0x21a6,
+	0x0078, 0x21a4, 0x1078, 0x21a6, 0x0078, 0x21a4, 0x1078, 0x21a6,
+	0x0078, 0x21a4, 0x1078, 0x21a6, 0x127f, 0x007c, 0x007e, 0x017e,
+	0x027e, 0x1078, 0xa5d2, 0x7930, 0xa184, 0x0003, 0x0040, 0x21c9,
+	0x2001, 0xa8c0, 0x2004, 0xa005, 0x0040, 0x21c5, 0x2001, 0x0133,
+	0x2004, 0xa005, 0x1040, 0x1332, 0x0c7e, 0x2001, 0xa8c0, 0x2064,
+	0x1078, 0x8a01, 0x0c7f, 0x0078, 0x21f2, 0x20e1, 0x9040, 0x0078,
+	0x21f2, 0xa184, 0x0030, 0x0040, 0x21da, 0x6a00, 0xa286, 0x0003,
+	0x00c0, 0x21d4, 0x0078, 0x21d6, 0x1078, 0x4224, 0x20e1, 0x9010,
+	0x0078, 0x21f2, 0xa184, 0x00c0, 0x0040, 0x21ec, 0x0e7e, 0x037e,
+	0x047e, 0x057e, 0x2071, 0xa8e7, 0x1078, 0x1af4, 0x057f, 0x047f,
+	0x037f, 0x0e7f, 0x0078, 0x21f2, 0xa184, 0x0300, 0x0040, 0x21f2,
+	0x20e1, 0x9020, 0x7932, 0x027f, 0x017f, 0x007f, 0x007c, 0x017e,
+	0x0e7e, 0x0f7e, 0x2071, 0xa600, 0x7128, 0x2001, 0xa890, 0x2102,
+	0x2001, 0xa898, 0x2102, 0xa182, 0x0211, 0x00c8, 0x220b, 0x2009,
+	0x0008, 0x0078, 0x2235, 0xa182, 0x0259, 0x00c8, 0x2213, 0x2009,
+	0x0007, 0x0078, 0x2235, 0xa182, 0x02c1, 0x00c8, 0x221b, 0x2009,
+	0x0006, 0x0078, 0x2235, 0xa182, 0x0349, 0x00c8, 0x2223, 0x2009,
+	0x0005, 0x0078, 0x2235, 0xa182, 0x0421, 0x00c8, 0x222b, 0x2009,
+	0x0004, 0x0078, 0x2235, 0xa182, 0x0581, 0x00c8, 0x2233, 0x2009,
+	0x0003, 0x0078, 0x2235, 0x2009, 0x0002, 0x2079, 0x0200, 0x7912,
+	0x7817, 0x0004, 0x1078, 0x251f, 0x0f7f, 0x0e7f, 0x017f, 0x007c,
+	0x127e, 0x2091, 0x2200, 0x2061, 0x0100, 0x2071, 0xa600, 0x6024,
+	0x6026, 0x6053, 0x0030, 0x6033, 0x00ef, 0x60e7, 0x0000, 0x60eb,
+	0x00ef, 0x60e3, 0x0008, 0x604b, 0xf7f7, 0x6043, 0x0000, 0x602f,
+	0x0080, 0x602f, 0x0000, 0x6007, 0x0eaf, 0x600f, 0x00ff, 0x602b,
+	0x002f, 0x127f, 0x007c, 0x2001, 0xa630, 0x2003, 0x0000, 0x2001,
+	0xa62f, 0x2003, 0x0001, 0x007c, 0x127e, 0x2091, 0x2200, 0x007e,
+	0x017e, 0x027e, 0x6124, 0xa184, 0x002c, 0x00c0, 0x227b, 0xa184,
+	0x0007, 0x0079, 0x2281, 0xa195, 0x0004, 0xa284, 0x0007, 0x0079,
+	0x2281, 0x22ad, 0x2289, 0x228d, 0x2291, 0x2297, 0x229b, 0x22a1,
+	0x22a7, 0x1078, 0x5c56, 0x0078, 0x22ad, 0x1078, 0x5d45, 0x0078,
+	0x22ad, 0x1078, 0x5d45, 0x1078, 0x5c56, 0x0078, 0x22ad, 0x1078,
+	0x22b2, 0x0078, 0x22ad, 0x1078, 0x5c56, 0x1078, 0x22b2, 0x0078,
+	0x22ad, 0x1078, 0x5d45, 0x1078, 0x22b2, 0x0078, 0x22ad, 0x1078,
+	0x5d45, 0x1078, 0x5c56, 0x1078, 0x22b2, 0x027f, 0x017f, 0x007f,
+	0x127f, 0x007c, 0x6124, 0xd1ac, 0x0040, 0x23ac, 0x017e, 0x047e,
+	0x0c7e, 0x644c, 0xa486, 0xf0f0, 0x00c0, 0x22c5, 0x2061, 0x0100,
+	0x644a, 0x6043, 0x0090, 0x6043, 0x0010, 0x74c6, 0xa48c, 0xff00,
+	0x7034, 0xd084, 0x0040, 0x22dd, 0xa186, 0xf800, 0x00c0, 0x22dd,
+	0x703c, 0xd084, 0x00c0, 0x22dd, 0xc085, 0x703e, 0x037e, 0x2418,
+	0x2011, 0x8016, 0x1078, 0x361b, 0x037f, 0xa196, 0xff00, 0x0040,
+	0x231f, 0x6030, 0xa084, 0x00ff, 0x810f, 0xa116, 0x0040, 0x231f,
+	0x7130, 0xd184, 0x00c0, 0x231f, 0x2011, 0xa653, 0x2214, 0xd2ec,
+	0x0040, 0x22fa, 0xc18d, 0x7132, 0x2011, 0xa653, 0x2214, 0xd2ac,
+	0x00c0, 0x231f, 0x6240, 0xa294, 0x0010, 0x0040, 0x2306, 0x6248,
+	0xa294, 0xff00, 0xa296, 0xff00, 0x0040, 0x231f, 0x7030, 0xd08c,
+	0x0040, 0x2371, 0x7034, 0xd08c, 0x00c0, 0x2316, 0x2001, 0xa60c,
+	0x200c, 0xd1ac, 0x00c0, 0x2371, 0xc1ad, 0x2102, 0x037e, 0x73c4,
+	0x2011, 0x8013, 0x1078, 0x361b, 0x037f, 0x0078, 0x2371, 0x7034,
+	0xd08c, 0x00c0, 0x232b, 0x2001, 0xa60c, 0x200c, 0xd1ac, 0x00c0,
+	0x2371, 0xc1ad, 0x2102, 0x037e, 0x73c4, 0x2011, 0x8013, 0x1078,
+	0x361b, 0x037f, 0x7130, 0xc185, 0x7132, 0x2011, 0xa653, 0x220c,
+	0xd1a4, 0x0040, 0x2355, 0x017e, 0x2009, 0x0001, 0x2011, 0x0100,
+	0x1078, 0x5bf1, 0x2019, 0x000e, 0x1078, 0xa195, 0xa484, 0x00ff,
+	0xa080, 0x29c0, 0x200c, 0xa18c, 0xff00, 0x810f, 0x8127, 0xa006,
+	0x2009, 0x000e, 0x1078, 0xa21d, 0x017f, 0xd1ac, 0x00c0, 0x2362,
+	0x017e, 0x2009, 0x0000, 0x2019, 0x0004, 0x1078, 0x284f, 0x017f,
+	0x0078, 0x2371, 0x157e, 0x20a9, 0x007f, 0x2009, 0x0000, 0x1078,
+	0x45c4, 0x00c0, 0x236d, 0x1078, 0x42f8, 0x8108, 0x00f0, 0x2367,
+	0x157f, 0x0c7f, 0x047f, 0x0f7e, 0x2079, 0xa8c4, 0x783c, 0xa086,
+	0x0000, 0x0040, 0x2383, 0x6027, 0x0004, 0x783f, 0x0000, 0x2079,
+	0x0140, 0x7803, 0x0000, 0x0f7f, 0x2011, 0x0003, 0x1078, 0x70e0,
+	0x2011, 0x0002, 0x1078, 0x70ea, 0x1078, 0x6fc4, 0x037e, 0x2019,
+	0x0000, 0x1078, 0x7058, 0x037f, 0x60e3, 0x0000, 0x017f, 0x2001,
+	0xa600, 0x2014, 0xa296, 0x0004, 0x00c0, 0x23a4, 0xd19c, 0x00c0,
+	0x23ac, 0x6228, 0xc29d, 0x622a, 0x2003, 0x0001, 0x2001, 0xa622,
+	0x2003, 0x0000, 0x6027, 0x0020, 0xd194, 0x0040, 0x2490, 0x0f7e,
+	0x2079, 0xa8c4, 0x783c, 0xa086, 0x0001, 0x00c0, 0x23d0, 0x017e,
+	0x6027, 0x0004, 0x783f, 0x0000, 0x2079, 0x0140, 0x7803, 0x1000,
+	0x7803, 0x0000, 0x2079, 0xa8b1, 0x7807, 0x0000, 0x7833, 0x0000,
+	0x1078, 0x62d1, 0x1078, 0x639b, 0x017f, 0x0f7f, 0x0078, 0x2490,
+	0x0f7f, 0x017e, 0x3900, 0xa082, 0xa9e3, 0x00c8, 0x23db, 0x017e,
+	0x1078, 0x747a, 0x017f, 0x6220, 0xd2b4, 0x0040, 0x2446, 0x1078,
+	0x5acb, 0x1078, 0x6e0f, 0x6027, 0x0004, 0x0f7e, 0x2019, 0xa8ba,
+	0x2304, 0xa07d, 0x0040, 0x241c, 0x7804, 0xa086, 0x0032, 0x00c0,
+	0x241c, 0x0d7e, 0x0c7e, 0x0e7e, 0x2069, 0x0140, 0x618c, 0x6288,
+	0x7818, 0x608e, 0x7808, 0x608a, 0x6043, 0x0002, 0x2001, 0x0003,
+	0x8001, 0x00c0, 0x2400, 0x6043, 0x0000, 0x6803, 0x1000, 0x6803,
+	0x0000, 0x618e, 0x628a, 0x1078, 0x61cd, 0x1078, 0x62d1, 0x7810,
+	0x2070, 0x7037, 0x0103, 0x2f60, 0x1078, 0x772d, 0x0e7f, 0x0c7f,
+	0x0d7f, 0x0f7f, 0x017f, 0x007c, 0x0f7f, 0x0d7e, 0x2069, 0x0140,
+	0x6804, 0xa084, 0x4000, 0x0040, 0x2429, 0x6803, 0x1000, 0x6803,
+	0x0000, 0x0d7f, 0x0c7e, 0x2061, 0xa8b1, 0x6028, 0xa09a, 0x00c8,
+	0x00c8, 0x2439, 0x8000, 0x602a, 0x0c7f, 0x1078, 0x6e01, 0x0078,
+	0x248f, 0x2019, 0xa8ba, 0x2304, 0xa065, 0x0040, 0x2443, 0x2009,
+	0x0027, 0x1078, 0x775c, 0x0c7f, 0x0078, 0x248f, 0xd2bc, 0x0040,
+	0x248f, 0x1078, 0x5ad8, 0x6017, 0x0010, 0x6027, 0x0004, 0x0d7e,
+	0x2069, 0x0140, 0x6804, 0xa084, 0x4000, 0x0040, 0x245b, 0x6803,
+	0x1000, 0x6803, 0x0000, 0x0d7f, 0x0c7e, 0x2061, 0xa8b1, 0x6044,
+	0xa09a, 0x00c8, 0x00c8, 0x247e, 0x8000, 0x6046, 0x603c, 0x0c7f,
+	0xa005, 0x0040, 0x248f, 0x2009, 0x07d0, 0x1078, 0x5ad0, 0xa080,
+	0x0007, 0x2004, 0xa086, 0x0006, 0x00c0, 0x247a, 0x6017, 0x0012,
+	0x0078, 0x248f, 0x6017, 0x0016, 0x0078, 0x248f, 0x037e, 0x2019,
+	0x0001, 0x1078, 0x7058, 0x037f, 0x2019, 0xa8c0, 0x2304, 0xa065,
+	0x0040, 0x248e, 0x2009, 0x004f, 0x1078, 0x775c, 0x0c7f, 0x017f,
+	0xd19c, 0x0040, 0x24e4, 0x7034, 0xd0ac, 0x00c0, 0x24c1, 0x017e,
+	0x157e, 0x6027, 0x0008, 0x602f, 0x0020, 0x20a9, 0x000a, 0x00f0,
+	0x249f, 0x602f, 0x0000, 0x6150, 0xa185, 0x1400, 0x6052, 0x20a9,
+	0x0320, 0x00e0, 0x24a9, 0x2091, 0x6000, 0x6020, 0xd09c, 0x00c0,
+	0x24b8, 0x157f, 0x6152, 0x017f, 0x6027, 0x0008, 0x0078, 0x24e4,
+	0x1078, 0x2577, 0x00f0, 0x24a9, 0x157f, 0x6152, 0x017f, 0x6027,
+	0x0008, 0x017e, 0x6028, 0xc09c, 0x602a, 0x2011, 0x0003, 0x1078,
+	0x70e0, 0x2011, 0x0002, 0x1078, 0x70ea, 0x1078, 0x6fc4, 0x037e,
+	0x2019, 0x0000, 0x1078, 0x7058, 0x037f, 0x60e3, 0x0000, 0x1078,
+	0xa5ad, 0x1078, 0xa5cb, 0x2001, 0xa600, 0x2003, 0x0004, 0x6027,
+	0x0008, 0x1078, 0x1246, 0x017f, 0xa18c, 0xffd0, 0x6126, 0x007c,
+	0x007e, 0x017e, 0x027e, 0x0e7e, 0x0f7e, 0x127e, 0x2091, 0x8000,
+	0x2071, 0xa600, 0x71bc, 0x70be, 0xa116, 0x0040, 0x2518, 0x81ff,
+	0x0040, 0x2500, 0x2011, 0x8011, 0x1078, 0x361b, 0x0078, 0x2518,
+	0x2011, 0x8012, 0x1078, 0x361b, 0x2001, 0xa672, 0x2004, 0xd0fc,
+	0x00c0, 0x2518, 0x037e, 0x0c7e, 0x1078, 0x6f9f, 0x2061, 0x0100,
+	0x2019, 0x0028, 0x2009, 0x0000, 0x1078, 0x284f, 0x0c7f, 0x037f,
+	0x127f, 0x0f7f, 0x0e7f, 0x027f, 0x017f, 0x007f, 0x007c, 0x0c7e,
+	0x0f7e, 0x007e, 0x027e, 0x2061, 0x0100, 0xa190, 0x253b, 0x2204,
+	0x60f2, 0x2011, 0x2548, 0x6000, 0xa082, 0x0003, 0x00c8, 0x2534,
+	0x2001, 0x00ff, 0x0078, 0x2535, 0x2204, 0x60ee, 0x027f, 0x007f,
+	0x0f7f, 0x0c7f, 0x007c, 0x0840, 0x0840, 0x0840, 0x0580, 0x0420,
+	0x0348, 0x02c0, 0x0258, 0x0210, 0x01a8, 0x01a8, 0x01a8, 0x01a8,
+	0x0140, 0x00f8, 0x00d0, 0x00b0, 0x00a0, 0x2028, 0xa18c, 0x00ff,
+	0x2130, 0xa094, 0xff00, 0x00c0, 0x2558, 0x81ff, 0x0040, 0x255c,
+	0x1078, 0x5761, 0x0078, 0x2563, 0xa080, 0x29c0, 0x200c, 0xa18c,
+	0xff00, 0x810f, 0xa006, 0x007c, 0xa080, 0x29c0, 0x200c, 0xa18c,
+	0x00ff, 0x007c, 0x0c7e, 0x2061, 0xa600, 0x6030, 0x0040, 0x2573,
+	0xc09d, 0x0078, 0x2574, 0xc09c, 0x6032, 0x0c7f, 0x007c, 0x007e,
+	0x157e, 0x0f7e, 0x2079, 0x0100, 0x20a9, 0x000a, 0x7854, 0xd08c,
+	0x00c0, 0x2584, 0x00f0, 0x257e, 0x0f7f, 0x157f, 0x007f, 0x007c,
+	0x0c7e, 0x007e, 0x2061, 0x0100, 0x6030, 0x007e, 0x6048, 0x007e,
+	0x60e4, 0x007e, 0x60e8, 0x007e, 0x6050, 0x007e, 0x60f0, 0x007e,
+	0x60ec, 0x007e, 0x600c, 0x007e, 0x6004, 0x007e, 0x6028, 0x007e,
+	0x60e0, 0x007e, 0x602f, 0x0100, 0x602f, 0x0000, 0x0005, 0x0005,
+	0x0005, 0x0005, 0x602f, 0x0040, 0x602f, 0x0000, 0x007f, 0x60e2,
+	0x007f, 0x602a, 0x007f, 0x6006, 0x007f, 0x600e, 0x007f, 0x60ee,
+	0x007f, 0x60f2, 0x007f, 0x6052, 0x007f, 0x60ea, 0x007f, 0x60e6,
+	0x007f, 0x604a, 0x007f, 0x6032, 0x007f, 0x0c7f, 0x007c, 0x25e7,
+	0x25eb, 0x25ef, 0x25f5, 0x25fb, 0x2601, 0x2607, 0x260f, 0x2617,
+	0x261d, 0x2623, 0x262b, 0x2633, 0x263b, 0x2643, 0x264d, 0x2657,
+	0x2657, 0x2657, 0x2657, 0x2657, 0x2657, 0x2657, 0x2657, 0x2657,
+	0x2657, 0x2657, 0x2657, 0x2657, 0x2657, 0x2657, 0x2657, 0x107e,
+	0x007e, 0x0078, 0x2670, 0x107e, 0x007e, 0x0078, 0x2670, 0x107e,
+	0x007e, 0x1078, 0x226c, 0x0078, 0x2670, 0x107e, 0x007e, 0x1078,
+	0x226c, 0x0078, 0x2670, 0x107e, 0x007e, 0x1078, 0x2133, 0x0078,
+	0x2670, 0x107e, 0x007e, 0x1078, 0x2133, 0x0078, 0x2670, 0x107e,
+	0x007e, 0x1078, 0x226c, 0x1078, 0x2133, 0x0078, 0x2670, 0x107e,
+	0x007e, 0x1078, 0x226c, 0x1078, 0x2133, 0x0078, 0x2670, 0x107e,
+	0x007e, 0x1078, 0x2178, 0x0078, 0x2670, 0x107e, 0x007e, 0x1078,
+	0x2178, 0x0078, 0x2670, 0x107e, 0x007e, 0x1078, 0x226c, 0x1078,
+	0x2178, 0x0078, 0x2670, 0x107e, 0x007e, 0x1078, 0x226c, 0x1078,
+	0x2178, 0x0078, 0x2670, 0x107e, 0x007e, 0x1078, 0x2133, 0x1078,
+	0x2178, 0x0078, 0x2670, 0x107e, 0x007e, 0x1078, 0x2133, 0x1078,
+	0x2178, 0x0078, 0x2670, 0x107e, 0x007e, 0x1078, 0x226c, 0x1078,
+	0x2133, 0x1078, 0x2178, 0x0078, 0x2670, 0x107e, 0x007e, 0x1078,
+	0x226c, 0x1078, 0x2133, 0x1078, 0x2178, 0x0078, 0x2670, 0x0005,
+	0x0078, 0x2657, 0xb084, 0x003c, 0x8004, 0x8004, 0x0079, 0x2660,
+	0x2670, 0x25ed, 0x25f1, 0x25f7, 0x25fd, 0x2603, 0x2609, 0x2611,
+	0x2619, 0x261f, 0x2625, 0x262d, 0x2635, 0x263d, 0x2645, 0x264f,
+	0x0008, 0x265a, 0x007f, 0x107f, 0x2091, 0x8001, 0x007c, 0x0c7e,
+	0x027e, 0x047e, 0x2021, 0x0000, 0x1078, 0x4967, 0x00c0, 0x2772,
+	0x70cc, 0xd09c, 0x0040, 0x268e, 0xd084, 0x00c0, 0x268e, 0xd0bc,
+	0x00c0, 0x2772, 0x1078, 0x2776, 0x0078, 0x2772, 0xd0cc, 0x00c0,
+	0x2772, 0xd094, 0x0040, 0x2698, 0x7097, 0xffff, 0x0078, 0x2772,
+	0x2001, 0x010c, 0x203c, 0x7284, 0xd284, 0x0040, 0x2701, 0xd28c,
+	0x00c0, 0x2701, 0x037e, 0x7394, 0xa38e, 0xffff, 0x0040, 0x26ab,
+	0x83ff, 0x00c0, 0x26ad, 0x2019, 0x0001, 0x8314, 0xa2e0, 0xacc0,
+	0x2c04, 0xa38c, 0x0001, 0x0040, 0x26ba, 0xa084, 0xff00, 0x8007,
+	0x0078, 0x26bc, 0xa084, 0x00ff, 0xa70e, 0x0040, 0x26f6, 0xa08e,
+	0x0000, 0x0040, 0x26f6, 0xa08e, 0x00ff, 0x00c0, 0x26d3, 0x7230,
+	0xd284, 0x00c0, 0x26fc, 0x7284, 0xc28d, 0x7286, 0x7097, 0xffff,
+	0x037f, 0x0078, 0x2701, 0x2009, 0x0000, 0x1078, 0x254d, 0x1078,
+	0x455c, 0x00c0, 0x26f9, 0x6004, 0xa084, 0x00ff, 0xa086, 0x0006,
+	0x00c0, 0x26f0, 0x7030, 0xd08c, 0x0040, 0x26ea, 0x6000, 0xd0bc,
+	0x0040, 0x26f0, 0x1078, 0x278c, 0x0040, 0x26f9, 0x0078, 0x26f6,
+	0x1078, 0x28c4, 0x1078, 0x27b9, 0x0040, 0x26f9, 0x8318, 0x0078,
+	0x26ad, 0x7396, 0x0078, 0x26fe, 0x7097, 0xffff, 0x037f, 0x0078,
+	0x2772, 0xa780, 0x29c0, 0x203c, 0xa7bc, 0xff00, 0x873f, 0x2041,
+	0x007e, 0x7094, 0xa096, 0xffff, 0x00c0, 0x2713, 0x2009, 0x0000,
+	0x28a8, 0x0078, 0x271f, 0xa812, 0x0048, 0x271b, 0x2008, 0xa802,
+	0x20a8, 0x0078, 0x271f, 0x7097, 0xffff, 0x0078, 0x2772, 0x2700,
+	0x157e, 0x017e, 0xa106, 0x0040, 0x2766, 0xc484, 0x1078, 0x45c4,
+	0x0040, 0x2730, 0x1078, 0x455c, 0x00c0, 0x276f, 0x0078, 0x2731,
+	0xc485, 0x6004, 0xa084, 0x00ff, 0xa086, 0x0006, 0x00c0, 0x2740,
+	0x7030, 0xd08c, 0x0040, 0x275e, 0x6000, 0xd0bc, 0x00c0, 0x275e,
+	0x7284, 0xd28c, 0x0040, 0x2756, 0x6004, 0xa084, 0x00ff, 0xa082,
+	0x0006, 0x0048, 0x2766, 0xd484, 0x00c0, 0x2752, 0x1078, 0x457f,
+	0x0078, 0x2754, 0x1078, 0x298e, 0x0078, 0x2766, 0x1078, 0x28c4,
+	0x1078, 0x27b9, 0x0040, 0x276f, 0x0078, 0x2766, 0x1078, 0x2959,
+	0x0040, 0x2766, 0x1078, 0x278c, 0x0040, 0x276f, 0x017f, 0x8108,
+	0x157f, 0x00f0, 0x271f, 0x7097, 0xffff, 0x0078, 0x2772, 0x017f,
+	0x157f, 0x7196, 0x047f, 0x027f, 0x0c7f, 0x007c, 0x0c7e, 0x017e,
+	0x7097, 0x0001, 0x2009, 0x007e, 0x1078, 0x455c, 0x00c0, 0x2789,
+	0x1078, 0x28c4, 0x1078, 0x27b9, 0x0040, 0x2789, 0x70cc, 0xc0bd,
+	0x70ce, 0x017f, 0x0c7f, 0x007c, 0x017e, 0x077e, 0x0d7e, 0x0c7e,
+	0x2c68, 0x2001, 0xa657, 0x2004, 0xa084, 0x00ff, 0x6842, 0x1078,
+	0x76c7, 0x0040, 0x27b4, 0x2d00, 0x601a, 0x601f, 0x0001, 0x2001,
+	0x0000, 0x1078, 0x44ee, 0x2001, 0x0000, 0x1078, 0x4502, 0x127e,
+	0x2091, 0x8000, 0x7090, 0x8000, 0x7092, 0x127f, 0x2009, 0x0004,
+	0x1078, 0x775c, 0xa085, 0x0001, 0x0c7f, 0x0d7f, 0x077f, 0x017f,
+	0x007c, 0x017e, 0x077e, 0x0d7e, 0x0c7e, 0x2c68, 0x2001, 0xa657,
+	0x2004, 0xa084, 0x00ff, 0x6842, 0x1078, 0x9187, 0x0040, 0x27f2,
+	0x2d00, 0x601a, 0x6800, 0xc0c4, 0x6802, 0x68a0, 0xa086, 0x007e,
+	0x0040, 0x27db, 0x6804, 0xa084, 0x00ff, 0xa086, 0x0006, 0x00c0,
+	0x27db, 0x1078, 0x2880, 0x601f, 0x0001, 0x2001, 0x0000, 0x1078,
+	0x44ee, 0x2001, 0x0002, 0x1078, 0x4502, 0x127e, 0x2091, 0x8000,
+	0x7090, 0x8000, 0x7092, 0x127f, 0x2009, 0x0002, 0x1078, 0x775c,
+	0xa085, 0x0001, 0x0c7f, 0x0d7f, 0x077f, 0x017f, 0x007c, 0x0c7e,
+	0x027e, 0x2009, 0x0080, 0x1078, 0x455c, 0x00c0, 0x2805, 0x1078,
+	0x2808, 0x0040, 0x2805, 0x70d3, 0xffff, 0x027f, 0x0c7f, 0x007c,
+	0x017e, 0x077e, 0x0d7e, 0x0c7e, 0x2c68, 0x1078, 0x76c7, 0x0040,
+	0x282a, 0x2d00, 0x601a, 0x601f, 0x0001, 0x2001, 0x0000, 0x1078,
+	0x44ee, 0x2001, 0x0002, 0x1078, 0x4502, 0x127e, 0x2091, 0x8000,
+	0x70d4, 0x8000, 0x70d6, 0x127f, 0x2009, 0x0002, 0x1078, 0x775c,
+	0xa085, 0x0001, 0x0c7f, 0x0d7f, 0x077f, 0x017f, 0x007c, 0x0c7e,
+	0x0d7e, 0x127e, 0x2091, 0x8000, 0x2009, 0x007f, 0x1078, 0x455c,
+	0x00c0, 0x284b, 0x2c68, 0x1078, 0x76c7, 0x0040, 0x284b, 0x2d00,
+	0x601a, 0x6312, 0x601f, 0x0001, 0x620a, 0x2009, 0x0022, 0x1078,
+	0x775c, 0xa085, 0x0001, 0x127f, 0x0d7f, 0x0c7f, 0x007c, 0x0e7e,
+	0x0c7e, 0x067e, 0x037e, 0x027e, 0x1078, 0x5f0e, 0x1078, 0x5eae,
+	0x1078, 0x8068, 0x2130, 0x81ff, 0x0040, 0x2864, 0x20a9, 0x007e,
+	0x2009, 0x0000, 0x0078, 0x2868, 0x20a9, 0x007f, 0x2009, 0x0000,
+	0x017e, 0x1078, 0x45c4, 0x00c0, 0x2871, 0x1078, 0x47e9, 0x1078,
+	0x42f8, 0x017f, 0x8108, 0x00f0, 0x2868, 0x86ff, 0x00c0, 0x287a,
+	0x1078, 0x119b, 0x027f, 0x037f, 0x067f, 0x0c7f, 0x0e7f, 0x007c,
+	0x0e7e, 0x0c7e, 0x037e, 0x027e, 0x017e, 0x6218, 0x2270, 0x72a0,
+	0x027e, 0x2019, 0x0029, 0x1078, 0x5f01, 0x077e, 0x2039, 0x0000,
+	0x1078, 0x5e0a, 0x2c08, 0x1078, 0x9f8b, 0x077f, 0x017f, 0x2e60,
+	0x1078, 0x47e9, 0x6210, 0x6314, 0x1078, 0x42f8, 0x6212, 0x6316,
+	0x017f, 0x027f, 0x037f, 0x0c7f, 0x0e7f, 0x007c, 0x0e7e, 0x007e,
+	0x6018, 0xa080, 0x0028, 0x2004, 0xd0bc, 0x00c0, 0x28ba, 0x2071,
+	0xa600, 0x7090, 0xa005, 0x0040, 0x28b7, 0x8001, 0x7092, 0x007f,
+	0x0e7f, 0x007c, 0x2071, 0xa600, 0x70d4, 0xa005, 0x0040, 0x28b7,
+	0x8001, 0x70d6, 0x0078, 0x28b7, 0x6000, 0xc08c, 0x6002, 0x007c,
+	0x0f7e, 0x0e7e, 0x0c7e, 0x037e, 0x027e, 0x017e, 0x157e, 0x2178,
+	0x81ff, 0x00c0, 0x28d7, 0x20a9, 0x0001, 0x0078, 0x28f2, 0x2001,
+	0xa653, 0x2004, 0xd0c4, 0x0040, 0x28ee, 0xd0a4, 0x0040, 0x28ee,
+	0x047e, 0x6018, 0xa080, 0x0028, 0x2024, 0xa4a4, 0x00ff, 0x8427,
+	0xa006, 0x2009, 0x002d, 0x1078, 0xa21d, 0x047f, 0x20a9, 0x00ff,
+	0x2011, 0x0000, 0x027e, 0xa28e, 0x007e, 0x0040, 0x2936, 0xa28e,
+	0x007f, 0x0040, 0x2936, 0xa28e, 0x0080, 0x0040, 0x2936, 0xa288,
+	0xa735, 0x210c, 0x81ff, 0x0040, 0x2936, 0x8fff, 0x1040, 0x2942,
+	0x0c7e, 0x2160, 0x2001, 0x0001, 0x1078, 0x4972, 0x0c7f, 0x2019,
+	0x0029, 0x1078, 0x5f01, 0x077e, 0x2039, 0x0000, 0x1078, 0x5e0a,
+	0x0c7e, 0x027e, 0x2160, 0x6204, 0xa294, 0x00ff, 0xa286, 0x0006,
+	0x00c0, 0x2926, 0x6007, 0x0404, 0x0078, 0x292b, 0x2001, 0x0004,
+	0x8007, 0xa215, 0x6206, 0x027f, 0x0c7f, 0x017e, 0x2c08, 0x1078,
+	0x9f8b, 0x017f, 0x077f, 0x2160, 0x1078, 0x47e9, 0x027f, 0x8210,
+	0x00f0, 0x28f2, 0x157f, 0x017f, 0x027f, 0x037f, 0x0c7f, 0x0e7f,
+	0x0f7f, 0x007c, 0x047e, 0x027e, 0x017e, 0x2001, 0xa653, 0x2004,
+	0xd0c4, 0x0040, 0x2955, 0xd0a4, 0x0040, 0x2955, 0xa006, 0x2220,
+	0x8427, 0x2009, 0x0029, 0x1078, 0xa21d, 0x017f, 0x027f, 0x047f,
+	0x007c, 0x017e, 0x027e, 0x037e, 0x0c7e, 0x7284, 0x82ff, 0x0040,
+	0x2987, 0xa290, 0xa653, 0x2214, 0xd2ac, 0x00c0, 0x2987, 0x2100,
+	0x1078, 0x2564, 0x81ff, 0x0040, 0x2989, 0x2019, 0x0001, 0x8314,
+	0xa2e0, 0xacc0, 0x2c04, 0xd384, 0x0040, 0x297b, 0xa084, 0xff00,
+	0x8007, 0x0078, 0x297d, 0xa084, 0x00ff, 0xa116, 0x0040, 0x2989,
+	0xa096, 0x00ff, 0x0040, 0x2987, 0x8318, 0x0078, 0x296f, 0xa085,
+	0x0001, 0x0c7f, 0x037f, 0x027f, 0x017f, 0x007c, 0x017e, 0x0c7e,
+	0x127e, 0x2091, 0x8000, 0x017e, 0x027e, 0x037e, 0x2110, 0x027e,
+	0x2019, 0x0029, 0x1078, 0x73d0, 0x027f, 0x1078, 0xa4f1, 0x037f,
+	0x027f, 0x017f, 0xa180, 0xa735, 0x2004, 0xa065, 0x0040, 0x29b7,
+	0x017e, 0x0c7e, 0x1078, 0x9187, 0x017f, 0x1040, 0x1332, 0x611a,
+	0x1078, 0x2880, 0x1078, 0x772d, 0x017f, 0x1078, 0x457f, 0x127f,
+	0x0c7f, 0x017f, 0x007c, 0x2001, 0xa633, 0x2004, 0xd0cc, 0x007c,
+	0x7eef, 0x7de8, 0x7ce4, 0x80e2, 0x7be1, 0x80e0, 0x80dc, 0x80da,
+	0x7ad9, 0x80d6, 0x80d5, 0x80d4, 0x80d3, 0x80d2, 0x80d1, 0x79ce,
+	0x78cd, 0x80cc, 0x80cb, 0x80ca, 0x80c9, 0x80c7, 0x80c6, 0x77c5,
+	0x76c3, 0x80bc, 0x80ba, 0x75b9, 0x80b6, 0x74b5, 0x73b4, 0x72b3,
+	0x80b2, 0x80b1, 0x80ae, 0x71ad, 0x80ac, 0x70ab, 0x6faa, 0x6ea9,
+	0x80a7, 0x6da6, 0x6ca5, 0x6ba3, 0x6a9f, 0x699e, 0x689d, 0x809b,
+	0x8098, 0x6797, 0x6690, 0x658f, 0x6488, 0x6384, 0x6282, 0x8081,
+	0x8080, 0x617c, 0x607a, 0x8079, 0x5f76, 0x8075, 0x8074, 0x8073,
+	0x8072, 0x8071, 0x806e, 0x5e6d, 0x806c, 0x5d6b, 0x5c6a, 0x5b69,
+	0x8067, 0x5a66, 0x5965, 0x5863, 0x575c, 0x565a, 0x5559, 0x8056,
+	0x8055, 0x5454, 0x5353, 0x5252, 0x5151, 0x504e, 0x4f4d, 0x804c,
+	0x804b, 0x4e4a, 0x4d49, 0x8047, 0x4c46, 0x8045, 0x8043, 0x803c,
+	0x803a, 0x8039, 0x8036, 0x4b35, 0x8034, 0x4a33, 0x4932, 0x4831,
+	0x802e, 0x472d, 0x462c, 0x452b, 0x442a, 0x4329, 0x4227, 0x8026,
+	0x8025, 0x4123, 0x401f, 0x3f1e, 0x3e1d, 0x3d1b, 0x3c18, 0x8017,
+	0x8010, 0x3b0f, 0x3a08, 0x8004, 0x3902, 0x8001, 0x8000, 0x8000,
+	0x3800, 0x3700, 0x3600, 0x8000, 0x3500, 0x8000, 0x8000, 0x8000,
+	0x3400, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x3300,
+	0x3200, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x3100,
+	0x3000, 0x8000, 0x8000, 0x2f00, 0x8000, 0x2e00, 0x2d00, 0x2c00,
+	0x8000, 0x8000, 0x8000, 0x2b00, 0x8000, 0x2a00, 0x2900, 0x2800,
+	0x8000, 0x2700, 0x2600, 0x2500, 0x2400, 0x2300, 0x2200, 0x8000,
+	0x8000, 0x2100, 0x2000, 0x1f00, 0x1e00, 0x1d00, 0x1c00, 0x8000,
+	0x8000, 0x1b00, 0x1a00, 0x8000, 0x1900, 0x8000, 0x8000, 0x8000,
+	0x8000, 0x8000, 0x8000, 0x1800, 0x8000, 0x1700, 0x1600, 0x1500,
+	0x8000, 0x1400, 0x1300, 0x1200, 0x1100, 0x1000, 0x0f00, 0x8000,
+	0x8000, 0x0e00, 0x0d00, 0x0c00, 0x0b00, 0x0a00, 0x0900, 0x8000,
+	0x8000, 0x0800, 0x0700, 0x8000, 0x0600, 0x8000, 0x8000, 0x8000,
+	0x0500, 0x0400, 0x0300, 0x8000, 0x0200, 0x8000, 0x8000, 0x8000,
+	0x0100, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000,
+	0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
+	0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
+	0x2071, 0xa682, 0x7003, 0x0002, 0xa006, 0x7012, 0x7016, 0x703a,
+	0x703e, 0x7033, 0xa692, 0x7037, 0xa692, 0x7007, 0x0001, 0x2061,
+	0xa6d2, 0x6003, 0x0002, 0x007c, 0x0090, 0x2ae7, 0x0068, 0x2ae7,
+	0x2071, 0xa682, 0x2b78, 0x7818, 0xd084, 0x00c0, 0x2ae7, 0x2a60,
+	0x7820, 0xa08e, 0x0069, 0x00c0, 0x2bd7, 0x0079, 0x2b6b, 0x007c,
+	0x2071, 0xa682, 0x7004, 0x0079, 0x2aed, 0x2af1, 0x2af2, 0x2afc,
+	0x2b0e, 0x007c, 0x0090, 0x2afb, 0x0068, 0x2afb, 0x2b78, 0x7818,
+	0xd084, 0x0040, 0x2b1a, 0x007c, 0x2b78, 0x2061, 0xa6d2, 0x6008,
+	0xa08e, 0x0100, 0x0040, 0x2b09, 0xa086, 0x0200, 0x0040, 0x2bcf,
+	0x007c, 0x7014, 0x2068, 0x2a60, 0x7018, 0x007a, 0x7010, 0x2068,
+	0x6834, 0xa086, 0x0103, 0x0040, 0x2b16, 0x007c, 0x2a60, 0x2b78,
+	0x7018, 0x007a, 0x2a60, 0x7820, 0xa08a, 0x0040, 0x00c8, 0x2b23,
+	0x61bc, 0x0079, 0x2b2b, 0x2100, 0xa08a, 0x003f, 0x00c8, 0x2bcb,
+	0x61bc, 0x0079, 0x2b6b, 0x2bad, 0x2bdf, 0x2be7, 0x2beb, 0x2bf3,
+	0x2bf9, 0x2bfd, 0x2c09, 0x2c0d, 0x2c17, 0x2c1b, 0x2bcb, 0x2bcb,
+	0x2bcb, 0x2c1f, 0x2bcb, 0x2c2f, 0x2c46, 0x2c5d, 0x2cdd, 0x2ce2,
+	0x2d0f, 0x2d69, 0x2d7a, 0x2d98, 0x2dd9, 0x2de3, 0x2df0, 0x2e03,
+	0x2e22, 0x2e2b, 0x2e68, 0x2e6e, 0x2bcb, 0x2e8a, 0x2bcb, 0x2bcb,
+	0x2bcb, 0x2bcb, 0x2bcb, 0x2e91, 0x2e9b, 0x2bcb, 0x2bcb, 0x2bcb,
+	0x2bcb, 0x2bcb, 0x2bcb, 0x2bcb, 0x2bcb, 0x2ea3, 0x2bcb, 0x2bcb,
+	0x2bcb, 0x2bcb, 0x2bcb, 0x2eb5, 0x2ece, 0x2bcb, 0x2bcb, 0x2bcb,
+	0x2bcb, 0x2bcb, 0x2bcb, 0x2ee0, 0x2f37, 0x2f95, 0x2fa9, 0x2bcb,
+	0x2bcb, 0x2bcb, 0x398e, 0x2bcb, 0x2bcb, 0x2bcb, 0x2bcb, 0x2bcb,
+	0x2bcb, 0x2bcb, 0x2bcb, 0x2c17, 0x2c1b, 0x2fc0, 0x2bcb, 0x2fcd,
+	0x3a26, 0x3a83, 0x2bcb, 0x2bcb, 0x2bcb, 0x2bcb, 0x2bcb, 0x2bcb,
+	0x2bcb, 0x2bcb, 0x2bcb, 0x301a, 0x314f, 0x316b, 0x3177, 0x31da,
+	0x3233, 0x323e, 0x327d, 0x328c, 0x329b, 0x329e, 0x2fd1, 0x32c2,
+	0x331e, 0x332b, 0x343c, 0x356f, 0x3599, 0x36a6, 0x2bcb, 0x36b6,
+	0x36f0, 0x37bf, 0x2bcb, 0x2bcb, 0x2bcb, 0x2bcb, 0x3827, 0x3843,
+	0x38bd, 0x3977, 0x713c, 0x0078, 0x2bad, 0x2021, 0x4000, 0x1078,
+	0x35f5, 0x127e, 0x2091, 0x8000, 0x0068, 0x2bba, 0x7818, 0xd084,
+	0x0040, 0x2bbd, 0x127f, 0x0078, 0x2bb1, 0x7c22, 0x7926, 0x7a2a,
+	0x7b2e, 0x781b, 0x0001, 0x2091, 0x4080, 0x7007, 0x0001, 0x2091,
+	0x5000, 0x127f, 0x007c, 0x2021, 0x4001, 0x0078, 0x2baf, 0x2021,
+	0x4002, 0x0078, 0x2baf, 0x2021, 0x4003, 0x0078, 0x2baf, 0x2021,
+	0x4005, 0x0078, 0x2baf, 0x2021, 0x4006, 0x0078, 0x2baf, 0xa02e,
+	0x2520, 0x7b28, 0x7a2c, 0x7824, 0x7930, 0x0078, 0x3604, 0x7823,
+	0x0004, 0x7824, 0x007a, 0xa02e, 0x2520, 0x7b28, 0x7a2c, 0x7824,
+	0x7930, 0x0078, 0x3608, 0x7924, 0x7828, 0x2114, 0x200a, 0x0078,
+	0x2bad, 0x7924, 0x2114, 0x0078, 0x2bad, 0x2099, 0x0009, 0x20a1,
+	0x0009, 0x20a9, 0x0007, 0x53a3, 0x7924, 0x7a28, 0x7b2c, 0x0078,
+	0x2bad, 0x7824, 0x2060, 0x0078, 0x2c21, 0x2009, 0x0001, 0x2011,
+	0x0013, 0x2019, 0x0018, 0x783b, 0x0017, 0x0078, 0x2bad, 0x7d38,
+	0x7c3c, 0x0078, 0x2be1, 0x7d38, 0x7c3c, 0x0078, 0x2bed, 0x2061,
+	0x1000, 0x610c, 0xa006, 0x2c14, 0xa200, 0x8c60, 0x8109, 0x00c0,
+	0x2c23, 0x2010, 0xa005, 0x0040, 0x2bad, 0x0078, 0x2bd3, 0x2069,
+	0xa652, 0x7824, 0x7930, 0xa11a, 0x00c8, 0x2bdb, 0x8019, 0x0040,
+	0x2bdb, 0x684a, 0x6942, 0x782c, 0x6852, 0x7828, 0x6856, 0xa006,
+	0x685a, 0x685e, 0x1078, 0x4eae, 0x0078, 0x2bad, 0x2069, 0xa652,
+	0x7824, 0x7934, 0xa11a, 0x00c8, 0x2bdb, 0x8019, 0x0040, 0x2bdb,
+	0x684e, 0x6946, 0x782c, 0x6862, 0x7828, 0x6866, 0xa006, 0x686a,
+	0x686e, 0x1078, 0x4a3e, 0x0078, 0x2bad, 0xa02e, 0x2520, 0x81ff,
+	0x00c0, 0x2bd7, 0x7924, 0x7b28, 0x7a2c, 0x20a9, 0x0005, 0x20a1,
+	0xa689, 0x41a1, 0x1078, 0x35ba, 0x0040, 0x2bd7, 0x2009, 0x0020,
+	0x1078, 0x3604, 0x701b, 0x2c75, 0x007c, 0x6834, 0x2008, 0xa084,
+	0x00ff, 0xa096, 0x0011, 0x0040, 0x2c85, 0xa096, 0x0019, 0x0040,
+	0x2c85, 0xa096, 0x0015, 0x00c0, 0x2bd7, 0x810f, 0xa18c, 0x00ff,
+	0x0040, 0x2bd7, 0x710e, 0x700c, 0x8001, 0x0040, 0x2cb6, 0x700e,
+	0x1078, 0x35ba, 0x0040, 0x2bd7, 0x2009, 0x0020, 0x2061, 0xa6d2,
+	0x6224, 0x6328, 0x642c, 0x6530, 0xa290, 0x0040, 0xa399, 0x0000,
+	0xa4a1, 0x0000, 0xa5a9, 0x0000, 0x1078, 0x3604, 0x701b, 0x2ca9,
+	0x007c, 0x6834, 0xa084, 0x00ff, 0xa096, 0x0002, 0x0040, 0x2cb4,
+	0xa096, 0x000a, 0x00c0, 0x2bd7, 0x0078, 0x2c8b, 0x7010, 0x2068,
+	0x6838, 0xc0fd, 0x683a, 0x1078, 0x4431, 0x00c0, 0x2cc4, 0x7007,
+	0x0003, 0x701b, 0x2cc6, 0x007c, 0x1078, 0x4b51, 0x127e, 0x2091,
+	0x8000, 0x20a9, 0x0005, 0x2099, 0xa689, 0x530a, 0x2100, 0xa210,
+	0xa399, 0x0000, 0xa4a1, 0x0000, 0xa5a9, 0x0000, 0xad80, 0x000d,
+	0x2009, 0x0020, 0x127f, 0x0078, 0x3608, 0x61a4, 0x7824, 0x60a6,
+	0x0078, 0x2bad, 0x2091, 0x8000, 0x7823, 0x4000, 0x7827, 0x4953,
+	0x782b, 0x5020, 0x782f, 0x2020, 0x2009, 0x017f, 0x2104, 0x7832,
+	0x3f00, 0x7836, 0x2061, 0x0100, 0x6200, 0x2061, 0x0200, 0x603c,
+	0x8007, 0xa205, 0x783a, 0x2009, 0x04fd, 0x2104, 0x783e, 0x781b,
+	0x0001, 0x2091, 0x5000, 0x2091, 0x4080, 0x2071, 0x0010, 0x20c1,
+	0x00f0, 0xa08a, 0x0003, 0x00c8, 0x0427, 0x0078, 0x0423, 0x81ff,
+	0x00c0, 0x2bd7, 0x7924, 0x810f, 0xa18c, 0x00ff, 0x1078, 0x45c4,
+	0x00c0, 0x2bdb, 0x7e38, 0xa684, 0x3fff, 0xa082, 0x4000, 0x0048,
+	0x2d23, 0x0078, 0x2bdb, 0x7c28, 0x7d2c, 0x1078, 0x47a4, 0xd28c,
+	0x00c0, 0x2d2e, 0x1078, 0x4736, 0x0078, 0x2d30, 0x1078, 0x4772,
+	0x00c0, 0x2d5a, 0x2061, 0xad00, 0x127e, 0x2091, 0x8000, 0x6000,
+	0xa086, 0x0000, 0x0040, 0x2d48, 0x6010, 0xa06d, 0x0040, 0x2d48,
+	0x683c, 0xa406, 0x00c0, 0x2d48, 0x6840, 0xa506, 0x0040, 0x2d53,
+	0x127f, 0xace0, 0x0010, 0x2001, 0xa616, 0x2004, 0xac02, 0x00c8,
+	0x2bd7, 0x0078, 0x2d34, 0x1078, 0x8a01, 0x127f, 0x0040, 0x2bd7,
+	0x0078, 0x2bad, 0xa00e, 0x2001, 0x0005, 0x1078, 0x4b51, 0x127e,
+	0x2091, 0x8000, 0x1078, 0x8f85, 0x1078, 0x4a73, 0x127f, 0x0078,
+	0x2bad, 0x81ff, 0x00c0, 0x2bd7, 0x1078, 0x35d2, 0x0040, 0x2bdb,
+	0x1078, 0x4673, 0x0040, 0x2bd7, 0x1078, 0x47b2, 0x0040, 0x2bd7,
+	0x0078, 0x2bad, 0x81ff, 0x00c0, 0x2bd7, 0x1078, 0x35e4, 0x0040,
+	0x2bdb, 0x1078, 0x482f, 0x0040, 0x2bd7, 0x2019, 0x0005, 0x1078,
+	0x47d3, 0x0040, 0x2bd7, 0x7828, 0xa08a, 0x1000, 0x00c8, 0x2bdb,
+	0x8003, 0x800b, 0x810b, 0xa108, 0x1078, 0x5a52, 0x0078, 0x2bad,
+	0x127e, 0x2091, 0x8000, 0x81ff, 0x0040, 0x2da2, 0x2009, 0x0001,
+	0x0078, 0x2dd3, 0x2029, 0x00ff, 0x6450, 0x2400, 0xa506, 0x0040,
+	0x2dcd, 0x2508, 0x1078, 0x45c4, 0x00c0, 0x2dcd, 0x1078, 0x482f,
+	0x00c0, 0x2db8, 0x2009, 0x0002, 0x62ac, 0x2518, 0x0078, 0x2dd3,
+	0x2019, 0x0004, 0x1078, 0x47d3, 0x00c0, 0x2dc2, 0x2009, 0x0006,
+	0x0078, 0x2dd3, 0x7824, 0xa08a, 0x1000, 0x00c8, 0x2dd6, 0x8003,
+	0x800b, 0x810b, 0xa108, 0x1078, 0x5a52, 0x8529, 0x00c8, 0x2da5,
+	0x127f, 0x0078, 0x2bad, 0x127f, 0x0078, 0x2bd7, 0x127f, 0x0078,
+	0x2bdb, 0x1078, 0x35d2, 0x0040, 0x2bdb, 0x1078, 0x46e7, 0x1078,
+	0x47a4, 0x0078, 0x2bad, 0x81ff, 0x00c0, 0x2bd7, 0x1078, 0x35d2,
+	0x0040, 0x2bdb, 0x1078, 0x46d6, 0x1078, 0x47a4, 0x0078, 0x2bad,
+	0x81ff, 0x00c0, 0x2bd7, 0x1078, 0x35d2, 0x0040, 0x2bdb, 0x1078,
+	0x4775, 0x0040, 0x2bd7, 0x1078, 0x4484, 0x1078, 0x472f, 0x1078,
+	0x47a4, 0x0078, 0x2bad, 0x1078, 0x35d2, 0x0040, 0x2bdb, 0x1078,
+	0x4673, 0x0040, 0x2bd7, 0x62a0, 0x2019, 0x0005, 0x0c7e, 0x1078,
+	0x47e9, 0x0c7f, 0x1078, 0x5f01, 0x077e, 0x2039, 0x0000, 0x1078,
+	0x5e0a, 0x2009, 0x0000, 0x1078, 0x9f8b, 0x077f, 0x1078, 0x47a4,
+	0x0078, 0x2bad, 0x1078, 0x35d2, 0x0040, 0x2bdb, 0x1078, 0x47a4,
+	0x2208, 0x0078, 0x2bad, 0x157e, 0x0d7e, 0x0e7e, 0x2069, 0xa714,
+	0x6810, 0x6914, 0xa10a, 0x00c8, 0x2e37, 0x2009, 0x0000, 0x6816,
+	0x2011, 0x0000, 0x2019, 0x0000, 0x20a9, 0x00ff, 0x2069, 0xa735,
+	0x2d04, 0xa075, 0x0040, 0x2e4c, 0x704c, 0x1078, 0x2e56, 0xa210,
+	0x7080, 0x1078, 0x2e56, 0xa318, 0x8d68, 0x00f0, 0x2e40, 0x2300,
+	0xa218, 0x0e7f, 0x0d7f, 0x157f, 0x0078, 0x2bad, 0x0f7e, 0x017e,
+	0xa07d, 0x0040, 0x2e65, 0x2001, 0x0000, 0x8000, 0x2f0c, 0x81ff,
+	0x0040, 0x2e65, 0x2178, 0x0078, 0x2e5d, 0x017f, 0x0f7f, 0x007c,
+	0x2069, 0xa714, 0x6910, 0x62a8, 0x0078, 0x2bad, 0x81ff, 0x00c0,
+	0x2bd7, 0x6150, 0xa190, 0x29c0, 0x2214, 0xa294, 0x00ff, 0x6070,
+	0xa084, 0xff00, 0xa215, 0x636c, 0x67cc, 0xd79c, 0x0040, 0x2e84,
+	0x2031, 0x0001, 0x0078, 0x2e86, 0x2031, 0x0000, 0x7e3a, 0x7f3e,
+	0x0078, 0x2bad, 0x6140, 0x6244, 0x2019, 0xa8a2, 0x231c, 0x0078,
+	0x2bad, 0x127e, 0x2091, 0x8000, 0x6134, 0x6338, 0xa006, 0x2010,
+	0x127f, 0x0078, 0x2bad, 0x1078, 0x35e4, 0x0040, 0x2bdb, 0x6244,
+	0x6338, 0x0078, 0x2bad, 0x6140, 0x6244, 0x7824, 0x6042, 0x7b28,
+	0x6346, 0x2069, 0xa652, 0x831f, 0xa305, 0x6816, 0x782c, 0x2069,
+	0xa8a2, 0x2d1c, 0x206a, 0x0078, 0x2bad, 0x017e, 0x127e, 0x2091,
+	0x8000, 0x7824, 0x6036, 0xd094, 0x0040, 0x2ec8, 0x7828, 0xa085,
+	0x0001, 0x2009, 0xa8ab, 0x200a, 0x2001, 0xffff, 0x1078, 0x5ae6,
+	0x782c, 0x603a, 0x127f, 0x017f, 0x0078, 0x2bad, 0x1078, 0x35e4,
+	0x0040, 0x2bdb, 0x7828, 0xa00d, 0x0040, 0x2bdb, 0x782c, 0xa005,
+	0x0040, 0x2bdb, 0x6244, 0x6146, 0x6338, 0x603a, 0x0078, 0x2bad,
+	0x2001, 0xa600, 0x2004, 0xa086, 0x0003, 0x00c0, 0x2bd7, 0x0c7e,
+	0x2061, 0x0100, 0x7924, 0x810f, 0xa18c, 0x00ff, 0xa196, 0x00ff,
+	0x00c0, 0x2ef7, 0x6030, 0xa085, 0xff00, 0x0078, 0x2f06, 0xa182,
+	0x007f, 0x00c8, 0x2f30, 0xa188, 0x29c0, 0x210c, 0xa18c, 0x00ff,
+	0x6030, 0xa116, 0x0040, 0x2f30, 0x810f, 0xa105, 0x127e, 0x2091,
+	0x8000, 0x007e, 0x1078, 0x76c7, 0x007f, 0x0040, 0x2f2c, 0x601a,
+	0x600b, 0xbc09, 0x601f, 0x0001, 0x1078, 0x35ba, 0x0040, 0x2f33,
+	0x6837, 0x0000, 0x7007, 0x0003, 0x6833, 0x0000, 0x6838, 0xc0fd,
+	0x683a, 0x701b, 0x2f8e, 0x2d00, 0x6012, 0x2009, 0x0032, 0x1078,
+	0x775c, 0x127f, 0x0c7f, 0x007c, 0x127f, 0x0c7f, 0x0078, 0x2bd7,
+	0x0c7f, 0x0078, 0x2bdb, 0x1078, 0x772d, 0x0078, 0x2f2c, 0x2001,
+	0xa600, 0x2004, 0xa086, 0x0003, 0x00c0, 0x2bd7, 0x0c7e, 0x2061,
+	0x0100, 0x7924, 0x810f, 0xa18c, 0x00ff, 0xa196, 0x00ff, 0x00c0,
+	0x2f4e, 0x6030, 0xa085, 0xff00, 0x0078, 0x2f5d, 0xa182, 0x007f,
+	0x00c8, 0x2f87, 0xa188, 0x29c0, 0x210c, 0xa18c, 0x00ff, 0x6030,
+	0xa116, 0x0040, 0x2f87, 0x810f, 0xa105, 0x127e, 0x2091, 0x8000,
+	0x007e, 0x1078, 0x76c7, 0x007f, 0x0040, 0x2f83, 0x601a, 0x600b,
+	0xbc05, 0x601f, 0x0001, 0x1078, 0x35ba, 0x0040, 0x2f8a, 0x6837,
+	0x0000, 0x7007, 0x0003, 0x6833, 0x0000, 0x6838, 0xc0fd, 0x683a,
+	0x701b, 0x2f8e, 0x2d00, 0x6012, 0x2009, 0x0032, 0x1078, 0x775c,
+	0x127f, 0x0c7f, 0x007c, 0x127f, 0x0c7f, 0x0078, 0x2bd7, 0x0c7f,
+	0x0078, 0x2bdb, 0x1078, 0x772d, 0x0078, 0x2f83, 0x6830, 0xa086,
+	0x0100, 0x0040, 0x2bd7, 0x0078, 0x2bad, 0x2061, 0xa933, 0x127e,
+	0x2091, 0x8000, 0x6000, 0xd084, 0x0040, 0x2fa6, 0x6104, 0x6208,
+	0x2019, 0xa612, 0x231c, 0x127f, 0x0078, 0x2bad, 0x127f, 0x0078,
+	0x2bdb, 0x81ff, 0x00c0, 0x2bd7, 0x127e, 0x2091, 0x8000, 0x6248,
+	0x6064, 0xa202, 0x0048, 0x2fbd, 0xa085, 0x0001, 0x1078, 0x256a,
+	0x1078, 0x3c9e, 0x127f, 0x0078, 0x2bad, 0x127f, 0x0078, 0x2bdb,
+	0x127e, 0x2091, 0x8000, 0x20a9, 0x0012, 0x2001, 0xa640, 0x20a0,
+	0xa006, 0x40a4, 0x127f, 0x0078, 0x2bad, 0x7d38, 0x7c3c, 0x0078,
+	0x2c5f, 0x7824, 0xa09c, 0x00ff, 0xa39a, 0x0003, 0x00c8, 0x2bd7,
+	0x6250, 0xa084, 0xff00, 0x8007, 0xa206, 0x00c0, 0x2fe9, 0x2001,
+	0xa640, 0x2009, 0x000c, 0x7a2c, 0x7b28, 0x7c3c, 0x7d38, 0x0078,
+	0x3608, 0x81ff, 0x00c0, 0x2bd7, 0x1078, 0x35e4, 0x0040, 0x2bdb,
+	0x6004, 0xa084, 0x00ff, 0xa086, 0x0006, 0x00c0, 0x2bd7, 0x0c7e,
+	0x1078, 0x35ba, 0x0c7f, 0x0040, 0x2bd7, 0x6837, 0x0000, 0x6838,
+	0xc0fd, 0x683a, 0x1078, 0x8e4a, 0x0040, 0x2bd7, 0x7007, 0x0003,
+	0x701b, 0x300b, 0x007c, 0x6830, 0xa086, 0x0100, 0x0040, 0x2bd7,
+	0xad80, 0x000e, 0x2009, 0x000c, 0x7a2c, 0x7b28, 0x7c3c, 0x7d38,
+	0x0078, 0x3608, 0x1078, 0x35ba, 0x0040, 0x2bd7, 0x1078, 0x42dd,
+	0x2009, 0x001c, 0x7a2c, 0x7b28, 0x7c3c, 0x7d38, 0x1078, 0x3604,
+	0x701b, 0x302b, 0x007c, 0xade8, 0x000d, 0x6800, 0xa005, 0x0040,
+	0x2bdb, 0x6804, 0xd0ac, 0x0040, 0x3038, 0xd0a4, 0x0040, 0x2bdb,
+	0xd094, 0x0040, 0x3043, 0x0c7e, 0x2061, 0x0100, 0x6104, 0xa18c,
+	0xffdf, 0x6106, 0x0c7f, 0xd08c, 0x0040, 0x304e, 0x0c7e, 0x2061,
+	0x0100, 0x6104, 0xa18d, 0x0010, 0x6106, 0x0c7f, 0x2009, 0x0100,
+	0x210c, 0xa18a, 0x0002, 0x0048, 0x3063, 0xd084, 0x0040, 0x3063,
+	0x6a28, 0xa28a, 0x007f, 0x00c8, 0x2bdb, 0xa288, 0x29c0, 0x210c,
+	0xa18c, 0x00ff, 0x6156, 0xd0dc, 0x0040, 0x306c, 0x6828, 0xa08a,
+	0x007f, 0x00c8, 0x2bdb, 0x6052, 0x6808, 0xa08a, 0x0100, 0x0048,
+	0x2bdb, 0xa08a, 0x0841, 0x00c8, 0x2bdb, 0xa084, 0x0007, 0x00c0,
+	0x2bdb, 0x680c, 0xa005, 0x0040, 0x2bdb, 0x6810, 0xa005, 0x0040,
+	0x2bdb, 0x6848, 0x6940, 0xa10a, 0x00c8, 0x2bdb, 0x8001, 0x0040,
+	0x2bdb, 0x684c, 0x6944, 0xa10a, 0x00c8, 0x2bdb, 0x8001, 0x0040,
+	0x2bdb, 0x6804, 0xd0fc, 0x0040, 0x30c2, 0x1078, 0x35ba, 0x0040,
+	0x2bd7, 0x2009, 0x0014, 0x7a2c, 0x7b28, 0x7c3c, 0x7d38, 0xa290,
+	0x0038, 0xa399, 0x0000, 0x1078, 0x3604, 0x701b, 0x30a8, 0x007c,
+	0xade8, 0x000d, 0x20a9, 0x0014, 0x2d98, 0x2069, 0xa66e, 0x2da0,
+	0x53a3, 0x7010, 0xa0e8, 0x000d, 0x2001, 0xa672, 0x200c, 0xd1e4,
+	0x0040, 0x30c2, 0x0c7e, 0x2061, 0x0100, 0x6004, 0xa085, 0x0b00,
+	0x6006, 0x0c7f, 0x20a9, 0x001c, 0x2d98, 0x2069, 0xa652, 0x2da0,
+	0x53a3, 0x6814, 0xa08c, 0x00ff, 0x6142, 0x8007, 0xa084, 0x00ff,
+	0x6046, 0x1078, 0x4eae, 0x1078, 0x49ce, 0x1078, 0x4a3e, 0x6000,
+	0xa086, 0x0000, 0x00c0, 0x314d, 0x6808, 0x602a, 0x1078, 0x21f7,
+	0x6818, 0x691c, 0x6a20, 0x6b24, 0x8007, 0x810f, 0x8217, 0x831f,
+	0x6016, 0x611a, 0x621e, 0x6322, 0x6c04, 0xd4f4, 0x0040, 0x30fa,
+	0x6830, 0x6934, 0x6a38, 0x6b3c, 0x8007, 0x810f, 0x8217, 0x831f,
+	0x0078, 0x30fc, 0xa084, 0xf0ff, 0x6006, 0x610a, 0x620e, 0x6312,
+	0x1078, 0x5b19, 0x6904, 0xd1fc, 0x0040, 0x312f, 0x0c7e, 0x2009,
+	0x0000, 0x20a9, 0x0001, 0x6b70, 0xd384, 0x0040, 0x312c, 0x0078,
+	0x3116, 0x839d, 0x00c8, 0x312c, 0x3508, 0x8109, 0x1078, 0x5480,
+	0x6878, 0x6016, 0x6874, 0x2008, 0xa084, 0xff00, 0x8007, 0x600a,
+	0xa184, 0x00ff, 0x6006, 0x8108, 0x00c0, 0x312a, 0x6003, 0x0003,
+	0x0078, 0x312c, 0x6003, 0x0001, 0x00f0, 0x3111, 0x0c7f, 0x0c7e,
+	0x2061, 0x0100, 0x602f, 0x0040, 0x602f, 0x0000, 0x0c7f, 0x1078,
+	0x3819, 0x0040, 0x313d, 0x1078, 0x256a, 0x60c0, 0xa005, 0x0040,
+	0x3149, 0x6003, 0x0001, 0x2091, 0x301d, 0x1078, 0x4224, 0x0078,
+	0x314d, 0x6003, 0x0004, 0x2091, 0x301d, 0x0078, 0x2bad, 0x6000,
+	0xa086, 0x0000, 0x0040, 0x2bd7, 0x2069, 0xa652, 0x7830, 0x6842,
+	0x7834, 0x6846, 0x6804, 0xd0fc, 0x0040, 0x3162, 0x2009, 0x0030,
+	0x0078, 0x3164, 0x2009, 0x001c, 0x2d00, 0x7a2c, 0x7b28, 0x7c3c,
+	0x7d38, 0x0078, 0x3608, 0xa006, 0x1078, 0x256a, 0x81ff, 0x00c0,
+	0x2bd7, 0x1078, 0x42dd, 0x1078, 0x4224, 0x0078, 0x2bad, 0x81ff,
+	0x00c0, 0x2bd7, 0x6184, 0x81ff, 0x0040, 0x3191, 0x703f, 0x0000,
+	0x2001, 0xacc0, 0x2009, 0x0040, 0x7a2c, 0x7b28, 0x7c3c, 0x7d38,
+	0x127e, 0x2091, 0x8000, 0x1078, 0x3608, 0x701b, 0x2baa, 0x127f,
+	0x007c, 0x703f, 0x0001, 0x0d7e, 0x2069, 0xacc0, 0x20a9, 0x0040,
+	0x20a1, 0xacc0, 0x2019, 0xffff, 0x43a4, 0x6550, 0xa588, 0x29c0,
+	0x210c, 0xa18c, 0x00ff, 0x216a, 0xa00e, 0x2011, 0x0002, 0x2100,
+	0xa506, 0x0040, 0x31c3, 0x1078, 0x45c4, 0x00c0, 0x31c3, 0x6014,
+	0x821c, 0x0048, 0x31bb, 0xa398, 0xacc0, 0xa085, 0xff00, 0x8007,
+	0x201a, 0x0078, 0x31c2, 0xa398, 0xacc0, 0x2324, 0xa4a4, 0xff00,
+	0xa405, 0x201a, 0x8210, 0x8108, 0xa182, 0x0080, 0x00c8, 0x31ca,
+	0x0078, 0x31a7, 0x8201, 0x8007, 0x2d0c, 0xa105, 0x206a, 0x0d7f,
+	0x20a9, 0x0040, 0x20a1, 0xacc0, 0x2099, 0xacc0, 0x1078, 0x4281,
+	0x0078, 0x3180, 0x1078, 0x35e4, 0x0040, 0x2bdb, 0x0c7e, 0x1078,
+	0x35ba, 0x0c7f, 0x00c0, 0x31e8, 0x2009, 0x0002, 0x0078, 0x2bd7,
+	0x2001, 0xa653, 0x2004, 0xd0b4, 0x0040, 0x320f, 0x6000, 0xd08c,
+	0x00c0, 0x320f, 0x6004, 0xa084, 0x00ff, 0xa086, 0x0006, 0x00c0,
+	0x320f, 0x6837, 0x0000, 0x6838, 0xc0fd, 0x683a, 0x1078, 0x8e9e,
+	0x00c0, 0x3206, 0x2009, 0x0003, 0x0078, 0x2bd7, 0x7007, 0x0003,
+	0x701b, 0x320b, 0x007c, 0x1078, 0x35e4, 0x0040, 0x2bdb, 0x20a9,
+	0x002b, 0x2c98, 0xade8, 0x0002, 0x2da0, 0x53a3, 0x20a9, 0x0004,
+	0xac80, 0x0006, 0x2098, 0xad80, 0x0006, 0x20a0, 0x1078, 0x4281,
+	0x20a9, 0x0004, 0xac80, 0x000a, 0x2098, 0xad80, 0x000a, 0x20a0,
+	0x1078, 0x4281, 0x2d00, 0x2009, 0x002b, 0x7a2c, 0x7b28, 0x7c3c,
+	0x7d38, 0x0078, 0x3608, 0x81ff, 0x00c0, 0x2bd7, 0x1078, 0x35d2,
+	0x0040, 0x2bdb, 0x1078, 0x47bd, 0x0078, 0x2bad, 0x81ff, 0x00c0,
+	0x2bd7, 0x7828, 0xa08a, 0x1000, 0x00c8, 0x2bdb, 0x1078, 0x35e4,
+	0x0040, 0x2bdb, 0x1078, 0x482f, 0x0040, 0x2bd7, 0x2019, 0x0004,
+	0x1078, 0x47d3, 0x7924, 0x810f, 0x7a28, 0x1078, 0x3259, 0x0078,
+	0x2bad, 0xa186, 0x00ff, 0x0040, 0x3261, 0x1078, 0x3271, 0x0078,
+	0x3270, 0x2029, 0x007e, 0x2061, 0xa600, 0x6450, 0x2400, 0xa506,
+	0x0040, 0x326d, 0x2508, 0x1078, 0x3271, 0x8529, 0x00c8, 0x3266,
+	0x007c, 0x1078, 0x45c4, 0x00c0, 0x327c, 0x2200, 0x8003, 0x800b,
+	0x810b, 0xa108, 0x1078, 0x5a52, 0x007c, 0x81ff, 0x00c0, 0x2bd7,
+	0x1078, 0x35d2, 0x0040, 0x2bdb, 0x1078, 0x4673, 0x0040, 0x2bd7,
+	0x1078, 0x47c8, 0x0078, 0x2bad, 0x81ff, 0x00c0, 0x2bd7, 0x1078,
+	0x35d2, 0x0040, 0x2bdb, 0x1078, 0x4673, 0x0040, 0x2bd7, 0x1078,
+	0x47b2, 0x0078, 0x2bad, 0x6100, 0x0078, 0x2bad, 0x1078, 0x35e4,
+	0x0040, 0x2bdb, 0x2001, 0xa600, 0x2004, 0xa086, 0x0003, 0x00c0,
+	0x2bd7, 0x0d7e, 0xace8, 0x000a, 0x7924, 0xd184, 0x0040, 0x32b2,
+	0xace8, 0x0006, 0x680c, 0x8007, 0x783e, 0x6808, 0x8007, 0x783a,
+	0x6b04, 0x831f, 0x6a00, 0x8217, 0x0d7f, 0x6100, 0xa18c, 0x0200,
+	0x0078, 0x2bad, 0xa006, 0x1078, 0x256a, 0x7824, 0xa084, 0x00ff,
+	0xa086, 0x00ff, 0x0040, 0x32cf, 0x81ff, 0x00c0, 0x2bd7, 0x1078,
+	0x42dd, 0x7828, 0xa08a, 0x1000, 0x00c8, 0x2bdb, 0x7924, 0xa18c,
+	0xff00, 0x810f, 0xa186, 0x00ff, 0x0040, 0x32e5, 0xa182, 0x007f,
+	0x00c8, 0x2bdb, 0x2100, 0x1078, 0x2564, 0x027e, 0x0c7e, 0x127e,
+	0x2091, 0x8000, 0x2061, 0xa8c4, 0x601b, 0x0000, 0x601f, 0x0000,
+	0x2011, 0x0003, 0x1078, 0x70e0, 0x2011, 0x0002, 0x1078, 0x70ea,
+	0x1078, 0x6fc4, 0x037e, 0x2019, 0x0000, 0x1078, 0x7058, 0x037f,
+	0x2061, 0x0100, 0x6030, 0xa084, 0x00ff, 0x810f, 0xa105, 0x604a,
+	0x6043, 0x0090, 0x6043, 0x0010, 0x2009, 0x002d, 0x2011, 0x4259,
+	0x1078, 0x5add, 0x7924, 0xa18c, 0xff00, 0x810f, 0x7a28, 0x1078,
+	0x3259, 0x127f, 0x0c7f, 0x027f, 0x0078, 0x2bad, 0x7924, 0xa18c,
+	0xff00, 0x810f, 0x0c7e, 0x1078, 0x455c, 0x2c08, 0x0c7f, 0x00c0,
+	0x2bdb, 0x0078, 0x2bad, 0x81ff, 0x0040, 0x3332, 0x2009, 0x0001,
+	0x0078, 0x2bd7, 0x60cc, 0xd09c, 0x00c0, 0x333a, 0x2009, 0x0005,
+	0x0078, 0x2bd7, 0x1078, 0x35ba, 0x00c0, 0x3342, 0x2009, 0x0002,
+	0x0078, 0x2bd7, 0x7924, 0x7a2c, 0x7b28, 0x7c3c, 0x7d38, 0x1078,
+	0x3604, 0x701b, 0x334c, 0x007c, 0x2009, 0x0080, 0x1078, 0x45c4,
+	0x00c0, 0x3359, 0x6004, 0xa084, 0x00ff, 0xa086, 0x0006, 0x0040,
+	0x335d, 0x2021, 0x400a, 0x0078, 0x2baf, 0x0d7e, 0xade8, 0x000d,
+	0x6900, 0x6a08, 0x6b0c, 0x6c10, 0x6d14, 0x6e18, 0x6820, 0xa0be,
+	0x0100, 0x0040, 0x33d0, 0xa0be, 0x0112, 0x0040, 0x33d0, 0xa0be,
+	0x0113, 0x0040, 0x33d0, 0xa0be, 0x0114, 0x0040, 0x33d0, 0xa0be,
+	0x0117, 0x0040, 0x33d0, 0xa0be, 0x011a, 0x0040, 0x33d0, 0xa0be,
+	0x0121, 0x0040, 0x33c6, 0xa0be, 0x0131, 0x0040, 0x33c6, 0xa0be,
+	0x0171, 0x0040, 0x33d0, 0xa0be, 0x0173, 0x0040, 0x33d0, 0xa0be,
+	0x01a1, 0x00c0, 0x3398, 0x6830, 0x8007, 0x6832, 0x0078, 0x33d6,
+	0xa0be, 0x0212, 0x0040, 0x33cc, 0xa0be, 0x0213, 0x0040, 0x33cc,
+	0xa0be, 0x0214, 0x0040, 0x33be, 0xa0be, 0x0217, 0x0040, 0x33b8,
+	0xa0be, 0x021a, 0x00c0, 0x33b1, 0x6838, 0x8007, 0x683a, 0x0078,
+	0x33d0, 0xa0be, 0x0300, 0x0040, 0x33d0, 0x0d7f, 0x0078, 0x2bdb,
+	0xad80, 0x0010, 0x20a9, 0x0007, 0x1078, 0x3418, 0xad80, 0x000e,
+	0x20a9, 0x0001, 0x1078, 0x3418, 0x0078, 0x33d0, 0xad80, 0x000c,
+	0x1078, 0x3426, 0x0078, 0x33d6, 0xad80, 0x000e, 0x1078, 0x3426,
+	0xad80, 0x000c, 0x20a9, 0x0001, 0x1078, 0x3418, 0x0c7e, 0x1078,
+	0x35ba, 0x0040, 0x3409, 0x6838, 0xc0fd, 0x683a, 0x6837, 0x0119,
+	0x6853, 0x0000, 0x684f, 0x0020, 0x685b, 0x0001, 0x810b, 0x697e,
+	0x6883, 0x0000, 0x6a86, 0x6b8a, 0x6c8e, 0x6d92, 0x6996, 0x689b,
+	0x0000, 0x0c7f, 0x0d7f, 0x6837, 0x0000, 0x6838, 0xc0fd, 0x683a,
+	0x6823, 0x0000, 0x6804, 0x2068, 0x1078, 0x8e66, 0x00c0, 0x3404,
+	0x2009, 0x0003, 0x0078, 0x2bd7, 0x7007, 0x0003, 0x701b, 0x340f,
+	0x007c, 0x0c7f, 0x0d7f, 0x2009, 0x0002, 0x0078, 0x2bd7, 0x6820,
+	0xa086, 0x8001, 0x00c0, 0x2bad, 0x2009, 0x0004, 0x0078, 0x2bd7,
+	0x017e, 0x2008, 0x2044, 0x8000, 0x204c, 0x8000, 0x290a, 0x8108,
+	0x280a, 0x8108, 0x00f0, 0x341a, 0x017f, 0x007c, 0x017e, 0x0a7e,
+	0x0b7e, 0x2008, 0x2044, 0x8000, 0x204c, 0x8000, 0x2054, 0x8000,
+	0x205c, 0x2b0a, 0x8108, 0x2a0a, 0x8108, 0x290a, 0x8108, 0x280a,
+	0x0b7f, 0x0a7f, 0x017f, 0x007c, 0x81ff, 0x0040, 0x3443, 0x2009,
+	0x0001, 0x0078, 0x2bd7, 0x60cc, 0xd09c, 0x00c0, 0x344b, 0x2009,
+	0x0005, 0x0078, 0x2bd7, 0x7924, 0x2140, 0xa18c, 0xff00, 0x810f,
+	0xa182, 0x0080, 0x0048, 0x2bdb, 0xa182, 0x00ff, 0x00c8, 0x2bdb,
+	0x7a2c, 0x7b28, 0x606c, 0xa306, 0x00c0, 0x3466, 0x6070, 0xa24e,
+	0x0040, 0x2bdb, 0xa9cc, 0xff00, 0x0040, 0x2bdb, 0x0c7e, 0x1078,
+	0x350f, 0x2c68, 0x0c7f, 0x0040, 0x349e, 0xa0c6, 0x4000, 0x00c0,
+	0x3484, 0x0c7e, 0x007e, 0x2d60, 0x2009, 0x0000, 0x1078, 0x489b,
+	0x00c0, 0x347b, 0xc185, 0x6000, 0xd0bc, 0x0040, 0x3480, 0xc18d,
+	0x007f, 0x0c7f, 0x0078, 0x349b, 0xa0c6, 0x4007, 0x00c0, 0x348b,
+	0x2408, 0x0078, 0x349b, 0xa0c6, 0x4008, 0x00c0, 0x3493, 0x2708,
+	0x2610, 0x0078, 0x349b, 0xa0c6, 0x4009, 0x00c0, 0x3499, 0x0078,
+	0x349b, 0x2001, 0x4006, 0x2020, 0x0078, 0x2baf, 0x2d00, 0x7022,
+	0x017e, 0x0b7e, 0x0c7e, 0x0e7e, 0x2c70, 0x1078, 0x76c7, 0x0040,
+	0x34e4, 0x2d00, 0x601a, 0x2001, 0xa657, 0x2004, 0xa084, 0x00ff,
+	0x6842, 0x2e58, 0x0e7f, 0x0e7e, 0x0c7e, 0x1078, 0x35ba, 0x0c7f,
+	0x2b70, 0x00c0, 0x34c5, 0x1078, 0x772d, 0x0e7f, 0x0c7f, 0x0b7f,
+	0x017f, 0x2009, 0x0002, 0x0078, 0x2bd7, 0x6837, 0x0000, 0x2d00,
+	0x6012, 0x6833, 0x0000, 0x6838, 0xc0fd, 0x683a, 0x127e, 0x2091,
+	0x8000, 0x1078, 0x2880, 0x127f, 0x601f, 0x0001, 0x2001, 0x0000,
+	0x1078, 0x44ee, 0x2001, 0x0002, 0x1078, 0x4502, 0x2009, 0x0002,
+	0x1078, 0x775c, 0xa085, 0x0001, 0x0e7f, 0x0c7f, 0x0b7f, 0x017f,
+	0x00c0, 0x34ee, 0x2009, 0x0003, 0x0078, 0x2bd7, 0x7007, 0x0003,
+	0x701b, 0x34f3, 0x007c, 0x6830, 0xa086, 0x0100, 0x7020, 0x2060,
+	0x00c0, 0x3501, 0x2009, 0x0004, 0x6204, 0xa294, 0x00ff, 0x0078,
+	0x2bd7, 0x2009, 0x0000, 0x1078, 0x489b, 0x00c0, 0x3508, 0xc185,
+	0x6000, 0xd0bc, 0x0040, 0x350d, 0xc18d, 0x0078, 0x2bad, 0x0e7e,
+	0x0d7e, 0x2029, 0x0000, 0x2021, 0x0080, 0x20a9, 0x007f, 0x2071,
+	0xa7b5, 0x2e04, 0xa005, 0x00c0, 0x3524, 0x2100, 0xa406, 0x00c0,
+	0x3555, 0x2428, 0x0078, 0x3555, 0x2068, 0x6f10, 0x2700, 0xa306,
+	0x00c0, 0x3546, 0x6e14, 0x2600, 0xa206, 0x00c0, 0x3546, 0x2400,
+	0xa106, 0x00c0, 0x3542, 0x2d60, 0xd884, 0x0040, 0x356a, 0x6004,
+	0xa084, 0x00ff, 0xa086, 0x0006, 0x00c0, 0x356a, 0x2001, 0x4000,
+	0x0078, 0x356b, 0x2001, 0x4007, 0x0078, 0x356b, 0x2400, 0xa106,
+	0x00c0, 0x3555, 0x6e14, 0x87ff, 0x00c0, 0x3551, 0x86ff, 0x0040,
+	0x3521, 0x2001, 0x4008, 0x0078, 0x356b, 0x8420, 0x8e70, 0x00f0,
+	0x3519, 0x85ff, 0x00c0, 0x3564, 0x2001, 0x4009, 0x0078, 0x356b,
+	0x2001, 0x0001, 0x0078, 0x356b, 0x1078, 0x455c, 0x00c0, 0x3560,
+	0x6312, 0x6216, 0xa006, 0xa005, 0x0d7f, 0x0e7f, 0x007c, 0x81ff,
+	0x00c0, 0x2bd7, 0x1078, 0x35ba, 0x0040, 0x2bd7, 0x6837, 0x0000,
+	0x6838, 0xc0fd, 0x683a, 0x7824, 0xa005, 0x0040, 0x2bdb, 0xa096,
+	0x00ff, 0x0040, 0x3587, 0xa092, 0x0004, 0x00c8, 0x2bdb, 0x2010,
+	0x2d18, 0x1078, 0x282f, 0x0040, 0x2bd7, 0x7007, 0x0003, 0x701b,
+	0x3592, 0x007c, 0x6830, 0xa086, 0x0100, 0x0040, 0x2bd7, 0x0078,
+	0x2bad, 0x7924, 0xa18c, 0xff00, 0x810f, 0xa182, 0x0080, 0x0048,
+	0x2bdb, 0xa182, 0x00ff, 0x00c8, 0x2bdb, 0x127e, 0x2091, 0x8000,
+	0x1078, 0x8d4b, 0x00c0, 0x35b7, 0xa190, 0xa735, 0x2204, 0xa065,
+	0x0040, 0x35b7, 0x1078, 0x42f8, 0x127f, 0x0078, 0x2bad, 0x127f,
+	0x0078, 0x2bd7, 0x1078, 0x138b, 0x0040, 0x35d1, 0xa006, 0x6802,
+	0x7010, 0xa005, 0x00c0, 0x35c9, 0x2d00, 0x7012, 0x7016, 0x0078,
+	0x35cf, 0x7014, 0x6802, 0x2060, 0x2d00, 0x6006, 0x7016, 0xad80,
+	0x000d, 0x007c, 0x7924, 0x810f, 0xa18c, 0x00ff, 0x1078, 0x45c4,
+	0x00c0, 0x35e1, 0x7e28, 0xa684, 0x3fff, 0xa082, 0x4000, 0x0048,
+	0x35e2, 0xa066, 0x8cff, 0x007c, 0x7e24, 0x860f, 0xa18c, 0x00ff,
+	0x1078, 0x45c4, 0x00c0, 0x35f2, 0xa6b4, 0x00ff, 0xa682, 0x4000,
+	0x0048, 0x35f3, 0xa066, 0x8cff, 0x007c, 0x017e, 0x7110, 0x81ff,
+	0x0040, 0x3600, 0x2168, 0x6904, 0x1078, 0x13a4, 0x0078, 0x35f7,
+	0x7112, 0x7116, 0x017f, 0x007c, 0x2031, 0x0001, 0x0078, 0x360a,
+	0x2031, 0x0000, 0x2061, 0xa6d2, 0x6606, 0x6112, 0x600e, 0x6226,
+	0x632a, 0x642e, 0x6532, 0x2c10, 0x1078, 0x13db, 0x7007, 0x0002,
+	0x701b, 0x2bad, 0x007c, 0x0f7e, 0x127e, 0x2091, 0x8000, 0x2079,
+	0x0000, 0x2001, 0xa690, 0x2004, 0xa005, 0x00c0, 0x3636, 0x0068,
+	0x3636, 0x7818, 0xd084, 0x00c0, 0x3636, 0x7a22, 0x7b26, 0x7c2a,
+	0x781b, 0x0001, 0x2091, 0x4080, 0x0078, 0x365b, 0x017e, 0x0c7e,
+	0x0e7e, 0x2071, 0xa682, 0x7138, 0xa182, 0x0008, 0x0048, 0x3644,
+	0x7030, 0x2060, 0x0078, 0x3655, 0x7030, 0xa0e0, 0x0008, 0xac82,
+	0xa6d2, 0x0048, 0x364d, 0x2061, 0xa692, 0x2c00, 0x7032, 0x81ff,
+	0x00c0, 0x3653, 0x7036, 0x8108, 0x713a, 0x2262, 0x6306, 0x640a,
+	0x0e7f, 0x0c7f, 0x017f, 0x127f, 0x0f7f, 0x007c, 0x0e7e, 0x2071,
+	0xa682, 0x7038, 0xa005, 0x0040, 0x3697, 0x127e, 0x2091, 0x8000,
+	0x0068, 0x3696, 0x0f7e, 0x2079, 0x0000, 0x7818, 0xd084, 0x00c0,
+	0x3695, 0x0c7e, 0x7034, 0x2060, 0x2c04, 0x7822, 0x6004, 0x7826,
+	0x6008, 0x782a, 0x781b, 0x0001, 0x2091, 0x4080, 0x7038, 0x8001,
+	0x703a, 0xa005, 0x00c0, 0x368b, 0x7033, 0xa692, 0x7037, 0xa692,
+	0x0c7f, 0x0078, 0x3695, 0xac80, 0x0008, 0xa0fa, 0xa6d2, 0x0048,
+	0x3693, 0x2001, 0xa692, 0x7036, 0x0c7f, 0x0f7f, 0x127f, 0x0e7f,
+	0x007c, 0x027e, 0x2001, 0xa653, 0x2004, 0xd0c4, 0x0040, 0x36a4,
+	0x2011, 0x8014, 0x1078, 0x361b, 0x027f, 0x007c, 0x81ff, 0x00c0,
+	0x2bd7, 0x127e, 0x2091, 0x8000, 0x6030, 0xc08d, 0xc085, 0xc0ac,
+	0x6032, 0x1078, 0x4224, 0x127f, 0x0078, 0x2bad, 0x81ff, 0x00c0,
+	0x2bd7, 0x6000, 0xa086, 0x0003, 0x00c0, 0x2bd7, 0x2001, 0xa653,
+	0x2004, 0xd0ac, 0x00c0, 0x2bd7, 0x1078, 0x35e4, 0x0040, 0x2bdb,
+	0x6004, 0xa084, 0x00ff, 0xa086, 0x0006, 0x00c0, 0x36d3, 0x7828,
+	0xa005, 0x0040, 0x2bad, 0x0c7e, 0x1078, 0x35ba, 0x0c7f, 0x0040,
+	0x2bd7, 0x6837, 0x0000, 0x6833, 0x0000, 0x6838, 0xc0fd, 0x683a,
+	0x1078, 0x8f12, 0x0040, 0x2bd7, 0x7007, 0x0003, 0x701b, 0x36e9,
+	0x007c, 0x6830, 0xa086, 0x0100, 0x0040, 0x2bd7, 0x0078, 0x2bad,
+	0x2001, 0xa600, 0x2004, 0xa086, 0x0003, 0x00c0, 0x2bd7, 0x7f24,
+	0x7a2c, 0x7b28, 0x7c3c, 0x7d38, 0x1078, 0x35ba, 0x0040, 0x2bd7,
+	0x2009, 0x0000, 0x2031, 0x0000, 0x7023, 0x0000, 0x702f, 0x0000,
+	0xad80, 0x0005, 0x7026, 0x20a0, 0x1078, 0x45c4, 0x00c0, 0x376d,
+	0x6004, 0xa0c4, 0x00ff, 0xa8c6, 0x0006, 0x0040, 0x371d, 0xa0c4,
+	0xff00, 0xa8c6, 0x0600, 0x00c0, 0x376d, 0x2001, 0xa653, 0x2004,
+	0xd0ac, 0x00c0, 0x372a, 0x1078, 0x489b, 0x00c0, 0x372a, 0xd79c,
+	0x0040, 0x376d, 0xd794, 0x00c0, 0x3730, 0xd784, 0x0040, 0x373c,
+	0xac80, 0x0006, 0x2098, 0x3400, 0x20a9, 0x0004, 0x53a3, 0x1078,
+	0x3426, 0xd794, 0x0040, 0x3745, 0xac80, 0x000a, 0x2098, 0x3400,
+	0x20a9, 0x0004, 0x53a3, 0x1078, 0x3426, 0x21a2, 0xd794, 0x0040,
+	0x3765, 0xac80, 0x0000, 0x2098, 0x94a0, 0x20a9, 0x0002, 0x53a3,
+	0xac80, 0x0003, 0x20a6, 0x94a0, 0xac80, 0x0004, 0x2098, 0x3400,
+	0x20a9, 0x0002, 0x53a3, 0x1078, 0x3418, 0xac80, 0x0026, 0x2098,
+	0x20a9, 0x0002, 0x53a3, 0x0078, 0x3766, 0x94a0, 0xd794, 0x0040,
+	0x376b, 0xa6b0, 0x000b, 0xa6b0, 0x0005, 0x8108, 0xd78c, 0x0040,
+	0x3777, 0xa186, 0x0100, 0x0040, 0x3788, 0x0078, 0x377b, 0xa186,
+	0x007e, 0x0040, 0x3788, 0xd794, 0x0040, 0x3782, 0xa686, 0x0020,
+	0x0078, 0x3784, 0xa686, 0x0028, 0x0040, 0x3791, 0x0078, 0x370c,
+	0x86ff, 0x00c0, 0x378f, 0x7120, 0x810b, 0x0078, 0x2bad, 0x702f,
+	0x0001, 0x711e, 0x7020, 0xa600, 0x7022, 0x772a, 0x2061, 0xa6d2,
+	0x6007, 0x0000, 0x6612, 0x7024, 0x600e, 0x6226, 0x632a, 0x642e,
+	0x6532, 0x2c10, 0x1078, 0x13db, 0x7007, 0x0002, 0x701b, 0x37a9,
+	0x007c, 0x702c, 0xa005, 0x00c0, 0x37bb, 0x711c, 0x7024, 0x20a0,
+	0x7728, 0x2031, 0x0000, 0x2061, 0xa6d2, 0x6224, 0x6328, 0x642c,
+	0x6530, 0x0078, 0x370c, 0x7120, 0x810b, 0x0078, 0x2bad, 0x2029,
+	0x007e, 0x7924, 0x7a28, 0x7b2c, 0x7c38, 0xa184, 0xff00, 0x8007,
+	0xa0e2, 0x0020, 0x0048, 0x2bdb, 0xa502, 0x0048, 0x2bdb, 0xa184,
+	0x00ff, 0xa0e2, 0x0020, 0x0048, 0x2bdb, 0xa502, 0x0048, 0x2bdb,
+	0xa284, 0xff00, 0x8007, 0xa0e2, 0x0020, 0x0048, 0x2bdb, 0xa502,
+	0x0048, 0x2bdb, 0xa284, 0x00ff, 0xa0e2, 0x0020, 0x0048, 0x2bdb,
+	0xa502, 0x0048, 0x2bdb, 0xa384, 0xff00, 0x8007, 0xa0e2, 0x0020,
+	0x0048, 0x2bdb, 0xa502, 0x0048, 0x2bdb, 0xa384, 0x00ff, 0xa0e2,
+	0x0020, 0x0048, 0x2bdb, 0xa502, 0x0048, 0x2bdb, 0xa484, 0xff00,
+	0x8007, 0xa0e2, 0x0020, 0x0048, 0x2bdb, 0xa502, 0x0048, 0x2bdb,
+	0xa484, 0x00ff, 0xa0e2, 0x0020, 0x0048, 0x2bdb, 0xa502, 0x0048,
+	0x2bdb, 0x2061, 0xa8a5, 0x6102, 0x6206, 0x630a, 0x640e, 0x0078,
+	0x2bad, 0x007e, 0x2001, 0xa653, 0x2004, 0xd0cc, 0x007f, 0x007c,
+	0x007e, 0x2001, 0xa672, 0x2004, 0xd0bc, 0x007f, 0x007c, 0x6164,
+	0x7a24, 0x6300, 0x82ff, 0x00c0, 0x3830, 0x7926, 0x0078, 0x2bad,
+	0x83ff, 0x00c0, 0x2bdb, 0x2001, 0xfff0, 0xa200, 0x00c8, 0x2bdb,
+	0x2019, 0xffff, 0x6068, 0xa302, 0xa200, 0x0048, 0x2bdb, 0x7926,
+	0x6266, 0x0078, 0x2bad, 0x2001, 0xa600, 0x2004, 0xa086, 0x0003,
+	0x00c0, 0x2bd7, 0x7c28, 0x7d24, 0x7e38, 0x7f2c, 0x1078, 0x35ba,
+	0x0040, 0x2bd7, 0x2009, 0x0000, 0x2019, 0x0000, 0x7023, 0x0000,
+	0x702f, 0x0000, 0xad80, 0x0003, 0x7026, 0x20a0, 0xa1e0, 0xa735,
+	0x2c64, 0x8cff, 0x0040, 0x387d, 0x6004, 0xa084, 0x00ff, 0xa086,
+	0x0006, 0x0040, 0x3872, 0x6004, 0xa084, 0xff00, 0xa086, 0x0600,
+	0x00c0, 0x387d, 0x6014, 0x20a2, 0x94a0, 0x6010, 0x8007, 0xa105,
+	0x8007, 0x20a2, 0x94a0, 0xa398, 0x0002, 0x8108, 0xa182, 0x00ff,
+	0x0040, 0x3888, 0xa386, 0x002a, 0x0040, 0x3891, 0x0078, 0x385e,
+	0x83ff, 0x00c0, 0x388f, 0x7120, 0x810c, 0x0078, 0x2bad, 0x702f,
+	0x0001, 0x711e, 0x7020, 0xa300, 0x7022, 0x2061, 0xa6d2, 0x6007,
+	0x0000, 0x6312, 0x7024, 0x600e, 0x6426, 0x652a, 0x662e, 0x6732,
+	0x2c10, 0x1078, 0x13db, 0x7007, 0x0002, 0x701b, 0x38a8, 0x007c,
+	0x702c, 0xa005, 0x00c0, 0x38b9, 0x711c, 0x7024, 0x20a0, 0x2019,
+	0x0000, 0x2061, 0xa6d2, 0x6424, 0x6528, 0x662c, 0x6730, 0x0078,
+	0x385e, 0x7120, 0x810c, 0x0078, 0x2bad, 0x81ff, 0x00c0, 0x2bd7,
+	0x60cc, 0xd09c, 0x0040, 0x2bd7, 0x1078, 0x35ba, 0x0040, 0x2bd7,
+	0x7924, 0x7a2c, 0x7b28, 0x7c3c, 0x7d38, 0x1078, 0x3604, 0x701b,
+	0x38d2, 0x007c, 0x0d7e, 0xade8, 0x000d, 0x6828, 0xa0be, 0x7000,
+	0x0040, 0x38e5, 0xa0be, 0x7100, 0x0040, 0x38e5, 0xa0be, 0x7200,
+	0x0040, 0x38e5, 0x0d7f, 0x0078, 0x2bdb, 0x6820, 0x6924, 0x1078,
+	0x254d, 0x00c0, 0x3910, 0x1078, 0x455c, 0x00c0, 0x3910, 0x7122,
+	0x6612, 0x6516, 0x6e18, 0x0c7e, 0x1078, 0x35ba, 0x0040, 0x3910,
+	0x1078, 0x35ba, 0x0040, 0x3910, 0x0c7f, 0x0d7f, 0x6837, 0x0000,
+	0x6838, 0xc0fd, 0x683a, 0x6823, 0x0000, 0x6804, 0x2068, 0x1078,
+	0x8e82, 0x0040, 0x2bd7, 0x7007, 0x0003, 0x701b, 0x3913, 0x007c,
+	0x0d7f, 0x0078, 0x2bd7, 0x7120, 0x1078, 0x298e, 0x6820, 0xa086,
+	0x8001, 0x0040, 0x2bd7, 0x2d00, 0x701e, 0x6804, 0xa080, 0x0002,
+	0x007e, 0x20a9, 0x002a, 0x2098, 0x20a0, 0x1078, 0x4281, 0x007f,
+	0xade8, 0x000d, 0x6a08, 0x6b0c, 0x6c10, 0x6d14, 0x2061, 0xa6d2,
+	0x6007, 0x0000, 0x6e00, 0x6f28, 0xa7c6, 0x7000, 0x00c0, 0x393a,
+	0x0078, 0x393e, 0xa7c6, 0x7100, 0x00c0, 0x3946, 0xa6c2, 0x0004,
+	0x0048, 0x2bdb, 0x2009, 0x0004, 0x0078, 0x3608, 0xa7c6, 0x7200,
+	0x00c0, 0x2bdb, 0xa6c2, 0x0054, 0x0048, 0x2bdb, 0x600e, 0x6013,
+	0x002a, 0x6226, 0x632a, 0x642e, 0x6532, 0x2c10, 0x1078, 0x13db,
+	0x7007, 0x0002, 0x701b, 0x395d, 0x007c, 0x701c, 0x2068, 0x6804,
+	0xa080, 0x0001, 0x2004, 0xa080, 0x0002, 0x007e, 0x20a9, 0x002a,
+	0x2098, 0x20a0, 0x1078, 0x4281, 0x007f, 0x2009, 0x002a, 0x2061,
+	0xa6d2, 0x6224, 0x6328, 0x642c, 0x6530, 0x0078, 0x3608, 0x81ff,
+	0x00c0, 0x2bd7, 0x792c, 0x2001, 0xa89d, 0x2102, 0x1078, 0x35d2,
+	0x0040, 0x2bdb, 0x1078, 0x4673, 0x0040, 0x2bd7, 0x127e, 0x2091,
+	0x8000, 0x1078, 0x47de, 0x127f, 0x0078, 0x2bad, 0x7824, 0xd08c,
+	0x00c0, 0x3995, 0xd084, 0x0040, 0x31da, 0x1078, 0x35e4, 0x0040,
+	0x2bdb, 0x0c7e, 0x1078, 0x35ba, 0x0c7f, 0x00c0, 0x39a3, 0x2009,
+	0x0002, 0x0078, 0x2bd7, 0x6004, 0xa084, 0x00ff, 0xa086, 0x0006,
+	0x0040, 0x39b0, 0xa08e, 0x0004, 0x0040, 0x39b0, 0xa08e, 0x0005,
+	0x00c0, 0x39dd, 0x7824, 0xd08c, 0x0040, 0x39bb, 0x6000, 0xc08c,
+	0x6002, 0x0078, 0x39c5, 0x2001, 0xa653, 0x2004, 0xd0b4, 0x0040,
+	0x320f, 0x6000, 0xd08c, 0x00c0, 0x320f, 0x6837, 0x0000, 0x6838,
+	0xc0fd, 0x683a, 0x1078, 0x8e9e, 0x00c0, 0x39d2, 0x2009, 0x0003,
+	0x0078, 0x2bd7, 0x7007, 0x0003, 0x701b, 0x39d7, 0x007c, 0x1078,
+	0x35e4, 0x0040, 0x2bdb, 0x0078, 0x320f, 0x2009, 0xa62f, 0x210c,
+	0x81ff, 0x0040, 0x39e7, 0x2009, 0x0001, 0x0078, 0x2bd7, 0x2001,
+	0xa600, 0x2004, 0xa086, 0x0003, 0x0040, 0x39f2, 0x2009, 0x0007,
+	0x0078, 0x2bd7, 0x2001, 0xa653, 0x2004, 0xd0ac, 0x0040, 0x39fc,
+	0x2009, 0x0008, 0x0078, 0x2bd7, 0x609c, 0xd0a4, 0x00c0, 0x3a03,
+	0xd0ac, 0x00c0, 0x320f, 0x6837, 0x0000, 0x6833, 0x0000, 0x6838,
+	0xc0fd, 0x683a, 0x1078, 0x8f12, 0x00c0, 0x3a12, 0x2009, 0x0003,
+	0x0078, 0x2bd7, 0x7007, 0x0003, 0x701b, 0x3a17, 0x007c, 0x6830,
+	0xa086, 0x0100, 0x00c0, 0x3a20, 0x2009, 0x0004, 0x0078, 0x2bd7,
+	0x1078, 0x35e4, 0x0040, 0x2bdb, 0x0078, 0x39b2, 0x81ff, 0x2009,
+	0x0001, 0x00c0, 0x2bd7, 0x6000, 0xa086, 0x0003, 0x2009, 0x0007,
+	0x00c0, 0x2bd7, 0x2001, 0xa653, 0x2004, 0xd0ac, 0x2009, 0x0008,
+	0x00c0, 0x2bd7, 0x1078, 0x35e4, 0x0040, 0x2bdb, 0x6004, 0xa084,
+	0x00ff, 0xa086, 0x0006, 0x2009, 0x0009, 0x00c0, 0x2bd7, 0x0c7e,
+	0x1078, 0x35ba, 0x0c7f, 0x2009, 0x0002, 0x0040, 0x2bd7, 0x6837,
+	0x0000, 0x6833, 0x0000, 0x6838, 0xc0fd, 0x683a, 0x7928, 0xa194,
+	0xff00, 0xa18c, 0x00ff, 0xa006, 0x82ff, 0x00c0, 0x3a65, 0xc0ed,
+	0x6952, 0x792c, 0x6956, 0x0078, 0x3a6e, 0xa28e, 0x0100, 0x00c0,
+	0x2bdb, 0xc0e5, 0x6853, 0x0000, 0x6857, 0x0000, 0x683e, 0x1078,
+	0x90bd, 0x2009, 0x0003, 0x0040, 0x2bd7, 0x7007, 0x0003, 0x701b,
+	0x3a7a, 0x007c, 0x6830, 0xa086, 0x0100, 0x2009, 0x0004, 0x0040,
+	0x2bd7, 0x0078, 0x2bad, 0x81ff, 0x2009, 0x0001, 0x00c0, 0x2bd7,
+	0x6000, 0xa086, 0x0003, 0x2009, 0x0007, 0x00c0, 0x2bd7, 0x1078,
+	0x35e4, 0x0040, 0x2bdb, 0x6004, 0xa084, 0x00ff, 0xa086, 0x0006,
+	0x2009, 0x0009, 0x00c0, 0x2bd7, 0x0c7e, 0x1078, 0x35ba, 0x0c7f,
+	0x2009, 0x0002, 0x0040, 0x2bd7, 0xad80, 0x000f, 0x2009, 0x0008,
+	0x7a2c, 0x7b28, 0x7c3c, 0x7d38, 0x1078, 0x3604, 0x701b, 0x3ab1,
+	0x007c, 0x0d7e, 0xade8, 0x000f, 0x6800, 0xa086, 0x0500, 0x00c0,
+	0x3ac4, 0x6804, 0xa005, 0x00c0, 0x3ac4, 0x6808, 0xa084, 0xff00,
+	0x00c0, 0x3ac4, 0x0078, 0x3ac7, 0x0d7f, 0x00c0, 0x2bdb, 0x0d7f,
+	0x6837, 0x0000, 0x6833, 0x0000, 0x6838, 0xc0fd, 0x683a, 0x0c7e,
+	0x1078, 0x35e4, 0x00c0, 0x3ad7, 0x0c7f, 0x0078, 0x2bdb, 0x1078,
+	0x9119, 0x2009, 0x0003, 0x0c7f, 0x0040, 0x2bd7, 0x7007, 0x0003,
+	0x701b, 0x3ae3, 0x007c, 0x6830, 0xa086, 0x0100, 0x2009, 0x0004,
+	0x0040, 0x2bd7, 0x0078, 0x2bad, 0x127e, 0x0c7e, 0x0e7e, 0x2061,
+	0x0100, 0x2071, 0xa600, 0x6044, 0xd0a4, 0x00c0, 0x3b15, 0xd084,
+	0x0040, 0x3afe, 0x1078, 0x3c75, 0x0078, 0x3b11, 0xd08c, 0x0040,
+	0x3b05, 0x1078, 0x3b8c, 0x0078, 0x3b11, 0xd094, 0x0040, 0x3b0c,
+	0x1078, 0x3b60, 0x0078, 0x3b11, 0xd09c, 0x0040, 0x3b11, 0x1078,
+	0x3b1f, 0x0e7f, 0x0c7f, 0x127f, 0x007c, 0x017e, 0x6128, 0xd19c,
+	0x00c0, 0x3b1c, 0xc19d, 0x612a, 0x017f, 0x0078, 0x3b11, 0x624c,
+	0xa286, 0xf0f0, 0x00c0, 0x3b30, 0x6048, 0xa086, 0xf0f0, 0x0040,
+	0x3b30, 0x624a, 0x6043, 0x0090, 0x6043, 0x0010, 0x0078, 0x3b5f,
+	0xa294, 0xff00, 0xa296, 0xf700, 0x0040, 0x3b45, 0x7134, 0xd1a4,
+	0x00c0, 0x3b45, 0x6240, 0xa294, 0x0010, 0x0040, 0x3b45, 0x2009,
+	0x00f7, 0x1078, 0x42a1, 0x0078, 0x3b5f, 0x6043, 0x0040, 0x6043,
+	0x0000, 0x7077, 0x0000, 0x708f, 0x0001, 0x70b3, 0x0000, 0x70cf,
+	0x0000, 0x2009, 0xacc0, 0x200b, 0x0000, 0x7087, 0x0000, 0x707b,
+	0x000f, 0x2009, 0x000f, 0x2011, 0x41d5, 0x1078, 0x5add, 0x007c,
+	0x157e, 0x7078, 0xa005, 0x00c0, 0x3b8a, 0x2011, 0x41d5, 0x1078,
+	0x5a45, 0x6040, 0xa094, 0x0010, 0xa285, 0x0020, 0x6042, 0x20a9,
+	0x00c8, 0x6044, 0xd08c, 0x00c0, 0x3b83, 0x00f0, 0x3b71, 0x6242,
+	0x708b, 0x0000, 0x6040, 0xa094, 0x0010, 0xa285, 0x0080, 0x6042,
+	0x6242, 0x0078, 0x3b8a, 0x6242, 0x708b, 0x0000, 0x707f, 0x0000,
+	0x0078, 0x3b8a, 0x157f, 0x007c, 0x707c, 0xa08a, 0x0003, 0x00c8,
+	0x3b95, 0x1079, 0x3b98, 0x0078, 0x3b97, 0x1078, 0x1332, 0x007c,
+	0x3b9b, 0x3bea, 0x3c74, 0x0f7e, 0x707f, 0x0001, 0x20e1, 0xa000,
+	0x20e1, 0x8700, 0x1078, 0x21f7, 0x20e1, 0x9080, 0x20e1, 0x4000,
+	0x2079, 0xab00, 0x207b, 0x2200, 0x7807, 0x00ef, 0x780b, 0x0000,
+	0x780f, 0x00ef, 0x7813, 0x0138, 0x7817, 0x0000, 0x781b, 0x0000,
+	0x781f, 0x0000, 0x7823, 0xffff, 0x7827, 0xffff, 0x782b, 0x0000,
+	0x782f, 0x0000, 0x2079, 0xab0c, 0x207b, 0x1101, 0x7807, 0x0000,
+	0x2099, 0xa605, 0x20a1, 0xab0e, 0x20a9, 0x0004, 0x53a3, 0x2079,
+	0xab12, 0x207b, 0x0000, 0x7807, 0x0000, 0x2099, 0xab00, 0x20a1,
+	0x020b, 0x20a9, 0x0014, 0x53a6, 0x60c3, 0x000c, 0x600f, 0x0000,
+	0x1078, 0x420b, 0x0f7f, 0x7083, 0x0000, 0x6043, 0x0008, 0x6043,
+	0x0000, 0x007c, 0x0d7e, 0x7080, 0x7083, 0x0000, 0xa025, 0x0040,
+	0x3c5e, 0x6020, 0xd0b4, 0x00c0, 0x3c5c, 0x718c, 0x81ff, 0x0040,
+	0x3c4b, 0xa486, 0x000c, 0x00c0, 0x3c56, 0xa480, 0x0018, 0x8004,
+	0x20a8, 0x2011, 0xab80, 0x2019, 0xab00, 0x220c, 0x2304, 0xa106,
+	0x00c0, 0x3c22, 0x8210, 0x8318, 0x00f0, 0x3c05, 0x6043, 0x0004,
+	0x608b, 0xbc94, 0x608f, 0xf0f0, 0x6043, 0x0006, 0x707f, 0x0002,
+	0x708b, 0x0002, 0x2009, 0x07d0, 0x2011, 0x41dc, 0x1078, 0x5add,
+	0x0078, 0x3c5c, 0x2069, 0xab80, 0x6930, 0xa18e, 0x1101, 0x00c0,
+	0x3c56, 0x6834, 0xa005, 0x00c0, 0x3c56, 0x6900, 0xa18c, 0x00ff,
+	0x00c0, 0x3c36, 0x6804, 0xa005, 0x0040, 0x3c4b, 0x2011, 0xab8e,
+	0x2019, 0xa605, 0x20a9, 0x0004, 0x220c, 0x2304, 0xa102, 0x0048,
+	0x3c49, 0x00c0, 0x3c56, 0x8210, 0x8318, 0x00f0, 0x3c3c, 0x0078,
+	0x3c56, 0x708f, 0x0000, 0x20e1, 0x9080, 0x20e1, 0x4000, 0x2099,
+	0xab80, 0x20a1, 0x020b, 0x20a9, 0x0014, 0x53a6, 0x6043, 0x0008,
+	0x6043, 0x0000, 0x0078, 0x3c5e, 0x0d7f, 0x007c, 0x6020, 0xd0b4,
+	0x00c0, 0x3c5c, 0x60c3, 0x000c, 0x2011, 0xa8bb, 0x2013, 0x0000,
+	0x7083, 0x0000, 0x20e1, 0x9080, 0x60a3, 0x0056, 0x60a7, 0x9575,
+	0x1078, 0x6e06, 0x0078, 0x3c5c, 0x007c, 0x7088, 0xa08a, 0x001d,
+	0x00c8, 0x3c7e, 0x1079, 0x3c81, 0x0078, 0x3c80, 0x1078, 0x1332,
+	0x007c, 0x3cab, 0x3cba, 0x3ce9, 0x3d02, 0x3d2e, 0x3d5a, 0x3d86,
+	0x3dbc, 0x3de8, 0x3e10, 0x3e53, 0x3e7d, 0x3e9f, 0x3eb5, 0x3edb,
+	0x3eee, 0x3ef7, 0x3f2b, 0x3f57, 0x3f83, 0x3faf, 0x3fe5, 0x4030,
+	0x405f, 0x4081, 0x40c3, 0x40e9, 0x4102, 0x4103, 0x0c7e, 0x2061,
+	0xa600, 0x6003, 0x0007, 0x2061, 0x0100, 0x6004, 0xa084, 0xfff9,
+	0x6006, 0x0c7f, 0x007c, 0x608b, 0xbc94, 0x608f, 0xf0f0, 0x6043,
+	0x0002, 0x708b, 0x0001, 0x2009, 0x07d0, 0x2011, 0x41dc, 0x1078,
+	0x5add, 0x007c, 0x0f7e, 0x7080, 0xa086, 0x0014, 0x00c0, 0x3ce7,
+	0x6043, 0x0000, 0x6020, 0xd0b4, 0x00c0, 0x3ce7, 0x2079, 0xab80,
+	0x7a30, 0xa296, 0x1102, 0x00c0, 0x3ce5, 0x7834, 0xa005, 0x00c0,
+	0x3ce5, 0x7a38, 0xd2fc, 0x0040, 0x3cdb, 0x70b0, 0xa005, 0x00c0,
+	0x3cdb, 0x70b3, 0x0001, 0x2011, 0x41dc, 0x1078, 0x5a45, 0x708b,
+	0x0010, 0x1078, 0x3ef7, 0x0078, 0x3ce7, 0x1078, 0x4224, 0x0f7f,
+	0x007c, 0x708b, 0x0003, 0x6043, 0x0004, 0x2011, 0x41dc, 0x1078,
+	0x5a45, 0x1078, 0x4289, 0x20a3, 0x1102, 0x20a3, 0x0000, 0x20a9,
+	0x000a, 0x20a3, 0x0000, 0x00f0, 0x3cf9, 0x60c3, 0x0014, 0x1078,
+	0x420b, 0x007c, 0x0f7e, 0x7080, 0xa005, 0x0040, 0x3d2c, 0x2011,
+	0x41dc, 0x1078, 0x5a45, 0xa086, 0x0014, 0x00c0, 0x3d2a, 0x2079,
+	0xab80, 0x7a30, 0xa296, 0x1102, 0x00c0, 0x3d2a, 0x7834, 0xa005,
+	0x00c0, 0x3d2a, 0x7a38, 0xd2fc, 0x0040, 0x3d24, 0x70b0, 0xa005,
+	0x00c0, 0x3d24, 0x70b3, 0x0001, 0x708b, 0x0004, 0x1078, 0x3d2e,
+	0x0078, 0x3d2c, 0x1078, 0x4224, 0x0f7f, 0x007c, 0x708b, 0x0005,
+	0x1078, 0x4289, 0x20a3, 0x1103, 0x20a3, 0x0000, 0x3430, 0x2011,
+	0xab8e, 0x1078, 0x42d4, 0x00c0, 0x3d4c, 0x7074, 0xa005, 0x00c0,
+	0x3d4c, 0x7150, 0xa186, 0xffff, 0x0040, 0x3d4c, 0x1078, 0x419d,
+	0x0040, 0x3d4c, 0x1078, 0x42b8, 0x20a9, 0x0008, 0x2298, 0x26a0,
+	0x53a6, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x60c3, 0x0014, 0x1078,
+	0x420b, 0x007c, 0x0f7e, 0x7080, 0xa005, 0x0040, 0x3d84, 0x2011,
+	0x41dc, 0x1078, 0x5a45, 0xa086, 0x0014, 0x00c0, 0x3d82, 0x2079,
+	0xab80, 0x7a30, 0xa296, 0x1103, 0x00c0, 0x3d82, 0x7834, 0xa005,
+	0x00c0, 0x3d82, 0x7a38, 0xd2fc, 0x0040, 0x3d7c, 0x70b0, 0xa005,
+	0x00c0, 0x3d7c, 0x70b3, 0x0001, 0x708b, 0x0006, 0x1078, 0x3d86,
+	0x0078, 0x3d84, 0x1078, 0x4224, 0x0f7f, 0x007c, 0x708b, 0x0007,
+	0x1078, 0x4289, 0x20a3, 0x1104, 0x20a3, 0x0000, 0x3430, 0x2011,
+	0xab8e, 0x1078, 0x42d4, 0x00c0, 0x3dae, 0x7074, 0xa005, 0x00c0,
+	0x3dae, 0x7154, 0xa186, 0xffff, 0x0040, 0x3dae, 0xa180, 0x29c0,
+	0x200c, 0xa18c, 0xff00, 0x810f, 0x1078, 0x419d, 0x0040, 0x3dae,
+	0x1078, 0x3820, 0x0040, 0x3dae, 0x1078, 0x256a, 0x20a9, 0x0008,
+	0x2298, 0x26a0, 0x53a6, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x60c3,
+	0x0014, 0x1078, 0x420b, 0x007c, 0x0f7e, 0x7080, 0xa005, 0x0040,
+	0x3de6, 0x2011, 0x41dc, 0x1078, 0x5a45, 0xa086, 0x0014, 0x00c0,
+	0x3de4, 0x2079, 0xab80, 0x7a30, 0xa296, 0x1104, 0x00c0, 0x3de4,
+	0x7834, 0xa005, 0x00c0, 0x3de4, 0x7a38, 0xd2fc, 0x0040, 0x3dde,
+	0x70b0, 0xa005, 0x00c0, 0x3dde, 0x70b3, 0x0001, 0x708b, 0x0008,
+	0x1078, 0x3de8, 0x0078, 0x3de6, 0x1078, 0x4224, 0x0f7f, 0x007c,
+	0x708b, 0x0009, 0x1078, 0x4289, 0x20a3, 0x1105, 0x20a3, 0x0100,
+	0x3430, 0x1078, 0x42d4, 0x00c0, 0x3e01, 0x7074, 0xa005, 0x00c0,
+	0x3e01, 0x1078, 0x4104, 0x00c0, 0x3e0b, 0xa085, 0x0001, 0x1078,
+	0x256a, 0x20a9, 0x0008, 0x2099, 0xab8e, 0x26a0, 0x53a6, 0x20a3,
+	0x0000, 0x20a3, 0x0000, 0x60c3, 0x0014, 0x1078, 0x420b, 0x007c,
+	0x0f7e, 0x7080, 0xa005, 0x0040, 0x3e51, 0x2011, 0x41dc, 0x1078,
+	0x5a45, 0xa086, 0x0014, 0x00c0, 0x3e4f, 0x2079, 0xab80, 0x7a30,
+	0xa296, 0x1105, 0x00c0, 0x3e4f, 0x7834, 0x2011, 0x0100, 0xa21e,
+	0x00c0, 0x3e3a, 0x7a38, 0xd2fc, 0x0040, 0x3e34, 0x70b0, 0xa005,
+	0x00c0, 0x3e34, 0x70b3, 0x0001, 0x708b, 0x000a, 0x1078, 0x3e53,
+	0x0078, 0x3e51, 0xa005, 0x00c0, 0x3e4f, 0x7a38, 0xd2fc, 0x0040,
+	0x3e47, 0x70b0, 0xa005, 0x00c0, 0x3e47, 0x70b3, 0x0001, 0x7087,
+	0x0000, 0x708b, 0x000e, 0x1078, 0x3edb, 0x0078, 0x3e51, 0x1078,
+	0x4224, 0x0f7f, 0x007c, 0x708b, 0x000b, 0x2011, 0xab0e, 0x22a0,
+	0x20a9, 0x0040, 0x2019, 0xffff, 0x43a4, 0x20a9, 0x0002, 0x2009,
+	0x0000, 0x41a4, 0x1078, 0x4289, 0x20a3, 0x1106, 0x20a3, 0x0000,
+	0x1078, 0x42d4, 0x0040, 0x3e70, 0x2013, 0x0000, 0x0078, 0x3e74,
+	0x6030, 0xa085, 0x0100, 0x2012, 0x2298, 0x20a9, 0x0042, 0x53a6,
+	0x60c3, 0x0084, 0x1078, 0x420b, 0x007c, 0x0f7e, 0x7080, 0xa005,
+	0x0040, 0x3e9d, 0x2011, 0x41dc, 0x1078, 0x5a45, 0xa086, 0x0084,
+	0x00c0, 0x3e9b, 0x2079, 0xab80, 0x7a30, 0xa296, 0x1106, 0x00c0,
+	0x3e9b, 0x7834, 0xa005, 0x00c0, 0x3e9b, 0x708b, 0x000c, 0x1078,
+	0x3e9f, 0x0078, 0x3e9d, 0x1078, 0x4224, 0x0f7f, 0x007c, 0x708b,
+	0x000d, 0x1078, 0x4289, 0x20a3, 0x1107, 0x20a3, 0x0000, 0x2099,
+	0xab8e, 0x20a9, 0x0040, 0x53a6, 0x20a3, 0x0000, 0x20a3, 0x0000,
+	0x60c3, 0x0084, 0x1078, 0x420b, 0x007c, 0x0f7e, 0x7080, 0xa005,
+	0x0040, 0x3ed9, 0x2011, 0x41dc, 0x1078, 0x5a45, 0xa086, 0x0084,
+	0x00c0, 0x3ed7, 0x2079, 0xab80, 0x7a30, 0xa296, 0x1107, 0x00c0,
+	0x3ed7, 0x7834, 0xa005, 0x00c0, 0x3ed7, 0x7087, 0x0001, 0x1078,
+	0x427b, 0x708b, 0x000e, 0x1078, 0x3edb, 0x0078, 0x3ed9, 0x1078,
+	0x4224, 0x0f7f, 0x007c, 0x708b, 0x000f, 0x7083, 0x0000, 0x608b,
+	0xbc85, 0x608f, 0xb5b5, 0x6043, 0x0005, 0x6043, 0x0004, 0x2009,
+	0x07d0, 0x2011, 0x41dc, 0x1078, 0x5a38, 0x007c, 0x7080, 0xa005,
+	0x0040, 0x3ef6, 0x2011, 0x41dc, 0x1078, 0x5a45, 0x007c, 0x708b,
+	0x0011, 0x1078, 0x42d4, 0x00c0, 0x3f14, 0x716c, 0x81ff, 0x0040,
+	0x3f14, 0x2009, 0x0000, 0x7070, 0xa084, 0x00ff, 0x1078, 0x254d,
+	0xa186, 0x007e, 0x0040, 0x3f14, 0xa186, 0x0080, 0x0040, 0x3f14,
+	0x2011, 0xab8e, 0x1078, 0x419d, 0x20e1, 0x9080, 0x20e1, 0x4000,
+	0x2099, 0xab80, 0x20a1, 0x020b, 0x7480, 0xa480, 0x0018, 0xa080,
+	0x0007, 0xa084, 0x03f8, 0x8004, 0x20a8, 0x53a6, 0x60c3, 0x0014,
+	0x1078, 0x420b, 0x007c, 0x0f7e, 0x7080, 0xa005, 0x0040, 0x3f55,
+	0x2011, 0x41dc, 0x1078, 0x5a45, 0xa086, 0x0014, 0x00c0, 0x3f53,
+	0x2079, 0xab80, 0x7a30, 0xa296, 0x1103, 0x00c0, 0x3f53, 0x7834,
+	0xa005, 0x00c0, 0x3f53, 0x7a38, 0xd2fc, 0x0040, 0x3f4d, 0x70b0,
+	0xa005, 0x00c0, 0x3f4d, 0x70b3, 0x0001, 0x708b, 0x0012, 0x1078,
+	0x3f57, 0x0078, 0x3f55, 0x1078, 0x4224, 0x0f7f, 0x007c, 0x708b,
+	0x0013, 0x1078, 0x4295, 0x20a3, 0x1103, 0x20a3, 0x0000, 0x3430,
+	0x2011, 0xab8e, 0x1078, 0x42d4, 0x00c0, 0x3f75, 0x7074, 0xa005,
+	0x00c0, 0x3f75, 0x7150, 0xa186, 0xffff, 0x0040, 0x3f75, 0x1078,
+	0x419d, 0x0040, 0x3f75, 0x1078, 0x42b8, 0x20a9, 0x0008, 0x2298,
+	0x26a0, 0x53a6, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x60c3, 0x0014,
+	0x1078, 0x420b, 0x007c, 0x0f7e, 0x7080, 0xa005, 0x0040, 0x3fad,
+	0x2011, 0x41dc, 0x1078, 0x5a45, 0xa086, 0x0014, 0x00c0, 0x3fab,
+	0x2079, 0xab80, 0x7a30, 0xa296, 0x1104, 0x00c0, 0x3fab, 0x7834,
+	0xa005, 0x00c0, 0x3fab, 0x7a38, 0xd2fc, 0x0040, 0x3fa5, 0x70b0,
+	0xa005, 0x00c0, 0x3fa5, 0x70b3, 0x0001, 0x708b, 0x0014, 0x1078,
+	0x3faf, 0x0078, 0x3fad, 0x1078, 0x4224, 0x0f7f, 0x007c, 0x708b,
+	0x0015, 0x1078, 0x4295, 0x20a3, 0x1104, 0x20a3, 0x0000, 0x3430,
+	0x2011, 0xab8e, 0x1078, 0x42d4, 0x00c0, 0x3fd7, 0x7074, 0xa005,
+	0x00c0, 0x3fd7, 0x7154, 0xa186, 0xffff, 0x0040, 0x3fd7, 0xa180,
+	0x29c0, 0x200c, 0xa18c, 0xff00, 0x810f, 0x1078, 0x419d, 0x0040,
+	0x3fd7, 0x1078, 0x3820, 0x0040, 0x3fd7, 0x1078, 0x256a, 0x20a9,
+	0x0008, 0x2298, 0x26a0, 0x53a6, 0x20a3, 0x0000, 0x20a3, 0x0000,
+	0x60c3, 0x0014, 0x1078, 0x420b, 0x007c, 0x0f7e, 0x7080, 0xa005,
+	0x0040, 0x402e, 0x2011, 0x41dc, 0x1078, 0x5a45, 0xa086, 0x0014,
+	0x00c0, 0x402c, 0x2079, 0xab80, 0x7a30, 0xa296, 0x1105, 0x00c0,
+	0x402c, 0x7834, 0x2011, 0x0100, 0xa21e, 0x00c0, 0x400b, 0x7a38,
+	0xd2fc, 0x0040, 0x4009, 0x70b0, 0xa005, 0x00c0, 0x4009, 0x70b3,
+	0x0001, 0x0078, 0x401a, 0xa005, 0x00c0, 0x402c, 0x7a38, 0xd2fc,
+	0x0040, 0x4018, 0x70b0, 0xa005, 0x00c0, 0x4018, 0x70b3, 0x0001,
+	0x7087, 0x0000, 0x7a38, 0xd2f4, 0x0040, 0x4026, 0x2001, 0xa674,
+	0x2004, 0xd0a4, 0x00c0, 0x4026, 0x70cf, 0x0008, 0x708b, 0x0016,
+	0x1078, 0x4030, 0x0078, 0x402e, 0x1078, 0x4224, 0x0f7f, 0x007c,
+	0x20e1, 0x9080, 0x20e1, 0x4000, 0x2099, 0xab80, 0x20a1, 0x020b,
+	0x20a9, 0x000e, 0x53a6, 0x3430, 0x2011, 0xab8e, 0x708b, 0x0017,
+	0x1078, 0x42d4, 0x00c0, 0x4050, 0x7074, 0xa005, 0x00c0, 0x4050,
+	0x1078, 0x4104, 0x00c0, 0x405a, 0xa085, 0x0001, 0x1078, 0x256a,
+	0x20a9, 0x0008, 0x2099, 0xab8e, 0x26a0, 0x53a6, 0x20a3, 0x0000,
+	0x20a3, 0x0000, 0x60c3, 0x0014, 0x1078, 0x420b, 0x007c, 0x0f7e,
+	0x7080, 0xa005, 0x0040, 0x407f, 0x2011, 0x41dc, 0x1078, 0x5a45,
+	0xa086, 0x0084, 0x00c0, 0x407d, 0x2079, 0xab80, 0x7a30, 0xa296,
+	0x1106, 0x00c0, 0x407d, 0x7834, 0xa005, 0x00c0, 0x407d, 0x708b,
+	0x0018, 0x1078, 0x4081, 0x0078, 0x407f, 0x1078, 0x4224, 0x0f7f,
+	0x007c, 0x708b, 0x0019, 0x1078, 0x4295, 0x20a3, 0x1106, 0x20a3,
+	0x0000, 0x3430, 0x2099, 0xab8e, 0x2039, 0xab0e, 0x27a0, 0x20a9,
+	0x0040, 0x53a3, 0x1078, 0x42d4, 0x00c0, 0x40b5, 0x2728, 0x2514,
+	0x8207, 0xa084, 0x00ff, 0x8000, 0x2018, 0xa294, 0x00ff, 0x8007,
+	0xa205, 0x202a, 0x6030, 0x2310, 0x8214, 0xa2a0, 0xab0e, 0x2414,
+	0xa38c, 0x0001, 0x0040, 0x40b0, 0xa294, 0xff00, 0x0078, 0x40b3,
+	0xa294, 0x00ff, 0x8007, 0xa215, 0x2222, 0x2798, 0x26a0, 0x20a9,
+	0x0040, 0x53a6, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x60c3, 0x0084,
+	0x1078, 0x420b, 0x007c, 0x0f7e, 0x7080, 0xa005, 0x0040, 0x40e7,
+	0x2011, 0x41dc, 0x1078, 0x5a45, 0xa086, 0x0084, 0x00c0, 0x40e5,
+	0x2079, 0xab80, 0x7a30, 0xa296, 0x1107, 0x00c0, 0x40e5, 0x7834,
+	0xa005, 0x00c0, 0x40e5, 0x7087, 0x0001, 0x1078, 0x427b, 0x708b,
+	0x001a, 0x1078, 0x40e9, 0x0078, 0x40e7, 0x1078, 0x4224, 0x0f7f,
+	0x007c, 0x708b, 0x001b, 0x20e1, 0x9080, 0x20e1, 0x4000, 0x2099,
+	0xab80, 0x20a1, 0x020b, 0x7480, 0xa480, 0x0018, 0xa080, 0x0007,
+	0xa084, 0x03f8, 0x8004, 0x20a8, 0x53a6, 0x60c3, 0x0084, 0x1078,
+	0x420b, 0x007c, 0x007c, 0x007c, 0x087e, 0x097e, 0x2029, 0xa653,
+	0x252c, 0x20a9, 0x0008, 0x2041, 0xab0e, 0x28a0, 0x2099, 0xab8e,
+	0x53a3, 0x20a9, 0x0008, 0x2011, 0x0007, 0xd5d4, 0x0040, 0x411a,
+	0x2011, 0x0000, 0x2800, 0xa200, 0x200c, 0xa1a6, 0xffff, 0x00c0,
+	0x412c, 0xd5d4, 0x0040, 0x4127, 0x8210, 0x0078, 0x4128, 0x8211,
+	0x00f0, 0x411a, 0x0078, 0x4194, 0x82ff, 0x00c0, 0x413e, 0xd5d4,
+	0x0040, 0x4138, 0xa1a6, 0x3fff, 0x0040, 0x4124, 0x0078, 0x413c,
+	0xa1a6, 0x3fff, 0x0040, 0x4194, 0xa18d, 0xc000, 0x20a9, 0x0010,
+	0x2019, 0x0001, 0xd5d4, 0x0040, 0x4147, 0x2019, 0x0010, 0x2120,
+	0xd5d4, 0x0040, 0x414e, 0x8423, 0x0078, 0x414f, 0x8424, 0x00c8,
+	0x415c, 0xd5d4, 0x0040, 0x4157, 0x8319, 0x0078, 0x4158, 0x8318,
+	0x00f0, 0x4148, 0x0078, 0x4194, 0x23a8, 0x2021, 0x0001, 0x8426,
+	0x8425, 0x00f0, 0x4160, 0x2328, 0x8529, 0xa2be, 0x0007, 0x0040,
+	0x4174, 0x007e, 0x2039, 0x0007, 0x2200, 0xa73a, 0x007f, 0x27a8,
+	0xa5a8, 0x0010, 0x00f0, 0x4170, 0x7552, 0xa5c8, 0x29c0, 0x292c,
+	0xa5ac, 0x00ff, 0x6532, 0x60e7, 0x0000, 0x65ea, 0x706f, 0x0000,
+	0x7572, 0x2018, 0x2304, 0xa405, 0x201a, 0x7077, 0x0001, 0x26a0,
+	0x2898, 0x20a9, 0x0008, 0x53a6, 0x20a3, 0x0000, 0x20a3, 0x0000,
+	0xa085, 0x0001, 0x0078, 0x419a, 0xa006, 0x0078, 0x419a, 0xa006,
+	0x1078, 0x1332, 0x097f, 0x087f, 0x007c, 0x2118, 0x2021, 0x0000,
+	0x2001, 0x0007, 0xa39a, 0x0010, 0x0048, 0x41aa, 0x8420, 0x8001,
+	0x0078, 0x41a2, 0x2118, 0x84ff, 0x0040, 0x41b3, 0xa39a, 0x0010,
+	0x8421, 0x00c0, 0x41ae, 0x2021, 0x0001, 0x83ff, 0x0040, 0x41bc,
+	0x8423, 0x8319, 0x00c0, 0x41b8, 0xa238, 0x2704, 0xa42c, 0x00c0,
+	0x41d4, 0xa405, 0x203a, 0x7152, 0xa1a0, 0x29c0, 0x242c, 0xa5ac,
+	0x00ff, 0x6532, 0x60e7, 0x0000, 0x65ea, 0x706f, 0x0000, 0x7572,
+	0x7077, 0x0001, 0xa084, 0x0000, 0x007c, 0x0e7e, 0x2071, 0xa600,
+	0x707b, 0x0000, 0x0e7f, 0x007c, 0x0e7e, 0x0f7e, 0x2001, 0x0002,
+	0x1078, 0x5ae6, 0x2079, 0x0100, 0x2071, 0x0140, 0x1078, 0x6e0f,
+	0x7004, 0xa084, 0x4000, 0x0040, 0x41f1, 0x7003, 0x1000, 0x7003,
+	0x0000, 0x127e, 0x2091, 0x8000, 0x2071, 0xa622, 0x2073, 0x0000,
+	0x7840, 0x027e, 0x017e, 0x2009, 0x00f7, 0x1078, 0x42a1, 0x017f,
+	0xa094, 0x0010, 0xa285, 0x0080, 0x7842, 0x7a42, 0x027f, 0x127f,
+	0x0f7f, 0x0e7f, 0x007c, 0x127e, 0x2091, 0x8000, 0x2011, 0xa8bb,
+	0x2013, 0x0000, 0x7083, 0x0000, 0x127f, 0x20e1, 0x9080, 0x60a3,
+	0x0056, 0x60a7, 0x9575, 0x1078, 0x6e06, 0x2009, 0x07d0, 0x2011,
+	0x41dc, 0x1078, 0x5add, 0x007c, 0x017e, 0x027e, 0x0c7e, 0x127e,
+	0x2091, 0x8000, 0x2011, 0x0003, 0x1078, 0x70e0, 0x2011, 0x0002,
+	0x1078, 0x70ea, 0x1078, 0x6fc4, 0x037e, 0x2019, 0x0000, 0x1078,
+	0x7058, 0x037f, 0x2009, 0x00f7, 0x1078, 0x42a1, 0x2061, 0xa8c4,
+	0x601b, 0x0000, 0x601f, 0x0000, 0x2061, 0xa600, 0x6003, 0x0001,
+	0x2061, 0x0100, 0x6043, 0x0090, 0x6043, 0x0010, 0x2009, 0x002d,
+	0x2011, 0x4259, 0x1078, 0x5a38, 0x127f, 0x0c7f, 0x027f, 0x017f,
+	0x007c, 0x0e7e, 0x007e, 0x127e, 0x2091, 0x8000, 0x2001, 0x0001,
+	0x1078, 0x5ae6, 0x2071, 0x0100, 0x1078, 0x6e0f, 0x2071, 0x0140,
+	0x7004, 0xa084, 0x4000, 0x0040, 0x4271, 0x7003, 0x1000, 0x7003,
+	0x0000, 0x2001, 0x0001, 0x1078, 0x24e8, 0x1078, 0x4224, 0x127f,
+	0x007f, 0x0e7f, 0x007c, 0x20a9, 0x0040, 0x20a1, 0xacc0, 0x2099,
+	0xab8e, 0x3304, 0x8007, 0x20a2, 0x9398, 0x94a0, 0x00f0, 0x4281,
+	0x007c, 0x20e1, 0x9080, 0x20e1, 0x4000, 0x2099, 0xab00, 0x20a1,
+	0x020b, 0x20a9, 0x000c, 0x53a6, 0x007c, 0x20e1, 0x9080, 0x20e1,
+	0x4000, 0x2099, 0xab80, 0x20a1, 0x020b, 0x20a9, 0x000c, 0x53a6,
+	0x007c, 0x0c7e, 0x007e, 0x2061, 0x0100, 0x810f, 0x2001, 0xa62f,
+	0x2004, 0xa005, 0x00c0, 0x42b2, 0x6030, 0xa084, 0x00ff, 0xa105,
+	0x0078, 0x42b4, 0xa185, 0x00f7, 0x604a, 0x007f, 0x0c7f, 0x007c,
+	0x017e, 0x047e, 0x2001, 0xa653, 0x2004, 0xd0a4, 0x0040, 0x42cb,
+	0xa006, 0x2020, 0x2009, 0x002a, 0x1078, 0xa21d, 0x2001, 0xa60c,
+	0x200c, 0xc195, 0x2102, 0x2019, 0x002a, 0x2009, 0x0000, 0x1078,
+	0x284f, 0x047f, 0x017f, 0x007c, 0x007e, 0x2001, 0xa60c, 0x2004,
+	0xd09c, 0x0040, 0x42db, 0x007f, 0x007c, 0x007e, 0x017e, 0x127e,
+	0x2091, 0x8000, 0x2001, 0x0101, 0x200c, 0xa18d, 0x0006, 0x2102,
+	0x127f, 0x017f, 0x007f, 0x007c, 0x157e, 0x20a9, 0x00ff, 0x2009,
+	0xa735, 0xa006, 0x200a, 0x8108, 0x00f0, 0x42f2, 0x157f, 0x007c,
+	0x0d7e, 0x037e, 0x157e, 0x137e, 0x147e, 0x2069, 0xa652, 0xa006,
+	0x6002, 0x6007, 0x0707, 0x600a, 0x600e, 0x6012, 0xa198, 0x29c0,
+	0x231c, 0xa39c, 0x00ff, 0x6316, 0x20a9, 0x0004, 0xac98, 0x0006,
+	0x23a0, 0x40a4, 0x20a9, 0x0004, 0xac98, 0x000a, 0x23a0, 0x40a4,
+	0x603e, 0x6042, 0x604e, 0x6052, 0x6056, 0x605a, 0x605e, 0x6062,
+	0x6066, 0x606a, 0x606e, 0x6072, 0x6076, 0x607a, 0x607e, 0x6082,
+	0x6086, 0x608a, 0x608e, 0x6092, 0x6096, 0x609a, 0x609e, 0x60ae,
+	0x61a2, 0x0d7e, 0x60a4, 0xa06d, 0x0040, 0x4338, 0x1078, 0x13a4,
+	0x60a7, 0x0000, 0x60a8, 0xa06d, 0x0040, 0x4340, 0x1078, 0x13a4,
+	0x60ab, 0x0000, 0x0d7f, 0xa006, 0x604a, 0x6810, 0x603a, 0x680c,
+	0x6046, 0x6814, 0xa084, 0x00ff, 0x6042, 0x147f, 0x137f, 0x157f,
+	0x037f, 0x0d7f, 0x007c, 0x127e, 0x2091, 0x8000, 0x6944, 0x6e48,
+	0xa684, 0x3fff, 0xa082, 0x4000, 0x00c8, 0x4424, 0xa18c, 0xff00,
+	0x810f, 0xa182, 0x00ff, 0x00c8, 0x442a, 0x2001, 0xa60c, 0x2004,
+	0xa084, 0x0003, 0x0040, 0x4385, 0x2001, 0xa60c, 0x2004, 0xd084,
+	0x00c0, 0x4405, 0xa188, 0xa735, 0x2104, 0xa065, 0x0040, 0x4405,
+	0x6004, 0xa084, 0x00ff, 0xa08e, 0x0006, 0x00c0, 0x4405, 0x6000,
+	0xd0c4, 0x0040, 0x4405, 0x0078, 0x4392, 0xa188, 0xa735, 0x2104,
+	0xa065, 0x0040, 0x43e9, 0x6004, 0xa084, 0x00ff, 0xa08e, 0x0006,
+	0x00c0, 0x43ef, 0x60a4, 0xa00d, 0x0040, 0x439a, 0x1078, 0x4817,
+	0x0040, 0x43e3, 0x60a8, 0xa00d, 0x0040, 0x43b4, 0x1078, 0x486a,
+	0x00c0, 0x43b4, 0x694c, 0xd1fc, 0x00c0, 0x43aa, 0x1078, 0x44df,
+	0x0078, 0x43de, 0x1078, 0x4484, 0x694c, 0xd1ec, 0x00c0, 0x43de,
+	0x1078, 0x46d6, 0x0078, 0x43de, 0x694c, 0xa184, 0xa000, 0x0040,
+	0x43ce, 0xd1ec, 0x0040, 0x43c7, 0xd1fc, 0x0040, 0x43c3, 0x1078,
+	0x46e7, 0x0078, 0x43ca, 0x1078, 0x46e7, 0x0078, 0x43ce, 0xd1fc,
+	0x0040, 0x43ce, 0x1078, 0x4484, 0x0078, 0x43de, 0x6050, 0xa00d,
+	0x0040, 0x43d9, 0x2d00, 0x200a, 0x6803, 0x0000, 0x6052, 0x0078,
+	0x43de, 0x2d00, 0x6052, 0x604e, 0x6803, 0x0000, 0x1078, 0x5da9,
+	0xa006, 0x127f, 0x007c, 0x2001, 0x0005, 0x2009, 0x0000, 0x0078,
+	0x442e, 0x2001, 0x0028, 0x2009, 0x0000, 0x0078, 0x442e, 0xa082,
+	0x0006, 0x00c8, 0x4405, 0x60a0, 0xd0bc, 0x00c0, 0x4401, 0x6100,
+	0xd1fc, 0x0040, 0x4392, 0x2001, 0x0029, 0x2009, 0x1000, 0x0078,
+	0x442e, 0x2001, 0x0028, 0x0078, 0x4420, 0x2009, 0xa60c, 0x210c,
+	0xd18c, 0x0040, 0x440f, 0x2001, 0x0004, 0x0078, 0x4420, 0xd184,
+	0x0040, 0x4416, 0x2001, 0x0004, 0x0078, 0x4420, 0x2001, 0x0029,
+	0x6100, 0xd1fc, 0x0040, 0x4420, 0x2009, 0x1000, 0x0078, 0x442e,
+	0x2009, 0x0000, 0x0078, 0x442e, 0x2001, 0x0029, 0x2009, 0x0000,
+	0x0078, 0x442e, 0x2001, 0x0029, 0x2009, 0x0000, 0xa005, 0x127f,
+	0x007c, 0x6944, 0x6e48, 0xa684, 0x3fff, 0xa082, 0x4000, 0x00c8,
+	0x447e, 0xa18c, 0xff00, 0x810f, 0xa182, 0x00ff, 0x00c8, 0x4464,
+	0xa188, 0xa735, 0x2104, 0xa065, 0x0040, 0x4464, 0x6004, 0xa084,
+	0x00ff, 0xa08e, 0x0006, 0x00c0, 0x446a, 0x684c, 0xd0ec, 0x0040,
+	0x4457, 0x1078, 0x46e7, 0x1078, 0x4484, 0x0078, 0x445f, 0x1078,
+	0x4484, 0x684c, 0xd0fc, 0x0040, 0x445f, 0x1078, 0x46d6, 0x1078,
+	0x472f, 0xa006, 0x0078, 0x4482, 0x2001, 0x0028, 0x2009, 0x0000,
+	0x0078, 0x4482, 0xa082, 0x0006, 0x00c8, 0x4478, 0x6100, 0xd1fc,
+	0x0040, 0x444d, 0x2001, 0x0029, 0x2009, 0x1000, 0x0078, 0x4482,
+	0x2001, 0x0029, 0x2009, 0x0000, 0x0078, 0x4482, 0x2001, 0x0029,
+	0x2009, 0x0000, 0xa005, 0x007c, 0x127e, 0x2091, 0x8000, 0x6050,
+	0xa00d, 0x0040, 0x4492, 0x2d00, 0x200a, 0x6803, 0x0000, 0x6052,
+	0x127f, 0x007c, 0x2d00, 0x6052, 0x604e, 0x6803, 0x0000, 0x0078,
+	0x4490, 0x127e, 0x2091, 0x8000, 0x604c, 0xa005, 0x0040, 0x44af,
+	0x0e7e, 0x2071, 0xa8b1, 0x7004, 0xa086, 0x0002, 0x0040, 0x44b6,
+	0x0e7f, 0x604c, 0x6802, 0x2d00, 0x604e, 0x127f, 0x007c, 0x2d00,
+	0x6052, 0x604e, 0x6803, 0x0000, 0x0078, 0x44ad, 0x701c, 0xac06,
+	0x00c0, 0x44a8, 0x604c, 0x2070, 0x7000, 0x6802, 0x2d00, 0x7002,
+	0x0e7f, 0x127f, 0x007c, 0x127e, 0x2091, 0x8000, 0x604c, 0xa06d,
+	0x0040, 0x44d1, 0x6800, 0xa005, 0x00c0, 0x44cf, 0x6052, 0x604e,
+	0xad05, 0x127f, 0x007c, 0x604c, 0xa06d, 0x0040, 0x44de, 0x6800,
+	0xa005, 0x00c0, 0x44dc, 0x6052, 0x604e, 0xad05, 0x007c, 0x6803,
+	0x0000, 0x6084, 0xa00d, 0x0040, 0x44e9, 0x2d00, 0x200a, 0x6086,
+	0x007c, 0x2d00, 0x6086, 0x6082, 0x0078, 0x44e8, 0x127e, 0x0c7e,
+	0x027e, 0x2091, 0x8000, 0x6218, 0x2260, 0x6200, 0xa005, 0x0040,
+	0x44fc, 0xc285, 0x0078, 0x44fd, 0xc284, 0x6202, 0x027f, 0x0c7f,
+	0x127f, 0x007c, 0x127e, 0x0c7e, 0x2091, 0x8000, 0x6218, 0x2260,
+	0x6204, 0x007e, 0xa086, 0x0006, 0x00c0, 0x4521, 0x609c, 0xd0ac,
+	0x0040, 0x4521, 0x2001, 0xa653, 0x2004, 0xd0a4, 0x0040, 0x4521,
+	0xa284, 0xff00, 0x8007, 0xa086, 0x0007, 0x00c0, 0x4521, 0x2011,
+	0x0600, 0x007f, 0xa294, 0xff00, 0xa215, 0x6206, 0x007e, 0xa086,
+	0x0006, 0x00c0, 0x4531, 0x6290, 0x82ff, 0x00c0, 0x4531, 0x1078,
+	0x1332, 0x007f, 0x0c7f, 0x127f, 0x007c, 0x127e, 0x0c7e, 0x2091,
+	0x8000, 0x6218, 0x2260, 0x6204, 0x007e, 0xa086, 0x0006, 0x00c0,
+	0x4553, 0x609c, 0xd0a4, 0x0040, 0x4553, 0x2001, 0xa653, 0x2004,
+	0xd0ac, 0x00c0, 0x4553, 0xa284, 0x00ff, 0xa086, 0x0007, 0x00c0,
+	0x4553, 0x2011, 0x0006, 0x007f, 0xa294, 0x00ff, 0x8007, 0xa215,
+	0x6206, 0x0c7f, 0x127f, 0x007c, 0x027e, 0xa182, 0x00ff, 0x0048,
+	0x4565, 0xa085, 0x0001, 0x0078, 0x457d, 0xa190, 0xa735, 0x2204,
+	0xa065, 0x00c0, 0x457c, 0x017e, 0x0d7e, 0x1078, 0x1370, 0x2d60,
+	0x0d7f, 0x017f, 0x0040, 0x4561, 0x2c00, 0x2012, 0x60a7, 0x0000,
+	0x60ab, 0x0000, 0x1078, 0x42f8, 0xa006, 0x027f, 0x007c, 0x127e,
+	0x2091, 0x8000, 0x027e, 0xa182, 0x00ff, 0x0048, 0x458b, 0xa085,
+	0x0001, 0x0078, 0x45c1, 0x0d7e, 0xa190, 0xa735, 0x2204, 0xa06d,
+	0x0040, 0x45bf, 0x2013, 0x0000, 0x0d7e, 0x0c7e, 0x2d60, 0x60a4,
+	0xa06d, 0x0040, 0x459d, 0x1078, 0x13a4, 0x60a8, 0xa06d, 0x0040,
+	0x45a3, 0x1078, 0x13a4, 0x0c7f, 0x0d7f, 0x0d7e, 0x0c7e, 0x68ac,
+	0x2060, 0x8cff, 0x0040, 0x45bb, 0x600c, 0x007e, 0x6010, 0x2068,
+	0x1078, 0x8d06, 0x0040, 0x45b6, 0x1078, 0x13b4, 0x1078, 0x772d,
+	0x0c7f, 0x0078, 0x45a9, 0x0c7f, 0x0d7f, 0x1078, 0x13a4, 0x0d7f,
+	0xa006, 0x027f, 0x127f, 0x007c, 0x017e, 0xa182, 0x00ff, 0x0048,
+	0x45cd, 0xa085, 0x0001, 0x0078, 0x45d4, 0xa188, 0xa735, 0x2104,
+	0xa065, 0x0040, 0x45c9, 0xa006, 0x017f, 0x007c, 0x0d7e, 0x157e,
+	0x137e, 0x147e, 0x600b, 0x0000, 0x600f, 0x0000, 0x6000, 0xc08c,
+	0x6002, 0x2069, 0xab8e, 0x6808, 0x605e, 0x6810, 0x6062, 0x6138,
+	0xa10a, 0x0048, 0x45ec, 0x603a, 0x6814, 0x6066, 0x2099, 0xab96,
+	0xac88, 0x000a, 0x21a0, 0x20a9, 0x0004, 0x53a3, 0x2099, 0xab9a,
+	0xac88, 0x0006, 0x21a0, 0x20a9, 0x0004, 0x53a3, 0x2069, 0xabae,
+	0x6808, 0x606a, 0x690c, 0x616e, 0x6810, 0x6072, 0x6818, 0x6076,
+	0x60a0, 0xa086, 0x007e, 0x00c0, 0x4611, 0x2069, 0xab8e, 0x690c,
+	0x616e, 0xa182, 0x0211, 0x00c8, 0x4619, 0x2009, 0x0008, 0x0078,
+	0x4643, 0xa182, 0x0259, 0x00c8, 0x4621, 0x2009, 0x0007, 0x0078,
+	0x4643, 0xa182, 0x02c1, 0x00c8, 0x4629, 0x2009, 0x0006, 0x0078,
+	0x4643, 0xa182, 0x0349, 0x00c8, 0x4631, 0x2009, 0x0005, 0x0078,
+	0x4643, 0xa182, 0x0421, 0x00c8, 0x4639, 0x2009, 0x0004, 0x0078,
+	0x4643, 0xa182, 0x0581, 0x00c8, 0x4641, 0x2009, 0x0003, 0x0078,
+	0x4643, 0x2009, 0x0002, 0x6192, 0x147f, 0x137f, 0x157f, 0x0d7f,
+	0x007c, 0x017e, 0x027e, 0x0e7e, 0x2071, 0xab8d, 0x2e04, 0x6896,
+	0x2071, 0xab8e, 0x7004, 0x689a, 0x701c, 0x689e, 0x6a00, 0x2009,
+	0xa672, 0x210c, 0xd0bc, 0x0040, 0x4663, 0xd1ec, 0x0040, 0x4663,
+	0xc2ad, 0x0078, 0x4664, 0xc2ac, 0xd0c4, 0x0040, 0x466d, 0xd1e4,
+	0x0040, 0x466d, 0xc2bd, 0x0078, 0x466e, 0xc2bc, 0x6a02, 0x0e7f,
+	0x027f, 0x017f, 0x007c, 0x0d7e, 0x127e, 0x2091, 0x8000, 0x60a4,
+	0xa06d, 0x0040, 0x4697, 0x6900, 0x81ff, 0x00c0, 0x46ab, 0x6a04,
+	0xa282, 0x0010, 0x00c8, 0x46b0, 0xad88, 0x0004, 0x20a9, 0x0010,
+	0x2104, 0xa086, 0xffff, 0x0040, 0x4692, 0x8108, 0x00f0, 0x4688,
+	0x1078, 0x1332, 0x260a, 0x8210, 0x6a06, 0x0078, 0x46ab, 0x1078,
+	0x138b, 0x0040, 0x46b0, 0x2d00, 0x60a6, 0x6803, 0x0000, 0xad88,
+	0x0004, 0x20a9, 0x0010, 0x200b, 0xffff, 0x8108, 0x00f0, 0x46a3,
+	0x6807, 0x0001, 0x6e12, 0xa085, 0x0001, 0x127f, 0x0d7f, 0x007c,
+	0xa006, 0x0078, 0x46ad, 0x127e, 0x2091, 0x8000, 0x0d7e, 0x60a4,
+	0xa00d, 0x0040, 0x46d3, 0x2168, 0x6800, 0xa005, 0x00c0, 0x46cf,
+	0x1078, 0x4817, 0x00c0, 0x46d3, 0x200b, 0xffff, 0x6804, 0xa08a,
+	0x0002, 0x0048, 0x46cf, 0x8001, 0x6806, 0x0078, 0x46d3, 0x1078,
+	0x13a4, 0x60a7, 0x0000, 0x0d7f, 0x127f, 0x007c, 0x127e, 0x2091,
+	0x8000, 0x1078, 0x487f, 0x0078, 0x46df, 0x1078, 0x4484, 0x1078,
+	0x4775, 0x00c0, 0x46dd, 0x1078, 0x472f, 0x127f, 0x007c, 0x0d7e,
+	0x127e, 0x2091, 0x8000, 0x60a8, 0xa06d, 0x0040, 0x470b, 0x6950,
+	0x81ff, 0x00c0, 0x471f, 0x6a54, 0xa282, 0x0010, 0x00c8, 0x472c,
+	0xad88, 0x0018, 0x20a9, 0x0010, 0x2104, 0xa086, 0xffff, 0x0040,
+	0x4706, 0x8108, 0x00f0, 0x46fc, 0x1078, 0x1332, 0x260a, 0x8210,
+	0x6a56, 0x0078, 0x471f, 0x1078, 0x138b, 0x0040, 0x472c, 0x2d00,
+	0x60aa, 0x6853, 0x0000, 0xad88, 0x0018, 0x20a9, 0x0010, 0x200b,
+	0xffff, 0x8108, 0x00f0, 0x4717, 0x6857, 0x0001, 0x6e62, 0x0078,
+	0x4723, 0x1078, 0x44df, 0x1078, 0x4739, 0x00c0, 0x4721, 0xa085,
+	0x0001, 0x127f, 0x0d7f, 0x007c, 0xa006, 0x0078, 0x4729, 0x127e,
+	0x2091, 0x8000, 0x1078, 0x5da9, 0x127f, 0x007c, 0xa01e, 0x0078,
+	0x473b, 0x2019, 0x0001, 0xa00e, 0x127e, 0x2091, 0x8000, 0x604c,
+	0x2068, 0x6000, 0xd0dc, 0x00c0, 0x4759, 0x8dff, 0x0040, 0x4770,
+	0x83ff, 0x0040, 0x4751, 0x6848, 0xa606, 0x0040, 0x475e, 0x0078,
+	0x4759, 0x683c, 0xa406, 0x00c0, 0x4759, 0x6840, 0xa506, 0x0040,
+	0x475e, 0x2d08, 0x6800, 0x2068, 0x0078, 0x4745, 0x1078, 0x7233,
+	0x6a00, 0x604c, 0xad06, 0x00c0, 0x4768, 0x624e, 0x0078, 0x476b,
+	0xa180, 0x0000, 0x2202, 0x82ff, 0x00c0, 0x4770, 0x6152, 0x8dff,
+	0x127f, 0x007c, 0xa01e, 0x0078, 0x4777, 0x2019, 0x0001, 0xa00e,
+	0x6080, 0x2068, 0x8dff, 0x0040, 0x47a3, 0x83ff, 0x0040, 0x4786,
+	0x6848, 0xa606, 0x0040, 0x4793, 0x0078, 0x478e, 0x683c, 0xa406,
+	0x00c0, 0x478e, 0x6840, 0xa506, 0x0040, 0x4793, 0x2d08, 0x6800,
+	0x2068, 0x0078, 0x477a, 0x6a00, 0x6080, 0xad06, 0x00c0, 0x479b,
+	0x6282, 0x0078, 0x479e, 0xa180, 0x0000, 0x2202, 0x82ff, 0x00c0,
+	0x47a3, 0x6186, 0x8dff, 0x007c, 0xa016, 0x1078, 0x4810, 0x00c0,
+	0x47ab, 0x2011, 0x0001, 0x1078, 0x4863, 0x00c0, 0x47b1, 0xa295,
+	0x0002, 0x007c, 0x1078, 0x489b, 0x0040, 0x47ba, 0x1078, 0x8dca,
+	0x0078, 0x47bc, 0xa085, 0x0001, 0x007c, 0x1078, 0x489b, 0x0040,
+	0x47c5, 0x1078, 0x8d62, 0x0078, 0x47c7, 0xa085, 0x0001, 0x007c,
+	0x1078, 0x489b, 0x0040, 0x47d0, 0x1078, 0x8dac, 0x0078, 0x47d2,
+	0xa085, 0x0001, 0x007c, 0x1078, 0x489b, 0x0040, 0x47db, 0x1078,
+	0x8d7e, 0x0078, 0x47dd, 0xa085, 0x0001, 0x007c, 0x1078, 0x489b,
+	0x0040, 0x47e6, 0x1078, 0x8de8, 0x0078, 0x47e8, 0xa085, 0x0001,
+	0x007c, 0x127e, 0x007e, 0x0d7e, 0x2091, 0x8000, 0x6080, 0xa06d,
+	0x0040, 0x4808, 0x6800, 0x007e, 0x6837, 0x0103, 0x6b4a, 0x6847,
+	0x0000, 0x1078, 0x8f7d, 0x007e, 0x6000, 0xd0fc, 0x0040, 0x4802,
+	0x1078, 0xa4ed, 0x007f, 0x1078, 0x4a73, 0x007f, 0x0078, 0x47ef,
+	0x6083, 0x0000, 0x6087, 0x0000, 0x0d7f, 0x007f, 0x127f, 0x007c,
+	0x60a4, 0xa00d, 0x00c0, 0x4817, 0xa085, 0x0001, 0x007c, 0x0e7e,
+	0x2170, 0x7000, 0xa005, 0x00c0, 0x482c, 0x20a9, 0x0010, 0xae88,
+	0x0004, 0x2104, 0xa606, 0x0040, 0x482c, 0x8108, 0x00f0, 0x4821,
+	0xa085, 0x0001, 0x0078, 0x482d, 0xa006, 0x0e7f, 0x007c, 0x0d7e,
+	0x127e, 0x2091, 0x8000, 0x60a4, 0xa06d, 0x00c0, 0x483d, 0x1078,
+	0x138b, 0x0040, 0x484f, 0x2d00, 0x60a6, 0x6803, 0x0001, 0x6807,
+	0x0000, 0xad88, 0x0004, 0x20a9, 0x0010, 0x200b, 0xffff, 0x8108,
+	0x00f0, 0x4845, 0xa085, 0x0001, 0x127f, 0x0d7f, 0x007c, 0xa006,
+	0x0078, 0x484c, 0x0d7e, 0x127e, 0x2091, 0x8000, 0x60a4, 0xa06d,
+	0x0040, 0x4860, 0x60a7, 0x0000, 0x1078, 0x13a4, 0xa085, 0x0001,
+	0x127f, 0x0d7f, 0x007c, 0x60a8, 0xa00d, 0x00c0, 0x486a, 0xa085,
+	0x0001, 0x007c, 0x0e7e, 0x2170, 0x7050, 0xa005, 0x00c0, 0x487d,
+	0x20a9, 0x0010, 0xae88, 0x0018, 0x2104, 0xa606, 0x0040, 0x487d,
+	0x8108, 0x00f0, 0x4874, 0xa085, 0x0001, 0x0e7f, 0x007c, 0x127e,
+	0x2091, 0x8000, 0x1078, 0x4863, 0x00c0, 0x4899, 0x200b, 0xffff,
+	0x0d7e, 0x60a8, 0x2068, 0x6854, 0xa08a, 0x0002, 0x0048, 0x4894,
+	0x8001, 0x6856, 0x0078, 0x4898, 0x1078, 0x13a4, 0x60ab, 0x0000,
+	0x0d7f, 0x127f, 0x007c, 0x609c, 0xd0a4, 0x007c, 0x0f7e, 0x71b0,
+	0x81ff, 0x00c0, 0x48b9, 0x71cc, 0xd19c, 0x0040, 0x48b9, 0x2001,
+	0x007e, 0xa080, 0xa735, 0x2004, 0xa07d, 0x0040, 0x48b9, 0x7804,
+	0xa084, 0x00ff, 0xa086, 0x0006, 0x00c0, 0x48b9, 0x7800, 0xc0ed,
+	0x7802, 0x2079, 0xa652, 0x7804, 0xd0a4, 0x0040, 0x48df, 0x157e,
+	0x0c7e, 0x20a9, 0x007f, 0x2009, 0x0000, 0x017e, 0x1078, 0x45c4,
+	0x00c0, 0x48d9, 0x6004, 0xa084, 0xff00, 0x8007, 0xa096, 0x0004,
+	0x0040, 0x48d6, 0xa086, 0x0006, 0x00c0, 0x48d9, 0x6000, 0xc0ed,
+	0x6002, 0x017f, 0x8108, 0x00f0, 0x48c5, 0x0c7f, 0x157f, 0x1078,
+	0x4967, 0x0040, 0x48e8, 0x2001, 0xa8a1, 0x200c, 0x0078, 0x48f0,
+	0x2079, 0xa652, 0x7804, 0xd0a4, 0x0040, 0x48f4, 0x2009, 0x07d0,
+	0x2011, 0x48f6, 0x1078, 0x5add, 0x0f7f, 0x007c, 0x2011, 0x48f6,
+	0x1078, 0x5a45, 0x1078, 0x4967, 0x0040, 0x491e, 0x2001, 0xa7b3,
+	0x2004, 0xa080, 0x0000, 0x200c, 0xc1ec, 0x2102, 0x2001, 0xa653,
+	0x2004, 0xd0a4, 0x0040, 0x4912, 0x2009, 0x07d0, 0x2011, 0x48f6,
+	0x1078, 0x5add, 0x0e7e, 0x2071, 0xa600, 0x706f, 0x0000, 0x7073,
+	0x0000, 0x1078, 0x2677, 0x0e7f, 0x0078, 0x4956, 0x157e, 0x0c7e,
+	0x20a9, 0x007f, 0x2009, 0x0000, 0x017e, 0x1078, 0x45c4, 0x00c0,
+	0x4950, 0x6000, 0xd0ec, 0x0040, 0x4950, 0x047e, 0x62a0, 0xa294,
+	0x00ff, 0x8227, 0xa006, 0x2009, 0x0029, 0x1078, 0xa21d, 0x6000,
+	0xc0e5, 0xc0ec, 0x6002, 0x6004, 0xa084, 0x00ff, 0xa085, 0x0700,
+	0x6006, 0x2019, 0x0029, 0x1078, 0x5f01, 0x077e, 0x2039, 0x0000,
+	0x1078, 0x5e0a, 0x2009, 0x0000, 0x1078, 0x9f8b, 0x077f, 0x047f,
+	0x017f, 0x8108, 0x00f0, 0x4924, 0x0c7f, 0x157f, 0x007c, 0x0c7e,
+	0x6018, 0x2060, 0x6000, 0xc0ec, 0x6002, 0x0c7f, 0x007c, 0x7818,
+	0x2004, 0xd0ac, 0x007c, 0x7818, 0x2004, 0xd0bc, 0x007c, 0x0f7e,
+	0x2001, 0xa7b3, 0x2004, 0xa07d, 0x0040, 0x4970, 0x7800, 0xd0ec,
+	0x0f7f, 0x007c, 0x127e, 0x027e, 0x2091, 0x8000, 0x007e, 0x62a0,
+	0xa290, 0xa735, 0x2204, 0xac06, 0x10c0, 0x1332, 0x007f, 0x6200,
+	0xa005, 0x0040, 0x4986, 0xc2fd, 0x0078, 0x4987, 0xc2fc, 0x6202,
+	0x027f, 0x127f, 0x007c, 0x2011, 0xa633, 0x2204, 0xd0cc, 0x0040,
+	0x4998, 0x2001, 0xa89f, 0x200c, 0x2011, 0x4999, 0x1078, 0x5add,
+	0x007c, 0x2011, 0x4999, 0x1078, 0x5a45, 0x2011, 0xa633, 0x2204,
+	0xc0cc, 0x2012, 0x007c, 0x2071, 0xa714, 0x7003, 0x0001, 0x7007,
+	0x0000, 0x7013, 0x0000, 0x7017, 0x0000, 0x701b, 0x0000, 0x701f,
+	0x0000, 0x700b, 0x0000, 0x704b, 0x0001, 0x704f, 0x0000, 0x705b,
+	0x0020, 0x705f, 0x0040, 0x707f, 0x0000, 0x2071, 0xa87d, 0x7003,
+	0xa714, 0x7007, 0x0000, 0x700b, 0x0000, 0x700f, 0xa85d, 0x7013,
+	0x0020, 0x7017, 0x0040, 0x7037, 0x0000, 0x007c, 0x017e, 0x0e7e,
+	0x2071, 0xa835, 0xa00e, 0x7186, 0x718a, 0x7097, 0x0001, 0x2001,
+	0xa653, 0x2004, 0xd0fc, 0x00c0, 0x49e8, 0x2001, 0xa653, 0x2004,
+	0xa00e, 0xd09c, 0x0040, 0x49e5, 0x8108, 0x7102, 0x0078, 0x4a3b,
+	0x2001, 0xa672, 0x200c, 0xa184, 0x000f, 0x2009, 0xa673, 0x210c,
+	0x0079, 0x49f2, 0x49dd, 0x4a13, 0x4a1b, 0x4a26, 0x4a2c, 0x49dd,
+	0x49dd, 0x49dd, 0x4a02, 0x49dd, 0x49dd, 0x49dd, 0x49dd, 0x49dd,
+	0x49dd, 0x49dd, 0x7003, 0x0004, 0x137e, 0x147e, 0x157e, 0x2099,
+	0xa676, 0x20a1, 0xa886, 0x20a9, 0x0004, 0x53a3, 0x157f, 0x147f,
+	0x137f, 0x0078, 0x4a3b, 0x708f, 0x0005, 0x7007, 0x0122, 0x2001,
+	0x0002, 0x0078, 0x4a21, 0x708f, 0x0002, 0x7007, 0x0121, 0x2001,
+	0x0003, 0x7002, 0x7097, 0x0001, 0x0078, 0x4a38, 0x7007, 0x0122,
+	0x2001, 0x0002, 0x0078, 0x4a30, 0x7007, 0x0121, 0x2001, 0x0003,
+	0x7002, 0xa006, 0x7096, 0x708e, 0xa184, 0xff00, 0x8007, 0x709a,
+	0xa184, 0x00ff, 0x7092, 0x0e7f, 0x017f, 0x007c, 0x0e7e, 0x2071,
+	0xa714, 0x684c, 0xa005, 0x00c0, 0x4a4c, 0x7028, 0xc085, 0x702a,
+	0xa085, 0x0001, 0x0078, 0x4a71, 0x6a60, 0x7236, 0x6b64, 0x733a,
+	0x6868, 0x703e, 0x7076, 0x686c, 0x7042, 0x707a, 0x684c, 0x702e,
+	0x6844, 0x7032, 0x2009, 0x000d, 0x200a, 0x700b, 0x0000, 0x8007,
+	0x8006, 0x8006, 0xa08c, 0x003f, 0xa084, 0xffc0, 0xa210, 0x2100,
+	0xa319, 0x726e, 0x7372, 0x7028, 0xc084, 0x702a, 0x7007, 0x0001,
+	0xa006, 0x0e7f, 0x007c, 0x0e7e, 0x027e, 0x6838, 0xd0fc, 0x00c0,
+	0x4ac9, 0x6804, 0xa00d, 0x0040, 0x4a8f, 0x0d7e, 0x2071, 0xa600,
+	0xa016, 0x702c, 0x2168, 0x6904, 0x206a, 0x8210, 0x2d00, 0x81ff,
+	0x00c0, 0x4a82, 0x702e, 0x70ac, 0xa200, 0x70ae, 0x0d7f, 0x2071,
+	0xa714, 0x701c, 0xa005, 0x00c0, 0x4adb, 0x0068, 0x4ad9, 0x2071,
+	0xa835, 0x7200, 0x82ff, 0x0040, 0x4ad9, 0x6934, 0xa186, 0x0103,
+	0x00c0, 0x4aec, 0x6948, 0x6844, 0xa105, 0x00c0, 0x4acc, 0x2009,
+	0x8020, 0x2200, 0x0079, 0x4aac, 0x4ad9, 0x4ab1, 0x4b09, 0x4b17,
+	0x4ad9, 0x2071, 0x0000, 0x7018, 0xd084, 0x00c0, 0x4ad9, 0x7122,
+	0x683c, 0x7026, 0x6840, 0x702a, 0x701b, 0x0001, 0x2091, 0x4080,
+	0x2071, 0xa600, 0x702c, 0x206a, 0x2d00, 0x702e, 0x70ac, 0x8000,
+	0x70ae, 0x027f, 0x0e7f, 0x007c, 0x6844, 0xa086, 0x0100, 0x00c0,
+	0x4ad9, 0x6868, 0xa005, 0x00c0, 0x4ad9, 0x2009, 0x8020, 0x0078,
+	0x4aa9, 0x2071, 0xa714, 0x2d08, 0x206b, 0x0000, 0x7010, 0x8000,
+	0x7012, 0x7018, 0xa06d, 0x711a, 0x0040, 0x4ae9, 0x6902, 0x0078,
+	0x4aea, 0x711e, 0x0078, 0x4ac9, 0xa18c, 0x00ff, 0xa186, 0x0017,
+	0x0040, 0x4afa, 0xa186, 0x001e, 0x0040, 0x4afa, 0xa18e, 0x001f,
+	0x00c0, 0x4ad9, 0x684c, 0xd0cc, 0x0040, 0x4ad9, 0x6850, 0xa084,
+	0x00ff, 0xa086, 0x0001, 0x00c0, 0x4ad9, 0x2009, 0x8021, 0x0078,
+	0x4aa9, 0x7084, 0x8008, 0xa092, 0x001e, 0x00c8, 0x4ad9, 0x7186,
+	0xae90, 0x0003, 0xa210, 0x683c, 0x2012, 0x0078, 0x4b27, 0x7084,
+	0x8008, 0xa092, 0x000f, 0x00c8, 0x4ad9, 0x7186, 0xae90, 0x0003,
+	0x8003, 0xa210, 0x683c, 0x2012, 0x8210, 0x6840, 0x2012, 0x7088,
+	0xa10a, 0x0048, 0x4ac0, 0x718c, 0x7084, 0xa10a, 0x0048, 0x4ac0,
+	0x2071, 0x0000, 0x7018, 0xd084, 0x00c0, 0x4ac0, 0x2071, 0xa835,
+	0x7000, 0xa086, 0x0002, 0x00c0, 0x4b47, 0x1078, 0x4dc3, 0x2071,
+	0x0000, 0x701b, 0x0001, 0x2091, 0x4080, 0x0078, 0x4ac0, 0x1078,
+	0x4dee, 0x2071, 0x0000, 0x701b, 0x0001, 0x2091, 0x4080, 0x0078,
+	0x4ac0, 0x007e, 0x684c, 0x007e, 0x6837, 0x0103, 0x20a9, 0x001c,
+	0xad80, 0x0011, 0x20a0, 0x2001, 0x0000, 0x40a4, 0x007f, 0xa084,
+	0x00ff, 0x684e, 0x007f, 0x684a, 0x6952, 0x007c, 0x2071, 0xa714,
+	0x7004, 0x0079, 0x4b6b, 0x4b75, 0x4b86, 0x4d94, 0x4d95, 0x4dbc,
+	0x4dc2, 0x4b76, 0x4d82, 0x4d23, 0x4da5, 0x007c, 0x127e, 0x2091,
+	0x8000, 0x0068, 0x4b85, 0x2009, 0x000d, 0x7030, 0x200a, 0x2091,
+	0x4080, 0x7007, 0x0001, 0x700b, 0x0000, 0x127f, 0x2069, 0xa8c4,
+	0x6844, 0xa005, 0x0050, 0x4bae, 0x00c0, 0x4bae, 0x127e, 0x2091,
+	0x8000, 0x2069, 0x0000, 0x6934, 0x2001, 0xa720, 0x2004, 0xa10a,
+	0x0040, 0x4ba9, 0x0068, 0x4bad, 0x2069, 0x0000, 0x6818, 0xd084,
+	0x00c0, 0x4bad, 0x2009, 0x8040, 0x6922, 0x681b, 0x0001, 0x2091,
+	0x4080, 0x2069, 0xa8c4, 0x6847, 0xffff, 0x127f, 0x2069, 0xa600,
+	0x6848, 0x6964, 0xa102, 0x2069, 0xa835, 0x688a, 0x6984, 0x701c,
+	0xa06d, 0x0040, 0x4bc0, 0x81ff, 0x0040, 0x4c08, 0x0078, 0x4bd6,
+	0x81ff, 0x0040, 0x4cda, 0x2071, 0xa835, 0x7184, 0x7088, 0xa10a,
+	0x00c8, 0x4bd6, 0x7190, 0x2071, 0xa8c4, 0x7040, 0xa005, 0x0040,
+	0x4bd6, 0x00d0, 0x4cda, 0x7142, 0x0078, 0x4cda, 0x2071, 0xa835,
+	0x718c, 0x127e, 0x2091, 0x8000, 0x7084, 0xa10a, 0x0048, 0x4cf7,
+	0x0068, 0x4c8c, 0x2071, 0x0000, 0x7018, 0xd084, 0x00c0, 0x4c8c,
+	0x2001, 0xffff, 0x2071, 0xa8c4, 0x7042, 0x2071, 0xa835, 0x7000,
+	0xa086, 0x0002, 0x00c0, 0x4bfe, 0x1078, 0x4dc3, 0x2071, 0x0000,
+	0x701b, 0x0001, 0x2091, 0x4080, 0x0078, 0x4c8c, 0x1078, 0x4dee,
+	0x2071, 0x0000, 0x701b, 0x0001, 0x2091, 0x4080, 0x0078, 0x4c8c,
+	0x2071, 0xa835, 0x7000, 0xa005, 0x0040, 0x4cb9, 0x6934, 0xa186,
+	0x0103, 0x00c0, 0x4c8f, 0x684c, 0xd0bc, 0x00c0, 0x4cb9, 0x6948,
+	0x6844, 0xa105, 0x00c0, 0x4cac, 0x2009, 0x8020, 0x2071, 0xa835,
+	0x7000, 0x0079, 0x4c23, 0x4cb9, 0x4c71, 0x4c49, 0x4c5b, 0x4c28,
+	0x137e, 0x147e, 0x157e, 0x2099, 0xa676, 0x20a1, 0xa886, 0x20a9,
+	0x0004, 0x53a3, 0x157f, 0x147f, 0x137f, 0x2071, 0xa87d, 0xad80,
+	0x000f, 0x700e, 0x7013, 0x0002, 0x7007, 0x0002, 0x700b, 0x0000,
+	0x2e10, 0x1078, 0x13db, 0x2071, 0xa714, 0x7007, 0x0009, 0x0078,
+	0x4cda, 0x7084, 0x8008, 0xa092, 0x001e, 0x00c8, 0x4cda, 0xae90,
+	0x0003, 0xa210, 0x683c, 0x2012, 0x7186, 0x2071, 0xa714, 0x1078,
+	0x4e4c, 0x0078, 0x4cda, 0x7084, 0x8008, 0xa092, 0x000f, 0x00c8,
+	0x4cda, 0xae90, 0x0003, 0x8003, 0xa210, 0x683c, 0x2012, 0x8210,
+	0x6840, 0x2012, 0x7186, 0x2071, 0xa714, 0x1078, 0x4e4c, 0x0078,
+	0x4cda, 0x127e, 0x2091, 0x8000, 0x0068, 0x4c8c, 0x2071, 0x0000,
+	0x7018, 0xd084, 0x00c0, 0x4c8c, 0x7122, 0x683c, 0x7026, 0x6840,
+	0x702a, 0x701b, 0x0001, 0x2091, 0x4080, 0x127f, 0x2071, 0xa714,
+	0x1078, 0x4e4c, 0x0078, 0x4cda, 0x127f, 0x0078, 0x4cda, 0xa18c,
+	0x00ff, 0xa186, 0x0017, 0x0040, 0x4c9d, 0xa186, 0x001e, 0x0040,
+	0x4c9d, 0xa18e, 0x001f, 0x00c0, 0x4cb9, 0x684c, 0xd0cc, 0x0040,
+	0x4cb9, 0x6850, 0xa084, 0x00ff, 0xa086, 0x0001, 0x00c0, 0x4cb9,
+	0x2009, 0x8021, 0x0078, 0x4c1e, 0x6844, 0xa086, 0x0100, 0x00c0,
+	0x4cb9, 0x6868, 0xa005, 0x00c0, 0x4cb9, 0x2009, 0x8020, 0x0078,
+	0x4c1e, 0x2071, 0xa714, 0x1078, 0x4e60, 0x0040, 0x4cda, 0x2071,
+	0xa714, 0x700f, 0x0001, 0x6934, 0xa184, 0x00ff, 0xa086, 0x0003,
+	0x00c0, 0x4cd1, 0x810f, 0xa18c, 0x00ff, 0x8101, 0x0040, 0x4cd1,
+	0x710e, 0x7007, 0x0003, 0x1078, 0x4e80, 0x7050, 0xa086, 0x0100,
+	0x0040, 0x4d95, 0x127e, 0x2091, 0x8000, 0x2071, 0xa714, 0x7008,
+	0xa086, 0x0001, 0x00c0, 0x4cf5, 0x0068, 0x4cf5, 0x2009, 0x000d,
+	0x7030, 0x200a, 0x2091, 0x4080, 0x700b, 0x0000, 0x7004, 0xa086,
+	0x0006, 0x00c0, 0x4cf5, 0x7007, 0x0001, 0x127f, 0x007c, 0x2071,
+	0xa714, 0x1078, 0x4e60, 0x0040, 0x4d20, 0x2071, 0xa835, 0x7084,
+	0x700a, 0x20a9, 0x0020, 0x2099, 0xa836, 0x20a1, 0xa85d, 0x53a3,
+	0x7087, 0x0000, 0x2071, 0xa714, 0x2069, 0xa87d, 0x706c, 0x6826,
+	0x7070, 0x682a, 0x7074, 0x682e, 0x7078, 0x6832, 0x2d10, 0x1078,
+	0x13db, 0x7007, 0x0008, 0x2001, 0xffff, 0x2071, 0xa8c4, 0x7042,
+	0x127f, 0x0078, 0x4cda, 0x2069, 0xa87d, 0x6808, 0xa08e, 0x0000,
+	0x0040, 0x4d81, 0xa08e, 0x0200, 0x0040, 0x4d7f, 0xa08e, 0x0100,
+	0x00c0, 0x4d81, 0x127e, 0x2091, 0x8000, 0x0068, 0x4d7c, 0x2069,
+	0x0000, 0x6818, 0xd084, 0x00c0, 0x4d7c, 0x702c, 0x7130, 0x8108,
+	0xa102, 0x0048, 0x4d4a, 0xa00e, 0x7034, 0x706e, 0x7038, 0x7072,
+	0x0078, 0x4d54, 0x706c, 0xa080, 0x0040, 0x706e, 0x00c8, 0x4d54,
+	0x7070, 0xa081, 0x0000, 0x7072, 0x7132, 0x6936, 0x700b, 0x0000,
+	0x2001, 0xa85a, 0x2004, 0xa005, 0x00c0, 0x4d73, 0x6934, 0x2069,
+	0xa835, 0x689c, 0x699e, 0x2069, 0xa8c4, 0xa102, 0x00c0, 0x4d6c,
+	0x6844, 0xa005, 0x00d0, 0x4d7a, 0x2001, 0xa85b, 0x200c, 0x810d,
+	0x6946, 0x0078, 0x4d7a, 0x2009, 0x8040, 0x6922, 0x681b, 0x0001,
+	0x2091, 0x4080, 0x7007, 0x0001, 0x127f, 0x0078, 0x4d81, 0x7007,
+	0x0005, 0x007c, 0x701c, 0xa06d, 0x0040, 0x4d93, 0x1078, 0x4e60,
+	0x0040, 0x4d93, 0x7007, 0x0003, 0x1078, 0x4e80, 0x7050, 0xa086,
+	0x0100, 0x0040, 0x4d95, 0x007c, 0x007c, 0x7050, 0xa09e, 0x0100,
+	0x00c0, 0x4d9e, 0x7007, 0x0004, 0x0078, 0x4dbc, 0xa086, 0x0200,
+	0x00c0, 0x4da4, 0x7007, 0x0005, 0x007c, 0x2001, 0xa87f, 0x2004,
+	0xa08e, 0x0100, 0x00c0, 0x4db1, 0x7007, 0x0001, 0x1078, 0x4e4c,
+	0x007c, 0xa08e, 0x0000, 0x0040, 0x4db0, 0xa08e, 0x0200, 0x00c0,
+	0x4db0, 0x7007, 0x0005, 0x007c, 0x1078, 0x4e16, 0x7006, 0x1078,
+	0x4e4c, 0x007c, 0x007c, 0x0e7e, 0x157e, 0x2071, 0xa835, 0x7184,
+	0x81ff, 0x0040, 0x4deb, 0xa006, 0x7086, 0xae80, 0x0003, 0x2071,
+	0x0000, 0x21a8, 0x2014, 0x7226, 0x8000, 0x0070, 0x4de8, 0x2014,
+	0x722a, 0x8000, 0x0070, 0x4de8, 0x2014, 0x722e, 0x8000, 0x0070,
+	0x4de8, 0x2014, 0x723a, 0x8000, 0x0070, 0x4de8, 0x2014, 0x723e,
+	0xa180, 0x8030, 0x7022, 0x157f, 0x0e7f, 0x007c, 0x0e7e, 0x157e,
+	0x2071, 0xa835, 0x7184, 0x81ff, 0x0040, 0x4e13, 0xa006, 0x7086,
+	0xae80, 0x0003, 0x2071, 0x0000, 0x21a8, 0x2014, 0x7226, 0x8000,
+	0x2014, 0x722a, 0x8000, 0x0070, 0x4e0c, 0x2014, 0x723a, 0x8000,
+	0x2014, 0x723e, 0x0078, 0x4e10, 0x2001, 0x8020, 0x0078, 0x4e12,
+	0x2001, 0x8042, 0x7022, 0x157f, 0x0e7f, 0x007c, 0x702c, 0x7130,
+	0x8108, 0xa102, 0x0048, 0x4e23, 0xa00e, 0x7034, 0x706e, 0x7038,
+	0x7072, 0x0078, 0x4e2d, 0x706c, 0xa080, 0x0040, 0x706e, 0x00c8,
+	0x4e2d, 0x7070, 0xa081, 0x0000, 0x7072, 0x7132, 0x700c, 0x8001,
+	0x700e, 0x00c0, 0x4e43, 0x127e, 0x2091, 0x8000, 0x0068, 0x4e46,
+	0x2001, 0x000d, 0x2102, 0x2091, 0x4080, 0x2001, 0x0001, 0x700b,
+	0x0000, 0x127f, 0x007c, 0x2001, 0x0007, 0x007c, 0x2001, 0x0006,
+	0x700b, 0x0001, 0x127f, 0x007c, 0x701c, 0xa06d, 0x0040, 0x4e5f,
+	0x127e, 0x2091, 0x8000, 0x7010, 0x8001, 0x7012, 0x2d04, 0x701e,
+	0xa005, 0x00c0, 0x4e5c, 0x701a, 0x127f, 0x1078, 0x13a4, 0x007c,
+	0x2019, 0x000d, 0x2304, 0x230c, 0xa10e, 0x0040, 0x4e6f, 0x2304,
+	0x230c, 0xa10e, 0x0040, 0x4e6f, 0xa006, 0x0078, 0x4e7f, 0x732c,
+	0x8319, 0x7130, 0xa102, 0x00c0, 0x4e79, 0x2300, 0xa005, 0x0078,
+	0x4e7f, 0x0048, 0x4e7e, 0xa302, 0x0078, 0x4e7f, 0x8002, 0x007c,
+	0x2d00, 0x7026, 0xa080, 0x000d, 0x7056, 0x7053, 0x0000, 0x127e,
+	0x2091, 0x8000, 0x2009, 0xa8d6, 0x2104, 0xc08d, 0x200a, 0x127f,
+	0x1078, 0x13f9, 0x007c, 0x2071, 0xa6e2, 0x7003, 0x0000, 0x7007,
+	0x0000, 0x700f, 0x0000, 0x702b, 0x0001, 0x704f, 0x0000, 0x7053,
+	0x0001, 0x705f, 0x0020, 0x7063, 0x0040, 0x7083, 0x0000, 0x708b,
+	0x0000, 0x708f, 0x0001, 0x70bf, 0x0000, 0x007c, 0x0e7e, 0x2071,
+	0xa6e2, 0x6848, 0xa005, 0x00c0, 0x4ebc, 0x7028, 0xc085, 0x702a,
+	0xa085, 0x0001, 0x0078, 0x4ee1, 0x6a50, 0x7236, 0x6b54, 0x733a,
+	0x6858, 0x703e, 0x707a, 0x685c, 0x7042, 0x707e, 0x6848, 0x702e,
+	0x6840, 0x7032, 0x2009, 0x000c, 0x200a, 0x8007, 0x8006, 0x8006,
+	0xa08c, 0x003f, 0xa084, 0xffc0, 0xa210, 0x2100, 0xa319, 0x7272,
+	0x7376, 0x7028, 0xc084, 0x702a, 0x7007, 0x0001, 0x700f, 0x0000,
+	0xa006, 0x0e7f, 0x007c, 0x2b78, 0x2071, 0xa6e2, 0x7004, 0x1079,
+	0x4f41, 0x700c, 0x0079, 0x4eec, 0x4ef1, 0x4ee6, 0x4ee6, 0x4ee6,
+	0x4ee6, 0x007c, 0x700c, 0x0079, 0x4ef5, 0x4efa, 0x4f3f, 0x4f3f,
+	0x4f40, 0x4f40, 0x7830, 0x7930, 0xa106, 0x0040, 0x4f04, 0x7830,
+	0x7930, 0xa106, 0x00c0, 0x4f2a, 0x7030, 0xa10a, 0x0040, 0x4f2a,
+	0x00c8, 0x4f0c, 0x712c, 0xa10a, 0xa18a, 0x0002, 0x00c8, 0x4f2b,
+	0x1078, 0x1370, 0x0040, 0x4f2a, 0x2d00, 0x705a, 0x7063, 0x0040,
+	0x2001, 0x0003, 0x7057, 0x0000, 0x127e, 0x007e, 0x2091, 0x8000,
+	0x2009, 0xa8d6, 0x2104, 0xc085, 0x200a, 0x007f, 0x700e, 0x127f,
+	0x1078, 0x13f9, 0x007c, 0x1078, 0x1370, 0x0040, 0x4f2a, 0x2d00,
+	0x705a, 0x1078, 0x1370, 0x00c0, 0x4f37, 0x0078, 0x4f16, 0x2d00,
+	0x7086, 0x7063, 0x0080, 0x2001, 0x0004, 0x0078, 0x4f1a, 0x007c,
+	0x007c, 0x4f52, 0x4f53, 0x4f8a, 0x4f8b, 0x4f3f, 0x4fc1, 0x4fc6,
+	0x4ffd, 0x4ffe, 0x5019, 0x501a, 0x501b, 0x501c, 0x501d, 0x501e,
+	0x509e, 0x50c8, 0x007c, 0x700c, 0x0079, 0x4f56, 0x4f5b, 0x4f5e,
+	0x4f6e, 0x4f89, 0x4f89, 0x1078, 0x4ef2, 0x007c, 0x127e, 0x8001,
+	0x700e, 0x7058, 0x007e, 0x1078, 0x5464, 0x0040, 0x4f6b, 0x2091,
+	0x8000, 0x1078, 0x4ef2, 0x0d7f, 0x0078, 0x4f77, 0x127e, 0x8001,
+	0x700e, 0x1078, 0x5464, 0x7058, 0x2068, 0x7084, 0x705a, 0x6803,
+	0x0000, 0x6807, 0x0000, 0x6834, 0xa084, 0x00ff, 0xa08a, 0x0020,
+	0x00c8, 0x4f86, 0x1079, 0x4fa1, 0x127f, 0x007c, 0x127f, 0x1078,
+	0x501f, 0x007c, 0x007c, 0x007c, 0x0e7e, 0x2071, 0xa6e2, 0x700c,
+	0x0079, 0x4f92, 0x4f97, 0x4f97, 0x4f97, 0x4f99, 0x4f9d, 0x0e7f,
+	0x007c, 0x700f, 0x0001, 0x0078, 0x4f9f, 0x700f, 0x0002, 0x0e7f,
+	0x007c, 0x501f, 0x501f, 0x503b, 0x501f, 0x5171, 0x501f, 0x501f,
+	0x501f, 0x501f, 0x501f, 0x503b, 0x51bb, 0x5208, 0x5261, 0x5277,
+	0x501f, 0x501f, 0x5057, 0x503b, 0x501f, 0x501f, 0x5078, 0x5338,
+	0x5356, 0x501f, 0x5057, 0x501f, 0x501f, 0x501f, 0x501f, 0x506d,
+	0x5356, 0x7020, 0x2068, 0x1078, 0x13a4, 0x007c, 0x700c, 0x0079,
+	0x4fc9, 0x4fce, 0x4fd1, 0x4fe1, 0x4ffc, 0x4ffc, 0x1078, 0x4ef2,
+	0x007c, 0x127e, 0x8001, 0x700e, 0x7058, 0x007e, 0x1078, 0x5464,
+	0x0040, 0x4fde, 0x2091, 0x8000, 0x1078, 0x4ef2, 0x0d7f, 0x0078,
+	0x4fea, 0x127e, 0x8001, 0x700e, 0x1078, 0x5464, 0x7058, 0x2068,
+	0x7084, 0x705a, 0x6803, 0x0000, 0x6807, 0x0000, 0x6834, 0xa084,
+	0x00ff, 0xa08a, 0x001a, 0x00c8, 0x4ff9, 0x1079, 0x4fff, 0x127f,
+	0x007c, 0x127f, 0x1078, 0x501f, 0x007c, 0x007c, 0x007c, 0x501f,
+	0x503b, 0x515b, 0x501f, 0x503b, 0x501f, 0x503b, 0x503b, 0x501f,
+	0x503b, 0x515b, 0x503b, 0x503b, 0x503b, 0x503b, 0x503b, 0x501f,
+	0x503b, 0x515b, 0x501f, 0x501f, 0x503b, 0x501f, 0x501f, 0x501f,
+	0x503b, 0x007c, 0x007c, 0x007c, 0x007c, 0x007c, 0x007c, 0x7007,
+	0x0001, 0x6838, 0xa084, 0x00ff, 0xc0d5, 0x683a, 0x127e, 0x2091,
+	0x8000, 0x1078, 0x4a73, 0x127f, 0x007c, 0x7007, 0x0001, 0x6838,
+	0xa084, 0x00ff, 0xc0e5, 0x683a, 0x127e, 0x2091, 0x8000, 0x1078,
+	0x4a73, 0x127f, 0x007c, 0x7007, 0x0001, 0x6838, 0xa084, 0x00ff,
+	0xc0ed, 0x683a, 0x127e, 0x2091, 0x8000, 0x1078, 0x4a73, 0x127f,
+	0x007c, 0x7007, 0x0001, 0x6838, 0xa084, 0x00ff, 0xc0dd, 0x683a,
+	0x127e, 0x2091, 0x8000, 0x1078, 0x4a73, 0x127f, 0x007c, 0x6834,
+	0x8007, 0xa084, 0x00ff, 0x0040, 0x502d, 0x8001, 0x00c0, 0x5064,
+	0x7007, 0x0001, 0x0078, 0x513a, 0x7007, 0x0006, 0x7012, 0x2d00,
+	0x7016, 0x701a, 0x704b, 0x513a, 0x007c, 0x684c, 0xa084, 0x00c0,
+	0xa086, 0x00c0, 0x00c0, 0x5078, 0x7007, 0x0001, 0x0078, 0x5373,
+	0x2d00, 0x7016, 0x701a, 0x20a9, 0x0004, 0xa080, 0x0024, 0x2098,
+	0x20a1, 0xa70d, 0x53a3, 0x6858, 0x7012, 0xa082, 0x0401, 0x00c8,
+	0x5049, 0x6884, 0xa08a, 0x0002, 0x00c8, 0x5049, 0x82ff, 0x00c0,
+	0x509a, 0x6888, 0x698c, 0xa105, 0x0040, 0x509a, 0x2001, 0x510a,
+	0x0078, 0x509d, 0xa280, 0x5100, 0x2004, 0x70c6, 0x7010, 0xa015,
+	0x0040, 0x50e8, 0x1078, 0x1370, 0x00c0, 0x50a9, 0x7007, 0x000f,
+	0x007c, 0x2d00, 0x7022, 0x70c4, 0x2060, 0x6000, 0x6836, 0x6004,
+	0xad00, 0x7096, 0x6008, 0xa20a, 0x00c8, 0x50b8, 0xa00e, 0x2200,
+	0x7112, 0x620c, 0x8003, 0x800b, 0xa296, 0x0004, 0x0040, 0x50c1,
+	0xa108, 0x719a, 0x810b, 0x719e, 0xae90, 0x0022, 0x1078, 0x13db,
+	0x7090, 0xa08e, 0x0100, 0x0040, 0x50dc, 0xa086, 0x0200, 0x0040,
+	0x50d4, 0x7007, 0x0010, 0x007c, 0x7020, 0x2068, 0x1078, 0x13a4,
+	0x7014, 0x2068, 0x0078, 0x5049, 0x7020, 0x2068, 0x7018, 0x6802,
+	0x6807, 0x0000, 0x2d08, 0x2068, 0x6906, 0x711a, 0x0078, 0x509e,
+	0x7014, 0x2068, 0x7007, 0x0001, 0x6884, 0xa005, 0x00c0, 0x50f7,
+	0x6888, 0x698c, 0xa105, 0x0040, 0x50f7, 0x1078, 0x510e, 0x6834,
+	0xa084, 0x00ff, 0xa086, 0x001e, 0x0040, 0x5373, 0x0078, 0x513a,
+	0x5102, 0x5106, 0x0002, 0x0011, 0x0007, 0x0004, 0x000a, 0x000f,
+	0x0005, 0x0006, 0x000a, 0x0011, 0x0005, 0x0004, 0x0f7e, 0x0e7e,
+	0x0c7e, 0x077e, 0x067e, 0x6f88, 0x6e8c, 0x6804, 0x2060, 0xacf0,
+	0x0021, 0xacf8, 0x0027, 0x2009, 0x0005, 0x700c, 0x7816, 0x7008,
+	0x7812, 0x7004, 0x7806, 0x7000, 0x7802, 0x7e0e, 0x7f0a, 0x8109,
+	0x0040, 0x5130, 0xaef2, 0x0004, 0xaffa, 0x0006, 0x0078, 0x511d,
+	0x6004, 0xa065, 0x00c0, 0x5117, 0x067f, 0x077f, 0x0c7f, 0x0e7f,
+	0x0f7f, 0x007c, 0x2009, 0xa62f, 0x210c, 0x81ff, 0x00c0, 0x5155,
+	0x6838, 0xa084, 0x00ff, 0x683a, 0x1078, 0x4353, 0x00c0, 0x5149,
+	0x007c, 0x1078, 0x4b51, 0x127e, 0x2091, 0x8000, 0x1078, 0x8f7d,
+	0x1078, 0x4a73, 0x127f, 0x0078, 0x5148, 0x2001, 0x0028, 0x2009,
+	0x0000, 0x0078, 0x5149, 0x7018, 0x6802, 0x2d08, 0x2068, 0x6906,
+	0x711a, 0x7010, 0x8001, 0x7012, 0x0040, 0x516a, 0x7007, 0x0006,
+	0x0078, 0x5170, 0x7014, 0x2068, 0x7007, 0x0001, 0x7048, 0x107a,
+	0x007c, 0x7007, 0x0001, 0x6944, 0x810f, 0xa18c, 0x00ff, 0x6848,
+	0xa084, 0x00ff, 0x20a9, 0x0001, 0xa096, 0x0001, 0x0040, 0x519a,
+	0x2009, 0x0000, 0x20a9, 0x00ff, 0xa096, 0x0002, 0x0040, 0x519a,
+	0xa005, 0x00c0, 0x51ad, 0x6944, 0x810f, 0xa18c, 0x00ff, 0x1078,
+	0x45c4, 0x00c0, 0x51ad, 0x067e, 0x6e50, 0x1078, 0x46b3, 0x067f,
+	0x0078, 0x51ad, 0x047e, 0x2011, 0xa60c, 0x2224, 0xc484, 0xc48c,
+	0x2412, 0x047f, 0x0c7e, 0x1078, 0x45c4, 0x00c0, 0x51a9, 0x1078,
+	0x4852, 0x8108, 0x00f0, 0x51a3, 0x0c7f, 0x684c, 0xd084, 0x00c0,
+	0x51b4, 0x1078, 0x13a4, 0x007c, 0x127e, 0x2091, 0x8000, 0x1078,
+	0x4a73, 0x127f, 0x007c, 0x127e, 0x2091, 0x8000, 0x7007, 0x0001,
+	0x2001, 0xa653, 0x2004, 0xd0a4, 0x0040, 0x51ff, 0x2061, 0xa933,
+	0x6100, 0xd184, 0x0040, 0x51df, 0x6858, 0xa084, 0x00ff, 0x00c0,
+	0x5202, 0x6000, 0xd084, 0x0040, 0x51ff, 0x6004, 0xa005, 0x00c0,
+	0x5205, 0x6003, 0x0000, 0x600b, 0x0000, 0x0078, 0x51fc, 0x2011,
+	0x0001, 0x6860, 0xa005, 0x00c0, 0x51e7, 0x2001, 0x001e, 0x8000,
+	0x6016, 0x6858, 0xa084, 0x00ff, 0x0040, 0x51ff, 0x6006, 0x6858,
+	0x8007, 0xa084, 0x00ff, 0x0040, 0x51ff, 0x600a, 0x6858, 0x8000,
+	0x00c0, 0x51fb, 0xc28d, 0x6202, 0x127f, 0x0078, 0x5453, 0x127f,
+	0x0078, 0x544b, 0x127f, 0x0078, 0x5443, 0x127f, 0x0078, 0x5447,
+	0x127e, 0x2091, 0x8000, 0x7007, 0x0001, 0x2001, 0xa653, 0x2004,
+	0xd0a4, 0x0040, 0x525e, 0x2061, 0xa933, 0x6000, 0xd084, 0x0040,
+	0x525e, 0x6204, 0x6308, 0xd08c, 0x00c0, 0x5250, 0x6c48, 0xa484,
+	0x0003, 0x0040, 0x5236, 0x6958, 0xa18c, 0x00ff, 0x8001, 0x00c0,
+	0x522f, 0x2100, 0xa210, 0x0048, 0x525b, 0x0078, 0x5236, 0x8001,
+	0x00c0, 0x525b, 0x2100, 0xa212, 0x0048, 0x525b, 0xa484, 0x000c,
+	0x0040, 0x5250, 0x6958, 0x810f, 0xa18c, 0x00ff, 0xa082, 0x0004,
+	0x00c0, 0x5248, 0x2100, 0xa318, 0x0048, 0x525b, 0x0078, 0x5250,
+	0xa082, 0x0004, 0x00c0, 0x525b, 0x2100, 0xa31a, 0x0048, 0x525b,
+	0x6860, 0xa005, 0x0040, 0x5256, 0x8000, 0x6016, 0x6206, 0x630a,
+	0x127f, 0x0078, 0x5453, 0x127f, 0x0078, 0x544f, 0x127f, 0x0078,
+	0x544b, 0x127e, 0x2091, 0x8000, 0x7007, 0x0001, 0x2061, 0xa933,
+	0x6300, 0xd38c, 0x00c0, 0x5271, 0x6308, 0x8318, 0x0048, 0x5274,
+	0x630a, 0x127f, 0x0078, 0x5461, 0x127f, 0x0078, 0x544f, 0x127e,
+	0x0c7e, 0x2091, 0x8000, 0x7007, 0x0001, 0x684c, 0xd0ac, 0x0040,
+	0x528b, 0x0c7e, 0x2061, 0xa933, 0x6000, 0xa084, 0xfcff, 0x6002,
+	0x0c7f, 0x0078, 0x52ba, 0x6858, 0xa005, 0x0040, 0x52d1, 0x685c,
+	0xa065, 0x0040, 0x52cd, 0x2001, 0xa62f, 0x2004, 0xa005, 0x0040,
+	0x529d, 0x1078, 0x8ec6, 0x0078, 0x52ab, 0x6013, 0x0400, 0x6037,
+	0x0000, 0x694c, 0xd1a4, 0x0040, 0x52a7, 0x6950, 0x6136, 0x2009,
+	0x0041, 0x1078, 0x775c, 0x6958, 0xa18c, 0xff00, 0xa186, 0x2000,
+	0x00c0, 0x52ba, 0x027e, 0x2009, 0x0000, 0x2011, 0xfdff, 0x1078,
+	0x5bf1, 0x027f, 0x684c, 0xd0c4, 0x0040, 0x52c9, 0x2061, 0xa933,
+	0x6000, 0xd08c, 0x00c0, 0x52c9, 0x6008, 0x8000, 0x0048, 0x52cd,
+	0x600a, 0x0c7f, 0x127f, 0x0078, 0x5453, 0x0c7f, 0x127f, 0x0078,
+	0x544b, 0x6954, 0xa186, 0x0045, 0x0040, 0x5306, 0xa186, 0x002a,
+	0x00c0, 0x52e1, 0x2001, 0xa60c, 0x200c, 0xc194, 0x2102, 0x0078,
+	0x52ba, 0xa186, 0x0020, 0x0040, 0x52fa, 0xa186, 0x0029, 0x0040,
+	0x52ed, 0xa186, 0x002d, 0x00c0, 0x52cd, 0x6944, 0xa18c, 0xff00,
+	0x810f, 0x1078, 0x45c4, 0x00c0, 0x52ba, 0x6000, 0xc0e4, 0x6002,
+	0x0078, 0x52ba, 0x685c, 0xa065, 0x0040, 0x52cd, 0x6007, 0x0024,
+	0x2001, 0xa8a3, 0x2004, 0x6016, 0x0078, 0x52ba, 0x685c, 0xa065,
+	0x0040, 0x52cd, 0x0e7e, 0x6860, 0xa075, 0x2001, 0xa62f, 0x2004,
+	0xa005, 0x0040, 0x531e, 0x1078, 0x8ec6, 0x8eff, 0x0040, 0x531b,
+	0x2e60, 0x1078, 0x8ec6, 0x0e7f, 0x0078, 0x52ba, 0x6024, 0xc0dc,
+	0xc0d5, 0x6026, 0x2e60, 0x6007, 0x003a, 0x6870, 0xa005, 0x0040,
+	0x532f, 0x6007, 0x003b, 0x6874, 0x602a, 0x6878, 0x6012, 0x6003,
+	0x0001, 0x1078, 0x5d8a, 0x1078, 0x62d1, 0x0e7f, 0x0078, 0x52ba,
+	0x2061, 0xa933, 0x6000, 0xd084, 0x0040, 0x5352, 0xd08c, 0x00c0,
+	0x5461, 0x2091, 0x8000, 0x6204, 0x8210, 0x0048, 0x534c, 0x6206,
+	0x2091, 0x8001, 0x0078, 0x5461, 0x2091, 0x8001, 0x6853, 0x0016,
+	0x0078, 0x545a, 0x6853, 0x0007, 0x0078, 0x545a, 0x6834, 0x8007,
+	0xa084, 0x00ff, 0x00c0, 0x5360, 0x1078, 0x502d, 0x0078, 0x5372,
+	0x2030, 0x8001, 0x00c0, 0x536a, 0x7007, 0x0001, 0x1078, 0x5373,
+	0x0078, 0x5372, 0x7007, 0x0006, 0x7012, 0x2d00, 0x7016, 0x701a,
+	0x704b, 0x5373, 0x007c, 0x0e7e, 0x127e, 0x2091, 0x8000, 0xa03e,
+	0x2009, 0xa62f, 0x210c, 0x81ff, 0x00c0, 0x53ff, 0x2009, 0xa60c,
+	0x210c, 0xd194, 0x00c0, 0x5431, 0x6848, 0x2070, 0xae82, 0xad00,
+	0x0048, 0x53ef, 0x2001, 0xa616, 0x2004, 0xae02, 0x00c8, 0x53ef,
+	0x2061, 0xa933, 0x6100, 0xa184, 0x0301, 0xa086, 0x0001, 0x00c0,
+	0x53d2, 0x711c, 0xa186, 0x0006, 0x00c0, 0x53da, 0x7018, 0xa005,
+	0x0040, 0x53ff, 0x2004, 0xd0e4, 0x00c0, 0x542b, 0x7024, 0xd0dc,
+	0x00c0, 0x5435, 0x6853, 0x0000, 0x6803, 0x0000, 0x2d08, 0x7010,
+	0xa005, 0x00c0, 0x53be, 0x7112, 0x684c, 0xd0f4, 0x00c0, 0x5439,
+	0x2e60, 0x1078, 0x5b27, 0x127f, 0x0e7f, 0x007c, 0x2068, 0x6800,
+	0xa005, 0x00c0, 0x53be, 0x6902, 0x2168, 0x684c, 0xd0f4, 0x00c0,
+	0x5439, 0x127f, 0x0e7f, 0x007c, 0x127f, 0x0e7f, 0x6853, 0x0006,
+	0x0078, 0x545a, 0xd184, 0x0040, 0x53cc, 0xd1c4, 0x00c0, 0x53f3,
+	0x0078, 0x53f7, 0x6944, 0xa18c, 0xff00, 0x810f, 0x1078, 0x45c4,
+	0x00c0, 0x542b, 0x6000, 0xd0e4, 0x00c0, 0x542b, 0x711c, 0xa186,
+	0x0007, 0x00c0, 0x53ef, 0x6853, 0x0002, 0x0078, 0x542d, 0x6853,
+	0x0008, 0x0078, 0x542d, 0x6853, 0x000e, 0x0078, 0x542d, 0x6853,
+	0x0017, 0x0078, 0x542d, 0x6853, 0x0035, 0x0078, 0x542d, 0x2001,
+	0xa672, 0x2004, 0xd0fc, 0x0040, 0x5427, 0x6848, 0x2070, 0xae82,
+	0xad00, 0x0048, 0x5427, 0x6058, 0xae02, 0x00c8, 0x5427, 0x711c,
+	0xa186, 0x0006, 0x00c0, 0x5427, 0x7018, 0xa005, 0x0040, 0x5427,
+	0x2004, 0xd0bc, 0x0040, 0x5427, 0x2039, 0x0001, 0x7000, 0xa086,
+	0x0007, 0x00c0, 0x537e, 0x7003, 0x0002, 0x0078, 0x537e, 0x6853,
+	0x0028, 0x0078, 0x542d, 0x6853, 0x0029, 0x127f, 0x0e7f, 0x0078,
+	0x545a, 0x6853, 0x002a, 0x0078, 0x542d, 0x6853, 0x0045, 0x0078,
+	0x542d, 0x2e60, 0x2019, 0x0002, 0x6017, 0x0014, 0x1078, 0x9dc7,
+	0x127f, 0x0e7f, 0x007c, 0x2009, 0x003e, 0x0078, 0x5455, 0x2009,
+	0x0004, 0x0078, 0x5455, 0x2009, 0x0006, 0x0078, 0x5455, 0x2009,
+	0x0016, 0x0078, 0x5455, 0x2009, 0x0001, 0x6854, 0xa084, 0xff00,
+	0xa105, 0x6856, 0x2091, 0x8000, 0x1078, 0x4a73, 0x2091, 0x8001,
+	0x007c, 0x1078, 0x13a4, 0x007c, 0x702c, 0x7130, 0x8108, 0xa102,
+	0x0048, 0x5471, 0xa00e, 0x7034, 0x7072, 0x7038, 0x7076, 0x0078,
+	0x547d, 0x7070, 0xa080, 0x0040, 0x7072, 0x00c8, 0x547d, 0x7074,
+	0xa081, 0x0000, 0x7076, 0xa085, 0x0001, 0x7932, 0x7132, 0x007c,
+	0x0d7e, 0x1078, 0x5b1e, 0x0d7f, 0x007c, 0x0d7e, 0x2011, 0x0004,
+	0x2204, 0xa085, 0x8002, 0x2012, 0x0d7f, 0x007c, 0x20e1, 0x0002,
+	0x3d08, 0x20e1, 0x2000, 0x3d00, 0xa084, 0x7000, 0x0040, 0x549c,
+	0xa086, 0x1000, 0x00c0, 0x54d3, 0x20e1, 0x0000, 0x3d00, 0xa094,
+	0xff00, 0x8217, 0xa084, 0xf000, 0xa086, 0x3000, 0x00c0, 0x54b7,
+	0xa184, 0xff00, 0x8007, 0xa086, 0x0008, 0x00c0, 0x54d3, 0x1078,
+	0x29bb, 0x00c0, 0x54d3, 0x1078, 0x56b2, 0x0078, 0x54ce, 0x20e1,
+	0x0004, 0x3d60, 0xd1bc, 0x00c0, 0x54be, 0x3e60, 0xac84, 0x000f,
+	0x00c0, 0x54d3, 0xac82, 0xad00, 0x0048, 0x54d3, 0x6858, 0xac02,
+	0x00c8, 0x54d3, 0x2009, 0x0047, 0x1078, 0x775c, 0x7a1c, 0xd284,
+	0x00c0, 0x548e, 0x007c, 0xa016, 0x1078, 0x15fa, 0x0078, 0x54ce,
+	0x0078, 0x54d3, 0x781c, 0xd08c, 0x0040, 0x5502, 0x157e, 0x137e,
+	0x147e, 0x20e1, 0x3000, 0x3d20, 0x3e28, 0xa584, 0x0076, 0x00c0,
+	0x5518, 0xa484, 0x7000, 0xa086, 0x1000, 0x00c0, 0x5507, 0x1078,
+	0x554e, 0x0040, 0x5518, 0x20e1, 0x3000, 0x7828, 0x7828, 0x1078,
+	0x556c, 0x147f, 0x137f, 0x157f, 0x2009, 0xa8b9, 0x2104, 0xa005,
+	0x00c0, 0x5503, 0x007c, 0x1078, 0x62d1, 0x0078, 0x5502, 0xa484,
+	0x7000, 0x00c0, 0x5518, 0x1078, 0x554e, 0x0040, 0x552c, 0x7000,
+	0xa084, 0xff00, 0xa086, 0x8100, 0x0040, 0x54f3, 0x0078, 0x552c,
+	0x1078, 0xa54f, 0xd5a4, 0x0040, 0x5528, 0x047e, 0x1078, 0x1b22,
+	0x047f, 0x20e1, 0x9010, 0x2001, 0x0138, 0x2202, 0x0078, 0x5530,
+	0x1078, 0x554e, 0x6883, 0x0000, 0x20e1, 0x3000, 0x7828, 0x7828,
+	0x1078, 0x5537, 0x147f, 0x137f, 0x157f, 0x0078, 0x5502, 0x2001,
+	0xa60e, 0x2004, 0xd08c, 0x0040, 0x554d, 0x2001, 0xa600, 0x2004,
+	0xa086, 0x0003, 0x00c0, 0x554d, 0x027e, 0x037e, 0x2011, 0x8048,
+	0x2518, 0x1078, 0x361b, 0x037f, 0x027f, 0x007c, 0xa484, 0x01ff,
+	0x6882, 0xa005, 0x0040, 0x5560, 0xa080, 0x001f, 0xa084, 0x03f8,
+	0x80ac, 0x20e1, 0x1000, 0x2ea0, 0x2099, 0x020a, 0x53a5, 0x007c,
+	0x20a9, 0x000c, 0x20e1, 0x1000, 0x2ea0, 0x2099, 0x020a, 0x53a5,
+	0xa085, 0x0001, 0x0078, 0x555f, 0x7000, 0xa084, 0xff00, 0xa08c,
+	0xf000, 0x8007, 0xa196, 0x0000, 0x00c0, 0x5579, 0x0078, 0x57ba,
+	0x007c, 0xa196, 0x2000, 0x00c0, 0x558a, 0x6900, 0xa18e, 0x0001,
+	0x00c0, 0x5586, 0x1078, 0x3aec, 0x0078, 0x5578, 0x1078, 0x5592,
+	0x0078, 0x5578, 0xa196, 0x8000, 0x00c0, 0x5578, 0x1078, 0x5871,
+	0x0078, 0x5578, 0x0c7e, 0x7110, 0xa18c, 0xff00, 0x810f, 0xa196,
+	0x0001, 0x0040, 0x559f, 0xa196, 0x0023, 0x00c0, 0x56aa, 0xa08e,
+	0x0023, 0x00c0, 0x55d4, 0x1078, 0x591d, 0x0040, 0x56aa, 0x7124,
+	0x610a, 0x7030, 0xa08e, 0x0200, 0x00c0, 0x55b8, 0x7034, 0xa005,
+	0x00c0, 0x56aa, 0x2009, 0x0015, 0x1078, 0x775c, 0x0078, 0x56aa,
+	0xa08e, 0x0214, 0x0040, 0x55c0, 0xa08e, 0x0210, 0x00c0, 0x55c6,
+	0x2009, 0x0015, 0x1078, 0x775c, 0x0078, 0x56aa, 0xa08e, 0x0100,
+	0x00c0, 0x56aa, 0x7034, 0xa005, 0x00c0, 0x56aa, 0x2009, 0x0016,
+	0x1078, 0x775c, 0x0078, 0x56aa, 0xa08e, 0x0022, 0x00c0, 0x56aa,
+	0x7030, 0xa08e, 0x0300, 0x00c0, 0x55e5, 0x7034, 0xa005, 0x00c0,
+	0x56aa, 0x2009, 0x0017, 0x0078, 0x5676, 0xa08e, 0x0500, 0x00c0,
+	0x55f1, 0x7034, 0xa005, 0x00c0, 0x56aa, 0x2009, 0x0018, 0x0078,
+	0x5676, 0xa08e, 0x2010, 0x00c0, 0x55f9, 0x2009, 0x0019, 0x0078,
+	0x5676, 0xa08e, 0x2110, 0x00c0, 0x5601, 0x2009, 0x001a, 0x0078,
+	0x5676, 0xa08e, 0x5200, 0x00c0, 0x560d, 0x7034, 0xa005, 0x00c0,
+	0x56aa, 0x2009, 0x001b, 0x0078, 0x5676, 0xa08e, 0x5000, 0x00c0,
+	0x5619, 0x7034, 0xa005, 0x00c0, 0x56aa, 0x2009, 0x001c, 0x0078,
+	0x5676, 0xa08e, 0x1300, 0x00c0, 0x5621, 0x2009, 0x0034, 0x0078,
+	0x5676, 0xa08e, 0x1200, 0x00c0, 0x562d, 0x7034, 0xa005, 0x00c0,
+	0x56aa, 0x2009, 0x0024, 0x0078, 0x5676, 0xa08c, 0xff00, 0xa18e,
+	0x2400, 0x00c0, 0x5637, 0x2009, 0x002d, 0x0078, 0x5676, 0xa08c,
+	0xff00, 0xa18e, 0x5300, 0x00c0, 0x5641, 0x2009, 0x002a, 0x0078,
+	0x5676, 0xa08e, 0x0f00, 0x00c0, 0x5649, 0x2009, 0x0020, 0x0078,
+	0x5676, 0xa08e, 0x5300, 0x00c0, 0x564f, 0x0078, 0x566c, 0xa08e,
+	0x6104, 0x00c0, 0x566c, 0x2011, 0xab8d, 0x8208, 0x2204, 0xa082,
+	0x0004, 0x20a8, 0x95ac, 0x95ac, 0x2011, 0x8015, 0x211c, 0x8108,
+	0x047e, 0x2124, 0x1078, 0x361b, 0x047f, 0x8108, 0x00f0, 0x565c,
+	0x2009, 0x0023, 0x0078, 0x5676, 0xa08e, 0x6000, 0x00c0, 0x5674,
+	0x2009, 0x003f, 0x0078, 0x5676, 0x2009, 0x001d, 0x017e, 0x2011,
+	0xab83, 0x2204, 0x8211, 0x220c, 0x1078, 0x254d, 0x00c0, 0x56ac,
+	0x1078, 0x455c, 0x00c0, 0x56ac, 0x6612, 0x6516, 0x86ff, 0x0040,
+	0x569c, 0x017f, 0x017e, 0xa186, 0x0017, 0x00c0, 0x569c, 0x686c,
+	0xa606, 0x00c0, 0x569c, 0x6870, 0xa506, 0xa084, 0xff00, 0x00c0,
+	0x569c, 0x6000, 0xc0f5, 0x6002, 0x0c7e, 0x1078, 0x76c7, 0x0040,
+	0x56af, 0x017f, 0x611a, 0x601f, 0x0004, 0x7120, 0x610a, 0x017f,
+	0x1078, 0x775c, 0x0c7f, 0x007c, 0x017f, 0x0078, 0x56aa, 0x0c7f,
+	0x0078, 0x56ac, 0x0c7e, 0x1078, 0x570f, 0x00c0, 0x570d, 0xa28e,
+	0x0033, 0x00c0, 0x56de, 0x1078, 0x591d, 0x0040, 0x570d, 0x7124,
+	0x610a, 0x7030, 0xa08e, 0x0200, 0x00c0, 0x56d0, 0x7034, 0xa005,
+	0x00c0, 0x570d, 0x2009, 0x0015, 0x1078, 0x775c, 0x0078, 0x570d,
+	0xa08e, 0x0100, 0x00c0, 0x570d, 0x7034, 0xa005, 0x00c0, 0x570d,
+	0x2009, 0x0016, 0x1078, 0x775c, 0x0078, 0x570d, 0xa28e, 0x0032,
+	0x00c0, 0x570d, 0x7030, 0xa08e, 0x1400, 0x00c0, 0x570d, 0x2009,
+	0x0038, 0x017e, 0x2011, 0xab83, 0x2204, 0x8211, 0x220c, 0x1078,
+	0x254d, 0x00c0, 0x570c, 0x1078, 0x455c, 0x00c0, 0x570c, 0x6612,
+	0x6516, 0x0c7e, 0x1078, 0x76c7, 0x0040, 0x570b, 0x017f, 0x611a,
+	0x601f, 0x0004, 0x7120, 0x610a, 0x017f, 0x1078, 0x775c, 0x1078,
+	0x62d1, 0x0078, 0x570d, 0x0c7f, 0x017f, 0x0c7f, 0x007c, 0x0f7e,
+	0x0d7e, 0x027e, 0x017e, 0x137e, 0x147e, 0x157e, 0x3c00, 0x007e,
+	0x2079, 0x0030, 0x2069, 0x0200, 0x1078, 0x1c6a, 0x00c0, 0x5750,
+	0x1078, 0x1b40, 0x0040, 0x575d, 0x7908, 0xa18c, 0x1fff, 0xa182,
+	0x0011, 0x00c8, 0x575a, 0x20a9, 0x000c, 0x20e1, 0x0000, 0x2ea0,
+	0x2099, 0x020a, 0x53a5, 0x20e1, 0x2000, 0x2001, 0x020a, 0x2004,
+	0x7a0c, 0x7808, 0xa080, 0x0007, 0xa084, 0x1ff8, 0xa08a, 0x0140,
+	0x10c8, 0x1332, 0x80ac, 0x20e1, 0x6000, 0x2099, 0x020a, 0x53a5,
+	0x20e1, 0x7000, 0x6828, 0x6828, 0x7803, 0x0004, 0xa294, 0x0070,
+	0x007f, 0x20e0, 0x157f, 0x147f, 0x137f, 0x017f, 0x027f, 0x0d7f,
+	0x0f7f, 0x007c, 0xa016, 0x1078, 0x15fa, 0xa085, 0x0001, 0x0078,
+	0x5750, 0x047e, 0x0e7e, 0x0d7e, 0x2028, 0x2130, 0xa696, 0x00ff,
+	0x00c0, 0x5782, 0xa596, 0xfffd, 0x00c0, 0x5772, 0x2009, 0x007f,
+	0x0078, 0x57b5, 0xa596, 0xfffe, 0x00c0, 0x577a, 0x2009, 0x007e,
+	0x0078, 0x57b5, 0xa596, 0xfffc, 0x00c0, 0x5782, 0x2009, 0x0080,
+	0x0078, 0x57b5, 0x2011, 0x0000, 0x2021, 0x0081, 0x20a9, 0x007e,
+	0x2071, 0xa7b6, 0x2e1c, 0x83ff, 0x00c0, 0x5794, 0x82ff, 0x00c0,
+	0x57a9, 0x2410, 0x0078, 0x57a9, 0x2368, 0x6f10, 0x007e, 0x2100,
+	0xa706, 0x007f, 0x6b14, 0x00c0, 0x57a3, 0xa346, 0x00c0, 0x57a3,
+	0x2408, 0x0078, 0x57b5, 0x87ff, 0x00c0, 0x57a9, 0x83ff, 0x0040,
+	0x578e, 0x8420, 0x8e70, 0x00f0, 0x578a, 0x82ff, 0x00c0, 0x57b4,
+	0xa085, 0x0001, 0x0078, 0x57b6, 0x2208, 0xa006, 0x0d7f, 0x0e7f,
+	0x047f, 0x007c, 0xa084, 0x0007, 0x0079, 0x57bf, 0x007c, 0x57c7,
+	0x57c7, 0x57c7, 0x5933, 0x57c7, 0x57c8, 0x57e1, 0x5858, 0x007c,
+	0x7110, 0xd1bc, 0x0040, 0x57e0, 0x7120, 0x2160, 0xac8c, 0x000f,
+	0x00c0, 0x57e0, 0xac8a, 0xad00, 0x0048, 0x57e0, 0x6858, 0xac02,
+	0x00c8, 0x57e0, 0x7124, 0x610a, 0x2009, 0x0046, 0x1078, 0x775c,
+	0x007c, 0x0c7e, 0xa484, 0x01ff, 0x0040, 0x5833, 0x7110, 0xd1bc,
+	0x00c0, 0x5833, 0x2011, 0xab83, 0x2204, 0x8211, 0x220c, 0x1078,
+	0x254d, 0x00c0, 0x5833, 0x1078, 0x455c, 0x00c0, 0x5833, 0x6612,
+	0x6516, 0x6000, 0xd0ec, 0x00c0, 0x5833, 0x6204, 0xa294, 0xff00,
+	0x8217, 0xa286, 0x0006, 0x00c0, 0x5818, 0x0c7e, 0x1078, 0x76c7,
+	0x017f, 0x0040, 0x5835, 0x611a, 0x601f, 0x0006, 0x7120, 0x610a,
+	0x7130, 0x6122, 0x2009, 0x0044, 0x1078, 0x775c, 0x0078, 0x5833,
+	0x0c7e, 0x1078, 0x76c7, 0x017f, 0x0040, 0x5833, 0x611a, 0x601f,
+	0x0004, 0x7120, 0x610a, 0xa286, 0x0004, 0x00c0, 0x582b, 0x6007,
+	0x0005, 0x0078, 0x582d, 0x6007, 0x0001, 0x6003, 0x0001, 0x1078,
+	0x5dd7, 0x1078, 0x62d1, 0x0c7f, 0x007c, 0x2001, 0xa60d, 0x2004,
+	0xd0ec, 0x0040, 0x583f, 0x2011, 0x8049, 0x1078, 0x361b, 0x0c7e,
+	0x1078, 0x9187, 0x017f, 0x0040, 0x5833, 0x611a, 0x601f, 0x0006,
+	0x7120, 0x610a, 0x7130, 0x6122, 0x6013, 0x0300, 0x6003, 0x0001,
+	0x6007, 0x0041, 0x1078, 0x5d8a, 0x1078, 0x62d1, 0x0078, 0x5833,
+	0x7110, 0xd1bc, 0x0040, 0x5870, 0x7020, 0x2060, 0xac84, 0x000f,
+	0x00c0, 0x5870, 0xac82, 0xad00, 0x0048, 0x5870, 0x6858, 0xac02,
+	0x00c8, 0x5870, 0x7124, 0x610a, 0x2009, 0x0045, 0x1078, 0x775c,
+	0x007c, 0x007e, 0x1078, 0x29bb, 0x007f, 0x00c0, 0x5887, 0x7110,
+	0xa18c, 0xff00, 0x810f, 0xa18e, 0x0000, 0x00c0, 0x5887, 0xa084,
+	0x000f, 0xa08a, 0x0006, 0x00c8, 0x5887, 0x1079, 0x5888, 0x007c,
+	0x588e, 0x588f, 0x588e, 0x588e, 0x58ff, 0x590e, 0x007c, 0x7110,
+	0xd1bc, 0x0040, 0x5897, 0x702c, 0xd084, 0x0040, 0x58fe, 0x700c,
+	0x7108, 0x1078, 0x254d, 0x00c0, 0x58fe, 0x1078, 0x455c, 0x00c0,
+	0x58fe, 0x6612, 0x6516, 0x6204, 0x7110, 0xd1bc, 0x0040, 0x58c9,
+	0xa28c, 0x00ff, 0xa186, 0x0004, 0x0040, 0x58b2, 0xa186, 0x0006,
+	0x00c0, 0x58ef, 0x0c7e, 0x1078, 0x591d, 0x0c7f, 0x0040, 0x58fe,
+	0x0c7e, 0x1078, 0x76c7, 0x017f, 0x0040, 0x58fe, 0x611a, 0x601f,
+	0x0002, 0x7120, 0x610a, 0x2009, 0x0088, 0x1078, 0x775c, 0x0078,
+	0x58fe, 0xa28c, 0x00ff, 0xa186, 0x0006, 0x0040, 0x58de, 0xa186,
+	0x0004, 0x0040, 0x58de, 0xa294, 0xff00, 0x8217, 0xa286, 0x0004,
+	0x0040, 0x58de, 0xa286, 0x0006, 0x00c0, 0x58ef, 0x0c7e, 0x1078,
+	0x76c7, 0x017f, 0x0040, 0x58fe, 0x611a, 0x601f, 0x0005, 0x7120,
+	0x610a, 0x2009, 0x0088, 0x1078, 0x775c, 0x0078, 0x58fe, 0x0c7e,
+	0x1078, 0x76c7, 0x017f, 0x0040, 0x58fe, 0x611a, 0x601f, 0x0004,
+	0x7120, 0x610a, 0x2009, 0x0001, 0x1078, 0x775c, 0x007c, 0x7110,
+	0xd1bc, 0x0040, 0x590d, 0x1078, 0x591d, 0x0040, 0x590d, 0x7124,
+	0x610a, 0x2009, 0x0089, 0x1078, 0x775c, 0x007c, 0x7110, 0xd1bc,
+	0x0040, 0x591c, 0x1078, 0x591d, 0x0040, 0x591c, 0x7124, 0x610a,
+	0x2009, 0x008a, 0x1078, 0x775c, 0x007c, 0x7020, 0x2060, 0xac84,
+	0x000f, 0x00c0, 0x5930, 0xac82, 0xad00, 0x0048, 0x5930, 0x2001,
+	0xa616, 0x2004, 0xac02, 0x00c8, 0x5930, 0xa085, 0x0001, 0x007c,
+	0xa006, 0x0078, 0x592f, 0x7110, 0xd1bc, 0x00c0, 0x5949, 0x7024,
+	0x2060, 0xac84, 0x000f, 0x00c0, 0x5949, 0xac82, 0xad00, 0x0048,
+	0x5949, 0x6858, 0xac02, 0x00c8, 0x5949, 0x2009, 0x0051, 0x1078,
+	0x775c, 0x007c, 0x2071, 0xa8c4, 0x7003, 0x0003, 0x700f, 0x0361,
+	0xa006, 0x701a, 0x7012, 0x7017, 0xad00, 0x7007, 0x0000, 0x7026,
+	0x702b, 0x6e1c, 0x7032, 0x7037, 0x6e70, 0x703b, 0x0002, 0x703f,
+	0x0000, 0x7043, 0xffff, 0x7047, 0xffff, 0x007c, 0x2071, 0xa8c4,
+	0x00e0, 0x5a32, 0x2091, 0x6000, 0x700c, 0x8001, 0x700e, 0x00c0,
+	0x59de, 0x700f, 0x0361, 0x7007, 0x0001, 0x127e, 0x2091, 0x8000,
+	0x7138, 0x8109, 0x713a, 0x00c0, 0x59dc, 0x703b, 0x0002, 0x2009,
+	0x0100, 0x2104, 0xa082, 0x0003, 0x00c8, 0x59dc, 0x703c, 0xa086,
+	0x0001, 0x00c0, 0x59b9, 0x0d7e, 0x2069, 0x0140, 0x6804, 0xa084,
+	0x4000, 0x0040, 0x5997, 0x6803, 0x1000, 0x0078, 0x599e, 0x6804,
+	0xa084, 0x1000, 0x0040, 0x599e, 0x6803, 0x0100, 0x6803, 0x0000,
+	0x703f, 0x0000, 0x2069, 0xa8b1, 0x6804, 0xa082, 0x0006, 0x00c0,
+	0x59ab, 0x6807, 0x0000, 0x6830, 0xa082, 0x0003, 0x00c0, 0x59b2,
+	0x6833, 0x0000, 0x1078, 0x62d1, 0x1078, 0x639b, 0x0d7f, 0x0078,
+	0x59dc, 0x0d7e, 0x2069, 0xa600, 0x6948, 0x6864, 0xa102, 0x00c8,
+	0x59db, 0x2069, 0xa8b1, 0x6804, 0xa086, 0x0000, 0x00c0, 0x59db,
+	0x6830, 0xa086, 0x0000, 0x00c0, 0x59db, 0x703f, 0x0001, 0x6807,
+	0x0006, 0x6833, 0x0003, 0x2069, 0x0100, 0x6830, 0x689e, 0x2069,
+	0x0140, 0x6803, 0x0600, 0x0d7f, 0x0078, 0x59e1, 0x127e, 0x2091,
+	0x8000, 0x7024, 0xa00d, 0x0040, 0x59f9, 0x7020, 0x8001, 0x7022,
+	0x00c0, 0x59f9, 0x7023, 0x0009, 0x8109, 0x7126, 0xa186, 0x03e8,
+	0x00c0, 0x59f4, 0x7028, 0x107a, 0x81ff, 0x00c0, 0x59f9, 0x7028,
+	0x107a, 0x7030, 0xa00d, 0x0040, 0x5a10, 0x702c, 0x8001, 0x702e,
+	0x00c0, 0x5a10, 0x702f, 0x0009, 0x8109, 0x7132, 0x0040, 0x5a0e,
+	0xa184, 0x007f, 0x1040, 0x6ea2, 0x0078, 0x5a10, 0x7034, 0x107a,
+	0x7040, 0xa005, 0x0040, 0x5a18, 0x0050, 0x5a18, 0x8001, 0x7042,
+	0x7044, 0xa005, 0x0040, 0x5a20, 0x0050, 0x5a20, 0x8001, 0x7046,
+	0x7018, 0xa00d, 0x0040, 0x5a31, 0x7008, 0x8001, 0x700a, 0x00c0,
+	0x5a31, 0x700b, 0x0009, 0x8109, 0x711a, 0x00c0, 0x5a31, 0x701c,
+	0x107a, 0x127f, 0x7004, 0x0079, 0x5a35, 0x5a5c, 0x5a5d, 0x5a79,
+	0x0e7e, 0x2071, 0xa8c4, 0x7018, 0xa005, 0x00c0, 0x5a43, 0x711a,
+	0x721e, 0x700b, 0x0009, 0x0e7f, 0x007c, 0x0e7e, 0x007e, 0x2071,
+	0xa8c4, 0x701c, 0xa206, 0x00c0, 0x5a4f, 0x701a, 0x701e, 0x007f,
+	0x0e7f, 0x007c, 0x0e7e, 0x2071, 0xa8c4, 0x6088, 0xa102, 0x0048,
+	0x5a5a, 0x618a, 0x0e7f, 0x007c, 0x007c, 0x7110, 0x1078, 0x45c4,
+	0x00c0, 0x5a6f, 0x6088, 0x8001, 0x0048, 0x5a6f, 0x608a, 0x00c0,
+	0x5a6f, 0x127e, 0x2091, 0x8000, 0x1078, 0x62d1, 0x127f, 0x8108,
+	0xa182, 0x00ff, 0x0048, 0x5a77, 0xa00e, 0x7007, 0x0002, 0x7112,
+	0x007c, 0x7014, 0x2060, 0x127e, 0x2091, 0x8000, 0x603c, 0xa005,
+	0x0040, 0x5a88, 0x8001, 0x603e, 0x00c0, 0x5a88, 0x1078, 0x8f9c,
+	0x6014, 0xa005, 0x0040, 0x5ab2, 0x8001, 0x6016, 0x00c0, 0x5ab2,
+	0x611c, 0xa186, 0x0003, 0x0040, 0x5a99, 0xa186, 0x0006, 0x00c0,
+	0x5ab0, 0x6010, 0x2068, 0x6854, 0xa08a, 0x199a, 0x0048, 0x5ab0,
+	0xa082, 0x1999, 0x6856, 0xa08a, 0x199a, 0x0048, 0x5aa9, 0x2001,
+	0x1999, 0x8003, 0x800b, 0x810b, 0xa108, 0x6116, 0x0078, 0x5ab2,
+	0x1078, 0x8abe, 0x127f, 0xac88, 0x0010, 0x7116, 0x2001, 0xcd00,
+	0xa102, 0x0048, 0x5abf, 0x7017, 0xad00, 0x7007, 0x0000, 0x007c,
+	0x0e7e, 0x2071, 0xa8c4, 0x7027, 0x07d0, 0x7023, 0x0009, 0x703b,
+	0x0002, 0x0e7f, 0x007c, 0x2001, 0xa8cd, 0x2003, 0x0000, 0x007c,
+	0x0e7e, 0x2071, 0xa8c4, 0x7132, 0x702f, 0x0009, 0x0e7f, 0x007c,
+	0x2011, 0xa8d0, 0x2013, 0x0000, 0x007c, 0x0e7e, 0x2071, 0xa8c4,
+	0x711a, 0x721e, 0x700b, 0x0009, 0x0e7f, 0x007c, 0x027e, 0x0e7e,
+	0x0f7e, 0x2079, 0xa600, 0x7a34, 0xd294, 0x0040, 0x5b15, 0x2071,
+	0xa8ac, 0x2e14, 0xa0fe, 0x0000, 0x0040, 0x5b02, 0xa0fe, 0x0001,
+	0x0040, 0x5b06, 0xa0fe, 0x0002, 0x00c0, 0x5b11, 0xa292, 0x0085,
+	0x0078, 0x5b08, 0xa292, 0x0005, 0x0078, 0x5b08, 0xa292, 0x0002,
+	0x2272, 0x0040, 0x5b0d, 0x00c8, 0x5b15, 0x2011, 0x8037, 0x1078,
+	0x361b, 0x2011, 0xa8ab, 0x2204, 0x2072, 0x0f7f, 0x0e7f, 0x027f,
+	0x007c, 0x0c7e, 0x2061, 0xa933, 0x0c7f, 0x007c, 0xa184, 0x000f,
+	0x8003, 0x8003, 0x8003, 0xa080, 0xa933, 0x2060, 0x007c, 0x6854,
+	0xa08a, 0x199a, 0x0048, 0x5b2e, 0x2001, 0x1999, 0xa005, 0x00c0,
+	0x5b3d, 0x0c7e, 0x2061, 0xa933, 0x6014, 0x0c7f, 0xa005, 0x00c0,
+	0x5b42, 0x2001, 0x001e, 0x0078, 0x5b42, 0xa08e, 0xffff, 0x00c0,
+	0x5b42, 0xa006, 0x8003, 0x800b, 0x810b, 0xa108, 0x6116, 0x684c,
+	0xa08c, 0x00c0, 0xa18e, 0x00c0, 0x0040, 0x5b9e, 0xd0b4, 0x00c0,
+	0x5b59, 0xd0bc, 0x00c0, 0x5b8b, 0x2009, 0x0006, 0x1078, 0x5bc3,
+	0x007c, 0xd0fc, 0x0040, 0x5b64, 0xa084, 0x0003, 0x0040, 0x5b64,
+	0xa086, 0x0003, 0x00c0, 0x5bbc, 0x6024, 0xd0d4, 0x0040, 0x5b6e,
+	0xc0d4, 0x6026, 0x6860, 0x602a, 0x685c, 0x602e, 0x2009, 0xa674,
+	0x2104, 0xd084, 0x0040, 0x5b83, 0x6118, 0xa188, 0x0027, 0x2104,
+	0xd08c, 0x00c0, 0x5b83, 0x87ff, 0x00c0, 0x5b82, 0x2009, 0x0042,
+	0x1078, 0x775c, 0x007c, 0x87ff, 0x00c0, 0x5b8a, 0x2009, 0x0043,
+	0x1078, 0x775c, 0x007c, 0xd0fc, 0x0040, 0x5b96, 0xa084, 0x0003,
+	0x0040, 0x5b96, 0xa086, 0x0003, 0x00c0, 0x5bbc, 0x87ff, 0x00c0,
+	0x5b9d, 0x2009, 0x0042, 0x1078, 0x775c, 0x007c, 0xd0fc, 0x0040,
+	0x5baf, 0xa084, 0x0003, 0xa08e, 0x0002, 0x0040, 0x5bb3, 0x87ff,
+	0x00c0, 0x5bae, 0x2009, 0x0041, 0x1078, 0x775c, 0x007c, 0x1078,
+	0x5bc1, 0x0078, 0x5bae, 0x87ff, 0x00c0, 0x5bae, 0x2009, 0x0043,
+	0x1078, 0x775c, 0x0078, 0x5bae, 0x2009, 0x0004, 0x1078, 0x5bc3,
+	0x007c, 0x2009, 0x0001, 0x0d7e, 0x6010, 0xa0ec, 0xf000, 0x0040,
+	0x5bef, 0x2068, 0x6952, 0x6800, 0x6012, 0xa186, 0x0001, 0x00c0,
+	0x5be5, 0x694c, 0xa18c, 0x8100, 0xa18e, 0x8100, 0x00c0, 0x5be5,
+	0x0c7e, 0x2061, 0xa933, 0x6200, 0xd28c, 0x00c0, 0x5be4, 0x6204,
+	0x8210, 0x0048, 0x5be4, 0x6206, 0x0c7f, 0x1078, 0x4a73, 0x6010,
+	0xa06d, 0x077e, 0x2039, 0x0000, 0x10c0, 0x5b27, 0x077f, 0x0d7f,
+	0x007c, 0x157e, 0x0c7e, 0x2061, 0xa933, 0x6000, 0x81ff, 0x0040,
+	0x5bfc, 0xa205, 0x0078, 0x5bfd, 0xa204, 0x6002, 0x0c7f, 0x157f,
+	0x007c, 0x6800, 0xd08c, 0x00c0, 0x5c0d, 0x6808, 0xa005, 0x0040,
+	0x5c0d, 0x8001, 0x680a, 0xa085, 0x0001, 0x007c, 0x20a9, 0x0010,
+	0xa006, 0x8004, 0x8086, 0x818e, 0x00c8, 0x5c17, 0xa200, 0x00f0,
+	0x5c12, 0x8086, 0x818e, 0x007c, 0x157e, 0x20a9, 0x0010, 0xa005,
+	0x0040, 0x5c3d, 0xa11a, 0x00c8, 0x5c3d, 0x8213, 0x818d, 0x0048,
+	0x5c30, 0xa11a, 0x00c8, 0x5c31, 0x00f0, 0x5c25, 0x0078, 0x5c35,
+	0xa11a, 0x2308, 0x8210, 0x00f0, 0x5c25, 0x007e, 0x3200, 0xa084,
+	0xf7ff, 0x2080, 0x007f, 0x157f, 0x007c, 0x007e, 0x3200, 0xa085,
+	0x0800, 0x0078, 0x5c39, 0x127e, 0x2091, 0x2200, 0x2079, 0xa8b1,
+	0x127f, 0x0d7e, 0x2069, 0xa8b1, 0x6803, 0x0005, 0x2069, 0x0004,
+	0x2d04, 0xa085, 0x8001, 0x206a, 0x0d7f, 0x007c, 0x0c7e, 0x6027,
+	0x0001, 0x7804, 0xa084, 0x0007, 0x0079, 0x5c5e, 0x5c68, 0x5c8d,
+	0x5ce8, 0x5c6e, 0x5c8d, 0x5c68, 0x5c66, 0x5c66, 0x1078, 0x1332,
+	0x1078, 0x5acb, 0x1078, 0x62d1, 0x0c7f, 0x007c, 0x62c0, 0x82ff,
+	0x00c0, 0x5c74, 0x0c7f, 0x007c, 0x2011, 0x41dc, 0x1078, 0x5a45,
+	0x7828, 0xa092, 0x00c8, 0x00c8, 0x5c83, 0x8000, 0x782a, 0x1078,
+	0x421b, 0x0078, 0x5c72, 0x1078, 0x41dc, 0x7807, 0x0003, 0x7827,
+	0x0000, 0x782b, 0x0000, 0x0078, 0x5c72, 0x1078, 0x5acb, 0x3c00,
+	0x007e, 0x2011, 0x0209, 0x20e1, 0x4000, 0x2214, 0x007f, 0x20e0,
+	0x82ff, 0x0040, 0x5cab, 0x62c0, 0x82ff, 0x00c0, 0x5cab, 0x782b,
+	0x0000, 0x7824, 0xa065, 0x1040, 0x1332, 0x2009, 0x0013, 0x1078,
+	0x775c, 0x0c7f, 0x007c, 0x3900, 0xa082, 0xa9e3, 0x00c8, 0x5cb2,
+	0x1078, 0x747a, 0x0c7e, 0x7824, 0xa065, 0x1040, 0x1332, 0x7804,
+	0xa086, 0x0004, 0x0040, 0x5d2d, 0x7828, 0xa092, 0x2710, 0x00c8,
+	0x5cc8, 0x8000, 0x782a, 0x0c7f, 0x1078, 0x6e01, 0x0078, 0x5ca9,
+	0x6104, 0xa186, 0x0003, 0x00c0, 0x5cdf, 0x0e7e, 0x2071, 0xa600,
+	0x70d8, 0x0e7f, 0xd08c, 0x0040, 0x5cdf, 0x0c7e, 0x0e7e, 0x2061,
+	0x0100, 0x2071, 0xa600, 0x1078, 0x4224, 0x0e7f, 0x0c7f, 0x1078,
+	0xa5c4, 0x2009, 0x0014, 0x1078, 0x775c, 0x0c7f, 0x0078, 0x5ca9,
+	0x2001, 0xa8cd, 0x2003, 0x0000, 0x62c0, 0x82ff, 0x00c0, 0x5cfc,
+	0x782b, 0x0000, 0x7824, 0xa065, 0x1040, 0x1332, 0x2009, 0x0013,
+	0x1078, 0x77b3, 0x0c7f, 0x007c, 0x0c7e, 0x0d7e, 0x3900, 0xa082,
+	0xa9e3, 0x00c8, 0x5d05, 0x1078, 0x747a, 0x7824, 0xa005, 0x1040,
+	0x1332, 0x781c, 0xa06d, 0x1040, 0x1332, 0x6800, 0xc0dc, 0x6802,
+	0x7924, 0x2160, 0x1078, 0x772d, 0x693c, 0x81ff, 0x1040, 0x1332,
+	0x8109, 0x693e, 0x6854, 0xa015, 0x0040, 0x5d21, 0x7a1e, 0x0078,
+	0x5d23, 0x7918, 0x791e, 0x7807, 0x0000, 0x7827, 0x0000, 0x0d7f,
+	0x0c7f, 0x1078, 0x62d1, 0x0078, 0x5cfa, 0x6104, 0xa186, 0x0002,
+	0x0040, 0x5d38, 0xa186, 0x0004, 0x0040, 0x5d38, 0x0078, 0x5cbc,
+	0x7808, 0xac06, 0x0040, 0x5cbc, 0x1078, 0x61cd, 0x1078, 0x5dd7,
+	0x0c7f, 0x1078, 0x62d1, 0x0078, 0x5ca9, 0x0c7e, 0x6027, 0x0002,
+	0x62c8, 0x82ff, 0x00c0, 0x5d61, 0x62c4, 0x82ff, 0x00c0, 0x5d61,
+	0x793c, 0xa1e5, 0x0000, 0x0040, 0x5d5b, 0x2009, 0x0049, 0x1078,
+	0x775c, 0x0c7f, 0x007c, 0x2011, 0xa8d0, 0x2013, 0x0000, 0x0078,
+	0x5d59, 0x3908, 0xa192, 0xa9e3, 0x00c8, 0x5d68, 0x1078, 0x747a,
+	0x6017, 0x0010, 0x793c, 0x81ff, 0x0040, 0x5d5b, 0x7944, 0xa192,
+	0x7530, 0x00c8, 0x5d85, 0x8108, 0x7946, 0x793c, 0xa188, 0x0007,
+	0x210c, 0xa18e, 0x0006, 0x00c0, 0x5d81, 0x6017, 0x0012, 0x0078,
+	0x5d59, 0x6017, 0x0016, 0x0078, 0x5d59, 0x7848, 0xc085, 0x784a,
+	0x0078, 0x5d59, 0x007e, 0x017e, 0x0c7e, 0x127e, 0x2091, 0x8000,
+	0x600f, 0x0000, 0x2c08, 0x2061, 0xa8b1, 0x6020, 0x8000, 0x6022,
+	0x6010, 0xa005, 0x0040, 0x5da5, 0xa080, 0x0003, 0x2102, 0x6112,
+	0x127f, 0x0c7f, 0x017f, 0x007f, 0x007c, 0x6116, 0x6112, 0x0078,
+	0x5da0, 0x0d7e, 0x2069, 0xa8b1, 0x6000, 0xd0d4, 0x0040, 0x5dbe,
+	0x6820, 0x8000, 0x6822, 0xa086, 0x0001, 0x00c0, 0x5db9, 0x2c00,
+	0x681e, 0x6804, 0xa084, 0x0007, 0x0079, 0x62d9, 0xc0d5, 0x6002,
+	0x6818, 0xa005, 0x0040, 0x5dd0, 0x6056, 0x605b, 0x0000, 0x007e,
+	0x2c00, 0x681a, 0x0d7f, 0x685a, 0x2069, 0xa8b1, 0x0078, 0x5db0,
+	0x6056, 0x605a, 0x2c00, 0x681a, 0x681e, 0x0078, 0x5db0, 0x007e,
+	0x017e, 0x0c7e, 0x127e, 0x2091, 0x8000, 0x600f, 0x0000, 0x2c08,
+	0x2061, 0xa8b1, 0x6020, 0x8000, 0x6022, 0x6008, 0xa005, 0x0040,
+	0x5df2, 0xa080, 0x0003, 0x2102, 0x610a, 0x127f, 0x0c7f, 0x017f,
+	0x007f, 0x007c, 0x610e, 0x610a, 0x0078, 0x5ded, 0x0c7e, 0x600f,
+	0x0000, 0x2c08, 0x2061, 0xa8b1, 0x6034, 0xa005, 0x0040, 0x5e06,
+	0xa080, 0x0003, 0x2102, 0x6136, 0x0c7f, 0x007c, 0x613a, 0x6136,
+	0x0078, 0x5e04, 0x0f7e, 0x0e7e, 0x0d7e, 0x0c7e, 0x067e, 0x057e,
+	0x037e, 0x027e, 0x017e, 0x007e, 0x127e, 0xa02e, 0x2071, 0xa8b1,
+	0x7638, 0x2660, 0x2678, 0x2091, 0x8000, 0x8cff, 0x0040, 0x5e8c,
+	0x6018, 0xa080, 0x0028, 0x2004, 0xa206, 0x00c0, 0x5e87, 0x87ff,
+	0x0040, 0x5e2e, 0x6020, 0xa106, 0x00c0, 0x5e87, 0x703c, 0xac06,
+	0x00c0, 0x5e44, 0x037e, 0x2019, 0x0001, 0x1078, 0x7058, 0x7033,
+	0x0000, 0x703f, 0x0000, 0x7043, 0x0000, 0x7047, 0x0000, 0x704b,
+	0x0000, 0x037f, 0x2029, 0x0001, 0x7038, 0xac36, 0x00c0, 0x5e4a,
+	0x660c, 0x763a, 0x7034, 0xac36, 0x00c0, 0x5e58, 0x2c00, 0xaf36,
+	0x0040, 0x5e56, 0x2f00, 0x7036, 0x0078, 0x5e58, 0x7037, 0x0000,
+	0x660c, 0x067e, 0x2c00, 0xaf06, 0x0040, 0x5e61, 0x7e0e, 0x0078,
+	0x5e62, 0x2678, 0x600f, 0x0000, 0x1078, 0x8d06, 0x0040, 0x5e82,
+	0x6010, 0x2068, 0x601c, 0xa086, 0x0003, 0x00c0, 0x5e9d, 0x6837,
+	0x0103, 0x6b4a, 0x6847, 0x0000, 0x017e, 0x037e, 0x077e, 0x1078,
+	0x8f7d, 0x1078, 0xa4e2, 0x1078, 0x4a73, 0x077f, 0x037f, 0x017f,
+	0x1078, 0x8eb9, 0x1078, 0x8ec6, 0x0c7f, 0x0078, 0x5e1d, 0x2c78,
+	0x600c, 0x2060, 0x0078, 0x5e1d, 0x85ff, 0x0040, 0x5e91, 0x1078,
+	0x639b, 0x127f, 0x007f, 0x017f, 0x027f, 0x037f, 0x057f, 0x067f,
+	0x0c7f, 0x0d7f, 0x0e7f, 0x0f7f, 0x007c, 0x601c, 0xa086, 0x0006,
+	0x00c0, 0x5e6f, 0x017e, 0x037e, 0x077e, 0x1078, 0xa4e2, 0x1078,
+	0xa1ca, 0x077f, 0x037f, 0x017f, 0x0078, 0x5e82, 0x007e, 0x067e,
+	0x0c7e, 0x0d7e, 0x0f7e, 0x2031, 0x0000, 0x127e, 0x2091, 0x8000,
+	0x2079, 0xa8b1, 0x7838, 0xa065, 0x0040, 0x5eef, 0x600c, 0x007e,
+	0x600f, 0x0000, 0x783c, 0xac06, 0x00c0, 0x5ed6, 0x037e, 0x2019,
+	0x0001, 0x1078, 0x7058, 0x7833, 0x0000, 0x783f, 0x0000, 0x7843,
+	0x0000, 0x7847, 0x0000, 0x784b, 0x0000, 0x037f, 0x1078, 0x8d06,
+	0x0040, 0x5eea, 0x6010, 0x2068, 0x601c, 0xa086, 0x0003, 0x00c0,
+	0x5ef8, 0x6837, 0x0103, 0x6b4a, 0x6847, 0x0000, 0x1078, 0x4a73,
+	0x1078, 0x8eb9, 0x1078, 0x8ec6, 0x007f, 0x0078, 0x5ebb, 0x7e3a,
+	0x7e36, 0x127f, 0x0f7f, 0x0d7f, 0x0c7f, 0x067f, 0x007f, 0x007c,
+	0x601c, 0xa086, 0x0006, 0x00c0, 0x5ee1, 0x1078, 0xa1ca, 0x0078,
+	0x5eea, 0x017e, 0x027e, 0x087e, 0x2041, 0x0000, 0x1078, 0x5f1b,
+	0x1078, 0x5fdb, 0x087f, 0x027f, 0x017f, 0x007c, 0x0f7e, 0x127e,
+	0x2079, 0xa8b1, 0x2091, 0x8000, 0x1078, 0x6076, 0x1078, 0x60ec,
+	0x127f, 0x0f7f, 0x007c, 0x0f7e, 0x0e7e, 0x0d7e, 0x0c7e, 0x067e,
+	0x017e, 0x007e, 0x127e, 0x2091, 0x8000, 0x2071, 0xa8b1, 0x7614,
+	0x2660, 0x2678, 0x8cff, 0x0040, 0x5fb5, 0x6018, 0xa080, 0x0028,
+	0x2004, 0xa206, 0x00c0, 0x5fb0, 0x88ff, 0x0040, 0x5f3b, 0x6020,
+	0xa106, 0x00c0, 0x5fb0, 0x7024, 0xac06, 0x00c0, 0x5f6b, 0x2069,
+	0x0100, 0x68c0, 0xa005, 0x0040, 0x5f66, 0x1078, 0x5acb, 0x1078,
+	0x6e0f, 0x68c3, 0x0000, 0x1078, 0x7378, 0x7027, 0x0000, 0x037e,
+	0x2069, 0x0140, 0x6b04, 0xa384, 0x1000, 0x0040, 0x5f5b, 0x6803,
+	0x0100, 0x6803, 0x0000, 0x2069, 0x0100, 0x6824, 0xd084, 0x0040,
+	0x5f63, 0x6827, 0x0001, 0x037f, 0x0078, 0x5f6b, 0x6003, 0x0009,
+	0x630a, 0x0078, 0x5fb0, 0x7014, 0xac36, 0x00c0, 0x5f71, 0x660c,
+	0x7616, 0x7010, 0xac36, 0x00c0, 0x5f7f, 0x2c00, 0xaf36, 0x0040,
+	0x5f7d, 0x2f00, 0x7012, 0x0078, 0x5f7f, 0x7013, 0x0000, 0x660c,
+	0x067e, 0x2c00, 0xaf06, 0x0040, 0x5f88, 0x7e0e, 0x0078, 0x5f89,
+	0x2678, 0x600f, 0x0000, 0x6010, 0x2068, 0x1078, 0x8d06, 0x0040,
+	0x5fa9, 0x601c, 0xa086, 0x0003, 0x00c0, 0x5fbe, 0x6837, 0x0103,
+	0x6b4a, 0x6847, 0x0000, 0x017e, 0x037e, 0x087e, 0x1078, 0x8f7d,
+	0x1078, 0xa4e2, 0x1078, 0x4a73, 0x087f, 0x037f, 0x017f, 0x1078,
+	0x8eb9, 0x1078, 0x8ec6, 0x1078, 0x7233, 0x0c7f, 0x0078, 0x5f2a,
+	0x2c78, 0x600c, 0x2060, 0x0078, 0x5f2a, 0x127f, 0x007f, 0x017f,
+	0x067f, 0x0c7f, 0x0d7f, 0x0e7f, 0x0f7f, 0x007c, 0x601c, 0xa086,
+	0x0006, 0x00c0, 0x5fcf, 0x017e, 0x037e, 0x087e, 0x1078, 0xa4e2,
+	0x1078, 0xa1ca, 0x087f, 0x037f, 0x017f, 0x0078, 0x5fa9, 0x601c,
+	0xa086, 0x0002, 0x00c0, 0x5fa9, 0x6004, 0xa086, 0x0085, 0x0040,
+	0x5f96, 0x0078, 0x5fa9, 0x0c7e, 0x007e, 0x127e, 0x2091, 0x8000,
+	0xa280, 0xa735, 0x2004, 0xa065, 0x0040, 0x6072, 0x0f7e, 0x0e7e,
+	0x0d7e, 0x067e, 0x2071, 0xa8b1, 0x6654, 0x7018, 0xac06, 0x00c0,
+	0x5ff2, 0x761a, 0x701c, 0xac06, 0x00c0, 0x5ffe, 0x86ff, 0x00c0,
+	0x5ffd, 0x7018, 0x701e, 0x0078, 0x5ffe, 0x761e, 0x6058, 0xa07d,
+	0x0040, 0x6003, 0x7e56, 0xa6ed, 0x0000, 0x0040, 0x6009, 0x2f00,
+	0x685a, 0x6057, 0x0000, 0x605b, 0x0000, 0x6000, 0xc0d4, 0xc0dc,
+	0x6002, 0x1078, 0x44d3, 0x0040, 0x606e, 0x7624, 0x86ff, 0x0040,
+	0x605c, 0xa680, 0x0004, 0x2004, 0xad06, 0x00c0, 0x605c, 0x0d7e,
+	0x2069, 0x0100, 0x68c0, 0xa005, 0x0040, 0x6053, 0x1078, 0x5acb,
+	0x1078, 0x6e0f, 0x68c3, 0x0000, 0x1078, 0x7378, 0x7027, 0x0000,
+	0x037e, 0x2069, 0x0140, 0x6b04, 0xa384, 0x1000, 0x0040, 0x603c,
+	0x6803, 0x0100, 0x6803, 0x0000, 0x2069, 0x0100, 0x6824, 0xd084,
+	0x0040, 0x6044, 0x6827, 0x0001, 0x037f, 0x0d7f, 0x0c7e, 0x603c,
+	0xa005, 0x0040, 0x604d, 0x8001, 0x603e, 0x2660, 0x1078, 0x8ec6,
+	0x0c7f, 0x0078, 0x605c, 0x0d7f, 0x0c7e, 0x2660, 0x6003, 0x0009,
+	0x630a, 0x0c7f, 0x0078, 0x6011, 0x8dff, 0x0040, 0x606a, 0x6837,
+	0x0103, 0x6b4a, 0x6847, 0x0000, 0x1078, 0x8f7d, 0x1078, 0xa4e2,
+	0x1078, 0x4a73, 0x1078, 0x7233, 0x0078, 0x6011, 0x067f, 0x0d7f,
+	0x0e7f, 0x0f7f, 0x127f, 0x007f, 0x0c7f, 0x007c, 0x007e, 0x067e,
+	0x0c7e, 0x0d7e, 0x2031, 0x0000, 0x7814, 0xa065, 0x0040, 0x60d0,
+	0x600c, 0x007e, 0x600f, 0x0000, 0x7824, 0xac06, 0x00c0, 0x60b5,
+	0x2069, 0x0100, 0x68c0, 0xa005, 0x0040, 0x60af, 0x1078, 0x5acb,
+	0x1078, 0x6e0f, 0x68c3, 0x0000, 0x1078, 0x7378, 0x7827, 0x0000,
+	0x037e, 0x2069, 0x0140, 0x6b04, 0xa384, 0x1000, 0x0040, 0x60a4,
+	0x6803, 0x0100, 0x6803, 0x0000, 0x2069, 0x0100, 0x6824, 0xd084,
+	0x0040, 0x60ac, 0x6827, 0x0001, 0x037f, 0x0078, 0x60b5, 0x6003,
+	0x0009, 0x630a, 0x2c30, 0x0078, 0x60cd, 0x6010, 0x2068, 0x1078,
+	0x8d06, 0x0040, 0x60c9, 0x601c, 0xa086, 0x0003, 0x00c0, 0x60d7,
+	0x6837, 0x0103, 0x6b4a, 0x6847, 0x0000, 0x1078, 0x4a73, 0x1078,
+	0x8eb9, 0x1078, 0x8ec6, 0x1078, 0x7233, 0x007f, 0x0078, 0x607d,
+	0x7e16, 0x7e12, 0x0d7f, 0x0c7f, 0x067f, 0x007f, 0x007c, 0x601c,
+	0xa086, 0x0006, 0x00c0, 0x60e0, 0x1078, 0xa1ca, 0x0078, 0x60c9,
+	0x601c, 0xa086, 0x0002, 0x00c0, 0x60c9, 0x6004, 0xa086, 0x0085,
+	0x0040, 0x60c0, 0x0078, 0x60c9, 0x007e, 0x067e, 0x0c7e, 0x0d7e,
+	0x7818, 0xa065, 0x0040, 0x615a, 0x6054, 0x007e, 0x6057, 0x0000,
+	0x605b, 0x0000, 0x6000, 0xc0d4, 0xc0dc, 0x6002, 0x1078, 0x44d3,
+	0x0040, 0x6157, 0x7e24, 0x86ff, 0x0040, 0x6149, 0xa680, 0x0004,
+	0x2004, 0xad06, 0x00c0, 0x6149, 0x0d7e, 0x2069, 0x0100, 0x68c0,
+	0xa005, 0x0040, 0x6140, 0x1078, 0x5acb, 0x1078, 0x6e0f, 0x68c3,
+	0x0000, 0x1078, 0x7378, 0x7827, 0x0000, 0x037e, 0x2069, 0x0140,
+	0x6b04, 0xa384, 0x1000, 0x0040, 0x6129, 0x6803, 0x0100, 0x6803,
+	0x0000, 0x2069, 0x0100, 0x6824, 0xd084, 0x0040, 0x6131, 0x6827,
+	0x0001, 0x037f, 0x0d7f, 0x0c7e, 0x603c, 0xa005, 0x0040, 0x613a,
+	0x8001, 0x603e, 0x2660, 0x1078, 0x8ec6, 0x0c7f, 0x0078, 0x6149,
+	0x0d7f, 0x0c7e, 0x2660, 0x6003, 0x0009, 0x630a, 0x0c7f, 0x0078,
+	0x60fe, 0x8dff, 0x0040, 0x6153, 0x6837, 0x0103, 0x6b4a, 0x6847,
+	0x0000, 0x1078, 0x4a73, 0x1078, 0x7233, 0x0078, 0x60fe, 0x007f,
+	0x0078, 0x60f1, 0x781e, 0x781a, 0x0d7f, 0x0c7f, 0x067f, 0x007f,
+	0x007c, 0x0e7e, 0x0d7e, 0x067e, 0x6000, 0xd0dc, 0x0040, 0x6181,
+	0x604c, 0xa06d, 0x0040, 0x6181, 0x6848, 0xa606, 0x00c0, 0x6181,
+	0x2071, 0xa8b1, 0x7024, 0xa035, 0x0040, 0x6181, 0xa080, 0x0004,
+	0x2004, 0xad06, 0x00c0, 0x6181, 0x6000, 0xc0dc, 0x6002, 0x1078,
+	0x6185, 0x067f, 0x0d7f, 0x0e7f, 0x007c, 0x0f7e, 0x2079, 0x0100,
+	0x78c0, 0xa005, 0x00c0, 0x6194, 0x0c7e, 0x2660, 0x6003, 0x0009,
+	0x630a, 0x0c7f, 0x0078, 0x61cb, 0x1078, 0x6e0f, 0x78c3, 0x0000,
+	0x1078, 0x7378, 0x7027, 0x0000, 0x037e, 0x2079, 0x0140, 0x7b04,
+	0xa384, 0x1000, 0x0040, 0x61a8, 0x7803, 0x0100, 0x7803, 0x0000,
+	0x2079, 0x0100, 0x7824, 0xd084, 0x0040, 0x61b0, 0x7827, 0x0001,
+	0x1078, 0x7378, 0x037f, 0x1078, 0x44d3, 0x0c7e, 0x603c, 0xa005,
+	0x0040, 0x61bc, 0x8001, 0x603e, 0x2660, 0x1078, 0x772d, 0x0c7f,
+	0x6837, 0x0103, 0x6b4a, 0x6847, 0x0000, 0x1078, 0x8f7d, 0x1078,
+	0x4a73, 0x1078, 0x7233, 0x0f7f, 0x007c, 0x0e7e, 0x0c7e, 0x2071,
+	0xa8b1, 0x7004, 0xa084, 0x0007, 0x0079, 0x61d6, 0x61e0, 0x61e3,
+	0x61fc, 0x6218, 0x6262, 0x61e0, 0x61e0, 0x61de, 0x1078, 0x1332,
+	0x0c7f, 0x0e7f, 0x007c, 0x7024, 0xa065, 0x0040, 0x61f1, 0x7020,
+	0x8001, 0x7022, 0x600c, 0xa015, 0x0040, 0x61f8, 0x7216, 0x600f,
+	0x0000, 0x7007, 0x0000, 0x7027, 0x0000, 0x0c7f, 0x0e7f, 0x007c,
+	0x7216, 0x7212, 0x0078, 0x61f1, 0x6018, 0x2060, 0x1078, 0x44d3,
+	0x6000, 0xc0dc, 0x6002, 0x7020, 0x8001, 0x7022, 0x0040, 0x620d,
+	0x6054, 0xa015, 0x0040, 0x6214, 0x721e, 0x7007, 0x0000, 0x7027,
+	0x0000, 0x0c7f, 0x0e7f, 0x007c, 0x7218, 0x721e, 0x0078, 0x620d,
+	0x7024, 0xa065, 0x0040, 0x625f, 0x700c, 0xac06, 0x00c0, 0x622f,
+	0x1078, 0x7233, 0x600c, 0xa015, 0x0040, 0x622b, 0x720e, 0x600f,
+	0x0000, 0x0078, 0x625d, 0x720e, 0x720a, 0x0078, 0x625d, 0x7014,
+	0xac06, 0x00c0, 0x6242, 0x1078, 0x7233, 0x600c, 0xa015, 0x0040,
+	0x623e, 0x7216, 0x600f, 0x0000, 0x0078, 0x625d, 0x7216, 0x7212,
+	0x0078, 0x625d, 0x601c, 0xa086, 0x0003, 0x00c0, 0x625d, 0x6018,
+	0x2060, 0x1078, 0x44d3, 0x6000, 0xc0dc, 0x6002, 0x1078, 0x7233,
+	0x701c, 0xa065, 0x0040, 0x625d, 0x6054, 0xa015, 0x0040, 0x625b,
+	0x721e, 0x0078, 0x625d, 0x7218, 0x721e, 0x7027, 0x0000, 0x0c7f,
+	0x0e7f, 0x007c, 0x7024, 0xa065, 0x0040, 0x626f, 0x1078, 0x7233,
+	0x600c, 0xa015, 0x0040, 0x6276, 0x720e, 0x600f, 0x0000, 0x1078,
+	0x7378, 0x7027, 0x0000, 0x0c7f, 0x0e7f, 0x007c, 0x720e, 0x720a,
+	0x0078, 0x626f, 0x0d7e, 0x2069, 0xa8b1, 0x6830, 0xa084, 0x0003,
+	0x0079, 0x6282, 0x6288, 0x628a, 0x62b4, 0x6288, 0x1078, 0x1332,
+	0x0d7f, 0x007c, 0x0c7e, 0x6840, 0xa086, 0x0001, 0x0040, 0x62aa,
+	0x683c, 0xa065, 0x0040, 0x629b, 0x600c, 0xa015, 0x0040, 0x62a6,
+	0x6a3a, 0x600f, 0x0000, 0x6833, 0x0000, 0x683f, 0x0000, 0x2011,
+	0xa8d0, 0x2013, 0x0000, 0x0c7f, 0x0d7f, 0x007c, 0x683a, 0x6836,
+	0x0078, 0x629b, 0x6843, 0x0000, 0x6838, 0xa065, 0x0040, 0x629b,
+	0x6003, 0x0003, 0x0078, 0x629b, 0x0c7e, 0x6843, 0x0000, 0x6847,
+	0x0000, 0x684b, 0x0000, 0x683c, 0xa065, 0x0040, 0x62ce, 0x600c,
+	0xa015, 0x0040, 0x62ca, 0x6a3a, 0x600f, 0x0000, 0x683f, 0x0000,
+	0x0078, 0x62ce, 0x683f, 0x0000, 0x683a, 0x6836, 0x0c7f, 0x0d7f,
+	0x007c, 0x0d7e, 0x2069, 0xa8b1, 0x6804, 0xa084, 0x0007, 0x0079,
+	0x62d9, 0x62e3, 0x638a, 0x638a, 0x638a, 0x638a, 0x638c, 0x638a,
+	0x62e1, 0x1078, 0x1332, 0x6820, 0xa005, 0x00c0, 0x62e9, 0x0d7f,
+	0x007c, 0x0c7e, 0x680c, 0xa065, 0x0040, 0x62f8, 0x6807, 0x0004,
+	0x6826, 0x682b, 0x0000, 0x1078, 0x63d4, 0x0c7f, 0x0d7f, 0x007c,
+	0x6814, 0xa065, 0x0040, 0x6306, 0x6807, 0x0001, 0x6826, 0x682b,
+	0x0000, 0x1078, 0x63d4, 0x0c7f, 0x0d7f, 0x007c, 0x0e7e, 0x037e,
+	0x6a1c, 0xa2f5, 0x0000, 0x0040, 0x6385, 0x704c, 0xa00d, 0x0040,
+	0x6315, 0x7088, 0xa005, 0x0040, 0x632d, 0x7054, 0xa075, 0x0040,
+	0x631e, 0xa20e, 0x0040, 0x6385, 0x0078, 0x6323, 0x6818, 0xa20e,
+	0x0040, 0x6385, 0x2070, 0x704c, 0xa00d, 0x0040, 0x6315, 0x7088,
+	0xa005, 0x00c0, 0x6315, 0x2e00, 0x681e, 0x733c, 0x7038, 0xa302,
+	0x00c8, 0x6315, 0x1078, 0x76fc, 0x0040, 0x6385, 0x8318, 0x733e,
+	0x6112, 0x2e10, 0x621a, 0xa180, 0x0014, 0x2004, 0xa084, 0x00ff,
+	0x6032, 0xa180, 0x0014, 0x2003, 0x0000, 0xa180, 0x0015, 0x2004,
+	0xa08a, 0x199a, 0x0048, 0x634e, 0x2001, 0x1999, 0x8003, 0x801b,
+	0x831b, 0xa318, 0x6316, 0x037f, 0x0f7e, 0x2c78, 0x71a0, 0xd1bc,
+	0x0040, 0x6367, 0x7100, 0xd1f4, 0x0040, 0x6363, 0x7114, 0xa18c,
+	0x00ff, 0x0078, 0x636c, 0x2009, 0x0000, 0x0078, 0x636c, 0xa1e0,
+	0x29c0, 0x2c0c, 0xa18c, 0x00ff, 0x2061, 0x0100, 0x619a, 0x1078,
+	0x6965, 0x7300, 0xc3dd, 0x7302, 0x6807, 0x0002, 0x2f18, 0x6b26,
+	0x682b, 0x0000, 0x781f, 0x0003, 0x7803, 0x0001, 0x7807, 0x0040,
+	0x0f7f, 0x0e7f, 0x0c7f, 0x0d7f, 0x007c, 0x037f, 0x0e7f, 0x0c7f,
+	0x0078, 0x6383, 0x0d7f, 0x007c, 0x0c7e, 0x680c, 0xa065, 0x0040,
+	0x6398, 0x6807, 0x0004, 0x6826, 0x682b, 0x0000, 0x1078, 0x63d4,
+	0x0c7f, 0x0d7f, 0x007c, 0x0f7e, 0x0d7e, 0x2069, 0xa8b1, 0x6830,
+	0xa086, 0x0000, 0x00c0, 0x63bb, 0x6838, 0xa07d, 0x0040, 0x63bb,
+	0x6833, 0x0001, 0x683e, 0x6847, 0x0000, 0x684b, 0x0000, 0x127e,
+	0x0f7e, 0x2091, 0x2200, 0x027f, 0x1078, 0x1d6d, 0x00c0, 0x63be,
+	0x127f, 0x1078, 0x6cb3, 0x0d7f, 0x0f7f, 0x007c, 0x127f, 0x6843,
+	0x0000, 0x7803, 0x0002, 0x780c, 0xa015, 0x0040, 0x63d0, 0x6a3a,
+	0x780f, 0x0000, 0x6833, 0x0000, 0x683f, 0x0000, 0x0078, 0x63bb,
+	0x683a, 0x6836, 0x0078, 0x63ca, 0x601c, 0xa084, 0x000f, 0x1079,
+	0x63da, 0x007c, 0x63e3, 0x63e8, 0x6809, 0x6922, 0x63e8, 0x6809,
+	0x6922, 0x63e3, 0x63e8, 0x1078, 0x61cd, 0x1078, 0x62d1, 0x007c,
+	0x157e, 0x137e, 0x147e, 0x0c7e, 0x0f7e, 0x6004, 0xa08a, 0x0044,
+	0x10c8, 0x1332, 0x6118, 0x2178, 0x79a0, 0xd1bc, 0x0040, 0x6405,
+	0x7900, 0xd1f4, 0x0040, 0x6401, 0x7914, 0xa18c, 0x00ff, 0x0078,
+	0x640a, 0x2009, 0x0000, 0x0078, 0x640a, 0xa1f8, 0x29c0, 0x2f0c,
+	0xa18c, 0x00ff, 0x2c78, 0x2061, 0x0100, 0x619a, 0xa08a, 0x0040,
+	0x00c8, 0x645c, 0x1079, 0x641a, 0x0f7f, 0x0c7f, 0x147f, 0x137f,
+	0x157f, 0x007c, 0x64c2, 0x650a, 0x6532, 0x65cd, 0x65fd, 0x6605,
+	0x662c, 0x663d, 0x664e, 0x6656, 0x666e, 0x6656, 0x66d9, 0x663d,
+	0x66fa, 0x6702, 0x664e, 0x6702, 0x6713, 0x645a, 0x645a, 0x645a,
+	0x645a, 0x645a, 0x645a, 0x645a, 0x645a, 0x645a, 0x645a, 0x645a,
+	0x6eef, 0x6f14, 0x6f29, 0x6f4c, 0x6f6d, 0x662c, 0x645a, 0x662c,
+	0x6656, 0x645a, 0x6532, 0x65cd, 0x645a, 0x749c, 0x6656, 0x645a,
+	0x74bc, 0x6656, 0x645a, 0x645a, 0x64bd, 0x646b, 0x645a, 0x74e1,
+	0x7558, 0x7640, 0x645a, 0x7651, 0x6626, 0x766d, 0x645a, 0x6f82,
+	0x645a, 0x645a, 0x1078, 0x1332, 0x2100, 0x1079, 0x6465, 0x0f7f,
+	0x0c7f, 0x147f, 0x137f, 0x157f, 0x007c, 0x6469, 0x6469, 0x6469,
+	0x649f, 0x1078, 0x1332, 0x0d7e, 0x20a1, 0x020b, 0x1078, 0x6731,
+	0x7810, 0x2068, 0x20a3, 0x2414, 0x20a3, 0x0018, 0x20a3, 0x0800,
+	0x683c, 0x20a2, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000,
+	0x20a3, 0x0000, 0x6850, 0x20a2, 0x6854, 0x20a2, 0x20a3, 0x0000,
+	0x20a3, 0x0000, 0x60c3, 0x0018, 0x1078, 0x6dfb, 0x0d7f, 0x007c,
+	0x0d7e, 0x7818, 0x2068, 0x68a0, 0xa082, 0x007e, 0x0048, 0x649c,
+	0xa085, 0x0001, 0x0d7f, 0x007c, 0xa006, 0x0078, 0x649a, 0x0d7e,
+	0x20a1, 0x020b, 0x1078, 0x6731, 0x20a3, 0x0500, 0x20a3, 0x0000,
+	0x7810, 0xa0e8, 0x000f, 0x6808, 0x20a2, 0x680c, 0x20a2, 0x6810,
+	0x20a2, 0x6814, 0x20a2, 0x6818, 0x20a2, 0x681c, 0x20a2, 0x60c3,
+	0x0010, 0x1078, 0x6dfb, 0x0d7f, 0x007c, 0x6030, 0x609a, 0x1078,
+	0x6dfb, 0x007c, 0x20a1, 0x020b, 0x1078, 0x6731, 0x20a3, 0x5200,
+	0x20a3, 0x0000, 0x0d7e, 0x2069, 0xa652, 0x6804, 0xd084, 0x0040,
+	0x64dc, 0x6828, 0x20a3, 0x0000, 0x017e, 0x1078, 0x2564, 0x21a2,
+	0x017f, 0x0d7f, 0x0078, 0x64e1, 0x0d7f, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x20a9, 0x0004, 0x2099, 0xa605, 0x53a6, 0x20a9, 0x0004,
+	0x2099, 0xa601, 0x53a6, 0x7818, 0xa080, 0x0028, 0x2004, 0xa082,
+	0x007f, 0x0048, 0x64fb, 0x2001, 0xa61b, 0x20a6, 0x2001, 0xa61c,
+	0x20a6, 0x0078, 0x6501, 0x20a3, 0x0000, 0x6030, 0xa084, 0x00ff,
+	0x20a2, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x60c3, 0x001c, 0x1078,
+	0x6dfb, 0x007c, 0x20a1, 0x020b, 0x1078, 0x6731, 0x20a3, 0x0500,
+	0x20a3, 0x0000, 0x7818, 0xa080, 0x0028, 0x2004, 0xa082, 0x007f,
+	0x0048, 0x6522, 0x2001, 0xa61b, 0x20a6, 0x2001, 0xa61c, 0x20a6,
+	0x0078, 0x6528, 0x20a3, 0x0000, 0x6030, 0xa084, 0x00ff, 0x20a2,
+	0x20a9, 0x0004, 0x2099, 0xa605, 0x53a6, 0x60c3, 0x0010, 0x1078,
+	0x6dfb, 0x007c, 0x20a1, 0x020b, 0x1078, 0x6731, 0x0c7e, 0x7818,
+	0x2060, 0x2001, 0x0000, 0x1078, 0x4972, 0x0c7f, 0x7818, 0xa080,
+	0x0028, 0x2004, 0xa086, 0x007e, 0x00c0, 0x654d, 0x20a3, 0x0400,
+	0x620c, 0xc2b4, 0x620e, 0x0078, 0x654f, 0x20a3, 0x0300, 0x20a3,
+	0x0000, 0x7818, 0xa080, 0x0028, 0x2004, 0xa086, 0x007e, 0x00c0,
+	0x659c, 0x2099, 0xa88d, 0x33a6, 0x9398, 0x33a6, 0x9398, 0x3304,
+	0xa084, 0x3fff, 0x20a2, 0x9398, 0x33a6, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x20a9, 0x0004, 0x2099,
+	0xa605, 0x53a6, 0x20a9, 0x0004, 0x2099, 0xa601, 0x53a6, 0x20a9,
+	0x0010, 0x20a3, 0x0000, 0x00f0, 0x6579, 0x2099, 0xa895, 0x3304,
+	0xc0dd, 0x20a2, 0x2001, 0xa672, 0x2004, 0xd0e4, 0x0040, 0x6594,
+	0x20a3, 0x0000, 0x20a3, 0x0000, 0x9398, 0x9398, 0x9398, 0x33a6,
+	0x20a9, 0x0004, 0x0078, 0x6596, 0x20a9, 0x0007, 0x20a3, 0x0000,
+	0x00f0, 0x6596, 0x0078, 0x65bc, 0x2099, 0xa88d, 0x20a9, 0x0008,
+	0x53a6, 0x20a9, 0x0004, 0x2099, 0xa605, 0x53a6, 0x20a9, 0x0004,
+	0x2099, 0xa601, 0x53a6, 0x20a9, 0x0008, 0x20a3, 0x0000, 0x00f0,
+	0x65ad, 0x20a9, 0x0008, 0x20a3, 0x0000, 0x00f0, 0x65b3, 0x2099,
+	0xa895, 0x20a9, 0x0008, 0x53a6, 0x20a9, 0x0008, 0x20a3, 0x0000,
+	0x00f0, 0x65be, 0x20a9, 0x000a, 0x20a3, 0x0000, 0x00f0, 0x65c4,
+	0x60c3, 0x0074, 0x1078, 0x6dfb, 0x007c, 0x20a1, 0x020b, 0x1078,
+	0x6731, 0x20a3, 0x2010, 0x20a3, 0x0014, 0x20a3, 0x0800, 0x20a3,
+	0x2000, 0xa006, 0x20a2, 0x20a2, 0x20a2, 0x20a2, 0x20a2, 0x0f7e,
+	0x2079, 0xa652, 0x7904, 0x0f7f, 0xd1ac, 0x00c0, 0x65e9, 0xa085,
+	0x0020, 0xd1a4, 0x0040, 0x65ee, 0xa085, 0x0010, 0xa085, 0x0002,
+	0x0d7e, 0x0078, 0x66b7, 0x20a2, 0x20a3, 0x0000, 0x20a3, 0x0000,
+	0x60c3, 0x0014, 0x1078, 0x6dfb, 0x007c, 0x20a1, 0x020b, 0x1078,
+	0x6731, 0x20a3, 0x5000, 0x0078, 0x654f, 0x20a1, 0x020b, 0x1078,
+	0x6731, 0x20a3, 0x2110, 0x20a3, 0x0014, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x60c3, 0x0014, 0x1078, 0x6dfb, 0x007c, 0x20a1, 0x020b,
+	0x1078, 0x67b9, 0x0078, 0x6630, 0x20a1, 0x020b, 0x1078, 0x67c2,
+	0x20a3, 0x0200, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000,
+	0x60c3, 0x0004, 0x1078, 0x6dfb, 0x007c, 0x20a1, 0x020b, 0x1078,
+	0x67c2, 0x20a3, 0x0100, 0x20a3, 0x0000, 0x20a3, 0x0003, 0x20a3,
+	0x2a00, 0x60c3, 0x0008, 0x1078, 0x6dfb, 0x007c, 0x20a1, 0x020b,
+	0x1078, 0x67c2, 0x20a3, 0x0200, 0x0078, 0x654f, 0x20a1, 0x020b,
+	0x1078, 0x67c2, 0x20a3, 0x0100, 0x20a3, 0x0000, 0x7828, 0xa005,
+	0x0040, 0x6665, 0x20a2, 0x0078, 0x6667, 0x20a3, 0x0003, 0x7810,
+	0x20a2, 0x60c3, 0x0008, 0x1078, 0x6dfb, 0x007c, 0x0d7e, 0x20a1,
+	0x020b, 0x1078, 0x67c2, 0x20a3, 0x0210, 0x20a3, 0x0014, 0x20a3,
+	0x0800, 0x7818, 0x2068, 0x6894, 0xa086, 0x0014, 0x00c0, 0x6694,
+	0x6998, 0xa184, 0xc000, 0x00c0, 0x6690, 0xd1ec, 0x0040, 0x668c,
+	0x20a3, 0x2100, 0x0078, 0x6696, 0x20a3, 0x0100, 0x0078, 0x6696,
+	0x20a3, 0x0400, 0x0078, 0x6696, 0x20a3, 0x0700, 0xa006, 0x20a2,
+	0x20a2, 0x20a2, 0x20a2, 0x20a2, 0x0f7e, 0x2079, 0xa652, 0x7904,
+	0x0f7f, 0xd1ac, 0x00c0, 0x66a6, 0xa085, 0x0020, 0xd1a4, 0x0040,
+	0x66ab, 0xa085, 0x0010, 0x2009, 0xa674, 0x210c, 0xd184, 0x0040,
+	0x66b5, 0x699c, 0xd18c, 0x0040, 0x66b7, 0xa085, 0x0002, 0x027e,
+	0x2009, 0xa672, 0x210c, 0xd1e4, 0x0040, 0x66c5, 0xc0c5, 0xa094,
+	0x0030, 0xa296, 0x0010, 0x0040, 0x66cf, 0xd1ec, 0x0040, 0x66cf,
+	0xa094, 0x0030, 0xa296, 0x0010, 0x0040, 0x66cf, 0xc0bd, 0x027f,
+	0x20a2, 0x20a2, 0x20a2, 0x60c3, 0x0014, 0x1078, 0x6dfb, 0x0d7f,
+	0x007c, 0x20a1, 0x020b, 0x1078, 0x67c2, 0x20a3, 0x0210, 0x20a3,
+	0x0014, 0x20a3, 0x0000, 0x20a3, 0x0100, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x60c3, 0x0014, 0x1078,
+	0x6dfb, 0x007c, 0x20a1, 0x020b, 0x1078, 0x67c2, 0x20a3, 0x0200,
+	0x0078, 0x64c8, 0x20a1, 0x020b, 0x1078, 0x67c2, 0x20a3, 0x0100,
+	0x20a3, 0x0000, 0x20a3, 0x0003, 0x20a3, 0x2a00, 0x60c3, 0x0008,
+	0x1078, 0x6dfb, 0x007c, 0x20e1, 0x9080, 0x20e1, 0x4000, 0x20a1,
+	0x020b, 0x1078, 0x67c2, 0x20a3, 0x0100, 0x20a3, 0x0000, 0x20a3,
+	0x000b, 0x20a3, 0x0000, 0x60c3, 0x0008, 0x1078, 0x6dfb, 0x007c,
+	0x027e, 0x037e, 0x047e, 0x2019, 0x3200, 0x2021, 0x0800, 0x0078,
+	0x6738, 0x027e, 0x037e, 0x047e, 0x2019, 0x2200, 0x2021, 0x0100,
+	0x20e1, 0x9080, 0x20e1, 0x4000, 0x7818, 0xa080, 0x0028, 0x2014,
+	0xa286, 0x007e, 0x00c0, 0x674b, 0xa385, 0x00ff, 0x20a2, 0x20a3,
+	0xfffe, 0x0078, 0x6780, 0xa286, 0x007f, 0x00c0, 0x6757, 0x0d7e,
+	0xa385, 0x00ff, 0x20a2, 0x20a3, 0xfffd, 0x0078, 0x676e, 0xd2bc,
+	0x0040, 0x6776, 0xa286, 0x0080, 0x0d7e, 0x00c0, 0x6766, 0xa385,
+	0x00ff, 0x20a2, 0x20a3, 0xfffc, 0x0078, 0x676e, 0xa2e8, 0xa735,
+	0x2d6c, 0x6810, 0xa305, 0x20a2, 0x6814, 0x20a2, 0x2069, 0xa61b,
+	0x2da6, 0x8d68, 0x2da6, 0x0d7f, 0x0078, 0x6784, 0x0d7e, 0xa2e8,
+	0xa735, 0x2d6c, 0x6810, 0xa305, 0x20a2, 0x6814, 0x20a2, 0x0d7f,
+	0x20a3, 0x0000, 0x6230, 0x22a2, 0xa485, 0x0029, 0x20a2, 0x047f,
+	0x037f, 0x20a3, 0x0000, 0x1078, 0x6dea, 0x22a2, 0x20a3, 0x0000,
+	0x2fa2, 0x20a3, 0xffff, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x027f,
+	0x007c, 0x027e, 0x20e1, 0x9080, 0x20e1, 0x4000, 0x20a3, 0x02ff,
+	0x2011, 0xfffc, 0x22a2, 0x0d7e, 0x2069, 0xa61b, 0x2da6, 0x8d68,
+	0x2da6, 0x0d7f, 0x20a3, 0x2029, 0x20a3, 0x0000, 0x0078, 0x678b,
+	0x20a3, 0x0100, 0x20a3, 0x0000, 0x20a3, 0xfc02, 0x20a3, 0x0000,
+	0x007c, 0x027e, 0x037e, 0x047e, 0x2019, 0x3300, 0x2021, 0x0800,
+	0x0078, 0x67c9, 0x027e, 0x037e, 0x047e, 0x2019, 0x2300, 0x2021,
+	0x0100, 0x20e1, 0x9080, 0x20e1, 0x4000, 0x7818, 0xa080, 0x0028,
+	0x2004, 0xa092, 0x007e, 0x0048, 0x67e6, 0x0d7e, 0xa0e8, 0xa735,
+	0x2d6c, 0x6810, 0xa305, 0x20a2, 0x6814, 0x20a2, 0x2069, 0xa61b,
+	0x2da6, 0x8d68, 0x2da6, 0x0d7f, 0x0078, 0x67f4, 0x0d7e, 0xa0e8,
+	0xa735, 0x2d6c, 0x6810, 0xa305, 0x20a2, 0x6814, 0x20a2, 0x0d7f,
+	0x20a3, 0x0000, 0x6230, 0x22a2, 0xa485, 0x0098, 0x20a2, 0x20a3,
+	0x0000, 0x047f, 0x037f, 0x1078, 0x6dea, 0x22a2, 0x20a3, 0x0000,
+	0x7a08, 0x22a2, 0x2fa2, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x027f,
+	0x007c, 0x0c7e, 0x0f7e, 0x6004, 0xa08a, 0x0085, 0x1048, 0x1332,
+	0xa08a, 0x008c, 0x10c8, 0x1332, 0x6118, 0x2178, 0x79a0, 0xd1bc,
+	0x0040, 0x6827, 0x7900, 0xd1f4, 0x0040, 0x6823, 0x7914, 0xa18c,
+	0x00ff, 0x0078, 0x682c, 0x2009, 0x0000, 0x0078, 0x682c, 0xa1f8,
+	0x29c0, 0x2f0c, 0xa18c, 0x00ff, 0x2c78, 0x2061, 0x0100, 0x619a,
+	0xa082, 0x0085, 0x1079, 0x6837, 0x0f7f, 0x0c7f, 0x007c, 0x6840,
+	0x684b, 0x6866, 0x683e, 0x683e, 0x683e, 0x6840, 0x1078, 0x1332,
+	0x147e, 0x20a1, 0x020b, 0x1078, 0x6879, 0x60c3, 0x0000, 0x1078,
+	0x6dfb, 0x147f, 0x007c, 0x147e, 0x20a1, 0x020b, 0x1078, 0x68ad,
+	0x20a3, 0x0000, 0x20a3, 0x0000, 0x7808, 0x20a2, 0x7810, 0x20a2,
+	0x20a3, 0x0000, 0x20a3, 0xffff, 0x20a3, 0x0000, 0x20a3, 0x0000,
+	0x60c3, 0x000c, 0x1078, 0x6dfb, 0x147f, 0x007c, 0x147e, 0x20a1,
+	0x020b, 0x1078, 0x68ee, 0x20a3, 0x0003, 0x20a3, 0x0300, 0x20a3,
+	0x0000, 0x20a3, 0x0000, 0x60c3, 0x0004, 0x1078, 0x6dfb, 0x147f,
+	0x007c, 0x027e, 0x20e1, 0x9080, 0x20e1, 0x4000, 0x7818, 0xa080,
+	0x0028, 0x2004, 0xa092, 0x007e, 0x0048, 0x6898, 0x0d7e, 0xa0e8,
+	0xa735, 0x2d6c, 0x6810, 0xa085, 0x8100, 0x20a2, 0x6814, 0x20a2,
+	0x2069, 0xa61b, 0x2da6, 0x8d68, 0x2da6, 0x0d7f, 0x0078, 0x68a7,
+	0x0d7e, 0xa0e8, 0xa735, 0x2d6c, 0x6810, 0xa085, 0x8100, 0x20a2,
+	0x6814, 0x20a2, 0x0d7f, 0x20a3, 0x0000, 0x6230, 0x22a2, 0x20a3,
+	0x0009, 0x20a3, 0x0000, 0x0078, 0x678b, 0x027e, 0x20e1, 0x9080,
+	0x20e1, 0x4000, 0x7818, 0xa080, 0x0028, 0x2004, 0xa092, 0x007e,
+	0x0048, 0x68cc, 0x0d7e, 0xa0e8, 0xa735, 0x2d6c, 0x6810, 0xa085,
+	0x8400, 0x20a2, 0x6814, 0x20a2, 0x2069, 0xa61b, 0x2da6, 0x8d68,
+	0x2da6, 0x0d7f, 0x0078, 0x68db, 0x0d7e, 0xa0e8, 0xa735, 0x2d6c,
+	0x6810, 0xa085, 0x8400, 0x20a2, 0x6814, 0x20a2, 0x0d7f, 0x20a3,
+	0x0000, 0x6230, 0x22a2, 0x20a3, 0x0099, 0x20a3, 0x0000, 0x1078,
+	0x6dea, 0x22a2, 0x20a3, 0x0000, 0x7a08, 0x22a2, 0x7a10, 0x22a2,
+	0x20a3, 0x0000, 0x20a3, 0x0000, 0x027f, 0x007c, 0x027e, 0x20e1,
+	0x9080, 0x20e1, 0x4000, 0x7818, 0xa080, 0x0028, 0x2004, 0xa092,
+	0x007e, 0x0048, 0x690d, 0x0d7e, 0xa0e8, 0xa735, 0x2d6c, 0x6810,
+	0xa085, 0x8500, 0x20a2, 0x6814, 0x20a2, 0x2069, 0xa61b, 0x2da6,
+	0x8d68, 0x2da6, 0x0d7f, 0x0078, 0x691c, 0x0d7e, 0xa0e8, 0xa735,
+	0x2d6c, 0x6810, 0xa085, 0x8500, 0x20a2, 0x6814, 0x20a2, 0x0d7f,
+	0x20a3, 0x0000, 0x6230, 0x22a2, 0x20a3, 0x0099, 0x20a3, 0x0000,
+	0x0078, 0x68df, 0x0c7e, 0x0f7e, 0x2c78, 0x7804, 0xa08a, 0x0040,
+	0x1048, 0x1332, 0xa08a, 0x0053, 0x10c8, 0x1332, 0x7918, 0x2160,
+	0x61a0, 0xd1bc, 0x0040, 0x6941, 0x6100, 0xd1f4, 0x0040, 0x693d,
+	0x6114, 0xa18c, 0x00ff, 0x0078, 0x6946, 0x2009, 0x0000, 0x0078,
+	0x6946, 0xa1e0, 0x29c0, 0x2c0c, 0xa18c, 0x00ff, 0x2061, 0x0100,
+	0x619a, 0xa082, 0x0040, 0x1079, 0x6950, 0x0f7f, 0x0c7f, 0x007c,
+	0x6965, 0x6a73, 0x6a14, 0x6c27, 0x6963, 0x6963, 0x6963, 0x6963,
+	0x6963, 0x6963, 0x6963, 0x714c, 0x715d, 0x716e, 0x717f, 0x6963,
+	0x767e, 0x6963, 0x713b, 0x1078, 0x1332, 0x0d7e, 0x157e, 0x147e,
+	0x780b, 0xffff, 0x20a1, 0x020b, 0x1078, 0x69d0, 0x7910, 0x2168,
+	0x6948, 0x7922, 0x21a2, 0xa016, 0x22a2, 0x22a2, 0x22a2, 0x694c,
+	0xa184, 0x000f, 0x00c0, 0x6980, 0x2001, 0x0005, 0x0078, 0x698a,
+	0xd184, 0x0040, 0x6987, 0x2001, 0x0004, 0x0078, 0x698a, 0xa084,
+	0x0006, 0x8004, 0x017e, 0x2008, 0x7830, 0xa084, 0x00ff, 0x8007,
+	0xa105, 0x017f, 0x20a2, 0xd1ac, 0x0040, 0x699a, 0x20a3, 0x0002,
+	0x0078, 0x69a6, 0xd1b4, 0x0040, 0x69a1, 0x20a3, 0x0001, 0x0078,
+	0x69a6, 0x20a3, 0x0000, 0x2230, 0x0078, 0x69a8, 0x6a80, 0x6e7c,
+	0x20a9, 0x0008, 0xad80, 0x0017, 0x200c, 0x810f, 0x21a2, 0x8000,
+	0x00f0, 0x69ac, 0x22a2, 0x26a2, 0x60c3, 0x0020, 0x20e1, 0x9080,
+	0x6014, 0xa084, 0x0004, 0xa085, 0x0009, 0x6016, 0x2001, 0xa8cd,
+	0x2003, 0x07d0, 0x2001, 0xa8cc, 0x2003, 0x0009, 0x2001, 0xa8d2,
+	0x2003, 0x0002, 0x1078, 0x158c, 0x147f, 0x157f, 0x0d7f, 0x007c,
+	0x20e1, 0x9080, 0x20e1, 0x4000, 0x7a18, 0xa280, 0x0023, 0x2014,
+	0x8210, 0xa294, 0x00ff, 0x2202, 0x8217, 0x7818, 0xa080, 0x0028,
+	0x2004, 0xd0bc, 0x0040, 0x69f6, 0x0d7e, 0xa0e8, 0xa735, 0x2d6c,
+	0x6810, 0xa085, 0x0600, 0x20a2, 0x6814, 0x20a2, 0x2069, 0xa61b,
+	0x2da6, 0x8d68, 0x2da6, 0x0d7f, 0x0078, 0x6a05, 0x0d7e, 0xa0e8,
+	0xa735, 0x2d6c, 0x6810, 0xa085, 0x0600, 0x20a2, 0x6814, 0x20a2,
+	0x0d7f, 0x20a3, 0x0000, 0x6130, 0x21a2, 0x20a3, 0x0829, 0x20a3,
+	0x0000, 0x22a2, 0x20a3, 0x0000, 0x2fa2, 0x20a3, 0xffff, 0x20a3,
+	0x0000, 0x20a3, 0x0000, 0x007c, 0x0d7e, 0x157e, 0x137e, 0x147e,
+	0x20a1, 0x020b, 0x1078, 0x6a34, 0x7810, 0x2068, 0x6860, 0x20a2,
+	0x685c, 0x20a2, 0x6880, 0x20a2, 0x687c, 0x20a2, 0xa006, 0x20a2,
+	0x20a2, 0x20a2, 0x20a2, 0x60c3, 0x000c, 0x1078, 0x6dfb, 0x147f,
+	0x137f, 0x157f, 0x0d7f, 0x007c, 0x027e, 0x20e1, 0x9080, 0x20e1,
+	0x4000, 0x7818, 0xa080, 0x0028, 0x2004, 0xd0bc, 0x0040, 0x6a52,
+	0x0d7e, 0xa0e8, 0xa735, 0x2d6c, 0x6810, 0xa085, 0x0500, 0x20a2,
+	0x6814, 0x20a2, 0x2069, 0xa61b, 0x2da6, 0x8d68, 0x2da6, 0x0d7f,
+	0x0078, 0x6a61, 0x0d7e, 0xa0e8, 0xa735, 0x2d6c, 0x6810, 0xa085,
+	0x0500, 0x20a2, 0x6814, 0x20a2, 0x0d7f, 0x20a3, 0x0000, 0x6230,
+	0x22a2, 0x20a3, 0x0889, 0x20a3, 0x0000, 0x1078, 0x6dea, 0x22a2,
+	0x20a3, 0x0000, 0x7a08, 0x22a2, 0x2fa2, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x027f, 0x007c, 0x0d7e, 0x157e, 0x137e, 0x147e, 0x7810,
+	0xa0ec, 0xf000, 0x0040, 0x6a8b, 0xa06d, 0x1078, 0x495f, 0x0040,
+	0x6a8b, 0x684c, 0xa084, 0x2020, 0xa086, 0x2020, 0x00c0, 0x6a8b,
+	0x7824, 0xc0cd, 0x7826, 0x20a1, 0x020b, 0x1078, 0x6be0, 0xa016,
+	0x22a2, 0x22a2, 0x22a2, 0x22a2, 0x22a2, 0x7810, 0xa084, 0xf000,
+	0x00c0, 0x6aa2, 0x7810, 0xa084, 0x0700, 0x8007, 0x1079, 0x6aaa,
+	0x0078, 0x6aa5, 0xa006, 0x1079, 0x6aaa, 0x147f, 0x137f, 0x157f,
+	0x0d7f, 0x007c, 0x6ab4, 0x6b4c, 0x6b57, 0x6b81, 0x6b95, 0x6bb1,
+	0x6bbc, 0x6ab2, 0x1078, 0x1332, 0x017e, 0x037e, 0x694c, 0xa18c,
+	0x0003, 0x0040, 0x6abf, 0xa186, 0x0003, 0x00c0, 0x6ace, 0x6b78,
+	0x7824, 0xd0cc, 0x0040, 0x6ac5, 0xc3e5, 0x23a2, 0x6868, 0x20a2,
+	0x6864, 0x20a2, 0x037f, 0x017f, 0x0078, 0x6b8c, 0xa186, 0x0001,
+	0x10c0, 0x1332, 0x6b78, 0x7824, 0xd0cc, 0x0040, 0x6ad8, 0xc3e5,
+	0x23a2, 0x6868, 0x20a2, 0x6864, 0x20a2, 0x22a2, 0x6874, 0x20a2,
+	0x22a2, 0x687c, 0x20a2, 0x2009, 0x0018, 0xa384, 0x0300, 0x0040,
+	0x6b46, 0xd3c4, 0x0040, 0x6aee, 0x687c, 0xa108, 0xd3cc, 0x0040,
+	0x6af3, 0x6874, 0xa108, 0x157e, 0x20a9, 0x000d, 0xad80, 0x0020,
+	0x201c, 0x831f, 0x23a2, 0x8000, 0x00f0, 0x6af8, 0x157f, 0x22a2,
+	0x22a2, 0x22a2, 0xa184, 0x0003, 0x0040, 0x6b46, 0x20a1, 0x020b,
+	0x20e1, 0x9080, 0x20e1, 0x4000, 0x007e, 0x7818, 0xa080, 0x0028,
+	0x2004, 0xd0bc, 0x0040, 0x6b26, 0x0d7e, 0xa0e8, 0xa735, 0x2d6c,
+	0x6810, 0xa085, 0x0700, 0x20a2, 0x6814, 0x20a2, 0x2069, 0xa61b,
+	0x2da6, 0x8d68, 0x2da6, 0x0d7f, 0x0078, 0x6b35, 0x0d7e, 0xa0e8,
+	0xa735, 0x2d6c, 0x6810, 0xa085, 0x0700, 0x20a2, 0x6814, 0x20a2,
+	0x0d7f, 0x20a3, 0x0000, 0x6230, 0x22a2, 0x007f, 0x7b24, 0xd3cc,
+	0x0040, 0x6b3e, 0x20a3, 0x0889, 0x0078, 0x6b40, 0x20a3, 0x0898,
+	0x20a2, 0x1078, 0x6dea, 0x22a2, 0x20a3, 0x0000, 0x61c2, 0x037f,
+	0x017f, 0x1078, 0x6dfb, 0x007c, 0x2011, 0x0008, 0x7824, 0xd0cc,
+	0x0040, 0x6b53, 0xc2e5, 0x22a2, 0xa016, 0x0078, 0x6b8a, 0x2011,
+	0x0302, 0x7824, 0xd0cc, 0x0040, 0x6b5e, 0xc2e5, 0x22a2, 0xa016,
+	0x22a2, 0x22a2, 0x22a2, 0x20a3, 0x0012, 0x22a2, 0x20a3, 0x0008,
+	0x22a2, 0x22a2, 0x22a2, 0x22a2, 0x20a3, 0x7000, 0x20a3, 0x0500,
+	0x22a2, 0x20a3, 0x000a, 0x22a2, 0x22a2, 0x20a3, 0x2500, 0x22a2,
+	0x22a2, 0x22a2, 0x22a2, 0x22a2, 0x60c3, 0x0032, 0x1078, 0x6dfb,
+	0x007c, 0x2011, 0x0028, 0x7824, 0xd0cc, 0x0040, 0x6b88, 0xc2e5,
+	0x22a2, 0xa016, 0x22a2, 0x22a2, 0x22a2, 0x22a2, 0x22a2, 0x22a2,
+	0x60c3, 0x0018, 0x1078, 0x6dfb, 0x007c, 0x2011, 0x0100, 0x7824,
+	0xd0cc, 0x0040, 0x6b9c, 0xc2e5, 0x22a2, 0xa016, 0x22a2, 0x22a2,
+	0x22a2, 0x22a2, 0x22a2, 0x20a3, 0x0008, 0x22a2, 0x7834, 0xa084,
+	0x00ff, 0x20a2, 0x22a2, 0x22a2, 0x60c3, 0x0020, 0x1078, 0x6dfb,
+	0x007c, 0x2011, 0x0008, 0x7824, 0xd0cc, 0x0040, 0x6bb8, 0xc2e5,
+	0x22a2, 0xa016, 0x0078, 0x6b8a, 0x037e, 0x7b10, 0xa384, 0xff00,
+	0x7812, 0xa384, 0x00ff, 0x8001, 0x00c0, 0x6bcf, 0x7824, 0xd0cc,
+	0x0040, 0x6bcb, 0xc2e5, 0x22a2, 0x037f, 0x0078, 0x6b8a, 0x047e,
+	0x2021, 0x0800, 0x007e, 0x7824, 0xd0cc, 0x007f, 0x0040, 0x6bd9,
+	0xc4e5, 0x24a2, 0x047f, 0x22a2, 0x20a2, 0x037f, 0x0078, 0x6b8c,
+	0x027e, 0x20e1, 0x9080, 0x20e1, 0x4000, 0x7818, 0xa080, 0x0028,
+	0x2004, 0xd0bc, 0x0040, 0x6bfe, 0x0d7e, 0xa0e8, 0xa735, 0x2d6c,
+	0x6810, 0xa085, 0x0700, 0x20a2, 0x6814, 0x20a2, 0x2069, 0xa61b,
+	0x2da6, 0x8d68, 0x2da6, 0x0d7f, 0x0078, 0x6c0d, 0x0d7e, 0xa0e8,
+	0xa735, 0x2d6c, 0x6810, 0xa085, 0x0700, 0x20a2, 0x6814, 0x20a2,
+	0x0d7f, 0x20a3, 0x0000, 0x6230, 0x22a2, 0x7824, 0xd0cc, 0x0040,
+	0x6c15, 0x20a3, 0x0889, 0x0078, 0x6c17, 0x20a3, 0x0898, 0x20a3,
+	0x0000, 0x1078, 0x6dea, 0x22a2, 0x20a3, 0x0000, 0x7a08, 0x22a2,
+	0x2fa2, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x027f, 0x007c, 0x0d7e,
+	0x157e, 0x137e, 0x147e, 0x017e, 0x037e, 0x7810, 0xa084, 0x0700,
+	0x8007, 0x1079, 0x6c3a, 0x037f, 0x017f, 0x147f, 0x137f, 0x157f,
+	0x0d7f, 0x007c, 0x6c42, 0x6c42, 0x6c44, 0x6c42, 0x6c42, 0x6c42,
+	0x6c69, 0x6c42, 0x1078, 0x1332, 0x7910, 0xa18c, 0xf8ff, 0xa18d,
+	0x0600, 0x7912, 0x20a1, 0x020b, 0x2009, 0x0003, 0x1078, 0x6c73,
+	0x0d7e, 0x2069, 0xa652, 0x6804, 0xd0bc, 0x0040, 0x6c5e, 0x682c,
+	0xa084, 0x00ff, 0x8007, 0x20a2, 0x0078, 0x6c60, 0x20a3, 0x3f00,
+	0x0d7f, 0x22a2, 0x22a2, 0x22a2, 0x60c3, 0x0001, 0x1078, 0x6dfb,
+	0x007c, 0x20a1, 0x020b, 0x2009, 0x0003, 0x1078, 0x6c73, 0x20a3,
+	0x7f00, 0x0078, 0x6c61, 0x027e, 0x20e1, 0x9080, 0x20e1, 0x4000,
+	0x7818, 0xa080, 0x0028, 0x2004, 0xd0bc, 0x0040, 0x6c91, 0x0d7e,
+	0xa0e8, 0xa735, 0x2d6c, 0x6810, 0xa085, 0x0100, 0x20a2, 0x6814,
+	0x20a2, 0x2069, 0xa61b, 0x2da6, 0x8d68, 0x2da6, 0x0d7f, 0x0078,
+	0x6ca0, 0x0d7e, 0xa0e8, 0xa735, 0x2d6c, 0x6810, 0xa085, 0x0100,
+	0x20a2, 0x6814, 0x20a2, 0x0d7f, 0x20a3, 0x0000, 0x6230, 0x22a2,
+	0x20a3, 0x0888, 0xa18d, 0x0008, 0x21a2, 0x1078, 0x6dea, 0x22a2,
+	0x20a3, 0x0000, 0x7a08, 0x22a2, 0x2fa2, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x027f, 0x007c, 0x0e7e, 0x0d7e, 0x0c7e, 0x057e, 0x047e,
+	0x037e, 0x2061, 0x0100, 0x2071, 0xa600, 0x6130, 0x7818, 0x2068,
+	0x68a0, 0x2028, 0xd0bc, 0x00c0, 0x6cca, 0x6910, 0x6a14, 0x6430,
+	0x0078, 0x6cce, 0x6910, 0x6a14, 0x736c, 0x7470, 0x781c, 0xa086,
+	0x0006, 0x0040, 0x6d2d, 0xd5bc, 0x0040, 0x6cde, 0xa185, 0x0100,
+	0x6062, 0x6266, 0x636a, 0x646e, 0x0078, 0x6ce5, 0xa185, 0x0100,
+	0x6062, 0x6266, 0x606b, 0x0000, 0x646e, 0x6073, 0x0809, 0x6077,
+	0x0008, 0x688c, 0x8000, 0xa084, 0x00ff, 0x688e, 0x8007, 0x607a,
+	0x607f, 0x0000, 0x2f00, 0x6082, 0x7808, 0x6086, 0x7810, 0x2070,
+	0x7014, 0x608a, 0x7010, 0x608e, 0x700c, 0x60c6, 0x7008, 0x60ca,
+	0x686c, 0x60ce, 0x60ab, 0x0036, 0x60af, 0x95d5, 0x60d7, 0x0000,
+	0xa582, 0x0080, 0x0048, 0x6d17, 0x6a00, 0xd2f4, 0x0040, 0x6d15,
+	0x6a14, 0xa294, 0x00ff, 0x0078, 0x6d17, 0x2011, 0x0000, 0x629e,
+	0x6017, 0x0016, 0x2009, 0x07d0, 0x60c4, 0xa084, 0xfff0, 0xa005,
+	0x0040, 0x6d24, 0x2009, 0x1b58, 0x1078, 0x5ad0, 0x037f, 0x047f,
+	0x057f, 0x0c7f, 0x0d7f, 0x0e7f, 0x007c, 0x7810, 0x2070, 0x704c,
+	0xa084, 0x0003, 0xa086, 0x0002, 0x0040, 0x6d85, 0xd5bc, 0x0040,
+	0x6d41, 0xa185, 0x0100, 0x6062, 0x6266, 0x636a, 0x646e, 0x0078,
+	0x6d48, 0xa185, 0x0100, 0x6062, 0x6266, 0x606b, 0x0000, 0x646e,
+	0x6073, 0x0880, 0x6077, 0x0008, 0x688c, 0x8000, 0xa084, 0x00ff,
+	0x688e, 0x8007, 0x607a, 0x607f, 0x0000, 0x2f00, 0x6086, 0x7808,
+	0x6082, 0x7060, 0x608a, 0x705c, 0x608e, 0x7080, 0x60c6, 0x707c,
+	0x60ca, 0x707c, 0x792c, 0xa108, 0x792e, 0x7080, 0x7928, 0xa109,
+	0x792a, 0x686c, 0x60ce, 0x60ab, 0x0036, 0x60af, 0x95d5, 0x60d7,
+	0x0000, 0xa582, 0x0080, 0x0048, 0x6d80, 0x6a00, 0xd2f4, 0x0040,
+	0x6d7e, 0x6a14, 0xa294, 0x00ff, 0x0078, 0x6d80, 0x2011, 0x0000,
+	0x629e, 0x6017, 0x0012, 0x0078, 0x6d1a, 0xd5bc, 0x0040, 0x6d90,
+	0xa185, 0x0700, 0x6062, 0x6266, 0x636a, 0x646e, 0x0078, 0x6d97,
+	0xa185, 0x0700, 0x6062, 0x6266, 0x606b, 0x0000, 0x646e, 0x1078,
+	0x495f, 0x0040, 0x6dad, 0x0d7e, 0x7810, 0xa06d, 0x684c, 0x0d7f,
+	0xa084, 0x2020, 0xa086, 0x2020, 0x00c0, 0x6dad, 0x7824, 0xc0cd,
+	0x7826, 0x6073, 0x0889, 0x0078, 0x6daf, 0x6073, 0x0898, 0x6077,
+	0x0000, 0x688c, 0x8000, 0xa084, 0x00ff, 0x688e, 0x8007, 0x607a,
+	0x607f, 0x0000, 0x2f00, 0x6086, 0x7808, 0x6082, 0x7014, 0x608a,
+	0x7010, 0x608e, 0x700c, 0x60c6, 0x7008, 0x60ca, 0x686c, 0x60ce,
+	0x60ab, 0x0036, 0x60af, 0x95d5, 0x60d7, 0x0000, 0xa582, 0x0080,
+	0x0048, 0x6ddd, 0x6a00, 0xd2f4, 0x0040, 0x6ddb, 0x6a14, 0xa294,
+	0x00ff, 0x0078, 0x6ddd, 0x2011, 0x0000, 0x629e, 0x7824, 0xd0cc,
+	0x0040, 0x6de6, 0x6017, 0x0016, 0x0078, 0x6d1a, 0x6017, 0x0012,
+	0x0078, 0x6d1a, 0x7a18, 0xa280, 0x0023, 0x2014, 0x8210, 0xa294,
+	0x00ff, 0x2202, 0x8217, 0x007c, 0x0d7e, 0x2069, 0xa8b1, 0x6843,
+	0x0001, 0x0d7f, 0x007c, 0x20e1, 0x9080, 0x60a3, 0x0056, 0x60a7,
+	0x9575, 0x1078, 0x6e06, 0x1078, 0x5ac0, 0x007c, 0x007e, 0x6014,
+	0xa084, 0x0004, 0xa085, 0x0009, 0x6016, 0x007f, 0x007c, 0x007e,
+	0x0c7e, 0x2061, 0x0100, 0x6014, 0xa084, 0x0004, 0xa085, 0x0008,
+	0x6016, 0x0c7f, 0x007f, 0x007c, 0x0c7e, 0x0d7e, 0x017e, 0x027e,
+	0x2061, 0x0100, 0x2069, 0x0140, 0x6904, 0xa194, 0x4000, 0x0040,
+	0x6e59, 0x1078, 0x6e0f, 0x6803, 0x1000, 0x6803, 0x0000, 0x0c7e,
+	0x2061, 0xa8b1, 0x6128, 0xa192, 0x00c8, 0x00c8, 0x6e44, 0x8108,
+	0x612a, 0x6124, 0x0c7f, 0x81ff, 0x0040, 0x6e54, 0x1078, 0x5ac0,
+	0x1078, 0x6e06, 0x0078, 0x6e54, 0x6124, 0xa1e5, 0x0000, 0x0040,
+	0x6e51, 0x1078, 0xa5c4, 0x1078, 0x5acb, 0x2009, 0x0014, 0x1078,
+	0x775c, 0x0c7f, 0x0078, 0x6e54, 0x027f, 0x017f, 0x0d7f, 0x0c7f,
+	0x007c, 0x2001, 0xa8cd, 0x2004, 0xa005, 0x00c0, 0x6e54, 0x0c7e,
+	0x2061, 0xa8b1, 0x6128, 0xa192, 0x0003, 0x00c8, 0x6e44, 0x8108,
+	0x612a, 0x0c7f, 0x1078, 0x5ac0, 0x1078, 0x4224, 0x0078, 0x6e54,
+	0x0c7e, 0x0d7e, 0x0e7e, 0x017e, 0x027e, 0x1078, 0x5ad8, 0x2071,
+	0xa8b1, 0x713c, 0x81ff, 0x0040, 0x6e9a, 0x2061, 0x0100, 0x2069,
+	0x0140, 0x6904, 0xa194, 0x4000, 0x0040, 0x6ea0, 0x6803, 0x1000,
+	0x6803, 0x0000, 0x037e, 0x2019, 0x0001, 0x1078, 0x7058, 0x037f,
+	0x713c, 0x2160, 0x1078, 0xa5c4, 0x2009, 0x004a, 0x1078, 0x775c,
+	0x0078, 0x6e9a, 0x027f, 0x017f, 0x0e7f, 0x0d7f, 0x0c7f, 0x007c,
+	0x0078, 0x6e8a, 0x0e7e, 0x2071, 0xa8b1, 0x7048, 0xd084, 0x0040,
+	0x6ebc, 0x713c, 0x81ff, 0x0040, 0x6ebc, 0x2071, 0x0100, 0xa188,
+	0x0007, 0x210c, 0xa18e, 0x0006, 0x00c0, 0x6eba, 0x7017, 0x0012,
+	0x0078, 0x6ebc, 0x7017, 0x0016, 0x0e7f, 0x007c, 0x0e7e, 0x0d7e,
+	0x0c7e, 0x067e, 0x057e, 0x047e, 0x007e, 0x127e, 0x2091, 0x8000,
+	0x6018, 0x2068, 0x6ca0, 0x2071, 0xa8b1, 0x7018, 0x2068, 0x8dff,
+	0x0040, 0x6ee6, 0x68a0, 0xa406, 0x0040, 0x6eda, 0x6854, 0x2068,
+	0x0078, 0x6ecf, 0x6010, 0x2060, 0x643c, 0x6540, 0x6648, 0x2d60,
+	0x1078, 0x4736, 0x0040, 0x6ee6, 0xa085, 0x0001, 0x127f, 0x007f,
+	0x047f, 0x057f, 0x067f, 0x0c7f, 0x0d7f, 0x0e7f, 0x007c, 0x20a1,
+	0x020b, 0x1078, 0x6731, 0x20a3, 0x1200, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x781c, 0xa086, 0x0004, 0x00c0, 0x6f01, 0x6098, 0x0078,
+	0x6f02, 0x6030, 0x20a2, 0x7834, 0x20a2, 0x7838, 0x20a2, 0x20a9,
+	0x0010, 0xa006, 0x20a2, 0x00f0, 0x6f0a, 0x20a2, 0x20a2, 0x60c3,
+	0x002c, 0x1078, 0x6dfb, 0x007c, 0x157e, 0x147e, 0x20a1, 0x020b,
+	0x1078, 0x6731, 0x20a3, 0x0f00, 0x20a3, 0x0000, 0x20a3, 0x0000,
+	0x7808, 0x20a2, 0x60c3, 0x0008, 0x1078, 0x6dfb, 0x147f, 0x157f,
+	0x007c, 0x157e, 0x147e, 0x20a1, 0x020b, 0x1078, 0x67c2, 0x20a3,
+	0x0200, 0x20a3, 0x0000, 0x20a9, 0x0006, 0x2011, 0xa640, 0x2019,
+	0xa641, 0x23a6, 0x22a6, 0xa398, 0x0002, 0xa290, 0x0002, 0x00f0,
+	0x6f39, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x60c3, 0x001c, 0x1078,
+	0x6dfb, 0x147f, 0x157f, 0x007c, 0x157e, 0x147e, 0x017e, 0x027e,
+	0x20a1, 0x020b, 0x1078, 0x6799, 0x1078, 0x67b0, 0x7810, 0xa080,
+	0x0000, 0x2004, 0xa080, 0x0015, 0x2098, 0x7808, 0xa088, 0x0002,
+	0x21a8, 0x53a6, 0xa080, 0x0004, 0x8003, 0x60c2, 0x1078, 0x6dfb,
+	0x027f, 0x017f, 0x147f, 0x157f, 0x007c, 0x157e, 0x147e, 0x20a1,
+	0x020b, 0x1078, 0x6731, 0x20a3, 0x6200, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x7808, 0x20a2, 0x60c3, 0x0008, 0x1078, 0x6dfb, 0x147f,
+	0x157f, 0x007c, 0x157e, 0x147e, 0x017e, 0x027e, 0x20a1, 0x020b,
+	0x1078, 0x6731, 0x7810, 0xa080, 0x0000, 0x2004, 0xa080, 0x0017,
+	0x2098, 0x7808, 0xa088, 0x0002, 0x21a8, 0x53a6, 0x8003, 0x60c2,
+	0x1078, 0x6dfb, 0x027f, 0x017f, 0x147f, 0x157f, 0x007c, 0x0e7e,
+	0x0c7e, 0x007e, 0x127e, 0x2091, 0x8000, 0x2071, 0xa8b1, 0x700c,
+	0x2060, 0x8cff, 0x0040, 0x6fbb, 0x1078, 0x8f00, 0x00c0, 0x6fb2,
+	0x1078, 0x7c83, 0x600c, 0x007e, 0x1078, 0x772d, 0x1078, 0x7233,
+	0x0c7f, 0x0078, 0x6fa9, 0x700f, 0x0000, 0x700b, 0x0000, 0x127f,
+	0x007f, 0x0c7f, 0x0e7f, 0x007c, 0x127e, 0x157e, 0x0f7e, 0x0e7e,
+	0x0d7e, 0x0c7e, 0x027e, 0x017e, 0x007e, 0x2091, 0x8000, 0x2069,
+	0x0100, 0x2079, 0x0140, 0x2071, 0xa8b1, 0x7024, 0x2060, 0x8cff,
+	0x0040, 0x7014, 0x1078, 0x6e0f, 0x68c3, 0x0000, 0x1078, 0x5acb,
+	0x2009, 0x0013, 0x1078, 0x775c, 0x20a9, 0x01f4, 0x6824, 0xd094,
+	0x0040, 0x6ff7, 0x6827, 0x0004, 0x7804, 0xa084, 0x4000, 0x0040,
+	0x7009, 0x7803, 0x1000, 0x7803, 0x0000, 0x0078, 0x7009, 0xd084,
+	0x0040, 0x6ffe, 0x6827, 0x0001, 0x0078, 0x7000, 0x00f0, 0x6fe6,
+	0x7804, 0xa084, 0x1000, 0x0040, 0x7009, 0x7803, 0x0100, 0x7803,
+	0x0000, 0x6824, 0x007f, 0x017f, 0x027f, 0x0c7f, 0x0d7f, 0x0e7f,
+	0x0f7f, 0x157f, 0x127f, 0x007c, 0x2001, 0xa600, 0x2004, 0xa096,
+	0x0001, 0x0040, 0x704e, 0xa096, 0x0004, 0x0040, 0x704e, 0x1078,
+	0x5acb, 0x6817, 0x0008, 0x68c3, 0x0000, 0x2011, 0x41dc, 0x1078,
+	0x5a45, 0x20a9, 0x01f4, 0x6824, 0xd094, 0x0040, 0x703c, 0x6827,
+	0x0004, 0x7804, 0xa084, 0x4000, 0x0040, 0x704e, 0x7803, 0x1000,
+	0x7803, 0x0000, 0x0078, 0x704e, 0xd084, 0x0040, 0x7043, 0x6827,
+	0x0001, 0x0078, 0x7045, 0x00f0, 0x702b, 0x7804, 0xa084, 0x1000,
+	0x0040, 0x704e, 0x7803, 0x0100, 0x7803, 0x0000, 0x007f, 0x017f,
+	0x027f, 0x0c7f, 0x0d7f, 0x0e7f, 0x0f7f, 0x157f, 0x127f, 0x007c,
+	0x127e, 0x157e, 0x0f7e, 0x0e7e, 0x0d7e, 0x0c7e, 0x027e, 0x017e,
+	0x007e, 0x2091, 0x8000, 0x2069, 0x0100, 0x2079, 0x0140, 0x2071,
+	0xa8b1, 0x703c, 0x2060, 0x8cff, 0x0040, 0x70d6, 0x68af, 0x95f5,
+	0x6817, 0x0010, 0x2009, 0x00fa, 0x8109, 0x00c0, 0x7074, 0x68c7,
+	0x0000, 0x68cb, 0x0008, 0x1078, 0x5ad8, 0x1078, 0x1f7e, 0x047e,
+	0x057e, 0x2009, 0x017f, 0x212c, 0x200b, 0x00a5, 0x2021, 0x0169,
+	0x2404, 0xa084, 0x000f, 0xa086, 0x0004, 0x00c0, 0x70a5, 0x68c7,
+	0x0000, 0x68cb, 0x0008, 0x0e7e, 0x0f7e, 0x2079, 0x0020, 0x2071,
+	0xa908, 0x6814, 0xa084, 0x0004, 0xa085, 0x0012, 0x6816, 0x7803,
+	0x0008, 0x7003, 0x0000, 0x0f7f, 0x0e7f, 0x250a, 0x057f, 0x047f,
+	0xa39d, 0x0000, 0x00c0, 0x70b0, 0x2009, 0x0049, 0x1078, 0x775c,
+	0x20a9, 0x03e8, 0x6824, 0xd094, 0x0040, 0x70c3, 0x6827, 0x0004,
+	0x7804, 0xa084, 0x4000, 0x0040, 0x70d5, 0x7803, 0x1000, 0x7803,
+	0x0000, 0x0078, 0x70d5, 0xd08c, 0x0040, 0x70ca, 0x6827, 0x0002,
+	0x0078, 0x70cc, 0x00f0, 0x70b2, 0x7804, 0xa084, 0x1000, 0x0040,
+	0x70d5, 0x7803, 0x0100, 0x7803, 0x0000, 0x6824, 0x007f, 0x017f,
+	0x027f, 0x0c7f, 0x0d7f, 0x0e7f, 0x0f7f, 0x157f, 0x127f, 0x007c,
+	0x0d7e, 0x127e, 0x2091, 0x8000, 0x2069, 0xa8b1, 0x6a06, 0x127f,
+	0x0d7f, 0x007c, 0x0d7e, 0x127e, 0x2091, 0x8000, 0x2069, 0xa8b1,
+	0x6a32, 0x127f, 0x0d7f, 0x007c, 0x0f7e, 0x0e7e, 0x0c7e, 0x067e,
+	0x007e, 0x127e, 0x2071, 0xa8b1, 0x7614, 0x2660, 0x2678, 0x2091,
+	0x8000, 0x8cff, 0x0040, 0x7134, 0x601c, 0xa206, 0x00c0, 0x712f,
+	0x7014, 0xac36, 0x00c0, 0x710e, 0x660c, 0x7616, 0x7010, 0xac36,
+	0x00c0, 0x711c, 0x2c00, 0xaf36, 0x0040, 0x711a, 0x2f00, 0x7012,
+	0x0078, 0x711c, 0x7013, 0x0000, 0x660c, 0x067e, 0x2c00, 0xaf06,
+	0x0040, 0x7125, 0x7e0e, 0x0078, 0x7126, 0x2678, 0x600f, 0x0000,
+	0x1078, 0x8ec6, 0x1078, 0x7233, 0x0c7f, 0x0078, 0x7101, 0x2c78,
+	0x600c, 0x2060, 0x0078, 0x7101, 0x127f, 0x007f, 0x067f, 0x0c7f,
+	0x0e7f, 0x0f7f, 0x007c, 0x157e, 0x147e, 0x20a1, 0x020b, 0x1078,
+	0x69d0, 0x7810, 0x20a2, 0xa006, 0x20a2, 0x20a2, 0x20a2, 0x20a2,
+	0x20a3, 0x1000, 0x0078, 0x718e, 0x157e, 0x147e, 0x20a1, 0x020b,
+	0x1078, 0x69d0, 0x7810, 0x20a2, 0xa006, 0x20a2, 0x20a2, 0x20a2,
+	0x20a2, 0x20a3, 0x4000, 0x0078, 0x718e, 0x157e, 0x147e, 0x20a1,
+	0x020b, 0x1078, 0x69d0, 0x7810, 0x20a2, 0xa006, 0x20a2, 0x20a2,
+	0x20a2, 0x20a2, 0x20a3, 0x2000, 0x0078, 0x718e, 0x157e, 0x147e,
+	0x20a1, 0x020b, 0x1078, 0x69d0, 0x7810, 0x20a2, 0xa006, 0x20a2,
+	0x20a2, 0x20a2, 0x20a2, 0x20a3, 0x0400, 0x0078, 0x718e, 0x157e,
+	0x147e, 0x20a1, 0x020b, 0x1078, 0x69d0, 0x7810, 0x20a2, 0xa006,
+	0x20a2, 0x20a2, 0x20a2, 0x20a2, 0x20a3, 0x0200, 0x1078, 0x723e,
+	0x60c3, 0x0020, 0x1078, 0x6dfb, 0x147f, 0x157f, 0x007c, 0x127e,
+	0x0c7e, 0x2091, 0x8000, 0x2061, 0x0100, 0x6120, 0xd1b4, 0x00c0,
+	0x71a6, 0xd1bc, 0x00c0, 0x71f0, 0x0078, 0x7230, 0x2009, 0x017f,
+	0x200b, 0x00a1, 0x157e, 0x007e, 0x0d7e, 0x2069, 0x0140, 0x20a9,
+	0x001e, 0x2009, 0x0169, 0x6804, 0xa084, 0x4000, 0x0040, 0x71e7,
+	0x6020, 0xd0b4, 0x0040, 0x71e7, 0x6024, 0xd094, 0x00c0, 0x71e7,
+	0x2104, 0xa084, 0x000f, 0xa086, 0x0004, 0x00c0, 0x71e7, 0x00f0,
+	0x71b3, 0x027e, 0x6198, 0xa18c, 0x00ff, 0x8107, 0x6130, 0xa18c,
+	0x00ff, 0xa10d, 0x6088, 0x628c, 0x618e, 0x608b, 0xbc91, 0x6043,
+	0x0001, 0x6043, 0x0000, 0x608a, 0x628e, 0x6024, 0xd094, 0x00c0,
+	0x71e6, 0x6a04, 0xa294, 0x4000, 0x00c0, 0x71dd, 0x027f, 0x0d7f,
+	0x007f, 0x157f, 0x2009, 0x017f, 0x200b, 0x0000, 0x0078, 0x7230,
+	0x2009, 0x017f, 0x200b, 0x00a1, 0x157e, 0x007e, 0x0d7e, 0x2069,
+	0x0140, 0x20a9, 0x001e, 0x2009, 0x0169, 0x6804, 0xa084, 0x4000,
+	0x0040, 0x7229, 0x6020, 0xd0bc, 0x0040, 0x7229, 0x2104, 0xa084,
+	0x000f, 0xa086, 0x0004, 0x00c0, 0x7229, 0x00f0, 0x71fd, 0x027e,
+	0x6164, 0xa18c, 0x00ff, 0x8107, 0x6130, 0xa18c, 0x00ff, 0xa10d,
+	0x6088, 0x628c, 0x608b, 0xbc91, 0x618e, 0x6043, 0x0001, 0x6043,
+	0x0000, 0x608a, 0x628e, 0x6a04, 0xa294, 0x4000, 0x00c0, 0x7223,
+	0x027f, 0x0d7f, 0x007f, 0x157f, 0x2009, 0x017f, 0x200b, 0x0000,
+	0x0c7f, 0x127f, 0x007c, 0x0e7e, 0x2071, 0xa8b1, 0x7020, 0xa005,
+	0x0040, 0x723c, 0x8001, 0x7022, 0x0e7f, 0x007c, 0x20a9, 0x0008,
+	0x20a2, 0x00f0, 0x7240, 0x20a2, 0x20a2, 0x007c, 0x0f7e, 0x0e7e,
+	0x0d7e, 0x0c7e, 0x077e, 0x067e, 0x007e, 0x127e, 0x2091, 0x8000,
+	0x2071, 0xa8b1, 0x7614, 0x2660, 0x2678, 0x2039, 0x0001, 0x87ff,
+	0x0040, 0x72e2, 0x8cff, 0x0040, 0x72e2, 0x601c, 0xa086, 0x0006,
+	0x00c0, 0x72dd, 0x88ff, 0x0040, 0x726d, 0x2800, 0xac06, 0x00c0,
+	0x72dd, 0x2039, 0x0000, 0x0078, 0x7278, 0x6018, 0xa206, 0x00c0,
+	0x72dd, 0x85ff, 0x0040, 0x7278, 0x6020, 0xa106, 0x00c0, 0x72dd,
+	0x7024, 0xac06, 0x00c0, 0x72a8, 0x2069, 0x0100, 0x68c0, 0xa005,
+	0x0040, 0x72a3, 0x1078, 0x5acb, 0x6817, 0x0008, 0x68c3, 0x0000,
+	0x1078, 0x7378, 0x7027, 0x0000, 0x037e, 0x2069, 0x0140, 0x6b04,
+	0xa384, 0x1000, 0x0040, 0x7298, 0x6803, 0x0100, 0x6803, 0x0000,
+	0x2069, 0x0100, 0x6824, 0xd084, 0x0040, 0x72a0, 0x6827, 0x0001,
+	0x037f, 0x0078, 0x72a8, 0x6003, 0x0009, 0x630a, 0x0078, 0x72dd,
+	0x7014, 0xac36, 0x00c0, 0x72ae, 0x660c, 0x7616, 0x7010, 0xac36,
+	0x00c0, 0x72bc, 0x2c00, 0xaf36, 0x0040, 0x72ba, 0x2f00, 0x7012,
+	0x0078, 0x72bc, 0x7013, 0x0000, 0x660c, 0x067e, 0x2c00, 0xaf06,
+	0x0040, 0x72c5, 0x7e0e, 0x0078, 0x72c6, 0x2678, 0x89ff, 0x00c0,
+	0x72d5, 0x600f, 0x0000, 0x6010, 0x2068, 0x1078, 0x8d06, 0x0040,
+	0x72d3, 0x1078, 0xa1ca, 0x1078, 0x8ec6, 0x1078, 0x7233, 0x88ff,
+	0x00c0, 0x72ec, 0x0c7f, 0x0078, 0x7257, 0x2c78, 0x600c, 0x2060,
+	0x0078, 0x7257, 0xa006, 0x127f, 0x007f, 0x067f, 0x077f, 0x0c7f,
+	0x0d7f, 0x0e7f, 0x0f7f, 0x007c, 0x6017, 0x0000, 0x0c7f, 0xa8c5,
+	0x0001, 0x0078, 0x72e3, 0x0f7e, 0x0e7e, 0x0d7e, 0x0c7e, 0x067e,
+	0x027e, 0x007e, 0x127e, 0x2091, 0x8000, 0x2071, 0xa8b1, 0x7638,
+	0x2660, 0x2678, 0x8cff, 0x0040, 0x7367, 0x601c, 0xa086, 0x0006,
+	0x00c0, 0x7362, 0x87ff, 0x0040, 0x7313, 0x2700, 0xac06, 0x00c0,
+	0x7362, 0x0078, 0x731e, 0x6018, 0xa206, 0x00c0, 0x7362, 0x85ff,
+	0x0040, 0x731e, 0x6020, 0xa106, 0x00c0, 0x7362, 0x703c, 0xac06,
+	0x00c0, 0x7332, 0x037e, 0x2019, 0x0001, 0x1078, 0x7058, 0x7033,
+	0x0000, 0x703f, 0x0000, 0x7043, 0x0000, 0x7047, 0x0000, 0x704b,
+	0x0000, 0x037f, 0x7038, 0xac36, 0x00c0, 0x7338, 0x660c, 0x763a,
+	0x7034, 0xac36, 0x00c0, 0x7346, 0x2c00, 0xaf36, 0x0040, 0x7344,
+	0x2f00, 0x7036, 0x0078, 0x7346, 0x7037, 0x0000, 0x660c, 0x067e,
+	0x2c00, 0xaf06, 0x0040, 0x734f, 0x7e0e, 0x0078, 0x7350, 0x2678,
+	0x600f, 0x0000, 0x6010, 0x2068, 0x1078, 0x8d06, 0x0040, 0x735a,
+	0x1078, 0xa1ca, 0x1078, 0x8ec6, 0x87ff, 0x00c0, 0x7371, 0x0c7f,
+	0x0078, 0x7302, 0x2c78, 0x600c, 0x2060, 0x0078, 0x7302, 0xa006,
+	0x127f, 0x007f, 0x027f, 0x067f, 0x0c7f, 0x0d7f, 0x0e7f, 0x0f7f,
+	0x007c, 0x6017, 0x0000, 0x0c7f, 0xa7bd, 0x0001, 0x0078, 0x7368,
+	0x0e7e, 0x2071, 0xa8b1, 0x2001, 0xa600, 0x2004, 0xa086, 0x0002,
+	0x00c0, 0x7386, 0x7007, 0x0005, 0x0078, 0x7388, 0x7007, 0x0000,
+	0x0e7f, 0x007c, 0x0f7e, 0x0e7e, 0x0c7e, 0x067e, 0x027e, 0x007e,
+	0x127e, 0x2091, 0x8000, 0x2071, 0xa8b1, 0x2c10, 0x7638, 0x2660,
+	0x2678, 0x8cff, 0x0040, 0x73c8, 0x2200, 0xac06, 0x00c0, 0x73c3,
+	0x7038, 0xac36, 0x00c0, 0x73a6, 0x660c, 0x763a, 0x7034, 0xac36,
+	0x00c0, 0x73b4, 0x2c00, 0xaf36, 0x0040, 0x73b2, 0x2f00, 0x7036,
+	0x0078, 0x73b4, 0x7037, 0x0000, 0x660c, 0x2c00, 0xaf06, 0x0040,
+	0x73bc, 0x7e0e, 0x0078, 0x73bd, 0x2678, 0x600f, 0x0000, 0xa085,
+	0x0001, 0x0078, 0x73c8, 0x2c78, 0x600c, 0x2060, 0x0078, 0x7399,
+	0x127f, 0x007f, 0x027f, 0x067f, 0x0c7f, 0x0e7f, 0x0f7f, 0x007c,
+	0x0f7e, 0x0e7e, 0x0d7e, 0x0c7e, 0x067e, 0x007e, 0x127e, 0x2091,
+	0x8000, 0x2071, 0xa8b1, 0x760c, 0x2660, 0x2678, 0x8cff, 0x0040,
+	0x7469, 0x6018, 0xa080, 0x0028, 0x2004, 0xa206, 0x00c0, 0x7464,
+	0x7024, 0xac06, 0x00c0, 0x740f, 0x2069, 0x0100, 0x68c0, 0xa005,
+	0x0040, 0x743d, 0x1078, 0x6e0f, 0x68c3, 0x0000, 0x1078, 0x7378,
+	0x7027, 0x0000, 0x037e, 0x2069, 0x0140, 0x6b04, 0xa384, 0x1000,
+	0x0040, 0x7406, 0x6803, 0x0100, 0x6803, 0x0000, 0x2069, 0x0100,
+	0x6824, 0xd084, 0x0040, 0x740e, 0x6827, 0x0001, 0x037f, 0x700c,
+	0xac36, 0x00c0, 0x7415, 0x660c, 0x760e, 0x7008, 0xac36, 0x00c0,
+	0x7423, 0x2c00, 0xaf36, 0x0040, 0x7421, 0x2f00, 0x700a, 0x0078,
+	0x7423, 0x700b, 0x0000, 0x660c, 0x067e, 0x2c00, 0xaf06, 0x0040,
+	0x742c, 0x7e0e, 0x0078, 0x742d, 0x2678, 0x600f, 0x0000, 0x1078,
+	0x8eec, 0x00c0, 0x7441, 0x1078, 0x28a6, 0x1078, 0x8f00, 0x00c0,
+	0x745d, 0x1078, 0x7c83, 0x0078, 0x745d, 0x1078, 0x7378, 0x0078,
+	0x740f, 0x1078, 0x8f00, 0x00c0, 0x7449, 0x1078, 0x7c83, 0x0078,
+	0x745d, 0x6010, 0x2068, 0x1078, 0x8d06, 0x0040, 0x745d, 0x601c,
+	0xa086, 0x0003, 0x00c0, 0x7471, 0x6837, 0x0103, 0x6b4a, 0x6847,
+	0x0000, 0x1078, 0x4a73, 0x1078, 0x8eb9, 0x1078, 0x8ec6, 0x1078,
+	0x7233, 0x0c7f, 0x0078, 0x73de, 0x2c78, 0x600c, 0x2060, 0x0078,
+	0x73de, 0x127f, 0x007f, 0x067f, 0x0c7f, 0x0d7f, 0x0e7f, 0x0f7f,
+	0x007c, 0x601c, 0xa086, 0x0006, 0x00c0, 0x745d, 0x1078, 0xa1ca,
+	0x0078, 0x745d, 0x037e, 0x157e, 0x137e, 0x147e, 0x3908, 0xa006,
+	0xa190, 0x0020, 0x221c, 0xa39e, 0x2676, 0x00c0, 0x748b, 0x8210,
+	0x8000, 0x0078, 0x7482, 0xa005, 0x0040, 0x7497, 0x20a9, 0x0020,
+	0x2198, 0x8211, 0xa282, 0x0020, 0x20c8, 0x20a0, 0x53a3, 0x147f,
+	0x137f, 0x157f, 0x037f, 0x007c, 0x0d7e, 0x20a1, 0x020b, 0x1078,
+	0x67c2, 0x20a3, 0x0200, 0x20a3, 0x0014, 0x60c3, 0x0014, 0x20a3,
+	0x0000, 0x20a3, 0x0000, 0x2099, 0xa8a5, 0x20a9, 0x0004, 0x53a6,
+	0x20a3, 0x0004, 0x20a3, 0x7878, 0x20a3, 0x0000, 0x20a3, 0x0000,
+	0x1078, 0x6dfb, 0x0d7f, 0x007c, 0x20a1, 0x020b, 0x1078, 0x67c2,
+	0x20a3, 0x0214, 0x20a3, 0x0018, 0x20a3, 0x0800, 0x7810, 0xa084,
+	0xff00, 0x20a2, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000,
+	0x20a3, 0x0000, 0x7810, 0xa084, 0x00ff, 0x20a2, 0x7828, 0x20a2,
+	0x20a3, 0x0000, 0x20a3, 0x0000, 0x60c3, 0x0018, 0x1078, 0x6dfb,
+	0x007c, 0x0d7e, 0x017e, 0x2f68, 0x2009, 0x0035, 0x1078, 0x91bc,
+	0x00c0, 0x7551, 0x20a1, 0x020b, 0x1078, 0x6731, 0x20a3, 0x1300,
+	0x20a3, 0x0000, 0x7828, 0x2068, 0x681c, 0xa086, 0x0003, 0x0040,
+	0x752d, 0x7818, 0xa080, 0x0028, 0x2014, 0xa286, 0x007e, 0x00c0,
+	0x7507, 0x20a3, 0x00ff, 0x20a3, 0xfffe, 0x0078, 0x7542, 0xa286,
+	0x007f, 0x00c0, 0x7511, 0x20a3, 0x00ff, 0x20a3, 0xfffd, 0x0078,
+	0x7542, 0xd2bc, 0x0040, 0x7527, 0xa286, 0x0080, 0x00c0, 0x751e,
+	0x20a3, 0x00ff, 0x20a3, 0xfffc, 0x0078, 0x7542, 0xa2e8, 0xa735,
+	0x2d6c, 0x6810, 0x20a2, 0x6814, 0x20a2, 0x0078, 0x7542, 0x20a3,
+	0x0000, 0x6098, 0x20a2, 0x0078, 0x7542, 0x7818, 0xa080, 0x0028,
+	0x2004, 0xa082, 0x007e, 0x0048, 0x753e, 0x0d7e, 0x2069, 0xa61b,
+	0x2da6, 0x8d68, 0x2da6, 0x0d7f, 0x0078, 0x7542, 0x20a3, 0x0000,
+	0x6030, 0x20a2, 0x7834, 0x20a2, 0x7838, 0x20a2, 0x20a3, 0x0000,
+	0x20a3, 0x0000, 0x60c3, 0x000c, 0x1078, 0x6dfb, 0x017f, 0x0d7f,
+	0x007c, 0x7817, 0x0001, 0x7803, 0x0006, 0x017f, 0x0d7f, 0x007c,
+	0x0d7e, 0x027e, 0x7928, 0x2168, 0x691c, 0xa186, 0x0006, 0x0040,
+	0x757a, 0xa186, 0x0003, 0x0040, 0x75d5, 0xa186, 0x0005, 0x0040,
+	0x75b8, 0xa186, 0x0004, 0x0040, 0x75a8, 0xa186, 0x0008, 0x0040,
+	0x75c2, 0x7807, 0x0037, 0x7813, 0x1700, 0x1078, 0x7640, 0x027f,
+	0x0d7f, 0x007c, 0x1078, 0x75fd, 0x2009, 0x4000, 0x6800, 0x0079,
+	0x7581, 0x7594, 0x75a2, 0x7596, 0x75a2, 0x759d, 0x7594, 0x7594,
+	0x75a2, 0x75a2, 0x75a2, 0x75a2, 0x7594, 0x7594, 0x7594, 0x7594,
+	0x7594, 0x75a2, 0x7594, 0x75a2, 0x1078, 0x1332, 0x6824, 0xd0e4,
+	0x0040, 0x759d, 0xd0cc, 0x0040, 0x75a0, 0xa00e, 0x0078, 0x75a2,
+	0x2009, 0x2000, 0x6828, 0x20a2, 0x682c, 0x20a2, 0x0078, 0x75f3,
+	0x1078, 0x75fd, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x2009, 0x4000,
+	0x6a00, 0xa286, 0x0002, 0x00c0, 0x75b6, 0xa00e, 0x0078, 0x75f3,
+	0x1078, 0x75fd, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x2009, 0x4000,
+	0x0078, 0x75f3, 0x1078, 0x75fd, 0x20a3, 0x0000, 0x20a3, 0x0000,
+	0x2009, 0x4000, 0xa286, 0x0005, 0x0040, 0x75d2, 0xa286, 0x0002,
+	0x00c0, 0x75d3, 0xa00e, 0x0078, 0x75f3, 0x1078, 0x75fd, 0x6810,
+	0x2068, 0x697c, 0x6810, 0xa112, 0x6980, 0x6814, 0xa103, 0x20a2,
+	0x22a2, 0x7928, 0xa180, 0x0000, 0x2004, 0xa08e, 0x0002, 0x0040,
+	0x75f1, 0xa08e, 0x0004, 0x0040, 0x75f1, 0x2009, 0x4000, 0x0078,
+	0x75f3, 0x2009, 0x0000, 0x21a2, 0x20a3, 0x0000, 0x60c3, 0x0018,
+	0x1078, 0x6dfb, 0x027f, 0x0d7f, 0x007c, 0x037e, 0x047e, 0x057e,
+	0x067e, 0x20a1, 0x020b, 0x1078, 0x67c2, 0xa006, 0x20a3, 0x0200,
+	0x20a2, 0x7934, 0x21a2, 0x7938, 0x21a2, 0x7818, 0xa080, 0x0028,
+	0x2004, 0xa092, 0x007e, 0x0048, 0x7623, 0x0d7e, 0x2069, 0xa61b,
+	0x2d2c, 0x8d68, 0x2d34, 0xa0e8, 0xa735, 0x2d6c, 0x6b10, 0x6c14,
+	0x0d7f, 0x0078, 0x7629, 0x2019, 0x0000, 0x6498, 0x2029, 0x0000,
+	0x6630, 0x7828, 0xa080, 0x0007, 0x2004, 0xa086, 0x0003, 0x00c0,
+	0x7637, 0x25a2, 0x26a2, 0x23a2, 0x24a2, 0x0078, 0x763b, 0x23a2,
+	0x24a2, 0x25a2, 0x26a2, 0x067f, 0x057f, 0x047f, 0x037f, 0x007c,
+	0x20a1, 0x020b, 0x1078, 0x67c2, 0x20a3, 0x0100, 0x20a3, 0x0000,
+	0x20a3, 0x0009, 0x7810, 0x20a2, 0x60c3, 0x0008, 0x1078, 0x6dfb,
+	0x007c, 0x20a1, 0x020b, 0x1078, 0x6728, 0x20a3, 0x1400, 0x20a3,
+	0x0000, 0x7834, 0x20a2, 0x7838, 0x20a2, 0x7828, 0x20a2, 0x782c,
+	0x20a2, 0x7830, 0xa084, 0x00ff, 0x8007, 0x20a2, 0x20a3, 0x0000,
+	0x60c3, 0x0010, 0x1078, 0x6dfb, 0x007c, 0x20a1, 0x020b, 0x1078,
+	0x67b9, 0x20a3, 0x0100, 0x20a3, 0x0000, 0x7828, 0x20a2, 0x7810,
+	0x20a2, 0x60c3, 0x0008, 0x1078, 0x6dfb, 0x007c, 0x147e, 0x20a1,
+	0x020b, 0x1078, 0x7689, 0x60c3, 0x0000, 0x1078, 0x6dfb, 0x147f,
+	0x007c, 0x20e1, 0x9080, 0x20e1, 0x4000, 0x7818, 0xa080, 0x0028,
+	0x2004, 0xd0bc, 0x0040, 0x76a6, 0x0d7e, 0xa0e8, 0xa735, 0x2d6c,
+	0x6810, 0xa085, 0x0300, 0x20a2, 0x6814, 0x20a2, 0x2069, 0xa61b,
+	0x2da6, 0x8d68, 0x2da6, 0x0d7f, 0x0078, 0x76ae, 0x20a3, 0x0300,
+	0x6298, 0x22a2, 0x20a3, 0x0000, 0x6230, 0x22a2, 0x20a3, 0x0819,
+	0x20a3, 0x0000, 0x1078, 0x6dea, 0x22a2, 0x20a3, 0x0000, 0x2fa2,
+	0x7a08, 0x22a2, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x007c, 0x2061,
+	0xad00, 0x2a70, 0x7064, 0x704a, 0x704f, 0xad00, 0x007c, 0x0e7e,
+	0x127e, 0x2071, 0xa600, 0x2091, 0x8000, 0x7548, 0xa582, 0x0010,
+	0x0048, 0x76f9, 0x704c, 0x2060, 0x6000, 0xa086, 0x0000, 0x0040,
+	0x76e5, 0xace0, 0x0010, 0x7058, 0xac02, 0x00c8, 0x76e1, 0x0078,
+	0x76d4, 0x2061, 0xad00, 0x0078, 0x76d4, 0x6003, 0x0008, 0x8529,
+	0x754a, 0xaca8, 0x0010, 0x7058, 0xa502, 0x00c8, 0x76f5, 0x754e,
+	0xa085, 0x0001, 0x127f, 0x0e7f, 0x007c, 0x704f, 0xad00, 0x0078,
+	0x76f0, 0xa006, 0x0078, 0x76f2, 0x0e7e, 0x2071, 0xa600, 0x7548,
+	0xa582, 0x0010, 0x0048, 0x772a, 0x704c, 0x2060, 0x6000, 0xa086,
+	0x0000, 0x0040, 0x7717, 0xace0, 0x0010, 0x7058, 0xac02, 0x00c8,
+	0x7713, 0x0078, 0x7706, 0x2061, 0xad00, 0x0078, 0x7706, 0x6003,
+	0x0008, 0x8529, 0x754a, 0xaca8, 0x0010, 0x7058, 0xa502, 0x00c8,
+	0x7726, 0x754e, 0xa085, 0x0001, 0x0e7f, 0x007c, 0x704f, 0xad00,
+	0x0078, 0x7722, 0xa006, 0x0078, 0x7724, 0xac82, 0xad00, 0x1048,
+	0x1332, 0x2001, 0xa616, 0x2004, 0xac02, 0x10c8, 0x1332, 0xa006,
+	0x6006, 0x600a, 0x600e, 0x6012, 0x6016, 0x601a, 0x601f, 0x0000,
+	0x6003, 0x0000, 0x6022, 0x6026, 0x602a, 0x602e, 0x6032, 0x6036,
+	0x603a, 0x603e, 0x2061, 0xa600, 0x6048, 0x8000, 0x604a, 0xa086,
+	0x0001, 0x0040, 0x7754, 0x007c, 0x127e, 0x2091, 0x8000, 0x1078,
+	0x62d1, 0x127f, 0x0078, 0x7753, 0x601c, 0xa084, 0x000f, 0x0079,
+	0x7761, 0x776a, 0x777b, 0x7797, 0x77b3, 0x920e, 0x922a, 0x9246,
+	0x776a, 0x777b, 0xa186, 0x0013, 0x00c0, 0x7773, 0x1078, 0x61cd,
+	0x1078, 0x62d1, 0x007c, 0xa18e, 0x0047, 0x00c0, 0x777a, 0xa016,
+	0x1078, 0x15fa, 0x007c, 0x067e, 0x6000, 0xa0b2, 0x0010, 0x10c8,
+	0x1332, 0x1079, 0x7785, 0x067f, 0x007c, 0x7795, 0x7b00, 0x7cb2,
+	0x7795, 0x7d36, 0x77cf, 0x7795, 0x7795, 0x7a92, 0x80f6, 0x7795,
+	0x7795, 0x7795, 0x7795, 0x7795, 0x7795, 0x1078, 0x1332, 0x067e,
+	0x6000, 0xa0b2, 0x0010, 0x10c8, 0x1332, 0x1079, 0x77a1, 0x067f,
+	0x007c, 0x77b1, 0x87c3, 0x77b1, 0x77b1, 0x77b1, 0x77b1, 0x77b1,
+	0x77b1, 0x8766, 0x8951, 0x77b1, 0x87f3, 0x8879, 0x87f3, 0x8879,
+	0x77b1, 0x1078, 0x1332, 0x067e, 0x6000, 0xa0b2, 0x0010, 0x10c8,
+	0x1332, 0x1079, 0x77bd, 0x067f, 0x007c, 0x77cd, 0x813d, 0x820e,
+	0x8368, 0x84e4, 0x77cd, 0x77cd, 0x77cd, 0x8116, 0x870e, 0x8712,
+	0x77cd, 0x77cd, 0x77cd, 0x77cd, 0x8742, 0x1078, 0x1332, 0xa1b6,
+	0x0015, 0x00c0, 0x77d7, 0x1078, 0x772d, 0x0078, 0x77dd, 0xa1b6,
+	0x0016, 0x10c0, 0x1332, 0x1078, 0x772d, 0x007c, 0x20a9, 0x000e,
+	0x2e98, 0x6010, 0x20a0, 0x53a3, 0x20a9, 0x0006, 0x3310, 0x3420,
+	0x9398, 0x94a0, 0x3318, 0x3428, 0x222e, 0x2326, 0xa290, 0x0002,
+	0xa5a8, 0x0002, 0xa398, 0x0002, 0xa4a0, 0x0002, 0x00f0, 0x77ec,
+	0x0e7e, 0x1078, 0x8d06, 0x0040, 0x7803, 0x6010, 0x2070, 0x7007,
+	0x0000, 0x7037, 0x0103, 0x0e7f, 0x1078, 0x772d, 0x007c, 0x0d7e,
+	0x037e, 0x7330, 0xa386, 0x0200, 0x00c0, 0x7814, 0x6018, 0x2068,
+	0x6813, 0x00ff, 0x6817, 0xfffd, 0x6010, 0xa005, 0x0040, 0x781e,
+	0x2068, 0x6807, 0x0000, 0x6837, 0x0103, 0x6b32, 0x1078, 0x772d,
+	0x037f, 0x0d7f, 0x007c, 0x017e, 0x20a9, 0x002a, 0xae80, 0x000c,
+	0x2098, 0x6010, 0xa080, 0x0002, 0x20a0, 0x53a3, 0x20a9, 0x002a,
+	0x6010, 0xa080, 0x0001, 0x2004, 0xa080, 0x0002, 0x20a0, 0x53a3,
+	0x0e7e, 0x6010, 0x2004, 0x2070, 0x7037, 0x0103, 0x0e7f, 0x1078,
+	0x772d, 0x017f, 0x007c, 0x0e7e, 0x0d7e, 0x603f, 0x0000, 0x2c68,
+	0x017e, 0x2009, 0x0035, 0x1078, 0x91bc, 0x017f, 0x00c0, 0x785f,
+	0x027e, 0x6228, 0x2268, 0x027f, 0x2071, 0xab8c, 0x6b1c, 0xa386,
+	0x0003, 0x0040, 0x7863, 0xa386, 0x0006, 0x0040, 0x7867, 0x1078,
+	0x772d, 0x0078, 0x7869, 0x1078, 0x786c, 0x0078, 0x7869, 0x1078,
+	0x7938, 0x0d7f, 0x0e7f, 0x007c, 0x0f7e, 0x6810, 0x2078, 0xa186,
+	0x0015, 0x0040, 0x791d, 0xa18e, 0x0016, 0x00c0, 0x7936, 0x700c,
+	0xa08c, 0xff00, 0xa186, 0x1700, 0x0040, 0x7882, 0xa186, 0x0300,
+	0x00c0, 0x78f8, 0x8fff, 0x00c0, 0x788c, 0x6800, 0xa086, 0x000f,
+	0x0040, 0x78db, 0x0078, 0x7934, 0x6808, 0xa086, 0xffff, 0x00c0,
+	0x7921, 0x784c, 0xa084, 0x0060, 0xa086, 0x0020, 0x00c0, 0x78a2,
+	0x797c, 0x7810, 0xa106, 0x00c0, 0x7921, 0x7980, 0x7814, 0xa106,
+	0x00c0, 0x7921, 0x1078, 0x8eb9, 0x6830, 0x7852, 0x784c, 0xc0dc,
+	0xc0f4, 0xc0d4, 0x784e, 0x027e, 0xa00e, 0x6a14, 0x2001, 0x000a,
+	0x1078, 0x5c1c, 0x7854, 0xa20a, 0x0048, 0x78b7, 0x8011, 0x7a56,
+	0x82ff, 0x027f, 0x00c0, 0x78c3, 0x0c7e, 0x2d60, 0x1078, 0x8ae0,
+	0x0c7f, 0x0078, 0x7934, 0x0c7e, 0x0d7e, 0x2f68, 0x6838, 0xd0fc,
+	0x00c0, 0x78ce, 0x1078, 0x4353, 0x0078, 0x78d0, 0x1078, 0x4431,
+	0x0d7f, 0x0c7f, 0x00c0, 0x7921, 0x0c7e, 0x2d60, 0x1078, 0x772d,
+	0x0c7f, 0x0078, 0x7934, 0x0c7e, 0x1078, 0x9187, 0x0040, 0x78f1,
+	0x6013, 0x0000, 0x6818, 0x601a, 0x601f, 0x0003, 0x6904, 0x0c7e,
+	0x2d60, 0x1078, 0x772d, 0x0c7f, 0x1078, 0x775c, 0x0c7f, 0x0078,
+	0x7934, 0x2001, 0xa8a4, 0x2004, 0x683e, 0x0c7f, 0x0078, 0x7934,
+	0x7008, 0xa086, 0x000b, 0x00c0, 0x7912, 0x6018, 0x200c, 0xc1bc,
+	0x2102, 0x0c7e, 0x2d60, 0x7853, 0x0003, 0x6007, 0x0085, 0x6003,
+	0x000b, 0x601f, 0x0002, 0x1078, 0x5d8a, 0x1078, 0x62d1, 0x0c7f,
+	0x0078, 0x7934, 0x700c, 0xa086, 0x2a00, 0x00c0, 0x7921, 0x2001,
+	0xa8a4, 0x2004, 0x683e, 0x0078, 0x7934, 0x1078, 0x7953, 0x0078,
+	0x7936, 0x8fff, 0x1040, 0x1332, 0x0c7e, 0x0d7e, 0x2d60, 0x2f68,
+	0x6837, 0x0103, 0x684b, 0x0003, 0x1078, 0x89cf, 0x1078, 0x8eb9,
+	0x1078, 0x8ec6, 0x0d7f, 0x0c7f, 0x1078, 0x772d, 0x0f7f, 0x007c,
+	0xa186, 0x0015, 0x00c0, 0x7942, 0x2001, 0xa8a4, 0x2004, 0x683e,
+	0x0078, 0x7950, 0xa18e, 0x0016, 0x00c0, 0x7952, 0x0c7e, 0x2d00,
+	0x2060, 0x1078, 0xa495, 0x1078, 0x5bc1, 0x1078, 0x772d, 0x0c7f,
+	0x1078, 0x772d, 0x007c, 0x027e, 0x037e, 0x047e, 0x7228, 0x7c80,
+	0x7b7c, 0xd2f4, 0x0040, 0x7962, 0x2001, 0xa8a4, 0x2004, 0x683e,
+	0x0078, 0x79c6, 0x0c7e, 0x2d60, 0x1078, 0x89f3, 0x0c7f, 0x6804,
+	0xa086, 0x0050, 0x00c0, 0x797a, 0x0c7e, 0x2d00, 0x2060, 0x6003,
+	0x0001, 0x6007, 0x0050, 0x1078, 0x5d8a, 0x1078, 0x62d1, 0x0c7f,
+	0x0078, 0x79c6, 0x6800, 0xa086, 0x000f, 0x0040, 0x799c, 0x8fff,
+	0x1040, 0x1332, 0x6824, 0xd0dc, 0x00c0, 0x799c, 0x6800, 0xa086,
+	0x0004, 0x00c0, 0x79a1, 0x784c, 0xd0ac, 0x0040, 0x79a1, 0x784c,
+	0xc0dc, 0xc0f4, 0x784e, 0x7850, 0xc0f4, 0xc0fc, 0x7852, 0x2001,
+	0x0001, 0x682e, 0x0078, 0x79c0, 0x2001, 0x0007, 0x682e, 0x0078,
+	0x79c0, 0x784c, 0xd0b4, 0x00c0, 0x79ae, 0xd0ac, 0x0040, 0x799c,
+	0x784c, 0xd0f4, 0x00c0, 0x799c, 0x0078, 0x798f, 0xd2ec, 0x00c0,
+	0x799c, 0x7024, 0xa306, 0x00c0, 0x79b9, 0x7020, 0xa406, 0x0040,
+	0x799c, 0x7020, 0x6836, 0x7024, 0x683a, 0x2001, 0x0005, 0x682e,
+	0x1078, 0x8ff0, 0x1078, 0x62d1, 0x0078, 0x79c8, 0x1078, 0x772d,
+	0x047f, 0x037f, 0x027f, 0x007c, 0x0e7e, 0x0d7e, 0x027e, 0x6034,
+	0x2068, 0x6a1c, 0xa286, 0x0007, 0x0040, 0x7a35, 0xa286, 0x0002,
+	0x0040, 0x7a35, 0xa286, 0x0000, 0x0040, 0x7a35, 0x6808, 0x6338,
+	0xa306, 0x00c0, 0x7a35, 0x2071, 0xab8c, 0xa186, 0x0015, 0x0040,
+	0x7a2f, 0xa18e, 0x0016, 0x00c0, 0x7a02, 0x6030, 0xa084, 0x00ff,
+	0xa086, 0x0001, 0x00c0, 0x7a02, 0x700c, 0xa086, 0x2a00, 0x00c0,
+	0x7a02, 0x6034, 0xa080, 0x0009, 0x200c, 0xc1dd, 0xc1f5, 0x2102,
+	0x0078, 0x7a2f, 0x0c7e, 0x6034, 0x2060, 0x6104, 0xa186, 0x004b,
+	0x0040, 0x7a22, 0xa186, 0x004c, 0x0040, 0x7a22, 0xa186, 0x004d,
+	0x0040, 0x7a22, 0xa186, 0x004e, 0x0040, 0x7a22, 0xa186, 0x0052,
+	0x0040, 0x7a22, 0x6010, 0x2068, 0x1078, 0x8d06, 0x1040, 0x1332,
+	0x6853, 0x0003, 0x6007, 0x0085, 0x6003, 0x000b, 0x601f, 0x0002,
+	0x1078, 0x5d8a, 0x1078, 0x62d1, 0x0c7f, 0x0078, 0x7a35, 0x6034,
+	0x2068, 0x2001, 0xa8a4, 0x2004, 0x683e, 0x1078, 0x772d, 0x027f,
+	0x0d7f, 0x0e7f, 0x007c, 0x0d7e, 0x20a9, 0x000e, 0x2e98, 0x6010,
+	0x20a0, 0x53a3, 0xa1b6, 0x0015, 0x00c0, 0x7a73, 0x6018, 0x2068,
+	0x157e, 0x037e, 0x027e, 0xae90, 0x000c, 0xa290, 0x0004, 0x20a9,
+	0x0004, 0xad98, 0x000a, 0x1078, 0x80de, 0x027f, 0x037f, 0x157f,
+	0x00c0, 0x7a76, 0x157e, 0x037e, 0x027e, 0xae90, 0x000c, 0xa290,
+	0x0008, 0x20a9, 0x0004, 0xad98, 0x0006, 0x1078, 0x80de, 0x027f,
+	0x037f, 0x157f, 0x00c0, 0x7a76, 0x7038, 0x680a, 0x703c, 0x680e,
+	0x6800, 0xc08d, 0x6802, 0x0d7f, 0x0078, 0x77f8, 0x1078, 0x2880,
+	0x0c7e, 0x1078, 0x76c7, 0x2f00, 0x601a, 0x6013, 0x0000, 0x601f,
+	0x0001, 0x6007, 0x0001, 0x6003, 0x0001, 0x2001, 0x0007, 0x1078,
+	0x4502, 0x1078, 0x4535, 0x1078, 0x5dd7, 0x1078, 0x62d1, 0x0c7f,
+	0x0078, 0x7a73, 0x2100, 0xa1b2, 0x0044, 0x10c8, 0x1332, 0xa1b2,
+	0x0040, 0x00c8, 0x7af7, 0x0079, 0x7a9d, 0x7aeb, 0x7adf, 0x7aeb,
+	0x7aeb, 0x7aeb, 0x7aeb, 0x7add, 0x7add, 0x7add, 0x7add, 0x7add,
+	0x7add, 0x7add, 0x7add, 0x7add, 0x7add, 0x7add, 0x7add, 0x7add,
+	0x7add, 0x7add, 0x7add, 0x7add, 0x7add, 0x7add, 0x7add, 0x7add,
+	0x7add, 0x7add, 0x7add, 0x7add, 0x7aeb, 0x7add, 0x7aeb, 0x7aeb,
+	0x7add, 0x7add, 0x7add, 0x7add, 0x7add, 0x7aeb, 0x7add, 0x7add,
+	0x7add, 0x7add, 0x7add, 0x7add, 0x7add, 0x7add, 0x7add, 0x7aeb,
+	0x7aeb, 0x7add, 0x7add, 0x7add, 0x7add, 0x7add, 0x7add, 0x7add,
+	0x7add, 0x7add, 0x7aeb, 0x7add, 0x7add, 0x1078, 0x1332, 0x6003,
+	0x0001, 0x6106, 0x1078, 0x5dd7, 0x127e, 0x2091, 0x8000, 0x1078,
+	0x62d1, 0x127f, 0x007c, 0x6003, 0x0001, 0x6106, 0x1078, 0x5dd7,
+	0x127e, 0x2091, 0x8000, 0x1078, 0x62d1, 0x127f, 0x007c, 0x2600,
+	0x0079, 0x7afa, 0x7afe, 0x7afe, 0x7afe, 0x7aeb, 0x1078, 0x1332,
+	0x6004, 0xa0b2, 0x0044, 0x10c8, 0x1332, 0xa1b6, 0x0013, 0x00c0,
+	0x7b10, 0xa0b2, 0x0040, 0x00c8, 0x7c79, 0x2008, 0x0079, 0x7bbf,
+	0xa1b6, 0x0027, 0x00c0, 0x7b7c, 0x1078, 0x61cd, 0x6004, 0x1078,
+	0x8eec, 0x0040, 0x7b2d, 0x1078, 0x8f00, 0x0040, 0x7b74, 0xa08e,
+	0x0021, 0x0040, 0x7b78, 0xa08e, 0x0022, 0x0040, 0x7b74, 0xa08e,
+	0x003d, 0x0040, 0x7b78, 0x0078, 0x7b6f, 0x1078, 0x28a6, 0x2001,
+	0x0007, 0x1078, 0x4502, 0x6018, 0xa080, 0x0028, 0x200c, 0x1078,
+	0x7c83, 0xa186, 0x007e, 0x00c0, 0x7b42, 0x2001, 0xa633, 0x2014,
+	0xc285, 0x2202, 0x017e, 0x027e, 0x037e, 0x2110, 0x027e, 0x2019,
+	0x0028, 0x1078, 0x73d0, 0x027f, 0x1078, 0xa4f1, 0x037f, 0x027f,
+	0x017f, 0x017e, 0x027e, 0x037e, 0x2110, 0x2019, 0x0028, 0x1078,
+	0x5f01, 0x077e, 0x2039, 0x0000, 0x1078, 0x5e0a, 0x0c7e, 0x6018,
+	0xa065, 0x0040, 0x7b65, 0x1078, 0x47e9, 0x0c7f, 0x2c08, 0x1078,
+	0x9f8b, 0x077f, 0x037f, 0x027f, 0x017f, 0x1078, 0x457f, 0x1078,
+	0x772d, 0x1078, 0x62d1, 0x007c, 0x1078, 0x7c83, 0x0078, 0x7b6f,
+	0x1078, 0x7ca6, 0x0078, 0x7b6f, 0xa186, 0x0014, 0x00c0, 0x7b73,
+	0x1078, 0x61cd, 0x1078, 0x2880, 0x1078, 0x8eec, 0x00c0, 0x7b9b,
+	0x1078, 0x28a6, 0x6018, 0xa080, 0x0028, 0x200c, 0x1078, 0x7c83,
+	0xa186, 0x007e, 0x00c0, 0x7b99, 0x2001, 0xa633, 0x200c, 0xc185,
+	0x2102, 0x0078, 0x7b6f, 0x1078, 0x8f00, 0x00c0, 0x7ba3, 0x1078,
+	0x7c83, 0x0078, 0x7b6f, 0x6004, 0xa08e, 0x0032, 0x00c0, 0x7bb4,
+	0x0e7e, 0x0f7e, 0x2071, 0xa682, 0x2079, 0x0000, 0x1078, 0x2bd7,
+	0x0f7f, 0x0e7f, 0x0078, 0x7b6f, 0x6004, 0xa08e, 0x0021, 0x0040,
+	0x7b9f, 0xa08e, 0x0022, 0x1040, 0x7c83, 0x0078, 0x7b6f, 0x7c01,
+	0x7c03, 0x7c07, 0x7c0b, 0x7c0f, 0x7c13, 0x7bff, 0x7bff, 0x7bff,
+	0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff,
+	0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff,
+	0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7c17, 0x7c29, 0x7bff,
+	0x7c2b, 0x7c29, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7c29,
+	0x7c29, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff,
+	0x7bff, 0x7c5c, 0x7c29, 0x7bff, 0x7c23, 0x7bff, 0x7bff, 0x7bff,
+	0x7c25, 0x7bff, 0x7bff, 0x7bff, 0x7c29, 0x7bff, 0x7bff, 0x1078,
+	0x1332, 0x0078, 0x7c29, 0x2001, 0x000b, 0x0078, 0x7c36, 0x2001,
+	0x0003, 0x0078, 0x7c36, 0x2001, 0x0005, 0x0078, 0x7c36, 0x2001,
+	0x0001, 0x0078, 0x7c36, 0x2001, 0x0009, 0x0078, 0x7c36, 0x1078,
+	0x61cd, 0x6003, 0x0005, 0x2001, 0xa8a4, 0x2004, 0x603e, 0x1078,
+	0x62d1, 0x0078, 0x7c35, 0x0078, 0x7c29, 0x0078, 0x7c29, 0x1078,
+	0x4502, 0x0078, 0x7c6e, 0x1078, 0x61cd, 0x6003, 0x0004, 0x2001,
+	0xa8a2, 0x2004, 0x6016, 0x1078, 0x62d1, 0x007c, 0x1078, 0x4502,
+	0x1078, 0x61cd, 0x2001, 0xa8a4, 0x2004, 0x603e, 0x6003, 0x0002,
+	0x037e, 0x2019, 0xa65d, 0x2304, 0xa084, 0xff00, 0x00c0, 0x7c4d,
+	0x2019, 0xa8a2, 0x231c, 0x0078, 0x7c56, 0x8007, 0xa09a, 0x0004,
+	0x0048, 0x7c48, 0x8003, 0x801b, 0x831b, 0xa318, 0x6316, 0x037f,
+	0x1078, 0x62d1, 0x0078, 0x7c35, 0x0e7e, 0x0f7e, 0x2071, 0xa682,
+	0x2079, 0x0000, 0x1078, 0x2bd7, 0x0f7f, 0x0e7f, 0x1078, 0x61cd,
+	0x1078, 0x772d, 0x1078, 0x62d1, 0x0078, 0x7c35, 0x1078, 0x61cd,
+	0x6003, 0x0002, 0x2001, 0xa8a2, 0x2004, 0x6016, 0x1078, 0x62d1,
+	0x007c, 0x2600, 0x2008, 0x0079, 0x7c7d, 0x7c81, 0x7c81, 0x7c81,
+	0x7c6e, 0x1078, 0x1332, 0x0e7e, 0x1078, 0x8d06, 0x0040, 0x7c9f,
+	0x6010, 0x2070, 0x7038, 0xd0fc, 0x0040, 0x7c9f, 0x7007, 0x0000,
+	0x017e, 0x6004, 0xa08e, 0x0021, 0x0040, 0x7ca1, 0xa08e, 0x003d,
+	0x0040, 0x7ca1, 0x017f, 0x7037, 0x0103, 0x7033, 0x0100, 0x0e7f,
+	0x007c, 0x017f, 0x1078, 0x7ca6, 0x0078, 0x7c9f, 0x0e7e, 0xacf0,
+	0x0004, 0x2e74, 0x7000, 0x2070, 0x7037, 0x0103, 0x7023, 0x8001,
+	0x0e7f, 0x007c, 0x0d7e, 0x6618, 0x2668, 0x6804, 0xa084, 0x00ff,
+	0x0d7f, 0xa0b2, 0x000c, 0x10c8, 0x1332, 0x6604, 0xa6b6, 0x0043,
+	0x00c0, 0x7cc6, 0x1078, 0x9134, 0x0078, 0x7d25, 0x6604, 0xa6b6,
+	0x0033, 0x00c0, 0x7ccf, 0x1078, 0x90d8, 0x0078, 0x7d25, 0x6604,
+	0xa6b6, 0x0028, 0x00c0, 0x7cd8, 0x1078, 0x8f2f, 0x0078, 0x7d25,
+	0x6604, 0xa6b6, 0x0029, 0x00c0, 0x7ce1, 0x1078, 0x8f49, 0x0078,
+	0x7d25, 0x6604, 0xa6b6, 0x001f, 0x00c0, 0x7cea, 0x1078, 0x77de,
+	0x0078, 0x7d25, 0x6604, 0xa6b6, 0x0000, 0x00c0, 0x7cf3, 0x1078,
+	0x7a3b, 0x0078, 0x7d25, 0x6604, 0xa6b6, 0x0022, 0x00c0, 0x7cfc,
+	0x1078, 0x7807, 0x0078, 0x7d25, 0x6604, 0xa6b6, 0x0035, 0x00c0,
+	0x7d05, 0x1078, 0x7843, 0x0078, 0x7d25, 0x6604, 0xa6b6, 0x0039,
+	0x00c0, 0x7d0e, 0x1078, 0x79cc, 0x0078, 0x7d25, 0x6604, 0xa6b6,
+	0x003d, 0x00c0, 0x7d17, 0x1078, 0x7823, 0x0078, 0x7d25, 0xa1b6,
+	0x0015, 0x00c0, 0x7d1f, 0x1079, 0x7d2a, 0x0078, 0x7d25, 0xa1b6,
+	0x0016, 0x00c0, 0x7d26, 0x1079, 0x7e7f, 0x007c, 0x1078, 0x7773,
+	0x0078, 0x7d25, 0x7d4e, 0x7d51, 0x7d4e, 0x7d9c, 0x7d4e, 0x7e13,
+	0x7e8b, 0x7d4e, 0x7d4e, 0x7e57, 0x7d4e, 0x7e6d, 0xa1b6, 0x0048,
+	0x0040, 0x7d42, 0x20e1, 0x0005, 0x3d18, 0x3e20, 0x2c10, 0x1078,
+	0x15fa, 0x007c, 0x0e7e, 0xacf0, 0x0004, 0x2e74, 0x7000, 0x2070,
+	0x7037, 0x0103, 0x0e7f, 0x1078, 0x772d, 0x007c, 0x0005, 0x0005,
+	0x007c, 0x0e7e, 0x2071, 0xa600, 0x7080, 0xa086, 0x0074, 0x00c0,
+	0x7d85, 0x1078, 0x9f5f, 0x00c0, 0x7d77, 0x0d7e, 0x6018, 0x2068,
+	0x7030, 0xd08c, 0x0040, 0x7d6a, 0x6800, 0xd0bc, 0x0040, 0x7d6a,
+	0xc0c5, 0x6802, 0x1078, 0x7d89, 0x0d7f, 0x2001, 0x0006, 0x1078,
+	0x4502, 0x1078, 0x28a6, 0x1078, 0x772d, 0x0078, 0x7d87, 0x2001,
+	0x000a, 0x1078, 0x4502, 0x1078, 0x28a6, 0x6003, 0x0001, 0x6007,
+	0x0001, 0x1078, 0x5dd7, 0x0078, 0x7d87, 0x1078, 0x7dff, 0x0e7f,
+	0x007c, 0x6800, 0xd084, 0x0040, 0x7d9b, 0x2001, 0x0000, 0x1078,
+	0x44ee, 0x2069, 0xa652, 0x6804, 0xd0a4, 0x0040, 0x7d9b, 0x2001,
+	0x0006, 0x1078, 0x4535, 0x007c, 0x0d7e, 0x2011, 0xa620, 0x2204,
+	0xa086, 0x0074, 0x00c0, 0x7dfb, 0x6018, 0x2068, 0x6aa0, 0xa286,
+	0x007e, 0x00c0, 0x7daf, 0x1078, 0x7f9b, 0x0078, 0x7dfd, 0x1078,
+	0x7f91, 0x6018, 0x2068, 0xa080, 0x0028, 0x2014, 0xa286, 0x0080,
+	0x00c0, 0x7dd3, 0x6813, 0x00ff, 0x6817, 0xfffc, 0x6010, 0xa005,
+	0x0040, 0x7dc9, 0x2068, 0x6807, 0x0000, 0x6837, 0x0103, 0x6833,
+	0x0200, 0x2001, 0x0006, 0x1078, 0x4502, 0x1078, 0x28a6, 0x1078,
+	0x772d, 0x0078, 0x7dfd, 0x0e7e, 0x2071, 0xa633, 0x2e04, 0xd09c,
+	0x0040, 0x7dee, 0x2071, 0xab80, 0x7108, 0x720c, 0xa18c, 0x00ff,
+	0x00c0, 0x7de6, 0xa284, 0xff00, 0x0040, 0x7dee, 0x6018, 0x2070,
+	0x70a0, 0xd0bc, 0x00c0, 0x7dee, 0x7112, 0x7216, 0x0e7f, 0x2001,
+	0x0004, 0x1078, 0x4502, 0x6003, 0x0001, 0x6007, 0x0003, 0x1078,
+	0x5dd7, 0x0078, 0x7dfd, 0x1078, 0x7dff, 0x0d7f, 0x007c, 0x2001,
+	0x0007, 0x1078, 0x4502, 0x2001, 0xa600, 0x2004, 0xa086, 0x0003,
+	0x00c0, 0x7e0e, 0x2001, 0x0007, 0x1078, 0x4535, 0x1078, 0x28a6,
+	0x1078, 0x772d, 0x007c, 0x0e7e, 0x2071, 0xa600, 0x7080, 0xa086,
+	0x0014, 0x00c0, 0x7e51, 0x7000, 0xa086, 0x0003, 0x00c0, 0x7e26,
+	0x6010, 0xa005, 0x00c0, 0x7e26, 0x1078, 0x3699, 0x0d7e, 0x6018,
+	0x2068, 0x1078, 0x4649, 0x1078, 0x7d89, 0x0d7f, 0x1078, 0x8043,
+	0x00c0, 0x7e51, 0x0d7e, 0x6018, 0x2068, 0x6890, 0x0d7f, 0xa005,
+	0x0040, 0x7e51, 0x2001, 0x0006, 0x1078, 0x4502, 0x0e7e, 0x6010,
+	0xa005, 0x0040, 0x7e4a, 0x2070, 0x7007, 0x0000, 0x7037, 0x0103,
+	0x7033, 0x0200, 0x0e7f, 0x1078, 0x28a6, 0x1078, 0x772d, 0x0078,
+	0x7e55, 0x1078, 0x7c83, 0x1078, 0x7dff, 0x0e7f, 0x007c, 0x2011,
+	0xa620, 0x2204, 0xa086, 0x0014, 0x00c0, 0x7e6a, 0x2001, 0x0002,
+	0x1078, 0x4502, 0x6003, 0x0001, 0x6007, 0x0001, 0x1078, 0x5dd7,
+	0x0078, 0x7e6c, 0x1078, 0x7dff, 0x007c, 0x2011, 0xa620, 0x2204,
+	0xa086, 0x0004, 0x00c0, 0x7e7c, 0x2001, 0x0007, 0x1078, 0x4502,
+	0x1078, 0x772d, 0x0078, 0x7e7e, 0x1078, 0x7dff, 0x007c, 0x7d4e,
+	0x7e97, 0x7d4e, 0x7ed2, 0x7d4e, 0x7f44, 0x7e8b, 0x7d4e, 0x7d4e,
+	0x7f59, 0x7d4e, 0x7f6c, 0x6604, 0xa686, 0x0003, 0x0040, 0x7e13,
+	0xa6b6, 0x001e, 0x00c0, 0x7e96, 0x1078, 0x772d, 0x007c, 0x0d7e,
+	0x0c7e, 0x1078, 0x7f7f, 0x00c0, 0x7ead, 0x2001, 0x0000, 0x1078,
+	0x44ee, 0x2001, 0x0002, 0x1078, 0x4502, 0x6003, 0x0001, 0x6007,
+	0x0002, 0x1078, 0x5dd7, 0x0078, 0x7ecf, 0x2009, 0xab8e, 0x2104,
+	0xa086, 0x0009, 0x00c0, 0x7ec2, 0x6018, 0x2068, 0x6840, 0xa084,
+	0x00ff, 0xa005, 0x0040, 0x7ecd, 0x8001, 0x6842, 0x6017, 0x000a,
+	0x0078, 0x7ecf, 0x2009, 0xab8f, 0x2104, 0xa084, 0xff00, 0xa086,
+	0x1900, 0x00c0, 0x7ecd, 0x0078, 0x7ea1, 0x1078, 0x7dff, 0x0c7f,
+	0x0d7f, 0x007c, 0x1078, 0x7f8e, 0x00c0, 0x7ee6, 0x2001, 0x0000,
+	0x1078, 0x44ee, 0x2001, 0x0002, 0x1078, 0x4502, 0x6003, 0x0001,
+	0x6007, 0x0002, 0x1078, 0x5dd7, 0x0078, 0x7f12, 0x1078, 0x7c83,
+	0x2009, 0xab8e, 0x2134, 0xa6b4, 0x00ff, 0xa686, 0x0005, 0x0040,
+	0x7f13, 0xa686, 0x000b, 0x0040, 0x7f10, 0x2009, 0xab8f, 0x2104,
+	0xa084, 0xff00, 0x00c0, 0x7f00, 0xa686, 0x0009, 0x0040, 0x7f13,
+	0xa086, 0x1900, 0x00c0, 0x7f10, 0xa686, 0x0009, 0x0040, 0x7f13,
+	0x2001, 0x0004, 0x1078, 0x4502, 0x1078, 0x772d, 0x0078, 0x7f12,
+	0x1078, 0x7dff, 0x007c, 0x0d7e, 0x6010, 0x2068, 0x1078, 0x8d06,
+	0x0040, 0x7f21, 0x6838, 0xd0fc, 0x0040, 0x7f21, 0x0d7f, 0x0078,
+	0x7f10, 0x6018, 0x2068, 0x6840, 0xa084, 0x00ff, 0xa005, 0x0040,
+	0x7f32, 0x8001, 0x6842, 0x6017, 0x000a, 0x6007, 0x0016, 0x0d7f,
+	0x0078, 0x7f12, 0x68a0, 0xa086, 0x007e, 0x00c0, 0x7f3f, 0x0e7e,
+	0x2071, 0xa600, 0x1078, 0x42b8, 0x0e7f, 0x0078, 0x7f41, 0x1078,
+	0x2880, 0x0d7f, 0x0078, 0x7f10, 0x1078, 0x7f8e, 0x00c0, 0x7f54,
+	0x2001, 0x0004, 0x1078, 0x4502, 0x6003, 0x0001, 0x6007, 0x0003,
+	0x1078, 0x5dd7, 0x0078, 0x7f58, 0x1078, 0x7c83, 0x1078, 0x7dff,
+	0x007c, 0x1078, 0x7f8e, 0x00c0, 0x7f69, 0x2001, 0x0008, 0x1078,
+	0x4502, 0x6003, 0x0001, 0x6007, 0x0005, 0x1078, 0x5dd7, 0x0078,
+	0x7f6b, 0x1078, 0x7dff, 0x007c, 0x1078, 0x7f8e, 0x00c0, 0x7f7c,
+	0x2001, 0x000a, 0x1078, 0x4502, 0x6003, 0x0001, 0x6007, 0x0001,
+	0x1078, 0x5dd7, 0x0078, 0x7f7e, 0x1078, 0x7dff, 0x007c, 0x2009,
+	0xab8e, 0x2104, 0xa086, 0x0003, 0x00c0, 0x7f8d, 0x2009, 0xab8f,
+	0x2104, 0xa084, 0xff00, 0xa086, 0x2a00, 0x007c, 0xa085, 0x0001,
+	0x007c, 0x0c7e, 0x017e, 0xac88, 0x0006, 0x2164, 0x1078, 0x45d6,
+	0x017f, 0x0c7f, 0x007c, 0x0f7e, 0x0e7e, 0x0d7e, 0x037e, 0x017e,
+	0x6018, 0x2068, 0x2071, 0xa633, 0x2e04, 0xa085, 0x0003, 0x2072,
+	0x1078, 0x8014, 0x0040, 0x7fd9, 0x2009, 0xa633, 0x2104, 0xc0cd,
+	0x200a, 0x2001, 0xa653, 0x2004, 0xd0a4, 0x0040, 0x7fc2, 0xa006,
+	0x2020, 0x2009, 0x002a, 0x1078, 0xa21d, 0x2001, 0xa60c, 0x200c,
+	0xc195, 0x2102, 0x2019, 0x002a, 0x2009, 0x0001, 0x1078, 0x284f,
+	0x2071, 0xa600, 0x1078, 0x2677, 0x0c7e, 0x157e, 0x20a9, 0x0081,
+	0x2009, 0x007f, 0x1078, 0x298e, 0x8108, 0x00f0, 0x7fd2, 0x157f,
+	0x0c7f, 0x1078, 0x7f91, 0x6813, 0x00ff, 0x6817, 0xfffe, 0x2071,
+	0xab80, 0x2079, 0x0100, 0x2e04, 0xa084, 0x00ff, 0x2069, 0xa61b,
+	0x206a, 0x78e6, 0x007e, 0x8e70, 0x2e04, 0x2069, 0xa61c, 0x206a,
+	0x78ea, 0xa084, 0xff00, 0x017f, 0xa105, 0x2009, 0xa626, 0x200a,
+	0x2069, 0xab8e, 0x2071, 0xa89e, 0x6810, 0x2072, 0x6814, 0x7006,
+	0x6818, 0x700a, 0x681c, 0x700e, 0x1078, 0x906e, 0x2001, 0x0006,
+	0x1078, 0x4502, 0x1078, 0x28a6, 0x1078, 0x772d, 0x017f, 0x037f,
+	0x0d7f, 0x0e7f, 0x0f7f, 0x007c, 0x027e, 0x037e, 0x0e7e, 0x157e,
+	0x2019, 0xa626, 0x231c, 0x83ff, 0x0040, 0x803e, 0x2071, 0xab80,
+	0x2e14, 0xa294, 0x00ff, 0x7004, 0xa084, 0xff00, 0xa205, 0xa306,
+	0x00c0, 0x803e, 0x2011, 0xab96, 0xad98, 0x000a, 0x20a9, 0x0004,
+	0x1078, 0x80de, 0x00c0, 0x803e, 0x2011, 0xab9a, 0xad98, 0x0006,
+	0x20a9, 0x0004, 0x1078, 0x80de, 0x00c0, 0x803e, 0x157f, 0x0e7f,
+	0x037f, 0x027f, 0x007c, 0x0e7e, 0x2071, 0xab8c, 0x7004, 0xa086,
+	0x0014, 0x00c0, 0x8066, 0x7008, 0xa086, 0x0800, 0x00c0, 0x8066,
+	0x700c, 0xd0ec, 0x0040, 0x8064, 0xa084, 0x0f00, 0xa086, 0x0100,
+	0x00c0, 0x8064, 0x7024, 0xd0a4, 0x00c0, 0x8061, 0xd0ac, 0x0040,
+	0x8064, 0xa006, 0x0078, 0x8066, 0xa085, 0x0001, 0x0e7f, 0x007c,
+	0x0e7e, 0x0d7e, 0x0c7e, 0x077e, 0x057e, 0x047e, 0x027e, 0x007e,
+	0x127e, 0x2091, 0x8000, 0x2029, 0xa8ba, 0x252c, 0x2021, 0xa8c0,
+	0x2424, 0x2061, 0xad00, 0x2071, 0xa600, 0x7248, 0x7064, 0xa202,
+	0x00c8, 0x80cc, 0x1078, 0xa242, 0x0040, 0x80c4, 0x671c, 0xa786,
+	0x0001, 0x0040, 0x80c4, 0xa786, 0x0007, 0x0040, 0x80c4, 0x2500,
+	0xac06, 0x0040, 0x80c4, 0x2400, 0xac06, 0x0040, 0x80c4, 0x0c7e,
+	0x6000, 0xa086, 0x0004, 0x00c0, 0x809f, 0x1078, 0x1757, 0xa786,
+	0x0008, 0x00c0, 0x80ae, 0x1078, 0x8f00, 0x00c0, 0x80ae, 0x0c7f,
+	0x1078, 0x7c83, 0x1078, 0x8ec6, 0x0078, 0x80c4, 0x6010, 0x2068,
+	0x1078, 0x8d06, 0x0040, 0x80c1, 0xa786, 0x0003, 0x00c0, 0x80d6,
+	0x6837, 0x0103, 0x6b4a, 0x6847, 0x0000, 0x1078, 0x4a73, 0x1078,
+	0x8eb9, 0x1078, 0x8ec6, 0x0c7f, 0xace0, 0x0010, 0x7058, 0xac02,
+	0x00c8, 0x80cc, 0x0078, 0x807d, 0x127f, 0x007f, 0x027f, 0x047f,
+	0x057f, 0x077f, 0x0c7f, 0x0d7f, 0x0e7f, 0x007c, 0xa786, 0x0006,
+	0x00c0, 0x80b8, 0x1078, 0xa1ca, 0x0078, 0x80c1, 0x220c, 0x2304,
+	0xa106, 0x00c0, 0x80e9, 0x8210, 0x8318, 0x00f0, 0x80de, 0xa006,
+	0x007c, 0x2304, 0xa102, 0x0048, 0x80f1, 0x2001, 0x0001, 0x0078,
+	0x80f3, 0x2001, 0x0000, 0xa18d, 0x0001, 0x007c, 0x6004, 0xa08a,
+	0x0044, 0x10c8, 0x1332, 0x1078, 0x8eec, 0x0040, 0x8105, 0x1078,
+	0x8f00, 0x0040, 0x8112, 0x0078, 0x810b, 0x1078, 0x28a6, 0x1078,
+	0x8f00, 0x0040, 0x8112, 0x1078, 0x61cd, 0x1078, 0x772d, 0x1078,
+	0x62d1, 0x007c, 0x1078, 0x7c83, 0x0078, 0x810b, 0xa182, 0x0040,
+	0x0079, 0x811a, 0x812d, 0x812d, 0x812d, 0x812d, 0x812d, 0x812d,
+	0x812d, 0x812d, 0x812d, 0x812d, 0x812d, 0x812f, 0x812f, 0x812f,
+	0x812f, 0x812d, 0x812d, 0x812d, 0x812f, 0x1078, 0x1332, 0x600b,
+	0xffff, 0x6003, 0x0001, 0x6106, 0x1078, 0x5d8a, 0x127e, 0x2091,
+	0x8000, 0x1078, 0x62d1, 0x127f, 0x007c, 0xa186, 0x0013, 0x00c0,
+	0x8146, 0x6004, 0xa082, 0x0040, 0x0079, 0x81d1, 0xa186, 0x0027,
+	0x00c0, 0x8168, 0x1078, 0x61cd, 0x1078, 0x2880, 0x0d7e, 0x6110,
+	0x2168, 0x1078, 0x8d06, 0x0040, 0x8162, 0x6837, 0x0103, 0x684b,
+	0x0029, 0x6847, 0x0000, 0x694c, 0xc1c5, 0x694e, 0x1078, 0x4a73,
+	0x1078, 0x8eb9, 0x0d7f, 0x1078, 0x772d, 0x1078, 0x62d1, 0x007c,
+	0xa186, 0x0014, 0x00c0, 0x8171, 0x6004, 0xa082, 0x0040, 0x0079,
+	0x8199, 0xa186, 0x0046, 0x0040, 0x817d, 0xa186, 0x0045, 0x0040,
+	0x817d, 0xa186, 0x0047, 0x10c0, 0x1332, 0x2001, 0x0109, 0x2004,
+	0xd084, 0x0040, 0x8196, 0x127e, 0x2091, 0x2200, 0x007e, 0x017e,
+	0x027e, 0x1078, 0x5c56, 0x027f, 0x017f, 0x007f, 0x127f, 0x6000,
+	0xa086, 0x0002, 0x00c0, 0x8196, 0x0078, 0x820e, 0x1078, 0x7773,
+	0x007c, 0x81ae, 0x81ac, 0x81ac, 0x81ac, 0x81ac, 0x81ac, 0x81ac,
+	0x81ac, 0x81ac, 0x81ac, 0x81ac, 0x81ca, 0x81ca, 0x81ca, 0x81ca,
+	0x81ac, 0x81ca, 0x81ac, 0x81ca, 0x1078, 0x1332, 0x1078, 0x61cd,
+	0x0d7e, 0x6110, 0x2168, 0x1078, 0x8d06, 0x0040, 0x81c4, 0x6837,
+	0x0103, 0x684b, 0x0006, 0x6847, 0x0000, 0x6850, 0xc0ec, 0x6852,
+	0x1078, 0x4a73, 0x1078, 0x8eb9, 0x0d7f, 0x1078, 0x772d, 0x1078,
+	0x62d1, 0x007c, 0x1078, 0x61cd, 0x1078, 0x772d, 0x1078, 0x62d1,
+	0x007c, 0x81e6, 0x81e4, 0x81e4, 0x81e4, 0x81e4, 0x81e4, 0x81e4,
+	0x81e4, 0x81e4, 0x81e4, 0x81e4, 0x81f8, 0x81f8, 0x81f8, 0x81f8,
+	0x81e4, 0x8207, 0x81e4, 0x81f8, 0x1078, 0x1332, 0x1078, 0x61cd,
+	0x2001, 0xa8a4, 0x2004, 0x603e, 0x6003, 0x0002, 0x1078, 0x62d1,
+	0x6010, 0xa088, 0x0013, 0x2104, 0xa085, 0x0400, 0x200a, 0x007c,
+	0x1078, 0x61cd, 0x2001, 0xa8a2, 0x2004, 0x6016, 0x2001, 0xa8a4,
+	0x2004, 0x603e, 0x6003, 0x000f, 0x1078, 0x62d1, 0x007c, 0x1078,
+	0x61cd, 0x1078, 0x772d, 0x1078, 0x62d1, 0x007c, 0xa182, 0x0040,
+	0x0079, 0x8212, 0x8225, 0x8225, 0x8225, 0x8225, 0x8225, 0x8227,
+	0x8327, 0x8359, 0x8225, 0x8225, 0x8225, 0x8225, 0x8225, 0x8225,
+	0x8225, 0x8225, 0x8225, 0x8225, 0x8225, 0x1078, 0x1332, 0x0e7e,
+	0x0d7e, 0x603f, 0x0000, 0x2071, 0xab80, 0x7124, 0x610a, 0x2071,
+	0xab8c, 0x6110, 0x2168, 0x7614, 0xa6b4, 0x0fff, 0x86ff, 0x0040,
+	0x82e9, 0xa68c, 0x0c00, 0x0040, 0x825e, 0x0f7e, 0x2c78, 0x1078,
+	0x4963, 0x0f7f, 0x0040, 0x825a, 0x684c, 0xd0ac, 0x0040, 0x825a,
+	0x6024, 0xd0dc, 0x00c0, 0x825a, 0x6850, 0xd0bc, 0x00c0, 0x825a,
+	0x7318, 0x6814, 0xa306, 0x00c0, 0x8301, 0x731c, 0x6810, 0xa306,
+	0x00c0, 0x8301, 0x7318, 0x6b62, 0x731c, 0x6b5e, 0xa68c, 0x00ff,
+	0xa186, 0x0002, 0x0040, 0x8291, 0xa186, 0x0028, 0x00c0, 0x826e,
+	0x1078, 0x8eda, 0x684b, 0x001c, 0x0078, 0x8293, 0xd6dc, 0x0040,
+	0x828a, 0x684b, 0x0015, 0x684c, 0xd0ac, 0x0040, 0x8288, 0x6914,
+	0x6a10, 0x2100, 0xa205, 0x0040, 0x8288, 0x7018, 0xa106, 0x00c0,
+	0x8285, 0x701c, 0xa206, 0x0040, 0x8288, 0x6962, 0x6a5e, 0xc6dc,
+	0x0078, 0x8293, 0xd6d4, 0x0040, 0x8291, 0x684b, 0x0007, 0x0078,
+	0x8293, 0x684b, 0x0000, 0x6837, 0x0103, 0x6e46, 0xa01e, 0xd6c4,
+	0x0040, 0x82bc, 0xa686, 0x0100, 0x00c0, 0x82a7, 0x2001, 0xab99,
+	0x2004, 0xa005, 0x00c0, 0x82a7, 0xc6c4, 0x0078, 0x8236, 0x7328,
+	0x732c, 0x6b56, 0x83ff, 0x0040, 0x82bc, 0xa38a, 0x0009, 0x0048,
+	0x82b3, 0x2019, 0x0008, 0x037e, 0x2308, 0x2019, 0xab98, 0xad90,
+	0x0019, 0x1078, 0x89e2, 0x037f, 0xd6cc, 0x0040, 0x8317, 0x7124,
+	0x695a, 0x81ff, 0x0040, 0x8317, 0xa192, 0x0021, 0x00c8, 0x82d5,
+	0x2071, 0xab98, 0x831c, 0x2300, 0xae18, 0xad90, 0x001d, 0x1078,
+	0x89e2, 0x1078, 0x91f4, 0x0078, 0x8317, 0x6838, 0xd0fc, 0x0040,
+	0x82de, 0x2009, 0x0020, 0x695a, 0x0078, 0x82c8, 0x0f7e, 0x2d78,
+	0x1078, 0x897a, 0x0f7f, 0x1078, 0x91f4, 0x1078, 0x89cf, 0x0078,
+	0x8319, 0x0f7e, 0x2c78, 0x1078, 0x4963, 0x0f7f, 0x0040, 0x8307,
+	0x684c, 0xd0ac, 0x0040, 0x8307, 0x6024, 0xd0dc, 0x00c0, 0x8307,
+	0x6850, 0xd0bc, 0x00c0, 0x8307, 0x6810, 0x6914, 0xa105, 0x0040,
+	0x8307, 0x1078, 0x8fbf, 0x0d7f, 0x0e7f, 0x0078, 0x8326, 0x684b,
+	0x0000, 0x6837, 0x0103, 0x6e46, 0x684c, 0xd0ac, 0x0040, 0x8317,
+	0x6810, 0x6914, 0xa115, 0x0040, 0x8317, 0x1078, 0x84d5, 0x1078,
+	0x4a73, 0x6218, 0x2268, 0x6a3c, 0x8211, 0x6a3e, 0x1078, 0x8f89,
+	0x0d7f, 0x0e7f, 0x00c0, 0x8326, 0x1078, 0x772d, 0x007c, 0x0f7e,
+	0x6003, 0x0003, 0x2079, 0xab8c, 0x7c04, 0x7b00, 0x7e0c, 0x7d08,
+	0x6010, 0x2078, 0x784c, 0xd0ac, 0x0040, 0x833e, 0x6003, 0x0002,
+	0x0f7f, 0x007c, 0x2130, 0x2228, 0x0078, 0x834a, 0x2400, 0x797c,
+	0xa10a, 0x2300, 0x7a80, 0xa213, 0x2600, 0xa102, 0x2500, 0xa203,
+	0x0048, 0x833a, 0x7c12, 0x7b16, 0x7e0a, 0x7d0e, 0x0f7f, 0x603f,
+	0x0000, 0x2c10, 0x1078, 0x1cf0, 0x1078, 0x5df6, 0x1078, 0x639b,
+	0x007c, 0x2001, 0xa8a4, 0x2004, 0x603e, 0x6003, 0x0004, 0x6110,
+	0x20e1, 0x0005, 0x3d18, 0x3e20, 0x2c10, 0x1078, 0x15fa, 0x007c,
+	0xa182, 0x0040, 0x0079, 0x836c, 0x837f, 0x837f, 0x837f, 0x837f,
+	0x837f, 0x8381, 0x8424, 0x837f, 0x837f, 0x843a, 0x84ab, 0x837f,
+	0x837f, 0x837f, 0x837f, 0x84ba, 0x837f, 0x837f, 0x837f, 0x1078,
+	0x1332, 0x077e, 0x0f7e, 0x0e7e, 0x0d7e, 0x2071, 0xab8c, 0x6110,
+	0x2178, 0x7614, 0xa6b4, 0x0fff, 0x7e46, 0x7f4c, 0xc7e5, 0x7f4e,
+	0x6218, 0x2268, 0x6a3c, 0x8211, 0x6a3e, 0x86ff, 0x0040, 0x841f,
+	0xa694, 0xff00, 0xa284, 0x0c00, 0x0040, 0x83a2, 0x7018, 0x7862,
+	0x701c, 0x785e, 0xa284, 0x0300, 0x0040, 0x841f, 0x1078, 0x138b,
+	0x1040, 0x1332, 0x2d00, 0x784a, 0x7f4c, 0xc7cd, 0x7f4e, 0x6837,
+	0x0103, 0x7838, 0x683a, 0x783c, 0x683e, 0x7840, 0x6842, 0x6e46,
+	0xa68c, 0x0c00, 0x0040, 0x83c0, 0x7318, 0x6b62, 0x731c, 0x6b5e,
+	0xa68c, 0x00ff, 0xa186, 0x0002, 0x0040, 0x83dc, 0xa186, 0x0028,
+	0x00c0, 0x83ce, 0x684b, 0x001c, 0x0078, 0x83de, 0xd6dc, 0x0040,
+	0x83d5, 0x684b, 0x0015, 0x0078, 0x83de, 0xd6d4, 0x0040, 0x83dc,
+	0x684b, 0x0007, 0x0078, 0x83de, 0x684b, 0x0000, 0x6f4e, 0x7850,
+	0x6852, 0x7854, 0x6856, 0xa01e, 0xd6c4, 0x0040, 0x83fc, 0x7328,
+	0x732c, 0x6b56, 0x83ff, 0x0040, 0x83fc, 0xa38a, 0x0009, 0x0048,
+	0x83f3, 0x2019, 0x0008, 0x037e, 0x2308, 0x2019, 0xab98, 0xad90,
+	0x0019, 0x1078, 0x89e2, 0x037f, 0xd6cc, 0x0040, 0x841f, 0x7124,
+	0x695a, 0x81ff, 0x0040, 0x841f, 0xa192, 0x0021, 0x00c8, 0x8413,
+	0x2071, 0xab98, 0x831c, 0x2300, 0xae18, 0xad90, 0x001d, 0x1078,
+	0x89e2, 0x0078, 0x841f, 0x7838, 0xd0fc, 0x0040, 0x841c, 0x2009,
+	0x0020, 0x695a, 0x0078, 0x8408, 0x2d78, 0x1078, 0x897a, 0x0d7f,
+	0x0e7f, 0x0f7f, 0x077f, 0x007c, 0x0f7e, 0x6003, 0x0003, 0x2079,
+	0xab8c, 0x7c04, 0x7b00, 0x7e0c, 0x7d08, 0x6010, 0x2078, 0x7c12,
+	0x7b16, 0x7e0a, 0x7d0e, 0x0f7f, 0x2c10, 0x1078, 0x1cf0, 0x1078,
+	0x6df4, 0x007c, 0x0d7e, 0x0f7e, 0x2c78, 0x1078, 0x4963, 0x0f7f,
+	0x0040, 0x8446, 0x2001, 0xa8a4, 0x2004, 0x603e, 0x6003, 0x0002,
+	0x1078, 0x627a, 0x1078, 0x639b, 0x6110, 0x2168, 0x694c, 0xd1e4,
+	0x0040, 0x84a9, 0xd1cc, 0x0040, 0x8480, 0x6948, 0x6838, 0xd0fc,
+	0x0040, 0x8478, 0x017e, 0x684c, 0x007e, 0x6850, 0x007e, 0xad90,
+	0x000d, 0xa198, 0x000d, 0x2009, 0x0020, 0x157e, 0x21a8, 0x2304,
+	0x2012, 0x8318, 0x8210, 0x00f0, 0x8467, 0x157f, 0x007f, 0x6852,
+	0x007f, 0x684e, 0x017f, 0x2168, 0x1078, 0x13b4, 0x0078, 0x84a3,
+	0x017e, 0x1078, 0x13b4, 0x0d7f, 0x1078, 0x89cf, 0x0078, 0x84a3,
+	0x6837, 0x0103, 0x6944, 0xa184, 0x00ff, 0xa0b6, 0x0002, 0x0040,
+	0x849f, 0xa086, 0x0028, 0x00c0, 0x8491, 0x684b, 0x001c, 0x0078,
+	0x84a1, 0xd1dc, 0x0040, 0x8498, 0x684b, 0x0015, 0x0078, 0x84a1,
+	0xd1d4, 0x0040, 0x849f, 0x684b, 0x0007, 0x0078, 0x84a1, 0x684b,
+	0x0000, 0x1078, 0x4a73, 0x1078, 0x8f89, 0x00c0, 0x84a9, 0x1078,
+	0x772d, 0x0d7f, 0x007c, 0x2019, 0x0001, 0x1078, 0x7058, 0x6003,
+	0x0002, 0x2001, 0xa8a4, 0x2004, 0x603e, 0x1078, 0x627a, 0x1078,
+	0x639b, 0x007c, 0x1078, 0x627a, 0x1078, 0x2880, 0x0d7e, 0x6110,
+	0x2168, 0x1078, 0x8d06, 0x0040, 0x84cf, 0x6837, 0x0103, 0x684b,
+	0x0029, 0x6847, 0x0000, 0x1078, 0x4a73, 0x1078, 0x8eb9, 0x0d7f,
+	0x1078, 0x772d, 0x1078, 0x639b, 0x007c, 0x684b, 0x0015, 0xd1fc,
+	0x0040, 0x84e1, 0x684b, 0x0007, 0x8002, 0x8000, 0x810a, 0xa189,
+	0x0000, 0x6962, 0x685e, 0x007c, 0xa182, 0x0040, 0x0079, 0x84e8,
+	0x84fb, 0x84fb, 0x84fb, 0x84fb, 0x84fb, 0x84fd, 0x84fb, 0x85d0,
+	0x85dc, 0x84fb, 0x84fb, 0x84fb, 0x84fb, 0x84fb, 0x84fb, 0x84fb,
+	0x84fb, 0x84fb, 0x84fb, 0x1078, 0x1332, 0x077e, 0x0f7e, 0x0e7e,
+	0x0d7e, 0x2071, 0xab8c, 0x6110, 0x2178, 0x7614, 0xa6b4, 0x0fff,
+	0x0f7e, 0x2c78, 0x1078, 0x4963, 0x0f7f, 0x0040, 0x851b, 0xa684,
+	0x00ff, 0x00c0, 0x851b, 0x6024, 0xd0f4, 0x0040, 0x851b, 0x1078,
+	0x8fbf, 0x0078, 0x85cb, 0x7e46, 0x7f4c, 0xc7e5, 0x7f4e, 0x6218,
+	0x2268, 0x6a3c, 0x8211, 0x6a3e, 0x86ff, 0x0040, 0x85c0, 0xa694,
+	0xff00, 0xa284, 0x0c00, 0x0040, 0x8531, 0x7018, 0x7862, 0x701c,
+	0x785e, 0xa284, 0x0300, 0x0040, 0x85bd, 0xa686, 0x0100, 0x00c0,
+	0x8543, 0x2001, 0xab99, 0x2004, 0xa005, 0x00c0, 0x8543, 0xc6c4,
+	0x7e46, 0x0078, 0x8524, 0x1078, 0x138b, 0x1040, 0x1332, 0x2d00,
+	0x784a, 0x7f4c, 0xa7bd, 0x0200, 0x7f4e, 0x6837, 0x0103, 0x7838,
+	0x683a, 0x783c, 0x683e, 0x7840, 0x6842, 0x6e46, 0xa68c, 0x0c00,
+	0x0040, 0x855e, 0x7318, 0x6b62, 0x731c, 0x6b5e, 0xa68c, 0x00ff,
+	0xa186, 0x0002, 0x0040, 0x857a, 0xa186, 0x0028, 0x00c0, 0x856c,
+	0x684b, 0x001c, 0x0078, 0x857c, 0xd6dc, 0x0040, 0x8573, 0x684b,
+	0x0015, 0x0078, 0x857c, 0xd6d4, 0x0040, 0x857a, 0x684b, 0x0007,
+	0x0078, 0x857c, 0x684b, 0x0000, 0x6f4e, 0x7850, 0x6852, 0x7854,
+	0x6856, 0xa01e, 0xd6c4, 0x0040, 0x859a, 0x7328, 0x732c, 0x6b56,
+	0x83ff, 0x0040, 0x859a, 0xa38a, 0x0009, 0x0048, 0x8591, 0x2019,
+	0x0008, 0x037e, 0x2308, 0x2019, 0xab98, 0xad90, 0x0019, 0x1078,
+	0x89e2, 0x037f, 0xd6cc, 0x0040, 0x85bd, 0x7124, 0x695a, 0x81ff,
+	0x0040, 0x85bd, 0xa192, 0x0021, 0x00c8, 0x85b1, 0x2071, 0xab98,
+	0x831c, 0x2300, 0xae18, 0xad90, 0x001d, 0x1078, 0x89e2, 0x0078,
+	0x85bd, 0x7838, 0xd0fc, 0x0040, 0x85ba, 0x2009, 0x0020, 0x695a,
+	0x0078, 0x85a6, 0x2d78, 0x1078, 0x897a, 0xd6dc, 0x00c0, 0x85c3,
+	0xa006, 0x0078, 0x85c9, 0x2001, 0x0001, 0x2071, 0xab8c, 0x7218,
+	0x731c, 0x1078, 0x1653, 0x0d7f, 0x0e7f, 0x0f7f, 0x077f, 0x007c,
+	0x2001, 0xa8a4, 0x2004, 0x603e, 0x20e1, 0x0005, 0x3d18, 0x3e20,
+	0x2c10, 0x1078, 0x15fa, 0x007c, 0x2001, 0xa8a4, 0x2004, 0x603e,
+	0x0d7e, 0x6003, 0x0002, 0x6110, 0x2168, 0x694c, 0xd1e4, 0x0040,
+	0x870c, 0x603f, 0x0000, 0x0f7e, 0x2c78, 0x1078, 0x4963, 0x0f7f,
+	0x0040, 0x8622, 0x6814, 0x6910, 0xa115, 0x0040, 0x8622, 0x6a60,
+	0xa206, 0x00c0, 0x85ff, 0x685c, 0xa106, 0x0040, 0x8622, 0x684c,
+	0xc0e4, 0x684e, 0x6847, 0x0000, 0x6863, 0x0000, 0x685f, 0x0000,
+	0x6024, 0xd0f4, 0x00c0, 0x8617, 0x697c, 0x6810, 0xa102, 0x603a,
+	0x6980, 0x6814, 0xa103, 0x6036, 0x6024, 0xc0f5, 0x6026, 0x0d7e,
+	0x6018, 0x2068, 0x683c, 0x8000, 0x683e, 0x0d7f, 0x1078, 0x8fbf,
+	0x0078, 0x870c, 0x694c, 0xd1cc, 0x0040, 0x86d1, 0x6948, 0x6838,
+	0xd0fc, 0x0040, 0x8689, 0x017e, 0x684c, 0x007e, 0x6850, 0x007e,
+	0x0f7e, 0x2178, 0x7944, 0xa184, 0x00ff, 0xa0b6, 0x0002, 0x0040,
+	0x865c, 0xa086, 0x0028, 0x00c0, 0x8643, 0x684b, 0x001c, 0x784b,
+	0x001c, 0x0078, 0x8667, 0xd1dc, 0x0040, 0x8653, 0x684b, 0x0015,
+	0x784b, 0x0015, 0x1078, 0x916c, 0x0040, 0x8651, 0x7944, 0xc1dc,
+	0x7946, 0x0078, 0x8667, 0xd1d4, 0x0040, 0x865c, 0x684b, 0x0007,
+	0x784b, 0x0007, 0x0078, 0x8667, 0x684c, 0xd0ac, 0x0040, 0x8667,
+	0x6810, 0x6914, 0xa115, 0x0040, 0x8667, 0x1078, 0x84d5, 0x6848,
+	0x784a, 0x6860, 0x7862, 0x685c, 0x785e, 0xad90, 0x000d, 0xaf98,
+	0x000d, 0x2009, 0x0020, 0x157e, 0x21a8, 0x2304, 0x2012, 0x8318,
+	0x8210, 0x00f0, 0x8675, 0x157f, 0x0f7f, 0x007f, 0x6852, 0x007f,
+	0x684e, 0x1078, 0x91f4, 0x017f, 0x2168, 0x1078, 0x13b4, 0x0078,
+	0x8706, 0x017e, 0x0f7e, 0x2178, 0x7944, 0xa184, 0x00ff, 0xa0b6,
+	0x0002, 0x0040, 0x86b6, 0xa086, 0x0028, 0x00c0, 0x869d, 0x684b,
+	0x001c, 0x784b, 0x001c, 0x0078, 0x86c1, 0xd1dc, 0x0040, 0x86ad,
+	0x684b, 0x0015, 0x784b, 0x0015, 0x1078, 0x916c, 0x0040, 0x86ab,
+	0x7944, 0xc1dc, 0x7946, 0x0078, 0x86c1, 0xd1d4, 0x0040, 0x86b6,
+	0x684b, 0x0007, 0x784b, 0x0007, 0x0078, 0x86c1, 0x684c, 0xd0ac,
+	0x0040, 0x86c1, 0x6810, 0x6914, 0xa115, 0x0040, 0x86c1, 0x1078,
+	0x84d5, 0x6860, 0x7862, 0x685c, 0x785e, 0x684c, 0x784e, 0x0f7f,
+	0x1078, 0x13b4, 0x0d7f, 0x1078, 0x91f4, 0x1078, 0x89cf, 0x0078,
+	0x8706, 0x6837, 0x0103, 0x6944, 0xa184, 0x00ff, 0xa0b6, 0x0002,
+	0x0040, 0x86f7, 0xa086, 0x0028, 0x00c0, 0x86e2, 0x684b, 0x001c,
+	0x0078, 0x8704, 0xd1dc, 0x0040, 0x86f0, 0x684b, 0x0015, 0x1078,
+	0x916c, 0x0040, 0x86ee, 0x6944, 0xc1dc, 0x6946, 0x0078, 0x8704,
+	0xd1d4, 0x0040, 0x86f7, 0x684b, 0x0007, 0x0078, 0x8704, 0x684b,
+	0x0000, 0x684c, 0xd0ac, 0x0040, 0x8704, 0x6810, 0x6914, 0xa115,
+	0x0040, 0x8704, 0x1078, 0x84d5, 0x1078, 0x4a73, 0x1078, 0x8f89,
+	0x00c0, 0x870c, 0x1078, 0x772d, 0x0d7f, 0x007c, 0x1078, 0x61cd,
+	0x0078, 0x8714, 0x1078, 0x627a, 0x1078, 0x8d06, 0x0040, 0x8733,
+	0x0d7e, 0x6110, 0x2168, 0x6837, 0x0103, 0x2009, 0xa60c, 0x210c,
+	0xd18c, 0x00c0, 0x873e, 0xd184, 0x00c0, 0x873a, 0x6108, 0x694a,
+	0xa18e, 0x0029, 0x00c0, 0x872e, 0x1078, 0xa4e2, 0x6847, 0x0000,
+	0x1078, 0x4a73, 0x0d7f, 0x1078, 0x772d, 0x1078, 0x62d1, 0x1078,
+	0x639b, 0x007c, 0x684b, 0x0004, 0x0078, 0x872e, 0x684b, 0x0004,
+	0x0078, 0x872e, 0xa182, 0x0040, 0x0079, 0x8746, 0x8759, 0x8759,
+	0x8759, 0x8759, 0x8759, 0x875b, 0x8759, 0x875e, 0x8759, 0x8759,
+	0x8759, 0x8759, 0x8759, 0x8759, 0x8759, 0x8759, 0x8759, 0x8759,
+	0x8759, 0x1078, 0x1332, 0x1078, 0x772d, 0x007c, 0x007e, 0x027e,
+	0xa016, 0x1078, 0x15fa, 0x027f, 0x007f, 0x007c, 0xa182, 0x0085,
+	0x0079, 0x876a, 0x8773, 0x8771, 0x8771, 0x877f, 0x8771, 0x8771,
+	0x8771, 0x1078, 0x1332, 0x6003, 0x0001, 0x6106, 0x1078, 0x5d8a,
+	0x127e, 0x2091, 0x8000, 0x1078, 0x62d1, 0x127f, 0x007c, 0x027e,
+	0x057e, 0x0d7e, 0x0e7e, 0x2071, 0xab80, 0x7224, 0x6212, 0x7220,
+	0x1078, 0x8cf2, 0x0040, 0x87a4, 0x2268, 0x6800, 0xa086, 0x0000,
+	0x0040, 0x87a4, 0x6018, 0x6d18, 0xa52e, 0x00c0, 0x87a4, 0x0c7e,
+	0x2d60, 0x1078, 0x89f3, 0x0c7f, 0x0040, 0x87a4, 0x6803, 0x0002,
+	0x6007, 0x0086, 0x0078, 0x87a6, 0x6007, 0x0087, 0x6003, 0x0001,
+	0x1078, 0x5d8a, 0x1078, 0x62d1, 0x0f7e, 0x2278, 0x1078, 0x4963,
+	0x0f7f, 0x0040, 0x87be, 0x6824, 0xd0ec, 0x0040, 0x87be, 0x0c7e,
+	0x2260, 0x603f, 0x0000, 0x1078, 0x8fbf, 0x0c7f, 0x0e7f, 0x0d7f,
+	0x057f, 0x027f, 0x007c, 0xa186, 0x0013, 0x00c0, 0x87d4, 0x6004,
+	0xa08a, 0x0085, 0x1048, 0x1332, 0xa08a, 0x008c, 0x10c8, 0x1332,
+	0xa082, 0x0085, 0x0079, 0x87e3, 0xa186, 0x0027, 0x0040, 0x87dc,
+	0xa186, 0x0014, 0x10c0, 0x1332, 0x1078, 0x61cd, 0x1078, 0x8ec6,
+	0x1078, 0x62d1, 0x007c, 0x87ea, 0x87ec, 0x87ec, 0x87ea, 0x87ea,
+	0x87ea, 0x87ea, 0x1078, 0x1332, 0x1078, 0x61cd, 0x1078, 0x8ec6,
+	0x1078, 0x62d1, 0x007c, 0xa186, 0x0013, 0x00c0, 0x87fd, 0x6004,
+	0xa082, 0x0085, 0x2008, 0x0078, 0x8838, 0xa186, 0x0027, 0x00c0,
+	0x8820, 0x1078, 0x61cd, 0x1078, 0x2880, 0x0d7e, 0x6010, 0x2068,
+	0x1078, 0x8d06, 0x0040, 0x8816, 0x6837, 0x0103, 0x6847, 0x0000,
+	0x684b, 0x0029, 0x1078, 0x4a73, 0x1078, 0x8eb9, 0x0d7f, 0x1078,
+	0x772d, 0x1078, 0x62d1, 0x007c, 0x1078, 0x7773, 0x0078, 0x881b,
+	0xa186, 0x0014, 0x00c0, 0x881c, 0x1078, 0x61cd, 0x0d7e, 0x6010,
+	0x2068, 0x1078, 0x8d06, 0x0040, 0x8816, 0x6837, 0x0103, 0x6847,
+	0x0000, 0x684b, 0x0006, 0x6850, 0xc0ec, 0x6852, 0x0078, 0x8812,
+	0x0079, 0x883a, 0x8843, 0x8841, 0x8841, 0x8841, 0x8841, 0x8841,
+	0x885e, 0x1078, 0x1332, 0x1078, 0x61cd, 0x6030, 0xa08c, 0xff00,
+	0x810f, 0xa186, 0x0039, 0x0040, 0x8851, 0xa186, 0x0035, 0x00c0,
+	0x8855, 0x2001, 0xa8a2, 0x0078, 0x8857, 0x2001, 0xa8a3, 0x2004,
+	0x6016, 0x6003, 0x000c, 0x1078, 0x62d1, 0x007c, 0x1078, 0x61cd,
+	0x6030, 0xa08c, 0xff00, 0x810f, 0xa186, 0x0039, 0x0040, 0x886c,
+	0xa186, 0x0035, 0x00c0, 0x8870, 0x2001, 0xa8a2, 0x0078, 0x8872,
+	0x2001, 0xa8a3, 0x2004, 0x6016, 0x6003, 0x000e, 0x1078, 0x62d1,
+	0x007c, 0xa182, 0x008c, 0x00c8, 0x8883, 0xa182, 0x0085, 0x0048,
+	0x8883, 0x0079, 0x8886, 0x1078, 0x7773, 0x007c, 0x888d, 0x888d,
+	0x888d, 0x888d, 0x888f, 0x88ec, 0x888d, 0x1078, 0x1332, 0x0f7e,
+	0x2c78, 0x1078, 0x4963, 0x0f7f, 0x0040, 0x88a2, 0x6030, 0xa08c,
+	0xff00, 0x810f, 0xa186, 0x0039, 0x0040, 0x8903, 0xa186, 0x0035,
+	0x0040, 0x8903, 0x0d7e, 0x1078, 0x8d06, 0x00c0, 0x88ab, 0x1078,
+	0x8eb9, 0x0078, 0x88ce, 0x6010, 0x2068, 0x684c, 0xd0e4, 0x00c0,
+	0x88b3, 0x1078, 0x8eb9, 0x6837, 0x0103, 0x6850, 0xd0b4, 0x0040,
+	0x88bf, 0x684b, 0x0006, 0xc0ec, 0x6852, 0x0078, 0x88ca, 0xd0bc,
+	0x0040, 0x88c6, 0x684b, 0x0002, 0x0078, 0x88ca, 0x684b, 0x0005,
+	0x1078, 0x8f85, 0x6847, 0x0000, 0x1078, 0x4a73, 0x2c68, 0x1078,
+	0x76c7, 0x0040, 0x88e7, 0x6003, 0x0001, 0x6007, 0x001e, 0x2009,
+	0xab8e, 0x210c, 0x6136, 0x2009, 0xab8f, 0x210c, 0x613a, 0x6918,
+	0x611a, 0x6920, 0x6122, 0x601f, 0x0001, 0x1078, 0x5d8a, 0x2d60,
+	0x1078, 0x772d, 0x0d7f, 0x007c, 0x0f7e, 0x2c78, 0x1078, 0x4963,
+	0x0f7f, 0x0040, 0x8929, 0x6030, 0xa08c, 0xff00, 0x810f, 0xa186,
+	0x0035, 0x0040, 0x8903, 0xa186, 0x001e, 0x0040, 0x8903, 0xa186,
+	0x0039, 0x00c0, 0x8929, 0x0d7e, 0x2c68, 0x1078, 0x91bc, 0x00c0,
+	0x894d, 0x1078, 0x76c7, 0x0040, 0x8926, 0x6106, 0x6003, 0x0001,
+	0x601f, 0x0001, 0x6918, 0x611a, 0x6928, 0x612a, 0x692c, 0x612e,
+	0x6930, 0xa18c, 0x00ff, 0x6132, 0x6934, 0x6136, 0x6938, 0x613a,
+	0x6920, 0x6122, 0x1078, 0x5d8a, 0x1078, 0x62d1, 0x2d60, 0x0078,
+	0x894d, 0x0d7e, 0x6010, 0x2068, 0x1078, 0x8d06, 0x0040, 0x894d,
+	0x6837, 0x0103, 0x6850, 0xd0b4, 0x0040, 0x893c, 0xc0ec, 0x6852,
+	0x684b, 0x0006, 0x0078, 0x8947, 0xd0bc, 0x0040, 0x8943, 0x684b,
+	0x0002, 0x0078, 0x8947, 0x684b, 0x0005, 0x1078, 0x8f85, 0x6847,
+	0x0000, 0x1078, 0x4a73, 0x1078, 0x8eb9, 0x0d7f, 0x1078, 0x772d,
+	0x007c, 0x017e, 0x0d7e, 0x6010, 0x2068, 0x1078, 0x8d06, 0x0040,
+	0x8961, 0x6837, 0x0103, 0x684b, 0x0028, 0x6847, 0x0000, 0x1078,
+	0x4a73, 0x0d7f, 0x017f, 0xa186, 0x0013, 0x0040, 0x8973, 0xa186,
+	0x0014, 0x0040, 0x8973, 0xa186, 0x0027, 0x0040, 0x8973, 0x1078,
+	0x7773, 0x0078, 0x8979, 0x1078, 0x61cd, 0x1078, 0x8ec6, 0x1078,
+	0x62d1, 0x007c, 0x057e, 0x067e, 0x0d7e, 0x0f7e, 0x2029, 0x0001,
+	0xa182, 0x0101, 0x00c8, 0x8986, 0x0078, 0x8988, 0x2009, 0x0100,
+	0x2130, 0x2069, 0xab98, 0x831c, 0x2300, 0xad18, 0x2009, 0x0020,
+	0xaf90, 0x001d, 0x1078, 0x89e2, 0xa6b2, 0x0020, 0x7804, 0xa06d,
+	0x0040, 0x899c, 0x1078, 0x13b4, 0x1078, 0x138b, 0x0040, 0x89c6,
+	0x8528, 0x6837, 0x0110, 0x683b, 0x0000, 0x2d20, 0x7c06, 0xa68a,
+	0x003d, 0x00c8, 0x89b2, 0x2608, 0xad90, 0x000f, 0x1078, 0x89e2,
+	0x0078, 0x89c6, 0xa6b2, 0x003c, 0x2009, 0x003c, 0x2d78, 0xad90,
+	0x000f, 0x1078, 0x89e2, 0x0078, 0x899c, 0x0f7f, 0x852f, 0xa5ad,
+	0x0003, 0x7d36, 0xa5ac, 0x0000, 0x0078, 0x89cb, 0x0f7f, 0x852f,
+	0xa5ad, 0x0003, 0x7d36, 0x0d7f, 0x067f, 0x057f, 0x007c, 0x0f7e,
+	0x8dff, 0x0040, 0x89e0, 0x6804, 0xa07d, 0x0040, 0x89de, 0x6807,
+	0x0000, 0x1078, 0x4a73, 0x2f68, 0x0078, 0x89d3, 0x1078, 0x4a73,
+	0x0f7f, 0x007c, 0x157e, 0xa184, 0x0001, 0x0040, 0x89e8, 0x8108,
+	0x810c, 0x21a8, 0x2304, 0x8007, 0x2012, 0x8318, 0x8210, 0x00f0,
+	0x89ea, 0x157f, 0x007c, 0x067e, 0x127e, 0x2091, 0x8000, 0x2031,
+	0x0001, 0x601c, 0xa084, 0x000f, 0x1079, 0x8a0f, 0x127f, 0x067f,
+	0x007c, 0x127e, 0x2091, 0x8000, 0x067e, 0x2031, 0x0000, 0x601c,
+	0xa084, 0x000f, 0x1079, 0x8a0f, 0x067f, 0x127f, 0x007c, 0x8a29,
+	0x8a17, 0x8a24, 0x8a45, 0x8a17, 0x8a24, 0x8a45, 0x8a24, 0x1078,
+	0x1332, 0x037e, 0x2019, 0x0010, 0x1078, 0x9dc7, 0x601f, 0x0006,
+	0x6003, 0x0007, 0x037f, 0x007c, 0xa006, 0x007c, 0xa085, 0x0001,
+	0x007c, 0x0d7e, 0x86ff, 0x00c0, 0x8a40, 0x6010, 0x2068, 0x1078,
+	0x8d06, 0x0040, 0x8a42, 0xa00e, 0x2001, 0x0005, 0x1078, 0x4b51,
+	0x1078, 0x8f85, 0x1078, 0x4a73, 0x1078, 0x772d, 0xa085, 0x0001,
+	0x0d7f, 0x007c, 0xa006, 0x0078, 0x8a40, 0x6000, 0xa08a, 0x0010,
+	0x10c8, 0x1332, 0x1079, 0x8a4d, 0x007c, 0x8a5d, 0x8a82, 0x8a5f,
+	0x8aa5, 0x8a7e, 0x8a5d, 0x8a24, 0x8a29, 0x8a29, 0x8a24, 0x8a24,
+	0x8a24, 0x8a24, 0x8a24, 0x8a24, 0x8a24, 0x1078, 0x1332, 0x86ff,
+	0x00c0, 0x8a7b, 0x601c, 0xa086, 0x0006, 0x0040, 0x8a7b, 0x0d7e,
+	0x6010, 0x2068, 0x1078, 0x8d06, 0x0040, 0x8a70, 0x1078, 0x8f85,
+	0x0d7f, 0x6007, 0x0085, 0x6003, 0x000b, 0x601f, 0x0002, 0x1078,
+	0x5d8a, 0x1078, 0x62d1, 0xa085, 0x0001, 0x007c, 0x1078, 0x1757,
+	0x0078, 0x8a5f, 0x0e7e, 0x2071, 0xa8b1, 0x7024, 0xac06, 0x00c0,
+	0x8a8b, 0x1078, 0x6fc4, 0x601c, 0xa084, 0x000f, 0xa086, 0x0006,
+	0x00c0, 0x8a9d, 0x087e, 0x097e, 0x2049, 0x0001, 0x2c40, 0x1078,
+	0x7246, 0x097f, 0x087f, 0x0078, 0x8a9f, 0x1078, 0x6ebe, 0x0e7f,
+	0x00c0, 0x8a5f, 0x1078, 0x8a24, 0x007c, 0x037e, 0x0e7e, 0x2071,
+	0xa8b1, 0x703c, 0xac06, 0x00c0, 0x8ab5, 0x2019, 0x0000, 0x1078,
+	0x7058, 0x0e7f, 0x037f, 0x0078, 0x8a5f, 0x1078, 0x738a, 0x0e7f,
+	0x037f, 0x00c0, 0x8a5f, 0x1078, 0x8a24, 0x007c, 0x0c7e, 0x601c,
+	0xa084, 0x000f, 0x1079, 0x8ac6, 0x0c7f, 0x007c, 0x8ad5, 0x8b47,
+	0x8c7f, 0x8ae0, 0x8ec6, 0x8ad5, 0x9db8, 0x772d, 0x8b47, 0x1078,
+	0x8f00, 0x00c0, 0x8ad5, 0x1078, 0x7c83, 0x007c, 0x1078, 0x61cd,
+	0x1078, 0x62d1, 0x1078, 0x772d, 0x007c, 0x6017, 0x0001, 0x007c,
+	0x1078, 0x8d06, 0x0040, 0x8ae8, 0x6010, 0xa080, 0x0019, 0x2c02,
+	0x6000, 0xa08a, 0x0010, 0x10c8, 0x1332, 0x1079, 0x8af0, 0x007c,
+	0x8b00, 0x8b02, 0x8b24, 0x8b36, 0x8b43, 0x8b00, 0x8ad5, 0x8ad5,
+	0x8ad5, 0x8b36, 0x8b36, 0x8b00, 0x8b00, 0x8b00, 0x8b00, 0x8b40,
+	0x1078, 0x1332, 0x0e7e, 0x6010, 0x2070, 0x7050, 0xc0b5, 0x7052,
+	0x2071, 0xa8b1, 0x7024, 0xac06, 0x0040, 0x8b20, 0x1078, 0x6ebe,
+	0x6007, 0x0085, 0x6003, 0x000b, 0x601f, 0x0002, 0x2001, 0xa8a3,
+	0x2004, 0x6016, 0x1078, 0x5d8a, 0x1078, 0x62d1, 0x0e7f, 0x007c,
+	0x6017, 0x0001, 0x0078, 0x8b1e, 0x0d7e, 0x6010, 0x2068, 0x6850,
+	0xc0b5, 0x6852, 0x0d7f, 0x6007, 0x0085, 0x6003, 0x000b, 0x601f,
+	0x0002, 0x1078, 0x5d8a, 0x1078, 0x62d1, 0x007c, 0x0d7e, 0x6017,
+	0x0001, 0x6010, 0x2068, 0x6850, 0xc0b5, 0x6852, 0x0d7f, 0x007c,
+	0x1078, 0x772d, 0x007c, 0x1078, 0x1757, 0x0078, 0x8b24, 0x6000,
+	0xa08a, 0x0010, 0x10c8, 0x1332, 0x1079, 0x8b4f, 0x007c, 0x8b5f,
+	0x8add, 0x8b61, 0x8b5f, 0x8b61, 0x8b61, 0x8ad6, 0x8b5f, 0x8acf,
+	0x8acf, 0x8b5f, 0x8b5f, 0x8b5f, 0x8b5f, 0x8b5f, 0x8b5f, 0x1078,
+	0x1332, 0x0d7e, 0x6018, 0x2068, 0x6804, 0xa084, 0x00ff, 0x0d7f,
+	0xa08a, 0x000c, 0x10c8, 0x1332, 0x1079, 0x8b6f, 0x007c, 0x8b7b,
+	0x8c23, 0x8b7d, 0x8bbd, 0x8b7d, 0x8bbd, 0x8b7d, 0x8b8a, 0x8b7b,
+	0x8bbd, 0x8b7b, 0x8ba7, 0x1078, 0x1332, 0x6004, 0xa08e, 0x0016,
+	0x0040, 0x8bb8, 0xa08e, 0x0004, 0x0040, 0x8bb8, 0xa08e, 0x0002,
+	0x0040, 0x8bb8, 0x6004, 0x1078, 0x8f00, 0x0040, 0x8c3e, 0xa08e,
+	0x0021, 0x0040, 0x8c42, 0xa08e, 0x0022, 0x0040, 0x8c3e, 0xa08e,
+	0x003d, 0x0040, 0x8c42, 0xa08e, 0x0039, 0x0040, 0x8c46, 0xa08e,
+	0x0035, 0x0040, 0x8c46, 0xa08e, 0x001e, 0x0040, 0x8bba, 0xa08e,
+	0x0001, 0x00c0, 0x8bb6, 0x0d7e, 0x6018, 0x2068, 0x6804, 0xa084,
+	0x00ff, 0x0d7f, 0xa086, 0x0006, 0x0040, 0x8bb8, 0x1078, 0x2880,
+	0x1078, 0x7c83, 0x1078, 0x8ec6, 0x007c, 0x0c7e, 0x0d7e, 0x6104,
+	0xa186, 0x0016, 0x0040, 0x8c13, 0xa186, 0x0002, 0x00c0, 0x8be6,
+	0x6018, 0x2068, 0x68a0, 0xd0bc, 0x00c0, 0x8c6a, 0x6840, 0xa084,
+	0x00ff, 0xa005, 0x0040, 0x8be6, 0x8001, 0x6842, 0x6013, 0x0000,
+	0x601f, 0x0007, 0x6017, 0x0398, 0x1078, 0x76c7, 0x0040, 0x8be6,
+	0x2d00, 0x601a, 0x601f, 0x0001, 0x0078, 0x8c13, 0x0d7f, 0x0c7f,
+	0x6004, 0xa08e, 0x0002, 0x00c0, 0x8c04, 0x6018, 0xa080, 0x0028,
+	0x2004, 0xa086, 0x007e, 0x00c0, 0x8c04, 0x2009, 0xa633, 0x2104,
+	0xc085, 0x200a, 0x0e7e, 0x2071, 0xa600, 0x1078, 0x42b8, 0x0e7f,
+	0x1078, 0x7c83, 0x0078, 0x8c08, 0x1078, 0x7c83, 0x1078, 0x2880,
+	0x0e7e, 0x127e, 0x2091, 0x8000, 0x1078, 0x28a6, 0x127f, 0x0e7f,
+	0x1078, 0x8ec6, 0x007c, 0x2001, 0x0002, 0x1078, 0x4502, 0x6003,
+	0x0001, 0x6007, 0x0002, 0x1078, 0x5dd7, 0x1078, 0x62d1, 0x0d7f,
+	0x0c7f, 0x0078, 0x8c12, 0x0c7e, 0x0d7e, 0x6104, 0xa186, 0x0016,
+	0x0040, 0x8c13, 0x6018, 0x2068, 0x6840, 0xa084, 0x00ff, 0xa005,
+	0x0040, 0x8be6, 0x8001, 0x6842, 0x6003, 0x0001, 0x1078, 0x5dd7,
+	0x1078, 0x62d1, 0x0d7f, 0x0c7f, 0x0078, 0x8c12, 0x1078, 0x7c83,
+	0x0078, 0x8bba, 0x1078, 0x7ca6, 0x0078, 0x8bba, 0x0d7e, 0x2c68,
+	0x6104, 0x1078, 0x91bc, 0x0d7f, 0x0040, 0x8c52, 0x1078, 0x772d,
+	0x0078, 0x8c69, 0x6004, 0x8007, 0x6130, 0xa18c, 0x00ff, 0xa105,
+	0x6032, 0x6007, 0x0085, 0x6003, 0x000b, 0x601f, 0x0002, 0x6038,
+	0x600a, 0x2001, 0xa8a3, 0x2004, 0x6016, 0x1078, 0x5d8a, 0x1078,
+	0x62d1, 0x007c, 0x0d7f, 0x0c7f, 0x1078, 0x7c83, 0x1078, 0x2880,
+	0x0e7e, 0x127e, 0x2091, 0x8000, 0x1078, 0x28a6, 0x6013, 0x0000,
+	0x601f, 0x0007, 0x6017, 0x0398, 0x127f, 0x0e7f, 0x007c, 0x6000,
+	0xa08a, 0x0010, 0x10c8, 0x1332, 0x1079, 0x8c87, 0x007c, 0x8c97,
+	0x8c97, 0x8c97, 0x8c97, 0x8c97, 0x8c97, 0x8c97, 0x8c97, 0x8c97,
+	0x8ad5, 0x8c97, 0x8add, 0x8c99, 0x8add, 0x8ca7, 0x8c97, 0x1078,
+	0x1332, 0x6004, 0xa086, 0x008b, 0x0040, 0x8ca7, 0x6007, 0x008b,
+	0x6003, 0x000d, 0x1078, 0x5d8a, 0x1078, 0x62d1, 0x007c, 0x1078,
+	0x8eb9, 0x1078, 0x8d06, 0x0040, 0x8cdf, 0x1078, 0x2880, 0x0d7e,
+	0x1078, 0x8d06, 0x0040, 0x8cc1, 0x6010, 0x2068, 0x6837, 0x0103,
+	0x684b, 0x0006, 0x6847, 0x0000, 0x6850, 0xc0ed, 0x6852, 0x1078,
+	0x4a73, 0x2c68, 0x1078, 0x76c7, 0x0040, 0x8ccf, 0x6818, 0x601a,
+	0x0c7e, 0x2d60, 0x1078, 0x8ec6, 0x0c7f, 0x0078, 0x8cd0, 0x2d60,
+	0x0d7f, 0x6013, 0x0000, 0x601f, 0x0001, 0x6007, 0x0001, 0x6003,
+	0x0001, 0x1078, 0x5dd7, 0x1078, 0x62d1, 0x0078, 0x8cf1, 0x6030,
+	0xa08c, 0xff00, 0x810f, 0xa186, 0x0039, 0x0040, 0x8ceb, 0xa186,
+	0x0035, 0x00c0, 0x8cef, 0x1078, 0x2880, 0x0078, 0x8cc1, 0x1078,
+	0x8ec6, 0x007c, 0xa284, 0x000f, 0x00c0, 0x8d03, 0xa282, 0xad00,
+	0x0048, 0x8d03, 0x2001, 0xa616, 0x2004, 0xa202, 0x00c8, 0x8d03,
+	0xa085, 0x0001, 0x007c, 0xa006, 0x0078, 0x8d02, 0x027e, 0x0e7e,
+	0x2071, 0xa600, 0x6210, 0x705c, 0xa202, 0x0048, 0x8d18, 0x7060,
+	0xa202, 0x00c8, 0x8d18, 0xa085, 0x0001, 0x0e7f, 0x027f, 0x007c,
+	0xa006, 0x0078, 0x8d15, 0x0e7e, 0x0c7e, 0x037e, 0x007e, 0x127e,
+	0x2091, 0x8000, 0x2061, 0xad00, 0x2071, 0xa600, 0x7348, 0x7064,
+	0xa302, 0x00c8, 0x8d45, 0x601c, 0xa206, 0x00c0, 0x8d3d, 0x1078,
+	0x902b, 0x0040, 0x8d3d, 0x1078, 0x8f00, 0x00c0, 0x8d39, 0x1078,
+	0x7c83, 0x0c7e, 0x1078, 0x772d, 0x0c7f, 0xace0, 0x0010, 0x7058,
+	0xac02, 0x00c8, 0x8d45, 0x0078, 0x8d26, 0x127f, 0x007f, 0x037f,
+	0x0c7f, 0x0e7f, 0x007c, 0x0e7e, 0x0c7e, 0x017e, 0xa188, 0xa735,
+	0x210c, 0x81ff, 0x0040, 0x8d59, 0x2061, 0xa9b3, 0x611a, 0x1078,
+	0x2880, 0xa006, 0x0078, 0x8d5e, 0xa085, 0x0001, 0x017f, 0x0c7f,
+	0x0e7f, 0x007c, 0x0c7e, 0x057e, 0x127e, 0x2091, 0x8000, 0x0c7e,
+	0x1078, 0x76c7, 0x057f, 0x0040, 0x8d7b, 0x6612, 0x651a, 0x601f,
+	0x0003, 0x2009, 0x004b, 0x1078, 0x775c, 0xa085, 0x0001, 0x127f,
+	0x057f, 0x0c7f, 0x007c, 0xa006, 0x0078, 0x8d77, 0x0c7e, 0x057e,
+	0x127e, 0x2091, 0x8000, 0x62a0, 0x0c7e, 0x1078, 0x76c7, 0x057f,
+	0x0040, 0x8da9, 0x6013, 0x0000, 0x651a, 0x601f, 0x0003, 0x0c7e,
+	0x2560, 0x1078, 0x47e9, 0x0c7f, 0x1078, 0x5f01, 0x077e, 0x2039,
+	0x0000, 0x1078, 0x5e0a, 0x2c08, 0x1078, 0x9f8b, 0x077f, 0x2009,
+	0x004c, 0x1078, 0x775c, 0xa085, 0x0001, 0x127f, 0x057f, 0x0c7f,
+	0x007c, 0xa006, 0x0078, 0x8da5, 0x0f7e, 0x0c7e, 0x047e, 0x0c7e,
+	0x1078, 0x76c7, 0x2c78, 0x0c7f, 0x0040, 0x8dc6, 0x7e12, 0x2c00,
+	0x781a, 0x781f, 0x0003, 0x2021, 0x0005, 0x1078, 0x8e11, 0x2f60,
+	0x2009, 0x004d, 0x1078, 0x775c, 0xa085, 0x0001, 0x047f, 0x0c7f,
+	0x0f7f, 0x007c, 0x0f7e, 0x0c7e, 0x047e, 0x0c7e, 0x1078, 0x76c7,
+	0x2c78, 0x0c7f, 0x0040, 0x8de4, 0x7e12, 0x2c00, 0x781a, 0x781f,
+	0x0003, 0x2021, 0x0005, 0x1078, 0x8e11, 0x2f60, 0x2009, 0x004e,
+	0x1078, 0x775c, 0xa085, 0x0001, 0x047f, 0x0c7f, 0x0f7f, 0x007c,
+	0x0f7e, 0x0c7e, 0x047e, 0x0c7e, 0x1078, 0x76c7, 0x2c78, 0x0c7f,
+	0x0040, 0x8e0d, 0x7e12, 0x2c00, 0x781a, 0x781f, 0x0003, 0x2021,
+	0x0004, 0x1078, 0x8e11, 0x2001, 0xa89d, 0x2004, 0xd0fc, 0x0040,
+	0x8e06, 0x2f60, 0x1078, 0x772d, 0x0078, 0x8e0b, 0x2f60, 0x2009,
+	0x0052, 0x1078, 0x775c, 0xa085, 0x0001, 0x047f, 0x0c7f, 0x0f7f,
+	0x007c, 0x097e, 0x077e, 0x127e, 0x2091, 0x8000, 0x1078, 0x4775,
+	0x0040, 0x8e1e, 0x2001, 0x8e16, 0x0078, 0x8e24, 0x1078, 0x4739,
+	0x0040, 0x8e2d, 0x2001, 0x8e1e, 0x007e, 0xa00e, 0x2400, 0x1078,
+	0x4b51, 0x1078, 0x4a73, 0x007f, 0x007a, 0x2418, 0x1078, 0x6161,
+	0x62a0, 0x087e, 0x2041, 0x0001, 0x2039, 0x0001, 0x2608, 0x1078,
+	0x5f1b, 0x087f, 0x1078, 0x5e0a, 0x2f08, 0x2648, 0x1078, 0x9f8b,
+	0x613c, 0x81ff, 0x1040, 0x5fdb, 0x1078, 0x62d1, 0x127f, 0x077f,
+	0x097f, 0x007c, 0x0c7e, 0x127e, 0x2091, 0x8000, 0x0c7e, 0x1078,
+	0x76c7, 0x017f, 0x0040, 0x8e63, 0x660a, 0x611a, 0x601f, 0x0001,
+	0x2d00, 0x6012, 0x2009, 0x001f, 0x1078, 0x775c, 0xa085, 0x0001,
+	0x127f, 0x0c7f, 0x007c, 0xa006, 0x0078, 0x8e60, 0x0c7e, 0x127e,
+	0x2091, 0x8000, 0x0c7e, 0x1078, 0x76c7, 0x017f, 0x0040, 0x8e7f,
+	0x660a, 0x611a, 0x601f, 0x0008, 0x2d00, 0x6012, 0x2009, 0x0021,
+	0x1078, 0x775c, 0xa085, 0x0001, 0x127f, 0x0c7f, 0x007c, 0xa006,
+	0x0078, 0x8e7c, 0x0c7e, 0x127e, 0x2091, 0x8000, 0x0c7e, 0x1078,
+	0x76c7, 0x017f, 0x0040, 0x8e9b, 0x660a, 0x611a, 0x601f, 0x0001,
+	0x2d00, 0x6012, 0x2009, 0x003d, 0x1078, 0x775c, 0xa085, 0x0001,
+	0x127f, 0x0c7f, 0x007c, 0xa006, 0x0078, 0x8e98, 0x0c7e, 0x127e,
+	0x2091, 0x8000, 0x0c7e, 0x1078, 0x76c7, 0x017f, 0x0040, 0x8eb6,
+	0x611a, 0x601f, 0x0001, 0x2d00, 0x6012, 0x2009, 0x0000, 0x1078,
+	0x775c, 0xa085, 0x0001, 0x127f, 0x0c7f, 0x007c, 0xa006, 0x0078,
+	0x8eb3, 0x027e, 0x0d7e, 0x6218, 0x2268, 0x6a3c, 0x82ff, 0x0040,
+	0x8ec3, 0x8211, 0x6a3e, 0x0d7f, 0x027f, 0x007c, 0x007e, 0x6000,
+	0xa086, 0x0000, 0x0040, 0x8ed8, 0x6013, 0x0000, 0x601f, 0x0007,
+	0x2001, 0xa8a3, 0x2004, 0x6016, 0x1078, 0xa495, 0x603f, 0x0000,
+	0x007f, 0x007c, 0x067e, 0x0c7e, 0x0d7e, 0x2031, 0xa653, 0x2634,
+	0xd6e4, 0x0040, 0x8ee8, 0x6618, 0x2660, 0x6e48, 0x1078, 0x46e7,
+	0x0d7f, 0x0c7f, 0x067f, 0x007c, 0x007e, 0x017e, 0x6004, 0xa08e,
+	0x0002, 0x0040, 0x8efd, 0xa08e, 0x0003, 0x0040, 0x8efd, 0xa08e,
+	0x0004, 0x0040, 0x8efd, 0xa085, 0x0001, 0x017f, 0x007f, 0x007c,
+	0x007e, 0x0d7e, 0x6010, 0xa06d, 0x0040, 0x8f0d, 0x6838, 0xd0fc,
+	0x0040, 0x8f0d, 0xa006, 0x0078, 0x8f0f, 0xa085, 0x0001, 0x0d7f,
+	0x007f, 0x007c, 0x0c7e, 0x127e, 0x2091, 0x8000, 0x0c7e, 0x1078,
+	0x76c7, 0x017f, 0x0040, 0x8f2c, 0x611a, 0x601f, 0x0001, 0x2d00,
+	0x6012, 0x1078, 0x2880, 0x2009, 0x0028, 0x1078, 0x775c, 0xa085,
+	0x0001, 0x127f, 0x0c7f, 0x007c, 0xa006, 0x0078, 0x8f29, 0xa186,
+	0x0015, 0x00c0, 0x8f44, 0x2011, 0xa620, 0x2204, 0xa086, 0x0074,
+	0x00c0, 0x8f44, 0x1078, 0x7f91, 0x6003, 0x0001, 0x6007, 0x0029,
+	0x1078, 0x5dd7, 0x0078, 0x8f48, 0x1078, 0x7c83, 0x1078, 0x772d,
+	0x007c, 0xa186, 0x0016, 0x00c0, 0x8f53, 0x2001, 0x0004, 0x1078,
+	0x4502, 0x0078, 0x8f74, 0xa186, 0x0015, 0x00c0, 0x8f78, 0x2011,
+	0xa620, 0x2204, 0xa086, 0x0014, 0x00c0, 0x8f78, 0x0d7e, 0x6018,
+	0x2068, 0x1078, 0x4649, 0x0d7f, 0x1078, 0x8043, 0x00c0, 0x8f78,
+	0x0d7e, 0x6018, 0x2068, 0x6890, 0x0d7f, 0xa005, 0x0040, 0x8f78,
+	0x2001, 0x0006, 0x1078, 0x4502, 0x1078, 0x77f8, 0x0078, 0x8f7c,
+	0x1078, 0x7c83, 0x1078, 0x772d, 0x007c, 0x6848, 0xa086, 0x0005,
+	0x00c0, 0x8f84, 0x1078, 0x8f85, 0x007c, 0x6850, 0xc0ad, 0x6852,
+	0x007c, 0x0e7e, 0x2071, 0xab8c, 0x7014, 0xd0e4, 0x0040, 0x8f9a,
+	0x6013, 0x0000, 0x6003, 0x0001, 0x6007, 0x0050, 0x1078, 0x5d8a,
+	0x1078, 0x62d1, 0x0e7f, 0x007c, 0x0c7e, 0x0f7e, 0x2c78, 0x1078,
+	0x4963, 0x0f7f, 0x0040, 0x8fa9, 0x601c, 0xa084, 0x000f, 0x1079,
+	0x8fab, 0x0c7f, 0x007c, 0x8ad5, 0x8fb6, 0x8fb9, 0x8fbc, 0xa25d,
+	0xa279, 0xa27c, 0x8ad5, 0x8ad5, 0x1078, 0x1332, 0x0005, 0x0005,
+	0x007c, 0x0005, 0x0005, 0x007c, 0x1078, 0x8fbf, 0x007c, 0x0f7e,
+	0x2c78, 0x1078, 0x4963, 0x0040, 0x8fee, 0x1078, 0x76c7, 0x00c0,
+	0x8fcf, 0x2001, 0xa8a4, 0x2004, 0x783e, 0x0078, 0x8fee, 0x7818,
+	0x601a, 0x781c, 0xa086, 0x0003, 0x0040, 0x8fdc, 0x7808, 0x6036,
+	0x2f00, 0x603a, 0x0078, 0x8fe0, 0x7808, 0x603a, 0x2f00, 0x6036,
+	0x602a, 0x601f, 0x0001, 0x6007, 0x0035, 0x6003, 0x0001, 0x7920,
+	0x6122, 0x1078, 0x5d8a, 0x1078, 0x62d1, 0x2f60, 0x0f7f, 0x007c,
+	0x017e, 0x0f7e, 0x682c, 0x6032, 0xa08e, 0x0001, 0x0040, 0x9001,
+	0xa086, 0x0005, 0x0040, 0x9005, 0xa006, 0x602a, 0x602e, 0x0078,
+	0x9016, 0x6824, 0xc0f4, 0xc0d5, 0x6826, 0x6810, 0x2078, 0x787c,
+	0x6938, 0xa102, 0x7880, 0x6934, 0xa103, 0x00c8, 0x8ffc, 0x6834,
+	0x602a, 0x6838, 0xa084, 0xfffc, 0x683a, 0x602e, 0x2d00, 0x6036,
+	0x6808, 0x603a, 0x6918, 0x611a, 0x6920, 0x6122, 0x601f, 0x0001,
+	0x6007, 0x0039, 0x6003, 0x0001, 0x1078, 0x5d8a, 0x6803, 0x0002,
+	0x0f7f, 0x017f, 0x007c, 0x007e, 0x017e, 0x6004, 0xa08e, 0x0034,
+	0x0040, 0x9050, 0xa08e, 0x0035, 0x0040, 0x9050, 0xa08e, 0x0036,
+	0x0040, 0x9050, 0xa08e, 0x0037, 0x0040, 0x9050, 0xa08e, 0x0038,
+	0x0040, 0x9050, 0xa08e, 0x0039, 0x0040, 0x9050, 0xa08e, 0x003a,
+	0x0040, 0x9050, 0xa08e, 0x003b, 0x0040, 0x9050, 0xa085, 0x0001,
+	0x017f, 0x007f, 0x007c, 0x0f7e, 0x2c78, 0x1078, 0x4963, 0x00c0,
+	0x905d, 0xa085, 0x0001, 0x0078, 0x906c, 0x6024, 0xd0f4, 0x00c0,
+	0x906b, 0xc0f5, 0x6026, 0x6010, 0x2078, 0x7828, 0x603a, 0x782c,
+	0x6036, 0x1078, 0x1757, 0xa006, 0x0f7f, 0x007c, 0x007e, 0x017e,
+	0x027e, 0x037e, 0x0e7e, 0x2001, 0xa89e, 0x200c, 0x8000, 0x2014,
+	0x2001, 0x0032, 0x1078, 0x5c1c, 0x2001, 0xa8a2, 0x82ff, 0x00c0,
+	0x9083, 0x2011, 0x0014, 0x2202, 0x2001, 0xa8a0, 0x200c, 0x8000,
+	0x2014, 0x2071, 0xa88d, 0x711a, 0x721e, 0x2001, 0x0064, 0x1078,
+	0x5c1c, 0x2001, 0xa8a3, 0x82ff, 0x00c0, 0x9098, 0x2011, 0x0014,
+	0x2202, 0x2009, 0xa8a4, 0xa280, 0x000a, 0x200a, 0x1078, 0x498b,
+	0x0e7f, 0x037f, 0x027f, 0x017f, 0x007f, 0x007c, 0x007e, 0x0e7e,
+	0x2001, 0xa8a2, 0x2003, 0x0028, 0x2001, 0xa8a3, 0x2003, 0x0014,
+	0x2071, 0xa88d, 0x701b, 0x0000, 0x701f, 0x07d0, 0x2001, 0xa8a4,
+	0x2003, 0x001e, 0x0e7f, 0x007f, 0x007c, 0x0c7e, 0x127e, 0x2091,
+	0x8000, 0x0c7e, 0x1078, 0x76c7, 0x017f, 0x0040, 0x90d5, 0x611a,
+	0x601f, 0x0001, 0x2d00, 0x6012, 0x2009, 0x0033, 0x1078, 0x775c,
+	0xa085, 0x0001, 0x127f, 0x0c7f, 0x007c, 0xa006, 0x0078, 0x90d2,
+	0x0d7e, 0x0e7e, 0x0f7e, 0x2071, 0xa600, 0xa186, 0x0015, 0x00c0,
+	0x9107, 0x7080, 0xa086, 0x0018, 0x00c0, 0x9107, 0x6010, 0x2068,
+	0x6a3c, 0xd2e4, 0x00c0, 0x90fb, 0x2c78, 0x1078, 0x6490, 0x0040,
+	0x910f, 0x706c, 0x6a50, 0xa206, 0x00c0, 0x9103, 0x7070, 0x6a54,
+	0xa206, 0x00c0, 0x9103, 0x6218, 0xa290, 0x0028, 0x2214, 0x2009,
+	0x0000, 0x1078, 0x28c8, 0x1078, 0x77f8, 0x0078, 0x910b, 0x1078,
+	0x7c83, 0x1078, 0x772d, 0x0f7f, 0x0e7f, 0x0d7f, 0x007c, 0x7050,
+	0xa080, 0x29c0, 0x2004, 0x6a54, 0xa206, 0x0040, 0x90fb, 0x0078,
+	0x9103, 0x0c7e, 0x127e, 0x2091, 0x8000, 0x0c7e, 0x1078, 0x76c7,
+	0x017f, 0x0040, 0x9131, 0x611a, 0x601f, 0x0001, 0x2d00, 0x6012,
+	0x2009, 0x0043, 0x1078, 0x775c, 0xa085, 0x0001, 0x127f, 0x0c7f,
+	0x007c, 0xa006, 0x0078, 0x912e, 0x0d7e, 0x0e7e, 0x0f7e, 0x2071,
+	0xa600, 0xa186, 0x0015, 0x00c0, 0x915a, 0x7080, 0xa086, 0x0004,
+	0x00c0, 0x915a, 0x6010, 0xa0e8, 0x000f, 0x2c78, 0x1078, 0x6490,
+	0x0040, 0x9162, 0x706c, 0x6a08, 0xa206, 0x00c0, 0x9156, 0x7070,
+	0x6a0c, 0xa206, 0x00c0, 0x9156, 0x1078, 0x2880, 0x1078, 0x77f8,
+	0x0078, 0x915e, 0x1078, 0x7c83, 0x1078, 0x772d, 0x0f7f, 0x0e7f,
+	0x0d7f, 0x007c, 0x7050, 0xa080, 0x29c0, 0x2004, 0x6a0c, 0xa206,
+	0x0040, 0x9154, 0x0078, 0x9156, 0x017e, 0x027e, 0x684c, 0xd0ac,
+	0x0040, 0x9184, 0x6914, 0x6a10, 0x2100, 0xa205, 0x0040, 0x9184,
+	0x6860, 0xa106, 0x00c0, 0x9180, 0x685c, 0xa206, 0x0040, 0x9184,
+	0x6962, 0x6a5e, 0xa085, 0x0001, 0x027f, 0x017f, 0x007c, 0x0e7e,
+	0x127e, 0x2071, 0xa600, 0x2091, 0x8000, 0x7548, 0xa582, 0x0001,
+	0x0048, 0x91b9, 0x704c, 0x2060, 0x6000, 0xa086, 0x0000, 0x0040,
+	0x91a5, 0xace0, 0x0010, 0x7058, 0xac02, 0x00c8, 0x91a1, 0x0078,
+	0x9194, 0x2061, 0xad00, 0x0078, 0x9194, 0x6003, 0x0008, 0x8529,
+	0x754a, 0xaca8, 0x0010, 0x7058, 0xa502, 0x00c8, 0x91b5, 0x754e,
+	0xa085, 0x0001, 0x127f, 0x0e7f, 0x007c, 0x704f, 0xad00, 0x0078,
+	0x91b0, 0xa006, 0x0078, 0x91b2, 0x0c7e, 0x027e, 0x017e, 0xa186,
+	0x0035, 0x0040, 0x91c6, 0x6a34, 0x0078, 0x91c7, 0x6a28, 0x1078,
+	0x8cf2, 0x0040, 0x91f0, 0x2260, 0x611c, 0xa186, 0x0003, 0x0040,
+	0x91d5, 0xa186, 0x0006, 0x00c0, 0x91ec, 0x6834, 0xa206, 0x0040,
+	0x91e4, 0x6838, 0xa206, 0x00c0, 0x91ec, 0x6108, 0x6834, 0xa106,
+	0x00c0, 0x91ec, 0x0078, 0x91e9, 0x6008, 0x6938, 0xa106, 0x00c0,
+	0x91ec, 0x6018, 0x6918, 0xa106, 0x017f, 0x027f, 0x0c7f, 0x007c,
+	0xa085, 0x0001, 0x0078, 0x91ec, 0x6944, 0xd1cc, 0x0040, 0x920d,
+	0xa18c, 0x00ff, 0xa18e, 0x0002, 0x00c0, 0x920d, 0xad88, 0x001e,
+	0x210c, 0xa18c, 0x0f00, 0x810f, 0xa18e, 0x0001, 0x00c0, 0x920d,
+	0x6810, 0x6914, 0xa115, 0x10c0, 0x84d5, 0x007c, 0x067e, 0x6000,
+	0xa0b2, 0x0010, 0x10c8, 0x1332, 0x1079, 0x9218, 0x067f, 0x007c,
+	0x9228, 0x96df, 0x97fb, 0x9228, 0x9228, 0x9228, 0x9228, 0x9228,
+	0x9262, 0x988e, 0x9228, 0x9228, 0x9228, 0x9228, 0x9228, 0x9228,
+	0x1078, 0x1332, 0x067e, 0x6000, 0xa0b2, 0x0010, 0x10c8, 0x1332,
+	0x1079, 0x9234, 0x067f, 0x007c, 0x9244, 0x9d53, 0x9244, 0x9244,
+	0x9244, 0x9244, 0x9244, 0x9244, 0x9d11, 0x9da1, 0x9244, 0xa3b0,
+	0xa3e4, 0xa3b0, 0xa3e4, 0x9244, 0x1078, 0x1332, 0x067e, 0x6000,
+	0xa0b2, 0x0010, 0x10c8, 0x1332, 0x1079, 0x9250, 0x067f, 0x007c,
+	0x9260, 0x99eb, 0x9ac7, 0x9af5, 0x9b70, 0x9260, 0x9c76, 0x9c1e,
+	0x989a, 0x9ce5, 0x9cfb, 0x9260, 0x9260, 0x9260, 0x9260, 0x9260,
+	0x1078, 0x1332, 0xa1b2, 0x0044, 0x10c8, 0x1332, 0x2100, 0x0079,
+	0x9269, 0x92a9, 0x9498, 0x92a9, 0x92a9, 0x92a9, 0x94a0, 0x92a9,
+	0x92a9, 0x92a9, 0x92a9, 0x92a9, 0x92a9, 0x92a9, 0x92a9, 0x92a9,
+	0x92a9, 0x92a9, 0x92a9, 0x92a9, 0x92a9, 0x92a9, 0x92a9, 0x92a9,
+	0x92ab, 0x9311, 0x9320, 0x9377, 0x9396, 0x9415, 0x9485, 0x92a9,
+	0x92a9, 0x94a4, 0x92a9, 0x92a9, 0x94b7, 0x94c2, 0x92a9, 0x92a9,
+	0x92a9, 0x92a9, 0x92a9, 0x94fa, 0x92a9, 0x92a9, 0x9509, 0x92a9,
+	0x92a9, 0x92a9, 0x92a9, 0x92a9, 0x92a9, 0x9522, 0x92a9, 0x92a9,
+	0x92a9, 0x95af, 0x92a9, 0x92a9, 0x92a9, 0x92a9, 0x92a9, 0x92a9,
+	0x9629, 0x1078, 0x1332, 0x1078, 0x4967, 0x00c0, 0x92bb, 0x2001,
+	0xa633, 0x2004, 0xd0cc, 0x00c0, 0x92bb, 0xa084, 0x0009, 0xa086,
+	0x0008, 0x00c0, 0x92c3, 0x6007, 0x0009, 0x602b, 0x0009, 0x6013,
+	0x0000, 0x0078, 0x9493, 0x1078, 0x4957, 0x0e7e, 0x0c7e, 0x037e,
+	0x027e, 0x017e, 0x6218, 0x2270, 0x72a0, 0x027e, 0x2019, 0x0029,
+	0x1078, 0x5f01, 0x077e, 0x2039, 0x0000, 0x1078, 0x5e0a, 0x2c08,
+	0x1078, 0x9f8b, 0x077f, 0x017f, 0x2e60, 0x1078, 0x47e9, 0x017f,
+	0x027f, 0x037f, 0x0c7f, 0x0e7f, 0x6618, 0x0c7e, 0x2660, 0x1078,
+	0x45d6, 0x0c7f, 0xa6b0, 0x0001, 0x2634, 0xa684, 0x00ff, 0xa082,
+	0x0006, 0x0048, 0x9303, 0x1078, 0x9ebf, 0x00c0, 0x9371, 0x1078,
+	0x9e50, 0x00c0, 0x92ff, 0x6007, 0x0008, 0x0078, 0x9493, 0x6007,
+	0x0009, 0x0078, 0x9493, 0x1078, 0xa09f, 0x0040, 0x930d, 0x1078,
+	0x9ebf, 0x0040, 0x92f7, 0x0078, 0x9371, 0x6013, 0x1900, 0x0078,
+	0x92ff, 0x1078, 0x29bb, 0x00c0, 0x9664, 0x6106, 0x1078, 0x9e05,
+	0x6007, 0x0006, 0x0078, 0x9493, 0x6007, 0x0007, 0x0078, 0x9493,
+	0x1078, 0xa41c, 0x00c0, 0x9664, 0x1078, 0x29bb, 0x00c0, 0x9664,
+	0x0d7e, 0x6618, 0x2668, 0x6e04, 0xa684, 0x00ff, 0xa082, 0x0006,
+	0x00c8, 0x9336, 0x2001, 0x0001, 0x1078, 0x44ee, 0xa6b4, 0xff00,
+	0x8637, 0xa686, 0x0006, 0x0040, 0x9353, 0xa686, 0x0004, 0x0040,
+	0x9353, 0x6e04, 0xa6b4, 0x00ff, 0xa686, 0x0006, 0x0040, 0x9353,
+	0xa686, 0x0004, 0x0040, 0x9353, 0xa686, 0x0005, 0x0040, 0x9353,
+	0x0d7f, 0x0078, 0x9371, 0x1078, 0x9f25, 0x00c0, 0x936c, 0xa686,
+	0x0006, 0x00c0, 0x9365, 0x027e, 0x6218, 0xa290, 0x0028, 0x2214,
+	0x2009, 0x0000, 0x1078, 0x28c8, 0x027f, 0x1078, 0x4649, 0x6007,
+	0x000a, 0x0d7f, 0x0078, 0x9493, 0x6007, 0x000b, 0x0d7f, 0x0078,
+	0x9493, 0x1078, 0x2880, 0x6007, 0x0001, 0x0078, 0x9493, 0x1078,
+	0xa41c, 0x00c0, 0x9664, 0x1078, 0x29bb, 0x00c0, 0x9664, 0x6618,
+	0x0d7e, 0x2668, 0x6e04, 0x0d7f, 0xa686, 0x0707, 0x0040, 0x9371,
+	0x027e, 0x6218, 0xa290, 0x0028, 0x2214, 0x2009, 0x0000, 0x1078,
+	0x28c8, 0x027f, 0x6007, 0x000c, 0x0078, 0x9493, 0x1078, 0x4967,
+	0x00c0, 0x93a3, 0x2001, 0xa633, 0x2004, 0xa084, 0x0009, 0xa086,
+	0x0008, 0x00c0, 0x93ab, 0x6007, 0x0009, 0x602b, 0x0009, 0x6013,
+	0x0000, 0x0078, 0x9493, 0x1078, 0x4957, 0x6618, 0xa6b0, 0x0001,
+	0x2634, 0xa684, 0x00ff, 0xa082, 0x0006, 0x0048, 0x93ef, 0xa6b4,
+	0xff00, 0x8637, 0xa686, 0x0004, 0x0040, 0x93c2, 0xa686, 0x0006,
+	0x00c0, 0x9371, 0x1078, 0x9f34, 0x00c0, 0x93ca, 0x6007, 0x000e,
+	0x0078, 0x9493, 0x047e, 0x6418, 0xa4a0, 0x0028, 0x2424, 0xa4a4,
+	0x00ff, 0x8427, 0x047e, 0x1078, 0x2880, 0x047f, 0x017e, 0xa006,
+	0x2009, 0xa653, 0x210c, 0xd1a4, 0x0040, 0x93e9, 0x2009, 0x0029,
+	0x1078, 0xa21d, 0x6018, 0x0d7e, 0x2068, 0x6800, 0xc0e5, 0x6802,
+	0x0d7f, 0x017f, 0x047f, 0x6007, 0x0001, 0x0078, 0x9493, 0x2001,
+	0x0001, 0x1078, 0x44ee, 0x157e, 0x017e, 0x027e, 0x037e, 0x20a9,
+	0x0004, 0x2019, 0xa605, 0x2011, 0xab90, 0x1078, 0x80de, 0x037f,
+	0x027f, 0x017f, 0x157f, 0xa005, 0x0040, 0x940f, 0xa6b4, 0xff00,
+	0x8637, 0xa686, 0x0006, 0x0040, 0x93c2, 0x0078, 0x9371, 0x6013,
+	0x1900, 0x6007, 0x0009, 0x0078, 0x9493, 0x1078, 0x4967, 0x00c0,
+	0x9422, 0x2001, 0xa633, 0x2004, 0xa084, 0x0009, 0xa086, 0x0008,
+	0x00c0, 0x942a, 0x6007, 0x0009, 0x602b, 0x0009, 0x6013, 0x0000,
+	0x0078, 0x9493, 0x1078, 0x4957, 0x6618, 0xa6b0, 0x0001, 0x2634,
+	0xa684, 0x00ff, 0xa082, 0x0006, 0x0048, 0x9472, 0xa6b4, 0xff00,
+	0x8637, 0xa686, 0x0004, 0x0040, 0x9441, 0xa686, 0x0006, 0x00c0,
+	0x9371, 0x1078, 0x9f5f, 0x00c0, 0x944d, 0x1078, 0x9e50, 0x00c0,
+	0x944d, 0x6007, 0x0010, 0x0078, 0x9493, 0x047e, 0x6418, 0xa4a0,
+	0x0028, 0x2424, 0xa4a4, 0x00ff, 0x8427, 0x047e, 0x1078, 0x2880,
+	0x047f, 0x017e, 0xa006, 0x2009, 0xa653, 0x210c, 0xd1a4, 0x0040,
+	0x946c, 0x2009, 0x0029, 0x1078, 0xa21d, 0x6018, 0x0d7e, 0x2068,
+	0x6800, 0xc0e5, 0x6802, 0x0d7f, 0x017f, 0x047f, 0x6007, 0x0001,
+	0x0078, 0x9493, 0x1078, 0xa09f, 0x0040, 0x947f, 0xa6b4, 0xff00,
+	0x8637, 0xa686, 0x0006, 0x0040, 0x9441, 0x0078, 0x9371, 0x6013,
+	0x1900, 0x6007, 0x0009, 0x0078, 0x9493, 0x1078, 0x29bb, 0x00c0,
+	0x9664, 0x1078, 0xa41c, 0x00c0, 0x9664, 0x1078, 0x9667, 0x00c0,
+	0x9371, 0x6007, 0x0012, 0x6003, 0x0001, 0x1078, 0x5dd7, 0x007c,
+	0x6007, 0x0001, 0x6003, 0x0001, 0x1078, 0x5dd7, 0x0078, 0x9497,
+	0x6007, 0x0005, 0x0078, 0x949a, 0x1078, 0xa41c, 0x00c0, 0x9664,
+	0x1078, 0x29bb, 0x00c0, 0x9664, 0x1078, 0x9667, 0x00c0, 0x9371,
+	0x6007, 0x0020, 0x6003, 0x0001, 0x1078, 0x5dd7, 0x007c, 0x1078,
+	0x29bb, 0x00c0, 0x9664, 0x6007, 0x0023, 0x6003, 0x0001, 0x1078,
+	0x5dd7, 0x007c, 0x1078, 0xa41c, 0x00c0, 0x9664, 0x1078, 0x29bb,
+	0x00c0, 0x9664, 0x1078, 0x9667, 0x00c0, 0x9371, 0x017e, 0x027e,
+	0x2011, 0xab90, 0x2214, 0x2c08, 0xa006, 0x1078, 0xa1e6, 0x00c0,
+	0x94e9, 0x2160, 0x6007, 0x0026, 0x6013, 0x1700, 0x2011, 0xab89,
+	0x2214, 0xa296, 0xffff, 0x00c0, 0x94f3, 0x6007, 0x0025, 0x0078,
+	0x94f3, 0x6004, 0xa086, 0x0024, 0x00c0, 0x94f0, 0x1078, 0x772d,
+	0x2160, 0x6007, 0x0025, 0x6003, 0x0001, 0x1078, 0x5dd7, 0x027f,
+	0x017f, 0x007c, 0x1078, 0x29bb, 0x00c0, 0x9664, 0x6106, 0x1078,
+	0x9687, 0x6007, 0x002b, 0x0078, 0x9493, 0x6007, 0x002c, 0x0078,
+	0x9493, 0x1078, 0xa41c, 0x00c0, 0x9664, 0x1078, 0x29bb, 0x00c0,
+	0x9664, 0x1078, 0x9667, 0x00c0, 0x9371, 0x6106, 0x1078, 0x968c,
+	0x00c0, 0x951e, 0x6007, 0x002e, 0x0078, 0x9493, 0x6007, 0x002f,
+	0x0078, 0x9493, 0x1078, 0x29bb, 0x00c0, 0x9664, 0x0e7e, 0x0d7e,
+	0x0c7e, 0x6018, 0xa080, 0x0001, 0x200c, 0xa184, 0x00ff, 0xa086,
+	0x0006, 0x0040, 0x953f, 0xa184, 0xff00, 0x8007, 0xa086, 0x0006,
+	0x0040, 0x953f, 0x0c7f, 0x0d7f, 0x0e7f, 0x0078, 0x9498, 0x2001,
+	0xa672, 0x2004, 0xd0e4, 0x0040, 0x95ab, 0x2071, 0xab8c, 0x7010,
+	0x6036, 0x7014, 0x603a, 0x7108, 0x720c, 0x2001, 0xa653, 0x2004,
+	0xd0a4, 0x0040, 0x955d, 0x6018, 0x2068, 0x6810, 0xa106, 0x00c0,
+	0x955d, 0x6814, 0xa206, 0x0040, 0x9581, 0x2001, 0xa653, 0x2004,
+	0xd0ac, 0x00c0, 0x959f, 0x2069, 0xa600, 0x6870, 0xa206, 0x00c0,
+	0x959f, 0x686c, 0xa106, 0x00c0, 0x959f, 0x7210, 0x1078, 0x8cf2,
+	0x0040, 0x95a5, 0x1078, 0xa28e, 0x0040, 0x95a5, 0x622a, 0x6007,
+	0x0036, 0x6003, 0x0001, 0x1078, 0x5d8a, 0x0c7f, 0x0d7f, 0x0e7f,
+	0x007c, 0x7214, 0xa286, 0xffff, 0x0040, 0x9593, 0x1078, 0x8cf2,
+	0x0040, 0x95a5, 0xa280, 0x0002, 0x2004, 0x7110, 0xa106, 0x00c0,
+	0x95a5, 0x0078, 0x956e, 0x7210, 0x2c08, 0xa085, 0x0001, 0x1078,
+	0xa1e6, 0x2c10, 0x2160, 0x0040, 0x95a5, 0x0078, 0x956e, 0x6007,
+	0x0037, 0x6013, 0x1500, 0x0078, 0x9579, 0x6007, 0x0037, 0x6013,
+	0x1700, 0x0078, 0x9579, 0x6007, 0x0012, 0x0078, 0x9579, 0x1078,
+	0x29bb, 0x00c0, 0x9664, 0x6018, 0xa080, 0x0001, 0x2004, 0xa084,
+	0xff00, 0x8007, 0xa086, 0x0006, 0x00c0, 0x9498, 0x0e7e, 0x0d7e,
+	0x0c7e, 0x2001, 0xa672, 0x2004, 0xd0e4, 0x0040, 0x9621, 0x2069,
+	0xa600, 0x2071, 0xab8c, 0x7008, 0x6036, 0x720c, 0x623a, 0xa286,
+	0xffff, 0x00c0, 0x95de, 0x7208, 0x0c7e, 0x2c08, 0xa085, 0x0001,
+	0x1078, 0xa1e6, 0x2c10, 0x0c7f, 0x0040, 0x9615, 0x1078, 0x8cf2,
+	0x0040, 0x9615, 0x0c7e, 0x027e, 0x2260, 0x1078, 0x89f3, 0x027f,
+	0x0c7f, 0x7118, 0xa18c, 0xff00, 0x810f, 0xa186, 0x0001, 0x0040,
+	0x95ff, 0xa186, 0x0005, 0x0040, 0x95f9, 0xa186, 0x0007, 0x00c0,
+	0x9609, 0xa280, 0x0004, 0x2004, 0xa005, 0x0040, 0x9609, 0x057e,
+	0x7510, 0x7614, 0x1078, 0xa2a3, 0x057f, 0x0c7f, 0x0d7f, 0x0e7f,
+	0x007c, 0x6007, 0x003b, 0x602b, 0x0009, 0x6013, 0x2a00, 0x6003,
+	0x0001, 0x1078, 0x5d8a, 0x0078, 0x9605, 0x6007, 0x003b, 0x602b,
+	0x0009, 0x6013, 0x1700, 0x6003, 0x0001, 0x1078, 0x5d8a, 0x0078,
+	0x9605, 0x6007, 0x003b, 0x602b, 0x000b, 0x6013, 0x0000, 0x0078,
+	0x9579, 0x0e7e, 0x027e, 0x1078, 0x4967, 0x0040, 0x965e, 0x1078,
+	0x4957, 0x1078, 0xa4a9, 0x00c0, 0x965c, 0x2071, 0xa600, 0x70cc,
+	0xc085, 0x70ce, 0x0f7e, 0x2079, 0x0100, 0x7298, 0xa284, 0x00ff,
+	0x706e, 0x78e6, 0xa284, 0xff00, 0x7270, 0xa205, 0x7072, 0x78ea,
+	0x0f7f, 0x70d7, 0x0000, 0x2001, 0xa653, 0x2004, 0xd0a4, 0x0040,
+	0x9655, 0x2011, 0xa8ca, 0x2013, 0x07d0, 0xd0ac, 0x00c0, 0x965e,
+	0x1078, 0x2677, 0x0078, 0x965e, 0x1078, 0xa4d9, 0x027f, 0x0e7f,
+	0x1078, 0x772d, 0x0078, 0x9497, 0x1078, 0x772d, 0x007c, 0x0d7e,
+	0x067e, 0x6618, 0x2668, 0x6e04, 0xa6b4, 0xff00, 0x8637, 0xa686,
+	0x0006, 0x0040, 0x9684, 0xa686, 0x0004, 0x0040, 0x9684, 0x6e04,
+	0xa6b4, 0x00ff, 0xa686, 0x0006, 0x0040, 0x9684, 0xa686, 0x0004,
+	0x0040, 0x9684, 0xa085, 0x0001, 0x067f, 0x0d7f, 0x007c, 0x0d7e,
+	0x1078, 0x96bb, 0x0d7f, 0x007c, 0x0d7e, 0x1078, 0x96ca, 0x00c0,
+	0x96b4, 0x680c, 0xa08c, 0xff00, 0x6820, 0xa084, 0x00ff, 0xa115,
+	0x6212, 0x6824, 0x602a, 0xd1e4, 0x0040, 0x96a2, 0x2009, 0x0001,
+	0x0078, 0x96b0, 0xd1ec, 0x0040, 0x96b4, 0x6920, 0xa18c, 0x00ff,
+	0x6824, 0x1078, 0x254d, 0x00c0, 0x96b4, 0x2110, 0x2009, 0x0000,
+	0x1078, 0x28c8, 0x0078, 0x96b8, 0xa085, 0x0001, 0x0078, 0x96b9,
+	0xa006, 0x0d7f, 0x007c, 0x2069, 0xab8d, 0x6800, 0xa082, 0x0010,
+	0x00c8, 0x96c8, 0x6013, 0x0000, 0xa085, 0x0001, 0x0078, 0x96c9,
+	0xa006, 0x007c, 0x6013, 0x0000, 0x2069, 0xab8c, 0x6808, 0xa084,
+	0xff00, 0xa086, 0x0800, 0x00c0, 0x96de, 0x6800, 0xa084, 0x00ff,
+	0xa08e, 0x0014, 0x0040, 0x96de, 0xa08e, 0x0010, 0x007c, 0x6004,
+	0xa0b2, 0x0044, 0x10c8, 0x1332, 0xa1b6, 0x0013, 0x00c0, 0x96eb,
+	0x2008, 0x0079, 0x96fe, 0xa1b6, 0x0027, 0x0040, 0x96f3, 0xa1b6,
+	0x0014, 0x10c0, 0x1332, 0x2001, 0x0007, 0x1078, 0x4535, 0x1078,
+	0x61cd, 0x1078, 0x8ec6, 0x1078, 0x62d1, 0x007c, 0x973e, 0x9740,
+	0x973e, 0x973e, 0x973e, 0x9740, 0x974c, 0x97d6, 0x9799, 0x97d6,
+	0x97ad, 0x97d6, 0x974c, 0x97d6, 0x97ce, 0x97d6, 0x97ce, 0x97d6,
+	0x97d6, 0x973e, 0x973e, 0x973e, 0x973e, 0x973e, 0x973e, 0x973e,
+	0x973e, 0x973e, 0x973e, 0x973e, 0x9740, 0x973e, 0x97d6, 0x973e,
+	0x973e, 0x97d6, 0x973e, 0x97d6, 0x97d6, 0x973e, 0x973e, 0x973e,
+	0x973e, 0x97d6, 0x97d6, 0x973e, 0x97d6, 0x97d6, 0x973e, 0x973e,
+	0x973e, 0x973e, 0x973e, 0x9740, 0x97d6, 0x97d6, 0x973e, 0x973e,
+	0x97d6, 0x97d6, 0x973e, 0x973e, 0x973e, 0x973e, 0x1078, 0x1332,
+	0x1078, 0x61cd, 0x2001, 0xa8a2, 0x2004, 0x6016, 0x6003, 0x0002,
+	0x1078, 0x62d1, 0x0078, 0x97dc, 0x0f7e, 0x2079, 0xa652, 0x7804,
+	0x0f7f, 0xd0ac, 0x00c0, 0x97d6, 0x2001, 0x0000, 0x1078, 0x44ee,
+	0x6018, 0xa080, 0x0004, 0x2004, 0xa086, 0x00ff, 0x0040, 0x97d6,
+	0x0c7e, 0x6018, 0x2060, 0x6000, 0xd0f4, 0x00c0, 0x9770, 0x6010,
+	0xa005, 0x0040, 0x9770, 0x0c7f, 0x1078, 0x3699, 0x0078, 0x97d6,
+	0x0c7f, 0x2001, 0xa600, 0x2004, 0xa086, 0x0002, 0x00c0, 0x977f,
+	0x0f7e, 0x2079, 0xa600, 0x7890, 0x8000, 0x7892, 0x0f7f, 0x2001,
+	0x0002, 0x1078, 0x4502, 0x1078, 0x61cd, 0x601f, 0x0001, 0x6003,
+	0x0001, 0x6007, 0x0002, 0x1078, 0x5dd7, 0x1078, 0x62d1, 0x0c7e,
+	0x6118, 0x2160, 0x2009, 0x0001, 0x1078, 0x5a52, 0x0c7f, 0x0078,
+	0x97dc, 0x6618, 0x0d7e, 0x2668, 0x6e04, 0x0d7f, 0xa6b4, 0xff00,
+	0x8637, 0xa686, 0x0006, 0x0040, 0x97d6, 0xa686, 0x0004, 0x0040,
+	0x97d6, 0x2001, 0x0004, 0x0078, 0x97d4, 0x2001, 0xa600, 0x2004,
+	0xa086, 0x0003, 0x00c0, 0x97b6, 0x1078, 0x3699, 0x2001, 0x0006,
+	0x1078, 0x97dd, 0x6618, 0x0d7e, 0x2668, 0x6e04, 0x0d7f, 0xa6b4,
+	0xff00, 0x8637, 0xa686, 0x0006, 0x0040, 0x97d6, 0x2001, 0x0006,
+	0x0078, 0x97d4, 0x2001, 0x0004, 0x0078, 0x97d4, 0x2001, 0x0006,
+	0x1078, 0x97dd, 0x0078, 0x97d6, 0x1078, 0x4535, 0x1078, 0x61cd,
+	0x1078, 0x772d, 0x1078, 0x62d1, 0x007c, 0x017e, 0x0d7e, 0x6118,
+	0x2168, 0x6900, 0xd184, 0x0040, 0x97f8, 0x6104, 0xa18e, 0x000a,
+	0x00c0, 0x97f0, 0x699c, 0xd1a4, 0x00c0, 0x97f0, 0x2001, 0x0007,
+	0x1078, 0x4502, 0x2001, 0x0000, 0x1078, 0x44ee, 0x1078, 0x28a6,
+	0x0d7f, 0x017f, 0x007c, 0x0d7e, 0x6618, 0x2668, 0x6804, 0xa084,
+	0xff00, 0x8007, 0x0d7f, 0xa0b2, 0x000c, 0x10c8, 0x1332, 0xa1b6,
+	0x0015, 0x00c0, 0x980f, 0x1079, 0x9816, 0x0078, 0x9815, 0xa1b6,
+	0x0016, 0x10c0, 0x1332, 0x1079, 0x9822, 0x007c, 0x7d4e, 0x7d4e,
+	0x7d4e, 0x7d4e, 0x7d4e, 0x7d4e, 0x9877, 0x982e, 0x7d4e, 0x7d4e,
+	0x7d4e, 0x7d4e, 0x7d4e, 0x7d4e, 0x7d4e, 0x7d4e, 0x7d4e, 0x7d4e,
+	0x9877, 0x987f, 0x7d4e, 0x7d4e, 0x7d4e, 0x7d4e, 0x0f7e, 0x2079,
+	0xa652, 0x7804, 0xd0ac, 0x00c0, 0x9855, 0x6018, 0xa07d, 0x0040,
+	0x9855, 0x7800, 0xd0f4, 0x00c0, 0x9841, 0x7810, 0xa005, 0x00c0,
+	0x9855, 0x2001, 0x0000, 0x1078, 0x44ee, 0x2001, 0x0002, 0x1078,
+	0x4502, 0x601f, 0x0001, 0x6003, 0x0001, 0x6007, 0x0002, 0x1078,
+	0x5dd7, 0x1078, 0x62d1, 0x0078, 0x9875, 0x2011, 0xab83, 0x2204,
+	0x8211, 0x220c, 0x1078, 0x254d, 0x00c0, 0x9875, 0x0c7e, 0x1078,
+	0x45c4, 0x0040, 0x9868, 0x0c7f, 0x1078, 0x772d, 0x0078, 0x9875,
+	0x6010, 0x007e, 0x6014, 0x007e, 0x1078, 0x42f8, 0x007f, 0x6016,
+	0x007f, 0x6012, 0x0c7f, 0x1078, 0x772d, 0x0f7f, 0x007c, 0x6604,
+	0xa6b6, 0x001e, 0x00c0, 0x987e, 0x1078, 0x772d, 0x007c, 0x1078,
+	0x7f8e, 0x00c0, 0x988b, 0x6003, 0x0001, 0x6007, 0x0001, 0x1078,
+	0x5dd7, 0x0078, 0x988d, 0x1078, 0x772d, 0x007c, 0x6004, 0xa08a,
+	0x0044, 0x10c8, 0x1332, 0x1078, 0x61cd, 0x1078, 0x8ec6, 0x1078,
+	0x62d1, 0x007c, 0xa182, 0x0040, 0x0079, 0x989e, 0x98b1, 0x98b1,
+	0x98b1, 0x98b1, 0x98b3, 0x98b1, 0x98b1, 0x98b1, 0x98b1, 0x98b1,
+	0x98b1, 0x98b1, 0x98b1, 0x98b1, 0x98b1, 0x98b1, 0x98b1, 0x98b1,
+	0x98b1, 0x1078, 0x1332, 0x0d7e, 0x0e7e, 0x0f7e, 0x157e, 0x047e,
+	0x027e, 0x6218, 0xa280, 0x002b, 0x2004, 0xa005, 0x0040, 0x98c4,
+	0x2021, 0x0000, 0x1078, 0xa472, 0x6106, 0x2071, 0xab80, 0x7444,
+	0xa4a4, 0xff00, 0x0040, 0x991b, 0xa486, 0x2000, 0x00c0, 0x98d6,
+	0x2009, 0x0001, 0x2011, 0x0200, 0x1078, 0x5bf1, 0x1078, 0x138b,
+	0x1040, 0x1332, 0x6003, 0x0007, 0x2d00, 0x6837, 0x010d, 0x6803,
+	0x0000, 0x683b, 0x0000, 0x6c5a, 0x2c00, 0x685e, 0x6008, 0x68b2,
+	0x6018, 0x2078, 0x78a0, 0x8007, 0x7130, 0x694a, 0x017e, 0xa084,
+	0xff00, 0x6846, 0x684f, 0x0000, 0x6857, 0x0036, 0x1078, 0x4a73,
+	0x017f, 0xa486, 0x2000, 0x00c0, 0x9903, 0x2019, 0x0017, 0x1078,
+	0xa195, 0x0078, 0x997d, 0xa486, 0x0400, 0x00c0, 0x990d, 0x2019,
+	0x0002, 0x1078, 0xa146, 0x0078, 0x997d, 0xa486, 0x0200, 0x00c0,
+	0x9913, 0x1078, 0xa12b, 0xa486, 0x1000, 0x00c0, 0x9919, 0x1078,
+	0xa17a, 0x0078, 0x997d, 0x2069, 0xa933, 0x6a00, 0xd284, 0x0040,
+	0x99e7, 0xa284, 0x0300, 0x00c0, 0x99df, 0x6804, 0xa005, 0x0040,
+	0x99c5, 0x2d78, 0x6003, 0x0007, 0x1078, 0x1370, 0x0040, 0x9984,
+	0x7800, 0xd08c, 0x00c0, 0x9937, 0x7804, 0x8001, 0x7806, 0x6013,
+	0x0000, 0x6803, 0x0000, 0x6837, 0x0116, 0x683b, 0x0000, 0x6008,
+	0x68b2, 0x2c00, 0x684a, 0x6018, 0x2078, 0x78a0, 0x8007, 0x7130,
+	0x6986, 0x6846, 0x7928, 0x698a, 0x792c, 0x698e, 0x7930, 0x6992,
+	0x7934, 0x6996, 0x6853, 0x003d, 0x7244, 0xa294, 0x0003, 0xa286,
+	0x0002, 0x00c0, 0x995f, 0x684f, 0x0040, 0x0078, 0x9969, 0xa286,
+	0x0001, 0x00c0, 0x9967, 0x684f, 0x0080, 0x0078, 0x9969, 0x684f,
+	0x0000, 0x20a9, 0x000a, 0x2001, 0xab90, 0xad90, 0x0015, 0x200c,
+	0x810f, 0x2112, 0x8000, 0x8210, 0x00f0, 0x996f, 0x200c, 0x6982,
+	0x8000, 0x200c, 0x697e, 0x1078, 0x4a73, 0x027f, 0x047f, 0x157f,
+	0x0f7f, 0x0e7f, 0x0d7f, 0x007c, 0x2001, 0xa60e, 0x2004, 0xd084,
+	0x0040, 0x998e, 0x1078, 0x138b, 0x00c0, 0x9930, 0x6013, 0x0100,
+	0x6003, 0x0001, 0x6007, 0x0041, 0x1078, 0x5d8a, 0x1078, 0x62d1,
+	0x0078, 0x997d, 0x2069, 0xab92, 0x2d04, 0xa084, 0xff00, 0xa086,
+	0x1200, 0x00c0, 0x99b9, 0x2069, 0xab80, 0x686c, 0xa084, 0x00ff,
+	0x017e, 0x6110, 0xa18c, 0x0700, 0xa10d, 0x6112, 0x017f, 0x6003,
+	0x0001, 0x6007, 0x0043, 0x1078, 0x5d8a, 0x1078, 0x62d1, 0x0078,
+	0x997d, 0x6013, 0x0200, 0x6003, 0x0001, 0x6007, 0x0041, 0x1078,
+	0x5d8a, 0x1078, 0x62d1, 0x0078, 0x997d, 0x2001, 0xa60d, 0x2004,
+	0xd0ec, 0x0040, 0x99cf, 0x2011, 0x8049, 0x1078, 0x361b, 0x6013,
+	0x0300, 0x0078, 0x99d5, 0x6013, 0x0100, 0x6003, 0x0001, 0x6007,
+	0x0041, 0x1078, 0x5d8a, 0x1078, 0x62d1, 0x0078, 0x997d, 0x6013,
+	0x0500, 0x0078, 0x99d5, 0x6013, 0x0600, 0x0078, 0x999a, 0x6013,
+	0x0200, 0x0078, 0x999a, 0xa186, 0x0013, 0x00c0, 0x99fd, 0x6004,
+	0xa08a, 0x0040, 0x1048, 0x1332, 0xa08a, 0x0053, 0x10c8, 0x1332,
+	0xa082, 0x0040, 0x2008, 0x0079, 0x9a82, 0xa186, 0x0051, 0x0040,
+	0x9a0a, 0xa186, 0x0047, 0x00c0, 0x9a23, 0x6004, 0xa086, 0x0041,
+	0x0040, 0x9a31, 0x2001, 0x0109, 0x2004, 0xd084, 0x0040, 0x9a31,
+	0x127e, 0x2091, 0x2200, 0x007e, 0x017e, 0x027e, 0x1078, 0x5c56,
+	0x027f, 0x017f, 0x007f, 0x127f, 0x6000, 0xa086, 0x0002, 0x00c0,
+	0x9a31, 0x0078, 0x9ac7, 0xa186, 0x0027, 0x0040, 0x9a2b, 0xa186,
+	0x0014, 0x10c0, 0x1332, 0x6004, 0xa082, 0x0040, 0x2008, 0x0079,
+	0x9a34, 0x1078, 0x7773, 0x007c, 0x9a47, 0x9a49, 0x9a49, 0x9a71,
+	0x9a47, 0x9a47, 0x9a47, 0x9a47, 0x9a47, 0x9a47, 0x9a47, 0x9a47,
+	0x9a47, 0x9a47, 0x9a47, 0x9a47, 0x9a47, 0x9a47, 0x9a47, 0x1078,
+	0x1332, 0x1078, 0x61cd, 0x1078, 0x62d1, 0x037e, 0x0d7e, 0x6010,
+	0xa06d, 0x0040, 0x9a6e, 0xad84, 0xf000, 0x0040, 0x9a6e, 0x6003,
+	0x0002, 0x6018, 0x2004, 0xd0bc, 0x00c0, 0x9a6e, 0x2019, 0x0004,
+	0x1078, 0xa1ca, 0x6013, 0x0000, 0x6014, 0xa005, 0x00c0, 0x9a6c,
+	0x2001, 0xa8a3, 0x2004, 0x6016, 0x6003, 0x0007, 0x0d7f, 0x037f,
+	0x007c, 0x0d7e, 0x1078, 0x61cd, 0x1078, 0x62d1, 0x1078, 0x8d06,
+	0x0040, 0x9a7e, 0x6010, 0x2068, 0x1078, 0x13a4, 0x1078, 0x8ec6,
+	0x0d7f, 0x007c, 0x9a95, 0x9ab4, 0x9a9e, 0x9ac1, 0x9a95, 0x9a95,
+	0x9a95, 0x9a95, 0x9a95, 0x9a95, 0x9a95, 0x9a95, 0x9a95, 0x9a95,
+	0x9a95, 0x9a95, 0x9a95, 0x9a95, 0x9a95, 0x1078, 0x1332, 0x6010,
+	0xa088, 0x0013, 0x2104, 0xa085, 0x0400, 0x200a, 0x1078, 0x61cd,
+	0x6010, 0xa080, 0x0013, 0x2004, 0xd0b4, 0x0040, 0x9aaf, 0x6003,
+	0x0007, 0x2009, 0x0043, 0x1078, 0x775c, 0x0078, 0x9ab1, 0x6003,
+	0x0002, 0x1078, 0x62d1, 0x007c, 0x1078, 0x61cd, 0x1078, 0xa423,
+	0x00c0, 0x9abe, 0x1078, 0x5bc1, 0x1078, 0x772d, 0x1078, 0x62d1,
+	0x007c, 0x1078, 0x61cd, 0x2009, 0x0041, 0x0078, 0x9c1e, 0xa182,
+	0x0040, 0x0079, 0x9acb, 0x9ade, 0x9ae0, 0x9ade, 0x9ade, 0x9ade,
+	0x9ade, 0x9ade, 0x9ae1, 0x9ade, 0x9ade, 0x9ade, 0x9ade, 0x9ade,
+	0x9ade, 0x9ade, 0x9ade, 0x9ade, 0x9aec, 0x9ade, 0x1078, 0x1332,
+	0x007c, 0x6003, 0x0004, 0x6110, 0x20e1, 0x0005, 0x3d18, 0x3e20,
+	0x2c10, 0x1078, 0x15fa, 0x007c, 0x0d7e, 0x1078, 0x5bc1, 0x0d7f,
+	0x1078, 0xa495, 0x1078, 0x772d, 0x007c, 0xa182, 0x0040, 0x0079,
+	0x9af9, 0x9b0c, 0x9b0c, 0x9b0c, 0x9b0c, 0x9b0c, 0x9b0c, 0x9b0c,
+	0x9b0e, 0x9b0c, 0x9b11, 0x9b3c, 0x9b0c, 0x9b0c, 0x9b0c, 0x9b0c,
+	0x9b3c, 0x9b0c, 0x9b0c, 0x9b0c, 0x1078, 0x1332, 0x1078, 0x7773,
+	0x007c, 0x1078, 0x627a, 0x1078, 0x639b, 0x6010, 0x0d7e, 0x2068,
+	0x684c, 0xd0fc, 0x0040, 0x9b27, 0xa08c, 0x0003, 0xa18e, 0x0002,
+	0x0040, 0x9b2f, 0x2009, 0x0041, 0x0d7f, 0x0078, 0x9c1e, 0x6003,
+	0x0007, 0x6017, 0x0000, 0x1078, 0x5bc1, 0x0d7f, 0x007c, 0x1078,
+	0xa423, 0x0040, 0x9b35, 0x0d7f, 0x007c, 0x1078, 0x5bc1, 0x1078,
+	0x772d, 0x0d7f, 0x0078, 0x9b2e, 0x037e, 0x1078, 0x627a, 0x1078,
+	0x639b, 0x6010, 0x0d7e, 0x2068, 0x6018, 0x2004, 0xd0bc, 0x0040,
+	0x9b5c, 0x684c, 0xa084, 0x0003, 0xa086, 0x0002, 0x0040, 0x9b58,
+	0x687c, 0x632c, 0xa31a, 0x632e, 0x6880, 0x6328, 0xa31b, 0x632a,
+	0x6003, 0x0002, 0x0078, 0x9b6d, 0x2019, 0x0004, 0x1078, 0xa1ca,
+	0x6014, 0xa005, 0x00c0, 0x9b69, 0x2001, 0xa8a3, 0x2004, 0x8003,
+	0x6016, 0x6013, 0x0000, 0x6003, 0x0007, 0x0d7f, 0x037f, 0x007c,
+	0xa186, 0x0013, 0x00c0, 0x9b7e, 0x6004, 0xa086, 0x0042, 0x10c0,
+	0x1332, 0x1078, 0x61cd, 0x1078, 0x62d1, 0x007c, 0xa186, 0x0027,
+	0x0040, 0x9b86, 0xa186, 0x0014, 0x00c0, 0x9b96, 0x6004, 0xa086,
+	0x0042, 0x10c0, 0x1332, 0x2001, 0x0007, 0x1078, 0x4535, 0x1078,
+	0x61cd, 0x1078, 0x8ec6, 0x1078, 0x62d1, 0x007c, 0xa182, 0x0040,
+	0x0079, 0x9b9a, 0x9bad, 0x9bad, 0x9bad, 0x9bad, 0x9bad, 0x9bad,
+	0x9bad, 0x9baf, 0x9bbb, 0x9bad, 0x9bad, 0x9bad, 0x9bad, 0x9bad,
+	0x9bad, 0x9bad, 0x9bad, 0x9bad, 0x9bad, 0x1078, 0x1332, 0x037e,
+	0x047e, 0x20e1, 0x0005, 0x3d18, 0x3e20, 0x2c10, 0x1078, 0x15fa,
+	0x047f, 0x037f, 0x007c, 0x6010, 0x0d7e, 0x2068, 0x6810, 0x6a14,
+	0x6118, 0x210c, 0xd1bc, 0x0040, 0x9bda, 0x6124, 0xd1f4, 0x00c0,
+	0x9bda, 0x007e, 0x047e, 0x057e, 0x6c7c, 0xa422, 0x6d80, 0x2200,
+	0xa52b, 0x602c, 0xa420, 0x642e, 0x6028, 0xa529, 0x652a, 0x057f,
+	0x047f, 0x007f, 0xa20d, 0x00c0, 0x9bee, 0x684c, 0xd0fc, 0x0040,
+	0x9be6, 0x2009, 0x0041, 0x0d7f, 0x0078, 0x9c1e, 0x6003, 0x0007,
+	0x6017, 0x0000, 0x1078, 0x5bc1, 0x0d7f, 0x007c, 0x007e, 0x0f7e,
+	0x2c78, 0x1078, 0x4963, 0x0f7f, 0x007f, 0x0040, 0x9bfb, 0x6003,
+	0x0002, 0x0d7f, 0x007c, 0x2009, 0xa60d, 0x210c, 0xd19c, 0x0040,
+	0x9c05, 0x6003, 0x0007, 0x0078, 0x9c07, 0x6003, 0x0006, 0x1078,
+	0x9c0d, 0x1078, 0x5bc3, 0x0d7f, 0x007c, 0xd2fc, 0x0040, 0x9c19,
+	0x8002, 0x8000, 0x8212, 0xa291, 0x0000, 0x2009, 0x0009, 0x0078,
+	0x9c1b, 0x2009, 0x0015, 0x6a6a, 0x6866, 0x007c, 0xa182, 0x0040,
+	0x0048, 0x9c24, 0x0079, 0x9c31, 0xa186, 0x0013, 0x0040, 0x9c2c,
+	0xa186, 0x0014, 0x10c0, 0x1332, 0x6024, 0xd0dc, 0x1040, 0x1332,
+	0x007c, 0x9c44, 0x9c4b, 0x9c57, 0x9c63, 0x9c44, 0x9c44, 0x9c44,
+	0x9c72, 0x9c44, 0x9c46, 0x9c46, 0x9c44, 0x9c44, 0x9c44, 0x9c44,
+	0x9c44, 0x9c44, 0x9c44, 0x9c44, 0x1078, 0x1332, 0x6024, 0xd0dc,
+	0x1040, 0x1332, 0x007c, 0x6003, 0x0001, 0x6106, 0x1078, 0x5d8a,
+	0x127e, 0x2091, 0x8000, 0x1078, 0x62d1, 0x127f, 0x007c, 0x6003,
+	0x0001, 0x6106, 0x1078, 0x5d8a, 0x127e, 0x2091, 0x8000, 0x1078,
+	0x62d1, 0x127f, 0x007c, 0x6003, 0x0003, 0x6106, 0x2c10, 0x1078,
+	0x1cf0, 0x127e, 0x2091, 0x8000, 0x1078, 0x5df6, 0x1078, 0x639b,
+	0x127f, 0x007c, 0xa016, 0x1078, 0x15fa, 0x007c, 0x127e, 0x2091,
+	0x8000, 0x037e, 0x0d7e, 0xa182, 0x0040, 0x1079, 0x9c83, 0x0d7f,
+	0x037f, 0x127f, 0x007c, 0x9c93, 0x9c95, 0x9caa, 0x9cc9, 0x9c93,
+	0x9c93, 0x9c93, 0x9ce1, 0x9c93, 0x9c93, 0x9c93, 0x9c93, 0x9c93,
+	0x9c93, 0x9c93, 0x9c93, 0x1078, 0x1332, 0x6010, 0x2068, 0x684c,
+	0xd0fc, 0x0040, 0x9cbf, 0xa09c, 0x0003, 0xa39e, 0x0003, 0x0040,
+	0x9cbf, 0x6003, 0x0001, 0x6106, 0x1078, 0x5d8a, 0x1078, 0x62d1,
+	0x0078, 0x9ce4, 0x6010, 0x2068, 0x684c, 0xd0fc, 0x0040, 0x9cbf,
+	0xa09c, 0x0003, 0xa39e, 0x0003, 0x0040, 0x9cbf, 0x6003, 0x0001,
+	0x6106, 0x1078, 0x5d8a, 0x1078, 0x62d1, 0x0078, 0x9ce4, 0x6013,
+	0x0000, 0x6017, 0x0000, 0x2019, 0x0004, 0x1078, 0xa1ca, 0x0078,
+	0x9ce4, 0x6010, 0x2068, 0x684c, 0xd0fc, 0x0040, 0x9cbf, 0xa09c,
+	0x0003, 0xa39e, 0x0003, 0x0040, 0x9cbf, 0x6003, 0x0003, 0x6106,
+	0x2c10, 0x1078, 0x1cf0, 0x1078, 0x5df6, 0x1078, 0x639b, 0x0078,
+	0x9ce4, 0xa016, 0x1078, 0x15fa, 0x007c, 0x1078, 0x61cd, 0x6110,
+	0x81ff, 0x0040, 0x9cf6, 0x0d7e, 0x2168, 0x1078, 0xa4e2, 0x037e,
+	0x2019, 0x0029, 0x1078, 0xa1ca, 0x037f, 0x0d7f, 0x1078, 0x8ec6,
+	0x1078, 0x62d1, 0x007c, 0x1078, 0x627a, 0x6110, 0x81ff, 0x0040,
+	0x9d0c, 0x0d7e, 0x2168, 0x1078, 0xa4e2, 0x037e, 0x2019, 0x0029,
+	0x1078, 0xa1ca, 0x037f, 0x0d7f, 0x1078, 0x8ec6, 0x1078, 0x639b,
+	0x007c, 0xa182, 0x0085, 0x0079, 0x9d15, 0x9d1e, 0x9d1c, 0x9d1c,
+	0x9d2a, 0x9d1c, 0x9d1c, 0x9d1c, 0x1078, 0x1332, 0x6003, 0x000b,
+	0x6106, 0x1078, 0x5d8a, 0x127e, 0x2091, 0x8000, 0x1078, 0x62d1,
+	0x127f, 0x007c, 0x027e, 0x0e7e, 0x1078, 0xa41c, 0x0040, 0x9d34,
+	0x1078, 0x772d, 0x0078, 0x9d50, 0x2071, 0xab80, 0x7224, 0x6212,
+	0x7220, 0x1078, 0xa069, 0x0040, 0x9d41, 0x6007, 0x0086, 0x0078,
+	0x9d4a, 0x6007, 0x0087, 0x7224, 0xa296, 0xffff, 0x00c0, 0x9d4a,
+	0x6007, 0x0086, 0x6003, 0x0001, 0x1078, 0x5d8a, 0x1078, 0x62d1,
+	0x0e7f, 0x027f, 0x007c, 0xa186, 0x0013, 0x00c0, 0x9d64, 0x6004,
+	0xa08a, 0x0085, 0x1048, 0x1332, 0xa08a, 0x008c, 0x10c8, 0x1332,
+	0xa082, 0x0085, 0x0079, 0x9d7b, 0xa186, 0x0027, 0x0040, 0x9d70,
+	0xa186, 0x0014, 0x0040, 0x9d70, 0x1078, 0x7773, 0x0078, 0x9d7a,
+	0x2001, 0x0007, 0x1078, 0x4535, 0x1078, 0x61cd, 0x1078, 0x8ec6,
+	0x1078, 0x62d1, 0x007c, 0x9d82, 0x9d84, 0x9d84, 0x9d82, 0x9d82,
+	0x9d82, 0x9d82, 0x1078, 0x1332, 0x1078, 0x61cd, 0x1078, 0x8ec6,
+	0x1078, 0x62d1, 0x007c, 0xa182, 0x0085, 0x1048, 0x1332, 0xa182,
+	0x008c, 0x10c8, 0x1332, 0xa182, 0x0085, 0x0079, 0x9d97, 0x9d9e,
+	0x9d9e, 0x9d9e, 0x9da0, 0x9d9e, 0x9d9e, 0x9d9e, 0x1078, 0x1332,
+	0x007c, 0xa186, 0x0013, 0x0040, 0x9db1, 0xa186, 0x0014, 0x0040,
+	0x9db1, 0xa186, 0x0027, 0x0040, 0x9db1, 0x1078, 0x7773, 0x0078,
+	0x9db7, 0x1078, 0x61cd, 0x1078, 0x8ec6, 0x1078, 0x62d1, 0x007c,
+	0x037e, 0x1078, 0xa495, 0x603f, 0x0000, 0x2019, 0x000b, 0x1078,
+	0x9dc7, 0x601f, 0x0006, 0x6003, 0x0007, 0x037f, 0x007c, 0x127e,
+	0x037e, 0x2091, 0x8000, 0x087e, 0x2c40, 0x097e, 0x2049, 0x0000,
+	0x1078, 0x7246, 0x097f, 0x087f, 0x00c0, 0x9e02, 0x077e, 0x2c38,
+	0x1078, 0x72f3, 0x077f, 0x00c0, 0x9e02, 0x6000, 0xa086, 0x0000,
+	0x0040, 0x9e02, 0x601c, 0xa086, 0x0007, 0x0040, 0x9e02, 0x0d7e,
+	0x6000, 0xa086, 0x0004, 0x00c0, 0x9df3, 0x1078, 0xa495, 0x601f,
+	0x0007, 0x1078, 0x1757, 0x6010, 0x2068, 0x1078, 0x8d06, 0x0040,
+	0x9dfb, 0x1078, 0xa1ca, 0x0d7f, 0x6013, 0x0000, 0x1078, 0xa495,
+	0x601f, 0x0007, 0x037f, 0x127f, 0x007c, 0x0f7e, 0x0c7e, 0x037e,
+	0x157e, 0x2079, 0xab80, 0x7938, 0x783c, 0x1078, 0x254d, 0x00c0,
+	0x9e49, 0x017e, 0x0c7e, 0x1078, 0x45c4, 0x00c0, 0x9e49, 0x017f,
+	0x027f, 0x027e, 0x017e, 0x2019, 0x0029, 0x1078, 0x73d0, 0x1078,
+	0x5f01, 0x077e, 0x2039, 0x0000, 0x1078, 0x5e0a, 0x077f, 0x017f,
+	0x077e, 0x2039, 0x0000, 0x1078, 0x9f8b, 0x077f, 0x1078, 0x47e9,
+	0x027e, 0x6204, 0xa294, 0xff00, 0x8217, 0xa286, 0x0006, 0x0040,
+	0x9e3d, 0xa286, 0x0004, 0x00c0, 0x9e40, 0x62a0, 0x1078, 0x2942,
+	0x027f, 0x017f, 0x1078, 0x42f8, 0x6612, 0x6516, 0xa006, 0x0078,
+	0x9e4b, 0x0c7f, 0x017f, 0x157f, 0x037f, 0x0c7f, 0x0f7f, 0x007c,
+	0x0c7e, 0x0d7e, 0x0e7e, 0x017e, 0x2009, 0xa620, 0x2104, 0xa086,
+	0x0074, 0x00c0, 0x9eb3, 0x2069, 0xab8e, 0x690c, 0xa182, 0x0100,
+	0x0048, 0x9ea3, 0x6908, 0xa184, 0x8000, 0x0040, 0x9eaf, 0x6018,
+	0x2070, 0x7010, 0xa084, 0x00ff, 0x0040, 0x9e72, 0x7000, 0xd0f4,
+	0x0040, 0x9e76, 0xa184, 0x0800, 0x0040, 0x9eaf, 0x6910, 0xa18a,
+	0x0001, 0x0048, 0x9ea7, 0x6914, 0x2069, 0xabae, 0x6904, 0x81ff,
+	0x00c0, 0x9e9b, 0x690c, 0xa182, 0x0100, 0x0048, 0x9ea3, 0x6908,
+	0x81ff, 0x00c0, 0x9e9f, 0x6910, 0xa18a, 0x0001, 0x0048, 0x9ea7,
+	0x6918, 0xa18a, 0x0001, 0x0048, 0x9eaf, 0x0078, 0x9eb9, 0x6013,
+	0x0100, 0x0078, 0x9eb5, 0x6013, 0x0300, 0x0078, 0x9eb5, 0x6013,
+	0x0500, 0x0078, 0x9eb5, 0x6013, 0x0700, 0x0078, 0x9eb5, 0x6013,
+	0x0900, 0x0078, 0x9eb5, 0x6013, 0x0b00, 0x0078, 0x9eb5, 0x6013,
+	0x0f00, 0x0078, 0x9eb5, 0x6013, 0x2d00, 0xa085, 0x0001, 0x0078,
+	0x9eba, 0xa006, 0x017f, 0x0e7f, 0x0d7f, 0x0c7f, 0x007c, 0x0c7e,
+	0x0d7e, 0x027e, 0x037e, 0x157e, 0x6218, 0x2268, 0x6b04, 0xa394,
+	0x00ff, 0xa286, 0x0006, 0x0040, 0x9ee3, 0xa286, 0x0004, 0x0040,
+	0x9ee3, 0xa394, 0xff00, 0x8217, 0xa286, 0x0006, 0x0040, 0x9ee3,
+	0xa286, 0x0004, 0x0040, 0x9ee3, 0x0c7e, 0x2d60, 0x1078, 0x45d6,
+	0x0c7f, 0x0078, 0x9f1e, 0x2011, 0xab96, 0xad98, 0x000a, 0x20a9,
+	0x0004, 0x1078, 0x80de, 0x00c0, 0x9f1f, 0x2011, 0xab9a, 0xad98,
+	0x0006, 0x20a9, 0x0004, 0x1078, 0x80de, 0x00c0, 0x9f1f, 0x047e,
+	0x017e, 0x6aa0, 0xa294, 0x00ff, 0x8227, 0xa006, 0x2009, 0xa653,
+	0x210c, 0xd1a4, 0x0040, 0x9f0b, 0x2009, 0x0029, 0x1078, 0xa21d,
+	0x6800, 0xc0e5, 0x6802, 0x2019, 0x0029, 0x1078, 0x5f01, 0x077e,
+	0x2039, 0x0000, 0x1078, 0x5e0a, 0x2c08, 0x1078, 0x9f8b, 0x077f,
+	0x2001, 0x0007, 0x1078, 0x4535, 0x017f, 0x047f, 0xa006, 0x157f,
+	0x037f, 0x027f, 0x0d7f, 0x0c7f, 0x007c, 0x0d7e, 0x2069, 0xab8e,
+	0x6800, 0xa086, 0x0800, 0x0040, 0x9f31, 0x6013, 0x0000, 0x0078,
+	0x9f32, 0xa006, 0x0d7f, 0x007c, 0x0c7e, 0x0f7e, 0x017e, 0x027e,
+	0x037e, 0x157e, 0x2079, 0xab8c, 0x7930, 0x7834, 0x1078, 0x254d,
+	0x00c0, 0x9f58, 0x1078, 0x45c4, 0x00c0, 0x9f58, 0x2011, 0xab90,
+	0xac98, 0x000a, 0x20a9, 0x0004, 0x1078, 0x80de, 0x00c0, 0x9f58,
+	0x2011, 0xab94, 0xac98, 0x0006, 0x20a9, 0x0004, 0x1078, 0x80de,
+	0x157f, 0x037f, 0x027f, 0x017f, 0x0f7f, 0x0c7f, 0x007c, 0x0c7e,
+	0x007e, 0x017e, 0x027e, 0x037e, 0x157e, 0x2011, 0xab83, 0x2204,
+	0x8211, 0x220c, 0x1078, 0x254d, 0x00c0, 0x9f84, 0x1078, 0x45c4,
+	0x00c0, 0x9f84, 0x2011, 0xab96, 0xac98, 0x000a, 0x20a9, 0x0004,
+	0x1078, 0x80de, 0x00c0, 0x9f84, 0x2011, 0xab9a, 0xac98, 0x0006,
+	0x20a9, 0x0004, 0x1078, 0x80de, 0x157f, 0x037f, 0x027f, 0x017f,
+	0x007f, 0x0c7f, 0x007c, 0x0e7e, 0x0c7e, 0x087e, 0x077e, 0x067e,
+	0x057e, 0x047e, 0x027e, 0x127e, 0x2091, 0x8000, 0x2740, 0x2029,
+	0xa8ba, 0x252c, 0x2021, 0xa8c0, 0x2424, 0x2061, 0xad00, 0x2071,
+	0xa600, 0x7648, 0x7064, 0x81ff, 0x0040, 0x9fb2, 0x007e, 0xa186,
+	0xa9b3, 0x007f, 0x0040, 0x9fb2, 0x8001, 0xa602, 0x00c8, 0xa01c,
+	0x0078, 0x9fb5, 0xa606, 0x0040, 0xa01c, 0x2100, 0xac06, 0x0040,
+	0xa012, 0x1078, 0xa242, 0x0040, 0xa012, 0x671c, 0xa786, 0x0001,
+	0x0040, 0xa037, 0xa786, 0x0004, 0x0040, 0xa037, 0xa786, 0x0007,
+	0x0040, 0xa012, 0x2500, 0xac06, 0x0040, 0xa012, 0x2400, 0xac06,
+	0x0040, 0xa012, 0x1078, 0xa256, 0x00c0, 0xa012, 0x88ff, 0x0040,
+	0x9fdd, 0x6020, 0xa906, 0x00c0, 0xa012, 0x0d7e, 0x6000, 0xa086,
+	0x0004, 0x00c0, 0x9fe7, 0x017e, 0x1078, 0x1757, 0x017f, 0xa786,
+	0x0008, 0x00c0, 0x9ff6, 0x1078, 0x8f00, 0x00c0, 0x9ff6, 0x1078,
+	0x7c83, 0x0d7f, 0x1078, 0x8ec6, 0x0078, 0xa012, 0x6010, 0x2068,
+	0x1078, 0x8d06, 0x0040, 0xa00f, 0xa786, 0x0003, 0x00c0, 0xa026,
+	0x6837, 0x0103, 0x6b4a, 0x6847, 0x0000, 0x1078, 0xa4e2, 0x017e,
+	0x1078, 0x8f7d, 0x1078, 0x4a73, 0x017f, 0x1078, 0x8eb9, 0x0d7f,
+	0x1078, 0x8ec6, 0xace0, 0x0010, 0x2001, 0xa616, 0x2004, 0xac02,
+	0x00c8, 0xa01c, 0x0078, 0x9f9f, 0x127f, 0x027f, 0x047f, 0x057f,
+	0x067f, 0x077f, 0x087f, 0x0c7f, 0x0e7f, 0x007c, 0xa786, 0x0006,
+	0x00c0, 0xa000, 0xa386, 0x0005, 0x0040, 0xa034, 0x1078, 0xa4e2,
+	0x1078, 0xa1ca, 0x0078, 0xa00f, 0x0d7f, 0x0078, 0xa012, 0x1078,
+	0xa256, 0x00c0, 0xa012, 0x81ff, 0x0040, 0xa012, 0xa180, 0x0001,
+	0x2004, 0xa086, 0x0018, 0x0040, 0xa04c, 0xa180, 0x0001, 0x2004,
+	0xa086, 0x002d, 0x00c0, 0xa012, 0x6000, 0xa086, 0x0002, 0x00c0,
+	0xa012, 0x1078, 0x8eec, 0x0040, 0xa05d, 0x1078, 0x8f00, 0x00c0,
+	0xa012, 0x1078, 0x7c83, 0x0078, 0xa065, 0x1078, 0x28a6, 0x1078,
+	0x8f00, 0x00c0, 0xa065, 0x1078, 0x7c83, 0x1078, 0x8ec6, 0x0078,
+	0xa012, 0x0c7e, 0x0e7e, 0x017e, 0x2c08, 0x2170, 0xa006, 0x1078,
+	0xa1e6, 0x017f, 0x0040, 0xa079, 0x601c, 0xa084, 0x000f, 0x1079,
+	0xa07c, 0x0e7f, 0x0c7f, 0x007c, 0xa084, 0xa084, 0xa084, 0xa084,
+	0xa084, 0xa084, 0xa086, 0xa084, 0xa006, 0x007c, 0x047e, 0x017e,
+	0x7018, 0xa080, 0x0028, 0x2024, 0xa4a4, 0x00ff, 0x8427, 0x2c00,
+	0x2009, 0x0020, 0x1078, 0xa21d, 0x017f, 0x047f, 0x037e, 0x2019,
+	0x0002, 0x1078, 0x9dc7, 0x037f, 0xa085, 0x0001, 0x007c, 0x2001,
+	0x0001, 0x1078, 0x44ee, 0x157e, 0x017e, 0x027e, 0x037e, 0x20a9,
+	0x0004, 0x2019, 0xa605, 0x2011, 0xab96, 0x1078, 0x80de, 0x037f,
+	0x027f, 0x017f, 0x157f, 0xa005, 0x007c, 0x0f7e, 0x0e7e, 0x0c7e,
+	0x087e, 0x077e, 0x067e, 0x027e, 0x127e, 0x2091, 0x8000, 0x2740,
+	0x2061, 0xad00, 0x2079, 0x0001, 0x8fff, 0x0040, 0xa11d, 0x2071,
+	0xa600, 0x7648, 0x7064, 0x8001, 0xa602, 0x00c8, 0xa11d, 0x88ff,
+	0x0040, 0xa0d8, 0x2800, 0xac06, 0x00c0, 0xa113, 0x2079, 0x0000,
+	0x1078, 0xa242, 0x0040, 0xa113, 0x2400, 0xac06, 0x0040, 0xa113,
+	0x671c, 0xa786, 0x0006, 0x00c0, 0xa113, 0xa786, 0x0007, 0x0040,
+	0xa113, 0x88ff, 0x00c0, 0xa0f7, 0x6018, 0xa206, 0x00c0, 0xa113,
+	0x85ff, 0x0040, 0xa0f7, 0x6020, 0xa106, 0x00c0, 0xa113, 0x0d7e,
+	0x6000, 0xa086, 0x0004, 0x00c0, 0xa103, 0x1078, 0xa495, 0x601f,
+	0x0007, 0x1078, 0x1757, 0x6010, 0x2068, 0x1078, 0x8d06, 0x0040,
+	0xa10d, 0x047e, 0x1078, 0xa1ca, 0x047f, 0x0d7f, 0x1078, 0x8ec6,
+	0x88ff, 0x00c0, 0xa127, 0xace0, 0x0010, 0x2001, 0xa616, 0x2004,
+	0xac02, 0x00c8, 0xa11d, 0x0078, 0xa0c4, 0xa006, 0x127f, 0x027f,
+	0x067f, 0x077f, 0x087f, 0x0c7f, 0x0e7f, 0x0f7f, 0x007c, 0xa8c5,
+	0x0001, 0x0078, 0xa11e, 0x077e, 0x057e, 0x087e, 0x2041, 0x0000,
+	0x2029, 0x0001, 0x2c20, 0x2019, 0x0002, 0x6218, 0x097e, 0x2049,
+	0x0000, 0x1078, 0x7246, 0x097f, 0x087f, 0x2039, 0x0000, 0x1078,
+	0x72f3, 0x1078, 0xa0b5, 0x057f, 0x077f, 0x007c, 0x027e, 0x047e,
+	0x057e, 0x077e, 0x0c7e, 0x157e, 0x2c20, 0x2128, 0x20a9, 0x007f,
+	0x2009, 0x0000, 0x017e, 0x037e, 0x1078, 0x45c4, 0x00c0, 0xa16e,
+	0x2c10, 0x057e, 0x087e, 0x2041, 0x0000, 0x2508, 0x2029, 0x0001,
+	0x097e, 0x2049, 0x0000, 0x1078, 0x7246, 0x097f, 0x087f, 0x2039,
+	0x0000, 0x1078, 0x72f3, 0x1078, 0xa0b5, 0x057f, 0x037f, 0x017f,
+	0x8108, 0x00f0, 0xa152, 0x157f, 0x0c7f, 0x077f, 0x057f, 0x047f,
+	0x027f, 0x007c, 0x077e, 0x057e, 0x6218, 0x087e, 0x2041, 0x0000,
+	0x2029, 0x0001, 0x2019, 0x0048, 0x097e, 0x2049, 0x0000, 0x1078,
+	0x7246, 0x097f, 0x087f, 0x2039, 0x0000, 0x1078, 0x72f3, 0x2c20,
+	0x1078, 0xa0b5, 0x057f, 0x077f, 0x007c, 0x027e, 0x047e, 0x057e,
+	0x077e, 0x0c7e, 0x157e, 0x2c20, 0x20a9, 0x007f, 0x2009, 0x0000,
+	0x017e, 0x037e, 0x1078, 0x45c4, 0x00c0, 0xa1be, 0x2c10, 0x087e,
+	0x2041, 0x0000, 0x2828, 0x047e, 0x2021, 0x0001, 0x1078, 0xa472,
+	0x047f, 0x097e, 0x2049, 0x0000, 0x1078, 0x7246, 0x097f, 0x087f,
+	0x2039, 0x0000, 0x1078, 0x72f3, 0x1078, 0xa0b5, 0x037f, 0x017f,
+	0x8108, 0x00f0, 0xa1a0, 0x157f, 0x0c7f, 0x077f, 0x057f, 0x047f,
+	0x027f, 0x007c, 0x017e, 0x0f7e, 0xad82, 0xcd00, 0x0048, 0xa1e3,
+	0xad82, 0xffff, 0x00c8, 0xa1e3, 0x6800, 0xa07d, 0x0040, 0xa1e0,
+	0x6803, 0x0000, 0x6b52, 0x1078, 0x4a73, 0x2f68, 0x0078, 0xa1d4,
+	0x6b52, 0x1078, 0x4a73, 0x0f7f, 0x017f, 0x007c, 0x0e7e, 0x047e,
+	0x037e, 0x2061, 0xad00, 0xa005, 0x00c0, 0xa1f6, 0x2071, 0xa600,
+	0x7448, 0x7064, 0x8001, 0xa402, 0x00c8, 0xa218, 0x2100, 0xac06,
+	0x0040, 0xa20a, 0x6000, 0xa086, 0x0000, 0x0040, 0xa20a, 0x6008,
+	0xa206, 0x00c0, 0xa20a, 0x6018, 0xa1a0, 0x0006, 0x2424, 0xa406,
+	0x0040, 0xa214, 0xace0, 0x0010, 0x2001, 0xa616, 0x2004, 0xac02,
+	0x00c8, 0xa218, 0x0078, 0xa1f6, 0xa085, 0x0001, 0x0078, 0xa219,
+	0xa006, 0x037f, 0x047f, 0x0e7f, 0x007c, 0x0d7e, 0x007e, 0x1078,
+	0x138b, 0x007f, 0x1040, 0x1332, 0x6837, 0x010d, 0x685e, 0x027e,
+	0x2010, 0x1078, 0x8cf2, 0x2001, 0x0000, 0x0040, 0xa233, 0x2200,
+	0xa080, 0x0008, 0x2004, 0x027f, 0x684a, 0x6956, 0x6c46, 0x684f,
+	0x0000, 0xa006, 0x68b2, 0x6802, 0x683a, 0x685a, 0x1078, 0x4a73,
+	0x0d7f, 0x007c, 0x6700, 0xa786, 0x0000, 0x0040, 0xa255, 0xa786,
+	0x0001, 0x0040, 0xa255, 0xa786, 0x000a, 0x0040, 0xa255, 0xa786,
+	0x0009, 0x0040, 0xa255, 0xa085, 0x0001, 0x007c, 0x0e7e, 0x6018,
+	0x2070, 0x70a0, 0xa206, 0x0e7f, 0x007c, 0x017e, 0x6004, 0xa08e,
+	0x001e, 0x00c0, 0xa277, 0x8007, 0x6130, 0xa18c, 0x00ff, 0xa105,
+	0x6032, 0x6007, 0x0085, 0x6003, 0x000b, 0x601f, 0x0005, 0x2001,
+	0xa8a3, 0x2004, 0x6016, 0x1078, 0x5d8a, 0x1078, 0x62d1, 0x017f,
+	0x007c, 0x0005, 0x0005, 0x007c, 0x6024, 0xd0e4, 0x0040, 0xa28d,
+	0xd0cc, 0x0040, 0xa287, 0x1078, 0x8fbf, 0x0078, 0xa28d, 0x1078,
+	0xa495, 0x1078, 0x5bc1, 0x1078, 0x772d, 0x007c, 0xa280, 0x0007,
+	0x2004, 0xa084, 0x000f, 0x0079, 0xa295, 0xa29e, 0xa29e, 0xa29e,
+	0xa2a0, 0xa29e, 0xa2a0, 0xa2a0, 0xa29e, 0xa2a0, 0xa006, 0x007c,
+	0xa085, 0x0001, 0x007c, 0xa280, 0x0007, 0x2004, 0xa084, 0x000f,
+	0x0079, 0xa2aa, 0xa2b3, 0xa2b3, 0xa2b3, 0xa2b3, 0xa2b3, 0xa2b3,
+	0xa2be, 0xa2b3, 0xa2b3, 0x6007, 0x003b, 0x602b, 0x0009, 0x6013,
+	0x2a00, 0x6003, 0x0001, 0x1078, 0x5d8a, 0x007c, 0x0c7e, 0x2260,
+	0x1078, 0xa495, 0x603f, 0x0000, 0x6024, 0xc0f4, 0xc0cc, 0x6026,
+	0x0c7f, 0x0d7e, 0x2268, 0xa186, 0x0007, 0x00c0, 0xa31f, 0x6810,
+	0xa005, 0x0040, 0xa2dc, 0xa080, 0x0013, 0x2004, 0xd0fc, 0x00c0,
+	0xa2dc, 0x0d7f, 0x0078, 0xa2b3, 0x6007, 0x003a, 0x6003, 0x0001,
+	0x1078, 0x5d8a, 0x1078, 0x62d1, 0x0c7e, 0x2d60, 0x6100, 0xa186,
+	0x0002, 0x00c0, 0xa3ad, 0x6010, 0xa005, 0x00c0, 0xa2f6, 0x6000,
+	0xa086, 0x0007, 0x10c0, 0x1332, 0x0078, 0xa3ad, 0xa08c, 0xf000,
+	0x00c0, 0xa302, 0x0078, 0xa302, 0x2068, 0x6800, 0xa005, 0x00c0,
+	0xa2fc, 0x2d00, 0xa080, 0x0013, 0x2004, 0xa084, 0x0003, 0xa086,
+	0x0002, 0x00c0, 0xa31b, 0x6010, 0x2068, 0x684c, 0xc0dc, 0xc0f4,
+	0x684e, 0x6850, 0xc0f4, 0xc0fc, 0x6852, 0x2009, 0x0043, 0x1078,
+	0x9c1e, 0x0078, 0xa3ad, 0x2009, 0x0041, 0x0078, 0xa3a7, 0xa186,
+	0x0005, 0x00c0, 0xa366, 0x6810, 0xa080, 0x0013, 0x2004, 0xd0bc,
+	0x00c0, 0xa32d, 0x0d7f, 0x0078, 0xa2b3, 0xd0b4, 0x0040, 0xa335,
+	0xd0fc, 0x1040, 0x1332, 0x0078, 0xa2cf, 0x6007, 0x003a, 0x6003,
+	0x0001, 0x1078, 0x5d8a, 0x1078, 0x62d1, 0x0c7e, 0x2d60, 0x6100,
+	0xa186, 0x0002, 0x0040, 0xa348, 0xa186, 0x0004, 0x00c0, 0xa3ad,
+	0x2071, 0xa8e7, 0x7000, 0xa086, 0x0003, 0x00c0, 0xa355, 0x7004,
+	0xac06, 0x00c0, 0xa355, 0x7003, 0x0000, 0x6810, 0xa080, 0x0013,
+	0x200c, 0xc1f4, 0xc1dc, 0x2102, 0x8000, 0x200c, 0xc1f4, 0xc1fc,
+	0xc1bc, 0x2102, 0x2009, 0x0042, 0x0078, 0xa3a7, 0x037e, 0x0d7e,
+	0x0d7e, 0x1078, 0x138b, 0x037f, 0x1040, 0x1332, 0x6837, 0x010d,
+	0x6803, 0x0000, 0x683b, 0x0000, 0x685b, 0x0000, 0x6b5e, 0x6857,
+	0x0045, 0x2c00, 0x6862, 0x6034, 0x6872, 0x2360, 0x6024, 0xc0dd,
+	0x6026, 0x6018, 0xa080, 0x0028, 0x2004, 0xa084, 0x00ff, 0x8007,
+	0x6320, 0x6b4a, 0x6846, 0x684f, 0x0000, 0x6d6a, 0x6e66, 0x686f,
+	0x0001, 0x1078, 0x4a73, 0x2019, 0x0045, 0x6008, 0x2068, 0x1078,
+	0x9dc7, 0x2d00, 0x600a, 0x601f, 0x0006, 0x6003, 0x0007, 0x6017,
+	0x0000, 0x603f, 0x0000, 0x0d7f, 0x037f, 0x0078, 0xa3ae, 0x603f,
+	0x0000, 0x6003, 0x0007, 0x1078, 0x9c1e, 0x0c7f, 0x0d7f, 0x007c,
+	0xa186, 0x0013, 0x00c0, 0xa3ba, 0x6004, 0xa082, 0x0085, 0x2008,
+	0x0079, 0xa3d4, 0xa186, 0x0027, 0x00c0, 0xa3cd, 0x1078, 0x61cd,
+	0x037e, 0x0d7e, 0x6010, 0x2068, 0x2019, 0x0004, 0x1078, 0xa1ca,
+	0x0d7f, 0x037f, 0x1078, 0x62d1, 0x007c, 0xa186, 0x0014, 0x0040,
+	0xa3be, 0x1078, 0x7773, 0x007c, 0xa3dd, 0xa3db, 0xa3db, 0xa3db,
+	0xa3db, 0xa3db, 0xa3dd, 0x1078, 0x1332, 0x1078, 0x61cd, 0x6003,
+	0x000c, 0x1078, 0x62d1, 0x007c, 0xa182, 0x008c, 0x00c8, 0xa3ee,
+	0xa182, 0x0085, 0x0048, 0xa3ee, 0x0079, 0xa3f1, 0x1078, 0x7773,
+	0x007c, 0xa3f8, 0xa3f8, 0xa3f8, 0xa3f8, 0xa3fa, 0xa419, 0xa3f8,
+	0x1078, 0x1332, 0x0d7e, 0x2c68, 0x1078, 0x76c7, 0x0040, 0xa414,
+	0x6003, 0x0001, 0x6007, 0x001e, 0x2009, 0xab8e, 0x210c, 0x6136,
+	0x2009, 0xab8f, 0x210c, 0x613a, 0x600b, 0xffff, 0x6918, 0x611a,
+	0x601f, 0x0004, 0x1078, 0x5d8a, 0x2d60, 0x1078, 0x772d, 0x0d7f,
+	0x007c, 0x1078, 0x772d, 0x007c, 0x0e7e, 0x6018, 0x2070, 0x7000,
+	0xd0ec, 0x0e7f, 0x007c, 0x6010, 0xa08c, 0xf000, 0x0040, 0xa471,
+	0xa080, 0x0013, 0x200c, 0xd1ec, 0x0040, 0xa471, 0x2001, 0xa672,
+	0x2004, 0xd0ec, 0x0040, 0xa471, 0x6003, 0x0002, 0x6024, 0xc0e5,
+	0x6026, 0xd1ac, 0x0040, 0xa44f, 0x0f7e, 0x2c78, 0x1078, 0x495f,
+	0x0f7f, 0x0040, 0xa44f, 0x2001, 0xa8a4, 0x2004, 0x603e, 0x2009,
+	0xa672, 0x210c, 0xd1f4, 0x00c0, 0xa46f, 0x0078, 0xa461, 0x2009,
+	0xa672, 0x210c, 0xd1f4, 0x0040, 0xa45b, 0x6024, 0xc0e4, 0x6026,
+	0xa006, 0x0078, 0xa471, 0x2001, 0xa8a4, 0x200c, 0x8103, 0xa100,
+	0x603e, 0x6018, 0xa088, 0x002b, 0x2104, 0xa005, 0x0040, 0xa46c,
+	0xa088, 0x0003, 0x0078, 0xa464, 0x2c0a, 0x600f, 0x0000, 0xa085,
+	0x0001, 0x007c, 0x017e, 0x0c7e, 0x0e7e, 0x6120, 0xa2f0, 0x002b,
+	0x2e04, 0x2060, 0x8cff, 0x0040, 0xa491, 0x84ff, 0x00c0, 0xa484,
+	0x6020, 0xa106, 0x00c0, 0xa48c, 0x600c, 0x2072, 0x1078, 0x5bc1,
+	0x1078, 0x772d, 0x0078, 0xa48e, 0xacf0, 0x0003, 0x2e64, 0x0078,
+	0xa47a, 0x0e7f, 0x0c7f, 0x017f, 0x007c, 0x0d7e, 0x6018, 0xa0e8,
+	0x002b, 0x2d04, 0xa005, 0x0040, 0xa4a7, 0xac06, 0x0040, 0xa4a5,
+	0x2d04, 0xa0e8, 0x0003, 0x0078, 0xa499, 0x600c, 0x206a, 0x0d7f,
+	0x007c, 0x027e, 0x037e, 0x157e, 0x2011, 0xa626, 0x2204, 0xa084,
+	0x00ff, 0x2019, 0xab8e, 0x2334, 0xa636, 0x00c0, 0xa4d5, 0x8318,
+	0x2334, 0x2204, 0xa084, 0xff00, 0xa636, 0x00c0, 0xa4d5, 0x2011,
+	0xab90, 0x6018, 0xa098, 0x000a, 0x20a9, 0x0004, 0x1078, 0x80de,
+	0x00c0, 0xa4d5, 0x2011, 0xab94, 0x6018, 0xa098, 0x0006, 0x20a9,
+	0x0004, 0x1078, 0x80de, 0x00c0, 0xa4d5, 0x157f, 0x037f, 0x027f,
+	0x007c, 0x0e7e, 0x2071, 0xa600, 0x1078, 0x42b8, 0x1078, 0x2677,
+	0x0e7f, 0x007c, 0x0e7e, 0x6018, 0x2070, 0x7000, 0xd0fc, 0x0040,
+	0xa4eb, 0x1078, 0xa4ed, 0x0e7f, 0x007c, 0x6850, 0xc0e5, 0x6852,
+	0x007c, 0x0e7e, 0x0c7e, 0x077e, 0x067e, 0x057e, 0x047e, 0x027e,
+	0x017e, 0x127e, 0x2091, 0x8000, 0x2029, 0xa8ba, 0x252c, 0x2021,
+	0xa8c0, 0x2424, 0x2061, 0xad00, 0x2071, 0xa600, 0x7648, 0x7064,
+	0xa606, 0x0040, 0xa545, 0x671c, 0xa786, 0x0001, 0x0040, 0xa514,
+	0xa786, 0x0008, 0x00c0, 0xa53b, 0x2500, 0xac06, 0x0040, 0xa53b,
+	0x2400, 0xac06, 0x0040, 0xa53b, 0x1078, 0xa242, 0x0040, 0xa53b,
+	0x1078, 0xa256, 0x00c0, 0xa53b, 0x6000, 0xa086, 0x0004, 0x00c0,
+	0xa52d, 0x017e, 0x1078, 0x1757, 0x017f, 0x1078, 0x8eec, 0x00c0,
+	0xa533, 0x1078, 0x28a6, 0x1078, 0x8f00, 0x00c0, 0xa539, 0x1078,
+	0x7c83, 0x1078, 0x8ec6, 0xace0, 0x0010, 0x2001, 0xa616, 0x2004,
+	0xac02, 0x00c8, 0xa545, 0x0078, 0xa504, 0x127f, 0x017f, 0x027f,
+	0x047f, 0x057f, 0x067f, 0x077f, 0x0c7f, 0x0e7f, 0x007c, 0x127e,
+	0x007e, 0x0e7e, 0x017e, 0x2091, 0x8000, 0x2071, 0xa640, 0xd5a4,
+	0x0040, 0xa55d, 0x7034, 0x8000, 0x7036, 0xd5b4, 0x0040, 0xa563,
+	0x7030, 0x8000, 0x7032, 0xd5ac, 0x0040, 0xa579, 0x2500, 0xa084,
+	0x0007, 0xa08e, 0x0003, 0x0040, 0xa579, 0xa08e, 0x0004, 0x0040,
+	0xa579, 0xa08e, 0x0005, 0x0040, 0xa579, 0x2071, 0xa64a, 0x1078,
+	0xa5ba, 0x017f, 0x0e7f, 0x007f, 0x127f, 0x007c, 0x127e, 0x007e,
+	0x0e7e, 0x017e, 0x2091, 0x8000, 0x2071, 0xa640, 0xd5a4, 0x0040,
+	0xa58c, 0x7034, 0x8000, 0x7036, 0xd5b4, 0x0040, 0xa592, 0x7030,
+	0x8000, 0x7032, 0xd5ac, 0x0040, 0xa5a8, 0x2500, 0xa084, 0x0007,
+	0xa08e, 0x0003, 0x0040, 0xa5a8, 0xa08e, 0x0004, 0x0040, 0xa5a8,
+	0xa08e, 0x0005, 0x0040, 0xa5a8, 0x2071, 0xa64a, 0x1078, 0xa5ba,
+	0x017f, 0x0e7f, 0x007f, 0x127f, 0x007c, 0x127e, 0x007e, 0x0e7e,
+	0x2091, 0x8000, 0x2071, 0xa642, 0x1078, 0xa5ba, 0x0e7f, 0x007f,
+	0x127f, 0x007c, 0x2e04, 0x8000, 0x2072, 0x00c8, 0xa5c3, 0x8e70,
+	0x2e04, 0x8000, 0x2072, 0x007c, 0x0e7e, 0x2071, 0xa640, 0x1078,
+	0xa5ba, 0x0e7f, 0x007c, 0x0e7e, 0x2071, 0xa644, 0x1078, 0xa5ba,
+	0x0e7f, 0x007c, 0x127e, 0x007e, 0x0e7e, 0x2091, 0x8000, 0x2071,
+	0xa640, 0x7044, 0x8000, 0x7046, 0x0e7f, 0x007f, 0x127f, 0x007c,
+	0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
+	0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000,
+	0xa50c
+};
+#ifdef UNIQUE_FW_NAME
+unsigned short fw2100tp_length01 = 0x95f1;
+#else
+unsigned short risc_code_length01 = 0x95f1;
+#endif
+
diff -puN /dev/null drivers/scsi/qla2xxx/ql2200.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/ql2200.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,92 @@
+/*
+ * QLogic ISP2200 device driver for Linux 2.6.x
+ * Copyright (C) 2003 Christoph Hellwig.
+ * Copyright (C) 2003 QLogic Corporation (www.qlogic.com)
+ *
+ * Released under GPL v2.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+
+#include "qla_os.h"
+#include "qla_def.h"
+
+static char qla_driver_name[] = "qla2200";
+
+extern unsigned char  fw2200tp_version[];
+extern unsigned char  fw2200tp_version_str[];
+extern unsigned short fw2200tp_addr01;
+extern unsigned short fw2200tp_code01[];
+extern unsigned short fw2200tp_length01;
+
+static struct qla_fw_info qla_fw_tbl[] = {
+	{
+		.addressing	= FW_INFO_ADDR_NORMAL,
+		.fwcode		= &fw2200tp_code01[0],
+		.fwlen		= &fw2200tp_length01,
+		.fwstart	= &fw2200tp_addr01,
+	},
+
+	{ FW_INFO_ADDR_NOMORE, },
+};
+
+static struct qla_board_info qla_board_tbl = {
+	.drv_name	= qla_driver_name,
+
+	.isp_name	= "ISP2200",
+	.fw_info	= qla_fw_tbl,
+};
+
+static struct pci_device_id qla2200_pci_tbl[] = {
+	{
+		.vendor		= PCI_VENDOR_ID_QLOGIC,
+		.device		= PCI_DEVICE_ID_QLOGIC_ISP2200,
+		.subvendor	= PCI_ANY_ID,
+		.subdevice	= PCI_ANY_ID,
+		.driver_data	= (unsigned long)&qla_board_tbl,
+	},
+
+	{0, 0},
+};
+MODULE_DEVICE_TABLE(pci, qla2200_pci_tbl);
+
+static int __devinit
+qla2200_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+	return qla2x00_probe_one(pdev,
+	    (struct qla_board_info *)id->driver_data);
+}
+
+static void __devexit
+qla2200_remove_one(struct pci_dev *pdev)
+{
+	qla2x00_remove_one(pdev);
+}
+
+static struct pci_driver qla2200_pci_driver = {
+	.name		= "qla2200",
+	.id_table	= qla2200_pci_tbl,
+	.probe		= qla2200_probe_one,
+	.remove		= __devexit_p(qla2200_remove_one),
+};
+
+static int __init
+qla2200_init(void)
+{
+	return pci_module_init(&qla2200_pci_driver);
+}
+
+static void __exit
+qla2200_exit(void)
+{
+	pci_unregister_driver(&qla2200_pci_driver);
+}
+
+module_init(qla2200_init);
+module_exit(qla2200_exit);
+
+MODULE_AUTHOR("QLogic Corporation");
+MODULE_DESCRIPTION("QLogic ISP22xx FC-SCSI Host Bus Adapter driver");
+MODULE_LICENSE("GPL");
diff -puN /dev/null drivers/scsi/qla2xxx/ql2200_fw.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/ql2200_fw.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,5321 @@
+/******************************************************************************
+ *                  QLOGIC LINUX SOFTWARE
+ *
+ * QLogic ISP2x00 device driver for Linux 2.6.x
+ * Copyright (C) 2003 QLogic Corporation
+ * (www.qlogic.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ *************************************************************************/
+
+/*
+ *	Firmware Version 2.02.06 (08:46 Jun 26, 2003)
+ */
+
+#ifdef UNIQUE_FW_NAME
+unsigned short fw2200tp_version = 2*1024+2;
+#else
+unsigned short risc_code_version = 2*1024+2;
+#endif
+
+#ifdef UNIQUE_FW_NAME
+unsigned char fw2200tp_version_str[] = {2,2,6};
+#else
+unsigned char firmware_version[] = {2,2,6};
+#endif
+
+#ifdef UNIQUE_FW_NAME
+#define fw2200tp_VERSION_STRING "2.02.06"
+#else
+#define FW_VERSION_STRING "2.02.06"
+#endif
+
+#ifdef UNIQUE_FW_NAME
+unsigned short fw2200tp_addr01 = 0x1000 ;
+#else
+unsigned short risc_code_addr01 = 0x1000 ;
+#endif
+
+#ifdef UNIQUE_FW_NAME
+unsigned short fw2200tp_code01[] = { 
+#else
+unsigned short risc_code01[] = { 
+#endif
+	0x0470, 0x0000, 0x0000, 0xa46f, 0x0000, 0x0002, 0x0002, 0x0006,
+	0x0017, 0x2043, 0x4f50, 0x5952, 0x4947, 0x4854, 0x2032, 0x3030,
+	0x3120, 0x514c, 0x4f47, 0x4943, 0x2043, 0x4f52, 0x504f, 0x5241,
+	0x5449, 0x4f4e, 0x2049, 0x5350, 0x3232, 0x3030, 0x2046, 0x6972,
+	0x6d77, 0x6172, 0x6520, 0x2056, 0x6572, 0x7369, 0x6f6e, 0x2030,
+	0x322e, 0x3032, 0x2e30, 0x3620, 0x2020, 0x2020, 0x2400, 0x20c1,
+	0x0005, 0x2001, 0x017f, 0x2003, 0x0000, 0x20c9, 0xbaff, 0x2091,
+	0x2000, 0x2059, 0x0000, 0x2b78, 0x7823, 0x0004, 0x2089, 0x296a,
+	0x2051, 0xb500, 0x2a70, 0x2029, 0xed00, 0x2031, 0xffff, 0x2039,
+	0xece9, 0x2021, 0x0200, 0x0804, 0x1468, 0x20a1, 0xb46f, 0xa00e,
+	0x20a9, 0x0891, 0x41a4, 0x3400, 0x7562, 0x7666, 0x775e, 0x746a,
+	0x746e, 0x20a1, 0xbd00, 0x7164, 0x810d, 0x810d, 0x810d, 0x810d,
+	0xa18c, 0x000f, 0x2001, 0x000b, 0xa112, 0xa00e, 0x21a8, 0x41a4,
+	0x3400, 0x8211, 0x1dd8, 0x7164, 0x3400, 0xa102, 0x0120, 0x0218,
+	0x20a8, 0xa00e, 0x41a4, 0x3800, 0xd08c, 0x01d8, 0x2009, 0xb500,
+	0x810d, 0x810d, 0x810d, 0x810d, 0xa18c, 0x000f, 0x2001, 0x0001,
+	0xa112, 0x20a1, 0x1000, 0xa00e, 0x21a8, 0x41a4, 0x8211, 0x1de0,
+	0x2009, 0xb500, 0x3400, 0xa102, 0x0120, 0x0218, 0x20a8, 0xa00e,
+	0x41a4, 0x080c, 0x1411, 0x080c, 0x1632, 0x080c, 0x17cf, 0x080c,
+	0x1fa2, 0x080c, 0x4bff, 0x080c, 0x85bf, 0x080c, 0x15bb, 0x080c,
+	0x2ec4, 0x080c, 0x5d8a, 0x080c, 0x5341, 0x080c, 0x68ce, 0x080c,
+	0x2510, 0x080c, 0x6b61, 0x080c, 0x63bb, 0x080c, 0x23ca, 0x080c,
+	0x24de, 0x2091, 0x3009, 0x7823, 0x0000, 0x1004, 0x10c5, 0x7820,
+	0xa086, 0x0002, 0x1150, 0x7823, 0x4000, 0x0e04, 0x10bd, 0x781b,
+	0x0001, 0x2091, 0x5000, 0x2091, 0x4080, 0x2a70, 0x7003, 0x0000,
+	0x2a70, 0x7000, 0xa08e, 0x0003, 0x1158, 0x080c, 0x3f08, 0x080c,
+	0x2eeb, 0x080c, 0x5dd8, 0x080c, 0x54f0, 0x080c, 0x68f9, 0x0c80,
+	0x000b, 0x0c98, 0x10e4, 0x10e5, 0x1210, 0x10e2, 0x12dd, 0x140e,
+	0x140f, 0x1410, 0x080c, 0x1515, 0x0005, 0x0126, 0x00f6, 0x2091,
+	0x8000, 0x7000, 0xa086, 0x0001, 0x1904, 0x11ed, 0x080c, 0x1588,
+	0x080c, 0x5acf, 0x0150, 0x080c, 0x5af5, 0x15c0, 0x2079, 0x0100,
+	0x7828, 0xa085, 0x1800, 0x782a, 0x0488, 0x080c, 0x5a07, 0x7000,
+	0xa086, 0x0001, 0x1904, 0x11ed, 0x708c, 0xa086, 0x0028, 0x1904,
+	0x11ed, 0x2001, 0x0161, 0x2003, 0x0001, 0x2079, 0x0100, 0x7827,
+	0xffff, 0x7a28, 0xa295, 0x1e2f, 0x7a2a, 0x2011, 0x59a2, 0x080c,
+	0x699c, 0x2011, 0x5995, 0x080c, 0x6a5c, 0x2011, 0x59e4, 0x080c,
+	0x699c, 0x2011, 0x4adc, 0x080c, 0x699c, 0x2011, 0x8030, 0x2019,
+	0x0000, 0x708b, 0x0000, 0x080c, 0x1de9, 0x00e8, 0x080c, 0x448f,
+	0x2079, 0x0100, 0x7844, 0xa005, 0x1904, 0x11ed, 0x2011, 0x4adc,
+	0x080c, 0x699c, 0x2011, 0x59e4, 0x080c, 0x699c, 0x080c, 0x1de9,
+	0x2001, 0xb78d, 0x2004, 0x780e, 0x7840, 0xa084, 0xfffb, 0x7842,
+	0x2011, 0x8010, 0x73cc, 0x080c, 0x3ecc, 0x723c, 0xc284, 0x723e,
+	0x2001, 0xb50c, 0x200c, 0xc1ac, 0x2102, 0x080c, 0x7f35, 0x2011,
+	0x0004, 0x080c, 0x9c60, 0x080c, 0x524d, 0x080c, 0x5acf, 0x0158,
+	0x080c, 0x4be8, 0x0140, 0x708b, 0x0001, 0x70c7, 0x0000, 0x080c,
+	0x462c, 0x0804, 0x11ed, 0x080c, 0x5309, 0x0120, 0x7a0c, 0xc2b4,
+	0x7a0e, 0x0060, 0x7073, 0x0000, 0x080c, 0xa008, 0x70d4, 0xd09c,
+	0x1128, 0x70a0, 0xa005, 0x0110, 0x080c, 0x4bc6, 0x70df, 0x0000,
+	0x70db, 0x0000, 0x72d4, 0x080c, 0x5acf, 0x1178, 0x2011, 0x0000,
+	0x0016, 0x080c, 0x28eb, 0x2019, 0xb78f, 0x211a, 0x001e, 0x7053,
+	0xffff, 0x7057, 0x00ef, 0x7077, 0x0000, 0x2079, 0xb552, 0x7804,
+	0xd0ac, 0x0108, 0xc295, 0x72d6, 0x080c, 0x5acf, 0x0118, 0xa296,
+	0x0004, 0x0548, 0x2011, 0x0001, 0x080c, 0x9c60, 0x709b, 0x0000,
+	0x709f, 0xffff, 0x7003, 0x0002, 0x2079, 0x0100, 0x7827, 0x0003,
+	0x7828, 0xa085, 0x0003, 0x782a, 0x00fe, 0x080c, 0x2ab8, 0x2011,
+	0x0005, 0x080c, 0x8075, 0x080c, 0x7173, 0x080c, 0x5acf, 0x0148,
+	0x00c6, 0x2061, 0x0100, 0x0016, 0x080c, 0x28eb, 0x61e2, 0x001e,
+	0x00ce, 0x012e, 0x0420, 0x709b, 0x0000, 0x709f, 0xffff, 0x7003,
+	0x0002, 0x00f6, 0x2079, 0x0100, 0x7827, 0x0003, 0x7828, 0xa085,
+	0x0003, 0x782a, 0x00fe, 0x2011, 0x0005, 0x080c, 0x8075, 0x080c,
+	0x7173, 0x080c, 0x5acf, 0x0148, 0x00c6, 0x2061, 0x0100, 0x0016,
+	0x080c, 0x28eb, 0x61e2, 0x001e, 0x00ce, 0x00fe, 0x012e, 0x0005,
+	0x00c6, 0x080c, 0x5acf, 0x1118, 0x20a9, 0x0100, 0x0010, 0x20a9,
+	0x0082, 0x080c, 0x5acf, 0x1118, 0x2009, 0x0000, 0x0010, 0x2009,
+	0x007e, 0x080c, 0x2d97, 0x8108, 0x1f04, 0x1201, 0x00ce, 0x7073,
+	0x0000, 0x7074, 0xa084, 0x00ff, 0x7076, 0x70a3, 0x0000, 0x0005,
+	0x0126, 0x2091, 0x8000, 0x7000, 0xa086, 0x0002, 0x1904, 0x12db,
+	0x709c, 0xa086, 0xffff, 0x0130, 0x080c, 0x2ab8, 0x080c, 0x7173,
+	0x0804, 0x12db, 0x70d4, 0xd0ac, 0x1110, 0xd09c, 0x0540, 0xd084,
+	0x0530, 0x0006, 0x0016, 0x2001, 0x0103, 0x2009, 0xb78d, 0x210c,
+	0x2102, 0x001e, 0x000e, 0xd08c, 0x01d0, 0x70d8, 0xa086, 0xffff,
+	0x0190, 0x080c, 0x2c17, 0x080c, 0x7173, 0x70d4, 0xd094, 0x1904,
+	0x12db, 0x2011, 0x0001, 0x2019, 0x0000, 0x080c, 0x2c4f, 0x080c,
+	0x7173, 0x0804, 0x12db, 0x70dc, 0xa005, 0x1904, 0x12db, 0x7098,
+	0xa005, 0x1904, 0x12db, 0x70d4, 0xd0a4, 0x0118, 0xd0b4, 0x0904,
+	0x12db, 0x080c, 0x5309, 0x1904, 0x12db, 0x2001, 0xb553, 0x2004,
+	0xd0ac, 0x01c8, 0x0156, 0x00c6, 0x20a9, 0x007f, 0x2009, 0x0000,
+	0x0016, 0x080c, 0x4fa9, 0x1118, 0x6000, 0xd0ec, 0x1138, 0x001e,
+	0x8108, 0x1f04, 0x1268, 0x00ce, 0x015e, 0x0028, 0x001e, 0x00ce,
+	0x015e, 0x0804, 0x12db, 0x0006, 0x0016, 0x2001, 0x0103, 0x2009,
+	0xb78d, 0x210c, 0x2102, 0x001e, 0x000e, 0x71a8, 0x81ff, 0x11b0,
+	0xa006, 0x2009, 0x0200, 0x20a9, 0x0002, 0x20a1, 0xb7de, 0x40a1,
+	0x2009, 0x0700, 0x20a9, 0x0002, 0x20a1, 0xb7ce, 0x40a1, 0x7070,
+	0x8007, 0x7174, 0x810f, 0x20a9, 0x0002, 0x40a1, 0x20a1, 0xb7d2,
+	0x2009, 0x0000, 0x080c, 0x14fb, 0x2001, 0x0000, 0x810f, 0x20a9,
+	0x0002, 0x40a1, 0x7030, 0xc08c, 0x7032, 0x7003, 0x0003, 0x709f,
+	0xffff, 0x080c, 0x1581, 0xa006, 0x080c, 0x27c3, 0x080c, 0x3f3e,
+	0x00f6, 0x2079, 0x0100, 0x080c, 0x5af5, 0x0150, 0x080c, 0x5acf,
+	0x7828, 0x0118, 0xa084, 0xe1ff, 0x0010, 0xa084, 0xffdf, 0x782a,
+	0x00fe, 0x2001, 0xb7e1, 0x2004, 0xa086, 0x0005, 0x1120, 0x2011,
+	0x0000, 0x080c, 0x8075, 0x2011, 0x0000, 0x080c, 0x807f, 0x080c,
+	0x7173, 0x080c, 0x7230, 0x012e, 0x0005, 0x0016, 0x0046, 0x00f6,
+	0x0126, 0x2091, 0x8000, 0x2079, 0x0100, 0x2009, 0xb534, 0x2104,
+	0xa005, 0x1110, 0x080c, 0x2917, 0x2009, 0x00f7, 0x080c, 0x4baf,
+	0x7940, 0xa18c, 0x0010, 0x7942, 0x7924, 0xd1b4, 0x0110, 0x7827,
+	0x0040, 0xd19c, 0x0110, 0x7827, 0x0008, 0x0006, 0x0036, 0x0156,
+	0x7954, 0xd1ac, 0x1904, 0x134b, 0x080c, 0x5ae1, 0x0158, 0x080c,
+	0x5af5, 0x1128, 0x2001, 0xb79e, 0x2003, 0x0000, 0x0070, 0x080c,
+	0x5ad7, 0x0dc0, 0x2001, 0xb79e, 0x2003, 0xaaaa, 0x2001, 0xb79f,
+	0x2003, 0x0001, 0x080c, 0x5a07, 0x0058, 0x080c, 0x5acf, 0x0140,
+	0x2009, 0x00f8, 0x080c, 0x4baf, 0x7843, 0x0090, 0x7843, 0x0010,
+	0x20a9, 0x09c4, 0x7820, 0xd09c, 0x1138, 0x080c, 0x5acf, 0x0138,
+	0x7824, 0xd0ac, 0x1904, 0x13f5, 0x1f04, 0x132a, 0x0070, 0x7824,
+	0x080c, 0x5aeb, 0x0118, 0xd0ac, 0x1904, 0x13f5, 0xa084, 0x1800,
+	0x0d98, 0x7003, 0x0001, 0x0804, 0x13f5, 0x2001, 0x0001, 0x080c,
+	0x27c3, 0x0804, 0x1404, 0x7850, 0xa084, 0x0180, 0x7852, 0x782f,
+	0x0020, 0x20a9, 0x0046, 0x1d04, 0x1353, 0x080c, 0x6a44, 0x1f04,
+	0x1353, 0x7850, 0xa084, 0x0180, 0xa085, 0x0400, 0x7852, 0x782f,
+	0x0000, 0x080c, 0x5ae1, 0x0158, 0x080c, 0x5af5, 0x1128, 0x2001,
+	0xb79e, 0x2003, 0x0000, 0x0070, 0x080c, 0x5ad7, 0x0dc0, 0x2001,
+	0xb79e, 0x2003, 0xaaaa, 0x2001, 0xb79f, 0x2003, 0x0001, 0x080c,
+	0x5a07, 0x0020, 0x2009, 0x00f8, 0x080c, 0x4baf, 0x20a9, 0x000e,
+	0xe000, 0x1f04, 0x1380, 0x7850, 0xa084, 0x0180, 0xa085, 0x1400,
+	0x7852, 0x080c, 0x5acf, 0x0120, 0x7843, 0x0090, 0x7843, 0x0010,
+	0x2021, 0xe678, 0x2019, 0xea60, 0x7820, 0xd09c, 0x1558, 0x080c,
+	0x5acf, 0x05d8, 0x7824, 0xd0ac, 0x1904, 0x13f5, 0x080c, 0x5af5,
+	0x1508, 0x0046, 0x2021, 0x0190, 0x8421, 0x1df0, 0x004e, 0x8421,
+	0x11c8, 0x7827, 0x0048, 0x20a9, 0x01f4, 0x1d04, 0x13ad, 0x080c,
+	0x6a44, 0x1f04, 0x13ad, 0x7824, 0xa084, 0x0068, 0x15c8, 0x2001,
+	0xb79e, 0x2003, 0xaaaa, 0x2001, 0xb79f, 0x2003, 0x0001, 0x7003,
+	0x0001, 0x0498, 0x1d04, 0x13c6, 0x080c, 0x6a44, 0x8319, 0x1960,
+	0x2009, 0xb534, 0x2104, 0x8000, 0x200a, 0xa084, 0xfff0, 0x0120,
+	0x200b, 0x0000, 0x080c, 0x2917, 0x00d8, 0x080c, 0x5ae1, 0x1140,
+	0xa4a2, 0x0064, 0x1128, 0x080c, 0x5aa6, 0x7003, 0x0001, 0x00a8,
+	0x7827, 0x1800, 0xe000, 0xe000, 0x7824, 0x080c, 0x5aeb, 0x0110,
+	0xd0ac, 0x1158, 0xa084, 0x1800, 0x09a8, 0x7003, 0x0001, 0x0028,
+	0x2001, 0x0001, 0x080c, 0x27c3, 0x0048, 0x2001, 0xb534, 0x2003,
+	0x0000, 0x7827, 0x0048, 0x7828, 0xc09d, 0x782a, 0x7850, 0xa084,
+	0x0180, 0xa085, 0x0400, 0x7852, 0x015e, 0x003e, 0x000e, 0x080c,
+	0x1558, 0x012e, 0x00fe, 0x004e, 0x001e, 0x0005, 0x0005, 0x0005,
+	0x0005, 0x2a70, 0x2061, 0xb7c1, 0x2063, 0x0002, 0x6007, 0x0002,
+	0x600b, 0x0006, 0x600f, 0x0017, 0x2001, 0xb79e, 0x2003, 0x0000,
+	0x708b, 0x0000, 0x2009, 0x0100, 0x2104, 0xa082, 0x0002, 0x0218,
+	0x7053, 0xffff, 0x0010, 0x7053, 0x0000, 0x705b, 0xffff, 0x7073,
+	0x0000, 0x7077, 0x0000, 0x080c, 0xa008, 0x2061, 0xb78e, 0x6003,
+	0x0909, 0x6007, 0x0000, 0x600b, 0x8800, 0x600f, 0x0200, 0x6013,
+	0x00ff, 0x6017, 0x000f, 0x601b, 0x0000, 0x601f, 0x07d0, 0x2061,
+	0xb796, 0x6003, 0x8000, 0x6007, 0x0000, 0x600b, 0x0000, 0x600f,
+	0x0200, 0x6013, 0x00ff, 0x6017, 0x0000, 0x601b, 0x0001, 0x601f,
+	0x0000, 0x2061, 0xb7b9, 0x6003, 0x514c, 0x6007, 0x4f47, 0x600b,
+	0x4943, 0x600f, 0x2020, 0x2001, 0xb528, 0x2003, 0x0000, 0x0005,
+	0x04a0, 0x2011, 0x0000, 0x81ff, 0x0570, 0xa186, 0x0001, 0x1148,
+	0x2031, 0x8fff, 0x2039, 0xd501, 0x2021, 0x0100, 0x2029, 0xd500,
+	0x00e8, 0xa186, 0x0002, 0x1118, 0x2011, 0x0000, 0x00b8, 0xa186,
+	0x0005, 0x1118, 0x2011, 0x0001, 0x0088, 0xa186, 0x0009, 0x1118,
+	0x2011, 0x0002, 0x0058, 0xa186, 0x000a, 0x1118, 0x2011, 0x0002,
+	0x0028, 0xa186, 0x0055, 0x1110, 0x2011, 0x0003, 0x3800, 0xa084,
+	0xfffc, 0xa205, 0x20c0, 0x0804, 0x104d, 0xa00e, 0x2011, 0x0003,
+	0x2019, 0x14a4, 0x0804, 0x14f5, 0x2019, 0xaaaa, 0x2061, 0xffff,
+	0x2c14, 0x2362, 0xe000, 0xe000, 0x2c04, 0xa306, 0x2262, 0x1110,
+	0xc1b5, 0xc1a5, 0x2011, 0x0000, 0x2019, 0x14b7, 0x04f0, 0x2019,
+	0xaaaa, 0x2061, 0xffff, 0x2c14, 0x2362, 0xe000, 0xe000, 0x2c1c,
+	0x2061, 0x7fff, 0xe000, 0xe000, 0x2c04, 0x2061, 0xffff, 0x2262,
+	0xa306, 0x0110, 0xc18d, 0x0008, 0xc185, 0x2011, 0x0002, 0x2019,
+	0x14d2, 0x0418, 0x2061, 0xffff, 0x2019, 0xaaaa, 0x2c14, 0x2362,
+	0xe000, 0xe000, 0x2c04, 0x2262, 0xa306, 0x1180, 0x2c14, 0x2362,
+	0xe000, 0xe000, 0x2c1c, 0x2061, 0x7fff, 0x2c04, 0x2061, 0xffff,
+	0x2262, 0xa306, 0x1110, 0xc195, 0x0008, 0xc19d, 0x2011, 0x0001,
+	0x2019, 0x14f3, 0x0010, 0x0804, 0x1469, 0x3800, 0xa084, 0xfffc,
+	0xa205, 0x20c0, 0x0837, 0x2011, 0x0000, 0x080c, 0x4fa9, 0x1178,
+	0x6004, 0xa0c4, 0x00ff, 0xa8c6, 0x0006, 0x0128, 0xa0c4, 0xff00,
+	0xa8c6, 0x0600, 0x1120, 0xa186, 0x0080, 0x0108, 0x8210, 0x8108,
+	0xa186, 0x0100, 0x1d50, 0x2208, 0x0005, 0x2091, 0x8000, 0x0e04,
+	0x1517, 0x0006, 0x0016, 0x2079, 0x0000, 0x7818, 0xd084, 0x1de8,
+	0x001e, 0x792e, 0x000e, 0x782a, 0x000e, 0x7826, 0x3900, 0x783a,
+	0x7823, 0x8002, 0x781b, 0x0001, 0x2091, 0x5000, 0x0126, 0x0156,
+	0x0146, 0x20a9, 0x0010, 0x20a1, 0xb90c, 0x2091, 0x2000, 0x40a1,
+	0x20a9, 0x0010, 0x2091, 0x2200, 0x40a1, 0x20a9, 0x0010, 0x2091,
+	0x2400, 0x40a1, 0x20a9, 0x0010, 0x2091, 0x2600, 0x40a1, 0x20a9,
+	0x0010, 0x2091, 0x2800, 0x40a1, 0x014e, 0x015e, 0x012e, 0x2079,
+	0xb500, 0x7803, 0x0005, 0x2091, 0x4080, 0x04c9, 0x0cf8, 0x0005,
+	0x0006, 0x080c, 0x15a3, 0x1518, 0x00f6, 0x2079, 0xb524, 0x2f04,
+	0x8000, 0x207a, 0xa082, 0x000f, 0x0258, 0xa006, 0x207a, 0x2079,
+	0xb526, 0x2f04, 0xa084, 0x0001, 0xa086, 0x0001, 0x207a, 0x0070,
+	0x2079, 0xb526, 0x2f7c, 0x8fff, 0x1128, 0x2001, 0x0c03, 0x2003,
+	0x0040, 0x0020, 0x2001, 0x0c03, 0x2003, 0x00c0, 0x00fe, 0x000e,
+	0x0005, 0x0409, 0x1120, 0x2001, 0x0c03, 0x2003, 0x0080, 0x0005,
+	0x00d1, 0x1120, 0x2001, 0x0c03, 0x2003, 0x0040, 0x0005, 0x0006,
+	0x0091, 0x1178, 0x2001, 0x0c03, 0x2003, 0x0040, 0x2009, 0x0fff,
+	0x00a1, 0x2001, 0x0c03, 0x2003, 0x0080, 0x2009, 0x0fff, 0x0069,
+	0x0c88, 0x000e, 0x0005, 0x00c6, 0x2061, 0x0c00, 0x2c04, 0xa084,
+	0x00ff, 0xa086, 0x00aa, 0x00ce, 0x0005, 0x0156, 0x0126, 0xa18c,
+	0x0fff, 0x21a8, 0x1d04, 0x15b2, 0x2091, 0x6000, 0x1f04, 0x15b2,
+	0x012e, 0x015e, 0x0005, 0x2071, 0xb500, 0x7160, 0x712e, 0x2021,
+	0x0001, 0xa190, 0x0030, 0xa298, 0x0030, 0x0240, 0x7064, 0xa302,
+	0x1228, 0x220a, 0x2208, 0x2310, 0x8420, 0x0ca8, 0x3800, 0xd08c,
+	0x0148, 0x7064, 0xa086, 0xb500, 0x0128, 0x7067, 0xb500, 0x2011,
+	0x1000, 0x0c48, 0x200b, 0x0000, 0x74b2, 0x74b6, 0x0005, 0x00e6,
+	0x0126, 0x2091, 0x8000, 0x2071, 0xb500, 0x70b4, 0xa0ea, 0x0010,
+	0x0268, 0x8001, 0x70b6, 0x702c, 0x2068, 0x2d04, 0x702e, 0x206b,
+	0x0000, 0x6807, 0x0000, 0x012e, 0x00ee, 0x0005, 0xa06e, 0x0cd8,
+	0x00e6, 0x2071, 0xb500, 0x0126, 0x2091, 0x8000, 0x70b4, 0x8001,
+	0x0260, 0x70b6, 0x702c, 0x2068, 0x2d04, 0x702e, 0x206b, 0x0000,
+	0x6807, 0x0000, 0x012e, 0x00ee, 0x0005, 0xa06e, 0x0cd8, 0x00e6,
+	0x0126, 0x2091, 0x8000, 0x2071, 0xb500, 0x702c, 0x206a, 0x2d00,
+	0x702e, 0x70b4, 0x8000, 0x70b6, 0x012e, 0x00ee, 0x0005, 0x8dff,
+	0x0138, 0x6804, 0x6807, 0x0000, 0x0006, 0x0c49, 0x00de, 0x0cb8,
+	0x0005, 0x00e6, 0x2071, 0xb500, 0x70b4, 0xa08a, 0x0010, 0xa00d,
+	0x00ee, 0x0005, 0x00e6, 0x2071, 0xb812, 0x7007, 0x0000, 0x701b,
+	0x0000, 0x701f, 0x0000, 0x2071, 0x0000, 0x7010, 0xa085, 0x8004,
+	0x7012, 0x00ee, 0x0005, 0x0126, 0x2091, 0x8000, 0x00e6, 0x2270,
+	0x700b, 0x0000, 0x2071, 0xb812, 0x7018, 0xa088, 0xb81b, 0x220a,
+	0x8000, 0xa084, 0x0007, 0x701a, 0x7004, 0xa005, 0x1128, 0x00f6,
+	0x2079, 0x0010, 0x0089, 0x00fe, 0x00ee, 0x012e, 0x0005, 0x00e6,
+	0x2071, 0xb812, 0x7004, 0xa005, 0x1128, 0x00f6, 0x2079, 0x0010,
+	0x0019, 0x00fe, 0x00ee, 0x0005, 0x7000, 0x0002, 0x1672, 0x16d6,
+	0x16f3, 0x16f3, 0x7018, 0x711c, 0xa106, 0x1118, 0x7007, 0x0000,
+	0x0005, 0x00d6, 0xa180, 0xb81b, 0x2004, 0x700a, 0x2068, 0x8108,
+	0xa18c, 0x0007, 0x711e, 0x7803, 0x0026, 0x6824, 0x7832, 0x6828,
+	0x7836, 0x682c, 0x783a, 0x6830, 0x783e, 0x6810, 0x700e, 0x680c,
+	0x7016, 0x6804, 0x00de, 0xd084, 0x0120, 0x7007, 0x0001, 0x0029,
+	0x0005, 0x7007, 0x0002, 0x00b1, 0x0005, 0x0016, 0x0026, 0x710c,
+	0x2011, 0x0040, 0xa182, 0x0040, 0x1210, 0x2110, 0xa006, 0x700e,
+	0x7212, 0x8203, 0x7822, 0x7803, 0x0020, 0x7803, 0x0041, 0x002e,
+	0x001e, 0x0005, 0x0016, 0x0026, 0x0136, 0x0146, 0x0156, 0x7014,
+	0x2098, 0x20a1, 0x0014, 0x7803, 0x0026, 0x710c, 0x2011, 0x0040,
+	0xa182, 0x0040, 0x1210, 0x2110, 0xa006, 0x700e, 0x22a8, 0x53a6,
+	0x8203, 0x7822, 0x7803, 0x0020, 0x3300, 0x7016, 0x7803, 0x0001,
+	0x015e, 0x014e, 0x013e, 0x002e, 0x001e, 0x0005, 0x0136, 0x0146,
+	0x0156, 0x2099, 0xb5fa, 0x20a1, 0x0018, 0x20a9, 0x0008, 0x53a3,
+	0x7803, 0x0020, 0x0126, 0x2091, 0x8000, 0x7803, 0x0041, 0x7007,
+	0x0003, 0x7000, 0xc084, 0x7002, 0x700b, 0xb5f5, 0x012e, 0x015e,
+	0x014e, 0x013e, 0x0005, 0x0136, 0x0146, 0x0156, 0x2001, 0xb629,
+	0x209c, 0x20a1, 0x0014, 0x7803, 0x0026, 0x2001, 0xb62a, 0x20ac,
+	0x53a6, 0x2099, 0xb62b, 0x20a1, 0x0018, 0x20a9, 0x0008, 0x53a3,
+	0x7803, 0x0020, 0x0126, 0x2091, 0x8000, 0x7803, 0x0001, 0x7007,
+	0x0004, 0x7000, 0xc08c, 0x7002, 0x700b, 0xb626, 0x012e, 0x015e,
+	0x014e, 0x013e, 0x0005, 0x0016, 0x00e6, 0x2071, 0xb812, 0x00f6,
+	0x2079, 0x0010, 0x7904, 0x7803, 0x0002, 0xd1fc, 0x0120, 0xa18c,
+	0x0700, 0x7004, 0x0023, 0x00fe, 0x00ee, 0x001e, 0x0005, 0x166c,
+	0x1736, 0x1764, 0x178e, 0x17be, 0x1735, 0x0cf8, 0xa18c, 0x0700,
+	0x1528, 0x0136, 0x0146, 0x0156, 0x7014, 0x20a0, 0x2099, 0x0014,
+	0x7803, 0x0040, 0x7010, 0x20a8, 0x53a5, 0x3400, 0x7016, 0x015e,
+	0x014e, 0x013e, 0x700c, 0xa005, 0x0570, 0x7830, 0x7832, 0x7834,
+	0x7836, 0x080c, 0x169d, 0x0005, 0x7008, 0xa080, 0x0002, 0x2003,
+	0x0100, 0x7007, 0x0000, 0x080c, 0x166c, 0x0005, 0x7008, 0xa080,
+	0x0002, 0x2003, 0x0200, 0x0ca8, 0xa18c, 0x0700, 0x1150, 0x700c,
+	0xa005, 0x0188, 0x7830, 0x7832, 0x7834, 0x7836, 0x080c, 0x16b2,
+	0x0005, 0x7008, 0xa080, 0x0002, 0x2003, 0x0200, 0x7007, 0x0000,
+	0x080c, 0x166c, 0x0005, 0x00d6, 0x7008, 0x2068, 0x7830, 0x6826,
+	0x7834, 0x682a, 0x7838, 0x682e, 0x783c, 0x6832, 0x680b, 0x0100,
+	0x00de, 0x7007, 0x0000, 0x080c, 0x166c, 0x0005, 0xa18c, 0x0700,
+	0x1540, 0x0136, 0x0146, 0x0156, 0x2001, 0xb5f8, 0x2004, 0xa080,
+	0x000d, 0x20a0, 0x2099, 0x0014, 0x7803, 0x0040, 0x20a9, 0x0020,
+	0x53a5, 0x2001, 0xb5fa, 0x2004, 0xd0bc, 0x0148, 0x2001, 0xb603,
+	0x2004, 0xa080, 0x000d, 0x20a0, 0x20a9, 0x0020, 0x53a5, 0x015e,
+	0x014e, 0x013e, 0x7007, 0x0000, 0x080c, 0x5e6f, 0x080c, 0x166c,
+	0x0005, 0x2011, 0x8003, 0x080c, 0x3ecc, 0x0cf8, 0xa18c, 0x0700,
+	0x1148, 0x2001, 0xb628, 0x2003, 0x0100, 0x7007, 0x0000, 0x080c,
+	0x166c, 0x0005, 0x2011, 0x8004, 0x080c, 0x3ecc, 0x0cf8, 0x0126,
+	0x2091, 0x2200, 0x2079, 0x0030, 0x2071, 0xb823, 0x7003, 0x0000,
+	0x700f, 0xb82f, 0x7013, 0xb82f, 0x780f, 0x00f6, 0x7803, 0x0004,
+	0x012e, 0x0005, 0x6934, 0xa184, 0x0007, 0x0002, 0x17ee, 0x182c,
+	0x17ee, 0x17ee, 0x17ee, 0x1814, 0x17fb, 0x17f2, 0xa085, 0x0001,
+	0x0804, 0x1846, 0x684c, 0xd0bc, 0x0dc8, 0x6860, 0x682e, 0x685c,
+	0x682a, 0x6858, 0x04c8, 0xa18c, 0x00ff, 0xa186, 0x001e, 0x1d70,
+	0x684c, 0xd0bc, 0x0d58, 0x6860, 0x682e, 0x685c, 0x682a, 0x6804,
+	0x681a, 0xa080, 0x000d, 0x2004, 0xa084, 0x000f, 0xa080, 0x22e5,
+	0x2005, 0x6832, 0x6858, 0x0440, 0xa18c, 0x00ff, 0xa186, 0x0015,
+	0x19a8, 0x684c, 0xd0ac, 0x0990, 0x6804, 0x681a, 0xa080, 0x000d,
+	0x2004, 0xa084, 0x000f, 0xa080, 0x22e5, 0x2005, 0x6832, 0xa006,
+	0x682e, 0x682a, 0x6858, 0x0080, 0x684c, 0xd0ac, 0x0904, 0x17ee,
+	0xa006, 0x682e, 0x682a, 0x6858, 0xa18c, 0x000f, 0xa188, 0x22e5,
+	0x210d, 0x6932, 0x2d08, 0x691a, 0x6826, 0x684c, 0xc0dd, 0x684e,
+	0xa006, 0x680a, 0x697c, 0x6912, 0x6980, 0x6916, 0x0005, 0x684c,
+	0xd0ac, 0x090c, 0x1515, 0x6833, 0x22e2, 0x2d08, 0x691a, 0x6858,
+	0x8001, 0x6826, 0x684c, 0xc0dd, 0x684e, 0xa006, 0x680a, 0x682e,
+	0x682a, 0x697c, 0x6912, 0x6980, 0x6916, 0x0005, 0x20e1, 0x0007,
+	0x20e1, 0x2000, 0x2001, 0x020a, 0x2004, 0x82ff, 0x01e8, 0xa280,
+	0x0004, 0x00d6, 0x206c, 0x684c, 0xd0dc, 0x1190, 0xa280, 0x0007,
+	0x2004, 0xa086, 0x000a, 0x1110, 0x0891, 0x0010, 0x080c, 0x17e2,
+	0x0138, 0x00de, 0xa280, 0x0000, 0x2003, 0x0002, 0xa016, 0x0020,
+	0x6808, 0x8000, 0x680a, 0x00de, 0x0126, 0x0046, 0x0036, 0x0026,
+	0x2091, 0x2200, 0x002e, 0x003e, 0x004e, 0x7000, 0xa005, 0x01d0,
+	0x710c, 0x220a, 0x8108, 0x230a, 0x8108, 0x240a, 0x8108, 0xa182,
+	0xb84a, 0x0210, 0x2009, 0xb82f, 0x710e, 0x7010, 0xa102, 0xa082,
+	0x0009, 0x0118, 0xa080, 0x001b, 0x1118, 0x2009, 0x0138, 0x200a,
+	0x012e, 0x0005, 0x7206, 0x2001, 0x18a8, 0x0006, 0x2260, 0x0804,
+	0x19d5, 0x0126, 0x0026, 0x0036, 0x00c6, 0x0006, 0x2091, 0x2200,
+	0x000e, 0x004e, 0x003e, 0x002e, 0x00d6, 0x00c6, 0x2460, 0x6110,
+	0x2168, 0x6a62, 0x6b5e, 0xa005, 0x0904, 0x190a, 0x6808, 0xa005,
+	0x0904, 0x1941, 0x7000, 0xa005, 0x1108, 0x0488, 0x700c, 0x7110,
+	0xa106, 0x1904, 0x1949, 0x7004, 0xa406, 0x1548, 0x2001, 0x0005,
+	0x2004, 0xd08c, 0x0168, 0x0046, 0x080c, 0x1b06, 0x004e, 0x2460,
+	0x6010, 0xa080, 0x0002, 0x2004, 0xa005, 0x0904, 0x1941, 0x0c10,
+	0x2001, 0x0207, 0x2004, 0xd09c, 0x1d48, 0x7804, 0xa084, 0x6000,
+	0x0120, 0xa086, 0x6000, 0x0108, 0x0c08, 0x7818, 0x6812, 0x781c,
+	0x6816, 0x7803, 0x0004, 0x7003, 0x0000, 0x7004, 0x2060, 0x6100,
+	0xa18e, 0x0004, 0x1904, 0x1949, 0x2009, 0x0048, 0x080c, 0x864c,
+	0x0804, 0x1949, 0x6808, 0xa005, 0x05a0, 0x7000, 0xa005, 0x0588,
+	0x700c, 0x7110, 0xa106, 0x1118, 0x7004, 0xa406, 0x1550, 0x2001,
+	0x0005, 0x2004, 0xd08c, 0x0160, 0x0046, 0x080c, 0x1b06, 0x004e,
+	0x2460, 0x6010, 0xa080, 0x0002, 0x2004, 0xa005, 0x01d0, 0x0c28,
+	0x2001, 0x0207, 0x2004, 0xd09c, 0x1d50, 0x2001, 0x0005, 0x2004,
+	0xd08c, 0x1d50, 0x7804, 0xa084, 0x6000, 0x0118, 0xa086, 0x6000,
+	0x19f0, 0x7818, 0x6812, 0x781c, 0x6816, 0x7803, 0x0004, 0x7003,
+	0x0000, 0x6100, 0xa18e, 0x0004, 0x1120, 0x2009, 0x0048, 0x080c,
+	0x864c, 0x00ce, 0x00de, 0x012e, 0x0005, 0x00f6, 0x00e6, 0x0026,
+	0x0036, 0x0046, 0x0056, 0x2071, 0xb823, 0x7000, 0xa086, 0x0000,
+	0x0904, 0x19b3, 0x7004, 0xac06, 0x1904, 0x19a5, 0x2079, 0x0030,
+	0x7000, 0xa086, 0x0003, 0x0904, 0x19a5, 0x7804, 0xd0fc, 0x15c8,
+	0x20e1, 0x6000, 0x2011, 0x0032, 0x2001, 0x0208, 0x200c, 0x2001,
+	0x0209, 0x2004, 0xa106, 0x1d88, 0x8211, 0x1db0, 0x7804, 0xd0fc,
+	0x1540, 0x080c, 0x1e6e, 0x0026, 0x0056, 0x7803, 0x0004, 0x7804,
+	0xd0ac, 0x1de8, 0x7803, 0x0002, 0x7803, 0x0009, 0x7003, 0x0003,
+	0x7007, 0x0000, 0x005e, 0x002e, 0x2001, 0x015d, 0x2003, 0x0000,
+	0x080c, 0x5acf, 0x1138, 0x0066, 0x2031, 0x0001, 0x080c, 0x5b51,
+	0x006e, 0x0058, 0x2001, 0x0160, 0x2502, 0x2001, 0x0138, 0x2202,
+	0x0020, 0x080c, 0x1b06, 0x0804, 0x1955, 0x0156, 0x20a9, 0x0009,
+	0x2009, 0xb82f, 0x2104, 0xac06, 0x1108, 0x200a, 0xa188, 0x0003,
+	0x1f04, 0x19aa, 0x015e, 0x005e, 0x004e, 0x003e, 0x002e, 0x00ee,
+	0x00fe, 0x0005, 0x700c, 0x7110, 0xa106, 0x0904, 0x1a49, 0x2104,
+	0x7006, 0x2060, 0x8108, 0x211c, 0x8108, 0x2124, 0x8108, 0xa182,
+	0xb84a, 0x0210, 0x2009, 0xb82f, 0x7112, 0x700c, 0xa106, 0x1128,
+	0x080c, 0x28eb, 0x2001, 0x0138, 0x2102, 0x8cff, 0x0598, 0x6010,
+	0x2068, 0x2d58, 0x6828, 0xa406, 0x1590, 0x682c, 0xa306, 0x1578,
+	0x7004, 0x2060, 0x6020, 0xc0d4, 0x6022, 0x684c, 0xd0f4, 0x0128,
+	0x6817, 0xffff, 0x6813, 0xffff, 0x00e8, 0x6850, 0xd0f4, 0x1130,
+	0x7803, 0x0004, 0x6810, 0x781a, 0x6814, 0x781e, 0x6824, 0x2050,
+	0x6818, 0x2060, 0x6830, 0x2040, 0x6034, 0xa0cc, 0x000f, 0x2009,
+	0x0011, 0x080c, 0x1a4c, 0x0120, 0x2009, 0x0001, 0x080c, 0x1a4c,
+	0x2d58, 0x0005, 0x080c, 0x1ddd, 0x0904, 0x19ba, 0x0cd0, 0x6020,
+	0xd0f4, 0x11e0, 0xd0d4, 0x01b8, 0x6038, 0xa402, 0x6034, 0xa303,
+	0x0108, 0x1288, 0x643a, 0x6336, 0x6c2a, 0x6b2e, 0x0046, 0x0036,
+	0x2400, 0x6c7c, 0xa402, 0x6812, 0x2300, 0x6b80, 0xa303, 0x6816,
+	0x003e, 0x004e, 0x0018, 0x080c, 0x9f9a, 0x09e0, 0x601c, 0xa08e,
+	0x0008, 0x0904, 0x19e0, 0xa08e, 0x000a, 0x0904, 0x19e0, 0x2001,
+	0xb574, 0x2004, 0xd0b4, 0x1140, 0x6018, 0x2004, 0xd0bc, 0x1120,
+	0x6817, 0x7fff, 0x6813, 0xffff, 0x080c, 0x2305, 0x1918, 0x0804,
+	0x19e0, 0x7003, 0x0000, 0x0005, 0x8aff, 0x0904, 0x1ae0, 0xa03e,
+	0x2730, 0xc9fc, 0x6850, 0xd0fc, 0x11b8, 0xd0f4, 0x1528, 0x00d6,
+	0x2805, 0xac68, 0x2900, 0x0002, 0x1a9e, 0x1a82, 0x1a82, 0x1a9e,
+	0x1a9e, 0x1a96, 0x1a9e, 0x1a82, 0x1a9e, 0x1a87, 0x1a87, 0x1a9e,
+	0x1a9e, 0x1a9e, 0x1a8e, 0x1a87, 0x7803, 0x0004, 0xc0fc, 0x6852,
+	0x6b6c, 0x6a70, 0x6d1c, 0x6c20, 0x00d6, 0xd99c, 0x0550, 0x2805,
+	0xac68, 0x6f08, 0x6e0c, 0x0430, 0xc0f4, 0x6852, 0x6b6c, 0x6a70,
+	0x00d6, 0x0468, 0x6b08, 0x6a0c, 0x6d00, 0x6c04, 0x00d0, 0x6b10,
+	0x6a14, 0x6d00, 0x6c04, 0x6f08, 0x6e0c, 0x00a0, 0x00de, 0x00d6,
+	0x6834, 0xa084, 0x00ff, 0xa086, 0x001e, 0x1140, 0x00de, 0x080c,
+	0x22a7, 0x1904, 0x1a4c, 0xa00e, 0x0804, 0x1ae0, 0x00de, 0x080c,
+	0x1515, 0xc9fd, 0x7b22, 0x7a26, 0x7d32, 0x7c36, 0x7f3a, 0x7e3e,
+	0x7316, 0x721a, 0x751e, 0x7422, 0x7726, 0x762a, 0x7902, 0x7100,
+	0x8108, 0x7102, 0x00de, 0x6828, 0xa300, 0x682a, 0x682c, 0xa201,
+	0x682e, 0x8109, 0x2d08, 0x1500, 0xd9fc, 0x0160, 0xc9fc, 0x080c,
+	0x22a7, 0x01e8, 0x2805, 0xac68, 0x6800, 0xa506, 0x11c0, 0x6804,
+	0xa406, 0x00a8, 0xc9fc, 0x080c, 0x22a7, 0x0188, 0x2805, 0xac68,
+	0x6800, 0xa506, 0x1160, 0x6804, 0xa406, 0x1148, 0x6808, 0xa706,
+	0x1130, 0x680c, 0xa606, 0x0018, 0xc9fc, 0x080c, 0x22a7, 0x2168,
+	0x0005, 0x080c, 0x1515, 0x080c, 0x1f55, 0x7004, 0x2060, 0x00d6,
+	0x6010, 0x2068, 0x7003, 0x0000, 0x080c, 0x1dfe, 0x080c, 0x9c5a,
+	0x0170, 0x6808, 0x8001, 0x680a, 0x697c, 0x6912, 0x6980, 0x6916,
+	0x682b, 0xffff, 0x682f, 0xffff, 0x6850, 0xc0bd, 0x6852, 0x00de,
+	0x080c, 0x992a, 0x0804, 0x1d2b, 0x080c, 0x1515, 0x0126, 0x2091,
+	0x2200, 0x0006, 0x0016, 0x2b68, 0x6818, 0x2060, 0x7904, 0x7803,
+	0x0002, 0xa184, 0x0700, 0x1978, 0xa184, 0x0003, 0xa086, 0x0003,
+	0x0d58, 0x7000, 0x0002, 0x1b23, 0x1b29, 0x1c3a, 0x1d06, 0x1d1a,
+	0x1b23, 0x1b23, 0x1b23, 0x7804, 0xd09c, 0x1904, 0x1d2b, 0x080c,
+	0x1515, 0x8001, 0x7002, 0xd1bc, 0x11a0, 0xd19c, 0x1904, 0x1bbe,
+	0xd1dc, 0x1178, 0x8aff, 0x0904, 0x1bbe, 0x2009, 0x0001, 0x080c,
+	0x1a4c, 0x0904, 0x1d2b, 0x2009, 0x0001, 0x080c, 0x1a4c, 0x0804,
+	0x1d2b, 0x7803, 0x0004, 0x7003, 0x0000, 0xd1bc, 0x1904, 0x1b9e,
+	0x0026, 0x0036, 0x7c20, 0x7d24, 0x7e30, 0x7f34, 0x7818, 0x6812,
+	0x781c, 0x6816, 0x2001, 0x0201, 0x2004, 0xa005, 0x0140, 0x7808,
+	0xd0ec, 0x1128, 0x7803, 0x0009, 0x7003, 0x0004, 0x0010, 0x080c,
+	0x1d2f, 0x6b28, 0x6a2c, 0x2400, 0x686e, 0xa31a, 0x2500, 0x6872,
+	0xa213, 0x6b2a, 0x6a2e, 0x00c6, 0x7004, 0x2060, 0x6020, 0xd0f4,
+	0x1110, 0x633a, 0x6236, 0x00ce, 0x003e, 0x002e, 0x6e1e, 0x6f22,
+	0x2500, 0xa405, 0x0128, 0x080c, 0x22bd, 0x6850, 0xc0fd, 0x6852,
+	0x2a00, 0x6826, 0x2c00, 0x681a, 0x2800, 0x6832, 0x6808, 0x8001,
+	0x680a, 0x1148, 0x684c, 0xd0e4, 0x0130, 0x7004, 0x2060, 0x2009,
+	0x0048, 0x080c, 0x864c, 0x7000, 0xa086, 0x0004, 0x0904, 0x1d2b,
+	0x7003, 0x0000, 0x080c, 0x19ba, 0x0804, 0x1d2b, 0x0056, 0x7d0c,
+	0xd5bc, 0x1110, 0x080c, 0xb407, 0x005e, 0x080c, 0x1dfe, 0x00f6,
+	0x7004, 0x2078, 0x080c, 0x5305, 0x0118, 0x7820, 0xc0f5, 0x7822,
+	0x00fe, 0x682b, 0xffff, 0x682f, 0xffff, 0x6808, 0x8001, 0x680a,
+	0x697c, 0x791a, 0x6980, 0x791e, 0x0804, 0x1d2b, 0x7004, 0x00c6,
+	0x2060, 0x6020, 0x00ce, 0xd0f4, 0x0120, 0x6808, 0x8001, 0x680a,
+	0x04c0, 0x7818, 0x6812, 0x7a1c, 0x6a16, 0xd19c, 0x0160, 0xa205,
+	0x0150, 0x7004, 0xa080, 0x0007, 0x2004, 0xa084, 0xfffd, 0xa086,
+	0x0008, 0x1904, 0x1b41, 0x684c, 0xc0f5, 0x684e, 0x7814, 0xa005,
+	0x1520, 0x7003, 0x0000, 0x6808, 0x8001, 0x680a, 0x01a0, 0x7004,
+	0x2060, 0x601c, 0xa086, 0x000a, 0x11a0, 0x0156, 0x20a9, 0x0009,
+	0x2009, 0xb82f, 0x2104, 0xac06, 0x1108, 0x200a, 0xa188, 0x0003,
+	0x1f04, 0x1bf2, 0x015e, 0x7004, 0x2060, 0x2009, 0x0048, 0x080c,
+	0x864c, 0x080c, 0x19ba, 0x0804, 0x1d2b, 0x7818, 0x6812, 0x781c,
+	0x6816, 0x7814, 0x7908, 0xa18c, 0x0fff, 0xa192, 0x0841, 0x1a04,
+	0x1ae3, 0xa188, 0x0007, 0x8114, 0x8214, 0x8214, 0xa10a, 0x8104,
+	0x8004, 0x8004, 0xa20a, 0x810b, 0x810b, 0x810b, 0x080c, 0x1e99,
+	0x7803, 0x0004, 0x780f, 0xffff, 0x7803, 0x0001, 0x7804, 0xd0fc,
+	0x0de8, 0x7803, 0x0002, 0x7803, 0x0004, 0x780f, 0x00f6, 0x7004,
+	0x7007, 0x0000, 0x2060, 0x2009, 0x0048, 0x080c, 0x864c, 0x080c,
+	0x1eef, 0x0838, 0x8001, 0x7002, 0xd194, 0x01b0, 0x7804, 0xd0fc,
+	0x1904, 0x1cd6, 0xd09c, 0x0138, 0x7804, 0xd0fc, 0x1904, 0x1cd6,
+	0xd09c, 0x1904, 0x1cda, 0x8aff, 0x0904, 0x1d2b, 0x2009, 0x0001,
+	0x080c, 0x1a4c, 0x0804, 0x1d2b, 0xa184, 0x0888, 0x1148, 0x8aff,
+	0x0904, 0x1d2b, 0x2009, 0x0001, 0x080c, 0x1a4c, 0x0804, 0x1d2b,
+	0x7818, 0x6812, 0x7a1c, 0x6a16, 0xa205, 0x0904, 0x1bdb, 0x7803,
+	0x0004, 0x7003, 0x0000, 0xd1bc, 0x1904, 0x1cb8, 0x6834, 0xa084,
+	0x00ff, 0xa086, 0x0029, 0x1118, 0xd19c, 0x1904, 0x1bdb, 0x0026,
+	0x0036, 0x7c20, 0x7d24, 0x7e30, 0x7f34, 0x7818, 0x6812, 0x781c,
+	0x6816, 0x2001, 0x0201, 0x2004, 0xa005, 0x0140, 0x7808, 0xd0ec,
+	0x1128, 0x7803, 0x0009, 0x7003, 0x0004, 0x0020, 0x0016, 0x080c,
+	0x1d2f, 0x001e, 0x6b28, 0x6a2c, 0x080c, 0x22bd, 0x00d6, 0x2805,
+	0xac68, 0x6034, 0xd09c, 0x1128, 0x6808, 0xa31a, 0x680c, 0xa213,
+	0x0020, 0x6810, 0xa31a, 0x6814, 0xa213, 0x00de, 0xd194, 0x0904,
+	0x1b63, 0x2a00, 0x6826, 0x2c00, 0x681a, 0x2800, 0x6832, 0x6808,
+	0x8001, 0x680a, 0x6b2a, 0x6a2e, 0x003e, 0x002e, 0x0804, 0x1c01,
+	0x0056, 0x7d0c, 0x080c, 0xb407, 0x005e, 0x080c, 0x1dfe, 0x00f6,
+	0x7004, 0x2078, 0x080c, 0x5305, 0x0118, 0x7820, 0xc0f5, 0x7822,
+	0x00fe, 0x682b, 0xffff, 0x682f, 0xffff, 0x6808, 0x8001, 0x680a,
+	0x697c, 0x791a, 0x6980, 0x791e, 0x0804, 0x1d2b, 0x7804, 0xd09c,
+	0x0904, 0x1b0e, 0x7c20, 0x7824, 0xa405, 0x1904, 0x1b0e, 0x7818,
+	0x6812, 0x7c1c, 0x6c16, 0xa405, 0x1120, 0x7803, 0x0002, 0x0804,
+	0x1bdb, 0x751c, 0x7420, 0x7724, 0x7628, 0x7014, 0xa528, 0x7018,
+	0xa421, 0xa7b9, 0x0000, 0xa6b1, 0x0000, 0x7830, 0xa506, 0x1150,
+	0x7834, 0xa406, 0x1138, 0x7838, 0xa706, 0x1120, 0x783c, 0xa606,
+	0x0904, 0x1b0e, 0x7803, 0x0002, 0x0804, 0x1c67, 0x7803, 0x0004,
+	0x7003, 0x0000, 0x7004, 0xa00d, 0x0150, 0x6808, 0x8001, 0x680a,
+	0x1130, 0x7004, 0x2060, 0x2009, 0x0048, 0x080c, 0x864c, 0x080c,
+	0x19ba, 0x0088, 0x7803, 0x0004, 0x7003, 0x0000, 0x7004, 0x2060,
+	0x6010, 0xa005, 0x0da0, 0x2068, 0x6808, 0x8000, 0x680a, 0x6c28,
+	0x6b2c, 0x080c, 0x19d5, 0x001e, 0x000e, 0x012e, 0x0005, 0x700c,
+	0x7110, 0xa106, 0x0904, 0x1dd1, 0x7004, 0x0016, 0x210c, 0xa106,
+	0x001e, 0x0904, 0x1dd1, 0x00d6, 0x00c6, 0x216c, 0x2d00, 0xa005,
+	0x0904, 0x1dcf, 0x681c, 0xa086, 0x0008, 0x0904, 0x1dcf, 0x6820,
+	0xd0d4, 0x1904, 0x1dcf, 0x6810, 0x2068, 0x6850, 0xd0fc, 0x05a8,
+	0x8108, 0x2104, 0x6b2c, 0xa306, 0x1904, 0x1dcf, 0x8108, 0x2104,
+	0x6a28, 0xa206, 0x1904, 0x1dcf, 0x6850, 0xc0fc, 0xc0f5, 0x6852,
+	0x686c, 0x7822, 0x7016, 0x6870, 0x7826, 0x701a, 0x681c, 0x7832,
+	0x701e, 0x6820, 0x7836, 0x7022, 0x6818, 0x2060, 0x6034, 0xd09c,
+	0x0168, 0x6830, 0x2005, 0x00d6, 0xac68, 0x6808, 0x783a, 0x7026,
+	0x680c, 0x783e, 0x702a, 0x00de, 0x0804, 0x1dc9, 0xa006, 0x783a,
+	0x783e, 0x7026, 0x702a, 0x0804, 0x1dc9, 0x8108, 0x2104, 0xa005,
+	0x1904, 0x1dcf, 0x6b2c, 0xa306, 0x1904, 0x1dcf, 0x8108, 0x2104,
+	0xa005, 0x15e8, 0x6a28, 0xa206, 0x15d0, 0x6850, 0xc0f5, 0x6852,
+	0x6830, 0x2005, 0x6918, 0xa160, 0xa180, 0x000d, 0x2004, 0xd09c,
+	0x11a0, 0x6008, 0x7822, 0x7016, 0x686e, 0x600c, 0x7826, 0x701a,
+	0x6872, 0x6000, 0x7832, 0x701e, 0x6004, 0x7836, 0x7022, 0xa006,
+	0x783a, 0x783e, 0x7026, 0x702a, 0x00a0, 0x6010, 0x7822, 0x7016,
+	0x686e, 0x6014, 0x7826, 0x701a, 0x6872, 0x6000, 0x7832, 0x701e,
+	0x6004, 0x7836, 0x7022, 0x6008, 0x783a, 0x7026, 0x600c, 0x783e,
+	0x702a, 0x6810, 0x781a, 0x6814, 0x781e, 0x7803, 0x0011, 0x00ce,
+	0x00de, 0x0005, 0x2011, 0x0201, 0x2009, 0x003c, 0x2204, 0xa005,
+	0x1118, 0x8109, 0x1dd8, 0x0005, 0x0005, 0x0ca1, 0x0118, 0x780c,
+	0xd0a4, 0x0120, 0x00d9, 0xa085, 0x0001, 0x0010, 0x080c, 0x1eef,
+	0x0005, 0x0126, 0x2091, 0x2200, 0x7000, 0xa086, 0x0003, 0x1160,
+	0x700c, 0x7110, 0xa106, 0x0140, 0x080c, 0x295c, 0x20e1, 0x9028,
+	0x700f, 0xb82f, 0x7013, 0xb82f, 0x012e, 0x0005, 0x00c6, 0x080c,
+	0x5acf, 0x11b8, 0x2001, 0x0160, 0x2003, 0x0000, 0x2001, 0x0138,
+	0x2003, 0x0000, 0x2011, 0x00c8, 0xe000, 0xe000, 0x8211, 0x1de0,
+	0x04b1, 0x0066, 0x2031, 0x0000, 0x080c, 0x5b51, 0x006e, 0x00ce,
+	0x0005, 0x080c, 0x1e6e, 0x080c, 0x295c, 0x20e1, 0x9028, 0x700c,
+	0x7110, 0xa106, 0x01c0, 0x2104, 0xa005, 0x0130, 0x2060, 0x6010,
+	0x2060, 0x6008, 0x8001, 0x600a, 0xa188, 0x0003, 0xa182, 0xb84a,
+	0x0210, 0x2009, 0xb82f, 0x7112, 0x700c, 0xa106, 0x1d40, 0x080c,
+	0x28eb, 0x2110, 0x0c20, 0x2001, 0x015d, 0x2003, 0x0000, 0x2001,
+	0x0160, 0x2502, 0x2001, 0x0138, 0x2202, 0x00ce, 0x0005, 0x080c,
+	0x295c, 0x20e1, 0x9028, 0x2001, 0x015d, 0x2003, 0x0000, 0x00e6,
+	0x00c6, 0x0016, 0x2071, 0xb823, 0x700c, 0x7110, 0xa106, 0x0190,
+	0x2104, 0xa005, 0x0130, 0x2060, 0x6010, 0x2060, 0x6008, 0x8001,
+	0x600a, 0xa188, 0x0003, 0xa182, 0xb84a, 0x0210, 0x2009, 0xb82f,
+	0x7112, 0x0c50, 0x001e, 0x00ce, 0x00ee, 0x0005, 0x2001, 0x0138,
+	0x2014, 0x2003, 0x0000, 0x2001, 0x0160, 0x202c, 0x2003, 0x0000,
+	0x080c, 0x5acf, 0x1148, 0x2021, 0x0002, 0x1d04, 0x1e7d, 0x2091,
+	0x6000, 0x8421, 0x1dd0, 0x0005, 0x2021, 0xb015, 0x2001, 0x0141,
+	0x201c, 0xd3dc, 0x1168, 0x2001, 0x0109, 0x201c, 0xa39c, 0x0048,
+	0x1138, 0x2001, 0x0111, 0x201c, 0x83ff, 0x1110, 0x8421, 0x1d70,
+	0x0005, 0x00e6, 0x2071, 0x0200, 0x7808, 0xa084, 0xf000, 0xa10d,
+	0x0869, 0x2001, 0x0105, 0x2004, 0xa084, 0x0003, 0x1130, 0x2001,
+	0xb84a, 0x2004, 0xa086, 0x0000, 0x0548, 0xa026, 0x2019, 0xf000,
+	0x8319, 0x1148, 0x2001, 0x012b, 0x2003, 0x95f5, 0x2001, 0x0129,
+	0x2003, 0x95f5, 0x00d8, 0x2001, 0x0105, 0x2004, 0xa084, 0x0003,
+	0x1130, 0x2001, 0xb84a, 0x2004, 0xa086, 0x0000, 0x0178, 0x2001,
+	0x0132, 0x2004, 0xa436, 0x0110, 0x2020, 0x0c00, 0x2001, 0x0021,
+	0x2004, 0xd0fc, 0x09e8, 0x080c, 0x214a, 0x08c0, 0x20e1, 0x7000,
+	0x7324, 0x7420, 0x7028, 0x7028, 0x7426, 0x7037, 0x0001, 0x810f,
+	0x712e, 0x702f, 0x0100, 0x7037, 0x0008, 0x7326, 0x7422, 0x2001,
+	0x0160, 0x2502, 0x2001, 0x0138, 0x2202, 0x00ee, 0x0005, 0x0026,
+	0x2001, 0x015d, 0x2003, 0x0000, 0x7908, 0xa18c, 0x0fff, 0xa182,
+	0x0ffd, 0x0210, 0x2009, 0x0000, 0xa190, 0x0007, 0xa294, 0x1ff8,
+	0x8214, 0x8214, 0x8214, 0x2001, 0x020a, 0x82ff, 0x0140, 0x20e1,
+	0x6000, 0x200c, 0x200c, 0x200c, 0x200c, 0x8211, 0x1dd0, 0x20e1,
+	0x7000, 0x200c, 0x200c, 0x7003, 0x0000, 0x20e1, 0x6000, 0x2001,
+	0x0208, 0x200c, 0x2001, 0x0209, 0x2004, 0xa106, 0x0158, 0x080c,
+	0x1dd2, 0x0130, 0x7908, 0xd1ec, 0x1128, 0x790c, 0xd1a4, 0x0960,
+	0x080c, 0x1dfe, 0xa006, 0x002e, 0x0005, 0x00f6, 0x00e6, 0x0016,
+	0x0026, 0x2071, 0xb823, 0x2079, 0x0030, 0x2011, 0x0050, 0x7000,
+	0xa086, 0x0000, 0x01a8, 0x8211, 0x0188, 0x2001, 0x0005, 0x2004,
+	0xd08c, 0x0dc8, 0x7904, 0xa18c, 0x0780, 0x0016, 0x080c, 0x1b06,
+	0x001e, 0x81ff, 0x1118, 0x2011, 0x0050, 0x0c48, 0xa085, 0x0001,
+	0x002e, 0x001e, 0x00ee, 0x00fe, 0x0005, 0x7803, 0x0004, 0x2009,
+	0x0064, 0x7804, 0xd0ac, 0x0904, 0x1fa1, 0x8109, 0x1dd0, 0x2009,
+	0x0100, 0x210c, 0xa18a, 0x0003, 0x0a0c, 0x1515, 0x080c, 0x2251,
+	0x00e6, 0x00f6, 0x2071, 0xb812, 0x2079, 0x0010, 0x7004, 0xa086,
+	0x0000, 0x0538, 0x7800, 0x0006, 0x7820, 0x0006, 0x7830, 0x0006,
+	0x7834, 0x0006, 0x7838, 0x0006, 0x783c, 0x0006, 0x7803, 0x0004,
+	0xe000, 0xe000, 0x2079, 0x0030, 0x7804, 0xd0ac, 0x190c, 0x1515,
+	0x2079, 0x0010, 0x000e, 0x783e, 0x000e, 0x783a, 0x000e, 0x7836,
+	0x000e, 0x7832, 0x000e, 0x7822, 0x000e, 0x7802, 0x00fe, 0x00ee,
+	0x0030, 0x00fe, 0x00ee, 0x7804, 0xd0ac, 0x190c, 0x1515, 0x080c,
+	0x7230, 0x0005, 0x00e6, 0x2071, 0xb84a, 0x7003, 0x0000, 0x00ee,
+	0x0005, 0x00d6, 0xa280, 0x0004, 0x206c, 0x694c, 0xd1dc, 0x1904,
+	0x201f, 0x6934, 0xa184, 0x0007, 0x0002, 0x1fbd, 0x200a, 0x1fbd,
+	0x1fbd, 0x1fbd, 0x1ff1, 0x1fd0, 0x1fbf, 0x080c, 0x1515, 0x684c,
+	0xd0b4, 0x0904, 0x2107, 0x6860, 0x682e, 0x6816, 0x685c, 0x682a,
+	0x6812, 0x687c, 0x680a, 0x6880, 0x680e, 0x6958, 0x0804, 0x2012,
+	0x6834, 0xa084, 0x00ff, 0xa086, 0x001e, 0x1d38, 0x684c, 0xd0b4,
+	0x0904, 0x2107, 0x6860, 0x682e, 0x6816, 0x685c, 0x682a, 0x6812,
+	0x687c, 0x680a, 0x6880, 0x680e, 0x6804, 0x681a, 0xa080, 0x000d,
+	0x2004, 0xa084, 0x000f, 0xa080, 0x22e5, 0x2005, 0x6832, 0x6958,
+	0x0450, 0xa18c, 0x00ff, 0xa186, 0x0015, 0x1548, 0x684c, 0xd0b4,
+	0x0904, 0x2107, 0x6804, 0x681a, 0xa080, 0x000d, 0x2004, 0xa084,
+	0x000f, 0xa080, 0x22e5, 0x2005, 0x6832, 0x6958, 0xa006, 0x682e,
+	0x682a, 0x0088, 0x684c, 0xd0b4, 0x0904, 0x1ae1, 0x6958, 0xa006,
+	0x682e, 0x682a, 0x2d00, 0x681a, 0x6834, 0xa084, 0x000f, 0xa080,
+	0x22e5, 0x2005, 0x6832, 0x6926, 0x684c, 0xc0dd, 0x684e, 0x00de,
+	0x0005, 0x00f6, 0x2079, 0x0020, 0x7804, 0xd0fc, 0x190c, 0x214a,
+	0x00e6, 0x00d6, 0x2071, 0xb84a, 0x7000, 0xa005, 0x1904, 0x2087,
+	0x00c6, 0x7206, 0xa280, 0x0004, 0x205c, 0x7004, 0x2068, 0x7803,
+	0x0004, 0x6818, 0x00d6, 0x2068, 0x686c, 0x7812, 0x6890, 0x00f6,
+	0x20e1, 0x9040, 0x2079, 0x0200, 0x781a, 0x2079, 0x0100, 0x8004,
+	0x78d6, 0x00fe, 0x00de, 0x2b68, 0x6824, 0x2050, 0x6818, 0x2060,
+	0x6830, 0x2040, 0x6034, 0xa0cc, 0x000f, 0x6908, 0x791a, 0x7116,
+	0x680c, 0x781e, 0x701a, 0xa006, 0x700e, 0x7012, 0x7004, 0x692c,
+	0x6814, 0xa106, 0x1120, 0x6928, 0x6810, 0xa106, 0x0158, 0x0036,
+	0x0046, 0x6b14, 0x6c10, 0x080c, 0x2305, 0x004e, 0x003e, 0x0110,
+	0x00ce, 0x00a8, 0x8aff, 0x1120, 0x00ce, 0xa085, 0x0001, 0x0078,
+	0x0126, 0x2091, 0x8000, 0x2079, 0x0020, 0x2009, 0x0001, 0x0059,
+	0x0118, 0x2009, 0x0001, 0x0039, 0x012e, 0x00ce, 0xa006, 0x00de,
+	0x00ee, 0x00fe, 0x0005, 0x0076, 0x0066, 0x0056, 0x0046, 0x0036,
+	0x0026, 0x8aff, 0x0904, 0x2100, 0x700c, 0x7214, 0xa23a, 0x7010,
+	0x7218, 0xa203, 0x0a04, 0x20ff, 0xa705, 0x0904, 0x20ff, 0xa03e,
+	0x2730, 0x6850, 0xd0fc, 0x11a8, 0x00d6, 0x2805, 0xac68, 0x2900,
+	0x0002, 0x20e2, 0x20c7, 0x20c7, 0x20e2, 0x20e2, 0x20db, 0x20e2,
+	0x20c7, 0x20e2, 0x20cc, 0x20cc, 0x20e2, 0x20e2, 0x20e2, 0x20d3,
+	0x20cc, 0xc0fc, 0x6852, 0x6b6c, 0x6a70, 0x6d1c, 0x6c20, 0xd99c,
+	0x0528, 0x00d6, 0x2805, 0xac68, 0x6f08, 0x6e0c, 0x00f0, 0x6b08,
+	0x6a0c, 0x6d00, 0x6c04, 0x00c8, 0x6b10, 0x6a14, 0x6d00, 0x6c04,
+	0x6f08, 0x6e0c, 0x0090, 0x00de, 0x00d6, 0x6834, 0xa084, 0x00ff,
+	0xa086, 0x001e, 0x1138, 0x00de, 0x080c, 0x22a7, 0x1904, 0x2091,
+	0xa00e, 0x00f0, 0x00de, 0x080c, 0x1515, 0x00de, 0x7b22, 0x7a26,
+	0x7d32, 0x7c36, 0x7f3a, 0x7e3e, 0x7902, 0x7000, 0x8000, 0x7002,
+	0x6828, 0xa300, 0x682a, 0x682c, 0xa201, 0x682e, 0x700c, 0xa300,
+	0x700e, 0x7010, 0xa201, 0x7012, 0x080c, 0x22a7, 0x0008, 0xa006,
+	0x002e, 0x003e, 0x004e, 0x005e, 0x006e, 0x007e, 0x0005, 0x080c,
+	0x1515, 0x0026, 0x2001, 0x0105, 0x2003, 0x0010, 0x20e1, 0x9040,
+	0x7803, 0x0004, 0x7003, 0x0000, 0x7004, 0x2060, 0x00d6, 0x6010,
+	0x2068, 0x080c, 0x9c5a, 0x0118, 0x6850, 0xc0bd, 0x6852, 0x601c,
+	0xa086, 0x0006, 0x1180, 0x2061, 0x0100, 0x62c8, 0x2001, 0x00fa,
+	0x8001, 0x1df0, 0x60c8, 0xa206, 0x1dc0, 0x60c4, 0x686a, 0x60c8,
+	0x6866, 0x7004, 0x2060, 0x00de, 0x00c6, 0x080c, 0x992a, 0x00ce,
+	0x2001, 0xb7ef, 0x2004, 0xac06, 0x1150, 0x20e1, 0x9040, 0x080c,
+	0x825d, 0x2011, 0x0000, 0x080c, 0x807f, 0x080c, 0x7230, 0x002e,
+	0x0804, 0x2204, 0x0126, 0x2091, 0x2400, 0x0006, 0x0016, 0x00f6,
+	0x00e6, 0x00d6, 0x00c6, 0x2079, 0x0020, 0x2071, 0xb84a, 0x2b68,
+	0x6818, 0x2060, 0x7904, 0x7803, 0x0002, 0xa184, 0x0700, 0x1904,
+	0x2109, 0x7000, 0x0002, 0x2204, 0x2167, 0x21d7, 0x2202, 0x8001,
+	0x7002, 0xd19c, 0x1170, 0x8aff, 0x05d0, 0x2009, 0x0001, 0x080c,
+	0x208b, 0x0904, 0x2204, 0x2009, 0x0001, 0x080c, 0x208b, 0x0804,
+	0x2204, 0x7803, 0x0004, 0xd194, 0x0148, 0x6850, 0xc0fc, 0x6852,
+	0x8aff, 0x11d8, 0x684c, 0xc0f5, 0x684e, 0x00b8, 0x0026, 0x0036,
+	0x6b28, 0x6a2c, 0x7820, 0x686e, 0xa31a, 0x7824, 0x6872, 0xa213,
+	0x7830, 0x681e, 0x7834, 0x6822, 0x6b2a, 0x6a2e, 0x003e, 0x002e,
+	0x080c, 0x22bd, 0x6850, 0xc0fd, 0x6852, 0x2a00, 0x6826, 0x2c00,
+	0x681a, 0x2800, 0x6832, 0x7003, 0x0000, 0x0804, 0x2204, 0x00f6,
+	0x0026, 0x781c, 0x0006, 0x7818, 0x0006, 0x2079, 0x0100, 0x7a14,
+	0xa284, 0x0184, 0xa085, 0x0012, 0x7816, 0x0036, 0x2019, 0x1000,
+	0x8319, 0x090c, 0x1515, 0x7820, 0xd0bc, 0x1dd0, 0x003e, 0x79c8,
+	0x000e, 0xa102, 0x001e, 0x0006, 0x0016, 0x79c4, 0x000e, 0xa103,
+	0x78c6, 0x000e, 0x78ca, 0xa284, 0x0184, 0xa085, 0x0012, 0x7816,
+	0x002e, 0x00fe, 0x7803, 0x0008, 0x7003, 0x0000, 0x0468, 0x8001,
+	0x7002, 0xd194, 0x0168, 0x7804, 0xd0fc, 0x1904, 0x215a, 0xd19c,
+	0x11f8, 0x8aff, 0x0508, 0x2009, 0x0001, 0x080c, 0x208b, 0x00e0,
+	0x0026, 0x0036, 0x6b28, 0x6a2c, 0x080c, 0x22bd, 0x00d6, 0x2805,
+	0xac68, 0x6034, 0xd09c, 0x1128, 0x6808, 0xa31a, 0x680c, 0xa213,
+	0x0020, 0x6810, 0xa31a, 0x6814, 0xa213, 0x00de, 0x0804, 0x218a,
+	0x0804, 0x2186, 0x080c, 0x1515, 0x00ce, 0x00de, 0x00ee, 0x00fe,
+	0x001e, 0x000e, 0x012e, 0x0005, 0x00f6, 0x00e6, 0x2071, 0xb84a,
+	0x7000, 0xa086, 0x0000, 0x05d0, 0x2079, 0x0020, 0x0016, 0x2009,
+	0x0207, 0x210c, 0xd194, 0x0198, 0x2009, 0x020c, 0x210c, 0xa184,
+	0x0003, 0x0168, 0x080c, 0xb450, 0x2001, 0x0133, 0x2004, 0xa005,
+	0x090c, 0x1515, 0x20e1, 0x9040, 0x2001, 0x020c, 0x2102, 0x2009,
+	0x0206, 0x2104, 0x2009, 0x0203, 0x210c, 0xa106, 0x1110, 0x20e1,
+	0x9040, 0x7804, 0xd0fc, 0x09d8, 0x080c, 0x214a, 0x7000, 0xa086,
+	0x0000, 0x19a8, 0x001e, 0x7803, 0x0004, 0x7804, 0xd0ac, 0x1de8,
+	0x20e1, 0x9040, 0x7803, 0x0002, 0x7003, 0x0000, 0x00ee, 0x00fe,
+	0x0005, 0x0026, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2071, 0xb84a,
+	0x2079, 0x0020, 0x7000, 0xa086, 0x0000, 0x0540, 0x7004, 0x2060,
+	0x6010, 0x2068, 0x080c, 0x9c5a, 0x0158, 0x6850, 0xc0b5, 0x6852,
+	0x680c, 0x7a1c, 0xa206, 0x1120, 0x6808, 0x7a18, 0xa206, 0x01e0,
+	0x2001, 0x0105, 0x2003, 0x0010, 0x20e1, 0x9040, 0x7803, 0x0004,
+	0x7003, 0x0000, 0x7004, 0x2060, 0x080c, 0x992a, 0x20e1, 0x9040,
+	0x080c, 0x825d, 0x2011, 0x0000, 0x080c, 0x807f, 0x00fe, 0x00ee,
+	0x00de, 0x00ce, 0x002e, 0x0005, 0x6810, 0x6a14, 0xa205, 0x1d00,
+	0x684c, 0xc0dc, 0x684e, 0x2c10, 0x080c, 0x1fa9, 0x2001, 0x0105,
+	0x2003, 0x0010, 0x20e1, 0x9040, 0x7803, 0x0004, 0x7003, 0x0000,
+	0x2069, 0xb7e0, 0x6833, 0x0000, 0x683f, 0x0000, 0x08f8, 0x8840,
+	0x2805, 0xa005, 0x1170, 0x6004, 0xa005, 0x0168, 0x681a, 0x2060,
+	0x6034, 0xa084, 0x000f, 0xa080, 0x22e5, 0x2045, 0x88ff, 0x090c,
+	0x1515, 0x8a51, 0x0005, 0x2050, 0x0005, 0x8a50, 0x8841, 0x2805,
+	0xa005, 0x1190, 0x2c00, 0xad06, 0x0120, 0x6000, 0xa005, 0x1108,
+	0x2d00, 0x2060, 0x681a, 0x6034, 0xa084, 0x000f, 0xa080, 0x22f5,
+	0x2045, 0x88ff, 0x090c, 0x1515, 0x0005, 0x0000, 0x0011, 0x0015,
+	0x0019, 0x001d, 0x0021, 0x0025, 0x0029, 0x0000, 0x000f, 0x0015,
+	0x001b, 0x0021, 0x0027, 0x0000, 0x0000, 0x0000, 0x22da, 0x22d6,
+	0x0000, 0x0000, 0x22e4, 0x0000, 0x22da, 0x0000, 0x22e1, 0x22de,
+	0x0000, 0x0000, 0x0000, 0x22e4, 0x22e1, 0x0000, 0x22dc, 0x22dc,
+	0x0000, 0x0000, 0x22e4, 0x0000, 0x22dc, 0x0000, 0x22e2, 0x22e2,
+	0x0000, 0x0000, 0x0000, 0x22e4, 0x22e2, 0x00a6, 0x0096, 0x0086,
+	0x6b2e, 0x6c2a, 0x6858, 0xa055, 0x0904, 0x2396, 0x2d60, 0x6034,
+	0xa0cc, 0x000f, 0xa9c0, 0x22e5, 0xa986, 0x0007, 0x0130, 0xa986,
+	0x000e, 0x0118, 0xa986, 0x000f, 0x1120, 0x605c, 0xa422, 0x6060,
+	0xa31b, 0x2805, 0xa045, 0x1140, 0x0310, 0x0804, 0x2396, 0x6004,
+	0xa065, 0x0904, 0x2396, 0x0c18, 0x2805, 0xa005, 0x01a8, 0xac68,
+	0xd99c, 0x1128, 0x6808, 0xa422, 0x680c, 0xa31b, 0x0020, 0x6810,
+	0xa422, 0x6814, 0xa31b, 0x0620, 0x2300, 0xa405, 0x0150, 0x8a51,
+	0x0904, 0x2396, 0x8840, 0x0c40, 0x6004, 0xa065, 0x0904, 0x2396,
+	0x0830, 0x8a51, 0x0904, 0x2396, 0x8840, 0x2805, 0xa005, 0x1158,
+	0x6004, 0xa065, 0x0904, 0x2396, 0x6034, 0xa0cc, 0x000f, 0xa9c0,
+	0x22e5, 0x2805, 0x2040, 0x2b68, 0x6850, 0xc0fc, 0x6852, 0x0458,
+	0x8422, 0x8420, 0x831a, 0xa399, 0x0000, 0x00d6, 0x2b68, 0x6c6e,
+	0x6b72, 0x00de, 0xd99c, 0x1168, 0x6908, 0x2400, 0xa122, 0x690c,
+	0x2300, 0xa11b, 0x0a0c, 0x1515, 0x6800, 0xa420, 0x6804, 0xa319,
+	0x0060, 0x6910, 0x2400, 0xa122, 0x6914, 0x2300, 0xa11b, 0x0a0c,
+	0x1515, 0x6800, 0xa420, 0x6804, 0xa319, 0x2b68, 0x6c1e, 0x6b22,
+	0x6850, 0xc0fd, 0x6852, 0x2c00, 0x681a, 0x2800, 0x6832, 0x2a00,
+	0x6826, 0x000e, 0x000e, 0x000e, 0xa006, 0x0028, 0x008e, 0x009e,
+	0x00ae, 0xa085, 0x0001, 0x0005, 0x2001, 0x0005, 0x2004, 0xa084,
+	0x0007, 0x0002, 0x23aa, 0x23ab, 0x23ae, 0x23b1, 0x23b6, 0x23b9,
+	0x23be, 0x23c3, 0x0005, 0x080c, 0x214a, 0x0005, 0x080c, 0x1b06,
+	0x0005, 0x080c, 0x1b06, 0x080c, 0x214a, 0x0005, 0x080c, 0x171b,
+	0x0005, 0x080c, 0x214a, 0x080c, 0x171b, 0x0005, 0x080c, 0x1b06,
+	0x080c, 0x171b, 0x0005, 0x080c, 0x1b06, 0x080c, 0x214a, 0x080c,
+	0x171b, 0x0005, 0x0126, 0x2091, 0x2600, 0x2079, 0x0200, 0x2071,
+	0xbb80, 0x2069, 0xb500, 0x080c, 0x24c0, 0x080c, 0x24b0, 0x2009,
+	0x0004, 0x7912, 0x7817, 0x0004, 0x080c, 0x27f8, 0x781b, 0x0002,
+	0x20e1, 0x9080, 0x20e1, 0x4000, 0x20a9, 0x0080, 0x782f, 0x0000,
+	0x1f04, 0x23e6, 0x20e1, 0x9080, 0x783b, 0x001f, 0x20e1, 0x8700,
+	0x012e, 0x0005, 0x0126, 0x2091, 0x2600, 0x781c, 0xd0a4, 0x190c,
+	0x24ad, 0xa084, 0x0007, 0x0002, 0x2416, 0x2404, 0x2407, 0x240a,
+	0x240f, 0x2411, 0x2413, 0x2415, 0x080c, 0x63c4, 0x0078, 0x080c,
+	0x6403, 0x0060, 0x080c, 0x63c4, 0x080c, 0x6403, 0x0038, 0x0041,
+	0x0028, 0x0031, 0x0018, 0x0021, 0x0008, 0x0011, 0x012e, 0x0005,
+	0x0006, 0x0016, 0x0026, 0x080c, 0xb450, 0x7930, 0xa184, 0x0003,
+	0x01b0, 0x2001, 0xb7ef, 0x2004, 0xa005, 0x0170, 0x2001, 0x0133,
+	0x2004, 0xa005, 0x090c, 0x1515, 0x00c6, 0x2001, 0xb7ef, 0x2064,
+	0x080c, 0x992a, 0x00ce, 0x04b8, 0x20e1, 0x9040, 0x04a0, 0xa184,
+	0x0030, 0x01e0, 0x6a00, 0xa286, 0x0003, 0x1108, 0x00a0, 0x080c,
+	0x5acf, 0x1178, 0x2001, 0xb79f, 0x2003, 0x0001, 0x2001, 0xb500,
+	0x2003, 0x0001, 0xa085, 0x0001, 0x080c, 0x5b13, 0x080c, 0x5a07,
+	0x0010, 0x080c, 0x4b1f, 0x080c, 0x24b0, 0x00a8, 0xa184, 0x00c0,
+	0x0168, 0x00e6, 0x0036, 0x0046, 0x0056, 0x2071, 0xb823, 0x080c,
+	0x1dfe, 0x005e, 0x004e, 0x003e, 0x00ee, 0x0028, 0xa184, 0x0300,
+	0x0110, 0x20e1, 0x9020, 0x7932, 0x002e, 0x001e, 0x000e, 0x0005,
+	0x0016, 0x00e6, 0x00f6, 0x2071, 0xb500, 0x7128, 0x2001, 0xb791,
+	0x2102, 0x2001, 0xb799, 0x2102, 0xa182, 0x0211, 0x1218, 0x2009,
+	0x0008, 0x0400, 0xa182, 0x0259, 0x1218, 0x2009, 0x0007, 0x00d0,
+	0xa182, 0x02c1, 0x1218, 0x2009, 0x0006, 0x00a0, 0xa182, 0x0349,
+	0x1218, 0x2009, 0x0005, 0x0070, 0xa182, 0x0421, 0x1218, 0x2009,
+	0x0004, 0x0040, 0xa182, 0x0581, 0x1218, 0x2009, 0x0003, 0x0010,
+	0x2009, 0x0002, 0x2079, 0x0200, 0x7912, 0x7817, 0x0004, 0x080c,
+	0x27f8, 0x00fe, 0x00ee, 0x001e, 0x0005, 0x7938, 0x080c, 0x1515,
+	0x00e6, 0x0026, 0x2071, 0x0200, 0x20e1, 0x1000, 0x7220, 0x7028,
+	0x7020, 0xa206, 0x0de0, 0x20e1, 0x9010, 0x002e, 0x00ee, 0x0005,
+	0x20e1, 0xa000, 0x7837, 0x0001, 0x782f, 0x0000, 0x782f, 0x0000,
+	0x782f, 0x0000, 0x782f, 0x0000, 0x7837, 0x0005, 0x20a9, 0x0210,
+	0x7830, 0xd0bc, 0x1110, 0x1f04, 0x24d0, 0x7837, 0x0001, 0x7837,
+	0x0000, 0xe000, 0xe000, 0x20e1, 0xa000, 0x0005, 0x0126, 0x2091,
+	0x2800, 0x2061, 0x0100, 0x2071, 0xb500, 0x6024, 0x6026, 0x6053,
+	0x0030, 0x080c, 0x2837, 0x6050, 0xa084, 0xfe7f, 0x6052, 0x2009,
+	0x00ef, 0x6132, 0x6136, 0x080c, 0x2847, 0x60e7, 0x0000, 0x61ea,
+	0x60e3, 0x0008, 0x604b, 0xf7f7, 0x6043, 0x0000, 0x602f, 0x0080,
+	0x602f, 0x0000, 0x6007, 0x0e9f, 0x601b, 0x001e, 0x600f, 0x00ff,
+	0x2001, 0xb78d, 0x2003, 0x00ff, 0x602b, 0x002f, 0x012e, 0x0005,
+	0x2001, 0xb532, 0x2003, 0x0000, 0x2001, 0xb531, 0x2003, 0x0001,
+	0x0005, 0x0126, 0x2091, 0x2800, 0x0006, 0x0016, 0x0026, 0x6124,
+	0xa184, 0x1e2c, 0x1118, 0xa184, 0x0007, 0x002a, 0xa195, 0x0004,
+	0xa284, 0x0007, 0x0002, 0x254d, 0x2533, 0x2536, 0x2539, 0x253e,
+	0x2540, 0x2544, 0x2548, 0x080c, 0x6b74, 0x00b8, 0x080c, 0x6c4f,
+	0x00a0, 0x080c, 0x6c4f, 0x080c, 0x6b74, 0x0078, 0x0099, 0x0068,
+	0x080c, 0x6b74, 0x0079, 0x0048, 0x080c, 0x6c4f, 0x0059, 0x0028,
+	0x080c, 0x6c4f, 0x080c, 0x6b74, 0x0029, 0x002e, 0x001e, 0x000e,
+	0x012e, 0x0005, 0x6124, 0x6028, 0xd09c, 0x0118, 0xd19c, 0x1904,
+	0x2766, 0x080c, 0x5acf, 0x0578, 0x7000, 0xa086, 0x0003, 0x0198,
+	0x6024, 0xa084, 0x1800, 0x0178, 0x080c, 0x5af5, 0x0118, 0x080c,
+	0x5ae1, 0x1148, 0x6027, 0x0020, 0x6043, 0x0000, 0x2001, 0xb79e,
+	0x2003, 0xaaaa, 0x0458, 0x080c, 0x5af5, 0x15d0, 0x6024, 0xa084,
+	0x1800, 0x1108, 0x04a8, 0x2001, 0xb79e, 0x2003, 0xaaaa, 0x2001,
+	0xb79f, 0x2003, 0x0001, 0x2001, 0xb500, 0x2003, 0x0001, 0x080c,
+	0x5a07, 0x0804, 0x2766, 0xd1ac, 0x1518, 0x6024, 0xd0dc, 0x1170,
+	0xd0e4, 0x1188, 0xd0d4, 0x11a0, 0xd0cc, 0x0130, 0x708c, 0xa086,
+	0x0028, 0x1110, 0x080c, 0x5c5e, 0x0804, 0x2766, 0x2001, 0xb79f,
+	0x2003, 0x0000, 0x0048, 0x2001, 0xb79f, 0x2003, 0x0002, 0x0020,
+	0x080c, 0x5bd1, 0x0804, 0x2766, 0x080c, 0x5d03, 0x0804, 0x2766,
+	0xd1ac, 0x0904, 0x26ae, 0x080c, 0x5acf, 0x11d8, 0x6027, 0x0020,
+	0x0006, 0x0026, 0x0036, 0x080c, 0x5aeb, 0x1170, 0x2001, 0xb79f,
+	0x2003, 0x0001, 0x2001, 0xb500, 0x2003, 0x0001, 0x080c, 0x5a07,
+	0x003e, 0x002e, 0x000e, 0x0005, 0x003e, 0x002e, 0x000e, 0x080c,
+	0x5aa6, 0x0016, 0x0046, 0x00c6, 0x644c, 0xa486, 0xf0f0, 0x1138,
+	0x2061, 0x0100, 0x644a, 0x6043, 0x0090, 0x6043, 0x0010, 0x74ce,
+	0xa48c, 0xff00, 0x7034, 0xd084, 0x0178, 0xa186, 0xf800, 0x1160,
+	0x703c, 0xd084, 0x1148, 0xc085, 0x703e, 0x0036, 0x2418, 0x2011,
+	0x8016, 0x080c, 0x3ecc, 0x003e, 0xa196, 0xff00, 0x05b8, 0x7054,
+	0xa084, 0x00ff, 0x810f, 0xa116, 0x0588, 0x7130, 0xd184, 0x1570,
+	0x2011, 0xb553, 0x2214, 0xd2ec, 0x0138, 0xc18d, 0x7132, 0x2011,
+	0xb553, 0x2214, 0xd2ac, 0x1510, 0x6240, 0xa294, 0x0010, 0x0130,
+	0x6248, 0xa294, 0xff00, 0xa296, 0xff00, 0x01c0, 0x7030, 0xd08c,
+	0x0904, 0x267b, 0x7034, 0xd08c, 0x1140, 0x2001, 0xb50c, 0x200c,
+	0xd1ac, 0x1904, 0x267b, 0xc1ad, 0x2102, 0x0036, 0x73cc, 0x2011,
+	0x8013, 0x080c, 0x3ecc, 0x003e, 0x0804, 0x267b, 0x7034, 0xd08c,
+	0x1140, 0x2001, 0xb50c, 0x200c, 0xd1ac, 0x1904, 0x267b, 0xc1ad,
+	0x2102, 0x0036, 0x73cc, 0x2011, 0x8013, 0x080c, 0x3ecc, 0x003e,
+	0x7130, 0xc185, 0x7132, 0x2011, 0xb553, 0x220c, 0xd1a4, 0x01d0,
+	0x0016, 0x2009, 0x0001, 0x2011, 0x0100, 0x080c, 0x6b1a, 0x2019,
+	0x000e, 0x080c, 0xb065, 0xa484, 0x00ff, 0xa080, 0x2dc4, 0x200d,
+	0xa18c, 0xff00, 0x810f, 0x8127, 0xa006, 0x2009, 0x000e, 0x080c,
+	0xb0e8, 0x001e, 0xd1ac, 0x1148, 0x0016, 0x2009, 0x0000, 0x2019,
+	0x0004, 0x080c, 0x2c6f, 0x001e, 0x0070, 0x0156, 0x20a9, 0x007f,
+	0x2009, 0x0000, 0x080c, 0x4fa9, 0x1110, 0x080c, 0x4c0b, 0x8108,
+	0x1f04, 0x2672, 0x015e, 0x00ce, 0x004e, 0x2011, 0x0003, 0x080c,
+	0x8075, 0x2011, 0x0002, 0x080c, 0x807f, 0x080c, 0x7f59, 0x0036,
+	0x2019, 0x0000, 0x080c, 0x7fe4, 0x003e, 0x60e3, 0x0000, 0x001e,
+	0x2001, 0xb500, 0x2014, 0xa296, 0x0004, 0x1128, 0xd19c, 0x11b0,
+	0x6228, 0xc29d, 0x622a, 0x2003, 0x0001, 0x2001, 0xb523, 0x2003,
+	0x0000, 0x6027, 0x0020, 0x080c, 0x5af5, 0x1140, 0x0016, 0x2009,
+	0x07d0, 0x2011, 0x59e4, 0x080c, 0x6a22, 0x001e, 0xd194, 0x0904,
+	0x2766, 0x0016, 0x6220, 0xd2b4, 0x0904, 0x2717, 0x080c, 0x6a10,
+	0x080c, 0x7d7a, 0x6027, 0x0004, 0x00f6, 0x2019, 0xb7e9, 0x2304,
+	0xa07d, 0x0570, 0x7804, 0xa086, 0x0032, 0x1550, 0x00d6, 0x00c6,
+	0x00e6, 0x2069, 0x0140, 0x618c, 0x6288, 0x7818, 0x608e, 0x7808,
+	0x608a, 0x6043, 0x0002, 0x2001, 0x0003, 0x8001, 0x1df0, 0x6043,
+	0x0000, 0x6803, 0x1000, 0x6803, 0x0000, 0x618e, 0x628a, 0x080c,
+	0x7090, 0x080c, 0x7173, 0x7810, 0x2070, 0x7037, 0x0103, 0x2f60,
+	0x080c, 0x861d, 0x00ee, 0x00ce, 0x00de, 0x00fe, 0x001e, 0x0005,
+	0x00fe, 0x00d6, 0x2069, 0x0140, 0x6804, 0xa084, 0x4000, 0x0120,
+	0x6803, 0x1000, 0x6803, 0x0000, 0x00de, 0x00c6, 0x2061, 0xb7e0,
+	0x6028, 0xa09a, 0x00c8, 0x1238, 0x8000, 0x602a, 0x00ce, 0x080c,
+	0x7d6d, 0x0804, 0x2765, 0x2019, 0xb7e9, 0x2304, 0xa065, 0x0120,
+	0x2009, 0x0027, 0x080c, 0x864c, 0x00ce, 0x0804, 0x2765, 0xd2bc,
+	0x0904, 0x2765, 0x080c, 0x6a1d, 0x6014, 0xa084, 0x0184, 0xa085,
+	0x0010, 0x6016, 0x6027, 0x0004, 0x00d6, 0x2069, 0x0140, 0x6804,
+	0xa084, 0x4000, 0x0120, 0x6803, 0x1000, 0x6803, 0x0000, 0x00de,
+	0x00c6, 0x2061, 0xb7e0, 0x6044, 0xa09a, 0x00c8, 0x12f0, 0x8000,
+	0x6046, 0x603c, 0x00ce, 0xa005, 0x0540, 0x2009, 0x07d0, 0x080c,
+	0x6a15, 0xa080, 0x0007, 0x2004, 0xa086, 0x0006, 0x1138, 0x6114,
+	0xa18c, 0x0184, 0xa18d, 0x0012, 0x6116, 0x00b8, 0x6114, 0xa18c,
+	0x0184, 0xa18d, 0x0016, 0x6116, 0x0080, 0x0036, 0x2019, 0x0001,
+	0x080c, 0x7fe4, 0x003e, 0x2019, 0xb7ef, 0x2304, 0xa065, 0x0120,
+	0x2009, 0x004f, 0x080c, 0x864c, 0x00ce, 0x001e, 0xd19c, 0x0904,
+	0x27bf, 0x7034, 0xd0ac, 0x1560, 0x0016, 0x0156, 0x6027, 0x0008,
+	0x602f, 0x0020, 0x20a9, 0x0006, 0x1d04, 0x2774, 0x2091, 0x6000,
+	0x1f04, 0x2774, 0x602f, 0x0000, 0x6150, 0xa185, 0x1400, 0x6052,
+	0x20a9, 0x0366, 0x1d04, 0x2782, 0x2091, 0x6000, 0x6020, 0xd09c,
+	0x1130, 0x015e, 0x6152, 0x001e, 0x6027, 0x0008, 0x0480, 0x080c,
+	0x2907, 0x1f04, 0x2782, 0x015e, 0x6152, 0x001e, 0x6027, 0x0008,
+	0x0016, 0x6028, 0xc09c, 0x602a, 0x2011, 0x0003, 0x080c, 0x8075,
+	0x2011, 0x0002, 0x080c, 0x807f, 0x080c, 0x7f59, 0x0036, 0x2019,
+	0x0000, 0x080c, 0x7fe4, 0x003e, 0x60e3, 0x0000, 0x080c, 0xb42f,
+	0x080c, 0xb44a, 0xa085, 0x0001, 0x080c, 0x5b13, 0x2001, 0xb500,
+	0x2003, 0x0004, 0x6027, 0x0008, 0x080c, 0x12dd, 0x001e, 0xa18c,
+	0xffd0, 0x6126, 0x0005, 0x0006, 0x0016, 0x0026, 0x00e6, 0x00f6,
+	0x0126, 0x2091, 0x8000, 0x2071, 0xb500, 0x71c4, 0x70c6, 0xa116,
+	0x0500, 0x81ff, 0x0128, 0x2011, 0x8011, 0x080c, 0x3ecc, 0x00c8,
+	0x2011, 0x8012, 0x080c, 0x3ecc, 0x2001, 0xb572, 0x2004, 0xd0fc,
+	0x1180, 0x0036, 0x00c6, 0x080c, 0x2892, 0x080c, 0x7f35, 0x2061,
+	0x0100, 0x2019, 0x0028, 0x2009, 0x0000, 0x080c, 0x2c6f, 0x00ce,
+	0x003e, 0x012e, 0x00fe, 0x00ee, 0x002e, 0x001e, 0x000e, 0x0005,
+	0x00c6, 0x00f6, 0x0006, 0x0026, 0x2061, 0x0100, 0xa190, 0x280b,
+	0x2205, 0x60f2, 0x2011, 0x2818, 0x2205, 0x60ee, 0x002e, 0x000e,
+	0x00fe, 0x00ce, 0x0005, 0x0840, 0x0840, 0x0840, 0x0580, 0x0420,
+	0x0348, 0x02c0, 0x0258, 0x0210, 0x01a8, 0x01a8, 0x01a8, 0x01a8,
+	0x0140, 0x00f8, 0x00d0, 0x00b0, 0x00a0, 0x2028, 0xa18c, 0x00ff,
+	0x2130, 0xa094, 0xff00, 0x1110, 0x81ff, 0x0118, 0x080c, 0x66b1,
+	0x0038, 0xa080, 0x2dc4, 0x200d, 0xa18c, 0xff00, 0x810f, 0xa006,
+	0x0005, 0xa080, 0x2dc4, 0x200d, 0xa18c, 0x00ff, 0x0005, 0x00d6,
+	0x2069, 0x0140, 0x2001, 0xb515, 0x2003, 0x00ef, 0x20a9, 0x0010,
+	0xa006, 0x6852, 0x6856, 0x1f04, 0x2842, 0x00de, 0x0005, 0x0006,
+	0x00d6, 0x0026, 0x2069, 0x0140, 0x2001, 0xb515, 0x2102, 0x8114,
+	0x8214, 0x8214, 0x8214, 0x20a9, 0x0010, 0x6853, 0x0000, 0xa006,
+	0x82ff, 0x1128, 0xa184, 0x000f, 0xa080, 0xb45e, 0x2005, 0x6856,
+	0x8211, 0x1f04, 0x2857, 0x002e, 0x00de, 0x000e, 0x0005, 0x00c6,
+	0x2061, 0xb500, 0x6030, 0x0110, 0xc09d, 0x0008, 0xc09c, 0x6032,
+	0x00ce, 0x0005, 0x0156, 0x00d6, 0x0026, 0x0016, 0x0006, 0x2069,
+	0x0140, 0x6980, 0xa116, 0x0180, 0xa112, 0x1230, 0x8212, 0x8210,
+	0x22a8, 0x2001, 0x0402, 0x0018, 0x22a8, 0x2001, 0x0404, 0x680e,
+	0x1f04, 0x2887, 0x680f, 0x0000, 0x000e, 0x001e, 0x002e, 0x00de,
+	0x015e, 0x0005, 0x2001, 0xb553, 0x2004, 0xd0c4, 0x0150, 0xd0a4,
+	0x0140, 0xa006, 0x0046, 0x2020, 0x2009, 0x002e, 0x080c, 0xb0e8,
+	0x004e, 0x0005, 0x00f6, 0x0016, 0x0026, 0x2079, 0x0140, 0x78c4,
+	0xd0dc, 0x0548, 0xa084, 0x0700, 0xa08e, 0x0300, 0x1520, 0x2011,
+	0x0000, 0x2009, 0x0002, 0x2300, 0xa080, 0x0020, 0x2018, 0x2300,
+	0x080c, 0x6b40, 0x2011, 0x0030, 0x2200, 0x8007, 0xa085, 0x004c,
+	0x78c2, 0x2009, 0x0204, 0x210c, 0x2200, 0xa100, 0x2009, 0x0138,
+	0x200a, 0x080c, 0x5acf, 0x1118, 0x2009, 0xb78f, 0x200a, 0x002e,
+	0x001e, 0x00fe, 0x0005, 0x78c3, 0x0000, 0x0cc8, 0x0126, 0x2091,
+	0x2800, 0x0006, 0x0016, 0x0026, 0x2001, 0x0170, 0x200c, 0x8000,
+	0x2014, 0xa184, 0x0003, 0x0110, 0x0804, 0x1b04, 0x002e, 0x001e,
+	0x000e, 0x012e, 0x0005, 0x0006, 0x2001, 0x0100, 0x2004, 0xa082,
+	0x0005, 0x000e, 0x0268, 0x2001, 0x0170, 0x200c, 0xa18c, 0x00ff,
+	0xa18e, 0x004c, 0x1128, 0x200c, 0xa18c, 0xff00, 0x810f, 0x0010,
+	0x2009, 0x0000, 0x2001, 0x0204, 0x2004, 0xa108, 0x0005, 0x0006,
+	0x0156, 0x00f6, 0x2079, 0x0100, 0x20a9, 0x000a, 0x7854, 0xd08c,
+	0x1110, 0x1f04, 0x290e, 0x00fe, 0x015e, 0x000e, 0x0005, 0x0016,
+	0x00c6, 0x0006, 0x2061, 0x0100, 0x6030, 0x0006, 0x6048, 0x0006,
+	0x60e4, 0x0006, 0x60e8, 0x0006, 0x6050, 0x0006, 0x60f0, 0x0006,
+	0x60ec, 0x0006, 0x600c, 0x0006, 0x6004, 0x0006, 0x6028, 0x0006,
+	0x60e0, 0x0006, 0x602f, 0x0100, 0x602f, 0x0000, 0xe000, 0xe000,
+	0xe000, 0xe000, 0x602f, 0x0040, 0x602f, 0x0000, 0x000e, 0x60e2,
+	0x000e, 0x602a, 0x000e, 0x6006, 0x000e, 0x600e, 0x000e, 0x60ee,
+	0x000e, 0x60f2, 0x000e, 0x6052, 0x000e, 0x60ea, 0x000e, 0x60e6,
+	0x000e, 0x604a, 0x000e, 0x6032, 0x6036, 0x2008, 0x080c, 0x2847,
+	0x000e, 0x00ce, 0x001e, 0x0005, 0x2009, 0x0171, 0x2104, 0xd0dc,
+	0x0140, 0x2009, 0x0170, 0x2104, 0x200b, 0x0080, 0xe000, 0xe000,
+	0x200a, 0x0005, 0x29fa, 0x29fe, 0x2a02, 0x2a08, 0x2a0e, 0x2a14,
+	0x2a1a, 0x2a22, 0x2a2a, 0x2a30, 0x2a36, 0x2a3e, 0x2a46, 0x2a4e,
+	0x2a56, 0x2a60, 0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad,
+	0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad,
+	0x2aad, 0x2aad, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad,
+	0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad,
+	0x2aad, 0x2aad, 0x2a6c, 0x2a6c, 0x2a72, 0x2a72, 0x2a79, 0x2a79,
+	0x2a80, 0x2a80, 0x2a89, 0x2a89, 0x2a90, 0x2a90, 0x2a99, 0x2a99,
+	0x2aa2, 0x2aa2, 0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad,
+	0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad,
+	0x2aad, 0x2aad, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad,
+	0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad, 0x2aad,
+	0x2aad, 0x2aad, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a, 0x2a6a,
+	0x2a6a, 0x2a6a, 0x0106, 0x0006, 0x0804, 0x2ab5, 0x0106, 0x0006,
+	0x0804, 0x2ab5, 0x0106, 0x0006, 0x080c, 0x2519, 0x0804, 0x2ab5,
+	0x0106, 0x0006, 0x080c, 0x2519, 0x0804, 0x2ab5, 0x0106, 0x0006,
+	0x080c, 0x239c, 0x0804, 0x2ab5, 0x0106, 0x0006, 0x080c, 0x239c,
+	0x0804, 0x2ab5, 0x0106, 0x0006, 0x080c, 0x2519, 0x080c, 0x239c,
+	0x0804, 0x2ab5, 0x0106, 0x0006, 0x080c, 0x2519, 0x080c, 0x239c,
+	0x0804, 0x2ab5, 0x0106, 0x0006, 0x080c, 0x23f2, 0x0804, 0x2ab5,
+	0x0106, 0x0006, 0x080c, 0x23f2, 0x0804, 0x2ab5, 0x0106, 0x0006,
+	0x080c, 0x2519, 0x080c, 0x23f2, 0x0804, 0x2ab5, 0x0106, 0x0006,
+	0x080c, 0x2519, 0x080c, 0x23f2, 0x0804, 0x2ab5, 0x0106, 0x0006,
+	0x080c, 0x239c, 0x080c, 0x23f2, 0x0804, 0x2ab5, 0x0106, 0x0006,
+	0x080c, 0x239c, 0x080c, 0x23f2, 0x0804, 0x2ab5, 0x0106, 0x0006,
+	0x080c, 0x2519, 0x080c, 0x239c, 0x080c, 0x23f2, 0x0804, 0x2ab5,
+	0x0106, 0x0006, 0x080c, 0x2519, 0x080c, 0x239c, 0x080c, 0x23f2,
+	0x0804, 0x2ab5, 0xe000, 0x0cf0, 0x0106, 0x0006, 0x080c, 0x28d6,
+	0x0804, 0x2ab5, 0x0106, 0x0006, 0x080c, 0x28d6, 0x080c, 0x2519,
+	0x04e0, 0x0106, 0x0006, 0x080c, 0x28d6, 0x080c, 0x239c, 0x04a8,
+	0x0106, 0x0006, 0x080c, 0x28d6, 0x080c, 0x2519, 0x080c, 0x239c,
+	0x0460, 0x0106, 0x0006, 0x080c, 0x28d6, 0x080c, 0x23f2, 0x0428,
+	0x0106, 0x0006, 0x080c, 0x28d6, 0x080c, 0x2519, 0x080c, 0x23f2,
+	0x00e0, 0x0106, 0x0006, 0x080c, 0x28d6, 0x080c, 0x239c, 0x080c,
+	0x23f2, 0x0098, 0x0106, 0x0006, 0x080c, 0x28d6, 0x080c, 0x2519,
+	0x080c, 0x239c, 0x080c, 0x23f2, 0x0040, 0x20d1, 0x0000, 0x20d1,
+	0x0001, 0x20d1, 0x0000, 0x080c, 0x1515, 0x000e, 0x010e, 0x000d,
+	0x00c6, 0x0026, 0x0046, 0x2021, 0x0000, 0x080c, 0x5309, 0x1904,
+	0x2b95, 0x72d4, 0x2001, 0xb79e, 0x2004, 0xa005, 0x1110, 0xd29c,
+	0x0148, 0xd284, 0x1138, 0xd2bc, 0x1904, 0x2b95, 0x080c, 0x2b99,
+	0x0804, 0x2b95, 0xd2cc, 0x1904, 0x2b95, 0x080c, 0x5acf, 0x1120,
+	0x709f, 0xffff, 0x0804, 0x2b95, 0xd294, 0x0120, 0x709f, 0xffff,
+	0x0804, 0x2b95, 0x2001, 0xb515, 0x203c, 0x7288, 0xd284, 0x0904,
+	0x2b37, 0xd28c, 0x1904, 0x2b37, 0x0036, 0x739c, 0xa38e, 0xffff,
+	0x1110, 0x2019, 0x0001, 0x8314, 0xa2e0, 0xbcc0, 0x2c04, 0xa38c,
+	0x0001, 0x0120, 0xa084, 0xff00, 0x8007, 0x0010, 0xa084, 0x00ff,
+	0xa70e, 0x0560, 0xa08e, 0x0000, 0x0548, 0xa08e, 0x00ff, 0x1150,
+	0x7230, 0xd284, 0x1538, 0x7288, 0xc28d, 0x728a, 0x709f, 0xffff,
+	0x003e, 0x0428, 0x2009, 0x0000, 0x080c, 0x281d, 0x080c, 0x4f4d,
+	0x11b8, 0x6004, 0xa084, 0x00ff, 0xa086, 0x0006, 0x1150, 0x7030,
+	0xd08c, 0x0118, 0x6000, 0xd0bc, 0x0120, 0x080c, 0x2bac, 0x0140,
+	0x0028, 0x080c, 0x2cdd, 0x080c, 0x2bda, 0x0110, 0x8318, 0x0818,
+	0x739e, 0x0010, 0x709f, 0xffff, 0x003e, 0x0804, 0x2b95, 0xa780,
+	0x2dc4, 0x203d, 0xa7bc, 0xff00, 0x873f, 0x2041, 0x007e, 0x709c,
+	0xa096, 0xffff, 0x1120, 0x2009, 0x0000, 0x28a8, 0x0050, 0xa812,
+	0x0220, 0x2008, 0xa802, 0x20a8, 0x0020, 0x709f, 0xffff, 0x0804,
+	0x2b95, 0x2700, 0x0156, 0x0016, 0xa106, 0x05a0, 0xc484, 0x080c,
+	0x4fa9, 0x0120, 0x080c, 0x4f4d, 0x15a8, 0x0008, 0xc485, 0x6004,
+	0xa084, 0x00ff, 0xa086, 0x0006, 0x1130, 0x7030, 0xd08c, 0x01e8,
+	0x6000, 0xd0bc, 0x11d0, 0x7288, 0xd28c, 0x0188, 0x6004, 0xa084,
+	0x00ff, 0xa082, 0x0006, 0x02b0, 0xd484, 0x1118, 0x080c, 0x4f6c,
+	0x0028, 0x080c, 0x2d6a, 0x0170, 0x080c, 0x2d97, 0x0058, 0x080c,
+	0x2cdd, 0x080c, 0x2bda, 0x0170, 0x0028, 0x080c, 0x2d6a, 0x0110,
+	0x0419, 0x0140, 0x001e, 0x8108, 0x015e, 0x1f04, 0x2b51, 0x709f,
+	0xffff, 0x0018, 0x001e, 0x015e, 0x719e, 0x004e, 0x002e, 0x00ce,
+	0x0005, 0x00c6, 0x0016, 0x709f, 0x0001, 0x2009, 0x007e, 0x080c,
+	0x4f4d, 0x1138, 0x080c, 0x2cdd, 0x04a9, 0x0118, 0x70d4, 0xc0bd,
+	0x70d6, 0x001e, 0x00ce, 0x0005, 0x0016, 0x0076, 0x00d6, 0x00c6,
+	0x2c68, 0x2001, 0xb557, 0x2004, 0xa084, 0x00ff, 0x6842, 0x080c,
+	0x9ed6, 0x01d8, 0x2d00, 0x601a, 0x080c, 0xa027, 0x601f, 0x0001,
+	0x2001, 0x0000, 0x080c, 0x4eeb, 0x2001, 0x0000, 0x080c, 0x4efd,
+	0x0126, 0x2091, 0x8000, 0x7098, 0x8000, 0x709a, 0x012e, 0x2009,
+	0x0004, 0x080c, 0x864c, 0xa085, 0x0001, 0x00ce, 0x00de, 0x007e,
+	0x001e, 0x0005, 0x0016, 0x0076, 0x00d6, 0x00c6, 0x2c68, 0x2001,
+	0xb557, 0x2004, 0xa084, 0x00ff, 0x6842, 0x080c, 0x9ed6, 0x0550,
+	0x2d00, 0x601a, 0x6800, 0xc0c4, 0x6802, 0x68a0, 0xa086, 0x007e,
+	0x0140, 0x6804, 0xa084, 0x00ff, 0xa086, 0x0006, 0x1110, 0x080c,
+	0x2c9c, 0x080c, 0xa027, 0x601f, 0x0001, 0x2001, 0x0000, 0x080c,
+	0x4eeb, 0x2001, 0x0002, 0x080c, 0x4efd, 0x0126, 0x2091, 0x8000,
+	0x7098, 0x8000, 0x709a, 0x012e, 0x2009, 0x0002, 0x080c, 0x864c,
+	0xa085, 0x0001, 0x00ce, 0x00de, 0x007e, 0x001e, 0x0005, 0x00c6,
+	0x0026, 0x2009, 0x0080, 0x080c, 0x4f4d, 0x1120, 0x0031, 0x0110,
+	0x70db, 0xffff, 0x002e, 0x00ce, 0x0005, 0x0016, 0x0076, 0x00d6,
+	0x00c6, 0x2c68, 0x080c, 0x85c7, 0x01e8, 0x2d00, 0x601a, 0x080c,
+	0xa027, 0x601f, 0x0001, 0x2001, 0x0000, 0x080c, 0x4eeb, 0x2001,
+	0x0002, 0x080c, 0x4efd, 0x0126, 0x2091, 0x8000, 0x080c, 0x2c9c,
+	0x70dc, 0x8000, 0x70de, 0x012e, 0x2009, 0x0002, 0x080c, 0x864c,
+	0xa085, 0x0001, 0x00ce, 0x00de, 0x007e, 0x001e, 0x0005, 0x00c6,
+	0x00d6, 0x0126, 0x2091, 0x8000, 0x2009, 0x007f, 0x080c, 0x4f4d,
+	0x1190, 0x2c68, 0x080c, 0x85c7, 0x0170, 0x2d00, 0x601a, 0x6312,
+	0x601f, 0x0001, 0x620a, 0x080c, 0xa027, 0x2009, 0x0022, 0x080c,
+	0x864c, 0xa085, 0x0001, 0x012e, 0x00de, 0x00ce, 0x0005, 0x00e6,
+	0x00c6, 0x0066, 0x0036, 0x0026, 0x080c, 0x6e01, 0x080c, 0x6da4,
+	0x080c, 0x906f, 0x2130, 0x81ff, 0x0128, 0x20a9, 0x007e, 0x2009,
+	0x0000, 0x0020, 0x20a9, 0x007f, 0x2009, 0x0000, 0x0016, 0x080c,
+	0x4fa9, 0x1120, 0x080c, 0x51aa, 0x080c, 0x4c0b, 0x001e, 0x8108,
+	0x1f04, 0x2c86, 0x86ff, 0x1110, 0x080c, 0x11f0, 0x002e, 0x003e,
+	0x006e, 0x00ce, 0x00ee, 0x0005, 0x00e6, 0x00c6, 0x0036, 0x0026,
+	0x0016, 0x6218, 0x2270, 0x72a0, 0x0026, 0x2019, 0x0029, 0x080c,
+	0x6df5, 0x0076, 0x2039, 0x0000, 0x080c, 0x6d02, 0x2c08, 0x080c,
+	0xae82, 0x007e, 0x001e, 0x2e60, 0x080c, 0x51aa, 0x6210, 0x6314,
+	0x080c, 0x4c0b, 0x6212, 0x6316, 0x001e, 0x002e, 0x003e, 0x00ce,
+	0x00ee, 0x0005, 0x00e6, 0x0006, 0x6018, 0xa080, 0x0028, 0x2004,
+	0xa086, 0x0080, 0x0150, 0x2071, 0xb500, 0x7098, 0xa005, 0x0110,
+	0x8001, 0x709a, 0x000e, 0x00ee, 0x0005, 0x2071, 0xb500, 0x70dc,
+	0xa005, 0x0dc0, 0x8001, 0x70de, 0x0ca8, 0x6000, 0xc08c, 0x6002,
+	0x0005, 0x00f6, 0x00e6, 0x00c6, 0x0036, 0x0026, 0x0016, 0x0156,
+	0x2178, 0x81ff, 0x1118, 0x20a9, 0x0001, 0x0098, 0x2001, 0xb553,
+	0x2004, 0xd0c4, 0x0150, 0xd0a4, 0x0140, 0xa006, 0x0046, 0x2020,
+	0x2009, 0x002d, 0x080c, 0xb0e8, 0x004e, 0x20a9, 0x00ff, 0x2011,
+	0x0000, 0x0026, 0xa28e, 0x007e, 0x0904, 0x2d49, 0xa28e, 0x007f,
+	0x0904, 0x2d49, 0xa28e, 0x0080, 0x05e0, 0xa288, 0xb635, 0x210c,
+	0x81ff, 0x05b8, 0x8fff, 0x1148, 0x2001, 0xb7be, 0x0006, 0x2003,
+	0x0001, 0x04d9, 0x000e, 0x2003, 0x0000, 0x00c6, 0x2160, 0x2001,
+	0x0001, 0x080c, 0x5313, 0x00ce, 0x2019, 0x0029, 0x080c, 0x6df5,
+	0x0076, 0x2039, 0x0000, 0x080c, 0x6d02, 0x00c6, 0x0026, 0x2160,
+	0x6204, 0xa294, 0x00ff, 0xa286, 0x0006, 0x1118, 0x6007, 0x0404,
+	0x0028, 0x2001, 0x0004, 0x8007, 0xa215, 0x6206, 0x002e, 0x00ce,
+	0x0016, 0x2c08, 0x080c, 0xae82, 0x001e, 0x007e, 0x2160, 0x080c,
+	0x51aa, 0x002e, 0x8210, 0x1f04, 0x2d01, 0x015e, 0x001e, 0x002e,
+	0x003e, 0x00ce, 0x00ee, 0x00fe, 0x0005, 0x0046, 0x0026, 0x0016,
+	0x2001, 0xb553, 0x2004, 0xd0c4, 0x0148, 0xd0a4, 0x0138, 0xa006,
+	0x2220, 0x8427, 0x2009, 0x0029, 0x080c, 0xb0e8, 0x001e, 0x002e,
+	0x004e, 0x0005, 0x0016, 0x0026, 0x0036, 0x00c6, 0x7288, 0x82ff,
+	0x01f8, 0x2011, 0xb553, 0x2214, 0xd2ac, 0x11d0, 0x2100, 0x080c,
+	0x2831, 0x81ff, 0x01b8, 0x2019, 0x0001, 0x8314, 0xa2e0, 0xbcc0,
+	0x2c04, 0xd384, 0x0120, 0xa084, 0xff00, 0x8007, 0x0010, 0xa084,
+	0x00ff, 0xa116, 0x0138, 0xa096, 0x00ff, 0x0110, 0x8318, 0x0c68,
+	0xa085, 0x0001, 0x00ce, 0x003e, 0x002e, 0x001e, 0x0005, 0x0016,
+	0x00c6, 0x0126, 0x2091, 0x8000, 0x0016, 0x0026, 0x0036, 0x2110,
+	0x0026, 0x2019, 0x0029, 0x080c, 0x8299, 0x002e, 0x080c, 0xb38d,
+	0x003e, 0x002e, 0x001e, 0xa180, 0xb635, 0x2004, 0xa065, 0x0158,
+	0x0016, 0x00c6, 0x2061, 0xb8f4, 0x001e, 0x611a, 0x080c, 0x2c9c,
+	0x001e, 0x080c, 0x4f6c, 0x012e, 0x00ce, 0x001e, 0x0005, 0x2001,
+	0xb535, 0x2004, 0xd0cc, 0x0005, 0x7eef, 0x7de8, 0x7ce4, 0x80e2,
+	0x7be1, 0x80e0, 0x80dc, 0x80da, 0x7ad9, 0x80d6, 0x80d5, 0x80d4,
+	0x80d3, 0x80d2, 0x80d1, 0x79ce, 0x78cd, 0x80cc, 0x80cb, 0x80ca,
+	0x80c9, 0x80c7, 0x80c6, 0x77c5, 0x76c3, 0x80bc, 0x80ba, 0x75b9,
+	0x80b6, 0x74b5, 0x73b4, 0x72b3, 0x80b2, 0x80b1, 0x80ae, 0x71ad,
+	0x80ac, 0x70ab, 0x6faa, 0x6ea9, 0x80a7, 0x6da6, 0x6ca5, 0x6ba3,
+	0x6a9f, 0x699e, 0x689d, 0x809b, 0x8098, 0x6797, 0x6690, 0x658f,
+	0x6488, 0x6384, 0x6282, 0x8081, 0x8080, 0x617c, 0x607a, 0x8079,
+	0x5f76, 0x8075, 0x8074, 0x8073, 0x8072, 0x8071, 0x806e, 0x5e6d,
+	0x806c, 0x5d6b, 0x5c6a, 0x5b69, 0x8067, 0x5a66, 0x5965, 0x5863,
+	0x575c, 0x565a, 0x5559, 0x8056, 0x8055, 0x5454, 0x5353, 0x5252,
+	0x5151, 0x504e, 0x4f4d, 0x804c, 0x804b, 0x4e4a, 0x4d49, 0x8047,
+	0x4c46, 0x8045, 0x8043, 0x803c, 0x803a, 0x8039, 0x8036, 0x4b35,
+	0x8034, 0x4a33, 0x4932, 0x4831, 0x802e, 0x472d, 0x462c, 0x452b,
+	0x442a, 0x4329, 0x4227, 0x8026, 0x8025, 0x4123, 0x401f, 0x3f1e,
+	0x3e1d, 0x3d1b, 0x3c18, 0x8017, 0x8010, 0x3b0f, 0x3a08, 0x8004,
+	0x3902, 0x8001, 0x8000, 0x8000, 0x3800, 0x3700, 0x3600, 0x8000,
+	0x3500, 0x8000, 0x8000, 0x8000, 0x3400, 0x8000, 0x8000, 0x8000,
+	0x8000, 0x8000, 0x8000, 0x3300, 0x3200, 0x8000, 0x8000, 0x8000,
+	0x8000, 0x8000, 0x8000, 0x3100, 0x3000, 0x8000, 0x8000, 0x2f00,
+	0x8000, 0x2e00, 0x2d00, 0x2c00, 0x8000, 0x8000, 0x8000, 0x2b00,
+	0x8000, 0x2a00, 0x2900, 0x2800, 0x8000, 0x2700, 0x2600, 0x2500,
+	0x2400, 0x2300, 0x2200, 0x8000, 0x8000, 0x2100, 0x2000, 0x1f00,
+	0x1e00, 0x1d00, 0x1c00, 0x8000, 0x8000, 0x1b00, 0x1a00, 0x8000,
+	0x1900, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x1800,
+	0x8000, 0x1700, 0x1600, 0x1500, 0x8000, 0x1400, 0x1300, 0x1200,
+	0x1100, 0x1000, 0x0f00, 0x8000, 0x8000, 0x0e00, 0x0d00, 0x0c00,
+	0x0b00, 0x0a00, 0x0900, 0x8000, 0x8000, 0x0800, 0x0700, 0x8000,
+	0x0600, 0x8000, 0x8000, 0x8000, 0x0500, 0x0400, 0x0300, 0x8000,
+	0x0200, 0x8000, 0x8000, 0x8000, 0x0100, 0x8000, 0x8000, 0x8000,
+	0x8000, 0x8000, 0x8000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000,
+	0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
+	0x8000, 0x8000, 0x8000, 0x8000, 0x2071, 0xb582, 0x7003, 0x0002,
+	0xa006, 0x7012, 0x7016, 0x703a, 0x703e, 0x7033, 0xb592, 0x7037,
+	0xb592, 0x7007, 0x0001, 0x2061, 0xb5d2, 0x6003, 0x0002, 0x0005,
+	0x1004, 0x2eea, 0x0e04, 0x2eea, 0x2071, 0xb582, 0x2b78, 0x7818,
+	0xd084, 0x1140, 0x2a60, 0x7820, 0xa08e, 0x0069, 0x1904, 0x2fcf,
+	0x0804, 0x2f68, 0x0005, 0x2071, 0xb582, 0x7004, 0x0002, 0x2ef3,
+	0x2ef4, 0x2efd, 0x2f0e, 0x0005, 0x1004, 0x2efc, 0x0e04, 0x2efc,
+	0x2b78, 0x7818, 0xd084, 0x01e8, 0x0005, 0x2b78, 0x2061, 0xb5d2,
+	0x6008, 0xa08e, 0x0100, 0x0128, 0xa086, 0x0200, 0x0904, 0x2fc9,
+	0x0005, 0x7014, 0x2068, 0x2a60, 0x7018, 0x0807, 0x7010, 0x2068,
+	0x6834, 0xa086, 0x0103, 0x0108, 0x0005, 0x2a60, 0x2b78, 0x7018,
+	0x0807, 0x2a60, 0x7820, 0xa08a, 0x0040, 0x1210, 0x61c4, 0x0042,
+	0x2100, 0xa08a, 0x003f, 0x1a04, 0x2fc6, 0x61c4, 0x0804, 0x2f68,
+	0x2faa, 0x2fd5, 0x2fdd, 0x2fe1, 0x2fe9, 0x2fef, 0x2ff3, 0x2fff,
+	0x3002, 0x300c, 0x300f, 0x2fc6, 0x2fc6, 0x2fc6, 0x3012, 0x2fc6,
+	0x3021, 0x3038, 0x304f, 0x30c9, 0x30ce, 0x30f7, 0x3148, 0x3159,
+	0x3178, 0x31b0, 0x31ba, 0x31c7, 0x31da, 0x31fb, 0x3204, 0x323a,
+	0x3240, 0x2fc6, 0x3269, 0x2fc6, 0x2fc6, 0x2fc6, 0x2fc6, 0x2fc6,
+	0x3270, 0x327a, 0x2fc6, 0x2fc6, 0x2fc6, 0x2fc6, 0x2fc6, 0x2fc6,
+	0x2fc6, 0x2fc6, 0x3282, 0x2fc6, 0x2fc6, 0x2fc6, 0x2fc6, 0x2fc6,
+	0x3294, 0x329e, 0x2fc6, 0x2fc6, 0x2fc6, 0x2fc6, 0x2fc6, 0x2fc6,
+	0x0002, 0x32c8, 0x331c, 0x3377, 0x3391, 0x2fc6, 0x33c2, 0x37f5,
+	0x4233, 0x2fc6, 0x2fc6, 0x2fc6, 0x2fc6, 0x2fc6, 0x2fc6, 0x2fc6,
+	0x2fc6, 0x300c, 0x300f, 0x37f7, 0x2fc6, 0x3804, 0x42cc, 0x4327,
+	0x438b, 0x2fc6, 0x43ee, 0x4418, 0x4437, 0x4469, 0x2fc6, 0x2fc6,
+	0x2fc6, 0x3808, 0x39ad, 0x39c7, 0x39e5, 0x3a46, 0x3aa6, 0x3ab1,
+	0x3ae9, 0x3af8, 0x3b07, 0x3b0a, 0x3b2d, 0x3b79, 0x3bef, 0x3bfc,
+	0x3cfd, 0x3e23, 0x3e4c, 0x3f4a, 0x3f6c, 0x3f78, 0x3fb1, 0x4075,
+	0x2fc6, 0x2fc6, 0x2fc6, 0x2fc6, 0x40dd, 0x40f8, 0x416a, 0x421c,
+	0x713c, 0x0000, 0x2021, 0x4000, 0x080c, 0x3ea9, 0x0126, 0x2091,
+	0x8000, 0x0e04, 0x2fb6, 0x7818, 0xd084, 0x0110, 0x012e, 0x0cb0,
+	0x7c22, 0x7926, 0x7a2a, 0x7b2e, 0x781b, 0x0001, 0x2091, 0x4080,
+	0x7007, 0x0001, 0x2091, 0x5000, 0x012e, 0x0005, 0x2021, 0x4001,
+	0x0c18, 0x2021, 0x4002, 0x0c00, 0x2021, 0x4003, 0x08e8, 0x2021,
+	0x4005, 0x08d0, 0x2021, 0x4006, 0x08b8, 0xa02e, 0x2520, 0x7b28,
+	0x7a2c, 0x7824, 0x7930, 0x0804, 0x3eb6, 0x7823, 0x0004, 0x7824,
+	0x0807, 0xa02e, 0x2520, 0x7b28, 0x7a2c, 0x7824, 0x7930, 0x0804,
+	0x3eb9, 0x7924, 0x7828, 0x2114, 0x200a, 0x0804, 0x2faa, 0x7924,
+	0x2114, 0x0804, 0x2faa, 0x2099, 0x0009, 0x20a1, 0x0009, 0x20a9,
+	0x0007, 0x53a3, 0x7924, 0x7a28, 0x7b2c, 0x0804, 0x2faa, 0x7824,
+	0x2060, 0x0090, 0x2009, 0x0002, 0x2011, 0x0002, 0x2019, 0x0006,
+	0x783b, 0x0017, 0x0804, 0x2faa, 0x7d38, 0x7c3c, 0x0840, 0x7d38,
+	0x7c3c, 0x0888, 0x2061, 0x1000, 0xe10c, 0xa006, 0x2c15, 0xa200,
+	0x8c60, 0x8109, 0x1dd8, 0x2010, 0xa005, 0x0904, 0x2faa, 0x0804,
+	0x2fcc, 0x2069, 0xb552, 0x7824, 0x7930, 0xa11a, 0x1a04, 0x2fd2,
+	0x8019, 0x0904, 0x2fd2, 0x684a, 0x6942, 0x782c, 0x6852, 0x7828,
+	0x6856, 0xa006, 0x685a, 0x685e, 0x080c, 0x5da5, 0x0804, 0x2faa,
+	0x2069, 0xb552, 0x7824, 0x7934, 0xa11a, 0x1a04, 0x2fd2, 0x8019,
+	0x0904, 0x2fd2, 0x684e, 0x6946, 0x782c, 0x6862, 0x7828, 0x6866,
+	0xa006, 0x686a, 0x686e, 0x080c, 0x53d5, 0x0804, 0x2faa, 0xa02e,
+	0x2520, 0x81ff, 0x1904, 0x2fcf, 0x7924, 0x7b28, 0x7a2c, 0x20a9,
+	0x0005, 0x20a1, 0xb589, 0x41a1, 0x080c, 0x3e75, 0x0904, 0x2fcf,
+	0x2009, 0x0020, 0x080c, 0x3eb6, 0x701b, 0x3067, 0x0005, 0x6834,
+	0x2008, 0xa084, 0x00ff, 0xa096, 0x0011, 0x0138, 0xa096, 0x0019,
+	0x0120, 0xa096, 0x0015, 0x1904, 0x2fcf, 0x810f, 0xa18c, 0x00ff,
+	0x0904, 0x2fcf, 0x710e, 0x700c, 0x8001, 0x0528, 0x700e, 0x080c,
+	0x3e75, 0x0904, 0x2fcf, 0x2009, 0x0020, 0x2061, 0xb5d2, 0x6224,
+	0x6328, 0x642c, 0x6530, 0xa290, 0x0040, 0xa399, 0x0000, 0xa4a1,
+	0x0000, 0xa5a9, 0x0000, 0x080c, 0x3eb6, 0x701b, 0x3098, 0x0005,
+	0x6834, 0xa084, 0x00ff, 0xa096, 0x0002, 0x0120, 0xa096, 0x000a,
+	0x1904, 0x2fcf, 0x08c0, 0x7010, 0x2068, 0x6838, 0xc0fd, 0x683a,
+	0x080c, 0x4e49, 0x1128, 0x7007, 0x0003, 0x701b, 0x30b2, 0x0005,
+	0x080c, 0x54db, 0x0126, 0x2091, 0x8000, 0x20a9, 0x0005, 0x2099,
+	0xb589, 0x530a, 0x2100, 0xa210, 0xa399, 0x0000, 0xa4a1, 0x0000,
+	0xa5a9, 0x0000, 0xad80, 0x000d, 0x2009, 0x0020, 0x012e, 0x0804,
+	0x3eb9, 0x61ac, 0x7824, 0x60ae, 0x0804, 0x2faa, 0x2091, 0x8000,
+	0x7823, 0x4000, 0x7827, 0x4953, 0x782b, 0x5020, 0x782f, 0x2020,
+	0x2009, 0x017f, 0x2104, 0x7832, 0x3f00, 0x7836, 0x2061, 0x0100,
+	0x6200, 0x2061, 0x0200, 0x603c, 0x8007, 0xa205, 0x783a, 0x2009,
+	0x04fd, 0x2104, 0x783e, 0x781b, 0x0001, 0x2091, 0x5000, 0x2091,
+	0x4080, 0x2071, 0x0010, 0x20c1, 0x00f0, 0x0804, 0x0427, 0x81ff,
+	0x1904, 0x2fcf, 0x7924, 0x810f, 0xa18c, 0x00ff, 0x080c, 0x4fa9,
+	0x1904, 0x2fd2, 0x7e38, 0xa684, 0x3fff, 0xa082, 0x4000, 0x0210,
+	0x0804, 0x2fd2, 0x7c28, 0x7d2c, 0x080c, 0x5171, 0xd28c, 0x1118,
+	0x080c, 0x511a, 0x0010, 0x080c, 0x514a, 0x1518, 0x2061, 0xbd00,
+	0x0126, 0x2091, 0x8000, 0x6000, 0xa086, 0x0000, 0x0148, 0x6010,
+	0xa06d, 0x0130, 0x683c, 0xa406, 0x1118, 0x6840, 0xa506, 0x0150,
+	0x012e, 0xace0, 0x0018, 0x2001, 0xb517, 0x2004, 0xac02, 0x1a04,
+	0x2fcf, 0x0c30, 0x080c, 0x992a, 0x012e, 0x0904, 0x2fcf, 0x0804,
+	0x2faa, 0xa00e, 0x2001, 0x0005, 0x080c, 0x54db, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x9ed2, 0x080c, 0x5408, 0x012e, 0x0804, 0x2faa,
+	0x81ff, 0x1904, 0x2fcf, 0x080c, 0x3e8a, 0x0904, 0x2fd2, 0x080c,
+	0x506f, 0x0904, 0x2fcf, 0x080c, 0x517d, 0x0904, 0x2fcf, 0x0804,
+	0x2faa, 0x81ff, 0x1904, 0x2fcf, 0x080c, 0x3e9a, 0x0904, 0x2fd2,
+	0x080c, 0x51e9, 0x0904, 0x2fcf, 0x2019, 0x0005, 0x7924, 0x080c,
+	0x5198, 0x0904, 0x2fcf, 0x7828, 0xa08a, 0x1000, 0x1a04, 0x2fd2,
+	0x8003, 0x800b, 0x810b, 0xa108, 0x080c, 0x69a8, 0x0804, 0x2faa,
+	0x0126, 0x2091, 0x8000, 0x81ff, 0x0118, 0x2009, 0x0001, 0x0450,
+	0x2029, 0x00ff, 0x6450, 0x2400, 0xa506, 0x01f8, 0x2508, 0x080c,
+	0x4fa9, 0x11d8, 0x080c, 0x51e9, 0x1128, 0x2009, 0x0002, 0x62b4,
+	0x2518, 0x00c0, 0x2019, 0x0004, 0xa00e, 0x080c, 0x5198, 0x1118,
+	0x2009, 0x0006, 0x0078, 0x7824, 0xa08a, 0x1000, 0x1270, 0x8003,
+	0x800b, 0x810b, 0xa108, 0x080c, 0x69a8, 0x8529, 0x1ae0, 0x012e,
+	0x0804, 0x2faa, 0x012e, 0x0804, 0x2fcf, 0x012e, 0x0804, 0x2fd2,
+	0x080c, 0x3e8a, 0x0904, 0x2fd2, 0x080c, 0x50d5, 0x080c, 0x5171,
+	0x0804, 0x2faa, 0x81ff, 0x1904, 0x2fcf, 0x080c, 0x3e8a, 0x0904,
+	0x2fd2, 0x080c, 0x50c6, 0x080c, 0x5171, 0x0804, 0x2faa, 0x81ff,
+	0x1904, 0x2fcf, 0x080c, 0x3e8a, 0x0904, 0x2fd2, 0x080c, 0x514c,
+	0x0904, 0x2fcf, 0x080c, 0x4e8d, 0x080c, 0x5113, 0x080c, 0x5171,
+	0x0804, 0x2faa, 0x080c, 0x3e8a, 0x0904, 0x2fd2, 0x080c, 0x506f,
+	0x0904, 0x2fcf, 0x62a0, 0x2019, 0x0005, 0x00c6, 0x080c, 0x51aa,
+	0x2061, 0x0000, 0x080c, 0x6df5, 0x0076, 0x2039, 0x0000, 0x080c,
+	0x6d02, 0x2009, 0x0000, 0x080c, 0xae82, 0x007e, 0x00ce, 0x080c,
+	0x5171, 0x0804, 0x2faa, 0x080c, 0x3e8a, 0x0904, 0x2fd2, 0x080c,
+	0x5171, 0x2208, 0x0804, 0x2faa, 0x0156, 0x00d6, 0x00e6, 0x2069,
+	0xb614, 0x6810, 0x6914, 0xa10a, 0x1210, 0x2009, 0x0000, 0x6816,
+	0x2011, 0x0000, 0x2019, 0x0000, 0x20a9, 0x007e, 0x2069, 0xb635,
+	0x2d04, 0xa075, 0x0130, 0x704c, 0x0071, 0xa210, 0x7080, 0x0059,
+	0xa318, 0x8d68, 0x1f04, 0x3218, 0x2300, 0xa218, 0x00ee, 0x00de,
+	0x015e, 0x0804, 0x2faa, 0x00f6, 0x0016, 0xa07d, 0x0140, 0x2001,
+	0x0000, 0x8000, 0x2f0c, 0x81ff, 0x0110, 0x2178, 0x0cd0, 0x001e,
+	0x00fe, 0x0005, 0x2069, 0xb614, 0x6910, 0x62b0, 0x0804, 0x2faa,
+	0x81ff, 0x1904, 0x2fcf, 0x6150, 0xa190, 0x2dc4, 0x2215, 0xa294,
+	0x00ff, 0x6370, 0x83ff, 0x0108, 0x6274, 0x67d4, 0xd79c, 0x0118,
+	0x2031, 0x0001, 0x0090, 0xd7ac, 0x0118, 0x2031, 0x0003, 0x0068,
+	0xd7a4, 0x0118, 0x2031, 0x0002, 0x0040, 0x080c, 0x5acf, 0x1118,
+	0x2031, 0x0004, 0x0010, 0x2031, 0x0000, 0x7e3a, 0x7f3e, 0x0804,
+	0x2faa, 0x6140, 0x6244, 0x2019, 0xb7b6, 0x231c, 0x0804, 0x2faa,
+	0x0126, 0x2091, 0x8000, 0x6134, 0xa006, 0x2010, 0x6338, 0x012e,
+	0x0804, 0x2faa, 0x080c, 0x3e9a, 0x0904, 0x2fd2, 0x6244, 0x6338,
+	0x0804, 0x2faa, 0x6140, 0x6244, 0x7824, 0x6042, 0x7b28, 0x6346,
+	0x2069, 0xb552, 0x831f, 0xa305, 0x6816, 0x782c, 0x2069, 0xb7b6,
+	0x2d1c, 0x206a, 0x0804, 0x2faa, 0x0126, 0x2091, 0x8000, 0x7824,
+	0x6036, 0x782c, 0x603a, 0x012e, 0x0804, 0x2faa, 0x7838, 0xa005,
+	0x01a8, 0x7828, 0xa025, 0x0904, 0x2fd2, 0x782c, 0xa02d, 0x0904,
+	0x2fd2, 0xa00e, 0x080c, 0x4fa9, 0x1120, 0x6244, 0x6338, 0x6446,
+	0x653a, 0xa186, 0x00ff, 0x0190, 0x8108, 0x0ca0, 0x080c, 0x3e9a,
+	0x0904, 0x2fd2, 0x7828, 0xa00d, 0x0904, 0x2fd2, 0x782c, 0xa005,
+	0x0904, 0x2fd2, 0x6244, 0x6146, 0x6338, 0x603a, 0x0804, 0x2faa,
+	0x2001, 0xb500, 0x2004, 0xa086, 0x0003, 0x1904, 0x2fcf, 0x00c6,
+	0x2061, 0x0100, 0x7924, 0x810f, 0xa18c, 0x00ff, 0xa196, 0x00ff,
+	0x1130, 0x2001, 0xb515, 0x2004, 0xa085, 0xff00, 0x0078, 0xa182,
+	0x007f, 0x16a0, 0xa188, 0x2dc4, 0x210d, 0xa18c, 0x00ff, 0x2001,
+	0xb515, 0x2004, 0xa116, 0x0550, 0x810f, 0xa105, 0x0126, 0x2091,
+	0x8000, 0x0006, 0x080c, 0x85c7, 0x000e, 0x01e0, 0x601a, 0x600b,
+	0xbc09, 0x601f, 0x0001, 0x080c, 0x3e75, 0x01d8, 0x6837, 0x0000,
+	0x7007, 0x0003, 0x6833, 0x0000, 0x6838, 0xc0fd, 0x683a, 0x701b,
+	0x3370, 0x2d00, 0x6012, 0x2009, 0x0032, 0x080c, 0x864c, 0x012e,
+	0x00ce, 0x0005, 0x012e, 0x00ce, 0x0804, 0x2fcf, 0x00ce, 0x0804,
+	0x2fd2, 0x080c, 0x861d, 0x0cb0, 0x2001, 0xb500, 0x2004, 0xa086,
+	0x0003, 0x1904, 0x2fcf, 0x00c6, 0x2061, 0x0100, 0x7924, 0x810f,
+	0xa18c, 0x00ff, 0xa196, 0x00ff, 0x1130, 0x2001, 0xb515, 0x2004,
+	0xa085, 0xff00, 0x0078, 0xa182, 0x007f, 0x16a0, 0xa188, 0x2dc4,
+	0x210d, 0xa18c, 0x00ff, 0x2001, 0xb515, 0x2004, 0xa116, 0x0550,
+	0x810f, 0xa105, 0x0126, 0x2091, 0x8000, 0x0006, 0x080c, 0x85c7,
+	0x000e, 0x01e0, 0x601a, 0x600b, 0xbc05, 0x601f, 0x0001, 0x080c,
+	0x3e75, 0x01d8, 0x6837, 0x0000, 0x7007, 0x0003, 0x6833, 0x0000,
+	0x6838, 0xc0fd, 0x683a, 0x701b, 0x3370, 0x2d00, 0x6012, 0x2009,
+	0x0032, 0x080c, 0x864c, 0x012e, 0x00ce, 0x0005, 0x012e, 0x00ce,
+	0x0804, 0x2fcf, 0x00ce, 0x0804, 0x2fd2, 0x080c, 0x861d, 0x0cb0,
+	0x6830, 0xa086, 0x0100, 0x0904, 0x2fcf, 0x0804, 0x2faa, 0x2061,
+	0xb874, 0x0126, 0x2091, 0x8000, 0x6000, 0xd084, 0x0178, 0x6104,
+	0x6208, 0x2a60, 0x6068, 0x783a, 0x60b4, 0x783e, 0x60b0, 0x2019,
+	0x0072, 0x201a, 0x6348, 0x012e, 0x0804, 0x2faa, 0xa00e, 0x2110,
+	0x0c80, 0x81ff, 0x1904, 0x2fcf, 0x080c, 0x5acf, 0x0904, 0x2fcf,
+	0x0126, 0x2091, 0x8000, 0x6248, 0x6068, 0xa202, 0x0248, 0xa085,
+	0x0001, 0x080c, 0x2867, 0x080c, 0x462c, 0x012e, 0x0804, 0x2faa,
+	0x012e, 0x0804, 0x2fd2, 0x0006, 0x0016, 0x00c6, 0x00e6, 0x2001,
+	0xb7bf, 0x2070, 0x2061, 0xb552, 0x6008, 0x2072, 0x2009, 0x0000,
+	0x2011, 0x1000, 0x080c, 0x6b40, 0x7206, 0x00ee, 0x00ce, 0x001e,
+	0x000e, 0x0005, 0x0126, 0x2091, 0x8000, 0x7824, 0xa084, 0x0007,
+	0x0002, 0x33d4, 0x33dd, 0x33e4, 0x33d1, 0x33d1, 0x33d1, 0x33d1,
+	0x33d1, 0x012e, 0x0804, 0x2fd2, 0x2009, 0x0114, 0x2104, 0xa085,
+	0x0800, 0x200a, 0x080c, 0x354f, 0x0070, 0x2009, 0x010b, 0x200b,
+	0x0010, 0x080c, 0x354f, 0x0038, 0x81ff, 0x0128, 0x012e, 0x2021,
+	0x400b, 0x0804, 0x2fac, 0x0086, 0x0096, 0x00a6, 0x00b6, 0x00c6,
+	0x00d6, 0x00e6, 0x00f6, 0x080c, 0x33ab, 0x2009, 0x0101, 0x210c,
+	0x0016, 0x2001, 0x0138, 0x200c, 0x2003, 0x0001, 0x0016, 0x2001,
+	0x007a, 0x2034, 0x2001, 0x007b, 0x202c, 0xa006, 0x2048, 0x2050,
+	0x2058, 0x080c, 0x379a, 0x080c, 0x36fe, 0xa03e, 0x2720, 0x00f6,
+	0x00e6, 0x00c6, 0x2d60, 0x2071, 0xb84a, 0x2079, 0x0020, 0x00d6,
+	0x2069, 0x0000, 0x6824, 0xd0b4, 0x0140, 0x2001, 0x007d, 0x2004,
+	0x783e, 0x2001, 0x007c, 0x2004, 0x783a, 0x00de, 0x2011, 0x0001,
+	0x080c, 0x36aa, 0x080c, 0x36aa, 0x00ce, 0x00ee, 0x00fe, 0x080c,
+	0x35f5, 0x080c, 0x36d2, 0x080c, 0x364f, 0x080c, 0x35b4, 0x080c,
+	0x35e5, 0x00f6, 0x2079, 0x0100, 0x7824, 0xd094, 0x0530, 0x7814,
+	0xa084, 0x0184, 0xa085, 0x0010, 0x7816, 0x2079, 0x0140, 0x080c,
+	0x352d, 0x1110, 0x00fe, 0x0430, 0x7804, 0xd0dc, 0x0dc0, 0x2079,
+	0x0100, 0x7827, 0x0086, 0x7814, 0xa084, 0x0184, 0xa085, 0x0032,
+	0x7816, 0x080c, 0x352d, 0x1110, 0x00fe, 0x00a0, 0x7824, 0xd0bc,
+	0x0dc0, 0x7827, 0x0080, 0xa026, 0x7c16, 0x7824, 0xd0ac, 0x0130,
+	0x8b58, 0x080c, 0x3537, 0x00fe, 0x0804, 0x34f7, 0x00fe, 0x080c,
+	0x352d, 0x1150, 0x8948, 0x2001, 0x007a, 0x2602, 0x2001, 0x007b,
+	0x2502, 0x080c, 0x3537, 0x0088, 0x87ff, 0x0140, 0x2001, 0x0201,
+	0x2004, 0xa005, 0x1904, 0x3431, 0x8739, 0x0038, 0x2001, 0xb823,
+	0x2004, 0xa086, 0x0000, 0x1904, 0x3431, 0x2001, 0x0033, 0x2003,
+	0x00f6, 0x8631, 0x1208, 0x8529, 0x2500, 0xa605, 0x0904, 0x34f7,
+	0x7824, 0xd0bc, 0x0128, 0x2900, 0xaa05, 0xab05, 0x1904, 0x34f7,
+	0x6033, 0x000d, 0x2001, 0x0030, 0x2003, 0x0004, 0x7824, 0xd0ac,
+	0x1148, 0x2001, 0xb823, 0x2003, 0x0003, 0x2001, 0x0030, 0x2003,
+	0x0009, 0x0040, 0x6027, 0x0001, 0x2001, 0x0075, 0x2004, 0xa005,
+	0x0108, 0x6026, 0x2c00, 0x601a, 0x20e1, 0x9040, 0x2d00, 0x681a,
+	0x6833, 0x000d, 0x7824, 0xd0a4, 0x1180, 0x6827, 0x0000, 0x00c6,
+	0x20a9, 0x0004, 0x2061, 0x0020, 0x6003, 0x0008, 0x2001, 0x0203,
+	0x2004, 0x1f04, 0x34cc, 0x00ce, 0x0040, 0x6827, 0x0001, 0x2001,
+	0x0074, 0x2004, 0xa005, 0x0108, 0x6826, 0x00f6, 0x00c6, 0x2079,
+	0x0100, 0x2061, 0x0020, 0x7827, 0x0002, 0x2001, 0x0072, 0x2004,
+	0xa084, 0xfff8, 0x601a, 0x0006, 0x2001, 0x0073, 0x2004, 0x601e,
+	0x78c6, 0x000e, 0x78ca, 0x00ce, 0x00fe, 0x0804, 0x340f, 0x2061,
+	0x0100, 0x6027, 0x0002, 0x001e, 0x61e2, 0x001e, 0x6106, 0x7824,
+	0xa084, 0x0003, 0xa086, 0x0002, 0x0188, 0x20e1, 0x9028, 0x6050,
+	0xa084, 0xf7ef, 0x6052, 0x602f, 0x0000, 0x602c, 0xc0ac, 0x602e,
+	0x604b, 0xf7f7, 0x6043, 0x0090, 0x6043, 0x0010, 0x2908, 0x2a10,
+	0x2b18, 0x2b00, 0xaa05, 0xa905, 0x00fe, 0x00ee, 0x00de, 0x00ce,
+	0x00be, 0x00ae, 0x009e, 0x008e, 0x1118, 0x012e, 0x0804, 0x2faa,
+	0x012e, 0x2021, 0x400c, 0x0804, 0x2fac, 0xa085, 0x0001, 0x1d04,
+	0x3536, 0x2091, 0x6000, 0x8420, 0xa486, 0x0064, 0x0005, 0x2001,
+	0x0105, 0x2003, 0x0010, 0x2001, 0x0030, 0x2003, 0x0004, 0x2001,
+	0x0020, 0x2003, 0x0004, 0x2001, 0xb823, 0x2003, 0x0000, 0x2001,
+	0xb84a, 0x2003, 0x0000, 0x20e1, 0xf000, 0xa026, 0x0005, 0x00f6,
+	0x2079, 0x0100, 0x2001, 0xb515, 0x200c, 0x7932, 0x7936, 0x080c,
+	0x2847, 0x7850, 0xa084, 0x0980, 0xa085, 0x0030, 0x7852, 0x2019,
+	0x01f4, 0x8319, 0x1df0, 0xa084, 0x0980, 0x7852, 0x782c, 0xc0ad,
+	0x782e, 0x20a9, 0x0046, 0x1d04, 0x356b, 0x2091, 0x6000, 0x1f04,
+	0x356b, 0x7850, 0xa085, 0x0400, 0x7852, 0x2001, 0x0009, 0x2004,
+	0xa084, 0x0003, 0xa086, 0x0001, 0x1118, 0x782c, 0xc0ac, 0x782e,
+	0x784b, 0xf7f7, 0x7843, 0x0090, 0x7843, 0x0010, 0x20a9, 0x000e,
+	0xe000, 0x1f04, 0x3588, 0x7850, 0xa085, 0x1400, 0x7852, 0x2019,
+	0x61a8, 0x7854, 0xe000, 0xe000, 0xd08c, 0x1110, 0x8319, 0x1dc8,
+	0x7827, 0x0048, 0x7850, 0xa085, 0x0400, 0x7852, 0x7843, 0x0040,
+	0x2019, 0x01f4, 0xe000, 0xe000, 0x8319, 0x1de0, 0x2001, 0x0140,
+	0x2003, 0x0100, 0x7827, 0x0020, 0x7843, 0x0000, 0x2003, 0x0000,
+	0x7827, 0x0048, 0x00fe, 0x0005, 0x7824, 0xd0ac, 0x11c8, 0x00f6,
+	0x00e6, 0x2071, 0xb823, 0x2079, 0x0030, 0x2001, 0x0201, 0x2004,
+	0xa005, 0x0160, 0x7000, 0xa086, 0x0000, 0x1140, 0x0051, 0xd0bc,
+	0x0108, 0x8738, 0x7003, 0x0003, 0x7803, 0x0019, 0x00ee, 0x00fe,
+	0x0005, 0x780c, 0xa08c, 0x0070, 0x0178, 0x2009, 0x007a, 0x260a,
+	0x2009, 0x007b, 0x250a, 0xd0b4, 0x0108, 0x8a50, 0xd0ac, 0x0108,
+	0x8948, 0xd0a4, 0x0108, 0x8b58, 0x0005, 0x00f6, 0x2079, 0x0200,
+	0x781c, 0xd084, 0x0140, 0x20e1, 0x0007, 0x20e1, 0x2000, 0x2001,
+	0x020a, 0x2004, 0x0ca8, 0x00fe, 0x0005, 0x00e6, 0x2071, 0x0100,
+	0x2001, 0xb7c0, 0x2004, 0x70e2, 0x2009, 0xb515, 0x210c, 0x716e,
+	0x7063, 0x0100, 0x7166, 0x719e, 0x706b, 0x0000, 0x7073, 0x0809,
+	0x7077, 0x0008, 0x7078, 0xa080, 0x0100, 0x707a, 0x7080, 0x8000,
+	0x7082, 0x7087, 0xaaaa, 0xa006, 0x708a, 0x708e, 0x707e, 0x70d6,
+	0x70ab, 0x0036, 0x70af, 0x95d5, 0x7027, 0x0080, 0x7014, 0xa084,
+	0x0184, 0xa085, 0x0032, 0x7016, 0x080c, 0x36d2, 0x080c, 0x352d,
+	0x1110, 0x8421, 0x0028, 0x7024, 0xd0bc, 0x0db0, 0x7027, 0x0080,
+	0x00f6, 0x00e6, 0x2071, 0xb823, 0x2079, 0x0030, 0x00d6, 0x2069,
+	0x0000, 0x6824, 0xd0b4, 0x0120, 0x683c, 0x783e, 0x6838, 0x783a,
+	0x00de, 0x2011, 0x0011, 0x080c, 0x36aa, 0x2011, 0x0001, 0x080c,
+	0x36aa, 0x00ee, 0x00fe, 0x7017, 0x0000, 0x00ee, 0x0005, 0x00f6,
+	0x00e6, 0x2071, 0xb823, 0x2079, 0x0030, 0x7904, 0xd1fc, 0x0904,
+	0x36a7, 0x7803, 0x0002, 0xa026, 0xd19c, 0x1904, 0x36a3, 0x7000,
+	0x0002, 0x36a7, 0x3665, 0x3689, 0x36a3, 0xd1bc, 0x1150, 0xd1dc,
+	0x1150, 0x8001, 0x7002, 0x2011, 0x0001, 0x04e1, 0x05c0, 0x04d1,
+	0x04b0, 0x780f, 0x0000, 0x7820, 0x7924, 0x7803, 0x0004, 0x7822,
+	0x7926, 0x2001, 0x0201, 0x200c, 0x81ff, 0x0de8, 0x080c, 0x35d1,
+	0x2009, 0x0001, 0x7808, 0xd0ec, 0x0110, 0x2009, 0x0011, 0x7902,
+	0x00f0, 0x8001, 0x7002, 0xa184, 0x0880, 0x1138, 0x7804, 0xd0fc,
+	0x1940, 0x2011, 0x0001, 0x00b1, 0x0090, 0x6030, 0xa092, 0x0004,
+	0xa086, 0x0009, 0x1120, 0x6000, 0x601a, 0x2011, 0x0025, 0x6232,
+	0xd1dc, 0x1988, 0x0870, 0x7803, 0x0004, 0x7003, 0x0000, 0x00ee,
+	0x00fe, 0x0005, 0x6024, 0xa005, 0x0520, 0x8001, 0x6026, 0x6018,
+	0x6130, 0xa140, 0x2804, 0x7832, 0x8840, 0x2804, 0x7836, 0x8840,
+	0x2804, 0x7822, 0x8840, 0x2804, 0x7826, 0x8840, 0x7a02, 0x7000,
+	0x8000, 0x7002, 0x6018, 0xa802, 0xa08a, 0x0029, 0x1138, 0x6018,
+	0xa080, 0x0001, 0x2004, 0x601a, 0x2001, 0x000d, 0x6032, 0xa085,
+	0x0001, 0x0005, 0x00f6, 0x00e6, 0x00c6, 0x2071, 0xb84a, 0x2079,
+	0x0020, 0x7904, 0xd1fc, 0x01f0, 0x7803, 0x0002, 0x2d60, 0xa026,
+	0x7000, 0x0002, 0x36fa, 0x36e5, 0x36f1, 0x8001, 0x7002, 0xd19c,
+	0x1188, 0x2011, 0x0001, 0x080c, 0x36aa, 0x0160, 0x080c, 0x36aa,
+	0x0048, 0x8001, 0x7002, 0x7804, 0xd0fc, 0x1d30, 0x2011, 0x0001,
+	0x080c, 0x36aa, 0x00ce, 0x00ee, 0x00fe, 0x0005, 0x00f6, 0x00e6,
+	0x00c6, 0x2061, 0x0200, 0x2001, 0xb7c0, 0x2004, 0x601a, 0x2061,
+	0x0100, 0x2001, 0xb7bf, 0x2004, 0x60ce, 0x6004, 0xc0ac, 0xa085,
+	0x0200, 0x6006, 0x2001, 0x0074, 0x2004, 0xa005, 0x01f8, 0x2038,
+	0x2001, 0x0076, 0x2024, 0x2001, 0x0077, 0x201c, 0x080c, 0x3e75,
+	0x6833, 0x000d, 0x6f26, 0x2d00, 0x681a, 0xa78a, 0x0007, 0x0220,
+	0x2138, 0x2009, 0x0007, 0x0010, 0x2708, 0xa03e, 0x6818, 0xa080,
+	0x000d, 0x04b1, 0x1d90, 0x2d00, 0x681a, 0x0088, 0x080c, 0x3e75,
+	0x6833, 0x000d, 0x2070, 0x6827, 0x0001, 0x2d00, 0x681a, 0x2001,
+	0x0076, 0x2004, 0x2072, 0x2001, 0x0077, 0x2004, 0x7006, 0x2061,
+	0x0020, 0x2079, 0x0100, 0x2001, 0xb7bf, 0x2004, 0x6012, 0x20e1,
+	0x9040, 0x2001, 0x0072, 0x2004, 0xa084, 0xfff8, 0x700a, 0x601a,
+	0x0006, 0x2001, 0x0073, 0x2004, 0x700e, 0x601e, 0x78c6, 0x000e,
+	0x78ca, 0xa006, 0x603a, 0x603e, 0x00ce, 0x00ee, 0x00fe, 0x0005,
+	0x00e6, 0x2071, 0x0010, 0x20a0, 0x2099, 0x0014, 0x7003, 0x0026,
+	0x7432, 0x7336, 0xa006, 0x703a, 0x703e, 0x810b, 0x810b, 0x21a8,
+	0x810b, 0x7122, 0x7003, 0x0041, 0x7004, 0xd0fc, 0x0de8, 0x7003,
+	0x0002, 0x7003, 0x0040, 0x53a5, 0x7430, 0x7334, 0x87ff, 0x0180,
+	0x00c6, 0x00d6, 0x2d60, 0x00c6, 0x080c, 0x3e75, 0x00ce, 0x6018,
+	0x2070, 0x2d00, 0x7006, 0x601a, 0x00de, 0x00ce, 0xa085, 0x0001,
+	0x00ee, 0x0005, 0x00e6, 0x2001, 0x0075, 0x2004, 0xa005, 0x0508,
+	0x2038, 0x2001, 0x0078, 0x2024, 0x2001, 0x0079, 0x201c, 0x080c,
+	0x3e75, 0x2d60, 0x6833, 0x000d, 0x6f26, 0x2d00, 0x681a, 0xa78a,
+	0x0007, 0x0220, 0x2138, 0x2009, 0x0007, 0x0010, 0x2708, 0xa03e,
+	0x6818, 0xa080, 0x000d, 0x080c, 0x3768, 0x1d88, 0x2d00, 0x681a,
+	0x00e0, 0x080c, 0x3e75, 0x2d60, 0x6033, 0x000d, 0x2070, 0x6027,
+	0x0001, 0x2c00, 0x601a, 0x2001, 0x0078, 0x2004, 0x2072, 0x2001,
+	0x0079, 0x2004, 0x7006, 0x2001, 0x0072, 0x2004, 0xa084, 0xfff8,
+	0x700a, 0x2001, 0x0073, 0x2004, 0x700e, 0x2001, 0x0030, 0x2003,
+	0x0004, 0x7824, 0xd0ac, 0x1178, 0x2001, 0x0101, 0x200c, 0xc1ed,
+	0x2102, 0x6027, 0x0000, 0x2001, 0xb823, 0x2003, 0x0003, 0x2001,
+	0x0030, 0x2003, 0x0009, 0x00ee, 0x0005, 0x0804, 0x2faa, 0x0126,
+	0x2091, 0x8000, 0x20a9, 0x0012, 0x2001, 0xb540, 0x20a0, 0xa006,
+	0x40a4, 0x012e, 0x0804, 0x2faa, 0x7d38, 0x7c3c, 0x0804, 0x3051,
+	0x080c, 0x3e75, 0x0904, 0x2fcf, 0x080c, 0x5acf, 0x0110, 0x080c,
+	0x4bf0, 0x2009, 0x001c, 0x7a2c, 0x7b28, 0x7c3c, 0x7d38, 0x080c,
+	0x3eb6, 0x701b, 0x381c, 0x0005, 0xade8, 0x000d, 0x6800, 0xa005,
+	0x0904, 0x2fd2, 0x6804, 0xd0ac, 0x0118, 0xd0a4, 0x0904, 0x2fd2,
+	0xd094, 0x00c6, 0x2061, 0x0100, 0x6104, 0x0138, 0x6200, 0xa292,
+	0x0005, 0x0218, 0xa18c, 0xffdf, 0x0010, 0xa18d, 0x0020, 0x6106,
+	0x00ce, 0xd08c, 0x00c6, 0x2061, 0x0100, 0x6104, 0x0118, 0xa18d,
+	0x0010, 0x0010, 0xa18c, 0xffef, 0x6106, 0x00ce, 0x2009, 0x0100,
+	0x210c, 0xa18a, 0x0002, 0x0268, 0xd084, 0x0158, 0x6a28, 0xa28a,
+	0x007f, 0x1a04, 0x2fd2, 0xa288, 0x2dc4, 0x210d, 0xa18c, 0x00ff,
+	0x615a, 0xd0dc, 0x0130, 0x6828, 0xa08a, 0x007f, 0x1a04, 0x2fd2,
+	0x6052, 0x6808, 0xa08a, 0x0100, 0x0a04, 0x2fd2, 0xa08a, 0x0841,
+	0x1a04, 0x2fd2, 0xa084, 0x0007, 0x1904, 0x2fd2, 0x680c, 0xa005,
+	0x0904, 0x2fd2, 0x6810, 0xa005, 0x0904, 0x2fd2, 0x6848, 0x6940,
+	0xa10a, 0x1a04, 0x2fd2, 0x8001, 0x0904, 0x2fd2, 0x684c, 0x6944,
+	0xa10a, 0x1a04, 0x2fd2, 0x8001, 0x0904, 0x2fd2, 0x6804, 0xd0fc,
+	0x0560, 0x080c, 0x3e75, 0x0904, 0x2fcf, 0x2009, 0x0014, 0x7a2c,
+	0x7b28, 0x7c3c, 0x7d38, 0xa290, 0x0038, 0xa399, 0x0000, 0x080c,
+	0x3eb6, 0x701b, 0x389c, 0x0005, 0xade8, 0x000d, 0x20a9, 0x0014,
+	0x2d98, 0x2069, 0xb56e, 0x2da0, 0x53a3, 0x7010, 0xa0e8, 0x000d,
+	0x2001, 0xb572, 0x200c, 0xd1e4, 0x0140, 0x00c6, 0x2061, 0x0100,
+	0x6004, 0xa085, 0x0b00, 0x6006, 0x00ce, 0x2009, 0xb7b1, 0x200b,
+	0x0000, 0x2001, 0xb574, 0x2004, 0xd0ac, 0x0158, 0x7824, 0x200a,
+	0x2009, 0x017f, 0x200a, 0x3200, 0xa084, 0x003f, 0xa085, 0x3020,
+	0x2090, 0x20a9, 0x001c, 0x2d98, 0x2069, 0xb552, 0x2da0, 0x53a3,
+	0x6814, 0xa08c, 0x00ff, 0x6142, 0x8007, 0xa084, 0x00ff, 0x6046,
+	0x080c, 0x5da5, 0x080c, 0x536c, 0x080c, 0x53d5, 0x6000, 0xa086,
+	0x0000, 0x1904, 0x3997, 0x6808, 0x602a, 0x080c, 0x2470, 0x0006,
+	0x2001, 0x0100, 0x2004, 0xa082, 0x0005, 0x000e, 0x0268, 0x2009,
+	0x0170, 0x200b, 0x0080, 0xe000, 0xe000, 0x200b, 0x0000, 0x0036,
+	0x6b08, 0x080c, 0x28a2, 0x003e, 0x6818, 0x691c, 0x6a20, 0x6b24,
+	0x8007, 0x810f, 0x8217, 0x831f, 0x6016, 0x611a, 0x621e, 0x6322,
+	0x6c04, 0xd4f4, 0x0148, 0x6830, 0x6934, 0x6a38, 0x6b3c, 0x8007,
+	0x810f, 0x8217, 0x831f, 0x0010, 0xa084, 0xf0ff, 0x6006, 0x610a,
+	0x620e, 0x6312, 0x8007, 0x810f, 0x8217, 0x831f, 0x20a9, 0x0004,
+	0x20a1, 0xb7c6, 0x40a1, 0x080c, 0x6a68, 0x6904, 0xd1fc, 0x0520,
+	0x00c6, 0x2009, 0x0000, 0x20a9, 0x0001, 0x6b70, 0xd384, 0x01c8,
+	0x0020, 0x839d, 0x12b0, 0x3508, 0x8109, 0x080c, 0x635c, 0x6878,
+	0x6016, 0x6874, 0x2008, 0xa084, 0xff00, 0x8007, 0x600a, 0xa184,
+	0x00ff, 0x6006, 0x8108, 0x1118, 0x6003, 0x0003, 0x0010, 0x6003,
+	0x0001, 0x1f04, 0x3931, 0x00ce, 0x2069, 0xb552, 0x2001, 0xb79e,
+	0x6a80, 0xa294, 0x0030, 0xa28e, 0x0000, 0x0170, 0xa28e, 0x0010,
+	0x0118, 0xa28e, 0x0020, 0x0140, 0x2003, 0xaaaa, 0x080c, 0x28eb,
+	0x2001, 0xb78f, 0x2102, 0x0008, 0x2102, 0x00c6, 0x2061, 0x0100,
+	0x602f, 0x0040, 0x602f, 0x0000, 0x00ce, 0x080c, 0x5acf, 0x0128,
+	0x080c, 0x40cf, 0x0110, 0x080c, 0x2867, 0x60c8, 0xa005, 0x01d0,
+	0x6003, 0x0001, 0x2009, 0x397d, 0x00e0, 0x080c, 0x5acf, 0x1178,
+	0x2011, 0x59a2, 0x080c, 0x699c, 0x2011, 0x5995, 0x080c, 0x6a5c,
+	0x2001, 0xb79f, 0x2003, 0x0000, 0x080c, 0x5a07, 0x0040, 0x080c,
+	0x4b1f, 0x0028, 0x6003, 0x0004, 0x2009, 0x3997, 0x0010, 0x0804,
+	0x2faa, 0x2001, 0x0100, 0x2004, 0xa082, 0x0005, 0x0258, 0x2001,
+	0x0170, 0x2004, 0xa084, 0x00ff, 0xa086, 0x004c, 0x1118, 0x2091,
+	0x309d, 0x0817, 0x2091, 0x301d, 0x0817, 0x6000, 0xa086, 0x0000,
+	0x0904, 0x2fcf, 0x2069, 0xb552, 0x7830, 0x6842, 0x7834, 0x6846,
+	0x6804, 0xd0fc, 0x0118, 0x2009, 0x0030, 0x0010, 0x2009, 0x001c,
+	0x2d00, 0x7a2c, 0x7b28, 0x7c3c, 0x7d38, 0x0804, 0x3eb9, 0xa006,
+	0x080c, 0x2867, 0x81ff, 0x1904, 0x2fcf, 0x080c, 0x5acf, 0x1178,
+	0x2001, 0xb79f, 0x2003, 0x0001, 0x2001, 0xb500, 0x2003, 0x0001,
+	0xa085, 0x0001, 0x080c, 0x5b13, 0x080c, 0x5a07, 0x0020, 0x080c,
+	0x4bf0, 0x080c, 0x4b1f, 0x0804, 0x2faa, 0x81ff, 0x1904, 0x2fcf,
+	0x080c, 0x5acf, 0x1110, 0x0804, 0x2fcf, 0x6188, 0x81ff, 0x0198,
+	0x703f, 0x0000, 0x2001, 0xbcc0, 0x2009, 0x0040, 0x7a2c, 0x7b28,
+	0x7c3c, 0x7d38, 0x0126, 0x2091, 0x8000, 0x080c, 0x3eb9, 0x701b,
+	0x2fa8, 0x012e, 0x0005, 0x703f, 0x0001, 0x00d6, 0x2069, 0xbcc0,
+	0x20a9, 0x0040, 0x20a1, 0xbcc0, 0x2019, 0xffff, 0x43a4, 0x6550,
+	0xa588, 0x2dc4, 0x210d, 0xa18c, 0x00ff, 0x216a, 0xa00e, 0x2011,
+	0x0002, 0x2100, 0xa506, 0x01a8, 0x080c, 0x4fa9, 0x1190, 0x6014,
+	0x821c, 0x0238, 0xa398, 0xbcc0, 0xa085, 0xff00, 0x8007, 0x201a,
+	0x0038, 0xa398, 0xbcc0, 0x2324, 0xa4a4, 0xff00, 0xa405, 0x201a,
+	0x8210, 0x8108, 0xa182, 0x0080, 0x1208, 0x0c18, 0x8201, 0x8007,
+	0x2d0c, 0xa105, 0x206a, 0x00de, 0x20a9, 0x0040, 0x20a1, 0xbcc0,
+	0x2099, 0xbcc0, 0x080c, 0x4b8f, 0x0804, 0x39f2, 0x080c, 0x3e9a,
+	0x0904, 0x2fd2, 0x00c6, 0x080c, 0x3e75, 0x00ce, 0x1120, 0x2009,
+	0x0002, 0x0804, 0x2fcf, 0x2001, 0xb553, 0x2004, 0xd0b4, 0x0550,
+	0x7824, 0xa084, 0xff00, 0xa08e, 0x7e00, 0x0520, 0xa08e, 0x7f00,
+	0x0508, 0xa08e, 0x8000, 0x01f0, 0x6000, 0xd08c, 0x11d8, 0x6004,
+	0xa084, 0x00ff, 0xa086, 0x0006, 0x11a8, 0x6837, 0x0000, 0x6838,
+	0xc0fd, 0x683a, 0x080c, 0x9dda, 0x1120, 0x2009, 0x0003, 0x0804,
+	0x2fcf, 0x7007, 0x0003, 0x701b, 0x3a7e, 0x0005, 0x080c, 0x3e9a,
+	0x0904, 0x2fd2, 0x20a9, 0x002b, 0x2c98, 0xade8, 0x0002, 0x2da0,
+	0x53a3, 0x20a9, 0x0004, 0xac80, 0x0006, 0x2098, 0xad80, 0x0006,
+	0x20a0, 0x080c, 0x4b8f, 0x20a9, 0x0004, 0xac80, 0x000a, 0x2098,
+	0xad80, 0x000a, 0x20a0, 0x080c, 0x4b8f, 0x2d00, 0x2009, 0x002b,
+	0x7a2c, 0x7b28, 0x7c3c, 0x7d38, 0x0804, 0x3eb9, 0x81ff, 0x1904,
+	0x2fcf, 0x080c, 0x3e8a, 0x0904, 0x2fd2, 0x080c, 0x5186, 0x0804,
+	0x2faa, 0x81ff, 0x1904, 0x2fcf, 0x7828, 0xa08a, 0x1000, 0x1a04,
+	0x2fd2, 0x080c, 0x3e9a, 0x0904, 0x2fd2, 0x080c, 0x51e9, 0x0904,
+	0x2fcf, 0x2019, 0x0004, 0xa00e, 0x080c, 0x5198, 0x7924, 0x810f,
+	0x7a28, 0x0011, 0x0804, 0x2faa, 0xa186, 0x00ff, 0x0110, 0x0071,
+	0x0060, 0x2029, 0x007e, 0x2061, 0xb500, 0x6450, 0x2400, 0xa506,
+	0x0110, 0x2508, 0x0019, 0x8529, 0x1ec8, 0x0005, 0x080c, 0x4fa9,
+	0x1138, 0x2200, 0x8003, 0x800b, 0x810b, 0xa108, 0x080c, 0x69a8,
+	0x0005, 0x81ff, 0x1904, 0x2fcf, 0x080c, 0x3e8a, 0x0904, 0x2fd2,
+	0x080c, 0x506f, 0x0904, 0x2fcf, 0x080c, 0x518f, 0x0804, 0x2faa,
+	0x81ff, 0x1904, 0x2fcf, 0x080c, 0x3e8a, 0x0904, 0x2fd2, 0x080c,
+	0x506f, 0x0904, 0x2fcf, 0x080c, 0x517d, 0x0804, 0x2faa, 0x6100,
+	0x0804, 0x2faa, 0x080c, 0x3e9a, 0x0904, 0x2fd2, 0x2001, 0xb500,
+	0x2004, 0xa086, 0x0003, 0x1904, 0x2fcf, 0x00d6, 0xace8, 0x000a,
+	0x7924, 0xd184, 0x0110, 0xace8, 0x0006, 0x680c, 0x8007, 0x783e,
+	0x6808, 0x8007, 0x783a, 0x6b04, 0x831f, 0x6a00, 0x8217, 0x00de,
+	0x6100, 0xa18c, 0x0200, 0x0804, 0x2faa, 0x7824, 0xa09c, 0x0003,
+	0xd0b4, 0x1160, 0xa39a, 0x0003, 0x1a04, 0x2fcf, 0x6250, 0xa294,
+	0x00ff, 0xa084, 0xff00, 0x8007, 0xa206, 0x1150, 0x2001, 0xb540,
+	0x2009, 0x000c, 0x7a2c, 0x7b28, 0x7c3c, 0x7d38, 0x0804, 0x3eb9,
+	0x81ff, 0x1904, 0x2fcf, 0x080c, 0x3e9a, 0x0904, 0x2fd2, 0x6004,
+	0xa084, 0x00ff, 0xa086, 0x0006, 0x1904, 0x2fcf, 0x00c6, 0x080c,
+	0x3e75, 0x00ce, 0x0904, 0x2fcf, 0x6837, 0x0000, 0x6838, 0xc0fd,
+	0x683a, 0x080c, 0x9d86, 0x0904, 0x2fcf, 0x7007, 0x0003, 0x701b,
+	0x3b6a, 0x0005, 0x6830, 0xa086, 0x0100, 0x0904, 0x2fcf, 0xad80,
+	0x000e, 0x2009, 0x000c, 0x7a2c, 0x7b28, 0x7c3c, 0x7d38, 0x0804,
+	0x3eb9, 0xa006, 0x080c, 0x2867, 0x7824, 0xa084, 0x00ff, 0xa086,
+	0x00ff, 0x0118, 0x81ff, 0x1904, 0x2fcf, 0x080c, 0x5acf, 0x0110,
+	0x080c, 0x4bf0, 0x7828, 0xa08a, 0x1000, 0x1a04, 0x2fd2, 0x7924,
+	0xa18c, 0xff00, 0x810f, 0xa186, 0x00ff, 0x0138, 0xa182, 0x007f,
+	0x1a04, 0x2fd2, 0x2100, 0x080c, 0x2831, 0x0026, 0x00c6, 0x0126,
+	0x2091, 0x8000, 0x2061, 0xb7f3, 0x601b, 0x0000, 0x601f, 0x0000,
+	0x080c, 0x5acf, 0x1178, 0x2001, 0xb79f, 0x2003, 0x0001, 0x2001,
+	0xb500, 0x2003, 0x0001, 0xa085, 0x0001, 0x080c, 0x5b13, 0x080c,
+	0x5a07, 0x0420, 0x2011, 0x0003, 0x080c, 0x8075, 0x2011, 0x0002,
+	0x080c, 0x807f, 0x080c, 0x7f59, 0x0036, 0x2019, 0x0000, 0x080c,
+	0x7fe4, 0x003e, 0x2061, 0x0100, 0x2001, 0xb515, 0x2004, 0xa084,
+	0x00ff, 0x810f, 0xa105, 0x604a, 0x6043, 0x0090, 0x6043, 0x0010,
+	0x2009, 0x002d, 0x2011, 0x4b54, 0x080c, 0x6a22, 0x7924, 0xa18c,
+	0xff00, 0x810f, 0x080c, 0x5acf, 0x1110, 0x2009, 0x00ff, 0x7a28,
+	0x080c, 0x3acc, 0x012e, 0x00ce, 0x002e, 0x0804, 0x2faa, 0x7924,
+	0xa18c, 0xff00, 0x810f, 0x00c6, 0x080c, 0x4f4d, 0x2c08, 0x00ce,
+	0x1904, 0x2fd2, 0x0804, 0x2faa, 0x81ff, 0x0120, 0x2009, 0x0001,
+	0x0804, 0x2fcf, 0x60d4, 0xd0ac, 0x1130, 0xd09c, 0x1120, 0x2009,
+	0x0005, 0x0804, 0x2fcf, 0x080c, 0x3e75, 0x1120, 0x2009, 0x0002,
+	0x0804, 0x2fcf, 0x7924, 0x7a2c, 0x7b28, 0x7c3c, 0x7d38, 0x080c,
+	0x3eb6, 0x701b, 0x3c1c, 0x0005, 0x2009, 0x0080, 0x080c, 0x4fa9,
+	0x1130, 0x6004, 0xa084, 0x00ff, 0xa086, 0x0006, 0x0120, 0x2021,
+	0x400a, 0x0804, 0x2fac, 0x00d6, 0xade8, 0x000d, 0x6900, 0x6a08,
+	0x6b0c, 0x6c10, 0x6d14, 0x6e18, 0x6820, 0xa0be, 0x0100, 0x0904,
+	0x3c93, 0xa0be, 0x0112, 0x0904, 0x3c93, 0xa0be, 0x0113, 0x0904,
+	0x3c93, 0xa0be, 0x0114, 0x0904, 0x3c93, 0xa0be, 0x0117, 0x0904,
+	0x3c93, 0xa0be, 0x011a, 0x0904, 0x3c93, 0xa0be, 0x011c, 0x0904,
+	0x3c93, 0xa0be, 0x0121, 0x05b0, 0xa0be, 0x0131, 0x0598, 0xa0be,
+	0x0171, 0x05c8, 0xa0be, 0x0173, 0x05b0, 0xa0be, 0x01a1, 0x1120,
+	0x6830, 0x8007, 0x6832, 0x04a8, 0xa0be, 0x0212, 0x0540, 0xa0be,
+	0x0213, 0x0528, 0xa0be, 0x0214, 0x01b0, 0xa0be, 0x0217, 0x0168,
+	0xa0be, 0x021a, 0x1120, 0x6838, 0x8007, 0x683a, 0x00e0, 0xa0be,
+	0x0300, 0x01c8, 0x00de, 0x0804, 0x2fd2, 0xad80, 0x0010, 0x20a9,
+	0x0007, 0x080c, 0x3cd9, 0xad80, 0x000e, 0x20a9, 0x0001, 0x080c,
+	0x3cd9, 0x0048, 0xad80, 0x000c, 0x080c, 0x3ce7, 0x0050, 0xad80,
+	0x000e, 0x080c, 0x3ce7, 0xad80, 0x000c, 0x20a9, 0x0001, 0x080c,
+	0x3cd9, 0x00c6, 0x080c, 0x3e75, 0x0568, 0x6838, 0xc0fd, 0x683a,
+	0x6837, 0x0119, 0x6853, 0x0000, 0x684f, 0x0020, 0x685b, 0x0001,
+	0x810b, 0x697e, 0x6883, 0x0000, 0x6a86, 0x6b8a, 0x6c8e, 0x6d92,
+	0x6996, 0x689b, 0x0000, 0x00ce, 0x00de, 0x6837, 0x0000, 0x6838,
+	0xc0fd, 0x683a, 0x6823, 0x0000, 0x6804, 0x2068, 0x080c, 0x9da2,
+	0x1120, 0x2009, 0x0003, 0x0804, 0x2fcf, 0x7007, 0x0003, 0x701b,
+	0x3cd0, 0x0005, 0x00ce, 0x00de, 0x2009, 0x0002, 0x0804, 0x2fcf,
+	0x6820, 0xa086, 0x8001, 0x1904, 0x2faa, 0x2009, 0x0004, 0x0804,
+	0x2fcf, 0x0016, 0x2008, 0x2044, 0x8000, 0x204c, 0x8000, 0x290a,
+	0x8108, 0x280a, 0x8108, 0x1f04, 0x3cdb, 0x001e, 0x0005, 0x0016,
+	0x00a6, 0x00b6, 0x2008, 0x2044, 0x8000, 0x204c, 0x8000, 0x2054,
+	0x8000, 0x205c, 0x2b0a, 0x8108, 0x2a0a, 0x8108, 0x290a, 0x8108,
+	0x280a, 0x00be, 0x00ae, 0x001e, 0x0005, 0x81ff, 0x0120, 0x2009,
+	0x0001, 0x0804, 0x2fcf, 0x60d4, 0xd0ac, 0x1130, 0xd09c, 0x1120,
+	0x2009, 0x0005, 0x0804, 0x2fcf, 0x7924, 0x2140, 0xa18c, 0xff00,
+	0x810f, 0x60d4, 0xd0ac, 0x1120, 0xa182, 0x0080, 0x0a04, 0x2fd2,
+	0xa182, 0x00ff, 0x1a04, 0x2fd2, 0x7a2c, 0x7b28, 0x6070, 0xa306,
+	0x1140, 0x6074, 0xa24e, 0x0904, 0x2fd2, 0xa9cc, 0xff00, 0x0904,
+	0x2fd2, 0x00c6, 0x080c, 0x3dc5, 0x2c68, 0x00ce, 0x0530, 0xa0c6,
+	0x4000, 0x1178, 0x00c6, 0x0006, 0x2d60, 0xa00e, 0x080c, 0x524a,
+	0x1108, 0xc185, 0x6000, 0xd0bc, 0x0108, 0xc18d, 0x000e, 0x00ce,
+	0x0088, 0xa0c6, 0x4007, 0x1110, 0x2408, 0x0060, 0xa0c6, 0x4008,
+	0x1118, 0x2708, 0x2610, 0x0030, 0xa0c6, 0x4009, 0x1108, 0x0010,
+	0x2001, 0x4006, 0x2020, 0x0804, 0x2fac, 0x2d00, 0x7022, 0x0016,
+	0x00b6, 0x00c6, 0x00e6, 0x2c70, 0x080c, 0x85c7, 0x05d8, 0x2d00,
+	0x601a, 0x080c, 0xa027, 0x2e58, 0x00ee, 0x00e6, 0x00c6, 0x080c,
+	0x3e75, 0x00ce, 0x2b70, 0x1150, 0x080c, 0x861d, 0x00ee, 0x00ce,
+	0x00be, 0x001e, 0x2009, 0x0002, 0x0804, 0x2fcf, 0x6837, 0x0000,
+	0x683b, 0x0000, 0x2d00, 0x6012, 0x6833, 0x0000, 0x6838, 0xc0fd,
+	0xd88c, 0x0108, 0xc0f5, 0x683a, 0x0126, 0x2091, 0x8000, 0x080c,
+	0x2c9c, 0x012e, 0x601f, 0x0001, 0x2001, 0x0000, 0x080c, 0x4eeb,
+	0x2001, 0x0002, 0x080c, 0x4efd, 0x2009, 0x0002, 0x080c, 0x864c,
+	0xa085, 0x0001, 0x00ee, 0x00ce, 0x00be, 0x001e, 0x1120, 0x2009,
+	0x0003, 0x0804, 0x2fcf, 0x7007, 0x0003, 0x701b, 0x3da8, 0x0005,
+	0x6830, 0xa086, 0x0100, 0x7020, 0x2060, 0x1138, 0x2009, 0x0004,
+	0x6204, 0xa294, 0x00ff, 0x0804, 0x2fcf, 0x2009, 0x0000, 0x6838,
+	0xd0f4, 0x1904, 0x2faa, 0x080c, 0x524a, 0x1108, 0xc185, 0x6000,
+	0xd0bc, 0x0108, 0xc18d, 0x0804, 0x2faa, 0x00e6, 0x00d6, 0xa02e,
+	0x2001, 0xb535, 0x2004, 0xd0ac, 0x0130, 0xa026, 0x20a9, 0x00ff,
+	0x2071, 0xb635, 0x0030, 0x2021, 0x0080, 0x20a9, 0x007f, 0x2071,
+	0xb6b5, 0x2e04, 0xa005, 0x1130, 0x2100, 0xa406, 0x1570, 0x2428,
+	0xc5fd, 0x0458, 0x2068, 0x6f10, 0x2700, 0xa306, 0x11b0, 0x6e14,
+	0x2600, 0xa206, 0x1190, 0x2400, 0xa106, 0x1160, 0x2d60, 0xd884,
+	0x0568, 0x6004, 0xa084, 0x00ff, 0xa086, 0x0006, 0x1538, 0x2001,
+	0x4000, 0x0428, 0x2001, 0x4007, 0x0410, 0x2400, 0xa106, 0x1168,
+	0x6e14, 0x87ff, 0x1138, 0x86ff, 0x09d0, 0x2001, 0xb535, 0x2004,
+	0xd0ac, 0x19a8, 0x2001, 0x4008, 0x0090, 0x8420, 0x8e70, 0x1f04,
+	0x3dd9, 0x85ff, 0x1130, 0x2001, 0x4009, 0x0048, 0x2001, 0x0001,
+	0x0030, 0x080c, 0x4f4d, 0x1dd0, 0x6312, 0x6216, 0xa006, 0xa005,
+	0x00de, 0x00ee, 0x0005, 0x81ff, 0x1904, 0x2fcf, 0x080c, 0x3e75,
+	0x0904, 0x2fcf, 0x6837, 0x0000, 0x6838, 0xc0fd, 0x683a, 0x7824,
+	0xa005, 0x0904, 0x2fd2, 0xa096, 0x00ff, 0x0120, 0xa092, 0x0004,
+	0x1a04, 0x2fd2, 0x2010, 0x2d18, 0x080c, 0x2c4f, 0x0904, 0x2fcf,
+	0x7007, 0x0003, 0x701b, 0x3e45, 0x0005, 0x6830, 0xa086, 0x0100,
+	0x0904, 0x2fcf, 0x0804, 0x2faa, 0x7924, 0xa18c, 0xff00, 0x810f,
+	0x60d4, 0xd0ac, 0x1120, 0xa182, 0x0080, 0x0a04, 0x2fd2, 0xa182,
+	0x00ff, 0x1a04, 0x2fd2, 0x0126, 0x2091, 0x8000, 0x080c, 0x9c8a,
+	0x1188, 0xa190, 0xb635, 0x2204, 0xa065, 0x0160, 0x080c, 0x4c0b,
+	0x2001, 0xb535, 0x2004, 0xd0ac, 0x0110, 0x6017, 0x0000, 0x012e,
+	0x0804, 0x2faa, 0x012e, 0x0804, 0x2fcf, 0x080c, 0x15f8, 0x0188,
+	0xa006, 0x6802, 0x7010, 0xa005, 0x1120, 0x2d00, 0x7012, 0x7016,
+	0x0030, 0x7014, 0x6802, 0x2060, 0x2d00, 0x6006, 0x7016, 0xad80,
+	0x000d, 0x0005, 0x7924, 0x810f, 0xa18c, 0x00ff, 0x080c, 0x4fa9,
+	0x1130, 0x7e28, 0xa684, 0x3fff, 0xa082, 0x4000, 0x0208, 0xa066,
+	0x8cff, 0x0005, 0x7e24, 0x860f, 0xa18c, 0x00ff, 0x080c, 0x4fa9,
+	0x1128, 0xa6b4, 0x00ff, 0xa682, 0x4000, 0x0208, 0xa066, 0x8cff,
+	0x0005, 0x0016, 0x7110, 0x81ff, 0x0128, 0x2168, 0x6904, 0x080c,
+	0x160f, 0x0cc8, 0x7112, 0x7116, 0x001e, 0x0005, 0x2031, 0x0001,
+	0x0010, 0x2031, 0x0000, 0x2061, 0xb5d2, 0x6606, 0x6112, 0x600e,
+	0x6226, 0x632a, 0x642e, 0x6532, 0x2c10, 0x080c, 0x1643, 0x7007,
+	0x0002, 0x701b, 0x2faa, 0x0005, 0x00f6, 0x0126, 0x2091, 0x8000,
+	0x2079, 0x0000, 0x2001, 0xb590, 0x2004, 0xa005, 0x1168, 0x0e04,
+	0x3ee4, 0x7818, 0xd084, 0x1140, 0x7a22, 0x7b26, 0x7c2a, 0x781b,
+	0x0001, 0x2091, 0x4080, 0x0408, 0x0016, 0x00c6, 0x00e6, 0x2071,
+	0xb582, 0x7138, 0xa182, 0x0010, 0x0218, 0x7030, 0x2060, 0x0078,
+	0x7030, 0xa0e0, 0x0004, 0xac82, 0xb5d2, 0x0210, 0x2061, 0xb592,
+	0x2c00, 0x7032, 0x81ff, 0x1108, 0x7036, 0x8108, 0x713a, 0x2262,
+	0x6306, 0x640a, 0x00ee, 0x00ce, 0x001e, 0x012e, 0x00fe, 0x0005,
+	0x00e6, 0x2071, 0xb582, 0x7038, 0xa005, 0x0570, 0x0126, 0x2091,
+	0x8000, 0x0e04, 0x3f3b, 0x00f6, 0x2079, 0x0000, 0x7818, 0xd084,
+	0x1508, 0x00c6, 0x7034, 0x2060, 0x2c04, 0x7822, 0x6004, 0x7826,
+	0x6008, 0x782a, 0x781b, 0x0001, 0x2091, 0x4080, 0x7038, 0x8001,
+	0x703a, 0xa005, 0x1130, 0x7033, 0xb592, 0x7037, 0xb592, 0x00ce,
+	0x0048, 0xac80, 0x0004, 0xa0fa, 0xb5d2, 0x0210, 0x2001, 0xb592,
+	0x7036, 0x00ce, 0x00fe, 0x012e, 0x00ee, 0x0005, 0x0026, 0x2001,
+	0xb553, 0x2004, 0xd0c4, 0x0120, 0x2011, 0x8014, 0x080c, 0x3ecc,
+	0x002e, 0x0005, 0x81ff, 0x1904, 0x2fcf, 0x0126, 0x2091, 0x8000,
+	0x6030, 0xc08d, 0xc085, 0xc0ac, 0x6032, 0x080c, 0x5acf, 0x1178,
+	0x2001, 0xb79f, 0x2003, 0x0001, 0x2001, 0xb500, 0x2003, 0x0001,
+	0xa085, 0x0001, 0x080c, 0x5b13, 0x080c, 0x5a07, 0x0010, 0x080c,
+	0x4b1f, 0x012e, 0x0804, 0x2faa, 0x7824, 0x2008, 0xa18c, 0xfffd,
+	0x1128, 0x61e0, 0xa10d, 0x61e2, 0x0804, 0x2faa, 0x0804, 0x2fd2,
+	0x81ff, 0x1904, 0x2fcf, 0x6000, 0xa086, 0x0003, 0x1904, 0x2fcf,
+	0x2001, 0xb553, 0x2004, 0xd0ac, 0x1904, 0x2fcf, 0x080c, 0x3e9a,
+	0x0904, 0x2fd2, 0x6004, 0xa084, 0x00ff, 0xa086, 0x0006, 0x1120,
+	0x7828, 0xa005, 0x0904, 0x2faa, 0x00c6, 0x080c, 0x3e75, 0x00ce,
+	0x0904, 0x2fcf, 0x6837, 0x0000, 0x6833, 0x0000, 0x6838, 0xc0fd,
+	0x683a, 0x080c, 0x9e6b, 0x0904, 0x2fcf, 0x7007, 0x0003, 0x701b,
+	0x3faa, 0x0005, 0x6830, 0xa086, 0x0100, 0x0904, 0x2fcf, 0x0804,
+	0x2faa, 0x2001, 0xb500, 0x2004, 0xa086, 0x0003, 0x1904, 0x2fcf,
+	0x7f24, 0x7a2c, 0x7b28, 0x7c3c, 0x7d38, 0x080c, 0x3e75, 0x0904,
+	0x2fcf, 0x2009, 0x0000, 0x2031, 0x0000, 0x7023, 0x0000, 0x702f,
+	0x0000, 0xad80, 0x0005, 0x7026, 0x20a0, 0x080c, 0x4fa9, 0x1904,
+	0x4024, 0x6004, 0xa0c4, 0x00ff, 0xa8c6, 0x0006, 0x0130, 0xa0c4,
+	0xff00, 0xa8c6, 0x0600, 0x1904, 0x4024, 0x2001, 0xb553, 0x2004,
+	0xd0ac, 0x1128, 0x080c, 0x524a, 0x1110, 0xd79c, 0x05e8, 0xd794,
+	0x1110, 0xd784, 0x0158, 0xac80, 0x0006, 0x2098, 0x3400, 0x20a9,
+	0x0004, 0x53a3, 0x080c, 0x3ce7, 0xd794, 0x0148, 0xac80, 0x000a,
+	0x2098, 0x3400, 0x20a9, 0x0004, 0x53a3, 0x080c, 0x3ce7, 0x21a2,
+	0xd794, 0x01d8, 0xac80, 0x0000, 0x2098, 0x94a0, 0x20a9, 0x0002,
+	0x53a3, 0xac80, 0x0003, 0x20a6, 0x94a0, 0xac80, 0x0004, 0x2098,
+	0x3400, 0x20a9, 0x0002, 0x53a3, 0x080c, 0x3cd9, 0xac80, 0x0026,
+	0x2098, 0x20a9, 0x0002, 0x53a3, 0x0008, 0x94a0, 0xd794, 0x0110,
+	0xa6b0, 0x000b, 0xa6b0, 0x0005, 0x8108, 0x2001, 0xb535, 0x2004,
+	0xd0ac, 0x0118, 0xa186, 0x0100, 0x0040, 0xd78c, 0x0120, 0xa186,
+	0x0100, 0x0170, 0x0018, 0xa186, 0x007e, 0x0150, 0xd794, 0x0118,
+	0xa686, 0x0020, 0x0010, 0xa686, 0x0028, 0x0150, 0x0804, 0x3fcd,
+	0x86ff, 0x1120, 0x7120, 0x810b, 0x0804, 0x2faa, 0x702f, 0x0001,
+	0x711e, 0x7020, 0xa600, 0x7022, 0x772a, 0x2061, 0xb5d2, 0x6007,
+	0x0000, 0x6612, 0x7024, 0x600e, 0x6226, 0x632a, 0x642e, 0x6532,
+	0x2c10, 0x080c, 0x1643, 0x7007, 0x0002, 0x701b, 0x4060, 0x0005,
+	0x702c, 0xa005, 0x1170, 0x711c, 0x7024, 0x20a0, 0x7728, 0x2031,
+	0x0000, 0x2061, 0xb5d2, 0x6224, 0x6328, 0x642c, 0x6530, 0x0804,
+	0x3fcd, 0x7120, 0x810b, 0x0804, 0x2faa, 0x2029, 0x007e, 0x7924,
+	0x7a28, 0x7b2c, 0x7c38, 0xa184, 0xff00, 0x8007, 0xa0e2, 0x0020,
+	0x0a04, 0x2fd2, 0xa502, 0x0a04, 0x2fd2, 0xa184, 0x00ff, 0xa0e2,
+	0x0020, 0x0a04, 0x2fd2, 0xa502, 0x0a04, 0x2fd2, 0xa284, 0xff00,
+	0x8007, 0xa0e2, 0x0020, 0x0a04, 0x2fd2, 0xa502, 0x0a04, 0x2fd2,
+	0xa284, 0x00ff, 0xa0e2, 0x0020, 0x0a04, 0x2fd2, 0xa502, 0x0a04,
+	0x2fd2, 0xa384, 0xff00, 0x8007, 0xa0e2, 0x0020, 0x0a04, 0x2fd2,
+	0xa502, 0x0a04, 0x2fd2, 0xa384, 0x00ff, 0xa0e2, 0x0020, 0x0a04,
+	0x2fd2, 0xa502, 0x0a04, 0x2fd2, 0xa484, 0xff00, 0x8007, 0xa0e2,
+	0x0020, 0x0a04, 0x2fd2, 0xa502, 0x0a04, 0x2fd2, 0xa484, 0x00ff,
+	0xa0e2, 0x0020, 0x0a04, 0x2fd2, 0xa502, 0x0a04, 0x2fd2, 0x2061,
+	0xb7b9, 0x6102, 0x6206, 0x630a, 0x640e, 0x0804, 0x2faa, 0x0006,
+	0x2001, 0xb553, 0x2004, 0xd0cc, 0x000e, 0x0005, 0x0006, 0x2001,
+	0xb572, 0x2004, 0xd0bc, 0x000e, 0x0005, 0x6168, 0x7a24, 0x6300,
+	0x82ff, 0x1118, 0x7926, 0x0804, 0x2faa, 0x83ff, 0x1904, 0x2fd2,
+	0x2001, 0xfff0, 0xa200, 0x1a04, 0x2fd2, 0x2019, 0xffff, 0x606c,
+	0xa302, 0xa200, 0x0a04, 0x2fd2, 0x7926, 0x626a, 0x0804, 0x2faa,
+	0x2001, 0xb500, 0x2004, 0xa086, 0x0003, 0x1904, 0x2fcf, 0x7c28,
+	0x7d24, 0x7e38, 0x7f2c, 0x080c, 0x3e75, 0x0904, 0x2fcf, 0x2009,
+	0x0000, 0x2019, 0x0000, 0x7023, 0x0000, 0x702f, 0x0000, 0xad80,
+	0x0003, 0x7026, 0x20a0, 0xa1e0, 0xb635, 0x2c64, 0x8cff, 0x01b8,
+	0x6004, 0xa084, 0x00ff, 0xa086, 0x0006, 0x0130, 0x6004, 0xa084,
+	0xff00, 0xa086, 0x0600, 0x1158, 0x6014, 0x20a2, 0x94a0, 0x6010,
+	0x8007, 0xa105, 0x8007, 0x20a2, 0x94a0, 0xa398, 0x0002, 0x8108,
+	0xa182, 0x00ff, 0x0120, 0xa386, 0x002a, 0x0148, 0x08e0, 0x83ff,
+	0x1120, 0x7120, 0x810c, 0x0804, 0x2faa, 0x702f, 0x0001, 0x711e,
+	0x7020, 0xa300, 0x7022, 0x2061, 0xb5d2, 0x6007, 0x0000, 0x6312,
+	0x7024, 0x600e, 0x6426, 0x652a, 0x662e, 0x6732, 0x2c10, 0x080c,
+	0x1643, 0x7007, 0x0002, 0x701b, 0x4156, 0x0005, 0x702c, 0xa005,
+	0x1168, 0x711c, 0x7024, 0x20a0, 0x2019, 0x0000, 0x2061, 0xb5d2,
+	0x6424, 0x6528, 0x662c, 0x6730, 0x0804, 0x4113, 0x7120, 0x810c,
+	0x0804, 0x2faa, 0x81ff, 0x1904, 0x2fcf, 0x60d4, 0xd0ac, 0x1118,
+	0xd09c, 0x0904, 0x2fcf, 0x080c, 0x3e75, 0x0904, 0x2fcf, 0x7924,
+	0x7a2c, 0x7b28, 0x7c3c, 0x7d38, 0x080c, 0x3eb6, 0x701b, 0x4181,
+	0x0005, 0x00d6, 0xade8, 0x000d, 0x6828, 0xa0be, 0x7000, 0x0148,
+	0xa0be, 0x7100, 0x0130, 0xa0be, 0x7200, 0x0118, 0x00de, 0x0804,
+	0x2fd2, 0x6820, 0x6924, 0x080c, 0x281d, 0x1510, 0x080c, 0x4f4d,
+	0x11f8, 0x7122, 0x6612, 0x6516, 0x6e18, 0x00c6, 0x080c, 0x3e75,
+	0x01b8, 0x080c, 0x3e75, 0x01a0, 0x00ce, 0x00de, 0x6837, 0x0000,
+	0x6838, 0xc0fd, 0x683a, 0x6823, 0x0000, 0x6804, 0x2068, 0x080c,
+	0x9dbe, 0x0904, 0x2fcf, 0x7007, 0x0003, 0x701b, 0x41bb, 0x0005,
+	0x00de, 0x0804, 0x2fcf, 0x7120, 0x080c, 0x2d97, 0x6820, 0xa086,
+	0x8001, 0x0904, 0x2fcf, 0x2d00, 0x701e, 0x6804, 0xa080, 0x0002,
+	0x0006, 0x20a9, 0x002a, 0x2098, 0x20a0, 0x080c, 0x4b8f, 0x000e,
+	0xade8, 0x000d, 0x6a08, 0x6b0c, 0x6c10, 0x6d14, 0x2061, 0xb5d2,
+	0x6007, 0x0000, 0x6e00, 0x6f28, 0xa7c6, 0x7000, 0x1108, 0x0018,
+	0xa7c6, 0x7100, 0x1140, 0xa6c2, 0x0004, 0x0a04, 0x2fd2, 0x2009,
+	0x0004, 0x0804, 0x3eb9, 0xa7c6, 0x7200, 0x1904, 0x2fd2, 0xa6c2,
+	0x0054, 0x0a04, 0x2fd2, 0x600e, 0x6013, 0x002a, 0x6226, 0x632a,
+	0x642e, 0x6532, 0x2c10, 0x080c, 0x1643, 0x7007, 0x0002, 0x701b,
+	0x4202, 0x0005, 0x701c, 0x2068, 0x6804, 0xa080, 0x0001, 0x2004,
+	0xa080, 0x0002, 0x0006, 0x20a9, 0x002a, 0x2098, 0x20a0, 0x080c,
+	0x4b8f, 0x000e, 0x2009, 0x002a, 0x2061, 0xb5d2, 0x6224, 0x6328,
+	0x642c, 0x6530, 0x0804, 0x3eb9, 0x81ff, 0x1904, 0x2fcf, 0x792c,
+	0x2001, 0xb7a0, 0x2102, 0x080c, 0x3e8a, 0x0904, 0x2fd2, 0x080c,
+	0x506f, 0x0904, 0x2fcf, 0x0126, 0x2091, 0x8000, 0x080c, 0x51a1,
+	0x012e, 0x0804, 0x2faa, 0x7824, 0xd08c, 0x1118, 0xd084, 0x0904,
+	0x3a46, 0x080c, 0x3e9a, 0x0904, 0x2fd2, 0x00c6, 0x080c, 0x3e75,
+	0x00ce, 0x1120, 0x2009, 0x0002, 0x0804, 0x2fcf, 0x6004, 0xa084,
+	0x00ff, 0xa086, 0x0006, 0x0128, 0xa08e, 0x0004, 0x0110, 0xa08e,
+	0x0005, 0x15b8, 0x7824, 0xd08c, 0x0120, 0x6000, 0xc08c, 0x6002,
+	0x0030, 0x2001, 0xb553, 0x2004, 0xd0b4, 0x0904, 0x3a82, 0x7824,
+	0xa084, 0xff00, 0xa08e, 0x7e00, 0x0904, 0x3a82, 0xa08e, 0x7f00,
+	0x0904, 0x3a82, 0xa08e, 0x8000, 0x0904, 0x3a82, 0x6000, 0xd08c,
+	0x1904, 0x3a82, 0x6837, 0x0000, 0x6838, 0xc0fd, 0x683a, 0x080c,
+	0x9dda, 0x1120, 0x2009, 0x0003, 0x0804, 0x2fcf, 0x7007, 0x0003,
+	0x701b, 0x4283, 0x0005, 0x080c, 0x3e9a, 0x0904, 0x2fd2, 0x0804,
+	0x3a82, 0x2009, 0xb531, 0x210c, 0x81ff, 0x0120, 0x2009, 0x0001,
+	0x0804, 0x2fcf, 0x2001, 0xb500, 0x2004, 0xa086, 0x0003, 0x0120,
+	0x2009, 0x0007, 0x0804, 0x2fcf, 0x2001, 0xb553, 0x2004, 0xd0ac,
+	0x0120, 0x2009, 0x0008, 0x0804, 0x2fcf, 0x609c, 0xd0a4, 0x1118,
+	0xd0ac, 0x1904, 0x3a82, 0x6837, 0x0000, 0x6833, 0x0000, 0x6838,
+	0xc0fd, 0x683a, 0x080c, 0x9e6b, 0x1120, 0x2009, 0x0003, 0x0804,
+	0x2fcf, 0x7007, 0x0003, 0x701b, 0x42be, 0x0005, 0x6830, 0xa086,
+	0x0100, 0x1120, 0x2009, 0x0004, 0x0804, 0x2fcf, 0x080c, 0x3e9a,
+	0x0904, 0x2fd2, 0x0804, 0x4252, 0x81ff, 0x2009, 0x0001, 0x1904,
+	0x2fcf, 0x6000, 0xa086, 0x0003, 0x2009, 0x0007, 0x1904, 0x2fcf,
+	0x2001, 0xb553, 0x2004, 0xd0ac, 0x2009, 0x0008, 0x1904, 0x2fcf,
+	0x080c, 0x3e9a, 0x0904, 0x2fd2, 0x6004, 0xa084, 0x00ff, 0xa086,
+	0x0006, 0x2009, 0x0009, 0x1904, 0x2fcf, 0x00c6, 0x080c, 0x3e75,
+	0x00ce, 0x2009, 0x0002, 0x0904, 0x2fcf, 0x6837, 0x0000, 0x6833,
+	0x0000, 0x6838, 0xc0fd, 0x683a, 0x7928, 0xa194, 0xff00, 0xa18c,
+	0x00ff, 0xa006, 0x82ff, 0x1128, 0xc0ed, 0x6952, 0x792c, 0x6956,
+	0x0048, 0xa28e, 0x0100, 0x1904, 0x2fd2, 0xc0e5, 0x6853, 0x0000,
+	0x6857, 0x0000, 0x683e, 0x080c, 0xa028, 0x2009, 0x0003, 0x0904,
+	0x2fcf, 0x7007, 0x0003, 0x701b, 0x431e, 0x0005, 0x6830, 0xa086,
+	0x0100, 0x2009, 0x0004, 0x0904, 0x2fcf, 0x0804, 0x2faa, 0x81ff,
+	0x2009, 0x0001, 0x1904, 0x2fcf, 0x6000, 0xa086, 0x0003, 0x2009,
+	0x0007, 0x1904, 0x2fcf, 0x080c, 0x3e9a, 0x0904, 0x2fd2, 0x6004,
+	0xa084, 0x00ff, 0xa086, 0x0006, 0x2009, 0x0009, 0x1904, 0x2fcf,
+	0x00c6, 0x080c, 0x3e75, 0x00ce, 0x2009, 0x0002, 0x0904, 0x2fcf,
+	0xad80, 0x000f, 0x2009, 0x0008, 0x7a2c, 0x7b28, 0x7c3c, 0x7d38,
+	0x080c, 0x3eb6, 0x701b, 0x4355, 0x0005, 0x00d6, 0xade8, 0x000f,
+	0x6800, 0xa086, 0x0500, 0x1140, 0x6804, 0xa005, 0x1128, 0x6808,
+	0xa084, 0xff00, 0x1108, 0x0018, 0x00de, 0x1904, 0x2fd2, 0x00de,
+	0x6837, 0x0000, 0x6833, 0x0000, 0x6838, 0xc0fd, 0x683a, 0x00c6,
+	0x080c, 0x3e9a, 0x1118, 0x00ce, 0x0804, 0x2fd2, 0x080c, 0xa077,
+	0x2009, 0x0003, 0x00ce, 0x0904, 0x2fcf, 0x7007, 0x0003, 0x701b,
+	0x4382, 0x0005, 0x6830, 0xa086, 0x0100, 0x2009, 0x0004, 0x0904,
+	0x2fcf, 0x0804, 0x2faa, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804,
+	0x2fcf, 0x6000, 0xa086, 0x0003, 0x0120, 0x2009, 0x0007, 0x0804,
+	0x2fcf, 0x7e24, 0x860f, 0xa18c, 0x00ff, 0xa6b4, 0x00ff, 0x080c,
+	0x4fa9, 0x1904, 0x2fd2, 0xa186, 0x007f, 0x0150, 0x6004, 0xa084,
+	0x00ff, 0xa086, 0x0006, 0x0120, 0x2009, 0x0009, 0x0804, 0x2fcf,
+	0x00c6, 0x080c, 0x3e75, 0x00ce, 0x1120, 0x2009, 0x0002, 0x0804,
+	0x2fcf, 0x6837, 0x0000, 0x6838, 0xc0fd, 0x683a, 0x2001, 0x0100,
+	0x8007, 0x680a, 0x080c, 0x9df5, 0x1120, 0x2009, 0x0003, 0x0804,
+	0x2fcf, 0x7007, 0x0003, 0x701b, 0x43ce, 0x0005, 0x6808, 0x8007,
+	0xa086, 0x0100, 0x1120, 0x2009, 0x0004, 0x0804, 0x2fcf, 0x68b0,
+	0x6836, 0x6810, 0x8007, 0xa084, 0x00ff, 0x800c, 0x6814, 0x8007,
+	0xa084, 0x00ff, 0x8004, 0xa080, 0x0002, 0xa108, 0xad80, 0x0004,
+	0x7a2c, 0x7b28, 0x7c3c, 0x7d38, 0x0804, 0x3eb9, 0x080c, 0x3e75,
+	0x1120, 0x2009, 0x0002, 0x0804, 0x2fcf, 0x7924, 0xa194, 0xff00,
+	0xa18c, 0x00ff, 0x8217, 0x82ff, 0x0110, 0x0804, 0x2fd2, 0x2009,
+	0x001a, 0x7a2c, 0x7b28, 0x7c3c, 0x7d38, 0x080c, 0x3eb6, 0x701b,
+	0x440a, 0x0005, 0x2001, 0xb52a, 0x2003, 0x0001, 0xad80, 0x000d,
+	0x2098, 0x20a9, 0x001a, 0x20a1, 0xb7c6, 0x53a3, 0x0804, 0x2faa,
+	0x080c, 0x3e75, 0x1120, 0x2009, 0x0002, 0x0804, 0x2fcf, 0x7924,
+	0xa194, 0xff00, 0xa18c, 0x00ff, 0x8217, 0x82ff, 0x0110, 0x0804,
+	0x2fd2, 0x2099, 0xb7c6, 0x20a0, 0x20a9, 0x001a, 0x53a3, 0x2009,
+	0x001a, 0x7a2c, 0x7b28, 0x7c3c, 0x7d38, 0x0804, 0x3eb9, 0x7824,
+	0xa08a, 0x1000, 0x1a04, 0x2fd2, 0x0126, 0x2091, 0x8000, 0x8003,
+	0x800b, 0x810b, 0xa108, 0x00c6, 0x2061, 0xb7f3, 0x6142, 0x00ce,
+	0x012e, 0x0804, 0x2faa, 0x00c6, 0x080c, 0x5acf, 0x1188, 0x2001,
+	0xb79f, 0x2003, 0x0001, 0x2001, 0xb500, 0x2003, 0x0001, 0xa085,
+	0x0001, 0x080c, 0x5b13, 0x080c, 0x5a07, 0x080c, 0x1515, 0x0038,
+	0x2061, 0xb500, 0x6030, 0xc09d, 0x6032, 0x080c, 0x4b1f, 0x00ce,
+	0x0005, 0x0126, 0x2091, 0x8000, 0x00c6, 0x2061, 0xb7f3, 0x7924,
+	0x6152, 0x614e, 0x6057, 0x0000, 0x604b, 0x0009, 0x7838, 0x606a,
+	0x783c, 0x6066, 0x7828, 0x6062, 0x782c, 0x605e, 0x2061, 0xb7a1,
+	0x2001, 0xb808, 0x600e, 0x6013, 0x0001, 0x6017, 0x0002, 0x6007,
+	0x0000, 0x6037, 0x0000, 0x00ce, 0x012e, 0x0804, 0x2faa, 0x0126,
+	0x00c6, 0x00e6, 0x2061, 0x0100, 0x2071, 0xb500, 0x6044, 0xd0a4,
+	0x11b0, 0xd084, 0x0118, 0x080c, 0x4606, 0x0068, 0xd08c, 0x0118,
+	0x080c, 0x4527, 0x0040, 0xd094, 0x0118, 0x080c, 0x44f8, 0x0018,
+	0xd09c, 0x0108, 0x0061, 0x00ee, 0x00ce, 0x012e, 0x0005, 0x0016,
+	0x6128, 0xd19c, 0x1110, 0xc19d, 0x612a, 0x001e, 0x0ca0, 0x624c,
+	0xa286, 0xf0f0, 0x1150, 0x6048, 0xa086, 0xf0f0, 0x0130, 0x624a,
+	0x6043, 0x0090, 0x6043, 0x0010, 0x0490, 0xa294, 0xff00, 0xa296,
+	0xf700, 0x0178, 0x7134, 0xd1a4, 0x1160, 0x6240, 0xa295, 0x0100,
+	0x6242, 0xa294, 0x0010, 0x0128, 0x2009, 0x00f7, 0x080c, 0x4baf,
+	0x00f0, 0x6040, 0xa084, 0x0010, 0xa085, 0x0140, 0x6042, 0x6043,
+	0x0000, 0x707b, 0x0000, 0x7097, 0x0001, 0x70bb, 0x0000, 0x70d7,
+	0x0000, 0x2009, 0xbcc0, 0x200b, 0x0000, 0x708b, 0x0000, 0x707f,
+	0x000a, 0x2009, 0x000a, 0x2011, 0x4ad5, 0x080c, 0x6a22, 0x0005,
+	0x0156, 0x2001, 0xb574, 0x2004, 0xd08c, 0x0110, 0x7053, 0xffff,
+	0x707c, 0xa005, 0x1510, 0x2011, 0x4ad5, 0x080c, 0x699c, 0x6040,
+	0xa094, 0x0010, 0xa285, 0x0020, 0x6042, 0x20a9, 0x00c8, 0x6044,
+	0xd08c, 0x1168, 0x1f04, 0x450f, 0x6242, 0x708f, 0x0000, 0x6040,
+	0xa094, 0x0010, 0xa285, 0x0080, 0x6042, 0x6242, 0x0030, 0x6242,
+	0x708f, 0x0000, 0x7083, 0x0000, 0x0000, 0x015e, 0x0005, 0x7080,
+	0xa08a, 0x0003, 0x1210, 0x0023, 0x0010, 0x080c, 0x1515, 0x0005,
+	0x4533, 0x4583, 0x4605, 0x00f6, 0x7083, 0x0001, 0x20e1, 0xa000,
+	0xe000, 0x20e1, 0x8700, 0x080c, 0x2470, 0x20e1, 0x9080, 0x20e1,
+	0x4000, 0x2079, 0xbb00, 0x207b, 0x2200, 0x7807, 0x00ef, 0x780b,
+	0x0000, 0x780f, 0x00ef, 0x7813, 0x0138, 0x7817, 0x0000, 0x781b,
+	0x0000, 0x781f, 0x0000, 0x7823, 0xffff, 0x7827, 0xffff, 0x782b,
+	0x0000, 0x782f, 0x0000, 0x2079, 0xbb0c, 0x207b, 0x1101, 0x7807,
+	0x0000, 0x2099, 0xb505, 0x20a1, 0xbb0e, 0x20a9, 0x0004, 0x53a3,
+	0x2079, 0xbb12, 0x207b, 0x0000, 0x7807, 0x0000, 0x2099, 0xbb00,
+	0x20a1, 0x020b, 0x20a9, 0x0014, 0x53a6, 0x60c3, 0x000c, 0x600f,
+	0x0000, 0x080c, 0x4b06, 0x00fe, 0x7087, 0x0000, 0x6043, 0x0008,
+	0x6043, 0x0000, 0x0005, 0x00d6, 0x7084, 0x7087, 0x0000, 0xa025,
+	0x0904, 0x45ed, 0x6020, 0xd0b4, 0x1904, 0x45eb, 0x7194, 0x81ff,
+	0x0904, 0x45db, 0xa486, 0x000c, 0x1904, 0x45e6, 0xa480, 0x0018,
+	0x8004, 0x20a8, 0x2011, 0xbb80, 0x2019, 0xbb00, 0x220c, 0x2304,
+	0xa106, 0x11b8, 0x8210, 0x8318, 0x1f04, 0x459e, 0x6043, 0x0004,
+	0x608b, 0xbc94, 0x608f, 0xf0f0, 0x6043, 0x0006, 0x7083, 0x0002,
+	0x708f, 0x0002, 0x2009, 0x07d0, 0x2011, 0x4adc, 0x080c, 0x6a22,
+	0x0490, 0x2069, 0xbb80, 0x6930, 0xa18e, 0x1101, 0x1538, 0x6834,
+	0xa005, 0x1520, 0x6900, 0xa18c, 0x00ff, 0x1118, 0x6804, 0xa005,
+	0x0190, 0x2011, 0xbb8e, 0x2019, 0xb505, 0x20a9, 0x0004, 0x220c,
+	0x2304, 0xa102, 0x0230, 0x1190, 0x8210, 0x8318, 0x1f04, 0x45cf,
+	0x0068, 0x7097, 0x0000, 0x20e1, 0x9080, 0x20e1, 0x4000, 0x2099,
+	0xbb80, 0x20a1, 0x020b, 0x20a9, 0x0014, 0x53a6, 0x6043, 0x0008,
+	0x6043, 0x0000, 0x0010, 0x00de, 0x0005, 0x6040, 0xa085, 0x0100,
+	0x6042, 0x6020, 0xd0b4, 0x1db8, 0x60c3, 0x000c, 0x2011, 0xb7ea,
+	0x2013, 0x0000, 0x7087, 0x0000, 0x20e1, 0x9080, 0x60a3, 0x0056,
+	0x60a7, 0x9575, 0x080c, 0x7d71, 0x0c30, 0x0005, 0x708c, 0xa08a,
+	0x001d, 0x1210, 0x0023, 0x0010, 0x080c, 0x1515, 0x0005, 0x4639,
+	0x4648, 0x4670, 0x4689, 0x46ad, 0x46d5, 0x46f9, 0x472a, 0x474e,
+	0x4776, 0x47ad, 0x47d5, 0x47f1, 0x4807, 0x4827, 0x483a, 0x4842,
+	0x4872, 0x4896, 0x48be, 0x48e2, 0x4913, 0x4950, 0x497f, 0x499b,
+	0x49da, 0x49fa, 0x4a13, 0x4a14, 0x00c6, 0x2061, 0xb500, 0x6003,
+	0x0007, 0x2061, 0x0100, 0x6004, 0xa084, 0xfff9, 0x6006, 0x00ce,
+	0x0005, 0x608b, 0xbc94, 0x608f, 0xf0f0, 0x6043, 0x0002, 0x708f,
+	0x0001, 0x2009, 0x07d0, 0x2011, 0x4adc, 0x080c, 0x6a22, 0x0005,
+	0x00f6, 0x7084, 0xa086, 0x0014, 0x1508, 0x6043, 0x0000, 0x6020,
+	0xd0b4, 0x11e0, 0x2079, 0xbb80, 0x7a30, 0xa296, 0x1102, 0x11a0,
+	0x7834, 0xa005, 0x1188, 0x7a38, 0xd2fc, 0x0128, 0x70b8, 0xa005,
+	0x1110, 0x70bb, 0x0001, 0x2011, 0x4adc, 0x080c, 0x699c, 0x708f,
+	0x0010, 0x080c, 0x4842, 0x0010, 0x080c, 0x4b1f, 0x00fe, 0x0005,
+	0x708f, 0x0003, 0x6043, 0x0004, 0x2011, 0x4adc, 0x080c, 0x699c,
+	0x080c, 0x4b97, 0x20a3, 0x1102, 0x20a3, 0x0000, 0x20a9, 0x000a,
+	0x20a3, 0x0000, 0x1f04, 0x4680, 0x60c3, 0x0014, 0x080c, 0x4b06,
+	0x0005, 0x00f6, 0x7084, 0xa005, 0x01f0, 0x2011, 0x4adc, 0x080c,
+	0x699c, 0xa086, 0x0014, 0x11a8, 0x2079, 0xbb80, 0x7a30, 0xa296,
+	0x1102, 0x1178, 0x7834, 0xa005, 0x1160, 0x7a38, 0xd2fc, 0x0128,
+	0x70b8, 0xa005, 0x1110, 0x70bb, 0x0001, 0x708f, 0x0004, 0x0029,
+	0x0010, 0x080c, 0x4b1f, 0x00fe, 0x0005, 0x708f, 0x0005, 0x080c,
+	0x4b97, 0x20a3, 0x1103, 0x20a3, 0x0000, 0x3430, 0x2011, 0xbb8e,
+	0x080c, 0x4be8, 0x1160, 0x7078, 0xa005, 0x1148, 0x7150, 0xa186,
+	0xffff, 0x0128, 0x080c, 0x4aa0, 0x0110, 0x080c, 0x4bc6, 0x20a9,
+	0x0008, 0x2298, 0x26a0, 0x53a6, 0x20a3, 0x0000, 0x20a3, 0x0000,
+	0x60c3, 0x0014, 0x080c, 0x4b06, 0x0005, 0x00f6, 0x7084, 0xa005,
+	0x01f0, 0x2011, 0x4adc, 0x080c, 0x699c, 0xa086, 0x0014, 0x11a8,
+	0x2079, 0xbb80, 0x7a30, 0xa296, 0x1103, 0x1178, 0x7834, 0xa005,
+	0x1160, 0x7a38, 0xd2fc, 0x0128, 0x70b8, 0xa005, 0x1110, 0x70bb,
+	0x0001, 0x708f, 0x0006, 0x0029, 0x0010, 0x080c, 0x4b1f, 0x00fe,
+	0x0005, 0x708f, 0x0007, 0x080c, 0x4b97, 0x20a3, 0x1104, 0x20a3,
+	0x0000, 0x3430, 0x2011, 0xbb8e, 0x080c, 0x4be8, 0x11a8, 0x7078,
+	0xa005, 0x1190, 0x7158, 0xa186, 0xffff, 0x0170, 0xa180, 0x2dc4,
+	0x200d, 0xa18c, 0xff00, 0x810f, 0x080c, 0x4aa0, 0x0128, 0x080c,
+	0x40d6, 0x0110, 0x080c, 0x2867, 0x20a9, 0x0008, 0x2298, 0x26a0,
+	0x53a6, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x60c3, 0x0014, 0x080c,
+	0x4b06, 0x0005, 0x00f6, 0x7084, 0xa005, 0x01f0, 0x2011, 0x4adc,
+	0x080c, 0x699c, 0xa086, 0x0014, 0x11a8, 0x2079, 0xbb80, 0x7a30,
+	0xa296, 0x1104, 0x1178, 0x7834, 0xa005, 0x1160, 0x7a38, 0xd2fc,
+	0x0128, 0x70b8, 0xa005, 0x1110, 0x70bb, 0x0001, 0x708f, 0x0008,
+	0x0029, 0x0010, 0x080c, 0x4b1f, 0x00fe, 0x0005, 0x708f, 0x0009,
+	0x080c, 0x4b97, 0x20a3, 0x1105, 0x20a3, 0x0100, 0x3430, 0x080c,
+	0x4be8, 0x1150, 0x7078, 0xa005, 0x1138, 0x080c, 0x4a15, 0x1170,
+	0xa085, 0x0001, 0x080c, 0x2867, 0x20a9, 0x0008, 0x2099, 0xbb8e,
+	0x26a0, 0x53a6, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x60c3, 0x0014,
+	0x080c, 0x4b06, 0x0010, 0x080c, 0x462c, 0x0005, 0x00f6, 0x7084,
+	0xa005, 0x0588, 0x2011, 0x4adc, 0x080c, 0x699c, 0xa086, 0x0014,
+	0x1540, 0x2079, 0xbb80, 0x7a30, 0xa296, 0x1105, 0x1510, 0x7834,
+	0x2011, 0x0100, 0xa21e, 0x1160, 0x7a38, 0xd2fc, 0x0128, 0x70b8,
+	0xa005, 0x1110, 0x70bb, 0x0001, 0x708f, 0x000a, 0x00b1, 0x0098,
+	0xa005, 0x1178, 0x7a38, 0xd2fc, 0x0128, 0x70b8, 0xa005, 0x1110,
+	0x70bb, 0x0001, 0x708b, 0x0000, 0x708f, 0x000e, 0x080c, 0x4827,
+	0x0010, 0x080c, 0x4b1f, 0x00fe, 0x0005, 0x708f, 0x000b, 0x2011,
+	0xbb0e, 0x22a0, 0x20a9, 0x0040, 0x2019, 0xffff, 0x43a4, 0x20a9,
+	0x0002, 0x2009, 0x0000, 0x41a4, 0x080c, 0x4b97, 0x20a3, 0x1106,
+	0x20a3, 0x0000, 0x080c, 0x4be8, 0x0118, 0x2013, 0x0000, 0x0020,
+	0x7054, 0xa085, 0x0100, 0x2012, 0x2298, 0x20a9, 0x0042, 0x53a6,
+	0x60c3, 0x0084, 0x080c, 0x4b06, 0x0005, 0x00f6, 0x7084, 0xa005,
+	0x01b0, 0x2011, 0x4adc, 0x080c, 0x699c, 0xa086, 0x0084, 0x1168,
+	0x2079, 0xbb80, 0x7a30, 0xa296, 0x1106, 0x1138, 0x7834, 0xa005,
+	0x1120, 0x708f, 0x000c, 0x0029, 0x0010, 0x080c, 0x4b1f, 0x00fe,
+	0x0005, 0x708f, 0x000d, 0x080c, 0x4b97, 0x20a3, 0x1107, 0x20a3,
+	0x0000, 0x2099, 0xbb8e, 0x20a9, 0x0040, 0x53a6, 0x20a3, 0x0000,
+	0x20a3, 0x0000, 0x60c3, 0x0084, 0x080c, 0x4b06, 0x0005, 0x00f6,
+	0x7084, 0xa005, 0x01d0, 0x2011, 0x4adc, 0x080c, 0x699c, 0xa086,
+	0x0084, 0x1188, 0x2079, 0xbb80, 0x7a30, 0xa296, 0x1107, 0x1158,
+	0x7834, 0xa005, 0x1140, 0x708b, 0x0001, 0x080c, 0x4b89, 0x708f,
+	0x000e, 0x0029, 0x0010, 0x080c, 0x4b1f, 0x00fe, 0x0005, 0x708f,
+	0x000f, 0x7087, 0x0000, 0x608b, 0xbc85, 0x608f, 0xb5b5, 0x6043,
+	0x0005, 0x6043, 0x0004, 0x2009, 0x07d0, 0x2011, 0x4adc, 0x080c,
+	0x6990, 0x0005, 0x7084, 0xa005, 0x0120, 0x2011, 0x4adc, 0x080c,
+	0x699c, 0x0005, 0x708f, 0x0011, 0x080c, 0x4be8, 0x11a0, 0x7170,
+	0x81ff, 0x0188, 0x2009, 0x0000, 0x7074, 0xa084, 0x00ff, 0x080c,
+	0x281d, 0xa186, 0x007e, 0x0138, 0xa186, 0x0080, 0x0120, 0x2011,
+	0xbb8e, 0x080c, 0x4aa0, 0x20e1, 0x9080, 0x20e1, 0x4000, 0x2099,
+	0xbb80, 0x20a1, 0x020b, 0x7484, 0xa480, 0x0018, 0xa080, 0x0007,
+	0xa084, 0x03f8, 0x8004, 0x20a8, 0x53a6, 0x60c3, 0x0014, 0x080c,
+	0x4b06, 0x0005, 0x00f6, 0x7084, 0xa005, 0x01f0, 0x2011, 0x4adc,
+	0x080c, 0x699c, 0xa086, 0x0014, 0x11a8, 0x2079, 0xbb80, 0x7a30,
+	0xa296, 0x1103, 0x1178, 0x7834, 0xa005, 0x1160, 0x7a38, 0xd2fc,
+	0x0128, 0x70b8, 0xa005, 0x1110, 0x70bb, 0x0001, 0x708f, 0x0012,
+	0x0029, 0x0010, 0x080c, 0x4b1f, 0x00fe, 0x0005, 0x708f, 0x0013,
+	0x080c, 0x4ba3, 0x20a3, 0x1103, 0x20a3, 0x0000, 0x3430, 0x2011,
+	0xbb8e, 0x080c, 0x4be8, 0x1160, 0x7078, 0xa005, 0x1148, 0x7150,
+	0xa186, 0xffff, 0x0128, 0x080c, 0x4aa0, 0x0110, 0x080c, 0x4bc6,
+	0x20a9, 0x0008, 0x2298, 0x26a0, 0x53a6, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x60c3, 0x0014, 0x080c, 0x4b06, 0x0005, 0x00f6, 0x7084,
+	0xa005, 0x01f0, 0x2011, 0x4adc, 0x080c, 0x699c, 0xa086, 0x0014,
+	0x11a8, 0x2079, 0xbb80, 0x7a30, 0xa296, 0x1104, 0x1178, 0x7834,
+	0xa005, 0x1160, 0x7a38, 0xd2fc, 0x0128, 0x70b8, 0xa005, 0x1110,
+	0x70bb, 0x0001, 0x708f, 0x0014, 0x0029, 0x0010, 0x080c, 0x4b1f,
+	0x00fe, 0x0005, 0x708f, 0x0015, 0x080c, 0x4ba3, 0x20a3, 0x1104,
+	0x20a3, 0x0000, 0x3430, 0x2011, 0xbb8e, 0x080c, 0x4be8, 0x11a8,
+	0x7078, 0xa005, 0x1190, 0x7158, 0xa186, 0xffff, 0x0170, 0xa180,
+	0x2dc4, 0x200d, 0xa18c, 0xff00, 0x810f, 0x080c, 0x4aa0, 0x0128,
+	0x080c, 0x40d6, 0x0110, 0x080c, 0x2867, 0x20a9, 0x0008, 0x2298,
+	0x26a0, 0x53a6, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x60c3, 0x0014,
+	0x080c, 0x4b06, 0x0005, 0x00f6, 0x7084, 0xa005, 0x05b8, 0x2011,
+	0x4adc, 0x080c, 0x699c, 0xa086, 0x0014, 0x1570, 0x2079, 0xbb80,
+	0x7a30, 0xa296, 0x1105, 0x1540, 0x7834, 0x2011, 0x0100, 0xa21e,
+	0x1148, 0x7a38, 0xd2fc, 0x0128, 0x70b8, 0xa005, 0x1110, 0x70bb,
+	0x0001, 0x0060, 0xa005, 0x11c0, 0x7a38, 0xd2fc, 0x0128, 0x70b8,
+	0xa005, 0x1110, 0x70bb, 0x0001, 0x708b, 0x0000, 0x7a38, 0xd2f4,
+	0x0138, 0x2001, 0xb574, 0x2004, 0xd0a4, 0x1110, 0x70d7, 0x0008,
+	0x708f, 0x0016, 0x0029, 0x0010, 0x080c, 0x4b1f, 0x00fe, 0x0005,
+	0x20e1, 0x9080, 0x20e1, 0x4000, 0x2099, 0xbb80, 0x20a1, 0x020b,
+	0x20a9, 0x000e, 0x53a6, 0x3430, 0x2011, 0xbb8e, 0x708f, 0x0017,
+	0x080c, 0x4be8, 0x1150, 0x7078, 0xa005, 0x1138, 0x080c, 0x4a15,
+	0x1170, 0xa085, 0x0001, 0x080c, 0x2867, 0x20a9, 0x0008, 0x2099,
+	0xbb8e, 0x26a0, 0x53a6, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x60c3,
+	0x0014, 0x080c, 0x4b06, 0x0010, 0x080c, 0x462c, 0x0005, 0x00f6,
+	0x7084, 0xa005, 0x01b0, 0x2011, 0x4adc, 0x080c, 0x699c, 0xa086,
+	0x0084, 0x1168, 0x2079, 0xbb80, 0x7a30, 0xa296, 0x1106, 0x1138,
+	0x7834, 0xa005, 0x1120, 0x708f, 0x0018, 0x0029, 0x0010, 0x080c,
+	0x4b1f, 0x00fe, 0x0005, 0x708f, 0x0019, 0x080c, 0x4ba3, 0x20a3,
+	0x1106, 0x20a3, 0x0000, 0x3430, 0x2099, 0xbb8e, 0x2039, 0xbb0e,
+	0x27a0, 0x20a9, 0x0040, 0x53a3, 0x080c, 0x4be8, 0x11e8, 0x2728,
+	0x2514, 0x8207, 0xa084, 0x00ff, 0x8000, 0x2018, 0xa294, 0x00ff,
+	0x8007, 0xa205, 0x202a, 0x7054, 0x2310, 0x8214, 0xa2a0, 0xbb0e,
+	0x2414, 0xa38c, 0x0001, 0x0118, 0xa294, 0xff00, 0x0018, 0xa294,
+	0x00ff, 0x8007, 0xa215, 0x2222, 0x2798, 0x26a0, 0x20a9, 0x0040,
+	0x53a6, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x60c3, 0x0084, 0x080c,
+	0x4b06, 0x0005, 0x00f6, 0x7084, 0xa005, 0x01d0, 0x2011, 0x4adc,
+	0x080c, 0x699c, 0xa086, 0x0084, 0x1188, 0x2079, 0xbb80, 0x7a30,
+	0xa296, 0x1107, 0x1158, 0x7834, 0xa005, 0x1140, 0x708b, 0x0001,
+	0x080c, 0x4b89, 0x708f, 0x001a, 0x0029, 0x0010, 0x080c, 0x4b1f,
+	0x00fe, 0x0005, 0x708f, 0x001b, 0x20e1, 0x9080, 0x20e1, 0x4000,
+	0x2099, 0xbb80, 0x20a1, 0x020b, 0x7484, 0xa480, 0x0018, 0xa080,
+	0x0007, 0xa084, 0x03f8, 0x8004, 0x20a8, 0x53a6, 0x60c3, 0x0084,
+	0x080c, 0x4b06, 0x0005, 0x0005, 0x0005, 0x0086, 0x0096, 0x2029,
+	0xb553, 0x252c, 0x20a9, 0x0008, 0x2041, 0xbb0e, 0x28a0, 0x2099,
+	0xbb8e, 0x53a3, 0x20a9, 0x0008, 0x2011, 0x0007, 0xd5d4, 0x0110,
+	0x2011, 0x0000, 0x2800, 0xa200, 0x200c, 0xa1a6, 0xffff, 0x1148,
+	0xd5d4, 0x0110, 0x8210, 0x0008, 0x8211, 0x1f04, 0x4a2a, 0x0804,
+	0x4a98, 0x82ff, 0x1160, 0xd5d4, 0x0120, 0xa1a6, 0x3fff, 0x0d90,
+	0x0020, 0xa1a6, 0x3fff, 0x0904, 0x4a98, 0xa18d, 0xc000, 0x20a9,
+	0x0010, 0x2019, 0x0001, 0xd5d4, 0x0110, 0x2019, 0x0010, 0x2120,
+	0xd5d4, 0x0110, 0x8423, 0x0008, 0x8424, 0x1240, 0xd5d4, 0x0110,
+	0x8319, 0x0008, 0x8318, 0x1f04, 0x4a50, 0x04d0, 0x23a8, 0x2021,
+	0x0001, 0x8426, 0x8425, 0x1f04, 0x4a62, 0x2328, 0x8529, 0xa2be,
+	0x0007, 0x0158, 0x0006, 0x2039, 0x0007, 0x2200, 0xa73a, 0x000e,
+	0x27a8, 0xa5a8, 0x0010, 0x1f04, 0x4a71, 0x7552, 0xa5c8, 0x2dc4,
+	0x292d, 0xa5ac, 0x00ff, 0x7576, 0x6532, 0x6536, 0x0016, 0x2508,
+	0x080c, 0x2847, 0x001e, 0x60e7, 0x0000, 0x65ea, 0x2018, 0x2304,
+	0xa405, 0x201a, 0x707b, 0x0001, 0x26a0, 0x2898, 0x20a9, 0x0008,
+	0x53a6, 0x20a3, 0x0000, 0x20a3, 0x0000, 0xa085, 0x0001, 0x0028,
+	0xa006, 0x0018, 0xa006, 0x080c, 0x1515, 0x009e, 0x008e, 0x0005,
+	0x2118, 0x2021, 0x0000, 0x2001, 0x0007, 0xa39a, 0x0010, 0x0218,
+	0x8420, 0x8001, 0x0cd0, 0x2118, 0x84ff, 0x0120, 0xa39a, 0x0010,
+	0x8421, 0x1de0, 0x2021, 0x0001, 0x83ff, 0x0118, 0x8423, 0x8319,
+	0x1de8, 0xa238, 0x2704, 0xa42c, 0x11b8, 0xa405, 0x203a, 0x7152,
+	0xa1a0, 0x2dc4, 0x242d, 0xa5ac, 0x00ff, 0x7576, 0x6532, 0x6536,
+	0x0016, 0x2508, 0x080c, 0x2847, 0x001e, 0x60e7, 0x0000, 0x65ea,
+	0x707b, 0x0001, 0xa084, 0x0000, 0x0005, 0x00e6, 0x2071, 0xb500,
+	0x707f, 0x0000, 0x00ee, 0x0005, 0x00e6, 0x00f6, 0x2079, 0x0100,
+	0x2071, 0x0140, 0x080c, 0x7d7a, 0x7004, 0xa084, 0x4000, 0x0120,
+	0x7003, 0x1000, 0x7003, 0x0000, 0x0126, 0x2091, 0x8000, 0x2071,
+	0xb523, 0x2073, 0x0000, 0x7840, 0x0026, 0x0016, 0x2009, 0x00f7,
+	0x080c, 0x4baf, 0x001e, 0xa094, 0x0010, 0xa285, 0x0080, 0x7842,
+	0x7a42, 0x002e, 0x012e, 0x00fe, 0x00ee, 0x0005, 0x0126, 0x2091,
+	0x8000, 0x2011, 0xb7ea, 0x2013, 0x0000, 0x7087, 0x0000, 0x012e,
+	0x20e1, 0x9080, 0x60a3, 0x0056, 0x60a7, 0x9575, 0x080c, 0x7d71,
+	0x2009, 0x07d0, 0x2011, 0x4adc, 0x080c, 0x6a22, 0x0005, 0x0016,
+	0x0026, 0x00c6, 0x0126, 0x2091, 0x8000, 0x2011, 0x0003, 0x080c,
+	0x8075, 0x2011, 0x0002, 0x080c, 0x807f, 0x080c, 0x7f59, 0x0036,
+	0x2019, 0x0000, 0x080c, 0x7fe4, 0x003e, 0x2009, 0x00f7, 0x080c,
+	0x4baf, 0x2061, 0xb7f3, 0x601b, 0x0000, 0x601f, 0x0000, 0x2061,
+	0xb500, 0x6003, 0x0001, 0x2061, 0x0100, 0x6043, 0x0090, 0x6043,
+	0x0010, 0x2009, 0x002d, 0x2011, 0x4b54, 0x080c, 0x6990, 0x012e,
+	0x00ce, 0x002e, 0x001e, 0x0005, 0x00e6, 0x0006, 0x0126, 0x2091,
+	0x8000, 0x2071, 0x0100, 0x080c, 0x7d7a, 0x2071, 0x0140, 0x7004,
+	0xa084, 0x4000, 0x0120, 0x7003, 0x1000, 0x7003, 0x0000, 0x080c,
+	0x5ad7, 0x01a8, 0x080c, 0x5af5, 0x1190, 0x2001, 0xb79e, 0x2003,
+	0xaaaa, 0x0016, 0x080c, 0x28eb, 0x2001, 0xb78f, 0x2102, 0x001e,
+	0x2001, 0xb79f, 0x2003, 0x0000, 0x080c, 0x5a07, 0x0030, 0x2001,
+	0x0001, 0x080c, 0x27c3, 0x080c, 0x4b1f, 0x012e, 0x000e, 0x00ee,
+	0x0005, 0x20a9, 0x0040, 0x20a1, 0xbcc0, 0x2099, 0xbb8e, 0x3304,
+	0x8007, 0x20a2, 0x9398, 0x94a0, 0x1f04, 0x4b8f, 0x0005, 0x20e1,
+	0x9080, 0x20e1, 0x4000, 0x2099, 0xbb00, 0x20a1, 0x020b, 0x20a9,
+	0x000c, 0x53a6, 0x0005, 0x20e1, 0x9080, 0x20e1, 0x4000, 0x2099,
+	0xbb80, 0x20a1, 0x020b, 0x20a9, 0x000c, 0x53a6, 0x0005, 0x00c6,
+	0x0006, 0x2061, 0x0100, 0x810f, 0x2001, 0xb531, 0x2004, 0xa005,
+	0x1138, 0x2001, 0xb515, 0x2004, 0xa084, 0x00ff, 0xa105, 0x0010,
+	0xa185, 0x00f7, 0x604a, 0x000e, 0x00ce, 0x0005, 0x0016, 0x0046,
+	0x2001, 0xb553, 0x2004, 0xd0a4, 0x0158, 0xa006, 0x2020, 0x2009,
+	0x002a, 0x080c, 0xb0e8, 0x2001, 0xb50c, 0x200c, 0xc195, 0x2102,
+	0x2019, 0x002a, 0x2009, 0x0000, 0x080c, 0x2c6f, 0x004e, 0x001e,
+	0x0005, 0x080c, 0x4b1f, 0x708f, 0x0000, 0x7087, 0x0000, 0x0005,
+	0x0006, 0x2001, 0xb50c, 0x2004, 0xd09c, 0x0100, 0x000e, 0x0005,
+	0x0006, 0x0016, 0x0126, 0x2091, 0x8000, 0x2001, 0x0101, 0x200c,
+	0xa18d, 0x0006, 0x2102, 0x012e, 0x001e, 0x000e, 0x0005, 0x0156,
+	0x20a9, 0x00ff, 0x2009, 0xb635, 0xa006, 0x200a, 0x8108, 0x1f04,
+	0x4c05, 0x015e, 0x0005, 0x00d6, 0x0036, 0x0156, 0x0136, 0x0146,
+	0x2069, 0xb552, 0xa006, 0x6002, 0x6007, 0x0707, 0x600a, 0x600e,
+	0x6012, 0xa198, 0x2dc4, 0x231d, 0xa39c, 0x00ff, 0x6316, 0x20a9,
+	0x0004, 0xac98, 0x0006, 0x23a0, 0x40a4, 0x20a9, 0x0004, 0xac98,
+	0x000a, 0x23a0, 0x40a4, 0x603e, 0x6042, 0x604e, 0x6052, 0x6056,
+	0x605a, 0x605e, 0x6062, 0x6066, 0x606a, 0x606e, 0x6072, 0x6076,
+	0x607a, 0x607e, 0x6082, 0x6086, 0x608a, 0x608e, 0x6092, 0x6096,
+	0x609a, 0x609e, 0x60ae, 0x61a2, 0x00d6, 0x60a4, 0xa06d, 0x0110,
+	0x080c, 0x160f, 0x60a7, 0x0000, 0x60a8, 0xa06d, 0x0110, 0x080c,
+	0x160f, 0x60ab, 0x0000, 0x00de, 0xa006, 0x604a, 0x6810, 0x603a,
+	0x680c, 0x6046, 0x6814, 0xa084, 0x00ff, 0x6042, 0x014e, 0x013e,
+	0x015e, 0x003e, 0x00de, 0x0005, 0x0126, 0x2091, 0x8000, 0x6944,
+	0x6e48, 0xa684, 0x3fff, 0xa082, 0x4000, 0x1a04, 0x4d1a, 0xa18c,
+	0xff00, 0x810f, 0xa182, 0x00ff, 0x1a04, 0x4d1f, 0x2001, 0xb50c,
+	0x2004, 0xa084, 0x0003, 0x01c0, 0x2001, 0xb50c, 0x2004, 0xd084,
+	0x1904, 0x4d02, 0xa188, 0xb635, 0x2104, 0xa065, 0x0904, 0x4d02,
+	0x6004, 0xa084, 0x00ff, 0xa08e, 0x0006, 0x1904, 0x4d02, 0x6000,
+	0xd0c4, 0x0904, 0x4d02, 0x0068, 0xa188, 0xb635, 0x2104, 0xa065,
+	0x0904, 0x4ce6, 0x6004, 0xa084, 0x00ff, 0xa08e, 0x0006, 0x1904,
+	0x4ceb, 0x60a4, 0xa00d, 0x0118, 0x080c, 0x51d4, 0x05d0, 0x60a8,
+	0xa00d, 0x0188, 0x080c, 0x521f, 0x1170, 0x694c, 0xd1fc, 0x1118,
+	0x080c, 0x4ede, 0x0448, 0x080c, 0x4e8d, 0x694c, 0xd1ec, 0x1520,
+	0x080c, 0x50c6, 0x0408, 0x694c, 0xa184, 0xa000, 0x0178, 0xd1ec,
+	0x0140, 0xd1fc, 0x0118, 0x080c, 0x50d5, 0x0028, 0x080c, 0x50d5,
+	0x0028, 0xd1fc, 0x0118, 0x080c, 0x4e8d, 0x0070, 0x6050, 0xa00d,
+	0x0130, 0x2d00, 0x200a, 0x6803, 0x0000, 0x6052, 0x0028, 0x2d00,
+	0x6052, 0x604e, 0x6803, 0x0000, 0x080c, 0x6caa, 0xa006, 0x012e,
+	0x0005, 0x2001, 0x0005, 0x2009, 0x0000, 0x04e8, 0x2001, 0x0028,
+	0x2009, 0x0000, 0x04c0, 0xa082, 0x0006, 0x12a0, 0x2001, 0xb535,
+	0x2004, 0xd0ac, 0x1160, 0x60a0, 0xd0bc, 0x1148, 0x6100, 0xd1fc,
+	0x0904, 0x4ca1, 0x2001, 0x0029, 0x2009, 0x1000, 0x0420, 0x2001,
+	0x0028, 0x00a8, 0x2009, 0xb50c, 0x210c, 0xd18c, 0x0118, 0x2001,
+	0x0004, 0x0068, 0xd184, 0x0118, 0x2001, 0x0004, 0x0040, 0x2001,
+	0x0029, 0x6100, 0xd1fc, 0x0118, 0x2009, 0x1000, 0x0060, 0x2009,
+	0x0000, 0x0048, 0x2001, 0x0029, 0x2009, 0x0000, 0x0020, 0x2001,
+	0x0029, 0x2009, 0x0000, 0xa005, 0x012e, 0x0005, 0x00e6, 0x0126,
+	0x2091, 0x8000, 0x6844, 0x8007, 0xa084, 0x00ff, 0x2008, 0xa182,
+	0x00ff, 0x1a04, 0x4d79, 0xa188, 0xb635, 0x2104, 0xa065, 0x01c0,
+	0x6004, 0xa084, 0x00ff, 0xa08e, 0x0006, 0x11a8, 0x2c70, 0x080c,
+	0x85c7, 0x05e8, 0x2e00, 0x601a, 0x2d00, 0x6012, 0x600b, 0xffff,
+	0x601f, 0x000a, 0x2009, 0x0003, 0x080c, 0x864c, 0xa006, 0x0460,
+	0x2001, 0x0028, 0x0440, 0xa082, 0x0006, 0x1298, 0x2001, 0xb535,
+	0x2004, 0xd0ac, 0x1158, 0x60a0, 0xd0bc, 0x1140, 0x6100, 0xd1fc,
+	0x09e8, 0x2001, 0x0029, 0x2009, 0x1000, 0x00a8, 0x2001, 0x0028,
+	0x0090, 0x2009, 0xb50c, 0x210c, 0xd18c, 0x0118, 0x2001, 0x0004,
+	0x0050, 0xd184, 0x0118, 0x2001, 0x0004, 0x0028, 0x2001, 0x0029,
+	0x0010, 0x2001, 0x0029, 0xa005, 0x012e, 0x00ee, 0x0005, 0x2001,
+	0x002c, 0x0cc8, 0x00f6, 0x00e6, 0x0126, 0x2091, 0x8000, 0x2011,
+	0x0000, 0x2079, 0xb500, 0x6944, 0xa18c, 0xff00, 0x810f, 0xa182,
+	0x00ff, 0x1a04, 0x4e44, 0x080c, 0x4fa9, 0x11a0, 0x6004, 0xa084,
+	0x00ff, 0xa082, 0x0006, 0x1270, 0x6864, 0xa0c6, 0x006f, 0x0150,
+	0x2001, 0xb535, 0x2004, 0xd0ac, 0x1904, 0x4e2d, 0x60a0, 0xd0bc,
+	0x1904, 0x4e2d, 0x6864, 0xa0c6, 0x006f, 0x0118, 0x2008, 0x0804,
+	0x4df6, 0x6968, 0x2140, 0xa18c, 0xff00, 0x810f, 0x78d4, 0xd0ac,
+	0x1118, 0xa182, 0x0080, 0x06d0, 0xa182, 0x00ff, 0x16b8, 0x6a70,
+	0x6b6c, 0x7870, 0xa306, 0x1160, 0x7874, 0xa24e, 0x1118, 0x2208,
+	0x2310, 0x0460, 0xa9cc, 0xff00, 0x1118, 0x2208, 0x2310, 0x0430,
+	0x080c, 0x3dc5, 0x2c70, 0x0550, 0x2009, 0x0000, 0x2011, 0x0000,
+	0xa0c6, 0x4000, 0x1160, 0x0006, 0x2e60, 0x080c, 0x524a, 0x1108,
+	0xc185, 0x7000, 0xd0bc, 0x0108, 0xc18d, 0x000e, 0x0088, 0xa0c6,
+	0x4007, 0x1110, 0x2408, 0x0060, 0xa0c6, 0x4008, 0x1118, 0x2708,
+	0x2610, 0x0030, 0xa0c6, 0x4009, 0x1108, 0x0010, 0x2001, 0x4006,
+	0x6866, 0x696a, 0x6a6e, 0x2001, 0x0030, 0x0450, 0x080c, 0x85c7,
+	0x1138, 0x2001, 0x4005, 0x2009, 0x0003, 0x2011, 0x0000, 0x0c80,
+	0x2e00, 0x601a, 0x080c, 0xa027, 0x2d00, 0x6012, 0x601f, 0x0001,
+	0x6838, 0xd88c, 0x0108, 0xc0f5, 0x683a, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x2c9c, 0x012e, 0x2001, 0x0000, 0x080c, 0x4eeb, 0x2001,
+	0x0002, 0x080c, 0x4efd, 0x2009, 0x0002, 0x080c, 0x864c, 0xa006,
+	0xa005, 0x012e, 0x00ee, 0x00fe, 0x0005, 0x2001, 0x0028, 0x2009,
+	0x0000, 0x0cb0, 0x2009, 0xb50c, 0x210c, 0xd18c, 0x0118, 0x2001,
+	0x0004, 0x0038, 0xd184, 0x0118, 0x2001, 0x0004, 0x0010, 0x2001,
+	0x0029, 0x2009, 0x0000, 0x0c20, 0x2001, 0x0029, 0x2009, 0x0000,
+	0x08f8, 0x6944, 0x6e48, 0xa684, 0x3fff, 0xa082, 0x4000, 0x16b8,
+	0xa18c, 0xff00, 0x810f, 0xa182, 0x00ff, 0x12e0, 0xa188, 0xb635,
+	0x2104, 0xa065, 0x01b8, 0x6004, 0xa084, 0x00ff, 0xa08e, 0x0006,
+	0x11b0, 0x684c, 0xd0ec, 0x0120, 0x080c, 0x50d5, 0x0431, 0x0030,
+	0x0421, 0x684c, 0xd0fc, 0x0110, 0x080c, 0x50c6, 0x080c, 0x5113,
+	0xa006, 0x00c8, 0x2001, 0x0028, 0x2009, 0x0000, 0x00a0, 0xa082,
+	0x0006, 0x1240, 0x6100, 0xd1fc, 0x0d20, 0x2001, 0x0029, 0x2009,
+	0x1000, 0x0048, 0x2001, 0x0029, 0x2009, 0x0000, 0x0020, 0x2001,
+	0x0029, 0x2009, 0x0000, 0xa005, 0x0005, 0x0126, 0x2091, 0x8000,
+	0x6050, 0xa00d, 0x0138, 0x2d00, 0x200a, 0x6803, 0x0000, 0x6052,
+	0x012e, 0x0005, 0x2d00, 0x6052, 0x604e, 0x6803, 0x0000, 0x0cc0,
+	0x0126, 0x2091, 0x8000, 0x604c, 0xa005, 0x0170, 0x00e6, 0x2071,
+	0xb7e0, 0x7004, 0xa086, 0x0002, 0x0168, 0x00ee, 0x604c, 0x6802,
+	0x2d00, 0x604e, 0x012e, 0x0005, 0x2d00, 0x6052, 0x604e, 0x6803,
+	0x0000, 0x0cc0, 0x701c, 0xac06, 0x1d80, 0x604c, 0x2070, 0x7000,
+	0x6802, 0x2d00, 0x7002, 0x00ee, 0x012e, 0x0005, 0x0126, 0x2091,
+	0x8000, 0x604c, 0xa06d, 0x0130, 0x6800, 0xa005, 0x1108, 0x6052,
+	0x604e, 0xad05, 0x012e, 0x0005, 0x604c, 0xa06d, 0x0130, 0x6800,
+	0xa005, 0x1108, 0x6052, 0x604e, 0xad05, 0x0005, 0x6803, 0x0000,
+	0x6084, 0xa00d, 0x0120, 0x2d00, 0x200a, 0x6086, 0x0005, 0x2d00,
+	0x6086, 0x6082, 0x0cd8, 0x0126, 0x00c6, 0x0026, 0x2091, 0x8000,
+	0x6218, 0x2260, 0x6200, 0xa005, 0x0110, 0xc285, 0x0008, 0xc284,
+	0x6202, 0x002e, 0x00ce, 0x012e, 0x0005, 0x0126, 0x00c6, 0x2091,
+	0x8000, 0x6218, 0x2260, 0x6204, 0x0006, 0xa086, 0x0006, 0x1180,
+	0x609c, 0xd0ac, 0x0168, 0x2001, 0xb553, 0x2004, 0xd0a4, 0x0140,
+	0xa284, 0xff00, 0x8007, 0xa086, 0x0007, 0x1110, 0x2011, 0x0600,
+	0x000e, 0xa294, 0xff00, 0xa215, 0x6206, 0x0006, 0xa086, 0x0006,
+	0x1128, 0x6290, 0x82ff, 0x1110, 0x080c, 0x1515, 0x000e, 0x00ce,
+	0x012e, 0x0005, 0x0126, 0x00c6, 0x2091, 0x8000, 0x6218, 0x2260,
+	0x6204, 0x0006, 0xa086, 0x0006, 0x1178, 0x609c, 0xd0a4, 0x0160,
+	0x2001, 0xb553, 0x2004, 0xd0ac, 0x1138, 0xa284, 0x00ff, 0xa086,
+	0x0007, 0x1110, 0x2011, 0x0006, 0x000e, 0xa294, 0x00ff, 0x8007,
+	0xa215, 0x6206, 0x00ce, 0x012e, 0x0005, 0x0026, 0xa182, 0x00ff,
+	0x0218, 0xa085, 0x0001, 0x00b0, 0xa190, 0xb635, 0x2204, 0xa065,
+	0x1180, 0x0016, 0x00d6, 0x080c, 0x15df, 0x2d60, 0x00de, 0x001e,
+	0x0d80, 0x2c00, 0x2012, 0x60a7, 0x0000, 0x60ab, 0x0000, 0x080c,
+	0x4c0b, 0xa006, 0x002e, 0x0005, 0x0126, 0x2091, 0x8000, 0x0026,
+	0xa182, 0x00ff, 0x0218, 0xa085, 0x0001, 0x0480, 0x00d6, 0xa190,
+	0xb635, 0x2204, 0xa06d, 0x0540, 0x2013, 0x0000, 0x00d6, 0x00c6,
+	0x2d60, 0x60a4, 0xa06d, 0x0110, 0x080c, 0x160f, 0x60a8, 0xa06d,
+	0x0110, 0x080c, 0x160f, 0x00ce, 0x00de, 0x00d6, 0x00c6, 0x68ac,
+	0x2060, 0x8cff, 0x0168, 0x600c, 0x0006, 0x6010, 0x2068, 0x080c,
+	0x9c5a, 0x0110, 0x080c, 0x161f, 0x080c, 0x861d, 0x00ce, 0x0c88,
+	0x00ce, 0x00de, 0x080c, 0x160f, 0x00de, 0xa006, 0x002e, 0x012e,
+	0x0005, 0x0016, 0xa182, 0x00ff, 0x0218, 0xa085, 0x0001, 0x0030,
+	0xa188, 0xb635, 0x2104, 0xa065, 0x0dc0, 0xa006, 0x001e, 0x0005,
+	0x00d6, 0x0156, 0x0136, 0x0146, 0x600b, 0x0000, 0x600f, 0x0000,
+	0x6000, 0xc08c, 0x6002, 0x080c, 0x5acf, 0x1558, 0x60a0, 0xa086,
+	0x007e, 0x2069, 0xbb90, 0x0130, 0x2001, 0xb535, 0x2004, 0xd0ac,
+	0x1500, 0x0098, 0x2d04, 0xd0e4, 0x01e0, 0x00d6, 0x2069, 0xbb8e,
+	0x00c6, 0x2061, 0xb7b2, 0x6810, 0x2062, 0x6814, 0x6006, 0x6818,
+	0x600a, 0x681c, 0x600e, 0x00ce, 0x00de, 0x8d69, 0x2d04, 0x2069,
+	0x0140, 0xa005, 0x1110, 0x2001, 0x0001, 0x6886, 0x2069, 0xb500,
+	0x68a6, 0x2069, 0xbb8e, 0x6808, 0x605e, 0x6810, 0x6062, 0x6138,
+	0xa10a, 0x0208, 0x603a, 0x6814, 0x6066, 0x2099, 0xbb96, 0xac88,
+	0x000a, 0x21a0, 0x20a9, 0x0004, 0x53a3, 0x2099, 0xbb9a, 0xac88,
+	0x0006, 0x21a0, 0x20a9, 0x0004, 0x53a3, 0x2069, 0xbbae, 0x6808,
+	0x606a, 0x690c, 0x616e, 0x6810, 0x6072, 0x6818, 0x6076, 0x60a0,
+	0xa086, 0x007e, 0x1120, 0x2069, 0xbb8e, 0x690c, 0x616e, 0xa182,
+	0x0211, 0x1218, 0x2009, 0x0008, 0x0400, 0xa182, 0x0259, 0x1218,
+	0x2009, 0x0007, 0x00d0, 0xa182, 0x02c1, 0x1218, 0x2009, 0x0006,
+	0x00a0, 0xa182, 0x0349, 0x1218, 0x2009, 0x0005, 0x0070, 0xa182,
+	0x0421, 0x1218, 0x2009, 0x0004, 0x0040, 0xa182, 0x0581, 0x1218,
+	0x2009, 0x0003, 0x0010, 0x2009, 0x0002, 0x6192, 0x014e, 0x013e,
+	0x015e, 0x00de, 0x0005, 0x0016, 0x0026, 0x00e6, 0x2071, 0xbb8d,
+	0x2e04, 0x6896, 0x2071, 0xbb8e, 0x7004, 0x689a, 0x701c, 0x689e,
+	0x6a00, 0x2009, 0xb572, 0x210c, 0xd0bc, 0x0120, 0xd1ec, 0x0110,
+	0xc2ad, 0x0008, 0xc2ac, 0xd0c4, 0x0120, 0xd1e4, 0x0110, 0xc2bd,
+	0x0008, 0xc2bc, 0x6a02, 0x00ee, 0x002e, 0x001e, 0x0005, 0x00d6,
+	0x0126, 0x2091, 0x8000, 0x60a4, 0xa06d, 0x01c0, 0x6900, 0x81ff,
+	0x1540, 0x6a04, 0xa282, 0x0010, 0x1648, 0xad88, 0x0004, 0x20a9,
+	0x0010, 0x2104, 0xa086, 0xffff, 0x0128, 0x8108, 0x1f04, 0x5081,
+	0x080c, 0x1515, 0x260a, 0x8210, 0x6a06, 0x0098, 0x080c, 0x15f8,
+	0x01a8, 0x2d00, 0x60a6, 0x6803, 0x0000, 0xad88, 0x0004, 0x20a9,
+	0x0010, 0x200b, 0xffff, 0x8108, 0x1f04, 0x5099, 0x6807, 0x0001,
+	0x6e12, 0xa085, 0x0001, 0x012e, 0x00de, 0x0005, 0xa006, 0x0cd8,
+	0x0126, 0x2091, 0x8000, 0x00d6, 0x60a4, 0xa00d, 0x01a0, 0x2168,
+	0x6800, 0xa005, 0x1160, 0x080c, 0x51d4, 0x1168, 0x200b, 0xffff,
+	0x6804, 0xa08a, 0x0002, 0x0218, 0x8001, 0x6806, 0x0020, 0x080c,
+	0x160f, 0x60a7, 0x0000, 0x00de, 0x012e, 0x0005, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x5232, 0x0010, 0x080c, 0x4e8d, 0x080c, 0x514c,
+	0x1dd8, 0x080c, 0x5113, 0x012e, 0x0005, 0x00d6, 0x0126, 0x2091,
+	0x8000, 0x60a8, 0xa06d, 0x01c0, 0x6950, 0x81ff, 0x1540, 0x6a54,
+	0xa282, 0x0010, 0x1670, 0xad88, 0x0018, 0x20a9, 0x0010, 0x2104,
+	0xa086, 0xffff, 0x0128, 0x8108, 0x1f04, 0x50e7, 0x080c, 0x1515,
+	0x260a, 0x8210, 0x6a56, 0x0098, 0x080c, 0x15f8, 0x01d0, 0x2d00,
+	0x60aa, 0x6853, 0x0000, 0xad88, 0x0018, 0x20a9, 0x0010, 0x200b,
+	0xffff, 0x8108, 0x1f04, 0x50ff, 0x6857, 0x0001, 0x6e62, 0x0010,
+	0x080c, 0x4ede, 0x0089, 0x1de0, 0xa085, 0x0001, 0x012e, 0x00de,
+	0x0005, 0xa006, 0x0cd8, 0x0126, 0x2091, 0x8000, 0x080c, 0x6caa,
+	0x012e, 0x0005, 0xa01e, 0x0010, 0x2019, 0x0001, 0xa00e, 0x0126,
+	0x2091, 0x8000, 0x604c, 0x2068, 0x6000, 0xd0dc, 0x1170, 0x8dff,
+	0x01f8, 0x83ff, 0x0120, 0x6848, 0xa606, 0x0158, 0x0030, 0x683c,
+	0xa406, 0x1118, 0x6840, 0xa506, 0x0120, 0x2d08, 0x6800, 0x2068,
+	0x0c70, 0x080c, 0x811e, 0x6a00, 0x604c, 0xad06, 0x1110, 0x624e,
+	0x0018, 0xa180, 0x0000, 0x2202, 0x82ff, 0x1110, 0x6152, 0x8dff,
+	0x012e, 0x0005, 0xa01e, 0x0010, 0x2019, 0x0001, 0xa00e, 0x6080,
+	0x2068, 0x8dff, 0x01e8, 0x83ff, 0x0120, 0x6848, 0xa606, 0x0158,
+	0x0030, 0x683c, 0xa406, 0x1118, 0x6840, 0xa506, 0x0120, 0x2d08,
+	0x6800, 0x2068, 0x0c70, 0x6a00, 0x6080, 0xad06, 0x1110, 0x6282,
+	0x0018, 0xa180, 0x0000, 0x2202, 0x82ff, 0x1110, 0x6186, 0x8dff,
+	0x0005, 0xa016, 0x080c, 0x51ce, 0x1110, 0x2011, 0x0001, 0x080c,
+	0x5219, 0x1110, 0xa295, 0x0002, 0x0005, 0x080c, 0x524a, 0x0118,
+	0x080c, 0x9d0f, 0x0010, 0xa085, 0x0001, 0x0005, 0x080c, 0x524a,
+	0x0118, 0x080c, 0x9c9f, 0x0010, 0xa085, 0x0001, 0x0005, 0x080c,
+	0x524a, 0x0118, 0x080c, 0x9cf2, 0x0010, 0xa085, 0x0001, 0x0005,
+	0x080c, 0x524a, 0x0118, 0x080c, 0x9cbb, 0x0010, 0xa085, 0x0001,
+	0x0005, 0x080c, 0x524a, 0x0118, 0x080c, 0x9d2b, 0x0010, 0xa085,
+	0x0001, 0x0005, 0x0126, 0x0006, 0x00d6, 0x2091, 0x8000, 0x6080,
+	0xa06d, 0x01a0, 0x6800, 0x0006, 0x6837, 0x0103, 0x6b4a, 0x6847,
+	0x0000, 0x080c, 0x9ecc, 0x0006, 0x6000, 0xd0fc, 0x0110, 0x080c,
+	0xb389, 0x000e, 0x080c, 0x5408, 0x000e, 0x0c50, 0x6083, 0x0000,
+	0x6087, 0x0000, 0x00de, 0x000e, 0x012e, 0x0005, 0x60a4, 0xa00d,
+	0x1118, 0xa085, 0x0001, 0x0005, 0x00e6, 0x2170, 0x7000, 0xa005,
+	0x1168, 0x20a9, 0x0010, 0xae88, 0x0004, 0x2104, 0xa606, 0x0130,
+	0x8108, 0x1f04, 0x51dd, 0xa085, 0x0001, 0x0008, 0xa006, 0x00ee,
+	0x0005, 0x00d6, 0x0126, 0x2091, 0x8000, 0x60a4, 0xa06d, 0x1128,
+	0x080c, 0x15f8, 0x01a0, 0x2d00, 0x60a6, 0x6803, 0x0001, 0x6807,
+	0x0000, 0xad88, 0x0004, 0x20a9, 0x0010, 0x200b, 0xffff, 0x8108,
+	0x1f04, 0x51fd, 0xa085, 0x0001, 0x012e, 0x00de, 0x0005, 0xa006,
+	0x0cd8, 0x00d6, 0x0126, 0x2091, 0x8000, 0x60a4, 0xa06d, 0x0130,
+	0x60a7, 0x0000, 0x080c, 0x160f, 0xa085, 0x0001, 0x012e, 0x00de,
+	0x0005, 0x60a8, 0xa00d, 0x1118, 0xa085, 0x0001, 0x0005, 0x00e6,
+	0x2170, 0x7050, 0xa005, 0x1160, 0x20a9, 0x0010, 0xae88, 0x0018,
+	0x2104, 0xa606, 0x0128, 0x8108, 0x1f04, 0x5228, 0xa085, 0x0001,
+	0x00ee, 0x0005, 0x0126, 0x2091, 0x8000, 0x0c19, 0x1188, 0x200b,
+	0xffff, 0x00d6, 0x60a8, 0x2068, 0x6854, 0xa08a, 0x0002, 0x0218,
+	0x8001, 0x6856, 0x0020, 0x080c, 0x160f, 0x60ab, 0x0000, 0x00de,
+	0x012e, 0x0005, 0x609c, 0xd0a4, 0x0005, 0x00f6, 0x080c, 0x5acf,
+	0x01b0, 0x71b8, 0x81ff, 0x1198, 0x71d4, 0xd19c, 0x0180, 0x2001,
+	0x007e, 0xa080, 0xb635, 0x2004, 0xa07d, 0x0148, 0x7804, 0xa084,
+	0x00ff, 0xa086, 0x0006, 0x1118, 0x7800, 0xc0ed, 0x7802, 0x2079,
+	0xb552, 0x7804, 0xd0a4, 0x01e8, 0x0156, 0x00c6, 0x20a9, 0x007f,
+	0x2009, 0x0000, 0x0016, 0x080c, 0x4fa9, 0x1168, 0x6004, 0xa084,
+	0xff00, 0x8007, 0xa096, 0x0004, 0x0118, 0xa086, 0x0006, 0x1118,
+	0x6000, 0xc0ed, 0x6002, 0x001e, 0x8108, 0x1f04, 0x5272, 0x00ce,
+	0x015e, 0x080c, 0x5309, 0x0120, 0x2001, 0xb7b5, 0x200c, 0x0038,
+	0x2079, 0xb552, 0x7804, 0xd0a4, 0x0130, 0x2009, 0x07d0, 0x2011,
+	0x529d, 0x080c, 0x6a22, 0x00fe, 0x0005, 0x2011, 0x529d, 0x080c,
+	0x699c, 0x080c, 0x5309, 0x01f0, 0x2001, 0xb6b3, 0x2004, 0xa080,
+	0x0000, 0x200c, 0xc1ec, 0x2102, 0x2001, 0xb553, 0x2004, 0xd0a4,
+	0x0130, 0x2009, 0x07d0, 0x2011, 0x529d, 0x080c, 0x6a22, 0x00e6,
+	0x2071, 0xb500, 0x7073, 0x0000, 0x7077, 0x0000, 0x080c, 0x2ab8,
+	0x00ee, 0x04b0, 0x0156, 0x00c6, 0x20a9, 0x007f, 0x2009, 0x0000,
+	0x0016, 0x080c, 0x4fa9, 0x1530, 0x6000, 0xd0ec, 0x0518, 0x0046,
+	0x62a0, 0xa294, 0x00ff, 0x8227, 0xa006, 0x2009, 0x0029, 0x080c,
+	0xb0e8, 0x6000, 0xc0e5, 0xc0ec, 0x6002, 0x6004, 0xa084, 0x00ff,
+	0xa085, 0x0700, 0x6006, 0x2019, 0x0029, 0x080c, 0x6df5, 0x0076,
+	0x2039, 0x0000, 0x080c, 0x6d02, 0x2009, 0x0000, 0x080c, 0xae82,
+	0x007e, 0x004e, 0x001e, 0x8108, 0x1f04, 0x52c8, 0x00ce, 0x015e,
+	0x0005, 0x00c6, 0x6018, 0x2060, 0x6000, 0xc0ec, 0x6002, 0x00ce,
+	0x0005, 0x7818, 0x2004, 0xd0ac, 0x0005, 0x7818, 0x2004, 0xd0bc,
+	0x0005, 0x00f6, 0x2001, 0xb6b3, 0x2004, 0xa07d, 0x0110, 0x7800,
+	0xd0ec, 0x00fe, 0x0005, 0x0126, 0x0026, 0x2091, 0x8000, 0x0006,
+	0x62a0, 0xa290, 0xb635, 0x2204, 0xac06, 0x190c, 0x1515, 0x000e,
+	0x6200, 0xa005, 0x0110, 0xc2fd, 0x0008, 0xc2fc, 0x6202, 0x002e,
+	0x012e, 0x0005, 0x2011, 0xb535, 0x2204, 0xd0cc, 0x0138, 0x2001,
+	0xb7b3, 0x200c, 0x2011, 0x5337, 0x080c, 0x6a22, 0x0005, 0x2011,
+	0x5337, 0x080c, 0x699c, 0x2011, 0xb535, 0x2204, 0xc0cc, 0x2012,
+	0x0005, 0x2071, 0xb614, 0x7003, 0x0001, 0x7007, 0x0000, 0x7013,
+	0x0000, 0x7017, 0x0000, 0x701b, 0x0000, 0x701f, 0x0000, 0x700b,
+	0x0000, 0x704b, 0x0001, 0x704f, 0x0000, 0x705b, 0x0020, 0x705f,
+	0x0040, 0x707f, 0x0000, 0x2071, 0xb77d, 0x7003, 0xb614, 0x7007,
+	0x0000, 0x700b, 0x0000, 0x700f, 0xb75d, 0x7013, 0x0020, 0x7017,
+	0x0040, 0x7037, 0x0000, 0x0005, 0x0016, 0x00e6, 0x2071, 0xb735,
+	0xa00e, 0x7186, 0x718a, 0x7097, 0x0001, 0x2001, 0xb553, 0x2004,
+	0xd0fc, 0x1150, 0x2001, 0xb553, 0x2004, 0xa00e, 0xd09c, 0x0108,
+	0x8108, 0x7102, 0x0804, 0x53d2, 0x2001, 0xb572, 0x200c, 0xa184,
+	0x000f, 0x2009, 0xb573, 0x210c, 0x0002, 0x537a, 0x53ad, 0x53b4,
+	0x53be, 0x53c3, 0x537a, 0x537a, 0x537a, 0x539d, 0x537a, 0x537a,
+	0x537a, 0x537a, 0x537a, 0x537a, 0x537a, 0x7003, 0x0004, 0x0136,
+	0x0146, 0x0156, 0x2099, 0xb576, 0x20a1, 0xb786, 0x20a9, 0x0004,
+	0x53a3, 0x015e, 0x014e, 0x013e, 0x0428, 0x708f, 0x0005, 0x7007,
+	0x0122, 0x2001, 0x0002, 0x0030, 0x708f, 0x0002, 0x7007, 0x0121,
+	0x2001, 0x0003, 0x7002, 0x7097, 0x0001, 0x0088, 0x7007, 0x0122,
+	0x2001, 0x0002, 0x0020, 0x7007, 0x0121, 0x2001, 0x0003, 0x7002,
+	0xa006, 0x7096, 0x708e, 0xa184, 0xff00, 0x8007, 0x709a, 0xa184,
+	0x00ff, 0x7092, 0x00ee, 0x001e, 0x0005, 0x00e6, 0x2071, 0xb614,
+	0x684c, 0xa005, 0x1130, 0x7028, 0xc085, 0x702a, 0xa085, 0x0001,
+	0x0428, 0x6a60, 0x7236, 0x6b64, 0x733a, 0x6868, 0x703e, 0x7076,
+	0x686c, 0x7042, 0x707a, 0x684c, 0x702e, 0x6844, 0x7032, 0x2009,
+	0x000d, 0x200a, 0x700b, 0x0000, 0x8007, 0x8006, 0x8006, 0xa08c,
+	0x003f, 0xa084, 0xffc0, 0xa210, 0x2100, 0xa319, 0x726e, 0x7372,
+	0x7028, 0xc084, 0x702a, 0x7007, 0x0001, 0xa006, 0x00ee, 0x0005,
+	0x0156, 0x00e6, 0x0026, 0x6838, 0xd0fc, 0x1904, 0x5461, 0x6804,
+	0xa00d, 0x0188, 0x00d6, 0x2071, 0xb500, 0xa016, 0x702c, 0x2168,
+	0x6904, 0x206a, 0x8210, 0x2d00, 0x81ff, 0x1dc8, 0x702e, 0x70b4,
+	0xa200, 0x70b6, 0x00de, 0x2071, 0xb614, 0x701c, 0xa005, 0x1904,
+	0x5471, 0x20a9, 0x0032, 0x0f04, 0x546f, 0x0e04, 0x542b, 0x2071,
+	0xb735, 0x7200, 0x82ff, 0x05d8, 0x6934, 0xa186, 0x0103, 0x1904,
+	0x547f, 0x6948, 0x6844, 0xa105, 0x1540, 0x2009, 0x8020, 0x2200,
+	0x0002, 0x546f, 0x5446, 0x5497, 0x54a3, 0x546f, 0x2071, 0x0000,
+	0x20a9, 0x0032, 0x0f04, 0x546f, 0x7018, 0xd084, 0x1dd8, 0x7122,
+	0x683c, 0x7026, 0x6840, 0x702a, 0x701b, 0x0001, 0x2091, 0x4080,
+	0x2071, 0xb500, 0x702c, 0x206a, 0x2d00, 0x702e, 0x70b4, 0x8000,
+	0x70b6, 0x002e, 0x00ee, 0x015e, 0x0005, 0x6844, 0xa086, 0x0100,
+	0x1130, 0x6868, 0xa005, 0x1118, 0x2009, 0x8020, 0x0880, 0x2071,
+	0xb614, 0x2d08, 0x206b, 0x0000, 0x7010, 0x8000, 0x7012, 0x7018,
+	0xa06d, 0x711a, 0x0110, 0x6902, 0x0008, 0x711e, 0x0c10, 0xa18c,
+	0x00ff, 0xa186, 0x0017, 0x0130, 0xa186, 0x001e, 0x0118, 0xa18e,
+	0x001f, 0x1d28, 0x684c, 0xd0cc, 0x0d10, 0x6850, 0xa084, 0x00ff,
+	0xa086, 0x0001, 0x19e0, 0x2009, 0x8021, 0x0804, 0x543f, 0x7084,
+	0x8008, 0xa092, 0x001e, 0x1a98, 0x7186, 0xae90, 0x0003, 0xa210,
+	0x683c, 0x2012, 0x0078, 0x7084, 0x8008, 0xa092, 0x000f, 0x1a38,
+	0x7186, 0xae90, 0x0003, 0x8003, 0xa210, 0x683c, 0x2012, 0x8210,
+	0x6840, 0x2012, 0x7088, 0xa10a, 0x0a04, 0x5458, 0x718c, 0x7084,
+	0xa10a, 0x0a04, 0x5458, 0x2071, 0x0000, 0x7018, 0xd084, 0x1904,
+	0x5458, 0x2071, 0xb735, 0x7000, 0xa086, 0x0002, 0x1150, 0x080c,
+	0x5722, 0x2071, 0x0000, 0x701b, 0x0001, 0x2091, 0x4080, 0x0804,
+	0x5458, 0x080c, 0x574c, 0x2071, 0x0000, 0x701b, 0x0001, 0x2091,
+	0x4080, 0x0804, 0x5458, 0x0006, 0x684c, 0x0006, 0x6837, 0x0103,
+	0x20a9, 0x001c, 0xad80, 0x0011, 0x20a0, 0x2001, 0x0000, 0x40a4,
+	0x000e, 0xa084, 0x00ff, 0x684e, 0x000e, 0x684a, 0x6952, 0x0005,
+	0x2071, 0xb614, 0x7004, 0x0002, 0x54fe, 0x550f, 0x570d, 0x570e,
+	0x571b, 0x5721, 0x54ff, 0x56fe, 0x5694, 0x56ea, 0x0005, 0x0126,
+	0x2091, 0x8000, 0x0e04, 0x550e, 0x2009, 0x000d, 0x7030, 0x200a,
+	0x2091, 0x4080, 0x7007, 0x0001, 0x700b, 0x0000, 0x012e, 0x2069,
+	0xb7f3, 0x683c, 0xa005, 0x03f8, 0x11f0, 0x0126, 0x2091, 0x8000,
+	0x2069, 0x0000, 0x6934, 0x2001, 0xb620, 0x2004, 0xa10a, 0x0170,
+	0x0e04, 0x5532, 0x2069, 0x0000, 0x6818, 0xd084, 0x1158, 0x2009,
+	0x8040, 0x6922, 0x681b, 0x0001, 0x2091, 0x4080, 0x2069, 0xb7f3,
+	0x683f, 0xffff, 0x012e, 0x2069, 0xb500, 0x6848, 0x6968, 0xa102,
+	0x2069, 0xb735, 0x688a, 0x6984, 0x701c, 0xa06d, 0x0120, 0x81ff,
+	0x0904, 0x5588, 0x00a0, 0x81ff, 0x0904, 0x564e, 0x2071, 0xb735,
+	0x7184, 0x7088, 0xa10a, 0x1258, 0x7190, 0x2071, 0xb7f3, 0x7038,
+	0xa005, 0x0128, 0x1b04, 0x564e, 0x713a, 0x0804, 0x564e, 0x2071,
+	0xb735, 0x718c, 0x0126, 0x2091, 0x8000, 0x7084, 0xa10a, 0x0a04,
+	0x5669, 0x0e04, 0x560a, 0x2071, 0x0000, 0x7018, 0xd084, 0x1904,
+	0x560a, 0x2001, 0xffff, 0x2071, 0xb7f3, 0x703a, 0x2071, 0xb735,
+	0x7000, 0xa086, 0x0002, 0x1150, 0x080c, 0x5722, 0x2071, 0x0000,
+	0x701b, 0x0001, 0x2091, 0x4080, 0x0804, 0x560a, 0x080c, 0x574c,
+	0x2071, 0x0000, 0x701b, 0x0001, 0x2091, 0x4080, 0x0804, 0x560a,
+	0x2071, 0xb735, 0x7000, 0xa005, 0x0904, 0x5630, 0x6934, 0xa186,
+	0x0103, 0x1904, 0x560d, 0x684c, 0xd0bc, 0x1904, 0x5630, 0x6948,
+	0x6844, 0xa105, 0x1904, 0x5625, 0x2009, 0x8020, 0x2071, 0xb735,
+	0x7000, 0x0002, 0x5630, 0x55f0, 0x55c8, 0x55da, 0x55a7, 0x0136,
+	0x0146, 0x0156, 0x2099, 0xb576, 0x20a1, 0xb786, 0x20a9, 0x0004,
+	0x53a3, 0x015e, 0x014e, 0x013e, 0x2071, 0xb77d, 0xad80, 0x000f,
+	0x700e, 0x7013, 0x0002, 0x7007, 0x0002, 0x700b, 0x0000, 0x2e10,
+	0x080c, 0x1643, 0x2071, 0xb614, 0x7007, 0x0009, 0x0804, 0x564e,
+	0x7084, 0x8008, 0xa092, 0x001e, 0x1a04, 0x564e, 0xae90, 0x0003,
+	0xa210, 0x683c, 0x2012, 0x7186, 0x2071, 0xb614, 0x080c, 0x57a3,
+	0x0804, 0x564e, 0x7084, 0x8008, 0xa092, 0x000f, 0x1a04, 0x564e,
+	0xae90, 0x0003, 0x8003, 0xa210, 0x683c, 0x2012, 0x8210, 0x6840,
+	0x2012, 0x7186, 0x2071, 0xb614, 0x080c, 0x57a3, 0x0804, 0x564e,
+	0x0126, 0x2091, 0x8000, 0x0e04, 0x560a, 0x2071, 0x0000, 0x7018,
+	0xd084, 0x1180, 0x7122, 0x683c, 0x7026, 0x6840, 0x702a, 0x701b,
+	0x0001, 0x2091, 0x4080, 0x012e, 0x2071, 0xb614, 0x080c, 0x57a3,
+	0x0804, 0x564e, 0x012e, 0x0804, 0x564e, 0xa18c, 0x00ff, 0xa186,
+	0x0017, 0x0130, 0xa186, 0x001e, 0x0118, 0xa18e, 0x001f, 0x11c0,
+	0x684c, 0xd0cc, 0x01a8, 0x6850, 0xa084, 0x00ff, 0xa086, 0x0001,
+	0x1178, 0x2009, 0x8021, 0x0804, 0x559e, 0x6844, 0xa086, 0x0100,
+	0x1138, 0x6868, 0xa005, 0x1120, 0x2009, 0x8020, 0x0804, 0x559e,
+	0x2071, 0xb614, 0x080c, 0x57b5, 0x01c8, 0x2071, 0xb614, 0x700f,
+	0x0001, 0x6934, 0xa184, 0x00ff, 0xa086, 0x0003, 0x1130, 0x810f,
+	0xa18c, 0x00ff, 0x8101, 0x0108, 0x710e, 0x7007, 0x0003, 0x080c,
+	0x57ce, 0x7050, 0xa086, 0x0100, 0x0904, 0x570e, 0x0126, 0x2091,
+	0x8000, 0x2071, 0xb614, 0x7008, 0xa086, 0x0001, 0x1180, 0x0e04,
+	0x5667, 0x2009, 0x000d, 0x7030, 0x200a, 0x2091, 0x4080, 0x700b,
+	0x0000, 0x7004, 0xa086, 0x0006, 0x1110, 0x7007, 0x0001, 0x012e,
+	0x0005, 0x2071, 0xb614, 0x080c, 0x57b5, 0x0518, 0x2071, 0xb735,
+	0x7084, 0x700a, 0x20a9, 0x0020, 0x2099, 0xb736, 0x20a1, 0xb75d,
+	0x53a3, 0x7087, 0x0000, 0x2071, 0xb614, 0x2069, 0xb77d, 0x706c,
+	0x6826, 0x7070, 0x682a, 0x7074, 0x682e, 0x7078, 0x6832, 0x2d10,
+	0x080c, 0x1643, 0x7007, 0x0008, 0x2001, 0xffff, 0x2071, 0xb7f3,
+	0x703a, 0x012e, 0x0804, 0x564e, 0x2069, 0xb77d, 0x6808, 0xa08e,
+	0x0000, 0x0904, 0x56e9, 0xa08e, 0x0200, 0x0904, 0x56e7, 0xa08e,
+	0x0100, 0x1904, 0x56e9, 0x0126, 0x2091, 0x8000, 0x0e04, 0x56e5,
+	0x2069, 0x0000, 0x6818, 0xd084, 0x15c0, 0x702c, 0x7130, 0x8108,
+	0xa102, 0x0230, 0xa00e, 0x7034, 0x706e, 0x7038, 0x7072, 0x0048,
+	0x706c, 0xa080, 0x0040, 0x706e, 0x1220, 0x7070, 0xa081, 0x0000,
+	0x7072, 0x7132, 0x6936, 0x700b, 0x0000, 0x2001, 0xb75a, 0x2004,
+	0xa005, 0x1190, 0x6934, 0x2069, 0xb735, 0x689c, 0x699e, 0x2069,
+	0xb7f3, 0xa102, 0x1118, 0x683c, 0xa005, 0x1368, 0x2001, 0xb75b,
+	0x200c, 0x810d, 0x693e, 0x0038, 0x2009, 0x8040, 0x6922, 0x681b,
+	0x0001, 0x2091, 0x4080, 0x7007, 0x0001, 0x012e, 0x0010, 0x7007,
+	0x0005, 0x0005, 0x2001, 0xb77f, 0x2004, 0xa08e, 0x0100, 0x1128,
+	0x7007, 0x0001, 0x080c, 0x57a3, 0x0005, 0xa08e, 0x0000, 0x0de0,
+	0xa08e, 0x0200, 0x1dc8, 0x7007, 0x0005, 0x0005, 0x701c, 0xa06d,
+	0x0158, 0x080c, 0x57b5, 0x0140, 0x7007, 0x0003, 0x080c, 0x57ce,
+	0x7050, 0xa086, 0x0100, 0x0110, 0x0005, 0x0005, 0x7050, 0xa09e,
+	0x0100, 0x1118, 0x7007, 0x0004, 0x0030, 0xa086, 0x0200, 0x1110,
+	0x7007, 0x0005, 0x0005, 0x080c, 0x5771, 0x7006, 0x080c, 0x57a3,
+	0x0005, 0x0005, 0x00e6, 0x0156, 0x2071, 0xb735, 0x7184, 0x81ff,
+	0x0500, 0xa006, 0x7086, 0xae80, 0x0003, 0x2071, 0x0000, 0x21a8,
+	0x2014, 0x7226, 0x8000, 0x0f04, 0x5746, 0x2014, 0x722a, 0x8000,
+	0x0f04, 0x5746, 0x2014, 0x722e, 0x8000, 0x0f04, 0x5746, 0x2014,
+	0x723a, 0x8000, 0x0f04, 0x5746, 0x2014, 0x723e, 0xa180, 0x8030,
+	0x7022, 0x015e, 0x00ee, 0x0005, 0x00e6, 0x0156, 0x2071, 0xb735,
+	0x7184, 0x81ff, 0x01d8, 0xa006, 0x7086, 0xae80, 0x0003, 0x2071,
+	0x0000, 0x21a8, 0x2014, 0x7226, 0x8000, 0x2014, 0x722a, 0x8000,
+	0x0f04, 0x5768, 0x2014, 0x723a, 0x8000, 0x2014, 0x723e, 0x0018,
+	0x2001, 0x8020, 0x0010, 0x2001, 0x8042, 0x7022, 0x015e, 0x00ee,
+	0x0005, 0x702c, 0x7130, 0x8108, 0xa102, 0x0230, 0xa00e, 0x7034,
+	0x706e, 0x7038, 0x7072, 0x0048, 0x706c, 0xa080, 0x0040, 0x706e,
+	0x1220, 0x7070, 0xa081, 0x0000, 0x7072, 0x7132, 0x700c, 0x8001,
+	0x700e, 0x1180, 0x0126, 0x2091, 0x8000, 0x0e04, 0x579d, 0x2001,
+	0x000d, 0x2102, 0x2091, 0x4080, 0x2001, 0x0001, 0x700b, 0x0000,
+	0x012e, 0x0005, 0x2001, 0x0007, 0x0005, 0x2001, 0x0006, 0x700b,
+	0x0001, 0x012e, 0x0005, 0x701c, 0xa06d, 0x0170, 0x0126, 0x2091,
+	0x8000, 0x7010, 0x8001, 0x7012, 0x2d04, 0x701e, 0xa005, 0x1108,
+	0x701a, 0x012e, 0x080c, 0x160f, 0x0005, 0x2019, 0x000d, 0x2304,
+	0x230c, 0xa10e, 0x0130, 0x2304, 0x230c, 0xa10e, 0x0110, 0xa006,
+	0x0060, 0x732c, 0x8319, 0x7130, 0xa102, 0x1118, 0x2300, 0xa005,
+	0x0020, 0x0210, 0xa302, 0x0008, 0x8002, 0x0005, 0x2d00, 0x7026,
+	0xa080, 0x000d, 0x7056, 0x7053, 0x0000, 0x0126, 0x2091, 0x8000,
+	0x2009, 0xb812, 0x2104, 0xc08d, 0x200a, 0x012e, 0x080c, 0x165f,
+	0x0005, 0x708c, 0xa08a, 0x0029, 0x1220, 0xa082, 0x001d, 0x0033,
+	0x0010, 0x080c, 0x1515, 0x6027, 0x1e00, 0x0005, 0x58dc, 0x5857,
+	0x586f, 0x58ac, 0x58cd, 0x5907, 0x5919, 0x586f, 0x58f3, 0x57fb,
+	0x5829, 0x57fa, 0x0005, 0x00d6, 0x2069, 0x0200, 0x6804, 0xa005,
+	0x1180, 0x6808, 0xa005, 0x1518, 0x708f, 0x0028, 0x2069, 0xb7c5,
+	0x2d04, 0x7002, 0x080c, 0x5bd1, 0x6028, 0xa085, 0x0600, 0x602a,
+	0x00b0, 0x708f, 0x0028, 0x2069, 0xb7c5, 0x2d04, 0x7002, 0x6028,
+	0xa085, 0x0600, 0x602a, 0x00e6, 0x0036, 0x0046, 0x0056, 0x2071,
+	0xb823, 0x080c, 0x1dfe, 0x005e, 0x004e, 0x003e, 0x00ee, 0x00de,
+	0x0005, 0x00d6, 0x2069, 0x0200, 0x6804, 0xa005, 0x1180, 0x6808,
+	0xa005, 0x1518, 0x708f, 0x0028, 0x2069, 0xb7c5, 0x2d04, 0x7002,
+	0x080c, 0x5c5e, 0x6028, 0xa085, 0x0600, 0x602a, 0x00b0, 0x708f,
+	0x0028, 0x2069, 0xb7c5, 0x2d04, 0x7002, 0x6028, 0xa085, 0x0600,
+	0x602a, 0x00e6, 0x0036, 0x0046, 0x0056, 0x2071, 0xb823, 0x080c,
+	0x1dfe, 0x005e, 0x004e, 0x003e, 0x00ee, 0x00de, 0x0005, 0x6803,
+	0x0090, 0x6124, 0xd1e4, 0x1190, 0x080c, 0x5984, 0xd1d4, 0x1160,
+	0xd1dc, 0x1138, 0xd1cc, 0x0150, 0x708f, 0x0020, 0x080c, 0x5984,
+	0x0028, 0x708f, 0x001d, 0x0010, 0x708f, 0x001f, 0x0005, 0x6803,
+	0x0088, 0x6124, 0xd1cc, 0x1590, 0xd1dc, 0x1568, 0xd1e4, 0x1540,
+	0xa184, 0x1e00, 0x1580, 0x60e3, 0x0001, 0x600c, 0xc0b4, 0x600e,
+	0x080c, 0x5aff, 0x080c, 0x24b0, 0x0156, 0x6803, 0x0100, 0x20a9,
+	0x0014, 0x6804, 0xd0dc, 0x1118, 0x1f04, 0x5889, 0x0048, 0x20a9,
+	0x0014, 0x6803, 0x0080, 0x6804, 0xd0d4, 0x1130, 0x1f04, 0x5893,
+	0x080c, 0x5b20, 0x015e, 0x0078, 0x015e, 0x708f, 0x0028, 0x0058,
+	0x708f, 0x001e, 0x0040, 0x708f, 0x001d, 0x0028, 0x708f, 0x0020,
+	0x0010, 0x708f, 0x001f, 0x0005, 0x60e3, 0x0001, 0x600c, 0xc0b4,
+	0x600e, 0x080c, 0x5aff, 0x080c, 0x24b0, 0x6803, 0x0080, 0x6124,
+	0xd1d4, 0x1180, 0xd1dc, 0x1158, 0xd1e4, 0x1130, 0xa184, 0x1e00,
+	0x1158, 0x708f, 0x0028, 0x0040, 0x708f, 0x001e, 0x0028, 0x708f,
+	0x001d, 0x0010, 0x708f, 0x001f, 0x0005, 0x6803, 0x00a0, 0x6124,
+	0xd1dc, 0x1138, 0xd1e4, 0x0138, 0x080c, 0x1e47, 0x708f, 0x001e,
+	0x0010, 0x708f, 0x001d, 0x0005, 0x080c, 0x59f6, 0x6124, 0xd1dc,
+	0x1188, 0x080c, 0x5984, 0x0016, 0x080c, 0x1e47, 0x001e, 0xd1d4,
+	0x1128, 0xd1e4, 0x0138, 0x708f, 0x001e, 0x0020, 0x708f, 0x001f,
+	0x080c, 0x5984, 0x0005, 0x6803, 0x00a0, 0x6124, 0xd1d4, 0x1160,
+	0xd1cc, 0x1150, 0xd1dc, 0x1128, 0xd1e4, 0x0140, 0x708f, 0x001e,
+	0x0028, 0x708f, 0x001d, 0x0010, 0x708f, 0x0021, 0x0005, 0x080c,
+	0x59f6, 0x6124, 0xd1d4, 0x1150, 0xd1dc, 0x1128, 0xd1e4, 0x0140,
+	0x708f, 0x001e, 0x0028, 0x708f, 0x001d, 0x0010, 0x708f, 0x001f,
+	0x0005, 0x6803, 0x0090, 0x6124, 0xd1d4, 0x1178, 0xd1cc, 0x1150,
+	0xd1dc, 0x1128, 0xd1e4, 0x0158, 0x708f, 0x001e, 0x0040, 0x708f,
+	0x001d, 0x0028, 0x708f, 0x0020, 0x0010, 0x708f, 0x001f, 0x0005,
+	0x0016, 0x00c6, 0x00d6, 0x00e6, 0x0126, 0x2061, 0x0100, 0x2069,
+	0x0140, 0x2071, 0xb500, 0x2091, 0x8000, 0x080c, 0x5acf, 0x11e8,
+	0x2001, 0xb50c, 0x200c, 0xd1b4, 0x01c0, 0xc1b4, 0x2102, 0x6027,
+	0x0200, 0xe000, 0xe000, 0x6024, 0xd0cc, 0x0158, 0x6803, 0x00a0,
+	0x2001, 0xb79f, 0x2003, 0x0001, 0x2001, 0xb500, 0x2003, 0x0001,
+	0x0428, 0x6028, 0xc0cd, 0x602a, 0x0408, 0x080c, 0x5aeb, 0x0150,
+	0x080c, 0x5ae1, 0x1138, 0x2001, 0x0001, 0x080c, 0x27c3, 0x080c,
+	0x5aa6, 0x00a0, 0x080c, 0x59f3, 0x0178, 0x2001, 0x0001, 0x080c,
+	0x27c3, 0x708c, 0xa086, 0x001e, 0x0120, 0x708c, 0xa086, 0x0022,
+	0x1118, 0x708f, 0x0025, 0x0010, 0x708f, 0x0021, 0x012e, 0x00ee,
+	0x00de, 0x00ce, 0x001e, 0x0005, 0x0026, 0x2011, 0x5995, 0x080c,
+	0x6a5c, 0x002e, 0x0016, 0x0026, 0x2009, 0x0064, 0x2011, 0x5995,
+	0x080c, 0x6a53, 0x002e, 0x001e, 0x0005, 0x00e6, 0x00f6, 0x0016,
+	0x080c, 0x7d7a, 0x2071, 0xb500, 0x080c, 0x5930, 0x001e, 0x00fe,
+	0x00ee, 0x0005, 0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6, 0x00e6,
+	0x00f6, 0x0126, 0x080c, 0x7d7a, 0x2061, 0x0100, 0x2069, 0x0140,
+	0x2071, 0xb500, 0x2091, 0x8000, 0x6028, 0xc09c, 0x602a, 0x2011,
+	0x0003, 0x080c, 0x8075, 0x2011, 0x0002, 0x080c, 0x807f, 0x080c,
+	0x7f59, 0x080c, 0x6a10, 0x0036, 0x2019, 0x0000, 0x080c, 0x7fe4,
+	0x003e, 0x60e3, 0x0000, 0x080c, 0xb42f, 0x080c, 0xb44a, 0x2001,
+	0xb500, 0x2003, 0x0004, 0x6027, 0x0008, 0x080c, 0x12dd, 0x2001,
+	0x0001, 0x080c, 0x27c3, 0x012e, 0x00fe, 0x00ee, 0x00de, 0x00ce,
+	0x003e, 0x002e, 0x001e, 0x0005, 0x2001, 0xb500, 0x2004, 0xa086,
+	0x0004, 0x0140, 0x2001, 0xb79e, 0x2003, 0xaaaa, 0x2001, 0xb79f,
+	0x2003, 0x0000, 0x0005, 0x6020, 0xd09c, 0x0005, 0x6800, 0xa086,
+	0x00c0, 0x0160, 0x6803, 0x00c0, 0x0156, 0x20a9, 0x002d, 0x1d04,
+	0x59ff, 0x2091, 0x6000, 0x1f04, 0x59ff, 0x015e, 0x0005, 0x00c6,
+	0x00d6, 0x00e6, 0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0xb500,
+	0x2001, 0xb79f, 0x200c, 0xa186, 0x0000, 0x0158, 0xa186, 0x0001,
+	0x0158, 0xa186, 0x0002, 0x0158, 0xa186, 0x0003, 0x0158, 0x0804,
+	0x5a94, 0x708f, 0x0022, 0x0040, 0x708f, 0x0021, 0x0028, 0x708f,
+	0x0023, 0x0020, 0x708f, 0x0024, 0x6043, 0x0000, 0x60e3, 0x0000,
+	0x6887, 0x0001, 0x2001, 0x0001, 0x080c, 0x2872, 0x0026, 0x2011,
+	0x0003, 0x080c, 0x8075, 0x2011, 0x0002, 0x080c, 0x807f, 0x080c,
+	0x7f59, 0x0036, 0x2019, 0x0000, 0x080c, 0x7fe4, 0x003e, 0x002e,
+	0x7000, 0xa08e, 0x0004, 0x0118, 0x602b, 0x0028, 0x0010, 0x602b,
+	0x0020, 0x0156, 0x0126, 0x2091, 0x8000, 0x20a9, 0x0005, 0x6024,
+	0xd0ac, 0x0120, 0x012e, 0x015e, 0x0804, 0x5aa2, 0x6800, 0xa084,
+	0x00a0, 0xc0bd, 0x6802, 0x6904, 0xd1d4, 0x1130, 0x6803, 0x0100,
+	0x1f04, 0x5a57, 0x080c, 0x5b20, 0x012e, 0x015e, 0x080c, 0x5ae1,
+	0x01a8, 0x6044, 0xa005, 0x0168, 0x6050, 0x0006, 0xa085, 0x0020,
+	0x6052, 0x080c, 0x5b20, 0xa006, 0x8001, 0x1df0, 0x000e, 0x6052,
+	0x0028, 0x6804, 0xd0d4, 0x1110, 0x080c, 0x5b20, 0x0016, 0x0026,
+	0x2009, 0x00c8, 0x2011, 0x59a2, 0x080c, 0x6a22, 0x002e, 0x001e,
+	0x2001, 0xb79f, 0x2003, 0x0004, 0x080c, 0x57e1, 0x080c, 0x5ae1,
+	0x0148, 0x6804, 0xd0d4, 0x1130, 0xd0dc, 0x1100, 0x2001, 0xb79f,
+	0x2003, 0x0000, 0x00ee, 0x00de, 0x00ce, 0x0005, 0x00c6, 0x00d6,
+	0x00e6, 0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0xb500, 0x2001,
+	0xb79e, 0x2003, 0x0000, 0x2001, 0xb78f, 0x2003, 0x0000, 0x708f,
+	0x0000, 0x60e3, 0x0000, 0x6887, 0x0000, 0x2001, 0x0000, 0x080c,
+	0x2872, 0x6803, 0x0000, 0x6043, 0x0090, 0x6043, 0x0010, 0x6027,
+	0xffff, 0x602b, 0x182f, 0x00ee, 0x00de, 0x00ce, 0x0005, 0x0006,
+	0x2001, 0xb79e, 0x2004, 0xa086, 0xaaaa, 0x000e, 0x0005, 0x0006,
+	0x2001, 0xb572, 0x2004, 0xa084, 0x0030, 0xa086, 0x0000, 0x000e,
+	0x0005, 0x0006, 0x2001, 0xb572, 0x2004, 0xa084, 0x0030, 0xa086,
+	0x0030, 0x000e, 0x0005, 0x0006, 0x2001, 0xb572, 0x2004, 0xa084,
+	0x0030, 0xa086, 0x0010, 0x000e, 0x0005, 0x0006, 0x2001, 0xb572,
+	0x2004, 0xa084, 0x0030, 0xa086, 0x0020, 0x000e, 0x0005, 0x2001,
+	0xb50c, 0x2004, 0xd0a4, 0x0170, 0x080c, 0x2892, 0x0036, 0x0016,
+	0x2009, 0x0000, 0x2019, 0x0028, 0x080c, 0x2c6f, 0x001e, 0x003e,
+	0xa006, 0x0009, 0x0005, 0x00e6, 0x2071, 0xb50c, 0x2e04, 0x0118,
+	0xa085, 0x0010, 0x0010, 0xa084, 0xffef, 0x2072, 0x00ee, 0x0005,
+	0x6050, 0x0006, 0x60f0, 0x0006, 0x60ec, 0x0006, 0x600c, 0x0006,
+	0x6004, 0x0006, 0x6028, 0x0006, 0x602f, 0x0100, 0x602f, 0x0000,
+	0x602f, 0x0040, 0x602f, 0x0000, 0x000e, 0x602a, 0x000e, 0x6006,
+	0x000e, 0x600e, 0x000e, 0x60ee, 0x000e, 0x60f2, 0x60e3, 0x0000,
+	0x6887, 0x0001, 0x2001, 0x0001, 0x080c, 0x2872, 0x6800, 0xa084,
+	0x00a0, 0xc0bd, 0x6802, 0x6803, 0x00a0, 0x000e, 0x6052, 0x6050,
+	0x0005, 0x0156, 0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6, 0x00e6,
+	0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0xb500, 0x6020, 0xa084,
+	0x0080, 0x0138, 0x2001, 0xb50c, 0x200c, 0xc1bd, 0x2102, 0x0804,
+	0x5bc9, 0x2001, 0xb50c, 0x200c, 0xc1bc, 0x2102, 0x6028, 0xa084,
+	0xe1ff, 0x602a, 0x6027, 0x0200, 0x6803, 0x0090, 0x20a9, 0x0384,
+	0x6024, 0xd0cc, 0x1508, 0x1d04, 0x5b78, 0x2091, 0x6000, 0x1f04,
+	0x5b78, 0x2011, 0x0003, 0x080c, 0x8075, 0x2011, 0x0002, 0x080c,
+	0x807f, 0x080c, 0x7f59, 0x2019, 0x0000, 0x080c, 0x7fe4, 0x6803,
+	0x00a0, 0x2001, 0xb79f, 0x2003, 0x0001, 0x2001, 0xb500, 0x2003,
+	0x0001, 0xa085, 0x0001, 0x0468, 0x86ff, 0x1120, 0x080c, 0x1e47,
+	0x080c, 0x24b0, 0x60e3, 0x0000, 0x2001, 0xb78f, 0x2004, 0x080c,
+	0x2872, 0x60e2, 0x6803, 0x0080, 0x20a9, 0x0384, 0x6027, 0x1e00,
+	0x2009, 0x1e00, 0xe000, 0x6024, 0xa10c, 0x0138, 0x1d04, 0x5bae,
+	0x2091, 0x6000, 0x1f04, 0x5bae, 0x0820, 0x6028, 0xa085, 0x1e00,
+	0x602a, 0x70a4, 0xa005, 0x1118, 0x6887, 0x0001, 0x0008, 0x6886,
+	0xa006, 0x00ee, 0x00de, 0x00ce, 0x003e, 0x002e, 0x001e, 0x015e,
+	0x0005, 0x0156, 0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6, 0x00e6,
+	0x2061, 0x0100, 0x2071, 0xb500, 0x2069, 0x0140, 0x6020, 0xa084,
+	0x00c0, 0x0120, 0x6884, 0xa005, 0x1904, 0x5c25, 0x6803, 0x0088,
+	0x60e3, 0x0000, 0x6887, 0x0000, 0x2001, 0x0000, 0x080c, 0x2872,
+	0x2069, 0x0200, 0x6804, 0xa005, 0x1118, 0x6808, 0xa005, 0x01c0,
+	0x6028, 0xa084, 0xfbff, 0x602a, 0x6027, 0x0400, 0x2069, 0xb7c5,
+	0x7000, 0x206a, 0x708f, 0x0026, 0x7003, 0x0001, 0x20a9, 0x0002,
+	0x1d04, 0x5c08, 0x2091, 0x6000, 0x1f04, 0x5c08, 0x0804, 0x5c56,
+	0x2069, 0x0140, 0x20a9, 0x0384, 0x6027, 0x1e00, 0x2009, 0x1e00,
+	0xe000, 0x6024, 0xa10c, 0x0520, 0xa084, 0x1a00, 0x1508, 0x1d04,
+	0x5c14, 0x2091, 0x6000, 0x1f04, 0x5c14, 0x2011, 0x0003, 0x080c,
+	0x8075, 0x2011, 0x0002, 0x080c, 0x807f, 0x080c, 0x7f59, 0x2019,
+	0x0000, 0x080c, 0x7fe4, 0x6803, 0x00a0, 0x2001, 0xb79f, 0x2003,
+	0x0001, 0x2001, 0xb500, 0x2003, 0x0001, 0xa085, 0x0001, 0x00b0,
+	0x080c, 0x24b0, 0x6803, 0x0080, 0x2069, 0x0140, 0x60e3, 0x0000,
+	0x70a4, 0xa005, 0x1118, 0x6887, 0x0001, 0x0008, 0x6886, 0x2001,
+	0xb78f, 0x2004, 0x080c, 0x2872, 0x60e2, 0xa006, 0x00ee, 0x00de,
+	0x00ce, 0x003e, 0x002e, 0x001e, 0x015e, 0x0005, 0x0156, 0x0016,
+	0x0026, 0x0036, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100, 0x2071,
+	0xb500, 0x6020, 0xa084, 0x00c0, 0x01e0, 0x2011, 0x0003, 0x080c,
+	0x8075, 0x2011, 0x0002, 0x080c, 0x807f, 0x080c, 0x7f59, 0x2019,
+	0x0000, 0x080c, 0x7fe4, 0x2069, 0x0140, 0x6803, 0x00a0, 0x2001,
+	0xb79f, 0x2003, 0x0001, 0x2001, 0xb500, 0x2003, 0x0001, 0x0804,
+	0x5cfb, 0x2001, 0xb50c, 0x200c, 0xd1b4, 0x1160, 0xc1b5, 0x2102,
+	0x080c, 0x598a, 0x2069, 0x0140, 0x080c, 0x24b0, 0x6803, 0x0080,
+	0x60e3, 0x0000, 0x2069, 0x0200, 0x6804, 0xa005, 0x1118, 0x6808,
+	0xa005, 0x01c0, 0x6028, 0xa084, 0xfdff, 0x602a, 0x6027, 0x0200,
+	0x2069, 0xb7c5, 0x7000, 0x206a, 0x708f, 0x0027, 0x7003, 0x0001,
+	0x20a9, 0x0002, 0x1d04, 0x5cb2, 0x2091, 0x6000, 0x1f04, 0x5cb2,
+	0x0804, 0x5cfb, 0x6027, 0x1e00, 0x2009, 0x1e00, 0xe000, 0x6024,
+	0xa10c, 0x01c8, 0xa084, 0x1c00, 0x11b0, 0x1d04, 0x5cba, 0x0006,
+	0x0016, 0x00c6, 0x00d6, 0x00e6, 0x080c, 0x68f9, 0x00ee, 0x00de,
+	0x00ce, 0x001e, 0x000e, 0x00e6, 0x2071, 0xb7f3, 0x7018, 0x00ee,
+	0xa005, 0x1d00, 0x0500, 0x0026, 0x2011, 0x59a2, 0x080c, 0x699c,
+	0x2011, 0x5995, 0x080c, 0x6a5c, 0x002e, 0x2069, 0x0140, 0x60e3,
+	0x0000, 0x70a4, 0xa005, 0x1118, 0x6887, 0x0001, 0x0008, 0x6886,
+	0x2001, 0xb78f, 0x2004, 0x080c, 0x2872, 0x60e2, 0x2001, 0xb50c,
+	0x200c, 0xc1b4, 0x2102, 0x00ee, 0x00de, 0x00ce, 0x003e, 0x002e,
+	0x001e, 0x015e, 0x0005, 0x0156, 0x0016, 0x0026, 0x0036, 0x0046,
+	0x00c6, 0x00e6, 0x2061, 0x0100, 0x2071, 0xb500, 0x7130, 0xd184,
+	0x1180, 0x2011, 0xb553, 0x2214, 0xd2ec, 0x0138, 0xc18d, 0x7132,
+	0x2011, 0xb553, 0x2214, 0xd2ac, 0x1120, 0x7030, 0xd08c, 0x0904,
+	0x5d68, 0x7130, 0xc185, 0x7132, 0x2011, 0xb553, 0x220c, 0xd1a4,
+	0x0530, 0x0016, 0x2019, 0x000e, 0x080c, 0xb065, 0x0156, 0x20a9,
+	0x007f, 0x2009, 0x0000, 0xa186, 0x007e, 0x01a0, 0xa186, 0x0080,
+	0x0188, 0x080c, 0x4fa9, 0x1170, 0x8127, 0xa006, 0x0016, 0x2009,
+	0x000e, 0x080c, 0xb0e8, 0x2009, 0x0001, 0x2011, 0x0100, 0x080c,
+	0x6b1a, 0x001e, 0x8108, 0x1f04, 0x5d33, 0x015e, 0x001e, 0xd1ac,
+	0x1148, 0x0016, 0x2009, 0x0000, 0x2019, 0x0004, 0x080c, 0x2c6f,
+	0x001e, 0x0070, 0x0156, 0x20a9, 0x007f, 0x2009, 0x0000, 0x080c,
+	0x4fa9, 0x1110, 0x080c, 0x4c0b, 0x8108, 0x1f04, 0x5d5f, 0x015e,
+	0x080c, 0x1e47, 0x2011, 0x0003, 0x080c, 0x8075, 0x2011, 0x0002,
+	0x080c, 0x807f, 0x080c, 0x7f59, 0x0036, 0x2019, 0x0000, 0x080c,
+	0x7fe4, 0x003e, 0x60e3, 0x0000, 0x2001, 0xb500, 0x2003, 0x0001,
+	0x080c, 0x5a07, 0x00ee, 0x00ce, 0x004e, 0x003e, 0x002e, 0x001e,
+	0x015e, 0x0005, 0x2071, 0xb5e2, 0x7003, 0x0000, 0x7007, 0x0000,
+	0x700f, 0x0000, 0x702b, 0x0001, 0x704f, 0x0000, 0x7053, 0x0001,
+	0x705f, 0x0020, 0x7063, 0x0040, 0x7083, 0x0000, 0x708b, 0x0000,
+	0x708f, 0x0001, 0x70bf, 0x0000, 0x0005, 0x00e6, 0x2071, 0xb5e2,
+	0x6848, 0xa005, 0x1130, 0x7028, 0xc085, 0x702a, 0xa085, 0x0001,
+	0x0428, 0x6a50, 0x7236, 0x6b54, 0x733a, 0x6858, 0x703e, 0x707a,
+	0x685c, 0x7042, 0x707e, 0x6848, 0x702e, 0x6840, 0x7032, 0x2009,
+	0x000c, 0x200a, 0x8007, 0x8006, 0x8006, 0xa08c, 0x003f, 0xa084,
+	0xffc0, 0xa210, 0x2100, 0xa319, 0x7272, 0x7376, 0x7028, 0xc084,
+	0x702a, 0x7007, 0x0001, 0x700f, 0x0000, 0xa006, 0x00ee, 0x0005,
+	0x2b78, 0x2071, 0xb5e2, 0x7004, 0x0043, 0x700c, 0x0002, 0x5de4,
+	0x5ddb, 0x5ddb, 0x5ddb, 0x5ddb, 0x0005, 0x5e3a, 0x5e3b, 0x5e6d,
+	0x5e6e, 0x5e38, 0x5ebc, 0x5ec1, 0x5ef2, 0x5ef3, 0x5f0e, 0x5f0f,
+	0x5f10, 0x5f11, 0x5f12, 0x5f13, 0x5fc9, 0x5ff0, 0x700c, 0x0002,
+	0x5dfd, 0x5e38, 0x5e38, 0x5e39, 0x5e39, 0x7830, 0x7930, 0xa106,
+	0x0120, 0x7830, 0x7930, 0xa106, 0x1510, 0x7030, 0xa10a, 0x01f8,
+	0x1210, 0x712c, 0xa10a, 0xa18a, 0x0002, 0x12d0, 0x080c, 0x15df,
+	0x01b0, 0x2d00, 0x705a, 0x7063, 0x0040, 0x2001, 0x0003, 0x7057,
+	0x0000, 0x0126, 0x0006, 0x2091, 0x8000, 0x2009, 0xb812, 0x2104,
+	0xc085, 0x200a, 0x000e, 0x700e, 0x012e, 0x080c, 0x165f, 0x0005,
+	0x080c, 0x15df, 0x0de0, 0x2d00, 0x705a, 0x080c, 0x15df, 0x1108,
+	0x0c10, 0x2d00, 0x7086, 0x7063, 0x0080, 0x2001, 0x0004, 0x08f8,
+	0x0005, 0x0005, 0x0005, 0x700c, 0x0002, 0x5e42, 0x5e45, 0x5e53,
+	0x5e6c, 0x5e6c, 0x080c, 0x5df6, 0x0005, 0x0126, 0x8001, 0x700e,
+	0x7058, 0x0006, 0x080c, 0x6343, 0x0120, 0x2091, 0x8000, 0x080c,
+	0x5df6, 0x00de, 0x0048, 0x0126, 0x8001, 0x700e, 0x080c, 0x6343,
+	0x7058, 0x2068, 0x7084, 0x705a, 0x6803, 0x0000, 0x6807, 0x0000,
+	0x6834, 0xa084, 0x00ff, 0xa08a, 0x003a, 0x1218, 0x00db, 0x012e,
+	0x0005, 0x012e, 0x080c, 0x5f14, 0x0005, 0x0005, 0x0005, 0x00e6,
+	0x2071, 0xb5e2, 0x700c, 0x0002, 0x5e79, 0x5e79, 0x5e79, 0x5e7b,
+	0x5e7e, 0x00ee, 0x0005, 0x700f, 0x0001, 0x0010, 0x700f, 0x0002,
+	0x00ee, 0x0005, 0x5f14, 0x5f14, 0x5f30, 0x5f14, 0x60ad, 0x5f14,
+	0x5f14, 0x5f14, 0x5f14, 0x5f14, 0x5f30, 0x60ef, 0x6132, 0x617b,
+	0x618f, 0x5f14, 0x5f14, 0x5f4c, 0x5f30, 0x5f14, 0x5f14, 0x5fa6,
+	0x623b, 0x6256, 0x5f14, 0x5f4c, 0x5f14, 0x5f14, 0x5f14, 0x5f14,
+	0x5f9c, 0x6256, 0x5f14, 0x5f14, 0x5f14, 0x5f14, 0x5f14, 0x5f14,
+	0x5f14, 0x5f14, 0x5f14, 0x5f60, 0x5f14, 0x5f14, 0x5f14, 0x5f14,
+	0x5f14, 0x5f14, 0x5f14, 0x5f14, 0x5f14, 0x6361, 0x5f14, 0x5f14,
+	0x5f14, 0x5f14, 0x5f14, 0x5f75, 0x7020, 0x2068, 0x080c, 0x160f,
+	0x0005, 0x700c, 0x0002, 0x5ec8, 0x5ecb, 0x5ed9, 0x5ef1, 0x5ef1,
+	0x080c, 0x5df6, 0x0005, 0x0126, 0x8001, 0x700e, 0x7058, 0x0006,
+	0x080c, 0x6343, 0x0120, 0x2091, 0x8000, 0x080c, 0x5df6, 0x00de,
+	0x0048, 0x0126, 0x8001, 0x700e, 0x080c, 0x6343, 0x7058, 0x2068,
+	0x7084, 0x705a, 0x6803, 0x0000, 0x6807, 0x0000, 0x6834, 0xa084,
+	0x00ff, 0xa08a, 0x001a, 0x1218, 0x003b, 0x012e, 0x0005, 0x012e,
+	0x0419, 0x0005, 0x0005, 0x0005, 0x5f14, 0x5f30, 0x6099, 0x5f14,
+	0x5f30, 0x5f14, 0x5f30, 0x5f30, 0x5f14, 0x5f30, 0x6099, 0x5f30,
+	0x5f30, 0x5f30, 0x5f30, 0x5f30, 0x5f14, 0x5f30, 0x6099, 0x5f14,
+	0x5f14, 0x5f30, 0x5f14, 0x5f14, 0x5f14, 0x5f30, 0x0005, 0x0005,
+	0x0005, 0x0005, 0x0005, 0x0005, 0x7007, 0x0001, 0x6838, 0xa084,
+	0x00ff, 0xc0d5, 0x683a, 0x0126, 0x2091, 0x8000, 0x080c, 0x5408,
+	0x012e, 0x0005, 0x7007, 0x0001, 0x6838, 0xa084, 0x00ff, 0xc0e5,
+	0x683a, 0x0126, 0x2091, 0x8000, 0x080c, 0x5408, 0x012e, 0x0005,
+	0x7007, 0x0001, 0x6838, 0xa084, 0x00ff, 0xc0ed, 0x683a, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x5408, 0x012e, 0x0005, 0x7007, 0x0001,
+	0x6838, 0xa084, 0x00ff, 0xc0dd, 0x683a, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x5408, 0x012e, 0x0005, 0x6834, 0x8007, 0xa084, 0x00ff,
+	0x0988, 0x8001, 0x1120, 0x7007, 0x0001, 0x0804, 0x6059, 0x7007,
+	0x0006, 0x7012, 0x2d00, 0x7016, 0x701a, 0x704b, 0x6059, 0x0005,
+	0x6834, 0x8007, 0xa084, 0x00ff, 0x0904, 0x5f22, 0x8001, 0x1120,
+	0x7007, 0x0001, 0x0804, 0x6076, 0x7007, 0x0006, 0x7012, 0x2d00,
+	0x7016, 0x701a, 0x704b, 0x6076, 0x0005, 0x6834, 0x8007, 0xa084,
+	0x00ff, 0xa086, 0x0001, 0x1904, 0x5f22, 0x7007, 0x0001, 0x2009,
+	0xb531, 0x210c, 0x81ff, 0x11a8, 0x6838, 0xa084, 0x00ff, 0x683a,
+	0x6853, 0x0000, 0x080c, 0x4d82, 0x1108, 0x0005, 0x0126, 0x2091,
+	0x8000, 0x6837, 0x0139, 0x684a, 0x6952, 0x080c, 0x5408, 0x012e,
+	0x0ca0, 0x2001, 0x0028, 0x0c90, 0x684c, 0xa084, 0x00c0, 0xa086,
+	0x00c0, 0x1120, 0x7007, 0x0001, 0x0804, 0x626e, 0x2d00, 0x7016,
+	0x701a, 0x20a9, 0x0004, 0xa080, 0x0024, 0x2098, 0x20a1, 0xb60d,
+	0x53a3, 0x6858, 0x7012, 0xa082, 0x0401, 0x1a04, 0x5f3e, 0x6a84,
+	0xa28a, 0x0002, 0x1a04, 0x5f3e, 0x82ff, 0x1138, 0x6888, 0x698c,
+	0xa105, 0x0118, 0x2001, 0x602c, 0x0018, 0xa280, 0x6022, 0x2005,
+	0x70c6, 0x7010, 0xa015, 0x0904, 0x600e, 0x080c, 0x15df, 0x1118,
+	0x7007, 0x000f, 0x0005, 0x2d00, 0x7022, 0x70c4, 0x2060, 0x2c05,
+	0x6836, 0xe004, 0xad00, 0x7096, 0xe008, 0xa20a, 0x1210, 0xa00e,
+	0x2200, 0x7112, 0xe20c, 0x8003, 0x800b, 0xa296, 0x0004, 0x0108,
+	0xa108, 0x719a, 0x810b, 0x719e, 0xae90, 0x0022, 0x080c, 0x1643,
+	0x7090, 0xa08e, 0x0100, 0x0170, 0xa086, 0x0200, 0x0118, 0x7007,
+	0x0010, 0x0005, 0x7020, 0x2068, 0x080c, 0x160f, 0x7014, 0x2068,
+	0x0804, 0x5f3e, 0x7020, 0x2068, 0x7018, 0x6802, 0x6807, 0x0000,
+	0x2d08, 0x2068, 0x6906, 0x711a, 0x0804, 0x5fc9, 0x7014, 0x2068,
+	0x7007, 0x0001, 0x6884, 0xa005, 0x1128, 0x6888, 0x698c, 0xa105,
+	0x0108, 0x00b1, 0x6834, 0xa084, 0x00ff, 0xa086, 0x001e, 0x0904,
+	0x626e, 0x04b8, 0x6024, 0x6028, 0x0002, 0x0011, 0x0007, 0x0004,
+	0x000a, 0x000f, 0x0005, 0x0006, 0x000a, 0x0011, 0x0005, 0x0004,
+	0x00f6, 0x00e6, 0x00c6, 0x0076, 0x0066, 0x6f88, 0x6e8c, 0x6804,
+	0x2060, 0xacf0, 0x0021, 0xacf8, 0x0027, 0x2009, 0x0005, 0x700c,
+	0x7816, 0x7008, 0x7812, 0x7004, 0x7806, 0x7000, 0x7802, 0x7e0e,
+	0x7f0a, 0x8109, 0x0128, 0xaef2, 0x0004, 0xaffa, 0x0006, 0x0c78,
+	0x6004, 0xa065, 0x1d30, 0x006e, 0x007e, 0x00ce, 0x00ee, 0x00fe,
+	0x0005, 0x2009, 0xb531, 0x210c, 0x81ff, 0x1198, 0x6838, 0xa084,
+	0x00ff, 0x683a, 0x080c, 0x4c64, 0x1108, 0x0005, 0x080c, 0x54db,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x9ecc, 0x080c, 0x5408, 0x012e,
+	0x0ca0, 0x2001, 0x0028, 0x2009, 0x0000, 0x0c80, 0x2009, 0xb531,
+	0x210c, 0x81ff, 0x11b0, 0x6858, 0xa005, 0x01c0, 0x6838, 0xa084,
+	0x00ff, 0x683a, 0x6853, 0x0000, 0x080c, 0x4d26, 0x1108, 0x0005,
+	0x0126, 0x2091, 0x8000, 0x684a, 0x6952, 0x080c, 0x5408, 0x012e,
+	0x0cb0, 0x2001, 0x0028, 0x2009, 0x0000, 0x0c90, 0x2001, 0x0000,
+	0x0c78, 0x7018, 0x6802, 0x2d08, 0x2068, 0x6906, 0x711a, 0x7010,
+	0x8001, 0x7012, 0x0118, 0x7007, 0x0006, 0x0030, 0x7014, 0x2068,
+	0x7007, 0x0001, 0x7048, 0x080f, 0x0005, 0x7007, 0x0001, 0x6944,
+	0x810f, 0xa18c, 0x00ff, 0x6848, 0xa084, 0x00ff, 0x20a9, 0x0001,
+	0xa096, 0x0001, 0x01b0, 0x2009, 0x0000, 0x20a9, 0x00ff, 0xa096,
+	0x0002, 0x0178, 0xa005, 0x11f0, 0x6944, 0x810f, 0xa18c, 0x00ff,
+	0x080c, 0x4fa9, 0x11b8, 0x0066, 0x6e50, 0x080c, 0x50a8, 0x006e,
+	0x0088, 0x0046, 0x2011, 0xb50c, 0x2224, 0xc484, 0x2412, 0x004e,
+	0x00c6, 0x080c, 0x4fa9, 0x1110, 0x080c, 0x5209, 0x8108, 0x1f04,
+	0x60d9, 0x00ce, 0x684c, 0xd084, 0x1118, 0x080c, 0x160f, 0x0005,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x5408, 0x012e, 0x0005, 0x0126,
+	0x2091, 0x8000, 0x7007, 0x0001, 0x2001, 0xb553, 0x2004, 0xd0a4,
+	0x0580, 0x2061, 0xb874, 0x6100, 0xd184, 0x0178, 0x6858, 0xa084,
+	0x00ff, 0x1550, 0x6000, 0xd084, 0x0520, 0x6004, 0xa005, 0x1538,
+	0x6003, 0x0000, 0x600b, 0x0000, 0x00c8, 0x2011, 0x0001, 0x6860,
+	0xa005, 0x1110, 0x2001, 0x001e, 0x8000, 0x6016, 0x6858, 0xa084,
+	0x00ff, 0x0178, 0x6006, 0x6858, 0x8007, 0xa084, 0x00ff, 0x0148,
+	0x600a, 0x6858, 0x8000, 0x1108, 0xc28d, 0x6202, 0x012e, 0x0804,
+	0x6332, 0x012e, 0x0804, 0x632c, 0x012e, 0x0804, 0x6326, 0x012e,
+	0x0804, 0x6329, 0x0126, 0x2091, 0x8000, 0x7007, 0x0001, 0x2001,
+	0xb553, 0x2004, 0xd0a4, 0x05e0, 0x2061, 0xb874, 0x6000, 0xd084,
+	0x05b8, 0x6204, 0x6308, 0xd08c, 0x1530, 0x6c48, 0xa484, 0x0003,
+	0x0170, 0x6958, 0xa18c, 0x00ff, 0x8001, 0x1120, 0x2100, 0xa210,
+	0x0620, 0x0028, 0x8001, 0x1508, 0x2100, 0xa212, 0x02f0, 0xa484,
+	0x000c, 0x0188, 0x6958, 0x810f, 0xa18c, 0x00ff, 0xa082, 0x0004,
+	0x1120, 0x2100, 0xa318, 0x0288, 0x0030, 0xa082, 0x0004, 0x1168,
+	0x2100, 0xa31a, 0x0250, 0x6860, 0xa005, 0x0110, 0x8000, 0x6016,
+	0x6206, 0x630a, 0x012e, 0x0804, 0x6332, 0x012e, 0x0804, 0x632f,
+	0x012e, 0x0804, 0x632c, 0x0126, 0x2091, 0x8000, 0x7007, 0x0001,
+	0x2061, 0xb874, 0x6300, 0xd38c, 0x1120, 0x6308, 0x8318, 0x0220,
+	0x630a, 0x012e, 0x0804, 0x6340, 0x012e, 0x0804, 0x632f, 0x0126,
+	0x00c6, 0x2091, 0x8000, 0x7007, 0x0001, 0x684c, 0xd0ac, 0x0148,
+	0x00c6, 0x2061, 0xb874, 0x6000, 0xa084, 0xfcff, 0x6002, 0x00ce,
+	0x0448, 0x6858, 0xa005, 0x05d0, 0x685c, 0xa065, 0x0598, 0x2001,
+	0xb531, 0x2004, 0xa005, 0x0118, 0x080c, 0x9e1d, 0x0068, 0x6013,
+	0x0400, 0x6057, 0x0000, 0x694c, 0xd1a4, 0x0110, 0x6950, 0x6156,
+	0x2009, 0x0041, 0x080c, 0x864c, 0x6958, 0xa18c, 0xff00, 0xa186,
+	0x2000, 0x1140, 0x0026, 0x2009, 0x0000, 0x2011, 0xfdff, 0x080c,
+	0x6b1a, 0x002e, 0x684c, 0xd0c4, 0x0148, 0x2061, 0xb874, 0x6000,
+	0xd08c, 0x1120, 0x6008, 0x8000, 0x0208, 0x600a, 0x00ce, 0x012e,
+	0x0804, 0x6332, 0x00ce, 0x012e, 0x0804, 0x632c, 0x6954, 0xa186,
+	0x002e, 0x0d40, 0xa186, 0x002d, 0x0d28, 0xa186, 0x0045, 0x0528,
+	0xa186, 0x002a, 0x1130, 0x2001, 0xb50c, 0x200c, 0xc194, 0x2102,
+	0x08c8, 0xa186, 0x0020, 0x0170, 0xa186, 0x0029, 0x1d18, 0x6944,
+	0xa18c, 0xff00, 0x810f, 0x080c, 0x4fa9, 0x1960, 0x6000, 0xc0e4,
+	0x6002, 0x0840, 0x685c, 0xa065, 0x09a8, 0x6007, 0x0024, 0x2001,
+	0xb7b6, 0x2004, 0x6016, 0x0804, 0x61ca, 0x685c, 0xa065, 0x0950,
+	0x00e6, 0x6860, 0xa075, 0x2001, 0xb531, 0x2004, 0xa005, 0x0150,
+	0x080c, 0x9e1d, 0x8eff, 0x0118, 0x2e60, 0x080c, 0x9e1d, 0x00ee,
+	0x0804, 0x61ca, 0x6020, 0xc0dc, 0xc0d5, 0x6022, 0x2e60, 0x6007,
+	0x003a, 0x6870, 0xa005, 0x0130, 0x6007, 0x003b, 0x6874, 0x602a,
+	0x6878, 0x6012, 0x6003, 0x0001, 0x080c, 0x6c8d, 0x080c, 0x7173,
+	0x00ee, 0x0804, 0x61ca, 0x2061, 0xb874, 0x6000, 0xd084, 0x0190,
+	0xd08c, 0x1904, 0x6340, 0x0126, 0x2091, 0x8000, 0x6204, 0x8210,
+	0x0220, 0x6206, 0x012e, 0x0804, 0x6340, 0x012e, 0x6853, 0x0016,
+	0x0804, 0x6339, 0x6853, 0x0007, 0x0804, 0x6339, 0x6834, 0x8007,
+	0xa084, 0x00ff, 0x1118, 0x080c, 0x5f22, 0x0078, 0x2030, 0x8001,
+	0x1120, 0x7007, 0x0001, 0x0051, 0x0040, 0x7007, 0x0006, 0x7012,
+	0x2d00, 0x7016, 0x701a, 0x704b, 0x626e, 0x0005, 0x00e6, 0x0126,
+	0x2091, 0x8000, 0xa03e, 0x2009, 0xb531, 0x210c, 0x81ff, 0x1904,
+	0x62ec, 0x2009, 0xb50c, 0x210c, 0xd194, 0x1904, 0x6316, 0x6848,
+	0x2070, 0xae82, 0xbd00, 0x0a04, 0x62e0, 0x2001, 0xb517, 0x2004,
+	0xae02, 0x1a04, 0x62e0, 0x711c, 0xa186, 0x0006, 0x1904, 0x62cf,
+	0x7018, 0xa005, 0x0904, 0x62ec, 0x2004, 0xd0e4, 0x1904, 0x6311,
+	0x2061, 0xb874, 0x6100, 0xa184, 0x0301, 0xa086, 0x0001, 0x1550,
+	0x7020, 0xd0dc, 0x1904, 0x6319, 0x6853, 0x0000, 0x6803, 0x0000,
+	0x2d08, 0x7010, 0xa005, 0x1158, 0x7112, 0x684c, 0xd0f4, 0x1904,
+	0x631c, 0x2e60, 0x080c, 0x6a76, 0x012e, 0x00ee, 0x0005, 0x2068,
+	0x6800, 0xa005, 0x1de0, 0x6902, 0x2168, 0x684c, 0xd0f4, 0x1904,
+	0x631c, 0x012e, 0x00ee, 0x0005, 0x012e, 0x00ee, 0x6853, 0x0006,
+	0x0804, 0x6339, 0xd184, 0x0dc0, 0xd1c4, 0x11a8, 0x00b8, 0x6944,
+	0xa18c, 0xff00, 0x810f, 0x080c, 0x4fa9, 0x15d8, 0x6000, 0xd0e4,
+	0x15c0, 0x711c, 0xa186, 0x0007, 0x1118, 0x6853, 0x0002, 0x0498,
+	0x6853, 0x0008, 0x0480, 0x6853, 0x000e, 0x0468, 0x6853, 0x0017,
+	0x0450, 0x6853, 0x0035, 0x0438, 0x2001, 0xb572, 0x2004, 0xd0fc,
+	0x01e8, 0x6848, 0x2070, 0xae82, 0xbd00, 0x02c0, 0x605c, 0xae02,
+	0x12a8, 0x711c, 0xa186, 0x0006, 0x1188, 0x7018, 0xa005, 0x0170,
+	0x2004, 0xd0bc, 0x0158, 0x2039, 0x0001, 0x7000, 0xa086, 0x0007,
+	0x1904, 0x6279, 0x7003, 0x0002, 0x0804, 0x6279, 0x6853, 0x0028,
+	0x0010, 0x6853, 0x0029, 0x012e, 0x00ee, 0x0418, 0x6853, 0x002a,
+	0x0cd0, 0x6853, 0x0045, 0x0cb8, 0x2e60, 0x2019, 0x0002, 0x6017,
+	0x0014, 0x080c, 0xace0, 0x012e, 0x00ee, 0x0005, 0x2009, 0x003e,
+	0x0058, 0x2009, 0x0004, 0x0040, 0x2009, 0x0006, 0x0028, 0x2009,
+	0x0016, 0x0010, 0x2009, 0x0001, 0x6854, 0xa084, 0xff00, 0xa105,
+	0x6856, 0x0126, 0x2091, 0x8000, 0x080c, 0x5408, 0x012e, 0x0005,
+	0x080c, 0x160f, 0x0005, 0x702c, 0x7130, 0x8108, 0xa102, 0x0230,
+	0xa00e, 0x7034, 0x7072, 0x7038, 0x7076, 0x0058, 0x7070, 0xa080,
+	0x0040, 0x7072, 0x1230, 0x7074, 0xa081, 0x0000, 0x7076, 0xa085,
+	0x0001, 0x7932, 0x7132, 0x0005, 0x00d6, 0x080c, 0x6a6d, 0x00de,
+	0x0005, 0x00d6, 0x00c6, 0x0036, 0x0026, 0x0016, 0x7007, 0x0001,
+	0x6a44, 0xa282, 0x0004, 0x1a04, 0x63ac, 0xd284, 0x0170, 0x6a4c,
+	0xa290, 0xb635, 0x2204, 0xa065, 0x6004, 0x05e0, 0x8007, 0xa084,
+	0x00ff, 0xa084, 0x0006, 0x1108, 0x04a8, 0x2c10, 0x080c, 0x85c7,
+	0x1118, 0x080c, 0x9ed6, 0x05a0, 0x621a, 0x6844, 0x0002, 0x638b,
+	0x6390, 0x6393, 0x6399, 0x2019, 0x0002, 0x080c, 0xb065, 0x0060,
+	0x080c, 0xaffc, 0x0048, 0x2019, 0x0002, 0x6950, 0x080c, 0xb017,
+	0x0018, 0x6950, 0x080c, 0xaffc, 0x080c, 0x861d, 0x6857, 0x0000,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x5408, 0x012e, 0x001e, 0x002e,
+	0x003e, 0x00ce, 0x00de, 0x0005, 0x6857, 0x0006, 0x0c88, 0x6857,
+	0x0002, 0x0c70, 0x6857, 0x0005, 0x0c58, 0x6857, 0x0004, 0x0c40,
+	0x6857, 0x0007, 0x0c28, 0x00d6, 0x2011, 0x0004, 0x2204, 0xa085,
+	0x8002, 0x2012, 0x00de, 0x0005, 0x20e1, 0x0002, 0x3d08, 0x20e1,
+	0x2000, 0x3d00, 0xa084, 0x7000, 0x0118, 0xa086, 0x1000, 0x1570,
+	0x20e1, 0x0000, 0x3d00, 0xa094, 0xff00, 0x8217, 0xa084, 0xf000,
+	0xa086, 0x3000, 0x1160, 0xa184, 0xff00, 0x8007, 0xa086, 0x0008,
+	0x11e8, 0x080c, 0x2dbf, 0x11d0, 0x080c, 0x6603, 0x0098, 0x20e1,
+	0x0004, 0x3d60, 0xd1bc, 0x1108, 0x3e60, 0xac84, 0x0007, 0x1170,
+	0xac82, 0xbd00, 0x0258, 0x685c, 0xac02, 0x1240, 0x2009, 0x0047,
+	0x080c, 0x864c, 0x7a1c, 0xd284, 0x1938, 0x0005, 0xa016, 0x080c,
+	0x185e, 0x0cc0, 0x0cd8, 0x781c, 0xd08c, 0x0500, 0x0156, 0x0136,
+	0x0146, 0x20e1, 0x3000, 0x3d20, 0x3e28, 0xa584, 0x0076, 0x1538,
+	0xa484, 0x7000, 0xa086, 0x1000, 0x11a8, 0x080c, 0x647e, 0x01f8,
+	0x20e1, 0x3000, 0x7828, 0x7828, 0x080c, 0x649a, 0x014e, 0x013e,
+	0x015e, 0x2009, 0xb7e8, 0x2104, 0xa005, 0x1108, 0x0005, 0x080c,
+	0x7173, 0x0ce0, 0xa484, 0x7000, 0x1548, 0x080c, 0x647e, 0x01d8,
+	0x7000, 0xa084, 0xff00, 0xa086, 0x8100, 0x0d10, 0x00a0, 0xd5a4,
+	0x0178, 0x0056, 0x0046, 0x080c, 0x1e6e, 0x080c, 0x24b0, 0x2001,
+	0x0160, 0x2502, 0x2001, 0x0138, 0x2202, 0x004e, 0x005e, 0x0048,
+	0x04a9, 0x6887, 0x0000, 0x080c, 0xb3df, 0x20e1, 0x3000, 0x7828,
+	0x7828, 0x00b9, 0x014e, 0x013e, 0x015e, 0x0880, 0x0439, 0x1130,
+	0x7000, 0xa084, 0xff00, 0xa086, 0x8100, 0x1d68, 0x080c, 0xb3df,
+	0x20e1, 0x3000, 0x7828, 0x7828, 0x0056, 0x080c, 0x6874, 0x005e,
+	0x0c40, 0x2001, 0xb50e, 0x2004, 0xd08c, 0x0178, 0x2001, 0xb500,
+	0x2004, 0xa086, 0x0003, 0x1148, 0x0026, 0x0036, 0x2011, 0x8048,
+	0x2518, 0x080c, 0x3ecc, 0x003e, 0x002e, 0x0005, 0xa484, 0x01ff,
+	0x6886, 0xa005, 0x0160, 0xa080, 0x001f, 0xa084, 0x03f8, 0x80ac,
+	0x20e1, 0x1000, 0x2ea0, 0x2099, 0x020a, 0x53a5, 0x0005, 0x20a9,
+	0x000c, 0x20e1, 0x1000, 0x2ea0, 0x2099, 0x020a, 0x53a5, 0xa085,
+	0x0001, 0x0ca0, 0x7000, 0xa084, 0xff00, 0xa08c, 0xf000, 0x8007,
+	0xa196, 0x0000, 0x1118, 0x0804, 0x6708, 0x0005, 0xa196, 0x2000,
+	0x1148, 0x6900, 0xa18e, 0x0001, 0x1118, 0x080c, 0x448f, 0x0ca8,
+	0x0039, 0x0c98, 0xa196, 0x8000, 0x1d80, 0x080c, 0x67b4, 0x0c68,
+	0x00c6, 0x6a84, 0x82ff, 0x0904, 0x65fd, 0x7110, 0xa18c, 0xff00,
+	0x810f, 0xa196, 0x0001, 0x0120, 0xa196, 0x0023, 0x1904, 0x65fd,
+	0xa08e, 0x0023, 0x1570, 0x080c, 0x684f, 0x0904, 0x65fd, 0x7124,
+	0x610a, 0x7030, 0xa08e, 0x0200, 0x1150, 0x7034, 0xa005, 0x1904,
+	0x65fd, 0x2009, 0x0015, 0x080c, 0x864c, 0x0804, 0x65fd, 0xa08e,
+	0x0214, 0x0118, 0xa08e, 0x0210, 0x1130, 0x2009, 0x0015, 0x080c,
+	0x864c, 0x0804, 0x65fd, 0xa08e, 0x0100, 0x1904, 0x65fd, 0x7034,
+	0xa005, 0x1904, 0x65fd, 0x2009, 0x0016, 0x080c, 0x864c, 0x0804,
+	0x65fd, 0xa08e, 0x0022, 0x1904, 0x65fd, 0x7030, 0xa08e, 0x0300,
+	0x1580, 0x68d4, 0xd0a4, 0x0528, 0xc0b5, 0x68d6, 0x7100, 0xa18c,
+	0x00ff, 0x6972, 0x7004, 0x6876, 0x00f6, 0x2079, 0x0100, 0x79e6,
+	0x78ea, 0x0006, 0xa084, 0x00ff, 0x0016, 0x2008, 0x080c, 0x2847,
+	0x7932, 0x7936, 0x001e, 0x000e, 0x00fe, 0x080c, 0x281d, 0x6952,
+	0x703c, 0x00e6, 0x2071, 0x0140, 0x7086, 0x2071, 0xb500, 0x70a6,
+	0x00ee, 0x7034, 0xa005, 0x1904, 0x65fd, 0x2009, 0x0017, 0x0804,
+	0x65c3, 0xa08e, 0x0400, 0x1158, 0x7034, 0xa005, 0x1904, 0x65fd,
+	0x68d4, 0xc0a5, 0x68d6, 0x2009, 0x0030, 0x0804, 0x65c3, 0xa08e,
+	0x0500, 0x1140, 0x7034, 0xa005, 0x1904, 0x65fd, 0x2009, 0x0018,
+	0x0804, 0x65c3, 0xa08e, 0x2010, 0x1120, 0x2009, 0x0019, 0x0804,
+	0x65c3, 0xa08e, 0x2110, 0x1120, 0x2009, 0x001a, 0x0804, 0x65c3,
+	0xa08e, 0x5200, 0x1140, 0x7034, 0xa005, 0x1904, 0x65fd, 0x2009,
+	0x001b, 0x0804, 0x65c3, 0xa08e, 0x5000, 0x1140, 0x7034, 0xa005,
+	0x1904, 0x65fd, 0x2009, 0x001c, 0x0804, 0x65c3, 0xa08e, 0x1300,
+	0x1120, 0x2009, 0x0034, 0x0804, 0x65c3, 0xa08e, 0x1200, 0x1140,
+	0x7034, 0xa005, 0x1904, 0x65fd, 0x2009, 0x0024, 0x0804, 0x65c3,
+	0xa08c, 0xff00, 0xa18e, 0x2400, 0x1118, 0x2009, 0x002d, 0x04d8,
+	0xa08c, 0xff00, 0xa18e, 0x5300, 0x1118, 0x2009, 0x002a, 0x0498,
+	0xa08e, 0x0f00, 0x1118, 0x2009, 0x0020, 0x0468, 0xa08e, 0x5300,
+	0x1108, 0x00d8, 0xa08e, 0x6104, 0x11c0, 0x2011, 0xbb8d, 0x8208,
+	0x2204, 0xa082, 0x0004, 0x20a8, 0x95ac, 0x95ac, 0x2011, 0x8015,
+	0x211c, 0x8108, 0x0046, 0x2124, 0x080c, 0x3ecc, 0x004e, 0x8108,
+	0x1f04, 0x65a6, 0x2009, 0x0023, 0x0070, 0xa08e, 0x6000, 0x1118,
+	0x2009, 0x003f, 0x0040, 0xa08e, 0x7800, 0x1118, 0x2009, 0x0045,
+	0x0010, 0x2009, 0x001d, 0x0016, 0x2011, 0xbb83, 0x2204, 0x8211,
+	0x220c, 0x080c, 0x281d, 0x1598, 0x080c, 0x4f4d, 0x1580, 0x6612,
+	0x6516, 0x86ff, 0x01e8, 0x001e, 0x0016, 0xa186, 0x0017, 0x1158,
+	0x6870, 0xa606, 0x11a8, 0x6874, 0xa506, 0xa084, 0xff00, 0x1180,
+	0x6000, 0xc0f5, 0x6002, 0xa186, 0x0046, 0x1150, 0x6870, 0xa606,
+	0x1138, 0x6874, 0xa506, 0xa084, 0xff00, 0x1110, 0x001e, 0x0068,
+	0x00c6, 0x080c, 0x85c7, 0x0168, 0x001e, 0x611a, 0x601f, 0x0004,
+	0x7120, 0x610a, 0x001e, 0x080c, 0x864c, 0x00ce, 0x0005, 0x001e,
+	0x0ce0, 0x00ce, 0x0ce0, 0x00c6, 0x0046, 0x080c, 0x6657, 0x1904,
+	0x6654, 0xa28e, 0x0033, 0x11e8, 0x080c, 0x684f, 0x0904, 0x6654,
+	0x7124, 0x610a, 0x7030, 0xa08e, 0x0200, 0x1140, 0x7034, 0xa005,
+	0x15d8, 0x2009, 0x0015, 0x080c, 0x864c, 0x04b0, 0xa08e, 0x0100,
+	0x1598, 0x7034, 0xa005, 0x1580, 0x2009, 0x0016, 0x080c, 0x864c,
+	0x0458, 0xa28e, 0x0032, 0x1540, 0x7030, 0xa08e, 0x1400, 0x1520,
+	0x2009, 0x0038, 0x0016, 0x2011, 0xbb83, 0x2204, 0x8211, 0x220c,
+	0x080c, 0x281d, 0x11c0, 0x080c, 0x4f4d, 0x11a8, 0x6612, 0x6516,
+	0x00c6, 0x080c, 0x85c7, 0x0170, 0x001e, 0x611a, 0x080c, 0xa027,
+	0x601f, 0x0004, 0x7120, 0x610a, 0x001e, 0x080c, 0x864c, 0x080c,
+	0x7173, 0x0010, 0x00ce, 0x001e, 0x004e, 0x00ce, 0x0005, 0x00f6,
+	0x00d6, 0x0026, 0x0016, 0x0136, 0x0146, 0x0156, 0x3c00, 0x0006,
+	0x2079, 0x0030, 0x2069, 0x0200, 0x080c, 0x1f2d, 0x1590, 0x080c,
+	0x1dd2, 0x05e0, 0x04f1, 0x1130, 0x7908, 0xa18c, 0x1fff, 0xa182,
+	0x0011, 0x1688, 0x20a9, 0x000c, 0x20e1, 0x0000, 0x2ea0, 0x2099,
+	0x020a, 0x53a5, 0x20e1, 0x2000, 0x2001, 0x020a, 0x2004, 0x7a0c,
+	0x7808, 0xa080, 0x0007, 0xa084, 0x1ff8, 0x0419, 0x1120, 0xa08a,
+	0x0140, 0x1a0c, 0x1515, 0x80ac, 0x20e1, 0x6000, 0x2099, 0x020a,
+	0x53a5, 0x20e1, 0x7000, 0x6828, 0x6828, 0x7803, 0x0004, 0xa294,
+	0x0070, 0x000e, 0x20e0, 0x015e, 0x014e, 0x013e, 0x001e, 0x002e,
+	0x00de, 0x00fe, 0x0005, 0xa016, 0x080c, 0x185e, 0xa085, 0x0001,
+	0x0c80, 0x0006, 0x2001, 0x0111, 0x2004, 0xa084, 0x0003, 0x000e,
+	0x0005, 0x0046, 0x00e6, 0x00d6, 0x2028, 0x2130, 0xa696, 0x00ff,
+	0x1198, 0xa596, 0xfffd, 0x1120, 0x2009, 0x007f, 0x0804, 0x6703,
+	0xa596, 0xfffe, 0x1118, 0x2009, 0x007e, 0x04e8, 0xa596, 0xfffc,
+	0x1118, 0x2009, 0x0080, 0x04b8, 0x2011, 0x0000, 0x2019, 0xb535,
+	0x231c, 0xd3ac, 0x0138, 0x2021, 0x0000, 0x20a9, 0x00ff, 0x2071,
+	0xb635, 0x0030, 0x2021, 0x0081, 0x20a9, 0x007e, 0x2071, 0xb6b6,
+	0x2e1c, 0x83ff, 0x1128, 0x82ff, 0x1198, 0x2410, 0xc2fd, 0x0080,
+	0x2368, 0x6f10, 0x0006, 0x2100, 0xa706, 0x000e, 0x6b14, 0x1120,
+	0xa346, 0x1110, 0x2408, 0x0078, 0x87ff, 0x1110, 0x83ff, 0x0d58,
+	0x8420, 0x8e70, 0x1f04, 0x66e0, 0x82ff, 0x1118, 0xa085, 0x0001,
+	0x0018, 0xc2fc, 0x2208, 0xa006, 0x00de, 0x00ee, 0x004e, 0x0005,
+	0xa084, 0x0007, 0x000a, 0x0005, 0x6714, 0x6714, 0x6714, 0x6861,
+	0x6714, 0x6715, 0x672a, 0x679f, 0x0005, 0x7110, 0xd1bc, 0x0188,
+	0x7120, 0x2160, 0xac8c, 0x0007, 0x1160, 0xac8a, 0xbd00, 0x0248,
+	0x685c, 0xac02, 0x1230, 0x7124, 0x610a, 0x2009, 0x0046, 0x080c,
+	0x864c, 0x0005, 0x00c6, 0xa484, 0x01ff, 0x0904, 0x677d, 0x7110,
+	0xd1bc, 0x1904, 0x677d, 0x2011, 0xbb83, 0x2204, 0x8211, 0x220c,
+	0x080c, 0x281d, 0x1904, 0x677d, 0x080c, 0x4f4d, 0x15f0, 0x6612,
+	0x6516, 0x6000, 0xd0ec, 0x15c8, 0x6204, 0xa294, 0xff00, 0x8217,
+	0xa286, 0x0006, 0x0148, 0x6204, 0xa294, 0x00ff, 0xa286, 0x0006,
+	0x11a0, 0xa295, 0x0600, 0x6206, 0x00c6, 0x080c, 0x85c7, 0x001e,
+	0x0530, 0x611a, 0x601f, 0x0006, 0x7120, 0x610a, 0x7130, 0x6152,
+	0x2009, 0x0044, 0x080c, 0x864c, 0x00c0, 0x00c6, 0x080c, 0x85c7,
+	0x001e, 0x0198, 0x611a, 0x601f, 0x0004, 0x7120, 0x610a, 0xa286,
+	0x0004, 0x1118, 0x6007, 0x0005, 0x0010, 0x6007, 0x0001, 0x6003,
+	0x0001, 0x080c, 0x6cd3, 0x080c, 0x7173, 0x00ce, 0x0005, 0x2001,
+	0xb50d, 0x2004, 0xd0ec, 0x0120, 0x2011, 0x8049, 0x080c, 0x3ecc,
+	0x00c6, 0x080c, 0x9ed6, 0x001e, 0x0d80, 0x611a, 0x601f, 0x0006,
+	0x7120, 0x610a, 0x7130, 0x6152, 0x6013, 0x0300, 0x6003, 0x0001,
+	0x6007, 0x0041, 0x080c, 0x6c8d, 0x080c, 0x7173, 0x08f0, 0x7110,
+	0xd1bc, 0x0188, 0x7020, 0x2060, 0xac84, 0x0007, 0x1160, 0xac82,
+	0xbd00, 0x0248, 0x685c, 0xac02, 0x1230, 0x7124, 0x610a, 0x2009,
+	0x0045, 0x080c, 0x864c, 0x0005, 0x0006, 0x080c, 0x2dbf, 0x000e,
+	0x1168, 0x7110, 0xa18c, 0xff00, 0x810f, 0xa18e, 0x0000, 0x1130,
+	0xa084, 0x000f, 0xa08a, 0x0006, 0x1208, 0x000b, 0x0005, 0x67cd,
+	0x67ce, 0x67cd, 0x67cd, 0x6837, 0x6843, 0x0005, 0x7110, 0xd1bc,
+	0x0120, 0x702c, 0xd084, 0x0904, 0x6836, 0x700c, 0x7108, 0x080c,
+	0x281d, 0x1904, 0x6836, 0x080c, 0x4f4d, 0x1904, 0x6836, 0x6612,
+	0x6516, 0x6204, 0x7110, 0xd1bc, 0x01f8, 0xa28c, 0x00ff, 0xa186,
+	0x0004, 0x0118, 0xa186, 0x0006, 0x15c8, 0x00c6, 0x080c, 0x684f,
+	0x00ce, 0x0904, 0x6836, 0x00c6, 0x080c, 0x85c7, 0x001e, 0x05f0,
+	0x611a, 0x080c, 0xa027, 0x601f, 0x0002, 0x7120, 0x610a, 0x2009,
+	0x0088, 0x080c, 0x864c, 0x0490, 0xa28c, 0x00ff, 0xa186, 0x0006,
+	0x0160, 0xa186, 0x0004, 0x0148, 0xa294, 0xff00, 0x8217, 0xa286,
+	0x0004, 0x0118, 0xa286, 0x0006, 0x1188, 0x00c6, 0x080c, 0x85c7,
+	0x001e, 0x01e0, 0x611a, 0x080c, 0xa027, 0x601f, 0x0005, 0x7120,
+	0x610a, 0x2009, 0x0088, 0x080c, 0x864c, 0x0080, 0x00c6, 0x080c,
+	0x85c7, 0x001e, 0x0158, 0x611a, 0x080c, 0xa027, 0x601f, 0x0004,
+	0x7120, 0x610a, 0x2009, 0x0001, 0x080c, 0x864c, 0x0005, 0x7110,
+	0xd1bc, 0x0140, 0x00a1, 0x0130, 0x7124, 0x610a, 0x2009, 0x0089,
+	0x080c, 0x864c, 0x0005, 0x7110, 0xd1bc, 0x0140, 0x0041, 0x0130,
+	0x7124, 0x610a, 0x2009, 0x008a, 0x080c, 0x864c, 0x0005, 0x7020,
+	0x2060, 0xac84, 0x0007, 0x1158, 0xac82, 0xbd00, 0x0240, 0x2001,
+	0xb517, 0x2004, 0xac02, 0x1218, 0xa085, 0x0001, 0x0005, 0xa006,
+	0x0ce8, 0x7110, 0xd1bc, 0x1178, 0x7024, 0x2060, 0xac84, 0x0007,
+	0x1150, 0xac82, 0xbd00, 0x0238, 0x685c, 0xac02, 0x1220, 0x2009,
+	0x0051, 0x080c, 0x864c, 0x0005, 0x2031, 0x0105, 0x0069, 0x0005,
+	0x2031, 0x0206, 0x0049, 0x0005, 0x2031, 0x0207, 0x0029, 0x0005,
+	0x2031, 0x0213, 0x0009, 0x0005, 0x00c6, 0x00d6, 0x00f6, 0x7000,
+	0xa084, 0xf000, 0xa086, 0xc000, 0x05b0, 0x080c, 0x85c7, 0x0598,
+	0x0066, 0x00c6, 0x0046, 0x2011, 0xbb83, 0x2204, 0x8211, 0x220c,
+	0x080c, 0x281d, 0x1580, 0x080c, 0x4f4d, 0x1568, 0x6612, 0x6516,
+	0x2c00, 0x004e, 0x00ce, 0x601a, 0x080c, 0xa027, 0x080c, 0x15f8,
+	0x01f0, 0x2d00, 0x6056, 0x6803, 0x0000, 0x6837, 0x0000, 0x6c3a,
+	0xadf8, 0x000f, 0x20a9, 0x000e, 0x2fa0, 0x2e98, 0x53a3, 0x006e,
+	0x6612, 0x6007, 0x003e, 0x601f, 0x0001, 0x6003, 0x0001, 0x080c,
+	0x6cd3, 0x080c, 0x7173, 0x00fe, 0x00de, 0x00ce, 0x0005, 0x080c,
+	0x861d, 0x006e, 0x0cc0, 0x004e, 0x00ce, 0x0cc8, 0x2071, 0xb7f3,
+	0x7003, 0x0003, 0x700f, 0x0361, 0xa006, 0x701a, 0x7076, 0x7012,
+	0x7017, 0xbd00, 0x7007, 0x0000, 0x7026, 0x702b, 0x7d91, 0x7032,
+	0x7037, 0x7df1, 0x703b, 0xffff, 0x703f, 0xffff, 0x7042, 0x7047,
+	0x444b, 0x704a, 0x705b, 0x6a2b, 0x2001, 0xb7a1, 0x2003, 0x0003,
+	0x2001, 0xb7a3, 0x2003, 0x0100, 0x3a00, 0xa084, 0x0005, 0x706e,
+	0x0005, 0x2071, 0xb7f3, 0x1d04, 0x698b, 0x2091, 0x6000, 0x700c,
+	0x8001, 0x700e, 0x1518, 0x700f, 0x0361, 0x7007, 0x0001, 0x0126,
+	0x2091, 0x8000, 0x7040, 0xa00d, 0x0128, 0x8109, 0x7142, 0x1110,
+	0x7044, 0x080f, 0x00c6, 0x2061, 0xb500, 0x6034, 0x00ce, 0xd0cc,
+	0x0180, 0x3a00, 0xa084, 0x0005, 0x726c, 0xa216, 0x0150, 0x706e,
+	0x2011, 0x8043, 0x2018, 0x080c, 0x3ecc, 0x0018, 0x0126, 0x2091,
+	0x8000, 0x7024, 0xa00d, 0x0188, 0x7020, 0x8001, 0x7022, 0x1168,
+	0x7023, 0x0009, 0x8109, 0x7126, 0xa186, 0x03e8, 0x1110, 0x7028,
+	0x080f, 0x81ff, 0x1110, 0x7028, 0x080f, 0x7030, 0xa00d, 0x0180,
+	0x702c, 0x8001, 0x702e, 0x1160, 0x702f, 0x0009, 0x8109, 0x7132,
+	0x0128, 0xa184, 0x007f, 0x090c, 0x7e36, 0x0010, 0x7034, 0x080f,
+	0x7038, 0xa005, 0x0118, 0x0310, 0x8001, 0x703a, 0x703c, 0xa005,
+	0x0118, 0x0310, 0x8001, 0x703e, 0x704c, 0xa00d, 0x0168, 0x7048,
+	0x8001, 0x704a, 0x1148, 0x704b, 0x0009, 0x8109, 0x714e, 0x1120,
+	0x7150, 0x714e, 0x7058, 0x080f, 0x7018, 0xa00d, 0x01d8, 0x0016,
+	0x7074, 0xa00d, 0x0158, 0x7070, 0x8001, 0x7072, 0x1138, 0x7073,
+	0x0009, 0x8109, 0x7176, 0x1110, 0x7078, 0x080f, 0x001e, 0x7008,
+	0x8001, 0x700a, 0x1138, 0x700b, 0x0009, 0x8109, 0x711a, 0x1110,
+	0x701c, 0x080f, 0x012e, 0x7004, 0x0002, 0x69b1, 0x69b2, 0x69ca,
+	0x00e6, 0x2071, 0xb7f3, 0x7018, 0xa005, 0x1120, 0x711a, 0x721e,
+	0x700b, 0x0009, 0x00ee, 0x0005, 0x00e6, 0x0006, 0x2071, 0xb7f3,
+	0x701c, 0xa206, 0x1110, 0x701a, 0x701e, 0x000e, 0x00ee, 0x0005,
+	0x00e6, 0x2071, 0xb7f3, 0x6088, 0xa102, 0x0208, 0x618a, 0x00ee,
+	0x0005, 0x0005, 0x7110, 0x080c, 0x4fa9, 0x1158, 0x6088, 0x8001,
+	0x0240, 0x608a, 0x1130, 0x0126, 0x2091, 0x8000, 0x080c, 0x7173,
+	0x012e, 0x8108, 0xa182, 0x00ff, 0x0218, 0xa00e, 0x7007, 0x0002,
+	0x7112, 0x0005, 0x7014, 0x2060, 0x0126, 0x2091, 0x8000, 0x603c,
+	0xa005, 0x0128, 0x8001, 0x603e, 0x1110, 0x080c, 0x9f15, 0x6014,
+	0xa005, 0x0500, 0x8001, 0x6016, 0x11e8, 0x611c, 0xa186, 0x0003,
+	0x0118, 0xa186, 0x0006, 0x11a0, 0x6010, 0x2068, 0x6854, 0xa08a,
+	0x199a, 0x0270, 0xa082, 0x1999, 0x6856, 0xa08a, 0x199a, 0x0210,
+	0x2001, 0x1999, 0x8003, 0x800b, 0x810b, 0xa108, 0x6116, 0x0010,
+	0x080c, 0x99e5, 0x012e, 0xac88, 0x0018, 0x7116, 0x2001, 0xed00,
+	0xa102, 0x0220, 0x7017, 0xbd00, 0x7007, 0x0000, 0x0005, 0x00e6,
+	0x2071, 0xb7f3, 0x7027, 0x07d0, 0x7023, 0x0009, 0x00ee, 0x0005,
+	0x2001, 0xb7fc, 0x2003, 0x0000, 0x0005, 0x00e6, 0x2071, 0xb7f3,
+	0x7132, 0x702f, 0x0009, 0x00ee, 0x0005, 0x2011, 0xb7ff, 0x2013,
+	0x0000, 0x0005, 0x00e6, 0x2071, 0xb7f3, 0x711a, 0x721e, 0x700b,
+	0x0009, 0x00ee, 0x0005, 0x00c6, 0x0026, 0x7054, 0x8000, 0x7056,
+	0x2061, 0xb7a1, 0x6008, 0xa086, 0x0000, 0x0158, 0x7068, 0x6032,
+	0x7064, 0x602e, 0x7060, 0x602a, 0x705c, 0x6026, 0x2c10, 0x080c,
+	0x1643, 0x002e, 0x00ce, 0x0005, 0x0006, 0x0016, 0x00c6, 0x00d6,
+	0x00e6, 0x00f6, 0x080c, 0x68f9, 0x00fe, 0x00ee, 0x00de, 0x00ce,
+	0x001e, 0x000e, 0x0005, 0x00e6, 0x2071, 0xb7f3, 0x7176, 0x727a,
+	0x7073, 0x0009, 0x00ee, 0x0005, 0x00e6, 0x0006, 0x2071, 0xb7f3,
+	0x7078, 0xa206, 0x1110, 0x7076, 0x707a, 0x000e, 0x00ee, 0x0005,
+	0x00c6, 0x2061, 0xb874, 0x00ce, 0x0005, 0xa184, 0x000f, 0x8003,
+	0x8003, 0x8003, 0xa080, 0xb874, 0x2060, 0x0005, 0x6854, 0xa08a,
+	0x199a, 0x0210, 0x2001, 0x1999, 0xa005, 0x1150, 0x00c6, 0x2061,
+	0xb874, 0x6014, 0x00ce, 0xa005, 0x1138, 0x2001, 0x001e, 0x0020,
+	0xa08e, 0xffff, 0x1108, 0xa006, 0x8003, 0x800b, 0x810b, 0xa108,
+	0x6116, 0x684c, 0xa08c, 0x00c0, 0xa18e, 0x00c0, 0x05e8, 0xd0b4,
+	0x1138, 0xd0bc, 0x1550, 0x2009, 0x0006, 0x080c, 0x6af1, 0x0005,
+	0xd0fc, 0x0138, 0xa084, 0x0003, 0x0120, 0xa086, 0x0003, 0x1904,
+	0x6aeb, 0x6020, 0xd0d4, 0x0130, 0xc0d4, 0x6022, 0x6860, 0x602a,
+	0x685c, 0x602e, 0x2009, 0xb574, 0x2104, 0xd084, 0x0138, 0x87ff,
+	0x1120, 0x2009, 0x0042, 0x080c, 0x864c, 0x0005, 0x87ff, 0x1120,
+	0x2009, 0x0043, 0x080c, 0x864c, 0x0005, 0xd0fc, 0x0130, 0xa084,
+	0x0003, 0x0118, 0xa086, 0x0003, 0x11f0, 0x87ff, 0x1120, 0x2009,
+	0x0042, 0x080c, 0x864c, 0x0005, 0xd0fc, 0x0160, 0xa084, 0x0003,
+	0xa08e, 0x0002, 0x0148, 0x87ff, 0x1120, 0x2009, 0x0041, 0x080c,
+	0x864c, 0x0005, 0x0061, 0x0ce8, 0x87ff, 0x1dd8, 0x2009, 0x0043,
+	0x080c, 0x864c, 0x0cb0, 0x2009, 0x0004, 0x0019, 0x0005, 0x2009,
+	0x0001, 0x00d6, 0x6010, 0xa0ec, 0xf000, 0x0510, 0x2068, 0x6952,
+	0x6800, 0x6012, 0xa186, 0x0001, 0x1188, 0x694c, 0xa18c, 0x8100,
+	0xa18e, 0x8100, 0x1158, 0x00c6, 0x2061, 0xb874, 0x6200, 0xd28c,
+	0x1120, 0x6204, 0x8210, 0x0208, 0x6206, 0x00ce, 0x080c, 0x5408,
+	0x6010, 0xa06d, 0x0076, 0x2039, 0x0000, 0x190c, 0x6a76, 0x007e,
+	0x00de, 0x0005, 0x0156, 0x00c6, 0x2061, 0xb874, 0x6000, 0x81ff,
+	0x0110, 0xa205, 0x0008, 0xa204, 0x6002, 0x00ce, 0x015e, 0x0005,
+	0x6800, 0xd08c, 0x1138, 0x6808, 0xa005, 0x0120, 0x8001, 0x680a,
+	0xa085, 0x0001, 0x0005, 0x20a9, 0x0010, 0xa006, 0x8004, 0x8086,
+	0x818e, 0x1208, 0xa200, 0x1f04, 0x6b37, 0x8086, 0x818e, 0x0005,
+	0x0156, 0x20a9, 0x0010, 0xa005, 0x01b8, 0xa11a, 0x12a8, 0x8213,
+	0x818d, 0x0228, 0xa11a, 0x1220, 0x1f04, 0x6b47, 0x0028, 0xa11a,
+	0x2308, 0x8210, 0x1f04, 0x6b47, 0x0006, 0x3200, 0xa084, 0xefff,
+	0x2080, 0x000e, 0x015e, 0x0005, 0x0006, 0x3200, 0xa085, 0x1000,
+	0x0cb8, 0x0126, 0x2091, 0x2800, 0x2079, 0xb7e0, 0x012e, 0x00d6,
+	0x2069, 0xb7e0, 0x6803, 0x0005, 0x2069, 0x0004, 0x2d04, 0xa085,
+	0x8001, 0x206a, 0x00de, 0x0005, 0x00c6, 0x6027, 0x0001, 0x7804,
+	0xa084, 0x0007, 0x0002, 0x6b85, 0x6ba6, 0x6bf9, 0x6b8b, 0x6ba6,
+	0x6b85, 0x6b83, 0x6b83, 0x080c, 0x1515, 0x080c, 0x6a10, 0x080c,
+	0x7173, 0x00ce, 0x0005, 0x62c0, 0x82ff, 0x1110, 0x00ce, 0x0005,
+	0x2011, 0x4adc, 0x080c, 0x699c, 0x7828, 0xa092, 0x00c8, 0x1228,
+	0x8000, 0x782a, 0x080c, 0x4b16, 0x0c88, 0x080c, 0x4adc, 0x7807,
+	0x0003, 0x7827, 0x0000, 0x782b, 0x0000, 0x0c40, 0x080c, 0x6a10,
+	0x3c00, 0x0006, 0x2011, 0x0209, 0x20e1, 0x4000, 0x2214, 0x000e,
+	0x20e0, 0x82ff, 0x0178, 0x62c0, 0x82ff, 0x1160, 0x782b, 0x0000,
+	0x7824, 0xa065, 0x090c, 0x1515, 0x2009, 0x0013, 0x080c, 0x864c,
+	0x00ce, 0x0005, 0x3900, 0xa082, 0xb92c, 0x1210, 0x080c, 0x8332,
+	0x00c6, 0x7824, 0xa065, 0x090c, 0x1515, 0x7804, 0xa086, 0x0004,
+	0x0904, 0x6c39, 0x7828, 0xa092, 0x2710, 0x1230, 0x8000, 0x782a,
+	0x00ce, 0x080c, 0x7d6d, 0x0c20, 0x6104, 0xa186, 0x0003, 0x1188,
+	0x00e6, 0x2071, 0xb500, 0x70e0, 0x00ee, 0xd08c, 0x0150, 0x00c6,
+	0x00e6, 0x2061, 0x0100, 0x2071, 0xb500, 0x080c, 0x4b1f, 0x00ee,
+	0x00ce, 0x080c, 0xb444, 0x2009, 0x0014, 0x080c, 0x864c, 0x00ce,
+	0x0838, 0x2001, 0xb7fc, 0x2003, 0x0000, 0x62c0, 0x82ff, 0x1160,
+	0x782b, 0x0000, 0x7824, 0xa065, 0x090c, 0x1515, 0x2009, 0x0013,
+	0x080c, 0x86a0, 0x00ce, 0x0005, 0x00c6, 0x00d6, 0x3900, 0xa082,
+	0xb92c, 0x1210, 0x080c, 0x8332, 0x7824, 0xa005, 0x090c, 0x1515,
+	0x781c, 0xa06d, 0x090c, 0x1515, 0x6800, 0xc0dc, 0x6802, 0x7924,
+	0x2160, 0x080c, 0x861d, 0x693c, 0x81ff, 0x090c, 0x1515, 0x8109,
+	0x693e, 0x6854, 0xa015, 0x0110, 0x7a1e, 0x0010, 0x7918, 0x791e,
+	0x7807, 0x0000, 0x7827, 0x0000, 0x00de, 0x00ce, 0x080c, 0x7173,
+	0x0888, 0x6104, 0xa186, 0x0002, 0x0128, 0xa186, 0x0004, 0x0110,
+	0x0804, 0x6bd2, 0x7808, 0xac06, 0x0904, 0x6bd2, 0x080c, 0x7090,
+	0x080c, 0x6cd3, 0x00ce, 0x080c, 0x7173, 0x0804, 0x6bc0, 0x00c6,
+	0x6027, 0x0002, 0x62c8, 0x60c4, 0xa205, 0x1178, 0x793c, 0xa1e5,
+	0x0000, 0x0130, 0x2009, 0x0049, 0x080c, 0x864c, 0x00ce, 0x0005,
+	0x2011, 0xb7ff, 0x2013, 0x0000, 0x0cc8, 0x3908, 0xa192, 0xb92c,
+	0x1210, 0x080c, 0x8332, 0x793c, 0x81ff, 0x0d90, 0x7944, 0xa192,
+	0x7530, 0x12b8, 0x8108, 0x7946, 0x793c, 0xa188, 0x0007, 0x210c,
+	0xa18e, 0x0006, 0x1138, 0x6014, 0xa084, 0x0184, 0xa085, 0x0012,
+	0x6016, 0x08e0, 0x6014, 0xa084, 0x0184, 0xa085, 0x0016, 0x6016,
+	0x08a8, 0x7848, 0xc085, 0x784a, 0x0888, 0x0006, 0x0016, 0x00c6,
+	0x0126, 0x2091, 0x8000, 0x600f, 0x0000, 0x2c08, 0x2061, 0xb7e0,
+	0x6020, 0x8000, 0x6022, 0x6010, 0xa005, 0x0148, 0xa080, 0x0003,
+	0x2102, 0x6112, 0x012e, 0x00ce, 0x001e, 0x000e, 0x0005, 0x6116,
+	0x6112, 0x0cc0, 0x00d6, 0x2069, 0xb7e0, 0x6000, 0xd0d4, 0x0168,
+	0x6820, 0x8000, 0x6822, 0xa086, 0x0001, 0x1110, 0x2c00, 0x681e,
+	0x6804, 0xa084, 0x0007, 0x0804, 0x7179, 0xc0d5, 0x6002, 0x6818,
+	0xa005, 0x0158, 0x6056, 0x605b, 0x0000, 0x0006, 0x2c00, 0x681a,
+	0x00de, 0x685a, 0x2069, 0xb7e0, 0x0c18, 0x6056, 0x605a, 0x2c00,
+	0x681a, 0x681e, 0x08e8, 0x0006, 0x0016, 0x00c6, 0x0126, 0x2091,
+	0x8000, 0x600f, 0x0000, 0x2c08, 0x2061, 0xb7e0, 0x6020, 0x8000,
+	0x6022, 0x6008, 0xa005, 0x0148, 0xa080, 0x0003, 0x2102, 0x610a,
+	0x012e, 0x00ce, 0x001e, 0x000e, 0x0005, 0x610e, 0x610a, 0x0cc0,
+	0x00c6, 0x600f, 0x0000, 0x2c08, 0x2061, 0xb7e0, 0x6034, 0xa005,
+	0x0130, 0xa080, 0x0003, 0x2102, 0x6136, 0x00ce, 0x0005, 0x613a,
+	0x6136, 0x0cd8, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0076, 0x0066,
+	0x0056, 0x0036, 0x0026, 0x0016, 0x0006, 0x0126, 0xa02e, 0x2071,
+	0xb7e0, 0x7638, 0x2660, 0x2678, 0x2091, 0x8000, 0x8cff, 0x0904,
+	0x6d7b, 0x6018, 0xa080, 0x0028, 0x2004, 0xa206, 0x1904, 0x6d76,
+	0x87ff, 0x0120, 0x6050, 0xa106, 0x1904, 0x6d76, 0x703c, 0xac06,
+	0x1190, 0x0036, 0x2019, 0x0001, 0x080c, 0x7fe4, 0x7033, 0x0000,
+	0x703f, 0x0000, 0x7043, 0x0000, 0x7047, 0x0000, 0x704b, 0x0000,
+	0x003e, 0x2029, 0x0001, 0x7038, 0xac36, 0x1110, 0x660c, 0x763a,
+	0x7034, 0xac36, 0x1140, 0x2c00, 0xaf36, 0x0118, 0x2f00, 0x7036,
+	0x0010, 0x7037, 0x0000, 0x660c, 0x0066, 0x2c00, 0xaf06, 0x0110,
+	0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000, 0x080c, 0x9c5a, 0x01c8,
+	0x6010, 0x2068, 0x601c, 0xa086, 0x0003, 0x1580, 0x6837, 0x0103,
+	0x6b4a, 0x6847, 0x0000, 0x0016, 0x0036, 0x0076, 0x080c, 0x9ecc,
+	0x080c, 0xb380, 0x080c, 0x5408, 0x007e, 0x003e, 0x001e, 0x080c,
+	0x9e11, 0x080c, 0x9e1d, 0x00ce, 0x0804, 0x6d16, 0x2c78, 0x600c,
+	0x2060, 0x0804, 0x6d16, 0x85ff, 0x0120, 0x0036, 0x080c, 0x7230,
+	0x003e, 0x012e, 0x000e, 0x001e, 0x002e, 0x003e, 0x005e, 0x006e,
+	0x007e, 0x00ce, 0x00de, 0x00ee, 0x00fe, 0x0005, 0x601c, 0xa086,
+	0x0006, 0x1158, 0x0016, 0x0036, 0x0076, 0x080c, 0xb380, 0x080c,
+	0xb099, 0x007e, 0x003e, 0x001e, 0x08a0, 0x601c, 0xa086, 0x000a,
+	0x0904, 0x6d60, 0x0804, 0x6d5e, 0x0006, 0x0066, 0x00c6, 0x00d6,
+	0x00f6, 0x2031, 0x0000, 0x0126, 0x2091, 0x8000, 0x2079, 0xb7e0,
+	0x7838, 0xa065, 0x0568, 0x600c, 0x0006, 0x600f, 0x0000, 0x783c,
+	0xac06, 0x1180, 0x0036, 0x2019, 0x0001, 0x080c, 0x7fe4, 0x7833,
+	0x0000, 0x783f, 0x0000, 0x7843, 0x0000, 0x7847, 0x0000, 0x784b,
+	0x0000, 0x003e, 0x080c, 0x9c5a, 0x0178, 0x6010, 0x2068, 0x601c,
+	0xa086, 0x0003, 0x11b0, 0x6837, 0x0103, 0x6b4a, 0x6847, 0x0000,
+	0x080c, 0x5408, 0x080c, 0x9e11, 0x080c, 0x9e1d, 0x000e, 0x0888,
+	0x7e3a, 0x7e36, 0x012e, 0x00fe, 0x00de, 0x00ce, 0x006e, 0x000e,
+	0x0005, 0x601c, 0xa086, 0x0006, 0x1118, 0x080c, 0xb099, 0x0c60,
+	0x601c, 0xa086, 0x000a, 0x0d08, 0x08f0, 0x0016, 0x0026, 0x0086,
+	0x2041, 0x0000, 0x0099, 0x080c, 0x6ec3, 0x008e, 0x002e, 0x001e,
+	0x0005, 0x00f6, 0x0126, 0x2079, 0xb7e0, 0x2091, 0x8000, 0x080c,
+	0x6f50, 0x080c, 0x6fc2, 0x012e, 0x00fe, 0x0005, 0x00f6, 0x00e6,
+	0x00d6, 0x00c6, 0x0066, 0x0016, 0x0006, 0x0126, 0x2091, 0x8000,
+	0x2071, 0xb7e0, 0x7614, 0x2660, 0x2678, 0x8cff, 0x0904, 0x6e99,
+	0x6018, 0xa080, 0x0028, 0x2004, 0xa206, 0x1904, 0x6e94, 0x88ff,
+	0x0120, 0x6050, 0xa106, 0x1904, 0x6e94, 0x7024, 0xac06, 0x1538,
+	0x2069, 0x0100, 0x68c0, 0xa005, 0x01f0, 0x080c, 0x6a10, 0x080c,
+	0x7d7a, 0x68c3, 0x0000, 0x080c, 0x824d, 0x7027, 0x0000, 0x0036,
+	0x2069, 0x0140, 0x6b04, 0xa384, 0x1000, 0x0120, 0x6803, 0x0100,
+	0x6803, 0x0000, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827,
+	0x0001, 0x003e, 0x0020, 0x6003, 0x0009, 0x630a, 0x04e8, 0x7014,
+	0xac36, 0x1110, 0x660c, 0x7616, 0x7010, 0xac36, 0x1140, 0x2c00,
+	0xaf36, 0x0118, 0x2f00, 0x7012, 0x0010, 0x7013, 0x0000, 0x660c,
+	0x0066, 0x2c00, 0xaf06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f,
+	0x0000, 0x6010, 0x2068, 0x080c, 0x9c5a, 0x01b8, 0x601c, 0xa086,
+	0x0003, 0x1540, 0x6837, 0x0103, 0x6b4a, 0x6847, 0x0000, 0x0016,
+	0x0036, 0x0086, 0x080c, 0x9ecc, 0x080c, 0xb380, 0x080c, 0x5408,
+	0x008e, 0x003e, 0x001e, 0x080c, 0x9e11, 0x080c, 0x9e1d, 0x080c,
+	0x811e, 0x00ce, 0x0804, 0x6e1d, 0x2c78, 0x600c, 0x2060, 0x0804,
+	0x6e1d, 0x012e, 0x000e, 0x001e, 0x006e, 0x00ce, 0x00de, 0x00ee,
+	0x00fe, 0x0005, 0x601c, 0xa086, 0x0006, 0x1158, 0x0016, 0x0036,
+	0x0086, 0x080c, 0xb380, 0x080c, 0xb099, 0x008e, 0x003e, 0x001e,
+	0x08e0, 0x601c, 0xa086, 0x0002, 0x1128, 0x6004, 0xa086, 0x0085,
+	0x0908, 0x0898, 0x601c, 0xa086, 0x0005, 0x1978, 0x6004, 0xa086,
+	0x0085, 0x0d20, 0x0850, 0x00c6, 0x0006, 0x0126, 0x2091, 0x8000,
+	0xa280, 0xb635, 0x2004, 0xa065, 0x0904, 0x6f4c, 0x00f6, 0x00e6,
+	0x00d6, 0x0066, 0x2071, 0xb7e0, 0x6654, 0x7018, 0xac06, 0x1108,
+	0x761a, 0x701c, 0xac06, 0x1130, 0x86ff, 0x1118, 0x7018, 0x701e,
+	0x0008, 0x761e, 0x6058, 0xa07d, 0x0108, 0x7e56, 0xa6ed, 0x0000,
+	0x0110, 0x2f00, 0x685a, 0x6057, 0x0000, 0x605b, 0x0000, 0x6000,
+	0xc0d4, 0xc0dc, 0x6002, 0x080c, 0x4ed4, 0x0904, 0x6f48, 0x7624,
+	0x86ff, 0x05e8, 0xa680, 0x0004, 0x2004, 0xad06, 0x15c0, 0x00d6,
+	0x2069, 0x0100, 0x68c0, 0xa005, 0x0548, 0x080c, 0x6a10, 0x080c,
+	0x7d7a, 0x68c3, 0x0000, 0x080c, 0x824d, 0x7027, 0x0000, 0x0036,
+	0x2069, 0x0140, 0x6b04, 0xa384, 0x1000, 0x0120, 0x6803, 0x0100,
+	0x6803, 0x0000, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827,
+	0x0001, 0x003e, 0x00de, 0x00c6, 0x603c, 0xa005, 0x0110, 0x8001,
+	0x603e, 0x2660, 0x080c, 0x9e1d, 0x00ce, 0x0048, 0x00de, 0x00c6,
+	0x2660, 0x6003, 0x0009, 0x630a, 0x00ce, 0x0804, 0x6ef3, 0x8dff,
+	0x0158, 0x6837, 0x0103, 0x6b4a, 0x6847, 0x0000, 0x080c, 0x9ecc,
+	0x080c, 0xb380, 0x080c, 0x5408, 0x080c, 0x811e, 0x0804, 0x6ef3,
+	0x006e, 0x00de, 0x00ee, 0x00fe, 0x012e, 0x000e, 0x00ce, 0x0005,
+	0x0006, 0x0066, 0x00c6, 0x00d6, 0x2031, 0x0000, 0x7814, 0xa065,
+	0x0904, 0x6fa2, 0x600c, 0x0006, 0x600f, 0x0000, 0x7824, 0xac06,
+	0x1540, 0x2069, 0x0100, 0x68c0, 0xa005, 0x01f0, 0x080c, 0x6a10,
+	0x080c, 0x7d7a, 0x68c3, 0x0000, 0x080c, 0x824d, 0x7827, 0x0000,
+	0x0036, 0x2069, 0x0140, 0x6b04, 0xa384, 0x1000, 0x0120, 0x6803,
+	0x0100, 0x6803, 0x0000, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110,
+	0x6827, 0x0001, 0x003e, 0x0028, 0x6003, 0x0009, 0x630a, 0x2c30,
+	0x00b0, 0x6010, 0x2068, 0x080c, 0x9c5a, 0x0168, 0x601c, 0xa086,
+	0x0003, 0x11b8, 0x6837, 0x0103, 0x6b4a, 0x6847, 0x0000, 0x080c,
+	0x5408, 0x080c, 0x9e11, 0x080c, 0x9e1d, 0x080c, 0x811e, 0x000e,
+	0x0804, 0x6f57, 0x7e16, 0x7e12, 0x00de, 0x00ce, 0x006e, 0x000e,
+	0x0005, 0x601c, 0xa086, 0x0006, 0x1118, 0x080c, 0xb099, 0x0c58,
+	0x601c, 0xa086, 0x0002, 0x1128, 0x6004, 0xa086, 0x0085, 0x09d0,
+	0x0c10, 0x601c, 0xa086, 0x0005, 0x19f0, 0x6004, 0xa086, 0x0085,
+	0x0d60, 0x08c8, 0x0006, 0x0066, 0x00c6, 0x00d6, 0x7818, 0xa065,
+	0x0904, 0x7028, 0x6054, 0x0006, 0x6057, 0x0000, 0x605b, 0x0000,
+	0x6000, 0xc0d4, 0xc0dc, 0x6002, 0x080c, 0x4ed4, 0x0904, 0x7025,
+	0x7e24, 0x86ff, 0x05e8, 0xa680, 0x0004, 0x2004, 0xad06, 0x15c0,
+	0x00d6, 0x2069, 0x0100, 0x68c0, 0xa005, 0x0548, 0x080c, 0x6a10,
+	0x080c, 0x7d7a, 0x68c3, 0x0000, 0x080c, 0x824d, 0x7827, 0x0000,
+	0x0036, 0x2069, 0x0140, 0x6b04, 0xa384, 0x1000, 0x0120, 0x6803,
+	0x0100, 0x6803, 0x0000, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110,
+	0x6827, 0x0001, 0x003e, 0x00de, 0x00c6, 0x603c, 0xa005, 0x0110,
+	0x8001, 0x603e, 0x2660, 0x080c, 0x9e1d, 0x00ce, 0x0048, 0x00de,
+	0x00c6, 0x2660, 0x6003, 0x0009, 0x630a, 0x00ce, 0x0804, 0x6fd4,
+	0x8dff, 0x0138, 0x6837, 0x0103, 0x6b4a, 0x6847, 0x0000, 0x080c,
+	0x5408, 0x080c, 0x811e, 0x0804, 0x6fd4, 0x000e, 0x0804, 0x6fc7,
+	0x781e, 0x781a, 0x00de, 0x00ce, 0x006e, 0x000e, 0x0005, 0x00e6,
+	0x00d6, 0x0066, 0x6000, 0xd0dc, 0x01a0, 0x604c, 0xa06d, 0x0188,
+	0x6848, 0xa606, 0x1170, 0x2071, 0xb7e0, 0x7024, 0xa035, 0x0148,
+	0xa080, 0x0004, 0x2004, 0xad06, 0x1120, 0x6000, 0xc0dc, 0x6002,
+	0x0021, 0x006e, 0x00de, 0x00ee, 0x0005, 0x00f6, 0x2079, 0x0100,
+	0x78c0, 0xa005, 0x1138, 0x00c6, 0x2660, 0x6003, 0x0009, 0x630a,
+	0x00ce, 0x04a0, 0x080c, 0x7d7a, 0x78c3, 0x0000, 0x080c, 0x824d,
+	0x7027, 0x0000, 0x0036, 0x2079, 0x0140, 0x7b04, 0xa384, 0x1000,
+	0x0120, 0x7803, 0x0100, 0x7803, 0x0000, 0x2079, 0x0100, 0x7824,
+	0xd084, 0x0110, 0x7827, 0x0001, 0x080c, 0x824d, 0x003e, 0x080c,
+	0x4ed4, 0x00c6, 0x603c, 0xa005, 0x0110, 0x8001, 0x603e, 0x2660,
+	0x080c, 0x861d, 0x00ce, 0x6837, 0x0103, 0x6b4a, 0x6847, 0x0000,
+	0x080c, 0x9ecc, 0x080c, 0x5408, 0x080c, 0x811e, 0x00fe, 0x0005,
+	0x00e6, 0x00c6, 0x2071, 0xb7e0, 0x7004, 0xa084, 0x0007, 0x0002,
+	0x70a2, 0x70a5, 0x70bb, 0x70d4, 0x7111, 0x70a2, 0x70a0, 0x70a0,
+	0x080c, 0x1515, 0x00ce, 0x00ee, 0x0005, 0x7024, 0xa065, 0x0148,
+	0x7020, 0x8001, 0x7022, 0x600c, 0xa015, 0x0150, 0x7216, 0x600f,
+	0x0000, 0x7007, 0x0000, 0x7027, 0x0000, 0x00ce, 0x00ee, 0x0005,
+	0x7216, 0x7212, 0x0cb0, 0x6018, 0x2060, 0x080c, 0x4ed4, 0x6000,
+	0xc0dc, 0x6002, 0x7020, 0x8001, 0x7022, 0x0120, 0x6054, 0xa015,
+	0x0140, 0x721e, 0x7007, 0x0000, 0x7027, 0x0000, 0x00ce, 0x00ee,
+	0x0005, 0x7218, 0x721e, 0x0cb0, 0x7024, 0xa065, 0x05b8, 0x700c,
+	0xac06, 0x1160, 0x080c, 0x811e, 0x600c, 0xa015, 0x0120, 0x720e,
+	0x600f, 0x0000, 0x0448, 0x720e, 0x720a, 0x0430, 0x7014, 0xac06,
+	0x1160, 0x080c, 0x811e, 0x600c, 0xa015, 0x0120, 0x7216, 0x600f,
+	0x0000, 0x00d0, 0x7216, 0x7212, 0x00b8, 0x601c, 0xa086, 0x0003,
+	0x1198, 0x6018, 0x2060, 0x080c, 0x4ed4, 0x6000, 0xc0dc, 0x6002,
+	0x080c, 0x811e, 0x701c, 0xa065, 0x0138, 0x6054, 0xa015, 0x0110,
+	0x721e, 0x0010, 0x7218, 0x721e, 0x7027, 0x0000, 0x00ce, 0x00ee,
+	0x0005, 0x7024, 0xa065, 0x0140, 0x080c, 0x811e, 0x600c, 0xa015,
+	0x0150, 0x720e, 0x600f, 0x0000, 0x080c, 0x824d, 0x7027, 0x0000,
+	0x00ce, 0x00ee, 0x0005, 0x720e, 0x720a, 0x0cb0, 0x00d6, 0x2069,
+	0xb7e0, 0x6830, 0xa084, 0x0003, 0x0002, 0x7133, 0x7135, 0x7159,
+	0x7131, 0x080c, 0x1515, 0x00de, 0x0005, 0x00c6, 0x6840, 0xa086,
+	0x0001, 0x01b8, 0x683c, 0xa065, 0x0130, 0x600c, 0xa015, 0x0170,
+	0x6a3a, 0x600f, 0x0000, 0x6833, 0x0000, 0x683f, 0x0000, 0x2011,
+	0xb7ff, 0x2013, 0x0000, 0x00ce, 0x00de, 0x0005, 0x683a, 0x6836,
+	0x0c90, 0x6843, 0x0000, 0x6838, 0xa065, 0x0d68, 0x6003, 0x0003,
+	0x0c50, 0x00c6, 0x6843, 0x0000, 0x6847, 0x0000, 0x684b, 0x0000,
+	0x683c, 0xa065, 0x0168, 0x600c, 0xa015, 0x0130, 0x6a3a, 0x600f,
+	0x0000, 0x683f, 0x0000, 0x0020, 0x683f, 0x0000, 0x683a, 0x6836,
+	0x00ce, 0x00de, 0x0005, 0x00d6, 0x2069, 0xb7e0, 0x6804, 0xa084,
+	0x0007, 0x0002, 0x7184, 0x7220, 0x7220, 0x7220, 0x7220, 0x7222,
+	0x7182, 0x7182, 0x080c, 0x1515, 0x6820, 0xa005, 0x1110, 0x00de,
+	0x0005, 0x00c6, 0x680c, 0xa065, 0x0150, 0x6807, 0x0004, 0x6826,
+	0x682b, 0x0000, 0x080c, 0x7272, 0x00ce, 0x00de, 0x0005, 0x6814,
+	0xa065, 0x0150, 0x6807, 0x0001, 0x6826, 0x682b, 0x0000, 0x080c,
+	0x7272, 0x00ce, 0x00de, 0x0005, 0x00e6, 0x0036, 0x6a1c, 0xa2f5,
+	0x0000, 0x0904, 0x721c, 0x704c, 0xa00d, 0x0118, 0x7088, 0xa005,
+	0x01a0, 0x7054, 0xa075, 0x0120, 0xa20e, 0x0904, 0x721c, 0x0028,
+	0x6818, 0xa20e, 0x0904, 0x721c, 0x2070, 0x704c, 0xa00d, 0x0d88,
+	0x7088, 0xa005, 0x1d70, 0x2e00, 0x681e, 0x733c, 0x7038, 0xa302,
+	0x1e40, 0x080c, 0x85f4, 0x0904, 0x721c, 0x8318, 0x733e, 0x6112,
+	0x2e10, 0x621a, 0xa180, 0x0014, 0x2004, 0xa084, 0x00ff, 0x605a,
+	0xa180, 0x0014, 0x2003, 0x0000, 0xa180, 0x0015, 0x2004, 0xa08a,
+	0x199a, 0x0210, 0x2001, 0x1999, 0x8003, 0x801b, 0x831b, 0xa318,
+	0x6316, 0x003e, 0x00f6, 0x2c78, 0x71a0, 0x2001, 0xb535, 0x2004,
+	0xd0ac, 0x1110, 0xd1bc, 0x0150, 0x7100, 0xd1f4, 0x0120, 0x7114,
+	0xa18c, 0x00ff, 0x0040, 0x2009, 0x0000, 0x0028, 0xa1e0, 0x2dc4,
+	0x2c0d, 0xa18c, 0x00ff, 0x2061, 0x0100, 0x619a, 0x080c, 0x78a2,
+	0x7300, 0xc3dd, 0x7302, 0x6807, 0x0002, 0x2f18, 0x6b26, 0x682b,
+	0x0000, 0x781f, 0x0003, 0x7803, 0x0001, 0x7807, 0x0040, 0x00fe,
+	0x00ee, 0x00ce, 0x00de, 0x0005, 0x003e, 0x00ee, 0x00ce, 0x0cd0,
+	0x00de, 0x0005, 0x00c6, 0x680c, 0xa065, 0x0138, 0x6807, 0x0004,
+	0x6826, 0x682b, 0x0000, 0x080c, 0x7272, 0x00ce, 0x00de, 0x0005,
+	0x00f6, 0x00d6, 0x2069, 0xb7e0, 0x6830, 0xa086, 0x0000, 0x11d0,
+	0x2001, 0xb50c, 0x200c, 0xd1bc, 0x1560, 0x6838, 0xa07d, 0x0190,
+	0x6833, 0x0001, 0x683e, 0x6847, 0x0000, 0x684b, 0x0000, 0x0126,
+	0x00f6, 0x2091, 0x2400, 0x002e, 0x080c, 0x2021, 0x1130, 0x012e,
+	0x080c, 0x7beb, 0x00de, 0x00fe, 0x0005, 0x012e, 0xe000, 0x6843,
+	0x0000, 0x7803, 0x0002, 0x780c, 0xa015, 0x0140, 0x6a3a, 0x780f,
+	0x0000, 0x6833, 0x0000, 0x683f, 0x0000, 0x0c60, 0x683a, 0x6836,
+	0x0cc0, 0xc1bc, 0x2102, 0x0066, 0x2031, 0x0001, 0x080c, 0x5b51,
+	0x006e, 0x0858, 0x601c, 0xa084, 0x000f, 0x000b, 0x0005, 0x7280,
+	0x7285, 0x7743, 0x785f, 0x7285, 0x7743, 0x785f, 0x7280, 0x7285,
+	0x080c, 0x7090, 0x080c, 0x7173, 0x0005, 0x0156, 0x0136, 0x0146,
+	0x00c6, 0x00f6, 0x6004, 0xa08a, 0x0080, 0x1a0c, 0x1515, 0x6118,
+	0x2178, 0x79a0, 0x2011, 0xb535, 0x2214, 0xd2ac, 0x1110, 0xd1bc,
+	0x0150, 0x7900, 0xd1f4, 0x0120, 0x7914, 0xa18c, 0x00ff, 0x0040,
+	0x2009, 0x0000, 0x0028, 0xa1f8, 0x2dc4, 0x2f0d, 0xa18c, 0x00ff,
+	0x2c78, 0x2061, 0x0100, 0x619a, 0xa08a, 0x0040, 0x1a04, 0x72f9,
+	0x0033, 0x00fe, 0x00ce, 0x014e, 0x013e, 0x015e, 0x0005, 0x73a8,
+	0x73f3, 0x7420, 0x74ed, 0x751b, 0x7523, 0x7549, 0x755a, 0x756b,
+	0x7573, 0x7589, 0x7573, 0x75ea, 0x755a, 0x760b, 0x7613, 0x756b,
+	0x7613, 0x7624, 0x72f7, 0x72f7, 0x72f7, 0x72f7, 0x72f7, 0x72f7,
+	0x72f7, 0x72f7, 0x72f7, 0x72f7, 0x72f7, 0x7e85, 0x7eaa, 0x7ebf,
+	0x7ee2, 0x7f03, 0x7549, 0x72f7, 0x7549, 0x7573, 0x72f7, 0x7420,
+	0x74ed, 0x72f7, 0x834f, 0x7573, 0x72f7, 0x836f, 0x7573, 0x72f7,
+	0x756b, 0x73a1, 0x730c, 0x72f7, 0x8394, 0x8409, 0x84e0, 0x72f7,
+	0x84f1, 0x7544, 0x850d, 0x72f7, 0x7f18, 0x8568, 0x72f7, 0x080c,
+	0x1515, 0x2100, 0x0033, 0x00fe, 0x00ce, 0x014e, 0x013e, 0x015e,
+	0x0005, 0x730a, 0x730a, 0x730a, 0x7340, 0x735e, 0x7374, 0x730a,
+	0x730a, 0x730a, 0x080c, 0x1515, 0x00d6, 0x20a1, 0x020b, 0x080c,
+	0x7641, 0x7810, 0x2068, 0x20a3, 0x2414, 0x20a3, 0x0018, 0x20a3,
+	0x0800, 0x683c, 0x20a2, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x20a3, 0x0000, 0x6850, 0x20a2, 0x6854, 0x20a2, 0x20a3,
+	0x0000, 0x20a3, 0x0000, 0x60c3, 0x0018, 0x080c, 0x7d67, 0x00de,
+	0x0005, 0x00d6, 0x7818, 0x2068, 0x68a0, 0x2069, 0xb500, 0x6ad4,
+	0xd2ac, 0x1110, 0xd0bc, 0x0110, 0xa085, 0x0001, 0x00de, 0x0005,
+	0x00d6, 0x20a1, 0x020b, 0x080c, 0x7641, 0x20a3, 0x0500, 0x20a3,
+	0x0000, 0x7810, 0xa0e8, 0x000f, 0x6808, 0x20a2, 0x680c, 0x20a2,
+	0x6810, 0x20a2, 0x6814, 0x20a2, 0x6818, 0x20a2, 0x681c, 0x20a2,
+	0x60c3, 0x0010, 0x080c, 0x7d67, 0x00de, 0x0005, 0x0156, 0x0146,
+	0x20a1, 0x020b, 0x080c, 0x7641, 0x20a3, 0x7800, 0x20a3, 0x0000,
+	0x7808, 0x8007, 0x20a2, 0x20a3, 0x0000, 0x60c3, 0x0008, 0x080c,
+	0x7d67, 0x014e, 0x015e, 0x0005, 0x0156, 0x0146, 0x20a1, 0x020b,
+	0x080c, 0x76dd, 0x20a3, 0x0200, 0x20a3, 0x0000, 0x20a3, 0xdf10,
+	0x20a3, 0x0034, 0x2099, 0xb505, 0x20a9, 0x0004, 0x53a6, 0x2099,
+	0xb501, 0x20a9, 0x0004, 0x53a6, 0x2099, 0xb7c6, 0x20a9, 0x001a,
+	0x3304, 0x8007, 0x20a2, 0x9398, 0x1f04, 0x7390, 0x20a3, 0x0000,
+	0x20a3, 0x0000, 0x60c3, 0x004c, 0x080c, 0x7d67, 0x014e, 0x015e,
+	0x0005, 0x2001, 0xb515, 0x2004, 0x609a, 0x080c, 0x7d67, 0x0005,
+	0x20a1, 0x020b, 0x080c, 0x7641, 0x20a3, 0x5200, 0x20a3, 0x0000,
+	0x00d6, 0x2069, 0xb552, 0x6804, 0xd084, 0x0150, 0x6828, 0x20a3,
+	0x0000, 0x0016, 0x080c, 0x2831, 0x21a2, 0x001e, 0x00de, 0x0028,
+	0x00de, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x20a9, 0x0004, 0x2099,
+	0xb505, 0x53a6, 0x20a9, 0x0004, 0x2099, 0xb501, 0x53a6, 0x2001,
+	0xb535, 0x2004, 0xd0ac, 0x1138, 0x7818, 0xa080, 0x0028, 0x2004,
+	0xa082, 0x007f, 0x0238, 0x2001, 0xb51c, 0x20a6, 0x2001, 0xb51d,
+	0x20a6, 0x0040, 0x20a3, 0x0000, 0x2001, 0xb515, 0x2004, 0xa084,
+	0x00ff, 0x20a2, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x60c3, 0x001c,
+	0x080c, 0x7d67, 0x0005, 0x20a1, 0x020b, 0x080c, 0x7641, 0x20a3,
+	0x0500, 0x20a3, 0x0000, 0x2001, 0xb535, 0x2004, 0xd0ac, 0x1138,
+	0x7818, 0xa080, 0x0028, 0x2004, 0xa082, 0x007f, 0x0238, 0x2001,
+	0xb51c, 0x20a6, 0x2001, 0xb51d, 0x20a6, 0x0040, 0x20a3, 0x0000,
+	0x2001, 0xb515, 0x2004, 0xa084, 0x00ff, 0x20a2, 0x20a9, 0x0004,
+	0x2099, 0xb505, 0x53a6, 0x60c3, 0x0010, 0x080c, 0x7d67, 0x0005,
+	0x20a1, 0x020b, 0x080c, 0x7641, 0x00c6, 0x7818, 0x2060, 0x2001,
+	0x0000, 0x080c, 0x5313, 0x00ce, 0x7818, 0xa080, 0x0028, 0x2004,
+	0xa086, 0x007e, 0x1130, 0x20a3, 0x0400, 0x620c, 0xc2b4, 0x620e,
+	0x0010, 0x20a3, 0x0300, 0x20a3, 0x0000, 0x7818, 0xa080, 0x0028,
+	0x2004, 0xa086, 0x007e, 0x1904, 0x74af, 0x2001, 0xb535, 0x2004,
+	0xd0a4, 0x01c8, 0x2099, 0xb78e, 0x33a6, 0x9398, 0x20a3, 0x0000,
+	0x9398, 0x3304, 0xa084, 0x2000, 0x20a2, 0x9398, 0x33a6, 0x9398,
+	0x20a3, 0x0000, 0x9398, 0x2001, 0x2710, 0x20a2, 0x9398, 0x33a6,
+	0x9398, 0x33a6, 0x00d0, 0x2099, 0xb78e, 0x33a6, 0x9398, 0x33a6,
+	0x9398, 0x3304, 0x080c, 0x5acf, 0x1118, 0xa084, 0x37ff, 0x0010,
+	0xa084, 0x3fff, 0x20a2, 0x9398, 0x33a6, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x20a9, 0x0004, 0x2099,
+	0xb505, 0x53a6, 0x20a9, 0x0004, 0x2099, 0xb501, 0x53a6, 0x20a9,
+	0x0008, 0x20a3, 0x0000, 0x1f04, 0x7489, 0x20a9, 0x0008, 0x20a3,
+	0x0000, 0x1f04, 0x748f, 0x2099, 0xb796, 0x3304, 0xc0dd, 0x20a2,
+	0x2001, 0xb572, 0x2004, 0xd0e4, 0x0158, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x9398, 0x9398, 0x9398, 0x33a6, 0x20a9, 0x0004, 0x0010,
+	0x20a9, 0x0007, 0x20a3, 0x0000, 0x1f04, 0x74aa, 0x0468, 0x2001,
+	0xb535, 0x2004, 0xd0a4, 0x0140, 0x2001, 0xb78f, 0x2004, 0x60e3,
+	0x0000, 0x080c, 0x2872, 0x60e2, 0x2099, 0xb78e, 0x20a9, 0x0008,
+	0x53a6, 0x20a9, 0x0004, 0x2099, 0xb505, 0x53a6, 0x20a9, 0x0004,
+	0x2099, 0xb501, 0x53a6, 0x20a9, 0x0008, 0x20a3, 0x0000, 0x1f04,
+	0x74cd, 0x20a9, 0x0008, 0x20a3, 0x0000, 0x1f04, 0x74d3, 0x2099,
+	0xb796, 0x20a9, 0x0008, 0x53a6, 0x20a9, 0x0008, 0x20a3, 0x0000,
+	0x1f04, 0x74de, 0x20a9, 0x000a, 0x20a3, 0x0000, 0x1f04, 0x74e4,
+	0x60c3, 0x0074, 0x080c, 0x7d67, 0x0005, 0x20a1, 0x020b, 0x080c,
+	0x7641, 0x20a3, 0x2010, 0x20a3, 0x0014, 0x20a3, 0x0800, 0x20a3,
+	0x2000, 0xa006, 0x20a2, 0x20a2, 0x20a2, 0x20a2, 0x20a2, 0x00f6,
+	0x2079, 0xb552, 0x7904, 0x00fe, 0xd1ac, 0x1110, 0xa085, 0x0020,
+	0xd1a4, 0x0110, 0xa085, 0x0010, 0xa085, 0x0002, 0x00d6, 0x0804,
+	0x75cc, 0x20a2, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x60c3, 0x0014,
+	0x080c, 0x7d67, 0x0005, 0x20a1, 0x020b, 0x080c, 0x7641, 0x20a3,
+	0x5000, 0x0804, 0x743b, 0x20a1, 0x020b, 0x080c, 0x7641, 0x20a3,
+	0x2110, 0x20a3, 0x0014, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x60c3,
+	0x0014, 0x080c, 0x7d67, 0x0005, 0x20a1, 0x020b, 0x080c, 0x76d5,
+	0x0020, 0x20a1, 0x020b, 0x080c, 0x76dd, 0x20a3, 0x0200, 0x20a3,
+	0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x60c3, 0x0004, 0x080c,
+	0x7d67, 0x0005, 0x20a1, 0x020b, 0x080c, 0x76dd, 0x20a3, 0x0100,
+	0x20a3, 0x0000, 0x20a3, 0x0003, 0x20a3, 0x2a00, 0x60c3, 0x0008,
+	0x080c, 0x7d67, 0x0005, 0x20a1, 0x020b, 0x080c, 0x76dd, 0x20a3,
+	0x0200, 0x0804, 0x743b, 0x20a1, 0x020b, 0x080c, 0x76dd, 0x20a3,
+	0x0100, 0x20a3, 0x0000, 0x7828, 0xa005, 0x0110, 0x20a2, 0x0010,
+	0x20a3, 0x0003, 0x7810, 0x20a2, 0x60c3, 0x0008, 0x080c, 0x7d67,
+	0x0005, 0x00d6, 0x20a1, 0x020b, 0x080c, 0x76dd, 0x20a3, 0x0210,
+	0x20a3, 0x0014, 0x20a3, 0x0800, 0x7818, 0x2068, 0x6894, 0xa086,
+	0x0014, 0x1198, 0x699c, 0xa184, 0x0030, 0x0190, 0x6998, 0xa184,
+	0xc000, 0x1140, 0xd1ec, 0x0118, 0x20a3, 0x2100, 0x0058, 0x20a3,
+	0x0100, 0x0040, 0x20a3, 0x0400, 0x0028, 0x20a3, 0x0700, 0x0010,
+	0x700f, 0x0800, 0xa006, 0x20a2, 0x20a2, 0x20a2, 0x20a2, 0x20a2,
+	0x00f6, 0x2079, 0xb552, 0x7904, 0x00fe, 0xd1ac, 0x1110, 0xa085,
+	0x0020, 0xd1a4, 0x0110, 0xa085, 0x0010, 0x2009, 0xb574, 0x210c,
+	0xd184, 0x1110, 0xa085, 0x0002, 0x0026, 0x2009, 0xb572, 0x210c,
+	0xd1e4, 0x0130, 0xc0c5, 0xa094, 0x0030, 0xa296, 0x0010, 0x0140,
+	0xd1ec, 0x0130, 0xa094, 0x0030, 0xa296, 0x0010, 0x0108, 0xc0bd,
+	0x002e, 0x20a2, 0x20a2, 0x20a2, 0x60c3, 0x0014, 0x080c, 0x7d67,
+	0x00de, 0x0005, 0x20a1, 0x020b, 0x080c, 0x76dd, 0x20a3, 0x0210,
+	0x20a3, 0x0014, 0x20a3, 0x0000, 0x20a3, 0x0100, 0x20a3, 0x0000,
+	0x20a3, 0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000,
+	0x20a3, 0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x60c3, 0x0014,
+	0x080c, 0x7d67, 0x0005, 0x20a1, 0x020b, 0x080c, 0x76dd, 0x20a3,
+	0x0200, 0x0804, 0x73ae, 0x20a1, 0x020b, 0x080c, 0x76dd, 0x20a3,
+	0x0100, 0x20a3, 0x0000, 0x20a3, 0x0003, 0x20a3, 0x2a00, 0x60c3,
+	0x0008, 0x080c, 0x7d67, 0x0005, 0x20e1, 0x9080, 0x20e1, 0x4000,
+	0x20a1, 0x020b, 0x080c, 0x76dd, 0x20a3, 0x0100, 0x20a3, 0x0000,
+	0x20a3, 0x000b, 0x20a3, 0x0000, 0x60c3, 0x0008, 0x080c, 0x7d67,
+	0x0005, 0x0026, 0x0036, 0x0046, 0x2019, 0x3200, 0x2021, 0x0800,
+	0x0038, 0x0026, 0x0036, 0x0046, 0x2019, 0x2200, 0x2021, 0x0100,
+	0x20e1, 0x9080, 0x20e1, 0x4000, 0x7818, 0xa080, 0x0028, 0x2014,
+	0xa286, 0x007e, 0x11a0, 0xa385, 0x00ff, 0x20a2, 0x20a3, 0xfffe,
+	0x20a3, 0x0000, 0x2011, 0xb515, 0x2214, 0x2001, 0xb79e, 0x2004,
+	0xa005, 0x0118, 0x2011, 0xb51d, 0x2214, 0x22a2, 0x04d0, 0xa286,
+	0x007f, 0x1138, 0x00d6, 0xa385, 0x00ff, 0x20a2, 0x20a3, 0xfffd,
+	0x00c8, 0x2001, 0xb535, 0x2004, 0xd0ac, 0x1110, 0xd2bc, 0x01c8,
+	0xa286, 0x0080, 0x00d6, 0x1130, 0xa385, 0x00ff, 0x20a2, 0x20a3,
+	0xfffc, 0x0040, 0xa2e8, 0xb635, 0x2d6c, 0x6810, 0xa305, 0x20a2,
+	0x6814, 0x20a2, 0x2069, 0xb51c, 0x2da6, 0x8d68, 0x2da6, 0x00de,
+	0x0080, 0x00d6, 0xa2e8, 0xb635, 0x2d6c, 0x6810, 0xa305, 0x20a2,
+	0x6814, 0x20a2, 0x00de, 0x20a3, 0x0000, 0x2011, 0xb515, 0x2214,
+	0x22a2, 0xa485, 0x0029, 0x20a2, 0x004e, 0x003e, 0x20a3, 0x0000,
+	0x080c, 0x7d56, 0x22a2, 0x20a3, 0x0000, 0x2fa2, 0x20a3, 0xffff,
+	0x20a3, 0x0000, 0x20a3, 0x0000, 0x002e, 0x0005, 0x0026, 0x20e1,
+	0x9080, 0x20e1, 0x4000, 0x20a3, 0x02ff, 0x2011, 0xfffc, 0x22a2,
+	0x00d6, 0x2069, 0xb51c, 0x2da6, 0x8d68, 0x2da6, 0x00de, 0x20a3,
+	0x2029, 0x20a3, 0x0000, 0x08e0, 0x20a3, 0x0100, 0x20a3, 0x0000,
+	0x20a3, 0xfc02, 0x20a3, 0x0000, 0x0005, 0x0026, 0x0036, 0x0046,
+	0x2019, 0x3300, 0x2021, 0x0800, 0x0038, 0x0026, 0x0036, 0x0046,
+	0x2019, 0x2300, 0x2021, 0x0100, 0x20e1, 0x9080, 0x20e1, 0x4000,
+	0x7818, 0xa080, 0x0028, 0x2004, 0x2011, 0xb535, 0x2214, 0xd2ac,
+	0x1118, 0xa092, 0x007e, 0x02d8, 0x00d6, 0xa0e8, 0xb635, 0x2d6c,
+	0x6810, 0xa305, 0x20a2, 0x6814, 0x20a2, 0x6810, 0xa005, 0x1140,
+	0x6814, 0xa005, 0x1128, 0x20a3, 0x00ff, 0x20a3, 0xfffe, 0x0028,
+	0x2069, 0xb51c, 0x2da6, 0x8d68, 0x2da6, 0x00de, 0x0080, 0x00d6,
+	0xa0e8, 0xb635, 0x2d6c, 0x6810, 0xa305, 0x20a2, 0x6814, 0x20a2,
+	0x00de, 0x20a3, 0x0000, 0x2011, 0xb515, 0x2214, 0x22a2, 0xa485,
+	0x0098, 0x20a2, 0x20a3, 0x0000, 0x004e, 0x003e, 0x080c, 0x7d56,
+	0x22a2, 0x20a3, 0x0000, 0x7a08, 0x22a2, 0x2fa2, 0x20a3, 0x0000,
+	0x20a3, 0x0000, 0x002e, 0x0005, 0x080c, 0x7d56, 0x22a2, 0x20a3,
+	0x0000, 0x7a08, 0x22a2, 0x7810, 0x20a2, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x002e, 0x0005, 0x00c6, 0x00f6, 0x6004, 0xa08a, 0x0085,
+	0x0a0c, 0x1515, 0xa08a, 0x008c, 0x1a0c, 0x1515, 0x6118, 0x2178,
+	0x79a0, 0x2011, 0xb535, 0x2214, 0xd2ac, 0x1110, 0xd1bc, 0x0150,
+	0x7900, 0xd1f4, 0x0120, 0x7914, 0xa18c, 0x00ff, 0x0040, 0x2009,
+	0x0000, 0x0028, 0xa1f8, 0x2dc4, 0x2f0d, 0xa18c, 0x00ff, 0x2c78,
+	0x2061, 0x0100, 0x619a, 0xa082, 0x0085, 0x001b, 0x00fe, 0x00ce,
+	0x0005, 0x777a, 0x7784, 0x779f, 0x7778, 0x7778, 0x7778, 0x777a,
+	0x080c, 0x1515, 0x0146, 0x20a1, 0x020b, 0x04a1, 0x60c3, 0x0000,
+	0x080c, 0x7d67, 0x014e, 0x0005, 0x0146, 0x20a1, 0x020b, 0x080c,
+	0x77eb, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x7808, 0x20a2, 0x7810,
+	0x20a2, 0x20a3, 0x0000, 0x20a3, 0xffff, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x60c3, 0x000c, 0x080c, 0x7d67, 0x014e, 0x0005, 0x0146,
+	0x20a1, 0x020b, 0x080c, 0x7825, 0x20a3, 0x0003, 0x20a3, 0x0300,
+	0x20a3, 0x0000, 0x20a3, 0x0000, 0x60c3, 0x0004, 0x080c, 0x7d67,
+	0x014e, 0x0005, 0x0026, 0x20e1, 0x9080, 0x20e1, 0x4000, 0x7818,
+	0xa080, 0x0028, 0x2004, 0x2011, 0xb535, 0x2214, 0xd2ac, 0x1118,
+	0xa092, 0x007e, 0x0288, 0x00d6, 0xa0e8, 0xb635, 0x2d6c, 0x6810,
+	0xa085, 0x8100, 0x20a2, 0x6814, 0x20a2, 0x2069, 0xb51c, 0x2da6,
+	0x8d68, 0x2da6, 0x00de, 0x0088, 0x00d6, 0xa0e8, 0xb635, 0x2d6c,
+	0x6810, 0xa085, 0x8100, 0x20a2, 0x6814, 0x20a2, 0x00de, 0x20a3,
+	0x0000, 0x2011, 0xb515, 0x2214, 0x22a2, 0x20a3, 0x0009, 0x20a3,
+	0x0000, 0x0804, 0x76a8, 0x0026, 0x20e1, 0x9080, 0x20e1, 0x4000,
+	0x7818, 0xa080, 0x0028, 0x2004, 0x2011, 0xb535, 0x2214, 0xd2ac,
+	0x1118, 0xa092, 0x007e, 0x0288, 0x00d6, 0xa0e8, 0xb635, 0x2d6c,
+	0x6810, 0xa085, 0x8400, 0x20a2, 0x6814, 0x20a2, 0x2069, 0xb51c,
+	0x2da6, 0x8d68, 0x2da6, 0x00de, 0x0088, 0x00d6, 0xa0e8, 0xb635,
+	0x2d6c, 0x6810, 0xa085, 0x8400, 0x20a2, 0x6814, 0x20a2, 0x00de,
+	0x20a3, 0x0000, 0x2011, 0xb515, 0x2214, 0x22a2, 0x2001, 0x0099,
+	0x20a2, 0x20a3, 0x0000, 0x0804, 0x7734, 0x0026, 0x20e1, 0x9080,
+	0x20e1, 0x4000, 0x7818, 0xa080, 0x0028, 0x2004, 0x2011, 0xb535,
+	0x2214, 0xd2ac, 0x1118, 0xa092, 0x007e, 0x0288, 0x00d6, 0xa0e8,
+	0xb635, 0x2d6c, 0x6810, 0xa085, 0x8500, 0x20a2, 0x6814, 0x20a2,
+	0x2069, 0xb51c, 0x2da6, 0x8d68, 0x2da6, 0x00de, 0x0088, 0x00d6,
+	0xa0e8, 0xb635, 0x2d6c, 0x6810, 0xa085, 0x8500, 0x20a2, 0x6814,
+	0x20a2, 0x00de, 0x20a3, 0x0000, 0x2011, 0xb515, 0x2214, 0x22a2,
+	0x2001, 0x0099, 0x20a2, 0x20a3, 0x0000, 0x0804, 0x7734, 0x00c6,
+	0x00f6, 0x2c78, 0x7804, 0xa08a, 0x0040, 0x0a0c, 0x1515, 0xa08a,
+	0x0053, 0x1a0c, 0x1515, 0x7918, 0x2160, 0x61a0, 0x2011, 0xb535,
+	0x2214, 0xd2ac, 0x1110, 0xd1bc, 0x0150, 0x6100, 0xd1f4, 0x0120,
+	0x6114, 0xa18c, 0x00ff, 0x0040, 0x2009, 0x0000, 0x0028, 0xa1e0,
+	0x2dc4, 0x2c0d, 0xa18c, 0x00ff, 0x2061, 0x0100, 0x619a, 0xa082,
+	0x0040, 0x001b, 0x00fe, 0x00ce, 0x0005, 0x78a2, 0x79ae, 0x794b,
+	0x7b60, 0x78a0, 0x78a0, 0x78a0, 0x78a0, 0x78a0, 0x78a0, 0x78a0,
+	0x80d7, 0x80e7, 0x80f7, 0x8107, 0x78a0, 0x851e, 0x78a0, 0x80c6,
+	0x080c, 0x1515, 0x00d6, 0x0156, 0x0146, 0x780b, 0xffff, 0x20a1,
+	0x020b, 0x080c, 0x7902, 0x7910, 0x2168, 0x6948, 0x7952, 0x21a2,
+	0xa016, 0x22a2, 0x22a2, 0x22a2, 0x694c, 0xa184, 0x000f, 0x1118,
+	0x2001, 0x0005, 0x0040, 0xd184, 0x0118, 0x2001, 0x0004, 0x0018,
+	0xa084, 0x0006, 0x8004, 0x0016, 0x2008, 0x7858, 0xa084, 0x00ff,
+	0x8007, 0xa105, 0x001e, 0x20a2, 0xd1ac, 0x0118, 0x20a3, 0x0002,
+	0x0048, 0xd1b4, 0x0118, 0x20a3, 0x0001, 0x0020, 0x20a3, 0x0000,
+	0x2230, 0x0010, 0x6a80, 0x6e7c, 0x20a9, 0x0008, 0x0136, 0xad88,
+	0x0017, 0x2198, 0x20a1, 0x021b, 0x53a6, 0x013e, 0x20a1, 0x020b,
+	0x22a2, 0x26a2, 0x60c3, 0x0020, 0x20e1, 0x9080, 0x6014, 0xa084,
+	0x0004, 0xa085, 0x0009, 0x6016, 0x2001, 0xb7fc, 0x2003, 0x07d0,
+	0x2001, 0xb7fb, 0x2003, 0x0009, 0x080c, 0x17e2, 0x014e, 0x015e,
+	0x00de, 0x0005, 0x20e1, 0x9080, 0x20e1, 0x4000, 0x7a18, 0xa280,
+	0x0023, 0x2014, 0x8210, 0xa294, 0x00ff, 0x2202, 0x8217, 0x7818,
+	0xa080, 0x0028, 0x2004, 0x2019, 0xb535, 0x231c, 0xd3ac, 0x1110,
+	0xd0bc, 0x0188, 0x00d6, 0xa0e8, 0xb635, 0x2d6c, 0x6810, 0xa085,
+	0x0600, 0x20a2, 0x6814, 0x20a2, 0x2069, 0xb51c, 0x2da6, 0x8d68,
+	0x2da6, 0x00de, 0x0088, 0x00d6, 0xa0e8, 0xb635, 0x2d6c, 0x6810,
+	0xa085, 0x0600, 0x20a2, 0x6814, 0x20a2, 0x00de, 0x20a3, 0x0000,
+	0x2009, 0xb515, 0x210c, 0x21a2, 0x20a3, 0x0829, 0x20a3, 0x0000,
+	0x22a2, 0x20a3, 0x0000, 0x2fa2, 0x20a3, 0xffff, 0x20a3, 0x0000,
+	0x20a3, 0x0000, 0x0005, 0x00d6, 0x0156, 0x0136, 0x0146, 0x20a1,
+	0x020b, 0x00c1, 0x7810, 0x2068, 0x6860, 0x20a2, 0x685c, 0x20a2,
+	0x6880, 0x20a2, 0x687c, 0x20a2, 0xa006, 0x20a2, 0x20a2, 0x20a2,
+	0x20a2, 0x60c3, 0x000c, 0x080c, 0x7d67, 0x014e, 0x013e, 0x015e,
+	0x00de, 0x0005, 0x0026, 0x20e1, 0x9080, 0x20e1, 0x4000, 0x7818,
+	0xa080, 0x0028, 0x2004, 0x2011, 0xb535, 0x2214, 0xd2ac, 0x1110,
+	0xd0bc, 0x0188, 0x00d6, 0xa0e8, 0xb635, 0x2d6c, 0x6810, 0xa085,
+	0x0500, 0x20a2, 0x6814, 0x20a2, 0x2069, 0xb51c, 0x2da6, 0x8d68,
+	0x2da6, 0x00de, 0x0088, 0x00d6, 0xa0e8, 0xb635, 0x2d6c, 0x6810,
+	0xa085, 0x0500, 0x20a2, 0x6814, 0x20a2, 0x00de, 0x20a3, 0x0000,
+	0x2011, 0xb515, 0x2214, 0x22a2, 0x20a3, 0x0889, 0x20a3, 0x0000,
+	0x080c, 0x7d56, 0x22a2, 0x20a3, 0x0000, 0x7a08, 0x22a2, 0x2fa2,
+	0x20a3, 0x0000, 0x20a3, 0x0000, 0x002e, 0x0005, 0x00d6, 0x0156,
+	0x0136, 0x0146, 0x7810, 0xa0ec, 0xf000, 0x0168, 0xa06d, 0x080c,
+	0x5301, 0x0148, 0x684c, 0xa084, 0x2020, 0xa086, 0x2020, 0x1118,
+	0x7820, 0xc0cd, 0x7822, 0x20a1, 0x020b, 0x080c, 0x7b16, 0xa016,
+	0x22a2, 0x22a2, 0x22a2, 0x22a2, 0x22a2, 0x7810, 0xa084, 0xf000,
+	0x1130, 0x7810, 0xa084, 0x0700, 0x8007, 0x0043, 0x0010, 0xa006,
+	0x002b, 0x014e, 0x013e, 0x015e, 0x00de, 0x0005, 0x79e8, 0x7a7d,
+	0x7a8d, 0x7abf, 0x7ad2, 0x7aed, 0x7af6, 0x79e6, 0x080c, 0x1515,
+	0x0016, 0x0036, 0x694c, 0xa18c, 0x0003, 0x0118, 0xa186, 0x0003,
+	0x1170, 0x6b78, 0x7820, 0xd0cc, 0x0108, 0xc3e5, 0x23a2, 0x6868,
+	0x20a2, 0x6864, 0x20a2, 0x003e, 0x001e, 0x0804, 0x7ac9, 0xa186,
+	0x0001, 0x190c, 0x1515, 0x6b78, 0x7820, 0xd0cc, 0x0108, 0xc3e5,
+	0x23a2, 0x6868, 0x20a2, 0x6864, 0x20a2, 0x22a2, 0x6874, 0x20a2,
+	0x22a2, 0x687c, 0x20a2, 0x2009, 0x0018, 0xa384, 0x0300, 0x0904,
+	0x7a77, 0xd3c4, 0x0110, 0x687c, 0xa108, 0xd3cc, 0x0110, 0x6874,
+	0xa108, 0x0156, 0x20a9, 0x000d, 0xad80, 0x0020, 0x201c, 0x831f,
+	0x23a2, 0x8000, 0x1f04, 0x7a26, 0x015e, 0x22a2, 0x22a2, 0x22a2,
+	0xa184, 0x0003, 0x0904, 0x7a77, 0x20a1, 0x020b, 0x20e1, 0x9080,
+	0x20e1, 0x4000, 0x0006, 0x7818, 0xa080, 0x0028, 0x2004, 0x2011,
+	0xb535, 0x2214, 0xd2ac, 0x1110, 0xd0bc, 0x0188, 0x00d6, 0xa0e8,
+	0xb635, 0x2d6c, 0x6810, 0xa085, 0x0700, 0x20a2, 0x6814, 0x20a2,
+	0x2069, 0xb51c, 0x2da6, 0x8d68, 0x2da6, 0x00de, 0x0088, 0x00d6,
+	0xa0e8, 0xb635, 0x2d6c, 0x6810, 0xa085, 0x0700, 0x20a2, 0x6814,
+	0x20a2, 0x00de, 0x20a3, 0x0000, 0x2011, 0xb515, 0x2214, 0x22a2,
+	0x000e, 0x7b20, 0xd3cc, 0x0118, 0x20a3, 0x0889, 0x0010, 0x20a3,
+	0x0898, 0x20a2, 0x080c, 0x7d56, 0x22a2, 0x20a3, 0x0000, 0x61c2,
+	0x003e, 0x001e, 0x080c, 0x7d67, 0x0005, 0x2011, 0x0008, 0x2001,
+	0xb50d, 0x2004, 0xd0f4, 0x0110, 0x2011, 0x0028, 0x7820, 0xd0cc,
+	0x0108, 0xc2e5, 0x22a2, 0xa016, 0x04d0, 0x2011, 0x0302, 0x0016,
+	0x0036, 0x7828, 0x792c, 0xa11d, 0x0108, 0xc2dd, 0x7b20, 0xd3cc,
+	0x0108, 0xc2e5, 0x22a2, 0x20a2, 0x21a2, 0x003e, 0x001e, 0xa016,
+	0x22a2, 0x20a3, 0x0012, 0x22a2, 0x20a3, 0x0008, 0x22a2, 0x22a2,
+	0x22a2, 0x22a2, 0x20a3, 0x7000, 0x20a3, 0x0500, 0x22a2, 0x20a3,
+	0x000a, 0x22a2, 0x22a2, 0x20a3, 0x2500, 0x22a2, 0x22a2, 0x22a2,
+	0x22a2, 0x22a2, 0x60c3, 0x0032, 0x080c, 0x7d67, 0x0005, 0x2011,
+	0x0028, 0x7820, 0xd0cc, 0x0108, 0xc2e5, 0x22a2, 0xa016, 0x22a2,
+	0x22a2, 0x22a2, 0x22a2, 0x22a2, 0x22a2, 0x60c3, 0x0018, 0x080c,
+	0x7d67, 0x0005, 0x2011, 0x0100, 0x7820, 0xd0cc, 0x0108, 0xc2e5,
+	0x22a2, 0xa016, 0x22a2, 0x22a2, 0x22a2, 0x22a2, 0x22a2, 0x20a3,
+	0x0008, 0x22a2, 0x7854, 0xa084, 0x00ff, 0x20a2, 0x22a2, 0x22a2,
+	0x60c3, 0x0020, 0x080c, 0x7d67, 0x0005, 0x2011, 0x0008, 0x7820,
+	0xd0cc, 0x0108, 0xc2e5, 0x22a2, 0xa016, 0x0888, 0x0036, 0x7b10,
+	0xa384, 0xff00, 0x7812, 0xa384, 0x00ff, 0x8001, 0x1138, 0x7820,
+	0xd0cc, 0x0108, 0xc2e5, 0x22a2, 0x003e, 0x0808, 0x0046, 0x2021,
+	0x0800, 0x0006, 0x7820, 0xd0cc, 0x000e, 0x0108, 0xc4e5, 0x24a2,
+	0x004e, 0x22a2, 0x20a2, 0x003e, 0x0804, 0x7ac9, 0x0026, 0x20e1,
+	0x9080, 0x20e1, 0x4000, 0x7818, 0xa080, 0x0028, 0x2004, 0x2011,
+	0xb535, 0x2214, 0xd2ac, 0x1110, 0xd0bc, 0x0188, 0x00d6, 0xa0e8,
+	0xb635, 0x2d6c, 0x6810, 0xa085, 0x0700, 0x20a2, 0x6814, 0x20a2,
+	0x2069, 0xb51c, 0x2da6, 0x8d68, 0x2da6, 0x00de, 0x0088, 0x00d6,
+	0xa0e8, 0xb635, 0x2d6c, 0x6810, 0xa085, 0x0700, 0x20a2, 0x6814,
+	0x20a2, 0x00de, 0x20a3, 0x0000, 0x2011, 0xb515, 0x2214, 0x22a2,
+	0x7820, 0xd0cc, 0x0118, 0x20a3, 0x0889, 0x0010, 0x20a3, 0x0898,
+	0x20a3, 0x0000, 0x080c, 0x7d56, 0x22a2, 0x20a3, 0x0000, 0x7a08,
+	0x22a2, 0x2fa2, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x002e, 0x0005,
+	0x00d6, 0x0156, 0x0136, 0x0146, 0x0016, 0x0036, 0x7810, 0xa084,
+	0x0700, 0x8007, 0x003b, 0x003e, 0x001e, 0x014e, 0x013e, 0x015e,
+	0x00de, 0x0005, 0x7b7a, 0x7b7a, 0x7b7c, 0x7b7a, 0x7b7a, 0x7b7a,
+	0x7b9e, 0x7b7a, 0x080c, 0x1515, 0x7910, 0xa18c, 0xf8ff, 0xa18d,
+	0x0600, 0x7912, 0x20a1, 0x020b, 0x2009, 0x0003, 0x00f9, 0x00d6,
+	0x2069, 0xb552, 0x6804, 0xd0bc, 0x0130, 0x682c, 0xa084, 0x00ff,
+	0x8007, 0x20a2, 0x0010, 0x20a3, 0x3f00, 0x00de, 0x22a2, 0x22a2,
+	0x22a2, 0x60c3, 0x0001, 0x080c, 0x7d67, 0x0005, 0x20a1, 0x020b,
+	0x2009, 0x0003, 0x0019, 0x20a3, 0x7f00, 0x0c80, 0x0026, 0x20e1,
+	0x9080, 0x20e1, 0x4000, 0x7818, 0xa080, 0x0028, 0x2004, 0x2011,
+	0xb535, 0x2214, 0xd2ac, 0x1110, 0xd0bc, 0x0188, 0x00d6, 0xa0e8,
+	0xb635, 0x2d6c, 0x6810, 0xa085, 0x0100, 0x20a2, 0x6814, 0x20a2,
+	0x2069, 0xb51c, 0x2da6, 0x8d68, 0x2da6, 0x00de, 0x0088, 0x00d6,
+	0xa0e8, 0xb635, 0x2d6c, 0x6810, 0xa085, 0x0100, 0x20a2, 0x6814,
+	0x20a2, 0x00de, 0x20a3, 0x0000, 0x2011, 0xb515, 0x2214, 0x22a2,
+	0x20a3, 0x0888, 0xa18d, 0x0008, 0x21a2, 0x080c, 0x7d56, 0x22a2,
+	0x20a3, 0x0000, 0x7a08, 0x22a2, 0x2fa2, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x002e, 0x0005, 0x00e6, 0x00d6, 0x00c6, 0x0056, 0x0046,
+	0x0036, 0x2061, 0x0100, 0x2071, 0xb500, 0x7154, 0x7818, 0x2068,
+	0x68a0, 0x2028, 0x76d4, 0xd6ac, 0x1130, 0xd0bc, 0x1120, 0x6910,
+	0x6a14, 0x7454, 0x0020, 0x6910, 0x6a14, 0x7370, 0x7474, 0x781c,
+	0xa0be, 0x0006, 0x0904, 0x7ca1, 0xa0be, 0x000a, 0x15e8, 0xa185,
+	0x0200, 0x6062, 0x6266, 0x636a, 0x646e, 0x6073, 0x2029, 0x6077,
+	0x0000, 0x688c, 0x8000, 0xa084, 0x00ff, 0x688e, 0x8007, 0x607a,
+	0x607f, 0x0000, 0x2f00, 0x6082, 0x7808, 0x6086, 0x7810, 0x2070,
+	0x7014, 0x608a, 0x7010, 0x608e, 0x700c, 0x60c6, 0x7008, 0x60ca,
+	0x686c, 0x60ce, 0x60af, 0x95d5, 0x60d7, 0x0000, 0x609f, 0x0000,
+	0x080c, 0x85b9, 0x2009, 0x07d0, 0x60c4, 0xa084, 0xfff0, 0xa005,
+	0x0110, 0x2009, 0x1b58, 0x080c, 0x6a15, 0x003e, 0x004e, 0x005e,
+	0x00ce, 0x00de, 0x00ee, 0x0005, 0x70d4, 0xd0ac, 0x1110, 0xd5bc,
+	0x0138, 0xa185, 0x0100, 0x6062, 0x6266, 0x636a, 0x646e, 0x0038,
+	0xa185, 0x0100, 0x6062, 0x6266, 0x606b, 0x0000, 0x646e, 0x6073,
+	0x0809, 0x6077, 0x0008, 0x688c, 0x8000, 0xa084, 0x00ff, 0x688e,
+	0x8007, 0x607a, 0x607f, 0x0000, 0x2f00, 0x6082, 0x7808, 0x6086,
+	0x7810, 0x2070, 0x7014, 0x608a, 0x7010, 0x608e, 0x700c, 0x60c6,
+	0x7008, 0x60ca, 0x686c, 0x60ce, 0x60af, 0x95d5, 0x60d7, 0x0000,
+	0xa582, 0x0080, 0x0248, 0x6a00, 0xd2f4, 0x0120, 0x6a14, 0xa294,
+	0x00ff, 0x0010, 0x2011, 0x0000, 0x629e, 0x080c, 0x85b9, 0x2009,
+	0x07d0, 0x60c4, 0xa084, 0xfff0, 0xa005, 0x0110, 0x2009, 0x1b58,
+	0x080c, 0x6a15, 0x003e, 0x004e, 0x005e, 0x00ce, 0x00de, 0x00ee,
+	0x0005, 0x7810, 0x2070, 0x704c, 0xa084, 0x0003, 0xa086, 0x0002,
+	0x0904, 0x7cf7, 0x2001, 0xb535, 0x2004, 0xd0ac, 0x1110, 0xd5bc,
+	0x0138, 0xa185, 0x0100, 0x6062, 0x6266, 0x636a, 0x646e, 0x0038,
+	0xa185, 0x0100, 0x6062, 0x6266, 0x606b, 0x0000, 0x646e, 0x6073,
+	0x0880, 0x6077, 0x0008, 0x688c, 0x8000, 0xa084, 0x00ff, 0x688e,
+	0x8007, 0x607a, 0x7834, 0x607e, 0x2f00, 0x6086, 0x7808, 0x6082,
+	0x7060, 0x608a, 0x705c, 0x608e, 0x7080, 0x60c6, 0x707c, 0x60ca,
+	0x707c, 0x792c, 0xa108, 0x792e, 0x7080, 0x7928, 0xa109, 0x792a,
+	0x686c, 0x60ce, 0x60af, 0x95d5, 0x60d7, 0x0000, 0xa582, 0x0080,
+	0x0248, 0x6a00, 0xd2f4, 0x0120, 0x6a14, 0xa294, 0x00ff, 0x0010,
+	0x2011, 0x0000, 0x629e, 0x080c, 0x85b6, 0x0804, 0x7c8f, 0x2001,
+	0xb535, 0x2004, 0xd0ac, 0x1110, 0xd5bc, 0x0138, 0xa185, 0x0700,
+	0x6062, 0x6266, 0x636a, 0x646e, 0x0038, 0xa185, 0x0700, 0x6062,
+	0x6266, 0x606b, 0x0000, 0x646e, 0x080c, 0x5301, 0x0180, 0x00d6,
+	0x7810, 0xa06d, 0x684c, 0x00de, 0xa084, 0x2020, 0xa086, 0x2020,
+	0x1130, 0x7820, 0xc0cd, 0x7822, 0x6073, 0x0889, 0x0010, 0x6073,
+	0x0898, 0x6077, 0x0000, 0x688c, 0x8000, 0xa084, 0x00ff, 0x688e,
+	0x8007, 0x607a, 0x607f, 0x0000, 0x2f00, 0x6086, 0x7808, 0x6082,
+	0x7014, 0x608a, 0x7010, 0x608e, 0x700c, 0x60c6, 0x7008, 0x60ca,
+	0x686c, 0x60ce, 0x60af, 0x95d5, 0x60d7, 0x0000, 0xa582, 0x0080,
+	0x0248, 0x6a00, 0xd2f4, 0x0120, 0x6a14, 0xa294, 0x00ff, 0x0010,
+	0x2011, 0x0000, 0x629e, 0x7820, 0xd0cc, 0x0120, 0x080c, 0x85b9,
+	0x0804, 0x7c8f, 0x080c, 0x85b6, 0x0804, 0x7c8f, 0x7a18, 0xa280,
+	0x0023, 0x2014, 0x8210, 0xa294, 0x00ff, 0x2202, 0x8217, 0x0005,
+	0x00d6, 0x2069, 0xb7e0, 0x6843, 0x0001, 0x00de, 0x0005, 0x20e1,
+	0x9080, 0x60a3, 0x0056, 0x60a7, 0x9575, 0x0019, 0x080c, 0x6a07,
+	0x0005, 0x0006, 0x6014, 0xa084, 0x0004, 0xa085, 0x0009, 0x6016,
+	0x000e, 0x0005, 0x0016, 0x00c6, 0x0006, 0x2061, 0x0100, 0x61a4,
+	0x60a7, 0x95f5, 0x6014, 0xa084, 0x0004, 0xa085, 0x0008, 0x6016,
+	0x000e, 0xe000, 0xe000, 0xe000, 0xe000, 0x61a6, 0x00ce, 0x001e,
+	0x0005, 0x00c6, 0x00d6, 0x0016, 0x0026, 0x2061, 0x0100, 0x2069,
+	0x0140, 0x080c, 0x5acf, 0x1198, 0x2001, 0xb7fc, 0x2004, 0xa005,
+	0x15b8, 0x0066, 0x2031, 0x0001, 0x080c, 0x5b51, 0x006e, 0x1118,
+	0x080c, 0x6a07, 0x0468, 0x00c6, 0x2061, 0xb7e0, 0x00d8, 0x6904,
+	0xa194, 0x4000, 0x0550, 0x0831, 0x6803, 0x1000, 0x6803, 0x0000,
+	0x00c6, 0x2061, 0xb7e0, 0x6128, 0xa192, 0x00c8, 0x1258, 0x8108,
+	0x612a, 0x6124, 0x00ce, 0x81ff, 0x0198, 0x080c, 0x6a07, 0x080c,
+	0x7d71, 0x0070, 0x6124, 0xa1e5, 0x0000, 0x0140, 0x080c, 0xb444,
+	0x080c, 0x6a10, 0x2009, 0x0014, 0x080c, 0x864c, 0x00ce, 0x0000,
+	0x002e, 0x001e, 0x00de, 0x00ce, 0x0005, 0x2001, 0xb7fc, 0x2004,
+	0xa005, 0x1db0, 0x00c6, 0x2061, 0xb7e0, 0x6128, 0xa192, 0x0003,
+	0x1e08, 0x8108, 0x612a, 0x00ce, 0x080c, 0x6a07, 0x080c, 0x4b1f,
+	0x0c38, 0x00c6, 0x00d6, 0x00e6, 0x0016, 0x0026, 0x080c, 0x6a1d,
+	0x2071, 0xb7e0, 0x713c, 0x81ff, 0x0590, 0x2061, 0x0100, 0x2069,
+	0x0140, 0x080c, 0x5acf, 0x11a8, 0x0036, 0x2019, 0x0002, 0x080c,
+	0x7fe4, 0x003e, 0x713c, 0x2160, 0x080c, 0xb444, 0x2009, 0x004a,
+	0x080c, 0x864c, 0x0066, 0x2031, 0x0001, 0x080c, 0x5b51, 0x006e,
+	0x00b0, 0x6904, 0xa194, 0x4000, 0x01c0, 0x6803, 0x1000, 0x6803,
+	0x0000, 0x0036, 0x2019, 0x0001, 0x080c, 0x7fe4, 0x003e, 0x713c,
+	0x2160, 0x080c, 0xb444, 0x2009, 0x004a, 0x080c, 0x864c, 0x002e,
+	0x001e, 0x00ee, 0x00de, 0x00ce, 0x0005, 0x0c58, 0x0026, 0x00e6,
+	0x2071, 0xb7e0, 0x7048, 0xd084, 0x01c0, 0x713c, 0x81ff, 0x01a8,
+	0x2071, 0x0100, 0xa188, 0x0007, 0x2114, 0xa28e, 0x0006, 0x1138,
+	0x7014, 0xa084, 0x0184, 0xa085, 0x0012, 0x7016, 0x0030, 0x7014,
+	0xa084, 0x0184, 0xa085, 0x0016, 0x7016, 0x00ee, 0x002e, 0x0005,
+	0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0056, 0x0046, 0x0006, 0x0126,
+	0x2091, 0x8000, 0x6018, 0x2068, 0x6ca0, 0x2071, 0xb7e0, 0x7018,
+	0x2068, 0x8dff, 0x0188, 0x68a0, 0xa406, 0x0118, 0x6854, 0x2068,
+	0x0cc0, 0x6010, 0x2060, 0x643c, 0x6540, 0x6648, 0x2d60, 0x080c,
+	0x511a, 0x0110, 0xa085, 0x0001, 0x012e, 0x000e, 0x004e, 0x005e,
+	0x006e, 0x00ce, 0x00de, 0x00ee, 0x0005, 0x20a1, 0x020b, 0x080c,
+	0x7641, 0x20a3, 0x1200, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x781c,
+	0xa086, 0x0004, 0x1110, 0x6098, 0x0018, 0x2001, 0xb515, 0x2004,
+	0x20a2, 0x7834, 0x20a2, 0x7838, 0x20a2, 0x20a9, 0x0010, 0xa006,
+	0x20a2, 0x1f04, 0x7ea0, 0x20a2, 0x20a2, 0x60c3, 0x002c, 0x080c,
+	0x7d67, 0x0005, 0x0156, 0x0146, 0x20a1, 0x020b, 0x080c, 0x7641,
+	0x20a3, 0x0f00, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x7808, 0x20a2,
+	0x60c3, 0x0008, 0x080c, 0x7d67, 0x014e, 0x015e, 0x0005, 0x0156,
+	0x0146, 0x20a1, 0x020b, 0x080c, 0x76dd, 0x20a3, 0x0200, 0x20a3,
+	0x0000, 0x20a9, 0x0006, 0x2011, 0xb540, 0x2019, 0xb541, 0x23a6,
+	0x22a6, 0xa398, 0x0002, 0xa290, 0x0002, 0x1f04, 0x7ecf, 0x20a3,
+	0x0000, 0x20a3, 0x0000, 0x60c3, 0x001c, 0x080c, 0x7d67, 0x014e,
+	0x015e, 0x0005, 0x0156, 0x0146, 0x0016, 0x0026, 0x20a1, 0x020b,
+	0x080c, 0x76b6, 0x080c, 0x76cc, 0x7810, 0xa080, 0x0000, 0x2004,
+	0xa080, 0x0015, 0x2098, 0x7808, 0xa088, 0x0002, 0x21a8, 0x53a6,
+	0xa080, 0x0004, 0x8003, 0x60c2, 0x080c, 0x7d67, 0x002e, 0x001e,
+	0x014e, 0x015e, 0x0005, 0x0156, 0x0146, 0x20a1, 0x020b, 0x080c,
+	0x7641, 0x20a3, 0x6200, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x7808,
+	0x20a2, 0x60c3, 0x0008, 0x080c, 0x7d67, 0x014e, 0x015e, 0x0005,
+	0x0156, 0x0146, 0x0016, 0x0026, 0x20a1, 0x020b, 0x080c, 0x7641,
+	0x7810, 0xa080, 0x0000, 0x2004, 0xa080, 0x0017, 0x2098, 0x7808,
+	0xa088, 0x0002, 0x21a8, 0x53a6, 0x8003, 0x60c2, 0x080c, 0x7d67,
+	0x002e, 0x001e, 0x014e, 0x015e, 0x0005, 0x00e6, 0x00c6, 0x0006,
+	0x0126, 0x2091, 0x8000, 0x2071, 0xb7e0, 0x700c, 0x2060, 0x8cff,
+	0x0178, 0x080c, 0x9e58, 0x1110, 0x080c, 0x8c19, 0x600c, 0x0006,
+	0x080c, 0xa01f, 0x080c, 0x861d, 0x080c, 0x811e, 0x00ce, 0x0c78,
+	0x700f, 0x0000, 0x700b, 0x0000, 0x012e, 0x000e, 0x00ce, 0x00ee,
+	0x0005, 0x0126, 0x0156, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0026,
+	0x0016, 0x0006, 0x2091, 0x8000, 0x2069, 0x0100, 0x2079, 0x0140,
+	0x2071, 0xb7e0, 0x7024, 0x2060, 0x8cff, 0x05a0, 0x080c, 0x7d7a,
+	0x68c3, 0x0000, 0x080c, 0x6a10, 0x2009, 0x0013, 0x080c, 0x864c,
+	0x20a9, 0x01f4, 0x6824, 0xd094, 0x0158, 0x6827, 0x0004, 0x7804,
+	0xa084, 0x4000, 0x01a0, 0x7803, 0x1000, 0x7803, 0x0000, 0x0078,
+	0xd084, 0x0118, 0x6827, 0x0001, 0x0010, 0x1f04, 0x7f7a, 0x7804,
+	0xa084, 0x1000, 0x0120, 0x7803, 0x0100, 0x7803, 0x0000, 0x6824,
+	0x000e, 0x001e, 0x002e, 0x00ce, 0x00de, 0x00ee, 0x00fe, 0x015e,
+	0x012e, 0x0005, 0x2001, 0xb500, 0x2004, 0xa096, 0x0001, 0x0590,
+	0xa096, 0x0004, 0x0578, 0x080c, 0x6a10, 0x6814, 0xa084, 0x0001,
+	0x0110, 0x68a7, 0x95f5, 0x6817, 0x0008, 0x68c3, 0x0000, 0x2011,
+	0x4adc, 0x080c, 0x699c, 0x20a9, 0x01f4, 0x6824, 0xd094, 0x0158,
+	0x6827, 0x0004, 0x7804, 0xa084, 0x4000, 0x01a0, 0x7803, 0x1000,
+	0x7803, 0x0000, 0x0078, 0xd084, 0x0118, 0x6827, 0x0001, 0x0010,
+	0x1f04, 0x7fbd, 0x7804, 0xa084, 0x1000, 0x0120, 0x7803, 0x0100,
+	0x7803, 0x0000, 0x000e, 0x001e, 0x002e, 0x00ce, 0x00de, 0x00ee,
+	0x00fe, 0x015e, 0x012e, 0x0005, 0x0126, 0x0156, 0x00f6, 0x00e6,
+	0x00d6, 0x00c6, 0x0026, 0x0016, 0x0006, 0x2091, 0x8000, 0x2069,
+	0x0100, 0x2079, 0x0140, 0x2071, 0xb7e0, 0x703c, 0x2060, 0x8cff,
+	0x0904, 0x806b, 0xa386, 0x0002, 0x1128, 0x6814, 0xa084, 0x0002,
+	0x0904, 0x806b, 0x68af, 0x95f5, 0x6817, 0x0010, 0x2009, 0x00fa,
+	0x8109, 0x1df0, 0x68c7, 0x0000, 0x68cb, 0x0008, 0x080c, 0x6a1d,
+	0x080c, 0x220c, 0x0046, 0x2009, 0x017f, 0x200b, 0x00a5, 0x2021,
+	0x0169, 0x2404, 0xa084, 0x000f, 0xa086, 0x0004, 0x1500, 0x68af,
+	0x95f5, 0x68c7, 0x0000, 0x68cb, 0x0008, 0x00e6, 0x00f6, 0x2079,
+	0x0020, 0x2071, 0xb84a, 0x6814, 0xa084, 0x0184, 0xa085, 0x0012,
+	0x6816, 0x7803, 0x0008, 0x7003, 0x0000, 0x00fe, 0x00ee, 0xa386,
+	0x0002, 0x1128, 0x7884, 0xa005, 0x1110, 0x7887, 0x0001, 0x2001,
+	0xb7b1, 0x2004, 0x200a, 0x004e, 0xa39d, 0x0000, 0x1120, 0x2009,
+	0x0049, 0x080c, 0x864c, 0x20a9, 0x03e8, 0x6824, 0xd094, 0x0158,
+	0x6827, 0x0004, 0x7804, 0xa084, 0x4000, 0x01a0, 0x7803, 0x1000,
+	0x7803, 0x0000, 0x0078, 0xd08c, 0x0118, 0x6827, 0x0002, 0x0010,
+	0x1f04, 0x804d, 0x7804, 0xa084, 0x1000, 0x0120, 0x7803, 0x0100,
+	0x7803, 0x0000, 0x6824, 0x000e, 0x001e, 0x002e, 0x00ce, 0x00de,
+	0x00ee, 0x00fe, 0x015e, 0x012e, 0x0005, 0x00d6, 0x0126, 0x2091,
+	0x8000, 0x2069, 0xb7e0, 0x6a06, 0x012e, 0x00de, 0x0005, 0x00d6,
+	0x0126, 0x2091, 0x8000, 0x2069, 0xb7e0, 0x6a32, 0x012e, 0x00de,
+	0x0005, 0x00f6, 0x00e6, 0x00c6, 0x0066, 0x0006, 0x0126, 0x2071,
+	0xb7e0, 0x7614, 0x2660, 0x2678, 0x2091, 0x8000, 0x8cff, 0x0538,
+	0x601c, 0xa206, 0x1500, 0x7014, 0xac36, 0x1110, 0x660c, 0x7616,
+	0x7010, 0xac36, 0x1140, 0x2c00, 0xaf36, 0x0118, 0x2f00, 0x7012,
+	0x0010, 0x7013, 0x0000, 0x660c, 0x0066, 0x2c00, 0xaf06, 0x0110,
+	0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000, 0x080c, 0x9e1d, 0x080c,
+	0x811e, 0x00ce, 0x08d8, 0x2c78, 0x600c, 0x2060, 0x08b8, 0x012e,
+	0x000e, 0x006e, 0x00ce, 0x00ee, 0x00fe, 0x0005, 0x0156, 0x0146,
+	0x20a1, 0x020b, 0x080c, 0x7902, 0x7810, 0x20a2, 0xa006, 0x20a2,
+	0x20a2, 0x20a2, 0x20a2, 0x20a3, 0x1000, 0x0804, 0x8116, 0x0156,
+	0x0146, 0x20a1, 0x020b, 0x080c, 0x7902, 0x7810, 0x20a2, 0xa006,
+	0x20a2, 0x20a2, 0x20a2, 0x20a2, 0x20a3, 0x4000, 0x0478, 0x0156,
+	0x0146, 0x20a1, 0x020b, 0x080c, 0x7902, 0x7810, 0x20a2, 0xa006,
+	0x20a2, 0x20a2, 0x20a2, 0x20a2, 0x20a3, 0x2000, 0x00f8, 0x0156,
+	0x0146, 0x20a1, 0x020b, 0x080c, 0x7902, 0x7810, 0x20a2, 0xa006,
+	0x20a2, 0x20a2, 0x20a2, 0x20a2, 0x20a3, 0x0400, 0x0078, 0x0156,
+	0x0146, 0x20a1, 0x020b, 0x080c, 0x7902, 0x7810, 0x20a2, 0xa006,
+	0x20a2, 0x20a2, 0x20a2, 0x20a2, 0x20a3, 0x0200, 0x0089, 0x60c3,
+	0x0020, 0x080c, 0x7d67, 0x014e, 0x015e, 0x0005, 0x00e6, 0x2071,
+	0xb7e0, 0x7020, 0xa005, 0x0110, 0x8001, 0x7022, 0x00ee, 0x0005,
+	0x20a9, 0x0008, 0x20a2, 0x1f04, 0x812a, 0x20a2, 0x20a2, 0x0005,
+	0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0076, 0x0066, 0x0006, 0x0126,
+	0x2091, 0x8000, 0x2071, 0xb7e0, 0x7614, 0x2660, 0x2678, 0x2039,
+	0x0001, 0x87ff, 0x0904, 0x81c6, 0x8cff, 0x0904, 0x81c6, 0x601c,
+	0xa086, 0x0006, 0x1904, 0x81c1, 0x88ff, 0x0138, 0x2800, 0xac06,
+	0x1904, 0x81c1, 0x2039, 0x0000, 0x0050, 0x6018, 0xa206, 0x1904,
+	0x81c1, 0x85ff, 0x0120, 0x6050, 0xa106, 0x1904, 0x81c1, 0x7024,
+	0xac06, 0x1598, 0x2069, 0x0100, 0x68c0, 0xa005, 0x1160, 0x6824,
+	0xd084, 0x0148, 0x6827, 0x0001, 0x080c, 0x6a10, 0x080c, 0x824d,
+	0x7027, 0x0000, 0x0410, 0x080c, 0x6a10, 0x6820, 0xd0b4, 0x0110,
+	0x68a7, 0x95f5, 0x6817, 0x0008, 0x68c3, 0x0000, 0x080c, 0x824d,
+	0x7027, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0xa384, 0x1000,
+	0x0120, 0x6803, 0x0100, 0x6803, 0x0000, 0x2069, 0x0100, 0x6824,
+	0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x7014, 0xac36, 0x1110,
+	0x660c, 0x7616, 0x7010, 0xac36, 0x1140, 0x2c00, 0xaf36, 0x0118,
+	0x2f00, 0x7012, 0x0010, 0x7013, 0x0000, 0x660c, 0x0066, 0x2c00,
+	0xaf06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x89ff, 0x1158, 0x600f,
+	0x0000, 0x6010, 0x2068, 0x080c, 0x9c5a, 0x0110, 0x080c, 0xb099,
+	0x080c, 0x9e1d, 0x080c, 0x811e, 0x88ff, 0x1190, 0x00ce, 0x0804,
+	0x8141, 0x2c78, 0x600c, 0x2060, 0x0804, 0x8141, 0xa006, 0x012e,
+	0x000e, 0x006e, 0x007e, 0x00ce, 0x00de, 0x00ee, 0x00fe, 0x0005,
+	0x6017, 0x0000, 0x00ce, 0xa8c5, 0x0001, 0x0c88, 0x00f6, 0x00e6,
+	0x00d6, 0x00c6, 0x0066, 0x0026, 0x0006, 0x0126, 0x2091, 0x8000,
+	0x2071, 0xb7e0, 0x7638, 0x2660, 0x2678, 0x8cff, 0x0904, 0x823d,
+	0x601c, 0xa086, 0x0006, 0x1904, 0x8238, 0x87ff, 0x0128, 0x2700,
+	0xac06, 0x1904, 0x8238, 0x0048, 0x6018, 0xa206, 0x1904, 0x8238,
+	0x85ff, 0x0118, 0x6050, 0xa106, 0x15d8, 0x703c, 0xac06, 0x1180,
+	0x0036, 0x2019, 0x0001, 0x080c, 0x7fe4, 0x7033, 0x0000, 0x703f,
+	0x0000, 0x7043, 0x0000, 0x7047, 0x0000, 0x704b, 0x0000, 0x003e,
+	0x7038, 0xac36, 0x1110, 0x660c, 0x763a, 0x7034, 0xac36, 0x1140,
+	0x2c00, 0xaf36, 0x0118, 0x2f00, 0x7036, 0x0010, 0x7037, 0x0000,
+	0x660c, 0x0066, 0x2c00, 0xaf06, 0x0110, 0x7e0e, 0x0008, 0x2678,
+	0x600f, 0x0000, 0x6010, 0x2068, 0x080c, 0x9c5a, 0x0110, 0x080c,
+	0xb099, 0x080c, 0x9e1d, 0x87ff, 0x1190, 0x00ce, 0x0804, 0x81e5,
+	0x2c78, 0x600c, 0x2060, 0x0804, 0x81e5, 0xa006, 0x012e, 0x000e,
+	0x002e, 0x006e, 0x00ce, 0x00de, 0x00ee, 0x00fe, 0x0005, 0x6017,
+	0x0000, 0x00ce, 0xa7bd, 0x0001, 0x0c88, 0x00e6, 0x2071, 0xb7e0,
+	0x2001, 0xb500, 0x2004, 0xa086, 0x0002, 0x1118, 0x7007, 0x0005,
+	0x0010, 0x7007, 0x0000, 0x00ee, 0x0005, 0x00f6, 0x00e6, 0x00c6,
+	0x0066, 0x0026, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0xb7e0,
+	0x2c10, 0x7638, 0x2660, 0x2678, 0x8cff, 0x0518, 0x2200, 0xac06,
+	0x11e0, 0x7038, 0xac36, 0x1110, 0x660c, 0x763a, 0x7034, 0xac36,
+	0x1140, 0x2c00, 0xaf36, 0x0118, 0x2f00, 0x7036, 0x0010, 0x7037,
+	0x0000, 0x660c, 0x2c00, 0xaf06, 0x0110, 0x7e0e, 0x0008, 0x2678,
+	0x600f, 0x0000, 0xa085, 0x0001, 0x0020, 0x2c78, 0x600c, 0x2060,
+	0x08d8, 0x012e, 0x000e, 0x002e, 0x006e, 0x00ce, 0x00ee, 0x00fe,
+	0x0005, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0006, 0x0126,
+	0x2091, 0x8000, 0x2071, 0xb7e0, 0x760c, 0x2660, 0x2678, 0x8cff,
+	0x0904, 0x8323, 0x6018, 0xa080, 0x0028, 0x2004, 0xa206, 0x1904,
+	0x831e, 0x7024, 0xac06, 0x1508, 0x2069, 0x0100, 0x68c0, 0xa005,
+	0x0904, 0x82fa, 0x080c, 0x7d7a, 0x68c3, 0x0000, 0x080c, 0x824d,
+	0x7027, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0xa384, 0x1000,
+	0x0120, 0x6803, 0x0100, 0x6803, 0x0000, 0x2069, 0x0100, 0x6824,
+	0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x700c, 0xac36, 0x1110,
+	0x660c, 0x760e, 0x7008, 0xac36, 0x1140, 0x2c00, 0xaf36, 0x0118,
+	0x2f00, 0x700a, 0x0010, 0x700b, 0x0000, 0x660c, 0x0066, 0x2c00,
+	0xaf06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000, 0x080c,
+	0x9e47, 0x1158, 0x080c, 0x2cc2, 0x080c, 0x9e58, 0x11f0, 0x080c,
+	0x8c19, 0x00d8, 0x080c, 0x824d, 0x08c0, 0x080c, 0x9e58, 0x1118,
+	0x080c, 0x8c19, 0x0090, 0x6010, 0x2068, 0x080c, 0x9c5a, 0x0168,
+	0x601c, 0xa086, 0x0003, 0x11f8, 0x6837, 0x0103, 0x6b4a, 0x6847,
+	0x0000, 0x080c, 0x5408, 0x080c, 0x9e11, 0x080c, 0xa01f, 0x080c,
+	0x9e1d, 0x080c, 0x811e, 0x00ce, 0x0804, 0x82a7, 0x2c78, 0x600c,
+	0x2060, 0x0804, 0x82a7, 0x012e, 0x000e, 0x006e, 0x00ce, 0x00de,
+	0x00ee, 0x00fe, 0x0005, 0x601c, 0xa086, 0x0006, 0x1d30, 0x080c,
+	0xb099, 0x0c18, 0x0036, 0x0156, 0x0136, 0x0146, 0x3908, 0xa006,
+	0xa190, 0x0020, 0x221c, 0xa39e, 0x2ab7, 0x1118, 0x8210, 0x8000,
+	0x0cc8, 0xa005, 0x0138, 0x20a9, 0x0020, 0x2198, 0xa110, 0x22a0,
+	0x22c8, 0x53a3, 0x014e, 0x013e, 0x015e, 0x003e, 0x0005, 0x00d6,
+	0x20a1, 0x020b, 0x080c, 0x76dd, 0x20a3, 0x0200, 0x20a3, 0x0014,
+	0x60c3, 0x0014, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x2099, 0xb7b9,
+	0x20a9, 0x0004, 0x53a6, 0x20a3, 0x0004, 0x20a3, 0x7878, 0x20a3,
+	0x0000, 0x20a3, 0x0000, 0x080c, 0x7d67, 0x00de, 0x0005, 0x20a1,
+	0x020b, 0x080c, 0x76dd, 0x20a3, 0x0214, 0x20a3, 0x0018, 0x20a3,
+	0x0800, 0x7810, 0xa084, 0xff00, 0x20a2, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x7810, 0xa084, 0x00ff,
+	0x20a2, 0x7828, 0x20a2, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x60c3,
+	0x0018, 0x080c, 0x7d67, 0x0005, 0x00d6, 0x0016, 0x2f68, 0x2009,
+	0x0035, 0x080c, 0xa10a, 0x1904, 0x8402, 0x20a1, 0x020b, 0x080c,
+	0x7641, 0x20a3, 0x1300, 0x20a3, 0x0000, 0x7828, 0x2068, 0x681c,
+	0xa086, 0x0003, 0x0580, 0x7818, 0xa080, 0x0028, 0x2014, 0x2001,
+	0xb535, 0x2004, 0xd0ac, 0x11d0, 0xa286, 0x007e, 0x1128, 0x20a3,
+	0x00ff, 0x20a3, 0xfffe, 0x04b8, 0xa286, 0x007f, 0x1128, 0x20a3,
+	0x00ff, 0x20a3, 0xfffd, 0x0478, 0xd2bc, 0x0180, 0xa286, 0x0080,
+	0x1128, 0x20a3, 0x00ff, 0x20a3, 0xfffc, 0x0428, 0xa2e8, 0xb635,
+	0x2d6c, 0x6810, 0x20a2, 0x6814, 0x20a2, 0x00e8, 0x20a3, 0x0000,
+	0x6098, 0x20a2, 0x00c0, 0x2001, 0xb535, 0x2004, 0xd0ac, 0x1138,
+	0x7818, 0xa080, 0x0028, 0x2004, 0xa082, 0x007e, 0x0240, 0x00d6,
+	0x2069, 0xb51c, 0x2da6, 0x8d68, 0x2da6, 0x00de, 0x0020, 0x20a3,
+	0x0000, 0x6034, 0x20a2, 0x7834, 0x20a2, 0x7838, 0x20a2, 0x20a3,
+	0x0000, 0x20a3, 0x0000, 0x60c3, 0x000c, 0x080c, 0x7d67, 0x001e,
+	0x00de, 0x0005, 0x7817, 0x0001, 0x7803, 0x0006, 0x001e, 0x00de,
+	0x0005, 0x00d6, 0x0026, 0x7928, 0x2168, 0x691c, 0xa186, 0x0006,
+	0x01c0, 0xa186, 0x0003, 0x0904, 0x8478, 0xa186, 0x0005, 0x0904,
+	0x8461, 0xa186, 0x0004, 0x05b8, 0xa186, 0x0008, 0x0904, 0x8469,
+	0x7807, 0x0037, 0x7813, 0x1700, 0x080c, 0x84e0, 0x002e, 0x00de,
+	0x0005, 0x080c, 0x849c, 0x2009, 0x4000, 0x6800, 0x0002, 0x8442,
+	0x844d, 0x8444, 0x844d, 0x8449, 0x8442, 0x8442, 0x844d, 0x844d,
+	0x844d, 0x844d, 0x8442, 0x8442, 0x8442, 0x8442, 0x8442, 0x844d,
+	0x8442, 0x844d, 0x080c, 0x1515, 0x6820, 0xd0e4, 0x0110, 0xd0cc,
+	0x0110, 0xa00e, 0x0010, 0x2009, 0x2000, 0x6828, 0x20a2, 0x682c,
+	0x20a2, 0x0804, 0x8492, 0x080c, 0x849c, 0x20a3, 0x0000, 0x20a3,
+	0x0000, 0x2009, 0x4000, 0x6a00, 0xa286, 0x0002, 0x1108, 0xa00e,
+	0x0488, 0x04d1, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x2009, 0x4000,
+	0x0448, 0x0491, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x2009, 0x4000,
+	0xa286, 0x0005, 0x0118, 0xa286, 0x0002, 0x1108, 0xa00e, 0x00d0,
+	0x0419, 0x6810, 0x2068, 0x697c, 0x6810, 0xa112, 0x6980, 0x6814,
+	0xa103, 0x20a2, 0x22a2, 0x7928, 0xa180, 0x0000, 0x2004, 0xa08e,
+	0x0002, 0x0130, 0xa08e, 0x0004, 0x0118, 0x2009, 0x4000, 0x0010,
+	0x2009, 0x0000, 0x21a2, 0x20a3, 0x0000, 0x60c3, 0x0018, 0x080c,
+	0x7d67, 0x002e, 0x00de, 0x0005, 0x0036, 0x0046, 0x0056, 0x0066,
+	0x20a1, 0x020b, 0x080c, 0x76dd, 0xa006, 0x20a3, 0x0200, 0x20a2,
+	0x7934, 0x21a2, 0x7938, 0x21a2, 0x7818, 0xa080, 0x0028, 0x2004,
+	0x2011, 0xb535, 0x2214, 0xd2ac, 0x1118, 0xa092, 0x007e, 0x0268,
+	0x00d6, 0x2069, 0xb51c, 0x2d2c, 0x8d68, 0x2d34, 0xa0e8, 0xb635,
+	0x2d6c, 0x6b10, 0x6c14, 0x00de, 0x0030, 0x2019, 0x0000, 0x6498,
+	0x2029, 0x0000, 0x6634, 0x7828, 0xa080, 0x0007, 0x2004, 0xa086,
+	0x0003, 0x1128, 0x25a2, 0x26a2, 0x23a2, 0x24a2, 0x0020, 0x23a2,
+	0x24a2, 0x25a2, 0x26a2, 0x006e, 0x005e, 0x004e, 0x003e, 0x0005,
+	0x20a1, 0x020b, 0x080c, 0x76dd, 0x20a3, 0x0100, 0x20a3, 0x0000,
+	0x20a3, 0x0009, 0x7810, 0x20a2, 0x60c3, 0x0008, 0x080c, 0x7d67,
+	0x0005, 0x20a1, 0x020b, 0x080c, 0x7639, 0x20a3, 0x1400, 0x20a3,
+	0x0000, 0x7834, 0x20a2, 0x7838, 0x20a2, 0x7828, 0x20a2, 0x782c,
+	0x20a2, 0x7830, 0xa084, 0x00ff, 0x8007, 0x20a2, 0x20a3, 0x0000,
+	0x60c3, 0x0010, 0x080c, 0x7d67, 0x0005, 0x20a1, 0x020b, 0x080c,
+	0x76d5, 0x20a3, 0x0100, 0x20a3, 0x0000, 0x7828, 0x20a2, 0x7810,
+	0x20a2, 0x60c3, 0x0008, 0x080c, 0x7d67, 0x0005, 0x0146, 0x20a1,
+	0x020b, 0x0031, 0x60c3, 0x0000, 0x080c, 0x7d67, 0x014e, 0x0005,
+	0x20e1, 0x9080, 0x20e1, 0x4000, 0x7818, 0xa080, 0x0028, 0x2004,
+	0x2011, 0xb535, 0x2214, 0xd2ac, 0x1110, 0xd0bc, 0x0188, 0x00d6,
+	0xa0e8, 0xb635, 0x2d6c, 0x6810, 0xa085, 0x0300, 0x20a2, 0x6814,
+	0x20a2, 0x2069, 0xb51c, 0x2da6, 0x8d68, 0x2da6, 0x00de, 0x0078,
+	0x00d6, 0xa0e8, 0xb635, 0x2d6c, 0x6810, 0xa085, 0x0300, 0x20a2,
+	0x6814, 0x20a2, 0x00de, 0x20a3, 0x0000, 0x6234, 0x22a2, 0x20a3,
+	0x0819, 0x20a3, 0x0000, 0x080c, 0x7d56, 0x22a2, 0x20a3, 0x0000,
+	0x2fa2, 0x7a08, 0x22a2, 0x20a3, 0x0000, 0x20a3, 0x0000, 0x0005,
+	0x20a1, 0x020b, 0x0079, 0x7910, 0x21a2, 0x20a3, 0x0000, 0x60c3,
+	0x0000, 0x20e1, 0x9080, 0x60a7, 0x9575, 0x080c, 0x7d71, 0x080c,
+	0x6a07, 0x0005, 0x0156, 0x0136, 0x0036, 0x00d6, 0x00e6, 0x20e1,
+	0x9080, 0x20e1, 0x4000, 0x7854, 0x2068, 0xadf0, 0x000f, 0x7210,
+	0xa296, 0x00c0, 0xa294, 0xfffd, 0x7212, 0x7214, 0xa294, 0x0300,
+	0x7216, 0x7100, 0xa194, 0x00ff, 0x7308, 0xa384, 0x00ff, 0xa08d,
+	0xc200, 0x7102, 0xa384, 0xff00, 0xa215, 0x720a, 0x7004, 0x720c,
+	0x700e, 0x7206, 0x20a9, 0x000a, 0x2e98, 0x53a6, 0x60a3, 0x0035,
+	0x6a38, 0xa294, 0x7000, 0xa286, 0x3000, 0x0110, 0x60a3, 0x0037,
+	0x00ee, 0x00de, 0x003e, 0x013e, 0x015e, 0x0005, 0x2009, 0x0092,
+	0x0010, 0x2009, 0x0096, 0x60ab, 0x0036, 0x6116, 0x0005, 0x2061,
+	0xbd00, 0x2a70, 0x7068, 0x704a, 0x704f, 0xbd00, 0x0005, 0x00e6,
+	0x0126, 0x2071, 0xb500, 0x2091, 0x8000, 0x7548, 0xa582, 0x0010,
+	0x0608, 0x704c, 0x2060, 0x6000, 0xa086, 0x0000, 0x0148, 0xace0,
+	0x0018, 0x705c, 0xac02, 0x1208, 0x0cb0, 0x2061, 0xbd00, 0x0c98,
+	0x6003, 0x0008, 0x8529, 0x754a, 0xaca8, 0x0018, 0x705c, 0xa502,
+	0x1230, 0x754e, 0xa085, 0x0001, 0x012e, 0x00ee, 0x0005, 0x704f,
+	0xbd00, 0x0cc0, 0xa006, 0x0cc0, 0x00e6, 0x2071, 0xb500, 0x7548,
+	0xa582, 0x0010, 0x0600, 0x704c, 0x2060, 0x6000, 0xa086, 0x0000,
+	0x0148, 0xace0, 0x0018, 0x705c, 0xac02, 0x1208, 0x0cb0, 0x2061,
+	0xbd00, 0x0c98, 0x6003, 0x0008, 0x8529, 0x754a, 0xaca8, 0x0018,
+	0x705c, 0xa502, 0x1228, 0x754e, 0xa085, 0x0001, 0x00ee, 0x0005,
+	0x704f, 0xbd00, 0x0cc8, 0xa006, 0x0cc8, 0xac82, 0xbd00, 0x0a0c,
+	0x1515, 0x2001, 0xb517, 0x2004, 0xac02, 0x1a0c, 0x1515, 0xa006,
+	0x6006, 0x600a, 0x600e, 0x6012, 0x6016, 0x601a, 0x601f, 0x0000,
+	0x6003, 0x0000, 0x6052, 0x6056, 0x6022, 0x6026, 0x602a, 0x602e,
+	0x6032, 0x6036, 0x603a, 0x603e, 0x2061, 0xb500, 0x6048, 0x8000,
+	0x604a, 0xa086, 0x0001, 0x0108, 0x0005, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x7173, 0x012e, 0x0cc0, 0x601c, 0xa084, 0x000f, 0x0002,
+	0x865b, 0x866a, 0x8685, 0x86a0, 0xa152, 0xa16d, 0xa188, 0x865b,
+	0x866a, 0x865b, 0x86bb, 0xa186, 0x0013, 0x1128, 0x080c, 0x7090,
+	0x080c, 0x7173, 0x0005, 0xa18e, 0x0047, 0x1118, 0xa016, 0x080c,
+	0x185e, 0x0005, 0x0066, 0x6000, 0xa0b2, 0x0010, 0x1a0c, 0x1515,
+	0x0013, 0x006e, 0x0005, 0x8683, 0x8a9b, 0x8c53, 0x8683, 0x8cc8,
+	0x8779, 0x8683, 0x8683, 0x8a2d, 0x90ef, 0x8683, 0x8683, 0x8683,
+	0x8683, 0x8683, 0x8683, 0x080c, 0x1515, 0x0066, 0x6000, 0xa0b2,
+	0x0010, 0x1a0c, 0x1515, 0x0013, 0x006e, 0x0005, 0x869e, 0x9722,
+	0x869e, 0x869e, 0x869e, 0x869e, 0x869e, 0x869e, 0x96cd, 0x988e,
+	0x869e, 0x974f, 0x97c6, 0x974f, 0x97c6, 0x869e, 0x080c, 0x1515,
+	0x0066, 0x6000, 0xa0b2, 0x0010, 0x1a0c, 0x1515, 0x0013, 0x006e,
+	0x0005, 0x86b9, 0x9130, 0x91fa, 0x9335, 0x9491, 0x86b9, 0x86b9,
+	0x86b9, 0x910a, 0x967d, 0x9680, 0x86b9, 0x86b9, 0x86b9, 0x86b9,
+	0x96aa, 0x080c, 0x1515, 0x0066, 0x6000, 0xa0b2, 0x0010, 0x1a0c,
+	0x1515, 0x0013, 0x006e, 0x0005, 0x86d4, 0x86d4, 0x86d4, 0x8702,
+	0x874f, 0x86d4, 0x86d4, 0x86d4, 0x86d6, 0x86d4, 0x86d4, 0x86d4,
+	0x86d4, 0x86d4, 0x86d4, 0x86d4, 0x080c, 0x1515, 0xa186, 0x0003,
+	0x190c, 0x1515, 0x00d6, 0x6003, 0x0003, 0x6106, 0x6010, 0x2068,
+	0x684f, 0x0040, 0x687c, 0x680a, 0x6880, 0x680e, 0x6813, 0x0000,
+	0x6817, 0x0000, 0x6854, 0xa092, 0x199a, 0x0210, 0x2001, 0x1999,
+	0x8003, 0x8013, 0x8213, 0xa210, 0x6216, 0x00de, 0x2c10, 0x080c,
+	0x1fa9, 0x080c, 0x6cf0, 0x0126, 0x2091, 0x8000, 0x080c, 0x7230,
+	0x012e, 0x0005, 0xa182, 0x0047, 0x0002, 0x870e, 0x870e, 0x8710,
+	0x8729, 0x870e, 0x870e, 0x870e, 0x870e, 0x873b, 0x080c, 0x1515,
+	0x00d6, 0x0016, 0x080c, 0x7126, 0x080c, 0x7230, 0x6003, 0x0004,
+	0x6110, 0x2168, 0x684f, 0x0020, 0x685c, 0x685a, 0x6874, 0x687e,
+	0x6878, 0x6882, 0x6897, 0x0000, 0x689b, 0x0000, 0x001e, 0x00de,
+	0x0005, 0x080c, 0x7126, 0x00d6, 0x6110, 0x2168, 0x080c, 0x9c5a,
+	0x0120, 0x684b, 0x0006, 0x080c, 0x5408, 0x00de, 0x080c, 0x861d,
+	0x080c, 0x7230, 0x0005, 0x080c, 0x7126, 0x080c, 0x2c9c, 0x00d6,
+	0x6110, 0x2168, 0x080c, 0x9c5a, 0x0120, 0x684b, 0x0029, 0x080c,
+	0x5408, 0x00de, 0x080c, 0x861d, 0x080c, 0x7230, 0x0005, 0xa182,
+	0x0047, 0x0002, 0x875d, 0x876c, 0x875b, 0x875b, 0x875b, 0x875b,
+	0x875b, 0x875b, 0x875b, 0x080c, 0x1515, 0x00d6, 0x6010, 0x2068,
+	0x684c, 0xc0f4, 0x684e, 0x00de, 0x20e1, 0x0005, 0x3d18, 0x3e20,
+	0x2c10, 0x080c, 0x185e, 0x0005, 0x00d6, 0x6110, 0x2168, 0x684b,
+	0x0000, 0x6853, 0x0000, 0x080c, 0x5408, 0x00de, 0x080c, 0x861d,
+	0x0005, 0xa1b6, 0x0015, 0x1118, 0x080c, 0x861d, 0x0030, 0xa1b6,
+	0x0016, 0x190c, 0x1515, 0x080c, 0x861d, 0x0005, 0x20a9, 0x000e,
+	0x2e98, 0x6010, 0x20a0, 0x53a3, 0x20a9, 0x0006, 0x3310, 0x3420,
+	0x9398, 0x94a0, 0x3318, 0x3428, 0x222e, 0x2326, 0xa290, 0x0002,
+	0xa5a8, 0x0002, 0xa398, 0x0002, 0xa4a0, 0x0002, 0x1f04, 0x8794,
+	0x00e6, 0x080c, 0x9c5a, 0x0130, 0x6010, 0x2070, 0x7007, 0x0000,
+	0x7037, 0x0103, 0x00ee, 0x080c, 0x861d, 0x0005, 0x00d6, 0x0036,
+	0x7330, 0xa386, 0x0200, 0x1130, 0x6018, 0x2068, 0x6813, 0x00ff,
+	0x6817, 0xfffd, 0x6010, 0xa005, 0x0130, 0x2068, 0x6807, 0x0000,
+	0x6837, 0x0103, 0x6b32, 0x080c, 0x861d, 0x003e, 0x00de, 0x0005,
+	0x0016, 0x20a9, 0x002a, 0xae80, 0x000c, 0x2098, 0x6010, 0xa080,
+	0x0002, 0x20a0, 0x53a3, 0x20a9, 0x002a, 0x6010, 0xa080, 0x0001,
+	0x2004, 0xa080, 0x0002, 0x20a0, 0x53a3, 0x00e6, 0x6010, 0x2004,
+	0x2070, 0x7037, 0x0103, 0x00ee, 0x080c, 0x861d, 0x001e, 0x0005,
+	0x0016, 0x2009, 0x0000, 0x7030, 0xa086, 0x0100, 0x0140, 0x7038,
+	0xa084, 0x00ff, 0x800c, 0x703c, 0xa084, 0x00ff, 0x8004, 0xa080,
+	0x0004, 0xa108, 0x21a8, 0xae80, 0x000c, 0x2098, 0x6010, 0xa080,
+	0x0002, 0x20a0, 0x080c, 0x4b8f, 0x00e6, 0x080c, 0x9c5a, 0x0140,
+	0x6010, 0x2070, 0x7007, 0x0000, 0x7034, 0x70b2, 0x7037, 0x0103,
+	0x00ee, 0x080c, 0x861d, 0x001e, 0x0005, 0x00e6, 0x00d6, 0x603f,
+	0x0000, 0x2c68, 0x0016, 0x2009, 0x0035, 0x080c, 0xa10a, 0x001e,
+	0x1168, 0x0026, 0x6228, 0x2268, 0x002e, 0x2071, 0xbb8c, 0x6b1c,
+	0xa386, 0x0003, 0x0130, 0xa386, 0x0006, 0x0128, 0x080c, 0x861d,
+	0x0020, 0x0031, 0x0010, 0x080c, 0x88f6, 0x00de, 0x00ee, 0x0005,
+	0x00f6, 0x6810, 0x2078, 0xa186, 0x0015, 0x0904, 0x88dd, 0xa18e,
+	0x0016, 0x1904, 0x88f4, 0x700c, 0xa08c, 0xff00, 0xa186, 0x1700,
+	0x0120, 0xa186, 0x0300, 0x1904, 0x88bc, 0x8fff, 0x1138, 0x6800,
+	0xa086, 0x000f, 0x0904, 0x88a0, 0x0804, 0x88f2, 0x6808, 0xa086,
+	0xffff, 0x1904, 0x88df, 0x784c, 0xa084, 0x0060, 0xa086, 0x0020,
+	0x1150, 0x797c, 0x7810, 0xa106, 0x1904, 0x88df, 0x7980, 0x7814,
+	0xa106, 0x1904, 0x88df, 0x080c, 0x9e11, 0x6858, 0x7852, 0x784c,
+	0xc0dc, 0xc0f4, 0xc0d4, 0x784e, 0x0026, 0xa00e, 0x6a14, 0x2001,
+	0x000a, 0x080c, 0x6b40, 0x7854, 0xa20a, 0x0208, 0x8011, 0x7a56,
+	0x82ff, 0x002e, 0x1138, 0x00c6, 0x2d60, 0x080c, 0x9a09, 0x00ce,
+	0x0804, 0x88f2, 0x00c6, 0x00d6, 0x2f68, 0x6838, 0xd0fc, 0x1118,
+	0x080c, 0x4c64, 0x0010, 0x080c, 0x4e49, 0x00de, 0x00ce, 0x1904,
+	0x88df, 0x00c6, 0x2d60, 0x080c, 0x861d, 0x00ce, 0x0804, 0x88f2,
+	0x00c6, 0x080c, 0x9ed6, 0x0190, 0x6013, 0x0000, 0x6818, 0x601a,
+	0x080c, 0xa027, 0x601f, 0x0003, 0x6904, 0x00c6, 0x2d60, 0x080c,
+	0x861d, 0x00ce, 0x080c, 0x864c, 0x00ce, 0x04e0, 0x2001, 0xb7b8,
+	0x2004, 0x683e, 0x00ce, 0x04b0, 0x7008, 0xa086, 0x000b, 0x11a0,
+	0x6018, 0x200c, 0xc1bc, 0x2102, 0x00c6, 0x2d60, 0x7853, 0x0003,
+	0x6007, 0x0085, 0x6003, 0x000b, 0x601f, 0x0002, 0x080c, 0x6c8d,
+	0x080c, 0x7173, 0x00ce, 0x00f0, 0x700c, 0xa086, 0x2a00, 0x1138,
+	0x2001, 0xb7b8, 0x2004, 0x683e, 0x00a8, 0x0481, 0x00a8, 0x8fff,
+	0x090c, 0x1515, 0x00c6, 0x00d6, 0x2d60, 0x2f68, 0x6837, 0x0103,
+	0x684b, 0x0003, 0x080c, 0x98fd, 0x080c, 0x9e11, 0x080c, 0x9e1d,
+	0x00de, 0x00ce, 0x080c, 0x861d, 0x00fe, 0x0005, 0xa186, 0x0015,
+	0x1128, 0x2001, 0xb7b8, 0x2004, 0x683e, 0x0068, 0xa18e, 0x0016,
+	0x1160, 0x00c6, 0x2d00, 0x2060, 0x080c, 0xb33a, 0x080c, 0x6aef,
+	0x080c, 0x861d, 0x00ce, 0x080c, 0x861d, 0x0005, 0x0026, 0x0036,
+	0x0046, 0x7228, 0x7c80, 0x7b7c, 0xd2f4, 0x0130, 0x2001, 0xb7b8,
+	0x2004, 0x683e, 0x0804, 0x8970, 0x00c6, 0x2d60, 0x080c, 0x991d,
+	0x00ce, 0x6804, 0xa086, 0x0050, 0x1168, 0x00c6, 0x2d00, 0x2060,
+	0x6003, 0x0001, 0x6007, 0x0050, 0x080c, 0x6c8d, 0x080c, 0x7173,
+	0x00ce, 0x04f0, 0x6800, 0xa086, 0x000f, 0x01c8, 0x8fff, 0x090c,
+	0x1515, 0x6820, 0xd0dc, 0x1198, 0x6800, 0xa086, 0x0004, 0x1198,
+	0x784c, 0xd0ac, 0x0180, 0x784c, 0xc0dc, 0xc0f4, 0x784e, 0x7850,
+	0xc0f4, 0xc0fc, 0x7852, 0x2001, 0x0001, 0x682e, 0x00e0, 0x2001,
+	0x0007, 0x682e, 0x00c0, 0x784c, 0xd0b4, 0x1130, 0xd0ac, 0x0db8,
+	0x784c, 0xd0f4, 0x1da0, 0x0c38, 0xd2ec, 0x1d88, 0x7024, 0xa306,
+	0x1118, 0x7020, 0xa406, 0x0d58, 0x7020, 0x6836, 0x7024, 0x683a,
+	0x2001, 0x0005, 0x682e, 0x080c, 0x9f63, 0x080c, 0x7173, 0x0010,
+	0x080c, 0x861d, 0x004e, 0x003e, 0x002e, 0x0005, 0x00e6, 0x00d6,
+	0x0026, 0x6034, 0x2068, 0x6a1c, 0xa286, 0x0007, 0x0904, 0x89d4,
+	0xa286, 0x0002, 0x0904, 0x89d4, 0xa286, 0x0000, 0x0904, 0x89d4,
+	0x6808, 0x6338, 0xa306, 0x1904, 0x89d4, 0x2071, 0xbb8c, 0xa186,
+	0x0015, 0x05e0, 0xa18e, 0x0016, 0x1190, 0x6030, 0xa084, 0x00ff,
+	0xa086, 0x0001, 0x1160, 0x700c, 0xa086, 0x2a00, 0x1140, 0x6034,
+	0xa080, 0x0008, 0x200c, 0xc1dd, 0xc1f5, 0x2102, 0x0438, 0x00c6,
+	0x6034, 0x2060, 0x6104, 0xa186, 0x004b, 0x01a0, 0xa186, 0x004c,
+	0x0188, 0xa186, 0x004d, 0x0170, 0xa186, 0x004e, 0x0158, 0xa186,
+	0x0052, 0x0140, 0x6010, 0x2068, 0x080c, 0x9c5a, 0x090c, 0x1515,
+	0x6853, 0x0003, 0x6007, 0x0085, 0x6003, 0x000b, 0x601f, 0x0002,
+	0x080c, 0x6c8d, 0x080c, 0x7173, 0x00ce, 0x0030, 0x6034, 0x2070,
+	0x2001, 0xb7b8, 0x2004, 0x703e, 0x080c, 0x861d, 0x002e, 0x00de,
+	0x00ee, 0x0005, 0x00d6, 0x20a9, 0x000e, 0x2e98, 0x6010, 0x20a0,
+	0x53a3, 0xa1b6, 0x0015, 0x1558, 0x6018, 0x2068, 0x0156, 0x0036,
+	0x0026, 0xae90, 0x000c, 0xa290, 0x0004, 0x20a9, 0x0004, 0xad98,
+	0x000a, 0x080c, 0x90da, 0x002e, 0x003e, 0x015e, 0x11d8, 0x0156,
+	0x0036, 0x0026, 0xae90, 0x000c, 0xa290, 0x0008, 0x20a9, 0x0004,
+	0xad98, 0x0006, 0x080c, 0x90da, 0x002e, 0x003e, 0x015e, 0x1150,
+	0x7038, 0x680a, 0x703c, 0x680e, 0x6800, 0xc08d, 0x6802, 0x00de,
+	0x0804, 0x87a0, 0x080c, 0x2c9c, 0x00c6, 0x080c, 0x85c7, 0x2f00,
+	0x601a, 0x6013, 0x0000, 0x601f, 0x0001, 0x6007, 0x0001, 0x6003,
+	0x0001, 0x2001, 0x0007, 0x080c, 0x4efd, 0x080c, 0x4f2a, 0x080c,
+	0x6cd3, 0x080c, 0x7173, 0x00ce, 0x0c10, 0x2100, 0xa1b2, 0x0080,
+	0x1a0c, 0x1515, 0xa1b2, 0x0040, 0x1a04, 0x8a91, 0x0002, 0x8a85,
+	0x8a79, 0x8a85, 0x8a85, 0x8a85, 0x8a85, 0x8a77, 0x8a77, 0x8a77,
+	0x8a77, 0x8a77, 0x8a77, 0x8a77, 0x8a77, 0x8a77, 0x8a77, 0x8a77,
+	0x8a77, 0x8a77, 0x8a77, 0x8a77, 0x8a77, 0x8a77, 0x8a77, 0x8a77,
+	0x8a77, 0x8a77, 0x8a77, 0x8a77, 0x8a77, 0x8a77, 0x8a85, 0x8a77,
+	0x8a85, 0x8a85, 0x8a77, 0x8a77, 0x8a77, 0x8a77, 0x8a77, 0x8a85,
+	0x8a77, 0x8a77, 0x8a77, 0x8a77, 0x8a77, 0x8a77, 0x8a77, 0x8a77,
+	0x8a77, 0x8a85, 0x8a85, 0x8a77, 0x8a77, 0x8a77, 0x8a77, 0x8a77,
+	0x8a77, 0x8a77, 0x8a77, 0x8a77, 0x8a85, 0x8a77, 0x8a77, 0x080c,
+	0x1515, 0x6003, 0x0001, 0x6106, 0x080c, 0x6cd3, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x7173, 0x012e, 0x0005, 0x6003, 0x0001, 0x6106,
+	0x080c, 0x6cd3, 0x0126, 0x2091, 0x8000, 0x080c, 0x7173, 0x012e,
+	0x0005, 0x2600, 0x0002, 0x8a85, 0x8a85, 0x8a99, 0x8a85, 0x8a85,
+	0x8a99, 0x080c, 0x1515, 0x6004, 0xa0b2, 0x0080, 0x1a0c, 0x1515,
+	0xa1b6, 0x0013, 0x0904, 0x8b4b, 0xa1b6, 0x0027, 0x1904, 0x8b11,
+	0x080c, 0x7090, 0x6004, 0x080c, 0x9e47, 0x0190, 0x080c, 0x9e58,
+	0x0904, 0x8b0b, 0xa08e, 0x0021, 0x0904, 0x8b0e, 0xa08e, 0x0022,
+	0x0904, 0x8b0b, 0xa08e, 0x003d, 0x0904, 0x8b0e, 0x0804, 0x8b04,
+	0x080c, 0x2cc2, 0x2001, 0x0007, 0x080c, 0x4efd, 0x6018, 0xa080,
+	0x0028, 0x200c, 0x080c, 0x8c19, 0xa186, 0x007e, 0x1148, 0x2001,
+	0xb535, 0x2014, 0xc285, 0x080c, 0x5acf, 0x1108, 0xc2ad, 0x2202,
+	0x0016, 0x0026, 0x0036, 0x2110, 0x0026, 0x2019, 0x0028, 0x080c,
+	0x8299, 0x002e, 0x080c, 0xb38d, 0x003e, 0x002e, 0x001e, 0x0016,
+	0x0026, 0x0036, 0x2110, 0x2019, 0x0028, 0x080c, 0x6df5, 0x0076,
+	0x2039, 0x0000, 0x080c, 0x6d02, 0x00c6, 0x6018, 0xa065, 0x0110,
+	0x080c, 0x51aa, 0x00ce, 0x2c08, 0x080c, 0xae82, 0x007e, 0x003e,
+	0x002e, 0x001e, 0x080c, 0x4f6c, 0x080c, 0xa01f, 0x080c, 0x861d,
+	0x080c, 0x7173, 0x0005, 0x080c, 0x8c19, 0x0cb0, 0x080c, 0x8c47,
+	0x0c98, 0xa186, 0x0014, 0x1db0, 0x080c, 0x7090, 0x080c, 0x2c9c,
+	0x080c, 0x9e47, 0x1188, 0x080c, 0x2cc2, 0x6018, 0xa080, 0x0028,
+	0x200c, 0x080c, 0x8c19, 0xa186, 0x007e, 0x1128, 0x2001, 0xb535,
+	0x200c, 0xc185, 0x2102, 0x08c0, 0x080c, 0x9e58, 0x1118, 0x080c,
+	0x8c19, 0x0890, 0x6004, 0xa08e, 0x0032, 0x1158, 0x00e6, 0x00f6,
+	0x2071, 0xb582, 0x2079, 0x0000, 0x080c, 0x2fcf, 0x00fe, 0x00ee,
+	0x0818, 0x6004, 0xa08e, 0x0021, 0x0d50, 0xa08e, 0x0022, 0x090c,
+	0x8c19, 0x0804, 0x8b04, 0xa0b2, 0x0040, 0x1a04, 0x8c0e, 0x2008,
+	0x0002, 0x8b93, 0x8b94, 0x8b97, 0x8b9a, 0x8b9d, 0x8ba0, 0x8b91,
+	0x8b91, 0x8b91, 0x8b91, 0x8b91, 0x8b91, 0x8b91, 0x8b91, 0x8b91,
+	0x8b91, 0x8b91, 0x8b91, 0x8b91, 0x8b91, 0x8b91, 0x8b91, 0x8b91,
+	0x8b91, 0x8b91, 0x8b91, 0x8b91, 0x8b91, 0x8b91, 0x8b91, 0x8ba3,
+	0x8bb2, 0x8b91, 0x8bb4, 0x8bb2, 0x8b91, 0x8b91, 0x8b91, 0x8b91,
+	0x8b91, 0x8bb2, 0x8bb2, 0x8b91, 0x8b91, 0x8b91, 0x8b91, 0x8b91,
+	0x8b91, 0x8b91, 0x8b91, 0x8bee, 0x8bb2, 0x8b91, 0x8bae, 0x8b91,
+	0x8b91, 0x8b91, 0x8baf, 0x8b91, 0x8b91, 0x8b91, 0x8bb2, 0x8be5,
+	0x8b91, 0x080c, 0x1515, 0x00f0, 0x2001, 0x000b, 0x0460, 0x2001,
+	0x0003, 0x0448, 0x2001, 0x0005, 0x0430, 0x2001, 0x0001, 0x0418,
+	0x2001, 0x0009, 0x0400, 0x080c, 0x7090, 0x6003, 0x0005, 0x2001,
+	0xb7b8, 0x2004, 0x603e, 0x080c, 0x7173, 0x00a0, 0x0018, 0x0010,
+	0x080c, 0x4efd, 0x0804, 0x8bff, 0x080c, 0x7090, 0x2001, 0xb7b6,
+	0x2004, 0x6016, 0x2001, 0xb7b8, 0x2004, 0x603e, 0x6003, 0x0004,
+	0x080c, 0x7173, 0x0005, 0x080c, 0x4efd, 0x080c, 0x7090, 0x6003,
+	0x0002, 0x2001, 0xb7b8, 0x2004, 0x603e, 0x0036, 0x2019, 0xb55d,
+	0x2304, 0xa084, 0xff00, 0x1120, 0x2001, 0xb7b6, 0x201c, 0x0040,
+	0x8007, 0xa09a, 0x0004, 0x0ec0, 0x8003, 0x801b, 0x831b, 0xa318,
+	0x6316, 0x003e, 0x080c, 0x7173, 0x08e8, 0x080c, 0x7090, 0x080c,
+	0xa01f, 0x080c, 0x861d, 0x080c, 0x7173, 0x08a0, 0x00e6, 0x00f6,
+	0x2071, 0xb582, 0x2079, 0x0000, 0x080c, 0x2fcf, 0x00fe, 0x00ee,
+	0x080c, 0x7090, 0x080c, 0x861d, 0x080c, 0x7173, 0x0818, 0x080c,
+	0x7090, 0x2001, 0xb7b8, 0x2004, 0x603e, 0x6003, 0x0002, 0x2001,
+	0xb7b6, 0x2004, 0x6016, 0x080c, 0x7173, 0x0005, 0x2600, 0x2008,
+	0x0002, 0x8c17, 0x8c17, 0x8c17, 0x8bff, 0x8bff, 0x8c17, 0x080c,
+	0x1515, 0x00e6, 0x0026, 0x0016, 0x080c, 0x9c5a, 0x0508, 0x6010,
+	0x2070, 0x7034, 0xa086, 0x0139, 0x1148, 0x2001, 0x0030, 0x2009,
+	0x0000, 0x2011, 0x4005, 0x080c, 0xa0d6, 0x0090, 0x7038, 0xd0fc,
+	0x0178, 0x7007, 0x0000, 0x0016, 0x6004, 0xa08e, 0x0021, 0x0160,
+	0xa08e, 0x003d, 0x0148, 0x001e, 0x7037, 0x0103, 0x7033, 0x0100,
+	0x001e, 0x002e, 0x00ee, 0x0005, 0x001e, 0x0009, 0x0cc8, 0x00e6,
+	0xacf0, 0x0004, 0x2e74, 0x7000, 0x2070, 0x7037, 0x0103, 0x7023,
+	0x8001, 0x00ee, 0x0005, 0x00d6, 0x6618, 0x2668, 0x6804, 0xa084,
+	0x00ff, 0x00de, 0xa0b2, 0x000c, 0x1a0c, 0x1515, 0x6604, 0xa6b6,
+	0x0043, 0x1120, 0x080c, 0xa092, 0x0804, 0x8cb8, 0x6604, 0xa6b6,
+	0x0033, 0x1120, 0x080c, 0xa042, 0x0804, 0x8cb8, 0x6604, 0xa6b6,
+	0x0028, 0x1120, 0x080c, 0x9e88, 0x0804, 0x8cb8, 0x6604, 0xa6b6,
+	0x0029, 0x1118, 0x080c, 0x9e9f, 0x04d8, 0x6604, 0xa6b6, 0x001f,
+	0x1118, 0x080c, 0x8786, 0x04a0, 0x6604, 0xa6b6, 0x0000, 0x1118,
+	0x080c, 0x89da, 0x0468, 0x6604, 0xa6b6, 0x0022, 0x1118, 0x080c,
+	0x87ae, 0x0430, 0x6604, 0xa6b6, 0x0035, 0x1118, 0x080c, 0x8815,
+	0x00f8, 0x6604, 0xa6b6, 0x0039, 0x1118, 0x080c, 0x8976, 0x00c0,
+	0x6604, 0xa6b6, 0x003d, 0x1118, 0x080c, 0x87c8, 0x0088, 0x6604,
+	0xa6b6, 0x0044, 0x1118, 0x080c, 0x87e8, 0x0050, 0xa1b6, 0x0015,
+	0x1110, 0x0053, 0x0028, 0xa1b6, 0x0016, 0x1118, 0x0804, 0x8e7c,
+	0x0005, 0x080c, 0x8663, 0x0ce0, 0x8cdf, 0x8ce2, 0x8cdf, 0x8d24,
+	0x8cdf, 0x8e09, 0x8e8a, 0x8cdf, 0x8cdf, 0x8e58, 0x8cdf, 0x8e6c,
+	0xa1b6, 0x0048, 0x0140, 0x20e1, 0x0005, 0x3d18, 0x3e20, 0x2c10,
+	0x080c, 0x185e, 0x0005, 0x00e6, 0xacf0, 0x0004, 0x2e74, 0x7000,
+	0x2070, 0x7037, 0x0103, 0x00ee, 0x080c, 0x861d, 0x0005, 0xe000,
+	0xe000, 0x0005, 0x00e6, 0x2071, 0xb500, 0x7084, 0xa086, 0x0074,
+	0x1530, 0x080c, 0xae59, 0x11b0, 0x00d6, 0x6018, 0x2068, 0x7030,
+	0xd08c, 0x0128, 0x6800, 0xd0bc, 0x0110, 0xc0c5, 0x6802, 0x00d9,
+	0x00de, 0x2001, 0x0006, 0x080c, 0x4efd, 0x080c, 0x2cc2, 0x080c,
+	0x861d, 0x0078, 0x2001, 0x000a, 0x080c, 0x4efd, 0x080c, 0x2cc2,
+	0x6003, 0x0001, 0x6007, 0x0001, 0x080c, 0x6cd3, 0x0010, 0x080c,
+	0x8df6, 0x00ee, 0x0005, 0x6800, 0xd084, 0x0168, 0x2001, 0x0000,
+	0x080c, 0x4eeb, 0x2069, 0xb552, 0x6804, 0xd0a4, 0x0120, 0x2001,
+	0x0006, 0x080c, 0x4f2a, 0x0005, 0x00d6, 0x2011, 0xb521, 0x2204,
+	0xa086, 0x0074, 0x1904, 0x8df3, 0x6018, 0x2068, 0x6aa0, 0xa286,
+	0x007e, 0x1120, 0x080c, 0x8fa2, 0x0804, 0x8d92, 0x080c, 0x8f98,
+	0x6018, 0x2068, 0xa080, 0x0028, 0x2014, 0xa286, 0x0080, 0x11c0,
+	0x6813, 0x00ff, 0x6817, 0xfffc, 0x6010, 0xa005, 0x0138, 0x2068,
+	0x6807, 0x0000, 0x6837, 0x0103, 0x6833, 0x0200, 0x2001, 0x0006,
+	0x080c, 0x4efd, 0x080c, 0x2cc2, 0x080c, 0x861d, 0x0804, 0x8df4,
+	0x00e6, 0x2071, 0xb535, 0x2e04, 0xd09c, 0x0188, 0x2071, 0xbb80,
+	0x7108, 0x720c, 0xa18c, 0x00ff, 0x1118, 0xa284, 0xff00, 0x0138,
+	0x6018, 0x2070, 0x70a0, 0xd0bc, 0x1110, 0x7112, 0x7216, 0x00ee,
+	0x6010, 0xa005, 0x0198, 0x2068, 0x6838, 0xd0f4, 0x0178, 0x6834,
+	0xa084, 0x00ff, 0xa086, 0x0039, 0x1958, 0x2001, 0x0000, 0x2009,
+	0x0000, 0x2011, 0x4000, 0x080c, 0xa0d6, 0x0840, 0x2001, 0x0004,
+	0x080c, 0x4efd, 0x6003, 0x0001, 0x6007, 0x0003, 0x080c, 0x6cd3,
+	0x0804, 0x8df4, 0x685c, 0xd0e4, 0x01d8, 0x080c, 0x9fd2, 0x080c,
+	0x5acf, 0x0118, 0xd0dc, 0x1904, 0x8d4e, 0x2011, 0xb535, 0x2204,
+	0xc0ad, 0x2012, 0x2001, 0xb78f, 0x2004, 0x00f6, 0x2079, 0x0100,
+	0x78e3, 0x0000, 0x080c, 0x2872, 0x78e2, 0x00fe, 0x0804, 0x8d4e,
+	0x080c, 0xa008, 0x2011, 0xb535, 0x2204, 0xc0a5, 0x2012, 0x0006,
+	0x080c, 0xaf7b, 0x000e, 0x1904, 0x8d4e, 0xc0b5, 0x2012, 0x2001,
+	0x0006, 0x080c, 0x4efd, 0x2001, 0x0000, 0x080c, 0x4eeb, 0x00c6,
+	0x2009, 0x00ef, 0x00f6, 0x2079, 0x0100, 0x79ea, 0x7932, 0x7936,
+	0x00fe, 0x080c, 0x2847, 0x00f6, 0x2079, 0xb500, 0x7976, 0x2100,
+	0x2009, 0x0000, 0x080c, 0x281d, 0x7952, 0x00fe, 0x8108, 0x080c,
+	0x4f4d, 0x2c00, 0x00ce, 0x1904, 0x8d4e, 0x601a, 0x2001, 0x0002,
+	0x080c, 0x4efd, 0x601f, 0x0001, 0x6003, 0x0001, 0x6007, 0x0002,
+	0x080c, 0x6cd3, 0x0008, 0x0011, 0x00de, 0x0005, 0x2001, 0x0007,
+	0x080c, 0x4efd, 0x2001, 0xb500, 0x2004, 0xa086, 0x0003, 0x1120,
+	0x2001, 0x0007, 0x080c, 0x4f2a, 0x080c, 0x2cc2, 0x080c, 0x861d,
+	0x0005, 0x00e6, 0x0026, 0x0016, 0x2071, 0xb500, 0x7084, 0xa086,
+	0x0014, 0x15f0, 0x7000, 0xa086, 0x0003, 0x1128, 0x6010, 0xa005,
+	0x1110, 0x080c, 0x3f3e, 0x00d6, 0x6018, 0x2068, 0x080c, 0x504b,
+	0x080c, 0x8d13, 0x00de, 0x080c, 0x9051, 0x1550, 0x00d6, 0x6018,
+	0x2068, 0x6890, 0x00de, 0xa005, 0x0518, 0x2001, 0x0006, 0x080c,
+	0x4efd, 0x00e6, 0x6010, 0xa075, 0x01a8, 0x7034, 0xa084, 0x00ff,
+	0xa086, 0x0039, 0x1148, 0x2001, 0x0000, 0x2009, 0x0000, 0x2011,
+	0x4000, 0x080c, 0xa0d6, 0x0030, 0x7007, 0x0000, 0x7037, 0x0103,
+	0x7033, 0x0200, 0x00ee, 0x080c, 0x2cc2, 0x080c, 0x861d, 0x0020,
+	0x080c, 0x8c19, 0x080c, 0x8df6, 0x001e, 0x002e, 0x00ee, 0x0005,
+	0x2011, 0xb521, 0x2204, 0xa086, 0x0014, 0x1158, 0x2001, 0x0002,
+	0x080c, 0x4efd, 0x6003, 0x0001, 0x6007, 0x0001, 0x080c, 0x6cd3,
+	0x0010, 0x080c, 0x8df6, 0x0005, 0x2011, 0xb521, 0x2204, 0xa086,
+	0x0004, 0x1138, 0x2001, 0x0007, 0x080c, 0x4efd, 0x080c, 0x861d,
+	0x0010, 0x080c, 0x8df6, 0x0005, 0x000b, 0x0005, 0x8cdf, 0x8e95,
+	0x8cdf, 0x8ec9, 0x8cdf, 0x8f54, 0x8e8a, 0x8cdf, 0x8cdf, 0x8f67,
+	0x8cdf, 0x8f77, 0x6604, 0xa686, 0x0003, 0x0904, 0x8e09, 0xa6b6,
+	0x001e, 0x1110, 0x080c, 0x861d, 0x0005, 0x00d6, 0x00c6, 0x080c,
+	0x8f87, 0x1178, 0x2001, 0x0000, 0x080c, 0x4eeb, 0x2001, 0x0002,
+	0x080c, 0x4efd, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x6cd3,
+	0x00e8, 0x2009, 0xbb8e, 0x2104, 0xa086, 0x0009, 0x1160, 0x6018,
+	0x2068, 0x6840, 0xa084, 0x00ff, 0xa005, 0x0170, 0x8001, 0x6842,
+	0x6017, 0x000a, 0x0058, 0x2009, 0xbb8f, 0x2104, 0xa084, 0xff00,
+	0xa086, 0x1900, 0x1108, 0x08d0, 0x080c, 0x8df6, 0x00ce, 0x00de,
+	0x0005, 0x0026, 0x2011, 0x0000, 0x080c, 0x8f95, 0x00d6, 0x2069,
+	0xb79e, 0x2d04, 0xa005, 0x0168, 0x6018, 0x2068, 0x68a0, 0xa086,
+	0x007e, 0x1138, 0x2069, 0xb51d, 0x2d04, 0x8000, 0x206a, 0x00de,
+	0x0010, 0x00de, 0x0078, 0x2001, 0x0000, 0x080c, 0x4eeb, 0x2001,
+	0x0002, 0x080c, 0x4efd, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c,
+	0x6cd3, 0x0480, 0x00d6, 0x6010, 0x2068, 0x080c, 0x9c5a, 0x00de,
+	0x0108, 0x6a34, 0x080c, 0x8c19, 0x2009, 0xbb8e, 0x2134, 0xa6b4,
+	0x00ff, 0xa686, 0x0005, 0x0500, 0xa686, 0x000b, 0x01c8, 0x2009,
+	0xbb8f, 0x2104, 0xa084, 0xff00, 0x1118, 0xa686, 0x0009, 0x01a0,
+	0xa086, 0x1900, 0x1168, 0xa686, 0x0009, 0x0170, 0x2001, 0x0004,
+	0x080c, 0x4efd, 0x2001, 0x0028, 0x6016, 0x6007, 0x004b, 0x0010,
+	0x080c, 0x8df6, 0x002e, 0x0005, 0x00d6, 0xa286, 0x0139, 0x0160,
+	0x6010, 0x2068, 0x080c, 0x9c5a, 0x0148, 0x6834, 0xa086, 0x0139,
+	0x0118, 0x6838, 0xd0fc, 0x0110, 0x00de, 0x0c50, 0x6018, 0x2068,
+	0x6840, 0xa084, 0x00ff, 0xa005, 0x0140, 0x8001, 0x6842, 0x6017,
+	0x000a, 0x6007, 0x0016, 0x00de, 0x08e8, 0x68a0, 0xa086, 0x007e,
+	0x1138, 0x00e6, 0x2071, 0xb500, 0x080c, 0x4bc6, 0x00ee, 0x0010,
+	0x080c, 0x2c9c, 0x00de, 0x0860, 0x080c, 0x8f95, 0x1158, 0x2001,
+	0x0004, 0x080c, 0x4efd, 0x6003, 0x0001, 0x6007, 0x0003, 0x080c,
+	0x6cd3, 0x0020, 0x080c, 0x8c19, 0x080c, 0x8df6, 0x0005, 0x0469,
+	0x1158, 0x2001, 0x0008, 0x080c, 0x4efd, 0x6003, 0x0001, 0x6007,
+	0x0005, 0x080c, 0x6cd3, 0x0010, 0x080c, 0x8df6, 0x0005, 0x00e9,
+	0x1158, 0x2001, 0x000a, 0x080c, 0x4efd, 0x6003, 0x0001, 0x6007,
+	0x0001, 0x080c, 0x6cd3, 0x0010, 0x080c, 0x8df6, 0x0005, 0x2009,
+	0xbb8e, 0x2104, 0xa086, 0x0003, 0x1138, 0x2009, 0xbb8f, 0x2104,
+	0xa084, 0xff00, 0xa086, 0x2a00, 0x0005, 0xa085, 0x0001, 0x0005,
+	0x00c6, 0x0016, 0xac88, 0x0006, 0x2164, 0x080c, 0x4fb8, 0x001e,
+	0x00ce, 0x0005, 0x00f6, 0x00e6, 0x00d6, 0x0036, 0x0016, 0x6018,
+	0x2068, 0x2071, 0xb535, 0x2e04, 0xa085, 0x0003, 0x2072, 0x080c,
+	0x9026, 0x0560, 0x2009, 0xb535, 0x2104, 0xc0cd, 0x200a, 0x2001,
+	0xb553, 0x2004, 0xd0a4, 0x0158, 0xa006, 0x2020, 0x2009, 0x002a,
+	0x080c, 0xb0e8, 0x2001, 0xb50c, 0x200c, 0xc195, 0x2102, 0x2019,
+	0x002a, 0x2009, 0x0001, 0x080c, 0x2c6f, 0x2071, 0xb500, 0x080c,
+	0x2ab8, 0x00c6, 0x0156, 0x20a9, 0x0081, 0x2009, 0x007f, 0x080c,
+	0x2d97, 0x8108, 0x1f04, 0x8fd7, 0x015e, 0x00ce, 0x080c, 0x8f98,
+	0x6813, 0x00ff, 0x6817, 0xfffe, 0x2071, 0xbb80, 0x2079, 0x0100,
+	0x2e04, 0xa084, 0x00ff, 0x2069, 0xb51c, 0x206a, 0x78e6, 0x0006,
+	0x8e70, 0x2e04, 0x2069, 0xb51d, 0x206a, 0x78ea, 0x7832, 0x7836,
+	0x2010, 0xa084, 0xff00, 0x001e, 0xa105, 0x2009, 0xb528, 0x200a,
+	0x2200, 0xa084, 0x00ff, 0x2008, 0x080c, 0x2847, 0x080c, 0x5acf,
+	0x0170, 0x2069, 0xbb8e, 0x2071, 0xb7b2, 0x6810, 0x2072, 0x6814,
+	0x7006, 0x6818, 0x700a, 0x681c, 0x700e, 0x080c, 0x9fd2, 0x0040,
+	0x2001, 0x0006, 0x080c, 0x4efd, 0x080c, 0x2cc2, 0x080c, 0x861d,
+	0x001e, 0x003e, 0x00de, 0x00ee, 0x00fe, 0x0005, 0x0026, 0x0036,
+	0x00e6, 0x0156, 0x2019, 0xb528, 0x231c, 0x83ff, 0x01e8, 0x2071,
+	0xbb80, 0x2e14, 0xa294, 0x00ff, 0x7004, 0xa084, 0xff00, 0xa205,
+	0xa306, 0x1190, 0x2011, 0xbb96, 0xad98, 0x000a, 0x20a9, 0x0004,
+	0x080c, 0x90da, 0x1148, 0x2011, 0xbb9a, 0xad98, 0x0006, 0x20a9,
+	0x0004, 0x080c, 0x90da, 0x1100, 0x015e, 0x00ee, 0x003e, 0x002e,
+	0x0005, 0x00e6, 0x2071, 0xbb8c, 0x7004, 0xa086, 0x0014, 0x11a8,
+	0x7008, 0xa086, 0x0800, 0x1188, 0x700c, 0xd0ec, 0x0160, 0xa084,
+	0x0f00, 0xa086, 0x0100, 0x1138, 0x7024, 0xd0a4, 0x1110, 0xd0ac,
+	0x0110, 0xa006, 0x0010, 0xa085, 0x0001, 0x00ee, 0x0005, 0x00e6,
+	0x00d6, 0x00c6, 0x0076, 0x0056, 0x0046, 0x0026, 0x0006, 0x0126,
+	0x2091, 0x8000, 0x2029, 0xb7e9, 0x252c, 0x2021, 0xb7ef, 0x2424,
+	0x2061, 0xbd00, 0x2071, 0xb500, 0x7248, 0x7068, 0xa202, 0x16f0,
+	0x080c, 0xb110, 0x05a0, 0x671c, 0xa786, 0x0001, 0x0580, 0xa786,
+	0x0007, 0x0568, 0x2500, 0xac06, 0x0550, 0x2400, 0xac06, 0x0538,
+	0x00c6, 0x6000, 0xa086, 0x0004, 0x1110, 0x080c, 0x194d, 0xa786,
+	0x0008, 0x1148, 0x080c, 0x9e58, 0x1130, 0x00ce, 0x080c, 0x8c19,
+	0x080c, 0x9e1d, 0x00a0, 0x6010, 0x2068, 0x080c, 0x9c5a, 0x0160,
+	0xa786, 0x0003, 0x11e8, 0x6837, 0x0103, 0x6b4a, 0x6847, 0x0000,
+	0x080c, 0x5408, 0x080c, 0x9e11, 0x080c, 0x9e1d, 0x00ce, 0xace0,
+	0x0018, 0x705c, 0xac02, 0x1210, 0x0804, 0x9084, 0x012e, 0x000e,
+	0x002e, 0x004e, 0x005e, 0x007e, 0x00ce, 0x00de, 0x00ee, 0x0005,
+	0xa786, 0x0006, 0x1118, 0x080c, 0xb099, 0x0c30, 0xa786, 0x000a,
+	0x09e0, 0x08c8, 0x220c, 0x2304, 0xa106, 0x1130, 0x8210, 0x8318,
+	0x1f04, 0x90da, 0xa006, 0x0005, 0x2304, 0xa102, 0x0218, 0x2001,
+	0x0001, 0x0010, 0x2001, 0x0000, 0xa18d, 0x0001, 0x0005, 0x6004,
+	0xa08a, 0x0080, 0x1a0c, 0x1515, 0x080c, 0x9e47, 0x0120, 0x080c,
+	0x9e58, 0x0168, 0x0028, 0x080c, 0x2cc2, 0x080c, 0x9e58, 0x0138,
+	0x080c, 0x7090, 0x080c, 0x861d, 0x080c, 0x7173, 0x0005, 0x080c,
+	0x8c19, 0x0cb0, 0xa182, 0x0040, 0x0002, 0x9120, 0x9120, 0x9120,
+	0x9120, 0x9120, 0x9120, 0x9120, 0x9120, 0x9120, 0x9120, 0x9120,
+	0x9122, 0x9122, 0x9122, 0x9122, 0x9120, 0x9120, 0x9120, 0x9122,
+	0x080c, 0x1515, 0x600b, 0xffff, 0x6003, 0x0001, 0x6106, 0x080c,
+	0x6c8d, 0x0126, 0x2091, 0x8000, 0x080c, 0x7173, 0x012e, 0x0005,
+	0xa186, 0x0013, 0x1128, 0x6004, 0xa082, 0x0040, 0x0804, 0x91bc,
+	0xa186, 0x0027, 0x11e8, 0x080c, 0x7090, 0x080c, 0x2c9c, 0x00d6,
+	0x6110, 0x2168, 0x080c, 0x9c5a, 0x0168, 0x6837, 0x0103, 0x684b,
+	0x0029, 0x6847, 0x0000, 0x694c, 0xc1c5, 0x694e, 0x080c, 0x5408,
+	0x080c, 0x9e11, 0x00de, 0x080c, 0x861d, 0x080c, 0x7173, 0x0005,
+	0xa186, 0x0014, 0x1120, 0x6004, 0xa082, 0x0040, 0x0428, 0xa186,
+	0x0046, 0x0138, 0xa186, 0x0045, 0x0120, 0xa186, 0x0047, 0x190c,
+	0x1515, 0x2001, 0x0109, 0x2004, 0xd084, 0x0198, 0x0126, 0x2091,
+	0x2800, 0x0006, 0x0016, 0x0026, 0x080c, 0x6b74, 0x002e, 0x001e,
+	0x000e, 0x012e, 0xe000, 0x6000, 0xa086, 0x0002, 0x1110, 0x0804,
+	0x91fa, 0x080c, 0x8663, 0x0005, 0x0002, 0x919a, 0x9198, 0x9198,
+	0x9198, 0x9198, 0x9198, 0x9198, 0x9198, 0x9198, 0x9198, 0x9198,
+	0x91b5, 0x91b5, 0x91b5, 0x91b5, 0x9198, 0x91b5, 0x9198, 0x91b5,
+	0x080c, 0x1515, 0x080c, 0x7090, 0x00d6, 0x6110, 0x2168, 0x080c,
+	0x9c5a, 0x0168, 0x6837, 0x0103, 0x684b, 0x0006, 0x6847, 0x0000,
+	0x6850, 0xc0ec, 0x6852, 0x080c, 0x5408, 0x080c, 0x9e11, 0x00de,
+	0x080c, 0x861d, 0x080c, 0x7173, 0x0005, 0x080c, 0x7090, 0x080c,
+	0x861d, 0x080c, 0x7173, 0x0005, 0x0002, 0x91d2, 0x91d0, 0x91d0,
+	0x91d0, 0x91d0, 0x91d0, 0x91d0, 0x91d0, 0x91d0, 0x91d0, 0x91d0,
+	0x91e4, 0x91e4, 0x91e4, 0x91e4, 0x91d0, 0x91f3, 0x91d0, 0x91e4,
+	0x080c, 0x1515, 0x080c, 0x7090, 0x2001, 0xb7b8, 0x2004, 0x603e,
+	0x6003, 0x0002, 0x080c, 0x7173, 0x6010, 0xa088, 0x0013, 0x2104,
+	0xa085, 0x0400, 0x200a, 0x0005, 0x080c, 0x7090, 0x2001, 0xb7b6,
+	0x2004, 0x6016, 0x2001, 0xb7b8, 0x2004, 0x603e, 0x6003, 0x000f,
+	0x080c, 0x7173, 0x0005, 0x080c, 0x7090, 0x080c, 0x861d, 0x080c,
+	0x7173, 0x0005, 0xa182, 0x0040, 0x0002, 0x9210, 0x9210, 0x9210,
+	0x9210, 0x9210, 0x9212, 0x92f7, 0x9326, 0x9210, 0x9210, 0x9210,
+	0x9210, 0x9210, 0x9210, 0x9210, 0x9210, 0x9210, 0x9210, 0x9210,
+	0x080c, 0x1515, 0x00e6, 0x00d6, 0x603f, 0x0000, 0x2071, 0xbb80,
+	0x7124, 0x610a, 0x2071, 0xbb8c, 0x6110, 0x2168, 0x7614, 0xa6b4,
+	0x0fff, 0x86ff, 0x0904, 0x92c0, 0xa68c, 0x0c00, 0x0518, 0x00f6,
+	0x2c78, 0x080c, 0x5305, 0x00fe, 0x01c8, 0x684c, 0xd0ac, 0x01b0,
+	0x6020, 0xd0dc, 0x1198, 0x6850, 0xd0bc, 0x1180, 0x7318, 0x6814,
+	0xa306, 0x1904, 0x92d3, 0x731c, 0x6810, 0xa31e, 0x0138, 0xd6d4,
+	0x0904, 0x92d3, 0x6b14, 0xa305, 0x1904, 0x92d3, 0x7318, 0x6b62,
+	0x731c, 0x6b5e, 0xa68c, 0x00ff, 0xa186, 0x0002, 0x0518, 0xa186,
+	0x0028, 0x1128, 0x080c, 0x9e36, 0x684b, 0x001c, 0x00e8, 0xd6dc,
+	0x01a0, 0x684b, 0x0015, 0x684c, 0xd0ac, 0x0170, 0x6914, 0x6a10,
+	0x2100, 0xa205, 0x0148, 0x7018, 0xa106, 0x1118, 0x701c, 0xa206,
+	0x0118, 0x6962, 0x6a5e, 0xc6dc, 0x0038, 0xd6d4, 0x0118, 0x684b,
+	0x0007, 0x0010, 0x684b, 0x0000, 0x6837, 0x0103, 0x6e46, 0xa01e,
+	0xd6c4, 0x01f0, 0xa686, 0x0100, 0x1140, 0x2001, 0xbb99, 0x2004,
+	0xa005, 0x1118, 0xc6c4, 0x0804, 0x9221, 0x7328, 0x732c, 0x6b56,
+	0x83ff, 0x0170, 0xa38a, 0x0009, 0x0210, 0x2019, 0x0008, 0x0036,
+	0x2308, 0x2019, 0xbb98, 0xad90, 0x0019, 0x080c, 0x990d, 0x003e,
+	0xd6cc, 0x0904, 0x92e6, 0x7124, 0x695a, 0x81ff, 0x0904, 0x92e6,
+	0xa192, 0x0021, 0x1260, 0x2071, 0xbb98, 0x831c, 0x2300, 0xae18,
+	0xad90, 0x001d, 0x080c, 0x990d, 0x080c, 0xa137, 0x04b8, 0x6838,
+	0xd0fc, 0x0120, 0x2009, 0x0020, 0x695a, 0x0c68, 0x00f6, 0x2d78,
+	0x080c, 0x98b2, 0x00fe, 0x080c, 0xa137, 0x080c, 0x98fd, 0x0440,
+	0x00f6, 0x2c78, 0x080c, 0x5305, 0x00fe, 0x0190, 0x684c, 0xd0ac,
+	0x0178, 0x6020, 0xd0dc, 0x1160, 0x6850, 0xd0bc, 0x1148, 0x6810,
+	0x6914, 0xa105, 0x0128, 0x080c, 0x9f35, 0x00de, 0x00ee, 0x00f0,
+	0x684b, 0x0000, 0x6837, 0x0103, 0x6e46, 0x684c, 0xd0ac, 0x0130,
+	0x6810, 0x6914, 0xa115, 0x0110, 0x080c, 0x9483, 0x080c, 0x5408,
+	0x6218, 0x2268, 0x6a3c, 0x82ff, 0x0110, 0x8211, 0x6a3e, 0x080c,
+	0x9f03, 0x00de, 0x00ee, 0x1110, 0x080c, 0x861d, 0x0005, 0x00f6,
+	0x6003, 0x0003, 0x2079, 0xbb8c, 0x7c04, 0x7b00, 0x7e0c, 0x7d08,
+	0x6010, 0x2078, 0x784c, 0xd0ac, 0x0138, 0x6003, 0x0002, 0x00fe,
+	0x0005, 0x2130, 0x2228, 0x0058, 0x2400, 0x797c, 0xa10a, 0x2300,
+	0x7a80, 0xa213, 0x2600, 0xa102, 0x2500, 0xa203, 0x0e90, 0x7c12,
+	0x7b16, 0x7e0a, 0x7d0e, 0x00fe, 0x603f, 0x0000, 0x2c10, 0x080c,
+	0x1fa9, 0x080c, 0x6cf0, 0x080c, 0x7230, 0x0005, 0x2001, 0xb7b8,
+	0x2004, 0x603e, 0x6003, 0x0004, 0x6110, 0x20e1, 0x0005, 0x3d18,
+	0x3e20, 0x2c10, 0x080c, 0x185e, 0x0005, 0xa182, 0x0040, 0x0002,
+	0x934b, 0x934b, 0x934b, 0x934b, 0x934b, 0x934d, 0x93e0, 0x934b,
+	0x934b, 0x93f6, 0x945a, 0x934b, 0x934b, 0x934b, 0x934b, 0x9469,
+	0x934b, 0x934b, 0x934b, 0x080c, 0x1515, 0x0076, 0x00f6, 0x00e6,
+	0x00d6, 0x2071, 0xbb8c, 0x6110, 0x2178, 0x7614, 0xa6b4, 0x0fff,
+	0x7e46, 0x7f4c, 0xc7e5, 0x7f4e, 0x6218, 0x2268, 0x6a3c, 0x82ff,
+	0x0110, 0x8211, 0x6a3e, 0x86ff, 0x0904, 0x93db, 0xa694, 0xff00,
+	0xa284, 0x0c00, 0x0120, 0x7018, 0x7862, 0x701c, 0x785e, 0xa284,
+	0x0300, 0x0904, 0x93db, 0x080c, 0x15f8, 0x090c, 0x1515, 0x2d00,
+	0x784a, 0x7f4c, 0xc7cd, 0x7f4e, 0x6837, 0x0103, 0x7838, 0x683a,
+	0x783c, 0x683e, 0x7840, 0x6842, 0x6e46, 0xa68c, 0x0c00, 0x0120,
+	0x7318, 0x6b62, 0x731c, 0x6b5e, 0xa68c, 0x00ff, 0xa186, 0x0002,
+	0x0180, 0xa186, 0x0028, 0x1118, 0x684b, 0x001c, 0x0060, 0xd6dc,
+	0x0118, 0x684b, 0x0015, 0x0038, 0xd6d4, 0x0118, 0x684b, 0x0007,
+	0x0010, 0x684b, 0x0000, 0x6f4e, 0x7850, 0x6852, 0x7854, 0x6856,
+	0xa01e, 0xd6c4, 0x0198, 0x7328, 0x732c, 0x6b56, 0x83ff, 0x0170,
+	0xa38a, 0x0009, 0x0210, 0x2019, 0x0008, 0x0036, 0x2308, 0x2019,
+	0xbb98, 0xad90, 0x0019, 0x080c, 0x990d, 0x003e, 0xd6cc, 0x01d8,
+	0x7124, 0x695a, 0x81ff, 0x01b8, 0xa192, 0x0021, 0x1250, 0x2071,
+	0xbb98, 0x831c, 0x2300, 0xae18, 0xad90, 0x001d, 0x080c, 0x990d,
+	0x0050, 0x7838, 0xd0fc, 0x0120, 0x2009, 0x0020, 0x695a, 0x0c78,
+	0x2d78, 0x080c, 0x98b2, 0x00de, 0x00ee, 0x00fe, 0x007e, 0x0005,
+	0x00f6, 0x6003, 0x0003, 0x2079, 0xbb8c, 0x7c04, 0x7b00, 0x7e0c,
+	0x7d08, 0x6010, 0x2078, 0x7c12, 0x7b16, 0x7e0a, 0x7d0e, 0x00fe,
+	0x2c10, 0x080c, 0x1fa9, 0x080c, 0x7d60, 0x0005, 0x00d6, 0x00f6,
+	0x2c78, 0x080c, 0x5305, 0x00fe, 0x0120, 0x2001, 0xb7b8, 0x2004,
+	0x603e, 0x6003, 0x0002, 0x080c, 0x7126, 0x080c, 0x7230, 0x6110,
+	0x2168, 0x694c, 0xd1e4, 0x0904, 0x9458, 0xd1cc, 0x0540, 0x6948,
+	0x6838, 0xd0fc, 0x01e8, 0x0016, 0x684c, 0x0006, 0x6850, 0x0006,
+	0xad90, 0x000d, 0xa198, 0x000d, 0x2009, 0x0020, 0x0156, 0x21a8,
+	0x2304, 0x2012, 0x8318, 0x8210, 0x1f04, 0x9420, 0x015e, 0x000e,
+	0x6852, 0x000e, 0x684e, 0x001e, 0x2168, 0x080c, 0x161f, 0x0418,
+	0x0016, 0x080c, 0x161f, 0x00de, 0x080c, 0x98fd, 0x00e0, 0x6837,
+	0x0103, 0x6944, 0xa184, 0x00ff, 0xa0b6, 0x0002, 0x0180, 0xa086,
+	0x0028, 0x1118, 0x684b, 0x001c, 0x0060, 0xd1dc, 0x0118, 0x684b,
+	0x0015, 0x0038, 0xd1d4, 0x0118, 0x684b, 0x0007, 0x0010, 0x684b,
+	0x0000, 0x080c, 0x5408, 0x080c, 0x9f03, 0x1110, 0x080c, 0x861d,
+	0x00de, 0x0005, 0x2019, 0x0001, 0x080c, 0x7fe4, 0x6003, 0x0002,
+	0x2001, 0xb7b8, 0x2004, 0x603e, 0x080c, 0x7126, 0x080c, 0x7230,
+	0x0005, 0x080c, 0x7126, 0x080c, 0x2c9c, 0x00d6, 0x6110, 0x2168,
+	0x080c, 0x9c5a, 0x0150, 0x6837, 0x0103, 0x684b, 0x0029, 0x6847,
+	0x0000, 0x080c, 0x5408, 0x080c, 0x9e11, 0x00de, 0x080c, 0x861d,
+	0x080c, 0x7230, 0x0005, 0x684b, 0x0015, 0xd1fc, 0x0138, 0x684b,
+	0x0007, 0x8002, 0x8000, 0x810a, 0xa189, 0x0000, 0x6962, 0x685e,
+	0x0005, 0xa182, 0x0040, 0x0002, 0x94a7, 0x94a7, 0x94a7, 0x94a7,
+	0x94a7, 0x94a9, 0x94a7, 0x9564, 0x9570, 0x94a7, 0x94a7, 0x94a7,
+	0x94a7, 0x94a7, 0x94a7, 0x94a7, 0x94a7, 0x94a7, 0x94a7, 0x080c,
+	0x1515, 0x0076, 0x00f6, 0x00e6, 0x00d6, 0x2071, 0xbb8c, 0x6110,
+	0x2178, 0x7614, 0xa6b4, 0x0fff, 0x00f6, 0x2c78, 0x080c, 0x5305,
+	0x00fe, 0x0150, 0xa684, 0x00ff, 0x1138, 0x6020, 0xd0f4, 0x0120,
+	0x080c, 0x9f35, 0x0804, 0x955f, 0x7e46, 0x7f4c, 0xc7e5, 0x7f4e,
+	0x6218, 0x2268, 0x6a3c, 0x82ff, 0x0110, 0x8211, 0x6a3e, 0x86ff,
+	0x0904, 0x9555, 0xa694, 0xff00, 0xa284, 0x0c00, 0x0120, 0x7018,
+	0x7862, 0x701c, 0x785e, 0xa284, 0x0300, 0x0904, 0x9553, 0xa686,
+	0x0100, 0x1140, 0x2001, 0xbb99, 0x2004, 0xa005, 0x1118, 0xc6c4,
+	0x7e46, 0x0c28, 0x080c, 0x15f8, 0x090c, 0x1515, 0x2d00, 0x784a,
+	0x7f4c, 0xa7bd, 0x0200, 0x7f4e, 0x6837, 0x0103, 0x7838, 0x683a,
+	0x783c, 0x683e, 0x7840, 0x6842, 0x6e46, 0xa68c, 0x0c00, 0x0120,
+	0x7318, 0x6b62, 0x731c, 0x6b5e, 0xa68c, 0x00ff, 0xa186, 0x0002,
+	0x0180, 0xa186, 0x0028, 0x1118, 0x684b, 0x001c, 0x0060, 0xd6dc,
+	0x0118, 0x684b, 0x0015, 0x0038, 0xd6d4, 0x0118, 0x684b, 0x0007,
+	0x0010, 0x684b, 0x0000, 0x6f4e, 0x7850, 0x6852, 0x7854, 0x6856,
+	0xa01e, 0xd6c4, 0x0198, 0x7328, 0x732c, 0x6b56, 0x83ff, 0x0170,
+	0xa38a, 0x0009, 0x0210, 0x2019, 0x0008, 0x0036, 0x2308, 0x2019,
+	0xbb98, 0xad90, 0x0019, 0x080c, 0x990d, 0x003e, 0xd6cc, 0x01d8,
+	0x7124, 0x695a, 0x81ff, 0x01b8, 0xa192, 0x0021, 0x1250, 0x2071,
+	0xbb98, 0x831c, 0x2300, 0xae18, 0xad90, 0x001d, 0x080c, 0x990d,
+	0x0050, 0x7838, 0xd0fc, 0x0120, 0x2009, 0x0020, 0x695a, 0x0c78,
+	0x2d78, 0x080c, 0x98b2, 0xd6dc, 0x1110, 0xa006, 0x0030, 0x2001,
+	0x0001, 0x2071, 0xbb8c, 0x7218, 0x731c, 0x080c, 0x18b1, 0x00de,
+	0x00ee, 0x00fe, 0x007e, 0x0005, 0x2001, 0xb7b8, 0x2004, 0x603e,
+	0x20e1, 0x0005, 0x3d18, 0x3e20, 0x2c10, 0x080c, 0x185e, 0x0005,
+	0x2001, 0xb7b8, 0x2004, 0x603e, 0x00d6, 0x6003, 0x0002, 0x6110,
+	0x2168, 0x694c, 0xd1e4, 0x0904, 0x967b, 0x603f, 0x0000, 0x00f6,
+	0x2c78, 0x080c, 0x5305, 0x00fe, 0x0560, 0x6814, 0x6910, 0xa115,
+	0x0540, 0x6a60, 0xa206, 0x1118, 0x685c, 0xa106, 0x0510, 0x684c,
+	0xc0e4, 0x684e, 0x6847, 0x0000, 0x6863, 0x0000, 0x685f, 0x0000,
+	0x6020, 0xd0f4, 0x1158, 0x697c, 0x6810, 0xa102, 0x603a, 0x6980,
+	0x6814, 0xa103, 0x6036, 0x6020, 0xc0f5, 0x6022, 0x00d6, 0x6018,
+	0x2068, 0x683c, 0x8000, 0x683e, 0x00de, 0x080c, 0x9f35, 0x0804,
+	0x967b, 0x694c, 0xd1cc, 0x0904, 0x964b, 0x6948, 0x6838, 0xd0fc,
+	0x0904, 0x960e, 0x0016, 0x684c, 0x0006, 0x6850, 0x0006, 0x00f6,
+	0x2178, 0x7944, 0xa184, 0x00ff, 0xa0b6, 0x0002, 0x01e0, 0xa086,
+	0x0028, 0x1128, 0x684b, 0x001c, 0x784b, 0x001c, 0x00e8, 0xd1dc,
+	0x0158, 0x684b, 0x0015, 0x784b, 0x0015, 0x080c, 0xa0bf, 0x0118,
+	0x7944, 0xc1dc, 0x7946, 0x0080, 0xd1d4, 0x0128, 0x684b, 0x0007,
+	0x784b, 0x0007, 0x0048, 0x684c, 0xd0ac, 0x0130, 0x6810, 0x6914,
+	0xa115, 0x0110, 0x080c, 0x9483, 0x6848, 0x784a, 0x6860, 0x7862,
+	0x685c, 0x785e, 0xad90, 0x000d, 0xaf98, 0x000d, 0x2009, 0x0020,
+	0x0156, 0x21a8, 0x2304, 0x2012, 0x8318, 0x8210, 0x1f04, 0x95fa,
+	0x015e, 0x00fe, 0x000e, 0x6852, 0x000e, 0x684e, 0x080c, 0xa137,
+	0x001e, 0x2168, 0x080c, 0x161f, 0x0804, 0x9676, 0x0016, 0x00f6,
+	0x2178, 0x7944, 0xa184, 0x00ff, 0xa0b6, 0x0002, 0x01e0, 0xa086,
+	0x0028, 0x1128, 0x684b, 0x001c, 0x784b, 0x001c, 0x00e8, 0xd1dc,
+	0x0158, 0x684b, 0x0015, 0x784b, 0x0015, 0x080c, 0xa0bf, 0x0118,
+	0x7944, 0xc1dc, 0x7946, 0x0080, 0xd1d4, 0x0128, 0x684b, 0x0007,
+	0x784b, 0x0007, 0x0048, 0x684c, 0xd0ac, 0x0130, 0x6810, 0x6914,
+	0xa115, 0x0110, 0x080c, 0x9483, 0x6860, 0x7862, 0x685c, 0x785e,
+	0x684c, 0x784e, 0x00fe, 0x080c, 0x161f, 0x00de, 0x080c, 0xa137,
+	0x080c, 0x98fd, 0x0458, 0x6837, 0x0103, 0x6944, 0xa184, 0x00ff,
+	0xa0b6, 0x0002, 0x01b0, 0xa086, 0x0028, 0x1118, 0x684b, 0x001c,
+	0x00d8, 0xd1dc, 0x0148, 0x684b, 0x0015, 0x080c, 0xa0bf, 0x0118,
+	0x6944, 0xc1dc, 0x6946, 0x0080, 0xd1d4, 0x0118, 0x684b, 0x0007,
+	0x0058, 0x684b, 0x0000, 0x684c, 0xd0ac, 0x0130, 0x6810, 0x6914,
+	0xa115, 0x0110, 0x080c, 0x9483, 0x080c, 0x5408, 0x080c, 0x9f03,
+	0x1110, 0x080c, 0x861d, 0x00de, 0x0005, 0x080c, 0x7090, 0x0010,
+	0x080c, 0x7126, 0x080c, 0x9c5a, 0x01c0, 0x00d6, 0x6110, 0x2168,
+	0x6837, 0x0103, 0x2009, 0xb50c, 0x210c, 0xd18c, 0x11c0, 0xd184,
+	0x1198, 0x6108, 0x694a, 0xa18e, 0x0029, 0x1110, 0x080c, 0xb380,
+	0x6847, 0x0000, 0x080c, 0x5408, 0x00de, 0x080c, 0x861d, 0x080c,
+	0x7173, 0x080c, 0x7230, 0x0005, 0x684b, 0x0004, 0x0c88, 0x684b,
+	0x0004, 0x0c70, 0xa182, 0x0040, 0x0002, 0x96c0, 0x96c0, 0x96c0,
+	0x96c0, 0x96c0, 0x96c2, 0x96c0, 0x96c5, 0x96c0, 0x96c0, 0x96c0,
+	0x96c0, 0x96c0, 0x96c0, 0x96c0, 0x96c0, 0x96c0, 0x96c0, 0x96c0,
+	0x080c, 0x1515, 0x080c, 0x861d, 0x0005, 0x0006, 0x0026, 0xa016,
+	0x080c, 0x185e, 0x002e, 0x000e, 0x0005, 0xa182, 0x0085, 0x0002,
+	0x96d9, 0x96d7, 0x96d7, 0x96e5, 0x96d7, 0x96d7, 0x96d7, 0x080c,
+	0x1515, 0x6003, 0x0001, 0x6106, 0x080c, 0x6c8d, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x7173, 0x012e, 0x0005, 0x0026, 0x0056, 0x00d6,
+	0x00e6, 0x2071, 0xbb80, 0x7224, 0x6212, 0x7220, 0x080c, 0x9c4a,
+	0x01a0, 0x2268, 0x6800, 0xa086, 0x0000, 0x0178, 0x6018, 0x6d18,
+	0xa52e, 0x1158, 0x00c6, 0x2d60, 0x080c, 0x991d, 0x00ce, 0x0128,
+	0x6803, 0x0002, 0x6007, 0x0086, 0x0010, 0x6007, 0x0087, 0x6003,
+	0x0001, 0x080c, 0x6c8d, 0x080c, 0x7173, 0x00f6, 0x2278, 0x080c,
+	0x5305, 0x00fe, 0x0150, 0x6820, 0xd0ec, 0x0138, 0x00c6, 0x2260,
+	0x603f, 0x0000, 0x080c, 0x9f35, 0x00ce, 0x00ee, 0x00de, 0x005e,
+	0x002e, 0x0005, 0xa186, 0x0013, 0x1160, 0x6004, 0xa08a, 0x0085,
+	0x0a0c, 0x1515, 0xa08a, 0x008c, 0x1a0c, 0x1515, 0xa082, 0x0085,
+	0x0072, 0xa186, 0x0027, 0x0120, 0xa186, 0x0014, 0x190c, 0x1515,
+	0x080c, 0x7090, 0x080c, 0x9e1d, 0x080c, 0x7173, 0x0005, 0x9746,
+	0x9748, 0x9748, 0x9746, 0x9746, 0x9746, 0x9746, 0x080c, 0x1515,
+	0x080c, 0x7090, 0x080c, 0x9e1d, 0x080c, 0x7173, 0x0005, 0xa186,
+	0x0013, 0x1128, 0x6004, 0xa082, 0x0085, 0x2008, 0x04a8, 0xa186,
+	0x0027, 0x11e8, 0x080c, 0x7090, 0x080c, 0x2c9c, 0x00d6, 0x6010,
+	0x2068, 0x080c, 0x9c5a, 0x0150, 0x6837, 0x0103, 0x6847, 0x0000,
+	0x684b, 0x0029, 0x080c, 0x5408, 0x080c, 0x9e11, 0x00de, 0x080c,
+	0x861d, 0x080c, 0x7173, 0x0005, 0x080c, 0x8663, 0x0ce0, 0xa186,
+	0x0014, 0x1dd0, 0x080c, 0x7090, 0x00d6, 0x6010, 0x2068, 0x080c,
+	0x9c5a, 0x0d60, 0x6837, 0x0103, 0x6847, 0x0000, 0x684b, 0x0006,
+	0x6850, 0xc0ec, 0x6852, 0x08f0, 0x0002, 0x9796, 0x9794, 0x9794,
+	0x9794, 0x9794, 0x9794, 0x97ae, 0x080c, 0x1515, 0x080c, 0x7090,
+	0x6030, 0xa08c, 0xff00, 0x810f, 0xa186, 0x0039, 0x0118, 0xa186,
+	0x0035, 0x1118, 0x2001, 0xb7b6, 0x0010, 0x2001, 0xb7b7, 0x2004,
+	0x6016, 0x6003, 0x000c, 0x080c, 0x7173, 0x0005, 0x080c, 0x7090,
+	0x6030, 0xa08c, 0xff00, 0x810f, 0xa186, 0x0039, 0x0118, 0xa186,
+	0x0035, 0x1118, 0x2001, 0xb7b6, 0x0010, 0x2001, 0xb7b7, 0x2004,
+	0x6016, 0x6003, 0x000e, 0x080c, 0x7173, 0x0005, 0xa182, 0x008c,
+	0x1220, 0xa182, 0x0085, 0x0208, 0x001a, 0x080c, 0x8663, 0x0005,
+	0x97d7, 0x97d7, 0x97d7, 0x97d7, 0x97d9, 0x9832, 0x97d7, 0x080c,
+	0x1515, 0x00d6, 0x00f6, 0x2c78, 0x080c, 0x5305, 0x00fe, 0x0168,
+	0x6030, 0xa08c, 0xff00, 0x810f, 0xa186, 0x0039, 0x0118, 0xa186,
+	0x0035, 0x1118, 0x00de, 0x0804, 0x9845, 0x080c, 0x9c5a, 0x1118,
+	0x080c, 0x9e11, 0x00f0, 0x6010, 0x2068, 0x684c, 0xd0e4, 0x1110,
+	0x080c, 0x9e11, 0x6837, 0x0103, 0x6850, 0xd0b4, 0x0128, 0x684b,
+	0x0006, 0xc0ec, 0x6852, 0x0048, 0xd0bc, 0x0118, 0x684b, 0x0002,
+	0x0020, 0x684b, 0x0005, 0x080c, 0x9ed2, 0x6847, 0x0000, 0x080c,
+	0x5408, 0x2c68, 0x080c, 0x85c7, 0x01c0, 0x6003, 0x0001, 0x6007,
+	0x001e, 0x600b, 0xffff, 0x2009, 0xbb8e, 0x210c, 0x6136, 0x2009,
+	0xbb8f, 0x210c, 0x613a, 0x6918, 0x611a, 0x080c, 0xa027, 0x6950,
+	0x6152, 0x601f, 0x0001, 0x080c, 0x6c8d, 0x2d60, 0x080c, 0x861d,
+	0x00de, 0x0005, 0x00f6, 0x2c78, 0x080c, 0x5305, 0x00fe, 0x0598,
+	0x6030, 0xa08c, 0xff00, 0x810f, 0xa186, 0x0035, 0x0130, 0xa186,
+	0x001e, 0x0118, 0xa186, 0x0039, 0x1530, 0x00d6, 0x2c68, 0x080c,
+	0xa10a, 0x1904, 0x988a, 0x080c, 0x85c7, 0x01d8, 0x6106, 0x6003,
+	0x0001, 0x601f, 0x0001, 0x6918, 0x611a, 0x6928, 0x612a, 0x692c,
+	0x612e, 0x6930, 0xa18c, 0x00ff, 0x6132, 0x6934, 0x6136, 0x6938,
+	0x613a, 0x6950, 0x6152, 0x080c, 0xa027, 0x080c, 0x6c8d, 0x080c,
+	0x7173, 0x2d60, 0x00f8, 0x00d6, 0x6010, 0x2068, 0x080c, 0x9c5a,
+	0x01c8, 0x6837, 0x0103, 0x6850, 0xd0b4, 0x0128, 0xc0ec, 0x6852,
+	0x684b, 0x0006, 0x0048, 0xd0bc, 0x0118, 0x684b, 0x0002, 0x0020,
+	0x684b, 0x0005, 0x080c, 0x9ed2, 0x6847, 0x0000, 0x080c, 0x5408,
+	0x080c, 0x9e11, 0x00de, 0x080c, 0x861d, 0x0005, 0x0016, 0x00d6,
+	0x6010, 0x2068, 0x080c, 0x9c5a, 0x0140, 0x6837, 0x0103, 0x684b,
+	0x0028, 0x6847, 0x0000, 0x080c, 0x5408, 0x00de, 0x001e, 0xa186,
+	0x0013, 0x0148, 0xa186, 0x0014, 0x0130, 0xa186, 0x0027, 0x0118,
+	0x080c, 0x8663, 0x0030, 0x080c, 0x7090, 0x080c, 0x9e1d, 0x080c,
+	0x7173, 0x0005, 0x0056, 0x0066, 0x00d6, 0x00f6, 0x2029, 0x0001,
+	0xa182, 0x0101, 0x1208, 0x0010, 0x2009, 0x0100, 0x2130, 0x2069,
+	0xbb98, 0x831c, 0x2300, 0xad18, 0x2009, 0x0020, 0xaf90, 0x001d,
+	0x080c, 0x990d, 0xa6b2, 0x0020, 0x7804, 0xa06d, 0x0110, 0x080c,
+	0x161f, 0x080c, 0x15f8, 0x0500, 0x8528, 0x6837, 0x0110, 0x683b,
+	0x0000, 0x2d20, 0x7c06, 0xa68a, 0x003d, 0x1228, 0x2608, 0xad90,
+	0x000f, 0x0459, 0x0088, 0xa6b2, 0x003c, 0x2009, 0x003c, 0x2d78,
+	0xad90, 0x000f, 0x0411, 0x0c28, 0x00fe, 0x852f, 0xa5ad, 0x0003,
+	0x7d36, 0xa5ac, 0x0000, 0x0028, 0x00fe, 0x852f, 0xa5ad, 0x0003,
+	0x7d36, 0x00de, 0x006e, 0x005e, 0x0005, 0x00f6, 0x8dff, 0x0158,
+	0x6804, 0xa07d, 0x0130, 0x6807, 0x0000, 0x080c, 0x5408, 0x2f68,
+	0x0cb8, 0x080c, 0x5408, 0x00fe, 0x0005, 0x0156, 0xa184, 0x0001,
+	0x0108, 0x8108, 0x810c, 0x21a8, 0x2304, 0x8007, 0x2012, 0x8318,
+	0x8210, 0x1f04, 0x9914, 0x015e, 0x0005, 0x0066, 0x0126, 0x2091,
+	0x8000, 0x2031, 0x0001, 0x601c, 0xa084, 0x000f, 0x0083, 0x012e,
+	0x006e, 0x0005, 0x0126, 0x2091, 0x8000, 0x0066, 0x2031, 0x0000,
+	0x601c, 0xa084, 0x000f, 0x001b, 0x006e, 0x012e, 0x0005, 0x9954,
+	0x9954, 0x994f, 0x9976, 0x9942, 0x994f, 0x9976, 0x994f, 0x994f,
+	0x9942, 0x994f, 0x080c, 0x1515, 0x0036, 0x2019, 0x0010, 0x080c,
+	0xace0, 0x601f, 0x0006, 0x6003, 0x0007, 0x003e, 0x0005, 0xa006,
+	0x0005, 0xa085, 0x0001, 0x0005, 0x00d6, 0x86ff, 0x11d8, 0x6010,
+	0x2068, 0x080c, 0x9c5a, 0x01c0, 0x6834, 0xa086, 0x0139, 0x1128,
+	0x684b, 0x0005, 0x6853, 0x0000, 0x0028, 0xa00e, 0x2001, 0x0005,
+	0x080c, 0x54db, 0x080c, 0x9ed2, 0x080c, 0x5408, 0x080c, 0x861d,
+	0xa085, 0x0001, 0x00de, 0x0005, 0xa006, 0x0ce0, 0x6000, 0xa08a,
+	0x0010, 0x1a0c, 0x1515, 0x000b, 0x0005, 0x998d, 0x99ae, 0x998f,
+	0x99cd, 0x99ab, 0x998d, 0x994f, 0x9954, 0x9954, 0x994f, 0x994f,
+	0x994f, 0x994f, 0x994f, 0x994f, 0x994f, 0x080c, 0x1515, 0x86ff,
+	0x11b8, 0x601c, 0xa086, 0x0006, 0x0198, 0x00d6, 0x6010, 0x2068,
+	0x080c, 0x9c5a, 0x0110, 0x080c, 0x9ed2, 0x00de, 0x6007, 0x0085,
+	0x6003, 0x000b, 0x601f, 0x0002, 0x080c, 0x6c8d, 0x080c, 0x7173,
+	0xa085, 0x0001, 0x0005, 0x080c, 0x194d, 0x0c08, 0x00e6, 0x2071,
+	0xb7e0, 0x7024, 0xac06, 0x1110, 0x080c, 0x7f59, 0x601c, 0xa084,
+	0x000f, 0xa086, 0x0006, 0x1150, 0x0086, 0x0096, 0x2049, 0x0001,
+	0x2c40, 0x080c, 0x8130, 0x009e, 0x008e, 0x0010, 0x080c, 0x7e58,
+	0x00ee, 0x1928, 0x080c, 0x994f, 0x0005, 0x0036, 0x00e6, 0x2071,
+	0xb7e0, 0x703c, 0xac06, 0x1140, 0x2019, 0x0000, 0x080c, 0x7fe4,
+	0x00ee, 0x003e, 0x0804, 0x998f, 0x080c, 0x825d, 0x00ee, 0x003e,
+	0x1904, 0x998f, 0x080c, 0x994f, 0x0005, 0x00c6, 0x601c, 0xa084,
+	0x000f, 0x0013, 0x00ce, 0x0005, 0x99fe, 0x9a6b, 0x9bb9, 0x9a09,
+	0x9e1d, 0x99fe, 0xacd2, 0xa14e, 0x9a6b, 0x99f7, 0x9c24, 0x080c,
+	0x1515, 0x080c, 0x9e58, 0x1110, 0x080c, 0x8c19, 0x0005, 0x080c,
+	0x7090, 0x080c, 0x7173, 0x080c, 0x861d, 0x0005, 0x6017, 0x0001,
+	0x0005, 0x080c, 0x9c5a, 0x0120, 0x6010, 0xa080, 0x0019, 0x2c02,
+	0x6000, 0xa08a, 0x0010, 0x1a0c, 0x1515, 0x000b, 0x0005, 0x9a27,
+	0x9a29, 0x9a49, 0x9a5b, 0x9a68, 0x9a27, 0x99fe, 0x99fe, 0x99fe,
+	0x9a5b, 0x9a5b, 0x9a27, 0x9a27, 0x9a27, 0x9a27, 0x9a65, 0x080c,
+	0x1515, 0x00e6, 0x6010, 0x2070, 0x7050, 0xc0b5, 0x7052, 0x2071,
+	0xb7e0, 0x7024, 0xac06, 0x0190, 0x080c, 0x7e58, 0x6007, 0x0085,
+	0x6003, 0x000b, 0x601f, 0x0002, 0x2001, 0xb7b7, 0x2004, 0x6016,
+	0x080c, 0x6c8d, 0x080c, 0x7173, 0x00ee, 0x0005, 0x6017, 0x0001,
+	0x0cd8, 0x00d6, 0x6010, 0x2068, 0x6850, 0xc0b5, 0x6852, 0x00de,
+	0x6007, 0x0085, 0x6003, 0x000b, 0x601f, 0x0002, 0x080c, 0x6c8d,
+	0x080c, 0x7173, 0x0005, 0x00d6, 0x6017, 0x0001, 0x6010, 0x2068,
+	0x6850, 0xc0b5, 0x6852, 0x00de, 0x0005, 0x080c, 0x861d, 0x0005,
+	0x080c, 0x194d, 0x08f0, 0x6000, 0xa08a, 0x0010, 0x1a0c, 0x1515,
+	0x000b, 0x0005, 0x9a82, 0x9a06, 0x9a84, 0x9a82, 0x9a84, 0x9a84,
+	0x99ff, 0x9a82, 0x99f9, 0x99f9, 0x9a82, 0x9a82, 0x9a82, 0x9a82,
+	0x9a82, 0x9a82, 0x080c, 0x1515, 0x00d6, 0x6018, 0x2068, 0x6804,
+	0xa084, 0x00ff, 0x00de, 0xa08a, 0x000c, 0x1a0c, 0x1515, 0x000b,
+	0x0005, 0x9a9d, 0x9b5f, 0x9a9f, 0x9add, 0x9a9f, 0x9add, 0x9a9f,
+	0x9aad, 0x9a9d, 0x9add, 0x9a9d, 0x9ac9, 0x080c, 0x1515, 0x6004,
+	0xa08e, 0x0016, 0x05a8, 0xa08e, 0x0004, 0x0590, 0xa08e, 0x0002,
+	0x0578, 0xa08e, 0x004b, 0x0904, 0x9b5b, 0x6004, 0x080c, 0x9e58,
+	0x0904, 0x9b78, 0xa08e, 0x0021, 0x0904, 0x9b7c, 0xa08e, 0x0022,
+	0x0904, 0x9b78, 0xa08e, 0x003d, 0x0904, 0x9b7c, 0xa08e, 0x0039,
+	0x0904, 0x9b80, 0xa08e, 0x0035, 0x0904, 0x9b80, 0xa08e, 0x001e,
+	0x0188, 0xa08e, 0x0001, 0x1150, 0x00d6, 0x6018, 0x2068, 0x6804,
+	0xa084, 0x00ff, 0x00de, 0xa086, 0x0006, 0x0110, 0x080c, 0x2c9c,
+	0x080c, 0x8c19, 0x080c, 0x9e1d, 0x0005, 0x00c6, 0x00d6, 0x6104,
+	0xa186, 0x0016, 0x0904, 0x9b4c, 0xa186, 0x0002, 0x15d8, 0x2001,
+	0xb535, 0x2004, 0xd08c, 0x1198, 0x080c, 0x5acf, 0x1180, 0x2001,
+	0xb79f, 0x2003, 0x0001, 0x2001, 0xb500, 0x2003, 0x0001, 0xa085,
+	0x0001, 0x080c, 0x5b13, 0x080c, 0x5a07, 0x0804, 0x9ba2, 0x6018,
+	0x2068, 0x2001, 0xb535, 0x2004, 0xd0ac, 0x1904, 0x9ba2, 0x68a0,
+	0xd0bc, 0x1904, 0x9ba2, 0x6840, 0xa084, 0x00ff, 0xa005, 0x0190,
+	0x8001, 0x6842, 0x6013, 0x0000, 0x601f, 0x0007, 0x6017, 0x0398,
+	0x603f, 0x0000, 0x080c, 0x85c7, 0x0128, 0x2d00, 0x601a, 0x601f,
+	0x0001, 0x0450, 0x00de, 0x00ce, 0x6004, 0xa08e, 0x0002, 0x11a8,
+	0x6018, 0xa080, 0x0028, 0x2004, 0xa086, 0x007e, 0x1170, 0x2009,
+	0xb535, 0x2104, 0xc085, 0x200a, 0x00e6, 0x2071, 0xb500, 0x080c,
+	0x4bc6, 0x00ee, 0x080c, 0x8c19, 0x0020, 0x080c, 0x8c19, 0x080c,
+	0x2c9c, 0x00e6, 0x0126, 0x2091, 0x8000, 0x080c, 0x2cc2, 0x012e,
+	0x00ee, 0x080c, 0x9e1d, 0x0005, 0x2001, 0x0002, 0x080c, 0x4efd,
+	0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x6cd3, 0x080c, 0x7173,
+	0x00de, 0x00ce, 0x0c80, 0x080c, 0x2cc2, 0x0804, 0x9ad8, 0x00c6,
+	0x00d6, 0x6104, 0xa186, 0x0016, 0x0d38, 0x6018, 0x2068, 0x6840,
+	0xa084, 0x00ff, 0xa005, 0x0904, 0x9b22, 0x8001, 0x6842, 0x6003,
+	0x0001, 0x080c, 0x6cd3, 0x080c, 0x7173, 0x00de, 0x00ce, 0x0898,
+	0x080c, 0x8c19, 0x0804, 0x9ada, 0x080c, 0x8c47, 0x0804, 0x9ada,
+	0x00d6, 0x2c68, 0x6104, 0x080c, 0xa10a, 0x00de, 0x0118, 0x080c,
+	0x861d, 0x00b8, 0x6004, 0x8007, 0x6130, 0xa18c, 0x00ff, 0xa105,
+	0x6032, 0x6007, 0x0085, 0x6003, 0x000b, 0x601f, 0x0002, 0x6038,
+	0x600a, 0x2001, 0xb7b7, 0x2004, 0x6016, 0x080c, 0x6c8d, 0x080c,
+	0x7173, 0x0005, 0x00de, 0x00ce, 0x080c, 0x8c19, 0x080c, 0x2c9c,
+	0x00e6, 0x0126, 0x2091, 0x8000, 0x080c, 0x2cc2, 0x6013, 0x0000,
+	0x601f, 0x0007, 0x6017, 0x0398, 0x603f, 0x0000, 0x012e, 0x00ee,
+	0x0005, 0x6000, 0xa08a, 0x0010, 0x1a0c, 0x1515, 0x000b, 0x0005,
+	0x9bd0, 0x9bd0, 0x9bd0, 0x9bd0, 0x9bd0, 0x9bd0, 0x9bd0, 0x9bd0,
+	0x9bd0, 0x99fe, 0x9bd0, 0x9a06, 0x9bd2, 0x9a06, 0x9bdf, 0x9bd0,
+	0x080c, 0x1515, 0x6004, 0xa086, 0x008b, 0x0148, 0x6007, 0x008b,
+	0x6003, 0x000d, 0x080c, 0x6c8d, 0x080c, 0x7173, 0x0005, 0x080c,
+	0x9e11, 0x080c, 0x9c5a, 0x0580, 0x080c, 0x2c9c, 0x00d6, 0x080c,
+	0x9c5a, 0x0168, 0x6010, 0x2068, 0x6837, 0x0103, 0x684b, 0x0006,
+	0x6847, 0x0000, 0x6850, 0xc0ed, 0x6852, 0x080c, 0x5408, 0x2c68,
+	0x080c, 0x85c7, 0x0150, 0x6818, 0x601a, 0x080c, 0xa027, 0x00c6,
+	0x2d60, 0x080c, 0x9e1d, 0x00ce, 0x0008, 0x2d60, 0x00de, 0x6013,
+	0x0000, 0x601f, 0x0001, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c,
+	0x6cd3, 0x080c, 0x7173, 0x0078, 0x6030, 0xa08c, 0xff00, 0x810f,
+	0xa186, 0x0039, 0x0118, 0xa186, 0x0035, 0x1118, 0x080c, 0x2c9c,
+	0x08b0, 0x080c, 0x9e1d, 0x0005, 0x6000, 0xa08a, 0x0010, 0x1a0c,
+	0x1515, 0x000b, 0x0005, 0x9c3b, 0x9c3b, 0x9c3b, 0x9c3d, 0x9c3d,
+	0x9c3b, 0x9c3b, 0x9c3b, 0x9c3b, 0x9c3b, 0x9c3b, 0x9c3b, 0x9c3b,
+	0x9c3b, 0x9c3b, 0x9c3b, 0x080c, 0x1515, 0x080c, 0x825d, 0x190c,
+	0x1515, 0x6110, 0x2168, 0x684b, 0x0006, 0x080c, 0x5408, 0x080c,
+	0x861d, 0x0005, 0xa284, 0x0007, 0x1158, 0xa282, 0xbd00, 0x0240,
+	0x2001, 0xb517, 0x2004, 0xa202, 0x1218, 0xa085, 0x0001, 0x0005,
+	0xa006, 0x0ce8, 0x0026, 0x6210, 0xa294, 0xf000, 0x002e, 0x0005,
+	0x00e6, 0x00c6, 0x0036, 0x0006, 0x0126, 0x2091, 0x8000, 0x2061,
+	0xbd00, 0x2071, 0xb500, 0x7348, 0x7068, 0xa302, 0x12a8, 0x601c,
+	0xa206, 0x1160, 0x080c, 0x9fb2, 0x0148, 0x080c, 0x9e58, 0x1110,
+	0x080c, 0x8c19, 0x00c6, 0x080c, 0x861d, 0x00ce, 0xace0, 0x0018,
+	0x705c, 0xac02, 0x1208, 0x0c38, 0x012e, 0x000e, 0x003e, 0x00ce,
+	0x00ee, 0x0005, 0x00e6, 0x00c6, 0x0016, 0xa188, 0xb635, 0x210c,
+	0x81ff, 0x0128, 0x2061, 0xb8f4, 0x611a, 0x080c, 0x2c9c, 0xa006,
+	0x0010, 0xa085, 0x0001, 0x001e, 0x00ce, 0x00ee, 0x0005, 0x00c6,
+	0x0056, 0x0126, 0x2091, 0x8000, 0x00c6, 0x080c, 0x85c7, 0x005e,
+	0x0180, 0x6612, 0x651a, 0x080c, 0xa027, 0x601f, 0x0003, 0x2009,
+	0x004b, 0x080c, 0x864c, 0xa085, 0x0001, 0x012e, 0x005e, 0x00ce,
+	0x0005, 0xa006, 0x0cd0, 0x00c6, 0x0056, 0x0126, 0x2091, 0x8000,
+	0x62a0, 0x00c6, 0x080c, 0x9ed6, 0x005e, 0x0550, 0x6013, 0x0000,
+	0x651a, 0x080c, 0xa027, 0x601f, 0x0003, 0x0016, 0x00c6, 0x2560,
+	0x080c, 0x51aa, 0x00ce, 0x080c, 0x6df5, 0x0076, 0x2039, 0x0000,
+	0x080c, 0x6d02, 0x2c08, 0x080c, 0xae82, 0x007e, 0x001e, 0xd184,
+	0x0128, 0x080c, 0x861d, 0xa085, 0x0001, 0x0030, 0x2009, 0x004c,
+	0x080c, 0x864c, 0xa085, 0x0001, 0x012e, 0x005e, 0x00ce, 0x0005,
+	0xa006, 0x0cd0, 0x00f6, 0x00c6, 0x0046, 0x00c6, 0x080c, 0x85c7,
+	0x2c78, 0x00ce, 0x0180, 0x7e12, 0x2c00, 0x781a, 0x781f, 0x0003,
+	0x2021, 0x0005, 0x080c, 0x9d50, 0x2f60, 0x2009, 0x004d, 0x080c,
+	0x864c, 0xa085, 0x0001, 0x004e, 0x00ce, 0x00fe, 0x0005, 0x00f6,
+	0x00c6, 0x0046, 0x00c6, 0x080c, 0x85c7, 0x2c78, 0x00ce, 0x0178,
+	0x7e12, 0x2c00, 0x781a, 0x781f, 0x0003, 0x2021, 0x0005, 0x0481,
+	0x2f60, 0x2009, 0x004e, 0x080c, 0x864c, 0xa085, 0x0001, 0x004e,
+	0x00ce, 0x00fe, 0x0005, 0x00f6, 0x00c6, 0x0046, 0x00c6, 0x080c,
+	0x85c7, 0x2c78, 0x00ce, 0x01c0, 0x7e12, 0x2c00, 0x781a, 0x781f,
+	0x0003, 0x2021, 0x0004, 0x00a1, 0x2001, 0xb7a0, 0x2004, 0xd0fc,
+	0x0120, 0x2f60, 0x080c, 0x861d, 0x0028, 0x2f60, 0x2009, 0x0052,
+	0x080c, 0x864c, 0xa085, 0x0001, 0x004e, 0x00ce, 0x00fe, 0x0005,
+	0x0096, 0x0076, 0x0126, 0x2091, 0x8000, 0x080c, 0x514c, 0x0118,
+	0x2001, 0x9d55, 0x0028, 0x080c, 0x511c, 0x0158, 0x2001, 0x9d5b,
+	0x0006, 0xa00e, 0x2400, 0x080c, 0x54db, 0x080c, 0x5408, 0x000e,
+	0x0807, 0x2418, 0x080c, 0x702f, 0x62a0, 0x0086, 0x2041, 0x0001,
+	0x2039, 0x0001, 0x2608, 0x080c, 0x6e0e, 0x008e, 0x080c, 0x6d02,
+	0x2f08, 0x2648, 0x080c, 0xae82, 0x613c, 0x81ff, 0x090c, 0x6ec3,
+	0x080c, 0x7173, 0x012e, 0x007e, 0x009e, 0x0005, 0x00c6, 0x0126,
+	0x2091, 0x8000, 0x00c6, 0x080c, 0x85c7, 0x001e, 0x0188, 0x660a,
+	0x611a, 0x080c, 0xa027, 0x601f, 0x0001, 0x2d00, 0x6012, 0x2009,
+	0x001f, 0x080c, 0x864c, 0xa085, 0x0001, 0x012e, 0x00ce, 0x0005,
+	0xa006, 0x0cd8, 0x00c6, 0x0126, 0x2091, 0x8000, 0x00c6, 0x080c,
+	0x85c7, 0x001e, 0x0188, 0x660a, 0x611a, 0x080c, 0xa027, 0x601f,
+	0x0008, 0x2d00, 0x6012, 0x2009, 0x0021, 0x080c, 0x864c, 0xa085,
+	0x0001, 0x012e, 0x00ce, 0x0005, 0xa006, 0x0cd8, 0x00c6, 0x0126,
+	0x2091, 0x8000, 0x00c6, 0x080c, 0x85c7, 0x001e, 0x0188, 0x660a,
+	0x611a, 0x080c, 0xa027, 0x601f, 0x0001, 0x2d00, 0x6012, 0x2009,
+	0x003d, 0x080c, 0x864c, 0xa085, 0x0001, 0x012e, 0x00ce, 0x0005,
+	0xa006, 0x0cd8, 0x00c6, 0x0126, 0x2091, 0x8000, 0x00c6, 0x080c,
+	0x9ed6, 0x001e, 0x0180, 0x611a, 0x080c, 0xa027, 0x601f, 0x0001,
+	0x2d00, 0x6012, 0x2009, 0x0000, 0x080c, 0x864c, 0xa085, 0x0001,
+	0x012e, 0x00ce, 0x0005, 0xa006, 0x0cd8, 0x00c6, 0x0126, 0x2091,
+	0x8000, 0x00c6, 0x080c, 0x85c7, 0x001e, 0x0188, 0x660a, 0x611a,
+	0x080c, 0xa027, 0x601f, 0x0001, 0x2d00, 0x6012, 0x2009, 0x0044,
+	0x080c, 0x864c, 0xa085, 0x0001, 0x012e, 0x00ce, 0x0005, 0xa006,
+	0x0cd8, 0x0026, 0x00d6, 0x6218, 0x2268, 0x6a3c, 0x82ff, 0x0110,
+	0x8211, 0x6a3e, 0x00de, 0x002e, 0x0005, 0x0006, 0x6000, 0xa086,
+	0x0000, 0x0190, 0x6013, 0x0000, 0x601f, 0x0007, 0x2001, 0xb7b6,
+	0x2004, 0x0006, 0xa082, 0x0051, 0x000e, 0x0208, 0x8004, 0x6016,
+	0x080c, 0xb33a, 0x603f, 0x0000, 0x000e, 0x0005, 0x0066, 0x00c6,
+	0x00d6, 0x2031, 0xb553, 0x2634, 0xd6e4, 0x0128, 0x6618, 0x2660,
+	0x6e48, 0x080c, 0x50d5, 0x00de, 0x00ce, 0x006e, 0x0005, 0x0006,
+	0x0016, 0x6004, 0xa08e, 0x0002, 0x0140, 0xa08e, 0x0003, 0x0128,
+	0xa08e, 0x0004, 0x0110, 0xa085, 0x0001, 0x001e, 0x000e, 0x0005,
+	0x0006, 0x00d6, 0x6010, 0xa06d, 0x0148, 0x6834, 0xa086, 0x0139,
+	0x0138, 0x6838, 0xd0fc, 0x0110, 0xa006, 0x0010, 0xa085, 0x0001,
+	0x00de, 0x000e, 0x0005, 0x00c6, 0x0126, 0x2091, 0x8000, 0x00c6,
+	0x080c, 0x85c7, 0x001e, 0x0190, 0x611a, 0x080c, 0xa027, 0x601f,
+	0x0001, 0x2d00, 0x6012, 0x080c, 0x2c9c, 0x2009, 0x0028, 0x080c,
+	0x864c, 0xa085, 0x0001, 0x012e, 0x00ce, 0x0005, 0xa006, 0x0cd8,
+	0xa186, 0x0015, 0x1178, 0x2011, 0xb521, 0x2204, 0xa086, 0x0074,
+	0x1148, 0x080c, 0x8f98, 0x6003, 0x0001, 0x6007, 0x0029, 0x080c,
+	0x6cd3, 0x0020, 0x080c, 0x8c19, 0x080c, 0x861d, 0x0005, 0xa186,
+	0x0016, 0x1128, 0x2001, 0x0004, 0x080c, 0x4efd, 0x00e8, 0xa186,
+	0x0015, 0x11e8, 0x2011, 0xb521, 0x2204, 0xa086, 0x0014, 0x11b8,
+	0x00d6, 0x6018, 0x2068, 0x080c, 0x504b, 0x00de, 0x080c, 0x9051,
+	0x1170, 0x00d6, 0x6018, 0x2068, 0x6890, 0x00de, 0xa005, 0x0138,
+	0x2001, 0x0006, 0x080c, 0x4efd, 0x080c, 0x87a0, 0x0020, 0x080c,
+	0x8c19, 0x080c, 0x861d, 0x0005, 0x6848, 0xa086, 0x0005, 0x1108,
+	0x0009, 0x0005, 0x6850, 0xc0ad, 0x6852, 0x0005, 0x00e6, 0x0126,
+	0x2071, 0xb500, 0x2091, 0x8000, 0x7548, 0xa582, 0x0001, 0x0608,
+	0x704c, 0x2060, 0x6000, 0xa086, 0x0000, 0x0148, 0xace0, 0x0018,
+	0x705c, 0xac02, 0x1208, 0x0cb0, 0x2061, 0xbd00, 0x0c98, 0x6003,
+	0x0008, 0x8529, 0x754a, 0xaca8, 0x0018, 0x705c, 0xa502, 0x1230,
+	0x754e, 0xa085, 0x0001, 0x012e, 0x00ee, 0x0005, 0x704f, 0xbd00,
+	0x0cc0, 0xa006, 0x0cc0, 0x00e6, 0x2071, 0xbb8c, 0x7014, 0xd0e4,
+	0x0150, 0x6013, 0x0000, 0x6003, 0x0001, 0x6007, 0x0050, 0x080c,
+	0x6c8d, 0x080c, 0x7173, 0x00ee, 0x0005, 0x00c6, 0x00f6, 0x2c78,
+	0x080c, 0x5305, 0x00fe, 0x0120, 0x601c, 0xa084, 0x000f, 0x0013,
+	0x00ce, 0x0005, 0x99fe, 0x9f2d, 0x9f30, 0x9f33, 0xb127, 0xb142,
+	0xb145, 0x99fe, 0x99fe, 0x080c, 0x1515, 0xe000, 0xe000, 0x0005,
+	0xe000, 0xe000, 0x0005, 0x0009, 0x0005, 0x00f6, 0x2c78, 0x080c,
+	0x5305, 0x0538, 0x080c, 0x85c7, 0x1128, 0x2001, 0xb7b8, 0x2004,
+	0x783e, 0x00f8, 0x7818, 0x601a, 0x080c, 0xa027, 0x781c, 0xa086,
+	0x0003, 0x0128, 0x7808, 0x6036, 0x2f00, 0x603a, 0x0020, 0x7808,
+	0x603a, 0x2f00, 0x6036, 0x602a, 0x601f, 0x0001, 0x6007, 0x0035,
+	0x6003, 0x0001, 0x7950, 0x6152, 0x080c, 0x6c8d, 0x080c, 0x7173,
+	0x2f60, 0x00fe, 0x0005, 0x0016, 0x00f6, 0x682c, 0x6032, 0xa08e,
+	0x0001, 0x0138, 0xa086, 0x0005, 0x0140, 0xa006, 0x602a, 0x602e,
+	0x00a0, 0x6820, 0xc0f4, 0xc0d5, 0x6822, 0x6810, 0x2078, 0x787c,
+	0x6938, 0xa102, 0x7880, 0x6934, 0xa103, 0x1e78, 0x6834, 0x602a,
+	0x6838, 0xa084, 0xfffc, 0x683a, 0x602e, 0x2d00, 0x6036, 0x6808,
+	0x603a, 0x6918, 0x611a, 0x6950, 0x6152, 0x601f, 0x0001, 0x6007,
+	0x0039, 0x6003, 0x0001, 0x080c, 0x6c8d, 0x6803, 0x0002, 0x00fe,
+	0x001e, 0x0005, 0x00f6, 0x2c78, 0x080c, 0x5305, 0x1118, 0xa085,
+	0x0001, 0x0070, 0x6020, 0xd0f4, 0x1150, 0xc0f5, 0x6022, 0x6010,
+	0x2078, 0x7828, 0x603a, 0x782c, 0x6036, 0x080c, 0x194d, 0xa006,
+	0x00fe, 0x0005, 0x0006, 0x0016, 0x6004, 0xa08e, 0x0034, 0x01b8,
+	0xa08e, 0x0035, 0x01a0, 0xa08e, 0x0036, 0x0188, 0xa08e, 0x0037,
+	0x0170, 0xa08e, 0x0038, 0x0158, 0xa08e, 0x0039, 0x0140, 0xa08e,
+	0x003a, 0x0128, 0xa08e, 0x003b, 0x0110, 0xa085, 0x0001, 0x001e,
+	0x000e, 0x0005, 0x0006, 0x0016, 0x0026, 0x0036, 0x00e6, 0x2001,
+	0xb7b2, 0x200c, 0x8000, 0x2014, 0x2001, 0x0032, 0x080c, 0x6b40,
+	0x2001, 0xb7b6, 0x82ff, 0x1110, 0x2011, 0x0014, 0x2202, 0x2001,
+	0xb7b4, 0x200c, 0x8000, 0x2014, 0x2071, 0xb78e, 0x711a, 0x721e,
+	0x2001, 0x0064, 0x080c, 0x6b40, 0x2001, 0xb7b7, 0x82ff, 0x1110,
+	0x2011, 0x0014, 0x2202, 0x2009, 0xb7b8, 0xa280, 0x000a, 0x200a,
+	0x080c, 0x532a, 0x00ee, 0x003e, 0x002e, 0x001e, 0x000e, 0x0005,
+	0x0006, 0x00e6, 0x2001, 0xb7b6, 0x2003, 0x0028, 0x2001, 0xb7b7,
+	0x2003, 0x0014, 0x2071, 0xb78e, 0x701b, 0x0000, 0x701f, 0x07d0,
+	0x2001, 0xb7b8, 0x2003, 0x001e, 0x00ee, 0x000e, 0x0005, 0x00d6,
+	0x6054, 0xa06d, 0x0110, 0x080c, 0x160f, 0x00de, 0x0005, 0x0005,
+	0x00c6, 0x0126, 0x2091, 0x8000, 0x00c6, 0x080c, 0x85c7, 0x001e,
+	0x0178, 0x611a, 0x0ca1, 0x601f, 0x0001, 0x2d00, 0x6012, 0x2009,
+	0x0033, 0x080c, 0x864c, 0xa085, 0x0001, 0x012e, 0x00ce, 0x0005,
+	0xa006, 0x0cd8, 0x00d6, 0x00e6, 0x00f6, 0x2071, 0xb500, 0xa186,
+	0x0015, 0x1500, 0x7084, 0xa086, 0x0018, 0x11e0, 0x6010, 0x2068,
+	0x6a3c, 0xd2e4, 0x1160, 0x2c78, 0x080c, 0x7331, 0x01d8, 0x7070,
+	0x6a50, 0xa206, 0x1160, 0x7074, 0x6a54, 0xa206, 0x1140, 0x6218,
+	0xa290, 0x0028, 0x2214, 0x2009, 0x0000, 0x080c, 0x2ce1, 0x080c,
+	0x87a0, 0x0020, 0x080c, 0x8c19, 0x080c, 0x861d, 0x00fe, 0x00ee,
+	0x00de, 0x0005, 0x7054, 0x6a54, 0xa206, 0x0d48, 0x0c80, 0x00c6,
+	0x0126, 0x2091, 0x8000, 0x00c6, 0x080c, 0x85c7, 0x001e, 0x0180,
+	0x611a, 0x080c, 0xa027, 0x601f, 0x0001, 0x2d00, 0x6012, 0x2009,
+	0x0043, 0x080c, 0x864c, 0xa085, 0x0001, 0x012e, 0x00ce, 0x0005,
+	0xa006, 0x0cd8, 0x00d6, 0x00e6, 0x00f6, 0x2071, 0xb500, 0xa186,
+	0x0015, 0x11c0, 0x7084, 0xa086, 0x0004, 0x11a0, 0x6010, 0xa0e8,
+	0x000f, 0x2c78, 0x080c, 0x7331, 0x01a8, 0x7070, 0x6a08, 0xa206,
+	0x1130, 0x7074, 0x6a0c, 0xa206, 0x1110, 0x080c, 0x2c9c, 0x080c,
+	0x87a0, 0x0020, 0x080c, 0x8c19, 0x080c, 0x861d, 0x00fe, 0x00ee,
+	0x00de, 0x0005, 0x7054, 0x6a0c, 0xa206, 0x0d78, 0x0c80, 0x0016,
+	0x0026, 0x684c, 0xd0ac, 0x0178, 0x6914, 0x6a10, 0x2100, 0xa205,
+	0x0150, 0x6860, 0xa106, 0x1118, 0x685c, 0xa206, 0x0120, 0x6962,
+	0x6a5e, 0xa085, 0x0001, 0x002e, 0x001e, 0x0005, 0x00d6, 0x0036,
+	0x6310, 0x2368, 0x684a, 0x6952, 0xa29e, 0x4000, 0x11a0, 0x00c6,
+	0x6318, 0x2360, 0x2009, 0x0000, 0x6838, 0xd0f4, 0x1140, 0x080c,
+	0x524a, 0x1108, 0xc185, 0x6000, 0xd0bc, 0x0108, 0xc18d, 0x6a66,
+	0x696a, 0x00ce, 0x0080, 0x6a66, 0x3918, 0xa398, 0x0006, 0x231c,
+	0x686b, 0x0004, 0x6b72, 0x00c6, 0x6318, 0x2360, 0x6004, 0xa084,
+	0x00ff, 0x686e, 0x00ce, 0x080c, 0x5408, 0x6013, 0x0000, 0x003e,
+	0x00de, 0x0005, 0x00c6, 0x0026, 0x0016, 0xa186, 0x0035, 0x0110,
+	0x6a34, 0x0008, 0x6a28, 0x080c, 0x9c4a, 0x01f0, 0x2260, 0x611c,
+	0xa186, 0x0003, 0x0118, 0xa186, 0x0006, 0x1190, 0x6834, 0xa206,
+	0x0140, 0x6838, 0xa206, 0x1160, 0x6108, 0x6834, 0xa106, 0x1140,
+	0x0020, 0x6008, 0x6938, 0xa106, 0x1118, 0x6018, 0x6918, 0xa106,
+	0x001e, 0x002e, 0x00ce, 0x0005, 0xa085, 0x0001, 0x0cc8, 0x6944,
+	0xd1cc, 0x0198, 0xa18c, 0x00ff, 0xa18e, 0x0002, 0x1170, 0xad88,
+	0x001e, 0x210c, 0xa18c, 0x0f00, 0x810f, 0xa18e, 0x0001, 0x1128,
+	0x6810, 0x6914, 0xa115, 0x190c, 0x9483, 0x0005, 0x080c, 0x861d,
+	0x0804, 0x7173, 0x0066, 0x6000, 0xa0b2, 0x0010, 0x1a0c, 0x1515,
+	0x0013, 0x006e, 0x0005, 0xa16b, 0xa646, 0xa76c, 0xa16b, 0xa16b,
+	0xa16b, 0xa16b, 0xa16b, 0xa1a3, 0xa7f0, 0xa16b, 0xa16b, 0xa16b,
+	0xa16b, 0xa16b, 0xa16b, 0x080c, 0x1515, 0x0066, 0x6000, 0xa0b2,
+	0x0010, 0x1a0c, 0x1515, 0x0013, 0x006e, 0x0005, 0xa186, 0xac77,
+	0xa186, 0xa186, 0xa186, 0xa186, 0xa186, 0xa186, 0xac39, 0xacbf,
+	0xa186, 0xb26c, 0xb29c, 0xb26c, 0xb29c, 0xa186, 0x080c, 0x1515,
+	0x0066, 0x6000, 0xa0b2, 0x0010, 0x1a0c, 0x1515, 0x0013, 0x006e,
+	0x0005, 0xa1a1, 0xa940, 0xaa0d, 0xaa3a, 0xaabe, 0xa1a1, 0xabab,
+	0xab56, 0xa7fc, 0xac0f, 0xac24, 0xa1a1, 0xa1a1, 0xa1a1, 0xa1a1,
+	0xa1a1, 0x080c, 0x1515, 0xa1b2, 0x0080, 0x1a0c, 0x1515, 0x2100,
+	0xa1b2, 0x0040, 0x1a04, 0xa5ba, 0x0002, 0xa1ed, 0xa3b8, 0xa1ed,
+	0xa1ed, 0xa1ed, 0xa3bf, 0xa1ed, 0xa1ed, 0xa1ed, 0xa1ed, 0xa1ed,
+	0xa1ed, 0xa1ed, 0xa1ed, 0xa1ed, 0xa1ed, 0xa1ed, 0xa1ed, 0xa1ed,
+	0xa1ed, 0xa1ed, 0xa1ed, 0xa1ed, 0xa1ef, 0xa24d, 0xa25c, 0xa2aa,
+	0xa2c8, 0xa346, 0xa3a5, 0xa1ed, 0xa1ed, 0xa3c2, 0xa1ed, 0xa1ed,
+	0xa3d5, 0xa3e0, 0xa1ed, 0xa1ed, 0xa1ed, 0xa1ed, 0xa1ed, 0xa46b,
+	0xa1ed, 0xa1ed, 0xa47e, 0xa1ed, 0xa1ed, 0xa436, 0xa1ed, 0xa1ed,
+	0xa1ed, 0xa496, 0xa1ed, 0xa1ed, 0xa1ed, 0xa510, 0xa1ed, 0xa1ed,
+	0xa1ed, 0xa1ed, 0xa1ed, 0xa1ed, 0xa581, 0x080c, 0x1515, 0x080c,
+	0x5309, 0x1150, 0x2001, 0xb535, 0x2004, 0xd0cc, 0x1128, 0xa084,
+	0x0009, 0xa086, 0x0008, 0x1140, 0x6007, 0x0009, 0x602b, 0x0009,
+	0x6013, 0x0000, 0x0804, 0xa3b3, 0x080c, 0x52f9, 0x00e6, 0x00c6,
+	0x0036, 0x0026, 0x0016, 0x6218, 0x2270, 0x72a0, 0x0026, 0x2019,
+	0x0029, 0x080c, 0x6df5, 0x0076, 0x2039, 0x0000, 0x080c, 0x6d02,
+	0x2c08, 0x080c, 0xae82, 0x007e, 0x001e, 0x2e60, 0x080c, 0x51aa,
+	0x001e, 0x002e, 0x003e, 0x00ce, 0x00ee, 0x6618, 0x00c6, 0x2660,
+	0x080c, 0x4fb8, 0x00ce, 0xa6b0, 0x0001, 0x2634, 0xa684, 0x00ff,
+	0xa082, 0x0006, 0x0278, 0x080c, 0xadc6, 0x1904, 0xa2a4, 0x080c,
+	0xad66, 0x1120, 0x6007, 0x0008, 0x0804, 0xa3b3, 0x6007, 0x0009,
+	0x0804, 0xa3b3, 0x080c, 0xaf7b, 0x0128, 0x080c, 0xadc6, 0x0d78,
+	0x0804, 0xa2a4, 0x6013, 0x1900, 0x0c88, 0x080c, 0x2dbf, 0x1904,
+	0xa5b7, 0x6106, 0x080c, 0xad20, 0x6007, 0x0006, 0x0804, 0xa3b3,
+	0x6007, 0x0007, 0x0804, 0xa3b3, 0x080c, 0xb2d0, 0x1904, 0xa5b7,
+	0x080c, 0x2dbf, 0x1904, 0xa5b7, 0x00d6, 0x6618, 0x2668, 0x6e04,
+	0xa684, 0x00ff, 0xa082, 0x0006, 0x1220, 0x2001, 0x0001, 0x080c,
+	0x4eeb, 0xa6b4, 0xff00, 0x8637, 0xa686, 0x0006, 0x0188, 0xa686,
+	0x0004, 0x0170, 0x6e04, 0xa6b4, 0x00ff, 0xa686, 0x0006, 0x0140,
+	0xa686, 0x0004, 0x0128, 0xa686, 0x0005, 0x0110, 0x00de, 0x00e0,
+	0x080c, 0xae24, 0x11a0, 0xa686, 0x0006, 0x1150, 0x0026, 0x6218,
+	0xa290, 0x0028, 0x2214, 0x2009, 0x0000, 0x080c, 0x2ce1, 0x002e,
+	0x080c, 0x504b, 0x6007, 0x000a, 0x00de, 0x0804, 0xa3b3, 0x6007,
+	0x000b, 0x00de, 0x0804, 0xa3b3, 0x080c, 0x2c9c, 0x6007, 0x0001,
+	0x0804, 0xa3b3, 0x080c, 0xb2d0, 0x1904, 0xa5b7, 0x080c, 0x2dbf,
+	0x1904, 0xa5b7, 0x6618, 0x00d6, 0x2668, 0x6e04, 0x00de, 0xa686,
+	0x0707, 0x0d50, 0x0026, 0x6218, 0xa290, 0x0028, 0x2214, 0x2009,
+	0x0000, 0x080c, 0x2ce1, 0x002e, 0x6007, 0x000c, 0x0804, 0xa3b3,
+	0x080c, 0x5309, 0x1140, 0x2001, 0xb535, 0x2004, 0xa084, 0x0009,
+	0xa086, 0x0008, 0x1110, 0x0804, 0xa1fc, 0x080c, 0x52f9, 0x6618,
+	0xa6b0, 0x0001, 0x2634, 0xa684, 0x00ff, 0xa082, 0x0006, 0x06e8,
+	0x1138, 0x0026, 0x2001, 0x0006, 0x080c, 0x4f2a, 0x002e, 0x0050,
+	0xa6b4, 0xff00, 0x8637, 0xa686, 0x0004, 0x0120, 0xa686, 0x0006,
+	0x1904, 0xa2a4, 0x080c, 0xae31, 0x1120, 0x6007, 0x000e, 0x0804,
+	0xa3b3, 0x0046, 0x6418, 0xa4a0, 0x0028, 0x2424, 0xa4a4, 0x00ff,
+	0x8427, 0x0046, 0x080c, 0x2c9c, 0x004e, 0x0016, 0xa006, 0x2009,
+	0xb553, 0x210c, 0xd1a4, 0x0158, 0x2009, 0x0029, 0x080c, 0xb0e8,
+	0x6018, 0x00d6, 0x2068, 0x6800, 0xc0e5, 0x6802, 0x00de, 0x001e,
+	0x004e, 0x6007, 0x0001, 0x0804, 0xa3b3, 0x2001, 0x0001, 0x080c,
+	0x4eeb, 0x0156, 0x0016, 0x0026, 0x0036, 0x20a9, 0x0004, 0x2019,
+	0xb505, 0x2011, 0xbb90, 0x080c, 0x90da, 0x003e, 0x002e, 0x001e,
+	0x015e, 0xa005, 0x0168, 0xa6b4, 0xff00, 0x8637, 0xa682, 0x0004,
+	0x0a04, 0xa2a4, 0xa682, 0x0007, 0x0a04, 0xa2f2, 0x0804, 0xa2a4,
+	0x6013, 0x1900, 0x6007, 0x0009, 0x0804, 0xa3b3, 0x080c, 0x5309,
+	0x1140, 0x2001, 0xb535, 0x2004, 0xa084, 0x0009, 0xa086, 0x0008,
+	0x1110, 0x0804, 0xa1fc, 0x080c, 0x52f9, 0x6618, 0xa6b0, 0x0001,
+	0x2634, 0xa684, 0x00ff, 0xa082, 0x0006, 0x06b8, 0xa6b4, 0xff00,
+	0x8637, 0xa686, 0x0004, 0x0120, 0xa686, 0x0006, 0x1904, 0xa2a4,
+	0x080c, 0xae59, 0x1138, 0x080c, 0xad66, 0x1120, 0x6007, 0x0010,
+	0x0804, 0xa3b3, 0x0046, 0x6418, 0xa4a0, 0x0028, 0x2424, 0xa4a4,
+	0x00ff, 0x8427, 0x0046, 0x080c, 0x2c9c, 0x004e, 0x0016, 0xa006,
+	0x2009, 0xb553, 0x210c, 0xd1a4, 0x0158, 0x2009, 0x0029, 0x080c,
+	0xb0e8, 0x6018, 0x00d6, 0x2068, 0x6800, 0xc0e5, 0x6802, 0x00de,
+	0x001e, 0x004e, 0x6007, 0x0001, 0x00f0, 0x080c, 0xaf7b, 0x0140,
+	0xa6b4, 0xff00, 0x8637, 0xa686, 0x0006, 0x0950, 0x0804, 0xa2a4,
+	0x6013, 0x1900, 0x6007, 0x0009, 0x0070, 0x080c, 0x2dbf, 0x1904,
+	0xa5b7, 0x080c, 0xb2d0, 0x1904, 0xa5b7, 0x080c, 0xa5df, 0x1904,
+	0xa2a4, 0x6007, 0x0012, 0x6003, 0x0001, 0x080c, 0x6cd3, 0x0005,
+	0x6007, 0x0001, 0x6003, 0x0001, 0x080c, 0x6cd3, 0x0cc0, 0x6007,
+	0x0005, 0x0cc0, 0x080c, 0xb2d0, 0x1904, 0xa5b7, 0x080c, 0x2dbf,
+	0x1904, 0xa5b7, 0x080c, 0xa5df, 0x1904, 0xa2a4, 0x6007, 0x0020,
+	0x6003, 0x0001, 0x080c, 0x6cd3, 0x0005, 0x080c, 0x2dbf, 0x1904,
+	0xa5b7, 0x6007, 0x0023, 0x6003, 0x0001, 0x080c, 0x6cd3, 0x0005,
+	0x080c, 0xb2d0, 0x1904, 0xa5b7, 0x080c, 0x2dbf, 0x1904, 0xa5b7,
+	0x080c, 0xa5df, 0x1904, 0xa2a4, 0x0016, 0x0026, 0x2011, 0xbb91,
+	0x2214, 0xa286, 0xffff, 0x0190, 0x2c08, 0x080c, 0x9c4a, 0x01e0,
+	0x2260, 0x2011, 0xbb90, 0x2214, 0x6008, 0xa206, 0x11a8, 0x6018,
+	0xa190, 0x0006, 0x2214, 0xa206, 0x01e8, 0x0070, 0x2011, 0xbb90,
+	0x2214, 0x2c08, 0xa006, 0x080c, 0xb0ba, 0x11a0, 0x2011, 0xbb91,
+	0x2214, 0xa286, 0xffff, 0x01c0, 0x2160, 0x6007, 0x0026, 0x6013,
+	0x1700, 0x2011, 0xbb89, 0x2214, 0xa296, 0xffff, 0x1180, 0x6007,
+	0x0025, 0x0068, 0x601c, 0xa086, 0x0007, 0x1d70, 0x6004, 0xa086,
+	0x0024, 0x1110, 0x080c, 0x861d, 0x2160, 0x6007, 0x0025, 0x6003,
+	0x0001, 0x080c, 0x6cd3, 0x002e, 0x001e, 0x0005, 0x2001, 0x0001,
+	0x080c, 0x4eeb, 0x0156, 0x0016, 0x0026, 0x0036, 0x20a9, 0x0004,
+	0x2019, 0xb505, 0x2011, 0xbb96, 0x080c, 0x90da, 0x003e, 0x002e,
+	0x001e, 0x015e, 0x0120, 0x6007, 0x0031, 0x0804, 0xa3b3, 0x080c,
+	0x8df6, 0x080c, 0x5acf, 0x11b0, 0x0006, 0x0026, 0x0036, 0x080c,
+	0x5aeb, 0x1158, 0x2001, 0xb79f, 0x2003, 0x0001, 0x2001, 0xb500,
+	0x2003, 0x0001, 0x080c, 0x5a07, 0x0010, 0x080c, 0x5aa6, 0x003e,
+	0x002e, 0x000e, 0x0005, 0x080c, 0x2dbf, 0x1904, 0xa5b7, 0x080c,
+	0xa5df, 0x1904, 0xa2a4, 0x6106, 0x080c, 0xa5fb, 0x6007, 0x002b,
+	0x0804, 0xa3b3, 0x6007, 0x002c, 0x0804, 0xa3b3, 0x080c, 0xb2d0,
+	0x1904, 0xa5b7, 0x080c, 0x2dbf, 0x1904, 0xa5b7, 0x080c, 0xa5df,
+	0x1904, 0xa2a4, 0x6106, 0x080c, 0xa5ff, 0x1120, 0x6007, 0x002e,
+	0x0804, 0xa3b3, 0x6007, 0x002f, 0x0804, 0xa3b3, 0x080c, 0x2dbf,
+	0x1904, 0xa5b7, 0x00e6, 0x00d6, 0x00c6, 0x6018, 0xa080, 0x0001,
+	0x200c, 0xa184, 0x00ff, 0xa086, 0x0006, 0x0158, 0xa184, 0xff00,
+	0x8007, 0xa086, 0x0006, 0x0128, 0x00ce, 0x00de, 0x00ee, 0x0804,
+	0xa3b8, 0x2001, 0xb572, 0x2004, 0xd0e4, 0x0904, 0xa50d, 0x2071,
+	0xbb8c, 0x7010, 0x6036, 0x7014, 0x603a, 0x7108, 0x720c, 0x2001,
+	0xb553, 0x2004, 0xd0a4, 0x0140, 0x6018, 0x2068, 0x6810, 0xa106,
+	0x1118, 0x6814, 0xa206, 0x01f8, 0x2001, 0xb553, 0x2004, 0xd0ac,
+	0x1590, 0x2069, 0xb500, 0x6874, 0xa206, 0x1568, 0x6870, 0xa106,
+	0x1550, 0x7210, 0x080c, 0x9c4a, 0x0558, 0x080c, 0xb154, 0x0540,
+	0x622a, 0x6007, 0x0036, 0x6003, 0x0001, 0x080c, 0x6c8d, 0x00ce,
+	0x00de, 0x00ee, 0x0005, 0x7214, 0xa286, 0xffff, 0x0150, 0x080c,
+	0x9c4a, 0x01b0, 0xa280, 0x0002, 0x2004, 0x7110, 0xa106, 0x1180,
+	0x0c08, 0x7210, 0x2c08, 0xa085, 0x0001, 0x080c, 0xb0ba, 0x2c10,
+	0x2160, 0x0130, 0x08b8, 0x6007, 0x0037, 0x6013, 0x1500, 0x08d8,
+	0x6007, 0x0037, 0x6013, 0x1700, 0x08b0, 0x6007, 0x0012, 0x0898,
+	0x080c, 0x2dbf, 0x1904, 0xa5b7, 0x6018, 0xa080, 0x0001, 0x2004,
+	0xa084, 0xff00, 0x8007, 0xa086, 0x0006, 0x1904, 0xa3b8, 0x00e6,
+	0x00d6, 0x00c6, 0x2001, 0xb572, 0x2004, 0xd0e4, 0x0904, 0xa579,
+	0x2069, 0xb500, 0x2071, 0xbb8c, 0x7008, 0x6036, 0x720c, 0x623a,
+	0xa286, 0xffff, 0x1150, 0x7208, 0x00c6, 0x2c08, 0xa085, 0x0001,
+	0x080c, 0xb0ba, 0x2c10, 0x00ce, 0x0588, 0x080c, 0x9c4a, 0x0570,
+	0x00c6, 0x0026, 0x2260, 0x080c, 0x991d, 0x002e, 0x00ce, 0x7118,
+	0xa18c, 0xff00, 0x810f, 0xa186, 0x0001, 0x0158, 0xa186, 0x0005,
+	0x0118, 0xa186, 0x0007, 0x1178, 0xa280, 0x0004, 0x2004, 0xa005,
+	0x0150, 0x0056, 0x7510, 0x7614, 0x080c, 0xb16b, 0x005e, 0x00ce,
+	0x00de, 0x00ee, 0x0005, 0x6007, 0x003b, 0x602b, 0x0009, 0x6013,
+	0x2a00, 0x6003, 0x0001, 0x080c, 0x6c8d, 0x0c88, 0x6007, 0x003b,
+	0x602b, 0x0009, 0x6013, 0x1700, 0x6003, 0x0001, 0x080c, 0x6c8d,
+	0x0c30, 0x6007, 0x003b, 0x602b, 0x000b, 0x6013, 0x0000, 0x0804,
+	0xa4e3, 0x00e6, 0x0026, 0x080c, 0x5309, 0x0558, 0x080c, 0x52f9,
+	0x080c, 0xb34b, 0x1520, 0x2071, 0xb500, 0x70d4, 0xc085, 0x70d6,
+	0x00f6, 0x2079, 0x0100, 0x72a0, 0xa284, 0x00ff, 0x7072, 0x78e6,
+	0xa284, 0xff00, 0x7274, 0xa205, 0x7076, 0x78ea, 0x00fe, 0x70df,
+	0x0000, 0x2001, 0xb553, 0x2004, 0xd0a4, 0x0120, 0x2011, 0xb7f9,
+	0x2013, 0x07d0, 0xd0ac, 0x1128, 0x080c, 0x2ab8, 0x0010, 0x080c,
+	0xb377, 0x002e, 0x00ee, 0x080c, 0x861d, 0x0804, 0xa3b7, 0x080c,
+	0x861d, 0x0005, 0x2600, 0x0002, 0xa5c5, 0xa5c5, 0xa5c5, 0xa5c5,
+	0xa5c5, 0xa5c7, 0xa5c5, 0xa5c5, 0xa5c5, 0x080c, 0x1515, 0x080c,
+	0xb2d0, 0x1d68, 0x080c, 0x2dbf, 0x1d50, 0x0089, 0x1138, 0x6007,
+	0x0045, 0x6003, 0x0001, 0x080c, 0x6cd3, 0x0005, 0x080c, 0x2c9c,
+	0x6007, 0x0001, 0x6003, 0x0001, 0x080c, 0x6cd3, 0x0005, 0x00d6,
+	0x0066, 0x6618, 0x2668, 0x6e04, 0xa6b4, 0xff00, 0x8637, 0xa686,
+	0x0006, 0x0170, 0xa686, 0x0004, 0x0158, 0x6e04, 0xa6b4, 0x00ff,
+	0xa686, 0x0006, 0x0128, 0xa686, 0x0004, 0x0110, 0xa085, 0x0001,
+	0x006e, 0x00de, 0x0005, 0x00d6, 0x0449, 0x00de, 0x0005, 0x00d6,
+	0x0491, 0x11f0, 0x680c, 0xa08c, 0xff00, 0x6820, 0xa084, 0x00ff,
+	0xa115, 0x6212, 0x6824, 0x602a, 0xd1e4, 0x0118, 0x2009, 0x0001,
+	0x0060, 0xd1ec, 0x0168, 0x6920, 0xa18c, 0x00ff, 0x6824, 0x080c,
+	0x281d, 0x1130, 0x2110, 0x2009, 0x0000, 0x080c, 0x2ce1, 0x0018,
+	0xa085, 0x0001, 0x0008, 0xa006, 0x00de, 0x0005, 0x2069, 0xbb8d,
+	0x6800, 0xa082, 0x0010, 0x1228, 0x6013, 0x0000, 0xa085, 0x0001,
+	0x0008, 0xa006, 0x0005, 0x6013, 0x0000, 0x2069, 0xbb8c, 0x6808,
+	0xa084, 0xff00, 0xa086, 0x0800, 0x1140, 0x6800, 0xa084, 0x00ff,
+	0xa08e, 0x0014, 0x0110, 0xa08e, 0x0010, 0x0005, 0x6004, 0xa0b2,
+	0x0080, 0x1a0c, 0x1515, 0xa1b6, 0x0013, 0x1130, 0x2008, 0xa1b2,
+	0x0040, 0x1a04, 0xa746, 0x0092, 0xa1b6, 0x0027, 0x0120, 0xa1b6,
+	0x0014, 0x190c, 0x1515, 0x2001, 0x0007, 0x080c, 0x4f2a, 0x080c,
+	0x7090, 0x080c, 0x9e1d, 0x080c, 0x7173, 0x0005, 0xa6a6, 0xa6a8,
+	0xa6a6, 0xa6a6, 0xa6a6, 0xa6a8, 0xa6ba, 0xa73f, 0xa70a, 0xa73f,
+	0xa71b, 0xa73f, 0xa6ba, 0xa73f, 0xa737, 0xa73f, 0xa737, 0xa73f,
+	0xa73f, 0xa6a6, 0xa6a6, 0xa6a6, 0xa6a6, 0xa6a6, 0xa6a6, 0xa6a6,
+	0xa6a6, 0xa6a6, 0xa6a6, 0xa6a6, 0xa6a8, 0xa6a6, 0xa73f, 0xa6a6,
+	0xa6a6, 0xa73f, 0xa6a6, 0xa73c, 0xa73f, 0xa6a6, 0xa6a6, 0xa6a6,
+	0xa6a6, 0xa73f, 0xa73f, 0xa6a6, 0xa73f, 0xa73f, 0xa6a6, 0xa6b4,
+	0xa6a6, 0xa6a6, 0xa6a6, 0xa6a6, 0xa73b, 0xa73f, 0xa6a6, 0xa6a6,
+	0xa73f, 0xa73f, 0xa6a6, 0xa6a6, 0xa6a6, 0xa6a6, 0x080c, 0x1515,
+	0x080c, 0x7090, 0x2001, 0xb7b6, 0x2004, 0x6016, 0x6003, 0x0002,
+	0x080c, 0x7173, 0x0804, 0xa745, 0x2001, 0x0000, 0x080c, 0x4eeb,
+	0x0804, 0xa73f, 0x00f6, 0x2079, 0xb552, 0x7804, 0x00fe, 0xd0ac,
+	0x1904, 0xa73f, 0x2001, 0x0000, 0x080c, 0x4eeb, 0x6018, 0xa080,
+	0x0004, 0x2004, 0xa086, 0x00ff, 0x1140, 0x00f6, 0x2079, 0xb500,
+	0x7898, 0x8000, 0x789a, 0x00fe, 0x00e0, 0x00c6, 0x6018, 0x2060,
+	0x6000, 0xd0f4, 0x1140, 0x6010, 0xa005, 0x0128, 0x00ce, 0x080c,
+	0x3f3e, 0x0804, 0xa73f, 0x00ce, 0x2001, 0xb500, 0x2004, 0xa086,
+	0x0002, 0x1138, 0x00f6, 0x2079, 0xb500, 0x7898, 0x8000, 0x789a,
+	0x00fe, 0x2001, 0x0002, 0x080c, 0x4efd, 0x080c, 0x7090, 0x601f,
+	0x0001, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x6cd3, 0x080c,
+	0x7173, 0x00c6, 0x6118, 0x2160, 0x2009, 0x0001, 0x080c, 0x69a8,
+	0x00ce, 0x04d8, 0x6618, 0x00d6, 0x2668, 0x6e04, 0x00de, 0xa6b4,
+	0xff00, 0x8637, 0xa686, 0x0006, 0x0550, 0xa686, 0x0004, 0x0538,
+	0x2001, 0x0004, 0x0410, 0x2001, 0xb500, 0x2004, 0xa086, 0x0003,
+	0x1110, 0x080c, 0x3f3e, 0x2001, 0x0006, 0x04a1, 0x6618, 0x00d6,
+	0x2668, 0x6e04, 0x00de, 0xa6b4, 0xff00, 0x8637, 0xa686, 0x0006,
+	0x0170, 0x2001, 0x0006, 0x0048, 0x2001, 0x0004, 0x0030, 0x2001,
+	0x0006, 0x0401, 0x0020, 0x0018, 0x0010, 0x080c, 0x4f2a, 0x080c,
+	0x7090, 0x080c, 0x861d, 0x080c, 0x7173, 0x0005, 0x2600, 0x0002,
+	0xa751, 0xa751, 0xa751, 0xa751, 0xa751, 0xa753, 0xa751, 0xa751,
+	0xa751, 0x080c, 0x1515, 0x080c, 0x7090, 0x080c, 0x861d, 0x080c,
+	0x7173, 0x0005, 0x0016, 0x00d6, 0x6118, 0x2168, 0x6900, 0xd184,
+	0x0140, 0x080c, 0x4efd, 0x2001, 0x0000, 0x080c, 0x4eeb, 0x080c,
+	0x2cc2, 0x00de, 0x001e, 0x0005, 0x00d6, 0x6618, 0x2668, 0x6804,
+	0xa084, 0xff00, 0x8007, 0x00de, 0xa0b2, 0x000c, 0x1a0c, 0x1515,
+	0xa1b6, 0x0015, 0x1110, 0x003b, 0x0028, 0xa1b6, 0x0016, 0x190c,
+	0x1515, 0x006b, 0x0005, 0x8cdf, 0x8cdf, 0x8cdf, 0x8cdf, 0x8cdf,
+	0x8cdf, 0xa7dc, 0xa79b, 0x8cdf, 0x8cdf, 0x8cdf, 0x8cdf, 0x8cdf,
+	0x8cdf, 0x8cdf, 0x8cdf, 0x8cdf, 0x8cdf, 0xa7dc, 0xa7e3, 0x8cdf,
+	0x8cdf, 0x8cdf, 0x8cdf, 0x00f6, 0x2079, 0xb552, 0x7804, 0xd0ac,
+	0x11e0, 0x6018, 0xa07d, 0x01c8, 0x7800, 0xd0f4, 0x1118, 0x7810,
+	0xa005, 0x1198, 0x2001, 0x0000, 0x080c, 0x4eeb, 0x2001, 0x0002,
+	0x080c, 0x4efd, 0x601f, 0x0001, 0x6003, 0x0001, 0x6007, 0x0002,
+	0x080c, 0x6cd3, 0x080c, 0x7173, 0x00e8, 0x2011, 0xbb83, 0x2204,
+	0x8211, 0x220c, 0x080c, 0x281d, 0x11a8, 0x00c6, 0x080c, 0x4fa9,
+	0x0120, 0x00ce, 0x080c, 0x861d, 0x0068, 0x6010, 0x0006, 0x6014,
+	0x0006, 0x080c, 0x4c0b, 0x000e, 0x6016, 0x000e, 0x6012, 0x00ce,
+	0x080c, 0x861d, 0x00fe, 0x0005, 0x6604, 0xa6b6, 0x001e, 0x1110,
+	0x080c, 0x861d, 0x0005, 0x080c, 0x8f95, 0x1138, 0x6003, 0x0001,
+	0x6007, 0x0001, 0x080c, 0x6cd3, 0x0010, 0x080c, 0x861d, 0x0005,
+	0x6004, 0xa08a, 0x0080, 0x1a0c, 0x1515, 0x080c, 0x7090, 0x080c,
+	0x9e1d, 0x080c, 0x7173, 0x0005, 0xa182, 0x0040, 0x0002, 0xa812,
+	0xa812, 0xa812, 0xa812, 0xa814, 0xa812, 0xa812, 0xa812, 0xa812,
+	0xa812, 0xa812, 0xa812, 0xa812, 0xa812, 0xa812, 0xa812, 0xa812,
+	0xa812, 0xa812, 0x080c, 0x1515, 0x00d6, 0x00e6, 0x00f6, 0x0156,
+	0x0046, 0x0026, 0x6218, 0xa280, 0x002b, 0x2004, 0xa005, 0x0120,
+	0x2021, 0x0000, 0x080c, 0xb31c, 0x6106, 0x2071, 0xbb80, 0x7444,
+	0xa4a4, 0xff00, 0x0904, 0xa878, 0xa486, 0x2000, 0x1130, 0x2009,
+	0x0001, 0x2011, 0x0200, 0x080c, 0x6b1a, 0x080c, 0x15f8, 0x090c,
+	0x1515, 0x6003, 0x0007, 0x2d00, 0x6837, 0x010d, 0x6803, 0x0000,
+	0x683b, 0x0000, 0x6c5a, 0x2c00, 0x685e, 0x6008, 0x68b2, 0x6018,
+	0x2078, 0x78a0, 0x8007, 0x7130, 0x694a, 0x0016, 0xa084, 0xff00,
+	0x6846, 0x684f, 0x0000, 0x6853, 0x0000, 0x6857, 0x0036, 0x080c,
+	0x5408, 0x001e, 0xa486, 0x2000, 0x1130, 0x2019, 0x0017, 0x080c,
+	0xb065, 0x0804, 0xa8d5, 0xa486, 0x0400, 0x1130, 0x2019, 0x0002,
+	0x080c, 0xb017, 0x0804, 0xa8d5, 0xa486, 0x0200, 0x1110, 0x080c,
+	0xaffc, 0xa486, 0x1000, 0x1110, 0x080c, 0xb04a, 0x0804, 0xa8d5,
+	0x2069, 0xb874, 0x6a00, 0xd284, 0x0904, 0xa93c, 0xa284, 0x0300,
+	0x1904, 0xa935, 0x6804, 0xa005, 0x0904, 0xa91d, 0x2d78, 0x6003,
+	0x0007, 0x080c, 0x15df, 0x0904, 0xa8dc, 0x7800, 0xd08c, 0x1118,
+	0x7804, 0x8001, 0x7806, 0x6013, 0x0000, 0x6803, 0x0000, 0x6837,
+	0x0116, 0x683b, 0x0000, 0x6008, 0x68b2, 0x2c00, 0x684a, 0x6018,
+	0x2078, 0x78a0, 0x8007, 0x7130, 0x6986, 0x6846, 0x7928, 0x698a,
+	0x792c, 0x698e, 0x7930, 0x6992, 0x7934, 0x6996, 0x6853, 0x003d,
+	0x7244, 0xa294, 0x0003, 0xa286, 0x0002, 0x1118, 0x684f, 0x0040,
+	0x0040, 0xa286, 0x0001, 0x1118, 0x684f, 0x0080, 0x0010, 0x684f,
+	0x0000, 0x20a9, 0x000a, 0x2001, 0xbb90, 0xad90, 0x0015, 0x200c,
+	0x810f, 0x2112, 0x8000, 0x8210, 0x1f04, 0xa8c7, 0x200c, 0x6982,
+	0x8000, 0x200c, 0x697e, 0x080c, 0x5408, 0x002e, 0x004e, 0x015e,
+	0x00fe, 0x00ee, 0x00de, 0x0005, 0x2001, 0xb50e, 0x2004, 0xd084,
+	0x0120, 0x080c, 0x15f8, 0x1904, 0xa88d, 0x6013, 0x0100, 0x6003,
+	0x0001, 0x6007, 0x0041, 0x080c, 0x6c8d, 0x080c, 0x7173, 0x0c28,
+	0x2069, 0xbb92, 0x2d04, 0xa084, 0xff00, 0xa086, 0x1200, 0x11a8,
+	0x2069, 0xbb80, 0x686c, 0xa084, 0x00ff, 0x0016, 0x6110, 0xa18c,
+	0x0700, 0xa10d, 0x6112, 0x001e, 0x6003, 0x0001, 0x6007, 0x0043,
+	0x080c, 0x6c8d, 0x080c, 0x7173, 0x0840, 0x6868, 0x602a, 0x686c,
+	0x602e, 0x6013, 0x0200, 0x6003, 0x0001, 0x6007, 0x0041, 0x080c,
+	0x6c8d, 0x080c, 0x7173, 0x0804, 0xa8d5, 0x2001, 0xb50d, 0x2004,
+	0xd0ec, 0x0120, 0x2011, 0x8049, 0x080c, 0x3ecc, 0x6013, 0x0300,
+	0x0010, 0x6013, 0x0100, 0x6003, 0x0001, 0x6007, 0x0041, 0x080c,
+	0x6c8d, 0x080c, 0x7173, 0x0804, 0xa8d5, 0x6013, 0x0500, 0x0c98,
+	0x6013, 0x0600, 0x0804, 0xa8f0, 0x6013, 0x0200, 0x0804, 0xa8f0,
+	0xa186, 0x0013, 0x1170, 0x6004, 0xa08a, 0x0040, 0x0a0c, 0x1515,
+	0xa08a, 0x0053, 0x1a0c, 0x1515, 0xa082, 0x0040, 0x2008, 0x0804,
+	0xa9ca, 0xa186, 0x0051, 0x0138, 0xa186, 0x0047, 0x11d8, 0x6004,
+	0xa086, 0x0041, 0x0518, 0x2001, 0x0109, 0x2004, 0xd084, 0x01f0,
+	0x0126, 0x2091, 0x2800, 0x0006, 0x0016, 0x0026, 0x080c, 0x6b74,
+	0x002e, 0x001e, 0x000e, 0x012e, 0x6000, 0xa086, 0x0002, 0x1170,
+	0x0804, 0xaa0d, 0xa186, 0x0027, 0x0120, 0xa186, 0x0014, 0x190c,
+	0x1515, 0x6004, 0xa082, 0x0040, 0x2008, 0x001a, 0x080c, 0x8663,
+	0x0005, 0xa994, 0xa996, 0xa996, 0xa9ba, 0xa994, 0xa994, 0xa994,
+	0xa994, 0xa994, 0xa994, 0xa994, 0xa994, 0xa994, 0xa994, 0xa994,
+	0xa994, 0xa994, 0xa994, 0xa994, 0x080c, 0x1515, 0x080c, 0x7090,
+	0x080c, 0x7173, 0x0036, 0x00d6, 0x6010, 0xa06d, 0x01c0, 0xad84,
+	0xf000, 0x01a8, 0x6003, 0x0002, 0x6018, 0x2004, 0xd0bc, 0x1178,
+	0x2019, 0x0004, 0x080c, 0xb099, 0x6013, 0x0000, 0x6014, 0xa005,
+	0x1120, 0x2001, 0xb7b7, 0x2004, 0x6016, 0x6003, 0x0007, 0x00de,
+	0x003e, 0x0005, 0x00d6, 0x080c, 0x7090, 0x080c, 0x7173, 0x080c,
+	0x9c5a, 0x0120, 0x6010, 0x2068, 0x080c, 0x160f, 0x080c, 0x9e1d,
+	0x00de, 0x0005, 0x0002, 0xa9de, 0xa9fb, 0xa9e7, 0xaa07, 0xa9de,
+	0xa9de, 0xa9de, 0xa9de, 0xa9de, 0xa9de, 0xa9de, 0xa9de, 0xa9de,
+	0xa9de, 0xa9de, 0xa9de, 0xa9de, 0xa9de, 0xa9de, 0x080c, 0x1515,
+	0x6010, 0xa088, 0x0013, 0x2104, 0xa085, 0x0400, 0x200a, 0x080c,
+	0x7090, 0x6010, 0xa080, 0x0013, 0x2004, 0xd0b4, 0x0138, 0x6003,
+	0x0007, 0x2009, 0x0043, 0x080c, 0x864c, 0x0010, 0x6003, 0x0002,
+	0x080c, 0x7173, 0x0005, 0x080c, 0x7090, 0x080c, 0xb2d7, 0x1120,
+	0x080c, 0x6aef, 0x080c, 0x861d, 0x080c, 0x7173, 0x0005, 0x080c,
+	0x7090, 0x2009, 0x0041, 0x0804, 0xab56, 0xa182, 0x0040, 0x0002,
+	0xaa23, 0xaa25, 0xaa23, 0xaa23, 0xaa23, 0xaa23, 0xaa23, 0xaa26,
+	0xaa23, 0xaa23, 0xaa23, 0xaa23, 0xaa23, 0xaa23, 0xaa23, 0xaa23,
+	0xaa23, 0xaa31, 0xaa23, 0x080c, 0x1515, 0x0005, 0x6003, 0x0004,
+	0x6110, 0x20e1, 0x0005, 0x3d18, 0x3e20, 0x2c10, 0x080c, 0x185e,
+	0x0005, 0x00d6, 0x080c, 0x6aef, 0x00de, 0x080c, 0xb33a, 0x080c,
+	0x861d, 0x0005, 0xa182, 0x0040, 0x0002, 0xaa50, 0xaa50, 0xaa50,
+	0xaa50, 0xaa50, 0xaa50, 0xaa50, 0xaa52, 0xaa50, 0xaa55, 0xaa8e,
+	0xaa50, 0xaa50, 0xaa50, 0xaa50, 0xaa8e, 0xaa50, 0xaa50, 0xaa50,
+	0x080c, 0x1515, 0x080c, 0x8663, 0x0005, 0x2001, 0xb572, 0x2004,
+	0xd0e4, 0x0158, 0x2001, 0x0100, 0x2004, 0xa082, 0x0005, 0x0228,
+	0x2001, 0x011f, 0x2004, 0x6036, 0x0010, 0x6037, 0x0000, 0x080c,
+	0x7126, 0x080c, 0x7230, 0x6010, 0x00d6, 0x2068, 0x684c, 0xd0fc,
+	0x0150, 0xa08c, 0x0003, 0xa18e, 0x0002, 0x0168, 0x2009, 0x0041,
+	0x00de, 0x0804, 0xab56, 0x6003, 0x0007, 0x6017, 0x0000, 0x080c,
+	0x6aef, 0x00de, 0x0005, 0x080c, 0xb2d7, 0x0110, 0x00de, 0x0005,
+	0x080c, 0x6aef, 0x080c, 0x861d, 0x00de, 0x0ca0, 0x0036, 0x080c,
+	0x7126, 0x080c, 0x7230, 0x6010, 0x00d6, 0x2068, 0x6018, 0x2004,
+	0xd0bc, 0x0188, 0x684c, 0xa084, 0x0003, 0xa086, 0x0002, 0x0140,
+	0x687c, 0x632c, 0xa31a, 0x632e, 0x6880, 0x6328, 0xa31b, 0x632a,
+	0x6003, 0x0002, 0x0080, 0x2019, 0x0004, 0x080c, 0xb099, 0x6014,
+	0xa005, 0x1128, 0x2001, 0xb7b7, 0x2004, 0x8003, 0x6016, 0x6013,
+	0x0000, 0x6003, 0x0007, 0x00de, 0x003e, 0x0005, 0xa186, 0x0013,
+	0x1150, 0x6004, 0xa086, 0x0042, 0x190c, 0x1515, 0x080c, 0x7090,
+	0x080c, 0x7173, 0x0005, 0xa186, 0x0027, 0x0118, 0xa186, 0x0014,
+	0x1180, 0x6004, 0xa086, 0x0042, 0x190c, 0x1515, 0x2001, 0x0007,
+	0x080c, 0x4f2a, 0x080c, 0x7090, 0x080c, 0x9e1d, 0x080c, 0x7173,
+	0x0005, 0xa182, 0x0040, 0x0002, 0xaaf7, 0xaaf7, 0xaaf7, 0xaaf7,
+	0xaaf7, 0xaaf7, 0xaaf7, 0xaaf9, 0xab05, 0xaaf7, 0xaaf7, 0xaaf7,
+	0xaaf7, 0xaaf7, 0xaaf7, 0xaaf7, 0xaaf7, 0xaaf7, 0xaaf7, 0x080c,
+	0x1515, 0x0036, 0x0046, 0x20e1, 0x0005, 0x3d18, 0x3e20, 0x2c10,
+	0x080c, 0x185e, 0x004e, 0x003e, 0x0005, 0x6010, 0x00d6, 0x2068,
+	0x6810, 0x6a14, 0x0006, 0x0046, 0x0056, 0x6c7c, 0xa422, 0x6d80,
+	0x2200, 0xa52b, 0x602c, 0xa420, 0x642e, 0x6028, 0xa529, 0x652a,
+	0x005e, 0x004e, 0x000e, 0xa20d, 0x1178, 0x684c, 0xd0fc, 0x0120,
+	0x2009, 0x0041, 0x00de, 0x0490, 0x6003, 0x0007, 0x6017, 0x0000,
+	0x080c, 0x6aef, 0x00de, 0x0005, 0x0006, 0x00f6, 0x2c78, 0x080c,
+	0x5305, 0x00fe, 0x000e, 0x0120, 0x6003, 0x0002, 0x00de, 0x0005,
+	0x2009, 0xb50d, 0x210c, 0xd19c, 0x0118, 0x6003, 0x0007, 0x0010,
+	0x6003, 0x0006, 0x0021, 0x080c, 0x6af1, 0x00de, 0x0005, 0xd2fc,
+	0x0140, 0x8002, 0x8000, 0x8212, 0xa291, 0x0000, 0x2009, 0x0009,
+	0x0010, 0x2009, 0x0015, 0x6a6a, 0x6866, 0x0005, 0xa182, 0x0040,
+	0x0208, 0x0062, 0xa186, 0x0013, 0x0120, 0xa186, 0x0014, 0x190c,
+	0x1515, 0x6020, 0xd0dc, 0x090c, 0x1515, 0x0005, 0xab79, 0xab80,
+	0xab8c, 0xab98, 0xab79, 0xab79, 0xab79, 0xaba7, 0xab79, 0xab7b,
+	0xab7b, 0xab79, 0xab79, 0xab79, 0xab79, 0xab7b, 0xab79, 0xab7b,
+	0xab79, 0x080c, 0x1515, 0x6020, 0xd0dc, 0x090c, 0x1515, 0x0005,
+	0x6003, 0x0001, 0x6106, 0x080c, 0x6c8d, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x7173, 0x012e, 0x0005, 0x6003, 0x0001, 0x6106, 0x080c,
+	0x6c8d, 0x0126, 0x2091, 0x8000, 0x080c, 0x7173, 0x012e, 0x0005,
+	0x6003, 0x0003, 0x6106, 0x2c10, 0x080c, 0x1fa9, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x6cf0, 0x080c, 0x7230, 0x012e, 0x0005, 0xa016,
+	0x080c, 0x185e, 0x0005, 0x0126, 0x2091, 0x8000, 0x0036, 0x00d6,
+	0xa182, 0x0040, 0x0023, 0x00de, 0x003e, 0x012e, 0x0005, 0xabc7,
+	0xabc9, 0xabdb, 0xabf6, 0xabc7, 0xabc7, 0xabc7, 0xac0b, 0xabc7,
+	0xabc7, 0xabc7, 0xabc7, 0xabc7, 0xabc7, 0xabc7, 0xabc7, 0x080c,
+	0x1515, 0x6010, 0x2068, 0x684c, 0xd0fc, 0x01f8, 0xa09c, 0x0003,
+	0xa39e, 0x0003, 0x01d0, 0x6003, 0x0001, 0x6106, 0x080c, 0x6c8d,
+	0x080c, 0x7173, 0x0498, 0x6010, 0x2068, 0x684c, 0xd0fc, 0x0168,
+	0xa09c, 0x0003, 0xa39e, 0x0003, 0x0140, 0x6003, 0x0001, 0x6106,
+	0x080c, 0x6c8d, 0x080c, 0x7173, 0x0408, 0x6013, 0x0000, 0x6017,
+	0x0000, 0x2019, 0x0004, 0x080c, 0xb099, 0x00c0, 0x6010, 0x2068,
+	0x684c, 0xd0fc, 0x0d90, 0xa09c, 0x0003, 0xa39e, 0x0003, 0x0d68,
+	0x6003, 0x0003, 0x6106, 0x2c10, 0x080c, 0x1fa9, 0x080c, 0x6cf0,
+	0x080c, 0x7230, 0x0018, 0xa016, 0x080c, 0x185e, 0x0005, 0x080c,
+	0x7090, 0x6110, 0x81ff, 0x0158, 0x00d6, 0x2168, 0x080c, 0xb380,
+	0x0036, 0x2019, 0x0029, 0x080c, 0xb099, 0x003e, 0x00de, 0x080c,
+	0x9e1d, 0x080c, 0x7173, 0x0005, 0x080c, 0x7126, 0x6110, 0x81ff,
+	0x0158, 0x00d6, 0x2168, 0x080c, 0xb380, 0x0036, 0x2019, 0x0029,
+	0x080c, 0xb099, 0x003e, 0x00de, 0x080c, 0x9e1d, 0x080c, 0x7230,
+	0x0005, 0xa182, 0x0085, 0x0002, 0xac45, 0xac43, 0xac43, 0xac51,
+	0xac43, 0xac43, 0xac43, 0x080c, 0x1515, 0x6003, 0x000b, 0x6106,
+	0x080c, 0x6c8d, 0x0126, 0x2091, 0x8000, 0x080c, 0x7173, 0x012e,
+	0x0005, 0x0026, 0x00e6, 0x080c, 0xb2d0, 0x0118, 0x080c, 0x861d,
+	0x00d8, 0x2071, 0xbb80, 0x7224, 0x6212, 0x7220, 0x080c, 0xaf47,
+	0x0118, 0x6007, 0x0086, 0x0040, 0x6007, 0x0087, 0x7224, 0xa296,
+	0xffff, 0x1110, 0x6007, 0x0086, 0x6003, 0x0001, 0x080c, 0x6c8d,
+	0x080c, 0x7173, 0x080c, 0x7230, 0x00ee, 0x002e, 0x0005, 0xa186,
+	0x0013, 0x1160, 0x6004, 0xa08a, 0x0085, 0x0a0c, 0x1515, 0xa08a,
+	0x008c, 0x1a0c, 0x1515, 0xa082, 0x0085, 0x00a2, 0xa186, 0x0027,
+	0x0130, 0xa186, 0x0014, 0x0118, 0x080c, 0x8663, 0x0050, 0x2001,
+	0x0007, 0x080c, 0x4f2a, 0x080c, 0x7090, 0x080c, 0x9e1d, 0x080c,
+	0x7173, 0x0005, 0xaca1, 0xaca3, 0xaca3, 0xaca1, 0xaca1, 0xaca1,
+	0xaca1, 0x080c, 0x1515, 0x080c, 0x7090, 0x080c, 0x9e1d, 0x080c,
+	0x7173, 0x0005, 0xa182, 0x0085, 0x0a0c, 0x1515, 0xa182, 0x008c,
+	0x1a0c, 0x1515, 0xa182, 0x0085, 0x0002, 0xacbc, 0xacbc, 0xacbc,
+	0xacbe, 0xacbc, 0xacbc, 0xacbc, 0x080c, 0x1515, 0x0005, 0xa186,
+	0x0013, 0x0148, 0xa186, 0x0014, 0x0130, 0xa186, 0x0027, 0x0118,
+	0x080c, 0x8663, 0x0030, 0x080c, 0x7090, 0x080c, 0x9e1d, 0x080c,
+	0x7173, 0x0005, 0x0036, 0x080c, 0xb33a, 0x603f, 0x0000, 0x2019,
+	0x000b, 0x0031, 0x601f, 0x0006, 0x6003, 0x0007, 0x003e, 0x0005,
+	0x0126, 0x0036, 0x2091, 0x8000, 0x0086, 0x2c40, 0x0096, 0x2049,
+	0x0000, 0x080c, 0x8130, 0x009e, 0x008e, 0x1578, 0x0076, 0x2c38,
+	0x080c, 0x81d6, 0x007e, 0x1548, 0x6000, 0xa086, 0x0000, 0x0528,
+	0x601c, 0xa086, 0x0007, 0x0508, 0x00d6, 0x6000, 0xa086, 0x0004,
+	0x1150, 0x080c, 0xb33a, 0x601f, 0x0007, 0x2001, 0xb7b6, 0x2004,
+	0x6016, 0x080c, 0x194d, 0x6010, 0x2068, 0x080c, 0x9c5a, 0x0110,
+	0x080c, 0xb099, 0x00de, 0x6013, 0x0000, 0x080c, 0xb33a, 0x601f,
+	0x0007, 0x2001, 0xb7b6, 0x2004, 0x6016, 0x003e, 0x012e, 0x0005,
+	0x00f6, 0x00c6, 0x0036, 0x0156, 0x2079, 0xbb80, 0x7938, 0x783c,
+	0x080c, 0x281d, 0x15b0, 0x0016, 0x00c6, 0x080c, 0x4fa9, 0x1578,
+	0x001e, 0x002e, 0x0026, 0x0016, 0x2019, 0x0029, 0x080c, 0x8299,
+	0x080c, 0x6df5, 0x0076, 0x2039, 0x0000, 0x080c, 0x6d02, 0x007e,
+	0x001e, 0x0076, 0x2039, 0x0000, 0x080c, 0xae82, 0x007e, 0x080c,
+	0x51aa, 0x0026, 0x6204, 0xa294, 0xff00, 0x8217, 0xa286, 0x0006,
+	0x0118, 0xa286, 0x0004, 0x1118, 0x62a0, 0x080c, 0x2d55, 0x002e,
+	0x001e, 0x080c, 0x4c0b, 0x6612, 0x6516, 0xa006, 0x0010, 0x00ce,
+	0x001e, 0x015e, 0x003e, 0x00ce, 0x00fe, 0x0005, 0x00c6, 0x00d6,
+	0x00e6, 0x0016, 0x2009, 0xb521, 0x2104, 0xa086, 0x0074, 0x1904,
+	0xadbb, 0x2069, 0xbb8e, 0x690c, 0xa182, 0x0100, 0x06c0, 0x6908,
+	0xa184, 0x8000, 0x05e8, 0x2001, 0xb79e, 0x2004, 0xa005, 0x1160,
+	0x6018, 0x2070, 0x7010, 0xa084, 0x00ff, 0x0118, 0x7000, 0xd0f4,
+	0x0118, 0xa184, 0x0800, 0x0560, 0x6910, 0xa18a, 0x0001, 0x0610,
+	0x6914, 0x2069, 0xbbae, 0x6904, 0x81ff, 0x1198, 0x690c, 0xa182,
+	0x0100, 0x02a8, 0x6908, 0x81ff, 0x1178, 0x6910, 0xa18a, 0x0001,
+	0x0288, 0x6918, 0xa18a, 0x0001, 0x0298, 0x00d0, 0x6013, 0x0100,
+	0x00a0, 0x6013, 0x0300, 0x0088, 0x6013, 0x0500, 0x0070, 0x6013,
+	0x0700, 0x0058, 0x6013, 0x0900, 0x0040, 0x6013, 0x0b00, 0x0028,
+	0x6013, 0x0f00, 0x0010, 0x6013, 0x2d00, 0xa085, 0x0001, 0x0008,
+	0xa006, 0x001e, 0x00ee, 0x00de, 0x00ce, 0x0005, 0x00c6, 0x00d6,
+	0x0026, 0x0036, 0x0156, 0x6218, 0x2268, 0x6b04, 0xa394, 0x00ff,
+	0xa286, 0x0006, 0x0190, 0xa286, 0x0004, 0x0178, 0xa394, 0xff00,
+	0x8217, 0xa286, 0x0006, 0x0148, 0xa286, 0x0004, 0x0130, 0x00c6,
+	0x2d60, 0x080c, 0x4fb8, 0x00ce, 0x04c0, 0x2011, 0xbb96, 0xad98,
+	0x000a, 0x20a9, 0x0004, 0x080c, 0x90da, 0x1580, 0x2011, 0xbb9a,
+	0xad98, 0x0006, 0x20a9, 0x0004, 0x080c, 0x90da, 0x1538, 0x0046,
+	0x0016, 0x6aa0, 0xa294, 0x00ff, 0x8227, 0xa006, 0x2009, 0xb553,
+	0x210c, 0xd1a4, 0x0138, 0x2009, 0x0029, 0x080c, 0xb0e8, 0x6800,
+	0xc0e5, 0x6802, 0x2019, 0x0029, 0x080c, 0x6df5, 0x0076, 0x2039,
+	0x0000, 0x080c, 0x6d02, 0x2c08, 0x080c, 0xae82, 0x007e, 0x2001,
+	0x0007, 0x080c, 0x4f2a, 0x001e, 0x004e, 0xa006, 0x015e, 0x003e,
+	0x002e, 0x00de, 0x00ce, 0x0005, 0x00d6, 0x2069, 0xbb8e, 0x6800,
+	0xa086, 0x0800, 0x0118, 0x6013, 0x0000, 0x0008, 0xa006, 0x00de,
+	0x0005, 0x00c6, 0x00f6, 0x0016, 0x0026, 0x0036, 0x0156, 0x2079,
+	0xbb8c, 0x7930, 0x7834, 0x080c, 0x281d, 0x11a0, 0x080c, 0x4fa9,
+	0x1188, 0x2011, 0xbb90, 0xac98, 0x000a, 0x20a9, 0x0004, 0x080c,
+	0x90da, 0x1140, 0x2011, 0xbb94, 0xac98, 0x0006, 0x20a9, 0x0004,
+	0x080c, 0x90da, 0x015e, 0x003e, 0x002e, 0x001e, 0x00fe, 0x00ce,
+	0x0005, 0x00c6, 0x0006, 0x0016, 0x0026, 0x0036, 0x0156, 0x2011,
+	0xbb83, 0x2204, 0x8211, 0x220c, 0x080c, 0x281d, 0x11a0, 0x080c,
+	0x4fa9, 0x1188, 0x2011, 0xbb96, 0xac98, 0x000a, 0x20a9, 0x0004,
+	0x080c, 0x90da, 0x1140, 0x2011, 0xbb9a, 0xac98, 0x0006, 0x20a9,
+	0x0004, 0x080c, 0x90da, 0x015e, 0x003e, 0x002e, 0x001e, 0x000e,
+	0x00ce, 0x0005, 0x00e6, 0x00c6, 0x0086, 0x0076, 0x0066, 0x0056,
+	0x0046, 0x0026, 0x0126, 0x2091, 0x8000, 0x2740, 0x2029, 0xb7e9,
+	0x252c, 0x2021, 0xb7ef, 0x2424, 0x2061, 0xbd00, 0x2071, 0xb500,
+	0x7648, 0x7068, 0x81ff, 0x0150, 0x0006, 0xa186, 0xb8f4, 0x000e,
+	0x0128, 0x8001, 0xa602, 0x1a04, 0xaf03, 0x0018, 0xa606, 0x0904,
+	0xaf03, 0x2100, 0xac06, 0x0904, 0xaefa, 0x080c, 0xb110, 0x0904,
+	0xaefa, 0x671c, 0xa786, 0x0001, 0x0904, 0xaf1e, 0xa786, 0x0004,
+	0x0904, 0xaf1e, 0xa786, 0x0007, 0x05e8, 0x2500, 0xac06, 0x05d0,
+	0x2400, 0xac06, 0x05b8, 0x080c, 0xb120, 0x15a0, 0x88ff, 0x0118,
+	0x6050, 0xa906, 0x1578, 0x00d6, 0x6000, 0xa086, 0x0004, 0x1120,
+	0x0016, 0x080c, 0x194d, 0x001e, 0xa786, 0x0008, 0x1148, 0x080c,
+	0x9e58, 0x1130, 0x080c, 0x8c19, 0x00de, 0x080c, 0x9e1d, 0x00d0,
+	0x6010, 0x2068, 0x080c, 0x9c5a, 0x0190, 0xa786, 0x0003, 0x1528,
+	0x6837, 0x0103, 0x6b4a, 0x6847, 0x0000, 0x080c, 0xb380, 0x0016,
+	0x080c, 0x9ecc, 0x080c, 0x5408, 0x001e, 0x080c, 0x9e11, 0x00de,
+	0x080c, 0x9e1d, 0xace0, 0x0018, 0x2001, 0xb517, 0x2004, 0xac02,
+	0x1210, 0x0804, 0xae96, 0x012e, 0x002e, 0x004e, 0x005e, 0x006e,
+	0x007e, 0x008e, 0x00ce, 0x00ee, 0x0005, 0xa786, 0x0006, 0x1150,
+	0xa386, 0x0005, 0x0128, 0x080c, 0xb380, 0x080c, 0xb099, 0x08f8,
+	0x00de, 0x0c00, 0xa786, 0x000a, 0x0968, 0x0850, 0x080c, 0xb120,
+	0x19c8, 0x81ff, 0x09b8, 0xa180, 0x0001, 0x2004, 0xa086, 0x0018,
+	0x0130, 0xa180, 0x0001, 0x2004, 0xa086, 0x002d, 0x1958, 0x6000,
+	0xa086, 0x0002, 0x1938, 0x080c, 0x9e47, 0x0130, 0x080c, 0x9e58,
+	0x1908, 0x080c, 0x8c19, 0x0038, 0x080c, 0x2cc2, 0x080c, 0x9e58,
+	0x1110, 0x080c, 0x8c19, 0x080c, 0x9e1d, 0x0804, 0xaefa, 0x00c6,
+	0x00e6, 0x0016, 0x2c08, 0x2170, 0xa006, 0x080c, 0xb0ba, 0x001e,
+	0x0120, 0x601c, 0xa084, 0x000f, 0x001b, 0x00ee, 0x00ce, 0x0005,
+	0xaf60, 0xaf60, 0xaf60, 0xaf60, 0xaf60, 0xaf60, 0xaf62, 0xaf60,
+	0xa006, 0x0005, 0x0046, 0x0016, 0x7018, 0xa080, 0x0028, 0x2024,
+	0xa4a4, 0x00ff, 0x8427, 0x2c00, 0x2009, 0x0020, 0x080c, 0xb0e8,
+	0x001e, 0x004e, 0x0036, 0x2019, 0x0002, 0x080c, 0xace0, 0x003e,
+	0xa085, 0x0001, 0x0005, 0x2001, 0x0001, 0x080c, 0x4eeb, 0x0156,
+	0x0016, 0x0026, 0x0036, 0x20a9, 0x0004, 0x2019, 0xb505, 0x2011,
+	0xbb96, 0x080c, 0x90da, 0x003e, 0x002e, 0x001e, 0x015e, 0xa005,
+	0x0005, 0x00f6, 0x00e6, 0x00c6, 0x0086, 0x0076, 0x0066, 0x0026,
+	0x0126, 0x2091, 0x8000, 0x2740, 0x2061, 0xbd00, 0x2079, 0x0001,
+	0x8fff, 0x0904, 0xafef, 0x2071, 0xb500, 0x7648, 0x7068, 0x8001,
+	0xa602, 0x1a04, 0xafef, 0x88ff, 0x0128, 0x2800, 0xac06, 0x15b0,
+	0x2079, 0x0000, 0x080c, 0xb110, 0x0588, 0x2400, 0xac06, 0x0570,
+	0x671c, 0xa786, 0x0006, 0x1550, 0xa786, 0x0007, 0x0538, 0x88ff,
+	0x1140, 0x6018, 0xa206, 0x1510, 0x85ff, 0x0118, 0x6050, 0xa106,
+	0x11e8, 0x00d6, 0x6000, 0xa086, 0x0004, 0x1150, 0x080c, 0xb33a,
+	0x601f, 0x0007, 0x2001, 0xb7b6, 0x2004, 0x6016, 0x080c, 0x194d,
+	0x6010, 0x2068, 0x080c, 0x9c5a, 0x0120, 0x0046, 0x080c, 0xb099,
+	0x004e, 0x00de, 0x080c, 0x9e1d, 0x88ff, 0x1198, 0xace0, 0x0018,
+	0x2001, 0xb517, 0x2004, 0xac02, 0x1210, 0x0804, 0xafa0, 0xa006,
+	0x012e, 0x002e, 0x006e, 0x007e, 0x008e, 0x00ce, 0x00ee, 0x00fe,
+	0x0005, 0xa8c5, 0x0001, 0x0ca0, 0x0076, 0x0056, 0x0086, 0x2041,
+	0x0000, 0x2029, 0x0001, 0x2c20, 0x2019, 0x0002, 0x6218, 0x0096,
+	0x2049, 0x0000, 0x080c, 0x8130, 0x009e, 0x008e, 0x2039, 0x0000,
+	0x080c, 0x81d6, 0x080c, 0xaf91, 0x005e, 0x007e, 0x0005, 0x0026,
+	0x0046, 0x0056, 0x0076, 0x00c6, 0x0156, 0x2c20, 0x2128, 0x20a9,
+	0x007f, 0x2009, 0x0000, 0x0016, 0x0036, 0x080c, 0x4fa9, 0x11b0,
+	0x2c10, 0x0056, 0x0086, 0x2041, 0x0000, 0x2508, 0x2029, 0x0001,
+	0x0096, 0x2049, 0x0000, 0x080c, 0x8130, 0x009e, 0x008e, 0x2039,
+	0x0000, 0x080c, 0x81d6, 0x080c, 0xaf91, 0x005e, 0x003e, 0x001e,
+	0x8108, 0x1f04, 0xb023, 0x015e, 0x00ce, 0x007e, 0x005e, 0x004e,
+	0x002e, 0x0005, 0x0076, 0x0056, 0x6218, 0x0086, 0x2041, 0x0000,
+	0x2029, 0x0001, 0x2019, 0x0048, 0x0096, 0x2049, 0x0000, 0x080c,
+	0x8130, 0x009e, 0x008e, 0x2039, 0x0000, 0x080c, 0x81d6, 0x2c20,
+	0x080c, 0xaf91, 0x005e, 0x007e, 0x0005, 0x0026, 0x0046, 0x0056,
+	0x0076, 0x00c6, 0x0156, 0x2c20, 0x20a9, 0x007f, 0x2009, 0x0000,
+	0x0016, 0x0036, 0x080c, 0x4fa9, 0x11c0, 0x2c10, 0x0086, 0x2041,
+	0x0000, 0x2828, 0x0046, 0x2021, 0x0001, 0x080c, 0xb31c, 0x004e,
+	0x0096, 0x2049, 0x0000, 0x080c, 0x8130, 0x009e, 0x008e, 0x2039,
+	0x0000, 0x080c, 0x81d6, 0x080c, 0xaf91, 0x003e, 0x001e, 0x8108,
+	0x1f04, 0xb070, 0x015e, 0x00ce, 0x007e, 0x005e, 0x004e, 0x002e,
+	0x0005, 0x0016, 0x00f6, 0x3800, 0xd08c, 0x0130, 0xad82, 0x1000,
+	0x02b0, 0xad82, 0xb500, 0x0230, 0xad82, 0xed00, 0x0280, 0xad82,
+	0xffff, 0x1268, 0x6800, 0xa07d, 0x0138, 0x6803, 0x0000, 0x6b52,
+	0x080c, 0x5408, 0x2f68, 0x0cb0, 0x6b52, 0x080c, 0x5408, 0x00fe,
+	0x001e, 0x0005, 0x00e6, 0x0046, 0x0036, 0x2061, 0xbd00, 0xa005,
+	0x1138, 0x2071, 0xb500, 0x7448, 0x7068, 0x8001, 0xa402, 0x12d8,
+	0x2100, 0xac06, 0x0168, 0x6000, 0xa086, 0x0000, 0x0148, 0x6008,
+	0xa206, 0x1130, 0x6018, 0xa1a0, 0x0006, 0x2424, 0xa406, 0x0140,
+	0xace0, 0x0018, 0x2001, 0xb517, 0x2004, 0xac02, 0x1220, 0x0c40,
+	0xa085, 0x0001, 0x0008, 0xa006, 0x003e, 0x004e, 0x00ee, 0x0005,
+	0x00d6, 0x0006, 0x080c, 0x15f8, 0x000e, 0x090c, 0x1515, 0x6837,
+	0x010d, 0x685e, 0x0026, 0x2010, 0x080c, 0x9c4a, 0x2001, 0x0000,
+	0x0120, 0x2200, 0xa080, 0x0014, 0x2004, 0x002e, 0x684a, 0x6956,
+	0x6c46, 0x684f, 0x0000, 0x2001, 0xb7be, 0x2004, 0x6852, 0xa006,
+	0x68b2, 0x6802, 0x683a, 0x685a, 0x080c, 0x5408, 0x00de, 0x0005,
+	0x6700, 0xa786, 0x0000, 0x0158, 0xa786, 0x0001, 0x0140, 0xa786,
+	0x000a, 0x0128, 0xa786, 0x0009, 0x0110, 0xa085, 0x0001, 0x0005,
+	0x00e6, 0x6018, 0x2070, 0x70a0, 0xa206, 0x00ee, 0x0005, 0x0016,
+	0x6004, 0xa08e, 0x001e, 0x11a0, 0x8007, 0x6130, 0xa18c, 0x00ff,
+	0xa105, 0x6032, 0x6007, 0x0085, 0x6003, 0x000b, 0x601f, 0x0005,
+	0x2001, 0xb7b7, 0x2004, 0x6016, 0x080c, 0x6c8d, 0x080c, 0x7173,
+	0x001e, 0x0005, 0xe000, 0xe000, 0x0005, 0x6020, 0xd0e4, 0x0158,
+	0xd0cc, 0x0118, 0x080c, 0x9f35, 0x0030, 0x080c, 0xb33a, 0x080c,
+	0x6aef, 0x080c, 0x861d, 0x0005, 0xa280, 0x0007, 0x2004, 0xa084,
+	0x000f, 0x0002, 0xb163, 0xb163, 0xb163, 0xb168, 0xb163, 0xb165,
+	0xb165, 0xb163, 0xb165, 0xa006, 0x0005, 0x00c6, 0x2260, 0x00ce,
+	0xa085, 0x0001, 0x0005, 0xa280, 0x0007, 0x2004, 0xa084, 0x000f,
+	0x0002, 0xb17a, 0xb17a, 0xb17a, 0xb17a, 0xb17a, 0xb17a, 0xb185,
+	0xb17a, 0xb17a, 0x6007, 0x003b, 0x602b, 0x0009, 0x6013, 0x2a00,
+	0x6003, 0x0001, 0x080c, 0x6c8d, 0x0005, 0x00c6, 0x2260, 0x080c,
+	0xb33a, 0x603f, 0x0000, 0x6020, 0xc0f4, 0xc0cc, 0x6022, 0x6037,
+	0x0000, 0x00ce, 0x00d6, 0x2268, 0xa186, 0x0007, 0x1904, 0xb1e0,
+	0x6810, 0xa005, 0x0138, 0xa080, 0x0013, 0x2004, 0xd0fc, 0x1110,
+	0x00de, 0x08c0, 0x6007, 0x003a, 0x6003, 0x0001, 0x080c, 0x6c8d,
+	0x080c, 0x7173, 0x00c6, 0x2d60, 0x6100, 0xa186, 0x0002, 0x1904,
+	0xb269, 0x6010, 0xa005, 0x1138, 0x6000, 0xa086, 0x0007, 0x190c,
+	0x1515, 0x0804, 0xb269, 0xa08c, 0xf000, 0x1130, 0x0028, 0x2068,
+	0x6800, 0xa005, 0x1de0, 0x2d00, 0xa080, 0x0013, 0x2004, 0xa084,
+	0x0003, 0xa086, 0x0002, 0x1180, 0x6010, 0x2068, 0x684c, 0xc0dc,
+	0xc0f4, 0x684e, 0x6850, 0xc0f4, 0xc0fc, 0x6852, 0x2009, 0x0043,
+	0x080c, 0xab56, 0x0804, 0xb269, 0x2009, 0x0041, 0x0804, 0xb263,
+	0xa186, 0x0005, 0x15f0, 0x6810, 0xa080, 0x0013, 0x2004, 0xd0bc,
+	0x1118, 0x00de, 0x0804, 0xb17a, 0xd0b4, 0x0128, 0xd0fc, 0x090c,
+	0x1515, 0x0804, 0xb198, 0x6007, 0x003a, 0x6003, 0x0001, 0x080c,
+	0x6c8d, 0x080c, 0x7173, 0x00c6, 0x2d60, 0x6100, 0xa186, 0x0002,
+	0x0120, 0xa186, 0x0004, 0x1904, 0xb269, 0x2071, 0xb823, 0x7000,
+	0xa086, 0x0003, 0x1128, 0x7004, 0xac06, 0x1110, 0x7003, 0x0000,
+	0x6810, 0xa080, 0x0013, 0x200c, 0xc1f4, 0xc1dc, 0x2102, 0x8000,
+	0x200c, 0xc1f4, 0xc1fc, 0xc1bc, 0x2102, 0x2009, 0x0042, 0x0804,
+	0xb263, 0x0036, 0x00d6, 0x00d6, 0x080c, 0x15f8, 0x003e, 0x090c,
+	0x1515, 0x6837, 0x010d, 0x6803, 0x0000, 0x683b, 0x0000, 0x685b,
+	0x0000, 0x6b5e, 0x6857, 0x0045, 0x2c00, 0x6862, 0x6034, 0x6872,
+	0x2360, 0x6020, 0xc0dd, 0x6022, 0x6018, 0xa080, 0x0028, 0x2004,
+	0xa084, 0x00ff, 0x8007, 0x6350, 0x6b4a, 0x6846, 0x684f, 0x0000,
+	0x6853, 0x0000, 0x6d6a, 0x6e66, 0x686f, 0x0001, 0x080c, 0x5408,
+	0x2019, 0x0045, 0x6008, 0x2068, 0x080c, 0xace0, 0x2d00, 0x600a,
+	0x601f, 0x0006, 0x6003, 0x0007, 0x6017, 0x0000, 0x603f, 0x0000,
+	0x00de, 0x003e, 0x0038, 0x603f, 0x0000, 0x6003, 0x0007, 0x080c,
+	0xab56, 0x00ce, 0x00de, 0x0005, 0xa186, 0x0013, 0x1128, 0x6004,
+	0xa082, 0x0085, 0x2008, 0x00c2, 0xa186, 0x0027, 0x1178, 0x080c,
+	0x7090, 0x0036, 0x00d6, 0x6010, 0x2068, 0x2019, 0x0004, 0x080c,
+	0xb099, 0x00de, 0x003e, 0x080c, 0x7173, 0x0005, 0xa186, 0x0014,
+	0x0d70, 0x080c, 0x8663, 0x0005, 0xb295, 0xb293, 0xb293, 0xb293,
+	0xb293, 0xb293, 0xb295, 0x080c, 0x1515, 0x080c, 0x7090, 0x6003,
+	0x000c, 0x080c, 0x7173, 0x0005, 0xa182, 0x008c, 0x1220, 0xa182,
+	0x0085, 0x0208, 0x001a, 0x080c, 0x8663, 0x0005, 0xb2ad, 0xb2ad,
+	0xb2ad, 0xb2ad, 0xb2af, 0xb2cd, 0xb2ad, 0x080c, 0x1515, 0x00d6,
+	0x2c68, 0x080c, 0x85c7, 0x01a0, 0x6003, 0x0001, 0x6007, 0x001e,
+	0x2009, 0xbb8e, 0x210c, 0x6136, 0x2009, 0xbb8f, 0x210c, 0x613a,
+	0x600b, 0xffff, 0x6918, 0x611a, 0x601f, 0x0004, 0x080c, 0x6c8d,
+	0x2d60, 0x080c, 0x861d, 0x00de, 0x0005, 0x080c, 0x861d, 0x0005,
+	0x00e6, 0x6018, 0x2070, 0x7000, 0xd0ec, 0x00ee, 0x0005, 0x6010,
+	0xa08c, 0xf000, 0x0904, 0xb31b, 0xa080, 0x0013, 0x200c, 0xd1ec,
+	0x05d0, 0x2001, 0xb572, 0x2004, 0xd0ec, 0x05a8, 0x6003, 0x0002,
+	0x6020, 0xc0e5, 0x6022, 0xd1ac, 0x0180, 0x00f6, 0x2c78, 0x080c,
+	0x5301, 0x00fe, 0x0150, 0x2001, 0xb7b8, 0x2004, 0x603e, 0x2009,
+	0xb572, 0x210c, 0xd1f4, 0x11e8, 0x0080, 0x2009, 0xb572, 0x210c,
+	0xd1f4, 0x0128, 0x6020, 0xc0e4, 0x6022, 0xa006, 0x00a0, 0x2001,
+	0xb7b8, 0x200c, 0x8103, 0xa100, 0x603e, 0x6018, 0xa088, 0x002b,
+	0x2104, 0xa005, 0x0118, 0xa088, 0x0003, 0x0cd0, 0x2c0a, 0x600f,
+	0x0000, 0xa085, 0x0001, 0x0005, 0x0016, 0x00c6, 0x00e6, 0x6150,
+	0xa2f0, 0x002b, 0x2e04, 0x2060, 0x8cff, 0x0180, 0x84ff, 0x1118,
+	0x6050, 0xa106, 0x1138, 0x600c, 0x2072, 0x080c, 0x6aef, 0x080c,
+	0x861d, 0x0010, 0xacf0, 0x0003, 0x2e64, 0x0c70, 0x00ee, 0x00ce,
+	0x001e, 0x0005, 0x00d6, 0x6018, 0xa0e8, 0x002b, 0x2d04, 0xa005,
+	0x0140, 0xac06, 0x0120, 0x2d04, 0xa0e8, 0x0003, 0x0cb8, 0x600c,
+	0x206a, 0x00de, 0x0005, 0x0026, 0x0036, 0x0156, 0x2011, 0xb528,
+	0x2204, 0xa084, 0x00ff, 0x2019, 0xbb8e, 0x2334, 0xa636, 0x11d8,
+	0x8318, 0x2334, 0x2204, 0xa084, 0xff00, 0xa636, 0x11a0, 0x2011,
+	0xbb90, 0x6018, 0xa098, 0x000a, 0x20a9, 0x0004, 0x080c, 0x90da,
+	0x1150, 0x2011, 0xbb94, 0x6018, 0xa098, 0x0006, 0x20a9, 0x0004,
+	0x080c, 0x90da, 0x1100, 0x015e, 0x003e, 0x002e, 0x0005, 0x00e6,
+	0x2071, 0xb500, 0x080c, 0x4bc6, 0x080c, 0x2ab8, 0x00ee, 0x0005,
+	0x00e6, 0x6018, 0x2070, 0x7000, 0xd0fc, 0x0108, 0x0011, 0x00ee,
+	0x0005, 0x6850, 0xc0e5, 0x6852, 0x0005, 0x00e6, 0x00c6, 0x0076,
+	0x0066, 0x0056, 0x0046, 0x0026, 0x0016, 0x0126, 0x2091, 0x8000,
+	0x2029, 0xb7e9, 0x252c, 0x2021, 0xb7ef, 0x2424, 0x2061, 0xbd00,
+	0x2071, 0xb500, 0x7648, 0x7068, 0xa606, 0x0578, 0x671c, 0xa786,
+	0x0001, 0x0118, 0xa786, 0x0008, 0x1500, 0x2500, 0xac06, 0x01e8,
+	0x2400, 0xac06, 0x01d0, 0x080c, 0xb110, 0x01b8, 0x080c, 0xb120,
+	0x11a0, 0x6000, 0xa086, 0x0004, 0x1120, 0x0016, 0x080c, 0x194d,
+	0x001e, 0x080c, 0x9e47, 0x1110, 0x080c, 0x2cc2, 0x080c, 0x9e58,
+	0x1110, 0x080c, 0x8c19, 0x080c, 0x9e1d, 0xace0, 0x0018, 0x2001,
+	0xb517, 0x2004, 0xac02, 0x1208, 0x0858, 0x012e, 0x001e, 0x002e,
+	0x004e, 0x005e, 0x006e, 0x007e, 0x00ce, 0x00ee, 0x0005, 0x0126,
+	0x0006, 0x00e6, 0x0016, 0x2091, 0x8000, 0x2071, 0xb540, 0xd5a4,
+	0x0118, 0x7034, 0x8000, 0x7036, 0xd5b4, 0x0118, 0x7030, 0x8000,
+	0x7032, 0xd5ac, 0x0178, 0x2500, 0xa084, 0x0007, 0xa08e, 0x0003,
+	0x0148, 0xa08e, 0x0004, 0x0130, 0xa08e, 0x0005, 0x0118, 0x2071,
+	0xb54a, 0x04c9, 0x001e, 0x00ee, 0x000e, 0x012e, 0x0005, 0x0126,
+	0x0006, 0x00e6, 0x0016, 0x2091, 0x8000, 0x2071, 0xb540, 0xd5a4,
+	0x0118, 0x7034, 0x8000, 0x7036, 0xd5b4, 0x0118, 0x7030, 0x8000,
+	0x7032, 0xd5ac, 0x0178, 0x2500, 0xa084, 0x0007, 0xa08e, 0x0003,
+	0x0148, 0xa08e, 0x0004, 0x0130, 0xa08e, 0x0005, 0x0118, 0x2071,
+	0xb54a, 0x0089, 0x001e, 0x00ee, 0x000e, 0x012e, 0x0005, 0x0126,
+	0x0006, 0x00e6, 0x2091, 0x8000, 0x2071, 0xb542, 0x0021, 0x00ee,
+	0x000e, 0x012e, 0x0005, 0x2e04, 0x8000, 0x2072, 0x1220, 0x8e70,
+	0x2e04, 0x8000, 0x2072, 0x0005, 0x00e6, 0x2071, 0xb540, 0x0c99,
+	0x00ee, 0x0005, 0x00e6, 0x2071, 0xb544, 0x0c69, 0x00ee, 0x0005,
+	0x0126, 0x0006, 0x00e6, 0x2091, 0x8000, 0x2071, 0xb540, 0x7044,
+	0x8000, 0x7046, 0x00ee, 0x000e, 0x012e, 0x0005, 0x0001, 0x0002,
+	0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100, 0x0200,
+	0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000, 0x2440
+};
+#ifdef UNIQUE_FW_NAME
+unsigned short fw2200tp_length01 = 0xa46f;
+#else
+unsigned short risc_code_length01 = 0xa46f;
+#endif
+
diff -puN /dev/null drivers/scsi/qla2xxx/ql2300.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/ql2300.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,161 @@
+/*
+ * QLogic ISP23XX device driver for Linux 2.6.x
+ * Copyright (C) 2003 Christoph Hellwig.
+ * Copyright (C) 2003 QLogic Corporation (www.qlogic.com)
+ *
+ * Released under GPL v2.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+
+#include "qla_os.h"
+#include "qla_def.h"
+
+static char qla_driver_name[] = "qla2300";
+
+extern unsigned char  fw2300tpx_version[];
+extern unsigned char  fw2300tpx_version_str[];
+extern unsigned short fw2300tpx_addr01;
+extern unsigned short fw2300tpx_code01[];
+extern unsigned short fw2300tpx_length01;
+
+extern unsigned char  fw2322tpx_version[];
+extern unsigned char  fw2322tpx_version_str[];
+extern unsigned short fw2322tpx_addr01;
+extern unsigned short fw2322tpx_code01[];
+extern unsigned short fw2322tpx_length01;
+extern unsigned long rseqtpx_code_addr01;
+extern unsigned short rseqtpx_code01[];
+extern unsigned short rseqtpx_code_length01;
+extern unsigned long xseqtpx_code_addr01;
+extern unsigned short xseqtpx_code01[];
+extern unsigned short xseqtpx_code_length01;
+
+static struct qla_fw_info qla_fw_tbl[] = {
+	{
+		.addressing	= FW_INFO_ADDR_NORMAL,
+		.fwcode		= &fw2300tpx_code01[0],
+		.fwlen		= &fw2300tpx_length01,
+		.fwstart	= &fw2300tpx_addr01,
+	},
+#if defined(ISP2322)
+	/* End of 23xx firmware list */
+	{ FW_INFO_ADDR_NOMORE, },
+
+	/* Start of 232x firmware list */
+	{
+		.addressing	= FW_INFO_ADDR_NORMAL,
+		.fwcode		= &fw2322tpx_code01[0],
+		.fwlen		= &fw2322tpx_length01,
+		.fwstart	= &fw2322tpx_addr01,
+	},
+	{
+		.addressing	= FW_INFO_ADDR_EXTENDED,
+		.fwcode		= &rseqtpx_code01[0],
+		.fwlen		= &rseqtpx_code_length01,
+		.lfwstart	= &rseqtpx_code_addr01,
+	},
+	{
+		.addressing	= FW_INFO_ADDR_EXTENDED,
+		.fwcode		= &xseqtpx_code01[0],
+		.fwlen		= &xseqtpx_code_length01,
+		.lfwstart	= &xseqtpx_code_addr01,
+	},
+#endif
+	{ FW_INFO_ADDR_NOMORE, },
+};
+
+static struct qla_board_info qla_board_tbl[] = {
+	{
+		.drv_name	= qla_driver_name,
+
+		.isp_name	= "ISP2300",
+		.fw_info	= qla_fw_tbl,
+	},
+
+	{
+		.drv_name	= qla_driver_name,
+
+		.isp_name	= "ISP2312",
+		.fw_info	= qla_fw_tbl,
+	},
+#if defined(ISP2322)
+	{
+		.drv_name	= qla_driver_name,
+
+		.isp_name	= "ISP2322",
+		.fw_info	= &qla_fw_tbl[2],
+	},
+#endif
+};
+
+static struct pci_device_id qla2300_pci_tbl[] = {
+	{
+		.vendor		= PCI_VENDOR_ID_QLOGIC,
+		.device		= PCI_DEVICE_ID_QLOGIC_ISP2300,
+		.subvendor	= PCI_ANY_ID,
+		.subdevice	= PCI_ANY_ID,
+		.driver_data	= (unsigned long)&qla_board_tbl[0],
+	},
+
+	{
+		.vendor		= PCI_VENDOR_ID_QLOGIC,
+		.device		= PCI_DEVICE_ID_QLOGIC_ISP2312,
+		.subvendor	= PCI_ANY_ID,
+		.subdevice	= PCI_ANY_ID,
+		.driver_data	= (unsigned long)&qla_board_tbl[1],
+	},
+
+#if defined(ISP2322)
+	{
+		.vendor		= PCI_VENDOR_ID_QLOGIC,
+		.device		= PCI_DEVICE_ID_QLOGIC_ISP2322,
+		.subvendor	= PCI_ANY_ID,
+		.subdevice	= PCI_ANY_ID,
+		.driver_data	= (unsigned long)&qla_board_tbl[2],
+	},
+#endif
+	{0, 0},
+};
+MODULE_DEVICE_TABLE(pci, qla2300_pci_tbl);
+
+static int __devinit
+qla2300_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+	return qla2x00_probe_one(pdev,
+	    (struct qla_board_info *)id->driver_data);
+}
+
+static void __devexit
+qla2300_remove_one(struct pci_dev *pdev)
+{
+	qla2x00_remove_one(pdev);
+}
+
+static struct pci_driver qla2300_pci_driver = {
+	.name		= "qla2300",
+	.id_table	= qla2300_pci_tbl,
+	.probe		= qla2300_probe_one,
+	.remove		= __devexit_p(qla2300_remove_one),
+};
+
+static int __init
+qla2300_init(void)
+{
+	return pci_module_init(&qla2300_pci_driver);
+}
+
+static void __exit
+qla2300_exit(void)
+{
+	pci_unregister_driver(&qla2300_pci_driver);
+}
+
+module_init(qla2300_init);
+module_exit(qla2300_exit);
+
+MODULE_AUTHOR("QLogic Corporation");
+MODULE_DESCRIPTION("QLogic ISP23xx FC-SCSI Host Bus Adapter driver");
+MODULE_LICENSE("GPL");
diff -puN /dev/null drivers/scsi/qla2xxx/ql2300_fw.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/ql2300_fw.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,6695 @@
+/**************************************************************************
+ *                  QLOGIC LINUX SOFTWARE
+ *
+ * QLogic ISP2x00 device driver for Linux 2.6.x
+ * Copyright (C) 2003 QLogic Corporation
+ * (www.qlogic.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ *************************************************************************/
+
+/*
+ *	Firmware Version 3.02.18 (10:33 Nov 03, 2003)
+ */
+
+#ifdef UNIQUE_FW_NAME
+unsigned short fw2300tpx_version = 3*1024+2;
+#else
+unsigned short risc_code_version = 3*1024+2;
+#endif
+
+#ifdef UNIQUE_FW_NAME
+unsigned char fw2300tpx_version_str[] = {3, 2,18};
+#else
+unsigned char firmware_version[] = {3, 2,18};
+#endif
+
+#ifdef UNIQUE_FW_NAME
+#define fw2300tpx_VERSION_STRING "3.02.18"
+#else
+#define FW_VERSION_STRING "3.02.18"
+#endif
+
+#ifdef UNIQUE_FW_NAME
+unsigned short fw2300tpx_addr01 = 0x0800 ;
+#else
+unsigned short risc_code_addr01 = 0x0800 ;
+#endif
+
+#ifdef UNIQUE_FW_NAME
+unsigned short fw2300tpx_code01[] = { 
+#else
+unsigned short risc_code01[] = { 
+#endif
+	0x0470, 0x0000, 0x0000, 0xcf5b, 0x0000, 0x0003, 0x0002, 0x0012,
+	0x0117, 0x2043, 0x4f50, 0x5952, 0x4947, 0x4854, 0x2032, 0x3030,
+	0x3120, 0x514c, 0x4f47, 0x4943, 0x2043, 0x4f52, 0x504f, 0x5241,
+	0x5449, 0x4f4e, 0x2049, 0x5350, 0x3233, 0x3030, 0x2046, 0x6972,
+	0x6d77, 0x6172, 0x6520, 0x2056, 0x6572, 0x7369, 0x6f6e, 0x2030,
+	0x332e, 0x3032, 0x2e31, 0x3820, 0x2020, 0x2020, 0x2400, 0x20a9,
+	0x000f, 0x2001, 0x0000, 0x400f, 0x2091, 0x2200, 0x20a9, 0x000f,
+	0x2001, 0x0000, 0x400f, 0x2091, 0x2400, 0x20a9, 0x000f, 0x2001,
+	0x0000, 0x400f, 0x2091, 0x2600, 0x20a9, 0x000f, 0x2001, 0x0000,
+	0x400f, 0x2091, 0x2800, 0x20a9, 0x000f, 0x2001, 0x0000, 0x400f,
+	0x2091, 0x2a00, 0x20a9, 0x000f, 0x2001, 0x0000, 0x400f, 0x2091,
+	0x2c00, 0x20a9, 0x000f, 0x2001, 0x0000, 0x400f, 0x2091, 0x2e00,
+	0x20a9, 0x000f, 0x2001, 0x0000, 0x400f, 0x2091, 0x2000, 0x2001,
+	0x0000, 0x20c1, 0x0004, 0x2001, 0x017f, 0x2003, 0x0000, 0x20c9,
+	0x1bff, 0x2059, 0x0000, 0x2b78, 0x7883, 0x0004, 0x2089, 0x29be,
+	0x2051, 0x1800, 0x2a70, 0x20e1, 0x0001, 0x20e9, 0x0001, 0x2029,
+	0x4d00, 0x2031, 0xffff, 0x2039, 0x4cd0, 0x2021, 0x0200, 0x20e9,
+	0x0001, 0x20a1, 0x0000, 0x20a9, 0x0800, 0x900e, 0x4104, 0x20e9,
+	0x0001, 0x20a1, 0x1000, 0x900e, 0x2001, 0x0cc0, 0x9084, 0x0fff,
+	0x20a8, 0x4104, 0x2001, 0x0000, 0x9086, 0x0000, 0x0120, 0x21a8,
+	0x4104, 0x8001, 0x1de0, 0x7566, 0x766a, 0x7762, 0x746e, 0x7472,
+	0x00e6, 0x2071, 0x1a8b, 0x2472, 0x00ee, 0x20a1, 0x1cd0, 0x7168,
+	0x810d, 0x810d, 0x810d, 0x810d, 0x918c, 0x000f, 0x2001, 0x0001,
+	0x9112, 0x900e, 0x21a8, 0x4104, 0x8211, 0x1de0, 0x7168, 0x3400,
+	0x8001, 0x9102, 0x0120, 0x0218, 0x20a8, 0x900e, 0x4104, 0x2009,
+	0x1800, 0x810d, 0x810d, 0x810d, 0x810d, 0x810d, 0x918c, 0x001f,
+	0x2001, 0x0001, 0x9112, 0x20e9, 0x0001, 0x20a1, 0x0800, 0x900e,
+	0x20a9, 0x0800, 0x4104, 0x8211, 0x1dd8, 0x080c, 0x0eed, 0x080c,
+	0x5a2f, 0x080c, 0x996c, 0x080c, 0x10a4, 0x080c, 0x127c, 0x080c,
+	0x196d, 0x080c, 0x0d4b, 0x080c, 0x1029, 0x080c, 0x3092, 0x080c,
+	0x6f3e, 0x080c, 0x62c8, 0x080c, 0x7b85, 0x080c, 0x217b, 0x080c,
+	0x7eaf, 0x080c, 0x757c, 0x080c, 0x1fb8, 0x080c, 0x20ec, 0x080c,
+	0x2170, 0x2091, 0x3009, 0x7883, 0x0000, 0x1004, 0x091d, 0x7880,
+	0x9086, 0x0002, 0x1190, 0x7883, 0x4000, 0x7837, 0x4000, 0x7833,
+	0x0010, 0x0e04, 0x0911, 0x2091, 0x5000, 0x2091, 0x4080, 0x2001,
+	0x0089, 0x2004, 0xd084, 0x190c, 0x1167, 0x2071, 0x1800, 0x7003,
+	0x0000, 0x2071, 0x1800, 0x7000, 0x908e, 0x0003, 0x1168, 0x080c,
+	0x4737, 0x080c, 0x30b9, 0x080c, 0x6faf, 0x080c, 0x6787, 0x080c,
+	0x7bae, 0x080c, 0x292b, 0x0c68, 0x000b, 0x0c88, 0x0940, 0x0941,
+	0x0ad4, 0x093e, 0x0b94, 0x0d4a, 0x0d4a, 0x0d4a, 0x080c, 0x0db2,
+	0x0005, 0x0126, 0x00f6, 0x2091, 0x8000, 0x7000, 0x9086, 0x0001,
+	0x1904, 0x0aa7, 0x080c, 0x0e5a, 0x080c, 0x6c53, 0x0150, 0x080c,
+	0x6c76, 0x1590, 0x2079, 0x0100, 0x7828, 0x9085, 0x1800, 0x782a,
+	0x0458, 0x080c, 0x6b8a, 0x7000, 0x9086, 0x0001, 0x1904, 0x0aa7,
+	0x7090, 0x9086, 0x0028, 0x1904, 0x0aa7, 0x080c, 0x7b7c, 0x2001,
+	0x0161, 0x2003, 0x0001, 0x2079, 0x0100, 0x7827, 0xffff, 0x7a28,
+	0x9295, 0x5e2f, 0x7a2a, 0x2011, 0x6ad9, 0x080c, 0x7c4a, 0x2011,
+	0x6acc, 0x080c, 0x7d1b, 0x2011, 0x588a, 0x080c, 0x7c4a, 0x2011,
+	0x8030, 0x901e, 0x738e, 0x04a0, 0x080c, 0x5137, 0x2079, 0x0100,
+	0x7844, 0x9005, 0x1904, 0x0aa7, 0x2011, 0x588a, 0x080c, 0x7c4a,
+	0x2011, 0x6ad9, 0x080c, 0x7c4a, 0x2011, 0x6acc, 0x080c, 0x7d1b,
+	0x2001, 0x0265, 0x2001, 0x0205, 0x2003, 0x0000, 0x7840, 0x9084,
+	0xfffb, 0x7842, 0x2001, 0x1975, 0x2004, 0x9005, 0x1140, 0x00c6,
+	0x2061, 0x0100, 0x080c, 0x59d7, 0x00ce, 0x0804, 0x0aa7, 0x780f,
+	0x006b, 0x7a28, 0x9295, 0x5e2f, 0x7a2a, 0x2011, 0x8010, 0x73d0,
+	0x2001, 0x1976, 0x2003, 0x0001, 0x080c, 0x27f1, 0x080c, 0x4672,
+	0x7240, 0xc284, 0x7242, 0x2001, 0x180c, 0x200c, 0xc1ac, 0xc1cc,
+	0x2102, 0x080c, 0x91bb, 0x2011, 0x0004, 0x080c, 0xb60b, 0x080c,
+	0x61a1, 0x080c, 0x6c53, 0x1120, 0x080c, 0x2835, 0x02e0, 0x0400,
+	0x080c, 0x59de, 0x0140, 0x708f, 0x0001, 0x70cb, 0x0000, 0x080c,
+	0x5304, 0x0804, 0x0aa7, 0x080c, 0x5113, 0xd094, 0x0188, 0x2011,
+	0x180c, 0x2204, 0xc0cd, 0x2012, 0x080c, 0x5117, 0xd0d4, 0x1118,
+	0x080c, 0x2835, 0x1270, 0x2011, 0x180c, 0x2204, 0xc0bc, 0x00a8,
+	0x080c, 0x5117, 0xd0d4, 0x1db8, 0x2011, 0x180c, 0x2204, 0xc0bd,
+	0x0060, 0x2011, 0x180c, 0x2204, 0xc0bd, 0x2012, 0x080c, 0x629c,
+	0x1128, 0xd0a4, 0x0118, 0x2204, 0xc0fd, 0x2012, 0x080c, 0x6262,
+	0x0120, 0x7a0c, 0xc2b4, 0x7a0e, 0x00a8, 0x7077, 0x0000, 0x080c,
+	0x6c53, 0x1130, 0x70a8, 0x9005, 0x1168, 0x080c, 0xba40, 0x0050,
+	0x080c, 0xba40, 0x70d4, 0xd09c, 0x1128, 0x70a8, 0x9005, 0x0110,
+	0x080c, 0x59b4, 0x70df, 0x0000, 0x70db, 0x0000, 0x709f, 0x0000,
+	0x080c, 0x283d, 0x0228, 0x2011, 0x0101, 0x2204, 0xc0c4, 0x2012,
+	0x72d4, 0x080c, 0x6c53, 0x1178, 0x9016, 0x0016, 0x080c, 0x25ee,
+	0x2019, 0x193e, 0x211a, 0x001e, 0x7057, 0xffff, 0x705b, 0x00ef,
+	0x707b, 0x0000, 0x0020, 0x2019, 0x193e, 0x201b, 0x0000, 0x2079,
+	0x1853, 0x7804, 0xd0ac, 0x0108, 0xc295, 0x72d6, 0x080c, 0x6c53,
+	0x0118, 0x9296, 0x0004, 0x0548, 0x2011, 0x0001, 0x080c, 0xb60b,
+	0x70a3, 0x0000, 0x70a7, 0xffff, 0x7003, 0x0002, 0x2079, 0x0100,
+	0x7827, 0x0003, 0x7828, 0x9085, 0x0003, 0x782a, 0x00fe, 0x080c,
+	0x2c2b, 0x2011, 0x0005, 0x080c, 0x92ec, 0x080c, 0x8582, 0x080c,
+	0x6c53, 0x0148, 0x00c6, 0x2061, 0x0100, 0x0016, 0x080c, 0x25ee,
+	0x61e2, 0x001e, 0x00ce, 0x012e, 0x0420, 0x70a3, 0x0000, 0x70a7,
+	0xffff, 0x7003, 0x0002, 0x00f6, 0x2079, 0x0100, 0x7827, 0x0003,
+	0x7828, 0x9085, 0x0003, 0x782a, 0x00fe, 0x2011, 0x0005, 0x080c,
+	0x92ec, 0x080c, 0x8582, 0x080c, 0x6c53, 0x0148, 0x00c6, 0x2061,
+	0x0100, 0x0016, 0x080c, 0x25ee, 0x61e2, 0x001e, 0x00ce, 0x00fe,
+	0x012e, 0x0005, 0x00c6, 0x00b6, 0x080c, 0x6c53, 0x1118, 0x20a9,
+	0x0800, 0x0010, 0x20a9, 0x0782, 0x080c, 0x6c53, 0x1110, 0x900e,
+	0x0010, 0x2009, 0x007e, 0x86ff, 0x0138, 0x9180, 0x1000, 0x2004,
+	0x905d, 0x0110, 0xb800, 0xd0bc, 0x090c, 0x2f28, 0x8108, 0x1f04,
+	0x0abb, 0x7077, 0x0000, 0x7078, 0x9084, 0x00ff, 0x707a, 0x70ab,
+	0x0000, 0x00be, 0x00ce, 0x0005, 0x00b6, 0x0126, 0x2091, 0x8000,
+	0x7000, 0x9086, 0x0002, 0x1904, 0x0b91, 0x70a4, 0x9086, 0xffff,
+	0x0130, 0x080c, 0x2c2b, 0x080c, 0x8582, 0x0804, 0x0b91, 0x70d4,
+	0xd0ac, 0x1110, 0xd09c, 0x0558, 0xd084, 0x0548, 0x0006, 0x2001,
+	0x0103, 0x2003, 0x002b, 0x000e, 0xd08c, 0x0508, 0x080c, 0x2f8b,
+	0x11d0, 0x70d8, 0x9086, 0xffff, 0x01b0, 0x080c, 0x2d9c, 0x080c,
+	0x8582, 0x70d4, 0xd094, 0x1904, 0x0b91, 0x2011, 0x0001, 0x080c,
+	0xbcec, 0x0110, 0x2011, 0x0003, 0x901e, 0x080c, 0x2dd6, 0x080c,
+	0x8582, 0x0804, 0x0b91, 0x70dc, 0x9005, 0x1904, 0x0b91, 0x70a0,
+	0x9005, 0x1904, 0x0b91, 0x70d4, 0xd0a4, 0x0118, 0xd0b4, 0x0904,
+	0x0b91, 0x080c, 0x6262, 0x1904, 0x0b91, 0x080c, 0x62b5, 0x1904,
+	0x0b91, 0x080c, 0x629c, 0x01c0, 0x0156, 0x00c6, 0x20a9, 0x007f,
+	0x900e, 0x0016, 0x080c, 0x5f7e, 0x1118, 0xb800, 0xd0ec, 0x1138,
+	0x001e, 0x8108, 0x1f04, 0x0b31, 0x00ce, 0x015e, 0x0028, 0x001e,
+	0x00ce, 0x015e, 0x0804, 0x0b91, 0x0006, 0x2001, 0x0103, 0x2003,
+	0x006b, 0x000e, 0x2011, 0x1982, 0x080c, 0x0f5d, 0x2011, 0x199c,
+	0x080c, 0x0f5d, 0x7030, 0xc08c, 0x7032, 0x7003, 0x0003, 0x70a7,
+	0xffff, 0x080c, 0x0e3c, 0x9006, 0x080c, 0x247f, 0x080c, 0x2f8b,
+	0x0118, 0x080c, 0x480f, 0x0050, 0x0036, 0x0046, 0x2019, 0xffff,
+	0x2021, 0x0006, 0x080c, 0x4829, 0x004e, 0x003e, 0x00f6, 0x2079,
+	0x0100, 0x080c, 0x6c76, 0x0150, 0x080c, 0x6c53, 0x7828, 0x0118,
+	0x9084, 0xe1ff, 0x0010, 0x9084, 0xffdf, 0x782a, 0x00fe, 0x2001,
+	0x19b7, 0x2004, 0x9086, 0x0005, 0x1120, 0x2011, 0x0000, 0x080c,
+	0x92ec, 0x2011, 0x0000, 0x080c, 0x92f6, 0x080c, 0x8582, 0x080c,
+	0x865d, 0x012e, 0x00be, 0x0005, 0x0016, 0x0046, 0x00f6, 0x0126,
+	0x2091, 0x8000, 0x2079, 0x0100, 0x7904, 0x918c, 0xfffd, 0x7906,
+	0x2009, 0x00f7, 0x080c, 0x599d, 0x7940, 0x918c, 0x0010, 0x7942,
+	0x7924, 0xd1b4, 0x0110, 0x7827, 0x0040, 0xd19c, 0x0110, 0x7827,
+	0x0008, 0x0006, 0x0036, 0x0156, 0x7954, 0xd1ac, 0x1904, 0x0c21,
+	0x2001, 0x1976, 0x2004, 0x9005, 0x1518, 0x080c, 0x28b8, 0x1148,
+	0x2001, 0x0001, 0x080c, 0x2820, 0x2001, 0x0001, 0x080c, 0x2803,
+	0x00b8, 0x080c, 0x28c0, 0x1138, 0x9006, 0x080c, 0x2820, 0x9006,
+	0x080c, 0x2803, 0x0068, 0x080c, 0x28c8, 0x1d50, 0x2001, 0x1967,
+	0x2004, 0xd0fc, 0x0108, 0x0020, 0x080c, 0x261a, 0x0804, 0x0d01,
+	0x080c, 0x6c64, 0x0148, 0x080c, 0x6c76, 0x1118, 0x080c, 0x6f39,
+	0x0050, 0x080c, 0x6c5b, 0x0dd0, 0x080c, 0x6f34, 0x080c, 0x6f2a,
+	0x080c, 0x6b8a, 0x0058, 0x080c, 0x6c53, 0x0140, 0x2009, 0x00f8,
+	0x080c, 0x599d, 0x7843, 0x0090, 0x7843, 0x0010, 0x20a9, 0x09c4,
+	0x7820, 0xd09c, 0x1138, 0x080c, 0x6c53, 0x0138, 0x7824, 0xd0ac,
+	0x1904, 0x0d06, 0x1f04, 0x0c00, 0x0070, 0x7824, 0x080c, 0x6c6d,
+	0x0118, 0xd0ac, 0x1904, 0x0d06, 0x9084, 0x1800, 0x0d98, 0x7003,
+	0x0001, 0x0804, 0x0d06, 0x2001, 0x0001, 0x080c, 0x247f, 0x0804,
+	0x0d19, 0x2001, 0x1976, 0x2004, 0x9005, 0x1518, 0x080c, 0x28b8,
+	0x1148, 0x2001, 0x0001, 0x080c, 0x2820, 0x2001, 0x0001, 0x080c,
+	0x2803, 0x00b8, 0x080c, 0x28c0, 0x1138, 0x9006, 0x080c, 0x2820,
+	0x9006, 0x080c, 0x2803, 0x0068, 0x080c, 0x28c8, 0x1d50, 0x2001,
+	0x1967, 0x2004, 0xd0fc, 0x0108, 0x0020, 0x080c, 0x261a, 0x0804,
+	0x0d01, 0x7850, 0x9085, 0x0040, 0x7852, 0x7938, 0x7850, 0x9084,
+	0xfbcf, 0x7852, 0x080c, 0x28d0, 0x9085, 0x2000, 0x7852, 0x793a,
+	0x20a9, 0x0046, 0x1d04, 0x0c5a, 0x080c, 0x7cfb, 0x1f04, 0x0c5a,
+	0x7850, 0x9085, 0x0400, 0x9084, 0xdfbf, 0x7852, 0x793a, 0x080c,
+	0x6c64, 0x0148, 0x080c, 0x6c76, 0x1118, 0x080c, 0x6f39, 0x0050,
+	0x080c, 0x6c5b, 0x0dd0, 0x080c, 0x6f34, 0x080c, 0x6f2a, 0x080c,
+	0x6b8a, 0x0020, 0x2009, 0x00f8, 0x080c, 0x599d, 0x20a9, 0x0028,
+	0xa001, 0x1f04, 0x0c80, 0x7850, 0x9085, 0x1400, 0x7852, 0x080c,
+	0x6c53, 0x0120, 0x7843, 0x0090, 0x7843, 0x0010, 0x2021, 0xe678,
+	0x2019, 0xea60, 0x0d0c, 0x7cfb, 0x7820, 0xd09c, 0x1588, 0x080c,
+	0x6c53, 0x0904, 0x0ce6, 0x7824, 0xd0ac, 0x1904, 0x0d06, 0x080c,
+	0x6c76, 0x1530, 0x0046, 0x2021, 0x0320, 0x8421, 0x1df0, 0x004e,
+	0x7827, 0x1800, 0x080c, 0x28d0, 0x7824, 0x9084, 0x1800, 0x1168,
+	0x9484, 0x0fff, 0x1140, 0x2001, 0x180f, 0x2004, 0x9084, 0x9000,
+	0x0110, 0x080c, 0x0d27, 0x8421, 0x1158, 0x1d04, 0x0cc1, 0x080c,
+	0x7cfb, 0x080c, 0x6f34, 0x080c, 0x6f2a, 0x7003, 0x0001, 0x04f0,
+	0x8319, 0x1940, 0x1d04, 0x0cce, 0x080c, 0x7cfb, 0x2009, 0x196a,
+	0x2104, 0x9005, 0x0118, 0x8001, 0x200a, 0x1178, 0x200b, 0x000a,
+	0x7827, 0x0048, 0x20a9, 0x0002, 0x080c, 0x28b1, 0x7924, 0x080c,
+	0x28d0, 0xd19c, 0x0110, 0x080c, 0x27f1, 0x00d8, 0x080c, 0x6c64,
+	0x1140, 0x94a2, 0x03e8, 0x1128, 0x080c, 0x6c2d, 0x7003, 0x0001,
+	0x00a8, 0x7827, 0x1800, 0x080c, 0x28d0, 0x7824, 0x080c, 0x6c6d,
+	0x0110, 0xd0ac, 0x1158, 0x9084, 0x1800, 0x0950, 0x7003, 0x0001,
+	0x0028, 0x2001, 0x0001, 0x080c, 0x247f, 0x0078, 0x2009, 0x180c,
+	0x210c, 0xd19c, 0x1120, 0x7904, 0x918d, 0x0002, 0x7906, 0x7827,
+	0x0048, 0x7828, 0x9085, 0x0028, 0x782a, 0x7850, 0x9085, 0x0400,
+	0x7852, 0x2001, 0x1976, 0x2003, 0x0000, 0x9006, 0x78f2, 0x015e,
+	0x003e, 0x000e, 0x012e, 0x00fe, 0x004e, 0x001e, 0x0005, 0x0006,
+	0x0016, 0x0036, 0x0046, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6,
+	0x0156, 0x0069, 0x0d0c, 0x7cfb, 0x015e, 0x00fe, 0x00ee, 0x00de,
+	0x00ce, 0x00be, 0x004e, 0x003e, 0x001e, 0x000e, 0x0005, 0x00e6,
+	0x2071, 0x1894, 0x7004, 0x9086, 0x0001, 0x1110, 0x080c, 0x30b9,
+	0x00ee, 0x0005, 0x0005, 0x2a70, 0x2061, 0x197a, 0x2063, 0x0003,
+	0x6007, 0x0002, 0x600b, 0x0012, 0x600f, 0x0117, 0x2001, 0x194d,
+	0x900e, 0x2102, 0x718e, 0x2001, 0x0100, 0x2004, 0x9082, 0x0002,
+	0x0218, 0x7057, 0xffff, 0x0008, 0x7156, 0x705f, 0xffff, 0x7176,
+	0x717a, 0x080c, 0xba40, 0x70e3, 0x00c0, 0x2061, 0x193d, 0x6003,
+	0x0909, 0x6106, 0x600b, 0x8800, 0x600f, 0x0200, 0x6013, 0x00ff,
+	0x6017, 0x000f, 0x611a, 0x601f, 0x07d0, 0x2061, 0x1945, 0x6003,
+	0x8000, 0x6106, 0x610a, 0x600f, 0x0200, 0x6013, 0x00ff, 0x6116,
+	0x601b, 0x0001, 0x611e, 0x2061, 0x1958, 0x6003, 0x514c, 0x6007,
+	0x4f47, 0x600b, 0x4943, 0x600f, 0x2020, 0x2001, 0x182a, 0x2102,
+	0x0005, 0x9016, 0x080c, 0x5f7e, 0x1178, 0xb804, 0x90c4, 0x00ff,
+	0x98c6, 0x0006, 0x0128, 0x90c4, 0xff00, 0x98c6, 0x0600, 0x1120,
+	0x9186, 0x0080, 0x0108, 0x8210, 0x8108, 0x9186, 0x0800, 0x1d50,
+	0x2208, 0x0005, 0x2091, 0x8000, 0x0e04, 0x0db4, 0x0006, 0x0016,
+	0x2001, 0x8002, 0x0006, 0x2079, 0x0000, 0x000e, 0x7882, 0x7836,
+	0x001e, 0x798e, 0x000e, 0x788a, 0x000e, 0x7886, 0x3900, 0x789a,
+	0x7833, 0x0012, 0x2091, 0x5000, 0x0156, 0x00d6, 0x0036, 0x0026,
+	0x2079, 0x0300, 0x2069, 0x1a66, 0x7a18, 0x226a, 0x8d68, 0x7a1c,
+	0x226a, 0x782c, 0x2019, 0x1a73, 0x201a, 0x2019, 0x1a76, 0x9016,
+	0x7808, 0xd09c, 0x0168, 0x7820, 0x201a, 0x8210, 0x8318, 0x9386,
+	0x1a8b, 0x0108, 0x0ca8, 0x7808, 0xd09c, 0x0110, 0x2011, 0xdead,
+	0x2019, 0x1a74, 0x782c, 0x201a, 0x8318, 0x221a, 0x7803, 0x0000,
+	0x2069, 0x1a46, 0x901e, 0x20a9, 0x0020, 0x7b26, 0x7a28, 0x226a,
+	0x8d68, 0x8318, 0x1f04, 0x0dfd, 0x002e, 0x003e, 0x00de, 0x015e,
+	0x2079, 0x1800, 0x7803, 0x0005, 0x2091, 0x4080, 0x2001, 0x0089,
+	0x2004, 0xd084, 0x0180, 0x2001, 0x19e8, 0x2004, 0x9005, 0x0128,
+	0x2001, 0x008b, 0x2004, 0xd0fc, 0x0dd8, 0x2001, 0x008a, 0x2003,
+	0x0002, 0x2003, 0x1001, 0x080c, 0x5122, 0x1108, 0x0011, 0x0cd8,
+	0x0005, 0x0026, 0x0126, 0x2011, 0x0080, 0x080c, 0x0eb4, 0x20a9,
+	0x0900, 0x080c, 0x0ed5, 0x2011, 0x0040, 0x080c, 0x0eb4, 0x20a9,
+	0x0900, 0x080c, 0x0ed5, 0x0c78, 0x0026, 0x080c, 0x0ec1, 0x1118,
+	0x2011, 0x0040, 0x0098, 0x2011, 0x010e, 0x2214, 0x9294, 0x0007,
+	0x9296, 0x0007, 0x0118, 0x2011, 0xa880, 0x0010, 0x2011, 0x6840,
+	0xd0e4, 0x70e7, 0x0000, 0x1128, 0x70e7, 0x0fa0, 0x080c, 0x0ec6,
+	0x002e, 0x0005, 0x0026, 0x080c, 0x0ec1, 0x0128, 0xd0a4, 0x1138,
+	0x2011, 0xcdd5, 0x0010, 0x2011, 0x0080, 0x080c, 0x0ec6, 0x002e,
+	0x0005, 0x0026, 0x70e7, 0x0000, 0x080c, 0x0ec1, 0x1148, 0x080c,
+	0x28c8, 0x1118, 0x2011, 0x8484, 0x0058, 0x2011, 0x8282, 0x0040,
+	0x080c, 0x28c8, 0x1118, 0x2011, 0xcdc5, 0x0010, 0x2011, 0xcac2,
+	0x080c, 0x0ec6, 0x002e, 0x0005, 0x00e6, 0x0006, 0x2071, 0x1800,
+	0xd0b4, 0x70e0, 0x1110, 0xc0e4, 0x0048, 0x0006, 0x3b00, 0x9084,
+	0xff3f, 0x20d8, 0x000e, 0x70e7, 0x0000, 0xc0e5, 0x0079, 0x000e,
+	0x00ee, 0x0005, 0x00e6, 0x2071, 0x1800, 0xd0e4, 0x70e0, 0x1110,
+	0xc0dc, 0x0008, 0xc0dd, 0x0011, 0x00ee, 0x0005, 0x70e2, 0x7000,
+	0x9084, 0x0007, 0x000b, 0x0005, 0x0e83, 0x0e5a, 0x0e5a, 0x0e3c,
+	0x0e69, 0x0e5a, 0x0e5a, 0x0e69, 0x0016, 0x3b08, 0x3a00, 0x9104,
+	0x918d, 0x00c0, 0x21d8, 0x9084, 0xff3f, 0x9205, 0x20d0, 0x001e,
+	0x0005, 0x2001, 0x1838, 0x2004, 0xd0dc, 0x0005, 0x9e86, 0x1800,
+	0x190c, 0x0db2, 0x70e0, 0xd0e4, 0x0108, 0xc2e5, 0x72e2, 0xd0e4,
+	0x1118, 0x9294, 0x00c0, 0x0c01, 0x0005, 0x1d04, 0x0ed5, 0x2091,
+	0x6000, 0x1f04, 0x0ed5, 0x0005, 0x890e, 0x810e, 0x810f, 0x9194,
+	0x003f, 0x918c, 0xffc0, 0x0005, 0x0006, 0x2200, 0x914d, 0x894f,
+	0x894d, 0x894d, 0x000e, 0x000e, 0x0005, 0x01d6, 0x0146, 0x0036,
+	0x0096, 0x2061, 0x1883, 0x600b, 0x0000, 0x600f, 0x0000, 0x6003,
+	0x0000, 0x6007, 0x0000, 0x2009, 0xffc0, 0x2105, 0x0006, 0x2001,
+	0xaaaa, 0x200f, 0x2019, 0x5555, 0x9016, 0x2049, 0x0bff, 0xab02,
+	0xa001, 0xa001, 0xa800, 0x9306, 0x1138, 0x2105, 0x9306, 0x0120,
+	0x8210, 0x99c8, 0x0400, 0x0c98, 0x000e, 0x200f, 0x2001, 0x1893,
+	0x928a, 0x000e, 0x1638, 0x928a, 0x0006, 0x2011, 0x0006, 0x1210,
+	0x2011, 0x0000, 0x2202, 0x9006, 0x2008, 0x82ff, 0x01b0, 0x8200,
+	0x600a, 0x600f, 0xffff, 0x6003, 0x0002, 0x6007, 0x0000, 0x0026,
+	0x2019, 0x0010, 0x9280, 0x0001, 0x20e8, 0x21a0, 0x21a8, 0x4104,
+	0x8319, 0x1de0, 0x8211, 0x1da0, 0x002e, 0x009e, 0x003e, 0x014e,
+	0x01de, 0x0005, 0x2011, 0x000e, 0x08e8, 0x0016, 0x0026, 0x0096,
+	0x3348, 0x080c, 0x0edc, 0x2100, 0x9300, 0x2098, 0x22e0, 0x009e,
+	0x002e, 0x001e, 0x0036, 0x3518, 0x20a9, 0x0001, 0x4002, 0x8007,
+	0x4004, 0x8319, 0x1dd8, 0x003e, 0x0005, 0x20e9, 0x0001, 0x71b0,
+	0x81ff, 0x11c0, 0x9006, 0x2009, 0x0200, 0x20a9, 0x0002, 0x9298,
+	0x0018, 0x23a0, 0x4001, 0x2009, 0x0700, 0x20a9, 0x0002, 0x9298,
+	0x0008, 0x23a0, 0x4001, 0x7074, 0x8007, 0x7178, 0x810f, 0x20a9,
+	0x0002, 0x4001, 0x9298, 0x000c, 0x23a0, 0x900e, 0x080c, 0x0d99,
+	0x2001, 0x0000, 0x810f, 0x20a9, 0x0002, 0x4001, 0x0005, 0x89ff,
+	0x0140, 0xa804, 0xa807, 0x0000, 0x0006, 0x080c, 0x1007, 0x009e,
+	0x0cb0, 0x0005, 0x00e6, 0x2071, 0x1800, 0x080c, 0x1080, 0x090c,
+	0x0db2, 0x00ee, 0x0005, 0x0086, 0x00e6, 0x0006, 0x0026, 0x0036,
+	0x0126, 0x2091, 0x8000, 0x00c9, 0x2071, 0x1800, 0x73b8, 0x702c,
+	0x9016, 0x9045, 0x0158, 0x8210, 0x9906, 0x090c, 0x0db2, 0x2300,
+	0x9202, 0x0120, 0x1a0c, 0x0db2, 0xa000, 0x0c98, 0x012e, 0x003e,
+	0x002e, 0x000e, 0x00ee, 0x008e, 0x0005, 0x0086, 0x00e6, 0x0006,
+	0x0126, 0x2091, 0x8000, 0x2071, 0x1906, 0x7010, 0x9005, 0x0140,
+	0x7018, 0x9045, 0x0128, 0x9906, 0x090c, 0x0db2, 0xa000, 0x0cc8,
+	0x012e, 0x000e, 0x00ee, 0x008e, 0x0005, 0x00e6, 0x2071, 0x1800,
+	0x0126, 0x2091, 0x8000, 0x70b8, 0x8001, 0x0270, 0x70ba, 0x702c,
+	0x2048, 0x9085, 0x0001, 0xa800, 0x702e, 0xa803, 0x0000, 0xa807,
+	0x0000, 0x012e, 0x00ee, 0x0005, 0x904e, 0x0cd8, 0x00e6, 0x0126,
+	0x2091, 0x8000, 0x2071, 0x1800, 0x70b8, 0x90ca, 0x0040, 0x0268,
+	0x8001, 0x70ba, 0x702c, 0x2048, 0xa800, 0x702e, 0xa803, 0x0000,
+	0xa807, 0x0000, 0x012e, 0x00ee, 0x0005, 0x904e, 0x0cd8, 0x00e6,
+	0x0126, 0x2091, 0x8000, 0x0016, 0x890e, 0x810e, 0x810f, 0x9184,
+	0x003f, 0xa862, 0x9184, 0xffc0, 0xa85e, 0x001e, 0x0020, 0x00e6,
+	0x0126, 0x2091, 0x8000, 0x2071, 0x1800, 0x702c, 0xa802, 0x2900,
+	0x702e, 0x70b8, 0x8000, 0x70ba, 0x080c, 0x7b7c, 0x012e, 0x00ee,
+	0x0005, 0x2071, 0x1800, 0x9026, 0x2009, 0x0000, 0x2049, 0x0400,
+	0x2900, 0x702e, 0x8940, 0x2800, 0xa802, 0xa95e, 0xa863, 0x0001,
+	0x8420, 0x9886, 0x0440, 0x0120, 0x2848, 0x9188, 0x0040, 0x0c90,
+	0x2071, 0x1883, 0x7000, 0x9005, 0x11a0, 0x2001, 0x0534, 0xa802,
+	0x2048, 0x2009, 0x4d00, 0x8940, 0x2800, 0xa802, 0xa95e, 0xa863,
+	0x0001, 0x8420, 0x9886, 0x0800, 0x0120, 0x2848, 0x9188, 0x0040,
+	0x0c90, 0x2071, 0x1883, 0x7104, 0x7200, 0x82ff, 0x01d0, 0x7308,
+	0x8318, 0x831f, 0x831b, 0x831b, 0x7312, 0x8319, 0x2001, 0x0800,
+	0xa802, 0x2048, 0x8900, 0xa802, 0x2040, 0xa95e, 0xaa62, 0x8420,
+	0x2300, 0x9906, 0x0130, 0x2848, 0x9188, 0x0040, 0x9291, 0x0000,
+	0x0c88, 0xa803, 0x0000, 0x2071, 0x1800, 0x74b6, 0x74ba, 0x0005,
+	0x00e6, 0x0016, 0x9984, 0xfc00, 0x01e8, 0x908c, 0xf800, 0x1168,
+	0x9982, 0x0400, 0x02b8, 0x9982, 0x0440, 0x0278, 0x9982, 0x0534,
+	0x0288, 0x9982, 0x0800, 0x1270, 0x0040, 0x9982, 0x0800, 0x0250,
+	0x2071, 0x1883, 0x7010, 0x9902, 0x1228, 0x9085, 0x0001, 0x001e,
+	0x00ee, 0x0005, 0x9006, 0x0cd8, 0x00e6, 0x2071, 0x19e7, 0x7007,
+	0x0000, 0x9006, 0x701e, 0x7022, 0x7002, 0x2071, 0x0000, 0x7010,
+	0x9085, 0x8004, 0x7012, 0x00ee, 0x0005, 0x0126, 0x2091, 0x8000,
+	0x00e6, 0xa06f, 0x0000, 0x2071, 0x19e7, 0x701c, 0x9088, 0x19f1,
+	0x280a, 0x8000, 0x9084, 0x003f, 0x701e, 0x7120, 0x9106, 0x090c,
+	0x0db2, 0x7004, 0x9005, 0x1128, 0x00f6, 0x2079, 0x0080, 0x00a9,
+	0x00fe, 0x00ee, 0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0x00e6,
+	0x2071, 0x19e7, 0x7004, 0x9005, 0x1128, 0x00f6, 0x2079, 0x0080,
+	0x0021, 0x00fe, 0x00ee, 0x012e, 0x0005, 0x7004, 0x9086, 0x0000,
+	0x1110, 0x7007, 0x0006, 0x7000, 0x0002, 0x10f7, 0x10f5, 0x10f5,
+	0x10f5, 0x126b, 0x126b, 0x126b, 0x126b, 0x080c, 0x0db2, 0x701c,
+	0x7120, 0x9106, 0x1148, 0x792c, 0x9184, 0x0001, 0x1120, 0xd1fc,
+	0x1110, 0x7007, 0x0000, 0x0005, 0x0096, 0x9180, 0x19f1, 0x2004,
+	0x700a, 0x2048, 0x8108, 0x918c, 0x003f, 0x7122, 0x782b, 0x0026,
+	0xa88c, 0x7802, 0xa890, 0x7806, 0xa894, 0x780a, 0xa898, 0x780e,
+	0xa878, 0x700e, 0xa870, 0x7016, 0xa874, 0x701a, 0xa868, 0x009e,
+	0xd084, 0x0120, 0x7007, 0x0001, 0x0029, 0x0005, 0x7007, 0x0002,
+	0x00b1, 0x0005, 0x0016, 0x0026, 0x710c, 0x2011, 0x0040, 0x9182,
+	0x0040, 0x1210, 0x2110, 0x9006, 0x700e, 0x7212, 0x8203, 0x7812,
+	0x782b, 0x0020, 0x782b, 0x0041, 0x002e, 0x001e, 0x0005, 0x0016,
+	0x0026, 0x0136, 0x0146, 0x0156, 0x7014, 0x20e0, 0x7018, 0x2098,
+	0x20e9, 0x0000, 0x20a1, 0x0088, 0x782b, 0x0026, 0x710c, 0x2011,
+	0x0040, 0x9182, 0x0040, 0x1210, 0x2110, 0x9006, 0x700e, 0x22a8,
+	0x4006, 0x8203, 0x7812, 0x782b, 0x0020, 0x3300, 0x701a, 0x782b,
+	0x0001, 0x015e, 0x014e, 0x013e, 0x002e, 0x001e, 0x0005, 0x2009,
+	0x19e7, 0x2104, 0xc095, 0x200a, 0x080c, 0x10d4, 0x0005, 0x0016,
+	0x00e6, 0x2071, 0x19e7, 0x00f6, 0x2079, 0x0080, 0x792c, 0x782b,
+	0x0002, 0xd1fc, 0x0120, 0x918c, 0x0700, 0x7004, 0x0023, 0x00fe,
+	0x00ee, 0x001e, 0x0005, 0x10e5, 0x118a, 0x11be, 0x0db2, 0x0db2,
+	0x1277, 0x0db2, 0x918c, 0x0700, 0x1550, 0x0136, 0x0146, 0x0156,
+	0x7014, 0x20e8, 0x7018, 0x20a0, 0x20e1, 0x0000, 0x2099, 0x0088,
+	0x782b, 0x0040, 0x7010, 0x20a8, 0x4005, 0x3400, 0x701a, 0x015e,
+	0x014e, 0x013e, 0x700c, 0x9005, 0x0578, 0x7800, 0x7802, 0x7804,
+	0x7806, 0x080c, 0x112a, 0x0005, 0x7008, 0x0096, 0x2048, 0xa86f,
+	0x0100, 0x009e, 0x7007, 0x0000, 0x080c, 0x10e5, 0x0005, 0x7008,
+	0x0096, 0x2048, 0xa86f, 0x0200, 0x009e, 0x0ca0, 0x918c, 0x0700,
+	0x1150, 0x700c, 0x9005, 0x0180, 0x7800, 0x7802, 0x7804, 0x7806,
+	0x080c, 0x113f, 0x0005, 0x7008, 0x0096, 0x2048, 0xa86f, 0x0200,
+	0x009e, 0x7007, 0x0000, 0x0080, 0x0096, 0x7008, 0x2048, 0x7800,
+	0xa88e, 0x7804, 0xa892, 0x7808, 0xa896, 0x780c, 0xa89a, 0xa86f,
+	0x0100, 0x009e, 0x7007, 0x0000, 0x0096, 0x00d6, 0x7008, 0x2048,
+	0x2001, 0x18af, 0x2004, 0x9906, 0x1128, 0xa89c, 0x080f, 0x00de,
+	0x009e, 0x00a0, 0x00de, 0x009e, 0x0096, 0x00d6, 0x7008, 0x2048,
+	0x0081, 0x0150, 0xa89c, 0x0086, 0x2940, 0x080f, 0x008e, 0x00de,
+	0x009e, 0x080c, 0x10d4, 0x0005, 0x00de, 0x009e, 0x080c, 0x10d4,
+	0x0005, 0xa8a8, 0xd08c, 0x0005, 0x0096, 0xa0a0, 0x904d, 0x090c,
+	0x0db2, 0xa06c, 0x908e, 0x0100, 0x0130, 0xa87b, 0x0030, 0xa883,
+	0x0000, 0xa897, 0x4002, 0x080c, 0x6529, 0xa09f, 0x0000, 0xa0a3,
+	0x0000, 0x2848, 0x080c, 0x1007, 0x009e, 0x0005, 0x00a6, 0xa0a0,
+	0x904d, 0x090c, 0x0db2, 0xa06c, 0x908e, 0x0100, 0x0128, 0xa87b,
+	0x0001, 0xa883, 0x0000, 0x00c0, 0xa80c, 0x2050, 0xb004, 0x9005,
+	0x0198, 0xa80e, 0x2050, 0x8006, 0x8006, 0x8007, 0x908c, 0x003f,
+	0x9084, 0xffc0, 0x9080, 0x0002, 0xa076, 0xa172, 0xb000, 0xa07a,
+	0x2810, 0x080c, 0x10b5, 0x00e8, 0xa97c, 0xa894, 0x0016, 0x0006,
+	0x080c, 0x6529, 0x000e, 0x001e, 0xd1fc, 0x1138, 0xd1f4, 0x0128,
+	0x00c6, 0x2060, 0x080c, 0x99d6, 0x00ce, 0x7008, 0x2048, 0xa89f,
+	0x0000, 0xa8a3, 0x0000, 0x080c, 0x1007, 0x7007, 0x0000, 0x080c,
+	0x10d4, 0x00ae, 0x0005, 0x0126, 0x2091, 0x8000, 0x782b, 0x1001,
+	0x7007, 0x0005, 0x7000, 0xc094, 0x7002, 0x012e, 0x0005, 0x7007,
+	0x0000, 0x080c, 0x10e5, 0x0005, 0x0126, 0x2091, 0x2200, 0x2079,
+	0x0300, 0x2071, 0x1a31, 0x7003, 0x0000, 0x78bf, 0x00f6, 0x00c1,
+	0x7803, 0x0003, 0x780f, 0x0000, 0x20a9, 0x01ed, 0x2061, 0xd372,
+	0x2c0d, 0x7912, 0xe104, 0x9ce0, 0x0002, 0x7916, 0x1f04, 0x1290,
+	0x7807, 0x0001, 0x7803, 0x0000, 0x7803, 0x0001, 0x012e, 0x0005,
+	0x00c6, 0x7803, 0x0000, 0x7808, 0xd09c, 0x0110, 0x7820, 0x0cd8,
+	0x2001, 0x1a32, 0x2003, 0x0000, 0x78ab, 0x0004, 0x78ac, 0xd0ac,
+	0x1de8, 0x78ab, 0x0002, 0x7807, 0x0001, 0x7827, 0x0030, 0x782b,
+	0x0400, 0x7827, 0x0031, 0x782b, 0x1a46, 0x781f, 0xff00, 0x781b,
+	0xff00, 0x2001, 0x0200, 0x2004, 0xd0dc, 0x0110, 0x781f, 0x0303,
+	0x2061, 0x1a46, 0x602f, 0x1cd0, 0x2001, 0x1818, 0x2004, 0x9082,
+	0x1cd0, 0x6032, 0x603b, 0x1da2, 0x00ce, 0x0005, 0x0126, 0x2091,
+	0x2200, 0x7808, 0xd09c, 0x0158, 0x7820, 0x908c, 0xf000, 0x1588,
+	0x908a, 0x0021, 0x1a0c, 0x0db2, 0x0043, 0x012e, 0x0005, 0x9084,
+	0x0070, 0x190c, 0x0db2, 0x012e, 0x0005, 0x130f, 0x130f, 0x1318,
+	0x131d, 0x1321, 0x1326, 0x134e, 0x1352, 0x1360, 0x1364, 0x130f,
+	0x13ee, 0x13f2, 0x1455, 0x130f, 0x130f, 0x130f, 0x130f, 0x130f,
+	0x130f, 0x130f, 0x130f, 0x130f, 0x130f, 0x130f, 0x130f, 0x130f,
+	0x1328, 0x130f, 0x130f, 0x130f, 0x130f, 0x130f, 0x130f, 0x080c,
+	0x0db2, 0x2009, 0x0048, 0x2060, 0x080c, 0x9a50, 0x012e, 0x0005,
+	0x7004, 0xc085, 0xc0b5, 0x7006, 0x0005, 0x7004, 0xc085, 0x7006,
+	0x0005, 0x080c, 0x145c, 0x080c, 0x1518, 0x0005, 0x080c, 0x0db2,
+	0x080c, 0x145c, 0x2060, 0x6014, 0x0096, 0x2048, 0xa83b, 0xffff,
+	0x009e, 0x2009, 0x0048, 0x080c, 0x9a50, 0x2001, 0x015d, 0x2003,
+	0x0000, 0x2009, 0x03e8, 0x8109, 0x0160, 0x2001, 0x0201, 0x2004,
+	0x9005, 0x0dc8, 0x2001, 0x0218, 0x2004, 0xd0ec, 0x1110, 0x080c,
+	0x1461, 0x2001, 0x0307, 0x2003, 0x8000, 0x0005, 0x7004, 0xc095,
+	0x7006, 0x0005, 0x080c, 0x145c, 0x2060, 0x6014, 0x0096, 0x2048,
+	0xa83b, 0xffff, 0x009e, 0x2009, 0x0048, 0x080c, 0x9a50, 0x0005,
+	0x080c, 0x145c, 0x080c, 0x0db2, 0x080c, 0x145c, 0x080c, 0x13d9,
+	0x7827, 0x0018, 0x79ac, 0xd1dc, 0x0540, 0x7827, 0x0015, 0x7828,
+	0x782b, 0x0000, 0x9065, 0x0138, 0x2001, 0x020d, 0x2003, 0x0050,
+	0x2003, 0x0020, 0x0400, 0x7004, 0x9005, 0x1180, 0x78ab, 0x0004,
+	0x7827, 0x0018, 0x782b, 0x0000, 0xd1bc, 0x090c, 0x0db2, 0x2001,
+	0x020d, 0x2003, 0x0050, 0x2003, 0x0020, 0x0480, 0x78ab, 0x0004,
+	0x7803, 0x0001, 0x080c, 0x13f2, 0x0005, 0x7828, 0x782b, 0x0000,
+	0x9065, 0x090c, 0x0db2, 0x6014, 0x2048, 0x78ab, 0x0004, 0x918c,
+	0x0700, 0x0198, 0x080c, 0x763f, 0x080c, 0x1872, 0x080c, 0xb5fb,
+	0x0158, 0xa9ac, 0xa936, 0xa9b0, 0xa93a, 0xa83f, 0xffff, 0xa843,
+	0xffff, 0xa880, 0xc0bd, 0xa882, 0x0005, 0x6010, 0x00b6, 0x2058,
+	0xb800, 0x00be, 0xd0bc, 0x6024, 0x190c, 0xb9d9, 0x2029, 0x00c8,
+	0x8529, 0x0128, 0x2001, 0x0201, 0x2004, 0x9005, 0x0dc8, 0x7dbc,
+	0x080c, 0xd31b, 0xd5a4, 0x1118, 0x080c, 0x1461, 0x0005, 0x080c,
+	0x763f, 0x080c, 0x1872, 0x0005, 0x781f, 0x0300, 0x7803, 0x0001,
+	0x0005, 0x0016, 0x0066, 0x0076, 0x00f6, 0x2079, 0x0300, 0x7908,
+	0x918c, 0x0007, 0x9186, 0x0003, 0x0120, 0x2001, 0x0016, 0x080c,
+	0x14d2, 0x00fe, 0x007e, 0x006e, 0x001e, 0x0005, 0x7004, 0xc09d,
+	0x7006, 0x0005, 0x7104, 0x9184, 0x0004, 0x190c, 0x0db2, 0xd184,
+	0x1189, 0xd19c, 0x0158, 0xc19c, 0x7106, 0x2001, 0x020d, 0x2003,
+	0x0050, 0x2003, 0x0020, 0x080c, 0x1461, 0x0005, 0x81ff, 0x190c,
+	0x0db2, 0x0005, 0xc184, 0xd1b4, 0xc1b4, 0x7106, 0x0016, 0x00e6,
+	0x15e0, 0x2071, 0x0200, 0x080c, 0x150c, 0x6014, 0x9005, 0x05a8,
+	0x0096, 0x2048, 0xa864, 0x009e, 0x9084, 0x00ff, 0x908e, 0x0029,
+	0x0160, 0x908e, 0x0048, 0x1548, 0x601c, 0xd084, 0x11d8, 0x00f6,
+	0x2c78, 0x080c, 0x1582, 0x00fe, 0x00a8, 0x00f6, 0x2c78, 0x080c,
+	0x16b6, 0x00fe, 0x2009, 0x01f4, 0x8109, 0x0160, 0x2001, 0x0201,
+	0x2004, 0x9005, 0x0dc8, 0x2001, 0x0218, 0x2004, 0xd0ec, 0x1110,
+	0x0401, 0x0040, 0x2001, 0x020d, 0x2003, 0x0020, 0x080c, 0x12a0,
+	0x7803, 0x0001, 0x00ee, 0x001e, 0x0005, 0x2001, 0x020d, 0x2003,
+	0x0050, 0x2003, 0x0020, 0x0069, 0x0ca8, 0x0031, 0x2060, 0x2009,
+	0x0053, 0x080c, 0x9a50, 0x0005, 0x7808, 0xd09c, 0x0de8, 0x7820,
+	0x0005, 0x080c, 0x13d9, 0x00d6, 0x2069, 0x0200, 0x2009, 0x01f4,
+	0x8109, 0x0510, 0x6804, 0x9005, 0x0dd8, 0x2001, 0x015d, 0x2003,
+	0x0000, 0x79bc, 0xd1a4, 0x1528, 0x79b8, 0x918c, 0x0fff, 0x0180,
+	0x9182, 0x0841, 0x1268, 0x9188, 0x0007, 0x918c, 0x0ff8, 0x810c,
+	0x810c, 0x810c, 0x080c, 0x14c4, 0x6827, 0x0001, 0x8109, 0x1dd0,
+	0x04d9, 0x6827, 0x0002, 0x04c1, 0x6804, 0x9005, 0x1130, 0x682c,
+	0xd0e4, 0x1500, 0x6804, 0x9005, 0x0de8, 0x79b8, 0xd1ec, 0x1130,
+	0x08c0, 0x080c, 0x763f, 0x080c, 0x1872, 0x0090, 0x7827, 0x0015,
+	0x782b, 0x0000, 0x7827, 0x0018, 0x782b, 0x0000, 0x2001, 0x020d,
+	0x2003, 0x0020, 0x2001, 0x0307, 0x2003, 0x0300, 0x7803, 0x0001,
+	0x00de, 0x0005, 0x682c, 0x9084, 0x5400, 0x9086, 0x5400, 0x0d30,
+	0x7827, 0x0015, 0x782b, 0x0000, 0x7803, 0x0001, 0x6800, 0x9085,
+	0x1800, 0x6802, 0x00de, 0x0005, 0x6824, 0x9084, 0x0003, 0x1de0,
+	0x0005, 0x2001, 0x0030, 0x2c08, 0x621c, 0x0021, 0x7830, 0x9086,
+	0x0041, 0x0005, 0x00f6, 0x2079, 0x0300, 0x0006, 0x7808, 0xd09c,
+	0x0140, 0x0016, 0x0026, 0x00c6, 0x080c, 0x12d6, 0x00ce, 0x002e,
+	0x001e, 0x000e, 0x0006, 0x7832, 0x7936, 0x7a3a, 0x781b, 0x8080,
+	0x2009, 0xff00, 0x8109, 0x0130, 0x7818, 0xd0bc, 0x1dd8, 0x000e,
+	0x00fe, 0x0005, 0x000e, 0x792c, 0x3900, 0x8000, 0x2004, 0x080c,
+	0x0db2, 0x7832, 0x7936, 0x7a3a, 0x781b, 0x8080, 0x2009, 0xff00,
+	0x8109, 0x0120, 0x7818, 0xd0bc, 0x1dd8, 0x0005, 0x792c, 0x3900,
+	0x8000, 0x2004, 0x080c, 0x0db2, 0x7037, 0x0001, 0x7150, 0x7037,
+	0x0002, 0x7050, 0x2060, 0xd1bc, 0x1110, 0x7054, 0x2060, 0x0005,
+	0x00e6, 0x0016, 0x2071, 0x0200, 0x0c79, 0x6124, 0xd1dc, 0x01f8,
+	0x701c, 0xd08c, 0x0904, 0x1577, 0x7017, 0x0000, 0x2001, 0x0264,
+	0x2004, 0xd0bc, 0x0904, 0x1577, 0x2001, 0x0268, 0x00c6, 0x2064,
+	0x6104, 0x6038, 0x00ce, 0x918e, 0x0039, 0x1904, 0x1577, 0x9c06,
+	0x15f0, 0x0126, 0x2091, 0x2600, 0x080c, 0x7597, 0x012e, 0x7358,
+	0x745c, 0x6014, 0x905d, 0x0598, 0x2b48, 0x6010, 0x00b6, 0x2058,
+	0xb800, 0x00be, 0xd0bc, 0x190c, 0xb9b4, 0xab42, 0xac3e, 0x2001,
+	0x1875, 0x2004, 0xd0b4, 0x1170, 0x601c, 0xd0e4, 0x1158, 0x6010,
+	0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x1120, 0xa83b, 0x7fff,
+	0xa837, 0xffff, 0x080c, 0x1dc2, 0x1190, 0x080c, 0x1705, 0x2a00,
+	0xa816, 0x0130, 0x2800, 0xa80e, 0x2c05, 0xa80a, 0x2c00, 0xa812,
+	0x7037, 0x0020, 0x781f, 0x0300, 0x001e, 0x00ee, 0x0005, 0x7037,
+	0x0050, 0x7037, 0x0020, 0x001e, 0x00ee, 0x080c, 0x1461, 0x0005,
+	0x080c, 0x0db2, 0x2ff0, 0x0126, 0x2091, 0x2200, 0x3e60, 0x6014,
+	0x2048, 0x2940, 0x903e, 0x2730, 0xa864, 0x2068, 0xa81a, 0x9d84,
+	0x000f, 0x9088, 0x1da2, 0x2165, 0x0002, 0x15ac, 0x15f9, 0x15ac,
+	0x15ac, 0x15ac, 0x15db, 0x15ac, 0x15b0, 0x15a5, 0x15f0, 0x15ac,
+	0x15ac, 0x15ac, 0x16b4, 0x15c4, 0x15ba, 0xa964, 0x918c, 0x00ff,
+	0x918e, 0x0048, 0x0904, 0x15f0, 0x9085, 0x0001, 0x0804, 0x16ac,
+	0xa87c, 0xd0bc, 0x0dc8, 0xa890, 0xa842, 0xa88c, 0xa83e, 0xa888,
+	0x0804, 0x1600, 0xa87c, 0xd0bc, 0x0d78, 0xa890, 0xa842, 0xa88c,
+	0xa83e, 0xa888, 0x0804, 0x164f, 0xa87c, 0xd0bc, 0x0d28, 0xa890,
+	0xa842, 0xa88c, 0xa83e, 0xa804, 0x9045, 0x090c, 0x0db2, 0xa164,
+	0xa91a, 0x91ec, 0x000f, 0x9d80, 0x1da2, 0x2065, 0xa888, 0xd19c,
+	0x1904, 0x164f, 0x0428, 0xa87c, 0xd0ac, 0x0970, 0xa804, 0x9045,
+	0x090c, 0x0db2, 0xa164, 0xa91a, 0x91ec, 0x000f, 0x9d80, 0x1da2,
+	0x2065, 0x9006, 0xa842, 0xa83e, 0xd19c, 0x1904, 0x164f, 0x0080,
+	0xa87c, 0xd0ac, 0x0904, 0x15ac, 0x9006, 0xa842, 0xa83e, 0x0804,
+	0x164f, 0xa87c, 0xd0ac, 0x0904, 0x15ac, 0x9006, 0xa842, 0xa83e,
+	0x2c05, 0x908a, 0x0036, 0x1a0c, 0x0db2, 0x9082, 0x001b, 0x0002,
+	0x1623, 0x1623, 0x1625, 0x1623, 0x1623, 0x1623, 0x162b, 0x1623,
+	0x1623, 0x1623, 0x1631, 0x1623, 0x1623, 0x1623, 0x1637, 0x1623,
+	0x1623, 0x1623, 0x163d, 0x1623, 0x1623, 0x1623, 0x1643, 0x1623,
+	0x1623, 0x1623, 0x1649, 0x080c, 0x0db2, 0xa574, 0xa478, 0xa37c,
+	0xa280, 0x0804, 0x1694, 0xa584, 0xa488, 0xa38c, 0xa290, 0x0804,
+	0x1694, 0xa594, 0xa498, 0xa39c, 0xa2a0, 0x0804, 0x1694, 0xa5a4,
+	0xa4a8, 0xa3ac, 0xa2b0, 0x0804, 0x1694, 0xa5b4, 0xa4b8, 0xa3bc,
+	0xa2c0, 0x0804, 0x1694, 0xa5c4, 0xa4c8, 0xa3cc, 0xa2d0, 0x0804,
+	0x1694, 0xa5d4, 0xa4d8, 0xa3dc, 0xa2e0, 0x0804, 0x1694, 0x2c05,
+	0x908a, 0x0034, 0x1a0c, 0x0db2, 0x9082, 0x001b, 0x0002, 0x1672,
+	0x1670, 0x1670, 0x1670, 0x1670, 0x1670, 0x1679, 0x1670, 0x1670,
+	0x1670, 0x1670, 0x1670, 0x1680, 0x1670, 0x1670, 0x1670, 0x1670,
+	0x1670, 0x1687, 0x1670, 0x1670, 0x1670, 0x1670, 0x1670, 0x168e,
+	0x080c, 0x0db2, 0xa56c, 0xa470, 0xa774, 0xa678, 0xa37c, 0xa280,
+	0x00d8, 0xa584, 0xa488, 0xa78c, 0xa690, 0xa394, 0xa298, 0x00a0,
+	0xa59c, 0xa4a0, 0xa7a4, 0xa6a8, 0xa3ac, 0xa2b0, 0x0068, 0xa5b4,
+	0xa4b8, 0xa7bc, 0xa6c0, 0xa3c4, 0xa2c8, 0x0030, 0xa5cc, 0xa4d0,
+	0xa7d4, 0xa6d8, 0xa3dc, 0xa2e0, 0xab2e, 0xaa32, 0xad1e, 0xac22,
+	0xaf26, 0xae2a, 0xa988, 0x8c60, 0x2c1d, 0xa8ac, 0xaab0, 0xa836,
+	0xaa3a, 0x8109, 0xa916, 0x1150, 0x3e60, 0x601c, 0xc085, 0x601e,
+	0xa87c, 0xc0dd, 0xa87e, 0x9006, 0x012e, 0x0005, 0x2800, 0xa80e,
+	0xab0a, 0x2c00, 0xa812, 0x0c80, 0x0804, 0x15ac, 0x2ff0, 0x0126,
+	0x2091, 0x2200, 0x3e60, 0x6014, 0x2048, 0x2940, 0xa80e, 0x2061,
+	0x1d9d, 0xa80b, 0x1d9d, 0x2c05, 0xa812, 0xa964, 0xa91a, 0xa87c,
+	0xd0ac, 0x090c, 0x0db2, 0x9006, 0xa842, 0xa83e, 0x2c05, 0x908a,
+	0x0034, 0x1a0c, 0x0db2, 0xadcc, 0xacd0, 0xafd4, 0xaed8, 0xabdc,
+	0xaae0, 0xab2e, 0xaa32, 0xad1e, 0xac22, 0xaf26, 0xae2a, 0xa8ac,
+	0xaab0, 0xa836, 0xaa3a, 0xa988, 0x918a, 0x0002, 0xa916, 0x1150,
+	0x3e60, 0x601c, 0xc085, 0x601e, 0xa87c, 0xc0dd, 0xa87e, 0x9006,
+	0x012e, 0x0005, 0xa804, 0x9045, 0x090c, 0x0db2, 0xa80e, 0xa064,
+	0xa81a, 0x9084, 0x000f, 0x9080, 0x1da2, 0x2015, 0x82ff, 0x090c,
+	0x0db2, 0xaa0a, 0x2205, 0xa812, 0x0c18, 0x903e, 0x2730, 0xa880,
+	0xd0fc, 0x1190, 0x2d00, 0x0002, 0x17fa, 0x175c, 0x175c, 0x17fa,
+	0x17fa, 0x17f4, 0x17fa, 0x175c, 0x17fa, 0x17ab, 0x17ab, 0x17fa,
+	0x17fa, 0x17fa, 0x17f1, 0x17ab, 0xc0fc, 0xa882, 0xab2c, 0xaa30,
+	0xad1c, 0xac20, 0xdd9c, 0x0904, 0x17fc, 0x2c05, 0x908a, 0x0034,
+	0x1a0c, 0x0db2, 0x9082, 0x001b, 0x0002, 0x1748, 0x1746, 0x1746,
+	0x1746, 0x1746, 0x1746, 0x174c, 0x1746, 0x1746, 0x1746, 0x1746,
+	0x1746, 0x1750, 0x1746, 0x1746, 0x1746, 0x1746, 0x1746, 0x1754,
+	0x1746, 0x1746, 0x1746, 0x1746, 0x1746, 0x1758, 0x080c, 0x0db2,
+	0xa774, 0xa678, 0x0804, 0x17fc, 0xa78c, 0xa690, 0x0804, 0x17fc,
+	0xa7a4, 0xa6a8, 0x0804, 0x17fc, 0xa7bc, 0xa6c0, 0x0804, 0x17fc,
+	0xa7d4, 0xa6d8, 0x0804, 0x17fc, 0x2c05, 0x908a, 0x0036, 0x1a0c,
+	0x0db2, 0x9082, 0x001b, 0x0002, 0x177f, 0x177f, 0x1781, 0x177f,
+	0x177f, 0x177f, 0x1787, 0x177f, 0x177f, 0x177f, 0x178d, 0x177f,
+	0x177f, 0x177f, 0x1793, 0x177f, 0x177f, 0x177f, 0x1799, 0x177f,
+	0x177f, 0x177f, 0x179f, 0x177f, 0x177f, 0x177f, 0x17a5, 0x080c,
+	0x0db2, 0xa574, 0xa478, 0xa37c, 0xa280, 0x0804, 0x17fc, 0xa584,
+	0xa488, 0xa38c, 0xa290, 0x0804, 0x17fc, 0xa594, 0xa498, 0xa39c,
+	0xa2a0, 0x0804, 0x17fc, 0xa5a4, 0xa4a8, 0xa3ac, 0xa2b0, 0x0804,
+	0x17fc, 0xa5b4, 0xa4b8, 0xa3bc, 0xa2c0, 0x0804, 0x17fc, 0xa5c4,
+	0xa4c8, 0xa3cc, 0xa2d0, 0x0804, 0x17fc, 0xa5d4, 0xa4d8, 0xa3dc,
+	0xa2e0, 0x0804, 0x17fc, 0x2c05, 0x908a, 0x0034, 0x1a0c, 0x0db2,
+	0x9082, 0x001b, 0x0002, 0x17ce, 0x17cc, 0x17cc, 0x17cc, 0x17cc,
+	0x17cc, 0x17d5, 0x17cc, 0x17cc, 0x17cc, 0x17cc, 0x17cc, 0x17dc,
+	0x17cc, 0x17cc, 0x17cc, 0x17cc, 0x17cc, 0x17e3, 0x17cc, 0x17cc,
+	0x17cc, 0x17cc, 0x17cc, 0x17ea, 0x080c, 0x0db2, 0xa56c, 0xa470,
+	0xa774, 0xa678, 0xa37c, 0xa280, 0x0438, 0xa584, 0xa488, 0xa78c,
+	0xa690, 0xa394, 0xa298, 0x0400, 0xa59c, 0xa4a0, 0xa7a4, 0xa6a8,
+	0xa3ac, 0xa2b0, 0x00c8, 0xa5b4, 0xa4b8, 0xa7bc, 0xa6c0, 0xa3c4,
+	0xa2c8, 0x0090, 0xa5cc, 0xa4d0, 0xa7d4, 0xa6d8, 0xa3dc, 0xa2e0,
+	0x0058, 0x9d86, 0x000e, 0x1130, 0x080c, 0x1d60, 0x1904, 0x1705,
+	0x900e, 0x0050, 0x080c, 0x0db2, 0xab2e, 0xaa32, 0xad1e, 0xac22,
+	0xaf26, 0xae2a, 0x080c, 0x1d60, 0x0005, 0x6014, 0x2048, 0x6118,
+	0x810c, 0x810c, 0x810c, 0x81ff, 0x1118, 0xa887, 0x0001, 0x0008,
+	0xa986, 0x601b, 0x0002, 0xa974, 0xd1dc, 0x1108, 0x0005, 0xa934,
+	0xa88c, 0x9106, 0x1158, 0xa938, 0xa890, 0x9106, 0x1138, 0x601c,
+	0xc084, 0x601e, 0x2009, 0x0048, 0x0804, 0x9a50, 0x0005, 0x0126,
+	0x00c6, 0x2091, 0x2200, 0x00ce, 0x7908, 0x918c, 0x0007, 0x9186,
+	0x0000, 0x05b0, 0x9186, 0x0003, 0x0598, 0x6020, 0x6023, 0x0000,
+	0x0006, 0x2031, 0x0008, 0x00c6, 0x781f, 0x0808, 0x7808, 0xd09c,
+	0x0120, 0x080c, 0x12d6, 0x8631, 0x1db8, 0x00ce, 0x781f, 0x0800,
+	0x2031, 0x0168, 0x00c6, 0x7808, 0xd09c, 0x190c, 0x12d6, 0x00ce,
+	0x2001, 0x0038, 0x080c, 0x18ff, 0x7930, 0x9186, 0x0040, 0x0160,
+	0x9186, 0x0042, 0x190c, 0x0db2, 0x2001, 0x001e, 0x8001, 0x1df0,
+	0x8631, 0x1d40, 0x080c, 0x190e, 0x000e, 0x6022, 0x012e, 0x0005,
+	0x080c, 0x18fb, 0x7827, 0x0015, 0x7828, 0x9c06, 0x1db8, 0x782b,
+	0x0000, 0x0ca0, 0x00f6, 0x2079, 0x0300, 0x7803, 0x0000, 0x78ab,
+	0x0004, 0x00fe, 0x080c, 0x6c53, 0x11b0, 0x2001, 0x0138, 0x2003,
+	0x0000, 0x2001, 0x0160, 0x2003, 0x0000, 0x2011, 0x012c, 0xa001,
+	0xa001, 0x8211, 0x1de0, 0x0081, 0x0066, 0x2031, 0x0000, 0x080c,
+	0x6d03, 0x006e, 0x0005, 0x0479, 0x0039, 0x2001, 0x0160, 0x2502,
+	0x2001, 0x0138, 0x2202, 0x0005, 0x00e6, 0x2071, 0x0200, 0x080c,
+	0x28dc, 0x2009, 0x003c, 0x080c, 0x20d9, 0x2001, 0x015d, 0x2003,
+	0x0000, 0x7000, 0x9084, 0x003c, 0x1de0, 0x080c, 0x7b7c, 0x70a0,
+	0x70a2, 0x7098, 0x709a, 0x709c, 0x709e, 0x2001, 0x020d, 0x2003,
+	0x0020, 0x00f6, 0x2079, 0x0300, 0x080c, 0x12a0, 0x7803, 0x0001,
+	0x00fe, 0x00ee, 0x0005, 0x2001, 0x0138, 0x2014, 0x2003, 0x0000,
+	0x2001, 0x0160, 0x202c, 0x2003, 0x0000, 0x080c, 0x6c53, 0x1108,
+	0x0005, 0x2021, 0x0260, 0x2001, 0x0141, 0x201c, 0xd3dc, 0x1168,
+	0x2001, 0x0109, 0x201c, 0x939c, 0x0048, 0x1160, 0x2001, 0x0111,
+	0x201c, 0x83ff, 0x1110, 0x8421, 0x1d70, 0x2001, 0x015d, 0x2003,
+	0x0000, 0x0005, 0x0046, 0x2021, 0x0019, 0x2003, 0x0048, 0xa001,
+	0xa001, 0x201c, 0x939c, 0x0048, 0x0120, 0x8421, 0x1db0, 0x004e,
+	0x0c60, 0x004e, 0x0c40, 0x601c, 0xc084, 0x601e, 0x0005, 0x2c08,
+	0x621c, 0x080c, 0x14d2, 0x7930, 0x0005, 0x2c08, 0x621c, 0x080c,
+	0x14f9, 0x7930, 0x0005, 0x8001, 0x1df0, 0x0005, 0x2031, 0x0005,
+	0x781c, 0x9084, 0x0007, 0x0170, 0x2001, 0x0038, 0x0c41, 0x9186,
+	0x0040, 0x0904, 0x196c, 0x2001, 0x001e, 0x0c69, 0x8631, 0x1d80,
+	0x080c, 0x0db2, 0x781f, 0x0202, 0x2001, 0x015d, 0x2003, 0x0000,
+	0x2001, 0x0b10, 0x0c01, 0x781c, 0xd084, 0x0110, 0x0861, 0x04e0,
+	0x2001, 0x0030, 0x0891, 0x9186, 0x0040, 0x0568, 0x781c, 0xd084,
+	0x1da8, 0x781f, 0x0101, 0x2001, 0x0014, 0x0869, 0x2001, 0x0037,
+	0x0821, 0x9186, 0x0040, 0x0140, 0x2001, 0x0030, 0x080c, 0x1905,
+	0x9186, 0x0040, 0x190c, 0x0db2, 0x00d6, 0x2069, 0x0200, 0x692c,
+	0xd1f4, 0x1170, 0xd1c4, 0x0160, 0xd19c, 0x0130, 0x6800, 0x9085,
+	0x1800, 0x6802, 0x00de, 0x0080, 0x6908, 0x9184, 0x0007, 0x1db0,
+	0x00de, 0x781f, 0x0100, 0x791c, 0x9184, 0x0007, 0x090c, 0x0db2,
+	0xa001, 0xa001, 0x781f, 0x0200, 0x0005, 0x0126, 0x2091, 0x2400,
+	0x2071, 0x1a34, 0x2079, 0x0090, 0x012e, 0x0005, 0x9280, 0x0005,
+	0x2004, 0x2048, 0xa97c, 0xd1dc, 0x1904, 0x19f1, 0xa964, 0x9184,
+	0x0007, 0x0002, 0x198a, 0x19dc, 0x1991, 0x1991, 0x1991, 0x19c4,
+	0x19a4, 0x1993, 0x2100, 0x9084, 0x00ff, 0x9086, 0x0048, 0x0904,
+	0x19dc, 0x080c, 0x0db2, 0xa87c, 0xd0b4, 0x0904, 0x1ba3, 0xa890,
+	0xa842, 0xa83a, 0xa88c, 0xa83e, 0xa836, 0xa8ac, 0xa846, 0xa8b0,
+	0xa84a, 0xa988, 0x0804, 0x19e4, 0xa864, 0x9084, 0x00ff, 0x9086,
+	0x001e, 0x1d38, 0xa87c, 0xd0b4, 0x0904, 0x1ba3, 0xa890, 0xa842,
+	0xa83a, 0xa88c, 0xa83e, 0xa836, 0xa8ac, 0xa846, 0xa8b0, 0xa84a,
+	0xa804, 0xa85a, 0x2040, 0xa064, 0x9084, 0x000f, 0x9080, 0x1da2,
+	0x2005, 0xa812, 0xa988, 0x0448, 0x918c, 0x00ff, 0x9186, 0x0015,
+	0x1540, 0xa87c, 0xd0b4, 0x0904, 0x1ba3, 0xa804, 0xa85a, 0x2040,
+	0xa064, 0x9084, 0x000f, 0x9080, 0x1da2, 0x2005, 0xa812, 0xa988,
+	0x9006, 0xa842, 0xa83e, 0x0088, 0xa87c, 0xd0b4, 0x0904, 0x1ba3,
+	0xa988, 0x9006, 0xa842, 0xa83e, 0x2900, 0xa85a, 0xa864, 0x9084,
+	0x000f, 0x9080, 0x1da2, 0x2005, 0xa812, 0xa916, 0xa87c, 0xc0dd,
+	0xa87e, 0x0005, 0x00f6, 0x2079, 0x0090, 0x782c, 0xd0fc, 0x190c,
+	0x1be4, 0x00e6, 0x2071, 0x1a34, 0x7000, 0x9005, 0x1904, 0x1a4b,
+	0x7206, 0x9280, 0x0005, 0x204c, 0x9280, 0x0004, 0x2004, 0x782b,
+	0x0004, 0x00f6, 0x2079, 0x0200, 0x7803, 0x0040, 0x00fe, 0x00b6,
+	0x2058, 0xb86c, 0x7836, 0xb890, 0x00be, 0x00f6, 0x2079, 0x0200,
+	0x7803, 0x0040, 0xa001, 0xa001, 0xa001, 0xa001, 0xa001, 0xa001,
+	0x781a, 0x2079, 0x0100, 0x8004, 0x78d6, 0x00fe, 0xa814, 0x2050,
+	0xa858, 0x2040, 0xa810, 0x2060, 0xa064, 0x90ec, 0x000f, 0xa944,
+	0x791a, 0x7116, 0xa848, 0x781e, 0x701a, 0x9006, 0x700e, 0x7012,
+	0x7004, 0xa940, 0xa838, 0x9106, 0x1188, 0xa93c, 0xa834, 0x9106,
+	0x1168, 0x8aff, 0x01a8, 0x0126, 0x2091, 0x8000, 0x00a1, 0x0108,
+	0x0091, 0x012e, 0x9006, 0x00ee, 0x00fe, 0x0005, 0x0036, 0x0046,
+	0xab38, 0xac34, 0x080c, 0x1dc2, 0x004e, 0x003e, 0x0d50, 0x0c98,
+	0x9085, 0x0001, 0x0c80, 0x0076, 0x0066, 0x0056, 0x0046, 0x0036,
+	0x0026, 0x8aff, 0x0904, 0x1b9c, 0x700c, 0x7214, 0x923a, 0x7010,
+	0x7218, 0x9203, 0x0a04, 0x1b9b, 0x9705, 0x0904, 0x1b9b, 0x903e,
+	0x2730, 0xa880, 0xd0fc, 0x1190, 0x2d00, 0x0002, 0x1b7f, 0x1ac6,
+	0x1ac6, 0x1b7f, 0x1b7f, 0x1b62, 0x1b7f, 0x1ac6, 0x1b68, 0x1b15,
+	0x1b15, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b5c, 0x1b15, 0xc0fc, 0xa882,
+	0xab2c, 0xaa30, 0xad1c, 0xac20, 0xdd9c, 0x0904, 0x1b81, 0x2c05,
+	0x908a, 0x0034, 0x1a0c, 0x0db2, 0x9082, 0x001b, 0x0002, 0x1ab2,
+	0x1ab0, 0x1ab0, 0x1ab0, 0x1ab0, 0x1ab0, 0x1ab6, 0x1ab0, 0x1ab0,
+	0x1ab0, 0x1ab0, 0x1ab0, 0x1aba, 0x1ab0, 0x1ab0, 0x1ab0, 0x1ab0,
+	0x1ab0, 0x1abe, 0x1ab0, 0x1ab0, 0x1ab0, 0x1ab0, 0x1ab0, 0x1ac2,
+	0x080c, 0x0db2, 0xa774, 0xa678, 0x0804, 0x1b81, 0xa78c, 0xa690,
+	0x0804, 0x1b81, 0xa7a4, 0xa6a8, 0x0804, 0x1b81, 0xa7bc, 0xa6c0,
+	0x0804, 0x1b81, 0xa7d4, 0xa6d8, 0x0804, 0x1b81, 0x2c05, 0x908a,
+	0x0036, 0x1a0c, 0x0db2, 0x9082, 0x001b, 0x0002, 0x1ae9, 0x1ae9,
+	0x1aeb, 0x1ae9, 0x1ae9, 0x1ae9, 0x1af1, 0x1ae9, 0x1ae9, 0x1ae9,
+	0x1af7, 0x1ae9, 0x1ae9, 0x1ae9, 0x1afd, 0x1ae9, 0x1ae9, 0x1ae9,
+	0x1b03, 0x1ae9, 0x1ae9, 0x1ae9, 0x1b09, 0x1ae9, 0x1ae9, 0x1ae9,
+	0x1b0f, 0x080c, 0x0db2, 0xa574, 0xa478, 0xa37c, 0xa280, 0x0804,
+	0x1b81, 0xa584, 0xa488, 0xa38c, 0xa290, 0x0804, 0x1b81, 0xa594,
+	0xa498, 0xa39c, 0xa2a0, 0x0804, 0x1b81, 0xa5a4, 0xa4a8, 0xa3ac,
+	0xa2b0, 0x0804, 0x1b81, 0xa5b4, 0xa4b8, 0xa3bc, 0xa2c0, 0x0804,
+	0x1b81, 0xa5c4, 0xa4c8, 0xa3cc, 0xa2d0, 0x0804, 0x1b81, 0xa5d4,
+	0xa4d8, 0xa3dc, 0xa2e0, 0x0804, 0x1b81, 0x2c05, 0x908a, 0x0034,
+	0x1a0c, 0x0db2, 0x9082, 0x001b, 0x0002, 0x1b38, 0x1b36, 0x1b36,
+	0x1b36, 0x1b36, 0x1b36, 0x1b40, 0x1b36, 0x1b36, 0x1b36, 0x1b36,
+	0x1b36, 0x1b47, 0x1b36, 0x1b36, 0x1b36, 0x1b36, 0x1b36, 0x1b4e,
+	0x1b36, 0x1b36, 0x1b36, 0x1b36, 0x1b36, 0x1b55, 0x080c, 0x0db2,
+	0xa56c, 0xa470, 0xa774, 0xa678, 0xa37c, 0xa280, 0x0804, 0x1b81,
+	0xa584, 0xa488, 0xa78c, 0xa690, 0xa394, 0xa298, 0x04d0, 0xa59c,
+	0xa4a0, 0xa7a4, 0xa6a8, 0xa3ac, 0xa2b0, 0x0498, 0xa5b4, 0xa4b8,
+	0xa7bc, 0xa6c0, 0xa3c4, 0xa2c8, 0x0460, 0xa5cc, 0xa4d0, 0xa7d4,
+	0xa6d8, 0xa3dc, 0xa2e0, 0x0428, 0xa864, 0x9084, 0x00ff, 0x9086,
+	0x001e, 0x11e8, 0x080c, 0x1d60, 0x1904, 0x1a61, 0x900e, 0x04a0,
+	0xa864, 0x9084, 0x00ff, 0x9086, 0x0048, 0x190c, 0x0db2, 0x00c6,
+	0x7004, 0x2060, 0x6004, 0x9086, 0x0043, 0x00ce, 0x0904, 0x1b15,
+	0xab9c, 0x9016, 0xad8c, 0xac90, 0xaf94, 0xae98, 0x0010, 0x080c,
+	0x0db2, 0x7b12, 0x7a16, 0x7d02, 0x7c06, 0x7f0a, 0x7e0e, 0x782b,
+	0x0001, 0x7000, 0x8000, 0x7002, 0xa83c, 0x9300, 0xa83e, 0xa840,
+	0x9201, 0xa842, 0x700c, 0x9300, 0x700e, 0x7010, 0x9201, 0x7012,
+	0x080c, 0x1d60, 0x0008, 0x9006, 0x002e, 0x003e, 0x004e, 0x005e,
+	0x006e, 0x007e, 0x0005, 0x080c, 0x0db2, 0x0026, 0x2001, 0x0105,
+	0x2003, 0x0010, 0x782b, 0x0004, 0x7003, 0x0000, 0x7004, 0x2060,
+	0x6014, 0x2048, 0x080c, 0xb5fb, 0x0118, 0xa880, 0xc0bd, 0xa882,
+	0x6020, 0x9086, 0x0006, 0x1180, 0x2061, 0x0100, 0x62c8, 0x2001,
+	0x00fa, 0x8001, 0x1df0, 0x60c8, 0x9206, 0x1dc0, 0x60c4, 0xa89a,
+	0x60c8, 0xa896, 0x7004, 0x2060, 0x00c6, 0x080c, 0xb251, 0x00ce,
+	0x2001, 0x19c5, 0x2004, 0x9c06, 0x1160, 0x2009, 0x0040, 0x080c,
+	0x20d9, 0x080c, 0x9479, 0x2011, 0x0000, 0x080c, 0x92f6, 0x080c,
+	0x865d, 0x002e, 0x0804, 0x1d12, 0x0126, 0x2091, 0x2400, 0xa858,
+	0x2040, 0x792c, 0x782b, 0x0002, 0x9184, 0x0700, 0x1904, 0x1ba5,
+	0x7000, 0x0002, 0x1d12, 0x1bf6, 0x1c63, 0x1d10, 0x8001, 0x7002,
+	0xd19c, 0x1150, 0x8aff, 0x05b0, 0x080c, 0x1a5b, 0x0904, 0x1d12,
+	0x080c, 0x1a5b, 0x0804, 0x1d12, 0x782b, 0x0004, 0xd194, 0x0148,
+	0xa880, 0xc0fc, 0xa882, 0x8aff, 0x11d8, 0xa87c, 0xc0f5, 0xa87e,
+	0x00b8, 0x0026, 0x0036, 0xab3c, 0xaa40, 0x7810, 0xa82e, 0x931a,
+	0x7814, 0xa832, 0x9213, 0x7800, 0xa81e, 0x7804, 0xa822, 0xab3e,
+	0xaa42, 0x003e, 0x002e, 0x080c, 0x1d78, 0xa880, 0xc0fd, 0xa882,
+	0x2a00, 0xa816, 0x2800, 0xa85a, 0x2c00, 0xa812, 0x7003, 0x0000,
+	0x0804, 0x1d12, 0x00f6, 0x0026, 0x781c, 0x0006, 0x7818, 0x0006,
+	0x2079, 0x0100, 0x7a14, 0x9284, 0x1984, 0x9085, 0x0012, 0x7816,
+	0x0036, 0x2019, 0x1000, 0x8319, 0x090c, 0x0db2, 0x7820, 0xd0bc,
+	0x1dd0, 0x003e, 0x79c8, 0x000e, 0x9102, 0x001e, 0x0006, 0x0016,
+	0x79c4, 0x000e, 0x9103, 0x78c6, 0x000e, 0x78ca, 0x9284, 0x1984,
+	0x9085, 0x0012, 0x7816, 0x002e, 0x00fe, 0x782b, 0x0008, 0x7003,
+	0x0000, 0x0804, 0x1d12, 0x8001, 0x7002, 0xd194, 0x0170, 0x782c,
+	0xd0fc, 0x1904, 0x1be9, 0xd19c, 0x1904, 0x1d0e, 0x8aff, 0x0904,
+	0x1d12, 0x080c, 0x1a5b, 0x0804, 0x1d12, 0x0026, 0x0036, 0xab3c,
+	0xaa40, 0x080c, 0x1d78, 0xdd9c, 0x1904, 0x1ccd, 0x2c05, 0x908a,
+	0x0036, 0x1a0c, 0x0db2, 0x9082, 0x001b, 0x0002, 0x1ca1, 0x1ca1,
+	0x1ca3, 0x1ca1, 0x1ca1, 0x1ca1, 0x1ca9, 0x1ca1, 0x1ca1, 0x1ca1,
+	0x1caf, 0x1ca1, 0x1ca1, 0x1ca1, 0x1cb5, 0x1ca1, 0x1ca1, 0x1ca1,
+	0x1cbb, 0x1ca1, 0x1ca1, 0x1ca1, 0x1cc1, 0x1ca1, 0x1ca1, 0x1ca1,
+	0x1cc7, 0x080c, 0x0db2, 0xa07c, 0x931a, 0xa080, 0x9213, 0x0804,
+	0x1c15, 0xa08c, 0x931a, 0xa090, 0x9213, 0x0804, 0x1c15, 0xa09c,
+	0x931a, 0xa0a0, 0x9213, 0x0804, 0x1c15, 0xa0ac, 0x931a, 0xa0b0,
+	0x9213, 0x0804, 0x1c15, 0xa0bc, 0x931a, 0xa0c0, 0x9213, 0x0804,
+	0x1c15, 0xa0cc, 0x931a, 0xa0d0, 0x9213, 0x0804, 0x1c15, 0xa0dc,
+	0x931a, 0xa0e0, 0x9213, 0x0804, 0x1c15, 0x2c05, 0x908a, 0x0034,
+	0x1a0c, 0x0db2, 0x9082, 0x001b, 0x0002, 0x1cf0, 0x1cee, 0x1cee,
+	0x1cee, 0x1cee, 0x1cee, 0x1cf6, 0x1cee, 0x1cee, 0x1cee, 0x1cee,
+	0x1cee, 0x1cfc, 0x1cee, 0x1cee, 0x1cee, 0x1cee, 0x1cee, 0x1d02,
+	0x1cee, 0x1cee, 0x1cee, 0x1cee, 0x1cee, 0x1d08, 0x080c, 0x0db2,
+	0xa07c, 0x931a, 0xa080, 0x9213, 0x0804, 0x1c15, 0xa094, 0x931a,
+	0xa098, 0x9213, 0x0804, 0x1c15, 0xa0ac, 0x931a, 0xa0b0, 0x9213,
+	0x0804, 0x1c15, 0xa0c4, 0x931a, 0xa0c8, 0x9213, 0x0804, 0x1c15,
+	0xa0dc, 0x931a, 0xa0e0, 0x9213, 0x0804, 0x1c15, 0x0804, 0x1c11,
+	0x080c, 0x0db2, 0x012e, 0x0005, 0x00f6, 0x00e6, 0x2071, 0x1a34,
+	0x7000, 0x9086, 0x0000, 0x0904, 0x1d5d, 0x2079, 0x0090, 0x2009,
+	0x0207, 0x210c, 0xd194, 0x01b8, 0x2009, 0x020c, 0x210c, 0x9184,
+	0x0003, 0x0188, 0x080c, 0xd364, 0x2001, 0x0133, 0x2004, 0x9005,
+	0x090c, 0x0db2, 0x0016, 0x2009, 0x0040, 0x080c, 0x20d9, 0x001e,
+	0x2001, 0x020c, 0x2102, 0x2009, 0x0206, 0x2104, 0x2009, 0x0203,
+	0x210c, 0x9106, 0x1120, 0x2009, 0x0040, 0x080c, 0x20d9, 0x782c,
+	0xd0fc, 0x09a8, 0x080c, 0x1be4, 0x7000, 0x9086, 0x0000, 0x1978,
+	0x782b, 0x0004, 0x782c, 0xd0ac, 0x1de8, 0x2009, 0x0040, 0x080c,
+	0x20d9, 0x782b, 0x0002, 0x7003, 0x0000, 0x00ee, 0x00fe, 0x0005,
+	0x8c60, 0x2c05, 0x9005, 0x0110, 0x8a51, 0x0005, 0xa004, 0x9005,
+	0x0168, 0xa85a, 0x2040, 0xa064, 0x9084, 0x000f, 0x9080, 0x1da2,
+	0x2065, 0x8cff, 0x090c, 0x0db2, 0x8a51, 0x0005, 0x2050, 0x0005,
+	0x8a50, 0x8c61, 0x2c05, 0x9005, 0x1190, 0x2800, 0x9906, 0x0120,
+	0xa000, 0x9005, 0x1108, 0x2900, 0x2040, 0xa85a, 0xa064, 0x9084,
+	0x000f, 0x9080, 0x1db2, 0x2065, 0x8cff, 0x090c, 0x0db2, 0x0005,
+	0x0000, 0x001d, 0x0021, 0x0025, 0x0029, 0x002d, 0x0031, 0x0035,
+	0x0000, 0x001b, 0x0021, 0x0027, 0x002d, 0x0033, 0x0000, 0x0000,
+	0x0023, 0x0000, 0x0000, 0x1d95, 0x1d91, 0x0000, 0x0000, 0x1d9f,
+	0x0000, 0x1d95, 0x1d9c, 0x1d9c, 0x1d99, 0x0000, 0x0000, 0x0000,
+	0x1d9f, 0x1d9c, 0x0000, 0x1d97, 0x1d97, 0x0000, 0x0000, 0x1d9f,
+	0x0000, 0x1d97, 0x1d9d, 0x1d9d, 0x1d9d, 0x0000, 0x0000, 0x0000,
+	0x1d9f, 0x1d9d, 0x00c6, 0x00d6, 0x0086, 0xab42, 0xac3e, 0xa888,
+	0x9055, 0x0904, 0x1f99, 0x2940, 0xa064, 0x90ec, 0x000f, 0x9de0,
+	0x1da2, 0x9d86, 0x0007, 0x0130, 0x9d86, 0x000e, 0x0118, 0x9d86,
+	0x000f, 0x1120, 0xa08c, 0x9422, 0xa090, 0x931b, 0x2c05, 0x9065,
+	0x1140, 0x0310, 0x0804, 0x1f99, 0xa004, 0x9045, 0x0904, 0x1f99,
+	0x0c18, 0x2c05, 0x9005, 0x0904, 0x1e81, 0xdd9c, 0x1904, 0x1e3d,
+	0x908a, 0x0036, 0x1a0c, 0x0db2, 0x9082, 0x001b, 0x0002, 0x1e12,
+	0x1e12, 0x1e14, 0x1e12, 0x1e12, 0x1e12, 0x1e1a, 0x1e12, 0x1e12,
+	0x1e12, 0x1e20, 0x1e12, 0x1e12, 0x1e12, 0x1e26, 0x1e12, 0x1e12,
+	0x1e12, 0x1e2c, 0x1e12, 0x1e12, 0x1e12, 0x1e32, 0x1e12, 0x1e12,
+	0x1e12, 0x1e38, 0x080c, 0x0db2, 0xa07c, 0x9422, 0xa080, 0x931b,
+	0x0804, 0x1e77, 0xa08c, 0x9422, 0xa090, 0x931b, 0x0804, 0x1e77,
+	0xa09c, 0x9422, 0xa0a0, 0x931b, 0x0804, 0x1e77, 0xa0ac, 0x9422,
+	0xa0b0, 0x931b, 0x0804, 0x1e77, 0xa0bc, 0x9422, 0xa0c0, 0x931b,
+	0x0804, 0x1e77, 0xa0cc, 0x9422, 0xa0d0, 0x931b, 0x0804, 0x1e77,
+	0xa0dc, 0x9422, 0xa0e0, 0x931b, 0x04d0, 0x908a, 0x0034, 0x1a0c,
+	0x0db2, 0x9082, 0x001b, 0x0002, 0x1e5f, 0x1e5d, 0x1e5d, 0x1e5d,
+	0x1e5d, 0x1e5d, 0x1e64, 0x1e5d, 0x1e5d, 0x1e5d, 0x1e5d, 0x1e5d,
+	0x1e69, 0x1e5d, 0x1e5d, 0x1e5d, 0x1e5d, 0x1e5d, 0x1e6e, 0x1e5d,
+	0x1e5d, 0x1e5d, 0x1e5d, 0x1e5d, 0x1e73, 0x080c, 0x0db2, 0xa07c,
+	0x9422, 0xa080, 0x931b, 0x0098, 0xa094, 0x9422, 0xa098, 0x931b,
+	0x0070, 0xa0ac, 0x9422, 0xa0b0, 0x931b, 0x0048, 0xa0c4, 0x9422,
+	0xa0c8, 0x931b, 0x0020, 0xa0dc, 0x9422, 0xa0e0, 0x931b, 0x0630,
+	0x2300, 0x9405, 0x0160, 0x8a51, 0x0904, 0x1f99, 0x8c60, 0x0804,
+	0x1de9, 0xa004, 0x9045, 0x0904, 0x1f99, 0x0804, 0x1dcc, 0x8a51,
+	0x0904, 0x1f99, 0x8c60, 0x2c05, 0x9005, 0x1158, 0xa004, 0x9045,
+	0x0904, 0x1f99, 0xa064, 0x90ec, 0x000f, 0x9de0, 0x1da2, 0x2c05,
+	0x2060, 0xa880, 0xc0fc, 0xa882, 0x0804, 0x1f8e, 0x2c05, 0x8422,
+	0x8420, 0x831a, 0x9399, 0x0000, 0xac2e, 0xab32, 0xdd9c, 0x1904,
+	0x1f2b, 0x9082, 0x001b, 0x0002, 0x1ec7, 0x1ec7, 0x1ec9, 0x1ec7,
+	0x1ec7, 0x1ec7, 0x1ed7, 0x1ec7, 0x1ec7, 0x1ec7, 0x1ee5, 0x1ec7,
+	0x1ec7, 0x1ec7, 0x1ef3, 0x1ec7, 0x1ec7, 0x1ec7, 0x1f01, 0x1ec7,
+	0x1ec7, 0x1ec7, 0x1f0f, 0x1ec7, 0x1ec7, 0x1ec7, 0x1f1d, 0x080c,
+	0x0db2, 0xa17c, 0x2400, 0x9122, 0xa180, 0x2300, 0x911b, 0x0a0c,
+	0x0db2, 0xa074, 0x9420, 0xa078, 0x9319, 0x0804, 0x1f89, 0xa18c,
+	0x2400, 0x9122, 0xa190, 0x2300, 0x911b, 0x0a0c, 0x0db2, 0xa084,
+	0x9420, 0xa088, 0x9319, 0x0804, 0x1f89, 0xa19c, 0x2400, 0x9122,
+	0xa1a0, 0x2300, 0x911b, 0x0a0c, 0x0db2, 0xa094, 0x9420, 0xa098,
+	0x9319, 0x0804, 0x1f89, 0xa1ac, 0x2400, 0x9122, 0xa1b0, 0x2300,
+	0x911b, 0x0a0c, 0x0db2, 0xa0a4, 0x9420, 0xa0a8, 0x9319, 0x0804,
+	0x1f89, 0xa1bc, 0x2400, 0x9122, 0xa1c0, 0x2300, 0x911b, 0x0a0c,
+	0x0db2, 0xa0b4, 0x9420, 0xa0b8, 0x9319, 0x0804, 0x1f89, 0xa1cc,
+	0x2400, 0x9122, 0xa1d0, 0x2300, 0x911b, 0x0a0c, 0x0db2, 0xa0c4,
+	0x9420, 0xa0c8, 0x9319, 0x0804, 0x1f89, 0xa1dc, 0x2400, 0x9122,
+	0xa1e0, 0x2300, 0x911b, 0x0a0c, 0x0db2, 0xa0d4, 0x9420, 0xa0d8,
+	0x9319, 0x0804, 0x1f89, 0x9082, 0x001b, 0x0002, 0x1f49, 0x1f47,
+	0x1f47, 0x1f47, 0x1f47, 0x1f47, 0x1f56, 0x1f47, 0x1f47, 0x1f47,
+	0x1f47, 0x1f47, 0x1f63, 0x1f47, 0x1f47, 0x1f47, 0x1f47, 0x1f47,
+	0x1f70, 0x1f47, 0x1f47, 0x1f47, 0x1f47, 0x1f47, 0x1f7d, 0x080c,
+	0x0db2, 0xa17c, 0x2400, 0x9122, 0xa180, 0x2300, 0x911b, 0x0a0c,
+	0x0db2, 0xa06c, 0x9420, 0xa070, 0x9319, 0x0498, 0xa194, 0x2400,
+	0x9122, 0xa198, 0x2300, 0x911b, 0x0a0c, 0x0db2, 0xa084, 0x9420,
+	0xa088, 0x9319, 0x0430, 0xa1ac, 0x2400, 0x9122, 0xa1b0, 0x2300,
+	0x911b, 0x0a0c, 0x0db2, 0xa09c, 0x9420, 0xa0a0, 0x9319, 0x00c8,
+	0xa1c4, 0x2400, 0x9122, 0xa1c8, 0x2300, 0x911b, 0x0a0c, 0x0db2,
+	0xa0b4, 0x9420, 0xa0b8, 0x9319, 0x0060, 0xa1dc, 0x2400, 0x9122,
+	0xa1e0, 0x2300, 0x911b, 0x0a0c, 0x0db2, 0xa0cc, 0x9420, 0xa0d0,
+	0x9319, 0xac1e, 0xab22, 0xa880, 0xc0fd, 0xa882, 0x2800, 0xa85a,
+	0x2c00, 0xa812, 0x2a00, 0xa816, 0x000e, 0x000e, 0x000e, 0x9006,
+	0x0028, 0x008e, 0x00de, 0x00ce, 0x9085, 0x0001, 0x0005, 0x2001,
+	0x0005, 0x2004, 0x9084, 0x0007, 0x0002, 0x1fb7, 0x1be4, 0x1fb7,
+	0x1fad, 0x1fb0, 0x1fb3, 0x1fb0, 0x1fb3, 0x080c, 0x1be4, 0x0005,
+	0x080c, 0x116f, 0x0005, 0x080c, 0x1be4, 0x080c, 0x116f, 0x0005,
+	0x0126, 0x2091, 0x2600, 0x2079, 0x0200, 0x2071, 0x0260, 0x2069,
+	0x1800, 0x7817, 0x0000, 0x789b, 0x0814, 0x78a3, 0x0406, 0x789f,
+	0x0410, 0x2009, 0x013b, 0x200b, 0x0400, 0x781b, 0x0002, 0x783b,
+	0x001f, 0x7837, 0x0020, 0x7803, 0x1600, 0x012e, 0x0005, 0x2091,
+	0x2600, 0x781c, 0xd0a4, 0x190c, 0x20d6, 0x7900, 0xd1dc, 0x1118,
+	0x9084, 0x0006, 0x001a, 0x9084, 0x000e, 0x0002, 0x1ffe, 0x1ff6,
+	0x7597, 0x1ff6, 0x1ff8, 0x1ff8, 0x1ff8, 0x1ff8, 0x757d, 0x1ff6,
+	0x1ffa, 0x1ff6, 0x1ff8, 0x1ff6, 0x1ff8, 0x1ff6, 0x080c, 0x0db2,
+	0x0031, 0x0020, 0x080c, 0x757d, 0x080c, 0x7597, 0x0005, 0x0006,
+	0x0016, 0x0026, 0x080c, 0xd364, 0x7930, 0x9184, 0x0003, 0x01c0,
+	0x2001, 0x19c5, 0x2004, 0x9005, 0x0170, 0x2001, 0x0133, 0x2004,
+	0x9005, 0x090c, 0x0db2, 0x00c6, 0x2001, 0x19c5, 0x2064, 0x080c,
+	0xb251, 0x00ce, 0x00f8, 0x2009, 0x0040, 0x080c, 0x20d9, 0x00d0,
+	0x9184, 0x0014, 0x01a0, 0x6a00, 0x9286, 0x0003, 0x0160, 0x080c,
+	0x6c53, 0x1138, 0x080c, 0x6f2a, 0x080c, 0x5a21, 0x080c, 0x6b8a,
+	0x0010, 0x080c, 0x58e0, 0x080c, 0x7635, 0x0041, 0x0018, 0x9184,
+	0x9540, 0x1dc8, 0x002e, 0x001e, 0x000e, 0x0005, 0x00e6, 0x0036,
+	0x0046, 0x0056, 0x2071, 0x1a31, 0x080c, 0x1872, 0x005e, 0x004e,
+	0x003e, 0x00ee, 0x0005, 0x0126, 0x2091, 0x2e00, 0x2071, 0x1800,
+	0x7128, 0x2001, 0x1940, 0x2102, 0x2001, 0x1948, 0x2102, 0x2001,
+	0x013b, 0x2102, 0x2079, 0x0200, 0x2001, 0x0201, 0x789e, 0x78a3,
+	0x0200, 0x9198, 0x0007, 0x831c, 0x831c, 0x831c, 0x9398, 0x0005,
+	0x2320, 0x9182, 0x0204, 0x1230, 0x2011, 0x0008, 0x8423, 0x8423,
+	0x8423, 0x0488, 0x9182, 0x024c, 0x1240, 0x2011, 0x0007, 0x8403,
+	0x8003, 0x9400, 0x9400, 0x9420, 0x0430, 0x9182, 0x02bc, 0x1238,
+	0x2011, 0x0006, 0x8403, 0x8003, 0x9400, 0x9420, 0x00e0, 0x9182,
+	0x034c, 0x1230, 0x2011, 0x0005, 0x8403, 0x8003, 0x9420, 0x0098,
+	0x9182, 0x042c, 0x1228, 0x2011, 0x0004, 0x8423, 0x8423, 0x0058,
+	0x9182, 0x059c, 0x1228, 0x2011, 0x0003, 0x8403, 0x9420, 0x0018,
+	0x2011, 0x0002, 0x8423, 0x9482, 0x0228, 0x8002, 0x8020, 0x8301,
+	0x9402, 0x0110, 0x0208, 0x8321, 0x8217, 0x8203, 0x9405, 0x789a,
+	0x012e, 0x0005, 0x0006, 0x00d6, 0x2069, 0x0200, 0x6814, 0x9084,
+	0xffc0, 0x910d, 0x6916, 0x00de, 0x000e, 0x0005, 0x00d6, 0x2069,
+	0x0200, 0x9005, 0x6810, 0x0110, 0xc0a5, 0x0008, 0xc0a4, 0x6812,
+	0x00de, 0x0005, 0x0006, 0x00d6, 0x2069, 0x0200, 0x6810, 0x9084,
+	0xfff8, 0x910d, 0x6912, 0x00de, 0x000e, 0x0005, 0x7938, 0x080c,
+	0x0db2, 0x00f6, 0x2079, 0x0200, 0x7902, 0xa001, 0xa001, 0xa001,
+	0xa001, 0xa001, 0xa001, 0x7902, 0xa001, 0xa001, 0xa001, 0xa001,
+	0xa001, 0xa001, 0x00fe, 0x0005, 0x0126, 0x2091, 0x2800, 0x2061,
+	0x0100, 0x2071, 0x1800, 0x2009, 0x0000, 0x080c, 0x28d6, 0x080c,
+	0x27f1, 0x6054, 0x8004, 0x8004, 0x8004, 0x8004, 0x9084, 0x000c,
+	0x6150, 0x918c, 0xfff3, 0x9105, 0x6052, 0x6050, 0x9084, 0xb17f,
+	0x9085, 0x2000, 0x6052, 0x2009, 0x196c, 0x2011, 0x196d, 0x6358,
+	0x939c, 0x38f0, 0x2320, 0x080c, 0x2835, 0x1238, 0x939d, 0x4003,
+	0x94a5, 0x8603, 0x230a, 0x2412, 0x0030, 0x939d, 0x0203, 0x94a5,
+	0x8603, 0x230a, 0x2412, 0x9006, 0x080c, 0x2820, 0x9006, 0x080c,
+	0x2803, 0x20a9, 0x0012, 0x1d04, 0x212b, 0x2091, 0x6000, 0x1f04,
+	0x212b, 0x602f, 0x0100, 0x602f, 0x0000, 0x6050, 0x9085, 0x0400,
+	0x9084, 0xdfff, 0x6052, 0x6024, 0x6026, 0x080c, 0x250f, 0x2009,
+	0x00ef, 0x6132, 0x6136, 0x080c, 0x251f, 0x60e7, 0x0000, 0x61ea,
+	0x60e3, 0x0008, 0x604b, 0xf7f7, 0x6043, 0x0000, 0x602f, 0x0080,
+	0x602f, 0x0000, 0x6007, 0x049f, 0x60bb, 0x0000, 0x20a9, 0x0018,
+	0x60bf, 0x0000, 0x1f04, 0x2158, 0x60bb, 0x0000, 0x60bf, 0x0108,
+	0x60bf, 0x0012, 0x60bf, 0x0320, 0x60bf, 0x0018, 0x601b, 0x00f0,
+	0x601f, 0x001e, 0x600f, 0x006b, 0x602b, 0x402f, 0x012e, 0x0005,
+	0x00f6, 0x2079, 0x0140, 0x78c3, 0x0080, 0x78c3, 0x0083, 0x78c3,
+	0x0000, 0x00fe, 0x0005, 0x2001, 0x1833, 0x2003, 0x0000, 0x2001,
+	0x1832, 0x2003, 0x0001, 0x0005, 0x0126, 0x2091, 0x2800, 0x0006,
+	0x0016, 0x0026, 0x6124, 0x9184, 0x5e2c, 0x1118, 0x9184, 0x0007,
+	0x002a, 0x9195, 0x0004, 0x9284, 0x0007, 0x0002, 0x21b8, 0x219e,
+	0x21a1, 0x21a4, 0x21a9, 0x21ab, 0x21af, 0x21b3, 0x080c, 0x7eec,
+	0x00b8, 0x080c, 0x7fb9, 0x00a0, 0x080c, 0x7fb9, 0x080c, 0x7eec,
+	0x0078, 0x0099, 0x0068, 0x080c, 0x7eec, 0x0079, 0x0048, 0x080c,
+	0x7fb9, 0x0059, 0x0028, 0x080c, 0x7fb9, 0x080c, 0x7eec, 0x0029,
+	0x002e, 0x001e, 0x000e, 0x012e, 0x0005, 0x00a6, 0x6124, 0x6028,
+	0xd09c, 0x0118, 0xd19c, 0x1904, 0x2408, 0xd1f4, 0x0110, 0x080c,
+	0x0db2, 0x080c, 0x6c53, 0x0904, 0x2214, 0x080c, 0xbcec, 0x1120,
+	0x7000, 0x9086, 0x0003, 0x0570, 0x6024, 0x9084, 0x1800, 0x0550,
+	0x080c, 0x6c76, 0x0118, 0x080c, 0x6c64, 0x1520, 0x6027, 0x0020,
+	0x6043, 0x0000, 0x080c, 0xbcec, 0x0168, 0x080c, 0x6c76, 0x1150,
+	0x2001, 0x1976, 0x2003, 0x0001, 0x6027, 0x1800, 0x080c, 0x6ad9,
+	0x0804, 0x240b, 0x709c, 0x9005, 0x1150, 0x709f, 0x0001, 0x00d6,
+	0x2069, 0x0140, 0x080c, 0x6caa, 0x00de, 0x1904, 0x240b, 0x080c,
+	0x6f34, 0x0428, 0x080c, 0x6c76, 0x1590, 0x6024, 0x9084, 0x1800,
+	0x1108, 0x0468, 0x080c, 0x6f34, 0x080c, 0x6f2a, 0x080c, 0x5a21,
+	0x080c, 0x6b8a, 0x0804, 0x2408, 0xd1ac, 0x1508, 0x6024, 0xd0dc,
+	0x1170, 0xd0e4, 0x1178, 0xd0d4, 0x1190, 0xd0cc, 0x0130, 0x7090,
+	0x9086, 0x0028, 0x1110, 0x080c, 0x6e17, 0x0804, 0x2408, 0x080c,
+	0x6f2f, 0x0048, 0x2001, 0x194e, 0x2003, 0x0002, 0x0020, 0x080c,
+	0x6d8d, 0x0804, 0x2408, 0x080c, 0x6eb2, 0x0804, 0x2408, 0xd1ac,
+	0x0904, 0x2329, 0x080c, 0x6c53, 0x11c0, 0x6027, 0x0020, 0x0006,
+	0x0026, 0x0036, 0x080c, 0x6c6d, 0x1158, 0x080c, 0x6f2a, 0x080c,
+	0x5a21, 0x080c, 0x6b8a, 0x003e, 0x002e, 0x000e, 0x00ae, 0x0005,
+	0x003e, 0x002e, 0x000e, 0x080c, 0x6c2d, 0x0016, 0x0046, 0x00c6,
+	0x644c, 0x9486, 0xf0f0, 0x1138, 0x2061, 0x0100, 0x644a, 0x6043,
+	0x0090, 0x6043, 0x0010, 0x74d2, 0x948c, 0xff00, 0x7034, 0xd084,
+	0x0178, 0x9186, 0xf800, 0x1160, 0x7040, 0xd084, 0x1148, 0xc085,
+	0x7042, 0x0036, 0x2418, 0x2011, 0x8016, 0x080c, 0x4672, 0x003e,
+	0x080c, 0xbce5, 0x1904, 0x2306, 0x9196, 0xff00, 0x05a8, 0x7058,
+	0x9084, 0x00ff, 0x810f, 0x81ff, 0x0110, 0x9116, 0x0568, 0x7130,
+	0xd184, 0x1550, 0x080c, 0x2f86, 0x0128, 0xc18d, 0x7132, 0x080c,
+	0x629c, 0x1510, 0x6240, 0x9294, 0x0010, 0x0130, 0x6248, 0x9294,
+	0xff00, 0x9296, 0xff00, 0x01c0, 0x7030, 0xd08c, 0x0904, 0x2306,
+	0x7034, 0xd08c, 0x1140, 0x2001, 0x180c, 0x200c, 0xd1ac, 0x1904,
+	0x2306, 0xc1ad, 0x2102, 0x0036, 0x73d0, 0x2011, 0x8013, 0x080c,
+	0x4672, 0x003e, 0x0804, 0x2306, 0x7034, 0xd08c, 0x1140, 0x2001,
+	0x180c, 0x200c, 0xd1ac, 0x1904, 0x2306, 0xc1ad, 0x2102, 0x0036,
+	0x73d0, 0x2011, 0x8013, 0x080c, 0x4672, 0x003e, 0x7130, 0xc185,
+	0x7132, 0x2011, 0x1854, 0x220c, 0xd1a4, 0x01f0, 0x0016, 0x2009,
+	0x0001, 0x2011, 0x0100, 0x080c, 0x7e3e, 0x2019, 0x000e, 0x00c6,
+	0x2061, 0x0000, 0x080c, 0xcf62, 0x00ce, 0x9484, 0x00ff, 0x9080,
+	0x2f92, 0x200d, 0x918c, 0xff00, 0x810f, 0x2120, 0x9006, 0x2009,
+	0x000e, 0x080c, 0xcfe6, 0x001e, 0xd1ac, 0x1148, 0x0016, 0x2009,
+	0x0002, 0x2019, 0x0004, 0x080c, 0x2dfb, 0x001e, 0x0078, 0x0156,
+	0x00b6, 0x20a9, 0x007f, 0x900e, 0x080c, 0x5f7e, 0x1110, 0x080c,
+	0x5a3b, 0x8108, 0x1f04, 0x22fc, 0x00be, 0x015e, 0x00ce, 0x004e,
+	0x080c, 0x9947, 0x60e3, 0x0000, 0x001e, 0x2001, 0x1800, 0x2014,
+	0x9296, 0x0004, 0x1170, 0xd19c, 0x11a0, 0x2011, 0x180c, 0x2214,
+	0xd29c, 0x1120, 0x6204, 0x9295, 0x0002, 0x6206, 0x6228, 0xc29d,
+	0x622a, 0x2003, 0x0001, 0x2001, 0x1824, 0x2003, 0x0000, 0x6027,
+	0x0020, 0xd194, 0x0904, 0x2408, 0x0016, 0x6220, 0xd2b4, 0x0904,
+	0x23b1, 0x080c, 0x7cc7, 0x080c, 0x8fbb, 0x6027, 0x0004, 0x00f6,
+	0x2019, 0x19bf, 0x2304, 0x907d, 0x0904, 0x2380, 0x7804, 0x9086,
+	0x0032, 0x15f0, 0x00d6, 0x00c6, 0x00e6, 0x0096, 0x2069, 0x0140,
+	0x782c, 0x685e, 0x7808, 0x685a, 0x6043, 0x0002, 0x2001, 0x0003,
+	0x8001, 0x1df0, 0x6043, 0x0000, 0x2001, 0x003c, 0x8001, 0x1df0,
+	0x080c, 0x2997, 0x2001, 0x001e, 0x8001, 0x0240, 0x20a9, 0x0009,
+	0x080c, 0x28b1, 0x6904, 0xd1dc, 0x1140, 0x0cb0, 0x2001, 0x0100,
+	0x080c, 0x2987, 0x9006, 0x080c, 0x2987, 0x080c, 0x847d, 0x080c,
+	0x8582, 0x7814, 0x2048, 0xa867, 0x0103, 0x2f60, 0x080c, 0x99d6,
+	0x009e, 0x00ee, 0x00ce, 0x00de, 0x00fe, 0x001e, 0x00ae, 0x0005,
+	0x00fe, 0x00d6, 0x2069, 0x0140, 0x6804, 0x9084, 0x4000, 0x0110,
+	0x080c, 0x2997, 0x00de, 0x00c6, 0x2061, 0x19b6, 0x6028, 0x080c,
+	0xbcec, 0x0120, 0x909a, 0x0003, 0x1258, 0x0018, 0x909a, 0x00c8,
+	0x1238, 0x8000, 0x602a, 0x00ce, 0x080c, 0x8f97, 0x0804, 0x2407,
+	0x2061, 0x0100, 0x62c0, 0x080c, 0x97d2, 0x2019, 0x19bf, 0x2304,
+	0x9065, 0x0120, 0x2009, 0x0027, 0x080c, 0x9a50, 0x00ce, 0x0804,
+	0x2407, 0xd2bc, 0x0904, 0x23f4, 0x080c, 0x7cd4, 0x6014, 0x9084,
+	0x1984, 0x9085, 0x0010, 0x6016, 0x6027, 0x0004, 0x00d6, 0x2069,
+	0x0140, 0x6804, 0x9084, 0x4000, 0x0110, 0x080c, 0x2997, 0x00de,
+	0x00c6, 0x2061, 0x19b6, 0x6044, 0x080c, 0xbcec, 0x0120, 0x909a,
+	0x0003, 0x1628, 0x0018, 0x909a, 0x00c8, 0x1608, 0x8000, 0x6046,
+	0x603c, 0x00ce, 0x9005, 0x0558, 0x2009, 0x07d0, 0x080c, 0x7ccc,
+	0x9080, 0x0008, 0x2004, 0x9086, 0x0006, 0x1138, 0x6114, 0x918c,
+	0x1984, 0x918d, 0x0012, 0x6116, 0x00d0, 0x6114, 0x918c, 0x1984,
+	0x918d, 0x0016, 0x6116, 0x0098, 0x6027, 0x0004, 0x0080, 0x0036,
+	0x2019, 0x0001, 0x080c, 0x9254, 0x003e, 0x2019, 0x19c5, 0x2304,
+	0x9065, 0x0120, 0x2009, 0x004f, 0x080c, 0x9a50, 0x00ce, 0x001e,
+	0xd19c, 0x0904, 0x247a, 0x7034, 0xd0ac, 0x1904, 0x244f, 0x0016,
+	0x0156, 0x6027, 0x0008, 0x6050, 0x9085, 0x0040, 0x6052, 0x6050,
+	0x9084, 0xfbcf, 0x6052, 0x080c, 0x28d0, 0x9085, 0x2000, 0x6052,
+	0x20a9, 0x0012, 0x1d04, 0x2422, 0x080c, 0x7cfb, 0x1f04, 0x2422,
+	0x6050, 0x9085, 0x0400, 0x9084, 0xdfbf, 0x6052, 0x20a9, 0x0028,
+	0xa001, 0x1f04, 0x2430, 0x6150, 0x9185, 0x1400, 0x6052, 0x20a9,
+	0x0366, 0x1d04, 0x2439, 0x080c, 0x7cfb, 0x6020, 0xd09c, 0x1130,
+	0x015e, 0x6152, 0x001e, 0x6027, 0x0008, 0x04a0, 0x080c, 0x2898,
+	0x1f04, 0x2439, 0x015e, 0x6152, 0x001e, 0x6027, 0x0008, 0x0016,
+	0x6028, 0xc09c, 0x602a, 0x080c, 0x9947, 0x60e3, 0x0000, 0x080c,
+	0xd343, 0x080c, 0xd35e, 0x080c, 0x5117, 0xd0fc, 0x1138, 0x080c,
+	0xbce5, 0x1120, 0x9085, 0x0001, 0x080c, 0x6c9a, 0x9006, 0x080c,
+	0x2987, 0x2009, 0x0002, 0x080c, 0x28d6, 0x00e6, 0x2071, 0x1800,
+	0x7003, 0x0004, 0x080c, 0x0e69, 0x00ee, 0x6027, 0x0008, 0x080c,
+	0x0b94, 0x001e, 0x918c, 0xffd0, 0x6126, 0x00ae, 0x0005, 0x0006,
+	0x0016, 0x0026, 0x0036, 0x00e6, 0x00f6, 0x0126, 0x2091, 0x8000,
+	0x2071, 0x1800, 0x71c8, 0x70ca, 0x9116, 0x0904, 0x24ce, 0x81ff,
+	0x01a0, 0x2009, 0x0000, 0x080c, 0x28d6, 0x2011, 0x8011, 0x2019,
+	0x010e, 0x231c, 0x939e, 0x0007, 0x1118, 0x2019, 0x0001, 0x0010,
+	0x2019, 0x0000, 0x080c, 0x4672, 0x0448, 0x2001, 0x1977, 0x200c,
+	0x81ff, 0x1140, 0x2001, 0x0109, 0x2004, 0xd0b4, 0x0118, 0x2019,
+	0x0003, 0x0008, 0x2118, 0x2011, 0x8012, 0x080c, 0x4672, 0x080c,
+	0x0e69, 0x080c, 0x5117, 0xd0fc, 0x1188, 0x080c, 0xbce5, 0x1170,
+	0x00c6, 0x080c, 0x256a, 0x080c, 0x91bb, 0x2061, 0x0100, 0x2019,
+	0x0028, 0x2009, 0x0002, 0x080c, 0x2dfb, 0x00ce, 0x012e, 0x00fe,
+	0x00ee, 0x003e, 0x002e, 0x001e, 0x000e, 0x0005, 0x2028, 0x918c,
+	0x00ff, 0x2130, 0x9094, 0xff00, 0x11f0, 0x2011, 0x1835, 0x2214,
+	0xd2ac, 0x11c8, 0x81ff, 0x01e8, 0x2011, 0x181d, 0x2204, 0x9106,
+	0x1190, 0x2011, 0x181e, 0x2214, 0x9294, 0xff00, 0x9584, 0xff00,
+	0x9206, 0x1148, 0x2011, 0x181e, 0x2214, 0x9294, 0x00ff, 0x9584,
+	0x00ff, 0x9206, 0x1120, 0x2500, 0x080c, 0x7876, 0x0048, 0x9584,
+	0x00ff, 0x9080, 0x2f92, 0x200d, 0x918c, 0xff00, 0x810f, 0x9006,
+	0x0005, 0x9080, 0x2f92, 0x200d, 0x918c, 0x00ff, 0x0005, 0x00d6,
+	0x2069, 0x0140, 0x2001, 0x1816, 0x2003, 0x00ef, 0x20a9, 0x0010,
+	0x9006, 0x6852, 0x6856, 0x1f04, 0x251a, 0x00de, 0x0005, 0x0006,
+	0x00d6, 0x0026, 0x2069, 0x0140, 0x2001, 0x1816, 0x2102, 0x8114,
+	0x8214, 0x8214, 0x8214, 0x20a9, 0x0010, 0x6853, 0x0000, 0x9006,
+	0x82ff, 0x1128, 0x9184, 0x000f, 0x9080, 0xd74a, 0x2005, 0x6856,
+	0x8211, 0x1f04, 0x252f, 0x002e, 0x00de, 0x000e, 0x0005, 0x00c6,
+	0x2061, 0x1800, 0x6030, 0x0110, 0xc09d, 0x0008, 0xc09c, 0x6032,
+	0x00ce, 0x0005, 0x0156, 0x00d6, 0x0026, 0x0016, 0x0006, 0x2069,
+	0x0140, 0x6980, 0x9116, 0x0180, 0x9112, 0x1230, 0x8212, 0x8210,
+	0x22a8, 0x2001, 0x0402, 0x0018, 0x22a8, 0x2001, 0x0404, 0x680e,
+	0x1f04, 0x255f, 0x680f, 0x0000, 0x000e, 0x001e, 0x002e, 0x00de,
+	0x015e, 0x0005, 0x080c, 0x5113, 0xd0c4, 0x0150, 0xd0a4, 0x0140,
+	0x9006, 0x0046, 0x2020, 0x2009, 0x002e, 0x080c, 0xcfe6, 0x004e,
+	0x0005, 0x00f6, 0x0016, 0x0026, 0x2079, 0x0140, 0x78c4, 0xd0dc,
+	0x0904, 0x25d6, 0x080c, 0x2835, 0x0660, 0x9084, 0x0700, 0x908e,
+	0x0600, 0x1120, 0x2011, 0x4000, 0x900e, 0x0458, 0x908e, 0x0500,
+	0x1120, 0x2011, 0x8000, 0x900e, 0x0420, 0x908e, 0x0400, 0x1120,
+	0x9016, 0x2009, 0x0001, 0x00e8, 0x908e, 0x0300, 0x1120, 0x9016,
+	0x2009, 0x0002, 0x00b0, 0x908e, 0x0200, 0x1120, 0x9016, 0x2009,
+	0x0004, 0x0078, 0x908e, 0x0100, 0x1548, 0x9016, 0x2009, 0x0008,
+	0x0040, 0x9084, 0x0700, 0x908e, 0x0300, 0x1500, 0x2011, 0x0030,
+	0x0058, 0x2300, 0x9080, 0x0020, 0x2018, 0x080c, 0x7e7f, 0x928c,
+	0xff00, 0x0110, 0x2011, 0x00ff, 0x2200, 0x8007, 0x9085, 0x004c,
+	0x78c2, 0x2009, 0x0138, 0x220a, 0x080c, 0x6c53, 0x1118, 0x2009,
+	0x193e, 0x220a, 0x002e, 0x001e, 0x00fe, 0x0005, 0x78c3, 0x0000,
+	0x0cc8, 0x0126, 0x2091, 0x2800, 0x0006, 0x0016, 0x0026, 0x2001,
+	0x0170, 0x200c, 0x8000, 0x2014, 0x9184, 0x0003, 0x0110, 0x080c,
+	0x0db2, 0x002e, 0x001e, 0x000e, 0x012e, 0x0005, 0x2001, 0x0171,
+	0x2004, 0xd0dc, 0x0168, 0x2001, 0x0170, 0x200c, 0x918c, 0x00ff,
+	0x918e, 0x004c, 0x1128, 0x200c, 0x918c, 0xff00, 0x810f, 0x0005,
+	0x900e, 0x2001, 0x0227, 0x2004, 0x8007, 0x9084, 0x00ff, 0x8004,
+	0x9108, 0x2001, 0x0226, 0x2004, 0x8007, 0x9084, 0x00ff, 0x8004,
+	0x9108, 0x0005, 0x0018, 0x000c, 0x0018, 0x0020, 0x1000, 0x0800,
+	0x1000, 0x1800, 0x0156, 0x0006, 0x0016, 0x0026, 0x00e6, 0x2001,
+	0x195f, 0x2004, 0x908a, 0x0007, 0x1a0c, 0x0db2, 0x0033, 0x00ee,
+	0x002e, 0x001e, 0x000e, 0x015e, 0x0005, 0x2634, 0x2652, 0x2676,
+	0x2678, 0x26a1, 0x26a3, 0x26a5, 0x2001, 0x0001, 0x080c, 0x247f,
+	0x080c, 0x2893, 0x2001, 0x1961, 0x2003, 0x0000, 0x7828, 0x9084,
+	0xe1d7, 0x782a, 0x9006, 0x20a9, 0x0009, 0x080c, 0x2851, 0x2001,
+	0x195f, 0x2003, 0x0006, 0x2009, 0x001e, 0x2011, 0x26a6, 0x080c,
+	0x7cd9, 0x0005, 0x2009, 0x1964, 0x200b, 0x0000, 0x2001, 0x1969,
+	0x2003, 0x0036, 0x2001, 0x1968, 0x2003, 0x002a, 0x2001, 0x1961,
+	0x2003, 0x0001, 0x9006, 0x080c, 0x2803, 0x2001, 0xffff, 0x20a9,
+	0x0009, 0x080c, 0x2851, 0x2001, 0x195f, 0x2003, 0x0006, 0x2009,
+	0x001e, 0x2011, 0x26a6, 0x080c, 0x7cd9, 0x0005, 0x080c, 0x0db2,
+	0x2001, 0x1969, 0x2003, 0x0036, 0x2001, 0x1961, 0x2003, 0x0003,
+	0x7a38, 0x9294, 0x0005, 0x9296, 0x0004, 0x0110, 0x9006, 0x0010,
+	0x2001, 0x0001, 0x080c, 0x2803, 0x2001, 0x1965, 0x2003, 0x0000,
+	0x2001, 0xffff, 0x20a9, 0x0009, 0x080c, 0x2851, 0x2001, 0x195f,
+	0x2003, 0x0006, 0x2009, 0x001e, 0x2011, 0x26a6, 0x080c, 0x7cd9,
+	0x0005, 0x080c, 0x0db2, 0x080c, 0x0db2, 0x0005, 0x0006, 0x0016,
+	0x0026, 0x00e6, 0x00f6, 0x0156, 0x0126, 0x2091, 0x8000, 0x2079,
+	0x0100, 0x2001, 0x1961, 0x2004, 0x908a, 0x0007, 0x1a0c, 0x0db2,
+	0x0043, 0x012e, 0x015e, 0x00fe, 0x00ee, 0x002e, 0x001e, 0x000e,
+	0x0005, 0x26c8, 0x26e8, 0x2728, 0x2758, 0x277c, 0x278c, 0x278e,
+	0x080c, 0x2845, 0x11b0, 0x7850, 0x9084, 0xefff, 0x7852, 0x2009,
+	0x1967, 0x2104, 0x7a38, 0x9294, 0x0005, 0x9296, 0x0004, 0x0110,
+	0xc08d, 0x0008, 0xc085, 0x200a, 0x2001, 0x195f, 0x2003, 0x0001,
+	0x0030, 0x080c, 0x27b2, 0x2001, 0xffff, 0x080c, 0x2643, 0x0005,
+	0x080c, 0x2790, 0x05e0, 0x2009, 0x1968, 0x2104, 0x8001, 0x200a,
+	0x080c, 0x2845, 0x1178, 0x7850, 0x9084, 0xefff, 0x7852, 0x7a38,
+	0x9294, 0x0005, 0x9296, 0x0005, 0x0518, 0x2009, 0x1967, 0x2104,
+	0xc085, 0x200a, 0x2009, 0x1964, 0x2104, 0x8000, 0x200a, 0x9086,
+	0x0005, 0x0118, 0x080c, 0x2798, 0x00c0, 0x200b, 0x0000, 0x7a38,
+	0x9294, 0x0006, 0x9296, 0x0004, 0x0110, 0x9006, 0x0010, 0x2001,
+	0x0001, 0x080c, 0x2820, 0x2001, 0x1961, 0x2003, 0x0002, 0x0028,
+	0x2001, 0x195f, 0x2003, 0x0003, 0x0010, 0x080c, 0x2665, 0x0005,
+	0x080c, 0x2790, 0x0560, 0x2009, 0x1968, 0x2104, 0x8001, 0x200a,
+	0x080c, 0x2845, 0x1168, 0x7850, 0x9084, 0xefff, 0x7852, 0x2001,
+	0x195f, 0x2003, 0x0003, 0x2001, 0x1960, 0x2003, 0x0000, 0x00b8,
+	0x2009, 0x1968, 0x2104, 0x9005, 0x1118, 0x080c, 0x27d5, 0x0010,
+	0x080c, 0x27a5, 0x080c, 0x2798, 0x2009, 0x1964, 0x200b, 0x0000,
+	0x2001, 0x1961, 0x2003, 0x0001, 0x080c, 0x2665, 0x0000, 0x0005,
+	0x04b9, 0x0508, 0x080c, 0x2845, 0x11b8, 0x7850, 0x9084, 0xefff,
+	0x7852, 0x2009, 0x1965, 0x2104, 0x8000, 0x200a, 0x9086, 0x0007,
+	0x0108, 0x0078, 0x2001, 0x196a, 0x2003, 0x000a, 0x2009, 0x1967,
+	0x2104, 0xc0fd, 0x200a, 0x0038, 0x0419, 0x2001, 0x1961, 0x2003,
+	0x0004, 0x080c, 0x2690, 0x0005, 0x0099, 0x0168, 0x080c, 0x2845,
+	0x1138, 0x7850, 0x9084, 0xefff, 0x7852, 0x080c, 0x267c, 0x0018,
+	0x0079, 0x080c, 0x2690, 0x0005, 0x080c, 0x0db2, 0x080c, 0x0db2,
+	0x2009, 0x1969, 0x2104, 0x8001, 0x200a, 0x090c, 0x27f1, 0x0005,
+	0x7a38, 0x9294, 0x0005, 0x9296, 0x0005, 0x0110, 0x9006, 0x0010,
+	0x2001, 0x0001, 0x080c, 0x2820, 0x0005, 0x7a38, 0x9294, 0x0006,
+	0x9296, 0x0006, 0x0110, 0x9006, 0x0010, 0x2001, 0x0001, 0x080c,
+	0x2803, 0x0005, 0x2009, 0x1964, 0x2104, 0x8000, 0x200a, 0x9086,
+	0x0005, 0x0108, 0x0068, 0x200b, 0x0000, 0x7a38, 0x9294, 0x0006,
+	0x9296, 0x0006, 0x0110, 0x9006, 0x0010, 0x2001, 0x0001, 0x04d9,
+	0x7a38, 0x9294, 0x0005, 0x9296, 0x0005, 0x0110, 0x9006, 0x0010,
+	0x2001, 0x0001, 0x080c, 0x2820, 0x0005, 0x0086, 0x2001, 0x1967,
+	0x2004, 0x9084, 0x7fff, 0x090c, 0x0db2, 0x2009, 0x1966, 0x2144,
+	0x8846, 0x280a, 0x9844, 0x0dd8, 0xd08c, 0x1120, 0xd084, 0x1120,
+	0x080c, 0x0db2, 0x9006, 0x0010, 0x2001, 0x0001, 0x00a1, 0x008e,
+	0x0005, 0x0006, 0x0156, 0x2001, 0x195f, 0x20a9, 0x0009, 0x2003,
+	0x0000, 0x8000, 0x1f04, 0x27f7, 0x2001, 0x1966, 0x2003, 0x8000,
+	0x015e, 0x000e, 0x0005, 0x00f6, 0x2079, 0x0100, 0x9085, 0x0000,
+	0x0158, 0x7838, 0x9084, 0xfff9, 0x9085, 0x0004, 0x783a, 0x2009,
+	0x196c, 0x210c, 0x795a, 0x0050, 0x7838, 0x9084, 0xfffb, 0x9085,
+	0x0006, 0x783a, 0x2009, 0x196d, 0x210c, 0x795a, 0x00fe, 0x0005,
+	0x00f6, 0x2079, 0x0100, 0x9085, 0x0000, 0x0138, 0x7838, 0x9084,
+	0xfffa, 0x9085, 0x0004, 0x783a, 0x0030, 0x7838, 0x9084, 0xfffb,
+	0x9085, 0x0005, 0x783a, 0x00fe, 0x0005, 0x0006, 0x2001, 0x0100,
+	0x2004, 0x9082, 0x0007, 0x000e, 0x0005, 0x0006, 0x2001, 0x0100,
+	0x2004, 0x9082, 0x0009, 0x000e, 0x0005, 0x0156, 0x20a9, 0x0064,
+	0x7820, 0x080c, 0x28d0, 0xd09c, 0x1110, 0x1f04, 0x2848, 0x015e,
+	0x0005, 0x0126, 0x0016, 0x0006, 0x2091, 0x8000, 0x7850, 0x9085,
+	0x0040, 0x7852, 0x7850, 0x9084, 0xfbcf, 0x7852, 0x080c, 0x28d0,
+	0x9085, 0x2000, 0x7852, 0x000e, 0x2008, 0x9186, 0x0000, 0x1118,
+	0x783b, 0x0007, 0x0090, 0x9186, 0x0001, 0x1118, 0x783b, 0x0006,
+	0x0060, 0x9186, 0x0002, 0x1118, 0x783b, 0x0005, 0x0030, 0x9186,
+	0x0003, 0x1118, 0x783b, 0x0004, 0x0000, 0x0006, 0x1d04, 0x287e,
+	0x080c, 0x7cfb, 0x1f04, 0x287e, 0x7850, 0x9085, 0x0400, 0x9084,
+	0xdfbf, 0x7852, 0x080c, 0x28d0, 0x9085, 0x1000, 0x7852, 0x000e,
+	0x001e, 0x012e, 0x0005, 0x7850, 0x9084, 0xffcf, 0x7852, 0x0005,
+	0x0006, 0x0156, 0x00f6, 0x2079, 0x0100, 0x20a9, 0x000a, 0x7854,
+	0xd0ac, 0x1130, 0x7820, 0xd0e4, 0x1140, 0x1f04, 0x28a2, 0x0028,
+	0x7854, 0xd08c, 0x1110, 0x1f04, 0x28a8, 0x00fe, 0x015e, 0x000e,
+	0x0005, 0x1d04, 0x28b1, 0x080c, 0x7cfb, 0x1f04, 0x28b1, 0x0005,
+	0x0006, 0x2001, 0x196b, 0x2004, 0x9086, 0x0000, 0x000e, 0x0005,
+	0x0006, 0x2001, 0x196b, 0x2004, 0x9086, 0x0001, 0x000e, 0x0005,
+	0x0006, 0x2001, 0x196b, 0x2004, 0x9086, 0x0002, 0x000e, 0x0005,
+	0xa001, 0xa001, 0xa001, 0xa001, 0xa001, 0x0005, 0x0006, 0x2001,
+	0x1977, 0x2102, 0x000e, 0x0005, 0x2009, 0x0171, 0x2104, 0xd0dc,
+	0x0140, 0x2009, 0x0170, 0x2104, 0x200b, 0x0080, 0xa001, 0xa001,
+	0x200a, 0x0005, 0x0036, 0x0046, 0x2001, 0x0141, 0x200c, 0x918c,
+	0xff00, 0x9186, 0x2000, 0x0118, 0x9186, 0x0100, 0x1588, 0x2009,
+	0x017f, 0x200b, 0x00a2, 0x2019, 0x0160, 0x2324, 0x2011, 0x0003,
+	0x2009, 0x0169, 0x2104, 0x9084, 0x0007, 0x210c, 0x918c, 0x0007,
+	0x910e, 0x1db0, 0x9086, 0x0003, 0x11b8, 0x2304, 0x9402, 0x02a0,
+	0x1d60, 0x8211, 0x1d68, 0x84ff, 0x0170, 0x2001, 0x0141, 0x200c,
+	0x918c, 0xff00, 0x9186, 0x0100, 0x0130, 0x2009, 0x180c, 0x2104,
+	0xc0dd, 0x200a, 0x0008, 0x0419, 0x2001, 0x017f, 0x2003, 0x0000,
+	0x004e, 0x003e, 0x0005, 0x2001, 0x180c, 0x2004, 0xd0dc, 0x01b0,
+	0x2001, 0x0160, 0x2004, 0x9005, 0x0140, 0x2001, 0x0141, 0x2004,
+	0x9084, 0xff00, 0x9086, 0x0100, 0x1148, 0x0126, 0x2091, 0x8000,
+	0x0016, 0x0026, 0x0021, 0x002e, 0x001e, 0x012e, 0x0005, 0x00c6,
+	0x2061, 0x0100, 0x6014, 0x0006, 0x2001, 0x0161, 0x2003, 0x0000,
+	0x6017, 0x0018, 0xa001, 0xa001, 0x602f, 0x0008, 0x6104, 0x918e,
+	0x0010, 0x6106, 0x918e, 0x0010, 0x6106, 0x6017, 0x0040, 0x04b9,
+	0x001e, 0x9184, 0x0003, 0x01e0, 0x0036, 0x0016, 0x2019, 0x0141,
+	0x6124, 0x918c, 0x0028, 0x1120, 0x2304, 0x9084, 0x2800, 0x0dc0,
+	0x001e, 0x919c, 0xffe4, 0x9184, 0x0001, 0x0118, 0x9385, 0x0009,
+	0x6016, 0x9184, 0x0002, 0x0118, 0x9385, 0x0012, 0x6016, 0x003e,
+	0x2001, 0x180c, 0x200c, 0xc1dc, 0x2102, 0x00ce, 0x0005, 0x0016,
+	0x0026, 0x080c, 0x6c6d, 0x0108, 0xc0bc, 0x2009, 0x0140, 0x2114,
+	0x9294, 0x0001, 0x9215, 0x220a, 0x002e, 0x001e, 0x0005, 0x0016,
+	0x0026, 0x2009, 0x0140, 0x2114, 0x9294, 0x0001, 0x9285, 0x1000,
+	0x200a, 0x220a, 0x002e, 0x001e, 0x0005, 0x0016, 0x0026, 0x2009,
+	0x0140, 0x2114, 0x9294, 0x0001, 0x9215, 0x220a, 0x002e, 0x001e,
+	0x0005, 0x0006, 0x0016, 0x2009, 0x0140, 0x2104, 0x1110, 0xc0bc,
+	0x0008, 0xc0bd, 0x200a, 0x001e, 0x000e, 0x0005, 0x2c2a, 0x2c2a,
+	0x2a4e, 0x2a4e, 0x2a5a, 0x2a5a, 0x2a66, 0x2a66, 0x2a74, 0x2a74,
+	0x2a80, 0x2a80, 0x2a8e, 0x2a8e, 0x2a9c, 0x2a9c, 0x2aae, 0x2aae,
+	0x2aba, 0x2aba, 0x2ac8, 0x2ac8, 0x2ae6, 0x2ae6, 0x2b06, 0x2b06,
+	0x2ad6, 0x2ad6, 0x2af6, 0x2af6, 0x2b14, 0x2b14, 0x2aac, 0x2aac,
+	0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac,
+	0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac,
+	0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac,
+	0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2b26, 0x2b26,
+	0x2b32, 0x2b32, 0x2b40, 0x2b40, 0x2b4e, 0x2b4e, 0x2b5e, 0x2b5e,
+	0x2b6c, 0x2b6c, 0x2b7c, 0x2b7c, 0x2b8c, 0x2b8c, 0x2b9e, 0x2b9e,
+	0x2bac, 0x2bac, 0x2bbc, 0x2bbc, 0x2bde, 0x2bde, 0x2c00, 0x2c00,
+	0x2bcc, 0x2bcc, 0x2bef, 0x2bef, 0x2c0f, 0x2c0f, 0x2aac, 0x2aac,
+	0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac,
+	0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac,
+	0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac,
+	0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac,
+	0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac,
+	0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x2aac, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2184,
+	0x0804, 0x2c22, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x1f9f, 0x0804, 0x2c22, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f9f,
+	0x080c, 0x2184, 0x0804, 0x2c22, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1fd7, 0x0804, 0x2c22,
+	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
+	0x080c, 0x2184, 0x080c, 0x1fd7, 0x0804, 0x2c22, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f9f,
+	0x080c, 0x1fd7, 0x0804, 0x2c22, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f9f, 0x080c, 0x2184,
+	0x080c, 0x1fd7, 0x0804, 0x2c22, 0xa001, 0x0cf0, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x12d6,
+	0x0804, 0x2c22, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x2184, 0x080c, 0x12d6, 0x0804, 0x2c22,
+	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
+	0x080c, 0x1f9f, 0x080c, 0x12d6, 0x0804, 0x2c22, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x2184,
+	0x080c, 0x12d6, 0x080c, 0x1fd7, 0x0804, 0x2c22, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f9f,
+	0x080c, 0x2184, 0x080c, 0x12d6, 0x0804, 0x2c22, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f9f,
+	0x080c, 0x12d6, 0x080c, 0x1fd7, 0x0804, 0x2c22, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x12d6,
+	0x080c, 0x1fd7, 0x0804, 0x2c22, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x1f9f, 0x080c, 0x2184,
+	0x080c, 0x12d6, 0x080c, 0x1fd7, 0x0804, 0x2c22, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x25d9,
+	0x0804, 0x2c22, 0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136,
+	0x0146, 0x0156, 0x080c, 0x25d9, 0x080c, 0x2184, 0x0804, 0x2c22,
+	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
+	0x080c, 0x25d9, 0x080c, 0x1f9f, 0x0804, 0x2c22, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x25d9,
+	0x080c, 0x1f9f, 0x080c, 0x2184, 0x0804, 0x2c22, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x25d9,
+	0x080c, 0x1fd7, 0x0804, 0x2c22, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x25d9, 0x080c, 0x2184,
+	0x080c, 0x1fd7, 0x0804, 0x2c22, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x25d9, 0x080c, 0x1f9f,
+	0x080c, 0x1fd7, 0x0804, 0x2c22, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x25d9, 0x080c, 0x1f9f,
+	0x080c, 0x2184, 0x080c, 0x1fd7, 0x0804, 0x2c22, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x25d9,
+	0x080c, 0x12d6, 0x0804, 0x2c22, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x25d9, 0x080c, 0x2184,
+	0x080c, 0x12d6, 0x0804, 0x2c22, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x25d9, 0x080c, 0x1f9f,
+	0x080c, 0x12d6, 0x0804, 0x2c22, 0x0106, 0x0006, 0x0126, 0x01c6,
+	0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x25d9, 0x080c, 0x2184,
+	0x080c, 0x12d6, 0x080c, 0x1fd7, 0x0804, 0x2c22, 0x0106, 0x0006,
+	0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c, 0x25d9,
+	0x080c, 0x1f9f, 0x080c, 0x2184, 0x080c, 0x12d6, 0x0498, 0x0106,
+	0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c,
+	0x25d9, 0x080c, 0x1f9f, 0x080c, 0x12d6, 0x080c, 0x1fd7, 0x0410,
+	0x0106, 0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156,
+	0x080c, 0x25d9, 0x080c, 0x12d6, 0x080c, 0x1fd7, 0x0098, 0x0106,
+	0x0006, 0x0126, 0x01c6, 0x01d6, 0x0136, 0x0146, 0x0156, 0x080c,
+	0x25d9, 0x080c, 0x1f9f, 0x080c, 0x2184, 0x080c, 0x12d6, 0x080c,
+	0x1fd7, 0x0000, 0x015e, 0x014e, 0x013e, 0x01de, 0x01ce, 0x012e,
+	0x000e, 0x010e, 0x000d, 0x00b6, 0x00c6, 0x0026, 0x0046, 0x9026,
+	0x080c, 0x6262, 0x1904, 0x2d17, 0x72d4, 0x2001, 0x194d, 0x2004,
+	0x9005, 0x1110, 0xd29c, 0x0148, 0xd284, 0x1138, 0xd2bc, 0x1904,
+	0x2d17, 0x080c, 0x2d1c, 0x0804, 0x2d17, 0xd2cc, 0x1904, 0x2d17,
+	0x080c, 0x6c53, 0x1120, 0x70a7, 0xffff, 0x0804, 0x2d17, 0xd294,
+	0x0120, 0x70a7, 0xffff, 0x0804, 0x2d17, 0x080c, 0x2f81, 0x0160,
+	0x080c, 0xbcec, 0x0128, 0x2001, 0x1816, 0x203c, 0x0804, 0x2cb5,
+	0x70a7, 0xffff, 0x0804, 0x2d17, 0x2001, 0x1816, 0x203c, 0x728c,
+	0xd284, 0x0904, 0x2cb5, 0xd28c, 0x1904, 0x2cb5, 0x0036, 0x73a4,
+	0x938e, 0xffff, 0x1110, 0x2019, 0x0001, 0x8314, 0x92e0, 0x1c80,
+	0x2c04, 0x938c, 0x0001, 0x0120, 0x9084, 0xff00, 0x8007, 0x0010,
+	0x9084, 0x00ff, 0x970e, 0x0540, 0x908e, 0x0000, 0x0528, 0x908e,
+	0x00ff, 0x1150, 0x7230, 0xd284, 0x1518, 0x728c, 0xc28d, 0x728e,
+	0x70a7, 0xffff, 0x003e, 0x0408, 0x900e, 0x080c, 0x24d6, 0x080c,
+	0x5f1e, 0x11a0, 0x080c, 0x62a4, 0x1150, 0x7030, 0xd08c, 0x0118,
+	0xb800, 0xd0bc, 0x0120, 0x080c, 0x2d35, 0x0140, 0x0028, 0x080c,
+	0x2e71, 0x080c, 0x2d61, 0x0110, 0x8318, 0x0838, 0x73a6, 0x0010,
+	0x70a7, 0xffff, 0x003e, 0x0804, 0x2d17, 0x9780, 0x2f92, 0x203d,
+	0x97bc, 0xff00, 0x873f, 0x2041, 0x007e, 0x70a4, 0x9096, 0xffff,
+	0x1118, 0x900e, 0x28a8, 0x0050, 0x9812, 0x0220, 0x2008, 0x9802,
+	0x20a8, 0x0020, 0x70a7, 0xffff, 0x0804, 0x2d17, 0x2700, 0x0156,
+	0x0016, 0x9106, 0x05c8, 0xc484, 0x080c, 0x5f7e, 0x0138, 0x080c,
+	0xbcec, 0x1590, 0x080c, 0x5f1e, 0x15b8, 0x0008, 0xc485, 0x080c,
+	0x62a4, 0x1130, 0x7030, 0xd08c, 0x01f8, 0xb800, 0xd0bc, 0x11e0,
+	0x728c, 0xd28c, 0x0180, 0x080c, 0x62a4, 0x9082, 0x0006, 0x02e0,
+	0xd484, 0x1118, 0x080c, 0x5f42, 0x0028, 0x080c, 0x2efd, 0x01a0,
+	0x080c, 0x2f28, 0x0088, 0x080c, 0x2e71, 0x080c, 0xbcec, 0x1160,
+	0x080c, 0x2d61, 0x0188, 0x0040, 0x080c, 0xbcec, 0x1118, 0x080c,
+	0x2efd, 0x0110, 0x0451, 0x0140, 0x001e, 0x8108, 0x015e, 0x1f04,
+	0x2cce, 0x70a7, 0xffff, 0x0018, 0x001e, 0x015e, 0x71a6, 0x004e,
+	0x002e, 0x00ce, 0x00be, 0x0005, 0x00c6, 0x0016, 0x70a7, 0x0001,
+	0x2009, 0x007e, 0x080c, 0x5f1e, 0x1168, 0xb813, 0x00ff, 0xb817,
+	0xfffe, 0x080c, 0x2e71, 0x04a9, 0x0128, 0x70d4, 0xc0bd, 0x70d6,
+	0x080c, 0xba40, 0x001e, 0x00ce, 0x0005, 0x0016, 0x0076, 0x00d6,
+	0x00c6, 0x2001, 0x1858, 0x2004, 0x9084, 0x00ff, 0xb842, 0x080c,
+	0x9a23, 0x01d0, 0x2b00, 0x6012, 0x080c, 0xba69, 0x6023, 0x0001,
+	0x9006, 0x080c, 0x5ebb, 0x2001, 0x0000, 0x080c, 0x5ecf, 0x0126,
+	0x2091, 0x8000, 0x70a0, 0x8000, 0x70a2, 0x012e, 0x2009, 0x0004,
+	0x080c, 0x9a50, 0x9085, 0x0001, 0x00ce, 0x00de, 0x007e, 0x001e,
+	0x0005, 0x0016, 0x0076, 0x00d6, 0x00c6, 0x2001, 0x1858, 0x2004,
+	0x9084, 0x00ff, 0xb842, 0x080c, 0x9a23, 0x0548, 0x2b00, 0x6012,
+	0xb800, 0xc0c4, 0xb802, 0xb8a0, 0x9086, 0x007e, 0x0140, 0xb804,
+	0x9084, 0x00ff, 0x9086, 0x0006, 0x1110, 0x080c, 0x2e30, 0x080c,
+	0xba69, 0x6023, 0x0001, 0x9006, 0x080c, 0x5ebb, 0x2001, 0x0002,
+	0x080c, 0x5ecf, 0x0126, 0x2091, 0x8000, 0x70a0, 0x8000, 0x70a2,
+	0x012e, 0x2009, 0x0002, 0x080c, 0x9a50, 0x9085, 0x0001, 0x00ce,
+	0x00de, 0x007e, 0x001e, 0x0005, 0x00b6, 0x00c6, 0x0026, 0x2009,
+	0x0080, 0x080c, 0x5f1e, 0x1140, 0xb813, 0x00ff, 0xb817, 0xfffc,
+	0x0039, 0x0110, 0x70db, 0xffff, 0x002e, 0x00ce, 0x00be, 0x0005,
+	0x0016, 0x0076, 0x00d6, 0x00c6, 0x080c, 0x9980, 0x01d0, 0x2b00,
+	0x6012, 0x080c, 0xba69, 0x6023, 0x0001, 0x9006, 0x080c, 0x5ebb,
+	0x2001, 0x0002, 0x080c, 0x5ecf, 0x0126, 0x2091, 0x8000, 0x70dc,
+	0x8000, 0x70de, 0x012e, 0x2009, 0x0002, 0x080c, 0x9a50, 0x9085,
+	0x0001, 0x00ce, 0x00de, 0x007e, 0x001e, 0x0005, 0x00c6, 0x00d6,
+	0x0126, 0x2091, 0x8000, 0x2009, 0x007f, 0x080c, 0x5f1e, 0x11b8,
+	0xb813, 0x00ff, 0xb817, 0xfffd, 0xb8bf, 0x0004, 0x080c, 0x9980,
+	0x0170, 0x2b00, 0x6012, 0x6316, 0x6023, 0x0001, 0x620a, 0x080c,
+	0xba69, 0x2009, 0x0022, 0x080c, 0x9a50, 0x9085, 0x0001, 0x012e,
+	0x00de, 0x00ce, 0x0005, 0x00e6, 0x00c6, 0x0066, 0x0036, 0x0026,
+	0x00b6, 0x21f0, 0x080c, 0x818b, 0x080c, 0x811a, 0x080c, 0x9819,
+	0x080c, 0xa893, 0x3e08, 0x2130, 0x81ff, 0x0120, 0x20a9, 0x007e,
+	0x900e, 0x0018, 0x20a9, 0x007f, 0x900e, 0x0016, 0x080c, 0x5f7e,
+	0x1140, 0x9686, 0x0002, 0x1118, 0xb800, 0xd0bc, 0x1110, 0x080c,
+	0x5a3b, 0x001e, 0x8108, 0x1f04, 0x2e15, 0x9686, 0x0001, 0x190c,
+	0x2f55, 0x00be, 0x002e, 0x003e, 0x006e, 0x00ce, 0x00ee, 0x0005,
+	0x00e6, 0x00c6, 0x0036, 0x0026, 0x0016, 0x00b6, 0x6210, 0x2258,
+	0xbaa0, 0x0026, 0x2019, 0x0029, 0x080c, 0x8180, 0x0076, 0x2039,
+	0x0000, 0x080c, 0x8078, 0x2c08, 0x080c, 0xcd62, 0x007e, 0x001e,
+	0xba10, 0xbb14, 0x080c, 0x5a3b, 0xba12, 0xbb16, 0x00be, 0x001e,
+	0x002e, 0x003e, 0x00ce, 0x00ee, 0x0005, 0x00e6, 0x0006, 0x00b6,
+	0x6010, 0x2058, 0xb8a0, 0x00be, 0x9086, 0x0080, 0x0150, 0x2071,
+	0x1800, 0x70a0, 0x9005, 0x0110, 0x8001, 0x70a2, 0x000e, 0x00ee,
+	0x0005, 0x2071, 0x1800, 0x70dc, 0x9005, 0x0dc0, 0x8001, 0x70de,
+	0x0ca8, 0xb800, 0xc08c, 0xb802, 0x0005, 0x00f6, 0x00e6, 0x00c6,
+	0x00b6, 0x0036, 0x0026, 0x0016, 0x0156, 0x2178, 0x81ff, 0x1118,
+	0x20a9, 0x0001, 0x0088, 0x080c, 0x5113, 0xd0c4, 0x0150, 0xd0a4,
+	0x0140, 0x9006, 0x0046, 0x2020, 0x2009, 0x002d, 0x080c, 0xcfe6,
+	0x004e, 0x20a9, 0x0800, 0x9016, 0x0026, 0x928e, 0x007e, 0x0904,
+	0x2edd, 0x928e, 0x007f, 0x0904, 0x2edd, 0x928e, 0x0080, 0x05e8,
+	0x9288, 0x1000, 0x210c, 0x81ff, 0x05c0, 0x8fff, 0x1148, 0x2001,
+	0x195d, 0x0006, 0x2003, 0x0001, 0x04e9, 0x000e, 0x2003, 0x0000,
+	0x00b6, 0x00c6, 0x2158, 0x2001, 0x0001, 0x080c, 0x626e, 0x00ce,
+	0x00be, 0x2019, 0x0029, 0x080c, 0x8180, 0x0076, 0x2039, 0x0000,
+	0x080c, 0x8078, 0x00b6, 0x00c6, 0x0026, 0x2158, 0xba04, 0x9294,
+	0x00ff, 0x9286, 0x0006, 0x1118, 0xb807, 0x0404, 0x0028, 0x2001,
+	0x0004, 0x8007, 0x9215, 0xba06, 0x002e, 0x00ce, 0x00be, 0x0016,
+	0x2c08, 0x080c, 0xcd62, 0x001e, 0x007e, 0x002e, 0x8210, 0x1f04,
+	0x2e94, 0x015e, 0x001e, 0x002e, 0x003e, 0x00be, 0x00ce, 0x00ee,
+	0x00fe, 0x0005, 0x0046, 0x0026, 0x0016, 0x080c, 0x5113, 0xd0c4,
+	0x0140, 0xd0a4, 0x0130, 0x9006, 0x2220, 0x2009, 0x0029, 0x080c,
+	0xcfe6, 0x001e, 0x002e, 0x004e, 0x0005, 0x0016, 0x0026, 0x0036,
+	0x00c6, 0x728c, 0x82ff, 0x01e8, 0x080c, 0x629c, 0x11d0, 0x2100,
+	0x080c, 0x2509, 0x81ff, 0x01b8, 0x2019, 0x0001, 0x8314, 0x92e0,
+	0x1c80, 0x2c04, 0xd384, 0x0120, 0x9084, 0xff00, 0x8007, 0x0010,
+	0x9084, 0x00ff, 0x9116, 0x0138, 0x9096, 0x00ff, 0x0110, 0x8318,
+	0x0c68, 0x9085, 0x0001, 0x00ce, 0x003e, 0x002e, 0x001e, 0x0005,
+	0x0016, 0x00c6, 0x0126, 0x2091, 0x8000, 0x0036, 0x2019, 0x0029,
+	0x00a9, 0x003e, 0x9180, 0x1000, 0x2004, 0x9065, 0x0158, 0x0016,
+	0x00c6, 0x2061, 0x1a73, 0x001e, 0x6112, 0x080c, 0x2e30, 0x001e,
+	0x080c, 0x5f42, 0x012e, 0x00ce, 0x001e, 0x0005, 0x0016, 0x0026,
+	0x2110, 0x080c, 0x94b5, 0x080c, 0xd29b, 0x002e, 0x001e, 0x0005,
+	0x2001, 0x1835, 0x2004, 0xd0cc, 0x0005, 0x00c6, 0x00b6, 0x080c,
+	0x6c53, 0x1118, 0x20a9, 0x0800, 0x0010, 0x20a9, 0x0782, 0x080c,
+	0x6c53, 0x1110, 0x900e, 0x0010, 0x2009, 0x007e, 0x9180, 0x1000,
+	0x2004, 0x905d, 0x0130, 0x86ff, 0x0110, 0xb800, 0xd0bc, 0x090c,
+	0x5f42, 0x8108, 0x1f04, 0x2f66, 0x2061, 0x1800, 0x6077, 0x0000,
+	0x6078, 0x9084, 0x00ff, 0x607a, 0x60ab, 0x0000, 0x00be, 0x00ce,
+	0x0005, 0x2001, 0x1875, 0x2004, 0xd0bc, 0x0005, 0x2011, 0x1854,
+	0x2214, 0xd2ec, 0x0005, 0x0026, 0x2011, 0x1873, 0x2214, 0xd2dc,
+	0x002e, 0x0005, 0x7eef, 0x7de8, 0x7ce4, 0x80e2, 0x7be1, 0x80e0,
+	0x80dc, 0x80da, 0x7ad9, 0x80d6, 0x80d5, 0x80d4, 0x80d3, 0x80d2,
+	0x80d1, 0x79ce, 0x78cd, 0x80cc, 0x80cb, 0x80ca, 0x80c9, 0x80c7,
+	0x80c6, 0x77c5, 0x76c3, 0x80bc, 0x80ba, 0x75b9, 0x80b6, 0x74b5,
+	0x73b4, 0x72b3, 0x80b2, 0x80b1, 0x80ae, 0x71ad, 0x80ac, 0x70ab,
+	0x6faa, 0x6ea9, 0x80a7, 0x6da6, 0x6ca5, 0x6ba3, 0x6a9f, 0x699e,
+	0x689d, 0x809b, 0x8098, 0x6797, 0x6690, 0x658f, 0x6488, 0x6384,
+	0x6282, 0x8081, 0x8080, 0x617c, 0x607a, 0x8079, 0x5f76, 0x8075,
+	0x8074, 0x8073, 0x8072, 0x8071, 0x806e, 0x5e6d, 0x806c, 0x5d6b,
+	0x5c6a, 0x5b69, 0x8067, 0x5a66, 0x5965, 0x5863, 0x575c, 0x565a,
+	0x5559, 0x8056, 0x8055, 0x5454, 0x5353, 0x5252, 0x5151, 0x504e,
+	0x4f4d, 0x804c, 0x804b, 0x4e4a, 0x4d49, 0x8047, 0x4c46, 0x8045,
+	0x8043, 0x803c, 0x803a, 0x8039, 0x8036, 0x4b35, 0x8034, 0x4a33,
+	0x4932, 0x4831, 0x802e, 0x472d, 0x462c, 0x452b, 0x442a, 0x4329,
+	0x4227, 0x8026, 0x8025, 0x4123, 0x401f, 0x3f1e, 0x3e1d, 0x3d1b,
+	0x3c18, 0x8017, 0x8010, 0x3b0f, 0x3a08, 0x8004, 0x3902, 0x8001,
+	0x8000, 0x8000, 0x3800, 0x3700, 0x3600, 0x8000, 0x3500, 0x8000,
+	0x8000, 0x8000, 0x3400, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
+	0x8000, 0x3300, 0x3200, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
+	0x8000, 0x3100, 0x3000, 0x8000, 0x8000, 0x2f00, 0x8000, 0x2e00,
+	0x2d00, 0x2c00, 0x8000, 0x8000, 0x8000, 0x2b00, 0x8000, 0x2a00,
+	0x2900, 0x2800, 0x8000, 0x2700, 0x2600, 0x2500, 0x2400, 0x2300,
+	0x2200, 0x8000, 0x8000, 0x2100, 0x2000, 0x1f00, 0x1e00, 0x1d00,
+	0x1c00, 0x8000, 0x8000, 0x1b00, 0x1a00, 0x8000, 0x1900, 0x8000,
+	0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x1800, 0x8000, 0x1700,
+	0x1600, 0x1500, 0x8000, 0x1400, 0x1300, 0x1200, 0x1100, 0x1000,
+	0x0f00, 0x8000, 0x8000, 0x0e00, 0x0d00, 0x0c00, 0x0b00, 0x0a00,
+	0x0900, 0x8000, 0x8000, 0x0800, 0x0700, 0x8000, 0x0600, 0x8000,
+	0x8000, 0x8000, 0x0500, 0x0400, 0x0300, 0x8000, 0x0200, 0x8000,
+	0x8000, 0x8000, 0x0100, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
+	0x8000, 0x0000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
+	0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
+	0x8000, 0x8000, 0x2071, 0x1894, 0x7003, 0x0002, 0x9006, 0x7016,
+	0x701a, 0x704a, 0x704e, 0x700e, 0x7042, 0x7046, 0x703b, 0x18b0,
+	0x703f, 0x18b0, 0x7007, 0x0001, 0x080c, 0x0fee, 0x090c, 0x0db2,
+	0x2900, 0x706a, 0xa867, 0x0002, 0xa8ab, 0xdcb0, 0x080c, 0x0fee,
+	0x090c, 0x0db2, 0x2900, 0x706e, 0xa867, 0x0002, 0xa8ab, 0xdcb0,
+	0x0005, 0x2071, 0x1894, 0x7004, 0x0002, 0x30c1, 0x30c2, 0x30d5,
+	0x30e9, 0x0005, 0x1004, 0x30d2, 0x0e04, 0x30d2, 0x2079, 0x0000,
+	0x0126, 0x2091, 0x8000, 0x700c, 0x9005, 0x1128, 0x700f, 0x0001,
+	0x012e, 0x0468, 0x0005, 0x012e, 0x0ce8, 0x2079, 0x0000, 0x2061,
+	0x18ae, 0x2c4c, 0xa86c, 0x908e, 0x0100, 0x0128, 0x9086, 0x0200,
+	0x0904, 0x31bd, 0x0005, 0x7018, 0x2048, 0x2061, 0x1800, 0x701c,
+	0x0807, 0x7014, 0x2048, 0xa864, 0x9094, 0x00ff, 0x9296, 0x0029,
+	0x1120, 0xaa78, 0xd2fc, 0x0128, 0x0005, 0x9086, 0x0103, 0x0108,
+	0x0005, 0x2079, 0x0000, 0x2061, 0x1800, 0x701c, 0x0807, 0x2061,
+	0x1800, 0x7880, 0x908a, 0x0040, 0x1210, 0x61c8, 0x0042, 0x2100,
+	0x908a, 0x003f, 0x1a04, 0x31ba, 0x61c8, 0x0804, 0x314f, 0x3191,
+	0x31c9, 0x31d3, 0x31d7, 0x31e1, 0x31e7, 0x31eb, 0x31fb, 0x31fe,
+	0x3208, 0x320d, 0x3212, 0x321d, 0x3228, 0x3237, 0x3246, 0x3254,
+	0x326b, 0x3286, 0x31ba, 0x332f, 0x336d, 0x3413, 0x3424, 0x3447,
+	0x31ba, 0x31ba, 0x31ba, 0x347f, 0x349b, 0x34a4, 0x34d3, 0x34d9,
+	0x31ba, 0x351f, 0x31ba, 0x31ba, 0x31ba, 0x31ba, 0x31ba, 0x352a,
+	0x3533, 0x353b, 0x353d, 0x31ba, 0x31ba, 0x31ba, 0x31ba, 0x31ba,
+	0x31ba, 0x3569, 0x31ba, 0x31ba, 0x31ba, 0x31ba, 0x31ba, 0x3586,
+	0x35e1, 0x31ba, 0x31ba, 0x31ba, 0x31ba, 0x31ba, 0x31ba, 0x0002,
+	0x360b, 0x360e, 0x366d, 0x3686, 0x36b6, 0x3954, 0x31ba, 0x4cec,
+	0x31ba, 0x31ba, 0x31ba, 0x31ba, 0x31ba, 0x31ba, 0x31ba, 0x31ba,
+	0x3208, 0x320d, 0x3e75, 0x31ba, 0x3e8b, 0x4d7b, 0x4dcc, 0x4ecf,
+	0x31ba, 0x4f31, 0x4f6d, 0x4f9e, 0x50a2, 0x4fcb, 0x5022, 0x31ba,
+	0x3e8f, 0x404f, 0x4065, 0x408a, 0x40ef, 0x4163, 0x4183, 0x41fa,
+	0x420b, 0x421c, 0x421f, 0x4244, 0x42b7, 0x431d, 0x4325, 0x4457,
+	0x459c, 0x45d0, 0x4834, 0x31ba, 0x4852, 0x48fe, 0x49d4, 0x31ba,
+	0x31ba, 0x31ba, 0x31ba, 0x4a3a, 0x4a55, 0x4325, 0x4c9b, 0x714c,
+	0x0000, 0x2021, 0x4000, 0x080c, 0x464e, 0x0126, 0x2091, 0x8000,
+	0x0e04, 0x319b, 0x0010, 0x012e, 0x0cc0, 0x7c36, 0x9486, 0x4000,
+	0x0118, 0x7833, 0x0011, 0x0010, 0x7833, 0x0010, 0x7c82, 0x7986,
+	0x7a8a, 0x7b8e, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
+	0x190c, 0x1167, 0x7007, 0x0001, 0x2091, 0x5000, 0x700f, 0x0000,
+	0x012e, 0x0005, 0x2021, 0x4001, 0x08b0, 0x2021, 0x4002, 0x0898,
+	0x2021, 0x4003, 0x0880, 0x2021, 0x4005, 0x0868, 0x2021, 0x4006,
+	0x0850, 0x2039, 0x0001, 0x902e, 0x2520, 0x7b88, 0x7a8c, 0x7884,
+	0x7990, 0x0804, 0x465b, 0x7883, 0x0004, 0x7884, 0x0807, 0x2039,
+	0x0001, 0x902e, 0x2520, 0x7b88, 0x7a8c, 0x7884, 0x7990, 0x0804,
+	0x465e, 0x7984, 0x7888, 0x2114, 0x200a, 0x0804, 0x3191, 0x7984,
+	0x2114, 0x0804, 0x3191, 0x20e1, 0x0000, 0x2099, 0x0021, 0x20e9,
+	0x0000, 0x20a1, 0x0021, 0x20a9, 0x001f, 0x4003, 0x7984, 0x7a88,
+	0x7b8c, 0x0804, 0x3191, 0x7884, 0x2060, 0x04d8, 0x2009, 0x0003,
+	0x2011, 0x0002, 0x2019, 0x0012, 0x789b, 0x0117, 0x0804, 0x3191,
+	0x2039, 0x0001, 0x7d98, 0x7c9c, 0x0800, 0x2039, 0x0001, 0x7d98,
+	0x7c9c, 0x0848, 0x79a0, 0x9182, 0x0040, 0x0210, 0x0804, 0x31c6,
+	0x2138, 0x7d98, 0x7c9c, 0x0804, 0x31cd, 0x79a0, 0x9182, 0x0040,
+	0x0210, 0x0804, 0x31c6, 0x2138, 0x7d98, 0x7c9c, 0x0804, 0x31db,
+	0x79a0, 0x9182, 0x0040, 0x0210, 0x0804, 0x31c6, 0x21e8, 0x7984,
+	0x7888, 0x20a9, 0x0001, 0x21a0, 0x4004, 0x0804, 0x3191, 0x2061,
+	0x0800, 0xe10c, 0x9006, 0x2c15, 0x9200, 0x8c60, 0x8109, 0x1dd8,
+	0x2010, 0x9005, 0x0904, 0x3191, 0x0804, 0x31c0, 0x79a0, 0x9182,
+	0x0040, 0x0210, 0x0804, 0x31c6, 0x21e0, 0x20a9, 0x0001, 0x7984,
+	0x2198, 0x4012, 0x0804, 0x3191, 0x2069, 0x1853, 0x7884, 0x7990,
+	0x911a, 0x1a04, 0x31c6, 0x8019, 0x0904, 0x31c6, 0x684a, 0x6942,
+	0x788c, 0x6852, 0x7888, 0x6856, 0x9006, 0x685a, 0x685e, 0x080c,
+	0x6f5b, 0x0804, 0x3191, 0x2069, 0x1853, 0x7884, 0x7994, 0x911a,
+	0x1a04, 0x31c6, 0x8019, 0x0904, 0x31c6, 0x684e, 0x6946, 0x788c,
+	0x6862, 0x7888, 0x6866, 0x9006, 0x686a, 0x686e, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x630e, 0x012e, 0x0804, 0x3191, 0x902e, 0x2520,
+	0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x31c3, 0x7984, 0x7b88,
+	0x7a8c, 0x20a9, 0x0005, 0x20e9, 0x0001, 0x20a1, 0x189c, 0x4101,
+	0x080c, 0x4612, 0x1120, 0x2009, 0x0002, 0x0804, 0x31c3, 0x2009,
+	0x0020, 0xa85c, 0x9080, 0x0019, 0xaf60, 0x080c, 0x465b, 0x701f,
+	0x32aa, 0x0005, 0xa864, 0x2008, 0x9084, 0x00ff, 0x9096, 0x0011,
+	0x0168, 0x9096, 0x0019, 0x0150, 0x9096, 0x0015, 0x0138, 0x9096,
+	0x0048, 0x0120, 0x9096, 0x0029, 0x1904, 0x31c3, 0x810f, 0x918c,
+	0x00ff, 0x0904, 0x31c3, 0x7112, 0x7010, 0x8001, 0x0560, 0x7012,
+	0x080c, 0x4612, 0x1120, 0x2009, 0x0002, 0x0804, 0x31c3, 0x2009,
+	0x0020, 0x7068, 0x2040, 0xa28c, 0xa390, 0xa494, 0xa598, 0x9290,
+	0x0040, 0x9399, 0x0000, 0x94a1, 0x0000, 0x95a9, 0x0000, 0xa85c,
+	0x9080, 0x0019, 0xaf60, 0x080c, 0x465b, 0x701f, 0x32e8, 0x0005,
+	0xa864, 0x9084, 0x00ff, 0x9096, 0x0002, 0x0120, 0x9096, 0x000a,
+	0x1904, 0x31c3, 0x0888, 0x7014, 0x2048, 0xa868, 0xc0fd, 0xa86a,
+	0xa864, 0x9084, 0x00ff, 0x9096, 0x0029, 0x1160, 0xc2fd, 0xaa7a,
+	0x080c, 0x5b2d, 0x0150, 0x0126, 0x2091, 0x8000, 0xa87a, 0xa982,
+	0x012e, 0x0050, 0x080c, 0x5e34, 0x1128, 0x7007, 0x0003, 0x701f,
+	0x3314, 0x0005, 0x080c, 0x6770, 0x0126, 0x2091, 0x8000, 0x20a9,
+	0x0005, 0x20e1, 0x0001, 0x2099, 0x189c, 0x400a, 0x2100, 0x9210,
+	0x9399, 0x0000, 0x94a1, 0x0000, 0x95a9, 0x0000, 0xa85c, 0x9080,
+	0x0019, 0x2009, 0x0020, 0x012e, 0xaf60, 0x0804, 0x465e, 0x2091,
+	0x8000, 0x7837, 0x4000, 0x7833, 0x0010, 0x7883, 0x4000, 0x7887,
+	0x4953, 0x788b, 0x5020, 0x788f, 0x2020, 0x2009, 0x017f, 0x2104,
+	0x7892, 0x3f00, 0x7896, 0x2061, 0x0100, 0x6200, 0x2061, 0x0200,
+	0x603c, 0x8007, 0x9205, 0x789a, 0x2009, 0x04fd, 0x2104, 0x789e,
+	0x2091, 0x5000, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
+	0x0180, 0x2001, 0x19e8, 0x2004, 0x9005, 0x0128, 0x2001, 0x008b,
+	0x2004, 0xd0fc, 0x0dd8, 0x2001, 0x008a, 0x2003, 0x0002, 0x2003,
+	0x1001, 0x2071, 0x0080, 0x0804, 0x0427, 0x81ff, 0x1904, 0x31c3,
+	0x7984, 0x080c, 0x5f7e, 0x1904, 0x31c6, 0x7e98, 0x9684, 0x3fff,
+	0x9082, 0x4000, 0x1a04, 0x31c6, 0x7c88, 0x7d8c, 0x080c, 0x60e1,
+	0x080c, 0x60b0, 0x0000, 0x1518, 0x2061, 0x1cd0, 0x0126, 0x2091,
+	0x8000, 0x6000, 0x9086, 0x0000, 0x0148, 0x6014, 0x904d, 0x0130,
+	0xa86c, 0x9406, 0x1118, 0xa870, 0x9506, 0x0150, 0x012e, 0x9ce0,
+	0x0018, 0x2001, 0x1818, 0x2004, 0x9c02, 0x1a04, 0x31c3, 0x0c30,
+	0x080c, 0xb251, 0x012e, 0x0904, 0x31c3, 0x0804, 0x3191, 0x900e,
+	0x2001, 0x0005, 0x080c, 0x6770, 0x0126, 0x2091, 0x8000, 0x080c,
+	0xb8e9, 0x080c, 0x6536, 0x012e, 0x0804, 0x3191, 0x00a6, 0x2950,
+	0xb198, 0x080c, 0x5f7e, 0x1904, 0x3400, 0xb6a4, 0x9684, 0x3fff,
+	0x9082, 0x4000, 0x16e8, 0xb49c, 0xb5a0, 0x080c, 0x60e1, 0x080c,
+	0x60b0, 0x1520, 0x2061, 0x1cd0, 0x0126, 0x2091, 0x8000, 0x6000,
+	0x9086, 0x0000, 0x0148, 0x6014, 0x904d, 0x0130, 0xa86c, 0x9406,
+	0x1118, 0xa870, 0x9506, 0x0158, 0x012e, 0x9ce0, 0x0018, 0x2001,
+	0x1818, 0x2004, 0x9c02, 0x2009, 0x000d, 0x12b0, 0x0c28, 0x080c,
+	0xb251, 0x012e, 0x2009, 0x0003, 0x0178, 0x00e0, 0x900e, 0x2001,
+	0x0005, 0x080c, 0x6770, 0x0126, 0x2091, 0x8000, 0x080c, 0xb8e9,
+	0x080c, 0x6529, 0x012e, 0x0070, 0xb097, 0x4005, 0xb19a, 0x0010,
+	0xb097, 0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x2a48,
+	0x00ae, 0x0005, 0xb097, 0x4000, 0x9006, 0x918d, 0x0001, 0x2008,
+	0x2a48, 0x00ae, 0x0005, 0x81ff, 0x1904, 0x31c3, 0x080c, 0x4629,
+	0x0904, 0x31c6, 0x080c, 0x6045, 0x0904, 0x31c3, 0x080c, 0x60e7,
+	0x0904, 0x31c3, 0x0804, 0x417a, 0x81ff, 0x1904, 0x31c3, 0x080c,
+	0x4645, 0x0904, 0x31c6, 0x080c, 0x6175, 0x0904, 0x31c3, 0x2019,
+	0x0005, 0x79a8, 0x080c, 0x6102, 0x0904, 0x31c3, 0x7888, 0x908a,
+	0x1000, 0x1a04, 0x31c6, 0x8003, 0x800b, 0x810b, 0x9108, 0x080c,
+	0x7c58, 0x7984, 0xd184, 0x1904, 0x3191, 0x0804, 0x417a, 0x0126,
+	0x2091, 0x8000, 0x81ff, 0x0118, 0x2009, 0x0001, 0x0450, 0x2029,
+	0x07ff, 0x6454, 0x2400, 0x9506, 0x01f8, 0x2508, 0x080c, 0x5f7e,
+	0x11d8, 0x080c, 0x6175, 0x1128, 0x2009, 0x0002, 0x62b8, 0x2518,
+	0x00c0, 0x2019, 0x0004, 0x900e, 0x080c, 0x6102, 0x1118, 0x2009,
+	0x0006, 0x0078, 0x7884, 0x908a, 0x1000, 0x1270, 0x8003, 0x800b,
+	0x810b, 0x9108, 0x080c, 0x7c58, 0x8529, 0x1ae0, 0x012e, 0x0804,
+	0x3191, 0x012e, 0x0804, 0x31c3, 0x012e, 0x0804, 0x31c6, 0x080c,
+	0x4629, 0x0904, 0x31c6, 0x080c, 0x6045, 0x0904, 0x31c3, 0xbaa0,
+	0x2019, 0x0005, 0x00c6, 0x9066, 0x080c, 0x8180, 0x0076, 0x903e,
+	0x080c, 0x8078, 0x900e, 0x080c, 0xcd62, 0x007e, 0x00ce, 0x080c,
+	0x60e1, 0x0804, 0x3191, 0x080c, 0x4629, 0x0904, 0x31c6, 0x080c,
+	0x60e1, 0x2208, 0x0804, 0x3191, 0x0156, 0x00d6, 0x00e6, 0x2069,
+	0x1906, 0x6810, 0x6914, 0x910a, 0x1208, 0x900e, 0x6816, 0x9016,
+	0x901e, 0x20a9, 0x007e, 0x2069, 0x1000, 0x2d04, 0x905d, 0x0118,
+	0xb84c, 0x0059, 0x9210, 0x8d68, 0x1f04, 0x34b5, 0x2300, 0x9218,
+	0x00ee, 0x00de, 0x015e, 0x0804, 0x3191, 0x00f6, 0x0016, 0x907d,
+	0x0138, 0x9006, 0x8000, 0x2f0c, 0x81ff, 0x0110, 0x2178, 0x0cd0,
+	0x001e, 0x00fe, 0x0005, 0x2069, 0x1906, 0x6910, 0x62b4, 0x0804,
+	0x3191, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x31c3, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x5127, 0x0128, 0x2009, 0x0007, 0x012e,
+	0x0804, 0x31c3, 0x012e, 0x6154, 0x9190, 0x2f92, 0x2215, 0x9294,
+	0x00ff, 0x6374, 0x83ff, 0x0108, 0x6278, 0x67d4, 0x97c4, 0x000a,
+	0x98c6, 0x000a, 0x1118, 0x2031, 0x0001, 0x00e8, 0x97c4, 0x0022,
+	0x98c6, 0x0022, 0x1118, 0x2031, 0x0003, 0x00a8, 0x97c4, 0x0012,
+	0x98c6, 0x0012, 0x1118, 0x2031, 0x0002, 0x0068, 0x080c, 0x6c53,
+	0x1118, 0x2031, 0x0004, 0x0038, 0xd79c, 0x0120, 0x2009, 0x0005,
+	0x0804, 0x31c3, 0x9036, 0x7e9a, 0x7f9e, 0x0804, 0x3191, 0x6144,
+	0x6248, 0x2019, 0x1955, 0x231c, 0x2001, 0x1956, 0x2004, 0x789a,
+	0x0804, 0x3191, 0x0126, 0x2091, 0x8000, 0x6134, 0x6238, 0x633c,
+	0x012e, 0x0804, 0x3191, 0x080c, 0x4645, 0x0904, 0x31c6, 0xba44,
+	0xbb38, 0x0804, 0x3191, 0x080c, 0x0db2, 0x080c, 0x4645, 0x2110,
+	0x0904, 0x31c6, 0xb804, 0x908c, 0x00ff, 0x918e, 0x0006, 0x0140,
+	0x9084, 0xff00, 0x9086, 0x0600, 0x2009, 0x0009, 0x1904, 0x31c3,
+	0x0126, 0x2091, 0x8000, 0x2019, 0x0005, 0x00c6, 0x9066, 0x080c,
+	0x94b5, 0x080c, 0x8180, 0x0076, 0x903e, 0x080c, 0x8078, 0x900e,
+	0x080c, 0xcd62, 0x007e, 0x00ce, 0xb807, 0x0407, 0x012e, 0x0804,
+	0x3191, 0x6144, 0x6248, 0x7884, 0x6046, 0x7b88, 0x634a, 0x2069,
+	0x1853, 0x831f, 0x9305, 0x6816, 0x788c, 0x2069, 0x1955, 0x2d1c,
+	0x206a, 0x7e98, 0x9682, 0x0014, 0x1210, 0x2031, 0x07d0, 0x2069,
+	0x1956, 0x2d04, 0x266a, 0x789a, 0x0804, 0x3191, 0x0126, 0x2091,
+	0x8000, 0x6134, 0x7884, 0x6036, 0x910e, 0xd1b4, 0x190c, 0x0e84,
+	0xd0c4, 0x01a8, 0x00d6, 0x78a8, 0x2009, 0x196c, 0x200a, 0x78ac,
+	0x2011, 0x196d, 0x2012, 0x2069, 0x0100, 0x6838, 0x9086, 0x0007,
+	0x1118, 0x2214, 0x6a5a, 0x0010, 0x210c, 0x695a, 0x00de, 0x7888,
+	0x603a, 0x2011, 0x0114, 0x220c, 0x7888, 0xd08c, 0x0118, 0x918d,
+	0x0080, 0x0010, 0x918c, 0xff7f, 0x2112, 0x613c, 0x788c, 0x603e,
+	0x910e, 0xd1e4, 0x190c, 0x0e9a, 0x603c, 0xd0cc, 0x0120, 0x78b0,
+	0x2011, 0x0114, 0x2012, 0x012e, 0x0804, 0x3191, 0x00f6, 0x2079,
+	0x1800, 0x7a34, 0xa898, 0x9084, 0xfebf, 0x9215, 0xa89c, 0x9084,
+	0xfebf, 0x8002, 0x9214, 0x7834, 0x9084, 0x0140, 0x9215, 0x7a36,
+	0xa897, 0x4000, 0x900e, 0x9085, 0x0001, 0x2001, 0x0000, 0x00fe,
+	0x0005, 0x7898, 0x9005, 0x01a8, 0x7888, 0x9025, 0x0904, 0x31c6,
+	0x788c, 0x902d, 0x0904, 0x31c6, 0x900e, 0x080c, 0x5f7e, 0x1120,
+	0xba44, 0xbb38, 0xbc46, 0xbd3a, 0x9186, 0x07ff, 0x0190, 0x8108,
+	0x0ca0, 0x080c, 0x4645, 0x0904, 0x31c6, 0x7888, 0x900d, 0x0904,
+	0x31c6, 0x788c, 0x9005, 0x0904, 0x31c6, 0xba44, 0xb946, 0xbb38,
+	0xb83a, 0x0804, 0x3191, 0x2011, 0xbc09, 0x0010, 0x2011, 0xbc05,
+	0x080c, 0x5127, 0x1904, 0x31c3, 0x00c6, 0x2061, 0x0100, 0x7984,
+	0x9186, 0x00ff, 0x1130, 0x2001, 0x1816, 0x2004, 0x9085, 0xff00,
+	0x0088, 0x9182, 0x007f, 0x16e0, 0x9188, 0x2f92, 0x210d, 0x918c,
+	0x00ff, 0x2001, 0x1816, 0x2004, 0x0026, 0x9116, 0x002e, 0x0580,
+	0x810f, 0x9105, 0x0126, 0x2091, 0x8000, 0x0006, 0x080c, 0x9980,
+	0x000e, 0x0510, 0x602e, 0x620a, 0x7984, 0x00b6, 0x080c, 0x5f24,
+	0x2b08, 0x00be, 0x1500, 0x6112, 0x6023, 0x0001, 0x080c, 0x4612,
+	0x01d0, 0x9006, 0xa866, 0x7007, 0x0003, 0xa832, 0xa868, 0xc0fd,
+	0xa86a, 0x701f, 0x3666, 0x2900, 0x6016, 0x2009, 0x0032, 0x080c,
+	0x9a50, 0x012e, 0x00ce, 0x0005, 0x012e, 0x00ce, 0x0804, 0x31c3,
+	0x00ce, 0x0804, 0x31c6, 0x080c, 0x99d6, 0x0cb0, 0xa830, 0x9086,
+	0x0100, 0x0904, 0x31c3, 0x0804, 0x3191, 0x2061, 0x1a3e, 0x0126,
+	0x2091, 0x8000, 0x6000, 0xd084, 0x0170, 0x6104, 0x6208, 0x2061,
+	0x1800, 0x634c, 0x606c, 0x789a, 0x60b8, 0x789e, 0x60b4, 0x78aa,
+	0x012e, 0x0804, 0x3191, 0x900e, 0x2110, 0x0c88, 0x81ff, 0x1904,
+	0x31c3, 0x080c, 0x6c53, 0x0904, 0x31c3, 0x0126, 0x2091, 0x8000,
+	0x624c, 0x606c, 0x9202, 0x0248, 0x9085, 0x0001, 0x080c, 0x253f,
+	0x080c, 0x5304, 0x012e, 0x0804, 0x3191, 0x012e, 0x0804, 0x31c6,
+	0x0006, 0x0016, 0x00c6, 0x00e6, 0x2001, 0x1978, 0x2070, 0x2061,
+	0x1853, 0x6008, 0x2072, 0x900e, 0x2011, 0x1400, 0x080c, 0x7e7f,
+	0x7206, 0x00ee, 0x00ce, 0x001e, 0x000e, 0x0005, 0x0126, 0x2091,
+	0x8000, 0x81ff, 0x0128, 0x012e, 0x2021, 0x400b, 0x0804, 0x3193,
+	0x7884, 0xd0fc, 0x0148, 0x2001, 0x002a, 0x2004, 0x9082, 0x00e1,
+	0x0288, 0x012e, 0x0804, 0x31c6, 0x2001, 0x002a, 0x2004, 0x2069,
+	0x1853, 0x6908, 0x9102, 0x1230, 0x012e, 0x0804, 0x31c6, 0x012e,
+	0x0804, 0x31c3, 0x080c, 0x9940, 0x0dd0, 0x7884, 0xd0fc, 0x0904,
+	0x3731, 0x00c6, 0x080c, 0x4612, 0x00ce, 0x0d88, 0xa867, 0x0000,
+	0x7884, 0xa80a, 0x7898, 0xa80e, 0x789c, 0xa812, 0x2001, 0x002e,
+	0x2004, 0xa81a, 0x2001, 0x002f, 0x2004, 0xa81e, 0x2001, 0x0030,
+	0x2004, 0xa822, 0x2001, 0x0031, 0x2004, 0xa826, 0x2001, 0x0034,
+	0x2004, 0xa82a, 0x2001, 0x0035, 0x2004, 0xa82e, 0x2001, 0x002a,
+	0x2004, 0x9080, 0x0003, 0x9084, 0x00fc, 0x8004, 0xa816, 0x080c,
+	0x38b7, 0x0928, 0x7014, 0x2048, 0xad2c, 0xac28, 0xab1c, 0xaa18,
+	0xa930, 0xa808, 0xd0b4, 0x1120, 0x2029, 0x0000, 0x2021, 0x0000,
+	0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080,
+	0x001b, 0x080c, 0x465b, 0x701f, 0x37f4, 0x7023, 0x0001, 0x012e,
+	0x0005, 0x0046, 0x0086, 0x0096, 0x00a6, 0x00b6, 0x00c6, 0x00d6,
+	0x00e6, 0x00f6, 0x080c, 0x36a0, 0x2001, 0x196e, 0x2003, 0x0000,
+	0x2021, 0x000a, 0x2061, 0x0100, 0x6104, 0x0016, 0x60bb, 0x0000,
+	0x60bf, 0x32e1, 0x60bf, 0x0012, 0x080c, 0x3926, 0x080c, 0x38e5,
+	0x00f6, 0x00e6, 0x0086, 0x2940, 0x2071, 0x1a34, 0x2079, 0x0090,
+	0x00d6, 0x2069, 0x0000, 0x6884, 0xd0b4, 0x0140, 0x2001, 0x0035,
+	0x2004, 0x780e, 0x2001, 0x0034, 0x2004, 0x780a, 0x00de, 0x2011,
+	0x0001, 0x080c, 0x3cb9, 0x008e, 0x00ee, 0x00fe, 0x080c, 0x3be6,
+	0x080c, 0x3aeb, 0x05b8, 0x2001, 0x020b, 0x2004, 0x9084, 0x0140,
+	0x1db8, 0x080c, 0x3d2d, 0x00f6, 0x2079, 0x0300, 0x78bc, 0x00fe,
+	0x908c, 0x0070, 0x1560, 0x2071, 0x0200, 0x7037, 0x0000, 0x7050,
+	0x9084, 0xff00, 0x9086, 0x3200, 0x1510, 0x7037, 0x0001, 0x7050,
+	0x9084, 0xff00, 0x9086, 0xe100, 0x11d0, 0x7037, 0x0000, 0x7054,
+	0x7037, 0x0000, 0x715c, 0x9106, 0x1190, 0x2001, 0x181e, 0x2004,
+	0x9106, 0x1168, 0x00c6, 0x2061, 0x0100, 0x6024, 0x9084, 0x1e00,
+	0x00ce, 0x0138, 0x080c, 0x3af5, 0x080c, 0x38e0, 0x0058, 0x080c,
+	0x38e0, 0x080c, 0x3c51, 0x080c, 0x3bdc, 0x2001, 0x020b, 0x2004,
+	0xd0e4, 0x0dd8, 0x2001, 0x032a, 0x2003, 0x0004, 0x2061, 0x0100,
+	0x6027, 0x0002, 0x001e, 0x6106, 0x2011, 0x020d, 0x2013, 0x0020,
+	0x60bb, 0x0000, 0x60bf, 0x0108, 0x60bf, 0x0012, 0x2001, 0x0004,
+	0x200c, 0x918c, 0xfffd, 0x2102, 0x080c, 0x127c, 0x2009, 0x0028,
+	0x080c, 0x20d9, 0x2001, 0x0227, 0x200c, 0x2102, 0x00fe, 0x00ee,
+	0x00de, 0x00ce, 0x00be, 0x00ae, 0x009e, 0x008e, 0x004e, 0x2001,
+	0x196e, 0x2004, 0x9005, 0x1118, 0x012e, 0x0804, 0x3191, 0x012e,
+	0x2021, 0x400c, 0x0804, 0x3193, 0x0016, 0x0026, 0x0036, 0x0046,
+	0x0056, 0x0076, 0x0086, 0x0096, 0x00d6, 0x0156, 0x7014, 0x2048,
+	0x7020, 0x20a8, 0x8000, 0x7022, 0xa804, 0x9005, 0x0904, 0x3850,
+	0x2048, 0x1f04, 0x3804, 0x7068, 0x2040, 0xa28c, 0xa390, 0xa494,
+	0xa598, 0xa930, 0xa808, 0xd0b4, 0x1120, 0x2029, 0x0000, 0x2021,
+	0x0000, 0x0096, 0x7014, 0x2048, 0xa864, 0x009e, 0x9086, 0x0103,
+	0x0170, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0,
+	0x9080, 0x001b, 0x080c, 0x465b, 0x701f, 0x37f4, 0x00b0, 0x8906,
+	0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x001b,
+	0x21a8, 0x27e0, 0x2098, 0x27e8, 0x20a0, 0x0006, 0x080c, 0x0f52,
+	0x000e, 0x080c, 0x465e, 0x701f, 0x37f4, 0x015e, 0x00de, 0x009e,
+	0x008e, 0x007e, 0x005e, 0x004e, 0x003e, 0x002e, 0x001e, 0x0005,
+	0x7014, 0x2048, 0xa864, 0x9086, 0x0103, 0x1118, 0x701f, 0x38b5,
+	0x0450, 0x7014, 0x2048, 0xa868, 0xc0fd, 0xa86a, 0x2009, 0x007f,
+	0x080c, 0x5f1e, 0x0110, 0x9006, 0x0030, 0xb813, 0x00ff, 0xb817,
+	0xfffd, 0x080c, 0xbab8, 0x015e, 0x00de, 0x009e, 0x008e, 0x007e,
+	0x005e, 0x004e, 0x003e, 0x002e, 0x001e, 0x0904, 0x31c3, 0x0016,
+	0x0026, 0x0036, 0x0046, 0x0056, 0x0076, 0x0086, 0x0096, 0x00d6,
+	0x0156, 0x701f, 0x3887, 0x7007, 0x0003, 0x0804, 0x3845, 0x0076,
+	0xa830, 0x9086, 0x0100, 0x2021, 0x400c, 0x0904, 0x3193, 0xad10,
+	0xac0c, 0xab24, 0xaa20, 0xa930, 0xa808, 0xd0b4, 0x1120, 0x2029,
+	0x0000, 0x2021, 0x0000, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f,
+	0x9084, 0xffc0, 0x9080, 0x001b, 0x21a8, 0x27e0, 0x2098, 0x27e8,
+	0x20a0, 0x0006, 0x080c, 0x0f52, 0x000e, 0x080c, 0x465e, 0x007e,
+	0x701f, 0x37f4, 0x7023, 0x0001, 0x0005, 0x0804, 0x3191, 0x0156,
+	0x00c6, 0xa814, 0x908a, 0x001e, 0x0218, 0xa833, 0x001e, 0x0010,
+	0xa832, 0x0078, 0x81ff, 0x0168, 0x0016, 0x080c, 0x4612, 0x001e,
+	0x0130, 0xa800, 0x2040, 0xa008, 0xa80a, 0x2100, 0x0c58, 0x9006,
+	0x0010, 0x9085, 0x0001, 0x00ce, 0x015e, 0x0005, 0x0006, 0x00f6,
+	0x2079, 0x0000, 0x7880, 0x9086, 0x0044, 0x00fe, 0x000e, 0x0005,
+	0x2001, 0x196e, 0x2003, 0x0001, 0x0005, 0x00f6, 0x00e6, 0x00c6,
+	0x2061, 0x0200, 0x2001, 0x1979, 0x2004, 0x601a, 0x2061, 0x0100,
+	0x2001, 0x1978, 0x2004, 0x60ce, 0x6104, 0xc1ac, 0x6106, 0x080c,
+	0x4612, 0xa813, 0x0019, 0xa817, 0x0001, 0x2900, 0xa85a, 0x2001,
+	0x002e, 0x2004, 0xa866, 0x2001, 0x002f, 0x2004, 0xa86a, 0x2061,
+	0x0090, 0x2079, 0x0100, 0x2001, 0x1978, 0x2004, 0x6036, 0x2009,
+	0x0040, 0x080c, 0x20d9, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8,
+	0xa86e, 0x601a, 0xa873, 0x0000, 0x601f, 0x0000, 0x78ca, 0x9006,
+	0x600a, 0x600e, 0x00ce, 0x00ee, 0x00fe, 0x0005, 0x00e6, 0x080c,
+	0x4612, 0x2940, 0xa013, 0x0019, 0xa017, 0x0001, 0x2800, 0xa05a,
+	0x2001, 0x0030, 0x2004, 0xa866, 0x2001, 0x0031, 0x2004, 0xa86a,
+	0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0xa86e, 0xa873, 0x0000,
+	0x2001, 0x032a, 0x2003, 0x0004, 0x2001, 0x0300, 0x2003, 0x0000,
+	0x2001, 0x020d, 0x2003, 0x0000, 0x2001, 0x0004, 0x200c, 0x918d,
+	0x0002, 0x2102, 0x00ee, 0x0005, 0x0126, 0x2091, 0x8000, 0x81ff,
+	0x0148, 0x080c, 0x28c8, 0x1130, 0x9006, 0x080c, 0x2820, 0x9006,
+	0x080c, 0x2803, 0x7884, 0x9084, 0x0007, 0x0002, 0x3971, 0x397a,
+	0x3983, 0x396e, 0x396e, 0x396e, 0x396e, 0x396e, 0x012e, 0x0804,
+	0x31c6, 0x2009, 0x0114, 0x2104, 0x9085, 0x0800, 0x200a, 0x080c,
+	0x3b3f, 0x00c0, 0x2009, 0x0114, 0x2104, 0x9085, 0x4000, 0x200a,
+	0x080c, 0x3b3f, 0x0078, 0x080c, 0x6c53, 0x1128, 0x012e, 0x2009,
+	0x0016, 0x0804, 0x31c3, 0x81ff, 0x0128, 0x012e, 0x2021, 0x400b,
+	0x0804, 0x3193, 0x0086, 0x0096, 0x00a6, 0x00b6, 0x00c6, 0x00d6,
+	0x00e6, 0x00f6, 0x080c, 0x36a0, 0x2009, 0x0101, 0x210c, 0x0016,
+	0x7ec8, 0x7dcc, 0x9006, 0x2068, 0x2060, 0x2058, 0x080c, 0x3e08,
+	0x080c, 0x3d58, 0x903e, 0x2720, 0x00f6, 0x00e6, 0x0086, 0x2940,
+	0x2071, 0x1a34, 0x2079, 0x0090, 0x00d6, 0x2069, 0x0000, 0x6884,
+	0xd0b4, 0x0120, 0x68d4, 0x780e, 0x68d0, 0x780a, 0x00de, 0x2011,
+	0x0001, 0x080c, 0x3cb9, 0x080c, 0x28d0, 0x080c, 0x28d0, 0x080c,
+	0x28d0, 0x080c, 0x28d0, 0x080c, 0x3cb9, 0x008e, 0x00ee, 0x00fe,
+	0x080c, 0x3be6, 0x2009, 0x0190, 0x8109, 0x11b0, 0x080c, 0x3af5,
+	0x2001, 0x0004, 0x200c, 0x918c, 0xfffd, 0x2102, 0x001e, 0x00fe,
+	0x00ee, 0x00de, 0x00ce, 0x00be, 0x00ae, 0x009e, 0x008e, 0x2009,
+	0x0017, 0x080c, 0x31c3, 0x0cf8, 0x2001, 0x020b, 0x2004, 0x9084,
+	0x0140, 0x1d10, 0x00f6, 0x2079, 0x0000, 0x7884, 0x00fe, 0xd0bc,
+	0x0178, 0x2001, 0x0201, 0x200c, 0x81ff, 0x0150, 0x080c, 0x3bc4,
+	0x2d00, 0x9c05, 0x9b05, 0x0120, 0x080c, 0x3af5, 0x0804, 0x3aa2,
+	0x080c, 0x3d2d, 0x080c, 0x3c51, 0x080c, 0x3ba7, 0x080c, 0x3bdc,
+	0x00f6, 0x2079, 0x0100, 0x7824, 0xd0ac, 0x0130, 0x8b58, 0x080c,
+	0x3af5, 0x00fe, 0x0804, 0x3aa2, 0x00fe, 0x080c, 0x3aeb, 0x1150,
+	0x8d68, 0x2001, 0x0032, 0x2602, 0x2001, 0x0033, 0x2502, 0x080c,
+	0x3af5, 0x0080, 0x87ff, 0x0138, 0x2001, 0x0201, 0x2004, 0x9005,
+	0x1908, 0x8739, 0x0038, 0x2001, 0x1a31, 0x2004, 0x9086, 0x0000,
+	0x1904, 0x39f2, 0x2001, 0x032f, 0x2003, 0x00f6, 0x8631, 0x1208,
+	0x8529, 0x2500, 0x9605, 0x0904, 0x3aa2, 0x7884, 0xd0bc, 0x0128,
+	0x2d00, 0x9c05, 0x9b05, 0x1904, 0x3aa2, 0xa013, 0x0019, 0x2001,
+	0x032a, 0x2003, 0x0004, 0x7884, 0xd0ac, 0x1148, 0x2001, 0x1a31,
+	0x2003, 0x0003, 0x2001, 0x032a, 0x2003, 0x0009, 0x0030, 0xa017,
+	0x0001, 0x78b4, 0x9005, 0x0108, 0xa016, 0x2800, 0xa05a, 0x2009,
+	0x0040, 0x080c, 0x20d9, 0x2900, 0xa85a, 0xa813, 0x0019, 0x7884,
+	0xd0a4, 0x1180, 0xa817, 0x0000, 0x00c6, 0x20a9, 0x0004, 0x2061,
+	0x0090, 0x602b, 0x0008, 0x2001, 0x0203, 0x2004, 0x1f04, 0x3a79,
+	0x00ce, 0x0030, 0xa817, 0x0001, 0x78b0, 0x9005, 0x0108, 0xa816,
+	0x00f6, 0x00c6, 0x2079, 0x0100, 0x2061, 0x0090, 0x7827, 0x0002,
+	0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0x601a, 0x0006, 0x2001,
+	0x002b, 0x2004, 0x601e, 0x78c6, 0x000e, 0x78ca, 0x00ce, 0x00fe,
+	0x0804, 0x39ac, 0x001e, 0x00c6, 0x2001, 0x032a, 0x2003, 0x0004,
+	0x2061, 0x0100, 0x6027, 0x0002, 0x6106, 0x2011, 0x020d, 0x2013,
+	0x0020, 0x2001, 0x0004, 0x200c, 0x918c, 0xfffd, 0x2102, 0x080c,
+	0x127c, 0x7884, 0x9084, 0x0003, 0x9086, 0x0002, 0x01a0, 0x2009,
+	0x0028, 0x080c, 0x20d9, 0x2001, 0x0227, 0x200c, 0x2102, 0x6050,
+	0x9084, 0xb7ef, 0x6052, 0x602f, 0x0000, 0x604b, 0xf7f7, 0x6043,
+	0x0090, 0x6043, 0x0010, 0x00ce, 0x2d08, 0x2c10, 0x2b18, 0x2b00,
+	0x9c05, 0x9d05, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x00ae,
+	0x009e, 0x008e, 0x1118, 0x012e, 0x0804, 0x3191, 0x012e, 0x2021,
+	0x400c, 0x0804, 0x3193, 0x9085, 0x0001, 0x1d04, 0x3af4, 0x2091,
+	0x6000, 0x8420, 0x9486, 0x0064, 0x0005, 0x2001, 0x0105, 0x2003,
+	0x0010, 0x2001, 0x032a, 0x2003, 0x0004, 0x2001, 0x1a31, 0x2003,
+	0x0000, 0x0071, 0x2009, 0x0048, 0x080c, 0x20d9, 0x2001, 0x0227,
+	0x2024, 0x2402, 0x2001, 0x0109, 0x2003, 0x4000, 0x9026, 0x0005,
+	0x00f6, 0x00e6, 0x2071, 0x1a34, 0x7000, 0x9086, 0x0000, 0x0520,
+	0x2079, 0x0090, 0x2009, 0x0206, 0x2104, 0x2009, 0x0203, 0x210c,
+	0x9106, 0x1120, 0x2009, 0x0040, 0x080c, 0x20d9, 0x782c, 0xd0fc,
+	0x0d88, 0x080c, 0x3d2d, 0x7000, 0x9086, 0x0000, 0x1d58, 0x782b,
+	0x0004, 0x782c, 0xd0ac, 0x1de8, 0x2009, 0x0040, 0x080c, 0x20d9,
+	0x782b, 0x0002, 0x7003, 0x0000, 0x00ee, 0x00fe, 0x0005, 0x00f6,
+	0x2079, 0x0100, 0x2001, 0x1816, 0x200c, 0x7932, 0x7936, 0x080c,
+	0x251f, 0x7850, 0x9084, 0xfbff, 0x9085, 0x0030, 0x7852, 0x2019,
+	0x01f4, 0x8319, 0x1df0, 0x9084, 0xffcf, 0x9085, 0x2000, 0x7852,
+	0x20a9, 0x0046, 0x1d04, 0x3b5a, 0x2091, 0x6000, 0x1f04, 0x3b5a,
+	0x7850, 0x9085, 0x0400, 0x9084, 0xdfff, 0x7852, 0x2001, 0x0021,
+	0x2004, 0x9084, 0x0003, 0x9086, 0x0001, 0x1120, 0x7850, 0x9084,
+	0xdfff, 0x7852, 0x784b, 0xf7f7, 0x7843, 0x0090, 0x7843, 0x0010,
+	0x20a9, 0x0028, 0xa001, 0x1f04, 0x3b7a, 0x7850, 0x9085, 0x1400,
+	0x7852, 0x2019, 0x61a8, 0x7854, 0xa001, 0xa001, 0xd08c, 0x1110,
+	0x8319, 0x1dc8, 0x7827, 0x0048, 0x7850, 0x9085, 0x0400, 0x7852,
+	0x7843, 0x0040, 0x2019, 0x01f4, 0xa001, 0xa001, 0x8319, 0x1de0,
+	0x2001, 0x0100, 0x080c, 0x2987, 0x7827, 0x0020, 0x7843, 0x0000,
+	0x9006, 0x080c, 0x2987, 0x7827, 0x0048, 0x00fe, 0x0005, 0x7884,
+	0xd0ac, 0x11c8, 0x00f6, 0x00e6, 0x2071, 0x1a31, 0x2079, 0x0320,
+	0x2001, 0x0201, 0x2004, 0x9005, 0x0160, 0x7000, 0x9086, 0x0000,
+	0x1140, 0x0051, 0xd0bc, 0x0108, 0x8738, 0x7003, 0x0003, 0x782b,
+	0x0019, 0x00ee, 0x00fe, 0x0005, 0x00f6, 0x2079, 0x0300, 0x78bc,
+	0x00fe, 0x908c, 0x0070, 0x0178, 0x2009, 0x0032, 0x260a, 0x2009,
+	0x0033, 0x250a, 0xd0b4, 0x0108, 0x8c60, 0xd0ac, 0x0108, 0x8d68,
+	0xd0a4, 0x0108, 0x8b58, 0x0005, 0x00f6, 0x2079, 0x0200, 0x781c,
+	0xd084, 0x0110, 0x7837, 0x0050, 0x00fe, 0x0005, 0x00e6, 0x2071,
+	0x0100, 0x2001, 0x1979, 0x2004, 0x70e2, 0x080c, 0x38d6, 0x1188,
+	0x2001, 0x181e, 0x2004, 0x2009, 0x181d, 0x210c, 0x918c, 0x00ff,
+	0x706e, 0x716a, 0x7066, 0x918d, 0x3200, 0x7162, 0x7073, 0xe109,
+	0x0080, 0x702c, 0x9085, 0x0002, 0x702e, 0x2009, 0x1816, 0x210c,
+	0x716e, 0x7063, 0x0100, 0x7166, 0x719e, 0x706b, 0x0000, 0x7073,
+	0x0809, 0x7077, 0x0008, 0x7078, 0x9080, 0x0100, 0x707a, 0x7080,
+	0x8000, 0x7082, 0x7087, 0xaaaa, 0x9006, 0x708a, 0x708e, 0x707e,
+	0x70d6, 0x70ab, 0x0036, 0x70af, 0x95d5, 0x7014, 0x9084, 0x1984,
+	0x9085, 0x0092, 0x7016, 0x080c, 0x3d2d, 0x00f6, 0x2071, 0x1a31,
+	0x2079, 0x0320, 0x00d6, 0x2069, 0x0000, 0x6884, 0xd0b4, 0x0120,
+	0x689c, 0x780e, 0x6898, 0x780a, 0x00de, 0x2009, 0x03e8, 0x8109,
+	0x1df0, 0x792c, 0xd1fc, 0x0110, 0x782b, 0x0004, 0x2011, 0x0011,
+	0x080c, 0x3cb9, 0x2011, 0x0001, 0x080c, 0x3cb9, 0x00fe, 0x00ee,
+	0x0005, 0x00f6, 0x00e6, 0x2071, 0x1a31, 0x2079, 0x0320, 0x792c,
+	0xd1fc, 0x0904, 0x3cb6, 0x782b, 0x0002, 0x9026, 0xd19c, 0x1904,
+	0x3cb2, 0x7000, 0x0002, 0x3cb6, 0x3c67, 0x3c97, 0x3cb2, 0xd1bc,
+	0x1170, 0xd1dc, 0x1190, 0x8001, 0x7002, 0x2011, 0x0001, 0x080c,
+	0x3cb9, 0x0904, 0x3cb6, 0x080c, 0x3cb9, 0x0804, 0x3cb6, 0x00f6,
+	0x2079, 0x0300, 0x78bf, 0x0000, 0x00fe, 0x7810, 0x7914, 0x782b,
+	0x0004, 0x7812, 0x7916, 0x2001, 0x0201, 0x200c, 0x81ff, 0x0de8,
+	0x080c, 0x3bc4, 0x2009, 0x0001, 0x00f6, 0x2079, 0x0300, 0x78b8,
+	0x00fe, 0xd0ec, 0x0110, 0x2009, 0x0011, 0x792a, 0x00f8, 0x8001,
+	0x7002, 0x9184, 0x0880, 0x1140, 0x782c, 0xd0fc, 0x1904, 0x3c5b,
+	0x2011, 0x0001, 0x00b1, 0x0090, 0xa010, 0x9092, 0x0004, 0x9086,
+	0x0015, 0x1120, 0xa000, 0xa05a, 0x2011, 0x0031, 0xa212, 0xd1dc,
+	0x1960, 0x0828, 0x782b, 0x0004, 0x7003, 0x0000, 0x00ee, 0x00fe,
+	0x0005, 0xa014, 0x9005, 0x0550, 0x8001, 0x0036, 0x0096, 0xa016,
+	0xa058, 0x2048, 0xa010, 0x2009, 0x0031, 0x911a, 0x831c, 0x831c,
+	0x938a, 0x0007, 0x1a0c, 0x0db2, 0x9398, 0x3ce7, 0x231d, 0x083f,
+	0x9080, 0x0004, 0x7a2a, 0x7100, 0x8108, 0x7102, 0x009e, 0x003e,
+	0x908a, 0x0035, 0x1140, 0x0096, 0xa058, 0x2048, 0xa804, 0xa05a,
+	0x2001, 0x0019, 0x009e, 0xa012, 0x9085, 0x0001, 0x0005, 0x3d24,
+	0x3d1b, 0x3d12, 0x3d09, 0x3d00, 0x3cf7, 0x3cee, 0xa964, 0x7902,
+	0xa968, 0x7906, 0xa96c, 0x7912, 0xa970, 0x7916, 0x0005, 0xa974,
+	0x7902, 0xa978, 0x7906, 0xa97c, 0x7912, 0xa980, 0x7916, 0x0005,
+	0xa984, 0x7902, 0xa988, 0x7906, 0xa98c, 0x7912, 0xa990, 0x7916,
+	0x0005, 0xa994, 0x7902, 0xa998, 0x7906, 0xa99c, 0x7912, 0xa9a0,
+	0x7916, 0x0005, 0xa9a4, 0x7902, 0xa9a8, 0x7906, 0xa9ac, 0x7912,
+	0xa9b0, 0x7916, 0x0005, 0xa9b4, 0x7902, 0xa9b8, 0x7906, 0xa9bc,
+	0x7912, 0xa9c0, 0x7916, 0x0005, 0xa9c4, 0x7902, 0xa9c8, 0x7906,
+	0xa9cc, 0x7912, 0xa9d0, 0x7916, 0x0005, 0x00f6, 0x00e6, 0x0086,
+	0x2071, 0x1a34, 0x2079, 0x0090, 0x792c, 0xd1fc, 0x01e8, 0x782b,
+	0x0002, 0x2940, 0x9026, 0x7000, 0x0002, 0x3d54, 0x3d40, 0x3d4b,
+	0x8001, 0x7002, 0xd19c, 0x1180, 0x2011, 0x0001, 0x080c, 0x3cb9,
+	0x190c, 0x3cb9, 0x0048, 0x8001, 0x7002, 0x782c, 0xd0fc, 0x1d38,
+	0x2011, 0x0001, 0x080c, 0x3cb9, 0x008e, 0x00ee, 0x00fe, 0x0005,
+	0x00f6, 0x00e6, 0x00c6, 0x0086, 0x2061, 0x0200, 0x2001, 0x1979,
+	0x2004, 0x601a, 0x2061, 0x0100, 0x2001, 0x1978, 0x2004, 0x60ce,
+	0x6104, 0xc1ac, 0x6106, 0x2001, 0x002c, 0x2004, 0x9005, 0x0520,
+	0x2038, 0x2001, 0x002e, 0x2024, 0x2001, 0x002f, 0x201c, 0x080c,
+	0x4612, 0xa813, 0x0019, 0xaf16, 0x2900, 0xa85a, 0x978a, 0x0007,
+	0x0220, 0x2138, 0x2009, 0x0007, 0x0010, 0x2708, 0x903e, 0x0096,
+	0xa858, 0x2048, 0xa85c, 0x9080, 0x0019, 0x009e, 0x080c, 0x3dd0,
+	0x1d68, 0x2900, 0xa85a, 0x00d0, 0x080c, 0x4612, 0xa813, 0x0019,
+	0xa817, 0x0001, 0x2900, 0xa85a, 0x2001, 0x002e, 0x2004, 0xa866,
+	0x2001, 0x002f, 0x2004, 0xa86a, 0x2001, 0x002a, 0x2004, 0x9084,
+	0xfff8, 0xa86e, 0x2001, 0x002b, 0x2004, 0xa872, 0x2061, 0x0090,
+	0x2079, 0x0100, 0x2001, 0x1978, 0x2004, 0x6036, 0x2009, 0x0040,
+	0x080c, 0x20d9, 0x2001, 0x002a, 0x2004, 0x9084, 0xfff8, 0x601a,
+	0x0006, 0x2001, 0x002b, 0x2004, 0x601e, 0x78c6, 0x000e, 0x78ca,
+	0x9006, 0x600a, 0x600e, 0x008e, 0x00ce, 0x00ee, 0x00fe, 0x0005,
+	0x00e6, 0x2071, 0x0080, 0xaa60, 0x22e8, 0x20a0, 0x20e1, 0x0000,
+	0x2099, 0x0088, 0x702b, 0x0026, 0x7402, 0x7306, 0x9006, 0x700a,
+	0x700e, 0x810b, 0x810b, 0x21a8, 0x810b, 0x7112, 0x702b, 0x0041,
+	0x702c, 0xd0fc, 0x0de8, 0x702b, 0x0002, 0x702b, 0x0040, 0x4005,
+	0x7400, 0x7304, 0x87ff, 0x0190, 0x0086, 0x0096, 0x2940, 0x0086,
+	0x080c, 0x4612, 0x008e, 0xa058, 0x00a6, 0x2050, 0x2900, 0xb006,
+	0xa05a, 0x00ae, 0x009e, 0x008e, 0x9085, 0x0001, 0x00ee, 0x0005,
+	0x00e6, 0x2001, 0x002d, 0x2004, 0x9005, 0x0528, 0x2038, 0x2001,
+	0x0030, 0x2024, 0x2001, 0x0031, 0x201c, 0x080c, 0x4612, 0x2940,
+	0xa813, 0x0019, 0xaf16, 0x2900, 0xa85a, 0x978a, 0x0007, 0x0220,
+	0x2138, 0x2009, 0x0007, 0x0010, 0x2708, 0x903e, 0x0096, 0xa858,
+	0x2048, 0xa85c, 0x9080, 0x0019, 0x009e, 0x080c, 0x3dd0, 0x1d68,
+	0x2900, 0xa85a, 0x00d8, 0x080c, 0x4612, 0x2940, 0xa013, 0x0019,
+	0xa017, 0x0001, 0x2800, 0xa05a, 0x2001, 0x0030, 0x2004, 0xa066,
+	0x2001, 0x0031, 0x2004, 0xa06a, 0x2001, 0x002a, 0x2004, 0x9084,
+	0xfff8, 0xa06e, 0x2001, 0x002b, 0x2004, 0xa072, 0x2001, 0x032a,
+	0x2003, 0x0004, 0x7884, 0xd0ac, 0x1180, 0x2001, 0x0101, 0x200c,
+	0x918d, 0x0200, 0x2102, 0xa017, 0x0000, 0x2001, 0x1a31, 0x2003,
+	0x0003, 0x2001, 0x032a, 0x2003, 0x0009, 0x2001, 0x0300, 0x2003,
+	0x0000, 0x2001, 0x020d, 0x2003, 0x0000, 0x2001, 0x0004, 0x200c,
+	0x918d, 0x0002, 0x2102, 0x00ee, 0x0005, 0x0126, 0x2091, 0x8000,
+	0x20a9, 0x0013, 0x20a1, 0x1840, 0x20e9, 0x0001, 0x9006, 0x4004,
+	0x2009, 0x013c, 0x200a, 0x012e, 0x7880, 0x9086, 0x0052, 0x0108,
+	0x0005, 0x0804, 0x3191, 0x7d98, 0x7c9c, 0x0804, 0x3288, 0x080c,
+	0x6c53, 0x190c, 0x59e6, 0x2069, 0x1853, 0x2d00, 0x2009, 0x0030,
+	0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x2039, 0x0001, 0x080c, 0x465b,
+	0x701f, 0x3ea3, 0x0005, 0x080c, 0x5122, 0x1130, 0x3b00, 0x3a08,
+	0xc194, 0xc095, 0x20d8, 0x21d0, 0x2069, 0x1853, 0x6800, 0x9005,
+	0x0904, 0x31c6, 0x6804, 0xd0ac, 0x0118, 0xd0a4, 0x0904, 0x31c6,
+	0xd094, 0x00c6, 0x2061, 0x0100, 0x6104, 0x0138, 0x6200, 0x9292,
+	0x0005, 0x0218, 0x918c, 0xffdf, 0x0010, 0x918d, 0x0020, 0x6106,
+	0x00ce, 0xd08c, 0x00c6, 0x2061, 0x0100, 0x6104, 0x0118, 0x918d,
+	0x0010, 0x0010, 0x918c, 0xffef, 0x6106, 0x00ce, 0xd084, 0x0158,
+	0x6a28, 0x928a, 0x007f, 0x1a04, 0x31c6, 0x9288, 0x2f92, 0x210d,
+	0x918c, 0x00ff, 0x615e, 0xd0dc, 0x0130, 0x6828, 0x908a, 0x007f,
+	0x1a04, 0x31c6, 0x6056, 0x6888, 0x9084, 0x0030, 0x8004, 0x8004,
+	0x8004, 0x8004, 0x0006, 0x2009, 0x1980, 0x9080, 0x2612, 0x2005,
+	0x200a, 0x000e, 0x2009, 0x1981, 0x9080, 0x2616, 0x2005, 0x200a,
+	0x6808, 0x908a, 0x0100, 0x0a04, 0x31c6, 0x908a, 0x0841, 0x1a04,
+	0x31c6, 0x9084, 0x0007, 0x1904, 0x31c6, 0x680c, 0x9005, 0x0904,
+	0x31c6, 0x6810, 0x9005, 0x0904, 0x31c6, 0x6848, 0x6940, 0x910a,
+	0x1a04, 0x31c6, 0x8001, 0x0904, 0x31c6, 0x684c, 0x6944, 0x910a,
+	0x1a04, 0x31c6, 0x8001, 0x0904, 0x31c6, 0x2009, 0x1950, 0x200b,
+	0x0000, 0x2001, 0x1875, 0x2004, 0xd0c4, 0x0140, 0x7884, 0x200a,
+	0x2009, 0x017f, 0x200a, 0x3b00, 0xc085, 0x20d8, 0x6814, 0x908c,
+	0x00ff, 0x6146, 0x8007, 0x9084, 0x00ff, 0x604a, 0x080c, 0x6f5b,
+	0x080c, 0x62da, 0x080c, 0x630e, 0x6808, 0x602a, 0x080c, 0x204b,
+	0x2009, 0x0170, 0x200b, 0x0080, 0xa001, 0xa001, 0x200b, 0x0000,
+	0x0036, 0x6b08, 0x080c, 0x2579, 0x003e, 0x6000, 0x9086, 0x0000,
+	0x1904, 0x403f, 0x6818, 0x691c, 0x6a20, 0x6b24, 0x8007, 0x810f,
+	0x8217, 0x831f, 0x6016, 0x611a, 0x621e, 0x6322, 0x6c04, 0xd4f4,
+	0x0148, 0x6830, 0x6934, 0x6a38, 0x6b3c, 0x8007, 0x810f, 0x8217,
+	0x831f, 0x0010, 0x9084, 0xf0ff, 0x6006, 0x610a, 0x620e, 0x6312,
+	0x8007, 0x810f, 0x8217, 0x831f, 0x20a9, 0x0004, 0x20a1, 0x1982,
+	0x20e9, 0x0001, 0x4001, 0x20a9, 0x0004, 0x20a1, 0x199c, 0x20e9,
+	0x0001, 0x4001, 0x080c, 0x7d50, 0x00c6, 0x900e, 0x20a9, 0x0001,
+	0x6b70, 0xd384, 0x0510, 0x0068, 0x2009, 0x0100, 0x210c, 0x918e,
+	0x0008, 0x1110, 0x839d, 0x0010, 0x83f5, 0x3e18, 0x12b0, 0x3508,
+	0x8109, 0x080c, 0x74e0, 0x6878, 0x6016, 0x6874, 0x2008, 0x9084,
+	0xff00, 0x8007, 0x600a, 0x9184, 0x00ff, 0x6006, 0x8108, 0x1118,
+	0x6003, 0x0003, 0x0010, 0x6003, 0x0001, 0x1f04, 0x3f94, 0x00ce,
+	0x00c6, 0x2061, 0x196b, 0x6a88, 0x9284, 0xc000, 0x2010, 0x9286,
+	0x0000, 0x1158, 0x2063, 0x0000, 0x2001, 0x0001, 0x080c, 0x2820,
+	0x2001, 0x0001, 0x080c, 0x2803, 0x0088, 0x9286, 0x4000, 0x1148,
+	0x2063, 0x0001, 0x9006, 0x080c, 0x2820, 0x9006, 0x080c, 0x2803,
+	0x0028, 0x9286, 0x8000, 0x1d30, 0x2063, 0x0002, 0x00ce, 0x00e6,
+	0x2c70, 0x080c, 0x0e69, 0x00ee, 0x6888, 0xd0ec, 0x0130, 0x2011,
+	0x0114, 0x2204, 0x9085, 0x0100, 0x2012, 0x6a80, 0x9284, 0x0030,
+	0x9086, 0x0030, 0x1128, 0x9294, 0xffcf, 0x9295, 0x0020, 0x6a82,
+	0x2001, 0x194d, 0x6a80, 0x9294, 0x0030, 0x928e, 0x0000, 0x0170,
+	0x928e, 0x0010, 0x0118, 0x928e, 0x0020, 0x0140, 0x2003, 0xaaaa,
+	0x080c, 0x25ee, 0x2001, 0x193e, 0x2102, 0x0008, 0x2102, 0x00c6,
+	0x2061, 0x0100, 0x602f, 0x0040, 0x602f, 0x0000, 0x00ce, 0x080c,
+	0x6c53, 0x0128, 0x080c, 0x4a2e, 0x0110, 0x080c, 0x253f, 0x60cc,
+	0x9005, 0x01c0, 0x6003, 0x0001, 0x2009, 0x4027, 0x00d0, 0x080c,
+	0x6c53, 0x1168, 0x2011, 0x6ad9, 0x080c, 0x7c4a, 0x2011, 0x6acc,
+	0x080c, 0x7d1b, 0x080c, 0x6f2f, 0x080c, 0x6b8a, 0x0040, 0x080c,
+	0x58e0, 0x0028, 0x6003, 0x0004, 0x2009, 0x403f, 0x0010, 0x0804,
+	0x3191, 0x2001, 0x0170, 0x2004, 0x9084, 0x00ff, 0x9086, 0x004c,
+	0x1118, 0x2091, 0x30bd, 0x0817, 0x2091, 0x303d, 0x0817, 0x6000,
+	0x9086, 0x0000, 0x0904, 0x31c3, 0x2069, 0x1853, 0x7890, 0x6842,
+	0x7894, 0x6846, 0x2d00, 0x2009, 0x0030, 0x7a8c, 0x7b88, 0x7c9c,
+	0x7d98, 0x2039, 0x0001, 0x0804, 0x465e, 0x9006, 0x080c, 0x253f,
+	0x81ff, 0x1904, 0x31c3, 0x080c, 0x6c53, 0x11b0, 0x080c, 0x6f2a,
+	0x080c, 0x5a21, 0x080c, 0x2f86, 0x0118, 0x6130, 0xc18d, 0x6132,
+	0x080c, 0xbcec, 0x0130, 0x080c, 0x6c76, 0x1118, 0x080c, 0x6c2d,
+	0x0038, 0x080c, 0x6b8a, 0x0020, 0x080c, 0x59e6, 0x080c, 0x58e0,
+	0x0804, 0x3191, 0x81ff, 0x1904, 0x31c3, 0x080c, 0x6c53, 0x1110,
+	0x0804, 0x31c3, 0x618c, 0x81ff, 0x01a8, 0x704f, 0x0000, 0x2001,
+	0x1c80, 0x2009, 0x0040, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0126,
+	0x2091, 0x8000, 0x2039, 0x0001, 0x080c, 0x465e, 0x701f, 0x318f,
+	0x012e, 0x0005, 0x704f, 0x0001, 0x00d6, 0x2069, 0x1c80, 0x20a9,
+	0x0040, 0x20e9, 0x0001, 0x20a1, 0x1c80, 0x2019, 0xffff, 0x4304,
+	0x6554, 0x9588, 0x2f92, 0x210d, 0x918c, 0x00ff, 0x216a, 0x900e,
+	0x2011, 0x0002, 0x2100, 0x9506, 0x01a8, 0x080c, 0x5f7e, 0x1190,
+	0xb814, 0x821c, 0x0238, 0x9398, 0x1c80, 0x9085, 0xff00, 0x8007,
+	0x201a, 0x0038, 0x9398, 0x1c80, 0x2324, 0x94a4, 0xff00, 0x9405,
+	0x201a, 0x8210, 0x8108, 0x9182, 0x0080, 0x1208, 0x0c18, 0x8201,
+	0x8007, 0x2d0c, 0x9105, 0x206a, 0x00de, 0x20a9, 0x0040, 0x20a1,
+	0x1c80, 0x2099, 0x1c80, 0x080c, 0x5971, 0x0804, 0x4097, 0x080c,
+	0x4645, 0x0904, 0x31c6, 0x080c, 0x4612, 0x1120, 0x2009, 0x0002,
+	0x0804, 0x31c3, 0x080c, 0x5113, 0xd0b4, 0x0558, 0x7884, 0x908e,
+	0x007e, 0x0538, 0x908e, 0x007f, 0x0520, 0x908e, 0x0080, 0x0508,
+	0x080c, 0x2f81, 0x1148, 0xb800, 0xd08c, 0x11d8, 0xb804, 0x9084,
+	0x00ff, 0x9086, 0x0006, 0x11a8, 0xa867, 0x0000, 0xa868, 0xc0fd,
+	0xa86a, 0x080c, 0xb7bd, 0x1120, 0x2009, 0x0003, 0x0804, 0x31c3,
+	0x7007, 0x0003, 0x701f, 0x4125, 0x0005, 0x080c, 0x4645, 0x0904,
+	0x31c6, 0x20a9, 0x002b, 0xb8b4, 0x20e0, 0xb8b8, 0x2098, 0xa860,
+	0x20e8, 0xa85c, 0x9080, 0x0002, 0x20a0, 0x4003, 0x20a9, 0x0008,
+	0x9080, 0x0006, 0x20a0, 0xb8b4, 0x20e0, 0xb8b8, 0x9080, 0x0006,
+	0x2098, 0x080c, 0x0f52, 0x0070, 0x20a9, 0x0004, 0xa85c, 0x9080,
+	0x000a, 0x20a0, 0xb8b4, 0x20e0, 0xb8b8, 0x9080, 0x000a, 0x2098,
+	0x080c, 0x0f52, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084,
+	0xffc0, 0x9080, 0x0002, 0x2009, 0x002b, 0x7a8c, 0x7b88, 0x7c9c,
+	0x7d98, 0x0804, 0x465e, 0x81ff, 0x1904, 0x31c3, 0x080c, 0x4629,
+	0x0904, 0x31c6, 0x080c, 0x60f0, 0x0904, 0x31c3, 0x0058, 0xa878,
+	0x9005, 0x0120, 0x2009, 0x0004, 0x0804, 0x31c3, 0xa974, 0xaa94,
+	0x0804, 0x3191, 0x080c, 0x511b, 0x0904, 0x3191, 0x701f, 0x416f,
+	0x7007, 0x0003, 0x0005, 0x81ff, 0x1904, 0x31c3, 0x7888, 0x908a,
+	0x1000, 0x1a04, 0x31c6, 0x080c, 0x4645, 0x0904, 0x31c6, 0x080c,
+	0x62a4, 0x0120, 0x080c, 0x62ac, 0x1904, 0x31c6, 0x080c, 0x6175,
+	0x0904, 0x31c3, 0x2019, 0x0004, 0x900e, 0x080c, 0x6102, 0x0904,
+	0x31c3, 0x7984, 0x7a88, 0x04c9, 0x08a8, 0xa89c, 0x908a, 0x1000,
+	0x12f8, 0x080c, 0x4643, 0x01e0, 0x080c, 0x62a4, 0x0118, 0x080c,
+	0x62ac, 0x11b0, 0x080c, 0x6175, 0x2009, 0x0002, 0x0168, 0x2009,
+	0x0002, 0x2019, 0x0004, 0x080c, 0x6102, 0x2009, 0x0003, 0x0120,
+	0xa998, 0xaa9c, 0x00d1, 0x0060, 0xa897, 0x4005, 0xa99a, 0x0010,
+	0xa897, 0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x0005,
+	0xa897, 0x4000, 0x080c, 0x511b, 0x0110, 0x9006, 0x0018, 0x900e,
+	0x9085, 0x0001, 0x2001, 0x0000, 0x0005, 0x9186, 0x00ff, 0x0110,
+	0x0071, 0x0060, 0x2029, 0x007e, 0x2061, 0x1800, 0x6454, 0x2400,
+	0x9506, 0x0110, 0x2508, 0x0019, 0x8529, 0x1ec8, 0x0005, 0x080c,
+	0x5f7e, 0x1138, 0x2200, 0x8003, 0x800b, 0x810b, 0x9108, 0x080c,
+	0x7c58, 0x0005, 0x81ff, 0x1904, 0x31c3, 0x080c, 0x4629, 0x0904,
+	0x31c6, 0x080c, 0x6045, 0x0904, 0x31c3, 0x080c, 0x60f9, 0x0904,
+	0x31c3, 0x0804, 0x417a, 0x81ff, 0x1904, 0x31c3, 0x080c, 0x4629,
+	0x0904, 0x31c6, 0x080c, 0x6045, 0x0904, 0x31c3, 0x080c, 0x60e7,
+	0x0904, 0x31c3, 0x0804, 0x417a, 0x6100, 0x0804, 0x3191, 0x080c,
+	0x4645, 0x0904, 0x31c6, 0x080c, 0x5127, 0x1904, 0x31c3, 0x79a8,
+	0xd184, 0x1158, 0xb834, 0x8007, 0x789e, 0xb830, 0x8007, 0x789a,
+	0xbb2c, 0x831f, 0xba28, 0x8217, 0x0050, 0xb824, 0x8007, 0x789e,
+	0xb820, 0x8007, 0x789a, 0xbb1c, 0x831f, 0xba18, 0x8217, 0xb900,
+	0x918c, 0x0200, 0x0804, 0x3191, 0x78a8, 0x909c, 0x0003, 0xd0b4,
+	0x1140, 0x939a, 0x0003, 0x1a04, 0x31c3, 0x6254, 0x7884, 0x9206,
+	0x1560, 0x2031, 0x1848, 0x2009, 0x013c, 0x2136, 0x2001, 0x1840,
+	0x2009, 0x000c, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x2039, 0x0001,
+	0x0006, 0x78a8, 0x9084, 0x0080, 0x1118, 0x000e, 0x0804, 0x465e,
+	0x000e, 0x2031, 0x0000, 0x2061, 0x18ae, 0x2c44, 0xa66a, 0xa17a,
+	0xa772, 0xa076, 0xa28e, 0xa392, 0xa496, 0xa59a, 0x080c, 0x10b5,
+	0x7007, 0x0002, 0x701f, 0x429d, 0x0005, 0x81ff, 0x1904, 0x31c3,
+	0x080c, 0x4645, 0x0904, 0x31c6, 0x080c, 0x62a4, 0x1904, 0x31c3,
+	0x00c6, 0x080c, 0x4612, 0x00ce, 0x0904, 0x31c3, 0xa867, 0x0000,
+	0xa868, 0xc0fd, 0xa86a, 0x7ea8, 0x080c, 0xb763, 0x0904, 0x31c3,
+	0x7007, 0x0003, 0x701f, 0x42a1, 0x0005, 0x080c, 0x3e75, 0x0804,
+	0x3191, 0xa830, 0x9086, 0x0100, 0x0904, 0x31c3, 0x8906, 0x8006,
+	0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x001b, 0x2009,
+	0x000c, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0804, 0x465e, 0x9006,
+	0x080c, 0x253f, 0x78a8, 0x9084, 0x00ff, 0x9086, 0x00ff, 0x0118,
+	0x81ff, 0x1904, 0x31c3, 0x080c, 0x6c53, 0x0110, 0x080c, 0x59e6,
+	0x7888, 0x908a, 0x1000, 0x1a04, 0x31c6, 0x7984, 0x9186, 0x00ff,
+	0x0138, 0x9182, 0x007f, 0x1a04, 0x31c6, 0x2100, 0x080c, 0x2509,
+	0x0026, 0x00c6, 0x0126, 0x2091, 0x8000, 0x2061, 0x19c9, 0x601b,
+	0x0000, 0x601f, 0x0000, 0x6073, 0x0000, 0x6077, 0x0000, 0x080c,
+	0x6c53, 0x1158, 0x080c, 0x6f2a, 0x080c, 0x5a21, 0x9085, 0x0001,
+	0x080c, 0x6c9a, 0x080c, 0x6b8a, 0x00d0, 0x080c, 0x9947, 0x2061,
+	0x0100, 0x2001, 0x1816, 0x2004, 0x9084, 0x00ff, 0x810f, 0x9105,
+	0x604a, 0x6043, 0x0090, 0x6043, 0x0010, 0x2009, 0x1968, 0x200b,
+	0x0000, 0x2009, 0x002d, 0x2011, 0x590c, 0x080c, 0x7cd9, 0x7984,
+	0x080c, 0x6c53, 0x1110, 0x2009, 0x00ff, 0x7a88, 0x080c, 0x41dd,
+	0x012e, 0x00ce, 0x002e, 0x0804, 0x3191, 0x7984, 0x080c, 0x5f1e,
+	0x2b08, 0x1904, 0x31c6, 0x0804, 0x3191, 0x81ff, 0x0120, 0x2009,
+	0x0001, 0x0804, 0x31c3, 0x60d4, 0xd0ac, 0x1130, 0xd09c, 0x1120,
+	0x2009, 0x0005, 0x0804, 0x31c3, 0x080c, 0x4612, 0x1120, 0x2009,
+	0x0002, 0x0804, 0x31c3, 0x7984, 0x9192, 0x0021, 0x1a04, 0x31c6,
+	0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0xa85c, 0x9080, 0x0019, 0x702a,
+	0xaf60, 0x7736, 0x080c, 0x465b, 0x701f, 0x4355, 0x7880, 0x9086,
+	0x006e, 0x0110, 0x701f, 0x4be0, 0x0005, 0x2009, 0x0080, 0x080c,
+	0x5f7e, 0x1118, 0x080c, 0x62a4, 0x0120, 0x2021, 0x400a, 0x0804,
+	0x3193, 0x00d6, 0x0096, 0xa964, 0xaa6c, 0xab70, 0xac74, 0xad78,
+	0xae7c, 0xa884, 0x90be, 0x0100, 0x0904, 0x43ee, 0x90be, 0x0112,
+	0x0904, 0x43ee, 0x90be, 0x0113, 0x0904, 0x43ee, 0x90be, 0x0114,
+	0x0904, 0x43ee, 0x90be, 0x0117, 0x0904, 0x43ee, 0x90be, 0x011a,
+	0x0904, 0x43ee, 0x90be, 0x011c, 0x0904, 0x43ee, 0x90be, 0x0121,
+	0x0904, 0x43d5, 0x90be, 0x0131, 0x0904, 0x43d5, 0x90be, 0x0171,
+	0x0904, 0x43ee, 0x90be, 0x0173, 0x0904, 0x43ee, 0x90be, 0x01a1,
+	0x1128, 0xa894, 0x8007, 0xa896, 0x0804, 0x43f9, 0x90be, 0x0212,
+	0x0904, 0x43e2, 0x90be, 0x0213, 0x05e8, 0x90be, 0x0214, 0x0500,
+	0x90be, 0x0217, 0x0188, 0x90be, 0x021a, 0x1120, 0xa89c, 0x8007,
+	0xa89e, 0x04e0, 0x90be, 0x021f, 0x05c8, 0x90be, 0x0300, 0x05b0,
+	0x009e, 0x00de, 0x0804, 0x31c6, 0x7028, 0x9080, 0x0010, 0x2098,
+	0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0007, 0x080c, 0x4437,
+	0x7028, 0x9080, 0x000e, 0x2098, 0x20a0, 0x7034, 0x20e0, 0x20e8,
+	0x20a9, 0x0001, 0x080c, 0x4437, 0x00c8, 0x7028, 0x9080, 0x000c,
+	0x2098, 0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0001, 0x080c,
+	0x4444, 0x00b8, 0x7028, 0x9080, 0x000e, 0x2098, 0x20a0, 0x7034,
+	0x20e0, 0x20e8, 0x20a9, 0x0001, 0x080c, 0x4444, 0x7028, 0x9080,
+	0x000c, 0x2098, 0x20a0, 0x7034, 0x20e0, 0x20e8, 0x20a9, 0x0001,
+	0x04f1, 0x00c6, 0x080c, 0x4612, 0x0550, 0xa868, 0xc0fd, 0xa86a,
+	0xa867, 0x0119, 0x9006, 0xa882, 0xa87f, 0x0020, 0xa88b, 0x0001,
+	0x810b, 0xa9ae, 0xa8b2, 0xaab6, 0xabba, 0xacbe, 0xadc2, 0xa9c6,
+	0xa8ca, 0x00ce, 0x009e, 0x00de, 0xa866, 0xa822, 0xa868, 0xc0fd,
+	0xa86a, 0xa804, 0x2048, 0x080c, 0xb77e, 0x1120, 0x2009, 0x0003,
+	0x0804, 0x31c3, 0x7007, 0x0003, 0x701f, 0x442e, 0x0005, 0x00ce,
+	0x009e, 0x00de, 0x2009, 0x0002, 0x0804, 0x31c3, 0xa820, 0x9086,
+	0x8001, 0x1904, 0x3191, 0x2009, 0x0004, 0x0804, 0x31c3, 0x0016,
+	0x0026, 0x3510, 0x20a9, 0x0002, 0x4002, 0x4104, 0x4004, 0x8211,
+	0x1dc8, 0x002e, 0x001e, 0x0005, 0x0016, 0x0026, 0x0036, 0x0046,
+	0x3520, 0x20a9, 0x0004, 0x4002, 0x4304, 0x4204, 0x4104, 0x4004,
+	0x8421, 0x1db8, 0x004e, 0x003e, 0x002e, 0x001e, 0x0005, 0x81ff,
+	0x0120, 0x2009, 0x0001, 0x0804, 0x31c3, 0x60d4, 0xd0ac, 0x1130,
+	0xd09c, 0x1120, 0x2009, 0x0005, 0x0804, 0x31c3, 0x7984, 0x78a8,
+	0x2040, 0x080c, 0x9940, 0x1120, 0x9182, 0x007f, 0x0a04, 0x31c6,
+	0x9186, 0x00ff, 0x0904, 0x31c6, 0x9182, 0x0800, 0x1a04, 0x31c6,
+	0x7a8c, 0x7b88, 0x6074, 0x9306, 0x1140, 0x6078, 0x924e, 0x0904,
+	0x31c6, 0x99cc, 0xff00, 0x0904, 0x31c6, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x452c, 0x0560, 0x90c6, 0x4000, 0x1170, 0x00c6, 0x0006,
+	0x900e, 0x080c, 0x619e, 0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108,
+	0xc18d, 0x000e, 0x00ce, 0x00b8, 0x90c6, 0x4007, 0x1110, 0x2408,
+	0x0090, 0x90c6, 0x4008, 0x1118, 0x2708, 0x2610, 0x0060, 0x90c6,
+	0x4009, 0x1108, 0x0040, 0x90c6, 0x4006, 0x1108, 0x0020, 0x2001,
+	0x4005, 0x2009, 0x000a, 0x2020, 0x012e, 0x0804, 0x3193, 0x2b00,
+	0x7026, 0x0016, 0x00b6, 0x00c6, 0x00e6, 0x2c70, 0x080c, 0x9a23,
+	0x0904, 0x4501, 0x2b00, 0x6012, 0x080c, 0xba69, 0x2e58, 0x00ee,
+	0x00e6, 0x00c6, 0x080c, 0x4612, 0x00ce, 0x2b70, 0x1158, 0x080c,
+	0x99d6, 0x00ee, 0x00ce, 0x00be, 0x001e, 0x012e, 0x2009, 0x0002,
+	0x0804, 0x31c3, 0x900e, 0xa966, 0xa96a, 0x2900, 0x6016, 0xa932,
+	0xa868, 0xc0fd, 0xd88c, 0x0108, 0xc0f5, 0xa86a, 0x080c, 0x2e30,
+	0x6023, 0x0001, 0x9006, 0x080c, 0x5ebb, 0x2001, 0x0002, 0x080c,
+	0x5ecf, 0x2009, 0x0002, 0x080c, 0x9a50, 0x78a8, 0xd094, 0x0138,
+	0x00ee, 0x7024, 0x00e6, 0x2058, 0xb8bc, 0xc08d, 0xb8be, 0x9085,
+	0x0001, 0x00ee, 0x00ce, 0x00be, 0x001e, 0x012e, 0x1120, 0x2009,
+	0x0003, 0x0804, 0x31c3, 0x7007, 0x0003, 0x701f, 0x4510, 0x0005,
+	0xa830, 0x9086, 0x0100, 0x7024, 0x2058, 0x1138, 0x2009, 0x0004,
+	0xba04, 0x9294, 0x00ff, 0x0804, 0x5070, 0x900e, 0xa868, 0xd0f4,
+	0x1904, 0x3191, 0x080c, 0x619e, 0x1108, 0xc185, 0xb800, 0xd0bc,
+	0x0108, 0xc18d, 0x0804, 0x3191, 0x00e6, 0x00d6, 0x0096, 0x83ff,
+	0x0904, 0x4574, 0x902e, 0x080c, 0x9940, 0x0130, 0x9026, 0x20a9,
+	0x0800, 0x2071, 0x1000, 0x0030, 0x2021, 0x007f, 0x20a9, 0x0781,
+	0x2071, 0x107f, 0x2e04, 0x9005, 0x11b0, 0x2100, 0x9406, 0x15e8,
+	0x2428, 0x94ce, 0x007f, 0x1120, 0x92ce, 0xfffd, 0x1528, 0x0030,
+	0x94ce, 0x0080, 0x1130, 0x92ce, 0xfffc, 0x11f0, 0x93ce, 0x00ff,
+	0x11d8, 0xc5fd, 0x0450, 0x2058, 0xbf10, 0x2700, 0x9306, 0x11b8,
+	0xbe14, 0x2600, 0x9206, 0x1198, 0x2400, 0x9106, 0x1150, 0xd884,
+	0x0568, 0xd894, 0x1558, 0x080c, 0x62a4, 0x1540, 0x2001, 0x4000,
+	0x0430, 0x2001, 0x4007, 0x0418, 0x2001, 0x4006, 0x0400, 0x2400,
+	0x9106, 0x1158, 0xbe14, 0x87ff, 0x1128, 0x86ff, 0x0948, 0x080c,
+	0x9940, 0x1930, 0x2001, 0x4008, 0x0090, 0x8420, 0x8e70, 0x1f04,
+	0x4542, 0x85ff, 0x1130, 0x2001, 0x4009, 0x0048, 0x2001, 0x0001,
+	0x0030, 0x080c, 0x5f1e, 0x1dd0, 0xbb12, 0xba16, 0x9006, 0x9005,
+	0x009e, 0x00de, 0x00ee, 0x0005, 0x81ff, 0x0120, 0x2009, 0x0001,
+	0x0804, 0x31c3, 0x080c, 0x4612, 0x1120, 0x2009, 0x0002, 0x0804,
+	0x31c3, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x7884, 0x9005,
+	0x0904, 0x31c6, 0x9096, 0x00ff, 0x0120, 0x9092, 0x0004, 0x1a04,
+	0x31c6, 0x2010, 0x2918, 0x080c, 0x2dd6, 0x1120, 0x2009, 0x0003,
+	0x0804, 0x31c3, 0x7007, 0x0003, 0x701f, 0x45c7, 0x0005, 0xa830,
+	0x9086, 0x0100, 0x1904, 0x3191, 0x2009, 0x0004, 0x0804, 0x31c3,
+	0x7984, 0x080c, 0x9940, 0x1120, 0x9182, 0x007f, 0x0a04, 0x31c6,
+	0x9186, 0x00ff, 0x0904, 0x31c6, 0x9182, 0x0800, 0x1a04, 0x31c6,
+	0x2001, 0x9000, 0x080c, 0x50cb, 0x1904, 0x31c3, 0x0804, 0x3191,
+	0xa998, 0x080c, 0x9940, 0x1118, 0x9182, 0x007f, 0x0280, 0x9186,
+	0x00ff, 0x0168, 0x9182, 0x0800, 0x1250, 0x2001, 0x9000, 0x080c,
+	0x50cb, 0x11a8, 0x0060, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897,
+	0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x0005, 0xa897,
+	0x4000, 0x900e, 0x9085, 0x0001, 0x2001, 0x0000, 0x0005, 0x2009,
+	0x000a, 0x0c48, 0x080c, 0x0fd5, 0x0198, 0x9006, 0xa802, 0x7014,
+	0x9005, 0x1120, 0x2900, 0x7016, 0x701a, 0x0040, 0x7018, 0xa802,
+	0x0086, 0x2040, 0x2900, 0xa006, 0x701a, 0x008e, 0x9085, 0x0001,
+	0x0005, 0x7984, 0x080c, 0x5f7e, 0x1130, 0x7e88, 0x9684, 0x3fff,
+	0x9082, 0x4000, 0x0208, 0x905e, 0x8bff, 0x0005, 0xa998, 0x080c,
+	0x5f7e, 0x1130, 0xae9c, 0x9684, 0x3fff, 0x9082, 0x4000, 0x0208,
+	0x905e, 0x8bff, 0x0005, 0xae98, 0x0008, 0x7e84, 0x2608, 0x080c,
+	0x5f7e, 0x1108, 0x0008, 0x905e, 0x8bff, 0x0005, 0x0016, 0x7114,
+	0x81ff, 0x0128, 0x2148, 0xa904, 0x080c, 0x1007, 0x0cc8, 0x7116,
+	0x711a, 0x001e, 0x0005, 0x2031, 0x0001, 0x0010, 0x2031, 0x0000,
+	0x2061, 0x18ae, 0x2c44, 0xa66a, 0xa17a, 0xa772, 0xa076, 0xa28e,
+	0xa392, 0xa496, 0xa59a, 0x080c, 0x10b5, 0x7007, 0x0002, 0x701f,
+	0x3191, 0x0005, 0x00f6, 0x0126, 0x2091, 0x8000, 0x2079, 0x0000,
+	0x2001, 0x18a6, 0x2004, 0x9005, 0x1190, 0x0e04, 0x468f, 0x7a36,
+	0x7833, 0x0012, 0x7a82, 0x7b86, 0x7c8a, 0x2091, 0x4080, 0x2001,
+	0x0089, 0x2004, 0xd084, 0x190c, 0x1167, 0x0804, 0x46f5, 0x0016,
+	0x0086, 0x0096, 0x00c6, 0x00e6, 0x2071, 0x1894, 0x7044, 0x9005,
+	0x1540, 0x7148, 0x9182, 0x0010, 0x0288, 0x7038, 0x2060, 0x080c,
+	0x0fd5, 0x0904, 0x46ed, 0xa84b, 0x0000, 0x2900, 0x7046, 0x2001,
+	0x0002, 0x9080, 0x1da2, 0x2005, 0xa846, 0x0098, 0x7038, 0x90e0,
+	0x0004, 0x2001, 0x18b0, 0x9c82, 0x18f0, 0x0210, 0x2061, 0x18b0,
+	0x2c00, 0x703a, 0x7148, 0x81ff, 0x1108, 0x703e, 0x8108, 0x714a,
+	0x0460, 0x7148, 0x8108, 0x714a, 0x7044, 0x2040, 0xa144, 0x2105,
+	0x0016, 0x908a, 0x0036, 0x1a0c, 0x0db2, 0x2060, 0x001e, 0x8108,
+	0x2105, 0x9005, 0xa146, 0x1520, 0x080c, 0x0fd5, 0x1130, 0x8109,
+	0xa946, 0x7148, 0x8109, 0x714a, 0x00d8, 0x9006, 0xa806, 0xa84a,
+	0xa046, 0x2800, 0xa802, 0x2900, 0xa006, 0x7046, 0x2001, 0x0002,
+	0x9080, 0x1da2, 0x2005, 0xa846, 0x0058, 0x2262, 0x6306, 0x640a,
+	0x00ee, 0x00ce, 0x009e, 0x008e, 0x001e, 0x012e, 0x00fe, 0x0005,
+	0x2c00, 0x9082, 0x001b, 0x0002, 0x4717, 0x4717, 0x4719, 0x4717,
+	0x4717, 0x4717, 0x471d, 0x4717, 0x4717, 0x4717, 0x4721, 0x4717,
+	0x4717, 0x4717, 0x4725, 0x4717, 0x4717, 0x4717, 0x4729, 0x4717,
+	0x4717, 0x4717, 0x472d, 0x4717, 0x4717, 0x4717, 0x4732, 0x080c,
+	0x0db2, 0xa276, 0xa37a, 0xa47e, 0x0898, 0xa286, 0xa38a, 0xa48e,
+	0x0878, 0xa296, 0xa39a, 0xa49e, 0x0858, 0xa2a6, 0xa3aa, 0xa4ae,
+	0x0838, 0xa2b6, 0xa3ba, 0xa4be, 0x0818, 0xa2c6, 0xa3ca, 0xa4ce,
+	0x0804, 0x46f0, 0xa2d6, 0xa3da, 0xa4de, 0x0804, 0x46f0, 0x00e6,
+	0x2071, 0x1894, 0x7048, 0x9005, 0x0904, 0x47c9, 0x0126, 0x2091,
+	0x8000, 0x0e04, 0x47c8, 0x00f6, 0x2079, 0x0000, 0x00c6, 0x0096,
+	0x0086, 0x0076, 0x9006, 0x2038, 0x7040, 0x2048, 0x9005, 0x0500,
+	0xa948, 0x2105, 0x0016, 0x908a, 0x0036, 0x1a0c, 0x0db2, 0x2060,
+	0x001e, 0x8108, 0x2105, 0x9005, 0xa94a, 0x1904, 0x47cb, 0xa804,
+	0x9005, 0x090c, 0x0db2, 0x7042, 0x2938, 0x2040, 0xa003, 0x0000,
+	0x2001, 0x0002, 0x9080, 0x1da2, 0x2005, 0xa04a, 0x0804, 0x47cb,
+	0x703c, 0x2060, 0x2c14, 0x6304, 0x6408, 0x650c, 0x2200, 0x7836,
+	0x7833, 0x0012, 0x7882, 0x2300, 0x7886, 0x2400, 0x788a, 0x2091,
+	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x1167, 0x87ff,
+	0x0118, 0x2748, 0x080c, 0x1007, 0x7048, 0x8001, 0x704a, 0x9005,
+	0x1170, 0x7040, 0x2048, 0x9005, 0x0128, 0x080c, 0x1007, 0x9006,
+	0x7042, 0x7046, 0x703b, 0x18b0, 0x703f, 0x18b0, 0x0420, 0x7040,
+	0x9005, 0x1508, 0x7238, 0x2c00, 0x9206, 0x0148, 0x9c80, 0x0004,
+	0x90fa, 0x18f0, 0x0210, 0x2001, 0x18b0, 0x703e, 0x00a0, 0x9006,
+	0x703e, 0x703a, 0x7044, 0x9005, 0x090c, 0x0db2, 0x2048, 0xa800,
+	0x9005, 0x1de0, 0x2900, 0x7042, 0x2001, 0x0002, 0x9080, 0x1da2,
+	0x2005, 0xa84a, 0x0000, 0x007e, 0x008e, 0x009e, 0x00ce, 0x00fe,
+	0x012e, 0x00ee, 0x0005, 0x2c00, 0x9082, 0x001b, 0x0002, 0x47ea,
+	0x47ea, 0x47ec, 0x47ea, 0x47ea, 0x47ea, 0x47f1, 0x47ea, 0x47ea,
+	0x47ea, 0x47f6, 0x47ea, 0x47ea, 0x47ea, 0x47fb, 0x47ea, 0x47ea,
+	0x47ea, 0x4800, 0x47ea, 0x47ea, 0x47ea, 0x4805, 0x47ea, 0x47ea,
+	0x47ea, 0x480a, 0x080c, 0x0db2, 0xaa74, 0xab78, 0xac7c, 0x0804,
+	0x4776, 0xaa84, 0xab88, 0xac8c, 0x0804, 0x4776, 0xaa94, 0xab98,
+	0xac9c, 0x0804, 0x4776, 0xaaa4, 0xaba8, 0xacac, 0x0804, 0x4776,
+	0xaab4, 0xabb8, 0xacbc, 0x0804, 0x4776, 0xaac4, 0xabc8, 0xaccc,
+	0x0804, 0x4776, 0xaad4, 0xabd8, 0xacdc, 0x0804, 0x4776, 0x0016,
+	0x0026, 0x0036, 0x00b6, 0x00c6, 0x2009, 0x007e, 0x080c, 0x5f7e,
+	0x2019, 0x0001, 0xb85c, 0xd0ac, 0x0110, 0x2019, 0x0000, 0x2011,
+	0x801b, 0x080c, 0x4672, 0x00ce, 0x00be, 0x003e, 0x002e, 0x001e,
+	0x0005, 0x0026, 0x080c, 0x5113, 0xd0c4, 0x0120, 0x2011, 0x8014,
+	0x080c, 0x4672, 0x002e, 0x0005, 0x81ff, 0x1904, 0x31c3, 0x0126,
+	0x2091, 0x8000, 0x6030, 0xc08d, 0xc085, 0xc0ac, 0x6032, 0x080c,
+	0x6c53, 0x1158, 0x080c, 0x6f2a, 0x080c, 0x5a21, 0x9085, 0x0001,
+	0x080c, 0x6c9a, 0x080c, 0x6b8a, 0x0010, 0x080c, 0x58e0, 0x012e,
+	0x0804, 0x3191, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x31c3,
+	0x080c, 0x5127, 0x0120, 0x2009, 0x0007, 0x0804, 0x31c3, 0x080c,
+	0x629c, 0x0120, 0x2009, 0x0008, 0x0804, 0x31c3, 0x080c, 0x2f81,
+	0x0128, 0x7984, 0x080c, 0x5f1e, 0x1904, 0x31c6, 0x080c, 0x4645,
+	0x0904, 0x31c6, 0x2b00, 0x7026, 0x080c, 0x62a4, 0x7888, 0x1170,
+	0x9084, 0x0005, 0x1158, 0x900e, 0x080c, 0x619e, 0x1108, 0xc185,
+	0xb800, 0xd0bc, 0x0108, 0xc18d, 0x0804, 0x3191, 0x080c, 0x4612,
+	0x0904, 0x31c3, 0x9006, 0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a,
+	0x080c, 0xb817, 0x0904, 0x31c3, 0x7888, 0xd094, 0x0118, 0xb8bc,
+	0xc08d, 0xb8be, 0x7007, 0x0003, 0x701f, 0x48eb, 0x0005, 0x2061,
+	0x1800, 0x080c, 0x5127, 0x2009, 0x0007, 0x1578, 0x080c, 0x629c,
+	0x0118, 0x2009, 0x0008, 0x0448, 0x080c, 0x2f81, 0x0120, 0xa998,
+	0x080c, 0x5f1e, 0x1530, 0x080c, 0x4643, 0x0518, 0x080c, 0x62a4,
+	0xa89c, 0x1168, 0x9084, 0x0005, 0x1150, 0x900e, 0x080c, 0x619e,
+	0x1108, 0xc185, 0xb800, 0xd0bc, 0x0108, 0xc18d, 0x00d0, 0xa868,
+	0xc0fc, 0xa86a, 0x080c, 0xb817, 0x11e0, 0xa89c, 0xd094, 0x0118,
+	0xb8bc, 0xc08d, 0xb8be, 0x2009, 0x0003, 0xa897, 0x4005, 0xa99a,
+	0x0010, 0xa897, 0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030,
+	0x0005, 0xa897, 0x4000, 0xa99a, 0x9006, 0x918d, 0x0001, 0x2008,
+	0x0005, 0x9006, 0x0005, 0xa830, 0x9086, 0x0100, 0x7024, 0x2058,
+	0x1110, 0x0804, 0x5070, 0x900e, 0x080c, 0x619e, 0x1108, 0xc185,
+	0xb800, 0xd0bc, 0x0108, 0xc18d, 0x0804, 0x3191, 0x080c, 0x5127,
+	0x0120, 0x2009, 0x0007, 0x0804, 0x31c3, 0x7f84, 0x7a8c, 0x7b88,
+	0x7c9c, 0x7d98, 0x080c, 0x4612, 0x1120, 0x2009, 0x0002, 0x0804,
+	0x31c3, 0x900e, 0x2130, 0x7126, 0x7132, 0xa860, 0x20e8, 0x7036,
+	0xa85c, 0x9080, 0x0005, 0x702a, 0x20a0, 0x080c, 0x5f7e, 0x1904,
+	0x4981, 0x080c, 0x62a4, 0x0120, 0x080c, 0x62ac, 0x1904, 0x4981,
+	0x080c, 0x629c, 0x1130, 0x080c, 0x619e, 0x1118, 0xd79c, 0x0904,
+	0x4981, 0xd794, 0x1110, 0xd784, 0x01a8, 0xb8b4, 0x20e0, 0xb8b8,
+	0x9080, 0x0006, 0x2098, 0x3400, 0xd794, 0x0160, 0x20a9, 0x0008,
+	0x4003, 0x2098, 0x20a0, 0x3d00, 0x20e0, 0x20a9, 0x0002, 0x080c,
+	0x4444, 0x0048, 0x20a9, 0x0004, 0x4003, 0x2098, 0x20a0, 0x3d00,
+	0x20e0, 0x080c, 0x4444, 0x4104, 0xd794, 0x0528, 0xb8b4, 0x20e0,
+	0xb8b8, 0x2060, 0x9c80, 0x0000, 0x2098, 0x20a9, 0x0002, 0x4003,
+	0x9c80, 0x0003, 0x2098, 0x20a9, 0x0001, 0x4005, 0x9c80, 0x0004,
+	0x2098, 0x3400, 0x20a9, 0x0002, 0x4003, 0x2098, 0x20a0, 0x3d00,
+	0x20e0, 0x080c, 0x4437, 0x9c80, 0x0026, 0x2098, 0xb8b4, 0x20e0,
+	0x20a9, 0x0002, 0x4003, 0xd794, 0x0110, 0x96b0, 0x000b, 0x96b0,
+	0x0005, 0x8108, 0x080c, 0x9940, 0x0118, 0x9186, 0x0800, 0x0040,
+	0xd78c, 0x0120, 0x9186, 0x0800, 0x0170, 0x0018, 0x9186, 0x007e,
+	0x0150, 0xd794, 0x0118, 0x9686, 0x0020, 0x0010, 0x9686, 0x0028,
+	0x0150, 0x0804, 0x491d, 0x86ff, 0x1120, 0x7124, 0x810b, 0x0804,
+	0x3191, 0x7033, 0x0001, 0x7122, 0x7024, 0x9600, 0x7026, 0x772e,
+	0x2061, 0x18ae, 0x2c44, 0xa06b, 0x0000, 0xa67a, 0x7034, 0xa072,
+	0x7028, 0xa076, 0xa28e, 0xa392, 0xa496, 0xa59a, 0x080c, 0x10b5,
+	0x7007, 0x0002, 0x701f, 0x49bd, 0x0005, 0x7030, 0x9005, 0x1180,
+	0x7120, 0x7028, 0x20a0, 0x772c, 0x9036, 0x7034, 0x20e8, 0x2061,
+	0x18ae, 0x2c44, 0xa28c, 0xa390, 0xa494, 0xa598, 0x0804, 0x491d,
+	0x7124, 0x810b, 0x0804, 0x3191, 0x2029, 0x007e, 0x7984, 0x7a88,
+	0x7b8c, 0x7c98, 0x9184, 0xff00, 0x8007, 0x90e2, 0x0020, 0x0a04,
+	0x31c6, 0x9502, 0x0a04, 0x31c6, 0x9184, 0x00ff, 0x90e2, 0x0020,
+	0x0a04, 0x31c6, 0x9502, 0x0a04, 0x31c6, 0x9284, 0xff00, 0x8007,
+	0x90e2, 0x0020, 0x0a04, 0x31c6, 0x9502, 0x0a04, 0x31c6, 0x9284,
+	0x00ff, 0x90e2, 0x0020, 0x0a04, 0x31c6, 0x9502, 0x0a04, 0x31c6,
+	0x9384, 0xff00, 0x8007, 0x90e2, 0x0020, 0x0a04, 0x31c6, 0x9502,
+	0x0a04, 0x31c6, 0x9384, 0x00ff, 0x90e2, 0x0020, 0x0a04, 0x31c6,
+	0x9502, 0x0a04, 0x31c6, 0x9484, 0xff00, 0x8007, 0x90e2, 0x0020,
+	0x0a04, 0x31c6, 0x9502, 0x0a04, 0x31c6, 0x9484, 0x00ff, 0x90e2,
+	0x0020, 0x0a04, 0x31c6, 0x9502, 0x0a04, 0x31c6, 0x2061, 0x1958,
+	0x6102, 0x6206, 0x630a, 0x640e, 0x0804, 0x3191, 0x0006, 0x080c,
+	0x5113, 0xd0cc, 0x000e, 0x0005, 0x0006, 0x080c, 0x5117, 0xd0bc,
+	0x000e, 0x0005, 0x616c, 0x7a84, 0x6300, 0x82ff, 0x1118, 0x7986,
+	0x0804, 0x3191, 0x83ff, 0x1904, 0x31c6, 0x2001, 0xfff0, 0x9200,
+	0x1a04, 0x31c6, 0x2019, 0xffff, 0x6070, 0x9302, 0x9200, 0x0a04,
+	0x31c6, 0x7986, 0x626e, 0x0804, 0x3191, 0x080c, 0x5127, 0x1904,
+	0x31c3, 0x7c88, 0x7d84, 0x7e98, 0x7f8c, 0x080c, 0x4612, 0x0904,
+	0x31c3, 0x900e, 0x901e, 0x7326, 0x7332, 0xa860, 0x20e8, 0x7036,
+	0xa85c, 0x9080, 0x0003, 0x702a, 0x20a0, 0x91d8, 0x1000, 0x2b5c,
+	0x8bff, 0x0178, 0x080c, 0x62a4, 0x0118, 0x080c, 0x62ac, 0x1148,
+	0x20a9, 0x0001, 0xb814, 0x4004, 0xb810, 0x4004, 0x4104, 0x9398,
+	0x0003, 0x8108, 0x9182, 0x0800, 0x0120, 0x9386, 0x003c, 0x0170,
+	0x0c20, 0x83ff, 0x1148, 0x7224, 0x900e, 0x2001, 0x0003, 0x080c,
+	0x7e7f, 0x2208, 0x0804, 0x3191, 0x7033, 0x0001, 0x7122, 0x7024,
+	0x9300, 0x7026, 0x2061, 0x18ae, 0x2c44, 0xa06b, 0x0000, 0xa37a,
+	0x7028, 0xa076, 0x7034, 0xa072, 0xa48e, 0xa592, 0xa696, 0xa79a,
+	0x080c, 0x10b5, 0x7007, 0x0002, 0x701f, 0x4aaf, 0x0005, 0x7030,
+	0x9005, 0x1178, 0x7120, 0x7028, 0x20a0, 0x901e, 0x7034, 0x20e8,
+	0x2061, 0x18ae, 0x2c44, 0xa48c, 0xa590, 0xa694, 0xa798, 0x0804,
+	0x4a6d, 0x7224, 0x900e, 0x2001, 0x0003, 0x080c, 0x7e7f, 0x2208,
+	0x0804, 0x3191, 0x00f6, 0x00e6, 0x080c, 0x5127, 0x2009, 0x0007,
+	0x1904, 0x4b42, 0x2071, 0x1894, 0x745c, 0x84ff, 0x2009, 0x000e,
+	0x1904, 0x4b42, 0xac9c, 0xad98, 0xaea4, 0xafa0, 0x0096, 0x080c,
+	0x0fee, 0x2009, 0x0002, 0x0904, 0x4b42, 0x2900, 0x705e, 0x900e,
+	0x901e, 0x7356, 0x7362, 0xa860, 0x7066, 0xa85c, 0x9080, 0x0003,
+	0x705a, 0x20a0, 0x91d8, 0x1000, 0x2b5c, 0x8bff, 0x0178, 0x080c,
+	0x62a4, 0x0118, 0x080c, 0x62ac, 0x1148, 0xb814, 0x20a9, 0x0001,
+	0x4004, 0xb810, 0x4004, 0x4104, 0x9398, 0x0003, 0x8108, 0x9182,
+	0x0800, 0x0120, 0x9386, 0x003c, 0x01e8, 0x0c20, 0x83ff, 0x11c0,
+	0x7254, 0x900e, 0x2001, 0x0003, 0x080c, 0x7e7f, 0x2208, 0x009e,
+	0xa897, 0x4000, 0xa99a, 0x715c, 0x81ff, 0x090c, 0x0db2, 0x2148,
+	0x080c, 0x1007, 0x9006, 0x705e, 0x918d, 0x0001, 0x2008, 0x0418,
+	0x7063, 0x0001, 0x7152, 0x7054, 0x9300, 0x7056, 0x2061, 0x18af,
+	0x2c44, 0xa37a, 0x7058, 0xa076, 0x7064, 0xa072, 0xa48e, 0xa592,
+	0xa696, 0xa79a, 0xa09f, 0x4b4e, 0x000e, 0xa0a2, 0x080c, 0x10b5,
+	0x9006, 0x0048, 0x009e, 0xa897, 0x4005, 0xa99a, 0x900e, 0x9085,
+	0x0001, 0x2001, 0x0030, 0x00ee, 0x00fe, 0x0005, 0x00f6, 0xa0a0,
+	0x904d, 0x090c, 0x0db2, 0x00e6, 0x2071, 0x1894, 0xa06c, 0x908e,
+	0x0100, 0x0138, 0xa87b, 0x0030, 0xa883, 0x0000, 0xa897, 0x4002,
+	0x00d8, 0x7060, 0x9005, 0x1158, 0x7150, 0x7058, 0x20a0, 0x901e,
+	0x7064, 0x20e8, 0xa48c, 0xa590, 0xa694, 0xa798, 0x0428, 0xa87b,
+	0x0000, 0xa883, 0x0000, 0xa897, 0x4000, 0x7254, 0x900e, 0x2001,
+	0x0003, 0x080c, 0x7e7f, 0xaa9a, 0x715c, 0x81ff, 0x090c, 0x0db2,
+	0x2148, 0x080c, 0x1007, 0x705f, 0x0000, 0xa0a0, 0x2048, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x6536, 0x012e, 0xa09f, 0x0000, 0xa0a3,
+	0x0000, 0x00ee, 0x00fe, 0x0005, 0x91d8, 0x1000, 0x2b5c, 0x8bff,
+	0x0178, 0x080c, 0x62a4, 0x0118, 0x080c, 0x62ac, 0x1148, 0xb814,
+	0x20a9, 0x0001, 0x4004, 0xb810, 0x4004, 0x4104, 0x9398, 0x0003,
+	0x8108, 0x9182, 0x0800, 0x0120, 0x9386, 0x003c, 0x0518, 0x0c20,
+	0x83ff, 0x11f0, 0x7154, 0x810c, 0xa99a, 0xa897, 0x4000, 0x715c,
+	0x81ff, 0x090c, 0x0db2, 0x2148, 0x080c, 0x1007, 0x9006, 0x705e,
+	0x918d, 0x0001, 0x2008, 0xa0a0, 0x2048, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x6536, 0x012e, 0xa09f, 0x0000, 0xa0a3, 0x0000, 0x0070,
+	0x7063, 0x0001, 0x7152, 0x7054, 0x9300, 0x7056, 0xa37a, 0xa48e,
+	0xa592, 0xa696, 0xa79a, 0x080c, 0x10b5, 0x9006, 0x00ee, 0x0005,
+	0x0096, 0xa88c, 0x90be, 0x7000, 0x0148, 0x90be, 0x7100, 0x0130,
+	0x90be, 0x7200, 0x0118, 0x009e, 0x0804, 0x31c6, 0xa884, 0xa988,
+	0x080c, 0x24d6, 0x1518, 0x080c, 0x5f1e, 0x1500, 0x7126, 0xbe12,
+	0xbd16, 0xae7c, 0x080c, 0x4612, 0x01c8, 0x080c, 0x4612, 0x01b0,
+	0x009e, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0xa823, 0x0000,
+	0xa804, 0x2048, 0x080c, 0xb79e, 0x1120, 0x2009, 0x0003, 0x0804,
+	0x31c3, 0x7007, 0x0003, 0x701f, 0x4c1b, 0x0005, 0x009e, 0x2009,
+	0x0002, 0x0804, 0x31c3, 0x7124, 0x080c, 0x2f28, 0xa820, 0x9086,
+	0x8001, 0x1120, 0x2009, 0x0004, 0x0804, 0x31c3, 0x2900, 0x7022,
+	0xa804, 0x0096, 0x2048, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f,
+	0x9084, 0xffc0, 0x009e, 0x9080, 0x0002, 0x0076, 0x0006, 0x2098,
+	0x20a0, 0x27e0, 0x27e8, 0x20a9, 0x002a, 0x080c, 0x0f52, 0xaa6c,
+	0xab70, 0xac74, 0xad78, 0x2061, 0x18ae, 0x2c44, 0xa06b, 0x0000,
+	0xae64, 0xaf8c, 0x97c6, 0x7000, 0x0118, 0x97c6, 0x7100, 0x1148,
+	0x96c2, 0x0004, 0x0600, 0x2009, 0x0004, 0x000e, 0x007e, 0x0804,
+	0x465e, 0x97c6, 0x7200, 0x11b8, 0x96c2, 0x0054, 0x02a0, 0x000e,
+	0x007e, 0x2061, 0x18ae, 0x2c44, 0xa076, 0xa772, 0xa07b, 0x002a,
+	0xa28e, 0xa392, 0xa496, 0xa59a, 0x080c, 0x10b5, 0x7007, 0x0002,
+	0x701f, 0x4c77, 0x0005, 0x000e, 0x007e, 0x0804, 0x31c6, 0x7020,
+	0x2048, 0xa804, 0x2048, 0xa804, 0x2048, 0x8906, 0x8006, 0x8007,
+	0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0x2098, 0x20a0,
+	0x27e0, 0x27e8, 0x20a9, 0x002a, 0x080c, 0x0f52, 0x2100, 0x2238,
+	0x2061, 0x18ae, 0x2c44, 0xa28c, 0xa390, 0xa494, 0xa598, 0x2009,
+	0x002a, 0x0804, 0x465e, 0x81ff, 0x1904, 0x31c3, 0x798c, 0x2001,
+	0x194f, 0x2102, 0x080c, 0x4629, 0x0904, 0x31c6, 0x080c, 0x62a4,
+	0x0120, 0x080c, 0x62ac, 0x1904, 0x31c6, 0x080c, 0x6045, 0x0904,
+	0x31c3, 0x0126, 0x2091, 0x8000, 0x080c, 0x610b, 0x012e, 0x0904,
+	0x31c3, 0x0804, 0x417a, 0xa9a0, 0x2001, 0x194f, 0xc18d, 0x2102,
+	0x080c, 0x4636, 0x01a0, 0x080c, 0x62a4, 0x0118, 0x080c, 0x62ac,
+	0x1170, 0x080c, 0x6045, 0x2009, 0x0002, 0x0128, 0x080c, 0x610b,
+	0x1170, 0x2009, 0x0003, 0xa897, 0x4005, 0xa99a, 0x0010, 0xa897,
+	0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030, 0x0005, 0xa897,
+	0x4000, 0x080c, 0x511b, 0x0110, 0x9006, 0x0018, 0x900e, 0x9085,
+	0x0001, 0x2001, 0x0000, 0x0005, 0x78a8, 0xd08c, 0x1118, 0xd084,
+	0x0904, 0x40ef, 0x080c, 0x4645, 0x0904, 0x31c6, 0x080c, 0x4612,
+	0x1120, 0x2009, 0x0002, 0x0804, 0x31c3, 0x080c, 0x62a4, 0x0130,
+	0x908e, 0x0004, 0x0118, 0x908e, 0x0005, 0x15a0, 0x78a8, 0xd08c,
+	0x0120, 0xb800, 0xc08c, 0xb802, 0x0028, 0x080c, 0x5113, 0xd0b4,
+	0x0904, 0x4129, 0x7884, 0x908e, 0x007e, 0x0904, 0x4129, 0x908e,
+	0x007f, 0x0904, 0x4129, 0x908e, 0x0080, 0x0904, 0x4129, 0xb800,
+	0xd08c, 0x1904, 0x4129, 0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a,
+	0x080c, 0xb7bd, 0x1120, 0x2009, 0x0003, 0x0804, 0x31c3, 0x7007,
+	0x0003, 0x701f, 0x4d34, 0x0005, 0x080c, 0x4645, 0x0904, 0x31c6,
+	0x0804, 0x4129, 0x080c, 0x2f81, 0x0108, 0x0005, 0x2009, 0x1832,
+	0x210c, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x31c3, 0x080c,
+	0x5127, 0x0120, 0x2009, 0x0007, 0x0804, 0x31c3, 0x080c, 0x629c,
+	0x0120, 0x2009, 0x0008, 0x0804, 0x31c3, 0xb89c, 0xd0a4, 0x1118,
+	0xd0ac, 0x1904, 0x4129, 0x9006, 0xa866, 0xa832, 0xa868, 0xc0fd,
+	0xa86a, 0x080c, 0xb817, 0x1120, 0x2009, 0x0003, 0x0804, 0x31c3,
+	0x7007, 0x0003, 0x701f, 0x4d6d, 0x0005, 0xa830, 0x9086, 0x0100,
+	0x1120, 0x2009, 0x0004, 0x0804, 0x5070, 0x080c, 0x4645, 0x0904,
+	0x31c6, 0x0804, 0x4d06, 0x81ff, 0x2009, 0x0001, 0x1904, 0x31c3,
+	0x080c, 0x5127, 0x2009, 0x0007, 0x1904, 0x31c3, 0x080c, 0x629c,
+	0x0120, 0x2009, 0x0008, 0x0804, 0x31c3, 0x080c, 0x4645, 0x0904,
+	0x31c6, 0x080c, 0x62a4, 0x2009, 0x0009, 0x1904, 0x31c3, 0x080c,
+	0x4612, 0x2009, 0x0002, 0x0904, 0x31c3, 0x9006, 0xa866, 0xa832,
+	0xa868, 0xc0fd, 0xa86a, 0x7988, 0x9194, 0xff00, 0x918c, 0x00ff,
+	0x9006, 0x82ff, 0x1128, 0xc0ed, 0xa952, 0x798c, 0xa956, 0x0038,
+	0x928e, 0x0100, 0x1904, 0x31c6, 0xc0e5, 0xa952, 0xa956, 0xa83e,
+	0x080c, 0xba6a, 0x2009, 0x0003, 0x0904, 0x31c3, 0x7007, 0x0003,
+	0x701f, 0x4dc3, 0x0005, 0xa830, 0x9086, 0x0100, 0x2009, 0x0004,
+	0x0904, 0x31c3, 0x0804, 0x3191, 0x7aa8, 0x9284, 0xc000, 0x0148,
+	0xd2ec, 0x01a0, 0x080c, 0x5127, 0x1188, 0x2009, 0x0014, 0x0804,
+	0x31c3, 0xd2dc, 0x1568, 0x81ff, 0x2009, 0x0001, 0x1904, 0x31c3,
+	0x080c, 0x5127, 0x2009, 0x0007, 0x1904, 0x31c3, 0xd2f4, 0x0130,
+	0x9284, 0x5000, 0x080c, 0x50ee, 0x0804, 0x3191, 0xd2fc, 0x0158,
+	0x080c, 0x4645, 0x0904, 0x31c6, 0x7984, 0x9284, 0x9000, 0x080c,
+	0x50cb, 0x0804, 0x3191, 0x080c, 0x4645, 0x0904, 0x31c6, 0xb804,
+	0x9084, 0x00ff, 0x9086, 0x0006, 0x2009, 0x0009, 0x1904, 0x4eac,
+	0x080c, 0x4612, 0x2009, 0x0002, 0x0904, 0x4eac, 0xa85c, 0x9080,
+	0x001b, 0xaf60, 0x2009, 0x0008, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98,
+	0x080c, 0x465b, 0x701f, 0x4e1d, 0x0005, 0xa86c, 0x9086, 0x0500,
+	0x1138, 0xa870, 0x9005, 0x1120, 0xa874, 0x9084, 0xff00, 0x0110,
+	0x1904, 0x31c6, 0xa866, 0xa832, 0xa868, 0xc0fd, 0xa86a, 0x080c,
+	0x4645, 0x1110, 0x0804, 0x31c6, 0x2009, 0x0043, 0x080c, 0xbad2,
+	0x2009, 0x0003, 0x0904, 0x4eac, 0x7007, 0x0003, 0x701f, 0x4e41,
+	0x0005, 0xa830, 0x9086, 0x0100, 0x2009, 0x0004, 0x0904, 0x4eac,
+	0x7984, 0x7aa8, 0x9284, 0x1000, 0x080c, 0x50cb, 0x0804, 0x3191,
+	0x00c6, 0xaab0, 0x9284, 0xc000, 0x0140, 0xd2ec, 0x0168, 0x080c,
+	0x5127, 0x1150, 0x2009, 0x0014, 0x04f0, 0x2061, 0x1800, 0x080c,
+	0x5127, 0x2009, 0x0007, 0x15b8, 0xd2f4, 0x0128, 0x9284, 0x5000,
+	0x080c, 0x50ee, 0x0050, 0xd2fc, 0x0178, 0x080c, 0x4643, 0x0588,
+	0xa998, 0x9284, 0x9000, 0x080c, 0x50cb, 0xa87b, 0x0000, 0xa883,
+	0x0000, 0xa897, 0x4000, 0x0438, 0x080c, 0x4643, 0x0510, 0x080c,
+	0x62a4, 0x2009, 0x0009, 0x11b8, 0xa8c4, 0x9086, 0x0500, 0x11c8,
+	0xa8c8, 0x9005, 0x11b0, 0xa8cc, 0x9084, 0xff00, 0x1190, 0x080c,
+	0x4643, 0x1108, 0x0070, 0x2009, 0x004b, 0x080c, 0xbad2, 0x2009,
+	0x0003, 0x0108, 0x0078, 0x0429, 0x19c0, 0xa897, 0x4005, 0xa99a,
+	0x0010, 0xa897, 0x4006, 0x900e, 0x9085, 0x0001, 0x2001, 0x0030,
+	0x00ce, 0x0005, 0x9006, 0x0ce0, 0x7aa8, 0xd2dc, 0x0904, 0x31c3,
+	0x0016, 0x7984, 0x9284, 0x1000, 0xc0fd, 0x080c, 0x50cb, 0x001e,
+	0x1904, 0x31c3, 0x0804, 0x3191, 0x00f6, 0x2d78, 0x0011, 0x00fe,
+	0x0005, 0xaab0, 0xd2dc, 0x0150, 0x0016, 0xa998, 0x9284, 0x1000,
+	0xc0fd, 0x080c, 0x50cb, 0x001e, 0x9085, 0x0001, 0x0005, 0x81ff,
+	0x0120, 0x2009, 0x0001, 0x0804, 0x31c3, 0x080c, 0x5127, 0x0120,
+	0x2009, 0x0007, 0x0804, 0x31c3, 0x7984, 0x7ea8, 0x96b4, 0x00ff,
+	0x080c, 0x5f7e, 0x1904, 0x31c6, 0x9186, 0x007f, 0x0138, 0x080c,
+	0x62a4, 0x0120, 0x2009, 0x0009, 0x0804, 0x31c3, 0x080c, 0x4612,
+	0x1120, 0x2009, 0x0002, 0x0804, 0x31c3, 0xa867, 0x0000, 0xa868,
+	0xc0fd, 0xa86a, 0x2001, 0x0100, 0x8007, 0xa80a, 0x080c, 0xb7d7,
+	0x1120, 0x2009, 0x0003, 0x0804, 0x31c3, 0x7007, 0x0003, 0x701f,
+	0x4f0a, 0x0005, 0xa808, 0x8007, 0x9086, 0x0100, 0x1120, 0x2009,
+	0x0004, 0x0804, 0x31c3, 0xa8e0, 0xa866, 0xa810, 0x8007, 0x9084,
+	0x00ff, 0x800c, 0xa814, 0x8007, 0x9084, 0x00ff, 0x8004, 0x9080,
+	0x0002, 0x9108, 0x8906, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084,
+	0xffc0, 0x9080, 0x0004, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0x0804,
+	0x465e, 0x080c, 0x4612, 0x1120, 0x2009, 0x0002, 0x0804, 0x31c3,
+	0x7984, 0x9194, 0xff00, 0x918c, 0x00ff, 0x8217, 0x82ff, 0x1118,
+	0x7023, 0x1982, 0x0040, 0x92c6, 0x0001, 0x1118, 0x7023, 0x199c,
+	0x0010, 0x0804, 0x31c6, 0x2009, 0x001a, 0x7a8c, 0x7b88, 0x7c9c,
+	0x7d98, 0xa85c, 0x9080, 0x0019, 0xaf60, 0x080c, 0x465b, 0x701f,
+	0x4f5a, 0x0005, 0x2001, 0x182c, 0x2003, 0x0001, 0xa85c, 0x9080,
+	0x0019, 0x2098, 0xa860, 0x20e0, 0x20a9, 0x001a, 0x7020, 0x20a0,
+	0x20e9, 0x0001, 0x4003, 0x0804, 0x3191, 0x080c, 0x4612, 0x1120,
+	0x2009, 0x0002, 0x0804, 0x31c3, 0x7984, 0x9194, 0xff00, 0x918c,
+	0x00ff, 0x8217, 0x82ff, 0x1118, 0x2099, 0x1982, 0x0040, 0x92c6,
+	0x0001, 0x1118, 0x2099, 0x199c, 0x0010, 0x0804, 0x31c6, 0xa85c,
+	0x9080, 0x0019, 0x20a0, 0xa860, 0x20e8, 0x20a9, 0x001a, 0x20e1,
+	0x0001, 0x4003, 0x2009, 0x001a, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98,
+	0xa85c, 0x9080, 0x0019, 0xaf60, 0x0804, 0x465e, 0x7884, 0x908a,
+	0x1000, 0x1a04, 0x31c6, 0x0126, 0x2091, 0x8000, 0x8003, 0x800b,
+	0x810b, 0x9108, 0x00c6, 0x2061, 0x19c9, 0x6142, 0x00ce, 0x012e,
+	0x0804, 0x3191, 0x00c6, 0x080c, 0x6c53, 0x1160, 0x080c, 0x6f2a,
+	0x080c, 0x5a21, 0x9085, 0x0001, 0x080c, 0x6c9a, 0x080c, 0x6b8a,
+	0x080c, 0x0db2, 0x2061, 0x1800, 0x6030, 0xc09d, 0x6032, 0x080c,
+	0x58e0, 0x00ce, 0x0005, 0x00c6, 0x2001, 0x1800, 0x2004, 0x908e,
+	0x0000, 0x0904, 0x31c3, 0x7884, 0x9005, 0x0188, 0x7888, 0x2061,
+	0x196b, 0x2c0c, 0x2062, 0x080c, 0x28b8, 0x01a0, 0x080c, 0x28c0,
+	0x0188, 0x080c, 0x28c8, 0x0170, 0x2162, 0x0804, 0x31c6, 0x2061,
+	0x0100, 0x6038, 0x9086, 0x0007, 0x1118, 0x2009, 0x0001, 0x0010,
+	0x2009, 0x0000, 0x7884, 0x9086, 0x0002, 0x1548, 0x2061, 0x0100,
+	0x6028, 0xc09c, 0x602a, 0x0026, 0x2011, 0x0003, 0x080c, 0x92ec,
+	0x2011, 0x0002, 0x080c, 0x92f6, 0x002e, 0x080c, 0x91de, 0x0036,
+	0x901e, 0x080c, 0x9254, 0x003e, 0x60e3, 0x0000, 0x080c, 0xd343,
+	0x080c, 0xd35e, 0x9085, 0x0001, 0x080c, 0x6c9a, 0x9006, 0x080c,
+	0x2987, 0x2001, 0x1800, 0x2003, 0x0004, 0x6027, 0x0008, 0x00ce,
+	0x0804, 0x3191, 0x81ff, 0x0120, 0x2009, 0x0001, 0x0804, 0x31c3,
+	0x080c, 0x5127, 0x0120, 0x2009, 0x0007, 0x0804, 0x31c3, 0x7984,
+	0x7ea8, 0x96b4, 0x00ff, 0x080c, 0x5f7e, 0x1904, 0x31c6, 0x9186,
+	0x007f, 0x0138, 0x080c, 0x62a4, 0x0120, 0x2009, 0x0009, 0x0804,
+	0x31c3, 0x080c, 0x4612, 0x1120, 0x2009, 0x0002, 0x0804, 0x31c3,
+	0xa867, 0x0000, 0xa868, 0xc0fd, 0xa86a, 0x080c, 0xb7da, 0x1120,
+	0x2009, 0x0003, 0x0804, 0x31c3, 0x7007, 0x0003, 0x701f, 0x5059,
+	0x0005, 0xa830, 0x9086, 0x0100, 0x1120, 0x2009, 0x0004, 0x0804,
+	0x31c3, 0xa8e0, 0xa866, 0xa834, 0x8007, 0x800c, 0xa85c, 0x9080,
+	0x000c, 0x7a8c, 0x7b88, 0x7c9c, 0x7d98, 0xaf60, 0x0804, 0x465e,
+	0xa898, 0x9086, 0x000d, 0x1904, 0x31c3, 0x2021, 0x4005, 0x0126,
+	0x2091, 0x8000, 0x0e04, 0x507d, 0x0010, 0x012e, 0x0cc0, 0x7c36,
+	0x9486, 0x4000, 0x0118, 0x7833, 0x0011, 0x0010, 0x7833, 0x0010,
+	0x7883, 0x4005, 0xa998, 0x7986, 0xa9a4, 0x799a, 0xa9a8, 0x799e,
+	0x080c, 0x464e, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
+	0x190c, 0x1167, 0x7007, 0x0001, 0x2091, 0x5000, 0x700f, 0x0000,
+	0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0x00c6, 0x2061, 0x19c9,
+	0x7984, 0x6152, 0x614e, 0x6057, 0x0000, 0x604b, 0x0009, 0x7898,
+	0x606a, 0x789c, 0x6066, 0x7888, 0x6062, 0x788c, 0x605e, 0x2001,
+	0x19d7, 0x2044, 0x2001, 0x19de, 0xa076, 0xa060, 0xa072, 0xa07b,
+	0x0001, 0xa07f, 0x0002, 0xa06b, 0x0000, 0xa09f, 0x0000, 0x00ce,
+	0x012e, 0x0804, 0x3191, 0x0126, 0x2091, 0x8000, 0x00b6, 0x00c6,
+	0x90e4, 0xc000, 0x0128, 0x0006, 0x080c, 0xb648, 0x000e, 0x1198,
+	0xd0e4, 0x0160, 0x9180, 0x1000, 0x2004, 0x905d, 0x0160, 0x080c,
+	0x5a3b, 0x080c, 0x9940, 0x0110, 0xb817, 0x0000, 0x9006, 0x00ce,
+	0x00be, 0x012e, 0x0005, 0x9085, 0x0001, 0x0cc8, 0x0126, 0x2091,
+	0x8000, 0x0156, 0x2010, 0x900e, 0x20a9, 0x0800, 0x0016, 0x9180,
+	0x1000, 0x2004, 0x9005, 0x0180, 0x9186, 0x007e, 0x0168, 0x9186,
+	0x007f, 0x0150, 0x9186, 0x0080, 0x0138, 0x9186, 0x00ff, 0x0120,
+	0x0026, 0x2200, 0x0801, 0x002e, 0x001e, 0x8108, 0x1f04, 0x50f6,
+	0x015e, 0x012e, 0x0005, 0x2001, 0x1854, 0x2004, 0x0005, 0x2001,
+	0x1873, 0x2004, 0x0005, 0x0006, 0x2001, 0x180f, 0x2004, 0xd0d4,
+	0x000e, 0x0005, 0x2001, 0x180d, 0x2004, 0xd0b4, 0x0005, 0x2001,
+	0x1800, 0x2004, 0x9086, 0x0003, 0x0005, 0x0016, 0x00e6, 0x2071,
+	0x1894, 0x7108, 0x910d, 0x710a, 0x00ee, 0x001e, 0x0005, 0x0126,
+	0x0156, 0x0136, 0x0146, 0x01c6, 0x01d6, 0x00c6, 0x00d6, 0x00e6,
+	0x00f6, 0x2061, 0x0100, 0x2069, 0x0200, 0x2071, 0x1800, 0x6044,
+	0xd0a4, 0x11e8, 0xd084, 0x0118, 0x080c, 0x52e0, 0x0068, 0xd08c,
+	0x0118, 0x080c, 0x51e9, 0x0040, 0xd094, 0x0118, 0x080c, 0x51b9,
+	0x0018, 0xd09c, 0x0108, 0x0099, 0x00fe, 0x00ee, 0x00de, 0x00ce,
+	0x01de, 0x01ce, 0x014e, 0x013e, 0x015e, 0x012e, 0x0005, 0x0016,
+	0x6128, 0xd19c, 0x1110, 0xc19d, 0x612a, 0x001e, 0x0c68, 0x0006,
+	0x7090, 0x9005, 0x000e, 0x0120, 0x7093, 0x0000, 0x708b, 0x0000,
+	0x624c, 0x9286, 0xf0f0, 0x1150, 0x6048, 0x9086, 0xf0f0, 0x0130,
+	0x624a, 0x6043, 0x0090, 0x6043, 0x0010, 0x0490, 0x9294, 0xff00,
+	0x9296, 0xf700, 0x0178, 0x7134, 0xd1a4, 0x1160, 0x6240, 0x9295,
+	0x0100, 0x6242, 0x9294, 0x0010, 0x0128, 0x2009, 0x00f7, 0x080c,
+	0x599d, 0x00f0, 0x6040, 0x9084, 0x0010, 0x9085, 0x0140, 0x6042,
+	0x6043, 0x0000, 0x707f, 0x0000, 0x709b, 0x0001, 0x70bf, 0x0000,
+	0x70d7, 0x0000, 0x2009, 0x1c80, 0x200b, 0x0000, 0x708f, 0x0000,
+	0x7083, 0x000f, 0x2009, 0x000f, 0x2011, 0x5883, 0x080c, 0x7cd9,
+	0x0005, 0x2001, 0x1875, 0x2004, 0xd08c, 0x0110, 0x7057, 0xffff,
+	0x7080, 0x9005, 0x1528, 0x2011, 0x5883, 0x080c, 0x7c4a, 0x6040,
+	0x9094, 0x0010, 0x9285, 0x0020, 0x6042, 0x20a9, 0x00c8, 0x6044,
+	0xd08c, 0x1168, 0x1f04, 0x51cf, 0x6242, 0x7093, 0x0000, 0x6040,
+	0x9094, 0x0010, 0x9285, 0x0080, 0x6042, 0x6242, 0x0048, 0x6242,
+	0x7093, 0x0000, 0x7087, 0x0000, 0x9006, 0x080c, 0x5a26, 0x0000,
+	0x0005, 0x7084, 0x908a, 0x0003, 0x1a0c, 0x0db2, 0x000b, 0x0005,
+	0x51f3, 0x5244, 0x52df, 0x00f6, 0x0016, 0x6900, 0x918c, 0x0800,
+	0x7087, 0x0001, 0x2001, 0x015d, 0x2003, 0x0000, 0x6803, 0x00fc,
+	0x20a9, 0x0004, 0x6800, 0x9084, 0x00fc, 0x0120, 0x1f04, 0x5202,
+	0x080c, 0x0db2, 0x68a0, 0x68a2, 0x689c, 0x689e, 0x6898, 0x689a,
+	0xa001, 0x918d, 0x1600, 0x6902, 0x001e, 0x6837, 0x0020, 0x080c,
+	0x5a02, 0x2079, 0x1c00, 0x7833, 0x1101, 0x7837, 0x0000, 0x20e1,
+	0x0001, 0x2099, 0x1805, 0x20e9, 0x0001, 0x20a1, 0x1c0e, 0x20a9,
+	0x0004, 0x4003, 0x080c, 0x97ce, 0x20e1, 0x0001, 0x2099, 0x1c00,
+	0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9, 0x0014, 0x4003, 0x60c3,
+	0x000c, 0x600f, 0x0000, 0x080c, 0x58b4, 0x00fe, 0x9006, 0x708a,
+	0x6043, 0x0008, 0x6042, 0x0005, 0x00f6, 0x7088, 0x708b, 0x0000,
+	0x9025, 0x0904, 0x52bc, 0x6020, 0xd0b4, 0x1904, 0x52ba, 0x7198,
+	0x81ff, 0x0904, 0x52a8, 0x9486, 0x000c, 0x1904, 0x52b5, 0x9480,
+	0x0018, 0x8004, 0x20a8, 0x080c, 0x59fb, 0x2011, 0x0260, 0x2019,
+	0x1c00, 0x220c, 0x2304, 0x9106, 0x11e8, 0x8210, 0x8318, 0x1f04,
+	0x5261, 0x6043, 0x0004, 0x2061, 0x0140, 0x605b, 0xbc94, 0x605f,
+	0xf0f0, 0x2061, 0x0100, 0x6043, 0x0006, 0x7087, 0x0002, 0x7093,
+	0x0002, 0x2009, 0x07d0, 0x2011, 0x588a, 0x080c, 0x7cd9, 0x080c,
+	0x5a02, 0x04c0, 0x080c, 0x59fb, 0x2079, 0x0260, 0x7930, 0x918e,
+	0x1101, 0x1558, 0x7834, 0x9005, 0x1540, 0x7900, 0x918c, 0x00ff,
+	0x1118, 0x7804, 0x9005, 0x0190, 0x080c, 0x59fb, 0x2011, 0x026e,
+	0x2019, 0x1805, 0x20a9, 0x0004, 0x220c, 0x2304, 0x9102, 0x0230,
+	0x11a0, 0x8210, 0x8318, 0x1f04, 0x529c, 0x0078, 0x709b, 0x0000,
+	0x080c, 0x59fb, 0x20e1, 0x0000, 0x2099, 0x0260, 0x20e9, 0x0001,
+	0x20a1, 0x1c00, 0x20a9, 0x0014, 0x4003, 0x6043, 0x0008, 0x6043,
+	0x0000, 0x0010, 0x00fe, 0x0005, 0x6040, 0x9085, 0x0100, 0x6042,
+	0x6020, 0xd0b4, 0x1db8, 0x080c, 0x97ce, 0x20e1, 0x0001, 0x2099,
+	0x1c00, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9, 0x0014, 0x4003,
+	0x60c3, 0x000c, 0x2011, 0x19c0, 0x2013, 0x0000, 0x708b, 0x0000,
+	0x60a3, 0x0056, 0x60a7, 0x9575, 0x080c, 0x8fb2, 0x08d8, 0x0005,
+	0x7090, 0x908a, 0x001d, 0x1a0c, 0x0db2, 0x000b, 0x0005, 0x5311,
+	0x5324, 0x534d, 0x536d, 0x5393, 0x53c2, 0x53e8, 0x5420, 0x5446,
+	0x5474, 0x54af, 0x54e7, 0x5505, 0x5530, 0x5552, 0x556d, 0x5577,
+	0x55ab, 0x55d1, 0x5600, 0x5626, 0x565e, 0x56a2, 0x56df, 0x5700,
+	0x5759, 0x577b, 0x57a9, 0x57a9, 0x00c6, 0x2061, 0x1800, 0x6003,
+	0x0007, 0x2061, 0x0100, 0x6004, 0x9084, 0xfff9, 0x6006, 0x00ce,
+	0x0005, 0x2061, 0x0140, 0x605b, 0xbc94, 0x605f, 0xf0f0, 0x2061,
+	0x0100, 0x6043, 0x0002, 0x7093, 0x0001, 0x2009, 0x07d0, 0x2011,
+	0x588a, 0x080c, 0x7cd9, 0x0005, 0x00f6, 0x7088, 0x9086, 0x0014,
+	0x1510, 0x6042, 0x6020, 0xd0b4, 0x11f0, 0x080c, 0x59fb, 0x2079,
+	0x0260, 0x7a30, 0x9296, 0x1102, 0x11a0, 0x7834, 0x9005, 0x1188,
+	0x7a38, 0xd2fc, 0x0128, 0x70bc, 0x9005, 0x1110, 0x70bf, 0x0001,
+	0x2011, 0x588a, 0x080c, 0x7c4a, 0x7093, 0x0010, 0x080c, 0x5577,
+	0x0010, 0x708b, 0x0000, 0x00fe, 0x0005, 0x00f6, 0x7093, 0x0003,
+	0x6043, 0x0004, 0x2011, 0x588a, 0x080c, 0x7c4a, 0x080c, 0x597f,
+	0x2079, 0x0240, 0x7833, 0x1102, 0x7837, 0x0000, 0x20a9, 0x0008,
+	0x9f88, 0x000e, 0x200b, 0x0000, 0x8108, 0x1f04, 0x5362, 0x60c3,
+	0x0014, 0x080c, 0x58b4, 0x00fe, 0x0005, 0x00f6, 0x7088, 0x9005,
+	0x0500, 0x2011, 0x588a, 0x080c, 0x7c4a, 0x9086, 0x0014, 0x11b8,
+	0x080c, 0x59fb, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1102, 0x1178,
+	0x7834, 0x9005, 0x1160, 0x7a38, 0xd2fc, 0x0128, 0x70bc, 0x9005,
+	0x1110, 0x70bf, 0x0001, 0x7093, 0x0004, 0x0029, 0x0010, 0x080c,
+	0x59d7, 0x00fe, 0x0005, 0x00f6, 0x7093, 0x0005, 0x080c, 0x597f,
+	0x2079, 0x0240, 0x7833, 0x1103, 0x7837, 0x0000, 0x080c, 0x59fb,
+	0x080c, 0x59de, 0x1170, 0x707c, 0x9005, 0x1158, 0x7154, 0x9186,
+	0xffff, 0x0138, 0x2011, 0x0008, 0x080c, 0x5837, 0x0168, 0x080c,
+	0x59b4, 0x20a9, 0x0008, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9,
+	0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x58b4,
+	0x00fe, 0x0005, 0x00f6, 0x7088, 0x9005, 0x0500, 0x2011, 0x588a,
+	0x080c, 0x7c4a, 0x9086, 0x0014, 0x11b8, 0x080c, 0x59fb, 0x2079,
+	0x0260, 0x7a30, 0x9296, 0x1103, 0x1178, 0x7834, 0x9005, 0x1160,
+	0x7a38, 0xd2fc, 0x0128, 0x70bc, 0x9005, 0x1110, 0x70bf, 0x0001,
+	0x7093, 0x0006, 0x0029, 0x0010, 0x080c, 0x59d7, 0x00fe, 0x0005,
+	0x00f6, 0x7093, 0x0007, 0x080c, 0x597f, 0x2079, 0x0240, 0x7833,
+	0x1104, 0x7837, 0x0000, 0x080c, 0x59fb, 0x080c, 0x59de, 0x11b8,
+	0x707c, 0x9005, 0x11a0, 0x715c, 0x9186, 0xffff, 0x0180, 0x9180,
+	0x2f92, 0x200d, 0x918c, 0xff00, 0x810f, 0x2011, 0x0008, 0x080c,
+	0x5837, 0x0180, 0x080c, 0x4a34, 0x0110, 0x080c, 0x253f, 0x20a9,
+	0x0008, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9, 0x0000, 0x20a1,
+	0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x58b4, 0x00fe, 0x0005,
+	0x00f6, 0x7088, 0x9005, 0x0500, 0x2011, 0x588a, 0x080c, 0x7c4a,
+	0x9086, 0x0014, 0x11b8, 0x080c, 0x59fb, 0x2079, 0x0260, 0x7a30,
+	0x9296, 0x1104, 0x1178, 0x7834, 0x9005, 0x1160, 0x7a38, 0xd2fc,
+	0x0128, 0x70bc, 0x9005, 0x1110, 0x70bf, 0x0001, 0x7093, 0x0008,
+	0x0029, 0x0010, 0x080c, 0x59d7, 0x00fe, 0x0005, 0x00f6, 0x7093,
+	0x0009, 0x080c, 0x597f, 0x2079, 0x0240, 0x7833, 0x1105, 0x7837,
+	0x0100, 0x080c, 0x59de, 0x1150, 0x707c, 0x9005, 0x1138, 0x080c,
+	0x57aa, 0x1188, 0x9085, 0x0001, 0x080c, 0x253f, 0x20a9, 0x0008,
+	0x080c, 0x59fb, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9, 0x0000,
+	0x20a1, 0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x58b4, 0x0010,
+	0x080c, 0x5304, 0x00fe, 0x0005, 0x00f6, 0x7088, 0x9005, 0x05a8,
+	0x2011, 0x588a, 0x080c, 0x7c4a, 0x9086, 0x0014, 0x1560, 0x080c,
+	0x59fb, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1105, 0x1520, 0x7834,
+	0x9084, 0x0100, 0x2011, 0x0100, 0x921e, 0x1160, 0x7a38, 0xd2fc,
+	0x0128, 0x70bc, 0x9005, 0x1110, 0x70bf, 0x0001, 0x7093, 0x000a,
+	0x00b1, 0x0098, 0x9005, 0x1178, 0x7a38, 0xd2fc, 0x0128, 0x70bc,
+	0x9005, 0x1110, 0x70bf, 0x0001, 0x708f, 0x0000, 0x7093, 0x000e,
+	0x080c, 0x5552, 0x0010, 0x080c, 0x59d7, 0x00fe, 0x0005, 0x00f6,
+	0x7093, 0x000b, 0x2011, 0x1c0e, 0x20e9, 0x0001, 0x22a0, 0x20a9,
+	0x0040, 0x2019, 0xffff, 0x4304, 0x080c, 0x597f, 0x2079, 0x0240,
+	0x7833, 0x1106, 0x7837, 0x0000, 0x080c, 0x59de, 0x0118, 0x2013,
+	0x0000, 0x0020, 0x7058, 0x9085, 0x0100, 0x2012, 0x20a9, 0x0040,
+	0x2009, 0x024e, 0x2011, 0x1c0e, 0x220e, 0x8210, 0x8108, 0x9186,
+	0x0260, 0x1128, 0x6810, 0x8000, 0x6812, 0x2009, 0x0240, 0x1f04,
+	0x54d4, 0x60c3, 0x0084, 0x080c, 0x58b4, 0x00fe, 0x0005, 0x00f6,
+	0x7088, 0x9005, 0x01c0, 0x2011, 0x588a, 0x080c, 0x7c4a, 0x9086,
+	0x0084, 0x1178, 0x080c, 0x59fb, 0x2079, 0x0260, 0x7a30, 0x9296,
+	0x1106, 0x1138, 0x7834, 0x9005, 0x1120, 0x7093, 0x000c, 0x0029,
+	0x0010, 0x080c, 0x59d7, 0x00fe, 0x0005, 0x00f6, 0x7093, 0x000d,
+	0x080c, 0x597f, 0x2079, 0x0240, 0x7833, 0x1107, 0x7837, 0x0000,
+	0x080c, 0x59fb, 0x20a9, 0x0040, 0x2011, 0x026e, 0x2009, 0x024e,
+	0x220e, 0x8210, 0x8108, 0x9186, 0x0260, 0x1150, 0x6810, 0x8000,
+	0x6812, 0x2009, 0x0240, 0x6814, 0x8000, 0x6816, 0x2011, 0x0260,
+	0x1f04, 0x5518, 0x60c3, 0x0084, 0x080c, 0x58b4, 0x00fe, 0x0005,
+	0x00f6, 0x7088, 0x9005, 0x01e0, 0x2011, 0x588a, 0x080c, 0x7c4a,
+	0x9086, 0x0084, 0x1198, 0x080c, 0x59fb, 0x2079, 0x0260, 0x7a30,
+	0x9296, 0x1107, 0x1158, 0x7834, 0x9005, 0x1140, 0x708f, 0x0001,
+	0x080c, 0x5951, 0x7093, 0x000e, 0x0029, 0x0010, 0x080c, 0x59d7,
+	0x00fe, 0x0005, 0x918d, 0x0001, 0x080c, 0x5a26, 0x7093, 0x000f,
+	0x708b, 0x0000, 0x2061, 0x0140, 0x605b, 0xbc85, 0x605f, 0xb5b5,
+	0x2061, 0x0100, 0x6043, 0x0005, 0x6043, 0x0004, 0x2009, 0x07d0,
+	0x2011, 0x588a, 0x080c, 0x7c3e, 0x0005, 0x7088, 0x9005, 0x0130,
+	0x2011, 0x588a, 0x080c, 0x7c4a, 0x7093, 0x0000, 0x0005, 0x7093,
+	0x0011, 0x080c, 0x97ce, 0x080c, 0x59fb, 0x20e1, 0x0000, 0x2099,
+	0x0260, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x7488, 0x9480, 0x0018,
+	0x9080, 0x0007, 0x9084, 0x03f8, 0x8004, 0x20a8, 0x4003, 0x080c,
+	0x59de, 0x11a0, 0x7174, 0x81ff, 0x0188, 0x900e, 0x7078, 0x9084,
+	0x00ff, 0x0160, 0x080c, 0x24d6, 0x9186, 0x007e, 0x0138, 0x9186,
+	0x0080, 0x0120, 0x2011, 0x0008, 0x080c, 0x5837, 0x60c3, 0x0014,
+	0x080c, 0x58b4, 0x0005, 0x00f6, 0x7088, 0x9005, 0x0500, 0x2011,
+	0x588a, 0x080c, 0x7c4a, 0x9086, 0x0014, 0x11b8, 0x080c, 0x59fb,
+	0x2079, 0x0260, 0x7a30, 0x9296, 0x1103, 0x1178, 0x7834, 0x9005,
+	0x1160, 0x7a38, 0xd2fc, 0x0128, 0x70bc, 0x9005, 0x1110, 0x70bf,
+	0x0001, 0x7093, 0x0012, 0x0029, 0x0010, 0x708b, 0x0000, 0x00fe,
+	0x0005, 0x00f6, 0x7093, 0x0013, 0x080c, 0x598d, 0x2079, 0x0240,
+	0x7833, 0x1103, 0x7837, 0x0000, 0x080c, 0x59fb, 0x080c, 0x59de,
+	0x1170, 0x707c, 0x9005, 0x1158, 0x7154, 0x9186, 0xffff, 0x0138,
+	0x2011, 0x0008, 0x080c, 0x5837, 0x0168, 0x080c, 0x59b4, 0x20a9,
+	0x0008, 0x20e1, 0x0000, 0x2099, 0x026e, 0x20e9, 0x0000, 0x20a1,
+	0x024e, 0x4003, 0x60c3, 0x0014, 0x080c, 0x58b4, 0x00fe, 0x0005,
+	0x00f6, 0x7088, 0x9005, 0x0500, 0x2011, 0x588a, 0x080c, 0x7c4a,
+	0x9086, 0x0014, 0x11b8, 0x080c, 0x59fb, 0x2079, 0x0260, 0x7a30,
+	0x9296, 0x1104, 0x1178, 0x7834, 0x9005, 0x1160, 0x7a38, 0xd2fc,
+	0x0128, 0x70bc, 0x9005, 0x1110, 0x70bf, 0x0001, 0x7093, 0x0014,
+	0x0029, 0x0010, 0x708b, 0x0000, 0x00fe, 0x0005, 0x00f6, 0x7093,
+	0x0015, 0x080c, 0x598d, 0x2079, 0x0240, 0x7833, 0x1104, 0x7837,
+	0x0000, 0x080c, 0x59fb, 0x080c, 0x59de, 0x11b8, 0x707c, 0x9005,
+	0x11a0, 0x715c, 0x9186, 0xffff, 0x0180, 0x9180, 0x2f92, 0x200d,
+	0x918c, 0xff00, 0x810f, 0x2011, 0x0008, 0x080c, 0x5837, 0x0180,
+	0x080c, 0x4a34, 0x0110, 0x080c, 0x253f, 0x20a9, 0x0008, 0x20e1,
+	0x0000, 0x2099, 0x026e, 0x20e9, 0x0000, 0x20a1, 0x024e, 0x4003,
+	0x60c3, 0x0014, 0x080c, 0x58b4, 0x00fe, 0x0005, 0x00f6, 0x7088,
+	0x9005, 0x05f0, 0x2011, 0x588a, 0x080c, 0x7c4a, 0x9086, 0x0014,
+	0x15a8, 0x080c, 0x59fb, 0x2079, 0x0260, 0x7a30, 0x9296, 0x1105,
+	0x1568, 0x7834, 0x9084, 0x0100, 0x2011, 0x0100, 0x921e, 0x1168,
+	0x9085, 0x0001, 0x080c, 0x5a26, 0x7a38, 0xd2fc, 0x0128, 0x70bc,
+	0x9005, 0x1110, 0x70bf, 0x0001, 0x0080, 0x9005, 0x11b8, 0x7a38,
+	0xd2fc, 0x0128, 0x70bc, 0x9005, 0x1110, 0x70bf, 0x0001, 0x9085,
+	0x0001, 0x080c, 0x5a26, 0x708f, 0x0000, 0x7a38, 0xd2f4, 0x0110,
+	0x70d7, 0x0008, 0x7093, 0x0016, 0x0029, 0x0010, 0x708b, 0x0000,
+	0x00fe, 0x0005, 0x080c, 0x97ce, 0x080c, 0x59fb, 0x20e1, 0x0000,
+	0x2099, 0x0260, 0x20e9, 0x0000, 0x20a1, 0x0240, 0x20a9, 0x000e,
+	0x4003, 0x2011, 0x026d, 0x2204, 0x9084, 0x0100, 0x2011, 0x024d,
+	0x2012, 0x2011, 0x026e, 0x7093, 0x0017, 0x080c, 0x59de, 0x1150,
+	0x707c, 0x9005, 0x1138, 0x080c, 0x57aa, 0x1188, 0x9085, 0x0001,
+	0x080c, 0x253f, 0x20a9, 0x0008, 0x080c, 0x59fb, 0x20e1, 0x0000,
+	0x2099, 0x026e, 0x20e9, 0x0000, 0x20a1, 0x024e, 0x4003, 0x60c3,
+	0x0014, 0x080c, 0x58b4, 0x0010, 0x080c, 0x5304, 0x0005, 0x00f6,
+	0x7088, 0x9005, 0x01d8, 0x2011, 0x588a, 0x080c, 0x7c4a, 0x9086,
+	0x0084, 0x1190, 0x080c, 0x59fb, 0x2079, 0x0260, 0x7a30, 0x9296,
+	0x1106, 0x1150, 0x7834, 0x9005, 0x1138, 0x9006, 0x080c, 0x5a26,
+	0x7093, 0x0018, 0x0029, 0x0010, 0x708b, 0x0000, 0x00fe, 0x0005,
+	0x00f6, 0x7093, 0x0019, 0x080c, 0x598d, 0x2079, 0x0240, 0x7833,
+	0x1106, 0x7837, 0x0000, 0x080c, 0x59fb, 0x2009, 0x026e, 0x2039,
+	0x1c0e, 0x20a9, 0x0040, 0x213e, 0x8738, 0x8108, 0x9186, 0x0280,
+	0x1128, 0x6814, 0x8000, 0x6816, 0x2009, 0x0260, 0x1f04, 0x5713,
+	0x2039, 0x1c0e, 0x080c, 0x59de, 0x11e8, 0x2728, 0x2514, 0x8207,
+	0x9084, 0x00ff, 0x8000, 0x2018, 0x9294, 0x00ff, 0x8007, 0x9205,
+	0x202a, 0x7058, 0x2310, 0x8214, 0x92a0, 0x1c0e, 0x2414, 0x938c,
+	0x0001, 0x0118, 0x9294, 0xff00, 0x0018, 0x9294, 0x00ff, 0x8007,
+	0x9215, 0x2222, 0x20a9, 0x0040, 0x2009, 0x024e, 0x270e, 0x8738,
+	0x8108, 0x9186, 0x0260, 0x1128, 0x6810, 0x8000, 0x6812, 0x2009,
+	0x0240, 0x1f04, 0x5746, 0x60c3, 0x0084, 0x080c, 0x58b4, 0x00fe,
+	0x0005, 0x00f6, 0x7088, 0x9005, 0x01e0, 0x2011, 0x588a, 0x080c,
+	0x7c4a, 0x9086, 0x0084, 0x1198, 0x080c, 0x59fb, 0x2079, 0x0260,
+	0x7a30, 0x9296, 0x1107, 0x1158, 0x7834, 0x9005, 0x1140, 0x708f,
+	0x0001, 0x080c, 0x5951, 0x7093, 0x001a, 0x0029, 0x0010, 0x708b,
+	0x0000, 0x00fe, 0x0005, 0x9085, 0x0001, 0x080c, 0x5a26, 0x7093,
+	0x001b, 0x080c, 0x97ce, 0x080c, 0x59fb, 0x2011, 0x0260, 0x2009,
+	0x0240, 0x7488, 0x9480, 0x0018, 0x9080, 0x0007, 0x9084, 0x03f8,
+	0x8004, 0x20a8, 0x220e, 0x8210, 0x8108, 0x9186, 0x0260, 0x1150,
+	0x6810, 0x8000, 0x6812, 0x2009, 0x0240, 0x6814, 0x8000, 0x6816,
+	0x2011, 0x0260, 0x1f04, 0x5792, 0x60c3, 0x0084, 0x080c, 0x58b4,
+	0x0005, 0x0005, 0x0086, 0x0096, 0x2029, 0x1854, 0x252c, 0x20a9,
+	0x0008, 0x2041, 0x1c0e, 0x20e9, 0x0001, 0x28a0, 0x080c, 0x59fb,
+	0x20e1, 0x0000, 0x2099, 0x026e, 0x4003, 0x20a9, 0x0008, 0x2011,
+	0x0007, 0xd5d4, 0x0108, 0x9016, 0x2800, 0x9200, 0x200c, 0x91a6,
+	0xffff, 0x1148, 0xd5d4, 0x0110, 0x8210, 0x0008, 0x8211, 0x1f04,
+	0x57c4, 0x0804, 0x5833, 0x82ff, 0x1160, 0xd5d4, 0x0120, 0x91a6,
+	0x3fff, 0x0d90, 0x0020, 0x91a6, 0x3fff, 0x0904, 0x5833, 0x918d,
+	0xc000, 0x20a9, 0x0010, 0x2019, 0x0001, 0xd5d4, 0x0110, 0x2019,
+	0x0010, 0x2120, 0xd5d4, 0x0110, 0x8423, 0x0008, 0x8424, 0x1240,
+	0xd5d4, 0x0110, 0x8319, 0x0008, 0x8318, 0x1f04, 0x57ea, 0x04d8,
+	0x23a8, 0x2021, 0x0001, 0x8426, 0x8425, 0x1f04, 0x57fc, 0x2328,
+	0x8529, 0x92be, 0x0007, 0x0158, 0x0006, 0x2039, 0x0007, 0x2200,
+	0x973a, 0x000e, 0x27a8, 0x95a8, 0x0010, 0x1f04, 0x580b, 0x7556,
+	0x95c8, 0x2f92, 0x292d, 0x95ac, 0x00ff, 0x757a, 0x6532, 0x6536,
+	0x0016, 0x2508, 0x080c, 0x251f, 0x001e, 0x60e7, 0x0000, 0x65ea,
+	0x2018, 0x2304, 0x9405, 0x201a, 0x707f, 0x0001, 0x20e9, 0x0000,
+	0x20a1, 0x024e, 0x20e1, 0x0001, 0x2898, 0x20a9, 0x0008, 0x4003,
+	0x9085, 0x0001, 0x0008, 0x9006, 0x009e, 0x008e, 0x0005, 0x0156,
+	0x01c6, 0x01d6, 0x0136, 0x0146, 0x22a8, 0x20e1, 0x0000, 0x2099,
+	0x026e, 0x20e9, 0x0000, 0x2011, 0x024e, 0x22a0, 0x4003, 0x014e,
+	0x013e, 0x01de, 0x01ce, 0x015e, 0x2118, 0x9026, 0x2001, 0x0007,
+	0x939a, 0x0010, 0x0218, 0x8420, 0x8001, 0x0cd0, 0x2118, 0x84ff,
+	0x0120, 0x939a, 0x0010, 0x8421, 0x1de0, 0x2021, 0x0001, 0x83ff,
+	0x0118, 0x8423, 0x8319, 0x1de8, 0x9238, 0x2029, 0x026e, 0x9528,
+	0x2504, 0x942c, 0x11b8, 0x9405, 0x203a, 0x7156, 0x91a0, 0x2f92,
+	0x242d, 0x95ac, 0x00ff, 0x757a, 0x6532, 0x6536, 0x0016, 0x2508,
+	0x080c, 0x251f, 0x001e, 0x60e7, 0x0000, 0x65ea, 0x707f, 0x0001,
+	0x9084, 0x0000, 0x0005, 0x00e6, 0x2071, 0x1800, 0x7083, 0x0000,
+	0x00ee, 0x0005, 0x00e6, 0x00f6, 0x2079, 0x0100, 0x2071, 0x0140,
+	0x080c, 0x5940, 0x080c, 0x8fbb, 0x7004, 0x9084, 0x4000, 0x0110,
+	0x080c, 0x2997, 0x0126, 0x2091, 0x8000, 0x2071, 0x1824, 0x2073,
+	0x0000, 0x7840, 0x0026, 0x0016, 0x2009, 0x00f7, 0x080c, 0x599d,
+	0x001e, 0x9094, 0x0010, 0x9285, 0x0080, 0x7842, 0x7a42, 0x002e,
+	0x012e, 0x00fe, 0x00ee, 0x0005, 0x0126, 0x2091, 0x8000, 0x080c,
+	0x283d, 0x0228, 0x2011, 0x0101, 0x2204, 0xc0c5, 0x2012, 0x2011,
+	0x19c0, 0x2013, 0x0000, 0x708b, 0x0000, 0x012e, 0x60a3, 0x0056,
+	0x60a7, 0x9575, 0x080c, 0x8fb2, 0x6144, 0xd184, 0x0120, 0x7190,
+	0x918d, 0x2000, 0x0018, 0x7184, 0x918d, 0x1000, 0x2011, 0x1968,
+	0x2112, 0x2009, 0x07d0, 0x2011, 0x588a, 0x080c, 0x7cd9, 0x0005,
+	0x0016, 0x0026, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0x9947,
+	0x2009, 0x00f7, 0x080c, 0x599d, 0x2061, 0x19c9, 0x900e, 0x611a,
+	0x611e, 0x6172, 0x6176, 0x2061, 0x1800, 0x6003, 0x0001, 0x2061,
+	0x0100, 0x6043, 0x0090, 0x6043, 0x0010, 0x2009, 0x1968, 0x200b,
+	0x0000, 0x2009, 0x002d, 0x2011, 0x590c, 0x080c, 0x7c3e, 0x012e,
+	0x00ce, 0x002e, 0x001e, 0x0005, 0x00e6, 0x0006, 0x0126, 0x2091,
+	0x8000, 0x0471, 0x2071, 0x0100, 0x080c, 0x8fbb, 0x2071, 0x0140,
+	0x7004, 0x9084, 0x4000, 0x0110, 0x080c, 0x2997, 0x080c, 0x6c5b,
+	0x0188, 0x080c, 0x6c76, 0x1170, 0x080c, 0x6f34, 0x0016, 0x080c,
+	0x25ee, 0x2001, 0x193e, 0x2102, 0x001e, 0x080c, 0x6f2f, 0x080c,
+	0x6b8a, 0x0050, 0x2009, 0x0001, 0x080c, 0x28d6, 0x2001, 0x0001,
+	0x080c, 0x247f, 0x080c, 0x58e0, 0x012e, 0x000e, 0x00ee, 0x0005,
+	0x2001, 0x180d, 0x2004, 0xd0bc, 0x0158, 0x0026, 0x0036, 0x2011,
+	0x8017, 0x2001, 0x1968, 0x201c, 0x080c, 0x4672, 0x003e, 0x002e,
+	0x0005, 0x20a9, 0x0012, 0x20e9, 0x0001, 0x20a1, 0x1c80, 0x080c,
+	0x59fb, 0x20e9, 0x0000, 0x2099, 0x026e, 0x0099, 0x20a9, 0x0020,
+	0x080c, 0x59f5, 0x2099, 0x0260, 0x20a1, 0x1c92, 0x0051, 0x20a9,
+	0x000e, 0x080c, 0x59f8, 0x2099, 0x0260, 0x20a1, 0x1cb2, 0x0009,
+	0x0005, 0x0016, 0x0026, 0x3410, 0x3308, 0x2104, 0x8007, 0x2012,
+	0x8108, 0x8210, 0x1f04, 0x5975, 0x002e, 0x001e, 0x0005, 0x080c,
+	0x97ce, 0x20e1, 0x0001, 0x2099, 0x1c00, 0x20e9, 0x0000, 0x20a1,
+	0x0240, 0x20a9, 0x000c, 0x4003, 0x0005, 0x080c, 0x97ce, 0x080c,
+	0x59fb, 0x20e1, 0x0000, 0x2099, 0x0260, 0x20e9, 0x0000, 0x20a1,
+	0x0240, 0x20a9, 0x000c, 0x4003, 0x0005, 0x00c6, 0x0006, 0x2061,
+	0x0100, 0x810f, 0x2001, 0x1832, 0x2004, 0x9005, 0x1138, 0x2001,
+	0x1816, 0x2004, 0x9084, 0x00ff, 0x9105, 0x0010, 0x9185, 0x00f7,
+	0x604a, 0x000e, 0x00ce, 0x0005, 0x0016, 0x0046, 0x080c, 0x62a0,
+	0x0158, 0x9006, 0x2020, 0x2009, 0x002a, 0x080c, 0xcfe6, 0x2001,
+	0x180c, 0x200c, 0xc195, 0x2102, 0x2019, 0x002a, 0x900e, 0x080c,
+	0x2dfb, 0x080c, 0xbcec, 0x0140, 0x0036, 0x2019, 0xffff, 0x2021,
+	0x0007, 0x080c, 0x4829, 0x003e, 0x004e, 0x001e, 0x0005, 0x080c,
+	0x58e0, 0x7093, 0x0000, 0x708b, 0x0000, 0x0005, 0x0006, 0x2001,
+	0x180c, 0x2004, 0xd09c, 0x0100, 0x000e, 0x0005, 0x0006, 0x0016,
+	0x0126, 0x2091, 0x8000, 0x2001, 0x0101, 0x200c, 0x918d, 0x0006,
+	0x2102, 0x012e, 0x001e, 0x000e, 0x0005, 0x2009, 0x0001, 0x0020,
+	0x2009, 0x0002, 0x0008, 0x900e, 0x6814, 0x9084, 0xffc0, 0x910d,
+	0x6916, 0x0005, 0x00f6, 0x0156, 0x0146, 0x01d6, 0x9006, 0x20a9,
+	0x0080, 0x20e9, 0x0001, 0x20a1, 0x1c00, 0x4004, 0x2079, 0x1c00,
+	0x7803, 0x2200, 0x7807, 0x00ef, 0x780f, 0x00ef, 0x7813, 0x0138,
+	0x7823, 0xffff, 0x7827, 0xffff, 0x01de, 0x014e, 0x015e, 0x00fe,
+	0x0005, 0x2001, 0x1800, 0x2003, 0x0001, 0x0005, 0x2001, 0x1975,
+	0x0118, 0x2003, 0x0001, 0x0010, 0x2003, 0x0000, 0x0005, 0x0156,
+	0x20a9, 0x0800, 0x2009, 0x1000, 0x9006, 0x200a, 0x8108, 0x1f04,
+	0x5a35, 0x015e, 0x0005, 0x00d6, 0x0036, 0x0156, 0x0136, 0x0146,
+	0x2069, 0x1853, 0x9006, 0xb802, 0xb8be, 0xb807, 0x0707, 0xb80a,
+	0xb80e, 0xb812, 0x9198, 0x2f92, 0x231d, 0x939c, 0x00ff, 0xbb16,
+	0x0016, 0x0026, 0xb8b2, 0x080c, 0x9940, 0x1120, 0x9192, 0x007e,
+	0x1208, 0xbbb2, 0x20a9, 0x0004, 0xb8b4, 0x20e8, 0xb9b8, 0x9198,
+	0x0006, 0x9006, 0x23a0, 0x4004, 0x20a9, 0x0004, 0x9198, 0x000a,
+	0x23a0, 0x4004, 0x002e, 0x001e, 0xb83e, 0xb842, 0xb84e, 0xb852,
+	0xb856, 0xb85a, 0xb85e, 0xb862, 0xb866, 0xb86a, 0xb86f, 0x0100,
+	0xb872, 0xb876, 0xb87a, 0xb88a, 0xb88e, 0xb893, 0x0008, 0xb896,
+	0xb89a, 0xb89e, 0xb8ae, 0xb9a2, 0x0096, 0xb8a4, 0x904d, 0x0110,
+	0x080c, 0x1007, 0xb8a7, 0x0000, 0x009e, 0x9006, 0xb84a, 0x6810,
+	0xb83a, 0x680c, 0xb846, 0x6814, 0x9084, 0x00ff, 0xb842, 0x014e,
+	0x013e, 0x015e, 0x003e, 0x00de, 0x0005, 0x0126, 0x2091, 0x8000,
+	0xa974, 0xae78, 0x9684, 0x3fff, 0x9082, 0x4000, 0x1a04, 0x5b0b,
+	0x9182, 0x0800, 0x1a04, 0x5b0f, 0x2001, 0x180c, 0x2004, 0x9084,
+	0x0003, 0x1904, 0x5b15, 0x9188, 0x1000, 0x2104, 0x905d, 0x0518,
+	0xb804, 0x9084, 0x00ff, 0x908e, 0x0006, 0x1508, 0xb8a4, 0x900d,
+	0x1904, 0x5b27, 0xb850, 0x900d, 0x1148, 0xa802, 0x2900, 0xb852,
+	0xb84e, 0x080c, 0x801d, 0x9006, 0x012e, 0x0005, 0x00a6, 0x2150,
+	0x2900, 0xb002, 0xa803, 0x0000, 0x00ae, 0xb852, 0x0c90, 0x2001,
+	0x0005, 0x900e, 0x04b8, 0x2001, 0x0028, 0x900e, 0x0498, 0x9082,
+	0x0006, 0x1290, 0x080c, 0x9940, 0x1160, 0xb8a0, 0x9084, 0xff80,
+	0x1140, 0xb900, 0xd1fc, 0x0990, 0x2001, 0x0029, 0x2009, 0x1000,
+	0x0408, 0x2001, 0x0028, 0x00a8, 0x2009, 0x180c, 0x210c, 0xd18c,
+	0x0118, 0x2001, 0x0004, 0x0068, 0xd184, 0x0118, 0x2001, 0x0004,
+	0x0040, 0x2001, 0x0029, 0xb900, 0xd1fc, 0x0118, 0x2009, 0x1000,
+	0x0048, 0x900e, 0x0038, 0x2001, 0x0029, 0x900e, 0x0018, 0x2001,
+	0x0029, 0x900e, 0x9005, 0x012e, 0x0005, 0x2001, 0x180c, 0x2004,
+	0xd084, 0x19d0, 0x9188, 0x1000, 0x2104, 0x905d, 0x09a8, 0x080c,
+	0x62a4, 0x1990, 0xb800, 0xd0bc, 0x0978, 0x0804, 0x5abe, 0x080c,
+	0x611a, 0x0904, 0x5ad7, 0x0804, 0x5ac2, 0x00b6, 0x00e6, 0x0126,
+	0x2091, 0x8000, 0xa974, 0x9182, 0x0800, 0x1a04, 0x5ba8, 0x9188,
+	0x1000, 0x2104, 0x905d, 0x0904, 0x5b80, 0xb8a0, 0x9086, 0x007f,
+	0x0178, 0x080c, 0x62ac, 0x0160, 0xa994, 0x81ff, 0x0130, 0x908e,
+	0x0004, 0x0130, 0x908e, 0x0005, 0x0118, 0x080c, 0x62a4, 0x1598,
+	0xa87c, 0xd0fc, 0x01e0, 0xa894, 0x9005, 0x01c8, 0x2060, 0x0026,
+	0x2010, 0x080c, 0xb5e9, 0x002e, 0x1120, 0x2001, 0x0008, 0x0804,
+	0x5baa, 0x6020, 0x9086, 0x000a, 0x0120, 0x2001, 0x0008, 0x0804,
+	0x5baa, 0x601a, 0x6003, 0x0008, 0x2900, 0x6016, 0x0058, 0x080c,
+	0x9980, 0x05e8, 0x2b00, 0x6012, 0x2900, 0x6016, 0x600b, 0xffff,
+	0x6023, 0x000a, 0x2009, 0x0003, 0x080c, 0x9a50, 0x9006, 0x0458,
+	0x2001, 0x0028, 0x0438, 0x9082, 0x0006, 0x1290, 0x080c, 0x9940,
+	0x1160, 0xb8a0, 0x9084, 0xff80, 0x1140, 0xb900, 0xd1fc, 0x0900,
+	0x2001, 0x0029, 0x2009, 0x1000, 0x00a8, 0x2001, 0x0028, 0x0090,
+	0x2009, 0x180c, 0x210c, 0xd18c, 0x0118, 0x2001, 0x0004, 0x0050,
+	0xd184, 0x0118, 0x2001, 0x0004, 0x0028, 0x2001, 0x0029, 0x0010,
+	0x2001, 0x0029, 0x9005, 0x012e, 0x00ee, 0x00be, 0x0005, 0x2001,
+	0x002c, 0x0cc0, 0x00f6, 0x00b6, 0x0126, 0x2091, 0x8000, 0xa8e0,
+	0x9005, 0x1550, 0xa8dc, 0x9082, 0x0101, 0x1630, 0xa8c8, 0x9005,
+	0x1518, 0xa8c4, 0x9082, 0x0101, 0x12f8, 0xa974, 0x2079, 0x1800,
+	0x9182, 0x0800, 0x12e8, 0x7830, 0x9084, 0x0003, 0x1130, 0xaa98,
+	0xab94, 0xa878, 0x9084, 0x0007, 0x00ea, 0x7930, 0xd18c, 0x0118,
+	0x2001, 0x0004, 0x0038, 0xd184, 0x0118, 0x2001, 0x0004, 0x0010,
+	0x2001, 0x0029, 0x900e, 0x0038, 0x2001, 0x002c, 0x900e, 0x0018,
+	0x2001, 0x0029, 0x900e, 0x9006, 0x0008, 0x9005, 0x012e, 0x00be,
+	0x00fe, 0x0005, 0x5c3f, 0x5bfa, 0x5c11, 0x5c3f, 0x5c3f, 0x5c3f,
+	0x5c3f, 0x5c3f, 0x2100, 0x9082, 0x007e, 0x1278, 0x080c, 0x5f1e,
+	0x0148, 0x9046, 0xb810, 0x9306, 0x1904, 0x5c47, 0xb814, 0x9206,
+	0x15f0, 0x0028, 0xbb12, 0xba16, 0x0010, 0x080c, 0x452c, 0x0150,
+	0x04b0, 0x080c, 0x5f7e, 0x1598, 0xb810, 0x9306, 0x1580, 0xb814,
+	0x9206, 0x1568, 0x080c, 0x9980, 0x0530, 0x2b00, 0x6012, 0x080c,
+	0xba69, 0x2900, 0x6016, 0x600b, 0xffff, 0x6023, 0x000a, 0xa878,
+	0x9086, 0x0001, 0x1170, 0x080c, 0x2e30, 0x9006, 0x080c, 0x5ebb,
+	0x2001, 0x0002, 0x080c, 0x5ecf, 0x2001, 0x0200, 0xb86e, 0xb893,
+	0x0002, 0x2009, 0x0003, 0x080c, 0x9a50, 0x9006, 0x0068, 0x2001,
+	0x0001, 0x900e, 0x0038, 0x2001, 0x002c, 0x900e, 0x0018, 0x2001,
+	0x0028, 0x900e, 0x9005, 0x0000, 0x012e, 0x00be, 0x00fe, 0x0005,
+	0x00b6, 0x00f6, 0x00e6, 0x0126, 0x2091, 0x8000, 0xa894, 0x90c6,
+	0x0015, 0x0904, 0x5e14, 0x90c6, 0x0056, 0x0904, 0x5e18, 0x90c6,
+	0x0066, 0x0904, 0x5e1c, 0x90c6, 0x0071, 0x0904, 0x5e20, 0x90c6,
+	0x0074, 0x0904, 0x5e24, 0x90c6, 0x007c, 0x0904, 0x5e28, 0x90c6,
+	0x007e, 0x0904, 0x5e2c, 0x90c6, 0x0037, 0x0904, 0x5e30, 0x9016,
+	0x2079, 0x1800, 0xa974, 0x9186, 0x00ff, 0x0904, 0x5e0f, 0x9182,
+	0x0800, 0x1a04, 0x5e0f, 0x080c, 0x5f7e, 0x1198, 0xb804, 0x9084,
+	0x00ff, 0x9082, 0x0006, 0x1268, 0xa894, 0x90c6, 0x006f, 0x0148,
+	0x080c, 0x9940, 0x1904, 0x5df8, 0xb8a0, 0x9084, 0xff80, 0x1904,
+	0x5df8, 0xa894, 0x90c6, 0x006f, 0x0158, 0x90c6, 0x005e, 0x0904,
+	0x5d58, 0x90c6, 0x0064, 0x0904, 0x5d81, 0x2008, 0x0804, 0x5d1b,
+	0xa998, 0xa8b0, 0x2040, 0x080c, 0x9940, 0x1120, 0x9182, 0x007f,
+	0x0a04, 0x5d1b, 0x9186, 0x00ff, 0x0904, 0x5d1b, 0x9182, 0x0800,
+	0x1a04, 0x5d1b, 0xaaa0, 0xab9c, 0x7874, 0x9306, 0x1188, 0x7878,
+	0x0096, 0x924e, 0x1128, 0x2208, 0x2310, 0x009e, 0x0804, 0x5d1b,
+	0x99cc, 0xff00, 0x009e, 0x1120, 0x2208, 0x2310, 0x0804, 0x5d1b,
+	0x080c, 0x452c, 0x0904, 0x5d24, 0x900e, 0x9016, 0x90c6, 0x4000,
+	0x1558, 0x0006, 0x080c, 0x619e, 0x1108, 0xc185, 0xb800, 0xd0bc,
+	0x0108, 0xc18d, 0x20a9, 0x0004, 0xa860, 0x20e8, 0xa85c, 0x9080,
+	0x0031, 0x20a0, 0xb8b4, 0x20e0, 0xb8b8, 0x9080, 0x0006, 0x2098,
+	0x080c, 0x0f52, 0x20a9, 0x0004, 0xa860, 0x20e8, 0xa85c, 0x9080,
+	0x0035, 0x20a0, 0xb8b4, 0x20e0, 0xb8b8, 0x9080, 0x000a, 0x2098,
+	0x080c, 0x0f52, 0x000e, 0x00c8, 0x90c6, 0x4007, 0x1110, 0x2408,
+	0x00a0, 0x90c6, 0x4008, 0x1118, 0x2708, 0x2610, 0x0070, 0x90c6,
+	0x4009, 0x1108, 0x0050, 0x90c6, 0x4006, 0x0138, 0x2001, 0x4005,
+	0x2009, 0x000a, 0x0010, 0x2001, 0x4006, 0xa896, 0xa99a, 0xaa9e,
+	0x2001, 0x0030, 0x900e, 0x0470, 0x080c, 0x9980, 0x1130, 0x2001,
+	0x4005, 0x2009, 0x0003, 0x9016, 0x0c80, 0x2b00, 0x6012, 0x080c,
+	0xba69, 0x2900, 0x6016, 0x6023, 0x0001, 0xa868, 0xd88c, 0x0108,
+	0xc0f5, 0xa86a, 0x0126, 0x2091, 0x8000, 0x080c, 0x2e30, 0x012e,
+	0x9006, 0x080c, 0x5ebb, 0x2001, 0x0002, 0x080c, 0x5ecf, 0x2009,
+	0x0002, 0x080c, 0x9a50, 0xa8b0, 0xd094, 0x0118, 0xb8bc, 0xc08d,
+	0xb8be, 0x9006, 0x9005, 0x012e, 0x00ee, 0x00fe, 0x00be, 0x0005,
+	0x080c, 0x5127, 0x0118, 0x2009, 0x0007, 0x00f8, 0xa998, 0xaeb0,
+	0x080c, 0x5f7e, 0x1904, 0x5d16, 0x9186, 0x007f, 0x0130, 0x080c,
+	0x62a4, 0x0118, 0x2009, 0x0009, 0x0080, 0x0096, 0x080c, 0x0fd5,
+	0x1120, 0x009e, 0x2009, 0x0002, 0x0040, 0x2900, 0x009e, 0xa806,
+	0x080c, 0xb7da, 0x19b0, 0x2009, 0x0003, 0x2001, 0x4005, 0x0804,
+	0x5d1d, 0xa998, 0xaeb0, 0x080c, 0x5f7e, 0x1904, 0x5d16, 0x0096,
+	0x080c, 0x0fd5, 0x1128, 0x009e, 0x2009, 0x0002, 0x0804, 0x5dd5,
+	0x2900, 0x009e, 0xa806, 0x0096, 0x2048, 0x20a9, 0x002b, 0xb8b4,
+	0x20e0, 0xb8b8, 0x2098, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002,
+	0x20a0, 0x4003, 0x20a9, 0x0008, 0x9080, 0x0006, 0x20a0, 0xbbb8,
+	0x9398, 0x0006, 0x2398, 0x080c, 0x0f52, 0x009e, 0xa87b, 0x0000,
+	0xa883, 0x0000, 0xa897, 0x4000, 0xd684, 0x1168, 0x080c, 0x5113,
+	0xd0b4, 0x1118, 0xa89b, 0x000b, 0x00e0, 0xb800, 0xd08c, 0x0118,
+	0xa89b, 0x000c, 0x00b0, 0x080c, 0x62a4, 0x0118, 0xa89b, 0x0009,
+	0x0080, 0x080c, 0x5127, 0x0118, 0xa89b, 0x0007, 0x0050, 0x080c,
+	0xb7bd, 0x1904, 0x5d51, 0x2009, 0x0003, 0x2001, 0x4005, 0x0804,
+	0x5d1d, 0xa87b, 0x0030, 0xa897, 0x4005, 0xa804, 0x8006, 0x8006,
+	0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002, 0x2009,
+	0x002b, 0xaaa0, 0xab9c, 0xaca8, 0xada4, 0x2031, 0x0000, 0x2041,
+	0x120c, 0x080c, 0x9ed6, 0x1904, 0x5d51, 0x2009, 0x0002, 0x08e8,
+	0x2001, 0x0028, 0x900e, 0x0804, 0x5d52, 0x2009, 0x180c, 0x210c,
+	0xd18c, 0x0118, 0x2001, 0x0004, 0x0038, 0xd184, 0x0118, 0x2001,
+	0x0004, 0x0010, 0x2001, 0x0029, 0x900e, 0x0804, 0x5d52, 0x2001,
+	0x0029, 0x900e, 0x0804, 0x5d52, 0x080c, 0x33b6, 0x0804, 0x5d53,
+	0x080c, 0x4e50, 0x0804, 0x5d53, 0x080c, 0x41a5, 0x0804, 0x5d53,
+	0x080c, 0x45e8, 0x0804, 0x5d53, 0x080c, 0x489f, 0x0804, 0x5d53,
+	0x080c, 0x4aca, 0x0804, 0x5d53, 0x080c, 0x4cbb, 0x0804, 0x5d53,
+	0x080c, 0x35c6, 0x0804, 0x5d53, 0x00b6, 0xa974, 0xae78, 0x9684,
+	0x3fff, 0x9082, 0x4000, 0x1618, 0x9182, 0x0800, 0x1268, 0x9188,
+	0x1000, 0x2104, 0x905d, 0x0140, 0x080c, 0x62a4, 0x1148, 0x00e9,
+	0x080c, 0x60a9, 0x9006, 0x00b0, 0x2001, 0x0028, 0x900e, 0x0090,
+	0x9082, 0x0006, 0x1240, 0xb900, 0xd1fc, 0x0d88, 0x2001, 0x0029,
+	0x2009, 0x1000, 0x0038, 0x2001, 0x0029, 0x900e, 0x0018, 0x2001,
+	0x0029, 0x900e, 0x9005, 0x00be, 0x0005, 0x0126, 0x2091, 0x8000,
+	0xb850, 0x900d, 0x0150, 0x2900, 0x0096, 0x2148, 0xa802, 0x009e,
+	0xa803, 0x0000, 0xb852, 0x012e, 0x0005, 0x2900, 0xb852, 0xb84e,
+	0xa803, 0x0000, 0x0cc0, 0x0126, 0x2091, 0x8000, 0xb84c, 0x9005,
+	0x0170, 0x00e6, 0x2071, 0x19b6, 0x7004, 0x9086, 0x0002, 0x0168,
+	0x00ee, 0xb84c, 0xa802, 0x2900, 0xb84e, 0x012e, 0x0005, 0x2900,
+	0xb852, 0xb84e, 0xa803, 0x0000, 0x0cc0, 0x701c, 0x9b06, 0x1d80,
+	0xb84c, 0x00a6, 0x2050, 0xb000, 0xa802, 0x2900, 0xb002, 0x00ae,
+	0x00ee, 0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0xb84c, 0x904d,
+	0x0130, 0xa800, 0x9005, 0x1108, 0xb852, 0xb84e, 0x9905, 0x012e,
+	0x0005, 0xb84c, 0x904d, 0x0130, 0xa800, 0x9005, 0x1108, 0xb852,
+	0xb84e, 0x9905, 0x0005, 0x00b6, 0x0126, 0x00c6, 0x0026, 0x2091,
+	0x8000, 0x6210, 0x2258, 0xba00, 0x9005, 0x0110, 0xc285, 0x0008,
+	0xc284, 0xba02, 0x002e, 0x00ce, 0x012e, 0x00be, 0x0005, 0x00b6,
+	0x0126, 0x00c6, 0x2091, 0x8000, 0x6210, 0x2258, 0xba04, 0x0006,
+	0x9086, 0x0006, 0x1170, 0xb89c, 0xd0ac, 0x0158, 0x080c, 0x62a0,
+	0x0140, 0x9284, 0xff00, 0x8007, 0x9086, 0x0007, 0x1110, 0x2011,
+	0x0600, 0x000e, 0x9294, 0xff00, 0x9215, 0xba06, 0x0006, 0x9086,
+	0x0006, 0x1120, 0xba90, 0x82ff, 0x090c, 0x0db2, 0x000e, 0x00ce,
+	0x012e, 0x00be, 0x0005, 0x00b6, 0x0126, 0x00c6, 0x2091, 0x8000,
+	0x6210, 0x2258, 0xba04, 0x0006, 0x9086, 0x0006, 0x1168, 0xb89c,
+	0xd0a4, 0x0150, 0x080c, 0x629c, 0x1138, 0x9284, 0x00ff, 0x9086,
+	0x0007, 0x1110, 0x2011, 0x0006, 0x000e, 0x9294, 0x00ff, 0x8007,
+	0x9215, 0xba06, 0x00ce, 0x012e, 0x00be, 0x0005, 0x9182, 0x0800,
+	0x0218, 0x9085, 0x0001, 0x0005, 0x00d6, 0x0026, 0x9190, 0x1000,
+	0x2204, 0x905d, 0x1180, 0x0096, 0x080c, 0x0fd5, 0x2958, 0x009e,
+	0x0160, 0x2b00, 0x2012, 0xb85c, 0xb8ba, 0xb860, 0xb8b6, 0x9006,
+	0xb8a6, 0x080c, 0x5a3b, 0x9006, 0x0010, 0x9085, 0x0001, 0x002e,
+	0x00de, 0x0005, 0x00b6, 0x0096, 0x0126, 0x2091, 0x8000, 0x0026,
+	0x9182, 0x0800, 0x0218, 0x9085, 0x0001, 0x0458, 0x00d6, 0x9190,
+	0x1000, 0x2204, 0x905d, 0x0518, 0x2013, 0x0000, 0xb8a4, 0x904d,
+	0x0110, 0x080c, 0x1007, 0x00d6, 0x00c6, 0xb8ac, 0x2060, 0x8cff,
+	0x0168, 0x600c, 0x0006, 0x6014, 0x2048, 0x080c, 0xb5fb, 0x0110,
+	0x080c, 0x0f87, 0x080c, 0x99d6, 0x00ce, 0x0c88, 0x00ce, 0x00de,
+	0x2b48, 0xb8b8, 0xb85e, 0xb8b4, 0xb862, 0x080c, 0x1017, 0x00de,
+	0x9006, 0x002e, 0x012e, 0x009e, 0x00be, 0x0005, 0x0016, 0x9182,
+	0x0800, 0x0218, 0x9085, 0x0001, 0x0030, 0x9188, 0x1000, 0x2104,
+	0x905d, 0x0dc0, 0x9006, 0x001e, 0x0005, 0x00d6, 0x0156, 0x0136,
+	0x0146, 0x9006, 0xb80a, 0xb80e, 0xb800, 0xc08c, 0xb802, 0x080c,
+	0x6c53, 0x1510, 0xb8a0, 0x9086, 0x007e, 0x0120, 0x080c, 0x9940,
+	0x11d8, 0x0078, 0x7040, 0xd0e4, 0x01b8, 0x00c6, 0x2061, 0x1951,
+	0x7048, 0x2062, 0x704c, 0x6006, 0x7050, 0x600a, 0x7054, 0x600e,
+	0x00ce, 0x703c, 0x2069, 0x0140, 0x9005, 0x1110, 0x2001, 0x0001,
+	0x6886, 0x2069, 0x1800, 0x68ae, 0x7040, 0xb85e, 0x7048, 0xb862,
+	0x704c, 0xb866, 0x20e1, 0x0000, 0x2099, 0x0276, 0xb8b4, 0x20e8,
+	0xb8b8, 0x9088, 0x000a, 0x21a0, 0x20a9, 0x0004, 0x4003, 0x2099,
+	0x027a, 0x9088, 0x0006, 0x21a0, 0x20a9, 0x0004, 0x4003, 0x2069,
+	0x0200, 0x6817, 0x0001, 0x7040, 0xb86a, 0x7144, 0xb96e, 0x7048,
+	0xb872, 0x7050, 0xb876, 0x2069, 0x0200, 0x6817, 0x0000, 0xb8a0,
+	0x9086, 0x007e, 0x1110, 0x7144, 0xb96e, 0x9182, 0x0211, 0x1218,
+	0x2009, 0x0008, 0x0400, 0x9182, 0x0259, 0x1218, 0x2009, 0x0007,
+	0x00d0, 0x9182, 0x02c1, 0x1218, 0x2009, 0x0006, 0x00a0, 0x9182,
+	0x0349, 0x1218, 0x2009, 0x0005, 0x0070, 0x9182, 0x0421, 0x1218,
+	0x2009, 0x0004, 0x0040, 0x9182, 0x0581, 0x1218, 0x2009, 0x0003,
+	0x0010, 0x2009, 0x0002, 0xb992, 0x014e, 0x013e, 0x015e, 0x00de,
+	0x0005, 0x0016, 0x0026, 0x00e6, 0x2071, 0x0260, 0x7034, 0xb896,
+	0x703c, 0xb89a, 0x7054, 0xb89e, 0x0036, 0xbbbc, 0xc384, 0xba00,
+	0x2009, 0x1873, 0x210c, 0xd0bc, 0x0120, 0xd1ec, 0x0110, 0xc2ad,
+	0x0008, 0xc2ac, 0xd0c4, 0x0148, 0xd1e4, 0x0138, 0xc2bd, 0xd0cc,
+	0x0128, 0xd38c, 0x1108, 0xc385, 0x0008, 0xc2bc, 0xba02, 0xbbbe,
+	0x003e, 0x00ee, 0x002e, 0x001e, 0x0005, 0x0096, 0x0126, 0x2091,
+	0x8000, 0xb8a4, 0x904d, 0x0578, 0xa900, 0x81ff, 0x15c0, 0xaa04,
+	0x9282, 0x0010, 0x16c8, 0x0136, 0x0146, 0x01c6, 0x01d6, 0x8906,
+	0x8006, 0x8007, 0x908c, 0x003f, 0x21e0, 0x9084, 0xffc0, 0x9080,
+	0x0004, 0x2098, 0x2009, 0x0010, 0x20a9, 0x0001, 0x4002, 0x9086,
+	0xffff, 0x0120, 0x8109, 0x1dd0, 0x080c, 0x0db2, 0x3c00, 0x20e8,
+	0x3300, 0x8001, 0x20a0, 0x4604, 0x8210, 0xaa06, 0x01de, 0x01ce,
+	0x014e, 0x013e, 0x0060, 0x080c, 0x0fd5, 0x0170, 0x2900, 0xb8a6,
+	0xa803, 0x0000, 0x080c, 0x613a, 0xa807, 0x0001, 0xae12, 0x9085,
+	0x0001, 0x012e, 0x009e, 0x0005, 0x9006, 0x0cd8, 0x0126, 0x2091,
+	0x8000, 0x0096, 0xb8a4, 0x904d, 0x0188, 0xa800, 0x9005, 0x1150,
+	0x080c, 0x6149, 0x1158, 0xa804, 0x908a, 0x0002, 0x0218, 0x8001,
+	0xa806, 0x0020, 0x080c, 0x1007, 0xb8a7, 0x0000, 0x009e, 0x012e,
+	0x0005, 0x0126, 0x2091, 0x8000, 0x080c, 0x801d, 0x012e, 0x0005,
+	0x901e, 0x0010, 0x2019, 0x0001, 0x900e, 0x0126, 0x2091, 0x8000,
+	0xb84c, 0x2048, 0xb800, 0xd0dc, 0x1170, 0x89ff, 0x0500, 0x83ff,
+	0x0120, 0xa878, 0x9606, 0x0158, 0x0030, 0xa86c, 0x9406, 0x1118,
+	0xa870, 0x9506, 0x0120, 0x2908, 0xa800, 0x2048, 0x0c70, 0x080c,
+	0x933f, 0xaa00, 0xb84c, 0x9906, 0x1110, 0xba4e, 0x0020, 0x00a6,
+	0x2150, 0xb202, 0x00ae, 0x82ff, 0x1110, 0xb952, 0x89ff, 0x012e,
+	0x0005, 0x9016, 0x0489, 0x1110, 0x2011, 0x0001, 0x0005, 0x080c,
+	0x619e, 0x0128, 0x080c, 0xb6c3, 0x0010, 0x9085, 0x0001, 0x0005,
+	0x080c, 0x619e, 0x0128, 0x080c, 0xb65d, 0x0010, 0x9085, 0x0001,
+	0x0005, 0x080c, 0x619e, 0x0128, 0x080c, 0xb6c0, 0x0010, 0x9085,
+	0x0001, 0x0005, 0x080c, 0x619e, 0x0128, 0x080c, 0xb681, 0x0010,
+	0x9085, 0x0001, 0x0005, 0x080c, 0x619e, 0x0128, 0x080c, 0xb6ed,
+	0x0010, 0x9085, 0x0001, 0x0005, 0xb8a4, 0x900d, 0x1118, 0x9085,
+	0x0001, 0x0005, 0x0136, 0x01c6, 0xa800, 0x9005, 0x11b8, 0x890e,
+	0x810e, 0x810f, 0x9184, 0x003f, 0x20e0, 0x9184, 0xffc0, 0x9080,
+	0x0004, 0x2098, 0x20a9, 0x0001, 0x2009, 0x0010, 0x4002, 0x9606,
+	0x0128, 0x8109, 0x1dd8, 0x9085, 0x0001, 0x0008, 0x9006, 0x01ce,
+	0x013e, 0x0005, 0x0146, 0x01d6, 0xa860, 0x20e8, 0xa85c, 0x9080,
+	0x0004, 0x20a0, 0x20a9, 0x0010, 0x2009, 0xffff, 0x4104, 0x01de,
+	0x014e, 0x0136, 0x01c6, 0xa800, 0x9005, 0x11b8, 0x890e, 0x810e,
+	0x810f, 0x9184, 0x003f, 0x20e0, 0x9184, 0xffc0, 0x9080, 0x0004,
+	0x2098, 0x20a9, 0x0001, 0x2009, 0x0010, 0x4002, 0x9606, 0x0128,
+	0x8109, 0x1dd8, 0x9085, 0x0001, 0x0068, 0x0146, 0x01d6, 0x3300,
+	0x8001, 0x20a0, 0x3c00, 0x20e8, 0x2001, 0xffff, 0x4004, 0x01de,
+	0x014e, 0x9006, 0x01ce, 0x013e, 0x0005, 0x0096, 0x0126, 0x2091,
+	0x8000, 0xb8a4, 0x904d, 0x1128, 0x080c, 0x0fd5, 0x0168, 0x2900,
+	0xb8a6, 0x080c, 0x613a, 0xa803, 0x0001, 0xa807, 0x0000, 0x9085,
+	0x0001, 0x012e, 0x009e, 0x0005, 0x9006, 0x0cd8, 0x0096, 0x0126,
+	0x2091, 0x8000, 0xb8a4, 0x904d, 0x0130, 0xb8a7, 0x0000, 0x080c,
+	0x1007, 0x9085, 0x0001, 0x012e, 0x009e, 0x0005, 0xb89c, 0xd0a4,
+	0x0005, 0x00b6, 0x00f6, 0x080c, 0x6c53, 0x01b0, 0x71bc, 0x81ff,
+	0x1198, 0x71d4, 0xd19c, 0x0180, 0x2001, 0x007e, 0x9080, 0x1000,
+	0x2004, 0x905d, 0x0148, 0xb804, 0x9084, 0x00ff, 0x9086, 0x0006,
+	0x1118, 0xb800, 0xc0ed, 0xb802, 0x2079, 0x1853, 0x7804, 0xd0a4,
+	0x01d0, 0x0156, 0x20a9, 0x007f, 0x900e, 0x0016, 0x080c, 0x5f7e,
+	0x1168, 0xb804, 0x9084, 0xff00, 0x8007, 0x9096, 0x0004, 0x0118,
+	0x9086, 0x0006, 0x1118, 0xb800, 0xc0ed, 0xb802, 0x001e, 0x8108,
+	0x1f04, 0x61c5, 0x015e, 0x080c, 0x6262, 0x0120, 0x2001, 0x1954,
+	0x200c, 0x0038, 0x2079, 0x1853, 0x7804, 0xd0a4, 0x0130, 0x2009,
+	0x07d0, 0x2011, 0x61f0, 0x080c, 0x7cd9, 0x00fe, 0x00be, 0x0005,
+	0x00b6, 0x2011, 0x61f0, 0x080c, 0x7c4a, 0x080c, 0x6262, 0x01d8,
+	0x2001, 0x107e, 0x2004, 0x2058, 0xb900, 0xc1ec, 0xb902, 0x080c,
+	0x62a0, 0x0130, 0x2009, 0x07d0, 0x2011, 0x61f0, 0x080c, 0x7cd9,
+	0x00e6, 0x2071, 0x1800, 0x9006, 0x7076, 0x7058, 0x707a, 0x080c,
+	0x2c2b, 0x00ee, 0x04b0, 0x0156, 0x00c6, 0x20a9, 0x007f, 0x900e,
+	0x0016, 0x080c, 0x5f7e, 0x1538, 0xb800, 0xd0ec, 0x0520, 0x0046,
+	0xbaa0, 0x2220, 0x9006, 0x2009, 0x0029, 0x080c, 0xcfe6, 0xb800,
+	0xc0e5, 0xc0ec, 0xb802, 0x080c, 0x629c, 0x2001, 0x0707, 0x1128,
+	0xb804, 0x9084, 0x00ff, 0x9085, 0x0700, 0xb806, 0x2019, 0x0029,
+	0x080c, 0x8180, 0x0076, 0x903e, 0x080c, 0x8078, 0x900e, 0x080c,
+	0xcd62, 0x007e, 0x004e, 0x001e, 0x8108, 0x1f04, 0x6218, 0x00ce,
+	0x015e, 0x00be, 0x0005, 0x00b6, 0x6010, 0x2058, 0xb800, 0xc0ec,
+	0xb802, 0x00be, 0x0005, 0x7810, 0x00b6, 0x2058, 0xb800, 0x00be,
+	0xd0ac, 0x0005, 0x6010, 0x00b6, 0x905d, 0x0108, 0xb800, 0x00be,
+	0xd0bc, 0x0005, 0x00b6, 0x00f6, 0x2001, 0x107e, 0x2004, 0x905d,
+	0x0110, 0xb800, 0xd0ec, 0x00fe, 0x00be, 0x0005, 0x0126, 0x0026,
+	0x2091, 0x8000, 0x0006, 0xbaa0, 0x9290, 0x1000, 0x2204, 0x9b06,
+	0x190c, 0x0db2, 0x000e, 0xba00, 0x9005, 0x0110, 0xc2fd, 0x0008,
+	0xc2fc, 0xba02, 0x002e, 0x012e, 0x0005, 0x2011, 0x1835, 0x2204,
+	0xd0cc, 0x0138, 0x2001, 0x1952, 0x200c, 0x2011, 0x6292, 0x080c,
+	0x7cd9, 0x0005, 0x2011, 0x6292, 0x080c, 0x7c4a, 0x2011, 0x1835,
+	0x2204, 0xc0cc, 0x2012, 0x0005, 0x080c, 0x5113, 0xd0ac, 0x0005,
+	0x080c, 0x5113, 0xd0a4, 0x0005, 0x0016, 0xb904, 0x9184, 0x00ff,
+	0x908e, 0x0006, 0x001e, 0x0005, 0x0016, 0xb904, 0x9184, 0xff00,
+	0x8007, 0x908e, 0x0006, 0x001e, 0x0005, 0x00b6, 0x00f6, 0x080c,
+	0xbcec, 0x0158, 0x70d4, 0x9084, 0x0028, 0x0138, 0x2001, 0x107f,
+	0x2004, 0x905d, 0x0110, 0xb8bc, 0xd094, 0x00fe, 0x00be, 0x0005,
+	0x2071, 0x1906, 0x7003, 0x0001, 0x7007, 0x0000, 0x9006, 0x7012,
+	0x7016, 0x701a, 0x701e, 0x700a, 0x7046, 0x2001, 0x1919, 0x2003,
+	0x0000, 0x0005, 0x0016, 0x00e6, 0x2071, 0x191a, 0x900e, 0x710a,
+	0x080c, 0x5113, 0xd0fc, 0x1140, 0x080c, 0x5113, 0x900e, 0xd09c,
+	0x0108, 0x8108, 0x7102, 0x00f8, 0x2001, 0x1873, 0x200c, 0x9184,
+	0x0007, 0x0002, 0x62e4, 0x62e4, 0x62e4, 0x62e4, 0x62e4, 0x62fa,
+	0x6308, 0x62e4, 0x7003, 0x0003, 0x2009, 0x1874, 0x210c, 0x9184,
+	0xff00, 0x8007, 0x9005, 0x1110, 0x2001, 0x0002, 0x7006, 0x0018,
+	0x7003, 0x0005, 0x0c88, 0x00ee, 0x001e, 0x0005, 0x00e6, 0x2071,
+	0x0050, 0x684c, 0x9005, 0x1150, 0x00e6, 0x2071, 0x1906, 0x7028,
+	0xc085, 0x702a, 0x00ee, 0x9085, 0x0001, 0x0488, 0x6844, 0x9005,
+	0x0158, 0x080c, 0x6f9c, 0x6a60, 0x9200, 0x7002, 0x6864, 0x9101,
+	0x7006, 0x9006, 0x7012, 0x7016, 0x6860, 0x7002, 0x6864, 0x7006,
+	0x6868, 0x700a, 0x686c, 0x700e, 0x6844, 0x9005, 0x1110, 0x7012,
+	0x7016, 0x684c, 0x701a, 0x701c, 0x9085, 0x0040, 0x701e, 0x7037,
+	0x0019, 0x702b, 0x0001, 0x00e6, 0x2071, 0x1906, 0x7028, 0xc084,
+	0x702a, 0x7007, 0x0001, 0x700b, 0x0000, 0x00ee, 0x9006, 0x00ee,
+	0x0005, 0xa868, 0xd0fc, 0x11d8, 0x00e6, 0x0026, 0x2001, 0x191a,
+	0x2004, 0x9005, 0x0904, 0x653b, 0xa87c, 0xd0bc, 0x1904, 0x653b,
+	0xa978, 0xa874, 0x9105, 0x1904, 0x653b, 0x2001, 0x191a, 0x2004,
+	0x0002, 0x653b, 0x6394, 0x63d0, 0x63d0, 0x653b, 0x63d0, 0x0005,
+	0xa868, 0xd0fc, 0x1500, 0x00e6, 0x0026, 0x2009, 0x191a, 0x210c,
+	0x81ff, 0x0904, 0x653b, 0xa87c, 0xd0cc, 0x0904, 0x653b, 0xa880,
+	0x9084, 0x00ff, 0x9086, 0x0001, 0x1904, 0x653b, 0x9186, 0x0003,
+	0x0904, 0x63d0, 0x9186, 0x0005, 0x0904, 0x63d0, 0xa84f, 0x8021,
+	0xa853, 0x0017, 0x0028, 0x0005, 0xa84f, 0x8020, 0xa853, 0x0016,
+	0x2071, 0x1906, 0x701c, 0x9005, 0x1904, 0x66fb, 0x0e04, 0x6746,
+	0x2071, 0x0000, 0xa84c, 0x7082, 0xa850, 0x7032, 0xa86c, 0x7086,
+	0x7036, 0xa870, 0x708a, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004,
+	0xd084, 0x190c, 0x1167, 0x2071, 0x1800, 0x2011, 0x0001, 0xa804,
+	0x900d, 0x702c, 0x1158, 0xa802, 0x2900, 0x702e, 0x70b8, 0x9200,
+	0x70ba, 0x080c, 0x7b7c, 0x002e, 0x00ee, 0x0005, 0x0096, 0x2148,
+	0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x009e, 0x0c58,
+	0xa84f, 0x0000, 0x00f6, 0x2079, 0x0050, 0x2071, 0x1906, 0xa803,
+	0x0000, 0x7010, 0x9005, 0x1904, 0x64bf, 0x782c, 0x908c, 0x0780,
+	0x190c, 0x686d, 0x8004, 0x8004, 0x8004, 0x9084, 0x0003, 0x0002,
+	0x63ee, 0x64bf, 0x6413, 0x645a, 0x080c, 0x0db2, 0x2071, 0x1800,
+	0x2900, 0x7822, 0xa804, 0x900d, 0x1170, 0x2071, 0x19c9, 0x703c,
+	0x9005, 0x1328, 0x2001, 0x191b, 0x2004, 0x8005, 0x703e, 0x00fe,
+	0x002e, 0x00ee, 0x0005, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802,
+	0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70b8, 0x9200, 0x70ba,
+	0x080c, 0x7b7c, 0x0c10, 0x2071, 0x1800, 0x2900, 0x7822, 0xa804,
+	0x900d, 0x1580, 0x7824, 0x00e6, 0x2071, 0x0040, 0x712c, 0xd19c,
+	0x1148, 0x2009, 0x182e, 0x210c, 0x918a, 0x0040, 0x0218, 0x7022,
+	0x00ee, 0x0058, 0x00ee, 0x2048, 0x702c, 0xa802, 0x2900, 0x702e,
+	0x70b8, 0x8000, 0x70ba, 0x080c, 0x7b7c, 0x782c, 0x9094, 0x0780,
+	0x190c, 0x686d, 0xd0a4, 0x19f0, 0x2071, 0x19c9, 0x703c, 0x9005,
+	0x1328, 0x2001, 0x191b, 0x2004, 0x8005, 0x703e, 0x00fe, 0x002e,
+	0x00ee, 0x0005, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210,
+	0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70b8, 0x9200, 0x70ba, 0x080c,
+	0x7b7c, 0x0800, 0x0096, 0x00e6, 0x7824, 0x2048, 0x2071, 0x1800,
+	0x702c, 0xa802, 0x2900, 0x702e, 0x70b8, 0x8000, 0x70ba, 0x080c,
+	0x7b7c, 0x782c, 0x9094, 0x0780, 0x190c, 0x686d, 0xd0a4, 0x1d60,
+	0x00ee, 0x782c, 0x9094, 0x0780, 0x190c, 0x686d, 0xd09c, 0x11a0,
+	0x009e, 0x2900, 0x7822, 0xa804, 0x900d, 0x1560, 0x2071, 0x19c9,
+	0x703c, 0x9005, 0x1328, 0x2001, 0x191b, 0x2004, 0x8005, 0x703e,
+	0x00fe, 0x002e, 0x00ee, 0x0005, 0x009e, 0x2908, 0x7010, 0x8000,
+	0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902, 0x0008, 0x711e,
+	0x2148, 0xa804, 0x900d, 0x1170, 0x2071, 0x19c9, 0x703c, 0x9005,
+	0x1328, 0x2001, 0x191b, 0x2004, 0x8005, 0x703e, 0x00fe, 0x002e,
+	0x00ee, 0x0005, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148, 0xa904,
+	0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70b8, 0x9200,
+	0x70ba, 0x080c, 0x7b7c, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x2908,
+	0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902,
+	0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1904, 0x6514, 0x782c,
+	0x9094, 0x0780, 0x190c, 0x686d, 0xd09c, 0x1198, 0x701c, 0x904d,
+	0x0180, 0x7010, 0x8001, 0x7012, 0x1108, 0x701a, 0xa800, 0x701e,
+	0x2900, 0x7822, 0x782c, 0x9094, 0x0780, 0x190c, 0x686d, 0xd09c,
+	0x0d68, 0x782c, 0x9094, 0x0780, 0x190c, 0x686d, 0xd0a4, 0x01b0,
+	0x00e6, 0x7824, 0x2048, 0x2071, 0x1800, 0x702c, 0xa802, 0x2900,
+	0x702e, 0x70b8, 0x8000, 0x70ba, 0x080c, 0x7b7c, 0x782c, 0x9094,
+	0x0780, 0x190c, 0x686d, 0xd0a4, 0x1d60, 0x00ee, 0x2071, 0x19c9,
+	0x703c, 0x9005, 0x1328, 0x2001, 0x191b, 0x2004, 0x8005, 0x703e,
+	0x00fe, 0x002e, 0x00ee, 0x0005, 0x00e6, 0x2071, 0x1800, 0x9016,
+	0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8,
+	0x702e, 0x70b8, 0x9200, 0x70ba, 0x080c, 0x7b7c, 0x00ee, 0x0804,
+	0x64cf, 0xa868, 0xd0fc, 0x1904, 0x6577, 0x0096, 0xa804, 0xa807,
+	0x0000, 0x904d, 0x190c, 0x0f87, 0x009e, 0x0018, 0xa868, 0xd0fc,
+	0x15f0, 0x00e6, 0x0026, 0xa84f, 0x0000, 0x00f6, 0x2079, 0x0050,
+	0x2071, 0x1800, 0x70e4, 0x8001, 0x01d0, 0x1678, 0x2071, 0x1906,
+	0xa803, 0x0000, 0x7010, 0x9005, 0x1904, 0x6675, 0x782c, 0x908c,
+	0x0780, 0x190c, 0x686d, 0x8004, 0x8004, 0x8004, 0x9084, 0x0003,
+	0x0002, 0x6578, 0x6675, 0x6593, 0x6604, 0x080c, 0x0db2, 0x70e7,
+	0x0fa0, 0x71e0, 0x8107, 0x9106, 0x9094, 0x00c0, 0x9184, 0xff3f,
+	0x9205, 0x70e2, 0x3b08, 0x3a00, 0x9104, 0x918d, 0x00c0, 0x21d8,
+	0x9084, 0xff3f, 0x9205, 0x20d0, 0x0888, 0x70e6, 0x0878, 0x0005,
+	0x2071, 0x1800, 0x2900, 0x7822, 0xa804, 0x900d, 0x1120, 0x00fe,
+	0x002e, 0x00ee, 0x0005, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802,
+	0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70b8, 0x9200, 0x70ba,
+	0x080c, 0x7b7c, 0x0c60, 0x2071, 0x1800, 0x2900, 0x7822, 0xa804,
+	0x900d, 0x1904, 0x65f3, 0x7830, 0x8007, 0x9084, 0x001f, 0x9082,
+	0x0005, 0x1220, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x7824, 0x00e6,
+	0x2071, 0x0040, 0x712c, 0xd19c, 0x1148, 0x2009, 0x182e, 0x210c,
+	0x918a, 0x0040, 0x0218, 0x7022, 0x00ee, 0x0058, 0x00ee, 0x2048,
+	0x702c, 0xa802, 0x2900, 0x702e, 0x70b8, 0x8000, 0x70ba, 0x080c,
+	0x7b7c, 0x782c, 0x9094, 0x0780, 0x190c, 0x686d, 0xd0a4, 0x19f0,
+	0x0e04, 0x65ea, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069,
+	0x0000, 0x6836, 0x6833, 0x0013, 0x00de, 0x2001, 0x1917, 0x200c,
+	0xc184, 0x2102, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084,
+	0x190c, 0x1167, 0x2009, 0x1919, 0x200b, 0x0000, 0x00fe, 0x002e,
+	0x00ee, 0x0005, 0x2001, 0x1917, 0x200c, 0xc185, 0x2102, 0x00fe,
+	0x002e, 0x00ee, 0x0005, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802,
+	0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70b8, 0x9200, 0x70ba,
+	0x080c, 0x7b7c, 0x0804, 0x65a6, 0x0096, 0x00e6, 0x7824, 0x2048,
+	0x2071, 0x1800, 0x702c, 0xa802, 0x2900, 0x702e, 0x70b8, 0x8000,
+	0x70ba, 0x080c, 0x7b7c, 0x782c, 0x9094, 0x0780, 0x190c, 0x686d,
+	0xd0a4, 0x1d60, 0x00ee, 0x0e04, 0x6648, 0x7838, 0x7938, 0x910e,
+	0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836, 0x6833, 0x0013, 0x00de,
+	0x7044, 0xc084, 0x7046, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004,
+	0xd084, 0x190c, 0x1167, 0x2009, 0x1919, 0x200b, 0x0000, 0x782c,
+	0x9094, 0x0780, 0x190c, 0x686d, 0xd09c, 0x1170, 0x009e, 0x2900,
+	0x7822, 0xa804, 0x900d, 0x11e0, 0x00fe, 0x002e, 0x00ee, 0x0005,
+	0x7044, 0xc085, 0x7046, 0x0c58, 0x009e, 0x2908, 0x7010, 0x8000,
+	0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902, 0x0008, 0x711e,
+	0x2148, 0xa804, 0x900d, 0x1120, 0x00fe, 0x002e, 0x00ee, 0x0005,
+	0x2071, 0x1800, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210,
+	0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70b8, 0x9200, 0x70ba, 0x080c,
+	0x7b7c, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x2908, 0x7010, 0x8000,
+	0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902, 0x0008, 0x711e,
+	0x2148, 0xa804, 0x900d, 0x1904, 0x66e6, 0x782c, 0x9094, 0x0780,
+	0x190c, 0x686d, 0xd09c, 0x11b0, 0x701c, 0x904d, 0x0198, 0xa84c,
+	0x9005, 0x1180, 0x7010, 0x8001, 0x7012, 0x1108, 0x701a, 0xa800,
+	0x701e, 0x2900, 0x7822, 0x782c, 0x9094, 0x0780, 0x190c, 0x686d,
+	0xd09c, 0x0d50, 0x782c, 0x9094, 0x0780, 0x190c, 0x686d, 0xd0a4,
+	0x05c8, 0x00e6, 0x7824, 0x2048, 0x2071, 0x1800, 0x702c, 0xa802,
+	0x2900, 0x702e, 0x70b8, 0x8000, 0x70ba, 0x080c, 0x7b7c, 0x782c,
+	0x9094, 0x0780, 0x190c, 0x686d, 0xd0a4, 0x1d60, 0x00ee, 0x0e04,
+	0x66df, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000,
+	0x6836, 0x6833, 0x0013, 0x00de, 0x7044, 0xc084, 0x7046, 0x2091,
+	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x1167, 0x2009,
+	0x1919, 0x200b, 0x0000, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x7044,
+	0xc085, 0x7046, 0x00fe, 0x002e, 0x00ee, 0x0005, 0x00e6, 0x2071,
+	0x1800, 0x9016, 0x702c, 0x2148, 0xa904, 0xa802, 0x8210, 0x2900,
+	0x81ff, 0x1dc8, 0x702e, 0x70b8, 0x9200, 0x70ba, 0x080c, 0x7b7c,
+	0x00ee, 0x0804, 0x6685, 0x2071, 0x1906, 0xa803, 0x0000, 0x2908,
+	0x7010, 0x8000, 0x7012, 0x7018, 0x904d, 0x711a, 0x0110, 0xa902,
+	0x0008, 0x711e, 0x2148, 0xa804, 0x900d, 0x1128, 0x1e04, 0x6726,
+	0x002e, 0x00ee, 0x0005, 0x2071, 0x1800, 0x9016, 0x702c, 0x2148,
+	0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e, 0x70b8,
+	0x9200, 0x70ba, 0x080c, 0x7b7c, 0x0e04, 0x6710, 0x2071, 0x1906,
+	0x701c, 0x2048, 0xa84c, 0x900d, 0x0d18, 0x2071, 0x0000, 0x7182,
+	0xa850, 0x7032, 0xa86c, 0x7086, 0x7036, 0xa870, 0x708a, 0x2091,
+	0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x1167, 0x2071,
+	0x1906, 0x080c, 0x6859, 0x002e, 0x00ee, 0x0005, 0x2071, 0x1906,
+	0xa803, 0x0000, 0x2908, 0x7010, 0x8000, 0x7012, 0x7018, 0x904d,
+	0x711a, 0x0110, 0xa902, 0x0008, 0x711e, 0x2148, 0xa804, 0x900d,
+	0x1118, 0x002e, 0x00ee, 0x0005, 0x2071, 0x1800, 0x9016, 0x702c,
+	0x2148, 0xa904, 0xa802, 0x8210, 0x2900, 0x81ff, 0x1dc8, 0x702e,
+	0x70b8, 0x9200, 0x70ba, 0x080c, 0x7b7c, 0x002e, 0x00ee, 0x0005,
+	0x0006, 0xa87c, 0x0006, 0xa867, 0x0103, 0x20a9, 0x001c, 0xa860,
+	0x20e8, 0xa85c, 0x9080, 0x001d, 0x20a0, 0x9006, 0x4004, 0x000e,
+	0x9084, 0x00ff, 0xa87e, 0x000e, 0xa87a, 0xa982, 0x0005, 0x2071,
+	0x1906, 0x7004, 0x0002, 0x6791, 0x6792, 0x6858, 0x6792, 0x0db2,
+	0x6858, 0x0005, 0x2001, 0x191a, 0x2004, 0x0002, 0x679c, 0x679c,
+	0x67f1, 0x67f2, 0x679c, 0x67f2, 0x0126, 0x2091, 0x8000, 0x1e0c,
+	0x6878, 0x701c, 0x904d, 0x01e0, 0xa84c, 0x9005, 0x01d8, 0x0e04,
+	0x67c0, 0xa94c, 0x2071, 0x0000, 0x7182, 0xa850, 0x7032, 0xa86c,
+	0x7086, 0x7036, 0xa870, 0x708a, 0x2091, 0x4080, 0x2001, 0x0089,
+	0x2004, 0xd084, 0x190c, 0x1167, 0x2071, 0x1906, 0x080c, 0x6859,
+	0x012e, 0x0470, 0x2001, 0x005b, 0x2004, 0x9094, 0x0780, 0x190c,
+	0x686d, 0xd09c, 0x2071, 0x1906, 0x1510, 0x2071, 0x1906, 0x700f,
+	0x0001, 0xa964, 0x9184, 0x00ff, 0x9086, 0x0003, 0x1130, 0x810f,
+	0x918c, 0x00ff, 0x8101, 0x0108, 0x710e, 0x2900, 0x00d6, 0x2069,
+	0x0050, 0x6822, 0x00de, 0x2071, 0x1906, 0x701c, 0x2048, 0x7010,
+	0x8001, 0x7012, 0xa800, 0x701e, 0x9005, 0x1108, 0x701a, 0x012e,
+	0x0005, 0x0005, 0x00d6, 0x2008, 0x2069, 0x19c9, 0x683c, 0x9005,
+	0x0760, 0x0158, 0x9186, 0x0003, 0x0540, 0x2001, 0x1813, 0x2004,
+	0x2009, 0x1a8b, 0x210c, 0x9102, 0x1500, 0x0126, 0x2091, 0x8000,
+	0x2069, 0x0050, 0x693c, 0x6838, 0x9106, 0x0190, 0x0e04, 0x6824,
+	0x2069, 0x0000, 0x6837, 0x8040, 0x6833, 0x0012, 0x6883, 0x8040,
+	0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c, 0x1167,
+	0x2069, 0x19c9, 0x683f, 0xffff, 0x012e, 0x00de, 0x0126, 0x2091,
+	0x8000, 0x1e0c, 0x68e9, 0x701c, 0x904d, 0x0540, 0x2001, 0x005b,
+	0x2004, 0x9094, 0x0780, 0x15c9, 0xd09c, 0x1500, 0x2071, 0x1906,
+	0x700f, 0x0001, 0xa964, 0x9184, 0x00ff, 0x9086, 0x0003, 0x1130,
+	0x810f, 0x918c, 0x00ff, 0x8101, 0x0108, 0x710e, 0x2900, 0x00d6,
+	0x2069, 0x0050, 0x6822, 0x00de, 0x701c, 0x2048, 0x7010, 0x8001,
+	0x7012, 0xa800, 0x701e, 0x9005, 0x1108, 0x701a, 0x012e, 0x0005,
+	0x0005, 0x0126, 0x2091, 0x8000, 0x701c, 0x904d, 0x0160, 0x7010,
+	0x8001, 0x7012, 0xa800, 0x701e, 0x9005, 0x1108, 0x701a, 0x012e,
+	0x080c, 0x1007, 0x0005, 0x012e, 0x0005, 0x2091, 0x8000, 0x0e04,
+	0x686f, 0x0006, 0x0016, 0x2001, 0x8004, 0x0006, 0x0804, 0x0dbb,
+	0x0096, 0x00f6, 0x2079, 0x0050, 0x7044, 0xd084, 0x01e0, 0xc084,
+	0x7046, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000,
+	0x6836, 0x6833, 0x0013, 0x00de, 0x2091, 0x4080, 0x2001, 0x0089,
+	0x2004, 0xd084, 0x190c, 0x1167, 0x2009, 0x1919, 0x200b, 0x0000,
+	0x00fe, 0x009e, 0x0005, 0x782c, 0x9094, 0x0780, 0x1971, 0xd0a4,
+	0x0db8, 0x2009, 0x1919, 0x2104, 0x8000, 0x200a, 0x9082, 0x000f,
+	0x0e78, 0x00e6, 0x2071, 0x1800, 0x7824, 0x00e6, 0x2071, 0x0040,
+	0x712c, 0xd19c, 0x1148, 0x2009, 0x182e, 0x210c, 0x918a, 0x0040,
+	0x0218, 0x7022, 0x00ee, 0x0058, 0x00ee, 0x2048, 0x702c, 0xa802,
+	0x2900, 0x702e, 0x70b8, 0x8000, 0x70ba, 0x080c, 0x7b7c, 0x782c,
+	0x9094, 0x0780, 0x190c, 0x686d, 0xd0a4, 0x19f0, 0x7838, 0x7938,
+	0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000, 0x6836, 0x6833, 0x0013,
+	0x00de, 0x2091, 0x4080, 0x2001, 0x0089, 0x2004, 0xd084, 0x190c,
+	0x1167, 0x2009, 0x1919, 0x200b, 0x0000, 0x00ee, 0x00fe, 0x009e,
+	0x0005, 0x00f6, 0x2079, 0x0050, 0x7044, 0xd084, 0x01b8, 0xc084,
+	0x7046, 0x7838, 0x7938, 0x910e, 0x1de0, 0x00d6, 0x2069, 0x0000,
+	0x6836, 0x6833, 0x0013, 0x00de, 0x2091, 0x4080, 0x2001, 0x0089,
+	0x2004, 0xd084, 0x190c, 0x1167, 0x00fe, 0x0005, 0x782c, 0x9094,
+	0x0780, 0x190c, 0x686d, 0xd0a4, 0x0db8, 0x00e6, 0x2071, 0x1800,
+	0x7824, 0x2048, 0x702c, 0xa802, 0x2900, 0x702e, 0x70b8, 0x8000,
+	0x70ba, 0x080c, 0x7b7c, 0x782c, 0x9094, 0x0780, 0x190c, 0x686d,
+	0xd0a4, 0x1d70, 0x00d6, 0x2069, 0x0050, 0x693c, 0x2069, 0x191a,
+	0x6808, 0x690a, 0x2069, 0x19c9, 0x9102, 0x1118, 0x683c, 0x9005,
+	0x1328, 0x2001, 0x191b, 0x200c, 0x810d, 0x693e, 0x00de, 0x00ee,
+	0x00fe, 0x0005, 0x7090, 0x908a, 0x0029, 0x1a0c, 0x0db2, 0x9082,
+	0x001d, 0x001b, 0x6027, 0x1e00, 0x0005, 0x6a0d, 0x6997, 0x69b3,
+	0x69db, 0x69fc, 0x6a3c, 0x6a4e, 0x69b3, 0x6a24, 0x6952, 0x6980,
+	0x6951, 0x0005, 0x00d6, 0x2069, 0x0200, 0x6804, 0x9005, 0x1180,
+	0x6808, 0x9005, 0x1518, 0x7093, 0x0028, 0x2069, 0x195e, 0x2d04,
+	0x7002, 0x080c, 0x6d8d, 0x6028, 0x9085, 0x0600, 0x602a, 0x00b0,
+	0x7093, 0x0028, 0x2069, 0x195e, 0x2d04, 0x7002, 0x6028, 0x9085,
+	0x0600, 0x602a, 0x00e6, 0x0036, 0x0046, 0x0056, 0x2071, 0x1a31,
+	0x080c, 0x1872, 0x005e, 0x004e, 0x003e, 0x00ee, 0x00de, 0x0005,
+	0x00d6, 0x2069, 0x0200, 0x6804, 0x9005, 0x1178, 0x6808, 0x9005,
+	0x1160, 0x7093, 0x0028, 0x2069, 0x195e, 0x2d04, 0x7002, 0x080c,
+	0x6e17, 0x6028, 0x9085, 0x0600, 0x602a, 0x00de, 0x0005, 0x0006,
+	0x2001, 0x0090, 0x080c, 0x2987, 0x000e, 0x6124, 0xd1e4, 0x1190,
+	0x080c, 0x6abb, 0xd1d4, 0x1160, 0xd1dc, 0x1138, 0xd1cc, 0x0150,
+	0x7093, 0x0020, 0x080c, 0x6abb, 0x0028, 0x7093, 0x001d, 0x0010,
+	0x7093, 0x001f, 0x0005, 0x2001, 0x0088, 0x080c, 0x2987, 0x6124,
+	0xd1cc, 0x11d8, 0xd1dc, 0x11b0, 0xd1e4, 0x1188, 0x9184, 0x1e00,
+	0x11c8, 0x60e3, 0x0001, 0x600c, 0xc0b4, 0x600e, 0x080c, 0x6c7f,
+	0x2001, 0x0080, 0x080c, 0x2987, 0x7093, 0x0028, 0x0058, 0x7093,
+	0x001e, 0x0040, 0x7093, 0x001d, 0x0028, 0x7093, 0x0020, 0x0010,
+	0x7093, 0x001f, 0x0005, 0x60e3, 0x0001, 0x600c, 0xc0b4, 0x600e,
+	0x080c, 0x6c7f, 0x2001, 0x0080, 0x080c, 0x2987, 0x6124, 0xd1d4,
+	0x1180, 0xd1dc, 0x1158, 0xd1e4, 0x1130, 0x9184, 0x1e00, 0x1158,
+	0x7093, 0x0028, 0x0040, 0x7093, 0x001e, 0x0028, 0x7093, 0x001d,
+	0x0010, 0x7093, 0x001f, 0x0005, 0x2001, 0x00a0, 0x080c, 0x2987,
+	0x6124, 0xd1dc, 0x1138, 0xd1e4, 0x0138, 0x080c, 0x189c, 0x7093,
+	0x001e, 0x0010, 0x7093, 0x001d, 0x0005, 0x080c, 0x6b3e, 0x6124,
+	0xd1dc, 0x1188, 0x080c, 0x6abb, 0x0016, 0x080c, 0x189c, 0x001e,
+	0xd1d4, 0x1128, 0xd1e4, 0x0138, 0x7093, 0x001e, 0x0020, 0x7093,
+	0x001f, 0x080c, 0x6abb, 0x0005, 0x0006, 0x2001, 0x00a0, 0x080c,
+	0x2987, 0x000e, 0x6124, 0xd1d4, 0x1160, 0xd1cc, 0x1150, 0xd1dc,
+	0x1128, 0xd1e4, 0x0140, 0x7093, 0x001e, 0x0028, 0x7093, 0x001d,
+	0x0010, 0x7093, 0x0021, 0x0005, 0x080c, 0x6b3e, 0x6124, 0xd1d4,
+	0x1150, 0xd1dc, 0x1128, 0xd1e4, 0x0140, 0x7093, 0x001e, 0x0028,
+	0x7093, 0x001d, 0x0010, 0x7093, 0x001f, 0x0005, 0x0006, 0x2001,
+	0x0090, 0x080c, 0x2987, 0x000e, 0x6124, 0xd1d4, 0x1178, 0xd1cc,
+	0x1150, 0xd1dc, 0x1128, 0xd1e4, 0x0158, 0x7093, 0x001e, 0x0040,
+	0x7093, 0x001d, 0x0028, 0x7093, 0x0020, 0x0010, 0x7093, 0x001f,
+	0x0005, 0x0016, 0x00c6, 0x00d6, 0x00e6, 0x0126, 0x2061, 0x0100,
+	0x2069, 0x0140, 0x2071, 0x1800, 0x2091, 0x8000, 0x080c, 0x6c53,
+	0x11d8, 0x2001, 0x180c, 0x200c, 0xd1b4, 0x01b0, 0xc1b4, 0x2102,
+	0x6027, 0x0200, 0x080c, 0x28d0, 0x6024, 0xd0cc, 0x0148, 0x2001,
+	0x00a0, 0x080c, 0x2987, 0x080c, 0x6f2a, 0x080c, 0x5a21, 0x0428,
+	0x6028, 0xc0cd, 0x602a, 0x0408, 0x080c, 0x6c6d, 0x0150, 0x080c,
+	0x6c64, 0x1138, 0x2001, 0x0001, 0x080c, 0x247f, 0x080c, 0x6c2d,
+	0x00a0, 0x080c, 0x6b3b, 0x0178, 0x2001, 0x0001, 0x080c, 0x247f,
+	0x7090, 0x9086, 0x001e, 0x0120, 0x7090, 0x9086, 0x0022, 0x1118,
+	0x7093, 0x0025, 0x0010, 0x7093, 0x0021, 0x012e, 0x00ee, 0x00de,
+	0x00ce, 0x001e, 0x0005, 0x0026, 0x2011, 0x6acc, 0x080c, 0x7d1b,
+	0x002e, 0x0016, 0x0026, 0x2009, 0x0064, 0x2011, 0x6acc, 0x080c,
+	0x7d12, 0x002e, 0x001e, 0x0005, 0x00e6, 0x00f6, 0x0016, 0x080c,
+	0x8fbb, 0x2071, 0x1800, 0x080c, 0x6a69, 0x001e, 0x00fe, 0x00ee,
+	0x0005, 0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6, 0x00e6, 0x00f6,
+	0x0126, 0x080c, 0x8fbb, 0x2061, 0x0100, 0x2069, 0x0140, 0x2071,
+	0x1800, 0x2091, 0x8000, 0x6028, 0xc09c, 0x602a, 0x2011, 0x0003,
+	0x080c, 0x92ec, 0x2011, 0x0002, 0x080c, 0x92f6, 0x080c, 0x91de,
+	0x080c, 0x7cc7, 0x0036, 0x901e, 0x080c, 0x9254, 0x003e, 0x60e3,
+	0x0000, 0x080c, 0xd343, 0x080c, 0xd35e, 0x2009, 0x0004, 0x080c,
+	0x28d6, 0x080c, 0x27f1, 0x2001, 0x1800, 0x2003, 0x0004, 0x6027,
+	0x0008, 0x2011, 0x6acc, 0x080c, 0x7d1b, 0x080c, 0x6c6d, 0x0118,
+	0x9006, 0x080c, 0x2987, 0x080c, 0x0b94, 0x2001, 0x0001, 0x080c,
+	0x247f, 0x012e, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x003e, 0x002e,
+	0x001e, 0x0005, 0x0026, 0x00e6, 0x2011, 0x6ad9, 0x2071, 0x19c9,
+	0x701c, 0x9206, 0x1118, 0x7018, 0x9005, 0x0110, 0x9085, 0x0001,
+	0x00ee, 0x002e, 0x0005, 0x6020, 0xd09c, 0x0005, 0x6800, 0x9084,
+	0xfffe, 0x9086, 0x00c0, 0x01b8, 0x2001, 0x00c0, 0x080c, 0x2987,
+	0x0156, 0x20a9, 0x002d, 0x1d04, 0x6b4b, 0x2091, 0x6000, 0x1f04,
+	0x6b4b, 0x015e, 0x00d6, 0x2069, 0x1800, 0x6894, 0x8001, 0x0220,
+	0x0118, 0x6896, 0x00de, 0x0005, 0x6897, 0x0014, 0x68e0, 0xd0dc,
+	0x0dc8, 0x6800, 0x9086, 0x0001, 0x1da8, 0x080c, 0x7d27, 0x0c90,
+	0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100, 0x2069, 0x0140, 0x2071,
+	0x1800, 0x080c, 0x6f39, 0x2001, 0x193e, 0x2003, 0x0000, 0x9006,
+	0x7092, 0x60e2, 0x6886, 0x080c, 0x254a, 0x9006, 0x080c, 0x2987,
+	0x080c, 0x58e0, 0x6027, 0xffff, 0x602b, 0x182f, 0x00ee, 0x00de,
+	0x00ce, 0x0005, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100, 0x2069,
+	0x0140, 0x2071, 0x1800, 0x2001, 0x194e, 0x200c, 0x9186, 0x0000,
+	0x0158, 0x9186, 0x0001, 0x0158, 0x9186, 0x0002, 0x0158, 0x9186,
+	0x0003, 0x0158, 0x0804, 0x6c1d, 0x7093, 0x0022, 0x0040, 0x7093,
+	0x0021, 0x0028, 0x7093, 0x0023, 0x0010, 0x7093, 0x0024, 0x60e3,
+	0x0000, 0x6887, 0x0001, 0x2001, 0x0001, 0x080c, 0x254a, 0x0026,
+	0x080c, 0x9947, 0x002e, 0x7000, 0x908e, 0x0004, 0x0118, 0x602b,
+	0x0028, 0x0010, 0x602b, 0x0020, 0x0156, 0x0126, 0x2091, 0x8000,
+	0x20a9, 0x0005, 0x6024, 0xd0ac, 0x0150, 0x012e, 0x015e, 0x080c,
+	0xbcec, 0x0118, 0x9006, 0x080c, 0x29b1, 0x0804, 0x6c29, 0x6800,
+	0x9084, 0x00a1, 0xc0bd, 0x6802, 0x080c, 0x28d0, 0x6904, 0xd1d4,
+	0x1140, 0x2001, 0x0100, 0x080c, 0x2987, 0x1f04, 0x6bca, 0x080c,
+	0x6caa, 0x012e, 0x015e, 0x080c, 0x6c64, 0x01a8, 0x6044, 0x9005,
+	0x0168, 0x6050, 0x0006, 0x9085, 0x0020, 0x6052, 0x080c, 0x6caa,
+	0x9006, 0x8001, 0x1df0, 0x000e, 0x6052, 0x0028, 0x6804, 0xd0d4,
+	0x1110, 0x080c, 0x6caa, 0x080c, 0xbcec, 0x0118, 0x9006, 0x080c,
+	0x29b1, 0x0016, 0x0026, 0x7000, 0x908e, 0x0004, 0x0130, 0x2009,
+	0x00c8, 0x2011, 0x6ad9, 0x080c, 0x7cd9, 0x002e, 0x001e, 0x080c,
+	0x7b73, 0x2001, 0x194e, 0x2003, 0x0004, 0x080c, 0x693a, 0x080c,
+	0x6c64, 0x0138, 0x6804, 0xd0d4, 0x1120, 0xd0dc, 0x1100, 0x080c,
+	0x6f2f, 0x00ee, 0x00de, 0x00ce, 0x0005, 0x00c6, 0x00d6, 0x00e6,
+	0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800, 0x080c, 0x7b7c,
+	0x080c, 0x6f39, 0x2001, 0x193e, 0x2003, 0x0000, 0x9006, 0x7092,
+	0x60e2, 0x6886, 0x080c, 0x254a, 0x9006, 0x080c, 0x2987, 0x6043,
+	0x0090, 0x6043, 0x0010, 0x6027, 0xffff, 0x602b, 0x182f, 0x00ee,
+	0x00de, 0x00ce, 0x0005, 0x0006, 0x2001, 0x194d, 0x2004, 0x9086,
+	0xaaaa, 0x000e, 0x0005, 0x0006, 0x080c, 0x5117, 0x9084, 0x0030,
+	0x9086, 0x0000, 0x000e, 0x0005, 0x0006, 0x080c, 0x5117, 0x9084,
+	0x0030, 0x9086, 0x0030, 0x000e, 0x0005, 0x0006, 0x080c, 0x5117,
+	0x9084, 0x0030, 0x9086, 0x0010, 0x000e, 0x0005, 0x0006, 0x080c,
+	0x5117, 0x9084, 0x0030, 0x9086, 0x0020, 0x000e, 0x0005, 0x0036,
+	0x0016, 0x2001, 0x180c, 0x2004, 0x908c, 0x0013, 0x0180, 0x0020,
+	0x080c, 0x256a, 0x900e, 0x0028, 0x080c, 0x629c, 0x1dc8, 0x2009,
+	0x0002, 0x2019, 0x0028, 0x080c, 0x2dfb, 0x9006, 0x0019, 0x001e,
+	0x003e, 0x0005, 0x00e6, 0x2071, 0x180c, 0x2e04, 0x0130, 0x080c,
+	0xbce5, 0x1128, 0x9085, 0x0010, 0x0010, 0x9084, 0xffef, 0x2072,
+	0x00ee, 0x0005, 0x6050, 0x0006, 0x60ec, 0x0006, 0x600c, 0x0006,
+	0x6004, 0x0006, 0x6028, 0x0006, 0x0016, 0x6138, 0x6050, 0x9084,
+	0xfbff, 0x9085, 0x2000, 0x6052, 0x613a, 0x20a9, 0x0012, 0x1d04,
+	0x6cbf, 0x2091, 0x6000, 0x1f04, 0x6cbf, 0x602f, 0x0100, 0x602f,
+	0x0000, 0x6050, 0x9085, 0x0400, 0x9084, 0xdfff, 0x6052, 0x613a,
+	0x001e, 0x602f, 0x0040, 0x602f, 0x0000, 0x000e, 0x602a, 0x000e,
+	0x6006, 0x000e, 0x600e, 0x000e, 0x60ee, 0x60e3, 0x0000, 0x6887,
+	0x0001, 0x2001, 0x0001, 0x080c, 0x254a, 0x2001, 0x00a0, 0x0006,
+	0x080c, 0xbcec, 0x000e, 0x0130, 0x080c, 0x29a5, 0x9006, 0x080c,
+	0x29b1, 0x0010, 0x080c, 0x2987, 0x000e, 0x6052, 0x6050, 0x0006,
+	0xc0e5, 0x6052, 0x00f6, 0x2079, 0x0100, 0x080c, 0x2845, 0x00fe,
+	0x000e, 0x6052, 0x0005, 0x0156, 0x0016, 0x0026, 0x0036, 0x00c6,
+	0x00d6, 0x00e6, 0x2061, 0x0100, 0x2069, 0x0140, 0x2071, 0x1800,
+	0x6020, 0x9084, 0x0080, 0x0138, 0x2001, 0x180c, 0x200c, 0xc1c5,
+	0x2102, 0x0804, 0x6d7f, 0x2001, 0x180c, 0x200c, 0xc1c4, 0x2102,
+	0x6028, 0x9084, 0xe1ff, 0x602a, 0x6027, 0x0200, 0x2001, 0x0090,
+	0x080c, 0x2987, 0x20a9, 0x0366, 0x6024, 0xd0cc, 0x1518, 0x1d04,
+	0x6d2c, 0x2091, 0x6000, 0x1f04, 0x6d2c, 0x2011, 0x0003, 0x080c,
+	0x92ec, 0x2011, 0x0002, 0x080c, 0x92f6, 0x080c, 0x91de, 0x901e,
+	0x080c, 0x9254, 0x2001, 0x00a0, 0x080c, 0x2987, 0x080c, 0x6f2a,
+	0x080c, 0x5a21, 0x080c, 0xbcec, 0x0110, 0x080c, 0x0d27, 0x9085,
+	0x0001, 0x0498, 0x86ff, 0x1110, 0x080c, 0x189c, 0x60e3, 0x0000,
+	0x2001, 0x193e, 0x2004, 0x080c, 0x254a, 0x60e2, 0x2001, 0x0080,
+	0x080c, 0x2987, 0x20a9, 0x0366, 0x6027, 0x1e00, 0x2009, 0x1e00,
+	0x080c, 0x28d0, 0x6024, 0x910c, 0x0138, 0x1d04, 0x6d64, 0x2091,
+	0x6000, 0x1f04, 0x6d64, 0x0808, 0x6028, 0x9085, 0x1e00, 0x602a,
+	0x70ac, 0x9005, 0x1118, 0x6887, 0x0001, 0x0008, 0x6886, 0x080c,
+	0xbcec, 0x0110, 0x080c, 0x0d27, 0x9006, 0x00ee, 0x00de, 0x00ce,
+	0x003e, 0x002e, 0x001e, 0x015e, 0x0005, 0x0156, 0x0016, 0x0026,
+	0x0036, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100, 0x2071, 0x1800,
+	0x2069, 0x0140, 0x6020, 0x9084, 0x00c0, 0x0120, 0x6884, 0x9005,
+	0x1904, 0x6de1, 0x2001, 0x0088, 0x080c, 0x2987, 0x9006, 0x60e2,
+	0x6886, 0x080c, 0x254a, 0x2069, 0x0200, 0x6804, 0x9005, 0x1118,
+	0x6808, 0x9005, 0x01c0, 0x6028, 0x9084, 0xfbff, 0x602a, 0x6027,
+	0x0400, 0x2069, 0x195e, 0x7000, 0x206a, 0x7093, 0x0026, 0x7003,
+	0x0001, 0x20a9, 0x0002, 0x1d04, 0x6dc3, 0x2091, 0x6000, 0x1f04,
+	0x6dc3, 0x0804, 0x6e0f, 0x2069, 0x0140, 0x20a9, 0x0384, 0x6027,
+	0x1e00, 0x2009, 0x1e00, 0x080c, 0x28d0, 0x6024, 0x910c, 0x0508,
+	0x9084, 0x1a00, 0x11f0, 0x1d04, 0x6dcf, 0x2091, 0x6000, 0x1f04,
+	0x6dcf, 0x2011, 0x0003, 0x080c, 0x92ec, 0x2011, 0x0002, 0x080c,
+	0x92f6, 0x080c, 0x91de, 0x901e, 0x080c, 0x9254, 0x2001, 0x00a0,
+	0x080c, 0x2987, 0x080c, 0x6f2a, 0x080c, 0x5a21, 0x9085, 0x0001,
+	0x00b0, 0x2001, 0x0080, 0x080c, 0x2987, 0x2069, 0x0140, 0x60e3,
+	0x0000, 0x70ac, 0x9005, 0x1118, 0x6887, 0x0001, 0x0008, 0x6886,
+	0x2001, 0x193e, 0x2004, 0x080c, 0x254a, 0x60e2, 0x9006, 0x00ee,
+	0x00de, 0x00ce, 0x003e, 0x002e, 0x001e, 0x015e, 0x0005, 0x0156,
+	0x0016, 0x0026, 0x0036, 0x00c6, 0x00d6, 0x00e6, 0x2061, 0x0100,
+	0x2071, 0x1800, 0x6020, 0x9084, 0x00c0, 0x01c8, 0x2011, 0x0003,
+	0x080c, 0x92ec, 0x2011, 0x0002, 0x080c, 0x92f6, 0x080c, 0x91de,
+	0x901e, 0x080c, 0x9254, 0x2069, 0x0140, 0x2001, 0x00a0, 0x080c,
+	0x2987, 0x080c, 0x6f2a, 0x080c, 0x5a21, 0x0804, 0x6eaa, 0x2001,
+	0x180c, 0x200c, 0xd1b4, 0x1160, 0xc1b5, 0x2102, 0x080c, 0x6ac1,
+	0x2069, 0x0140, 0x2001, 0x0080, 0x080c, 0x2987, 0x60e3, 0x0000,
+	0x2069, 0x0200, 0x6804, 0x9005, 0x1118, 0x6808, 0x9005, 0x0180,
+	0x6028, 0x9084, 0xfdff, 0x602a, 0x6027, 0x0200, 0x2069, 0x195e,
+	0x7000, 0x206a, 0x7093, 0x0027, 0x7003, 0x0001, 0x0804, 0x6eaa,
+	0x6027, 0x1e00, 0x2009, 0x1e00, 0x080c, 0x28d0, 0x6024, 0x910c,
+	0x01c8, 0x9084, 0x1c00, 0x11b0, 0x1d04, 0x6e68, 0x0006, 0x0016,
+	0x00c6, 0x00d6, 0x00e6, 0x080c, 0x7bae, 0x00ee, 0x00de, 0x00ce,
+	0x001e, 0x000e, 0x00e6, 0x2071, 0x19c9, 0x7018, 0x00ee, 0x9005,
+	0x19f8, 0x0500, 0x0026, 0x2011, 0x6ad9, 0x080c, 0x7c4a, 0x2011,
+	0x6acc, 0x080c, 0x7d1b, 0x002e, 0x2069, 0x0140, 0x60e3, 0x0000,
+	0x70ac, 0x9005, 0x1118, 0x6887, 0x0001, 0x0008, 0x6886, 0x2001,
+	0x193e, 0x2004, 0x080c, 0x254a, 0x60e2, 0x2001, 0x180c, 0x200c,
+	0xc1b4, 0x2102, 0x00ee, 0x00de, 0x00ce, 0x003e, 0x002e, 0x001e,
+	0x015e, 0x0005, 0x0156, 0x0016, 0x0026, 0x0036, 0x0046, 0x00c6,
+	0x00e6, 0x2061, 0x0100, 0x2071, 0x1800, 0x080c, 0xbce5, 0x1904,
+	0x6f18, 0x7130, 0xd184, 0x1170, 0x080c, 0x2f86, 0x0138, 0xc18d,
+	0x7132, 0x2011, 0x1854, 0x2214, 0xd2ac, 0x1120, 0x7030, 0xd08c,
+	0x0904, 0x6f18, 0x2011, 0x1854, 0x220c, 0xd1a4, 0x0538, 0x0016,
+	0x2019, 0x000e, 0x080c, 0xcf62, 0x0156, 0x00b6, 0x20a9, 0x007f,
+	0x900e, 0x9186, 0x007e, 0x01a0, 0x9186, 0x0080, 0x0188, 0x080c,
+	0x5f7e, 0x1170, 0x2120, 0x9006, 0x0016, 0x2009, 0x000e, 0x080c,
+	0xcfe6, 0x2009, 0x0001, 0x2011, 0x0100, 0x080c, 0x7e3e, 0x001e,
+	0x8108, 0x1f04, 0x6ee1, 0x00be, 0x015e, 0x001e, 0xd1ac, 0x1148,
+	0x0016, 0x2009, 0x0002, 0x2019, 0x0004, 0x080c, 0x2dfb, 0x001e,
+	0x0078, 0x0156, 0x00b6, 0x20a9, 0x007f, 0x900e, 0x080c, 0x5f7e,
+	0x1110, 0x080c, 0x5a3b, 0x8108, 0x1f04, 0x6f0e, 0x00be, 0x015e,
+	0x080c, 0x189c, 0x080c, 0x9947, 0x60e3, 0x0000, 0x080c, 0x5a21,
+	0x080c, 0x6b8a, 0x00ee, 0x00ce, 0x004e, 0x003e, 0x002e, 0x001e,
+	0x015e, 0x0005, 0x2001, 0x194e, 0x2003, 0x0001, 0x0005, 0x2001,
+	0x194e, 0x2003, 0x0000, 0x0005, 0x2001, 0x194d, 0x2003, 0xaaaa,
+	0x0005, 0x2001, 0x194d, 0x2003, 0x0000, 0x0005, 0x2071, 0x18f0,
+	0x7003, 0x0000, 0x7007, 0x0000, 0x080c, 0x0fee, 0x090c, 0x0db2,
+	0xa8ab, 0xdcb0, 0x2900, 0x704e, 0x080c, 0x0fee, 0x090c, 0x0db2,
+	0xa8ab, 0xdcb0, 0x2900, 0x7052, 0xa867, 0x0000, 0xa86b, 0x0001,
+	0xa89f, 0x0000, 0x0005, 0x00e6, 0x2071, 0x0040, 0x6848, 0x9005,
+	0x1118, 0x9085, 0x0001, 0x04b0, 0x6840, 0x9005, 0x0150, 0x04a1,
+	0x6a50, 0x9200, 0x7002, 0x6854, 0x9101, 0x7006, 0x9006, 0x7012,
+	0x7016, 0x6850, 0x7002, 0x6854, 0x7006, 0x6858, 0x700a, 0x685c,
+	0x700e, 0x6840, 0x9005, 0x1110, 0x7012, 0x7016, 0x6848, 0x701a,
+	0x701c, 0x9085, 0x0040, 0x701e, 0x2001, 0x0019, 0x7036, 0x702b,
+	0x0001, 0x2001, 0x0004, 0x200c, 0x918c, 0xfff7, 0x918d, 0x8000,
+	0x2102, 0x00d6, 0x2069, 0x18f0, 0x6807, 0x0001, 0x00de, 0x080c,
+	0x74e5, 0x9006, 0x00ee, 0x0005, 0x900e, 0x0156, 0x20a9, 0x0006,
+	0x8003, 0x2011, 0x0100, 0x2214, 0x9296, 0x0008, 0x1110, 0x818d,
+	0x0010, 0x81f5, 0x3e08, 0x1f04, 0x6fa0, 0x015e, 0x0005, 0x2079,
+	0x0040, 0x2071, 0x18f0, 0x7004, 0x0002, 0x6fbf, 0x6fc0, 0x6ff7,
+	0x7052, 0x714d, 0x6fbd, 0x6fbd, 0x7177, 0x080c, 0x0db2, 0x0005,
+	0x2079, 0x0040, 0x782c, 0x908c, 0x0780, 0x190c, 0x7571, 0xd0a4,
+	0x01f0, 0x7824, 0x2048, 0x9006, 0xa802, 0xa806, 0xa864, 0x9084,
+	0x00ff, 0x908a, 0x0040, 0x0608, 0x00b8, 0x2001, 0x1800, 0x200c,
+	0x9186, 0x0003, 0x1160, 0x7104, 0x9186, 0x0004, 0x0140, 0x9186,
+	0x0007, 0x0128, 0x9186, 0x0003, 0x19e8, 0x080c, 0x7052, 0x782c,
+	0xd09c, 0x090c, 0x74e5, 0x0005, 0x9082, 0x005a, 0x1218, 0x2100,
+	0x003b, 0x0c18, 0x080c, 0x7088, 0x0c90, 0x00e3, 0x08f0, 0x0005,
+	0x7088, 0x7088, 0x7088, 0x7088, 0x7088, 0x7088, 0x7088, 0x7088,
+	0x70aa, 0x7088, 0x7088, 0x7088, 0x7088, 0x7088, 0x7088, 0x7088,
+	0x7088, 0x7088, 0x7088, 0x7088, 0x7088, 0x7088, 0x7088, 0x7088,
+	0x7088, 0x7088, 0x7088, 0x7088, 0x7094, 0x7088, 0x724c, 0x7088,
+	0x7088, 0x7088, 0x7088, 0x7088, 0x7094, 0x728d, 0x72ce, 0x7315,
+	0x7329, 0x7088, 0x7088, 0x70aa, 0x7094, 0x7088, 0x7088, 0x7121,
+	0x73d4, 0x73ef, 0x7088, 0x70aa, 0x7088, 0x7088, 0x7088, 0x7088,
+	0x7117, 0x73ef, 0x7088, 0x7088, 0x7088, 0x7088, 0x7088, 0x7088,
+	0x7088, 0x7088, 0x7088, 0x70be, 0x7088, 0x7088, 0x7088, 0x7088,
+	0x7088, 0x7088, 0x7088, 0x7088, 0x7088, 0x7515, 0x7088, 0x7088,
+	0x7088, 0x7088, 0x7088, 0x70d2, 0x7088, 0x7088, 0x7088, 0x7088,
+	0x7088, 0x7088, 0x2079, 0x0040, 0x7004, 0x9086, 0x0003, 0x1198,
+	0x782c, 0x080c, 0x750e, 0xd0a4, 0x0170, 0x7824, 0x2048, 0x9006,
+	0xa802, 0xa806, 0xa864, 0x9084, 0x00ff, 0x908a, 0x001a, 0x1210,
+	0x002b, 0x0c50, 0x00e9, 0x080c, 0x74e5, 0x0005, 0x7088, 0x7094,
+	0x7238, 0x7088, 0x7094, 0x7088, 0x7094, 0x7094, 0x7088, 0x7094,
+	0x7238, 0x7094, 0x7094, 0x7094, 0x7094, 0x7094, 0x7088, 0x7094,
+	0x7238, 0x7088, 0x7088, 0x7094, 0x7088, 0x7088, 0x7088, 0x7094,
+	0x00e6, 0x2071, 0x18f0, 0x2009, 0x0400, 0x0071, 0x00ee, 0x0005,
+	0x2009, 0x1000, 0x0049, 0x0005, 0x2009, 0x2000, 0x0029, 0x0005,
+	0x2009, 0x0800, 0x0009, 0x0005, 0x7007, 0x0001, 0xa868, 0x9084,
+	0x00ff, 0x9105, 0xa86a, 0x0126, 0x2091, 0x8000, 0x080c, 0x6536,
+	0x012e, 0x0005, 0xa864, 0x8007, 0x9084, 0x00ff, 0x0d08, 0x8001,
+	0x1120, 0x7007, 0x0001, 0x0804, 0x71f6, 0x7007, 0x0003, 0x7012,
+	0x2900, 0x7016, 0x701a, 0x704b, 0x71f6, 0x0005, 0xa864, 0x8007,
+	0x9084, 0x00ff, 0x0968, 0x8001, 0x1120, 0x7007, 0x0001, 0x0804,
+	0x7211, 0x7007, 0x0003, 0x7012, 0x2900, 0x7016, 0x701a, 0x704b,
+	0x7211, 0x0005, 0xa864, 0x8007, 0x9084, 0x00ff, 0x9086, 0x0001,
+	0x1904, 0x7090, 0x7007, 0x0001, 0x2009, 0x1832, 0x210c, 0x81ff,
+	0x11a8, 0xa868, 0x9084, 0x00ff, 0xa86a, 0xa883, 0x0000, 0x080c,
+	0x5c50, 0x1108, 0x0005, 0x0126, 0x2091, 0x8000, 0xa867, 0x0139,
+	0xa87a, 0xa982, 0x080c, 0x6536, 0x012e, 0x0ca0, 0xa994, 0x9186,
+	0x0071, 0x0d38, 0x9186, 0x0064, 0x0d20, 0x9186, 0x007c, 0x0d08,
+	0x9186, 0x0028, 0x09f0, 0x9186, 0x0038, 0x09d8, 0x9186, 0x0078,
+	0x09c0, 0x9186, 0x005f, 0x09a8, 0x9186, 0x0056, 0x0990, 0xa897,
+	0x4005, 0xa89b, 0x0001, 0x2001, 0x0030, 0x900e, 0x08a0, 0xa87c,
+	0x9084, 0x00c0, 0x9086, 0x00c0, 0x1120, 0x7007, 0x0001, 0x0804,
+	0x7406, 0x2900, 0x7016, 0x701a, 0x20a9, 0x0004, 0xa860, 0x20e0,
+	0xa85c, 0x9080, 0x0030, 0x2098, 0x7050, 0x2040, 0xa060, 0x20e8,
+	0xa05c, 0x9080, 0x0023, 0x20a0, 0x4003, 0xa888, 0x7012, 0x9082,
+	0x0401, 0x1a04, 0x7098, 0xaab4, 0x928a, 0x0002, 0x1a04, 0x7098,
+	0x82ff, 0x1138, 0xa8b8, 0xa9bc, 0x9105, 0x0118, 0x2001, 0x71b4,
+	0x0018, 0x9280, 0x71aa, 0x2005, 0x7056, 0x7010, 0x9015, 0x0904,
+	0x7195, 0x080c, 0x0fee, 0x1118, 0x7007, 0x0004, 0x0005, 0x2900,
+	0x7022, 0x7054, 0x2060, 0xe000, 0xa866, 0x7050, 0x2040, 0xa95c,
+	0xe004, 0x9100, 0xa076, 0xa860, 0xa072, 0xe008, 0x920a, 0x1210,
+	0x900e, 0x2200, 0x7112, 0xe20c, 0x8003, 0x800b, 0x9296, 0x0004,
+	0x0108, 0x9108, 0xa17a, 0x810b, 0xa17e, 0x080c, 0x10b5, 0xa06c,
+	0x908e, 0x0100, 0x0170, 0x9086, 0x0200, 0x0118, 0x7007, 0x0007,
+	0x0005, 0x7020, 0x2048, 0x080c, 0x1007, 0x7014, 0x2048, 0x0804,
+	0x7098, 0x7020, 0x2048, 0x7018, 0xa802, 0xa807, 0x0000, 0x2908,
+	0x2048, 0xa906, 0x711a, 0x0804, 0x714d, 0x7014, 0x2048, 0x7007,
+	0x0001, 0xa8b4, 0x9005, 0x1128, 0xa8b8, 0xa9bc, 0x9105, 0x0108,
+	0x00b9, 0xa864, 0x9084, 0x00ff, 0x9086, 0x001e, 0x0904, 0x7406,
+	0x0804, 0x71f6, 0x71ac, 0x71b0, 0x0002, 0x001d, 0x0007, 0x0004,
+	0x000a, 0x001b, 0x0005, 0x0006, 0x000a, 0x001d, 0x0005, 0x0004,
+	0x0076, 0x0066, 0xafb8, 0xaebc, 0xa804, 0x2050, 0xb0c0, 0xb0e2,
+	0xb0bc, 0xb0de, 0xb0b8, 0xb0d2, 0xb0b4, 0xb0ce, 0xb6da, 0xb7d6,
+	0xb0b0, 0xb0ca, 0xb0ac, 0xb0c6, 0xb0a8, 0xb0ba, 0xb0a4, 0xb0b6,
+	0xb6c2, 0xb7be, 0xb0a0, 0xb0b2, 0xb09c, 0xb0ae, 0xb098, 0xb0a2,
+	0xb094, 0xb09e, 0xb6aa, 0xb7a6, 0xb090, 0xb09a, 0xb08c, 0xb096,
+	0xb088, 0xb08a, 0xb084, 0xb086, 0xb692, 0xb78e, 0xb080, 0xb082,
+	0xb07c, 0xb07e, 0xb078, 0xb072, 0xb074, 0xb06e, 0xb67a, 0xb776,
+	0xb004, 0x9055, 0x1958, 0x006e, 0x007e, 0x0005, 0x2009, 0x1832,
+	0x210c, 0x81ff, 0x1178, 0x080c, 0x5a9d, 0x1108, 0x0005, 0x080c,
+	0x6770, 0x0126, 0x2091, 0x8000, 0x080c, 0xb8e3, 0x080c, 0x6536,
+	0x012e, 0x0ca0, 0x080c, 0xbce5, 0x1d70, 0x2001, 0x0028, 0x900e,
+	0x0c70, 0x2009, 0x1832, 0x210c, 0x81ff, 0x11d8, 0xa888, 0x9005,
+	0x01e0, 0xa883, 0x0000, 0xa87c, 0xd0f4, 0x0120, 0x080c, 0x5bb2,
+	0x1138, 0x0005, 0x9006, 0xa87a, 0x080c, 0x5b2d, 0x1108, 0x0005,
+	0x0126, 0x2091, 0x8000, 0xa87a, 0xa982, 0x080c, 0x6536, 0x012e,
+	0x0cb0, 0x2001, 0x0028, 0x900e, 0x0c98, 0x2001, 0x0000, 0x0c80,
+	0x7018, 0xa802, 0x2908, 0x2048, 0xa906, 0x711a, 0x7010, 0x8001,
+	0x7012, 0x0118, 0x7007, 0x0003, 0x0030, 0x7014, 0x2048, 0x7007,
+	0x0001, 0x7048, 0x080f, 0x0005, 0x00b6, 0x7007, 0x0001, 0xa974,
+	0xa878, 0x9084, 0x00ff, 0x9096, 0x0004, 0x0540, 0x20a9, 0x0001,
+	0x9096, 0x0001, 0x0190, 0x900e, 0x20a9, 0x0800, 0x9096, 0x0002,
+	0x0160, 0x9005, 0x11d8, 0xa974, 0x080c, 0x5f7e, 0x11b8, 0x0066,
+	0xae80, 0x080c, 0x608e, 0x006e, 0x0088, 0x0046, 0x2011, 0x180c,
+	0x2224, 0xc484, 0x2412, 0x004e, 0x00c6, 0x080c, 0x5f7e, 0x1110,
+	0x080c, 0x618e, 0x8108, 0x1f04, 0x7275, 0x00ce, 0xa87c, 0xd084,
+	0x1120, 0x080c, 0x1007, 0x00be, 0x0005, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x6536, 0x012e, 0x00be, 0x0005, 0x0126, 0x2091, 0x8000,
+	0x7007, 0x0001, 0x080c, 0x62a0, 0x0580, 0x2061, 0x1a3e, 0x6100,
+	0xd184, 0x0178, 0xa888, 0x9084, 0x00ff, 0x1550, 0x6000, 0xd084,
+	0x0520, 0x6004, 0x9005, 0x1538, 0x6003, 0x0000, 0x600b, 0x0000,
+	0x00c8, 0x2011, 0x0001, 0xa890, 0x9005, 0x1110, 0x2001, 0x001e,
+	0x8000, 0x6016, 0xa888, 0x9084, 0x00ff, 0x0178, 0x6006, 0xa888,
+	0x8007, 0x9084, 0x00ff, 0x0148, 0x600a, 0xa888, 0x8000, 0x1108,
+	0xc28d, 0x6202, 0x012e, 0x0804, 0x74cf, 0x012e, 0x0804, 0x74c9,
+	0x012e, 0x0804, 0x74c3, 0x012e, 0x0804, 0x74c6, 0x0126, 0x2091,
+	0x8000, 0x7007, 0x0001, 0x080c, 0x62a0, 0x05e0, 0x2061, 0x1a3e,
+	0x6000, 0xd084, 0x05b8, 0x6204, 0x6308, 0xd08c, 0x1530, 0xac78,
+	0x9484, 0x0003, 0x0170, 0xa988, 0x918c, 0x00ff, 0x8001, 0x1120,
+	0x2100, 0x9210, 0x0620, 0x0028, 0x8001, 0x1508, 0x2100, 0x9212,
+	0x02f0, 0x9484, 0x000c, 0x0188, 0xa988, 0x810f, 0x918c, 0x00ff,
+	0x9082, 0x0004, 0x1120, 0x2100, 0x9318, 0x0288, 0x0030, 0x9082,
+	0x0004, 0x1168, 0x2100, 0x931a, 0x0250, 0xa890, 0x9005, 0x0110,
+	0x8000, 0x6016, 0x6206, 0x630a, 0x012e, 0x0804, 0x74cf, 0x012e,
+	0x0804, 0x74cc, 0x012e, 0x0804, 0x74c9, 0x0126, 0x2091, 0x8000,
+	0x7007, 0x0001, 0x2061, 0x1a3e, 0x6300, 0xd38c, 0x1120, 0x6308,
+	0x8318, 0x0220, 0x630a, 0x012e, 0x0804, 0x74dd, 0x012e, 0x0804,
+	0x74cc, 0x00b6, 0x0126, 0x00c6, 0x2091, 0x8000, 0x7007, 0x0001,
+	0xa87c, 0xd0ac, 0x0148, 0x00c6, 0x2061, 0x1a3e, 0x6000, 0x9084,
+	0xfcff, 0x6002, 0x00ce, 0x0440, 0xa888, 0x9005, 0x05d8, 0xa88c,
+	0x9065, 0x0598, 0x2001, 0x1832, 0x2004, 0x9005, 0x0118, 0x080c,
+	0x9a06, 0x0068, 0x6017, 0xf400, 0x605b, 0x0000, 0xa97c, 0xd1a4,
+	0x0110, 0xa980, 0x615a, 0x2009, 0x0041, 0x080c, 0x9a50, 0xa988,
+	0x918c, 0xff00, 0x9186, 0x2000, 0x1138, 0x0026, 0x900e, 0x2011,
+	0xfdff, 0x080c, 0x7e3e, 0x002e, 0xa87c, 0xd0c4, 0x0148, 0x2061,
+	0x1a3e, 0x6000, 0xd08c, 0x1120, 0x6008, 0x8000, 0x0208, 0x600a,
+	0x00ce, 0x012e, 0x00be, 0x0804, 0x74cf, 0x00ce, 0x012e, 0x00be,
+	0x0804, 0x74c9, 0xa984, 0x9186, 0x002e, 0x0d30, 0x9186, 0x002d,
+	0x0d18, 0x9186, 0x0045, 0x0510, 0x9186, 0x002a, 0x1130, 0x2001,
+	0x180c, 0x200c, 0xc194, 0x2102, 0x08b8, 0x9186, 0x0020, 0x0158,
+	0x9186, 0x0029, 0x1d10, 0xa974, 0x080c, 0x5f7e, 0x1968, 0xb800,
+	0xc0e4, 0xb802, 0x0848, 0xa88c, 0x9065, 0x09b8, 0x6007, 0x0024,
+	0x2001, 0x1955, 0x2004, 0x601a, 0x0804, 0x7364, 0xa88c, 0x9065,
+	0x0960, 0x00e6, 0xa890, 0x9075, 0x2001, 0x1832, 0x2004, 0x9005,
+	0x0150, 0x080c, 0x9a06, 0x8eff, 0x0118, 0x2e60, 0x080c, 0x9a06,
+	0x00ee, 0x0804, 0x7364, 0x6024, 0xc0dc, 0xc0d5, 0x6026, 0x2e60,
+	0x6007, 0x003a, 0xa8a0, 0x9005, 0x0130, 0x6007, 0x003b, 0xa8a4,
+	0x602e, 0xa8a8, 0x6016, 0x6003, 0x0001, 0x080c, 0x8000, 0x080c,
+	0x8582, 0x00ee, 0x0804, 0x7364, 0x2061, 0x1a3e, 0x6000, 0xd084,
+	0x0190, 0xd08c, 0x1904, 0x74dd, 0x0126, 0x2091, 0x8000, 0x6204,
+	0x8210, 0x0220, 0x6206, 0x012e, 0x0804, 0x74dd, 0x012e, 0xa883,
+	0x0016, 0x0804, 0x74d6, 0xa883, 0x0007, 0x0804, 0x74d6, 0xa864,
+	0x8007, 0x9084, 0x00ff, 0x0130, 0x8001, 0x1138, 0x7007, 0x0001,
+	0x0069, 0x0005, 0x080c, 0x7090, 0x0040, 0x7007, 0x0003, 0x7012,
+	0x2900, 0x7016, 0x701a, 0x704b, 0x7406, 0x0005, 0x00b6, 0x00e6,
+	0x0126, 0x2091, 0x8000, 0x903e, 0x2061, 0x1800, 0x61c8, 0x81ff,
+	0x1904, 0x7488, 0x6130, 0xd194, 0x1904, 0x74b2, 0xa878, 0x2070,
+	0x9e82, 0x1cd0, 0x0a04, 0x747c, 0x6060, 0x9e02, 0x1a04, 0x747c,
+	0x7120, 0x9186, 0x0006, 0x1904, 0x746e, 0x7010, 0x905d, 0x0904,
+	0x7488, 0xb800, 0xd0e4, 0x1904, 0x74ac, 0x2061, 0x1a3e, 0x6100,
+	0x9184, 0x0301, 0x9086, 0x0001, 0x15a0, 0x7024, 0xd0dc, 0x1904,
+	0x74b5, 0xa883, 0x0000, 0xa803, 0x0000, 0x2908, 0x7014, 0x9005,
+	0x1198, 0x7116, 0xa87c, 0xd0f4, 0x1904, 0x74b8, 0x080c, 0x5113,
+	0xd09c, 0x1118, 0xa87c, 0xc0cc, 0xa87e, 0x2e60, 0x080c, 0x7d5e,
+	0x012e, 0x00ee, 0x00be, 0x0005, 0x2048, 0xa800, 0x9005, 0x1de0,
+	0xa902, 0x2148, 0xa87c, 0xd0f4, 0x1904, 0x74b8, 0x012e, 0x00ee,
+	0x00be, 0x0005, 0x012e, 0x00ee, 0xa883, 0x0006, 0x00be, 0x0804,
+	0x74d6, 0xd184, 0x0db8, 0xd1c4, 0x1190, 0x00a0, 0xa974, 0x080c,
+	0x5f7e, 0x15d0, 0xb800, 0xd0e4, 0x15b8, 0x7120, 0x9186, 0x0007,
+	0x1118, 0xa883, 0x0002, 0x0490, 0xa883, 0x0008, 0x0478, 0xa883,
+	0x000e, 0x0460, 0xa883, 0x0017, 0x0448, 0xa883, 0x0035, 0x0430,
+	0x080c, 0x5117, 0xd0fc, 0x01e8, 0xa878, 0x2070, 0x9e82, 0x1cd0,
+	0x02c0, 0x6060, 0x9e02, 0x12a8, 0x7120, 0x9186, 0x0006, 0x1188,
+	0x7010, 0x905d, 0x0170, 0xb800, 0xd0bc, 0x0158, 0x2039, 0x0001,
+	0x7000, 0x9086, 0x0007, 0x1904, 0x7412, 0x7003, 0x0002, 0x0804,
+	0x7412, 0xa883, 0x0028, 0x0010, 0xa883, 0x0029, 0x012e, 0x00ee,
+	0x00be, 0x0420, 0xa883, 0x002a, 0x0cc8, 0xa883, 0x0045, 0x0cb0,
+	0x2e60, 0x2019, 0x0002, 0x601b, 0x0014, 0x080c, 0xcbad, 0x012e,
+	0x00ee, 0x00be, 0x0005, 0x2009, 0x003e, 0x0058, 0x2009, 0x0004,
+	0x0040, 0x2009, 0x0006, 0x0028, 0x2009, 0x0016, 0x0010, 0x2009,
+	0x0001, 0xa884, 0x9084, 0xff00, 0x9105, 0xa886, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x6536, 0x012e, 0x0005, 0x080c, 0x1007, 0x0005,
+	0x00d6, 0x080c, 0x7d55, 0x00de, 0x0005, 0x00d6, 0x00e6, 0x0126,
+	0x2091, 0x8000, 0x2071, 0x0040, 0x702c, 0xd084, 0x01d8, 0x908c,
+	0x0780, 0x190c, 0x7571, 0xd09c, 0x11a8, 0x2071, 0x1800, 0x70b8,
+	0x90ea, 0x0040, 0x0278, 0x8001, 0x70ba, 0x702c, 0x2048, 0xa800,
+	0x702e, 0x9006, 0xa802, 0xa806, 0x2071, 0x0040, 0x2900, 0x7022,
+	0x702c, 0x0c28, 0x012e, 0x00ee, 0x00de, 0x0005, 0x0006, 0x9084,
+	0x0780, 0x190c, 0x7571, 0x000e, 0x0005, 0x00d6, 0x00c6, 0x0036,
+	0x0026, 0x0016, 0x00b6, 0x7007, 0x0001, 0xaa74, 0x9282, 0x0004,
+	0x1a04, 0x7562, 0xa97c, 0x9188, 0x1000, 0x2104, 0x905d, 0xb804,
+	0xd284, 0x0140, 0x05e8, 0x8007, 0x9084, 0x00ff, 0x9084, 0x0006,
+	0x1108, 0x04b0, 0x2b10, 0x080c, 0x9980, 0x1118, 0x080c, 0x9a23,
+	0x05a8, 0x6212, 0xa874, 0x0002, 0x7540, 0x7545, 0x7548, 0x754e,
+	0x2019, 0x0002, 0x080c, 0xcf62, 0x0060, 0x080c, 0xcefe, 0x0048,
+	0x2019, 0x0002, 0xa980, 0x080c, 0xcf19, 0x0018, 0xa980, 0x080c,
+	0xcefe, 0x080c, 0x99d6, 0xa887, 0x0000, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x6536, 0x012e, 0x00be, 0x001e, 0x002e, 0x003e, 0x00ce,
+	0x00de, 0x0005, 0xa887, 0x0006, 0x0c80, 0xa887, 0x0002, 0x0c68,
+	0xa887, 0x0005, 0x0c50, 0xa887, 0x0004, 0x0c38, 0xa887, 0x0007,
+	0x0c20, 0x2091, 0x8000, 0x0e04, 0x7573, 0x0006, 0x0016, 0x2001,
+	0x8003, 0x0006, 0x0804, 0x0dbb, 0x0005, 0x00f6, 0x2079, 0x0300,
+	0x2001, 0x0200, 0x200c, 0xc1e5, 0xc1dc, 0x2102, 0x2009, 0x0218,
+	0x210c, 0xd1ec, 0x1120, 0x080c, 0x1461, 0x00fe, 0x0005, 0x2001,
+	0x020d, 0x2003, 0x0020, 0x781f, 0x0300, 0x00fe, 0x0005, 0x781c,
+	0xd08c, 0x0904, 0x75dd, 0x68b8, 0x90aa, 0x0005, 0x0a04, 0x7b73,
+	0x7d44, 0x7c40, 0x9584, 0x00f6, 0x1508, 0x9484, 0x7000, 0x0138,
+	0x908a, 0x2000, 0x1258, 0x9584, 0x0700, 0x8007, 0x04a8, 0x7000,
+	0x9084, 0xff00, 0x9086, 0x8100, 0x0db0, 0x00b0, 0x9484, 0x0fff,
+	0x1130, 0x7000, 0x9084, 0xff00, 0x9086, 0x8100, 0x11c0, 0x080c,
+	0xd31b, 0x080c, 0x7ab8, 0x7817, 0x0140, 0x00a8, 0x9584, 0x0076,
+	0x1118, 0x080c, 0x7b16, 0x19c8, 0xd5a4, 0x0148, 0x0046, 0x0056,
+	0x080c, 0x763f, 0x080c, 0x203e, 0x005e, 0x004e, 0x0020, 0x080c,
+	0xd31b, 0x7817, 0x0140, 0x080c, 0x7620, 0x2001, 0x19bf, 0x2004,
+	0x9005, 0x090c, 0x8582, 0x0005, 0x0002, 0x75f6, 0x78da, 0x75ed,
+	0x75ed, 0x75ed, 0x75ed, 0x75ed, 0x75ed, 0x7817, 0x0140, 0x2001,
+	0x19bf, 0x2004, 0x9005, 0x090c, 0x8582, 0x0005, 0x7000, 0x908c,
+	0xff00, 0x9194, 0xf000, 0x810f, 0x9484, 0x0fff, 0x688a, 0x9286,
+	0x2000, 0x1150, 0x6800, 0x9086, 0x0001, 0x1118, 0x080c, 0x5137,
+	0x0070, 0x080c, 0x765f, 0x0058, 0x9286, 0x3000, 0x1118, 0x080c,
+	0x7815, 0x0028, 0x9286, 0x8000, 0x1110, 0x080c, 0x79e8, 0x7817,
+	0x0140, 0x2001, 0x19bf, 0x2004, 0x9005, 0x090c, 0x8582, 0x0005,
+	0x2001, 0x180f, 0x2004, 0xd08c, 0x0178, 0x2001, 0x1800, 0x2004,
+	0x9086, 0x0003, 0x1148, 0x0026, 0x0036, 0x2011, 0x8048, 0x2518,
+	0x080c, 0x4672, 0x003e, 0x002e, 0x0005, 0x0036, 0x0046, 0x0056,
+	0x00f6, 0x2079, 0x0200, 0x2019, 0xfffe, 0x7c30, 0x0050, 0x0036,
+	0x0046, 0x0056, 0x00f6, 0x2079, 0x0200, 0x7d44, 0x7c40, 0x2019,
+	0xffff, 0x2001, 0x180f, 0x2004, 0xd08c, 0x0160, 0x2001, 0x1800,
+	0x2004, 0x9086, 0x0003, 0x1130, 0x0026, 0x2011, 0x8048, 0x080c,
+	0x4672, 0x002e, 0x00fe, 0x005e, 0x004e, 0x003e, 0x0005, 0x00b6,
+	0x00c6, 0x7010, 0x9084, 0xff00, 0x8007, 0x9096, 0x0001, 0x0120,
+	0x9096, 0x0023, 0x1904, 0x77e6, 0x9186, 0x0023, 0x15c0, 0x080c,
+	0x7a7d, 0x0904, 0x77e6, 0x6120, 0x9186, 0x0001, 0x0150, 0x9186,
+	0x0004, 0x0138, 0x9186, 0x0008, 0x0120, 0x9186, 0x000a, 0x1904,
+	0x77e6, 0x7124, 0x610a, 0x7030, 0x908e, 0x0200, 0x1130, 0x2009,
+	0x0015, 0x080c, 0x9a50, 0x0804, 0x77e6, 0x908e, 0x0214, 0x0118,
+	0x908e, 0x0210, 0x1130, 0x2009, 0x0015, 0x080c, 0x9a50, 0x0804,
+	0x77e6, 0x908e, 0x0100, 0x1904, 0x77e6, 0x7034, 0x9005, 0x1904,
+	0x77e6, 0x2009, 0x0016, 0x080c, 0x9a50, 0x0804, 0x77e6, 0x9186,
+	0x0022, 0x1904, 0x77e6, 0x7030, 0x908e, 0x0300, 0x1580, 0x68d4,
+	0xd0a4, 0x0528, 0xc0b5, 0x68d6, 0x7100, 0x918c, 0x00ff, 0x6976,
+	0x7004, 0x687a, 0x00f6, 0x2079, 0x0100, 0x79e6, 0x78ea, 0x0006,
+	0x9084, 0x00ff, 0x0016, 0x2008, 0x080c, 0x251f, 0x7932, 0x7936,
+	0x001e, 0x000e, 0x00fe, 0x080c, 0x24d6, 0x6956, 0x703c, 0x00e6,
+	0x2071, 0x0140, 0x7086, 0x2071, 0x1800, 0x70ae, 0x00ee, 0x7034,
+	0x9005, 0x1904, 0x77e6, 0x2009, 0x0017, 0x0804, 0x77b3, 0x908e,
+	0x0400, 0x1190, 0x7034, 0x9005, 0x1904, 0x77e6, 0x080c, 0x6c53,
+	0x0120, 0x2009, 0x001d, 0x0804, 0x77b3, 0x68d4, 0xc0a5, 0x68d6,
+	0x2009, 0x0030, 0x0804, 0x77b3, 0x908e, 0x0500, 0x1140, 0x7034,
+	0x9005, 0x1904, 0x77e6, 0x2009, 0x0018, 0x0804, 0x77b3, 0x908e,
+	0x2010, 0x1120, 0x2009, 0x0019, 0x0804, 0x77b3, 0x908e, 0x2110,
+	0x1120, 0x2009, 0x001a, 0x0804, 0x77b3, 0x908e, 0x5200, 0x1140,
+	0x7034, 0x9005, 0x1904, 0x77e6, 0x2009, 0x001b, 0x0804, 0x77b3,
+	0x908e, 0x5000, 0x1140, 0x7034, 0x9005, 0x1904, 0x77e6, 0x2009,
+	0x001c, 0x0804, 0x77b3, 0x908e, 0x1300, 0x1120, 0x2009, 0x0034,
+	0x0804, 0x77b3, 0x908e, 0x1200, 0x1140, 0x7034, 0x9005, 0x1904,
+	0x77e6, 0x2009, 0x0024, 0x0804, 0x77b3, 0x908c, 0xff00, 0x918e,
+	0x2400, 0x1170, 0x2009, 0x002d, 0x2001, 0x180f, 0x2004, 0xd09c,
+	0x0904, 0x77b3, 0x080c, 0xc384, 0x1904, 0x77e6, 0x0804, 0x77b1,
+	0x908c, 0xff00, 0x918e, 0x5300, 0x1120, 0x2009, 0x002a, 0x0804,
+	0x77b3, 0x908e, 0x0f00, 0x1120, 0x2009, 0x0020, 0x0804, 0x77b3,
+	0x908e, 0x5300, 0x1108, 0x0440, 0x908e, 0x6104, 0x1528, 0x2029,
+	0x0205, 0x2011, 0x026d, 0x8208, 0x2204, 0x9082, 0x0004, 0x8004,
+	0x8004, 0x20a8, 0x2011, 0x8015, 0x211c, 0x8108, 0x0046, 0x2124,
+	0x080c, 0x4672, 0x004e, 0x8108, 0x0f04, 0x777f, 0x9186, 0x0280,
+	0x1d88, 0x2504, 0x8000, 0x202a, 0x2009, 0x0260, 0x0c58, 0x202b,
+	0x0000, 0x2009, 0x0023, 0x0478, 0x908e, 0x6000, 0x1118, 0x2009,
+	0x003f, 0x0448, 0x908e, 0x7800, 0x1118, 0x2009, 0x0045, 0x0418,
+	0x908e, 0x1000, 0x1118, 0x2009, 0x004e, 0x00e8, 0x908e, 0x6300,
+	0x1118, 0x2009, 0x004a, 0x00b8, 0x908c, 0xff00, 0x918e, 0x5600,
+	0x1118, 0x2009, 0x004f, 0x0078, 0x908c, 0xff00, 0x918e, 0x5700,
+	0x1118, 0x2009, 0x0050, 0x0038, 0x2009, 0x001d, 0x6834, 0xd0d4,
+	0x0110, 0x2009, 0x004c, 0x0016, 0x2011, 0x0263, 0x2204, 0x8211,
+	0x220c, 0x080c, 0x24d6, 0x1568, 0x080c, 0x5f1e, 0x1550, 0xbe12,
+	0xbd16, 0x001e, 0x0016, 0xb8b0, 0x9005, 0x1168, 0x9186, 0x0046,
+	0x1150, 0x6874, 0x9606, 0x1138, 0x6878, 0x9506, 0x9084, 0xff00,
+	0x1110, 0x001e, 0x0098, 0x080c, 0x9980, 0x01a8, 0x2b08, 0x6112,
+	0x6023, 0x0004, 0x7120, 0x610a, 0x001e, 0x9186, 0x004c, 0x1110,
+	0x6023, 0x000a, 0x0016, 0x001e, 0x080c, 0x9a50, 0x00ce, 0x00be,
+	0x0005, 0x001e, 0x0cd8, 0x2001, 0x180d, 0x2004, 0xd0ec, 0x0120,
+	0x2011, 0x8049, 0x080c, 0x4672, 0x080c, 0x9a23, 0x0d90, 0x2b08,
+	0x6112, 0x6023, 0x0004, 0x7120, 0x610a, 0x001e, 0x0016, 0x9186,
+	0x0017, 0x0118, 0x9186, 0x0030, 0x1128, 0x6007, 0x0009, 0x6017,
+	0x2900, 0x0020, 0x6007, 0x0051, 0x6017, 0x0000, 0x602f, 0x0009,
+	0x6003, 0x0001, 0x080c, 0x8048, 0x08a0, 0x080c, 0x2f50, 0x1140,
+	0x7010, 0x9084, 0xff00, 0x8007, 0x908e, 0x0008, 0x1108, 0x0009,
+	0x0005, 0x00b6, 0x00c6, 0x0046, 0x7000, 0x908c, 0xff00, 0x810f,
+	0x9186, 0x0033, 0x11e8, 0x080c, 0x7a7d, 0x0904, 0x7872, 0x7124,
+	0x610a, 0x7030, 0x908e, 0x0200, 0x1140, 0x7034, 0x9005, 0x15d0,
+	0x2009, 0x0015, 0x080c, 0x9a50, 0x04a8, 0x908e, 0x0100, 0x1590,
+	0x7034, 0x9005, 0x1578, 0x2009, 0x0016, 0x080c, 0x9a50, 0x0450,
+	0x9186, 0x0032, 0x1538, 0x7030, 0x908e, 0x1400, 0x1518, 0x2009,
+	0x0038, 0x0016, 0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c,
+	0x24d6, 0x11b8, 0x080c, 0x5f1e, 0x11a0, 0xbe12, 0xbd16, 0x080c,
+	0x9980, 0x0178, 0x2b08, 0x6112, 0x080c, 0xba69, 0x6023, 0x0004,
+	0x7120, 0x610a, 0x001e, 0x080c, 0x9a50, 0x080c, 0x8582, 0x0010,
+	0x00ce, 0x001e, 0x004e, 0x00ce, 0x00be, 0x0005, 0x00b6, 0x0046,
+	0x00e6, 0x00d6, 0x2028, 0x2130, 0x9696, 0x00ff, 0x11b8, 0x9592,
+	0xfffc, 0x02a0, 0x9596, 0xfffd, 0x1120, 0x2009, 0x007f, 0x0804,
+	0x78d4, 0x9596, 0xfffe, 0x1120, 0x2009, 0x007e, 0x0804, 0x78d4,
+	0x9596, 0xfffc, 0x1118, 0x2009, 0x0080, 0x04f0, 0x2011, 0x0000,
+	0x2019, 0x1835, 0x231c, 0xd3ac, 0x0130, 0x9026, 0x20a9, 0x0800,
+	0x2071, 0x1000, 0x0030, 0x2021, 0x0081, 0x20a9, 0x077f, 0x2071,
+	0x1081, 0x2e1c, 0x93dd, 0x0000, 0x1140, 0x82ff, 0x11d0, 0x9496,
+	0x00ff, 0x01b8, 0x2410, 0xc2fd, 0x00a0, 0xbf10, 0x2600, 0x9706,
+	0xb814, 0x1120, 0x9546, 0x1110, 0x2408, 0x00b0, 0x9745, 0x1148,
+	0x94c6, 0x007e, 0x0130, 0x94c6, 0x007f, 0x0118, 0x94c6, 0x0080,
+	0x1d20, 0x8420, 0x8e70, 0x1f04, 0x78a9, 0x82ff, 0x1118, 0x9085,
+	0x0001, 0x0018, 0xc2fc, 0x2208, 0x9006, 0x00de, 0x00ee, 0x004e,
+	0x00be, 0x0005, 0x7000, 0x908c, 0xff00, 0x810f, 0x9184, 0x000f,
+	0x0002, 0x78f1, 0x78f1, 0x78f1, 0x7a8f, 0x78f1, 0x78fa, 0x7925,
+	0x79b3, 0x78f1, 0x78f1, 0x78f1, 0x78f1, 0x78f1, 0x78f1, 0x78f1,
+	0x78f1, 0x7817, 0x0140, 0x2001, 0x19bf, 0x2004, 0x9005, 0x090c,
+	0x8582, 0x0005, 0x00b6, 0x7110, 0xd1bc, 0x01e8, 0x7120, 0x2160,
+	0x9c8c, 0x0007, 0x11c0, 0x9c8a, 0x1cd0, 0x02a8, 0x6860, 0x9c02,
+	0x1290, 0x7008, 0x9084, 0x00ff, 0x6110, 0x2158, 0xb910, 0x9106,
+	0x1150, 0x700c, 0xb914, 0x9106, 0x1130, 0x7124, 0x610a, 0x2009,
+	0x0046, 0x080c, 0x9a50, 0x7817, 0x0140, 0x2001, 0x19bf, 0x2004,
+	0x9005, 0x090c, 0x8582, 0x00be, 0x0005, 0x00b6, 0x00c6, 0x9484,
+	0x0fff, 0x0904, 0x7989, 0x7110, 0xd1bc, 0x1904, 0x7989, 0x7108,
+	0x700c, 0x2028, 0x918c, 0x00ff, 0x2130, 0x9094, 0xff00, 0x15b0,
+	0x81ff, 0x15a0, 0x9080, 0x2f92, 0x200d, 0x918c, 0xff00, 0x810f,
+	0x2001, 0x0080, 0x9106, 0x0904, 0x7989, 0x080c, 0x5f1e, 0x1904,
+	0x7989, 0xbe12, 0xbd16, 0xb800, 0xd0ec, 0x15d8, 0xba04, 0x9294,
+	0xff00, 0x9286, 0x0600, 0x11a0, 0x080c, 0x9980, 0x05e8, 0x2b08,
+	0x7028, 0x604a, 0x702c, 0x6046, 0x6112, 0x6023, 0x0006, 0x7120,
+	0x610a, 0x7130, 0x6156, 0x2009, 0x0044, 0x080c, 0xc5dc, 0x0408,
+	0x080c, 0x62a4, 0x1138, 0xb807, 0x0606, 0x0c30, 0x190c, 0x7876,
+	0x11c0, 0x0898, 0x080c, 0x9980, 0x2b08, 0x0198, 0x6112, 0x6023,
+	0x0004, 0x7120, 0x610a, 0x9286, 0x0400, 0x1118, 0x6007, 0x0005,
+	0x0010, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c, 0x8048, 0x080c,
+	0x8582, 0x7817, 0x0140, 0x2001, 0x19bf, 0x2004, 0x9005, 0x090c,
+	0x8582, 0x00ce, 0x00be, 0x0005, 0x2001, 0x180d, 0x2004, 0xd0ec,
+	0x0120, 0x2011, 0x8049, 0x080c, 0x4672, 0x080c, 0x9a23, 0x0d48,
+	0x2b08, 0x6112, 0x6023, 0x0006, 0x7120, 0x610a, 0x7130, 0x6156,
+	0x6017, 0xf300, 0x6003, 0x0001, 0x6007, 0x0041, 0x080c, 0x8000,
+	0x080c, 0x8582, 0x08b0, 0x00b6, 0x7110, 0xd1bc, 0x01e8, 0x7020,
+	0x2060, 0x9c84, 0x0007, 0x11c0, 0x9c82, 0x1cd0, 0x02a8, 0x6860,
+	0x9c02, 0x1290, 0x7008, 0x9084, 0x00ff, 0x6110, 0x2158, 0xb910,
+	0x9106, 0x1150, 0x700c, 0xb914, 0x9106, 0x1130, 0x7124, 0x610a,
+	0x2009, 0x0045, 0x080c, 0x9a50, 0x7817, 0x0140, 0x2001, 0x19bf,
+	0x2004, 0x9005, 0x090c, 0x8582, 0x00be, 0x0005, 0x6120, 0x9186,
+	0x0002, 0x0128, 0x9186, 0x0005, 0x0110, 0x9085, 0x0001, 0x0005,
+	0x080c, 0x2f50, 0x1168, 0x7010, 0x9084, 0xff00, 0x8007, 0x9086,
+	0x0000, 0x1130, 0x9184, 0x000f, 0x908a, 0x0006, 0x1208, 0x000b,
+	0x0005, 0x79ff, 0x7a00, 0x79ff, 0x79ff, 0x7a5f, 0x7a6e, 0x0005,
+	0x00b6, 0x7110, 0xd1bc, 0x0120, 0x702c, 0xd084, 0x0904, 0x7a5d,
+	0x700c, 0x7108, 0x080c, 0x24d6, 0x1904, 0x7a5d, 0x080c, 0x5f1e,
+	0x1904, 0x7a5d, 0xbe12, 0xbd16, 0x7110, 0xd1bc, 0x01d8, 0x080c,
+	0x62a4, 0x0118, 0x9086, 0x0004, 0x1588, 0x00c6, 0x080c, 0x7a7d,
+	0x00ce, 0x05d8, 0x080c, 0x9980, 0x2b08, 0x05b8, 0x6112, 0x080c,
+	0xba69, 0x6023, 0x0002, 0x7120, 0x610a, 0x2009, 0x0088, 0x080c,
+	0x9a50, 0x0458, 0x080c, 0x62a4, 0x0148, 0x9086, 0x0004, 0x0130,
+	0x080c, 0x62ac, 0x0118, 0x9086, 0x0004, 0x1180, 0x080c, 0x9980,
+	0x2b08, 0x01d8, 0x6112, 0x080c, 0xba69, 0x6023, 0x0005, 0x7120,
+	0x610a, 0x2009, 0x0088, 0x080c, 0x9a50, 0x0078, 0x080c, 0x9980,
+	0x2b08, 0x0158, 0x6112, 0x080c, 0xba69, 0x6023, 0x0004, 0x7120,
+	0x610a, 0x2009, 0x0001, 0x080c, 0x9a50, 0x00be, 0x0005, 0x7110,
+	0xd1bc, 0x0158, 0x00d1, 0x0148, 0x080c, 0x79de, 0x1130, 0x7124,
+	0x610a, 0x2009, 0x0089, 0x080c, 0x9a50, 0x0005, 0x7110, 0xd1bc,
+	0x0158, 0x0059, 0x0148, 0x080c, 0x79de, 0x1130, 0x7124, 0x610a,
+	0x2009, 0x008a, 0x080c, 0x9a50, 0x0005, 0x7020, 0x2060, 0x9c84,
+	0x0007, 0x1158, 0x9c82, 0x1cd0, 0x0240, 0x2001, 0x1818, 0x2004,
+	0x9c02, 0x1218, 0x9085, 0x0001, 0x0005, 0x9006, 0x0ce8, 0x00b6,
+	0x7110, 0xd1bc, 0x11d8, 0x7024, 0x2060, 0x9c84, 0x0007, 0x11b0,
+	0x9c82, 0x1cd0, 0x0298, 0x6860, 0x9c02, 0x1280, 0x7008, 0x9084,
+	0x00ff, 0x6110, 0x2158, 0xb910, 0x9106, 0x1140, 0x700c, 0xb914,
+	0x9106, 0x1120, 0x2009, 0x0051, 0x080c, 0x9a50, 0x7817, 0x0140,
+	0x2001, 0x19bf, 0x2004, 0x9005, 0x090c, 0x8582, 0x00be, 0x0005,
+	0x2031, 0x0105, 0x0069, 0x0005, 0x2031, 0x0206, 0x0049, 0x0005,
+	0x2031, 0x0207, 0x0029, 0x0005, 0x2031, 0x0213, 0x0009, 0x0005,
+	0x00c6, 0x0096, 0x00f6, 0x7000, 0x9084, 0xf000, 0x9086, 0xc000,
+	0x05d0, 0x080c, 0x9980, 0x05b8, 0x0066, 0x00c6, 0x0046, 0x2011,
+	0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x24d6, 0x15a0, 0x080c,
+	0x5f1e, 0x1588, 0xbe12, 0xbd16, 0x2b00, 0x004e, 0x00ce, 0x6012,
+	0x080c, 0xba69, 0x080c, 0x0fd5, 0x0510, 0x2900, 0x605a, 0x9006,
+	0xa802, 0xa866, 0xac6a, 0xa85c, 0x90f8, 0x001b, 0x20a9, 0x000e,
+	0xa860, 0x20e8, 0x20e1, 0x0000, 0x2fa0, 0x2e98, 0x4003, 0x006e,
+	0x6616, 0x6007, 0x003e, 0x6023, 0x0001, 0x6003, 0x0001, 0x080c,
+	0x8048, 0x080c, 0x8582, 0x00fe, 0x009e, 0x00ce, 0x0005, 0x080c,
+	0x99d6, 0x006e, 0x0cc0, 0x004e, 0x00ce, 0x0cc8, 0x00c6, 0x7000,
+	0x908c, 0xff00, 0x9184, 0xf000, 0x810f, 0x9086, 0x2000, 0x1904,
+	0x7b6d, 0x9186, 0x0022, 0x15f0, 0x2001, 0x0111, 0x2004, 0x9005,
+	0x1904, 0x7b6f, 0x7030, 0x908e, 0x0400, 0x0904, 0x7b6f, 0x908e,
+	0x6000, 0x05e8, 0x908e, 0x5400, 0x05d0, 0x908e, 0x0300, 0x11d8,
+	0x2009, 0x1835, 0x210c, 0xd18c, 0x1590, 0xd1a4, 0x1580, 0x080c,
+	0x6262, 0x0558, 0x68a8, 0x9084, 0x00ff, 0x7100, 0x918c, 0x00ff,
+	0x9106, 0x1518, 0x6878, 0x69a8, 0x918c, 0xff00, 0x9105, 0x7104,
+	0x9106, 0x11d8, 0x00e0, 0x2009, 0x0103, 0x210c, 0xd1b4, 0x11a8,
+	0x908e, 0x5200, 0x09e8, 0x908e, 0x0500, 0x09d0, 0x908e, 0x5000,
+	0x09b8, 0x0058, 0x9186, 0x0023, 0x1140, 0x080c, 0x7a7d, 0x0128,
+	0x6004, 0x9086, 0x0002, 0x0118, 0x0000, 0x9006, 0x0010, 0x9085,
+	0x0001, 0x00ce, 0x0005, 0x00f6, 0x2079, 0x0200, 0x7800, 0xc0e5,
+	0xc0cc, 0x7802, 0x00fe, 0x0005, 0x00f6, 0x2079, 0x0200, 0x7800,
+	0x9085, 0x1200, 0x7802, 0x00fe, 0x0005, 0x2071, 0x19c9, 0x7003,
+	0x0003, 0x700f, 0x0361, 0x9006, 0x701a, 0x7072, 0x7012, 0x7017,
+	0x1cd0, 0x7007, 0x0000, 0x7026, 0x702b, 0x8fd1, 0x7032, 0x7037,
+	0x903f, 0x703f, 0xffff, 0x7042, 0x7047, 0x4fb2, 0x704a, 0x705b,
+	0x7ce2, 0x080c, 0x0fee, 0x090c, 0x0db2, 0x2900, 0x703a, 0xa867,
+	0x0003, 0xa86f, 0x0100, 0xa8ab, 0xdcb0, 0x0005, 0x2071, 0x19c9,
+	0x1d04, 0x7c39, 0x2091, 0x6000, 0x700c, 0x8001, 0x700e, 0x1510,
+	0x2001, 0x1875, 0x2004, 0xd0c4, 0x0158, 0x3a00, 0xd08c, 0x1140,
+	0x20d1, 0x0000, 0x20d1, 0x0001, 0x20d1, 0x0000, 0x080c, 0x0db2,
+	0x700f, 0x0361, 0x7007, 0x0001, 0x0126, 0x2091, 0x8000, 0x080c,
+	0x7d27, 0x7040, 0x900d, 0x0148, 0x8109, 0x7142, 0x1130, 0x7044,
+	0x080f, 0x0018, 0x0126, 0x2091, 0x8000, 0x7024, 0x900d, 0x0188,
+	0x7020, 0x8001, 0x7022, 0x1168, 0x7023, 0x0009, 0x8109, 0x7126,
+	0x9186, 0x03e8, 0x1110, 0x7028, 0x080f, 0x81ff, 0x1110, 0x7028,
+	0x080f, 0x7030, 0x900d, 0x0180, 0x702c, 0x8001, 0x702e, 0x1160,
+	0x702f, 0x0009, 0x8109, 0x7132, 0x0128, 0x9184, 0x007f, 0x090c,
+	0x90b9, 0x0010, 0x7034, 0x080f, 0x703c, 0x9005, 0x0118, 0x0310,
+	0x8001, 0x703e, 0x704c, 0x900d, 0x0168, 0x7048, 0x8001, 0x704a,
+	0x1148, 0x704b, 0x0009, 0x8109, 0x714e, 0x1120, 0x7150, 0x714e,
+	0x7058, 0x080f, 0x7018, 0x900d, 0x01d8, 0x0016, 0x7070, 0x900d,
+	0x0158, 0x706c, 0x8001, 0x706e, 0x1138, 0x706f, 0x0009, 0x8109,
+	0x7172, 0x1110, 0x7074, 0x080f, 0x001e, 0x7008, 0x8001, 0x700a,
+	0x1138, 0x700b, 0x0009, 0x8109, 0x711a, 0x1110, 0x701c, 0x080f,
+	0x012e, 0x7004, 0x0002, 0x7c61, 0x7c62, 0x7c7e, 0x00e6, 0x2071,
+	0x19c9, 0x7018, 0x9005, 0x1120, 0x711a, 0x721e, 0x700b, 0x0009,
+	0x00ee, 0x0005, 0x00e6, 0x0006, 0x2071, 0x19c9, 0x701c, 0x9206,
+	0x1120, 0x701a, 0x701e, 0x7072, 0x7076, 0x000e, 0x00ee, 0x0005,
+	0x00e6, 0x2071, 0x19c9, 0xb888, 0x9102, 0x0208, 0xb98a, 0x00ee,
+	0x0005, 0x0005, 0x00b6, 0x7110, 0x080c, 0x5f7e, 0x1168, 0xb888,
+	0x8001, 0x0250, 0xb88a, 0x1140, 0x0126, 0x2091, 0x8000, 0x0016,
+	0x080c, 0x8582, 0x001e, 0x012e, 0x8108, 0x9182, 0x0800, 0x0218,
+	0x900e, 0x7007, 0x0002, 0x7112, 0x00be, 0x0005, 0x7014, 0x2060,
+	0x0126, 0x2091, 0x8000, 0x6040, 0x9005, 0x0128, 0x8001, 0x6042,
+	0x1110, 0x080c, 0xb8fa, 0x6018, 0x9005, 0x0510, 0x8001, 0x601a,
+	0x11f8, 0x6120, 0x9186, 0x0003, 0x0118, 0x9186, 0x0006, 0x11b0,
+	0x6014, 0x2048, 0xa884, 0x908a, 0x199a, 0x0280, 0x9082, 0x1999,
+	0xa886, 0x908a, 0x199a, 0x0210, 0x2001, 0x1999, 0x8003, 0x800b,
+	0x810b, 0x9108, 0x611a, 0xa87c, 0xd0e4, 0x0110, 0x080c, 0xb313,
+	0x012e, 0x9c88, 0x0018, 0x7116, 0x2001, 0x1818, 0x2004, 0x9102,
+	0x0220, 0x7017, 0x1cd0, 0x7007, 0x0000, 0x0005, 0x00e6, 0x2071,
+	0x19c9, 0x7027, 0x07d0, 0x7023, 0x0009, 0x00ee, 0x0005, 0x2001,
+	0x19d2, 0x2003, 0x0000, 0x0005, 0x00e6, 0x2071, 0x19c9, 0x7132,
+	0x702f, 0x0009, 0x00ee, 0x0005, 0x2011, 0x19d5, 0x2013, 0x0000,
+	0x0005, 0x00e6, 0x2071, 0x19c9, 0x711a, 0x721e, 0x700b, 0x0009,
+	0x00ee, 0x0005, 0x0086, 0x0026, 0x7054, 0x8000, 0x7056, 0x2001,
+	0x19d7, 0x2044, 0xa06c, 0x9086, 0x0000, 0x0150, 0x7068, 0xa09a,
+	0x7064, 0xa096, 0x7060, 0xa092, 0x705c, 0xa08e, 0x080c, 0x10b5,
+	0x002e, 0x008e, 0x0005, 0x0006, 0x0016, 0x0096, 0x00a6, 0x00b6,
+	0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x0156, 0x080c, 0x7bae, 0x015e,
+	0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x00ae, 0x009e, 0x001e,
+	0x000e, 0x0005, 0x00e6, 0x2071, 0x19c9, 0x7172, 0x7276, 0x706f,
+	0x0009, 0x00ee, 0x0005, 0x00e6, 0x0006, 0x2071, 0x19c9, 0x7074,
+	0x9206, 0x1110, 0x7072, 0x7076, 0x000e, 0x00ee, 0x0005, 0x2069,
+	0x1800, 0x69e0, 0xd1e4, 0x1518, 0x0026, 0xd1ec, 0x0140, 0x6a4c,
+	0x686c, 0x9202, 0x0288, 0x8117, 0x9294, 0x00c0, 0x0088, 0x9184,
+	0x0007, 0x01a0, 0x8109, 0x9184, 0x0007, 0x0110, 0x69e2, 0x0070,
+	0x8107, 0x9084, 0x0007, 0x910d, 0x8107, 0x9106, 0x9094, 0x00c0,
+	0x9184, 0xff3f, 0x9205, 0x68e2, 0x080c, 0x0eb4, 0x002e, 0x0005,
+	0x00c6, 0x2061, 0x1a3e, 0x00ce, 0x0005, 0x9184, 0x000f, 0x8003,
+	0x8003, 0x8003, 0x9080, 0x1a3e, 0x2060, 0x0005, 0xa884, 0x908a,
+	0x199a, 0x1638, 0x9005, 0x1150, 0x00c6, 0x2061, 0x1a3e, 0x6014,
+	0x00ce, 0x9005, 0x1130, 0x2001, 0x001e, 0x0018, 0x908e, 0xffff,
+	0x01b0, 0x8003, 0x800b, 0x810b, 0x9108, 0x611a, 0xa87c, 0x908c,
+	0x00c0, 0x918e, 0x00c0, 0x0904, 0x7de8, 0xd0b4, 0x1168, 0xd0bc,
+	0x1904, 0x7dc1, 0x2009, 0x0006, 0x080c, 0x7e15, 0x0005, 0x900e,
+	0x0c60, 0x2001, 0x1999, 0x08b0, 0xd0fc, 0x0160, 0x908c, 0x0003,
+	0x0120, 0x918e, 0x0003, 0x1904, 0x7e0f, 0x908c, 0x2020, 0x918e,
+	0x2020, 0x01a8, 0x6024, 0xd0d4, 0x11e8, 0x2009, 0x1875, 0x2104,
+	0xd084, 0x1138, 0x87ff, 0x1120, 0x2009, 0x0043, 0x0804, 0x9a50,
+	0x0005, 0x87ff, 0x1de8, 0x2009, 0x0042, 0x0804, 0x9a50, 0x6110,
+	0x00b6, 0x2158, 0xb900, 0x00be, 0xd1ac, 0x0d20, 0x6024, 0xc0cd,
+	0x6026, 0x0c00, 0xc0d4, 0x6026, 0xa890, 0x602e, 0xa88c, 0x6032,
+	0x08e0, 0xd0fc, 0x0160, 0x908c, 0x0003, 0x0120, 0x918e, 0x0003,
+	0x1904, 0x7e0f, 0x908c, 0x2020, 0x918e, 0x2020, 0x0170, 0x0076,
+	0x00f6, 0x2c78, 0x080c, 0x1582, 0x00fe, 0x007e, 0x87ff, 0x1120,
+	0x2009, 0x0042, 0x080c, 0x9a50, 0x0005, 0x6110, 0x00b6, 0x2158,
+	0xb900, 0x00be, 0xd1ac, 0x0d58, 0x6124, 0xc1cd, 0x6126, 0x0c38,
+	0xd0fc, 0x0188, 0x908c, 0x2020, 0x918e, 0x2020, 0x01a8, 0x9084,
+	0x0003, 0x908e, 0x0002, 0x0148, 0x87ff, 0x1120, 0x2009, 0x0041,
+	0x080c, 0x9a50, 0x0005, 0x00b9, 0x0ce8, 0x87ff, 0x1dd8, 0x2009,
+	0x0043, 0x080c, 0x9a50, 0x0cb0, 0x6110, 0x00b6, 0x2158, 0xb900,
+	0x00be, 0xd1ac, 0x0d20, 0x6124, 0xc1cd, 0x6126, 0x0c00, 0x2009,
+	0x0004, 0x0019, 0x0005, 0x2009, 0x0001, 0x0096, 0x080c, 0xb5fb,
+	0x0518, 0x6014, 0x2048, 0xa982, 0xa800, 0x6016, 0x9186, 0x0001,
+	0x1188, 0xa97c, 0x918c, 0x8100, 0x918e, 0x8100, 0x1158, 0x00c6,
+	0x2061, 0x1a3e, 0x6200, 0xd28c, 0x1120, 0x6204, 0x8210, 0x0208,
+	0x6206, 0x00ce, 0x080c, 0x6370, 0x6014, 0x904d, 0x0076, 0x2039,
+	0x0000, 0x190c, 0x7d5e, 0x007e, 0x009e, 0x0005, 0x0156, 0x00c6,
+	0x2061, 0x1a3e, 0x6000, 0x81ff, 0x0110, 0x9205, 0x0008, 0x9204,
+	0x6002, 0x00ce, 0x015e, 0x0005, 0x6800, 0xd08c, 0x1138, 0x6808,
+	0x9005, 0x0120, 0x8001, 0x680a, 0x9085, 0x0001, 0x0005, 0x0126,
+	0x2091, 0x8000, 0x0036, 0x0046, 0x20a9, 0x0010, 0x9006, 0x8004,
+	0x2019, 0x0100, 0x231c, 0x93a6, 0x0008, 0x1118, 0x8086, 0x818e,
+	0x0020, 0x80f6, 0x3e00, 0x81f6, 0x3e08, 0x1208, 0x9200, 0x1f04,
+	0x7e60, 0x93a6, 0x0008, 0x1118, 0x8086, 0x818e, 0x0020, 0x80f6,
+	0x3e00, 0x81f6, 0x3e08, 0x004e, 0x003e, 0x012e, 0x0005, 0x0126,
+	0x2091, 0x8000, 0x0076, 0x0156, 0x20a9, 0x0010, 0x9005, 0x0510,
+	0x911a, 0x1600, 0x8213, 0x2039, 0x0100, 0x273c, 0x97be, 0x0008,
+	0x1110, 0x818d, 0x0010, 0x81f5, 0x3e08, 0x0228, 0x911a, 0x1220,
+	0x1f04, 0x7e8a, 0x0028, 0x911a, 0x2308, 0x8210, 0x1f04, 0x7e8a,
+	0x0006, 0x3200, 0x9084, 0xefff, 0x2080, 0x000e, 0x015e, 0x007e,
+	0x012e, 0x0005, 0x0006, 0x3200, 0x9085, 0x1000, 0x0ca8, 0x0126,
+	0x2091, 0x2800, 0x2079, 0x19b6, 0x012e, 0x00d6, 0x2069, 0x19b6,
+	0x6803, 0x0005, 0x0156, 0x0146, 0x01d6, 0x20e9, 0x0000, 0x2069,
+	0x0200, 0x080c, 0x97ce, 0x0401, 0x080c, 0x97b9, 0x00e9, 0x080c,
+	0x97bc, 0x00d1, 0x080c, 0x97bf, 0x00b9, 0x080c, 0x97c2, 0x00a1,
+	0x080c, 0x97c5, 0x0089, 0x080c, 0x97c8, 0x0071, 0x080c, 0x97cb,
+	0x0059, 0x01de, 0x014e, 0x015e, 0x2069, 0x0004, 0x2d04, 0x9085,
+	0x8001, 0x206a, 0x00de, 0x0005, 0x20a9, 0x0020, 0x20a1, 0x0240,
+	0x2001, 0x0000, 0x4004, 0x0005, 0x00c6, 0x6027, 0x0001, 0x7804,
+	0x9084, 0x0007, 0x0002, 0x7efd, 0x7f21, 0x7f60, 0x7f03, 0x7f21,
+	0x7efd, 0x7efb, 0x7efb, 0x080c, 0x0db2, 0x080c, 0x7cc7, 0x080c,
+	0x8582, 0x00ce, 0x0005, 0x62c0, 0x82ff, 0x1110, 0x00ce, 0x0005,
+	0x2011, 0x588a, 0x080c, 0x7c4a, 0x7828, 0x9092, 0x00c8, 0x1228,
+	0x8000, 0x782a, 0x080c, 0x58ca, 0x0c88, 0x62c0, 0x080c, 0x97d2,
+	0x080c, 0x588a, 0x7807, 0x0003, 0x7827, 0x0000, 0x782b, 0x0000,
+	0x0c28, 0x080c, 0x7cc7, 0x6220, 0xd2a4, 0x0160, 0x782b, 0x0000,
+	0x7824, 0x9065, 0x090c, 0x0db2, 0x2009, 0x0013, 0x080c, 0x9a50,
+	0x00ce, 0x0005, 0x00c6, 0x7824, 0x9065, 0x090c, 0x0db2, 0x7828,
+	0x9092, 0xc350, 0x12c0, 0x8000, 0x782a, 0x00ce, 0x080c, 0x283d,
+	0x0278, 0x00c6, 0x7924, 0x2160, 0x6010, 0x906d, 0x090c, 0x0db2,
+	0x7807, 0x0000, 0x7827, 0x0000, 0x00ce, 0x080c, 0x8582, 0x0c00,
+	0x080c, 0x8f97, 0x08e8, 0x2011, 0x0130, 0x2214, 0x080c, 0x97d2,
+	0x080c, 0xd358, 0x2009, 0x0014, 0x080c, 0x9a50, 0x00ce, 0x0880,
+	0x2001, 0x19d2, 0x2003, 0x0000, 0x62c0, 0x82ff, 0x1160, 0x782b,
+	0x0000, 0x7824, 0x9065, 0x090c, 0x0db2, 0x2009, 0x0013, 0x080c,
+	0x9aa2, 0x00ce, 0x0005, 0x00b6, 0x00c6, 0x00d6, 0x7824, 0x9005,
+	0x090c, 0x0db2, 0x7828, 0x9092, 0xc350, 0x1648, 0x8000, 0x782a,
+	0x00de, 0x00ce, 0x00be, 0x080c, 0x283d, 0x02f0, 0x00b6, 0x00c6,
+	0x00d6, 0x781c, 0x905d, 0x090c, 0x0db2, 0xb800, 0xc0dc, 0xb802,
+	0x7924, 0x2160, 0x080c, 0x99d6, 0xb93c, 0x81ff, 0x090c, 0x0db2,
+	0x8109, 0xb93e, 0x7807, 0x0000, 0x7827, 0x0000, 0x00de, 0x00ce,
+	0x00be, 0x080c, 0x8582, 0x0868, 0x080c, 0x8f97, 0x0850, 0x2011,
+	0x0130, 0x2214, 0x080c, 0x97d2, 0x080c, 0xd358, 0x7824, 0x9065,
+	0x2009, 0x0014, 0x080c, 0x9a50, 0x00de, 0x00ce, 0x00be, 0x0804,
+	0x7f71, 0x00c6, 0x2001, 0x009b, 0x2004, 0xd0fc, 0x190c, 0x1be4,
+	0x6024, 0x6027, 0x0002, 0xd0f4, 0x1580, 0x62c8, 0x60c4, 0x9205,
+	0x1170, 0x783c, 0x9065, 0x0130, 0x2009, 0x0049, 0x080c, 0x9a50,
+	0x00ce, 0x0005, 0x2011, 0x19d5, 0x2013, 0x0000, 0x0cc8, 0x793c,
+	0x81ff, 0x0dc0, 0x7944, 0x9192, 0x7530, 0x12f0, 0x8108, 0x7946,
+	0x793c, 0x9188, 0x0008, 0x210c, 0x918e, 0x0006, 0x1138, 0x6014,
+	0x9084, 0x1984, 0x9085, 0x0012, 0x6016, 0x0c10, 0x6014, 0x9084,
+	0x1984, 0x9085, 0x0016, 0x6016, 0x08d8, 0x793c, 0x2160, 0x2009,
+	0x004a, 0x080c, 0x9a50, 0x08a0, 0x7848, 0xc085, 0x784a, 0x0880,
+	0x0006, 0x0016, 0x00c6, 0x0126, 0x2091, 0x8000, 0x600f, 0x0000,
+	0x2c08, 0x2061, 0x19b6, 0x6020, 0x8000, 0x6022, 0x6010, 0x9005,
+	0x0148, 0x9080, 0x0003, 0x2102, 0x6112, 0x012e, 0x00ce, 0x001e,
+	0x000e, 0x0005, 0x6116, 0x6112, 0x0cc0, 0x00d6, 0x2069, 0x19b6,
+	0xb800, 0xd0d4, 0x0168, 0x6820, 0x8000, 0x6822, 0x9086, 0x0001,
+	0x1110, 0x2b00, 0x681e, 0x00de, 0x0804, 0x8582, 0x00de, 0x0005,
+	0xc0d5, 0xb802, 0x6818, 0x9005, 0x0168, 0xb856, 0xb85b, 0x0000,
+	0x0086, 0x0006, 0x2b00, 0x681a, 0x008e, 0xa05a, 0x008e, 0x2069,
+	0x19b6, 0x0c08, 0xb856, 0xb85a, 0x2b00, 0x681a, 0x681e, 0x08d8,
+	0x0006, 0x0016, 0x00c6, 0x0126, 0x2091, 0x8000, 0x600f, 0x0000,
+	0x2c08, 0x2061, 0x19b6, 0x6020, 0x8000, 0x6022, 0x6008, 0x9005,
+	0x0148, 0x9080, 0x0003, 0x2102, 0x610a, 0x012e, 0x00ce, 0x001e,
+	0x000e, 0x0005, 0x610e, 0x610a, 0x0cc0, 0x00c6, 0x600f, 0x0000,
+	0x2c08, 0x2061, 0x19b6, 0x6034, 0x9005, 0x0130, 0x9080, 0x0003,
+	0x2102, 0x6136, 0x00ce, 0x0005, 0x613a, 0x6136, 0x00ce, 0x0005,
+	0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x00b6, 0x0096, 0x0076, 0x0066,
+	0x0056, 0x0036, 0x0026, 0x0016, 0x0006, 0x0126, 0x902e, 0x2071,
+	0x19b6, 0x7638, 0x2660, 0x2678, 0x2091, 0x8000, 0x8cff, 0x0904,
+	0x80ef, 0x6010, 0x2058, 0xb8a0, 0x9206, 0x1904, 0x80ea, 0x87ff,
+	0x0120, 0x6054, 0x9106, 0x1904, 0x80ea, 0x703c, 0x9c06, 0x1178,
+	0x0036, 0x2019, 0x0001, 0x080c, 0x9254, 0x7033, 0x0000, 0x9006,
+	0x703e, 0x7042, 0x7046, 0x704a, 0x003e, 0x2029, 0x0001, 0x7038,
+	0x9c36, 0x1110, 0x660c, 0x763a, 0x7034, 0x9c36, 0x1140, 0x2c00,
+	0x9f36, 0x0118, 0x2f00, 0x7036, 0x0010, 0x7037, 0x0000, 0x660c,
+	0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f,
+	0x0000, 0x080c, 0xb5fb, 0x01c8, 0x6014, 0x2048, 0x6020, 0x9086,
+	0x0003, 0x1590, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x0016,
+	0x0036, 0x0076, 0x080c, 0xb8e3, 0x080c, 0xd28c, 0x080c, 0x6536,
+	0x007e, 0x003e, 0x001e, 0x080c, 0xb7dd, 0x080c, 0x9a06, 0x00ce,
+	0x0804, 0x808e, 0x2c78, 0x600c, 0x2060, 0x0804, 0x808e, 0x85ff,
+	0x0120, 0x0036, 0x080c, 0x865d, 0x003e, 0x012e, 0x000e, 0x001e,
+	0x002e, 0x003e, 0x005e, 0x006e, 0x007e, 0x009e, 0x00be, 0x00ce,
+	0x00de, 0x00ee, 0x00fe, 0x0005, 0x6020, 0x9086, 0x0006, 0x1158,
+	0x0016, 0x0036, 0x0076, 0x080c, 0xd28c, 0x080c, 0xcf91, 0x007e,
+	0x003e, 0x001e, 0x0890, 0x6020, 0x9086, 0x000a, 0x0904, 0x80d4,
+	0x0804, 0x80d2, 0x0006, 0x0066, 0x0096, 0x00c6, 0x00d6, 0x00f6,
+	0x9036, 0x0126, 0x2091, 0x8000, 0x2079, 0x19b6, 0x7838, 0x9065,
+	0x0904, 0x816a, 0x600c, 0x0006, 0x600f, 0x0000, 0x783c, 0x9c06,
+	0x1168, 0x0036, 0x2019, 0x0001, 0x080c, 0x9254, 0x7833, 0x0000,
+	0x901e, 0x7b3e, 0x7b42, 0x7b46, 0x7b4a, 0x003e, 0x080c, 0xb5fb,
+	0x0520, 0x6014, 0x2048, 0x6020, 0x9086, 0x0003, 0x1568, 0x3e08,
+	0x918e, 0x0002, 0x1188, 0x6010, 0x9005, 0x0170, 0x00b6, 0x2058,
+	0xb800, 0x00be, 0xd0bc, 0x0140, 0x6040, 0x9005, 0x1180, 0x2001,
+	0x1957, 0x2004, 0x6042, 0x0058, 0xa867, 0x0103, 0xab7a, 0xa877,
+	0x0000, 0x080c, 0x6529, 0x080c, 0xb7dd, 0x080c, 0x9a06, 0x000e,
+	0x0804, 0x8127, 0x7e3a, 0x7e36, 0x012e, 0x00fe, 0x00de, 0x00ce,
+	0x009e, 0x006e, 0x000e, 0x0005, 0x6020, 0x9086, 0x0006, 0x1118,
+	0x080c, 0xcf91, 0x0c50, 0x6020, 0x9086, 0x000a, 0x09f8, 0x08e0,
+	0x0016, 0x0026, 0x0086, 0x9046, 0x0099, 0x080c, 0x8269, 0x008e,
+	0x002e, 0x001e, 0x0005, 0x00f6, 0x0126, 0x2079, 0x19b6, 0x2091,
+	0x8000, 0x080c, 0x8300, 0x080c, 0x838e, 0x012e, 0x00fe, 0x0005,
+	0x00b6, 0x0096, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0016,
+	0x0006, 0x0126, 0x2091, 0x8000, 0x2071, 0x19b6, 0x7614, 0x2660,
+	0x2678, 0x8cff, 0x0904, 0x822e, 0x6010, 0x2058, 0xb8a0, 0x9206,
+	0x1904, 0x8229, 0x88ff, 0x0120, 0x6054, 0x9106, 0x1904, 0x8229,
+	0x7024, 0x9c06, 0x1558, 0x2069, 0x0100, 0x6820, 0xd0a4, 0x1508,
+	0x080c, 0x7cc7, 0x080c, 0x8fbb, 0x68c3, 0x0000, 0x080c, 0x9469,
+	0x7027, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000,
+	0x0138, 0x2001, 0x0100, 0x080c, 0x2987, 0x9006, 0x080c, 0x2987,
+	0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e,
+	0x0028, 0x6003, 0x0009, 0x630a, 0x0804, 0x8229, 0x7014, 0x9c36,
+	0x1110, 0x660c, 0x7616, 0x7010, 0x9c36, 0x1140, 0x2c00, 0x9f36,
+	0x0118, 0x2f00, 0x7012, 0x0010, 0x7013, 0x0000, 0x660c, 0x0066,
+	0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000,
+	0x6014, 0x2048, 0x080c, 0xb5fb, 0x01e8, 0x6020, 0x9086, 0x0003,
+	0x1580, 0x080c, 0xb7fa, 0x1118, 0x080c, 0xa364, 0x0098, 0xa867,
+	0x0103, 0xab7a, 0xa877, 0x0000, 0x0016, 0x0036, 0x0086, 0x080c,
+	0xb8e3, 0x080c, 0xd28c, 0x080c, 0x6536, 0x008e, 0x003e, 0x001e,
+	0x080c, 0xb7dd, 0x080c, 0x9a06, 0x080c, 0x933f, 0x00ce, 0x0804,
+	0x81a9, 0x2c78, 0x600c, 0x2060, 0x0804, 0x81a9, 0x012e, 0x000e,
+	0x001e, 0x006e, 0x00ce, 0x00de, 0x00ee, 0x00fe, 0x009e, 0x00be,
+	0x0005, 0x6020, 0x9086, 0x0006, 0x1158, 0x0016, 0x0036, 0x0086,
+	0x080c, 0xd28c, 0x080c, 0xcf91, 0x008e, 0x003e, 0x001e, 0x08d0,
+	0x080c, 0xa364, 0x6020, 0x9086, 0x0002, 0x1160, 0x6004, 0x0006,
+	0x9086, 0x0085, 0x000e, 0x0904, 0x820f, 0x9086, 0x008b, 0x0904,
+	0x820f, 0x0840, 0x6020, 0x9086, 0x0005, 0x1920, 0x6004, 0x0006,
+	0x9086, 0x0085, 0x000e, 0x09c8, 0x9086, 0x008b, 0x09b0, 0x0804,
+	0x8222, 0x00b6, 0x00a6, 0x0096, 0x00c6, 0x0006, 0x0126, 0x2091,
+	0x8000, 0x9280, 0x1000, 0x2004, 0x905d, 0x0904, 0x82f9, 0x00f6,
+	0x00e6, 0x00d6, 0x0066, 0x2071, 0x19b6, 0xbe54, 0x7018, 0x9b06,
+	0x1108, 0x761a, 0x701c, 0x9b06, 0x1130, 0x86ff, 0x1118, 0x7018,
+	0x701e, 0x0008, 0x761e, 0xb858, 0x904d, 0x0108, 0xae56, 0x96d5,
+	0x0000, 0x0110, 0x2900, 0xb05a, 0xb857, 0x0000, 0xb85b, 0x0000,
+	0xb800, 0xc0d4, 0xc0dc, 0xb802, 0x080c, 0x5eb1, 0x0904, 0x82f5,
+	0x7624, 0x86ff, 0x0904, 0x82e4, 0x9680, 0x0005, 0x2004, 0x9906,
+	0x15d8, 0x00d6, 0x2069, 0x0100, 0x68c0, 0x9005, 0x0560, 0x080c,
+	0x7cc7, 0x080c, 0x8fbb, 0x68c3, 0x0000, 0x080c, 0x9469, 0x7027,
+	0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138,
+	0x2001, 0x0100, 0x080c, 0x2987, 0x9006, 0x080c, 0x2987, 0x2069,
+	0x0100, 0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x00de,
+	0x00c6, 0xb83c, 0x9005, 0x0110, 0x8001, 0xb83e, 0x2660, 0x080c,
+	0x9a06, 0x00ce, 0x0048, 0x00de, 0x00c6, 0x2660, 0x6003, 0x0009,
+	0x630a, 0x00ce, 0x0804, 0x829c, 0x89ff, 0x0158, 0xa867, 0x0103,
+	0xab7a, 0xa877, 0x0000, 0x080c, 0xb8e3, 0x080c, 0xd28c, 0x080c,
+	0x6536, 0x080c, 0x933f, 0x0804, 0x829c, 0x006e, 0x00de, 0x00ee,
+	0x00fe, 0x012e, 0x000e, 0x00ce, 0x009e, 0x00ae, 0x00be, 0x0005,
+	0x0096, 0x0006, 0x0066, 0x00c6, 0x00d6, 0x9036, 0x7814, 0x9065,
+	0x0904, 0x8361, 0x600c, 0x0006, 0x600f, 0x0000, 0x7824, 0x9c06,
+	0x1570, 0x2069, 0x0100, 0x6820, 0xd0a4, 0x1508, 0x080c, 0x7cc7,
+	0x080c, 0x8fbb, 0x68c3, 0x0000, 0x080c, 0x9469, 0x7827, 0x0000,
+	0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138, 0x2001,
+	0x0100, 0x080c, 0x2987, 0x9006, 0x080c, 0x2987, 0x2069, 0x0100,
+	0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x0040, 0x080c,
+	0x625a, 0x1520, 0x6003, 0x0009, 0x630a, 0x2c30, 0x00f8, 0x6014,
+	0x2048, 0x080c, 0xb5f9, 0x01b0, 0x6020, 0x9086, 0x0003, 0x1508,
+	0x080c, 0xb7fa, 0x1118, 0x080c, 0xa364, 0x0060, 0x080c, 0x625a,
+	0x1168, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0x6536,
+	0x080c, 0xb7dd, 0x080c, 0x9a06, 0x080c, 0x933f, 0x000e, 0x0804,
+	0x8307, 0x7e16, 0x7e12, 0x00de, 0x00ce, 0x006e, 0x000e, 0x009e,
+	0x0005, 0x6020, 0x9086, 0x0006, 0x1118, 0x080c, 0xcf91, 0x0c50,
+	0x080c, 0xa364, 0x6020, 0x9086, 0x0002, 0x1150, 0x6004, 0x0006,
+	0x9086, 0x0085, 0x000e, 0x0990, 0x9086, 0x008b, 0x0978, 0x08d0,
+	0x6020, 0x9086, 0x0005, 0x19b0, 0x6004, 0x0006, 0x9086, 0x0085,
+	0x000e, 0x0d18, 0x9086, 0x008b, 0x0d00, 0x0860, 0x0006, 0x0066,
+	0x0096, 0x00b6, 0x00c6, 0x00d6, 0x7818, 0x905d, 0x0904, 0x840e,
+	0xb854, 0x0006, 0x9006, 0xb856, 0xb85a, 0xb800, 0xc0d4, 0xc0dc,
+	0xb802, 0x080c, 0x5eb1, 0x0904, 0x840b, 0x7e24, 0x86ff, 0x0904,
+	0x83fe, 0x9680, 0x0005, 0x2004, 0x9906, 0x1904, 0x83fe, 0x00d6,
+	0x2069, 0x0100, 0x68c0, 0x9005, 0x0904, 0x83f5, 0x080c, 0x7cc7,
+	0x080c, 0x8fbb, 0x68c3, 0x0000, 0x080c, 0x9469, 0x7827, 0x0000,
+	0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138, 0x2001,
+	0x0100, 0x080c, 0x2987, 0x9006, 0x080c, 0x2987, 0x2069, 0x0100,
+	0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x00de, 0x00c6,
+	0x3e08, 0x918e, 0x0002, 0x1168, 0xb800, 0xd0bc, 0x0150, 0x9680,
+	0x0010, 0x200c, 0x81ff, 0x1518, 0x2009, 0x1957, 0x210c, 0x2102,
+	0x00f0, 0xb83c, 0x9005, 0x0110, 0x8001, 0xb83e, 0x2660, 0x600f,
+	0x0000, 0x080c, 0x9a06, 0x00ce, 0x0048, 0x00de, 0x00c6, 0x2660,
+	0x6003, 0x0009, 0x630a, 0x00ce, 0x0804, 0x83a1, 0x89ff, 0x0138,
+	0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0x6536, 0x080c,
+	0x933f, 0x0804, 0x83a1, 0x000e, 0x0804, 0x8395, 0x781e, 0x781a,
+	0x00de, 0x00ce, 0x00be, 0x009e, 0x006e, 0x000e, 0x0005, 0x00e6,
+	0x00d6, 0x0096, 0x0066, 0xb800, 0xd0dc, 0x01a0, 0xb84c, 0x904d,
+	0x0188, 0xa878, 0x9606, 0x1170, 0x2071, 0x19b6, 0x7024, 0x9035,
+	0x0148, 0x9080, 0x0005, 0x2004, 0x9906, 0x1120, 0xb800, 0xc0dc,
+	0xb802, 0x0029, 0x006e, 0x009e, 0x00de, 0x00ee, 0x0005, 0x00f6,
+	0x2079, 0x0100, 0x78c0, 0x9005, 0x1138, 0x00c6, 0x2660, 0x6003,
+	0x0009, 0x630a, 0x00ce, 0x04b8, 0x080c, 0x8fbb, 0x78c3, 0x0000,
+	0x080c, 0x9469, 0x7027, 0x0000, 0x0036, 0x2079, 0x0140, 0x7b04,
+	0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2987, 0x9006,
+	0x080c, 0x2987, 0x2079, 0x0100, 0x7824, 0xd084, 0x0110, 0x7827,
+	0x0001, 0x080c, 0x9469, 0x003e, 0x080c, 0x5eb1, 0x00c6, 0xb83c,
+	0x9005, 0x0110, 0x8001, 0xb83e, 0x2660, 0x080c, 0x99d6, 0x00ce,
+	0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0xb8e3, 0x080c,
+	0x6536, 0x080c, 0x933f, 0x00fe, 0x0005, 0x00b6, 0x00e6, 0x00c6,
+	0x2011, 0x0101, 0x2204, 0xc0c4, 0x2012, 0x2001, 0x180c, 0x2014,
+	0xc2e4, 0x2202, 0x2071, 0x19b6, 0x7004, 0x9084, 0x0007, 0x0002,
+	0x849a, 0x849e, 0x84b5, 0x84de, 0x851c, 0x849a, 0x84b5, 0x8498,
+	0x080c, 0x0db2, 0x00ce, 0x00ee, 0x00be, 0x0005, 0x7024, 0x9065,
+	0x0148, 0x7020, 0x8001, 0x7022, 0x600c, 0x9015, 0x0158, 0x7216,
+	0x600f, 0x0000, 0x7007, 0x0000, 0x7027, 0x0000, 0x00ce, 0x00ee,
+	0x00be, 0x0005, 0x7216, 0x7212, 0x0ca8, 0x6010, 0x2058, 0x080c,
+	0x5eb1, 0xb800, 0xc0dc, 0xb802, 0x7007, 0x0000, 0x7027, 0x0000,
+	0x7020, 0x8001, 0x7022, 0x1148, 0x2001, 0x180c, 0x2014, 0xd2ec,
+	0x1180, 0x00ce, 0x00ee, 0x00be, 0x0005, 0xb854, 0x9015, 0x0120,
+	0x721e, 0x080c, 0x8582, 0x0ca8, 0x7218, 0x721e, 0x080c, 0x8582,
+	0x0c80, 0xc2ec, 0x2202, 0x080c, 0x865d, 0x0c58, 0x7024, 0x9065,
+	0x05b8, 0x700c, 0x9c06, 0x1160, 0x080c, 0x933f, 0x600c, 0x9015,
+	0x0120, 0x720e, 0x600f, 0x0000, 0x0448, 0x720e, 0x720a, 0x0430,
+	0x7014, 0x9c06, 0x1160, 0x080c, 0x933f, 0x600c, 0x9015, 0x0120,
+	0x7216, 0x600f, 0x0000, 0x00d0, 0x7216, 0x7212, 0x00b8, 0x6020,
+	0x9086, 0x0003, 0x1198, 0x6010, 0x2058, 0x080c, 0x5eb1, 0xb800,
+	0xc0dc, 0xb802, 0x080c, 0x933f, 0x701c, 0x9065, 0x0138, 0xb854,
+	0x9015, 0x0110, 0x721e, 0x0010, 0x7218, 0x721e, 0x7027, 0x0000,
+	0x00ce, 0x00ee, 0x00be, 0x0005, 0x7024, 0x9065, 0x0140, 0x080c,
+	0x933f, 0x600c, 0x9015, 0x0158, 0x720e, 0x600f, 0x0000, 0x080c,
+	0x9469, 0x7027, 0x0000, 0x00ce, 0x00ee, 0x00be, 0x0005, 0x720e,
+	0x720a, 0x0ca8, 0x00d6, 0x2069, 0x19b6, 0x6830, 0x9084, 0x0003,
+	0x0002, 0x853f, 0x8541, 0x8565, 0x853d, 0x080c, 0x0db2, 0x00de,
+	0x0005, 0x00c6, 0x6840, 0x9086, 0x0001, 0x01b8, 0x683c, 0x9065,
+	0x0130, 0x600c, 0x9015, 0x0170, 0x6a3a, 0x600f, 0x0000, 0x6833,
+	0x0000, 0x683f, 0x0000, 0x2011, 0x19d5, 0x2013, 0x0000, 0x00ce,
+	0x00de, 0x0005, 0x683a, 0x6836, 0x0c90, 0x6843, 0x0000, 0x6838,
+	0x9065, 0x0d68, 0x6003, 0x0003, 0x0c50, 0x00c6, 0x9006, 0x6842,
+	0x6846, 0x684a, 0x683c, 0x9065, 0x0160, 0x600c, 0x9015, 0x0130,
+	0x6a3a, 0x600f, 0x0000, 0x683f, 0x0000, 0x0018, 0x683e, 0x683a,
+	0x6836, 0x00ce, 0x00de, 0x0005, 0x2001, 0x180c, 0x200c, 0xc1e5,
+	0x2102, 0x0005, 0x2001, 0x180c, 0x200c, 0xd1ec, 0x0120, 0xc1ec,
+	0x2102, 0x080c, 0x865d, 0x2001, 0x19c2, 0x2004, 0x9086, 0x0001,
+	0x0d58, 0x00d6, 0x2069, 0x19b6, 0x6804, 0x9084, 0x0007, 0x0002,
+	0x85a2, 0x8645, 0x8645, 0x8645, 0x8645, 0x8647, 0x8645, 0x85a0,
+	0x080c, 0x0db2, 0x6820, 0x9005, 0x1110, 0x00de, 0x0005, 0x00c6,
+	0x680c, 0x9065, 0x0150, 0x6807, 0x0004, 0x6826, 0x682b, 0x0000,
+	0x080c, 0x86b3, 0x00ce, 0x00de, 0x0005, 0x6814, 0x9065, 0x0150,
+	0x6807, 0x0001, 0x6826, 0x682b, 0x0000, 0x080c, 0x86b3, 0x00ce,
+	0x00de, 0x0005, 0x00b6, 0x00e6, 0x6a1c, 0x92dd, 0x0000, 0x0904,
+	0x8631, 0xb84c, 0x900d, 0x0118, 0xb888, 0x9005, 0x01a0, 0xb854,
+	0x905d, 0x0120, 0x920e, 0x0904, 0x8631, 0x0028, 0x6818, 0x920e,
+	0x0904, 0x8631, 0x2058, 0xb84c, 0x900d, 0x0d88, 0xb888, 0x9005,
+	0x1d70, 0x2b00, 0x681e, 0xbb3c, 0xb838, 0x9302, 0x1e40, 0x080c,
+	0x99ad, 0x0904, 0x8631, 0x8318, 0xbb3e, 0x6116, 0x2b10, 0x6212,
+	0x0096, 0x2148, 0xa880, 0x9084, 0x00ff, 0x605e, 0xa883, 0x0000,
+	0xa884, 0x009e, 0x908a, 0x199a, 0x0210, 0x2001, 0x1999, 0x8003,
+	0x801b, 0x831b, 0x9318, 0x631a, 0x6114, 0x0096, 0x2148, 0xa964,
+	0x009e, 0x918c, 0x00ff, 0x918e, 0x0048, 0x0538, 0x00f6, 0x2c78,
+	0x2061, 0x0100, 0xbab0, 0x629a, 0x2069, 0x0200, 0x2071, 0x0240,
+	0x080c, 0x8bf2, 0x2069, 0x19b6, 0xbb00, 0xc3dd, 0xbb02, 0x6807,
+	0x0002, 0x2f18, 0x6b26, 0x682b, 0x0000, 0x7823, 0x0003, 0x7803,
+	0x0001, 0x7807, 0x0040, 0x00fe, 0x00ee, 0x00be, 0x00ce, 0x00de,
+	0x0005, 0x00ee, 0x00be, 0x00ce, 0x0cd0, 0xbb00, 0xc3dd, 0xbb02,
+	0x6807, 0x0006, 0x2f18, 0x6b26, 0x682b, 0x0000, 0x080c, 0x97f2,
+	0x00ee, 0x00be, 0x00ce, 0x00de, 0x0005, 0x00de, 0x0005, 0x00c6,
+	0x680c, 0x9065, 0x0138, 0x6807, 0x0004, 0x6826, 0x682b, 0x0000,
+	0x080c, 0x86b3, 0x00ce, 0x00de, 0x0005, 0x2001, 0x180c, 0x2014,
+	0xc2ed, 0x2202, 0x00de, 0x00fe, 0x0005, 0x00f6, 0x00d6, 0x2069,
+	0x19b6, 0x6830, 0x9086, 0x0000, 0x1548, 0x2001, 0x180c, 0x2014,
+	0xd2e4, 0x0130, 0xc2e4, 0x2202, 0x080c, 0x8591, 0x2069, 0x19b6,
+	0x2001, 0x180c, 0x200c, 0xd1c4, 0x11e0, 0x6838, 0x907d, 0x01b0,
+	0x6a04, 0x9296, 0x0000, 0x1588, 0x6833, 0x0001, 0x683e, 0x6847,
+	0x0000, 0x684b, 0x0000, 0x0126, 0x00f6, 0x2091, 0x2400, 0x002e,
+	0x080c, 0x19f2, 0x1178, 0x012e, 0x080c, 0x8e0a, 0x00de, 0x00fe,
+	0x0005, 0xc1c4, 0x2102, 0x0066, 0x2031, 0x0001, 0x080c, 0x6d03,
+	0x006e, 0x08d8, 0x012e, 0x6843, 0x0000, 0x7803, 0x0002, 0x780c,
+	0x9015, 0x0140, 0x6a3a, 0x780f, 0x0000, 0x6833, 0x0000, 0x683f,
+	0x0000, 0x0c20, 0x683a, 0x6836, 0x0cc0, 0x6a04, 0x9296, 0x0006,
+	0x0958, 0x0804, 0x8655, 0x6020, 0x9084, 0x000f, 0x000b, 0x0005,
+	0x86c7, 0x86cc, 0x8b2c, 0x8bbb, 0x86cc, 0x8b2c, 0x8bbb, 0x86c7,
+	0x86cc, 0x86c7, 0x86c7, 0x86c7, 0x86c7, 0x86c7, 0x86c7, 0x080c,
+	0x847d, 0x080c, 0x8582, 0x0005, 0x00b6, 0x0156, 0x0136, 0x0146,
+	0x01c6, 0x01d6, 0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2069, 0x0200,
+	0x2071, 0x0240, 0x6004, 0x908a, 0x0053, 0x1a0c, 0x0db2, 0x6110,
+	0x2158, 0xb9b0, 0x2c78, 0x2061, 0x0100, 0x619a, 0x908a, 0x0040,
+	0x1a04, 0x8738, 0x005b, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x01de,
+	0x01ce, 0x014e, 0x013e, 0x015e, 0x00be, 0x0005, 0x88af, 0x88ea,
+	0x8913, 0x89bb, 0x89dd, 0x89e3, 0x89f0, 0x89f8, 0x8a04, 0x8a0a,
+	0x8a1b, 0x8a0a, 0x8a73, 0x89f8, 0x8a7f, 0x8a85, 0x8a04, 0x8a85,
+	0x8a91, 0x8736, 0x8736, 0x8736, 0x8736, 0x8736, 0x8736, 0x8736,
+	0x8736, 0x8736, 0x8736, 0x8736, 0x910b, 0x912e, 0x913f, 0x915f,
+	0x9191, 0x89f0, 0x8736, 0x89f0, 0x8a0a, 0x8736, 0x8913, 0x89bb,
+	0x8736, 0x9556, 0x8a0a, 0x8736, 0x9572, 0x8a0a, 0x8736, 0x8a04,
+	0x88a9, 0x8759, 0x8736, 0x958e, 0x95fb, 0x96d2, 0x8736, 0x96df,
+	0x89ed, 0x970a, 0x8736, 0x919b, 0x9737, 0x8736, 0x080c, 0x0db2,
+	0x2100, 0x005b, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x01de, 0x01ce,
+	0x014e, 0x013e, 0x015e, 0x00be, 0x0005, 0x8757, 0x8757, 0x8757,
+	0x8780, 0x882c, 0x8837, 0x8757, 0x8757, 0x8757, 0x887e, 0x888a,
+	0x879b, 0x8757, 0x87b6, 0x87ea, 0x98b4, 0x98f9, 0x8a0a, 0x080c,
+	0x0db2, 0x00d6, 0x0096, 0x080c, 0x8aa4, 0x7003, 0x2414, 0x7007,
+	0x0018, 0x700b, 0x0800, 0x7814, 0x2048, 0xa83c, 0x700e, 0xa850,
+	0x7022, 0xa854, 0x7026, 0x60c3, 0x0018, 0x080c, 0x8f8f, 0x009e,
+	0x00de, 0x0005, 0x7810, 0x00b6, 0x2058, 0xb8a0, 0x00be, 0x080c,
+	0x9940, 0x1118, 0x9084, 0xff80, 0x0110, 0x9085, 0x0001, 0x0005,
+	0x00d6, 0x0096, 0x080c, 0x8aa4, 0x7003, 0x0500, 0x7814, 0x2048,
+	0xa874, 0x700a, 0xa878, 0x700e, 0xa87c, 0x7012, 0xa880, 0x7016,
+	0xa884, 0x701a, 0xa888, 0x701e, 0x60c3, 0x0010, 0x080c, 0x8f8f,
+	0x009e, 0x00de, 0x0005, 0x00d6, 0x0096, 0x080c, 0x8aa4, 0x7003,
+	0x0500, 0x7814, 0x2048, 0xa8cc, 0x700a, 0xa8d0, 0x700e, 0xa8d4,
+	0x7012, 0xa8d8, 0x7016, 0xa8dc, 0x701a, 0xa8e0, 0x701e, 0x60c3,
+	0x0010, 0x080c, 0x8f8f, 0x009e, 0x00de, 0x0005, 0x00d6, 0x0096,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x8aa4, 0x20e9, 0x0000, 0x2001,
+	0x1972, 0x2003, 0x0000, 0x7814, 0x2048, 0xa814, 0x8003, 0x60c2,
+	0xa830, 0x20a8, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x001b, 0x2098,
+	0x2001, 0x1972, 0x0016, 0x200c, 0x2001, 0x0001, 0x080c, 0x20be,
+	0x080c, 0xc2e6, 0x9006, 0x080c, 0x20be, 0x001e, 0xa804, 0x9005,
+	0x0110, 0x2048, 0x0c28, 0x04d9, 0x080c, 0x8f8f, 0x012e, 0x009e,
+	0x00de, 0x0005, 0x00d6, 0x0096, 0x0126, 0x2091, 0x8000, 0x080c,
+	0x8aef, 0x20e9, 0x0000, 0x2001, 0x1972, 0x2003, 0x0000, 0x7814,
+	0x2048, 0xa86f, 0x0200, 0xa873, 0x0000, 0xa814, 0x8003, 0x60c2,
+	0xa830, 0x20a8, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x001b, 0x2098,
+	0x2001, 0x1972, 0x0016, 0x200c, 0x080c, 0xc2e6, 0x001e, 0xa804,
+	0x9005, 0x0110, 0x2048, 0x0c60, 0x0051, 0x7814, 0x2048, 0x080c,
+	0x0f87, 0x080c, 0x8f8f, 0x012e, 0x009e, 0x00de, 0x0005, 0x60c0,
+	0x8004, 0x9084, 0x0003, 0x9005, 0x0130, 0x9082, 0x0004, 0x20a3,
+	0x0000, 0x8000, 0x1de0, 0x0005, 0x080c, 0x8aa4, 0x7003, 0x7800,
+	0x7808, 0x8007, 0x700a, 0x60c3, 0x0008, 0x0804, 0x8f8f, 0x00d6,
+	0x00e6, 0x080c, 0x8aef, 0x7814, 0x9084, 0xff00, 0x2073, 0x0200,
+	0x8e70, 0x8e70, 0x9095, 0x0010, 0x2272, 0x8e70, 0x2073, 0x0034,
+	0x8e70, 0x2069, 0x1805, 0x20a9, 0x0004, 0x2d76, 0x8d68, 0x8e70,
+	0x1f04, 0x884d, 0x2069, 0x1801, 0x20a9, 0x0004, 0x2d76, 0x8d68,
+	0x8e70, 0x1f04, 0x8856, 0x2069, 0x1982, 0x9086, 0xdf00, 0x0110,
+	0x2069, 0x199c, 0x20a9, 0x001a, 0x9e86, 0x0260, 0x1148, 0x00c6,
+	0x2061, 0x0200, 0x6010, 0x8000, 0x6012, 0x00ce, 0x2071, 0x0240,
+	0x2d04, 0x8007, 0x2072, 0x8d68, 0x8e70, 0x1f04, 0x8864, 0x60c3,
+	0x004c, 0x080c, 0x8f8f, 0x00ee, 0x00de, 0x0005, 0x080c, 0x8aa4,
+	0x7003, 0x6300, 0x7007, 0x0028, 0x7808, 0x700e, 0x60c3, 0x0008,
+	0x0804, 0x8f8f, 0x00d6, 0x0026, 0x0016, 0x080c, 0x8aef, 0x7003,
+	0x0200, 0x7814, 0x700e, 0x00e6, 0x9ef0, 0x0004, 0x2009, 0x0001,
+	0x2011, 0x000c, 0x2073, 0x0800, 0x8e70, 0x2073, 0x0000, 0x00ee,
+	0x7206, 0x710a, 0x62c2, 0x080c, 0x8f8f, 0x001e, 0x002e, 0x00de,
+	0x0005, 0x2001, 0x1816, 0x2004, 0x609a, 0x0804, 0x8f8f, 0x080c,
+	0x8aa4, 0x7003, 0x5200, 0x2069, 0x1853, 0x6804, 0xd084, 0x0130,
+	0x6828, 0x0016, 0x080c, 0x2509, 0x710e, 0x001e, 0x20a9, 0x0004,
+	0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9, 0x0000, 0x20a1, 0x0250,
+	0x4003, 0x20a9, 0x0004, 0x2099, 0x1801, 0x20a1, 0x0254, 0x4003,
+	0x080c, 0x9940, 0x1120, 0xb8a0, 0x9082, 0x007f, 0x0248, 0x2001,
+	0x181d, 0x2004, 0x7032, 0x2001, 0x181e, 0x2004, 0x7036, 0x0030,
+	0x2001, 0x1816, 0x2004, 0x9084, 0x00ff, 0x7036, 0x60c3, 0x001c,
+	0x0804, 0x8f8f, 0x080c, 0x8aa4, 0x7003, 0x0500, 0x080c, 0x9940,
+	0x1120, 0xb8a0, 0x9082, 0x007f, 0x0248, 0x2001, 0x181d, 0x2004,
+	0x700a, 0x2001, 0x181e, 0x2004, 0x700e, 0x0030, 0x2001, 0x1816,
+	0x2004, 0x9084, 0x00ff, 0x700e, 0x20a9, 0x0004, 0x20e1, 0x0001,
+	0x2099, 0x1805, 0x20e9, 0x0000, 0x20a1, 0x0250, 0x4003, 0x60c3,
+	0x0010, 0x0804, 0x8f8f, 0x080c, 0x8aa4, 0x9006, 0x080c, 0x626e,
+	0xb8a0, 0x9086, 0x007e, 0x1130, 0x7003, 0x0400, 0x620c, 0xc2b4,
+	0x620e, 0x0058, 0x7814, 0x0096, 0x904d, 0x0120, 0x9006, 0xa89a,
+	0xa8a6, 0xa8aa, 0x009e, 0x7003, 0x0300, 0xb8a0, 0x9086, 0x007e,
+	0x1904, 0x8982, 0x00d6, 0x2069, 0x193d, 0x2001, 0x1835, 0x2004,
+	0xd0a4, 0x0188, 0x6800, 0x700a, 0x6808, 0x9084, 0x2000, 0x7012,
+	0x080c, 0x9957, 0x680c, 0x7016, 0x701f, 0x2710, 0x6818, 0x7022,
+	0x681c, 0x7026, 0x0090, 0x6800, 0x700a, 0x6804, 0x700e, 0x6808,
+	0x080c, 0x6c53, 0x1118, 0x9084, 0x37ff, 0x0010, 0x9084, 0x3fff,
+	0x7012, 0x080c, 0x9957, 0x680c, 0x7016, 0x00de, 0x20a9, 0x0004,
+	0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9, 0x0000, 0x20a1, 0x0256,
+	0x4003, 0x20a9, 0x0004, 0x2099, 0x1801, 0x20a1, 0x025a, 0x4003,
+	0x00d6, 0x080c, 0x97b9, 0x2069, 0x1945, 0x2071, 0x024e, 0x6800,
+	0xc0dd, 0x7002, 0x080c, 0x5117, 0xd0e4, 0x0110, 0x680c, 0x700e,
+	0x00de, 0x04a8, 0x2001, 0x1835, 0x2004, 0xd0a4, 0x0170, 0x0016,
+	0x2001, 0x193e, 0x200c, 0x60e0, 0x9106, 0x0130, 0x2100, 0x60e3,
+	0x0000, 0x080c, 0x254a, 0x61e2, 0x001e, 0x20e1, 0x0001, 0x2099,
+	0x193d, 0x20e9, 0x0000, 0x20a1, 0x024e, 0x20a9, 0x0008, 0x4003,
+	0x20a9, 0x0004, 0x2099, 0x1805, 0x20a1, 0x0256, 0x4003, 0x20a9,
+	0x0004, 0x2099, 0x1801, 0x20a1, 0x025a, 0x4003, 0x080c, 0x97b9,
+	0x20a1, 0x024e, 0x20a9, 0x0008, 0x2099, 0x1945, 0x4003, 0x60c3,
+	0x0074, 0x0804, 0x8f8f, 0x080c, 0x8aa4, 0x7003, 0x2010, 0x7007,
+	0x0014, 0x700b, 0x0800, 0x700f, 0x2000, 0x9006, 0x00f6, 0x2079,
+	0x1853, 0x7904, 0x00fe, 0xd1ac, 0x1110, 0x9085, 0x0020, 0xd1a4,
+	0x0110, 0x9085, 0x0010, 0x9085, 0x0002, 0x00d6, 0x0804, 0x8a54,
+	0x7026, 0x60c3, 0x0014, 0x0804, 0x8f8f, 0x080c, 0x8aa4, 0x7003,
+	0x5000, 0x0804, 0x892d, 0x080c, 0x8aa4, 0x7003, 0x2110, 0x7007,
+	0x0014, 0x60c3, 0x0014, 0x0804, 0x8f8f, 0x080c, 0x8ae6, 0x0010,
+	0x080c, 0x8aef, 0x7003, 0x0200, 0x60c3, 0x0004, 0x0804, 0x8f8f,
+	0x080c, 0x8aef, 0x7003, 0x0100, 0x700b, 0x0003, 0x700f, 0x2a00,
+	0x60c3, 0x0008, 0x0804, 0x8f8f, 0x080c, 0x8aef, 0x7003, 0x0200,
+	0x0804, 0x892d, 0x080c, 0x8aef, 0x7003, 0x0100, 0x782c, 0x9005,
+	0x0110, 0x700a, 0x0010, 0x700b, 0x0003, 0x7814, 0x700e, 0x60c3,
+	0x0008, 0x0804, 0x8f8f, 0x00d6, 0x080c, 0x8aef, 0x7003, 0x0210,
+	0x7007, 0x0014, 0x700b, 0x0800, 0xb894, 0x9086, 0x0014, 0x1198,
+	0xb99c, 0x9184, 0x0030, 0x0190, 0xb998, 0x9184, 0xc000, 0x1140,
+	0xd1ec, 0x0118, 0x700f, 0x2100, 0x0058, 0x700f, 0x0100, 0x0040,
+	0x700f, 0x0400, 0x0028, 0x700f, 0x0700, 0x0010, 0x700f, 0x0800,
+	0x00f6, 0x2079, 0x1853, 0x7904, 0x00fe, 0xd1ac, 0x1110, 0x9085,
+	0x0020, 0xd1a4, 0x0110, 0x9085, 0x0010, 0x2009, 0x1875, 0x210c,
+	0xd184, 0x1110, 0x9085, 0x0002, 0x0026, 0x2009, 0x1873, 0x210c,
+	0xd1e4, 0x0150, 0xc0c5, 0xbabc, 0xd28c, 0x1108, 0xc0cd, 0x9094,
+	0x0030, 0x9296, 0x0010, 0x0140, 0xd1ec, 0x0130, 0x9094, 0x0030,
+	0x9296, 0x0010, 0x0108, 0xc0bd, 0x002e, 0x7026, 0x60c3, 0x0014,
+	0x00de, 0x0804, 0x8f8f, 0x080c, 0x8aef, 0x7003, 0x0210, 0x7007,
+	0x0014, 0x700f, 0x0100, 0x60c3, 0x0014, 0x0804, 0x8f8f, 0x080c,
+	0x8aef, 0x7003, 0x0200, 0x0804, 0x88b3, 0x080c, 0x8aef, 0x7003,
+	0x0100, 0x700b, 0x0003, 0x700f, 0x2a00, 0x60c3, 0x0008, 0x0804,
+	0x8f8f, 0x080c, 0x8aef, 0x7003, 0x0100, 0x700b, 0x000b, 0x60c3,
+	0x0008, 0x0804, 0x8f8f, 0x0026, 0x00d6, 0x0036, 0x0046, 0x2019,
+	0x3200, 0x2021, 0x0800, 0x0040, 0x0026, 0x00d6, 0x0036, 0x0046,
+	0x2019, 0x2200, 0x2021, 0x0100, 0x080c, 0x97ce, 0xb810, 0x9305,
+	0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0x6874, 0x700a, 0x6878,
+	0x700e, 0x9485, 0x0029, 0x7012, 0x004e, 0x003e, 0x00de, 0x080c,
+	0x8f7d, 0x721a, 0x9f95, 0x0000, 0x7222, 0x7027, 0xffff, 0x2071,
+	0x024c, 0x002e, 0x0005, 0x0026, 0x080c, 0x97ce, 0x7003, 0x02ff,
+	0x7007, 0xfffc, 0x00d6, 0x2069, 0x1800, 0x6874, 0x700a, 0x6878,
+	0x700e, 0x00de, 0x7013, 0x2029, 0x0c10, 0x7003, 0x0100, 0x7007,
+	0x0000, 0x700b, 0xfc02, 0x700f, 0x0000, 0x0005, 0x0026, 0x00d6,
+	0x0036, 0x0046, 0x2019, 0x3300, 0x2021, 0x0800, 0x0040, 0x0026,
+	0x00d6, 0x0036, 0x0046, 0x2019, 0x2300, 0x2021, 0x0100, 0x080c,
+	0x97ce, 0xb810, 0x9305, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800,
+	0xb810, 0x9005, 0x1140, 0xb814, 0x9005, 0x1128, 0x700b, 0x00ff,
+	0x700f, 0xfffe, 0x0020, 0x6874, 0x700a, 0x6878, 0x700e, 0x0000,
+	0x9485, 0x0098, 0x7012, 0x004e, 0x003e, 0x00de, 0x080c, 0x8f7d,
+	0x721a, 0x7a08, 0x7222, 0x2f10, 0x7226, 0x2071, 0x024c, 0x002e,
+	0x0005, 0x080c, 0x8f7d, 0x721a, 0x7a08, 0x7222, 0x7814, 0x7026,
+	0x2071, 0x024c, 0x002e, 0x0005, 0x00b6, 0x00c6, 0x00d6, 0x00e6,
+	0x00f6, 0x2069, 0x0200, 0x2071, 0x0240, 0x6004, 0x908a, 0x0085,
+	0x0a0c, 0x0db2, 0x908a, 0x0092, 0x1a0c, 0x0db2, 0x6110, 0x2158,
+	0xb9b0, 0x2c78, 0x2061, 0x0100, 0x619a, 0x9082, 0x0085, 0x0033,
+	0x00fe, 0x00ee, 0x00de, 0x00ce, 0x00be, 0x0005, 0x8b5d, 0x8b6c,
+	0x8b77, 0x8b5b, 0x8b5b, 0x8b5b, 0x8b5d, 0x8b5b, 0x8b5b, 0x8b5b,
+	0x8b5b, 0x8b5b, 0x8b5b, 0x080c, 0x0db2, 0x0411, 0x60c3, 0x0000,
+	0x0026, 0x080c, 0x283d, 0x0228, 0x2011, 0x0101, 0x2204, 0xc0c5,
+	0x2012, 0x002e, 0x0804, 0x8f8f, 0x0431, 0x7808, 0x700a, 0x7814,
+	0x700e, 0x7017, 0xffff, 0x60c3, 0x000c, 0x0804, 0x8f8f, 0x0479,
+	0x7003, 0x0003, 0x7007, 0x0300, 0x60c3, 0x0004, 0x0804, 0x8f8f,
+	0x0026, 0x080c, 0x97ce, 0xb810, 0x9085, 0x8100, 0x7002, 0xb814,
+	0x7006, 0x2069, 0x1800, 0x6874, 0x700a, 0x6878, 0x700e, 0x7013,
+	0x0009, 0x0804, 0x8abf, 0x0026, 0x080c, 0x97ce, 0xb810, 0x9085,
+	0x8400, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0x6874, 0x700a,
+	0x6878, 0x700e, 0x2001, 0x0099, 0x7012, 0x0804, 0x8b21, 0x0026,
+	0x080c, 0x97ce, 0xb810, 0x9085, 0x8500, 0x7002, 0xb814, 0x7006,
+	0x2069, 0x1800, 0x6874, 0x700a, 0x6878, 0x700e, 0x2001, 0x0099,
+	0x7012, 0x0804, 0x8b21, 0x00b6, 0x00c6, 0x00d6, 0x00e6, 0x00f6,
+	0x2c78, 0x2069, 0x0200, 0x2071, 0x0240, 0x7804, 0x908a, 0x0040,
+	0x0a0c, 0x0db2, 0x908a, 0x0054, 0x1a0c, 0x0db2, 0x7910, 0x2158,
+	0xb9b0, 0x2061, 0x0100, 0x619a, 0x9082, 0x0040, 0x0033, 0x00fe,
+	0x00ee, 0x00de, 0x00ce, 0x00be, 0x0005, 0x8bf2, 0x8c99, 0x8c6c,
+	0x8dbb, 0x8bf0, 0x8bf0, 0x8bf0, 0x8bf0, 0x8bf0, 0x8bf0, 0x8bf0,
+	0x930c, 0x9318, 0x9324, 0x9330, 0x8bf0, 0x9716, 0x8bf0, 0x9300,
+	0x080c, 0x0db2, 0x0096, 0x780b, 0xffff, 0x080c, 0x8c48, 0x7914,
+	0x2148, 0xa978, 0x7956, 0x7132, 0xa97c, 0x9184, 0x000f, 0x1118,
+	0x2001, 0x0005, 0x0040, 0xd184, 0x0118, 0x2001, 0x0004, 0x0018,
+	0x9084, 0x0006, 0x8004, 0x2010, 0x785c, 0x9084, 0x00ff, 0x8007,
+	0x9205, 0x7042, 0xd1ac, 0x0128, 0x7047, 0x0002, 0x080c, 0x1582,
+	0x0050, 0xd1b4, 0x0118, 0x7047, 0x0001, 0x0028, 0x7047, 0x0000,
+	0x9016, 0x2230, 0x0010, 0xaab0, 0xaeac, 0x726a, 0x766e, 0x20a9,
+	0x0008, 0x20e9, 0x0000, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x0023,
+	0x2098, 0x20a1, 0x0252, 0x2069, 0x0200, 0x6813, 0x0018, 0x4003,
+	0x6813, 0x0008, 0x60c3, 0x0020, 0x6017, 0x0009, 0x2001, 0x19d2,
+	0x2003, 0x07d0, 0x2001, 0x19d1, 0x2003, 0x0009, 0x009e, 0x0005,
+	0x6813, 0x0008, 0xba8c, 0x8210, 0xb8bc, 0xd084, 0x0128, 0x7a46,
+	0x7b14, 0x7b4a, 0x722e, 0x732a, 0x9294, 0x00ff, 0xba8e, 0x8217,
+	0x721a, 0xba10, 0x9295, 0x0600, 0x7202, 0xba14, 0x7206, 0x2069,
+	0x1800, 0x6a74, 0x720a, 0x6a78, 0x720e, 0x7013, 0x0829, 0x2f10,
+	0x7222, 0x7027, 0xffff, 0x0005, 0x00d6, 0x0096, 0x0081, 0x7814,
+	0x2048, 0xa890, 0x7002, 0xa88c, 0x7006, 0xa8b0, 0x700a, 0xa8ac,
+	0x700e, 0x60c3, 0x000c, 0x009e, 0x00de, 0x0804, 0x8f8f, 0x6813,
+	0x0008, 0xb810, 0x9085, 0x0500, 0x7002, 0xb814, 0x7006, 0x2069,
+	0x1800, 0x6874, 0x700a, 0x6878, 0x700e, 0x7013, 0x0889, 0x080c,
+	0x8f7d, 0x721a, 0x7a08, 0x7222, 0x2f10, 0x7226, 0x2071, 0x024c,
+	0x0005, 0x00d6, 0x0096, 0x080c, 0x8d99, 0x7814, 0x2048, 0x080c,
+	0xb5f9, 0x1130, 0x7814, 0x9084, 0x0700, 0x8007, 0x0033, 0x0010,
+	0x9006, 0x001b, 0x009e, 0x00de, 0x0005, 0x8cb7, 0x8d20, 0x8d30,
+	0x8d56, 0x8d62, 0x8d73, 0x8d7b, 0x8cb5, 0x080c, 0x0db2, 0x0016,
+	0x0036, 0xa97c, 0x918c, 0x0003, 0x0118, 0x9186, 0x0003, 0x1198,
+	0xaba8, 0x7824, 0xd0cc, 0x1168, 0x7316, 0xa898, 0x701a, 0xa894,
+	0x701e, 0x003e, 0x001e, 0x2001, 0x1980, 0x2004, 0x60c2, 0x0804,
+	0x8f8f, 0xc3e5, 0x0c88, 0x9186, 0x0001, 0x190c, 0x0db2, 0xaba8,
+	0x7824, 0xd0cc, 0x1904, 0x8d1d, 0x7316, 0xa898, 0x701a, 0xa894,
+	0x701e, 0xa8a4, 0x7026, 0xa8ac, 0x702e, 0x2009, 0x0018, 0x9384,
+	0x0300, 0x0570, 0xd3c4, 0x0110, 0xa8ac, 0x9108, 0xd3cc, 0x0110,
+	0xa8a4, 0x9108, 0x6810, 0x9085, 0x0010, 0x6812, 0x2011, 0x0258,
+	0x20e9, 0x0000, 0x22a0, 0x0156, 0x20a9, 0x0008, 0xa860, 0x20e0,
+	0xa85c, 0x9080, 0x002c, 0x2098, 0x4003, 0x6810, 0x8000, 0x6812,
+	0x2011, 0x0240, 0x22a0, 0x20a9, 0x0005, 0x4003, 0x6810, 0xc084,
+	0x6812, 0x015e, 0x9184, 0x0003, 0x0118, 0x2019, 0x0245, 0x201a,
+	0x61c2, 0x003e, 0x001e, 0x0804, 0x8f8f, 0xc3e5, 0x0804, 0x8cdc,
+	0x2011, 0x0008, 0x2001, 0x180e, 0x2004, 0xd0a4, 0x0110, 0x2011,
+	0x0028, 0x7824, 0xd0cc, 0x1110, 0x7216, 0x0470, 0x0ce8, 0xc2e5,
+	0x2011, 0x0302, 0x0016, 0x782c, 0x701a, 0x7930, 0x711e, 0x9105,
+	0x0108, 0xc2dd, 0x001e, 0x7824, 0xd0cc, 0x0108, 0xc2e5, 0x7216,
+	0x7027, 0x0012, 0x702f, 0x0008, 0x7043, 0x7000, 0x7047, 0x0500,
+	0x704f, 0x000a, 0x2069, 0x0200, 0x6813, 0x0009, 0x2071, 0x0240,
+	0x700b, 0x2500, 0x60c3, 0x0032, 0x0804, 0x8f8f, 0x2011, 0x0028,
+	0x7824, 0xd0cc, 0x1128, 0x7216, 0x60c3, 0x0018, 0x0804, 0x8f8f,
+	0x0cd0, 0xc2e5, 0x2011, 0x0100, 0x7824, 0xd0cc, 0x0108, 0xc2e5,
+	0x7216, 0x702f, 0x0008, 0x7858, 0x9084, 0x00ff, 0x7036, 0x60c3,
+	0x0020, 0x0804, 0x8f8f, 0x2011, 0x0008, 0x7824, 0xd0cc, 0x0108,
+	0xc2e5, 0x7216, 0x0c08, 0x0036, 0x7b14, 0x9384, 0xff00, 0x7816,
+	0x9384, 0x00ff, 0x8001, 0x1138, 0x7824, 0xd0cc, 0x0108, 0xc2e5,
+	0x7216, 0x003e, 0x0888, 0x0046, 0x2021, 0x0800, 0x0006, 0x7824,
+	0xd0cc, 0x000e, 0x0108, 0xc4e5, 0x7416, 0x004e, 0x701e, 0x003e,
+	0x0818, 0x00d6, 0x6813, 0x0008, 0xb810, 0x9085, 0x0700, 0x7002,
+	0xb814, 0x7006, 0x2069, 0x1800, 0x6874, 0x700a, 0x6878, 0x700e,
+	0x7824, 0xd0cc, 0x1168, 0x7013, 0x0898, 0x080c, 0x8f7d, 0x721a,
+	0x7a08, 0x7222, 0x2f10, 0x7226, 0x2071, 0x024c, 0x00de, 0x0005,
+	0x7013, 0x0889, 0x0c90, 0x0016, 0x7814, 0x9084, 0x0700, 0x8007,
+	0x0013, 0x001e, 0x0005, 0x8dcb, 0x8dcb, 0x8dcd, 0x8dcb, 0x8dcb,
+	0x8dcb, 0x8de7, 0x8dcb, 0x080c, 0x0db2, 0x7914, 0x918c, 0x08ff,
+	0x918d, 0xf600, 0x7916, 0x2009, 0x0003, 0x00b9, 0x2069, 0x1853,
+	0x6804, 0xd0bc, 0x0130, 0x682c, 0x9084, 0x00ff, 0x8007, 0x7032,
+	0x0010, 0x7033, 0x3f00, 0x60c3, 0x0001, 0x0804, 0x8f8f, 0x2009,
+	0x0003, 0x0019, 0x7033, 0x7f00, 0x0cb0, 0x0016, 0x080c, 0x97ce,
+	0x001e, 0xb810, 0x9085, 0x0100, 0x7002, 0xb814, 0x7006, 0x2069,
+	0x1800, 0x6a74, 0x720a, 0x6a78, 0x720e, 0x7013, 0x0888, 0x918d,
+	0x0008, 0x7116, 0x080c, 0x8f7d, 0x721a, 0x7a08, 0x7222, 0x2f10,
+	0x7226, 0x0005, 0x00b6, 0x0096, 0x00e6, 0x00d6, 0x00c6, 0x0056,
+	0x0046, 0x0036, 0x2061, 0x0100, 0x2071, 0x1800, 0x7810, 0x2058,
+	0xb8a0, 0x2028, 0xb910, 0xba14, 0x7374, 0x7478, 0x7820, 0x90be,
+	0x0006, 0x0904, 0x8eec, 0x90be, 0x000a, 0x1904, 0x8ea8, 0x609f,
+	0x0000, 0x7814, 0x2048, 0xa87c, 0xd0fc, 0x05c8, 0xaf90, 0x9784,
+	0xff00, 0x9105, 0x6062, 0x873f, 0x9784, 0xff00, 0x0006, 0x7814,
+	0x2048, 0xa878, 0x9005, 0x000e, 0x1160, 0xaf94, 0x87ff, 0x0510,
+	0x2039, 0x0098, 0x9705, 0x6072, 0x7808, 0x6082, 0x2f00, 0x6086,
+	0x0038, 0x9185, 0x2200, 0x6062, 0x6073, 0x0129, 0x6077, 0x0000,
+	0x609f, 0x0000, 0x2001, 0x1835, 0x2004, 0xd0ac, 0x11a8, 0xd09c,
+	0x0130, 0x7814, 0x2048, 0xa874, 0x9082, 0x0080, 0x1268, 0xb814,
+	0x609e, 0x0050, 0x2039, 0x0029, 0x9705, 0x6072, 0x0c48, 0x9185,
+	0x0200, 0x6062, 0x6073, 0x2029, 0xa87c, 0xd0fc, 0x0118, 0xaf94,
+	0x87ff, 0x1120, 0x2f00, 0x6082, 0x7808, 0x6086, 0x6266, 0x636a,
+	0x646e, 0x6077, 0x0000, 0xb88c, 0x8000, 0x9084, 0x00ff, 0xb88e,
+	0x8007, 0x607a, 0x607f, 0x0000, 0xa838, 0x608a, 0xa834, 0x608e,
+	0xa848, 0x60c6, 0xa844, 0x60ca, 0xb86c, 0x60ce, 0x60af, 0x95d5,
+	0x60d7, 0x0000, 0x080c, 0x97b3, 0x2009, 0x07d0, 0x60c4, 0x9084,
+	0xfff0, 0x9005, 0x0110, 0x2009, 0x1b58, 0x080c, 0x7ccc, 0x003e,
+	0x004e, 0x005e, 0x00ce, 0x00de, 0x00ee, 0x009e, 0x00be, 0x0005,
+	0x7804, 0x9086, 0x0040, 0x0904, 0x8f28, 0x9185, 0x0100, 0x6062,
+	0x6266, 0x636a, 0x646e, 0x6073, 0x0809, 0x6077, 0x0008, 0x60af,
+	0x95d5, 0x60d7, 0x0000, 0xb88c, 0x8000, 0x9084, 0x00ff, 0xb88e,
+	0x8007, 0x607a, 0x607f, 0x0000, 0x2f00, 0x6082, 0x7808, 0x6086,
+	0x7814, 0x2048, 0xa838, 0x608a, 0xa834, 0x608e, 0xa848, 0x60c6,
+	0xa844, 0x60ca, 0xb86c, 0x60ce, 0xbab0, 0x629e, 0x080c, 0x97b3,
+	0x2009, 0x07d0, 0x60c4, 0x9084, 0xfff0, 0x9005, 0x0110, 0x2009,
+	0x1b58, 0x080c, 0x7ccc, 0x003e, 0x004e, 0x005e, 0x00ce, 0x00de,
+	0x00ee, 0x009e, 0x00be, 0x0005, 0x7814, 0x2048, 0xa87c, 0x9084,
+	0x0003, 0x9086, 0x0002, 0x0904, 0x8f44, 0x9185, 0x0100, 0x6062,
+	0x6266, 0x636a, 0x646e, 0x6073, 0x0880, 0x6077, 0x0008, 0xb88c,
+	0x8000, 0x9084, 0x00ff, 0xb88e, 0x8007, 0x607a, 0x7838, 0x607e,
+	0x2f00, 0x6086, 0x7808, 0x6082, 0xa890, 0x608a, 0xa88c, 0x608e,
+	0xa8b0, 0x60c6, 0xa8ac, 0x60ca, 0xa8ac, 0x7930, 0x9108, 0x7932,
+	0xa8b0, 0x792c, 0x9109, 0x792e, 0xb86c, 0x60ce, 0x60af, 0x95d5,
+	0x60d7, 0x0000, 0xbab0, 0x629e, 0x080c, 0x9790, 0x0804, 0x8ed8,
+	0xb8bc, 0xd084, 0x0148, 0xb88c, 0x7814, 0x2048, 0xb88c, 0x7846,
+	0xa836, 0x2900, 0xa83a, 0xb04a, 0x9185, 0x0600, 0x6062, 0x6266,
+	0x636a, 0x646e, 0x6073, 0x0829, 0x6077, 0x0000, 0x60af, 0x9575,
+	0x60d7, 0x0000, 0x0804, 0x8ebb, 0x9185, 0x0700, 0x6062, 0x6266,
+	0x636a, 0x646e, 0x7824, 0xd0cc, 0x7826, 0x0118, 0x6073, 0x0889,
+	0x0010, 0x6073, 0x0898, 0x6077, 0x0000, 0xb88c, 0x8000, 0x9084,
+	0x00ff, 0xb88e, 0x8007, 0x607a, 0x607f, 0x0000, 0x2f00, 0x6086,
+	0x7808, 0x6082, 0xa838, 0x608a, 0xa834, 0x608e, 0xa848, 0x60c6,
+	0xa844, 0x60ca, 0xb86c, 0x60ce, 0x60af, 0x95d5, 0x60d7, 0x0000,
+	0xbab0, 0x629e, 0x7824, 0xd0cc, 0x0120, 0x080c, 0x97b3, 0x0804,
+	0x8ed8, 0x080c, 0x9790, 0x0804, 0x8ed8, 0x7a10, 0x00b6, 0x2258,
+	0xba8c, 0x8210, 0x9294, 0x00ff, 0xba8e, 0x00be, 0x8217, 0x0005,
+	0x00d6, 0x2069, 0x19b6, 0x6843, 0x0001, 0x00de, 0x0005, 0x60a3,
+	0x0056, 0x60a7, 0x9575, 0x00f1, 0x080c, 0x7cbe, 0x0005, 0x0016,
+	0x2001, 0x180c, 0x200c, 0x9184, 0x0600, 0x9086, 0x0600, 0x0128,
+	0x0089, 0x080c, 0x7cbe, 0x001e, 0x0005, 0xc1e5, 0x2001, 0x180c,
+	0x2102, 0x2001, 0x19b7, 0x2003, 0x0000, 0x2001, 0x19bf, 0x2003,
+	0x0000, 0x0c88, 0x0006, 0x6014, 0x9084, 0x1804, 0x9085, 0x0009,
+	0x6016, 0x000e, 0x0005, 0x0016, 0x00c6, 0x0006, 0x2061, 0x0100,
+	0x61a4, 0x60a7, 0x95f5, 0x6014, 0x9084, 0x1804, 0x9085, 0x0008,
+	0x6016, 0x000e, 0xa001, 0xa001, 0xa001, 0x61a6, 0x00ce, 0x001e,
+	0x0005, 0x00c6, 0x00d6, 0x0016, 0x0026, 0x2061, 0x0100, 0x2069,
+	0x0140, 0x080c, 0x6c53, 0x11e8, 0x2001, 0x19d2, 0x2004, 0x9005,
+	0x1904, 0x9021, 0x0066, 0x2031, 0x0001, 0x080c, 0x6d03, 0x006e,
+	0x1160, 0x2061, 0x0100, 0x6020, 0xd0b4, 0x1120, 0x6024, 0xd084,
+	0x090c, 0x0db2, 0x080c, 0x7cbe, 0x0460, 0x00c6, 0x2061, 0x19b6,
+	0x00d0, 0x6904, 0x9194, 0x4000, 0x0548, 0x080c, 0x8fbb, 0x080c,
+	0x2997, 0x00c6, 0x2061, 0x19b6, 0x6128, 0x9192, 0x0008, 0x1258,
+	0x8108, 0x612a, 0x6124, 0x00ce, 0x81ff, 0x0198, 0x080c, 0x7cbe,
+	0x080c, 0x8fb2, 0x0070, 0x6124, 0x91e5, 0x0000, 0x0140, 0x080c,
+	0xd358, 0x080c, 0x7cc7, 0x2009, 0x0014, 0x080c, 0x9a50, 0x00ce,
+	0x0000, 0x002e, 0x001e, 0x00de, 0x00ce, 0x0005, 0x2001, 0x19d2,
+	0x2004, 0x9005, 0x1db0, 0x00c6, 0x2061, 0x19b6, 0x6128, 0x9192,
+	0x0003, 0x1e08, 0x8108, 0x612a, 0x00ce, 0x080c, 0x7cbe, 0x080c,
+	0x58e0, 0x2009, 0x1852, 0x2114, 0x8210, 0x220a, 0x0c10, 0x0096,
+	0x00c6, 0x00d6, 0x00e6, 0x0016, 0x0026, 0x080c, 0x7cd4, 0x2071,
+	0x19b6, 0x713c, 0x81ff, 0x0904, 0x90ad, 0x2061, 0x0100, 0x2069,
+	0x0140, 0x080c, 0x6c53, 0x11b0, 0x0036, 0x2019, 0x0002, 0x080c,
+	0x9254, 0x003e, 0x713c, 0x2160, 0x080c, 0xd358, 0x2009, 0x004a,
+	0x080c, 0x9a50, 0x0066, 0x2031, 0x0001, 0x080c, 0x6d03, 0x006e,
+	0x0804, 0x90ad, 0x6904, 0xd1f4, 0x0904, 0x90b4, 0x080c, 0x2997,
+	0x00c6, 0x703c, 0x9065, 0x090c, 0x0db2, 0x6020, 0x00ce, 0x9086,
+	0x0006, 0x1528, 0x61c8, 0x60c4, 0x9105, 0x1508, 0x2009, 0x180c,
+	0x2104, 0xd0d4, 0x01e0, 0x6214, 0x9294, 0x1800, 0x1128, 0x6224,
+	0x9294, 0x0002, 0x1510, 0x0030, 0xc0d4, 0x200a, 0xd0cc, 0x0110,
+	0x080c, 0x28ea, 0x6014, 0x9084, 0xe7fd, 0x9085, 0x0010, 0x6016,
+	0x703c, 0x2060, 0x2009, 0x0049, 0x080c, 0x9a50, 0x0070, 0x0036,
+	0x2019, 0x0001, 0x080c, 0x9254, 0x003e, 0x713c, 0x2160, 0x080c,
+	0xd358, 0x2009, 0x004a, 0x080c, 0x9a50, 0x002e, 0x001e, 0x00ee,
+	0x00de, 0x00ce, 0x009e, 0x0005, 0xd1ec, 0x1904, 0x906e, 0x0804,
+	0x9070, 0x0026, 0x00e6, 0x2071, 0x19b6, 0x7048, 0xd084, 0x01c0,
+	0x713c, 0x81ff, 0x01a8, 0x2071, 0x0100, 0x9188, 0x0008, 0x2114,
+	0x928e, 0x0006, 0x1138, 0x7014, 0x9084, 0x1984, 0x9085, 0x0012,
+	0x7016, 0x0030, 0x7014, 0x9084, 0x1984, 0x9085, 0x0016, 0x7016,
+	0x00ee, 0x002e, 0x0005, 0x00b6, 0x00e6, 0x00d6, 0x00c6, 0x0066,
+	0x0056, 0x0046, 0x0006, 0x0126, 0x2091, 0x8000, 0x6010, 0x2058,
+	0xbca0, 0x2071, 0x19b6, 0x7018, 0x2058, 0x8bff, 0x0190, 0xb8a0,
+	0x9406, 0x0118, 0xb854, 0x2058, 0x0cc0, 0x6014, 0x0096, 0x2048,
+	0xac6c, 0xad70, 0xae78, 0x009e, 0x080c, 0x60b0, 0x0110, 0x9085,
+	0x0001, 0x012e, 0x000e, 0x004e, 0x005e, 0x006e, 0x00ce, 0x00de,
+	0x00ee, 0x00be, 0x0005, 0x080c, 0x8aa4, 0x7003, 0x1200, 0x7838,
+	0x7012, 0x783c, 0x7016, 0x00c6, 0x7820, 0x9086, 0x0004, 0x1148,
+	0x7810, 0x9005, 0x0130, 0x00b6, 0x2058, 0xb810, 0xb914, 0x00be,
+	0x0020, 0x2061, 0x1800, 0x6074, 0x6178, 0x9084, 0x00ff, 0x700a,
+	0x710e, 0x00ce, 0x60c3, 0x002c, 0x0804, 0x8f8f, 0x080c, 0x8aa4,
+	0x7003, 0x0f00, 0x7808, 0xd09c, 0x0128, 0xb810, 0x9084, 0x00ff,
+	0x700a, 0xb814, 0x700e, 0x60c3, 0x0008, 0x0804, 0x8f8f, 0x0156,
+	0x080c, 0x8aef, 0x7003, 0x0200, 0x2011, 0x1848, 0x63f0, 0x2312,
+	0x20a9, 0x0006, 0x2011, 0x1840, 0x2019, 0x1841, 0x9ef0, 0x0002,
+	0x2376, 0x8e70, 0x2276, 0x8e70, 0x9398, 0x0002, 0x9290, 0x0002,
+	0x1f04, 0x9150, 0x60c3, 0x001c, 0x015e, 0x0804, 0x8f8f, 0x0016,
+	0x0026, 0x080c, 0x8acb, 0x080c, 0x8add, 0x9e80, 0x0004, 0x20e9,
+	0x0000, 0x20a0, 0x7814, 0x0096, 0x2048, 0xa800, 0x2048, 0xa860,
+	0x20e0, 0xa85c, 0x9080, 0x0021, 0x2098, 0x009e, 0x7808, 0x9088,
+	0x0002, 0x21a8, 0x9192, 0x0010, 0x1250, 0x4003, 0x9080, 0x0004,
+	0x8003, 0x60c2, 0x080c, 0x8f8f, 0x002e, 0x001e, 0x0005, 0x20a9,
+	0x0010, 0x4003, 0x080c, 0x97b9, 0x20a1, 0x0240, 0x22a8, 0x4003,
+	0x0c68, 0x080c, 0x8aa4, 0x7003, 0x6200, 0x7808, 0x700e, 0x60c3,
+	0x0008, 0x0804, 0x8f8f, 0x0016, 0x0026, 0x080c, 0x8aa4, 0x20e9,
+	0x0000, 0x20a1, 0x024c, 0x7814, 0x0096, 0x2048, 0xa800, 0x2048,
+	0xa860, 0x20e0, 0xa85c, 0x9080, 0x0023, 0x2098, 0x009e, 0x7808,
+	0x9088, 0x0002, 0x21a8, 0x4003, 0x8003, 0x60c2, 0x080c, 0x8f8f,
+	0x002e, 0x001e, 0x0005, 0x00e6, 0x00c6, 0x0006, 0x0126, 0x2091,
+	0x8000, 0x2071, 0x19b6, 0x700c, 0x2060, 0x8cff, 0x0178, 0x080c,
+	0xb7fa, 0x1110, 0x080c, 0xa364, 0x600c, 0x0006, 0x080c, 0xba61,
+	0x080c, 0x99d6, 0x080c, 0x933f, 0x00ce, 0x0c78, 0x2c00, 0x700e,
+	0x700a, 0x012e, 0x000e, 0x00ce, 0x00ee, 0x0005, 0x0126, 0x0156,
+	0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0066, 0x0026, 0x0016, 0x0006,
+	0x2091, 0x8000, 0x2001, 0x180c, 0x200c, 0x918c, 0xe7ff, 0x2102,
+	0x2069, 0x0100, 0x2079, 0x0140, 0x2071, 0x19b6, 0x7024, 0x2060,
+	0x8cff, 0x01f8, 0x080c, 0x8fbb, 0x6ac0, 0x68c3, 0x0000, 0x080c,
+	0x7cc7, 0x00c6, 0x2061, 0x0100, 0x080c, 0x97d2, 0x00ce, 0x20a9,
+	0x01f4, 0x0461, 0x2009, 0x0013, 0x080c, 0x9a50, 0x000e, 0x001e,
+	0x002e, 0x006e, 0x00ce, 0x00de, 0x00ee, 0x00fe, 0x015e, 0x012e,
+	0x0005, 0x2001, 0x1800, 0x2004, 0x9096, 0x0001, 0x0d78, 0x9096,
+	0x0004, 0x0d60, 0x080c, 0x7cc7, 0x6814, 0x9084, 0x0001, 0x0110,
+	0x68a7, 0x95f5, 0x6817, 0x0008, 0x68c3, 0x0000, 0x2011, 0x588a,
+	0x080c, 0x7c4a, 0x20a9, 0x01f4, 0x0009, 0x08c0, 0x6824, 0xd094,
+	0x0140, 0x6827, 0x0004, 0x7804, 0x9084, 0x4000, 0x190c, 0x2997,
+	0x0090, 0xd084, 0x0118, 0x6827, 0x0001, 0x0010, 0x1f04, 0x9236,
+	0x7804, 0x9084, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2987,
+	0x9006, 0x080c, 0x2987, 0x0005, 0x0126, 0x0156, 0x00f6, 0x00e6,
+	0x00d6, 0x00c6, 0x0066, 0x0026, 0x0016, 0x0006, 0x2091, 0x8000,
+	0x2001, 0x180c, 0x200c, 0x918c, 0xdbff, 0x2102, 0x2069, 0x0100,
+	0x2079, 0x0140, 0x2071, 0x19b6, 0x703c, 0x2060, 0x8cff, 0x0904,
+	0x92e1, 0x9386, 0x0002, 0x1128, 0x6814, 0x9084, 0x0002, 0x0904,
+	0x92e1, 0x68af, 0x95f5, 0x6817, 0x0010, 0x2009, 0x00fa, 0x8109,
+	0x1df0, 0x69c6, 0x68cb, 0x0008, 0x080c, 0x7cd4, 0x080c, 0x1d14,
+	0x0046, 0x2009, 0x017f, 0x200b, 0x00a5, 0x2021, 0x0169, 0x2404,
+	0x9084, 0x000f, 0x9086, 0x0004, 0x11f8, 0x68af, 0x95f5, 0x68c6,
+	0x68cb, 0x0008, 0x00e6, 0x00f6, 0x2079, 0x0090, 0x2071, 0x1a34,
+	0x6814, 0x9084, 0x1984, 0x9085, 0x0012, 0x6816, 0x782b, 0x0008,
+	0x7003, 0x0000, 0x00fe, 0x00ee, 0x9386, 0x0002, 0x1128, 0x7884,
+	0x9005, 0x1110, 0x7887, 0x0001, 0x2001, 0x1950, 0x2004, 0x200a,
+	0x004e, 0x20a9, 0x03e8, 0x6824, 0xd094, 0x0140, 0x6827, 0x0004,
+	0x7804, 0x9084, 0x4000, 0x190c, 0x2997, 0x0090, 0xd08c, 0x0118,
+	0x6827, 0x0002, 0x0010, 0x1f04, 0x92bb, 0x7804, 0x9084, 0x1000,
+	0x0138, 0x2001, 0x0100, 0x080c, 0x2987, 0x9006, 0x080c, 0x2987,
+	0x6827, 0x4000, 0x6824, 0x83ff, 0x1120, 0x2009, 0x0049, 0x080c,
+	0x9a50, 0x000e, 0x001e, 0x002e, 0x006e, 0x00ce, 0x00de, 0x00ee,
+	0x00fe, 0x015e, 0x012e, 0x0005, 0x00d6, 0x0126, 0x2091, 0x8000,
+	0x2069, 0x19b6, 0x6a06, 0x012e, 0x00de, 0x0005, 0x00d6, 0x0126,
+	0x2091, 0x8000, 0x2069, 0x19b6, 0x6a32, 0x012e, 0x00de, 0x0005,
+	0x080c, 0x8c48, 0x7814, 0x080c, 0x511b, 0x0108, 0x782c, 0x7032,
+	0x7042, 0x7047, 0x1000, 0x0478, 0x080c, 0x8c48, 0x7814, 0x080c,
+	0x511b, 0x0108, 0x782c, 0x7032, 0x7042, 0x7047, 0x4000, 0x0418,
+	0x080c, 0x8c48, 0x7814, 0x080c, 0x511b, 0x0108, 0x782c, 0x7032,
+	0x7042, 0x7047, 0x2000, 0x00b8, 0x080c, 0x8c48, 0x7814, 0x080c,
+	0x511b, 0x0108, 0x782c, 0x7032, 0x7042, 0x7047, 0x0400, 0x0058,
+	0x080c, 0x8c48, 0x7814, 0x080c, 0x511b, 0x0108, 0x782c, 0x7032,
+	0x7042, 0x7047, 0x0200, 0x60c3, 0x0020, 0x0804, 0x8f8f, 0x00e6,
+	0x2071, 0x19b6, 0x7020, 0x9005, 0x0110, 0x8001, 0x7022, 0x00ee,
+	0x0005, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x0076, 0x0066, 0x0006,
+	0x0126, 0x2091, 0x8000, 0x2071, 0x19b6, 0x7614, 0x2660, 0x2678,
+	0x2039, 0x0001, 0x87ff, 0x0904, 0x93e4, 0x8cff, 0x0904, 0x93e4,
+	0x6020, 0x9086, 0x0006, 0x1904, 0x93df, 0x88ff, 0x0138, 0x2800,
+	0x9c06, 0x1904, 0x93df, 0x2039, 0x0000, 0x0050, 0x6010, 0x9b06,
+	0x1904, 0x93df, 0x85ff, 0x0120, 0x6054, 0x9106, 0x1904, 0x93df,
+	0x7024, 0x9c06, 0x15b0, 0x2069, 0x0100, 0x68c0, 0x9005, 0x1160,
+	0x6824, 0xd084, 0x0148, 0x6827, 0x0001, 0x080c, 0x7cc7, 0x080c,
+	0x9469, 0x7027, 0x0000, 0x0428, 0x080c, 0x7cc7, 0x6820, 0xd0b4,
+	0x0110, 0x68a7, 0x95f5, 0x6817, 0x0008, 0x68c3, 0x0000, 0x080c,
+	0x9469, 0x7027, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0x9384,
+	0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2987, 0x9006, 0x080c,
+	0x2987, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827, 0x0001,
+	0x003e, 0x7014, 0x9c36, 0x1110, 0x660c, 0x7616, 0x7010, 0x9c36,
+	0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x7012, 0x0010, 0x7013,
+	0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008,
+	0x2678, 0x89ff, 0x1168, 0x600f, 0x0000, 0x6014, 0x0096, 0x2048,
+	0x080c, 0xb5f9, 0x0110, 0x080c, 0xcf91, 0x009e, 0x080c, 0x9a06,
+	0x080c, 0x933f, 0x88ff, 0x1190, 0x00ce, 0x0804, 0x935a, 0x2c78,
+	0x600c, 0x2060, 0x0804, 0x935a, 0x9006, 0x012e, 0x000e, 0x006e,
+	0x007e, 0x00ce, 0x00de, 0x00ee, 0x00fe, 0x0005, 0x601b, 0x0000,
+	0x00ce, 0x98c5, 0x0001, 0x0c88, 0x00f6, 0x00e6, 0x00d6, 0x0096,
+	0x00c6, 0x0066, 0x0026, 0x0006, 0x0126, 0x2091, 0x8000, 0x2071,
+	0x19b6, 0x7638, 0x2660, 0x2678, 0x8cff, 0x0904, 0x9458, 0x6020,
+	0x9086, 0x0006, 0x1904, 0x9453, 0x87ff, 0x0128, 0x2700, 0x9c06,
+	0x1904, 0x9453, 0x0040, 0x6010, 0x9b06, 0x15e8, 0x85ff, 0x0118,
+	0x6054, 0x9106, 0x15c0, 0x703c, 0x9c06, 0x1168, 0x0036, 0x2019,
+	0x0001, 0x080c, 0x9254, 0x7033, 0x0000, 0x9006, 0x703e, 0x7042,
+	0x7046, 0x704a, 0x003e, 0x7038, 0x9c36, 0x1110, 0x660c, 0x763a,
+	0x7034, 0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x7036,
+	0x0010, 0x7037, 0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110,
+	0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000, 0x6014, 0x2048, 0x080c,
+	0xb5f9, 0x0110, 0x080c, 0xcf91, 0x080c, 0x9a06, 0x87ff, 0x1198,
+	0x00ce, 0x0804, 0x9404, 0x2c78, 0x600c, 0x2060, 0x0804, 0x9404,
+	0x9006, 0x012e, 0x000e, 0x002e, 0x006e, 0x00ce, 0x009e, 0x00de,
+	0x00ee, 0x00fe, 0x0005, 0x601b, 0x0000, 0x00ce, 0x97bd, 0x0001,
+	0x0c80, 0x00e6, 0x2071, 0x19b6, 0x2001, 0x1800, 0x2004, 0x9086,
+	0x0002, 0x1118, 0x7007, 0x0005, 0x0010, 0x7007, 0x0000, 0x00ee,
+	0x0005, 0x00f6, 0x00e6, 0x00c6, 0x0066, 0x0026, 0x0006, 0x0126,
+	0x2091, 0x8000, 0x2071, 0x19b6, 0x2c10, 0x7638, 0x2660, 0x2678,
+	0x8cff, 0x0518, 0x2200, 0x9c06, 0x11e0, 0x7038, 0x9c36, 0x1110,
+	0x660c, 0x763a, 0x7034, 0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118,
+	0x2f00, 0x7036, 0x0010, 0x7037, 0x0000, 0x660c, 0x2c00, 0x9f06,
+	0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f, 0x0000, 0x9085, 0x0001,
+	0x0020, 0x2c78, 0x600c, 0x2060, 0x08d8, 0x012e, 0x000e, 0x002e,
+	0x006e, 0x00ce, 0x00ee, 0x00fe, 0x0005, 0x0096, 0x00f6, 0x00e6,
+	0x00d6, 0x00c6, 0x0066, 0x0026, 0x0006, 0x0126, 0x2091, 0x8000,
+	0x2071, 0x19b6, 0x760c, 0x2660, 0x2678, 0x8cff, 0x0904, 0x9545,
+	0x6010, 0x00b6, 0x2058, 0xb8a0, 0x00be, 0x9206, 0x1904, 0x9540,
+	0x7024, 0x9c06, 0x1520, 0x2069, 0x0100, 0x68c0, 0x9005, 0x0904,
+	0x951c, 0x080c, 0x8fbb, 0x68c3, 0x0000, 0x080c, 0x9469, 0x7027,
+	0x0000, 0x0036, 0x2069, 0x0140, 0x6b04, 0x9384, 0x1000, 0x0138,
+	0x2001, 0x0100, 0x080c, 0x2987, 0x9006, 0x080c, 0x2987, 0x2069,
+	0x0100, 0x6824, 0xd084, 0x0110, 0x6827, 0x0001, 0x003e, 0x700c,
+	0x9c36, 0x1110, 0x660c, 0x760e, 0x7008, 0x9c36, 0x1140, 0x2c00,
+	0x9f36, 0x0118, 0x2f00, 0x700a, 0x0010, 0x700b, 0x0000, 0x660c,
+	0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e, 0x0008, 0x2678, 0x600f,
+	0x0000, 0x080c, 0xb7e9, 0x1158, 0x080c, 0x2e55, 0x080c, 0xb7fa,
+	0x11f0, 0x080c, 0xa364, 0x00d8, 0x080c, 0x9469, 0x08c0, 0x080c,
+	0xb7fa, 0x1118, 0x080c, 0xa364, 0x0090, 0x6014, 0x2048, 0x080c,
+	0xb5f9, 0x0168, 0x6020, 0x9086, 0x0003, 0x1508, 0xa867, 0x0103,
+	0xab7a, 0xa877, 0x0000, 0x080c, 0x6529, 0x080c, 0xb7dd, 0x080c,
+	0xba61, 0x080c, 0x9a06, 0x080c, 0x933f, 0x00ce, 0x0804, 0x94c5,
+	0x2c78, 0x600c, 0x2060, 0x0804, 0x94c5, 0x012e, 0x000e, 0x002e,
+	0x006e, 0x00ce, 0x00de, 0x00ee, 0x00fe, 0x009e, 0x0005, 0x6020,
+	0x9086, 0x0006, 0x1d20, 0x080c, 0xcf91, 0x0c08, 0x00d6, 0x080c,
+	0x8aef, 0x7003, 0x0200, 0x7007, 0x0014, 0x60c3, 0x0014, 0x20e1,
+	0x0001, 0x2099, 0x1958, 0x20e9, 0x0000, 0x20a1, 0x0250, 0x20a9,
+	0x0004, 0x4003, 0x7023, 0x0004, 0x7027, 0x7878, 0x080c, 0x8f8f,
+	0x00de, 0x0005, 0x080c, 0x8aef, 0x700b, 0x0800, 0x7814, 0x9084,
+	0xff00, 0x700e, 0x7814, 0x9084, 0x00ff, 0x7022, 0x782c, 0x7026,
+	0x7858, 0x9084, 0x00ff, 0x9085, 0x0200, 0x7002, 0x7858, 0x9084,
+	0xff00, 0x8007, 0x7006, 0x60c2, 0x0804, 0x8f8f, 0x00b6, 0x00d6,
+	0x0016, 0x00d6, 0x2f68, 0x2009, 0x0035, 0x080c, 0xbc66, 0x00de,
+	0x1904, 0x95f3, 0x080c, 0x8aa4, 0x7003, 0x1300, 0x782c, 0x080c,
+	0x96f5, 0x2068, 0x6820, 0x9086, 0x0003, 0x0560, 0x7810, 0x2058,
+	0xbaa0, 0x080c, 0x9940, 0x11d8, 0x9286, 0x007e, 0x1128, 0x700b,
+	0x00ff, 0x700f, 0xfffe, 0x0498, 0x9286, 0x007f, 0x1128, 0x700b,
+	0x00ff, 0x700f, 0xfffd, 0x0458, 0x9284, 0xff80, 0x0180, 0x9286,
+	0x0080, 0x1128, 0x700b, 0x00ff, 0x700f, 0xfffc, 0x0400, 0x92d8,
+	0x1000, 0x2b5c, 0xb810, 0x700a, 0xb814, 0x700e, 0x00c0, 0x6098,
+	0x700e, 0x00a8, 0x080c, 0x9940, 0x1130, 0x7810, 0x2058, 0xb8a0,
+	0x9082, 0x007e, 0x0250, 0x00d6, 0x2069, 0x181d, 0x2d04, 0x700a,
+	0x8d68, 0x2d04, 0x700e, 0x00de, 0x0010, 0x6034, 0x700e, 0x7838,
+	0x7012, 0x783c, 0x7016, 0x60c3, 0x000c, 0x001e, 0x00de, 0x080c,
+	0x8f8f, 0x00be, 0x0005, 0x781b, 0x0001, 0x7803, 0x0006, 0x001e,
+	0x00de, 0x00be, 0x0005, 0x792c, 0x9180, 0x0008, 0x200c, 0x9186,
+	0x0006, 0x01c0, 0x9186, 0x0003, 0x0904, 0x966d, 0x9186, 0x0005,
+	0x0904, 0x9656, 0x9186, 0x0004, 0x05d8, 0x9186, 0x0008, 0x0904,
+	0x965e, 0x7807, 0x0037, 0x782f, 0x0003, 0x7817, 0x1700, 0x080c,
+	0x96d2, 0x0005, 0x080c, 0x9693, 0x00d6, 0x0026, 0x792c, 0x2168,
+	0x2009, 0x4000, 0x6800, 0x0002, 0x9637, 0x9642, 0x9639, 0x9642,
+	0x963e, 0x9637, 0x9637, 0x9642, 0x9642, 0x9642, 0x9642, 0x9637,
+	0x9637, 0x9637, 0x9637, 0x9637, 0x9642, 0x9637, 0x9642, 0x080c,
+	0x0db2, 0x6824, 0xd0e4, 0x0110, 0xd0cc, 0x0110, 0x900e, 0x0010,
+	0x2009, 0x2000, 0x682c, 0x7022, 0x6830, 0x7026, 0x0804, 0x968c,
+	0x080c, 0x9693, 0x00d6, 0x0026, 0x792c, 0x2168, 0x2009, 0x4000,
+	0x6a00, 0x9286, 0x0002, 0x1108, 0x900e, 0x04b0, 0x04e1, 0x00d6,
+	0x0026, 0x792c, 0x2168, 0x2009, 0x4000, 0x0470, 0x04a1, 0x00d6,
+	0x0026, 0x792c, 0x2168, 0x2009, 0x4000, 0x9286, 0x0005, 0x0118,
+	0x9286, 0x0002, 0x1108, 0x900e, 0x00f8, 0x0429, 0x00d6, 0x0026,
+	0x792c, 0x2168, 0x6814, 0x0096, 0x2048, 0xa9ac, 0xa834, 0x9112,
+	0xa9b0, 0xa838, 0x009e, 0x9103, 0x7022, 0x7226, 0x792c, 0x9180,
+	0x0000, 0x2004, 0x908e, 0x0002, 0x0130, 0x908e, 0x0004, 0x0118,
+	0x2009, 0x4000, 0x0008, 0x900e, 0x712a, 0x60c3, 0x0018, 0x002e,
+	0x00de, 0x0804, 0x8f8f, 0x00b6, 0x0036, 0x0046, 0x0056, 0x0066,
+	0x080c, 0x8aef, 0x9006, 0x7003, 0x0200, 0x7938, 0x710a, 0x793c,
+	0x710e, 0x7810, 0x2058, 0xb8a0, 0x080c, 0x9940, 0x1118, 0x9092,
+	0x007e, 0x0268, 0x00d6, 0x2069, 0x181d, 0x2d2c, 0x8d68, 0x2d34,
+	0x90d8, 0x1000, 0x2b5c, 0xbb10, 0xbc14, 0x00de, 0x0028, 0x901e,
+	0x6498, 0x2029, 0x0000, 0x6634, 0x782c, 0x9080, 0x0008, 0x2004,
+	0x9086, 0x0003, 0x1128, 0x7512, 0x7616, 0x731a, 0x741e, 0x0020,
+	0x7312, 0x7416, 0x751a, 0x761e, 0x006e, 0x005e, 0x004e, 0x003e,
+	0x00be, 0x0005, 0x080c, 0x8aef, 0x7003, 0x0100, 0x782c, 0x700a,
+	0x7814, 0x700e, 0x700e, 0x60c3, 0x0008, 0x0804, 0x8f8f, 0x080c,
+	0x8a9b, 0x7003, 0x1400, 0x7838, 0x700a, 0x0079, 0x783c, 0x700e,
+	0x782c, 0x7012, 0x7830, 0x7016, 0x7834, 0x9084, 0x00ff, 0x8007,
+	0x701a, 0x60c3, 0x0010, 0x0804, 0x8f8f, 0x00e6, 0x2071, 0x0240,
+	0x0006, 0x00f6, 0x2078, 0x7810, 0x00b6, 0x2058, 0xb8bc, 0xd084,
+	0x0120, 0x7848, 0x702a, 0x7844, 0x702e, 0x00be, 0x00fe, 0x000e,
+	0x00ee, 0x0005, 0x080c, 0x8ae6, 0x7003, 0x0100, 0x782c, 0x700a,
+	0x7814, 0x700e, 0x60c3, 0x0008, 0x0804, 0x8f8f, 0x0021, 0x60c3,
+	0x0000, 0x0804, 0x8f8f, 0x00d6, 0x080c, 0x97ce, 0xb810, 0x9085,
+	0x0300, 0x7002, 0xb814, 0x7006, 0x2069, 0x1800, 0x6874, 0x700a,
+	0x6878, 0x700e, 0x7013, 0x0819, 0x080c, 0x8f7d, 0x721a, 0x2f10,
+	0x7222, 0x7a08, 0x7226, 0x2071, 0x024c, 0x00de, 0x0005, 0x00a9,
+	0x7914, 0x712a, 0x60c3, 0x0000, 0x60a7, 0x9575, 0x0026, 0x080c,
+	0x283d, 0x0228, 0x2011, 0x0101, 0x2204, 0xc0c5, 0x2012, 0x002e,
+	0x080c, 0x8fb2, 0x080c, 0x7cbe, 0x0005, 0x0036, 0x0096, 0x00d6,
+	0x00e6, 0x7858, 0x2048, 0xaa7c, 0x9296, 0x00c0, 0x9294, 0xfffd,
+	0xaa7e, 0xaa80, 0x9294, 0x0300, 0xaa82, 0xa96c, 0x9194, 0x00ff,
+	0xab74, 0x9384, 0x00ff, 0x908d, 0xc200, 0xa96e, 0x9384, 0xff00,
+	0x9215, 0xaa76, 0xa870, 0xaa78, 0xa87a, 0xaa72, 0x00d6, 0x2069,
+	0x0200, 0x080c, 0x97ce, 0x00de, 0x20e9, 0x0000, 0x20a1, 0x0240,
+	0x20a9, 0x000a, 0xa860, 0x20e0, 0xa85c, 0x9080, 0x001b, 0x2098,
+	0x4003, 0x60a3, 0x0035, 0xaa68, 0x9294, 0x7000, 0x9286, 0x3000,
+	0x0110, 0x60a3, 0x0037, 0x00ee, 0x00de, 0x009e, 0x003e, 0x0005,
+	0x900e, 0x7814, 0x0096, 0x2048, 0xa87c, 0xd0fc, 0x01c0, 0x9084,
+	0x0003, 0x11a8, 0x2001, 0x180c, 0x2004, 0xd0bc, 0x0180, 0x7824,
+	0xd0cc, 0x1168, 0xd0c4, 0x1158, 0xa8a8, 0x9005, 0x1140, 0x2001,
+	0x180c, 0x200c, 0xc1d5, 0x2102, 0x2009, 0x1981, 0x210c, 0x009e,
+	0x918d, 0x0092, 0x0010, 0x2009, 0x0096, 0x60ab, 0x0036, 0x6116,
+	0x0005, 0x2009, 0x0009, 0x00a0, 0x2009, 0x000a, 0x0088, 0x2009,
+	0x000b, 0x0070, 0x2009, 0x000c, 0x0058, 0x2009, 0x000d, 0x0040,
+	0x2009, 0x000e, 0x0028, 0x2009, 0x000f, 0x0010, 0x2009, 0x0008,
+	0x6912, 0x0005, 0x00d6, 0x9290, 0x0018, 0x8214, 0x20e9, 0x0000,
+	0x2069, 0x0200, 0x6813, 0x0000, 0x22a8, 0x9284, 0x00e0, 0x0128,
+	0x20a9, 0x0020, 0x9292, 0x0020, 0x0008, 0x9016, 0x20a1, 0x0240,
+	0x9006, 0x4004, 0x82ff, 0x0120, 0x6810, 0x8000, 0x6812, 0x0c60,
+	0x00de, 0x0005, 0x00d6, 0x0096, 0x6014, 0x2048, 0xa878, 0x6056,
+	0x9006, 0xa836, 0xa83a, 0xa99c, 0xa946, 0xa84a, 0x6023, 0x0003,
+	0x6007, 0x0040, 0x6003, 0x0003, 0x600b, 0xffff, 0xa817, 0x0001,
+	0xa842, 0xa83e, 0x2900, 0xa85a, 0xa813, 0x1da0, 0x080c, 0x8065,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x865d, 0x012e, 0x009e, 0x00de,
+	0x0005, 0x00f6, 0x00e6, 0x00d6, 0x00c6, 0x00a6, 0x0096, 0x0066,
+	0x0126, 0x2091, 0x8000, 0x2071, 0x19b6, 0x760c, 0x2660, 0x2678,
+	0x8cff, 0x0904, 0x98a0, 0x7024, 0x9c06, 0x1520, 0x2069, 0x0100,
+	0x68c0, 0x9005, 0x0904, 0x9877, 0x080c, 0x8fbb, 0x68c3, 0x0000,
+	0x080c, 0x9469, 0x7027, 0x0000, 0x0036, 0x2069, 0x0140, 0x6b04,
+	0x9384, 0x1000, 0x0138, 0x2001, 0x0100, 0x080c, 0x2987, 0x9006,
+	0x080c, 0x2987, 0x2069, 0x0100, 0x6824, 0xd084, 0x0110, 0x6827,
+	0x0001, 0x003e, 0x700c, 0x9c36, 0x1110, 0x660c, 0x760e, 0x7008,
+	0x9c36, 0x1140, 0x2c00, 0x9f36, 0x0118, 0x2f00, 0x700a, 0x0010,
+	0x700b, 0x0000, 0x660c, 0x0066, 0x2c00, 0x9f06, 0x0110, 0x7e0e,
+	0x0008, 0x2678, 0x600f, 0x0000, 0x080c, 0xb7e9, 0x1158, 0x080c,
+	0x2e55, 0x080c, 0xb7fa, 0x11f0, 0x080c, 0xa364, 0x00d8, 0x080c,
+	0x9469, 0x08c0, 0x080c, 0xb7fa, 0x1118, 0x080c, 0xa364, 0x0090,
+	0x6014, 0x2048, 0x080c, 0xb5f9, 0x0168, 0x6020, 0x9086, 0x0003,
+	0x1520, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c, 0x6536,
+	0x080c, 0xb7dd, 0x080c, 0xba61, 0x080c, 0x9a06, 0x080c, 0x933f,
+	0x00ce, 0x0804, 0x9828, 0x2c78, 0x600c, 0x2060, 0x0804, 0x9828,
+	0x700f, 0x0000, 0x700b, 0x0000, 0x012e, 0x006e, 0x009e, 0x00ae,
+	0x00ce, 0x00de, 0x00ee, 0x00fe, 0x0005, 0x6020, 0x9086, 0x0006,
+	0x1d08, 0x080c, 0xcf91, 0x08f0, 0x00d6, 0x0156, 0x080c, 0x8aef,
+	0x7a14, 0x82ff, 0x0138, 0x7003, 0x0100, 0x700b, 0x0003, 0x60c3,
+	0x0008, 0x0490, 0x7003, 0x0200, 0x7007, 0x0000, 0x2069, 0x1800,
+	0x901e, 0x6800, 0x9086, 0x0004, 0x1110, 0xc38d, 0x0060, 0x080c,
+	0x6c53, 0x1110, 0xc3ad, 0x0008, 0xc3a5, 0x6ad4, 0xd29c, 0x1110,
+	0xd2ac, 0x0108, 0xc39d, 0x730e, 0x2011, 0x1848, 0x63f0, 0x2312,
+	0x20a9, 0x0006, 0x2011, 0x1840, 0x2019, 0x1841, 0x2071, 0x0250,
+	0x2376, 0x8e70, 0x2276, 0x8e70, 0x9398, 0x0002, 0x9290, 0x0002,
+	0x1f04, 0x98e8, 0x60c3, 0x0020, 0x080c, 0x8f8f, 0x015e, 0x00de,
+	0x0005, 0x0156, 0x080c, 0x8aef, 0x7a14, 0x82ff, 0x0168, 0x9286,
+	0xffff, 0x0118, 0x9282, 0x000e, 0x1238, 0x7003, 0x0100, 0x700b,
+	0x0003, 0x60c3, 0x0008, 0x0488, 0x7003, 0x0200, 0x7007, 0x001c,
+	0x700f, 0x0001, 0x2011, 0x198c, 0x2204, 0x8007, 0x701a, 0x8210,
+	0x2204, 0x8007, 0x701e, 0x0421, 0x1120, 0xb8a0, 0x9082, 0x007f,
+	0x0248, 0x2001, 0x181d, 0x2004, 0x7022, 0x2001, 0x181e, 0x2004,
+	0x7026, 0x0030, 0x2001, 0x1816, 0x2004, 0x9084, 0x00ff, 0x7026,
+	0x20a9, 0x0004, 0x20e1, 0x0001, 0x2099, 0x1805, 0x20e9, 0x0000,
+	0x20a1, 0x0256, 0x4003, 0x60c3, 0x001c, 0x015e, 0x0804, 0x8f8f,
+	0x0006, 0x2001, 0x1835, 0x2004, 0xd0ac, 0x000e, 0x0005, 0x2011,
+	0x0003, 0x080c, 0x92ec, 0x2011, 0x0002, 0x080c, 0x92f6, 0x080c,
+	0x91de, 0x0036, 0x901e, 0x080c, 0x9254, 0x003e, 0x0005, 0x080c,
+	0x2f8b, 0x0188, 0x0016, 0x00b6, 0x00c6, 0x7010, 0x9085, 0x0020,
+	0x7012, 0x2009, 0x007e, 0x080c, 0x5f7e, 0xb85c, 0xc0ac, 0xb85e,
+	0x00ce, 0x00be, 0x001e, 0x0005, 0x2071, 0x1883, 0x7000, 0x9005,
+	0x0140, 0x2001, 0x0976, 0x2071, 0x1800, 0x706e, 0x7072, 0x7063,
+	0xffe0, 0x2071, 0x1800, 0x706c, 0x704e, 0x7053, 0x1cd0, 0x0005,
+	0x00e6, 0x0126, 0x2071, 0x1800, 0x2091, 0x8000, 0x754c, 0x9582,
+	0x0010, 0x0608, 0x7050, 0x2060, 0x6000, 0x9086, 0x0000, 0x0148,
+	0x9ce0, 0x0018, 0x7060, 0x9c02, 0x1208, 0x0cb0, 0x2061, 0x1cd0,
+	0x0c98, 0x6003, 0x0008, 0x8529, 0x754e, 0x9ca8, 0x0018, 0x7060,
+	0x9502, 0x1230, 0x7552, 0x9085, 0x0001, 0x012e, 0x00ee, 0x0005,
+	0x7053, 0x1cd0, 0x0cc0, 0x9006, 0x0cc0, 0x00e6, 0x2071, 0x1800,
+	0x754c, 0x9582, 0x0010, 0x0600, 0x7050, 0x2060, 0x6000, 0x9086,
+	0x0000, 0x0148, 0x9ce0, 0x0018, 0x7060, 0x9c02, 0x1208, 0x0cb0,
+	0x2061, 0x1cd0, 0x0c98, 0x6003, 0x0008, 0x8529, 0x754e, 0x9ca8,
+	0x0018, 0x7060, 0x9502, 0x1228, 0x7552, 0x9085, 0x0001, 0x00ee,
+	0x0005, 0x7053, 0x1cd0, 0x0cc8, 0x9006, 0x0cc8, 0x9c82, 0x1cd0,
+	0x0a0c, 0x0db2, 0x2001, 0x1818, 0x2004, 0x9c02, 0x1a0c, 0x0db2,
+	0x9006, 0x6006, 0x600a, 0x600e, 0x6016, 0x601a, 0x6012, 0x6023,
+	0x0000, 0x6003, 0x0000, 0x601e, 0x6056, 0x605a, 0x6026, 0x602a,
+	0x602e, 0x6032, 0x6036, 0x603a, 0x603e, 0x6042, 0x2061, 0x1800,
+	0x604c, 0x8000, 0x604e, 0x9086, 0x0001, 0x0108, 0x0005, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x8582, 0x012e, 0x0cc0, 0x0006, 0x6000,
+	0x9086, 0x0000, 0x01b0, 0x601c, 0xd084, 0x190c, 0x1827, 0x6017,
+	0x0000, 0x6023, 0x0007, 0x2001, 0x1955, 0x2004, 0x0006, 0x9082,
+	0x0051, 0x000e, 0x0208, 0x8004, 0x601a, 0x080c, 0xd240, 0x6043,
+	0x0000, 0x000e, 0x0005, 0x00e6, 0x0126, 0x2071, 0x1800, 0x2091,
+	0x8000, 0x754c, 0x9582, 0x0001, 0x0608, 0x7050, 0x2060, 0x6000,
+	0x9086, 0x0000, 0x0148, 0x9ce0, 0x0018, 0x7060, 0x9c02, 0x1208,
+	0x0cb0, 0x2061, 0x1cd0, 0x0c98, 0x6003, 0x0008, 0x8529, 0x754e,
+	0x9ca8, 0x0018, 0x7060, 0x9502, 0x1230, 0x7552, 0x9085, 0x0001,
+	0x012e, 0x00ee, 0x0005, 0x7053, 0x1cd0, 0x0cc0, 0x9006, 0x0cc0,
+	0x6020, 0x9084, 0x000f, 0x0002, 0x9a63, 0x9a6c, 0x9a87, 0x9aa2,
+	0xbd12, 0xbd2f, 0xbd4a, 0x9a63, 0x9a6c, 0x9a63, 0x9abe, 0x9a63,
+	0x9a63, 0x9a63, 0x9a63, 0x9186, 0x0013, 0x1128, 0x080c, 0x847d,
+	0x080c, 0x8582, 0x0005, 0x0005, 0x0066, 0x6000, 0x90b2, 0x0016,
+	0x1a0c, 0x0db2, 0x0013, 0x006e, 0x0005, 0x9a85, 0xa1dd, 0xa3ab,
+	0x9a85, 0xa439, 0x9d9f, 0x9a85, 0x9a85, 0xa15f, 0xa947, 0x9a85,
+	0x9a85, 0x9a85, 0x9a85, 0x9a85, 0x9a85, 0x080c, 0x0db2, 0x0066,
+	0x6000, 0x90b2, 0x0016, 0x1a0c, 0x0db2, 0x0013, 0x006e, 0x0005,
+	0x9aa0, 0xb012, 0x9aa0, 0x9aa0, 0x9aa0, 0x9aa0, 0x9aa0, 0x9aa0,
+	0xafb7, 0xb194, 0x9aa0, 0xb053, 0xb0d2, 0xb053, 0xb0d2, 0x9aa0,
+	0x080c, 0x0db2, 0x6000, 0x9082, 0x0016, 0x1a0c, 0x0db2, 0x6000,
+	0x0002, 0x9abc, 0xa98e, 0xaa73, 0xaba3, 0xad45, 0x9abc, 0x9abc,
+	0x9abc, 0xa962, 0xaf43, 0xaf46, 0x9abc, 0x9abc, 0x9abc, 0x9abc,
+	0xaf75, 0x9abc, 0x9abc, 0x9abc, 0x080c, 0x0db2, 0x0066, 0x6000,
+	0x90b2, 0x0016, 0x1a0c, 0x0db2, 0x0013, 0x006e, 0x0005, 0x9ad7,
+	0x9ad7, 0x9b1a, 0x9bb8, 0x9c4c, 0x9ad7, 0x9ad7, 0x9ad7, 0x9ad9,
+	0x9ad7, 0x9ad7, 0x9ad7, 0x9ad7, 0x9ad7, 0x9ad7, 0x9ad7, 0x080c,
+	0x0db2, 0x9186, 0x004c, 0x0588, 0x9186, 0x0003, 0x190c, 0x0db2,
+	0x0096, 0x601c, 0xc0ed, 0x601e, 0x6003, 0x0003, 0x6106, 0x6014,
+	0x2048, 0xa87c, 0x9084, 0xa000, 0xc0b5, 0xa87e, 0xa8ac, 0xa846,
+	0xa8b0, 0xa84a, 0x9006, 0xa836, 0xa83a, 0xa884, 0x9092, 0x199a,
+	0x0210, 0x2001, 0x1999, 0x8003, 0x8013, 0x8213, 0x9210, 0x621a,
+	0x009e, 0x2c10, 0x080c, 0x1976, 0x080c, 0x8065, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x865d, 0x012e, 0x0005, 0x6010, 0x00b6, 0x2058,
+	0xbca0, 0x00be, 0x2c00, 0x080c, 0x9c6e, 0x080c, 0xbd04, 0x6003,
+	0x0007, 0x0005, 0x00d6, 0x0096, 0x00f6, 0x2079, 0x1800, 0x7a88,
+	0x6014, 0x2048, 0xa87c, 0xd0ec, 0x1110, 0x9290, 0x0018, 0xac78,
+	0x0046, 0xa8e0, 0x9005, 0x1140, 0xa8dc, 0x921a, 0x0140, 0x0220,
+	0xa87b, 0x0007, 0x2010, 0x0028, 0xa87b, 0x0015, 0x0010, 0xa87b,
+	0x0000, 0x8214, 0xa883, 0x0000, 0xaa02, 0x0006, 0x0016, 0x0026,
+	0x00c6, 0x00d6, 0x00e6, 0x00f6, 0x2400, 0x9005, 0x1108, 0x009a,
+	0x2100, 0x9086, 0x0015, 0x1118, 0x2001, 0x0001, 0x0038, 0x2100,
+	0x9086, 0x0016, 0x0118, 0x2001, 0x0001, 0x002a, 0x94a4, 0x0007,
+	0x8423, 0x9405, 0x0002, 0x9b80, 0x9b80, 0x9b7b, 0x9b7e, 0x9b80,
+	0x9b78, 0x9b6b, 0x9b6b, 0x9b6b, 0x9b6b, 0x9b6b, 0x9b6b, 0x9b6b,
+	0x9b6b, 0x9b6b, 0x9b6b, 0x00fe, 0x00ee, 0x00de, 0x00ce, 0x002e,
+	0x001e, 0x000e, 0x004e, 0x00fe, 0x009e, 0x00de, 0x080c, 0x0db2,
+	0x080c, 0xa5d7, 0x0028, 0x080c, 0xa6b5, 0x0010, 0x080c, 0xa7a4,
+	0x00fe, 0x00ee, 0x00de, 0x00ce, 0x002e, 0x001e, 0x2c00, 0xa896,
+	0x000e, 0x080c, 0x9d2c, 0x0530, 0xa804, 0xa80e, 0x00a6, 0x2050,
+	0xb100, 0x00ae, 0x8006, 0x8006, 0x8007, 0x90bc, 0x003f, 0x9084,
+	0xffc0, 0x9080, 0x0002, 0xaacc, 0xabd0, 0xacd4, 0xadd8, 0x2031,
+	0x0000, 0x2041, 0x1226, 0x080c, 0x9ed6, 0x0160, 0x000e, 0x9005,
+	0x0120, 0x00fe, 0x009e, 0x00de, 0x0005, 0x00fe, 0x009e, 0x00de,
+	0x0804, 0x99d6, 0x2001, 0x002c, 0x900e, 0x080c, 0x9d92, 0x0c70,
+	0x91b6, 0x0015, 0x0170, 0x91b6, 0x0016, 0x0158, 0x91b2, 0x0047,
+	0x0a0c, 0x0db2, 0x91b2, 0x0050, 0x1a0c, 0x0db2, 0x9182, 0x0047,
+	0x00ca, 0x2001, 0x0109, 0x2004, 0xd08c, 0x0198, 0x0126, 0x2091,
+	0x2800, 0x0006, 0x0016, 0x0026, 0x080c, 0x7fb9, 0x002e, 0x001e,
+	0x000e, 0x012e, 0xa001, 0x6000, 0x9086, 0x0002, 0x1110, 0x0804,
+	0x9b1a, 0x0005, 0x9beb, 0x9beb, 0x9bed, 0x9c22, 0x9beb, 0x9beb,
+	0x9beb, 0x9beb, 0x9c35, 0x080c, 0x0db2, 0x00d6, 0x0016, 0x0096,
+	0x080c, 0x8532, 0x080c, 0x865d, 0x6003, 0x0004, 0x6114, 0x2148,
+	0xa87c, 0xd0fc, 0x01b8, 0xa878, 0x9005, 0x1158, 0xa894, 0x9005,
+	0x0140, 0x2001, 0x0000, 0x900e, 0x080c, 0x9d92, 0x080c, 0x99d6,
+	0x00a8, 0x6003, 0x0002, 0xa8a4, 0xa9a8, 0x9105, 0x1178, 0xa8ae,
+	0xa8b2, 0x0c78, 0xa87f, 0x0020, 0xa88c, 0xa88a, 0xa8a4, 0xa8ae,
+	0xa8a8, 0xa8b2, 0xa8c7, 0x0000, 0xa8cb, 0x0000, 0x009e, 0x001e,
+	0x00de, 0x0005, 0x080c, 0x8532, 0x00d6, 0x0096, 0x6114, 0x2148,
+	0x080c, 0xb5fb, 0x0120, 0xa87b, 0x0006, 0x080c, 0x6536, 0x009e,
+	0x00de, 0x080c, 0x99d6, 0x0804, 0x865d, 0x080c, 0x8532, 0x080c,
+	0x2e30, 0x080c, 0xbd01, 0x00d6, 0x0096, 0x6114, 0x2148, 0x080c,
+	0xb5fb, 0x0120, 0xa87b, 0x0029, 0x080c, 0x6536, 0x009e, 0x00de,
+	0x080c, 0x99d6, 0x0804, 0x865d, 0x9182, 0x0047, 0x0002, 0x9c5c,
+	0x9c5e, 0x9c5c, 0x9c5c, 0x9c5c, 0x9c5c, 0x9c5c, 0x9c5c, 0x9c5c,
+	0x9c5c, 0x9c5c, 0x9c5c, 0x9c5e, 0x080c, 0x0db2, 0x00d6, 0x0096,
+	0x080c, 0x14c9, 0x6114, 0x2148, 0xa87b, 0x0000, 0xa883, 0x0000,
+	0x080c, 0x6536, 0x009e, 0x00de, 0x0804, 0x99d6, 0x0026, 0x0036,
+	0x0056, 0x0066, 0x0096, 0x00a6, 0x00f6, 0x0006, 0x080c, 0x0fd5,
+	0x000e, 0x090c, 0x0db2, 0xa960, 0x21e8, 0xa95c, 0x9188, 0x0019,
+	0x21a0, 0x900e, 0x20a9, 0x0020, 0x4104, 0xa87a, 0x2079, 0x1800,
+	0x7988, 0x9188, 0x0018, 0x918c, 0x0fff, 0xa972, 0xac76, 0x2950,
+	0x00a6, 0x2001, 0x0205, 0x2003, 0x0000, 0x901e, 0x2029, 0x0001,
+	0x9182, 0x0034, 0x1228, 0x2011, 0x001f, 0x080c, 0xb219, 0x04c0,
+	0x2130, 0x2009, 0x0034, 0x2011, 0x001f, 0x080c, 0xb219, 0x96b2,
+	0x0034, 0xb004, 0x904d, 0x0110, 0x080c, 0x0f87, 0x080c, 0x0fd5,
+	0x01d0, 0x8528, 0xa867, 0x0110, 0xa86b, 0x0000, 0x2920, 0xb406,
+	0x968a, 0x003d, 0x1230, 0x2608, 0x2011, 0x001b, 0x080c, 0xb219,
+	0x00b8, 0x96b2, 0x003c, 0x2009, 0x003c, 0x2950, 0x2011, 0x001b,
+	0x080c, 0xb219, 0x0c18, 0x2001, 0x0205, 0x2003, 0x0000, 0x00ae,
+	0x852f, 0x95ad, 0x0050, 0xb566, 0xb070, 0xc0fd, 0xb072, 0x0048,
+	0x2001, 0x0205, 0x2003, 0x0000, 0x00ae, 0x852f, 0x95ad, 0x0050,
+	0xb566, 0x2a48, 0xa804, 0xa807, 0x0000, 0x0006, 0x080c, 0x6536,
+	0x000e, 0x2048, 0x9005, 0x1db0, 0x00fe, 0x00ae, 0x009e, 0x006e,
+	0x005e, 0x003e, 0x002e, 0x0005, 0x00d6, 0x00f6, 0x0096, 0x0006,
+	0x080c, 0x0fd5, 0x000e, 0x090c, 0x0db2, 0xa960, 0x21e8, 0xa95c,
+	0x9188, 0x0019, 0x21a0, 0x900e, 0x20a9, 0x0020, 0x4104, 0xaa66,
+	0xa87a, 0x2079, 0x1800, 0x7988, 0x810c, 0x9188, 0x000c, 0x9182,
+	0x001a, 0x0210, 0x2009, 0x001a, 0x21a8, 0x810b, 0xa972, 0xac76,
+	0x2e98, 0xa85c, 0x9080, 0x001f, 0x20a0, 0x2001, 0x0205, 0x200c,
+	0x918d, 0x0080, 0x2102, 0x4003, 0x2003, 0x0000, 0x080c, 0x6536,
+	0x009e, 0x00fe, 0x00de, 0x0005, 0x0016, 0x00d6, 0x00f6, 0x0096,
+	0x0016, 0x2001, 0x0205, 0x200c, 0x918d, 0x0080, 0x2102, 0x001e,
+	0x2079, 0x0200, 0x2e98, 0xa87c, 0xd0ec, 0x0118, 0x9e80, 0x000c,
+	0x2098, 0x2021, 0x003e, 0x901e, 0x9282, 0x0020, 0x0218, 0x2011,
+	0x0020, 0x2018, 0x9486, 0x003e, 0x1170, 0x0096, 0x080c, 0x0fd5,
+	0x2900, 0x009e, 0x05c0, 0xa806, 0x2048, 0xa860, 0x20e8, 0xa85c,
+	0x9080, 0x0002, 0x20a0, 0x3300, 0x908e, 0x0260, 0x0140, 0x2009,
+	0x0280, 0x9102, 0x920a, 0x0218, 0x2010, 0x2100, 0x9318, 0x2200,
+	0x9402, 0x1228, 0x2400, 0x9202, 0x2410, 0x9318, 0x9006, 0x2020,
+	0x22a8, 0xa800, 0x9200, 0xa802, 0x20e1, 0x0000, 0x4003, 0x83ff,
+	0x0180, 0x3300, 0x9086, 0x0280, 0x1130, 0x7814, 0x8000, 0x9085,
+	0x0080, 0x7816, 0x2e98, 0x2310, 0x84ff, 0x0904, 0x9d41, 0x0804,
+	0x9d43, 0x9085, 0x0001, 0x7817, 0x0000, 0x009e, 0x00fe, 0x00de,
+	0x001e, 0x0005, 0x00d6, 0x0036, 0x0096, 0x6314, 0x2348, 0xa87a,
+	0xa982, 0x080c, 0x6529, 0x009e, 0x003e, 0x00de, 0x0005, 0x91b6,
+	0x0015, 0x1118, 0x080c, 0x99d6, 0x0030, 0x91b6, 0x0016, 0x190c,
+	0x0db2, 0x080c, 0x99d6, 0x0005, 0x20a9, 0x000e, 0x20e1, 0x0000,
+	0x2e98, 0x6014, 0x0096, 0x2048, 0xa860, 0x20e8, 0xa85c, 0x20a0,
+	0x009e, 0x4003, 0x0136, 0x9080, 0x001b, 0x2011, 0x0006, 0x20a9,
+	0x0001, 0x3418, 0x8318, 0x23a0, 0x4003, 0x3318, 0x8318, 0x2398,
+	0x8211, 0x1db8, 0x2011, 0x0006, 0x013e, 0x20a0, 0x3318, 0x8318,
+	0x2398, 0x4003, 0x3418, 0x8318, 0x23a0, 0x8211, 0x1db8, 0x0096,
+	0x080c, 0xb5fb, 0x0130, 0x6014, 0x2048, 0xa807, 0x0000, 0xa867,
+	0x0103, 0x009e, 0x0804, 0x99d6, 0x0096, 0x00d6, 0x0036, 0x7330,
+	0x9386, 0x0200, 0x11a8, 0x6010, 0x00b6, 0x2058, 0xb8bf, 0x0000,
+	0x00be, 0x6014, 0x9005, 0x0130, 0x2048, 0xa807, 0x0000, 0xa867,
+	0x0103, 0xab32, 0x080c, 0x99d6, 0x003e, 0x00de, 0x009e, 0x0005,
+	0x0011, 0x1d48, 0x0cc8, 0x0006, 0x0016, 0x080c, 0xbcec, 0x0188,
+	0x6014, 0x9005, 0x1170, 0x600b, 0x0003, 0x601b, 0x0000, 0x6043,
+	0x0000, 0x2009, 0x0022, 0x080c, 0xa1b5, 0x9006, 0x001e, 0x000e,
+	0x0005, 0x9085, 0x0001, 0x0cd0, 0x0096, 0x0016, 0x20a9, 0x0014,
+	0x9e80, 0x000c, 0x20e1, 0x0000, 0x2098, 0x6014, 0x2048, 0xa860,
+	0x20e8, 0xa85c, 0x9080, 0x0002, 0x20a0, 0x4003, 0x2001, 0x0205,
+	0x2003, 0x0001, 0x2099, 0x0260, 0x20a9, 0x0016, 0x4003, 0x20a9,
+	0x000a, 0xa804, 0x2048, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0002,
+	0x20a0, 0x4003, 0x2001, 0x0205, 0x2003, 0x0002, 0x2099, 0x0260,
+	0x20a9, 0x0020, 0x4003, 0x2003, 0x0000, 0x6014, 0x2048, 0xa800,
+	0x2048, 0xa867, 0x0103, 0x080c, 0x99d6, 0x001e, 0x009e, 0x0005,
+	0x0096, 0x0016, 0x900e, 0x7030, 0x9086, 0x0100, 0x0140, 0x7038,
+	0x9084, 0x00ff, 0x800c, 0x703c, 0x9084, 0x00ff, 0x8004, 0x9080,
+	0x0004, 0x9108, 0x810b, 0x2011, 0x0002, 0x2019, 0x000c, 0x6014,
+	0x2048, 0x080c, 0xb219, 0x080c, 0xb5fb, 0x0140, 0x6014, 0x2048,
+	0xa807, 0x0000, 0xa864, 0xa8e2, 0xa867, 0x0103, 0x080c, 0x99d6,
+	0x001e, 0x009e, 0x0005, 0x0016, 0x0096, 0x7030, 0x9086, 0x0100,
+	0x1118, 0x2009, 0x0004, 0x0010, 0x7034, 0x800c, 0x810b, 0x2011,
+	0x000c, 0x2019, 0x000c, 0x6014, 0x2048, 0xa804, 0x0096, 0x9005,
+	0x0108, 0x2048, 0x080c, 0xb219, 0x009e, 0x080c, 0xb5fb, 0x0148,
+	0xa804, 0x9005, 0x1158, 0xa807, 0x0000, 0xa864, 0xa8e2, 0xa867,
+	0x0103, 0x080c, 0x99d6, 0x009e, 0x001e, 0x0005, 0x0086, 0x2040,
+	0xa030, 0x8007, 0x9086, 0x0100, 0x1118, 0x080c, 0xa364, 0x00e0,
+	0xa034, 0x8007, 0x800c, 0x8806, 0x8006, 0x8007, 0x90bc, 0x003f,
+	0x9084, 0xffc0, 0x9080, 0x000c, 0xa87b, 0x0000, 0xa883, 0x0000,
+	0xa897, 0x4000, 0xaaa0, 0xab9c, 0xaca8, 0xada4, 0x2031, 0x0000,
+	0x2041, 0x120c, 0x0019, 0x0d08, 0x008e, 0x0898, 0x0096, 0x0006,
+	0x080c, 0x0fd5, 0x000e, 0x01b0, 0xa8ab, 0x0dcb, 0xa876, 0x000e,
+	0xa8a2, 0x0006, 0xae6a, 0x2800, 0xa89e, 0xa97a, 0xaf72, 0xaa8e,
+	0xab92, 0xac96, 0xad9a, 0x0086, 0x2940, 0x080c, 0x10b5, 0x008e,
+	0x9085, 0x0001, 0x009e, 0x0005, 0x00e6, 0x00d6, 0x0026, 0x7008,
+	0x9084, 0x00ff, 0x6210, 0x00b6, 0x2258, 0xba10, 0x00be, 0x9206,
+	0x1520, 0x700c, 0x6210, 0x00b6, 0x2258, 0xba14, 0x00be, 0x9206,
+	0x11e0, 0x6043, 0x0000, 0x2c68, 0x0016, 0x2009, 0x0035, 0x080c,
+	0xbc66, 0x001e, 0x1158, 0x622c, 0x2268, 0x2071, 0x026c, 0x6b20,
+	0x9386, 0x0003, 0x0130, 0x9386, 0x0006, 0x0128, 0x080c, 0x99d6,
+	0x0020, 0x0039, 0x0010, 0x080c, 0x9fe8, 0x002e, 0x00de, 0x00ee,
+	0x0005, 0x0096, 0x6814, 0x2048, 0x9186, 0x0015, 0x0904, 0x9fd0,
+	0x918e, 0x0016, 0x1904, 0x9fe6, 0x700c, 0x908c, 0xff00, 0x9186,
+	0x1700, 0x0120, 0x9186, 0x0300, 0x1904, 0x9faa, 0x89ff, 0x1138,
+	0x6800, 0x9086, 0x000f, 0x0904, 0x9f8d, 0x0804, 0x9fe4, 0x6808,
+	0x9086, 0xffff, 0x1904, 0x9fd2, 0xa87c, 0x9084, 0x0060, 0x9086,
+	0x0020, 0x1128, 0xa83c, 0xa940, 0x9105, 0x1904, 0x9fd2, 0x6824,
+	0xd0b4, 0x1904, 0x9fd2, 0x080c, 0xb7dd, 0x685c, 0xa882, 0xa87c,
+	0xc0dc, 0xc0f4, 0xc0d4, 0xa87e, 0x0026, 0x900e, 0x6a18, 0x2001,
+	0x000a, 0x080c, 0x7e7f, 0xa884, 0x920a, 0x0208, 0x8011, 0xaa86,
+	0x82ff, 0x002e, 0x1138, 0x00c6, 0x2d60, 0x080c, 0xb33a, 0x00ce,
+	0x0804, 0x9fe4, 0x00c6, 0xa868, 0xd0fc, 0x1118, 0x080c, 0x5a9d,
+	0x0010, 0x080c, 0x5e34, 0x00ce, 0x1904, 0x9fd2, 0x00c6, 0x2d60,
+	0x080c, 0x99d6, 0x00ce, 0x0804, 0x9fe4, 0x00c6, 0x080c, 0x9a23,
+	0x0198, 0x6017, 0x0000, 0x6810, 0x6012, 0x080c, 0xba69, 0x6023,
+	0x0003, 0x6904, 0x00c6, 0x2d60, 0x080c, 0x99d6, 0x00ce, 0x080c,
+	0x9a50, 0x00ce, 0x0804, 0x9fe4, 0x2001, 0x1957, 0x2004, 0x6842,
+	0x00ce, 0x04d0, 0x7008, 0x9086, 0x000b, 0x11c8, 0x6010, 0x00b6,
+	0x2058, 0xb900, 0xc1bc, 0xb902, 0x00be, 0x00c6, 0x2d60, 0xa883,
+	0x0003, 0x080c, 0xbca8, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023,
+	0x0002, 0x080c, 0x8000, 0x080c, 0x8582, 0x00ce, 0x00e8, 0x700c,
+	0x9086, 0x2a00, 0x1138, 0x2001, 0x1957, 0x2004, 0x6842, 0x00a0,
+	0x0479, 0x00a0, 0x89ff, 0x090c, 0x0db2, 0x00c6, 0x00d6, 0x2d60,
+	0xa867, 0x0103, 0xa87b, 0x0003, 0x080c, 0x6351, 0x080c, 0xb7dd,
+	0x080c, 0x9a06, 0x00de, 0x00ce, 0x080c, 0x99d6, 0x009e, 0x0005,
+	0x9186, 0x0015, 0x1128, 0x2001, 0x1957, 0x2004, 0x6842, 0x0068,
+	0x918e, 0x0016, 0x1160, 0x00c6, 0x2d00, 0x2060, 0x080c, 0xd240,
+	0x080c, 0x7e13, 0x080c, 0x99d6, 0x00ce, 0x080c, 0x99d6, 0x0005,
+	0x0026, 0x0036, 0x0046, 0x7228, 0xacb0, 0xabac, 0xd2f4, 0x0130,
+	0x2001, 0x1957, 0x2004, 0x6842, 0x0804, 0xa064, 0x00c6, 0x2d60,
+	0x080c, 0xb244, 0x00ce, 0x6804, 0x9086, 0x0050, 0x1170, 0x00c6,
+	0x2d00, 0x2060, 0x6003, 0x0001, 0x6007, 0x0050, 0x080c, 0x8000,
+	0x080c, 0x8582, 0x00ce, 0x0804, 0xa064, 0x6800, 0x9086, 0x000f,
+	0x01b0, 0x89ff, 0x090c, 0x0db2, 0x6800, 0x9086, 0x0004, 0x1198,
+	0xa87c, 0xd0ac, 0x0180, 0xa843, 0x0fff, 0xa83f, 0x0fff, 0xa880,
+	0xc0f4, 0xc0fc, 0xa882, 0x2001, 0x0001, 0x6832, 0x0400, 0x2001,
+	0x0007, 0x6832, 0x00e0, 0xa87c, 0xd0b4, 0x1150, 0xd0ac, 0x0db8,
+	0x6824, 0xd0f4, 0x1d40, 0xa838, 0xa934, 0x9105, 0x0d80, 0x0c18,
+	0xd2ec, 0x1d68, 0x7024, 0x9306, 0x1118, 0x7020, 0x9406, 0x0d38,
+	0x7020, 0x683e, 0x7024, 0x683a, 0x2001, 0x0005, 0x6832, 0x080c,
+	0xb960, 0x080c, 0x8582, 0x0010, 0x080c, 0x99d6, 0x004e, 0x003e,
+	0x002e, 0x0005, 0x00e6, 0x00d6, 0x0026, 0x7008, 0x9084, 0x00ff,
+	0x6210, 0x00b6, 0x2258, 0xba10, 0x00be, 0x9206, 0x1904, 0xa0cf,
+	0x700c, 0x6210, 0x00b6, 0x2258, 0xba14, 0x00be, 0x9206, 0x1904,
+	0xa0cf, 0x6038, 0x2068, 0x6824, 0xc0dc, 0x6826, 0x6a20, 0x9286,
+	0x0007, 0x0904, 0xa0cf, 0x9286, 0x0002, 0x0904, 0xa0cf, 0x9286,
+	0x0000, 0x05e8, 0x6808, 0x633c, 0x9306, 0x15c8, 0x2071, 0x026c,
+	0x9186, 0x0015, 0x0570, 0x918e, 0x0016, 0x1100, 0x00c6, 0x6038,
+	0x2060, 0x6104, 0x9186, 0x004b, 0x01c0, 0x9186, 0x004c, 0x01a8,
+	0x9186, 0x004d, 0x0190, 0x9186, 0x004e, 0x0178, 0x9186, 0x0052,
+	0x0160, 0x6014, 0x0096, 0x2048, 0x080c, 0xb5fb, 0x090c, 0x0db2,
+	0xa883, 0x0003, 0x009e, 0x080c, 0xbca8, 0x6007, 0x0085, 0x6003,
+	0x000b, 0x6023, 0x0002, 0x080c, 0x8000, 0x080c, 0x8582, 0x00ce,
+	0x0030, 0x6038, 0x2070, 0x2001, 0x1957, 0x2004, 0x7042, 0x080c,
+	0x99d6, 0x002e, 0x00de, 0x00ee, 0x0005, 0x00b6, 0x0096, 0x00f6,
+	0x6014, 0x2048, 0x6010, 0x2058, 0x91b6, 0x0015, 0x0130, 0xba08,
+	0xbb0c, 0xbc00, 0xc48c, 0xbc02, 0x0460, 0x0096, 0x0156, 0x0036,
+	0x0026, 0x2b48, 0x9e90, 0x0010, 0x2019, 0x000a, 0x20a9, 0x0004,
+	0x080c, 0xa91d, 0x002e, 0x003e, 0x015e, 0x009e, 0x1904, 0xa13e,
+	0x0096, 0x0156, 0x0036, 0x0026, 0x2b48, 0x9e90, 0x0014, 0x2019,
+	0x0006, 0x20a9, 0x0004, 0x080c, 0xa91d, 0x002e, 0x003e, 0x015e,
+	0x009e, 0x15a0, 0x7238, 0xba0a, 0x733c, 0xbb0e, 0xbc00, 0xc48d,
+	0xbc02, 0xa804, 0x9005, 0x1128, 0x00fe, 0x009e, 0x00be, 0x0804,
+	0x9dd7, 0x0096, 0x2048, 0xaa12, 0xab16, 0xac0a, 0x009e, 0x8006,
+	0x8006, 0x8007, 0x90bc, 0x003f, 0x9084, 0xffc0, 0x9080, 0x0002,
+	0x2009, 0x002b, 0xaaa0, 0xab9c, 0xaca8, 0xada4, 0x2031, 0x0000,
+	0x2041, 0x120c, 0x080c, 0x9ed6, 0x0130, 0x00fe, 0x009e, 0x080c,
+	0x99d6, 0x00be, 0x0005, 0x080c, 0xa364, 0x0cb8, 0x2b78, 0x00f6,
+	0x080c, 0x2e30, 0x080c, 0xbd01, 0x00fe, 0x00c6, 0x080c, 0x9980,
+	0x2f00, 0x6012, 0x6017, 0x0000, 0x6023, 0x0001, 0x6007, 0x0001,
+	0x6003, 0x0001, 0x2001, 0x0007, 0x080c, 0x5ecf, 0x080c, 0x5efb,
+	0x080c, 0x8048, 0x080c, 0x8582, 0x00ce, 0x0804, 0xa111, 0x2100,
+	0x91b2, 0x0053, 0x1a0c, 0x0db2, 0x91b2, 0x0040, 0x1a04, 0xa1c7,
+	0x0002, 0xa1b5, 0xa1b5, 0xa1ab, 0xa1b5, 0xa1b5, 0xa1b5, 0xa1a9,
+	0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9,
+	0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9,
+	0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9,
+	0xa1b5, 0xa1a9, 0xa1b5, 0xa1b5, 0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9,
+	0xa1a9, 0xa1ab, 0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9,
+	0xa1a9, 0xa1a9, 0xa1a9, 0xa1b5, 0xa1b5, 0xa1a9, 0xa1a9, 0xa1a9,
+	0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9, 0xa1a9, 0xa1b5, 0xa1a9,
+	0xa1a9, 0x080c, 0x0db2, 0x0066, 0x00b6, 0x6610, 0x2658, 0xb8bc,
+	0xc08c, 0xb8be, 0x00be, 0x006e, 0x0000, 0x6003, 0x0001, 0x6106,
+	0x9186, 0x0032, 0x0118, 0x080c, 0x8048, 0x0010, 0x080c, 0x8000,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x8582, 0x012e, 0x0005, 0x2600,
+	0x0002, 0xa1db, 0xa1db, 0xa1db, 0xa1b5, 0xa1b5, 0xa1db, 0xa1db,
+	0xa1db, 0xa1db, 0xa1b5, 0xa1db, 0xa1b5, 0xa1db, 0xa1b5, 0xa1db,
+	0xa1db, 0xa1db, 0xa1db, 0x080c, 0x0db2, 0x6004, 0x90b2, 0x0053,
+	0x1a0c, 0x0db2, 0x91b6, 0x0013, 0x0904, 0xa29f, 0x91b6, 0x0027,
+	0x1904, 0xa25a, 0x080c, 0x847d, 0x6004, 0x080c, 0xb7e9, 0x01b0,
+	0x080c, 0xb7fa, 0x01a8, 0x908e, 0x0021, 0x0904, 0xa257, 0x908e,
+	0x0022, 0x1130, 0x080c, 0x9e03, 0x0904, 0xa253, 0x0804, 0xa254,
+	0x908e, 0x003d, 0x0904, 0xa257, 0x0804, 0xa24d, 0x080c, 0x2e55,
+	0x2001, 0x0007, 0x080c, 0x5ecf, 0x6010, 0x00b6, 0x2058, 0xb9a0,
+	0x00be, 0x080c, 0xa364, 0x9186, 0x007e, 0x1148, 0x2001, 0x1835,
+	0x2014, 0xc285, 0x080c, 0x6c53, 0x1108, 0xc2ad, 0x2202, 0x0036,
+	0x0026, 0x2019, 0x0028, 0x2110, 0x080c, 0xd29b, 0x002e, 0x003e,
+	0x0016, 0x0026, 0x0036, 0x2110, 0x2019, 0x0028, 0x080c, 0x8180,
+	0x0076, 0x903e, 0x080c, 0x8078, 0x6010, 0x00b6, 0x905d, 0x0100,
+	0x00be, 0x2c08, 0x080c, 0xcd62, 0x007e, 0x003e, 0x002e, 0x001e,
+	0x080c, 0xbd01, 0x0016, 0x080c, 0xba61, 0x080c, 0x99d6, 0x001e,
+	0x080c, 0x2f28, 0x080c, 0x8582, 0x0030, 0x080c, 0xba61, 0x080c,
+	0x99d6, 0x080c, 0x8582, 0x0005, 0x080c, 0xa364, 0x0cb0, 0x080c,
+	0xa3a0, 0x0c98, 0x9186, 0x0014, 0x1db0, 0x080c, 0x847d, 0x6004,
+	0x908e, 0x0022, 0x1118, 0x080c, 0x9e03, 0x0d68, 0x080c, 0x2e30,
+	0x080c, 0xbd01, 0x080c, 0xb7e9, 0x1190, 0x080c, 0x2e55, 0x6010,
+	0x00b6, 0x2058, 0xb9a0, 0x00be, 0x080c, 0xa364, 0x9186, 0x007e,
+	0x1128, 0x2001, 0x1835, 0x200c, 0xc185, 0x2102, 0x0870, 0x080c,
+	0xb7fa, 0x1118, 0x080c, 0xa364, 0x0840, 0x6004, 0x908e, 0x0032,
+	0x1160, 0x00e6, 0x00f6, 0x2071, 0x1894, 0x2079, 0x0000, 0x080c,
+	0x31c3, 0x00fe, 0x00ee, 0x0804, 0xa24d, 0x6004, 0x908e, 0x0021,
+	0x0d48, 0x908e, 0x0022, 0x090c, 0xa364, 0x0804, 0xa24d, 0x90b2,
+	0x0040, 0x1a04, 0xa34d, 0x2008, 0x0002, 0xa2e7, 0xa2e8, 0xa2eb,
+	0xa2ee, 0xa2f1, 0xa2f4, 0xa2e5, 0xa2e5, 0xa2e5, 0xa2e5, 0xa2e5,
+	0xa2e5, 0xa2e5, 0xa2e5, 0xa2e5, 0xa2e5, 0xa2e5, 0xa2e5, 0xa2e5,
+	0xa2e5, 0xa2e5, 0xa2e5, 0xa2e5, 0xa2e5, 0xa2e5, 0xa2e5, 0xa2e5,
+	0xa2e5, 0xa2e5, 0xa2e5, 0xa2f7, 0xa302, 0xa2e5, 0xa304, 0xa302,
+	0xa2e5, 0xa2e5, 0xa2e5, 0xa2e5, 0xa2e5, 0xa302, 0xa302, 0xa2e5,
+	0xa2e5, 0xa2e5, 0xa2e5, 0xa2e5, 0xa2e5, 0xa2e5, 0xa2e5, 0xa334,
+	0xa302, 0xa2e5, 0xa2fe, 0xa2e5, 0xa2e5, 0xa2e5, 0xa2ff, 0xa2e5,
+	0xa2e5, 0xa2e5, 0xa302, 0xa32b, 0xa2e5, 0x080c, 0x0db2, 0x00d0,
+	0x2001, 0x000b, 0x0410, 0x2001, 0x0003, 0x00f8, 0x2001, 0x0005,
+	0x00e0, 0x2001, 0x0001, 0x00c8, 0x2001, 0x0009, 0x00b0, 0x080c,
+	0x847d, 0x6003, 0x0005, 0x080c, 0x8582, 0x0070, 0x0018, 0x0010,
+	0x080c, 0x5ecf, 0x0804, 0xa345, 0x080c, 0x847d, 0x080c, 0xbd04,
+	0x6003, 0x0004, 0x080c, 0x8582, 0x0005, 0x080c, 0x5ecf, 0x080c,
+	0x847d, 0x6003, 0x0002, 0x0036, 0x2019, 0x185e, 0x2304, 0x9084,
+	0xff00, 0x1120, 0x2001, 0x1955, 0x201c, 0x0040, 0x8007, 0x909a,
+	0x0004, 0x0ec0, 0x8003, 0x801b, 0x831b, 0x9318, 0x631a, 0x003e,
+	0x080c, 0x8582, 0x0c08, 0x080c, 0x847d, 0x080c, 0xba61, 0x080c,
+	0x99d6, 0x080c, 0x8582, 0x08c0, 0x00e6, 0x00f6, 0x2071, 0x1894,
+	0x2079, 0x0000, 0x080c, 0x31c3, 0x00fe, 0x00ee, 0x080c, 0x847d,
+	0x080c, 0x99d6, 0x080c, 0x8582, 0x0838, 0x080c, 0x847d, 0x6003,
+	0x0002, 0x080c, 0xbd04, 0x0804, 0x8582, 0x2600, 0x2008, 0x0002,
+	0xa362, 0xa362, 0xa362, 0xa345, 0xa345, 0xa362, 0xa362, 0xa362,
+	0xa362, 0xa345, 0xa362, 0xa345, 0xa362, 0xa345, 0xa362, 0xa362,
+	0xa362, 0xa362, 0x080c, 0x0db2, 0x00e6, 0x0096, 0x0026, 0x0016,
+	0x080c, 0xb5fb, 0x0568, 0x6014, 0x2048, 0xa864, 0x9086, 0x0139,
+	0x11a8, 0xa894, 0x9086, 0x0056, 0x1148, 0x080c, 0x4ebc, 0x0130,
+	0x2001, 0x0000, 0x900e, 0x2011, 0x4000, 0x0028, 0x2001, 0x0030,
+	0x900e, 0x2011, 0x4005, 0x080c, 0xbbcd, 0x0090, 0xa868, 0xd0fc,
+	0x0178, 0xa807, 0x0000, 0x0016, 0x6004, 0x908e, 0x0021, 0x0168,
+	0x908e, 0x003d, 0x0150, 0x001e, 0xa867, 0x0103, 0xa833, 0x0100,
+	0x001e, 0x002e, 0x009e, 0x00ee, 0x0005, 0x001e, 0x0009, 0x0cc0,
+	0x0096, 0x6014, 0x2048, 0xa800, 0x2048, 0xa867, 0x0103, 0xa823,
+	0x8001, 0x009e, 0x0005, 0x00b6, 0x6610, 0x2658, 0xb804, 0x9084,
+	0x00ff, 0x90b2, 0x000c, 0x1a0c, 0x0db2, 0x6604, 0x96b6, 0x004d,
+	0x1120, 0x080c, 0xbaed, 0x0804, 0xa428, 0x6604, 0x96b6, 0x0043,
+	0x1120, 0x080c, 0xbb36, 0x0804, 0xa428, 0x6604, 0x96b6, 0x004b,
+	0x1120, 0x080c, 0xbb62, 0x0804, 0xa428, 0x6604, 0x96b6, 0x0033,
+	0x1120, 0x080c, 0xba83, 0x0804, 0xa428, 0x6604, 0x96b6, 0x0028,
+	0x1120, 0x080c, 0xb833, 0x0804, 0xa428, 0x6604, 0x96b6, 0x0029,
+	0x1120, 0x080c, 0xb874, 0x0804, 0xa428, 0x6604, 0x96b6, 0x001f,
+	0x1118, 0x080c, 0x9dac, 0x04e0, 0x6604, 0x96b6, 0x0000, 0x1118,
+	0x080c, 0xa0d5, 0x04a8, 0x6604, 0x96b6, 0x0022, 0x1118, 0x080c,
+	0x9de4, 0x0470, 0x6604, 0x96b6, 0x0035, 0x1118, 0x080c, 0x9ef4,
+	0x0438, 0x6604, 0x96b6, 0x0039, 0x1118, 0x080c, 0xa06a, 0x0400,
+	0x6604, 0x96b6, 0x003d, 0x1118, 0x080c, 0x9e1c, 0x00c8, 0x6604,
+	0x96b6, 0x0044, 0x1118, 0x080c, 0x9e58, 0x0090, 0x6604, 0x96b6,
+	0x0049, 0x1118, 0x080c, 0x9e83, 0x0058, 0x91b6, 0x0015, 0x1110,
+	0x0063, 0x0030, 0x91b6, 0x0016, 0x1128, 0x00be, 0x0804, 0xa65e,
+	0x00be, 0x0005, 0x080c, 0x9a6b, 0x0cd8, 0xa445, 0xa448, 0xa445,
+	0xa48d, 0xa445, 0xa5d7, 0xa66b, 0xa445, 0xa445, 0xa638, 0xa445,
+	0xa64c, 0x0096, 0x080c, 0x14c9, 0x6014, 0x2048, 0xa800, 0x2048,
+	0xa867, 0x0103, 0x009e, 0x0804, 0x99d6, 0xa001, 0xa001, 0x0005,
+	0x00e6, 0x2071, 0x1800, 0x7088, 0x9086, 0x0074, 0x1540, 0x080c,
+	0xcd33, 0x11b0, 0x6010, 0x00b6, 0x2058, 0x7030, 0xd08c, 0x0128,
+	0xb800, 0xd0bc, 0x0110, 0xc0c5, 0xb802, 0x00e9, 0x00be, 0x2001,
+	0x0006, 0x080c, 0x5ecf, 0x080c, 0x2e55, 0x080c, 0x99d6, 0x0088,
+	0x2001, 0x000a, 0x080c, 0x5ecf, 0x080c, 0x2e55, 0x6003, 0x0001,
+	0x6007, 0x0001, 0x080c, 0x8048, 0x080c, 0x8582, 0x0010, 0x080c,
+	0xa5c2, 0x00ee, 0x0005, 0x00d6, 0xb800, 0xd084, 0x0160, 0x9006,
+	0x080c, 0x5ebb, 0x2069, 0x1853, 0x6804, 0xd0a4, 0x0120, 0x2001,
+	0x0006, 0x080c, 0x5efb, 0x00de, 0x0005, 0x00b6, 0x0096, 0x00d6,
+	0x2011, 0x1822, 0x2204, 0x9086, 0x0074, 0x1904, 0xa59b, 0x6010,
+	0x2058, 0xbaa0, 0x9286, 0x007e, 0x1120, 0x080c, 0xa7af, 0x0804,
+	0xa4ff, 0x080c, 0xa7a4, 0x6010, 0x2058, 0xbaa0, 0x9286, 0x0080,
+	0x1510, 0x6014, 0x9005, 0x01a8, 0x2048, 0xa864, 0x9084, 0x00ff,
+	0x9086, 0x0039, 0x1140, 0x2001, 0x0000, 0x900e, 0x2011, 0x4000,
+	0x080c, 0xbbcd, 0x0030, 0xa807, 0x0000, 0xa867, 0x0103, 0xa833,
+	0x0200, 0x2001, 0x0006, 0x080c, 0x5ecf, 0x080c, 0x2e55, 0x080c,
+	0x99d6, 0x0804, 0xa59c, 0x080c, 0xa5aa, 0x6014, 0x9005, 0x0190,
+	0x2048, 0xa868, 0xd0f4, 0x01e8, 0xa864, 0x9084, 0x00ff, 0x9086,
+	0x0039, 0x1d08, 0x2001, 0x0000, 0x900e, 0x2011, 0x4000, 0x080c,
+	0xbbcd, 0x08f8, 0x080c, 0xa5a0, 0x0160, 0x9006, 0x080c, 0x5ebb,
+	0x2001, 0x0004, 0x080c, 0x5efb, 0x2001, 0x0007, 0x080c, 0x5ecf,
+	0x08a0, 0x2001, 0x0004, 0x080c, 0x5ecf, 0x6003, 0x0001, 0x6007,
+	0x0003, 0x080c, 0x8048, 0x080c, 0x8582, 0x0804, 0xa59c, 0xb85c,
+	0xd0e4, 0x01d8, 0x080c, 0xba03, 0x080c, 0x6c53, 0x0118, 0xd0dc,
+	0x1904, 0xa4c1, 0x2011, 0x1835, 0x2204, 0xc0ad, 0x2012, 0x2001,
+	0x193e, 0x2004, 0x00f6, 0x2079, 0x0100, 0x78e3, 0x0000, 0x080c,
+	0x254a, 0x78e2, 0x00fe, 0x0804, 0xa4c1, 0x080c, 0xba40, 0x2011,
+	0x1835, 0x2204, 0xc0a5, 0x2012, 0x0006, 0x080c, 0xce81, 0x000e,
+	0x1904, 0xa4c1, 0xc0b5, 0x2012, 0x2001, 0x0006, 0x080c, 0x5ecf,
+	0x9006, 0x080c, 0x5ebb, 0x00c6, 0x2001, 0x180e, 0x2004, 0xd09c,
+	0x0520, 0x00f6, 0x2079, 0x0100, 0x00e6, 0x2071, 0x1800, 0x700c,
+	0x9084, 0x00ff, 0x78e6, 0x7076, 0x7010, 0x78ea, 0x707a, 0x908c,
+	0x00ff, 0x00ee, 0x780c, 0xc0b5, 0x780e, 0x00fe, 0x080c, 0x251f,
+	0x00f6, 0x2100, 0x900e, 0x080c, 0x24d6, 0x7956, 0x00fe, 0x9186,
+	0x0081, 0x01d8, 0x2009, 0x0081, 0x00c8, 0x2009, 0x00ef, 0x00f6,
+	0x2079, 0x0100, 0x79ea, 0x7932, 0x7936, 0x780c, 0xc0b5, 0x780e,
+	0x00fe, 0x080c, 0x251f, 0x00f6, 0x2079, 0x1800, 0x797a, 0x2100,
+	0x900e, 0x080c, 0x24d6, 0x7956, 0x00fe, 0x8108, 0x080c, 0x5f1e,
+	0x2b00, 0x00ce, 0x1904, 0xa4c1, 0x6012, 0x2009, 0x180e, 0x210c,
+	0xd19c, 0x0150, 0x2009, 0x027c, 0x210c, 0x918c, 0x00ff, 0xb912,
+	0x2009, 0x027d, 0x210c, 0xb916, 0x2001, 0x0002, 0x080c, 0x5ecf,
+	0x6023, 0x0001, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x8048,
+	0x080c, 0x8582, 0x0008, 0x0431, 0x00de, 0x009e, 0x00be, 0x0005,
+	0x2001, 0x180f, 0x2004, 0xd0a4, 0x0120, 0x2001, 0x1854, 0x2004,
+	0xd0ac, 0x0005, 0x00e6, 0x080c, 0xd2f4, 0x0190, 0x2071, 0x0260,
+	0x7108, 0x720c, 0x918c, 0x00ff, 0x1118, 0x9284, 0xff00, 0x0140,
+	0x6010, 0x2058, 0xb8a0, 0x9084, 0xff80, 0x1110, 0xb912, 0xba16,
+	0x00ee, 0x0005, 0x2030, 0x2001, 0x0007, 0x080c, 0x5ecf, 0x080c,
+	0x5127, 0x1120, 0x2001, 0x0007, 0x080c, 0x5efb, 0x080c, 0x2e55,
+	0x6020, 0x9086, 0x000a, 0x1108, 0x0005, 0x0804, 0x99d6, 0x00b6,
+	0x00e6, 0x0026, 0x0016, 0x2071, 0x1800, 0x7088, 0x9086, 0x0014,
+	0x1904, 0xa62f, 0x080c, 0x5127, 0x1170, 0x6014, 0x9005, 0x1158,
+	0x0036, 0x0046, 0x6010, 0x2058, 0xbba0, 0x2021, 0x0006, 0x080c,
+	0x4829, 0x004e, 0x003e, 0x00d6, 0x6010, 0x2058, 0x080c, 0x6019,
+	0x080c, 0xa47b, 0x00de, 0x080c, 0xa875, 0x1588, 0x6010, 0x2058,
+	0xb890, 0x9005, 0x0560, 0x2001, 0x0006, 0x080c, 0x5ecf, 0x0096,
+	0x6014, 0x904d, 0x01d0, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0039,
+	0x1140, 0x2001, 0x0000, 0x900e, 0x2011, 0x4000, 0x080c, 0xbbcd,
+	0x0060, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0029, 0x0130, 0xa807,
+	0x0000, 0xa867, 0x0103, 0xa833, 0x0200, 0x009e, 0x080c, 0x2e55,
+	0x6020, 0x9086, 0x000a, 0x0138, 0x080c, 0x99d6, 0x0020, 0x080c,
+	0xa364, 0x080c, 0xa5c2, 0x001e, 0x002e, 0x00ee, 0x00be, 0x0005,
+	0x2011, 0x1822, 0x2204, 0x9086, 0x0014, 0x1160, 0x2001, 0x0002,
+	0x080c, 0x5ecf, 0x6003, 0x0001, 0x6007, 0x0001, 0x080c, 0x8048,
+	0x0804, 0x8582, 0x0804, 0xa5c2, 0x2030, 0x2011, 0x1822, 0x2204,
+	0x9086, 0x0004, 0x1148, 0x96b6, 0x000b, 0x1120, 0x2001, 0x0007,
+	0x080c, 0x5ecf, 0x0804, 0x99d6, 0x0804, 0xa5c2, 0x0002, 0xa445,
+	0xa676, 0xa445, 0xa6b5, 0xa445, 0xa760, 0xa66b, 0xa445, 0xa445,
+	0xa773, 0xa445, 0xa783, 0x6604, 0x9686, 0x0003, 0x0904, 0xa5d7,
+	0x96b6, 0x001e, 0x1110, 0x080c, 0x99d6, 0x0005, 0x00b6, 0x00d6,
+	0x00c6, 0x080c, 0xa793, 0x11a0, 0x9006, 0x080c, 0x5ebb, 0x080c,
+	0x2e30, 0x080c, 0xbd01, 0x2001, 0x0002, 0x080c, 0x5ecf, 0x6003,
+	0x0001, 0x6007, 0x0002, 0x080c, 0x8048, 0x080c, 0x8582, 0x0408,
+	0x2009, 0x026e, 0x2104, 0x9086, 0x0009, 0x1160, 0x6010, 0x2058,
+	0xb840, 0x9084, 0x00ff, 0x9005, 0x0170, 0x8001, 0xb842, 0x601b,
+	0x000a, 0x0078, 0x2009, 0x026f, 0x2104, 0x9084, 0xff00, 0x9086,
+	0x1900, 0x1108, 0x08a0, 0x080c, 0x2e30, 0x080c, 0xbd01, 0x080c,
+	0xa5c2, 0x00ce, 0x00de, 0x00be, 0x0005, 0x0096, 0x00b6, 0x0026,
+	0x9016, 0x080c, 0xa7a1, 0x00d6, 0x2069, 0x194d, 0x2d04, 0x9005,
+	0x0168, 0x6010, 0x2058, 0xb8a0, 0x9086, 0x007e, 0x1138, 0x2069,
+	0x181e, 0x2d04, 0x8000, 0x206a, 0x00de, 0x0010, 0x00de, 0x0088,
+	0x9006, 0x080c, 0x5ebb, 0x2001, 0x0002, 0x080c, 0x5ecf, 0x6003,
+	0x0001, 0x6007, 0x0002, 0x080c, 0x8048, 0x080c, 0x8582, 0x0804,
+	0xa730, 0x080c, 0xb5fb, 0x01b0, 0x6014, 0x2048, 0xa864, 0x2010,
+	0x9086, 0x0139, 0x1138, 0x6007, 0x0016, 0x2001, 0x0002, 0x080c,
+	0xbc27, 0x00b0, 0x6014, 0x2048, 0xa864, 0xd0fc, 0x0118, 0x2001,
+	0x0001, 0x0ca8, 0x2001, 0x180d, 0x2004, 0xd0dc, 0x0148, 0x6010,
+	0x2058, 0xb840, 0x9084, 0x00ff, 0x9005, 0x1110, 0x9006, 0x0c38,
+	0x080c, 0xa364, 0x2009, 0x026e, 0x2134, 0x96b4, 0x00ff, 0x9686,
+	0x0005, 0x0510, 0x9686, 0x000b, 0x01c8, 0x2009, 0x026f, 0x2104,
+	0x9084, 0xff00, 0x1118, 0x9686, 0x0009, 0x01b0, 0x9086, 0x1900,
+	0x1168, 0x9686, 0x0009, 0x0180, 0x2001, 0x0004, 0x080c, 0x5ecf,
+	0x2001, 0x0028, 0x601a, 0x6007, 0x0052, 0x0010, 0x080c, 0xa5c2,
+	0x002e, 0x00be, 0x009e, 0x0005, 0x9286, 0x0139, 0x0160, 0x6014,
+	0x2048, 0x080c, 0xb5fb, 0x0140, 0xa864, 0x9086, 0x0139, 0x0118,
+	0xa868, 0xd0fc, 0x0108, 0x0c50, 0x6010, 0x2058, 0xb840, 0x9084,
+	0x00ff, 0x9005, 0x0138, 0x8001, 0xb842, 0x601b, 0x000a, 0x6007,
+	0x0016, 0x08f0, 0xb8a0, 0x9086, 0x007e, 0x1138, 0x00e6, 0x2071,
+	0x1800, 0x080c, 0x59b4, 0x00ee, 0x0010, 0x080c, 0x2e30, 0x0870,
+	0x080c, 0xa7a1, 0x1160, 0x2001, 0x0004, 0x080c, 0x5ecf, 0x6003,
+	0x0001, 0x6007, 0x0003, 0x080c, 0x8048, 0x0804, 0x8582, 0x080c,
+	0xa364, 0x0804, 0xa5c2, 0x0469, 0x1160, 0x2001, 0x0008, 0x080c,
+	0x5ecf, 0x6003, 0x0001, 0x6007, 0x0005, 0x080c, 0x8048, 0x0804,
+	0x8582, 0x0804, 0xa5c2, 0x00e9, 0x1160, 0x2001, 0x000a, 0x080c,
+	0x5ecf, 0x6003, 0x0001, 0x6007, 0x0001, 0x080c, 0x8048, 0x0804,
+	0x8582, 0x0804, 0xa5c2, 0x2009, 0x026e, 0x2104, 0x9086, 0x0003,
+	0x1138, 0x2009, 0x026f, 0x2104, 0x9084, 0xff00, 0x9086, 0x2a00,
+	0x0005, 0x9085, 0x0001, 0x0005, 0x00b6, 0x00c6, 0x0016, 0x6110,
+	0x2158, 0x080c, 0x5f8d, 0x001e, 0x00ce, 0x00be, 0x0005, 0x00b6,
+	0x00f6, 0x00e6, 0x00d6, 0x0036, 0x0016, 0x6010, 0x2058, 0x2009,
+	0x1835, 0x2104, 0x9085, 0x0003, 0x200a, 0x080c, 0xa847, 0x0560,
+	0x2009, 0x1835, 0x2104, 0xc0cd, 0x200a, 0x080c, 0x62a0, 0x0158,
+	0x9006, 0x2020, 0x2009, 0x002a, 0x080c, 0xcfe6, 0x2001, 0x180c,
+	0x200c, 0xc195, 0x2102, 0x2019, 0x002a, 0x2009, 0x0001, 0x080c,
+	0x2dfb, 0x00e6, 0x2071, 0x1800, 0x080c, 0x2c2b, 0x00ee, 0x00c6,
+	0x0156, 0x20a9, 0x0781, 0x2009, 0x007f, 0x080c, 0x2f28, 0x8108,
+	0x1f04, 0xa7e5, 0x015e, 0x00ce, 0x080c, 0xa7a4, 0x2071, 0x0260,
+	0x2079, 0x0200, 0x7817, 0x0001, 0x2001, 0x1835, 0x200c, 0xc1c5,
+	0x7018, 0xd0fc, 0x0110, 0xd0dc, 0x0118, 0x7038, 0xd0dc, 0x1108,
+	0xc1c4, 0x7817, 0x0000, 0x2001, 0x1835, 0x2102, 0x2079, 0x0100,
+	0x2e04, 0x9084, 0x00ff, 0x2069, 0x181d, 0x206a, 0x78e6, 0x0006,
+	0x8e70, 0x2e04, 0x2069, 0x181e, 0x206a, 0x78ea, 0x7832, 0x7836,
+	0x2010, 0x9084, 0xff00, 0x001e, 0x9105, 0x2009, 0x182a, 0x200a,
+	0x2200, 0x9084, 0x00ff, 0x2008, 0x080c, 0x251f, 0x080c, 0x6c53,
+	0x0170, 0x2071, 0x0260, 0x2069, 0x1951, 0x7048, 0x206a, 0x704c,
+	0x6806, 0x7050, 0x680a, 0x7054, 0x680e, 0x080c, 0xba03, 0x0040,
+	0x2001, 0x0006, 0x080c, 0x5ecf, 0x080c, 0x2e55, 0x080c, 0x99d6,
+	0x001e, 0x003e, 0x00de, 0x00ee, 0x00fe, 0x00be, 0x0005, 0x0096,
+	0x0026, 0x0036, 0x00e6, 0x0156, 0x2019, 0x182a, 0x231c, 0x83ff,
+	0x01f0, 0x2071, 0x0260, 0x7200, 0x9294, 0x00ff, 0x7004, 0x9084,
+	0xff00, 0x9205, 0x9306, 0x1198, 0x2011, 0x0276, 0x20a9, 0x0004,
+	0x2b48, 0x2019, 0x000a, 0x080c, 0xa91d, 0x1148, 0x2011, 0x027a,
+	0x20a9, 0x0004, 0x2019, 0x0006, 0x080c, 0xa91d, 0x1100, 0x015e,
+	0x00ee, 0x003e, 0x002e, 0x009e, 0x0005, 0x00e6, 0x2071, 0x0260,
+	0x7034, 0x9086, 0x0014, 0x11a8, 0x7038, 0x9086, 0x0800, 0x1188,
+	0x703c, 0xd0ec, 0x0160, 0x9084, 0x0f00, 0x9086, 0x0100, 0x1138,
+	0x7054, 0xd0a4, 0x1110, 0xd0ac, 0x0110, 0x9006, 0x0010, 0x9085,
+	0x0001, 0x00ee, 0x0005, 0x00e6, 0x0096, 0x00c6, 0x0076, 0x0056,
+	0x0046, 0x0026, 0x0006, 0x0126, 0x2091, 0x8000, 0x2029, 0x19bf,
+	0x252c, 0x2021, 0x19c5, 0x2424, 0x2061, 0x1cd0, 0x2071, 0x1800,
+	0x724c, 0x706c, 0x9202, 0x1a04, 0xa8f5, 0x080c, 0xd012, 0x05f0,
+	0x6720, 0x9786, 0x0007, 0x05d0, 0x2500, 0x9c06, 0x05b8, 0x2400,
+	0x9c06, 0x05a0, 0x3e08, 0x9186, 0x0002, 0x1148, 0x6010, 0x9005,
+	0x0130, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x1538, 0x00c6,
+	0x6000, 0x9086, 0x0004, 0x1110, 0x080c, 0x1827, 0x9786, 0x000a,
+	0x0148, 0x080c, 0xb7fa, 0x1130, 0x00ce, 0x080c, 0xa364, 0x080c,
+	0x9a06, 0x00a0, 0x6014, 0x2048, 0x080c, 0xb5fb, 0x0160, 0x9786,
+	0x0003, 0x11e8, 0xa867, 0x0103, 0xab7a, 0xa877, 0x0000, 0x080c,
+	0x6529, 0x080c, 0xb7dd, 0x080c, 0x9a06, 0x00ce, 0x9ce0, 0x0018,
+	0x7060, 0x9c02, 0x1210, 0x0804, 0xa8a8, 0x012e, 0x000e, 0x002e,
+	0x004e, 0x005e, 0x007e, 0x00ce, 0x009e, 0x00ee, 0x0005, 0x9786,
+	0x0006, 0x1118, 0x080c, 0xcf91, 0x0c30, 0x9786, 0x000a, 0x09e0,
+	0x08c8, 0x220c, 0x2304, 0x9106, 0x1130, 0x8210, 0x8318, 0x1f04,
+	0xa909, 0x9006, 0x0005, 0x2304, 0x9102, 0x0218, 0x2001, 0x0001,
+	0x0008, 0x9006, 0x918d, 0x0001, 0x0005, 0x0136, 0x01c6, 0x0016,
+	0x8906, 0x8006, 0x8007, 0x908c, 0x003f, 0x21e0, 0x9084, 0xffc0,
+	0x9300, 0x2098, 0x3518, 0x20a9, 0x0001, 0x220c, 0x4002, 0x910e,
+	0x1140, 0x8210, 0x8319, 0x1dc8, 0x9006, 0x001e, 0x01ce, 0x013e,
+	0x0005, 0x220c, 0x9102, 0x0218, 0x2001, 0x0001, 0x0010, 0x2001,
+	0x0000, 0x918d, 0x0001, 0x001e, 0x01ce, 0x013e, 0x0005, 0x6004,
+	0x908a, 0x0053, 0x1a0c, 0x0db2, 0x080c, 0xb7e9, 0x0120, 0x080c,
+	0xb7fa, 0x0168, 0x0028, 0x080c, 0x2e55, 0x080c, 0xb7fa, 0x0138,
+	0x080c, 0x847d, 0x080c, 0x99d6, 0x080c, 0x8582, 0x0005, 0x080c,
+	0xa364, 0x0cb0, 0x9182, 0x0054, 0x1220, 0x9182, 0x0040, 0x0208,
+	0x000a, 0x0005, 0xa97e, 0xa97e, 0xa97e, 0xa97e, 0xa97e, 0xa97e,
+	0xa97e, 0xa97e, 0xa97e, 0xa97e, 0xa97e, 0xa980, 0xa980, 0xa980,
+	0xa980, 0xa97e, 0xa97e, 0xa97e, 0xa980, 0xa97e, 0x080c, 0x0db2,
+	0x600b, 0xffff, 0x6003, 0x0001, 0x6106, 0x080c, 0x8000, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x8582, 0x012e, 0x0005, 0x9186, 0x0013,
+	0x1128, 0x6004, 0x9082, 0x0040, 0x0804, 0xaa35, 0x9186, 0x0027,
+	0x1520, 0x080c, 0x847d, 0x080c, 0x2e30, 0x080c, 0xbd01, 0x0096,
+	0x6114, 0x2148, 0x080c, 0xb5fb, 0x0198, 0x080c, 0xb7fa, 0x1118,
+	0x080c, 0xa364, 0x0068, 0xa867, 0x0103, 0xa87b, 0x0029, 0xa877,
+	0x0000, 0xa97c, 0xc1c5, 0xa97e, 0x080c, 0x6536, 0x080c, 0xb7dd,
+	0x009e, 0x080c, 0x99d6, 0x0804, 0x8582, 0x9186, 0x0014, 0x1120,
+	0x6004, 0x9082, 0x0040, 0x04a0, 0x9186, 0x0046, 0x0150, 0x9186,
+	0x0045, 0x0138, 0x9186, 0x0053, 0x0120, 0x9186, 0x0048, 0x190c,
+	0x0db2, 0x2001, 0x0109, 0x2004, 0xd084, 0x0508, 0x0126, 0x2091,
+	0x2800, 0x0006, 0x0016, 0x0026, 0x0036, 0x00f6, 0x00e6, 0x00c6,
+	0x2079, 0x19b6, 0x2071, 0x1800, 0x2061, 0x0100, 0x080c, 0x7eec,
+	0x00ce, 0x00ee, 0x00fe, 0x003e, 0x002e, 0x001e, 0x000e, 0x012e,
+	0xa001, 0x6000, 0x9086, 0x0002, 0x1110, 0x0804, 0xaa73, 0x0005,
+	0x0002, 0xaa0f, 0xaa0d, 0xaa0d, 0xaa0d, 0xaa0d, 0xaa0d, 0xaa0d,
+	0xaa0d, 0xaa0d, 0xaa0d, 0xaa0d, 0xaa2a, 0xaa2a, 0xaa2a, 0xaa2a,
+	0xaa0d, 0xaa2a, 0xaa0d, 0xaa2a, 0xaa0d, 0x080c, 0x0db2, 0x080c,
+	0x847d, 0x0096, 0x6114, 0x2148, 0x080c, 0xb5fb, 0x0168, 0xa867,
+	0x0103, 0xa87b, 0x0006, 0xa877, 0x0000, 0xa880, 0xc0ec, 0xa882,
+	0x080c, 0x6536, 0x080c, 0xb7dd, 0x009e, 0x080c, 0x99d6, 0x080c,
+	0x8582, 0x0005, 0x080c, 0x847d, 0x080c, 0xb7fa, 0x090c, 0xa364,
+	0x080c, 0x99d6, 0x080c, 0x8582, 0x0005, 0x0002, 0xaa4c, 0xaa4a,
+	0xaa4a, 0xaa4a, 0xaa4a, 0xaa4a, 0xaa4a, 0xaa4a, 0xaa4a, 0xaa4a,
+	0xaa4a, 0xaa63, 0xaa63, 0xaa63, 0xaa63, 0xaa4a, 0xaa6d, 0xaa4a,
+	0xaa63, 0xaa4a, 0x080c, 0x0db2, 0x0096, 0x080c, 0x847d, 0x6014,
+	0x2048, 0x2001, 0x1957, 0x2004, 0x6042, 0xa97c, 0xd1ac, 0x0140,
+	0x6003, 0x0004, 0xa87c, 0x9085, 0x0400, 0xa87e, 0x009e, 0x0005,
+	0x6003, 0x0002, 0x0cb8, 0x080c, 0x847d, 0x080c, 0xbd04, 0x080c,
+	0xbd09, 0x6003, 0x000f, 0x0804, 0x8582, 0x080c, 0x847d, 0x080c,
+	0x99d6, 0x0804, 0x8582, 0x9182, 0x0054, 0x1220, 0x9182, 0x0040,
+	0x0208, 0x000a, 0x0005, 0xaa8f, 0xaa8f, 0xaa8f, 0xaa8f, 0xaa8f,
+	0xaa91, 0xab6e, 0xaa8f, 0xaba2, 0xaa8f, 0xaa8f, 0xaa8f, 0xaa8f,
+	0xaa8f, 0xaa8f, 0xaa8f, 0xaa8f, 0xaa8f, 0xaa8f, 0xaba2, 0x080c,
+	0x0db2, 0x00b6, 0x0096, 0x6114, 0x2148, 0x7644, 0x96b4, 0x0fff,
+	0x86ff, 0x1528, 0x6010, 0x2058, 0xb800, 0xd0bc, 0x1904, 0xab5d,
+	0xa87b, 0x0000, 0xa867, 0x0103, 0xae76, 0xa87c, 0xd0ac, 0x0128,
+	0xa834, 0xa938, 0x9115, 0x190c, 0xad37, 0x080c, 0x6351, 0x6210,
+	0x2258, 0xba3c, 0x82ff, 0x0110, 0x8211, 0xba3e, 0x7044, 0xd0e4,
+	0x1904, 0xab41, 0x080c, 0x99d6, 0x009e, 0x00be, 0x0005, 0x968c,
+	0x0c00, 0x0150, 0x6010, 0x2058, 0xb800, 0xd0bc, 0x1904, 0xab45,
+	0x7348, 0xab92, 0x734c, 0xab8e, 0x968c, 0x00ff, 0x9186, 0x0002,
+	0x0508, 0x9186, 0x0028, 0x1118, 0xa87b, 0x001c, 0x00e8, 0xd6dc,
+	0x01a0, 0xa87b, 0x0015, 0xa87c, 0xd0ac, 0x0170, 0xa938, 0xaa34,
+	0x2100, 0x9205, 0x0148, 0x7048, 0x9106, 0x1118, 0x704c, 0x9206,
+	0x0118, 0xa992, 0xaa8e, 0xc6dc, 0x0038, 0xd6d4, 0x0118, 0xa87b,
+	0x0007, 0x0010, 0xa87b, 0x0000, 0xa867, 0x0103, 0xae76, 0x901e,
+	0xd6c4, 0x01d8, 0x9686, 0x0100, 0x1130, 0x7064, 0x9005, 0x1118,
+	0xc6c4, 0x0804, 0xaa98, 0x735c, 0xab86, 0x83ff, 0x0170, 0x938a,
+	0x0009, 0x0210, 0x2019, 0x0008, 0x0036, 0x2308, 0x2019, 0x0018,
+	0x2011, 0x0025, 0x080c, 0xb219, 0x003e, 0xd6cc, 0x0904, 0xaaad,
+	0x7154, 0xa98a, 0x81ff, 0x0904, 0xaaad, 0x9192, 0x0021, 0x1278,
+	0x8304, 0x9098, 0x0018, 0x2011, 0x0029, 0x080c, 0xb219, 0x2011,
+	0x0205, 0x2013, 0x0000, 0x080c, 0xbc93, 0x0804, 0xaaad, 0xa868,
+	0xd0fc, 0x0120, 0x2009, 0x0020, 0xa98a, 0x0c50, 0x00a6, 0x2950,
+	0x080c, 0xb1b8, 0x00ae, 0x080c, 0xbc93, 0x080c, 0xb209, 0x0804,
+	0xaaaf, 0x080c, 0xb8ed, 0x0804, 0xaabc, 0xa87c, 0xd0ac, 0x0904,
+	0xaac8, 0xa880, 0xd0bc, 0x1904, 0xaac8, 0x7348, 0xa838, 0x9306,
+	0x11c8, 0x734c, 0xa834, 0x931e, 0x0904, 0xaac8, 0xd6d4, 0x0190,
+	0xab38, 0x9305, 0x0904, 0xaac8, 0x0068, 0xa87c, 0xd0ac, 0x0904,
+	0xaaa0, 0xa838, 0xa934, 0x9105, 0x0904, 0xaaa0, 0xa880, 0xd0bc,
+	0x1904, 0xaaa0, 0x080c, 0xb927, 0x0804, 0xaabc, 0x0096, 0x00f6,
+	0x6003, 0x0003, 0x6007, 0x0043, 0x2079, 0x026c, 0x7c04, 0x7b00,
+	0x7e0c, 0x7d08, 0x6014, 0x2048, 0xa87c, 0xd0ac, 0x0140, 0x6003,
+	0x0002, 0x00fe, 0x009e, 0x0005, 0x2130, 0x2228, 0x0058, 0x2400,
+	0xa9ac, 0x910a, 0x2300, 0xaab0, 0x9213, 0x2600, 0x9102, 0x2500,
+	0x9203, 0x0e90, 0xac36, 0xab3a, 0xae46, 0xad4a, 0x00fe, 0x6043,
+	0x0000, 0x2c10, 0x080c, 0x1976, 0x080c, 0x8065, 0x080c, 0x865d,
+	0x009e, 0x0005, 0x0005, 0x9182, 0x0054, 0x1220, 0x9182, 0x0040,
+	0x0208, 0x000a, 0x0005, 0xabbf, 0xabbf, 0xabbf, 0xabbf, 0xabbf,
+	0xabc1, 0xac57, 0xabbf, 0xabbf, 0xac6e, 0xacfa, 0xabbf, 0xabbf,
+	0xabbf, 0xabbf, 0xad0f, 0xabbf, 0xabbf, 0xabbf, 0xabbf, 0x080c,
+	0x0db2, 0x0076, 0x00a6, 0x00e6, 0x0096, 0x2071, 0x0260, 0x6114,
+	0x2150, 0x7644, 0xb676, 0x96b4, 0x0fff, 0xb77c, 0xc7e5, 0xb77e,
+	0x6210, 0x00b6, 0x2258, 0xba3c, 0x82ff, 0x0110, 0x8211, 0xba3e,
+	0x00be, 0x86ff, 0x0904, 0xac52, 0x9694, 0xff00, 0x9284, 0x0c00,
+	0x0120, 0x7048, 0xb092, 0x704c, 0xb08e, 0x9284, 0x0300, 0x0904,
+	0xac52, 0x080c, 0x0fd5, 0x090c, 0x0db2, 0x2900, 0xb07a, 0xb77c,
+	0xc7cd, 0xb77e, 0xa867, 0x0103, 0xb068, 0xa86a, 0xb06c, 0xa86e,
+	0xb070, 0xa872, 0xae76, 0x968c, 0x0c00, 0x0120, 0x7348, 0xab92,
+	0x734c, 0xab8e, 0x968c, 0x00ff, 0x9186, 0x0002, 0x0180, 0x9186,
+	0x0028, 0x1118, 0xa87b, 0x001c, 0x0060, 0xd6dc, 0x0118, 0xa87b,
+	0x0015, 0x0038, 0xd6d4, 0x0118, 0xa87b, 0x0007, 0x0010, 0xa87b,
+	0x0000, 0xaf7e, 0xb080, 0xa882, 0xb084, 0xa886, 0x901e, 0xd6c4,
+	0x0190, 0x735c, 0xab86, 0x83ff, 0x0170, 0x938a, 0x0009, 0x0210,
+	0x2019, 0x0008, 0x0036, 0x2308, 0x2019, 0x0018, 0x2011, 0x0025,
+	0x080c, 0xb219, 0x003e, 0xd6cc, 0x01e8, 0x7154, 0xa98a, 0x81ff,
+	0x01c8, 0x9192, 0x0021, 0x1260, 0x8304, 0x9098, 0x0018, 0x2011,
+	0x0029, 0x080c, 0xb219, 0x2011, 0x0205, 0x2013, 0x0000, 0x0050,
+	0xb068, 0xd0fc, 0x0120, 0x2009, 0x0020, 0xa98a, 0x0c68, 0x2950,
+	0x080c, 0xb1b8, 0x009e, 0x00ee, 0x00ae, 0x007e, 0x0005, 0x00f6,
+	0x00a6, 0x6003, 0x0003, 0x2079, 0x026c, 0x7c04, 0x7b00, 0x7e0c,
+	0x7d08, 0x6014, 0x2050, 0xb436, 0xb33a, 0xb646, 0xb54a, 0x00ae,
+	0x00fe, 0x2c10, 0x080c, 0x1976, 0x0804, 0x8f88, 0x6003, 0x0002,
+	0x6004, 0x9086, 0x0040, 0x11c8, 0x0096, 0x6014, 0x2048, 0xa87c,
+	0xd0ac, 0x0160, 0x601c, 0xd084, 0x1130, 0x00f6, 0x2c00, 0x2078,
+	0x080c, 0x1582, 0x00fe, 0x6003, 0x0004, 0x0010, 0x6003, 0x0002,
+	0x009e, 0x080c, 0x847d, 0x080c, 0x8582, 0x0096, 0x2001, 0x1957,
+	0x2004, 0x6042, 0x080c, 0x8532, 0x080c, 0x865d, 0x6114, 0x2148,
+	0xa97c, 0xd1e4, 0x0904, 0xacf5, 0xd1cc, 0x05a8, 0xa978, 0xa868,
+	0xd0fc, 0x0538, 0x0016, 0xa87c, 0x0006, 0xa880, 0x0006, 0xa860,
+	0x20e8, 0xa85c, 0x9080, 0x0019, 0x20a0, 0x810e, 0x810e, 0x810f,
+	0x9184, 0x003f, 0x20e0, 0x9184, 0xffc0, 0x9080, 0x0019, 0x2098,
+	0x0156, 0x20a9, 0x0020, 0x4003, 0x015e, 0x000e, 0xa882, 0x000e,
+	0xa87e, 0x001e, 0xa874, 0x0006, 0x2148, 0x080c, 0x0f87, 0x001e,
+	0x0440, 0x0016, 0x080c, 0x0f87, 0x009e, 0xa974, 0x0016, 0x080c,
+	0xb209, 0x001e, 0x00f0, 0xa867, 0x0103, 0xa974, 0x9184, 0x00ff,
+	0x90b6, 0x0002, 0x0180, 0x9086, 0x0028, 0x1118, 0xa87b, 0x001c,
+	0x0060, 0xd1dc, 0x0118, 0xa87b, 0x0015, 0x0038, 0xd1d4, 0x0118,
+	0xa87b, 0x0007, 0x0010, 0xa87b, 0x0000, 0x0016, 0x080c, 0x6351,
+	0x001e, 0xd1e4, 0x1120, 0x080c, 0x99d6, 0x009e, 0x0005, 0x080c,
+	0xb8ed, 0x0cd8, 0x6004, 0x9086, 0x0040, 0x1120, 0x080c, 0x847d,
+	0x080c, 0x8582, 0x2019, 0x0001, 0x080c, 0x9254, 0x6003, 0x0002,
+	0x080c, 0xbd09, 0x080c, 0x8532, 0x080c, 0x865d, 0x0005, 0x6004,
+	0x9086, 0x0040, 0x1120, 0x080c, 0x847d, 0x080c, 0x8582, 0x2019,
+	0x0001, 0x080c, 0x9254, 0x080c, 0x8532, 0x080c, 0x2e30, 0x080c,
+	0xbd01, 0x0096, 0x6114, 0x2148, 0x080c, 0xb5fb, 0x0150, 0xa867,
+	0x0103, 0xa87b, 0x0029, 0xa877, 0x0000, 0x080c, 0x6536, 0x080c,
+	0xb7dd, 0x009e, 0x080c, 0x99d6, 0x080c, 0x865d, 0x0005, 0xa87b,
+	0x0015, 0xd1fc, 0x0138, 0xa87b, 0x0007, 0x8002, 0x8000, 0x810a,
+	0x9189, 0x0000, 0xa992, 0xa88e, 0x0005, 0x9182, 0x0054, 0x1220,
+	0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xad61, 0xad61, 0xad61,
+	0xad61, 0xad61, 0xad63, 0xad61, 0xad61, 0xae09, 0xad61, 0xad61,
+	0xad61, 0xad61, 0xad61, 0xad61, 0xad61, 0xad61, 0xad61, 0xad61,
+	0xaf3a, 0x080c, 0x0db2, 0x0076, 0x00a6, 0x00e6, 0x0096, 0x2071,
+	0x0260, 0x6114, 0x2150, 0x7644, 0xb676, 0x96b4, 0x0fff, 0xb77c,
+	0xc7e5, 0xb77e, 0x6210, 0x00b6, 0x2258, 0xba3c, 0x82ff, 0x0110,
+	0x8211, 0xba3e, 0x00be, 0x86ff, 0x0904, 0xae02, 0x9694, 0xff00,
+	0x9284, 0x0c00, 0x0120, 0x7048, 0xb092, 0x704c, 0xb08e, 0x9284,
+	0x0300, 0x0904, 0xae02, 0x9686, 0x0100, 0x1130, 0x7064, 0x9005,
+	0x1118, 0xc6c4, 0xb676, 0x0c38, 0x080c, 0x0fd5, 0x090c, 0x0db2,
+	0x2900, 0xb07a, 0xb77c, 0x97bd, 0x0200, 0xb77e, 0xa867, 0x0103,
+	0xb068, 0xa86a, 0xb06c, 0xa86e, 0xb070, 0xa872, 0x7044, 0x9084,
+	0xf000, 0x9635, 0xae76, 0x968c, 0x0c00, 0x0120, 0x7348, 0xab92,
+	0x734c, 0xab8e, 0x968c, 0x00ff, 0x9186, 0x0002, 0x0180, 0x9186,
+	0x0028, 0x1118, 0xa87b, 0x001c, 0x0060, 0xd6dc, 0x0118, 0xa87b,
+	0x0015, 0x0038, 0xd6d4, 0x0118, 0xa87b, 0x0007, 0x0010, 0xa87b,
+	0x0000, 0xaf7e, 0xb080, 0xa882, 0xb084, 0xa886, 0x901e, 0xd6c4,
+	0x0190, 0x735c, 0xab86, 0x83ff, 0x0170, 0x938a, 0x0009, 0x0210,
+	0x2019, 0x0008, 0x0036, 0x2308, 0x2019, 0x0018, 0x2011, 0x0025,
+	0x080c, 0xb219, 0x003e, 0xd6cc, 0x01e8, 0x7154, 0xa98a, 0x81ff,
+	0x01c8, 0x9192, 0x0021, 0x1260, 0x8304, 0x9098, 0x0018, 0x2011,
+	0x0029, 0x080c, 0xb219, 0x2011, 0x0205, 0x2013, 0x0000, 0x0050,
+	0xb068, 0xd0fc, 0x0120, 0x2009, 0x0020, 0xa98a, 0x0c68, 0x2950,
+	0x080c, 0xb1b8, 0x080c, 0x1805, 0x009e, 0x00ee, 0x00ae, 0x007e,
+	0x0005, 0x2001, 0x1957, 0x2004, 0x6042, 0x0096, 0x6114, 0x2148,
+	0xa83c, 0xa940, 0x9105, 0x1118, 0xa87c, 0xc0dc, 0xa87e, 0x6003,
+	0x0002, 0xa97c, 0xd1e4, 0x0904, 0xaf35, 0x6043, 0x0000, 0x6010,
+	0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x1500, 0xd1cc, 0x0904,
+	0xaf04, 0xa978, 0xa868, 0xd0fc, 0x0904, 0xaec5, 0x0016, 0xa87c,
+	0x0006, 0xa880, 0x0006, 0x00a6, 0x2150, 0xb174, 0x9184, 0x00ff,
+	0x90b6, 0x0002, 0x0904, 0xae93, 0x9086, 0x0028, 0x1904, 0xae7f,
+	0xa87b, 0x001c, 0xb07b, 0x001c, 0x0804, 0xae9b, 0x6024, 0xd0f4,
+	0x11d0, 0xa838, 0xaa34, 0x9205, 0x09c8, 0xa838, 0xaa90, 0x9206,
+	0x1120, 0xa88c, 0xaa34, 0x9206, 0x0988, 0x6024, 0xd0d4, 0x1148,
+	0xa9ac, 0xa834, 0x9102, 0x603a, 0xa9b0, 0xa838, 0x9103, 0x603e,
+	0x6024, 0xc0f5, 0x6026, 0x6010, 0x00b6, 0x2058, 0xb83c, 0x8000,
+	0xb83e, 0x00be, 0x9006, 0xa876, 0xa892, 0xa88e, 0xa87c, 0xc0e4,
+	0xa87e, 0xd0cc, 0x0140, 0xc0cc, 0xa87e, 0x0096, 0xa878, 0x2048,
+	0x080c, 0x0f87, 0x009e, 0x080c, 0xb927, 0x0804, 0xaf35, 0xd1dc,
+	0x0158, 0xa87b, 0x0015, 0xb07b, 0x0015, 0x080c, 0xbbb6, 0x0118,
+	0xb174, 0xc1dc, 0xb176, 0x0078, 0xd1d4, 0x0128, 0xa87b, 0x0007,
+	0xb07b, 0x0007, 0x0040, 0xa87c, 0xd0ac, 0x0128, 0xa834, 0xa938,
+	0x9115, 0x190c, 0xad37, 0xa87c, 0xb07e, 0xa890, 0xb092, 0xa88c,
+	0xb08e, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x0019, 0x20a0, 0x20a9,
+	0x0020, 0x8a06, 0x8006, 0x8007, 0x9094, 0x003f, 0x22e0, 0x9084,
+	0xffc0, 0x9080, 0x0019, 0x2098, 0x4003, 0x00ae, 0x000e, 0xa882,
+	0x000e, 0xa87e, 0x080c, 0xbc93, 0x001e, 0xa874, 0x0006, 0x2148,
+	0x080c, 0x0f87, 0x001e, 0x0804, 0xaf31, 0x0016, 0x00a6, 0x2150,
+	0xb174, 0x9184, 0x00ff, 0x90b6, 0x0002, 0x01e0, 0x9086, 0x0028,
+	0x1128, 0xa87b, 0x001c, 0xb07b, 0x001c, 0x00e0, 0xd1dc, 0x0158,
+	0xa87b, 0x0015, 0xb07b, 0x0015, 0x080c, 0xbbb6, 0x0118, 0xb174,
+	0xc1dc, 0xb176, 0x0078, 0xd1d4, 0x0128, 0xa87b, 0x0007, 0xb07b,
+	0x0007, 0x0040, 0xa87c, 0xd0ac, 0x0128, 0xa834, 0xa938, 0x9115,
+	0x190c, 0xad37, 0xa890, 0xb092, 0xa88c, 0xb08e, 0xa87c, 0xb07e,
+	0x00ae, 0x080c, 0x0f87, 0x009e, 0x080c, 0xbc93, 0xa974, 0x0016,
+	0x080c, 0xb209, 0x001e, 0x0468, 0xa867, 0x0103, 0xa974, 0x9184,
+	0x00ff, 0x90b6, 0x0002, 0x01b0, 0x9086, 0x0028, 0x1118, 0xa87b,
+	0x001c, 0x00d0, 0xd1dc, 0x0148, 0xa87b, 0x0015, 0x080c, 0xbbb6,
+	0x0118, 0xa974, 0xc1dc, 0xa976, 0x0078, 0xd1d4, 0x0118, 0xa87b,
+	0x0007, 0x0050, 0xa87b, 0x0000, 0xa87c, 0xd0ac, 0x0128, 0xa834,
+	0xa938, 0x9115, 0x190c, 0xad37, 0xa974, 0x0016, 0x080c, 0x6351,
+	0x001e, 0xd1e4, 0x1120, 0x080c, 0x99d6, 0x009e, 0x0005, 0x080c,
+	0xb8ed, 0x0cd8, 0x6114, 0x0096, 0x2148, 0xa97c, 0xd1e4, 0x190c,
+	0x1813, 0x009e, 0x0005, 0x080c, 0x847d, 0x0010, 0x080c, 0x8532,
+	0x080c, 0xb5fb, 0x01f0, 0x0096, 0x6114, 0x2148, 0x080c, 0xb7fa,
+	0x1118, 0x080c, 0xa364, 0x00a0, 0xa867, 0x0103, 0x2009, 0x180c,
+	0x210c, 0xd18c, 0x11b8, 0xd184, 0x1190, 0x6108, 0xa97a, 0x918e,
+	0x0029, 0x1110, 0x080c, 0xd28c, 0xa877, 0x0000, 0x080c, 0x6536,
+	0x009e, 0x080c, 0x99d6, 0x080c, 0x8582, 0x0804, 0x865d, 0xa87b,
+	0x0004, 0x0c90, 0xa87b, 0x0004, 0x0c78, 0x9182, 0x0054, 0x1220,
+	0x9182, 0x0040, 0x0208, 0x000a, 0x0005, 0xaf91, 0xaf91, 0xaf91,
+	0xaf91, 0xaf91, 0xaf93, 0xaf91, 0xaf91, 0xaf91, 0xaf91, 0xaf91,
+	0xaf91, 0xaf91, 0xaf91, 0xaf91, 0xaf91, 0xaf91, 0xaf91, 0xaf91,
+	0xaf91, 0x080c, 0x0db2, 0x080c, 0x511b, 0x01f8, 0x6014, 0x7144,
+	0x918c, 0x0fff, 0x9016, 0xd1c4, 0x0118, 0x7264, 0x9294, 0x00ff,
+	0x0096, 0x904d, 0x0188, 0xa87b, 0x0000, 0xa864, 0x9086, 0x0139,
+	0x0128, 0xa867, 0x0103, 0xa976, 0xaa96, 0x0030, 0xa897, 0x4000,
+	0xa99a, 0xaa9e, 0x080c, 0x6536, 0x009e, 0x0804, 0x99d6, 0x9182,
+	0x0085, 0x0002, 0xafc9, 0xafc7, 0xafc7, 0xafd5, 0xafc7, 0xafc7,
+	0xafc7, 0xafc7, 0xafc7, 0xafc7, 0xafc7, 0xafc7, 0xafc7, 0x080c,
+	0x0db2, 0x6003, 0x0001, 0x6106, 0x080c, 0x8000, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x8582, 0x012e, 0x0005, 0x0026, 0x0056, 0x00d6,
+	0x00e6, 0x2071, 0x0260, 0x7224, 0x6216, 0x7220, 0x080c, 0xb5e9,
+	0x01a0, 0x2268, 0x6800, 0x9086, 0x0000, 0x0178, 0x6010, 0x6d10,
+	0x952e, 0x1158, 0x00c6, 0x2d60, 0x080c, 0xb244, 0x00ce, 0x0128,
+	0x6803, 0x0002, 0x6007, 0x0086, 0x0010, 0x6007, 0x0087, 0x6003,
+	0x0001, 0x080c, 0x8000, 0x080c, 0x8582, 0x9280, 0x0004, 0x00b6,
+	0x2058, 0xb800, 0x00be, 0xd0bc, 0x0140, 0x6824, 0xd0ec, 0x0128,
+	0x00c6, 0x2260, 0x080c, 0xb927, 0x00ce, 0x00ee, 0x00de, 0x005e,
+	0x002e, 0x0005, 0x9186, 0x0013, 0x1160, 0x6004, 0x908a, 0x0085,
+	0x0a0c, 0x0db2, 0x908a, 0x0092, 0x1a0c, 0x0db2, 0x9082, 0x0085,
+	0x00e2, 0x9186, 0x0027, 0x0120, 0x9186, 0x0014, 0x190c, 0x0db2,
+	0x080c, 0x847d, 0x0096, 0x6014, 0x2048, 0x080c, 0xb5fb, 0x0140,
+	0xa867, 0x0103, 0xa877, 0x0000, 0xa87b, 0x0029, 0x080c, 0x6536,
+	0x009e, 0x080c, 0x9a06, 0x0804, 0x8582, 0xb04a, 0xb04c, 0xb04c,
+	0xb04a, 0xb04a, 0xb04a, 0xb04a, 0xb04a, 0xb04a, 0xb04a, 0xb04a,
+	0xb04a, 0xb04a, 0x080c, 0x0db2, 0x080c, 0x847d, 0x080c, 0x9a06,
+	0x080c, 0x8582, 0x0005, 0x9186, 0x0013, 0x1128, 0x6004, 0x9082,
+	0x0085, 0x2008, 0x04b8, 0x9186, 0x0027, 0x11f8, 0x080c, 0x847d,
+	0x080c, 0x2e30, 0x080c, 0xbd01, 0x0096, 0x6014, 0x2048, 0x080c,
+	0xb5fb, 0x0150, 0xa867, 0x0103, 0xa877, 0x0000, 0xa87b, 0x0029,
+	0x080c, 0x6536, 0x080c, 0xb7dd, 0x009e, 0x080c, 0x99d6, 0x080c,
+	0x8582, 0x0005, 0x080c, 0x9a6b, 0x0ce0, 0x9186, 0x0014, 0x1dd0,
+	0x080c, 0x847d, 0x0096, 0x6014, 0x2048, 0x080c, 0xb5fb, 0x0d60,
+	0xa867, 0x0103, 0xa877, 0x0000, 0xa87b, 0x0006, 0xa880, 0xc0ec,
+	0xa882, 0x08f0, 0x0002, 0xb0a2, 0xb0a0, 0xb0a0, 0xb0a0, 0xb0a0,
+	0xb0a0, 0xb0ba, 0xb0a0, 0xb0a0, 0xb0a0, 0xb0a0, 0xb0a0, 0xb0a0,
+	0x080c, 0x0db2, 0x080c, 0x847d, 0x6034, 0x908c, 0xff00, 0x810f,
+	0x9186, 0x0039, 0x0118, 0x9186, 0x0035, 0x1118, 0x2001, 0x1955,
+	0x0010, 0x2001, 0x1956, 0x2004, 0x601a, 0x6003, 0x000c, 0x080c,
+	0x8582, 0x0005, 0x080c, 0x847d, 0x6034, 0x908c, 0xff00, 0x810f,
+	0x9186, 0x0039, 0x0118, 0x9186, 0x0035, 0x1118, 0x2001, 0x1955,
+	0x0010, 0x2001, 0x1956, 0x2004, 0x601a, 0x6003, 0x000e, 0x080c,
+	0x8582, 0x0005, 0x9182, 0x0092, 0x1220, 0x9182, 0x0085, 0x0208,
+	0x0012, 0x0804, 0x9a6b, 0xb0e8, 0xb0e8, 0xb0e8, 0xb0e8, 0xb0ea,
+	0xb137, 0xb0e8, 0xb0e8, 0xb0e8, 0xb0e8, 0xb0e8, 0xb0e8, 0xb0e8,
+	0x080c, 0x0db2, 0x0096, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be,
+	0xd0bc, 0x0168, 0x6034, 0x908c, 0xff00, 0x810f, 0x9186, 0x0039,
+	0x0118, 0x9186, 0x0035, 0x1118, 0x009e, 0x0804, 0xb14b, 0x080c,
+	0xb5fb, 0x1118, 0x080c, 0xb7dd, 0x0068, 0x6014, 0x2048, 0xa87c,
+	0xd0e4, 0x1110, 0x080c, 0xb7dd, 0xa867, 0x0103, 0x080c, 0xbccc,
+	0x080c, 0x6536, 0x00d6, 0x2c68, 0x080c, 0x9980, 0x01d0, 0x6003,
+	0x0001, 0x6007, 0x001e, 0x600b, 0xffff, 0x2009, 0x026e, 0x210c,
+	0x613a, 0x2009, 0x026f, 0x210c, 0x613e, 0x6910, 0x6112, 0x080c,
+	0xba69, 0x6954, 0x6156, 0x6023, 0x0001, 0x080c, 0x8000, 0x080c,
+	0x8582, 0x2d60, 0x00de, 0x080c, 0x99d6, 0x009e, 0x0005, 0x6010,
+	0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x05a0, 0x6034, 0x908c,
+	0xff00, 0x810f, 0x9186, 0x0035, 0x0130, 0x9186, 0x001e, 0x0118,
+	0x9186, 0x0039, 0x1538, 0x00d6, 0x2c68, 0x080c, 0xbc66, 0x11f0,
+	0x080c, 0x9980, 0x01d8, 0x6106, 0x6003, 0x0001, 0x6023, 0x0001,
+	0x6910, 0x6112, 0x692c, 0x612e, 0x6930, 0x6132, 0x6934, 0x918c,
+	0x00ff, 0x6136, 0x6938, 0x613a, 0x693c, 0x613e, 0x6954, 0x6156,
+	0x080c, 0xba69, 0x080c, 0x8000, 0x080c, 0x8582, 0x2d60, 0x00de,
+	0x0804, 0x99d6, 0x0096, 0x6014, 0x2048, 0x080c, 0xb5fb, 0x01c8,
+	0xa867, 0x0103, 0xa880, 0xd0b4, 0x0128, 0xc0ec, 0xa882, 0xa87b,
+	0x0006, 0x0048, 0xd0bc, 0x0118, 0xa87b, 0x0002, 0x0020, 0xa87b,
+	0x0005, 0x080c, 0xb8e9, 0xa877, 0x0000, 0x080c, 0x6536, 0x080c,
+	0xb7dd, 0x009e, 0x0804, 0x99d6, 0x0016, 0x0096, 0x6014, 0x2048,
+	0x080c, 0xb5fb, 0x0140, 0xa867, 0x0103, 0xa87b, 0x0028, 0xa877,
+	0x0000, 0x080c, 0x6536, 0x009e, 0x001e, 0x9186, 0x0013, 0x0148,
+	0x9186, 0x0014, 0x0130, 0x9186, 0x0027, 0x0118, 0x080c, 0x9a6b,
+	0x0030, 0x080c, 0x847d, 0x080c, 0x9a06, 0x080c, 0x8582, 0x0005,
+	0x0056, 0x0066, 0x0096, 0x00a6, 0x2029, 0x0001, 0x9182, 0x0101,
+	0x1208, 0x0010, 0x2009, 0x0100, 0x2130, 0x8304, 0x9098, 0x0018,
+	0x2009, 0x0020, 0x2011, 0x0029, 0x080c, 0xb219, 0x96b2, 0x0020,
+	0xb004, 0x904d, 0x0110, 0x080c, 0x0f87, 0x080c, 0x0fd5, 0x0520,
+	0x8528, 0xa867, 0x0110, 0xa86b, 0x0000, 0x2920, 0xb406, 0x968a,
+	0x003d, 0x1228, 0x2608, 0x2011, 0x001b, 0x0499, 0x00a8, 0x96b2,
+	0x003c, 0x2009, 0x003c, 0x2950, 0x2011, 0x001b, 0x0451, 0x0c28,
+	0x2001, 0x0205, 0x2003, 0x0000, 0x00ae, 0x852f, 0x95ad, 0x0003,
+	0xb566, 0x95ac, 0x0000, 0x0048, 0x2001, 0x0205, 0x2003, 0x0000,
+	0x00ae, 0x852f, 0x95ad, 0x0003, 0xb566, 0x009e, 0x006e, 0x005e,
+	0x0005, 0x00a6, 0x89ff, 0x0158, 0xa804, 0x9055, 0x0130, 0xa807,
+	0x0000, 0x080c, 0x6536, 0x2a48, 0x0cb8, 0x080c, 0x6536, 0x00ae,
+	0x0005, 0x00f6, 0x2079, 0x0200, 0x7814, 0x9085, 0x0080, 0x7816,
+	0xd184, 0x0108, 0x8108, 0x810c, 0x20a9, 0x0001, 0xa860, 0x20e8,
+	0xa85c, 0x9200, 0x20a0, 0x20e1, 0x0000, 0x2300, 0x9e00, 0x2098,
+	0x4003, 0x8318, 0x9386, 0x0020, 0x1148, 0x2018, 0x2300, 0x9e00,
+	0x2098, 0x7814, 0x8000, 0x9085, 0x0080, 0x7816, 0x8109, 0x1d80,
+	0x7817, 0x0000, 0x00fe, 0x0005, 0x0066, 0x0126, 0x2091, 0x8000,
+	0x2031, 0x0001, 0x6020, 0x9084, 0x000f, 0x0083, 0x012e, 0x006e,
+	0x0005, 0x0126, 0x2091, 0x8000, 0x0066, 0x2031, 0x0000, 0x6020,
+	0x9084, 0x000f, 0x001b, 0x006e, 0x012e, 0x0005, 0xb27f, 0xb27f,
+	0xb27a, 0xb2a1, 0xb26d, 0xb27a, 0xb2a1, 0xb27a, 0xb26d, 0xb26d,
+	0xb27a, 0xb27a, 0xb27a, 0xb26d, 0xb26d, 0x080c, 0x0db2, 0x0036,
+	0x2019, 0x0010, 0x080c, 0xcbad, 0x6023, 0x0006, 0x6003, 0x0007,
+	0x003e, 0x0005, 0x9006, 0x0005, 0x9085, 0x0001, 0x0005, 0x0096,
+	0x86ff, 0x11d8, 0x6014, 0x2048, 0x080c, 0xb5fb, 0x01c0, 0xa864,
+	0x9086, 0x0139, 0x1128, 0xa87b, 0x0005, 0xa883, 0x0000, 0x0028,
+	0x900e, 0x2001, 0x0005, 0x080c, 0x6770, 0x080c, 0xb8e9, 0x080c,
+	0x6529, 0x080c, 0x9a06, 0x9085, 0x0001, 0x009e, 0x0005, 0x9006,
+	0x0ce0, 0x6000, 0x908a, 0x0016, 0x1a0c, 0x0db2, 0x0002, 0xb2b7,
+	0xb2dc, 0xb2b9, 0xb2fd, 0xb2d7, 0xb2b7, 0xb27a, 0xb27f, 0xb27f,
+	0xb27a, 0xb27a, 0xb27a, 0xb27a, 0xb27a, 0xb27a, 0xb27a, 0x080c,
+	0x0db2, 0x86ff, 0x11c8, 0x6020, 0x9086, 0x0006, 0x01a8, 0x0096,
+	0x6014, 0x2048, 0x080c, 0xb5fb, 0x0110, 0x080c, 0xb8e9, 0x009e,
+	0x080c, 0xbca8, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0002,
+	0x080c, 0x8000, 0x080c, 0x8582, 0x9085, 0x0001, 0x0005, 0x0066,
+	0x080c, 0x1827, 0x006e, 0x08e8, 0x00e6, 0x2071, 0x19b6, 0x7024,
+	0x9c06, 0x1120, 0x080c, 0x91de, 0x00ee, 0x0898, 0x6020, 0x9084,
+	0x000f, 0x9086, 0x0006, 0x1150, 0x0086, 0x0096, 0x2049, 0x0001,
+	0x2c40, 0x080c, 0x9349, 0x009e, 0x008e, 0x0010, 0x080c, 0x90db,
+	0x00ee, 0x1904, 0xb2b9, 0x0804, 0xb27a, 0x0036, 0x00e6, 0x2071,
+	0x19b6, 0x703c, 0x9c06, 0x1138, 0x901e, 0x080c, 0x9254, 0x00ee,
+	0x003e, 0x0804, 0xb2b9, 0x080c, 0x9479, 0x00ee, 0x003e, 0x1904,
+	0xb2b9, 0x0804, 0xb27a, 0x00c6, 0x6020, 0x9084, 0x000f, 0x0013,
+	0x00ce, 0x0005, 0xb330, 0xb3df, 0xb546, 0xb33a, 0x9a06, 0xb330,
+	0xcb9f, 0xbd0e, 0xb3df, 0xb329, 0xb5c5, 0xb329, 0xb329, 0xb329,
+	0xb329, 0x080c, 0x0db2, 0x080c, 0xb7fa, 0x1110, 0x080c, 0xa364,
+	0x0005, 0x080c, 0x847d, 0x080c, 0x8582, 0x0804, 0x99d6, 0x601b,
+	0x0001, 0x0005, 0x080c, 0xb5fb, 0x0130, 0x6014, 0x0096, 0x2048,
+	0x2c00, 0xa896, 0x009e, 0x6000, 0x908a, 0x0016, 0x1a0c, 0x0db2,
+	0x0002, 0xb359, 0xb35b, 0xb37f, 0xb393, 0xb3b7, 0xb359, 0xb330,
+	0xb330, 0xb330, 0xb393, 0xb393, 0xb359, 0xb359, 0xb359, 0xb359,
+	0xb39d, 0x080c, 0x0db2, 0x00e6, 0x6014, 0x0096, 0x2048, 0xa880,
+	0xc0b5, 0xa882, 0x009e, 0x2071, 0x19b6, 0x7024, 0x9c06, 0x01a0,
+	0x080c, 0x90db, 0x080c, 0xbca8, 0x6007, 0x0085, 0x6003, 0x000b,
+	0x6023, 0x0002, 0x2001, 0x1956, 0x2004, 0x601a, 0x080c, 0x8000,
+	0x080c, 0x8582, 0x00ee, 0x0005, 0x601b, 0x0001, 0x0cd8, 0x0096,
+	0x6014, 0x2048, 0xa880, 0xc0b5, 0xa882, 0x009e, 0x080c, 0xbca8,
+	0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0002, 0x080c, 0x8000,
+	0x080c, 0x8582, 0x0005, 0x0096, 0x601b, 0x0001, 0x6014, 0x2048,
+	0xa880, 0xc0b5, 0xa882, 0x009e, 0x0005, 0x080c, 0x511b, 0x01a8,
+	0x6014, 0x0096, 0x904d, 0x0180, 0xa864, 0xa867, 0x0103, 0xa87b,
+	0x0006, 0x9086, 0x0139, 0x1140, 0xa867, 0x0139, 0xa897, 0x4005,
+	0xa89b, 0x0004, 0x080c, 0x6536, 0x009e, 0x0804, 0x99d6, 0x6014,
+	0x0096, 0x904d, 0x01f8, 0xa97c, 0xd1e4, 0x01e0, 0x2001, 0x180e,
+	0x2004, 0xd0c4, 0x0110, 0x009e, 0x0005, 0xa884, 0x009e, 0x8003,
+	0x800b, 0x810b, 0x9108, 0x611a, 0x2001, 0x0037, 0x2c08, 0x080c,
+	0x14d2, 0x6000, 0x9086, 0x0004, 0x1120, 0x2009, 0x0048, 0x080c,
+	0x9a50, 0x0005, 0x009e, 0x080c, 0x1827, 0x0804, 0xb37f, 0x6000,
+	0x908a, 0x0016, 0x1a0c, 0x0db2, 0x000b, 0x0005, 0xb3f6, 0xb337,
+	0xb3f8, 0xb3f6, 0xb3f8, 0xb3f8, 0xb331, 0xb3f6, 0xb32b, 0xb32b,
+	0xb3f6, 0xb3f6, 0xb3f6, 0xb3f6, 0xb3f6, 0xb3f6, 0x080c, 0x0db2,
+	0x6010, 0x00b6, 0x2058, 0xb804, 0x9084, 0x00ff, 0x00be, 0x908a,
+	0x000c, 0x1a0c, 0x0db2, 0x00b6, 0x0013, 0x00be, 0x0005, 0xb413,
+	0xb4e0, 0xb415, 0xb455, 0xb415, 0xb455, 0xb415, 0xb423, 0xb413,
+	0xb455, 0xb413, 0xb444, 0x080c, 0x0db2, 0x6004, 0x908e, 0x0016,
+	0x05c0, 0x908e, 0x0004, 0x05a8, 0x908e, 0x0002, 0x0590, 0x908e,
+	0x0052, 0x0904, 0xb4dc, 0x6004, 0x080c, 0xb7fa, 0x0904, 0xb4f9,
+	0x908e, 0x0004, 0x1110, 0x080c, 0x2e55, 0x908e, 0x0021, 0x0904,
+	0xb4fd, 0x908e, 0x0022, 0x0904, 0xb541, 0x908e, 0x003d, 0x0904,
+	0xb4fd, 0x908e, 0x0039, 0x0904, 0xb501, 0x908e, 0x0035, 0x0904,
+	0xb501, 0x908e, 0x001e, 0x0178, 0x908e, 0x0001, 0x1140, 0x6010,
+	0x2058, 0xb804, 0x9084, 0x00ff, 0x9086, 0x0006, 0x0110, 0x080c,
+	0x2e30, 0x080c, 0xa364, 0x0804, 0x9a06, 0x00c6, 0x00d6, 0x6104,
+	0x9186, 0x0016, 0x0904, 0xb4cd, 0x9186, 0x0002, 0x1904, 0xb4a2,
+	0x2001, 0x1835, 0x2004, 0xd08c, 0x11c8, 0x080c, 0x6c53, 0x11b0,
+	0x080c, 0xbcec, 0x0138, 0x080c, 0x6c76, 0x1120, 0x080c, 0x6b68,
+	0x0804, 0xb52a, 0x2001, 0x194e, 0x2003, 0x0001, 0x2001, 0x1800,
+	0x2003, 0x0001, 0x080c, 0x6b8a, 0x0804, 0xb52a, 0x6010, 0x2058,
+	0x2001, 0x1835, 0x2004, 0xd0ac, 0x1904, 0xb52a, 0xb8a0, 0x9084,
+	0xff80, 0x1904, 0xb52a, 0xb840, 0x9084, 0x00ff, 0x9005, 0x0190,
+	0x8001, 0xb842, 0x6017, 0x0000, 0x6023, 0x0007, 0x601b, 0x0398,
+	0x6043, 0x0000, 0x080c, 0x9980, 0x0128, 0x2b00, 0x6012, 0x6023,
+	0x0001, 0x0458, 0x00de, 0x00ce, 0x6004, 0x908e, 0x0002, 0x11a0,
+	0x6010, 0x2058, 0xb8a0, 0x9086, 0x007e, 0x1170, 0x2009, 0x1835,
+	0x2104, 0xc085, 0x200a, 0x00e6, 0x2071, 0x1800, 0x080c, 0x59b4,
+	0x00ee, 0x080c, 0xa364, 0x0030, 0x080c, 0xa364, 0x080c, 0x2e30,
+	0x080c, 0xbd01, 0x00e6, 0x0126, 0x2091, 0x8000, 0x080c, 0x2e55,
+	0x012e, 0x00ee, 0x080c, 0x9a06, 0x0005, 0x2001, 0x0002, 0x080c,
+	0x5ecf, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x8048, 0x080c,
+	0x8582, 0x00de, 0x00ce, 0x0c80, 0x080c, 0x2e55, 0x0804, 0xb451,
+	0x00c6, 0x00d6, 0x6104, 0x9186, 0x0016, 0x0d38, 0x6010, 0x2058,
+	0xb840, 0x9084, 0x00ff, 0x9005, 0x0904, 0xb4a2, 0x8001, 0xb842,
+	0x6003, 0x0001, 0x080c, 0x8048, 0x080c, 0x8582, 0x00de, 0x00ce,
+	0x0898, 0x080c, 0xa364, 0x0804, 0xb453, 0x080c, 0xa3a0, 0x0804,
+	0xb453, 0x00d6, 0x2c68, 0x6104, 0x080c, 0xbc66, 0x00de, 0x0118,
+	0x080c, 0x99d6, 0x00f0, 0x6004, 0x8007, 0x6134, 0x918c, 0x00ff,
+	0x9105, 0x6036, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023, 0x0002,
+	0x603c, 0x600a, 0x2001, 0x1956, 0x2004, 0x601a, 0x602c, 0x2c08,
+	0x2060, 0x6024, 0xc0b5, 0x6026, 0x2160, 0x080c, 0x8000, 0x080c,
+	0x8582, 0x0005, 0x00de, 0x00ce, 0x080c, 0xa364, 0x080c, 0x2e30,
+	0x00e6, 0x0126, 0x2091, 0x8000, 0x080c, 0x2e55, 0x6017, 0x0000,
+	0x6023, 0x0007, 0x601b, 0x0398, 0x6043, 0x0000, 0x012e, 0x00ee,
+	0x0005, 0x080c, 0x9e03, 0x1904, 0xb4f9, 0x0005, 0x6000, 0x908a,
+	0x0016, 0x1a0c, 0x0db2, 0x0096, 0x00d6, 0x001b, 0x00de, 0x009e,
+	0x0005, 0xb561, 0xb561, 0xb561, 0xb561, 0xb561, 0xb561, 0xb561,
+	0xb561, 0xb561, 0xb330, 0xb561, 0xb337, 0xb563, 0xb337, 0xb570,
+	0xb561, 0x080c, 0x0db2, 0x6004, 0x9086, 0x008b, 0x0148, 0x6007,
+	0x008b, 0x6003, 0x000d, 0x080c, 0x8000, 0x080c, 0x8582, 0x0005,
+	0x080c, 0xbce0, 0x0118, 0x080c, 0xbcf3, 0x0010, 0x080c, 0xbd01,
+	0x080c, 0xb7dd, 0x080c, 0xb5fb, 0x0570, 0x080c, 0x2e30, 0x080c,
+	0xb5fb, 0x0168, 0x6014, 0x2048, 0xa867, 0x0103, 0xa87b, 0x0006,
+	0xa877, 0x0000, 0xa880, 0xc0ed, 0xa882, 0x080c, 0x6536, 0x2c68,
+	0x080c, 0x9980, 0x0150, 0x6810, 0x6012, 0x080c, 0xba69, 0x00c6,
+	0x2d60, 0x080c, 0x9a06, 0x00ce, 0x0008, 0x2d60, 0x6017, 0x0000,
+	0x6023, 0x0001, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c, 0x8048,
+	0x080c, 0x8582, 0x00c8, 0x080c, 0xbce0, 0x0138, 0x6034, 0x9086,
+	0x4000, 0x1118, 0x080c, 0x2e30, 0x08d0, 0x6034, 0x908c, 0xff00,
+	0x810f, 0x9186, 0x0039, 0x0118, 0x9186, 0x0035, 0x1118, 0x080c,
+	0x2e30, 0x0868, 0x080c, 0x9a06, 0x0005, 0x6000, 0x908a, 0x0016,
+	0x1a0c, 0x0db2, 0x0002, 0xb5db, 0xb5db, 0xb5dd, 0xb5dd, 0xb5dd,
+	0xb5db, 0xb5db, 0x9a06, 0xb5db, 0xb5db, 0xb5db, 0xb5db, 0xb5db,
+	0xb5db, 0xb5db, 0xb5db, 0x080c, 0x0db2, 0x080c, 0x9479, 0x6114,
+	0x0096, 0x2148, 0xa87b, 0x0006, 0x080c, 0x6536, 0x009e, 0x0804,
+	0x99d6, 0x9284, 0x0007, 0x1158, 0x9282, 0x1cd0, 0x0240, 0x2001,
+	0x1818, 0x2004, 0x9202, 0x1218, 0x9085, 0x0001, 0x0005, 0x9006,
+	0x0ce8, 0x0096, 0x0028, 0x0096, 0x0006, 0x6014, 0x2048, 0x000e,
+	0x0006, 0x9984, 0xf000, 0x9086, 0xf000, 0x0110, 0x080c, 0x1080,
+	0x000e, 0x009e, 0x0005, 0x00e6, 0x00c6, 0x0036, 0x0006, 0x0126,
+	0x2091, 0x8000, 0x2061, 0x1cd0, 0x2071, 0x1800, 0x734c, 0x706c,
+	0x9302, 0x1640, 0x6020, 0x9206, 0x11f8, 0x080c, 0xbcec, 0x0180,
+	0x9286, 0x0001, 0x1168, 0x6004, 0x9086, 0x0004, 0x1148, 0x080c,
+	0x2e30, 0x080c, 0xbd01, 0x00c6, 0x080c, 0x9a06, 0x00ce, 0x0060,
+	0x080c, 0xb9e3, 0x0148, 0x080c, 0xb7fa, 0x1110, 0x080c, 0xa364,
+	0x00c6, 0x080c, 0x99d6, 0x00ce, 0x9ce0, 0x0018, 0x7060, 0x9c02,
+	0x1208, 0x08a0, 0x012e, 0x000e, 0x003e, 0x00ce, 0x00ee, 0x0005,
+	0x00e6, 0x00c6, 0x0016, 0x9188, 0x1000, 0x210c, 0x81ff, 0x0128,
+	0x2061, 0x1a73, 0x6112, 0x080c, 0x2e30, 0x9006, 0x0010, 0x9085,
+	0x0001, 0x001e, 0x00ce, 0x00ee, 0x0005, 0x00c6, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x9980, 0x01d8, 0x080c, 0x511b, 0x0110, 0x662e,
+	0x0008, 0x6616, 0x2b00, 0x6012, 0x080c, 0x511b, 0x0118, 0x080c,
+	0xb721, 0x0168, 0x080c, 0xba69, 0x6023, 0x0003, 0x2009, 0x004b,
+	0x080c, 0x9a50, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x9006,
+	0x0cd8, 0x00c6, 0x0126, 0x2091, 0x8000, 0xbaa0, 0x080c, 0x9a23,
+	0x0590, 0x080c, 0x511b, 0x0118, 0x602f, 0x0000, 0x0010, 0x6017,
+	0x0000, 0x2b00, 0x6012, 0x080c, 0xba69, 0x6023, 0x0003, 0x0016,
+	0x080c, 0x8180, 0x0076, 0x903e, 0x080c, 0x8078, 0x2c08, 0x080c,
+	0xcd62, 0x007e, 0x001e, 0xd184, 0x0128, 0x080c, 0x99d6, 0x9085,
+	0x0001, 0x0070, 0x080c, 0x511b, 0x0128, 0xd18c, 0x1170, 0x080c,
+	0xb721, 0x0148, 0x2009, 0x004c, 0x080c, 0x9a50, 0x9085, 0x0001,
+	0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x2900, 0x6016, 0x0c90,
+	0x2009, 0x004d, 0x0010, 0x2009, 0x004e, 0x00f6, 0x00c6, 0x0046,
+	0x0016, 0x080c, 0x9980, 0x2c78, 0x01d8, 0x080c, 0x511b, 0x0110,
+	0x7e2e, 0x0008, 0x7e16, 0x2b00, 0x7812, 0x7823, 0x0003, 0x2021,
+	0x0005, 0x080c, 0xb733, 0x2f60, 0x080c, 0x511b, 0x0118, 0x080c,
+	0xb721, 0x0130, 0x001e, 0x0016, 0x080c, 0x9a50, 0x9085, 0x0001,
+	0x001e, 0x004e, 0x00ce, 0x00fe, 0x0005, 0x00f6, 0x00c6, 0x0046,
+	0x080c, 0x9980, 0x2c78, 0x0530, 0x080c, 0x511b, 0x0110, 0x7e2e,
+	0x0008, 0x7e16, 0x2b00, 0x7812, 0x7823, 0x0003, 0x0096, 0x2021,
+	0x0004, 0x0489, 0x009e, 0x2001, 0x194f, 0x200c, 0xd1fc, 0x0120,
+	0x2f60, 0x080c, 0x99d6, 0x0060, 0x2f60, 0x080c, 0x511b, 0x0120,
+	0xd18c, 0x1160, 0x0071, 0x0130, 0x2009, 0x0052, 0x080c, 0x9a50,
+	0x9085, 0x0001, 0x004e, 0x00ce, 0x00fe, 0x0005, 0x2900, 0x7816,
+	0x0c98, 0x00c6, 0x080c, 0x4612, 0x00ce, 0x1120, 0x080c, 0x99d6,
+	0x9006, 0x0005, 0xa867, 0x0000, 0xa86b, 0x8000, 0x2900, 0x6016,
+	0x9085, 0x0001, 0x0005, 0x0096, 0x0076, 0x0126, 0x2091, 0x8000,
+	0x080c, 0x60b2, 0x0158, 0x2001, 0xb738, 0x0006, 0x900e, 0x2400,
+	0x080c, 0x6770, 0x080c, 0x6536, 0x000e, 0x0807, 0x2418, 0x080c,
+	0x8417, 0xbaa0, 0x0086, 0x2041, 0x0001, 0x2039, 0x0001, 0x2608,
+	0x080c, 0x8198, 0x008e, 0x080c, 0x8078, 0x2f08, 0x2648, 0x080c,
+	0xcd62, 0xb93c, 0x81ff, 0x090c, 0x8269, 0x080c, 0x8582, 0x012e,
+	0x007e, 0x009e, 0x0005, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c,
+	0x9980, 0x0190, 0x660a, 0x2b08, 0x6112, 0x080c, 0xba69, 0x6023,
+	0x0001, 0x2900, 0x6016, 0x2009, 0x001f, 0x080c, 0x9a50, 0x9085,
+	0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x00c6, 0x0126,
+	0x2091, 0x8000, 0x080c, 0x9a23, 0x01b8, 0x660a, 0x2b08, 0x6112,
+	0x080c, 0xba69, 0x6023, 0x0008, 0x2900, 0x6016, 0x00f6, 0x2c78,
+	0x080c, 0x1582, 0x00fe, 0x2009, 0x0021, 0x080c, 0x9a50, 0x9085,
+	0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x2009, 0x003d,
+	0x00c6, 0x0126, 0x0016, 0x2091, 0x8000, 0x080c, 0x9980, 0x0198,
+	0x660a, 0x2b08, 0x6112, 0x080c, 0xba69, 0x6023, 0x0001, 0x2900,
+	0x6016, 0x001e, 0x0016, 0x080c, 0x9a50, 0x9085, 0x0001, 0x001e,
+	0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd0, 0x00c6, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x9a23, 0x0188, 0x2b08, 0x6112, 0x080c, 0xba69,
+	0x6023, 0x0001, 0x2900, 0x6016, 0x2009, 0x0000, 0x080c, 0x9a50,
+	0x9085, 0x0001, 0x012e, 0x00ce, 0x0005, 0x9006, 0x0cd8, 0x2009,
+	0x0044, 0x0830, 0x2009, 0x0049, 0x0818, 0x0026, 0x00b6, 0x6210,
+	0x2258, 0xba3c, 0x82ff, 0x0110, 0x8211, 0xba3e, 0x00be, 0x002e,
+	0x0005, 0x0006, 0x0016, 0x6004, 0x908e, 0x0002, 0x0140, 0x908e,
+	0x0003, 0x0128, 0x908e, 0x0004, 0x0110, 0x9085, 0x0001, 0x001e,
+	0x000e, 0x0005, 0x0006, 0x0096, 0x6020, 0x9086, 0x0004, 0x0190,
+	0x6014, 0x904d, 0x080c, 0xb5fb, 0x0168, 0xa864, 0x9086, 0x0139,
+	0x0158, 0x6020, 0x9086, 0x0003, 0x0128, 0xa868, 0xd0fc, 0x0110,
+	0x9006, 0x0010, 0x9085, 0x0001, 0x009e, 0x000e, 0x0005, 0x00c6,
+	0x0126, 0x2091, 0x8000, 0x080c, 0x9a23, 0x0198, 0x2b08, 0x6112,
+	0x080c, 0xba69, 0x6023, 0x0001, 0x2900, 0x6016, 0x080c, 0x2e30,
+	0x2009, 0x0028, 0x080c, 0x9a50, 0x9085, 0x0001, 0x012e, 0x00ce,
+	0x0005, 0x9006, 0x0cd8, 0x9186, 0x0015, 0x11a8, 0x2011, 0x1822,
+	0x2204, 0x9086, 0x0074, 0x1178, 0x00b6, 0x080c, 0xa5aa, 0x00be,
+	0x080c, 0xa7a4, 0x6003, 0x0001, 0x6007, 0x0029, 0x080c, 0x8048,
+	0x080c, 0x8582, 0x0078, 0x6014, 0x0096, 0x2048, 0xa868, 0x009e,
+	0xd0fc, 0x0148, 0x2001, 0x0001, 0x080c, 0xbc27, 0x080c, 0xa364,
+	0x080c, 0x99d6, 0x0005, 0x0096, 0x6014, 0x904d, 0x090c, 0x0db2,
+	0xa87b, 0x0030, 0xa883, 0x0000, 0xa897, 0x4005, 0xa89b, 0x0004,
+	0xa867, 0x0139, 0x0126, 0x2091, 0x8000, 0x080c, 0x6536, 0x012e,
+	0x009e, 0x080c, 0x99d6, 0x0c30, 0x0096, 0x9186, 0x0016, 0x1128,
+	0x2001, 0x0004, 0x080c, 0x5ecf, 0x00e8, 0x9186, 0x0015, 0x1510,
+	0x2011, 0x1822, 0x2204, 0x9086, 0x0014, 0x11e0, 0x6010, 0x00b6,
+	0x2058, 0x080c, 0x6019, 0x00be, 0x080c, 0xa875, 0x1198, 0x6010,
+	0x00b6, 0x2058, 0xb890, 0x00be, 0x9005, 0x0160, 0x2001, 0x0006,
+	0x080c, 0x5ecf, 0x6014, 0x2048, 0xa868, 0xd0fc, 0x0170, 0x080c,
+	0x9dd7, 0x0048, 0x6014, 0x2048, 0xa868, 0xd0fc, 0x0528, 0x080c,
+	0xa364, 0x080c, 0x99d6, 0x009e, 0x0005, 0x6014, 0x6310, 0x2358,
+	0x904d, 0x090c, 0x0db2, 0xa87b, 0x0000, 0xa883, 0x0000, 0xa897,
+	0x4000, 0x900e, 0x080c, 0x619e, 0x1108, 0xc185, 0xb800, 0xd0bc,
+	0x0108, 0xc18d, 0xa99a, 0x0126, 0x2091, 0x8000, 0x080c, 0x6536,
+	0x012e, 0x080c, 0x99d6, 0x08f8, 0x6014, 0x904d, 0x090c, 0x0db2,
+	0xa87b, 0x0030, 0xa883, 0x0000, 0xa897, 0x4005, 0xa89b, 0x0004,
+	0xa867, 0x0139, 0x0126, 0x2091, 0x8000, 0x080c, 0x6536, 0x012e,
+	0x080c, 0x99d6, 0x0840, 0xa878, 0x9086, 0x0005, 0x1108, 0x0009,
+	0x0005, 0xa880, 0xc0ad, 0xa882, 0x0005, 0x6043, 0x0000, 0x6017,
+	0x0000, 0x6003, 0x0001, 0x6007, 0x0050, 0x080c, 0x8000, 0x080c,
+	0x8582, 0x0005, 0x00c6, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be,
+	0xd0bc, 0x0120, 0x6020, 0x9084, 0x000f, 0x0013, 0x00ce, 0x0005,
+	0xb330, 0xb919, 0xb919, 0xb91c, 0xd030, 0xd04b, 0xd04e, 0xb330,
+	0xb330, 0xb330, 0xb330, 0xb330, 0xb330, 0xb330, 0xb330, 0x080c,
+	0x0db2, 0xa001, 0xa001, 0x0005, 0x0096, 0x6014, 0x904d, 0x0118,
+	0xa87c, 0xd0e4, 0x1110, 0x009e, 0x0010, 0x009e, 0x0005, 0x6010,
+	0x00b6, 0x2058, 0xb800, 0x00be, 0xd0bc, 0x0550, 0x2001, 0x1832,
+	0x2004, 0x9005, 0x1540, 0x00f6, 0x2c78, 0x080c, 0x9980, 0x0508,
+	0x7810, 0x6012, 0x080c, 0xba69, 0x7820, 0x9086, 0x0003, 0x0128,
+	0x7808, 0x603a, 0x2f00, 0x603e, 0x0020, 0x7808, 0x603e, 0x2f00,
+	0x603a, 0x602e, 0x6023, 0x0001, 0x6007, 0x0035, 0x6003, 0x0001,
+	0x7954, 0x6156, 0x080c, 0x8000, 0x080c, 0x8582, 0x2f60, 0x00fe,
+	0x0005, 0x2f60, 0x00fe, 0x2001, 0x1957, 0x2004, 0x6042, 0x0005,
+	0x0016, 0x0096, 0x6814, 0x2048, 0xa87c, 0xd0e4, 0x0180, 0xc0e4,
+	0xa87e, 0xa877, 0x0000, 0xa893, 0x0000, 0xa88f, 0x0000, 0xd0cc,
+	0x0130, 0xc0cc, 0xa87e, 0xa878, 0x2048, 0x080c, 0x0f87, 0x6830,
+	0x6036, 0x908e, 0x0001, 0x0148, 0x6803, 0x0002, 0x9086, 0x0005,
+	0x0170, 0x9006, 0x602e, 0x6032, 0x00d0, 0x681c, 0xc085, 0x681e,
+	0x6803, 0x0004, 0x6824, 0xc0f4, 0x9085, 0x0c00, 0x6826, 0x6814,
+	0x2048, 0xa8ac, 0x6938, 0x9102, 0xa8b0, 0x693c, 0x9103, 0x1e48,
+	0x683c, 0x602e, 0x6838, 0x9084, 0xfffc, 0x683a, 0x6032, 0x2d00,
+	0x603a, 0x6808, 0x603e, 0x6910, 0x6112, 0x6954, 0x6156, 0x6023,
+	0x0001, 0x6007, 0x0039, 0x6003, 0x0001, 0x080c, 0x8000, 0x080c,
+	0x8582, 0x009e, 0x001e, 0x0005, 0x6024, 0xd0d4, 0x0510, 0xd0f4,
+	0x11f8, 0x6038, 0x940a, 0x603c, 0x9303, 0x0230, 0x9105, 0x0120,
+	0x6024, 0xc0d4, 0xc0f5, 0x0098, 0x643a, 0x633e, 0xac3e, 0xab42,
+	0x0046, 0x0036, 0x2400, 0xacac, 0x9402, 0xa836, 0x2300, 0xabb0,
+	0x9303, 0xa83a, 0x003e, 0x004e, 0x6024, 0xc0d4, 0x0000, 0x6026,
+	0x0005, 0xd0f4, 0x1138, 0xa83c, 0x603a, 0xa840, 0x603e, 0x6024,
+	0xc0f5, 0x6026, 0x0005, 0x0006, 0x0016, 0x6004, 0x908e, 0x0034,
+	0x01b8, 0x908e, 0x0035, 0x01a0, 0x908e, 0x0036, 0x0188, 0x908e,
+	0x0037, 0x0170, 0x908e, 0x0038, 0x0158, 0x908e, 0x0039, 0x0140,
+	0x908e, 0x003a, 0x0128, 0x908e, 0x003b, 0x0110, 0x9085, 0x0001,
+	0x001e, 0x000e, 0x0005, 0x0006, 0x0016, 0x0026, 0x0036, 0x00e6,
+	0x2001, 0x1951, 0x200c, 0x8000, 0x2014, 0x2001, 0x0032, 0x080c,
+	0x7e7f, 0x2001, 0x1955, 0x82ff, 0x1110, 0x2011, 0x0014, 0x2202,
+	0x2001, 0x1953, 0x200c, 0x8000, 0x2014, 0x2071, 0x193d, 0x711a,
+	0x721e, 0x2001, 0x0064, 0x080c, 0x7e7f, 0x2001, 0x1956, 0x82ff,
+	0x1110, 0x2011, 0x0014, 0x2202, 0x2001, 0x1957, 0x9288, 0x000a,
+	0x2102, 0x2001, 0x1a55, 0x2102, 0x2001, 0x0032, 0x080c, 0x14d2,
+	0x080c, 0x6285, 0x00ee, 0x003e, 0x002e, 0x001e, 0x000e, 0x0005,
+	0x0006, 0x0016, 0x00e6, 0x2001, 0x1955, 0x2003, 0x0028, 0x2001,
+	0x1956, 0x2003, 0x0014, 0x2071, 0x193d, 0x701b, 0x0000, 0x701f,
+	0x07d0, 0x2001, 0x1957, 0x2009, 0x001e, 0x2102, 0x2001, 0x1a55,
+	0x2102, 0x2001, 0x0032, 0x080c, 0x14d2, 0x00ee, 0x001e, 0x000e,
+	0x0005, 0x0096, 0x6058, 0x904d, 0x0110, 0x080c, 0x1007, 0x009e,
+	0x0005, 0x0005, 0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0x9980,
+	0x0180, 0x2b08, 0x6112, 0x0ca9, 0x6023, 0x0001, 0x2900, 0x6016,
+	0x2009, 0x0033, 0x080c, 0x9a50, 0x9085, 0x0001, 0x012e, 0x00ce,
+	0x0005, 0x9006, 0x0cd8, 0x0096, 0x00e6, 0x00f6, 0x2071, 0x1800,
+	0x9186, 0x0015, 0x1500, 0x7088, 0x9086, 0x0018, 0x11e0, 0x6014,
+	0x2048, 0xaa3c, 0xd2e4, 0x1160, 0x2c78, 0x080c, 0x8772, 0x01d8,
+	0x7074, 0xaa50, 0x9206, 0x1160, 0x7078, 0xaa54, 0x9206, 0x1140,
+	0x6210, 0x00b6, 0x2258, 0xbaa0, 0x00be, 0x900e, 0x080c, 0x2e75,
+	0x080c, 0x9dd7, 0x0020, 0x080c, 0xa364, 0x080c, 0x99d6, 0x00fe,
+	0x00ee, 0x009e, 0x0005, 0x7058, 0xaa54, 0x9206, 0x0d48, 0x0c80,
+	0x00c6, 0x0126, 0x2091, 0x8000, 0x080c, 0x9980, 0x0188, 0x2b08,
+	0x6112, 0x080c, 0xba69, 0x6023, 0x0001, 0x2900, 0x6016, 0x2009,
+	0x004d, 0x080c, 0x9a50, 0x9085, 0x0001, 0x012e, 0x00ce, 0x0005,
+	0x9006, 0x0cd8, 0x00c6, 0x0126, 0x2091, 0x8000, 0x0016, 0x080c,
+	0x9980, 0x0180, 0x2b08, 0x6112, 0x080c, 0xba69, 0x6023, 0x0001,
+	0x2900, 0x6016, 0x001e, 0x080c, 0x9a50, 0x9085, 0x0001, 0x012e,
+	0x00ce, 0x0005, 0x001e, 0x9006, 0x0cd0, 0x0016, 0x0026, 0x0036,
+	0x0046, 0x0056, 0x0066, 0x0096, 0x00e6, 0x00f6, 0x2071, 0x1800,
+	0x9186, 0x0015, 0x1568, 0x7188, 0x6014, 0x2048, 0xa814, 0x8003,
+	0x9106, 0x1530, 0x20e1, 0x0000, 0x2001, 0x196f, 0x2003, 0x0000,
+	0x6014, 0x2048, 0xa830, 0x20a8, 0x8906, 0x8006, 0x8007, 0x9094,
+	0x003f, 0x22e8, 0x9084, 0xffc0, 0x9080, 0x001b, 0x20a0, 0x2001,
+	0x196f, 0x0016, 0x200c, 0x080c, 0xc29a, 0x001e, 0xa804, 0x9005,
+	0x0110, 0x2048, 0x0c38, 0x6014, 0x2048, 0xa867, 0x0103, 0x0010,
+	0x080c, 0xa364, 0x080c, 0x99d6, 0x00fe, 0x00ee, 0x009e, 0x006e,
+	0x005e, 0x004e, 0x003e, 0x002e, 0x001e, 0x0005, 0x0096, 0x00e6,
+	0x00f6, 0x2071, 0x1800, 0x9186, 0x0015, 0x11b8, 0x7088, 0x9086,
+	0x0004, 0x1198, 0x6014, 0x2048, 0x2c78, 0x080c, 0x8772, 0x01a8,
+	0x7074, 0xaa74, 0x9206, 0x1130, 0x7078, 0xaa78, 0x9206, 0x1110,
+	0x080c, 0x2e30, 0x080c, 0x9dd7, 0x0020, 0x080c, 0xa364, 0x080c,
+	0x99d6, 0x00fe, 0x00ee, 0x009e, 0x0005, 0x7058, 0xaa78, 0x9206,
+	0x0d78, 0x0c80, 0x0096, 0x00e6, 0x00f6, 0x2071, 0x1800, 0x9186,
+	0x0015, 0x1550, 0x7088, 0x9086, 0x0004, 0x1530, 0x6014, 0x2048,
+	0x2c78, 0x080c, 0x8772, 0x05e8, 0x7074, 0xaacc, 0x9206, 0x1180,
+	0x7078, 0xaad0, 0x9206, 0x1160, 0x080c, 0x2e30, 0x0016, 0xa998,
+	0xaab0, 0x9284, 0x1000, 0xc0fd, 0x080c, 0x50cb, 0x001e, 0x0010,
+	0x080c, 0x4ebc, 0x080c, 0xb5fb, 0x0500, 0xa87b, 0x0000, 0xa883,
+	0x0000, 0xa897, 0x4000, 0x0078, 0x080c, 0x4ebc, 0x080c, 0xb5fb,
+	0x01a0, 0x6014, 0x2048, 0xa87b, 0x0030, 0xa883, 0x0000, 0xa897,
+	0x4005, 0xa89b, 0x0004, 0x0126, 0x2091, 0x8000, 0xa867, 0x0139,
+	0x080c, 0x6536, 0x012e, 0x080c, 0x99d6, 0x00fe, 0x00ee, 0x009e,
+	0x0005, 0x7058, 0xaad0, 0x9206, 0x0938, 0x0890, 0x0016, 0x0026,
+	0xa87c, 0xd0ac, 0x0178, 0xa938, 0xaa34, 0x2100, 0x9205, 0x0150,
+	0xa890, 0x9106, 0x1118, 0xa88c, 0x9206, 0x0120, 0xa992, 0xaa8e,
+	0x9085, 0x0001, 0x002e, 0x001e, 0x0005, 0x00b6, 0x00d6, 0x0036,
+	0x080c, 0xb5fb, 0x0904, 0xbc23, 0x0096, 0x6314, 0x2348, 0xa87a,
+	0xa982, 0x929e, 0x4000, 0x1580, 0x6310, 0x00c6, 0x2358, 0x2009,
+	0x0000, 0xa868, 0xd0f4, 0x1140, 0x080c, 0x619e, 0x1108, 0xc185,
+	0xb800, 0xd0bc, 0x0108, 0xc18d, 0xaa96, 0xa99a, 0x20a9, 0x0004,
+	0xa860, 0x20e8, 0xa85c, 0x9080, 0x0031, 0x20a0, 0xb8b4, 0x20e0,
+	0xb8b8, 0x9080, 0x0006, 0x2098, 0x080c, 0x0f52, 0x20a9, 0x0004,
+	0xa85c, 0x9080, 0x0035, 0x20a0, 0xb8b8, 0x9080, 0x000a, 0x2098,
+	0x080c, 0x0f52, 0x00ce, 0x0090, 0xaa96, 0x3918, 0x9398, 0x0007,
+	0x231c, 0x6004, 0x9086, 0x0016, 0x0110, 0xa89b, 0x0004, 0xaba2,
+	0x6310, 0x2358, 0xb804, 0x9084, 0x00ff, 0xa89e, 0x080c, 0x6529,
+	0x6017, 0x0000, 0x009e, 0x003e, 0x00de, 0x00be, 0x0005, 0x0026,
+	0x0036, 0x0046, 0x00b6, 0x0096, 0x00f6, 0x6214, 0x2248, 0x6210,
+	0x2258, 0x2079, 0x0260, 0x9096, 0x0000, 0x11a0, 0xb814, 0x9084,
+	0x00ff, 0x900e, 0x080c, 0x24d6, 0x2118, 0x831f, 0x939c, 0xff00,
+	0x7838, 0x9084, 0x00ff, 0x931d, 0x7c3c, 0x2011, 0x8018, 0x080c,
+	0x4672, 0x00a8, 0x9096, 0x0001, 0x1148, 0x89ff, 0x0180, 0xa89b,
+	0x000d, 0x7838, 0xa8a6, 0x783c, 0xa8aa, 0x0048, 0x9096, 0x0002,
+	0x1130, 0xa89b, 0x000d, 0x7838, 0xa8a6, 0x783c, 0xa8aa, 0x00fe,
+	0x009e, 0x00be, 0x004e, 0x003e, 0x002e, 0x0005, 0x00c6, 0x0026,
+	0x0016, 0x9186, 0x0035, 0x0110, 0x6a38, 0x0008, 0x6a2c, 0x080c,
+	0xb5e9, 0x01f0, 0x2260, 0x6120, 0x9186, 0x0003, 0x0118, 0x9186,
+	0x0006, 0x1190, 0x6838, 0x9206, 0x0140, 0x683c, 0x9206, 0x1160,
+	0x6108, 0x6838, 0x9106, 0x1140, 0x0020, 0x6008, 0x693c, 0x9106,
+	0x1118, 0x6010, 0x6910, 0x9106, 0x001e, 0x002e, 0x00ce, 0x0005,
+	0x9085, 0x0001, 0x0cc8, 0xa974, 0xd1cc, 0x0188, 0x918c, 0x00ff,
+	0x918e, 0x0002, 0x1160, 0xa9a8, 0x918c, 0x0f00, 0x810f, 0x918e,
+	0x0001, 0x1128, 0xa834, 0xa938, 0x9115, 0x190c, 0xad37, 0x0005,
+	0x0036, 0x2019, 0x0001, 0x0010, 0x0036, 0x901e, 0x0489, 0x01d0,
+	0x080c, 0xb5fb, 0x01b8, 0x6037, 0x4000, 0x6014, 0x6017, 0x0000,
+	0x0096, 0x2048, 0xa87c, 0x080c, 0xb7fa, 0x1118, 0x080c, 0xa364,
+	0x0040, 0xa867, 0x0103, 0xa877, 0x0000, 0x83ff, 0x1129, 0x080c,
+	0x6536, 0x009e, 0x003e, 0x0005, 0xa880, 0xd0b4, 0x0128, 0xa87b,
+	0x0006, 0xc0ec, 0xa882, 0x0048, 0xd0bc, 0x0118, 0xa87b, 0x0002,
+	0x0020, 0xa87b, 0x0005, 0x080c, 0xb8e9, 0xa877, 0x0000, 0x0005,
+	0x2001, 0x180f, 0x2004, 0xd0ec, 0x0005, 0x0006, 0x2001, 0x180f,
+	0x2004, 0xd0f4, 0x000e, 0x0005, 0x0006, 0x2001, 0x180f, 0x2004,
+	0xd0e4, 0x000e, 0x0005, 0x0036, 0x0046, 0x6010, 0x00b6, 0x2058,
+	0xbba0, 0x00be, 0x2021, 0x0007, 0x080c, 0x4829, 0x004e, 0x003e,
+	0x0005, 0x0c51, 0x1d81, 0x0005, 0x2001, 0x1955, 0x2004, 0x601a,
+	0x0005, 0x2001, 0x1957, 0x2004, 0x6042, 0x0005, 0x080c, 0x99d6,
+	0x0804, 0x8582, 0x00b6, 0x0066, 0x6000, 0x90b2, 0x0016, 0x1a0c,
+	0x0db2, 0x001b, 0x006e, 0x00be, 0x0005, 0xbd2d, 0xc3f7, 0xc552,
+	0xbd2d, 0xbd2d, 0xbd2d, 0xbd2d, 0xbd2d, 0xbd64, 0xc5d0, 0xbd2d,
+	0xbd2d, 0xbd2d, 0xbd2d, 0xbd2d, 0xbd2d, 0x080c, 0x0db2, 0x0066,
+	0x6000, 0x90b2, 0x0016, 0x1a0c, 0x0db2, 0x0013, 0x006e, 0x0005,
+	0xbd48, 0xcb38, 0xbd48, 0xbd48, 0xbd48, 0xbd48, 0xbd48, 0xbd48,
+	0xcae5, 0xcb8c, 0xbd48, 0xd16d, 0xd1a3, 0xd16d, 0xd1a3, 0xbd48,
+	0x080c, 0x0db2, 0x6000, 0x9082, 0x0016, 0x1a0c, 0x0db2, 0x6000,
+	0x000a, 0x0005, 0xbd62, 0xc7ad, 0xc89d, 0xc8bf, 0xc97e, 0xbd62,
+	0xca5c, 0xca06, 0xc5dc, 0xcabb, 0xcad0, 0xbd62, 0xbd62, 0xbd62,
+	0xbd62, 0xbd62, 0x080c, 0x0db2, 0x91b2, 0x0053, 0x1a0c, 0x0db2,
+	0x2100, 0x91b2, 0x0040, 0x1a04, 0xc19a, 0x0002, 0xbdae, 0xbf8b,
+	0xbdae, 0xbdae, 0xbdae, 0xbf94, 0xbdae, 0xbdae, 0xbdae, 0xbdae,
+	0xbdae, 0xbdae, 0xbdae, 0xbdae, 0xbdae, 0xbdae, 0xbdae, 0xbdae,
+	0xbdae, 0xbdae, 0xbdae, 0xbdae, 0xbdae, 0xbdb0, 0xbe06, 0xbe15,
+	0xbe79, 0xbea4, 0xbf1d, 0xbf76, 0xbdae, 0xbdae, 0xbf97, 0xbdae,
+	0xbdae, 0xbfac, 0xbfb9, 0xbdae, 0xbdae, 0xbdae, 0xbdae, 0xbdae,
+	0xc03c, 0xbdae, 0xbdae, 0xc050, 0xbdae, 0xbdae, 0xc00b, 0xbdae,
+	0xbdae, 0xbdae, 0xc068, 0xbdae, 0xbdae, 0xbdae, 0xc0e5, 0xbdae,
+	0xbdae, 0xbdae, 0xbdae, 0xbdae, 0xbdae, 0xc162, 0x080c, 0x0db2,
+	0x080c, 0x6262, 0x1150, 0x2001, 0x1835, 0x2004, 0xd0cc, 0x1128,
+	0x9084, 0x0009, 0x9086, 0x0008, 0x1140, 0x6007, 0x0009, 0x602f,
+	0x0009, 0x6017, 0x0000, 0x0804, 0xbf84, 0x080c, 0x624b, 0x00e6,
+	0x00c6, 0x0036, 0x0026, 0x0016, 0x6210, 0x2258, 0xbaa0, 0x0026,
+	0x2019, 0x0029, 0x080c, 0x8180, 0x0076, 0x903e, 0x080c, 0x8078,
+	0x2c08, 0x080c, 0xcd62, 0x007e, 0x001e, 0x001e, 0x002e, 0x003e,
+	0x00ce, 0x00ee, 0x6610, 0x2658, 0x080c, 0x5f8d, 0xbe04, 0x9684,
+	0x00ff, 0x9082, 0x0006, 0x0278, 0x080c, 0xcc94, 0x1904, 0xbe71,
+	0x080c, 0xcc30, 0x1120, 0x6007, 0x0008, 0x0804, 0xbf84, 0x6007,
+	0x0009, 0x0804, 0xbf84, 0x080c, 0xce81, 0x0128, 0x080c, 0xcc94,
+	0x0d78, 0x0804, 0xbe71, 0x6017, 0x1900, 0x0c88, 0x080c, 0x2f50,
+	0x1904, 0xc197, 0x6106, 0x080c, 0xcbe7, 0x6007, 0x0006, 0x0804,
+	0xbf84, 0x6007, 0x0007, 0x0804, 0xbf84, 0x080c, 0xd1df, 0x1904,
+	0xc197, 0x080c, 0x2f50, 0x1904, 0xc197, 0x00d6, 0x6610, 0x2658,
+	0xbe04, 0x9684, 0x00ff, 0x9082, 0x0006, 0x1220, 0x2001, 0x0001,
+	0x080c, 0x5ebb, 0x96b4, 0xff00, 0x8637, 0x9686, 0x0006, 0x0188,
+	0x9686, 0x0004, 0x0170, 0xbe04, 0x96b4, 0x00ff, 0x9686, 0x0006,
+	0x0140, 0x9686, 0x0004, 0x0128, 0x9686, 0x0005, 0x0110, 0x00de,
+	0x0480, 0x00e6, 0x2071, 0x0260, 0x7034, 0x9084, 0x0003, 0x1140,
+	0x7034, 0x9082, 0x0014, 0x0220, 0x7030, 0x9084, 0x0003, 0x0130,
+	0x00ee, 0x6017, 0x0000, 0x602f, 0x0007, 0x00b0, 0x00ee, 0x080c,
+	0xccf8, 0x1190, 0x9686, 0x0006, 0x1140, 0x0026, 0x6210, 0x2258,
+	0xbaa0, 0x900e, 0x080c, 0x2e75, 0x002e, 0x080c, 0x6019, 0x6007,
+	0x000a, 0x00de, 0x0804, 0xbf84, 0x6007, 0x000b, 0x00de, 0x0804,
+	0xbf84, 0x080c, 0x2e30, 0x080c, 0xbd01, 0x6007, 0x0001, 0x0804,
+	0xbf84, 0x080c, 0xd1df, 0x1904, 0xc197, 0x080c, 0x2f50, 0x1904,
+	0xc197, 0x2071, 0x0260, 0x7034, 0x90b4, 0x0003, 0x1948, 0x90b2,
+	0x0014, 0x0a30, 0x7030, 0x9084, 0x0003, 0x1910, 0x6610, 0x2658,
+	0xbe04, 0x9686, 0x0707, 0x09e8, 0x0026, 0x6210, 0x2258, 0xbaa0,
+	0x900e, 0x080c, 0x2e75, 0x002e, 0x6007, 0x000c, 0x2001, 0x0001,
+	0x080c, 0xd2fb, 0x0804, 0xbf84, 0x080c, 0x6262, 0x1140, 0x2001,
+	0x1835, 0x2004, 0x9084, 0x0009, 0x9086, 0x0008, 0x1110, 0x0804,
+	0xbdbd, 0x080c, 0x624b, 0x6610, 0x2658, 0xbe04, 0x9684, 0x00ff,
+	0x9082, 0x0006, 0x06c8, 0x1138, 0x0026, 0x2001, 0x0006, 0x080c,
+	0x5efb, 0x002e, 0x0050, 0x96b4, 0xff00, 0x8637, 0x9686, 0x0004,
+	0x0120, 0x9686, 0x0006, 0x1904, 0xbe71, 0x080c, 0xcd05, 0x1120,
+	0x6007, 0x000e, 0x0804, 0xbf84, 0x0046, 0x6410, 0x2458, 0xbca0,
+	0x0046, 0x080c, 0x2e30, 0x080c, 0xbd01, 0x004e, 0x0016, 0x9006,
+	0x2009, 0x1854, 0x210c, 0xd1a4, 0x0148, 0x2009, 0x0029, 0x080c,
+	0xcfe6, 0x6010, 0x2058, 0xb800, 0xc0e5, 0xb802, 0x001e, 0x004e,
+	0x6007, 0x0001, 0x0804, 0xbf84, 0x2001, 0x0001, 0x080c, 0x5ebb,
+	0x0156, 0x0016, 0x0026, 0x0036, 0x20a9, 0x0004, 0x2019, 0x1805,
+	0x2011, 0x0270, 0x080c, 0xa909, 0x003e, 0x002e, 0x001e, 0x015e,
+	0x9005, 0x0168, 0x96b4, 0xff00, 0x8637, 0x9682, 0x0004, 0x0a04,
+	0xbe71, 0x9682, 0x0007, 0x0a04, 0xbecd, 0x0804, 0xbe71, 0x6017,
+	0x1900, 0x6007, 0x0009, 0x0804, 0xbf84, 0x080c, 0x6262, 0x1140,
+	0x2001, 0x1835, 0x2004, 0x9084, 0x0009, 0x9086, 0x0008, 0x1110,
+	0x0804, 0xbdbd, 0x080c, 0x624b, 0x6610, 0x2658, 0xbe04, 0x9684,
+	0x00ff, 0x9082, 0x0006, 0x0690, 0x96b4, 0xff00, 0x8637, 0x9686,
+	0x0004, 0x0120, 0x9686, 0x0006, 0x1904, 0xbe71, 0x080c, 0xcd33,
+	0x1130, 0x080c, 0xcc30, 0x1118, 0x6007, 0x0010, 0x04e8, 0x0046,
+	0x6410, 0x2458, 0xbca0, 0x0046, 0x080c, 0x2e30, 0x080c, 0xbd01,
+	0x004e, 0x0016, 0x9006, 0x2009, 0x1854, 0x210c, 0xd1a4, 0x0148,
+	0x2009, 0x0029, 0x080c, 0xcfe6, 0x6010, 0x2058, 0xb800, 0xc0e5,
+	0xb802, 0x001e, 0x004e, 0x6007, 0x0001, 0x00f0, 0x080c, 0xce81,
+	0x0140, 0x96b4, 0xff00, 0x8637, 0x9686, 0x0006, 0x0978, 0x0804,
+	0xbe71, 0x6017, 0x1900, 0x6007, 0x0009, 0x0070, 0x080c, 0x2f50,
+	0x1904, 0xc197, 0x080c, 0xd1df, 0x1904, 0xc197, 0x080c, 0xc335,
+	0x1904, 0xbe71, 0x6007, 0x0012, 0x6003, 0x0001, 0x080c, 0x8048,
+	0x080c, 0x8582, 0x0005, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c,
+	0x8048, 0x080c, 0x8582, 0x0cb0, 0x6007, 0x0005, 0x0c68, 0x080c,
+	0xd1df, 0x1904, 0xc197, 0x080c, 0x2f50, 0x1904, 0xc197, 0x080c,
+	0xc335, 0x1904, 0xbe71, 0x6007, 0x0020, 0x6003, 0x0001, 0x080c,
+	0x8048, 0x080c, 0x8582, 0x0005, 0x080c, 0x2f50, 0x1904, 0xc197,
+	0x6007, 0x0023, 0x6003, 0x0001, 0x080c, 0x8048, 0x080c, 0x8582,
+	0x0005, 0x080c, 0xd1df, 0x1904, 0xc197, 0x080c, 0x2f50, 0x1904,
+	0xc197, 0x080c, 0xc335, 0x1904, 0xbe71, 0x0016, 0x0026, 0x00e6,
+	0x2071, 0x0260, 0x7244, 0x9286, 0xffff, 0x0180, 0x2c08, 0x080c,
+	0xb5e9, 0x01b0, 0x2260, 0x7240, 0x6008, 0x9206, 0x1188, 0x6010,
+	0x9190, 0x0004, 0x2214, 0x9206, 0x01b8, 0x0050, 0x7240, 0x2c08,
+	0x9006, 0x080c, 0xcfb8, 0x1180, 0x7244, 0x9286, 0xffff, 0x01b0,
+	0x2160, 0x6007, 0x0026, 0x6017, 0x1700, 0x7214, 0x9296, 0xffff,
+	0x1180, 0x6007, 0x0025, 0x0068, 0x6020, 0x9086, 0x0007, 0x1d80,
+	0x6004, 0x9086, 0x0024, 0x1110, 0x080c, 0x99d6, 0x2160, 0x6007,
+	0x0025, 0x6003, 0x0001, 0x080c, 0x8048, 0x080c, 0x8582, 0x00ee,
+	0x002e, 0x001e, 0x0005, 0x2001, 0x0001, 0x080c, 0x5ebb, 0x0156,
+	0x0016, 0x0026, 0x0036, 0x20a9, 0x0004, 0x2019, 0x1805, 0x2011,
+	0x0276, 0x080c, 0xa909, 0x003e, 0x002e, 0x001e, 0x015e, 0x0120,
+	0x6007, 0x0031, 0x0804, 0xbf84, 0x080c, 0xa5c2, 0x080c, 0x6c53,
+	0x1190, 0x0006, 0x0026, 0x0036, 0x080c, 0x6c6d, 0x1138, 0x080c,
+	0x6f2a, 0x080c, 0x5a21, 0x080c, 0x6b8a, 0x0010, 0x080c, 0x6c2d,
+	0x003e, 0x002e, 0x000e, 0x0005, 0x080c, 0x2f50, 0x1904, 0xc197,
+	0x080c, 0xc335, 0x1904, 0xbe71, 0x6106, 0x080c, 0xc351, 0x1120,
+	0x6007, 0x002b, 0x0804, 0xbf84, 0x6007, 0x002c, 0x0804, 0xbf84,
+	0x080c, 0xd1df, 0x1904, 0xc197, 0x080c, 0x2f50, 0x1904, 0xc197,
+	0x080c, 0xc335, 0x1904, 0xbe71, 0x6106, 0x080c, 0xc356, 0x1120,
+	0x6007, 0x002e, 0x0804, 0xbf84, 0x6007, 0x002f, 0x0804, 0xbf84,
+	0x080c, 0x2f50, 0x1904, 0xc197, 0x00e6, 0x00d6, 0x00c6, 0x6010,
+	0x2058, 0xb904, 0x9184, 0x00ff, 0x9086, 0x0006, 0x0158, 0x9184,
+	0xff00, 0x8007, 0x9086, 0x0006, 0x0128, 0x00ce, 0x00de, 0x00ee,
+	0x0804, 0xbf8b, 0x080c, 0x5117, 0xd0e4, 0x0904, 0xc0e2, 0x2071,
+	0x026c, 0x7010, 0x603a, 0x7014, 0x603e, 0x7108, 0x720c, 0x080c,
+	0x62a0, 0x0140, 0x6010, 0x2058, 0xb810, 0x9106, 0x1118, 0xb814,
+	0x9206, 0x0510, 0x080c, 0x629c, 0x15b8, 0x2069, 0x1800, 0x6878,
+	0x9206, 0x1590, 0x6874, 0x9106, 0x1578, 0x7210, 0x080c, 0xb5e9,
+	0x0590, 0x080c, 0xc222, 0x0578, 0x080c, 0xd05d, 0x0560, 0x622e,
+	0x6007, 0x0036, 0x6003, 0x0001, 0x080c, 0x8000, 0x080c, 0x8582,
+	0x00ce, 0x00de, 0x00ee, 0x0005, 0x7214, 0x9286, 0xffff, 0x0150,
+	0x080c, 0xb5e9, 0x01c0, 0x9280, 0x0002, 0x2004, 0x7110, 0x9106,
+	0x1190, 0x08e0, 0x7210, 0x2c08, 0x9085, 0x0001, 0x080c, 0xcfb8,
+	0x2c10, 0x2160, 0x0140, 0x0890, 0x6007, 0x0037, 0x602f, 0x0009,
+	0x6017, 0x1500, 0x08b8, 0x6007, 0x0037, 0x602f, 0x0003, 0x6017,
+	0x1700, 0x0880, 0x6007, 0x0012, 0x0868, 0x080c, 0x2f50, 0x1904,
+	0xc197, 0x6010, 0x2058, 0xb804, 0x9084, 0xff00, 0x8007, 0x9086,
+	0x0006, 0x1904, 0xbf8b, 0x00e6, 0x00d6, 0x00c6, 0x080c, 0x5117,
+	0xd0e4, 0x0904, 0xc15a, 0x2069, 0x1800, 0x2071, 0x026c, 0x7008,
+	0x603a, 0x720c, 0x623e, 0x9286, 0xffff, 0x1150, 0x7208, 0x00c6,
+	0x2c08, 0x9085, 0x0001, 0x080c, 0xcfb8, 0x2c10, 0x00ce, 0x05e8,
+	0x080c, 0xb5e9, 0x05d0, 0x7108, 0x9280, 0x0002, 0x2004, 0x9106,
+	0x15a0, 0x00c6, 0x0026, 0x2260, 0x080c, 0xb244, 0x002e, 0x00ce,
+	0x7118, 0x918c, 0xff00, 0x810f, 0x9186, 0x0001, 0x0178, 0x9186,
+	0x0005, 0x0118, 0x9186, 0x0007, 0x1198, 0x9280, 0x0005, 0x2004,
+	0x9005, 0x0170, 0x080c, 0xc222, 0x0904, 0xc0db, 0x0056, 0x7510,
+	0x7614, 0x080c, 0xd076, 0x005e, 0x00ce, 0x00de, 0x00ee, 0x0005,
+	0x6007, 0x003b, 0x602f, 0x0009, 0x6017, 0x2a00, 0x6003, 0x0001,
+	0x080c, 0x8000, 0x080c, 0x8582, 0x0c78, 0x6007, 0x003b, 0x602f,
+	0x0003, 0x6017, 0x0300, 0x6003, 0x0001, 0x080c, 0x8000, 0x080c,
+	0x8582, 0x0c10, 0x6007, 0x003b, 0x602f, 0x000b, 0x6017, 0x0000,
+	0x0804, 0xc0b2, 0x00e6, 0x0026, 0x080c, 0x6262, 0x0550, 0x080c,
+	0x624b, 0x080c, 0xd251, 0x1518, 0x2071, 0x1800, 0x70d4, 0x9085,
+	0x0003, 0x70d6, 0x00f6, 0x2079, 0x0100, 0x72a8, 0x9284, 0x00ff,
+	0x7076, 0x78e6, 0x9284, 0xff00, 0x7278, 0x9205, 0x707a, 0x78ea,
+	0x00fe, 0x70df, 0x0000, 0x080c, 0x62a0, 0x0120, 0x2011, 0x19cf,
+	0x2013, 0x07d0, 0xd0ac, 0x1128, 0x080c, 0x2c2b, 0x0010, 0x080c,
+	0xd283, 0x002e, 0x00ee, 0x080c, 0x99d6, 0x0804, 0xbf8a, 0x080c,
+	0x99d6, 0x0005, 0x2600, 0x0002, 0xc1ae, 0xc1ae, 0xc1ae, 0xc1ae,
+	0xc1ae, 0xc1b0, 0xc1ae, 0xc1ae, 0xc1ae, 0xc1ae, 0xc1cd, 0xc1ae,
+	0xc1ae, 0xc1ae, 0xc1df, 0xc1ec, 0xc21d, 0xc1ae, 0x080c, 0x0db2,
+	0x080c, 0xd1df, 0x1d20, 0x080c, 0x2f50, 0x1d08, 0x080c, 0xc335,
+	0x1148, 0x7038, 0x6016, 0x6007, 0x0045, 0x6003, 0x0001, 0x080c,
+	0x8048, 0x0005, 0x080c, 0x2e30, 0x080c, 0xbd01, 0x6007, 0x0001,
+	0x6003, 0x0001, 0x080c, 0x8048, 0x0005, 0x080c, 0xd1df, 0x1938,
+	0x080c, 0x2f50, 0x1920, 0x080c, 0xc335, 0x1d60, 0x703c, 0x6016,
+	0x6007, 0x004a, 0x6003, 0x0001, 0x080c, 0x8048, 0x0005, 0x080c,
+	0xc23d, 0x0904, 0xc197, 0x6007, 0x004e, 0x6003, 0x0001, 0x080c,
+	0x8048, 0x080c, 0x8582, 0x0005, 0x6007, 0x004f, 0x6017, 0x0000,
+	0x7134, 0x918c, 0x00ff, 0x81ff, 0x0508, 0x9186, 0x0001, 0x1160,
+	0x7140, 0x2001, 0x198c, 0x2004, 0x9106, 0x11b0, 0x7144, 0x2001,
+	0x198d, 0x2004, 0x9106, 0x0190, 0x9186, 0x0002, 0x1168, 0x2011,
+	0x0276, 0x20a9, 0x0004, 0x6010, 0x0096, 0x2048, 0x2019, 0x000a,
+	0x080c, 0xa91d, 0x009e, 0x0110, 0x6017, 0x0001, 0x6003, 0x0001,
+	0x080c, 0x8048, 0x080c, 0x8582, 0x0005, 0x6007, 0x0050, 0x703c,
+	0x6016, 0x0ca0, 0x00e6, 0x2071, 0x0260, 0x00b6, 0x00c6, 0x2260,
+	0x6010, 0x2058, 0xb8bc, 0xd084, 0x0150, 0x7128, 0x6048, 0x9106,
+	0x1120, 0x712c, 0x6044, 0x9106, 0x0110, 0x9006, 0x0010, 0x9085,
+	0x0001, 0x00ce, 0x00be, 0x00ee, 0x0005, 0x0016, 0x0096, 0x0086,
+	0x00e6, 0x01c6, 0x01d6, 0x0126, 0x2091, 0x8000, 0x2071, 0x1800,
+	0x7088, 0x908a, 0x00f9, 0x16e8, 0x20e1, 0x0000, 0x2001, 0x196f,
+	0x2003, 0x0000, 0x080c, 0x0fee, 0x05a0, 0x2900, 0x6016, 0x7088,
+	0x8004, 0xa816, 0x908a, 0x001e, 0x02d0, 0xa833, 0x001e, 0x20a9,
+	0x001e, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x001b, 0x20a0, 0x2001,
+	0x196f, 0x0016, 0x200c, 0x0471, 0x001e, 0x2940, 0x080c, 0x0fee,
+	0x01c0, 0x2900, 0xa006, 0x2100, 0x81ff, 0x0180, 0x0c18, 0xa832,
+	0x20a8, 0xa860, 0x20e8, 0xa85c, 0x9080, 0x001b, 0x20a0, 0x2001,
+	0x196f, 0x0016, 0x200c, 0x00b1, 0x001e, 0x0000, 0x9085, 0x0001,
+	0x0048, 0x2071, 0x1800, 0x708b, 0x0000, 0x6014, 0x2048, 0x080c,
+	0x0f87, 0x9006, 0x012e, 0x01de, 0x01ce, 0x00ee, 0x008e, 0x009e,
+	0x001e, 0x0005, 0x0006, 0x0016, 0x0026, 0x0036, 0x00c6, 0x918c,
+	0xffff, 0x11a8, 0x080c, 0x20b2, 0x2099, 0x026c, 0x2001, 0x0014,
+	0x3518, 0x9312, 0x1218, 0x23a8, 0x4003, 0x00f8, 0x20a8, 0x4003,
+	0x22a8, 0x8108, 0x080c, 0x20b2, 0x2099, 0x0260, 0x0ca8, 0x080c,
+	0x20b2, 0x2061, 0x196f, 0x6004, 0x2098, 0x6008, 0x3518, 0x9312,
+	0x1218, 0x23a8, 0x4003, 0x0048, 0x20a8, 0x4003, 0x22a8, 0x8108,
+	0x080c, 0x20b2, 0x2099, 0x0260, 0x0ca8, 0x2061, 0x196f, 0x2019,
+	0x0280, 0x3300, 0x931e, 0x0110, 0x6006, 0x0020, 0x2001, 0x0260,
+	0x6006, 0x8108, 0x2162, 0x9292, 0x0021, 0x9296, 0xffff, 0x620a,
+	0x00ce, 0x003e, 0x002e, 0x001e, 0x000e, 0x0005, 0x0006, 0x0016,
+	0x0026, 0x0036, 0x00c6, 0x81ff, 0x11b8, 0x080c, 0x20ca, 0x20a1,
+	0x024c, 0x2001, 0x0014, 0x3518, 0x9312, 0x1218, 0x23a8, 0x4003,
+	0x0418, 0x20a8, 0x4003, 0x82ff, 0x01f8, 0x22a8, 0x8108, 0x080c,
+	0x20ca, 0x20a1, 0x0240, 0x0c98, 0x080c, 0x20ca, 0x2061, 0x1972,
+	0x6004, 0x20a0, 0x6008, 0x3518, 0x9312, 0x1218, 0x23a8, 0x4003,
+	0x0058, 0x20a8, 0x4003, 0x82ff, 0x0138, 0x22a8, 0x8108, 0x080c,
+	0x20ca, 0x20a1, 0x0240, 0x0c98, 0x2061, 0x1972, 0x2019, 0x0260,
+	0x3400, 0x931e, 0x0110, 0x6006, 0x0020, 0x2001, 0x0240, 0x6006,
+	0x8108, 0x2162, 0x9292, 0x0021, 0x9296, 0xffff, 0x620a, 0x00ce,
+	0x003e, 0x002e, 0x001e, 0x000e, 0x0005, 0x00b6, 0x0066, 0x6610,
+	0x2658, 0xbe04, 0x96b4, 0xff00, 0x8637, 0x9686, 0x0006, 0x0170,
+	0x9686, 0x0004, 0x0158, 0xbe04, 0x96b4, 0x00ff, 0x9686, 0x0006,
+	0x0128, 0x9686, 0x0004, 0x0110, 0x9085, 0x0001, 0x006e, 0x00be,
+	0x0005, 0x00d6, 0x080c, 0xc3cd, 0x00de, 0x0005, 0x00d6, 0x080c,
+	0xc3da, 0x1520, 0x680c, 0x908c, 0xff00, 0x6820, 0x9084, 0x00ff,
+	0x9115, 0x6216, 0x6824, 0x602e, 0xd1e4, 0x0130, 0x9006, 0x080c,
+	0xd2fb, 0x2009, 0x0001, 0x0078, 0xd1ec, 0x0180, 0x6920, 0x918c,
+	0x00ff, 0x6824, 0x080c, 0x24d6, 0x1148, 0x2001, 0x0001, 0x080c,
+	0xd2fb, 0x2110, 0x900e, 0x080c, 0x2e75, 0x0018, 0x9085, 0x0001,
+	0x0008, 0x9006, 0x00de, 0x0005, 0x00b6, 0x00c6, 0x080c, 0x9a23,
+	0x05a8, 0x0016, 0x0026, 0x00c6, 0x2011, 0x0263, 0x2204, 0x8211,
+	0x220c, 0x080c, 0x24d6, 0x1578, 0x080c, 0x5f1e, 0x1560, 0xbe12,
+	0xbd16, 0x00ce, 0x002e, 0x001e, 0x2b00, 0x6012, 0x080c, 0xd1df,
+	0x11d8, 0x080c, 0x2f50, 0x11c0, 0x080c, 0xc335, 0x0510, 0x2001,
+	0x0007, 0x080c, 0x5ecf, 0x2001, 0x0007, 0x080c, 0x5efb, 0x6017,
+	0x0000, 0x6023, 0x0001, 0x6007, 0x0001, 0x6003, 0x0001, 0x080c,
+	0x8048, 0x080c, 0x8582, 0x0010, 0x080c, 0x99d6, 0x9085, 0x0001,
+	0x00ce, 0x00be, 0x0005, 0x080c, 0x99d6, 0x00ce, 0x002e, 0x001e,
+	0x0ca8, 0x080c, 0x99d6, 0x9006, 0x0c98, 0x2069, 0x026d, 0x6800,
+	0x9082, 0x0010, 0x1228, 0x6017, 0x0000, 0x9085, 0x0001, 0x0008,
+	0x9006, 0x0005, 0x6017, 0x0000, 0x2069, 0x026c, 0x6808, 0x9084,
+	0xff00, 0x9086, 0x0800, 0x1190, 0x6904, 0x9186, 0x0018, 0x0118,
+	0x9186, 0x0014, 0x1158, 0x810f, 0x6800, 0x9084, 0x00ff, 0x910d,
+	0x615a, 0x908e, 0x0014, 0x0110, 0x908e, 0x0010, 0x0005, 0x6004,
+	0x90b2, 0x0053, 0x1a0c, 0x0db2, 0x91b6, 0x0013, 0x1130, 0x2008,
+	0x91b2, 0x0040, 0x1a04, 0xc522, 0x0092, 0x91b6, 0x0027, 0x0120,
+	0x91b6, 0x0014, 0x190c, 0x0db2, 0x2001, 0x0007, 0x080c, 0x5efb,
+	0x080c, 0x847d, 0x080c, 0x9a06, 0x080c, 0x8582, 0x0005, 0xc457,
+	0xc459, 0xc457, 0xc457, 0xc457, 0xc459, 0xc468, 0xc51b, 0xc4ba,
+	0xc51b, 0xc4cc, 0xc51b, 0xc468, 0xc51b, 0xc513, 0xc51b, 0xc513,
+	0xc51b, 0xc51b, 0xc457, 0xc457, 0xc457, 0xc457, 0xc457, 0xc457,
+	0xc457, 0xc457, 0xc457, 0xc457, 0xc457, 0xc459, 0xc457, 0xc51b,
+	0xc457, 0xc457, 0xc51b, 0xc457, 0xc518, 0xc51b, 0xc457, 0xc457,
+	0xc457, 0xc457, 0xc51b, 0xc51b, 0xc457, 0xc51b, 0xc51b, 0xc457,
+	0xc463, 0xc457, 0xc457, 0xc457, 0xc457, 0xc517, 0xc51b, 0xc457,
+	0xc457, 0xc51b, 0xc51b, 0xc457, 0xc457, 0xc457, 0xc457, 0x080c,
+	0x0db2, 0x080c, 0x847d, 0x080c, 0xbd04, 0x6003, 0x0002, 0x080c,
+	0x8582, 0x0804, 0xc521, 0x9006, 0x080c, 0x5ebb, 0x0804, 0xc51b,
+	0x080c, 0x629c, 0x1904, 0xc51b, 0x9006, 0x080c, 0x5ebb, 0x6010,
+	0x2058, 0xb810, 0x9086, 0x00ff, 0x1140, 0x00f6, 0x2079, 0x1800,
+	0x78a0, 0x8000, 0x78a2, 0x00fe, 0x0428, 0x6010, 0x2058, 0xb8b0,
+	0x9005, 0x1178, 0x080c, 0xbcec, 0x1904, 0xc51b, 0x0036, 0x0046,
+	0xbba0, 0x2021, 0x0007, 0x080c, 0x4829, 0x004e, 0x003e, 0x0804,
+	0xc51b, 0x080c, 0x2f81, 0x1904, 0xc51b, 0x2001, 0x1800, 0x2004,
+	0x9086, 0x0002, 0x1138, 0x00f6, 0x2079, 0x1800, 0x78a0, 0x8000,
+	0x78a2, 0x00fe, 0x2001, 0x0002, 0x080c, 0x5ecf, 0x080c, 0x847d,
+	0x6023, 0x0001, 0x6003, 0x0001, 0x6007, 0x0002, 0x080c, 0x8048,
+	0x080c, 0x8582, 0x6110, 0x2158, 0x2009, 0x0001, 0x080c, 0x7c58,
+	0x0804, 0xc521, 0x6610, 0x2658, 0xbe04, 0x96b4, 0xff00, 0x8637,
+	0x9686, 0x0006, 0x0904, 0xc51b, 0x9686, 0x0004, 0x0904, 0xc51b,
+	0x2001, 0x0004, 0x0804, 0xc519, 0x2001, 0x1800, 0x2004, 0x9086,
+	0x0003, 0x1158, 0x0036, 0x0046, 0x6010, 0x2058, 0xbba0, 0x2021,
+	0x0006, 0x080c, 0x4829, 0x004e, 0x003e, 0x2001, 0x0006, 0x080c,
+	0xc53f, 0x6610, 0x2658, 0xbe04, 0x0066, 0x96b4, 0xff00, 0x8637,
+	0x9686, 0x0006, 0x006e, 0x0168, 0x2001, 0x0006, 0x080c, 0x5efb,
+	0x9284, 0x00ff, 0x908e, 0x0007, 0x1120, 0x2001, 0x0006, 0x080c,
+	0x5ecf, 0x080c, 0x629c, 0x11f8, 0x2001, 0x1835, 0x2004, 0xd0a4,
+	0x01d0, 0xbe04, 0x96b4, 0x00ff, 0x9686, 0x0006, 0x01a0, 0x00f6,
+	0x2079, 0x1800, 0x78a0, 0x8000, 0x78a2, 0x00fe, 0x0804, 0xc4a2,
+	0x2001, 0x0004, 0x0030, 0x2001, 0x0006, 0x0449, 0x0020, 0x0018,
+	0x0010, 0x080c, 0x5efb, 0x080c, 0x847d, 0x080c, 0x99d6, 0x080c,
+	0x8582, 0x0005, 0x2600, 0x0002, 0xc536, 0xc536, 0xc536, 0xc536,
+	0xc536, 0xc538, 0xc536, 0xc536, 0xc536, 0xc536, 0xc538, 0xc536,
+	0xc536, 0xc536, 0xc538, 0xc538, 0xc538, 0xc538, 0x080c, 0x0db2,
+	0x080c, 0x847d, 0x080c, 0x99d6, 0x080c, 0x8582, 0x0005, 0x0016,
+	0x00b6, 0x00d6, 0x6110, 0x2158, 0xb900, 0xd184, 0x0138, 0x080c,
+	0x5ecf, 0x9006, 0x080c, 0x5ebb, 0x080c, 0x2e55, 0x00de, 0x00be,
+	0x001e, 0x0005, 0x6610, 0x2658, 0xb804, 0x9084, 0xff00, 0x8007,
+	0x90b2, 0x000c, 0x1a0c, 0x0db2, 0x91b6, 0x0015, 0x1110, 0x003b,
+	0x0028, 0x91b6, 0x0016, 0x190c, 0x0db2, 0x006b, 0x0005, 0xa445,
+	0xa445, 0xa445, 0xa445, 0xa445, 0xa445, 0xc5ba, 0xc57f, 0xa445,
+	0xa445, 0xa445, 0xa445, 0xa445, 0xa445, 0xa445, 0xa445, 0xa445,
+	0xa445, 0xc5ba, 0xc5c1, 0xa445, 0xa445, 0xa445, 0xa445, 0x00f6,
+	0x080c, 0x629c, 0x11d8, 0x080c, 0xbcec, 0x11c0, 0x6010, 0x905d,
+	0x01a8, 0xb8b0, 0x9005, 0x0190, 0x9006, 0x080c, 0x5ebb, 0x2001,
+	0x0002, 0x080c, 0x5ecf, 0x6023, 0x0001, 0x6003, 0x0001, 0x6007,
+	0x0002, 0x080c, 0x8048, 0x080c, 0x8582, 0x00d0, 0x2011, 0x0263,
+	0x2204, 0x8211, 0x220c, 0x080c, 0x24d6, 0x1190, 0x080c, 0x5f7e,
+	0x0118, 0x080c, 0x99d6, 0x0060, 0xb810, 0x0006, 0xb814, 0x0006,
+	0x080c, 0x5a3b, 0x000e, 0xb816, 0x000e, 0xb812, 0x080c, 0x99d6,
+	0x00fe, 0x0005, 0x6604, 0x96b6, 0x001e, 0x1110, 0x080c, 0x99d6,
+	0x0005, 0x080c, 0xa7a1, 0x1148, 0x6003, 0x0001, 0x6007, 0x0001,
+	0x080c, 0x8048, 0x080c, 0x8582, 0x0010, 0x080c, 0x99d6, 0x0005,
+	0x6004, 0x908a, 0x0053, 0x1a0c, 0x0db2, 0x080c, 0x847d, 0x080c,
+	0x9a06, 0x080c, 0x8582, 0x0005, 0x9182, 0x0040, 0x0002, 0xc5f2,
+	0xc5f2, 0xc5f2, 0xc5f2, 0xc5f4, 0xc5f2, 0xc5f2, 0xc5f2, 0xc5f2,
+	0xc5f2, 0xc5f2, 0xc5f2, 0xc5f2, 0xc5f2, 0xc5f2, 0xc5f2, 0xc5f2,
+	0xc5f2, 0xc5f2, 0x080c, 0x0db2, 0x0096, 0x00b6, 0x00d6, 0x00e6,
+	0x00f6, 0x0046, 0x0026, 0x6210, 0x2258, 0xb8ac, 0x9005, 0x11a8,
+	0x6106, 0x2071, 0x0260, 0x7444, 0x94a4, 0xff00, 0x0904, 0xc65a,
+	0x080c, 0xd2ef, 0x1170, 0x9486, 0x2000, 0x1158, 0x2009, 0x0001,
+	0x2011, 0x0200, 0x080c, 0x7e3e, 0x0020, 0x9026, 0x080c, 0xd224,
+	0x0c38, 0x080c, 0x0fd5, 0x090c, 0x0db2, 0x6003, 0x0007, 0xa867,
+	0x010d, 0x9006, 0xa802, 0xa86a, 0xac8a, 0x2c00, 0xa88e, 0x6008,
+	0xa8e2, 0x6010, 0x2058, 0xb8a0, 0x7130, 0xa97a, 0x0016, 0xa876,
+	0xa87f, 0x0000, 0xa883, 0x0000, 0xa887, 0x0036, 0x080c, 0x6536,
+	0x001e, 0x080c, 0xd2ef, 0x1904, 0xc6ba, 0x9486, 0x2000, 0x1130,
+	0x2019, 0x0017, 0x080c, 0xcf62, 0x0804, 0xc6ba, 0x9486, 0x0200,
+	0x1120, 0x080c, 0xcefe, 0x0804, 0xc6ba, 0x9486, 0x0400, 0x0120,
+	0x9486, 0x1000, 0x1904, 0xc6ba, 0x2019, 0x0002, 0x080c, 0xcf19,
+	0x0804, 0xc6ba, 0x2069, 0x1a3e, 0x6a00, 0xd284, 0x0904, 0xc724,
+	0x9284, 0x0300, 0x1904, 0xc71d, 0x6804, 0x9005, 0x0904, 0xc705,
+	0x2d78, 0x6003, 0x0007, 0x080c, 0x0fee, 0x0904, 0xc6c6, 0x7800,
+	0xd08c, 0x1118, 0x7804, 0x8001, 0x7806, 0x6017, 0x0000, 0x2001,
+	0x180e, 0x2004, 0xd084, 0x1904, 0xc728, 0x9006, 0xa802, 0xa867,
+	0x0116, 0xa86a, 0x6008, 0xa8e2, 0x2c00, 0xa87a, 0x6010, 0x2058,
+	0xb8a0, 0x7130, 0xa9b6, 0xa876, 0xb928, 0xa9ba, 0xb92c, 0xa9be,
+	0xb930, 0xa9c2, 0xb934, 0xa9c6, 0xa883, 0x003d, 0x7044, 0x9084,
+	0x0003, 0x9080, 0xc6c2, 0x2005, 0xa87e, 0x20a9, 0x000a, 0x2001,
+	0x0270, 0xaa5c, 0x9290, 0x0021, 0x2009, 0x0205, 0x200b, 0x0080,
+	0x20e1, 0x0000, 0xab60, 0x23e8, 0x2098, 0x22a0, 0x4003, 0x200b,
+	0x0000, 0x2001, 0x027a, 0x200c, 0xa9b2, 0x8000, 0x200c, 0xa9ae,
+	0x080c, 0x6536, 0x002e, 0x004e, 0x00fe, 0x00ee, 0x00de, 0x00be,
+	0x009e, 0x0005, 0x0000, 0x0080, 0x0040, 0x0000, 0x2001, 0x180f,
+	0x2004, 0xd084, 0x0120, 0x080c, 0x0fd5, 0x1904, 0xc66f, 0x6017,
+	0xf100, 0x6003, 0x0001, 0x6007, 0x0041, 0x080c, 0x8000, 0x080c,
+	0x8582, 0x0c00, 0x2069, 0x0260, 0x6848, 0x9084, 0xff00, 0x9086,
+	0x1200, 0x1198, 0x686c, 0x9084, 0x00ff, 0x0016, 0x6114, 0x918c,
+	0xf700, 0x910d, 0x6116, 0x001e, 0x6003, 0x0001, 0x6007, 0x0043,
+	0x080c, 0x8000, 0x080c, 0x8582, 0x0828, 0x6868, 0x602e, 0x686c,
+	0x6032, 0x6017, 0xf200, 0x6003, 0x0001, 0x6007, 0x0041, 0x080c,
+	0x8000, 0x080c, 0x8582, 0x0804, 0xc6ba, 0x2001, 0x180d, 0x2004,
+	0xd0ec, 0x0120, 0x2011, 0x8049, 0x080c, 0x4672, 0x6017, 0xf300,
+	0x0010, 0x6017, 0xf100, 0x6003, 0x0001, 0x6007, 0x0041, 0x080c,
+	0x8000, 0x080c, 0x8582, 0x0804, 0xc6ba, 0x6017, 0xf500, 0x0c98,
+	0x6017, 0xf600, 0x0804, 0xc6da, 0x6017, 0xf200, 0x0804, 0xc6da,
+	0xa867, 0x0146, 0xa86b, 0x0000, 0x6008, 0xa886, 0x2c00, 0xa87a,
+	0x7044, 0x9084, 0x0003, 0x9080, 0xc6c2, 0x2005, 0xa87e, 0x2928,
+	0x6010, 0x2058, 0xb8a0, 0xa876, 0xb828, 0xa88a, 0xb82c, 0xa88e,
+	0xb830, 0xa892, 0xb834, 0xa896, 0xa883, 0x003d, 0x2009, 0x0205,
+	0x2104, 0x9085, 0x0080, 0x200a, 0x20e1, 0x0000, 0x2011, 0x0210,
+	0x2214, 0x9294, 0x0fff, 0xaaa2, 0x9282, 0x0111, 0x1a0c, 0x0db2,
+	0x8210, 0x821c, 0x2001, 0x026c, 0x2098, 0xa860, 0x20e8, 0xa85c,
+	0x9080, 0x0029, 0x20a0, 0x2011, 0xc7a4, 0x2041, 0x0001, 0x223d,
+	0x9784, 0x00ff, 0x9322, 0x1208, 0x2300, 0x20a8, 0x4003, 0x931a,
+	0x0530, 0x8210, 0xd7fc, 0x1130, 0x8d68, 0x2d0a, 0x2001, 0x0260,
+	0x2098, 0x0c68, 0x2950, 0x080c, 0x0fee, 0x0170, 0x2900, 0xb002,
+	0xa867, 0x0147, 0xa86b, 0x0000, 0xa860, 0x20e8, 0xa85c, 0x9080,
+	0x001b, 0x20a0, 0x8840, 0x08d8, 0x2548, 0xa800, 0x902d, 0x0118,
+	0x080c, 0x1007, 0x0cc8, 0x080c, 0x1007, 0x0804, 0xc6c6, 0x2548,
+	0x8847, 0x9885, 0x0046, 0xa866, 0x2009, 0x0205, 0x200b, 0x0000,
+	0x080c, 0xcf91, 0x0804, 0xc6ba, 0x8010, 0x0004, 0x801a, 0x0006,
+	0x8018, 0x0008, 0x8016, 0x000a, 0x8014, 0x9186, 0x0013, 0x1160,
+	0x6004, 0x908a, 0x0054, 0x1a0c, 0x0db2, 0x9082, 0x0040, 0x0a0c,
+	0x0db2, 0x2008, 0x0804, 0xc855, 0x9186, 0x0051, 0x0108, 0x00c0,
+	0x2001, 0x0109, 0x2004, 0xd084, 0x0904, 0xc806, 0x0126, 0x2091,
+	0x2800, 0x0006, 0x0016, 0x0026, 0x080c, 0x7eec, 0x002e, 0x001e,
+	0x000e, 0x012e, 0x6000, 0x9086, 0x0002, 0x1580, 0x0804, 0xc89d,
+	0x9186, 0x0027, 0x0530, 0x9186, 0x0048, 0x0128, 0x9186, 0x0014,
+	0x0500, 0x190c, 0x0db2, 0x2001, 0x0109, 0x2004, 0xd084, 0x01f0,
+	0x00c6, 0x0126, 0x2091, 0x2800, 0x00c6, 0x2061, 0x0100, 0x0006,
+	0x0016, 0x0026, 0x080c, 0x7eec, 0x002e, 0x001e, 0x000e, 0x00ce,
+	0x012e, 0x00ce, 0x6000, 0x9086, 0x0004, 0x190c, 0x0db2, 0x0804,
+	0xc97e, 0x6004, 0x9082, 0x0040, 0x2008, 0x001a, 0x080c, 0x9a6b,
+	0x0005, 0xc81c, 0xc81e, 0xc81e, 0xc845, 0xc81c, 0xc81c, 0xc81c,
+	0xc81c, 0xc81c, 0xc81c, 0xc81c, 0xc81c, 0xc81c, 0xc81c, 0xc81c,
+	0xc81c, 0xc81c, 0xc81c, 0xc81c, 0x080c, 0x0db2, 0x080c, 0x847d,
+	0x080c, 0x8582, 0x0036, 0x0096, 0x6014, 0x904d, 0x01d8, 0x080c,
+	0xb5fb, 0x01c0, 0x6003, 0x0002, 0x6010, 0x00b6, 0x2058, 0xb800,
+	0x00be, 0xd0bc, 0x1178, 0x2019, 0x0004, 0x080c, 0xcf91, 0x6017,
+	0x0000, 0x6018, 0x9005, 0x1120, 0x2001, 0x1956, 0x2004, 0x601a,
+	0x6003, 0x0007, 0x009e, 0x003e, 0x0005, 0x0096, 0x080c, 0x847d,
+	0x080c, 0x8582, 0x080c, 0xb5fb, 0x0120, 0x6014, 0x2048, 0x080c,
+	0x1007, 0x080c, 0x9a06, 0x009e, 0x0005, 0x0002, 0xc869, 0xc880,
+	0xc86b, 0xc897, 0xc869, 0xc869, 0xc869, 0xc869, 0xc869, 0xc869,
+	0xc869, 0xc869, 0xc869, 0xc869, 0xc869, 0xc869, 0xc869, 0xc869,
+	0xc869, 0x080c, 0x0db2, 0x0096, 0x080c, 0x847d, 0x6014, 0x2048,
+	0xa87c, 0xd0b4, 0x0138, 0x6003, 0x0007, 0x2009, 0x0043, 0x080c,
+	0x9a50, 0x0010, 0x6003, 0x0004, 0x080c, 0x8582, 0x009e, 0x0005,
+	0x080c, 0x847d, 0x080c, 0xb5fb, 0x0138, 0x6114, 0x0096, 0x2148,
+	0xa97c, 0x009e, 0xd1ec, 0x1138, 0x080c, 0x7e13, 0x080c, 0x99d6,
+	0x080c, 0x8582, 0x0005, 0x080c, 0xd1e8, 0x0db0, 0x0cc8, 0x080c,
+	0x847d, 0x2009, 0x0041, 0x0804, 0xca06, 0x9182, 0x0040, 0x0002,
+	0xc8b3, 0xc8b5, 0xc8b3, 0xc8b3, 0xc8b3, 0xc8b3, 0xc8b3, 0xc8b3,
+	0xc8b3, 0xc8b3, 0xc8b3, 0xc8b3, 0xc8b3, 0xc8b3, 0xc8b3, 0xc8b3,
+	0xc8b3, 0xc8b6, 0xc8b3, 0x080c, 0x0db2, 0x0005, 0x00d6, 0x080c,
+	0x7e13, 0x00de, 0x080c, 0xd240, 0x080c, 0x99d6, 0x0005, 0x9182,
+	0x0040, 0x0002, 0xc8d5, 0xc8d5, 0xc8d5, 0xc8d5, 0xc8d5, 0xc8d5,
+	0xc8d5, 0xc8d5, 0xc8d5, 0xc8d7, 0xc946, 0xc8d5, 0xc8d5, 0xc8d5,
+	0xc8d5, 0xc946, 0xc8d5, 0xc8d5, 0xc8d5, 0x080c, 0x0db2, 0x2001,
+	0x0105, 0x2004, 0x9084, 0x1800, 0x01c8, 0x2001, 0x0132, 0x200c,
+	0x2001, 0x0131, 0x2004, 0x9105, 0x1904, 0xc946, 0x2009, 0x180c,
+	0x2104, 0xd0d4, 0x0904, 0xc946, 0xc0d4, 0x200a, 0x2009, 0x0105,
+	0x2104, 0x9084, 0xe7fd, 0x9085, 0x0010, 0x200a, 0x2001, 0x1873,
+	0x2004, 0xd0e4, 0x1528, 0x603b, 0x0000, 0x080c, 0x8532, 0x6014,
+	0x0096, 0x2048, 0xa87c, 0xd0fc, 0x0188, 0x908c, 0x0003, 0x918e,
+	0x0002, 0x0508, 0x2001, 0x180c, 0x2004, 0xd0d4, 0x11e0, 0x080c,
+	0x865d, 0x2009, 0x0041, 0x009e, 0x0804, 0xca06, 0x080c, 0x865d,
+	0x6003, 0x0007, 0x601b, 0x0000, 0x080c, 0x7e13, 0x009e, 0x0005,
+	0x2001, 0x0100, 0x2004, 0x9082, 0x0005, 0x0aa8, 0x2001, 0x011f,
+	0x2004, 0x603a, 0x0890, 0x2001, 0x180c, 0x200c, 0xc1d4, 0x2102,
+	0xd1cc, 0x0110, 0x080c, 0x28ea, 0x080c, 0x865d, 0x6014, 0x2048,
+	0xa97c, 0xd1ec, 0x1130, 0x080c, 0x7e13, 0x080c, 0x99d6, 0x009e,
+	0x0005, 0x080c, 0xd1e8, 0x0db8, 0x009e, 0x0005, 0x2001, 0x180c,
+	0x200c, 0xc1d4, 0x2102, 0x0036, 0x080c, 0x8532, 0x080c, 0x865d,
+	0x6014, 0x0096, 0x2048, 0x6010, 0x00b6, 0x2058, 0xb800, 0x00be,
+	0xd0bc, 0x0188, 0xa87c, 0x9084, 0x0003, 0x9086, 0x0002, 0x0140,
+	0xa8ac, 0x6330, 0x931a, 0x6332, 0xa8b0, 0x632c, 0x931b, 0x632e,
+	0x6003, 0x0002, 0x0080, 0x2019, 0x0004, 0x080c, 0xcf91, 0x6018,
+	0x9005, 0x1128, 0x2001, 0x1956, 0x2004, 0x8003, 0x601a, 0x6017,
+	0x0000, 0x6003, 0x0007, 0x009e, 0x003e, 0x0005, 0x9182, 0x0040,
+	0x0002, 0xc995, 0xc995, 0xc995, 0xc995, 0xc995, 0xc995, 0xc995,
+	0xc995, 0xc997, 0xc995, 0xc995, 0xc995, 0xc995, 0xc995, 0xc995,
+	0xc995, 0xc995, 0xc995, 0xc995, 0xc9e2, 0x080c, 0x0db2, 0x6014,
+	0x0096, 0x2048, 0xa834, 0xaa38, 0x6110, 0x00b6, 0x2058, 0xb900,
+	0x00be, 0xd1bc, 0x1190, 0x920d, 0x1518, 0xa87c, 0xd0fc, 0x0128,
+	0x2009, 0x0041, 0x009e, 0x0804, 0xca06, 0x6003, 0x0007, 0x601b,
+	0x0000, 0x080c, 0x7e13, 0x009e, 0x0005, 0x6124, 0xd1f4, 0x1d58,
+	0x0006, 0x0046, 0xacac, 0x9422, 0xa9b0, 0x2200, 0x910b, 0x6030,
+	0x9420, 0x6432, 0x602c, 0x9109, 0x612e, 0x004e, 0x000e, 0x08d8,
+	0x6110, 0x00b6, 0x2158, 0xb900, 0x00be, 0xd1bc, 0x1178, 0x2009,
+	0x180d, 0x210c, 0xd19c, 0x0118, 0x6003, 0x0007, 0x0010, 0x6003,
+	0x0006, 0x00e9, 0x080c, 0x7e15, 0x009e, 0x0005, 0x6003, 0x0002,
+	0x009e, 0x0005, 0x6024, 0xd0f4, 0x0128, 0x080c, 0x14c9, 0x1904,
+	0xc997, 0x0005, 0x6014, 0x0096, 0x2048, 0xa834, 0xa938, 0x009e,
+	0x9105, 0x1120, 0x080c, 0x14c9, 0x1904, 0xc997, 0x0005, 0xd2fc,
+	0x0140, 0x8002, 0x8000, 0x8212, 0x9291, 0x0000, 0x2009, 0x0009,
+	0x0010, 0x2009, 0x0015, 0xaa9a, 0xa896, 0x0005, 0x9182, 0x0040,
+	0x0208, 0x0062, 0x9186, 0x0013, 0x0120, 0x9186, 0x0014, 0x190c,
+	0x0db2, 0x6024, 0xd0dc, 0x090c, 0x0db2, 0x0005, 0xca29, 0xca35,
+	0xca41, 0xca4d, 0xca29, 0xca29, 0xca29, 0xca29, 0xca30, 0xca2b,
+	0xca2b, 0xca29, 0xca29, 0xca29, 0xca29, 0xca2b, 0xca29, 0xca2b,
+	0xca29, 0x080c, 0x0db2, 0x6024, 0xd0dc, 0x090c, 0x0db2, 0x0005,
+	0x6014, 0x9005, 0x190c, 0x0db2, 0x0005, 0x6003, 0x0001, 0x6106,
+	0x080c, 0x8000, 0x0126, 0x2091, 0x8000, 0x080c, 0x8582, 0x012e,
+	0x0005, 0x6003, 0x0001, 0x6106, 0x080c, 0x8000, 0x0126, 0x2091,
+	0x8000, 0x080c, 0x8582, 0x012e, 0x0005, 0x6003, 0x0003, 0x6106,
+	0x2c10, 0x080c, 0x1976, 0x0126, 0x2091, 0x8000, 0x080c, 0x8065,
+	0x080c, 0x865d, 0x012e, 0x0005, 0x0126, 0x2091, 0x8000, 0x0036,
+	0x0096, 0x9182, 0x0040, 0x0023, 0x009e, 0x003e, 0x012e, 0x0005,
+	0xca78, 0xca7a, 0xca8c, 0xcaa6, 0xca78, 0xca78, 0xca78, 0xca78,
+	0xca78, 0xca78, 0xca78, 0xca78, 0xca78, 0xca78, 0xca78, 0xca78,
+	0x080c, 0x0db2, 0x6014, 0x2048, 0xa87c, 0xd0fc, 0x01f8, 0x909c,
+	0x0003, 0x939e, 0x0003, 0x01d0, 0x6003, 0x0001, 0x6106, 0x080c,
+	0x8000, 0x080c, 0x8582, 0x0470, 0x6014, 0x2048, 0xa87c, 0xd0fc,
+	0x0168, 0x909c, 0x0003, 0x939e, 0x0003, 0x0140, 0x6003, 0x0001,
+	0x6106, 0x080c, 0x8000, 0x080c, 0x8582, 0x00e0, 0x901e, 0x6316,
+	0x631a, 0x2019, 0x0004, 0x080c, 0xcf91, 0x00a0, 0x6014, 0x2048,
+	0xa87c, 0xd0fc, 0x0d98, 0x909c, 0x0003, 0x939e, 0x0003, 0x0d70,
+	0x6003, 0x0003, 0x6106, 0x2c10, 0x080c, 0x1976, 0x080c, 0x8065,
+	0x080c, 0x865d, 0x0005, 0x080c, 0x847d, 0x6114, 0x81ff, 0x0158,
+	0x0096, 0x2148, 0x080c, 0xd28c, 0x0036, 0x2019, 0x0029, 0x080c,
+	0xcf91, 0x003e, 0x009e, 0x080c, 0x9a06, 0x080c, 0x8582, 0x0005,
+	0x080c, 0x8532, 0x6114, 0x81ff, 0x0158, 0x0096, 0x2148, 0x080c,
+	0xd28c, 0x0036, 0x2019, 0x0029, 0x080c, 0xcf91, 0x003e, 0x009e,
+	0x080c, 0x9a06, 0x080c, 0x865d, 0x0005, 0x9182, 0x0085, 0x0002,
+	0xcaf7, 0xcaf5, 0xcaf5, 0xcb03, 0xcaf5, 0xcaf5, 0xcaf5, 0xcaf5,
+	0xcaf5, 0xcaf5, 0xcaf5, 0xcaf5, 0xcaf5, 0x080c, 0x0db2, 0x6003,
+	0x000b, 0x6106, 0x080c, 0x8000, 0x0126, 0x2091, 0x8000, 0x080c,
+	0x8582, 0x012e, 0x0005, 0x0026, 0x00e6, 0x080c, 0xd1df, 0x0118,
+	0x080c, 0x99d6, 0x0450, 0x2071, 0x0260, 0x7224, 0x6216, 0x2001,
+	0x180d, 0x2004, 0xd0e4, 0x0150, 0x6010, 0x00b6, 0x2058, 0xbca0,
+	0x00be, 0x2c00, 0x2011, 0x014e, 0x080c, 0x9cf4, 0x7220, 0x080c,
+	0xce37, 0x0118, 0x6007, 0x0086, 0x0040, 0x6007, 0x0087, 0x7224,
+	0x9296, 0xffff, 0x1110, 0x6007, 0x0086, 0x6003, 0x0001, 0x080c,
+	0x8000, 0x080c, 0x8582, 0x080c, 0x865d, 0x00ee, 0x002e, 0x0005,
+	0x9186, 0x0013, 0x1160, 0x6004, 0x908a, 0x0085, 0x0a0c, 0x0db2,
+	0x908a, 0x0092, 0x1a0c, 0x0db2, 0x9082, 0x0085, 0x00a2, 0x9186,
+	0x0027, 0x0130, 0x9186, 0x0014, 0x0118, 0x080c, 0x9a6b, 0x0050,
+	0x2001, 0x0007, 0x080c, 0x5efb, 0x080c, 0x847d, 0x080c, 0x9a06,
+	0x080c, 0x8582, 0x0005, 0xcb68, 0xcb6a, 0xcb6a, 0xcb68, 0xcb68,
+	0xcb68, 0xcb68, 0xcb68, 0xcb68, 0xcb68, 0xcb68, 0xcb68, 0xcb68,
+	0x080c, 0x0db2, 0x080c, 0x847d, 0x080c, 0x9a06, 0x080c, 0x8582,
+	0x0005, 0x9182, 0x0085, 0x0a0c, 0x0db2, 0x9182, 0x0092, 0x1a0c,
+	0x0db2, 0x9182, 0x0085, 0x0002, 0xcb89, 0xcb89, 0xcb89, 0xcb8b,
+	0xcb89, 0xcb89, 0xcb89, 0xcb89, 0xcb89, 0xcb89, 0xcb89, 0xcb89,
+	0xcb89, 0x080c, 0x0db2, 0x0005, 0x9186, 0x0013, 0x0148, 0x9186,
+	0x0014, 0x0130, 0x9186, 0x0027, 0x0118, 0x080c, 0x9a6b, 0x0030,
+	0x080c, 0x847d, 0x080c, 0x9a06, 0x080c, 0x8582, 0x0005, 0x0036,
+	0x080c, 0xd240, 0x6043, 0x0000, 0x2019, 0x000b, 0x0031, 0x6023,
+	0x0006, 0x6003, 0x0007, 0x003e, 0x0005, 0x0126, 0x0036, 0x2091,
+	0x8000, 0x0086, 0x2c40, 0x0096, 0x904e, 0x080c, 0x9349, 0x009e,
+	0x008e, 0x1550, 0x0076, 0x2c38, 0x080c, 0x93f4, 0x007e, 0x1520,
+	0x6000, 0x9086, 0x0000, 0x0500, 0x6020, 0x9086, 0x0007, 0x01e0,
+	0x0096, 0x601c, 0xd084, 0x0140, 0x080c, 0xd240, 0x080c, 0xbd04,
+	0x080c, 0x1827, 0x6023, 0x0007, 0x6014, 0x2048, 0x080c, 0xb5fb,
+	0x0110, 0x080c, 0xcf91, 0x009e, 0x6017, 0x0000, 0x080c, 0xd240,
+	0x6023, 0x0007, 0x080c, 0xbd04, 0x003e, 0x012e, 0x0005, 0x00f6,
+	0x00c6, 0x00b6, 0x0036, 0x0156, 0x2079, 0x0260, 0x7938, 0x783c,
+	0x080c, 0x24d6, 0x15b8, 0x0016, 0x00c6, 0x080c, 0x5f7e, 0x1580,
+	0x001e, 0x00c6, 0x2160, 0x080c, 0xbd01, 0x00ce, 0x002e, 0x0026,
+	0x0016, 0x2019, 0x0029, 0x080c, 0x94b5, 0x080c, 0x8180, 0x0076,
+	0x903e, 0x080c, 0x8078, 0x007e, 0x001e, 0x0076, 0x903e, 0x080c,
+	0xcd62, 0x007e, 0x0026, 0xba04, 0x9294, 0xff00, 0x8217, 0x9286,
+	0x0006, 0x0118, 0x9286, 0x0004, 0x1118, 0xbaa0, 0x080c, 0x2eea,
+	0x002e, 0x001e, 0x080c, 0x5a3b, 0xbe12, 0xbd16, 0x9006, 0x0010,
+	0x00ce, 0x001e, 0x015e, 0x003e, 0x00be, 0x00ce, 0x00fe, 0x0005,
+	0x00c6, 0x00d6, 0x00b6, 0x0016, 0x2009, 0x1822, 0x2104, 0x9086,
+	0x0074, 0x1904, 0xcc89, 0x2069, 0x0260, 0x6944, 0x9182, 0x0100,
+	0x06e0, 0x6940, 0x9184, 0x8000, 0x0904, 0xcc86, 0x2001, 0x194d,
+	0x2004, 0x9005, 0x1140, 0x6010, 0x2058, 0xb8b0, 0x9005, 0x0118,
+	0x9184, 0x0800, 0x0598, 0x6948, 0x918a, 0x0001, 0x0648, 0x080c,
+	0xd2f4, 0x0118, 0x6978, 0xd1fc, 0x11b8, 0x2009, 0x0205, 0x200b,
+	0x0001, 0x693c, 0x81ff, 0x1198, 0x6944, 0x9182, 0x0100, 0x02a8,
+	0x6940, 0x81ff, 0x1178, 0x6948, 0x918a, 0x0001, 0x0288, 0x6950,
+	0x918a, 0x0001, 0x0298, 0x00d0, 0x6017, 0x0100, 0x00a0, 0x6017,
+	0x0300, 0x0088, 0x6017, 0x0500, 0x0070, 0x6017, 0x0700, 0x0058,
+	0x6017, 0x0900, 0x0040, 0x6017, 0x0b00, 0x0028, 0x6017, 0x0f00,
+	0x0010, 0x6017, 0x2d00, 0x9085, 0x0001, 0x0008, 0x9006, 0x001e,
+	0x00be, 0x00de, 0x00ce, 0x0005, 0x00c6, 0x00b6, 0x0026, 0x0036,
+	0x0156, 0x6210, 0x2258, 0xbb04, 0x9394, 0x00ff, 0x9286, 0x0006,
+	0x0180, 0x9286, 0x0004, 0x0168, 0x9394, 0xff00, 0x8217, 0x9286,
+	0x0006, 0x0138, 0x9286, 0x0004, 0x0120, 0x080c, 0x5f8d, 0x0804,
+	0xccf1, 0x2011, 0x0276, 0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019,
+	0x000a, 0x080c, 0xa91d, 0x009e, 0x15a8, 0x2011, 0x027a, 0x20a9,
+	0x0004, 0x0096, 0x2b48, 0x2019, 0x0006, 0x080c, 0xa91d, 0x009e,
+	0x1548, 0x0046, 0x0016, 0xbaa0, 0x2220, 0x9006, 0x2009, 0x1854,
+	0x210c, 0xd1a4, 0x0138, 0x2009, 0x0029, 0x080c, 0xcfe6, 0xb800,
+	0xc0e5, 0xb802, 0x2019, 0x0029, 0x080c, 0x8180, 0x0076, 0x2039,
+	0x0000, 0x080c, 0x8078, 0x2c08, 0x080c, 0xcd62, 0x007e, 0x2001,
+	0x0007, 0x080c, 0x5efb, 0x2001, 0x0007, 0x080c, 0x5ecf, 0x001e,
+	0x004e, 0x9006, 0x015e, 0x003e, 0x002e, 0x00be, 0x00ce, 0x0005,
+	0x00d6, 0x2069, 0x026e, 0x6800, 0x9086, 0x0800, 0x0118, 0x6017,
+	0x0000, 0x0008, 0x9006, 0x00de, 0x0005, 0x00b6, 0x00f6, 0x0016,
+	0x0026, 0x0036, 0x0156, 0x2079, 0x026c, 0x7930, 0x7834, 0x080c,
+	0x24d6, 0x11d0, 0x080c, 0x5f7e, 0x11b8, 0x2011, 0x0270, 0x20a9,
+	0x0004, 0x0096, 0x2b48, 0x2019, 0x000a, 0x080c, 0xa91d, 0x009e,
+	0x1158, 0x2011, 0x0274, 0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019,
+	0x0006, 0x080c, 0xa91d, 0x009e, 0x015e, 0x003e, 0x002e, 0x001e,
+	0x00fe, 0x00be, 0x0005, 0x00b6, 0x0006, 0x0016, 0x0026, 0x0036,
+	0x0156, 0x2011, 0x0263, 0x2204, 0x8211, 0x220c, 0x080c, 0x24d6,
+	0x11d0, 0x080c, 0x5f7e, 0x11b8, 0x2011, 0x0276, 0x20a9, 0x0004,
+	0x0096, 0x2b48, 0x2019, 0x000a, 0x080c, 0xa91d, 0x009e, 0x1158,
+	0x2011, 0x027a, 0x20a9, 0x0004, 0x0096, 0x2b48, 0x2019, 0x0006,
+	0x080c, 0xa91d, 0x009e, 0x015e, 0x003e, 0x002e, 0x001e, 0x000e,
+	0x00be, 0x0005, 0x00e6, 0x00c6, 0x0086, 0x0076, 0x0066, 0x0056,
+	0x0046, 0x0026, 0x0126, 0x2091, 0x8000, 0x2740, 0x2029, 0x19bf,
+	0x252c, 0x2021, 0x19c5, 0x2424, 0x2061, 0x1cd0, 0x2071, 0x1800,
+	0x764c, 0x706c, 0x81ff, 0x0150, 0x0006, 0x9186, 0x1a73, 0x000e,
+	0x0128, 0x8001, 0x9602, 0x1a04, 0xcdf0, 0x0018, 0x9606, 0x0904,
+	0xcdf0, 0x2100, 0x9c06, 0x0904, 0xcde7, 0x080c, 0xd022, 0x1904,
+	0xcde7, 0x080c, 0xd311, 0x0904, 0xcde7, 0x080c, 0xd012, 0x0904,
+	0xcde7, 0x6720, 0x9786, 0x0001, 0x1148, 0x080c, 0x2f81, 0x0904,
+	0xce0b, 0x6004, 0x9086, 0x0000, 0x1904, 0xce0b, 0x9786, 0x0004,
+	0x0904, 0xce0b, 0x9786, 0x0007, 0x05d0, 0x2500, 0x9c06, 0x05b8,
+	0x2400, 0x9c06, 0x05a0, 0x88ff, 0x0118, 0x6054, 0x9906, 0x1578,
+	0x0096, 0x6000, 0x9086, 0x0004, 0x1120, 0x0016, 0x080c, 0x1827,
+	0x001e, 0x9786, 0x000a, 0x0148, 0x080c, 0xb7fa, 0x1130, 0x080c,
+	0xa364, 0x009e, 0x080c, 0x9a06, 0x00d0, 0x6014, 0x2048, 0x080c,
+	0xb5fb, 0x0190, 0x9786, 0x0003, 0x1528, 0xa867, 0x0103, 0xab7a,
+	0xa877, 0x0000, 0x080c, 0xd28c, 0x0016, 0x080c, 0xb8e3, 0x080c,
+	0x6529, 0x001e, 0x080c, 0xb7dd, 0x009e, 0x080c, 0x9a06, 0x9ce0,
+	0x0018, 0x2001, 0x1818, 0x2004, 0x9c02, 0x1210, 0x0804, 0xcd76,
+	0x012e, 0x002e, 0x004e, 0x005e, 0x006e, 0x007e, 0x008e, 0x00ce,
+	0x00ee, 0x0005, 0x9786, 0x0006, 0x1150, 0x9386, 0x0005, 0x0128,
+	0x080c, 0xd28c, 0x080c, 0xcf91, 0x08f8, 0x009e, 0x0c00, 0x9786,
+	0x000a, 0x0968, 0x0850, 0x81ff, 0x09d0, 0x9180, 0x0001, 0x2004,
+	0x9086, 0x0018, 0x0130, 0x9180, 0x0001, 0x2004, 0x9086, 0x002d,
+	0x1970, 0x6000, 0x9086, 0x0002, 0x1950, 0x080c, 0xb7e9, 0x0130,
+	0x080c, 0xb7fa, 0x1920, 0x080c, 0xa364, 0x0038, 0x080c, 0x2e55,
+	0x080c, 0xb7fa, 0x1110, 0x080c, 0xa364, 0x080c, 0x9a06, 0x0804,
+	0xcde7, 0xa864, 0x9084, 0x00ff, 0x9086, 0x0039, 0x0005, 0x00c6,
+	0x00e6, 0x0016, 0x2c08, 0x2170, 0x9006, 0x080c, 0xcfb8, 0x001e,
+	0x0120, 0x6020, 0x9084, 0x000f, 0x001b, 0x00ee, 0x00ce, 0x0005,
+	0xce56, 0xce56, 0xce56, 0xce56, 0xce56, 0xce56, 0xce58, 0xce56,
+	0xce56, 0xce56, 0xce56, 0x9a06, 0x9a06, 0xce56, 0x9006, 0x0005,
+	0x0036, 0x0046, 0x0016, 0x7010, 0x00b6, 0x2058, 0xbca0, 0x00be,
+	0x2c00, 0x2009, 0x0020, 0x080c, 0xcfe6, 0x001e, 0x004e, 0x2019,
+	0x0002, 0x080c, 0xcbad, 0x003e, 0x9085, 0x0001, 0x0005, 0x0096,
+	0x080c, 0xb5fb, 0x0140, 0x6014, 0x904d, 0x080c, 0xb251, 0x687b,
+	0x0005, 0x080c, 0x6536, 0x009e, 0x080c, 0x9a06, 0x9085, 0x0001,
+	0x0005, 0x2001, 0x0001, 0x080c, 0x5ebb, 0x0156, 0x0016, 0x0026,
+	0x0036, 0x20a9, 0x0004, 0x2019, 0x1805, 0x2011, 0x0276, 0x080c,
+	0xa909, 0x003e, 0x002e, 0x001e, 0x015e, 0x9005, 0x0005, 0x00f6,
+	0x00e6, 0x00c6, 0x0086, 0x0076, 0x0066, 0x00b6, 0x0126, 0x2091,
+	0x8000, 0x2740, 0x2061, 0x1cd0, 0x2079, 0x0001, 0x8fff, 0x0904,
+	0xcef1, 0x2071, 0x1800, 0x764c, 0x706c, 0x8001, 0x9602, 0x1a04,
+	0xcef1, 0x88ff, 0x0120, 0x2800, 0x9c06, 0x1590, 0x2078, 0x080c,
+	0xd012, 0x0570, 0x2400, 0x9c06, 0x0558, 0x6720, 0x9786, 0x0006,
+	0x1538, 0x9786, 0x0007, 0x0520, 0x88ff, 0x1140, 0x6010, 0x9b06,
+	0x11f8, 0x85ff, 0x0118, 0x6054, 0x9106, 0x11d0, 0x0096, 0x601c,
+	0xd084, 0x0140, 0x080c, 0xd240, 0x080c, 0xbd04, 0x080c, 0x1827,
+	0x6023, 0x0007, 0x6014, 0x2048, 0x080c, 0xb5fb, 0x0120, 0x0046,
+	0x080c, 0xcf91, 0x004e, 0x009e, 0x080c, 0x9a06, 0x88ff, 0x1198,
+	0x9ce0, 0x0018, 0x2001, 0x1818, 0x2004, 0x9c02, 0x1210, 0x0804,
+	0xcea6, 0x9006, 0x012e, 0x00be, 0x006e, 0x007e, 0x008e, 0x00ce,
+	0x00ee, 0x00fe, 0x0005, 0x98c5, 0x0001, 0x0ca0, 0x00b6, 0x0076,
+	0x0056, 0x0086, 0x9046, 0x2029, 0x0001, 0x2c20, 0x2019, 0x0002,
+	0x6210, 0x2258, 0x0096, 0x904e, 0x080c, 0x9349, 0x009e, 0x008e,
+	0x903e, 0x080c, 0x93f4, 0x080c, 0xce97, 0x005e, 0x007e, 0x00be,
+	0x0005, 0x00b6, 0x0046, 0x0056, 0x0076, 0x00c6, 0x0156, 0x2c20,
+	0x2128, 0x20a9, 0x007f, 0x900e, 0x0016, 0x0036, 0x080c, 0x5f7e,
+	0x1190, 0x0056, 0x0086, 0x9046, 0x2508, 0x2029, 0x0001, 0x0096,
+	0x904e, 0x080c, 0x9349, 0x009e, 0x008e, 0x903e, 0x080c, 0x93f4,
+	0x080c, 0xce97, 0x005e, 0x003e, 0x001e, 0x8108, 0x1f04, 0xcf24,
+	0x015e, 0x00ce, 0x007e, 0x005e, 0x004e, 0x00be, 0x0005, 0x00b6,
+	0x0076, 0x0056, 0x6210, 0x2258, 0x0086, 0x9046, 0x2029, 0x0001,
+	0x2019, 0x0048, 0x0096, 0x904e, 0x080c, 0x9349, 0x009e, 0x008e,
+	0x903e, 0x080c, 0x93f4, 0x2c20, 0x080c, 0xce97, 0x005e, 0x007e,
+	0x00be, 0x0005, 0x00b6, 0x0046, 0x0056, 0x0076, 0x00c6, 0x0156,
+	0x2c20, 0x20a9, 0x0800, 0x900e, 0x0016, 0x0036, 0x080c, 0x5f7e,
+	0x11a0, 0x0086, 0x9046, 0x2828, 0x0046, 0x2021, 0x0001, 0x080c,
+	0xd224, 0x004e, 0x0096, 0x904e, 0x080c, 0x9349, 0x009e, 0x008e,
+	0x903e, 0x080c, 0x93f4, 0x080c, 0xce97, 0x003e, 0x001e, 0x8108,
+	0x1f04, 0xcf6c, 0x015e, 0x00ce, 0x007e, 0x005e, 0x004e, 0x00be,
+	0x0005, 0x0016, 0x00f6, 0x080c, 0xb5f9, 0x0198, 0xa864, 0x9084,
+	0x00ff, 0x9086, 0x0046, 0x0180, 0xa800, 0x907d, 0x0138, 0xa803,
+	0x0000, 0xab82, 0x080c, 0x6536, 0x2f48, 0x0cb0, 0xab82, 0x080c,
+	0x6536, 0x00fe, 0x001e, 0x0005, 0xa800, 0x907d, 0x0130, 0xa803,
+	0x0000, 0x080c, 0x6536, 0x2f48, 0x0cb8, 0x080c, 0x6536, 0x0c88,
+	0x00e6, 0x0046, 0x0036, 0x2061, 0x1cd0, 0x9005, 0x1138, 0x2071,
+	0x1800, 0x744c, 0x706c, 0x8001, 0x9402, 0x12d8, 0x2100, 0x9c06,
+	0x0168, 0x6000, 0x9086, 0x0000, 0x0148, 0x6008, 0x9206, 0x1130,
+	0x6010, 0x91a0, 0x0004, 0x2424, 0x9406, 0x0140, 0x9ce0, 0x0018,
+	0x2001, 0x1818, 0x2004, 0x9c02, 0x1220, 0x0c40, 0x9085, 0x0001,
+	0x0008, 0x9006, 0x003e, 0x004e, 0x00ee, 0x0005, 0x0096, 0x0006,
+	0x080c, 0x0fd5, 0x000e, 0x090c, 0x0db2, 0xa867, 0x010d, 0xa88e,
+	0x0026, 0x2010, 0x080c, 0xb5e9, 0x2001, 0x0000, 0x0120, 0x2200,
+	0x9080, 0x0015, 0x2004, 0x002e, 0xa87a, 0xa986, 0xac76, 0xa87f,
+	0x0000, 0x2001, 0x195d, 0x2004, 0xa882, 0x9006, 0xa8e2, 0xa802,
+	0xa86a, 0xa88a, 0x0126, 0x2091, 0x8000, 0x080c, 0x6536, 0x012e,
+	0x009e, 0x0005, 0x6700, 0x9786, 0x0000, 0x0158, 0x9786, 0x0001,
+	0x0140, 0x9786, 0x000a, 0x0128, 0x9786, 0x0009, 0x0110, 0x9085,
+	0x0001, 0x0005, 0x00e6, 0x6010, 0x9075, 0x0138, 0x00b6, 0x2058,
+	0xb8a0, 0x00be, 0x9206, 0x00ee, 0x0005, 0x9085, 0x0001, 0x0cd8,
+	0x0016, 0x6004, 0x908e, 0x001e, 0x11a0, 0x8007, 0x6134, 0x918c,
+	0x00ff, 0x9105, 0x6036, 0x6007, 0x0085, 0x6003, 0x000b, 0x6023,
+	0x0005, 0x2001, 0x1956, 0x2004, 0x601a, 0x080c, 0x8000, 0x080c,
+	0x8582, 0x001e, 0x0005, 0xa001, 0xa001, 0x0005, 0x6024, 0xd0e4,
+	0x0158, 0xd0cc, 0x0118, 0x080c, 0xb927, 0x0030, 0x080c, 0xd240,
+	0x080c, 0x7e13, 0x080c, 0x99d6, 0x0005, 0x9280, 0x0008, 0x2004,
+	0x9084, 0x000f, 0x0002, 0xd071, 0xd071, 0xd071, 0xd073, 0xd071,
+	0xd073, 0xd073, 0xd071, 0xd073, 0xd071, 0xd071, 0xd071, 0xd071,
+	0xd071, 0x9006, 0x0005, 0x9085, 0x0001, 0x0005, 0x9280, 0x0008,
+	0x2004, 0x9084, 0x000f, 0x0002, 0xd08a, 0xd08a, 0xd08a, 0xd08a,
+	0xd08a, 0xd08a, 0xd097, 0xd08a, 0xd08a, 0xd08a, 0xd08a, 0xd08a,
+	0xd08a, 0xd08a, 0x6007, 0x003b, 0x602f, 0x0009, 0x6017, 0x2a00,
+	0x6003, 0x0001, 0x080c, 0x8000, 0x080c, 0x8582, 0x0005, 0x0096,
+	0x00c6, 0x2260, 0x080c, 0xd240, 0x6043, 0x0000, 0x6024, 0xc0f4,
+	0xc0e4, 0x6026, 0x603b, 0x0000, 0x00ce, 0x00d6, 0x2268, 0x9186,
+	0x0007, 0x1904, 0xd0f1, 0x6814, 0x9005, 0x0138, 0x2048, 0xa87c,
+	0xd0fc, 0x1118, 0x00de, 0x009e, 0x08a8, 0x6007, 0x003a, 0x6003,
+	0x0001, 0x080c, 0x8000, 0x080c, 0x8582, 0x00c6, 0x2d60, 0x6100,
+	0x9186, 0x0002, 0x1904, 0xd169, 0x6014, 0x9005, 0x1138, 0x6000,
+	0x9086, 0x0007, 0x190c, 0x0db2, 0x0804, 0xd169, 0x2048, 0x080c,
+	0xb5fb, 0x1130, 0x0028, 0x2048, 0xa800, 0x9005, 0x1de0, 0x2900,
+	0x2048, 0xa87c, 0x9084, 0x0003, 0x9086, 0x0002, 0x1170, 0xa87c,
+	0xc0dc, 0xc0f4, 0xa87e, 0xa880, 0xc0f4, 0xc0fc, 0xa882, 0x2009,
+	0x0043, 0x080c, 0xca06, 0x0804, 0xd169, 0x2009, 0x0041, 0x0804,
+	0xd163, 0x9186, 0x0005, 0x15a8, 0x6814, 0x2048, 0xa87c, 0xd0bc,
+	0x1120, 0x00de, 0x009e, 0x0804, 0xd08a, 0xd0b4, 0x0128, 0xd0fc,
+	0x090c, 0x0db2, 0x0804, 0xd0ab, 0x6007, 0x003a, 0x6003, 0x0001,
+	0x080c, 0x8000, 0x080c, 0x8582, 0x00c6, 0x2d60, 0x6100, 0x9186,
+	0x0002, 0x0120, 0x9186, 0x0004, 0x1904, 0xd169, 0x6814, 0x2048,
+	0xa97c, 0xc1f4, 0xc1dc, 0xa97e, 0xa980, 0xc1f4, 0xc1fc, 0xc1bc,
+	0xa982, 0x00f6, 0x2c78, 0x080c, 0x1582, 0x00fe, 0x2009, 0x0042,
+	0x04d0, 0x0036, 0x080c, 0x0fd5, 0x090c, 0x0db2, 0xa867, 0x010d,
+	0x9006, 0xa802, 0xa86a, 0xa88a, 0x2d18, 0xab8e, 0xa887, 0x0045,
+	0x2c00, 0xa892, 0x6038, 0xa8a2, 0x2360, 0x6024, 0xc0dd, 0x6026,
+	0x6010, 0x00b6, 0x2058, 0xb8a0, 0x00be, 0x2004, 0x6354, 0xab7a,
+	0xa876, 0x9006, 0xa87e, 0xa882, 0xad9a, 0xae96, 0xa89f, 0x0001,
+	0x080c, 0x6536, 0x2019, 0x0045, 0x6008, 0x2068, 0x080c, 0xcbad,
+	0x2d00, 0x600a, 0x6023, 0x0006, 0x6003, 0x0007, 0x901e, 0x631a,
+	0x6342, 0x003e, 0x0038, 0x6043, 0x0000, 0x6003, 0x0007, 0x080c,
+	0xca06, 0x00ce, 0x00de, 0x009e, 0x0005, 0x9186, 0x0013, 0x1128,
+	0x6004, 0x9082, 0x0085, 0x2008, 0x00c2, 0x9186, 0x0027, 0x1178,
+	0x080c, 0x847d, 0x0036, 0x0096, 0x6014, 0x2048, 0x2019, 0x0004,
+	0x080c, 0xcf91, 0x009e, 0x003e, 0x080c, 0x8582, 0x0005, 0x9186,
+	0x0014, 0x0d70, 0x080c, 0x9a6b, 0x0005, 0xd19c, 0xd19a, 0xd19a,
+	0xd19a, 0xd19a, 0xd19a, 0xd19c, 0xd19a, 0xd19a, 0xd19a, 0xd19a,
+	0xd19a, 0xd19a, 0x080c, 0x0db2, 0x080c, 0x847d, 0x6003, 0x000c,
+	0x080c, 0x8582, 0x0005, 0x9182, 0x0092, 0x1220, 0x9182, 0x0085,
+	0x0208, 0x001a, 0x080c, 0x9a6b, 0x0005, 0xd1ba, 0xd1ba, 0xd1ba,
+	0xd1ba, 0xd1bc, 0xd1dc, 0xd1ba, 0xd1ba, 0xd1ba, 0xd1ba, 0xd1ba,
+	0xd1ba, 0xd1ba, 0x080c, 0x0db2, 0x00d6, 0x2c68, 0x080c, 0x9980,
+	0x01b0, 0x6003, 0x0001, 0x6007, 0x001e, 0x2009, 0x026e, 0x210c,
+	0x613a, 0x2009, 0x026f, 0x210c, 0x613e, 0x600b, 0xffff, 0x6910,
+	0x6112, 0x6023, 0x0004, 0x080c, 0x8000, 0x080c, 0x8582, 0x2d60,
+	0x080c, 0x99d6, 0x00de, 0x0005, 0x080c, 0x99d6, 0x0005, 0x00e6,
+	0x6010, 0x00b6, 0x2058, 0xb800, 0x00be, 0xd0ec, 0x00ee, 0x0005,
+	0x2009, 0x1873, 0x210c, 0xd1ec, 0x05b0, 0x6003, 0x0002, 0x6024,
+	0xc0e5, 0x6026, 0xd0cc, 0x0150, 0x2001, 0x1957, 0x2004, 0x6042,
+	0x2009, 0x1873, 0x210c, 0xd1f4, 0x1520, 0x00a0, 0x2009, 0x1873,
+	0x210c, 0xd1f4, 0x0128, 0x6024, 0xc0e4, 0x6026, 0x9006, 0x00d8,
+	0x2001, 0x1957, 0x200c, 0x2001, 0x1955, 0x2004, 0x9100, 0x9080,
+	0x000a, 0x6042, 0x6010, 0x00b6, 0x2058, 0xb8ac, 0x00be, 0x0008,
+	0x2104, 0x9005, 0x0118, 0x9088, 0x0003, 0x0cd0, 0x2c0a, 0x600f,
+	0x0000, 0x9085, 0x0001, 0x0005, 0x0016, 0x00c6, 0x00e6, 0x6154,
+	0xb8ac, 0x2060, 0x8cff, 0x0180, 0x84ff, 0x1118, 0x6054, 0x9106,
+	0x1138, 0x600c, 0x2072, 0x080c, 0x7e13, 0x080c, 0x99d6, 0x0010,
+	0x9cf0, 0x0003, 0x2e64, 0x0c70, 0x00ee, 0x00ce, 0x001e, 0x0005,
+	0x00d6, 0x00b6, 0x6010, 0x2058, 0xb8ac, 0x2068, 0x9005, 0x0130,
+	0x9c06, 0x0110, 0x680c, 0x0cd0, 0x600c, 0x680e, 0x00be, 0x00de,
+	0x0005, 0x0026, 0x0036, 0x0156, 0x2011, 0x182a, 0x2204, 0x9084,
+	0x00ff, 0x2019, 0x026e, 0x2334, 0x9636, 0x1508, 0x8318, 0x2334,
+	0x2204, 0x9084, 0xff00, 0x9636, 0x11d0, 0x2011, 0x0270, 0x20a9,
+	0x0004, 0x6010, 0x0096, 0x2048, 0x2019, 0x000a, 0x080c, 0xa91d,
+	0x009e, 0x1168, 0x2011, 0x0274, 0x20a9, 0x0004, 0x6010, 0x0096,
+	0x2048, 0x2019, 0x0006, 0x080c, 0xa91d, 0x009e, 0x1100, 0x015e,
+	0x003e, 0x002e, 0x0005, 0x00e6, 0x2071, 0x1800, 0x080c, 0x59b4,
+	0x080c, 0x2c2b, 0x00ee, 0x0005, 0x00e6, 0x6010, 0x00b6, 0x2058,
+	0xb800, 0x00be, 0xd0fc, 0x0108, 0x0011, 0x00ee, 0x0005, 0xa880,
+	0xc0e5, 0xa882, 0x0005, 0x00e6, 0x00d6, 0x00c6, 0x0076, 0x0066,
+	0x0056, 0x0046, 0x0026, 0x0016, 0x0126, 0x2091, 0x8000, 0x2029,
+	0x19bf, 0x252c, 0x2021, 0x19c5, 0x2424, 0x2061, 0x1cd0, 0x2071,
+	0x1800, 0x764c, 0x706c, 0x9606, 0x0578, 0x6720, 0x9786, 0x0001,
+	0x0118, 0x9786, 0x0008, 0x1500, 0x2500, 0x9c06, 0x01e8, 0x2400,
+	0x9c06, 0x01d0, 0x080c, 0xd012, 0x01b8, 0x080c, 0xd022, 0x11a0,
+	0x6000, 0x9086, 0x0004, 0x1120, 0x0016, 0x080c, 0x1827, 0x001e,
+	0x080c, 0xb7e9, 0x1110, 0x080c, 0x2e55, 0x080c, 0xb7fa, 0x1110,
+	0x080c, 0xa364, 0x080c, 0x9a06, 0x9ce0, 0x0018, 0x2001, 0x1818,
+	0x2004, 0x9c02, 0x1208, 0x0858, 0x012e, 0x001e, 0x002e, 0x004e,
+	0x005e, 0x006e, 0x007e, 0x00ce, 0x00de, 0x00ee, 0x0005, 0x2001,
+	0x180f, 0x2004, 0xd0dc, 0x0005, 0x0006, 0x2001, 0x1835, 0x2004,
+	0xd09c, 0x000e, 0x0005, 0x0006, 0x0036, 0x0046, 0x080c, 0xbcec,
+	0x0168, 0x2019, 0xffff, 0x9005, 0x0128, 0x6010, 0x00b6, 0x2058,
+	0xbba0, 0x00be, 0x2021, 0x0004, 0x080c, 0x4829, 0x004e, 0x003e,
+	0x000e, 0x6004, 0x9086, 0x0001, 0x1128, 0x080c, 0x94b5, 0x080c,
+	0x9a06, 0x9006, 0x0005, 0x0126, 0x0006, 0x00e6, 0x0016, 0x2091,
+	0x8000, 0x2071, 0x1840, 0xd5a4, 0x0118, 0x7034, 0x8000, 0x7036,
+	0xd5b4, 0x0118, 0x7030, 0x8000, 0x7032, 0xd5ac, 0x0178, 0x2500,
+	0x9084, 0x0007, 0x908e, 0x0003, 0x0148, 0x908e, 0x0004, 0x0130,
+	0x908e, 0x0005, 0x0118, 0x2071, 0x184a, 0x0089, 0x001e, 0x00ee,
+	0x000e, 0x012e, 0x0005, 0x0126, 0x0006, 0x00e6, 0x2091, 0x8000,
+	0x2071, 0x1842, 0x0021, 0x00ee, 0x000e, 0x012e, 0x0005, 0x2e04,
+	0x8000, 0x2072, 0x1220, 0x8e70, 0x2e04, 0x8000, 0x2072, 0x0005,
+	0x00e6, 0x2071, 0x1840, 0x0c99, 0x00ee, 0x0005, 0x00e6, 0x2071,
+	0x1844, 0x0c69, 0x00ee, 0x0005, 0x0126, 0x0006, 0x00e6, 0x2091,
+	0x8000, 0x2071, 0x1840, 0x7044, 0x8000, 0x7046, 0x00ee, 0x000e,
+	0x012e, 0x0005, 0x0002, 0x0003, 0x03d8, 0x0000, 0x8064, 0x0008,
+	0x0010, 0x0000, 0x8066, 0x0000, 0x0101, 0x0008, 0x4406, 0x000b,
+	0x8060, 0x0000, 0x0400, 0x0000, 0x580c, 0x0003, 0x7933, 0x0003,
+	0x5090, 0x000b, 0x4c09, 0x0003, 0xbac0, 0x0009, 0x008a, 0x0000,
+	0x0c09, 0x000b, 0x15fe, 0x0008, 0x3409, 0x0003, 0x808c, 0x0008,
+	0x0001, 0x0000, 0x0000, 0x0007, 0x4047, 0x000a, 0x808c, 0x0008,
+	0x0002, 0x0000, 0x081b, 0x0003, 0x4022, 0x0000, 0x001c, 0x0003,
+	0x4122, 0x0008, 0x4447, 0x0002, 0x0de8, 0x0003, 0x0bfe, 0x0008,
+	0x11a0, 0x0001, 0x11ca, 0x000b, 0x0ca0, 0x0001, 0x11ca, 0x000b,
+	0x9180, 0x0001, 0x0004, 0x0000, 0x8060, 0x0000, 0x0400, 0x0000,
+	0x7f62, 0x0008, 0x8066, 0x0000, 0x0009, 0x0008, 0x442a, 0x0003,
+	0x808c, 0x0008, 0x0000, 0x0008, 0x0060, 0x0008, 0x8062, 0x0008,
+	0x0004, 0x0000, 0x8066, 0x0000, 0x0411, 0x0000, 0x4432, 0x0003,
+	0x03fe, 0x0000, 0x43e0, 0x0001, 0x0dc7, 0x000b, 0xc2c0, 0x0009,
+	0x00ff, 0x0008, 0x02e0, 0x0001, 0x0dc7, 0x000b, 0x9180, 0x0001,
+	0x0005, 0x0008, 0x8060, 0x0000, 0x0400, 0x0000, 0x7f62, 0x0008,
+	0x8066, 0x0000, 0x0019, 0x0000, 0x4441, 0x000b, 0x0240, 0x0002,
+	0x09c4, 0x0003, 0x00fe, 0x0000, 0x31c7, 0x000b, 0x112a, 0x0000,
+	0x002e, 0x0008, 0x022c, 0x0008, 0x3a44, 0x0002, 0x0c09, 0x000b,
+	0x808c, 0x0008, 0x0002, 0x0000, 0x1760, 0x0008, 0x8062, 0x0008,
+	0x000f, 0x0008, 0x8066, 0x0000, 0x0011, 0x0008, 0x4452, 0x0003,
+	0x01fe, 0x0008, 0x42e0, 0x0009, 0x0dba, 0x000b, 0x00fe, 0x0000,
+	0x43e0, 0x0001, 0x0dba, 0x000b, 0x1734, 0x0000, 0x1530, 0x0000,
+	0x1632, 0x0008, 0x0d2a, 0x0008, 0x9880, 0x0001, 0x0010, 0x0000,
+	0x8060, 0x0000, 0x0400, 0x0000, 0x7f62, 0x0008, 0x8066, 0x0000,
+	0x1e0a, 0x0008, 0x4464, 0x0003, 0x808a, 0x0008, 0x0003, 0x0008,
+	0x1a60, 0x0000, 0x8062, 0x0008, 0x0002, 0x0000, 0x586a, 0x0003,
+	0x8066, 0x0000, 0x3679, 0x0000, 0x446d, 0x0003, 0x586e, 0x000b,
+	0x8054, 0x0008, 0x0011, 0x0008, 0x8074, 0x0000, 0x1010, 0x0008,
+	0x1efe, 0x0000, 0x3009, 0x000b, 0x0077, 0x0004, 0x0009, 0x000b,
+	0x1c60, 0x0000, 0x1b62, 0x0000, 0x8066, 0x0000, 0x0231, 0x0008,
+	0x447b, 0x000b, 0x587c, 0x000b, 0x0140, 0x0008, 0x0242, 0x0000,
+	0x1f43, 0x0002, 0x0c86, 0x0003, 0x0d44, 0x0000, 0x0d46, 0x0008,
+	0x0348, 0x0008, 0x044a, 0x0008, 0x008a, 0x0003, 0x0344, 0x0008,
+	0x0446, 0x0008, 0x0548, 0x0008, 0x064a, 0x0000, 0x588a, 0x000b,
+	0x8054, 0x0008, 0x0001, 0x0000, 0x8074, 0x0000, 0x2020, 0x0008,
+	0x4000, 0x000f, 0x3a40, 0x000a, 0x0c0c, 0x000b, 0x2b24, 0x0008,
+	0x2b24, 0x0008, 0x5894, 0x000b, 0x8054, 0x0008, 0x0002, 0x0000,
+	0x1242, 0x0002, 0x08d8, 0x0003, 0x3a45, 0x000a, 0x08c9, 0x0003,
+	0x1e10, 0x000a, 0x7f3c, 0x0000, 0x08c6, 0x0003, 0x1d00, 0x0002,
+	0x7f3a, 0x0000, 0x0d60, 0x0000, 0x7f62, 0x0008, 0x8066, 0x0000,
+	0x0009, 0x0008, 0x44a4, 0x0003, 0x00fe, 0x0000, 0x34c3, 0x0003,
+	0x1c60, 0x0000, 0x8062, 0x0008, 0x0001, 0x0000, 0x8066, 0x0000,
+	0x0009, 0x0008, 0x44ac, 0x000b, 0x00fe, 0x0000, 0x31a3, 0x0003,
+	0x0038, 0x0000, 0x0060, 0x0008, 0x8062, 0x0008, 0x0019, 0x0000,
+	0x8066, 0x0000, 0x0009, 0x0008, 0x44b5, 0x0003, 0x80c0, 0x0009,
+	0x00ff, 0x0008, 0x7f3e, 0x0008, 0x0d60, 0x0000, 0x0efe, 0x0008,
+	0x1f80, 0x0001, 0x7f62, 0x0008, 0x8066, 0x0000, 0x0009, 0x0008,
+	0x44bf, 0x0003, 0x003a, 0x0008, 0x1dfe, 0x0000, 0x00a0, 0x000b,
+	0x0036, 0x0008, 0x0077, 0x0004, 0x00d8, 0x000b, 0x8074, 0x0000,
+	0x2000, 0x0000, 0x00d8, 0x000b, 0x3a44, 0x0002, 0x09cd, 0x0003,
+	0x8074, 0x0000, 0x1000, 0x0000, 0x2d0e, 0x0000, 0x2d0e, 0x0000,
+	0x35a3, 0x000b, 0x26fe, 0x0008, 0x26fe, 0x0008, 0x2700, 0x0008,
+	0x2700, 0x0008, 0x00d0, 0x0009, 0x0ce6, 0x0003, 0x8074, 0x0000,
+	0x4040, 0x0008, 0x58d8, 0x0003, 0x5090, 0x000b, 0x3a46, 0x000a,
+	0x0ce6, 0x0003, 0x3a47, 0x0002, 0x08e3, 0x000b, 0x8054, 0x0008,
+	0x0004, 0x0000, 0x8074, 0x0000, 0x8000, 0x0000, 0x0127, 0x0003,
+	0x92c0, 0x0009, 0x0f88, 0x0008, 0x0809, 0x0003, 0x1a60, 0x0000,
+	0x8062, 0x0008, 0x0002, 0x0000, 0x8066, 0x0000, 0x362a, 0x0000,
+	0x44eb, 0x000b, 0x2000, 0x0000, 0x2000, 0x0000, 0x2102, 0x0000,
+	0x2102, 0x0000, 0x2204, 0x0000, 0x2204, 0x0000, 0x2306, 0x0000,
+	0x2306, 0x0000, 0x2408, 0x0000, 0x2408, 0x0000, 0x250a, 0x0000,
+	0x250a, 0x0000, 0x260c, 0x0000, 0x260c, 0x0000, 0x270e, 0x0000,
+	0x270e, 0x0000, 0x2810, 0x0000, 0x2810, 0x0000, 0x2912, 0x0000,
+	0x2912, 0x0000, 0x1a60, 0x0000, 0x8062, 0x0008, 0x0007, 0x0000,
+	0x8066, 0x0000, 0x0052, 0x0000, 0x4505, 0x0003, 0x92c0, 0x0009,
+	0x0780, 0x0008, 0x0db4, 0x0003, 0x124b, 0x0002, 0x090e, 0x0003,
+	0x2e4d, 0x0002, 0x2e4d, 0x0002, 0x09a3, 0x000b, 0x3a46, 0x000a,
+	0x0d1b, 0x0003, 0x5910, 0x0003, 0x8054, 0x0008, 0x0004, 0x0000,
+	0x1243, 0x000a, 0x0925, 0x0003, 0x8010, 0x0008, 0x000d, 0x0000,
+	0x0194, 0x0004, 0x1810, 0x0000, 0x0194, 0x0004, 0x0125, 0x000b,
+	0x194d, 0x000a, 0x091f, 0x0003, 0x1243, 0x000a, 0x09aa, 0x000b,
+	0x591f, 0x0003, 0x8054, 0x0008, 0x0004, 0x0000, 0x0189, 0x0004,
+	0x1810, 0x0000, 0x0194, 0x0004, 0x8074, 0x0000, 0xf000, 0x0008,
+	0x0d30, 0x0000, 0x3a42, 0x0002, 0x0d2d, 0x0003, 0x15fe, 0x0008,
+	0x344b, 0x0003, 0x0009, 0x000b, 0x8074, 0x0000, 0x0501, 0x0000,
+	0x8010, 0x0008, 0x000c, 0x0008, 0x0194, 0x0004, 0x0009, 0x000b,
+	0xbbe0, 0x0009, 0x0030, 0x0008, 0x0d43, 0x000b, 0x18fe, 0x0000,
+	0x3ce0, 0x0009, 0x0940, 0x0003, 0x15fe, 0x0008, 0x3ce0, 0x0009,
+	0x0940, 0x0003, 0x0184, 0x000c, 0x8076, 0x0008, 0x0040, 0x0000,
+	0x0181, 0x0003, 0x8076, 0x0008, 0x0041, 0x0008, 0x0181, 0x0003,
+	0xbbe0, 0x0009, 0x0032, 0x0000, 0x0d48, 0x0003, 0x3c1e, 0x0008,
+	0x0181, 0x0003, 0xbbe0, 0x0009, 0x0037, 0x0000, 0x0d66, 0x0003,
+	0x18fe, 0x0000, 0x3ce0, 0x0009, 0x0d40, 0x000b, 0x8076, 0x0008,
+	0x0040, 0x0000, 0x1a60, 0x0000, 0x8062, 0x0008, 0x000d, 0x0000,
+	0x2604, 0x0008, 0x2604, 0x0008, 0x2706, 0x0008, 0x2706, 0x0008,
+	0x2808, 0x0000, 0x2808, 0x0000, 0x290a, 0x0000, 0x290a, 0x0000,
+	0x8066, 0x0000, 0x0422, 0x0000, 0x455d, 0x000b, 0x0189, 0x0004,
+	0x8054, 0x0008, 0x0004, 0x0000, 0x8074, 0x0000, 0xf000, 0x0008,
+	0x8072, 0x0000, 0x8000, 0x0000, 0x0127, 0x0003, 0xbbe0, 0x0009,
+	0x0038, 0x0000, 0x0d78, 0x0003, 0x18fe, 0x0000, 0x3ce0, 0x0009,
+	0x0975, 0x0003, 0x15fe, 0x0008, 0x3ce0, 0x0009, 0x0d3c, 0x0003,
+	0x0184, 0x000c, 0x8076, 0x0008, 0x0040, 0x0000, 0x8072, 0x0000,
+	0x8000, 0x0000, 0x01c4, 0x000b, 0x8076, 0x0008, 0x0042, 0x0008,
+	0x0181, 0x0003, 0xbbe0, 0x0009, 0x0016, 0x0000, 0x0d81, 0x0003,
+	0x3a44, 0x0002, 0x0c0b, 0x0003, 0x8072, 0x0000, 0x8000, 0x0000,
+	0x8000, 0x000f, 0x0009, 0x000b, 0x8072, 0x0000, 0x8000, 0x0000,
+	0x0009, 0x000b, 0x3d30, 0x000a, 0x7f00, 0x0000, 0xbc80, 0x0001,
+	0x0007, 0x0000, 0x018d, 0x0003, 0x1930, 0x000a, 0x7f00, 0x0000,
+	0x9880, 0x0001, 0x0007, 0x0000, 0x8060, 0x0000, 0x0400, 0x0000,
+	0x7f62, 0x0008, 0x8066, 0x0000, 0x000a, 0x0008, 0x4592, 0x000b,
+	0x4000, 0x000f, 0x2194, 0x0003, 0x0870, 0x0008, 0x4000, 0x000f,
+	0xbac0, 0x0009, 0x0090, 0x0008, 0x099d, 0x0003, 0x8074, 0x0000,
+	0x0706, 0x0000, 0x019f, 0x0003, 0x8074, 0x0000, 0x0703, 0x0000,
+	0x4000, 0x000f, 0x8010, 0x0008, 0x0008, 0x0000, 0x01d2, 0x0003,
+	0x0189, 0x0004, 0x8010, 0x0008, 0x0007, 0x0000, 0x0194, 0x0004,
+	0x1810, 0x0000, 0x0194, 0x0004, 0x01dc, 0x000b, 0x0189, 0x0004,
+	0x8010, 0x0008, 0x001b, 0x0008, 0x0194, 0x0004, 0x1810, 0x0000,
+	0x0194, 0x0004, 0x8074, 0x0000, 0xf080, 0x0000, 0x0d30, 0x0000,
+	0x0009, 0x000b, 0x8010, 0x0008, 0x0009, 0x0008, 0x01d2, 0x0003,
+	0x8010, 0x0008, 0x0005, 0x0008, 0x01d2, 0x0003, 0x808c, 0x0008,
+	0x0001, 0x0000, 0x8010, 0x0008, 0x0004, 0x0000, 0x4143, 0x000a,
+	0x0859, 0x0003, 0x3a44, 0x0002, 0x0c09, 0x000b, 0x0d2a, 0x0008,
+	0x01d2, 0x0003, 0x8010, 0x0008, 0x0003, 0x0008, 0x01d4, 0x0003,
+	0x8010, 0x0008, 0x000b, 0x0000, 0x01d4, 0x0003, 0x8010, 0x0008,
+	0x0002, 0x0000, 0x01d4, 0x0003, 0x3a47, 0x0002, 0x0cd8, 0x000b,
+	0x8010, 0x0008, 0x0006, 0x0008, 0x01d4, 0x0003, 0x8074, 0x0000,
+	0xf000, 0x0008, 0x0194, 0x0004, 0x0197, 0x0004, 0x3a40, 0x000a,
+	0x0809, 0x0003, 0x8010, 0x0008, 0x000c, 0x0008, 0x0194, 0x0004,
+	0x0009, 0x000b, 0x8074, 0x0000, 0xf080, 0x0000, 0x0d30, 0x0000,
+	0x2e4d, 0x0002, 0x2e4d, 0x0002, 0x09e5, 0x0003, 0x8054, 0x0008,
+	0x0019, 0x0000, 0x0009, 0x000b, 0x8054, 0x0008, 0x0009, 0x0008,
+	0x0009, 0x000b, 0x3a44, 0x0002, 0x0c09, 0x000b, 0x01c7, 0x000b,
+	0x55d0, 0xf6d9, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020,
+	0x0040, 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000,
+	0x4000, 0x8000, 0xac74
+};
+#ifdef UNIQUE_FW_NAME
+unsigned short fw2300tpx_length01 = 0xcf5b;
+#else
+unsigned short risc_code_length01 = 0xcf5b;
+#endif
+
diff -puN /dev/null drivers/scsi/qla2xxx/qla_dbg.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/qla_dbg.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,1229 @@
+/*
+ *                  QLOGIC LINUX SOFTWARE
+ *
+ * QLogic ISP2x00 device driver for Linux 2.6.x
+ * Copyright (C) 2003 QLogic Corporation
+ * (www.qlogic.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+#include "qla_os.h"
+
+#include "qla_def.h"
+
+static int qla_uprintf(char **, char *, ...);
+
+/**
+ * qla2300_fw_dump() - Dumps binary data from the 2300 firmware.
+ * @ha: HA context
+ * @hardware_locked: Called with the hardware_lock
+ */
+void
+qla2300_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
+{
+	int		rval;
+	uint32_t	cnt, timer;
+	uint32_t	risc_address;
+	uint16_t	mb0, mb2;
+
+	uint32_t	stat;
+	device_reg_t	*reg;
+	uint16_t	*dmp_reg;
+	unsigned long	flags;
+	struct qla2300_fw_dump	*fw;
+
+	reg = ha->iobase;
+	risc_address = 0;
+	mb0 = mb2 = 0;
+	flags = 0;
+
+	if (!hardware_locked)
+		spin_lock_irqsave(&ha->hardware_lock, flags);
+
+	if (ha->fw_dump != NULL) {
+		qla_printk(KERN_WARNING, ha,
+		    "Firmware has been previously dumped (%p) -- ignoring "
+		    "request...\n", ha->fw_dump);
+		return;
+	}
+
+	/* Allocate (large) dump buffer. */
+	ha->fw_dump_order = get_order(sizeof(struct qla2300_fw_dump));
+	ha->fw_dump = (struct qla2300_fw_dump *) __get_free_pages(GFP_ATOMIC,
+	    ha->fw_dump_order);
+	if (ha->fw_dump == NULL) {
+		qla_printk(KERN_WARNING, ha,
+		    "Unable to allocated memory for firmware dump (%d/%d).\n",
+		    ha->fw_dump_order, sizeof(struct qla2300_fw_dump));
+		return;
+	}
+	fw = ha->fw_dump;
+
+	rval = QLA_SUCCESS;
+	fw->hccr = RD_REG_WORD(&reg->hccr);
+
+	/* Pause RISC. */
+	WRT_REG_WORD(&reg->hccr, HCCR_PAUSE_RISC); 
+	if (!IS_QLA2312(ha) && !IS_QLA2322(ha)) {
+		for (cnt = 30000;
+		    (RD_REG_WORD(&reg->hccr) & HCCR_RISC_PAUSE) == 0 &&
+			rval == QLA_SUCCESS; cnt--) {
+			if (cnt)
+				udelay(100);
+			else
+				rval = QLA_FUNCTION_TIMEOUT;
+		}
+	} else {
+		udelay(10);
+	}
+
+	if (rval == QLA_SUCCESS) {
+		dmp_reg = (uint16_t *)(reg + 0);
+		for (cnt = 0; cnt < sizeof(fw->pbiu_reg) / 2; cnt++) 
+			fw->pbiu_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x10);
+		for (cnt = 0; cnt < sizeof(fw->risc_host_reg) / 2; cnt++) 
+			fw->risc_host_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x40);
+		for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++) 
+			fw->mailbox_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->ctrl_status, 0x40);
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->resp_dma_reg) / 2; cnt++) 
+			fw->resp_dma_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->ctrl_status, 0x50);
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->dma_reg) / 2; cnt++) 
+			fw->dma_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->ctrl_status, 0x00);
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0xA0);
+		for (cnt = 0; cnt < sizeof(fw->risc_hdw_reg) / 2; cnt++) 
+			fw->risc_hdw_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->pcr, 0x2000); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->risc_gp0_reg) / 2; cnt++) 
+			fw->risc_gp0_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->pcr, 0x2200); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->risc_gp1_reg) / 2; cnt++) 
+			fw->risc_gp1_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->pcr, 0x2400); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->risc_gp2_reg) / 2; cnt++) 
+			fw->risc_gp2_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->pcr, 0x2600); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->risc_gp3_reg) / 2; cnt++) 
+			fw->risc_gp3_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->pcr, 0x2800); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->risc_gp4_reg) / 2; cnt++) 
+			fw->risc_gp4_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->pcr, 0x2A00); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->risc_gp5_reg) / 2; cnt++) 
+			fw->risc_gp5_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->pcr, 0x2C00); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->risc_gp6_reg) / 2; cnt++) 
+			fw->risc_gp6_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->pcr, 0x2E00); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->risc_gp7_reg) / 2; cnt++) 
+			fw->risc_gp7_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->ctrl_status, 0x10); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->frame_buf_hdw_reg) / 2; cnt++) 
+			fw->frame_buf_hdw_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->ctrl_status, 0x20); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->fpm_b0_reg) / 2; cnt++) 
+			fw->fpm_b0_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->ctrl_status, 0x30); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->fpm_b1_reg) / 2; cnt++) 
+			fw->fpm_b1_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		/* Reset RISC. */
+		WRT_REG_WORD(&reg->ctrl_status, CSR_ISP_SOFT_RESET);
+		for (cnt = 0; cnt < 30000; cnt++) {
+			if ((RD_REG_WORD(&reg->ctrl_status) &
+			    CSR_ISP_SOFT_RESET) == 0)
+				break;
+
+			udelay(10);
+		}
+	}
+
+	if (IS_QLA2312(ha) || IS_QLA2322(ha)) {
+		for (cnt = 30000; RD_MAILBOX_REG(ha, reg, 0) != 0 &&
+		    rval == QLA_SUCCESS; cnt--) {
+			if (cnt)
+				udelay(100);
+			else
+				rval = QLA_FUNCTION_TIMEOUT;
+		}
+	}
+
+	if (rval == QLA_SUCCESS) {
+		/* Get RISC SRAM. */
+		risc_address = 0x800;
+ 		WRT_MAILBOX_REG(ha, reg, 0, MBC_READ_RAM_WORD);
+		clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
+	}
+	for (cnt = 0; cnt < sizeof(fw->risc_ram) / 2 && rval == QLA_SUCCESS;
+	    cnt++, risc_address++) {
+ 		WRT_MAILBOX_REG(ha, reg, 1, (uint16_t)risc_address);
+		WRT_REG_WORD(&reg->hccr, HCCR_SET_HOST_INT);
+
+		for (timer = 6000000; timer; timer--) {
+			/* Check for pending interrupts. */
+ 			stat = RD_REG_DWORD(&reg->u.isp2300.host_status);
+			if (stat & HSR_RISC_INT) {
+				stat &= 0xff;
+
+				if (stat == 0x1 || stat == 0x2) {
+					set_bit(MBX_INTERRUPT,
+					    &ha->mbx_cmd_flags);
+
+					mb0 = RD_MAILBOX_REG(ha, reg, 0);
+					mb2 = RD_MAILBOX_REG(ha, reg, 2);
+
+					/* Release mailbox registers. */
+					WRT_REG_WORD(&reg->semaphore, 0);
+					WRT_REG_WORD(&reg->hccr,
+					    HCCR_CLR_RISC_INT);
+					break;
+				} else if (stat == 0x10 || stat == 0x11) {
+					set_bit(MBX_INTERRUPT,
+					    &ha->mbx_cmd_flags);
+
+					mb0 = RD_MAILBOX_REG(ha, reg, 0);
+					mb2 = RD_MAILBOX_REG(ha, reg, 2);
+
+					WRT_REG_WORD(&reg->hccr,
+					    HCCR_CLR_RISC_INT);
+					break;
+				}
+
+				/* clear this intr; it wasn't a mailbox intr */
+				WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
+			}
+			udelay(5);
+		}
+
+		if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
+			rval = mb0 & MBS_MASK;
+			fw->risc_ram[cnt] = mb2;
+		} else {
+			rval = QLA_FUNCTION_FAILED;
+		}
+	}
+
+	if (rval == QLA_SUCCESS) {
+		/* Get stack SRAM. */
+		risc_address = 0x10000;
+ 		WRT_MAILBOX_REG(ha, reg, 0, MBC_READ_RAM_EXTENDED);
+		clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
+	}
+	for (cnt = 0; cnt < sizeof(fw->stack_ram) / 2 && rval == QLA_SUCCESS;
+	    cnt++, risc_address++) {
+ 		WRT_MAILBOX_REG(ha, reg, 1, LSW(risc_address));
+ 		WRT_MAILBOX_REG(ha, reg, 8, MSW(risc_address));
+		WRT_REG_WORD(&reg->hccr, HCCR_SET_HOST_INT);
+
+		for (timer = 6000000; timer; timer--) {
+			/* Check for pending interrupts. */
+ 			stat = RD_REG_DWORD(&reg->u.isp2300.host_status);
+			if (stat & HSR_RISC_INT) {
+				stat &= 0xff;
+
+				if (stat == 0x1 || stat == 0x2) {
+					set_bit(MBX_INTERRUPT,
+					    &ha->mbx_cmd_flags);
+
+					mb0 = RD_MAILBOX_REG(ha, reg, 0);
+					mb2 = RD_MAILBOX_REG(ha, reg, 2);
+
+					/* Release mailbox registers. */
+					WRT_REG_WORD(&reg->semaphore, 0);
+					WRT_REG_WORD(&reg->hccr,
+					    HCCR_CLR_RISC_INT);
+					break;
+				} else if (stat == 0x10 || stat == 0x11) {
+					set_bit(MBX_INTERRUPT,
+					    &ha->mbx_cmd_flags);
+
+					mb0 = RD_MAILBOX_REG(ha, reg, 0);
+					mb2 = RD_MAILBOX_REG(ha, reg, 2);
+
+					WRT_REG_WORD(&reg->hccr,
+					    HCCR_CLR_RISC_INT);
+					break;
+				}
+
+				/* clear this intr; it wasn't a mailbox intr */
+				WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
+			}
+			udelay(5);
+		}
+
+		if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
+			rval = mb0 & MBS_MASK;
+			fw->stack_ram[cnt] = mb2;
+		} else {
+			rval = QLA_FUNCTION_FAILED;
+		}
+	}
+
+	if (rval == QLA_SUCCESS) {
+		/* Get data SRAM. */
+		risc_address = 0x11000;
+ 		WRT_MAILBOX_REG(ha, reg, 0, MBC_READ_RAM_EXTENDED);
+		clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
+	}
+	for (cnt = 0; cnt < sizeof(fw->data_ram) / 2 && rval == QLA_SUCCESS;
+	    cnt++, risc_address++) {
+ 		WRT_MAILBOX_REG(ha, reg, 1, LSW(risc_address));
+ 		WRT_MAILBOX_REG(ha, reg, 8, MSW(risc_address));
+		WRT_REG_WORD(&reg->hccr, HCCR_SET_HOST_INT);
+
+		for (timer = 6000000; timer; timer--) {
+			/* Check for pending interrupts. */
+ 			stat = RD_REG_DWORD(&reg->u.isp2300.host_status);
+			if (stat & HSR_RISC_INT) {
+				stat &= 0xff;
+
+				if (stat == 0x1 || stat == 0x2) {
+					set_bit(MBX_INTERRUPT,
+					    &ha->mbx_cmd_flags);
+
+					mb0 = RD_MAILBOX_REG(ha, reg, 0);
+					mb2 = RD_MAILBOX_REG(ha, reg, 2);
+
+					/* Release mailbox registers. */
+					WRT_REG_WORD(&reg->semaphore, 0);
+					WRT_REG_WORD(&reg->hccr,
+					    HCCR_CLR_RISC_INT);
+					break;
+				} else if (stat == 0x10 || stat == 0x11) {
+					set_bit(MBX_INTERRUPT,
+					    &ha->mbx_cmd_flags);
+
+					mb0 = RD_MAILBOX_REG(ha, reg, 0);
+					mb2 = RD_MAILBOX_REG(ha, reg, 2);
+
+					WRT_REG_WORD(&reg->hccr,
+					    HCCR_CLR_RISC_INT);
+					break;
+				}
+
+				/* clear this intr; it wasn't a mailbox intr */
+				WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
+			}
+			udelay(5);
+		}
+
+		if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
+			rval = mb0 & MBS_MASK;
+			fw->data_ram[cnt] = mb2;
+		} else {
+			rval = QLA_FUNCTION_FAILED;
+		}
+	}
+
+
+	if (rval != QLA_SUCCESS) {
+		qla_printk(KERN_WARNING, ha,
+		    "Failed to dump firmware (%d)!!!\n", rval);
+
+		free_pages((unsigned long)ha->fw_dump, ha->fw_dump_order);
+		ha->fw_dump = NULL;
+	} else {
+		qla_printk(KERN_INFO, ha,
+		    "Firmware dump saved to temp buffer (%ld/%p).\n",
+		    ha->host_no, ha->fw_dump);
+	}
+
+	if (!hardware_locked)
+		spin_unlock_irqrestore(&ha->hardware_lock, flags);
+}
+
+/**
+ * qla2300_ascii_fw_dump() - Converts a binary firmware dump to ASCII.
+ * @ha: HA context
+ */
+void
+qla2300_ascii_fw_dump(scsi_qla_host_t *ha)
+{
+	uint32_t cnt;
+	char *uiter;
+	char fw_info[30];
+	struct qla2300_fw_dump *fw;
+
+	uiter = ha->fw_dump_buffer;
+	fw = ha->fw_dump;
+
+	qla_uprintf(&uiter, "%s Firmware Version %s\n", ha->model_number,
+	    qla2x00_get_fw_version_str(ha, fw_info));
+
+	qla_uprintf(&uiter, "\n[==>BEG]\n");
+
+	qla_uprintf(&uiter, "HCCR Register:\n%04x\n\n", fw->hccr);
+
+	qla_uprintf(&uiter, "PBIU Registers:");
+	for (cnt = 0; cnt < sizeof (fw->pbiu_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->pbiu_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nReqQ-RspQ-Risc2Host Status registers:");
+	for (cnt = 0; cnt < sizeof (fw->risc_host_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_host_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nMailbox Registers:");
+	for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->mailbox_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nAuto Request Response DMA Registers:");
+	for (cnt = 0; cnt < sizeof (fw->resp_dma_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->resp_dma_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nDMA Registers:");
+	for (cnt = 0; cnt < sizeof (fw->dma_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->dma_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nRISC Hardware Registers:");
+	for (cnt = 0; cnt < sizeof (fw->risc_hdw_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_hdw_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nRISC GP0 Registers:");
+	for (cnt = 0; cnt < sizeof (fw->risc_gp0_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_gp0_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nRISC GP1 Registers:");
+	for (cnt = 0; cnt < sizeof (fw->risc_gp1_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_gp1_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nRISC GP2 Registers:");
+	for (cnt = 0; cnt < sizeof (fw->risc_gp2_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_gp2_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nRISC GP3 Registers:");
+	for (cnt = 0; cnt < sizeof (fw->risc_gp3_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_gp3_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nRISC GP4 Registers:");
+	for (cnt = 0; cnt < sizeof (fw->risc_gp4_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_gp4_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nRISC GP5 Registers:");
+	for (cnt = 0; cnt < sizeof (fw->risc_gp5_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_gp5_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nRISC GP6 Registers:");
+	for (cnt = 0; cnt < sizeof (fw->risc_gp6_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_gp6_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nRISC GP7 Registers:");
+	for (cnt = 0; cnt < sizeof (fw->risc_gp7_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_gp7_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nFrame Buffer Hardware Registers:");
+	for (cnt = 0; cnt < sizeof (fw->frame_buf_hdw_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->frame_buf_hdw_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nFPM B0 Registers:");
+	for (cnt = 0; cnt < sizeof (fw->fpm_b0_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->fpm_b0_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nFPM B1 Registers:");
+	for (cnt = 0; cnt < sizeof (fw->fpm_b1_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->fpm_b1_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nCode RAM Dump:");
+	for (cnt = 0; cnt < sizeof (fw->risc_ram) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n%04x: ", cnt + 0x0800);
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_ram[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nStack RAM Dump:");
+	for (cnt = 0; cnt < sizeof (fw->stack_ram) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n%05x: ", cnt + 0x10000);
+		}
+		qla_uprintf(&uiter, "%04x ", fw->stack_ram[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nData RAM Dump:");
+	for (cnt = 0; cnt < sizeof (fw->data_ram) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n%05x: ", cnt + 0x11000);
+		}
+		qla_uprintf(&uiter, "%04x ", fw->data_ram[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\n[<==END] ISP Debug Dump.");
+}
+
+/**
+ * qla2100_fw_dump() - Dumps binary data from the 2100/2200 firmware.
+ * @ha: HA context
+ * @hardware_locked: Called with the hardware_lock
+ */
+void
+qla2100_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
+{
+	int		rval;
+	uint32_t	cnt, timer;
+	uint32_t	risc_address;
+	uint16_t	mb0, mb2;
+
+	device_reg_t	*reg;
+	uint16_t	*dmp_reg;
+	unsigned long	flags;
+	struct qla2100_fw_dump	*fw;
+
+	reg = ha->iobase;
+	risc_address = 0;
+	mb0 = mb2 = 0;
+	flags = 0;
+
+	if (!hardware_locked)
+		spin_lock_irqsave(&ha->hardware_lock, flags);
+
+	if (ha->fw_dump != NULL) {
+		qla_printk(KERN_WARNING, ha,
+		    "Firmware has been previously dumped (%p) -- ignoring "
+		    "request...\n", ha->fw_dump);
+		return;
+	}
+
+	/* Allocate (large) dump buffer. */
+	ha->fw_dump_order = get_order(sizeof(struct qla2100_fw_dump));
+	ha->fw_dump = (struct qla2100_fw_dump *) __get_free_pages(GFP_ATOMIC,
+	    ha->fw_dump_order);
+	if (ha->fw_dump == NULL) {
+		qla_printk(KERN_WARNING, ha,
+		    "Unable to allocated memory for firmware dump (%d/%d).\n",
+		    ha->fw_dump_order, sizeof(struct qla2100_fw_dump));
+		return;
+	}
+	fw = ha->fw_dump;
+
+	rval = QLA_SUCCESS;
+	fw->hccr = RD_REG_WORD(&reg->hccr);
+
+	/* Pause RISC. */
+	WRT_REG_WORD(&reg->hccr, HCCR_PAUSE_RISC); 
+	for (cnt = 30000; (RD_REG_WORD(&reg->hccr) & HCCR_RISC_PAUSE) == 0 &&
+	    rval == QLA_SUCCESS; cnt--) {
+		if (cnt)
+			udelay(100);
+		else
+			rval = QLA_FUNCTION_TIMEOUT;
+	}
+
+	if (rval == QLA_SUCCESS) {
+		dmp_reg = (uint16_t *)(reg + 0);
+		for (cnt = 0; cnt < sizeof(fw->pbiu_reg) / 2; cnt++) 
+			fw->pbiu_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x10);
+		for (cnt = 0; cnt < ha->mbx_count; cnt++) {
+			if (cnt == 8) {
+				dmp_reg = (uint16_t *)((uint8_t *)reg + 0xe0);
+			}
+			fw->mailbox_reg[cnt] = RD_REG_WORD(dmp_reg++);
+		}
+
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x20);
+		for (cnt = 0; cnt < sizeof(fw->dma_reg) / 2; cnt++) 
+			fw->dma_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->ctrl_status, 0x00);
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0xA0);
+		for (cnt = 0; cnt < sizeof(fw->risc_hdw_reg) / 2; cnt++) 
+			fw->risc_hdw_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->pcr, 0x2000); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->risc_gp0_reg) / 2; cnt++) 
+			fw->risc_gp0_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->pcr, 0x2100); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->risc_gp1_reg) / 2; cnt++) 
+			fw->risc_gp1_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->pcr, 0x2200); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->risc_gp2_reg) / 2; cnt++) 
+			fw->risc_gp2_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->pcr, 0x2300); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->risc_gp3_reg) / 2; cnt++) 
+			fw->risc_gp3_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->pcr, 0x2400); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->risc_gp4_reg) / 2; cnt++) 
+			fw->risc_gp4_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->pcr, 0x2500); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->risc_gp5_reg) / 2; cnt++) 
+			fw->risc_gp5_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->pcr, 0x2600); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->risc_gp6_reg) / 2; cnt++) 
+			fw->risc_gp6_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->pcr, 0x2700); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->risc_gp7_reg) / 2; cnt++) 
+			fw->risc_gp7_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->ctrl_status, 0x10); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->frame_buf_hdw_reg) / 2; cnt++) 
+			fw->frame_buf_hdw_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->ctrl_status, 0x20); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->fpm_b0_reg) / 2; cnt++) 
+			fw->fpm_b0_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		WRT_REG_WORD(&reg->ctrl_status, 0x30); 
+		dmp_reg = (uint16_t *)((uint8_t *)reg + 0x80);
+		for (cnt = 0; cnt < sizeof(fw->fpm_b1_reg) / 2; cnt++) 
+			fw->fpm_b1_reg[cnt] = RD_REG_WORD(dmp_reg++);
+
+		/* Disable ISP interrupts. */
+		WRT_REG_WORD(&reg->ictrl, 0);
+
+		/* Reset RISC module. */
+		WRT_REG_WORD(&reg->hccr, HCCR_RESET_RISC);
+
+		/* Release RISC module. */
+		WRT_REG_WORD(&reg->hccr, HCCR_RELEASE_RISC); 
+
+		/* Insure mailbox registers are free. */
+		WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT); 
+		WRT_REG_WORD(&reg->hccr, HCCR_CLR_HOST_INT); 
+	}
+
+	for (cnt = 30000; RD_MAILBOX_REG(ha, reg, 0) != 0 &&
+	    rval == QLA_SUCCESS; cnt--) {
+		if (cnt)
+			udelay(100);
+		else
+			rval = QLA_FUNCTION_TIMEOUT;
+	}
+
+	/* Pause RISC. */
+	if (rval == QLA_SUCCESS && (IS_QLA2200(ha) || (IS_QLA2100(ha) &&
+	    (RD_REG_WORD(&reg->mctr) & (BIT_1 | BIT_0)) != 0))) {
+
+		WRT_REG_WORD(&reg->hccr, HCCR_PAUSE_RISC); 
+		for (cnt = 30000;
+		    (RD_REG_WORD(&reg->hccr) & HCCR_RISC_PAUSE) == 0 &&
+		    rval == QLA_SUCCESS; cnt--) {
+			if (cnt)
+				udelay(100);
+			else
+				rval = QLA_FUNCTION_TIMEOUT;
+		}
+
+		if (rval == QLA_SUCCESS) {
+			/* Set memory configuration and timing. */
+			if (IS_QLA2100(ha))
+				WRT_REG_WORD(&reg->mctr, 0xf1);
+			else
+				WRT_REG_WORD(&reg->mctr, 0xf2);
+
+			/* Release RISC. */
+			WRT_REG_WORD(&reg->hccr, HCCR_RELEASE_RISC);
+		}
+	}
+
+	if (rval == QLA_SUCCESS) {
+		/* Get RISC SRAM. */
+		risc_address = 0x1000;
+ 		WRT_MAILBOX_REG(ha, reg, 0, MBC_READ_RAM_WORD);
+		clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
+	}
+	for (cnt = 0; cnt < sizeof(fw->risc_ram) / 2 && rval == QLA_SUCCESS;
+	    cnt++, risc_address++) {
+ 		WRT_MAILBOX_REG(ha, reg, 1, (uint16_t)risc_address);
+		WRT_REG_WORD(&reg->hccr, HCCR_SET_HOST_INT);
+
+		for (timer = 6000000; timer != 0; timer--) {
+			/* Check for pending interrupts. */
+			if (RD_REG_WORD(&reg->istatus) & ISR_RISC_INT) {
+				if (RD_REG_WORD(&reg->semaphore) & BIT_0) {
+					set_bit(MBX_INTERRUPT,
+					    &ha->mbx_cmd_flags);
+
+					mb0 = RD_MAILBOX_REG(ha, reg, 0);
+					mb2 = RD_MAILBOX_REG(ha, reg, 2);
+
+					WRT_REG_WORD(&reg->semaphore, 0);
+					WRT_REG_WORD(&reg->hccr,
+					    HCCR_CLR_RISC_INT);
+					break;
+				}
+				WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
+			}
+			udelay(5);
+		}
+
+		if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
+			rval = mb0 & MBS_MASK;
+			fw->risc_ram[cnt] = mb2;
+		} else {
+			rval = QLA_FUNCTION_FAILED;
+		}
+	}
+
+	if (rval != QLA_SUCCESS) {
+		qla_printk(KERN_WARNING, ha,
+		    "Failed to dump firmware (%d)!!!\n", rval);
+
+		free_pages((unsigned long)ha->fw_dump, ha->fw_dump_order);
+		ha->fw_dump = NULL;
+	} else {
+		qla_printk(KERN_INFO, ha,
+		    "Firmware dump saved to temp buffer (%ld/%p).\n",
+		    ha->host_no, ha->fw_dump);
+	}
+
+	if (!hardware_locked)
+		spin_unlock_irqrestore(&ha->hardware_lock, flags);
+}
+
+/**
+ * qla2100_ascii_fw_dump() - Converts a binary firmware dump to ASCII.
+ * @ha: HA context
+ */
+void
+qla2100_ascii_fw_dump(scsi_qla_host_t *ha)
+{
+	uint32_t cnt;
+	char *uiter;
+	char fw_info[30];
+	struct qla2100_fw_dump *fw;
+
+	uiter = ha->fw_dump_buffer;
+	fw = ha->fw_dump;
+
+	qla_uprintf(&uiter, "%s Firmware Version %s\n", ha->model_number,
+	    qla2x00_get_fw_version_str(ha, fw_info));
+
+	qla_uprintf(&uiter, "\n[==>BEG]\n");
+
+	qla_uprintf(&uiter, "HCCR Register:\n%04x\n\n", fw->hccr);
+
+	qla_uprintf(&uiter, "PBIU Registers:");
+	for (cnt = 0; cnt < sizeof (fw->pbiu_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->pbiu_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nMailbox Registers:");
+	for (cnt = 0; cnt < sizeof (fw->mailbox_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->mailbox_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nDMA Registers:");
+	for (cnt = 0; cnt < sizeof (fw->dma_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->dma_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nRISC Hardware Registers:");
+	for (cnt = 0; cnt < sizeof (fw->risc_hdw_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_hdw_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nRISC GP0 Registers:");
+	for (cnt = 0; cnt < sizeof (fw->risc_gp0_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_gp0_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nRISC GP1 Registers:");
+	for (cnt = 0; cnt < sizeof (fw->risc_gp1_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_gp1_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nRISC GP2 Registers:");
+	for (cnt = 0; cnt < sizeof (fw->risc_gp2_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_gp2_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nRISC GP3 Registers:");
+	for (cnt = 0; cnt < sizeof (fw->risc_gp3_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_gp3_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nRISC GP4 Registers:");
+	for (cnt = 0; cnt < sizeof (fw->risc_gp4_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_gp4_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nRISC GP5 Registers:");
+	for (cnt = 0; cnt < sizeof (fw->risc_gp5_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_gp5_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nRISC GP6 Registers:");
+	for (cnt = 0; cnt < sizeof (fw->risc_gp6_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_gp6_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nRISC GP7 Registers:");
+	for (cnt = 0; cnt < sizeof (fw->risc_gp7_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_gp7_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nFrame Buffer Hardware Registers:");
+	for (cnt = 0; cnt < sizeof (fw->frame_buf_hdw_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->frame_buf_hdw_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nFPM B0 Registers:");
+	for (cnt = 0; cnt < sizeof (fw->fpm_b0_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->fpm_b0_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nFPM B1 Registers:");
+	for (cnt = 0; cnt < sizeof (fw->fpm_b1_reg) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n");
+		}
+		qla_uprintf(&uiter, "%04x ", fw->fpm_b1_reg[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\nRISC SRAM:");
+	for (cnt = 0; cnt < sizeof (fw->risc_ram) / 2; cnt++) {
+		if (cnt % 8 == 0) {
+			qla_uprintf(&uiter, "\n%04x: ", cnt + 0x1000);
+		}
+		qla_uprintf(&uiter, "%04x ", fw->risc_ram[cnt]);
+	}
+
+	qla_uprintf(&uiter, "\n\n[<==END] ISP Debug Dump.");
+
+	return;
+}
+
+static int
+qla_uprintf(char **uiter, char *fmt, ...)
+{
+	int	iter, len;
+	char	buf[128];
+	va_list	args;
+ 
+	va_start(args, fmt);
+	len = vsprintf(buf, fmt, args);
+	va_end(args);
+
+	for (iter = 0; iter < len; iter++, *uiter += 1)
+		*uiter[0] = buf[iter];
+
+	return (len);
+}
+
+//FIXME
+
+/****************************************************************************/
+/*                         Driver Debug Functions.                          */
+/****************************************************************************/
+
+void 
+qla2x00_dump_regs(scsi_qla_host_t *ha) 
+{
+	device_reg_t	*reg;
+
+	reg = ha->iobase;
+
+	printk("Mailbox registers:\n");
+	printk("scsi(%ld): mbox 0 0x%04x \n",
+	    ha->host_no, RD_MAILBOX_REG(ha, reg, 0));
+	printk("scsi(%ld): mbox 1 0x%04x \n",
+	    ha->host_no, RD_MAILBOX_REG(ha, reg, 1));
+	printk("scsi(%ld): mbox 2 0x%04x \n",
+	    ha->host_no, RD_MAILBOX_REG(ha, reg, 2));
+	printk("scsi(%ld): mbox 3 0x%04x \n",
+	    ha->host_no, RD_MAILBOX_REG(ha, reg, 3));
+	printk("scsi(%ld): mbox 4 0x%04x \n",
+	    ha->host_no, RD_MAILBOX_REG(ha, reg, 4));
+	printk("scsi(%ld): mbox 5 0x%04x \n",
+	    ha->host_no, RD_MAILBOX_REG(ha, reg, 5));
+}
+
+
+void
+qla2x00_dump_buffer(uint8_t * b, uint32_t size) 
+{
+	uint32_t cnt;
+	uint8_t c;
+
+	printk(" 0   1   2   3   4   5   6   7   8   9  "
+	    "Ah  Bh  Ch  Dh  Eh  Fh\n");
+	printk("----------------------------------------"
+	    "----------------------\n");
+
+	for (cnt = 0; cnt < size;) {
+		c = *b++;
+		printk("%02x",(uint32_t) c);
+		cnt++;
+		if (!(cnt % 16))
+			printk("\n");
+		else
+			printk("  ");
+	}
+	if (cnt % 16)
+		printk("\n");
+}
+
+/**************************************************************************
+ *   qla2x00_print_scsi_cmd
+ *	 Dumps out info about the scsi cmd and srb.
+ *   Input	 
+ *	 cmd : struct scsi_cmnd
+ **************************************************************************/
+void
+qla2x00_print_scsi_cmd(struct scsi_cmnd * cmd) 
+{
+	int i;
+	struct scsi_qla_host *ha;
+	srb_t *sp;
+
+	ha = (struct scsi_qla_host *)cmd->device->host->hostdata;
+
+	sp = (srb_t *) cmd->SCp.ptr;
+	printk("SCSI Command @=0x%p, Handle=0x%p\n", cmd, cmd->host_scribble);
+	printk("  chan=0x%02x, target=0x%02x, lun=0x%02x, cmd_len=0x%02x\n",
+	    cmd->device->channel, cmd->device->id, cmd->device->lun,
+	    cmd->cmd_len);
+	printk(" CDB: ");
+	for (i = 0; i < cmd->cmd_len; i++) {
+		printk("0x%02x ", cmd->cmnd[i]);
+	}
+	printk("\n  seg_cnt=%d, allowed=%d, retries=%d, "
+	    "serial_number_at_timeout=0x%lx\n",
+	    cmd->use_sg, cmd->allowed, cmd->retries,
+	    cmd->serial_number_at_timeout);
+	printk("  request buffer=0x%p, request buffer len=0x%x\n",
+	    cmd->request_buffer, cmd->request_bufflen);
+	printk("  tag=%d, transfersize=0x%x\n",
+	    cmd->tag, cmd->transfersize);
+	printk("  serial_number=%lx, SP=%p\n", cmd->serial_number, sp); 
+	printk("  data direction=%d\n", cmd->sc_data_direction);
+
+	if (!sp)
+		return;
+
+	printk("  sp flags=0x%x\n", sp->flags);
+	printk("  r_start=0x%lx, u_start=0x%lx, f_start=0x%lx, state=%d\n",
+	    sp->r_start, sp->u_start, sp->f_start, sp->state);
+
+	printk(" e_start= 0x%lx, ext_history=%d, fo retry=%d, loopid=%x, "
+	    "port path=%d\n", sp->e_start, sp->ext_history, sp->fo_retry_cnt,
+	    sp->lun_queue->fclun->fcport->loop_id,
+	    sp->lun_queue->fclun->fcport->cur_path);
+}
+
+/*
+ * qla2x00_print_q_info
+ * 	 Prints queue info
+ * Input
+ *      q: lun queue	 
+ */ 
+void 
+qla2x00_print_q_info(struct os_lun *q) 
+{
+	printk("Queue info: flags=0x%lx\n", q->q_flag);
+}
+
+#if defined(QL_DEBUG_ROUTINES)
+/*
+ * qla2x00_formatted_dump_buffer
+ *       Prints string plus buffer.
+ *
+ * Input:
+ *       string  = Null terminated string (no newline at end).
+ *       buffer  = buffer address.
+ *       wd_size = word size 8, 16, 32 or 64 bits
+ *       count   = number of words.
+ */
+void
+qla2x00_formatted_dump_buffer(char *string, uint8_t * buffer, 
+				uint8_t wd_size, uint32_t count) 
+{
+	uint32_t cnt;
+	uint16_t *buf16;
+	uint32_t *buf32;
+
+	if (strcmp(string, "") != 0)
+		printk("%s\n",string);
+
+	switch (wd_size) {
+		case 8:
+			printk(" 0    1    2    3    4    5    6    7    "
+				"8    9    Ah   Bh   Ch   Dh   Eh   Fh\n");
+			printk("-----------------------------------------"
+				"-------------------------------------\n");
+
+			for (cnt = 1; cnt <= count; cnt++, buffer++) {
+				printk("%02x",*buffer);
+				if (cnt % 16 == 0)
+					printk("\n");
+				else
+					printk("  ");
+			}
+			if (cnt % 16 != 0)
+				printk("\n");
+			break;
+		case 16:
+			printk("   0      2      4      6      8      Ah "
+				"	Ch     Eh\n");
+			printk("-----------------------------------------"
+				"-------------\n");
+
+			buf16 = (uint16_t *) buffer;
+			for (cnt = 1; cnt <= count; cnt++, buf16++) {
+				printk("%4x",*buf16);
+
+				if (cnt % 8 == 0)
+					printk("\n");
+				else if (*buf16 < 10)
+					printk("   ");
+				else
+					printk("  ");
+			}
+			if (cnt % 8 != 0)
+				printk("\n");
+			break;
+		case 32:
+			printk("       0          4          8          Ch\n");
+			printk("------------------------------------------\n");
+
+			buf32 = (uint32_t *) buffer;
+			for (cnt = 1; cnt <= count; cnt++, buf32++) {
+				printk("%8x", *buf32);
+
+				if (cnt % 4 == 0)
+					printk("\n");
+				else if (*buf32 < 10)
+					printk("   ");
+				else
+					printk("  ");
+			}
+			if (cnt % 4 != 0)
+				printk("\n");
+			break;
+		default:
+			break;
+	}
+}
+
+#endif
+
+
+#if STOP_ON_ERROR
+/**************************************************************************
+*   qla2x00_panic
+*
+**************************************************************************/
+static void 
+qla2x00_panic(char *cp, struct Scsi_Host *host) 
+{
+	struct scsi_qla_host *ha;
+	long *fp;
+
+	ha = (struct scsi_qla_host *) host->hostdata;
+	DEBUG2(ql2x_debug_print = 1;);
+	printk("qla2100 - PANIC:  %s\n", cp);
+	printk("Current time=0x%lx\n", jiffies);
+	printk("Number of pending commands =0x%lx\n", ha->actthreads);
+	printk("Number of queued commands =0x%lx\n", ha->qthreads);
+	printk("Number of free entries = (%d)\n", ha->req_q_cnt);
+	printk("Request Queue @ 0x%lx, Response Queue @ 0x%lx\n",
+			       ha->request_dma, ha->response_dma);
+	printk("Request In Ptr %d\n", ha->req_ring_index);
+	fp = (long *) &ha->flags;
+	printk("HA flags =0x%lx\n", *fp);
+	qla2x00_dump_requests(ha);
+	qla2x00_dump_regs(ha);
+	cli();
+	for (;;) {
+		udelay(2);
+		barrier();
+		/* cpu_relax();*/
+	}
+	sti();
+}
+
+#endif
+
+/**************************************************************************
+*   qla2x00_dump_requests
+*
+**************************************************************************/
+void
+qla2x00_dump_requests(scsi_qla_host_t *ha) 
+{
+
+	struct scsi_cmnd       *cp;
+	srb_t           *sp;
+	int i;
+
+	printk("Outstanding Commands on controller:\n");
+
+	for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) {
+		if ((sp = ha->outstanding_cmds[i]) == NULL)
+			continue;
+		if ((cp = sp->cmd) == NULL)
+			continue;
+
+		printk("(%d): Pid=%ld, sp flags=0x%x, cmd=0x%p\n",
+		    i, sp->cmd->serial_number, sp->flags, CMD_SP(sp->cmd));
+	}
+}
diff -puN /dev/null drivers/scsi/qla2xxx/qla_dbg.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/qla_dbg.h	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,229 @@
+/******************************************************************************
+ *                  QLOGIC LINUX SOFTWARE
+ *
+ * QLogic ISP2x00 device driver for Linux 2.6.x
+ * Copyright (C) 2003 QLogic Corporation
+ * (www.qlogic.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ ******************************************************************************/
+
+/*
+ * Firmware Dump structure definition
+ */
+#define FW_DUMP_SIZE	0xBC000		/* bytes */
+
+struct qla2300_fw_dump {
+	uint16_t hccr;
+	uint16_t pbiu_reg[8];
+	uint16_t risc_host_reg[8];
+	uint16_t mailbox_reg[32];
+	uint16_t resp_dma_reg[32];
+	uint16_t dma_reg[48];
+	uint16_t risc_hdw_reg[16];
+	uint16_t risc_gp0_reg[16];
+	uint16_t risc_gp1_reg[16];
+	uint16_t risc_gp2_reg[16];
+	uint16_t risc_gp3_reg[16];
+	uint16_t risc_gp4_reg[16];
+	uint16_t risc_gp5_reg[16];
+	uint16_t risc_gp6_reg[16];
+	uint16_t risc_gp7_reg[16];
+	uint16_t frame_buf_hdw_reg[64];
+	uint16_t fpm_b0_reg[64];
+	uint16_t fpm_b1_reg[64];
+	uint16_t risc_ram[0xf800];
+	uint16_t stack_ram[0x1000];
+	uint16_t data_ram[0xF000];
+};
+
+struct qla2100_fw_dump {
+	uint16_t hccr;
+	uint16_t pbiu_reg[8];
+	uint16_t mailbox_reg[32];
+	uint16_t dma_reg[48];
+	uint16_t risc_hdw_reg[16];
+	uint16_t risc_gp0_reg[16];
+	uint16_t risc_gp1_reg[16];
+	uint16_t risc_gp2_reg[16];
+	uint16_t risc_gp3_reg[16];
+	uint16_t risc_gp4_reg[16];
+	uint16_t risc_gp5_reg[16];
+	uint16_t risc_gp6_reg[16];
+	uint16_t risc_gp7_reg[16];
+	uint16_t frame_buf_hdw_reg[16];
+	uint16_t fpm_b0_reg[64];
+	uint16_t fpm_b1_reg[64];
+	uint16_t risc_ram[0xf000];
+};
+
+/*
+ * Driver debug definitions.
+ */
+/* #define QL_DEBUG_LEVEL_1  */ /* Output register accesses to COM1 */
+/* #define QL_DEBUG_LEVEL_2  */ /* Output error msgs to COM1 */
+/* #define QL_DEBUG_LEVEL_3  */ /* Output function trace msgs to COM1 */
+/* #define QL_DEBUG_LEVEL_4  */ /* Output NVRAM trace msgs to COM1 */
+/* #define QL_DEBUG_LEVEL_5  */ /* Output ring trace msgs to COM1 */
+/* #define QL_DEBUG_LEVEL_6  */ /* Output WATCHDOG timer trace to COM1 */
+/* #define QL_DEBUG_LEVEL_7  */ /* Output RISC load trace msgs to COM1 */
+/* #define QL_DEBUG_LEVEL_8  */ /* Output ring saturation msgs to COM1 */
+/* #define QL_DEBUG_LEVEL_9  */ /* Output IOCTL trace msgs */
+/* #define QL_DEBUG_LEVEL_10 */ /* Output IOCTL error msgs */
+/* #define QL_DEBUG_LEVEL_11 */ /* Output Mbx Cmd trace msgs */
+/* #define QL_DEBUG_LEVEL_12 */ /* Output IP trace msgs */
+/* #define QL_DEBUG_LEVEL_13 */ /* Output fdmi function trace msgs */
+/* #define QL_DEBUG_LEVEL_14 */ /* Output RSCN trace msgs */
+/*
+ *  Local Macro Definitions.
+ */
+#if defined(QL_DEBUG_LEVEL_1)  || defined(QL_DEBUG_LEVEL_2) || \
+    defined(QL_DEBUG_LEVEL_3)  || defined(QL_DEBUG_LEVEL_4) || \
+    defined(QL_DEBUG_LEVEL_5)  || defined(QL_DEBUG_LEVEL_6) || \
+    defined(QL_DEBUG_LEVEL_7)  || defined(QL_DEBUG_LEVEL_8) || \
+    defined(QL_DEBUG_LEVEL_9)  || defined(QL_DEBUG_LEVEL_10) || \
+    defined(QL_DEBUG_LEVEL_11) || defined(QL_DEBUG_LEVEL_12) || \
+    defined(QL_DEBUG_LEVEL_13) || defined(QL_DEBUG_LEVEL_14)
+    #define QL_DEBUG_ROUTINES
+#endif
+
+/*
+* Macros use for debugging the driver.
+*/
+#undef ENTER_TRACE
+#if defined(ENTER_TRACE)
+#define ENTER(x)	do { printk("qla2100 : Entering %s()\n", x); } while (0)
+#define LEAVE(x)	do { printk("qla2100 : Leaving %s()\n", x);  } while (0)
+#define ENTER_INTR(x)	do { printk("qla2100 : Entering %s()\n", x); } while (0)
+#define LEAVE_INTR(x)	do { printk("qla2100 : Leaving %s()\n", x);  } while (0)
+#else
+#define ENTER(x)	do {} while (0)
+#define LEAVE(x)	do {} while (0)
+#define ENTER_INTR(x) 	do {} while (0)
+#define LEAVE_INTR(x)   do {} while (0)
+#endif
+
+#if  DEBUG_QLA2100
+#define DEBUG(x)	do {x;} while (0);
+#else
+#define DEBUG(x)	do {} while (0);
+#endif
+
+#if defined(QL_DEBUG_LEVEL_1)
+#define DEBUG1(x)	do {x;} while (0);
+#else
+#define DEBUG1(x)	do {} while (0);
+#endif
+
+#if defined(QL_DEBUG_LEVEL_2)
+#define DEBUG2(x)       do {x;} while (0);
+#define DEBUG2_3(x)     do {x;} while (0);
+#define DEBUG2_3_11(x)  do {x;} while (0);
+#define DEBUG2_9_10(x)    do {x;} while (0);
+#define DEBUG2_11(x)    do {x;} while (0);
+#else
+#define DEBUG2(x)	do {} while (0);
+#endif
+
+#if defined(QL_DEBUG_LEVEL_3)
+#define DEBUG3(x)	do {x;} while (0);
+#define DEBUG2_3(x)	do {x;} while (0);
+#define DEBUG2_3_11(x)	do {x;} while (0);
+#define DEBUG3_11(x)	do {x;} while (0);
+#else
+#define DEBUG3(x)	do {} while (0);
+  #if !defined(QL_DEBUG_LEVEL_2)
+  #define DEBUG2_3(x)	do {} while (0);
+  #endif
+#endif
+
+#if defined(QL_DEBUG_LEVEL_4)
+#define DEBUG4(x)	do {x;} while (0);
+#else
+#define DEBUG4(x)	do {} while (0);
+#endif
+
+#if defined(QL_DEBUG_LEVEL_5)
+#define DEBUG5(x)          do {x;} while (0);
+#else
+#define DEBUG5(x)	do {} while (0);
+#endif
+
+#if defined(QL_DEBUG_LEVEL_7)
+#define DEBUG7(x)          do {x;} while (0);
+#else
+#define DEBUG7(x)	   do {} while (0);
+#endif
+
+#if defined(QL_DEBUG_LEVEL_9)
+#define DEBUG9(x)       do {x;} while (0);
+#define DEBUG9_10(x)    do {x;} while (0);
+#define DEBUG2_9_10(x)	do {x;} while (0);
+#else
+#define DEBUG9(x)	do {} while (0);
+#endif
+
+#if defined(QL_DEBUG_LEVEL_10)
+#define DEBUG10(x)      do {x;} while (0);
+#define DEBUG2_9_10(x)	do {x;} while (0);
+#define DEBUG9_10(x)	do {x;} while (0);
+#else
+#define DEBUG10(x)	do {} while (0);
+  #if !defined(DEBUG2_9_10)
+  #define DEBUG2_9_10(x)	do {} while (0);
+  #endif
+  #if !defined(DEBUG9_10)
+  #define DEBUG9_10(x)	do {} while (0);
+  #endif
+#endif
+
+#if defined(QL_DEBUG_LEVEL_11)
+#define DEBUG11(x)      do{x;} while(0);
+#if !defined(DEBUG2_11)
+#define DEBUG2_11(x)    do{x;} while(0);
+#endif
+#if !defined(DEBUG2_3_11)
+#define DEBUG2_3_11(x)  do{x;} while(0);
+#endif
+#if !defined(DEBUG3_11)
+#define DEBUG3_11(x)    do{x;} while(0);
+#endif
+#else
+#define DEBUG11(x)	do{} while(0);
+  #if !defined(QL_DEBUG_LEVEL_2)
+  #define DEBUG2_11(x)	do{} while(0);
+    #if !defined(QL_DEBUG_LEVEL_3)
+    #define DEBUG2_3_11(x) do{} while(0);
+    #endif
+  #endif
+  #if !defined(QL_DEBUG_LEVEL_3)
+  #define DEBUG3_11(x)	do{} while(0);
+  #endif
+#endif
+
+#if defined(QL_DEBUG_LEVEL_12)
+#define DEBUG12(x)      do {x;} while (0);
+#else
+#define DEBUG12(x)	do {} while (0);
+#endif
+
+#if defined(QL_DEBUG_LEVEL_13)
+#define DEBUG13(x)      do {x;} while (0)
+#else
+#define DEBUG13(x)	do {} while (0)
+#endif
+
+#if defined(QL_DEBUG_LEVEL_14)
+#define DEBUG14(x)      do {x;} while (0)
+#else
+#define DEBUG14(x)	do {} while (0)
+#endif
diff -puN /dev/null drivers/scsi/qla2xxx/qla_def.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/qla_def.h	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,2371 @@
+/********************************************************************************
+*                  QLOGIC LINUX SOFTWARE
+*
+* QLogic ISP2x00 device driver for Linux 2.6.x
+* Copyright (C) 2003 QLogic Corporation
+* (www.qlogic.com)
+*
+* This program is free software; you can redistribute it and/or modify it
+* under the terms of the GNU General Public License as published by the
+* Free Software Foundation; either version 2, or (at your option) any
+* later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+* General Public License for more details.
+**
+******************************************************************************/
+
+#ifndef __QLA_DEF_H
+#define __QLA_DEF_H
+
+/* XXX(hch): move to pci_ids.h */
+#ifndef PCI_DEVICE_ID_QLOGIC_ISP2300
+#define PCI_DEVICE_ID_QLOGIC_ISP2300	0x2300
+#endif
+
+#ifndef PCI_DEVICE_ID_QLOGIC_ISP2312
+#define PCI_DEVICE_ID_QLOGIC_ISP2312	0x2312
+#endif
+
+#ifndef PCI_DEVICE_ID_QLOGIC_ISP2322
+#define PCI_DEVICE_ID_QLOGIC_ISP2322	0x2322
+#endif
+
+#if defined(CONFIG_SCSI_QLA21XX) || defined(CONFIG_SCSI_QLA21XX_MODULE)
+#define IS_QLA2100(ha)	((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2100)
+#else
+#define IS_QLA2100(ha)	0
+#endif
+
+#if defined(CONFIG_SCSI_QLA22XX) || defined(CONFIG_SCSI_QLA22XX_MODULE)
+#define IS_QLA2200(ha)	((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2200)
+#else
+#define IS_QLA2200(ha)	0
+#endif
+
+#if defined(CONFIG_SCSI_QLA23XX) || defined(CONFIG_SCSI_QLA23XX_MODULE)
+#define IS_QLA2300(ha)	((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2300)
+#define IS_QLA2312(ha)	((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2312)
+#define IS_QLA2322(ha)	((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2322)
+#define IS_QLA23XX(ha)	(IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA2322(ha))
+#else
+#define IS_QLA2300(ha)	0
+#define IS_QLA2312(ha)	0
+#define IS_QLA2322(ha)	0
+#define IS_QLA23XX(ha)	0
+#endif
+
+/*
+ * Only ISP23XX has extended addressing support in the firmware.
+ */
+#define HAS_EXTENDED_IDS(ha)	IS_QLA23XX(ha)
+
+/*
+ * We have MAILBOX_REGISTER_COUNT sized arrays in a few places,
+ * but that's fine as we don't look at the last 24 ones for
+ * ISP2100 HBAs.
+ */
+#define MAILBOX_REGISTER_COUNT_2100	8
+#define MAILBOX_REGISTER_COUNT		32
+
+#define QLA2200A_RISC_ROM_VER	4
+#define FPM_2300		6
+#define FPM_2310		7
+
+#include "qla_settings.h"
+
+/* 
+ * Data bit definitions
+ */
+#define BIT_0	0x1
+#define BIT_1	0x2
+#define BIT_2	0x4
+#define BIT_3	0x8
+#define BIT_4	0x10
+#define BIT_5	0x20
+#define BIT_6	0x40
+#define BIT_7	0x80
+#define BIT_8	0x100
+#define BIT_9	0x200
+#define BIT_10	0x400
+#define BIT_11	0x800
+#define BIT_12	0x1000
+#define BIT_13	0x2000
+#define BIT_14	0x4000
+#define BIT_15	0x8000
+#define BIT_16	0x10000
+#define BIT_17	0x20000
+#define BIT_18	0x40000
+#define BIT_19	0x80000
+#define BIT_20	0x100000
+#define BIT_21	0x200000
+#define BIT_22	0x400000
+#define BIT_23	0x800000
+#define BIT_24	0x1000000
+#define BIT_25	0x2000000
+#define BIT_26	0x4000000
+#define BIT_27	0x8000000
+#define BIT_28	0x10000000
+#define BIT_29	0x20000000
+#define BIT_30	0x40000000
+#define BIT_31	0x80000000
+
+#define LSB(x)	((uint8_t)(x))
+#define MSB(x)	((uint8_t)((uint16_t)(x) >> 8))
+
+#define LSW(x)	((uint16_t)(x))
+#define MSW(x)	((uint16_t)((uint32_t)(x) >> 16))
+
+#define LSD(x)	((uint32_t)((uint64_t)(x)))
+#define MSD(x)	((uint32_t)((((uint64_t)(x)) >> 16) >> 16))
+
+
+/*
+ * I/O register
+*/
+
+#if MEMORY_MAPPED_IO
+#define RD_REG_BYTE(addr)		readb(addr)
+#define RD_REG_WORD(addr)		readw(addr)
+#define RD_REG_DWORD(addr)		readl(addr)
+#define WRT_REG_BYTE(addr, data)	writeb(data,addr)
+#define WRT_REG_WORD(addr, data)	writew(data,addr)
+#define WRT_REG_DWORD(addr, data)	writel(data,addr)
+#else   /* MEMORY_MAPPED_IO */
+#define RD_REG_BYTE(addr)		(inb((unsigned long)addr))
+#define RD_REG_WORD(addr)		(inw((unsigned long)addr))
+#define RD_REG_DWORD(addr)		(inl((unsigned long)addr))
+#define WRT_REG_BYTE(addr, data)	(outb(data,(unsigned long)addr))
+#define WRT_REG_WORD(addr, data)	(outw(data,(unsigned long)addr))
+#define WRT_REG_DWORD(addr, data)	(outl(data,(unsigned long)addr))
+#endif  /* MEMORY_MAPPED_IO */
+
+/*
+ * Fibre Channel device definitions.
+ */
+#define WWN_SIZE		8	/* Size of WWPN, WWN & WWNN */
+#define MAX_FIBRE_DEVICES	512
+#define MAX_FIBRE_LUNS  	256
+#define	MAX_RSCN_COUNT		32
+#define	MAX_HOST_COUNT		16
+
+/*
+ * Host adapter default definitions.
+ */
+#define MAX_BUSES		1  /* We only have one bus today */
+#define MAX_TARGETS_2100	MAX_FIBRE_DEVICES
+#define MAX_TARGETS_2200	MAX_FIBRE_DEVICES
+#define MAX_TARGETS		MAX_FIBRE_DEVICES
+#define MIN_LUNS		8
+#define MAX_LUNS		MAX_FIBRE_LUNS
+#define MAX_CMDS_PER_LUN	255 
+                                    
+/*
+ * Fibre Channel device definitions.
+ */
+#define SNS_LAST_LOOP_ID_2100	0xfe
+#define SNS_LAST_LOOP_ID_2300	0x7ff
+
+#define LAST_LOCAL_LOOP_ID	0x7d
+#define SNS_FL_PORT		0x7e
+#define FABRIC_CONTROLLER	0x7f
+#define SIMPLE_NAME_SERVER	0x80
+#define SNS_FIRST_LOOP_ID	0x81
+#define MANAGEMENT_SERVER	0xfe
+#define BROADCAST		0xff
+
+#define RESERVED_LOOP_ID(x)	((x > LAST_LOCAL_LOOP_ID && \
+				 x < SNS_FIRST_LOOP_ID) || \
+				 x == MANAGEMENT_SERVER || \
+				 x == BROADCAST)
+
+/*
+ * Timeout timer counts in seconds
+ */
+#define PORT_RETRY_TIME			2
+#define LOOP_DOWN_TIMEOUT		60
+#define LOOP_DOWN_TIME			255	/* 240 */
+#define	LOOP_DOWN_RESET			(LOOP_DOWN_TIME - 30)
+
+/* Maximum outstanding commands in ISP queues (1-65535) */
+#define MAX_OUTSTANDING_COMMANDS	1024
+
+/* ISP request and response entry counts (37-65535) */
+#define REQUEST_ENTRY_CNT		1024	/* Number of request entries. */
+#define RESPONSE_ENTRY_CNT_2100		64	/* Number of response entries.*/
+#define RESPONSE_ENTRY_CNT_2300		512	/* Number of response entries.*/
+
+/* Calculations for SG segments */
+#define SEGS_PER_REQUEST_32	3 
+#define SEGS_PER_CONT_32	7
+#define SG_SEGMENTS_32 (SEGS_PER_REQUEST_32 + \
+    (SEGS_PER_CONT_32 * (REQUEST_ENTRY_CNT - 2)))     
+#define SEGS_PER_REQUEST_64	2 
+#define SEGS_PER_CONT_64	5
+#define SG_SEGMENTS_64 (SEGS_PER_REQUEST_64 + \
+    (SEGS_PER_CONT_64 * (REQUEST_ENTRY_CNT - 2)))     
+
+/*
+ * SCSI Request Block 
+ */
+typedef struct srb {
+	struct list_head list;
+
+	struct scsi_qla_host *ha;	/* HA the SP is queued on */
+
+	struct scsi_cmnd *cmd;		/* Linux SCSI command pkt */
+
+	struct timer_list timer;	/* Command timer */
+	atomic_t ref_count;	/* Reference count for this structure */			
+	uint16_t flags;
+
+	/* Request state */
+	uint16_t state;
+
+	/* Target/LUN queue pointers. */
+	struct os_tgt *tgt_queue;	/* ptr to visible ha's target */
+	struct os_lun *lun_queue;	/* ptr to visible ha's lun */
+	struct fc_lun *fclun;		/* FC LUN context pointer. */
+
+	/* Timing counts. */
+	unsigned long e_start;		/* Start of extend timeout */
+	unsigned long r_start;		/* Start of request */
+	unsigned long u_start;		/* When sent to RISC */
+	unsigned long f_start;		/* When placed in FO queue*/
+
+	/* Single transfer DMA context */
+	dma_addr_t dma_handle;
+
+	uint32_t request_sense_length;
+	uint8_t *request_sense_ptr;
+
+	int ext_history;
+
+	/* Suspend delay */
+	int delay;
+
+	/* Raw completion info for use by failover ? */
+	uint8_t	fo_retry_cnt;		/* Retry count this request */
+	uint8_t	err_id;			/* error id */
+
+	/* SRB magic number */
+	uint16_t magic;
+#define SRB_MAGIC       0x10CB
+} srb_t;
+
+/*
+ * SRB flag definitions
+ */
+#define SRB_TIMEOUT		BIT_0	/* Command timed out */
+#define SRB_DMA_VALID		BIT_1	/* Command sent to ISP */
+#define SRB_WATCHDOG		BIT_2	/* Command on watchdog list */
+#define SRB_ABORT_PENDING	BIT_3	/* Command abort sent to device */
+
+#define SRB_ABORTED		BIT_4	/* Command aborted command already */
+#define SRB_RETRY		BIT_5	/* Command needs retrying */
+#define SRB_GOT_SENSE		BIT_6	/* Command has sense data */
+#define SRB_FAILOVER		BIT_7	/* Command in failover state */
+
+#define SRB_BUSY		BIT_8	/* Command is in busy retry state */
+#define SRB_FO_CANCEL		BIT_9	/* Command don't need to do failover */
+#define	SRB_IOCTL		BIT_10	/* IOCTL command. */
+
+/*
+ * SRB state definitions
+ */
+#define SRB_FREE_STATE		0	/*   returned back */
+#define SRB_PENDING_STATE	1	/*   queued in LUN Q */
+#define SRB_ACTIVE_STATE	2	/*   in Active Array */
+#define SRB_DONE_STATE		3	/*   queued in Done Queue */
+#define SRB_RETRY_STATE		4	/*   in Retry Queue */
+#define SRB_SUSPENDED_STATE	5	/*   in suspended state */
+#define SRB_NO_QUEUE_STATE	6	/*   is in between states */
+#define SRB_ACTIVE_TIMEOUT_STATE 7	/*   in Active Array but timed out */
+#define SRB_FAILOVER_STATE	8	/*   in Failover Queue */
+#define SRB_SCSI_RETRY_STATE	9	/*   in Scsi Retry Queue */
+
+
+/*
+ * ISP I/O Register Set structure definitions.
+ */
+typedef volatile struct {
+	volatile uint16_t flash_address; /* Flash BIOS address */
+	volatile uint16_t flash_data;	/* Flash BIOS data */
+	uint16_t unused_1[1];		/* Gap */
+	volatile uint16_t ctrl_status;	/* Control/Status */
+#define CSR_FLASH_64K_BANK	BIT_3	/* Flash upper 64K bank select */ 
+#define CSR_FLASH_ENABLE	BIT_1	/* Flash BIOS Read/Write enable */
+#define CSR_ISP_SOFT_RESET	BIT_0	/* ISP soft reset */
+
+	volatile uint16_t ictrl;	/* Interrupt control */
+#define ICR_EN_INT		BIT_15	/* ISP enable interrupts. */
+#define ICR_EN_RISC		BIT_3	/* ISP enable RISC interrupts. */
+
+	volatile uint16_t istatus;	/* Interrupt status */
+#define ISR_RISC_INT		BIT_3	/* RISC interrupt */
+
+	volatile uint16_t semaphore;	/* Semaphore */
+	volatile uint16_t nvram;	/* NVRAM register. */
+#define NVR_DESELECT		0
+#define NVR_BUSY		BIT_15
+#define NVR_DATA_IN		BIT_3
+#define NVR_DATA_OUT		BIT_2
+#define NVR_SELECT		BIT_1
+#define NVR_CLOCK		BIT_0
+
+	union {
+		struct {
+			volatile uint16_t mailbox0;
+			volatile uint16_t mailbox1;
+			volatile uint16_t mailbox2;
+			volatile uint16_t mailbox3;
+			volatile uint16_t mailbox4;
+			volatile uint16_t mailbox5;
+			volatile uint16_t mailbox6;
+			volatile uint16_t mailbox7;
+			uint16_t unused_2[59];		/* Gap */
+		} __attribute__((packed)) isp2100;
+		struct {
+							/* Request Queue */
+			volatile uint16_t req_q_in;	/*  In-Pointer */
+			volatile uint16_t req_q_out;	/*  Out-Pointer */
+							/* Response Queue */
+			volatile uint16_t rsp_q_in;	/*  In-Pointer */
+			volatile uint16_t rsp_q_out;	/*  Out-Pointer */
+
+						/* RISC to Host Status */
+			volatile uint32_t host_status;	
+#define HSR_RISC_INT		BIT_15	/* RISC interrupt */
+#define HSR_RISC_PAUSED		BIT_8	/* RISC Paused */
+
+					/* Host to Host Semaphore */
+			volatile uint16_t host_semaphore; 
+			uint16_t unused_3[17];		/* Gap */
+			volatile uint16_t mailbox0;
+			volatile uint16_t mailbox1;
+			volatile uint16_t mailbox2;
+			volatile uint16_t mailbox3;
+			volatile uint16_t mailbox4;
+			volatile uint16_t mailbox5;
+			volatile uint16_t mailbox6;
+			volatile uint16_t mailbox7;
+			volatile uint16_t mailbox8;
+			volatile uint16_t mailbox9;
+			volatile uint16_t mailbox10;
+			volatile uint16_t mailbox11;
+			volatile uint16_t mailbox12;
+			volatile uint16_t mailbox13;
+			volatile uint16_t mailbox14;
+			volatile uint16_t mailbox15;
+			volatile uint16_t mailbox16;
+			volatile uint16_t mailbox17;
+			volatile uint16_t mailbox18;
+			volatile uint16_t mailbox19;
+			volatile uint16_t mailbox20;
+			volatile uint16_t mailbox21;
+			volatile uint16_t mailbox22;
+			volatile uint16_t mailbox23;
+			volatile uint16_t mailbox24;
+			volatile uint16_t mailbox25;
+			volatile uint16_t mailbox26;
+			volatile uint16_t mailbox27;
+			volatile uint16_t mailbox28;
+			volatile uint16_t mailbox29;
+			volatile uint16_t mailbox30;
+			volatile uint16_t mailbox31;
+			volatile uint16_t fb_cmd;
+			uint16_t unused_4[10];		/* Gap */
+		} __attribute__((packed)) isp2300;
+	} u;
+
+	volatile uint16_t fpm_diag_config;
+	uint16_t unused_5[0x6];		/* Gap */
+	volatile uint16_t pcr;		/* Processor Control Register. */
+	uint16_t unused_6[0x5];		/* Gap */
+	volatile uint16_t mctr;		/* Memory Configuration and Timing. */
+	uint16_t unused_7[0x3];		/* Gap */
+	volatile uint16_t fb_cmd_2100;	/* Unused on 23XX */
+	uint16_t unused_8[0x3];		/* Gap */
+	volatile uint16_t hccr;		/* Host command & control register. */
+#define HCCR_HOST_INT		BIT_7	/* Host interrupt bit */
+#define HCCR_RISC_PAUSE		BIT_5	/* Pause mode bit */
+					/* HCCR commands */
+#define HCCR_RESET_RISC		0x1000	/* Reset RISC */
+#define HCCR_PAUSE_RISC		0x2000	/* Pause RISC */
+#define HCCR_RELEASE_RISC	0x3000	/* Release RISC from reset. */
+#define HCCR_SET_HOST_INT	0x5000	/* Set host interrupt */
+#define HCCR_CLR_HOST_INT	0x6000	/* Clear HOST interrupt */
+#define HCCR_CLR_RISC_INT	0x7000	/* Clear RISC interrupt */
+#define	HCCR_DISABLE_PARITY_PAUSE 0x4001 /* Disable parity error RISC pause. */
+#define HCCR_ENABLE_PARITY	0xA000	/* Enable PARITY interrupt */
+
+	uint16_t unused_9[5];		/* Gap */
+	volatile uint16_t gpiod;	/* GPIO Data register. */
+	volatile uint16_t gpioe;	/* GPIO Enable register. */
+#define GPIO_LED_MASK			0x00C0
+#define GPIO_LED_GREEN_OFF_AMBER_OFF	0x0000
+#define GPIO_LED_GREEN_ON_AMBER_OFF	0x0040
+#define GPIO_LED_GREEN_OFF_AMBER_ON	0x0080
+#define GPIO_LED_GREEN_ON_AMBER_ON	0x00C0
+
+	union {
+		struct {
+			uint16_t unused_10[8];		/* Gap */
+			volatile uint16_t mailbox8;
+			volatile uint16_t mailbox9;
+			volatile uint16_t mailbox10;
+			volatile uint16_t mailbox11;
+			volatile uint16_t mailbox12;
+			volatile uint16_t mailbox13;
+			volatile uint16_t mailbox14;
+			volatile uint16_t mailbox15;
+			volatile uint16_t mailbox16;
+			volatile uint16_t mailbox17;
+			volatile uint16_t mailbox18;
+			volatile uint16_t mailbox19;
+			volatile uint16_t mailbox20;
+			volatile uint16_t mailbox21;
+			volatile uint16_t mailbox22;
+			volatile uint16_t mailbox23;	/* Also probe reg. */
+		} __attribute__((packed)) isp2200;
+	} u_end;
+} device_reg_t;
+
+#define	ISP_REQ_Q_IN(ha, reg) \
+	(IS_QLA23XX(ha) ? \
+	 &(reg)->u.isp2300.req_q_in : \
+	 &(reg)->u.isp2100.mailbox4)
+#define	ISP_REQ_Q_OUT(ha, reg) \
+	(IS_QLA23XX(ha) ? \
+	 &(reg)->u.isp2300.req_q_out : \
+	 &(reg)->u.isp2100.mailbox4)
+#define	ISP_RSP_Q_IN(ha, reg) \
+	(IS_QLA23XX(ha) ? \
+	 &(reg)->u.isp2300.rsp_q_in : \
+	 &(reg)->u.isp2100.mailbox5)
+#define	ISP_RSP_Q_OUT(ha, reg) \
+	(IS_QLA23XX(ha) ? \
+	 &(reg)->u.isp2300.rsp_q_out : \
+	 &(reg)->u.isp2100.mailbox5)
+
+#define MAILBOX_REG(ha, reg, num) \
+	(IS_QLA23XX(ha) ? \
+	 &(reg)->u.isp2300.mailbox0 + (num) : \
+	 ((num < 8) ? \
+	  &(reg)->u.isp2100.mailbox0 + (num) : \
+	  &(reg)->u_end.isp2200.mailbox8 + (num) - 8))	/* only for isp2200 */
+#define RD_MAILBOX_REG(ha, reg, num) \
+	RD_REG_WORD(MAILBOX_REG(ha, reg, num))
+#define WRT_MAILBOX_REG(ha, reg, num, data) \
+	WRT_REG_WORD(MAILBOX_REG(ha, reg, num), data)
+
+#define FB_CMD_REG(ha, reg) \
+	(IS_QLA23XX(ha) ? &(reg)->u.isp2300.fb_cmd : &(reg)->fb_cmd_2100)
+#define RD_FB_CMD_REG(ha, reg) \
+	RD_REG_WORD(FB_CMD_REG(ha, reg))
+#define WRT_FB_CMD_REG(ha, reg, data) \
+	WRT_REG_WORD(FB_CMD_REG(ha, reg), data)
+
+
+typedef struct {
+	uint32_t	out_mb;		/* outbound from driver */
+	uint32_t	in_mb;			/* Incoming from RISC */
+	uint16_t	mb[MAILBOX_REGISTER_COUNT];
+	long		buf_size;
+	void		*bufp;
+	uint32_t	tov;
+	uint8_t		flags;
+#define MBX_DMA_IN	BIT_0
+#define	MBX_DMA_OUT	BIT_1
+#define IOCTL_CMD	BIT_2
+} mbx_cmd_t;
+
+#define	MBX_TOV_SECONDS	30
+
+/*
+ *  ISP product identification definitions in mailboxes after reset.
+ */
+#define PROD_ID_1		0x4953
+#define PROD_ID_2		0x0000
+#define PROD_ID_2a		0x5020
+#define PROD_ID_3		0x2020
+
+/*
+ * ISP mailbox Self-Test status codes
+ */
+#define MBS_FRM_ALIVE		0	/* Firmware Alive. */
+#define MBS_CHKSUM_ERR		1	/* Checksum Error. */
+#define MBS_BUSY		4	/* Busy. */
+
+/*
+ * ISP mailbox command complete status codes
+ */
+#define MBS_COMMAND_COMPLETE		0x4000
+#define MBS_INVALID_COMMAND		0x4001
+#define MBS_HOST_INTERFACE_ERROR	0x4002
+#define MBS_TEST_FAILED			0x4003
+#define MBS_COMMAND_ERROR		0x4005
+#define MBS_COMMAND_PARAMETER_ERROR	0x4006
+#define MBS_PORT_ID_USED		0x4007
+#define MBS_LOOP_ID_USED		0x4008
+#define MBS_ALL_IDS_IN_USE		0x4009
+#define MBS_NOT_LOGGED_IN		0x400A
+
+/*
+ * ISP mailbox asynchronous event status codes
+ */
+#define MBA_ASYNC_EVENT		0x8000	/* Asynchronous event. */
+#define MBA_RESET		0x8001	/* Reset Detected. */
+#define MBA_SYSTEM_ERR		0x8002	/* System Error. */
+#define MBA_REQ_TRANSFER_ERR	0x8003	/* Request Transfer Error. */
+#define MBA_RSP_TRANSFER_ERR	0x8004	/* Response Transfer Error. */
+#define MBA_WAKEUP_THRES	0x8005	/* Request Queue Wake-up. */
+#define MBA_LIP_OCCURRED	0x8010	/* Loop Initialization Procedure */
+					/* occurred. */
+#define MBA_LOOP_UP		0x8011	/* FC Loop UP. */
+#define MBA_LOOP_DOWN		0x8012	/* FC Loop Down. */
+#define MBA_LIP_RESET		0x8013	/* LIP reset occurred. */
+#define MBA_PORT_UPDATE		0x8014	/* Port Database update. */
+#define MBA_RSCN_UPDATE		0x8015	/* Register State Chg Notification. */
+#define MBA_LIP_F8		0x8016	/* Received a LIP F8. */
+#define MBA_LOOP_INIT_ERR	0x8017	/* Loop Initialization Error. */
+#define MBA_FABRIC_AUTH_REQ	0x801b	/* Fabric Authentication Required. */
+#define MBA_SCSI_COMPLETION	0x8020	/* SCSI Command Complete. */
+#define MBA_CTIO_COMPLETION	0x8021	/* CTIO Complete. */
+#define MBA_IP_COMPLETION	0x8022	/* IP Transmit Command Complete. */
+#define MBA_IP_RECEIVE		0x8023	/* IP Received. */
+#define MBA_IP_BROADCAST	0x8024	/* IP Broadcast Received. */
+#define MBA_IP_LOW_WATER_MARK	0x8025	/* IP Low Water Mark reached. */
+#define MBA_IP_RCV_BUFFER_EMPTY 0x8026	/* IP receive buffer queue empty. */
+#define MBA_IP_HDR_DATA_SPLIT	0x8027	/* IP header/data splitting feature */
+					/* used. */
+#define MBA_POINT_TO_POINT	0x8030	/* Point to point mode. */
+#define MBA_CMPLT_1_16BIT	0x8031	/* Completion 1 16bit IOSB. */
+#define MBA_CMPLT_2_16BIT	0x8032	/* Completion 2 16bit IOSB. */
+#define MBA_CMPLT_3_16BIT	0x8033	/* Completion 3 16bit IOSB. */
+#define MBA_CMPLT_4_16BIT	0x8034	/* Completion 4 16bit IOSB. */
+#define MBA_CMPLT_5_16BIT	0x8035	/* Completion 5 16bit IOSB. */
+#define MBA_CHG_IN_CONNECTION	0x8036	/* Change in connection mode. */
+#define MBA_RIO_RESPONSE	0x8040	/* RIO response queue update. */
+#define MBA_ZIO_RESPONSE	0x8040	/* ZIO response queue update. */
+#define MBA_CMPLT_2_32BIT	0x8042	/* Completion 2 32bit IOSB. */
+#define MBA_BYPASS_NOTIFICATION	0x8043	/* Auto bypass notification. */
+#define MBA_DISCARD_RND_FRAME	0x8048	/* discard RND frame due to error. */
+#define MBA_REJECTED_FCP_CMD	0x8049	/* rejected FCP_CMD. */
+
+/*
+ * Firmware options 1, 2, 3.
+ */
+#define FO1_AE_ON_LIPF8			BIT_0
+#define FO1_AE_ALL_LIP_RESET		BIT_1
+#define FO1_CTIO_RETRY			BIT_3
+#define FO1_DISABLE_LIP_F7_SW		BIT_4
+#define FO1_DISABLE_100MS_LOS_WAIT	BIT_5
+#define FO1_DISABLE_GPIO6_7		BIT_6
+#define FO1_AE_ON_LOOP_INIT_ERR		BIT_7
+#define FO1_SET_EMPHASIS_SWING		BIT_8
+#define FO1_AE_AUTO_BYPASS		BIT_9
+#define FO1_ENABLE_PURE_IOCB		BIT_10
+#define FO1_AE_PLOGI_RJT		BIT_11
+#define FO1_ENABLE_ABORT_SEQUENCE	BIT_12
+#define FO1_AE_QUEUE_FULL		BIT_13
+
+#define FO2_ENABLE_ATIO_TYPE_3		BIT_0
+#define FO2_REV_LOOPBACK		BIT_1
+
+#define FO3_ENABLE_EMERG_IOCB		BIT_0
+#define FO3_AE_RND_ERROR		BIT_1
+
+/*
+ * ISP mailbox commands
+ */
+#define MBC_LOAD_RAM			1	/* Load RAM. */
+#define MBC_EXECUTE_FIRMWARE		2	/* Execute firmware. */
+#define MBC_WRITE_RAM_WORD		4	/* Write RAM word. */
+#define MBC_READ_RAM_WORD		5	/* Read RAM word. */
+#define MBC_MAILBOX_REGISTER_TEST	6	/* Wrap incoming mailboxes */
+#define MBC_VERIFY_CHECKSUM		7	/* Verify checksum. */
+#define MBC_GET_FIRMWARE_VERSION	8	/* Get firmware revision. */
+#define MBC_LOAD_RISC_RAM		9	/* Load RAM command. */
+#define MBC_DUMP_RISC_RAM		0xa	/* Dump RAM command. */
+#define MBC_LOAD_RISC_RAM_EXTENDED	0xb	/* Load RAM extended. */
+#define MBC_DUMP_RISC_RAM_EXTENDED	0xc	/* Dump RAM extended. */
+#define MBC_WRITE_RAM_WORD_EXTENDED	0xd	/* Write RAM word extended */
+#define MBC_READ_RAM_EXTENDED		0xf	/* Read RAM extended. */
+#define MBC_IOCB_COMMAND		0x12	/* Execute IOCB command. */
+#define MBC_ABORT_COMMAND		0x15	/* Abort IOCB command. */
+#define MBC_ABORT_DEVICE		0x16	/* Abort device (ID/LUN). */
+#define MBC_ABORT_TARGET		0x17	/* Abort target (ID). */
+#define MBC_RESET			0x18	/* Reset. */
+#define MBC_GET_ADAPTER_LOOP_ID		0x20	/* Get loop id of ISP2200. */
+#define MBC_GET_RETRY_COUNT		0x22	/* Get f/w retry cnt/delay. */
+#define MBC_DISABLE_VI			0x24	/* Disable VI operation. */
+#define MBC_ENABLE_VI			0x25	/* Enable VI operation. */
+#define MBC_GET_FIRMWARE_OPTION		0x28	/* Get Firmware Options. */
+#define MBC_SET_FIRMWARE_OPTION		0x38	/* Set Firmware Options. */
+#define MBC_LOOP_PORT_BYPASS		0x40	/* Loop Port Bypass. */
+#define MBC_LOOP_PORT_ENABLE		0x41	/* Loop Port Enable. */
+#define MBC_GET_RESOURCE_COUNTS		0x42	/* Get Resource Counts. */
+#define MBC_NON_PARTICIPATE		0x43	/* Non-Participating Mode. */
+#define MBC_DIAGNOSTIC_ECHO		0x44	/* Diagnostic echo. */
+#define MBC_DIAGNOSTIC_LOOP_BACK	0x45	/* Diagnostic loop back. */
+#define MBC_ONLINE_SELF_TEST		0x46	/* Online self-test. */
+#define MBC_ENHANCED_GET_PORT_DATABASE	0x47	/* Get port database + login */
+#define MBC_RESET_LINK_STATUS		0x52	/* Reset Link Error Status */
+#define MBC_IOCB_COMMAND_A64		0x54	/* Execute IOCB command (64) */
+#define MBC_SEND_RNID_ELS		0x57	/* Send RNID ELS request */
+#define MBC_SET_RNID_PARAMS		0x59	/* Set RNID parameters */
+#define MBC_GET_RNID_PARAMS		0x5a	/* Data Rate */
+#define MBC_DATA_RATE			0x5d	/* Get RNID parameters */
+#define MBC_INITIALIZE_FIRMWARE		0x60	/* Initialize firmware */
+#define MBC_INITIATE_LIP		0x62	/* Initiate Loop */
+						/* Initialization Procedure */
+#define MBC_GET_FC_AL_POSITION_MAP	0x63	/* Get FC_AL Position Map. */
+#define MBC_GET_PORT_DATABASE		0x64	/* Get Port Database. */
+#define MBC_CLEAR_ACA			0x65	/* Clear ACA. */
+#define MBC_TARGET_RESET		0x66	/* Target Reset. */
+#define MBC_CLEAR_TASK_SET		0x67	/* Clear Task Set. */
+#define MBC_ABORT_TASK_SET		0x68	/* Abort Task Set. */
+#define MBC_GET_FIRMWARE_STATE		0x69	/* Get firmware state. */
+#define MBC_GET_PORT_NAME		0x6a	/* Get port name. */
+#define MBC_GET_LINK_STATUS		0x6b	/* Get port link status. */
+#define MBC_LIP_RESET			0x6c	/* LIP reset. */
+#define MBC_SEND_SNS_COMMAND		0x6e	/* Send Simple Name Server */
+						/* commandd. */
+#define MBC_LOGIN_FABRIC_PORT		0x6f	/* Login fabric port. */
+#define MBC_SEND_CHANGE_REQUEST		0x70	/* Send Change Request. */
+#define MBC_LOGOUT_FABRIC_PORT		0x71	/* Logout fabric port. */
+#define MBC_LIP_FULL_LOGIN		0x72	/* Full login LIP. */
+#define MBC_LOGIN_LOOP_PORT		0x74	/* Login Loop Port. */
+#define MBC_PORT_NODE_NAME_LIST		0x75	/* Get port/node name list. */
+#define MBC_INITIALIZE_RECEIVE_QUEUE	0x77	/* Initialize receive queue */
+#define MBC_UNLOAD_IP			0x79	/* Shutdown IP */
+#define MBC_GET_ID_LIST			0x7C	/* Get Port ID list. */
+#define MBC_SEND_LFA_COMMAND		0x7D	/* Send Loop Fabric Address */
+#define MBC_LUN_RESET			0x7E	/* Send LUN reset */
+
+/* Firmware return data sizes */
+#define FCAL_MAP_SIZE	128
+
+/* Mailbox bit definitions for out_mb and in_mb */
+#define	MBX_31		BIT_31
+#define	MBX_30		BIT_30
+#define	MBX_29		BIT_29
+#define	MBX_28		BIT_28
+#define	MBX_27		BIT_27
+#define	MBX_26		BIT_26
+#define	MBX_25		BIT_25
+#define	MBX_24		BIT_24
+#define	MBX_23		BIT_23
+#define	MBX_22		BIT_22
+#define	MBX_21		BIT_21
+#define	MBX_20		BIT_20
+#define	MBX_19		BIT_19
+#define	MBX_18		BIT_18
+#define	MBX_17		BIT_17
+#define	MBX_16		BIT_16
+#define	MBX_15		BIT_15
+#define	MBX_14		BIT_14
+#define	MBX_13		BIT_13
+#define	MBX_12		BIT_12
+#define	MBX_11		BIT_11
+#define	MBX_10		BIT_10
+#define	MBX_9		BIT_9
+#define	MBX_8		BIT_8
+#define	MBX_7		BIT_7
+#define	MBX_6		BIT_6
+#define	MBX_5		BIT_5
+#define	MBX_4		BIT_4
+#define	MBX_3		BIT_3
+#define	MBX_2		BIT_2
+#define	MBX_1		BIT_1
+#define	MBX_0		BIT_0
+
+/*
+ * Firmware state codes from get firmware state mailbox command
+ */
+#define FSTATE_CONFIG_WAIT      0
+#define FSTATE_WAIT_AL_PA       1
+#define FSTATE_WAIT_LOGIN       2
+#define FSTATE_READY            3
+#define FSTATE_LOSS_OF_SYNC     4
+#define FSTATE_ERROR            5
+#define FSTATE_REINIT           6
+#define FSTATE_NON_PART         7
+
+#define FSTATE_CONFIG_CORRECT      0
+#define FSTATE_P2P_RCV_LIP         1
+#define FSTATE_P2P_CHOOSE_LOOP     2
+#define FSTATE_P2P_RCV_UNIDEN_LIP  3
+#define FSTATE_FATAL_ERROR         4
+#define FSTATE_LOOP_BACK_CONN      5
+
+/*
+ * Port Database structure definition
+ * Little endian except where noted.
+ */
+#define	PORT_DATABASE_SIZE	128	/* bytes */
+typedef struct {
+	uint8_t options;
+	uint8_t control;
+	uint8_t master_state;
+	uint8_t slave_state;
+	uint8_t reserved[2];
+	uint8_t hard_address;
+	uint8_t reserved_1;
+	uint8_t port_id[4];
+	uint8_t node_name[WWN_SIZE];		/* Big endian. */
+	uint8_t port_name[WWN_SIZE];		/* Big endian. */
+	uint16_t execution_throttle;
+	uint16_t execution_count;
+	uint8_t reset_count;
+	uint8_t reserved_2;
+	uint16_t resource_allocation;
+	uint16_t current_allocation;
+	uint16_t queue_head;
+	uint16_t queue_tail;
+	uint16_t transmit_execution_list_next;
+	uint16_t transmit_execution_list_previous;
+	uint16_t common_features;
+	uint16_t total_concurrent_sequences;
+	uint16_t RO_by_information_category;
+	uint8_t recipient;
+	uint8_t initiator;
+	uint16_t receive_data_size;
+	uint16_t concurrent_sequences;
+	uint16_t open_sequences_per_exchange;
+	uint16_t lun_abort_flags;
+	uint16_t lun_stop_flags;
+	uint16_t stop_queue_head;
+	uint16_t stop_queue_tail;
+	uint16_t port_retry_timer;
+	uint16_t next_sequence_id;
+	uint16_t frame_count;
+	uint16_t PRLI_payload_length;
+	uint8_t prli_svc_param_word_0[2];	/* Big endian */
+						/* Bits 15-0 of word 0 */
+	uint8_t prli_svc_param_word_3[2];	/* Big endian */
+						/* Bits 15-0 of word 3 */
+	uint16_t loop_id;
+	uint16_t extended_lun_info_list_pointer;
+	uint16_t extended_lun_stop_list_pointer;
+} port_database_t;
+
+/*
+ * Port database slave/master states
+ */
+#define PD_STATE_DISCOVERY			0
+#define PD_STATE_WAIT_DISCOVERY_ACK		1
+#define PD_STATE_PORT_LOGIN			2
+#define PD_STATE_WAIT_PORT_LOGIN_ACK		3
+#define PD_STATE_PROCESS_LOGIN			4
+#define PD_STATE_WAIT_PROCESS_LOGIN_ACK		5
+#define PD_STATE_PORT_LOGGED_IN			6
+#define PD_STATE_PORT_UNAVAILABLE		7
+#define PD_STATE_PROCESS_LOGOUT			8
+#define PD_STATE_WAIT_PROCESS_LOGOUT_ACK	9
+#define PD_STATE_PORT_LOGOUT			10
+#define PD_STATE_WAIT_PORT_LOGOUT_ACK		11
+
+
+/*
+ * ISP Initialization Control Block.
+ * Little endian except where noted.
+ */
+#define	ICB_VERSION 1
+typedef struct {
+	uint8_t  version;
+	uint8_t  reserved_1;
+
+	/*
+	 * LSB BIT 0  = Enable Hard Loop Id
+	 * LSB BIT 1  = Enable Fairness
+	 * LSB BIT 2  = Enable Full-Duplex
+	 * LSB BIT 3  = Enable Fast Posting
+	 * LSB BIT 4  = Enable Target Mode
+	 * LSB BIT 5  = Disable Initiator Mode
+	 * LSB BIT 6  = Enable ADISC
+	 * LSB BIT 7  = Enable Target Inquiry Data
+	 *
+	 * MSB BIT 0  = Enable PDBC Notify
+	 * MSB BIT 1  = Non Participating LIP
+	 * MSB BIT 2  = Descending Loop ID Search
+	 * MSB BIT 3  = Acquire Loop ID in LIPA
+	 * MSB BIT 4  = Stop PortQ on Full Status
+	 * MSB BIT 5  = Full Login after LIP
+	 * MSB BIT 6  = Node Name Option
+	 * MSB BIT 7  = Ext IFWCB enable bit
+	 */
+	uint8_t  firmware_options[2];
+
+	uint16_t frame_payload_size;
+	uint16_t max_iocb_allocation;
+	uint16_t execution_throttle;
+	uint8_t  retry_count;
+	uint8_t	 retry_delay;			/* unused */
+	uint8_t	 port_name[WWN_SIZE];		/* Big endian. */
+	uint16_t hard_address;
+	uint8_t	 inquiry_data;
+	uint8_t	 login_timeout;
+	uint8_t	 node_name[WWN_SIZE];		/* Big endian. */
+
+	uint16_t request_q_outpointer;
+	uint16_t response_q_inpointer;
+	uint16_t request_q_length;
+	uint16_t response_q_length;
+	uint32_t request_q_address[2];
+	uint32_t response_q_address[2];
+
+	uint16_t lun_enables;
+	uint8_t  command_resource_count;
+	uint8_t  immediate_notify_resource_count;
+	uint16_t timeout;
+	uint8_t  reserved_2[2];
+
+	/*
+	 * LSB BIT 0 = Timer Operation mode bit 0
+	 * LSB BIT 1 = Timer Operation mode bit 1
+	 * LSB BIT 2 = Timer Operation mode bit 2
+	 * LSB BIT 3 = Timer Operation mode bit 3
+	 * LSB BIT 4 = Init Config Mode bit 0
+	 * LSB BIT 5 = Init Config Mode bit 1
+	 * LSB BIT 6 = Init Config Mode bit 2
+	 * LSB BIT 7 = Enable Non part on LIHA failure
+	 *
+	 * MSB BIT 0 = Enable class 2
+	 * MSB BIT 1 = Enable ACK0
+	 * MSB BIT 2 =
+	 * MSB BIT 3 =
+	 * MSB BIT 4 = FC Tape Enable
+	 * MSB BIT 5 = Enable FC Confirm
+	 * MSB BIT 6 = Enable command queuing in target mode
+	 * MSB BIT 7 = No Logo On Link Down
+	 */
+	uint8_t	 add_firmware_options[2];
+
+	uint8_t	 response_accumulation_timer;
+	uint8_t	 interrupt_delay_timer;
+
+	/*
+	 * LSB BIT 0 = Enable Read xfr_rdy
+	 * LSB BIT 1 = Soft ID only
+	 * LSB BIT 2 =
+	 * LSB BIT 3 =
+	 * LSB BIT 4 = FCP RSP Payload [0]
+	 * LSB BIT 5 = FCP RSP Payload [1] / Sbus enable - 2200
+	 * LSB BIT 6 = Enable Out-of-Order frame handling
+	 * LSB BIT 7 = Disable Automatic PLOGI on Local Loop
+	 *
+	 * MSB BIT 0 = Sbus enable - 2300
+	 * MSB BIT 1 =
+	 * MSB BIT 2 =
+	 * MSB BIT 3 =
+	 * MSB BIT 4 =
+	 * MSB BIT 5 = enable 50 ohm termination
+	 * MSB BIT 6 = Data Rate (2300 only)
+	 * MSB BIT 7 = Data Rate (2300 only)
+	 */
+	uint8_t	 special_options[2];
+
+	uint8_t  reserved_3[26];
+} init_cb_t;
+
+/*
+ * Get Link Status mailbox command return buffer.
+ */
+typedef struct {
+	uint32_t	link_fail_cnt;
+	uint32_t	loss_sync_cnt;
+	uint32_t	loss_sig_cnt;
+	uint32_t	prim_seq_err_cnt;
+	uint32_t	inval_xmit_word_cnt;
+	uint32_t	inval_crc_cnt;
+} link_stat_t;
+
+/*
+ * NVRAM Command values.
+ */
+#define NV_START_BIT            BIT_2
+#define NV_WRITE_OP             (BIT_26+BIT_24)
+#define NV_READ_OP              (BIT_26+BIT_25)
+#define NV_ERASE_OP             (BIT_26+BIT_25+BIT_24)
+#define NV_MASK_OP              (BIT_26+BIT_25+BIT_24)
+#define NV_DELAY_COUNT          10
+
+/*
+ * QLogic ISP2100, ISP2200 and ISP2300 NVRAM structure definition.
+ */
+typedef struct {
+	/*
+	 * NVRAM header
+	 */
+	uint8_t	id[4];
+	uint8_t	nvram_version;
+	uint8_t	reserved_0;
+
+	/*
+	 * NVRAM RISC parameter block
+	 */
+	uint8_t	parameter_block_version;
+	uint8_t	reserved_1;
+
+	/*
+	 * LSB BIT 0  = Enable Hard Loop Id
+	 * LSB BIT 1  = Enable Fairness
+	 * LSB BIT 2  = Enable Full-Duplex
+	 * LSB BIT 3  = Enable Fast Posting
+	 * LSB BIT 4  = Enable Target Mode
+	 * LSB BIT 5  = Disable Initiator Mode
+	 * LSB BIT 6  = Enable ADISC
+	 * LSB BIT 7  = Enable Target Inquiry Data
+	 *
+	 * MSB BIT 0  = Enable PDBC Notify
+	 * MSB BIT 1  = Non Participating LIP
+	 * MSB BIT 2  = Descending Loop ID Search
+	 * MSB BIT 3  = Acquire Loop ID in LIPA
+	 * MSB BIT 4  = Stop PortQ on Full Status
+	 * MSB BIT 5  = Full Login after LIP
+	 * MSB BIT 6  = Node Name Option
+	 * MSB BIT 7  = Ext IFWCB enable bit
+	 */
+	uint8_t	 firmware_options[2];
+
+	uint16_t frame_payload_size;
+	uint16_t max_iocb_allocation;
+	uint16_t execution_throttle;
+	uint8_t	 retry_count;
+	uint8_t	 retry_delay;			/* unused */
+	uint8_t	 port_name[WWN_SIZE];		/* Big endian. */
+	uint16_t hard_address;
+	uint8_t	 inquiry_data;
+	uint8_t	 login_timeout;
+	uint8_t	 node_name[WWN_SIZE];		/* Big endian. */
+
+	/*
+	 * LSB BIT 0 = Timer Operation mode bit 0
+	 * LSB BIT 1 = Timer Operation mode bit 1
+	 * LSB BIT 2 = Timer Operation mode bit 2
+	 * LSB BIT 3 = Timer Operation mode bit 3
+	 * LSB BIT 4 = Init Config Mode bit 0
+	 * LSB BIT 5 = Init Config Mode bit 1
+	 * LSB BIT 6 = Init Config Mode bit 2
+	 * LSB BIT 7 = Enable Non part on LIHA failure
+	 *
+	 * MSB BIT 0 = Enable class 2
+	 * MSB BIT 1 = Enable ACK0
+	 * MSB BIT 2 =
+	 * MSB BIT 3 =
+	 * MSB BIT 4 = FC Tape Enable
+	 * MSB BIT 5 = Enable FC Confirm
+	 * MSB BIT 6 = Enable command queuing in target mode
+	 * MSB BIT 7 = No Logo On Link Down
+	 */
+	uint8_t	 add_firmware_options[2];
+
+	uint8_t	 response_accumulation_timer;
+	uint8_t	 interrupt_delay_timer;
+
+	/*
+	 * LSB BIT 0 = Enable Read xfr_rdy
+	 * LSB BIT 1 = Soft ID only
+	 * LSB BIT 2 =
+	 * LSB BIT 3 =
+	 * LSB BIT 4 = FCP RSP Payload [0]
+	 * LSB BIT 5 = FCP RSP Payload [1] / Sbus enable - 2200
+	 * LSB BIT 6 = Enable Out-of-Order frame handling
+	 * LSB BIT 7 = Disable Automatic PLOGI on Local Loop
+	 *
+	 * MSB BIT 0 = Sbus enable - 2300
+	 * MSB BIT 1 =
+	 * MSB BIT 2 =
+	 * MSB BIT 3 =
+	 * MSB BIT 4 =
+	 * MSB BIT 5 = enable 50 ohm termination
+	 * MSB BIT 6 = Data Rate (2300 only)
+	 * MSB BIT 7 = Data Rate (2300 only)
+	 */
+	uint8_t	 special_options[2];
+
+	/* Reserved for expanded RISC parameter block */
+	uint8_t reserved_2[24];
+
+	/*
+	 * LSB BIT 0 = Output Swing 1G bit 0
+	 * LSB BIT 1 = Output Swing 1G bit 1
+	 * LSB BIT 2 = Output Swing 1G bit 2
+	 * LSB BIT 3 = Output Emphasis 1G bit 0
+	 * LSB BIT 4 = Output Emphasis 1G bit 1
+	 * LSB BIT 5 = Output Swing 2G bit 0
+	 * LSB BIT 6 = Output Swing 2G bit 1
+	 * LSB BIT 7 = Output Swing 2G bit 2
+	 *            
+	 * MSB BIT 0 = Output Emphasis 2G bit 0
+	 * MSB BIT 1 = Output Emphasis 2G bit 1
+	 * MSB BIT 2 = Output Enable
+	 * MSB BIT 3 =
+	 * MSB BIT 4 =
+	 * MSB BIT 5 =
+	 * MSB BIT 6 =
+	 * MSB BIT 7 =
+	 */
+	uint8_t seriallink_options[2];
+
+	/*
+	 * NVRAM host parameter block
+	 *
+	 * LSB BIT 0 = Enable spinup delay
+	 * LSB BIT 1 = Disable BIOS
+	 * LSB BIT 2 = Enable Memory Map BIOS
+	 * LSB BIT 3 = Enable Selectable Boot
+	 * LSB BIT 4 = Disable RISC code load
+	 * LSB BIT 5 = Set cache line size 1
+	 * LSB BIT 6 = PCI Parity Disable
+	 * LSB BIT 7 = Enable extended logging
+	 *
+	 * MSB BIT 0 = Enable 64bit addressing
+	 * MSB BIT 1 = Enable lip reset
+	 * MSB BIT 2 = Enable lip full login
+	 * MSB BIT 3 = Enable target reset
+	 * MSB BIT 4 = Enable database storage
+	 * MSB BIT 5 = Enable cache flush read
+	 * MSB BIT 6 = Enable database load
+	 * MSB BIT 7 = Enable alternate WWN
+	 */
+	uint8_t host_p[2];
+
+	uint8_t boot_node_name[WWN_SIZE];
+	uint8_t boot_lun_number;
+	uint8_t reset_delay;
+	uint8_t port_down_retry_count;
+	uint8_t boot_id_number;
+	uint16_t max_luns_per_target;
+	uint8_t fcode_boot_port_name[WWN_SIZE];
+	uint8_t alternate_port_name[WWN_SIZE];
+	uint8_t alternate_node_name[WWN_SIZE];
+
+	/*
+	 * BIT 0 = Boot Zoning
+	 * BIT 1 = Alt-Boot Enable
+	 * BIT 2 = Report SCSI Path
+	 * BIT 3 = unused
+	 * BIT 4 = unused
+	 * BIT 5 = unused
+	 * BIT 6 = unused
+	 * BIT 7 = unused
+	 */
+	uint8_t efi_parameters;
+
+	uint8_t link_down_timeout;
+
+	uint8_t adapter_id_0[4];
+	uint8_t adapter_id_1[4];
+	uint8_t adapter_id_2[4];
+	uint8_t adapter_id_3[4];
+
+	uint8_t alt1_boot_node_name[WWN_SIZE];
+	uint16_t alt1_boot_lun_number;
+	uint8_t alt2_boot_node_name[WWN_SIZE];
+	uint16_t alt2_boot_lun_number;
+	uint8_t alt3_boot_node_name[WWN_SIZE];
+	uint16_t alt3_boot_lun_number;
+	uint8_t alt4_boot_node_name[WWN_SIZE];
+	uint16_t alt4_boot_lun_number;
+	uint8_t alt5_boot_node_name[WWN_SIZE];
+	uint16_t alt5_boot_lun_number;
+	uint8_t alt6_boot_node_name[WWN_SIZE];
+	uint16_t alt6_boot_lun_number;
+	uint8_t alt7_boot_node_name[WWN_SIZE];
+	uint16_t alt7_boot_lun_number;
+
+	uint8_t reserved_3[2];
+
+	/* Offset 200-215 : Model Number */
+	uint8_t model_number[16];
+
+	/* OEM related items */
+	uint8_t oem_specific[16];
+
+	/*
+	 * NVRAM Adapter Features offset 232-239
+	 *
+	 * LSB BIT 0 = External GBIC
+	 * LSB BIT 1 = Risc RAM parity
+	 * LSB BIT 2 = Buffer Plus Module
+	 * LSB BIT 3 = Multi Chip Adapter
+	 * LSB BIT 4 = Internal connector
+	 * LSB BIT 5 =
+	 * LSB BIT 6 =
+	 * LSB BIT 7 =
+	 *
+	 * MSB BIT 0 =
+	 * MSB BIT 1 =
+	 * MSB BIT 2 =
+	 * MSB BIT 3 =
+	 * MSB BIT 4 =
+	 * MSB BIT 5 =
+	 * MSB BIT 6 =
+	 * MSB BIT 7 =
+	 */
+	uint8_t	adapter_features[2];
+
+	uint8_t reserved_4[16];
+
+	/* Subsystem vendor ID for ISP2200 */
+	uint16_t subsystem_vendor_id_2200;
+
+	/* Subsystem device ID for ISP2200 */
+	uint16_t subsystem_device_id_2200;
+
+	uint8_t	 reserved_5;
+	uint8_t	 checksum;
+} nvram_t;
+
+/*
+ * ISP queue - response queue entry definition.
+ */
+typedef struct {
+	uint8_t		data[60];
+	uint32_t	signature;
+#define RESPONSE_PROCESSED	0xDEADDEAD	/* Signature */
+} response_t;
+
+typedef union {
+	uint16_t extended;
+	struct {
+		uint8_t reserved;
+		uint8_t standard;
+	} id;
+} target_id_t;
+
+#define SET_TARGET_ID(ha, to, from)			\
+do {							\
+	if (HAS_EXTENDED_IDS(ha))			\
+		to.extended = cpu_to_le16(from);	\
+	else						\
+		to.id.standard = (uint8_t)from;		\
+} while (0)
+
+/*
+ * ISP queue - command entry structure definition.
+ */
+#define COMMAND_TYPE	0x11		/* Command entry */
+#define MAX_CMDSZ	16		/* SCSI maximum CDB size. */
+typedef struct {
+	uint8_t entry_type;		/* Entry type. */
+	uint8_t entry_count;		/* Entry count. */
+	uint8_t sys_define;		/* System defined. */
+	uint8_t entry_status;		/* Entry Status. */
+	uint32_t handle;		/* System handle. */
+	target_id_t target;		/* SCSI ID */
+	uint16_t lun;			/* SCSI LUN */
+	uint16_t control_flags;		/* Control flags. */
+#define CF_WRITE	BIT_6
+#define CF_READ		BIT_5
+#define CF_SIMPLE_TAG	BIT_3
+#define CF_ORDERED_TAG	BIT_2
+#define CF_HEAD_TAG	BIT_1
+	uint16_t reserved_1;
+	uint16_t timeout;		/* Command timeout. */
+	uint16_t dseg_count;		/* Data segment count. */
+	uint8_t scsi_cdb[MAX_CMDSZ]; 	/* SCSI command words. */
+	uint32_t byte_count;		/* Total byte count. */
+	uint32_t dseg_0_address;	/* Data segment 0 address. */
+	uint32_t dseg_0_length;		/* Data segment 0 length. */
+	uint32_t dseg_1_address;	/* Data segment 1 address. */
+	uint32_t dseg_1_length;		/* Data segment 1 length. */
+	uint32_t dseg_2_address;	/* Data segment 2 address. */
+	uint32_t dseg_2_length;		/* Data segment 2 length. */
+} cmd_entry_t;
+
+/*
+ * ISP queue - 64-Bit addressing, command entry structure definition.
+ */
+#define COMMAND_A64_TYPE	0x19	/* Command A64 entry */
+typedef struct {
+	uint8_t entry_type;		/* Entry type. */
+	uint8_t entry_count;		/* Entry count. */
+	uint8_t sys_define;		/* System defined. */
+	uint8_t entry_status;		/* Entry Status. */
+	uint32_t handle;		/* System handle. */
+	target_id_t target;		/* SCSI ID */
+	uint16_t lun;			/* SCSI LUN */
+	uint16_t control_flags;		/* Control flags. */
+	uint16_t reserved_1;
+	uint16_t timeout;		/* Command timeout. */
+	uint16_t dseg_count;		/* Data segment count. */
+	uint8_t scsi_cdb[MAX_CMDSZ];	/* SCSI command words. */
+	uint32_t byte_count;		/* Total byte count. */
+	uint32_t dseg_0_address[2];	/* Data segment 0 address. */
+	uint32_t dseg_0_length;		/* Data segment 0 length. */
+	uint32_t dseg_1_address[2];	/* Data segment 1 address. */
+	uint32_t dseg_1_length;		/* Data segment 1 length. */
+} cmd_a64_entry_t, request_t;
+
+/*
+ * ISP queue - continuation entry structure definition.
+ */
+#define CONTINUE_TYPE		0x02	/* Continuation entry. */
+typedef struct {
+	uint8_t entry_type;		/* Entry type. */
+	uint8_t entry_count;		/* Entry count. */
+	uint8_t sys_define;		/* System defined. */
+	uint8_t entry_status;		/* Entry Status. */
+	uint32_t reserved;
+	uint32_t dseg_0_address;	/* Data segment 0 address. */
+	uint32_t dseg_0_length;		/* Data segment 0 length. */
+	uint32_t dseg_1_address;	/* Data segment 1 address. */
+	uint32_t dseg_1_length;		/* Data segment 1 length. */
+	uint32_t dseg_2_address;	/* Data segment 2 address. */
+	uint32_t dseg_2_length;		/* Data segment 2 length. */
+	uint32_t dseg_3_address;	/* Data segment 3 address. */
+	uint32_t dseg_3_length;		/* Data segment 3 length. */
+	uint32_t dseg_4_address;	/* Data segment 4 address. */
+	uint32_t dseg_4_length;		/* Data segment 4 length. */
+	uint32_t dseg_5_address;	/* Data segment 5 address. */
+	uint32_t dseg_5_length;		/* Data segment 5 length. */
+	uint32_t dseg_6_address;	/* Data segment 6 address. */
+	uint32_t dseg_6_length;		/* Data segment 6 length. */
+} cont_entry_t;
+
+/*
+ * ISP queue - 64-Bit addressing, continuation entry structure definition.
+ */
+#define CONTINUE_A64_TYPE	0x0A	/* Continuation A64 entry. */
+typedef struct {
+	uint8_t entry_type;		/* Entry type. */
+	uint8_t entry_count;		/* Entry count. */
+	uint8_t sys_define;		/* System defined. */
+	uint8_t entry_status;		/* Entry Status. */
+	uint32_t dseg_0_address[2];	/* Data segment 0 address. */
+	uint32_t dseg_0_length;		/* Data segment 0 length. */
+	uint32_t dseg_1_address[2];	/* Data segment 1 address. */
+	uint32_t dseg_1_length;		/* Data segment 1 length. */
+	uint32_t dseg_2_address	[2];	/* Data segment 2 address. */
+	uint32_t dseg_2_length;		/* Data segment 2 length. */
+	uint32_t dseg_3_address[2];	/* Data segment 3 address. */
+	uint32_t dseg_3_length;		/* Data segment 3 length. */
+	uint32_t dseg_4_address[2];	/* Data segment 4 address. */
+	uint32_t dseg_4_length;		/* Data segment 4 length. */
+} cont_a64_entry_t;
+
+/*
+ * ISP queue - status entry structure definition.
+ */
+#define	STATUS_TYPE	0x03		/* Status entry. */
+typedef struct {
+	uint8_t entry_type;		/* Entry type. */
+	uint8_t entry_count;		/* Entry count. */
+	uint8_t sys_define;		/* System defined. */
+	uint8_t entry_status;		/* Entry Status. */
+	uint32_t handle;		/* System handle. */
+	uint16_t scsi_status;		/* SCSI status. */
+	uint16_t comp_status;		/* Completion status. */
+	uint16_t state_flags;		/* State flags. */
+	uint16_t status_flags;		/* Status flags. */
+	uint16_t rsp_info_len;		/* Response Info Length. */
+	uint16_t req_sense_length;	/* Request sense data length. */
+	uint32_t residual_length;	/* Residual transfer length. */
+	uint8_t rsp_info[8];		/* FCP response information. */
+	uint8_t req_sense_data[32];	/* Request sense data. */
+} sts_entry_t;
+
+/*
+ * Status entry entry status
+ */
+#define RF_INV_E_ORDER	BIT_5		/* Invalid entry order. */
+#define RF_INV_E_COUNT	BIT_4		/* Invalid entry count. */
+#define RF_INV_E_PARAM	BIT_3		/* Invalid entry parameter. */
+#define RF_INV_E_TYPE	BIT_2		/* Invalid entry type. */
+#define RF_BUSY		BIT_1		/* Busy */
+
+/*
+ * Status entry SCSI status bit definitions.
+ */
+#define SS_MASK				0xfff	/* Reserved bits BIT_12-BIT_15*/
+#define SS_RESIDUAL_UNDER		BIT_11
+#define SS_RESIDUAL_OVER		BIT_10
+#define SS_SENSE_LEN_VALID		BIT_9
+#define SS_RESIDUAL_LEN_VALID		BIT_8	/* ISP2100 only */
+#define SS_RESPONSE_INFO_LEN_VALID	BIT_8	/* ISP2200 and 23xx */
+
+#define SS_RESERVE_CONFLICT		(BIT_4 | BIT_3)
+#define SS_BUSY_CONDITION		BIT_3
+#define SS_CONDITION_MET		BIT_2
+#define SS_CHECK_CONDITION		BIT_1
+
+/*
+ * Status entry completion status
+ */
+#define CS_COMPLETE		0x0	/* No errors */
+#define CS_INCOMPLETE		0x1	/* Incomplete transfer of cmd. */
+#define CS_DMA			0x2	/* A DMA direction error. */
+#define CS_TRANSPORT		0x3	/* Transport error. */
+#define CS_RESET		0x4	/* SCSI bus reset occurred */
+#define CS_ABORTED		0x5	/* System aborted command. */
+#define CS_TIMEOUT		0x6	/* Timeout error. */
+#define CS_DATA_OVERRUN		0x7	/* Data overrun. */
+
+#define CS_DATA_UNDERRUN	0x15	/* Data Underrun. */
+#define CS_QUEUE_FULL		0x1C	/* Queue Full. */
+#define CS_PORT_UNAVAILABLE	0x28	/* Port unavailable */
+					/* (selection timeout) */
+#define CS_PORT_LOGGED_OUT	0x29	/* Port Logged Out */
+#define CS_PORT_CONFIG_CHG	0x2A	/* Port Configuration Changed */
+#define CS_PORT_BUSY		0x2B	/* Port Busy */
+#define CS_COMPLETE_CHKCOND	0x30	/* Error? */
+#define CS_BAD_PAYLOAD		0x80	/* Driver defined */
+#define CS_UNKNOWN		0x81	/* Driver defined */
+#define CS_RETRY		0x82	/* Driver defined */
+#define CS_LOOP_DOWN_ABORT	0x83	/* Driver defined */
+
+/*
+ * Status entry status flags
+ */
+#define SF_LOGOUT_SENT		BIT_13
+
+/*
+ * ISP queue - status continuation entry structure definition.
+ */
+#define	STATUS_CONT_TYPE	0x10	/* Status continuation entry. */
+typedef struct {
+	uint8_t entry_type;		/* Entry type. */
+	uint8_t entry_count;		/* Entry count. */
+	uint8_t sys_define;		/* System defined. */
+	uint8_t entry_status;		/* Entry Status. */
+	uint8_t data[60];		/* data */
+} sts_cont_entry_t;
+
+/*
+ * ISP queue -	RIO Type 1 status entry (32 bit I/O entry handles)
+ *		structure definition.
+ */
+#define	STATUS_TYPE_21 0x21		/* Status entry. */
+typedef struct {
+	uint8_t entry_type;		/* Entry type. */
+	uint8_t entry_count;		/* Entry count. */
+	uint8_t handle_count;		/* Handle count. */
+	uint8_t entry_status;		/* Entry Status. */
+	uint32_t handle[15];		/* System handles. */
+} sts21_entry_t;
+
+/*
+ * ISP queue -	RIO Type 2 status entry (16 bit I/O entry handles)
+ *		structure definition.
+ */
+#define	STATUS_TYPE_22	0x22		/* Status entry. */
+typedef struct {
+	uint8_t entry_type;		/* Entry type. */
+	uint8_t entry_count;		/* Entry count. */
+	uint8_t handle_count;		/* Handle count. */
+	uint8_t entry_status;		/* Entry Status. */
+	uint16_t handle[30];		/* System handles. */
+} sts22_entry_t;
+
+/*
+ * ISP queue - marker entry structure definition.
+ */
+#define MARKER_TYPE	0x04		/* Marker entry. */
+typedef struct {
+	uint8_t entry_type;		/* Entry type. */
+	uint8_t entry_count;		/* Entry count. */
+	uint8_t handle_count;		/* Handle count. */
+	uint8_t entry_status;		/* Entry Status. */
+	uint32_t sys_define_2;		/* System defined. */
+	target_id_t target;		/* SCSI ID */
+	uint8_t modifier;		/* Modifier (7-0). */
+#define MK_SYNC_ID_LUN	0		/* Synchronize ID/LUN */
+#define MK_SYNC_ID	1		/* Synchronize ID */
+#define MK_SYNC_ALL	2		/* Synchronize all ID/LUN */
+#define MK_SYNC_LIP	3		/* Synchronize all ID/LUN, */
+					/* clear port changed, */
+					/* use sequence number. */
+	uint8_t reserved_1;
+	uint16_t sequence_number;	/* Sequence number of event */
+	uint16_t lun;			/* SCSI LUN */
+	uint8_t reserved_2[48];
+} mrk_entry_t;
+
+/*
+ * ISP queue - Management Server entry structure definition.
+ */
+#define MS_IOCB_TYPE		0x29	/* Management Server IOCB entry */
+typedef struct {
+	uint8_t entry_type;		/* Entry type. */
+	uint8_t entry_count;		/* Entry count. */
+	uint8_t handle_count;		/* Handle count. */
+	uint8_t entry_status;		/* Entry Status. */
+	uint32_t handle1;		/* System handle. */
+	target_id_t loop_id;
+	uint16_t status;
+	uint16_t control_flags;		/* Control flags. */
+	uint16_t reserved2;
+	uint16_t timeout;
+	uint16_t cmd_dsd_count;
+	uint16_t total_dsd_count;
+	uint8_t type;
+	uint8_t r_ctl;
+	uint16_t rx_id;
+	uint16_t reserved3;
+	uint32_t handle2;
+	uint32_t rsp_bytecount;
+	uint32_t req_bytecount;
+	uint32_t dseg_req_address[2];	/* Data segment 0 address. */
+	uint32_t dseg_req_length;	/* Data segment 0 length. */
+	uint32_t dseg_rsp_address[2];	/* Data segment 1 address. */
+	uint32_t dseg_rsp_length;	/* Data segment 1 length. */
+} ms_iocb_entry_t;
+
+
+/*
+ * ISP queue - Mailbox Command entry structure definition.
+ */
+#define MBX_IOCB_TYPE	0x39
+struct mbx_entry {
+	uint8_t entry_type;
+	uint8_t entry_count;
+	uint8_t sys_define1;
+	/* Use sys_define1 for source type */
+#define SOURCE_SCSI	0x00
+#define SOURCE_IP	0x01
+#define SOURCE_VI	0x02
+#define SOURCE_SCTP	0x03
+#define SOURCE_MP	0x04
+#define SOURCE_MPIOCTL	0x05
+#define SOURCE_ASYNC_IOCB 0x07
+
+	uint8_t entry_status;
+
+	uint32_t handle;
+	target_id_t loop_id;
+
+	uint16_t status;
+	uint16_t state_flags;
+	uint16_t status_flags;
+
+	uint32_t sys_define2[2];
+
+	uint16_t mb0;
+	uint16_t mb1;
+	uint16_t mb2;
+	uint16_t mb3;
+	uint16_t mb6;
+	uint16_t mb7;
+	uint16_t mb9;
+	uint16_t mb10;
+	uint32_t reserved_2[2];
+	uint8_t node_name[WWN_SIZE];
+	uint8_t port_name[WWN_SIZE];
+};
+
+/*
+ * ISP request and response queue entry sizes
+ */
+#define RESPONSE_ENTRY_SIZE	(sizeof(response_t))
+#define REQUEST_ENTRY_SIZE	(sizeof(request_t))
+
+
+/*
+ * 24 bit port ID type definition.
+ */
+typedef union {
+	uint32_t b24 : 24;
+
+	struct {
+		uint8_t d_id[3];
+		uint8_t rsvd_1;
+	} r;
+
+	struct {
+		uint8_t al_pa;
+		uint8_t area;
+		uint8_t domain;
+		uint8_t rsvd_1;
+	} b;
+} port_id_t;
+#define INVALID_PORT_ID	0xFFFFFF
+
+/*
+ * Switch info gathering structure.
+ */
+typedef struct {
+	port_id_t d_id;
+	uint8_t node_name[WWN_SIZE];
+	uint8_t port_name[WWN_SIZE];
+	uint32_t type;
+#define SW_TYPE_IP	BIT_1
+#define SW_TYPE_SCSI	BIT_0
+} sw_info_t;
+
+/*
+ * Inquiry command structure.
+ */
+#define INQ_DATA_SIZE	8
+
+/*
+ * Inquiry mailbox IOCB packet definition.
+ */
+typedef struct {
+	union {
+		cmd_a64_entry_t cmd;
+		sts_entry_t rsp;
+	} p;
+	uint8_t inq[INQ_DATA_SIZE];
+} inq_cmd_rsp_t;
+
+/*
+ * Report LUN command structure.
+ */
+#define CHAR_TO_SHORT(a, b)	(uint16_t)((uint8_t)b << 8 | (uint8_t)a)
+
+typedef struct {
+	uint32_t len;
+	uint32_t rsrv;
+} rpt_hdr_t;
+
+typedef struct {
+	struct {
+		uint8_t b : 6;
+		uint8_t address_method : 2;
+	} msb;
+	uint8_t lsb;
+	uint8_t unused[6];
+} rpt_lun_t;
+
+typedef struct {
+	rpt_hdr_t hdr;
+	rpt_lun_t lst[MAX_LUNS];
+} rpt_lun_lst_t;
+
+/*
+ * Report Lun mailbox IOCB packet definition.
+ */
+typedef struct {
+	union {
+		cmd_a64_entry_t cmd;
+		sts_entry_t rsp;
+	} p;
+	rpt_lun_lst_t list;
+} rpt_lun_cmd_rsp_t;
+
+/*
+ * SCSI Target Queue structure
+ */
+typedef struct os_tgt {
+	struct os_lun *olun[MAX_LUNS]; /* LUN context pointer. */
+	struct fc_port *fcport;
+	uint32_t flags;
+	uint8_t port_down_retry_count;
+    	uint32_t down_timer;
+	struct scsi_qla_host *ha;
+
+	/* Persistent binding information */
+	port_id_t d_id;
+	uint8_t node_name[WWN_SIZE];
+	uint8_t port_name[WWN_SIZE];
+} os_tgt_t;
+
+/*
+ * SCSI Target Queue flags
+ */
+#define TQF_QUEUE_SUSPENDED	BIT_0		/* Queue suspended. */
+#define TQF_BOOT_DEVICE		BIT_1		/* Boot device. */
+#define TQF_ONLINE		BIT_2		/* Device online to OS. */
+#define TQF_TGT_RST_NEEDED	BIT_3
+
+/*
+ * SCSI LUN Queue structure
+ */
+typedef struct os_lun {
+	struct fc_lun *fclun;		/* FC LUN context pointer. */
+    	spinlock_t q_lock;		/* Lun Lock */
+
+	unsigned long q_flag;
+#define LUN_MPIO_BUSY		2	/* Lun is changing paths  */
+#define LUN_EXEC_DELAYED	7	/* Lun execution is delayed */
+
+	u_long q_timeout;		/* total command timeouts */
+	atomic_t q_timer;		/* suspend timer */
+	uint32_t q_count;		/* current count */
+	uint32_t q_max;			/* maxmum count lun can be suspended */
+	uint8_t q_state;		/* lun State */
+#define LUN_STATE_READY		1	/* lun is ready for i/o */
+#define LUN_STATE_RUN		2	/* lun has a timer running */
+#define LUN_STATE_WAIT		3	/* lun is suspended */
+#define LUN_STATE_TIMEOUT	4	/* lun has timed out */
+
+	u_long io_cnt;			/* total xfer count since boot */
+	u_long out_cnt;			/* total outstanding IO count */
+	u_long w_cnt;			/* total writes */
+	u_long r_cnt;			/* total reads */
+	u_long avg_time;		/*  */
+} os_lun_t;
+
+
+/* LUN BitMask structure definition, array of 32bit words,
+ * 1 bit per lun.  When bit == 1, the lun is masked.
+ * Most significant bit of mask[0] is lun 0, bit 24 is lun 7.
+ */
+typedef struct lun_bit_mask {
+	/* Must allocate at least enough bits to accomodate all LUNs */
+#if ((MAX_FIBRE_LUNS & 0x7) == 0)
+	uint8_t mask[MAX_FIBRE_LUNS >> 3];
+#else
+	uint8_t mask[(MAX_FIBRE_LUNS + 8) >> 3];
+#endif
+} lun_bit_mask_t;
+
+/*
+ * Fibre channel port type.
+ */
+ typedef enum {
+	FCT_UNKNOWN,
+	FCT_RSCN,
+	FCT_SWITCH,
+	FCT_BROADCAST,
+	FCT_INITIATOR,
+	FCT_TARGET
+} fc_port_type_t;
+
+/*
+ * Fibre channel port structure.
+ */
+typedef struct fc_port {
+	struct list_head list;
+	struct list_head fcluns;
+
+	struct scsi_qla_host *ha;
+	struct scsi_qla_host *vis_ha;	/* only used when suspending lun */
+
+	uint8_t node_name[WWN_SIZE];
+	uint8_t port_name[WWN_SIZE];
+	port_id_t d_id;
+	uint16_t loop_id;
+	uint16_t old_loop_id;
+
+	fc_port_type_t port_type;
+
+	atomic_t state;
+	uint32_t flags;
+
+	os_tgt_t *tgt_queue;
+	uint16_t os_target_id;
+
+	uint16_t iodesc_idx_sent;
+
+	int port_login_retry_count;
+	int login_retry;
+	atomic_t port_down_timer;
+
+	uint8_t device_type;
+	uint8_t unused;
+
+	uint8_t mp_byte;		/* multi-path byte (not used) */
+    	uint8_t cur_path;		/* current path id */
+
+	lun_bit_mask_t lun_mask;
+} fc_port_t;
+
+/*
+ * Fibre channel port/lun states.
+ */
+#define FCS_UNCONFIGURED	1
+#define FCS_DEVICE_DEAD		2
+#define FCS_DEVICE_LOST		3
+#define FCS_ONLINE		4
+#define FCS_NOT_SUPPORTED	5
+#define FCS_FAILOVER		6
+#define FCS_FAILOVER_FAILED	7
+
+/*
+ * FC port flags.
+ */
+#define FCF_FABRIC_DEVICE	BIT_0
+#define FCF_LOGIN_NEEDED	BIT_1
+#define FCF_FO_MASKED		BIT_2
+#define FCF_FAILOVER_NEEDED	BIT_3
+#define FCF_RESET_NEEDED	BIT_4
+#define FCF_PERSISTENT_BOUND	BIT_5
+#define FCF_TAPE_PRESENT	BIT_6
+#define FCF_FARP_DONE		BIT_7
+#define FCF_FARP_FAILED		BIT_8
+#define FCF_FARP_REPLY_NEEDED	BIT_9
+#define FCF_AUTH_REQ		BIT_10
+#define FCF_SEND_AUTH_REQ	BIT_11
+#define FCF_RECEIVE_AUTH_REQ	BIT_12
+#define FCF_AUTH_SUCCESS	BIT_13
+#define FCF_RLC_SUPPORT		BIT_14
+#define FCF_CONFIG		BIT_15	/* Needed? */
+#define FCF_RESCAN_NEEDED	BIT_16
+
+/* No loop ID flag. */
+#define FC_NO_LOOP_ID		0x1000
+
+/*
+ * Fibre channel LUN structure.
+ */
+typedef struct fc_lun {
+        struct list_head list;
+
+	fc_port_t *fcport;
+	fc_port_t *o_fcport;
+	uint16_t lun;
+	atomic_t state;
+	uint8_t device_type;
+	uint8_t max_path_retries;
+} fc_lun_t;
+
+
+/*
+ * FC-CT interface
+ *
+ * NOTE: All structures are big-endian in form.
+ */
+
+#define CT_REJECT_RESPONSE	0x8001
+#define CT_ACCEPT_RESPONSE	0x8002
+
+#define NS_N_PORT_TYPE	0x01
+#define NS_NL_PORT_TYPE	0x02
+#define NS_NX_PORT_TYPE	0x7F
+
+#define	GA_NXT_CMD	0x100
+#define	GA_NXT_REQ_SIZE	(16 + 4)
+#define	GA_NXT_RSP_SIZE	(16 + 620)
+
+#define	GID_PT_CMD	0x1A1
+#define	GID_PT_REQ_SIZE	(16 + 4)
+#define	GID_PT_RSP_SIZE	(16 + (MAX_FIBRE_DEVICES * 4))
+
+#define	GPN_ID_CMD	0x112
+#define	GPN_ID_REQ_SIZE	(16 + 4)
+#define	GPN_ID_RSP_SIZE	(16 + 8)
+
+#define	GNN_ID_CMD	0x113
+#define	GNN_ID_REQ_SIZE	(16 + 4)
+#define	GNN_ID_RSP_SIZE	(16 + 8)
+
+#define	GFT_ID_CMD	0x117
+#define	GFT_ID_REQ_SIZE	(16 + 4)
+#define	GFT_ID_RSP_SIZE	(16 + 32)
+
+#define	RFT_ID_CMD	0x217
+#define	RFT_ID_REQ_SIZE	(16 + 4 + 32)
+#define	RFT_ID_RSP_SIZE	16
+
+#define	RFF_ID_CMD	0x21F
+#define	RFF_ID_REQ_SIZE	(16 + 4 + 2 + 1 + 1)
+#define	RFF_ID_RSP_SIZE	16
+
+#define	RNN_ID_CMD	0x213
+#define	RNN_ID_REQ_SIZE	(16 + 4 + 8)
+#define	RNN_ID_RSP_SIZE	16
+
+#define	RSNN_NN_CMD	 0x239
+#define	RSNN_NN_REQ_SIZE (16 + 8 + 1 + 255)
+#define	RSNN_NN_RSP_SIZE 16
+
+/* CT command header -- request/response common fields */
+struct ct_cmd_hdr {
+	uint8_t revision;
+	uint8_t in_id[3];
+	uint8_t gs_type;
+	uint8_t gs_subtype;
+	uint8_t options;
+	uint8_t reserved;
+};
+
+/* CT command request */
+struct ct_sns_req {
+	struct ct_cmd_hdr header;
+	uint16_t command;
+	uint16_t max_rsp_size;
+	uint8_t fragment_id;
+	uint8_t reserved[3];
+
+	union {
+		/* GA_NXT, GPN_ID, GNN_ID, GFT_ID */
+		struct {
+			uint8_t reserved;
+			uint8_t port_id[3];
+		} port_id;
+
+		struct {
+			uint8_t port_type;
+			uint8_t domain;
+			uint8_t area;
+			uint8_t reserved;
+		} gid_pt;
+
+		struct {
+			uint8_t reserved;
+			uint8_t port_id[3];
+			uint8_t fc4_types[32];
+		} rft_id;
+
+		struct {
+			uint8_t reserved;
+			uint8_t port_id[3];
+			uint16_t reserved2;
+			uint8_t fc4_feature;
+			uint8_t fc4_type;
+		} rff_id;
+
+		struct {
+			uint8_t reserved;
+			uint8_t port_id[3];
+			uint8_t node_name[8];
+		} rnn_id;
+
+		struct {
+			uint8_t node_name[8];
+			uint8_t name_len;
+			uint8_t sym_node_name[255];
+		} rsnn_nn;
+	} req;
+};
+
+/* CT command response header */
+struct ct_rsp_hdr {
+	struct ct_cmd_hdr header;
+	uint16_t response;
+	uint16_t residual;
+	uint8_t fragment_id;
+	uint8_t reason_code;
+	uint8_t explanation_code;
+	uint8_t vendor_unique;
+};
+
+struct ct_sns_gid_pt_data {
+	uint8_t control_byte;
+	uint8_t port_id[3];
+};
+
+struct ct_sns_rsp {
+	struct ct_rsp_hdr header;
+
+	union {
+		struct {
+			uint8_t port_type;
+			uint8_t port_id[3];
+			uint8_t port_name[8];
+			uint8_t sym_port_name_len;
+			uint8_t sym_port_name[255];
+			uint8_t node_name[8];
+			uint8_t sym_node_name_len;
+			uint8_t sym_node_name[255];
+			uint8_t init_proc_assoc[8];
+			uint8_t node_ip_addr[16];
+			uint8_t class_of_service[4];
+			uint8_t fc4_types[32];
+			uint8_t ip_address[16];
+			uint8_t fabric_port_name[8];
+			uint8_t reserved;
+			uint8_t hard_address[3];
+		} ga_nxt;
+
+		struct {
+			struct ct_sns_gid_pt_data entries[MAX_FIBRE_DEVICES];
+		} gid_pt;
+
+		struct {
+			uint8_t port_name[8];
+		} gpn_id;
+
+		struct {
+			uint8_t node_name[8];
+		} gnn_id;
+
+		struct {
+			uint8_t fc4_types[32];
+		} gft_id;
+	} rsp;
+};
+
+struct ct_sns_pkt {
+	union {
+		struct ct_sns_req req;
+		struct ct_sns_rsp rsp;
+	} p;
+};
+
+
+/* IO descriptors */
+#define MAX_IO_DESCRIPTORS	32
+
+#define ABORT_IOCB_CB		0
+#define ADISC_PORT_IOCB_CB	1
+#define LOGOUT_PORT_IOCB_CB	2
+#define LOGIN_PORT_IOCB_CB	3
+#define LAST_IOCB_CB		4
+
+#define IODESC_INVALID_INDEX	0xFFFF
+#define IODESC_ADISC_NEEDED	0xFFFE
+#define IODESC_LOGIN_NEEDED	0xFFFD
+
+struct io_descriptor {
+	uint16_t used:1;
+	uint16_t idx:11;
+	uint16_t cb_idx:4;
+
+	struct timer_list timer;
+
+	struct scsi_qla_host *ha;
+
+	port_id_t d_id;
+	fc_port_t *remote_fcport;
+
+	uint32_t signature;
+};
+
+/* Mailbox command semaphore queue for command serialization */
+typedef struct _mbx_cmdq_t {
+	struct semaphore	cmd_sem;
+	struct _mbx_cmdq_t	*pnext;
+} mbx_cmdq_t;
+
+struct qla_fw_info {
+	unsigned short addressing;	/* addressing method used to load fw */
+#define FW_INFO_ADDR_NORMAL	0
+#define FW_INFO_ADDR_EXTENDED	1
+#define FW_INFO_ADDR_NOMORE	0xffff
+	unsigned short *fwcode;		/* pointer to FW array */
+	unsigned short *fwlen;		/* number of words in array */
+	unsigned short *fwstart;	/* start address for F/W */
+	unsigned long *lfwstart;	/* start address (long) for F/W */
+};
+
+struct qla_board_info {
+	char *drv_name;
+
+	char isp_name[8];
+	struct qla_fw_info *fw_info;
+};
+
+/*
+ * Linux Host Adapter structure
+ */
+typedef struct scsi_qla_host {
+	struct list_head list;
+
+	/* Commonly used flags and state information. */
+	struct Scsi_Host *host;
+	struct pci_dev	*pdev;
+
+	unsigned long	host_no;
+	unsigned long	instance;
+
+	volatile struct {
+		uint32_t	init_done		:1;
+		uint32_t	online			:1;
+		uint32_t	mbox_int		:1;
+		uint32_t	mbox_busy		:1;
+		uint32_t	rscn_queue_overflow	:1;
+		uint32_t	reset_active		:1;
+
+		uint32_t	management_server_logged_in :1;
+                uint32_t	process_response_queue	:1;
+
+		uint32_t	disable_risc_code_load	:1;
+		uint32_t	enable_64bit_addressing	:1;
+		uint32_t	enable_lip_reset	:1;
+		uint32_t	enable_lip_full_login	:1;
+		uint32_t	enable_target_reset	:1;
+	} flags;
+
+	atomic_t	loop_state;
+#define LOOP_TIMEOUT	1
+#define LOOP_DOWN	2
+#define LOOP_UP		3
+#define LOOP_UPDATE	4
+#define LOOP_READY	5
+#define LOOP_DEAD	6
+
+	unsigned long   dpc_flags;
+#define	RESET_MARKER_NEEDED	0	/* Send marker to ISP. */
+#define	RESET_ACTIVE		1
+#define	ISP_ABORT_NEEDED	2	/* Initiate ISP abort. */
+#define	ABORT_ISP_ACTIVE	3	/* ISP abort in progress. */
+#define	LOOP_RESYNC_NEEDED	4	/* Device Resync needed. */
+#define	LOOP_RESYNC_ACTIVE	5
+#define LOCAL_LOOP_UPDATE       6	/* Perform a local loop update. */
+#define RSCN_UPDATE             7	/* Perform an RSCN update. */
+#define MAILBOX_RETRY           8
+#define ISP_RESET_NEEDED        9	/* Initiate a ISP reset. */
+#define FAILOVER_EVENT_NEEDED   10
+#define FAILOVER_EVENT		11
+#define FAILOVER_NEEDED   	12
+#define SCSI_RESTART_NEEDED	13	/* Processes SCSI retry queue. */
+#define PORT_RESTART_NEEDED	14	/* Processes Retry queue. */
+#define RESTART_QUEUES_NEEDED	15	/* Restarts the Lun queue. */
+#define ABORT_QUEUES_NEEDED	16
+#define RELOGIN_NEEDED	        17
+#define LOGIN_RETRY_NEEDED	18	/* Initiate required fabric logins. */
+#define REGISTER_FC4_NEEDED	19	/* SNS FC4 registration required. */
+#define ISP_ABORT_RETRY         20      /* ISP aborted. */
+#define FCPORT_RESCAN_NEEDED	21      /* IO descriptor processing needed */
+#define IODESC_PROCESS_NEEDED	22      /* IO descriptor processing needed */
+
+	uint32_t	device_flags;
+#define DFLG_LOCAL_DEVICES		BIT_0
+#define DFLG_RETRY_LOCAL_DEVICES	BIT_1
+#define DFLG_FABRIC_DEVICES		BIT_2
+#define	SWITCH_FOUND			BIT_3
+#define	DFLG_NO_CABLE			BIT_4
+
+	/* SRB cache. */
+#define SRB_MIN_REQ	128
+	mempool_t	*srb_mempool;
+
+	/* This spinlock is used to protect "io transactions", you must	
+	 * aquire it before doing any IO to the card, eg with RD_REG*() and
+	 * WRT_REG*() for the duration of your entire commandtransaction.
+	 *
+	 * This spinlock is of lower priority than the io request lock.
+	 */
+
+	spinlock_t		hardware_lock ____cacheline_aligned;
+
+	device_reg_t	*iobase;		/* Base I/O address */
+	unsigned long	pio_address;
+	unsigned long	pio_length;
+	void *		mmio_address;
+	unsigned long	mmio_length;
+#define MIN_IOBASE_LEN		0x100
+
+	/* ISP ring lock, rings, and indexes */
+	dma_addr_t	request_dma;        /* Physical address. */
+	request_t       *request_ring;      /* Base virtual address */
+	request_t       *request_ring_ptr;  /* Current address. */
+	uint16_t        req_ring_index;     /* Current index. */
+	uint16_t        req_q_cnt;          /* Number of available entries. */
+
+	dma_addr_t	response_dma;       /* Physical address. */
+	response_t      *response_ring;     /* Base virtual address */
+	response_t      *response_ring_ptr; /* Current address. */
+	uint16_t        rsp_ring_index;     /* Current index. */
+	uint16_t	response_q_length;
+    
+	uint16_t	(*calc_request_entries)(uint16_t);
+	void		(*build_scsi_iocbs)(srb_t *, cmd_entry_t *, uint16_t);
+
+	/* Outstandings ISP commands. */
+	srb_t		*outstanding_cmds[MAX_OUTSTANDING_COMMANDS];
+	uint32_t	current_outstanding_cmd; 
+	srb_t		*status_srb;	/* Status continuation entry. */
+
+	/*
+	 * Need to hold the list_lock with irq's disabled in order to access
+	 * the following list.
+	 *
+	 * This list_lock is of lower priority than the host_lock.
+	 */
+	spinlock_t		list_lock ____cacheline_aligned;
+						/* lock to guard lists which
+						 * hold srb_t's */
+        struct list_head        retry_queue;    /* watchdog queue */
+        struct list_head        done_queue;     /* job on done queue */
+        struct list_head        failover_queue; /* failover list link. */
+	struct list_head        scsi_retry_queue;     /* SCSI retry queue */
+	struct list_head        pending_queue;	/* SCSI command pending queue */
+
+	unsigned long    done_q_cnt;
+	unsigned long    pending_in_q;
+        uint32_t	retry_q_cnt; 
+        uint32_t	scsi_retry_q_cnt; 
+        uint32_t	failover_cnt; 
+
+	unsigned long	last_irq_cpu;	/* cpu where we got our last irq */
+
+	uint16_t           revision;
+	uint8_t           ports;
+	u_long            actthreads;
+	u_long            ipreq_cnt;
+	u_long            qthreads;
+
+	uint32_t        total_isr_cnt;		/* Interrupt count */
+	uint32_t        total_isp_aborts;	/* controller err cnt */
+	uint32_t        total_lip_cnt;		/* LIP cnt */
+	uint32_t	total_dev_errs;		/* device error cnt */
+	uint32_t	total_ios;		/* IO cnt */
+	uint64_t	total_bytes;		/* xfr byte cnt */
+	uint32_t	total_mbx_timeout;	/* mailbox timeout cnt */
+	uint32_t 	total_loop_resync; 	/* loop resyn cnt */
+	uint32_t	dropped_frame_error_cnt;
+
+	/* ISP configuration data. */
+	uint16_t	loop_id;		/* Host adapter loop id */
+	uint16_t	fb_rev;
+
+	port_id_t	d_id;			/* Host adapter port id */
+	uint16_t	max_public_loop_ids;
+	uint16_t	min_external_loopid;	/* First external loop Id */
+
+	uint8_t		current_topology;
+	uint8_t		prev_topology;
+#define ISP_CFG_NL	1
+#define ISP_CFG_N	2
+#define ISP_CFG_FL	4
+#define ISP_CFG_F	8
+
+	uint8_t		operating_mode;		/* F/W operating mode */
+#define LOOP      0
+#define P2P       1
+#define LOOP_P2P  2
+#define P2P_LOOP  3
+
+	uint8_t		active_fc4_types;	/* Active fc4 types */
+
+	uint8_t		current_speed;		/* F/W operating speed */
+        uint8_t		marker_needed; 
+	uint8_t		sns_retry_cnt;
+	uint8_t		mem_err;
+
+	uint8_t		interrupts_on;
+
+	/* HBA serial number */
+	uint8_t		serial0;
+	uint8_t		serial1;
+	uint8_t		serial2;
+
+	/* NVRAM configuration data */
+	uint16_t	nvram_base;
+
+	uint16_t	loop_reset_delay;
+	uint16_t	minimum_timeout;
+	uint8_t		retry_count;
+	uint8_t		login_timeout;
+	uint16_t	r_a_tov;
+	int		port_down_retry_count;
+	uint8_t		loop_down_timeout;
+	uint8_t		mbx_count;
+	uint16_t	max_probe_luns;
+	uint16_t	max_luns;
+	uint16_t	max_targets;
+	uint16_t	last_loop_id;
+
+        uint32_t	login_retry_count; 
+
+	/* Fibre Channel Device List. */
+	struct list_head	fcports;
+	struct list_head	rscn_fcports;
+
+	struct io_descriptor	io_descriptors[MAX_IO_DESCRIPTORS];
+	uint16_t		iodesc_signature;
+	port_database_t		*iodesc_pd;
+	dma_addr_t		iodesc_pd_dma;
+
+	/* OS target queue pointers. */
+	os_tgt_t		*otgt[MAX_FIBRE_DEVICES];
+
+	/* RSCN queue. */
+	uint32_t rscn_queue[MAX_RSCN_COUNT];
+	uint8_t rscn_in_ptr;
+	uint8_t rscn_out_ptr;
+
+	ms_iocb_entry_t		*ms_iocb;
+	dma_addr_t		ms_iocb_dma;
+	struct ct_sns_pkt	*ct_sns;
+	dma_addr_t		ct_sns_dma;
+
+	pid_t			dpc_pid;
+	int			dpc_should_die;
+	struct completion	dpc_inited;
+	struct completion	dpc_exited;
+	struct semaphore	*dpc_wait;
+	uint8_t dpc_active;                  /* DPC routine is active */
+
+	/* Timeout timers. */
+	uint8_t         queue_restart_timer;   
+	uint8_t         loop_down_abort_time;    /* port down timer */
+	atomic_t        loop_down_timer;         /* loop down timer */
+	uint8_t         link_down_timeout;       /* link down timeout */
+
+	uint32_t        timer_active;
+	struct timer_list        timer;
+
+	/* Firmware Initialization Control Block data */
+	dma_addr_t	init_cb_dma;         /* Physical address. */
+	init_cb_t       *init_cb;
+  
+	/* These are used by mailbox operations. */
+	volatile uint16_t mailbox_out[MAILBOX_REGISTER_COUNT];
+
+	mbx_cmd_t	*mcp;
+	unsigned long	mbx_cmd_flags;
+#define MBX_CMD_ACTIVE	1
+#define MBX_CMD_WANT	2
+#define MBX_INTERRUPT	3
+#define MBX_INTR_WAIT   4
+
+	spinlock_t	mbx_reg_lock;   /* Mbx Cmd Register Lock */
+	spinlock_t	mbx_q_lock;     /* Mbx Active Cmd Queue Lock */
+	spinlock_t	mbx_bits_lock;  /* Mailbox access bits Lock */
+
+	struct semaphore  mbx_intr_sem;  /* Used for completion notification */
+
+	mbx_cmdq_t	*mbx_sem_pool_head;  /* Head Pointer to a list of
+			                      * recyclable mbx semaphore pool
+			                      * to be used during run time.
+			                      */
+	mbx_cmdq_t	*mbx_sem_pool_tail;  /* Tail Pointer to semaphore pool*/
+#define MBQ_INIT_LEN	16 /* initial mbx sem pool q len. actual len may vary */
+
+	mbx_cmdq_t	*mbx_q_head; /* Head Pointer to sem q for active cmds */
+	mbx_cmdq_t	*mbx_q_tail; /* Tail Pointer to sem q for active cmds */
+
+	uint32_t	mbx_flags;
+#define  MBX_IN_PROGRESS	BIT_0
+#define  MBX_BUSY		BIT_1	/* Got the Access */
+#define  MBX_SLEEPING_ON_SEM	BIT_2 
+#define  MBX_POLLING_FOR_COMP	BIT_3
+#define  MBX_COMPLETED		BIT_4
+#define  MBX_TIMEDOUT		BIT_5 
+#define  MBX_ACCESS_TIMEDOUT	BIT_6
+
+	mbx_cmd_t 	mc;
+
+	uint8_t	*cmdline;
+
+	uint32_t failover_type;
+	uint32_t failback_delay;
+	unsigned long   cfg_flags;
+#define	CFG_ACTIVE	0	/* CFG during a failover, event update, or ioctl */
+
+	uint32_t	binding_type;
+#define BIND_BY_PORT_NAME	0
+#define BIND_BY_PORT_ID		1
+
+	/* Basic firmware related information. */
+	struct qla_board_info	*brd_info;
+	uint16_t	fw_major_version;
+	uint16_t	fw_minor_version;
+	uint16_t	fw_subminor_version;
+	uint16_t	fw_attributes;
+	uint32_t	fw_transfer_size;
+
+	uint16_t	fw_options[16];		/* slots: 1,2,3,10,11 */
+	uint8_t		fw_seriallink_options[2];
+
+	/* Firmware dump information. */
+	void		*fw_dump;
+	int		fw_dump_order;
+	int		fw_dump_reading;
+	char		*fw_dump_buffer;
+	int		fw_dump_buffer_len;
+
+	uint8_t		host_str[16];
+	uint16_t	pci_attr;
+	uint16_t	xchg_buf_cnt;
+	uint16_t	iocb_buf_cnt;
+
+	uint8_t model_number[16+1];
+#define BINZERO		"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+	char *model_desc;
+
+/* following are new and needed for IOCTL support */
+#ifdef CONFIG_SCSI_QLA2XXX_IOCTL
+	struct hba_ioctl *ioctl;
+
+	void        *ioctl_mem;
+	dma_addr_t  ioctl_mem_phys;
+	uint32_t    ioctl_mem_size;
+#endif
+	uint8_t     node_name[WWN_SIZE];
+	uint8_t     nvram_version; 
+	uint8_t     optrom_major; 
+	uint8_t     optrom_minor; 
+	uint32_t    isp_abort_cnt;
+
+	/* Adapter I/O statistics for failover */
+	uint64_t	IosRequested;
+	uint64_t	BytesRequested;
+	uint64_t	IosExecuted;
+	uint64_t	BytesExecuted;
+
+	/* Needed for BEACON */
+	uint16_t	beacon_blink_led;
+	uint16_t	beacon_green_on;
+} scsi_qla_host_t;
+
+
+/*
+ * Macros to help code, maintain, etc.
+ */
+#define LOOP_TRANSITION(ha) \
+	(test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) || \
+	 test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))
+
+#define LOOP_NOT_READY(ha) \
+	((test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) || \
+	  test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags) || \
+	  test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags) || \
+	  test_bit(LOOP_RESYNC_ACTIVE, &ha->dpc_flags)) || \
+	 atomic_read(&ha->loop_state) == LOOP_DOWN)
+				 
+#define LOOP_RDY(ha)	(!LOOP_NOT_READY(ha))
+
+#define TGT_Q(ha, t) (ha->otgt[t])
+#define LUN_Q(ha, t, l)	(TGT_Q(ha, t)->olun[l])
+#define GET_LU_Q(ha, t, l) ((TGT_Q(ha,t) != NULL)? TGT_Q(ha, t)->olun[l] : NULL)
+
+#define to_qla_host(x)		((scsi_qla_host_t *) (x)->hostdata)
+
+#define qla_printk(level, ha, format, arg...) \
+	dev_printk(level , &((ha)->pdev->dev) , format , ## arg)
+
+/*
+ * qla2x00 local function return status codes
+ */
+#define MBS_MASK		0x3fff
+
+#define QLA_SUCCESS		(MBS_COMMAND_COMPLETE & MBS_MASK)
+#define QLA_INVALID_COMMAND	(MBS_INVALID_COMMAND & MBS_MASK)
+#define QLA_INTERFACE_ERROR	(MBS_HOST_INTERFACE_ERROR & MBS_MASK)
+#define QLA_TEST_FAILED		(MBS_TEST_FAILED & MBS_MASK)
+#define QLA_COMMAND_ERROR	(MBS_COMMAND_ERROR & MBS_MASK)
+#define QLA_PARAMETER_ERROR	(MBS_COMMAND_PARAMETER_ERROR & MBS_MASK)
+#define QLA_PORT_ID_USED	(MBS_PORT_ID_USED & MBS_MASK)
+#define QLA_LOOP_ID_USED	(MBS_LOOP_ID_USED & MBS_MASK)
+#define QLA_ALL_IDS_IN_USE	(MBS_ALL_IDS_IN_USE & MBS_MASK)
+#define QLA_NOT_LOGGED_IN	(MBS_NOT_LOGGED_IN & MBS_MASK)
+
+#define QLA_FUNCTION_TIMEOUT		0x100
+#define QLA_FUNCTION_PARAMETER_ERROR	0x101
+#define QLA_FUNCTION_FAILED		0x102
+#define QLA_MEMORY_ALLOC_FAILED		0x103
+#define QLA_LOCK_TIMEOUT		0x104
+#define QLA_ABORTED			0x105
+#define QLA_SUSPENDED			0x106
+#define QLA_BUSY			0x107
+#define QLA_RSCNS_HANDLED		0x108
+
+/*
+* Stat info for all adpaters
+*/
+struct _qla2x00stats  {
+        unsigned long   mboxtout;            /* mailbox timeouts */
+        unsigned long   mboxerr;             /* mailbox errors */
+        unsigned long   ispAbort;            /* ISP aborts */
+        unsigned long   debugNo;
+        unsigned long   loop_resync;
+        unsigned long   outarray_full;
+        unsigned long   retry_q_cnt;
+};
+
+#define NVRAM_DELAY()		udelay(10)
+
+#define INVALID_HANDLE	(MAX_OUTSTANDING_COMMANDS+1)
+
+/*
+ * Flash support definitions
+ */
+#define FLASH_IMAGE_SIZE	131072
+
+#include "qla_gbl.h"
+#include "qla_dbg.h"
+#include "qla_inline.h"
+#include "qla_listops.h"
+
+#endif
diff -puN /dev/null drivers/scsi/qla2xxx/qla_devtbl.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/qla_devtbl.h	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,65 @@
+#define QLA_MODEL_NAMES         0x1B
+
+/*
+ * Adapter model names.
+ */
+char	*qla2x00_model_name[QLA_MODEL_NAMES] = {
+	"QLA2340",	/* 0x100 */
+	"QLA2342",	/* 0x101 */
+	"QLA2344",	/* 0x102 */
+	"QCP2342",	/* 0x103 */
+	"QSB2340",	/* 0x104 */
+	"QSB2342",	/* 0x105 */
+	"QLA2310",	/* 0x106 */
+	"QLA2332",	/* 0x107 */
+	"QCP2332",	/* 0x108 */
+	"QCP2340",	/* 0x109 */
+	"QLA2342",	/* 0x10a */
+	"QCP2342",	/* 0x10b */
+	"QLA2350",	/* 0x10c */
+	"QLA2352",	/* 0x10d */
+	"QLA2352",	/* 0x10e */
+	"HPQSVS ",	/* 0x10f */
+	"HPQSVS ",	/* 0x110 */
+	"QLA4010",	/* 0x111 */
+	"QLA4010",	/* 0x112 */
+	"QLA4010C",	/* 0x113 */
+	"QLA4010C",	/* 0x114 */
+	"QLA2360",	/* 0x115 */
+	"QLA2362",	/* 0x116 */
+	" ",		/* 0x117 */
+	" ",		/* 0x118 */
+	"QLA200",	/* 0x119 */
+	"QLA200C"	/* 0x11A */
+};
+
+char	*qla2x00_model_desc[QLA_MODEL_NAMES] = {
+	"133MHz PCI-X to 2Gb FC, Single Channel",	/* 0x100 */
+	"133MHz PCI-X to 2Gb FC, Dual Channel",		/* 0x101 */
+	"133MHz PCI-X to 2Gb FC, Quad Channel",		/* 0x102 */
+	" ",						/* 0x103 */
+	" ",						/* 0x104 */
+	" ",						/* 0x105 */
+	" ",						/* 0x106 */
+	" ",						/* 0x107 */
+	" ",						/* 0x108 */
+	" ",						/* 0x109 */
+	" ",						/* 0x10a */
+	" ",						/* 0x10b */
+	"133MHz PCI-X to 2Gb FC, Single Channel",	/* 0x10c */
+	"133MHz PCI-X to 2Gb FC, Dual Channel",		/* 0x10d */
+	" ",						/* 0x10e */
+	"HPQ SVS HBA- Initiator device",		/* 0x10f */
+	"HPQ SVS HBA- Target device",			/* 0x110 */
+	"Optical- 133MHz to 1Gb iSCSI- networking",	/* 0x111 */
+	"Optical- 133MHz to 1Gb iSCSI- storage",	/* 0x112 */
+	"Copper- 133MHz to 1Gb iSCSI- networking",	/* 0x113 */
+	"Copper- 133MHz to 1Gb iSCSI- storage",		/* 0x114 */
+	"133MHz PCI-X to 2Gb FC Single Channel",	/* 0x115 */
+	"133MHz PCI-X to 2Gb FC Dual Channel",		/* 0x116 */
+	" ",						/* 0x117 */
+	" ",						/* 0x118 */
+	"133MHz PCI-X to 2Gb FC Optical",		/* 0x119 */
+	"133MHz PCI-X to 2Gb FC Copper"			/* 0x11A */
+};
+
diff -puN /dev/null drivers/scsi/qla2xxx/qla_gbl.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/qla_gbl.h	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,327 @@
+/********************************************************************************
+*                  QLOGIC LINUX SOFTWARE
+*
+* QLogic ISP2x00 device driver for Linux 2.6.x
+* Copyright (C) 2003 QLogic Corporation
+* (www.qlogic.com)
+*
+* This program is free software; you can redistribute it and/or modify it
+* under the terms of the GNU General Public License as published by the
+* Free Software Foundation; either version 2, or (at your option) any
+* later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+* General Public License for more details.
+*
+******************************************************************************
+* Global include file.
+******************************************************************************/
+
+
+#ifndef __QLA_GBL_H
+#define	__QLA_GBL_H
+
+extern void qla2x00_remove_one(struct pci_dev *);
+extern int qla2x00_probe_one(struct pci_dev *, struct qla_board_info *);
+
+/*
+ * Global Function Prototypes in qla_init.c source file.
+ */
+extern int qla2x00_initialize_adapter(scsi_qla_host_t *);
+extern fc_port_t *qla2x00_alloc_fcport(scsi_qla_host_t *, int);
+
+extern int qla2x00_loop_resync(scsi_qla_host_t *);
+
+extern int qla2x00_find_new_loop_id(scsi_qla_host_t *, fc_port_t *);
+extern int qla2x00_fabric_login(scsi_qla_host_t *, fc_port_t *, uint16_t *);
+extern int qla2x00_local_device_login(scsi_qla_host_t *, uint16_t);
+
+extern void qla2x00_restart_queues(scsi_qla_host_t *, uint8_t);
+
+extern void qla2x00_rescan_fcports(scsi_qla_host_t *);
+
+extern void qla2x00_tgt_free(scsi_qla_host_t *ha, uint16_t t);
+extern os_tgt_t *qla2x00_tgt_alloc(scsi_qla_host_t *, uint16_t);
+extern os_lun_t * qla2x00_lun_alloc(scsi_qla_host_t *, uint16_t, uint16_t);
+
+extern int qla2x00_abort_isp(scsi_qla_host_t *);
+
+
+/*
+ * Global Data in qla_os.c source file.
+ */
+extern char qla2x00_version_str[];
+
+extern int num_hosts;
+extern int apiHBAInstance;
+
+extern struct _qla2x00stats qla2x00_stats;
+extern int ql2xretrycount;
+extern int ql2xlogintimeout;
+extern int qlport_down_retry;
+extern int ql2xmaxqdepth;
+extern int displayConfig;
+extern int ql2xplogiabsentdevice;
+extern int ql2xintrdelaytimer;
+
+extern int ConfigRequired;
+
+extern int Bind;
+extern int ql2xsuspendcount;
+#if defined(MODULE)
+extern char *ql2xopts;
+#endif
+extern struct list_head qla_hostlist;
+extern rwlock_t qla_hostlist_lock;
+
+extern char *qla2x00_get_fw_version_str(struct scsi_qla_host *, char *);
+
+extern int qla2x00_queuecommand(struct scsi_cmnd *,
+    void (*)(struct scsi_cmnd *));
+
+extern int __qla2x00_suspend_lun(scsi_qla_host_t *, os_lun_t *, int, int, int);
+
+extern void qla2x00_done(scsi_qla_host_t *);
+extern void qla2x00_next(scsi_qla_host_t *);
+extern void qla2x00_flush_failover_q(scsi_qla_host_t *, os_lun_t *);
+extern void qla2x00_reset_lun_fo_counts(scsi_qla_host_t *, os_lun_t *);
+
+extern int qla2x00_check_tgt_status(scsi_qla_host_t *, struct scsi_cmnd *);
+extern int qla2x00_check_port_status(scsi_qla_host_t *, fc_port_t *);
+
+extern void qla2x00_extend_timeout(struct scsi_cmnd *, int);
+extern srb_t * qla2x00_get_new_sp (scsi_qla_host_t *ha);
+
+extern void qla2x00_mark_device_lost(scsi_qla_host_t *, fc_port_t *, int);
+extern void qla2x00_mark_all_devices_lost(scsi_qla_host_t *);
+
+extern int qla2x00_get_prop_xstr(scsi_qla_host_t *, char *, uint8_t *, int);
+
+extern void qla2x00_abort_queues(scsi_qla_host_t *, uint8_t);
+
+extern void qla2x00_blink_led(scsi_qla_host_t *);
+
+/*
+ * Global Function Prototypes in qla_iocb.c source file.
+ */
+extern request_t *qla2x00_req_pkt(scsi_qla_host_t *);
+extern request_t *qla2x00_ms_req_pkt(scsi_qla_host_t *, srb_t *);
+extern void qla2x00_isp_cmd(scsi_qla_host_t *);
+
+extern uint16_t qla2x00_calc_iocbs_32(uint16_t);
+extern uint16_t qla2x00_calc_iocbs_64(uint16_t);
+extern void qla2x00_build_scsi_iocbs_32(srb_t *, cmd_entry_t *, uint16_t);
+extern void qla2x00_build_scsi_iocbs_64(srb_t *, cmd_entry_t *, uint16_t);
+extern int qla2x00_start_scsi(srb_t *sp);
+int qla2x00_marker(scsi_qla_host_t *, uint16_t, uint16_t, uint8_t);
+int __qla2x00_marker(scsi_qla_host_t *, uint16_t, uint16_t, uint8_t);
+
+/*
+ * Global Function Prototypes in qla_mbx.c source file.
+ */
+extern int
+qla2x00_mailbox_command(scsi_qla_host_t *, mbx_cmd_t *);
+
+extern int
+qla2x00_load_ram(scsi_qla_host_t *, dma_addr_t, uint16_t, uint16_t);
+
+extern int
+qla2x00_load_ram_ext(scsi_qla_host_t *, dma_addr_t, uint32_t, uint16_t);
+
+extern int
+qla2x00_execute_fw(scsi_qla_host_t *);
+
+extern void
+qla2x00_get_fw_version(scsi_qla_host_t *, uint16_t *,
+    uint16_t *, uint16_t *, uint16_t *);
+
+extern int
+qla2x00_get_fw_options(scsi_qla_host_t *, uint16_t *);
+
+extern int
+qla2x00_set_fw_options(scsi_qla_host_t *, uint16_t *);
+
+extern int
+qla2x00_read_ram_word(scsi_qla_host_t *, uint16_t, uint16_t *);
+extern int
+qla2x00_write_ram_word(scsi_qla_host_t *, uint16_t, uint16_t);
+extern int
+qla2x00_write_ram_word_ext(scsi_qla_host_t *, uint32_t, uint16_t);
+
+extern int
+qla2x00_mbx_reg_test(scsi_qla_host_t *);
+
+extern int
+qla2x00_verify_checksum(scsi_qla_host_t *);
+
+extern int
+qla2x00_issue_iocb(scsi_qla_host_t *, void *, dma_addr_t, size_t);
+
+extern int
+qla2x00_abort_command(scsi_qla_host_t *, srb_t *);
+
+extern int
+qla2x00_abort_device(scsi_qla_host_t *, uint16_t, uint16_t);
+
+#if USE_ABORT_TGT
+extern int
+qla2x00_abort_target(fc_port_t *fcport);
+#endif
+
+extern int
+qla2x00_target_reset(scsi_qla_host_t *, uint16_t, uint16_t);
+
+extern int
+qla2x00_get_adapter_id(scsi_qla_host_t *, uint16_t *, uint8_t *, uint8_t *,
+    uint8_t *, uint16_t *);
+
+extern int
+qla2x00_get_retry_cnt(scsi_qla_host_t *, uint8_t *, uint8_t *, uint16_t *);
+
+extern int
+qla2x00_init_firmware(scsi_qla_host_t *, uint16_t);
+
+extern int
+qla2x00_get_port_database(scsi_qla_host_t *, fc_port_t *, uint8_t);
+
+extern int
+qla2x00_get_firmware_state(scsi_qla_host_t *, uint16_t *);
+
+extern int
+qla2x00_get_port_name(scsi_qla_host_t *, uint16_t, uint8_t *, uint8_t);
+
+extern uint8_t
+qla2x00_get_link_status(scsi_qla_host_t *, uint8_t, void *, uint16_t *);
+
+extern int
+qla2x00_lip_reset(scsi_qla_host_t *);
+
+extern int
+qla2x00_send_sns(scsi_qla_host_t *, dma_addr_t, uint16_t, size_t);
+
+extern int
+qla2x00_login_fabric(scsi_qla_host_t *, uint16_t, uint8_t, uint8_t, uint8_t,
+    uint16_t *, uint8_t);
+
+extern int
+qla2x00_login_local_device(scsi_qla_host_t *, uint16_t, uint16_t *, uint8_t);
+
+extern int
+qla2x00_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id);
+
+extern int
+qla2x00_full_login_lip(scsi_qla_host_t *ha);
+
+extern int
+qla2x00_get_id_list(scsi_qla_host_t *, void *, dma_addr_t, uint16_t *);
+
+#if 0 /* not yet needed */
+extern int
+qla2x00_dump_ram(scsi_qla_host_t *, uint32_t, dma_addr_t, uint32_t);
+#endif
+
+extern int
+qla2x00_lun_reset(scsi_qla_host_t *, uint16_t, uint16_t);
+
+extern int
+qla2x00_send_rnid_mbx(scsi_qla_host_t *, uint16_t, uint8_t, dma_addr_t,
+    size_t, uint16_t *);
+
+extern int
+qla2x00_set_rnid_params_mbx(scsi_qla_host_t *, dma_addr_t, size_t, uint16_t *);
+
+extern int
+qla2x00_get_rnid_params_mbx(scsi_qla_host_t *, dma_addr_t, size_t, uint16_t *);
+
+extern int
+qla2x00_get_resource_cnts(scsi_qla_host_t *, uint16_t *, uint16_t *, uint16_t *,
+    uint16_t *);
+
+#if defined(QL_DEBUG_LEVEL_3)
+extern int
+qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map);
+#endif
+
+/*
+ * Global Function Prototypes in qla_isr.c source file.
+ */
+extern irqreturn_t qla2x00_intr_handler(int, void *, struct pt_regs *);
+extern void qla2x00_process_response_queue(struct scsi_qla_host *);
+
+/*
+ * Global Function Prototypes in qla_sup.c source file.
+ */
+extern void qla2x00_lock_nvram_access(scsi_qla_host_t *);
+extern void qla2x00_unlock_nvram_access(scsi_qla_host_t *);
+extern uint16_t qla2x00_get_nvram_word(scsi_qla_host_t *, uint32_t);
+extern void qla2x00_write_nvram_word(scsi_qla_host_t *, uint32_t, uint16_t);
+extern void qla2x00_flash_enable(scsi_qla_host_t *);
+extern void qla2x00_flash_disable(scsi_qla_host_t *);
+extern uint8_t qla2x00_read_flash_byte(scsi_qla_host_t *, uint32_t);
+extern uint8_t qla2x00_get_flash_manufacturer(scsi_qla_host_t *);
+extern uint16_t qla2x00_get_flash_version(scsi_qla_host_t *);
+extern uint16_t qla2x00_get_flash_image(scsi_qla_host_t *, uint8_t *);
+extern uint16_t qla2x00_set_flash_image(scsi_qla_host_t *, uint8_t *);
+
+/*
+ * Global Function Prototypes in qla_dbg.c source file.
+ */
+extern void qla2100_fw_dump(scsi_qla_host_t *, int);
+extern void qla2300_fw_dump(scsi_qla_host_t *, int);
+extern void qla2100_ascii_fw_dump(scsi_qla_host_t *);
+extern void qla2300_ascii_fw_dump(scsi_qla_host_t *);
+extern void qla2x00_dump_regs(scsi_qla_host_t *);
+extern void qla2x00_dump_buffer(uint8_t *, uint32_t);
+extern void qla2x00_print_scsi_cmd(struct scsi_cmnd *);
+extern void qla2x00_print_q_info(struct os_lun *);
+
+/*
+ * Global Function Prototypes in qla_ip.c source file.
+ */
+extern int qla2x00_ip_initialize(scsi_qla_host_t *);
+extern int qla2x00_update_ip_device_data(scsi_qla_host_t *, fc_port_t *);
+extern void qla2x00_ip_send_complete(scsi_qla_host_t *, uint32_t, uint16_t);
+extern void qla2x00_ip_receive(scsi_qla_host_t *, sts_entry_t *);
+extern void qla2x00_ip_receive_fastpost(scsi_qla_host_t *, uint16_t);
+extern void qla2x00_ip_mailbox_iocb_done(scsi_qla_host_t *, struct mbx_entry *);
+
+/*
+ * Global Function Prototypes in qla_gs.c source file.
+ */
+extern int qla2x00_ga_nxt(scsi_qla_host_t *, fc_port_t *);
+extern int qla2x00_gid_pt(scsi_qla_host_t *, sw_info_t *);
+extern int qla2x00_gpn_id(scsi_qla_host_t *, sw_info_t *);
+extern int qla2x00_gnn_id(scsi_qla_host_t *, sw_info_t *);
+extern int qla2x00_gft_id(scsi_qla_host_t *, sw_info_t *);
+extern int qla2x00_rft_id(scsi_qla_host_t *);
+extern int qla2x00_rff_id(scsi_qla_host_t *);
+extern int qla2x00_rnn_id(scsi_qla_host_t *);
+extern int qla2x00_rsnn_nn(scsi_qla_host_t *);
+
+/*
+ * Global Function Prototypes in qla_rscn.c source file.
+ */
+extern fc_port_t *qla2x00_alloc_rscn_fcport(scsi_qla_host_t *, int);
+extern int qla2x00_handle_port_rscn(scsi_qla_host_t *, uint32_t, fc_port_t *,
+    int);
+extern void qla2x00_process_iodesc(scsi_qla_host_t *, struct mbx_entry *);
+extern void qla2x00_cancel_io_descriptors(scsi_qla_host_t *);
+
+/*
+ * Global Function Prototypes in qla_xioctl.c source file.
+ */
+#ifdef CONFIG_SCSI_QLA2XXX_IOCTL
+extern void qla2x00_enqueue_aen(scsi_qla_host_t *, uint16_t, void *);
+extern int qla2x00_alloc_ioctl_mem(scsi_qla_host_t *);
+extern void qla2x00_free_ioctl_mem(scsi_qla_host_t *);
+extern int qla2x00_get_ioctl_scrap_mem(scsi_qla_host_t *, void **, uint32_t);
+extern void qla2x00_free_ioctl_scrap_mem(scsi_qla_host_t *);
+#else
+#define qla2x00_enqueue_aen(ha, cmd, mode)	do { } while (0)
+#define qla2x00_alloc_ioctl_mem(ha)		(0)
+#define qla2x00_free_ioctl_mem(ha)		do { } while (0)
+#endif
+
+#endif /* _QLA_GBL_H */
diff -puN /dev/null drivers/scsi/qla2xxx/qla_gs.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/qla_gs.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,681 @@
+/*
+ *                  QLOGIC LINUX SOFTWARE
+ *
+ * QLogic ISP2x00 device driver for Linux 2.6.x
+ * Copyright (C) 2003 QLogic Corporation
+ * (www.qlogic.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+#include "qla_os.h"
+
+#include "qla_def.h"
+
+/* XXX(hch): this is ugly, but we don't want to pull in exioctl.h */
+#ifndef EXT_DEF_FC4_TYPE_SCSI
+#define EXT_DEF_FC4_TYPE_SCSI		0x1
+#endif
+
+static inline ms_iocb_entry_t *
+qla2x00_prep_ms_iocb(scsi_qla_host_t *, uint32_t, uint32_t);
+
+static inline struct ct_sns_req *
+qla2x00_prep_ct_req(struct ct_sns_req *, uint16_t, uint16_t);
+
+/**
+ * qla2x00_prep_ms_iocb() - Prepare common MS IOCB fields for SNS CT query.
+ * @ha: HA context
+ * @req_size: request size in bytes
+ * @rsp_size: response size in bytes
+ *
+ * Returns a pointer to the @ha's ms_iocb.
+ */
+static inline ms_iocb_entry_t *
+qla2x00_prep_ms_iocb(scsi_qla_host_t *ha, uint32_t req_size, uint32_t rsp_size)
+{
+	ms_iocb_entry_t *ms_pkt;
+
+	ms_pkt = ha->ms_iocb;
+	memset(ms_pkt, 0, sizeof(ms_iocb_entry_t));
+
+	ms_pkt->entry_type = MS_IOCB_TYPE;
+	ms_pkt->entry_count = 1;
+	SET_TARGET_ID(ha, ms_pkt->loop_id, SIMPLE_NAME_SERVER);
+	ms_pkt->control_flags = __constant_cpu_to_le16(CF_READ | CF_HEAD_TAG);
+	ms_pkt->timeout = __constant_cpu_to_le16(25);
+	ms_pkt->cmd_dsd_count = __constant_cpu_to_le16(1);
+	ms_pkt->total_dsd_count = __constant_cpu_to_le16(2);
+	ms_pkt->rsp_bytecount = cpu_to_le32(rsp_size);
+	ms_pkt->req_bytecount = cpu_to_le32(req_size);
+
+	ms_pkt->dseg_req_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
+	ms_pkt->dseg_req_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
+	ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
+
+	ms_pkt->dseg_rsp_address[0] = cpu_to_le32(LSD(ha->ct_sns_dma));
+	ms_pkt->dseg_rsp_address[1] = cpu_to_le32(MSD(ha->ct_sns_dma));
+	ms_pkt->dseg_rsp_length = ms_pkt->rsp_bytecount;
+
+	return (ms_pkt);
+}
+
+/**
+ * qla2x00_prep_ct_req() - Prepare common CT request fields for SNS query.
+ * @ct_req: CT request buffer
+ * @cmd: GS command
+ * @rsp_size: response size in bytes
+ *
+ * Returns a pointer to the intitialized @ct_req.
+ */
+static inline struct ct_sns_req *
+qla2x00_prep_ct_req(struct ct_sns_req *ct_req, uint16_t cmd, uint16_t rsp_size)
+{
+	memset(ct_req, 0, sizeof(struct ct_sns_pkt));
+
+	ct_req->header.revision = 0x01;
+	ct_req->header.gs_type = 0xFC;
+	ct_req->header.gs_subtype = 0x02;
+	ct_req->command = cpu_to_be16(cmd);
+	ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4);
+
+	return (ct_req);
+}
+
+/**
+ * qla2x00_ga_nxt() - SNS scan for fabric devices via GA_NXT command.
+ * @ha: HA context
+ * @fcport: fcport entry to updated
+ *
+ * Returns 0 on success.
+ */
+int
+qla2x00_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport)
+{
+	int		rval;
+
+	ms_iocb_entry_t	*ms_pkt;
+	struct ct_sns_req	*ct_req;
+	struct ct_sns_rsp	*ct_rsp;
+
+	/* Issue GA_NXT */
+	/* Prepare common MS IOCB */
+	ms_pkt = qla2x00_prep_ms_iocb(ha, GA_NXT_REQ_SIZE, GA_NXT_RSP_SIZE);
+
+	/* Prepare CT request */
+	ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GA_NXT_CMD,
+	    GA_NXT_RSP_SIZE);
+	ct_rsp = &ha->ct_sns->p.rsp;
+
+	/* Prepare CT arguments -- port_id */
+	ct_req->req.port_id.port_id[0] = fcport->d_id.b.domain;
+	ct_req->req.port_id.port_id[1] = fcport->d_id.b.area;
+	ct_req->req.port_id.port_id[2] = fcport->d_id.b.al_pa;
+
+	/* Execute MS IOCB */
+	rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
+	    sizeof(ms_iocb_entry_t));
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3(printk("scsi(%ld): GA_NXT issue IOCB failed (%d).\n",
+		    ha->host_no, rval));
+	} else if (ct_rsp->header.response !=
+	    __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) {
+		DEBUG2_3(printk("scsi(%ld): GA_NXT failed, rejected request, "
+		    "ga_nxt_rsp:\n", ha->host_no));
+		DEBUG2_3(qla2x00_dump_buffer((uint8_t *)&ct_rsp->header,
+		    sizeof(struct ct_rsp_hdr)));
+		rval = QLA_FUNCTION_FAILED;
+	} else {
+		/* Populate fc_port_t entry. */
+		fcport->d_id.b.domain = ct_rsp->rsp.ga_nxt.port_id[0];
+		fcport->d_id.b.area = ct_rsp->rsp.ga_nxt.port_id[1];
+		fcport->d_id.b.al_pa = ct_rsp->rsp.ga_nxt.port_id[2];
+
+		memcpy(fcport->node_name, ct_rsp->rsp.ga_nxt.node_name,
+		    WWN_SIZE);
+		memcpy(fcport->port_name, ct_rsp->rsp.ga_nxt.port_name,
+		    WWN_SIZE);
+
+		if (ct_rsp->rsp.ga_nxt.port_type != NS_N_PORT_TYPE &&
+		    ct_rsp->rsp.ga_nxt.port_type != NS_NL_PORT_TYPE)
+			fcport->d_id.b.domain = 0xf0;
+
+		DEBUG2_3(printk("scsi(%ld): GA_NXT entry - "
+		    "nn %02x%02x%02x%02x%02x%02x%02x%02x "
+		    "pn %02x%02x%02x%02x%02x%02x%02x%02x "
+		    "portid=%02x%02x%02x.\n",
+		    ha->host_no,
+		    fcport->node_name[0], fcport->node_name[1],
+		    fcport->node_name[2], fcport->node_name[3],
+		    fcport->node_name[4], fcport->node_name[5],
+		    fcport->node_name[6], fcport->node_name[7],
+		    fcport->port_name[0], fcport->port_name[1],
+		    fcport->port_name[2], fcport->port_name[3],
+		    fcport->port_name[4], fcport->port_name[5],
+		    fcport->port_name[6], fcport->port_name[7],
+		    fcport->d_id.b.domain, fcport->d_id.b.area,
+		    fcport->d_id.b.al_pa));
+	}
+
+	return (rval);
+}
+
+/**
+ * qla2x00_gid_pt() - SNS scan for fabric devices via GID_PT command.
+ * @ha: HA context
+ * @list: switch info entries to populate
+ *
+ * NOTE: Non-Nx_Ports are not requested.
+ *
+ * Returns 0 on success.
+ */
+int
+qla2x00_gid_pt(scsi_qla_host_t *ha, sw_info_t *list)
+{
+	int		rval;
+	uint16_t	i;
+
+	ms_iocb_entry_t	*ms_pkt;
+	struct ct_sns_req	*ct_req;
+	struct ct_sns_rsp	*ct_rsp;
+
+	struct ct_sns_gid_pt_data *gid_data;
+
+	gid_data = NULL;
+
+	/* Issue GID_PT */
+	/* Prepare common MS IOCB */
+	ms_pkt = qla2x00_prep_ms_iocb(ha, GID_PT_REQ_SIZE, GID_PT_RSP_SIZE);
+
+	/* Prepare CT request */
+	ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GID_PT_CMD,
+	    GID_PT_RSP_SIZE);
+	ct_rsp = &ha->ct_sns->p.rsp;
+
+	/* Prepare CT arguments -- port_type */
+	ct_req->req.gid_pt.port_type = NS_NX_PORT_TYPE;
+
+	/* Execute MS IOCB */
+	rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
+	    sizeof(ms_iocb_entry_t));
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3(printk("scsi(%ld): GID_PT issue IOCB failed (%d).\n",
+		    ha->host_no, rval));
+	} else if (ct_rsp->header.response !=
+	    __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) {
+		DEBUG2_3(printk("scsi(%ld): GID_PT failed, rejected request, "
+		    "gid_pt_rsp:\n", ha->host_no));
+		DEBUG2_3(qla2x00_dump_buffer((uint8_t *)&ct_rsp->header,
+		    sizeof(struct ct_rsp_hdr)));
+		rval = QLA_FUNCTION_FAILED;
+	} else {
+		/* Set port IDs in switch info list. */
+		for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
+			gid_data = &ct_rsp->rsp.gid_pt.entries[i];
+			list[i].d_id.b.domain = gid_data->port_id[0];
+			list[i].d_id.b.area = gid_data->port_id[1];
+			list[i].d_id.b.al_pa = gid_data->port_id[2];
+
+			/* Last one exit. */
+			if (gid_data->control_byte & BIT_7) {
+				list[i].d_id.b.rsvd_1 = gid_data->control_byte;
+				break;
+			}
+		}
+
+		/*
+		 * If we've used all available slots, then the switch is
+		 * reporting back more devices that we can handle with this
+		 * single call.  Return a failed status, and let GA_NXT handle
+		 * the overload.
+		 */
+		if (i == MAX_FIBRE_DEVICES) 
+			rval = QLA_FUNCTION_FAILED;
+	}
+
+	return (rval);
+}
+
+/**
+ * qla2x00_gpn_id() - SNS Get Port Name (GPN_ID) query.
+ * @ha: HA context
+ * @list: switch info entries to populate
+ *
+ * Returns 0 on success.
+ */
+int
+qla2x00_gpn_id(scsi_qla_host_t *ha, sw_info_t *list)
+{
+	int		rval;
+	uint16_t	i;
+
+	ms_iocb_entry_t	*ms_pkt;
+	struct ct_sns_req	*ct_req;
+	struct ct_sns_rsp	*ct_rsp;
+
+	for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
+		/* Issue GPN_ID */
+		/* Prepare common MS IOCB */
+		ms_pkt = qla2x00_prep_ms_iocb(ha, GPN_ID_REQ_SIZE,
+		    GPN_ID_RSP_SIZE);
+
+		/* Prepare CT request */
+		ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GPN_ID_CMD,
+		    GPN_ID_RSP_SIZE);
+		ct_rsp = &ha->ct_sns->p.rsp;
+
+		/* Prepare CT arguments -- port_id */
+		ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain;
+		ct_req->req.port_id.port_id[1] = list[i].d_id.b.area;
+		ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
+
+		/* Execute MS IOCB */
+		rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
+		    sizeof(ms_iocb_entry_t));
+		if (rval != QLA_SUCCESS) {
+			/*EMPTY*/
+			DEBUG2_3(printk("scsi(%ld): GPN_ID issue IOCB failed "
+			    "(%d).\n", ha->host_no, rval));
+		} else if (ct_rsp->header.response !=
+		    __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) {
+			DEBUG2_3(printk("scsi(%ld): GPN_ID failed, rejected "
+			    "request, gpn_id_rsp:\n", ha->host_no));
+			DEBUG2_3(qla2x00_dump_buffer((uint8_t *)&ct_rsp->header,
+			    sizeof(struct ct_rsp_hdr)));
+			rval = QLA_FUNCTION_FAILED;
+		} else {
+			/* Save portname */
+			memcpy(list[i].port_name,
+			    ct_rsp->rsp.gpn_id.port_name, WWN_SIZE);
+		}
+
+		/* Last device exit. */
+		if (list[i].d_id.b.rsvd_1 != 0)
+			break;
+	}
+
+	return (rval);
+}
+
+/**
+ * qla2x00_gnn_id() - SNS Get Node Name (GPN_ID) query.
+ * @ha: HA context
+ * @list: switch info entries to populate
+ *
+ * Returns 0 on success.
+ */
+int
+qla2x00_gnn_id(scsi_qla_host_t *ha, sw_info_t *list)
+{
+	int		rval;
+	uint16_t	i;
+
+	ms_iocb_entry_t	*ms_pkt;
+	struct ct_sns_req	*ct_req;
+	struct ct_sns_rsp	*ct_rsp;
+
+	for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
+		/* Issue GNN_ID */
+		/* Prepare common MS IOCB */
+		ms_pkt = qla2x00_prep_ms_iocb(ha, GNN_ID_REQ_SIZE,
+		    GNN_ID_RSP_SIZE);
+
+		/* Prepare CT request */
+		ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GNN_ID_CMD,
+		    GNN_ID_RSP_SIZE);
+		ct_rsp = &ha->ct_sns->p.rsp;
+
+		/* Prepare CT arguments -- port_id */
+		ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain;
+		ct_req->req.port_id.port_id[1] = list[i].d_id.b.area;
+		ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
+
+		/* Execute MS IOCB */
+		rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
+		    sizeof(ms_iocb_entry_t));
+		if (rval != QLA_SUCCESS) {
+			/*EMPTY*/
+			DEBUG2_3(printk("scsi(%ld): GNN_ID issue IOCB failed "
+			    "(%d).\n", ha->host_no, rval));
+		} else if (ct_rsp->header.response !=
+		    __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) {
+			DEBUG2_3(printk("scsi(%ld): GNN_ID failed, rejected "
+			    "request, gnn_id_rsp:\n", ha->host_no));
+			DEBUG2_3(qla2x00_dump_buffer((uint8_t *)&ct_rsp->header,
+			    sizeof(struct ct_rsp_hdr)));
+			rval = QLA_FUNCTION_FAILED;
+		} else {
+			/* Save nodename */
+			memcpy(list[i].node_name,
+			    ct_rsp->rsp.gnn_id.node_name, WWN_SIZE);
+
+			DEBUG2_3(printk("scsi(%ld): GID_PT entry - "
+			    "nn %02x%02x%02x%02x%02x%02x%02x%02x "
+			    "pn %02x%02x%02x%02x%02x%02x%02x%02x "
+			    "portid=%02x%02x%02x.\n",
+			    ha->host_no,
+			    list[i].node_name[0], list[i].node_name[1],
+			    list[i].node_name[2], list[i].node_name[3],
+			    list[i].node_name[4], list[i].node_name[5],
+			    list[i].node_name[6], list[i].node_name[7],
+			    list[i].port_name[0], list[i].port_name[1],
+			    list[i].port_name[2], list[i].port_name[3],
+			    list[i].port_name[4], list[i].port_name[5],
+			    list[i].port_name[6], list[i].port_name[7],
+			    list[i].d_id.b.domain, list[i].d_id.b.area,
+			    list[i].d_id.b.al_pa));
+		}
+
+		/* Last device exit. */
+		if (list[i].d_id.b.rsvd_1 != 0)
+			break;
+	}
+
+	return (rval);
+}
+
+/**
+ * qla2x00_gft_id() - SNS Get FC-4 TYPEs (GFT_ID) query.
+ * @ha: HA context
+ * @list: switch info entries to populate
+ *
+ * Returns 0 on success.
+ */
+int
+qla2x00_gft_id(scsi_qla_host_t *ha, sw_info_t *list)
+{
+	int		rval;
+	uint16_t	i;
+
+	ms_iocb_entry_t	*ms_pkt;
+	struct ct_sns_req	*ct_req;
+	struct ct_sns_rsp	*ct_rsp;
+
+	for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
+		/* Issue GFT_ID */
+		/* Prepare common MS IOCB */
+		ms_pkt = qla2x00_prep_ms_iocb(ha, GFT_ID_REQ_SIZE,
+		    GFT_ID_RSP_SIZE);
+
+		/* Prepare CT request */
+		ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GFT_ID_CMD,
+		    GFT_ID_RSP_SIZE);
+		ct_rsp = &ha->ct_sns->p.rsp;
+
+		/* Prepare CT arguments -- port_id */
+		ct_req->req.port_id.port_id[0] = list[i].d_id.b.domain;
+		ct_req->req.port_id.port_id[1] = list[i].d_id.b.area;
+		ct_req->req.port_id.port_id[2] = list[i].d_id.b.al_pa;
+
+		/* Execute MS IOCB */
+		rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
+		    sizeof(ms_iocb_entry_t));
+		if (rval != QLA_SUCCESS) {
+			/*EMPTY*/
+			DEBUG2_3(printk("scsi(%ld): GFT_ID issue IOCB failed "
+			    "(%d).\n", ha->host_no, rval));
+		} else if (ct_rsp->header.response !=
+		    __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) {
+			DEBUG2_3(printk("scsi(%ld): GFT_ID failed, rejected "
+			    "request, gft_id_rsp:\n", ha->host_no));
+			DEBUG2_3(qla2x00_dump_buffer((uint8_t *)&ct_rsp->header,
+			    sizeof(struct ct_rsp_hdr)));
+			rval = QLA_FUNCTION_FAILED;
+		} else {
+			/* FCP-3 check necessary?  No, assume FCP-3 */
+			/*if (ct_rsp->rsp.gft_id.fc4_types[2] & 0x01)*/
+			list[i].type = SW_TYPE_SCSI;
+			if (ct_rsp->rsp.gft_id.fc4_types[3] & 0x20)
+				list[i].type |= SW_TYPE_IP;
+		}
+
+		/* Last device exit. */
+		if (list[i].d_id.b.rsvd_1 != 0)
+			break;
+	}
+
+	return (rval);
+}
+
+/**
+ * qla2x00_rft_id() - SNS Register FC-4 TYPEs (RFT_ID) supported by the HBA.
+ * @ha: HA context
+ *
+ * Returns 0 on success.
+ */
+int
+qla2x00_rft_id(scsi_qla_host_t *ha)
+{
+	int		rval;
+
+	ms_iocb_entry_t	*ms_pkt;
+	struct ct_sns_req	*ct_req;
+	struct ct_sns_rsp	*ct_rsp;
+
+	/* Issue RFT_ID */
+	/* Prepare common MS IOCB */
+	ms_pkt = qla2x00_prep_ms_iocb(ha, RFT_ID_REQ_SIZE, RFT_ID_RSP_SIZE);
+
+	/* Prepare CT request */
+	ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFT_ID_CMD,
+	    RFT_ID_RSP_SIZE);
+	ct_rsp = &ha->ct_sns->p.rsp;
+
+	/* Prepare CT arguments -- port_id, FC-4 types */
+	ct_req->req.rft_id.port_id[0] = ha->d_id.b.domain;
+	ct_req->req.rft_id.port_id[1] = ha->d_id.b.area;
+	ct_req->req.rft_id.port_id[2] = ha->d_id.b.al_pa;
+
+	ct_req->req.rft_id.fc4_types[2] = 0x01;		/* FCP-3 */
+	ha->active_fc4_types = EXT_DEF_FC4_TYPE_SCSI;
+
+	/* Execute MS IOCB */
+	rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
+	    sizeof(ms_iocb_entry_t));
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3(printk("scsi(%ld): RFT_ID issue IOCB failed (%d).\n",
+		    ha->host_no, rval));
+	} else if (ct_rsp->header.response !=
+	    __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) {
+		DEBUG2_3(printk("scsi(%ld): RFT_ID failed, rejected "
+		    "request, rft_id_rsp:\n", ha->host_no));
+		DEBUG2_3(qla2x00_dump_buffer((uint8_t *)&ct_rsp->header,
+		    sizeof(struct ct_rsp_hdr)));
+		rval = QLA_FUNCTION_FAILED;
+	} else {
+		DEBUG2(printk("scsi(%ld): RFT_ID exiting normally.\n",
+		    ha->host_no));
+	}
+
+	return (rval);
+}
+
+/**
+ * qla2x00_rff_id() - SNS Register FC-4 Features (RFF_ID) supported by the HBA.
+ * @ha: HA context
+ *
+ * Returns 0 on success.
+ */
+int
+qla2x00_rff_id(scsi_qla_host_t *ha)
+{
+	int		rval;
+
+	ms_iocb_entry_t	*ms_pkt;
+	struct ct_sns_req	*ct_req;
+	struct ct_sns_rsp	*ct_rsp;
+
+	/* Issue RFF_ID */
+	/* Prepare common MS IOCB */
+	ms_pkt = qla2x00_prep_ms_iocb(ha, RFF_ID_REQ_SIZE, RFF_ID_RSP_SIZE);
+
+	/* Prepare CT request */
+	ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFF_ID_CMD,
+	    RFF_ID_RSP_SIZE);
+	ct_rsp = &ha->ct_sns->p.rsp;
+
+	/* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */
+	ct_req->req.rff_id.port_id[0] = ha->d_id.b.domain;
+	ct_req->req.rff_id.port_id[1] = ha->d_id.b.area;
+	ct_req->req.rff_id.port_id[2] = ha->d_id.b.al_pa;
+
+	ct_req->req.rff_id.fc4_type = 0x08;		/* SCSI - FCP */
+
+	/* Execute MS IOCB */
+	rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
+	    sizeof(ms_iocb_entry_t));
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3(printk("scsi(%ld): RFF_ID issue IOCB failed (%d).\n",
+		    ha->host_no, rval));
+	} else if (ct_rsp->header.response !=
+	    __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) {
+		DEBUG2_3(printk("scsi(%ld): RFF_ID failed, rejected "
+		    "request, rff_id_rsp:\n", ha->host_no));
+		DEBUG2_3(qla2x00_dump_buffer((uint8_t *)&ct_rsp->header,
+		    sizeof(struct ct_rsp_hdr)));
+		rval = QLA_FUNCTION_FAILED;
+	} else {
+		DEBUG2(printk("scsi(%ld): RFF_ID exiting normally.\n",
+		    ha->host_no));
+	}
+
+	return (rval);
+}
+
+/**
+ * qla2x00_rnn_id() - SNS Register Node Name (RNN_ID) of the HBA.
+ * @ha: HA context
+ *
+ * Returns 0 on success.
+ */
+int
+qla2x00_rnn_id(scsi_qla_host_t *ha)
+{
+	int		rval;
+
+	ms_iocb_entry_t	*ms_pkt;
+	struct ct_sns_req	*ct_req;
+	struct ct_sns_rsp	*ct_rsp;
+
+	/* Issue RNN_ID */
+	/* Prepare common MS IOCB */
+	ms_pkt = qla2x00_prep_ms_iocb(ha, RNN_ID_REQ_SIZE, RNN_ID_RSP_SIZE);
+
+	/* Prepare CT request */
+	ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RNN_ID_CMD,
+	    RNN_ID_RSP_SIZE);
+	ct_rsp = &ha->ct_sns->p.rsp;
+
+	/* Prepare CT arguments -- port_id, node_name */
+	ct_req->req.rnn_id.port_id[0] = ha->d_id.b.domain;
+	ct_req->req.rnn_id.port_id[1] = ha->d_id.b.area;
+	ct_req->req.rnn_id.port_id[2] = ha->d_id.b.al_pa;
+
+	memcpy(ct_req->req.rnn_id.node_name, ha->init_cb->node_name, WWN_SIZE);
+
+	/* Execute MS IOCB */
+	rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
+	    sizeof(ms_iocb_entry_t));
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3(printk("scsi(%ld): RNN_ID issue IOCB failed (%d).\n",
+		    ha->host_no, rval));
+	} else if (ct_rsp->header.response !=
+	    __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) {
+		DEBUG2_3(printk("scsi(%ld): RNN_ID failed, rejected "
+		    "request, rnn_id_rsp:\n", ha->host_no));
+		DEBUG2_3(qla2x00_dump_buffer((uint8_t *)&ct_rsp->header,
+		    sizeof(struct ct_rsp_hdr)));
+		rval = QLA_FUNCTION_FAILED;
+	} else {
+		DEBUG2(printk("scsi(%ld): RNN_ID exiting normally.\n",
+		    ha->host_no));
+	}
+
+	return (rval);
+}
+
+/**
+ * qla2x00_rsnn_nn() - SNS Register Symbolic Node Name (RSNN_NN) of the HBA.
+ * @ha: HA context
+ *
+ * Returns 0 on success.
+ */
+int
+qla2x00_rsnn_nn(scsi_qla_host_t *ha)
+{
+	int		rval;
+	uint8_t		*snn;
+	uint8_t		version[20];
+
+	ms_iocb_entry_t	*ms_pkt;
+	struct ct_sns_req	*ct_req;
+	struct ct_sns_rsp	*ct_rsp;
+
+	/* Issue RSNN_NN */
+	/* Prepare common MS IOCB */
+	/*   Request size adjusted after CT preparation */
+	ms_pkt = qla2x00_prep_ms_iocb(ha, 0, RSNN_NN_RSP_SIZE);
+
+	/* Prepare CT request */
+	ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RSNN_NN_CMD,
+	    RSNN_NN_RSP_SIZE);
+	ct_rsp = &ha->ct_sns->p.rsp;
+
+	/* Prepare CT arguments -- node_name, symbolic node_name, size */
+	memcpy(ct_req->req.rsnn_nn.node_name, ha->init_cb->node_name, WWN_SIZE);
+	
+	/* Prepare the Symbolic Node Name */
+	/* Board type */
+	snn = ct_req->req.rsnn_nn.sym_node_name;
+	strcpy(snn, ha->model_number);
+	/* Firmware version */
+	strcat(snn, " FW:v");
+	sprintf(version, "%d.%02d.%02d", ha->fw_major_version,
+	    ha->fw_minor_version, ha->fw_subminor_version);
+	strcat(snn, version);
+	/* Driver version */
+	strcat(snn, " DVR:v");
+	strcat(snn, qla2x00_version_str);
+
+	/* Calculate SNN length */
+	ct_req->req.rsnn_nn.name_len = (uint8_t)strlen(snn);
+
+	/* Update MS IOCB request */
+	ms_pkt->req_bytecount =
+	    cpu_to_le32(24 + 1 + ct_req->req.rsnn_nn.name_len);
+	ms_pkt->dseg_req_length = ms_pkt->req_bytecount;
+
+	/* Execute MS IOCB */
+	rval = qla2x00_issue_iocb(ha, ha->ms_iocb, ha->ms_iocb_dma,
+	    sizeof(ms_iocb_entry_t));
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3(printk("scsi(%ld): RSNN_NN issue IOCB failed (%d).\n",
+		    ha->host_no, rval));
+	} else if (ct_rsp->header.response !=
+	    __constant_cpu_to_be16(CT_ACCEPT_RESPONSE)) {
+		DEBUG2_3(printk("scsi(%ld): RSNN_NN failed, rejected "
+		    "request, rsnn_id_rsp:\n", ha->host_no));
+		DEBUG2_3(qla2x00_dump_buffer((uint8_t *)&ct_rsp->header,
+		    sizeof(struct ct_rsp_hdr)));
+		rval = QLA_FUNCTION_FAILED;
+	} else {
+		DEBUG2(printk("scsi(%ld): RSNN_NN exiting normally.\n",
+		    ha->host_no));
+	}
+
+	return (rval);
+}
diff -puN /dev/null drivers/scsi/qla2xxx/qla_init.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/qla_init.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,4260 @@
+/*
+ *                  QLOGIC LINUX SOFTWARE
+ *
+ * QLogic ISP2x00 device driver for Linux 2.6.x
+ * Copyright (C) 2003 QLogic Corporation
+ * (www.qlogic.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+#include "qla_os.h"
+#include "qla_def.h"
+#include "qla_devtbl.h"
+
+/* XXX(hch): this is ugly, but we don't want to pull in exioctl.h */
+#ifndef EXT_IS_LUN_BIT_SET
+#define EXT_IS_LUN_BIT_SET(P,L) \
+    (((P)->mask[L/8] & (0x80 >> (L%8)))?1:0)
+#define EXT_SET_LUN_BIT(P,L) \
+    ((P)->mask[L/8] |= (0x80 >> (L%8)))
+#endif
+
+/*
+*  QLogic ISP2x00 Hardware Support Function Prototypes.
+*/
+static int qla2x00_pci_config(scsi_qla_host_t *);
+static int qla2x00_isp_firmware(scsi_qla_host_t *);
+static void qla2x00_reset_chip(scsi_qla_host_t *);
+static int qla2x00_chip_diag(scsi_qla_host_t *);
+static int qla2x00_setup_chip(scsi_qla_host_t *);
+static void qla2x00_init_response_q_entries(scsi_qla_host_t *);
+static int qla2x00_init_rings(scsi_qla_host_t *);
+static int qla2x00_fw_ready(scsi_qla_host_t *);
+static int qla2x00_configure_hba(scsi_qla_host_t *);
+static int qla2x00_nvram_config(scsi_qla_host_t *);
+static void qla2x00_init_tgt_map(scsi_qla_host_t *);
+static int qla2x00_configure_loop(scsi_qla_host_t *);
+static int qla2x00_configure_local_loop(scsi_qla_host_t *);
+static void qla2x00_update_fcport(scsi_qla_host_t *, fc_port_t *);
+static void qla2x00_lun_discovery(scsi_qla_host_t *, fc_port_t *);
+static int qla2x00_rpt_lun_discovery(scsi_qla_host_t *, fc_port_t *,
+    inq_cmd_rsp_t *, dma_addr_t);
+static int qla2x00_report_lun(scsi_qla_host_t *, fc_port_t *,
+    rpt_lun_cmd_rsp_t *, dma_addr_t);
+static fc_lun_t *qla2x00_cfg_lun(scsi_qla_host_t *, fc_port_t *, uint16_t,
+    inq_cmd_rsp_t *, dma_addr_t);
+static fc_lun_t * qla2x00_add_lun(fc_port_t *, uint16_t);
+static int qla2x00_inquiry(scsi_qla_host_t *, fc_port_t *, uint16_t,
+    inq_cmd_rsp_t *, dma_addr_t);
+static int qla2x00_configure_fabric(scsi_qla_host_t *);
+static int qla2x00_find_all_fabric_devs(scsi_qla_host_t *, struct list_head *);
+static int qla2x00_device_resync(scsi_qla_host_t *);
+static int qla2x00_fabric_dev_login(scsi_qla_host_t *, fc_port_t *,
+    uint16_t *);
+static void qla2x00_config_os(scsi_qla_host_t *ha);
+static uint16_t qla2x00_fcport_bind(scsi_qla_host_t *ha, fc_port_t *fcport);
+static os_lun_t * qla2x00_fclun_bind(scsi_qla_host_t *, fc_port_t *,
+    fc_lun_t *);
+static void qla2x00_lun_free(scsi_qla_host_t *, uint16_t, uint16_t);
+static int qla2x00_bstr_to_hex(char *, uint8_t *, int);
+static int qla2x00_find_propname(scsi_qla_host_t *,
+    char *, char *, char *, int);
+#if 0
+static int qla2x00_get_prop_16chars(scsi_qla_host_t *,
+    char *, char *, char *);
+static void qla2x00_get_properties(scsi_qla_host_t *, char *);
+
+static void qla2x00_cfg_persistent_binding(scsi_qla_host_t *);
+static os_tgt_t *qla2x00_persistent_bind(scsi_qla_host_t *, uint8_t *,
+    uint8_t *, port_id_t *, uint16_t);
+#endif
+
+static int qla2x00_restart_isp(scsi_qla_host_t *);
+static void qla2x00_reset_adapter(scsi_qla_host_t *);
+
+/****************************************************************************/
+/*                QLogic ISP2x00 Hardware Support Functions.                */
+/****************************************************************************/
+
+/*
+* qla2x00_initialize_adapter
+*      Initialize board.
+*
+* Input:
+*      ha = adapter block pointer.
+*
+* Returns:
+*      0 = success
+*/
+int
+qla2x00_initialize_adapter(scsi_qla_host_t *ha)
+{
+	int	rval;
+	uint8_t	isp_init = 0;
+	uint8_t	restart_risc = 0;
+	uint8_t	retry;
+
+	/* Clear adapter flags. */
+	ha->flags.online = FALSE;
+	ha->flags.reset_active = FALSE;
+	atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
+	atomic_set(&ha->loop_state, LOOP_DOWN);
+	ha->device_flags = 0;
+	ha->sns_retry_cnt = 0;
+	ha->dpc_flags = 0;
+	ha->failback_delay = 0;
+	ha->flags.management_server_logged_in = 0;
+	ha->marker_needed = 0;
+	ha->mbx_flags = 0;
+	ha->isp_abort_cnt = 0;
+	ha->beacon_blink_led = 0;
+
+	rval = qla2x00_pci_config(ha);
+	if (rval) {
+		DEBUG2(printk("scsi(%ld): Unable to configure PCI space=n",
+		    ha->host_no));
+		return (rval);
+	}
+
+	qla2x00_reset_chip(ha);
+
+	/* Initialize target map database. */
+	qla2x00_init_tgt_map(ha);
+
+	/* Get Flash Version */
+	qla2x00_get_flash_version(ha);
+
+	qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n");
+	qla2x00_nvram_config(ha);
+
+	ha->retry_count = ql2xretrycount;
+
+	qla_printk(KERN_INFO, ha, "Verifying loaded RISC code...\n");
+
+#if 0
+	/*
+	 * If the user specified a device configuration on the command line
+	 * then use it as the configuration.  Otherwise, we scan for all
+	 * devices.
+	 */
+	if (ql2xdevconf) {
+		ha->cmdline = ql2xdevconf;
+	}
+#endif
+
+	retry = 10;
+	/*
+	 * Try to configure the loop.
+	 */
+	do {
+		restart_risc = 0;
+		isp_init = 0;
+
+		/* If firmware needs to be loaded */
+		if (qla2x00_isp_firmware(ha) != QLA_SUCCESS) {
+			if ((rval = qla2x00_chip_diag(ha)) == QLA_SUCCESS) {
+				rval = qla2x00_setup_chip(ha);
+			}
+		}
+
+		/* Retrieve firmware information */
+		qla2x00_get_fw_version(ha, &ha->fw_major_version,
+		    &ha->fw_minor_version, &ha->fw_subminor_version,
+		    &ha->fw_attributes);
+		qla2x00_get_resource_cnts(ha, NULL, &ha->xchg_buf_cnt,
+		    &ha->iocb_buf_cnt, NULL);
+
+		if (rval == QLA_SUCCESS &&
+		    (rval = qla2x00_init_rings(ha)) == QLA_SUCCESS) {
+check_fw_ready_again:
+			/*
+			 * Wait for a successful LIP up to a maximum 
+			 * of (in seconds): RISC login timeout value,
+			 * RISC retry count value, and port down retry
+			 * value OR a minimum of 4 seconds OR If no 
+			 * cable, only 5 seconds.
+			 */
+			if (!qla2x00_fw_ready(ha)) {
+				clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
+
+				/*
+				 * Go setup flash database devices with proper
+				 * Loop ID's.
+				 */
+				do {
+					clear_bit(LOOP_RESYNC_NEEDED,
+					    &ha->dpc_flags);
+					rval = qla2x00_configure_loop(ha);
+
+					if (test_bit(ISP_ABORT_NEEDED,
+					    &ha->dpc_flags)) {
+
+						restart_risc = 1;
+						break;
+					}
+
+					/*
+					 * If loop state change while we were
+					 * discoverying devices then wait for
+					 * LIP to complete
+					 */
+
+					if (atomic_read(&ha->loop_state) ==
+					    LOOP_DOWN && retry--) {
+						goto check_fw_ready_again;
+					}
+				} while (!atomic_read(&ha->loop_down_timer) &&
+				    retry &&
+				    (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)));
+			}
+
+			if (ha->mem_err) {
+				restart_risc = 1;
+			}
+			isp_init = 1;
+
+		}
+	} while (restart_risc && retry--);
+
+	if (isp_init) {
+		clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
+		ha->marker_needed = 1;
+		qla2x00_marker(ha, 0, 0, MK_SYNC_ALL);
+		ha->marker_needed = 0;
+
+		ha->flags.online = TRUE;
+	}
+
+	if (rval) {
+		DEBUG2_3(printk("%s(): **** FAILED ****\n", __func__));
+	}
+
+	return (rval);
+}
+
+/**
+ * qla2x00_pci_config() - Setup device PCI configuration registers.
+ * @ha: HA context
+ *
+ * Returns 0 on success.
+ */
+static int
+qla2x00_pci_config(scsi_qla_host_t *ha)
+{
+	uint16_t	w, mwi;
+	unsigned long   flags = 0;
+	uint32_t	cnt;
+
+	qla_printk(KERN_INFO, ha, "Configuring PCI space...\n");
+
+	/* 
+	 * Turn on PCI master; for system BIOSes that don't turn it on by
+	 * default.
+	 */
+	pci_set_master(ha->pdev);
+	mwi = 0;
+	if (pci_set_mwi(ha->pdev))
+		mwi = PCI_COMMAND_INVALIDATE;
+	pci_read_config_word(ha->pdev, PCI_REVISION_ID, &ha->revision);
+
+	if (!ha->iobase)
+		return (QLA_FUNCTION_FAILED);
+
+	/*
+	 * We want to respect framework's setting of PCI configuration space
+	 * command register and also want to make sure that all bits of
+	 * interest to us are properly set in command register.
+	 */
+	pci_read_config_word(ha->pdev, PCI_COMMAND, &w);
+	w |= mwi | (PCI_COMMAND_PARITY | PCI_COMMAND_SERR);
+
+	/* Get PCI bus information. */
+	spin_lock_irqsave(&ha->hardware_lock, flags);
+	ha->pci_attr = RD_REG_WORD(&ha->iobase->ctrl_status);
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+	if (IS_QLA23XX(ha)) {
+		pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80);
+
+		/* PCI Specification Revision 2.3 changes */
+		if (IS_QLA2322(ha))
+			/* Command Register - Reset Interrupt Disable. */
+			w &= ~BIT_10;
+
+		/*
+		 * If this is a 2300 card and not 2312, reset the
+		 * COMMAND_INVALIDATE due to a bug in the 2300. Unfortunately,
+		 * the 2310 also reports itself as a 2300 so we need to get the
+		 * fb revision level -- a 6 indicates it really is a 2300 and
+		 * not a 2310.
+		 */
+		if (IS_QLA2300(ha)) {
+			spin_lock_irqsave(&ha->hardware_lock, flags);
+
+			/* Pause RISC. */
+			WRT_REG_WORD(&ha->iobase->hccr, HCCR_PAUSE_RISC);
+			for (cnt = 0; cnt < 30000; cnt++) {
+				if ((RD_REG_WORD(&ha->iobase->hccr) &
+				    HCCR_RISC_PAUSE) != 0)
+					break;
+	
+				udelay(10);
+			}
+
+			/* Select FPM registers. */
+			WRT_REG_WORD(&ha->iobase->ctrl_status, 0x20);
+
+			/* Get the fb rev level */
+			ha->fb_rev = RD_FB_CMD_REG(ha, ha->iobase);
+
+			if (ha->fb_rev == FPM_2300)
+				w &= ~PCI_COMMAND_INVALIDATE;
+
+			/* Deselect FPM registers. */
+			WRT_REG_WORD(&ha->iobase->ctrl_status, 0x0);
+
+			/* Release RISC module. */
+			WRT_REG_WORD(&ha->iobase->hccr, HCCR_RELEASE_RISC);
+			for (cnt = 0; cnt < 30000; cnt++) {
+				if ((RD_REG_WORD(&ha->iobase->hccr) &
+				    HCCR_RISC_PAUSE) == 0)
+					break;
+	
+				udelay(10);
+			}
+
+			spin_unlock_irqrestore(&ha->hardware_lock, flags);
+		}
+	}
+
+	pci_write_config_word(ha->pdev, PCI_COMMAND, w);
+
+	/* Reset expansion ROM address decode enable */
+	pci_read_config_word(ha->pdev, PCI_ROM_ADDRESS, &w);
+	w &= ~PCI_ROM_ADDRESS_ENABLE;
+	pci_write_config_word(ha->pdev, PCI_ROM_ADDRESS, w);
+
+	return (QLA_SUCCESS);
+}
+
+/**
+ * qla2x00_isp_firmware() - Choose firmware image.
+ * @ha: HA context
+ *
+ * Returns 0 on success.
+ */
+static int
+qla2x00_isp_firmware(scsi_qla_host_t *ha)
+{
+	int  rval;
+
+	/* Assume loading risc code */
+	rval = QLA_FUNCTION_FAILED; 
+
+	if (ha->flags.disable_risc_code_load) {
+		DEBUG2(printk("scsi(%ld): RISC CODE NOT loaded\n",
+		    ha->host_no));
+		qla_printk(KERN_INFO, ha, "RISC CODE NOT loaded\n");
+
+		/* Verify checksum of loaded RISC code. */
+		rval = qla2x00_verify_checksum(ha);
+	}
+
+	if (rval) {
+		DEBUG2_3(printk("scsi(%ld): **** Load RISC code ****\n",
+		    ha->host_no));
+	}
+
+	return (rval);
+}
+
+/**
+ * qla2x00_reset_chip() - Reset ISP chip.
+ * @ha: HA context
+ *
+ * Returns 0 on success.
+ */
+static void
+qla2x00_reset_chip(scsi_qla_host_t *ha) 
+{
+	unsigned long   flags = 0;
+	device_reg_t	*reg = ha->iobase;
+	uint32_t	cnt;
+	unsigned long	mbx_flags = 0;
+	uint16_t	cmd;
+
+	/* Disable ISP interrupts. */
+	qla2x00_disable_intrs(ha);
+
+	spin_lock_irqsave(&ha->hardware_lock, flags);
+
+	/* Turn off master enable */
+	cmd = 0;
+	pci_read_config_word(ha->pdev, PCI_COMMAND, &cmd);
+	cmd &= ~PCI_COMMAND_MASTER;
+	pci_write_config_word(ha->pdev, PCI_COMMAND, cmd);
+
+	if (!IS_QLA2100(ha)) {
+		/* Pause RISC. */
+		WRT_REG_WORD(&reg->hccr, HCCR_PAUSE_RISC);
+		if (!IS_QLA2312(ha) && !IS_QLA2322(ha)) {
+			for (cnt = 0; cnt < 30000; cnt++) {
+				if ((RD_REG_WORD(&reg->hccr) &
+				    HCCR_RISC_PAUSE) != 0)
+					break;
+				udelay(100);
+			}
+		} else {
+			udelay(10);
+		}
+
+		/* Select FPM registers. */
+		WRT_REG_WORD(&reg->ctrl_status, 0x20);
+
+		/* FPM Soft Reset. */
+		WRT_REG_WORD(&reg->fpm_diag_config, 0x100);
+
+		/* Toggle Fpm Reset. */
+		if (IS_QLA23XX(ha))
+			WRT_REG_WORD(&reg->fpm_diag_config, 0x0);
+
+		/* Select frame buffer registers. */
+		WRT_REG_WORD(&reg->ctrl_status, 0x10);
+
+		/* Reset frame buffer FIFOs. */
+		if (IS_QLA2200(ha)) {
+			WRT_FB_CMD_REG(ha, reg, 0xa000);
+		} else {
+			WRT_FB_CMD_REG(ha, reg, 0x00fc);
+
+			/* Read back fb_cmd until zero or 3 seconds max */
+			for (cnt = 0; cnt < 3000; cnt++) {
+				if ((RD_FB_CMD_REG(ha, reg) & 0xff) == 0)
+					break;
+				udelay(100);
+			}
+		}
+
+		/* Select RISC module registers. */
+		WRT_REG_WORD(&reg->ctrl_status, 0);
+
+		/* Reset RISC processor. */
+		WRT_REG_WORD(&reg->hccr, HCCR_RESET_RISC);
+
+		/* Release RISC processor. */
+		WRT_REG_WORD(&reg->hccr, HCCR_RELEASE_RISC);
+	}
+
+	WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
+	WRT_REG_WORD(&reg->hccr, HCCR_CLR_HOST_INT);
+
+	/* Reset ISP chip. */
+	WRT_REG_WORD(&reg->ctrl_status, CSR_ISP_SOFT_RESET);
+
+	/* Wait for RISC to recover from reset. */
+	if (IS_QLA2312(ha) || IS_QLA2322(ha)) {
+		udelay(10);
+	} else {
+		/*
+		 * It is necessary to for a delay here since the card doesn't
+		 * respond to PCI reads during a reset. On some architectures
+		 * this will result in an MCA.
+		 */
+		udelay(20);
+		for (cnt = 30000; cnt; cnt--) {
+			if ((RD_REG_WORD(&reg->ctrl_status) &
+			    CSR_ISP_SOFT_RESET) == 0)
+				break;
+			udelay(100);
+		}
+	}
+
+	/* Reset RISC processor. */
+	WRT_REG_WORD(&reg->hccr, HCCR_RESET_RISC);
+
+	WRT_REG_WORD(&reg->semaphore, 0);
+
+	/* Release RISC processor. */
+	WRT_REG_WORD(&reg->hccr, HCCR_RELEASE_RISC);
+	RD_REG_WORD(&reg->hccr);		/* PCI Posting. */
+
+	if (IS_QLA2312(ha) || IS_QLA2322(ha))
+		udelay(100);
+	else {
+		for (cnt = 0; cnt < 30000; cnt++) {
+			if (!(test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags)))
+				spin_lock_irqsave(&ha->mbx_reg_lock, mbx_flags);
+
+			if (RD_MAILBOX_REG(ha, reg, 0) != MBS_BUSY) {
+				if (!(test_bit(ABORT_ISP_ACTIVE,
+				    &ha->dpc_flags)))
+					spin_unlock_irqrestore(
+					    &ha->mbx_reg_lock, mbx_flags);
+				break;
+			}
+
+			if (!(test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags)))
+				spin_unlock_irqrestore(&ha->mbx_reg_lock,
+				    mbx_flags);
+
+			udelay(100);
+		}
+	}
+
+	/* Turn on master enable */
+	cmd |= PCI_COMMAND_MASTER;
+	pci_write_config_word(ha->pdev, PCI_COMMAND, cmd);
+
+	/* Disable RISC pause on FPM parity error. */
+	if (!IS_QLA2100(ha))
+		WRT_REG_WORD(&reg->hccr, HCCR_DISABLE_PARITY_PAUSE);
+
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
+}
+
+/**
+ * qla2x00_chip_diag() - Test chip for proper operation.
+ * @ha: HA context
+ *
+ * Returns 0 on success.
+ */
+static int
+qla2x00_chip_diag(scsi_qla_host_t *ha)
+{
+	int		rval;
+	device_reg_t	*reg = ha->iobase;
+	unsigned long	flags = 0;
+	uint16_t	data;
+	uint32_t	cnt;
+	uint16_t	mb[5];
+
+	/* Assume a failed state */
+	rval = QLA_FUNCTION_FAILED;
+
+	DEBUG3(printk("scsi(%ld): Testing device at %lx.\n",
+	    ha->host_no, (u_long)&reg->flash_address));
+
+	spin_lock_irqsave(&ha->hardware_lock, flags);
+
+	/* Reset ISP chip. */
+	WRT_REG_WORD(&reg->ctrl_status, CSR_ISP_SOFT_RESET);
+	/*
+	 * We need to have a delay here since the card will not respond while
+	 * in reset causing an MCA on some architectures.
+	 */
+	udelay(20);
+	data = qla2x00_debounce_register(&reg->ctrl_status);
+	for (cnt = 6000000 ; cnt && (data & CSR_ISP_SOFT_RESET); cnt--) {
+		udelay(5);
+		data = RD_REG_WORD(&reg->ctrl_status);
+		barrier();
+	}
+
+	if (!cnt)
+		goto chip_diag_failed;
+
+	DEBUG3(printk("scsi(%ld): Reset register cleared by chip reset\n",
+	    ha->host_no));
+
+	/* Reset RISC processor. */
+	WRT_REG_WORD(&reg->hccr, HCCR_RESET_RISC);
+	WRT_REG_WORD(&reg->hccr, HCCR_RELEASE_RISC);
+
+	/* Workaround for QLA2312 PCI parity error */
+	if (IS_QLA2312(ha) || IS_QLA2322(ha))
+		udelay(10);
+	else {
+		data = qla2x00_debounce_register(MAILBOX_REG(ha, reg, 0));
+		for (cnt = 6000000; cnt && (data == MBS_BUSY); cnt--) {
+			udelay(5);
+			data = RD_MAILBOX_REG(ha, reg, 0);
+			barrier(); 
+		}
+	}
+
+	if (!cnt)
+		goto chip_diag_failed;
+
+	/* Check product ID of chip */
+	DEBUG3(printk("scsi(%ld): Checking product ID of chip\n", ha->host_no));
+
+	mb[1] = RD_MAILBOX_REG(ha, reg, 1);
+	mb[2] = RD_MAILBOX_REG(ha, reg, 2);
+	mb[3] = RD_MAILBOX_REG(ha, reg, 3);
+
+	if (mb[1] != PROD_ID_1 || (mb[2] != PROD_ID_2 && mb[2] != PROD_ID_2a) ||
+	    mb[3] != PROD_ID_3) {
+		qla_printk(KERN_WARNING, ha,
+		    "Wrong product ID = 0x%x,0x%x,0x%x\n", mb[1], mb[2], mb[3]);
+
+		goto chip_diag_failed;
+	}
+
+	/* Adjust fw RISC transfer size */
+	ha->fw_transfer_size = REQUEST_ENTRY_SIZE * REQUEST_ENTRY_CNT;
+
+	if (IS_QLA2200(ha) &&
+	    RD_MAILBOX_REG(ha, reg, 7) == QLA2200A_RISC_ROM_VER) {
+		/* Limit firmware transfer size with a 2200A */
+		DEBUG3(printk("scsi(%ld): Found QLA2200A chip.\n",
+		    ha->host_no));
+
+		ha->fw_transfer_size = 128;
+	}
+
+	/* Wrap Incoming Mailboxes Test. */
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+	DEBUG3(printk("scsi(%ld): Checking mailboxes.\n", ha->host_no));
+	rval = qla2x00_mbx_reg_test(ha);
+	if (rval) {
+		DEBUG(printk("scsi(%ld): Failed mailbox send register test\n",
+		    ha->host_no));
+		qla_printk(KERN_WARNING, ha,
+		    "Failed mailbox send register test\n");
+	}
+	else {
+		/* Flag a successful rval */
+		rval = QLA_SUCCESS;
+	}
+	spin_lock_irqsave(&ha->hardware_lock, flags);
+
+chip_diag_failed:
+	if (rval)
+		DEBUG2_3(printk("scsi(%ld): Chip diagnostics **** FAILED "
+		    "****\n", ha->host_no));
+
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+	return (rval);
+}
+
+/**
+ * qla2x00_setup_chip() - Load and start RISC firmware.
+ * @ha: HA context
+ *
+ * Returns 0 on success.
+ */
+static int
+qla2x00_setup_chip(scsi_qla_host_t *ha)
+{
+	int		rval;
+	uint16_t	cnt;
+	uint16_t	*risc_code;
+	unsigned long	risc_address;
+	unsigned long	risc_code_size;
+	int		num;
+	int		i;
+	uint16_t	*req_ring;
+	struct qla_fw_info *fw_iter;
+
+	rval = QLA_SUCCESS;
+
+	/* Load firmware sequences */
+	fw_iter = ha->brd_info->fw_info;
+	while (fw_iter->addressing != FW_INFO_ADDR_NOMORE) {
+		risc_code = fw_iter->fwcode;
+		risc_code_size = *fw_iter->fwlen;
+
+		if (fw_iter->addressing == FW_INFO_ADDR_NORMAL) {
+			risc_address = *fw_iter->fwstart;
+		} else {
+			/* Extended address */
+			risc_address = *fw_iter->lfwstart;
+		}
+
+		num = 0;
+		rval = 0;
+		while (risc_code_size > 0 && !rval) {
+			cnt = (uint16_t)(ha->fw_transfer_size >> 1);
+			if (cnt > risc_code_size)
+				cnt = risc_code_size;
+
+			DEBUG7(printk("scsi(%ld): Loading risc segment@ "
+			    "addr %p, number of bytes 0x%x, offset 0x%lx.\n",
+			    ha->host_no, risc_code, cnt, risc_address));
+
+			req_ring = (uint16_t *)ha->request_ring;
+			for (i = 0; i < cnt; i++)
+				req_ring[i] = cpu_to_le16(risc_code[i]);
+
+			/*
+			 * Flush written firmware to the ha->request_ring buffer
+			 * before DMA.
+			 */
+			flush_cache_all();
+
+			if (fw_iter->addressing == FW_INFO_ADDR_NORMAL) {
+				rval = qla2x00_load_ram(ha,
+				    ha->request_dma, risc_address, cnt);
+			} else {
+				rval = qla2x00_load_ram_ext(ha,
+				    ha->request_dma, risc_address, cnt);
+			}
+			if (rval) {
+				DEBUG(printk("scsi(%ld): [ERROR] Failed to "
+				    "load segment %d of firmware\n",
+				    ha->host_no, num));
+				qla_printk(KERN_WARNING, ha,
+				    "[ERROR] Failed to load "
+				    "segment %d of firmware\n", num);
+
+				qla2x00_dump_regs(ha);
+				break;
+			}
+
+			risc_code += cnt;
+			risc_address += cnt;
+			risc_code_size -= cnt;
+			num++;
+		}
+
+		/* Next firmware sequence */
+		fw_iter++;
+	}
+
+	/* Verify checksum of loaded RISC code. */
+	if (!rval) {
+		DEBUG(printk("scsi(%ld): Verifying Checksum of loaded RISC "
+		    "code.\n", ha->host_no));
+
+		rval = qla2x00_verify_checksum(ha);
+		if (rval == QLA_SUCCESS) {
+			/* Start firmware execution. */
+			DEBUG(printk("scsi(%ld): Checksum OK, start "
+			    "firmware.\n", ha->host_no));
+
+			rval = qla2x00_execute_fw(ha);
+		}
+		else {
+			DEBUG2(printk(KERN_INFO
+			    "scsi(%ld): ISP Firmware failed checksum.\n",
+			    ha->host_no));
+		}
+	}
+
+	if (rval) {
+		DEBUG2_3(printk("scsi(%ld): Setup chip **** FAILED ****.\n",
+		    ha->host_no));
+	}
+
+	return (rval);
+}
+
+/**
+ * qla2x00_init_response_q_entries() - Initializes response queue entries.
+ * @ha: HA context
+ *
+ * Beginning of request ring has initialization control block already built
+ * by nvram config routine.
+ *
+ * Returns 0 on success.
+ */
+static void
+qla2x00_init_response_q_entries(scsi_qla_host_t *ha)
+{
+	uint16_t cnt;
+	response_t *pkt;
+
+	pkt = ha->response_ring_ptr;
+	for (cnt = 0; cnt < ha->response_q_length; cnt++) {
+		pkt->signature = RESPONSE_PROCESSED;
+		pkt++;
+	}
+
+}
+
+/**
+ * qla2x00_init_rings() - Initializes firmware.
+ * @ha: HA context
+ *
+ * Beginning of request ring has initialization control block already built
+ * by nvram config routine.
+ *
+ * Returns 0 on success.
+ */
+static int
+qla2x00_init_rings(scsi_qla_host_t *ha)
+{
+	int	rval;
+	unsigned long flags = 0;
+	int cnt;
+	device_reg_t *reg = ha->iobase;
+
+	spin_lock_irqsave(&ha->hardware_lock, flags);
+
+	/* Clear outstanding commands array. */
+	for (cnt = 0; cnt < MAX_OUTSTANDING_COMMANDS; cnt++)
+		ha->outstanding_cmds[cnt] = 0;
+
+	ha->current_outstanding_cmd = 0;
+
+	/* Clear RSCN queue. */
+	ha->rscn_in_ptr = 0;
+	ha->rscn_out_ptr = 0;
+
+	/* Initialize firmware. */
+	ha->request_ring_ptr  = ha->request_ring;
+	ha->req_ring_index    = 0;
+	ha->req_q_cnt         = REQUEST_ENTRY_CNT;
+	ha->response_ring_ptr = ha->response_ring;
+	ha->rsp_ring_index    = 0;
+
+	/* Initialize response queue entries */
+	qla2x00_init_response_q_entries(ha);
+
+ 	WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), 0);
+ 	WRT_REG_WORD(ISP_REQ_Q_OUT(ha, reg), 0);
+ 	WRT_REG_WORD(ISP_RSP_Q_IN(ha, reg), 0);
+ 	WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), 0);
+	RD_REG_WORD(ISP_RSP_Q_OUT(ha, reg));
+
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+	DEBUG(printk("scsi(%ld): Issue init firmware.\n", ha->host_no));
+	rval = qla2x00_init_firmware(ha, sizeof(init_cb_t));
+	if (rval) {
+		DEBUG2_3(printk("scsi(%ld): Init firmware **** FAILED ****.\n",
+		    ha->host_no));
+	} else {
+		/* Setup seriallink options */
+		uint16_t swing, emphasis;
+
+		DEBUG3(printk("scsi(%ld): Serial link options:\n",
+		    ha->host_no));
+		DEBUG3(qla2x00_dump_buffer(
+		    (uint8_t *)&ha->fw_seriallink_options,
+		    sizeof(ha->fw_seriallink_options)));
+
+		memset(ha->fw_options, 0, sizeof(ha->fw_options));
+		qla2x00_get_fw_options(ha, ha->fw_options);
+
+		ha->fw_options[1] &= ~FO1_SET_EMPHASIS_SWING;
+		if (ha->fw_seriallink_options[1] & BIT_2)
+			ha->fw_options[1] |= FO1_SET_EMPHASIS_SWING;
+
+		/* 1G settings */
+		swing = ha->fw_seriallink_options[0] & (BIT_2 | BIT_1 | BIT_0);
+		emphasis = ha->fw_seriallink_options[0] & (BIT_4 | BIT_3);
+		emphasis >>= 3;
+		ha->fw_options[10] = (emphasis << 14) | (swing << 8) | 0x3;
+
+		/* 2G settings */
+		swing = ha->fw_seriallink_options[0] & (BIT_7 | BIT_6 | BIT_5);
+		swing >>= 5;
+		emphasis = ha->fw_seriallink_options[1] & (BIT_1 | BIT_0);
+		ha->fw_options[11] = (emphasis << 14) | (swing << 8) | 0x3;
+
+		qla2x00_set_fw_options(ha, ha->fw_options);
+
+		DEBUG3(printk("scsi(%ld): Init firmware -- success.\n",
+		    ha->host_no));
+	}
+
+	return (rval);
+}
+
+/**
+ * qla2x00_fw_ready() - Waits for firmware ready.
+ * @ha: HA context
+ *
+ * Returns 0 on success.
+ */
+static int
+qla2x00_fw_ready(scsi_qla_host_t *ha)
+{
+	int		rval;
+	unsigned long	wtime, mtime;
+	uint16_t	min_wait;	/* Minimum wait time if loop is down */
+	uint16_t	wait_time;	/* Wait time if loop is coming ready */
+	uint16_t	fw_state;
+
+	rval = QLA_SUCCESS;
+
+	/* 20 seconds for loop down. */
+	min_wait = 20;		
+
+	/*
+	 * Firmware should take at most one RATOV to login, plus 5 seconds for
+	 * our own processing.
+	 */
+	if ((wait_time = (ha->retry_count*ha->login_timeout) + 5) < min_wait) {
+		wait_time = min_wait;
+	}
+
+	/* Min wait time if loop down */
+	mtime = jiffies + (min_wait * HZ);
+
+	/* wait time before firmware ready */
+	wtime = jiffies + (wait_time * HZ);
+
+	/* Wait for ISP to finish LIP */
+	if (!ha->flags.init_done)
+ 		qla_printk(KERN_INFO, ha, "Waiting for LIP to complete...\n");
+
+	DEBUG3(printk("scsi(%ld): Waiting for LIP to complete...\n",
+	    ha->host_no));
+
+	do {
+		rval = qla2x00_get_firmware_state(ha, &fw_state);
+		if (rval == QLA_SUCCESS) {
+			if (fw_state < FSTATE_LOSS_OF_SYNC) {
+				ha->device_flags &= ~DFLG_NO_CABLE;
+			}
+			if (fw_state == FSTATE_READY) {
+				DEBUG(printk("scsi(%ld): F/W Ready - OK \n",
+				    ha->host_no));
+
+				qla2x00_get_retry_cnt(ha, &ha->retry_count,
+				    &ha->login_timeout, &ha->r_a_tov);
+
+				rval = QLA_SUCCESS;
+				break;
+			}
+
+			rval = QLA_FUNCTION_FAILED;
+
+			if (atomic_read(&ha->loop_down_timer) &&
+			    fw_state >= FSTATE_LOSS_OF_SYNC) {
+				/* Loop down. Timeout on min_wait for states
+				 * other than Wait for Login. 
+				 */	
+				if (time_after_eq(jiffies, mtime)) {
+					qla_printk(KERN_INFO, ha,
+					    "Cable is unplugged...\n");
+
+					ha->device_flags |= DFLG_NO_CABLE;
+					break;
+				}
+			}
+		} else {
+			/* Mailbox cmd failed. Timeout on min_wait. */
+			if (time_after_eq(jiffies, mtime))
+				break;
+		}
+
+		if (time_after_eq(jiffies, wtime))
+			break;
+
+		/* Delay for a while */
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(HZ / 2);
+
+		DEBUG3(printk("scsi(%ld): fw_state=%x curr time=%lx.\n",
+		    ha->host_no, fw_state, jiffies));
+	} while (1);
+
+	DEBUG(printk("scsi(%ld): fw_state=%x curr time=%lx.\n",
+	    ha->host_no, fw_state, jiffies));
+
+	if (rval) {
+		DEBUG2_3(printk("scsi(%ld): Firmware ready **** FAILED ****.\n",
+		    ha->host_no));
+	}
+
+	return (rval);
+}
+
+/*
+*  qla2x00_configure_hba
+*      Setup adapter context.
+*
+* Input:
+*      ha = adapter state pointer.
+*
+* Returns:
+*      0 = success
+*
+* Context:
+*      Kernel context.
+*/
+static int
+qla2x00_configure_hba(scsi_qla_host_t *ha)
+{
+	int       rval;
+	uint16_t      loop_id;
+	uint16_t      topo;
+	uint8_t       al_pa;
+	uint8_t       area;
+	uint8_t       domain;
+	char		connect_type[22];
+
+	/* Get host addresses. */
+	rval = qla2x00_get_adapter_id(ha,
+	    &loop_id, &al_pa, &area, &domain, &topo);
+	if (rval != QLA_SUCCESS) {
+		qla_printk(KERN_WARNING, ha,
+		    "ERROR -- Unable to get host loop ID.\n");
+		return (rval);
+	}
+
+	if (topo == 4) {
+		qla_printk(KERN_INFO, ha,
+			"Cannot get topology - retrying.\n");
+		return (QLA_FUNCTION_FAILED);
+	}
+
+	ha->loop_id = loop_id;
+
+	/* Make sure 2100 only has loop, in case of any firmware bug. */
+	if (IS_QLA2100(ha))
+		topo = 0;
+
+	/* initialize */
+	ha->min_external_loopid = SNS_FIRST_LOOP_ID;
+	ha->operating_mode = LOOP;
+
+	switch (topo) {
+	case 0:
+		DEBUG3(printk("scsi(%ld): HBA in NL topology.\n",
+		    ha->host_no));
+		ha->current_topology = ISP_CFG_NL;
+		strcpy(connect_type, "(Loop)");
+		break;
+
+	case 1:
+		DEBUG3(printk("scsi(%ld): HBA in FL topology.\n",
+		    ha->host_no));
+		ha->current_topology = ISP_CFG_FL;
+		strcpy(connect_type, "(FL_Port)");
+		break;
+
+	case 2:
+		DEBUG3(printk("scsi(%ld): HBA in N P2P topology.\n",
+		    ha->host_no));
+		ha->operating_mode = P2P;
+		ha->current_topology = ISP_CFG_N;
+		strcpy(connect_type, "(N_Port-to-N_Port)");
+		break;
+
+	case 3:
+		DEBUG3(printk("scsi(%ld): HBA in F P2P topology.\n",
+		    ha->host_no));
+		ha->operating_mode = P2P;
+		ha->current_topology = ISP_CFG_F;
+		strcpy(connect_type, "(F_Port)");
+		break;
+
+	default:
+		DEBUG3(printk("scsi(%ld): HBA in unknown topology %x. "
+		    "Using NL.\n",
+		    ha->host_no, topo));
+		ha->current_topology = ISP_CFG_NL;
+		strcpy(connect_type, "(Loop)");
+		break;
+	}
+
+	/* Save Host port and loop ID. */
+	/* byte order - Big Endian */
+	ha->d_id.b.domain = domain;
+	ha->d_id.b.area = area;
+	ha->d_id.b.al_pa = al_pa;
+
+	if (!ha->flags.init_done)
+ 		qla_printk(KERN_INFO, ha,
+		    "Topology - %s, Host Loop address 0x%x\n",
+ 		    connect_type, ha->loop_id);
+
+	if (rval) {
+		DEBUG2_3(printk("scsi(%ld): FAILED.\n", ha->host_no));
+	} else {
+		DEBUG3(printk("scsi(%ld): exiting normally.\n", ha->host_no));
+	}
+
+	return(rval);
+}
+
+/*
+* NVRAM configuration for ISP 2xxx
+*
+* Input:
+*      ha                = adapter block pointer.
+*
+* Output:
+*      initialization control block in response_ring
+*      host adapters parameters in host adapter block
+*
+* Returns:
+*      0 = success.
+*/
+static int
+qla2x00_nvram_config(scsi_qla_host_t *ha)
+{
+	int   rval;
+	uint8_t   chksum = 0;
+	uint16_t  cnt;
+	uint8_t   *dptr1, *dptr2;
+	init_cb_t *icb   = ha->init_cb;
+	nvram_t *nv    = (nvram_t *)ha->request_ring;
+	uint16_t  *wptr  = (uint16_t *)ha->request_ring;
+	device_reg_t *reg = ha->iobase;
+	uint16_t  timer_mode;
+
+	rval = QLA_SUCCESS;
+
+	if (ha->flags.init_done)
+		return (rval);
+
+	/* Determine NVRAM starting address. */
+	ha->nvram_base = 0;
+	if (IS_QLA2312(ha) || IS_QLA2322(ha))
+		if ((RD_REG_WORD(&reg->ctrl_status) >> 14) == 1)
+			ha->nvram_base = 0x80;
+
+	/* Get NVRAM data and calculate checksum. */
+	qla2x00_lock_nvram_access(ha);
+	for (cnt = 0; cnt < sizeof(nvram_t)/2; cnt++) {
+		*wptr = cpu_to_le16(qla2x00_get_nvram_word(ha,
+		    (cnt+ha->nvram_base)));
+		chksum += (uint8_t)*wptr;
+		chksum += (uint8_t)(*wptr >> 8);
+		wptr++;
+	}
+	qla2x00_unlock_nvram_access(ha);
+
+	DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", ha->host_no));
+	DEBUG5(qla2x00_dump_buffer((uint8_t *)ha->request_ring,
+	    sizeof(nvram_t)));
+
+	/* Bad NVRAM data, set defaults parameters. */
+	if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' ||
+	    nv->id[2] != 'P' || nv->id[3] != ' ' || nv->nvram_version < 1) {
+		/* Reset NVRAM data. */
+		qla_printk(KERN_WARNING, ha, "Inconsistent NVRAM detected: "
+		    "checksum=0x%x id=%c version=0x%x.\n", chksum, nv->id[0],
+		    nv->nvram_version);
+		qla_printk(KERN_WARNING, ha, "Falling back to functioning (yet "
+		    "invalid -- WWPN) defaults.\n");
+
+		/*
+		 * Set default initialization control block.
+		 */
+		memset(nv, 0, sizeof(nvram_t));
+		nv->parameter_block_version = ICB_VERSION;
+
+		if (IS_QLA23XX(ha)) {
+			nv->firmware_options[0] = BIT_2 | BIT_1;
+			nv->firmware_options[1] = BIT_7 | BIT_5;
+			nv->add_firmware_options[0] = BIT_5;
+			nv->add_firmware_options[1] = BIT_5 | BIT_4;
+			nv->frame_payload_size = __constant_cpu_to_le16(2048);
+			nv->special_options[1] = BIT_7;
+		} else if (IS_QLA2200(ha)) {
+			nv->firmware_options[0] = BIT_2 | BIT_1;
+			nv->firmware_options[1] = BIT_7 | BIT_5;
+			nv->add_firmware_options[0] = BIT_5 | BIT_4;
+			nv->add_firmware_options[1] = BIT_5 | BIT_4;
+			nv->frame_payload_size = __constant_cpu_to_le16(1024);
+		} else if (IS_QLA2100(ha)) {
+			nv->firmware_options[0] = BIT_3 | BIT_1;
+			nv->firmware_options[1] = BIT_5;
+			nv->frame_payload_size = __constant_cpu_to_le16(1024);
+		}
+
+		nv->max_iocb_allocation = __constant_cpu_to_le16(256);
+		nv->execution_throttle = __constant_cpu_to_le16(16);
+		nv->retry_count = 8;
+		nv->retry_delay = 1;
+
+		nv->port_name[0] = 33;
+		nv->port_name[3] = 224;
+		nv->port_name[4] = 139;
+
+		nv->login_timeout = 4;
+
+		/*
+		 * Set default host adapter parameters
+		 */
+		nv->host_p[1] = BIT_2;
+		nv->reset_delay = 5;
+		nv->port_down_retry_count = 8;
+		nv->max_luns_per_target = __constant_cpu_to_le16(8);
+		nv->link_down_timeout = 60;
+
+		rval = 1;
+	}
+
+#if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2)
+	/*
+	 * The SN2 does not provide BIOS emulation which means you can't change
+	 * potentially bogus BIOS settings. Force the use of default settings
+	 * for link rate and frame size.  Hope that the rest of the settings
+	 * are valid.
+	 */
+	if (ia64_platform_is("sn2")) {
+		nv->frame_payload_size = __constant_cpu_to_le16(2048);
+		if (IS_QLA23XX(ha))
+			nv->special_options[1] = BIT_7;
+	}
+#endif
+
+	/* Reset Initialization control block */
+	memset(icb, 0, sizeof(init_cb_t));
+
+	/*
+	 * Setup driver NVRAM options.
+	 */
+	nv->firmware_options[0] |= (BIT_6 | BIT_1);
+	nv->firmware_options[0] &= ~(BIT_5 | BIT_4);
+	nv->firmware_options[1] |= (BIT_5 | BIT_0);
+	nv->firmware_options[1] &= ~BIT_4;
+
+	if (IS_QLA23XX(ha)) {
+		nv->firmware_options[0] |= BIT_2;
+		nv->firmware_options[0] &= ~BIT_3;
+
+		if (IS_QLA2300(ha)) {
+			if (ha->fb_rev == FPM_2310) {
+				strcpy(ha->model_number, "QLA2310");
+			} else {
+				strcpy(ha->model_number, "QLA2300");
+			}
+		} else if (IS_QLA2312(ha) || IS_QLA2322(ha)) {
+			if (rval == 0 &&
+			    memcmp(nv->model_number, BINZERO,
+				    sizeof(nv->model_number)) != 0) {
+				char *st, *en;
+
+				strncpy(ha->model_number, nv->model_number,
+				    sizeof(nv->model_number));
+				st = en = ha->model_number;
+				en += sizeof(nv->model_number) - 1;
+				while (en > st) {
+					if (*en != 0x20)
+						break;
+					*en-- = '\0';
+				}
+			} else {
+				uint16_t        index;
+
+				index = (ha->pdev->subsystem_device & 0xff);
+				if (index < QLA_MODEL_NAMES) {
+					strcpy(ha->model_number,
+					    qla2x00_model_name[index]);
+					ha->model_desc =
+					    qla2x00_model_desc[index];
+				} else {
+					strcpy(ha->model_number, "QLA23xx");
+				}
+			}
+		} else {
+			strcpy(ha->model_number, "QLA23xx");
+		}
+	} else if (IS_QLA2200(ha)) {
+		nv->firmware_options[0] |= BIT_2;
+		strcpy(ha->model_number, "QLA22xx");
+	} else /*if (IS_QLA2100(ha))*/ {
+		strcpy(ha->model_number, "QLA2100");
+	}
+
+	/*
+	 * Copy over NVRAM RISC parameter block to initialization control block.
+	 */
+	dptr1 = (uint8_t *)icb;
+	dptr2 = (uint8_t *)&nv->parameter_block_version;
+	cnt = (uint8_t *)&icb->request_q_outpointer - (uint8_t *)&icb->version;
+	while (cnt--)
+		*dptr1++ = *dptr2++;
+
+	/* Copy 2nd half. */
+	dptr1 = (uint8_t *)icb->add_firmware_options;
+	cnt = (uint8_t *)icb->reserved_3 - (uint8_t *)icb->add_firmware_options;
+	while (cnt--)
+		*dptr1++ = *dptr2++;
+
+	/* Prepare nodename */
+	if ((icb->firmware_options[1] & BIT_6) == 0) {
+		/*
+		 * Firmware will apply the following mask if the nodename was
+		 * not provided.
+		 */
+		memcpy(icb->node_name, icb->port_name, WWN_SIZE);
+		icb->node_name[0] &= 0xF0;
+	}
+
+	/*
+	 * Set host adapter parameters.
+	 */
+	ha->nvram_version = nv->nvram_version;
+
+	ha->flags.disable_risc_code_load = ((nv->host_p[0] & BIT_4) ? 1 : 0);
+	ha->flags.enable_lip_reset = ((nv->host_p[1] & BIT_1) ? 1 : 0);
+	ha->flags.enable_lip_full_login = ((nv->host_p[1] & BIT_2) ? 1 : 0);
+	ha->flags.enable_target_reset = ((nv->host_p[1] & BIT_3) ? 1 : 0);
+
+	ha->operating_mode =
+	    (icb->add_firmware_options[0] & (BIT_6 | BIT_5 | BIT_4)) >> 4;
+
+	ha->fw_seriallink_options[0] = nv->seriallink_options[0];
+	ha->fw_seriallink_options[1] = nv->seriallink_options[1];
+
+	/* save HBA serial number */
+	ha->serial0 = icb->port_name[5];
+	ha->serial1 = icb->port_name[6];
+	ha->serial2 = icb->port_name[7];
+	memcpy(ha->node_name, icb->node_name, WWN_SIZE);
+
+	icb->execution_throttle = __constant_cpu_to_le16(0xFFFF);
+
+	ha->retry_count = nv->retry_count;
+
+	/* Set minimum login_timeout to 4 seconds. */
+	if (nv->login_timeout < ql2xlogintimeout)
+		nv->login_timeout = ql2xlogintimeout;
+	if (nv->login_timeout < 4)
+		nv->login_timeout = 4;
+	ha->login_timeout = nv->login_timeout;
+	icb->login_timeout = nv->login_timeout;
+
+	/* Set minimum RATOV to 200 tenths of a second. */
+	ha->r_a_tov = 200;
+
+/* FIXME
+ *
+ * port_down_retry_count updated twice
+ *
+ */
+	ha->port_down_retry_count = nv->port_down_retry_count;
+	ha->minimum_timeout =
+	    (ha->login_timeout * ha->retry_count) + ha->port_down_retry_count;
+	ha->loop_reset_delay = nv->reset_delay;
+
+	/* Will get the value from NVRAM. */
+	ha->loop_down_timeout = LOOP_DOWN_TIMEOUT;
+
+	/* Link Down Timeout = 0:
+	 *
+	 * 	When Port Down timer expires we will start returning
+	 *	I/O's to OS with "DID_NO_CONNECT".
+	 *
+	 * Link Down Timeout != 0:
+	 *
+	 *	 The driver waits for the link to come up after link down
+	 *	 before returning I/Os to OS with "DID_NO_CONNECT".
+	 */						
+	if (nv->link_down_timeout == 0) {
+		ha->loop_down_abort_time =
+		    (LOOP_DOWN_TIME - ha->loop_down_timeout);
+	} else {
+		ha->link_down_timeout =	 nv->link_down_timeout;
+		ha->loop_down_abort_time =
+		    (LOOP_DOWN_TIME - ha->link_down_timeout);
+	} 
+
+	ha->max_probe_luns = le16_to_cpu(nv->max_luns_per_target);
+	if (ha->max_probe_luns == 0)
+		ha->max_probe_luns = MIN_LUNS;
+
+#if USE_BIOS_MAX_LUNS
+	ha->max_luns = le16_to_cpu(nv->max_luns_per_target);
+	if (ha->max_luns == 0)
+		ha->max_luns = MAX_LUNS;
+	else if (ha->max_luns > MAX_LUNS)
+		ha->max_luns = MAX_LUNS;
+#else
+	ha->max_luns = MAX_LUNS;
+#endif
+
+/* FIXME
+ *
+ * port_down_retry_count updated twice
+ *
+ */
+	/*
+	 * Need enough time to try and get the port back.
+	 */
+	if (qlport_down_retry)
+		ha->port_down_retry_count = qlport_down_retry;
+	/* Set login_retry_count */
+	ha->login_retry_count  = nv->retry_count;
+	if (ha->port_down_retry_count == nv->port_down_retry_count &&
+	    ha->port_down_retry_count > 3)
+		ha->login_retry_count = ha->port_down_retry_count;
+	else if (ha->port_down_retry_count > (int)ha->login_retry_count)
+		ha->login_retry_count = ha->port_down_retry_count;
+
+	ha->binding_type = Bind;
+	if (ha->binding_type != BIND_BY_PORT_NAME &&
+	    ha->binding_type != BIND_BY_PORT_ID) {
+		qla_printk(KERN_WARNING, ha,
+		    "Invalid binding type specified (%d), "
+		    "defaulting to BIND_BY_PORT_NAME!!!\n", ha->binding_type);
+
+		ha->binding_type = BIND_BY_PORT_NAME;
+	}
+
+	/*
+	 * Setup ring parameters in initialization control block
+	 */
+	icb->request_q_outpointer = __constant_cpu_to_le16(0);
+	icb->response_q_inpointer = __constant_cpu_to_le16(0);
+	icb->request_q_length = __constant_cpu_to_le16(REQUEST_ENTRY_CNT);
+	icb->response_q_length = cpu_to_le16(ha->response_q_length);
+	icb->request_q_address[0] = cpu_to_le32(LSD(ha->request_dma));
+	icb->request_q_address[1] = cpu_to_le32(MSD(ha->request_dma));
+	icb->response_q_address[0] = cpu_to_le32(LSD(ha->response_dma));
+	icb->response_q_address[1] = cpu_to_le32(MSD(ha->response_dma));
+
+	icb->lun_enables = __constant_cpu_to_le16(0);
+	icb->command_resource_count = 0;
+	icb->immediate_notify_resource_count = 0;
+	icb->timeout = __constant_cpu_to_le16(0);
+
+	if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
+		/* Enable RIO */
+		icb->firmware_options[0] &= ~BIT_3;
+		icb->add_firmware_options[0] &=
+		    ~(BIT_3 | BIT_2 | BIT_1 | BIT_0);
+		icb->add_firmware_options[0] |= (BIT_1 | BIT_0);
+		icb->response_accumulation_timer = 3;
+		icb->interrupt_delay_timer = 5;
+
+		ha->flags.process_response_queue = 1;
+	} else {
+		/* TEST ZIO:
+		 *
+		 * icb->add_firmware_options[0] &=
+		 *    ~(BIT_3 | BIT_2 | BIT_1 | BIT_0);
+		 * icb->add_firmware_options[0] |= (BIT_2 | BIT_0);
+		 */
+		timer_mode  = icb->add_firmware_options[0] &
+		    (BIT_3 | BIT_2 | BIT_1 | BIT_0);
+		if (timer_mode == 5) {
+			DEBUG2(printk("scsi(%ld): ZIO enabled; timer delay "
+			    "(%d).\n", ha->host_no, ql2xintrdelaytimer));
+			qla_printk(KERN_INFO, ha,
+			    "ZIO enabled; timer delay (%d).\n",
+			    ql2xintrdelaytimer);
+
+			icb->interrupt_delay_timer = ql2xintrdelaytimer;
+	
+			ha->flags.process_response_queue = 1;
+		}
+	}
+
+	if (rval) {
+		DEBUG2_3(printk(KERN_WARNING
+		    "scsi(%ld): NVRAM configuration failed!\n", ha->host_no));
+	}
+
+	LEAVE(__func__);
+
+	return (rval);
+}
+
+/*
+* qla2x00_init_tgt_map
+*      Initializes target map.
+*
+* Input:
+*      ha = adapter block pointer.
+*
+* Output:
+*      TGT_Q initialized
+*/
+static void
+qla2x00_init_tgt_map(scsi_qla_host_t *ha)
+{
+	uint32_t t;
+
+	ENTER(__func__);
+
+	for (t = 0; t < MAX_TARGETS; t++)
+		TGT_Q(ha, t) = (os_tgt_t *)NULL;
+
+	LEAVE(__func__);
+}
+
+/**
+ * qla2x00_alloc_fcport() - Allocate a generic fcport.
+ * @ha: HA context
+ * @flags: allocation flags
+ *
+ * Returns a pointer to the allocated fcport, or NULL, if none available.
+ */
+fc_port_t *
+qla2x00_alloc_fcport(scsi_qla_host_t *ha, int flags)
+{
+	fc_port_t *fcport;
+
+	fcport = kmalloc(sizeof(fc_port_t), flags);
+	if (fcport == NULL)
+		return (fcport);
+
+	/* Setup fcport template structure. */
+	memset(fcport, 0, sizeof (fc_port_t));
+	fcport->ha = ha;
+	fcport->port_type = FCT_UNKNOWN;
+	fcport->loop_id = FC_NO_LOOP_ID;
+	fcport->iodesc_idx_sent = IODESC_INVALID_INDEX;
+	atomic_set(&fcport->state, FCS_UNCONFIGURED);
+	fcport->flags = FCF_RLC_SUPPORT;
+	INIT_LIST_HEAD(&fcport->fcluns);
+
+	return (fcport);
+}
+
+/*
+ * qla2x00_configure_loop
+ *      Updates Fibre Channel Device Database with what is actually on loop.
+ *
+ * Input:
+ *      ha                = adapter block pointer.
+ *
+ * Returns:
+ *      0 = success.
+ *      1 = error.
+ *      2 = database was full and device was not configured.
+ */
+static int
+qla2x00_configure_loop(scsi_qla_host_t *ha) 
+{
+	int  rval;
+	uint8_t  rval1 = 0;
+	static unsigned long  flags, save_flags;
+
+	rval = QLA_SUCCESS;
+
+	/* Get Initiator ID */
+	if (qla2x00_configure_hba(ha)) {
+		DEBUG(printk("scsi(%ld): Unable to configure HBA.\n",
+		    ha->host_no));
+		return (QLA_FUNCTION_FAILED);
+	}
+
+	save_flags = flags = ha->dpc_flags;
+	DEBUG(printk("scsi(%ld): Configure loop -- dpc flags =0x%lx\n",
+	    ha->host_no, flags));
+
+	/* dg 02/26/02 ha->dpc_flags &= ~(LOCAL_LOOP_UPDATE | RSCN_UPDATE); */
+
+	/*
+	 * If we have both an RSCN and PORT UPDATE pending then handle them
+	 * both at the same time.
+	 */
+	clear_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags);
+	clear_bit(RSCN_UPDATE, &ha->dpc_flags);
+	ha->mem_err = 0 ;
+
+	/* Determine what we need to do */
+	if (ha->current_topology == ISP_CFG_FL &&
+	    (test_bit(LOCAL_LOOP_UPDATE, &flags))) {
+
+		ha->flags.rscn_queue_overflow = TRUE;
+		set_bit(RSCN_UPDATE, &flags);
+
+	} else if (ha->current_topology == ISP_CFG_F &&
+	    (test_bit(LOCAL_LOOP_UPDATE, &flags))) {
+
+		ha->flags.rscn_queue_overflow = TRUE;
+		set_bit(RSCN_UPDATE, &flags);
+		clear_bit(LOCAL_LOOP_UPDATE, &flags);
+
+	} else if (!ha->flags.online ||
+	    (test_bit(ABORT_ISP_ACTIVE, &flags))) {
+
+		ha->flags.rscn_queue_overflow = TRUE;
+		set_bit(RSCN_UPDATE, &flags);
+		set_bit(LOCAL_LOOP_UPDATE, &flags);
+	}
+
+	do {
+		if (test_bit(LOCAL_LOOP_UPDATE, &flags)) {
+			rval = rval | qla2x00_configure_local_loop(ha);
+		}
+
+		if (test_bit(RSCN_UPDATE, &flags)) {
+			rval1 = qla2x00_configure_fabric(ha);
+			if ((rval1 & BIT_0) && ha->sns_retry_cnt < 8) {
+				ha->sns_retry_cnt++;
+				set_bit(LOGIN_RETRY_NEEDED, &ha->dpc_flags);
+			}
+		}
+
+		/* Isolate error status. */
+		if (rval & BIT_0) {
+			rval = 1;
+		} else {
+			rval = QLA_SUCCESS;
+		}
+
+	} while (rval != QLA_SUCCESS);
+
+	if (!atomic_read(&ha->loop_down_timer) &&
+	    !(test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))) {
+
+		qla2x00_config_os(ha);
+
+		/* If we found all devices then go ready */
+		if (!(test_bit(LOGIN_RETRY_NEEDED, &ha->dpc_flags))) {
+			atomic_set(&ha->loop_state, LOOP_READY);
+
+			DEBUG(printk("scsi(%ld): LOOP READY\n", ha->host_no));
+		} else {
+			if (test_bit(LOCAL_LOOP_UPDATE, &save_flags))
+				set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags);
+			if (test_bit(RSCN_UPDATE, &save_flags))
+				set_bit(RSCN_UPDATE, &ha->dpc_flags);
+		}
+	} else {
+		DEBUG(printk("scsi(%ld): Loop down counter running= %d or "
+		    "Resync needed- dpc flags= %ld\n",
+		    ha->host_no,
+		    atomic_read(&ha->loop_down_timer), ha->dpc_flags));
+		/* ???? dg 02/26/02  rval = 1; */
+	}
+
+	if (rval) {
+		DEBUG2_3(printk("%s(%ld): *** FAILED ***\n",
+		    __func__, ha->host_no));
+	} else {
+		DEBUG3(printk("%s: exiting normally\n", __func__));
+	}
+
+	return (rval);
+}
+
+
+
+/*
+ * qla2x00_configure_local_loop
+ *	Updates Fibre Channel Device Database with local loop devices.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *
+ * Returns:
+ *	0 = success.
+ *	BIT_0 = error.
+ */
+static int
+qla2x00_configure_local_loop(scsi_qla_host_t *ha) 
+{
+	int		rval, rval2;
+	int		found_devs;
+	int		found;
+	fc_port_t	*fcport, *new_fcport;
+
+	uint16_t	index;
+	uint16_t	entries;
+	struct dev_id {
+		uint8_t	al_pa;
+		uint8_t	area;
+		uint8_t	domain;		
+		uint8_t	loop_id_2100;	/* ISP2100/ISP2200 -- 4 bytes. */
+		uint16_t loop_id;	/* ISP23XX         -- 6 bytes. */
+	} *id_list;
+#define MAX_ID_LIST_SIZE (sizeof(struct dev_id) * MAX_FIBRE_DEVICES)
+	dma_addr_t	id_list_dma;
+	char		*id_iter;
+	uint16_t	loop_id;
+	uint8_t		domain, area, al_pa;
+
+	rval = QLA_SUCCESS;
+	found_devs = 0;
+	new_fcport = NULL;
+
+	/*
+	 * No point in continuing if the loop is in a volatile state -- 
+	 * reschedule LOCAL_LOOP_UPDATE for later processing
+	 */
+	if (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) {
+		set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags);
+		return (rval);
+	}
+
+	entries = MAX_FIBRE_DEVICES;
+	id_list = pci_alloc_consistent(ha->pdev, MAX_ID_LIST_SIZE,
+	    &id_list_dma);
+	if (id_list == NULL) {
+		DEBUG2(printk("scsi(%ld): Failed to allocate memory, No local "
+		    "loop\n", ha->host_no));
+
+		qla_printk(KERN_WARNING, ha,
+		    "Memory Allocation failed - port_list");
+
+		ha->mem_err++;
+		return (BIT_0);
+	}
+	memset(id_list, 0, MAX_ID_LIST_SIZE);
+
+	DEBUG3(printk("scsi(%ld): Getting FCAL position map\n", ha->host_no));
+	DEBUG3(qla2x00_get_fcal_position_map(ha, NULL));
+
+	/* Get list of logged in devices. */
+	rval = qla2x00_get_id_list(ha, id_list, id_list_dma, &entries);
+	if (rval) {
+		rval = BIT_0;
+		goto cleanup_allocation;
+	}
+
+	DEBUG3(printk("scsi(%ld): Entries in ID list (%d)\n",
+	    ha->host_no, entries));
+	DEBUG3(qla2x00_dump_buffer((uint8_t *)id_list,
+	    entries * sizeof(struct dev_id)));
+
+	/* Allocate temporary fcport for any new fcports discovered. */
+	new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL);
+	if (new_fcport == NULL) {
+		rval = BIT_0;
+		goto cleanup_allocation;
+	}
+	new_fcport->flags &= ~FCF_FABRIC_DEVICE;
+
+	/*
+	 * Mark local devices that were present with FCF_DEVICE_LOST for now.
+	 */
+	list_for_each_entry(fcport, &ha->fcports, list) {
+		if (atomic_read(&fcport->state) == FCS_ONLINE &&
+		    fcport->port_type != FCT_BROADCAST &&
+		    (fcport->flags & FCF_FABRIC_DEVICE) == 0) {
+
+			DEBUG(printk("scsi(%ld): Marking port lost, "
+			    "loop_id=0x%04x\n",
+			    ha->host_no, fcport->loop_id));
+
+			atomic_set(&fcport->state, FCS_DEVICE_LOST);
+			fcport->flags &= ~FCF_FARP_DONE;
+		}
+	}
+
+	/* Add devices to port list. */
+	id_iter = (char *)id_list;
+	for (index = 0; index < entries; index++) {
+		domain = ((struct dev_id *)id_iter)->domain;
+		area = ((struct dev_id *)id_iter)->area;
+		al_pa = ((struct dev_id *)id_iter)->al_pa;
+		if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
+			loop_id =
+			    (uint16_t)((struct dev_id *)id_iter)->loop_id_2100;
+			id_iter += 4;
+		} else {
+			loop_id =
+			    le16_to_cpu(((struct dev_id *)id_iter)->loop_id);
+			id_iter += 6;
+		}
+
+		/* Bypass reserved domain fields. */
+		if ((domain & 0xf0) == 0xf0)
+			continue;
+
+		/* Bypass if not same domain and area of adapter. */
+		if (area != ha->d_id.b.area || domain != ha->d_id.b.domain)
+			continue;
+
+		/* Bypass invalid local loop ID. */
+		if (loop_id > LAST_LOCAL_LOOP_ID)
+			continue;
+
+		/* Fill in member data. */
+		new_fcport->d_id.b.domain = domain;
+		new_fcport->d_id.b.area = area;
+		new_fcport->d_id.b.al_pa = al_pa;
+		new_fcport->loop_id = loop_id;
+		rval2 = qla2x00_get_port_database(ha, new_fcport, 0);
+		if (rval2 != QLA_SUCCESS) {
+			DEBUG2(printk("scsi(%ld): Failed to retrieve fcport "
+			    "information -- get_port_database=%x, "
+			    "loop_id=0x%04x\n",
+			    ha->host_no, rval2, new_fcport->loop_id));
+			continue;
+		}
+
+		/* Check for matching device in port list. */
+		found = 0;
+		fcport = NULL;
+		list_for_each_entry(fcport, &ha->fcports, list) {
+			if (memcmp(new_fcport->port_name, fcport->port_name,
+			    WWN_SIZE))
+				continue;
+
+			fcport->flags &= ~(FCF_FABRIC_DEVICE |
+			    FCF_PERSISTENT_BOUND);
+			fcport->loop_id = new_fcport->loop_id;
+			fcport->port_type = new_fcport->port_type;
+			fcport->d_id.b24 = new_fcport->d_id.b24;
+			memcpy(fcport->node_name, new_fcport->node_name,
+			    WWN_SIZE);
+
+			found++;
+			break;
+		}
+
+		if (!found) {
+			/* New device, add to fcports list. */
+			new_fcport->flags &= ~FCF_PERSISTENT_BOUND;
+			list_add_tail(&new_fcport->list, &ha->fcports);
+
+			/* Allocate a new replacement fcport. */
+			fcport = new_fcport;
+			new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL);
+			if (new_fcport == NULL) {
+				rval = BIT_0;
+				goto cleanup_allocation;
+			}
+			new_fcport->flags &= ~FCF_FABRIC_DEVICE;
+		}
+
+		qla2x00_update_fcport(ha, fcport);
+
+		found_devs++;
+	}
+
+cleanup_allocation:
+	pci_free_consistent(ha->pdev, MAX_ID_LIST_SIZE, id_list, id_list_dma);
+
+	if (new_fcport)
+		kfree(new_fcport);
+
+	if (rval & BIT_0) {
+		DEBUG2(printk("scsi(%ld): Configure local loop error exit: "
+		    "rval=%x\n", ha->host_no, rval));
+	}
+
+	if (found_devs) {
+		ha->device_flags |= DFLG_LOCAL_DEVICES;
+		ha->device_flags &= ~DFLG_RETRY_LOCAL_DEVICES;
+	}
+
+	return (rval);
+}
+
+/*
+ * qla2x00_update_fcport
+ *	Updates device on list.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	fcport = port structure pointer.
+ *
+ * Return:
+ *	0  - Success
+ *  BIT_0 - error
+ *
+ * Context:
+ *	Kernel context.
+ */
+static void
+qla2x00_update_fcport(scsi_qla_host_t *ha, fc_port_t *fcport)
+{
+	uint16_t	index;
+	unsigned long flags;
+	srb_t *sp;
+
+	fcport->ha = ha;
+	fcport->login_retry = 0;
+	fcport->port_login_retry_count = ha->port_down_retry_count *
+	    PORT_RETRY_TIME;
+	atomic_set(&fcport->port_down_timer, ha->port_down_retry_count *
+	    PORT_RETRY_TIME);
+	fcport->flags &= ~(FCF_LOGIN_NEEDED);
+
+	/*
+	 * Check for outstanding cmd on tape Bypass LUN discovery if active
+	 * command on tape.
+	 */
+	if (fcport->flags & FCF_TAPE_PRESENT) {
+		spin_lock_irqsave(&ha->hardware_lock, flags);
+		for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) {
+			if ((sp = ha->outstanding_cmds[index]) != 0) {
+				if (sp->fclun->fcport == fcport) {
+					atomic_set(&fcport->state, FCS_ONLINE);
+					spin_unlock_irqrestore(
+					    &ha->hardware_lock, flags);
+					return;
+				}
+			}
+		}
+		spin_unlock_irqrestore(&ha->hardware_lock, flags);
+	}
+
+	/* Do LUN discovery. */
+	if (fcport->port_type == FCT_INITIATOR ||
+	    fcport->port_type == FCT_BROADCAST) {
+		fcport->device_type = TYPE_PROCESSOR;
+	} else {
+		qla2x00_lun_discovery(ha, fcport);
+	}
+	atomic_set(&fcport->state, FCS_ONLINE);
+}
+
+/*
+ * qla2x00_lun_discovery
+ *	Issue SCSI inquiry command for LUN discovery.
+ *
+ * Input:
+ *	ha:		adapter state pointer.
+ *	fcport:		FC port structure pointer.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static void
+qla2x00_lun_discovery(scsi_qla_host_t *ha, fc_port_t *fcport)
+{
+	inq_cmd_rsp_t	*inq;
+	dma_addr_t	inq_dma;
+	uint16_t	lun;
+
+	inq = pci_alloc_consistent(ha->pdev, sizeof(inq_cmd_rsp_t), &inq_dma);
+	if (inq == NULL) {
+		qla_printk(KERN_WARNING, ha,
+		    "Memory Allocation failed - INQ\n");
+		return;
+	}
+
+	/* If report LUN works, exit. */
+	if (qla2x00_rpt_lun_discovery(ha, fcport, inq, inq_dma) !=
+	    QLA_SUCCESS) {
+		for (lun = 0; lun < ha->max_probe_luns; lun++) {
+			/* Configure LUN. */
+			qla2x00_cfg_lun(ha, fcport, lun, inq, inq_dma);
+		}
+	}
+
+	pci_free_consistent(ha->pdev, sizeof(inq_cmd_rsp_t), inq, inq_dma);
+}
+
+/*
+ * qla2x00_rpt_lun_discovery
+ *	Issue SCSI report LUN command for LUN discovery.
+ *
+ * Input:
+ *	ha:		adapter state pointer.
+ *	fcport:		FC port structure pointer.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static int
+qla2x00_rpt_lun_discovery(scsi_qla_host_t *ha, fc_port_t *fcport,
+    inq_cmd_rsp_t *inq, dma_addr_t inq_dma)
+{
+	int			rval;
+	uint32_t		len, cnt;
+	uint16_t		lun;
+	rpt_lun_cmd_rsp_t	*rlc;
+	dma_addr_t		rlc_dma;
+
+	/* Assume a failed status */
+	rval = QLA_FUNCTION_FAILED;
+
+	/* No point in continuing if the device doesn't support RLC */
+	if ((fcport->flags & FCF_RLC_SUPPORT) == 0)
+		return (rval);
+
+	rlc = pci_alloc_consistent(ha->pdev, sizeof(rpt_lun_cmd_rsp_t),
+	    &rlc_dma);
+	if (rlc == NULL) {
+		qla_printk(KERN_WARNING, ha,
+			"Memory Allocation failed - RLC");
+		return QLA_MEMORY_ALLOC_FAILED;
+	}
+
+	rval = qla2x00_report_lun(ha, fcport, rlc, rlc_dma);
+	if (rval != QLA_SUCCESS) {
+		pci_free_consistent(ha->pdev, sizeof(rpt_lun_cmd_rsp_t), rlc,
+		    rlc_dma);
+		return (rval);
+	}
+
+	/* Always add a fc_lun_t structure for lun 0 -- mid-layer requirement */
+	qla2x00_add_lun(fcport, 0);
+
+	/* Configure LUN list. */
+	len = be32_to_cpu(rlc->list.hdr.len);
+	len /= 8;
+	for (cnt = 0; cnt < len; cnt++) {
+		lun = CHAR_TO_SHORT(rlc->list.lst[cnt].lsb,
+		    rlc->list.lst[cnt].msb.b);
+
+		DEBUG3(printk("scsi(%ld): RLC lun = (%d)\n", ha->host_no, lun));
+
+		/* We only support 0 through MAX_LUNS-1 range */
+		if (lun < MAX_LUNS) {
+			qla2x00_cfg_lun(ha, fcport, lun, inq, inq_dma);
+		}
+	}
+	atomic_set(&fcport->state, FCS_ONLINE);
+
+	pci_free_consistent(ha->pdev, sizeof(rpt_lun_cmd_rsp_t), rlc, rlc_dma);
+
+	return (rval);
+}
+
+/*
+ * qla2x00_report_lun
+ *	Issue SCSI report LUN command.
+ *
+ * Input:
+ *	ha:		adapter state pointer.
+ *	fcport:		FC port structure pointer.
+ *	mem:		pointer to dma memory object for report LUN IOCB
+ *			packet.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static int
+qla2x00_report_lun(scsi_qla_host_t *ha,
+    fc_port_t *fcport, rpt_lun_cmd_rsp_t *rlc, dma_addr_t rlc_dma)
+{
+	int rval;
+	uint16_t retries;
+	uint16_t comp_status;
+	uint16_t scsi_status;
+
+	rval = QLA_FUNCTION_FAILED;
+
+	for (retries = 3; retries; retries--) {
+		memset(rlc, 0, sizeof(rpt_lun_cmd_rsp_t));
+		rlc->p.cmd.entry_type = COMMAND_A64_TYPE;
+		rlc->p.cmd.entry_count = 1;
+		SET_TARGET_ID(ha, rlc->p.cmd.target, fcport->loop_id);
+		rlc->p.cmd.control_flags =
+		    __constant_cpu_to_le16(CF_READ | CF_SIMPLE_TAG);
+		rlc->p.cmd.scsi_cdb[0] = REPORT_LUNS;
+		rlc->p.cmd.scsi_cdb[8] = MSB(sizeof(rpt_lun_lst_t));
+		rlc->p.cmd.scsi_cdb[9] = LSB(sizeof(rpt_lun_lst_t));
+		rlc->p.cmd.dseg_count = __constant_cpu_to_le16(1);
+		rlc->p.cmd.timeout = __constant_cpu_to_le16(10);
+		rlc->p.cmd.byte_count =
+		    __constant_cpu_to_le32(sizeof(rpt_lun_lst_t));
+		rlc->p.cmd.dseg_0_address[0] = cpu_to_le32(
+		    LSD(rlc_dma + sizeof(sts_entry_t)));
+		rlc->p.cmd.dseg_0_address[1] = cpu_to_le32(
+		    MSD(rlc_dma + sizeof(sts_entry_t)));
+		rlc->p.cmd.dseg_0_length =
+		    __constant_cpu_to_le32(sizeof(rpt_lun_lst_t));
+
+		rval = qla2x00_issue_iocb(ha, rlc, rlc_dma,
+		    sizeof(rpt_lun_cmd_rsp_t));
+
+		comp_status = le16_to_cpu(rlc->p.rsp.comp_status);
+		scsi_status = le16_to_cpu(rlc->p.rsp.scsi_status);
+
+		if (rval != QLA_SUCCESS || comp_status != CS_COMPLETE ||
+		    scsi_status & SS_CHECK_CONDITION) {
+
+			/* Device underrun, treat as OK. */
+			if (rval == QLA_SUCCESS &&
+			    comp_status == CS_DATA_UNDERRUN &&
+			    scsi_status & SS_RESIDUAL_UNDER) {
+
+				rval = QLA_SUCCESS;
+				break;
+			}
+
+			DEBUG(printk("scsi(%ld): RLC failed to issue iocb! "
+			    "fcport=[%04x/%p] rval=%x cs=%x ss=%x\n",
+			    ha->host_no, fcport->loop_id, fcport, rval,
+			    comp_status, scsi_status));
+
+			rval = QLA_FUNCTION_FAILED;
+			if (scsi_status & SS_CHECK_CONDITION) {
+				DEBUG2(printk("scsi(%ld): RLC "
+				    "SS_CHECK_CONDITION Sense Data "
+				    "%02x %02x %02x %02x %02x %02x %02x %02x\n",
+				    ha->host_no,
+				    rlc->p.rsp.req_sense_data[0],
+				    rlc->p.rsp.req_sense_data[1],
+				    rlc->p.rsp.req_sense_data[2],
+				    rlc->p.rsp.req_sense_data[3],
+				    rlc->p.rsp.req_sense_data[4],
+				    rlc->p.rsp.req_sense_data[5],
+				    rlc->p.rsp.req_sense_data[6],
+				    rlc->p.rsp.req_sense_data[7]));
+				if (rlc->p.rsp.req_sense_data[2] ==
+				    ILLEGAL_REQUEST) {
+					fcport->flags &= ~(FCF_RLC_SUPPORT);
+					break;
+				}
+			}
+		} else {
+			break;
+		}
+	}
+
+	return (rval);
+}
+
+/*
+ * qla2x00_cfg_lun
+ *	Configures LUN into fcport LUN list.
+ *
+ * Input:
+ *	fcport:		FC port structure pointer.
+ *	lun:		LUN number.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static fc_lun_t *
+qla2x00_cfg_lun(scsi_qla_host_t *ha, fc_port_t *fcport, uint16_t lun,
+    inq_cmd_rsp_t *inq, dma_addr_t inq_dma) 
+{
+	fc_lun_t *fclun;
+
+	/* Bypass LUNs that failed. */
+	if (qla2x00_inquiry(ha, fcport, lun, inq, inq_dma) != QLA_SUCCESS) {
+		DEBUG2(printk("scsi(%ld): Failed inquiry - loop id=0x%04x "
+		    "lun=%d\n", ha->host_no, fcport->loop_id, lun));
+
+		return (NULL);
+	}
+
+	switch (inq->inq[0]) {
+	case TYPE_DISK:
+	case TYPE_PROCESSOR:
+	case TYPE_WORM:
+	case TYPE_ROM:
+	case TYPE_SCANNER:
+	case TYPE_MOD:
+	case TYPE_MEDIUM_CHANGER:
+	case TYPE_ENCLOSURE:
+	case 0x20:
+		break;
+	case TYPE_TAPE:
+		fcport->flags |= FCF_TAPE_PRESENT;
+		break;
+	default:
+		DEBUG2(printk("scsi(%ld): Unsupported lun type -- "
+		    "loop id=0x%04x lun=%d type=%x\n",
+		    ha->host_no, fcport->loop_id, lun, inq->inq[0]));
+		return (NULL);
+	}
+
+	fcport->device_type = inq->inq[0];
+	fclun = qla2x00_add_lun(fcport, lun);
+
+	if (fclun != NULL) {
+		atomic_set(&fcport->state, FCS_ONLINE);
+	}
+
+	return (fclun);
+}
+
+/*
+ * qla2x00_add_lun
+ *	Adds LUN to database
+ *
+ * Input:
+ *	fcport:		FC port structure pointer.
+ *	lun:		LUN number.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static fc_lun_t *
+qla2x00_add_lun(fc_port_t *fcport, uint16_t lun)
+{
+	int		found;
+	fc_lun_t	*fclun;
+
+	if (fcport == NULL) {
+		DEBUG(printk("scsi: Unable to add lun to NULL port\n"));
+		return (NULL);
+	}
+
+	/* Allocate LUN if not already allocated. */
+	found = 0;
+	list_for_each_entry(fclun, &fcport->fcluns, list) {
+		if (fclun->lun == lun) {
+			found++;
+			break;
+		}
+	}
+	if (found)
+		return (NULL);
+
+	fclun = kmalloc(sizeof(fc_lun_t), GFP_ATOMIC);
+	if (fclun == NULL) {
+		printk(KERN_WARNING
+		    "%s(): Memory Allocation failed - FCLUN\n",
+		    __func__);
+		return (NULL);
+	}
+
+	/* Setup LUN structure. */
+	memset(fclun, 0, sizeof(fc_lun_t));
+	fclun->lun = lun;
+	fclun->fcport = fcport;
+	fclun->o_fcport = fcport;
+	fclun->device_type = fcport->device_type;
+	atomic_set(&fcport->state, FCS_UNCONFIGURED);
+
+	list_add_tail(&fclun->list, &fcport->fcluns);
+
+	return (fclun);
+}
+
+/*
+ * qla2x00_inquiry
+ *	Issue SCSI inquiry command.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	fcport = FC port structure pointer.
+ *
+ * Return:
+ *	0  - Success
+ *  BIT_0 - error
+ *
+ * Context:
+ *	Kernel context.
+ */
+static int
+qla2x00_inquiry(scsi_qla_host_t *ha,
+    fc_port_t *fcport, uint16_t lun, inq_cmd_rsp_t *inq, dma_addr_t inq_dma)
+{
+	int rval;
+	uint16_t retries;
+	uint16_t comp_status;
+	uint16_t scsi_status;
+
+	rval = QLA_FUNCTION_FAILED;
+
+	for (retries = 3; retries; retries--) {
+		memset(inq, 0, sizeof(inq_cmd_rsp_t));
+		inq->p.cmd.entry_type = COMMAND_A64_TYPE;
+		inq->p.cmd.entry_count = 1;
+		inq->p.cmd.lun = cpu_to_le16(lun);
+		SET_TARGET_ID(ha, inq->p.cmd.target, fcport->loop_id);
+		inq->p.cmd.control_flags =
+		    __constant_cpu_to_le16(CF_READ | CF_SIMPLE_TAG);
+		inq->p.cmd.scsi_cdb[0] = INQUIRY;
+		inq->p.cmd.scsi_cdb[4] = INQ_DATA_SIZE;
+		inq->p.cmd.dseg_count = __constant_cpu_to_le16(1);
+		inq->p.cmd.timeout = __constant_cpu_to_le16(10);
+		inq->p.cmd.byte_count =
+		    __constant_cpu_to_le32(INQ_DATA_SIZE);
+		inq->p.cmd.dseg_0_address[0] = cpu_to_le32(
+		    LSD(inq_dma + sizeof(sts_entry_t)));
+		inq->p.cmd.dseg_0_address[1] = cpu_to_le32(
+		    MSD(inq_dma + sizeof(sts_entry_t)));
+		inq->p.cmd.dseg_0_length =
+		    __constant_cpu_to_le32(INQ_DATA_SIZE);
+
+		DEBUG5(printk("scsi(%ld): Lun Inquiry - fcport=[%04x/%p],"
+		    " lun (%d)\n",
+		    ha->host_no, fcport->loop_id, fcport, lun));
+
+		rval = qla2x00_issue_iocb(ha, inq, inq_dma,
+		    sizeof(inq_cmd_rsp_t));
+
+		comp_status = le16_to_cpu(inq->p.rsp.comp_status);
+		scsi_status = le16_to_cpu(inq->p.rsp.scsi_status);
+
+		DEBUG5(printk("scsi(%ld): lun (%d) inquiry - "
+		    "inq[0]= 0x%x, comp status 0x%x, scsi status 0x%x, "
+		    "rval=%d\n",
+		    ha->host_no, lun, inq->inq[0], comp_status, scsi_status,
+		    rval));
+
+		if (rval != QLA_SUCCESS || comp_status != CS_COMPLETE ||
+		    scsi_status & SS_CHECK_CONDITION) {
+
+			DEBUG(printk("scsi(%ld): INQ failed to issue iocb! "
+			    "fcport=[%04x/%p] rval=%x cs=%x ss=%x\n",
+			    ha->host_no, fcport->loop_id, fcport, rval,
+			    comp_status, scsi_status));
+
+			if (rval == QLA_SUCCESS)
+				rval = QLA_FUNCTION_FAILED;
+
+			if (scsi_status & SS_CHECK_CONDITION) {
+				DEBUG2(printk("scsi(%ld): INQ "
+				    "SS_CHECK_CONDITION Sense Data "
+				    "%02x %02x %02x %02x %02x %02x %02x %02x\n",
+				    ha->host_no,
+				    inq->p.rsp.req_sense_data[0],
+				    inq->p.rsp.req_sense_data[1],
+				    inq->p.rsp.req_sense_data[2],
+				    inq->p.rsp.req_sense_data[3],
+				    inq->p.rsp.req_sense_data[4],
+				    inq->p.rsp.req_sense_data[5],
+				    inq->p.rsp.req_sense_data[6],
+				    inq->p.rsp.req_sense_data[7]));
+			}
+
+			/* Device underrun drop LUN. */
+			if (comp_status == CS_DATA_UNDERRUN &&
+			    scsi_status & SS_RESIDUAL_UNDER) {
+				break;
+			}
+		} else {
+			break;
+		}
+	}
+
+	return (rval);
+}
+
+
+/*
+ * qla2x00_configure_fabric
+ *      Setup SNS devices with loop ID's.
+ *
+ * Input:
+ *      ha = adapter block pointer.
+ *
+ * Returns:
+ *      0 = success.
+ *      BIT_0 = error
+ */
+static int
+qla2x00_configure_fabric(scsi_qla_host_t *ha)
+{
+	int	rval, rval2;
+	fc_port_t	*fcport, *fcptemp;
+	uint16_t	next_loopid;
+	LIST_HEAD(new_fcports);
+
+	/* If FL port exists, then SNS is present */
+	rval = qla2x00_get_port_name(ha, SNS_FL_PORT, NULL, 0);
+	if (rval != QLA_SUCCESS) {
+		DEBUG2(printk("scsi(%ld): MBC_GET_PORT_NAME Failed, No FL "
+		    "Port\n", ha->host_no));
+
+		ha->device_flags &= ~SWITCH_FOUND;
+		return (QLA_SUCCESS);
+	}
+
+	/* Mark devices that need re-synchronization. */
+	rval2 = qla2x00_device_resync(ha);
+	if (rval2 == QLA_RSCNS_HANDLED) {
+		/* No, point doing the scan, just continue. */
+		return (QLA_SUCCESS);
+	}
+	do {
+		if (test_and_clear_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags)) {
+			if (qla2x00_rft_id(ha)) {
+				/* EMPTY */
+				DEBUG2(printk("scsi(%ld): Register FC-4 "
+				    "TYPE failed.\n", ha->host_no));
+			}
+			if (qla2x00_rff_id(ha)) {
+				/* EMPTY */
+				DEBUG2(printk("scsi(%ld): Register FC-4 "
+				    "Features failed.\n", ha->host_no));
+			}
+			if (qla2x00_rnn_id(ha)) {
+				/* EMPTY */
+				DEBUG2(printk("scsi(%ld): Register Node Name "
+				    "failed.\n", ha->host_no));
+			} else if (qla2x00_rsnn_nn(ha)) {
+				/* EMPTY */
+				DEBUG2(printk("scsi(%ld): Register Symbolic "
+				    "Node Name failed.\n", ha->host_no));
+			}
+		}
+
+		rval = qla2x00_find_all_fabric_devs(ha, &new_fcports);
+		if (rval != QLA_SUCCESS)
+			break;
+
+		/*
+		 * Logout all previous fabric devices marked lost, except
+		 * tape devices.
+		 */
+		list_for_each_entry(fcport, &ha->fcports, list) {
+			if (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))
+				break;
+
+			if ((fcport->flags & FCF_FABRIC_DEVICE) == 0)
+				continue;
+
+			if (atomic_read(&fcport->state) == FCS_DEVICE_LOST) {
+				qla2x00_mark_device_lost(ha, fcport,
+				    ql2xplogiabsentdevice);
+				if (fcport->loop_id != FC_NO_LOOP_ID &&
+				    (fcport->flags & FCF_TAPE_PRESENT) == 0 &&
+				    fcport->port_type != FCT_INITIATOR &&
+				    fcport->port_type != FCT_BROADCAST) {
+
+					qla2x00_fabric_logout(ha,
+					    fcport->loop_id);
+					fcport->loop_id = FC_NO_LOOP_ID;
+				}
+			}
+		}
+
+		/* Starting free loop ID. */
+		next_loopid = ha->min_external_loopid;
+
+		/*
+		 * Scan through our port list and login entries that need to be
+		 * logged in.
+		 */
+		list_for_each_entry(fcport, &ha->fcports, list) {
+			if (atomic_read(&ha->loop_down_timer) ||
+			    test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))
+				break;
+
+			if ((fcport->flags & FCF_FABRIC_DEVICE) == 0 ||
+			    (fcport->flags & FCF_LOGIN_NEEDED) == 0)
+				continue;
+
+			if (fcport->loop_id == FC_NO_LOOP_ID) {
+				fcport->loop_id = next_loopid;
+				rval = qla2x00_find_new_loop_id(ha, fcport);
+				if (rval != QLA_SUCCESS) {
+					/* Ran out of IDs to use */
+					break;
+				}
+			}
+
+			/* Login and update database */
+			qla2x00_fabric_dev_login(ha, fcport, &next_loopid);
+		}
+
+		/* Exit if out of loop IDs. */
+		if (rval != QLA_SUCCESS) {
+			break;
+		}
+
+		/*
+		 * Login and add the new devices to our port list.
+		 */
+		list_for_each_entry_safe(fcport, fcptemp, &new_fcports, list) {
+			if (atomic_read(&ha->loop_down_timer) ||
+			    test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))
+				break;
+
+			/* Find a new loop ID to use. */
+			fcport->loop_id = next_loopid;
+			rval = qla2x00_find_new_loop_id(ha, fcport);
+			if (rval != QLA_SUCCESS) {
+				/* Ran out of IDs to use */
+				break;
+			}
+
+			/* Login and update database */
+			qla2x00_fabric_dev_login(ha, fcport, &next_loopid);
+
+			/* Remove device from the new list and add it to DB */
+			list_del(&fcport->list);
+			list_add_tail(&fcport->list, &ha->fcports);
+		}
+	} while (0);
+
+	/* Free all new device structures not processed. */
+	list_for_each_entry_safe(fcport, fcptemp, &new_fcports, list) {
+		list_del(&fcport->list);
+		kfree(fcport);
+	}
+
+	if (rval) {
+		DEBUG2(printk("scsi(%ld): Configure fabric error exit: "
+		    "rval=%d\n", ha->host_no, rval));
+	}
+
+	return (rval);
+}
+
+
+/*
+ * qla2x00_find_all_fabric_devs
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	dev = database device entry pointer.
+ *
+ * Returns:
+ *	0 = success.
+ *	BIT_0 = error.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static int
+qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports)
+{
+	int		rval;
+	uint16_t	loop_id;
+	fc_port_t	*fcport, *new_fcport;
+	int		found;
+
+	sw_info_t	*swl;
+	int		swl_idx;
+	int		first_dev, last_dev;
+	port_id_t	wrap, nxt_d_id;
+
+	rval = QLA_SUCCESS;
+
+	/* Try GID_PT to get device list, else GAN. */
+	swl = kmalloc(sizeof(sw_info_t) * MAX_FIBRE_DEVICES, GFP_ATOMIC);
+	if (swl == NULL) {
+		/*EMPTY*/
+		DEBUG2(printk("scsi(%ld): GID_PT allocations failed, fallback "
+		    "on GA_NXT\n", ha->host_no));
+	} else {
+		memset(swl, 0, sizeof(sw_info_t) * MAX_FIBRE_DEVICES);
+		if (qla2x00_gid_pt(ha, swl) != QLA_SUCCESS) {
+			kfree(swl);
+			swl = NULL;
+		} else if (qla2x00_gpn_id(ha, swl) != QLA_SUCCESS) {
+			kfree(swl);
+			swl = NULL;
+		} else if (qla2x00_gnn_id(ha, swl) != QLA_SUCCESS) {
+			kfree(swl);
+			swl = NULL;
+		}
+	}
+	swl_idx = 0;
+
+	/* Allocate temporary fcport for any new fcports discovered. */
+	new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL);
+	if (new_fcport == NULL) {
+		if (swl)
+			kfree(swl);
+		return (QLA_MEMORY_ALLOC_FAILED);
+	}
+	new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED);
+
+	/* Set start port ID scan at adapter ID. */
+	first_dev = 1;
+	last_dev = 0;
+
+	/* Starting free loop ID. */
+	loop_id = ha->min_external_loopid;
+
+	for (; loop_id <= ha->last_loop_id; loop_id++) {
+		if (RESERVED_LOOP_ID(loop_id))
+			continue;
+
+		if (atomic_read(&ha->loop_down_timer) ||
+		    test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))
+			break;
+
+		if (swl != NULL) {
+			if (last_dev) {
+				wrap.b24 = new_fcport->d_id.b24;
+			} else {
+				new_fcport->d_id.b24 = swl[swl_idx].d_id.b24;
+				memcpy(new_fcport->node_name,
+				    swl[swl_idx].node_name, WWN_SIZE);
+				memcpy(new_fcport->port_name,
+				    swl[swl_idx].port_name, WWN_SIZE);
+
+				if (swl[swl_idx].d_id.b.rsvd_1 != 0) {
+					last_dev = 1;
+				}
+				swl_idx++;
+			}
+		} else {
+			/* Send GA_NXT to the switch */
+			rval = qla2x00_ga_nxt(ha, new_fcport);
+			if (rval != QLA_SUCCESS) {
+				break;
+			}
+		}
+
+		/* If wrap on switch device list, exit. */
+		if (first_dev) {
+			wrap.b24 = new_fcport->d_id.b24;
+			first_dev = 0;
+		} else if (new_fcport->d_id.b24 == wrap.b24) {
+			DEBUG2(printk("scsi(%ld): device wrap (%02x%02x%02x)\n",
+			    ha->host_no, new_fcport->d_id.b.domain,
+			    new_fcport->d_id.b.area, new_fcport->d_id.b.al_pa));
+			break;
+		}
+
+		/* Bypass if host adapter. */
+		if (new_fcport->d_id.b24 == ha->d_id.b24)
+			continue;
+
+		/* Bypass reserved domain fields. */
+		if ((new_fcport->d_id.b.domain & 0xf0) == 0xf0)
+			continue;
+
+		/* Bypass if same domain and area of adapter. */
+		if ((new_fcport->d_id.b24 & 0xffff00) ==
+		    (ha->d_id.b24 & 0xffff00))
+			continue;
+
+		/* Locate matching device in database. */
+		found = 0;
+		list_for_each_entry(fcport, &ha->fcports, list) {
+			if (memcmp(new_fcport->port_name, fcport->port_name,
+			    WWN_SIZE))
+				continue;
+
+			found++;
+
+			/*
+			 * If device was not a fabric device before.
+			 */
+			if ((fcport->flags & FCF_FABRIC_DEVICE) == 0) {
+				fcport->d_id.b24 = new_fcport->d_id.b24;
+				fcport->loop_id = FC_NO_LOOP_ID;
+				fcport->flags |= (FCF_FABRIC_DEVICE |
+				    FCF_LOGIN_NEEDED);
+				fcport->flags &= ~FCF_PERSISTENT_BOUND;
+				break;
+			}
+
+			/*
+			 * If address the same and state FCS_ONLINE, nothing
+			 * changed.
+			 */
+			if (fcport->d_id.b24 == new_fcport->d_id.b24 &&
+			    atomic_read(&fcport->state) == FCS_ONLINE) {
+				break;
+			}
+
+			/*
+			 * Port ID changed or device was marked to be updated;
+			 * Log it out if still logged in and mark it for
+			 * relogin later.
+			 */
+			fcport->d_id.b24 = new_fcport->d_id.b24;
+			fcport->flags |= FCF_LOGIN_NEEDED;
+			if (fcport->loop_id != FC_NO_LOOP_ID &&
+			    (fcport->flags & FCF_TAPE_PRESENT) == 0 &&
+			    fcport->port_type != FCT_INITIATOR &&
+			    fcport->port_type != FCT_BROADCAST) {
+				qla2x00_fabric_logout(ha, fcport->loop_id);
+				fcport->loop_id = FC_NO_LOOP_ID;
+			}
+
+			break;
+		}
+
+		if (found)
+			continue;
+
+		/* If device was not in our fcports list, then add it. */
+		list_add_tail(&new_fcport->list, new_fcports);
+
+		/* Allocate a new replacement fcport. */
+		nxt_d_id.b24 = new_fcport->d_id.b24;
+		new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL);
+		if (new_fcport == NULL) {
+			if (swl)
+				kfree(swl);
+			return (QLA_MEMORY_ALLOC_FAILED);
+		}
+		new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED);
+		new_fcport->d_id.b24 = nxt_d_id.b24;
+	}
+
+	if (swl)
+		kfree(swl);
+
+	if (new_fcport)
+		kfree(new_fcport);
+
+	if (!list_empty(new_fcports))
+		ha->device_flags |= DFLG_FABRIC_DEVICES;
+
+	return (rval);
+}
+
+/*
+ * qla2x00_find_new_loop_id
+ *	Scan through our port list and find a new usable loop ID.
+ *
+ * Input:
+ *	ha:	adapter state pointer.
+ *	dev:	port structure pointer.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_find_new_loop_id(scsi_qla_host_t *ha, fc_port_t *dev)
+{
+	int	rval;
+	int	found;
+	fc_port_t *fcport;
+	uint16_t first_loop_id;
+
+	rval = QLA_SUCCESS;
+
+	/* Save starting loop ID. */
+	first_loop_id = dev->loop_id;
+
+	for (;;) {
+		/* Skip loop ID if already used by adapter. */
+		if (dev->loop_id == ha->loop_id) {
+			dev->loop_id++;
+		}
+
+		/* Skip reserved loop IDs. */
+		while (RESERVED_LOOP_ID(dev->loop_id)) {
+			dev->loop_id++;
+		}
+
+		/* Reset loop ID if passed the end. */
+		if (dev->loop_id > ha->last_loop_id) {
+			/* first loop ID. */
+			dev->loop_id = ha->min_external_loopid;
+		}
+
+		/* Check for loop ID being already in use. */
+		found = 0;
+		fcport = NULL;
+		list_for_each_entry(fcport, &ha->fcports, list) {
+			if (fcport->loop_id == dev->loop_id && fcport != dev) {
+				/* ID possibly in use */
+				found++;
+				break;
+			}
+		}
+
+		/* If not in use then it is free to use. */
+		if (!found) {
+			break;
+		}
+
+		/* ID in use. Try next value. */
+		dev->loop_id++;
+
+		/* If wrap around. No free ID to use. */
+		if (dev->loop_id == first_loop_id) {
+			dev->loop_id = FC_NO_LOOP_ID;
+			rval = QLA_FUNCTION_FAILED;
+			break;
+		}
+	}
+
+	return (rval);
+}
+
+/*
+ * qla2x00_device_resync
+ *	Marks devices in the database that needs resynchronization.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static int
+qla2x00_device_resync(scsi_qla_host_t *ha) 
+{
+	int	rval;
+	int	rval2;
+	uint32_t mask;
+	fc_port_t *fcport;
+	uint32_t rscn_entry;
+	uint8_t rscn_out_iter;
+	uint8_t format;
+	port_id_t d_id;
+
+	rval = QLA_RSCNS_HANDLED;
+
+	while (ha->rscn_out_ptr != ha->rscn_in_ptr ||
+	    ha->flags.rscn_queue_overflow) {
+
+		rscn_entry = ha->rscn_queue[ha->rscn_out_ptr];
+		format = MSB(MSW(rscn_entry));
+		d_id.b.domain = LSB(MSW(rscn_entry));
+		d_id.b.area = MSB(LSW(rscn_entry));
+		d_id.b.al_pa = LSB(LSW(rscn_entry));
+
+		DEBUG(printk("scsi(%ld): RSCN queue entry[%d] = "
+		    "[%02x/%02x%02x%02x].\n",
+		    ha->host_no, ha->rscn_out_ptr, format, d_id.b.domain,
+		    d_id.b.area, d_id.b.al_pa));
+
+		ha->rscn_out_ptr++;
+		if (ha->rscn_out_ptr == MAX_RSCN_COUNT)
+			ha->rscn_out_ptr = 0;
+
+		/* Skip duplicate entries. */
+		for (rscn_out_iter = ha->rscn_out_ptr;
+		    !ha->flags.rscn_queue_overflow &&
+		    rscn_out_iter != ha->rscn_in_ptr;
+		    rscn_out_iter = (rscn_out_iter ==
+			(MAX_RSCN_COUNT - 1)) ? 0: rscn_out_iter + 1) {
+
+			if (rscn_entry != ha->rscn_queue[rscn_out_iter])
+				break;
+
+			DEBUG(printk("scsi(%ld): Skipping duplicate RSCN queue "
+			    "entry found at [%d].\n", ha->host_no,
+			    rscn_out_iter));
+
+			ha->rscn_out_ptr = rscn_out_iter;
+		}
+
+		/* Queue overflow, set switch default case. */
+		if (ha->flags.rscn_queue_overflow) {
+			DEBUG(printk("scsi(%ld): device_resync: rscn "
+			    "overflow.\n", ha->host_no));
+
+			format = 3;
+			ha->flags.rscn_queue_overflow = 0;
+		}
+
+		switch (format) {
+		case 0:
+			if (IS_QLA23XX(ha) && ha->flags.init_done) {
+				/* Handle port RSCN via asyncronous IOCBs */
+				rval2 = qla2x00_handle_port_rscn(ha, rscn_entry,
+				    NULL, 0);
+				if (rval2 == QLA_SUCCESS)
+					continue;
+			}
+			mask = 0xffffff;
+			break;
+		case 1:
+			mask = 0xffff00;
+			break;
+		case 2:
+			mask = 0xff0000;
+			break;
+		default:
+			mask = 0x0;
+			d_id.b24 = 0;
+			ha->rscn_out_ptr = ha->rscn_in_ptr;
+			break;
+		}
+
+		rval = QLA_SUCCESS;
+
+		/* Abort any outstanding IO descriptors. */
+		if (IS_QLA23XX(ha))
+			qla2x00_cancel_io_descriptors(ha);
+
+		list_for_each_entry(fcport, &ha->fcports, list) {
+			if ((fcport->flags & FCF_FABRIC_DEVICE) == 0 ||
+			    (fcport->d_id.b24 & mask) != d_id.b24 ||
+			    fcport->port_type == FCT_BROADCAST)
+				continue;
+
+			if (atomic_read(&fcport->state) == FCS_ONLINE) {
+				if (format != 3 ||
+				    fcport->port_type != FCT_INITIATOR) {
+					atomic_set(&fcport->state,
+					    FCS_DEVICE_LOST);
+				}
+			}
+			fcport->flags &= ~FCF_FARP_DONE;
+		}
+	}
+	return (rval);
+}
+
+/*
+ * qla2x00_fabric_dev_login
+ *	Login fabric target device and update FC port database.
+ *
+ * Input:
+ *	ha:		adapter state pointer.
+ *	fcport:		port structure list pointer.
+ *	next_loopid:	contains value of a new loop ID that can be used
+ *			by the next login attempt.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static int
+qla2x00_fabric_dev_login(scsi_qla_host_t *ha, fc_port_t *fcport,
+    uint16_t *next_loopid)
+{
+	int	rval;
+	int	retry;
+
+	rval = QLA_SUCCESS;
+	retry = 0;
+
+	rval = qla2x00_fabric_login(ha, fcport, next_loopid);
+	if (rval == QLA_SUCCESS) {
+		rval = qla2x00_get_port_database(ha, fcport, BIT_1 | BIT_0);
+		if (rval != QLA_SUCCESS) {
+			qla2x00_fabric_logout(ha, fcport->loop_id);
+		} else {
+			qla2x00_update_fcport(ha, fcport);
+		}
+	}
+
+	return (rval);
+}
+
+/*
+ * qla2x00_fabric_login
+ *	Issue fabric login command.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	device = pointer to FC device type structure.
+ *
+ * Returns:
+ *      0 - Login successfully
+ *      1 - Login failed
+ *      2 - Initiator device
+ *      3 - Fatal error
+ */
+int
+qla2x00_fabric_login(scsi_qla_host_t *ha, fc_port_t *fcport,
+    uint16_t *next_loopid)
+{
+	int	rval;
+	int	retry;
+	uint16_t tmp_loopid;
+	uint16_t mb[MAILBOX_REGISTER_COUNT];
+
+	retry = 0;
+	tmp_loopid = 0;
+
+	for (;;) {
+		DEBUG(printk("scsi(%ld): Trying Fabric Login w/loop id 0x%04x "
+ 		    "for port %02x%02x%02x.\n",
+ 		    ha->host_no, fcport->loop_id, fcport->d_id.b.domain,
+		    fcport->d_id.b.area, fcport->d_id.b.al_pa));
+
+		/* Login fcport on switch. */
+		qla2x00_login_fabric(ha, fcport->loop_id,
+		    fcport->d_id.b.domain, fcport->d_id.b.area,
+		    fcport->d_id.b.al_pa, mb, BIT_0);
+		if (mb[0] == MBS_PORT_ID_USED) {
+			/*
+			 * Device has another loop ID.  The firmware team
+			 * recommends us to perform an implicit login with the
+			 * specified ID again. The ID we just used is save here
+			 * so we return with an ID that can be tried by the
+			 * next login.
+			 */
+			retry++;
+			tmp_loopid = fcport->loop_id;
+			fcport->loop_id = mb[1];
+
+			DEBUG(printk("Fabric Login: port in use - next "
+ 			    "loop id=0x%04x, port Id=%02x%02x%02x.\n",
+			    fcport->loop_id, fcport->d_id.b.domain,
+			    fcport->d_id.b.area, fcport->d_id.b.al_pa));
+
+		} else if (mb[0] == MBS_COMMAND_COMPLETE) {
+			/*
+			 * Login succeeded.
+			 */
+			if (retry) {
+				/* A retry occurred before. */
+				*next_loopid = tmp_loopid;
+			} else {
+				/*
+				 * No retry occurred before. Just increment the
+				 * ID value for next login.
+				 */
+				*next_loopid = (fcport->loop_id + 1);
+			}
+
+			if (mb[1] & BIT_0) {
+				fcport->port_type = FCT_INITIATOR;
+			} else {
+				fcport->port_type = FCT_TARGET;
+				if (mb[1] & BIT_1) {
+					fcport->flags |= FCF_TAPE_PRESENT;
+				}
+			}
+
+			rval = QLA_SUCCESS;
+			break;
+		} else if (mb[0] == MBS_LOOP_ID_USED) {
+			/*
+			 * Loop ID already used, try next loop ID.
+			 */
+			fcport->loop_id++;
+			rval = qla2x00_find_new_loop_id(ha, fcport);
+			if (rval != QLA_SUCCESS) {
+				/* Ran out of loop IDs to use */
+				break;
+			}
+		} else if (mb[0] == MBS_COMMAND_ERROR) {
+			/*
+			 * Firmware possibly timed out during login. If NO
+			 * retries are left to do then the device is declared
+			 * dead.
+			 */
+			*next_loopid = fcport->loop_id;
+			qla2x00_fabric_logout(ha, fcport->loop_id);
+			fcport->loop_id = FC_NO_LOOP_ID;
+
+			rval = 3;
+			break;
+		} else {
+			/*
+			 * unrecoverable / not handled error
+			 */
+			DEBUG2(printk("%s(%ld): failed=%x port_id=%02x%02x%02x "
+ 			    "loop_id=%x jiffies=%lx.\n", 
+ 			    __func__, ha->host_no, mb[0], 
+			    fcport->d_id.b.domain, fcport->d_id.b.area,
+			    fcport->d_id.b.al_pa, fcport->loop_id, jiffies));
+
+			*next_loopid = fcport->loop_id;
+			qla2x00_fabric_logout(ha, fcport->loop_id);
+			fcport->loop_id = FC_NO_LOOP_ID;
+			atomic_set(&fcport->state, FCS_DEVICE_DEAD);
+
+			rval = 1;
+			break;
+		}
+	}
+
+	return (rval);
+}
+
+/*
+ * qla2x00_local_device_login
+ *	Issue local device login command.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	loop_id = loop id of device to login to.
+ *
+ * Returns (Where's the #define!!!!):
+ *      0 - Login successfully
+ *      1 - Login failed
+ *      3 - Fatal error
+ */
+int
+qla2x00_local_device_login(scsi_qla_host_t *ha, uint16_t loop_id)
+{
+	int		rval;
+	uint16_t	mb[MAILBOX_REGISTER_COUNT];
+
+	memset(mb, 0, sizeof(mb));
+	rval = qla2x00_login_local_device(ha, loop_id, mb, BIT_0);
+	if (rval == QLA_SUCCESS) {
+		/* Interrogate mailbox registers for any errors */
+		if (mb[0] == MBS_COMMAND_ERROR)
+			rval = 1;
+		else if (mb[0] == MBS_COMMAND_PARAMETER_ERROR)
+			/* device not in PCB table */
+			rval = 3;
+	}
+
+	return (rval);
+}
+
+/*
+ *  qla2x00_loop_resync
+ *      Resync with fibre channel devices.
+ *
+ * Input:
+ *      ha = adapter block pointer.
+ *
+ * Returns:
+ *      0 = success
+ */
+int
+qla2x00_loop_resync(scsi_qla_host_t *ha) 
+{
+	int   rval;
+
+	rval = QLA_SUCCESS;
+
+	atomic_set(&ha->loop_state, LOOP_UPDATE);
+	qla2x00_stats.loop_resync++;
+	clear_bit(ISP_ABORT_RETRY, &ha->dpc_flags);
+	if (ha->flags.online) {
+		if (!(rval = qla2x00_fw_ready(ha))) {
+			do {
+				/* v2.19.05b6 */
+				atomic_set(&ha->loop_state, LOOP_UPDATE);
+
+				/*
+				 * Issue marker command only when we are going
+				 * to start the I/O .
+				 */
+				ha->marker_needed = 1;
+
+				/* Remap devices on Loop. */
+				clear_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
+
+				qla2x00_configure_loop(ha);
+
+			} while (!atomic_read(&ha->loop_down_timer) &&
+				!(test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) &&
+				(test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)));
+		}
+		qla2x00_restart_queues(ha,TRUE);
+	}
+
+	if (test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) {
+		return (QLA_FUNCTION_FAILED);
+	}
+
+	if (rval) {
+		DEBUG2_3(printk("%s(): **** FAILED ****\n", __func__));
+	}
+
+	return (rval);
+}
+
+/*
+ *  qla2x00_restart_queues
+ *	Restart device queues.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *
+ * Context:
+ *	Kernel/Interrupt context.
+ */
+void
+qla2x00_restart_queues(scsi_qla_host_t *ha, uint8_t flush) 
+{
+	srb_t  		*sp;
+	int		retry_q_cnt = 0;
+	int		pending_q_cnt = 0;
+	struct list_head *list, *temp;
+	unsigned long flags = 0;
+
+	ENTER(__func__);
+
+	clear_bit(RESTART_QUEUES_NEEDED, &ha->dpc_flags);
+
+	/*
+	 * start pending queue
+	 */
+	pending_q_cnt = ha->qthreads;
+	if (flush) {
+		spin_lock_irqsave(&ha->list_lock,flags);
+		list_for_each_safe(list, temp, &ha->pending_queue) {
+			sp = list_entry(list, srb_t, list);
+			/* 
+			 * When time expire return request back to OS as BUSY 
+			 */
+			__del_from_pending_queue(ha, sp);
+			sp->cmd->result = DID_BUS_BUSY << 16;
+			sp->cmd->host_scribble = (unsigned char *)NULL;
+			__add_to_done_queue(ha, sp);
+		}
+		spin_unlock_irqrestore(&ha->list_lock, flags);
+	} else {
+		if (!list_empty(&ha->pending_queue))
+			qla2x00_next(ha);
+	}
+
+	/*
+	 * Clear out our retry queue
+	 */
+	if (flush) {
+		spin_lock_irqsave(&ha->list_lock, flags);
+		retry_q_cnt = ha->retry_q_cnt;
+		list_for_each_safe(list, temp, &ha->retry_queue) {
+			sp = list_entry(list, srb_t, list);
+			/* when time expire return request back to OS as BUSY */
+			__del_from_retry_queue(ha, sp);
+			sp->cmd->result = DID_BUS_BUSY << 16;
+			sp->cmd->host_scribble = (unsigned char *)NULL;
+			__add_to_done_queue(ha, sp);
+		}
+		spin_unlock_irqrestore(&ha->list_lock, flags);
+
+		DEBUG2(printk("%s(%ld): callback %d commands.\n",
+				__func__,
+				ha->host_no,
+				retry_q_cnt);)
+	}
+
+	DEBUG2(printk("%s(%ld): active=%ld, retry=%d, pending=%d, "
+			"done=%ld, scsi retry=%d commands.\n",
+			__func__,
+			ha->host_no,
+			ha->actthreads,
+			ha->retry_q_cnt,
+			pending_q_cnt,
+			ha->done_q_cnt,
+			ha->scsi_retry_q_cnt);)
+
+	if (!list_empty(&ha->done_queue))
+		qla2x00_done(ha);
+
+	LEAVE(__func__);
+}
+
+//FIXME - Document
+void
+qla2x00_rescan_fcports(scsi_qla_host_t *ha)
+{
+	int rescan_done;
+	fc_port_t *fcport;
+
+	rescan_done = 0;
+	list_for_each_entry(fcport, &ha->fcports, list) {
+		if ((fcport->flags & FCF_RESCAN_NEEDED) == 0)
+			continue;
+
+		qla2x00_update_fcport(ha, fcport);
+		fcport->flags &= ~FCF_RESCAN_NEEDED;
+
+		rescan_done = 1;
+	}
+
+	/* Update OS target and lun structures if necessary. */
+	if (rescan_done)
+		qla2x00_config_os(ha);
+}
+
+
+/*
+ * qla2x00_config_os
+ *	Setup OS target and LUN structures.
+ *
+ * Input:
+ *	ha = adapter state pointer.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static void
+qla2x00_config_os(scsi_qla_host_t *ha) 
+{
+	fc_port_t	*fcport;
+	fc_lun_t	*fclun;
+	os_tgt_t	*tq;
+	uint16_t	tgt;
+
+
+	for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
+		if ((tq = TGT_Q(ha, tgt)) == NULL)
+			continue;
+
+		tq->flags &= ~TQF_ONLINE;
+	}
+
+	list_for_each_entry(fcport, &ha->fcports, list) {
+		if (atomic_read(&fcport->state) != FCS_ONLINE ||
+		    fcport->port_type == FCT_INITIATOR ||
+		    fcport->port_type == FCT_BROADCAST) {
+			fcport->os_target_id = MAX_TARGETS;
+			continue;
+		}
+
+		if (fcport->flags & FCF_FO_MASKED) {
+			continue;
+		}
+
+		/* Bind FC port to OS target number. */
+		if (qla2x00_fcport_bind(ha, fcport) == MAX_TARGETS) {
+			continue;
+		}
+
+		/* Bind FC LUN to OS LUN number. */
+		list_for_each_entry(fclun, &fcport->fcluns, list) {
+			qla2x00_fclun_bind(ha, fcport, fclun);
+		}
+	}
+}
+
+/*
+ * qla2x00_fcport_bind
+ *	Locates a target number for FC port.
+ *
+ * Input:
+ *	ha = adapter state pointer.
+ *	fcport = FC port structure pointer.
+ *
+ * Returns:
+ *	target number
+ *
+ * Context:
+ *	Kernel context.
+ */
+static uint16_t
+qla2x00_fcport_bind(scsi_qla_host_t *ha, fc_port_t *fcport) 
+{
+	uint16_t	tgt;
+	os_tgt_t	*tq;
+
+	/* Check for persistent binding. */
+	for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
+		if ((tq = TGT_Q(ha, tgt)) == NULL)
+			continue;
+
+		if (ha->binding_type == BIND_BY_PORT_ID &&
+		    fcport->d_id.b24 == tq->d_id.b24) {
+			memcpy(tq->node_name, fcport->node_name, WWN_SIZE);
+			memcpy(tq->port_name, fcport->port_name, WWN_SIZE);
+			break;
+		}
+
+		if (memcmp(fcport->port_name, tq->port_name, WWN_SIZE) == 0) {
+			/* In case of persistent binding, update the WWNN */
+			memcpy(tq->node_name, fcport->node_name, WWN_SIZE);
+			break;
+		}
+	}
+
+	/* TODO: honor the ConfigRequired flag */
+	if (tgt == MAX_TARGETS) {
+		/* Check if targetID 0 available. */
+		tgt = 0;
+
+		if (TGT_Q(ha, tgt) != NULL) {
+			/* Locate first free target for device. */
+			for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
+				if (TGT_Q(ha, tgt) == NULL) {
+					break;
+				}
+			}
+		}
+		if (tgt != MAX_TARGETS) {
+			if ((tq = qla2x00_tgt_alloc(ha, tgt)) != NULL) {
+				memcpy(tq->node_name, fcport->node_name,
+				    WWN_SIZE);
+				memcpy(tq->port_name, fcport->port_name,
+				    WWN_SIZE);
+				tq->d_id.b24 = fcport->d_id.b24;
+			}
+		}
+	}
+
+	/* Reset target numbers incase it changed. */
+	fcport->os_target_id = tgt;
+	if (tgt != MAX_TARGETS && tq != NULL) {
+		DEBUG2(printk("scsi(%ld): Assigning target ID=%02d @ %p to "
+		    "loop id=0x%04x, port state=0x%x, port down retry=%d\n",
+		    ha->host_no, tgt, tq, fcport->loop_id,
+		    atomic_read(&fcport->state),
+		    atomic_read(&fcport->port_down_timer)));
+
+		fcport->tgt_queue = tq;
+		fcport->flags |= FCF_PERSISTENT_BOUND;
+		tq->fcport = fcport;
+		tq->flags |= TQF_ONLINE;
+		tq->port_down_retry_count = ha->port_down_retry_count;
+
+	}
+
+	if (tgt == MAX_TARGETS) {
+		qla_printk(KERN_WARNING, ha,
+		    "Unable to bind fcport, loop_id=%x\n", fcport->loop_id);
+	}
+
+	return (tgt);
+}
+
+/*
+ * qla2x00_fclun_bind
+ *	Binds all FC device LUNS to OS LUNS.
+ *
+ * Input:
+ *	ha:		adapter state pointer.
+ *	fcport:		FC port structure pointer.
+ *
+ * Returns:
+ *	target number
+ *
+ * Context:
+ *	Kernel context.
+ */
+static os_lun_t *
+qla2x00_fclun_bind(scsi_qla_host_t *ha, fc_port_t *fcport, fc_lun_t *fclun)
+{
+	os_lun_t	*lq;
+	uint16_t	tgt;
+	uint16_t	lun;
+
+	tgt = fcport->os_target_id;
+	lun = fclun->lun;
+
+	/* Allocate LUNs */
+	if (lun >= MAX_LUNS) {
+		DEBUG2(printk("scsi(%ld): Unable to bind lun, invalid "
+		    "lun=(%x).\n", ha->host_no, lun));
+		return (NULL);
+	}
+
+	/* Always alloc LUN 0 so kernel will scan past LUN 0. */
+	if (lun != 0 && (EXT_IS_LUN_BIT_SET(&(fcport->lun_mask), lun))) {
+		return (NULL);
+	}
+
+	if ((lq = qla2x00_lun_alloc(ha, tgt, lun)) == NULL) {
+		qla_printk(KERN_WARNING, ha,
+		    "Unable to bind fclun, loop_id=%x lun=%x\n",
+		    fcport->loop_id, lun);
+		return (NULL);
+	}
+
+	lq->fclun = fclun;
+
+	return (lq);
+}
+
+/*
+ * qla2x00_tgt_alloc
+ *	Allocate and pre-initialize target queue.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	t = SCSI target number.
+ *
+ * Returns:
+ *	NULL = failure
+ *
+ * Context:
+ *	Kernel context.
+ */
+os_tgt_t *
+qla2x00_tgt_alloc(scsi_qla_host_t *ha, uint16_t tgt) 
+{
+	os_tgt_t	*tq;
+
+	/*
+	 * If SCSI addressing OK, allocate TGT queue and lock.
+	 */
+	if (tgt >= MAX_TARGETS) {
+		DEBUG2(printk("scsi(%ld): Unable to allocate target, invalid "
+		    "target number %d.\n", ha->host_no, tgt));
+		return (NULL);
+	}
+
+	tq = TGT_Q(ha, tgt);
+	if (tq == NULL) {
+		tq = kmalloc(sizeof(os_tgt_t), GFP_ATOMIC);
+		if (tq != NULL) {
+			DEBUG2(printk("scsi(%ld): Alloc Target %d @ %p\n",
+			    ha->host_no, tgt, tq));
+
+			memset(tq, 0, sizeof(os_tgt_t));
+			tq->ha = ha;
+
+			TGT_Q(ha, tgt) = tq;
+		}
+	}
+	if (tq != NULL) {
+		tq->port_down_retry_count = ha->port_down_retry_count;
+	} else {
+		qla_printk(KERN_WARNING, ha,
+		    "Unable to allocate target.\n");
+		ha->mem_err++;
+	}
+
+	return (tq);
+}
+
+/*
+ * qla2x00_tgt_free
+ *	Frees target and LUN queues.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	t = SCSI target number.
+ *
+ * Context:
+ *	Kernel context.
+ */
+void
+qla2x00_tgt_free(scsi_qla_host_t *ha, uint16_t tgt) 
+{
+	os_tgt_t	*tq;
+	uint16_t	lun;
+
+	/*
+	 * If SCSI addressing OK, allocate TGT queue and lock.
+	 */
+	if (tgt >= MAX_TARGETS) {
+		DEBUG2(printk("scsi(%ld): Unable to de-allocate target, "
+		    "invalid target number %d.\n", ha->host_no, tgt));
+
+		return;
+	}
+
+	tq = TGT_Q(ha, tgt);
+	if (tq != NULL) {
+		TGT_Q(ha, tgt) = NULL;
+
+		/* Free LUN structures. */
+		for (lun = 0; lun < MAX_LUNS; lun++)
+			qla2x00_lun_free(ha, tgt, lun);
+
+		kfree(tq);
+	}
+
+	return;
+}
+
+/*
+ * qla2x00_lun_alloc
+ *	Allocate and initialize LUN queue.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	t = SCSI target number.
+ *	l = LUN number.
+ *
+ * Returns:
+ *	NULL = failure
+ *
+ * Context:
+ *	Kernel context.
+ */
+os_lun_t *
+qla2x00_lun_alloc(scsi_qla_host_t *ha, uint16_t tgt, uint16_t lun) 
+{
+	os_lun_t	*lq;
+
+	/*
+	 * If SCSI addressing OK, allocate LUN queue.
+	 */
+	if (tgt >= MAX_TARGETS || lun >= MAX_LUNS || TGT_Q(ha, tgt) == NULL) {
+		DEBUG2(printk("scsi(%ld): Unable to allocate lun, invalid "
+		    "parameter.\n", ha->host_no));
+
+		return (NULL);
+	}
+
+	lq = LUN_Q(ha, tgt, lun);
+	if (lq == NULL) {
+		lq = kmalloc(sizeof(os_lun_t), GFP_ATOMIC);
+		if (lq != NULL) {
+			DEBUG2(printk("scsi(%ld): Alloc Lun %d @ tgt %d.\n",
+			    ha->host_no, lun, tgt));
+
+			memset(lq, 0, sizeof (os_lun_t));
+			LUN_Q(ha, tgt, lun) = lq;
+
+			/*
+			 * The following lun queue initialization code
+			 * must be duplicated in alloc_ioctl_mem function
+			 * for ioctl_lq.
+			 */
+			lq->q_state = LUN_STATE_READY;
+			spin_lock_init(&lq->q_lock);
+		}
+	}
+
+	if (lq == NULL) {
+		qla_printk(KERN_WARNING, ha, "Unable to allocate lun.\n");
+	}
+
+	return (lq);
+}
+
+/*
+ * qla2x00_lun_free
+ *	Frees LUN queue.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	t = SCSI target number.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static void
+qla2x00_lun_free(scsi_qla_host_t *ha, uint16_t tgt, uint16_t lun) 
+{
+	os_lun_t	*lq;
+
+	/*
+	 * If SCSI addressing OK, allocate TGT queue and lock.
+	 */
+	if (tgt >= MAX_TARGETS || lun >= MAX_LUNS) {
+		DEBUG2(printk("scsi(%ld): Unable to deallocate lun, invalid "
+		    "parameter.\n", ha->host_no));
+
+		return;
+	}
+
+	if (TGT_Q(ha, tgt) != NULL && (lq = LUN_Q(ha, tgt, lun)) != NULL) {
+		LUN_Q(ha, tgt, lun) = NULL;
+		kfree(lq);
+	}
+
+	return;
+}
+
+
+/*
+ * qla2x00_bstr_to_hex
+ *	Convert hex byte string to number.
+ *
+ * Input:
+ *	s = byte string pointer.
+ *	bp = byte pointer for number.
+ *	size = number of bytes.
+ *
+ * Context:
+ *	Kernel/Interrupt context.
+ */
+static int
+qla2x00_bstr_to_hex(char *s, uint8_t *bp, int size) 
+{
+	int		cnt;
+	uint8_t		n;
+
+	for (cnt = 0; *s != '\0' && cnt / 2 < size; cnt++) {
+		if (*s >= 'A' && *s <= 'F') {
+			n = (*s++ - 'A') + 10;
+		} else if (*s >= 'a' && *s <= 'f') {
+			n = (*s++ - 'a') + 10;
+		} else if (*s >= '0' && *s <= '9') {
+			n = *s++ - '0';
+		} else {
+			cnt = 0;
+			break;
+		}
+
+		if (cnt & BIT_0)
+			*bp++ |= n;
+		else
+			*bp = n << 4;
+	}
+
+	/* fixme(dg) Need to swap data little endian */
+
+	return (cnt / 2);
+}
+
+/*
+ * qla2x00_get_prop_xstr
+ *      Get a string property value for the specified property name and
+ *      convert from the property string found in the configuration file,
+ *      which are ASCII characters representing nibbles, 2 characters represent
+ *      the hexdecimal value for a byte in the byte array.
+ *      The byte array is initialized to zero.
+ *      The resulting converted value is in big endian format (MSB at byte0).
+ *
+ * Input:
+ *      ha = adapter state pointer.
+ *      propname = property name pointer.
+ *      propval  = pointer where to store converted property val.
+ *      size = max or expected size of 'propval' array.
+ *
+ * Returns:
+ *      0 = empty value string or invalid character in string
+ *      >0 = count of characters converted
+ *      -1 = property not found
+ *
+ * Context:
+ *      Kernel context.
+ */
+int
+qla2x00_get_prop_xstr(scsi_qla_host_t *ha, 
+		char *propname, uint8_t *propval, int size) 
+{
+	char		*propstr;
+	int		rval = -1;
+	static char	buf[LINESIZE];
+
+	/* Get the requested property string */
+	rval = qla2x00_find_propname(ha, propname, buf, ha->cmdline, size*2);
+	DEBUG3(printk("%s(): Ret rval from find propname = %d\n",
+			__func__,
+			rval);)
+
+	propstr = &buf[0];
+	if (*propstr == '=')
+		propstr++;   /* ignore equal sign */
+
+	if (rval == 0) {  /* not found */
+		LEAVE(__func__);
+		return (-1);
+	}
+
+	rval = qla2x00_bstr_to_hex(propstr, (uint8_t *)propval, size);
+	if (rval == 0) {
+		/* Invalid character in value string */
+		qla_printk(KERN_INFO, ha,
+			"%s(): %s Invalid hex string for property\n",
+			__func__,
+			propname);
+		qla_printk(KERN_INFO, ha,
+			" Invalid string - %s\n", 
+			propstr);
+	}
+
+	return (rval);
+}
+
+/*
+ * qla2x00_find_propname
+ *	Get property in database.
+ *
+ * Input:
+ *	ha = adapter structure pointer.
+ *      db = pointer to database
+ *      propstr = pointer to dest array for string
+ *	propname = name of property to search for.
+ *	siz = size of property
+ *
+ * Returns:
+ *	0 = no property
+ *      size = index of property
+ *
+ * Context:
+ *	Kernel context.
+ */
+static int
+qla2x00_find_propname(scsi_qla_host_t *ha, 
+			char *propname, char *propstr, 
+			char *db, int siz) 
+{
+	char	*cp;
+
+	/* find the specified string */
+	if (db) {
+		/* find the property name */
+		if ((cp = strstr(db,propname)) != NULL) {
+			while ((*cp)  && *cp != '=')
+				cp++;
+			if (*cp) {
+				strncpy(propstr, cp, siz+1);
+				propstr[siz+1] = '\0';
+				DEBUG(printk("qla2x00_find_propname: found "
+						"property = {%s}\n",
+						propstr);)
+				return (siz);   /* match */
+			}
+		}
+	}
+
+	return (0);
+}
+
+#if 0
+/*
+ * qla2x00_get_prop_16chars
+ *	Get an 8-byte property value for the specified property name by
+ *      converting from the property string found in the configuration file.
+ *      The resulting converted value is in big endian format (MSB at byte0).
+ *
+ * Input:
+ *	ha = adapter state pointer.
+ *	propname = property name pointer.
+ *	propval  = pointer to location for the converted property val.
+ *      db = pointer to database
+ *
+ * Returns:
+ *	0 = value returned successfully.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static int
+qla2x00_get_prop_16chars(scsi_qla_host_t *ha,
+				char *propname, char *propval, char *db) 
+{
+	char		*propstr;
+	int		i, k;
+	int		rval;
+	uint8_t		nval;
+	uint8_t		*pchar;
+	uint8_t		*ret_byte;
+	uint8_t		*tmp_byte;
+	uint8_t		*retval = (uint8_t*)propval;
+	uint8_t		tmpval[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+	uint16_t	max_byte_cnt = 8; /* 16 chars = 8 bytes */
+	uint16_t	max_strlen = 16;
+	static char	buf[LINESIZE];
+
+	rval = qla2x00_find_propname(ha, propname, buf, db, max_strlen);
+
+	propstr = &buf[0];
+	if (*propstr == '=')
+		propstr++;   /* ignore equal sign */
+
+	if (rval == 0) {
+		return (1);
+	}
+
+	/* Convert string to numbers. */
+	pchar = (uint8_t *)propstr;
+	tmp_byte = (uint8_t *)tmpval;
+
+	rval = 0;
+	for (i = 0; i < max_strlen; i++) {
+		/*
+		 * Check for invalid character, two at a time,
+		 * then convert them starting with first byte.
+		 */
+
+		if ((pchar[i] >= '0') && (pchar[i] <= '9')) {
+			nval = pchar[i] - '0';
+		} else if ((pchar[i] >= 'A') && (pchar[i] <= 'F')) {
+			nval = pchar[i] - 'A' + 10;
+		} else if ((pchar[i] >= 'a') && (pchar[i] <= 'f')) {
+			nval = pchar[i] - 'a' + 10;
+		} else {
+			/* invalid character */
+			rval = 1;
+			break;
+		}
+
+		if (i & BIT_0) {
+			*tmp_byte = *tmp_byte | nval;
+			tmp_byte++;
+		} else {
+			*tmp_byte = *tmp_byte | nval << 4;
+		}
+	}
+
+	if (rval != 0) {
+		/* Encountered invalid character. */
+		return (rval);
+	}
+
+	/* Copy over the converted value. */
+	ret_byte = retval;
+	tmp_byte = tmpval;
+
+	i = max_byte_cnt;
+	k = 0;
+	while (i--) {
+		*ret_byte++ = *tmp_byte++;
+	}
+
+	/* big endian retval[0]; */
+	return (0);
+}
+
+/*
+* qla2x00_get_properties
+*	Find all properties for the specified adapeter in
+*      command line.
+*
+* Input:
+*	ha = adapter block pointer.
+*	cmdline = pointer to command line string
+*
+* Context:
+*	Kernel context.
+*/
+static void
+qla2x00_get_properties(scsi_qla_host_t *ha, char *cmdline) 
+{
+	int	rval;
+	static char propbuf[LINESIZE];
+	uint8_t fc_name[8];
+
+	/* Adapter FC node names. */
+	sprintf(propbuf, "scsi-qla%d-adapter-node", (int) ha->instance);
+	rval = qla2x00_get_prop_16chars(ha, propbuf, fc_name, cmdline);
+	if (rval == QLA_SUCCESS)
+		memcpy(ha->init_cb->node_name, fc_name, WWN_SIZE);
+
+	/* DG 04/07 check portname of adapter */
+	sprintf(propbuf, "scsi-qla%d-adapter-port", (int)ha->instance);
+	rval = qla2x00_get_prop_16chars(ha, propbuf, fc_name, cmdline);
+	if (rval == QLA_SUCCESS &&
+	    memcmp(ha->init_cb->port_name, fc_name, WWN_SIZE)) {
+		/*
+		 * Adapter port name is WWN, and cannot be changed.
+		 * Inform users of the mismatch, then just continue driver
+		 * loading using the original adapter port name in NVRAM.
+		 */
+		qla_printk(KERN_WARNING, ha,
+		    "Found mismatch in adapter port names.\n");
+		qla_printk(KERN_INFO, ha,
+		    "       qla%ld port name found in NVRAM -> "
+		    "%02x%02x%02x%02x%02x%02x%02x%02x\n",
+		    ha->instance,
+		    ha->init_cb->port_name[0],
+		    ha->init_cb->port_name[1],
+		    ha->init_cb->port_name[2],
+		    ha->init_cb->port_name[3],
+		    ha->init_cb->port_name[4],
+		    ha->init_cb->port_name[5],
+		    ha->init_cb->port_name[6],
+		    ha->init_cb->port_name[7]);
+		qla_printk(KERN_INFO, ha,
+		    "      qla%ld port name found on command line -> "
+		    "%02x%02x%02x%02x%02x%02x%02x%02x\n",
+		    ha->instance,
+		    fc_name[0], fc_name[1], fc_name[2], fc_name[3],
+		    fc_name[4], fc_name[5], fc_name[6], fc_name[7]);
+		qla_printk(KERN_INFO, ha,
+		    "      Using port name from NVRAM.\n");
+	}
+
+	qla2x00_cfg_persistent_binding(ha);
+}
+
+/*
+ * qla2x00_cfg_persistent_binding
+ *	Get driver configuration file target persistent binding entries.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static void
+qla2x00_cfg_persistent_binding(scsi_qla_host_t *ha) 
+{
+	int		rval;
+	static char	propbuf[LINESIZE];
+	char		*cmdline = ha->cmdline;
+	uint16_t	tgt;
+	port_id_t	d_id;
+	uint8_t		portid[3];
+	uint8_t		port_name[8];
+
+	for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
+		if (ha->binding_type == BIND_BY_PORT_ID) {
+			sprintf(propbuf, "scsi-qla%d-tgt-%d-di-0-pid",
+			    (int)ha->instance, tgt);
+			rval = qla2x00_get_prop_xstr(ha,
+			    propbuf, portid, sizeof(portid));
+			if (rval != sizeof(portid))
+				continue;
+			
+			memset(&d_id, 0, sizeof(port_id_t));
+			d_id.r.d_id[0] = portid[2];
+			d_id.r.d_id[1] = portid[1];
+			d_id.r.d_id[2] = portid[0];
+		} else {
+			sprintf(propbuf, "scsi-qla%d-tgt-%d-di-0-port",
+			    (int)ha->instance, tgt);
+			rval = qla2x00_get_prop_16chars(ha,
+			    propbuf, port_name, cmdline);
+			if (rval != QLA_SUCCESS)
+				continue;
+
+			/* Fallthru since port_name already populated */
+		}
+
+		/*
+		 * Create target context for device.
+		 */
+		if (ha->binding_type == BIND_BY_PORT_ID) {
+			qla2x00_persistent_bind(ha, NULL, NULL, &d_id, tgt);
+		} else {
+			qla2x00_persistent_bind(ha, NULL, port_name, NULL, tgt);
+		}
+	}
+}
+
+/*
+ * qla2x00_persistent_bind
+ *	Allocates target and fcport.
+ *
+ * Input:
+ *	ha:		adapter state pointer.
+ *	node_name:	node name pointer.
+ *	port_name:	port name pointer.
+ *	d_id:		port ID pointer.
+ *	tgt:		OS target number.
+ *
+ * Returns:
+ *	success = target queue pointer.
+ *	failure = NULL.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static os_tgt_t *
+qla2x00_persistent_bind(scsi_qla_host_t *ha, uint8_t *node_name,
+    uint8_t *port_name, port_id_t *d_id, uint16_t tgt)
+{
+	os_tgt_t	*tq;
+	uint16_t	tgt2;
+
+	/*
+	 * Check for duplicates.
+	 */
+	for (tgt2 = 0; tgt2 < MAX_TARGETS; tgt2++) {
+		if ((tq = TGT_Q(ha, tgt2)) == NULL) {
+			continue;
+		}
+
+		if (ha->binding_type == BIND_BY_PORT_ID) {
+			if (tq->d_id.b24 != d_id->b24) {
+				continue;
+			}
+		} else if (memcmp(tq->port_name, port_name, WWN_SIZE) != 0) {
+			continue;
+		}
+
+		qla_printk(KERN_WARNING, ha,
+		    "Duplicate persistent bindings found for "
+		    "WWPN: %02x%02x%02x%02x%02x%02x%02x%02x.\n", 
+		    port_name[0], port_name[1], port_name[2], port_name[3],
+		    port_name[4], port_name[5], port_name[6], port_name[7]);
+
+		return (tq);
+	}
+
+	tq = qla2x00_tgt_alloc(ha, tgt);
+	if (tq == NULL) {
+		return (NULL);
+	}
+
+	if (node_name != NULL) {
+		memcpy(tq->node_name, node_name, WWN_SIZE);
+	}
+	if (port_name != NULL) {
+		memcpy(tq->port_name, port_name, WWN_SIZE);
+	}
+	if (d_id != NULL) {
+		tq->d_id.b24 = d_id->b24;
+	}
+
+	return (tq);
+}
+#endif
+
+/*
+*  qla2x00_abort_isp
+*      Resets ISP and aborts all outstanding commands.
+*
+* Input:
+*      ha           = adapter block pointer.
+*
+* Returns:
+*      0 = success
+*/
+int
+qla2x00_abort_isp(scsi_qla_host_t *ha)
+{
+	unsigned long flags = 0;
+	uint16_t       cnt;
+	srb_t          *sp;
+	uint8_t        status = 0;
+
+	ENTER("qla2x00_abort_isp");
+
+	if (ha->flags.online) {
+		ha->flags.online = FALSE;
+		clear_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
+		qla2x00_stats.ispAbort++;
+		ha->total_isp_aborts++;  /* used by ioctl */
+		ha->sns_retry_cnt = 0;
+
+		qla_printk(KERN_INFO, ha,
+		    "Performing ISP error recovery - ha= %p.\n", ha);
+		qla2x00_reset_chip(ha);
+
+		if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
+			atomic_set(&ha->loop_state, LOOP_DOWN);
+			atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
+			qla2x00_mark_all_devices_lost(ha);
+		}
+
+		spin_lock_irqsave(&ha->hardware_lock, flags);
+		/* Requeue all commands in outstanding command list. */
+		for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
+			sp = ha->outstanding_cmds[cnt];
+			if (sp) {
+				ha->outstanding_cmds[cnt] = 0;
+				if (ha->actthreads)
+					ha->actthreads--;
+				sp->lun_queue->out_cnt--;
+				sp->flags = 0;
+
+				/*
+				 * Set the cmd host_byte status depending on
+				 * whether the scsi_error_handler is
+				 * active or not.
+ 				 */
+				if (ha->host->eh_active != EH_ACTIVE) {
+					sp->cmd->result = DID_BUS_BUSY << 16;
+				} else {
+					sp->cmd->result = DID_RESET << 16;
+				}
+				sp->cmd->host_scribble = (unsigned char *)NULL;
+				add_to_done_queue(ha, sp);
+			}
+		}
+
+		spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+		qla2x00_nvram_config(ha);
+
+		if (!qla2x00_restart_isp(ha)) {
+			clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
+
+			if (!atomic_read(&ha->loop_down_timer)) {
+				/*
+				 * Issue marker command only when we are going
+				 * to start the I/O .
+				 */
+				ha->marker_needed = 1;
+			}
+
+			ha->flags.online = TRUE;
+
+			/* Enable ISP interrupts. */
+			qla2x00_enable_intrs(ha);
+
+			/* v2.19.5b6 Return all commands */
+			qla2x00_abort_queues(ha, TRUE);
+
+			/* Restart queues that may have been stopped. */
+			qla2x00_restart_queues(ha,TRUE);
+			ha->isp_abort_cnt = 0; 
+			clear_bit(ISP_ABORT_RETRY, &ha->dpc_flags);
+		} else {	/* failed the ISP abort */
+			ha->flags.online = TRUE;
+			if (test_bit(ISP_ABORT_RETRY, &ha->dpc_flags)) {
+				if (ha->isp_abort_cnt == 0) {
+ 					qla_printk(KERN_WARNING, ha,
+					    "ISP error recovery failed - "
+					    "board disabled\n");
+					/* 
+					 * The next call disables the board
+					 * completely.
+					 */
+					qla2x00_reset_adapter(ha);
+					qla2x00_abort_queues(ha, FALSE);
+					ha->flags.online = FALSE;
+					clear_bit(ISP_ABORT_RETRY,
+					    &ha->dpc_flags);
+					status = 0;
+				} else { /* schedule another ISP abort */
+					ha->isp_abort_cnt--;
+					DEBUG(printk("qla%ld: ISP abort - "
+					    "retry remainning %d\n",
+					    ha->host_no, ha->isp_abort_cnt);)
+					status = 1;
+				}
+			} else {
+				ha->isp_abort_cnt = MAX_RETRIES_OF_ISP_ABORT;
+				DEBUG(printk("qla2x00(%ld): ISP error recovery "
+				    "- retrying (%d) more times\n",
+				    ha->host_no, ha->isp_abort_cnt);)
+				set_bit(ISP_ABORT_RETRY, &ha->dpc_flags);
+				status = 1;
+			}
+		}
+		       
+	}
+
+	if (status) {
+		qla_printk(KERN_INFO, ha,
+			"qla2x00_abort_isp: **** FAILED ****\n");
+	} else {
+		DEBUG(printk(KERN_INFO
+				"qla2x00_abort_isp(%ld): exiting.\n",
+				ha->host_no);)
+	}
+
+	return(status);
+}
+
+/*
+*  qla2x00_restart_isp
+*      restarts the ISP after a reset
+*
+* Input:
+*      ha = adapter block pointer.
+*
+* Returns:
+*      0 = success
+*/
+static int
+qla2x00_restart_isp(scsi_qla_host_t *ha)
+{
+	uint8_t		status = 0;
+	device_reg_t	*reg;
+	unsigned long	flags = 0;
+
+	/* If firmware needs to be loaded */
+	if (qla2x00_isp_firmware(ha)) {
+		ha->flags.online = FALSE;
+		if (!(status = qla2x00_chip_diag(ha))) {
+			if (!IS_QLA23XX(ha)) {
+				status = qla2x00_setup_chip(ha);
+				goto done;
+			}
+
+			reg = ha->iobase;
+			spin_lock_irqsave(&ha->hardware_lock, flags);
+			/* Disable SRAM, Instruction RAM and GP RAM parity. */
+			WRT_REG_WORD(&reg->hccr, (HCCR_ENABLE_PARITY + 0x0));
+			spin_unlock_irqrestore(&ha->hardware_lock, flags);
+	
+			status = qla2x00_setup_chip(ha);
+
+			spin_lock_irqsave(&ha->hardware_lock, flags);
+ 
+ 			/* Enable proper parity */
+ 			if (IS_QLA2312(ha) || IS_QLA2322(ha))
+ 				/* SRAM, Instruction RAM and GP RAM parity */
+ 				WRT_REG_WORD(&reg->hccr,
+ 				    (HCCR_ENABLE_PARITY + 0x7));
+ 			else
+ 				/* SRAM parity */
+ 				WRT_REG_WORD(&reg->hccr,
+ 				    (HCCR_ENABLE_PARITY + 0x1));
+
+			spin_unlock_irqrestore(&ha->hardware_lock, flags);
+		}
+	}
+
+ done:
+	if (!status && !(status = qla2x00_init_rings(ha))) {
+		clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
+		if (!(status = qla2x00_fw_ready(ha))) {
+			DEBUG(printk("%s(): Start configure loop, "
+					"status = %d\n",
+					__func__,
+					status);)
+			ha->flags.online = TRUE;
+			do {
+				clear_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
+				qla2x00_configure_loop(ha);
+			} while (!atomic_read(&ha->loop_down_timer) &&
+				!(test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) &&
+				(test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)));
+		}
+
+		/* if no cable then assume it's good */
+		if ((ha->device_flags & DFLG_NO_CABLE)) 
+			status = 0;
+
+		DEBUG(printk("%s(): Configure loop done, status = 0x%x\n",
+				__func__,
+				status);)
+	}
+	return (status);
+}
+
+/*
+* qla2x00_reset_adapter
+*      Reset adapter.
+*
+* Input:
+*      ha = adapter block pointer.
+*/
+static void
+qla2x00_reset_adapter(scsi_qla_host_t *ha)
+{
+	unsigned long flags = 0;
+	device_reg_t *reg = ha->iobase;
+
+	ENTER(__func__);
+
+	ha->flags.online = FALSE;
+	qla2x00_disable_intrs(ha);
+	/* Reset RISC processor. */
+	spin_lock_irqsave(&ha->hardware_lock, flags);
+	WRT_REG_WORD(&reg->hccr, HCCR_RESET_RISC);
+	WRT_REG_WORD(&reg->hccr, HCCR_RELEASE_RISC);
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+	LEAVE(__func__);
+}
diff -puN /dev/null drivers/scsi/qla2xxx/qla_inline.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/qla_inline.h	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,242 @@
+/*
+ *                  QLOGIC LINUX SOFTWARE
+ *
+ * QLogic ISP2x00 device driver for Linux 2.6.x
+ * Copyright (C) 2003 QLogic Corporation
+ * (www.qlogic.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+
+
+static __inline__ uint16_t qla2x00_debounce_register(volatile uint16_t *);
+/*
+ * qla2x00_debounce_register
+ *      Debounce register.
+ *
+ * Input:
+ *      port = register address.
+ *
+ * Returns:
+ *      register value.
+ */
+static __inline__ uint16_t
+qla2x00_debounce_register(volatile uint16_t *addr) 
+{
+	volatile uint16_t first;
+	volatile uint16_t second;
+
+	do {
+		first = RD_REG_WORD(addr);
+		barrier();
+		cpu_relax();
+		second = RD_REG_WORD(addr);
+	} while (first != second);
+
+	return (first);
+}
+
+static __inline__ int qla2x00_normalize_dma_addr(
+    dma_addr_t *e_addr,  uint32_t *e_len,
+    dma_addr_t *ne_addr, uint32_t *ne_len);
+
+/**
+ * qla2x00_normalize_dma_addr() - Normalize an DMA address.
+ * @e_addr: Raw DMA address
+ * @e_len: Raw DMA length
+ * @ne_addr: Normalized second DMA address
+ * @ne_len: Normalized second DMA length
+ *
+ * If the address does not span a 4GB page boundary, the contents of @ne_addr
+ * and @ne_len are undefined.  @e_len is updated to reflect a normalization.
+ *
+ * Example:
+ *
+ * 	ffffabc0ffffeeee	(e_addr) start of DMA address
+ * 	0000000020000000	(e_len)  length of DMA transfer
+ *	ffffabc11fffeeed	end of DMA transfer
+ *
+ * Is the 4GB boundary crossed?
+ *
+ * 	ffffabc0ffffeeee	(e_addr)
+ *	ffffabc11fffeeed	(e_addr + e_len - 1)
+ *	00000001e0000003	((e_addr ^ (e_addr + e_len - 1))
+ *	0000000100000000	((e_addr ^ (e_addr + e_len - 1)) & ~(0xffffffff)
+ *
+ * Compute start of second DMA segment:
+ *
+ * 	ffffabc0ffffeeee	(e_addr)
+ *	ffffabc1ffffeeee	(0x100000000 + e_addr)
+ *	ffffabc100000000	(0x100000000 + e_addr) & ~(0xffffffff)
+ *	ffffabc100000000	(ne_addr)
+ *	
+ * Compute length of second DMA segment:
+ *
+ *	00000000ffffeeee	(e_addr & 0xffffffff)
+ *	0000000000001112	(0x100000000 - (e_addr & 0xffffffff))
+ *	000000001fffeeee	(e_len - (0x100000000 - (e_addr & 0xffffffff))
+ *	000000001fffeeee	(ne_len)
+ *
+ * Adjust length of first DMA segment
+ *
+ * 	0000000020000000	(e_len)
+ *	0000000000001112	(e_len - ne_len)
+ *	0000000000001112	(e_len)
+ *
+ * Returns non-zero if the specified address was normalized, else zero.
+ */
+static __inline__ int
+qla2x00_normalize_dma_addr(
+    dma_addr_t *e_addr,  uint32_t *e_len,
+    dma_addr_t *ne_addr, uint32_t *ne_len)
+{
+	int normalized;
+
+	normalized = 0;
+	if ((*e_addr ^ (*e_addr + *e_len - 1)) & ~(0xFFFFFFFFULL)) {
+		/* Compute normalized crossed address and len */
+		*ne_addr = (0x100000000ULL + *e_addr) & ~(0xFFFFFFFFULL);
+		*ne_len = *e_len - (0x100000000ULL - (*e_addr & 0xFFFFFFFFULL));
+		*e_len -= *ne_len;
+
+		normalized++;
+	}
+	return (normalized);
+}
+
+static __inline__ void qla2x00_poll(scsi_qla_host_t *);
+static inline void 
+qla2x00_poll(scsi_qla_host_t *ha)
+{
+	qla2x00_intr_handler(0, ha, NULL);
+}
+
+
+static __inline__ void qla2x00_enable_intrs(scsi_qla_host_t *);
+static __inline__ void qla2x00_disable_intrs(scsi_qla_host_t *);
+
+static inline void 
+qla2x00_enable_intrs(scsi_qla_host_t *ha)
+{
+	unsigned long flags = 0;
+	device_reg_t *reg;
+
+	spin_lock_irqsave(&ha->hardware_lock, flags);
+	reg = ha->iobase;
+	ha->interrupts_on = 1;
+	/* enable risc and host interrupts */
+	WRT_REG_WORD(&reg->ictrl, ICR_EN_INT | ICR_EN_RISC);
+	RD_REG_WORD(&reg->ictrl);
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+}
+
+static inline void 
+qla2x00_disable_intrs(scsi_qla_host_t *ha)
+{
+	unsigned long flags = 0;
+	device_reg_t *reg;
+
+	spin_lock_irqsave(&ha->hardware_lock, flags);
+	reg = ha->iobase;
+	ha->interrupts_on = 0;
+	/* disable risc and host interrupts */
+	WRT_REG_WORD(&reg->ictrl, 0);
+	RD_REG_WORD(&reg->ictrl);
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
+}
+
+
+static __inline__ int qla2x00_is_wwn_zero(uint8_t *);
+
+/*
+ * qla2x00_is_wwn_zero - Check for zero node name
+ *
+ * Input:
+ *      wwn = Pointer to WW name to check
+ *
+ * Returns:
+ *      TRUE if name is 0 else FALSE
+ *
+ * Context:
+ *      Kernel context.
+ */
+static __inline__ int
+qla2x00_is_wwn_zero(uint8_t *wwn)
+{
+	int cnt;
+
+	for (cnt = 0; cnt < WWN_SIZE ; cnt++, wwn++) {
+		if (*wwn != 0)
+			break;
+	}
+	/* if zero return TRUE */
+	if (cnt == WWN_SIZE)
+		return (1);
+	else
+		return (0);
+}
+
+static __inline__ uint8_t
+qla2x00_suspend_lun(scsi_qla_host_t *, os_lun_t *, int, int);
+static __inline__ uint8_t
+qla2x00_delay_lun(scsi_qla_host_t *, os_lun_t *, int);
+
+static __inline__ uint8_t
+qla2x00_suspend_lun(scsi_qla_host_t *ha, os_lun_t *lq, int time, int count)
+{
+	return (__qla2x00_suspend_lun(ha, lq, time, count, 0));
+}
+
+static __inline__ uint8_t
+qla2x00_delay_lun(scsi_qla_host_t *ha, os_lun_t *lq, int time)
+{
+	return (__qla2x00_suspend_lun(ha, lq, time, 1, 1));
+}
+
+static __inline__ void qla2x00_check_fabric_devices(scsi_qla_host_t *);
+/*
+ * This routine will wait for fabric devices for
+ * the reset delay.
+ */
+static __inline__ void qla2x00_check_fabric_devices(scsi_qla_host_t *ha) 
+{
+	uint16_t	fw_state;
+
+	qla2x00_get_firmware_state(ha, &fw_state);
+}
+
+/**
+ * qla2x00_issue_marker() - Issue a Marker IOCB if necessary.
+ * @ha: HA context
+ * @ha_locked: is function called with the hardware lock
+ *
+ * Returns non-zero if a failure occured, else zero.
+ */
+static inline int
+qla2x00_issue_marker(scsi_qla_host_t *ha, int ha_locked)
+{
+	/* Send marker if required */
+	if (ha->marker_needed != 0) {
+		if (ha_locked) {
+			if (__qla2x00_marker(ha, 0, 0, MK_SYNC_ALL) !=
+			    QLA_SUCCESS)
+				return (QLA_FUNCTION_FAILED);
+		} else {
+			if (qla2x00_marker(ha, 0, 0, MK_SYNC_ALL) !=
+			    QLA_SUCCESS)
+				return (QLA_FUNCTION_FAILED);
+		}
+		ha->marker_needed = 0;
+	}
+	return (QLA_SUCCESS);
+}
diff -puN /dev/null drivers/scsi/qla2xxx/qla_iocb.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/qla_iocb.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,764 @@
+/******************************************************************************
+ *                  QLOGIC LINUX SOFTWARE
+ *
+ * QLogic ISP2x00 device driver for Linux 2.6.x
+ * Copyright (C) 2003 QLogic Corporation
+ * (www.qlogic.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ ******************************************************************************/
+
+#include "qla_os.h"
+#include "qla_def.h"
+
+static inline uint16_t qla2x00_get_cmd_direction(struct scsi_cmnd *cmd);
+static inline cont_entry_t *qla2x00_prep_cont_type0_iocb(scsi_qla_host_t *);
+static inline cont_a64_entry_t *qla2x00_prep_cont_type1_iocb(scsi_qla_host_t *);
+
+/**
+ * qla2x00_get_cmd_direction() - Determine control_flag data direction.
+ * @cmd: SCSI command
+ *
+ * Returns the proper CF_* direction based on CDB.
+ */
+static inline uint16_t
+qla2x00_get_cmd_direction(struct scsi_cmnd *cmd)
+{
+	uint16_t cflags;
+
+	cflags = 0;
+
+	/* Set transfer direction */
+	if (cmd->sc_data_direction == DMA_TO_DEVICE)
+		cflags = CF_WRITE;
+	else if (cmd->sc_data_direction == DMA_FROM_DEVICE)
+		cflags = CF_READ;
+	else {
+		switch (cmd->data_cmnd[0]) {
+		case WRITE_6:
+		case WRITE_10:
+		case WRITE_12:
+		case WRITE_BUFFER:
+		case WRITE_LONG:
+		case WRITE_SAME:
+		case WRITE_VERIFY:
+		case WRITE_VERIFY_12:
+		case FORMAT_UNIT:
+		case SEND_VOLUME_TAG:
+		case MODE_SELECT:
+		case SEND_DIAGNOSTIC:
+		case MODE_SELECT_10:
+			cflags = CF_WRITE;
+			break;
+		default:
+			cflags = CF_READ;
+			break;
+		}
+	}
+	return (cflags);
+}
+
+/**
+ * qla2x00_calc_iocbs_32() - Determine number of Command Type 2 and
+ * Continuation Type 0 IOCBs to allocate.
+ *
+ * @dsds: number of data segment decriptors needed
+ *
+ * Returns the number of IOCB entries needed to store @dsds.
+ */
+uint16_t
+qla2x00_calc_iocbs_32(uint16_t dsds)
+{
+	uint16_t iocbs;
+
+	iocbs = 1;
+	if (dsds > 3) {
+		iocbs += (dsds - 3) / 7;
+		if ((dsds - 3) % 7)
+			iocbs++;
+	}
+	return (iocbs);
+}
+
+/**
+ * qla2x00_calc_iocbs_64() - Determine number of Command Type 3 and
+ * Continuation Type 1 IOCBs to allocate.
+ *
+ * @dsds: number of data segment decriptors needed
+ *
+ * Returns the number of IOCB entries needed to store @dsds.
+ */
+uint16_t
+qla2x00_calc_iocbs_64(uint16_t dsds)
+{
+	uint16_t iocbs;
+
+	iocbs = 1;
+	if (dsds > 2) {
+		iocbs += (dsds - 2) / 5;
+		if ((dsds - 2) % 5)
+			iocbs++;
+	}
+	return (iocbs);
+}
+
+/**
+ * qla2x00_prep_cont_type0_iocb() - Initialize a Continuation Type 0 IOCB.
+ * @ha: HA context
+ *
+ * Returns a pointer to the Continuation Type 0 IOCB packet.
+ */
+static inline cont_entry_t *
+qla2x00_prep_cont_type0_iocb(scsi_qla_host_t *ha)
+{
+	cont_entry_t *cont_pkt;
+
+	/* Adjust ring index. */
+	ha->req_ring_index++;
+	if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
+		ha->req_ring_index = 0;
+		ha->request_ring_ptr = ha->request_ring;
+	} else {
+		ha->request_ring_ptr++;
+	}
+
+	cont_pkt = (cont_entry_t *)ha->request_ring_ptr;
+
+	/* Load packet defaults. */
+	*((uint32_t *)(&cont_pkt->entry_type)) =
+	    __constant_cpu_to_le32(CONTINUE_TYPE);
+
+	return (cont_pkt);
+}
+
+/**
+ * qla2x00_prep_cont_type1_iocb() - Initialize a Continuation Type 1 IOCB.
+ * @ha: HA context
+ *
+ * Returns a pointer to the continuation type 1 IOCB packet.
+ */
+static inline cont_a64_entry_t *
+qla2x00_prep_cont_type1_iocb(scsi_qla_host_t *ha)
+{
+	cont_a64_entry_t *cont_pkt;
+
+	/* Adjust ring index. */
+	ha->req_ring_index++;
+	if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
+		ha->req_ring_index = 0;
+		ha->request_ring_ptr = ha->request_ring;
+	} else {
+		ha->request_ring_ptr++;
+	}
+
+	cont_pkt = (cont_a64_entry_t *)ha->request_ring_ptr;
+
+	/* Load packet defaults. */
+	*((uint32_t *)(&cont_pkt->entry_type)) =
+	    __constant_cpu_to_le32(CONTINUE_A64_TYPE);
+
+	return (cont_pkt);
+}
+
+/**
+ * qla2x00_build_scsi_iocbs_32() - Build IOCB command utilizing 32bit
+ * capable IOCB types.
+ *
+ * @sp: SRB command to process
+ * @cmd_pkt: Command type 2 IOCB
+ * @tot_dsds: Total number of segments to transfer
+ */
+void qla2x00_build_scsi_iocbs_32(srb_t *sp, cmd_entry_t *cmd_pkt,
+    uint16_t tot_dsds)
+{
+	uint16_t	avail_dsds;
+	uint32_t	*cur_dsd;
+	scsi_qla_host_t	*ha;
+	struct scsi_cmnd *cmd;
+
+	cmd = sp->cmd;
+
+	/* Update entry type to indicate Command Type 2 IOCB */
+	*((uint32_t *)(&cmd_pkt->entry_type)) =
+	    __constant_cpu_to_le32(COMMAND_TYPE);
+
+	/* No data transfer */
+	if (cmd->request_bufflen == 0 || cmd->sc_data_direction == DMA_NONE) {
+		cmd_pkt->byte_count = __constant_cpu_to_le32(0);
+		return;
+	}
+
+	ha = sp->ha;
+
+	cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(cmd));
+
+	/* Three DSDs are available in the Command Type 2 IOCB */
+	avail_dsds = 3;
+	cur_dsd = (uint32_t *)&cmd_pkt->dseg_0_address;
+
+	/* Load data segments */
+	if (cmd->use_sg != 0) {
+		struct	scatterlist *cur_seg;
+		struct	scatterlist *end_seg;
+
+		cur_seg = (struct scatterlist *)cmd->request_buffer;
+		end_seg = cur_seg + tot_dsds;
+		while (cur_seg < end_seg) {
+			cont_entry_t	*cont_pkt;
+
+			/* Allocate additional continuation packets? */
+			if (avail_dsds == 0) {
+				/*
+				 * Seven DSDs are available in the Continuation
+				 * Type 0 IOCB.
+				 */
+				cont_pkt = qla2x00_prep_cont_type0_iocb(ha);
+				cur_dsd = (uint32_t *)&cont_pkt->dseg_0_address;
+				avail_dsds = 7;
+			}
+
+			*cur_dsd++ = cpu_to_le32(sg_dma_address(cur_seg));
+			*cur_dsd++ = cpu_to_le32(sg_dma_len(cur_seg));
+			avail_dsds--;
+
+			cur_seg++;
+		}
+	} else {
+		dma_addr_t	req_dma;
+		struct page	*page;
+		unsigned long	offset;
+
+		page = virt_to_page(cmd->request_buffer);
+		offset = ((unsigned long)cmd->request_buffer & ~PAGE_MASK);
+		req_dma = pci_map_page(ha->pdev, page, offset,
+		    cmd->request_bufflen, cmd->sc_data_direction);
+
+		sp->dma_handle = req_dma;
+
+		*cur_dsd++ = cpu_to_le32(req_dma);
+		*cur_dsd++ = cpu_to_le32(cmd->request_bufflen);
+	}
+}
+
+/**
+ * qla2x00_build_scsi_iocbs_64() - Build IOCB command utilizing 64bit
+ * capable IOCB types.
+ *
+ * @sp: SRB command to process
+ * @cmd_pkt: Command type 3 IOCB
+ * @tot_dsds: Total number of segments to transfer
+ */
+void qla2x00_build_scsi_iocbs_64(srb_t *sp, cmd_entry_t *cmd_pkt,
+    uint16_t tot_dsds)
+{
+	uint16_t	avail_dsds;
+	uint32_t	*cur_dsd;
+	scsi_qla_host_t	*ha;
+	struct scsi_cmnd *cmd;
+
+	cmd = sp->cmd;
+
+	/* Update entry type to indicate Command Type 3 IOCB */
+	*((uint32_t *)(&cmd_pkt->entry_type)) =
+	    __constant_cpu_to_le32(COMMAND_A64_TYPE);
+
+	/* No data transfer */
+	if (cmd->request_bufflen == 0 || cmd->sc_data_direction == DMA_NONE) {
+		cmd_pkt->byte_count = __constant_cpu_to_le32(0);
+		return;
+	}
+
+	ha = sp->ha;
+
+	cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(cmd));
+
+	/* Two DSDs are available in the Command Type 3 IOCB */
+	avail_dsds = 2;
+	cur_dsd = (uint32_t *)&cmd_pkt->dseg_0_address;
+
+	/* Load data segments */
+	if (cmd->use_sg != 0) {
+		struct	scatterlist *cur_seg;
+		struct	scatterlist *end_seg;
+
+		cur_seg = (struct scatterlist *)cmd->request_buffer;
+		end_seg = cur_seg + tot_dsds;
+		while (cur_seg < end_seg) {
+			dma_addr_t	sle_dma;
+			cont_a64_entry_t *cont_pkt;
+
+			/* Allocate additional continuation packets? */
+			if (avail_dsds == 0) {
+				/*
+				 * Five DSDs are available in the Continuation
+				 * Type 1 IOCB.
+				 */
+				cont_pkt = qla2x00_prep_cont_type1_iocb(ha);
+				cur_dsd = (uint32_t *)cont_pkt->dseg_0_address;
+				avail_dsds = 5;
+			}
+
+			sle_dma = sg_dma_address(cur_seg);
+			*cur_dsd++ = cpu_to_le32(LSD(sle_dma));
+			*cur_dsd++ = cpu_to_le32(MSD(sle_dma));
+			*cur_dsd++ = cpu_to_le32(sg_dma_len(cur_seg));
+			avail_dsds--;
+
+			cur_seg++;
+		}
+	} else {
+		dma_addr_t	req_dma;
+		struct page	*page;
+		unsigned long	offset;
+
+		page = virt_to_page(cmd->request_buffer);
+		offset = ((unsigned long)cmd->request_buffer & ~PAGE_MASK);
+		req_dma = pci_map_page(ha->pdev, page, offset,
+		    cmd->request_bufflen, cmd->sc_data_direction);
+
+		sp->dma_handle = req_dma;
+
+		*cur_dsd++ = cpu_to_le32(LSD(req_dma));
+		*cur_dsd++ = cpu_to_le32(MSD(req_dma));
+		*cur_dsd++ = cpu_to_le32(cmd->request_bufflen);
+	}
+}
+
+/**
+ * qla2x00_start_scsi() - Send a SCSI command to the ISP
+ * @sp: command to send to the ISP
+ *
+ * Returns non-zero if a failure occured, else zero.
+ */
+int
+qla2x00_start_scsi(srb_t *sp)
+{
+	int		ret;
+	unsigned long   flags;
+	scsi_qla_host_t	*ha;
+	fc_lun_t	*fclun;
+	struct scsi_cmnd *cmd;
+	uint32_t	*clr_ptr;
+	uint32_t        index;
+	uint32_t	handle;
+	uint16_t	cnt, tot_dsds, req_cnt;
+	cmd_entry_t	*cmd_pkt;
+	uint32_t        timeout;
+	struct scatterlist *sg;
+
+	device_reg_t	*reg;
+
+	/* Setup device pointers. */
+	ret = 0;
+	fclun = sp->lun_queue->fclun;
+	ha = fclun->fcport->ha;
+	cmd = sp->cmd;
+	reg = ha->iobase;
+
+	/* Send marker if required */
+	if (ha->marker_needed != 0) {
+		if (qla2x00_marker(ha, 0, 0, MK_SYNC_ALL) != QLA_SUCCESS) {
+			return (QLA_FUNCTION_FAILED);
+		}
+		ha->marker_needed = 0;
+	}
+
+	/* Calculate number of segments and entries required */
+	tot_dsds = 0;
+	if (cmd->use_sg) {
+		sg = (struct scatterlist *) cmd->request_buffer;
+		tot_dsds = pci_map_sg(ha->pdev, sg, cmd->use_sg,
+		    cmd->sc_data_direction);
+	} else if (cmd->request_bufflen) {   /* Single segment transfer */
+		tot_dsds++;
+	}
+	req_cnt = (ha->calc_request_entries)(tot_dsds);
+
+	/* Acquire ring specific lock */
+	spin_lock_irqsave(&ha->hardware_lock, flags);
+
+	if (ha->req_q_cnt < (req_cnt + 2)) {
+		/* Calculate number of free request entries */
+		cnt = RD_REG_WORD(ISP_REQ_Q_OUT(ha, reg));
+		if (ha->req_ring_index < cnt)
+			ha->req_q_cnt = cnt - ha->req_ring_index;
+		else
+			ha->req_q_cnt = REQUEST_ENTRY_CNT -
+			    (ha->req_ring_index - cnt);
+	}
+
+	/* If no room for request in request ring */
+	if (ha->req_q_cnt < (req_cnt + 2)) {
+		DEBUG5(printk("scsi(%ld): in-ptr=%x req_q_cnt=%x "
+		    "tot_dsds=%x.\n",
+		    ha->host_no, ha->req_ring_index, ha->req_q_cnt, tot_dsds));
+
+		goto queuing_error;
+	}
+
+	/* Check for room in outstanding command list. */
+	handle = ha->current_outstanding_cmd;
+	for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) {
+		handle++;
+		if (handle == MAX_OUTSTANDING_COMMANDS)
+			handle = 1;
+		if (ha->outstanding_cmds[handle] == 0) {
+			ha->current_outstanding_cmd = handle;
+			break;
+		}
+	}
+	if (index == MAX_OUTSTANDING_COMMANDS) {
+		DEBUG5(printk("scsi(%ld): Unable to queue command -- NO ROOM "
+		    "IN OUTSTANDING ARRAY (req_q_cnt=%x).\n",
+		    ha->host_no, ha->req_q_cnt));
+		goto queuing_error;
+	}
+
+	/* Build command packet */
+	ha->outstanding_cmds[handle] = sp;
+	sp->ha = ha;
+	sp->cmd->host_scribble = (unsigned char *)(unsigned long)handle;
+	ha->req_q_cnt -= req_cnt;
+
+	cmd_pkt = (cmd_entry_t *)ha->request_ring_ptr;
+	cmd_pkt->handle = handle;
+	/* Zero out remaining portion of packet. */
+	clr_ptr = (uint32_t *)cmd_pkt + 2;
+	memset(clr_ptr, 0, REQUEST_ENTRY_SIZE - 8);
+	cmd_pkt->dseg_count = cpu_to_le16(tot_dsds);
+
+	/* Set target ID */
+	SET_TARGET_ID(ha, cmd_pkt->target, fclun->fcport->loop_id);
+
+	/* Set LUN number*/
+	cmd_pkt->lun = cpu_to_le16(fclun->lun);
+
+	/* Update tagged queuing modifier */
+	cmd_pkt->control_flags = __constant_cpu_to_le16(CF_SIMPLE_TAG);
+	if (cmd->device->tagged_supported) {
+		switch (cmd->tag) {
+		case HEAD_OF_QUEUE_TAG:
+			cmd_pkt->control_flags =
+			    __constant_cpu_to_le16(CF_HEAD_TAG);
+			break;
+		case ORDERED_QUEUE_TAG:
+			cmd_pkt->control_flags =
+			    __constant_cpu_to_le16(CF_ORDERED_TAG);
+			break;
+		}
+	}
+
+	/*
+	 * Allocate at least 5 (+ QLA_CMD_TIMER_DELTA) seconds for RISC timeout.
+	 */
+	timeout = (uint32_t)(cmd->timeout_per_command / HZ);
+	if (timeout > 65535)
+		cmd_pkt->timeout = __constant_cpu_to_le16(0);
+	else if (timeout > 25)
+		cmd_pkt->timeout = cpu_to_le16((uint16_t)timeout -
+		    (5 + QLA_CMD_TIMER_DELTA));
+	else
+		cmd_pkt->timeout = cpu_to_le16((uint16_t)timeout);
+
+	/* Load SCSI command packet. */
+	memcpy(cmd_pkt->scsi_cdb, cmd->cmnd, cmd->cmd_len);
+	cmd_pkt->byte_count = cpu_to_le32((uint32_t)cmd->request_bufflen);
+
+	/* Build IOCB segments */
+	(ha->build_scsi_iocbs)(sp, cmd_pkt, tot_dsds);
+
+	/* Set total data segment count. */
+	cmd_pkt->entry_count = (uint8_t)req_cnt;
+
+	/* Adjust ring index. */
+	ha->req_ring_index++;
+	if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
+		ha->req_ring_index = 0;
+		ha->request_ring_ptr = ha->request_ring;
+	} else
+		ha->request_ring_ptr++;
+
+	ha->actthreads++;
+	ha->total_ios++;
+	sp->lun_queue->out_cnt++;
+	sp->flags |= SRB_DMA_VALID;
+	sp->state = SRB_ACTIVE_STATE;
+	sp->u_start = jiffies;
+
+	/* Set chip new ring index. */
+	WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), ha->req_ring_index);
+	RD_REG_WORD(ISP_REQ_Q_IN(ha, reg));	/* PCI Posting. */
+
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
+	return (QLA_SUCCESS);
+
+queuing_error:
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+	if (cmd->use_sg)
+		pci_unmap_sg(ha->pdev, sg, cmd->use_sg, cmd->sc_data_direction);
+
+	return (QLA_FUNCTION_FAILED);
+}
+
+/**
+ * qla2x00_marker() - Send a marker IOCB to the firmware.
+ * @ha: HA context
+ * @loop_id: loop ID
+ * @lun: LUN
+ * @type: marker modifier
+ *
+ * Can be called from both normal and interrupt context.
+ *
+ * Returns non-zero if a failure occured, else zero.
+ */
+int
+__qla2x00_marker(scsi_qla_host_t *ha, uint16_t loop_id, uint16_t lun,
+    uint8_t type)
+{
+	mrk_entry_t	*pkt;
+
+	ENTER(__func__);
+
+	pkt = (mrk_entry_t *)qla2x00_req_pkt(ha);
+	if (pkt == NULL) {
+		DEBUG2_3(printk("%s(): **** FAILED ****\n", __func__));
+
+		return (QLA_FUNCTION_FAILED);
+	}
+
+	pkt->entry_type = MARKER_TYPE;
+	pkt->modifier = type;
+
+	if (type != MK_SYNC_ALL) {
+		pkt->lun = cpu_to_le16(lun);
+		SET_TARGET_ID(ha, pkt->target, loop_id);
+	}
+
+	/* Issue command to ISP */
+	qla2x00_isp_cmd(ha);
+
+	LEAVE(__func__);
+
+	return (QLA_SUCCESS);
+}
+
+int 
+qla2x00_marker(scsi_qla_host_t *ha, uint16_t loop_id, uint16_t lun,
+    uint8_t type)
+{
+	int ret;
+	unsigned long flags = 0;
+
+	spin_lock_irqsave(&ha->hardware_lock, flags);
+	ret = __qla2x00_marker(ha, loop_id, lun, type);
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+	return (ret);
+}
+
+/**
+ * qla2x00_req_pkt() - Retrieve a request packet from the request ring.
+ * @ha: HA context
+ *
+ * Note: The caller must hold the hardware lock before calling this routine.
+ *
+ * Returns NULL if function failed, else, a pointer to the request packet.
+ */
+request_t *
+qla2x00_req_pkt(scsi_qla_host_t *ha)
+{
+	device_reg_t	*reg = ha->iobase;
+	request_t	*pkt = NULL;
+	uint16_t	cnt;
+	uint32_t	*dword_ptr;
+	uint32_t	timer;
+	uint16_t	req_cnt = 1;
+
+	ENTER(__func__);
+
+	/* Wait 1 second for slot. */
+	for (timer = HZ; timer; timer--) {
+		if ((req_cnt + 2) >= ha->req_q_cnt) {
+			/* Calculate number of free request entries. */
+			cnt = qla2x00_debounce_register(ISP_REQ_Q_OUT(ha, reg));
+			if  (ha->req_ring_index < cnt)
+				ha->req_q_cnt = cnt - ha->req_ring_index;
+			else
+				ha->req_q_cnt = REQUEST_ENTRY_CNT -
+				    (ha->req_ring_index - cnt);
+		}
+		/* If room for request in request ring. */
+		if ((req_cnt + 2) < ha->req_q_cnt) {
+			ha->req_q_cnt--;
+			pkt = ha->request_ring_ptr;
+
+			/* Zero out packet. */
+			dword_ptr = (uint32_t *)pkt;
+			for (cnt = 0; cnt < REQUEST_ENTRY_SIZE / 4; cnt++)
+				*dword_ptr++ = 0;
+
+			/* Set system defined field. */
+			pkt->sys_define = (uint8_t)ha->req_ring_index;
+
+			/* Set entry count. */
+			pkt->entry_count = 1;
+
+			break;
+		}
+
+		/* Release ring specific lock */
+		spin_unlock(&ha->hardware_lock);
+
+		udelay(2);   /* 2 us */
+
+		/* Check for pending interrupts. */
+		/* During init we issue marker directly */
+		if (!ha->marker_needed)
+			qla2x00_poll(ha);
+
+		spin_lock_irq(&ha->hardware_lock);
+	}
+	if (!pkt) {
+		DEBUG2_3(printk("%s(): **** FAILED ****\n", __func__));
+	}
+
+	LEAVE(__func__);
+
+	return (pkt);
+}
+
+/**
+ * qla2x00_ms_req_pkt() - Retrieve a Management Server request packet from
+ * 				the request ring.
+ * @ha: HA context
+ * @sp: pointer to handle post function call
+ *
+ * Note: The caller must hold the hardware lock before calling this routine.
+ *
+ * Returns NULL if function failed, else, a pointer to the request packet.
+ */
+request_t *
+qla2x00_ms_req_pkt(scsi_qla_host_t *ha, srb_t  *sp)
+{
+	device_reg_t	*reg = ha->iobase;
+	request_t	*pkt = NULL;
+	uint16_t	cnt, i, index;
+	uint32_t	*dword_ptr;
+	uint32_t	timer;
+	uint8_t		found = 0;
+	uint16_t	req_cnt = 1;
+
+	ENTER(__func__);
+
+	/* Wait 1 second for slot. */
+	for (timer = HZ; timer; timer--) {
+		if ((req_cnt + 2) >= ha->req_q_cnt) {
+			/* Calculate number of free request entries. */
+			cnt = qla2x00_debounce_register(ISP_REQ_Q_OUT(ha, reg));
+			if (ha->req_ring_index < cnt) {
+				ha->req_q_cnt = cnt - ha->req_ring_index;
+			} else {
+				ha->req_q_cnt = REQUEST_ENTRY_CNT -
+				    (ha->req_ring_index - cnt);
+			}
+		}
+
+		/* Check for room in outstanding command list. */
+		cnt = ha->current_outstanding_cmd;
+		for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) {
+			cnt++;
+			if (cnt == MAX_OUTSTANDING_COMMANDS)
+				cnt = 1;
+
+			if (ha->outstanding_cmds[cnt] == 0) {
+				found = 1;
+				ha->current_outstanding_cmd = cnt;
+				break;
+			}
+		}
+
+		/* If room for request in request ring. */
+		if (found && (req_cnt + 2) < ha->req_q_cnt) {
+			pkt = ha->request_ring_ptr;
+
+			/* Zero out packet. */
+			dword_ptr = (uint32_t *)pkt;
+			for (i = 0; i < REQUEST_ENTRY_SIZE / 4; i++ )
+				*dword_ptr++ = 0;
+
+			DEBUG5(printk("%s(): putting sp=%p in "
+			    "outstanding_cmds[%x]\n",
+			    __func__,
+			    sp, cnt));
+
+			ha->outstanding_cmds[cnt] = sp;
+
+			/* save the handle */
+			sp->cmd->host_scribble = (unsigned char *) (u_long) cnt;
+			CMD_SP(sp->cmd) = (void *)sp;
+
+			ha->req_q_cnt--;
+			pkt->handle = (uint32_t)cnt;
+
+			/* Set system defined field. */
+			pkt->sys_define = (uint8_t)ha->req_ring_index;
+			pkt->entry_status = 0;
+
+			break;
+		}
+
+		/* Release ring specific lock */
+		spin_unlock(&ha->hardware_lock);
+		udelay(20);
+
+		/* Check for pending interrupts. */
+		qla2x00_poll(ha);
+
+		spin_lock_irq(&ha->hardware_lock);
+	}
+	if (!pkt) {
+		DEBUG2_3(printk("%s(): **** FAILED ****\n", __func__));
+	}
+
+	LEAVE(__func__);
+
+	return (pkt);
+}
+
+/**
+ * qla2x00_isp_cmd() - Modify the request ring pointer.
+ * @ha: HA context
+ *
+ * Note: The caller must hold the hardware lock before calling this routine.
+ */
+void
+qla2x00_isp_cmd(scsi_qla_host_t *ha)
+{
+	device_reg_t *reg = ha->iobase;
+
+	DEBUG5(printk("%s(): IOCB data:\n", __func__));
+	DEBUG5(qla2x00_dump_buffer(
+	    (uint8_t *)ha->request_ring_ptr, REQUEST_ENTRY_SIZE));
+
+	/* Adjust ring index. */
+	ha->req_ring_index++;
+	if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
+		ha->req_ring_index = 0;
+		ha->request_ring_ptr = ha->request_ring;
+	} else
+		ha->request_ring_ptr++;
+
+	/* Set chip new ring index. */
+	WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), ha->req_ring_index);
+	RD_REG_WORD(ISP_REQ_Q_IN(ha, reg));	/* PCI Posting. */
+}
diff -puN /dev/null drivers/scsi/qla2xxx/qla_isr.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/qla_isr.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,1421 @@
+/*
+ *                  QLOGIC LINUX SOFTWARE
+ *
+ * QLogic ISP2x00 device driver for Linux 2.6.x
+ * Copyright (C) 2003 QLogic Corporation
+ * (www.qlogic.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include "qla_os.h"
+
+#include "qla_def.h"
+
+/* XXX(hch): this is ugly, but we don't want to pull in exioctl.h */
+#ifndef EXT_DEF_PORTSPEED_1GBIT
+#define EXT_DEF_PORTSPEED_1GBIT		1
+#define EXT_DEF_PORTSPEED_2GBIT		2
+#endif
+
+static void qla2x00_mbx_completion(scsi_qla_host_t *, uint16_t);
+static void qla2x00_async_event(scsi_qla_host_t *, uint32_t);
+static void qla2x00_process_completed_request(struct scsi_qla_host *, uint32_t);
+void qla2x00_process_response_queue(struct scsi_qla_host *);
+static void qla2x00_status_entry(scsi_qla_host_t *, sts_entry_t *);
+static void qla2x00_status_cont_entry(scsi_qla_host_t *, sts_cont_entry_t *);
+static void qla2x00_error_entry(scsi_qla_host_t *, sts_entry_t *);
+static void qla2x00_ms_entry(scsi_qla_host_t *, ms_iocb_entry_t *);
+
+static int qla2x00_check_sense(struct scsi_cmnd *cp, os_lun_t *);
+
+/**
+ * qla2x00_intr_handler() - Process interrupts for the ISP.
+ * @irq:
+ * @dev_id: SCSI driver HA context
+ * @regs:
+ *
+ * Called by system whenever the host adapter generates an interrupt.
+ *
+ * Returns handled flag.
+ */
+irqreturn_t
+qla2x00_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
+{
+	scsi_qla_host_t	*ha;
+	device_reg_t	*reg;
+	uint32_t	mbx;
+	int		status = 0;
+	unsigned long	flags = 0;
+	unsigned long	mbx_flags = 0;
+	unsigned long	intr_iter;
+	uint32_t	stat;
+	uint16_t	hccr;
+
+	/* Don't loop forever, interrupt are OFF */
+	intr_iter = 50; 
+
+	ha = (scsi_qla_host_t *) dev_id;
+	if (!ha) {
+		printk(KERN_INFO
+		    "%s(): NULL host pointer\n", __func__);
+		return (IRQ_NONE);
+	}
+
+	reg = ha->iobase;
+
+	spin_lock_irqsave(&ha->hardware_lock, flags);
+
+	for (;;) {
+		/* Relax CPU! */
+		if (!(intr_iter--))
+			break;
+
+		if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
+			if ((RD_REG_WORD(&reg->istatus) & ISR_RISC_INT) == 0)
+				break;
+
+			if (RD_REG_WORD(&reg->semaphore) & BIT_0) {
+				WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
+				RD_REG_WORD(&reg->hccr);
+
+				/* Get mailbox data. */
+				mbx = RD_MAILBOX_REG(ha, reg, 0);
+				if (mbx > 0x3fff && mbx < 0x8000) {
+					qla2x00_mbx_completion(ha,
+					    (uint16_t)mbx);
+					status |= MBX_INTERRUPT;
+				} else if (mbx > 0x7fff && mbx < 0xc000) {
+					qla2x00_async_event(ha, mbx);
+				} else {
+					/*EMPTY*/
+					DEBUG2(printk("scsi(%ld): Unrecognized "
+					    "interrupt type (%d)\n",
+					    ha->host_no, mbx));
+				}
+				/* Release mailbox registers. */
+				WRT_REG_WORD(&reg->semaphore, 0);
+				/* Workaround for ISP2100 chip. */
+				if (IS_QLA2100(ha))
+					RD_REG_WORD(&reg->semaphore);
+			} else {
+				qla2x00_process_response_queue(ha);
+	
+				WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
+				RD_REG_WORD(&reg->hccr);
+			}
+		} else /* IS_QLA23XX(ha) */ {
+			stat = RD_REG_DWORD(&reg->u.isp2300.host_status);
+			if ((stat & HSR_RISC_INT) == 0)
+				break;
+
+			mbx = MSW(stat);
+			switch (stat & 0xff) {
+			case 0x13:
+				qla2x00_process_response_queue(ha);
+				break;
+			case 0x1:
+			case 0x2:
+			case 0x10:
+			case 0x11:
+				qla2x00_mbx_completion(ha, (uint16_t)mbx);
+				status |= MBX_INTERRUPT;
+
+				/* Release mailbox registers. */
+				WRT_REG_WORD(&reg->semaphore, 0);
+				break;
+			case 0x12:
+				qla2x00_async_event(ha, mbx);
+				break;
+			case 0x15:
+				mbx = mbx << 16 | MBA_CMPLT_1_16BIT;
+				qla2x00_async_event(ha, mbx);
+				break;
+			case 0x16:
+				mbx = mbx << 16 | MBA_SCSI_COMPLETION;
+				qla2x00_async_event(ha, mbx);
+				break;
+			default:
+				hccr = RD_REG_WORD(&reg->hccr);
+				if (hccr & HCCR_RISC_PAUSE) {
+					qla_printk(KERN_INFO, ha,
+					    "RISC paused, dumping HCCR=%x\n",
+					    hccr);
+
+					/*
+					 * Issue a "HARD" reset in order for
+					 * the RISC interrupt bit to be
+					 * cleared.  Schedule a big hammmer to
+					 * get out of the RISC PAUSED state.
+					 */
+					WRT_REG_WORD(&reg->hccr,
+					    HCCR_RESET_RISC);
+					RD_REG_WORD(&reg->hccr);
+					set_bit(ISP_ABORT_NEEDED,
+					    &ha->dpc_flags);
+					break;
+				} else {
+					DEBUG2(printk("scsi(%ld): Unrecognized "
+					    "interrupt type (%d)\n",
+					    ha->host_no, stat & 0xff));
+				}
+				break;
+			}
+			WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
+			RD_REG_WORD(&reg->hccr);
+		}
+	}
+
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+	qla2x00_next(ha);
+	ha->last_irq_cpu = smp_processor_id();
+	ha->total_isr_cnt++;
+
+	if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) &&
+	    (status & MBX_INTERRUPT) && ha->flags.mbox_int) {
+
+		/* There was a mailbox completion */
+		DEBUG3(printk("%s(%ld): Going to get mbx reg lock.\n",
+		    __func__, ha->host_no));
+
+		spin_lock_irqsave(&ha->mbx_reg_lock, mbx_flags);
+
+		if (ha->mcp == NULL) {
+			DEBUG3(printk("%s(%ld): Error mbx pointer.\n",
+			    __func__, ha->host_no));
+		} else {
+			DEBUG3(printk("%s(%ld): Going to set mbx intr flags. "
+			    "cmd=%x.\n",
+			    __func__, ha->host_no, ha->mcp->mb[0]));
+		}
+		set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
+
+		DEBUG3(printk("%s(%ld): Going to wake up mbx function for "
+		    "completion.\n",
+		    __func__, ha->host_no));
+
+		up(&ha->mbx_intr_sem);
+
+		DEBUG3(printk("%s(%ld): Going to release mbx reg lock.\n",
+		    __func__, ha->host_no));
+
+		spin_unlock_irqrestore(&ha->mbx_reg_lock, mbx_flags);
+	}
+
+	if (!list_empty(&ha->done_queue))
+		qla2x00_done(ha);
+
+	/* Wakeup the DPC routine */
+	if ((!ha->flags.mbox_busy &&
+	    (test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) ||
+		test_bit(RESET_MARKER_NEEDED, &ha->dpc_flags) ||
+		test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))) &&
+		    ha->dpc_wait && !ha->dpc_active) {
+
+		up(ha->dpc_wait);
+	}
+
+	return (IRQ_HANDLED);
+}
+
+/**
+ * qla2x00_mbx_completion() - Process mailbox command completions.
+ * @ha: SCSI driver HA context
+ * @mb0: Mailbox0 register
+ */
+static void
+qla2x00_mbx_completion(scsi_qla_host_t *ha, uint16_t mb0)
+{
+	uint16_t	cnt;
+	uint16_t	*wptr;
+	device_reg_t	*reg = ha->iobase;
+
+	/* Load return mailbox registers. */
+	ha->flags.mbox_int = TRUE;
+	ha->mailbox_out[0] = mb0;
+	wptr = (uint16_t *)MAILBOX_REG(ha, reg, 1);
+
+	for (cnt = 1; cnt < ha->mbx_count; cnt++) {
+		if (IS_QLA2200(ha) && cnt == 8) 
+			wptr = (uint16_t *)MAILBOX_REG(ha, reg, 8);
+		if (cnt == 4 || cnt == 5)
+			ha->mailbox_out[cnt] = qla2x00_debounce_register(wptr);
+		else
+			ha->mailbox_out[cnt] = RD_REG_WORD(wptr);
+	
+		wptr++;
+	}
+
+	if (ha->mcp) {
+		DEBUG3(printk("%s(%ld): Got mailbox completion. cmd=%x.\n",
+		    __func__, ha->host_no, ha->mcp->mb[0]));
+	} else {
+		DEBUG2_3(printk("%s(%ld): MBX pointer ERROR!\n",
+		    __func__, ha->host_no));
+	}
+}
+
+/**
+ * qla2x00_async_event() - Process aynchronous events.
+ * @ha: SCSI driver HA context
+ * @mb0: Mailbox0 register
+ */
+static void
+qla2x00_async_event(scsi_qla_host_t *ha, uint32_t mbx)
+{
+	static char	*link_speeds[5] = { "1", "2", "4", "?", "10" };
+	char		*link_speed;
+	uint16_t	mb[4];
+	uint16_t	handle_cnt;
+	uint16_t	cnt;
+	uint32_t	handles[5];
+	device_reg_t	*reg = ha->iobase;
+	uint32_t	rscn_entry, host_pid;
+	uint8_t		rscn_queue_index;
+
+	/* Setup to process RIO completion. */
+	handle_cnt = 0;
+	mb[0] = LSW(mbx);
+	switch (mb[0]) {
+	case MBA_SCSI_COMPLETION:
+		if (IS_QLA2100(ha) || IS_QLA2200(ha))
+			handles[0] = RD_MAILBOX_REG(ha, reg, 1);
+		else
+			handles[0] = MSW(mbx);
+		handles[0] |= (uint32_t)(RD_MAILBOX_REG(ha, reg, 2) << 16);
+		handle_cnt = 1;
+		break;
+	case MBA_CMPLT_1_16BIT:
+		if (IS_QLA2100(ha) || IS_QLA2200(ha))
+			handles[0] = (uint32_t)RD_MAILBOX_REG(ha, reg, 1);
+		else
+			handles[0] = MSW(mbx);
+		handle_cnt = 1;
+		mb[0] = MBA_SCSI_COMPLETION;
+		break;
+	case MBA_CMPLT_2_16BIT:
+		handles[0] = (uint32_t)RD_MAILBOX_REG(ha, reg, 1);
+		handles[1] = (uint32_t)RD_MAILBOX_REG(ha, reg, 2);
+		handle_cnt = 2;
+		mb[0] = MBA_SCSI_COMPLETION;
+		break;
+	case MBA_CMPLT_3_16BIT:
+		handles[0] = (uint32_t)RD_MAILBOX_REG(ha, reg, 1);
+		handles[1] = (uint32_t)RD_MAILBOX_REG(ha, reg, 2);
+		handles[2] = (uint32_t)RD_MAILBOX_REG(ha, reg, 3);
+		handle_cnt = 3;
+		mb[0] = MBA_SCSI_COMPLETION;
+		break;
+	case MBA_CMPLT_4_16BIT:
+		handles[0] = (uint32_t)RD_MAILBOX_REG(ha, reg, 1);
+		handles[1] = (uint32_t)RD_MAILBOX_REG(ha, reg, 2);
+		handles[2] = (uint32_t)RD_MAILBOX_REG(ha, reg, 3);
+		handles[3] = (uint32_t)RD_MAILBOX_REG(ha, reg, 6);
+		handle_cnt = 4;
+		mb[0] = MBA_SCSI_COMPLETION;
+		break;
+	case MBA_CMPLT_5_16BIT:
+		handles[0] = (uint32_t)RD_MAILBOX_REG(ha, reg, 1);
+		handles[1] = (uint32_t)RD_MAILBOX_REG(ha, reg, 2);
+		handles[2] = (uint32_t)RD_MAILBOX_REG(ha, reg, 3);
+		handles[3] = (uint32_t)RD_MAILBOX_REG(ha, reg, 6);
+		handles[4] = (uint32_t)RD_MAILBOX_REG(ha, reg, 7);
+		handle_cnt = 5;
+		mb[0] = MBA_SCSI_COMPLETION;
+		break;
+	case MBA_CMPLT_2_32BIT:
+		handles[0] = (uint32_t)((RD_MAILBOX_REG(ha, reg, 2) << 16) |
+		    RD_MAILBOX_REG(ha, reg, 1));
+		handles[1] = (uint32_t)((RD_MAILBOX_REG(ha, reg, 7) << 16) |
+		    RD_MAILBOX_REG(ha, reg, 6));
+		handle_cnt = 2;
+		mb[0] = MBA_SCSI_COMPLETION;
+		break;
+	default:
+		break;
+	}
+
+	mb[0] = LSW(mbx);
+	switch (mb[0]) {
+	case MBA_SCSI_COMPLETION:	/* Fast Post */
+		if (!ha->flags.online)
+			break;
+
+		for (cnt = 0; cnt < handle_cnt; cnt++)
+			qla2x00_process_completed_request(ha, handles[cnt]);
+		break;
+
+	case MBA_RESET:			/* Reset */
+		DEBUG2(printk("scsi(%ld): Asynchronous RESET.\n", ha->host_no));
+
+		set_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
+		break;
+
+	case MBA_SYSTEM_ERR:		/* System Error */
+		mb[1] = RD_MAILBOX_REG(ha, reg, 1);
+		mb[2] = RD_MAILBOX_REG(ha, reg, 2);
+		mb[3] = RD_MAILBOX_REG(ha, reg, 3);
+
+		qla_printk(KERN_INFO, ha,
+		    "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh.\n",
+		    mb[1], mb[2], mb[3]);
+
+		if (IS_QLA2100(ha) || IS_QLA2200(ha))
+			qla2100_fw_dump(ha, 1);
+		else
+	    		qla2300_fw_dump(ha, 1);
+		set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
+		break;
+
+	case MBA_REQ_TRANSFER_ERR:	/* Request Transfer Error */
+		DEBUG2(printk("scsi(%ld): ISP Request Transfer Error.\n",
+		    ha->host_no));
+		qla_printk(KERN_WARNING, ha, "ISP Request Transfer Error.\n");
+
+		set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
+		break;
+
+	case MBA_RSP_TRANSFER_ERR:	/* Response Transfer Error */
+		DEBUG2(printk("scsi(%ld): ISP Response Transfer Error.\n",
+		    ha->host_no));
+		qla_printk(KERN_WARNING, ha, "ISP Response Transfer Error.\n");
+
+		set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
+		break;
+
+	case MBA_WAKEUP_THRES:		/* Request Queue Wake-up */
+		DEBUG2(printk("scsi(%ld): Asynchronous WAKEUP_THRES.\n",
+		    ha->host_no));
+		break;
+
+	case MBA_LIP_OCCURRED:		/* Loop Initialization Procedure */
+		mb[1] = RD_MAILBOX_REG(ha, reg, 1);
+
+		DEBUG2(printk("scsi(%ld): LIP occured (%x).\n", ha->host_no,
+		    mb[1]));
+		qla_printk(KERN_INFO, ha, "LIP occured (%x).\n", mb[1]);
+
+		if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
+			atomic_set(&ha->loop_state, LOOP_DOWN);
+			atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
+			qla2x00_mark_all_devices_lost(ha);
+		}
+
+		set_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags);
+
+		ha->flags.management_server_logged_in = 0;
+
+		/* Update AEN queue. */
+		qla2x00_enqueue_aen(ha, MBA_LIP_OCCURRED, NULL);
+
+		ha->total_lip_cnt++;
+		break;
+
+	case MBA_LOOP_UP:		/* Loop Up Event */
+		mb[1] = RD_MAILBOX_REG(ha, reg, 1);
+
+		ha->current_speed = EXT_DEF_PORTSPEED_1GBIT;
+		if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
+			link_speed = link_speeds[0];
+		} else {
+			link_speed = link_speeds[3];
+			if (mb[1] < 5)
+				link_speed = link_speeds[mb[1]];
+			if (mb[1] == 1)
+				ha->current_speed = EXT_DEF_PORTSPEED_2GBIT;
+		}
+
+		DEBUG2(printk("scsi(%ld): Asynchronous LOOP UP (%s Gbps).\n",
+		    ha->host_no, link_speed));
+		qla_printk(KERN_INFO, ha, "LOOP UP detected (%s Gbps).\n",
+		    link_speed);
+
+		ha->flags.management_server_logged_in = 0;
+
+		/* Update AEN queue. */
+		qla2x00_enqueue_aen(ha, MBA_LOOP_UP, NULL);
+		break;
+
+	case MBA_LOOP_DOWN:		/* Loop Down Event */
+		DEBUG2(printk("scsi(%ld): Asynchronous LOOP DOWN.\n",
+		    ha->host_no));
+		qla_printk(KERN_INFO, ha, "LOOP DOWN detected.\n");
+
+		if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
+			atomic_set(&ha->loop_state, LOOP_DOWN);
+			atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
+			qla2x00_mark_all_devices_lost(ha);
+		}
+
+		ha->flags.management_server_logged_in = 0;
+		ha->current_speed = 0; /* reset value */
+
+		/* Update AEN queue. */
+		qla2x00_enqueue_aen(ha, MBA_LOOP_DOWN, NULL);
+		break;
+
+	case MBA_LIP_RESET:		/* LIP reset occurred */
+		mb[1] = RD_MAILBOX_REG(ha, reg, 1);
+
+		DEBUG2(printk("scsi(%ld): Asynchronous LIP RESET (%x).\n",
+		    ha->host_no, mb[1]));
+		qla_printk(KERN_INFO, ha,
+		    "LIP reset occured (%x).\n", mb[1]);
+
+		if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
+			atomic_set(&ha->loop_state, LOOP_DOWN);
+			atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
+			qla2x00_mark_all_devices_lost(ha);
+		}
+
+		set_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
+
+		ha->operating_mode = LOOP;
+		ha->flags.management_server_logged_in = 0;
+
+		/* Update AEN queue. */
+		qla2x00_enqueue_aen(ha, MBA_LIP_RESET, NULL);
+
+		ha->total_lip_cnt++;
+		break;
+
+	case MBA_POINT_TO_POINT:	/* Point-to-Point */
+		if (IS_QLA2100(ha))
+			break;
+
+		DEBUG2(printk("scsi(%ld): Asynchronous P2P MODE received.\n",
+		    ha->host_no));
+
+		/*
+		 * Until there's a transition from loop down to loop up, treat
+		 * this as loop down only.
+		 */
+		if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
+			atomic_set(&ha->loop_state, LOOP_DOWN);
+			if (!atomic_read(&ha->loop_down_timer))
+				atomic_set(&ha->loop_down_timer,
+				    LOOP_DOWN_TIME);
+			qla2x00_mark_all_devices_lost(ha);
+		}
+
+		if (!(test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags))) {
+			set_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
+		}
+		set_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags);
+		break;
+
+	case MBA_CHG_IN_CONNECTION:	/* Change in connection mode */
+		if (IS_QLA2100(ha))
+			break;
+
+		mb[1] = RD_MAILBOX_REG(ha, reg, 1);
+
+		DEBUG2(printk("scsi(%ld): Asynchronous Change In Connection "
+		    "received.\n",
+		    ha->host_no));
+		qla_printk(KERN_INFO, ha,
+		    "Configuration change detected: value=%x.\n", mb[1]);
+
+		if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
+			atomic_set(&ha->loop_state, LOOP_DOWN);  
+			if (!atomic_read(&ha->loop_down_timer))
+				atomic_set(&ha->loop_down_timer,
+				    LOOP_DOWN_TIME);
+			qla2x00_mark_all_devices_lost(ha);
+		}
+
+		set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
+		set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags);
+		break;
+
+	case MBA_PORT_UPDATE:		/* Port database update */
+		mb[1] = RD_MAILBOX_REG(ha, reg, 1);
+		mb[2] = RD_MAILBOX_REG(ha, reg, 2);
+
+		/*
+		 * If a single remote port just logged into (or logged out of)
+		 * us, create a new entry in our rscn fcports list and handle
+		 * the event like an RSCN.
+		 */
+		if (IS_QLA23XX(ha) && ha->flags.init_done && mb[1] != 0xffff &&
+		    ((ha->operating_mode == P2P && mb[1] != 0) ||
+		    (ha->operating_mode != P2P && mb[1] !=
+			SNS_FIRST_LOOP_ID)) && (mb[2] == 6 || mb[2] == 7)) {
+			int rval;
+			fc_port_t *rscn_fcport;
+
+			/* Create new fcport for login. */
+			rscn_fcport = qla2x00_alloc_rscn_fcport(ha, GFP_ATOMIC);
+			if (rscn_fcport) {
+				DEBUG14(printk("scsi(%ld): Port Update -- "
+				    "creating RSCN fcport %p for login.\n",
+				    ha->host_no, rscn_fcport));
+
+				rscn_fcport->loop_id = mb[1];
+				rscn_fcport->d_id.b24 = INVALID_PORT_ID;
+				atomic_set(&rscn_fcport->state,
+				    FCS_DEVICE_LOST);
+				list_add_tail(&rscn_fcport->list,
+				    &ha->rscn_fcports);
+
+				rval = qla2x00_handle_port_rscn(ha, 0,
+				    rscn_fcport, 1);
+				if (rval == QLA_SUCCESS)
+					break;
+			} else {
+				DEBUG14(printk("scsi(%ld): Port Update -- "
+				    "-- unable to allocate RSCN fcport "
+				    "login.\n", ha->host_no));
+			}
+		}
+
+		/*
+		 * If PORT UPDATE is global (recieved LIP_OCCURED/LIP_RESET
+		 * event etc. earlier indicating loop is down) then process
+		 * it.  Otherwise ignore it and Wait for RSCN to come in.
+		 */
+		if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
+			DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE "
+			    "ignored.\n", ha->host_no));
+			break;
+		}
+
+		DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE.\n",
+		    ha->host_no));
+		DEBUG(printk(KERN_INFO
+		    "scsi(%ld): Port database changed %04x %04x.\n",
+		    ha->host_no, mb[1], mb[2]));
+
+		/*
+		 * Mark all devices as missing so we will login again.
+		 */
+		atomic_set(&ha->loop_state, LOOP_UP);
+
+		atomic_set(&ha->loop_down_timer, 0);
+		qla2x00_mark_all_devices_lost(ha);
+
+		ha->flags.rscn_queue_overflow = 1;
+
+		set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
+		set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags);
+
+		/* Update AEN queue. */
+		qla2x00_enqueue_aen(ha, MBA_PORT_UPDATE, NULL);
+		break;
+
+	case MBA_RSCN_UPDATE:		/* State Change Registration */
+		mb[1] = RD_MAILBOX_REG(ha, reg, 1);
+		mb[2] = RD_MAILBOX_REG(ha, reg, 2);
+
+		DEBUG2(printk("scsi(%ld): Asynchronous RSCR UPDATE.\n",
+		    ha->host_no));
+		DEBUG(printk(KERN_INFO
+		    "scsi(%ld): RSCN database changed -- %04x %04x.\n",
+		    ha->host_no, mb[1], mb[2]));
+
+		rscn_entry = (mb[1] << 16) | mb[2];
+		host_pid = (ha->d_id.b.domain << 16) | (ha->d_id.b.area << 8) |
+		    ha->d_id.b.al_pa;
+		if (rscn_entry == host_pid) {
+			DEBUG(printk(KERN_INFO
+			    "scsi(%ld): Ignoring RSCN update to local host "
+			    "port ID (%06x)\n",
+			    ha->host_no, host_pid));
+			break;
+		}
+
+		rscn_queue_index = ha->rscn_in_ptr + 1;
+		if (rscn_queue_index == MAX_RSCN_COUNT)
+			rscn_queue_index = 0;
+		if (rscn_queue_index != ha->rscn_out_ptr) {
+			ha->rscn_queue[ha->rscn_in_ptr] = rscn_entry;
+			ha->rscn_in_ptr = rscn_queue_index;
+		} else {
+			ha->flags.rscn_queue_overflow = 1;
+		}
+
+		atomic_set(&ha->loop_state, LOOP_UPDATE);
+		atomic_set(&ha->loop_down_timer, 0);
+		ha->flags.management_server_logged_in = 0;
+
+		set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
+		set_bit(RSCN_UPDATE, &ha->dpc_flags);
+
+		/* Update AEN queue. */
+		qla2x00_enqueue_aen(ha, MBA_RSCN_UPDATE, &mb[0]);
+		break;
+
+	/* case MBA_RIO_RESPONSE: */
+	case MBA_ZIO_RESPONSE:
+		DEBUG2(printk("scsi(%ld): [R|Z]IO update completion.\n",
+		    ha->host_no));
+		DEBUG(printk(KERN_INFO
+		    "scsi(%ld): [R|Z]IO update completion.\n",
+		    ha->host_no));
+
+		qla2x00_process_response_queue(ha);
+		break;
+	}
+}
+
+/**
+ * qla2x00_process_completed_request() - Process a Fast Post response.
+ * @ha: SCSI driver HA context
+ * @index: SRB index
+ */
+static void
+qla2x00_process_completed_request(struct scsi_qla_host *ha, uint32_t index)
+{
+	srb_t *sp;
+
+	/* Validate handle. */
+	if (index >= MAX_OUTSTANDING_COMMANDS) {
+		DEBUG2(printk("scsi(%ld): Invalid SCSI completion handle %d.\n",
+		    ha->host_no, index));
+		qla_printk(KERN_WARNING, ha,
+		    "Invalid SCSI completion handle %d.\n", index);
+
+		set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
+		return;
+	}
+
+	sp = ha->outstanding_cmds[index];
+	if (sp) {
+		/* Free outstanding command slot. */
+		ha->outstanding_cmds[index] = 0;
+
+		if (ha->actthreads)
+			ha->actthreads--;
+		sp->lun_queue->out_cnt--;
+		CMD_COMPL_STATUS(sp->cmd) = 0L;
+		CMD_SCSI_STATUS(sp->cmd) = 0L;
+
+		/* Save ISP completion status */
+		sp->cmd->result = DID_OK << 16;
+		sp->fo_retry_cnt = 0;
+		add_to_done_queue(ha, sp);
+	} else {
+		DEBUG2(printk("scsi(%ld): Invalid ISP SCSI completion handle\n",
+		    ha->host_no));
+		qla_printk(KERN_WARNING, ha,
+		    "Invalid ISP SCSI completion handle\n");
+
+		set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
+	}
+}
+
+/**
+ * qla2x00_process_response_queue() - Process response queue entries.
+ * @ha: SCSI driver HA context
+ */
+void
+qla2x00_process_response_queue(struct scsi_qla_host *ha)
+{
+	device_reg_t	*reg = ha->iobase;
+	sts_entry_t	*pkt;
+	uint16_t        handle_cnt;
+	uint16_t        cnt;
+
+	if (!ha->flags.online)
+		return;
+
+	while (ha->response_ring_ptr->signature != RESPONSE_PROCESSED) {
+		pkt = (sts_entry_t *)ha->response_ring_ptr;
+
+		ha->rsp_ring_index++;
+		if (ha->rsp_ring_index == ha->response_q_length) {
+			ha->rsp_ring_index = 0;
+			ha->response_ring_ptr = ha->response_ring;
+		} else {
+			ha->response_ring_ptr++;
+		}
+
+		if (pkt->entry_status != 0) {
+			DEBUG3(printk(KERN_INFO
+			    "scsi(%ld): Process error entry.\n", ha->host_no));
+
+			qla2x00_error_entry(ha, pkt);
+			((response_t *)pkt)->signature = RESPONSE_PROCESSED;
+			wmb();
+			continue;
+		}
+
+		switch (pkt->entry_type) {
+		case STATUS_TYPE:
+			qla2x00_status_entry(ha, pkt);
+			break;
+		case STATUS_TYPE_21:
+			handle_cnt = ((sts21_entry_t *)pkt)->handle_count;
+			for (cnt = 0; cnt < handle_cnt; cnt++) {
+				qla2x00_process_completed_request(ha,
+				    ((sts21_entry_t *)pkt)->handle[cnt]);
+			}
+			break;
+		case STATUS_TYPE_22:
+			handle_cnt = ((sts22_entry_t *)pkt)->handle_count;
+			for (cnt = 0; cnt < handle_cnt; cnt++) {
+				qla2x00_process_completed_request(ha,
+				    ((sts22_entry_t *)pkt)->handle[cnt]);
+			}
+			break;
+		case STATUS_CONT_TYPE:
+			qla2x00_status_cont_entry(ha, (sts_cont_entry_t *)pkt);
+			break;
+		case MS_IOCB_TYPE:
+			qla2x00_ms_entry(ha, (ms_iocb_entry_t *)pkt);
+			break;
+		case MBX_IOCB_TYPE:
+			if (IS_QLA23XX(ha)) {
+				if (pkt->sys_define == SOURCE_ASYNC_IOCB) {
+					qla2x00_process_iodesc(ha,
+					    (struct mbx_entry *)pkt);
+				} else {
+					/* MBX IOCB Type Not Supported. */
+					DEBUG4(printk(KERN_WARNING
+					    "scsi(%ld): Received unknown MBX "
+					    "IOCB response pkt type=%x "
+					    "source=%x entry status=%x.\n",
+					    ha->host_no, pkt->entry_type,
+					    pkt->sys_define,
+					    pkt->entry_status));
+				}
+				break;
+			}
+			/* Fallthrough. */
+		default:
+			/* Type Not Supported. */
+			DEBUG4(printk(KERN_WARNING
+			    "scsi(%ld): Received unknown response pkt type %x "
+			    "entry status=%x.\n",
+			    ha->host_no, pkt->entry_type, pkt->entry_status));
+			break;
+		}
+		((response_t *)pkt)->signature = RESPONSE_PROCESSED;
+		wmb();
+	}
+
+	/* Adjust ring index */
+	WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), ha->rsp_ring_index);
+}
+
+/**
+ * qla2x00_status_entry() - Process a Status IOCB entry.
+ * @ha: SCSI driver HA context
+ * @pkt: Entry pointer
+ */
+static void
+qla2x00_status_entry(scsi_qla_host_t *ha, sts_entry_t *pkt)
+{
+	int		ret;
+	unsigned	b, t, l;
+	srb_t		*sp;
+	os_lun_t	*lq;
+	os_tgt_t	*tq;
+	fc_port_t	*fcport;
+	struct scsi_cmnd *cp;
+	uint16_t	comp_status;
+	uint16_t	scsi_status;
+	uint8_t		lscsi_status;
+	uint32_t	resid;
+	uint8_t		sense_sz = 0;
+
+	/* Fast path completion. */
+	if (le16_to_cpu(pkt->comp_status) == CS_COMPLETE &&
+	    (le16_to_cpu(pkt->scsi_status) & SS_MASK) == 0) {
+		qla2x00_process_completed_request(ha, pkt->handle);
+
+		return;
+	}
+
+	/* Validate handle. */
+	if (pkt->handle < MAX_OUTSTANDING_COMMANDS) {
+		sp = ha->outstanding_cmds[pkt->handle];
+		ha->outstanding_cmds[pkt->handle] = 0;
+	} else
+		sp = NULL;
+
+	if (sp == NULL) {
+		DEBUG2(printk("scsi(%ld): Status Entry invalid handle.\n",
+		    ha->host_no));
+		qla_printk(KERN_WARNING, ha, "Status Entry invalid handle.\n");
+
+		set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
+		if (ha->dpc_wait && !ha->dpc_active) 
+			up(ha->dpc_wait);
+
+		return;
+	}
+	cp = sp->cmd;
+	if (cp == NULL) {
+		DEBUG2(printk("scsi(%ld): Command already returned back to OS "
+		    "pkt->handle=%d sp=%p sp->state:%d\n",
+		    ha->host_no, pkt->handle, sp, sp->state));
+		qla_printk(KERN_WARNING, ha,
+		    "Command is NULL: already returned to OS (sp=%p)\n", sp);
+
+		return;
+	}
+
+	if (ha->actthreads)
+		ha->actthreads--;
+
+	if (sp->lun_queue == NULL) {
+		DEBUG2(printk("scsi(%ld): Status Entry invalid lun pointer.\n",
+		    ha->host_no));
+		qla_printk(KERN_WARNING, ha,
+		    "Status Entry invalid lun pointer.\n");
+
+		set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
+		if (ha->dpc_wait && !ha->dpc_active) 
+			up(ha->dpc_wait);
+
+		return;
+	}
+
+	sp->lun_queue->out_cnt--;
+
+	comp_status = le16_to_cpu(pkt->comp_status);
+	/* Mask of reserved bits 12-15, before we examine the scsi status */
+	scsi_status = le16_to_cpu(pkt->scsi_status) & SS_MASK;
+	lscsi_status = scsi_status & STATUS_MASK;
+
+	CMD_ENTRY_STATUS(cp) = pkt->entry_status;
+	CMD_COMPL_STATUS(cp) = comp_status;
+	CMD_SCSI_STATUS(cp) = scsi_status;
+
+	/* Generate LU queue on cntrl, target, LUN */
+	b = cp->device->channel;
+	t = cp->device->id;
+	l = cp->device->lun,
+
+	tq = sp->tgt_queue;
+	lq = sp->lun_queue;
+
+	/*
+	 * If loop is in transient state Report DID_BUS_BUSY
+	 */
+	if ((comp_status != CS_COMPLETE || scsi_status != 0)) {
+		if (!(sp->flags & SRB_IOCTL) &&
+		    (atomic_read(&ha->loop_down_timer) ||
+			atomic_read(&ha->loop_state) != LOOP_READY)) {
+
+			DEBUG2(printk("scsi(%ld:%d:%d:%d): Loop Not Ready - "
+			    "pid=%lx.\n",
+			    ha->host_no, b, t, l, cp->serial_number));
+
+			qla2x00_extend_timeout(cp, EXTEND_CMD_TIMEOUT);
+			add_to_retry_queue(ha, sp);
+			return;
+		}
+	}
+
+	/*
+	 * Based on Host and scsi status generate status code for Linux
+	 */
+	switch (comp_status) {
+	case CS_COMPLETE:
+		if (scsi_status == 0) {
+			cp->result = DID_OK << 16;
+			break;
+		}
+		if (lscsi_status == SS_BUSY_CONDITION) {
+			cp->result = DID_BUS_BUSY << 16 | lscsi_status;
+			break;
+		}
+
+		cp->result = DID_OK << 16 | lscsi_status;
+
+		if (lscsi_status != SS_CHECK_CONDITION)
+			break;
+
+		/*
+		 * Copy Sense Data into sense buffer
+		 */
+		memset(cp->sense_buffer, 0, sizeof(cp->sense_buffer));
+
+		if (!(scsi_status & SS_SENSE_LEN_VALID))
+			break;
+
+		if (le16_to_cpu(pkt->req_sense_length) <
+		    sizeof(cp->sense_buffer))
+			sense_sz = le16_to_cpu(pkt->req_sense_length);
+		else
+			sense_sz = sizeof(cp->sense_buffer) - 1;
+
+		CMD_ACTUAL_SNSLEN(cp) = sense_sz;
+		sp->request_sense_length = sense_sz;
+		sp->request_sense_ptr = cp->sense_buffer;
+
+		if (sp->request_sense_length > 32)
+			sense_sz = 32;
+
+		memcpy(cp->sense_buffer, pkt->req_sense_data, sense_sz);
+
+		sp->request_sense_ptr += sense_sz;
+		sp->request_sense_length -= sense_sz;
+		if (sp->request_sense_length != 0)
+			ha->status_srb = sp;
+
+		if (!(sp->flags & SRB_IOCTL) &&
+		    qla2x00_check_sense(cp, lq) == QLA_SUCCESS) {
+			/* Throw away status_cont if any */
+			ha->status_srb = NULL;
+			add_to_scsi_retry_queue(ha, sp);
+			return;
+		}
+
+		DEBUG5(printk("%s(): Check condition Sense data, "
+		    "scsi(%ld:%d:%d:%d) cmd=%p pid=%ld\n",
+		    __func__, ha->host_no, b, t, l, cp,
+		    cp->serial_number));
+		if (sense_sz)
+			DEBUG5(qla2x00_dump_buffer(cp->sense_buffer,
+			    CMD_ACTUAL_SNSLEN(cp)));
+		break;
+
+	case CS_DATA_UNDERRUN:
+		DEBUG2(printk(KERN_INFO
+		    "scsi(%ld:%d:%d) UNDERRUN status detected 0x%x-0x%x.\n",
+		    ha->host_no, t, l, comp_status, scsi_status));
+
+		resid = le32_to_cpu(pkt->residual_length);
+		CMD_RESID_LEN(cp) = resid;
+
+		/*
+		 * Check to see if SCSI Status is non zero. If so report SCSI 
+		 * Status.
+		 */
+		if (lscsi_status != 0) {
+			if (lscsi_status == SS_BUSY_CONDITION) {
+				cp->result = DID_BUS_BUSY << 16 |
+				    lscsi_status;
+				break;
+			}
+
+			cp->result = DID_OK << 16 | lscsi_status;
+
+			if (lscsi_status != SS_CHECK_CONDITION)
+				break;
+
+			/* Copy Sense Data into sense buffer */
+			memset(cp->sense_buffer, 0, sizeof(cp->sense_buffer));
+
+			if (!(scsi_status & SS_SENSE_LEN_VALID))
+				break;
+
+			if (le16_to_cpu(pkt->req_sense_length) <
+			    sizeof(cp->sense_buffer))
+				sense_sz = le16_to_cpu(pkt->req_sense_length);
+			else
+				sense_sz = sizeof(cp->sense_buffer) - 1;
+
+			CMD_ACTUAL_SNSLEN(cp) = sense_sz;
+			sp->request_sense_length = sense_sz;
+			sp->request_sense_ptr = cp->sense_buffer;
+
+			if (sp->request_sense_length > 32) 
+				sense_sz = 32;
+
+			memcpy(cp->sense_buffer, pkt->req_sense_data, sense_sz);
+
+			sp->request_sense_ptr += sense_sz;
+			sp->request_sense_length -= sense_sz;
+			if (sp->request_sense_length != 0)
+				ha->status_srb = sp;
+
+			if (!(sp->flags & SRB_IOCTL) &&
+			    (qla2x00_check_sense(cp, lq) == QLA_SUCCESS)) {
+				ha->status_srb = NULL;
+				add_to_scsi_retry_queue(ha, sp);
+				return;
+			}
+			DEBUG5(printk("%s(): Check condition Sense data, "
+			    "scsi(%ld:%d:%d:%d) cmd=%p pid=%ld\n",
+			    __func__, ha->host_no, b, t, l, cp,
+			    cp->serial_number));
+			if (sense_sz)
+				DEBUG5(qla2x00_dump_buffer(cp->sense_buffer,
+				    CMD_ACTUAL_SNSLEN(cp)));
+		} else {
+			/*
+			 * If RISC reports underrun and target does not report
+			 * it then we must have a lost frame, so tell upper
+			 * layer to retry it by reporting a bus busy.
+			 */
+			if (!(scsi_status & SS_RESIDUAL_UNDER)) {
+				DEBUG2(printk("scsi(%ld:%d:%d:%d) Dropped "
+				    "frame(s) detected (%x of %x bytes)..."
+				    "retrying command.\n",
+				    ha->host_no, b, t, l, resid,
+				    cp->request_bufflen));
+
+				cp->result = DID_BUS_BUSY << 16;
+				ha->dropped_frame_error_cnt++;
+				break;
+			}
+
+			/* Handle mid-layer underflow */
+			cp->resid = resid;
+			if ((unsigned)(cp->request_bufflen - resid) <
+			    cp->underflow) {
+				qla_printk(KERN_INFO, ha,
+				    "scsi(%ld:%d:%d:%d): Mid-layer underflow "
+				    "detected (%x of %x bytes)...returning "
+				    "error status.\n",
+				    ha->host_no, b, t, l, resid,
+				    cp->request_bufflen);
+
+				cp->result = DID_ERROR << 16;
+				break;
+			}
+
+			/* Everybody online, looking good... */
+			cp->result = DID_OK << 16;
+		}
+		break;
+
+	case CS_DATA_OVERRUN:
+		DEBUG2(printk(KERN_INFO
+		    "scsi(%ld:%d:%d): OVERRUN status detected 0x%x-0x%x\n",
+		    ha->host_no, t, l, comp_status, scsi_status));
+		DEBUG2(printk(KERN_INFO
+		    "CDB: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
+		    cp->cmnd[0], cp->cmnd[1], cp->cmnd[2], cp->cmnd[3],
+		    cp->cmnd[4], cp->cmnd[5]));
+		DEBUG2(printk(KERN_INFO
+		    "PID=0x%lx req=0x%x xtra=0x%x -- returning DID_ERROR "
+		    "status!\n",
+		    cp->serial_number, cp->request_bufflen,
+		    le32_to_cpu(pkt->residual_length)));
+
+		cp->result = DID_ERROR << 16;
+		break;
+
+	case CS_PORT_LOGGED_OUT:
+	case CS_PORT_CONFIG_CHG:
+	case CS_PORT_BUSY:
+	case CS_INCOMPLETE:
+	case CS_PORT_UNAVAILABLE:
+		/*
+		 * If the port is in Target Down state, return all IOs for this
+		 * Target with DID_NO_CONNECT ELSE Queue the IOs in the
+		 * retry_queue.
+		 */
+		fcport = sp->fclun->fcport;
+		DEBUG2(printk("scsi(%ld:%d:%d): status_entry: Port Down "
+		    "pid=%ld, compl status=0x%x, port state=0x%x\n",
+		    ha->host_no, t, l, cp->serial_number, comp_status,
+		    atomic_read(&fcport->state)));
+
+		if ((sp->flags & SRB_IOCTL) ||
+		    atomic_read(&fcport->state) == FCS_DEVICE_DEAD) {
+			cp->result = DID_NO_CONNECT << 16;
+			add_to_done_queue(ha, sp);
+		} else {
+			qla2x00_extend_timeout(cp, EXTEND_CMD_TIMEOUT);
+			add_to_retry_queue(ha, sp);
+		}
+
+		if (atomic_read(&fcport->state) == FCS_ONLINE) {
+			qla2x00_mark_device_lost(ha, fcport, 1);
+		}
+
+		return;
+		break;
+
+	case CS_RESET:
+		DEBUG2(printk(KERN_INFO
+		    "scsi(%ld): RESET status detected 0x%x-0x%x.\n",
+		    ha->host_no, comp_status, scsi_status));
+
+		if (sp->flags & SRB_IOCTL) {
+			cp->result = DID_RESET << 16;
+		} else {
+			qla2x00_extend_timeout(cp, EXTEND_CMD_TIMEOUT);
+			add_to_retry_queue(ha, sp);
+			return;
+		}
+		break;
+
+	case CS_ABORTED:
+		/* 
+		 * hv2.19.12 - DID_ABORT does not retry the request if we
+		 * aborted this request then abort otherwise it must be a
+		 * reset.
+		 */
+		DEBUG2(printk(KERN_INFO
+		    "scsi(%ld): ABORT status detected 0x%x-0x%x.\n",
+		    ha->host_no, comp_status, scsi_status));
+
+		cp->result = DID_RESET << 16;
+		break;
+
+	case CS_TIMEOUT:
+		DEBUG2(printk(KERN_INFO
+		    "scsi(%ld:%d:%d:%d): TIMEOUT status detected 0x%x-0x%x.\n",
+		    ha->host_no, b, t, l, comp_status, scsi_status));
+
+		cp->result = DID_BUS_BUSY << 16;
+
+		fcport = lq->fclun->fcport;
+
+		/* Check to see if logout occurred */
+		if ((le16_to_cpu(pkt->status_flags) & SF_LOGOUT_SENT)) {
+			qla2x00_mark_device_lost(ha, fcport, 1);
+		}
+		break;
+
+	case CS_QUEUE_FULL:
+		DEBUG2(printk(KERN_INFO
+		    "scsi(%ld): QUEUE FULL status detected 0x%x-0x%x.\n",
+		    ha->host_no, comp_status, scsi_status));
+
+		/* SCSI Mid-Layer handles device queue full */
+
+		cp->result = DID_OK << 16 | lscsi_status; 
+
+		/* TODO: ??? */
+		/* Adjust queue depth */
+		ret = scsi_track_queue_full(cp->device,
+		    sp->lun_queue->out_cnt - 1);
+		if (ret) {
+			qla_printk(KERN_INFO, ha,
+			    "scsi(%ld:%d:%d:%d): Queue depth adjusted to %d.\n",
+			    ha->host_no, cp->device->channel, cp->device->id,
+			    cp->device->lun, ret);
+		}
+		break;
+
+	default:
+		DEBUG3(printk("scsi(%ld): Error detected (unknown status) "
+		    "0x%x-0x%x.\n",
+		    ha->host_no, comp_status, scsi_status));
+		qla_printk(KERN_INFO, ha,
+		    "Unknown status detected 0x%x-0x%x.\n",
+		    comp_status, scsi_status);
+
+		cp->result = DID_ERROR << 16;
+		break;
+	}
+
+	/* Place command on done queue. */
+	if (ha->status_srb == NULL)
+		add_to_done_queue(ha, sp);
+}
+
+/**
+ * qla2x00_status_cont_entry() - Process a Status Continuations entry.
+ * @ha: SCSI driver HA context
+ * @pkt: Entry pointer
+ *
+ * Extended sense data.
+ */
+static void
+qla2x00_status_cont_entry(scsi_qla_host_t *ha, sts_cont_entry_t *pkt)
+{
+	uint8_t		sense_sz = 0;
+	srb_t		*sp = ha->status_srb;
+	struct scsi_cmnd *cp;
+
+	if (sp != NULL && sp->request_sense_length != 0) {
+		cp = sp->cmd;
+		if (cp == NULL) {
+			DEBUG2(printk("%s(): Cmd already returned back to OS "
+			    "sp=%p sp->state:%d\n", __func__, sp, sp->state));
+			qla_printk(KERN_INFO, ha,
+			    "cmd is NULL: already returned to OS (sp=%p)\n",
+			    sp); 
+
+			ha->status_srb = NULL;
+			return;
+		}
+
+		if (sp->request_sense_length > sizeof(pkt->data)) {
+			sense_sz = sizeof(pkt->data);
+		} else {
+			sense_sz = sp->request_sense_length;
+		}
+
+		/* Move sense data. */
+		memcpy(sp->request_sense_ptr, pkt->data, sense_sz);
+		DEBUG5(qla2x00_dump_buffer(sp->request_sense_ptr, sense_sz));
+
+		sp->request_sense_ptr += sense_sz;
+		sp->request_sense_length -= sense_sz;
+
+		/* Place command on done queue. */
+		if (sp->request_sense_length == 0) {
+			add_to_done_queue(ha, sp);
+			ha->status_srb = NULL;
+		}
+	}
+}
+
+/**
+ * qla2x00_error_entry() - Process an error entry.
+ * @ha: SCSI driver HA context
+ * @pkt: Entry pointer
+ */
+static void
+qla2x00_error_entry(scsi_qla_host_t *ha, sts_entry_t *pkt) 
+{
+	srb_t *sp;
+
+#if defined(QL_DEBUG_LEVEL_2)
+	if (pkt->entry_status & RF_INV_E_ORDER)
+		qla_printk(KERN_ERR, ha, "%s: Invalid Entry Order\n", __func__);
+	else if (pkt->entry_status & RF_INV_E_COUNT)
+		qla_printk(KERN_ERR, ha, "%s: Invalid Entry Count\n", __func__);
+	else if (pkt->entry_status & RF_INV_E_PARAM)
+		qla_printk(KERN_ERR, ha, 
+		    "%s: Invalid Entry Parameter\n", __func__);
+	else if (pkt->entry_status & RF_INV_E_TYPE)
+		qla_printk(KERN_ERR, ha, "%s: Invalid Entry Type\n", __func__);
+	else if (pkt->entry_status & RF_BUSY)
+		qla_printk(KERN_ERR, ha, "%s: Busy\n", __func__);
+	else
+		qla_printk(KERN_ERR, ha, "%s: UNKNOWN flag error\n", __func__);
+#endif
+
+	/* Validate handle. */
+	if (pkt->handle < MAX_OUTSTANDING_COMMANDS)
+		sp = ha->outstanding_cmds[pkt->handle];
+	else
+		sp = NULL;
+
+	if (sp) {
+		/* Free outstanding command slot. */
+		ha->outstanding_cmds[pkt->handle] = 0;
+		if (ha->actthreads)
+			ha->actthreads--;
+		sp->lun_queue->out_cnt--;
+
+		/* Bad payload or header */
+		if (pkt->entry_status &
+		    (RF_INV_E_ORDER | RF_INV_E_COUNT |
+		     RF_INV_E_PARAM | RF_INV_E_TYPE)) {
+			sp->cmd->result = DID_ERROR << 16;
+		} else if (pkt->entry_status & RF_BUSY) {
+			sp->cmd->result = DID_BUS_BUSY << 16;
+		} else {
+			sp->cmd->result = DID_ERROR << 16;
+		}
+		/* Place command on done queue. */
+		add_to_done_queue(ha, sp);
+
+	} else if (pkt->entry_type == COMMAND_A64_TYPE ||
+	    pkt->entry_type == COMMAND_TYPE) {
+		DEBUG2(printk("scsi(%ld): Error entry - invalid handle\n",
+		    ha->host_no));
+		qla_printk(KERN_WARNING, ha,
+		    "Error entry - invalid handle\n");
+
+		set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
+		if (ha->dpc_wait && !ha->dpc_active) 
+			up(ha->dpc_wait);
+	}
+}
+
+/**
+ * qla2x00_ms_entry() - Process a Management Server entry.
+ * @ha: SCSI driver HA context
+ * @index: Response queue out pointer
+ */
+static void
+qla2x00_ms_entry(scsi_qla_host_t *ha, ms_iocb_entry_t *pkt) 
+{
+	srb_t          *sp;
+
+	DEBUG3(printk("%s(%ld): pkt=%p pkthandle=%d.\n",
+	    __func__, ha->host_no, pkt, pkt->handle1));
+
+	/* Validate handle. */
+ 	if (pkt->handle1 < MAX_OUTSTANDING_COMMANDS)
+ 		sp = ha->outstanding_cmds[pkt->handle1];
+	else
+		sp = NULL;
+
+	if (sp == NULL) {
+		DEBUG2(printk("scsi(%ld): MS entry - invalid handle\n",
+		    ha->host_no));
+		qla_printk(KERN_WARNING, ha, "MS entry - invalid handle\n");
+
+		set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
+		return;
+	}
+
+	CMD_COMPL_STATUS(sp->cmd) = le16_to_cpu(pkt->status);
+	CMD_ENTRY_STATUS(sp->cmd) = pkt->entry_status;
+
+	/* Free outstanding command slot. */
+	ha->outstanding_cmds[pkt->handle1] = 0;
+
+	add_to_done_queue(ha, sp);
+}
+
+/**
+ * qla2x00_check_sense() - Perform any sense data interrogation.
+ * @cp: SCSI Command
+ * @lq: Lun queue
+ *
+ * Returns QLA_SUCCESS if the lun queue is suspended, else
+ * QLA_FUNCTION_FAILED  (lun queue not suspended).
+ */
+static int 
+qla2x00_check_sense(struct scsi_cmnd *cp, os_lun_t *lq)
+{
+	scsi_qla_host_t	*ha;
+	srb_t		*sp;
+	fc_port_t	*fcport;
+
+	ha = (scsi_qla_host_t *) cp->device->host->hostdata;
+	if ((cp->sense_buffer[0] & 0x70) != 0x70) {
+		return (QLA_FUNCTION_FAILED);
+	}
+
+	sp = (srb_t * )CMD_SP(cp);
+	sp->flags |= SRB_GOT_SENSE;
+
+	switch (cp->sense_buffer[2] & 0xf) {
+	case RECOVERED_ERROR:
+		cp->result = DID_OK << 16;
+		cp->sense_buffer[0] = 0;
+		break;
+
+	case NOT_READY:
+		fcport = lq->fclun->fcport;
+
+		/*
+		 * Suspend the lun only for hard disk device type.
+		 */
+		if ((fcport->flags & FCF_TAPE_PRESENT) == 0 &&
+		    lq->q_state != LUN_STATE_TIMEOUT) {
+			/*
+			 * If target is in process of being ready then suspend
+			 * lun for 6 secs and retry all the commands.
+			 */
+			if (cp->sense_buffer[12] == 0x4 &&
+			    cp->sense_buffer[13] == 0x1) {
+
+				/* Suspend the lun for 6 secs */
+				qla2x00_suspend_lun(ha, lq, 6,
+				    ql2xsuspendcount);
+
+				return (QLA_SUCCESS);
+			}
+		}
+		break;
+	}
+
+	return (QLA_FUNCTION_FAILED);
+}
diff -puN /dev/null drivers/scsi/qla2xxx/qla_listops.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/qla_listops.h	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,351 @@
+/******************************************************************************
+ *                  QLOGIC LINUX SOFTWARE
+ *
+ * QLogic ISP2x00 device driver for Linux 2.6.x
+ * Copyright (C) 2003 QLogic Corporation
+ * (www.qlogic.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ ******************************************************************************/
+
+/* Management functions for various lists */
+
+/* __add_to_done_queue()
+ * 
+ * Place SRB command on done queue.
+ *
+ * Input:
+ *      ha           = host pointer
+ *      sp           = srb pointer.
+ * Locking:
+ * 	this function assumes the ha->list_lock is already taken
+ */
+static inline void 
+__add_to_done_queue(struct scsi_qla_host * ha, srb_t * sp)
+{
+	/*
+        if (sp->state != SRB_NO_QUEUE_STATE && 
+        	sp->state != SRB_ACTIVE_STATE)
+		BUG();
+	*/
+
+        /* Place block on done queue */
+        sp->cmd->host_scribble = (unsigned char *) NULL;
+        sp->state = SRB_DONE_STATE;
+        list_add_tail(&sp->list,&ha->done_queue);
+        ha->done_q_cnt++;
+	sp->ha = ha;
+}
+
+static inline void 
+__add_to_retry_queue(struct scsi_qla_host * ha, srb_t * sp)
+{
+	/*
+        if( sp->state != SRB_NO_QUEUE_STATE && 
+        	sp->state != SRB_ACTIVE_STATE)
+		BUG();
+	*/
+
+        /* Place block on retry queue */
+        list_add_tail(&sp->list,&ha->retry_queue);
+        ha->retry_q_cnt++;
+        sp->flags |= SRB_WATCHDOG;
+        sp->state = SRB_RETRY_STATE;
+	sp->ha = ha;
+}
+
+static inline void 
+__add_to_scsi_retry_queue(struct scsi_qla_host * ha, srb_t * sp)
+{
+	/*
+        if( sp->state != SRB_NO_QUEUE_STATE && 
+        	sp->state != SRB_ACTIVE_STATE)
+		BUG();
+	*/
+
+        /* Place block on retry queue */
+        list_add_tail(&sp->list,&ha->scsi_retry_queue);
+        ha->scsi_retry_q_cnt++;
+        sp->state = SRB_SCSI_RETRY_STATE;
+	sp->ha = ha;
+}
+
+static inline void 
+add_to_done_queue(struct scsi_qla_host * ha, srb_t * sp)
+{
+        unsigned long flags;
+
+        spin_lock_irqsave(&ha->list_lock, flags);
+        __add_to_done_queue(ha,sp);
+        spin_unlock_irqrestore(&ha->list_lock, flags);
+}
+
+static inline void 
+add_to_free_queue(struct scsi_qla_host * ha, srb_t * sp)
+{
+	mempool_free(sp, ha->srb_mempool);
+}
+
+static inline void 
+add_to_retry_queue(struct scsi_qla_host * ha, srb_t * sp)
+{
+        unsigned long flags;
+
+        spin_lock_irqsave(&ha->list_lock, flags);
+        __add_to_retry_queue(ha,sp);
+        spin_unlock_irqrestore(&ha->list_lock, flags);
+}
+
+static inline void 
+add_to_scsi_retry_queue(struct scsi_qla_host * ha, srb_t * sp)
+{
+        unsigned long flags;
+
+        spin_lock_irqsave(&ha->list_lock, flags);
+        __add_to_scsi_retry_queue(ha,sp);
+        spin_unlock_irqrestore(&ha->list_lock, flags);
+}
+
+/*
+ * __del_from_retry_queue
+ *      Function used to remove a command block from the
+ *      watchdog timer queue.
+ *
+ *      Note: Must insure that command is on watchdog
+ *            list before calling del_from_retry_queue
+ *            if (sp->flags & SRB_WATCHDOG)
+ *
+ * Input: 
+ *      ha = adapter block pointer.
+ *      sp = srb pointer.
+ * Locking:
+ *	this function assumes the list_lock is already taken
+ */
+static inline void 
+__del_from_retry_queue(struct scsi_qla_host * ha, srb_t * sp)
+{
+        list_del_init(&sp->list);
+
+        sp->flags &= ~(SRB_WATCHDOG | SRB_BUSY);
+        sp->state = SRB_NO_QUEUE_STATE;
+        ha->retry_q_cnt--;
+}
+
+/*
+ * __del_from_scsi_retry_queue
+ *      Function used to remove a command block from the
+ *      scsi retry queue.
+ *
+ * Input: 
+ *      ha = adapter block pointer.
+ *      sp = srb pointer.
+ * Locking:
+ *	this function assumes the list_lock is already taken
+ */
+static inline void 
+__del_from_scsi_retry_queue(struct scsi_qla_host * ha, srb_t * sp)
+{
+        list_del_init(&sp->list);
+
+        ha->scsi_retry_q_cnt--;
+        sp->state = SRB_NO_QUEUE_STATE;
+}
+
+/*
+ * del_from_retry_queue
+ *      Function used to remove a command block from the
+ *      watchdog timer queue.
+ *
+ *      Note: Must insure that command is on watchdog
+ *            list before calling del_from_retry_queue
+ *            if (sp->flags & SRB_WATCHDOG)
+ *
+ * Input: 
+ *      ha = adapter block pointer.
+ *      sp = srb pointer.
+ * Locking:
+ *	this function takes and releases the list_lock
+ */
+static inline void 
+del_from_retry_queue(struct scsi_qla_host * ha, srb_t * sp)
+{
+        unsigned long flags;
+
+        /*	if (unlikely(!(sp->flags & SRB_WATCHDOG)))
+        		BUG();*/
+        spin_lock_irqsave(&ha->list_lock, flags);
+
+        /*	if (unlikely(list_empty(&ha->retry_queue)))
+        		BUG();*/
+
+        __del_from_retry_queue(ha,sp);
+
+        spin_unlock_irqrestore(&ha->list_lock, flags);
+}
+/*
+ * del_from_scsi_retry_queue
+ *      Function used to remove a command block from the
+ *      scsi retry queue.
+ *
+ * Input: 
+ *      ha = adapter block pointer.
+ *      sp = srb pointer.
+ * Locking:
+ *	this function takes and releases the list_lock
+ */
+static inline void 
+del_from_scsi_retry_queue(struct scsi_qla_host * ha, srb_t * sp)
+{
+        unsigned long flags;
+
+        spin_lock_irqsave(&ha->list_lock, flags);
+
+        /*	if (unlikely(list_empty(&ha->scsi_retry_queue)))
+        		BUG();*/
+
+        __del_from_scsi_retry_queue(ha,sp);
+
+        spin_unlock_irqrestore(&ha->list_lock, flags);
+}
+
+/*
+ * __add_to_pending_queue
+ *      Add the standard SCB job to the bottom of standard SCB commands.
+ *
+ * Input:
+ * COMPLETE!!!
+ *      q  = SCSI LU pointer.
+ *      sp = srb pointer.
+ *      SCSI_LU_Q lock must be already obtained.
+ */
+static inline int 
+__add_to_pending_queue(struct scsi_qla_host *ha, srb_t * sp)
+{
+	int	empty;
+	/*
+        if( sp->state != SRB_NO_QUEUE_STATE &&
+        	sp->state != SRB_FREE_STATE &&
+        	sp->state != SRB_ACTIVE_STATE)
+		BUG();
+	*/
+
+	empty = list_empty(&ha->pending_queue);
+	list_add_tail(&sp->list, &ha->pending_queue);
+	ha->qthreads++;
+	sp->state = SRB_PENDING_STATE;
+
+	return (empty);
+}
+
+static inline void 
+__add_to_pending_queue_head(struct scsi_qla_host *ha, srb_t * sp)
+{
+	/*
+        if( sp->state != SRB_NO_QUEUE_STATE && 
+        	sp->state != SRB_FREE_STATE &&
+        	sp->state != SRB_ACTIVE_STATE)
+		BUG();
+	*/
+
+	list_add(&sp->list, &ha->pending_queue);
+	ha->qthreads++;
+	sp->state = SRB_PENDING_STATE;
+}
+
+static inline int
+add_to_pending_queue(struct scsi_qla_host *ha, srb_t *sp)
+{
+	int	empty;
+	unsigned long flags;
+
+	spin_lock_irqsave(&ha->list_lock, flags);
+	empty = __add_to_pending_queue(ha, sp);
+	spin_unlock_irqrestore(&ha->list_lock, flags);
+
+	return (empty);
+}
+static inline void
+add_to_pending_queue_head(struct scsi_qla_host *ha, srb_t *sp)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&ha->list_lock, flags);
+	__add_to_pending_queue_head(ha, sp);
+	spin_unlock_irqrestore(&ha->list_lock, flags);
+}
+
+static inline void
+__del_from_pending_queue(struct scsi_qla_host *ha, srb_t *sp)
+{
+	list_del_init(&sp->list);
+	ha->qthreads--;
+	sp->state = SRB_NO_QUEUE_STATE;
+}
+
+/*
+ * Failover Stuff.
+ */
+static inline void
+__add_to_failover_queue(struct scsi_qla_host * ha, srb_t * sp)
+{
+	/*
+        if( sp->state != SRB_NO_QUEUE_STATE && 
+        	sp->state != SRB_ACTIVE_STATE)
+		BUG();
+	*/
+
+        list_add_tail(&sp->list,&ha->failover_queue);
+        ha->failover_cnt++;
+        sp->state = SRB_FAILOVER_STATE;
+	sp->ha = ha;
+}
+
+static inline void add_to_failover_queue(struct scsi_qla_host * ha, srb_t * sp)
+{
+        unsigned long flags;
+
+        spin_lock_irqsave(&ha->list_lock, flags);
+
+        __add_to_failover_queue(ha,sp);
+
+        spin_unlock_irqrestore(&ha->list_lock, flags);
+}
+static inline void __del_from_failover_queue(struct scsi_qla_host * ha, srb_t *
+                sp)
+{
+        ha->failover_cnt--;
+        list_del_init(&sp->list);
+        sp->state = SRB_NO_QUEUE_STATE;
+}
+
+static inline void del_from_failover_queue(struct scsi_qla_host * ha, srb_t * sp)
+{
+        unsigned long flags;
+
+        spin_lock_irqsave(&ha->list_lock, flags);
+
+        __del_from_failover_queue(ha,sp);
+
+        spin_unlock_irqrestore(&ha->list_lock, flags);
+}
+
+static inline void 
+del_from_pending_queue(struct scsi_qla_host * ha, srb_t * sp)
+{
+        unsigned long flags;
+
+        spin_lock_irqsave(&ha->list_lock, flags);
+
+        __del_from_pending_queue(ha,sp);
+
+        spin_unlock_irqrestore(&ha->list_lock, flags);
+}
diff -puN /dev/null drivers/scsi/qla2xxx/qla_mbx.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/qla_mbx.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,2778 @@
+/*
+ *                  QLOGIC LINUX SOFTWARE
+ *
+ * QLogic ISP2x00 device driver for Linux 2.6.x
+ * Copyright (C) 2003 QLogic Corporation
+ * (www.qlogic.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include "qla_os.h"
+
+#include "qla_def.h"
+
+/*
+ *  Local Function Prototypes.
+ */
+static void
+qla2x00_mbx_sem_timeout(unsigned long);
+
+static int
+qla2x00_get_mbx_access(scsi_qla_host_t *, uint32_t);
+
+static int
+qla2x00_release_mbx_access(scsi_qla_host_t *, uint32_t);
+
+static int
+qla2x00_mbx_q_add(scsi_qla_host_t *, mbx_cmdq_t **);
+
+static void
+qla2x00_mbx_q_get(scsi_qla_host_t *, mbx_cmdq_t **);
+
+static void
+qla2x00_mbx_q_memb_alloc(scsi_qla_host_t *, mbx_cmdq_t **);
+
+static void
+qla2x00_mbx_q_memb_free(scsi_qla_host_t *, mbx_cmdq_t *);
+
+/***************************/
+/* Function implementation */
+/***************************/
+
+static void
+qla2x00_mbx_sem_timeout(unsigned long data)
+{
+	struct semaphore	*sem_ptr = (struct semaphore *)data;
+
+	DEBUG11(printk("qla2x00_sem_timeout: entered.\n");)
+
+	if (sem_ptr != NULL) {
+		up(sem_ptr);
+	}
+
+	DEBUG11(printk("qla2x00_mbx_sem_timeout: exiting.\n");)
+}
+
+/*
+ *  tov = timeout value in seconds
+ */
+static int
+qla2x00_get_mbx_access(scsi_qla_host_t *ha, uint32_t tov)
+{
+	int		ret;
+	int		prev_val = 1;  /* assume no access yet */
+	mbx_cmdq_t	*ptmp_mbq;
+	struct timer_list	tmp_cmd_timer;
+	unsigned long	cpu_flags;
+
+
+	DEBUG11(printk("qla2x00_get_mbx_access(%ld): entered.\n",
+	    ha->host_no);)
+
+	while (1) {
+		if (test_bit(MBX_CMD_WANT, &ha->mbx_cmd_flags) == 0) {
+
+			DEBUG11(printk("qla2x00_get_mbx_access(%ld): going "
+			    " to test access flags.\n", ha->host_no);)
+
+			/* No one else is waiting. Go ahead and try to
+			 * get access.
+			 */
+			if ((prev_val = test_and_set_bit(MBX_CMD_ACTIVE,
+			    &ha->mbx_cmd_flags)) == 0) {
+				break;
+			}
+		}
+
+		/* wait for previous command to finish */
+		DEBUG(printk("qla2x00_get_mbx_access(%ld): access "
+		    "flags=%lx. busy. Waiting for access. curr time=0x%lx.\n",
+		    ha->host_no, ha->mbx_cmd_flags, jiffies);)
+
+		DEBUG11(printk("qla2x00_get_mbx_access(%ld): access "
+		    "flags=%lx. busy. Waiting for access. curr time=0x%lx.\n",
+		    ha->host_no, ha->mbx_cmd_flags, jiffies);)
+
+		/*
+		 * Init timer and get semaphore from mbx q. After we got valid
+		 * semaphore pointer the MBX_CMD_WANT flag would also had
+		 * been set.
+		 */
+		qla2x00_mbx_q_add(ha, &ptmp_mbq);
+
+		if (ptmp_mbq == NULL) {
+			/* queue full? problem? can't proceed. */
+			DEBUG2_3_11(printk("qla2x00_get_mbx_access(%ld): ERROR "
+			    "no more mbx_q allowed. exiting.\n", ha->host_no);)
+
+			break;
+		}
+
+		/* init timer and semaphore */
+		init_timer(&tmp_cmd_timer);
+		tmp_cmd_timer.data = (unsigned long)&ptmp_mbq->cmd_sem;
+		tmp_cmd_timer.function =
+		    (void (*)(unsigned long))qla2x00_mbx_sem_timeout;
+		tmp_cmd_timer.expires = jiffies + tov * HZ;
+
+		DEBUG11(printk("get_mbx_access(%ld): adding timer. "
+		    "curr time=0x%lx timeoutval=0x%lx.\n",
+		    ha->host_no, jiffies, tmp_cmd_timer.expires);)
+
+			/* wait. */
+/*	 	 add_timer(&tmp_cmd_timer);*/
+		DEBUG11(printk("get_mbx_access(%ld): going to sleep. "
+		    "current time=0x%lx.\n", ha->host_no, jiffies);)
+
+		down_interruptible(&ptmp_mbq->cmd_sem);
+
+		DEBUG11(printk("get_mbx_access(%ld): woke up. current "
+		    "time=0x%lx.\n",
+		    ha->host_no, jiffies);)
+
+/*		del_timer(&tmp_cmd_timer);*/
+
+		/* try to get lock again. we'll test later to see
+		 * if we actually got the lock.
+		 */
+		prev_val = test_and_set_bit(MBX_CMD_ACTIVE,
+		    &ha->mbx_cmd_flags);
+
+		/*
+		 * After we tried to get access then we check to see
+		 * if we need to clear the MBX_CMD_WANT flag. Don't clear
+		 * this flag before trying to get access or else another
+		 * new thread might grab it before we did.
+		 */
+		spin_lock_irqsave(&ha->mbx_q_lock, cpu_flags);
+		if (ha->mbx_q_head == NULL) {
+			/* We're the last thread in queue. */
+			clear_bit(MBX_CMD_WANT, &ha->mbx_cmd_flags);
+		}
+		qla2x00_mbx_q_memb_free(ha, ptmp_mbq);
+		spin_unlock_irqrestore(&ha->mbx_q_lock, cpu_flags);
+
+		break;
+	}
+
+	if (prev_val == 0) {
+		/* We got the lock */
+		DEBUG11(printk("qla2x00_get_mbx_access(%ld): success.\n",
+		    ha->host_no);)
+
+		ret = QLA_SUCCESS;
+	} else {
+		/* Timeout or resource error. */
+		DEBUG2_3_11(printk("qla2x00_get_mbx_access(%ld): timed out.\n",
+		    ha->host_no);)
+
+		ret = QLA_FUNCTION_TIMEOUT;
+	}
+
+	return ret;
+}
+
+static int
+qla2x00_release_mbx_access(scsi_qla_host_t *ha, uint32_t tov)
+{
+	mbx_cmdq_t	*next_thread;
+
+	DEBUG11(printk("qla2x00_release_mbx_access:(%ld): entered.\n",
+	    ha->host_no);)
+
+	clear_bit(MBX_CMD_ACTIVE, &ha->mbx_cmd_flags);
+
+	/* Wake up one pending mailbox cmd thread in queue. */
+	qla2x00_mbx_q_get(ha, &next_thread);
+	if (next_thread) {
+		DEBUG11(printk("qla2x00_release_mbx_access: found pending "
+		    "mbx cmd. Waking up sem in %p.\n", &next_thread);)
+		up(&next_thread->cmd_sem);
+	}
+
+	DEBUG11(printk("qla2x00_release_mbx_access:(%ld): exiting.\n",
+	    ha->host_no);)
+
+	return QLA_SUCCESS;
+}
+
+/* Allocates a mbx_cmdq_t struct and add to the mbx_q list. */
+static int
+qla2x00_mbx_q_add(scsi_qla_host_t *ha, mbx_cmdq_t **ret_mbq)
+{
+	int		ret;
+	unsigned long	cpu_flags;
+	mbx_cmdq_t	*ptmp = NULL;
+
+	spin_lock_irqsave(&ha->mbx_q_lock, cpu_flags);
+
+	DEBUG11(printk("qla2x00_mbx_q_add: got mbx_q spinlock. "
+	    "Inst=%d.\n", apiHBAInstance);)
+
+	qla2x00_mbx_q_memb_alloc(ha, &ptmp);
+	if (ptmp == NULL) {
+		/* can't add any more threads */
+		DEBUG2_3_11(printk("qla2x00_mbx_q_add: ERROR no more "
+		    "ioctl threads allowed. Inst=%d.\n", apiHBAInstance);)
+
+		ret = QLA_MEMORY_ALLOC_FAILED;
+	} else {
+		if (ha->mbx_q_tail == NULL) {
+			/* First thread to queue. */
+			set_bit(MBX_CMD_WANT, &ha->mbx_cmd_flags);
+
+			ha->mbx_q_head = ptmp;
+		} else {
+			ha->mbx_q_tail->pnext = ptmp;
+		}
+		ha->mbx_q_tail = ptmp;
+
+		/* Now init the semaphore */
+		init_MUTEX_LOCKED(&ptmp->cmd_sem);
+		ret = QLA_SUCCESS;
+	}
+
+	*ret_mbq = ptmp;
+
+	DEBUG11(printk("qla2x00_mbx_q_add: going to release spinlock. "
+	    "ret_mbq=%p, ret=%d. Inst=%d.\n", *ret_mbq, ret, apiHBAInstance);)
+
+	spin_unlock_irqrestore(&ha->mbx_q_lock, cpu_flags);
+
+	return ret;
+}
+
+/* Just remove and return first member from mbx_cmdq.  Don't free anything. */
+static void
+qla2x00_mbx_q_get(scsi_qla_host_t *ha, mbx_cmdq_t **ret_mbq)
+{
+	unsigned long	cpu_flags;
+
+	spin_lock_irqsave(&ha->mbx_q_lock, cpu_flags);
+
+	DEBUG11(printk("qla2x00_mbx_q_get: got mbx_q spinlock. "
+	    "Inst=%d.\n", apiHBAInstance);)
+
+	/* Remove from head */
+	*ret_mbq = ha->mbx_q_head;
+	if (ha->mbx_q_head != NULL) {
+		ha->mbx_q_head = ha->mbx_q_head->pnext;
+		if (ha->mbx_q_head == NULL) {
+			/* That's the last one in queue. */
+			ha->mbx_q_tail = NULL;
+		}
+		(*ret_mbq)->pnext = NULL;
+	}
+
+	DEBUG11(printk("qla2x00_mbx_q_remove: return ret_mbq=%p. Going to "
+	    "release spinlock. Inst=%d.\n", *ret_mbq, apiHBAInstance);)
+
+	spin_unlock_irqrestore(&ha->mbx_q_lock, cpu_flags);
+}
+
+/* Find a free mbx_q member from the array. Must already got the
+ * mbx_q_lock spinlock.
+ */
+static void
+qla2x00_mbx_q_memb_alloc(scsi_qla_host_t *ha, mbx_cmdq_t **ret_mbx_q_memb)
+{
+	mbx_cmdq_t	*ptmp = NULL;
+
+	DEBUG11(printk("qla2x00_mbx_q_memb_alloc: entered. "
+	    "Inst=%d.\n", apiHBAInstance);)
+
+	ptmp = ha->mbx_sem_pool_head;
+	if (ptmp != NULL) {
+		ha->mbx_sem_pool_head = ptmp->pnext;
+		ptmp->pnext = NULL;
+		if (ha->mbx_sem_pool_head == NULL) {
+			ha->mbx_sem_pool_tail = NULL;
+		}
+	} else {
+		/* We ran out of pre-allocated semaphores.  Try to allocate
+		 * a new one.
+		 */
+		ptmp = kmalloc(sizeof(mbx_cmdq_t), GFP_ATOMIC);
+		if(ptmp)
+			memset(ptmp, 0, sizeof(mbx_cmdq_t));
+	}
+
+	*ret_mbx_q_memb = ptmp;
+
+	DEBUG11(printk("qla2x00_mbx_q_memb_alloc: return waitq_memb=%p. "
+	    "Inst=%d.\n", *ret_mbx_q_memb, apiHBAInstance);)
+}
+
+/* Add the specified mbx_q member back to the free semaphore pool. Must
+ * already got the mbx_q_lock spinlock.
+ */
+static void
+qla2x00_mbx_q_memb_free(scsi_qla_host_t *ha, mbx_cmdq_t *pfree_mbx_q_memb)
+{
+	DEBUG11(printk("qla2x00_mbx_q_memb_free: entered. Inst=%d.\n",
+	    apiHBAInstance);)
+
+	if (pfree_mbx_q_memb != NULL) {
+		if (ha->mbx_sem_pool_tail != NULL) {
+			/* Add to tail */
+			ha->mbx_sem_pool_tail->pnext = pfree_mbx_q_memb;
+		} else {
+			ha->mbx_sem_pool_head = pfree_mbx_q_memb;
+		}
+		ha->mbx_sem_pool_tail = pfree_mbx_q_memb;
+	}
+
+	/* put it back to the free pool. */
+
+	DEBUG11(printk("qla2x00_mbx_q_memb_free: exiting. "
+	    "Inst=%d.\n", apiHBAInstance);)
+}
+
+/*
+ * qla2x00_mailbox_command
+ *	Issue mailbox command and waits for completion.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	mcp = driver internal mbx struct pointer.
+ *
+ * Output:
+ *	mb[MAX_MAILBOX_REGISTER_COUNT] = returned mailbox data.
+ *
+ * Returns:
+ *	0 : QLA_SUCCESS = cmd performed success
+ *	1 : QLA_FUNCTION_FAILED   (error encountered)
+ *	6 : QLA_FUNCTION_TIMEOUT (timeout condition encountered)
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp)
+{
+	int		rval;
+	unsigned long    flags = 0;
+	device_reg_t     *reg       = ha->iobase;
+	struct timer_list	tmp_intr_timer;
+	uint8_t		abort_active = test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags);
+	uint8_t		io_lock_on = ha->flags.init_done;
+	uint8_t		tmp_stat = 0;
+	uint16_t	command;
+	uint16_t	*iptr, *optr;
+	uint32_t	cnt;
+	uint32_t	mboxes;
+	unsigned long	mbx_flags = 0;
+	unsigned long	wait_time;
+
+	rval = QLA_SUCCESS;
+
+	DEBUG11(printk("qla2x00_mailbox_command(%ld): entered.\n",
+	    ha->host_no);)
+	/*
+	 * Wait for active mailbox commands to finish by waiting at most
+	 * tov seconds. This is to serialize actual issuing of mailbox cmds
+	 * during non ISP abort time.
+	 */
+	if (!abort_active) {
+		tmp_stat = qla2x00_get_mbx_access(ha, mcp->tov);
+		if (tmp_stat != QLA_SUCCESS) {
+			/* Timeout occurred. Return error. */
+			DEBUG2_3_11(printk("qla2x00_mailbox_command(%ld): cmd "
+			    "access timeout. Exiting.\n", ha->host_no);)
+			return QLA_FUNCTION_TIMEOUT;
+		}
+	}
+
+	ha->flags.mbox_busy = TRUE;
+	/* Save mailbox command for debug */
+	ha->mcp = mcp;
+
+	/* Try to get mailbox register access */
+	if (!abort_active)
+		spin_lock_irqsave(&ha->mbx_reg_lock, mbx_flags);
+
+	DEBUG11(printk("scsi%d: prepare to issue mbox cmd=0x%x.\n",
+	    (int)ha->host_no, mcp->mb[0]);)
+
+	spin_lock_irqsave(&ha->hardware_lock, flags);
+
+	/* Load mailbox registers. */
+	optr = (uint16_t *)MAILBOX_REG(ha, reg, 0);
+
+	iptr = mcp->mb;
+	command = mcp->mb[0];
+	mboxes = mcp->out_mb;
+
+	for (cnt = 0; cnt < ha->mbx_count; cnt++) {
+		if (IS_QLA2200(ha) && cnt == 8)
+			optr = (uint16_t *)MAILBOX_REG(ha, reg, 8);
+		if (mboxes & BIT_0)
+			WRT_REG_WORD(optr, *iptr);
+
+		mboxes >>= 1;
+		optr++;
+		iptr++;
+	}
+
+#if defined(QL_DEBUG_LEVEL_1)
+	printk("qla2x00_mailbox_command: Loaded MBX registers "
+	    "(displayed in bytes) = \n");
+	qla2x00_dump_buffer((uint8_t *)mcp->mb, 16);
+	printk("\n");
+	qla2x00_dump_buffer(((uint8_t *)mcp->mb + 0x10), 16);
+	printk("\n");
+	qla2x00_dump_buffer(((uint8_t *)mcp->mb + 0x20), 8);
+	printk("\n");
+	printk("qla2x00_mailbox_command: I/O address = %lx.\n",
+	    (u_long)optr);
+	qla2x00_dump_regs(ha);
+#endif
+
+	/* Issue set host interrupt command to send cmd out. */
+	ha->flags.mbox_int = FALSE;
+	clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
+
+	/* Unlock mbx registers and wait for interrupt */
+
+	DEBUG11(printk("qla2x00_mailbox_command: going to unlock irq & "
+	    "waiting for interrupt. jiffies=%lx.\n", jiffies);)
+
+	/* Wait for mbx cmd completion until timeout */
+
+	if (!abort_active && io_lock_on) {
+		/* sleep on completion semaphore */
+		DEBUG11(printk("qla2x00_mailbox_command(%ld): "
+		    "INTERRUPT MODE. Initializing timer.\n",
+		    ha->host_no);)
+
+		init_timer(&tmp_intr_timer);
+		tmp_intr_timer.data = (unsigned long)&ha->mbx_intr_sem;
+		tmp_intr_timer.expires = jiffies + mcp->tov * HZ;
+		tmp_intr_timer.function =
+		    (void (*)(unsigned long))qla2x00_mbx_sem_timeout;
+
+		DEBUG11(printk("qla2x00_mailbox_command(%ld): "
+		    "Adding timer.\n", ha->host_no);)
+		add_timer(&tmp_intr_timer);
+
+		DEBUG11(printk("qla2x00_mailbox_command: going to "
+		    "unlock & sleep. time=0x%lx.\n", jiffies);)
+
+		set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
+
+		WRT_REG_WORD(&reg->hccr, HCCR_SET_HOST_INT);
+		spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+		if (!abort_active)
+			spin_unlock_irqrestore(&ha->mbx_reg_lock, mbx_flags);
+
+		/* Wait for either the timer to expire
+		 * or the mbox completion interrupt
+		 */
+		down(&ha->mbx_intr_sem);
+
+		DEBUG11(printk("qla2x00_mailbox_command:"
+		    "waking up."
+		    "time=0x%lx\n", jiffies);)
+		clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
+
+		/* delete the timer */
+		del_timer(&tmp_intr_timer);
+	} else {
+
+		DEBUG3_11(printk("qla2x00_mailbox_command(%ld): cmd=%x "
+			"POLLING MODE.\n", ha->host_no, command);)
+
+		WRT_REG_WORD(&reg->hccr, HCCR_SET_HOST_INT);
+		spin_unlock_irqrestore(&ha->hardware_lock, flags);
+		if (!abort_active)
+			spin_unlock_irqrestore(&ha->mbx_reg_lock, mbx_flags);
+
+		wait_time = jiffies + mcp->tov * HZ; /* wait at most tov secs */
+		while (!ha->flags.mbox_int) {
+			if (time_after(jiffies, wait_time))
+				break;
+
+			/* Check for pending interrupts. */
+			qla2x00_poll(ha);
+
+			udelay(10); /* v4.27 */
+		} /* while */
+	}
+
+	if (!abort_active)
+		spin_lock_irqsave(&ha->mbx_reg_lock, mbx_flags);
+
+	/* Check whether we timed out */
+	if (ha->flags.mbox_int) {
+
+		DEBUG3_11(printk("qla2x00_mailbox_cmd: cmd %x completed.\n",
+		    command);)
+
+		/* Got interrupt. Clear the flag. */
+		ha->flags.mbox_int = FALSE;
+		clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
+
+		if (ha->mailbox_out[0] != MBS_COMMAND_COMPLETE) {
+			qla2x00_stats.mboxerr++;
+			rval = QLA_FUNCTION_FAILED;
+		}
+
+		/* Load return mailbox registers. */
+		optr = mcp->mb;
+		iptr = (uint16_t *)&ha->mailbox_out[0];
+		mboxes = mcp->in_mb;
+		for (cnt = 0; cnt < ha->mbx_count; cnt++) {
+			if (mboxes & BIT_0)
+				*optr = *iptr;
+
+			mboxes >>= 1;
+			optr++;
+			iptr++;
+		}
+	} else {
+
+#if defined(QL_DEBUG_LEVEL_2) || defined(QL_DEBUG_LEVEL_3) || \
+		defined(QL_DEBUG_LEVEL_11)
+		printk("qla2x00_mailbox_command(%ld): **** MB Command Timeout "
+		    "for cmd %x ****\n", ha->host_no, command);
+		printk("qla2x00_mailbox_command: icontrol=%x jiffies=%lx\n",
+		    RD_REG_WORD(&reg->ictrl), jiffies);
+		printk("qla2x00_mailbox_command: *** mailbox[0] = 0x%x ***\n",
+		    RD_REG_WORD(optr));
+		qla2x00_dump_regs(ha);
+#endif
+
+		qla2x00_stats.mboxtout++;
+		ha->total_mbx_timeout++;
+		rval = QLA_FUNCTION_TIMEOUT;
+	}
+
+	if (!abort_active)
+		spin_unlock_irqrestore(&ha->mbx_reg_lock, mbx_flags);
+
+	ha->flags.mbox_busy = FALSE;
+
+	/* Clean up */
+	ha->mcp = NULL;
+
+	if (!abort_active) {
+		DEBUG11(printk("qla2x00_mailbox_cmd: checking for additional "
+		    "resp interrupt.\n");)
+
+		/* polling mode for non isp_abort commands. */
+		qla2x00_poll(ha);
+	}
+
+	if (rval == QLA_FUNCTION_TIMEOUT) {
+		if (!io_lock_on || (mcp->flags & IOCTL_CMD)) {
+			/* not in dpc. schedule it for dpc to take over. */
+			DEBUG(printk("qla2x00_mailbox_command(%ld): timeout "
+			    "schedule isp_abort_needed.\n",
+			    ha->host_no);)
+			DEBUG2_3_11(printk("qla2x00_mailbox_command(%ld): "
+			    "timeout schedule isp_abort_needed.\n",
+			    ha->host_no);)
+			set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
+			if (ha->dpc_wait && !ha->dpc_active) 
+				up(ha->dpc_wait);
+
+		} else if (!abort_active) {
+
+			/* call abort directly since we are in the DPC thread */
+			DEBUG(printk("qla2x00_mailbox_command(%ld): timeout "
+			    "calling abort_isp\n", ha->host_no);)
+			DEBUG2_3_11(printk("qla2x00_mailbox_command(%ld): "
+			    "timeout calling abort_isp\n", ha->host_no);)
+
+			set_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags);
+			clear_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
+			if (qla2x00_abort_isp(ha)) {
+				/* failed. retry later. */
+				set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
+			}
+			clear_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags);
+
+			DEBUG(printk("qla2x00_mailbox_command: finished "
+			    "abort_isp\n");)
+			DEBUG2_3_11(printk("qla2x00_mailbox_command: finished "
+			    "abort_isp\n");)
+		}
+	}
+
+	/* Allow next mbx cmd to come in. */
+	if (!abort_active) {
+		tmp_stat = qla2x00_release_mbx_access(ha, mcp->tov);
+
+		if (rval == 0)
+			rval = tmp_stat;
+	}
+
+	if (rval) {
+		DEBUG2_3_11(printk("qla2x00_mailbox_command(%ld): **** FAILED. "
+		    "mbx0=%x, mbx1=%x, mbx2=%x, cmd=%x ****\n",
+		ha->host_no, mcp->mb[0], mcp->mb[1], mcp->mb[2], command);)
+	} else {
+		DEBUG11(printk("qla2x00_mailbox_command(%ld): done.\n",
+		    ha->host_no);)
+	}
+
+	DEBUG11(printk("qla2x00_mailbox_command(%ld): exiting.\n",
+	    ha->host_no);)
+
+	return rval;
+}
+
+/*
+ * qla2x00_load_ram
+ *	Load adapter RAM using DMA.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_load_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint16_t risc_addr,
+    uint16_t risc_code_size)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+	uint32_t	req_len;
+	dma_addr_t	nml_dma;
+	uint32_t	nml_len;
+	uint32_t	normalized;
+
+	DEBUG11(printk("qla2x00_load_ram(%ld): entered.\n",
+	    ha->host_no);)
+
+	req_len = risc_code_size;
+	nml_dma = 0;
+	nml_len = 0;
+
+	normalized = qla2x00_normalize_dma_addr(&req_dma, &req_len, &nml_dma,
+	    &nml_len);
+
+	/* Load first segment */
+	mcp->mb[0] = MBC_LOAD_RISC_RAM;
+	mcp->mb[1] = risc_addr;
+	mcp->mb[2] = MSW(req_dma);
+	mcp->mb[3] = LSW(req_dma);
+	mcp->mb[4] = (uint16_t)req_len;
+	mcp->mb[6] = MSW(MSD(req_dma));
+	mcp->mb[7] = LSW(MSD(req_dma));
+	mcp->out_mb = MBX_7|MBX_6|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	/* Load second segment - if necessary */
+	if (normalized && (rval == QLA_SUCCESS)) {
+		mcp->mb[0] = MBC_LOAD_RISC_RAM;
+		mcp->mb[1] = risc_addr + (uint16_t)req_len;
+		mcp->mb[2] = MSW(nml_dma);
+		mcp->mb[3] = LSW(nml_dma);
+		mcp->mb[4] = (uint16_t)nml_len;
+		mcp->mb[6] = MSW(MSD(nml_dma));
+		mcp->mb[7] = LSW(MSD(nml_dma));
+		mcp->out_mb = MBX_7|MBX_6|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
+		mcp->in_mb = MBX_0;
+		mcp->tov = 30;
+		mcp->flags = 0;
+		rval = qla2x00_mailbox_command(ha, mcp);
+	}
+
+	if (rval == QLA_SUCCESS) {
+		/* Empty */
+		DEBUG11(printk("qla2x00_load_ram(%ld): done.\n", ha->host_no);)
+	} else {
+		/* Empty */
+		DEBUG2_3_11(printk("qla2x00_load_ram(%ld): failed. rval=%x "
+		    "mb[0]=%x.\n", ha->host_no, rval, mcp->mb[0]);)
+	}
+	return rval;
+}
+
+/*
+ * qla2x00_load_ram_ext
+ *	Load adapter extended RAM using DMA.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_load_ram_ext(scsi_qla_host_t *ha, dma_addr_t req_dma,
+    uint32_t risc_addr, uint16_t risc_code_size)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+	uint32_t	req_len;
+	dma_addr_t	nml_dma;
+	uint32_t	nml_len;
+	uint32_t	normalized;
+
+	DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
+
+	req_len = risc_code_size;
+	nml_dma = 0;
+	nml_len = 0;
+
+	normalized = qla2x00_normalize_dma_addr(&req_dma, &req_len, &nml_dma,
+	    &nml_len);
+
+	/* Load first segment */
+	mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED;
+	mcp->mb[1] = LSW(risc_addr);
+	mcp->mb[2] = MSW(req_dma);
+	mcp->mb[3] = LSW(req_dma);
+	mcp->mb[4] = (uint16_t)req_len;
+	mcp->mb[6] = MSW(MSD(req_dma));
+	mcp->mb[7] = LSW(MSD(req_dma));
+	mcp->mb[8] = MSW(risc_addr);
+	mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	/* Load second segment - if necessary */
+	if (normalized && (rval == QLA_SUCCESS)) {
+		risc_addr += req_len;
+		mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED;
+		mcp->mb[1] = LSW(risc_addr);
+		mcp->mb[2] = MSW(nml_dma);
+		mcp->mb[3] = LSW(nml_dma);
+		mcp->mb[4] = (uint16_t)nml_len;
+		mcp->mb[6] = MSW(MSD(nml_dma));
+		mcp->mb[7] = LSW(MSD(nml_dma));
+		mcp->mb[8] = MSW(risc_addr);
+		mcp->out_mb = MBX_8|MBX_7|MBX_6|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
+		mcp->in_mb = MBX_0;
+		mcp->tov = 30;
+		mcp->flags = 0;
+		rval = qla2x00_mailbox_command(ha, mcp);
+	}
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n",
+		    __func__, ha->host_no, rval, mcp->mb[0]));
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_execute_fw
+ *	Start adapter firmware.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	TARGET_QUEUE_LOCK must be released.
+ *	ADAPTER_STATE_LOCK must be released.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_execute_fw(scsi_qla_host_t *ha)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("qla2x00_execute_fw(%ld): entered.\n", ha->host_no);)
+
+	mcp->mb[0] = MBC_EXECUTE_FIRMWARE;
+	mcp->mb[1] = *ha->brd_info->fw_info[0].fwstart;
+	mcp->out_mb = MBX_1|MBX_0;
+	if (IS_QLA2322(ha)) {
+		mcp->mb[2] = 0;
+		mcp->out_mb |= MBX_2;
+	}
+
+	mcp->in_mb = MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	DEBUG11(printk("qla2x00_execute_fw(%ld): done.\n", ha->host_no);)
+
+	return rval;
+}
+
+/*
+ * qla2x00_get_fw_version
+ *	Get firmware version.
+ *
+ * Input:
+ *	ha:		adapter state pointer.
+ *	major:		pointer for major number.
+ *	minor:		pointer for minor number.
+ *	subminor:	pointer for subminor number.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+void
+qla2x00_get_fw_version(scsi_qla_host_t *ha, uint16_t *major, uint16_t *minor,
+    uint16_t *subminor, uint16_t *attributes)
+{
+	int		rval;
+	mbx_cmd_t	mc;
+	mbx_cmd_t	*mcp = &mc;
+
+	DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
+
+	mcp->mb[0] = MBC_GET_FIRMWARE_VERSION;
+	mcp->out_mb = MBX_0;
+	mcp->in_mb = MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->flags = 0;
+	mcp->tov = 30;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	/* Return mailbox data. */
+	*major = mcp->mb[1];
+	*minor = mcp->mb[2];
+	*subminor = mcp->mb[3];
+	*attributes = mcp->mb[6];
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
+		    ha->host_no, rval));
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
+	}
+}
+
+/*
+ * qla2x00_get_fw_options
+ *	Set firmware options.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	fwopt = pointer for firmware options.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_get_fw_options(scsi_qla_host_t *ha, uint16_t *fwopts)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
+
+	mcp->mb[0] = MBC_GET_FIRMWARE_OPTION;
+	mcp->out_mb = MBX_0;
+	mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
+		    ha->host_no, rval));
+	} else {
+		fwopts[1] = mcp->mb[1];
+		fwopts[2] = mcp->mb[2];
+		fwopts[3] = mcp->mb[3];
+
+		DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
+	}
+
+	return rval;
+}
+
+
+/*
+ * qla2x00_set_fw_options
+ *	Set firmware options.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	fwopt = pointer for firmware options.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_set_fw_options(scsi_qla_host_t *ha, uint16_t *fwopts)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
+
+	mcp->mb[0] = MBC_SET_FIRMWARE_OPTION;
+	mcp->mb[1] = fwopts[1];
+	mcp->mb[2] = fwopts[2];
+	mcp->mb[3] = fwopts[3];
+	mcp->mb[10] = fwopts[10];
+	mcp->mb[11] = fwopts[11];
+	mcp->mb[12] = 0;	/* Undocumented, but used */
+	mcp->out_mb = MBX_12|MBX_11|MBX_10|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
+		    ha->host_no, rval));
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_read_ram_word
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_read_ram_word(scsi_qla_host_t *ha, uint16_t addr, uint16_t *data)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("qla2x00_read_ram_word(%ld): entered.\n", ha->host_no);)
+
+	mcp->mb[0] = MBC_READ_RAM_WORD;
+	mcp->mb[1] = addr;
+	mcp->out_mb = MBX_1|MBX_0;
+	mcp->in_mb = MBX_0|MBX_2;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("qla2x00_read_ram_word(%ld): failed=%x.\n",
+		    ha->host_no, rval);)
+	} else {
+		*data = mcp->mb[2];
+		DEBUG11(printk("qla2x00_read_ram_word(%ld): done.\n",
+		    ha->host_no);)
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_write_ram_word
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_write_ram_word(scsi_qla_host_t *ha, uint16_t addr, uint16_t data)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("qla2x00_write_ram_word(%ld): entered.\n",
+	    ha->host_no);)
+
+	mcp->mb[0] = MBC_WRITE_RAM_WORD;
+	mcp->mb[1] = addr;
+	mcp->mb[2] = data;
+	mcp->out_mb = MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("qla2x00_write_ram_word(%ld): failed=%x.\n",
+		    ha->host_no, rval);)
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("qla2x00_write_ram_word(%ld): done.\n",
+		    ha->host_no);)
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_write_ram_word_ext
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_write_ram_word_ext(scsi_qla_host_t *ha, uint32_t addr, uint16_t data)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
+
+	mcp->mb[0] = MBC_WRITE_RAM_WORD_EXTENDED;
+	mcp->mb[1] = LSW(addr);
+	mcp->mb[2] = data;
+	mcp->mb[8] = MSW(addr);
+	mcp->out_mb = MBX_8|MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
+		    ha->host_no, rval));
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_mbx_reg_test
+ *	Mailbox register wrap test.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	TARGET_QUEUE_LOCK must be released.
+ *	ADAPTER_STATE_LOCK must be released.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_mbx_reg_test(scsi_qla_host_t *ha)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("qla2x00_mbx_reg_test(%ld): entered.\n", ha->host_no);)
+
+	mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST;
+	mcp->mb[1] = 0xAAAA;
+	mcp->mb[2] = 0x5555;
+	mcp->mb[3] = 0xAA55;
+	mcp->mb[4] = 0x55AA;
+	mcp->mb[5] = 0xA5A5;
+	mcp->mb[6] = 0x5A5A;
+	mcp->mb[7] = 0x2525;
+	mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval == QLA_SUCCESS) {
+		if (mcp->mb[1] != 0xAAAA || mcp->mb[2] != 0x5555 ||
+		    mcp->mb[3] != 0xAA55 || mcp->mb[4] != 0x55AA)
+			rval = QLA_FUNCTION_FAILED;
+		if (mcp->mb[5] != 0xA5A5 || mcp->mb[6] != 0x5A5A ||
+		    mcp->mb[7] != 0x2525)
+			rval = QLA_FUNCTION_FAILED;
+	}
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("qla2x00_mbx_reg_test(%ld): failed=%x.\n",
+		    ha->host_no, rval);)
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("qla2x00_mbx_reg_test(%ld): done.\n",
+		    ha->host_no);)
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_verify_checksum
+ *	Verify firmware checksum.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	TARGET_QUEUE_LOCK must be released.
+ *	ADAPTER_STATE_LOCK must be released.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_verify_checksum(scsi_qla_host_t *ha)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("qla2x00_verify_checksum(%ld): entered.\n",
+	    ha->host_no);)
+
+	mcp->mb[0] = MBC_VERIFY_CHECKSUM;
+	mcp->mb[1] = *ha->brd_info->fw_info[0].fwstart;
+	mcp->out_mb = MBX_1|MBX_0;
+	mcp->in_mb = MBX_2|MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("qla2x00_verify_checksum(%ld): failed=%x.\n",
+		    ha->host_no, rval);)
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("qla2x00_verify_checksum(%ld): done.\n",
+		    ha->host_no);)
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_issue_iocb
+ *	Issue IOCB using mailbox command
+ *
+ * Input:
+ *	ha = adapter state pointer.
+ *	buffer = buffer pointer.
+ *	phys_addr = physical address of buffer.
+ *	size = size of buffer.
+ *	TARGET_QUEUE_LOCK must be released.
+ *	ADAPTER_STATE_LOCK must be released.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_issue_iocb(scsi_qla_host_t *ha, void*  buffer, dma_addr_t phys_addr,
+    size_t size)
+{
+	int		rval;
+	mbx_cmd_t	mc;
+	mbx_cmd_t	*mcp = &mc;
+
+	ENTER("qla2x00_issue_iocb: started");
+
+	mcp->mb[0] = MBC_IOCB_COMMAND_A64;
+	mcp->mb[1] = 0;
+	mcp->mb[2] = MSW(phys_addr);
+	mcp->mb[3] = LSW(phys_addr);
+	mcp->mb[6] = MSW(MSD(phys_addr));
+	mcp->mb[7] = LSW(MSD(phys_addr));
+	mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_2|MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG(printk("qla2x00_issue_iocb(%ld): failed rval 0x%x",
+		    ha->host_no,rval);)
+		DEBUG2(printk("qla2x00_issue_iocb(%ld): failed rval 0x%x",
+		    ha->host_no,rval);)
+	} else {
+		/*EMPTY*/
+		LEAVE("qla2x00_issue_iocb: exiting normally");
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_abort_command
+ *	Abort command aborts a specified IOCB.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	sp = SB structure pointer.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_abort_command(scsi_qla_host_t *ha, srb_t *sp)
+{
+	unsigned long   flags = 0;
+	fc_port_t	*fcport;
+	int		rval;
+	uint32_t	handle;
+	mbx_cmd_t	mc;
+	mbx_cmd_t	*mcp = &mc;
+
+	DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", ha->host_no);)
+
+	fcport = sp->fclun->fcport;
+
+	if (atomic_read(&ha->loop_state) == LOOP_DOWN ||
+	    atomic_read(&fcport->state) == FCS_DEVICE_LOST) {
+		/* v2.19.8 Ignore abort request if port is down */
+		return 1;
+	}
+
+	spin_lock_irqsave(&ha->hardware_lock, flags);
+	for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) {
+		if (ha->outstanding_cmds[handle] == sp)
+			break;
+	}
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+	if (handle == MAX_OUTSTANDING_COMMANDS) {
+		/* command not found */
+		return QLA_FUNCTION_FAILED;
+	}
+
+	mcp->mb[0] = MBC_ABORT_COMMAND;
+	if (HAS_EXTENDED_IDS(ha))
+		mcp->mb[1] = fcport->loop_id;
+	else
+		mcp->mb[1] = fcport->loop_id << 8;
+	mcp->mb[2] = (uint16_t)handle;
+	mcp->mb[3] = (uint16_t)(handle >> 16);
+	mcp->mb[6] = (uint16_t)sp->fclun->lun;
+	mcp->out_mb = MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		DEBUG2_3_11(printk("qla2x00_abort_command(%ld): failed=%x.\n",
+		    ha->host_no, rval);)
+	} else {
+		sp->flags |= SRB_ABORT_PENDING;
+		DEBUG11(printk("qla2x00_abort_command(%ld): done.\n",
+		    ha->host_no);)
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_abort_device
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *      loop_id  = FC loop ID
+ *      lun  = SCSI LUN.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_abort_device(scsi_qla_host_t *ha, uint16_t loop_id, uint16_t lun)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("qla2x00_abort_device(%ld): entered.\n", ha->host_no);)
+
+	mcp->mb[0] = MBC_ABORT_DEVICE;
+	if (HAS_EXTENDED_IDS(ha))
+		mcp->mb[1] = loop_id;
+	else
+		mcp->mb[1] = loop_id << 8;
+	mcp->mb[2] = lun;
+	mcp->out_mb = MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	/* Issue marker command. */
+	qla2x00_marker(ha, loop_id, lun, MK_SYNC_ID_LUN);
+
+	if (rval != QLA_SUCCESS) {
+		set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
+		if (ha->dpc_wait && !ha->dpc_active) 
+			up(ha->dpc_wait);
+		DEBUG2_3_11(printk("qla2x00_abort_device(%ld): failed=%x.\n",
+		    ha->host_no, rval);)
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("qla2x00_abort_device(%ld): done.\n",
+		    ha->host_no);)
+	}
+
+	return rval;
+}
+
+#if USE_ABORT_TGT
+/*
+ * qla2x00_abort_target
+ *	Issue abort target mailbox command.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_abort_target(fc_port_t *fcport)
+{
+	int        rval;
+	mbx_cmd_t  mc;
+	mbx_cmd_t  *mcp = &mc;
+
+	DEBUG11(printk("qla2x00_abort_target(%ld): entered.\n",
+	    fcport->ha->host_no);)
+
+	if (fcport == NULL) {
+		/* no target to abort */
+		return 0;
+	}
+
+	mcp->mb[0] = MBC_ABORT_TARGET;
+	mcp->out_mb = MBX_2|MBX_1|MBX_0;
+	if (HAS_EXTENDED_IDS(fcport->ha)) {
+		mcp->mb[1] = fcport->loop_id;
+		mcp->mb[10] = 0;
+		mcp->out_mb |= MBX_10;
+	} else {
+		mcp->mb[1] = fcport->loop_id << 8;
+	}
+	mcp->mb[2] = fcport->ha->loop_reset_delay;
+
+	mcp->in_mb = MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(fcport->ha, mcp);
+
+	/* Issue marker command. */
+	fcport->ha->marker_needed = 1;
+
+	if (rval != QLA_SUCCESS) {
+		DEBUG2_3_11(printk("qla2x00_abort_target(%ld): failed=%x.\n",
+		    fcport->ha->host_no, rval);)
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("qla2x00_abort_target(%ld): done.\n",
+		    fcport->ha->host_no);)
+	}
+
+	return rval;
+}
+#endif
+
+/*
+ * qla2x00_target_reset
+ *	Issue target reset mailbox command.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	TARGET_QUEUE_LOCK must be released.
+ *	ADAPTER_STATE_LOCK must be released.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_target_reset(scsi_qla_host_t *ha, uint16_t b, uint16_t t)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+	os_tgt_t *tgt;
+
+	DEBUG11(printk("qla2x00_target_reset(%ld): entered.\n", ha->host_no);)
+
+	tgt = TGT_Q(ha, t);
+	if (tgt->fcport == NULL) {
+		/* no target to abort */
+		return 0;
+	}
+	if (atomic_read(&tgt->fcport->state) != FCS_ONLINE) {
+		/* target not online */
+		return 0;
+	}
+
+	mcp->mb[0] = MBC_TARGET_RESET;
+	if (HAS_EXTENDED_IDS(ha))
+		mcp->mb[1] = tgt->fcport->loop_id;
+	else
+		mcp->mb[1] = tgt->fcport->loop_id << 8;
+	mcp->mb[2] = ha->loop_reset_delay;
+	mcp->out_mb = MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("qla2x00_target_reset(%ld): failed=%x.\n",
+		    ha->host_no, rval);)
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("qla2x00_target_reset(%ld): done.\n",
+		    ha->host_no);)
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_get_adapter_id
+ *	Get adapter ID and topology.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	id = pointer for loop ID.
+ *	al_pa = pointer for AL_PA.
+ *	area = pointer for area.
+ *	domain = pointer for domain.
+ *	top = pointer for topology.
+ *	TARGET_QUEUE_LOCK must be released.
+ *	ADAPTER_STATE_LOCK must be released.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_get_adapter_id(scsi_qla_host_t *ha, uint16_t *id, uint8_t *al_pa,
+    uint8_t *area, uint8_t *domain, uint16_t *top)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("qla2x00_get_adapter_id(%ld): entered.\n",
+	    ha->host_no);)
+
+	mcp->mb[0] = MBC_GET_ADAPTER_LOOP_ID;
+	mcp->out_mb = MBX_0;
+	mcp->in_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	/* Return data. */
+	*id = mcp->mb[1];
+	*al_pa = LSB(mcp->mb[2]);
+	*area = MSB(mcp->mb[2]);
+	*domain	= LSB(mcp->mb[3]);
+	*top = mcp->mb[6];
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("qla2x00_get_adapter_id(%ld): failed=%x.\n",
+		    ha->host_no, rval);)
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("qla2x00_get_adapter_id(%ld): done.\n",
+		    ha->host_no);)
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_get_retry_cnt
+ *	Get current firmware login retry count and delay.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	retry_cnt = pointer to login retry count.
+ *	tov = pointer to login timeout value.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_get_retry_cnt(scsi_qla_host_t *ha, uint8_t *retry_cnt, uint8_t *tov,
+    uint16_t *r_a_tov)
+{
+	int rval;
+	uint16_t ratov;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("qla2x00_get_retry_cnt(%ld): entered.\n",
+			ha->host_no);)
+
+	mcp->mb[0] = MBC_GET_RETRY_COUNT;
+	mcp->out_mb = MBX_0;
+	mcp->in_mb = MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("qla2x00_get_retry_cnt(%ld): failed = %x.\n",
+		    ha->host_no, mcp->mb[0]);)
+	} else {
+		/* Convert returned data and check our values. */
+		*r_a_tov = mcp->mb[3] / 2;
+		ratov = (mcp->mb[3]/2) / 10;  /* mb[3] value is in 100ms */
+		if (mcp->mb[1] * ratov > (*retry_cnt) * (*tov)) {
+			/* Update to the larger values */
+			*retry_cnt = (uint8_t)mcp->mb[1];
+			*tov = ratov;
+		}
+
+		DEBUG11(printk("qla2x00_get_retry_cnt(%ld): done. mb3=%d "
+		    "ratov=%d.\n", ha->host_no, mcp->mb[3], ratov);)
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_init_firmware
+ *	Initialize adapter firmware.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	dptr = Initialization control block pointer.
+ *	size = size of initialization control block.
+ *	TARGET_QUEUE_LOCK must be released.
+ *	ADAPTER_STATE_LOCK must be released.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_init_firmware(scsi_qla_host_t *ha, uint16_t size)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("qla2x00_init_firmware(%ld): entered.\n",
+	    ha->host_no);)
+
+	mcp->mb[0] = MBC_INITIALIZE_FIRMWARE;
+	mcp->mb[2] = MSW(ha->init_cb_dma);
+	mcp->mb[3] = LSW(ha->init_cb_dma);
+	mcp->mb[4] = 0;
+	mcp->mb[5] = 0;
+	mcp->mb[6] = MSW(MSD(ha->init_cb_dma));
+	mcp->mb[7] = LSW(MSD(ha->init_cb_dma));
+	mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
+	mcp->in_mb = MBX_5|MBX_4|MBX_0;
+	mcp->buf_size = size;
+	mcp->flags = MBX_DMA_OUT;
+	mcp->tov = 30;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("qla2x00_init_firmware(%ld): failed=%x "
+		    "mb0=%x.\n",
+		    ha->host_no, rval, mcp->mb[0]);)
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("qla2x00_init_firmware(%ld): done.\n",
+		    ha->host_no);)
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_get_port_database
+ *	Issue normal/enhanced get port database mailbox command
+ *	and copy device name as necessary.
+ *
+ * Input:
+ *	ha = adapter state pointer.
+ *	dev = structure pointer.
+ *	opt = enhanced cmd option byte.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+	port_database_t *pd;
+	dma_addr_t pd_dma;
+
+	DEBUG11(printk("qla2x00_get_port_database(%ld): entered.\n",
+	    ha->host_no);)
+
+	pd = pci_alloc_consistent(ha->pdev, PORT_DATABASE_SIZE, &pd_dma);
+	if (pd  == NULL) {
+		DEBUG2_3_11(printk("qla2x00_get_port_database(%ld): **** "
+		    "Mem Alloc Failed ****", ha->host_no);)
+		return QLA_MEMORY_ALLOC_FAILED;
+	}
+	memset(pd, 0, PORT_DATABASE_SIZE);
+
+	if (opt != 0)
+		mcp->mb[0] = MBC_ENHANCED_GET_PORT_DATABASE;
+	else
+		mcp->mb[0] = MBC_GET_PORT_DATABASE;
+	mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
+	if (HAS_EXTENDED_IDS(ha)) {
+		mcp->mb[1] = fcport->loop_id;
+		mcp->mb[10] = opt;
+		mcp->out_mb |= MBX_10;
+	} else {
+		mcp->mb[1] = fcport->loop_id << 8 | opt;
+	}
+	mcp->mb[2] = MSW(pd_dma);
+	mcp->mb[3] = LSW(pd_dma);
+	mcp->mb[6] = MSW(MSD(pd_dma));
+	mcp->mb[7] = LSW(MSD(pd_dma));
+
+	mcp->in_mb = MBX_0;
+	mcp->buf_size = PORT_DATABASE_SIZE;
+	mcp->flags = MBX_DMA_IN;
+	mcp->tov =  ha->login_timeout * 2;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval == QLA_SUCCESS) {
+		/* Names are little-endian. */
+		memcpy(fcport->node_name, pd->node_name, WWN_SIZE);
+		memcpy(fcport->port_name, pd->port_name, WWN_SIZE);
+
+		/* Get port_id of device. */
+		fcport->d_id.b.al_pa = pd->port_id[2];
+		fcport->d_id.b.area = pd->port_id[3];
+		fcport->d_id.b.domain = pd->port_id[0];
+		fcport->d_id.b.rsvd_1 = 0;
+
+		/* Check for device require authentication. */
+		pd->common_features & BIT_5 ? (fcport->flags |= FCF_AUTH_REQ) :
+		    (fcport->flags &= ~FCF_AUTH_REQ);
+
+		/* If not target must be initiator or unknown type. */
+		if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0) {
+			fcport->port_type = FCT_INITIATOR;
+		} else {
+			fcport->port_type = FCT_TARGET;
+
+			/* Check for logged in. */
+			if (pd->master_state != PD_STATE_PORT_LOGGED_IN &&
+			    pd->slave_state != PD_STATE_PORT_LOGGED_IN)
+				rval = QLA_FUNCTION_FAILED;
+		}
+	}
+
+	pci_free_consistent(ha->pdev, PORT_DATABASE_SIZE, pd, pd_dma);
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("qla2x00_get_port_database(%ld): "
+		    "failed=%x.\n", ha->host_no, rval);)
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("qla2x00_get_port_database(%ld): done.\n",
+		    ha->host_no);)
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_get_firmware_state
+ *	Get adapter firmware state.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	dptr = pointer for firmware state.
+ *	TARGET_QUEUE_LOCK must be released.
+ *	ADAPTER_STATE_LOCK must be released.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_get_firmware_state(scsi_qla_host_t *ha, uint16_t *dptr)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("qla2x00_get_firmware_state(%ld): entered.\n",
+	    ha->host_no);)
+
+	mcp->mb[0] = MBC_GET_FIRMWARE_STATE;
+	mcp->out_mb = MBX_0;
+	mcp->in_mb = MBX_2|MBX_1|MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	/* Return firmware state. */
+	*dptr = mcp->mb[1];
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("qla2x00_get_firmware_state(%ld): "
+		    "failed=%x.\n", ha->host_no, rval);)
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("qla2x00_get_firmware_state(%ld): done.\n",
+		    ha->host_no);)
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_get_port_name
+ *	Issue get port name mailbox command.
+ *	Returned name is in big endian format.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	loop_id = loop ID of device.
+ *	name = pointer for name.
+ *	TARGET_QUEUE_LOCK must be released.
+ *	ADAPTER_STATE_LOCK must be released.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_get_port_name(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t *name,
+    uint8_t opt)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("qla2x00_get_port_name(%ld): entered.\n",
+	    ha->host_no);)
+
+	mcp->mb[0] = MBC_GET_PORT_NAME;
+	mcp->out_mb = MBX_1|MBX_0;
+	if (HAS_EXTENDED_IDS(ha)) {
+		mcp->mb[1] = loop_id;
+		mcp->mb[10] = opt;
+		mcp->out_mb |= MBX_10;
+	} else {
+		mcp->mb[1] = loop_id << 8 | opt;
+	}
+
+	mcp->in_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("qla2x00_get_port_name(%ld): failed=%x.\n",
+		    ha->host_no, rval);)
+	} else {
+		if (name != NULL) {
+			/* This function returns name in big endian. */
+			name[0] = LSB(mcp->mb[2]);
+			name[1] = MSB(mcp->mb[2]);
+			name[2] = LSB(mcp->mb[3]);
+			name[3] = MSB(mcp->mb[3]);
+			name[4] = LSB(mcp->mb[6]);
+			name[5] = MSB(mcp->mb[6]);
+			name[6] = LSB(mcp->mb[7]);
+			name[7] = MSB(mcp->mb[7]);
+		}
+
+		DEBUG11(printk("qla2x00_get_port_name(%ld): done.\n",
+		    ha->host_no);)
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_get_link_status
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	loop_id = device loop ID.
+ *	ret_buf = pointer to link status return buffer.
+ *
+ * Returns:
+ *	0 = success.
+ *	BIT_0 = mem alloc error.
+ *	BIT_1 = mailbox error.
+ */
+uint8_t
+qla2x00_get_link_status(scsi_qla_host_t *ha, uint8_t loop_id, void *ret_buf,
+    uint16_t *status)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+	link_stat_t *stat_buf;
+	dma_addr_t phys_address = 0;
+
+
+	DEBUG11(printk("qla2x00_get_link_status(%ld): entered.\n",
+	    ha->host_no);)
+
+	stat_buf = pci_alloc_consistent(ha->pdev, sizeof(link_stat_t),
+	    &phys_address);
+	if (stat_buf == NULL) {
+		DEBUG2_3_11(printk("qla2x00_get_link_status(%ld): Failed to "
+		    "allocate memory.\n", ha->host_no));
+		return BIT_0;
+	}
+	memset(stat_buf, 0, sizeof(link_stat_t));
+
+	mcp->mb[0] = MBC_GET_LINK_STATUS;
+	mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
+	if (HAS_EXTENDED_IDS(ha)) {
+		mcp->mb[1] = loop_id;
+		mcp->mb[10] = 0;
+		mcp->out_mb |= MBX_10;
+	} else {
+		mcp->mb[1] = loop_id << 8;
+	}
+	mcp->mb[2] = MSW(phys_address);
+	mcp->mb[3] = LSW(phys_address);
+	mcp->mb[6] = MSW(MSD(phys_address));
+	mcp->mb[7] = LSW(MSD(phys_address));
+
+	mcp->in_mb = MBX_0;
+	mcp->tov = 30;
+	mcp->flags = IOCTL_CMD;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval == QLA_SUCCESS) {
+		if (mcp->mb[0] != MBS_COMMAND_COMPLETE) {
+			DEBUG2_3_11(printk("qla2x00_get_link_status(%ld): cmd "
+			    "failed. mbx0=%x.\n", ha->host_no, mcp->mb[0]);)
+			status[0] = mcp->mb[0];
+			rval = BIT_1;
+		} else {
+			/* copy over data */
+			memcpy(ret_buf, stat_buf,sizeof(link_stat_t));
+			DEBUG(printk("qla2x00_get_link_status(%ld): stat dump: "
+			    "fail_cnt=%d loss_sync=%d loss_sig=%d seq_err=%d "
+			    "inval_xmt_word=%d inval_crc=%d.\n",
+			    ha->host_no,
+			    stat_buf->link_fail_cnt, stat_buf->loss_sync_cnt,
+			    stat_buf->loss_sig_cnt, stat_buf->prim_seq_err_cnt,
+			    stat_buf->inval_xmit_word_cnt,
+			    stat_buf->inval_crc_cnt);)
+			DEBUG11(printk("qla2x00_get_link_status(%ld): stat "
+			    "dump: fail_cnt=%d loss_sync=%d loss_sig=%d "
+			    "seq_err=%d inval_xmt_word=%d inval_crc=%d.\n",
+			    ha->host_no,
+			    stat_buf->link_fail_cnt, stat_buf->loss_sync_cnt,
+			    stat_buf->loss_sig_cnt, stat_buf->prim_seq_err_cnt,
+			    stat_buf->inval_xmit_word_cnt,
+			    stat_buf->inval_crc_cnt);)
+		}
+	} else {
+		/* Failed. */
+		DEBUG2_3_11(printk("qla2x00_get_link_status(%ld): failed=%x.\n",
+		    ha->host_no, rval);)
+		rval = BIT_1;
+	}
+
+	pci_free_consistent(ha->pdev, sizeof(link_stat_t),
+	    stat_buf, phys_address);
+
+	return rval;
+}
+
+/*
+ * qla2x00_lip_reset
+ *	Issue LIP reset mailbox command.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	TARGET_QUEUE_LOCK must be released.
+ *	ADAPTER_STATE_LOCK must be released.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_lip_reset(scsi_qla_host_t *ha)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("qla2x00_lip_reset(%ld): entered.\n",
+	    ha->host_no);)
+
+	mcp->mb[0] = MBC_LIP_RESET;
+	mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
+	if (HAS_EXTENDED_IDS(ha)) {
+		mcp->mb[1] = 0x00ff;
+		mcp->mb[10] = 0;
+		mcp->out_mb |= MBX_10;
+	} else {
+		mcp->mb[1] = 0xff00;
+	}
+	mcp->mb[2] = ha->loop_reset_delay;
+	mcp->mb[3] = 0;
+
+	mcp->in_mb = MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("qla2x00_lip_reset(%ld): failed=%x.\n",
+		    ha->host_no, rval);)
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("qla2x00_lip_reset(%ld): done.\n", ha->host_no);)
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_send_sns
+ *	Send SNS command.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	sns = pointer for command.
+ *	cmd_size = command size.
+ *	buf_size = response/command size.
+ *	TARGET_QUEUE_LOCK must be released.
+ *	ADAPTER_STATE_LOCK must be released.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_send_sns(scsi_qla_host_t *ha, dma_addr_t sns_phys_address,
+    uint16_t cmd_size, size_t buf_size)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("qla2x00_send_sns(%ld): entered.\n",
+	    ha->host_no);)
+
+	DEBUG11(printk("qla2x00_send_sns: retry cnt=%d ratov=%d total "
+	    "tov=%d.\n", ha->retry_count, ha->login_timeout, mcp->tov);)
+
+	mcp->mb[0] = MBC_SEND_SNS_COMMAND;
+	mcp->mb[1] = cmd_size;
+	mcp->mb[2] = MSW(sns_phys_address);
+	mcp->mb[3] = LSW(sns_phys_address);
+	mcp->mb[6] = MSW(MSD(sns_phys_address));
+	mcp->mb[7] = LSW(MSD(sns_phys_address));
+	mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_0|MBX_1;
+	mcp->buf_size = buf_size;
+	mcp->flags = MBX_DMA_OUT|MBX_DMA_IN;
+	/*mcp->tov = ha->retry_count * ha->login_timeout * 2;*/
+	mcp->tov =  ha->login_timeout * 2;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x "
+		    "mb[1]=%x.\n", ha->host_no, rval, mcp->mb[0], mcp->mb[1]);)
+		DEBUG2_3_11(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x "
+		    "mb[1]=%x.\n", ha->host_no, rval, mcp->mb[0], mcp->mb[1]);)
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("qla2x00_send_sns(%ld): done.\n", ha->host_no);)
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_login_fabric
+ *	Issue login fabric port mailbox command.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	loop_id = device loop ID.
+ *	domain = device domain.
+ *	area = device area.
+ *	al_pa = device AL_PA.
+ *	status = pointer for return status.
+ *	opt = command options.
+ *	TARGET_QUEUE_LOCK must be released.
+ *	ADAPTER_STATE_LOCK must be released.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_login_fabric(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t domain,
+    uint8_t area, uint8_t al_pa, uint16_t *mb, uint8_t opt)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("qla2x00_login_fabric(%ld): entered.\n", ha->host_no);)
+
+	mcp->mb[0] = MBC_LOGIN_FABRIC_PORT;
+	mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
+	if (HAS_EXTENDED_IDS(ha)) {
+		mcp->mb[1] = loop_id;
+		mcp->mb[10] = opt;
+		mcp->out_mb |= MBX_10;
+	} else {
+		mcp->mb[1] = (loop_id << 8) | opt;
+	}
+	mcp->mb[2] = domain;
+	mcp->mb[3] = area << 8 | al_pa;
+
+	mcp->in_mb = MBX_7|MBX_6|MBX_2|MBX_1|MBX_0;
+	/*mcp->tov = ha->retry_count * ha->login_timeout * 2;*/
+	mcp->tov = ha->login_timeout * 2;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	/* Return mailbox statuses. */
+	if (mb != NULL) {
+		mb[0] = mcp->mb[0];
+		mb[1] = mcp->mb[1];
+		mb[2] = mcp->mb[2];
+		mb[6] = mcp->mb[6];
+		mb[7] = mcp->mb[7];
+	}
+
+	if (rval != QLA_SUCCESS) {
+		/* RLU tmp code: need to change main mailbox_command function to
+		 * return ok even when the mailbox completion value is not
+		 * SUCCESS. The caller needs to be responsible to interpret
+		 * the return values of this mailbox command if we're not
+		 * to change too much of the existing code.
+		 */
+		if (mcp->mb[0] == 0x4001 || mcp->mb[0] == 0x4002 ||
+		    mcp->mb[0] == 0x4003 || mcp->mb[0] == 0x4005 ||
+		    mcp->mb[0] == 0x4006)
+			rval = QLA_SUCCESS;
+
+		/*EMPTY*/
+		DEBUG2_3_11(printk("qla2x00_login_fabric(%ld): failed=%x "
+		    "mb[0]=%x mb[1]=%x mb[2]=%x.\n", ha->host_no, rval,
+		    mcp->mb[0], mcp->mb[1], mcp->mb[2]);)
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("qla2x00_login_fabric(%ld): done.\n",
+		    ha->host_no);)
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_login_local_device
+ *           Issue login loop port mailbox command.
+ *    
+ * Input:
+ *           ha = adapter block pointer.
+ *           loop_id = device loop ID.
+ *           opt = command options.
+ *          
+ * Returns:
+ *            Return status code.
+ *             
+ * Context:
+ *            Kernel context.
+ *             
+ */
+int
+qla2x00_login_local_device(scsi_qla_host_t *ha, uint16_t loop_id,
+    uint16_t *mb_ret, uint8_t opt)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG3(printk("%s(%ld): entered.\n", __func__, ha->host_no);)
+
+	mcp->mb[0] = MBC_LOGIN_LOOP_PORT;
+	if (HAS_EXTENDED_IDS(ha))
+		mcp->mb[1] = loop_id;
+	else
+		mcp->mb[1] = loop_id << 8;
+	mcp->mb[2] = opt;
+	mcp->out_mb = MBX_2|MBX_1|MBX_0;
+ 	mcp->in_mb = MBX_7|MBX_6|MBX_1|MBX_0;
+	mcp->tov =  ha->login_timeout * 2;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+ 	/* Return mailbox statuses. */
+ 	if (mb_ret != NULL) {
+ 		mb_ret[0] = mcp->mb[0];
+ 		mb_ret[1] = mcp->mb[1];
+ 		mb_ret[6] = mcp->mb[6];
+ 		mb_ret[7] = mcp->mb[7];
+ 	}
+
+	if (rval != QLA_SUCCESS) {
+ 		/* AV tmp code: need to change main mailbox_command function to
+ 		 * return ok even when the mailbox completion value is not
+ 		 * SUCCESS. The caller needs to be responsible to interpret
+ 		 * the return values of this mailbox command if we're not
+ 		 * to change too much of the existing code.
+ 		 */
+ 		if (mcp->mb[0] == 0x4005 || mcp->mb[0] == 0x4006)
+ 			rval = QLA_SUCCESS;
+
+		DEBUG(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "
+		    "mb[6]=%x mb[7]=%x.\n", __func__, ha->host_no, rval,
+		    mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7]);)
+		DEBUG2_3(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "
+		    "mb[6]=%x mb[7]=%x.\n", __func__, ha->host_no, rval,
+		    mcp->mb[0], mcp->mb[1], mcp->mb[6], mcp->mb[7]);)
+	} else {
+		/*EMPTY*/
+		DEBUG3(printk("%s(%ld): done.\n", __func__, ha->host_no);)
+	}
+
+	return (rval);
+}
+
+/*
+ * qla2x00_fabric_logout
+ *	Issue logout fabric port mailbox command.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	loop_id = device loop ID.
+ *	TARGET_QUEUE_LOCK must be released.
+ *	ADAPTER_STATE_LOCK must be released.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_fabric_logout(scsi_qla_host_t *ha, uint16_t loop_id)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("qla2x00_fabric_logout(%ld): entered.\n",
+	    ha->host_no);)
+
+	mcp->mb[0] = MBC_LOGOUT_FABRIC_PORT;
+	mcp->out_mb = MBX_1|MBX_0;
+	if (HAS_EXTENDED_IDS(ha)) {
+		mcp->mb[1] = loop_id;
+		mcp->mb[10] = 0;
+		mcp->out_mb |= MBX_10;
+	} else {
+		mcp->mb[1] = loop_id << 8;
+	}
+
+	mcp->in_mb = MBX_1|MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("qla2x00_fabric_logout(%ld): failed=%x "
+		    "mbx1=%x.\n", ha->host_no, rval, mcp->mb[1]);)
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("qla2x00_fabric_logout(%ld): done.\n",
+		    ha->host_no);)
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_full_login_lip
+ *	Issue full login LIP mailbox command.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	TARGET_QUEUE_LOCK must be released.
+ *	ADAPTER_STATE_LOCK must be released.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_full_login_lip(scsi_qla_host_t *ha)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("qla2x00_full_login_lip(%ld): entered.\n",
+	    ha->host_no);)
+
+	mcp->mb[0] = MBC_LIP_FULL_LOGIN;
+	mcp->mb[1] = 0;
+	mcp->mb[2] = 0;
+	mcp->mb[3] = 0;
+	mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("qla2x00_full_login_lip(%ld): failed=%x.\n",
+		    ha->instance, rval);)
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("qla2x00_full_login_lip(%ld): done.\n",
+		    ha->host_no);)
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_get_id_list
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_get_id_list(scsi_qla_host_t *ha, void *id_list, dma_addr_t id_list_dma,
+    uint16_t *entries)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("qla2x00_get_id_list(%ld): entered.\n",
+	    ha->host_no);)
+
+	if (id_list == NULL)
+		return QLA_FUNCTION_FAILED;
+
+	mcp->mb[0] = MBC_GET_ID_LIST;
+	mcp->mb[1] = MSW(id_list_dma);
+	mcp->mb[2] = LSW(id_list_dma);
+	mcp->mb[3] = MSW(MSD(id_list_dma));
+	mcp->mb[6] = LSW(MSD(id_list_dma));
+	mcp->out_mb = MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_1|MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("qla2x00_get_id_list(%ld): failed=%x.\n",
+		    ha->host_no, rval);)
+	} else {
+		*entries = mcp->mb[1];
+		DEBUG11(printk("qla2x00_get_id_list(%ld): done.\n",
+		    ha->host_no);)
+	}
+
+	return rval;
+}
+
+#if 0 /* not yet needed */
+int
+qla2x00_dump_ram(scsi_qla_host_t *ha, uint32_t risc_address,
+    dma_addr_t ispdump_dma, uint32_t size)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	mcp->mb[0] = MBC_DUMP_RAM;
+	mcp->mb[1] = risc_address & 0xffff;
+	mcp->mb[2] = MSW(ispdump_dma);
+	mcp->mb[3] = LSW(ispdump_dma);
+	mcp->mb[4] = 0;
+	mcp->mb[6] = MSW(MSD(ispdump_dma));
+	mcp->mb[7] = LSW(MSD(ispdump_dma));
+	mcp->out_mb = MBX_7|MBX_6|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	return rval;
+}
+#endif
+
+/*
+ * qla2x00_lun_reset
+ *	Issue lun reset mailbox command.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	loop_id = device loop ID.
+ *      lun = lun to be reset.
+ *	TARGET_QUEUE_LOCK must be released.
+ *	ADAPTER_STATE_LOCK must be released.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_lun_reset(scsi_qla_host_t *ha, uint16_t loop_id, uint16_t lun)
+{
+	int		rval;
+	mbx_cmd_t	mc;
+	mbx_cmd_t	*mcp = &mc;
+
+	ENTER("qla2x00_lun_reset");
+
+	mcp->mb[0] = MBC_LUN_RESET;
+	if (HAS_EXTENDED_IDS(ha))
+		mcp->mb[1] = loop_id;
+	else
+		mcp->mb[1] = loop_id << 8;
+	mcp->mb[2] = lun;
+	mcp->out_mb = MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		printk(KERN_WARNING "qla2x00_lun_reset(%d): failed = %d",
+		    (int)ha->instance, rval);
+	} else {
+		/*EMPTY*/
+		LEAVE("qla2x00_lun_reset: exiting normally");
+	}
+
+	return rval;
+}
+
+/*
+ * qla2x00_send_rnid_mbx
+ *	Issue RNID ELS using mailbox command
+ *
+ * Input:
+ *	ha = adapter state pointer.
+ *	loop_id = loop ID of the target device.
+ *	data_fmt = currently supports only 0xDF.
+ *	buffer = buffer pointer.
+ *	buf_size = size of buffer.
+ *	mb_reg = pointer to return mailbox registers.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_send_rnid_mbx(scsi_qla_host_t *ha, uint16_t loop_id, uint8_t data_fmt,
+    dma_addr_t buf_phys_addr, size_t buf_size, uint16_t *mb_reg)
+{
+	int		rval;
+	mbx_cmd_t	mc;
+	mbx_cmd_t	*mcp = &mc;
+
+	DEBUG11(printk("qla2x00_send_rnid_mbx(%ld): entered.\n",
+	    ha->host_no);)
+
+	mcp->mb[0] = MBC_SEND_RNID_ELS;
+	mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
+	if (HAS_EXTENDED_IDS(ha)) {
+		mcp->mb[1] = loop_id;
+		mcp->mb[10] = data_fmt;
+		mcp->out_mb |= MBX_10;
+	} else {
+		mcp->mb[1] = (loop_id << 8) | data_fmt;
+	}
+	mcp->mb[2] = MSW(buf_phys_addr);
+	mcp->mb[3] = LSW(buf_phys_addr);
+	mcp->mb[6] = MSW(MSD(buf_phys_addr));
+	mcp->mb[7] = LSW(MSD(buf_phys_addr));
+
+	mcp->in_mb = MBX_1|MBX_0;
+	mcp->buf_size = buf_size;
+	mcp->flags = MBX_DMA_IN;
+	mcp->tov = 30;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		memcpy(mb_reg, mcp->mb, 2 * 2); /* 2 status regs */
+
+		DEBUG2_3_11(printk("qla2x00_send_rnid_mbx(%ld): failed=%x "
+		    "mb[1]=%x.\n",
+		    ha->host_no, mcp->mb[0], mcp->mb[1]);)
+	} else {
+		/*EMPTY*/
+	 	DEBUG11(printk("qla2x00_send_rnid_mbx(%ld): done.\n",
+		     ha->host_no);)
+	}
+
+	return (rval);
+}
+
+/*
+ * qla2x00_set_rnid_params_mbx
+ *	Set RNID parameters using mailbox command
+ *
+ * Input:
+ *	ha = adapter state pointer.
+ *	buffer = buffer pointer.
+ *	buf_size = size of buffer.
+ *	mb_reg = pointer to return mailbox registers.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_set_rnid_params_mbx(scsi_qla_host_t *ha, dma_addr_t buf_phys_addr,
+    size_t buf_size, uint16_t *mb_reg)
+{
+	int		rval;
+	mbx_cmd_t	mc;
+	mbx_cmd_t	*mcp = &mc;
+
+	DEBUG11(printk("qla2x00_set_rnid_params_mbx(%ld): entered.\n",
+	    ha->host_no);)
+
+	mcp->mb[0] = MBC_SET_RNID_PARAMS;
+	mcp->mb[1] = 0;
+	mcp->mb[2] = MSW(buf_phys_addr);
+	mcp->mb[3] = LSW(buf_phys_addr);
+	mcp->mb[6] = MSW(MSD(buf_phys_addr));
+	mcp->mb[7] = LSW(MSD(buf_phys_addr));
+	mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_1|MBX_0;
+	mcp->buf_size = buf_size;
+	mcp->flags = MBX_DMA_OUT;
+	mcp->tov = 30;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		memcpy(mb_reg, mcp->mb, 2 * 2); /* 2 status regs */
+
+		DEBUG2_3_11(printk("qla2x00_set_rnid_params_mbx(%ld): "
+		    "failed=%x mb[1]=%x.\n", ha->host_no, mcp->mb[0],
+		    mcp->mb[1]);)
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("qla2x00_set_rnid_params_mbx(%ld): done.\n",
+		    ha->host_no);)
+	}
+
+	return (rval);
+}
+
+/*
+ * qla2x00_get_rnid_params_mbx
+ *	Get RNID parameters using mailbox command
+ *
+ * Input:
+ *	ha = adapter state pointer.
+ *	buffer = buffer pointer.
+ *	buf_size = size of buffer.
+ *	mb_reg = pointer to return mailbox registers.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_get_rnid_params_mbx(scsi_qla_host_t *ha, dma_addr_t buf_phys_addr,
+    size_t buf_size, uint16_t *mb_reg)
+{
+	int		rval;
+	mbx_cmd_t	mc;
+	mbx_cmd_t	*mcp = &mc;
+
+	DEBUG11(printk("qla2x00_get_rnid_params_mbx(%ld): entered.\n",
+	    ha->host_no);)
+
+	mcp->mb[0] = MBC_GET_RNID_PARAMS;
+	mcp->mb[1] = 0;
+	mcp->mb[2] = MSW(buf_phys_addr);
+	mcp->mb[3] = LSW(buf_phys_addr);
+	mcp->mb[6] = MSW(MSD(buf_phys_addr));
+	mcp->mb[7] = LSW(MSD(buf_phys_addr));
+	mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->in_mb = MBX_1|MBX_0;
+	mcp->buf_size = buf_size;
+	mcp->flags = MBX_DMA_IN;
+	mcp->tov = 30;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		memcpy(mb_reg, mcp->mb, 2 * 2); /* 2 status regs */
+
+		DEBUG2_3_11(printk("qla2x00_get_rnid_params_mbx(%ld): "
+		    "failed=%x mb[1]=%x.\n", ha->host_no, mcp->mb[0],
+		    mcp->mb[1]);)
+	} else {
+		/*EMPTY*/
+		DEBUG11(printk("qla2x00_get_rnid_params_mbx(%ld): done.\n",
+		    ha->host_no);)
+	}
+
+	return (rval);
+}
+
+/*
+ * qla2x00_get_resource_cnts
+ *	Get current firmware resource counts.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_get_resource_cnts(scsi_qla_host_t *ha, uint16_t *cur_xchg_cnt,
+    uint16_t *orig_xchg_cnt, uint16_t *cur_iocb_cnt, uint16_t *orig_iocb_cnt)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+
+	DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
+
+	mcp->mb[0] = MBC_GET_RESOURCE_COUNTS;
+	mcp->out_mb = MBX_0;
+	mcp->in_mb = MBX_10|MBX_7|MBX_6|MBX_3|MBX_2|MBX_1|MBX_0;
+	mcp->tov = 30;
+	mcp->flags = 0;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval != QLA_SUCCESS) {
+		/*EMPTY*/
+		DEBUG2_3_11(printk("%s(%ld): failed = %x.\n", __func__,
+		    ha->host_no, mcp->mb[0]);)
+	} else {
+		DEBUG11(printk("%s(%ld): done. mb1=%x mb2=%x mb3=%x mb6=%x "
+		    "mb7=%x mb10=%x.\n", __func__, ha->host_no,
+		    mcp->mb[1], mcp->mb[2], mcp->mb[3], mcp->mb[6], mcp->mb[7], 
+		    mcp->mb[10]));
+
+		if (cur_xchg_cnt)
+			*cur_xchg_cnt = mcp->mb[3];
+		if (orig_xchg_cnt)
+			*orig_xchg_cnt = mcp->mb[6];
+		if (cur_iocb_cnt)
+			*cur_iocb_cnt = mcp->mb[7];
+		if (orig_iocb_cnt)
+			*orig_iocb_cnt = mcp->mb[10];
+	}
+
+	return (rval);
+}
+
+#if defined(QL_DEBUG_LEVEL_3)
+/*
+ * qla2x00_get_fcal_position_map
+ *	Get FCAL (LILP) position map using mailbox command
+ *
+ * Input:
+ *	ha = adapter state pointer.
+ *	pos_map = buffer pointer (can be NULL).
+ *
+ * Returns:
+ *	qla2x00 local function return status code.
+ *
+ * Context:
+ *	Kernel context.
+ */
+int
+qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map)
+{
+	int rval;
+	mbx_cmd_t mc;
+	mbx_cmd_t *mcp = &mc;
+	char *pmap;
+	dma_addr_t pmap_dma;
+
+	pmap = pci_alloc_consistent(ha->pdev, FCAL_MAP_SIZE, &pmap_dma);
+	if (pmap  == NULL) {
+		DEBUG2_3_11(printk("%s(%ld): **** Mem Alloc Failed ****",
+		    __func__, ha->host_no));
+		return QLA_MEMORY_ALLOC_FAILED;
+	}
+	memset(pmap, 0, FCAL_MAP_SIZE);
+
+	mcp->mb[0] = MBC_GET_FC_AL_POSITION_MAP;
+	mcp->mb[2] = MSW(pmap_dma);
+	mcp->mb[3] = LSW(pmap_dma);
+	mcp->mb[6] = MSW(MSD(pmap_dma));
+	mcp->mb[7] = LSW(MSD(pmap_dma));
+	mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
+	mcp->in_mb = MBX_1|MBX_0;
+	mcp->buf_size = FCAL_MAP_SIZE;
+	mcp->flags = MBX_DMA_IN;
+	mcp->tov =  ha->login_timeout * 2;
+	rval = qla2x00_mailbox_command(ha, mcp);
+
+	if (rval == QLA_SUCCESS) {
+		DEBUG11(printk("%s(%ld): (mb0=%x/mb1=%x) FC/AL Position Map "
+		    "size (%x)\n", __func__, ha->host_no, mcp->mb[0],
+		    mcp->mb[1], (unsigned)pmap[0]));
+		DEBUG11(qla2x00_dump_buffer(pmap, pmap[0] + 1));
+
+		if (pos_map)
+			memcpy(pos_map, pmap, FCAL_MAP_SIZE);
+	}
+	pci_free_consistent(ha->pdev, FCAL_MAP_SIZE, pmap, pmap_dma);
+
+	if (rval != QLA_SUCCESS) {
+		DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
+		    ha->host_no, rval));
+	} else {
+		DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
+	}
+
+	return rval;
+}
+#endif
diff -puN /dev/null drivers/scsi/qla2xxx/qla_os.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/qla_os.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,4602 @@
+/*
+ *                  QLOGIC LINUX SOFTWARE
+ *
+ * QLogic ISP2x00 device driver for Linux 2.6.x
+ * Copyright (C) 2003 QLogic Corporation
+ * (www.qlogic.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include "qla_os.h"
+#include "qla_def.h"
+
+/*
+ * Driver version
+ */
+char qla2x00_version_str[40];
+
+/*
+ * SRB allocation cache
+ */
+char srb_cachep_name[16];
+kmem_cache_t *srb_cachep;
+
+/*
+ * Stats for all adpaters.
+ */
+struct _qla2x00stats qla2x00_stats;
+
+/*
+ * Ioctl related information.
+ */
+int num_hosts;
+int apiHBAInstance;
+
+/*
+ * Module parameter information and variables
+ */
+int ql2xmaxqdepth;
+module_param(ql2xmaxqdepth, int, 0);
+MODULE_PARM_DESC(ql2xmaxqdepth,
+		"Maximum queue depth to report for target devices.");
+
+int ql2xlogintimeout = 20;
+module_param(ql2xlogintimeout, int, 0);
+MODULE_PARM_DESC(ql2xlogintimeout,
+		"Login timeout value in seconds.");
+
+int qlport_down_retry;
+module_param(qlport_down_retry, int, 0);
+MODULE_PARM_DESC(qlport_down_retry,
+		"Maximum number of command retries to a port that returns"
+		"a PORT-DOWN status.");
+
+int ql2xretrycount = 20;
+module_param(ql2xretrycount, int, 0);
+MODULE_PARM_DESC(ql2xretrycount,
+		"Maximum number of mid-layer retries allowed for a command.  "
+		"Default value is 20, ");
+
+int displayConfig;
+module_param(displayConfig, int, 0);
+MODULE_PARM_DESC(displayConfig,
+		"If 1 then display the configuration used in /etc/modules.conf.");
+
+int ql2xplogiabsentdevice;
+module_param(ql2xplogiabsentdevice, int, 0);
+MODULE_PARM_DESC(ql2xplogiabsentdevice,
+		"Option to enable PLOGI to devices that are not present after "
+		"a Fabric scan.  This is needed for several broken switches."
+		"Default is 0 - no PLOGI. 1 - perfom PLOGI.");
+
+int ql2xintrdelaytimer = 10;
+module_param(ql2xintrdelaytimer, int, 0);
+MODULE_PARM_DESC(ql2xintrdelaytimer,
+		"ZIO: Waiting time for Firmware before it generates an "
+		"interrupt to the host to notify completion of request.");
+
+int ConfigRequired;
+module_param(ConfigRequired, int, 0);
+MODULE_PARM_DESC(ConfigRequired,
+		"If 1, then only configured devices passed in through the"
+		"ql2xopts parameter will be presented to the OS");
+
+int Bind = BIND_BY_PORT_NAME;
+module_param(Bind, int, 0);
+MODULE_PARM_DESC(Bind,
+		"Target persistent binding method: "
+		"0 by Portname (default); 1 by PortID; 2 by Nodename. ");
+
+int ql2xsuspendcount = SUSPEND_COUNT;
+module_param(ql2xsuspendcount, int, 0);
+MODULE_PARM_DESC(ql2xsuspendcount,
+		"Number of 6-second suspend iterations to perform while a "
+		"target returns a <NOT READY> status.  Default is 10 "
+		"iterations.");
+
+int ql2xdoinitscan = 1;
+module_param(ql2xdoinitscan, int, 0);
+MODULE_PARM_DESC(ql2xdoinitscan,
+		"Signal mid-layer to perform scan after driver load: 0 -- no "
+		"signal sent to mid-layer.");
+
+/*
+ * Proc structures and functions
+ */
+struct info_str {
+	char	*buffer;
+	int	length;
+	off_t	offset;
+	int	pos;
+};
+
+static void copy_mem_info(struct info_str *, char *, int);
+static int copy_info(struct info_str *, char *, ...);
+
+
+/*
+ * List of host adapters
+ */
+LIST_HEAD(qla_hostlist);
+rwlock_t qla_hostlist_lock = RW_LOCK_UNLOCKED;
+
+static void qla2x00_free_device(scsi_qla_host_t *);
+
+static void qla2x00_config_dma_addressing(scsi_qla_host_t *ha);
+
+/*
+ * SCSI host template entry points 
+ */
+static int qla2xxx_slave_configure(struct scsi_device * device);
+extern int qla2x00_ioctl(struct scsi_device *, int , void *);
+static int qla2xxx_eh_abort(struct scsi_cmnd *);
+static int qla2xxx_eh_device_reset(struct scsi_cmnd *);
+static int qla2xxx_eh_bus_reset(struct scsi_cmnd *);
+static int qla2xxx_eh_host_reset(struct scsi_cmnd *);
+static uint8_t qla2x00_loop_reset(scsi_qla_host_t *ha);
+static int qla2x00_device_reset(scsi_qla_host_t *, fc_port_t *);
+
+static int qla2x00_proc_info(struct Scsi_Host *, char *, char **,
+    off_t, int, int);
+
+static struct scsi_host_template qla2x00_driver_template = {
+	.module			= THIS_MODULE,
+	.name			= "qla2xxx",
+	.proc_name		= "qla2xxx",
+	.proc_info		= qla2x00_proc_info,
+	.queuecommand		= qla2x00_queuecommand,
+
+	.eh_abort_handler	= qla2xxx_eh_abort,
+	.eh_device_reset_handler = qla2xxx_eh_device_reset,
+	.eh_bus_reset_handler	= qla2xxx_eh_bus_reset,
+	.eh_host_reset_handler	= qla2xxx_eh_host_reset,
+
+	.slave_configure	= qla2xxx_slave_configure,
+
+	.this_id		= -1,
+	.can_queue		= REQUEST_ENTRY_CNT+128,
+	.cmd_per_lun		= 3,
+	.use_clustering		= ENABLE_CLUSTERING,
+	.sg_tablesize		= SG_ALL,
+
+	/*
+	 * The RISC allows for each command to transfer (2^32-1) bytes of data,
+	 * which equates to 0x800000 sectors.
+	 */
+	.max_sectors		= 0xFFFF,
+};
+
+static void qla2x00_display_fc_names(scsi_qla_host_t *);
+
+void qla2x00_blink_led(scsi_qla_host_t *);
+
+/* TODO Convert to inlines
+ *
+ * Timer routines
+ */
+#define	WATCH_INTERVAL		1       /* number of seconds */
+
+static void qla2x00_timer(scsi_qla_host_t *);
+
+static __inline__ void qla2x00_start_timer(scsi_qla_host_t *,
+    void *, unsigned long);
+static __inline__ void qla2x00_restart_timer(scsi_qla_host_t *, unsigned long);
+static __inline__ void qla2x00_stop_timer(scsi_qla_host_t *);
+
+static inline void
+qla2x00_start_timer(scsi_qla_host_t *ha, void *func, unsigned long interval)
+{
+	init_timer(&ha->timer);
+	ha->timer.expires = jiffies + interval * HZ;
+	ha->timer.data = (unsigned long)ha;
+	ha->timer.function = (void (*)(unsigned long))func;
+	add_timer(&ha->timer);
+	ha->timer_active = 1;
+}
+
+static inline void
+qla2x00_restart_timer(scsi_qla_host_t *ha, unsigned long interval)
+{
+	mod_timer(&ha->timer, jiffies + interval * HZ);
+}
+
+static __inline__ void
+qla2x00_stop_timer(scsi_qla_host_t *ha)
+{
+	del_timer_sync(&ha->timer);
+	ha->timer_active = 0;
+}
+
+
+static void qla2x00_cmd_timeout(srb_t *sp);
+static __inline__ void qla2x00_add_timer_to_cmd(srb_t *sp, int timeout);
+static __inline__ void qla2x00_delete_timer_from_cmd(srb_t *sp);
+
+/**************************************************************************
+*   qla2x00_add_timer_to_cmd
+*
+* Description:
+*       Creates a timer for the specified command. The timeout is usually
+*       the command time from kernel minus 2 secs.
+*
+* Input:
+*     sp - pointer to validate
+*
+* Returns:
+*     None.
+**************************************************************************/
+static inline void
+qla2x00_add_timer_to_cmd(srb_t *sp, int timeout)
+{
+	init_timer(&sp->timer);
+	sp->timer.expires = jiffies + timeout * HZ;
+	sp->timer.data = (unsigned long) sp;
+	sp->timer.function = (void (*) (unsigned long))qla2x00_cmd_timeout;
+	add_timer(&sp->timer);
+}
+
+/**************************************************************************
+*   qla2x00_delete_timer_from_cmd
+*
+* Description:
+*       Delete the timer for the specified command.
+*
+* Input:
+*     sp - pointer to validate
+*
+* Returns:
+*     None.
+**************************************************************************/
+static inline void 
+qla2x00_delete_timer_from_cmd(srb_t *sp)
+{
+	if (sp->timer.function != NULL) {
+		del_timer(&sp->timer);
+		sp->timer.function =  NULL;
+		sp->timer.data = (unsigned long) NULL;
+	}
+}
+
+static __inline__ void qla2x00_callback(scsi_qla_host_t *, struct scsi_cmnd *);
+static __inline__ void sp_put(struct scsi_qla_host * ha, srb_t *sp);
+static __inline__ void sp_get(struct scsi_qla_host * ha, srb_t *sp);
+static __inline__ void
+qla2x00_delete_from_done_queue(scsi_qla_host_t *, srb_t *); 
+
+/**************************************************************************
+* sp_put
+*
+* Description:
+*   Decrement reference count and call the callback if we're the last
+*   owner of the specified sp. Will get the host_lock before calling
+*   the callback.
+*
+* Input:
+*   ha - pointer to the scsi_qla_host_t where the callback is to occur.
+*   sp - pointer to srb_t structure to use.
+*
+* Returns:
+*
+**************************************************************************/
+static inline void
+sp_put(struct scsi_qla_host * ha, srb_t *sp)
+{
+        if (atomic_read(&sp->ref_count) == 0) {
+		qla_printk(KERN_INFO, ha,
+			"%s(): **** SP->ref_count not zero\n",
+			__func__);
+                DEBUG2(BUG();)
+
+                return;
+	}
+
+        if (!atomic_dec_and_test(&sp->ref_count)) {
+                return;
+        }
+
+        qla2x00_callback(ha, sp->cmd);
+}
+
+/**************************************************************************
+* sp_get
+*
+* Description:
+*   Increment reference count of the specified sp.
+*
+* Input:
+*   sp - pointer to srb_t structure to use.
+*
+* Returns:
+*
+**************************************************************************/
+static inline void
+sp_get(struct scsi_qla_host * ha, srb_t *sp)
+{
+        atomic_inc(&sp->ref_count);
+
+        if (atomic_read(&sp->ref_count) > 2) {
+		qla_printk(KERN_INFO, ha,
+			"%s(): **** SP->ref_count greater than two\n",
+			__func__);
+                DEBUG2(BUG();)
+
+		return;
+	}
+}
+
+/*
+* qla2x00_callback
+*      Returns the completed SCSI command to LINUX.
+*
+* Input:
+*	ha -- Host adapter structure
+*	cmd -- SCSI mid-level command structure.
+* Returns:
+*      None
+* Note:From failover point of view we always get the sp
+*      from vis_ha pool in queuecommand.So when we put it 
+*      back to the pool it has to be the vis_ha.	 
+*      So rely on struct scsi_cmnd to get the vis_ha and not on sp. 		 	
+*/
+static inline void
+qla2x00_callback(scsi_qla_host_t *ha, struct scsi_cmnd *cmd)
+{
+	srb_t *sp = (srb_t *) CMD_SP(cmd);
+	scsi_qla_host_t *vis_ha;
+	os_lun_t *lq;
+	int got_sense;
+	unsigned long	cpu_flags = 0;
+
+	ENTER(__func__);
+
+	cmd->host_scribble = (unsigned char *) NULL;
+	vis_ha = (scsi_qla_host_t *) cmd->device->host->hostdata;
+
+	if (sp == NULL) {
+		qla_printk(KERN_INFO, ha,
+			"%s(): **** CMD derives a NULL SP\n",
+			__func__);
+                DEBUG2(BUG();)
+		return;
+	}
+
+	/*
+	 * If command status is not DID_BUS_BUSY then go ahead and freed sp.
+	 */
+	/*
+	 * Cancel command timeout
+	 */
+	qla2x00_delete_timer_from_cmd(sp);
+
+	/*
+	 * Put SP back in the free queue
+	 */
+	sp->cmd   = NULL;
+	CMD_SP(cmd) = NULL;
+	lq = sp->lun_queue;
+	got_sense = (sp->flags & SRB_GOT_SENSE)? 1: 0;
+	add_to_free_queue(vis_ha, sp);
+
+	if (host_byte(cmd->result) == DID_OK) {
+		/* device ok */
+		ha->total_bytes += cmd->bufflen;
+		if (!got_sense) {
+			/* If lun was suspended then clear retry count */
+			spin_lock_irqsave(&lq->q_lock, cpu_flags);
+			if (!test_bit(LUN_EXEC_DELAYED, &lq->q_flag))
+				lq->q_state = LUN_STATE_READY;
+			spin_unlock_irqrestore(&lq->q_lock, cpu_flags);
+		}
+	} else if (host_byte(cmd->result) == DID_ERROR) {
+		/* device error */
+		ha->total_dev_errs++;
+	}
+
+	/* Call the mid-level driver interrupt handler */
+	(*(cmd)->scsi_done)(cmd);
+
+	LEAVE(__func__);
+}
+
+static inline void 
+qla2x00_delete_from_done_queue(scsi_qla_host_t *dest_ha, srb_t *sp) 
+{
+	/* remove command from done list */
+	list_del_init(&sp->list);
+	dest_ha->done_q_cnt--;
+	sp->state = SRB_NO_QUEUE_STATE;
+
+	if (sp->flags & SRB_DMA_VALID) {
+		sp->flags &= ~SRB_DMA_VALID;
+
+		/* Release memory used for this I/O */
+		if (sp->cmd->use_sg) {
+			pci_unmap_sg(dest_ha->pdev, sp->cmd->request_buffer,
+			    sp->cmd->use_sg, sp->cmd->sc_data_direction);
+		} else if (sp->cmd->request_bufflen) {
+			pci_unmap_page(dest_ha->pdev, sp->dma_handle,
+			    sp->cmd->request_bufflen,
+			    sp->cmd->sc_data_direction);
+		}
+	}
+}
+
+static int qla2x00_do_dpc(void *data);
+
+static void qla2x00_rst_aen(scsi_qla_host_t *);
+
+static uint8_t qla2x00_mem_alloc(scsi_qla_host_t *);
+static void qla2x00_mem_free(scsi_qla_host_t *ha);
+int qla2x00_allocate_sp_pool( scsi_qla_host_t *ha);
+void qla2x00_free_sp_pool(scsi_qla_host_t *ha);
+
+static ssize_t qla2x00_sysfs_read_fw_dump(struct kobject *, char *, loff_t,
+    size_t);
+static ssize_t qla2x00_sysfs_write_fw_dump(struct kobject *, char *, loff_t,
+    size_t);
+static struct bin_attribute sysfs_fw_dump_attr = {
+	.attr = {
+		.name = "fw_dump",
+		.mode = S_IRUSR | S_IWUSR,
+	},
+	.size = 0,
+	.read = qla2x00_sysfs_read_fw_dump,
+	.write = qla2x00_sysfs_write_fw_dump,
+};
+static ssize_t qla2x00_sysfs_read_nvram(struct kobject *, char *, loff_t,
+    size_t);
+static ssize_t qla2x00_sysfs_write_nvram(struct kobject *, char *, loff_t,
+    size_t);
+static struct bin_attribute sysfs_nvram_attr = {
+	.attr = {
+		.name = "nvram",
+		.mode = S_IRUSR | S_IWUSR,
+	},
+	.size = sizeof(nvram_t),
+	.read = qla2x00_sysfs_read_nvram,
+	.write = qla2x00_sysfs_write_nvram,
+};
+
+
+int
+qla2x00_set_info(char *buffer, int length, struct Scsi_Host *shost)
+{
+	return (-ENOSYS);  /* Currently this is a no-op */
+}
+
+/* -------------------------------------------------------------------------- */
+
+
+/* SysFS attributes. */
+static ssize_t qla2x00_sysfs_read_fw_dump(struct kobject *kobj, char *buf,
+    loff_t off, size_t count)
+{
+	struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
+	    struct device, kobj)));
+
+	if (ha->fw_dump_reading == 0)
+		return 0;
+	if (off > ha->fw_dump_buffer_len)
+		return 0;
+	if (off + count > ha->fw_dump_buffer_len)
+		count = ha->fw_dump_buffer_len - off;
+
+	memcpy(buf, &ha->fw_dump_buffer[off], count);
+
+	return (count);
+}
+
+static ssize_t qla2x00_sysfs_write_fw_dump(struct kobject *kobj, char *buf,
+    loff_t off, size_t count)
+{
+	struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
+	    struct device, kobj)));
+	int reading;
+
+	if (off != 0)
+		return (0);
+
+	reading = simple_strtol(buf, NULL, 10);
+	switch (reading) {
+	case 0:
+		if (ha->fw_dump_reading == 1) {
+			qla_printk(KERN_INFO, ha,
+			    "Firmware dump cleared on (%ld).\n",
+			    ha->host_no);
+
+			vfree(ha->fw_dump_buffer);
+			free_pages((unsigned long)ha->fw_dump,
+			    ha->fw_dump_order);
+
+			ha->fw_dump_reading = 0;
+			ha->fw_dump_buffer = NULL;
+			ha->fw_dump = NULL;
+		}
+		break;
+	case 1:
+		if (ha->fw_dump != NULL && !ha->fw_dump_reading) {
+			ha->fw_dump_reading = 1;
+
+			ha->fw_dump_buffer = (char *)vmalloc(FW_DUMP_SIZE);
+			if (ha->fw_dump_buffer == NULL) {
+				qla_printk(KERN_WARNING, ha,
+				    "Unable to allocate memory for firmware "
+				    "dump buffer (%d).\n", FW_DUMP_SIZE);
+
+				ha->fw_dump_reading = 0;
+				return (count);
+			}
+			qla_printk(KERN_INFO, ha,
+			    "Firmware dump ready for read on (%ld).\n",
+			    ha->host_no);
+			memset(ha->fw_dump_buffer, 0, FW_DUMP_SIZE);
+			if (IS_QLA2100(ha) || IS_QLA2200(ha))
+ 				qla2100_ascii_fw_dump(ha);
+ 			else
+ 				qla2300_ascii_fw_dump(ha);
+			ha->fw_dump_buffer_len = strlen(ha->fw_dump_buffer);
+		}
+		break;
+	}
+	return (count);
+}
+
+static ssize_t qla2x00_sysfs_read_nvram(struct kobject *kobj, char *buf,
+    loff_t off, size_t count)
+{
+	struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
+	    struct device, kobj)));
+	uint16_t	*witer;
+	unsigned long	flags;
+	uint16_t	cnt;
+
+	if (!capable(CAP_SYS_ADMIN) || off != 0 || count != sizeof(nvram_t))
+		return 0;
+
+	/* Read NVRAM. */
+	spin_lock_irqsave(&ha->hardware_lock, flags);
+	qla2x00_lock_nvram_access(ha);
+ 	witer = (uint16_t *)buf;
+ 	for (cnt = 0; cnt < count / 2; cnt++) {
+		*witer = cpu_to_le16(qla2x00_get_nvram_word(ha,
+		    cnt+ha->nvram_base));
+		witer++;
+ 	}
+	qla2x00_unlock_nvram_access(ha);
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+	return (count);
+}
+
+static ssize_t qla2x00_sysfs_write_nvram(struct kobject *kobj, char *buf,
+    loff_t off, size_t count)
+{
+	struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
+	    struct device, kobj)));
+	uint8_t		*iter;
+	uint16_t	*witer;
+	unsigned long	flags;
+	uint16_t	cnt;
+	uint8_t		chksum;
+
+	if (!capable(CAP_SYS_ADMIN) || off != 0 || count != sizeof(nvram_t))
+		return 0;
+
+	/* Checksum NVRAM. */
+	iter = (uint8_t *)buf;
+	chksum = 0;
+	for (cnt = 0; cnt < count - 1; cnt++)
+		chksum += *iter++;
+	chksum = ~chksum + 1;
+	*iter = chksum;
+
+	/* Write NVRAM. */
+	spin_lock_irqsave(&ha->hardware_lock, flags);
+	qla2x00_lock_nvram_access(ha);
+ 	witer = (uint16_t *)buf;
+	for (cnt = 0; cnt < count / 2; cnt++) {
+		qla2x00_write_nvram_word(ha, cnt+ha->nvram_base,
+		    cpu_to_le16(*witer));
+		witer++;
+	}
+	qla2x00_unlock_nvram_access(ha);
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+	return (count);
+}
+
+/* -------------------------------------------------------------------------- */
+char *
+qla2x00_get_pci_info_str(struct scsi_qla_host *ha, char *str)
+{
+	static char *pci_bus_modes[] = {
+		"33", "66", "100", "133",
+	};
+	uint16_t pci_bus;
+
+	strcpy(str, "PCI");
+	pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9;
+	if (pci_bus) {
+		strcat(str, "-X (");
+		strcat(str, pci_bus_modes[pci_bus]);
+	} else {
+		pci_bus = (ha->pci_attr & BIT_8) >> 8;
+		strcat(str, " (");
+		strcat(str, pci_bus_modes[pci_bus]);
+	}
+	strcat(str, " MHz)");
+
+	return (str);
+}
+
+char *
+qla2x00_get_fw_version_str(struct scsi_qla_host *ha, char *str)
+{
+	char un_str[10];
+	
+	sprintf(str, "%d.%02d.%02d ", ha->fw_major_version,
+	    ha->fw_minor_version,
+	    ha->fw_subminor_version);
+
+	switch (ha->fw_attributes & 0xFF) {
+	case 0x7:
+		strcat(str, "EF");
+		break;
+	case 0x17:
+		strcat(str, "TP");
+		break;
+	case 0x37:
+		strcat(str, "IP");
+		break;
+	case 0x77:
+		strcat(str, "VI");
+		break;
+	default:
+		sprintf(un_str, "(%x)", ha->fw_attributes);
+		strcat(str, un_str);
+		break;
+	}
+	if (ha->fw_attributes & 0x100)
+		strcat(str, "X");
+
+	return (str);
+}
+
+/**************************************************************************
+* qla2x00_queuecommand
+*
+* Description:
+*     Queue a command to the controller.
+*
+* Input:
+*     cmd - pointer to Scsi cmd structure
+*     fn - pointer to Scsi done function
+*
+* Returns:
+*   0 - Always
+*
+* Note:
+* The mid-level driver tries to ensures that queuecommand never gets invoked
+* concurrently with itself or the interrupt handler (although the
+* interrupt handler may call this routine as part of request-completion
+* handling).
+**************************************************************************/
+int
+qla2x00_queuecommand(struct scsi_cmnd *cmd, void (*fn)(struct scsi_cmnd *))
+{
+	fc_port_t	*fcport;
+	os_lun_t	*lq;
+	os_tgt_t	*tq;
+	scsi_qla_host_t	*ha, *ha2;
+	srb_t		*sp;
+	struct Scsi_Host *host;
+	unsigned int	b, t, l;
+	unsigned long	handle;
+	int		was_empty;
+
+
+	host = cmd->device->host;
+	ha = (scsi_qla_host_t *) host->hostdata;
+
+	cmd->scsi_done = fn;
+
+	spin_unlock_irq(ha->host->host_lock);
+
+	/*
+	 * Allocate a command packet from the "sp" pool.  If we cant get back
+	 * one then let scsi layer come back later.
+	 */
+	if ((sp = qla2x00_get_new_sp(ha)) == NULL) {
+		qla_printk(KERN_WARNING, ha,
+		    "Couldn't allocate memory for sp - retried.\n");
+
+		spin_lock_irq(ha->host->host_lock);
+
+		return (1);
+	}
+
+	sp->cmd = cmd;
+	CMD_SP(cmd) = (void *)sp;
+
+	sp->flags = 0;
+	if (CMD_RESID_LEN(cmd) & SRB_IOCTL) {
+		/* Need to set sp->flags */
+		sp->flags |= SRB_IOCTL;
+		CMD_RESID_LEN(cmd) = 0; /* Clear it since no more use. */
+	}
+
+	sp->fo_retry_cnt = 0;
+
+	/* Generate LU queue on bus, target, LUN */
+	b = cmd->device->channel;
+	t = cmd->device->id;
+	l = cmd->device->lun;
+
+	/*
+	 * Start Command Timer. Typically it will be 2 seconds less than what
+	 * is requested by the Host such that we can return the IO before
+	 * aborts are called.
+	 */
+	if ((cmd->timeout_per_command / HZ) > QLA_CMD_TIMER_DELTA)
+		qla2x00_add_timer_to_cmd(sp,
+		    (cmd->timeout_per_command / HZ) - QLA_CMD_TIMER_DELTA);
+	else
+		qla2x00_add_timer_to_cmd(sp, cmd->timeout_per_command / HZ);
+
+	if (l >= ha->max_luns) {
+		cmd->result = DID_NO_CONNECT << 16;
+
+		spin_lock_irq(ha->host->host_lock);
+
+		sp_put(ha, sp);
+
+		return (0);
+	}
+
+	if ((tq = (os_tgt_t *) TGT_Q(ha, t)) != NULL &&
+	    (lq = (os_lun_t *) LUN_Q(ha, t, l)) != NULL) {
+		fcport = lq->fclun->fcport;
+		ha2 = fcport->ha;
+	} else {
+		lq = NULL;
+		fcport = NULL;
+		ha2 = ha;
+	}
+
+	/* Set an invalid handle until we issue the command to ISP */
+	/* then we will set the real handle value.                 */
+	handle = INVALID_HANDLE;
+	cmd->host_scribble = (unsigned char *)handle;
+
+	/* Bookkeeping information */
+	sp->r_start = jiffies;       /* time the request was recieved */
+	sp->u_start = 0;
+
+	/* Setup device queue pointers. */
+	sp->tgt_queue = tq;
+	sp->lun_queue = lq;
+
+	/*
+	 * NOTE : q is NULL
+	 *
+	 * 1. When device is added from persistent binding but has not been
+	 *    discovered yet.The state of loopid == PORT_AVAIL.
+	 * 2. When device is never found on the bus.(loopid == UNUSED)
+	 *
+	 * IF Device Queue is not created, or device is not in a valid state
+	 * and link down error reporting is enabled, reject IO.
+	 */
+	if (fcport == NULL) {
+		DEBUG3(printk("scsi(%ld:%2d:%2d): port unavailable\n",
+		    ha->host_no,t,l));
+
+		cmd->result = DID_NO_CONNECT << 16;
+
+		spin_lock_irq(ha->host->host_lock);
+
+		sp_put(ha, sp);
+
+		return (0);
+	}
+
+	/* Only modify the allowed count if the target is a *non* tape device */
+	if ((fcport->flags & FCF_TAPE_PRESENT) == 0) {
+		if (cmd->allowed < ql2xretrycount) {
+			cmd->allowed = ql2xretrycount;
+		}
+	}
+
+	DEBUG5(printk("scsi(%ld:%2d:%2d): (queuecmd) queue sp = %p, "
+	    "flags=0x%x fo retry=%d, pid=%ld\n",
+	    ha->host_no, t, l, sp, sp->flags, sp->fo_retry_cnt,
+	    cmd->serial_number));
+	DEBUG5(qla2x00_print_scsi_cmd(cmd));
+
+	sp->fclun = lq->fclun;
+	sp->ha = ha2;
+
+	if (cmd->sc_data_direction == DMA_BIDIRECTIONAL &&
+	    cmd->request_bufflen != 0) {
+
+		DEBUG2(printk(KERN_WARNING
+		    "scsi(%ld): Incorrect data direction - transfer "
+		    "length=%d, direction=%d, pid=%ld, opcode=%x\n",
+		    ha->host_no, cmd->request_bufflen, cmd->sc_data_direction,
+		    cmd->serial_number, cmd->cmnd[0]));
+	}
+
+	/* Final pre-check :
+	 *
+	 *	Either PORT_DOWN_TIMER OR LINK_DOWN_TIMER Expired.
+	 */
+	if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD ||
+	    atomic_read(&ha->loop_state) == LOOP_DEAD) {
+		/*
+		 * Add the command to the done-queue for later failover
+		 * processing
+		 */
+		cmd->result = DID_NO_CONNECT << 16;
+		add_to_done_queue(ha, sp);
+		if (!list_empty(&ha->done_queue))
+			qla2x00_done(ha);
+
+		spin_lock_irq(ha->host->host_lock);
+		return (0);
+	}
+	was_empty = add_to_pending_queue(ha, sp);
+
+	if ((IS_QLA2100(ha) || IS_QLA2200(ha)) && ha->flags.online) {
+		unsigned long flags;
+		device_reg_t *reg;
+		reg = ha->iobase;
+		
+		if (RD_REG_WORD(ISP_RSP_Q_IN(ha, reg)) != ha->rsp_ring_index) {
+			spin_lock_irqsave(&ha->hardware_lock, flags);	
+			qla2x00_process_response_queue(ha);
+			spin_unlock_irqrestore(&ha->hardware_lock, flags);
+		}
+	}
+
+	/* We submit to the hardware if:
+	 *
+	 *	1) we're on the cpu the irq's arrive on or
+	 *	2) there are very few io's outstanding.
+	 *
+	 * In all other cases we'll let an irq pick up our IO and submit it
+	 * to the controller to improve affinity.
+	 */
+	if (smp_processor_id() == ha->last_irq_cpu || was_empty)
+		qla2x00_next(ha);
+
+	spin_lock_irq(ha->host->host_lock);
+
+	return (0);
+}
+
+/*
+ * qla2x00_eh_wait_on_command
+ *    Waits for the command to be returned by the Firmware for some
+ *    max time.
+ *
+ * Input:
+ *    ha = actual ha whose done queue will contain the command
+ *	      returned by firmware.
+ *    cmd = Scsi Command to wait on.
+ *    flag = Abort/Reset(Bus or Device Reset)
+ *
+ * Return:
+ *    Not Found : 0
+ *    Found : 1
+ */
+static int
+qla2x00_eh_wait_on_command(scsi_qla_host_t *ha, struct scsi_cmnd *cmd)
+{
+#define ABORT_WAIT_TIME	10 /* seconds */
+
+	int		found = 0;
+	int		done = 0;
+	srb_t		*rp;
+	struct list_head *list, *temp;
+	u_long		cpu_flags = 0;
+	u_long		max_wait_time = ABORT_WAIT_TIME;
+
+	ENTER(__func__);
+
+	do {
+		/* Check on done queue */
+		if (!found) {
+			spin_lock_irqsave(&ha->list_lock, cpu_flags);
+			list_for_each_safe(list, temp, &ha->done_queue) {
+				rp = list_entry(list, srb_t, list);
+
+				/*
+				* Found command.  Just exit and wait for the
+				* cmd sent to OS.
+			 	*/
+				if (cmd == rp->cmd) {
+					found++;
+					DEBUG3(printk("%s: found in done "
+							"queue.\n", __func__);)
+					break;
+				}
+			}
+			spin_unlock_irqrestore(&ha->list_lock, cpu_flags);
+		}
+
+		/* Checking to see if its returned to OS */
+		rp = (srb_t *) CMD_SP(cmd);
+		if (rp == NULL ) {
+			done++;
+			break;
+		}
+
+		spin_unlock_irq(ha->host->host_lock);
+
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(2*HZ);
+
+		spin_lock_irq(ha->host->host_lock);
+
+	} while ((max_wait_time--));
+
+	if (done) {
+		DEBUG2(printk(KERN_INFO "%s: found cmd=%p.\n", __func__, cmd));
+	} else if (found) {
+		/* Immediately return command to the mid-layer */
+		qla2x00_delete_from_done_queue(ha, rp);
+		sp_put(ha, rp);
+		done++;
+	}
+
+	LEAVE(__func__);
+
+	return (done);
+}
+
+/*
+ * qla2x00_wait_for_hba_online
+ *    Wait till the HBA is online after going through 
+ *    <= MAX_RETRIES_OF_ISP_ABORT  or
+ *    finally HBA is disabled ie marked offline
+ *
+ * Input:
+ *     ha - pointer to host adapter structure
+ * 
+ * Note:    
+ *    Does context switching-Release SPIN_LOCK
+ *    (if any) before calling this routine.
+ *
+ * Return:
+ *    Success (Adapter is online) : 0
+ *    Failed  (Adapter is offline/disabled) : 1
+ */
+static inline int 
+qla2x00_wait_for_hba_online(scsi_qla_host_t *ha)
+{
+	int 	 return_status ;
+
+	while ((test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) ||
+	    test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags) ||
+	    test_bit(ISP_ABORT_RETRY, &ha->dpc_flags)) {
+
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(3 * HZ);
+	}
+	if (ha->flags.online == TRUE) 
+		return_status = QLA_SUCCESS; 
+	else
+		/* Adapter is disabled/offline */
+		return_status = QLA_FUNCTION_FAILED;
+
+	DEBUG2(printk("%s return_status=%d\n",__func__,return_status));
+
+	return (return_status);
+}
+
+/*
+ * qla2x00_wait_for_loop_ready
+ *    Wait for MAX_LOOP_TIMEOUT(5 min) value for loop
+ *    to be in LOOP_READY state.	 
+ * Input:
+ *     ha - pointer to host adapter structure
+ * 
+ * Note:    
+ *    Does context switching-Release SPIN_LOCK
+ *    (if any) before calling this routine.
+ *    
+ *
+ * Return:
+ *    Success (LOOP_READY) : 0
+ *    Failed  (LOOP_NOT_READY) : 1
+ */
+static inline int 
+qla2x00_wait_for_loop_ready(scsi_qla_host_t *ha)
+{
+	int 	 return_status = QLA_SUCCESS;
+	unsigned long loop_timeout ;
+
+	/* wait for 5 min at the max for loop to be ready */
+	loop_timeout = jiffies + (MAX_LOOP_TIMEOUT * HZ); 
+
+	while ((!atomic_read(&ha->loop_down_timer) &&
+	    atomic_read(&ha->loop_state) == LOOP_DOWN) ||
+	    test_bit(CFG_ACTIVE, &ha->cfg_flags) ||
+	    atomic_read(&ha->loop_state) != LOOP_READY) {
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(3 * HZ);
+		if (time_after_eq(jiffies, loop_timeout)) {
+			return_status = QLA_FUNCTION_FAILED;
+			break;
+		}
+	}
+	return (return_status);	
+}
+
+/**************************************************************************
+* qla2xxx_eh_abort
+*
+* Description:
+*    The abort function will abort the specified command.
+*
+* Input:
+*    cmd = Linux SCSI command packet to be aborted.
+*
+* Returns:
+*    Either SUCCESS or FAILED.
+*
+* Note:
+**************************************************************************/
+int
+qla2xxx_eh_abort(struct scsi_cmnd *cmd)
+{
+	int		i;
+	int		return_status = FAILED;
+	os_lun_t	*q;
+	scsi_qla_host_t *ha;
+	scsi_qla_host_t *vis_ha;
+	srb_t		*sp;
+	srb_t		*rp;
+	struct list_head *list, *temp;
+	struct Scsi_Host *host;
+	uint8_t		found = 0;
+	unsigned int	b, t, l;
+	unsigned long	flags;
+
+
+	ENTER(__func__);
+
+	/* Get the SCSI request ptr */
+	sp = (srb_t *) CMD_SP(cmd);
+
+	/*
+	 * If sp is NULL, command is already returned.
+	 * sp is NULLED just before we call back scsi_done
+	 *
+	 */
+	if ((sp == NULL)) {
+		/* no action - we don't have command */
+		qla_printk(KERN_INFO, to_qla_host(cmd->device->host),
+		    "qla2xxx_eh_abort: cmd already done sp=%p\n", sp);
+		DEBUG(printk("qla2xxx_eh_abort: cmd already done sp=%p\n", sp);)
+		return(SUCCESS);
+	}
+	if (sp) {
+		DEBUG(printk("qla2xxx_eh_abort: refcount %i \n",
+		    atomic_read(&sp->ref_count));)
+	}
+
+	vis_ha = (scsi_qla_host_t *) cmd->device->host->hostdata;
+	ha = (scsi_qla_host_t *)cmd->device->host->hostdata;
+
+	host = ha->host;
+
+	/* Generate LU queue on bus, target, LUN */
+	b = cmd->device->channel;
+	t = cmd->device->id;
+	l = cmd->device->lun;
+	q = GET_LU_Q(vis_ha, t, l);
+
+	qla_printk(KERN_INFO, ha, 
+	    "%s scsi(%ld:%d:%d:%d): cmd_timeout_in_sec=0x%x.\n", __func__,
+	    ha->host_no, (int)b, (int)t, (int)l,
+	    cmd->timeout_per_command / HZ);
+
+	/*
+	 * if no LUN queue then something is very wrong!!!
+	 */
+	if (q == NULL) {
+		qla_printk(KERN_WARNING, ha,
+			"qla2x00: (%x:%x:%x) No LUN queue.\n", b, t, l);
+
+		/* no action - we don't have command */
+		return(FAILED);
+	}
+
+	DEBUG2(printk("scsi(%ld): ABORTing cmd=%p sp=%p jiffies = 0x%lx, "
+	    "timeout=%x, dpc_flags=%lx, vis_ha->dpc_flags=%lx\n",
+	    ha->host_no, cmd, sp, jiffies, cmd->timeout_per_command / HZ,
+	    ha->dpc_flags, vis_ha->dpc_flags));
+	DEBUG2(qla2x00_print_scsi_cmd(cmd));
+	DEBUG2(qla2x00_print_q_info(q);)
+
+	spin_unlock_irq(ha->host->host_lock);
+	/* Blocking call-Does context switching if abort isp is active etc */  
+	if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS) {
+		DEBUG2(printk("%s failed:board disabled\n", __func__);)
+		spin_lock_irq(ha->host->host_lock);
+		return (FAILED);
+	}
+	spin_lock_irq(ha->host->host_lock);
+
+	/* Search done queue */
+	spin_lock_irqsave(&ha->list_lock,flags);
+	list_for_each_safe(list, temp, &ha->done_queue) {
+		rp = list_entry(list, srb_t, list);
+
+		if (cmd != rp->cmd)
+			continue;
+
+		/*
+		 * Found command.Remove it from done list.
+		 * And proceed to post completion to scsi mid layer.
+		 */
+		return_status = SUCCESS;
+		found++;
+		qla2x00_delete_from_done_queue(ha, sp);
+
+		break;
+	} /* list_for_each_safe() */
+	spin_unlock_irqrestore(&ha->list_lock, flags);
+
+	/*
+	 * Return immediately if the aborted command was already in the done
+	 * queue
+	 */
+	if (found) {
+		qla_printk(KERN_INFO, ha,
+		    "qla2xxx_eh_abort: Returning completed command=%p sp=%p\n",
+		    cmd, sp);
+		sp_put(ha, sp);
+		return (return_status);
+	}
+	
+
+	/*
+	 * See if this command is in the retry queue
+	 */
+	DEBUG3(printk("qla2xxx_eh_abort: searching sp %p in retry "
+		    "queue.\n", sp);)
+
+	spin_lock_irqsave(&ha->list_lock, flags);
+	list_for_each_safe(list, temp, &ha->retry_queue) {
+		rp = list_entry(list, srb_t, list);
+
+		if (cmd != rp->cmd)
+			continue;
+
+
+		DEBUG2(printk("qla2xxx_eh_abort: found "
+		    "in retry queue. SP=%p\n", sp);)
+
+		__del_from_retry_queue(ha, rp);
+		cmd->result = DID_ABORT << 16;
+		__add_to_done_queue(ha, rp);
+
+		return_status = SUCCESS;
+		found++;
+
+		break;
+
+	} 
+	spin_unlock_irqrestore(&ha->list_lock, flags);
+
+	/*
+	 * Our SP pointer points at the command we want to remove from the
+	 * pending queue providing we haven't already sent it to the adapter.
+	 */
+	if (!found) {
+		DEBUG3(printk("qla2xxx_eh_abort: searching sp %p "
+		    "in pending queue.\n", sp);)
+
+		spin_lock_irqsave(&vis_ha->list_lock, flags);
+		list_for_each_safe(list, temp, &vis_ha->pending_queue) {
+			rp = list_entry(list, srb_t, list);
+
+			if (rp->cmd != cmd)
+				continue;
+
+			/* Remove srb from LUN queue. */
+			rp->flags |=  SRB_ABORTED;
+
+			DEBUG2(printk("qla2xxx_eh_abort: Cmd in pending queue."
+			    " serial_number %ld.\n",
+			    sp->cmd->serial_number);)
+
+			__del_from_pending_queue(vis_ha, rp);
+			cmd->result = DID_ABORT << 16;
+
+			__add_to_done_queue(vis_ha, rp);
+
+			return_status = SUCCESS;
+
+			found++;
+			break;
+		} /* list_for_each_safe() */
+		spin_unlock_irqrestore(&vis_ha->list_lock, flags);
+	} /*End of if !found */
+
+	if (!found) {  /* find the command in our active list */
+		DEBUG3(printk("qla2xxx_eh_abort: searching sp %p "
+		    "in outstanding queue.\n", sp);)
+
+		spin_lock_irqsave(&ha->hardware_lock, flags);
+		for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) {
+			sp = ha->outstanding_cmds[i];
+
+			if (sp == NULL)
+				continue;
+
+			if (sp->cmd != cmd)
+				continue;
+
+			DEBUG2(printk("qla2xxx_eh_abort(%ld): aborting sp %p "
+			    "from RISC. pid=%ld sp->state=%x\n",
+			    ha->host_no, sp, sp->cmd->serial_number,
+			    sp->state);)
+			DEBUG(qla2x00_print_scsi_cmd(cmd);)
+			DEBUG(qla2x00_print_q_info(q);)
+
+			/* Get a reference to the sp and drop the lock.*/
+			sp_get(ha, sp);
+
+			spin_unlock_irqrestore(&ha->hardware_lock, flags);
+			spin_unlock(ha->host->host_lock);
+
+			if (qla2x00_abort_command(ha, sp)) {
+				DEBUG2(printk("qla2xxx_eh_abort: abort_command "
+				    "mbx failed.\n");)
+				return_status = FAILED;
+			} else {
+				DEBUG3(printk("qla2xxx_eh_abort: abort_command "
+				    " mbx success.\n");)
+				return_status = SUCCESS;
+			}
+
+			sp_put(ha,sp);
+
+			spin_lock_irq(ha->host->host_lock);
+			spin_lock_irqsave(&ha->hardware_lock, flags);
+
+			/*
+			 * Regardless of mailbox command status, go check on
+			 * done queue just in case the sp is already done.
+			 */
+			break;
+
+		}/*End of for loop */
+		spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+	} /*End of if !found */
+
+	  /*Waiting for our command in done_queue to be returned to OS.*/
+	if (qla2x00_eh_wait_on_command(ha, cmd) != 0) {
+		DEBUG2(printk("qla2xxx_eh_abort: cmd returned back to OS.\n");)
+		return_status = SUCCESS;
+	}
+
+	if (return_status == FAILED) {
+		qla_printk(KERN_INFO, ha, 
+			"qla2xxx_eh_abort Exiting: status=Failed\n");
+		return FAILED;
+	}
+
+	DEBUG2(printk("qla2xxx_eh_abort: Exiting. return_status=0x%x.\n",
+	    return_status));
+
+	LEAVE("qla2xxx_eh_abort");
+
+	return(return_status);
+}
+
+/**************************************************************************
+* qla2x00_eh_wait_for_pending_target_commands
+*
+* Description:
+*    Waits for all the commands to come back from the specified target.
+*
+* Input:
+*    ha - pointer to scsi_qla_host structure.
+*    t  - target 	
+* Returns:
+*    Either SUCCESS or FAILED.
+*
+* Note:
+**************************************************************************/
+int
+qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t *ha, unsigned int t)
+{
+	int	cnt;
+	int	status;
+	unsigned long	flags;
+	srb_t		*sp;
+	struct scsi_cmnd *cmd;
+
+	status = 0;
+
+	/*
+	 * Waiting for all commands for the designated target in the active
+	 * array
+	 */
+	for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
+		spin_lock_irqsave(&ha->hardware_lock, flags);
+		sp = ha->outstanding_cmds[cnt];
+		if (sp) {
+			cmd = sp->cmd;
+			spin_unlock_irqrestore(&ha->hardware_lock, flags);
+			if (cmd->device->id == t) {
+				if (!qla2x00_eh_wait_on_command(ha, cmd)) {
+					status = 1;
+					break;
+				}
+			}
+		}
+		else {
+			spin_unlock_irqrestore(&ha->hardware_lock, flags);
+		}
+	}
+	return (status);
+}
+
+
+/**************************************************************************
+* qla2xxx_eh_device_reset
+*
+* Description:
+*    The device reset function will reset the target and abort any
+*    executing commands.
+*
+*    NOTE: The use of SP is undefined within this context.  Do *NOT*
+*          attempt to use this value, even if you determine it is 
+*          non-null.
+*
+* Input:
+*    cmd = Linux SCSI command packet of the command that cause the
+*          bus device reset.
+*
+* Returns:
+*    SUCCESS/FAILURE (defined as macro in scsi.h).
+*
+**************************************************************************/
+int
+qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
+{
+	int		return_status;
+	unsigned int	b, t, l;
+	scsi_qla_host_t	*ha;
+	os_tgt_t	*tq;
+	os_lun_t	*lq;
+	fc_port_t	*fcport_to_reset;
+
+	return_status = FAILED;
+	if (cmd == NULL) {
+		printk(KERN_INFO
+		    "%s(): **** SCSI mid-layer passing in NULL cmd\n",
+		    __func__);
+
+		return (return_status);
+	}
+
+	b = cmd->device->channel;
+	t = cmd->device->id;
+	l = cmd->device->lun;
+	ha = (scsi_qla_host_t *)cmd->device->host->hostdata;
+
+	tq = TGT_Q(ha, t);
+	if (tq == NULL) {
+		qla_printk(KERN_INFO, ha,
+		    "%s(): **** CMD derives a NULL TGT_Q\n", __func__);
+
+		return (return_status);
+	}
+	lq = (os_lun_t *)LUN_Q(ha, t, l);
+	if (lq == NULL) {
+		printk(KERN_INFO
+		    "%s(): **** CMD derives a NULL LUN_Q\n", __func__);
+
+		return (return_status);
+	}
+	fcport_to_reset = lq->fclun->fcport;
+
+#if STOP_ON_RESET
+	qla2x00_panic(__func__, ha->host);
+#endif
+
+	qla_printk(KERN_INFO, ha,
+	    "scsi(%ld:%d:%d:%d): DEVICE RESET ISSUED.\n", ha->host_no, b, t, l);
+
+	DEBUG2(printk(KERN_INFO
+	    "scsi(%ld): DEVICE_RESET cmd=%p jiffies = 0x%lx, timeout=%x, "
+	    "dpc_flags=%lx, status=%x allowed=%d cmd.state=%x\n",
+	    ha->host_no, cmd, jiffies, cmd->timeout_per_command / HZ,
+	    ha->dpc_flags, cmd->result, cmd->allowed, cmd->state));
+
+	spin_unlock_irq(ha->host->host_lock);
+
+	/* Blocking call-Does context switching if abort isp is active etc */  
+	if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS) {
+		DEBUG2(printk(KERN_INFO
+		    "%s failed:board disabled\n",__func__));
+
+		spin_lock_irq(ha->host->host_lock);
+		goto eh_dev_reset_done;
+	}
+
+	/* Blocking call-Does context switching if loop is Not Ready */
+	if (qla2x00_wait_for_loop_ready(ha) == QLA_SUCCESS) {
+		if (qla2x00_device_reset(ha, fcport_to_reset) == 0) {
+			return_status = SUCCESS;
+		}
+
+#if defined(LOGOUT_AFTER_DEVICE_RESET)
+		if (return_status == SUCCESS) {
+			if (fcport_to_reset->flags & FC_FABRIC_DEVICE) {
+				qla2x00_fabric_logout(ha,
+				    fcport_to_reset->loop_id);
+				qla2x00_mark_device_lost(ha, fcport_to_reset);
+			}
+		}
+#endif
+	} else {
+		DEBUG2(printk(KERN_INFO
+		    "%s failed: loop not ready\n",__func__);)
+	}
+
+	spin_lock_irq(ha->host->host_lock);
+
+	if (return_status == FAILED) {
+		DEBUG3(printk("%s(%ld): device reset failed\n",
+		    __func__,ha->host_no));
+		qla_printk(KERN_INFO, ha, "%s: device reset failed\n",
+		    __func__);
+
+		goto eh_dev_reset_done;
+	}
+
+	/*
+	 * If we are coming down the EH path, wait for all commands to
+	 * complete for the device.
+	 */
+	if (cmd->device->host->eh_active) {
+		if (qla2x00_eh_wait_for_pending_target_commands(ha, t))
+			return_status = FAILED;
+
+		if (return_status == FAILED) {
+			DEBUG3(printk("%s(%ld): failed while waiting for "
+			    "commands\n", __func__, ha->host_no));
+			qla_printk(KERN_INFO, ha,
+			    "%s: failed while waiting for commands\n",
+			    __func__); 
+
+			goto eh_dev_reset_done;
+		}
+	}
+
+	qla_printk(KERN_INFO, ha,
+	    "scsi(%ld:%d:%d:%d): DEVICE RESET SUCCEEDED.\n",
+	    ha->host_no, b, t, l);
+
+eh_dev_reset_done:
+
+	return (return_status);
+}
+
+/**************************************************************************
+* qla2x00_eh_wait_for_pending_commands
+*
+* Description:
+*    Waits for all the commands to come back from the specified host.
+*
+* Input:
+*    ha - pointer to scsi_qla_host structure.
+*
+* Returns:
+*    1 : SUCCESS
+*    0 : FAILED
+*
+* Note:
+**************************************************************************/
+int
+qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *ha)
+{
+	int	cnt;
+	int	status;
+	unsigned long	flags;
+	srb_t		*sp;
+	struct scsi_cmnd *cmd;
+
+	status = 1;
+
+	/*
+	 * Waiting for all commands for the designated target in the active
+	 * array
+	 */
+	for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
+		spin_lock_irqsave(&ha->hardware_lock, flags);
+		sp = ha->outstanding_cmds[cnt];
+		if (sp) {
+			cmd = sp->cmd;
+			spin_unlock_irqrestore(&ha->hardware_lock, flags);
+			status = qla2x00_eh_wait_on_command(ha, cmd);
+			if (status == 0)
+				break;
+		}
+		else {
+			spin_unlock_irqrestore(&ha->hardware_lock, flags);
+		}
+	}
+	return (status);
+}
+
+
+/**************************************************************************
+* qla2xxx_eh_bus_reset
+*
+* Description:
+*    The bus reset function will reset the bus and abort any executing
+*    commands.
+*
+* Input:
+*    cmd = Linux SCSI command packet of the command that cause the
+*          bus reset.
+*
+* Returns:
+*    SUCCESS/FAILURE (defined as macro in scsi.h).
+*
+**************************************************************************/
+int
+qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
+{
+	scsi_qla_host_t *ha;
+	srb_t *sp;
+	int rval = FAILED;
+
+
+	ENTER("qla2xxx_eh_bus_reset");
+
+	ha = (scsi_qla_host_t *) cmd->device->host->hostdata;
+	sp = (srb_t *) CMD_SP(cmd);
+
+#if  STOP_ON_RESET
+	printk("Resetting the Bus= 0x%x\n", (int)cmd);
+	qla2x00_print_scsi_cmd(cmd);
+	qla2x00_panic("qla2100_reset", ha->host);
+#endif
+
+	qla_printk(KERN_INFO, ha,
+	    "scsi(%ld:%d:%d:%d): LOOP RESET ISSUED.\n", ha->host_no,
+	    cmd->device->channel, cmd->device->id, cmd->device->lun);
+
+	spin_unlock_irq(ha->host->host_lock);
+
+	/* Blocking call-Does context switching if abort isp is active etc*/  
+	if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS) {
+		DEBUG2(printk("%s failed:board disabled\n",__func__));
+		spin_lock_irq(ha->host->host_lock);
+		return FAILED;
+	}
+
+	/* Blocking call-Does context switching if loop is Not Ready */ 
+	if (qla2x00_wait_for_loop_ready(ha) == QLA_SUCCESS) {
+		if (qla2x00_loop_reset(ha)) 
+			rval = SUCCESS;
+	}
+
+	spin_lock_irq(ha->host->host_lock);
+	if (rval == FAILED)
+		goto out;
+
+	/*
+	 * Blocking Call. It goes to sleep waiting for cmd to get to done q
+	 *
+	 * XXX(hch): really?  We're under host_lock here..
+	 */
+	/* Waiting for our command in done_queue to be returned to OS.*/
+	if (!qla2x00_eh_wait_for_pending_commands(ha))
+		rval = FAILED;
+
+ out:
+	qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__,
+			(rval == FAILED) ? "failed" : "succeded");
+
+	LEAVE("qla2xxx_eh_bus_reset");
+	return rval;
+}
+
+/**************************************************************************
+* qla2xxx_eh_host_reset
+*
+* Description:
+*    The reset function will reset the Adapter.
+*
+* Input:
+*      cmd = Linux SCSI command packet of the command that cause the
+*            adapter reset.
+*
+* Returns:
+*      Either SUCCESS or FAILED.
+*
+* Note:
+**************************************************************************/
+int
+qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
+{
+	scsi_qla_host_t *ha = (scsi_qla_host_t *)cmd->device->host->hostdata;
+	int		rval = SUCCESS;
+
+	ENTER("qla2xxx_eh_host_reset");
+
+	/* Display which one we're actually resetting for debug. */
+	DEBUG(printk("qla2xxx_eh_host_reset:Resetting scsi(%ld).\n",
+	    ha->host_no));
+
+#if  STOP_ON_RESET
+	qla_printk(KERN_INFO, ha, "Host Reset...  Command=\n");
+	qla2x00_print_scsi_cmd(cmd);
+	qla2x00_panic("qla2xxx_eh_host_reset", ha->host);
+#endif
+
+	/*
+	 *  Now issue reset.
+	 */
+	qla_printk(KERN_INFO, ha,
+	    "scsi(%ld:%d:%d:%d): ADAPTER RESET issued.\n", ha->host_no,
+	    cmd->device->channel, cmd->device->id, cmd->device->lun);
+
+	spin_unlock_irq(ha->host->host_lock);
+
+	/* Blocking call-Does context switching if abort isp is active etc*/  
+	if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS)
+		goto board_disabled;
+
+	/*
+	 * Fixme-may be dpc thread is active and processing
+	 * loop_resync,so wait a while for it to 
+	 * be completed and then issue big hammer.Otherwise
+	 * it may cause I/O failure as big hammer marks the
+	 * devices as lost kicking of the port_down_timer
+	 * while dpc is stuck for the mailbox to complete.
+	 */
+	/* Blocking call-Does context switching if loop is Not Ready */
+	qla2x00_wait_for_loop_ready(ha);
+	set_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags);
+	if (qla2x00_abort_isp(ha)) {
+		clear_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags);
+		/* failed. schedule dpc to try */
+		set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
+
+		if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS)
+			goto board_disabled;
+	} 
+
+	clear_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags);
+
+	spin_lock_irq(ha->host->host_lock);
+	if (rval == FAILED)
+		goto out;
+
+	/* Waiting for our command in done_queue to be returned to OS.*/
+	if (qla2x00_eh_wait_for_pending_commands(ha))
+		rval = FAILED;
+
+ out:
+	qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__,
+			(rval == FAILED) ? "failed" : "succeded");
+
+	LEAVE("qla2xxx_eh_host_reset");
+	return rval;
+
+ board_disabled:
+	spin_lock_irq(ha->host->host_lock);
+
+	qla_printk(KERN_INFO, ha, "%s: failed:board disabled\n", __func__);
+	return FAILED;
+}
+
+
+/*
+* qla2x00_loop_reset
+*      Issue loop reset.
+*
+* Input:
+*      ha = adapter block pointer.
+*
+* Returns:
+*      0 = success
+*/
+static uint8_t
+qla2x00_loop_reset(scsi_qla_host_t *ha)
+{
+	uint8_t  status = QLA_SUCCESS;
+	uint16_t t;
+	os_tgt_t        *tq;
+
+	ENTER(__func__);
+
+	if (ha->flags.enable_lip_reset) {
+		status = qla2x00_lip_reset(ha);
+	}
+
+	if (status == QLA_SUCCESS && ha->flags.enable_target_reset) {
+		for (t = 0; t < MAX_FIBRE_DEVICES; t++) {
+			if ((tq = TGT_Q(ha, t)) == NULL)
+				continue;
+
+			if (tq->fcport == NULL)
+				continue;
+
+			status = qla2x00_target_reset(ha, 0, t);
+			if (status != QLA_SUCCESS) {
+				break;
+			}
+		}
+	}
+
+	if (status == QLA_SUCCESS &&
+		((!ha->flags.enable_target_reset && 
+		  !ha->flags.enable_lip_reset) ||
+		ha->flags.enable_lip_full_login)) {
+
+		status = qla2x00_full_login_lip(ha);
+	}
+
+	/* Issue marker command only when we are going to start the I/O */
+	ha->marker_needed = 1;
+
+	if (status) {
+		/* Empty */
+		DEBUG2_3(printk("%s(%ld): **** FAILED ****\n",
+				__func__,
+				ha->host_no);)
+	} else {
+		/* Empty */
+		DEBUG3(printk("%s(%ld): exiting normally.\n",
+				__func__,
+				ha->host_no);)
+	}
+
+	LEAVE(__func__);
+
+	return(status);
+}
+
+/*
+ * qla2x00_device_reset
+ *	Issue bus device reset message to the target.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	t = SCSI ID.
+ *	TARGET_QUEUE_LOCK must be released.
+ *	ADAPTER_STATE_LOCK must be released.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static int
+qla2x00_device_reset(scsi_qla_host_t *ha, fc_port_t *reset_fcport)
+{
+	/* Abort Target command will clear Reservation */
+	return qla2x00_abort_target(reset_fcport);
+}
+
+/**************************************************************************
+* qla2x00_slave_configure
+*
+* Description:
+**************************************************************************/
+int
+qla2xxx_slave_configure(struct scsi_device *sdev)
+{
+	scsi_qla_host_t *ha = to_qla_host(sdev->host);
+	int queue_depth;
+
+	if (IS_QLA2100(ha) || IS_QLA2200(ha))
+		queue_depth = 16;
+	else
+		queue_depth = 32;
+
+	if (sdev->tagged_supported) {
+#if defined(MODULE)
+		if (!(ql2xmaxqdepth == 0 || ql2xmaxqdepth > 256))
+			queue_depth = ql2xmaxqdepth;
+#endif 
+		ql2xmaxqdepth = queue_depth;
+
+		scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, queue_depth);
+
+		qla_printk(KERN_INFO, ha,
+		    "scsi(%d:%d:%d:%d): Enabled tagged queuing, queue "
+		    "depth %d.\n",
+		    sdev->host->host_no, sdev->channel, sdev->id, sdev->lun,
+		    sdev->queue_depth);
+	} else {
+		 scsi_adjust_queue_depth(sdev, 0 /* TCQ off */,
+		     sdev->host->hostt->cmd_per_lun /* 3 */);
+	}
+
+	return (0);
+}
+
+/**
+ * qla2x00_config_dma_addressing() - Configure OS DMA addressing method.
+ * @ha: HA context
+ *
+ * At exit, the @ha's flags.enable_64bit_addressing set to indicated
+ * supported addressing method.
+ */
+static void
+qla2x00_config_dma_addressing(scsi_qla_host_t *ha)
+{
+	/* Assume 32bit DMA address */
+	ha->flags.enable_64bit_addressing = 0;
+	ha->calc_request_entries = qla2x00_calc_iocbs_32;
+	ha->build_scsi_iocbs = qla2x00_build_scsi_iocbs_32;
+
+	/*
+	 * Given the two variants pci_set_dma_mask(), allow the compiler to
+	 * assist in setting the proper dma mask.
+	 */
+	if (sizeof(dma_addr_t) > 4) {
+		/* Update our PCI device dma_mask for full 64 bits */
+		if (pci_set_dma_mask(ha->pdev, 0xffffffffffffffffULL) == 0) {
+			ha->flags.enable_64bit_addressing = 1;
+			ha->calc_request_entries = qla2x00_calc_iocbs_64;
+			ha->build_scsi_iocbs = qla2x00_build_scsi_iocbs_64;
+
+			if (pci_set_consistent_dma_mask(ha->pdev,
+			    0xffffffffffffffffULL)) {
+				qla_printk(KERN_DEBUG, ha, 
+				    "Failed to set 64 bit PCI consistent mask; "
+				    "using 32 bit.\n");
+				pci_set_consistent_dma_mask(ha->pdev,
+				    0xffffffffULL);
+			}
+		} else {
+			qla_printk(KERN_DEBUG, ha,
+			    "Failed to set 64 bit PCI DMA mask, falling back "
+			    "to 32 bit MASK.\n");
+			pci_set_dma_mask(ha->pdev, 0xffffffff);
+		}
+	} else {
+		pci_set_dma_mask(ha->pdev, 0xffffffff);
+	}
+}
+
+static int
+qla2x00_iospace_config(scsi_qla_host_t *ha)
+{
+	unsigned long	pio, pio_len, pio_flags;
+	unsigned long	mmio, mmio_len, mmio_flags;
+
+	pio = pci_resource_start(ha->pdev, 0);
+	pio_len = pci_resource_len(ha->pdev, 0);
+	pio_flags = pci_resource_flags(ha->pdev, 0);
+
+	mmio = pci_resource_start(ha->pdev, 1);
+	mmio_len = pci_resource_len(ha->pdev, 1);
+	mmio_flags = pci_resource_flags(ha->pdev, 1);
+
+#if MEMORY_MAPPED_IO
+	if (!(mmio_flags & IORESOURCE_MEM)) {
+		qla_printk(KERN_ERR, ha,
+		    "region #0 not an MMIO resource (%s), aborting\n",
+		    ha->pdev->slot_name);
+		goto iospace_error_exit;
+	}
+	if (mmio_len < MIN_IOBASE_LEN) {
+		qla_printk(KERN_ERR, ha,
+		    "Invalid PCI mem region size (%s), aborting\n",
+		    ha->pdev->slot_name);
+		goto iospace_error_exit;
+	}
+#else
+	if (!(pio_flags & IORESOURCE_IO)) {
+		qla_printk(KERN_ERR, ha,
+		    "region #0 not a PIO resource (%s), aborting\n",
+		    ha->pdev->slot_name);
+		goto iospace_error_exit;
+	}
+	if (pio_len < MIN_IOBASE_LEN) {
+		qla_printk(KERN_ERR, ha,
+		    "Invalid PCI I/O region size (%s), aborting\n",
+		    ha->pdev->slot_name);
+		goto iospace_error_exit;
+	}
+#endif
+
+	if (pci_request_regions(ha->pdev, ha->brd_info->drv_name)) {
+		qla_printk(KERN_WARNING, ha,
+		    "Failed to reserve PIO/MMIO regions (%s)\n", 
+		    ha->pdev->slot_name);
+
+		goto iospace_error_exit;
+	}
+
+	/* Assume PIO */
+	ha->iobase = (device_reg_t *) pio;
+	ha->pio_address = pio;
+	ha->pio_length = pio_len;
+	ha->mmio_address = NULL;
+#if MEMORY_MAPPED_IO
+	ha->mmio_address = ioremap(mmio, MIN_IOBASE_LEN);
+	if (!ha->mmio_address) {
+		qla_printk(KERN_ERR, ha,
+		    "cannot remap MMIO (%s), aborting\n", ha->pdev->slot_name);
+
+		goto iospace_error_exit;
+	}
+	ha->iobase = (device_reg_t *) ha->mmio_address;
+	ha->mmio_length = mmio_len;
+#endif
+
+	return (0);
+
+iospace_error_exit:
+	return (-ENOMEM);
+}
+
+/*
+ * PCI driver interface
+ */
+int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
+{
+	int	ret;
+	device_reg_t *reg;
+	struct Scsi_Host *host;
+	scsi_qla_host_t *ha;
+	unsigned long	flags = 0;
+	unsigned long	wait_switch = 0;
+	char pci_info[20];
+	char fw_str[30];
+
+	if (pci_enable_device(pdev))
+		return -1;
+
+	host = scsi_host_alloc(&qla2x00_driver_template,
+	    sizeof(scsi_qla_host_t));
+	if (host == NULL) {
+		printk(KERN_WARNING
+		    "qla2xxx: Couldn't allocate host from scsi layer!\n");
+		return -1;
+	}
+
+	/* Clear our data area */
+	ha = (scsi_qla_host_t *)host->hostdata;
+	memset(ha, 0, sizeof(scsi_qla_host_t));
+
+	ha->pdev = pdev;
+	ha->host = host;
+	ha->host_no = host->host_no;
+	ha->brd_info = brd_info;
+	sprintf(ha->host_str, "%s_%ld", ha->brd_info->drv_name, ha->host_no);
+
+	/* Configure PCI I/O space */
+	ret = qla2x00_iospace_config(ha);
+	if (ret != 0) {
+		goto probe_failed;
+	}
+
+	/* Sanitize the information from PCI BIOS. */
+	host->irq = pdev->irq;
+
+	qla_printk(KERN_INFO, ha,
+	    "Found an %s, irq %d, iobase 0x%p\n", ha->brd_info->isp_name,
+	    host->irq, ha->iobase);
+
+	spin_lock_init(&ha->hardware_lock);
+
+	/* 4.23 Initialize /proc/scsi/qla2x00 counters */
+	ha->actthreads = 0;
+	ha->qthreads   = 0;
+	ha->total_isr_cnt = 0;
+	ha->total_isp_aborts = 0;
+	ha->total_lip_cnt = 0;
+	ha->total_dev_errs = 0;
+	ha->total_ios = 0;
+	ha->total_bytes = 0;
+
+	ha->prev_topology = 0;
+	ha->ports = MAX_BUSES;
+
+	if (IS_QLA2100(ha)) {
+		ha->max_targets = MAX_TARGETS_2100;
+		ha->mbx_count = MAILBOX_REGISTER_COUNT_2100;
+		ha->response_q_length = RESPONSE_ENTRY_CNT_2100;
+		ha->last_loop_id = SNS_LAST_LOOP_ID_2100;
+	} else if (IS_QLA2200(ha)) {
+		ha->max_targets = MAX_TARGETS_2200;
+		ha->mbx_count = MAILBOX_REGISTER_COUNT;
+		ha->response_q_length = RESPONSE_ENTRY_CNT_2100;
+		ha->last_loop_id = SNS_LAST_LOOP_ID_2100;
+	} else /*if (IS_QLA2300(ha))*/ {
+		ha->max_targets = MAX_TARGETS_2200;
+		ha->mbx_count = MAILBOX_REGISTER_COUNT;
+		ha->response_q_length = RESPONSE_ENTRY_CNT_2300;
+		ha->last_loop_id = SNS_LAST_LOOP_ID_2300;
+	}
+
+	/* load the F/W, read paramaters, and init the H/W */
+	ha->instance = num_hosts;
+
+	init_MUTEX_LOCKED(&ha->mbx_intr_sem);
+
+	INIT_LIST_HEAD(&ha->list);
+	INIT_LIST_HEAD(&ha->fcports);
+	INIT_LIST_HEAD(&ha->rscn_fcports);
+	INIT_LIST_HEAD(&ha->done_queue);
+	INIT_LIST_HEAD(&ha->retry_queue);
+	INIT_LIST_HEAD(&ha->scsi_retry_queue);
+	INIT_LIST_HEAD(&ha->pending_queue);
+
+	/*
+	 * These locks are used to prevent more than one CPU
+	 * from modifying the queue at the same time. The
+	 * higher level "host_lock" will reduce most
+	 * contention for these locks.
+	 */
+	spin_lock_init(&ha->mbx_bits_lock);
+	spin_lock_init(&ha->mbx_reg_lock);
+	spin_lock_init(&ha->mbx_q_lock);
+	spin_lock_init(&ha->list_lock);
+
+	init_completion(&ha->dpc_inited);
+	init_completion(&ha->dpc_exited);
+
+	qla2x00_config_dma_addressing(ha);
+	if (qla2x00_mem_alloc(ha)) {
+		qla_printk(KERN_WARNING, ha,
+		    "[ERROR] Failed to allocate memory for adapter\n");
+
+		goto probe_failed;
+	}
+
+	if (qla2x00_initialize_adapter(ha) &&
+	    !(ha->device_flags & DFLG_NO_CABLE)) {
+
+		qla_printk(KERN_WARNING, ha,
+		    "Failed to initialize adapter\n");
+
+		DEBUG2(printk("scsi(%ld): Failed to initialize adapter - "
+		    "Adapter flags %x.\n",
+		    ha->host_no, ha->device_flags));
+
+		goto probe_failed;
+	}
+
+	/*
+	 * Startup the kernel thread for this host adapter
+	 */
+	ha->dpc_should_die = 0;
+	ha->dpc_pid = kernel_thread(qla2x00_do_dpc, ha, 0);
+	if (ha->dpc_pid < 0) {
+		qla_printk(KERN_WARNING, ha,
+		    "Unable to start DPC thread!\n");
+
+		goto probe_failed;
+	}
+	wait_for_completion(&ha->dpc_inited);
+
+	host->this_id = 255;
+	host->cmd_per_lun = 3;
+	host->max_cmd_len = MAX_CMDSZ;
+	host->max_channel = ha->ports - 1;
+	host->max_lun = ha->max_luns;
+	host->unique_id = ha->instance;
+	host->max_id = ha->max_targets;
+
+	if (request_irq(host->irq, qla2x00_intr_handler, SA_INTERRUPT|SA_SHIRQ,
+	    ha->brd_info->drv_name, ha)) {
+		qla_printk(KERN_WARNING, ha,
+		    "Failed to reserve interrupt %d already in use.\n",
+		    host->irq);
+		goto probe_failed;
+	}
+
+	/* Initialized the timer */
+	qla2x00_start_timer(ha, qla2x00_timer, WATCH_INTERVAL);
+
+	DEBUG2(printk("DEBUG: detect hba %ld at address = %p\n",
+	    ha->host_no, ha));
+
+	reg = ha->iobase;
+
+	/* Disable ISP interrupts. */
+	qla2x00_disable_intrs(ha);
+
+	/* Ensure mailbox registers are free. */
+	spin_lock_irqsave(&ha->hardware_lock, flags);
+	WRT_REG_WORD(&reg->semaphore, 0);
+	WRT_REG_WORD(&reg->hccr, HCCR_CLR_RISC_INT);
+	WRT_REG_WORD(&reg->hccr, HCCR_CLR_HOST_INT);
+
+	/* Enable proper parity */
+	if (IS_QLA23XX(ha)) {
+		if (IS_QLA2312(ha) || IS_QLA2322(ha))
+			/* SRAM, Instruction RAM and GP RAM parity */
+			WRT_REG_WORD(&reg->hccr, (HCCR_ENABLE_PARITY + 0x7));
+		else
+			/* SRAM parity */
+			WRT_REG_WORD(&reg->hccr, (HCCR_ENABLE_PARITY + 0x1));
+	}
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+	/* Enable chip interrupts. */
+	qla2x00_enable_intrs(ha);
+
+	/* Insert new entry into the list of adapters */
+	write_lock(&qla_hostlist_lock);
+	list_add_tail(&ha->list, &qla_hostlist);
+	write_unlock(&qla_hostlist_lock);
+
+	/* v2.19.5b6 */
+	/*
+	 * Wait around max loop_reset_delay secs for the devices to come
+	 * on-line. We don't want Linux scanning before we are ready.
+	 *
+	 */
+	for (wait_switch = jiffies + (ha->loop_reset_delay * HZ);
+	    time_before(jiffies,wait_switch) &&
+	     !(ha->device_flags & (DFLG_NO_CABLE | DFLG_FABRIC_DEVICES))
+	     && (ha->device_flags & SWITCH_FOUND) ;) {
+
+		qla2x00_check_fabric_devices(ha);
+
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(5);
+	}
+
+	pci_set_drvdata(pdev, ha);
+	ha->flags.init_done = 1;
+	num_hosts++;
+
+	/* List the target we have found */
+	if (displayConfig) {
+		qla2x00_display_fc_names(ha);
+	}
+
+	if (scsi_add_host(host, &pdev->dev))
+		goto probe_failed;
+
+	sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_fw_dump_attr);
+	sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr);
+
+	qla_printk(KERN_INFO, ha, "\n"
+	    " QLogic ISP2xxx PCI/PCI-X Fibre Channel HBA Driver: %s\n"
+	    "  QLogic %s - %s\n"
+	    "  %s: %s @ %s hdma%c, host#=%ld, fw=%s\n", qla2x00_version_str,
+	    ha->model_number, ha->model_desc ? ha->model_desc: "",
+	    ha->brd_info->isp_name, qla2x00_get_pci_info_str(ha, pci_info),
+	    pci_name(ha->pdev), ha->flags.enable_64bit_addressing ? '+': '-',
+	    ha->host_no, qla2x00_get_fw_version_str(ha, fw_str));
+
+	if (ql2xdoinitscan)
+		scsi_scan_host(host);
+
+	return 0;
+
+probe_failed:
+	qla2x00_free_device(ha);
+
+	scsi_host_put(host);
+
+	return -1;
+}
+EXPORT_SYMBOL_GPL(qla2x00_probe_one);
+
+void qla2x00_remove_one(struct pci_dev *pdev)
+{
+	scsi_qla_host_t *ha;
+
+	ha = pci_get_drvdata(pdev);
+
+	write_lock(&qla_hostlist_lock);
+	list_del(&ha->list);
+	write_unlock(&qla_hostlist_lock);
+
+	sysfs_remove_bin_file(&ha->host->shost_gendev.kobj,
+	    &sysfs_fw_dump_attr);
+	sysfs_remove_bin_file(&ha->host->shost_gendev.kobj, &sysfs_nvram_attr);
+
+	scsi_remove_host(ha->host);
+
+	qla2x00_free_device(ha);
+
+	scsi_host_put(ha->host);
+
+	pci_set_drvdata(pdev, NULL);
+}
+EXPORT_SYMBOL_GPL(qla2x00_remove_one);
+
+static void
+qla2x00_free_device(scsi_qla_host_t *ha)
+{
+	int ret;
+
+	/* Abort any outstanding IO descriptors. */
+	if (IS_QLA23XX(ha))
+		qla2x00_cancel_io_descriptors(ha);
+
+	/* turn-off interrupts on the card */
+	if (ha->interrupts_on)
+		qla2x00_disable_intrs(ha);
+
+	/* Disable timer */
+	if (ha->timer_active)
+		qla2x00_stop_timer(ha);
+
+	/* Kill the kernel thread for this host */
+	if (ha->dpc_pid >= 0) {
+		ha->dpc_should_die = 1;
+		wmb();
+		ret = kill_proc(ha->dpc_pid, SIGHUP, 1);
+		if (ret) {
+			qla_printk(KERN_ERR, ha,
+			    "Unable to signal DPC thread -- (%d)\n", ret);
+
+			/* TODO: SOMETHING MORE??? */
+		} else {
+			wait_for_completion(&ha->dpc_exited);
+		}
+	}
+
+	qla2x00_mem_free(ha);
+
+	ha->flags.online = FALSE;
+
+	/* Detach interrupts */
+	if (ha->pdev->irq)
+		free_irq(ha->pdev->irq, ha);
+
+	/* release io space registers  */
+	pci_release_regions(ha->pdev);
+
+#if MEMORY_MAPPED_IO
+	if (ha->mmio_address)
+		iounmap(ha->mmio_address);
+#endif
+}
+
+
+/*
+ * The following support functions are adopted to handle
+ * the re-entrant qla2x00_proc_info correctly.
+ */
+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);
+}
+
+/*************************************************************************
+* qla2x00_proc_info
+*
+* Description:
+*   Return information to handle /proc support for the driver.
+*
+* inout : decides the direction of the dataflow and the meaning of the
+*         variables
+* buffer: If inout==FALSE data is being written to it else read from it
+*         (ptr to a page buffer)
+* *start: If inout==FALSE start of the valid data in the buffer
+* offset: If inout==FALSE starting offset from the beginning of all
+*         possible data to return.
+* length: If inout==FALSE max number of bytes to be written into the buffer
+*         else number of bytes in "buffer"
+* Returns:
+*         < 0:  error. errno value.
+*         >= 0: sizeof data returned.
+*************************************************************************/
+int
+qla2x00_proc_info(struct Scsi_Host *shost, char *buffer,
+    char **start, off_t offset, int length, int inout)
+{
+	struct info_str	info;
+	int             i;
+	int             retval = -EINVAL;
+	os_lun_t	*up;
+	os_tgt_t	*tq;
+	unsigned int	t, l;
+	uint32_t        tmp_sn;
+	unsigned long   *flags;
+	uint8_t		*loop_state;
+	int	found;
+	scsi_qla_host_t *ha;
+	char fw_info[30];
+
+	DEBUG3(printk(KERN_INFO
+	    "Entering proc_info buff_in=%p, offset=0x%lx, length=0x%x\n",
+	    buffer, offset, length);)
+
+	ha = NULL;
+
+	/* Find the host that was specified */
+	found = 0;
+	read_lock(&qla_hostlist_lock);
+	list_for_each_entry(ha, &qla_hostlist, list) {
+		if (ha->host == shost) {
+			found++;
+			break;
+		}
+	}
+	read_unlock(&qla_hostlist_lock);
+
+	/* if host wasn't found then exit */
+	if (!found) {
+		DEBUG2_3(printk(KERN_WARNING
+		    "%s: Can't find adapter for host %p\n", 
+		    __func__, shost);)
+
+		return (retval);
+	}
+
+	if (inout == TRUE) {
+		/* Has data been written to the file? */
+		DEBUG3(printk(
+		    "%s: has data been written to the file. \n",
+		    __func__);)
+
+		return (qla2x00_set_info(buffer, length, shost));
+	}
+
+	if (start) {
+		*start = buffer;
+	}
+
+	info.buffer = buffer;
+	info.length = length;
+	info.offset = offset;
+	info.pos    = 0;
+
+	/* start building the print buffer */
+	copy_info(&info,
+	    "QLogic PCI to Fibre Channel Host Adapter for %s:\n"
+	    "        Firmware version %s, ",
+	    ha->model_number, qla2x00_get_fw_version_str(ha, fw_info));
+
+	copy_info(&info, "Driver version %s\n", qla2x00_version_str);
+
+	copy_info(&info, "Entry address = %p\n", qla2x00_set_info);
+
+	tmp_sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | 
+	    ha->serial1;
+	copy_info(&info, "ISP: %s, Serial# %c%05d\n",
+	    ha->brd_info->isp_name, ('A' + tmp_sn/100000), (tmp_sn%100000));
+
+	copy_info(&info,
+	    "Request Queue = 0x%p, Response Queue = 0x%p\n",
+	    (void *)ha->request_dma, (void *)ha->response_dma);
+
+	copy_info(&info,
+	    "Request Queue count = %ld, Response Queue count = %ld\n",
+	    (long)REQUEST_ENTRY_CNT, (long)ha->response_q_length);
+
+	copy_info(&info,
+	    "Total number of active commands = %ld\n",
+	    ha->actthreads);
+
+	copy_info(&info,
+	    "Total number of interrupts = %ld\n",
+	    (long)ha->total_isr_cnt);
+
+	copy_info(&info,
+	    "    Device queue depth = 0x%x\n",
+	    (ql2xmaxqdepth == 0) ? 16 : ql2xmaxqdepth);
+
+	copy_info(&info,
+	    "Number of free request entries = %d\n", ha->req_q_cnt);
+
+	copy_info(&info,
+	    "Number of mailbox timeouts = %ld\n", ha->total_mbx_timeout);
+
+	copy_info(&info,
+	    "Number of ISP aborts = %ld\n", ha->total_isp_aborts);
+
+	copy_info(&info,
+	    "Number of loop resyncs = %ld\n", ha->total_loop_resync);
+
+	copy_info(&info,
+	    "Number of retries for empty slots = %ld\n",
+	    qla2x00_stats.outarray_full);
+
+	copy_info(&info,
+	    "Number of reqs in pending_q= %ld, retry_q= %d, "
+	    "done_q= %ld, scsi_retry_q= %d\n",
+	    ha->qthreads, ha->retry_q_cnt,
+	    ha->done_q_cnt, ha->scsi_retry_q_cnt);
+
+	flags = (unsigned long *) &ha->flags;
+
+	if (atomic_read(&ha->loop_state) == LOOP_DOWN) {
+		loop_state = "DOWN";
+	} else if (atomic_read(&ha->loop_state) == LOOP_UP) {
+		loop_state = "UP";
+	} else if (atomic_read(&ha->loop_state) == LOOP_READY) {
+		loop_state = "READY";
+	} else if (atomic_read(&ha->loop_state) == LOOP_TIMEOUT) {
+		loop_state = "TIMEOUT";
+	} else if (atomic_read(&ha->loop_state) == LOOP_UPDATE) {
+		loop_state = "UPDATE";
+	} else {
+		loop_state = "UNKNOWN";
+	}
+
+	copy_info(&info, 
+	    "Host adapter:loop state = <%s>, flags = 0x%lx\n",
+	    loop_state , *flags);
+
+	copy_info(&info, "Dpc flags = 0x%lx\n", ha->dpc_flags);
+
+	copy_info(&info, "MBX flags = 0x%x\n", ha->mbx_flags);
+
+	copy_info(&info, "Link down Timeout = %3.3d\n",
+	    ha->link_down_timeout);
+
+	copy_info(&info, "Port down retry = %3.3d\n",
+	    ha->port_down_retry_count);
+
+	copy_info(&info, "Login retry count = %3.3d\n",
+	    ha->login_retry_count);
+
+	copy_info(&info,
+	    "Commands retried with dropped frame(s) = %d\n",
+	    ha->dropped_frame_error_cnt);
+
+	copy_info(&info,
+	    "Info -- pci=%x xchgs=0x%x iocbs=0x%x\n", ha->pci_attr,
+	    ha->xchg_buf_cnt, ha->iocb_buf_cnt);
+
+	copy_info(&info, "\n");
+
+	/* 2.25 node/port display to proc */
+	/* Display the node name for adapter */
+	copy_info(&info, "\nSCSI Device Information:\n");
+	copy_info(&info,
+	    "scsi-qla%d-adapter-node="
+	    "%02x%02x%02x%02x%02x%02x%02x%02x;\n",
+	    (int)ha->instance,
+	    ha->init_cb->node_name[0],
+	    ha->init_cb->node_name[1],
+	    ha->init_cb->node_name[2],
+	    ha->init_cb->node_name[3],
+	    ha->init_cb->node_name[4],
+	    ha->init_cb->node_name[5],
+	    ha->init_cb->node_name[6],
+	    ha->init_cb->node_name[7]);
+
+	/* display the port name for adapter */
+	copy_info(&info,
+	    "scsi-qla%d-adapter-port="
+	    "%02x%02x%02x%02x%02x%02x%02x%02x;\n",
+	    (int)ha->instance,
+	    ha->init_cb->port_name[0],
+	    ha->init_cb->port_name[1],
+	    ha->init_cb->port_name[2],
+	    ha->init_cb->port_name[3],
+	    ha->init_cb->port_name[4],
+	    ha->init_cb->port_name[5],
+	    ha->init_cb->port_name[6],
+	    ha->init_cb->port_name[7]);
+
+	/* Print out device port names */
+	for (i = 0; i < MAX_TARGETS; i++) {
+		if ((tq = TGT_Q(ha, i)) == NULL)
+			continue;
+
+		copy_info(&info,
+			  "scsi-qla%d-target-%d="
+			  "%02x%02x%02x%02x%02x%02x%02x%02x;\n",
+			  (int)ha->instance, i,
+			  tq->port_name[0], tq->port_name[1],
+			  tq->port_name[2], tq->port_name[3],
+			  tq->port_name[4], tq->port_name[5],
+			  tq->port_name[6], tq->port_name[7]);
+	} /* 2.25 node/port display to proc */
+
+	copy_info(&info, "\nSCSI LUN Information:\n");
+	copy_info(&info,
+	    "(Id:Lun)  * - indicates lun is not registered with the OS.\n");
+
+	/* scan for all equipment stats */
+	for (t = 0; t < MAX_FIBRE_DEVICES; t++) {
+		/* scan all luns */
+		for (l = 0; l < ha->max_luns; l++) {
+			up = (os_lun_t *) GET_LU_Q(ha, t, l);
+
+			if (up == NULL) {
+				continue;
+			}
+			if (up->fclun == NULL) {
+				continue;
+			}
+
+			copy_info(&info,
+			    "(%2d:%2d): Total reqs %ld,",
+			    t,l,up->io_cnt);
+
+			copy_info(&info,
+			    " Pending reqs %ld,",
+			    up->out_cnt);
+
+			if (up->io_cnt < 4) {
+				copy_info(&info,
+				    " flags 0x%x*,",
+				    (int)up->q_flag);
+			} else {
+				copy_info(&info,
+				    " flags 0x%x,",
+				    (int)up->q_flag);
+			}
+
+			copy_info(&info, 
+			    " %ld:%d:%02x %02x",
+			    up->fclun->fcport->ha->instance,
+			    up->fclun->fcport->cur_path,
+			    up->fclun->fcport->loop_id,
+			    up->fclun->device_type);
+
+			copy_info(&info, "\n");
+
+			if (info.pos >= info.offset + info.length) {
+				/* No need to continue */
+				goto profile_stop;
+			}
+		}
+
+		if (info.pos >= info.offset + info.length) {
+			/* No need to continue */
+			break;
+		}
+	}
+
+profile_stop:
+
+	retval = info.pos > info.offset ? info.pos - info.offset : 0;
+
+	DEBUG3(printk(KERN_INFO 
+	    "Exiting proc_info: info.pos=%d, offset=0x%lx, "
+	    "length=0x%x\n", info.pos, offset, length);)
+
+	return (retval);
+}
+
+/*
+* qla2x00_display_fc_names
+*      This routine will the node names of the different devices found
+*      after port inquiry.
+*
+* Input:
+*      cmd = SCSI command structure
+*
+* Returns:
+*      None.
+*/
+static void
+qla2x00_display_fc_names(scsi_qla_host_t *ha) 
+{
+	uint16_t	tgt;
+	os_tgt_t	*tq;
+
+	/* Display the node name for adapter */
+	qla_printk(KERN_INFO, ha,
+	    "scsi-qla%d-adapter-node=%02x%02x%02x%02x%02x%02x%02x%02x\\;\n",
+	    (int)ha->instance,
+	    ha->init_cb->node_name[0],
+	    ha->init_cb->node_name[1],
+	    ha->init_cb->node_name[2],
+	    ha->init_cb->node_name[3],
+	    ha->init_cb->node_name[4],
+	    ha->init_cb->node_name[5],
+	    ha->init_cb->node_name[6],
+	    ha->init_cb->node_name[7]);
+
+	/* display the port name for adapter */
+	qla_printk(KERN_INFO, ha,
+	    "scsi-qla%d-adapter-port=%02x%02x%02x%02x%02x%02x%02x%02x\\;\n",
+	    (int)ha->instance,
+	    ha->init_cb->port_name[0],
+	    ha->init_cb->port_name[1],
+	    ha->init_cb->port_name[2],
+	    ha->init_cb->port_name[3],
+	    ha->init_cb->port_name[4],
+	    ha->init_cb->port_name[5],
+	    ha->init_cb->port_name[6],
+	    ha->init_cb->port_name[7]);
+
+	/* Print out device port names */
+	for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
+		if ((tq = ha->otgt[tgt]) == NULL)
+			continue;
+
+		if (tq->fcport == NULL)
+			continue;
+
+		switch (ha->binding_type) {
+			case BIND_BY_PORT_NAME:
+				qla_printk(KERN_INFO, ha,
+				    "scsi-qla%d-tgt-%d-di-0-port="
+				    "%02x%02x%02x%02x%02x%02x%02x%02x\\;\n",
+				    (int)ha->instance, 
+				    tgt,
+				    tq->port_name[0], 
+				    tq->port_name[1],
+				    tq->port_name[2], 
+				    tq->port_name[3],
+				    tq->port_name[4], 
+				    tq->port_name[5],
+				    tq->port_name[6], 
+				    tq->port_name[7]);
+
+				break;
+
+			case BIND_BY_PORT_ID:
+				qla_printk(KERN_INFO, ha,
+				    "scsi-qla%d-tgt-%d-di-0-pid="
+				    "%02x%02x%02x\\;\n",
+				    (int)ha->instance,
+				    tgt,
+				    tq->d_id.b.domain,
+				    tq->d_id.b.area,
+				    tq->d_id.b.al_pa);
+				break;
+		}
+
+#if VSA
+		qla_printk(KERN_INFO, ha,
+		    "scsi-qla%d-target-%d-vsa=01;\n", (int)ha->instance, tgt);
+#endif
+	}
+}
+
+/*
+ *  qla2x00_suspend_lun
+ *	Suspend lun and start port down timer
+ *
+ * Input:
+ *	ha = visable adapter block pointer.
+ *  lq = lun queue
+ *  cp = Scsi command pointer 
+ *  time = time in seconds
+ *  count = number of times to let time expire
+ *  delay_lun = non-zero, if lun should be delayed rather than suspended
+ *
+ * Return:
+ *     QLA_SUCCESS  -- suspended lun 
+ *     QLA_FUNCTION_FAILED  -- Didn't suspend lun
+ *
+ * Context:
+ *	Interrupt context.
+ */
+int
+__qla2x00_suspend_lun(scsi_qla_host_t *ha,
+		os_lun_t *lq, int time, int count, int delay_lun)
+{
+	int	rval;
+	srb_t *sp;
+	struct list_head *list, *temp;
+	unsigned long flags;
+
+	rval = QLA_SUCCESS;
+
+	/* if the lun_q is already suspended then don't do it again */
+	if (lq->q_state == LUN_STATE_READY ||lq->q_state == LUN_STATE_RUN) {
+
+		spin_lock_irqsave(&lq->q_lock, flags);
+		if (lq->q_state == LUN_STATE_READY) {
+			lq->q_max = count;
+			lq->q_count = 0;
+		}
+		/* Set the suspend time usually 6 secs */
+		atomic_set(&lq->q_timer, time);
+
+		/* now suspend the lun */
+		lq->q_state = LUN_STATE_WAIT;
+
+		if (delay_lun) {
+			set_bit(LUN_EXEC_DELAYED, &lq->q_flag);
+			DEBUG(printk(KERN_INFO
+			    "scsi(%ld): Delay lun execution for %d secs, "
+			    "count=%d, max count=%d, state=%d\n",
+			    ha->host_no,
+			    time,
+			    lq->q_count, lq->q_max, lq->q_state));
+		} else {
+			DEBUG(printk(KERN_INFO
+			    "scsi(%ld): Suspend lun for %d secs, count=%d, "
+			    "max count=%d, state=%d\n",
+			    ha->host_no,
+			    time,
+			    lq->q_count, lq->q_max, lq->q_state));
+		}
+		spin_unlock_irqrestore(&lq->q_lock, flags);
+
+		/*
+		 * Remove all pending commands from request queue and  put them
+		 * in the scsi_retry queue.
+		 */
+		spin_lock_irqsave(&ha->list_lock, flags);
+		list_for_each_safe(list, temp, &ha->pending_queue) {
+			sp = list_entry(list, srb_t, list);
+			if (sp->lun_queue != lq)
+				continue;
+
+			__del_from_pending_queue(ha, sp);
+
+			if (sp->cmd->allowed < count)
+				sp->cmd->allowed = count;
+			__add_to_scsi_retry_queue(ha, sp);
+
+		} /* list_for_each_safe */
+		spin_unlock_irqrestore(&ha->list_lock, flags);
+		rval = QLA_SUCCESS;
+	} else {
+		rval = QLA_FUNCTION_FAILED;
+	}
+
+	return (rval);
+}
+
+/*
+ * qla2x00_mark_device_lost Updates fcport state when device goes offline.
+ *
+ * Input: ha = adapter block pointer.  fcport = port structure pointer.
+ *
+ * Return: None.
+ *
+ * Context:
+ */
+void qla2x00_mark_device_lost(scsi_qla_host_t *ha, fc_port_t *fcport,
+    int do_login)
+{
+	/* 
+	 * We may need to retry the login, so don't change the state of the
+	 * port but do the retries.
+	 */
+	if (atomic_read(&fcport->state) != FCS_DEVICE_DEAD)
+		atomic_set(&fcport->state, FCS_DEVICE_LOST);
+
+	if (!do_login)
+		return;
+
+	if (fcport->login_retry == 0) {
+		fcport->login_retry = ha->login_retry_count;
+		set_bit(RELOGIN_NEEDED, &ha->dpc_flags);
+
+		DEBUG(printk("scsi(%ld): Port login retry: "
+		    "%02x%02x%02x%02x%02x%02x%02x%02x, "
+		    "id = 0x%04x retry cnt=%d\n",
+		    ha->host_no,
+		    fcport->port_name[0],
+		    fcport->port_name[1],
+		    fcport->port_name[2],
+		    fcport->port_name[3],
+		    fcport->port_name[4],
+		    fcport->port_name[5],
+		    fcport->port_name[6],
+		    fcport->port_name[7],
+		    fcport->loop_id,
+		    fcport->login_retry));
+	}
+}
+
+/*
+ * qla2x00_mark_all_devices_lost
+ *	Updates fcport state when device goes offline.
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *	fcport = port structure pointer.
+ *
+ * Return:
+ *	None.
+ *
+ * Context:
+ */
+void
+qla2x00_mark_all_devices_lost(scsi_qla_host_t *ha) 
+{
+	struct list_head	*fcpl;
+	fc_port_t		*fcport;
+
+	list_for_each(fcpl, &ha->fcports) {
+		fcport = list_entry(fcpl, fc_port_t, list);
+
+		/*
+		 * No point in marking the device as lost, if the device is
+		 * already DEAD.
+		 */
+		if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD)
+			continue;
+
+		atomic_set(&fcport->state, FCS_DEVICE_LOST);
+	}
+}
+
+/*
+* qla2x00_mem_alloc
+*      Allocates adapter memory.
+*
+* Returns:
+*      0  = success.
+*      1  = failure.
+*/
+static uint8_t
+qla2x00_mem_alloc(scsi_qla_host_t *ha)
+{
+	uint8_t   status = 1;
+	uint8_t   i;
+	int	retry= 10;
+	mbx_cmdq_t	*ptmp;
+	mbx_cmdq_t	*tmp_q_head;
+	mbx_cmdq_t	*tmp_q_tail;
+
+	ENTER(__func__);
+
+	do {
+		/*
+		 * This will loop only once if everything goes well, else some
+		 * number of retries will be performed to get around a kernel
+		 * bug where available mem is not allocated until after a
+		 * little delay and a retry.
+		 */
+		ha->request_ring = pci_alloc_consistent(ha->pdev,
+		    ((REQUEST_ENTRY_CNT + 1) * (sizeof(request_t))),
+		    &ha->request_dma);
+		if (ha->request_ring == NULL) {
+			qla_printk(KERN_WARNING, ha,
+			    "Memory Allocation failed - request_ring\n");
+
+			qla2x00_mem_free(ha);
+			set_current_state(TASK_INTERRUPTIBLE);
+			schedule_timeout(HZ/10);
+
+			continue;
+		}
+
+		ha->response_ring = pci_alloc_consistent(ha->pdev,
+		    ((ha->response_q_length + 1) * (sizeof(response_t))),
+		    &ha->response_dma);
+		if (ha->response_ring == NULL) {
+			qla_printk(KERN_WARNING, ha,
+			    "Memory Allocation failed - response_ring\n");
+
+			qla2x00_mem_free(ha);
+			set_current_state(TASK_INTERRUPTIBLE);
+			schedule_timeout(HZ/10);
+
+			continue;
+		}
+
+		/* get consistent memory allocated for init control block */
+		ha->init_cb = pci_alloc_consistent(ha->pdev,
+		    sizeof(init_cb_t), &ha->init_cb_dma);
+		if (ha->init_cb == NULL) {
+			qla_printk(KERN_WARNING, ha,
+			    "Memory Allocation failed - init_cb\n");
+
+			qla2x00_mem_free(ha);
+			set_current_state(TASK_INTERRUPTIBLE);
+			schedule_timeout(HZ/10);
+
+			continue;
+		}
+		memset(ha->init_cb, 0, sizeof(init_cb_t));
+
+		/* Allocate ioctl related memory. */
+		if (qla2x00_alloc_ioctl_mem(ha)) {
+			qla_printk(KERN_WARNING, ha,
+			    "Memory Allocation failed - ioctl_mem\n");
+
+			qla2x00_mem_free(ha);
+			set_current_state(TASK_INTERRUPTIBLE);
+			schedule_timeout(HZ/10);
+
+			continue;
+		}
+
+		if (qla2x00_allocate_sp_pool(ha)) {
+			qla_printk(KERN_WARNING, ha,
+			    "Memory Allocation failed - "
+			    "qla2x00_allocate_sp_pool()\n");
+
+			qla2x00_mem_free(ha);
+			set_current_state(TASK_INTERRUPTIBLE);
+			schedule_timeout(HZ/10);
+
+			continue;
+		}
+
+		/*
+		 * Allocate an initial list of mailbox semaphore queue to be
+		 * used for serialization of the mailbox commands.
+		 */
+		tmp_q_head = kmalloc(sizeof(mbx_cmdq_t), GFP_KERNEL);
+		if (tmp_q_head == NULL) {
+			/* error */
+			qla_printk(KERN_WARNING, ha,
+			    "Memory Allocation failed - mbx_cmd_q");
+
+			qla2x00_mem_free(ha);
+			set_current_state(TASK_INTERRUPTIBLE);
+			schedule_timeout(HZ/10);
+
+			continue;
+		}
+		memset(tmp_q_head, 0, sizeof(mbx_cmdq_t));
+		ha->mbx_sem_pool_head = tmp_q_head;
+		tmp_q_tail = tmp_q_head;
+
+		/* Now try to allocate more */
+		for (i = 1; i < MBQ_INIT_LEN; i++) {
+			ptmp = kmalloc(sizeof(mbx_cmdq_t), GFP_KERNEL);
+			if (ptmp == NULL) {
+				/*
+				 * Error. Just exit. If more is needed later
+				 * they will be allocated at that time.
+				 */
+				break;
+			}
+			memset(ptmp, 0, sizeof(mbx_cmdq_t));
+			tmp_q_tail->pnext = ptmp;
+			tmp_q_tail = ptmp;
+		}
+		ha->mbx_sem_pool_tail = tmp_q_tail;
+
+		/* Get consistent memory allocated for MS IOCB */
+		ha->ms_iocb = pci_alloc_consistent(ha->pdev,
+		    sizeof(ms_iocb_entry_t), &ha->ms_iocb_dma);
+		if (ha->ms_iocb == NULL) {
+			/* error */
+			qla_printk(KERN_WARNING, ha,
+			    "Memory Allocation failed - ms_iocb\n");
+
+			qla2x00_mem_free(ha);
+			set_current_state(TASK_INTERRUPTIBLE);
+			schedule_timeout(HZ/10);
+
+			continue;
+		}
+		memset(ha->ms_iocb, 0, sizeof(ms_iocb_entry_t));
+
+		/* Get consistent memory allocated for CT SNS commands */
+		ha->ct_sns = pci_alloc_consistent(ha->pdev,
+		    sizeof(struct ct_sns_pkt), &ha->ct_sns_dma);
+		if (ha->ct_sns == NULL) {
+			/* error */
+			qla_printk(KERN_WARNING, ha,
+			    "Memory Allocation failed - ct_sns\n");
+
+			qla2x00_mem_free(ha);
+			set_current_state(TASK_INTERRUPTIBLE);
+			schedule_timeout(HZ/10);
+
+			continue;
+		}
+		memset(ha->ct_sns, 0, sizeof(struct ct_sns_pkt));
+
+		/* Get consistent memory allocated for Get Port Database cmd */
+		ha->iodesc_pd = pci_alloc_consistent(ha->pdev,
+		    PORT_DATABASE_SIZE, &ha->iodesc_pd_dma);
+		if (ha->iodesc_pd == NULL) {
+			/* error */
+			qla_printk(KERN_WARNING, ha,
+			    "Memory Allocation failed - iodesc_pd\n");
+
+			qla2x00_mem_free(ha);
+			set_current_state(TASK_INTERRUPTIBLE);
+			schedule_timeout(HZ/10);
+
+			continue;
+		}
+		memset(ha->iodesc_pd, 0, PORT_DATABASE_SIZE);
+
+		/* Done all allocations without any error. */
+		status = 0;
+
+	} while (retry-- && status != 0);
+
+	if (status) {
+		printk(KERN_WARNING
+			"%s(): **** FAILED ****\n", __func__);
+	}
+
+	LEAVE(__func__);
+
+	return(status);
+}
+
+/*
+* qla2x00_mem_free
+*      Frees all adapter allocated memory.
+*
+* Input:
+*      ha = adapter block pointer.
+*/
+static void
+qla2x00_mem_free(scsi_qla_host_t *ha)
+{
+	uint32_t	t;
+	struct list_head	*fcpl, *fcptemp;
+	fc_port_t	*fcport;
+	struct list_head	*fcll, *fcltemp;
+	fc_lun_t	*fclun;
+	mbx_cmdq_t	*ptmp;
+	mbx_cmdq_t	*tmp_q_head;
+	unsigned long	wtime;/* max wait time if mbx cmd is busy. */
+
+	ENTER(__func__);
+
+	if (ha == NULL) {
+		/* error */
+		DEBUG2(printk("%s(): ERROR invalid ha pointer.\n", __func__));
+		return;
+	}
+
+	/* Free the target queues */
+	for (t = 0; t < MAX_TARGETS; t++) {
+		qla2x00_tgt_free(ha, t);
+	}
+
+	/* Make sure all other threads are stopped. */
+	wtime = 60 * HZ;
+	while ((ha->dpc_wait != NULL || ha->mbx_q_head != NULL) && wtime) {
+		set_current_state(TASK_INTERRUPTIBLE);
+		wtime = schedule_timeout(wtime);
+	}
+
+	/* Now free the mbx sem pool */
+	tmp_q_head = ha->mbx_sem_pool_head;
+	while (tmp_q_head != NULL) {
+		ptmp = tmp_q_head->pnext;
+		kfree(tmp_q_head);
+		tmp_q_head = ptmp;
+	}
+	ha->mbx_sem_pool_head = NULL;
+
+	/* free ioctl memory */
+	qla2x00_free_ioctl_mem(ha);
+
+	/* free sp pool */
+	qla2x00_free_sp_pool(ha);
+
+	if (ha->iodesc_pd) {
+		pci_free_consistent(ha->pdev, PORT_DATABASE_SIZE,
+		    ha->iodesc_pd, ha->iodesc_pd_dma);
+	}
+	if (ha->ct_sns) {
+		pci_free_consistent(ha->pdev,
+		    sizeof(struct ct_sns_pkt), ha->ct_sns, ha->ct_sns_dma);
+	}
+	if (ha->ms_iocb) {
+		pci_free_consistent(ha->pdev,
+		    sizeof(ms_iocb_entry_t), ha->ms_iocb, ha->ms_iocb_dma);
+	}
+
+	if (ha->init_cb) {
+		pci_free_consistent(ha->pdev,
+		    sizeof(init_cb_t), ha->init_cb, ha->init_cb_dma);
+	}
+
+	if (ha->request_ring) {
+		pci_free_consistent(ha->pdev,
+		    ((REQUEST_ENTRY_CNT + 1) * (sizeof(request_t))),
+		    ha->request_ring, ha->request_dma);
+	}
+
+	if (ha->response_ring) {
+		pci_free_consistent(ha->pdev,
+		    ((ha->response_q_length + 1) * (sizeof(response_t))),
+		    ha->response_ring, ha->response_dma);
+	}
+
+	ha->iodesc_pd = NULL;
+	ha->iodesc_pd_dma = 0;
+	ha->ct_sns = NULL;
+	ha->ms_iocb = NULL;
+
+	ha->init_cb = NULL;
+	ha->request_ring = NULL;
+	ha->request_dma = 0;
+	ha->response_ring = NULL;
+	ha->response_dma = 0;
+
+	list_for_each_safe(fcpl, fcptemp, &ha->fcports) {
+		fcport = list_entry(fcpl, fc_port_t, list);
+
+		/* fc luns */
+		list_for_each_safe(fcll, fcltemp, &fcport->fcluns) {
+			fclun = list_entry(fcll, fc_lun_t, list);
+
+			list_del_init(&fclun->list);
+			kfree(fclun);
+		}
+
+		/* fc ports */
+		list_del_init(&fcport->list);
+		kfree(fcport);
+	}
+	INIT_LIST_HEAD(&ha->fcports);
+
+	if (ha->fw_dump) {
+		free_pages((unsigned long)ha->fw_dump, ha->fw_dump_order);
+		ha->fw_dump = NULL;
+	}
+
+	if (ha->fw_dump_buffer) {
+		vfree(ha->fw_dump_buffer);
+		ha->fw_dump_reading = 0;
+		ha->fw_dump_buffer = NULL;
+	}
+
+	LEAVE(__func__);
+}
+
+/*
+ * qla2x00_allocate_sp_pool
+ * 	 This routine is called during initialization to allocate
+ *  	 memory for local srb_t.
+ *
+ * Input:
+ *	 ha   = adapter block pointer.
+ *
+ * Context:
+ *      Kernel context.
+ * 
+ * Note: Sets the ref_count for non Null sp to one.
+ */
+int
+qla2x00_allocate_sp_pool(scsi_qla_host_t *ha) 
+{
+	int      rval;
+
+	rval = QLA_SUCCESS;
+	ha->srb_mempool = mempool_create(SRB_MIN_REQ, mempool_alloc_slab,
+	    mempool_free_slab, srb_cachep);
+	if (ha->srb_mempool == NULL) {
+		qla_printk(KERN_INFO, ha, "Unable to allocate SRB mempool.\n");
+		rval = QLA_FUNCTION_FAILED;
+	}
+	return (rval);
+}
+
+/*
+ *  This routine frees all adapter allocated memory.
+ *  
+ */
+void
+qla2x00_free_sp_pool( scsi_qla_host_t *ha) 
+{
+	if (ha->srb_mempool) {
+		mempool_destroy(ha->srb_mempool);
+		ha->srb_mempool = NULL;
+	}
+}
+
+/**************************************************************************
+* qla2x00_do_dpc
+*   This kernel thread is a task that is schedule by the interrupt handler
+*   to perform the background processing for interrupts.
+*
+* Notes:
+* This task always run in the context of a kernel thread.  It
+* is kick-off by the driver's detect code and starts up
+* up one per adapter. It immediately goes to sleep and waits for
+* some fibre event.  When either the interrupt handler or
+* the timer routine detects a event it will one of the task
+* bits then wake us up.
+**************************************************************************/
+static int
+qla2x00_do_dpc(void *data)
+{
+	DECLARE_MUTEX_LOCKED(sem);
+	scsi_qla_host_t *ha;
+	struct list_head *fcpl;
+	fc_port_t	*fcport;
+	os_lun_t        *q;
+	srb_t           *sp;
+	uint8_t		status;
+	unsigned long	flags = 0;
+	struct list_head *list, *templist;
+	int	dead_cnt, online_cnt;
+	uint16_t	next_loopid;
+
+	ha = (scsi_qla_host_t *)data;
+
+	lock_kernel();
+
+	daemonize("%s_dpc", ha->host_str);
+	allow_signal(SIGHUP);
+
+	ha->dpc_wait = &sem;
+
+	set_user_nice(current, -20);
+
+	unlock_kernel();
+
+	complete(&ha->dpc_inited);
+
+	while (1) {
+		DEBUG3(printk("qla2x00: DPC handler sleeping\n"));
+
+		if (down_interruptible(&sem))
+			break;
+
+		if (ha->dpc_should_die)
+			break;
+
+		if (!list_empty(&ha->done_queue))
+			qla2x00_done(ha);
+
+		DEBUG3(printk("qla2x00: DPC handler waking up\n"));
+
+		/* Initialization not yet finished. Don't do anything yet. */
+		if (!ha->flags.init_done || ha->dpc_active)
+			continue;
+
+		DEBUG3(printk("scsi(%ld): DPC handler\n", ha->host_no));
+
+		ha->dpc_active = 1;
+
+		/* Process commands in retry queue */
+		if (test_and_clear_bit(PORT_RESTART_NEEDED, &ha->dpc_flags)) {
+			DEBUG(printk("scsi(%ld): DPC checking retry_q. "
+			    "total=%d\n",
+			    ha->host_no, ha->retry_q_cnt));
+
+			spin_lock_irqsave(&ha->list_lock, flags);
+			dead_cnt = online_cnt = 0;
+			list_for_each_safe(list, templist, &ha->retry_queue) {
+				sp = list_entry(list, srb_t, list);
+				q = sp->lun_queue;
+				DEBUG3(printk("scsi(%ld): pid=%ld sp=%p, "
+				    "spflags=0x%x, q_flag= 0x%lx\n",
+				    ha->host_no, sp->cmd->serial_number, sp,
+				    sp->flags, q->q_flag));
+
+				if (q == NULL)
+					continue;
+				fcport = q->fclun->fcport;
+
+				if (atomic_read(&fcport->state) ==
+				    FCS_DEVICE_DEAD ||
+				    atomic_read(&ha->loop_state) == LOOP_DEAD) {
+
+					__del_from_retry_queue(ha, sp);
+					sp->cmd->result = DID_NO_CONNECT << 16;
+					sp->cmd->host_scribble =
+					    (unsigned char *) NULL;
+					__add_to_done_queue(ha, sp);
+					dead_cnt++;
+				} else if (atomic_read(&fcport->state) !=
+				    FCS_DEVICE_LOST) {
+
+					__del_from_retry_queue(ha, sp);
+					sp->cmd->result = DID_BUS_BUSY << 16;
+					sp->cmd->host_scribble =
+					    (unsigned char *) NULL;
+					__add_to_done_queue(ha, sp);
+					online_cnt++;
+				}
+			} /* list_for_each_safe() */
+			spin_unlock_irqrestore(&ha->list_lock, flags);
+
+			DEBUG(printk("scsi(%ld): done processing retry queue "
+			    "- dead=%d, online=%d\n ",
+			    ha->host_no, dead_cnt, online_cnt));
+		}
+
+		/* Process commands in scsi retry queue */
+		if (test_and_clear_bit(SCSI_RESTART_NEEDED, &ha->dpc_flags)) {
+			/*
+			 * Any requests we want to delay for some period is put
+			 * in the scsi retry queue with a delay added. The
+			 * timer will schedule a "scsi_restart_needed" every 
+			 * second as long as there are requests in the scsi
+			 * queue. 
+			 */
+			DEBUG(printk("scsi(%ld): DPC checking scsi "
+			    "retry_q.total=%d\n",
+			    ha->host_no, ha->scsi_retry_q_cnt));
+
+			online_cnt = 0;
+			spin_lock_irqsave(&ha->list_lock, flags);
+			list_for_each_safe(list, templist,
+			    &ha->scsi_retry_queue) {
+
+				sp = list_entry(list, srb_t, list);
+				q = sp->lun_queue;
+
+				DEBUG3(printk("scsi(%ld): scsi_retry_q: "
+				    "pid=%ld sp=%p, spflags=0x%x, "
+				    "q_flag= 0x%lx,q_state=%d\n",
+				    ha->host_no, sp->cmd->serial_number,
+				    sp, sp->flags, q->q_flag, q->q_state));
+
+				/* Was this lun suspended */
+				if (q->q_state != LUN_STATE_WAIT) {
+					online_cnt++;
+					__del_from_scsi_retry_queue(ha, sp);
+					__add_to_retry_queue(ha,sp);
+				}
+
+				/* Was this command suspended for N secs */
+				if (sp->delay != 0) {
+					sp->delay--;
+					if (sp->delay == 0) {
+						online_cnt++;
+						__del_from_scsi_retry_queue(
+						    ha, sp);
+						__add_to_retry_queue(ha,sp);
+					}
+				}
+			}
+			spin_unlock_irqrestore(&ha->list_lock, flags);
+
+			DEBUG(if (online_cnt > 0))
+			DEBUG(printk("scsi(%ld): dpc() found scsi reqs to "
+			    "restart= %d\n",
+			    ha->host_no, online_cnt));
+		}
+
+		if (ha->flags.mbox_busy) {
+			if (!list_empty(&ha->done_queue))
+				qla2x00_done(ha);
+
+			ha->dpc_active = 0;
+			continue;
+		}
+
+		if (test_and_clear_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) {
+
+			DEBUG(printk("scsi(%ld): dpc: sched "
+			    "qla2x00_abort_isp ha = %p\n",
+			    ha->host_no, ha));
+			if (!(test_and_set_bit(ABORT_ISP_ACTIVE,
+			    &ha->dpc_flags))) {
+
+				if (qla2x00_abort_isp(ha)) {
+					/* failed. retry later */
+					set_bit(ISP_ABORT_NEEDED,
+					    &ha->dpc_flags);
+				}
+				clear_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags);
+			}
+			DEBUG(printk("scsi(%ld): dpc: qla2x00_abort_isp end\n",
+			    ha->host_no));
+		}
+
+		if (test_and_clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags) &&
+		    (!(test_and_set_bit(RESET_ACTIVE, &ha->dpc_flags)))) {
+
+			DEBUG(printk("scsi(%ld): qla2x00_reset_marker()\n",
+			    ha->host_no));
+
+			qla2x00_rst_aen(ha);
+			clear_bit(RESET_ACTIVE, &ha->dpc_flags);
+		}
+
+		/* Retry each device up to login retry count */
+		if ((test_and_clear_bit(RELOGIN_NEEDED, &ha->dpc_flags)) &&
+		    !test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags) &&
+		    atomic_read(&ha->loop_state) != LOOP_DOWN) {
+
+			DEBUG(printk("scsi(%ld): qla2x00_port_login()\n",
+			    ha->host_no));
+
+			next_loopid = 0;
+			list_for_each(fcpl, &ha->fcports) {
+				fcport = list_entry(fcpl, fc_port_t, list);
+				
+				/*
+				 * If the port is not ONLINE then try to login
+				 * to it if we haven't run out of retries.
+				 */
+				if (atomic_read(&fcport->state) != FCS_ONLINE &&
+				    fcport->login_retry) {
+
+					fcport->login_retry--;
+					if (fcport->flags & FCF_FABRIC_DEVICE)
+						status = qla2x00_fabric_login(
+						    ha, fcport, &next_loopid);
+					else 	
+						status =
+						    qla2x00_local_device_login(
+							ha, fcport->loop_id);
+
+					if (status == QLA_SUCCESS) {
+						fcport->old_loop_id = fcport->loop_id;
+
+						DEBUG(printk("scsi(%ld): port login OK: logged in ID 0x%x\n",
+						    ha->host_no, fcport->loop_id));
+						
+						fcport->port_login_retry_count =
+						    ha->port_down_retry_count * PORT_RETRY_TIME;
+						atomic_set(&fcport->state, FCS_ONLINE);
+						atomic_set(&fcport->port_down_timer,
+						    ha->port_down_retry_count * PORT_RETRY_TIME);
+
+						fcport->login_retry = 0;
+					} else if (status == 1) {
+						set_bit(RELOGIN_NEEDED, &ha->dpc_flags);
+						/* retry the login again */
+						DEBUG(printk("scsi(%ld): Retrying %d login again loop_id 0x%x\n",
+						    ha->host_no,
+						    fcport->login_retry, fcport->loop_id));
+					} else {
+						fcport->login_retry = 0;
+					}
+				}
+				if (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))
+					break;
+			}
+			DEBUG(printk("scsi(%ld): qla2x00_port_login - end\n",
+			    ha->host_no));
+		}
+
+		if ((test_bit(LOGIN_RETRY_NEEDED, &ha->dpc_flags)) &&
+		    atomic_read(&ha->loop_state) != LOOP_DOWN) {
+
+			clear_bit(LOGIN_RETRY_NEEDED, &ha->dpc_flags);
+			DEBUG(printk("scsi(%ld): qla2x00_login_retry()\n",
+			    ha->host_no));
+				
+			set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
+
+			DEBUG(printk("scsi(%ld): qla2x00_login_retry - end\n",
+			    ha->host_no));
+		}
+
+		if (test_and_clear_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) {
+
+			DEBUG(printk("scsi(%ld): qla2x00_loop_resync()\n",
+			    ha->host_no));
+
+			if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE,
+			    &ha->dpc_flags))) {
+
+				qla2x00_loop_resync(ha);
+
+				clear_bit(LOOP_RESYNC_ACTIVE, &ha->dpc_flags);
+			}
+
+			DEBUG(printk("scsi(%ld): qla2x00_loop_resync - end\n",
+			    ha->host_no));
+		}
+
+		if (test_bit(RESTART_QUEUES_NEEDED, &ha->dpc_flags)) {
+			DEBUG(printk("scsi(%ld): qla2x00_restart_queues()\n",
+			    ha->host_no));
+
+			qla2x00_restart_queues(ha,FALSE);
+
+			DEBUG(printk("scsi(%ld): qla2x00_restart_queues - end\n",
+			    ha->host_no));
+		}
+
+		if (test_bit(ABORT_QUEUES_NEEDED, &ha->dpc_flags)) {
+
+			DEBUG(printk("scsi(%ld): qla2x00_abort_queues()\n",
+			    ha->host_no));
+				
+			qla2x00_abort_queues(ha, FALSE);
+
+			DEBUG(printk("scsi(%ld): qla2x00_abort_queues - end\n",
+			    ha->host_no));
+		}
+
+		if (test_and_clear_bit(FCPORT_RESCAN_NEEDED, &ha->dpc_flags)) {
+
+			DEBUG(printk("scsi(%ld): Rescan flagged fcports...\n",
+			    ha->host_no));
+
+			qla2x00_rescan_fcports(ha);
+
+			DEBUG(printk("scsi(%ld): Rescan flagged fcports..."
+			    "end.\n",
+			    ha->host_no));
+		}
+
+
+		if (!ha->interrupts_on)
+			qla2x00_enable_intrs(ha);
+
+		if (!list_empty(&ha->done_queue))
+			qla2x00_done(ha);
+
+		ha->dpc_active = 0;
+	} /* End of while(1) */
+
+	DEBUG(printk("scsi(%ld): DPC handler exiting\n", ha->host_no));
+
+	/*
+	 * Make sure that nobody tries to wake us up again.
+	 */
+	ha->dpc_wait = NULL;
+	ha->dpc_active = 0;
+
+	complete_and_exit(&ha->dpc_exited, 0);
+}
+
+/*
+ *  qla2x00_abort_queues
+ *	Abort all commands on queues on device
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *
+ * Context:
+ *	Interrupt context.
+ */
+void
+qla2x00_abort_queues(scsi_qla_host_t *ha, uint8_t doneqflg) 
+{
+
+	srb_t       *sp;
+	struct list_head *list, *temp;
+	unsigned long flags;
+
+	ENTER(__func__);
+
+	clear_bit(ABORT_QUEUES_NEEDED, &ha->dpc_flags);
+
+	/* Return all commands device queues. */
+	spin_lock_irqsave(&ha->list_lock,flags);
+	list_for_each_safe(list, temp, &ha->pending_queue) {
+		sp = list_entry(list, srb_t, list);
+
+		if (sp->flags & SRB_ABORTED)
+			continue;
+
+		/* Remove srb from LUN queue. */
+		__del_from_pending_queue(ha, sp);
+
+		/* Set ending status. */
+		sp->cmd->result = DID_BUS_BUSY << 16;
+
+		__add_to_done_queue(ha, sp);
+	}
+	spin_unlock_irqrestore(&ha->list_lock, flags);
+
+	LEAVE(__func__);
+}
+
+/*
+*  qla2x00_rst_aen
+*      Processes asynchronous reset.
+*
+* Input:
+*      ha  = adapter block pointer.
+*/
+static void
+qla2x00_rst_aen(scsi_qla_host_t *ha) 
+{
+	ENTER(__func__);
+
+	if (ha->flags.online && !ha->flags.reset_active &&
+	    !atomic_read(&ha->loop_down_timer) &&
+	    !(test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags))) {
+
+		/* 10/15 ha->flags.reset_active = TRUE; */
+		do {
+			clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
+
+			/*
+			 * Issue marker command only when we are going to start
+			 * the I/O.
+			 */
+			ha->marker_needed = 1;
+		} while (!atomic_read(&ha->loop_down_timer) &&
+		    (test_bit(RESET_MARKER_NEEDED, &ha->dpc_flags)));
+
+		/* 10/15 ha->flags.reset_active = FALSE; */
+	}
+
+	LEAVE(__func__);
+}
+
+
+/*
+ * This routine will alloacte SP from the free queue
+ * input:
+ *        scsi_qla_host_t *
+ * output:
+ *        srb_t * or NULL
+ */
+srb_t *
+qla2x00_get_new_sp(scsi_qla_host_t *ha)
+{
+	srb_t *sp;
+
+	sp = mempool_alloc(ha->srb_mempool, GFP_KERNEL);
+	if (sp) {
+		atomic_set(&sp->ref_count, 1);
+	}
+	return (sp);
+}
+
+/**************************************************************************
+ * qla2x00_blink_led
+ *
+ * Description:
+ *   This function sets the colour of the LED while preserving the
+ *   unsued GPIO pins every sec.
+ *
+ * Input:
+ *       ha - Host adapter structure
+ *      
+ * Return:
+ * 	None
+ *
+ * Context: qla2x00_timer() Interrupt
+ ***************************************************************************/
+void
+qla2x00_blink_led(scsi_qla_host_t *ha)
+{
+	uint16_t	gpio_enable, gpio_data, led_color;
+	unsigned long	cpu_flags = 0;
+	device_reg_t	*reg = ha->iobase;
+
+	ENTER(__func__);
+
+	/* Save the Original GPIOE */ 
+	spin_lock_irqsave(&ha->hardware_lock, cpu_flags);
+	gpio_enable = RD_REG_WORD(&reg->gpioe);
+	gpio_data = RD_REG_WORD(&reg->gpiod);
+	spin_unlock_irqrestore(&ha->hardware_lock, cpu_flags);
+
+	DEBUG2(printk("%s Original data of gpio_enable_reg=0x%x"
+	    " gpio_data_reg=0x%x\n",
+	    __func__,gpio_enable,gpio_data));
+
+	if (ha->beacon_green_on){
+		led_color = GPIO_LED_GREEN_ON_AMBER_OFF;
+		ha->beacon_green_on = 0;
+	} else {
+		led_color = GPIO_LED_GREEN_OFF_AMBER_OFF;
+		ha->beacon_green_on = 1;
+	}
+
+	/* Set the modified gpio_enable values */
+	gpio_enable |= GPIO_LED_GREEN_ON_AMBER_OFF;
+
+	DEBUG2(printk("%s Before writing enable : gpio_enable_reg=0x%x"
+	    " gpio_data_reg=0x%x led_color=0x%x\n",
+	    __func__, gpio_enable, gpio_data, led_color));
+
+	spin_lock_irqsave(&ha->hardware_lock, cpu_flags);
+	WRT_REG_WORD(&reg->gpioe,gpio_enable);
+	spin_unlock_irqrestore(&ha->hardware_lock, cpu_flags);
+
+	/* Clear out the previously set LED colour */
+	gpio_data &= ~GPIO_LED_GREEN_ON_AMBER_OFF;
+
+	/* Set the new input LED colour to GPIOD */
+	gpio_data |= led_color;
+
+	DEBUG2(printk("%s Before writing data: gpio_enable_reg=0x%x"
+	    " gpio_data_reg=0x%x led_color=0x%x\n",
+	    __func__,gpio_enable,gpio_data,led_color));
+
+	/* Set the modified gpio_data values */
+	spin_lock_irqsave(&ha->hardware_lock, cpu_flags);
+	WRT_REG_WORD(&reg->gpiod,gpio_data);
+	spin_unlock_irqrestore(&ha->hardware_lock, cpu_flags);
+
+	LEAVE(__func__);
+}
+
+/**************************************************************************
+*   qla2x00_timer
+*
+* Description:
+*   One second timer
+*
+* Context: Interrupt
+***************************************************************************/
+static void
+qla2x00_timer(scsi_qla_host_t *ha)
+{
+	int		t,l;
+	unsigned long	cpu_flags = 0;
+	struct list_head	*fcpl;
+	fc_port_t	*fcport;
+	os_lun_t *lq;
+	os_tgt_t *tq;
+	int		start_dpc = 0;
+
+	/*
+	 * We try and restart any request in the retry queue every second.
+	 */
+	if (!list_empty(&ha->retry_queue)) {
+		set_bit(PORT_RESTART_NEEDED, &ha->dpc_flags);
+		start_dpc++;
+	}
+
+	/*
+	 * We try and restart any request in the scsi_retry queue every second.
+	 */
+	if (!list_empty(&ha->scsi_retry_queue)) {
+		set_bit(SCSI_RESTART_NEEDED, &ha->dpc_flags);
+		start_dpc++;
+	}
+
+	/* Check if beacon LED needs to be blinked */
+	if (IS_QLA23XX(ha) && ha->beacon_blink_led)
+		qla2x00_blink_led(ha);
+
+	/*
+	 * Ports - Port down timer.
+	 *
+	 * Whenever, a port is in the LOST state we start decrementing its port
+	 * down timer every second until it reaches zero. Once  it reaches zero
+	 * the port it marked DEAD. 
+	 */
+	t = 0;
+	list_for_each(fcpl, &ha->fcports) {
+		fcport = list_entry(fcpl, fc_port_t, list);
+
+		if (atomic_read(&fcport->state) == FCS_DEVICE_LOST) {
+
+			if (atomic_read(&fcport->port_down_timer) == 0)
+				continue;
+
+			if (atomic_dec_and_test(&fcport->port_down_timer) != 0) 
+				atomic_set(&fcport->state, FCS_DEVICE_DEAD);
+			
+			DEBUG(printk("scsi(%ld): fcport-%d - port retry count: "
+			    "%d remainning\n",
+			    ha->host_no,
+			    t, atomic_read(&fcport->port_down_timer)));
+		}
+		t++;
+	} /* End of for fcport  */
+
+	/*
+	 * LUNS - lun suspend timer.
+	 *
+	 * Whenever, a lun is suspended the timer starts decrementing its
+	 * suspend timer every second until it reaches zero. Once  it reaches
+	 * zero the lun retry count is decremented. 
+	 */
+
+	/*
+	 * FIXME(dg) - Need to convert this linear search of luns into a search
+	 * of a list of suspended luns.
+	 */
+	for (t = 0; t < ha->max_targets; t++) {
+		if ((tq = ha->otgt[t]) == NULL)
+			continue;
+
+		for (l = 0; l < ha->max_luns; l++) {
+			if ((lq = (os_lun_t *) tq->olun[l]) == NULL)
+				continue;
+
+			spin_lock_irqsave(&lq->q_lock, cpu_flags);
+			if (lq->q_state == LUN_STATE_WAIT &&
+				atomic_read(&lq->q_timer) != 0) {
+
+				if (atomic_dec_and_test(&lq->q_timer) != 0) {
+					/*
+					 * A delay should immediately
+					 * transition to a READY state
+					 */
+					if (test_and_clear_bit(LUN_EXEC_DELAYED,
+					    &lq->q_flag)) {
+						lq->q_state = LUN_STATE_READY;
+					}
+					else {
+						lq->q_count++;
+						if (lq->q_count == lq->q_max)
+							lq->q_state =
+							    LUN_STATE_TIMEOUT;
+						else
+							lq->q_state =
+							    LUN_STATE_RUN;
+					}
+				}
+				DEBUG3(printk("scsi(%ld): lun%d - timer %d, "
+				    "count=%d, max=%d, state=%d\n",
+				    ha->host_no,
+				    l,
+				    atomic_read(&lq->q_timer),
+				    lq->q_count, lq->q_max, lq->q_state));
+			}
+			spin_unlock_irqrestore(&lq->q_lock, cpu_flags);
+		} /* End of for luns  */
+	} /* End of for targets  */
+
+	/* Loop down handler. */
+	if (atomic_read(&ha->loop_down_timer) > 0 &&
+	    !(test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags)) && ha->flags.online) {
+
+		/* dg 10/30 if (atomic_read(&ha->loop_down_timer) == LOOP_DOWN_TIME) { */
+		if (atomic_read(&ha->loop_down_timer) ==
+		    ha->loop_down_abort_time) {
+
+			DEBUG(printk("scsi(%ld): Loop Down - aborting the "
+			    "queues before time expire\n",
+			    ha->host_no));
+
+			if (!IS_QLA2100(ha) && ha->link_down_timeout)
+				atomic_set(&ha->loop_state, LOOP_DEAD); 
+
+			set_bit(ABORT_QUEUES_NEEDED, &ha->dpc_flags);
+			start_dpc++;
+		}
+
+		/* if the loop has been down for 4 minutes, reinit adapter */
+		if (atomic_dec_and_test(&ha->loop_down_timer) != 0) {
+			DEBUG(printk("scsi(%ld): Loop down exceed 4 mins - "
+			    "restarting queues.\n",
+			    ha->host_no));
+
+			set_bit(RESTART_QUEUES_NEEDED, &ha->dpc_flags);
+			start_dpc++;
+
+		}
+		DEBUG3(printk("scsi(%ld): Loop Down - seconds remainning %d\n",
+		    ha->host_no,
+		    atomic_read(&ha->loop_down_timer)));
+	}
+
+	/*
+	 * Done Q Handler -- dgFIXME This handler will kick off doneq if we
+	 * haven't process it in 2 seconds.
+	 */
+	if (!list_empty(&ha->done_queue))
+		qla2x00_done(ha);
+
+	/* Schedule the DPC routine if needed */
+	if ((test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) ||
+	    test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags) ||
+	    start_dpc ||
+	    test_bit(LOGIN_RETRY_NEEDED, &ha->dpc_flags) ||
+	    test_bit(RELOGIN_NEEDED, &ha->dpc_flags)) &&
+	    ha->dpc_wait && !ha->dpc_active) {
+
+		up(ha->dpc_wait);
+	}
+
+	qla2x00_restart_timer(ha, WATCH_INTERVAL);
+}
+
+/*
+ * qla2x00_extend_timeout
+ *      This routine will extend the timeout to the specified value.
+ *
+ * Input:
+ *      cmd = SCSI command structure
+ *
+ * Returns:
+ *      None.
+ */
+void 
+qla2x00_extend_timeout(struct scsi_cmnd *cmd, int timeout) 
+{
+	srb_t *sp = (srb_t *) CMD_SP(cmd);
+	u_long our_jiffies = (timeout * HZ) + jiffies;
+
+    	sp->ext_history= 0; 
+	sp->e_start = jiffies;
+	if (cmd->eh_timeout.function) {
+		mod_timer(&cmd->eh_timeout,our_jiffies);
+		sp->ext_history |= 1;
+	}
+	if (sp->timer.function != NULL) {
+		/* 
+		 * Our internal timer should timeout before the midlayer has a
+		 * chance begin the abort process
+		 */
+		mod_timer(&sp->timer,our_jiffies - (QLA_CMD_TIMER_DELTA * HZ));
+
+    	 	sp->ext_history |= 2;
+	}
+}
+
+/**************************************************************************
+*   qla2x00_cmd_timeout
+*
+* Description:
+*       Handles the command if it times out in any state.
+*
+* Input:
+*     sp - pointer to validate
+*
+* Returns:
+* None.
+* Note:Need to add the support for if( sp->state == SRB_FAILOVER_STATE).
+**************************************************************************/
+static void
+qla2x00_cmd_timeout(srb_t *sp)
+{
+	int t, l;
+	int processed;
+	scsi_qla_host_t *vis_ha, *dest_ha;
+	struct scsi_cmnd *cmd;
+	ulong      flags;
+#if defined(QL_DEBUG_LEVEL_3)
+	ulong      cpu_flags;
+#endif
+	fc_port_t	*fcport;
+
+	cmd = sp->cmd;
+	vis_ha = (scsi_qla_host_t *)cmd->device->host->hostdata;
+
+	DEBUG3(printk("cmd_timeout: Entering sp->state = %x\n", sp->state));
+
+	t = cmd->device->id;
+	l = cmd->device->lun;
+	fcport = sp->fclun->fcport;
+	dest_ha = sp->ha;
+
+	/*
+	 * If IO is found either in retry Queue 
+	 *    OR in Lun Queue
+	 * Return this IO back to host
+	 */
+	spin_lock_irqsave(&vis_ha->list_lock, flags);
+	processed = 0;
+	if (sp->state == SRB_PENDING_STATE) {
+		__del_from_pending_queue(vis_ha, sp);
+		DEBUG2(printk("scsi(%ld): Found in Pending queue pid %ld, "
+		    "State = %x., fcport state=%d jiffies=%lx\n",
+		    vis_ha->host_no, cmd->serial_number, sp->state,
+		    atomic_read(&fcport->state), jiffies));
+
+		/*
+		 * If FC_DEVICE is marked as dead return the cmd with
+		 * DID_NO_CONNECT status.  Otherwise set the host_byte to
+		 * DID_BUS_BUSY to let the OS  retry this cmd.
+		 */
+		if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD ||
+		    atomic_read(&vis_ha->loop_state) == LOOP_DEAD) {
+			cmd->result = DID_NO_CONNECT << 16;
+		} else {
+			cmd->result = DID_BUS_BUSY << 16;
+		}
+		__add_to_done_queue(vis_ha, sp);
+		processed++;
+	} 
+	spin_unlock_irqrestore(&vis_ha->list_lock, flags);
+
+	if (processed) {
+		qla2x00_done(vis_ha);
+		return;
+	}
+
+	spin_lock_irqsave(&dest_ha->list_lock, flags);
+	if ((sp->state == SRB_RETRY_STATE) ||
+	    (sp->state == SRB_SCSI_RETRY_STATE)) {
+
+		DEBUG2(printk("scsi(%ld): Found in (Scsi) Retry queue or "
+		    "failover Q pid %ld, State = %x., fcport state=%d "
+		    "jiffies=%lx retried=%d\n",
+		    dest_ha->host_no, cmd->serial_number, sp->state,
+		    atomic_read(&fcport->state), jiffies, cmd->retries));
+
+		if ((sp->state == SRB_RETRY_STATE)) {
+			__del_from_retry_queue(dest_ha, sp);
+		} else if ((sp->state == SRB_SCSI_RETRY_STATE)) {
+			__del_from_scsi_retry_queue(dest_ha, sp);
+		}
+
+		/*
+		 * If FC_DEVICE is marked as dead return the cmd with
+		 * DID_NO_CONNECT status.  Otherwise set the host_byte to
+		 * DID_BUS_BUSY to let the OS  retry this cmd.
+		 */
+
+		if ((atomic_read(&fcport->state) == FCS_DEVICE_DEAD) ||
+		    atomic_read(&dest_ha->loop_state) == LOOP_DEAD) {
+			qla2x00_extend_timeout(cmd, EXTEND_CMD_TIMEOUT);
+			cmd->result = DID_NO_CONNECT << 16;
+		} else {
+			cmd->result = DID_BUS_BUSY << 16;
+		}
+
+		__add_to_done_queue(dest_ha, sp);
+		processed++;
+	} 
+	spin_unlock_irqrestore(&dest_ha->list_lock, flags);
+
+	if (processed) {
+		qla2x00_done(dest_ha);
+
+		 return;
+	}
+/* TODO: Remove this code!!! */
+#if defined(QL_DEBUG_LEVEL_3)
+	spin_lock_irqsave(&dest_ha->list_lock, cpu_flags);
+	if (sp->state == SRB_DONE_STATE) {
+		/* IO in done_q  -- leave it */
+		DEBUG(printk("scsi(%ld): Found in Done queue pid %ld sp=%p.\n",
+		    dest_ha->host_no, cmd->serial_number, sp));
+	} else if (sp->state == SRB_SUSPENDED_STATE) {
+		DEBUG(printk("scsi(%ld): Found SP %p in suspended state  "
+		    "- pid %ld:\n",
+		    dest_ha->host_no, sp, cmd->serial_number));
+		DEBUG(qla2x00_dump_buffer((uint8_t *)sp, sizeof(srb_t));)
+	} else if (sp->state == SRB_ACTIVE_STATE) {
+		/*
+		 * IO is with ISP find the command in our active list.
+		 */
+		spin_unlock_irqrestore(&dest_ha->list_lock, cpu_flags);
+		spin_lock_irqsave(&dest_ha->hardware_lock, flags);
+		if (sp ==
+		    dest_ha->outstanding_cmds[(u_long)sp->cmd->host_scribble]) {
+
+			DEBUG(printk("cmd_timeout: Found in ISP \n");)
+
+			sp->state = SRB_ACTIVE_TIMEOUT_STATE;
+			spin_unlock_irqrestore(&dest_ha->hardware_lock, flags);
+		} else {
+			spin_unlock_irqrestore(&dest_ha->hardware_lock, flags);
+			printk(KERN_INFO 
+				"qla_cmd_timeout: State indicates it is with "
+				"ISP, But not in active array\n");
+		}
+		spin_lock_irqsave(&dest_ha->list_lock, cpu_flags); 	/* 01/03 */
+	} else if (sp->state == SRB_ACTIVE_TIMEOUT_STATE) {
+		DEBUG(printk("qla2100%ld: Found in Active timeout state"
+				"pid %ld, State = %x., \n",
+				dest_ha->host_no,
+				sp->cmd->serial_number, sp->state);)
+	} else {
+		/* EMPTY */
+		DEBUG2(printk("cmd_timeout%ld: LOST command state = "
+				"0x%x, sp=%p\n",
+				vis_ha->host_no, sp->state,sp);)
+
+		qla_printk(KERN_INFO, vis_ha,
+			"cmd_timeout: LOST command state = 0x%x\n", sp->state);
+	}
+	spin_unlock_irqrestore(&dest_ha->list_lock, cpu_flags);
+#endif
+	
+	DEBUG3(printk("cmd_timeout: Leaving\n");)
+}
+
+/**************************************************************************
+* qla2x00_done
+*      Process completed commands.
+*
+* Input:
+*      old_ha           = adapter block pointer.
+*
+**************************************************************************/
+void
+qla2x00_done(scsi_qla_host_t *old_ha)
+{
+	os_lun_t	*lq;
+	struct scsi_cmnd *cmd;
+	unsigned long	flags = 0;
+	scsi_qla_host_t	*ha;
+	scsi_qla_host_t	*vis_ha;
+	int	send_marker_once = 0;
+	srb_t           *sp, *sptemp;
+	LIST_HEAD(local_sp_list);
+
+	/*
+	 * Get into local queue such that we do not wind up calling done queue
+	 * tasklet for the same IOs from DPC or any other place.
+	 */
+	spin_lock_irqsave(&old_ha->list_lock, flags);
+	list_splice_init(&old_ha->done_queue, &local_sp_list);
+	spin_unlock_irqrestore(&old_ha->list_lock, flags);
+
+	/*
+	 * All done commands are in the local queue, now do the call back.
+	 */
+	list_for_each_entry_safe(sp, sptemp, &local_sp_list, list) {
+		old_ha->done_q_cnt--;
+        	sp->state = SRB_NO_QUEUE_STATE;
+
+		/* remove command from local list */
+		list_del_init(&sp->list);
+
+		cmd = sp->cmd;
+		if (cmd == NULL)
+		 	continue;
+
+		vis_ha = (scsi_qla_host_t *)cmd->device->host->hostdata;
+		lq = sp->lun_queue;
+		ha = sp->ha;
+
+		if (sp->flags & SRB_DMA_VALID) {
+			sp->flags &= ~SRB_DMA_VALID;
+
+			/* Release memory used for this I/O */
+			if (cmd->use_sg) {
+				pci_unmap_sg(ha->pdev, cmd->request_buffer,
+				    cmd->use_sg, cmd->sc_data_direction);
+			} else if (cmd->request_bufflen) {
+				pci_unmap_page(ha->pdev, sp->dma_handle,
+				    cmd->request_bufflen,
+				    cmd->sc_data_direction);
+			}
+		}
+
+		switch (host_byte(cmd->result)) {
+			case DID_OK:
+			case DID_ERROR:
+				break;
+
+			case DID_RESET:
+				/*
+				 * Set marker needed, so we don't have to
+				 * send multiple markers
+				 */
+				if (!send_marker_once) {
+					ha->marker_needed = 1;
+					send_marker_once++;
+				}
+
+				/*
+				 * WORKAROUND
+				 *
+				 * A backdoor device-reset requires different
+				 * error handling.  This code differentiates
+				 * between normal error handling and the
+				 * backdoor method.
+				 *
+				 */
+				if (ha->host->eh_active != EH_ACTIVE)
+					cmd->result = DID_BUS_BUSY << 16;
+				break;
+
+
+			case DID_ABORT:
+				sp->flags &= ~SRB_ABORT_PENDING;
+				sp->flags |= SRB_ABORTED;
+
+				if (sp->flags & SRB_TIMEOUT)
+					cmd->result = DID_TIME_OUT << 16;
+
+				break;
+
+			default:
+				DEBUG2(printk("scsi(%ld:%d:%d) %s: did_error "
+				    "= %d, comp-scsi= 0x%x-0x%x.\n",
+				    vis_ha->host_no,
+				    cmd->device->id, cmd->device->lun,
+				    __func__,
+				    host_byte(cmd->result),
+				    CMD_COMPL_STATUS(cmd),
+				    CMD_SCSI_STATUS(cmd)));
+				break;
+		}
+
+		/*
+		 * Call the mid-level driver interrupt handler -- via sp_put()
+		 */
+		sp_put(ha, sp);
+	} /* end of while */
+}
+
+/*
+ * qla2x00_process_response_queue_in_zio_mode
+ *	Process response queue completion as fast as possible
+ *	to achieve Zero Interrupt Opertions-ZIO
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *
+ * Context:
+ *	Kernel context.
+ */
+static inline void
+qla2x00_process_response_queue_in_zio_mode(scsi_qla_host_t *ha)
+{
+	unsigned long flags;
+
+	/* Check for unprocessed commands in response queue. */
+	if (!ha->flags.process_response_queue)
+		return;
+	if (!ha->flags.online)
+		return;
+	if (ha->response_ring_ptr->signature == RESPONSE_PROCESSED)
+		return;
+	
+	spin_lock_irqsave(&ha->hardware_lock,flags);
+	qla2x00_process_response_queue(ha);
+	spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+	if (!list_empty(&ha->done_queue))
+		qla2x00_done(ha);
+}
+
+/*
+ * qla2x00_next
+ *	Retrieve and process next job in the LUN queue.
+ *
+ * Input:
+ *	tq = SCSI target queue pointer.
+ *	lq = SCSI LUN queue pointer.
+ *	TGT_LOCK must be already obtained.
+ *
+ * Output:
+ *	Releases TGT_LOCK upon exit.
+ *
+ * Context:
+ *	Kernel/Interrupt context.
+ * 
+ * Note: This routine will always try to start I/O from visible HBA.
+ */
+void
+qla2x00_next(scsi_qla_host_t *vis_ha) 
+{
+	int		rval;
+	unsigned long   flags;
+	scsi_qla_host_t *dest_ha;
+	fc_port_t	*fcport;
+	srb_t           *sp, *sptemp;
+	LIST_HEAD(local_sp_list);
+
+	dest_ha = NULL;
+
+	spin_lock_irqsave(&vis_ha->list_lock, flags);
+	list_splice_init(&vis_ha->pending_queue, &local_sp_list);
+	vis_ha->qthreads = 0;
+	spin_unlock_irqrestore(&vis_ha->list_lock, flags);
+
+	list_for_each_entry_safe(sp, sptemp, &local_sp_list, list) {
+		list_del_init(&sp->list);
+        	sp->state = SRB_NO_QUEUE_STATE;
+
+		fcport = sp->fclun->fcport;
+		dest_ha = fcport->ha;
+
+		/* If device is dead then send request back to OS */
+		if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) {
+
+			sp->cmd->result = DID_NO_CONNECT << 16;
+
+			if (!atomic_read(&dest_ha->loop_down_timer) &&
+			    atomic_read(&dest_ha->loop_state) == LOOP_DOWN) {
+				sp->err_id = 2;
+			} else {
+				sp->err_id = 1;
+			}
+			DEBUG3(printk("scsi(%ld): loop/port is down - "
+			    "pid=%ld, sp=%p loopid=0x%x queued to dest HBA "
+			    "scsi%ld.\n",
+			    dest_ha->host_no,
+			    sp->cmd->serial_number, sp,
+			    fcport->loop_id, dest_ha->host_no));
+			/* 
+			 * Initiate a failover - done routine will initiate.
+			 */
+			add_to_done_queue(vis_ha, sp);
+
+			continue;
+		}
+
+		/*
+		 * SCSI Kluge: Whenever, we need to wait for an event such as
+		 * loop down (i.e. loop_down_timer ) or port down (i.e.  LUN
+		 * request qeueue is suspended) then we will recycle new
+		 * commands back to the SCSI layer.  We do this because this is
+		 * normally a temporary condition and we don't want the
+		 * mid-level scsi.c driver to get upset and start aborting
+		 * commands.  The timeout value is extracted from the command
+		 * minus 1-second and put on a retry queue (watchdog). Once the
+		 * command timeout it is returned to the mid-level with a BUSY
+		 * status, so the mid-level will retry it. This process
+		 * continues until the LOOP DOWN time expires or the condition
+		 * goes away.
+		 */
+	 	if (!(sp->flags & SRB_IOCTL) &&
+		    (atomic_read(&fcport->state) != FCS_ONLINE ||
+			test_bit(ABORT_ISP_ACTIVE, &dest_ha->dpc_flags) ||
+			atomic_read(&dest_ha->loop_state) != LOOP_READY)) {
+
+			DEBUG3(printk("scsi(%ld): port=(0x%x) retry_q(%d) "
+			    "loop state = %d, loop counter = 0x%x dpc flags "
+			    "= 0x%lx\n",
+			    dest_ha->host_no,
+			    fcport->loop_id,
+			    atomic_read(&fcport->state),
+			    atomic_read(&dest_ha->loop_state),
+			    atomic_read(&dest_ha->loop_down_timer),
+			    dest_ha->dpc_flags));
+
+			qla2x00_extend_timeout(sp->cmd, EXTEND_CMD_TIMEOUT);
+			add_to_retry_queue(vis_ha, sp);
+
+			continue;
+		} 
+
+		/*
+		 * If this request's lun is suspended then put the request on
+		 * the  scsi_retry queue. 
+		 */
+	 	if (!(sp->flags & SRB_IOCTL) &&
+		    sp->lun_queue->q_state == LUN_STATE_WAIT) {
+			DEBUG3(printk("scsi(%ld): lun wait state - pid=%ld, "
+			    "opcode=%d, allowed=%d, retries=%d\n",
+			    dest_ha->host_no,
+			    sp->cmd->serial_number,
+			    sp->cmd->cmnd[0],
+			    sp->cmd->allowed,
+			    sp->cmd->retries));
+				
+			add_to_scsi_retry_queue(vis_ha, sp);
+
+			continue;
+		}
+
+		sp->lun_queue->io_cnt++;
+
+		rval = qla2x00_start_scsi(sp);
+		if (rval != QLA_SUCCESS) {
+			/* Place request back on top of device queue */
+			/* add to the top of queue */
+			add_to_pending_queue_head(vis_ha, sp);
+
+			sp->lun_queue->io_cnt--;
+		}
+	}
+
+	if (IS_QLA23XX(vis_ha)) {
+		/* Process response_queue if ZIO support is enabled*/ 
+		qla2x00_process_response_queue_in_zio_mode(vis_ha);
+
+	}
+}
+
+
+/*
+ * qla2x00_reset_lun_fo_counts
+ *	Reset failover retry counts
+ *
+ * Input:
+ *	ha = adapter block pointer.
+ *
+ * Context:
+ *	Interrupt context.
+ */
+void 
+qla2x00_reset_lun_fo_counts(scsi_qla_host_t *ha, os_lun_t *lq) 
+{
+	srb_t		*tsp;
+	os_lun_t	*orig_lq;
+	struct list_head *list;
+	unsigned long	flags ;
+
+	spin_lock_irqsave(&ha->list_lock, flags);
+	/*
+	 * the pending queue.
+	 */
+	list_for_each(list,&ha->pending_queue) {
+		tsp = list_entry(list, srb_t, list);
+		orig_lq = tsp->lun_queue;
+		if (orig_lq == lq)
+			tsp->fo_retry_cnt = 0;
+	}
+	/*
+	 * the retry queue.
+	 */
+	list_for_each(list,&ha->retry_queue) {
+		tsp = list_entry(list, srb_t, list);
+		orig_lq = tsp->lun_queue;
+		if (orig_lq == lq)
+			tsp->fo_retry_cnt = 0;
+	}
+
+	/*
+	 * the done queue.
+	 */
+	list_for_each(list, &ha->done_queue) {
+		tsp = list_entry(list, srb_t, list);
+		orig_lq = tsp->lun_queue;
+		if (orig_lq == lq)
+			tsp->fo_retry_cnt = 0;
+	}
+	spin_unlock_irqrestore(&ha->list_lock, flags);
+}
+
+/**************************************************************************
+*   qla2x00_check_tgt_status
+*
+* Description:
+*     Checks to see if the target or loop is down.
+*
+* Input:
+*     cmd - pointer to Scsi cmd structure
+*
+* Returns:
+*   1 - if target is present
+*   0 - if target is not present
+*
+**************************************************************************/
+int
+qla2x00_check_tgt_status(scsi_qla_host_t *ha, struct scsi_cmnd *cmd)
+{
+	os_lun_t        *lq;
+	unsigned int	b, t, l;
+	fc_port_t	*fcport;
+
+	/* Generate LU queue on bus, target, LUN */
+	b = cmd->device->channel;
+	t = cmd->device->id;
+	l = cmd->device->lun;
+
+	if ((lq = GET_LU_Q(ha,t,l)) == NULL) {
+		return (QLA_FUNCTION_FAILED);
+	}
+
+	fcport = lq->fclun->fcport;
+
+	if (TGT_Q(ha, t) == NULL ||
+	    l >= ha->max_luns ||
+	    atomic_read(&fcport->state) == FCS_DEVICE_DEAD ||
+	    atomic_read(&ha->loop_state) == LOOP_DEAD ||
+	    (!atomic_read(&ha->loop_down_timer) &&
+		atomic_read(&ha->loop_state) == LOOP_DOWN) ||
+	    test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags) ||
+	    test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) ||
+	    atomic_read(&ha->loop_state) != LOOP_READY) {
+
+		DEBUG(printk(KERN_INFO
+		    "scsi(%ld:%2d:%2d:%2d): %s connection is down\n",
+		    ha->host_no,
+		    b, t, l,
+		    __func__));
+
+		cmd->result = DID_NO_CONNECT << 16;
+		return (QLA_FUNCTION_FAILED);
+	}
+	return (QLA_SUCCESS);
+}
+
+/**************************************************************************
+*   qla2x00_check_port_status
+*
+* Description:
+*     Checks to see if the port or loop is down.
+*
+* Input:
+*     fcport - pointer to fc_port_t structure.
+*
+* Returns:
+*   1 - if port is present
+*   0 - if port is not present
+*
+**************************************************************************/
+int
+qla2x00_check_port_status(scsi_qla_host_t *ha, fc_port_t *fcport)
+{
+	if (fcport == NULL) {
+		return (QLA_FUNCTION_FAILED);
+	}
+
+	if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD ||
+	    atomic_read(&ha->loop_state) == LOOP_DEAD) {
+		return (QLA_FUNCTION_FAILED);
+	}
+
+	if ((atomic_read(&fcport->state) != FCS_ONLINE) || 
+	    (!atomic_read(&ha->loop_down_timer) &&
+		atomic_read(&ha->loop_state) == LOOP_DOWN) ||
+	    (test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags)) ||
+	    test_bit(CFG_ACTIVE, &ha->cfg_flags) ||
+	    test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) ||
+	    atomic_read(&ha->loop_state) != LOOP_READY) {
+
+		DEBUG(printk(KERN_INFO
+		    "scsi(%ld): Connection is down. fcport=%p.\n",
+		    ha->host_no, fcport));
+
+		return (QLA_BUSY);
+	}
+
+	return (QLA_SUCCESS);
+}
+
+/**
+ * qla2x00_module_init - Module initialization.
+ **/
+static int __init
+qla2x00_module_init(void)
+{
+	/* Derive version string. */
+	strcpy(qla2x00_version_str, QLA2XXX_VERSION);
+#if DEBUG_QLA2100
+	strcat(qla2x00_version_str, "-debug");
+#endif
+	/* Allocate cache for SRBs. */
+	sprintf(srb_cachep_name, "qla2xxx_srbs");
+	srb_cachep = kmem_cache_create(srb_cachep_name, sizeof(srb_t), 0,
+	    SLAB_HWCACHE_ALIGN, NULL, NULL);
+	if (srb_cachep == NULL) {
+		printk(KERN_ERR
+		    "qla2xxx: Unable to allocate SRB cache...Failing load!\n");
+		return -ENOMEM;
+	}
+
+	printk(KERN_INFO
+	    "QLogic ISP2xxx PCI/PCI-X Fibre Channel HBA Driver (%p)\n",
+	    qla2x00_set_info);
+
+	return 0;
+}
+
+/**
+ * qla2x00_module_exit - Module cleanup.
+ **/
+static void __exit
+qla2x00_module_exit(void)
+{
+	/* Free SRBs cache. */
+	if (srb_cachep != NULL) {
+		if (kmem_cache_destroy(srb_cachep) != 0) {
+			printk(KERN_ERR
+			    "qla2xxx: Unable to free SRB cache...Memory pools "
+			    "still active?\n");
+		}
+		srb_cachep = NULL;
+	}
+}
+
+module_init(qla2x00_module_init);
+module_exit(qla2x00_module_exit);
+
+MODULE_AUTHOR("QLogic Corporation");
+MODULE_DESCRIPTION("QLogic ISP2xxx FC-SCSI Host Bus Adapter driver");
+MODULE_LICENSE("GPL");
diff -puN /dev/null drivers/scsi/qla2xxx/qla_os.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/qla_os.h	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,93 @@
+/******************************************************************************
+ *                  QLOGIC LINUX SOFTWARE
+ *
+ * QLogic ISP2x00 device driver for Linux 2.6.x
+ * Copyright (C) 2003 QLogic Corporation
+ * (www.qlogic.com)
+ *
+ * Portions (C) Arjan van de Ven <arjanv@redhat.com> for Red Hat, 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, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ ******************************************************************************/
+
+#ifndef __QLA_OS_H
+#define __QLA_OS_H
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/init.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include <linux/timer.h>
+#include <linux/sched.h>
+#include <linux/pci.h>
+#include <linux/proc_fs.h>
+#include <linux/blkdev.h>
+#include <linux/interrupt.h>
+#include <linux/stat.h>
+#include <linux/slab.h>
+#include <linux/mempool.h>
+#include <linux/vmalloc.h>
+#define __KERNEL_SYSCALLS__
+#include <linux/unistd.h>
+#include <linux/smp_lock.h>
+#include <linux/bio.h>
+#include <linux/moduleparam.h>
+#include <linux/capability.h>
+
+#include <asm/system.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/segment.h>
+#include <asm/byteorder.h>
+#include <asm/pgtable.h>
+
+#include <linux/ioctl.h>
+#include <asm/uaccess.h>
+
+#include "scsi.h"
+#include "hosts.h"
+
+#include <scsi/scsicam.h>
+#include <scsi/scsi_ioctl.h>
+
+//TODO Fix this!!!
+/*
+* String arrays
+*/
+#define LINESIZE    256
+#define MAXARGS      26
+
+/***********************************************************************
+* We use the struct scsi_pointer structure that's included with each 
+* command SCSI_Cmnd as a scratchpad. 
+*
+* SCp is defined as follows:
+*  - SCp.ptr  -- > pointer to the SRB
+*  - SCp.this_residual  -- > HBA completion status for ioctl code. 
+*
+* Cmnd->host_scribble --> Used to hold the hba actived handle (1..255).
+***********************************************************************/
+#define	CMD_SP(Cmnd)		((Cmnd)->SCp.ptr)
+#define CMD_COMPL_STATUS(Cmnd)  ((Cmnd)->SCp.this_residual)
+/* Additional fields used by ioctl passthru */
+#define CMD_RESID_LEN(Cmnd)	((Cmnd)->SCp.buffers_residual)
+#define CMD_SCSI_STATUS(Cmnd)	((Cmnd)->SCp.Status)
+#define CMD_ACTUAL_SNSLEN(Cmnd)	((Cmnd)->SCp.Message)
+#define CMD_ENTRY_STATUS(Cmnd)	((Cmnd)->SCp.have_data_in)
+
+#endif
diff -puN /dev/null drivers/scsi/qla2xxx/qla_rscn.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/qla_rscn.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,1458 @@
+/*
+ *                  QLOGIC LINUX SOFTWARE
+ *
+ * QLogic ISP2x00 device driver for Linux 2.6.x
+ * Copyright (C) 2003 QLogic Corporation
+ * (www.qlogic.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+#include "qla_os.h"
+
+#include "qla_def.h"
+
+/**
+ * IO descriptor handle definitions.
+ *
+ * Signature form:
+ *
+ *	|31------28|27-------------------12|11-------0|
+ *	|   Type   |   Rolling Signature   |   Index  |
+ *	|----------|-----------------------|----------|
+ *
+ **/
+
+#define HDL_TYPE_SCSI		0
+#define HDL_TYPE_ASYNC_IOCB	0x0A
+
+#define HDL_INDEX_BITS	12
+#define HDL_ITER_BITS	16
+#define HDL_TYPE_BITS	4
+
+#define HDL_INDEX_MASK	((1UL << HDL_INDEX_BITS) - 1)
+#define HDL_ITER_MASK	((1UL << HDL_ITER_BITS) - 1)
+#define HDL_TYPE_MASK	((1UL << HDL_TYPE_BITS) - 1)
+
+#define HDL_INDEX_SHIFT	0
+#define HDL_ITER_SHIFT	(HDL_INDEX_SHIFT + HDL_INDEX_BITS)
+#define HDL_TYPE_SHIFT	(HDL_ITER_SHIFT + HDL_ITER_BITS)
+
+/* Local Prototypes. */
+static inline uint32_t qla2x00_to_handle(uint16_t, uint16_t, uint16_t);
+static inline uint16_t qla2x00_handle_to_idx(uint32_t);
+static inline uint16_t qla2x00_handle_to_iter(uint32_t);
+static inline uint16_t qla2x00_handle_to_type(uint32_t);
+static inline uint32_t qla2x00_iodesc_to_handle(struct io_descriptor *);
+static inline struct io_descriptor *qla2x00_handle_to_iodesc(scsi_qla_host_t *,
+    uint32_t);
+
+static inline struct io_descriptor *qla2x00_alloc_iodesc(scsi_qla_host_t *);
+static inline void qla2x00_free_iodesc(struct io_descriptor *);
+static inline void qla2x00_init_io_descriptors(scsi_qla_host_t *);
+
+static void qla2x00_iodesc_timeout(unsigned long);
+static inline void qla2x00_add_iodesc_timer(struct io_descriptor *);
+static inline void qla2x00_remove_iodesc_timer(struct io_descriptor *);
+
+static inline void qla2x00_update_login_fcport(scsi_qla_host_t *,
+    struct mbx_entry *, fc_port_t *);
+
+static int qla2x00_send_abort_iocb(scsi_qla_host_t *, struct io_descriptor *,
+    uint32_t, int);
+static int qla2x00_send_abort_iocb_cb(scsi_qla_host_t *, struct io_descriptor *,
+    struct mbx_entry *);
+
+static int qla2x00_send_adisc_iocb(scsi_qla_host_t *, struct io_descriptor *,
+    int);
+static int qla2x00_send_adisc_iocb_cb(scsi_qla_host_t *, struct io_descriptor *,
+    struct mbx_entry *);
+
+static int qla2x00_send_logout_iocb(scsi_qla_host_t *, struct io_descriptor *,
+    int);
+static int qla2x00_send_logout_iocb_cb(scsi_qla_host_t *,
+    struct io_descriptor *, struct mbx_entry *);
+
+static int qla2x00_send_login_iocb(scsi_qla_host_t *, struct io_descriptor *,
+    port_id_t *, int);
+static int qla2x00_send_login_iocb_cb(scsi_qla_host_t *, struct io_descriptor *,
+    struct mbx_entry *);
+
+/** 
+ * Mailbox IOCB callback array.
+ **/
+int (*iocb_function_cb_list[LAST_IOCB_CB])
+	(scsi_qla_host_t *, struct io_descriptor *, struct mbx_entry *) = {
+
+	qla2x00_send_abort_iocb_cb,
+	qla2x00_send_adisc_iocb_cb,
+	qla2x00_send_logout_iocb_cb,
+	qla2x00_send_login_iocb_cb,
+};
+
+
+/** 
+ * Generic IO descriptor handle routines.
+ **/
+
+/**
+ * qla2x00_to_handle() - Create a descriptor handle.
+ * @type: descriptor type
+ * @iter: descriptor rolling signature
+ * @idx: index to the descriptor array
+ *
+ * Returns a composite handle based in the @type, @iter, and @idx.
+ */
+static inline uint32_t
+qla2x00_to_handle(uint16_t type, uint16_t iter, uint16_t idx)
+{
+	return ((uint32_t)(((uint32_t)type << HDL_TYPE_SHIFT) |
+	    ((uint32_t)iter << HDL_ITER_SHIFT) |
+	    ((uint32_t)idx << HDL_INDEX_SHIFT)));
+}
+
+/**
+ * qla2x00_handle_to_idx() - Retrive the index for a given handle.
+ * @handle: descriptor handle
+ *
+ * Returns the index specified by the @handle.
+ */
+static inline uint16_t
+qla2x00_handle_to_idx(uint32_t handle)
+{
+	return ((uint16_t)(((handle) >> HDL_INDEX_SHIFT) & HDL_INDEX_MASK));
+}
+
+/**
+ * qla2x00_handle_to_type() - Retrive the descriptor type for a given handle.
+ * @handle: descriptor handle
+ *
+ * Returns the descriptor type specified by the @handle.
+ */
+static inline uint16_t
+qla2x00_handle_to_type(uint32_t handle)
+{
+	return ((uint16_t)(((handle) >> HDL_TYPE_SHIFT) & HDL_TYPE_MASK));
+}
+
+/**
+ * qla2x00_handle_to_iter() - Retrive the rolling signature for a given handle.
+ * @handle: descriptor handle
+ *
+ * Returns the signature specified by the @handle.
+ */
+static inline uint16_t
+qla2x00_handle_to_iter(uint32_t handle)
+{
+	return ((uint16_t)(((handle) >> HDL_ITER_SHIFT) & HDL_ITER_MASK));
+}
+
+/**
+ * qla2x00_iodesc_to_handle() - Convert an IO descriptor to a unique handle.
+ * @iodesc: io descriptor
+ *
+ * Returns a unique handle for @iodesc.
+ */
+static inline uint32_t
+qla2x00_iodesc_to_handle(struct io_descriptor *iodesc)
+{
+	uint32_t handle;
+
+	handle = qla2x00_to_handle(HDL_TYPE_ASYNC_IOCB,
+	    ++iodesc->ha->iodesc_signature, iodesc->idx);
+	iodesc->signature = handle;
+
+	return (handle);
+}
+
+/**
+ * qla2x00_handle_to_iodesc() - Retrieve an IO descriptor given a unique handle.
+ * @ha: HA context
+ * @handle: handle to io descriptor
+ *
+ * Returns a pointer to the io descriptor, or NULL, if the io descriptor does
+ * not exist or the io descriptors signature does not @handle.
+ */
+static inline struct io_descriptor *
+qla2x00_handle_to_iodesc(scsi_qla_host_t *ha, uint32_t handle)
+{
+	uint16_t idx;
+	struct io_descriptor *iodesc;
+
+	idx = qla2x00_handle_to_idx(handle);
+	iodesc = &ha->io_descriptors[idx];
+	if (iodesc)
+		if (iodesc->signature != handle)
+			iodesc = NULL;
+
+	return (iodesc);
+}
+
+
+/** 
+ * IO descriptor allocation routines.
+ **/
+
+/**
+ * qla2x00_alloc_iodesc() - Allocate an IO descriptor from the pool.
+ * @ha: HA context
+ *
+ * Returns a pointer to the allocated io descriptor, or NULL, if none available.
+ */
+static inline struct io_descriptor *
+qla2x00_alloc_iodesc(scsi_qla_host_t *ha)
+{
+	uint16_t iter;
+	struct io_descriptor *iodesc;
+
+	iodesc = NULL;
+	for (iter = 0; iter < MAX_IO_DESCRIPTORS; iter++) {
+		if (ha->io_descriptors[iter].used)
+			continue;
+
+		iodesc = &ha->io_descriptors[iter];
+		iodesc->used = 1;
+		iodesc->idx = iter;
+		init_timer(&iodesc->timer);
+		iodesc->ha = ha;
+		iodesc->signature = qla2x00_iodesc_to_handle(iodesc);
+		break;
+	}
+
+	return (iodesc);
+}
+
+/**
+ * qla2x00_free_iodesc() - Free an IO descriptor.
+ * @iodesc: io descriptor
+ *
+ * NOTE: The io descriptors timer *must* be stopped before it can be free'd.
+ */
+static inline void
+qla2x00_free_iodesc(struct io_descriptor *iodesc)
+{
+	iodesc->used = 0;
+	iodesc->signature = 0;
+}
+
+/**
+ * qla2x00_init_io_descriptors() - Initialize the pool of IO descriptors.
+ * @ha: HA context
+ */
+static inline void
+qla2x00_init_io_descriptors(scsi_qla_host_t *ha)
+{
+	uint16_t iter;
+
+	for (iter = 0; iter < MAX_IO_DESCRIPTORS; iter++) {
+		if (!ha->io_descriptors[iter].used)
+			continue;
+
+		qla2x00_remove_iodesc_timer(&ha->io_descriptors[iter]);
+		qla2x00_free_iodesc(&ha->io_descriptors[iter]);
+	}
+}
+
+
+/** 
+ * IO descriptor timer routines.
+ **/
+
+/**
+ * qla2x00_iodesc_timeout() - Timeout IO descriptor handler.
+ * @data: io descriptor
+ */
+static void
+qla2x00_iodesc_timeout(unsigned long data)
+{
+	struct io_descriptor *iodesc;
+
+	iodesc = (struct io_descriptor *) data;
+
+	DEBUG14(printk("scsi(%ld): IO descriptor timeout, index=%x "
+	    "signature=%08x, scheduling ISP abort.\n", iodesc->ha->host_no,
+	    iodesc->idx, iodesc->signature));
+
+	qla2x00_free_iodesc(iodesc);
+
+	set_bit(ISP_ABORT_NEEDED, &iodesc->ha->dpc_flags);
+}
+
+/**
+ * qla2x00_add_iodesc_timer() - Add and start a timer for an IO descriptor.
+ * @iodesc: io descriptor
+ *
+ * NOTE:
+ * The firmware shall timeout an outstanding mailbox IOCB in 2 * R_A_TOV (in
+ * tenths of a second).  The driver will wait 2.5 * R_A_TOV before scheduling
+ * a recovery (big hammer).
+ */
+static inline void
+qla2x00_add_iodesc_timer(struct io_descriptor *iodesc)
+{
+	unsigned long timeout;
+
+	timeout = ((iodesc->ha->r_a_tov * 2) + (iodesc->ha->r_a_tov / 2)) / 10;
+	init_timer(&iodesc->timer);
+	iodesc->timer.data = (unsigned long) iodesc;
+	iodesc->timer.expires = jiffies + (timeout * HZ);
+	iodesc->timer.function =
+	    (void (*) (unsigned long)) qla2x00_iodesc_timeout;
+	add_timer(&iodesc->timer);
+}
+
+/**
+ * qla2x00_remove_iodesc_timer() - Remove an active timer from an IO descriptor.
+ * @iodesc: io descriptor
+ */
+static inline void
+qla2x00_remove_iodesc_timer(struct io_descriptor *iodesc)
+{
+	if (iodesc->timer.function != NULL) {
+		del_timer_sync(&iodesc->timer);
+		iodesc->timer.data = (unsigned long) NULL;
+		iodesc->timer.function = NULL;
+	}
+}
+
+/** 
+ * IO descriptor support routines.
+ **/
+
+/**
+ * qla2x00_update_login_fcport() - Update fcport data after login processing.
+ * @ha: HA context
+ * @mbxstat: Mailbox command status IOCB
+ * @fcport: port to update
+ */
+static inline void
+qla2x00_update_login_fcport(scsi_qla_host_t *ha, struct mbx_entry *mbxstat,
+    fc_port_t *fcport)
+{
+	if (le16_to_cpu(mbxstat->mb1) & BIT_0) {
+		fcport->port_type = FCT_INITIATOR;
+	} else {
+		fcport->port_type = FCT_TARGET;
+		if (le16_to_cpu(mbxstat->mb1) & BIT_1) {
+			fcport->flags |= FCF_TAPE_PRESENT;
+		}
+	}
+	fcport->login_retry = 0;
+	fcport->port_login_retry_count = ha->port_down_retry_count *
+	    PORT_RETRY_TIME;
+	atomic_set(&fcport->port_down_timer, ha->port_down_retry_count *
+	    PORT_RETRY_TIME);
+	fcport->flags |= FCF_FABRIC_DEVICE;
+	fcport->flags &= ~FCF_FAILOVER_NEEDED;
+	fcport->iodesc_idx_sent = IODESC_INVALID_INDEX;
+	atomic_set(&fcport->state, FCS_ONLINE);
+}
+
+
+/** 
+ * Mailbox IOCB commands.
+ **/
+
+/**
+ * qla2x00_get_mbx_iocb_entry() - Retrieve an IOCB from the request queue.
+ * @ha: HA context
+ * @handle: handle to io descriptor
+ *
+ * Returns a pointer to the reqest entry, or NULL, if none were available.
+ */
+static inline struct mbx_entry *
+qla2x00_get_mbx_iocb_entry(scsi_qla_host_t *ha, uint32_t handle)
+{
+	uint16_t cnt;
+	device_reg_t *reg;
+	struct mbx_entry *mbxentry;
+
+	reg = ha->iobase;
+	mbxentry = NULL;
+
+	if (ha->req_q_cnt < 3) {
+		cnt = qla2x00_debounce_register(ISP_REQ_Q_OUT(ha, reg));
+		if  (ha->req_ring_index < cnt)
+			ha->req_q_cnt = cnt - ha->req_ring_index;
+		else
+			ha->req_q_cnt = REQUEST_ENTRY_CNT -
+			    (ha->req_ring_index - cnt);
+	}
+	if (ha->req_q_cnt >= 3) {
+		mbxentry = (struct mbx_entry *)ha->request_ring_ptr;
+
+		memset(mbxentry, 0, sizeof(struct mbx_entry));
+		mbxentry->entry_type = MBX_IOCB_TYPE;
+		mbxentry->entry_count = 1;
+		mbxentry->sys_define1 = SOURCE_ASYNC_IOCB;
+		mbxentry->handle = handle;
+	}
+	return (mbxentry);
+}
+
+/**
+ * qla2x00_send_abort_iocb() - Issue an abort IOCB to the firmware.
+ * @ha: HA context
+ * @iodesc: io descriptor
+ * @handle_to_abort: firmware handle to abort
+ * @ha_locked: is function called with the hardware lock
+ *
+ * Returns QLA_SUCCESS if the IOCB was issued.
+ */
+static int
+qla2x00_send_abort_iocb(scsi_qla_host_t *ha, struct io_descriptor *iodesc, 
+    uint32_t handle_to_abort, int ha_locked)
+{
+	unsigned long flags = 0;
+	struct mbx_entry *mbxentry;
+
+	/* Send marker if required. */
+	if (qla2x00_issue_marker(ha, ha_locked) != QLA_SUCCESS)
+		return (QLA_FUNCTION_FAILED);
+
+	if (!ha_locked)
+		spin_lock_irqsave(&ha->hardware_lock, flags);
+
+	/* Build abort mailbox IOCB. */
+	mbxentry = qla2x00_get_mbx_iocb_entry(ha, iodesc->signature);
+	if (mbxentry == NULL) {
+		if (!ha_locked)
+			spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+		return (QLA_FUNCTION_FAILED);
+	}
+	mbxentry->mb0 = __constant_cpu_to_le16(MBC_ABORT_COMMAND);
+	mbxentry->mb1 = mbxentry->loop_id.extended =
+	    cpu_to_le16(iodesc->remote_fcport->loop_id);
+	mbxentry->mb2 = LSW(handle_to_abort);
+	mbxentry->mb3 = MSW(handle_to_abort);
+
+	qla2x00_add_iodesc_timer(iodesc);
+
+	/* Issue command to ISP. */
+	qla2x00_isp_cmd(ha);
+
+	if (!ha_locked)
+		spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+	DEBUG14(printk("scsi(%ld): Sending Abort IOCB (%08x) to [%x], aborting "
+	    "%08x.\n", ha->host_no, iodesc->signature,
+	    iodesc->remote_fcport->loop_id, handle_to_abort));
+
+	return (QLA_SUCCESS);
+}
+
+/**
+ * qla2x00_send_abort_iocb_cb() - Abort IOCB callback.
+ * @ha: HA context
+ * @iodesc: io descriptor
+ * @mbxstat: mailbox status IOCB
+ *
+ * Returns QLA_SUCCESS if @iodesc can be freed by the caller, else, @iodesc
+ * will be used for a retry.
+ */
+static int
+qla2x00_send_abort_iocb_cb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
+    struct mbx_entry *mbxstat)
+{
+	DEBUG14(printk("scsi(%ld): Abort IOCB -- sent to [%x/%02x%02x%02x], "
+	    "status=%x mb0=%x.\n", ha->host_no, iodesc->remote_fcport->loop_id,
+	    iodesc->d_id.b.domain, iodesc->d_id.b.area, iodesc->d_id.b.al_pa,
+	    le16_to_cpu(mbxstat->status), le16_to_cpu(mbxstat->mb0)));
+
+	return (QLA_SUCCESS);
+}
+
+
+/**
+ * qla2x00_send_adisc_iocb() - Issue a Get Port Database IOCB to the firmware.
+ * @ha: HA context
+ * @iodesc: io descriptor
+ * @ha_locked: is function called with the hardware lock
+ *
+ * Returns QLA_SUCCESS if the IOCB was issued.
+ */
+static int
+qla2x00_send_adisc_iocb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
+    int ha_locked)
+{
+	unsigned long flags = 0;
+	struct mbx_entry *mbxentry;
+
+	/* Send marker if required. */
+	if (qla2x00_issue_marker(ha, ha_locked) != QLA_SUCCESS)
+		return (QLA_FUNCTION_FAILED);
+
+	if (!ha_locked)
+		spin_lock_irqsave(&ha->hardware_lock, flags);
+
+	/* Build Get Port Database IOCB. */
+	mbxentry = qla2x00_get_mbx_iocb_entry(ha, iodesc->signature);
+	if (mbxentry == NULL) {
+		if (!ha_locked)
+			spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+		return (QLA_FUNCTION_FAILED);
+	}
+	mbxentry->mb0 = __constant_cpu_to_le16(MBC_GET_PORT_DATABASE);
+	mbxentry->mb1 = mbxentry->loop_id.extended =
+	    cpu_to_le16(iodesc->remote_fcport->loop_id);
+	mbxentry->mb2 = cpu_to_le16(MSW(LSD(ha->iodesc_pd_dma)));
+	mbxentry->mb3 = cpu_to_le16(LSW(LSD(ha->iodesc_pd_dma)));
+	mbxentry->mb6 = cpu_to_le16(MSW(MSD(ha->iodesc_pd_dma)));
+	mbxentry->mb7 = cpu_to_le16(LSW(MSD(ha->iodesc_pd_dma)));
+	mbxentry->mb10 = __constant_cpu_to_le16(BIT_0);
+
+	qla2x00_add_iodesc_timer(iodesc);
+
+	/* Issue command to ISP. */
+	qla2x00_isp_cmd(ha);
+
+	if (!ha_locked)
+		spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+	DEBUG14(printk("scsi(%ld): Sending Adisc IOCB (%08x) to [%x].\n",
+	    ha->host_no, iodesc->signature, iodesc->remote_fcport->loop_id));
+
+	return (QLA_SUCCESS);
+}
+
+/**
+ * qla2x00_send_adisc_iocb_cb() - Get Port Database IOCB callback.
+ * @ha: HA context
+ * @iodesc: io descriptor
+ * @mbxstat: mailbox status IOCB
+ *
+ * Returns QLA_SUCCESS if @iodesc can be freed by the caller, else, @iodesc
+ * will be used for a retry.
+ */
+static int
+qla2x00_send_adisc_iocb_cb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
+    struct mbx_entry *mbxstat)
+{
+	fc_port_t *remote_fcport;
+
+	remote_fcport = iodesc->remote_fcport;
+
+	/* Ensure the port IDs are consistent. */
+	if (remote_fcport->d_id.b24 != iodesc->d_id.b24) {
+		DEBUG14(printk("scsi(%ld): Adisc IOCB -- ignoring, remote port "
+		    "id changed from [%02x%02x%02x] to [%02x%02x%02x].\n",
+		    ha->host_no, remote_fcport->d_id.b.domain,
+		    remote_fcport->d_id.b.area, remote_fcport->d_id.b.al_pa,
+		    iodesc->d_id.b.domain, iodesc->d_id.b.area,
+		    iodesc->d_id.b.al_pa));
+
+		return (QLA_SUCCESS);
+	}
+
+	/* Only process the last command. */
+	if (remote_fcport->iodesc_idx_sent != iodesc->idx) {
+		DEBUG14(printk("scsi(%ld): Adisc IOCB -- ignoring, sent to "
+		    "[%02x%02x%02x], expected %x, received %x.\n", ha->host_no,
+		    iodesc->d_id.b.domain, iodesc->d_id.b.area,
+		    iodesc->d_id.b.al_pa, remote_fcport->iodesc_idx_sent,
+		    iodesc->idx));
+
+		return (QLA_SUCCESS);
+	}
+
+	if (le16_to_cpu(mbxstat->status) == CS_COMPLETE) {
+		DEBUG14(printk("scsi(%ld): Adisc IOCB -- marking "
+		    "[%x/%02x%02x%02x] online.\n", ha->host_no,
+		    remote_fcport->loop_id, remote_fcport->d_id.b.domain,
+		    remote_fcport->d_id.b.area, remote_fcport->d_id.b.al_pa));
+
+		atomic_set(&remote_fcport->state, FCS_ONLINE);
+	} else {
+		DEBUG14(printk("scsi(%ld): Adisc IOCB -- marking "
+		    "[%x/%02x%02x%02x] lost, status=%x mb0=%x.\n", ha->host_no,
+		    remote_fcport->loop_id, remote_fcport->d_id.b.domain,
+		    remote_fcport->d_id.b.area, remote_fcport->d_id.b.al_pa,
+		    le16_to_cpu(mbxstat->status), le16_to_cpu(mbxstat->mb0)));
+
+		if (atomic_read(&remote_fcport->state) != FCS_DEVICE_DEAD)
+			atomic_set(&remote_fcport->state, FCS_DEVICE_LOST);
+	}
+	remote_fcport->iodesc_idx_sent = IODESC_INVALID_INDEX;
+
+	return (QLA_SUCCESS);
+}
+
+
+/**
+ * qla2x00_send_logout_iocb() - Issue a fabric port logout IOCB to the firmware.
+ * @ha: HA context
+ * @iodesc: io descriptor
+ * @ha_locked: is function called with the hardware lock
+ *
+ * Returns QLA_SUCCESS if the IOCB was issued.
+ */
+static int
+qla2x00_send_logout_iocb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
+    int ha_locked)
+{
+	unsigned long flags = 0;
+	struct mbx_entry *mbxentry;
+
+	/* Send marker if required. */
+	if (qla2x00_issue_marker(ha, ha_locked) != QLA_SUCCESS)
+		return (QLA_FUNCTION_FAILED);
+
+	if (!ha_locked)
+		spin_lock_irqsave(&ha->hardware_lock, flags);
+
+	/* Build fabric port logout mailbox IOCB. */
+	mbxentry = qla2x00_get_mbx_iocb_entry(ha, iodesc->signature);
+	if (mbxentry == NULL) {
+		if (!ha_locked)
+			spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+		return (QLA_FUNCTION_FAILED);
+	}
+	mbxentry->mb0 = __constant_cpu_to_le16(MBC_LOGOUT_FABRIC_PORT);
+	mbxentry->mb1 = mbxentry->loop_id.extended =
+	    cpu_to_le16(iodesc->remote_fcport->loop_id);
+
+	qla2x00_add_iodesc_timer(iodesc);
+
+	/* Issue command to ISP. */
+	qla2x00_isp_cmd(ha);
+
+	if (!ha_locked)
+		spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+	DEBUG14(printk("scsi(%ld): Sending Logout IOCB (%08x) to [%x].\n",
+	    ha->host_no, iodesc->signature, iodesc->remote_fcport->loop_id));
+
+	return (QLA_SUCCESS);
+}
+
+/**
+ * qla2x00_send_logout_iocb_cb() - Fabric port logout IOCB callback.
+ * @ha: HA context
+ * @iodesc: io descriptor
+ * @mbxstat: mailbox status IOCB
+ *
+ * Returns QLA_SUCCESS if @iodesc can be freed by the caller, else, @iodesc
+ * will be used for a retry.
+ */
+static int
+qla2x00_send_logout_iocb_cb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
+    struct mbx_entry *mbxstat)
+{
+	DEBUG14(printk("scsi(%ld): Logout IOCB -- sent to [%x/%02x%02x%02x], "
+	    "status=%x mb0=%x mb1=%x.\n", ha->host_no,
+	    iodesc->remote_fcport->loop_id,
+	    iodesc->remote_fcport->d_id.b.domain,
+	    iodesc->remote_fcport->d_id.b.area,
+	    iodesc->remote_fcport->d_id.b.al_pa, le16_to_cpu(mbxstat->status),
+	    le16_to_cpu(mbxstat->mb0), le16_to_cpu(mbxstat->mb1)));
+
+	return (QLA_SUCCESS);
+}
+
+
+/**
+ * qla2x00_send_login_iocb() - Issue a fabric port login IOCB to the firmware.
+ * @ha: HA context
+ * @iodesc: io descriptor
+ * @d_id: port id for device
+ * @ha_locked: is function called with the hardware lock
+ *
+ * Returns QLA_SUCCESS if the IOCB was issued.
+ */
+static int
+qla2x00_send_login_iocb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
+    port_id_t *d_id, int ha_locked)
+{
+	unsigned long flags = 0;
+	struct mbx_entry *mbxentry;
+
+	/* Send marker if required. */
+	if (qla2x00_issue_marker(ha, ha_locked) != QLA_SUCCESS)
+		return (QLA_FUNCTION_FAILED);
+
+	if (!ha_locked)
+		spin_lock_irqsave(&ha->hardware_lock, flags);
+
+	/* Build fabric port login mailbox IOCB. */
+	mbxentry = qla2x00_get_mbx_iocb_entry(ha, iodesc->signature);
+	if (mbxentry == NULL) {
+		if (!ha_locked)
+			spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+		return (QLA_FUNCTION_FAILED);
+	}
+	mbxentry->mb0 = __constant_cpu_to_le16(MBC_LOGIN_FABRIC_PORT);
+	mbxentry->mb1 = mbxentry->loop_id.extended =
+	    cpu_to_le16(iodesc->remote_fcport->loop_id);
+	mbxentry->mb2 = cpu_to_le16(d_id->b.domain);
+	mbxentry->mb3 = cpu_to_le16(d_id->b.area << 8 | d_id->b.al_pa);
+	mbxentry->mb10 = __constant_cpu_to_le16(BIT_0);
+
+	qla2x00_add_iodesc_timer(iodesc);
+
+	/* Issue command to ISP. */
+	qla2x00_isp_cmd(ha);
+
+	if (!ha_locked)
+		spin_unlock_irqrestore(&ha->hardware_lock, flags);
+
+	DEBUG14(printk("scsi(%ld): Sending Login IOCB (%08x) to "
+	    "[%x/%02x%02x%02x].\n", ha->host_no, iodesc->signature,
+	    iodesc->remote_fcport->loop_id, d_id->b.domain, d_id->b.area,
+	    d_id->b.al_pa));
+
+	return (QLA_SUCCESS);
+}
+
+/**
+ * qla2x00_send_login_iocb_cb() - Fabric port logout IOCB callback.
+ * @ha: HA context
+ * @iodesc: io descriptor
+ * @mbxstat: mailbox status IOCB
+ *
+ * Returns QLA_SUCCESS if @iodesc can be freed by the caller, else, @iodesc
+ * will be used for a retry.
+ */
+static int
+qla2x00_send_login_iocb_cb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
+    struct mbx_entry *mbxstat)
+{
+	int rval;
+	fc_port_t *fcport, *remote_fcport, *exist_fcport;
+	struct io_descriptor *abort_iodesc, *login_iodesc;
+	uint16_t status, mb[8];
+	uint16_t reuse;
+	uint16_t remote_loopid;
+	port_id_t remote_did, inuse_did;
+
+	remote_fcport = iodesc->remote_fcport;
+
+	/* Only process the last command. */
+	if (remote_fcport->iodesc_idx_sent != iodesc->idx) {
+		DEBUG14(printk("scsi(%ld): Login IOCB -- ignoring, sent to "
+		    "[%02x%02x%02x], expected %x, received %x.\n", 
+		    ha->host_no, iodesc->d_id.b.domain, iodesc->d_id.b.area,
+		    iodesc->d_id.b.al_pa, remote_fcport->iodesc_idx_sent,
+		    iodesc->idx));
+
+		/* Free RSCN fcport resources. */
+		if (remote_fcport->port_type == FCT_RSCN) {
+			DEBUG14(printk("scsi(%ld): Login IOCB -- Freeing RSCN "
+			    "fcport %p [%x/%02x%02x%02x] given ignored Login "
+			    "IOCB.\n", ha->host_no, remote_fcport,
+			    remote_fcport->loop_id,
+			    remote_fcport->d_id.b.domain,
+			    remote_fcport->d_id.b.area,
+			    remote_fcport->d_id.b.al_pa));
+
+			list_del(&remote_fcport->list);
+			kfree(remote_fcport);
+		}
+		return (QLA_SUCCESS);
+	}
+
+	status = le16_to_cpu(mbxstat->status);
+	mb[0] = le16_to_cpu(mbxstat->mb0);
+	mb[1] = le16_to_cpu(mbxstat->mb1);
+	mb[2] = le16_to_cpu(mbxstat->mb2);
+	mb[6] = le16_to_cpu(mbxstat->mb6);
+	mb[7] = le16_to_cpu(mbxstat->mb7);
+
+	/* Good status? */
+	if ((status == CS_COMPLETE || status == CS_COMPLETE_CHKCOND) &&
+	    mb[0] == MBS_COMMAND_COMPLETE) {
+
+		DEBUG14(printk("scsi(%ld): Login IOCB -- status=%x mb1=%x pn="
+		    "%02x%02x%02x%02x%02x%02x%02x%02x.\n", ha->host_no, status,
+		    mb[1], mbxstat->port_name[0], mbxstat->port_name[1], 
+		    mbxstat->port_name[2], mbxstat->port_name[3], 
+		    mbxstat->port_name[4], mbxstat->port_name[5], 
+		    mbxstat->port_name[6], mbxstat->port_name[7]));
+
+		memcpy(remote_fcport->node_name, mbxstat->node_name, WWN_SIZE);
+		memcpy(remote_fcport->port_name, mbxstat->port_name, WWN_SIZE);
+
+		/* Is the device already in our fcports list? */
+		if (remote_fcport->port_type != FCT_RSCN) {
+			DEBUG14(printk("scsi(%ld): Login IOCB -- marking "
+			    "[%x/%02x%02x%02x] online.\n", ha->host_no,
+			    remote_fcport->loop_id,
+			    remote_fcport->d_id.b.domain,
+			    remote_fcport->d_id.b.area,
+			    remote_fcport->d_id.b.al_pa));
+
+			qla2x00_update_login_fcport(ha, mbxstat, remote_fcport);
+
+			return (QLA_SUCCESS);
+		}
+
+		/* Does the RSCN portname already exist in our fcports list? */
+		exist_fcport = NULL;
+		list_for_each_entry(fcport, &ha->fcports, list) {
+			if (memcmp(remote_fcport->port_name, fcport->port_name,
+			    WWN_SIZE) == 0) {
+				exist_fcport = fcport;
+				break;
+			}
+		}
+		if (exist_fcport != NULL) {
+			DEBUG14(printk("scsi(%ld): Login IOCB -- found RSCN "
+			    "fcport in fcports list [%p].\n", ha->host_no,
+			    exist_fcport));
+
+			/* Abort any ADISC that could have been sent. */
+			if (exist_fcport->iodesc_idx_sent != iodesc->idx &&
+			    exist_fcport->iodesc_idx_sent <
+			    MAX_IO_DESCRIPTORS &&
+			    ha->io_descriptors[exist_fcport->iodesc_idx_sent].
+			    cb_idx == ADISC_PORT_IOCB_CB) {
+
+				abort_iodesc = qla2x00_alloc_iodesc(ha);
+				if (abort_iodesc) {
+					DEBUG14(printk("scsi(%ld): Login IOCB "
+					    "-- issuing abort to outstanding "
+					    "Adisc [%x/%02x%02x%02x].\n",
+					    ha->host_no, remote_fcport->loop_id,
+					    exist_fcport->d_id.b.domain,
+					    exist_fcport->d_id.b.area,
+					    exist_fcport->d_id.b.al_pa));
+
+					abort_iodesc->cb_idx = ABORT_IOCB_CB;
+					abort_iodesc->d_id.b24 =
+					    exist_fcport->d_id.b24;
+					abort_iodesc->remote_fcport =
+					    exist_fcport;
+					exist_fcport->iodesc_idx_sent =
+					    abort_iodesc->idx;
+					qla2x00_send_abort_iocb(ha,
+					    abort_iodesc, ha->io_descriptors[
+					     exist_fcport->iodesc_idx_sent].
+					      signature, 1);
+				} else {
+					DEBUG14(printk("scsi(%ld): Login IOCB "
+					    "-- unable to abort outstanding "
+					    "Adisc [%x/%02x%02x%02x].\n",
+					    ha->host_no, remote_fcport->loop_id,
+					    exist_fcport->d_id.b.domain,
+					    exist_fcport->d_id.b.area,
+					    exist_fcport->d_id.b.al_pa));
+				}
+			}
+
+			/*
+			 * If the existing fcport is waiting to send an ADISC
+			 * or LOGIN, then reuse remote fcport (RSCN) to
+			 * continue waiting.
+			 */
+			reuse = 0;
+			remote_loopid = remote_fcport->loop_id;
+			remote_did.b24 = remote_fcport->d_id.b24;
+			if (exist_fcport->iodesc_idx_sent ==
+			    IODESC_ADISC_NEEDED ||
+			    exist_fcport->iodesc_idx_sent ==
+			    IODESC_LOGIN_NEEDED) {
+				DEBUG14(printk("scsi(%ld): Login IOCB -- "
+				    "existing fcport [%x/%02x%02x%02x] "
+				    "waiting for IO descriptor, reuse RSCN "
+				    "fcport.\n", ha->host_no,
+				    exist_fcport->loop_id,
+				    exist_fcport->d_id.b.domain,
+				    exist_fcport->d_id.b.area,
+				    exist_fcport->d_id.b.al_pa));
+
+				reuse++;
+				remote_fcport->iodesc_idx_sent =
+				    exist_fcport->iodesc_idx_sent;
+				exist_fcport->iodesc_idx_sent =
+				    IODESC_INVALID_INDEX;
+				remote_fcport->loop_id = exist_fcport->loop_id;
+				remote_fcport->d_id.b24 =
+				    exist_fcport->d_id.b24;
+			}
+
+			/* Logout the old loopid. */
+			if (!reuse &&
+			    exist_fcport->loop_id != remote_fcport->loop_id &&
+			    exist_fcport->loop_id != FC_NO_LOOP_ID) {
+				login_iodesc = qla2x00_alloc_iodesc(ha);
+				if (login_iodesc) {
+					DEBUG14(printk("scsi(%ld): Login IOCB "
+					    "-- issuing logout to free old "
+					    "loop id [%x/%02x%02x%02x].\n",
+					    ha->host_no, exist_fcport->loop_id,
+					    exist_fcport->d_id.b.domain,
+					    exist_fcport->d_id.b.area,
+					    exist_fcport->d_id.b.al_pa));
+
+					login_iodesc->cb_idx =
+					    LOGOUT_PORT_IOCB_CB;
+					login_iodesc->d_id.b24 =
+					    exist_fcport->d_id.b24;
+					login_iodesc->remote_fcport =
+					    exist_fcport;
+					exist_fcport->iodesc_idx_sent =
+					    login_iodesc->idx;
+					qla2x00_send_logout_iocb(ha,
+					    login_iodesc, 1);
+				} else {
+					/* Ran out of IO descriptiors. */
+					DEBUG14(printk("scsi(%ld): Login IOCB "
+					    "-- unable to logout to free old "
+					    "loop id [%x/%02x%02x%02x].\n",
+					    ha->host_no, exist_fcport->loop_id,
+					    exist_fcport->d_id.b.domain,
+					    exist_fcport->d_id.b.area,
+					    exist_fcport->d_id.b.al_pa));
+
+					exist_fcport->iodesc_idx_sent =
+					    IODESC_INVALID_INDEX;
+				}
+
+			}
+
+			/* Update existing fcport with remote fcport info. */
+			DEBUG14(printk("scsi(%ld): Login IOCB -- marking "
+			    "existing fcport [%x/%02x%02x%02x] online.\n",
+			    ha->host_no, remote_loopid, remote_did.b.domain,
+			    remote_did.b.area, remote_did.b.al_pa));
+
+			memcpy(exist_fcport->node_name,
+			    remote_fcport->node_name, WWN_SIZE);
+			exist_fcport->loop_id = remote_loopid;
+			exist_fcport->d_id.b24 = remote_did.b24;
+			qla2x00_update_login_fcport(ha, mbxstat, exist_fcport);
+
+			/* Finally, free the remote (RSCN) fcport. */
+			if (!reuse) {
+				DEBUG14(printk("scsi(%ld): Login IOCB -- "
+				    "Freeing RSCN fcport %p "
+				    "[%x/%02x%02x%02x].\n", ha->host_no,
+				    remote_fcport, remote_fcport->loop_id,
+				    remote_fcport->d_id.b.domain,
+				    remote_fcport->d_id.b.area,
+				    remote_fcport->d_id.b.al_pa));
+
+				list_del(&remote_fcport->list);
+				kfree(remote_fcport);
+			}
+
+			return (QLA_SUCCESS);
+		}
+
+		/*
+		 * A new device has been added, move the RSCN fcport to our
+		 * fcports list.
+		 */
+		DEBUG14(printk("scsi(%ld): Login IOCB -- adding RSCN fcport "
+		    "[%x/%02x%02x%02x] to fcports list.\n", ha->host_no,
+		    remote_fcport->loop_id, remote_fcport->d_id.b.domain,
+		    remote_fcport->d_id.b.area, remote_fcport->d_id.b.al_pa));
+
+		list_del(&remote_fcport->list);
+		remote_fcport->flags = (FCF_RLC_SUPPORT | FCF_RESCAN_NEEDED);
+		qla2x00_update_login_fcport(ha, mbxstat, remote_fcport);
+		list_add_tail(&remote_fcport->list, &ha->fcports);
+		set_bit(FCPORT_RESCAN_NEEDED, &ha->dpc_flags);
+	} else {
+		/* Handle login failure. */
+		if (remote_fcport->login_retry != 0) {
+			if (mb[0] == MBS_LOOP_ID_USED) {
+				inuse_did.b.domain = LSB(mb[1]);
+				inuse_did.b.area = MSB(mb[2]);
+				inuse_did.b.al_pa = LSB(mb[2]);
+
+				DEBUG14(printk("scsi(%ld): Login IOCB -- loop "
+				    "id [%x] used by port id [%02x%02x%02x].\n",
+				    ha->host_no, remote_fcport->loop_id,
+				    inuse_did.b.domain, inuse_did.b.area,
+				    inuse_did.b.al_pa));
+
+				if (remote_fcport->d_id.b24 ==
+				    INVALID_PORT_ID) {
+					/*
+					 * Invalid port id means we are trying
+					 * to login to a remote port with just
+					 * a loop id without knowing about the
+					 * port id.  Copy the port id and try
+					 * again.
+					 */
+					remote_fcport->d_id.b24 = inuse_did.b24;
+					iodesc->d_id.b24 = inuse_did.b24;
+				} else {
+					remote_fcport->loop_id++;
+					rval = qla2x00_find_new_loop_id(ha,
+					    remote_fcport);
+					if (rval == QLA_FUNCTION_FAILED) {
+						/* No more loop ids. */
+						return (QLA_SUCCESS);
+					}
+				}
+			} else if (mb[0] == MBS_PORT_ID_USED) {
+				/*
+				 * Device has another loop ID.  The firmware
+				 * group recommends the driver perform an
+				 * implicit login with the specified ID.
+				 */
+				DEBUG14(printk("scsi(%ld): Login IOCB -- port "
+				    "id [%02x%02x%02x] already assigned to "
+				    "loop id [%x].\n", ha->host_no,
+				    iodesc->d_id.b.domain, iodesc->d_id.b.area,
+				    iodesc->d_id.b.al_pa, mb[1]));
+
+				remote_fcport->loop_id = mb[1];
+
+			} else {
+				/* Unable to perform login, try again. */
+				DEBUG14(printk("scsi(%ld): Login IOCB -- "
+				    "failed login [%x/%02x%02x%02x], status=%x "
+				    "mb0=%x mb1=%x mb2=%x mb6=%x mb7=%x.\n",
+				    ha->host_no, remote_fcport->loop_id,
+				    iodesc->d_id.b.domain, iodesc->d_id.b.area,
+				    iodesc->d_id.b.al_pa, status, mb[0], mb[1],
+				    mb[2], mb[6], mb[7]));
+			}
+
+			/* Reissue Login with the same IO descriptor. */
+			iodesc->signature =
+			    qla2x00_iodesc_to_handle(iodesc);
+			iodesc->cb_idx = LOGIN_PORT_IOCB_CB;
+			iodesc->d_id.b24 = remote_fcport->d_id.b24;
+			remote_fcport->iodesc_idx_sent = iodesc->idx;
+			remote_fcport->login_retry--;
+
+			DEBUG14(printk("scsi(%ld): Login IOCB -- retrying "
+			    "login to [%x/%02x%02x%02x] (%d).\n", ha->host_no,
+			    remote_fcport->loop_id,
+			    remote_fcport->d_id.b.domain,
+			    remote_fcport->d_id.b.area,
+			    remote_fcport->d_id.b.al_pa,
+			    remote_fcport->login_retry));
+
+			qla2x00_send_login_iocb(ha, iodesc,
+			    &remote_fcport->d_id, 1);
+
+			return (QLA_FUNCTION_FAILED);
+		} else {
+			/* No more logins, mark device dead. */
+			DEBUG14(printk("scsi(%ld): Login IOCB -- failed "
+			    "login [%x/%02x%02x%02x] after retries, status=%x "
+			    "mb0=%x mb1=%x mb2=%x mb6=%x mb7=%x.\n",
+			    ha->host_no, remote_fcport->loop_id,
+			    iodesc->d_id.b.domain, iodesc->d_id.b.area,
+			    iodesc->d_id.b.al_pa, status, mb[0], mb[1],
+			    mb[2], mb[6], mb[7]));
+
+			atomic_set(&remote_fcport->state, FCS_DEVICE_DEAD);
+			if (remote_fcport->port_type == FCT_RSCN) {
+				DEBUG14(printk("scsi(%ld): Login IOCB -- "
+				    "Freeing dead RSCN fcport %p "
+				    "[%x/%02x%02x%02x].\n", ha->host_no,
+				    remote_fcport, remote_fcport->loop_id,
+				    remote_fcport->d_id.b.domain,
+				    remote_fcport->d_id.b.area,
+				    remote_fcport->d_id.b.al_pa));
+
+				list_del(&remote_fcport->list);
+				kfree(remote_fcport);
+			}
+		}
+	}
+
+	return (QLA_SUCCESS);
+}
+
+
+/** 
+ * IO descriptor processing routines.
+ **/
+
+/**
+ * qla2x00_alloc_rscn_fcport() - Allocate an RSCN type fcport.
+ * @ha: HA context
+ * @flags: allocation flags
+ *
+ * Returns a pointer to the allocated RSCN fcport, or NULL, if none available.
+ */
+fc_port_t *
+qla2x00_alloc_rscn_fcport(scsi_qla_host_t *ha, int flags)
+{
+	fc_port_t *fcport;
+
+	fcport = qla2x00_alloc_fcport(ha, flags);
+	if (fcport == NULL)
+		return (fcport);
+
+	/* Setup RSCN fcport structure. */
+	fcport->port_type = FCT_RSCN;
+
+	return (fcport);
+}
+
+/**
+ * qla2x00_handle_port_rscn() - Handle port RSCN.
+ * @ha: HA context
+ * @rscn_entry: RSCN entry
+ * @fcport: fcport entry to updated
+ *
+ * Returns QLA_SUCCESS if the port RSCN was handled.
+ */
+int
+qla2x00_handle_port_rscn(scsi_qla_host_t *ha, uint32_t rscn_entry,
+    fc_port_t *known_fcport, int ha_locked)
+{
+	int	rval;
+	port_id_t rscn_pid;
+	fc_port_t *fcport, *remote_fcport, *rscn_fcport;
+	struct io_descriptor *iodesc;
+
+	remote_fcport = NULL;
+	rscn_fcport = NULL;
+
+	/* Prepare port id based on incoming entries. */
+	if (known_fcport) {
+		rscn_pid.b24 = known_fcport->d_id.b24;
+		remote_fcport = known_fcport;
+
+		DEBUG14(printk("scsi(%ld): Handle RSCN -- process RSCN for "
+		    "fcport [%02x%02x%02x].\n", ha->host_no,
+		    remote_fcport->d_id.b.domain, remote_fcport->d_id.b.area,
+		    remote_fcport->d_id.b.al_pa));
+	} else {
+		rscn_pid.b.domain = LSB(MSW(rscn_entry));
+		rscn_pid.b.area = MSB(LSW(rscn_entry));
+		rscn_pid.b.al_pa = LSB(LSW(rscn_entry));
+
+		DEBUG14(printk("scsi(%ld): Handle RSCN -- process RSCN for "
+		    "port id [%02x%02x%02x].\n", ha->host_no,
+		    rscn_pid.b.domain, rscn_pid.b.area, rscn_pid.b.al_pa));
+
+		/*
+		 * Search fcport lists for a known entry at the specified port
+		 * ID.
+		 */
+		list_for_each_entry(fcport, &ha->fcports, list) {
+		    if (rscn_pid.b24 == fcport->d_id.b24) {
+			    remote_fcport = fcport;
+			    break;
+		    }
+		}
+		list_for_each_entry(fcport, &ha->rscn_fcports, list) {
+		    if (rscn_pid.b24 == fcport->d_id.b24) {
+			    rscn_fcport = fcport;
+			    break;
+		    }
+		}
+		if (remote_fcport == NULL)
+		    remote_fcport = rscn_fcport;
+	}
+
+	/* 
+	 * If the port is already in our fcport list and online, send an ADISC
+	 * to see if it's still alive.  Issue login if a new fcport or the known
+	 * fcport is currently offline.
+	 */
+	if (remote_fcport) {
+		/*
+		 * No need to send request if the remote fcport is currently
+		 * waiting for an available io descriptor.
+		 */
+		if (known_fcport == NULL &&
+		    (remote_fcport->iodesc_idx_sent == IODESC_ADISC_NEEDED ||
+		    remote_fcport->iodesc_idx_sent == IODESC_LOGIN_NEEDED)) {
+			/*
+			 * If previous waiting io descriptor is an ADISC, then
+			 * the new RSCN may come from a new remote fcport being
+			 * plugged into the same location.
+			 */
+			if (remote_fcport->port_type == FCT_RSCN) {
+			    remote_fcport->iodesc_idx_sent =
+				IODESC_LOGIN_NEEDED;
+			} else if (remote_fcport->iodesc_idx_sent ==
+			    IODESC_ADISC_NEEDED) {
+				fc_port_t *new_fcport;
+
+				remote_fcport->iodesc_idx_sent =
+				    IODESC_INVALID_INDEX;
+
+				/* Create new fcport for later login. */
+				new_fcport = qla2x00_alloc_rscn_fcport(ha,
+				    ha_locked ? GFP_ATOMIC: GFP_KERNEL);
+				if (new_fcport) {
+					DEBUG14(printk("scsi(%ld): Handle RSCN "
+					    "-- creating RSCN fcport %p for "
+					    "future login.\n", ha->host_no,
+					    new_fcport));
+
+					new_fcport->d_id.b24 =
+					    remote_fcport->d_id.b24;
+					new_fcport->iodesc_idx_sent =
+					    IODESC_LOGIN_NEEDED;
+
+					list_add_tail(&new_fcport->list,
+					    &ha->rscn_fcports);
+					set_bit(IODESC_PROCESS_NEEDED,
+					    &ha->dpc_flags);
+				} else {
+					DEBUG14(printk("scsi(%ld): Handle RSCN "
+					    "-- unable to allocate RSCN fcport "
+					    "for future login.\n",
+					    ha->host_no));
+				}
+			}
+			return (QLA_SUCCESS);
+		}
+		
+		/* Send ADISC if the fcport is online */
+		if (atomic_read(&remote_fcport->state) == FCS_ONLINE ||
+		    remote_fcport->iodesc_idx_sent == IODESC_ADISC_NEEDED) {
+
+			atomic_set(&remote_fcport->state, FCS_DEVICE_LOST);
+
+			iodesc = qla2x00_alloc_iodesc(ha);
+			if (iodesc == NULL) {
+				/* Mark fcport for later adisc processing */
+				DEBUG14(printk("scsi(%ld): Handle RSCN -- not "
+				    "enough IO descriptors for Adisc, flag "
+				    "for later processing.\n", ha->host_no));
+
+				remote_fcport->iodesc_idx_sent =
+				    IODESC_ADISC_NEEDED;
+				set_bit(IODESC_PROCESS_NEEDED, &ha->dpc_flags);
+
+				return (QLA_SUCCESS);
+			}
+
+			iodesc->cb_idx = ADISC_PORT_IOCB_CB;
+			iodesc->d_id.b24 = rscn_pid.b24;
+			iodesc->remote_fcport = remote_fcport;
+			remote_fcport->iodesc_idx_sent = iodesc->idx;
+			qla2x00_send_adisc_iocb(ha, iodesc, ha_locked);
+
+			return (QLA_SUCCESS);
+		} else if (remote_fcport->iodesc_idx_sent <
+		    MAX_IO_DESCRIPTORS &&
+		    ha->io_descriptors[remote_fcport->iodesc_idx_sent].cb_idx ==
+		    ADISC_PORT_IOCB_CB) {
+			/*
+			 * Receiving another RSCN while an ADISC is pending,
+			 * abort the IOCB.  Use the same descriptor for the
+			 * abort.
+			 */
+			uint32_t handle_to_abort;
+			
+			iodesc = &ha->io_descriptors[
+				remote_fcport->iodesc_idx_sent];
+			qla2x00_remove_iodesc_timer(iodesc);
+			handle_to_abort = iodesc->signature;
+			iodesc->signature = qla2x00_iodesc_to_handle(iodesc);
+			iodesc->cb_idx = ABORT_IOCB_CB;
+			iodesc->d_id.b24 = remote_fcport->d_id.b24;
+			iodesc->remote_fcport = remote_fcport;
+			remote_fcport->iodesc_idx_sent = iodesc->idx;
+
+			DEBUG14(printk("scsi(%ld): Handle RSCN -- issuing "
+			    "abort to outstanding Adisc [%x/%02x%02x%02x].\n",
+			    ha->host_no, remote_fcport->loop_id,
+			    iodesc->d_id.b.domain, iodesc->d_id.b.area,
+			    iodesc->d_id.b.al_pa));
+
+			qla2x00_send_abort_iocb(ha, iodesc, handle_to_abort,
+			    ha_locked);
+		}
+	}
+
+	/* We need to login to the remote port, find it. */
+	if (known_fcport) {
+		remote_fcport = known_fcport;
+	} else if (rscn_fcport && rscn_fcport->d_id.b24 != INVALID_PORT_ID &&
+	    rscn_fcport->iodesc_idx_sent < MAX_IO_DESCRIPTORS &&
+	    ha->io_descriptors[rscn_fcport->iodesc_idx_sent].cb_idx ==
+	    LOGIN_PORT_IOCB_CB) {
+		/*
+		 * Ignore duplicate RSCN on fcport which has already
+		 * initiated a login IOCB.
+		 */
+		DEBUG14(printk("scsi(%ld): Handle RSCN -- ignoring, login "
+		    "already sent to [%02x%02x%02x].\n", ha->host_no,
+		    rscn_fcport->d_id.b.domain, rscn_fcport->d_id.b.area,
+		    rscn_fcport->d_id.b.al_pa));
+
+		return (QLA_SUCCESS);
+	} else if (rscn_fcport && rscn_fcport->d_id.b24 != INVALID_PORT_ID &&
+	    rscn_fcport != remote_fcport) {
+		/* Reuse same rscn fcport. */
+		DEBUG14(printk("scsi(%ld): Handle RSCN -- reusing RSCN fcport "
+		    "[%02x%02x%02x].\n", ha->host_no,
+		    rscn_fcport->d_id.b.domain, rscn_fcport->d_id.b.area,
+		    rscn_fcport->d_id.b.al_pa));
+
+		remote_fcport = rscn_fcport;
+	} else {
+		/* Create new fcport for later login. */
+		remote_fcport = qla2x00_alloc_rscn_fcport(ha,
+		    ha_locked ? GFP_ATOMIC: GFP_KERNEL);
+		list_add_tail(&remote_fcport->list, &ha->rscn_fcports);
+	}
+	if (remote_fcport == NULL)
+		return (QLA_SUCCESS);
+
+	/* Prepare fcport for login. */
+	atomic_set(&remote_fcport->state, FCS_DEVICE_LOST);
+	remote_fcport->login_retry = 3; /* ha->login_retry_count; */
+	remote_fcport->d_id.b24 = rscn_pid.b24;
+
+	iodesc = qla2x00_alloc_iodesc(ha);
+	if (iodesc == NULL) {
+		/* Mark fcport for later adisc processing. */
+		DEBUG14(printk("scsi(%ld): Handle RSCN -- not enough IO "
+		    "descriptors for Login, flag for later processing.\n",
+		    ha->host_no));
+
+		remote_fcport->iodesc_idx_sent = IODESC_LOGIN_NEEDED;
+		set_bit(IODESC_PROCESS_NEEDED, &ha->dpc_flags);
+
+		return (QLA_SUCCESS);
+	}
+
+	if (known_fcport == NULL || rscn_pid.b24 != INVALID_PORT_ID) {
+		remote_fcport->loop_id = ha->min_external_loopid;
+
+		rval = qla2x00_find_new_loop_id(ha, remote_fcport);
+		if (rval == QLA_FUNCTION_FAILED) {
+			/* No more loop ids, failed. */
+			DEBUG14(printk("scsi(%ld): Handle RSCN -- no available "
+			    "loop id to perform Login, failed.\n",
+			    ha->host_no));
+
+			return (rval);
+		}
+	}
+
+	iodesc->cb_idx = LOGIN_PORT_IOCB_CB;
+	iodesc->d_id.b24 = rscn_pid.b24;
+	iodesc->remote_fcport = remote_fcport;
+	remote_fcport->iodesc_idx_sent = iodesc->idx;
+
+	DEBUG14(printk("scsi(%ld): Handle RSCN -- attempting login to "
+	    "[%x/%02x%02x%02x].\n", ha->host_no, remote_fcport->loop_id,
+	    iodesc->d_id.b.domain, iodesc->d_id.b.area, iodesc->d_id.b.al_pa));
+
+	qla2x00_send_login_iocb(ha, iodesc, &rscn_pid, ha_locked);
+
+	return (QLA_SUCCESS);
+}
+
+/**
+ * qla2x00_process_iodesc() - Complete IO descriptor processing.
+ * @ha: HA context
+ * @mbxstat: Mailbox IOCB status
+ */
+void
+qla2x00_process_iodesc(scsi_qla_host_t *ha, struct mbx_entry *mbxstat)
+{
+	int rval;
+	uint32_t signature;
+	fc_port_t *fcport;
+	struct io_descriptor *iodesc;
+
+	signature = mbxstat->handle;
+
+	DEBUG14(printk("scsi(%ld): Process IODesc -- processing %08x.\n",
+	    ha->host_no, signature));
+
+	/* Retrieve proper IO descriptor. */
+	iodesc = qla2x00_handle_to_iodesc(ha, signature);
+	if (iodesc == NULL) {
+		DEBUG14(printk("scsi(%ld): Process IODesc -- ignoring, "
+		    "incorrect signature %08x.\n", ha->host_no, signature));
+
+		return;
+	}
+
+	/* Stop IO descriptor timer. */
+	qla2x00_remove_iodesc_timer(iodesc);
+
+	/* Verify signature match. */
+	if (iodesc->signature != signature) {
+		DEBUG14(printk("scsi(%ld): Process IODesc -- ignoring, "
+		    "signature mismatch, sent %08x, received %08x.\n",
+		    ha->host_no, iodesc->signature, signature));
+
+		return;
+	}
+
+	/* Go with IOCB callback. */
+	rval = iocb_function_cb_list[iodesc->cb_idx](ha, iodesc, mbxstat);
+	if (rval != QLA_SUCCESS) {
+		/* IO descriptor reused by callback. */
+		return;
+	}
+
+	qla2x00_free_iodesc(iodesc);
+
+	if (test_bit(IODESC_PROCESS_NEEDED, &ha->dpc_flags)) {
+		/* Scan our fcports list for any RSCN requests. */
+		list_for_each_entry(fcport, &ha->fcports, list) {
+			if (fcport->iodesc_idx_sent == IODESC_ADISC_NEEDED ||
+			    fcport->iodesc_idx_sent == IODESC_LOGIN_NEEDED) {
+				qla2x00_handle_port_rscn(ha, 0, fcport, 1);
+				return;
+			}
+		}
+
+		/* Scan our RSCN fcports list for any RSCN requests. */
+		list_for_each_entry(fcport, &ha->rscn_fcports, list) {
+			if (fcport->iodesc_idx_sent == IODESC_ADISC_NEEDED ||
+			    fcport->iodesc_idx_sent == IODESC_LOGIN_NEEDED) {
+				qla2x00_handle_port_rscn(ha, 0, fcport, 1);
+				return;
+			}
+		}
+	}
+	clear_bit(IODESC_PROCESS_NEEDED, &ha->dpc_flags);
+}
+
+/**
+ * qla2x00_cancel_io_descriptors() - Cancel all outstanding io descriptors.
+ * @ha: HA context
+ *
+ * This routine will also delete any RSCN entries related to the outstanding
+ * IO descriptors.
+ */
+void
+qla2x00_cancel_io_descriptors(scsi_qla_host_t *ha)
+{
+	fc_port_t *fcport, *fcptemp;
+
+	clear_bit(IODESC_PROCESS_NEEDED, &ha->dpc_flags);
+
+	/* Abort all IO descriptors. */
+	qla2x00_init_io_descriptors(ha);
+
+	/* Reset all pending IO descriptors in fcports list. */
+	list_for_each_entry(fcport, &ha->fcports, list) {
+		fcport->iodesc_idx_sent = IODESC_INVALID_INDEX;
+	}
+
+	/* Reset all pending IO descriptors in rscn fcports list. */
+	list_for_each_entry_safe(fcport, fcptemp, &ha->rscn_fcports, list) {
+		DEBUG14(printk("scsi(%ld): Cancel IOs -- Freeing RSCN fcport "
+		    "%p [%x/%02x%02x%02x].\n", ha->host_no, fcport,
+		    fcport->loop_id, fcport->d_id.b.domain, fcport->d_id.b.area,
+		    fcport->d_id.b.al_pa));
+
+		list_del(&fcport->list);
+		kfree(fcport);
+	}
+}
diff -puN /dev/null drivers/scsi/qla2xxx/qla_settings.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/qla_settings.h	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,66 @@
+/******************************************************************************
+ *                  QLOGIC LINUX SOFTWARE
+ *
+ * QLogic ISP2x00 device driver for Linux 2.6.x
+ * Copyright (C) 2003 QLogic Corporation
+ * (www.qlogic.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ ******************************************************************************/
+/*
+ * Compile time Options:
+ *     0 - Disable and 1 - Enable
+ */
+#define DEBUG_QLA2100		0	/* For Debug of qla2x00 */
+
+#define MEMORY_MAPPED_IO	1
+#define STOP_ON_ERROR		0	/* Stop on aborts and resets  */
+#define STOP_ON_RESET		0
+#define USE_ABORT_TGT		1	/* Use Abort Target mbx cmd */
+
+#define VSA			0	/* Volume Set Addressing */
+
+/* Failover options */
+#define MAX_RECOVERYTIME	10	/*
+					 * Max suspend time for a lun recovery
+					 * time
+					 */
+#define MAX_FAILBACKTIME	5	/* Max suspend time before fail back */
+
+#define QLA_CMD_TIMER_DELTA	3
+
+/* 
+ * When a lun is suspended for the "Not Ready" condition then it will suspend
+ * the lun for increments of 6 sec delays.  SUSPEND_COUNT is that count.
+ */
+#define SUSPEND_COUNT		10	/* 6 secs * 10 retries = 60 secs */
+
+/*
+ * Defines the time in seconds that the driver extends the command timeout to
+ * get around the problem where the mid-layer only allows 5 retries for
+ * commands that return BUS_BUSY
+ */
+#define EXTEND_CMD_TIMEOUT	60
+
+#define MAX_RETRIES_OF_ISP_ABORT	5
+
+/* Max time to wait for the loop to be in LOOP_READY state */
+#define MAX_LOOP_TIMEOUT	(60 * 5)
+#define EH_ACTIVE		1	/* Error handler active */
+
+/*
+ * Some vendor subsystems do not recover properly after a device reset.  Define
+ * the following to force a logout after a successful device reset.
+ */
+#undef LOGOUT_AFTER_DEVICE_RESET
+
+#include "qla_version.h"
diff -puN /dev/null drivers/scsi/qla2xxx/qla_sup.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/qla_sup.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,680 @@
+/******************************************************************************
+ *                  QLOGIC LINUX SOFTWARE
+ *
+ * QLogic ISP2x00 device driver for Linux 2.6.x
+ * Copyright (C) 2003 QLogic Corporation
+ * (www.qlogic.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ ******************************************************************************/
+
+#include "qla_os.h"
+#include "qla_def.h"
+
+static uint16_t qla2x00_nvram_request(scsi_qla_host_t *, uint32_t);
+static void qla2x00_nv_deselect(scsi_qla_host_t *);
+static void qla2x00_nv_write(scsi_qla_host_t *, uint16_t);
+
+uint8_t qla2x00_read_flash_byte(scsi_qla_host_t *, uint32_t);
+static void qla2x00_write_flash_byte(scsi_qla_host_t *, uint32_t, uint8_t);
+static uint8_t qla2x00_poll_flash(scsi_qla_host_t *ha,
+		uint32_t addr, uint8_t poll_data, uint8_t mid);
+static uint8_t qla2x00_program_flash_address(scsi_qla_host_t *ha,
+		uint32_t addr, uint8_t data, uint8_t mid);
+static uint8_t qla2x00_erase_flash_sector(scsi_qla_host_t *ha,
+		uint32_t addr, uint32_t sec_mask, uint8_t mid);
+
+uint8_t qla2x00_get_flash_manufacturer(scsi_qla_host_t *ha);
+uint16_t qla2x00_get_flash_version(scsi_qla_host_t *);
+uint16_t qla2x00_get_flash_image(scsi_qla_host_t *ha, uint8_t *image);
+uint16_t qla2x00_set_flash_image(scsi_qla_host_t *ha, uint8_t *image);
+
+
+/*
+ * NVRAM support routines
+ */
+
+/**
+ * qla2x00_lock_nvram_access() - 
+ * @ha: HA context
+ */
+void
+qla2x00_lock_nvram_access(scsi_qla_host_t *ha)
+{
+	uint16_t data;
+	device_reg_t *reg;
+
+	reg = ha->iobase;
+
+	if (IS_QLA2312(ha) || IS_QLA2322(ha)) {
+		data = RD_REG_WORD(&reg->nvram);
+		while (data & NVR_BUSY) {
+			udelay(100);
+			data = RD_REG_WORD(&reg->nvram);
+		}
+
+		/* Lock resource */
+		WRT_REG_WORD(&reg->u.isp2300.host_semaphore, 0x1);
+		udelay(5);
+		data = RD_REG_WORD(&reg->u.isp2300.host_semaphore);
+		while ((data & BIT_0) == 0) {
+			/* Lock failed */
+			udelay(100);
+			WRT_REG_WORD(&reg->u.isp2300.host_semaphore, 0x1);
+			udelay(5);
+			data = RD_REG_WORD(&reg->u.isp2300.host_semaphore);
+		}
+	}
+}
+
+/**
+ * qla2x00_unlock_nvram_access() - 
+ * @ha: HA context
+ */
+void
+qla2x00_unlock_nvram_access(scsi_qla_host_t *ha)
+{
+	device_reg_t *reg;
+
+	reg = ha->iobase;
+
+	if (IS_QLA2312(ha) || IS_QLA2322(ha)) 
+		WRT_REG_WORD(&reg->u.isp2300.host_semaphore, 0);
+}
+
+/**
+ * qla2x00_get_nvram_word() - Calculates word position in NVRAM and calls the
+ *	request routine to get the word from NVRAM.
+ * @ha: HA context
+ * @addr: Address in NVRAM to read
+ *
+ * Returns the word read from nvram @addr.
+ */
+uint16_t
+qla2x00_get_nvram_word(scsi_qla_host_t *ha, uint32_t addr)
+{
+	uint16_t	data;
+	uint32_t	nv_cmd;
+
+	nv_cmd = addr << 16;
+	nv_cmd |= NV_READ_OP;
+	data = qla2x00_nvram_request(ha, nv_cmd);
+
+	return (data);
+}
+
+/**
+ * qla2x00_write_nvram_word() - Write NVRAM data.
+ * @ha: HA context
+ * @addr: Address in NVRAM to write
+ * @data: word to program
+ */
+void
+qla2x00_write_nvram_word(scsi_qla_host_t *ha, uint32_t addr, uint16_t data)
+{
+	int count;
+	uint16_t word;
+	uint32_t nv_cmd;
+	device_reg_t *reg = ha->iobase;
+
+	qla2x00_nv_write(ha, NVR_DATA_OUT);
+	qla2x00_nv_write(ha, 0);
+	qla2x00_nv_write(ha, 0);
+
+	for (word = 0; word < 8; word++)
+		qla2x00_nv_write(ha, NVR_DATA_OUT);
+
+	qla2x00_nv_deselect(ha);
+
+	/* Erase Location */
+	nv_cmd = (addr << 16) | NV_ERASE_OP;
+	nv_cmd <<= 5;
+	for (count = 0; count < 11; count++) {
+		if (nv_cmd & BIT_31)
+			qla2x00_nv_write(ha, NVR_DATA_OUT);
+		else
+			qla2x00_nv_write(ha, 0);
+
+		nv_cmd <<= 1;
+	}
+
+	qla2x00_nv_deselect(ha);
+
+	/* Wait for Erase to Finish */
+	WRT_REG_WORD(&reg->nvram, NVR_SELECT);
+	do {
+		NVRAM_DELAY();
+		word = RD_REG_WORD(&reg->nvram);
+	} while ((word & NVR_DATA_IN) == 0);
+
+	qla2x00_nv_deselect(ha);
+
+	/* Write data */
+	nv_cmd = (addr << 16) | NV_WRITE_OP;
+	nv_cmd |= data;
+	nv_cmd <<= 5;
+	for (count = 0; count < 27; count++) {
+		if (nv_cmd & BIT_31)
+			qla2x00_nv_write(ha, NVR_DATA_OUT);
+		else
+			qla2x00_nv_write(ha, 0);
+
+		nv_cmd <<= 1;
+	}
+
+	qla2x00_nv_deselect(ha);
+
+	/* Wait for NVRAM to become ready */
+	WRT_REG_WORD(&reg->nvram, NVR_SELECT);
+	do {
+		NVRAM_DELAY();
+		word = RD_REG_WORD(&reg->nvram);
+	} while ((word & NVR_DATA_IN) == 0);
+
+	qla2x00_nv_deselect(ha);
+
+	/* Disable writes */
+	qla2x00_nv_write(ha, NVR_DATA_OUT);
+	for (count = 0; count < 10; count++)
+		qla2x00_nv_write(ha, 0);
+
+	qla2x00_nv_deselect(ha);
+}
+
+/**
+ * qla2x00_nvram_request() - Sends read command to NVRAM and gets data from
+ *	NVRAM.
+ * @ha: HA context
+ * @nv_cmd: NVRAM command
+ *
+ * Bit definitions for NVRAM command:
+ *
+ *	Bit 26     = start bit
+ *	Bit 25, 24 = opcode
+ *	Bit 23-16  = address
+ *	Bit 15-0   = write data
+ *
+ * Returns the word read from nvram @addr.
+ */
+static uint16_t
+qla2x00_nvram_request(scsi_qla_host_t *ha, uint32_t nv_cmd)
+{
+	uint8_t		cnt;
+	device_reg_t	*reg = ha->iobase;
+	uint16_t	data = 0;
+	uint16_t	reg_data;
+
+	/* Send command to NVRAM. */
+	nv_cmd <<= 5;
+	for (cnt = 0; cnt < 11; cnt++) {
+		if (nv_cmd & BIT_31)
+			qla2x00_nv_write(ha, NVR_DATA_OUT);
+		else
+			qla2x00_nv_write(ha, 0);
+		nv_cmd <<= 1;
+	}
+
+	/* Read data from NVRAM. */
+	for (cnt = 0; cnt < 16; cnt++) {
+		WRT_REG_WORD(&reg->nvram, NVR_SELECT | NVR_CLOCK);
+		NVRAM_DELAY();
+		data <<= 1;
+		reg_data = RD_REG_WORD(&reg->nvram);
+		if (reg_data & NVR_DATA_IN)
+			data |= BIT_0;
+		WRT_REG_WORD(&reg->nvram, NVR_SELECT);
+		NVRAM_DELAY();
+		RD_REG_WORD(&reg->nvram);	/* PCI Posting. */
+	}
+
+	/* Deselect chip. */
+	WRT_REG_WORD(&reg->nvram, NVR_DESELECT);
+	NVRAM_DELAY();
+	RD_REG_WORD(&reg->nvram);		/* PCI Posting. */
+
+	return (data);
+}
+
+/**
+ * qla2x00_nv_write() - Clean NVRAM operations.
+ * @ha: HA context
+ */
+void
+qla2x00_nv_deselect(scsi_qla_host_t *ha)
+{
+	device_reg_t *reg = ha->iobase;
+
+	WRT_REG_WORD(&reg->nvram, NVR_DESELECT);
+	NVRAM_DELAY();
+	RD_REG_WORD(&reg->nvram);		/* PCI Posting. */
+}
+
+/**
+ * qla2x00_nv_write() - Prepare for NVRAM read/write operation.
+ * @ha: HA context
+ * @data: Serial interface selector
+ */
+void
+qla2x00_nv_write(scsi_qla_host_t *ha, uint16_t data)
+{
+	device_reg_t *reg = ha->iobase;
+
+	WRT_REG_WORD(&reg->nvram, data | NVR_SELECT);
+	NVRAM_DELAY();
+	RD_REG_WORD(&reg->nvram);		/* PCI Posting. */
+	WRT_REG_WORD(&reg->nvram, data | NVR_SELECT | NVR_CLOCK);
+	NVRAM_DELAY();
+	RD_REG_WORD(&reg->nvram);		/* PCI Posting. */
+	WRT_REG_WORD(&reg->nvram, data | NVR_SELECT);
+	NVRAM_DELAY();
+	RD_REG_WORD(&reg->nvram);		/* PCI Posting. */
+}
+
+/*
+ * Flash support routines
+ */
+
+/**
+ * qla2x00_flash_enable() - Setup flash for reading and writing.
+ * @ha: HA context
+ */
+void
+qla2x00_flash_enable(scsi_qla_host_t *ha)
+{
+	uint16_t	data;
+	device_reg_t	*reg = ha->iobase;
+
+	data = RD_REG_WORD(&reg->ctrl_status);
+	data |= CSR_FLASH_ENABLE;
+	WRT_REG_WORD(&reg->ctrl_status, data);
+}
+
+/**
+ * qla2x00_flash_disable() - Disable flash and allow RISC to run.
+ * @ha: HA context
+ */
+void
+qla2x00_flash_disable(scsi_qla_host_t *ha)
+{
+	uint16_t	data;
+	device_reg_t	*reg = ha->iobase;
+
+	data = RD_REG_WORD(&reg->ctrl_status);
+	data &= ~(CSR_FLASH_ENABLE);
+	WRT_REG_WORD(&reg->ctrl_status, data);
+}
+
+/**
+ * qla2x00_read_flash_byte() - Reads a byte from flash
+ * @ha: HA context
+ * @addr: Address in flash to read
+ *
+ * A word is read from the chip, but, only the lower byte is valid.
+ *
+ * Returns the byte read from flash @addr.
+ */
+uint8_t
+qla2x00_read_flash_byte(scsi_qla_host_t *ha, uint32_t addr)
+{
+	uint16_t	data;
+	uint16_t	bank_select;
+	device_reg_t	*reg = ha->iobase;
+
+	/* Setup bit 16 of flash address. */
+	bank_select = RD_REG_WORD(&reg->ctrl_status);
+	if ((addr & BIT_16) && ((bank_select & CSR_FLASH_64K_BANK) == 0)) {
+		bank_select |= CSR_FLASH_64K_BANK;
+		WRT_REG_WORD(&reg->ctrl_status, bank_select);
+	} else if (((addr & BIT_16) == 0) &&
+	    (bank_select & CSR_FLASH_64K_BANK)) {
+		bank_select &= ~(CSR_FLASH_64K_BANK);
+		WRT_REG_WORD(&reg->ctrl_status, bank_select);
+	}
+	WRT_REG_WORD(&reg->flash_address, (uint16_t)addr);
+	data = qla2x00_debounce_register(&reg->flash_data);
+
+	return ((uint8_t)data);
+}
+
+/**
+ * qla2x00_write_flash_byte() - Write a byte to flash
+ * @ha: HA context
+ * @addr: Address in flash to write
+ * @data: Data to write
+ */
+static void
+qla2x00_write_flash_byte(scsi_qla_host_t *ha, uint32_t addr, uint8_t data)
+{
+	uint16_t	bank_select;
+	device_reg_t	*reg = ha->iobase;
+
+	/* Setup bit 16 of flash address. */
+	bank_select = RD_REG_WORD(&reg->ctrl_status);
+	if ((addr & BIT_16) && ((bank_select & CSR_FLASH_64K_BANK) == 0)) {
+		bank_select |= CSR_FLASH_64K_BANK;
+		WRT_REG_WORD(&reg->ctrl_status, bank_select);
+	} else if (((addr & BIT_16) == 0) &&
+	    (bank_select & CSR_FLASH_64K_BANK)) {
+		bank_select &= ~(CSR_FLASH_64K_BANK);
+		WRT_REG_WORD(&reg->ctrl_status, bank_select);
+	}
+	WRT_REG_WORD(&reg->flash_address, (uint16_t)addr);
+	WRT_REG_WORD(&reg->flash_data, (uint16_t)data);
+}
+
+/**
+ * qla2x00_poll_flash() - Polls flash for completion.
+ * @ha: HA context
+ * @addr: Address in flash to poll
+ * @poll_data: Data to be polled
+ * @mid: Flash manufacturer ID
+ *
+ * This function polls the device until bit 7 of what is read matches data
+ * bit 7 or until data bit 5 becomes a 1.  If that hapens, the flash ROM timed
+ * out (a fatal error).  The flash book recommeds reading bit 7 again after
+ * reading bit 5 as a 1.
+ *
+ * Returns 0 on success, else non-zero.
+ */
+static uint8_t
+qla2x00_poll_flash(scsi_qla_host_t *ha,
+    uint32_t addr, uint8_t poll_data, uint8_t mid)
+{
+	uint8_t		status;
+	uint8_t		flash_data;
+	uint32_t	cnt;
+	int		failed_pass;
+
+	status = 1;
+	failed_pass = 1;
+
+	/* Wait for 30 seconds for command to finish. */
+	poll_data &= BIT_7;
+	for (cnt = 3000000; cnt; cnt--) {
+		flash_data = qla2x00_read_flash_byte(ha, addr);
+		if ((flash_data & BIT_7) == poll_data) {
+			status = 0;
+			break;
+		}
+
+		if (mid != 0x40 && mid != 0xda) {
+			if (flash_data & BIT_5)
+				failed_pass--;
+			if (failed_pass < 0)
+				break;
+		}
+		udelay(10);
+		barrier();
+	}
+	return (status);
+}
+
+/**
+ * qla2x00_program_flash_address() - Programs a flash address
+ * @ha: HA context
+ * @addr: Address in flash to program
+ * @data: Data to be written in flash
+ * @mid: Flash manufacturer ID
+ *
+ * Returns 0 on success, else non-zero.
+ */
+static uint8_t
+qla2x00_program_flash_address(scsi_qla_host_t *ha,
+    uint32_t addr, uint8_t data, uint8_t mid)
+{
+	/* Write Program Command Sequence */
+	qla2x00_write_flash_byte(ha, 0x5555, 0xaa);
+	qla2x00_write_flash_byte(ha, 0x2aaa, 0x55);
+	qla2x00_write_flash_byte(ha, 0x5555, 0xa0);
+	qla2x00_write_flash_byte(ha, addr, data);
+
+	/* Wait for write to complete. */
+	return (qla2x00_poll_flash(ha, addr, data, mid));
+}
+
+/**
+ * qla2x00_erase_flash_sector() - Erase a flash sector.
+ * @ha: HA context
+ * @addr: Flash sector to erase
+ * @sec_mask: Sector address mask
+ * @mid: Flash manufacturer ID
+ *
+ * Returns 0 on success, else non-zero.
+ */
+static uint8_t
+qla2x00_erase_flash_sector(scsi_qla_host_t *ha,
+    uint32_t addr, uint32_t sec_mask, uint8_t mid)
+{
+	/* Individual Sector Erase Command Sequence */
+	qla2x00_write_flash_byte(ha, 0x5555, 0xaa);
+	qla2x00_write_flash_byte(ha, 0x2aaa, 0x55);
+	qla2x00_write_flash_byte(ha, 0x5555, 0x80);
+	qla2x00_write_flash_byte(ha, 0x5555, 0xaa);
+	qla2x00_write_flash_byte(ha, 0x2aaa, 0x55);
+
+	if (mid == 0xda)
+		qla2x00_write_flash_byte(ha, addr & sec_mask, 0x10);
+	else
+		qla2x00_write_flash_byte(ha, addr & sec_mask, 0x30);
+
+	udelay(150);
+
+	/* Wait for erase to complete. */
+	return (qla2x00_poll_flash(ha, addr, 0x80, mid));
+}
+
+/**
+ * qla2x00_get_flash_manufacturer() - Read manufacturer ID from flash chip.
+ * @ha: HA context
+ *
+ * Returns the manufacturer's ID read from the flash chip.
+ */
+uint8_t
+qla2x00_get_flash_manufacturer(scsi_qla_host_t *ha)
+{
+	uint8_t	manuf_id;
+
+	qla2x00_write_flash_byte(ha, 0x5555, 0xaa);
+	qla2x00_write_flash_byte(ha, 0x2aaa, 0x55);
+	qla2x00_write_flash_byte(ha, 0x5555, 0x90);
+	manuf_id = qla2x00_read_flash_byte(ha, 0x0001);
+
+	return (manuf_id);
+}
+
+/**
+ * qla2x00_get_flash_version() - Read version information from flash.
+ * @ha: HA context
+ *
+ * Returns QLA_SUCCESS on successful retrieval of flash version.
+ */
+uint16_t
+qla2x00_get_flash_version(scsi_qla_host_t *ha)
+{
+	uint16_t	ret = QLA_SUCCESS;
+	uint32_t	loop_cnt = 1;  /* this is for error exit only */
+	uint32_t	pcir_adr;
+
+	ENTER(__func__);
+
+	qla2x00_flash_enable(ha);
+	do {	/* Loop once to provide quick error exit */
+		/* Match signature */
+		if (!(qla2x00_read_flash_byte(ha, 0) == 0x55 &&
+		    qla2x00_read_flash_byte(ha, 1) == 0xaa)) {
+			/* No signature */
+			DEBUG2(printk("scsi(%ld): No matching FLASH "
+			    "signature.\n", ha->host_no));
+			ret = QLA_FUNCTION_FAILED;
+			break;
+		}
+
+		pcir_adr = qla2x00_read_flash_byte(ha, 0x18) & 0xff;
+
+		/* validate signature of PCI data structure */
+		if ((qla2x00_read_flash_byte(ha, pcir_adr)) == 'P' &&
+		    (qla2x00_read_flash_byte(ha, pcir_adr + 1)) == 'C' &&
+		    (qla2x00_read_flash_byte(ha, pcir_adr + 2)) == 'I' &&
+		    (qla2x00_read_flash_byte(ha, pcir_adr + 3)) == 'R') {
+
+			/* Read version */
+			ha->optrom_minor =
+			    qla2x00_read_flash_byte(ha, pcir_adr + 0x12);
+			ha->optrom_major =
+			    qla2x00_read_flash_byte(ha, pcir_adr + 0x13);
+			DEBUG3(printk("%s(): got %d.%d.\n",
+			    __func__, ha->optrom_major, ha->optrom_minor));
+		} else {
+			/* error */
+			DEBUG2(printk("%s(): PCI data struct not found. "
+			    "pcir_adr=%x.\n",
+			    __func__, pcir_adr));
+			ret = QLA_FUNCTION_FAILED;
+			break;
+		}
+
+	} while (--loop_cnt);
+	qla2x00_flash_disable(ha);
+
+	LEAVE(__func__);
+
+	return (ret);
+}
+
+/**
+ * qla2x00_get_flash_image() - Read image from flash chip.
+ * @ha: HA context
+ * @image: Buffer to receive flash image
+ *
+ * Returns 0 on success, else non-zero.
+ */
+uint16_t
+qla2x00_get_flash_image(scsi_qla_host_t *ha, uint8_t *image)
+{
+	uint32_t	addr;
+	uint32_t	midpoint;
+	uint8_t		*data;
+	device_reg_t	*reg = ha->iobase;
+
+	midpoint = FLASH_IMAGE_SIZE / 2;
+
+	qla2x00_flash_enable(ha);
+	WRT_REG_WORD(&reg->nvram, 0);
+	for (addr = 0, data = image; addr < FLASH_IMAGE_SIZE; addr++, data++) {
+		if (addr == midpoint)
+			WRT_REG_WORD(&reg->nvram, NVR_SELECT);
+
+		*data = qla2x00_read_flash_byte(ha, addr);
+	}
+	qla2x00_flash_disable(ha);
+
+	return (0);
+}
+
+/**
+ * qla2x00_set_flash_image() - Write image to flash chip.
+ * @ha: HA context
+ * @image: Source image to write to flash
+ *
+ * Returns 0 on success, else non-zero.
+ */
+uint16_t
+qla2x00_set_flash_image(scsi_qla_host_t *ha, uint8_t *image)
+{
+	uint16_t	status;
+	uint32_t	addr;
+	uint32_t	midpoint;
+	uint32_t	sec_mask;
+	uint32_t	rest_addr;
+	uint8_t		mid;
+	uint8_t		sec_number;
+	uint8_t		data;
+	device_reg_t	*reg = ha->iobase;
+
+	status = 0;
+	sec_number = 0;
+
+	/* Reset ISP chip. */
+	WRT_REG_WORD(&reg->ctrl_status, CSR_ISP_SOFT_RESET);
+
+	qla2x00_flash_enable(ha);
+	do {	/* Loop once to provide quick error exit */
+		/* Structure of flash memory based on manufacturer */
+		mid = qla2x00_get_flash_manufacturer(ha);
+		if (mid == 0x6d) {
+			// Am29LV001 part
+			rest_addr = 0x1fff;
+			sec_mask = 0x1e000;
+		} else if (mid == 0x40) {
+			// Mostel v29c51001 part
+			rest_addr = 0x1ff;
+			sec_mask = 0x1fe00;
+		} else if (mid == 0xbf) {
+			// SST39sf10 part
+			rest_addr = 0xfff;
+			sec_mask = 0x1f000;
+		} else if (mid == 0xda) {
+			// Winbond W29EE011 part
+			rest_addr = 0x7f;
+			sec_mask = 0x1ff80;
+			addr = 0;
+			if (qla2x00_erase_flash_sector(ha, addr, sec_mask,
+			    mid)) {
+				status = 1;
+				break;
+			}
+		} else {
+			// Am29F010 part
+			rest_addr = 0x3fff;
+			sec_mask = 0x1c000;
+		}
+
+		midpoint = FLASH_IMAGE_SIZE / 2;
+		for (addr = 0; addr < FLASH_IMAGE_SIZE; addr++) {
+			data = *image++;
+			/* Are we at the beginning of a sector? */
+			if (!(addr & rest_addr)) {
+				if (addr == midpoint)
+					WRT_REG_WORD(&reg->nvram, NVR_SELECT);
+
+				/* Then erase it */
+				if (qla2x00_erase_flash_sector(ha, addr,
+				    sec_mask, mid)) {
+					status = 1;
+					break;
+				}
+
+				sec_number++;
+			}
+			if (mid == 0x6d) {
+				if (sec_number == 1 &&
+				    (addr == (rest_addr - 1))) {
+					rest_addr = 0x0fff;
+					sec_mask   = 0x1f000;
+				} else if (sec_number == 3 && (addr & 0x7ffe)) {
+					rest_addr = 0x3fff;
+					sec_mask   = 0x1c000;
+				}
+			}
+
+			if (qla2x00_program_flash_address(ha, addr, data,
+			    mid)) {
+				status = 1;
+				break;
+			}
+		}
+	} while (0);
+
+	qla2x00_flash_disable(ha);
+
+	return (status);
+}
diff -puN /dev/null drivers/scsi/qla2xxx/qla_version.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/scsi/qla2xxx/qla_version.h	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,27 @@
+/******************************************************************************
+ *                  QLOGIC LINUX SOFTWARE
+ *
+ * QLogic ISP2x00 device driver for Linux 2.6.x
+ * Copyright (C) 2003 QLogic Corporation
+ * (www.qlogic.com)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ ******************************************************************************/
+/*
+ * Driver version 
+ */
+#define QLA2XXX_VERSION      "8.00.00b8"
+
+#define QLA_DRIVER_MAJOR_VER	8
+#define QLA_DRIVER_MINOR_VER	0
+#define QLA_DRIVER_PATCH_VER	0
+#define QLA_DRIVER_BETA_VER	8
diff -puN drivers/scsi/qlogicpti.c~linus drivers/scsi/qlogicpti.c
--- 25/drivers/scsi/qlogicpti.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/qlogicpti.c	2004-01-19 22:17:23.000000000 -0800
@@ -319,7 +319,7 @@ static int qlogicpti_reset_hardware(stru
 
 	risc_code_addr = 0x1000;	/* all load addresses are at 0x1000 */
 
-	spin_lock_irqsave(&qpti->lock, flags);
+	spin_lock_irqsave(host->host_lock, flags);
 
 	sbus_writew(HCCTRL_PAUSE, qpti->qregs + HCCTRL);
 
@@ -367,7 +367,7 @@ static int qlogicpti_reset_hardware(stru
 	if (qlogicpti_mbox_command(qpti, param, 1)) {
 		printk(KERN_EMERG "qlogicpti%d: Cannot execute ISP firmware.\n",
 		       qpti->qpti_id);
-		spin_unlock_irqrestore(&qpti->lock, flags);
+		spin_unlock_irqrestore(host->host_lock, flags);
 		return 1;
 	}
 
@@ -378,7 +378,7 @@ static int qlogicpti_reset_hardware(stru
 	   (param[0] != MBOX_COMMAND_COMPLETE)) {
 		printk(KERN_EMERG "qlogicpti%d: Cannot set initiator SCSI ID.\n",
 		       qpti->qpti_id);
-		spin_unlock_irqrestore(&qpti->lock, flags);
+		spin_unlock_irqrestore(host->host_lock, flags);
 		return 1;
 	}
 
@@ -393,7 +393,7 @@ static int qlogicpti_reset_hardware(stru
 	if (qlogicpti_mbox_command(qpti, param, 1)) {
 		printk(KERN_EMERG "qlogicpti%d: Cannot init response queue.\n",
 		       qpti->qpti_id);
-		spin_unlock_irqrestore(&qpti->lock, flags);
+		spin_unlock_irqrestore(host->host_lock, flags);
 		return 1;
 	}
 
@@ -405,7 +405,7 @@ static int qlogicpti_reset_hardware(stru
 	if (qlogicpti_mbox_command(qpti, param, 1)) {
 		printk(KERN_EMERG "qlogicpti%d: Cannot init request queue.\n",
 		       qpti->qpti_id);
-		spin_unlock_irqrestore(&qpti->lock, flags);
+		spin_unlock_irqrestore(host->host_lock, flags);
 		return 1;
 	}
 
@@ -451,7 +451,7 @@ static int qlogicpti_reset_hardware(stru
 	qlogicpti_mbox_command(qpti, param, 0);
 	qpti->send_marker = 1;
 
-	spin_unlock_irqrestore(&qpti->lock, flags);
+	spin_unlock_irqrestore(host->host_lock, flags);
 	return 0;
 }
 
@@ -459,6 +459,7 @@ static int qlogicpti_reset_hardware(stru
 
 static int __init qlogicpti_load_firmware(struct qlogicpti *qpti)
 {
+	struct Scsi_Host *host = qpti->qhost;
 	unsigned short csum = 0;
 	unsigned short param[6];
 	unsigned short *risc_code, risc_code_addr, risc_code_length;
@@ -469,7 +470,7 @@ static int __init qlogicpti_load_firmwar
 	risc_code_addr = 0x1000;	/* all f/w modules load at 0x1000 */
 	risc_code_length = sbus_risc_code_length01;
 
-	spin_lock_irqsave(&qpti->lock, flags);
+	spin_lock_irqsave(host->host_lock, flags);
 
 	/* Verify the checksum twice, one before loading it, and once
 	 * afterwards via the mailbox commands.
@@ -477,7 +478,7 @@ static int __init qlogicpti_load_firmwar
 	for (i = 0; i < risc_code_length; i++)
 		csum += risc_code[i];
 	if (csum) {
-		spin_unlock_irqrestore(&qpti->lock, flags);
+		spin_unlock_irqrestore(host->host_lock, flags);
 		printk(KERN_EMERG "qlogicpti%d: Aieee, firmware checksum failed!",
 		       qpti->qpti_id);
 		return 1;
@@ -489,7 +490,7 @@ static int __init qlogicpti_load_firmwar
 	while (--timeout && (sbus_readw(qpti->qregs + SBUS_CTRL) & SBUS_CTRL_RESET))
 		udelay(20);
 	if (!timeout) {
-		spin_unlock_irqrestore(&qpti->lock, flags);
+		spin_unlock_irqrestore(host->host_lock, flags);
 		printk(KERN_EMERG "qlogicpti%d: Cannot reset the ISP.", qpti->qpti_id);
 		return 1;
 	}
@@ -529,7 +530,7 @@ static int __init qlogicpti_load_firmwar
 	if (qlogicpti_mbox_command(qpti, param, 1)) {
 		printk(KERN_EMERG "qlogicpti%d: Cannot stop firmware for reload.\n",
 		       qpti->qpti_id);
-		spin_unlock_irqrestore(&qpti->lock, flags);
+		spin_unlock_irqrestore(host->host_lock, flags);
 		return 1;
 	}		
 
@@ -542,7 +543,7 @@ static int __init qlogicpti_load_firmwar
 		    param[0] != MBOX_COMMAND_COMPLETE) {
 			printk("qlogicpti%d: Firmware dload failed, I'm bolixed!\n",
 			       qpti->qpti_id);
-			spin_unlock_irqrestore(&qpti->lock, flags);
+			spin_unlock_irqrestore(host->host_lock, flags);
 			return 1;
 		}
 	}
@@ -562,7 +563,7 @@ static int __init qlogicpti_load_firmwar
 	    (param[0] != MBOX_COMMAND_COMPLETE)) {
 		printk(KERN_EMERG "qlogicpti%d: New firmware csum failure!\n",
 		       qpti->qpti_id);
-		spin_unlock_irqrestore(&qpti->lock, flags);
+		spin_unlock_irqrestore(host->host_lock, flags);
 		return 1;
 	}
 
@@ -576,7 +577,7 @@ static int __init qlogicpti_load_firmwar
 	    (param[0] != MBOX_COMMAND_COMPLETE)) {
 		printk(KERN_EMERG "qlogicpti%d: AboutFirmware cmd fails.\n",
 		       qpti->qpti_id);
-		spin_unlock_irqrestore(&qpti->lock, flags);
+		spin_unlock_irqrestore(host->host_lock, flags);
 		return 1;
 	}
 
@@ -592,7 +593,7 @@ static int __init qlogicpti_load_firmwar
 	    (param[0] != MBOX_COMMAND_COMPLETE)) {
 		printk(KERN_EMERG "qlogicpti%d: could not set clock rate.\n",
 		       qpti->qpti_id);
-		spin_unlock_irqrestore(&qpti->lock, flags);
+		spin_unlock_irqrestore(host->host_lock, flags);
 		return 1;
 	}
 
@@ -609,7 +610,7 @@ static int __init qlogicpti_load_firmwar
 		qlogicpti_mbox_command(qpti, param, 1);
 	}
 
-	spin_unlock_irqrestore(&qpti->lock, flags);
+	spin_unlock_irqrestore(host->host_lock, flags);
 	return 0;
 }
 
@@ -844,8 +845,6 @@ static int __init qlogicpti_detect(Scsi_
 			}
 			qpti = (struct qlogicpti *) qpti_host->hostdata;
 
-			spin_lock_init(&qpti->lock);
-
 			/* We are wide capable, 16 targets. */
 			qpti_host->max_id = MAX_TARGETS;
 
@@ -1171,7 +1170,6 @@ static int qlogicpti_queuecommand_slow(S
 				       void (*done)(Scsi_Cmnd *))
 {
 	struct qlogicpti *qpti = (struct qlogicpti *) Cmnd->device->host->hostdata;
-	unsigned long flags;
 
 	/*
 	 * done checking this host adapter?
@@ -1188,8 +1186,6 @@ static int qlogicpti_queuecommand_slow(S
 		return qlogicpti_queuecommand(Cmnd, ourdone);
 	}
 
-	spin_lock_irqsave(&qpti->lock, flags);
-
 	/*
 	 * We've peeked at all targets for this bus- time
 	 * to set parameters for devices for real now.
@@ -1231,8 +1227,6 @@ static int qlogicpti_queuecommand_slow(S
 	if (qpti == NULL)
 		Cmnd->device->host->hostt->queuecommand = qlogicpti_queuecommand;
 
-	spin_unlock_irqrestore(&qpti->lock, flags);
-
 	return qlogicpti_queuecommand(Cmnd, done);
 }
 
@@ -1249,14 +1243,11 @@ static int qlogicpti_queuecommand(Scsi_C
 	struct Scsi_Host *host = Cmnd->device->host;
 	struct qlogicpti *qpti = (struct qlogicpti *) host->hostdata;
 	struct Command_Entry *cmd;
-	unsigned long flags;
 	u_int out_ptr;
 	int in_ptr;
 
 	Cmnd->scsi_done = done;
 
-	spin_lock_irqsave(&qpti->lock, flags);
-
 	in_ptr = qpti->req_in_ptr;
 	cmd = (struct Command_Entry *) &qpti->req_cpu[in_ptr];
 	out_ptr = sbus_readw(qpti->qregs + MBOX4);
@@ -1281,15 +1272,12 @@ static int qlogicpti_queuecommand(Scsi_C
 
 	update_can_queue(host, in_ptr, out_ptr);
 
-	spin_unlock_irqrestore(&qpti->lock, flags);
 	return 0;
 
 toss_command:
 	printk(KERN_EMERG "qlogicpti%d: request queue overflow\n",
 	       qpti->qpti_id);
 
-	spin_unlock_irqrestore(&qpti->lock, flags);
-
 	/* Unfortunately, unless you use the new EH code, which
 	 * we don't, the midlayer will ignore the return value,
 	 * which is insane.  We pick up the pieces like this.
@@ -1447,12 +1435,10 @@ static irqreturn_t qpti_intr(int irq, vo
 	unsigned long flags;
 	Scsi_Cmnd *dq;
 
-	spin_lock_irqsave(&qpti->lock, flags);
+	spin_lock_irqsave(qpti->qhost->host_lock, flags);
 	dq = qlogicpti_intr_handler(qpti);
-	spin_unlock(&qpti->lock);
 
 	if (dq != NULL) {
-		spin_lock(qpti->qhost->host_lock);
 		do {
 			Scsi_Cmnd *next;
 
@@ -1460,9 +1446,8 @@ static irqreturn_t qpti_intr(int irq, vo
 			dq->scsi_done(dq);
 			dq = next;
 		} while (dq != NULL);
-		spin_unlock(qpti->qhost->host_lock);
 	}
-	local_irq_restore(flags);
+	spin_unlock_irqrestore(qpti->qhost->host_lock, flags);
 
 	return IRQ_HANDLED;
 }
@@ -1473,15 +1458,12 @@ static int qlogicpti_abort(Scsi_Cmnd *Cm
 	struct Scsi_Host *host = Cmnd->device->host;
 	struct qlogicpti *qpti = (struct qlogicpti *) host->hostdata;
 	int return_status = SUCCESS;
-	unsigned long flags;
 	u32 cmd_cookie;
 	int i;
 
 	printk(KERN_WARNING "qlogicpti : Aborting cmd for tgt[%d] lun[%d]\n",
 	       (int)Cmnd->device->id, (int)Cmnd->device->lun);
 
-	spin_lock_irqsave(&qpti->lock, flags);
-
 	qlogicpti_disable_irqs(qpti);
 
 	/* Find the 32-bit cookie we gave to the firmware for
@@ -1504,8 +1486,6 @@ static int qlogicpti_abort(Scsi_Cmnd *Cm
 
 	qlogicpti_enable_irqs(qpti);
 
-	spin_unlock_irqrestore(&qpti->lock, flags);
-
 	return return_status;
 }
 
@@ -1515,12 +1495,9 @@ static int qlogicpti_reset(Scsi_Cmnd *Cm
 	struct Scsi_Host *host = Cmnd->device->host;
 	struct qlogicpti *qpti = (struct qlogicpti *) host->hostdata;
 	int return_status = SUCCESS;
-	unsigned long flags;
 
 	printk(KERN_WARNING "qlogicpti : Resetting SCSI bus!\n");
 
-	spin_lock_irqsave(&qpti->lock, flags);
-
 	qlogicpti_disable_irqs(qpti);
 
 	param[0] = MBOX_BUS_RESET;
@@ -1533,8 +1510,6 @@ static int qlogicpti_reset(Scsi_Cmnd *Cm
 
 	qlogicpti_enable_irqs(qpti);
 
-	spin_unlock_irqrestore(&qpti->lock, flags);
-
 	return return_status;
 }
 
diff -puN drivers/scsi/qlogicpti.h~linus drivers/scsi/qlogicpti.h
--- 25/drivers/scsi/qlogicpti.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/qlogicpti.h	2004-01-19 22:17:23.000000000 -0800
@@ -335,7 +335,6 @@ struct pti_queue_entry {
 /* Software state for the driver. */
 struct qlogicpti {
 	/* These are the hot elements in the cache, so they come first. */
-	spinlock_t		  lock;			/* Driver mutex		      */
 	unsigned long             qregs;                /* Adapter registers          */
 	struct pti_queue_entry   *res_cpu;              /* Ptr to RESPONSE bufs (CPU) */
 	struct pti_queue_entry   *req_cpu;              /* Ptr to REQUEST bufs (CPU)  */
diff -puN drivers/scsi/scsi.c~linus drivers/scsi/scsi.c
--- 25/drivers/scsi/scsi.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/scsi.c	2004-01-19 22:17:23.000000000 -0800
@@ -142,6 +142,21 @@ struct scsi_request *scsi_allocate_reque
 
 void __scsi_release_request(struct scsi_request *sreq)
 {
+	struct request *req = sreq->sr_request;
+
+	/* unlikely because the tag was usually ended earlier by the
+	 * mid-layer. However, for layering reasons ULD's don't end
+	 * the tag of commands they generate. */
+	if (unlikely(blk_rq_tagged(req))) {
+		unsigned long flags;
+		struct request_queue *q = req->q;
+
+		spin_lock_irqsave(q->queue_lock, flags);
+		blk_queue_end_tag(q, req);
+		spin_unlock_irqrestore(q->queue_lock, flags);
+	}
+
+
 	if (likely(sreq->sr_command != NULL)) {
 		struct scsi_cmnd *cmd = sreq->sr_command;
 
@@ -441,7 +456,7 @@ void scsi_log_completion(struct scsi_cmn
 			case FAILED:
 				printk("FAILED ");
 				break;
-			case TIMEOUT:
+			case TIMEOUT_ERROR:
 				/* 
 				 * If called via scsi_times_out.
 				 */
diff -puN drivers/scsi/scsi_error.c~linus drivers/scsi/scsi_error.c
--- 25/drivers/scsi/scsi_error.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/scsi_error.c	2004-01-19 22:17:23.000000000 -0800
@@ -164,7 +164,7 @@ int scsi_delete_timer(struct scsi_cmnd *
  **/
 void scsi_times_out(struct scsi_cmnd *scmd)
 {
-	scsi_log_completion(scmd, TIMEOUT);
+	scsi_log_completion(scmd, TIMEOUT_ERROR);
 	if (unlikely(!scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD))) {
 		panic("Error handler thread not present at %p %p %s %d",
 		      scmd, scmd->device->host, __FILE__, __LINE__);
@@ -1420,23 +1420,21 @@ static void scsi_eh_flush_done_q(struct 
 	list_for_each_safe(lh, lh_sf, done_q) {
 		scmd = list_entry(lh, struct scsi_cmnd, eh_entry);
 		list_del_init(lh);
-		if (!scmd->device->online) {
-			 scmd->result |= (DRIVER_TIMEOUT << 24);
-		} else {
-			if (++scmd->retries < scmd->allowed) {
-				SCSI_LOG_ERROR_RECOVERY(3,
-					printk("%s: flush retry"
-					       " cmd: %p\n",
-						  current->comm,
-						  scmd));
+		if (scmd->device->online &&
+		    	(++scmd->retries < scmd->allowed)) {
+			SCSI_LOG_ERROR_RECOVERY(3, printk("%s: flush"
+							  " retry cmd: %p\n",
+							  current->comm,
+							  scmd));
 				scsi_queue_insert(scmd, SCSI_MLQUEUE_EH_RETRY);
-				continue;
-			}
+		} else {
+			if (!scmd->result)
+				scmd->result |= (DRIVER_TIMEOUT << 24);
+			SCSI_LOG_ERROR_RECOVERY(3, printk("%s: flush finish"
+							" cmd: %p\n",
+							current->comm, scmd));
+			scsi_finish_command(scmd);
 		}
-		SCSI_LOG_ERROR_RECOVERY(3, printk("%s: flush finish"
-				       " cmd: %p\n",
-					  current->comm, scmd));
-		scsi_finish_command(scmd);
 	}
 }
 
diff -puN drivers/scsi/scsi_scan.c~linus drivers/scsi/scsi_scan.c
--- 25/drivers/scsi/scsi_scan.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/scsi_scan.c	2004-01-19 22:17:23.000000000 -0800
@@ -254,7 +254,7 @@ static struct scsi_device *scsi_alloc_sd
 			 "%d:%d:%d:%d", sdev->host->host_no,
 			 sdev->channel, sdev->id, sdev->lun);
 	} else
-		goto out_free_queue;
+		goto out_cleanup_slave;
 
 	/*
 	 * If there are any same target siblings, add this to the
@@ -283,6 +283,9 @@ static struct scsi_device *scsi_alloc_sd
 	spin_unlock_irqrestore(shost->host_lock, flags);
 	return sdev;
 
+out_cleanup_slave:
+	if (shost->hostt->slave_destroy)
+		shost->hostt->slave_destroy(sdev);
 out_free_queue:
 	scsi_free_queue(sdev->request_queue);
 out_free_dev:
diff -puN drivers/scsi/scsi_sysfs.c~linus drivers/scsi/scsi_sysfs.c
--- 25/drivers/scsi/scsi_sysfs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/scsi_sysfs.c	2004-01-19 22:17:23.000000000 -0800
@@ -361,7 +361,6 @@ int scsi_sysfs_add_sdev(struct scsi_devi
 	if (error) {
 		printk(KERN_INFO "error 2\n");
 		goto clean_device;
-		return error;
 	}
 
 	get_device(&sdev->sdev_gendev);
@@ -370,8 +369,10 @@ int scsi_sysfs_add_sdev(struct scsi_devi
 		for (i = 0; sdev->host->hostt->sdev_attrs[i]; i++) {
 			error = attr_add(&sdev->sdev_gendev,
 					sdev->host->hostt->sdev_attrs[i]);
-			if (error)
+			if (error) {
 				scsi_remove_device(sdev);
+				goto out;
+			}
 		}
 	}
 	
@@ -380,11 +381,14 @@ int scsi_sysfs_add_sdev(struct scsi_devi
 					scsi_sysfs_sdev_attrs[i])) {
 			error = device_create_file(&sdev->sdev_gendev,
 					scsi_sysfs_sdev_attrs[i]);
-			if (error)
+			if (error) {
 				scsi_remove_device(sdev);
+				goto out;
+			}
 		}
 	}
 
+ out:
 	return error;
 
 clean_device:
@@ -394,7 +398,6 @@ clean_device:
 	put_device(&sdev->sdev_gendev);
 
 	return error;
-
 }
 
 /**
diff -puN drivers/scsi/sr.c~linus drivers/scsi/sr.c
--- 25/drivers/scsi/sr.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/sr.c	2004-01-19 22:17:23.000000000 -0800
@@ -67,7 +67,8 @@ MODULE_PARM(xa_test, "i");	/* see sr_ioc
 	(CDC_CLOSE_TRAY|CDC_OPEN_TRAY|CDC_LOCK|CDC_SELECT_SPEED| \
 	 CDC_SELECT_DISC|CDC_MULTI_SESSION|CDC_MCN|CDC_MEDIA_CHANGED| \
 	 CDC_PLAY_AUDIO|CDC_RESET|CDC_IOCTLS|CDC_DRIVE_STATUS| \
-	 CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_DVD_RAM|CDC_GENERIC_PACKET)
+	 CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_DVD_RAM|CDC_GENERIC_PACKET| \
+	 CDC_MRW|CDC_MRW_W|CDC_RAM)
 
 static int sr_probe(struct device *);
 static int sr_remove(struct device *);
@@ -692,7 +693,7 @@ Enomem:
 static void get_capabilities(struct scsi_cd *cd)
 {
 	unsigned char *buffer;
-	int rc, n;
+	int rc, n, mrw_write = 0, mrw = 1;
 	struct scsi_mode_data data;
 	struct scsi_request *SRpnt;
 	unsigned char cmd[MAX_COMMAND_SIZE];
@@ -765,6 +766,15 @@ static void get_capabilities(struct scsi
 		printk("%s: scsi-1 drive\n", cd->cdi.name);
 		return;
 	}
+
+	if (cdrom_is_mrw(&cd->cdi, &mrw_write)) {
+		mrw = 0;
+		cd->cdi.mask |= CDC_MRW;
+		cd->cdi.mask |= CDC_MRW_W;
+	}
+	if (!mrw_write)
+		cd->cdi.mask |= CDC_MRW_W;
+
 	n = data.header_length + data.block_descriptor_length;
 	cd->cdi.speed = ((buffer[n + 8] << 8) + buffer[n + 9]) / 176;
 	cd->readcd_known = 1;
@@ -788,9 +798,7 @@ static void get_capabilities(struct scsi
 	if ((buffer[n + 3] & 0x20) == 0) {
 		/* can't write DVD-RAM media */
 		cd->cdi.mask |= CDC_DVD_RAM;
-	} else {
-		cd->device->writeable = 1;
-	}
+	} else
 	if ((buffer[n + 3] & 0x10) == 0)
 		/* can't write DVD-R media */
 		cd->cdi.mask |= CDC_DVD_R;
@@ -814,6 +822,12 @@ static void get_capabilities(struct scsi
 	/*else    I don't think it can close its tray
 		cd->cdi.mask |= CDC_CLOSE_TRAY; */
 
+	/*
+	 * if DVD-RAM of MRW-W, we are randomly writeable
+	 */
+	if ((cd->cdi.mask & (CDC_DVD_RAM | CDC_MRW_W)) != (CDC_DVD_RAM | CDC_MRW_W))
+		cd->device->writeable = 1;
+
 	scsi_release_request(SRpnt);
 	kfree(buffer);
 }
diff -puN drivers/scsi/sym53c8xx_2/sym_glue.c~linus drivers/scsi/sym53c8xx_2/sym_glue.c
--- 25/drivers/scsi/sym53c8xx_2/sym_glue.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/sym53c8xx_2/sym_glue.c	2004-01-19 22:17:23.000000000 -0800
@@ -2177,7 +2177,7 @@ sym53c8xx_pci_init(struct pci_dev *pdev,
  *  Detach the host.
  *  We have to free resources and halt the NCR chip.
  */
-static int __devexit sym_detach(struct sym_hcb *np)
+static int sym_detach(struct sym_hcb *np)
 {
 	printk("%s: detaching ...\n", sym_name(np));
 
diff -puN drivers/scsi/sym53c8xx_2/sym_hipd.c~linus drivers/scsi/sym53c8xx_2/sym_hipd.c
--- 25/drivers/scsi/sym53c8xx_2/sym_hipd.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/sym53c8xx_2/sym_hipd.c	2004-01-19 22:17:23.000000000 -0800
@@ -1058,12 +1058,10 @@ static int sym_prepare_setting(hcb_p np,
 		 *  and BUS width.
 		 */
 		if (np->features & FE_ULTRA3) {
-			if (tp->tinfo.user.period <= 9	&&
-			    tp->tinfo.user.width == BUS_16_BIT) {
-				tp->tinfo.user.options |= PPR_OPT_DT;
-				tp->tinfo.user.offset   = np->maxoffs_dt;
-				tp->tinfo.user.spi_version = 3;
-			}
+			tp->tinfo.user.options |= PPR_OPT_DT;
+			tp->tinfo.user.period = np->minsync_dt;
+			tp->tinfo.user.offset = np->maxoffs_dt;
+			tp->tinfo.user.spi_version = 3;
 		}
 
 		if (!tp->usrtags)
@@ -2126,9 +2124,15 @@ sym_setsync(hcb_p np, int target,
 
 	sym_settrans(np, target, 0, ofs, per, wide, div, fak);
 
-	tp->tinfo.goal.period	= tp->tinfo.curr.period  = per;
-	tp->tinfo.goal.offset	= tp->tinfo.curr.offset  = ofs;
-	tp->tinfo.goal.options	= tp->tinfo.curr.options = 0;
+	tp->tinfo.curr.period  = per;
+	tp->tinfo.curr.offset  = ofs;
+	tp->tinfo.curr.options = 0;
+
+	if (!(tp->tinfo.goal.options & PPR_OPT_MASK)) {
+		tp->tinfo.goal.period	= per;
+		tp->tinfo.goal.offset	= ofs;
+		tp->tinfo.goal.options	= 0;
+	}
 
 	sym_xpt_async_nego_sync(np, target);
 }
diff -puN drivers/scsi/sym53c8xx_2/sym_misc.c~linus drivers/scsi/sym53c8xx_2/sym_misc.c
--- 25/drivers/scsi/sym53c8xx_2/sym_misc.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/scsi/sym53c8xx_2/sym_misc.c	2004-01-19 22:17:23.000000000 -0800
@@ -328,7 +328,6 @@ printf("XXXXXX [%d] inq_version=%x inq_b
 	    tp->inq_byte56  != inq_byte56) {
 		tp->inq_version = inq_version;
 		tp->inq_byte7   = inq_byte7;
-		tp->inq_byte56  = inq_byte56;
 		return 1;
 	}
 	return 0;
diff -puN drivers/serial/8250_acpi.c~linus drivers/serial/8250_acpi.c
--- 25/drivers/serial/8250_acpi.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/serial/8250_acpi.c	2004-01-19 22:17:23.000000000 -0800
@@ -1,6 +1,7 @@
 /*
- * serial/acpi.c
  * Copyright (c) 2002-2003 Matthew Wilcox for Hewlett-Packard
+ * Copyright (C) 2004 Hewlett-Packard Co
+ *	Bjorn Helgaas <bjorn.helgaas@hp.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -11,13 +12,21 @@
 #include <linux/acpi.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/tty.h>
 #include <linux/serial.h>
+#include <linux/tty.h>
+#include <linux/serial_core.h>
 
 #include <acpi/acpi_bus.h>
 
 #include <asm/io.h>
 #include <asm/serial.h>
 
+struct serial_private {
+	int	line;
+	void	*iomem_base;
+};
+
 static acpi_status acpi_serial_mmio(struct serial_struct *req,
 				    struct acpi_resource_address64 *addr)
 {
@@ -94,38 +103,72 @@ static acpi_status acpi_serial_resource(
 
 static int acpi_serial_add(struct acpi_device *device)
 {
+	struct serial_private *priv;
 	acpi_status status;
 	struct serial_struct serial_req;
-	int line;
+	int result;
 
 	memset(&serial_req, 0, sizeof(serial_req));
 
+	priv = kmalloc(sizeof(struct serial_private), GFP_KERNEL);
+	if (!priv) {
+		result = -ENOMEM;
+		goto fail;
+	}
+	memset(priv, 0, sizeof(*priv));
+
 	status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
 				     acpi_serial_resource, &serial_req);
-	if (ACPI_FAILURE(status))
-		return -ENODEV;
+	if (ACPI_FAILURE(status)) {
+		result = -ENODEV;
+		goto fail;
+	}
 
-	if (!serial_req.iomem_base && !serial_req.port) {
+	if (serial_req.iomem_base)
+		priv->iomem_base = serial_req.iomem_base;
+	else if (!serial_req.port) {
 		printk(KERN_ERR "%s: no iomem or port address in %s _CRS\n",
 			__FUNCTION__, device->pnp.bus_id);
-		return -ENODEV;
+		result = -ENODEV;
+		goto fail;
 	}
 
 	serial_req.baud_base = BASE_BAUD;
-	serial_req.flags = ASYNC_SKIP_TEST|ASYNC_BOOT_AUTOCONF|ASYNC_AUTO_IRQ;
+	serial_req.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF |
+			   UPF_AUTO_IRQ  | UPF_RESOURCES;
 
-	line = register_serial(&serial_req);
-	if (line < 0) {
-		printk(KERN_WARNING "Couldn't register serial port %s: %d",
-			device->pnp.bus_id, line);
-		return -ENODEV;
+	priv->line = register_serial(&serial_req);
+	if (priv->line < 0) {
+		printk(KERN_WARNING "Couldn't register serial port %s: %d\n",
+			device->pnp.bus_id, priv->line);
+		result = -ENODEV;
+		goto fail;
 	}
 
+	acpi_driver_data(device) = priv;
 	return 0;
+
+fail:
+	if (serial_req.iomem_base)
+		iounmap(serial_req.iomem_base);
+	kfree(priv);
+
+	return result;
 }
 
 static int acpi_serial_remove(struct acpi_device *device, int type)
 {
+	struct serial_private *priv;
+
+	if (!device || !acpi_driver_data(device))
+		return -EINVAL;
+
+	priv = acpi_driver_data(device);
+	unregister_serial(priv->line);
+	if (priv->iomem_base)
+		iounmap(priv->iomem_base);
+	kfree(priv);
+
 	return 0;
 }
 
diff -puN drivers/serial/8250_hcdp.c~linus drivers/serial/8250_hcdp.c
--- 25/drivers/serial/8250_hcdp.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/serial/8250_hcdp.c	2004-01-19 22:17:23.000000000 -0800
@@ -185,7 +185,7 @@ setup_serial_hcdp(void *tablep)
 #else
 		port.irq = gsi;
 #endif
-		port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
+		port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF | UPF_RESOURCES;
 		if (gsi)
 			port.flags |= ASYNC_AUTO_IRQ;
 
diff -puN drivers/serial/8250_pnp.c~linus drivers/serial/8250_pnp.c
--- 25/drivers/serial/8250_pnp.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/serial/8250_pnp.c	2004-01-19 22:17:23.000000000 -0800
@@ -295,6 +295,8 @@ static const struct pnp_device_id pnp_de
 	{	"USR2080",		0	},
 	/* U.S. Robotics 56K FAX INT */
 	{	"USR3031",		0	},
+	/* U.S. Robotics 56K FAX INT */
+	{	"USR3050",		0	},
 	/* U.S. Robotics 56K Voice INT PnP */
 	{	"USR3070",		0	},
 	/* U.S. Robotics 56K Voice EXT PnP */
diff -puN drivers/serial/Kconfig~linus drivers/serial/Kconfig
--- 25/drivers/serial/Kconfig~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/serial/Kconfig	2004-01-19 22:17:23.000000000 -0800
@@ -62,6 +62,15 @@ config SERIAL_8250_CONSOLE
 
 	  If unsure, say N.
 
+config SERIAL_8250_HCDP
+	bool "Console device discovery via EFI HCDP table"
+	depends on IA64
+	depends on SERIAL_8250_CONSOLE=y
+	---help---
+	  If you wish to make the serial console port described by the EFI
+	  HCDP table available for use as serial console, say Y here.  See
+	  <http://www.dig64.org/specifications/DIG64_HCDPv10a_01.pdf>.
+
 config SERIAL_8250_CS
 	tristate "8250/16550 PCMCIA device support"
 	depends on PCMCIA && SERIAL_8250
@@ -84,15 +93,6 @@ config SERIAL_8250_ACPI
 	  If you wish to enable serial port discovery via the ACPI
 	  namespace, say Y here.  If unsure, say N.
 
-config SERIAL_8250_HCDP
-	bool "8250/16550 device discovery support via EFI HCDP table"
-	depends on IA64 && SERIAL_8250
-	---help---
-	  If you wish to make the serial console port described by the EFI
-	  HCDP table available for use as serial console or general
-	  purpose port, say Y here. See
-	  <http://www.dig64.org/specifications/DIG64_HCDPv10a_01.pdf>.
-
 config SERIAL_8250_NR_UARTS
 	int "Maximum number of non-legacy 8250/16550 serial ports"
 	depends on SERIAL_8250
diff -puN drivers/serial/serial_cs.c~linus drivers/serial/serial_cs.c
--- 25/drivers/serial/serial_cs.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/serial/serial_cs.c	2004-01-19 22:17:23.000000000 -0800
@@ -149,9 +149,9 @@ static void serial_remove(dev_link_t *li
 		info->link.dev = NULL;
 
 		if (!info->slave) {
-			CardServices(ReleaseConfiguration, info->link.handle);
-			CardServices(ReleaseIO, info->link.handle, &info->link.io);
-			CardServices(ReleaseIRQ, info->link.handle, &info->link.irq);
+			pcmcia_release_configuration(info->link.handle);
+			pcmcia_release_io(info->link.handle, &info->link.io);
+			pcmcia_release_irq(info->link.handle, &info->link.irq);
 		}
 
 		info->link.state &= ~DEV_CONFIG;
@@ -211,7 +211,7 @@ static dev_link_t *serial_attach(void)
 	client_reg.event_handler = &serial_event;
 	client_reg.Version = 0x0210;
 	client_reg.event_callback_args.client_data = link;
-	ret = CardServices(RegisterClient, &link->handle, &client_reg);
+	ret = pcmcia_register_client(&link->handle, &client_reg);
 	if (ret != CS_SUCCESS) {
 		cs_error(link->handle, RegisterClient, ret);
 		serial_detach(link);
@@ -256,7 +256,7 @@ static void serial_detach(dev_link_t * l
 	serial_remove(link);
 
 	if (link->handle) {
-		ret = CardServices(DeregisterClient, link->handle);
+		ret = pcmcia_deregister_client(link->handle);
 		if (ret != CS_SUCCESS)
 			cs_error(link->handle, DeregisterClient, ret);
 	}
@@ -300,20 +300,30 @@ static int setup_serial(struct serial_in
 /*====================================================================*/
 
 static int
-get_tuple(int fn, client_handle_t handle, tuple_t * tuple, cisparse_t * parse)
+first_tuple(client_handle_t handle, tuple_t * tuple, cisparse_t * parse)
 {
 	int i;
-	i = CardServices(fn, handle, tuple);
+	i = pcmcia_get_first_tuple(handle, tuple);
 	if (i != CS_SUCCESS)
 		return CS_NO_MORE_ITEMS;
-	i = CardServices(GetTupleData, handle, tuple);
+	i = pcmcia_get_tuple_data(handle, tuple);
 	if (i != CS_SUCCESS)
 		return i;
-	return CardServices(ParseTuple, handle, tuple, parse);
+	return pcmcia_parse_tuple(handle, tuple, parse);
 }
 
-#define first_tuple(a, b, c) get_tuple(GetFirstTuple, a, b, c)
-#define next_tuple(a, b, c) get_tuple(GetNextTuple, a, b, c)
+static int
+next_tuple(client_handle_t handle, tuple_t * tuple, cisparse_t * parse)
+{
+	int i;
+	i = pcmcia_get_next_tuple(handle, tuple);
+	if (i != CS_SUCCESS)
+		return CS_NO_MORE_ITEMS;
+	i = pcmcia_get_tuple_data(handle, tuple);
+	if (i != CS_SUCCESS)
+		return i;
+	return pcmcia_parse_tuple(handle, tuple, parse);
+}
 
 /*====================================================================*/
 
@@ -330,7 +340,7 @@ static int simple_config(dev_link_t * li
 	int i, j, try;
 
 	/* If the card is already configured, look up the port and irq */
-	i = CardServices(GetConfigurationInfo, handle, &config);
+	i = pcmcia_get_configuration_info(handle, &config);
 	if ((i == CS_SUCCESS) && (config.Attributes & CONF_VALID_CLIENT)) {
 		ioaddr_t port = 0;
 		if ((config.BasePort2 != 0) && (config.NumPorts2 == 8)) {
@@ -367,9 +377,7 @@ static int simple_config(dev_link_t * li
 				link->io.BasePort1 = cf->io.win[0].base;
 				link->io.IOAddrLines = (try == 0) ?
 				    16 : cf->io.flags & CISTPL_IO_LINES_MASK;
-				i =
-				    CardServices(RequestIO, link->handle,
-						 &link->io);
+				i = pcmcia_request_io(link->handle, &link->io);
 				if (i == CS_SUCCESS)
 					goto found_port;
 			}
@@ -389,8 +397,7 @@ static int simple_config(dev_link_t * li
 			for (j = 0; j < 5; j++) {
 				link->io.BasePort1 = base[j];
 				link->io.IOAddrLines = base[j] ? 16 : 3;
-				i = CardServices(RequestIO, link->handle,
-						 &link->io);
+				i = pcmcia_request_io(link->handle, &link->io);
 				if (i == CS_SUCCESS)
 					goto found_port;
 			}
@@ -406,14 +413,14 @@ static int simple_config(dev_link_t * li
 		return -1;
 	}
 
-	i = CardServices(RequestIRQ, link->handle, &link->irq);
+	i = pcmcia_request_irq(link->handle, &link->irq);
 	if (i != CS_SUCCESS) {
 		cs_error(link->handle, RequestIRQ, i);
 		link->irq.AssignedIRQ = 0;
 	}
 	if (info->multi && (info->manfid == MANFID_3COM))
 		link->conf.ConfigIndex &= ~(0x08);
-	i = CardServices(RequestConfiguration, link->handle, &link->conf);
+	i = pcmcia_request_configuration(link->handle, &link->conf);
 	if (i != CS_SUCCESS) {
 		cs_error(link->handle, RequestConfiguration, i);
 		return -1;
@@ -433,7 +440,7 @@ static int multi_config(dev_link_t * lin
 	config_info_t config;
 	int i, base2 = 0;
 
-	i = CardServices(GetConfigurationInfo, handle, &config);
+	i = pcmcia_get_configuration_info(handle, &config);
 	if (i != CS_SUCCESS) {
 		cs_error(handle, GetConfigurationInfo, i);
 		return -1;
@@ -458,7 +465,7 @@ static int multi_config(dev_link_t * lin
 			link->io.BasePort1 = cf->io.win[0].base;
 			link->io.IOAddrLines =
 			    cf->io.flags & CISTPL_IO_LINES_MASK;
-			i = CardServices(RequestIO, link->handle, &link->io);
+			i = pcmcia_request_io(link->handle, &link->io);
 			base2 = link->io.BasePort1 + 8;
 			if (i == CS_SUCCESS)
 				break;
@@ -478,9 +485,7 @@ static int multi_config(dev_link_t * lin
 				link->io.BasePort2 = cf->io.win[1].base;
 				link->io.IOAddrLines =
 				    cf->io.flags & CISTPL_IO_LINES_MASK;
-				i =
-				    CardServices(RequestIO, link->handle,
-						 &link->io);
+				i = pcmcia_request_io(link->handle, &link->io);
 				base2 = link->io.BasePort2;
 				if (i == CS_SUCCESS)
 					break;
@@ -494,7 +499,7 @@ static int multi_config(dev_link_t * lin
 		return -1;
 	}
 
-	i = CardServices(RequestIRQ, link->handle, &link->irq);
+	i = pcmcia_request_irq(link->handle, &link->irq);
 	if (i != CS_SUCCESS) {
 		printk(KERN_NOTICE
 		       "serial_cs: no usable port range found, giving up\n");
@@ -506,7 +511,7 @@ static int multi_config(dev_link_t * lin
 		link->conf.Present |= PRESENT_EXT_STATUS;
 		link->conf.ExtStatus = ESR_REQ_ATTN_ENA;
 	}
-	i = CardServices(RequestConfiguration, link->handle, &link->conf);
+	i = pcmcia_request_configuration(link->handle, &link->conf);
 	if (i != CS_SUCCESS) {
 		cs_error(link->handle, RequestConfiguration, i);
 		return -1;
@@ -543,9 +548,6 @@ static int multi_config(dev_link_t * lin
 
 ======================================================================*/
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
-
 void serial_config(dev_link_t * link)
 {
 	client_handle_t handle = link->handle;
@@ -619,10 +621,18 @@ void serial_config(dev_link_t * link)
 
 	if (info->manfid == MANFID_IBM) {
 		conf_reg_t reg = { 0, CS_READ, 0x800, 0 };
-		CS_CHECK(AccessConfigurationRegister, link->handle, &reg);
+		last_ret = pcmcia_access_configuration_register(link->handle, &reg);
+		if (last_ret) {
+			last_fn = AccessConfigurationRegister;
+			goto cs_failed;
+		}
 		reg.Action = CS_WRITE;
 		reg.Value = reg.Value | 1;
-		CS_CHECK(AccessConfigurationRegister, link->handle, &reg);
+		last_ret = pcmcia_access_configuration_register(link->handle, &reg);
+		if (last_ret) {
+			last_fn = AccessConfigurationRegister;
+			goto cs_failed;
+		}
 	}
 
 	link->dev = &info->node[0];
@@ -668,7 +678,7 @@ serial_event(event_t event, int priority
 		/* Fall through... */
 	case CS_EVENT_RESET_PHYSICAL:
 		if ((link->state & DEV_CONFIG) && !info->slave)
-			CardServices(ReleaseConfiguration, link->handle);
+			pcmcia_release_configuration(link->handle);
 		break;
 
 	case CS_EVENT_PM_RESUME:
@@ -676,8 +686,7 @@ serial_event(event_t event, int priority
 		/* Fall through... */
 	case CS_EVENT_CARD_RESET:
 		if (DEV_OK(link) && !info->slave)
-			CardServices(RequestConfiguration, link->handle,
-				     &link->conf);
+			pcmcia_request_configuration(link->handle, &link->conf);
 		break;
 	}
 	return 0;
diff -puN drivers/telephony/ixj_pcmcia.c~linus drivers/telephony/ixj_pcmcia.c
--- 25/drivers/telephony/ixj_pcmcia.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/telephony/ixj_pcmcia.c	2004-01-19 22:17:23.000000000 -0800
@@ -77,7 +77,7 @@ static dev_link_t *ixj_attach(void)
 	client_reg.event_handler = &ixj_event;
 	client_reg.Version = 0x0210;
 	client_reg.event_callback_args.client_data = link;
-	ret = CardServices(RegisterClient, &link->handle, &client_reg);
+	ret = pcmcia_register_client(&link->handle, &client_reg);
 	if (ret != CS_SUCCESS) {
 		cs_error(link->handle, RegisterClient, ret);
 		ixj_detach(link);
@@ -100,7 +100,7 @@ static void ixj_detach(dev_link_t * link
 	if (link->state & DEV_CONFIG)
 		ixj_cs_release(link);
 	if (link->handle) {
-		ret = CardServices(DeregisterClient, link->handle);
+		ret = pcmcia_deregister_client(link->handle);
 		if (ret != CS_SUCCESS)
 			cs_error(link->handle, DeregisterClient, ret);
 	}
@@ -110,11 +110,8 @@ static void ixj_detach(dev_link_t * link
         kfree(link);
 }
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
-
-#define CFG_CHECK(fn, args...) \
-if (CardServices(fn, args) != 0) goto next_entry
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static void ixj_get_serial(dev_link_t * link, IXJ * j)
 {
@@ -130,8 +127,8 @@ static void ixj_get_serial(dev_link_t * 
 	tuple.TupleDataMax = 80;
 	tuple.Attributes = 0;
 	tuple.DesiredTuple = CISTPL_VERS_1;
-	CS_CHECK(GetFirstTuple, handle, &tuple);
-	CS_CHECK(GetTupleData, handle, &tuple);
+	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+	CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
 	str = (char *) buf;
 	printk("PCMCIA Version %d.%d\n", str[0], str[1]);
 	str += 2;
@@ -202,19 +199,20 @@ static void ixj_config(dev_link_t * link
 	tuple.TupleDataMax = 255;
 	tuple.Attributes = 0;
 	tuple.DesiredTuple = CISTPL_CONFIG;
-	CS_CHECK(GetFirstTuple, handle, &tuple);
-	CS_CHECK(GetTupleData, handle, &tuple);
-	CS_CHECK(ParseTuple, handle, &tuple, &parse);
+	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+	CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+	CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
 	link->conf.ConfigBase = parse.config.base;
 	link->conf.Present = parse.config.rmask[0];
 	link->state |= DEV_CONFIG;
-	CS_CHECK(GetConfigurationInfo, handle, &conf);
+	CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf));
 	tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
 	tuple.Attributes = 0;
-	CS_CHECK(GetFirstTuple, handle, &tuple);
+	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
 	while (1) {
-		CFG_CHECK(GetTupleData, handle, &tuple);
-		CFG_CHECK(ParseTuple, handle, &tuple, &parse);
+		if (pcmcia_get_tuple_data(handle, &tuple) != 0 ||
+				pcmcia_parse_tuple(handle, &tuple, &parse) != 0)
+			goto next_entry;
 		if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
 			cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io;
 			link->conf.ConfigIndex = cfg->index;
@@ -224,17 +222,18 @@ static void ixj_config(dev_link_t * link
 				link->io.BasePort2 = io->win[1].base;
 				link->io.NumPorts2 = io->win[1].len;
 			}
-			CFG_CHECK(RequestIO, link->handle, &link->io);
+			if (pcmcia_request_io(link->handle, &link->io) != 0)
+				goto next_entry;
 			/* If we've got this far, we're done */
 			break;
 		}
 	      next_entry:
 		if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
 			dflt = *cfg;
-		CS_CHECK(GetNextTuple, handle, &tuple);
+		CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple));
 	}
 
-	CS_CHECK(RequestConfiguration, handle, &link->conf);
+	CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf));
 
 	/*
  	 *	Register the card with the core.
@@ -258,8 +257,8 @@ static void ixj_cs_release(dev_link_t *l
 	DEBUG(0, "ixj_cs_release(0x%p)\n", link);
 	info->ndev = 0;
 	link->dev = NULL;
-	CardServices(ReleaseConfiguration, link->handle);
-	CardServices(ReleaseIO, link->handle, &link->io);
+	pcmcia_release_configuration(link->handle);
+	pcmcia_release_io(link->handle, &link->io);
 	link->state &= ~DEV_CONFIG;
 }
 
@@ -284,14 +283,14 @@ static int ixj_event(event_t event, int 
 		/* Fall through... */
 	case CS_EVENT_RESET_PHYSICAL:
 		if (link->state & DEV_CONFIG)
-			CardServices(ReleaseConfiguration, link->handle);
+			pcmcia_release_configuration(link->handle);
 		break;
 	case CS_EVENT_PM_RESUME:
 		link->state &= ~DEV_SUSPEND;
 		/* Fall through... */
 	case CS_EVENT_CARD_RESET:
 		if (DEV_OK(link))
-			CardServices(RequestConfiguration, link->handle, &link->conf);
+			pcmcia_request_configuration(link->handle, &link->conf);
 		break;
 	}
 	return 0;
diff -puN drivers/video/cirrusfb.c~linus drivers/video/cirrusfb.c
--- 25/drivers/video/cirrusfb.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/video/cirrusfb.c	2004-01-19 22:17:23.000000000 -0800
@@ -3089,7 +3089,7 @@ static void RClut (struct clgenfb_info *
 *********************************************************************/
 
 /* FIXME: use interrupts instead */
-extern inline void clgen_WaitBLT (caddr_t regbase)
+static inline void clgen_WaitBLT (caddr_t regbase)
 {
 	/* now busy-wait until we're done */
 	while (vga_rgfx (regbase, CL_GR31) & 0x08)
diff -puN drivers/video/console/Kconfig~linus drivers/video/console/Kconfig
--- 25/drivers/video/console/Kconfig~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/video/console/Kconfig	2004-01-19 22:17:23.000000000 -0800
@@ -6,7 +6,7 @@ menu "Console display driver support"
 
 config VGA_CONSOLE
 	bool "VGA text console" if EMBEDDED || !X86
-	depends on !ARCH_ACORN && !ARCH_EBSA110 && !4xx && !8xx && !SPARC32 && !SPARC64
+	depends on !ARCH_ACORN && !ARCH_EBSA110 && !4xx && !8xx && !SPARC32 && !SPARC64 && !M68K
 	default y
 	help
 	  Saying Y here will allow you to use Linux in text mode through a
@@ -43,6 +43,7 @@ config VIDEO_SELECT
 	  about the Video mode selection support. If unsure, say N.
 
 config MDA_CONSOLE
+	depends on !M68K
 	tristate "MDA text console (dual-headed) (EXPERIMENTAL)"
 	---help---
 	  Say Y here if you have an old MDA or monochrome Hercules graphics
diff -puN drivers/video/fbmem.c~linus drivers/video/fbmem.c
--- 25/drivers/video/fbmem.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/video/fbmem.c	2004-01-19 22:17:23.000000000 -0800
@@ -159,6 +159,8 @@ extern int tcx_init(void);
 extern int tcx_setup(char*);
 extern int leo_init(void);
 extern int leo_setup(char*);
+extern int kyrofb_init(void);
+extern int kyrofb_setup(char*);
 
 static struct {
 	const char *name;
@@ -360,6 +362,10 @@ static struct {
 #ifdef CONFIG_FB_VOODOO1
 	{ "sstfb", sstfb_init, sstfb_setup },
 #endif
+#ifdef CONFIG_FB_KYRO
+	{ "kyrofb", kyrofb_init, kyrofb_setup },
+#endif
+
 	/*
 	 * Generic drivers that don't use resource management (yet)
 	 */
diff -puN drivers/video/Kconfig~linus drivers/video/Kconfig
--- 25/drivers/video/Kconfig~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/video/Kconfig	2004-01-19 22:17:23.000000000 -0800
@@ -406,14 +406,6 @@ config FB_PVR2
 	  (<file:drivers/video/pvr2fb.c>). Please see the file
 	  <file:Documentation/fb/pvr2fb.txt>.
 
-config FB_PVR2_DEBUG
-	bool "Debug pvr2fb"
-	depends on FB_PVR2=y
-	help
-	  Say Y here if you wish for the pvr2fb driver to print out debugging
-	  messages. Most people will want to say N here. If unsure, you will
-	  also want to say N.
-
 config FB_E1355
 	bool "Epson 1355 framebuffer support"
 	depends on FB && SUPERH
@@ -579,7 +571,8 @@ config FB_MATROX_G100
 
 config FB_MATROX_I2C
 	tristate "Matrox I2C support"
-	depends on FB_MATROX && I2C_ALGOBIT
+	depends on FB_MATROX && I2C
+	select I2C_ALGOBIT
 	---help---
 	  This drivers creates I2C buses which are needed for accessing the
 	  DDC (I2C) bus present on all Matroxes, an I2C bus which
@@ -734,6 +727,16 @@ config FB_NEOMAGIC
 	  To compile this driver as a module, choose M here: the
 	  module will be called neofb.
 
+config FB_KYRO
+	tristate "IMG Kyro support"
+	depends on FB && PCI
+	help
+	  Say Y here if you have a STG4000 / Kyro / PowerVR 3 based
+	  graphics board.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called kyrofb.
+
 config FB_3DFX
 	tristate "3Dfx Banshee/Voodoo3 display support"
 	depends on FB && PCI
diff -puN /dev/null drivers/video/kyro/fbdev.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/video/kyro/fbdev.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,808 @@
+/*
+ *  linux/drivers/video/kyro/kyrofb.c
+ *
+ *  Copyright (C) 2002 STMicroelectronics
+ *  Copyright (C) 2003, 2004 Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file COPYING in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/tty.h>
+#include <linux/delay.h>
+#include <linux/fb.h>
+#include <linux/ioctl.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#ifdef CONFIG_MTRR
+#include <asm/mtrr.h>
+#endif
+
+#include <video/kyro.h>
+
+#include "STG4000Reg.h"
+#include "STG4000Interface.h"
+
+/*
+ * PCI Definitions
+ */
+#define PCI_VENDOR_ID_ST	0x104a
+#define PCI_DEVICE_ID_STG4000	0x0010
+
+#define KHZ2PICOS(a) (1000000000UL/(a))
+
+/****************************************************************************/
+static struct fb_fix_screeninfo kyro_fix __initdata = {
+	.id		= "ST Kyro",
+	.type		= FB_TYPE_PACKED_PIXELS,
+	.visual		= FB_VISUAL_TRUECOLOR,
+	.accel		= FB_ACCEL_NONE,
+};
+
+static struct fb_var_screeninfo kyro_var __initdata = {
+	/* 640x480, 16bpp @ 60 Hz */
+	.xres		= 640,
+	.yres		= 480,
+	.xres_virtual	= 640,
+	.yres_virtual	= 480,
+	.bits_per_pixel	= 16,
+	.red		= { 11, 5, 0 },
+	.green		= {  5, 6, 0 },
+	.blue		= {  0, 5, 0 },
+	.activate	= FB_ACTIVATE_NOW,
+	.height		= -1,
+	.width		= -1,
+	.pixclock	= KHZ2PICOS(25175),
+	.left_margin	= 48,
+	.right_margin	= 16,
+	.upper_margin	= 33,
+	.lower_margin	= 10,
+	.hsync_len	= 96,
+	.vsync_len	= 2,
+	.vmode		= FB_VMODE_NONINTERLACED,
+};
+
+static struct kyrofb_info *currentpar;
+
+typedef struct {
+	STG4000REG *pSTGReg;	/* Virtual address of PCI register region */
+	u32 ulNextFreeVidMem;	/* Offset from start of vid mem to next free region */
+	u32 ulOverlayOffset;	/* Offset from start of vid mem to overlay */
+	u32 ulOverlayStride;	/* Interleaved YUV and 422 mode Y stride */
+	u32 ulOverlayUVStride;	/* 422 mode U & V stride */
+} device_info_t;
+
+/* global graphics card info structure (one per card) */
+static device_info_t deviceInfo = { 0 };
+
+static char *mode_option __initdata = NULL;
+static int nopan __initdata = 0;
+static int nowrap __initdata = 1;
+#ifdef CONFIG_MTRR
+static int nomtrr __initdata = 0;
+#endif
+
+/* PCI driver prototypes */
+static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
+static void kyrofb_remove(struct pci_dev *pdev);
+
+#ifndef MODULE
+static struct fb_videomode kyro_modedb[] __initdata = {
+	{
+		/* 640x350 @ 85Hz */
+		NULL, 85, 640, 350, KHZ2PICOS(31500),
+		96, 32, 60, 32, 64, 3,
+		FB_SYNC_HOR_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 640x400 @ 85Hz */
+		NULL, 85, 640, 400, KHZ2PICOS(31500),
+		96, 32, 41, 1, 64, 3,
+		FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 720x400 @ 85Hz */
+		NULL, 85, 720, 400, KHZ2PICOS(35500),
+		108, 36, 42, 1, 72, 3,
+		FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 640x480 @ 60Hz */
+		NULL, 60, 640, 480, KHZ2PICOS(25175),
+		48, 16, 33, 10, 96, 2,
+		0, FB_VMODE_NONINTERLACED
+	}, {
+		/* 640x480 @ 72Hz */
+		NULL, 72, 640, 480, KHZ2PICOS(31500),
+		128, 24, 28, 9, 40, 3,
+		0, FB_VMODE_NONINTERLACED
+	}, {
+		/* 640x480 @ 75Hz */
+		NULL, 75, 640, 480, KHZ2PICOS(31500),
+		120, 16, 16, 1, 64, 3,
+		0, FB_VMODE_NONINTERLACED
+	}, {
+		/* 640x480 @ 85Hz */
+		NULL, 85, 640, 480, KHZ2PICOS(36000),
+		80, 56, 25, 1, 56, 3,
+		0, FB_VMODE_NONINTERLACED
+	}, {
+		/* 800x600 @ 56Hz */
+		NULL, 56, 800, 600, KHZ2PICOS(36000),
+		128, 24, 22, 1, 72, 2,
+		FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 800x600 @ 60Hz */
+		NULL, 60, 800, 600, KHZ2PICOS(40000),
+		88, 40, 23, 1, 128, 4,
+		FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 800x600 @ 72Hz */
+		NULL, 72, 800, 600, KHZ2PICOS(50000),
+		64, 56, 23, 37, 120, 6,
+		FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 800x600 @ 75Hz */
+		NULL, 75, 800, 600, KHZ2PICOS(49500),
+		160, 16, 21, 1, 80, 3,
+		FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 800x600 @ 85Hz */
+		NULL, 85, 800, 600, KHZ2PICOS(56250),
+		152, 32, 27, 1, 64, 3,
+		FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1024x768 @ 60Hz */
+		NULL, 60, 1024, 768, KHZ2PICOS(65000),
+		160, 24, 29, 3, 136, 6,
+		0, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1024x768 @ 70Hz */
+		NULL, 70, 1024, 768, KHZ2PICOS(75000),
+		144, 24, 29, 3, 136, 6,
+		0, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1024x768 @ 75Hz */
+		NULL, 75, 1024, 768, KHZ2PICOS(78750),
+		176, 16, 28, 1, 96, 3,
+		FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1024x768 @ 85Hz */
+		NULL, 85, 1024, 768, KHZ2PICOS(94500),
+		208, 48, 36, 1, 96, 3,
+		FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1152x864 @ 75Hz */
+		NULL, 75, 1152, 864, KHZ2PICOS(108000),
+		256, 64, 32, 1, 128, 3,
+		FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1280x960 @ 60Hz */
+		NULL, 60, 1280, 960, KHZ2PICOS(108000),
+		312, 96, 36, 1, 112, 3,
+		FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1280x960 @ 85Hz */
+		NULL, 85, 1280, 960, KHZ2PICOS(148500),
+		224, 64, 47, 1, 160, 3,
+		FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1280x1024 @ 60Hz */
+		NULL, 60, 1280, 1024, KHZ2PICOS(108000),
+		248, 48, 38, 1, 112, 3,
+		FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1280x1024 @ 75Hz */
+		NULL, 75, 1280, 1024, KHZ2PICOS(135000),
+		248, 16, 38, 1, 144, 3,
+		FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1280x1024 @ 85Hz */
+		NULL, 85, 1280, 1024, KHZ2PICOS(157500),
+		224, 64, 44, 1, 160, 3,
+		FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1600x1200 @ 60Hz */
+		NULL, 60, 1600, 1200, KHZ2PICOS(162000),
+		304, 64, 46, 1, 192, 3,
+		FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1600x1200 @ 65Hz */
+		NULL, 65, 1600, 1200, KHZ2PICOS(175500),
+		304, 64, 46, 1, 192, 3,
+		FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1600x1200 @ 70Hz */
+		NULL, 70, 1600, 1200, KHZ2PICOS(189000),
+		304, 64, 46, 1, 192, 3,
+		FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1600x1200 @ 75Hz */
+		NULL, 75, 1600, 1200, KHZ2PICOS(202500),
+		304, 64, 46, 1, 192, 3,
+		FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1600x1200 @ 85Hz */
+		NULL, 85, 1600, 1200, KHZ2PICOS(229500),
+		304, 64, 46, 1, 192, 3,
+		FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1792x1344 @ 60Hz */
+		NULL, 60, 1792, 1344, KHZ2PICOS(204750),
+		328, 128, 46, 1, 200, 3,
+		FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1792x1344 @ 75Hz */
+		NULL, 75, 1792, 1344, KHZ2PICOS(261000),
+		352, 96, 69, 1, 216, 3,
+		FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1856x1392 @ 60Hz */
+		NULL, 60, 1856, 1392, KHZ2PICOS(218250),
+		352, 96, 43, 1, 224, 3,
+		FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1856x1392 @ 75Hz */
+		NULL, 75, 1856, 1392, KHZ2PICOS(288000),
+		352, 128, 104, 1, 224, 3,
+		FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1920x1440 @ 60Hz */
+		NULL, 60, 1920, 1440, KHZ2PICOS(234000),
+		344, 128, 56, 1, 208, 3,
+		FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	}, {
+		/* 1920x1440 @ 75Hz */
+		NULL, 75, 1920, 1440, KHZ2PICOS(297000),
+		352, 144, 56, 1, 224, 3,
+		FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+	},
+};
+#define NUM_TOTAL_MODES	ARRAY_SIZE(kyro_modedb)
+
+/*
+ * This needs to be kept ordered corresponding to kyro_modedb.
+ */
+enum {
+	VMODE_640_350_85,
+	VMODE_640_400_85,
+	VMODE_720_400_85,
+	VMODE_640_480_60,
+	VMODE_640_480_72,
+	VMODE_640_480_75,
+	VMODE_640_480_85,
+	VMODE_800_600_56,
+	VMODE_800_600_60,
+	VMODE_800_600_72,
+	VMODE_800_600_75,
+	VMODE_800_600_85,
+	VMODE_1024_768_60,
+	VMODE_1024_768_70,
+	VMODE_1024_768_75,
+	VMODE_1024_768_85,
+	VMODE_1152_864_75,
+	VMODE_1280_960_60,
+	VMODE_1280_960_85,
+	VMODE_1280_1024_60,
+	VMODE_1280_1024_75,
+	VMODE_1280_1024_85,
+	VMODE_1600_1200_60,
+	VMODE_1600_1200_65,
+	VMODE_1600_1200_70,
+	VMODE_1600_1200_75,
+	VMODE_1600_1200_85,
+	VMODE_1792_1344_60,
+	VMODE_1792_1344_75,
+	VMODE_1856_1392_60,
+	VMODE_1856_1392_75,
+	VMODE_1920_1440_60,
+	VMODE_1920_1440_75,
+};
+#endif
+
+/* Accessors */
+int kyro_dev_video_mode_set(struct fb_info *info)
+{
+	struct kyrofb_info *par = (struct kyrofb_info *)info->par;
+
+	/* Turn off display */
+	StopVTG(deviceInfo.pSTGReg);
+	DisableRamdacOutput(deviceInfo.pSTGReg);
+
+	/* Bring us out of VGA and into Hi-Res mode, if not already. */
+	DisableVGA(deviceInfo.pSTGReg);
+
+	if (InitialiseRamdac(deviceInfo.pSTGReg,
+			     info->var.bits_per_pixel,
+			     info->var.xres, info->var.yres,
+			     par->HSP, par->VSP, &par->PIXCLK) < 0)
+		return -EINVAL;
+
+	SetupVTG(deviceInfo.pSTGReg, par);
+
+	ResetOverlayRegisters(deviceInfo.pSTGReg);
+
+	/* Turn on display in new mode */
+	EnableRamdacOutput(deviceInfo.pSTGReg);
+	StartVTG(deviceInfo.pSTGReg);
+
+	deviceInfo.ulNextFreeVidMem = info->var.xres * info->var.yres *
+				      info->var.bits_per_pixel;
+	deviceInfo.ulOverlayOffset = 0;
+
+	return 0;
+}
+
+int kyro_dev_overlay_create(u32 ulWidth,
+			    u32 ulHeight, int bLinear)
+{
+	u32 offset;
+	u32 stride, uvStride;
+
+	if (deviceInfo.ulOverlayOffset != 0)
+		/*
+		 * Can only create one overlay without resetting the card or
+		 * changing display mode
+		 */
+		return -EINVAL;
+
+	ResetOverlayRegisters(deviceInfo.pSTGReg);
+
+	/* Overlays are addressed in multiples of 16bytes or 32bytes, so make
+	 * sure the start offset is on an appropriate boundary.
+	 */
+	offset = deviceInfo.ulNextFreeVidMem;
+	if ((offset & 0x1f) != 0) {
+		offset = (offset + 32L) & 0xffffffE0L;
+	}
+
+	if (CreateOverlaySurface(deviceInfo.pSTGReg, ulWidth, ulHeight,
+				 bLinear, offset, &stride, &uvStride) < 0)
+		return -EINVAL;
+
+	deviceInfo.ulOverlayOffset = offset;
+	deviceInfo.ulOverlayStride = stride;
+	deviceInfo.ulOverlayUVStride = uvStride;
+	deviceInfo.ulNextFreeVidMem = offset + (ulHeight * stride) + (ulHeight * 2 * uvStride);
+
+	SetOverlayBlendMode(deviceInfo.pSTGReg, GLOBAL_ALPHA, 0xf, 0x0);
+
+	return 0;
+}
+
+int kyro_dev_overlay_viewport_set(u32 x, u32 y, u32 ulWidth, u32 ulHeight)
+{
+	if (deviceInfo.ulOverlayOffset == 0)
+		/* probably haven't called CreateOverlay yet */
+		return -EINVAL;
+
+	/* Stop Ramdac Output */
+	DisableRamdacOutput(deviceInfo.pSTGReg);
+
+	SetOverlayViewPort(deviceInfo.pSTGReg,
+			   x, y, x + ulWidth - 1, y + ulHeight - 1);
+
+	EnableOverlayPlane(deviceInfo.pSTGReg);
+	/* Start Ramdac Output */
+	EnableRamdacOutput(deviceInfo.pSTGReg);
+
+	return 0;
+}
+
+static inline unsigned long get_line_length(int x, int bpp)
+{
+	return (unsigned long)((((x*bpp)+31)&~31) >> 3);
+}
+
+static int kyrofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
+{
+	struct kyrofb_info *par = (struct kyrofb_info *)info->par;
+
+	if (var->bits_per_pixel != 16 && var->bits_per_pixel != 32) {
+		printk(KERN_WARNING "kyrofb: depth not supported: %u\n", var->bits_per_pixel);
+		return -EINVAL;
+	}
+
+	switch (var->bits_per_pixel) {
+	case 16:
+		var->red.offset = 11;
+		var->red.length = 5;
+		var->green.offset = 5;
+		var->green.length = 6;
+		var->blue.length = 5;
+		break;
+	case 32:
+		var->transp.offset = 24;
+		var->red.offset = 16;
+		var->green.offset = 8;
+		var->blue.offset = 0;
+
+		var->red.length = 8;
+		var->green.length = 8;
+		var->blue.length = 8;
+		var->transp.length = 8;
+		break;
+	}
+
+	/* Height/Width of picture in mm */
+	var->height = var->width = -1;
+
+	/* Timing information. All values are in picoseconds */
+
+	/* par->PIXCLK is in 100Hz units. Convert to picoseconds -
+	 * ensuring we do not exceed 32 bit precision
+	 */
+	/*
+	 * XXX: Enabling this really screws over the pixclock value when we
+	 * read it back with fbset. As such, leaving this commented out appears
+	 * to do the right thing (at least for now) .. bearing in mind that we
+	 * have infact already done the KHZ2PICOS conversion in both the modedb
+	 * and kyro_var. -- PFM.
+	 */
+//	var->pixclock = 1000000000 / (par->PIXCLK / 10);
+
+	/* the header file claims we should use picoseconds
+	 * - nobody else does though, the all use pixels and lines
+	 * of h and v sizes. Both options here.
+	 */
+
+	/*
+	 * If we're being called by __fb_try_mode(), then we don't want to
+	 * override any of the var settings that we've already parsed
+	 * from our modedb. -- PFM.
+	 */
+	if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_TEST)
+		return 0;
+
+	var->left_margin = par->HBP;
+	var->hsync_len = par->HST;
+	var->right_margin = par->HFP;
+
+	var->upper_margin = par->VBP;
+	var->vsync_len = par->VST;
+	var->lower_margin = par->VFP;
+
+	if (par->HSP == 1)
+		var->sync |= FB_SYNC_HOR_HIGH_ACT;
+	if (par->VSP == 1)
+		var->sync |= FB_SYNC_VERT_HIGH_ACT;
+
+	return 0;
+}
+
+static int kyrofb_set_par(struct fb_info *info)
+{
+	struct kyrofb_info *par = (struct kyrofb_info *)info->par;
+	unsigned long lineclock;
+	unsigned long frameclock;
+
+	/* Actual resolution */
+	par->XRES = info->var.xres;
+	par->YRES = info->var.yres;
+
+	/* pixel depth */
+	par->PIXDEPTH = info->var.bits_per_pixel;
+
+	/* Refresh rate */
+	/* time for a line in ns */
+	lineclock = (info->var.pixclock * (info->var.xres +
+				    info->var.right_margin +
+				    info->var.hsync_len +
+				    info->var.left_margin)) / 1000;
+
+
+	/* time for a frame in ns (precision in 32bpp) */
+	frameclock = lineclock * (info->var.yres +
+				  info->var.lower_margin +
+				  info->var.vsync_len +
+				  info->var.upper_margin);
+
+	/* Calculate refresh rate and horrizontal clocks */
+	par->VFREQ = (1000000000 + (frameclock / 2)) / frameclock;
+	par->HCLK = (1000000000 + (lineclock / 2)) / lineclock;
+	par->PIXCLK = ((1000000000 + (info->var.pixclock / 2))
+					/ info->var.pixclock) * 10;
+
+	/* calculate horizontal timings */
+	par->HFP = info->var.right_margin;
+	par->HST = info->var.hsync_len;
+	par->HBP = info->var.left_margin;
+	par->HTot = par->XRES + par->HBP + par->HST + par->HFP;
+
+	/* calculate vertical timings */
+	par->VFP = info->var.lower_margin;
+	par->VST = info->var.vsync_len;
+	par->VBP = info->var.upper_margin;
+	par->VTot = par->YRES + par->VBP + par->VST + par->VFP;
+
+	par->HSP = (info->var.sync & FB_SYNC_HOR_HIGH_ACT) ? 1 : 0;
+	par->VSP = (info->var.sync & FB_SYNC_VERT_HIGH_ACT) ? 1 : 0;
+
+	kyro_dev_video_mode_set(info);
+
+	/* length of a line in bytes    */
+	info->fix.line_length = get_line_length(par->XRES, par->PIXDEPTH);
+	info->fix.visual = FB_VISUAL_TRUECOLOR;
+
+	return 0;
+}
+
+static int kyrofb_setcolreg(u_int regno, u_int red, u_int green,
+			    u_int blue, u_int transp, struct fb_info *info)
+{
+	if (regno > 255)
+		return 1;	/* Invalid register */
+
+	if (regno < 16) {
+		switch (info->var.bits_per_pixel) {
+		case 16:
+			((u16*)(info->pseudo_palette))[regno] =
+			     (red   & 0xf800) |
+			    ((green & 0xfc00) >> 5) |
+			    ((blue  & 0xf800) >> 11);
+			break;
+		case 32:
+			red >>= 8; green >>= 8; blue >>= 8; transp >>= 8;
+			((u32*)(info->pseudo_palette))[regno] =
+			    (transp << 24) | (red << 16) | (green << 8) | blue;
+			break;
+		}
+	}
+
+	return 0;
+}
+
+int __init kyrofb_setup(char *options)
+{
+	char *this_opt;
+
+	if (!options || !*options)
+		return 0;
+
+	while ((this_opt = strsep(&options, ","))) {
+		if (!*this_opt)
+			continue;
+		if (strcmp(this_opt, "nopan") == 0) {
+			nopan = 1;
+		} else if (strcmp(this_opt, "nowrap") == 0) {
+			nowrap = 1;
+#ifdef CONFIG_MTRR
+		} else if (strcmp(this_opt, "nomtrr") == 0) {
+			nomtrr = 1;
+#endif
+		} else {
+			mode_option = this_opt;
+		}
+	}
+
+	return 0;
+}
+
+static int kyrofb_ioctl(struct inode *inode, struct file *file,
+			unsigned int cmd, unsigned long arg,
+			struct fb_info *info)
+{
+	overlay_create ol_create;
+	overlay_viewport_set ol_viewport_set;
+
+	switch (cmd) {
+	case KYRO_IOCTL_OVERLAY_CREATE:
+		copy_from_user((void *) &ol_create, (void *) arg,
+			       sizeof(overlay_create));
+
+		if (kyro_dev_overlay_create(ol_create.ulWidth,
+					    ol_create.ulHeight, 0) < 0) {
+			printk(KERN_ERR "Kyro FB: failed to create overlay surface.\n");
+
+			return -EINVAL;
+		}
+		break;
+	case KYRO_IOCTL_OVERLAY_VIEWPORT_SET:
+		copy_from_user((void *) &ol_viewport_set, (void *) arg,
+			       sizeof(overlay_viewport_set));
+
+		if (kyro_dev_overlay_viewport_set(ol_viewport_set.xOrgin,
+						  ol_viewport_set.yOrgin,
+						  ol_viewport_set.xSize,
+						  ol_viewport_set.ySize) != 0)
+		{
+			printk(KERN_ERR "Kyro FB: failed to create overlay viewport.\n");
+			return -EINVAL;
+		}
+		break;
+	case KYRO_IOCTL_SET_VIDEO_MODE:
+		{
+			printk(KERN_ERR "Kyro FB: KYRO_IOCTL_SET_VIDEO_MODE is"
+				"obsolete, use the appropriate fb_ioctl()"
+				"command instead.\n");
+			return -EINVAL;
+		}
+		break;
+	case KYRO_IOCTL_UVSTRIDE:
+		copy_to_user((void *)arg, (void *)&deviceInfo.ulOverlayUVStride, sizeof(unsigned long));
+		break;
+	case KYRO_IOCTL_STRIDE:
+		copy_to_user((void *)arg, (void *)&deviceInfo.ulOverlayStride, sizeof(unsigned long));
+		break;
+	case KYRO_IOCTL_OVERLAY_OFFSET:
+		copy_to_user((void *)arg, (void *)&deviceInfo.ulOverlayOffset, sizeof(unsigned long));
+		break;
+	}
+
+	return 0;
+}
+
+static struct pci_device_id kyrofb_pci_tbl[] = {
+	{ PCI_VENDOR_ID_ST, PCI_DEVICE_ID_STG4000,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ 0, }
+};
+
+MODULE_DEVICE_TABLE(pci, kyrofb_pci_tbl);
+
+static struct pci_driver kyrofb_pci_driver = {
+	.name		= "kyrofb",
+	.id_table	= kyrofb_pci_tbl,
+	.probe		= kyrofb_probe,
+	.remove		= __devexit_p(kyrofb_remove),
+};
+
+static struct fb_ops kyrofb_ops = {
+	.owner		= THIS_MODULE,
+	.fb_check_var	= kyrofb_check_var,
+	.fb_set_par	= kyrofb_set_par,
+	.fb_setcolreg	= kyrofb_setcolreg,
+	.fb_ioctl	= kyrofb_ioctl,
+	.fb_fillrect	= cfb_fillrect,
+	.fb_copyarea	= cfb_copyarea,
+	.fb_imageblit	= cfb_imageblit,
+	.fb_cursor	= soft_cursor,
+};
+
+static int __devinit kyrofb_probe(struct pci_dev *pdev,
+				  const struct pci_device_id *ent)
+{
+	struct fb_info *info;
+	unsigned long size;
+	int err;
+
+	if ((err = pci_enable_device(pdev))) {
+		printk(KERN_WARNING "kyrofb: Can't enable pdev: %d\n", err);
+		return err;
+	}
+
+	size = sizeof(struct fb_info) + sizeof(struct kyrofb_info) + 16 * sizeof(u32);
+	info = kmalloc(size, GFP_KERNEL);
+	if (!info)
+		return -ENOMEM;
+
+	memset(info, 0, size);
+
+	currentpar = (struct kyrofb_info *)(info + 1);
+
+	kyro_fix.smem_start = pci_resource_start(pdev, 0);
+	kyro_fix.smem_len   = pci_resource_len(pdev, 0);
+	kyro_fix.mmio_start = pci_resource_start(pdev, 1);
+	kyro_fix.mmio_len   = pci_resource_len(pdev, 1);
+
+	currentpar->regbase = deviceInfo.pSTGReg =
+		ioremap_nocache(kyro_fix.mmio_start, kyro_fix.mmio_len);
+
+	info->screen_base = ioremap_nocache(kyro_fix.smem_start,
+					    kyro_fix.smem_len);
+
+#ifdef CONFIG_MTRR
+	if (!nomtrr)
+		currentpar->mtrr_handle =
+			mtrr_add(kyro_fix.smem_start,
+				 kyro_fix.smem_len,
+				 MTRR_TYPE_WRCOMB, 1);
+#endif
+
+	kyro_fix.ypanstep	= nopan ? 0 : 1;
+	kyro_fix.ywrapstep	= nowrap ? 0 : 1;
+
+	info->fbops		= &kyrofb_ops;
+	info->fix		= kyro_fix;
+	info->par		= currentpar;
+	info->pseudo_palette	= (void *)(currentpar + 1);
+	info->flags		= FBINFO_FLAG_DEFAULT;
+
+	SetCoreClockPLL(deviceInfo.pSTGReg, pdev);
+
+	deviceInfo.ulNextFreeVidMem = 0;
+	deviceInfo.ulOverlayOffset = 0;
+
+	/* This should give a reasonable default video mode */
+#ifndef MODULE
+	if (!fb_find_mode(&info->var, info, mode_option, kyro_modedb,
+			  NUM_TOTAL_MODES, &kyro_modedb[VMODE_1024_768_75], 32))
+#endif
+		info->var = kyro_var;
+
+	fb_alloc_cmap(&info->cmap, 256, 0);
+
+	kyrofb_set_par(info);
+	kyrofb_check_var(&info->var, info);
+
+	size = get_line_length(info->var.xres_virtual,
+			       info->var.bits_per_pixel);
+	size *= info->var.yres_virtual;
+
+	memset_io((unsigned long)info->screen_base, 0, size);
+
+	if (register_framebuffer(info) < 0)
+		goto out_unmap;
+
+	printk("fb%d: %s frame buffer device, at %dx%d@%d using %ldk/%ldk of VRAM\n",
+	       info->node, info->fix.id, info->var.xres,
+	       info->var.yres, info->var.bits_per_pixel, size >> 10,
+	       (unsigned long)info->fix.smem_len >> 10);
+
+	pci_set_drvdata(pdev, info);
+
+	return 0;
+
+out_unmap:
+	iounmap(currentpar->regbase);
+	iounmap(info->screen_base);
+	kfree(info);
+
+	return -EINVAL;
+}
+
+static void __devexit kyrofb_remove(struct pci_dev *pdev)
+{
+	struct fb_info *info = pci_get_drvdata(pdev);
+	struct kyrofb_info *par = (struct kyrofb_info *)info->par;
+
+	/* Reset the board */
+	StopVTG(deviceInfo.pSTGReg);
+	DisableRamdacOutput(deviceInfo.pSTGReg);
+
+	/* Sync up the PLL */
+	SetCoreClockPLL(deviceInfo.pSTGReg, pdev);
+
+	deviceInfo.ulNextFreeVidMem = 0;
+	deviceInfo.ulOverlayOffset = 0;
+
+	iounmap(info->screen_base);
+	iounmap(par->regbase);
+
+#ifdef CONFIG_MTRR
+	if (par->mtrr_handle)
+		mtrr_del(par->mtrr_handle,
+			 info->fix.smem_start,
+			 info->fix.smem_len);
+#endif
+
+	unregister_framebuffer(info);
+	pci_set_drvdata(pdev, NULL);
+	kfree(info);
+}
+
+int __init kyrofb_init(void)
+{
+	return pci_module_init(&kyrofb_pci_driver);
+}
+
+static void __exit kyrofb_exit(void)
+{
+	pci_unregister_driver(&kyrofb_pci_driver);
+}
+
+#ifdef MODULE
+module_init(kyrofb_init);
+module_exit(kyrofb_exit);
+#endif
+
+MODULE_AUTHOR("STMicroelectronics; Paul Mundt <lethal@linux-sh.org>");
+MODULE_LICENSE("GPL");
diff -puN /dev/null drivers/video/kyro/Makefile
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/video/kyro/Makefile	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,13 @@
+#
+# Makefile for the Kyro framebuffer driver
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+# Note 2! The CFLAGS definitions are now in the main makefile...
+
+obj-$(CONFIG_FB_KYRO)	+= kyrofb.o
+
+kyrofb-objs	:= STG4000Ramdac.o STG4000VTG.o STG4000OverlayDevice.o \
+		   STG4000InitDevice.o fbdev.o
diff -puN /dev/null drivers/video/kyro/STG4000InitDevice.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/video/kyro/STG4000InitDevice.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,326 @@
+/*
+ *  linux/drivers/video/kyro/STG4000InitDevice.c
+ *
+ *  Copyright (C) 2000 Imagination Technologies Ltd
+ *  Copyright (C) 2002 STMicroelectronics
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file COPYING in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+
+#include "STG4000Reg.h"
+
+/* SDRAM fixed settings */
+#define SDRAM_CFG_0   0x49A1
+#define SDRAM_CFG_1   0xA732
+#define SDRAM_CFG_2   0x31
+#define SDRAM_ARB_CFG 0xA0
+#define SDRAM_REFRESH 0x20
+
+/* Reset values */
+#define PMX2_SOFTRESET_DAC_RST		0x0001
+#define PMX2_SOFTRESET_C1_RST		0x0004
+#define PMX2_SOFTRESET_C2_RST		0x0008
+#define PMX2_SOFTRESET_3D_RST		0x0010
+#define PMX2_SOFTRESET_VIDIN_RST	0x0020
+#define PMX2_SOFTRESET_TLB_RST		0x0040
+#define PMX2_SOFTRESET_SD_RST		0x0080
+#define PMX2_SOFTRESET_VGA_RST		0x0100
+#define PMX2_SOFTRESET_ROM_RST		0x0200	/* reserved bit, do not reset */
+#define PMX2_SOFTRESET_TA_RST		0x0400
+#define PMX2_SOFTRESET_REG_RST		0x4000
+#define PMX2_SOFTRESET_ALL		0x7fff
+
+/* Core clock freq */
+#define CORE_PLL_FREQ 1000000
+
+/* Reference Clock freq */
+#define REF_FREQ 14318
+
+/* PCI Registers */
+static u16 CorePllControl = 0x70;
+
+#define	PCI_CONFIG_SUBSYS_ID	0x2e
+
+/* Misc */
+#define CORE_PLL_MODE_REG_0_7      3
+#define CORE_PLL_MODE_REG_8_15     2
+#define CORE_PLL_MODE_CONFIG_REG   1
+#define DAC_PLL_CONFIG_REG         0
+
+#define STG_MAX_VCO 500000
+#define STG_MIN_VCO 100000
+
+/* PLL Clock */
+#define    STG4K3_PLL_SCALER      8	/* scale numbers by 2^8 for fixed point calc */
+#define    STG4K3_PLL_MIN_R       2	/* Minimum multiplier */
+#define    STG4K3_PLL_MAX_R       33	/* Max */
+#define    STG4K3_PLL_MIN_F       2	/* Minimum divisor */
+#define    STG4K3_PLL_MAX_F       513	/* Max */
+#define    STG4K3_PLL_MIN_OD      0	/* Min output divider (shift) */
+#define    STG4K3_PLL_MAX_OD      2	/* Max */
+#define    STG4K3_PLL_MIN_VCO_SC  (100000000 >> STG4K3_PLL_SCALER)	/* Min VCO rate */
+#define    STG4K3_PLL_MAX_VCO_SC  (500000000 >> STG4K3_PLL_SCALER)	/* Max VCO rate */
+#define    STG4K3_PLL_MINR_VCO_SC (100000000 >> STG4K3_PLL_SCALER)	/* Min VCO rate (restricted) */
+#define    STG4K3_PLL_MAXR_VCO_SC (500000000 >> STG4K3_PLL_SCALER)	/* Max VCO rate (restricted) */
+#define    STG4K3_PLL_MINR_VCO    100000000	/* Min VCO rate (restricted) */
+#define    STG4K3_PLL_MAX_VCO     500000000	/* Max VCO rate */
+#define    STG4K3_PLL_MAXR_VCO    500000000	/* Max VCO rate (restricted) */
+
+#define OS_DELAY(X) \
+{ \
+volatile u32 i,count=0; \
+    for(i=0;i<X;i++) count++; \
+}
+
+u32 InitSDRAMRegisters(volatile STG4000REG * pSTGReg, u32 dwSubSysID,
+			 u32 dwRevID)
+{
+	u32 adwSDRAMArgCfg0[] = { 0xa0, 0x80, 0xa0, 0xa0, 0xa0 };
+	u32 adwSDRAMCfg1[] = { 0x8732, 0x8732, 0xa732, 0xa732, 0x8732 };
+	u32 adwSDRAMCfg2[] = { 0x87d2, 0x87d2, 0xa7d2, 0x87d2, 0xa7d2 };
+	u32 adwSDRAMRsh[] = { 36, 39, 40 };
+	u32 adwChipSpeed[] = { 110, 120, 125 };
+	u32 dwMemTypeIdx;
+	u32 dwChipSpeedIdx;
+
+	/* Get memory tpye and chip speed indexs from the SubSysDevID */
+	dwMemTypeIdx = (dwSubSysID & 0x70) >> 4;
+	dwChipSpeedIdx = (dwSubSysID & 0x180) >> 7;
+
+	if (dwMemTypeIdx > 4 || dwChipSpeedIdx > 2)
+		return 0;
+
+	/* Program SD-RAM interface */
+	STG_WRITE_REG(SDRAMArbiterConf, adwSDRAMArgCfg0[dwMemTypeIdx]);
+	if (dwRevID < 5) {
+		STG_WRITE_REG(SDRAMConf0, 0x49A1);
+		STG_WRITE_REG(SDRAMConf1, adwSDRAMCfg1[dwMemTypeIdx]);
+	} else {
+		STG_WRITE_REG(SDRAMConf0, 0x4DF1);
+		STG_WRITE_REG(SDRAMConf1, adwSDRAMCfg2[dwMemTypeIdx]);
+	}
+
+	STG_WRITE_REG(SDRAMConf2, 0x31);
+	STG_WRITE_REG(SDRAMRefresh, adwSDRAMRsh[dwChipSpeedIdx]);
+
+	return adwChipSpeed[dwChipSpeedIdx] * 10000;
+}
+
+u32 ProgramClock(u32 refClock,
+		   u32 coreClock,
+		   u32 * FOut, u32 * ROut, u32 * POut)
+{
+	u32 R = 0, F = 0, OD = 0, ODIndex = 0;
+	u32 ulBestR = 0, ulBestF = 0, ulBestOD = 0;
+	u32 ulBestVCO = 0, ulBestClk = 0, ulBestScore = 0;
+	u32 ulScore, ulPhaseScore, ulVcoScore;
+	u32 ulTmp = 0, ulVCO;
+	u32 ulScaleClockReq, ulMinClock, ulMaxClock;
+	u32 ODValues[] = { 1, 2, 0 };
+
+	/* Translate clock in Hz */
+	coreClock *= 100;	/* in Hz */
+	refClock *= 1000;	/* in Hz */
+
+	/* Work out acceptable clock
+	 * The method calculates ~ +- 0.4% (1/256)
+	 */
+	ulMinClock = coreClock - (coreClock >> 8);
+	ulMaxClock = coreClock + (coreClock >> 8);
+
+	/* Scale clock required for use in calculations */
+	ulScaleClockReq = coreClock >> STG4K3_PLL_SCALER;
+
+	/* Iterate through post divider values */
+	for (ODIndex = 0; ODIndex < 3; ODIndex++) {
+		OD = ODValues[ODIndex];
+		R = STG4K3_PLL_MIN_R;
+
+		/* loop for pre-divider from min to max  */
+		while (R <= STG4K3_PLL_MAX_R) {
+			/* estimate required feedback multiplier */
+			ulTmp = R * (ulScaleClockReq << OD);
+
+			/* F = ClkRequired * R * (2^OD) / Fref */
+			F = (u32)(ulTmp / (refClock >> STG4K3_PLL_SCALER));
+
+			/* compensate for accuracy */
+			if (F > STG4K3_PLL_MIN_F)
+				F--;
+
+
+			/*
+			 * We should be close to our target frequency (if it's
+			 * achievable with current OD & R) let's iterate
+			 * through F for best fit
+			 */
+			while ((F >= STG4K3_PLL_MIN_F) &&
+			       (F <= STG4K3_PLL_MAX_F)) {
+				/* Calc VCO at full accuracy */
+				ulVCO = refClock / R;
+				ulVCO = F * ulVCO;
+
+				/*
+				 * Check it's within restricted VCO range
+				 * unless of course the desired frequency is
+				 * above the restricted range, then test
+				 * against VCO limit
+				 */
+				if ((ulVCO >= STG4K3_PLL_MINR_VCO) &&
+				    ((ulVCO <= STG4K3_PLL_MAXR_VCO) ||
+				     ((coreClock > STG4K3_PLL_MAXR_VCO)
+				      && (ulVCO <= STG4K3_PLL_MAX_VCO)))) {
+					ulTmp = (ulVCO >> OD);	/* Clock = VCO / (2^OD) */
+
+					/* Is this clock good enough? */
+					if ((ulTmp >= ulMinClock)
+					    && (ulTmp <= ulMaxClock)) {
+						ulPhaseScore = (((refClock / R) - (refClock / STG4K3_PLL_MAX_R))) / ((refClock - (refClock / STG4K3_PLL_MAX_R)) >> 10);
+
+						ulVcoScore = ((ulVCO - STG4K3_PLL_MINR_VCO)) / ((STG4K3_PLL_MAXR_VCO - STG4K3_PLL_MINR_VCO) >> 10);
+						ulScore = ulPhaseScore + ulVcoScore;
+
+						if (!ulBestScore) {
+							ulBestVCO = ulVCO;
+							ulBestOD = OD;
+							ulBestF = F;
+							ulBestR = R;
+							ulBestClk = ulTmp;
+							ulBestScore =
+							    ulScore;
+						}
+						/* is this better, ( aim for highest Score) */
+			/*--------------------------------------------------------------------------
+                             Here we want to use a scoring system which will take account of both the
+                            value at the phase comparater and the VCO output
+                             to do this we will use a cumulative score between the two
+                          The way this ends up is that we choose the first value in the loop anyway
+                          but we shall keep this code in case new restrictions come into play
+                          --------------------------------------------------------------------------*/
+						if ((ulScore >= ulBestScore) && (OD > 0)) {
+							ulBestVCO = ulVCO;
+							ulBestOD = OD;
+							ulBestF = F;
+							ulBestR = R;
+							ulBestClk = ulTmp;
+							ulBestScore =
+							    ulScore;
+						}
+					}
+				}
+				F++;
+			}
+			R++;
+		}
+	}
+
+	/*
+	   did we find anything?
+	   Then return RFOD
+	 */
+	if (ulBestScore) {
+		*ROut = ulBestR;
+		*FOut = ulBestF;
+
+		if ((ulBestOD == 2) || (ulBestOD == 3)) {
+			*POut = 3;
+		} else
+			*POut = ulBestOD;
+
+	}
+
+	return (ulBestClk);
+}
+
+int SetCoreClockPLL(volatile STG4000REG * pSTGReg, struct pci_dev *pDev)
+{
+	u32 F, R, P;
+	u16 core_pll = 0, sub;
+	u32 ulCoreClock;
+	u32 tmp;
+	u32 ulChipSpeed;
+	u8 rev;
+
+	STG_WRITE_REG(IntMask, 0xFFFF);
+
+	/* Disable Primary Core Thread0 */
+	tmp = STG_READ_REG(Thread0Enable);
+	CLEAR_BIT(0);
+	STG_WRITE_REG(Thread0Enable, tmp);
+
+	/* Disable Primary Core Thread1 */
+	tmp = STG_READ_REG(Thread1Enable);
+	CLEAR_BIT(0);
+	STG_WRITE_REG(Thread1Enable, tmp);
+
+	STG_WRITE_REG(SoftwareReset,
+		      PMX2_SOFTRESET_REG_RST | PMX2_SOFTRESET_ROM_RST);
+	STG_WRITE_REG(SoftwareReset,
+		      PMX2_SOFTRESET_REG_RST | PMX2_SOFTRESET_TA_RST |
+		      PMX2_SOFTRESET_ROM_RST);
+
+	/* Need to play around to reset TA */
+	STG_WRITE_REG(TAConfiguration, 0);
+	STG_WRITE_REG(SoftwareReset,
+		      PMX2_SOFTRESET_REG_RST | PMX2_SOFTRESET_ROM_RST);
+	STG_WRITE_REG(SoftwareReset,
+		      PMX2_SOFTRESET_REG_RST | PMX2_SOFTRESET_TA_RST |
+		      PMX2_SOFTRESET_ROM_RST);
+
+	pci_read_config_word(pDev, PCI_CONFIG_SUBSYS_ID, &sub);
+	pci_read_config_byte(pDev, PCI_REVISION_ID, &rev);
+
+	ulChipSpeed = InitSDRAMRegisters(pSTGReg, (u32)sub, (u32)rev);
+
+	if (ulChipSpeed == 0)
+		return -EINVAL;
+
+	ulCoreClock = ProgramClock(REF_FREQ, CORE_PLL_FREQ, &F, &R, &P);
+
+	core_pll |= ((P) | ((F - 2) << 2) | ((R - 2) << 11));
+
+	/* Set Core PLL Control to Core PLL Mode  */
+
+	/* Send bits 0:7 of the Core PLL Mode register */
+	tmp = ((CORE_PLL_MODE_REG_0_7 << 8) | (core_pll & 0x00FF));
+	pci_write_config_word(pDev, CorePllControl, tmp);
+	/* Without some delay between the PCI config writes the clock does
+	   not reliably set when the code is compiled -O3
+	 */
+	OS_DELAY(1000000);
+
+	tmp |= SET_BIT(14);
+	pci_write_config_word(pDev, CorePllControl, tmp);
+	OS_DELAY(1000000);
+
+	/* Send bits 8:15 of the Core PLL Mode register */
+	tmp =
+	    ((CORE_PLL_MODE_REG_8_15 << 8) | ((core_pll & 0xFF00) >> 8));
+	pci_write_config_word(pDev, CorePllControl, tmp);
+	OS_DELAY(1000000);
+
+	tmp |= SET_BIT(14);
+	pci_write_config_word(pDev, CorePllControl, tmp);
+	OS_DELAY(1000000);
+
+	STG_WRITE_REG(SoftwareReset, PMX2_SOFTRESET_ALL);
+
+#if 0
+	/* Enable Primary Core Thread0 */
+	tmp = ((STG_READ_REG(Thread0Enable)) | SET_BIT(0));
+	STG_WRITE_REG(Thread0Enable, tmp);
+
+	/* Enable Primary Core Thread1 */
+	tmp = ((STG_READ_REG(Thread1Enable)) | SET_BIT(0));
+	STG_WRITE_REG(Thread1Enable, tmp);
+#endif
+
+	return 0;
+}
diff -puN /dev/null drivers/video/kyro/STG4000Interface.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/video/kyro/STG4000Interface.h	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,60 @@
+/*
+ *  linux/drivers/video/kyro/STG4000Interface.h
+ *
+ *  Copyright (C) 2002 STMicroelectronics
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file COPYING in the main directory of this archive
+ * for more details.
+ */
+
+#ifndef _STG4000INTERFACE_H
+#define _STG4000INTERFACE_H
+
+struct pci_dev;
+
+/*
+ * Ramdac Setup
+ */
+extern int InitialiseRamdac(volatile STG4000REG *pSTGReg, u32 displayDepth,
+			    u32 displayWidth, u32 displayHeight,
+			    s32 HSyncPolarity, s32 VSyncPolarity,
+			    u32 *pixelClock);
+
+extern void DisableRamdacOutput(volatile STG4000REG * pSTGReg);
+extern void EnableRamdacOutput(volatile STG4000REG * pSTGReg);
+
+/*
+ * Timing generator setup
+ */
+extern void DisableVGA(volatile STG4000REG * pSTGReg);
+extern void StopVTG(volatile STG4000REG * pSTGReg);
+extern void StartVTG(volatile STG4000REG * pSTGReg);
+extern void SetupVTG(volatile STG4000REG * pSTGReg,
+		     const struct kyrofb_info * pTiming);
+
+extern u32 ProgramClock(u32 refClock, u32 coreClock, u32 *FOut, u32 *ROut, u32 *POut);
+extern int SetCoreClockPLL(volatile STG4000REG * pSTGReg, struct pci_dev *pDev);
+
+/*
+ * Overlay setup
+ */
+extern void ResetOverlayRegisters(volatile STG4000REG * pSTGReg);
+
+extern int CreateOverlaySurface(volatile STG4000REG * pSTGReg,
+				u32 ulWidth, u32 ulHeight,
+				int bLinear,
+				u32 ulOverlayOffset,
+				u32 * retStride, u32 * retUVStride);
+
+extern int SetOverlayBlendMode(volatile STG4000REG * pSTGReg,
+			       OVRL_BLEND_MODE mode,
+			       u32 ulAlpha, u32 ulColorKey);
+
+extern int SetOverlayViewPort(volatile STG4000REG * pSTGReg,
+			      u32 left, u32 top,
+			      u32 right, u32 bottom);
+
+extern void EnableOverlayPlane(volatile STG4000REG * pSTGReg);
+
+#endif /* _STG4000INTERFACE_H */
diff -puN /dev/null drivers/video/kyro/STG4000OverlayDevice.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/video/kyro/STG4000OverlayDevice.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,600 @@
+/*
+ *  linux/drivers/video/kyro/STG4000OverlayDevice.c
+ *
+ *  Copyright (C) 2000 Imagination Technologies Ltd
+ *  Copyright (C) 2002 STMicroelectronics
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file COPYING in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/types.h>
+
+#include "STG4000Reg.h"
+
+/* HW Defines */
+
+#define STG4000_NO_SCALING    0x800
+#define STG4000_NO_DECIMATION 0xFFFFFFFF
+
+/* Primary surface */
+#define STG4000_PRIM_NUM_PIX   5
+#define STG4000_PRIM_ALIGN     4
+#define STG4000_PRIM_ADDR_BITS 20
+
+#define STG4000_PRIM_MIN_WIDTH  640
+#define STG4000_PRIM_MAX_WIDTH  1600
+#define STG4000_PRIM_MIN_HEIGHT 480
+#define STG4000_PRIM_MAX_HEIGHT 1200
+
+/* Overlay surface */
+#define STG4000_OVRL_NUM_PIX   4
+#define STG4000_OVRL_ALIGN     2
+#define STG4000_OVRL_ADDR_BITS 20
+#define STG4000_OVRL_NUM_MODES 5
+
+#define STG4000_OVRL_MIN_WIDTH  0
+#define STG4000_OVRL_MAX_WIDTH  720
+#define STG4000_OVRL_MIN_HEIGHT 0
+#define STG4000_OVRL_MAX_HEIGHT 576
+
+/* Decimation and Scaling */
+u32 adwDecim8[33] = {
+	0xffffffff, 0xfffeffff, 0xffdffbff, 0xfefefeff, 0xfdf7efbf,
+	    0xfbdf7bdf, 0xf7bbddef, 0xeeeeeeef, 0xeeddbb77, 0xedb76db7,
+	    0xdb6db6db, 0xdb5b5b5b, 0xdab5ad6b, 0xd5ab55ab, 0xd555aaab,
+	    0xaaaaaaab, 0xaaaa5555, 0xaa952a55, 0xa94a5295, 0xa5252525,
+	    0xa4924925, 0x92491249, 0x91224489, 0x91111111, 0x90884211,
+	    0x88410821, 0x88102041, 0x81010101, 0x80800801, 0x80010001,
+	    0x80000001, 0x00000001, 0x00000000
+};
+
+typedef struct _OVRL_SRC_DEST {
+	/*clipped on-screen pixel position of overlay */
+	u32 ulDstX1;
+	u32 ulDstY1;
+	u32 ulDstX2;
+	u32 ulDstY2;
+
+	/*clipped pixel pos of source data within buffer thses need to be 128 bit word aligned */
+	u32 ulSrcX1;
+	u32 ulSrcY1;
+	u32 ulSrcX2;
+	u32 ulSrcY2;
+
+	/* on-screen pixel position of overlay */
+	s32 lDstX1;
+	s32 lDstY1;
+	s32 lDstX2;
+	s32 lDstY2;
+} OVRL_SRC_DEST;
+
+static u32 ovlWidth, ovlHeight, ovlStride;
+static int ovlLinear;
+
+void ResetOverlayRegisters(volatile STG4000REG * pSTGReg)
+{
+	u32 tmp;
+
+	/* Set Overlay address to default */
+	tmp = STG_READ_REG(DACOverlayAddr);
+	CLEAR_BITS_FRM_TO(0, 20);
+	CLEAR_BIT(31);
+	STG_WRITE_REG(DACOverlayAddr, tmp);
+
+	/* Set Overlay U address */
+	tmp = STG_READ_REG(DACOverlayUAddr);
+	CLEAR_BITS_FRM_TO(0, 20);
+	STG_WRITE_REG(DACOverlayUAddr, tmp);
+
+	/* Set Overlay V address */
+	tmp = STG_READ_REG(DACOverlayVAddr);
+	CLEAR_BITS_FRM_TO(0, 20);
+	STG_WRITE_REG(DACOverlayVAddr, tmp);
+
+	/* Set Overlay Size */
+	tmp = STG_READ_REG(DACOverlaySize);
+	CLEAR_BITS_FRM_TO(0, 10);
+	CLEAR_BITS_FRM_TO(12, 31);
+	STG_WRITE_REG(DACOverlaySize, tmp);
+
+	/* Set Overlay Vt Decimation */
+	tmp = STG4000_NO_DECIMATION;
+	STG_WRITE_REG(DACOverlayVtDec, tmp);
+
+	/* Set Overlay format to default value */
+	tmp = STG_READ_REG(DACPixelFormat);
+	CLEAR_BITS_FRM_TO(4, 7);
+	CLEAR_BITS_FRM_TO(16, 22);
+	STG_WRITE_REG(DACPixelFormat, tmp);
+
+	/* Set Vertical scaling to default */
+	tmp = STG_READ_REG(DACVerticalScal);
+	CLEAR_BITS_FRM_TO(0, 11);
+	CLEAR_BITS_FRM_TO(16, 22);
+	tmp |= STG4000_NO_SCALING;	/* Set to no scaling */
+	STG_WRITE_REG(DACVerticalScal, tmp);
+
+	/* Set Horizontal Scaling to default */
+	tmp = STG_READ_REG(DACHorizontalScal);
+	CLEAR_BITS_FRM_TO(0, 11);
+	CLEAR_BITS_FRM_TO(16, 17);
+	tmp |= STG4000_NO_SCALING;	/* Set to no scaling */
+	STG_WRITE_REG(DACHorizontalScal, tmp);
+
+	/* Set Blend mode to Alpha Blend */
+	/* ????? SG 08/11/2001 Surely this isn't the alpha blend mode,
+	   hopefully its overwrite
+	 */
+	tmp = STG_READ_REG(DACBlendCtrl);
+	CLEAR_BITS_FRM_TO(0, 30);
+	tmp = (GRAPHICS_MODE << 28);
+	STG_WRITE_REG(DACBlendCtrl, tmp);
+
+}
+
+int CreateOverlaySurface(volatile STG4000REG * pSTGReg,
+			 u32 inWidth,
+			 u32 inHeight,
+			 int bLinear,
+			 u32 ulOverlayOffset,
+			 u32 * retStride, u32 * retUVStride)
+{
+	u32 tmp;
+	u32 ulStride;
+
+	if (inWidth > STG4000_OVRL_MAX_WIDTH ||
+	    inHeight > STG4000_OVRL_MAX_HEIGHT) {
+		return -EINVAL;
+	}
+
+	/* Stride in 16 byte words - 16Bpp */
+	if (bLinear) {
+		/* Format is 16bits so num 16 byte words is width/8 */
+		if ((inWidth & 0x7) == 0) {	/* inWidth % 8 */
+			ulStride = (inWidth / 8);
+		} else {
+			/* Round up to next 16byte boundary */
+			ulStride = ((inWidth + 8) / 8);
+		}
+	} else {
+		/* Y component is 8bits so num 16 byte words is width/16 */
+		if ((inWidth & 0xf) == 0) {	/* inWidth % 16 */
+			ulStride = (inWidth / 16);
+		} else {
+			/* Round up to next 16byte boundary */
+			ulStride = ((inWidth + 16) / 16);
+		}
+	}
+
+
+	/* Set Overlay address and Format mode */
+	tmp = STG_READ_REG(DACOverlayAddr);
+	CLEAR_BITS_FRM_TO(0, 20);
+	if (bLinear) {
+		CLEAR_BIT(31);	/* Overlay format to Linear */
+	} else {
+		tmp |= SET_BIT(31);	/* Overlay format to Planer */
+	}
+
+	/* Only bits 24:4 of the Overlay address */
+	tmp |= (ulOverlayOffset >> 4);
+	STG_WRITE_REG(DACOverlayAddr, tmp);
+
+	if (!bLinear) {
+		u32 uvSize =
+		    (inWidth & 0x1) ? (inWidth + 1 / 2) : (inWidth / 2);
+		u32 uvStride;
+		u32 ulOffset;
+		/* Y component is 8bits so num 32 byte words is width/32 */
+		if ((uvSize & 0xf) == 0) {	/* inWidth % 16 */
+			uvStride = (uvSize / 16);
+		} else {
+			/* Round up to next 32byte boundary */
+			uvStride = ((uvSize + 16) / 16);
+		}
+
+		ulOffset = ulOverlayOffset + (inHeight * (ulStride * 16));
+		/* Align U,V data to 32byte boundary */
+		if ((ulOffset & 0x1f) != 0)
+			ulOffset = (ulOffset + 32L) & 0xffffffE0L;
+
+		tmp = STG_READ_REG(DACOverlayUAddr);
+		CLEAR_BITS_FRM_TO(0, 20);
+		tmp |= (ulOffset >> 4);
+		STG_WRITE_REG(DACOverlayUAddr, tmp);
+
+		ulOffset += (inHeight / 2) * (uvStride * 16);
+		/* Align U,V data to 32byte boundary */
+		if ((ulOffset & 0x1f) != 0)
+			ulOffset = (ulOffset + 32L) & 0xffffffE0L;
+
+		tmp = STG_READ_REG(DACOverlayVAddr);
+		CLEAR_BITS_FRM_TO(0, 20);
+		tmp |= (ulOffset >> 4);
+		STG_WRITE_REG(DACOverlayVAddr, tmp);
+
+		*retUVStride = uvStride * 16;
+	}
+
+
+	/* Set Overlay YUV pixel format
+	 * Make sure that LUT not used - ??????
+	 */
+	tmp = STG_READ_REG(DACPixelFormat);
+	/* Only support Planer or UYVY linear formats */
+	CLEAR_BITS_FRM_TO(4, 9);
+	STG_WRITE_REG(DACPixelFormat, tmp);
+
+	ovlWidth = inWidth;
+	ovlHeight = inHeight;
+	ovlStride = ulStride;
+	ovlLinear = bLinear;
+	*retStride = ulStride << 4;	/* In bytes */
+
+	return 0;
+}
+
+int SetOverlayBlendMode(volatile STG4000REG * pSTGReg,
+			OVRL_BLEND_MODE mode,
+			u32 ulAlpha, u32 ulColorKey)
+{
+	u32 tmp;
+
+	tmp = STG_READ_REG(DACBlendCtrl);
+	CLEAR_BITS_FRM_TO(28, 30);
+	tmp |= (mode << 28);
+
+	switch (mode) {
+	case COLOR_KEY:
+		CLEAR_BITS_FRM_TO(0, 23);
+		tmp |= (ulColorKey & 0x00FFFFFF);
+		break;
+
+	case GLOBAL_ALPHA:
+		CLEAR_BITS_FRM_TO(24, 27);
+		tmp |= ((ulAlpha & 0xF) << 24);
+		break;
+
+	case CK_PIXEL_ALPHA:
+		CLEAR_BITS_FRM_TO(0, 23);
+		tmp |= (ulColorKey & 0x00FFFFFF);
+		break;
+
+	case CK_GLOBAL_ALPHA:
+		CLEAR_BITS_FRM_TO(0, 23);
+		tmp |= (ulColorKey & 0x00FFFFFF);
+		CLEAR_BITS_FRM_TO(24, 27);
+		tmp |= ((ulAlpha & 0xF) << 24);
+		break;
+
+	case GRAPHICS_MODE:
+	case PER_PIXEL_ALPHA:
+		break;
+
+	default:
+		return -EINVAL;
+	}
+
+	STG_WRITE_REG(DACBlendCtrl, tmp);
+
+	return 0;
+}
+
+void EnableOverlayPlane(volatile STG4000REG * pSTGReg)
+{
+	u32 tmp;
+	/* Enable Overlay */
+	tmp = STG_READ_REG(DACPixelFormat);
+	tmp |= SET_BIT(7);
+	STG_WRITE_REG(DACPixelFormat, tmp);
+
+	/* Set video stream control */
+	tmp = STG_READ_REG(DACStreamCtrl);
+	tmp |= SET_BIT(1);	/* video stream */
+	STG_WRITE_REG(DACStreamCtrl, tmp);
+}
+
+static u32 Overlap(u32 ulBits, u32 ulPattern)
+{
+	u32 ulCount = 0;
+
+	while (ulBits) {
+		if (!(ulPattern & 1))
+			ulCount++;
+		ulBits--;
+		ulPattern = ulPattern >> 1;
+	}
+
+	return ulCount;
+
+}
+
+int SetOverlayViewPort(volatile STG4000REG * pSTGReg,
+		       u32 left, u32 top,
+		       u32 right, u32 bottom)
+{
+	OVRL_SRC_DEST srcDest;
+
+	u32 ulSrcTop, ulSrcBottom;
+	u32 ulSrc, ulDest;
+	u32 ulFxScale, ulFxOffset;
+	u32 ulHeight, ulWidth;
+	u32 ulPattern;
+	u32 ulDecimate, ulDecimated;
+	u32 ulApplied;
+	u32 ulDacXScale, ulDacYScale;
+	u32 ulScale;
+	u32 ulLeft, ulRight;
+	u32 ulSrcLeft, ulSrcRight;
+	u32 ulScaleLeft, ulScaleRight;
+	u32 ulhDecim;
+	u32 ulsVal;
+	u32 ulVertDecFactor;
+	int bResult;
+	u32 ulClipOff = 0;
+	u32 ulBits = 0;
+	u32 ulsAdd = 0;
+	u32 tmp, ulStride;
+	u32 ulExcessPixels, ulClip, ulExtraLines;
+
+
+	srcDest.ulSrcX1 = 0;
+	srcDest.ulSrcY1 = 0;
+	srcDest.ulSrcX2 = ovlWidth - 1;
+	srcDest.ulSrcY2 = ovlHeight - 1;
+
+	srcDest.ulDstX1 = left;
+	srcDest.ulDstY1 = top;
+	srcDest.ulDstX2 = right;
+	srcDest.ulDstY2 = bottom;
+
+	srcDest.lDstX1 = srcDest.ulDstX1;
+	srcDest.lDstY1 = srcDest.ulDstY1;
+	srcDest.lDstX2 = srcDest.ulDstX2;
+	srcDest.lDstY2 = srcDest.ulDstY2;
+
+    /************* Vertical decimation/scaling ******************/
+
+	/* Get Src Top and Bottom */
+	ulSrcTop = srcDest.ulSrcY1;
+	ulSrcBottom = srcDest.ulSrcY2;
+
+	ulSrc = ulSrcBottom - ulSrcTop;
+	ulDest = srcDest.lDstY2 - srcDest.lDstY1;	/* on-screen overlay */
+
+	if (ulSrc <= 1)
+		return -EINVAL;
+
+	/* First work out the position we are to display as offset from the
+	 * source of the buffer
+	 */
+	ulFxScale = (ulDest << 11) / ulSrc;	/* fixed point scale factor */
+	ulFxOffset = (srcDest.lDstY2 - srcDest.ulDstY2) << 11;
+
+	ulSrcBottom = ulSrcBottom - (ulFxOffset / ulFxScale);
+	ulSrc = ulSrcBottom - ulSrcTop;
+	ulHeight = ulSrc;
+
+	ulDest = srcDest.ulDstY2 - (srcDest.ulDstY1 - 1);
+	ulPattern = adwDecim8[ulBits];
+
+	/* At this point ulSrc represents the input decimator */
+	if (ulSrc > ulDest) {
+		ulDecimate = ulSrc - ulDest;
+		ulBits = 0;
+		ulApplied = ulSrc / 32;
+
+		while (((ulBits * ulApplied) +
+			Overlap((ulSrc % 32),
+				adwDecim8[ulBits])) < ulDecimate)
+			ulBits++;
+
+		ulPattern = adwDecim8[ulBits];
+		ulDecimated =
+		    (ulBits * ulApplied) + Overlap((ulSrc % 32),
+						   ulPattern);
+		ulSrc = ulSrc - ulDecimated;	/* the number number of lines that will go into the scaler */
+	}
+
+	if (ulBits && (ulBits != 32)) {
+		ulVertDecFactor = (63 - ulBits) / (32 - ulBits);	/* vertical decimation factor scaled up to nearest integer */
+	} else {
+		ulVertDecFactor = 1;
+	}
+
+	ulDacYScale = ((ulSrc - 1) * 2048) / (ulDest + 1);
+
+	tmp = STG_READ_REG(DACOverlayVtDec);	/* Decimation */
+	CLEAR_BITS_FRM_TO(0, 31);
+	tmp = ulPattern;
+	STG_WRITE_REG(DACOverlayVtDec, tmp);
+
+	/***************** Horizontal decimation/scaling ***************************/
+
+	/*
+	 * Now we handle the horizontal case, this is a simplified verison of
+	 * the vertical case in that we decimate by factors of 2.  as we are
+	 * working in words we should always be able to decimate by these
+	 * factors.  as we always have to have a buffer which is aligned to a
+	 * whole number of 128 bit words, we must align the left side to the
+	 * lowest to the next lowest 128 bit boundary, and the right hand edge
+	 * to the next largets boundary, (in a similar way to how we didi it in
+	 * PMX1) as the left and right hand edges are aligned to these
+	 * boundaries normally this only becomes an issue when we are chopping
+	 * of one of the sides We shall work out vertical stuff first
+	 */
+	ulSrc = srcDest.ulSrcX2 - srcDest.ulSrcX1;
+	ulDest = srcDest.lDstX2 - srcDest.lDstX1;
+#ifdef _OLDCODE
+	ulLeft = srcDest.ulDstX1;
+	ulRight = srcDest.ulDstX2;
+#else
+	if (srcDest.ulDstX1 > 2) {
+		ulLeft = srcDest.ulDstX1 + 2;
+		ulRight = srcDest.ulDstX2 + 1;
+	} else {
+		ulLeft = srcDest.ulDstX1;
+		ulRight = srcDest.ulDstX2 + 1;
+	}
+#endif
+	/* first work out the position we are to display as offset from the source of the buffer */
+	bResult = 1;
+
+	do {
+		if (ulDest == 0)
+			return -EINVAL;
+
+		/* source pixels per dest pixel <<11 */
+		ulFxScale = ((ulSrc - 1) << 11) / (ulDest);
+
+		/* then number of destination pixels out we are */
+		ulFxOffset = ulFxScale * ((srcDest.ulDstX1 - srcDest.lDstX1) + ulClipOff);
+		ulFxOffset >>= 11;
+
+		/* this replaces the code which was making a decision as to use either ulFxOffset or ulSrcX1 */
+		ulSrcLeft = srcDest.ulSrcX1 + ulFxOffset;
+
+		/* then number of destination pixels out we are */
+		ulFxOffset = ulFxScale * (srcDest.lDstX2 - srcDest.ulDstX2);
+		ulFxOffset >>= 11;
+
+		ulSrcRight = srcDest.ulSrcX2 - ulFxOffset;
+
+		/*
+		 * we must align these to our 128 bit boundaries. we shall
+		 * round down the pixel pos to the nearest 8 pixels.
+		 */
+		ulScaleLeft = ulSrcLeft;
+		ulScaleRight = ulSrcRight;
+
+		/* shift fxscale until it is in the range of the scaler */
+		ulhDecim = 0;
+		ulScale = (((ulSrcRight - ulSrcLeft) - 1) << (11 - ulhDecim)) / (ulRight - ulLeft + 2);
+
+		while (ulScale > 0x800) {
+			ulhDecim++;
+			ulScale = (((ulSrcRight - ulSrcLeft) - 1) << (11 - ulhDecim)) / (ulRight - ulLeft + 2);
+		}
+
+		/*
+		 * to try and get the best values We first try and use
+		 * src/dwdest for the scale factor, then we move onto src-1
+		 *
+		 * we want to check to see if we will need to clip data, if so
+		 * then we should clip our source so that we don't need to
+		 */
+		if (!ovlLinear) {
+			ulSrcLeft &= ~0x1f;
+
+			/*
+			 * we must align the right hand edge to the next 32
+			 * pixel` boundary, must be on a 256 boundary so u, and
+			 * v are 128 bit aligned
+			 */
+			ulSrcRight = (ulSrcRight + 0x1f) & ~0x1f;
+		} else {
+			ulSrcLeft &= ~0x7;
+
+			/*
+			 * we must align the right hand edge to the next
+			 * 8pixel` boundary
+			 */
+			ulSrcRight = (ulSrcRight + 0x7) & ~0x7;
+		}
+
+		/* this is the input size line store needs to cope with */
+		ulWidth = ulSrcRight - ulSrcLeft;
+
+		/*
+		 * use unclipped value to work out scale factror this is the
+		 * scale factor we want we shall now work out the horizonal
+		 * decimation and scaling
+		 */
+		ulsVal = ((ulWidth / 8) >> ulhDecim);
+
+		if ((ulWidth != (ulsVal << ulhDecim) * 8))
+			ulsAdd = 1;
+
+		/* input pixels to scaler; */
+		ulSrc = ulWidth >> ulhDecim;
+
+		if (ulSrc <= 2)
+			return -EINVAL;
+
+		ulExcessPixels = ((((ulScaleLeft - ulSrcLeft)) << (11 - ulhDecim)) / ulScale);
+
+		ulClip = (ulSrc << 11) / ulScale;
+		ulClip -= (ulRight - ulLeft);
+		ulClip += ulExcessPixels;
+
+		if (ulClip)
+			ulClip--;
+
+		/* We may need to do more here if we really have a HW rev < 5 */
+	} while (!bResult);
+
+	ulExtraLines = (1 << ulhDecim) * ulVertDecFactor;
+	ulExtraLines += 64;
+	ulHeight += ulExtraLines;
+
+	ulDacXScale = ulScale;
+
+
+	tmp = STG_READ_REG(DACVerticalScal);
+	CLEAR_BITS_FRM_TO(0, 11);
+	CLEAR_BITS_FRM_TO(16, 22);	/* Vertical Scaling */
+
+	/* Calculate new output line stride, this is always the number of 422
+	   words in the line buffer, so it doesn't matter if the
+	   mode is 420. Then set the vertical scale register.
+	 */
+	ulStride = (ulWidth >> (ulhDecim + 3)) + ulsAdd;
+	tmp |= ((ulStride << 16) | (ulDacYScale));	/* DAC_LS_CTRL = stride */
+	STG_WRITE_REG(DACVerticalScal, tmp);
+
+	/* Now set up the overlay size using the modified width and height
+	   from decimate and scaling calculations
+	 */
+	tmp = STG_READ_REG(DACOverlaySize);
+	CLEAR_BITS_FRM_TO(0, 10);
+	CLEAR_BITS_FRM_TO(12, 31);
+
+	if (ovlLinear) {
+		tmp |=
+		    (ovlStride | ((ulHeight + 1) << 12) |
+		     (((ulWidth / 8) - 1) << 23));
+	} else {
+		tmp |=
+		    (ovlStride | ((ulHeight + 1) << 12) |
+		     (((ulWidth / 32) - 1) << 23));
+	}
+
+	STG_WRITE_REG(DACOverlaySize, tmp);
+
+	/* Set Video Window Start */
+	tmp = ((ulLeft << 16)) | (srcDest.ulDstY1);
+	STG_WRITE_REG(DACVidWinStart, tmp);
+
+	/* Set Video Window End */
+	tmp = ((ulRight) << 16) | (srcDest.ulDstY2);
+	STG_WRITE_REG(DACVidWinEnd, tmp);
+
+	/* Finally set up the rest of the overlay regs in the order
+	   done in the IMG driver
+	 */
+	tmp = STG_READ_REG(DACPixelFormat);
+	tmp = ((ulExcessPixels << 16) | tmp) & 0x7fffffff;
+	STG_WRITE_REG(DACPixelFormat, tmp);
+
+	tmp = STG_READ_REG(DACHorizontalScal);
+	CLEAR_BITS_FRM_TO(0, 11);
+	CLEAR_BITS_FRM_TO(16, 17);
+	tmp |= ((ulhDecim << 16) | (ulDacXScale));
+	STG_WRITE_REG(DACHorizontalScal, tmp);
+
+	return 0;
+}
diff -puN /dev/null drivers/video/kyro/STG4000Ramdac.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/video/kyro/STG4000Ramdac.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,164 @@
+/*
+ *  linux/drivers/video/kyro/STG4000Ramdac.c
+ *
+ *  Copyright (C) 2002 STMicroelectronics
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file COPYING in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <video/kyro.h>
+
+#include "STG4000Reg.h"
+#include "STG4000Interface.h"
+
+static u32 STG_PIXEL_BUS_WIDTH = 128;	/* 128 bit bus width      */
+static u32 REF_CLOCK = 14318;
+STG4000REG *pSTGReg;
+
+int InitialiseRamdac(volatile STG4000REG * pSTGReg,
+		     u32 displayDepth,
+		     u32 displayWidth,
+		     u32 displayHeight,
+		     s32 HSyncPolarity,
+		     s32 VSyncPolarity, u32 * pixelClock)
+{
+	u32 tmp = 0;
+	u32 F = 0, R = 0, P = 0;
+	u32 stride = 0;
+	u32 ulPdiv = 0;
+	u32 physicalPixelDepth = 0;
+	/* Make sure DAC is in Reset */
+	tmp = STG_READ_REG(SoftwareReset);
+
+	if (tmp & 0x1) {
+		CLEAR_BIT(1);
+		STG_WRITE_REG(SoftwareReset, tmp);
+	}
+
+	/* Set Pixel Format */
+	tmp = STG_READ_REG(DACPixelFormat);
+	CLEAR_BITS_FRM_TO(0, 2);
+
+	/* Set LUT not used from 16bpp to 32 bpp ??? */
+	CLEAR_BITS_FRM_TO(8, 9);
+
+	switch (displayDepth) {
+	case 16:
+		{
+			physicalPixelDepth = 16;
+			tmp |= _16BPP;
+			break;
+		}
+	case 32:
+		{
+			/* Set for 32 bits per pixel */
+			physicalPixelDepth = 32;
+			tmp |= _32BPP;
+			break;
+		}
+	default:
+		return -EINVAL;
+	}
+
+	STG_WRITE_REG(DACPixelFormat, tmp);
+
+	/* Workout Bus transfer bandwidth according to pixel format */
+	ulPdiv = STG_PIXEL_BUS_WIDTH / physicalPixelDepth;
+
+	/* Get Screen Stride in pixels */
+	stride = displayWidth;
+
+	/* Set Primary size info */
+	tmp = STG_READ_REG(DACPrimSize);
+	CLEAR_BITS_FRM_TO(0, 10);
+	CLEAR_BITS_FRM_TO(12, 31);
+	tmp |=
+	    ((((displayHeight - 1) << 12) | (((displayWidth / ulPdiv) -
+					      1) << 23))
+	     | (stride / ulPdiv));
+	STG_WRITE_REG(DACPrimSize, tmp);
+
+
+	/* Set Pixel Clock */
+	*pixelClock = ProgramClock(REF_CLOCK, *pixelClock, &F, &R, &P);
+
+	/* Set DAC PLL Mode */
+	tmp = STG_READ_REG(DACPLLMode);
+	CLEAR_BITS_FRM_TO(0, 15);
+	/* tmp |= ((P-1) | ((F-2) << 2) | ((R-2) << 11)); */
+	tmp |= ((P) | ((F - 2) << 2) | ((R - 2) << 11));
+	STG_WRITE_REG(DACPLLMode, tmp);
+
+	/* Set Prim Address */
+	tmp = STG_READ_REG(DACPrimAddress);
+	CLEAR_BITS_FRM_TO(0, 20);
+	CLEAR_BITS_FRM_TO(20, 31);
+	STG_WRITE_REG(DACPrimAddress, tmp);
+
+	/* Set Cursor details with HW Cursor disabled */
+	tmp = STG_READ_REG(DACCursorCtrl);
+	tmp &= ~SET_BIT(31);
+	STG_WRITE_REG(DACCursorCtrl, tmp);
+
+	tmp = STG_READ_REG(DACCursorAddr);
+	CLEAR_BITS_FRM_TO(0, 20);
+	STG_WRITE_REG(DACCursorAddr, tmp);
+
+	/* Set Video Window */
+	tmp = STG_READ_REG(DACVidWinStart);
+	CLEAR_BITS_FRM_TO(0, 10);
+	CLEAR_BITS_FRM_TO(16, 26);
+	STG_WRITE_REG(DACVidWinStart, tmp);
+
+	tmp = STG_READ_REG(DACVidWinEnd);
+	CLEAR_BITS_FRM_TO(0, 10);
+	CLEAR_BITS_FRM_TO(16, 26);
+	STG_WRITE_REG(DACVidWinEnd, tmp);
+
+	/* Set DAC Border Color to default */
+	tmp = STG_READ_REG(DACBorderColor);
+	CLEAR_BITS_FRM_TO(0, 23);
+	STG_WRITE_REG(DACBorderColor, tmp);
+
+	/* Set Graphics and Overlay Burst Control */
+	STG_WRITE_REG(DACBurstCtrl, 0x0404);
+
+	/* Set CRC Trigger to default */
+	tmp = STG_READ_REG(DACCrcTrigger);
+	CLEAR_BIT(0);
+	STG_WRITE_REG(DACCrcTrigger, tmp);
+
+	/* Set Video Port Control to default */
+	tmp = STG_READ_REG(DigVidPortCtrl);
+	CLEAR_BIT(8);
+	CLEAR_BITS_FRM_TO(16, 27);
+	CLEAR_BITS_FRM_TO(1, 3);
+	CLEAR_BITS_FRM_TO(10, 11);
+	STG_WRITE_REG(DigVidPortCtrl, tmp);
+
+	return 0;
+}
+
+/* Ramdac control, turning output to the screen on and off */
+void DisableRamdacOutput(volatile STG4000REG * pSTGReg)
+{
+	u32 tmp;
+
+	/* Disable DAC for Graphics Stream Control */
+	tmp = (STG_READ_REG(DACStreamCtrl)) & ~SET_BIT(0);
+	STG_WRITE_REG(DACStreamCtrl, tmp);
+}
+
+void EnableRamdacOutput(volatile STG4000REG * pSTGReg)
+{
+	u32 tmp;
+
+	/* Enable DAC for Graphics Stream Control */
+	tmp = (STG_READ_REG(DACStreamCtrl)) | SET_BIT(0);
+	STG_WRITE_REG(DACStreamCtrl, tmp);
+}
diff -puN /dev/null drivers/video/kyro/STG4000Reg.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/video/kyro/STG4000Reg.h	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,283 @@
+/*
+ *  linux/drivers/video/kyro/STG4000Reg.h
+ *
+ *  Copyright (C) 2002 STMicroelectronics
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file COPYING in the main directory of this archive
+ * for more details.
+ */
+
+#ifndef _STG4000REG_H
+#define _STG4000REG_H
+
+#define DWFILL unsigned long :32
+#define WFILL unsigned short :16
+
+/*
+ * Macros that access memory mapped card registers in PCI space
+ * Add an appropraite section for your OS or processor architecture.
+ */
+#if defined(__KERNEL__)
+#include <asm/page.h>
+#include <asm/io.h>
+#define STG_WRITE_REG(reg,data) (writel(data,(unsigned long)&pSTGReg->reg))
+#define STG_READ_REG(reg)      (readl((unsigned long)&pSTGReg->reg))
+#else
+#define STG_WRITE_REG(reg,data) (pSTGReg->reg = data)
+#define STG_READ_REG(reg)      (pSTGReg->reg)
+#endif /* __KERNEL__ */
+
+#define SET_BIT(n) (1<<(n))
+#define CLEAR_BIT(n) (tmp &= ~(1<<n))
+#define CLEAR_BITS_FRM_TO(frm, to) \
+{\
+int i; \
+    for(i = frm; i<= to; i++) \
+	{ \
+	    tmp &= ~(1<<i); \
+	} \
+}
+
+#define CLEAR_BIT_2(n) (usTemp &= ~(1<<n))
+#define CLEAR_BITS_FRM_TO_2(frm, to) \
+{\
+int i; \
+    for(i = frm; i<= to; i++) \
+	{ \
+	    usTemp &= ~(1<<i); \
+	} \
+}
+
+/* LUT select */
+typedef enum _LUT_USES {
+	NO_LUT = 0, RESERVED, GRAPHICS, OVERLAY
+} LUT_USES;
+
+/* Primary surface pixel format select */
+typedef enum _PIXEL_FORMAT {
+	_8BPP = 0, _15BPP, _16BPP, _24BPP, _32BPP
+} PIXEL_FORMAT;
+
+/* Overlay blending mode select */
+typedef enum _BLEND_MODE {
+	GRAPHICS_MODE = 0, COLOR_KEY, PER_PIXEL_ALPHA, GLOBAL_ALPHA,
+	CK_PIXEL_ALPHA, CK_GLOBAL_ALPHA
+} OVRL_BLEND_MODE;
+
+/* Overlay Pixel format select */
+typedef enum _OVRL_PIX_FORMAT {
+	UYVY, VYUY, YUYV, YVYU
+} OVRL_PIX_FORMAT;
+
+/* Register Table */
+typedef struct {
+	/* 0h  */
+	volatile unsigned long Thread0Enable;	/* 0x0000 */
+	volatile unsigned long Thread1Enable;	/* 0x0004 */
+	volatile unsigned long Thread0Recover;	/* 0x0008 */
+	volatile unsigned long Thread1Recover;	/* 0x000C */
+	volatile unsigned long Thread0Step;	/* 0x0010 */
+	volatile unsigned long Thread1Step;	/* 0x0014 */
+	volatile unsigned long VideoInStatus;	/* 0x0018 */
+	volatile unsigned long Core2InSignStart;	/* 0x001C */
+	volatile unsigned long Core1ResetVector;	/* 0x0020 */
+	volatile unsigned long Core1ROMOffset;	/* 0x0024 */
+	volatile unsigned long Core1ArbiterPriority;	/* 0x0028 */
+	volatile unsigned long VideoInControl;	/* 0x002C */
+	volatile unsigned long VideoInReg0CtrlA;	/* 0x0030 */
+	volatile unsigned long VideoInReg0CtrlB;	/* 0x0034 */
+	volatile unsigned long VideoInReg1CtrlA;	/* 0x0038 */
+	volatile unsigned long VideoInReg1CtrlB;	/* 0x003C */
+	volatile unsigned long Thread0Kicker;	/* 0x0040 */
+	volatile unsigned long Core2InputSign;	/* 0x0044 */
+	volatile unsigned long Thread0ProgCtr;	/* 0x0048 */
+	volatile unsigned long Thread1ProgCtr;	/* 0x004C */
+	volatile unsigned long Thread1Kicker;	/* 0x0050 */
+	volatile unsigned long GPRegister1;	/* 0x0054 */
+	volatile unsigned long GPRegister2;	/* 0x0058 */
+	volatile unsigned long GPRegister3;	/* 0x005C */
+	volatile unsigned long GPRegister4;	/* 0x0060 */
+	volatile unsigned long SerialIntA;	/* 0x0064 */
+
+	volatile unsigned long Fill0[6];	/* GAP 0x0068 - 0x007C */
+
+	volatile unsigned long SoftwareReset;	/* 0x0080 */
+	volatile unsigned long SerialIntB;	/* 0x0084 */
+
+	volatile unsigned long Fill1[37];	/* GAP 0x0088 - 0x011C */
+
+	volatile unsigned long ROMELQV;	/* 0x011C */
+	volatile unsigned long WLWH;	/* 0x0120 */
+	volatile unsigned long ROMELWL;	/* 0x0124 */
+
+	volatile unsigned long dwFill_1;	/* GAP 0x0128 */
+
+	volatile unsigned long IntStatus;	/* 0x012C */
+	volatile unsigned long IntMask;	/* 0x0130 */
+	volatile unsigned long IntClear;	/* 0x0134 */
+
+	volatile unsigned long Fill2[6];	/* GAP 0x0138 - 0x014C */
+
+	volatile unsigned long ROMGPIOA;	/* 0x0150 */
+	volatile unsigned long ROMGPIOB;	/* 0x0154 */
+	volatile unsigned long ROMGPIOC;	/* 0x0158 */
+	volatile unsigned long ROMGPIOD;	/* 0x015C */
+
+	volatile unsigned long Fill3[2];	/* GAP 0x0160 - 0x0168 */
+
+	volatile unsigned long AGPIntID;	/* 0x0168 */
+	volatile unsigned long AGPIntClassCode;	/* 0x016C */
+	volatile unsigned long AGPIntBIST;	/* 0x0170 */
+	volatile unsigned long AGPIntSSID;	/* 0x0174 */
+	volatile unsigned long AGPIntPMCSR;	/* 0x0178 */
+	volatile unsigned long VGAFrameBufBase;	/* 0x017C */
+	volatile unsigned long VGANotify;	/* 0x0180 */
+	volatile unsigned long DACPLLMode;	/* 0x0184 */
+	volatile unsigned long Core1VideoClockDiv;	/* 0x0188 */
+	volatile unsigned long AGPIntStat;	/* 0x018C */
+
+	/*
+	   volatile unsigned long Fill4[0x0400/4 - 0x0190/4]; //GAP 0x0190 - 0x0400
+	   volatile unsigned long Fill5[0x05FC/4 - 0x0400/4]; //GAP 0x0400 - 0x05FC Fog Table
+	   volatile unsigned long Fill6[0x0604/4 - 0x0600/4]; //GAP 0x0600 - 0x0604
+	   volatile unsigned long Fill7[0x0680/4 - 0x0608/4]; //GAP 0x0608 - 0x0680
+	   volatile unsigned long Fill8[0x07FC/4 - 0x0684/4]; //GAP 0x0684 - 0x07FC
+	 */
+	volatile unsigned long Fill4[412];	/* 0x0190 - 0x07FC */
+
+	volatile unsigned long TACtrlStreamBase;	/* 0x0800 */
+	volatile unsigned long TAObjDataBase;	/* 0x0804 */
+	volatile unsigned long TAPtrDataBase;	/* 0x0808 */
+	volatile unsigned long TARegionDataBase;	/* 0x080C */
+	volatile unsigned long TATailPtrBase;	/* 0x0810 */
+	volatile unsigned long TAPtrRegionSize;	/* 0x0814 */
+	volatile unsigned long TAConfiguration;	/* 0x0818 */
+	volatile unsigned long TAObjDataStartAddr;	/* 0x081C */
+	volatile unsigned long TAObjDataEndAddr;	/* 0x0820 */
+	volatile unsigned long TAXScreenClip;	/* 0x0824 */
+	volatile unsigned long TAYScreenClip;	/* 0x0828 */
+	volatile unsigned long TARHWClamp;	/* 0x082C */
+	volatile unsigned long TARHWCompare;	/* 0x0830 */
+	volatile unsigned long TAStart;	/* 0x0834 */
+	volatile unsigned long TAObjReStart;	/* 0x0838 */
+	volatile unsigned long TAPtrReStart;	/* 0x083C */
+	volatile unsigned long TAStatus1;	/* 0x0840 */
+	volatile unsigned long TAStatus2;	/* 0x0844 */
+	volatile unsigned long TAIntStatus;	/* 0x0848 */
+	volatile unsigned long TAIntMask;	/* 0x084C */
+
+	volatile unsigned long Fill5[235];	/* GAP 0x0850 - 0x0BF8 */
+
+	volatile unsigned long TextureAddrThresh;	/* 0x0BFC */
+	volatile unsigned long Core1Translation;	/* 0x0C00 */
+	volatile unsigned long TextureAddrReMap;	/* 0x0C04 */
+	volatile unsigned long RenderOutAGPRemap;	/* 0x0C08 */
+	volatile unsigned long _3DRegionReadTrans;	/* 0x0C0C */
+	volatile unsigned long _3DPtrReadTrans;	/* 0x0C10 */
+	volatile unsigned long _3DParamReadTrans;	/* 0x0C14 */
+	volatile unsigned long _3DRegionReadThresh;	/* 0x0C18 */
+	volatile unsigned long _3DPtrReadThresh;	/* 0x0C1C */
+	volatile unsigned long _3DParamReadThresh;	/* 0x0C20 */
+	volatile unsigned long _3DRegionReadAGPRemap;	/* 0x0C24 */
+	volatile unsigned long _3DPtrReadAGPRemap;	/* 0x0C28 */
+	volatile unsigned long _3DParamReadAGPRemap;	/* 0x0C2C */
+	volatile unsigned long ZBufferAGPRemap;	/* 0x0C30 */
+	volatile unsigned long TAIndexAGPRemap;	/* 0x0C34 */
+	volatile unsigned long TAVertexAGPRemap;	/* 0x0C38 */
+	volatile unsigned long TAUVAddrTrans;	/* 0x0C3C */
+	volatile unsigned long TATailPtrCacheTrans;	/* 0x0C40 */
+	volatile unsigned long TAParamWriteTrans;	/* 0x0C44 */
+	volatile unsigned long TAPtrWriteTrans;	/* 0x0C48 */
+	volatile unsigned long TAParamWriteThresh;	/* 0x0C4C */
+	volatile unsigned long TAPtrWriteThresh;	/* 0x0C50 */
+	volatile unsigned long TATailPtrCacheAGPRe;	/* 0x0C54 */
+	volatile unsigned long TAParamWriteAGPRe;	/* 0x0C58 */
+	volatile unsigned long TAPtrWriteAGPRe;	/* 0x0C5C */
+	volatile unsigned long SDRAMArbiterConf;	/* 0x0C60 */
+	volatile unsigned long SDRAMConf0;	/* 0x0C64 */
+	volatile unsigned long SDRAMConf1;	/* 0x0C68 */
+	volatile unsigned long SDRAMConf2;	/* 0x0C6C */
+	volatile unsigned long SDRAMRefresh;	/* 0x0C70 */
+	volatile unsigned long SDRAMPowerStat;	/* 0x0C74 */
+
+	volatile unsigned long Fill6[2];	/* GAP 0x0C78 - 0x0C7C */
+
+	volatile unsigned long RAMBistData;	/* 0x0C80 */
+	volatile unsigned long RAMBistCtrl;	/* 0x0C84 */
+	volatile unsigned long FIFOBistKey;	/* 0x0C88 */
+	volatile unsigned long RAMBistResult;	/* 0x0C8C */
+	volatile unsigned long FIFOBistResult;	/* 0x0C90 */
+
+	/*
+	   volatile unsigned long Fill11[0x0CBC/4 - 0x0C94/4]; //GAP 0x0C94 - 0x0CBC
+	   volatile unsigned long Fill12[0x0CD0/4 - 0x0CC0/4]; //GAP 0x0CC0 - 0x0CD0 3DRegisters
+	 */
+
+	volatile unsigned long Fill7[16];	/* 0x0c94 - 0x0cd0 */
+
+	volatile unsigned long SDRAMAddrSign;	/* 0x0CD4 */
+	volatile unsigned long SDRAMDataSign;	/* 0x0CD8 */
+	volatile unsigned long SDRAMSignConf;	/* 0x0CDC */
+
+	/* DWFILL; //GAP 0x0CE0 */
+	volatile unsigned long dwFill_2;
+
+	volatile unsigned long ISPSignature;	/* 0x0CE4 */
+
+	volatile unsigned long Fill8[454];	/*GAP 0x0CE8 - 0x13FC */
+
+	volatile unsigned long DACPrimAddress;	/* 0x1400 */
+	volatile unsigned long DACPrimSize;	/* 0x1404 */
+	volatile unsigned long DACCursorAddr;	/* 0x1408 */
+	volatile unsigned long DACCursorCtrl;	/* 0x140C */
+	volatile unsigned long DACOverlayAddr;	/* 0x1410 */
+	volatile unsigned long DACOverlayUAddr;	/* 0x1414 */
+	volatile unsigned long DACOverlayVAddr;	/* 0x1418 */
+	volatile unsigned long DACOverlaySize;	/* 0x141C */
+	volatile unsigned long DACOverlayVtDec;	/* 0x1420 */
+
+	volatile unsigned long Fill9[9];	/* GAP 0x1424 - 0x1444 */
+
+	volatile unsigned long DACVerticalScal;	/* 0x1448 */
+	volatile unsigned long DACPixelFormat;	/* 0x144C */
+	volatile unsigned long DACHorizontalScal;	/* 0x1450 */
+	volatile unsigned long DACVidWinStart;	/* 0x1454 */
+	volatile unsigned long DACVidWinEnd;	/* 0x1458 */
+	volatile unsigned long DACBlendCtrl;	/* 0x145C */
+	volatile unsigned long DACHorTim1;	/* 0x1460 */
+	volatile unsigned long DACHorTim2;	/* 0x1464 */
+	volatile unsigned long DACHorTim3;	/* 0x1468 */
+	volatile unsigned long DACVerTim1;	/* 0x146C */
+	volatile unsigned long DACVerTim2;	/* 0x1470 */
+	volatile unsigned long DACVerTim3;	/* 0x1474 */
+	volatile unsigned long DACBorderColor;	/* 0x1478 */
+	volatile unsigned long DACSyncCtrl;	/* 0x147C */
+	volatile unsigned long DACStreamCtrl;	/* 0x1480 */
+	volatile unsigned long DACLUTAddress;	/* 0x1484 */
+	volatile unsigned long DACLUTData;	/* 0x1488 */
+	volatile unsigned long DACBurstCtrl;	/* 0x148C */
+	volatile unsigned long DACCrcTrigger;	/* 0x1490 */
+	volatile unsigned long DACCrcDone;	/* 0x1494 */
+	volatile unsigned long DACCrcResult1;	/* 0x1498 */
+	volatile unsigned long DACCrcResult2;	/* 0x149C */
+	volatile unsigned long DACLinecount;	/* 0x14A0 */
+
+	volatile unsigned long Fill10[151];	/*GAP 0x14A4 - 0x16FC */
+
+	volatile unsigned long DigVidPortCtrl;	/* 0x1700 */
+	volatile unsigned long DigVidPortStat;	/* 0x1704 */
+
+	/*
+	   volatile unsigned long Fill11[0x1FFC/4 - 0x1708/4]; //GAP 0x1708 - 0x1FFC
+	   volatile unsigned long Fill17[0x3000/4 - 0x2FFC/4]; //GAP 0x2000 - 0x2FFC ALUT
+	 */
+
+	volatile unsigned long Fill11[1598];
+
+	/* DWFILL; //GAP 0x3000          ALUT 256MB offset */
+	volatile unsigned long Fill_3;
+
+} STG4000REG;
+
+#endif /* _STG4000REG_H */
diff -puN /dev/null drivers/video/kyro/STG4000VTG.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/video/kyro/STG4000VTG.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,170 @@
+/*
+ *  linux/drivers/video/kyro/STG4000VTG.c
+ *
+ *  Copyright (C) 2002 STMicroelectronics
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file COPYING in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/types.h>
+#include <video/kyro.h>
+
+#include "STG4000Reg.h"
+#include "STG4000Interface.h"
+
+void DisableVGA(volatile STG4000REG * pSTGReg)
+{
+	u32 tmp;
+	volatile u32 count, i;
+
+	/* Reset the VGA registers */
+	tmp = STG_READ_REG(SoftwareReset);
+	CLEAR_BIT(8);
+	STG_WRITE_REG(SoftwareReset, tmp);
+
+	/* Just for Delay */
+	for (i = 0; i < 1000; i++) {
+		count++;
+	}
+
+	/* Pull-out the VGA registers from reset */
+	tmp = STG_READ_REG(SoftwareReset);
+	tmp |= SET_BIT(8);
+	STG_WRITE_REG(SoftwareReset, tmp);
+}
+
+void StopVTG(volatile STG4000REG * pSTGReg)
+{
+	u32 tmp = 0;
+
+	/* Stop Ver and Hor Sync Generator */
+	tmp = (STG_READ_REG(DACSyncCtrl)) | SET_BIT(0) | SET_BIT(2);
+	CLEAR_BIT(31);
+	STG_WRITE_REG(DACSyncCtrl, tmp);
+}
+
+void StartVTG(volatile STG4000REG * pSTGReg)
+{
+	u32 tmp = 0;
+
+	/* Start Ver and Hor Sync Generator */
+	tmp = ((STG_READ_REG(DACSyncCtrl)) | SET_BIT(31));
+	CLEAR_BIT(0);
+	CLEAR_BIT(2);
+	STG_WRITE_REG(DACSyncCtrl, tmp);
+}
+
+void SetupVTG(volatile STG4000REG * pSTGReg,
+	      const struct kyrofb_info * pTiming)
+{
+	u32 tmp = 0;
+	u32 margins = 0;
+	u32 ulBorder;
+	u32 xRes = pTiming->XRES;
+	u32 yRes = pTiming->YRES;
+
+	/* Horizontal */
+	u32 HAddrTime, HRightBorder, HLeftBorder;
+	u32 HBackPorcStrt, HFrontPorchStrt, HTotal,
+	    HLeftBorderStrt, HRightBorderStrt, HDisplayStrt;
+
+	/* Vertical */
+	u32 VDisplayStrt, VBottomBorder, VTopBorder;
+	u32 VBackPorchStrt, VTotal, VTopBorderStrt,
+	    VFrontPorchStrt, VBottomBorderStrt, VAddrTime;
+
+	/* Need to calculate the right border */
+	if ((xRes == 640) && (yRes == 480)) {
+		if ((pTiming->VFREQ == 60) || (pTiming->VFREQ == 72)) {
+			margins = 8;
+		}
+	}
+
+	/* Work out the Border */
+	ulBorder =
+	    (pTiming->HTot -
+	     (pTiming->HST + (pTiming->HBP - margins) + xRes +
+	      (pTiming->HFP - margins))) >> 1;
+
+	/* Border the same for Vertical and Horizontal */
+	VBottomBorder = HLeftBorder = VTopBorder = HRightBorder = ulBorder;
+
+    /************ Get Timing values for Horizontal ******************/
+	HAddrTime = xRes;
+	HBackPorcStrt = pTiming->HST;
+	HTotal = pTiming->HTot;
+	HDisplayStrt =
+	    pTiming->HST + (pTiming->HBP - margins) + HLeftBorder;
+	HLeftBorderStrt = HDisplayStrt - HLeftBorder;
+	HFrontPorchStrt =
+	    pTiming->HST + (pTiming->HBP - margins) + HLeftBorder +
+	    HAddrTime + HRightBorder;
+	HRightBorderStrt = HFrontPorchStrt - HRightBorder;
+
+    /************ Get Timing values for Vertical ******************/
+	VAddrTime = yRes;
+	VBackPorchStrt = pTiming->VST;
+	VTotal = pTiming->VTot;
+	VDisplayStrt =
+	    pTiming->VST + (pTiming->VBP - margins) + VTopBorder;
+	VTopBorderStrt = VDisplayStrt - VTopBorder;
+	VFrontPorchStrt =
+	    pTiming->VST + (pTiming->VBP - margins) + VTopBorder +
+	    VAddrTime + VBottomBorder;
+	VBottomBorderStrt = VFrontPorchStrt - VBottomBorder;
+
+	/* Set Hor Timing 1, 2, 3 */
+	tmp = STG_READ_REG(DACHorTim1);
+	CLEAR_BITS_FRM_TO(0, 11);
+	CLEAR_BITS_FRM_TO(16, 27);
+	tmp |= (HTotal) | (HBackPorcStrt << 16);
+	STG_WRITE_REG(DACHorTim1, tmp);
+
+	tmp = STG_READ_REG(DACHorTim2);
+	CLEAR_BITS_FRM_TO(0, 11);
+	CLEAR_BITS_FRM_TO(16, 27);
+	tmp |= (HDisplayStrt << 16) | HLeftBorderStrt;
+	STG_WRITE_REG(DACHorTim2, tmp);
+
+	tmp = STG_READ_REG(DACHorTim3);
+	CLEAR_BITS_FRM_TO(0, 11);
+	CLEAR_BITS_FRM_TO(16, 27);
+	tmp |= (HFrontPorchStrt << 16) | HRightBorderStrt;
+	STG_WRITE_REG(DACHorTim3, tmp);
+
+	/* Set Ver Timing 1, 2, 3 */
+	tmp = STG_READ_REG(DACVerTim1);
+	CLEAR_BITS_FRM_TO(0, 11);
+	CLEAR_BITS_FRM_TO(16, 27);
+	tmp |= (VBackPorchStrt << 16) | (VTotal);
+	STG_WRITE_REG(DACVerTim1, tmp);
+
+	tmp = STG_READ_REG(DACVerTim2);
+	CLEAR_BITS_FRM_TO(0, 11);
+	CLEAR_BITS_FRM_TO(16, 27);
+	tmp |= (VDisplayStrt << 16) | VTopBorderStrt;
+	STG_WRITE_REG(DACVerTim2, tmp);
+
+	tmp = STG_READ_REG(DACVerTim3);
+	CLEAR_BITS_FRM_TO(0, 11);
+	CLEAR_BITS_FRM_TO(16, 27);
+	tmp |= (VFrontPorchStrt << 16) | VBottomBorderStrt;
+	STG_WRITE_REG(DACVerTim3, tmp);
+
+	/* Set Verical and Horizontal Polarity */
+	tmp = STG_READ_REG(DACSyncCtrl) | SET_BIT(3) | SET_BIT(1);
+
+	if ((pTiming->HSP > 0) && (pTiming->VSP < 0)) {	/* +hsync -vsync */
+		tmp &= ~0x8;
+	} else if ((pTiming->HSP < 0) && (pTiming->VSP > 0)) {	/* -hsync +vsync */
+		tmp &= ~0x2;
+	} else if ((pTiming->HSP < 0) && (pTiming->VSP < 0)) {	/* -hsync -vsync */
+		tmp &= ~0xA;
+	} else if ((pTiming->HSP > 0) && (pTiming->VSP > 0)) {	/* +hsync -vsync */
+		tmp &= ~0x0;
+	}
+
+	STG_WRITE_REG(DACSyncCtrl, tmp);
+}
diff -puN drivers/video/macfb.c~linus drivers/video/macfb.c
--- 25/drivers/video/macfb.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/video/macfb.c	2004-01-19 22:17:23.000000000 -0800
@@ -592,7 +592,7 @@ static struct fb_ops macfb_ops = {
 	.fb_cursor	= soft_cursor,
 };
 
-void __init macfb_setup(char *options, int *ints)
+void __init macfb_setup(char *options)
 {
 	char *this_opt;
 	
diff -puN drivers/video/Makefile~linus drivers/video/Makefile
--- 25/drivers/video/Makefile~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/video/Makefile	2004-01-19 22:17:23.000000000 -0800
@@ -70,6 +70,7 @@ obj-$(CONFIG_FB_VIRTUAL)          += vfb
 obj-$(CONFIG_FB_HIT)              += hitfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
 obj-$(CONFIG_FB_E1355)            += epson1355fb.o
 obj-$(CONFIG_FB_PVR2)             += pvr2fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
+obj-$(CONFIG_FB_KYRO)             += kyro/ cfbfillrect.o cfbcopyarea.o cfbimgblt.o
 obj-$(CONFIG_FB_VOODOO1)          += sstfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
 
 obj-$(CONFIG_FB_FFB)               += ffb.o sbuslib.o cfbimgblt.o cfbcopyarea.o
diff -puN drivers/video/pvr2fb.c~linus drivers/video/pvr2fb.c
--- 25/drivers/video/pvr2fb.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/video/pvr2fb.c	2004-01-19 22:17:23.000000000 -0800
@@ -4,7 +4,7 @@
  * Dreamcast.
  *
  * Copyright (c) 2001 M. R. Brown <mrbrown@0xd6.org>
- * Copyright (c) 2001, 2002, 2003 Paul Mundt <lethal@linux-sh.org>
+ * Copyright (c) 2001, 2002, 2003, 2004 Paul Mundt <lethal@linux-sh.org>
  *
  * This file is part of the LinuxDC project (linuxdc.sourceforge.net).
  *
@@ -46,6 +46,8 @@
  *  the benefit of being fully researched, so some modes may be broken.
  */
 
+#undef DEBUG
+
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -58,26 +60,30 @@
 #include <linux/interrupt.h>
 #include <linux/fb.h>
 #include <linux/init.h>
+#include <linux/pci.h>
 
 #ifdef CONFIG_SH_DREAMCAST
-#include <asm/io.h>
 #include <asm/machvec.h>
-#include <asm/dc_sysasic.h>
+#include <asm/mach/sysasic.h>
 #endif
 
-#ifdef CONFIG_MTRR
-#include <asm/mtrr.h>
+#ifdef CONFIG_SH_DMA
+#include <linux/pagemap.h>
+#include <asm/mach/dma.h>
+#include <asm/dma.h>
 #endif
 
-#ifdef CONFIG_FB_PVR2_DEBUG
-#  define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
-#else
-#  define DPRINTK(fmt, args...)
+#ifdef CONFIG_SH_STORE_QUEUES
+#include <asm/uaccess.h>
+#include <asm/cpu/sq.h>
 #endif
 
-/* 2D video registers */
-#define DISP_BASE 0xa05f8000
+#ifndef PCI_DEVICE_ID_NEC_NEON250
+#  define PCI_DEVICE_ID_NEC_NEON250	0x0067
+#endif
 
+/* 2D video registers */
+#define DISP_BASE	par->mmio_base
 #define DISP_BRDRCOLR (DISP_BASE + 0x40)
 #define DISP_DIWMODE (DISP_BASE + 0x44)
 #define DISP_DIWADDRL (DISP_BASE + 0x50)
@@ -101,11 +107,16 @@
 #define NTSC_HTOTAL 857
 #define NTSC_VTOTAL 262
 
+/* Supported cable types */
 enum { CT_VGA, CT_NONE, CT_RGB, CT_COMPOSITE };
 
+/* Supported video output types */
 enum { VO_PAL, VO_NTSC, VO_VGA };
 
-struct pvr2_params { u_short val; char *name; };
+/* Supported palette types */
+enum { PAL_ARGB1555, PAL_RGB565, PAL_ARGB4444, PAL_ARGB8888 };
+
+struct pvr2_params { unsigned int val; char *name; };
 static struct pvr2_params cables[] __initdata = {
 	{ CT_VGA, "VGA" }, { CT_RGB, "RGB" }, { CT_COMPOSITE, "COMPOSITE" },
 };
@@ -119,23 +130,24 @@ static struct pvr2_params outputs[] __in
  */
 
 static struct pvr2fb_par {
-	u_short hsync_total;	/* Clocks/line */
-	u_short vsync_total;	/* Lines/field */
-	u_short borderstart_h;
-	u_short borderstop_h;
-	u_short borderstart_v;
-	u_short borderstop_v;
-	u_short diwstart_h;	/* Horizontal offset of the display field */
-	u_short diwstart_v;	/* Vertical offset of the display field, for
+	unsigned int hsync_total;	/* Clocks/line */
+	unsigned int vsync_total;	/* Lines/field */
+	unsigned int borderstart_h;
+	unsigned int borderstop_h;
+	unsigned int borderstart_v;
+	unsigned int borderstop_v;
+	unsigned int diwstart_h;	/* Horizontal offset of the display field */
+	unsigned int diwstart_v;	/* Vertical offset of the display field, for
 				   interlaced modes, this is the long field */
-	u_long disp_start;	/* Address of image within VRAM */
-	u_char is_interlaced;	/* Is the display interlaced? */
-	u_char is_doublescan;	/* Are scanlines output twice? (doublescan) */
-	u_char is_lowres;	/* Is horizontal pixel-doubling enabled? */
+	unsigned long disp_start;	/* Address of image within VRAM */
+	unsigned char is_interlaced;	/* Is the display interlaced? */
+	unsigned char is_doublescan;	/* Are scanlines output twice? (doublescan) */
+	unsigned char is_lowres;	/* Is horizontal pixel-doubling enabled? */
+
+	unsigned long mmio_base;	/* MMIO base */
 } *currentpar;
 
 static struct fb_info *fb_info;
-static int pvr2fb_inverse = 0;
 
 static struct fb_fix_screeninfo pvr2_fix __initdata = {
 	.id =		"NEC PowerVR2",
@@ -161,10 +173,8 @@ static struct fb_var_screeninfo pvr2_var
 	.vmode =	FB_VMODE_NONINTERLACED,
 };
 
-#define VIDEOMEMSIZE (8*1024*1024)
-static u_long videomemory = 0xa5000000, videomemorysize = VIDEOMEMSIZE;
-static int cable_type = -1;
-static int video_output = -1;
+static int cable_type = CT_VGA;
+static int video_output = VO_VGA;
 
 static int nopan = 0;
 static int nowrap = 1;
@@ -172,20 +182,29 @@ static int nowrap = 1;
 /*
  * We do all updating, blanking, etc. during the vertical retrace period
  */
-static u_short do_vmode_full = 0;	/* Change the video mode */
-static u_short do_vmode_pan = 0;	/* Update the video mode */
+static unsigned int do_vmode_full = 0;	/* Change the video mode */
+static unsigned int do_vmode_pan = 0;	/* Update the video mode */
 static short do_blank = 0;		/* (Un)Blank the screen */
 
-static u_short is_blanked = 0;		/* Is the screen blanked? */
+static unsigned int is_blanked = 0;		/* Is the screen blanked? */
+
+#ifdef CONFIG_SH_STORE_QUEUES
+static struct sq_mapping *pvr2fb_map;
+#endif
+
+#ifdef CONFIG_SH_DMA
+static unsigned int shdma = PVR2_CASCADE_CHAN;
+static unsigned int pvr2dma = ONCHIP_NR_DMA_CHANNELS;
+#endif
 
 /* Interface used by the world */
 
 int pvr2fb_setup(char*);
 
-static int pvr2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
-                            u_int transp, struct fb_info *info);
+static int pvr2fb_setcolreg(unsigned int regno, unsigned int red, unsigned int green, unsigned int blue,
+                            unsigned int transp, struct fb_info *info);
 static int pvr2fb_blank(int blank, struct fb_info *info);
-static u_long get_line_length(int xres_virtual, int bpp);
+static unsigned long get_line_length(int xres_virtual, int bpp);
 static void set_color_bitfields(struct fb_var_screeninfo *var);
 static int pvr2fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info);
 static int pvr2fb_set_par(struct fb_info *info);
@@ -196,6 +215,8 @@ static irqreturn_t pvr2fb_interrupt(int 
 static int pvr2_init_cable(void);
 static int pvr2_get_param(const struct pvr2_params *p, const char *s,
                             int val, int size);
+static ssize_t pvr2fb_write(struct file *file, const char *buf,
+			    size_t count, loff_t *ppos);
 
 static struct fb_ops pvr2fb_ops = {
 	.owner 		= THIS_MODULE,
@@ -203,6 +224,9 @@ static struct fb_ops pvr2fb_ops = {
 	.fb_blank 	= pvr2fb_blank,
 	.fb_check_var 	= pvr2fb_check_var,
 	.fb_set_par 	= pvr2fb_set_par,
+#ifdef CONFIG_SH_DMA
+	.fb_write	= pvr2fb_write,
+#endif
 	.fb_fillrect 	= cfb_fillrect,
 	.fb_copyarea	= cfb_copyarea,
 	.fb_imageblit	= cfb_imageblit,
@@ -241,21 +265,36 @@ static struct fb_videomode pvr2_modedb[]
 static int defmode = DEFMODE_NTSC;
 static char *mode_option __initdata = NULL;
 
+static inline void pvr2fb_set_pal_type(unsigned int type)
+{
+	struct pvr2fb_par *par = (struct pvr2fb_par *)fb_info->par;
+
+	fb_writel(type, par->mmio_base + 0x108);
+}
+
+static inline void pvr2fb_set_pal_entry(struct pvr2fb_par *par,
+					unsigned int regno,
+					unsigned int val)
+{
+	fb_writel(val, par->mmio_base + 0x1000 + (4 * regno));
+}
+
 static int pvr2fb_blank(int blank, struct fb_info *info)
 {
 	do_blank = blank ? blank : -1;
 	return 0;
 }
 
-static inline u_long get_line_length(int xres_virtual, int bpp)
+static inline unsigned long get_line_length(int xres_virtual, int bpp)
 {
-	return (u_long)((((xres_virtual*bpp)+31)&~31) >> 3);
+	return (unsigned long)((((xres_virtual*bpp)+31)&~31) >> 3);
 }
 
 static void set_color_bitfields(struct fb_var_screeninfo *var)
 {
 	switch (var->bits_per_pixel) {
 	    case 16:        /* RGB 565 */
+	    	pvr2fb_set_pal_type(PAL_RGB565);
 		var->red.offset = 11;    var->red.length = 5;
 		var->green.offset = 5;   var->green.length = 6;
 		var->blue.offset = 0;    var->blue.length = 5;
@@ -268,6 +307,7 @@ static void set_color_bitfields(struct f
 		var->transp.offset = 0;  var->transp.length = 0;
 		break;
 	    case 32:        /* ARGB 8888 */
+	    	pvr2fb_set_pal_type(PAL_ARGB8888);
 		var->red.offset = 16;    var->red.length = 8;
 		var->green.offset = 8;   var->green.length = 8;
 		var->blue.offset = 0;    var->blue.length = 8;
@@ -276,31 +316,42 @@ static void set_color_bitfields(struct f
 	}
 }
 
-static int pvr2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
-                            u_int transp, struct fb_info *info)
+static int pvr2fb_setcolreg(unsigned int regno, unsigned int red,
+			    unsigned int green, unsigned int blue,
+                            unsigned int transp, struct fb_info *info)
 {
-	if (regno > 255)
+	struct pvr2fb_par *par = (struct pvr2fb_par *)info->par;
+	unsigned int tmp;
+
+	if (regno > info->cmap.len)
 		return 1;
 
-	if (regno < 16) {
-		switch (info->var.bits_per_pixel) {
-		    case 16: /* RGB 565 */
-			((u16*)(info->pseudo_palette))[regno] = (red & 0xf800) |
-						((green & 0xfc00) >> 5) |
-						  ((blue & 0xf800) >> 11);
-			break;
-		    case 24: /* RGB 888 */
-			red >>= 8; green >>= 8; blue >>= 8;
-			((u32*)(info->pseudo_palette))[regno] = (red << 16) | (green << 8) | blue;
-			break;
-		    case 32: /* ARGB 8888 */
-			red >>= 8; green >>= 8; blue >>= 8;
-			((u32*)(info->pseudo_palette))[regno] = (transp << 24) |(red << 16) | (green << 8) | blue;
-			break;
-		    default:
-			DPRINTK("Invalid bit depth %d?!?\n", info->var.bits_per_pixel);
-			return 1;
-		}
+	/*
+	 * We only support the hardware palette for 16 and 32bpp. It's also
+	 * expected that the palette format has been set by the time we get
+	 * here, so we don't waste time setting it again.
+	 */
+	switch (info->var.bits_per_pixel) {
+	    case 16: /* RGB 565 */
+		tmp =  (red   & 0xf800)       |
+		      ((green & 0xfc00) >> 5) |
+		      ((blue  & 0xf800) >> 11);
+
+		pvr2fb_set_pal_entry(par, regno, tmp);
+		break;
+	    case 24: /* RGB 888 */
+		red >>= 8; green >>= 8; blue >>= 8;
+		((u32*)(info->pseudo_palette))[regno] = (red << 16) | (green << 8) | blue;
+		break;
+	    case 32: /* ARGB 8888 */
+		red >>= 8; green >>= 8; blue >>= 8;
+		tmp = (transp << 24) | (red << 16) | (green << 8) | blue;
+
+		pvr2fb_set_pal_entry(par, regno, tmp);
+		break;
+	    default:
+		pr_debug("Invalid bit depth %d?!?\n", info->var.bits_per_pixel);
+		return 1;
 	}
 
 	return 0;
@@ -310,8 +361,8 @@ static int pvr2fb_set_par(struct fb_info
 {
 	struct pvr2fb_par *par = (struct pvr2fb_par *)info->par;
 	struct fb_var_screeninfo *var = &info->var;
-	u_long line_length;
-	u_short vtotal;
+	unsigned long line_length;
+	unsigned int vtotal;
 
 	/*
 	 * XXX: It's possible that a user could use a VGA box, change the cable
@@ -378,18 +429,18 @@ static int pvr2fb_set_par(struct fb_info
 		par->is_lowres = 1;
 
 	line_length = get_line_length(var->xres_virtual, var->bits_per_pixel);
-	par->disp_start = videomemory + (line_length * var->yoffset) * line_length;
+	par->disp_start = info->fix.smem_start + (line_length * var->yoffset) * line_length;
 	info->fix.line_length = line_length;
 	return 0;
 }
 
 static int pvr2fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
 {
-	u_short vtotal, hsync_total;
-	u_long line_length;
+	unsigned int vtotal, hsync_total;
+	unsigned long line_length;
 
 	if (var->pixclock != TV_CLK || var->pixclock != VGA_CLK) {
-		DPRINTK("Invalid pixclock value %d\n", var->pixclock);
+		pr_debug("Invalid pixclock value %d\n", var->pixclock);
 		return -EINVAL;
 	}
 
@@ -447,21 +498,22 @@ static int pvr2fb_check_var(struct fb_va
 			/* PAL video output */
 			/* XXX: Should be using a range here ... ? */
 			if (hsync_total != PAL_HTOTAL) {
-				DPRINTK("invalid hsync total for PAL\n");
+				pr_debug("invalid hsync total for PAL\n");
 				return -EINVAL;
 			}
 		} else {
 			/* NTSC video output */
 			if (hsync_total != NTSC_HTOTAL) {
-				DPRINTK("invalid hsync total for NTSC\n");
+				pr_debug("invalid hsync total for NTSC\n");
 				return -EINVAL;
 			}
 		}
 	}
 	/* Check memory sizes */
 	line_length = get_line_length(var->xres_virtual, var->bits_per_pixel);
-	if (line_length * var->yres_virtual > videomemorysize)
+	if (line_length * var->yres_virtual > info->fix.smem_len)
 		return -ENOMEM;
+
 	return 0;
 }
 
@@ -471,8 +523,8 @@ static void pvr2_update_display(struct f
 	struct fb_var_screeninfo *var = &info->var;
 
 	/* Update the start address of the display image */
-	ctrl_outl(par->disp_start, DISP_DIWADDRL);
-	ctrl_outl(par->disp_start +
+	fb_writel(par->disp_start, DISP_DIWADDRL);
+	fb_writel(par->disp_start +
 		  get_line_length(var->xoffset+var->xres, var->bits_per_pixel),
 	          DISP_DIWADDRS);
 }
@@ -487,11 +539,11 @@ static void pvr2_init_display(struct fb_
 {
 	struct pvr2fb_par *par = (struct pvr2fb_par *) info->par;
 	struct fb_var_screeninfo *var = &info->var;
-	u_short diw_height, diw_width, diw_modulo = 1;
-	u_short bytesperpixel = var->bits_per_pixel >> 3;
+	unsigned int diw_height, diw_width, diw_modulo = 1;
+	unsigned int bytesperpixel = var->bits_per_pixel >> 3;
 
 	/* hsync and vsync totals */
-	ctrl_outl((par->vsync_total << 16) | par->hsync_total, DISP_SYNCSIZE);
+	fb_writel((par->vsync_total << 16) | par->hsync_total, DISP_SYNCSIZE);
 
 	/* column height, modulo, row width */
 	/* since we're "panning" within vram, we need to offset things based
@@ -500,37 +552,37 @@ static void pvr2_init_display(struct fb_
 		diw_modulo += info->fix.line_length / 4;
 	diw_height = (par->is_interlaced ? var->yres / 2 : var->yres);
 	diw_width = get_line_length(var->xres, var->bits_per_pixel) / 4;
-	ctrl_outl((diw_modulo << 20) | (--diw_height << 10) | --diw_width,
+	fb_writel((diw_modulo << 20) | (--diw_height << 10) | --diw_width,
 	          DISP_DIWSIZE);
 
 	/* display address, long and short fields */
-	ctrl_outl(par->disp_start, DISP_DIWADDRL);
-	ctrl_outl(par->disp_start +
+	fb_writel(par->disp_start, DISP_DIWADDRL);
+	fb_writel(par->disp_start +
 	          get_line_length(var->xoffset+var->xres, var->bits_per_pixel),
 	          DISP_DIWADDRS);
 
 	/* border horizontal, border vertical, border color */
-	ctrl_outl((par->borderstart_h << 16) | par->borderstop_h, DISP_BRDRHORZ);
-	ctrl_outl((par->borderstart_v << 16) | par->borderstop_v, DISP_BRDRVERT);
-	ctrl_outl(0, DISP_BRDRCOLR);
+	fb_writel((par->borderstart_h << 16) | par->borderstop_h, DISP_BRDRHORZ);
+	fb_writel((par->borderstart_v << 16) | par->borderstop_v, DISP_BRDRVERT);
+	fb_writel(0, DISP_BRDRCOLR);
 
 	/* display window start position */
-	ctrl_outl(par->diwstart_h, DISP_DIWHSTRT);
-	ctrl_outl((par->diwstart_v << 16) | par->diwstart_v, DISP_DIWVSTRT);
+	fb_writel(par->diwstart_h, DISP_DIWHSTRT);
+	fb_writel((par->diwstart_v << 16) | par->diwstart_v, DISP_DIWVSTRT);
 	
 	/* misc. settings */
-	ctrl_outl((0x16 << 16) | par->is_lowres, DISP_DIWCONF);
+	fb_writel((0x16 << 16) | par->is_lowres, DISP_DIWCONF);
 
 	/* clock doubler (for VGA), scan doubler, display enable */
-	ctrl_outl(((video_output == VO_VGA) << 23) | 
+	fb_writel(((video_output == VO_VGA) << 23) | 
 	          (par->is_doublescan << 1) | 1, DISP_DIWMODE);
 
 	/* bits per pixel */
-	ctrl_outl(ctrl_inl(DISP_DIWMODE) | (--bytesperpixel << 2), DISP_DIWMODE);
+	fb_writel(fb_readl(DISP_DIWMODE) | (--bytesperpixel << 2), DISP_DIWMODE);
 
 	/* video enable, color sync, interlace, 
 	 * hsync and vsync polarity (currently unused) */
-	ctrl_outl(0x100 | ((par->is_interlaced /*|4*/) << 4), DISP_SYNCCONF);
+	fb_writel(0x100 | ((par->is_interlaced /*|4*/) << 4), DISP_SYNCCONF);
 }
 
 /* Simulate blanking by making the border cover the entire screen */
@@ -539,13 +591,14 @@ static void pvr2_init_display(struct fb_
 
 static void pvr2_do_blank(void)
 {
-	u_long diwconf;
+	struct pvr2fb_par *par = currentpar;
+	unsigned long diwconf;
 
-	diwconf = ctrl_inl(DISP_DIWCONF);
+	diwconf = fb_readl(DISP_DIWCONF);
 	if (do_blank > 0)
-		ctrl_outl(diwconf | BLANK_BIT, DISP_DIWCONF);
+		fb_writel(diwconf | BLANK_BIT, DISP_DIWCONF);
 	else
-		ctrl_outl(diwconf & ~BLANK_BIT, DISP_DIWCONF);
+		fb_writel(diwconf & ~BLANK_BIT, DISP_DIWCONF);
 
 	is_blanked = do_blank > 0 ? do_blank : 0;
 }
@@ -581,76 +634,132 @@ static irqreturn_t pvr2fb_interrupt(int 
 static int pvr2_init_cable(void)
 {
 	if (cable_type < 0) {
-		ctrl_outl((ctrl_inl(PCTRA) & 0xfff0ffff) | 0x000a0000, 
+		fb_writel((fb_readl(PCTRA) & 0xfff0ffff) | 0x000a0000, 
 	                  PCTRA);
-		cable_type = (ctrl_inw(PDTRA) >> 8) & 3;
+		cable_type = (fb_readw(PDTRA) >> 8) & 3;
 	}
 
 	/* Now select the output format (either composite or other) */
 	/* XXX: Save the previous val first, as this reg is also AICA
 	  related */
 	if (cable_type == CT_COMPOSITE)
-		ctrl_outl(3 << 8, VOUTC);
+		fb_writel(3 << 8, VOUTC);
 	else
-		ctrl_outl(0, VOUTC);
+		fb_writel(0, VOUTC);
 
 	return cable_type;
 }
 
-int __init pvr2fb_init(void)
+#ifdef CONFIG_SH_DMA
+static ssize_t pvr2fb_write(struct file *file, const char *buf,
+			    size_t count, loff_t *ppos)
 {
-	u_long modememused;
-	int err = -EINVAL;
+	unsigned long dst, start, end, len;
+	unsigned int nr_pages;
+	struct page **pages;
+	int ret, i;
 
-	if (!mach_is_dreamcast())
-		return -ENXIO;
+	nr_pages = (count + PAGE_SIZE - 1) >> PAGE_SHIFT;
 
-	fb_info = kmalloc(sizeof(struct fb_info) + sizeof(struct pvr2fb_par) +
-			  sizeof(u32) * 16, GFP_KERNEL);
-	
-	if (!fb_info) {
-		printk(KERN_ERR "Failed to allocate memory for fb_info\n");
+	pages = kmalloc(nr_pages * sizeof(struct page *), GFP_KERNEL);
+	if (!pages)
 		return -ENOMEM;
+	
+	down_read(&current->mm->mmap_sem);
+	ret = get_user_pages(current, current->mm, (unsigned long)buf,
+			     nr_pages, WRITE, 0, pages, NULL);
+	up_read(&current->mm->mmap_sem);
+
+	if (ret < nr_pages) {
+		nr_pages = ret;
+		ret = -EINVAL;
+		goto out_unmap;
 	}
 
-	memset(fb_info, 0, sizeof(fb_info) + sizeof(struct pvr2fb_par) + sizeof(u32) * 16);
+	dma_configure_channel(shdma, 0x12c1);
+	
+	dst   = (unsigned long)fb_info->screen_base + *ppos;
+	start = (unsigned long)page_address(pages[0]);
+	end   = (unsigned long)page_address(pages[nr_pages]);
+	len   = nr_pages << PAGE_SHIFT;
+
+	/* Half-assed contig check */
+	if (start + len == end) {
+		/* As we do this in one shot, it's either all or nothing.. */
+		if ((*ppos + len) > fb_info->fix.smem_len) {
+			ret = -ENOSPC;
+			goto out_unmap;
+		}
 
-	currentpar = (struct pvr2fb_par *)(fb_info + 1);
+		dma_write(shdma, start, 0, len);
+		dma_write(pvr2dma, 0, dst, len);
+		dma_wait_for_completion(pvr2dma);
 
-	/* Make a guess at the monitor based on the attached cable */
-	if (pvr2_init_cable() == CT_VGA) {
-		fb_info->monspecs.hfmin = 30000;
-		fb_info->monspecs.hfmax = 70000;
-		fb_info->monspecs.vfmin = 60;
-		fb_info->monspecs.vfmax = 60;
-	} else {
-		/* Not VGA, using a TV (taken from acornfb) */
-		fb_info->monspecs.hfmin = 15469;
-		fb_info->monspecs.hfmax = 15781;
-		fb_info->monspecs.vfmin = 49;
-		fb_info->monspecs.vfmax = 51;
+		goto out;
 	}
 
-	/*
-	 * XXX: This needs to pull default video output via BIOS or other means
-	 */
-	if (video_output < 0) {
-		if (cable_type == CT_VGA) {
-			video_output = VO_VGA;
-		} else {
-			video_output = VO_NTSC;
+	/* Not contiguous, writeout per-page instead.. */
+	for (i = 0; i < nr_pages; i++, dst += PAGE_SIZE) {
+		if ((*ppos + (i << PAGE_SHIFT)) > fb_info->fix.smem_len) {
+			ret = -ENOSPC;
+			goto out_unmap;
 		}
+
+		dma_write_page(shdma, (unsigned long)page_address(pages[i]), 0);
+		dma_write_page(pvr2dma, 0, dst);
+		dma_wait_for_completion(pvr2dma);
 	}
-	
-	pvr2_fix.smem_start = videomemory;
-	pvr2_fix.smem_len = videomemorysize;
+
+out:
+	*ppos += count;
+	ret = count;
+
+out_unmap:
+	for (i = 0; i < nr_pages; i++)
+		page_cache_release(pages[i]);
+
+	kfree(pages);
+
+	return ret;
+} 
+#endif /* CONFIG_SH_DMA */
+
+/**
+ * pvr2fb_common_init
+ *
+ * Common init code for the PVR2 chips.
+ *
+ * This mostly takes care of the common aspects of the fb setup and
+ * registration. It's expected that the board-specific init code has
+ * already setup pvr2_fix with something meaningful at this point.
+ *
+ * Device info reporting is also done here, as well as picking a sane
+ * default from the modedb. For board-specific modelines, simply define
+ * a per-board modedb.
+ *
+ * Also worth noting is that the cable and video output types are likely
+ * always going to be VGA for the PCI-based PVR2 boards, but we leave this
+ * in for flexibility anyways. Who knows, maybe someone has tv-out on a
+ * PCI-based version of these things ;-)
+ */
+static int __init pvr2fb_common_init(void)
+{
+	struct pvr2fb_par *par = currentpar;
+	unsigned long modememused, rev;
+	int size;
 
 	fb_info->screen_base = ioremap_nocache(pvr2_fix.smem_start,
 					       pvr2_fix.smem_len);
 	
 	if (!fb_info->screen_base) {
-		printk("Failed to remap MMIO space\n");
-		err = -ENXIO;
+		printk(KERN_ERR "pvr2fb: Failed to remap smem space\n");
+		goto out_err;
+	}
+
+	par->mmio_base = (unsigned long)ioremap_nocache(pvr2_fix.mmio_start,
+					 		pvr2_fix.mmio_len);
+	if (!par->mmio_base) {
+		printk(KERN_ERR "pvr2fb: Failed to remap mmio space\n");
 		goto out_err;
 	}
 
@@ -675,22 +784,21 @@ int __init pvr2fb_init(void)
 	                  NUM_TOTAL_MODES, &pvr2_modedb[defmode], 16))
 		fb_info->var = pvr2_var;
 
-	if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, 0,
-	                "pvr2 VBL handler", fb_info)) {
-		err = -EBUSY;
-		goto out_err;
-	}
+	size = (fb_info->var.bits_per_pixel == 8) ? 256 : 16;
+	fb_alloc_cmap(&fb_info->cmap, size, 0);
 
 	if (register_framebuffer(fb_info) < 0)
-		goto reg_failed;
+		goto out_err;
 
 	modememused = get_line_length(fb_info->var.xres_virtual,
 				      fb_info->var.bits_per_pixel);
 	modememused *= fb_info->var.yres_virtual;
 
-	printk("fb%d: %s frame buffer device, using %ldk/%ldk of video memory\n",
-	       fb_info->node, fb_info->fix.id, modememused>>10,
-	       videomemorysize>>10);
+	rev = fb_readl(par->mmio_base + 0x04);
+
+	printk("fb%d: %s (rev %ld.%ld) frame buffer device, using %ldk/%ldk of video memory\n",
+	       fb_info->node, fb_info->fix.id, (rev >> 4) & 0x0f, rev & 0x0f,
+	       modememused >> 10, (unsigned long)(fb_info->fix.smem_len >> 10));
 	printk("fb%d: Mode %dx%d-%d pitch = %ld cable: %s video output: %s\n", 
 	       fb_info->node, fb_info->var.xres, fb_info->var.yres,
 	       fb_info->var.bits_per_pixel, 
@@ -698,23 +806,152 @@ int __init pvr2fb_init(void)
 	       (char *)pvr2_get_param(cables, NULL, cable_type, 3),
 	       (char *)pvr2_get_param(outputs, NULL, video_output, 3));
 
+#ifdef CONFIG_SH_STORE_QUEUES
+	printk(KERN_NOTICE "fb%d: registering with SQ API\n", fb_info->node);
+
+	pvr2fb_map = sq_remap(fb_info->fix.smem_start, fb_info->fix.smem_len,
+			      fb_info->fix.id);
+
+	printk(KERN_NOTICE "fb%d: Mapped video memory to SQ addr 0x%lx\n",
+	       fb_info->node, pvr2fb_map->sq_addr);
+#endif
+
 	return 0;
 
-reg_failed:
-	free_irq(HW_EVENT_VSYNC, 0);
 out_err:
-	kfree(fb_info);
+	if (fb_info->screen_base)
+		iounmap(fb_info->screen_base);
+	if (par->mmio_base)
+		iounmap((void *)par->mmio_base);
 
-	return err;
+	return -ENXIO;
 }
 
-static void __exit pvr2fb_exit(void)
+#ifdef CONFIG_SH_DREAMCAST
+static int __init pvr2fb_dc_init(void)
+{
+	if (!mach_is_dreamcast())
+		return -ENXIO;
+
+	/* Make a guess at the monitor based on the attached cable */
+	if (pvr2_init_cable() == CT_VGA) {
+		fb_info->monspecs.hfmin = 30000;
+		fb_info->monspecs.hfmax = 70000;
+		fb_info->monspecs.vfmin = 60;
+		fb_info->monspecs.vfmax = 60;
+	} else {
+		/* Not VGA, using a TV (taken from acornfb) */
+		fb_info->monspecs.hfmin = 15469;
+		fb_info->monspecs.hfmax = 15781;
+		fb_info->monspecs.vfmin = 49;
+		fb_info->monspecs.vfmax = 51;
+	}
+
+	/*
+	 * XXX: This needs to pull default video output via BIOS or other means
+	 */
+	if (video_output < 0) {
+		if (cable_type == CT_VGA) {
+			video_output = VO_VGA;
+		} else {
+			video_output = VO_NTSC;
+		}
+	}
+	
+	/* 
+	 * Nothing exciting about the DC PVR2 .. only a measly 8MiB.
+	 */
+	pvr2_fix.smem_start	= 0xa5000000;	/* RAM starts here */
+	pvr2_fix.smem_len	= 8 << 20;
+
+	pvr2_fix.mmio_start	= 0xa05f8000;	/* registers start here */
+	pvr2_fix.mmio_len	= 0x2000;
+
+	if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, 0,
+	                "pvr2 VBL handler", fb_info)) {
+		return -EBUSY;
+	}
+
+#ifdef CONFIG_SH_DMA
+	if (request_dma(pvr2dma, "pvr2") != 0) {
+		free_irq(HW_EVENT_VSYNC, 0);
+		return -EBUSY;
+	}
+#endif
+
+	return pvr2fb_common_init();
+}
+
+static void pvr2fb_dc_exit(void)
 {
-	unregister_framebuffer(fb_info);
 	free_irq(HW_EVENT_VSYNC, 0);
-	kfree(fb_info);
+#ifdef CONFIG_SH_DMA
+	free_dma(pvr2dma);
+#endif
+}
+#endif /* CONFIG_SH_DREAMCAST */
+
+#ifdef CONFIG_PCI
+static int __devinit pvr2fb_pci_probe(struct pci_dev *pdev,
+				      const struct pci_device_id *ent)
+{
+	int ret;
+
+	ret = pci_enable_device(pdev);
+	if (ret) {
+		printk(KERN_ERR "pvr2fb: PCI enable failed\n");
+		return ret;
+	}
+
+	ret = pci_request_regions(pdev, "pvr2fb");
+	if (ret) {
+		printk(KERN_ERR "pvr2fb: PCI request regions failed\n");
+		return ret;
+	}
+
+	/*
+	 * Slightly more exciting than the DC PVR2 .. 16MiB!
+	 */
+	pvr2_fix.smem_start	= pci_resource_start(pdev, 0);
+	pvr2_fix.smem_len	= pci_resource_len(pdev, 0);
+
+	pvr2_fix.mmio_start	= pci_resource_start(pdev, 1);
+	pvr2_fix.mmio_len	= pci_resource_len(pdev, 1);
+
+	return pvr2fb_common_init();
+}
+
+static void __devexit pvr2fb_pci_remove(struct pci_dev *pdev)
+{
+	pci_release_regions(pdev);
+}
+
+static struct pci_device_id pvr2fb_pci_tbl[] __devinitdata = {
+	{ PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_NEON250,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ 0, },
+};
+
+MODULE_DEVICE_TABLE(pci, pvr2fb_pci_tbl);
+
+static struct pci_driver pvr2fb_pci_driver = {
+	.name		= "pvr2fb",
+	.id_table	= pvr2fb_pci_tbl,
+	.probe		= pvr2fb_pci_probe,
+	.remove		= __devexit_p(pvr2fb_pci_remove),
+};
+
+static int __init pvr2fb_pci_init(void)
+{
+	return pci_module_init(&pvr2fb_pci_driver);
 }
 
+static void pvr2fb_pci_exit(void)
+{
+	pci_unregister_driver(&pvr2fb_pci_driver);
+}
+#endif /* CONFIG_PCI */
+
 static int __init pvr2_get_param(const struct pvr2_params *p, const char *s,
                                    int val, int size)
 {
@@ -735,7 +972,6 @@ static int __init pvr2_get_param(const s
 /*
  * Parse command arguments.  Supported arguments are:
  *    inverse                             Use inverse color maps
- *    nomtrr                              Disable MTRR usage
  *    cable:composite|rgb|vga             Override the video cable type
  *    output:NTSC|PAL|VGA                 Override the video output format
  *
@@ -757,7 +993,6 @@ int __init pvr2fb_setup(char *options)
 		if (!*this_opt)
 			continue;
 		if (!strcmp(this_opt, "inverse")) {
-			pvr2fb_inverse = 1;
 			fb_invert_cmaps();
 		} else if (!strncmp(this_opt, "cable:", 6)) {
 			strcpy(cable_arg, this_opt + 6);
@@ -781,9 +1016,82 @@ int __init pvr2fb_setup(char *options)
 }
 #endif
 
+static struct pvr2_board {
+	int (*init)(void);
+	void (*exit)(void);
+	char name[16];
+} board_list[] = {
+#ifdef CONFIG_SH_DREAMCAST
+	{ pvr2fb_dc_init, pvr2fb_dc_exit, "Sega DC PVR2" },
+#endif
+#ifdef CONFIG_PCI
+	{ pvr2fb_pci_init, pvr2fb_pci_exit, "PCI PVR2" },
+#endif
+	{ 0, },
+};
+
+int __init pvr2fb_init(void)
+{
+	int i, ret = -ENODEV;
+	int size;
+
+	size = sizeof(struct fb_info) + sizeof(struct pvr2fb_par) + 16 * sizeof(u32);
+
+	fb_info = kmalloc(size, GFP_KERNEL);
+	
+	if (!fb_info) {
+		printk(KERN_ERR "Failed to allocate memory for fb_info\n");
+		return -ENOMEM;
+	}
+
+	memset(fb_info, 0, size);
+
+	currentpar = (struct pvr2fb_par *)(fb_info + 1);
+
+	for (i = 0; i < ARRAY_SIZE(board_list); i++) {
+		struct pvr2_board *pvr_board = board_list + i;
+
+		if (!pvr_board->init)
+			continue;
+
+		ret = pvr_board->init();
+
+		if (ret != 0) {
+			printk(KERN_ERR "pvr2fb: Failed init of %s device\n",
+				pvr_board->name);
+			kfree(fb_info);
+			break;
+		}
+	}
+
+	return ret;
+}
+
+static void __exit pvr2fb_exit(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(board_list); i++) {
+		struct pvr2_board *pvr_board = board_list + i;
+
+		if (pvr_board->exit)
+			pvr_board->exit();
+	}
+		
+#ifdef CONFIG_SH_STORE_QUEUES
+	sq_unmap(pvr2fb_map);
+#endif
+
+	unregister_framebuffer(fb_info);
+	kfree(fb_info);
+}
+
 #ifdef MODULE
-MODULE_LICENSE("GPL");
 module_init(pvr2fb_init);
 #endif
 module_exit(pvr2fb_exit);
 
+MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>, M. R. Brown <mrbrown@0xd6.org>");
+MODULE_DESCRIPTION("Framebuffer driver for NEC PowerVR 2 based graphics boards");
+MODULE_LICENSE("GPL");
+
diff -puN drivers/video/radeonfb.c~linus drivers/video/radeonfb.c
--- 25/drivers/video/radeonfb.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/video/radeonfb.c	2004-01-19 22:17:23.000000000 -0800
@@ -114,6 +114,7 @@ enum radeon_chips {
 	RADEON_Ie,
 	RADEON_If,
 	RADEON_Ig,
+	RADEON_Yd,
 	RADEON_Ld,
 	RADEON_Le,
 	RADEON_Lf,
@@ -207,6 +208,7 @@ static struct pci_device_id radeonfb_pci
 	{ PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RADEON_Ie, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_Ie},
 	{ PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RADEON_If, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_If},
 	{ PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RADEON_Ig, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_Ig},
+	{ PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RADEON_Yd, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_Yd},
 	{ PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RADEON_Ld, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_Ld},
 	{ PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RADEON_Le, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_Le},
 	{ PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RADEON_Lf, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_Lf},
@@ -679,7 +681,7 @@ static __inline__ int _max(int val1, int
  */
         
 static char *mode_option __initdata;
-static char noaccel = 1;
+static char noaccel = 0;
 static char mirror = 0;
 static int panel_yres __initdata = 0;
 static char force_dfp __initdata = 0;
@@ -1241,9 +1243,6 @@ static void radeon_engine_init (struct r
 	radeon_fifo_wait (1);
 	OUTREG(RB2D_DSTCACHE_MODE, 0);
 
-	/* XXX */
-	rinfo->pitch = ((rinfo->xres_virtual * (rinfo->bpp / 8) + 0x3f)) >> 6;
-
 	radeon_fifo_wait (1);
 	temp = INREG(DEFAULT_PITCH_OFFSET);
 	OUTREG(DEFAULT_PITCH_OFFSET, ((temp & 0xc0000000) | 
@@ -1782,6 +1781,7 @@ static int radeonfb_set_par (struct fb_i
 	int hsync_start, hsync_fudge, bytpp, hsync_wid, vsync_wid;
 	int primary_mon = PRIMARY_MONITOR(rinfo);
 	int depth = var_to_depth(mode);
+        int accel = (mode->accel_flags & FB_ACCELF_TEXT) != 0;
 
 	rinfo->xres = mode->xres;
 	rinfo->yres = mode->yres;
@@ -1878,7 +1878,15 @@ static int radeonfb_set_par (struct fb_i
 	newmode.crtc_v_sync_strt_wid = (((vSyncStart - 1) & 0xfff) |
 					 (vsync_wid << 16) | (v_sync_pol  << 23));
 
-	newmode.crtc_pitch = (mode->xres_virtual >> 3);
+	if (accel) {
+		/* We first calculate the engine pitch */
+		rinfo->pitch = ((mode->xres_virtual * ((mode->bits_per_pixel + 1) / 8) + 0x3f)
+ 				& ~(0x3f)) >> 6;
+
+		/* Then, re-multiply it to get the CRTC pitch */
+		newmode.crtc_pitch = (rinfo->pitch << 3) / ((mode->bits_per_pixel + 1) / 8);
+	} else
+		newmode.crtc_pitch = (mode->xres_virtual >> 3);
 	newmode.crtc_pitch |= (newmode.crtc_pitch << 16);
 
 #if defined(__BIG_ENDIAN)
@@ -2085,18 +2093,21 @@ static int radeonfb_set_par (struct fb_i
 	if (!rinfo->asleep) {
 		radeon_write_mode (rinfo, &newmode);
 		/* (re)initialize the engine */
-		if (!noaccel)
+		if (noaccel)
 			radeon_engine_init (rinfo);
 	
 	}
 	/* Update fix */
-        info->fix.line_length = rinfo->pitch*64;
+	if (accel)
+        	info->fix.line_length = rinfo->pitch*64;
+        else
+		info->fix.line_length = mode->xres_virtual * ((mode->bits_per_pixel + 1) / 8);
         info->fix.visual = rinfo->depth == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
 
 #ifdef CONFIG_BOOTX_TEXT
 	/* Update debug text engine */
 	btext_update_display(rinfo->fb_base_phys, mode->xres, mode->yres,
-			     rinfo->depth, rinfo->pitch*64);
+			     rinfo->depth, info->fix.line_length);
 #endif
 
 	return 0;
@@ -3022,11 +3033,6 @@ static int radeonfb_pci_register (struct
 	 */
 	radeon_save_state (rinfo, &rinfo->init_state);
 
-	if (!noaccel) {
-		/* initialize the engine */
-		radeon_engine_init (rinfo);
-	}
-
 	/* set all the vital stuff */
 	radeon_set_fbinfo (rinfo);
 
diff -puN drivers/video/tridentfb.c~linus drivers/video/tridentfb.c
--- 25/drivers/video/tridentfb.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/video/tridentfb.c	2004-01-19 22:17:23.000000000 -0800
@@ -723,7 +723,7 @@ static int tridentfb_check_var(struct fb
 	if (bpp == 24 )
 		bpp = var->bits_per_pixel = 32;
 	/* check whether resolution fits on panel and in memory*/
-	if (var->xres > nativex)
+	if (flatpanel && nativex && var->xres > nativex)
 		return -EINVAL;
 	if (var->xres * var->yres_virtual * bpp/8 > info->fix.smem_len)
 		return -EINVAL;
diff -puN drivers/zorro/Makefile~linus drivers/zorro/Makefile
--- 25/drivers/zorro/Makefile~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/zorro/Makefile	2004-01-19 22:17:23.000000000 -0800
@@ -2,7 +2,7 @@
 # Makefile for the Zorro bus specific drivers.
 #
 
-obj-$(CONFIG_ZORRO)	+= zorro.o names.o
+obj-$(CONFIG_ZORRO)	+= zorro.o zorro-driver.o zorro-sysfs.o names.o
 obj-$(CONFIG_PROC_FS)	+= proc.o
 
 host-progs 		:= gen-devlist
diff -puN drivers/zorro/proc.c~linus drivers/zorro/proc.c
--- 25/drivers/zorro/proc.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/zorro/proc.c	2004-01-19 22:17:23.000000000 -0800
@@ -3,7 +3,7 @@
  *
  *	Procfs interface for the Zorro bus.
  *
- *	Copyright (C) 1998-2000 Geert Uytterhoeven
+ *	Copyright (C) 1998-2003 Geert Uytterhoeven
  *
  *	Heavily based on the procfs interface for the PCI bus, which is
  *
@@ -49,7 +49,7 @@ proc_bus_zorro_read(struct file *file, c
 {
 	struct inode *ino = file->f_dentry->d_inode;
 	struct proc_dir_entry *dp = PDE(ino);
-	struct zorro_dev *dev = dp->data;
+	struct zorro_dev *z = dp->data;
 	struct ConfigDev cd;
 	loff_t pos = *ppos;
 
@@ -62,11 +62,11 @@ proc_bus_zorro_read(struct file *file, c
 
 	/* Construct a ConfigDev */
 	memset(&cd, 0, sizeof(cd));
-	cd.cd_Rom = dev->rom;
-	cd.cd_SlotAddr = dev->slotaddr;
-	cd.cd_SlotSize = dev->slotsize;
-	cd.cd_BoardAddr = (void *)dev->resource.start;
-	cd.cd_BoardSize = dev->resource.end-dev->resource.start+1;
+	cd.cd_Rom = z->rom;
+	cd.cd_SlotAddr = z->slotaddr;
+	cd.cd_SlotSize = z->slotsize;
+	cd.cd_BoardAddr = (void *)zorro_resource_start(z);
+	cd.cd_BoardSize = zorro_resource_len(z);
 
 	if (copy_to_user(buf, &cd, nbytes))
 		return -EFAULT;
@@ -88,11 +88,10 @@ get_zorro_dev_info(char *buf, char **sta
 	int len, cnt;
 
 	for (slot = cnt = 0; slot < zorro_num_autocon && count > cnt; slot++) {
-		struct zorro_dev *dev = &zorro_autocon[slot];
+		struct zorro_dev *z = &zorro_autocon[slot];
 		len = sprintf(buf, "%02x\t%08x\t%08lx\t%08lx\t%02x\n", slot,
-			      dev->id, dev->resource.start,
-			      dev->resource.end-dev->resource.start+1,
-			      dev->rom.er_Type);
+			      z->id, zorro_resource_start(z),
+			      zorro_resource_len(z), z->rom.er_Type);
 		at += len;
 		if (at >= pos) {
 			if (!*start) {
diff -puN drivers/zorro/zorro.c~linus drivers/zorro/zorro.c
--- 25/drivers/zorro/zorro.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/drivers/zorro/zorro.c	2004-01-19 22:17:23.000000000 -0800
@@ -3,7 +3,7 @@
  *
  *    Zorro Bus Services
  *
- *    Copyright (C) 1995-2000 Geert Uytterhoeven
+ *    Copyright (C) 1995-2003 Geert Uytterhoeven
  *
  *    This file is subject to the terms and conditions of the GNU General Public
  *    License.  See the file COPYING in the main directory of this archive
@@ -19,6 +19,8 @@
 #include <asm/bitops.h>
 #include <asm/amigahw.h>
 
+#include "zorro.h"
+
 
     /*
      *  Zorro Expansion Devices
@@ -29,21 +31,21 @@ struct zorro_dev zorro_autocon[ZORRO_NUM
 
 
     /*
-     *  Zorro Bus Resources
-     *  Order _does_ matter! (see code below)
+     *  Single Zorro bus
      */
 
-static struct resource zorro_res[4] = {
-    /* Zorro II regions (on Zorro II/III) */
-    { "Zorro II exp", 0x00e80000, 0x00efffff },
-    { "Zorro II mem", 0x00200000, 0x009fffff },
-    /* Zorro III regions (on Zorro III only) */
-    { "Zorro III exp", 0xff000000, 0xffffffff },
-    { "Zorro III cfg", 0x40000000, 0x7fffffff }
+struct zorro_bus zorro_bus = {\
+    .resources = {
+	/* Zorro II regions (on Zorro II/III) */
+	{ .name = "Zorro II exp", .start = 0x00e80000, .end = 0x00efffff },
+	{ .name = "Zorro II mem", .start = 0x00200000, .end = 0x009fffff },
+	/* Zorro III regions (on Zorro III only) */
+	{ .name = "Zorro III exp", .start = 0xff000000, .end = 0xffffffff },
+	{ .name = "Zorro III cfg", .start = 0x40000000, .end = 0x7fffffff }
+    },
+    .name = "Zorro bus"
 };
 
-static u_int zorro_num_res __initdata = 0;
-
 
     /*
      *  Find Zorro Devices
@@ -51,16 +53,16 @@ static u_int zorro_num_res __initdata = 
 
 struct zorro_dev *zorro_find_device(zorro_id id, struct zorro_dev *from)
 {
-    struct zorro_dev *dev;
+    struct zorro_dev *z;
 
     if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(ZORRO))
 	return NULL;
 
-    for (dev = from ? from+1 : &zorro_autocon[0];
-	 dev < zorro_autocon+zorro_num_autocon;
-	 dev++)
-	if (id == ZORRO_WILDCARD || id == dev->id)
-	    return dev;
+    for (z = from ? from+1 : &zorro_autocon[0];
+	 z < zorro_autocon+zorro_num_autocon;
+	 z++)
+	if (id == ZORRO_WILDCARD || id == z->id)
+	    return z;
     return NULL;
 }
 
@@ -112,10 +114,10 @@ static struct resource __init *zorro_fin
 {
     int i;
 
-    for (i = 0; i < zorro_num_res; i++)
-	if (z->resource.start >= zorro_res[i].start &&
-	    z->resource.end <= zorro_res[i].end)
-		return &zorro_res[i];
+    for (i = 0; i < zorro_bus.num_resources; i++)
+	if (zorro_resource_start(z) >= zorro_bus.resources[i].start &&
+	    zorro_resource_end(z) <= zorro_bus.resources[i].end)
+		return &zorro_bus.resources[i];
     return &iomem_resource;
 }
 
@@ -126,8 +128,8 @@ static struct resource __init *zorro_fin
 
 static int __init zorro_init(void)
 {
-    struct zorro_dev *dev;
-    u_int i;
+    struct zorro_dev *z;
+    unsigned int i;
 
     if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(ZORRO))
 	return 0;
@@ -135,32 +137,43 @@ static int __init zorro_init(void)
     printk("Zorro: Probing AutoConfig expansion devices: %d device%s\n",
 	   zorro_num_autocon, zorro_num_autocon == 1 ? "" : "s");
 
+    /* Initialize the Zorro bus */
+    INIT_LIST_HEAD(&zorro_bus.devices);
+    strcpy(zorro_bus.dev.bus_id, "zorro");
+    device_register(&zorro_bus.dev);
+
     /* Request the resources */
-    zorro_num_res = AMIGAHW_PRESENT(ZORRO3) ? 4 : 2;
-    for (i = 0; i < zorro_num_res; i++)
-	request_resource(&iomem_resource, &zorro_res[i]);
+    zorro_bus.num_resources = AMIGAHW_PRESENT(ZORRO3) ? 4 : 2;
+    for (i = 0; i < zorro_bus.num_resources; i++)
+	request_resource(&iomem_resource, &zorro_bus.resources[i]);
+
+    /* Register all devices */
     for (i = 0; i < zorro_num_autocon; i++) {
-	dev = &zorro_autocon[i];
-	dev->id = (dev->rom.er_Manufacturer<<16) | (dev->rom.er_Product<<8);
-	if (dev->id == ZORRO_PROD_GVP_EPC_BASE) {
+	z = &zorro_autocon[i];
+	z->id = (z->rom.er_Manufacturer<<16) | (z->rom.er_Product<<8);
+	if (z->id == ZORRO_PROD_GVP_EPC_BASE) {
 	    /* GVP quirk */
-	    unsigned long magic = dev->resource.start+0x8000;
-	    dev->id |= *(u16 *)ZTWO_VADDR(magic) & GVP_PRODMASK;
+	    unsigned long magic = zorro_resource_start(z)+0x8000;
+	    z->id |= *(u16 *)ZTWO_VADDR(magic) & GVP_PRODMASK;
 	}
-	sprintf(dev->name, "Zorro device %08x", dev->id);
-	zorro_name_device(dev);
-	dev->resource.name = dev->name;
-	if (request_resource(zorro_find_parent_resource(dev), &dev->resource))
+	sprintf(z->name, "Zorro device %08x", z->id);
+	zorro_name_device(z);
+	z->resource.name = z->name;
+	if (request_resource(zorro_find_parent_resource(z), &z->resource))
 	    printk(KERN_ERR "Zorro: Address space collision on device %s "
 		   "[%lx:%lx]\n",
-		   dev->name, dev->resource.start, dev->resource.end);
+		   z->name, zorro_resource_start(z), zorro_resource_end(z));
+	sprintf(z->dev.bus_id, "%02x", i);
+	z->dev.parent = &zorro_bus.dev;
+	z->dev.bus = &zorro_bus_type;
+	device_register(&z->dev);
+	zorro_create_sysfs_dev_files(z);
     }
 
     /* Mark all available Zorro II memory */
-    for (i = 0; i < zorro_num_autocon; i++) {
-	dev = &zorro_autocon[i];
-	if (dev->rom.er_Type & ERTF_MEMLIST)
-	    mark_region(dev->resource.start, dev->resource.end+1, 1);
+    zorro_for_each_dev(z) {
+	if (z->rom.er_Type & ERTF_MEMLIST)
+	    mark_region(zorro_resource_start(z), zorro_resource_end(z)+1, 1);
     }
 
     /* Unmark all used Zorro II memory */
diff -puN /dev/null drivers/zorro/zorro-driver.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/zorro/zorro-driver.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,150 @@
+/*
+ *  Zorro Driver Services
+ *
+ *  Copyright (C) 2003 Geert Uytterhoeven
+ *
+ *  Loosely based on drivers/pci/pci-driver.c
+ *
+ *  This file is subject to the terms and conditions of the GNU General Public
+ *  License.  See the file COPYING in the main directory of this archive
+ *  for more details.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/zorro.h>
+
+
+    /**
+     *  zorro_match_device - Tell if a Zorro device structure has a matching
+     *                       Zorro device id structure
+     *  @ids: array of Zorro device id structures to search in
+     *  @dev: the Zorro device structure to match against
+     *
+     *  Used by a driver to check whether a Zorro device present in the
+     *  system is in its list of supported devices. Returns the matching
+     *  zorro_device_id structure or %NULL if there is no match.
+     */
+
+const struct zorro_device_id *
+zorro_match_device(const struct zorro_device_id *ids,
+		   const struct zorro_dev *z)
+{
+	while (ids->id) {
+		if (ids->id == ZORRO_WILDCARD || ids->id == z->id)
+			return ids;
+		ids++;
+	}
+	return NULL;
+}
+
+
+static int zorro_device_probe(struct device *dev)
+{
+	int error = 0;
+	struct zorro_driver *drv = to_zorro_driver(dev->driver);
+	struct zorro_dev *z = to_zorro_dev(dev);
+
+	if (!z->driver && drv->probe) {
+		const struct zorro_device_id *id;
+
+		id = zorro_match_device(drv->id_table, z);
+		if (id)
+			error = drv->probe(z, id);
+		if (error >= 0) {
+			z->driver = drv;
+			error = 0;
+		}
+	}
+	return error;
+}
+
+
+    /**
+     *  zorro_register_driver - register a new Zorro driver
+     *  @drv: the driver structure to register
+     *
+     *  Adds the driver structure to the list of registered drivers
+     *  Returns the number of Zorro devices which were claimed by the driver
+     *  during registration.  The driver remains registered even if the
+     *  return value is zero.
+     */
+
+int zorro_register_driver(struct zorro_driver *drv)
+{
+	int count = 0;
+
+	/* initialize common driver fields */
+	drv->driver.name = drv->name;
+	drv->driver.bus = &zorro_bus_type;
+	drv->driver.probe = zorro_device_probe;
+
+	/* register with core */
+	count = driver_register(&drv->driver);
+	return count ? count : 1;
+}
+
+
+    /**
+     *  zorro_unregister_driver - unregister a zorro driver
+     *  @drv: the driver structure to unregister
+     *
+     *  Deletes the driver structure from the list of registered Zorro drivers,
+     *  gives it a chance to clean up by calling its remove() function for
+     *  each device it was responsible for, and marks those devices as
+     *  driverless.
+     */
+
+void zorro_unregister_driver(struct zorro_driver *drv)
+{
+	driver_unregister(&drv->driver);
+}
+
+
+    /**
+     *  zorro_bus_match - Tell if a Zorro device structure has a matching Zorro
+     *                    device id structure
+     *  @ids: array of Zorro device id structures to search in
+     *  @dev: the Zorro device structure to match against
+     *
+     *  Used by a driver to check whether a Zorro device present in the
+     *  system is in its list of supported devices.Returns the matching
+     *  zorro_device_id structure or %NULL if there is no match.
+     */
+
+static int zorro_bus_match(struct device *dev, struct device_driver *drv)
+{
+	struct zorro_dev *z = to_zorro_dev(dev);
+	struct zorro_driver *zorro_drv = to_zorro_driver(drv);
+	const struct zorro_device_id *ids = zorro_drv->id_table;
+
+	if (!ids)
+		return 0;
+
+	while (ids->id) {
+		if (ids->id == ZORRO_WILDCARD || ids->id == z->id)
+			return 1;
+		ids++;
+	}
+	return 0;
+}
+
+
+struct bus_type zorro_bus_type = {
+	.name	= "zorro",
+	.match	= zorro_bus_match
+};
+
+
+static int __init zorro_driver_init(void)
+{
+	return bus_register(&zorro_bus_type);
+}
+
+postcore_initcall(zorro_driver_init);
+
+EXPORT_SYMBOL(zorro_match_device);
+EXPORT_SYMBOL(zorro_register_driver);
+EXPORT_SYMBOL(zorro_unregister_driver);
+EXPORT_SYMBOL(zorro_dev_driver);
+EXPORT_SYMBOL(zorro_bus_type);
diff -puN /dev/null drivers/zorro/zorro.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/zorro/zorro.h	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,4 @@
+
+extern void zorro_name_device(struct zorro_dev *z);
+extern void zorro_create_sysfs_dev_files(struct zorro_dev *z);
+
diff -puN /dev/null drivers/zorro/zorro-sysfs.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/drivers/zorro/zorro-sysfs.c	2004-01-19 22:17:23.000000000 -0800
@@ -0,0 +1,98 @@
+/*
+ *  File Attributes for Zorro Devices
+ *
+ *  Copyright (C) 2003 Geert Uytterhoeven
+ *
+ *  Loosely based on drivers/pci/pci-sysfs.c
+ *
+ *  This file is subject to the terms and conditions of the GNU General Public
+ *  License.  See the file COPYING in the main directory of this archive
+ *  for more details.
+ */
+
+
+#include <linux/kernel.h>
+#include <linux/zorro.h>
+#include <linux/stat.h>
+
+#include "zorro.h"
+
+
+/* show configuration fields */
+#define zorro_config_attr(name, field, format_string)			\
+static ssize_t								\
+show_##name(struct device *dev, char *buf)				\
+{									\
+	struct zorro_dev *z;						\
+									\
+	z = to_zorro_dev(dev);						\
+	return sprintf(buf, format_string, z->field);			\
+}									\
+static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
+
+zorro_config_attr(id, id, "0x%08x\n");
+zorro_config_attr(type, rom.er_Type, "0x%02x\n");
+zorro_config_attr(serial, rom.er_SerialNumber, "0x%08x\n");
+zorro_config_attr(slotaddr, slotaddr, "0x%04x\n");
+zorro_config_attr(slotsize, slotsize, "0x%04x\n");
+
+static ssize_t zorro_show_resource(struct device *dev, char *buf)
+{
+	struct zorro_dev *z = to_zorro_dev(dev);
+
+	return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n",
+		       zorro_resource_start(z), zorro_resource_end(z),
+		       zorro_resource_flags(z));
+}
+
+static DEVICE_ATTR(resource, S_IRUGO, zorro_show_resource, NULL);
+
+static ssize_t zorro_read_config(struct kobject *kobj, char *buf, loff_t off,
+				 size_t count)
+{
+	struct zorro_dev *z = to_zorro_dev(container_of(kobj, struct device,
+					   kobj));
+	struct ConfigDev cd;
+	unsigned int size = sizeof(cd);
+
+	if (off > size)
+		return 0;
+	if (off+count > size)
+		count = size-off;
+
+	/* Construct a ConfigDev */
+	memset(&cd, 0, sizeof(cd));
+	cd.cd_Rom = z->rom;
+	cd.cd_SlotAddr = z->slotaddr;
+	cd.cd_SlotSize = z->slotsize;
+	cd.cd_BoardAddr = (void *)zorro_resource_start(z);
+	cd.cd_BoardSize = zorro_resource_len(z);
+
+	memcpy(buf, (void *)&cd+off, count);
+	return count;
+}
+
+static struct bin_attribute zorro_config_attr = {
+	.attr =	{
+		.name = "config",
+		.mode = S_IRUGO | S_IWUSR,
+		.owner = THIS_MODULE
+	},
+	.size = sizeof(struct ConfigDev),
+	.read = zorro_read_config,
+};
+
+void zorro_create_sysfs_dev_files(struct zorro_dev *z)
+{
+	struct device *dev = &z->dev;
+
+	/* current configuration's attributes */
+	device_create_file(dev, &dev_attr_id);
+	device_create_file(dev, &dev_attr_type);
+	device_create_file(dev, &dev_attr_serial);
+	device_create_file(dev, &dev_attr_slotaddr);
+	device_create_file(dev, &dev_attr_slotsize);
+	device_create_file(dev, &dev_attr_resource);
+	sysfs_create_bin_file(&dev->kobj, &zorro_config_attr);
+}
+
diff -puN fs/afs/callback.c~linus fs/afs/callback.c
--- 25/fs/afs/callback.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/callback.c	2004-01-19 22:17:23.000000000 -0800
@@ -24,28 +24,28 @@
 /*
  * allow the fileserver to request callback state (re-)initialisation
  */
-int SRXAFSCM_InitCallBackState(afs_server_t *server)
+int SRXAFSCM_InitCallBackState(struct afs_server *server)
 {
 	struct list_head callbacks;
 
-	_enter("%p",server);
+	_enter("%p", server);
 
 	INIT_LIST_HEAD(&callbacks);
 
 	/* transfer the callback list from the server to a temp holding area */
 	spin_lock(&server->cb_lock);
 
-	list_add(&callbacks,&server->cb_promises);
+	list_add(&callbacks, &server->cb_promises);
 	list_del_init(&server->cb_promises);
 
-	/* munch our way through the list, grabbing the inode, dropping all the locks and regetting
-	 * them in the right order
+	/* munch our way through the list, grabbing the inode, dropping all the
+	 * locks and regetting them in the right order
 	 */
 	while (!list_empty(&callbacks)) {
+		struct afs_vnode *vnode;
 		struct inode *inode;
-		afs_vnode_t *vnode;
 
-		vnode = list_entry(callbacks.next,afs_vnode_t,cb_link);
+		vnode = list_entry(callbacks.next, struct afs_vnode, cb_link);
 		list_del_init(&vnode->cb_link);
 
 		/* try and grab the inode - may fail */
@@ -56,7 +56,7 @@ int SRXAFSCM_InitCallBackState(afs_serve
 			spin_unlock(&server->cb_lock);
 			spin_lock(&vnode->lock);
 
-			if (vnode->cb_server==server) {
+			if (vnode->cb_server == server) {
 				vnode->cb_server = NULL;
 				afs_kafstimod_del_timer(&vnode->cb_timeout);
 				spin_lock(&afs_cb_hash_lock);
@@ -84,15 +84,14 @@ int SRXAFSCM_InitCallBackState(afs_serve
 /*
  * allow the fileserver to break callback promises
  */
-int SRXAFSCM_CallBack(afs_server_t *server, size_t count, afs_callback_t callbacks[])
+int SRXAFSCM_CallBack(struct afs_server *server, size_t count,
+		      struct afs_callback callbacks[])
 {
-	struct list_head *_p;
+	_enter("%p,%u,", server, count);
 
-	_enter("%p,%u,",server,count);
-
-	for (; count>0; callbacks++, count--) {
+	for (; count > 0; callbacks++, count--) {
+		struct afs_vnode *vnode = NULL;
 		struct inode *inode = NULL;
-		afs_vnode_t *vnode = NULL;
 		int valid = 0;
 
 		_debug("- Fid { vl=%08x n=%u u=%u }  CB { v=%u x=%u t=%u }",
@@ -107,14 +106,15 @@ int SRXAFSCM_CallBack(afs_server_t *serv
 		/* find the inode for this fid */
 		spin_lock(&afs_cb_hash_lock);
 
-		list_for_each(_p,&afs_cb_hash(server,&callbacks->fid)) {
-			vnode = list_entry(_p,afs_vnode_t,cb_hash_link);
-
-			if (memcmp(&vnode->fid,&callbacks->fid,sizeof(afs_fid_t))!=0)
+		list_for_each_entry(vnode,
+				    &afs_cb_hash(server, &callbacks->fid),
+				    cb_hash_link) {
+			if (memcmp(&vnode->fid, &callbacks->fid,
+				   sizeof(struct afs_fid)) != 0)
 				continue;
 
 			/* right vnode, but is it same server? */
-			if (vnode->cb_server!=server)
+			if (vnode->cb_server != server)
 				break; /* no */
 
 			/* try and nail the inode down */
@@ -127,7 +127,7 @@ int SRXAFSCM_CallBack(afs_server_t *serv
 		if (inode) {
 			/* we've found the record for this vnode */
 			spin_lock(&vnode->lock);
-			if (vnode->cb_server==server) {
+			if (vnode->cb_server == server) {
 				/* the callback _is_ on the calling server */
 				vnode->cb_server = NULL;
 				valid = 1;
@@ -161,8 +161,8 @@ int SRXAFSCM_CallBack(afs_server_t *serv
 /*
  * allow the fileserver to see if the cache manager is still alive
  */
-int SRXAFSCM_Probe(afs_server_t *server)
+int SRXAFSCM_Probe(struct afs_server *server)
 {
-	_debug("SRXAFSCM_Probe(%p)\n",server);
+	_debug("SRXAFSCM_Probe(%p)\n", server);
 	return 0;
 } /* end SRXAFSCM_Probe() */
diff -puN fs/afs/cell.c~linus fs/afs/cell.c
--- 25/fs/afs/cell.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/cell.c	2004-01-19 22:17:23.000000000 -0800
@@ -29,20 +29,16 @@ LIST_HEAD(afs_proc_cells);
 static struct list_head afs_cells = LIST_HEAD_INIT(afs_cells);
 static rwlock_t afs_cells_lock = RW_LOCK_UNLOCKED;
 static DECLARE_RWSEM(afs_cells_sem); /* add/remove serialisation */
-static afs_cell_t *afs_cell_root;
-
-static char *rootcell;
-
-MODULE_PARM(rootcell,"s");
-MODULE_PARM_DESC(rootcell,"root AFS cell name and VL server IP addr list");
+static struct afs_cell *afs_cell_root;
 
 #ifdef AFS_CACHING_SUPPORT
-static cachefs_match_val_t afs_cell_cache_match(void *target, const void *entry);
+static cachefs_match_val_t afs_cell_cache_match(void *target,
+						const void *entry);
 static void afs_cell_cache_update(void *source, void *entry);
 
 struct cachefs_index_def afs_cache_cell_index_def = {
 	.name			= "cell_ix",
-	.data_size		= sizeof(afs_cell_t),
+	.data_size		= sizeof(struct afs_cache_cell),
 	.keys[0]		= { CACHEFS_INDEX_KEYS_ASCIIZ, 64 },
 	.match			= afs_cell_cache_match,
 	.update			= afs_cell_cache_update,
@@ -55,27 +51,27 @@ struct cachefs_index_def afs_cache_cell_
  * - "name" is the name of the cell
  * - "vllist" is a colon separated list of IP addresses in "a.b.c.d" format
  */
-int afs_cell_create(const char *name, char *vllist, afs_cell_t **_cell)
+int afs_cell_create(const char *name, char *vllist, struct afs_cell **_cell)
 {
-	afs_cell_t *cell;
+	struct afs_cell *cell;
 	char *next;
 	int ret;
 
-	_enter("%s",name);
+	_enter("%s", name);
 
-	if (!name) BUG(); /* TODO: want to look up "this cell" in the cache */
-
-	down_write(&afs_cells_sem);
+	BUG_ON(!name); /* TODO: want to look up "this cell" in the cache */
 
 	/* allocate and initialise a cell record */
-	cell = kmalloc(sizeof(afs_cell_t) + strlen(name) + 1,GFP_KERNEL);
+	cell = kmalloc(sizeof(struct afs_cell) + strlen(name) + 1, GFP_KERNEL);
 	if (!cell) {
 		_leave(" = -ENOMEM");
 		return -ENOMEM;
 	}
 
-	memset(cell,0,sizeof(afs_cell_t));
-	atomic_set(&cell->usage,0);
+	down_write(&afs_cells_sem);
+
+	memset(cell, 0, sizeof(struct afs_cell));
+	atomic_set(&cell->usage, 0);
 
 	INIT_LIST_HEAD(&cell->link);
 
@@ -96,26 +92,27 @@ int afs_cell_create(const char *name, ch
 	do {
 		unsigned a, b, c, d;
 
-		next = strchr(vllist,':');
-		if (next) *next++ = 0;
+		next = strchr(vllist, ':');
+		if (next)
+			*next++ = 0;
 
-		if (sscanf(vllist,"%u.%u.%u.%u",&a,&b,&c,&d)!=4)
+		if (sscanf(vllist, "%u.%u.%u.%u", &a, &b, &c, &d) != 4)
 			goto badaddr;
 
-		if (a>255 || b>255 || c>255 || d>255)
+		if (a > 255 || b > 255 || c > 255 || d > 255)
 			goto badaddr;
 
 		cell->vl_addrs[cell->vl_naddrs++].s_addr =
-			htonl((a<<24)|(b<<16)|(c<<8)|d);
+			htonl((a << 24) | (b << 16) | (c << 8) | d);
 
 		if (cell->vl_naddrs >= AFS_CELL_MAX_ADDRS)
 			break;
 
-	} while(vllist=next, vllist);
+	} while(vllist = next, vllist);
 
 	/* add a proc dir for this cell */
 	ret = afs_proc_cell_setup(cell);
-	if (ret<0)
+	if (ret < 0)
 		goto error;
 
 #ifdef AFS_CACHING_SUPPORT
@@ -128,24 +125,25 @@ int afs_cell_create(const char *name, ch
 
 	/* add to the cell lists */
 	write_lock(&afs_cells_lock);
-	list_add_tail(&cell->link,&afs_cells);
+	list_add_tail(&cell->link, &afs_cells);
 	write_unlock(&afs_cells_lock);
 
 	down_write(&afs_proc_cells_sem);
-	list_add_tail(&cell->proc_link,&afs_proc_cells);
+	list_add_tail(&cell->proc_link, &afs_proc_cells);
 	up_write(&afs_proc_cells_sem);
 
 	*_cell = cell;
 	up_write(&afs_cells_sem);
 
-	_leave(" = 0 (%p)",cell);
+	_leave(" = 0 (%p)", cell);
 	return 0;
 
  badaddr:
-	printk("kAFS: bad VL server IP address: '%s'\n",vllist);
+	printk(KERN_ERR "kAFS: bad VL server IP address: '%s'\n", vllist);
  error:
 	up_write(&afs_cells_sem);
-	kfree(afs_cell_root);
+	kfree(cell);
+	_leave(" = %d", ret);
 	return ret;
 } /* end afs_cell_create() */
 
@@ -153,31 +151,54 @@ int afs_cell_create(const char *name, ch
 /*
  * initialise the cell database from module parameters
  */
-int afs_cell_init(void)
+int afs_cell_init(char *rootcell)
 {
+	struct afs_cell *old_root, *new_root;
 	char *cp;
 	int ret;
 
 	_enter("");
 
 	if (!rootcell) {
-		printk("kAFS: no root cell specified\n");
-		return -EINVAL;
+		/* module is loaded with no parameters, or built statically.
+		 * - in the future we might initialize cell DB here.
+		 */
+		_leave(" = 0 (but no root)");
+		return 0;
 	}
 
-	cp = strchr(rootcell,':');
+	cp = strchr(rootcell, ':');
 	if (!cp) {
-		printk("kAFS: no VL server IP addresses specified\n");
+		printk(KERN_ERR "kAFS: no VL server IP addresses specified\n");
+		_leave(" = %d (no colon)", -EINVAL);
 		return -EINVAL;
 	}
 
 	/* allocate a cell record for the root cell */
 	*cp++ = 0;
-	ret = afs_cell_create(rootcell,cp,&afs_cell_root);
-	if (ret==0)
-		afs_get_cell(afs_cell_root);
+	ret = afs_cell_create(rootcell, cp, &new_root);
+	if (ret < 0) {
+		_leave(" = %d", ret);
+		return ret;
+	}
 
-	_leave(" = %d",ret);
+	/* as afs_put_cell() takes locks by itself, we have to do
+	 * a little gymnastics to be race-free.
+	 */
+	afs_get_cell(new_root);
+
+	write_lock(&afs_cells_lock);
+	while (afs_cell_root) {
+		old_root = afs_cell_root;
+		afs_cell_root = NULL;
+		write_unlock(&afs_cells_lock);
+		afs_put_cell(old_root);
+		write_lock(&afs_cells_lock);
+	}
+	afs_cell_root = new_root;
+	write_unlock(&afs_cells_lock);
+
+	_leave(" = %d", ret);
 	return ret;
 
 } /* end afs_cell_init() */
@@ -188,8 +209,7 @@ int afs_cell_init(void)
  */
 int afs_cell_lookup(const char *name, unsigned namesz, struct afs_cell **_cell)
 {
-	struct list_head *_p;
-	afs_cell_t *cell;
+	struct afs_cell *cell;
 	int ret;
 
 	_enter("\"%*.*s\",", namesz, namesz, name ? name : "");
@@ -202,14 +222,14 @@ int afs_cell_lookup(const char *name, un
 		cell = NULL;
 		read_lock(&afs_cells_lock);
 
-		list_for_each(_p,&afs_cells) {
-			cell = list_entry(_p, struct afs_cell, link);
+		list_for_each_entry(cell, &afs_cells, link) {
 			if (strncmp(cell->name, name, namesz) == 0) {
 				afs_get_cell(cell);
-				break;
+				goto found;
 			}
-			cell = NULL;
 		}
+		cell = NULL;
+	found:
 
 		read_unlock(&afs_cells_lock);
 
@@ -217,9 +237,24 @@ int afs_cell_lookup(const char *name, un
 			ret = 0;
 	}
 	else {
+		read_lock(&afs_cells_lock);
+
 		cell = afs_cell_root;
-		afs_get_cell(cell);
-		ret = 0;
+		if (!cell) {
+			/* this should not happen unless user tries to mount
+			 * when root cell is not set. Return an impossibly
+			 * bizzare errno to alert the user. Things like
+			 * ENOENT might be "more appropriate" but they happen
+			 * for other reasons.
+			 */
+			ret = -EDESTADDRREQ;
+		}
+		else {
+			afs_get_cell(cell);
+			ret = 0;
+		}
+
+		read_unlock(&afs_cells_lock);
 	}
 
 	*_cell = cell;
@@ -232,9 +267,9 @@ int afs_cell_lookup(const char *name, un
 /*
  * try and get a cell record
  */
-afs_cell_t *afs_get_cell_maybe(afs_cell_t **_cell)
+struct afs_cell *afs_get_cell_maybe(struct afs_cell **_cell)
 {
-	afs_cell_t *cell;
+	struct afs_cell *cell;
 
 	write_lock(&afs_cells_lock);
 
@@ -253,18 +288,18 @@ afs_cell_t *afs_get_cell_maybe(afs_cell_
 /*
  * destroy a cell record
  */
-void afs_put_cell(afs_cell_t *cell)
+void afs_put_cell(struct afs_cell *cell)
 {
 	if (!cell)
 		return;
 
-	_enter("%p{%d,%s}",cell,atomic_read(&cell->usage),cell->name);
+	_enter("%p{%d,%s}", cell, atomic_read(&cell->usage), cell->name);
 
 	/* sanity check */
-	if (atomic_read(&cell->usage)<=0)
-		BUG();
+	BUG_ON(atomic_read(&cell->usage) <= 0);
 
-	/* to prevent a race, the decrement and the dequeue must be effectively atomic */
+	/* to prevent a race, the decrement and the dequeue must be effectively
+	 * atomic */
 	write_lock(&afs_cells_lock);
 
 	if (likely(!atomic_dec_and_test(&cell->usage))) {
@@ -275,10 +310,10 @@ void afs_put_cell(afs_cell_t *cell)
 
 	write_unlock(&afs_cells_lock);
 
-	if (!list_empty(&cell->sv_list))	BUG();
-	if (!list_empty(&cell->sv_graveyard))	BUG();
-	if (!list_empty(&cell->vl_list))	BUG();
-	if (!list_empty(&cell->vl_graveyard))	BUG();
+	BUG_ON(!list_empty(&cell->sv_list));
+	BUG_ON(!list_empty(&cell->sv_graveyard));
+	BUG_ON(!list_empty(&cell->vl_list));
+	BUG_ON(!list_empty(&cell->vl_graveyard));
 
 	_leave(" [unused]");
 } /* end afs_put_cell() */
@@ -287,16 +322,16 @@ void afs_put_cell(afs_cell_t *cell)
 /*
  * destroy a cell record
  */
-static void afs_cell_destroy(afs_cell_t *cell)
+static void afs_cell_destroy(struct afs_cell *cell)
 {
-	_enter("%p{%d,%s}",cell,atomic_read(&cell->usage),cell->name);
+	_enter("%p{%d,%s}", cell, atomic_read(&cell->usage), cell->name);
 
-	/* to prevent a race, the decrement and the dequeue must be effectively atomic */
+	/* to prevent a race, the decrement and the dequeue must be effectively
+	 * atomic */
 	write_lock(&afs_cells_lock);
 
 	/* sanity check */
-	if (atomic_read(&cell->usage)!=0)
-		BUG();
+	BUG_ON(atomic_read(&cell->usage) != 0);
 
 	list_del_init(&cell->link);
 
@@ -311,15 +346,15 @@ static void afs_cell_destroy(afs_cell_t 
 	up_write(&afs_proc_cells_sem);
 
 #ifdef AFS_CACHING_SUPPORT
-	cachefs_relinquish_cookie(cell->cache,0);
+	cachefs_relinquish_cookie(cell->cache, 0);
 #endif
 
 	up_write(&afs_cells_sem);
 
-	if (!list_empty(&cell->sv_list))	BUG();
-	if (!list_empty(&cell->sv_graveyard))	BUG();
-	if (!list_empty(&cell->vl_list))	BUG();
-	if (!list_empty(&cell->vl_graveyard))	BUG();
+	BUG_ON(!list_empty(&cell->sv_list));
+	BUG_ON(!list_empty(&cell->sv_graveyard));
+	BUG_ON(!list_empty(&cell->vl_list));
+	BUG_ON(!list_empty(&cell->vl_graveyard));
 
 	/* finish cleaning up the cell */
 	kfree(cell);
@@ -331,42 +366,40 @@ static void afs_cell_destroy(afs_cell_t 
 /*
  * lookup the server record corresponding to an Rx RPC peer
  */
-int afs_server_find_by_peer(const struct rxrpc_peer *peer, afs_server_t **_server)
+int afs_server_find_by_peer(const struct rxrpc_peer *peer,
+			    struct afs_server **_server)
 {
-	struct list_head *_pc, *_ps;
-	afs_server_t *server;
-	afs_cell_t *cell;
+	struct afs_server *server;
+	struct afs_cell *cell;
 
-	_enter("%p{a=%08x},",peer,ntohl(peer->addr.s_addr));
+	_enter("%p{a=%08x},", peer, ntohl(peer->addr.s_addr));
 
 	/* search the cell list */
 	read_lock(&afs_cells_lock);
 
-	list_for_each(_pc,&afs_cells) {
-		cell = list_entry(_pc,afs_cell_t,link);
+	list_for_each_entry(cell, &afs_cells, link) {
 
 		_debug("? cell %s",cell->name);
 
 		write_lock(&cell->sv_lock);
 
 		/* check the active list */
-		list_for_each(_ps,&cell->sv_list) {
-			server = list_entry(_ps,afs_server_t,link);
-
-			_debug("?? server %08x",ntohl(server->addr.s_addr));
+		list_for_each_entry(server, &cell->sv_list, link) {
+			_debug("?? server %08x", ntohl(server->addr.s_addr));
 
-			if (memcmp(&server->addr,&peer->addr,sizeof(struct in_addr))==0)
+			if (memcmp(&server->addr, &peer->addr,
+				   sizeof(struct in_addr)) == 0)
 				goto found_server;
 		}
 
 		/* check the inactive list */
 		spin_lock(&cell->sv_gylock);
-		list_for_each(_ps,&cell->sv_graveyard) {
-			server = list_entry(_ps,afs_server_t,link);
-
-			_debug("?? dead server %08x",ntohl(server->addr.s_addr));
+		list_for_each_entry(server, &cell->sv_graveyard, link) {
+			_debug("?? dead server %08x",
+			       ntohl(server->addr.s_addr));
 
-			if (memcmp(&server->addr,&peer->addr,sizeof(struct in_addr))==0)
+			if (memcmp(&server->addr, &peer->addr,
+				   sizeof(struct in_addr)) == 0)
 				goto found_dead_server;
 		}
 		spin_unlock(&cell->sv_gylock);
@@ -381,7 +414,7 @@ int afs_server_find_by_peer(const struct
 	/* we found it in the graveyard - resurrect it */
  found_dead_server:
 	list_del(&server->link);
-	list_add_tail(&server->link,&cell->sv_list);
+	list_add_tail(&server->link, &cell->sv_list);
 	afs_get_server(server);
 	afs_kafstimod_del_timer(&server->timeout);
 	spin_unlock(&cell->sv_gylock);
@@ -396,20 +429,20 @@ int afs_server_find_by_peer(const struct
 	read_unlock(&afs_cells_lock);
 
 	*_server = server;
-	_leave(" = 0 (s=%p c=%p)",server,cell);
+	_leave(" = 0 (s=%p c=%p)", server, cell);
 	return 0;
 
 } /* end afs_server_find_by_peer() */
 
 /*****************************************************************************/
 /*
- * purge in-memory cell database on module unload
+ * purge in-memory cell database on module unload or afs_init() failure
  * - the timeout daemon is stopped before calling this
  */
 void afs_cell_purge(void)
 {
-	afs_vlocation_t *vlocation;
-	afs_cell_t *cell;
+	struct afs_vlocation *vlocation;
+	struct afs_cell *cell;
 
 	_enter("");
 
@@ -422,17 +455,19 @@ void afs_cell_purge(void)
 		write_lock(&afs_cells_lock);
 
 		if (!list_empty(&afs_cells)) {
-			cell = list_entry(afs_cells.next,afs_cell_t,link);
+			cell = list_entry(afs_cells.next,
+					  struct afs_cell, link);
 			list_del_init(&cell->link);
 		}
 
 		write_unlock(&afs_cells_lock);
 
 		if (cell) {
-			_debug("PURGING CELL %s (%d)",cell->name,atomic_read(&cell->usage));
+			_debug("PURGING CELL %s (%d)",
+			       cell->name, atomic_read(&cell->usage));
 
-			if (!list_empty(&cell->sv_list)) BUG();
-			if (!list_empty(&cell->vl_list)) BUG();
+			BUG_ON(!list_empty(&cell->sv_list));
+			BUG_ON(!list_empty(&cell->vl_list));
 
 			/* purge the cell's VL graveyard list */
 			_debug(" - clearing VL graveyard");
@@ -441,7 +476,8 @@ void afs_cell_purge(void)
 
 			while (!list_empty(&cell->vl_graveyard)) {
 				vlocation = list_entry(cell->vl_graveyard.next,
-						       afs_vlocation_t,link);
+						       struct afs_vlocation,
+						       link);
 				list_del_init(&vlocation->link);
 
 				afs_kafstimod_del_timer(&vlocation->timeout);
@@ -449,7 +485,8 @@ void afs_cell_purge(void)
 				spin_unlock(&cell->vl_gylock);
 
 				afs_vlocation_do_timeout(vlocation);
-				/* TODO: race if move to use krxtimod instead of kafstimod */
+				/* TODO: race if move to use krxtimod instead
+				 * of kafstimod */
 
 				spin_lock(&cell->vl_gylock);
 			}
@@ -462,9 +499,10 @@ void afs_cell_purge(void)
 			spin_lock(&cell->sv_gylock);
 
 			while (!list_empty(&cell->sv_graveyard)) {
-				afs_server_t *server;
+				struct afs_server *server;
 
-				server = list_entry(cell->sv_graveyard.next,afs_server_t,link);
+				server = list_entry(cell->sv_graveyard.next,
+						    struct afs_server, link);
 				list_del_init(&server->link);
 
 				afs_kafstimod_del_timer(&server->timeout);
@@ -491,7 +529,8 @@ void afs_cell_purge(void)
  * match a cell record obtained from the cache
  */
 #ifdef AFS_CACHING_SUPPORT
-static cachefs_match_val_t afs_cell_cache_match(void *target, const void *entry)
+static cachefs_match_val_t afs_cell_cache_match(void *target,
+						const void *entry)
 {
 	const struct afs_cache_cell *ccell = entry;
 	struct afs_cell *cell = target;
diff -puN fs/afs/cell.h~linus fs/afs/cell.h
--- 25/fs/afs/cell.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/cell.h	2004-01-19 22:17:23.000000000 -0800
@@ -61,7 +61,7 @@ struct afs_cell
 	char			name[0];	/* cell name - must go last */
 };
 
-extern int afs_cell_init(void);
+extern int afs_cell_init(char *rootcell);
 
 extern int afs_cell_create(const char *name, char *vllist, struct afs_cell **_cell);
 
diff -puN fs/afs/cmservice.c~linus fs/afs/cmservice.c
--- 25/fs/afs/cmservice.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/cmservice.c	2004-01-19 22:17:23.000000000 -0800
@@ -94,7 +94,7 @@ static struct rxrpc_service AFSCM_servic
 	.error_func	= afscm_error,
 	.aemap_func	= afscm_aemap,
 	.ops_begin	= &AFSCM_ops[0],
-	.ops_end	= &AFSCM_ops[sizeof(AFSCM_ops)/sizeof(AFSCM_ops[0])],
+	.ops_end	= &AFSCM_ops[sizeof(AFSCM_ops) / sizeof(AFSCM_ops[0])],
 };
 
 static DECLARE_COMPLETION(kafscmd_alive);
@@ -112,13 +112,13 @@ static int kafscmd_die;
  */
 static int kafscmd(void *arg)
 {
-	DECLARE_WAITQUEUE(myself,current);
+	DECLARE_WAITQUEUE(myself, current);
 
 	struct rxrpc_call *call;
 	_SRXAFSCM_xxxx_t func;
 	int die;
 
-	printk("kAFS: Started kafscmd %d\n",current->pid);
+	printk("kAFS: Started kafscmd %d\n", current->pid);
 
 	daemonize("kafscmd");
 
@@ -128,7 +128,7 @@ static int kafscmd(void *arg)
 	do {
 		if (list_empty(&kafscmd_attention_list)) {
 			set_current_state(TASK_INTERRUPTIBLE);
-			add_wait_queue(&kafscmd_sleepq,&myself);
+			add_wait_queue(&kafscmd_sleepq, &myself);
 
 			for (;;) {
 				set_current_state(TASK_INTERRUPTIBLE);
@@ -140,7 +140,7 @@ static int kafscmd(void *arg)
 				schedule();
 			}
 
-			remove_wait_queue(&kafscmd_sleepq,&myself);
+			remove_wait_queue(&kafscmd_sleepq, &myself);
 			set_current_state(TASK_RUNNING);
 		}
 
@@ -162,7 +162,7 @@ static int kafscmd(void *arg)
 
 		if (call) {
 			/* act upon it */
-			_debug("@@@ Begin Attend Call %p",call);
+			_debug("@@@ Begin Attend Call %p", call);
 
 			func = call->app_user;
 			if (func)
@@ -170,13 +170,13 @@ static int kafscmd(void *arg)
 
 			rxrpc_put_call(call);
 
-			_debug("@@@ End Attend Call %p",call);
+			_debug("@@@ End Attend Call %p", call);
 		}
 
 	} while(!die);
 
 	/* and that's all */
-	complete_and_exit(&kafscmd_dead,0);
+	complete_and_exit(&kafscmd_dead, 0);
 
 } /* end kafscmd() */
 
@@ -184,12 +184,14 @@ static int kafscmd(void *arg)
 /*
  * handle a call coming in to the cache manager
  * - if I want to keep the call, I must increment its usage count
- * - the return value will be negated and passed back in an abort packet if non-zero
+ * - the return value will be negated and passed back in an abort packet if
+ *   non-zero
  * - serialised by virtue of there only being one krxiod
  */
 static int afscm_new_call(struct rxrpc_call *call)
 {
-	_enter("%p{cid=%u u=%d}",call,ntohl(call->call_id),atomic_read(&call->usage));
+	_enter("%p{cid=%u u=%d}",
+	       call, ntohl(call->call_id), atomic_read(&call->usage));
 
 	rxrpc_get_call(call);
 
@@ -209,12 +211,13 @@ static int afscm_new_call(struct rxrpc_c
  */
 static void afscm_attention(struct rxrpc_call *call)
 {
-	_enter("%p{cid=%u u=%d}",call,ntohl(call->call_id),atomic_read(&call->usage));
+	_enter("%p{cid=%u u=%d}",
+	       call, ntohl(call->call_id), atomic_read(&call->usage));
 
 	spin_lock(&kafscmd_attention_lock);
 
 	if (list_empty(&call->app_attn_link)) {
-		list_add_tail(&call->app_attn_link,&kafscmd_attention_list);
+		list_add_tail(&call->app_attn_link, &kafscmd_attention_list);
 		rxrpc_get_call(call);
 	}
 
@@ -222,7 +225,7 @@ static void afscm_attention(struct rxrpc
 
 	wake_up(&kafscmd_sleepq);
 
-	_leave(" {u=%d}",atomic_read(&call->usage));
+	_leave(" {u=%d}", atomic_read(&call->usage));
 } /* end afscm_attention() */
 
 /*****************************************************************************/
@@ -243,7 +246,7 @@ static void afscm_error(struct rxrpc_cal
 	spin_lock(&kafscmd_attention_lock);
 
 	if (list_empty(&call->app_attn_link)) {
-		list_add_tail(&call->app_attn_link,&kafscmd_attention_list);
+		list_add_tail(&call->app_attn_link, &kafscmd_attention_list);
 		rxrpc_get_call(call);
 	}
 
@@ -301,7 +304,7 @@ int afscm_start(void)
 		wait_for_completion(&kafscmd_alive);
 
 		ret = rxrpc_add_service(afs_transport, &AFSCM_service);
-		if (ret<0)
+		if (ret < 0)
 			goto kill;
 
 #ifdef AFS_AUTOMOUNT_SUPPORT
@@ -336,14 +339,15 @@ void afscm_stop(void)
 
 	down_write(&afscm_sem);
 
-	if (afscm_usage == 0) BUG();
+	BUG_ON(afscm_usage == 0);
 	afscm_usage--;
 
 	if (afscm_usage == 0) {
 		/* don't want more incoming calls */
 		rxrpc_del_service(afs_transport, &AFSCM_service);
 
-		/* abort any calls I've still got open (the afscm_error() will dequeue them) */
+		/* abort any calls I've still got open (the afscm_error() will
+		 * dequeue them) */
 		spin_lock(&afscm_calls_lock);
 		while (!list_empty(&afscm_calls)) {
 			call = list_entry(afscm_calls.next,
@@ -354,7 +358,8 @@ void afscm_stop(void)
 			rxrpc_get_call(call);
 			spin_unlock(&afscm_calls_lock);
 
-			rxrpc_call_abort(call,-ESRCH); /* abort, dequeue and put */
+			rxrpc_call_abort(call, -ESRCH); /* abort, dequeue and
+							 * put */
 
 			_debug("nuking active call %08x.%d",
 			       ntohl(call->conn->conn_id),
@@ -402,11 +407,11 @@ void afscm_stop(void)
  */
 static void _SRXAFSCM_CallBack(struct rxrpc_call *call)
 {
-	afs_server_t *server;
+	struct afs_server *server;
 	size_t count, qty, tmp;
 	int ret = 0, removed;
 
-	_enter("%p{acs=%s}",call,rxrpc_call_states[call->app_call_state]);
+	_enter("%p{acs=%s}", call, rxrpc_call_states[call->app_call_state]);
 
 	server = afs_server_get_from_peer(call->conn->peer);
 
@@ -417,38 +422,41 @@ static void _SRXAFSCM_CallBack(struct rx
 	case RXRPC_CSTATE_SRVR_GOT_ARGS:
 		ret = -EBADMSG;
 		qty = call->app_ready_qty;
-		if (qty<8 || qty>50*(6*4)+8)
+		if (qty < 8 || qty > 50 * (6 * 4) + 8)
 			break;
 
 		{
-			afs_callback_t *cb, *pcb;
+			struct afs_callback *cb, *pcb;
 			int loop;
 			u32 *fp, *bp;
 
-			fp = rxrpc_call_alloc_scratch(call,qty);
+			fp = rxrpc_call_alloc_scratch(call, qty);
 
-			/* drag the entire argument block out to the scratch space */
-			ret = rxrpc_call_read_data(call,fp,qty,0);
-			if (ret<0)
+			/* drag the entire argument block out to the scratch
+			 * space */
+			ret = rxrpc_call_read_data(call, fp, qty, 0);
+			if (ret < 0)
 				break;
 
 			/* and unmarshall the parameter block */
 			ret = -EBADMSG;
 			count = ntohl(*fp++);
 			if (count>AFSCBMAX ||
-			    (count*(3*4)+8 != qty && count*(6*4)+8 != qty))
+			    (count * (3 * 4) + 8 != qty &&
+			     count * (6 * 4) + 8 != qty))
 				break;
 
 			bp = fp + count*3;
 			tmp = ntohl(*bp++);
-			if (tmp>0 && tmp!=count)
+			if (tmp > 0 && tmp != count)
 				break;
-			if (tmp==0)
+			if (tmp == 0)
 				bp = NULL;
 
-			pcb = cb = rxrpc_call_alloc_scratch_s(call,afs_callback_t);
+			pcb = cb = rxrpc_call_alloc_scratch_s(
+				call, struct afs_callback);
 
-			for (loop=count-1; loop>=0; loop--) {
+			for (loop = count - 1; loop >= 0; loop--) {
 				pcb->fid.vid	= ntohl(*fp++);
 				pcb->fid.vnode	= ntohl(*fp++);
 				pcb->fid.unique	= ntohl(*fp++);
@@ -466,14 +474,15 @@ static void _SRXAFSCM_CallBack(struct rx
 			}
 
 			/* invoke the actual service routine */
-			ret = SRXAFSCM_CallBack(server,count,cb);
-			if (ret<0)
+			ret = SRXAFSCM_CallBack(server, count, cb);
+			if (ret < 0)
 				break;
 		}
 
 		/* send the reply */
-		ret = rxrpc_call_write_data(call,0,NULL,RXRPC_LAST_PACKET,GFP_KERNEL,0,&count);
-		if (ret<0)
+		ret = rxrpc_call_write_data(call, 0, NULL, RXRPC_LAST_PACKET,
+					    GFP_KERNEL, 0, &count);
+		if (ret < 0)
 			break;
 		break;
 
@@ -501,12 +510,12 @@ static void _SRXAFSCM_CallBack(struct rx
 		break;
 	}
 
-	if (ret<0)
-		rxrpc_call_abort(call,ret);
+	if (ret < 0)
+		rxrpc_call_abort(call, ret);
 
 	afs_put_server(server);
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 
 } /* end _SRXAFSCM_CallBack() */
 
@@ -516,16 +525,17 @@ static void _SRXAFSCM_CallBack(struct rx
  */
 static void _SRXAFSCM_InitCallBackState(struct rxrpc_call *call)
 {
-	afs_server_t *server;
+	struct afs_server *server;
 	size_t count;
 	int ret = 0, removed;
 
-	_enter("%p{acs=%s}",call,rxrpc_call_states[call->app_call_state]);
+	_enter("%p{acs=%s}", call, rxrpc_call_states[call->app_call_state]);
 
 	server = afs_server_get_from_peer(call->conn->peer);
 
 	switch (call->app_call_state) {
-		/* we've received the last packet - drain all the data from the call */
+		/* we've received the last packet - drain all the data from the
+		 * call */
 	case RXRPC_CSTATE_SRVR_GOT_ARGS:
 		/* shouldn't be any args */
 		ret = -EBADMSG;
@@ -535,11 +545,12 @@ static void _SRXAFSCM_InitCallBackState(
 	case RXRPC_CSTATE_SRVR_SND_REPLY:
 		/* invoke the actual service routine */
 		ret = SRXAFSCM_InitCallBackState(server);
-		if (ret<0)
+		if (ret < 0)
 			break;
 
-		ret = rxrpc_call_write_data(call,0,NULL,RXRPC_LAST_PACKET,GFP_KERNEL,0,&count);
-		if (ret<0)
+		ret = rxrpc_call_write_data(call, 0, NULL, RXRPC_LAST_PACKET,
+					    GFP_KERNEL, 0, &count);
+		if (ret < 0)
 			break;
 		break;
 
@@ -567,12 +578,12 @@ static void _SRXAFSCM_InitCallBackState(
 		break;
 	}
 
-	if (ret<0)
-		rxrpc_call_abort(call,ret);
+	if (ret < 0)
+		rxrpc_call_abort(call, ret);
 
 	afs_put_server(server);
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 
 } /* end _SRXAFSCM_InitCallBackState() */
 
@@ -582,16 +593,17 @@ static void _SRXAFSCM_InitCallBackState(
  */
 static void _SRXAFSCM_Probe(struct rxrpc_call *call)
 {
-	afs_server_t *server;
+	struct afs_server *server;
 	size_t count;
 	int ret = 0, removed;
 
-	_enter("%p{acs=%s}",call,rxrpc_call_states[call->app_call_state]);
+	_enter("%p{acs=%s}", call, rxrpc_call_states[call->app_call_state]);
 
 	server = afs_server_get_from_peer(call->conn->peer);
 
 	switch (call->app_call_state) {
-		/* we've received the last packet - drain all the data from the call */
+		/* we've received the last packet - drain all the data from the
+		 * call */
 	case RXRPC_CSTATE_SRVR_GOT_ARGS:
 		/* shouldn't be any args */
 		ret = -EBADMSG;
@@ -601,11 +613,12 @@ static void _SRXAFSCM_Probe(struct rxrpc
 	case RXRPC_CSTATE_SRVR_SND_REPLY:
 		/* invoke the actual service routine */
 		ret = SRXAFSCM_Probe(server);
-		if (ret<0)
+		if (ret < 0)
 			break;
 
-		ret = rxrpc_call_write_data(call,0,NULL,RXRPC_LAST_PACKET,GFP_KERNEL,0,&count);
-		if (ret<0)
+		ret = rxrpc_call_write_data(call, 0, NULL, RXRPC_LAST_PACKET,
+					    GFP_KERNEL, 0, &count);
+		if (ret < 0)
 			break;
 		break;
 
@@ -633,11 +646,11 @@ static void _SRXAFSCM_Probe(struct rxrpc
 		break;
 	}
 
-	if (ret<0)
-		rxrpc_call_abort(call,ret);
+	if (ret < 0)
+		rxrpc_call_abort(call, ret);
 
 	afs_put_server(server);
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 
 } /* end _SRXAFSCM_Probe() */
diff -puN fs/afs/cmservice.h~linus fs/afs/cmservice.h
--- 25/fs/afs/cmservice.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/cmservice.h	2004-01-19 22:17:23.000000000 -0800
@@ -20,8 +20,10 @@ extern int afscm_start(void);
 extern void afscm_stop(void);
 
 /* cache manager server functions */
-extern int SRXAFSCM_InitCallBackState(afs_server_t *server);
-extern int SRXAFSCM_CallBack(afs_server_t *server, size_t count, afs_callback_t callbacks[]);
-extern int SRXAFSCM_Probe(afs_server_t *server);
+extern int SRXAFSCM_InitCallBackState(struct afs_server *server);
+extern int SRXAFSCM_CallBack(struct afs_server *server,
+			     size_t count,
+			     struct afs_callback callbacks[]);
+extern int SRXAFSCM_Probe(struct afs_server *server);
 
 #endif /* _LINUX_AFS_CMSERVICE_H */
diff -puN fs/afs/dir.c~linus fs/afs/dir.c
--- 25/fs/afs/dir.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/dir.c	2004-01-19 22:17:23.000000000 -0800
@@ -29,8 +29,8 @@ static int afs_dir_open(struct inode *in
 static int afs_dir_readdir(struct file *file, void *dirent, filldir_t filldir);
 static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd);
 static int afs_d_delete(struct dentry *dentry);
-static int afs_dir_lookup_filldir(void *_cookie, const char *name, int nlen, loff_t fpos,
-				     ino_t ino, unsigned dtype);
+static int afs_dir_lookup_filldir(void *_cookie, const char *name, int nlen,
+				  loff_t fpos, ino_t ino, unsigned dtype);
 
 struct file_operations afs_dir_file_operations = {
 	.open		= afs_dir_open,
@@ -61,51 +61,53 @@ static struct dentry_operations afs_fs_d
 #define AFS_DIR_DIRENT_SIZE	32
 #define AFS_DIRENT_PER_BLOCK	64
 
-typedef union afs_dirent {
+union afs_dirent {
 	struct {
-		u8	valid;
-		u8	unused[1];
-		u16	hash_next;
-		u32	vnode;
-		u32	unique;
-		u8	name[16];
-		u8	overflow[4];	/* if any char of the name (inc NUL) reaches here, consume
-					 * the next dirent too */
+		uint8_t		valid;
+		uint8_t		unused[1];
+		uint16_t	hash_next;
+		uint32_t	vnode;
+		uint32_t	unique;
+		uint8_t		name[16];
+		uint8_t		overflow[4];	/* if any char of the name (inc
+						 * NUL) reaches here, consume
+						 * the next dirent too */
 	} u;
-	u8	extended_name[32];
-} afs_dirent_t;
+	uint8_t	extended_name[32];
+};
 
 /* AFS directory page header (one at the beginning of every 2048-byte chunk) */
-typedef struct afs_dir_pagehdr {
-	u16	npages;
-	u16	magic;
+struct afs_dir_pagehdr {
+	uint16_t	npages;
+	uint16_t	magic;
 #define AFS_DIR_MAGIC htons(1234)
-	u8	nentries;
-	u8	bitmap[8];
-	u8	pad[19];
-} afs_dir_pagehdr_t;
+	uint8_t		nentries;
+	uint8_t		bitmap[8];
+	uint8_t		pad[19];
+};
 
 /* directory block layout */
-typedef union afs_dir_block {
+union afs_dir_block {
 
-	afs_dir_pagehdr_t pagehdr;
+	struct afs_dir_pagehdr pagehdr;
 
 	struct {
-		afs_dir_pagehdr_t pagehdr;
-		u8		alloc_ctrs[128];
-		u16		hashtable[AFS_DIR_HASHTBL_SIZE]; /* dir hash table */
+		struct afs_dir_pagehdr	pagehdr;
+		uint8_t			alloc_ctrs[128];
+		/* dir hash table */
+		uint16_t		hashtable[AFS_DIR_HASHTBL_SIZE];
 	} hdr;
 
-	afs_dirent_t dirents[AFS_DIRENT_PER_BLOCK];
-} afs_dir_block_t;
+	union afs_dirent dirents[AFS_DIRENT_PER_BLOCK];
+};
 
 /* layout on a linux VM page */
-typedef struct afs_dir_page {
-	afs_dir_block_t	blocks[PAGE_SIZE/sizeof(afs_dir_block_t)];
-} afs_dir_page_t;
+struct afs_dir_page {
+	union afs_dir_block blocks[PAGE_SIZE / sizeof(union afs_dir_block)];
+};
 
 struct afs_dir_lookup_cookie {
-	afs_fid_t	fid;
+	struct afs_fid	fid;
 	const char	*name;
 	size_t		nlen;
 	int		found;
@@ -117,14 +119,14 @@ struct afs_dir_lookup_cookie {
  */
 static inline void afs_dir_check_page(struct inode *dir, struct page *page)
 {
-	afs_dir_page_t *dbuf;
+	struct afs_dir_page *dbuf;
 	loff_t latter;
 	int tmp, qty;
 
 #if 0
 	/* check the page count */
-	qty = desc.size/sizeof(dbuf->blocks[0]);
-	if (qty==0)
+	qty = desc.size / sizeof(dbuf->blocks[0]);
+	if (qty == 0)
 		goto error;
 
 	if (page->index==0 && qty!=ntohs(dbuf->blocks[0].pagehdr.npages)) {
@@ -140,15 +142,15 @@ static inline void afs_dir_check_page(st
 		qty = PAGE_SIZE;
 	else
 		qty = latter;
-	qty /= sizeof(afs_dir_block_t);
+	qty /= sizeof(union afs_dir_block);
 
 	/* check them */
 	dbuf = page_address(page);
-	for (tmp=0; tmp<qty; tmp++) {
+	for (tmp = 0; tmp < qty; tmp++) {
 		if (dbuf->blocks[tmp].pagehdr.magic != AFS_DIR_MAGIC) {
 			printk("kAFS: %s(%lu): bad magic %d/%d is %04hx\n",
-			       __FUNCTION__,dir->i_ino,tmp,
-			       qty,ntohs(dbuf->blocks[tmp].pagehdr.magic));
+			       __FUNCTION__, dir->i_ino, tmp, qty,
+			       ntohs(dbuf->blocks[tmp].pagehdr.magic));
 			goto error;
 		}
 	}
@@ -181,17 +183,18 @@ static struct page *afs_dir_get_page(str
 {
 	struct page *page;
 
-	_enter("{%lu},%lu",dir->i_ino,index);
+	_enter("{%lu},%lu", dir->i_ino, index);
 
 	page = read_cache_page(dir->i_mapping,index,
-			       (filler_t*)dir->i_mapping->a_ops->readpage,NULL);
+			       (filler_t *) dir->i_mapping->a_ops->readpage,
+			       NULL);
 	if (!IS_ERR(page)) {
 		wait_on_page_locked(page);
 		kmap(page);
 		if (!PageUptodate(page))
 			goto fail;
 		if (!PageChecked(page))
-			afs_dir_check_page(dir,page);
+			afs_dir_check_page(dir, page);
 		if (PageError(page))
 			goto fail;
 	}
@@ -208,10 +211,10 @@ static struct page *afs_dir_get_page(str
  */
 static int afs_dir_open(struct inode *inode, struct file *file)
 {
-	_enter("{%lu}",inode->i_ino);
+	_enter("{%lu}", inode->i_ino);
 
-	if (sizeof(afs_dir_block_t) != 2048) BUG();
-	if (sizeof(afs_dirent_t) != 32) BUG();
+	BUG_ON(sizeof(union afs_dir_block) != 2048);
+	BUG_ON(sizeof(union afs_dirent) != 32);
 
 	if (AFS_FS_I(inode)->flags & AFS_VNODE_DELETED)
 		return -ENOENT;
@@ -226,19 +229,19 @@ static int afs_dir_open(struct inode *in
  * deal with one block in an AFS directory
  */
 static int afs_dir_iterate_block(unsigned *fpos,
-				    afs_dir_block_t *block,
-				    unsigned blkoff,
-				    void *cookie,
-				    filldir_t filldir)
+				 union afs_dir_block *block,
+				 unsigned blkoff,
+				 void *cookie,
+				 filldir_t filldir)
 {
-	afs_dirent_t *dire;
+	union afs_dirent *dire;
 	unsigned offset, next, curr;
 	size_t nlen;
 	int tmp, ret;
 
 	_enter("%u,%x,%p,,",*fpos,blkoff,block);
 
-	curr = (*fpos - blkoff) / sizeof(afs_dirent_t);
+	curr = (*fpos - blkoff) / sizeof(union afs_dirent);
 
 	/* walk through the block, an entry at a time */
 	for (offset = AFS_DIRENT_PER_BLOCK - block->pagehdr.nentries;
@@ -248,58 +251,70 @@ static int afs_dir_iterate_block(unsigne
 		next = offset + 1;
 
 		/* skip entries marked unused in the bitmap */
-		if (!(block->pagehdr.bitmap[offset/8] & (1 << (offset % 8)))) {
-			_debug("ENT[%Zu.%u]: unused\n",blkoff/sizeof(afs_dir_block_t),offset);
-			if (offset>=curr)
-				*fpos = blkoff + next * sizeof(afs_dirent_t);
+		if (!(block->pagehdr.bitmap[offset / 8] &
+		      (1 << (offset % 8)))) {
+			_debug("ENT[%Zu.%u]: unused\n",
+			       blkoff / sizeof(union afs_dir_block), offset);
+			if (offset >= curr)
+				*fpos = blkoff +
+					next * sizeof(union afs_dirent);
 			continue;
 		}
 
 		/* got a valid entry */
 		dire = &block->dirents[offset];
-		nlen = strnlen(dire->u.name,sizeof(*block) - offset*sizeof(afs_dirent_t));
+		nlen = strnlen(dire->u.name,
+			       sizeof(*block) -
+			       offset * sizeof(union afs_dirent));
 
 		_debug("ENT[%Zu.%u]: %s %Zu \"%s\"\n",
-		       blkoff/sizeof(afs_dir_block_t),offset,
-		       (offset<curr ? "skip" : "fill"),
-		       nlen,dire->u.name);
+		       blkoff / sizeof(union afs_dir_block), offset,
+		       (offset < curr ? "skip" : "fill"),
+		       nlen, dire->u.name);
 
 		/* work out where the next possible entry is */
-		for (tmp=nlen; tmp>15; tmp-=sizeof(afs_dirent_t)) {
-			if (next>=AFS_DIRENT_PER_BLOCK) {
+		for (tmp = nlen; tmp > 15; tmp -= sizeof(union afs_dirent)) {
+			if (next >= AFS_DIRENT_PER_BLOCK) {
 				_debug("ENT[%Zu.%u]:"
-				       " %u travelled beyond end dir block (len %u/%Zu)\n",
-				       blkoff/sizeof(afs_dir_block_t),offset,next,tmp,nlen);
+				       " %u travelled beyond end dir block"
+				       " (len %u/%Zu)\n",
+				       blkoff / sizeof(union afs_dir_block),
+				       offset, next, tmp, nlen);
 				return -EIO;
 			}
-			if (!(block->pagehdr.bitmap[next/8] & (1 << (next % 8)))) {
-				_debug("ENT[%Zu.%u]: %u unmarked extension (len %u/%Zu)\n",
-				       blkoff/sizeof(afs_dir_block_t),offset,next,tmp,nlen);
+			if (!(block->pagehdr.bitmap[next / 8] &
+			      (1 << (next % 8)))) {
+				_debug("ENT[%Zu.%u]:"
+				       " %u unmarked extension (len %u/%Zu)\n",
+				       blkoff / sizeof(union afs_dir_block),
+				       offset, next, tmp, nlen);
 				return -EIO;
 			}
 
 			_debug("ENT[%Zu.%u]: ext %u/%Zu\n",
-			       blkoff/sizeof(afs_dir_block_t),next,tmp,nlen);
+			       blkoff / sizeof(union afs_dir_block),
+			       next, tmp, nlen);
 			next++;
 		}
 
 		/* skip if starts before the current position */
-		if (offset<curr)
+		if (offset < curr)
 			continue;
 
 		/* found the next entry */
 		ret = filldir(cookie,
 			      dire->u.name,
 			      nlen,
-			      blkoff + offset * sizeof(afs_dirent_t),
+			      blkoff + offset * sizeof(union afs_dirent),
 			      ntohl(dire->u.vnode),
-			      filldir==afs_dir_lookup_filldir ? dire->u.unique : DT_UNKNOWN);
-		if (ret<0) {
+			      filldir == afs_dir_lookup_filldir ?
+			      dire->u.unique : DT_UNKNOWN);
+		if (ret < 0) {
 			_leave(" = 0 [full]");
 			return 0;
 		}
 
-		*fpos = blkoff + next * sizeof(afs_dirent_t);
+		*fpos = blkoff + next * sizeof(union afs_dirent);
 	}
 
 	_leave(" = 1 [more]");
@@ -310,15 +325,16 @@ static int afs_dir_iterate_block(unsigne
 /*
  * read an AFS directory
  */
-static int afs_dir_iterate(struct inode *dir, unsigned *fpos, void *cookie, filldir_t filldir)
+static int afs_dir_iterate(struct inode *dir, unsigned *fpos, void *cookie,
+			   filldir_t filldir)
 {
-	afs_dir_block_t	*dblock;
-	afs_dir_page_t *dbuf;
+	union afs_dir_block	*dblock;
+	struct afs_dir_page *dbuf;
 	struct page *page;
 	unsigned blkoff, limit;
 	int ret;
 
-	_enter("{%lu},%u,,",dir->i_ino,*fpos);
+	_enter("{%lu},%u,,", dir->i_ino, *fpos);
 
 	if (AFS_FS_I(dir)->flags & AFS_VNODE_DELETED) {
 		_leave(" = -ESTALE");
@@ -326,35 +342,37 @@ static int afs_dir_iterate(struct inode 
 	}
 
 	/* round the file position up to the next entry boundary */
-	*fpos += sizeof(afs_dirent_t) - 1;
-	*fpos &= ~(sizeof(afs_dirent_t) - 1);
+	*fpos += sizeof(union afs_dirent) - 1;
+	*fpos &= ~(sizeof(union afs_dirent) - 1);
 
 	/* walk through the blocks in sequence */
 	ret = 0;
 	while (*fpos < dir->i_size) {
-		blkoff = *fpos & ~(sizeof(afs_dir_block_t) - 1);
+		blkoff = *fpos & ~(sizeof(union afs_dir_block) - 1);
 
 		/* fetch the appropriate page from the directory */
-		page = afs_dir_get_page(dir,blkoff/PAGE_SIZE);
+		page = afs_dir_get_page(dir, blkoff / PAGE_SIZE);
 		if (IS_ERR(page)) {
 			ret = PTR_ERR(page);
 			break;
 		}
 
-		limit = blkoff & ~(PAGE_SIZE-1);
+		limit = blkoff & ~(PAGE_SIZE - 1);
 
 		dbuf = page_address(page);
 
 		/* deal with the individual blocks stashed on this page */
 		do {
-			dblock = &dbuf->blocks[(blkoff % PAGE_SIZE) / sizeof(afs_dir_block_t)];
-			ret = afs_dir_iterate_block(fpos,dblock,blkoff,cookie,filldir);
-			if (ret!=1) {
+			dblock = &dbuf->blocks[(blkoff % PAGE_SIZE) /
+					       sizeof(union afs_dir_block)];
+			ret = afs_dir_iterate_block(fpos, dblock, blkoff,
+						    cookie, filldir);
+			if (ret != 1) {
 				afs_dir_put_page(page);
 				goto out;
 			}
 
-			blkoff += sizeof(afs_dir_block_t);
+			blkoff += sizeof(union afs_dir_block);
 
 		} while (*fpos < dir->i_size && blkoff < limit);
 
@@ -363,7 +381,7 @@ static int afs_dir_iterate(struct inode 
 	}
 
  out:
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end afs_dir_iterate() */
 
@@ -376,29 +394,31 @@ static int afs_dir_readdir(struct file *
 	unsigned fpos;
 	int ret;
 
-	_enter("{%Ld,{%lu}}",file->f_pos,file->f_dentry->d_inode->i_ino);
+	_enter("{%Ld,{%lu}}", file->f_pos, file->f_dentry->d_inode->i_ino);
 
 	fpos = file->f_pos;
-	ret = afs_dir_iterate(file->f_dentry->d_inode,&fpos,cookie,filldir);
+	ret = afs_dir_iterate(file->f_dentry->d_inode, &fpos, cookie, filldir);
 	file->f_pos = fpos;
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end afs_dir_readdir() */
 
 /*****************************************************************************/
 /*
  * search the directory for a name
- * - if afs_dir_iterate_block() spots this function, it'll pass the FID uniquifier through dtype
+ * - if afs_dir_iterate_block() spots this function, it'll pass the FID
+ *   uniquifier through dtype
  */
-static int afs_dir_lookup_filldir(void *_cookie, const char *name, int nlen, loff_t fpos,
-				  ino_t ino, unsigned dtype)
+static int afs_dir_lookup_filldir(void *_cookie, const char *name, int nlen,
+				  loff_t fpos, ino_t ino, unsigned dtype)
 {
 	struct afs_dir_lookup_cookie *cookie = _cookie;
 
-	_enter("{%s,%Zu},%s,%u,,%lu,%u",cookie->name,cookie->nlen,name,nlen,ino,ntohl(dtype));
+	_enter("{%s,%Zu},%s,%u,,%lu,%u",
+	       cookie->name, cookie->nlen, name, nlen, ino, ntohl(dtype));
 
-	if (cookie->nlen != nlen || memcmp(cookie->name,name,nlen)!=0) {
+	if (cookie->nlen != nlen || memcmp(cookie->name, name, nlen) != 0) {
 		_leave(" = 0 [no]");
 		return 0;
 	}
@@ -420,16 +440,16 @@ static struct dentry *afs_dir_lookup(str
 {
 	struct afs_dir_lookup_cookie cookie;
 	struct afs_super_info *as;
+	struct afs_vnode *vnode;
 	struct inode *inode;
-	afs_vnode_t *vnode;
 	unsigned fpos;
 	int ret;
 
-	_enter("{%lu},%p{%s}",dir->i_ino,dentry,dentry->d_name.name);
+	_enter("{%lu},%p{%s}", dir->i_ino, dentry, dentry->d_name.name);
 
 	/* insanity checks first */
-	BUG_ON(sizeof(afs_dir_block_t) != 2048);
-	BUG_ON(sizeof(afs_dirent_t) != 32);
+	BUG_ON(sizeof(union afs_dir_block) != 2048);
+	BUG_ON(sizeof(union afs_dirent) != 32);
 
 	if (dentry->d_name.len > 255) {
 		_leave(" = -ENAMETOOLONG");
@@ -451,29 +471,29 @@ static struct dentry *afs_dir_lookup(str
 	cookie.found	= 0;
 
 	fpos = 0;
-	ret = afs_dir_iterate(dir,&fpos,&cookie,afs_dir_lookup_filldir);
-	if (ret<0) {
-		_leave(" = %d",ret);
+	ret = afs_dir_iterate(dir, &fpos, &cookie, afs_dir_lookup_filldir);
+	if (ret < 0) {
+		_leave(" = %d", ret);
 		return ERR_PTR(ret);
 	}
 
 	ret = -ENOENT;
 	if (!cookie.found) {
-		_leave(" = %d",ret);
+		_leave(" = %d", ret);
 		return ERR_PTR(ret);
 	}
 
 	/* instantiate the dentry */
-	ret = afs_iget(dir->i_sb,&cookie.fid,&inode);
-	if (ret<0) {
-		_leave(" = %d",ret);
+	ret = afs_iget(dir->i_sb, &cookie.fid, &inode);
+	if (ret < 0) {
+		_leave(" = %d", ret);
 		return ERR_PTR(ret);
 	}
 
 	dentry->d_op = &afs_fs_dentry_operations;
-	dentry->d_fsdata = (void*) (unsigned long) vnode->status.version;
+	dentry->d_fsdata = (void *) (unsigned long) vnode->status.version;
 
-	d_add(dentry,inode);
+	d_add(dentry, inode);
 	_leave(" = 0 { vn=%u u=%u } -> { ino=%lu v=%lu }",
 	       cookie.fid.vnode,
 	       cookie.fid.unique,
@@ -486,7 +506,8 @@ static struct dentry *afs_dir_lookup(str
 /*****************************************************************************/
 /*
  * check that a dentry lookup hit has found a valid entry
- * - NOTE! the hit can be a negative hit too, so we can't assume we have an inode
+ * - NOTE! the hit can be a negative hit too, so we can't assume we have an
+ *   inode
  * (derived from nfs_lookup_revalidate)
  */
 static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
@@ -497,7 +518,7 @@ static int afs_d_revalidate(struct dentr
 	unsigned fpos;
 	int ret;
 
-	_enter("{sb=%p n=%s},",dentry->d_sb,dentry->d_name.name);
+	_enter("{sb=%p n=%s},", dentry->d_sb, dentry->d_name.name);
 
 	/* lock down the parent dentry so we can peer at it */
 	parent = dget_parent(dentry->d_parent);
@@ -505,39 +526,41 @@ static int afs_d_revalidate(struct dentr
 	dir = parent->d_inode;
 	inode = dentry->d_inode;
 
-	/* handle a negative inode */
+	/* handle a negative dentry */
 	if (!inode)
 		goto out_bad;
 
 	/* handle a bad inode */
 	if (is_bad_inode(inode)) {
 		printk("kAFS: afs_d_revalidate: %s/%s has bad inode\n",
-		       dentry->d_parent->d_name.name,dentry->d_name.name);
+		       dentry->d_parent->d_name.name, dentry->d_name.name);
 		goto out_bad;
 	}
 
-	/* force a full look up if the parent directory changed since last the server was consulted
-	 * - otherwise this inode must still exist, even if the inode details themselves have
-	 *   changed
+	/* force a full look up if the parent directory changed since last the
+	 * server was consulted
+	 * - otherwise this inode must still exist, even if the inode details
+	 *   themselves have changed
 	 */
 	if (AFS_FS_I(dir)->flags & AFS_VNODE_CHANGED)
 		afs_vnode_fetch_status(AFS_FS_I(dir));
 
 	if (AFS_FS_I(dir)->flags & AFS_VNODE_DELETED) {
-		_debug("%s: parent dir deleted",dentry->d_name.name);
+		_debug("%s: parent dir deleted", dentry->d_name.name);
 		goto out_bad;
 	}
 
 	if (AFS_FS_I(inode)->flags & AFS_VNODE_DELETED) {
-		_debug("%s: file already deleted",dentry->d_name.name);
+		_debug("%s: file already deleted", dentry->d_name.name);
 		goto out_bad;
 	}
 
-	if ((unsigned long)dentry->d_fsdata != (unsigned long)AFS_FS_I(dir)->status.version) {
+	if ((unsigned long) dentry->d_fsdata !=
+	    (unsigned long) AFS_FS_I(dir)->status.version) {
 		_debug("%s: parent changed %lu -> %u",
 		       dentry->d_name.name,
-		       (unsigned long)dentry->d_fsdata,
-		       (unsigned)AFS_FS_I(dir)->status.version);
+		       (unsigned long) dentry->d_fsdata,
+		       (unsigned) AFS_FS_I(dir)->status.version);
 
 		/* search the directory for this vnode */
 		cookie.name	= dentry->d_name.name;
@@ -546,25 +569,29 @@ static int afs_d_revalidate(struct dentr
 		cookie.found	= 0;
 
 		fpos = 0;
-		ret = afs_dir_iterate(dir,&fpos,&cookie,afs_dir_lookup_filldir);
-		if (ret<0) {
-			_debug("failed to iterate dir %s: %d",parent->d_name.name,ret);
+		ret = afs_dir_iterate(dir, &fpos, &cookie,
+				      afs_dir_lookup_filldir);
+		if (ret < 0) {
+			_debug("failed to iterate dir %s: %d",
+			       parent->d_name.name, ret);
 			goto out_bad;
 		}
 
 		if (!cookie.found) {
-			_debug("%s: dirent not found",dentry->d_name.name);
+			_debug("%s: dirent not found", dentry->d_name.name);
 			goto not_found;
 		}
 
-		/* if the vnode ID has changed, then the dirent points to a different file */
-		if (cookie.fid.vnode!=AFS_FS_I(inode)->fid.vnode) {
-			_debug("%s: dirent changed",dentry->d_name.name);
+		/* if the vnode ID has changed, then the dirent points to a
+		 * different file */
+		if (cookie.fid.vnode != AFS_FS_I(inode)->fid.vnode) {
+			_debug("%s: dirent changed", dentry->d_name.name);
 			goto not_found;
 		}
 
-		/* if the vnode ID uniqifier has changed, then the file has been deleted */
-		if (cookie.fid.unique!=AFS_FS_I(inode)->fid.unique) {
+		/* if the vnode ID uniqifier has changed, then the file has
+		 * been deleted */
+		if (cookie.fid.unique != AFS_FS_I(inode)->fid.unique) {
 			_debug("%s: file deleted (uq %u -> %u I:%lu)",
 			       dentry->d_name.name,
 			       cookie.fid.unique,
@@ -577,7 +604,8 @@ static int afs_d_revalidate(struct dentr
 			goto out_bad;
 		}
 
-		dentry->d_fsdata = (void*) (unsigned long) AFS_FS_I(dir)->status.version;
+		dentry->d_fsdata =
+			(void *) (unsigned long) AFS_FS_I(dir)->status.version;
 	}
 
  out_valid:
@@ -598,7 +626,8 @@ static int afs_d_revalidate(struct dentr
 
 	shrink_dcache_parent(dentry);
 
-	_debug("dropping dentry %s/%s",dentry->d_parent->d_name.name,dentry->d_name.name);
+	_debug("dropping dentry %s/%s",
+	       dentry->d_parent->d_name.name, dentry->d_name.name);
 	d_drop(dentry);
 
 	dput(parent);
@@ -609,13 +638,14 @@ static int afs_d_revalidate(struct dentr
 
 /*****************************************************************************/
 /*
- * allow the VFS to enquire as to whether a dentry should be unhashed (mustn't sleep)
+ * allow the VFS to enquire as to whether a dentry should be unhashed (mustn't
+ * sleep)
  * - called from dput() when d_count is going to 0.
  * - return 1 to request dentry be unhashed, 0 otherwise
  */
 static int afs_d_delete(struct dentry *dentry)
 {
-	_enter("%s",dentry->d_name.name);
+	_enter("%s", dentry->d_name.name);
 
 	if (dentry->d_flags & DCACHE_NFSFS_RENAMED)
 		goto zap;
diff -puN fs/afs/file.c~linus fs/afs/file.c
--- 25/fs/afs/file.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/file.c	2004-01-19 22:17:23.000000000 -0800
@@ -31,7 +31,8 @@ static int afs_file_readpage(struct file
 static int afs_file_invalidatepage(struct page *page, unsigned long offset);
 static int afs_file_releasepage(struct page *page, int gfp_flags);
 
-static ssize_t afs_file_write(struct file *file, const char *buf, size_t size, loff_t *off);
+static ssize_t afs_file_write(struct file *file, const char *buf, size_t size,
+			      loff_t *off);
 
 struct inode_operations afs_file_inode_operations = {
 	.getattr	= afs_inode_getattr,
@@ -60,9 +61,10 @@ struct address_space_operations afs_fs_a
 /*
  * AFS file write
  */
-static ssize_t afs_file_write(struct file *file, const char *buf, size_t size, loff_t *off)
+static ssize_t afs_file_write(struct file *file, const char *buf, size_t size,
+			      loff_t *off)
 {
-	afs_vnode_t *vnode;
+	struct afs_vnode *vnode;
 
 	vnode = AFS_FS_I(file->f_dentry->d_inode);
 	if (vnode->flags & AFS_VNODE_DELETED)
@@ -76,10 +78,12 @@ static ssize_t afs_file_write(struct fil
  * deal with notification that a page was read from the cache
  */
 #ifdef AFS_CACHING_SUPPORT
-static void afs_file_readpage_read_complete(void *cookie_data, struct page *page, void *data,
+static void afs_file_readpage_read_complete(void *cookie_data,
+					    struct page *page,
+					    void *data,
 					    int error)
 {
-	_enter("%p,%p,%p,%d",cookie_data,page,data,error);
+	_enter("%p,%p,%p,%d", cookie_data, page, data, error);
 
 	if (error)
 		SetPageError(page);
@@ -95,10 +99,12 @@ static void afs_file_readpage_read_compl
  * deal with notification that a page was written to the cache
  */
 #ifdef AFS_CACHING_SUPPORT
-static void afs_file_readpage_write_complete(void *cookie_data, struct page *page, void *data,
+static void afs_file_readpage_write_complete(void *cookie_data,
+					     struct page *page,
+					     void *data,
 					     int error)
 {
-	_enter("%p,%p,%p,%d",cookie_data,page,data,error);
+	_enter("%p,%p,%p,%d", cookie_data, page, data, error);
 
 	unlock_page(page);
 
@@ -115,13 +121,13 @@ static int afs_file_readpage(struct file
 #ifdef AFS_CACHING_SUPPORT
 	struct cachefs_page *pageio;
 #endif
+	struct afs_vnode *vnode;
 	struct inode *inode;
-	afs_vnode_t *vnode;
 	int ret;
 
 	inode = page->mapping->host;
 
-	_enter("{%lu},{%lu}",inode->i_ino,page->index);
+	_enter("{%lu},{%lu}", inode->i_ino, page->index);
 
 	vnode = AFS_FS_I(inode);
 
@@ -133,8 +139,8 @@ static int afs_file_readpage(struct file
 		goto error;
 
 #ifdef AFS_CACHING_SUPPORT
-	ret = cachefs_page_get_private(page,&pageio,GFP_NOIO);
-	if (ret<0)
+	ret = cachefs_page_get_private(page, &pageio, GFP_NOIO);
+	if (ret < 0)
 		goto error;
 
 	/* is it cached? */
@@ -162,23 +168,26 @@ static int afs_file_readpage(struct file
 	default:
 		desc.fid	= vnode->fid;
 		desc.offset	= page->index << PAGE_CACHE_SHIFT;
-		desc.size	= min((size_t)(inode->i_size - desc.offset),(size_t)PAGE_SIZE);
+		desc.size	= min((size_t) (inode->i_size - desc.offset),
+				      (size_t) PAGE_SIZE);
 		desc.buffer	= kmap(page);
 
 		clear_page(desc.buffer);
 
-		/* read the contents of the file from the server into the page */
-		ret = afs_vnode_fetch_data(vnode,&desc);
+		/* read the contents of the file from the server into the
+		 * page */
+		ret = afs_vnode_fetch_data(vnode, &desc);
 		kunmap(page);
-		if (ret<0) {
+		if (ret < 0) {
 			if (ret==-ENOENT) {
-				_debug("got NOENT from server - marking file deleted and stale");
+				_debug("got NOENT from server"
+				       " - marking file deleted and stale");
 				vnode->flags |= AFS_VNODE_DELETED;
 				ret = -ESTALE;
 			}
 
 #ifdef AFS_CACHING_SUPPORT
-			cachefs_uncache_page(vnode->cache,page);
+			cachefs_uncache_page(vnode->cache, page);
 #endif
 			goto error;
 		}
@@ -192,7 +201,7 @@ static int afs_file_readpage(struct file
 				       NULL,
 				       GFP_KERNEL) != 0
 		    ) {
-			cachefs_uncache_page(vnode->cache,page);
+			cachefs_uncache_page(vnode->cache, page);
 			unlock_page(page);
 		}
 #else
@@ -207,7 +216,7 @@ static int afs_file_readpage(struct file
 	SetPageError(page);
 	unlock_page(page);
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 
 } /* end afs_file_readpage() */
@@ -217,14 +226,15 @@ static int afs_file_readpage(struct file
  * get a page cookie for the specified page
  */
 #ifdef AFS_CACHING_SUPPORT
-int afs_cache_get_page_cookie(struct page *page, struct cachefs_page **_page_cookie)
+int afs_cache_get_page_cookie(struct page *page,
+			      struct cachefs_page **_page_cookie)
 {
 	int ret;
 
 	_enter("");
-	ret = cachefs_page_get_private(page,_page_cookie,GFP_NOIO);
+	ret = cachefs_page_get_private(page,_page_cookie, GFP_NOIO);
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end afs_cache_get_page_cookie() */
 #endif
@@ -237,30 +247,32 @@ static int afs_file_invalidatepage(struc
 {
 	int ret = 1;
 
-	_enter("{%lu},%lu",page->index,offset);
+	_enter("{%lu},%lu", page->index, offset);
 
 	BUG_ON(!PageLocked(page));
+
 	if (PagePrivate(page)) {
 #ifdef AFS_CACHING_SUPPORT
 		struct afs_vnode *vnode = AFS_FS_I(page->mapping->host);
 		cachefs_uncache_page(vnode->cache,page);
 #endif
 
-		/*
-		 * We release buffers only if the entire page is being invalidated.
-		 * The get_block cached value has been unconditionally invalidated,
-		 * so real IO is not possible anymore.
+		/* We release buffers only if the entire page is being
+		 * invalidated.
+		 * The get_block cached value has been unconditionally
+		 * invalidated, so real IO is not possible anymore.
 		 */
 		if (offset == 0) {
 			BUG_ON(!PageLocked(page));
 
 			ret = 0;
 			if (!PageWriteback(page))
-				ret = page->mapping->a_ops->releasepage(page, 0);
+				ret = page->mapping->a_ops->releasepage(page,
+									0);
 		}
 	}
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end afs_file_invalidatepage() */
 
@@ -272,12 +284,12 @@ static int afs_file_releasepage(struct p
 {
 	struct cachefs_page *pageio;
 
-	_enter("{%lu},%x",page->index,gfp_flags);
+	_enter("{%lu},%x", page->index, gfp_flags);
 
 	if (PagePrivate(page)) {
 #ifdef AFS_CACHING_SUPPORT
 		struct afs_vnode *vnode = AFS_FS_I(page->mapping->host);
-		cachefs_uncache_page(vnode->cache,page);
+		cachefs_uncache_page(vnode->cache, page);
 #endif
 
 		pageio = (struct cachefs_page *) page->private;
diff -puN fs/afs/fsclient.c~linus fs/afs/fsclient.c
--- 25/fs/afs/fsclient.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/fsclient.c	2004-01-19 22:17:23.000000000 -0800
@@ -24,7 +24,7 @@
 
 #define FSFETCHSTATUS		132	/* AFS Fetch file status */
 #define FSFETCHDATA		130	/* AFS Fetch file data */
-#define FSGIVEUPCALLBACKS	147	/* AFS Discard server callback promises */
+#define FSGIVEUPCALLBACKS	147	/* AFS Discard callback promises */
 #define FSGETVOLUMEINFO		148	/* AFS Get root volume information */
 #define FSGETROOTVOLUME		151	/* AFS Get root volume name */
 #define FSLOOKUP		161	/* AFS lookup file in directory */
@@ -54,10 +54,9 @@ static void afs_rxfs_aemap(struct rxrpc_
  * - this operation doesn't seem to work correctly in OpenAFS server 1.2.2
  */
 #if 0
-int afs_rxfs_get_root_volume(afs_server_t *server, char *buf, size_t *buflen)
+int afs_rxfs_get_root_volume(struct afs_server *server,
+			     char *buf, size_t *buflen)
 {
-	DECLARE_WAITQUEUE(myself,current);
-
 	struct rxrpc_connection *conn;
 	struct rxrpc_call *call;
 	struct iovec piov[2];
@@ -65,23 +64,25 @@ int afs_rxfs_get_root_volume(afs_server_
 	int ret;
 	u32 param[1];
 
-	kenter("%p,%p,%u",server,buf,*buflen);
+	DECLARE_WAITQUEUE(myself, current);
+
+	kenter("%p,%p,%u",server, buf, *buflen);
 
 	/* get hold of the fileserver connection */
-	ret = afs_server_get_fsconn(server,&conn);
-	if (ret<0)
+	ret = afs_server_get_fsconn(server, &conn);
+	if (ret < 0)
 		goto out;
 
 	/* create a call through that connection */
-	ret = rxrpc_create_call(conn,NULL,NULL,afs_rxfs_aemap,&call);
-	if (ret<0) {
-		printk("kAFS: Unable to create call: %d\n",ret);
+	ret = rxrpc_create_call(conn, NULL, NULL, afs_rxfs_aemap, &call);
+	if (ret < 0) {
+		printk("kAFS: Unable to create call: %d\n", ret);
 		goto out_put_conn;
 	}
 	call->app_opcode = FSGETROOTVOLUME;
 
 	/* we want to get event notifications from the call */
-	add_wait_queue(&call->waitq,&myself);
+	add_wait_queue(&call->waitq, &myself);
 
 	/* marshall the parameters */
 	param[0] = htonl(FSGETROOTVOLUME);
@@ -90,14 +91,15 @@ int afs_rxfs_get_root_volume(afs_server_
 	piov[0].iov_base = param;
 
 	/* send the parameters to the server */
-	ret = rxrpc_call_write_data(call,1,piov,RXRPC_LAST_PACKET,GFP_NOFS,0,&sent);
-	if (ret<0)
+	ret = rxrpc_call_write_data(call, 1, piov, RXRPC_LAST_PACKET, GFP_NOFS,
+				    0, &sent);
+	if (ret < 0)
 		goto abort;
 
 	/* wait for the reply to completely arrive */
 	for (;;) {
 		set_current_state(TASK_INTERRUPTIBLE);
-		if (call->app_call_state!=RXRPC_CSTATE_CLNT_RCV_REPLY ||
+		if (call->app_call_state != RXRPC_CSTATE_CLNT_RCV_REPLY ||
 		    signal_pending(current))
 			break;
 		schedule();
@@ -111,41 +113,41 @@ int afs_rxfs_get_root_volume(afs_server_
 	switch (call->app_call_state) {
 	case RXRPC_CSTATE_ERROR:
 		ret = call->app_errno;
-		kdebug("Got Error: %d",ret);
+		kdebug("Got Error: %d", ret);
 		goto out_unwait;
 
 	case RXRPC_CSTATE_CLNT_GOT_REPLY:
 		/* read the reply */
-		kdebug("Got Reply: qty=%d",call->app_ready_qty);
+		kdebug("Got Reply: qty=%d", call->app_ready_qty);
 
 		ret = -EBADMSG;
 		if (call->app_ready_qty <= 4)
 			goto abort;
 
-		ret = rxrpc_call_read_data(call,NULL,call->app_ready_qty,0);
-		if (ret<0)
+		ret = rxrpc_call_read_data(call, NULL, call->app_ready_qty, 0);
+		if (ret < 0)
 			goto abort;
 
 #if 0
 		/* unmarshall the reply */
 		bp = buffer;
-		for (loop=0; loop<65; loop++)
+		for (loop = 0; loop < 65; loop++)
 			entry->name[loop] = ntohl(*bp++);
 		entry->name[64] = 0;
 
 		entry->type = ntohl(*bp++);
 		entry->num_servers = ntohl(*bp++);
 
-		for (loop=0; loop<8; loop++)
+		for (loop = 0; loop < 8; loop++)
 			entry->servers[loop].addr.s_addr = *bp++;
 
-		for (loop=0; loop<8; loop++)
+		for (loop = 0; loop < 8; loop++)
 			entry->servers[loop].partition = ntohl(*bp++);
 
-		for (loop=0; loop<8; loop++)
+		for (loop = 0; loop < 8; loop++)
 			entry->servers[loop].flags = ntohl(*bp++);
 
-		for (loop=0; loop<3; loop++)
+		for (loop = 0; loop < 3; loop++)
 			entry->volume_ids[loop] = ntohl(*bp++);
 
 		entry->clone_id = ntohl(*bp++);
@@ -162,14 +164,14 @@ int afs_rxfs_get_root_volume(afs_server_
 
  abort:
 	set_current_state(TASK_UNINTERRUPTIBLE);
-	rxrpc_call_abort(call,ret);
+	rxrpc_call_abort(call, ret);
 	schedule();
  out_unwait:
 	set_current_state(TASK_RUNNING);
-	remove_wait_queue(&call->waitq,&myself);
+	remove_wait_queue(&call->waitq, &myself);
 	rxrpc_put_call(call);
  out_put_conn:
-	afs_server_release_fsconn(server,conn);
+	afs_server_release_fsconn(server, conn);
  out:
 	kleave("");
 	return ret;
@@ -181,12 +183,10 @@ int afs_rxfs_get_root_volume(afs_server_
  * get information about a volume
  */
 #if 0
-int afs_rxfs_get_volume_info(afs_server_t *server,
+int afs_rxfs_get_volume_info(struct afs_server *server,
 			     const char *name,
-			     afs_volume_info_t *vinfo)
+			     struct afs_volume_info *vinfo)
 {
-	DECLARE_WAITQUEUE(myself,current);
-
 	struct rxrpc_connection *conn;
 	struct rxrpc_call *call;
 	struct iovec piov[3];
@@ -194,27 +194,29 @@ int afs_rxfs_get_volume_info(afs_server_
 	int ret;
 	u32 param[2], *bp, zero;
 
-	_enter("%p,%s,%p",server,name,vinfo);
+	DECLARE_WAITQUEUE(myself, current);
+
+	_enter("%p,%s,%p", server, name, vinfo);
 
 	/* get hold of the fileserver connection */
-	ret = afs_server_get_fsconn(server,&conn);
-	if (ret<0)
+	ret = afs_server_get_fsconn(server, &conn);
+	if (ret < 0)
 		goto out;
 
 	/* create a call through that connection */
-	ret = rxrpc_create_call(conn,NULL,NULL,afs_rxfs_aemap,&call);
-	if (ret<0) {
-		printk("kAFS: Unable to create call: %d\n",ret);
+	ret = rxrpc_create_call(conn, NULL, NULL, afs_rxfs_aemap, &call);
+	if (ret < 0) {
+		printk("kAFS: Unable to create call: %d\n", ret);
 		goto out_put_conn;
 	}
 	call->app_opcode = FSGETVOLUMEINFO;
 
 	/* we want to get event notifications from the call */
-	add_wait_queue(&call->waitq,&myself);
+	add_wait_queue(&call->waitq, &myself);
 
 	/* marshall the parameters */
 	piov[1].iov_len = strlen(name);
-	piov[1].iov_base = (char*)name;
+	piov[1].iov_base = (char *) name;
 
 	zero = 0;
 	piov[2].iov_len = (4 - (piov[1].iov_len & 3)) & 3;
@@ -227,16 +229,19 @@ int afs_rxfs_get_volume_info(afs_server_
 	piov[0].iov_base = param;
 
 	/* send the parameters to the server */
-	ret = rxrpc_call_write_data(call,3,piov,RXRPC_LAST_PACKET,GFP_NOFS,0,&sent);
-	if (ret<0)
+	ret = rxrpc_call_write_data(call, 3, piov, RXRPC_LAST_PACKET, GFP_NOFS,
+				    0, &sent);
+	if (ret < 0)
 		goto abort;
 
 	/* wait for the reply to completely arrive */
-	bp = rxrpc_call_alloc_scratch(call,64);
+	bp = rxrpc_call_alloc_scratch(call, 64);
 
-	ret = rxrpc_call_read_data(call,bp,64,RXRPC_CALL_READ_BLOCK|RXRPC_CALL_READ_ALL);
-	if (ret<0) {
-		if (ret==-ECONNABORTED) {
+	ret = rxrpc_call_read_data(call, bp, 64,
+				   RXRPC_CALL_READ_BLOCK |
+				   RXRPC_CALL_READ_ALL);
+	if (ret < 0) {
+		if (ret == -ECONNABORTED) {
 			ret = call->app_errno;
 			goto out_unwait;
 		}
@@ -264,7 +269,7 @@ int afs_rxfs_get_volume_info(afs_server_
 	vinfo->servers[7].addr.s_addr = *bp++;
 
 	ret = -EBADMSG;
-	if (vinfo->nservers>8)
+	if (vinfo->nservers > 8)
 		goto abort;
 
 	/* success */
@@ -272,17 +277,17 @@ int afs_rxfs_get_volume_info(afs_server_
 
  out_unwait:
 	set_current_state(TASK_RUNNING);
-	remove_wait_queue(&call->waitq,&myself);
+	remove_wait_queue(&call->waitq, &myself);
 	rxrpc_put_call(call);
  out_put_conn:
-	afs_server_release_fsconn(server,conn);
+	afs_server_release_fsconn(server, conn);
  out:
 	_leave("");
 	return ret;
 
  abort:
 	set_current_state(TASK_UNINTERRUPTIBLE);
-	rxrpc_call_abort(call,ret);
+	rxrpc_call_abort(call, ret);
 	schedule();
 	goto out_unwait;
 
@@ -293,12 +298,10 @@ int afs_rxfs_get_volume_info(afs_server_
 /*
  * fetch the status information for a file
  */
-int afs_rxfs_fetch_file_status(afs_server_t *server,
-			       afs_vnode_t *vnode,
-			       afs_volsync_t *volsync)
+int afs_rxfs_fetch_file_status(struct afs_server *server,
+			       struct afs_vnode *vnode,
+			       struct afs_volsync *volsync)
 {
-	DECLARE_WAITQUEUE(myself,current);
-
 	struct afs_server_callslot callslot;
 	struct rxrpc_call *call;
 	struct iovec piov[1];
@@ -306,26 +309,30 @@ int afs_rxfs_fetch_file_status(afs_serve
 	int ret;
 	u32 *bp;
 
-	_enter("%p,{%u,%u,%u}",server,vnode->fid.vid,vnode->fid.vnode,vnode->fid.unique);
+	DECLARE_WAITQUEUE(myself, current);
+
+	_enter("%p,{%u,%u,%u}",
+	       server, vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique);
 
 	/* get hold of the fileserver connection */
-	ret = afs_server_request_callslot(server,&callslot);
-	if (ret<0)
+	ret = afs_server_request_callslot(server, &callslot);
+	if (ret < 0)
 		goto out;
 
 	/* create a call through that connection */
-	ret = rxrpc_create_call(callslot.conn,NULL,NULL,afs_rxfs_aemap,&call);
-	if (ret<0) {
-		printk("kAFS: Unable to create call: %d\n",ret);
+	ret = rxrpc_create_call(callslot.conn, NULL, NULL, afs_rxfs_aemap,
+				&call);
+	if (ret < 0) {
+		printk("kAFS: Unable to create call: %d\n", ret);
 		goto out_put_conn;
 	}
 	call->app_opcode = FSFETCHSTATUS;
 
 	/* we want to get event notifications from the call */
-	add_wait_queue(&call->waitq,&myself);
+	add_wait_queue(&call->waitq, &myself);
 
 	/* marshall the parameters */
-	bp = rxrpc_call_alloc_scratch(call,16);
+	bp = rxrpc_call_alloc_scratch(call, 16);
 	bp[0] = htonl(FSFETCHSTATUS);
 	bp[1] = htonl(vnode->fid.vid);
 	bp[2] = htonl(vnode->fid.vnode);
@@ -335,16 +342,19 @@ int afs_rxfs_fetch_file_status(afs_serve
 	piov[0].iov_base = bp;
 
 	/* send the parameters to the server */
-	ret = rxrpc_call_write_data(call,1,piov,RXRPC_LAST_PACKET,GFP_NOFS,0,&sent);
-	if (ret<0)
+	ret = rxrpc_call_write_data(call, 1, piov, RXRPC_LAST_PACKET, GFP_NOFS,
+				    0, &sent);
+	if (ret < 0)
 		goto abort;
 
 	/* wait for the reply to completely arrive */
-	bp = rxrpc_call_alloc_scratch(call,120);
+	bp = rxrpc_call_alloc_scratch(call, 120);
 
-	ret = rxrpc_call_read_data(call,bp,120,RXRPC_CALL_READ_BLOCK|RXRPC_CALL_READ_ALL);
-	if (ret<0) {
-		if (ret==-ECONNABORTED) {
+	ret = rxrpc_call_read_data(call, bp, 120,
+				   RXRPC_CALL_READ_BLOCK |
+				   RXRPC_CALL_READ_ALL);
+	if (ret < 0) {
+		if (ret == -ECONNABORTED) {
 			ret = call->app_errno;
 			goto out_unwait;
 		}
@@ -370,7 +380,7 @@ int afs_rxfs_fetch_file_status(afs_serve
 	vnode->status.mtime_server	= ntohl(*bp++);
 	bp++; /* group */
 	bp++; /* sync counter */
-	vnode->status.version		|= ((unsigned long long) ntohl(*bp++)) << 32;
+	vnode->status.version |= ((unsigned long long) ntohl(*bp++)) << 32;
 	bp++; /* spare2 */
 	bp++; /* spare3 */
 	bp++; /* spare4 */
@@ -393,17 +403,17 @@ int afs_rxfs_fetch_file_status(afs_serve
 
  out_unwait:
 	set_current_state(TASK_RUNNING);
-	remove_wait_queue(&call->waitq,&myself);
+	remove_wait_queue(&call->waitq, &myself);
 	rxrpc_put_call(call);
  out_put_conn:
-	afs_server_release_callslot(server,&callslot);
+	afs_server_release_callslot(server, &callslot);
  out:
 	_leave("");
 	return ret;
 
  abort:
 	set_current_state(TASK_UNINTERRUPTIBLE);
-	rxrpc_call_abort(call,ret);
+	rxrpc_call_abort(call, ret);
 	schedule();
 	goto out_unwait;
 } /* end afs_rxfs_fetch_file_status() */
@@ -412,13 +422,11 @@ int afs_rxfs_fetch_file_status(afs_serve
 /*
  * fetch the contents of a file or directory
  */
-int afs_rxfs_fetch_file_data(afs_server_t *server,
-			     afs_vnode_t *vnode,
+int afs_rxfs_fetch_file_data(struct afs_server *server,
+			     struct afs_vnode *vnode,
 			     struct afs_rxfs_fetch_descriptor *desc,
-			     afs_volsync_t *volsync)
+			     struct afs_volsync *volsync)
 {
-	DECLARE_WAITQUEUE(myself,current);
-
 	struct afs_server_callslot callslot;
 	struct rxrpc_call *call;
 	struct iovec piov[1];
@@ -426,6 +434,8 @@ int afs_rxfs_fetch_file_data(afs_server_
 	int ret;
 	u32 *bp;
 
+	DECLARE_WAITQUEUE(myself, current);
+
 	_enter("%p,{fid={%u,%u,%u},sz=%Zu,of=%lu}",
 	       server,
 	       desc->fid.vid,
@@ -435,23 +445,23 @@ int afs_rxfs_fetch_file_data(afs_server_
 	       desc->offset);
 
 	/* get hold of the fileserver connection */
-	ret = afs_server_request_callslot(server,&callslot);
-	if (ret<0)
+	ret = afs_server_request_callslot(server, &callslot);
+	if (ret < 0)
 		goto out;
 
 	/* create a call through that connection */
-	ret = rxrpc_create_call(callslot.conn,NULL,NULL,afs_rxfs_aemap,&call);
-	if (ret<0) {
-		printk("kAFS: Unable to create call: %d\n",ret);
+	ret = rxrpc_create_call(callslot.conn, NULL, NULL, afs_rxfs_aemap, &call);
+	if (ret < 0) {
+		printk("kAFS: Unable to create call: %d\n", ret);
 		goto out_put_conn;
 	}
 	call->app_opcode = FSFETCHDATA;
 
 	/* we want to get event notifications from the call */
-	add_wait_queue(&call->waitq,&myself);
+	add_wait_queue(&call->waitq, &myself);
 
 	/* marshall the parameters */
-	bp = rxrpc_call_alloc_scratch(call,24);
+	bp = rxrpc_call_alloc_scratch(call, 24);
 	bp[0] = htonl(FSFETCHDATA);
 	bp[1] = htonl(desc->fid.vid);
 	bp[2] = htonl(desc->fid.vnode);
@@ -463,17 +473,18 @@ int afs_rxfs_fetch_file_data(afs_server_
 	piov[0].iov_base = bp;
 
 	/* send the parameters to the server */
-	ret = rxrpc_call_write_data(call,1,piov,RXRPC_LAST_PACKET,GFP_NOFS,0,&sent);
-	if (ret<0)
+	ret = rxrpc_call_write_data(call, 1, piov, RXRPC_LAST_PACKET, GFP_NOFS,
+				    0, &sent);
+	if (ret < 0)
 		goto abort;
 
 	/* wait for the data count to arrive */
-	ret = rxrpc_call_read_data(call,bp,4,RXRPC_CALL_READ_BLOCK);
-	if (ret<0)
+	ret = rxrpc_call_read_data(call, bp, 4, RXRPC_CALL_READ_BLOCK);
+	if (ret < 0)
 		goto read_failed;
 
 	desc->actual = ntohl(bp[0]);
-	if (desc->actual!=desc->size) {
+	if (desc->actual != desc->size) {
 		ret = -EBADMSG;
 		goto abort;
 	}
@@ -481,16 +492,19 @@ int afs_rxfs_fetch_file_data(afs_server_
 	/* call the app to read the actual data */
 	rxrpc_call_reset_scratch(call);
 
-	ret = rxrpc_call_read_data(call,desc->buffer,desc->actual,RXRPC_CALL_READ_BLOCK);
-	if (ret<0)
+	ret = rxrpc_call_read_data(call, desc->buffer, desc->actual,
+				   RXRPC_CALL_READ_BLOCK);
+	if (ret < 0)
 		goto read_failed;
 
 	/* wait for the rest of the reply to completely arrive */
 	rxrpc_call_reset_scratch(call);
-	bp = rxrpc_call_alloc_scratch(call,120);
+	bp = rxrpc_call_alloc_scratch(call, 120);
 
-	ret = rxrpc_call_read_data(call,bp,120,RXRPC_CALL_READ_BLOCK|RXRPC_CALL_READ_ALL);
-	if (ret<0)
+	ret = rxrpc_call_read_data(call, bp, 120,
+				   RXRPC_CALL_READ_BLOCK |
+				   RXRPC_CALL_READ_ALL);
+	if (ret < 0)
 		goto read_failed;
 
 	/* unmarshall the reply */
@@ -512,7 +526,7 @@ int afs_rxfs_fetch_file_data(afs_server_
 	vnode->status.mtime_server	= ntohl(*bp++);
 	bp++; /* group */
 	bp++; /* sync counter */
-	vnode->status.version		|= ((unsigned long long) ntohl(*bp++)) << 32;
+	vnode->status.version |= ((unsigned long long) ntohl(*bp++)) << 32;
 	bp++; /* spare2 */
 	bp++; /* spare3 */
 	bp++; /* spare4 */
@@ -538,20 +552,20 @@ int afs_rxfs_fetch_file_data(afs_server_
 	remove_wait_queue(&call->waitq,&myself);
 	rxrpc_put_call(call);
  out_put_conn:
-	afs_server_release_callslot(server,&callslot);
+	afs_server_release_callslot(server, &callslot);
  out:
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 
  read_failed:
-	if (ret==-ECONNABORTED) {
+	if (ret == -ECONNABORTED) {
 		ret = call->app_errno;
 		goto out_unwait;
 	}
 
  abort:
 	set_current_state(TASK_UNINTERRUPTIBLE);
-	rxrpc_call_abort(call,ret);
+	rxrpc_call_abort(call, ret);
 	schedule();
 	goto out_unwait;
 
@@ -561,10 +575,9 @@ int afs_rxfs_fetch_file_data(afs_server_
 /*
  * ask the AFS fileserver to discard a callback request on a file
  */
-int afs_rxfs_give_up_callback(afs_server_t *server, afs_vnode_t *vnode)
+int afs_rxfs_give_up_callback(struct afs_server *server,
+			      struct afs_vnode *vnode)
 {
-	DECLARE_WAITQUEUE(myself,current);
-
 	struct afs_server_callslot callslot;
 	struct rxrpc_call *call;
 	struct iovec piov[1];
@@ -572,28 +585,31 @@ int afs_rxfs_give_up_callback(afs_server
 	int ret;
 	u32 *bp;
 
-	_enter("%p,{%u,%u,%u}",server,vnode->fid.vid,vnode->fid.vnode,vnode->fid.unique);
+	DECLARE_WAITQUEUE(myself, current);
+
+	_enter("%p,{%u,%u,%u}",
+	       server, vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique);
 
 	/* get hold of the fileserver connection */
-	ret = afs_server_request_callslot(server,&callslot);
-	if (ret<0)
+	ret = afs_server_request_callslot(server, &callslot);
+	if (ret < 0)
 		goto out;
 
 	/* create a call through that connection */
-	ret = rxrpc_create_call(callslot.conn,NULL,NULL,afs_rxfs_aemap,&call);
-	if (ret<0) {
-		printk("kAFS: Unable to create call: %d\n",ret);
+	ret = rxrpc_create_call(callslot.conn, NULL, NULL, afs_rxfs_aemap, &call);
+	if (ret < 0) {
+		printk("kAFS: Unable to create call: %d\n", ret);
 		goto out_put_conn;
 	}
 	call->app_opcode = FSGIVEUPCALLBACKS;
 
 	/* we want to get event notifications from the call */
-	add_wait_queue(&call->waitq,&myself);
+	add_wait_queue(&call->waitq, &myself);
 
 	/* marshall the parameters */
-	bp = rxrpc_call_alloc_scratch(call,(1+4+4)*4);
+	bp = rxrpc_call_alloc_scratch(call, (1 + 4 + 4) * 4);
 
-	piov[0].iov_len = (1+4+4)*4;
+	piov[0].iov_len = (1 + 4 + 4) * 4;
 	piov[0].iov_base = bp;
 
 	*bp++ = htonl(FSGIVEUPCALLBACKS);
@@ -607,14 +623,15 @@ int afs_rxfs_give_up_callback(afs_server
 	*bp++ = htonl(vnode->cb_type);
 
 	/* send the parameters to the server */
-	ret = rxrpc_call_write_data(call,1,piov,RXRPC_LAST_PACKET,GFP_NOFS,0,&sent);
-	if (ret<0)
+	ret = rxrpc_call_write_data(call, 1, piov, RXRPC_LAST_PACKET, GFP_NOFS,
+				    0, &sent);
+	if (ret < 0)
 		goto abort;
 
 	/* wait for the reply to completely arrive */
 	for (;;) {
 		set_current_state(TASK_INTERRUPTIBLE);
-		if (call->app_call_state!=RXRPC_CSTATE_CLNT_RCV_REPLY ||
+		if (call->app_call_state != RXRPC_CSTATE_CLNT_RCV_REPLY ||
 		    signal_pending(current))
 			break;
 		schedule();
@@ -640,17 +657,17 @@ int afs_rxfs_give_up_callback(afs_server
 
  out_unwait:
 	set_current_state(TASK_RUNNING);
-	remove_wait_queue(&call->waitq,&myself);
+	remove_wait_queue(&call->waitq, &myself);
 	rxrpc_put_call(call);
  out_put_conn:
-	afs_server_release_callslot(server,&callslot);
+	afs_server_release_callslot(server, &callslot);
  out:
 	_leave("");
 	return ret;
 
  abort:
 	set_current_state(TASK_UNINTERRUPTIBLE);
-	rxrpc_call_abort(call,ret);
+	rxrpc_call_abort(call, ret);
 	schedule();
 	goto out_unwait;
 } /* end afs_rxfs_give_up_callback() */
@@ -661,14 +678,12 @@ int afs_rxfs_give_up_callback(afs_server
  * - this operation doesn't seem to work correctly in OpenAFS server 1.2.2
  */
 #if 0
-int afs_rxfs_lookup(afs_server_t *server,
-		    afs_vnode_t *dir,
+int afs_rxfs_lookup(struct afs_server *server,
+		    struct afs_vnode *dir,
 		    const char *filename,
-		    afs_vnode_t *vnode,
-		    afs_volsync_t *volsync)
+		    struct afs_vnode *vnode,
+		    struct afs_volsync *volsync)
 {
-	DECLARE_WAITQUEUE(myself,current);
-
 	struct rxrpc_connection *conn;
 	struct rxrpc_call *call;
 	struct iovec piov[3];
@@ -676,17 +691,20 @@ int afs_rxfs_lookup(afs_server_t *server
 	int ret;
 	u32 *bp, zero;
 
-	kenter("%p,{%u,%u,%u},%s",server,fid->vid,fid->vnode,fid->unique,filename);
+	DECLARE_WAITQUEUE(myself, current);
+
+	kenter("%p,{%u,%u,%u},%s",
+	       server, fid->vid, fid->vnode, fid->unique, filename);
 
 	/* get hold of the fileserver connection */
-	ret = afs_server_get_fsconn(server,&conn);
-	if (ret<0)
+	ret = afs_server_get_fsconn(server, &conn);
+	if (ret < 0)
 		goto out;
 
 	/* create a call through that connection */
-	ret = rxrpc_create_call(conn,NULL,NULL,afs_rxfs_aemap,&call);
-	if (ret<0) {
-		printk("kAFS: Unable to create call: %d\n",ret);
+	ret = rxrpc_create_call(conn, NULL, NULL, afs_rxfs_aemap, &call);
+	if (ret < 0) {
+		printk("kAFS: Unable to create call: %d\n", ret);
 		goto out_put_conn;
 	}
 	call->app_opcode = FSLOOKUP;
@@ -695,14 +713,14 @@ int afs_rxfs_lookup(afs_server_t *server
 	add_wait_queue(&call->waitq,&myself);
 
 	/* marshall the parameters */
-	bp = rxrpc_call_alloc_scratch(call,20);
+	bp = rxrpc_call_alloc_scratch(call, 20);
 
 	zero = 0;
 
 	piov[0].iov_len = 20;
 	piov[0].iov_base = bp;
 	piov[1].iov_len = strlen(filename);
-	piov[1].iov_base = (char*) filename;
+	piov[1].iov_base = (char *) filename;
 	piov[2].iov_len = (4 - (piov[1].iov_len & 3)) & 3;
 	piov[2].iov_base = &zero;
 
@@ -713,16 +731,19 @@ int afs_rxfs_lookup(afs_server_t *server
 	*bp++ = htonl(piov[1].iov_len);
 
 	/* send the parameters to the server */
-	ret = rxrpc_call_write_data(call,3,piov,RXRPC_LAST_PACKET,GFP_NOFS,0,&sent);
-	if (ret<0)
+	ret = rxrpc_call_write_data(call, 3, piov, RXRPC_LAST_PACKET, GFP_NOFS,
+				    0, &sent);
+	if (ret < 0)
 		goto abort;
 
 	/* wait for the reply to completely arrive */
-	bp = rxrpc_call_alloc_scratch(call,220);
+	bp = rxrpc_call_alloc_scratch(call, 220);
 
-	ret = rxrpc_call_read_data(call,bp,220,RXRPC_CALL_READ_BLOCK|RXRPC_CALL_READ_ALL);
-	if (ret<0) {
-		if (ret==-ECONNABORTED) {
+	ret = rxrpc_call_read_data(call, bp, 220,
+				   RXRPC_CALL_READ_BLOCK |
+				   RXRPC_CALL_READ_ALL);
+	if (ret < 0) {
+		if (ret == -ECONNABORTED) {
 			ret = call->app_errno;
 			goto out_unwait;
 		}
@@ -752,30 +773,30 @@ int afs_rxfs_lookup(afs_server_t *server
 	vnode->status.mtime_server	= ntohl(*bp++);
 	bp++; /* group */
 	bp++; /* sync counter */
-	vnode->status.version		|= ((unsigned long long) ntohl(*bp++)) << 32;
+	vnode->status.version |= ((unsigned long long) ntohl(*bp++)) << 32;
 	bp++; /* spare2 */
 	bp++; /* spare3 */
 	bp++; /* spare4 */
 
 	dir->status.if_version		= ntohl(*bp++);
-	dir->status.type			= ntohl(*bp++);
+	dir->status.type		= ntohl(*bp++);
 	dir->status.nlink		= ntohl(*bp++);
-	dir->status.size			= ntohl(*bp++);
+	dir->status.size		= ntohl(*bp++);
 	dir->status.version		= ntohl(*bp++);
 	dir->status.author		= ntohl(*bp++);
 	dir->status.owner		= ntohl(*bp++);
 	dir->status.caller_access	= ntohl(*bp++);
 	dir->status.anon_access		= ntohl(*bp++);
-	dir->status.mode			= ntohl(*bp++);
+	dir->status.mode		= ntohl(*bp++);
 	dir->status.parent.vid		= dirfid->vid;
-	dir->status.parent.vnode		= ntohl(*bp++);
+	dir->status.parent.vnode	= ntohl(*bp++);
 	dir->status.parent.unique	= ntohl(*bp++);
 	bp++; /* seg size */
-	dir->status.mtime_client		= ntohl(*bp++);
-	dir->status.mtime_server		= ntohl(*bp++);
+	dir->status.mtime_client	= ntohl(*bp++);
+	dir->status.mtime_server	= ntohl(*bp++);
 	bp++; /* group */
 	bp++; /* sync counter */
-	dir->status.version		|= ((unsigned long long) ntohl(*bp++)) << 32;
+	dir->status.version |= ((unsigned long long) ntohl(*bp++)) << 32;
 	bp++; /* spare2 */
 	bp++; /* spare3 */
 	bp++; /* spare4 */
@@ -799,17 +820,17 @@ int afs_rxfs_lookup(afs_server_t *server
 
  out_unwait:
 	set_current_state(TASK_RUNNING);
-	remove_wait_queue(&call->waitq,&myself);
+	remove_wait_queue(&call->waitq, &myself);
 	rxrpc_put_call(call);
  out_put_conn:
-	afs_server_release_fsconn(server,conn);
+	afs_server_release_fsconn(server, conn);
  out:
 	kleave("");
 	return ret;
 
  abort:
 	set_current_state(TASK_UNINTERRUPTIBLE);
-	rxrpc_call_abort(call,ret);
+	rxrpc_call_abort(call, ret);
 	schedule();
 	goto out_unwait;
 } /* end afs_rxfs_lookup() */
diff -puN fs/afs/fsclient.h~linus fs/afs/fsclient.h
--- 25/fs/afs/fsclient.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/fsclient.h	2004-01-19 22:17:23.000000000 -0800
@@ -14,38 +14,39 @@
 
 #include "server.h"
 
-extern int afs_rxfs_get_volume_info(afs_server_t *server,
+extern int afs_rxfs_get_volume_info(struct afs_server *server,
 				    const char *name,
-				    afs_volume_info_t *vinfo);
+				    struct afs_volume_info *vinfo);
 
-extern int afs_rxfs_fetch_file_status(afs_server_t *server,
-				      afs_vnode_t *vnode,
-				      afs_volsync_t *volsync);
+extern int afs_rxfs_fetch_file_status(struct afs_server *server,
+				      struct afs_vnode *vnode,
+				      struct afs_volsync *volsync);
 
 struct afs_rxfs_fetch_descriptor {
-	afs_fid_t	fid;		/* file ID to fetch */
+	struct afs_fid	fid;		/* file ID to fetch */
 	size_t		size;		/* total number of bytes to fetch */
 	off_t		offset;		/* offset in file to start from */
 	void		*buffer;	/* read buffer */
 	size_t		actual;		/* actual size sent back by server */
 };
 
-extern int afs_rxfs_fetch_file_data(afs_server_t *server,
-				    afs_vnode_t *vnode,
+extern int afs_rxfs_fetch_file_data(struct afs_server *server,
+				    struct afs_vnode *vnode,
 				    struct afs_rxfs_fetch_descriptor *desc,
-				    afs_volsync_t *volsync);
+				    struct afs_volsync *volsync);
 
-extern int afs_rxfs_give_up_callback(afs_server_t *server, afs_vnode_t *vnode);
+extern int afs_rxfs_give_up_callback(struct afs_server *server,
+				     struct afs_vnode *vnode);
 
 /* this doesn't appear to work in OpenAFS server */
-extern int afs_rxfs_lookup(afs_server_t *server,
-			   afs_vnode_t *dir,
+extern int afs_rxfs_lookup(struct afs_server *server,
+			   struct afs_vnode *dir,
 			   const char *filename,
-			   afs_vnode_t *vnode,
-			   afs_volsync_t *volsync);
+			   struct afs_vnode *vnode,
+			   struct afs_volsync *volsync);
 
 /* this is apparently mis-implemented in OpenAFS server */
-extern int afs_rxfs_get_root_volume(afs_server_t *server,
+extern int afs_rxfs_get_root_volume(struct afs_server *server,
 				    char *buf,
 				    size_t *buflen);
 
diff -puN fs/afs/inode.c~linus fs/afs/inode.c
--- 25/fs/afs/inode.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/inode.c	2004-01-19 22:17:23.000000000 -0800
@@ -26,15 +26,15 @@
 #include "internal.h"
 
 struct afs_iget_data {
-	afs_fid_t		fid;
-	afs_volume_t		*volume;	/* volume on which resides */
+	struct afs_fid		fid;
+	struct afs_volume	*volume;	/* volume on which resides */
 };
 
 /*****************************************************************************/
 /*
  * map the AFS file status to the inode member variables
  */
-static int afs_inode_map_status(afs_vnode_t *vnode)
+static int afs_inode_map_status(struct afs_vnode *vnode)
 {
 	struct inode *inode = AFS_VNODE_TO_I(vnode);
 
@@ -97,7 +97,7 @@ static int afs_inode_map_status(afs_vnod
  */
 int afs_inode_fetch_status(struct inode *inode)
 {
-	afs_vnode_t *vnode;
+	struct afs_vnode *vnode;
 	int ret;
 
 	vnode = AFS_FS_I(inode);
@@ -130,7 +130,7 @@ static int afs_iget5_test(struct inode *
 static int afs_iget5_set(struct inode *inode, void *opaque)
 {
 	struct afs_iget_data *data = opaque;
-	afs_vnode_t *vnode = AFS_FS_I(inode);
+	struct afs_vnode *vnode = AFS_FS_I(inode);
 
 	inode->i_ino = data->fid.vnode;
 	inode->i_version = data->fid.unique;
@@ -144,7 +144,7 @@ static int afs_iget5_set(struct inode *i
 /*
  * inode retrieval
  */
-inline int afs_iget(struct super_block *sb, afs_fid_t *fid,
+inline int afs_iget(struct super_block *sb, struct afs_fid *fid,
 		    struct inode **_inode)
 {
 	struct afs_iget_data data = { fid: *fid };
@@ -201,7 +201,11 @@ inline int afs_iget(struct super_block *
 	       vnode->cb_version,
 	       vnode->cb_timeout.timo_jif,
 	       vnode->cb_type,
+#ifdef AFS_CACHING_SUPPORT
 	       vnode->cache
+#else
+	       NULL
+#endif
 	       );
 	return 0;
 
@@ -222,8 +226,8 @@ inline int afs_iget(struct super_block *
 int afs_inode_getattr(struct vfsmount *mnt, struct dentry *dentry,
 		      struct kstat *stat)
 {
+	struct afs_vnode *vnode;
 	struct inode *inode;
-	afs_vnode_t *vnode;
 	int ret;
 
 	inode = dentry->d_inode;
@@ -262,7 +266,7 @@ int afs_inode_getattr(struct vfsmount *m
  */
 void afs_clear_inode(struct inode *inode)
 {
-	afs_vnode_t *vnode;
+	struct afs_vnode *vnode;
 
 	vnode = AFS_FS_I(inode);
 
diff -puN fs/afs/internal.h~linus fs/afs/internal.h
--- 25/fs/afs/internal.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/internal.h	2004-01-19 22:17:23.000000000 -0800
@@ -46,7 +46,7 @@ static inline void afs_discard_my_signal
 		siginfo_t sinfo;
 
 		spin_lock_irq(&current->sighand->siglock);
-		dequeue_signal(current,&current->blocked,&sinfo);
+		dequeue_signal(current,&current->blocked, &sinfo);
 		spin_unlock_irq(&current->sighand->siglock);
 	}
 }
@@ -74,17 +74,28 @@ extern struct inode_operations afs_file_
 extern struct file_operations afs_file_file_operations;
 
 #ifdef AFS_CACHING_SUPPORT
-extern int afs_cache_get_page_cookie(struct page *page, struct cachefs_page **_page_cookie);
+extern int afs_cache_get_page_cookie(struct page *page,
+				     struct cachefs_page **_page_cookie);
 #endif
 
 /*
  * inode.c
  */
-extern int afs_iget(struct super_block *sb, afs_fid_t *fid, struct inode **_inode);
-extern int afs_inode_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
+extern int afs_iget(struct super_block *sb, struct afs_fid *fid,
+		    struct inode **_inode);
+extern int afs_inode_getattr(struct vfsmount *mnt, struct dentry *dentry,
+			     struct kstat *stat);
 extern void afs_clear_inode(struct inode *inode);
 
 /*
+ * key_afs.c
+ */
+#ifdef CONFIG_KEYS
+extern int afs_key_register(void);
+extern void afs_key_unregister(void);
+#endif
+
+/*
  * main.c
  */
 #ifdef AFS_CACHING_SUPPORT
@@ -102,7 +113,7 @@ extern struct afs_timer_ops afs_mntpt_ex
 extern unsigned long afs_mntpt_expiry_timeout;
 #endif
 
-extern int afs_mntpt_check_symlink(afs_vnode_t *vnode);
+extern int afs_mntpt_check_symlink(struct afs_vnode *vnode);
 
 /*
  * super.c
@@ -110,13 +121,14 @@ extern int afs_mntpt_check_symlink(afs_v
 extern int afs_fs_init(void);
 extern void afs_fs_exit(void);
 
-#define AFS_CB_HASH_COUNT (PAGE_SIZE/sizeof(struct list_head))
+#define AFS_CB_HASH_COUNT (PAGE_SIZE / sizeof(struct list_head))
 
 extern struct list_head afs_cb_hash_tbl[];
 extern spinlock_t afs_cb_hash_lock;
 
 #define afs_cb_hash(SRV,FID) \
-	afs_cb_hash_tbl[((unsigned long)(SRV) + (FID)->vid + (FID)->vnode + (FID)->unique) % \
+	afs_cb_hash_tbl[((unsigned long)(SRV) + \
+			(FID)->vid + (FID)->vnode + (FID)->unique) % \
 			AFS_CB_HASH_COUNT]
 
 /*
@@ -124,7 +136,7 @@ extern spinlock_t afs_cb_hash_lock;
  */
 extern int afs_proc_init(void);
 extern void afs_proc_cleanup(void);
-extern int afs_proc_cell_setup(afs_cell_t *cell);
-extern void afs_proc_cell_remove(afs_cell_t *cell);
+extern int afs_proc_cell_setup(struct afs_cell *cell);
+extern void afs_proc_cell_remove(struct afs_cell *cell);
 
 #endif /* AFS_INTERNAL_H */
diff -puN fs/afs/kafsasyncd.c~linus fs/afs/kafsasyncd.c
--- 25/fs/afs/kafsasyncd.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/kafsasyncd.c	2004-01-19 22:17:23.000000000 -0800
@@ -57,8 +57,8 @@ int afs_kafsasyncd_start(void)
 {
 	int ret;
 
-	ret = kernel_thread(kafsasyncd,NULL,0);
-	if (ret<0)
+	ret = kernel_thread(kafsasyncd, NULL, 0);
+	if (ret < 0)
 		return ret;
 
 	wait_for_completion(&kafsasyncd_alive);
@@ -85,14 +85,14 @@ void afs_kafsasyncd_stop(void)
  */
 static int kafsasyncd(void *arg)
 {
-	DECLARE_WAITQUEUE(myself,current);
-
-	struct list_head *_p;
+	struct afs_async_op *op;
 	int die;
 
+	DECLARE_WAITQUEUE(myself, current);
+
 	kafsasyncd_task = current;
 
-	printk("kAFS: Started kafsasyncd %d\n",current->pid);
+	printk("kAFS: Started kafsasyncd %d\n", current->pid);
 
 	daemonize("kafsasyncd");
 
@@ -101,7 +101,7 @@ static int kafsasyncd(void *arg)
 	/* loop around looking for things to attend to */
 	do {
 		set_current_state(TASK_INTERRUPTIBLE);
-		add_wait_queue(&kafsasyncd_sleepq,&myself);
+		add_wait_queue(&kafsasyncd_sleepq, &myself);
 
 		for (;;) {
 			if (!list_empty(&kafsasyncd_async_attnq) ||
@@ -113,7 +113,7 @@ static int kafsasyncd(void *arg)
 			set_current_state(TASK_INTERRUPTIBLE);
 		}
 
-		remove_wait_queue(&kafsasyncd_sleepq,&myself);
+		remove_wait_queue(&kafsasyncd_sleepq, &myself);
 		set_current_state(TASK_RUNNING);
 
 		/* discard pending signals */
@@ -121,7 +121,8 @@ static int kafsasyncd(void *arg)
 
 		die = kafsasyncd_die;
 
-		/* deal with the next asynchronous operation requiring attention */
+		/* deal with the next asynchronous operation requiring
+		 * attention */
 		if (!list_empty(&kafsasyncd_async_attnq)) {
 			struct afs_async_op *op;
 
@@ -131,14 +132,17 @@ static int kafsasyncd(void *arg)
 			spin_lock(&kafsasyncd_async_lock);
 
 			if (!list_empty(&kafsasyncd_async_attnq)) {
-				op = list_entry(kafsasyncd_async_attnq.next,afs_async_op_t,link);
+				op = list_entry(kafsasyncd_async_attnq.next,
+						struct afs_async_op, link);
 				list_del(&op->link);
-				list_add_tail(&op->link,&kafsasyncd_async_busyq);
+				list_add_tail(&op->link,
+					      &kafsasyncd_async_busyq);
 			}
 
 			spin_unlock(&kafsasyncd_async_lock);
 
-			_debug("@@@ Operation %p {%p}\n",op,op?op->ops:NULL);
+			_debug("@@@ Operation %p {%p}\n",
+			       op, op ? op->ops : NULL);
 
 			if (op)
 				op->ops->attend(op);
@@ -148,30 +152,30 @@ static int kafsasyncd(void *arg)
 
 	} while(!die);
 
-	/* need to kill all outstanding asynchronous operations before exiting */
+	/* need to kill all outstanding asynchronous operations before
+	 * exiting */
 	kafsasyncd_task = NULL;
 	spin_lock(&kafsasyncd_async_lock);
 
 	/* fold the busy and attention queues together */
-	list_splice_init(&kafsasyncd_async_busyq,&kafsasyncd_async_attnq);
+	list_splice_init(&kafsasyncd_async_busyq,
+			 &kafsasyncd_async_attnq);
 
 	/* dequeue kafsasyncd from all their wait queues */
-	list_for_each(_p,&kafsasyncd_async_attnq) {
-		afs_async_op_t *op = list_entry(_p,afs_async_op_t,link);
-
+	list_for_each_entry(op, &kafsasyncd_async_attnq, link) {
 		op->call->app_attn_func = kafsasyncd_null_call_attn_func;
 		op->call->app_error_func = kafsasyncd_null_call_error_func;
-		remove_wait_queue(&op->call->waitq,&op->waiter);
+		remove_wait_queue(&op->call->waitq, &op->waiter);
 	}
 
 	spin_unlock(&kafsasyncd_async_lock);
 
 	/* abort all the operations */
 	while (!list_empty(&kafsasyncd_async_attnq)) {
-		afs_async_op_t *op = list_entry(_p,afs_async_op_t,link);
+		op = list_entry(kafsasyncd_async_attnq.next, struct afs_async_op, link);
 		list_del_init(&op->link);
 
-		rxrpc_call_abort(op->call,-EIO);
+		rxrpc_call_abort(op->call, -EIO);
 		rxrpc_put_call(op->call);
 		op->call = NULL;
 
@@ -180,7 +184,7 @@ static int kafsasyncd(void *arg)
 
 	/* and that's all */
 	_leave("");
-	complete_and_exit(&kafsasyncd_dead,0);
+	complete_and_exit(&kafsasyncd_dead, 0);
 
 } /* end kafsasyncd() */
 
@@ -189,17 +193,17 @@ static int kafsasyncd(void *arg)
  * begin an operation
  * - place operation on busy queue
  */
-void afs_kafsasyncd_begin_op(afs_async_op_t *op)
+void afs_kafsasyncd_begin_op(struct afs_async_op *op)
 {
 	_enter("");
 
 	spin_lock(&kafsasyncd_async_lock);
 
-	init_waitqueue_entry(&op->waiter,kafsasyncd_task);
-	add_wait_queue(&op->call->waitq,&op->waiter);
+	init_waitqueue_entry(&op->waiter, kafsasyncd_task);
+	add_wait_queue(&op->call->waitq, &op->waiter);
 
 	list_del(&op->link);
-	list_add_tail(&op->link,&kafsasyncd_async_busyq);
+	list_add_tail(&op->link, &kafsasyncd_async_busyq);
 
 	spin_unlock(&kafsasyncd_async_lock);
 
@@ -211,14 +215,14 @@ void afs_kafsasyncd_begin_op(afs_async_o
  * request attention for an operation
  * - move to attention queue
  */
-void afs_kafsasyncd_attend_op(afs_async_op_t *op)
+void afs_kafsasyncd_attend_op(struct afs_async_op *op)
 {
 	_enter("");
 
 	spin_lock(&kafsasyncd_async_lock);
 
 	list_del(&op->link);
-	list_add_tail(&op->link,&kafsasyncd_async_attnq);
+	list_add_tail(&op->link, &kafsasyncd_async_attnq);
 
 	spin_unlock(&kafsasyncd_async_lock);
 
@@ -232,7 +236,7 @@ void afs_kafsasyncd_attend_op(afs_async_
  * terminate an operation
  * - remove from either queue
  */
-void afs_kafsasyncd_terminate_op(afs_async_op_t *op)
+void afs_kafsasyncd_terminate_op(struct afs_async_op *op)
 {
 	_enter("");
 
@@ -240,7 +244,7 @@ void afs_kafsasyncd_terminate_op(afs_asy
 
 	if (!list_empty(&op->link)) {
 		list_del_init(&op->link);
-		remove_wait_queue(&op->call->waitq,&op->waiter);
+		remove_wait_queue(&op->call->waitq, &op->waiter);
 	}
 
 	spin_unlock(&kafsasyncd_async_lock);
diff -puN fs/afs/kafsasyncd.h~linus fs/afs/kafsasyncd.h
--- 25/fs/afs/kafsasyncd.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/kafsasyncd.h	2004-01-19 22:17:23.000000000 -0800
@@ -14,9 +14,11 @@
 
 #include "types.h"
 
+struct afs_async_op;
+
 struct afs_async_op_ops {
-	void (*attend)(afs_async_op_t *op);
-	void (*discard)(afs_async_op_t *op);
+	void (*attend)(struct afs_async_op *op);
+	void (*discard)(struct afs_async_op *op);
 };
 
 /*****************************************************************************/
@@ -26,13 +28,14 @@ struct afs_async_op_ops {
 struct afs_async_op
 {
 	struct list_head		link;
-	afs_server_t			*server;	/* server being contacted */
+	struct afs_server		*server;	/* server being contacted */
 	struct rxrpc_call		*call;		/* RxRPC call performing op */
 	wait_queue_t			waiter;		/* wait queue for kafsasyncd */
 	const struct afs_async_op_ops	*ops;		/* operations */
 };
 
-static inline void afs_async_op_init(afs_async_op_t *op, const struct afs_async_op_ops *ops)
+static inline void afs_async_op_init(struct afs_async_op *op,
+				     const struct afs_async_op_ops *ops)
 {
 	INIT_LIST_HEAD(&op->link);
 	op->call = NULL;
@@ -42,8 +45,8 @@ static inline void afs_async_op_init(afs
 extern int afs_kafsasyncd_start(void);
 extern void afs_kafsasyncd_stop(void);
 
-extern void afs_kafsasyncd_begin_op(afs_async_op_t *op);
-extern void afs_kafsasyncd_attend_op(afs_async_op_t *op);
-extern void afs_kafsasyncd_terminate_op(afs_async_op_t *op);
+extern void afs_kafsasyncd_begin_op(struct afs_async_op *op);
+extern void afs_kafsasyncd_attend_op(struct afs_async_op *op);
+extern void afs_kafsasyncd_terminate_op(struct afs_async_op *op);
 
 #endif /* _LINUX_AFS_KAFSASYNCD_H */
diff -puN fs/afs/kafstimod.c~linus fs/afs/kafstimod.c
--- 25/fs/afs/kafstimod.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/kafstimod.c	2004-01-19 22:17:23.000000000 -0800
@@ -37,8 +37,8 @@ int afs_kafstimod_start(void)
 {
 	int ret;
 
-	ret = kernel_thread(kafstimod,NULL,0);
-	if (ret<0)
+	ret = kernel_thread(kafstimod, NULL, 0);
+	if (ret < 0)
 		return ret;
 
 	wait_for_completion(&kafstimod_alive);
@@ -65,11 +65,11 @@ void afs_kafstimod_stop(void)
  */
 static int kafstimod(void *arg)
 {
-	DECLARE_WAITQUEUE(myself,current);
+	struct afs_timer *timer;
 
-	afs_timer_t *timer;
+	DECLARE_WAITQUEUE(myself, current);
 
-	printk("kAFS: Started kafstimod %d\n",current->pid);
+	printk("kAFS: Started kafstimod %d\n", current->pid);
 
 	daemonize("kafstimod");
 
@@ -78,7 +78,7 @@ static int kafstimod(void *arg)
 	/* loop around looking for things to attend to */
  loop:
 	set_current_state(TASK_INTERRUPTIBLE);
-	add_wait_queue(&kafstimod_sleepq,&myself);
+	add_wait_queue(&kafstimod_sleepq, &myself);
 
 	for (;;) {
 		unsigned long jif;
@@ -86,9 +86,9 @@ static int kafstimod(void *arg)
 
 		/* deal with the server being asked to die */
 		if (kafstimod_die) {
-			remove_wait_queue(&kafstimod_sleepq,&myself);
+			remove_wait_queue(&kafstimod_sleepq, &myself);
 			_leave("");
-			complete_and_exit(&kafstimod_dead,0);
+			complete_and_exit(&kafstimod_dead, 0);
 		}
 
 		/* discard pending signals */
@@ -100,15 +100,16 @@ static int kafstimod(void *arg)
 			timeout = MAX_SCHEDULE_TIMEOUT;
 		}
 		else {
-			timer = list_entry(kafstimod_list.next,afs_timer_t,link);
+			timer = list_entry(kafstimod_list.next,
+					   struct afs_timer, link);
 			timeout = timer->timo_jif;
 			jif = jiffies;
 
-			if (time_before_eq((unsigned long)timeout,jif))
+			if (time_before_eq((unsigned long) timeout, jif))
 				goto immediate;
 
 			else {
-				timeout = (long)timeout - (long)jiffies;
+				timeout = (long) timeout - (long) jiffies;
 			}
 		}
 		spin_unlock(&kafstimod_lock);
@@ -119,13 +120,14 @@ static int kafstimod(void *arg)
 	}
 
 	/* the thing on the front of the queue needs processing
-	 * - we come here with the lock held and timer pointing to the expired entry
+	 * - we come here with the lock held and timer pointing to the expired
+	 *   entry
 	 */
  immediate:
-	remove_wait_queue(&kafstimod_sleepq,&myself);
+	remove_wait_queue(&kafstimod_sleepq, &myself);
 	set_current_state(TASK_RUNNING);
 
-	_debug("@@@ Begin Timeout of %p",timer);
+	_debug("@@@ Begin Timeout of %p", timer);
 
 	/* dequeue the timer */
 	list_del_init(&timer->link);
@@ -143,27 +145,28 @@ static int kafstimod(void *arg)
 /*
  * (re-)queue a timer
  */
-void afs_kafstimod_add_timer(afs_timer_t *timer, unsigned long timeout)
+void afs_kafstimod_add_timer(struct afs_timer *timer, unsigned long timeout)
 {
+	struct afs_timer *ptimer;
 	struct list_head *_p;
-	afs_timer_t *ptimer;
 
-	_enter("%p,%lu",timer,timeout);
+	_enter("%p,%lu", timer, timeout);
 
 	spin_lock(&kafstimod_lock);
 
 	list_del(&timer->link);
 
-	/* the timer was deferred or reset - put it back in the queue at the right place */
+	/* the timer was deferred or reset - put it back in the queue at the
+	 * right place */
 	timer->timo_jif = jiffies + timeout;
 
-	list_for_each(_p,&kafstimod_list) {
-		ptimer = list_entry(_p,afs_timer_t,link);
-		if (time_before(timer->timo_jif,ptimer->timo_jif))
+	list_for_each(_p, &kafstimod_list) {
+		ptimer = list_entry(_p, struct afs_timer, link);
+		if (time_before(timer->timo_jif, ptimer->timo_jif))
 			break;
 	}
 
-	list_add_tail(&timer->link,_p); /* insert before stopping point */
+	list_add_tail(&timer->link, _p); /* insert before stopping point */
 
 	spin_unlock(&kafstimod_lock);
 
@@ -177,11 +180,11 @@ void afs_kafstimod_add_timer(afs_timer_t
  * dequeue a timer
  * - returns 0 if the timer was deleted or -ENOENT if it wasn't queued
  */
-int afs_kafstimod_del_timer(afs_timer_t *timer)
+int afs_kafstimod_del_timer(struct afs_timer *timer)
 {
 	int ret = 0;
 
-	_enter("%p",timer);
+	_enter("%p", timer);
 
 	spin_lock(&kafstimod_lock);
 
@@ -194,6 +197,6 @@ int afs_kafstimod_del_timer(afs_timer_t 
 
 	wake_up(&kafstimod_sleepq);
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end afs_kafstimod_del_timer() */
diff -puN fs/afs/kafstimod.h~linus fs/afs/kafstimod.h
--- 25/fs/afs/kafstimod.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/kafstimod.h	2004-01-19 22:17:23.000000000 -0800
@@ -14,6 +14,8 @@
 
 #include "types.h"
 
+struct afs_timer;
+
 struct afs_timer_ops {
 	/* called when the front of the timer queue has timed out */
 	void (*timed_out)(struct afs_timer *timer);
@@ -30,7 +32,8 @@ struct afs_timer
 	const struct afs_timer_ops	*ops;		/* timeout expiry function */
 };
 
-static inline void afs_timer_init(afs_timer_t *timer, const struct afs_timer_ops *ops)
+static inline void afs_timer_init(struct afs_timer *timer,
+				  const struct afs_timer_ops *ops)
 {
 	INIT_LIST_HEAD(&timer->link);
 	timer->ops = ops;
@@ -39,7 +42,8 @@ static inline void afs_timer_init(afs_ti
 extern int afs_kafstimod_start(void);
 extern void afs_kafstimod_stop(void);
 
-extern void afs_kafstimod_add_timer(afs_timer_t *timer, unsigned long timeout);
-extern int afs_kafstimod_del_timer(afs_timer_t *timer);
+extern void afs_kafstimod_add_timer(struct afs_timer *timer,
+				    unsigned long timeout);
+extern int afs_kafstimod_del_timer(struct afs_timer *timer);
 
 #endif /* _LINUX_AFS_KAFSTIMOD_H */
diff -puN fs/afs/main.c~linus fs/afs/main.c
--- 25/fs/afs/main.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/main.c	2004-01-19 22:17:23.000000000 -0800
@@ -33,13 +33,24 @@ static void afs_exit(void);
 static int afs_adding_peer(struct rxrpc_peer *peer);
 static void afs_discarding_peer(struct rxrpc_peer *peer);
 
-module_init(afs_init);
+/* XXX late_initcall is kludgy, but the only alternative seems to create
+ * a transport upon the first mount, which is worse. Or is it?
+ */
+/* module_init(afs_init); */
+late_initcall(afs_init);	/* must be called after net/ to create socket */
+
 module_exit(afs_exit);
 
 MODULE_DESCRIPTION("AFS Client File System");
 MODULE_AUTHOR("Red Hat, Inc.");
 MODULE_LICENSE("GPL");
 
+static char *rootcell;
+
+MODULE_PARM(rootcell, "s");
+MODULE_PARM_DESC(rootcell, "root AFS cell name and VL server IP addr list");
+
+
 static struct rxrpc_peer_ops afs_peer_ops = {
 	.adding		= afs_adding_peer,
 	.discarding	= afs_discarding_peer,
@@ -72,7 +83,7 @@ static int afs_init(void)
 
 	/* initialise the callback hash table */
 	spin_lock_init(&afs_cb_hash_lock);
-	for (loop=AFS_CB_HASH_COUNT-1; loop>=0; loop--)
+	for (loop = AFS_CB_HASH_COUNT - 1; loop >= 0; loop--)
 		INIT_LIST_HEAD(&afs_cb_hash_tbl[loop]);
 
 	/* register the /proc stuff */
@@ -82,20 +93,27 @@ static int afs_init(void)
 
 #ifdef AFS_CACHING_SUPPORT
 	/* we want to be able to cache */
-	ret = cachefs_register_netfs(&afs_cache_netfs,&afs_cache_cell_index_def);
+	ret = cachefs_register_netfs(&afs_cache_netfs,
+				     &afs_cache_cell_index_def);
 	if (ret < 0)
 		goto error;
 #endif
 
-	/* initialise the cell DB */
-	ret = afs_cell_init();
+#ifdef CONFIG_KEYS
+	ret = afs_key_register();
 	if (ret < 0)
 		goto error_cache;
+#endif
+
+	/* initialise the cell DB */
+	ret = afs_cell_init(rootcell);
+	if (ret < 0)
+		goto error_keys;
 
 	/* start the timeout daemon */
 	ret = afs_kafstimod_start();
 	if (ret < 0)
-		goto error_cache;
+		goto error_keys;
 
 	/* start the async operation daemon */
 	ret = afs_kafsasyncd_start();
@@ -103,7 +121,7 @@ static int afs_init(void)
 		goto error_kafstimod;
 
 	/* create the RxRPC transport */
-	ret = rxrpc_create_transport(7001,&afs_transport);
+	ret = rxrpc_create_transport(7001, &afs_transport);
 	if (ret < 0)
 		goto error_kafsasyncd;
 
@@ -122,14 +140,18 @@ static int afs_init(void)
 	afs_kafsasyncd_stop();
  error_kafstimod:
 	afs_kafstimod_stop();
+ error_keys:
+#ifdef CONFIG_KEYS
+	afs_key_unregister();
  error_cache:
+#endif
 #ifdef AFS_CACHING_SUPPORT
 	cachefs_unregister_netfs(&afs_cache_netfs);
  error:
 #endif
 	afs_cell_purge();
 	afs_proc_cleanup();
-	printk(KERN_ERR "kAFS: failed to register: %d\n",ret);
+	printk(KERN_ERR "kAFS: failed to register: %d\n", ret);
 	return ret;
 } /* end afs_init() */
 
@@ -146,6 +168,9 @@ static void __exit afs_exit(void)
 	afs_kafstimod_stop();
 	afs_kafsasyncd_stop();
 	afs_cell_purge();
+#ifdef CONFIG_KEYS
+	afs_key_unregister();
+#endif
 #ifdef AFS_CACHING_SUPPORT
 	cachefs_unregister_netfs(&afs_cache_netfs);
 #endif
@@ -162,19 +187,20 @@ static void __exit afs_exit(void)
  */
 static int afs_adding_peer(struct rxrpc_peer *peer)
 {
-	afs_server_t *server;
+	struct afs_server *server;
 	int ret;
 
-	_debug("kAFS: Adding new peer %08x\n",ntohl(peer->addr.s_addr));
+	_debug("kAFS: Adding new peer %08x\n", ntohl(peer->addr.s_addr));
 
 	/* determine which server the peer resides in (if any) */
-	ret = afs_server_find_by_peer(peer,&server);
+	ret = afs_server_find_by_peer(peer, &server);
 	if (ret < 0)
 		return ret; /* none that we recognise, so abort */
 
-	_debug("Server %p{u=%d}\n",server,atomic_read(&server->usage));
+	_debug("Server %p{u=%d}\n", server, atomic_read(&server->usage));
 
-	_debug("Cell %p{u=%d}\n",server->cell,atomic_read(&server->cell->usage));
+	_debug("Cell %p{u=%d}\n",
+	       server->cell, atomic_read(&server->cell->usage));
 
 	/* cross-point the structs under a global lock */
 	spin_lock(&afs_server_peer_lock);
@@ -194,14 +220,14 @@ static int afs_adding_peer(struct rxrpc_
  */
 static void afs_discarding_peer(struct rxrpc_peer *peer)
 {
-	afs_server_t *server;
+	struct afs_server *server;
 
 	_enter("%p",peer);
 
 	_debug("Discarding peer %08x (rtt=%lu.%lumS)\n",
 	       ntohl(peer->addr.s_addr),
-	       (long)(peer->rtt/1000),
-	       (long)(peer->rtt%1000));
+	       (long) (peer->rtt / 1000),
+	       (long) (peer->rtt % 1000));
 
 	/* uncross-point the structs under a global lock */
 	spin_lock(&afs_server_peer_lock);
@@ -209,9 +235,6 @@ static void afs_discarding_peer(struct r
 	if (server) {
 		peer->user = NULL;
 		server->peer = NULL;
-
-		//_debug("Server %p{u=%d}\n",server,atomic_read(&server->usage));
-		//_debug("Cell %p{u=%d}\n",server->cell,atomic_read(&server->cell->usage));
 	}
 	spin_unlock(&afs_server_peer_lock);
 
@@ -239,7 +262,7 @@ void __cyg_profile_func_enter (void *thi
                     "  movl    $0xedededed,%%eax     \n"
                     "  rep stosl               \n"
                     :
-                    : "i"(~(THREAD_SIZE-1)), "i"(sizeof(struct thread_info))
+                    : "i"(~(THREAD_SIZE - 1)), "i"(sizeof(struct thread_info))
                     : "eax", "ecx", "edi", "memory", "cc"
                     );
 }
@@ -258,7 +281,7 @@ void __cyg_profile_func_exit(void *this_
                     "  movl    $0xdadadada,%%eax     \n"
                     "  rep stosl               \n"
                     :
-                    : "i"(~(THREAD_SIZE-1)), "i"(sizeof(struct thread_info))
+                    : "i"(~(THREAD_SIZE - 1)), "i"(sizeof(struct thread_info))
                     : "eax", "ecx", "edi", "memory", "cc"
                     );
 }
diff -puN fs/afs/mntpt.c~linus fs/afs/mntpt.c
--- 25/fs/afs/mntpt.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/mntpt.c	2004-01-19 22:17:23.000000000 -0800
@@ -67,18 +67,21 @@ unsigned long afs_mntpt_expiry_timeout =
  * check a symbolic link to see whether it actually encodes a mountpoint
  * - sets the AFS_VNODE_MOUNTPOINT flag on the vnode appropriately
  */
-int afs_mntpt_check_symlink(afs_vnode_t *vnode)
+int afs_mntpt_check_symlink(struct afs_vnode *vnode)
 {
 	struct page *page;
+	filler_t *filler;
 	size_t size;
 	char *buf;
 	int ret;
 
-	_enter("{%u,%u}",vnode->fid.vnode,vnode->fid.unique);
+	_enter("{%u,%u}", vnode->fid.vnode, vnode->fid.unique);
 
 	/* read the contents of the symlink into the pagecache */
-	page = read_cache_page(AFS_VNODE_TO_I(vnode)->i_mapping,0,
-			       (filler_t*)AFS_VNODE_TO_I(vnode)->i_mapping->a_ops->readpage,NULL);
+	filler = (filler_t *) AFS_VNODE_TO_I(vnode)->i_mapping->a_ops->readpage;
+
+	page = read_cache_page(AFS_VNODE_TO_I(vnode)->i_mapping, 0,
+			       filler, NULL);
 	if (IS_ERR(page)) {
 		ret = PTR_ERR(page);
 		goto out;
@@ -94,11 +97,11 @@ int afs_mntpt_check_symlink(afs_vnode_t 
 
 	/* examine the symlink's contents */
 	size = vnode->status.size;
-	_debug("symlink to %*.*s",size,(int)size,buf);
+	_debug("symlink to %*.*s", size, (int) size, buf);
 
-	if (size>2 &&
-	    (buf[0]=='%' || buf[0]=='#') &&
-	    buf[size-1]=='.'
+	if (size > 2 &&
+	    (buf[0] == '%' || buf[0] == '#') &&
+	    buf[size - 1] == '.'
 	    ) {
 		_debug("symlink is a mountpoint");
 		spin_lock(&vnode->lock);
@@ -112,7 +115,7 @@ int afs_mntpt_check_symlink(afs_vnode_t 
 	kunmap(page);
 	page_cache_release(page);
  out:
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 
 } /* end afs_mntpt_check_symlink() */
@@ -129,7 +132,8 @@ static struct dentry *afs_mntpt_lookup(s
 	       dir,
 	       dentry,
 	       dentry->d_parent,
-	       dentry->d_parent ? dentry->d_parent->d_name.name : (const unsigned char*)"",
+	       dentry->d_parent ?
+	       dentry->d_parent->d_name.name : (const unsigned char *) "",
 	       dentry->d_name.name);
 
 	return ERR_PTR(-EREMOTE);
@@ -144,7 +148,9 @@ static int afs_mntpt_open(struct inode *
 	kenter("%p,%p{%p{%s},%s}",
 	       inode, file,
 	       file->f_dentry->d_parent,
-	       file->f_dentry->d_parent ? file->f_dentry->d_parent->d_name.name : (const unsigned char*)"",
+	       file->f_dentry->d_parent ?
+	       file->f_dentry->d_parent->d_name.name :
+	       (const unsigned char *) "",
 	       file->f_dentry->d_name.name);
 
 	return -EREMOTE;
@@ -183,10 +189,9 @@ static struct vfsmount *afs_mntpt_do_aut
 		goto error;
 
 	/* read the contents of the AFS special symlink */
-	page = read_cache_page(mntpt->d_inode->i_mapping,
-			       0,
-			       (filler_t*)mntpt->d_inode->i_mapping->a_ops->readpage,
-			       NULL);
+	filler_t *filler = mntpt->d_inode->i_mapping->a_ops->readpage;
+
+	page = read_cache_page(mntpt->d_inode->i_mapping, 0, filler, NULL);
 	if (IS_ERR(page)) {
 		ret = PTR_ERR(page);
 		goto error;
@@ -208,26 +213,26 @@ static struct vfsmount *afs_mntpt_do_aut
 	memcpy(options, "cell=", 5);
 	strcpy(options + 5, super->volume->cell->name);
 	if (super->volume->type == AFSVL_RWVOL)
-		strcat(options,",rwpath");
+		strcat(options, ",rwpath");
 
 	/* try and do the mount */
 	kdebug("--- attempting mount %s -o %s ---", devname, options);
 	mnt = do_kern_mount("afs", 0, devname, options);
 	kdebug("--- mount result %p ---", mnt);
 
-	free_page((unsigned long)devname);
-	free_page((unsigned long)options);
-	kleave(" = %p",mnt);
+	free_page((unsigned long) devname);
+	free_page((unsigned long) options);
+	kleave(" = %p", mnt);
 	return mnt;
 
  error:
 	if (page)
 		page_cache_release(page);
 	if (devname)
-		free_page((unsigned long)devname);
+		free_page((unsigned long) devname);
 	if (options)
-		free_page((unsigned long)options);
-	kleave(" = %d",ret);
+		free_page((unsigned long) options);
+	kleave(" = %d", ret);
 	return ERR_PTR(ret);
 } /* end afs_mntpt_do_automount() */
 
@@ -252,7 +257,7 @@ static int afs_mntpt_follow_link(struct 
 	if (IS_ERR(newmnt))
 		return PTR_ERR(newmnt);
 
-	struct_cpy(&newnd,nd);
+	struct_cpy(&newnd, nd);
 	newnd.dentry = dentry;
 	err = do_add_mount(newmnt, &newnd, 0, &afs_vfsmounts);
 
diff -puN fs/afs/proc.c~linus fs/afs/proc.c
--- 25/fs/afs/proc.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/proc.c	2004-01-19 22:17:23.000000000 -0800
@@ -27,7 +27,8 @@ static void *afs_proc_cells_start(struct
 static void *afs_proc_cells_next(struct seq_file *p, void *v, loff_t *pos);
 static void afs_proc_cells_stop(struct seq_file *p, void *v);
 static int afs_proc_cells_show(struct seq_file *m, void *v);
-static ssize_t afs_proc_cells_write(struct file *file, const char *buf, size_t size, loff_t *_pos);
+static ssize_t afs_proc_cells_write(struct file *file, const char *buf,
+				    size_t size, loff_t *_pos);
 
 static struct seq_operations afs_proc_cells_ops = {
 	.start	= afs_proc_cells_start,
@@ -44,10 +45,27 @@ static struct file_operations afs_proc_c
 	.release	= seq_release,
 };
 
+static int afs_proc_rootcell_open(struct inode *inode, struct file *file);
+static int afs_proc_rootcell_release(struct inode *inode, struct file *file);
+static ssize_t afs_proc_rootcell_read(struct file *file, char *buf,
+				      size_t size, loff_t *_pos);
+static ssize_t afs_proc_rootcell_write(struct file *file, const char *buf,
+				       size_t size, loff_t *_pos);
+
+static struct file_operations afs_proc_rootcell_fops = {
+	.open		= afs_proc_rootcell_open,
+	.read		= afs_proc_rootcell_read,
+	.write		= afs_proc_rootcell_write,
+	.llseek		= no_llseek,
+	.release	= afs_proc_rootcell_release
+};
+
 static int afs_proc_cell_volumes_open(struct inode *inode, struct file *file);
-static int afs_proc_cell_volumes_release(struct inode *inode, struct file *file);
+static int afs_proc_cell_volumes_release(struct inode *inode,
+					 struct file *file);
 static void *afs_proc_cell_volumes_start(struct seq_file *p, loff_t *pos);
-static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v, loff_t *pos);
+static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v,
+					loff_t *pos);
 static void afs_proc_cell_volumes_stop(struct seq_file *p, void *v);
 static int afs_proc_cell_volumes_show(struct seq_file *m, void *v);
 
@@ -65,10 +83,13 @@ static struct file_operations afs_proc_c
 	.release	= afs_proc_cell_volumes_release,
 };
 
-static int afs_proc_cell_vlservers_open(struct inode *inode, struct file *file);
-static int afs_proc_cell_vlservers_release(struct inode *inode, struct file *file);
+static int afs_proc_cell_vlservers_open(struct inode *inode,
+					struct file *file);
+static int afs_proc_cell_vlservers_release(struct inode *inode,
+					   struct file *file);
 static void *afs_proc_cell_vlservers_start(struct seq_file *p, loff_t *pos);
-static void *afs_proc_cell_vlservers_next(struct seq_file *p, void *v, loff_t *pos);
+static void *afs_proc_cell_vlservers_next(struct seq_file *p, void *v,
+					  loff_t *pos);
 static void afs_proc_cell_vlservers_stop(struct seq_file *p, void *v);
 static int afs_proc_cell_vlservers_show(struct seq_file *m, void *v);
 
@@ -87,9 +108,11 @@ static struct file_operations afs_proc_c
 };
 
 static int afs_proc_cell_servers_open(struct inode *inode, struct file *file);
-static int afs_proc_cell_servers_release(struct inode *inode, struct file *file);
+static int afs_proc_cell_servers_release(struct inode *inode,
+					 struct file *file);
 static void *afs_proc_cell_servers_start(struct seq_file *p, loff_t *pos);
-static void *afs_proc_cell_servers_next(struct seq_file *p, void *v, loff_t *pos);
+static void *afs_proc_cell_servers_next(struct seq_file *p, void *v,
+					loff_t *pos);
 static void afs_proc_cell_servers_stop(struct seq_file *p, void *v);
 static int afs_proc_cell_servers_show(struct seq_file *m, void *v);
 
@@ -117,26 +140,30 @@ int afs_proc_init(void)
 
 	_enter("");
 
-	proc_afs = proc_mkdir("fs/afs",NULL);
+	proc_afs = proc_mkdir("fs/afs", NULL);
 	if (!proc_afs)
 		goto error;
 	proc_afs->owner = THIS_MODULE;
 
-	p = create_proc_entry("cells",0,proc_afs);
+	p = create_proc_entry("cells", 0, proc_afs);
 	if (!p)
 		goto error_proc;
 	p->proc_fops = &afs_proc_cells_fops;
 	p->owner = THIS_MODULE;
 
+	p = create_proc_entry("rootcell", 0, proc_afs);
+	if (!p)
+		goto error_cells;
+	p->proc_fops = &afs_proc_rootcell_fops;
+	p->owner = THIS_MODULE;
+
 	_leave(" = 0");
 	return 0;
 
-#if 0
  error_cells:
-	remove_proc_entry("cells",proc_afs);
-#endif
+ 	remove_proc_entry("cells", proc_afs);
  error_proc:
-	remove_proc_entry("fs/afs",NULL);
+	remove_proc_entry("fs/afs", NULL);
  error:
 	_leave(" = -ENOMEM");
 	return -ENOMEM;
@@ -149,9 +176,9 @@ int afs_proc_init(void)
  */
 void afs_proc_cleanup(void)
 {
-	remove_proc_entry("cells",proc_afs);
+	remove_proc_entry("cells", proc_afs);
 
-	remove_proc_entry("fs/afs",NULL);
+	remove_proc_entry("fs/afs", NULL);
 
 } /* end afs_proc_cleanup() */
 
@@ -164,8 +191,8 @@ static int afs_proc_cells_open(struct in
 	struct seq_file *m;
 	int ret;
 
-	ret = seq_open(file,&afs_proc_cells_ops);
-	if (ret<0)
+	ret = seq_open(file, &afs_proc_cells_ops);
+	if (ret < 0)
 		return ret;
 
 	m = file->private_data;
@@ -176,7 +203,8 @@ static int afs_proc_cells_open(struct in
 
 /*****************************************************************************/
 /*
- * set up the iterator to start reading from the cells list and return the first item
+ * set up the iterator to start reading from the cells list and return the
+ * first item
  */
 static void *afs_proc_cells_start(struct seq_file *m, loff_t *_pos)
 {
@@ -188,15 +216,15 @@ static void *afs_proc_cells_start(struct
 
 	/* allow for the header line */
 	if (!pos)
-		return (void *)1;
+		return (void *) 1;
 	pos--;
 
 	/* find the n'th element in the list */
-	list_for_each(_p,&afs_proc_cells)
+	list_for_each(_p, &afs_proc_cells)
 		if (!pos--)
 			break;
 
-	return _p!=&afs_proc_cells ? _p : NULL;
+	return _p != &afs_proc_cells ? _p : NULL;
 } /* end afs_proc_cells_start() */
 
 /*****************************************************************************/
@@ -210,9 +238,9 @@ static void *afs_proc_cells_next(struct 
 	(*pos)++;
 
 	_p = v;
-	_p = v==(void*)1 ? afs_proc_cells.next : _p->next;
+	_p = v == (void *) 1 ? afs_proc_cells.next : _p->next;
 
-	return _p!=&afs_proc_cells ? _p : NULL;
+	return _p != &afs_proc_cells ? _p : NULL;
 } /* end afs_proc_cells_next() */
 
 /*****************************************************************************/
@@ -231,16 +259,16 @@ static void afs_proc_cells_stop(struct s
  */
 static int afs_proc_cells_show(struct seq_file *m, void *v)
 {
-	afs_cell_t *cell = list_entry(v,afs_cell_t,proc_link);
+	struct afs_cell *cell = list_entry(v, struct afs_cell, proc_link);
 
 	/* display header on line 1 */
-	if (v == (void *)1) {
+	if (v == (void *) 1) {
 		seq_puts(m, "USE NAME\n");
 		return 0;
 	}
 
 	/* display one cell per line on subsequent lines */
-	seq_printf(m,"%3d %s\n",atomic_read(&cell->usage),cell->name);
+	seq_printf(m, "%3d %s\n", atomic_read(&cell->usage), cell->name);
 
 	return 0;
 } /* end afs_proc_cells_show() */
@@ -248,51 +276,61 @@ static int afs_proc_cells_show(struct se
 /*****************************************************************************/
 /*
  * handle writes to /proc/fs/afs/cells
- * - to add cells: echo "add <cellname> <IP>[:<IP>][:<IP>]*
+ * - to add cells: echo "add <cellname> <IP>[:<IP>][:<IP>]"
  */
-static ssize_t afs_proc_cells_write(struct file *file, const char *buf, size_t size, loff_t *_pos)
+static ssize_t afs_proc_cells_write(struct file *file, const char *buf,
+				    size_t size, loff_t *_pos)
 {
 	char *kbuf, *name, *args;
 	int ret;
 
 	/* start by dragging the command into memory */
-	if (size<=1 || size>=PAGE_SIZE)
+	if (size <= 1 || size >= PAGE_SIZE)
 		return -EINVAL;
 
-	kbuf = kmalloc(size+1,GFP_KERNEL);
+	kbuf = kmalloc(size + 1, GFP_KERNEL);
 	if (!kbuf)
 		return -ENOMEM;
 
 	ret = -EFAULT;
-	if (copy_from_user(kbuf,buf,size)!=0)
+	if (copy_from_user(kbuf, buf, size) != 0)
 		goto done;
 	kbuf[size] = 0;
 
 	/* trim to first NL */
-	name = memchr(kbuf,'\n',size);
-	if (name) *name = 0;
+	name = memchr(kbuf, '\n', size);
+	if (name)
+		*name = 0;
 
 	/* split into command, name and argslist */
-	name = strchr(kbuf,' ');
-	if (!name) goto inval;
-	do { *name++ = 0; } while(*name==' ');
-	if (!*name) goto inval;
-
-	args = strchr(name,' ');
-	if (!args) goto inval;
-	do { *args++ = 0; } while(*args==' ');
-	if (!*args) goto inval;
+	name = strchr(kbuf, ' ');
+	if (!name)
+		goto inval;
+	do {
+		*name++ = 0;
+	} while(*name == ' ');
+	if (!*name)
+		goto inval;
+
+	args = strchr(name, ' ');
+	if (!args)
+		goto inval;
+	do {
+		*args++ = 0;
+	} while(*args == ' ');
+	if (!*args)
+		goto inval;
 
 	/* determine command to perform */
-	_debug("cmd=%s name=%s args=%s",kbuf,name,args);
+	_debug("cmd=%s name=%s args=%s", kbuf, name, args);
 
-	if (strcmp(kbuf,"add")==0) {
-		afs_cell_t *cell;
-		ret = afs_cell_create(name,args,&cell);
-		if (ret<0)
+	if (strcmp(kbuf, "add") == 0) {
+		struct afs_cell *cell;
+		ret = afs_cell_create(name, args, &cell);
+		if (ret < 0)
 			goto done;
 
-		printk("kAFS: Added new cell '%s'\n",name);
+		printk("kAFS: Added new cell '%s'\n", name);
 	}
 	else {
 		goto inval;
@@ -302,7 +340,7 @@ static ssize_t afs_proc_cells_write(stru
 
  done:
 	kfree(kbuf);
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 
  inval:
@@ -313,33 +351,97 @@ static ssize_t afs_proc_cells_write(stru
 
 /*****************************************************************************/
 /*
+ * Stubs for /proc/fs/afs/rootcell
+ */
+static int afs_proc_rootcell_open(struct inode *inode, struct file *file)
+{
+	return 0;
+}
+
+static int afs_proc_rootcell_release(struct inode *inode, struct file *file)
+{
+	return 0;
+}
+
+static ssize_t afs_proc_rootcell_read(struct file *file, char *buf,
+				      size_t size, loff_t *_pos)
+{
+	return 0;
+}
+
+/*****************************************************************************/
+/*
+ * handle writes to /proc/fs/afs/rootcell
+ * - to initialize rootcell: echo "cell.name:192.168.231.14"
+ */
+static ssize_t afs_proc_rootcell_write(struct file *file, const char *buf,
+				       size_t size, loff_t *_pos)
+{
+	char *kbuf, *s;
+	int ret;
+
+	/* start by dragging the command into memory */
+	if (size <= 1 || size >= PAGE_SIZE)
+		return -EINVAL;
+
+	ret = -ENOMEM;
+	kbuf = kmalloc(size + 1, GFP_KERNEL);
+	if (!kbuf)
+		goto nomem;
+
+	ret = -EFAULT;
+	if (copy_from_user(kbuf, buf, size) != 0)
+		goto infault;
+	kbuf[size] = 0;
+
+	/* trim to first NL */
+	s = memchr(kbuf, '\n', size);
+	if (s)
+		*s = 0;
+
+	/* determine command to perform */
+	_debug("rootcell=%s", kbuf);
+
+	ret = afs_cell_init(kbuf);
+	if (ret >= 0)
+		ret = size;	/* consume everything, always */
+
+ infault:
+	kfree(kbuf);
+ nomem:
+	_leave(" = %d", ret);
+	return ret;
+} /* end afs_proc_rootcell_write() */
+
+/*****************************************************************************/
+/*
  * initialise /proc/fs/afs/<cell>/
  */
-int afs_proc_cell_setup(afs_cell_t *cell)
+int afs_proc_cell_setup(struct afs_cell *cell)
 {
 	struct proc_dir_entry *p;
 
-	_enter("%p{%s}",cell,cell->name);
+	_enter("%p{%s}", cell, cell->name);
 
-	cell->proc_dir = proc_mkdir(cell->name,proc_afs);
+	cell->proc_dir = proc_mkdir(cell->name, proc_afs);
 	if (!cell->proc_dir)
 		return -ENOMEM;
 
-	p = create_proc_entry("servers",0,cell->proc_dir);
+	p = create_proc_entry("servers", 0, cell->proc_dir);
 	if (!p)
 		goto error_proc;
 	p->proc_fops = &afs_proc_cell_servers_fops;
 	p->owner = THIS_MODULE;
 	p->data = cell;
 
-	p = create_proc_entry("vlservers",0,cell->proc_dir);
+	p = create_proc_entry("vlservers", 0, cell->proc_dir);
 	if (!p)
 		goto error_servers;
 	p->proc_fops = &afs_proc_cell_vlservers_fops;
 	p->owner = THIS_MODULE;
 	p->data = cell;
 
-	p = create_proc_entry("volumes",0,cell->proc_dir);
+	p = create_proc_entry("volumes", 0, cell->proc_dir);
 	if (!p)
 		goto error_vlservers;
 	p->proc_fops = &afs_proc_cell_volumes_fops;
@@ -350,11 +452,11 @@ int afs_proc_cell_setup(afs_cell_t *cell
 	return 0;
 
  error_vlservers:
-	remove_proc_entry("vlservers",cell->proc_dir);
+	remove_proc_entry("vlservers", cell->proc_dir);
  error_servers:
-	remove_proc_entry("servers",cell->proc_dir);
+	remove_proc_entry("servers", cell->proc_dir);
  error_proc:
-	remove_proc_entry(cell->name,proc_afs);
+	remove_proc_entry(cell->name, proc_afs);
 	_leave(" = -ENOMEM");
 	return -ENOMEM;
 } /* end afs_proc_cell_setup() */
@@ -363,14 +465,14 @@ int afs_proc_cell_setup(afs_cell_t *cell
 /*
  * remove /proc/fs/afs/<cell>/
  */
-void afs_proc_cell_remove(afs_cell_t *cell)
+void afs_proc_cell_remove(struct afs_cell *cell)
 {
 	_enter("");
 
-	remove_proc_entry("volumes",cell->proc_dir);
-	remove_proc_entry("vlservers",cell->proc_dir);
-	remove_proc_entry("servers",cell->proc_dir);
-	remove_proc_entry(cell->name,proc_afs);
+	remove_proc_entry("volumes", cell->proc_dir);
+	remove_proc_entry("vlservers", cell->proc_dir);
+	remove_proc_entry("servers", cell->proc_dir);
+	remove_proc_entry(cell->name, proc_afs);
 
 	_leave("");
 } /* end afs_proc_cell_remove() */
@@ -381,16 +483,16 @@ void afs_proc_cell_remove(afs_cell_t *ce
  */
 static int afs_proc_cell_volumes_open(struct inode *inode, struct file *file)
 {
+	struct afs_cell *cell;
 	struct seq_file *m;
-	afs_cell_t *cell;
 	int ret;
 
-	cell = afs_get_cell_maybe((afs_cell_t**)&PDE(inode)->data);
+	cell = afs_get_cell_maybe((struct afs_cell **) &PDE(inode)->data);
 	if (!cell)
 		return -ENOENT;
 
-	ret = seq_open(file,&afs_proc_cell_volumes_ops);
-	if (ret<0)
+	ret = seq_open(file, &afs_proc_cell_volumes_ops);
+	if (ret < 0)
 		return ret;
 
 	m = file->private_data;
@@ -405,7 +507,7 @@ static int afs_proc_cell_volumes_open(st
  */
 static int afs_proc_cell_volumes_release(struct inode *inode, struct file *file)
 {
-	afs_cell_t *cell = PDE(inode)->data;
+	struct afs_cell *cell = PDE(inode)->data;
 	int ret;
 
 	ret = seq_release(inode,file);
@@ -417,49 +519,51 @@ static int afs_proc_cell_volumes_release
 
 /*****************************************************************************/
 /*
- * set up the iterator to start reading from the cells list and return the first item
+ * set up the iterator to start reading from the cells list and return the
+ * first item
  */
 static void *afs_proc_cell_volumes_start(struct seq_file *m, loff_t *_pos)
 {
 	struct list_head *_p;
-	afs_cell_t *cell = m->private;
+	struct afs_cell *cell = m->private;
 	loff_t pos = *_pos;
 
-	_enter("cell=%p pos=%Ld",cell,*_pos);
+	_enter("cell=%p pos=%Ld", cell, *_pos);
 
 	/* lock the list against modification */
 	down_read(&cell->vl_sem);
 
 	/* allow for the header line */
 	if (!pos)
-		return (void *)1;
+		return (void *) 1;
 	pos--;
 
 	/* find the n'th element in the list */
-	list_for_each(_p,&cell->vl_list)
+	list_for_each(_p, &cell->vl_list)
 		if (!pos--)
 			break;
 
-	return _p!=&cell->vl_list ? _p : NULL;
+	return _p != &cell->vl_list ? _p : NULL;
 } /* end afs_proc_cell_volumes_start() */
 
 /*****************************************************************************/
 /*
  * move to next cell in cells list
  */
-static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v, loff_t *_pos)
+static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v,
+					loff_t *_pos)
 {
 	struct list_head *_p;
-	afs_cell_t *cell = p->private;
+	struct afs_cell *cell = p->private;
 
-	_enter("cell=%p pos=%Ld",cell,*_pos);
+	_enter("cell=%p pos=%Ld", cell, *_pos);
 
 	(*_pos)++;
 
 	_p = v;
-	_p = v==(void*)1 ? cell->vl_list.next : _p->next;
+	_p = v == (void *) 1 ? cell->vl_list.next : _p->next;
 
-	return _p!=&cell->vl_list ? _p : NULL;
+	return _p != &cell->vl_list ? _p : NULL;
 } /* end afs_proc_cell_volumes_next() */
 
 /*****************************************************************************/
@@ -468,7 +572,7 @@ static void *afs_proc_cell_volumes_next(
  */
 static void afs_proc_cell_volumes_stop(struct seq_file *p, void *v)
 {
-	afs_cell_t *cell = p->private;
+	struct afs_cell *cell = p->private;
 
 	up_read(&cell->vl_sem);
 
@@ -480,16 +584,17 @@ static void afs_proc_cell_volumes_stop(s
  */
 static int afs_proc_cell_volumes_show(struct seq_file *m, void *v)
 {
-	afs_vlocation_t *vlocation = list_entry(v,afs_vlocation_t,link);
+	struct afs_vlocation *vlocation =
+		list_entry(v, struct afs_vlocation, link);
 
 	/* display header on line 1 */
-	if (v == (void *)1) {
+	if (v == (void *) 1) {
 		seq_puts(m, "USE VLID[0]  VLID[1]  VLID[2]  NAME\n");
 		return 0;
 	}
 
 	/* display one cell per line on subsequent lines */
-	seq_printf(m,"%3d %08x %08x %08x %s\n",
+	seq_printf(m, "%3d %08x %08x %08x %s\n",
 		   atomic_read(&vlocation->usage),
 		   vlocation->vldb.vid[0],
 		   vlocation->vldb.vid[1],
@@ -502,15 +607,16 @@ static int afs_proc_cell_volumes_show(st
 
 /*****************************************************************************/
 /*
- * open "/proc/fs/afs/<cell>/vlservers" which provides a list of volume location server
+ * open "/proc/fs/afs/<cell>/vlservers" which provides a list of volume
+ * location server
  */
 static int afs_proc_cell_vlservers_open(struct inode *inode, struct file *file)
 {
+	struct afs_cell *cell;
 	struct seq_file *m;
-	afs_cell_t *cell;
 	int ret;
 
-	cell = afs_get_cell_maybe((afs_cell_t**)&PDE(inode)->data);
+	cell = afs_get_cell_maybe((struct afs_cell**)&PDE(inode)->data);
 	if (!cell)
 		return -ENOENT;
 
@@ -528,9 +634,10 @@ static int afs_proc_cell_vlservers_open(
 /*
  * close the file and release the ref to the cell
  */
-static int afs_proc_cell_vlservers_release(struct inode *inode, struct file *file)
+static int afs_proc_cell_vlservers_release(struct inode *inode,
+					   struct file *file)
 {
-	afs_cell_t *cell = PDE(inode)->data;
+	struct afs_cell *cell = PDE(inode)->data;
 	int ret;
 
 	ret = seq_release(inode,file);
@@ -542,24 +649,25 @@ static int afs_proc_cell_vlservers_relea
 
 /*****************************************************************************/
 /*
- * set up the iterator to start reading from the cells list and return the first item
+ * set up the iterator to start reading from the cells list and return the
+ * first item
  */
 static void *afs_proc_cell_vlservers_start(struct seq_file *m, loff_t *_pos)
 {
-	afs_cell_t *cell = m->private;
+	struct afs_cell *cell = m->private;
 	loff_t pos = *_pos;
 
-	_enter("cell=%p pos=%Ld",cell,*_pos);
+	_enter("cell=%p pos=%Ld", cell, *_pos);
 
 	/* lock the list against modification */
 	down_read(&cell->vl_sem);
 
 	/* allow for the header line */
 	if (!pos)
-		return (void *)1;
+		return (void *) 1;
 	pos--;
 
-	if (pos>=cell->vl_naddrs)
+	if (pos >= cell->vl_naddrs)
 		return NULL;
 
 	return &cell->vl_addrs[pos];
@@ -569,16 +677,17 @@ static void *afs_proc_cell_vlservers_sta
 /*
  * move to next cell in cells list
  */
-static void *afs_proc_cell_vlservers_next(struct seq_file *p, void *v, loff_t *_pos)
+static void *afs_proc_cell_vlservers_next(struct seq_file *p, void *v,
+					  loff_t *_pos)
 {
-	afs_cell_t *cell = p->private;
+	struct afs_cell *cell = p->private;
 	loff_t pos;
 
-	_enter("cell=%p{nad=%u} pos=%Ld",cell,cell->vl_naddrs,*_pos);
+	_enter("cell=%p{nad=%u} pos=%Ld", cell, cell->vl_naddrs, *_pos);
 
 	pos = *_pos;
 	(*_pos)++;
-	if (pos>=cell->vl_naddrs)
+	if (pos >= cell->vl_naddrs)
 		return NULL;
 
 	return &cell->vl_addrs[pos];
@@ -590,7 +699,7 @@ static void *afs_proc_cell_vlservers_nex
  */
 static void afs_proc_cell_vlservers_stop(struct seq_file *p, void *v)
 {
-	afs_cell_t *cell = p->private;
+	struct afs_cell *cell = p->private;
 
 	up_read(&cell->vl_sem);
 
@@ -605,33 +714,34 @@ static int afs_proc_cell_vlservers_show(
 	struct in_addr *addr = v;
 
 	/* display header on line 1 */
-	if (v == (struct in_addr *)1) {
-		seq_puts(m,"ADDRESS\n");
+	if (v == (struct in_addr *) 1) {
+		seq_puts(m, "ADDRESS\n");
 		return 0;
 	}
 
 	/* display one cell per line on subsequent lines */
-	seq_printf(m,"%u.%u.%u.%u\n",NIPQUAD(addr->s_addr));
+	seq_printf(m, "%u.%u.%u.%u\n", NIPQUAD(addr->s_addr));
 
 	return 0;
 } /* end afs_proc_cell_vlservers_show() */
 
 /*****************************************************************************/
 /*
- * open "/proc/fs/afs/<cell>/servers" which provides a summary of active servers
+ * open "/proc/fs/afs/<cell>/servers" which provides a summary of active
+ * servers
  */
 static int afs_proc_cell_servers_open(struct inode *inode, struct file *file)
 {
+	struct afs_cell *cell;
 	struct seq_file *m;
-	afs_cell_t *cell;
 	int ret;
 
-	cell = afs_get_cell_maybe((afs_cell_t**)&PDE(inode)->data);
+	cell = afs_get_cell_maybe((struct afs_cell **) &PDE(inode)->data);
 	if (!cell)
 		return -ENOENT;
 
-	ret = seq_open(file,&afs_proc_cell_servers_ops);
-	if (ret<0)
+	ret = seq_open(file, &afs_proc_cell_servers_ops);
+	if (ret < 0)
 		return ret;
 
 	m = file->private_data;
@@ -644,12 +754,13 @@ static int afs_proc_cell_servers_open(st
 /*
  * close the file and release the ref to the cell
  */
-static int afs_proc_cell_servers_release(struct inode *inode, struct file *file)
+static int afs_proc_cell_servers_release(struct inode *inode,
+					 struct file *file)
 {
-	afs_cell_t *cell = PDE(inode)->data;
+	struct afs_cell *cell = PDE(inode)->data;
 	int ret;
 
-	ret = seq_release(inode,file);
+	ret = seq_release(inode, file);
 
 	afs_put_cell(cell);
 
@@ -658,49 +769,51 @@ static int afs_proc_cell_servers_release
 
 /*****************************************************************************/
 /*
- * set up the iterator to start reading from the cells list and return the first item
+ * set up the iterator to start reading from the cells list and return the
+ * first item
  */
 static void *afs_proc_cell_servers_start(struct seq_file *m, loff_t *_pos)
 {
 	struct list_head *_p;
-	afs_cell_t *cell = m->private;
+	struct afs_cell *cell = m->private;
 	loff_t pos = *_pos;
 
-	_enter("cell=%p pos=%Ld",cell,*_pos);
+	_enter("cell=%p pos=%Ld", cell, *_pos);
 
 	/* lock the list against modification */
 	read_lock(&cell->sv_lock);
 
 	/* allow for the header line */
 	if (!pos)
-		return (void *)1;
+		return (void *) 1;
 	pos--;
 
 	/* find the n'th element in the list */
-	list_for_each(_p,&cell->sv_list)
+	list_for_each(_p, &cell->sv_list)
 		if (!pos--)
 			break;
 
-	return _p!=&cell->sv_list ? _p : NULL;
+	return _p != &cell->sv_list ? _p : NULL;
 } /* end afs_proc_cell_servers_start() */
 
 /*****************************************************************************/
 /*
  * move to next cell in cells list
  */
-static void *afs_proc_cell_servers_next(struct seq_file *p, void *v, loff_t *_pos)
+static void *afs_proc_cell_servers_next(struct seq_file *p, void *v,
+					loff_t *_pos)
 {
 	struct list_head *_p;
-	afs_cell_t *cell = p->private;
+	struct afs_cell *cell = p->private;
 
-	_enter("cell=%p pos=%Ld",cell,*_pos);
+	_enter("cell=%p pos=%Ld", cell, *_pos);
 
 	(*_pos)++;
 
 	_p = v;
-	_p = v==(void*)1 ? cell->sv_list.next : _p->next;
+	_p = v == (void *) 1 ? cell->sv_list.next : _p->next;
 
-	return _p!=&cell->sv_list ? _p : NULL;
+	return _p != &cell->sv_list ? _p : NULL;
 } /* end afs_proc_cell_servers_next() */
 
 /*****************************************************************************/
@@ -709,7 +822,7 @@ static void *afs_proc_cell_servers_next(
  */
 static void afs_proc_cell_servers_stop(struct seq_file *p, void *v)
 {
-	afs_cell_t *cell = p->private;
+	struct afs_cell *cell = p->private;
 
 	read_unlock(&cell->sv_lock);
 
@@ -721,18 +834,18 @@ static void afs_proc_cell_servers_stop(s
  */
 static int afs_proc_cell_servers_show(struct seq_file *m, void *v)
 {
-	afs_server_t *server = list_entry(v,afs_server_t,link);
+	struct afs_server *server = list_entry(v, struct afs_server, link);
 	char ipaddr[20];
 
 	/* display header on line 1 */
-	if (v == (void *)1) {
+	if (v == (void *) 1) {
 		seq_puts(m, "USE ADDR            STATE\n");
 		return 0;
 	}
 
 	/* display one cell per line on subsequent lines */
-	sprintf(ipaddr,"%u.%u.%u.%u",NIPQUAD(server->addr));
-	seq_printf(m,"%3d %-15.15s %5d\n",
+	sprintf(ipaddr, "%u.%u.%u.%u", NIPQUAD(server->addr));
+	seq_printf(m, "%3d %-15.15s %5d\n",
 		   atomic_read(&server->usage),
 		   ipaddr,
 		   server->fs_state
diff -puN fs/afs/server.c~linus fs/afs/server.c
--- 25/fs/afs/server.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/server.c	2004-01-19 22:17:23.000000000 -0800
@@ -26,11 +26,13 @@ spinlock_t afs_server_peer_lock = SPIN_L
 #define FS_SERVICE_ID		1	/* AFS Volume Location Service ID */
 #define VL_SERVICE_ID		52	/* AFS Volume Location Service ID */
 
-static void __afs_server_timeout(afs_timer_t *timer)
+static void __afs_server_timeout(struct afs_timer *timer)
 {
-	afs_server_t *server = list_entry(timer,afs_server_t,timeout);
+	struct afs_server *server =
+		list_entry(timer, struct afs_server, timeout);
 
-	_debug("SERVER TIMEOUT [%p{u=%d}]",server,atomic_read(&server->usage));
+	_debug("SERVER TIMEOUT [%p{u=%d}]",
+	       server, atomic_read(&server->usage));
 
 	afs_server_do_timeout(server);
 }
@@ -44,23 +46,23 @@ static const struct afs_timer_ops afs_se
  * lookup a server record in a cell
  * - TODO: search the cell's server list
  */
-int afs_server_lookup(afs_cell_t *cell, const struct in_addr *addr, afs_server_t **_server)
+int afs_server_lookup(struct afs_cell *cell, const struct in_addr *addr,
+		      struct afs_server **_server)
 {
-	struct list_head *_p;
-	afs_server_t *server, *active, *zombie;
+	struct afs_server *server, *active, *zombie;
 	int loop;
 
-	_enter("%p,%08x,",cell,ntohl(addr->s_addr));
+	_enter("%p,%08x,", cell, ntohl(addr->s_addr));
 
 	/* allocate and initialise a server record */
-	server = kmalloc(sizeof(afs_server_t),GFP_KERNEL);
+	server = kmalloc(sizeof(struct afs_server), GFP_KERNEL);
 	if (!server) {
 		_leave(" = -ENOMEM");
 		return -ENOMEM;
 	}
 
-	memset(server,0,sizeof(afs_server_t));
-	atomic_set(&server->usage,1);
+	memset(server, 0, sizeof(struct afs_server));
+	atomic_set(&server->usage, 1);
 
 	INIT_LIST_HEAD(&server->link);
 	init_rwsem(&server->sem);
@@ -69,43 +71,39 @@ int afs_server_lookup(afs_cell_t *cell, 
 	INIT_LIST_HEAD(&server->cb_promises);
 	spin_lock_init(&server->cb_lock);
 
-	for (loop=0; loop<AFS_SERVER_CONN_LIST_SIZE; loop++)
+	for (loop = 0; loop < AFS_SERVER_CONN_LIST_SIZE; loop++)
 		server->fs_conn_cnt[loop] = 4;
 
-	memcpy(&server->addr,addr,sizeof(struct in_addr));
+	memcpy(&server->addr, addr, sizeof(struct in_addr));
 	server->addr.s_addr = addr->s_addr;
 
-	afs_timer_init(&server->timeout,&afs_server_timer_ops);
+	afs_timer_init(&server->timeout, &afs_server_timer_ops);
 
 	/* add to the cell */
 	write_lock(&cell->sv_lock);
 
 	/* check the active list */
-	list_for_each(_p,&cell->sv_list) {
-		active = list_entry(_p,afs_server_t,link);
-
-		if (active->addr.s_addr==addr->s_addr)
+	list_for_each_entry(active, &cell->sv_list, link) {
+		if (active->addr.s_addr == addr->s_addr)
 			goto use_active_server;
 	}
 
 	/* check the inactive list */
 	spin_lock(&cell->sv_gylock);
-	list_for_each(_p,&cell->sv_graveyard) {
-		zombie = list_entry(_p,afs_server_t,link);
-
-		if (zombie->addr.s_addr==addr->s_addr)
+	list_for_each_entry(zombie, &cell->sv_graveyard, link) {
+		if (zombie->addr.s_addr == addr->s_addr)
 			goto resurrect_server;
 	}
 	spin_unlock(&cell->sv_gylock);
 
 	afs_get_cell(cell);
 	server->cell = cell;
-	list_add_tail(&server->link,&cell->sv_list);
+	list_add_tail(&server->link, &cell->sv_list);
 
 	write_unlock(&cell->sv_lock);
 
 	*_server = server;
-	_leave(" = 0 (%p)",server);
+	_leave(" = 0 (%p)", server);
 	return 0;
 
 	/* found a matching active server */
@@ -117,15 +115,16 @@ int afs_server_lookup(afs_cell_t *cell, 
 	kfree(server);
 
 	*_server = active;
-	_leave(" = 0 (%p)",active);
+	_leave(" = 0 (%p)", active);
 	return 0;
 
-	/* found a matching server in the graveyard, so resurrect it and dispose of the new rec */
+	/* found a matching server in the graveyard, so resurrect it and
+	 * dispose of the new record */
  resurrect_server:
 	_debug("resurrecting server");
 
 	list_del(&zombie->link);
-	list_add_tail(&zombie->link,&cell->sv_list);
+	list_add_tail(&zombie->link, &cell->sv_list);
 	afs_get_server(zombie);
 	afs_kafstimod_del_timer(&zombie->timeout);
 	spin_unlock(&cell->sv_gylock);
@@ -134,7 +133,7 @@ int afs_server_lookup(afs_cell_t *cell, 
 	kfree(server);
 
 	*_server = zombie;
-	_leave(" = 0 (%p)",zombie);
+	_leave(" = 0 (%p)", zombie);
 	return 0;
 
 } /* end afs_server_lookup() */
@@ -144,22 +143,22 @@ int afs_server_lookup(afs_cell_t *cell, 
  * destroy a server record
  * - removes from the cell list
  */
-void afs_put_server(afs_server_t *server)
+void afs_put_server(struct afs_server *server)
 {
-	afs_cell_t *cell;
+	struct afs_cell *cell;
 
 	if (!server)
 		return;
 
-	_enter("%p",server);
+	_enter("%p", server);
 
 	cell = server->cell;
 
 	/* sanity check */
-	if (atomic_read(&server->usage)<=0)
-		BUG();
+	BUG_ON(atomic_read(&server->usage) <= 0);
 
-	/* to prevent a race, the decrement and the dequeue must be effectively atomic */
+	/* to prevent a race, the decrement and the dequeue must be effectively
+	 * atomic */
 	write_lock(&cell->sv_lock);
 
 	if (likely(!atomic_dec_and_test(&server->usage))) {
@@ -170,10 +169,10 @@ void afs_put_server(afs_server_t *server
 
 	spin_lock(&cell->sv_gylock);
 	list_del(&server->link);
-	list_add_tail(&server->link,&cell->sv_graveyard);
+	list_add_tail(&server->link, &cell->sv_graveyard);
 
 	/* time out in 10 secs */
-	afs_kafstimod_add_timer(&server->timeout,10*HZ);
+	afs_kafstimod_add_timer(&server->timeout, 10 * HZ);
 
 	spin_unlock(&cell->sv_gylock);
 	write_unlock(&cell->sv_lock);
@@ -186,21 +185,21 @@ void afs_put_server(afs_server_t *server
  * timeout server record
  * - removes from the cell's graveyard if the usage count is zero
  */
-void afs_server_do_timeout(afs_server_t *server)
+void afs_server_do_timeout(struct afs_server *server)
 {
 	struct rxrpc_peer *peer;
-	afs_cell_t *cell;
+	struct afs_cell *cell;
 	int loop;
 
-	_enter("%p",server);
+	_enter("%p", server);
 
 	cell = server->cell;
 
-	if (atomic_read(&server->usage)<0) BUG();
+	BUG_ON(atomic_read(&server->usage) < 0);
 
 	/* remove from graveyard if still dead */
 	spin_lock(&cell->vl_gylock);
-	if (atomic_read(&server->usage)==0)
+	if (atomic_read(&server->usage) == 0)
 		list_del_init(&server->link);
 	else
 		server = NULL;
@@ -224,7 +223,7 @@ void afs_server_do_timeout(afs_server_t 
 	spin_unlock(&afs_server_peer_lock);
 
 	/* finish cleaning up the server */
-	for (loop=AFS_SERVER_CONN_LIST_SIZE-1; loop>=0; loop--)
+	for (loop = AFS_SERVER_CONN_LIST_SIZE - 1; loop >= 0; loop--)
 		if (server->fs_conn[loop])
 			rxrpc_put_connection(server->fs_conn[loop]);
 
@@ -240,7 +239,8 @@ void afs_server_do_timeout(afs_server_t 
 /*
  * get a callslot on a connection to the fileserver on the specified server
  */
-int afs_server_request_callslot(afs_server_t *server, struct afs_server_callslot *callslot)
+int afs_server_request_callslot(struct afs_server *server,
+				struct afs_server_callslot *callslot)
 {
 	struct afs_server_callslot *pcallslot;
 	struct rxrpc_connection *conn;
@@ -262,10 +262,10 @@ int afs_server_request_callslot(afs_serv
 
 	/* resurrect the server if it's death timeout has expired */
 	if (server->fs_state) {
-		if (time_before(jiffies,server->fs_dead_jif)) {
+		if (time_before(jiffies, server->fs_dead_jif)) {
 			ret = server->fs_state;
 			spin_unlock(&server->fs_lock);
-			_leave(" = %d [still dead]",ret);
+			_leave(" = %d [still dead]", ret);
 			return ret;
 		}
 
@@ -273,8 +273,8 @@ int afs_server_request_callslot(afs_serv
 	}
 
 	/* try and find a connection that has spare callslots */
-	for (nconn=0; nconn<AFS_SERVER_CONN_LIST_SIZE; nconn++) {
-		if (server->fs_conn_cnt[nconn]>0) {
+	for (nconn = 0; nconn < AFS_SERVER_CONN_LIST_SIZE; nconn++) {
+		if (server->fs_conn_cnt[nconn] > 0) {
 			server->fs_conn_cnt[nconn]--;
 			spin_unlock(&server->fs_lock);
 			callslot->nconn = nconn;
@@ -282,9 +282,10 @@ int afs_server_request_callslot(afs_serv
 		}
 	}
 
-	/* none were available - wait interruptibly for one to become available */
+	/* none were available - wait interruptibly for one to become
+	 * available */
 	set_current_state(TASK_INTERRUPTIBLE);
-	list_add_tail(&callslot->link,&server->fs_callq);
+	list_add_tail(&callslot->link, &server->fs_callq);
 	spin_unlock(&server->fs_lock);
 
 	while (!callslot->ready && !signal_pending(current)) {
@@ -303,22 +304,24 @@ int afs_server_request_callslot(afs_serv
 
 	nconn = callslot->nconn;
 
-	/* if interrupted, we must release any slot we also got before returning an error */
+	/* if interrupted, we must release any slot we also got before
+	 * returning an error */
 	if (signal_pending(current)) {
 		ret = -EINTR;
 		goto error_release;
 	}
 
-	/* if we were woken up with an error, then pass that error back to the called */
-	if (nconn<0) {
-		_leave(" = %d",callslot->errno);
+	/* if we were woken up with an error, then pass that error back to the
+	 * called */
+	if (nconn < 0) {
+		_leave(" = %d", callslot->errno);
 		return callslot->errno;
 	}
 
 	/* were we given a connection directly? */
 	if (callslot->conn) {
 		/* yes - use it */
-		_leave(" = 0 (nc=%d)",nconn);
+		_leave(" = 0 (nc=%d)", nconn);
 		return 0;
 	}
 
@@ -347,7 +350,7 @@ int afs_server_request_callslot(afs_serv
 					      NULL,
 					      &server->fs_conn[nconn]);
 
-		if (ret<0)
+		if (ret < 0)
 			goto error_release_upw;
 
 		callslot->conn = server->fs_conn[0];
@@ -364,10 +367,11 @@ int afs_server_request_callslot(afs_serv
 	up_write(&server->sem);
 
  error_release:
-	/* either release the callslot or pass it along to another deserving task */
+	/* either release the callslot or pass it along to another deserving
+	 * task */
 	spin_lock(&server->fs_lock);
 
-	if (nconn<0) {
+	if (nconn < 0) {
 		/* no callslot allocated */
 	}
 	else if (list_empty(&server->fs_callq)) {
@@ -377,13 +381,15 @@ int afs_server_request_callslot(afs_serv
 	}
 	else {
 		/* someone's waiting - dequeue them and wake them up */
-		pcallslot = list_entry(server->fs_callq.next,struct afs_server_callslot,link);
+		pcallslot = list_entry(server->fs_callq.next,
+				       struct afs_server_callslot, link);
 		list_del_init(&pcallslot->link);
 
 		pcallslot->errno = server->fs_state;
 		if (!pcallslot->errno) {
 			/* pass them out callslot details */
-			callslot->conn = xchg(&pcallslot->conn,callslot->conn);
+			callslot->conn = xchg(&pcallslot->conn,
+					      callslot->conn);
 			pcallslot->nconn = nconn;
 			callslot->nconn = nconn = -1;
 		}
@@ -392,10 +398,10 @@ int afs_server_request_callslot(afs_serv
 		spin_unlock(&server->fs_lock);
 	}
 
-	if (callslot->conn) rxrpc_put_connection(callslot->conn);
+	rxrpc_put_connection(callslot->conn);
 	callslot->conn = NULL;
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 
 } /* end afs_server_request_callslot() */
@@ -405,7 +411,8 @@ int afs_server_request_callslot(afs_serv
  * release a callslot back to the server
  * - transfers the RxRPC connection to the next pending callslot if possible
  */
-void afs_server_release_callslot(afs_server_t *server, struct afs_server_callslot *callslot)
+void afs_server_release_callslot(struct afs_server *server,
+				 struct afs_server_callslot *callslot)
 {
 	struct afs_server_callslot *pcallslot;
 
@@ -414,7 +421,7 @@ void afs_server_release_callslot(afs_ser
 	       server->fs_conn_cnt[callslot->nconn],
 	       callslot->nconn);
 
-	if (callslot->nconn<0) BUG();
+	BUG_ON(callslot->nconn < 0);
 
 	spin_lock(&server->fs_lock);
 
@@ -425,13 +432,14 @@ void afs_server_release_callslot(afs_ser
 	}
 	else {
 		/* someone's waiting - dequeue them and wake them up */
-		pcallslot = list_entry(server->fs_callq.next,struct afs_server_callslot,link);
+		pcallslot = list_entry(server->fs_callq.next,
+				       struct afs_server_callslot, link);
 		list_del_init(&pcallslot->link);
 
 		pcallslot->errno = server->fs_state;
 		if (!pcallslot->errno) {
 			/* pass them out callslot details */
-			callslot->conn = xchg(&pcallslot->conn,callslot->conn);
+			callslot->conn = xchg(&pcallslot->conn, callslot->conn);
 			pcallslot->nconn = callslot->nconn;
 			callslot->nconn = -1;
 		}
@@ -441,21 +449,23 @@ void afs_server_release_callslot(afs_ser
 		spin_unlock(&server->fs_lock);
 	}
 
-	if (callslot->conn) rxrpc_put_connection(callslot->conn);
+	rxrpc_put_connection(callslot->conn);
 
 	_leave("");
 } /* end afs_server_release_callslot() */
 
 /*****************************************************************************/
 /*
- * get a handle to a connection to the vlserver (volume location) on the specified server
+ * get a handle to a connection to the vlserver (volume location) on the
+ * specified server
  */
-int afs_server_get_vlconn(afs_server_t *server, struct rxrpc_connection **_conn)
+int afs_server_get_vlconn(struct afs_server *server,
+			  struct rxrpc_connection **_conn)
 {
 	struct rxrpc_connection *conn;
 	int ret;
 
-	_enter("%p,",server);
+	_enter("%p,", server);
 
 	ret = 0;
 	conn = NULL;
@@ -479,7 +489,7 @@ int afs_server_get_vlconn(afs_server_t *
 						      NULL,
 						      &server->vlserver);
 		}
-		if (ret==0) {
+		if (ret == 0) {
 			rxrpc_get_connection(server->vlserver);
 			conn = server->vlserver;
 		}
@@ -487,6 +497,6 @@ int afs_server_get_vlconn(afs_server_t *
 	}
 
 	*_conn = conn;
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end afs_server_get_vlconn() */
diff -puN fs/afs/server.h~linus fs/afs/server.h
--- 25/fs/afs/server.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/server.h	2004-01-19 22:17:23.000000000 -0800
@@ -26,10 +26,10 @@ extern spinlock_t afs_server_peer_lock;
 struct afs_server
 {
 	atomic_t		usage;
-	afs_cell_t		*cell;		/* cell in which server resides */
+	struct afs_cell		*cell;		/* cell in which server resides */
 	struct list_head	link;		/* link in cell's server list */
 	struct rw_semaphore	sem;		/* access lock */
-	afs_timer_t		timeout;	/* graveyard timeout */
+	struct afs_timer	timeout;	/* graveyard timeout */
 	struct in_addr		addr;		/* server address */
 	struct rxrpc_peer	*peer;		/* peer record for this server */
 	struct rxrpc_connection	*vlserver;	/* connection to the volume location service */
@@ -50,20 +50,25 @@ struct afs_server
 	spinlock_t		cb_lock;	/* access lock */
 };
 
-extern int afs_server_lookup(afs_cell_t *cell, const struct in_addr *addr, afs_server_t **_server);
+extern int afs_server_lookup(struct afs_cell *cell,
+			     const struct in_addr *addr,
+			     struct afs_server **_server);
 
 #define afs_get_server(S) do { atomic_inc(&(S)->usage); } while(0)
 
-extern void afs_put_server(afs_server_t *server);
-extern void afs_server_do_timeout(afs_server_t *server);
+extern void afs_put_server(struct afs_server *server);
+extern void afs_server_do_timeout(struct afs_server *server);
 
-extern int afs_server_find_by_peer(const struct rxrpc_peer *peer, afs_server_t **_server);
+extern int afs_server_find_by_peer(const struct rxrpc_peer *peer,
+				   struct afs_server **_server);
 
-extern int afs_server_get_vlconn(afs_server_t *server, struct rxrpc_connection **_conn);
+extern int afs_server_get_vlconn(struct afs_server *server,
+				 struct rxrpc_connection **_conn);
 
-static inline afs_server_t *afs_server_get_from_peer(struct rxrpc_peer *peer)
+static inline
+struct afs_server *afs_server_get_from_peer(struct rxrpc_peer *peer)
 {
-	afs_server_t *server;
+	struct afs_server *server;
 
 	spin_lock(&afs_server_peer_lock);
 	server = peer->user;
@@ -88,10 +93,10 @@ struct afs_server_callslot
 	int			errno;		/* error number if nconn==-1 */
 };
 
-extern int afs_server_request_callslot(afs_server_t *server,
+extern int afs_server_request_callslot(struct afs_server *server,
 				       struct afs_server_callslot *callslot);
 
-extern void afs_server_release_callslot(afs_server_t *server,
+extern void afs_server_release_callslot(struct afs_server *server,
 					struct afs_server_callslot *callslot);
 
 #endif /* _LINUX_AFS_SERVER_H */
diff -puN fs/afs/super.c~linus fs/afs/super.c
--- 25/fs/afs/super.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/super.c	2004-01-19 22:17:23.000000000 -0800
@@ -35,14 +35,6 @@ struct afs_mount_params {
 	struct afs_volume	*volume;
 };
 
-static inline char *strdup(const char *s)
-{
-	char *ns = kmalloc(strlen(s) + 1, GFP_KERNEL);
-	if (ns)
-		strcpy(ns, s);
-	return ns;
-}
-
 static void afs_i_init_once(void *foo, kmem_cache_t *cachep,
 			    unsigned long flags);
 
@@ -94,7 +86,7 @@ int __init afs_fs_init(void)
 
 	ret = -ENOMEM;
 	afs_inode_cachep = kmem_cache_create("afs_inode_cache",
-					     sizeof(afs_vnode_t),
+					     sizeof(struct afs_vnode),
 					     0,
 					     SLAB_HWCACHE_ALIGN,
 					     afs_i_init_once,
@@ -164,8 +156,8 @@ static int want_no_value(char *const *_v
 /*****************************************************************************/
 /*
  * parse the mount options
- * - this function has been shamelessly adapted from the ext3 fs which shamelessly adapted it from
- *   the msdos fs
+ * - this function has been shamelessly adapted from the ext3 fs which
+ *   shamelessly adapted it from the msdos fs
  */
 static int afs_super_parse_options(struct afs_mount_params *params,
 				   char *options,
@@ -243,9 +235,9 @@ static int afs_fill_super(struct super_b
 {
 	struct afs_mount_params *params = data;
 	struct afs_super_info *as = NULL;
+	struct afs_fid fid;
 	struct dentry *root = NULL;
 	struct inode *inode = NULL;
-	afs_fid_t fid;
 	int ret;
 
 	kenter("");
@@ -395,7 +387,7 @@ static void afs_put_super(struct super_b
 static void afs_i_init_once(void *_vnode, kmem_cache_t *cachep,
 			    unsigned long flags)
 {
-	afs_vnode_t *vnode = (afs_vnode_t *) _vnode;
+	struct afs_vnode *vnode = (struct afs_vnode *) _vnode;
 
 	if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
 	    SLAB_CTOR_CONSTRUCTOR) {
@@ -417,9 +409,9 @@ static void afs_i_init_once(void *_vnode
  */
 static struct inode *afs_alloc_inode(struct super_block *sb)
 {
-	afs_vnode_t *vnode;
+	struct afs_vnode *vnode;
 
-	vnode = (afs_vnode_t *)
+	vnode = (struct afs_vnode *)
 		kmem_cache_alloc(afs_inode_cachep, SLAB_KERNEL);
 	if (!vnode)
 		return NULL;
diff -puN fs/afs/types.h~linus fs/afs/types.h
--- 25/fs/afs/types.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/types.h	2004-01-19 22:17:23.000000000 -0800
@@ -20,21 +20,6 @@ typedef unsigned			afs_volid_t;
 typedef unsigned			afs_vnodeid_t;
 typedef unsigned long long		afs_dataversion_t;
 
-typedef struct afs_async_op		afs_async_op_t;
-typedef struct afs_callback		afs_callback_t;
-typedef struct afs_cell			afs_cell_t;
-typedef struct afs_fid			afs_fid_t;
-typedef struct afs_file_status		afs_file_status_t;
-typedef struct afs_server		afs_server_t;
-typedef struct afs_timer		afs_timer_t;
-typedef struct afs_vlocation		afs_vlocation_t;
-typedef struct afs_vnode		afs_vnode_t;
-typedef struct afs_volsync		afs_volsync_t;
-typedef struct afs_volume		afs_volume_t;
-typedef struct afs_volume_info		afs_volume_info_t;
-
-typedef struct afsvl_dbentry		afsvl_dbentry_t;
-
 typedef enum {
 	AFSVL_RWVOL,			/* read/write volume */
 	AFSVL_ROVOL,			/* read-only volume */
@@ -52,6 +37,9 @@ typedef enum {
 
 #ifdef __KERNEL__
 
+struct afs_cell;
+struct afs_vnode;
+
 /*****************************************************************************/
 /*
  * AFS file identifier
@@ -76,8 +64,8 @@ typedef enum {
 
 struct afs_callback
 {
-	afs_server_t		*server;	/* server that made the promise */
-	afs_fid_t		fid;		/* file identifier */
+	struct afs_server	*server;	/* server that made the promise */
+	struct afs_fid		fid;		/* file identifier */
 	unsigned		version;	/* callback version */
 	unsigned		expiry;		/* time at which expires */
 	afs_callback_type_t	type;		/* type of callback */
@@ -120,7 +108,7 @@ struct afs_file_status
 	unsigned		caller_access;	/* access rights for authenticated caller */
 	unsigned		anon_access;	/* access rights for unauthenticated caller */
 	umode_t			mode;		/* UNIX mode */
-	afs_fid_t		parent;		/* parent file ID */
+	struct afs_fid		parent;		/* parent file ID */
 	time_t			mtime_client;	/* last time client changed data */
 	time_t			mtime_server;	/* last time server changed data */
 };
diff -puN fs/afs/vlclient.c~linus fs/afs/vlclient.c
--- 25/fs/afs/vlclient.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/vlclient.c	2004-01-19 22:17:23.000000000 -0800
@@ -39,7 +39,8 @@ static void afs_rxvl_aemap(struct rxrpc_
 {
 	int err;
 
-	_enter("{%u,%u,%d}",call->app_err_state,call->app_abort_code,call->app_errno);
+	_enter("{%u,%u,%d}",
+	       call->app_err_state, call->app_abort_code, call->app_errno);
 
 	switch (call->app_err_state) {
 	case RXRPC_ESTATE_LOCAL_ABORT:
@@ -92,10 +93,8 @@ static void afs_rxvl_aemap(struct rxrpc_
 /*
  * probe a volume location server to see if it is still alive
  */
-int afs_rxvl_probe(afs_server_t *server, int alloc_flags)
+int afs_rxvl_probe(struct afs_server *server, int alloc_flags)
 {
-	DECLARE_WAITQUEUE(myself,current);
-
 	struct rxrpc_connection *conn;
 	struct rxrpc_call *call;
 	struct iovec piov[1];
@@ -103,21 +102,23 @@ int afs_rxvl_probe(afs_server_t *server,
 	int ret;
 	u32 param[1];
 
+	DECLARE_WAITQUEUE(myself, current);
+
 	/* get hold of the vlserver connection */
-	ret = afs_server_get_vlconn(server,&conn);
-	if (ret<0)
+	ret = afs_server_get_vlconn(server, &conn);
+	if (ret < 0)
 		goto out;
 
 	/* create a call through that connection */
-	ret = rxrpc_create_call(conn,NULL,NULL,afs_rxvl_aemap,&call);
-	if (ret<0) {
-		printk("kAFS: Unable to create call: %d\n",ret);
+	ret = rxrpc_create_call(conn, NULL, NULL, afs_rxvl_aemap, &call);
+	if (ret < 0) {
+		printk("kAFS: Unable to create call: %d\n", ret);
 		goto out_put_conn;
 	}
 	call->app_opcode = VLPROBE;
 
 	/* we want to get event notifications from the call */
-	add_wait_queue(&call->waitq,&myself);
+	add_wait_queue(&call->waitq, &myself);
 
 	/* marshall the parameters */
 	param[0] = htonl(VLPROBE);
@@ -125,14 +126,15 @@ int afs_rxvl_probe(afs_server_t *server,
 	piov[0].iov_base = param;
 
 	/* send the parameters to the server */
-	ret = rxrpc_call_write_data(call,1,piov,RXRPC_LAST_PACKET,alloc_flags,0,&sent);
-	if (ret<0)
+	ret = rxrpc_call_write_data(call, 1, piov, RXRPC_LAST_PACKET,
+				    alloc_flags, 0, &sent);
+	if (ret < 0)
 		goto abort;
 
 	/* wait for the reply to completely arrive */
 	for (;;) {
 		set_current_state(TASK_INTERRUPTIBLE);
-		if (call->app_call_state!=RXRPC_CSTATE_CLNT_RCV_REPLY ||
+		if (call->app_call_state != RXRPC_CSTATE_CLNT_RCV_REPLY ||
 		    signal_pending(current))
 			break;
 		schedule();
@@ -158,12 +160,12 @@ int afs_rxvl_probe(afs_server_t *server,
 
  abort:
 	set_current_state(TASK_UNINTERRUPTIBLE);
-	rxrpc_call_abort(call,ret);
+	rxrpc_call_abort(call, ret);
 	schedule();
 
  out_unwait:
 	set_current_state(TASK_RUNNING);
-	remove_wait_queue(&call->waitq,&myself);
+	remove_wait_queue(&call->waitq, &myself);
 	rxrpc_put_call(call);
  out_put_conn:
 	rxrpc_put_connection(conn);
@@ -176,10 +178,12 @@ int afs_rxvl_probe(afs_server_t *server,
 /*
  * look up a volume location database entry by name
  */
-int afs_rxvl_get_entry_by_name(afs_server_t *server, const char *volname, unsigned volnamesz,
+int afs_rxvl_get_entry_by_name(struct afs_server *server,
+			       const char *volname,
+			       unsigned volnamesz,
 			       struct afs_cache_vlocation *entry)
 {
-	DECLARE_WAITQUEUE(myself,current);
+	DECLARE_WAITQUEUE(myself, current);
 
 	struct rxrpc_connection *conn;
 	struct rxrpc_call *call;
@@ -195,7 +199,7 @@ int afs_rxvl_get_entry_by_name(afs_serve
 
 	/* get hold of the vlserver connection */
 	ret = afs_server_get_vlconn(server, &conn);
-	if (ret<0)
+	if (ret < 0)
 		goto out;
 
 	/* create a call through that connection */
@@ -211,7 +215,7 @@ int afs_rxvl_get_entry_by_name(afs_serve
 
 	/* marshall the parameters */
 	piov[1].iov_len = volnamesz;
-	piov[1].iov_base = (char*) volname;
+	piov[1].iov_base = (char *) volname;
 
 	zero = 0;
 	piov[2].iov_len = (4 - (piov[1].iov_len & 3)) & 3;
@@ -224,14 +228,17 @@ int afs_rxvl_get_entry_by_name(afs_serve
 	piov[0].iov_base = param;
 
 	/* send the parameters to the server */
-	ret = rxrpc_call_write_data(call, 3, piov, RXRPC_LAST_PACKET, GFP_NOFS, 0, &sent);
-	if (ret<0)
+	ret = rxrpc_call_write_data(call, 3, piov, RXRPC_LAST_PACKET, GFP_NOFS,
+				    0, &sent);
+	if (ret < 0)
 		goto abort;
 
 	/* wait for the reply to completely arrive */
 	bp = rxrpc_call_alloc_scratch(call, 384);
 
-	ret = rxrpc_call_read_data(call, bp, 384, RXRPC_CALL_READ_BLOCK|RXRPC_CALL_READ_ALL);
+	ret = rxrpc_call_read_data(call, bp, 384,
+				   RXRPC_CALL_READ_BLOCK |
+				   RXRPC_CALL_READ_ALL);
 	if (ret < 0) {
 		if (ret == -ECONNABORTED) {
 			ret = call->app_errno;
@@ -241,23 +248,26 @@ int afs_rxvl_get_entry_by_name(afs_serve
 	}
 
 	/* unmarshall the reply */
-	for (loop=0; loop<64; loop++)
+	for (loop = 0; loop < 64; loop++)
 		entry->name[loop] = ntohl(*bp++);
 	bp++; /* final NUL */
 
 	bp++; /* type */
 	entry->nservers = ntohl(*bp++);
 
-	for (loop=0; loop<8; loop++)
+	for (loop = 0; loop < 8; loop++)
 		entry->servers[loop].s_addr = *bp++;
 
 	bp += 8; /* partition IDs */
 
-	for (loop=0; loop<8; loop++) {
+	for (loop = 0; loop < 8; loop++) {
 		tmp = ntohl(*bp++);
-		if (tmp & AFS_VLSF_RWVOL  ) entry->srvtmask[loop] |= AFS_VOL_VTM_RW;
-		if (tmp & AFS_VLSF_ROVOL  ) entry->srvtmask[loop] |= AFS_VOL_VTM_RO;
-		if (tmp & AFS_VLSF_BACKVOL) entry->srvtmask[loop] |= AFS_VOL_VTM_BAK;
+		if (tmp & AFS_VLSF_RWVOL)
+			entry->srvtmask[loop] |= AFS_VOL_VTM_RW;
+		if (tmp & AFS_VLSF_ROVOL)
+			entry->srvtmask[loop] |= AFS_VOL_VTM_RO;
+		if (tmp & AFS_VLSF_BACKVOL)
+			entry->srvtmask[loop] |= AFS_VOL_VTM_BAK;
 	}
 
 	entry->vid[0] = ntohl(*bp++);
@@ -267,9 +277,12 @@ int afs_rxvl_get_entry_by_name(afs_serve
 	bp++; /* clone ID */
 
 	tmp = ntohl(*bp++); /* flags */
-	if (tmp & AFS_VLF_RWEXISTS  ) entry->vidmask |= AFS_VOL_VTM_RW;
-	if (tmp & AFS_VLF_ROEXISTS  ) entry->vidmask |= AFS_VOL_VTM_RO;
-	if (tmp & AFS_VLF_BACKEXISTS) entry->vidmask |= AFS_VOL_VTM_BAK;
+	if (tmp & AFS_VLF_RWEXISTS)
+		entry->vidmask |= AFS_VOL_VTM_RW;
+	if (tmp & AFS_VLF_ROEXISTS)
+		entry->vidmask |= AFS_VOL_VTM_RO;
+	if (tmp & AFS_VLF_BACKEXISTS)
+		entry->vidmask |= AFS_VOL_VTM_BAK;
 
 	ret = -ENOMEDIUM;
 	if (!entry->vidmask)
@@ -291,7 +304,7 @@ int afs_rxvl_get_entry_by_name(afs_serve
 
  abort:
 	set_current_state(TASK_UNINTERRUPTIBLE);
-	rxrpc_call_abort(call,ret);
+	rxrpc_call_abort(call, ret);
 	schedule();
 	goto out_unwait;
 } /* end afs_rxvl_get_entry_by_name() */
@@ -300,12 +313,12 @@ int afs_rxvl_get_entry_by_name(afs_serve
 /*
  * look up a volume location database entry by ID
  */
-int afs_rxvl_get_entry_by_id(afs_server_t *server,
+int afs_rxvl_get_entry_by_id(struct afs_server *server,
 			     afs_volid_t volid,
 			     afs_voltype_t voltype,
 			     struct afs_cache_vlocation *entry)
 {
-	DECLARE_WAITQUEUE(myself,current);
+	DECLARE_WAITQUEUE(myself, current);
 
 	struct rxrpc_connection *conn;
 	struct rxrpc_call *call;
@@ -315,25 +328,25 @@ int afs_rxvl_get_entry_by_id(afs_server_
 	int ret, loop;
 	u32 *bp, param[3];
 
-	_enter(",%x,%d,",volid,voltype);
+	_enter(",%x,%d,", volid, voltype);
 
-	memset(entry,0,sizeof(*entry));
+	memset(entry, 0, sizeof(*entry));
 
 	/* get hold of the vlserver connection */
-	ret = afs_server_get_vlconn(server,&conn);
-	if (ret<0)
+	ret = afs_server_get_vlconn(server, &conn);
+	if (ret < 0)
 		goto out;
 
 	/* create a call through that connection */
-	ret = rxrpc_create_call(conn,NULL,NULL,afs_rxvl_aemap,&call);
-	if (ret<0) {
-		printk("kAFS: Unable to create call: %d\n",ret);
+	ret = rxrpc_create_call(conn, NULL, NULL, afs_rxvl_aemap, &call);
+	if (ret < 0) {
+		printk("kAFS: Unable to create call: %d\n", ret);
 		goto out_put_conn;
 	}
 	call->app_opcode = VLGETENTRYBYID;
 
 	/* we want to get event notifications from the call */
-	add_wait_queue(&call->waitq,&myself);
+	add_wait_queue(&call->waitq, &myself);
 
 	/* marshall the parameters */
 	param[0] = htonl(VLGETENTRYBYID);
@@ -344,16 +357,19 @@ int afs_rxvl_get_entry_by_id(afs_server_
 	piov[0].iov_base = param;
 
 	/* send the parameters to the server */
-	ret = rxrpc_call_write_data(call,1,piov,RXRPC_LAST_PACKET,GFP_NOFS,0,&sent);
-	if (ret<0)
+	ret = rxrpc_call_write_data(call, 1, piov, RXRPC_LAST_PACKET, GFP_NOFS,
+				    0, &sent);
+	if (ret < 0)
 		goto abort;
 
 	/* wait for the reply to completely arrive */
-	bp = rxrpc_call_alloc_scratch(call,384);
+	bp = rxrpc_call_alloc_scratch(call, 384);
 
-	ret = rxrpc_call_read_data(call,bp,384,RXRPC_CALL_READ_BLOCK|RXRPC_CALL_READ_ALL);
-	if (ret<0) {
-		if (ret==-ECONNABORTED) {
+	ret = rxrpc_call_read_data(call, bp, 384,
+				   RXRPC_CALL_READ_BLOCK |
+				   RXRPC_CALL_READ_ALL);
+	if (ret < 0) {
+		if (ret == -ECONNABORTED) {
 			ret = call->app_errno;
 			goto out_unwait;
 		}
@@ -361,23 +377,26 @@ int afs_rxvl_get_entry_by_id(afs_server_
 	}
 
 	/* unmarshall the reply */
-	for (loop=0; loop<64; loop++)
+	for (loop = 0; loop < 64; loop++)
 		entry->name[loop] = ntohl(*bp++);
 	bp++; /* final NUL */
 
 	bp++; /* type */
 	entry->nservers = ntohl(*bp++);
 
-	for (loop=0; loop<8; loop++)
+	for (loop = 0; loop < 8; loop++)
 		entry->servers[loop].s_addr = *bp++;
 
 	bp += 8; /* partition IDs */
 
-	for (loop=0; loop<8; loop++) {
+	for (loop = 0; loop < 8; loop++) {
 		tmp = ntohl(*bp++);
-		if (tmp & AFS_VLSF_RWVOL  ) entry->srvtmask[loop] |= AFS_VOL_VTM_RW;
-		if (tmp & AFS_VLSF_ROVOL  ) entry->srvtmask[loop] |= AFS_VOL_VTM_RO;
-		if (tmp & AFS_VLSF_BACKVOL) entry->srvtmask[loop] |= AFS_VOL_VTM_BAK;
+		if (tmp & AFS_VLSF_RWVOL)
+			entry->srvtmask[loop] |= AFS_VOL_VTM_RW;
+		if (tmp & AFS_VLSF_ROVOL)
+			entry->srvtmask[loop] |= AFS_VOL_VTM_RO;
+		if (tmp & AFS_VLSF_BACKVOL)
+			entry->srvtmask[loop] |= AFS_VOL_VTM_BAK;
 	}
 
 	entry->vid[0] = ntohl(*bp++);
@@ -387,9 +406,12 @@ int afs_rxvl_get_entry_by_id(afs_server_
 	bp++; /* clone ID */
 
 	tmp = ntohl(*bp++); /* flags */
-	if (tmp & AFS_VLF_RWEXISTS  ) entry->vidmask |= AFS_VOL_VTM_RW;
-	if (tmp & AFS_VLF_ROEXISTS  ) entry->vidmask |= AFS_VOL_VTM_RO;
-	if (tmp & AFS_VLF_BACKEXISTS) entry->vidmask |= AFS_VOL_VTM_BAK;
+	if (tmp & AFS_VLF_RWEXISTS)
+		entry->vidmask |= AFS_VOL_VTM_RW;
+	if (tmp & AFS_VLF_ROEXISTS)
+		entry->vidmask |= AFS_VOL_VTM_RO;
+	if (tmp & AFS_VLF_BACKEXISTS)
+		entry->vidmask |= AFS_VOL_VTM_BAK;
 
 	ret = -ENOMEDIUM;
 	if (!entry->vidmask)
@@ -412,17 +434,17 @@ int afs_rxvl_get_entry_by_id(afs_server_
 
  out_unwait:
 	set_current_state(TASK_RUNNING);
-	remove_wait_queue(&call->waitq,&myself);
+	remove_wait_queue(&call->waitq, &myself);
 	rxrpc_put_call(call);
  out_put_conn:
 	rxrpc_put_connection(conn);
  out:
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 
  abort:
 	set_current_state(TASK_UNINTERRUPTIBLE);
-	rxrpc_call_abort(call,ret);
+	rxrpc_call_abort(call, ret);
 	schedule();
 	goto out_unwait;
 } /* end afs_rxvl_get_entry_by_id() */
@@ -431,7 +453,7 @@ int afs_rxvl_get_entry_by_id(afs_server_
 /*
  * look up a volume location database entry by ID asynchronously
  */
-int afs_rxvl_get_entry_by_id_async(afs_async_op_t *op,
+int afs_rxvl_get_entry_by_id_async(struct afs_async_op *op,
 				   afs_volid_t volid,
 				   afs_voltype_t voltype)
 {
@@ -442,12 +464,12 @@ int afs_rxvl_get_entry_by_id_async(afs_a
 	int ret;
 	u32 param[3];
 
-	_enter(",%x,%d,",volid,voltype);
+	_enter(",%x,%d,", volid, voltype);
 
 	/* get hold of the vlserver connection */
-	ret = afs_server_get_vlconn(op->server,&conn);
-	if (ret<0) {
-		_leave(" = %d",ret);
+	ret = afs_server_get_vlconn(op->server, &conn);
+	if (ret < 0) {
+		_leave(" = %d", ret);
 		return ret;
 	}
 
@@ -459,9 +481,9 @@ int afs_rxvl_get_entry_by_id_async(afs_a
 				&op->call);
 	rxrpc_put_connection(conn);
 
-	if (ret<0) {
-		printk("kAFS: Unable to create call: %d\n",ret);
-		_leave(" = %d",ret);
+	if (ret < 0) {
+		printk("kAFS: Unable to create call: %d\n", ret);
+		_leave(" = %d", ret);
 		return ret;
 	}
 
@@ -483,18 +505,19 @@ int afs_rxvl_get_entry_by_id_async(afs_a
 	piov[0].iov_base = param;
 
 	/* allocate result read buffer in scratch space */
-	call->app_scr_ptr = rxrpc_call_alloc_scratch(op->call,384);
+	call->app_scr_ptr = rxrpc_call_alloc_scratch(op->call, 384);
 
 	/* send the parameters to the server */
-	ret = rxrpc_call_write_data(call,1,piov,RXRPC_LAST_PACKET,GFP_NOFS,0,&sent);
-	if (ret<0) {
-		rxrpc_call_abort(call,ret); /* handle from kafsasyncd */
+	ret = rxrpc_call_write_data(call, 1, piov, RXRPC_LAST_PACKET, GFP_NOFS,
+				    0, &sent);
+	if (ret < 0) {
+		rxrpc_call_abort(call, ret); /* handle from kafsasyncd */
 		ret = 0;
 		goto out;
 	}
 
 	/* wait for the reply to completely arrive */
-	ret = rxrpc_call_read_data(call,call->app_scr_ptr,384,0);
+	ret = rxrpc_call_read_data(call, call->app_scr_ptr, 384, 0);
 	switch (ret) {
 	case 0:
 	case -EAGAIN:
@@ -503,14 +526,14 @@ int afs_rxvl_get_entry_by_id_async(afs_a
 		break;	/* all handled by kafsasyncd */
 
 	default:
-		rxrpc_call_abort(call,ret); /* force kafsasyncd to handle it */
+		rxrpc_call_abort(call, ret); /* make kafsasyncd handle it */
 		ret = 0;
 		break;
 	}
 
  out:
 	rxrpc_put_call(call);
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 
 } /* end afs_rxvl_get_entry_by_id_async() */
@@ -519,40 +542,43 @@ int afs_rxvl_get_entry_by_id_async(afs_a
 /*
  * attend to the asynchronous get VLDB entry by ID
  */
-int afs_rxvl_get_entry_by_id_async2(afs_async_op_t *op,
+int afs_rxvl_get_entry_by_id_async2(struct afs_async_op *op,
 				    struct afs_cache_vlocation *entry)
 {
 	unsigned *bp, tmp;
 	int loop, ret;
 
-	_enter("{op=%p cst=%u}",op,op->call->app_call_state);
+	_enter("{op=%p cst=%u}", op, op->call->app_call_state);
 
-	memset(entry,0,sizeof(*entry));
+	memset(entry, 0, sizeof(*entry));
 
-	if (op->call->app_call_state==RXRPC_CSTATE_COMPLETE) {
+	if (op->call->app_call_state == RXRPC_CSTATE_COMPLETE) {
 		/* operation finished */
 		afs_kafsasyncd_terminate_op(op);
 
 		bp = op->call->app_scr_ptr;
 
 		/* unmarshall the reply */
-		for (loop=0; loop<64; loop++)
+		for (loop = 0; loop < 64; loop++)
 			entry->name[loop] = ntohl(*bp++);
 		bp++; /* final NUL */
 
 		bp++; /* type */
 		entry->nservers = ntohl(*bp++);
 
-		for (loop=0; loop<8; loop++)
+		for (loop = 0; loop < 8; loop++)
 			entry->servers[loop].s_addr = *bp++;
 
 		bp += 8; /* partition IDs */
 
-		for (loop=0; loop<8; loop++) {
+		for (loop = 0; loop < 8; loop++) {
 			tmp = ntohl(*bp++);
-			if (tmp & AFS_VLSF_RWVOL  ) entry->srvtmask[loop] |= AFS_VOL_VTM_RW;
-			if (tmp & AFS_VLSF_ROVOL  ) entry->srvtmask[loop] |= AFS_VOL_VTM_RO;
-			if (tmp & AFS_VLSF_BACKVOL) entry->srvtmask[loop] |= AFS_VOL_VTM_BAK;
+			if (tmp & AFS_VLSF_RWVOL)
+				entry->srvtmask[loop] |= AFS_VOL_VTM_RW;
+			if (tmp & AFS_VLSF_ROVOL)
+				entry->srvtmask[loop] |= AFS_VOL_VTM_RO;
+			if (tmp & AFS_VLSF_BACKVOL)
+				entry->srvtmask[loop] |= AFS_VOL_VTM_BAK;
 		}
 
 		entry->vid[0] = ntohl(*bp++);
@@ -562,13 +588,16 @@ int afs_rxvl_get_entry_by_id_async2(afs_
 		bp++; /* clone ID */
 
 		tmp = ntohl(*bp++); /* flags */
-		if (tmp & AFS_VLF_RWEXISTS  ) entry->vidmask |= AFS_VOL_VTM_RW;
-		if (tmp & AFS_VLF_ROEXISTS  ) entry->vidmask |= AFS_VOL_VTM_RO;
-		if (tmp & AFS_VLF_BACKEXISTS) entry->vidmask |= AFS_VOL_VTM_BAK;
+		if (tmp & AFS_VLF_RWEXISTS)
+			entry->vidmask |= AFS_VOL_VTM_RW;
+		if (tmp & AFS_VLF_ROEXISTS)
+			entry->vidmask |= AFS_VOL_VTM_RO;
+		if (tmp & AFS_VLF_BACKEXISTS)
+			entry->vidmask |= AFS_VOL_VTM_BAK;
 
 		ret = -ENOMEDIUM;
 		if (!entry->vidmask) {
-			rxrpc_call_abort(op->call,ret);
+			rxrpc_call_abort(op->call, ret);
 			goto done;
 		}
 
@@ -589,7 +618,7 @@ int afs_rxvl_get_entry_by_id_async2(afs_
 		goto done;
 	}
 
-	if (op->call->app_call_state==RXRPC_CSTATE_ERROR) {
+	if (op->call->app_call_state == RXRPC_CSTATE_ERROR) {
 		/* operation error */
 		ret = op->call->app_errno;
 		goto done;
@@ -601,7 +630,7 @@ int afs_rxvl_get_entry_by_id_async2(afs_
  done:
 	rxrpc_put_call(op->call);
 	op->call = NULL;
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end afs_rxvl_get_entry_by_id_async2() */
 
@@ -612,9 +641,9 @@ int afs_rxvl_get_entry_by_id_async2(afs_
  */
 static void afs_rxvl_get_entry_by_id_attn(struct rxrpc_call *call)
 {
-	afs_async_op_t *op = call->app_user;
+	struct afs_async_op *op = call->app_user;
 
-	_enter("{op=%p cst=%u}",op,call->app_call_state);
+	_enter("{op=%p cst=%u}", op, call->app_call_state);
 
 	switch (call->app_call_state) {
 	case RXRPC_CSTATE_COMPLETE:
@@ -624,7 +653,7 @@ static void afs_rxvl_get_entry_by_id_att
 		if (call->app_async_read)
 			break;
 	case RXRPC_CSTATE_CLNT_GOT_REPLY:
-		if (call->app_read_count==0)
+		if (call->app_read_count == 0)
 			break;
 		printk("kAFS: Reply bigger than expected"
 		       " {cst=%u asyn=%d mark=%Zu rdy=%Zu pr=%u%s}",
@@ -635,7 +664,7 @@ static void afs_rxvl_get_entry_by_id_att
 		       call->pkt_rcv_count,
 		       call->app_last_rcv ? " last" : "");
 
-		rxrpc_call_abort(call,-EBADMSG);
+		rxrpc_call_abort(call, -EBADMSG);
 		break;
 	default:
 		BUG();
@@ -652,9 +681,9 @@ static void afs_rxvl_get_entry_by_id_att
  */
 static void afs_rxvl_get_entry_by_id_error(struct rxrpc_call *call)
 {
-	afs_async_op_t *op = call->app_user;
+	struct afs_async_op *op = call->app_user;
 
-	_enter("{op=%p cst=%u}",op,call->app_call_state);
+	_enter("{op=%p cst=%u}", op, call->app_call_state);
 
 	afs_kafsasyncd_attend_op(op);
 
diff -puN fs/afs/vlclient.h~linus fs/afs/vlclient.h
--- 25/fs/afs/vlclient.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/vlclient.h	2004-01-19 22:17:23.000000000 -0800
@@ -72,25 +72,25 @@ struct afs_vldbentry {
 };
 
 /* probe a volume location server to see if it is still alive */
-extern int afs_rxvl_probe(afs_server_t *server, int alloc_flags);
+extern int afs_rxvl_probe(struct afs_server *server, int alloc_flags);
 
 /* look up a volume location database entry by name */
-extern int afs_rxvl_get_entry_by_name(afs_server_t *server,
+extern int afs_rxvl_get_entry_by_name(struct afs_server *server,
 				      const char *volname,
 				      unsigned volnamesz,
 				      struct afs_cache_vlocation *entry);
 
 /* look up a volume location database entry by ID */
-extern int afs_rxvl_get_entry_by_id(afs_server_t *server,
+extern int afs_rxvl_get_entry_by_id(struct afs_server *server,
 				    afs_volid_t	volid,
 				    afs_voltype_t voltype,
 				    struct afs_cache_vlocation *entry);
 
-extern int afs_rxvl_get_entry_by_id_async(afs_async_op_t *op,
+extern int afs_rxvl_get_entry_by_id_async(struct afs_async_op *op,
 					  afs_volid_t volid,
 					  afs_voltype_t voltype);
 
-extern int afs_rxvl_get_entry_by_id_async2(afs_async_op_t *op,
+extern int afs_rxvl_get_entry_by_id_async2(struct afs_async_op *op,
 					   struct afs_cache_vlocation *entry);
 
 #endif /* _LINUX_AFS_VLCLIENT_H */
diff -puN fs/afs/vlocation.c~linus fs/afs/vlocation.c
--- 25/fs/afs/vlocation.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/vlocation.c	2004-01-19 22:17:23.000000000 -0800
@@ -26,15 +26,17 @@
 
 #define AFS_VLDB_TIMEOUT HZ*1000
 
-static void afs_vlocation_update_timer(afs_timer_t *timer);
-static void afs_vlocation_update_attend(afs_async_op_t *op);
-static void afs_vlocation_update_discard(afs_async_op_t *op);
+static void afs_vlocation_update_timer(struct afs_timer *timer);
+static void afs_vlocation_update_attend(struct afs_async_op *op);
+static void afs_vlocation_update_discard(struct afs_async_op *op);
 
-static void __afs_vlocation_timeout(afs_timer_t *timer)
+static void __afs_vlocation_timeout(struct afs_timer *timer)
 {
-	afs_vlocation_t *vlocation = list_entry(timer,afs_vlocation_t,timeout);
+	struct afs_vlocation *vlocation =
+		list_entry(timer, struct afs_vlocation, timeout);
 
-	_debug("VL TIMEOUT [%s{u=%d}]",vlocation->vldb.name,atomic_read(&vlocation->usage));
+	_debug("VL TIMEOUT [%s{u=%d}]",
+	       vlocation->vldb.name, atomic_read(&vlocation->usage));
 
 	afs_vlocation_do_timeout(vlocation);
 }
@@ -53,11 +55,12 @@ static const struct afs_async_op_ops afs
 };
 
 static LIST_HEAD(afs_vlocation_update_pendq);	/* queue of VLs awaiting update */
-static afs_vlocation_t *afs_vlocation_update;	/* VL currently being updated */
+static struct afs_vlocation *afs_vlocation_update;	/* VL currently being updated */
 static spinlock_t afs_vlocation_update_lock = SPIN_LOCK_UNLOCKED; /* lock guarding update queue */
 
 #ifdef AFS_CACHING_SUPPORT
-static cachefs_match_val_t afs_vlocation_cache_match(void *target, const void *entry);
+static cachefs_match_val_t afs_vlocation_cache_match(void *target,
+						     const void *entry);
 static void afs_vlocation_cache_update(void *source, void *entry);
 
 struct cachefs_index_def afs_vlocation_cache_index_def = {
@@ -71,29 +74,31 @@ struct cachefs_index_def afs_vlocation_c
 
 /*****************************************************************************/
 /*
- * iterate through the VL servers in a cell until one of them admits knowing about the volume in
- * question
+ * iterate through the VL servers in a cell until one of them admits knowing
+ * about the volume in question
  * - caller must have cell->vl_sem write-locked
  */
-static int afs_vlocation_access_vl_by_name(afs_vlocation_t *vlocation,
+static int afs_vlocation_access_vl_by_name(struct afs_vlocation *vlocation,
 					   const char *name,
 					   unsigned namesz,
 					   struct afs_cache_vlocation *vldb)
 {
-	afs_server_t *server = NULL;
-	afs_cell_t *cell = vlocation->cell;
+	struct afs_server *server = NULL;
+	struct afs_cell *cell = vlocation->cell;
 	int count, ret;
 
 	_enter("%s,%*.*s,%u", cell->name, namesz, namesz, name, namesz);
 
 	ret = -ENOMEDIUM;
-	for (count=cell->vl_naddrs; count>0; count--) {
+	for (count = cell->vl_naddrs; count > 0; count--) {
 		_debug("CellServ[%hu]: %08x",
 		       cell->vl_curr_svix,
 		       cell->vl_addrs[cell->vl_curr_svix].s_addr);
 
 		/* try and create a server */
-		ret = afs_server_lookup(cell, &cell->vl_addrs[cell->vl_curr_svix], &server);
+		ret = afs_server_lookup(cell,
+					&cell->vl_addrs[cell->vl_curr_svix],
+					&server);
 		switch (ret) {
 		case 0:
 			break;
@@ -141,36 +146,38 @@ static int afs_vlocation_access_vl_by_na
 	}
 
  out:
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 
 } /* end afs_vlocation_access_vl_by_name() */
 
 /*****************************************************************************/
 /*
- * iterate through the VL servers in a cell until one of them admits knowing about the volume in
- * question
+ * iterate through the VL servers in a cell until one of them admits knowing
+ * about the volume in question
  * - caller must have cell->vl_sem write-locked
  */
-static int afs_vlocation_access_vl_by_id(afs_vlocation_t *vlocation,
+static int afs_vlocation_access_vl_by_id(struct afs_vlocation *vlocation,
 					 afs_volid_t volid,
 					 afs_voltype_t voltype,
 					 struct afs_cache_vlocation *vldb)
 {
-	afs_server_t *server = NULL;
-	afs_cell_t *cell = vlocation->cell;
+	struct afs_server *server = NULL;
+	struct afs_cell *cell = vlocation->cell;
 	int count, ret;
 
 	_enter("%s,%x,%d,", cell->name, volid, voltype);
 
 	ret = -ENOMEDIUM;
-	for (count=cell->vl_naddrs; count>0; count--) {
+	for (count = cell->vl_naddrs; count > 0; count--) {
 		_debug("CellServ[%hu]: %08x",
 		       cell->vl_curr_svix,
 		       cell->vl_addrs[cell->vl_curr_svix].s_addr);
 
 		/* try and create a server */
-		ret = afs_server_lookup(cell, &cell->vl_addrs[cell->vl_curr_svix], &server);
+		ret = afs_server_lookup(cell,
+					&cell->vl_addrs[cell->vl_curr_svix],
+					&server);
 		switch (ret) {
 		case 0:
 			break;
@@ -218,7 +225,7 @@ static int afs_vlocation_access_vl_by_id
 	}
 
  out:
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 
 } /* end afs_vlocation_access_vl_by_id() */
@@ -227,17 +234,18 @@ static int afs_vlocation_access_vl_by_id
 /*
  * lookup volume location
  * - caller must have cell->vol_sem write-locked
- * - iterate through the VL servers in a cell until one of them admits knowing about the volume in
- *   question
+ * - iterate through the VL servers in a cell until one of them admits knowing
+ *   about the volume in question
  * - lookup in the local cache if not able to find on the VL server
  * - insert/update in the local cache if did get a VL response
  */
-int afs_vlocation_lookup(afs_cell_t *cell, const char *name, unsigned namesz,
-			 afs_vlocation_t **_vlocation)
+int afs_vlocation_lookup(struct afs_cell *cell,
+			 const char *name,
+			 unsigned namesz,
+			 struct afs_vlocation **_vlocation)
 {
 	struct afs_cache_vlocation vldb;
-	struct list_head *_p;
-	afs_vlocation_t *vlocation;
+	struct afs_vlocation *vlocation;
 	afs_voltype_t voltype;
 	afs_volid_t vid;
 	int active = 0, ret;
@@ -250,8 +258,7 @@ int afs_vlocation_lookup(afs_cell_t *cel
 	}
 
 	/* search the cell's active list first */
-	list_for_each(_p, &cell->vl_list) {
-		vlocation = list_entry(_p, afs_vlocation_t, link);
+	list_for_each_entry(vlocation, &cell->vl_list, link) {
 		if (namesz < sizeof(vlocation->vldb.name) &&
 		    vlocation->vldb.name[namesz] != '\0')
 			continue;
@@ -262,8 +269,7 @@ int afs_vlocation_lookup(afs_cell_t *cel
 
 	/* search the cell's graveyard list second */
 	spin_lock(&cell->vl_gylock);
-	list_for_each(_p, &cell->vl_graveyard) {
-		vlocation = list_entry(_p, afs_vlocation_t, link);
+	list_for_each_entry(vlocation, &cell->vl_graveyard, link) {
 		if (namesz < sizeof(vlocation->vldb.name) &&
 		    vlocation->vldb.name[namesz] != '\0')
 			continue;
@@ -274,11 +280,11 @@ int afs_vlocation_lookup(afs_cell_t *cel
 	spin_unlock(&cell->vl_gylock);
 
 	/* not in the cell's in-memory lists - create a new record */
-	vlocation = kmalloc(sizeof(afs_vlocation_t), GFP_KERNEL);
+	vlocation = kmalloc(sizeof(struct afs_vlocation), GFP_KERNEL);
 	if (!vlocation)
 		return -ENOMEM;
 
-	memset(vlocation, 0, sizeof(afs_vlocation_t));
+	memset(vlocation, 0, sizeof(struct afs_vlocation));
 	atomic_set(&vlocation->usage, 1);
 	INIT_LIST_HEAD(&vlocation->link);
 	rwlock_init(&vlocation->lock);
@@ -294,7 +300,8 @@ int afs_vlocation_lookup(afs_cell_t *cel
 	list_add_tail(&vlocation->link, &cell->vl_list);
 
 #ifdef AFS_CACHING_SUPPORT
-	/* we want to store it in the cache, plus it might already be encached */
+	/* we want to store it in the cache, plus it might already be
+	 * encached */
 	cachefs_acquire_cookie(cell->cache,
 			       &afs_volume_cache_index_def,
 			       vlocation,
@@ -306,7 +313,7 @@ int afs_vlocation_lookup(afs_cell_t *cel
 
 	/* try to look up an unknown volume in the cell VL databases by name */
 	ret = afs_vlocation_access_vl_by_name(vlocation, name, namesz, &vldb);
-	if (ret<0) {
+	if (ret < 0) {
 		printk("kAFS: failed to locate '%*.*s' in cell '%s'\n",
 		       namesz, namesz, name, cell->name);
 		goto error;
@@ -342,13 +349,18 @@ int afs_vlocation_lookup(afs_cell_t *cel
 	_debug("Locally Cached: %s %02x { %08x(%x) %08x(%x) %08x(%x) }",
 	       vlocation->vldb.name,
 	       vlocation->vldb.vidmask,
-	       ntohl(vlocation->vldb.servers[0].s_addr), vlocation->vldb.srvtmask[0],
-	       ntohl(vlocation->vldb.servers[1].s_addr), vlocation->vldb.srvtmask[1],
-	       ntohl(vlocation->vldb.servers[2].s_addr), vlocation->vldb.srvtmask[2]
+	       ntohl(vlocation->vldb.servers[0].s_addr),
+	       vlocation->vldb.srvtmask[0],
+	       ntohl(vlocation->vldb.servers[1].s_addr),
+	       vlocation->vldb.srvtmask[1],
+	       ntohl(vlocation->vldb.servers[2].s_addr),
+	       vlocation->vldb.srvtmask[2]
 	       );
 
 	_debug("Vids: %08x %08x %08x",
-	       vlocation->vldb.vid[0], vlocation->vldb.vid[1], vlocation->vldb.vid[2]);
+	       vlocation->vldb.vid[0],
+	       vlocation->vldb.vid[1],
+	       vlocation->vldb.vid[2]);
 
 	if (vlocation->vldb.vidmask & AFS_VOL_VTM_RW) {
 		vid = vlocation->vldb.vid[0];
@@ -400,21 +412,20 @@ int afs_vlocation_lookup(afs_cell_t *cel
 
 	_debug("Vids: %08x %08x %08x", vldb.vid[0], vldb.vid[1], vldb.vid[2]);
 
-	if ((namesz < sizeof(vlocation->vldb.name) && vlocation->vldb.name[namesz] != '\0') ||
+	if ((namesz < sizeof(vlocation->vldb.name) &&
+	     vlocation->vldb.name[namesz] != '\0') ||
 	    memcmp(vldb.name, name, namesz) != 0)
 		printk("kAFS: name of volume '%*.*s' changed to '%s' on server\n",
 		       namesz, namesz, name, vldb.name);
 
 	memcpy(&vlocation->vldb, &vldb, sizeof(vlocation->vldb));
 
-#if 0
-	/* add volume entry to local cache */
-	ret = afsc_update_vlocation(vlocation);
-	if (ret<0)
-		goto error;
-#endif
+	afs_kafstimod_add_timer(&vlocation->upd_timer, 10 * HZ);
 
-	afs_kafstimod_add_timer(&vlocation->upd_timer, 10*HZ);
+#ifdef AFS_CACHING_SUPPORT
+	/* update volume entry in local cache */
+	cachefs_update_cookie(vlocation->cache);
+#endif
 
 	*_vlocation = vlocation;
 	_leave(" = 0 (%p)",vlocation);
@@ -435,7 +446,7 @@ int afs_vlocation_lookup(afs_cell_t *cel
 		}
 	}
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end afs_vlocation_lookup() */
 
@@ -451,13 +462,12 @@ void __afs_put_vlocation(struct afs_vloc
 	if (!vlocation)
 		return;
 
-	_enter("%s",vlocation->vldb.name);
+	_enter("%s", vlocation->vldb.name);
 
 	cell = vlocation->cell;
 
 	/* sanity check */
-	if (atomic_read(&vlocation->usage)<=0)
-		BUG();
+	BUG_ON(atomic_read(&vlocation->usage) <= 0);
 
 	spin_lock(&cell->vl_gylock);
 	if (likely(!atomic_dec_and_test(&vlocation->usage))) {
@@ -470,12 +480,13 @@ void __afs_put_vlocation(struct afs_vloc
 	list_del(&vlocation->link);
 	list_add_tail(&vlocation->link,&cell->vl_graveyard);
 
-	/* remove from pending timeout queue (refcounted if actually being updated) */
+	/* remove from pending timeout queue (refcounted if actually being
+	 * updated) */
 	list_del_init(&vlocation->upd_op.link);
 
 	/* time out in 10 secs */
 	afs_kafstimod_del_timer(&vlocation->upd_timer);
-	afs_kafstimod_add_timer(&vlocation->timeout,10*HZ);
+	afs_kafstimod_add_timer(&vlocation->timeout, 10 * HZ);
 
 	spin_unlock(&cell->vl_gylock);
 
@@ -486,7 +497,7 @@ void __afs_put_vlocation(struct afs_vloc
 /*
  * finish using a volume location record
  */
-void afs_put_vlocation(afs_vlocation_t *vlocation)
+void afs_put_vlocation(struct afs_vlocation *vlocation)
 {
 	if (vlocation) {
 		struct afs_cell *cell = vlocation->cell;
@@ -502,19 +513,19 @@ void afs_put_vlocation(afs_vlocation_t *
  * timeout vlocation record
  * - removes from the cell's graveyard if the usage count is zero
  */
-void afs_vlocation_do_timeout(afs_vlocation_t *vlocation)
+void afs_vlocation_do_timeout(struct afs_vlocation *vlocation)
 {
-	afs_cell_t *cell;
+	struct afs_cell *cell;
 
-	_enter("%s",vlocation->vldb.name);
+	_enter("%s", vlocation->vldb.name);
 
 	cell = vlocation->cell;
 
-	if (atomic_read(&vlocation->usage)<0) BUG();
+	BUG_ON(atomic_read(&vlocation->usage) < 0);
 
 	/* remove from graveyard if still dead */
 	spin_lock(&cell->vl_gylock);
-	if (atomic_read(&vlocation->usage)==0)
+	if (atomic_read(&vlocation->usage) == 0)
 		list_del_init(&vlocation->link);
 	else
 		vlocation = NULL;
@@ -527,7 +538,7 @@ void afs_vlocation_do_timeout(afs_vlocat
 
 	/* we can now destroy it properly */
 #ifdef AFS_CACHING_SUPPORT
-	cachefs_relinquish_cookie(vlocation->cache,0);
+	cachefs_relinquish_cookie(vlocation->cache, 0);
 #endif
 	afs_put_cell(cell);
 
@@ -540,14 +551,16 @@ void afs_vlocation_do_timeout(afs_vlocat
 /*
  * send an update operation to the currently selected server
  */
-static int afs_vlocation_update_begin(afs_vlocation_t *vlocation)
+static int afs_vlocation_update_begin(struct afs_vlocation *vlocation)
 {
 	afs_voltype_t voltype;
 	afs_volid_t vid;
 	int ret;
 
 	_enter("%s{ufs=%u ucs=%u}",
-	       vlocation->vldb.name,vlocation->upd_first_svix,vlocation->upd_curr_svix);
+	       vlocation->vldb.name,
+	       vlocation->upd_first_svix,
+	       vlocation->upd_curr_svix);
 
 	/* try to look up a cached volume in the cell VL databases by ID */
 	if (vlocation->vldb.vidmask & AFS_VOL_VTM_RW) {
@@ -569,27 +582,29 @@ static int afs_vlocation_update_begin(af
 	}
 
 	/* contact the chosen server */
-	ret = afs_server_lookup(vlocation->cell,
-				&vlocation->cell->vl_addrs[vlocation->upd_curr_svix],
-				&vlocation->upd_op.server);
+	ret = afs_server_lookup(
+		vlocation->cell,
+		&vlocation->cell->vl_addrs[vlocation->upd_curr_svix],
+		&vlocation->upd_op.server);
+
 	switch (ret) {
 	case 0:
 		break;
 	case -ENOMEM:
 	case -ENONET:
 	default:
-		_leave(" = %d",ret);
+		_leave(" = %d", ret);
 		return ret;
 	}
 
 	/* initiate the update operation */
-	ret = afs_rxvl_get_entry_by_id_async(&vlocation->upd_op,vid,voltype);
-	if (ret<0) {
-		_leave(" = %d",ret);
+	ret = afs_rxvl_get_entry_by_id_async(&vlocation->upd_op, vid, voltype);
+	if (ret < 0) {
+		_leave(" = %d", ret);
 		return ret;
 	}
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end afs_vlocation_update_begin() */
 
@@ -598,14 +613,15 @@ static int afs_vlocation_update_begin(af
  * abandon updating a VL record
  * - does not restart the update timer
  */
-static void afs_vlocation_update_abandon(afs_vlocation_t *vlocation,
+static void afs_vlocation_update_abandon(struct afs_vlocation *vlocation,
 					 afs_vlocation_upd_t state,
 					 int ret)
 {
-	_enter("%s,%u",vlocation->vldb.name,state);
+	_enter("%s,%u", vlocation->vldb.name, state);
 
-	if (ret<0)
-		printk("kAFS: Abandoning VL update '%s': %d\n",vlocation->vldb.name,ret);
+	if (ret < 0)
+		printk("kAFS: Abandoning VL update '%s': %d\n",
+		       vlocation->vldb.name, ret);
 
 	/* discard the server record */
 	afs_put_server(vlocation->upd_op.server);
@@ -627,12 +643,13 @@ static void afs_vlocation_update_abandon
  * handle periodic update timeouts and busy retry timeouts
  * - called from kafstimod
  */
-static void afs_vlocation_update_timer(afs_timer_t *timer)
+static void afs_vlocation_update_timer(struct afs_timer *timer)
 {
-	afs_vlocation_t *vlocation = list_entry(timer,afs_vlocation_t,upd_timer);
+	struct afs_vlocation *vlocation =
+		list_entry(timer, struct afs_vlocation, upd_timer);
 	int ret;
 
-	_enter("%s",vlocation->vldb.name);
+	_enter("%s", vlocation->vldb.name);
 
 	/* only update if not in the graveyard (defend against putting too) */
 	spin_lock(&vlocation->cell->vl_gylock);
@@ -642,11 +659,12 @@ static void afs_vlocation_update_timer(a
 
 	spin_lock(&afs_vlocation_update_lock);
 
-	/* if we were woken up due to EBUSY sleep then restart immediately if possible or else jump
-	 * to front of pending queue */
-	if (vlocation->upd_state==AFS_VLUPD_BUSYSLEEP) {
+	/* if we were woken up due to EBUSY sleep then restart immediately if
+	 * possible or else jump to front of pending queue */
+	if (vlocation->upd_state == AFS_VLUPD_BUSYSLEEP) {
 		if (afs_vlocation_update) {
-			list_add(&vlocation->upd_op.link,&afs_vlocation_update_pendq);
+			list_add(&vlocation->upd_op.link,
+				 &afs_vlocation_update_pendq);
 		}
 		else {
 			afs_get_vlocation(vlocation);
@@ -659,7 +677,8 @@ static void afs_vlocation_update_timer(a
 	/* put on pending queue if there's already another update in progress */
 	if (afs_vlocation_update) {
 		vlocation->upd_state = AFS_VLUPD_PENDING;
-		list_add_tail(&vlocation->upd_op.link,&afs_vlocation_update_pendq);
+		list_add_tail(&vlocation->upd_op.link,
+			      &afs_vlocation_update_pendq);
 		goto out_unlock2;
 	}
 
@@ -672,16 +691,17 @@ static void afs_vlocation_update_timer(a
 	spin_unlock(&vlocation->cell->vl_gylock);
 
 	/* okay... we can start the update */
-	_debug("BEGIN VL UPDATE [%s]",vlocation->vldb.name);
+	_debug("BEGIN VL UPDATE [%s]", vlocation->vldb.name);
 	vlocation->upd_first_svix = vlocation->cell->vl_curr_svix;
 	vlocation->upd_curr_svix = vlocation->upd_first_svix;
 	vlocation->upd_rej_cnt = 0;
 	vlocation->upd_busy_cnt = 0;
 
 	ret = afs_vlocation_update_begin(vlocation);
-	if (ret<0) {
-		afs_vlocation_update_abandon(vlocation,AFS_VLUPD_SLEEP,ret);
-		afs_kafstimod_add_timer(&vlocation->upd_timer,AFS_VLDB_TIMEOUT);
+	if (ret < 0) {
+		afs_vlocation_update_abandon(vlocation, AFS_VLUPD_SLEEP, ret);
+		afs_kafstimod_add_timer(&vlocation->upd_timer,
+					AFS_VLDB_TIMEOUT);
 		afs_put_vlocation(vlocation);
 	}
 
@@ -702,56 +722,60 @@ static void afs_vlocation_update_timer(a
  * attend to an update operation upon which an event happened
  * - called in kafsasyncd context
  */
-static void afs_vlocation_update_attend(afs_async_op_t *op)
+static void afs_vlocation_update_attend(struct afs_async_op *op)
 {
 	struct afs_cache_vlocation vldb;
-	afs_vlocation_t *vlocation = list_entry(op,afs_vlocation_t,upd_op);
+	struct afs_vlocation *vlocation =
+		list_entry(op, struct afs_vlocation, upd_op);
 	unsigned tmp;
 	int ret;
 
-	_enter("%s",vlocation->vldb.name);
+	_enter("%s", vlocation->vldb.name);
 
-	ret = afs_rxvl_get_entry_by_id_async2(op,&vldb);
+	ret = afs_rxvl_get_entry_by_id_async2(op, &vldb);
 	switch (ret) {
 	case -EAGAIN:
 		_leave(" [unfinished]");
 		return;
 
 	case 0:
-		_debug("END VL UPDATE: %d\n",ret);
+		_debug("END VL UPDATE: %d\n", ret);
 		vlocation->valid = 1;
 
 		_debug("Done VL Lookup: %02x { %08x(%x) %08x(%x) %08x(%x) }",
 		       vldb.vidmask,
-		       ntohl(vldb.servers[0].s_addr),vldb.srvtmask[0],
-		       ntohl(vldb.servers[1].s_addr),vldb.srvtmask[1],
-		       ntohl(vldb.servers[2].s_addr),vldb.srvtmask[2]
+		       ntohl(vldb.servers[0].s_addr), vldb.srvtmask[0],
+		       ntohl(vldb.servers[1].s_addr), vldb.srvtmask[1],
+		       ntohl(vldb.servers[2].s_addr), vldb.srvtmask[2]
 		       );
 
-		_debug("Vids: %08x %08x %08x",vldb.vid[0],vldb.vid[1],vldb.vid[2]);
+		_debug("Vids: %08x %08x %08x",
+		       vldb.vid[0], vldb.vid[1], vldb.vid[2]);
 
-		afs_vlocation_update_abandon(vlocation,AFS_VLUPD_SLEEP,0);
+		afs_vlocation_update_abandon(vlocation, AFS_VLUPD_SLEEP, 0);
 
 		down_write(&vlocation->cell->vl_sem);
 
 		/* actually update the cache */
-		if (strncmp(vldb.name,vlocation->vldb.name,sizeof(vlocation->vldb.name))!=0)
-			printk("kAFS: name of volume '%s' changed to '%s' on server\n",
-			       vlocation->vldb.name,vldb.name);
+		if (strncmp(vldb.name, vlocation->vldb.name,
+			    sizeof(vlocation->vldb.name)) != 0)
+			printk("kAFS: name of volume '%s'"
+			       " changed to '%s' on server\n",
+			       vlocation->vldb.name, vldb.name);
 
-		memcpy(&vlocation->vldb,&vldb,sizeof(vlocation->vldb));
+		memcpy(&vlocation->vldb, &vldb, sizeof(vlocation->vldb));
 
 #if 0
-		/* add volume entry to local cache */
-		ret = afsc_update_vlocation(vlocation);
+		/* TODO update volume entry in local cache */
 #endif
 
 		up_write(&vlocation->cell->vl_sem);
 
-		if (ret<0)
-			printk("kAFS: failed to update local cache: %d\n",ret);
+		if (ret < 0)
+			printk("kAFS: failed to update local cache: %d\n", ret);
 
-		afs_kafstimod_add_timer(&vlocation->upd_timer,AFS_VLDB_TIMEOUT);
+		afs_kafstimod_add_timer(&vlocation->upd_timer,
+					AFS_VLDB_TIMEOUT);
 		afs_put_vlocation(vlocation);
 		_leave(" [found]");
 		return;
@@ -763,11 +787,12 @@ static void afs_vlocation_update_attend(
 		/* the server is locked - retry in a very short while */
 	case -EBUSY:
 		vlocation->upd_busy_cnt++;
-		if (vlocation->upd_busy_cnt>3)
+		if (vlocation->upd_busy_cnt > 3)
 			goto try_next; /* too many retries */
 
-		afs_vlocation_update_abandon(vlocation,AFS_VLUPD_BUSYSLEEP,0);
-		afs_kafstimod_add_timer(&vlocation->upd_timer,HZ/2);
+		afs_vlocation_update_abandon(vlocation,
+					     AFS_VLUPD_BUSYSLEEP, 0);
+		afs_kafstimod_add_timer(&vlocation->upd_timer, HZ / 2);
 		afs_put_vlocation(vlocation);
 		_leave(" [busy]");
 		return;
@@ -781,7 +806,8 @@ static void afs_vlocation_update_attend(
 		 */
 		if (vlocation->upd_curr_svix == vlocation->cell->vl_curr_svix)
 			vlocation->cell->vl_curr_svix =
-				vlocation->cell->vl_curr_svix % vlocation->cell->vl_naddrs;
+				vlocation->cell->vl_curr_svix %
+				vlocation->cell->vl_naddrs;
 
 	case -EBADRQC:
 	case -EINVAL:
@@ -802,26 +828,30 @@ static void afs_vlocation_update_attend(
 	vlocation->upd_op.server = NULL;
 
 	tmp = vlocation->cell->vl_naddrs;
-	if (tmp==0)
+	if (tmp == 0)
 		goto abandon;
 
 	vlocation->upd_curr_svix++;
-	if (vlocation->upd_curr_svix >= tmp) vlocation->upd_curr_svix = 0;
-	if (vlocation->upd_first_svix >= tmp) vlocation->upd_first_svix = tmp - 1;
+	if (vlocation->upd_curr_svix >= tmp)
+		vlocation->upd_curr_svix = 0;
+	if (vlocation->upd_first_svix >= tmp)
+		vlocation->upd_first_svix = tmp - 1;
 
 	/* move to the next server */
-	if (vlocation->upd_curr_svix!=vlocation->upd_first_svix) {
+	if (vlocation->upd_curr_svix != vlocation->upd_first_svix) {
 		afs_vlocation_update_begin(vlocation);
 		_leave(" [next]");
 		return;
 	}
 
 	/* run out of servers to try - was the volume rejected? */
-	if (vlocation->upd_rej_cnt>0) {
-		printk("kAFS: Active volume no longer valid '%s'\n",vlocation->vldb.name);
+	if (vlocation->upd_rej_cnt > 0) {
+		printk("kAFS: Active volume no longer valid '%s'\n",
+		       vlocation->vldb.name);
 		vlocation->valid = 0;
-		afs_vlocation_update_abandon(vlocation,AFS_VLUPD_SLEEP,0);
-		afs_kafstimod_add_timer(&vlocation->upd_timer,AFS_VLDB_TIMEOUT);
+		afs_vlocation_update_abandon(vlocation, AFS_VLUPD_SLEEP, 0);
+		afs_kafstimod_add_timer(&vlocation->upd_timer,
+					AFS_VLDB_TIMEOUT);
 		afs_put_vlocation(vlocation);
 		_leave(" [invalidated]");
 		return;
@@ -829,8 +859,8 @@ static void afs_vlocation_update_attend(
 
 	/* abandon the update */
  abandon:
-	afs_vlocation_update_abandon(vlocation,AFS_VLUPD_SLEEP,ret);
-	afs_kafstimod_add_timer(&vlocation->upd_timer,HZ*10);
+	afs_vlocation_update_abandon(vlocation, AFS_VLUPD_SLEEP, ret);
+	afs_kafstimod_add_timer(&vlocation->upd_timer, HZ * 10);
 	afs_put_vlocation(vlocation);
 	_leave(" [abandoned]");
 
@@ -842,11 +872,12 @@ static void afs_vlocation_update_attend(
  * - called in kafsasyncd context when it's dying due to rmmod
  * - the call has already been aborted and put()'d
  */
-static void afs_vlocation_update_discard(afs_async_op_t *op)
+static void afs_vlocation_update_discard(struct afs_async_op *op)
 {
-	afs_vlocation_t *vlocation = list_entry(op,afs_vlocation_t,upd_op);
+	struct afs_vlocation *vlocation =
+		list_entry(op, struct afs_vlocation, upd_op);
 
-	_enter("%s",vlocation->vldb.name);
+	_enter("%s", vlocation->vldb.name);
 
 	afs_put_server(op->server);
 	op->server = NULL;
@@ -870,11 +901,11 @@ static cachefs_match_val_t afs_vlocation
 
 	_enter("{%s},{%s}", vlocation->vldb.name, vldb->name);
 
-	if (strncmp(vlocation->vldb.name,
-		    vldb->name,
-		    sizeof(vldb->name)) == 0) {
+	if (strncmp(vlocation->vldb.name, vldb->name, sizeof(vldb->name)) == 0
+	    ) {
 		if (!vlocation->valid ||
-		    vlocation->vldb.rtime == vldb->rtime) {
+		    vlocation->vldb.rtime == vldb->rtime
+		    ) {
 			struct_cpy(&vlocation->vldb, vldb);
 			vlocation->valid = 1;
 			_leave(" = SUCCESS [c->m]");
diff -puN fs/afs/vnode.c~linus fs/afs/vnode.c
--- 25/fs/afs/vnode.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/vnode.c	2004-01-19 22:17:23.000000000 -0800
@@ -30,7 +30,8 @@ struct afs_timer_ops afs_vnode_cb_timed_
 };
 
 #ifdef AFS_CACHING_SUPPORT
-static cachefs_match_val_t afs_vnode_cache_match(void *target, const void *entry);
+static cachefs_match_val_t afs_vnode_cache_match(void *target,
+						 const void *entry);
 static void afs_vnode_cache_update(void *source, void *entry);
 
 struct cachefs_index_def afs_vnode_cache_index_def = {
@@ -49,17 +50,17 @@ struct cachefs_index_def afs_vnode_cache
  */
 static void afs_vnode_cb_timed_out(struct afs_timer *timer)
 {
-	afs_server_t *oldserver;
-	afs_vnode_t *vnode;
+	struct afs_server *oldserver;
+	struct afs_vnode *vnode;
 
-	vnode = list_entry(timer,afs_vnode_t,cb_timeout);
+	vnode = list_entry(timer, struct afs_vnode, cb_timeout);
 
-	_enter("%p",vnode);
+	_enter("%p", vnode);
 
 	/* set the changed flag in the vnode and release the server */
 	spin_lock(&vnode->lock);
 
-	oldserver = xchg(&vnode->cb_server,NULL);
+	oldserver = xchg(&vnode->cb_server, NULL);
 	if (oldserver) {
 		vnode->flags |= AFS_VNODE_CHANGED;
 
@@ -85,28 +86,33 @@ static void afs_vnode_cb_timed_out(struc
  * - starts callback expiry timer
  * - adds to server's callback list
  */
-void afs_vnode_finalise_status_update(afs_vnode_t *vnode, afs_server_t *server, int ret)
+void afs_vnode_finalise_status_update(struct afs_vnode *vnode,
+				      struct afs_server *server,
+				      int ret)
 {
-	afs_server_t *oldserver = NULL;
+	struct afs_server *oldserver = NULL;
 
-	_enter("%p,%p,%d",vnode,server,ret);
+	_enter("%p,%p,%d", vnode, server, ret);
 
 	spin_lock(&vnode->lock);
 
 	vnode->flags &= ~AFS_VNODE_CHANGED;
 
-	if (ret==0) {
+	if (ret == 0) {
 		/* adjust the callback timeout appropriately */
-		afs_kafstimod_add_timer(&vnode->cb_timeout,vnode->cb_expiry*HZ);
+		afs_kafstimod_add_timer(&vnode->cb_timeout,
+					vnode->cb_expiry * HZ);
 
 		spin_lock(&afs_cb_hash_lock);
 		list_del(&vnode->cb_hash_link);
-		list_add_tail(&vnode->cb_hash_link,&afs_cb_hash(server,&vnode->fid));
+		list_add_tail(&vnode->cb_hash_link,
+			      &afs_cb_hash(server, &vnode->fid));
 		spin_unlock(&afs_cb_hash_lock);
 
-		/* swap ref to old callback server with that for new callback server */
-		oldserver = xchg(&vnode->cb_server,server);
-		if (oldserver!=server) {
+		/* swap ref to old callback server with that for new callback
+		 * server */
+		oldserver = xchg(&vnode->cb_server, server);
+		if (oldserver != server) {
 			if (oldserver) {
 				spin_lock(&oldserver->cb_lock);
 				list_del_init(&vnode->cb_link);
@@ -115,7 +121,7 @@ void afs_vnode_finalise_status_update(af
 
 			afs_get_server(server);
 			spin_lock(&server->cb_lock);
-			list_add_tail(&vnode->cb_link,&server->cb_promises);
+			list_add_tail(&vnode->cb_link, &server->cb_promises);
 			spin_unlock(&server->cb_lock);
 		}
 		else {
@@ -123,9 +129,9 @@ void afs_vnode_finalise_status_update(af
 			oldserver = NULL;
 		}
 	}
-	else if (ret==-ENOENT) {
+	else if (ret == -ENOENT) {
 		/* the file was deleted - clear the callback timeout */
-		oldserver = xchg(&vnode->cb_server,NULL);
+		oldserver = xchg(&vnode->cb_server, NULL);
 		afs_kafstimod_del_timer(&vnode->cb_timeout);
 
 		_debug("got NOENT from server - marking file deleted");
@@ -152,15 +158,16 @@ void afs_vnode_finalise_status_update(af
  *   - there are any outstanding ops that will fetch the status
  * - TODO implement local caching
  */
-int afs_vnode_fetch_status(afs_vnode_t *vnode)
+int afs_vnode_fetch_status(struct afs_vnode *vnode)
 {
-	afs_server_t *server;
+	struct afs_server *server;
 	int ret;
 
-	DECLARE_WAITQUEUE(myself,current);
+	DECLARE_WAITQUEUE(myself, current);
 
-	_enter("%s,{%u,%u,%u}",vnode->volume->vlocation->vldb.name,
-	       vnode->fid.vid,vnode->fid.vnode,vnode->fid.unique);
+	_enter("%s,{%u,%u,%u}",
+	       vnode->volume->vlocation->vldb.name,
+	       vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique);
 
 	if (!(vnode->flags & AFS_VNODE_CHANGED) && vnode->cb_server) {
 		_leave(" [unchanged]");
@@ -180,19 +187,23 @@ int afs_vnode_fetch_status(afs_vnode_t *
 		return 0;
 	}
 
-	if (vnode->update_cnt>0) {
+	if (vnode->update_cnt > 0) {
 		/* someone else started a fetch */
 		set_current_state(TASK_UNINTERRUPTIBLE);
-		add_wait_queue(&vnode->update_waitq,&myself);
+		add_wait_queue(&vnode->update_waitq, &myself);
 
 		/* wait for the status to be updated */
 		for (;;) {
-			if (!(vnode->flags & AFS_VNODE_CHANGED))	break;
-			if (vnode->flags & AFS_VNODE_DELETED)		break;
-
-			/* it got updated and invalidated all before we saw it */
-			if (vnode->update_cnt==0) {
-				remove_wait_queue(&vnode->update_waitq,&myself);
+			if (!(vnode->flags & AFS_VNODE_CHANGED))
+				break;
+			if (vnode->flags & AFS_VNODE_DELETED)
+				break;
+
+			/* it got updated and invalidated all before we saw
+			 * it */
+			if (vnode->update_cnt == 0) {
+				remove_wait_queue(&vnode->update_waitq,
+						  &myself);
 				set_current_state(TASK_RUNNING);
 				goto get_anyway;
 			}
@@ -205,7 +216,7 @@ int afs_vnode_fetch_status(afs_vnode_t *
 			spin_lock(&vnode->lock);
 		}
 
-		remove_wait_queue(&vnode->update_waitq,&myself);
+		remove_wait_queue(&vnode->update_waitq, &myself);
 		spin_unlock(&vnode->lock);
 		set_current_state(TASK_RUNNING);
 
@@ -218,23 +229,24 @@ int afs_vnode_fetch_status(afs_vnode_t *
 
 	spin_unlock(&vnode->lock);
 
-	/* merge AFS status fetches and clear outstanding callback on this vnode */
+	/* merge AFS status fetches and clear outstanding callback on this
+	 * vnode */
 	do {
 		/* pick a server to query */
-		ret = afs_volume_pick_fileserver(vnode->volume,&server);
+		ret = afs_volume_pick_fileserver(vnode->volume, &server);
 		if (ret<0)
 			return ret;
 
-		_debug("USING SERVER: %08x\n",ntohl(server->addr.s_addr));
+		_debug("USING SERVER: %08x\n", ntohl(server->addr.s_addr));
 
-		ret = afs_rxfs_fetch_file_status(server,vnode,NULL);
+		ret = afs_rxfs_fetch_file_status(server, vnode, NULL);
 
-	} while (!afs_volume_release_fileserver(vnode->volume,server,ret));
+	} while (!afs_volume_release_fileserver(vnode->volume, server, ret));
 
 	/* adjust the flags */
-	afs_vnode_finalise_status_update(vnode,server,ret);
+	afs_vnode_finalise_status_update(vnode, server, ret);
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end afs_vnode_fetch_status() */
 
@@ -243,9 +255,10 @@ int afs_vnode_fetch_status(afs_vnode_t *
  * fetch file data from the volume
  * - TODO implement caching and server failover
  */
-int afs_vnode_fetch_data(afs_vnode_t *vnode, struct afs_rxfs_fetch_descriptor *desc)
+int afs_vnode_fetch_data(struct afs_vnode *vnode,
+			 struct afs_rxfs_fetch_descriptor *desc)
 {
-	afs_server_t *server;
+	struct afs_server *server;
 	int ret;
 
 	_enter("%s,{%u,%u,%u}",
@@ -259,23 +272,24 @@ int afs_vnode_fetch_data(afs_vnode_t *vn
 	vnode->update_cnt++;
 	spin_unlock(&vnode->lock);
 
-	/* merge in AFS status fetches and clear outstanding callback on this vnode */
+	/* merge in AFS status fetches and clear outstanding callback on this
+	 * vnode */
 	do {
 		/* pick a server to query */
-		ret = afs_volume_pick_fileserver(vnode->volume,&server);
-		if (ret<0)
+		ret = afs_volume_pick_fileserver(vnode->volume, &server);
+		if (ret < 0)
 			return ret;
 
-		_debug("USING SERVER: %08x\n",ntohl(server->addr.s_addr));
+		_debug("USING SERVER: %08x\n", ntohl(server->addr.s_addr));
 
-		ret = afs_rxfs_fetch_file_data(server,vnode,desc,NULL);
+		ret = afs_rxfs_fetch_file_data(server, vnode, desc, NULL);
 
-	} while (!afs_volume_release_fileserver(vnode->volume,server,ret));
+	} while (!afs_volume_release_fileserver(vnode->volume, server, ret));
 
 	/* adjust the flags */
-	afs_vnode_finalise_status_update(vnode,server,ret);
+	afs_vnode_finalise_status_update(vnode, server, ret);
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 
 } /* end afs_vnode_fetch_data() */
@@ -285,9 +299,9 @@ int afs_vnode_fetch_data(afs_vnode_t *vn
  * break any outstanding callback on a vnode
  * - only relevent to server that issued it
  */
-int afs_vnode_give_up_callback(afs_vnode_t *vnode)
+int afs_vnode_give_up_callback(struct afs_vnode *vnode)
 {
-	afs_server_t *server;
+	struct afs_server *server;
 	int ret;
 
 	_enter("%s,{%u,%u,%u}",
@@ -305,7 +319,7 @@ int afs_vnode_give_up_callback(afs_vnode
 
 	afs_kafstimod_del_timer(&vnode->cb_timeout);
 
-	server = xchg(&vnode->cb_server,NULL);
+	server = xchg(&vnode->cb_server, NULL);
 	if (server) {
 		vnode->flags |= AFS_VNODE_CHANGED;
 
@@ -318,11 +332,11 @@ int afs_vnode_give_up_callback(afs_vnode
 
 	ret = 0;
 	if (server) {
-		ret = afs_rxfs_give_up_callback(server,vnode);
+		ret = afs_rxfs_give_up_callback(server, vnode);
 		afs_put_server(server);
 	}
 
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end afs_vnode_give_up_callback() */
 
@@ -331,7 +345,8 @@ int afs_vnode_give_up_callback(afs_vnode
  * match a vnode record stored in the cache
  */
 #ifdef AFS_CACHING_SUPPORT
-static cachefs_match_val_t afs_vnode_cache_match(void *target, const void *entry)
+static cachefs_match_val_t afs_vnode_cache_match(void *target,
+						 const void *entry)
 {
 	const struct afs_cache_vnode *cvnode = entry;
 	struct afs_vnode *vnode = target;
diff -puN fs/afs/vnode.h~linus fs/afs/vnode.h
--- 25/fs/afs/vnode.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/vnode.h	2004-01-19 22:17:23.000000000 -0800
@@ -70,21 +70,22 @@ struct afs_vnode
 	afs_callback_type_t	cb_type;	/* type of callback */
 };
 
-static inline afs_vnode_t *AFS_FS_I(struct inode *inode)
+static inline struct afs_vnode *AFS_FS_I(struct inode *inode)
 {
-	return container_of(inode,afs_vnode_t,vfs_inode);
+	return container_of(inode,struct afs_vnode,vfs_inode);
 }
 
-static inline struct inode *AFS_VNODE_TO_I(afs_vnode_t *vnode)
+static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode)
 {
 	return &vnode->vfs_inode;
 }
 
-extern int afs_vnode_fetch_status(afs_vnode_t *vnode);
+extern int afs_vnode_fetch_status(struct afs_vnode *vnode);
 
-extern int afs_vnode_fetch_data(afs_vnode_t *vnode, struct afs_rxfs_fetch_descriptor *desc);
+extern int afs_vnode_fetch_data(struct afs_vnode *vnode,
+				struct afs_rxfs_fetch_descriptor *desc);
 
-extern int afs_vnode_give_up_callback(afs_vnode_t *vnode);
+extern int afs_vnode_give_up_callback(struct afs_vnode *vnode);
 
 extern struct afs_timer_ops afs_vnode_cb_timed_out_ops;
 
diff -puN fs/afs/volume.c~linus fs/afs/volume.c
--- 25/fs/afs/volume.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/afs/volume.c	2004-01-19 22:17:23.000000000 -0800
@@ -27,7 +27,8 @@
 const char *afs_voltypes[] = { "R/W", "R/O", "BAK" };
 
 #ifdef AFS_CACHING_SUPPORT
-static cachefs_match_val_t afs_volume_cache_match(void *target, const void *entry);
+static cachefs_match_val_t afs_volume_cache_match(void *target,
+						  const void *entry);
 static void afs_volume_cache_update(void *source, void *entry);
 
 struct cachefs_index_def afs_volume_cache_index_def = {
@@ -45,7 +46,8 @@ struct cachefs_index_def afs_volume_cach
  * lookup a volume by name
  * - this can be one of the following:
  *	"%[cell:]volume[.]"		R/W volume
- *	"#[cell:]volume[.]"		R/O or R/W volume (rwparent=0), or R/W (rwparent=1) volume
+ *	"#[cell:]volume[.]"		R/O or R/W volume (rwparent=0),
+ *					 or R/W (rwparent=1) volume
  *	"%[cell:]volume.readonly"	R/O volume
  *	"#[cell:]volume.readonly"	R/O volume
  *	"%[cell:]volume.backup"		Backup volume
@@ -53,14 +55,17 @@ struct cachefs_index_def afs_volume_cach
  *
  * The cell name is optional, and defaults to the current cell.
  *
- * See "The Rules of Mount Point Traversal" in Chapter 5 of the AFS SysAdmin Guide
+ * See "The Rules of Mount Point Traversal" in Chapter 5 of the AFS SysAdmin
+ * Guide
  * - Rule 1: Explicit type suffix forces access of that type or nothing
  *           (no suffix, then use Rule 2 & 3)
- * - Rule 2: If parent volume is R/O, then mount R/O volume by preference, R/W if not available
- * - Rule 3: If parent volume is R/W, then only mount R/W volume unless explicitly told otherwise
+ * - Rule 2: If parent volume is R/O, then mount R/O volume by preference, R/W
+ *           if not available
+ * - Rule 3: If parent volume is R/W, then only mount R/W volume unless
+ *           explicitly told otherwise
  */
 int afs_volume_lookup(const char *name, struct afs_cell *cell, int rwpath,
-		      afs_volume_t **_volume)
+		      struct afs_volume **_volume)
 {
 	struct afs_vlocation *vlocation = NULL;
 	struct afs_volume *volume = NULL;
@@ -108,6 +113,7 @@ int afs_volume_lookup(const char *name, 
 	if (volname) {
 		cellname = name;
 		cellnamesz = volname - name;
+		volname++;
 	}
 	else {
 		volname = name;
@@ -127,7 +133,8 @@ int afs_volume_lookup(const char *name, 
 	if (cellname || !cell) {
 		ret = afs_cell_lookup(cellname, cellnamesz, &cell);
 		if (ret<0) {
-			printk("kAFS: unable to lookup cell '%s'\n", cellname ?: "");
+			printk("kAFS: unable to lookup cell '%s'\n",
+			       cellname ?: "");
 			goto error;
 		}
 	}
@@ -146,7 +153,7 @@ int afs_volume_lookup(const char *name, 
 		goto error;
 
 	srvtmask = 0;
-	for (loop=0; loop<vlocation->vldb.nservers; loop++)
+	for (loop = 0; loop < vlocation->vldb.nservers; loop++)
 		srvtmask |= vlocation->vldb.srvtmask[loop];
 
 	if (force) {
@@ -177,11 +184,11 @@ int afs_volume_lookup(const char *name, 
 	_debug("creating new volume record");
 
 	ret = -ENOMEM;
-	volume = kmalloc(sizeof(afs_volume_t), GFP_KERNEL);
+	volume = kmalloc(sizeof(struct afs_volume), GFP_KERNEL);
 	if (!volume)
 		goto error_up;
 
-	memset(volume, 0, sizeof(afs_volume_t));
+	memset(volume, 0, sizeof(struct afs_volume));
 	atomic_set(&volume->usage, 1);
 	volume->type		= type;
 	volume->type_force	= force;
@@ -191,12 +198,13 @@ int afs_volume_lookup(const char *name, 
 	init_rwsem(&volume->server_sem);
 
 	/* look up all the applicable server records */
-	for (loop=0; loop<8; loop++) {
+	for (loop = 0; loop < 8; loop++) {
 		if (vlocation->vldb.srvtmask[loop] & (1 << volume->type)) {
-			ret = afs_server_lookup(volume->cell,
-						&vlocation->vldb.servers[loop],
-						&volume->servers[volume->nservers]);
-			if (ret<0)
+			ret = afs_server_lookup(
+				volume->cell,
+				&vlocation->vldb.servers[loop],
+				&volume->servers[volume->nservers]);
+			if (ret < 0)
 				goto error_discard;
 
 			volume->nservers++;
@@ -217,7 +225,8 @@ int afs_volume_lookup(const char *name, 
 	vlocation->vols[type] = volume;
 
  success:
-	_debug("kAFS selected %s volume %08x", afs_voltypes[volume->type], volume->vid);
+	_debug("kAFS selected %s volume %08x",
+	       afs_voltypes[volume->type], volume->vid);
 	*_volume = volume;
 	ret = 0;
 
@@ -234,7 +243,7 @@ int afs_volume_lookup(const char *name, 
  error_discard:
 	up_write(&cell->vl_sem);
 
-	for (loop=volume->nservers-1; loop>=0; loop--)
+	for (loop = volume->nservers - 1; loop >= 0; loop--)
 		afs_put_server(volume->servers[loop]);
 
 	kfree(volume);
@@ -245,23 +254,23 @@ int afs_volume_lookup(const char *name, 
 /*
  * destroy a volume record
  */
-void afs_put_volume(afs_volume_t *volume)
+void afs_put_volume(struct afs_volume *volume)
 {
-	afs_vlocation_t *vlocation;
+	struct afs_vlocation *vlocation;
 	int loop;
 
 	if (!volume)
 		return;
 
-	_enter("%p",volume);
+	_enter("%p", volume);
 
 	vlocation = volume->vlocation;
 
 	/* sanity check */
-	if (atomic_read(&volume->usage)<=0)
-		BUG();
+	BUG_ON(atomic_read(&volume->usage) <= 0);
 
-	/* to prevent a race, the decrement and the dequeue must be effectively atomic */
+	/* to prevent a race, the decrement and the dequeue must be effectively
+	 * atomic */
 	down_write(&vlocation->cell->vl_sem);
 
 	if (likely(!atomic_dec_and_test(&volume->usage))) {
@@ -276,11 +285,11 @@ void afs_put_volume(afs_volume_t *volume
 
 	/* finish cleaning up the volume */
 #ifdef AFS_CACHING_SUPPORT
-	cachefs_relinquish_cookie(volume->cache,0);
+	cachefs_relinquish_cookie(volume->cache, 0);
 #endif
 	afs_put_vlocation(vlocation);
 
-	for (loop=volume->nservers-1; loop>=0; loop--)
+	for (loop = volume->nservers - 1; loop >= 0; loop--)
 		afs_put_server(volume->servers[loop]);
 
 	kfree(volume);
@@ -293,26 +302,28 @@ void afs_put_volume(afs_volume_t *volume
  * pick a server to use to try accessing this volume
  * - returns with an elevated usage count on the server chosen
  */
-int afs_volume_pick_fileserver(afs_volume_t *volume, afs_server_t **_server)
+int afs_volume_pick_fileserver(struct afs_volume *volume,
+			       struct afs_server **_server)
 {
-	afs_server_t *server;
+	struct afs_server *server;
 	int ret, state, loop;
 
-	_enter("%s",volume->vlocation->vldb.name);
+	_enter("%s", volume->vlocation->vldb.name);
 
 	down_read(&volume->server_sem);
 
 	/* handle the no-server case */
-	if (volume->nservers==0) {
+	if (volume->nservers == 0) {
 		ret = volume->rjservers ? -ENOMEDIUM : -ESTALE;
 		up_read(&volume->server_sem);
-		_leave(" = %d [no servers]",ret);
+		_leave(" = %d [no servers]", ret);
 		return ret;
 	}
 
-	/* basically, just search the list for the first live server and use that */
+	/* basically, just search the list for the first live server and use
+	 * that */
 	ret = 0;
-	for (loop=0; loop<volume->nservers; loop++) {
+	for (loop = 0; loop < volume->nservers; loop++) {
 		server = volume->servers[loop];
 		state = server->fs_state;
 
@@ -322,30 +333,34 @@ int afs_volume_pick_fileserver(afs_volum
 			afs_get_server(server);
 			up_read(&volume->server_sem);
 			*_server = server;
-			_leave(" = 0 (picked %08x)",ntohl(server->addr.s_addr));
+			_leave(" = 0 (picked %08x)",
+			       ntohl(server->addr.s_addr));
 			return 0;
 
 		case -ENETUNREACH:
-			if (ret==0)
+			if (ret == 0)
 				ret = state;
 			break;
 
 		case -EHOSTUNREACH:
-			if (ret==0 || ret==-ENETUNREACH)
+			if (ret == 0 ||
+			    ret == -ENETUNREACH)
 				ret = state;
 			break;
 
 		case -ECONNREFUSED:
-			if (ret==0 || ret==-ENETUNREACH || ret==-EHOSTUNREACH)
+			if (ret == 0 ||
+			    ret == -ENETUNREACH ||
+			    ret == -EHOSTUNREACH)
 				ret = state;
 			break;
 
 		default:
 		case -EREMOTEIO:
-			if (ret==0 ||
-			    ret==-ENETUNREACH ||
-			    ret==-EHOSTUNREACH ||
-			    ret==-ECONNREFUSED)
+			if (ret == 0 ||
+			    ret == -ENETUNREACH ||
+			    ret == -EHOSTUNREACH ||
+			    ret == -ECONNREFUSED)
 				ret = state;
 			break;
 		}
@@ -355,7 +370,7 @@ int afs_volume_pick_fileserver(afs_volum
 	 * - TODO: handle the no active servers case better
 	 */
 	up_read(&volume->server_sem);
-	_leave(" = %d",ret);
+	_leave(" = %d", ret);
 	return ret;
 } /* end afs_volume_pick_fileserver() */
 
@@ -366,11 +381,15 @@ int afs_volume_pick_fileserver(afs_volum
  * - records result of using a particular server to access a volume
  * - return 0 to try again, 1 if okay or to issue error
  */
-int afs_volume_release_fileserver(afs_volume_t *volume, afs_server_t *server, int result)
+int afs_volume_release_fileserver(struct afs_volume *volume,
+				  struct afs_server *server,
+				  int result)
 {
 	unsigned loop;
 
-	_enter("%s,%08x,%d",volume->vlocation->vldb.name,ntohl(server->addr.s_addr),result);
+	_enter("%s,%08x,%d",
+	       volume->vlocation->vldb.name, ntohl(server->addr.s_addr),
+	       result);
 
 	switch (result) {
 		/* success */
@@ -383,9 +402,10 @@ int afs_volume_release_fileserver(afs_vo
 		server->fs_act_jif = jiffies;
 		down_write(&volume->server_sem);
 
-		/* first, find where the server is in the active list (if it is) */
-		for (loop=0; loop<volume->nservers; loop++)
-			if (volume->servers[loop]==server)
+		/* first, find where the server is in the active list (if it
+		 * is) */
+		for (loop = 0; loop < volume->nservers; loop++)
+			if (volume->servers[loop] == server)
 				goto present;
 
 		/* no longer there - may have been discarded by another op */
@@ -394,20 +414,22 @@ int afs_volume_release_fileserver(afs_vo
 	present:
 		volume->nservers--;
 		memmove(&volume->servers[loop],
-			&volume->servers[loop+1],
-			sizeof(volume->servers[loop]) * (volume->nservers - loop)
-			);
+			&volume->servers[loop + 1],
+			sizeof(volume->servers[loop]) *
+			(volume->nservers - loop));
 		volume->servers[volume->nservers] = NULL;
 		afs_put_server(server);
 		volume->rjservers++;
 
-		if (volume->nservers>0)
+		if (volume->nservers > 0)
 			/* another server might acknowledge its existence */
 			goto try_next_server_upw;
 
-		/* handle the case where all the fileservers have rejected the volume
+		/* handle the case where all the fileservers have rejected the
+		 * volume
 		 * - TODO: try asking the fileservers for volume information
-		 * - TODO: contact the VL server again to see if the volume is no longer registered
+		 * - TODO: contact the VL server again to see if the volume is
+		 *         no longer registered
 		 */
 		up_write(&volume->server_sem);
 		afs_put_server(server);
@@ -427,7 +449,7 @@ int afs_volume_release_fileserver(afs_vo
 		if (!server->fs_state) {
 			server->fs_dead_jif = jiffies + HZ * 10;
 			server->fs_state = result;
-			printk("kAFS: SERVER DEAD state=%d\n",result);
+			printk("kAFS: SERVER DEAD state=%d\n", result);
 		}
 		spin_unlock(&server->fs_lock);
 		goto try_next_server;
@@ -460,7 +482,8 @@ int afs_volume_release_fileserver(afs_vo
  * match a volume hash record stored in the cache
  */
 #ifdef AFS_CACHING_SUPPORT
-static cachefs_match_val_t afs_volume_cache_match(void *target, const void *entry)
+static cachefs_match_val_t afs_volume_cache_match(void *target,
+						  const void *entry)
 {
 	const struct afs_cache_vhash *vhash = entry;
 	struct afs_volume *volume = target;
diff -puN fs/binfmt_elf.c~linus fs/binfmt_elf.c
--- 25/fs/binfmt_elf.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/binfmt_elf.c	2004-01-19 22:17:23.000000000 -0800
@@ -349,6 +349,7 @@ static unsigned long load_elf_interp(str
 	    	elf_type |= MAP_FIXED;
 
 	    map_addr = elf_map(interpreter, load_addr + vaddr, eppnt, elf_prot, elf_type);
+	    error = map_addr;
 	    if (BAD_ADDR(map_addr))
 	    	goto out_close;
 
@@ -863,7 +864,8 @@ out:
 	/* error cleanup */
 out_free_dentry:
 	allow_write_access(interpreter);
-	fput(interpreter);
+	if (interpreter)
+		fput(interpreter);
 out_free_interp:
 	if (elf_interpreter)
 		kfree(elf_interpreter);
diff -puN fs/bio.c~linus fs/bio.c
--- 25/fs/bio.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/bio.c	2004-01-19 22:17:23.000000000 -0800
@@ -290,7 +290,9 @@ int bio_get_nr_vecs(struct block_device 
  *
  *	Attempt to add a page to the bio_vec maplist. This can fail for a
  *	number of reasons, such as the bio being full or target block
- *	device limitations.
+ *	device limitations. The target block device must allow bio's
+ *      smaller than PAGE_SIZE, so it is always possible to add a single
+ *      page to an empty bio.
  */
 int bio_add_page(struct bio *bio, struct page *page, unsigned int len,
 		 unsigned int offset)
@@ -592,7 +594,7 @@ static void bio_dirty_fn(void *data);
 
 static DECLARE_WORK(bio_dirty_work, bio_dirty_fn, NULL);
 static spinlock_t bio_dirty_lock = SPIN_LOCK_UNLOCKED;
-static struct bio *bio_dirty_list = NULL;
+static struct bio *bio_dirty_list;
 
 /*
  * This runs in process context
diff -puN fs/block_dev.c~linus fs/block_dev.c
--- 25/fs/block_dev.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/block_dev.c	2004-01-19 22:17:23.000000000 -0800
@@ -25,6 +25,22 @@
 #include <linux/namei.h>
 #include <asm/uaccess.h>
 
+struct bdev_inode {
+	struct block_device bdev;
+	struct inode vfs_inode;
+};
+
+static inline struct bdev_inode *BDEV_I(struct inode *inode)
+{
+	return container_of(inode, struct bdev_inode, vfs_inode);
+}
+
+inline struct block_device *I_BDEV(struct inode *inode)
+{
+	return &BDEV_I(inode)->bdev;
+}
+
+EXPORT_SYMBOL(I_BDEV);
 
 static sector_t max_block(struct block_device *bdev)
 {
@@ -100,10 +116,10 @@ static int
 blkdev_get_block(struct inode *inode, sector_t iblock,
 		struct buffer_head *bh, int create)
 {
-	if (iblock >= max_block(inode->i_bdev))
+	if (iblock >= max_block(I_BDEV(inode)))
 		return -EIO;
 
-	bh->b_bdev = inode->i_bdev;
+	bh->b_bdev = I_BDEV(inode);
 	bh->b_blocknr = iblock;
 	set_buffer_mapped(bh);
 	return 0;
@@ -113,10 +129,10 @@ static int
 blkdev_get_blocks(struct inode *inode, sector_t iblock,
 		unsigned long max_blocks, struct buffer_head *bh, int create)
 {
-	if ((iblock + max_blocks) > max_block(inode->i_bdev))
+	if ((iblock + max_blocks) > max_block(I_BDEV(inode)))
 		return -EIO;
 
-	bh->b_bdev = inode->i_bdev;
+	bh->b_bdev = I_BDEV(inode);
 	bh->b_blocknr = iblock;
 	bh->b_size = max_blocks << inode->i_blkbits;
 	set_buffer_mapped(bh);
@@ -128,9 +144,9 @@ blkdev_direct_IO(int rw, struct kiocb *i
 			loff_t offset, unsigned long nr_segs)
 {
 	struct file *file = iocb->ki_filp;
-	struct inode *inode = file->f_dentry->d_inode->i_mapping->host;
+	struct inode *inode = file->f_mapping->host;
 
-	return blockdev_direct_IO(rw, iocb, inode, inode->i_bdev, iov, offset,
+	return blockdev_direct_IO(rw, iocb, inode, I_BDEV(inode), iov, offset,
 				nr_segs, blkdev_get_blocks, NULL);
 }
 
@@ -161,11 +177,10 @@ static int blkdev_commit_write(struct fi
  */
 static loff_t block_llseek(struct file *file, loff_t offset, int origin)
 {
-	struct inode *bd_inode;
+	struct inode *bd_inode = file->f_mapping->host;
 	loff_t size;
 	loff_t retval;
 
-	bd_inode = file->f_dentry->d_inode->i_bdev->bd_inode;
 	down(&bd_inode->i_sem);
 	size = i_size_read(bd_inode);
 
@@ -188,15 +203,13 @@ static loff_t block_llseek(struct file *
 }
 	
 /*
- *	Filp may be NULL when we are called by an msync of a vma
- *	since the vma has no handle.
+ *	Filp is never NULL; the only case when ->fsync() is called with
+ *	NULL first argument is nfsd_sync_dir() and that's not a directory.
  */
  
 static int block_fsync(struct file *filp, struct dentry *dentry, int datasync)
 {
-	struct inode * inode = dentry->d_inode;
-
-	return sync_blockdev(inode->i_bdev);
+	return sync_blockdev(I_BDEV(filp->f_mapping->host));
 }
 
 /*
@@ -206,16 +219,6 @@ static int block_fsync(struct file *filp
 static spinlock_t bdev_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
 static kmem_cache_t * bdev_cachep;
 
-struct bdev_inode {
-	struct block_device bdev;
-	struct inode vfs_inode;
-};
-
-static inline struct bdev_inode *BDEV_I(struct inode *inode)
-{
-	return container_of(inode, struct bdev_inode, vfs_inode);
-}
-
 static struct inode *bdev_alloc_inode(struct super_block *sb)
 {
 	struct bdev_inode *ei = kmem_cache_alloc(bdev_cachep, SLAB_KERNEL);
@@ -387,26 +390,27 @@ void bdput(struct block_device *bdev)
 
 EXPORT_SYMBOL(bdput);
  
-int bd_acquire(struct inode *inode)
+static struct block_device *bd_acquire(struct inode *inode)
 {
 	struct block_device *bdev;
 	spin_lock(&bdev_lock);
-	if (inode->i_bdev && igrab(inode->i_bdev->bd_inode)) {
+	bdev = inode->i_bdev;
+	if (bdev && igrab(bdev->bd_inode)) {
 		spin_unlock(&bdev_lock);
-		return 0;
+		return bdev;
 	}
 	spin_unlock(&bdev_lock);
 	bdev = bdget(inode->i_rdev);
-	if (!bdev)
-		return -ENOMEM;
-	spin_lock(&bdev_lock);
-	if (inode->i_bdev)
-		__bd_forget(inode);
-	inode->i_bdev = bdev;
-	inode->i_mapping = bdev->bd_inode->i_mapping;
-	list_add(&inode->i_devices, &bdev->bd_inodes);
-	spin_unlock(&bdev_lock);
-	return 0;
+	if (bdev) {
+		spin_lock(&bdev_lock);
+		if (inode->i_bdev)
+			__bd_forget(inode);
+		inode->i_bdev = bdev;
+		inode->i_mapping = bdev->bd_inode->i_mapping;
+		list_add(&inode->i_devices, &bdev->bd_inodes);
+		spin_unlock(&bdev_lock);
+	}
+	return bdev;
 }
 
 /* Call when you free inode */
@@ -531,13 +535,14 @@ static void bd_set_size(struct block_dev
 	bdev->bd_inode->i_blkbits = blksize_bits(bsize);
 }
 
-static int do_open(struct block_device *bdev, struct inode *inode, struct file *file)
+static int do_open(struct block_device *bdev, struct file *file)
 {
 	struct module *owner = NULL;
 	struct gendisk *disk;
 	int ret = -ENXIO;
 	int part;
 
+	file->f_mapping = bdev->bd_inode->i_mapping;
 	lock_kernel();
 	disk = get_gendisk(bdev->bd_dev, &part);
 	if (!disk) {
@@ -554,7 +559,7 @@ static int do_open(struct block_device *
 		if (!part) {
 			struct backing_dev_info *bdi;
 			if (disk->fops->open) {
-				ret = disk->fops->open(inode, file);
+				ret = disk->fops->open(bdev->bd_inode, file);
 				if (ret)
 					goto out_first;
 			}
@@ -599,7 +604,7 @@ static int do_open(struct block_device *
 		module_put(owner);
 		if (bdev->bd_contains == bdev) {
 			if (bdev->bd_disk->fops->open) {
-				ret = bdev->bd_disk->fops->open(inode, file);
+				ret = bdev->bd_disk->fops->open(bdev->bd_inode, file);
 				if (ret)
 					goto out;
 			}
@@ -647,7 +652,7 @@ int blkdev_get(struct block_device *bdev
 	fake_file.f_dentry = &fake_dentry;
 	fake_dentry.d_inode = bdev->bd_inode;
 
-	return do_open(bdev, bdev->bd_inode, &fake_file);
+	return do_open(bdev, &fake_file);
 }
 
 EXPORT_SYMBOL(blkdev_get);
@@ -665,10 +670,9 @@ int blkdev_open(struct inode * inode, st
 	 */
 	filp->f_flags |= O_LARGEFILE;
 
-	bd_acquire(inode);
-	bdev = inode->i_bdev;
+	bdev = bd_acquire(inode);
 
-	res = do_open(bdev, inode, filp);
+	res = do_open(bdev, filp);
 	if (res)
 		return res;
 
@@ -696,7 +700,7 @@ int blkdev_put(struct block_device *bdev
 		switch (kind) {
 		case BDEV_FILE:
 		case BDEV_FS:
-			sync_blockdev(bd_inode->i_bdev);
+			sync_blockdev(bdev);
 			break;
 		}
 		kill_bdev(bdev);
@@ -734,11 +738,12 @@ int blkdev_put(struct block_device *bdev
 
 EXPORT_SYMBOL(blkdev_put);
 
-int blkdev_close(struct inode * inode, struct file * filp)
+static int blkdev_close(struct inode * inode, struct file * filp)
 {
-	if (inode->i_bdev->bd_holder == filp)
-		bd_release(inode->i_bdev);
-	return blkdev_put(inode->i_bdev, BDEV_FILE);
+	struct block_device *bdev = I_BDEV(filp->f_mapping->host);
+	if (bdev->bd_holder == filp)
+		bd_release(bdev);
+	return blkdev_put(bdev, BDEV_FILE);
 }
 
 static ssize_t blkdev_file_write(struct file *file, const char __user *buf,
@@ -757,6 +762,11 @@ static ssize_t blkdev_file_aio_write(str
 	return generic_file_aio_write_nolock(iocb, &local_iov, 1, &iocb->ki_pos);
 }
 
+static int block_ioctl(struct inode *inode, struct file *file, unsigned cmd,
+			unsigned long arg)
+{
+	return blkdev_ioctl(file->f_mapping->host, file, cmd, arg);
+}
 
 struct address_space_operations def_blk_aops = {
 	.readpage	= blkdev_readpage,
@@ -778,7 +788,7 @@ struct file_operations def_blk_fops = {
   	.aio_write	= blkdev_file_aio_write, 
 	.mmap		= generic_file_mmap,
 	.fsync		= block_fsync,
-	.ioctl		= blkdev_ioctl,
+	.ioctl		= block_ioctl,
 	.readv		= generic_file_readv,
 	.writev		= generic_file_writev,
 	.sendfile	= generic_file_sendfile,
@@ -828,11 +838,10 @@ struct block_device *lookup_bdev(const c
 	error = -EACCES;
 	if (nd.mnt->mnt_flags & MNT_NODEV)
 		goto fail;
-	error = bd_acquire(inode);
-	if (error)
+	error = -ENOMEM;
+	bdev = bd_acquire(inode);
+	if (!bdev)
 		goto fail;
-	bdev = inode->i_bdev;
-
 out:
 	path_release(&nd);
 	return bdev;
diff -puN fs/buffer.c~linus fs/buffer.c
--- 25/fs/buffer.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/buffer.c	2004-01-19 22:17:23.000000000 -0800
@@ -314,8 +314,7 @@ int file_fsync(struct file *filp, struct
 asmlinkage long sys_fsync(unsigned int fd)
 {
 	struct file * file;
-	struct dentry * dentry;
-	struct inode * inode;
+	struct address_space *mapping;
 	int ret, err;
 
 	ret = -EBADF;
@@ -323,8 +322,7 @@ asmlinkage long sys_fsync(unsigned int f
 	if (!file)
 		goto out;
 
-	dentry = file->f_dentry;
-	inode = dentry->d_inode;
+	mapping = file->f_mapping;
 
 	ret = -EINVAL;
 	if (!file->f_op || !file->f_op->fsync) {
@@ -333,17 +331,17 @@ asmlinkage long sys_fsync(unsigned int f
 	}
 
 	/* We need to protect against concurrent writers.. */
-	down(&inode->i_sem);
+	down(&mapping->host->i_sem);
 	current->flags |= PF_SYNCWRITE;
-	ret = filemap_fdatawrite(inode->i_mapping);
-	err = file->f_op->fsync(file, dentry, 0);
+	ret = filemap_fdatawrite(mapping);
+	err = file->f_op->fsync(file, file->f_dentry, 0);
 	if (!ret)
 		ret = err;
-	err = filemap_fdatawait(inode->i_mapping);
+	err = filemap_fdatawait(mapping);
 	if (!ret)
 		ret = err;
 	current->flags &= ~PF_SYNCWRITE;
-	up(&inode->i_sem);
+	up(&mapping->host->i_sem);
 
 out_putf:
 	fput(file);
@@ -354,8 +352,7 @@ out:
 asmlinkage long sys_fdatasync(unsigned int fd)
 {
 	struct file * file;
-	struct dentry * dentry;
-	struct inode * inode;
+	struct address_space *mapping;
 	int ret, err;
 
 	ret = -EBADF;
@@ -363,24 +360,23 @@ asmlinkage long sys_fdatasync(unsigned i
 	if (!file)
 		goto out;
 
-	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);
+	mapping = file->f_mapping;
+
+	down(&mapping->host->i_sem);
 	current->flags |= PF_SYNCWRITE;
-	ret = filemap_fdatawrite(inode->i_mapping);
-	err = file->f_op->fsync(file, dentry, 1);
+	ret = filemap_fdatawrite(mapping);
+	err = file->f_op->fsync(file, file->f_dentry, 1);
 	if (!ret)
 		ret = err;
-	err = filemap_fdatawait(inode->i_mapping);
+	err = filemap_fdatawait(mapping);
 	if (!ret)
 		ret = err;
 	current->flags &= ~PF_SYNCWRITE;
-	up(&inode->i_sem);
+	up(&mapping->host->i_sem);
 
 out_putf:
 	fput(file);
@@ -487,7 +483,7 @@ void invalidate_bdev(struct block_device
  */
 static void free_more_memory(void)
 {
-	struct zone *zone;
+	struct zone **zones;
 	pg_data_t *pgdat;
 
 	wakeup_bdflush(1024);
@@ -495,9 +491,9 @@ static void free_more_memory(void)
 	yield();
 
 	for_each_pgdat(pgdat) {
-		zone = pgdat->node_zonelists[GFP_NOFS&GFP_ZONEMASK].zones[0];
-		if (zone)
-			try_to_free_pages(zone, GFP_NOFS, 0);
+		zones = pgdat->node_zonelists[GFP_NOFS&GFP_ZONEMASK].zones;
+		if (*zones)
+			try_to_free_pages(zones, GFP_NOFS, 0);
 	}
 }
 
@@ -2944,10 +2940,8 @@ static void recalc_bh_state(void)
 	if (__get_cpu_var(bh_accounting).ratelimit++ < 4096)
 		return;
 	__get_cpu_var(bh_accounting).ratelimit = 0;
-	for (i = 0; i < NR_CPUS; i++) {
-		if (cpu_online(i))
-			tot += per_cpu(bh_accounting, i).nr;
-	}
+	for_each_cpu(i)
+		tot += per_cpu(bh_accounting, i).nr;
 	buffer_heads_over_limit = (tot > max_buffer_heads);
 }
 	
diff -puN fs/coda/file.c~linus fs/coda/file.c
--- 25/fs/coda/file.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/coda/file.c	2004-01-19 22:17:23.000000000 -0800
@@ -89,6 +89,7 @@ coda_file_mmap(struct file *coda_file, s
 
 	coda_inode = coda_file->f_dentry->d_inode;
 	host_inode = host_file->f_dentry->d_inode;
+	coda_file->f_mapping = host_file->f_mapping;
 	if (coda_inode->i_mapping == &coda_inode->i_data)
 		coda_inode->i_mapping = host_inode->i_mapping;
 
diff -puN fs/compat_ioctl.c~linus fs/compat_ioctl.c
--- 25/fs/compat_ioctl.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/compat_ioctl.c	2004-01-19 22:17:23.000000000 -0800
@@ -65,6 +65,7 @@
 #include <linux/ncp_fs.h>
 #include <linux/i2c.h>
 #include <linux/i2c-dev.h>
+#include <linux/wireless.h>
 
 #include <net/sock.h>          /* siocdevprivate_ioctl */
 #include <net/bluetooth/bluetooth.h>
@@ -161,9 +162,9 @@ static int do_ext2_ioctl(unsigned int fd
 	case EXT2_IOC32_GETVERSION: cmd = EXT2_IOC_GETVERSION; break;
 	case EXT2_IOC32_SETVERSION: cmd = EXT2_IOC_SETVERSION; break;
 	}
-	return sys_ioctl(fd, cmd, arg);
+	return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
 }
- 
+
 struct video_tuner32 {
 	compat_int_t tuner;
 	char name[32];
@@ -215,7 +216,7 @@ static int get_video_buffer32(struct vid
 
 	if(get_user(tmp, &up->base))
 		return -EFAULT;
-	kp->base = (void *) ((unsigned long)tmp);
+	kp->base = compat_ptr(tmp);
 	__get_user(kp->height, &up->height);
 	__get_user(kp->width, &up->width);
 	__get_user(kp->depth, &up->depth);
@@ -339,7 +340,7 @@ static int do_video_ioctl(unsigned int f
 		unsigned long vx;
 	} karg;
 	mm_segment_t old_fs = get_fs();
-	void *up = (void *)arg;
+	void *up = compat_ptr(arg);
 	int err = 0;
 
 	/* First, convert the command. */
@@ -407,7 +408,7 @@ out:
 
 static int do_siocgstamp(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
-	struct compat_timeval *up = (struct compat_timeval *)arg;
+	struct compat_timeval *up = compat_ptr(arg);
 	struct timeval ktv;
 	mm_segment_t old_fs = get_fs();
 	int err;
@@ -466,7 +467,7 @@ static int dev_ifname32(unsigned int fd,
 	struct ifreq32 ifr32;
 	int err;
 
-	if (copy_from_user(&ifr32, (struct ifreq32 *)arg, sizeof(struct ifreq32)))
+	if (copy_from_user(&ifr32, compat_ptr(arg), sizeof(ifr32)))
 		return -EFAULT;
 
 	dev = dev_get_by_index(ifr32.ifr_ifindex);
@@ -476,7 +477,7 @@ static int dev_ifname32(unsigned int fd,
 	strlcpy(ifr32.ifr_name, dev->name, sizeof(ifr32.ifr_name));
 	dev_put(dev);
 	
-	err = copy_to_user((struct ifreq32 *)arg, &ifr32, sizeof(struct ifreq32));
+	err = copy_to_user(compat_ptr(arg), &ifr32, sizeof(ifr32));
 	return (err ? -EFAULT : 0);
 }
 #endif
@@ -491,7 +492,7 @@ static int dev_ifconf(unsigned int fd, u
 	unsigned int i, j;
 	int err;
 
-	if (copy_from_user(&ifc32, (struct ifconf32 *)arg, sizeof(struct ifconf32)))
+	if (copy_from_user(&ifc32, compat_ptr(arg), sizeof(struct ifconf32)))
 		return -EFAULT;
 
 	if(ifc32.ifcbuf == 0) {
@@ -501,6 +502,7 @@ static int dev_ifconf(unsigned int fd, u
 	} else {
 		ifc.ifc_len = ((ifc32.ifc_len / sizeof (struct ifreq32)) + 1) *
 			sizeof (struct ifreq);
+		/* should the size be limited? -arnd */
 		ifc.ifc_buf = kmalloc (ifc.ifc_len, GFP_KERNEL);
 		if (!ifc.ifc_buf)
 			return -ENOMEM;
@@ -546,7 +548,7 @@ static int dev_ifconf(unsigned int fd, u
 				else
 					ifc32.ifc_len = i - sizeof (struct ifreq32);
 			}
-			if (copy_to_user((struct ifconf32 *)arg, &ifc32, sizeof(struct ifconf32)))
+			if (copy_to_user(compat_ptr(arg), &ifc32, sizeof(struct ifconf32)))
 				err = -EFAULT;
 		}
 	}
@@ -563,7 +565,7 @@ static int ethtool_ioctl(unsigned int fd
 	void *datap;
 	
 	ifr = compat_alloc_user_space(sizeof(*ifr));
-	ifr32 = (struct ifreq32 *) arg;
+	ifr32 = compat_ptr(arg);
 
 	if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
 		return -EFAULT;
@@ -571,18 +573,18 @@ static int ethtool_ioctl(unsigned int fd
 	if (get_user(data, &ifr32->ifr_ifru.ifru_data))
 		return -EFAULT;
 
-	datap = (void *) (unsigned long) data;
+	datap = compat_ptr(data);
 	if (put_user(datap, &ifr->ifr_ifru.ifru_data))
 		return -EFAULT;
 
 	return sys_ioctl(fd, cmd, (unsigned long) ifr);
 }
 
-static int bond_ioctl(unsigned long fd, unsigned int cmd, unsigned long arg)
+static int bond_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
 	struct ifreq kifr;
 	struct ifreq *uifr;
-	struct ifreq32 *ifr32 = (struct ifreq32 *) arg;
+	struct ifreq32 *ifr32 = compat_ptr(arg);
 	mm_segment_t old_fs;
 	int err;
 	u32 data;
@@ -624,7 +626,7 @@ static int bond_ioctl(unsigned long fd, 
 int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
 	struct ifreq *u_ifreq64;
-	struct ifreq32 *u_ifreq32 = (struct ifreq32 *) arg;
+	struct ifreq32 *u_ifreq32 = compat_ptr(arg);
 	char tmp_buf[IFNAMSIZ];
 	void *data64;
 	u32 data32;
@@ -650,23 +652,27 @@ int siocdevprivate_ioctl(unsigned int fd
 static int dev_ifsioc(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
 	struct ifreq ifr;
+	struct ifreq32 *uifr32;
+	struct ifmap32 *uifmap32;
 	mm_segment_t old_fs;
 	int err;
 	
+	uifr32 = compat_ptr(arg);
+	uifmap32 = &uifr32->ifr_ifru.ifru_map;
 	switch (cmd) {
 	case SIOCSIFMAP:
-		err = copy_from_user(&ifr, (struct ifreq32 *)arg, sizeof(ifr.ifr_name));
-		err |= __get_user(ifr.ifr_map.mem_start, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.mem_start));
-		err |= __get_user(ifr.ifr_map.mem_end, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.mem_end));
-		err |= __get_user(ifr.ifr_map.base_addr, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.base_addr));
-		err |= __get_user(ifr.ifr_map.irq, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.irq));
-		err |= __get_user(ifr.ifr_map.dma, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.dma));
-		err |= __get_user(ifr.ifr_map.port, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.port));
+		err = copy_from_user(&ifr, uifr32, sizeof(ifr.ifr_name));
+		err |= __get_user(ifr.ifr_map.mem_start, &uifmap32->mem_start);
+		err |= __get_user(ifr.ifr_map.mem_end, &uifmap32->mem_end);
+		err |= __get_user(ifr.ifr_map.base_addr, &uifmap32->base_addr);
+		err |= __get_user(ifr.ifr_map.irq, &uifmap32->irq);
+		err |= __get_user(ifr.ifr_map.dma, &uifmap32->dma);
+		err |= __get_user(ifr.ifr_map.port, &uifmap32->port);
 		if (err)
 			return -EFAULT;
 		break;
 	default:
-		if (copy_from_user(&ifr, (struct ifreq32 *)arg, sizeof(struct ifreq32)))
+		if (copy_from_user(&ifr, uifr32, sizeof(*uifr32)))
 			return -EFAULT;
 		break;
 	}
@@ -687,17 +693,17 @@ static int dev_ifsioc(unsigned int fd, u
 		case SIOCGIFDSTADDR:
 		case SIOCGIFNETMASK:
 		case SIOCGIFTXQLEN:
-			if (copy_to_user((struct ifreq32 *)arg, &ifr, sizeof(struct ifreq32)))
+			if (copy_to_user(uifr32, &ifr, sizeof(*uifr32)))
 				return -EFAULT;
 			break;
 		case SIOCGIFMAP:
-			err = copy_to_user((struct ifreq32 *)arg, &ifr, sizeof(ifr.ifr_name));
-			err |= __put_user(ifr.ifr_map.mem_start, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.mem_start));
-			err |= __put_user(ifr.ifr_map.mem_end, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.mem_end));
-			err |= __put_user(ifr.ifr_map.base_addr, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.base_addr));
-			err |= __put_user(ifr.ifr_map.irq, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.irq));
-			err |= __put_user(ifr.ifr_map.dma, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.dma));
-			err |= __put_user(ifr.ifr_map.port, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_map.port));
+			err = copy_to_user(uifr32, &ifr, sizeof(ifr.ifr_name));
+			err |= __put_user(ifr.ifr_map.mem_start, &uifmap32->mem_start);
+			err |= __put_user(ifr.ifr_map.mem_end, &uifmap32->mem_end);
+			err |= __put_user(ifr.ifr_map.base_addr, &uifmap32->base_addr);
+			err |= __put_user(ifr.ifr_map.irq, &uifmap32->irq);
+			err |= __put_user(ifr.ifr_map.dma, &uifmap32->dma);
+			err |= __put_user(ifr.ifr_map.port, &uifmap32->port);
 			if (err)
 				err = -EFAULT;
 			break;
@@ -751,25 +757,28 @@ static int routing_ioctl(unsigned int fd
 	struct socket *mysock = sockfd_lookup(fd, &ret);
 
 	if (mysock && mysock->sk && mysock->sk->sk_family == AF_INET6) { /* ipv6 */
-		ret = copy_from_user (&r6.rtmsg_dst, &(((struct in6_rtmsg32 *)arg)->rtmsg_dst),
+		struct in6_rtmsg32 *ur6 = compat_ptr(arg);
+		ret = copy_from_user (&r6.rtmsg_dst, &(ur6->rtmsg_dst),
 			3 * sizeof(struct in6_addr));
-		ret |= __get_user (r6.rtmsg_type, &(((struct in6_rtmsg32 *)arg)->rtmsg_type));
-		ret |= __get_user (r6.rtmsg_dst_len, &(((struct in6_rtmsg32 *)arg)->rtmsg_dst_len));
-		ret |= __get_user (r6.rtmsg_src_len, &(((struct in6_rtmsg32 *)arg)->rtmsg_src_len));
-		ret |= __get_user (r6.rtmsg_metric, &(((struct in6_rtmsg32 *)arg)->rtmsg_metric));
-		ret |= __get_user (r6.rtmsg_info, &(((struct in6_rtmsg32 *)arg)->rtmsg_info));
-		ret |= __get_user (r6.rtmsg_flags, &(((struct in6_rtmsg32 *)arg)->rtmsg_flags));
-		ret |= __get_user (r6.rtmsg_ifindex, &(((struct in6_rtmsg32 *)arg)->rtmsg_ifindex));
+		ret |= __get_user (r6.rtmsg_type, &(ur6->rtmsg_type));
+		ret |= __get_user (r6.rtmsg_dst_len, &(ur6->rtmsg_dst_len));
+		ret |= __get_user (r6.rtmsg_src_len, &(ur6->rtmsg_src_len));
+		ret |= __get_user (r6.rtmsg_metric, &(ur6->rtmsg_metric));
+		ret |= __get_user (r6.rtmsg_info, &(ur6->rtmsg_info));
+		ret |= __get_user (r6.rtmsg_flags, &(ur6->rtmsg_flags));
+		ret |= __get_user (r6.rtmsg_ifindex, &(ur6->rtmsg_ifindex));
 		
 		r = (void *) &r6;
 	} else { /* ipv4 */
-		ret = copy_from_user (&r4.rt_dst, &(((struct rtentry32 *)arg)->rt_dst), 3 * sizeof(struct sockaddr));
-		ret |= __get_user (r4.rt_flags, &(((struct rtentry32 *)arg)->rt_flags));
-		ret |= __get_user (r4.rt_metric, &(((struct rtentry32 *)arg)->rt_metric));
-		ret |= __get_user (r4.rt_mtu, &(((struct rtentry32 *)arg)->rt_mtu));
-		ret |= __get_user (r4.rt_window, &(((struct rtentry32 *)arg)->rt_window));
-		ret |= __get_user (r4.rt_irtt, &(((struct rtentry32 *)arg)->rt_irtt));
-		ret |= __get_user (rtdev, &(((struct rtentry32 *)arg)->rt_dev));
+		struct rtentry32 *ur4 = compat_ptr(arg);
+		ret = copy_from_user (&r4.rt_dst, &(ur4->rt_dst),
+					3 * sizeof(struct sockaddr));
+		ret |= __get_user (r4.rt_flags, &(ur4->rt_flags));
+		ret |= __get_user (r4.rt_metric, &(ur4->rt_metric));
+		ret |= __get_user (r4.rt_mtu, &(ur4->rt_mtu));
+		ret |= __get_user (r4.rt_window, &(ur4->rt_window));
+		ret |= __get_user (r4.rt_irtt, &(ur4->rt_irtt));
+		ret |= __get_user (rtdev, &(ur4->rt_dev));
 		if (rtdev) {
 			ret |= copy_from_user (devname, compat_ptr(rtdev), 15);
 			r4.rt_dev = devname; devname[15] = 0;
@@ -783,7 +792,7 @@ static int routing_ioctl(unsigned int fd
 		return -EFAULT;
 
 	set_fs (KERNEL_DS);
-	ret = sys_ioctl (fd, cmd, (long) r);
+	ret = sys_ioctl (fd, cmd, (unsigned long) r);
 	set_fs (old_fs);
 
 	if (mysock)
@@ -803,14 +812,16 @@ static int hdio_getgeo(unsigned int fd, 
 {
 	mm_segment_t old_fs = get_fs();
 	struct hd_geometry geo;
+	struct hd_geometry32 *ugeo;
 	int err;
 	
 	set_fs (KERNEL_DS);
 	err = sys_ioctl(fd, HDIO_GETGEO, (unsigned long)&geo);
 	set_fs (old_fs);
+	ugeo = compat_ptr(arg);
 	if (!err) {
-		err = copy_to_user ((struct hd_geometry32 *)arg, &geo, 4);
-		err |= __put_user (geo.start, &(((struct hd_geometry32 *)arg)->start));
+		err = copy_to_user (ugeo, &geo, 4);
+		err |= __put_user (geo.start, &ugeo->start);
 	}
 	return err ? -EFAULT : 0;
 }
@@ -848,7 +859,7 @@ static int do_cmap_ptr(__u16 **ptr64, __
 
 	if (get_user(data, ptr32))
 		return -EFAULT;
-	datap = (void *) (unsigned long) data;
+	datap = compat_ptr(data);
 	if (put_user(datap, ptr64))
 		return -EFAULT;
 	return 0;
@@ -861,7 +872,7 @@ static int fb_getput_cmap(unsigned int f
 	int err;
 
 	cmap = compat_alloc_user_space(sizeof(*cmap));
-	cmap32 = (struct fb_cmap32 *) arg;
+	cmap32 = compat_ptr(arg);
 
 	if (copy_in_user(&cmap->start, &cmap32->start, 2 * sizeof(__u32)))
 		return -EFAULT;
@@ -921,7 +932,7 @@ static int fb_get_fscreeninfo(unsigned i
 	struct fb_fix_screeninfo32 *fix32;
 	int err;
 
-	fix32 = (struct fb_fix_screeninfo32 *) arg;
+	fix32 = compat_ptr(arg);
 
 	old_fs = get_fs();
 	set_fs(KERNEL_DS);
@@ -975,7 +986,7 @@ static int hdio_ioctl_trans(unsigned int
 	set_fs(old_fs);
 
 	if(error == 0) {
-		uvp = (unsigned int *)arg;
+		uvp = compat_ptr(arg);
 		if(put_user(kval, uvp))
 			error = -EFAULT;
 	}
@@ -1025,12 +1036,12 @@ static int sg_build_iovec(sg_io_hdr_t *s
 
 		if (get_user(base, &iov32[i].iov_base) ||
 		    get_user(len, &iov32[i].iov_len) ||
-		    put_user((void *)(unsigned long)base, &iov[i].iov_base) ||
+		    put_user(compat_ptr(base), &iov[i].iov_base) ||
 		    put_user(len, &iov[i].iov_len))
 			return -EFAULT;
 	}
 
-	sgio->dxferp = iov;
+	sgio->dxferp = iov; /* FIXME: dereferencing user pointer? */
 	return 0;
 }
 
@@ -1043,7 +1054,7 @@ static int sg_ioctl_trans(unsigned int f
 	void *dxferp;
 	int err;
 
-	sgio32 = (sg_io_hdr32_t *) arg;
+	sgio32 = compat_ptr(arg);
 	if (get_user(iovec_count, &sgio32->iovec_count))
 		return -EFAULT;
 
@@ -1070,7 +1081,7 @@ static int sg_ioctl_trans(unsigned int f
 
 	if (get_user(data, &sgio32->dxferp))
 		return -EFAULT;
-	dxferp = (void *) (unsigned long) data;
+	dxferp = compat_ptr(data);
 	if (iovec_count) {
 		if (sg_build_iovec(sgio, dxferp, iovec_count))
 			return -EFAULT;
@@ -1084,11 +1095,11 @@ static int sg_ioctl_trans(unsigned int f
 
 		if (get_user(data, &sgio32->cmdp))
 			return -EFAULT;
-		cmdp = (unsigned char *) (unsigned long) data;
+		cmdp = compat_ptr(data);
 
 		if (get_user(data, &sgio32->sbp))
 			return -EFAULT;
-		sbp = (unsigned char *) (unsigned long) data;
+		sbp = compat_ptr(data);
 
 		if (put_user(cmdp, &sgio->cmdp) ||
 		    put_user(sbp, &sgio->sbp))
@@ -1101,7 +1112,7 @@ static int sg_ioctl_trans(unsigned int f
 
 	if (get_user(data, &sgio32->usr_ptr))
 		return -EFAULT;
-	if (put_user((void *)(unsigned long)data, &sgio->usr_ptr))
+	if (put_user(compat_ptr(data), &sgio->usr_ptr))
 		return -EFAULT;
 
 	if (copy_in_user(&sgio->status, &sgio32->status,
@@ -1140,7 +1151,7 @@ struct sock_fprog32 {
 
 static int ppp_sock_fprog_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
-	struct sock_fprog32 *u_fprog32 = (struct sock_fprog32 *) arg;
+	struct sock_fprog32 *u_fprog32 = compat_ptr(arg);
 	struct sock_fprog *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog));
 	void *fptr64;
 	u32 fptr32;
@@ -1185,7 +1196,7 @@ static int ppp_gidle(unsigned int fd, un
 	int err;
 
 	idle = compat_alloc_user_space(sizeof(*idle));
-	idle32 = (struct ppp_idle32 *) arg;
+	idle32 = compat_ptr(arg);
 
 	err = sys_ioctl(fd, PPPIOCGIDLE, (unsigned long) idle);
 
@@ -1207,12 +1218,12 @@ static int ppp_scompress(unsigned int fd
 	void *datap;
 
 	odata = compat_alloc_user_space(sizeof(*odata));
-	odata32 = (struct ppp_option_data32 *) arg;
+	odata32 = compat_ptr(arg);
 
 	if (get_user(data, &odata32->ptr))
 		return -EFAULT;
 
-	datap = (void *) (unsigned long) data;
+	datap = compat_ptr(data);
 	if (put_user(datap, &odata->ptr))
 		return -EFAULT;
 
@@ -1296,8 +1307,11 @@ static int mt_ioctl_trans(unsigned int f
 {
 	mm_segment_t old_fs = get_fs();
 	struct mtconfiginfo info;
+	struct mtconfiginfo32 *uinfo32;
 	struct mtget get;
+	struct mtget32 *umget32;
 	struct mtpos pos;
+	struct mtpos32 *upos32;
 	unsigned long kcmd;
 	void *karg;
 	int err = 0;
@@ -1318,15 +1332,17 @@ static int mt_ioctl_trans(unsigned int f
 	case MTIOCSETCONFIG32:
 		kcmd = MTIOCSETCONFIG;
 		karg = &info;
-		err = __get_user(info.mt_type, &((struct mtconfiginfo32 *)arg)->mt_type);
-		err |= __get_user(info.ifc_type, &((struct mtconfiginfo32 *)arg)->ifc_type);
-		err |= __get_user(info.irqnr, &((struct mtconfiginfo32 *)arg)->irqnr);
-		err |= __get_user(info.dmanr, &((struct mtconfiginfo32 *)arg)->dmanr);
-		err |= __get_user(info.port, &((struct mtconfiginfo32 *)arg)->port);
-		err |= __get_user(info.debug, &((struct mtconfiginfo32 *)arg)->debug);
-		err |= __copy_from_user((char *)&info.debug + sizeof(info.debug),
-				     (char *)&((struct mtconfiginfo32 *)arg)->debug
-				     + sizeof(((struct mtconfiginfo32 *)arg)->debug), sizeof(__u32));
+		uinfo32 = compat_ptr(arg);
+		err = __get_user(info.mt_type, &uinfo32->mt_type);
+		err |= __get_user(info.ifc_type, &uinfo32->ifc_type);
+		err |= __get_user(info.irqnr, &uinfo32->irqnr);
+		err |= __get_user(info.dmanr, &uinfo32->dmanr);
+		err |= __get_user(info.port, &uinfo32->port);
+		err |= __get_user(info.debug, &uinfo32->debug);
+		err |= __copy_from_user((char *)&info.debug
+				     + sizeof(info.debug),
+				     (char *)&uinfo32->debug
+				     + sizeof(uinfo32->debug), sizeof(__u32));
 		if (err)
 			return -EFAULT;
 		break;
@@ -1347,26 +1363,29 @@ static int mt_ioctl_trans(unsigned int f
 		return err;
 	switch (cmd) {
 	case MTIOCPOS32:
-		err = __put_user(pos.mt_blkno, &((struct mtpos32 *)arg)->mt_blkno);
+		upos32 = compat_ptr(arg);
+		err = __put_user(pos.mt_blkno, &upos32->mt_blkno);
 		break;
 	case MTIOCGET32:
-		err = __put_user(get.mt_type, &((struct mtget32 *)arg)->mt_type);
-		err |= __put_user(get.mt_resid, &((struct mtget32 *)arg)->mt_resid);
-		err |= __put_user(get.mt_dsreg, &((struct mtget32 *)arg)->mt_dsreg);
-		err |= __put_user(get.mt_gstat, &((struct mtget32 *)arg)->mt_gstat);
-		err |= __put_user(get.mt_erreg, &((struct mtget32 *)arg)->mt_erreg);
-		err |= __put_user(get.mt_fileno, &((struct mtget32 *)arg)->mt_fileno);
-		err |= __put_user(get.mt_blkno, &((struct mtget32 *)arg)->mt_blkno);
+		umget32 = compat_ptr(arg);
+		err = __put_user(get.mt_type, &umget32->mt_type);
+		err |= __put_user(get.mt_resid, &umget32->mt_resid);
+		err |= __put_user(get.mt_dsreg, &umget32->mt_dsreg);
+		err |= __put_user(get.mt_gstat, &umget32->mt_gstat);
+		err |= __put_user(get.mt_erreg, &umget32->mt_erreg);
+		err |= __put_user(get.mt_fileno, &umget32->mt_fileno);
+		err |= __put_user(get.mt_blkno, &umget32->mt_blkno);
 		break;
 	case MTIOCGETCONFIG32:
-		err = __put_user(info.mt_type, &((struct mtconfiginfo32 *)arg)->mt_type);
-		err |= __put_user(info.ifc_type, &((struct mtconfiginfo32 *)arg)->ifc_type);
-		err |= __put_user(info.irqnr, &((struct mtconfiginfo32 *)arg)->irqnr);
-		err |= __put_user(info.dmanr, &((struct mtconfiginfo32 *)arg)->dmanr);
-		err |= __put_user(info.port, &((struct mtconfiginfo32 *)arg)->port);
-		err |= __put_user(info.debug, &((struct mtconfiginfo32 *)arg)->debug);
-		err |= __copy_to_user((char *)&((struct mtconfiginfo32 *)arg)->debug
-			    		   + sizeof(((struct mtconfiginfo32 *)arg)->debug),
+		uinfo32 = compat_ptr(arg);
+		err = __put_user(info.mt_type, &uinfo32->mt_type);
+		err |= __put_user(info.ifc_type, &uinfo32->ifc_type);
+		err |= __put_user(info.irqnr, &uinfo32->irqnr);
+		err |= __put_user(info.dmanr, &uinfo32->dmanr);
+		err |= __put_user(info.port, &uinfo32->port);
+		err |= __put_user(info.debug, &uinfo32->debug);
+		err |= __copy_to_user((char *)&uinfo32->debug
+			    		   + sizeof(uinfo32->debug),
 					   (char *)&info.debug + sizeof(info.debug), sizeof(__u32));
 		break;
 	case MTIOCSETCONFIG32:
@@ -1402,7 +1421,7 @@ static int cdrom_do_read_audio(unsigned 
 	void *datap;
 
 	cdread_audio = compat_alloc_user_space(sizeof(*cdread_audio));
-	cdread_audio32 = (struct cdrom_read_audio32 *) arg;
+	cdread_audio32 = compat_ptr(arg);
 
 	if (copy_in_user(&cdread_audio->addr,
 			 &cdread_audio32->addr,
@@ -1412,7 +1431,7 @@ static int cdrom_do_read_audio(unsigned 
 
 	if (get_user(data, &cdread_audio32->buf))
 		return -EFAULT;
-	datap = (void *) (unsigned long) data;
+	datap = compat_ptr(data);
 	if (put_user(datap, &cdread_audio->buf))
 		return -EFAULT;
 
@@ -1426,7 +1445,7 @@ static int __cgc_do_ptr(void **ptr64, __
 
 	if (get_user(data, ptr32))
 		return -EFAULT;
-	datap = (void *) (unsigned long) data;
+	datap = compat_ptr(data);
 	if (put_user(datap, ptr64))
 		return -EFAULT;
 
@@ -1440,7 +1459,7 @@ static int cdrom_do_generic_command(unsi
 	unsigned char dir;
 
 	cgc = compat_alloc_user_space(sizeof(*cgc));
-	cgc32 = (struct cdrom_generic_command32 *) arg;
+	cgc32 = compat_ptr(arg);
 
 	if (copy_in_user(&cgc->cmd, &cgc32->cmd, sizeof(cgc->cmd)) ||
 	    __cgc_do_ptr((void **) &cgc->buffer, &cgc32->buffer) ||
@@ -1510,16 +1529,18 @@ static int loop_status(unsigned int fd, 
 {
 	mm_segment_t old_fs = get_fs();
 	struct loop_info l;
+	struct loop_info32 *ul;
 	int err = -EINVAL;
 
+	ul = compat_ptr(arg);
 	switch(cmd) {
 	case LOOP_SET_STATUS:
-		err = get_user(l.lo_number, &((struct loop_info32 *)arg)->lo_number);
-		err |= __get_user(l.lo_device, &((struct loop_info32 *)arg)->lo_device);
-		err |= __get_user(l.lo_inode, &((struct loop_info32 *)arg)->lo_inode);
-		err |= __get_user(l.lo_rdevice, &((struct loop_info32 *)arg)->lo_rdevice);
-		err |= __copy_from_user((char *)&l.lo_offset, (char *)&((struct loop_info32 *)arg)->lo_offset,
-					   8 + (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
+		err = get_user(l.lo_number, &ul->lo_number);
+		err |= __get_user(l.lo_device, &ul->lo_device);
+		err |= __get_user(l.lo_inode, &ul->lo_inode);
+		err |= __get_user(l.lo_rdevice, &ul->lo_rdevice);
+		err |= __copy_from_user(&l.lo_offset, &ul->lo_offset,
+		        8 + (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
 		if (err) {
 			err = -EFAULT;
 		} else {
@@ -1533,12 +1554,12 @@ static int loop_status(unsigned int fd, 
 		err = sys_ioctl (fd, cmd, (unsigned long)&l);
 		set_fs (old_fs);
 		if (!err) {
-			err = put_user(l.lo_number, &((struct loop_info32 *)arg)->lo_number);
-			err |= __put_user(l.lo_device, &((struct loop_info32 *)arg)->lo_device);
-			err |= __put_user(l.lo_inode, &((struct loop_info32 *)arg)->lo_inode);
-			err |= __put_user(l.lo_rdevice, &((struct loop_info32 *)arg)->lo_rdevice);
-			err |= __copy_to_user((char *)&((struct loop_info32 *)arg)->lo_offset,
-					   (char *)&l.lo_offset, (unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
+			err = put_user(l.lo_number, &ul->lo_number);
+			err |= __put_user(l.lo_device, &ul->lo_device);
+			err |= __put_user(l.lo_inode, &ul->lo_inode);
+			err |= __put_user(l.lo_rdevice, &ul->lo_rdevice);
+			err |= __copy_to_user(&ul->lo_offset, &l.lo_offset,
+				(unsigned long)l.lo_init - (unsigned long)&l.lo_offset);
 			if (err)
 				err = -EFAULT;
 		}
@@ -1588,10 +1609,11 @@ struct consolefontdesc32 {
 	compat_caddr_t chardata;	/* font data in expanded form */
 };
 
-static int do_fontx_ioctl(unsigned int fd, int cmd, struct consolefontdesc32 *user_cfd, struct file *file)
+static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
 {
 	struct consolefontdesc cfdarg;
 	struct console_font_op op;
+	struct consolefontdesc32 *user_cfd = compat_ptr(arg);
 	int i, perm;
 
 	perm = vt_check(file);
@@ -1643,9 +1665,10 @@ struct console_font_op32 {
 	compat_caddr_t data;    /* font data with height fixed to 32 */
 };
                                         
-static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, struct console_font_op32 *fontop, struct file *file)
+static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
 {
 	struct console_font_op op;
+	struct console_font_op32 *fontop = compat_ptr(arg);
 	int perm = vt_check(file), i;
 	struct vt_struct *vt;
 	
@@ -1671,9 +1694,10 @@ struct unimapdesc32 {
 	compat_caddr_t entries;
 };
 
-static int do_unimap_ioctl(unsigned int fd, unsigned int cmd, struct unimapdesc32 *user_ud, struct file *file)
+static int do_unimap_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
 {
 	struct unimapdesc32 tmp;
+	struct unimapdesc32 *user_ud = compat_ptr(arg);
 	int perm = vt_check(file);
 	
 	if (perm < 0) return perm;
@@ -1704,7 +1728,7 @@ static int do_smb_getmountuid(unsigned i
 	set_fs(old_fs);
 
 	if (err >= 0)
-		err = put_user(kuid, (compat_uid_t *)arg);
+		err = put_user(kuid, (compat_uid_t *)compat_ptr(arg));
 
 	return err;
 }
@@ -1773,12 +1797,12 @@ static int do_atm_iobuf(unsigned int fd,
 	int len, err;
 
 	iobuf = compat_alloc_user_space(sizeof(*iobuf));
-	iobuf32 = (struct atm_iobuf32 *) arg;
+	iobuf32 = compat_ptr(arg);
 
 	if (get_user(len, &iobuf32->length) ||
 	    get_user(data, &iobuf32->buffer))
 		return -EFAULT;
-	datap = (void *) (unsigned long) data;
+	datap = compat_ptr(data);
 	if (put_user(len, &iobuf->length) ||
 	    put_user(datap, &iobuf->buffer))
 		return -EFAULT;
@@ -1803,12 +1827,12 @@ static int do_atmif_sioc(unsigned int fd
 	int err;
         
 	sioc = compat_alloc_user_space(sizeof(*sioc));
-	sioc32 = (struct atmif_sioc32 *) arg;
+	sioc32 = compat_ptr(arg);
 
 	if (copy_in_user(&sioc->number, &sioc32->number, 2 * sizeof(int)) ||
 	    get_user(data, &sioc32->arg))
 		return -EFAULT;
-	datap = (void *) (unsigned long) data;
+	datap = compat_ptr(data);
 	if (put_user(datap, &sioc->arg))
 		return -EFAULT;
 
@@ -1891,25 +1915,32 @@ struct blkpg_ioctl_arg32 {
 	compat_int_t datalen;
 	compat_caddr_t data;
 };
-                                
-static int blkpg_ioctl_trans(unsigned int fd, unsigned int cmd, struct blkpg_ioctl_arg32 *arg)
+
+static int blkpg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
 	struct blkpg_ioctl_arg a;
+	struct blkpg_ioctl_arg32 *ua32;
 	struct blkpg_partition p;
+	struct blkpg_partition *up32;
+	compat_caddr_t udata;
 	int err;
 	mm_segment_t old_fs = get_fs();
 	
-	err = get_user(a.op, &arg->op);
-	err |= __get_user(a.flags, &arg->flags);
-	err |= __get_user(a.datalen, &arg->datalen);
-	err |= __get_user((long)a.data, &arg->data);
-	if (err) return err;
+	ua32 = compat_ptr(arg);
+	err = get_user(a.op, &ua32->op);
+	err |= __get_user(a.flags, &ua32->flags);
+	err |= __get_user(a.datalen, &ua32->datalen);
+	err |= __get_user(udata, &ua32->data);
+	up32 = compat_ptr(udata);
+	if (err)
+		return err;
+
 	switch (a.op) {
 	case BLKPG_ADD_PARTITION:
 	case BLKPG_DEL_PARTITION:
 		if (a.datalen < sizeof(struct blkpg_partition))
 			return -EINVAL;
-                if (copy_from_user(&p, a.data, sizeof(struct blkpg_partition)))
+                if (copy_from_user(&p, up32, sizeof(struct blkpg_partition)))
 			return -EFAULT;
 		a.data = &p;
 		set_fs (KERNEL_DS);
@@ -1933,18 +1964,18 @@ static int ioc_settimeout(unsigned int f
 
 static int do_blkbszget(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
-       return sys_ioctl(fd, BLKBSZGET, arg);
+       return sys_ioctl(fd, BLKBSZGET, (unsigned long)compat_ptr(arg));
 }
 
 static int do_blkbszset(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
-       return sys_ioctl(fd, BLKBSZSET, arg);
+       return sys_ioctl(fd, BLKBSZSET, (unsigned long)compat_ptr(arg));
 }
 
 static int do_blkgetsize64(unsigned int fd, unsigned int cmd,
                           unsigned long arg)
 {
-       return sys_ioctl(fd, BLKGETSIZE64, arg);
+       return sys_ioctl(fd, BLKGETSIZE64, (unsigned long)compat_ptr(arg));
 }
 
 /* Bluetooth ioctls */
@@ -2081,23 +2112,25 @@ static int fd_ioctl_trans(unsigned int f
 		case FDDEFPRM32:
 		case FDGETPRM32:
 		{
+			struct floppy_struct32 *uf;
 			struct floppy_struct *f;
 
+			uf = compat_ptr(arg);
 			f = karg = kmalloc(sizeof(struct floppy_struct), GFP_KERNEL);
 			if (!karg)
 				return -ENOMEM;
 			if (cmd == FDGETPRM32)
 				break;
-			err = __get_user(f->size, &((struct floppy_struct32 *)arg)->size);
-			err |= __get_user(f->sect, &((struct floppy_struct32 *)arg)->sect);
-			err |= __get_user(f->head, &((struct floppy_struct32 *)arg)->head);
-			err |= __get_user(f->track, &((struct floppy_struct32 *)arg)->track);
-			err |= __get_user(f->stretch, &((struct floppy_struct32 *)arg)->stretch);
-			err |= __get_user(f->gap, &((struct floppy_struct32 *)arg)->gap);
-			err |= __get_user(f->rate, &((struct floppy_struct32 *)arg)->rate);
-			err |= __get_user(f->spec1, &((struct floppy_struct32 *)arg)->spec1);
-			err |= __get_user(f->fmt_gap, &((struct floppy_struct32 *)arg)->fmt_gap);
-			err |= __get_user((u64)f->name, &((struct floppy_struct32 *)arg)->name);
+			err = __get_user(f->size, &uf->size);
+			err |= __get_user(f->sect, &uf->sect);
+			err |= __get_user(f->head, &uf->head);
+			err |= __get_user(f->track, &uf->track);
+			err |= __get_user(f->stretch, &uf->stretch);
+			err |= __get_user(f->gap, &uf->gap);
+			err |= __get_user(f->rate, &uf->rate);
+			err |= __get_user(f->spec1, &uf->spec1);
+			err |= __get_user(f->fmt_gap, &uf->fmt_gap);
+			err |= __get_user((u64)f->name, &uf->name);
 			if (err) {
 				err = -EFAULT;
 				goto out;
@@ -2107,32 +2140,34 @@ static int fd_ioctl_trans(unsigned int f
 		case FDSETDRVPRM32:
 		case FDGETDRVPRM32:
 		{
+			struct floppy_drive_params32 *uf;
 			struct floppy_drive_params *f;
 
+			uf = compat_ptr(arg);
 			f = karg = kmalloc(sizeof(struct floppy_drive_params), GFP_KERNEL);
 			if (!karg)
 				return -ENOMEM;
 			if (cmd == FDGETDRVPRM32)
 				break;
-			err = __get_user(f->cmos, &((struct floppy_drive_params32 *)arg)->cmos);
-			err |= __get_user(f->max_dtr, &((struct floppy_drive_params32 *)arg)->max_dtr);
-			err |= __get_user(f->hlt, &((struct floppy_drive_params32 *)arg)->hlt);
-			err |= __get_user(f->hut, &((struct floppy_drive_params32 *)arg)->hut);
-			err |= __get_user(f->srt, &((struct floppy_drive_params32 *)arg)->srt);
-			err |= __get_user(f->spinup, &((struct floppy_drive_params32 *)arg)->spinup);
-			err |= __get_user(f->spindown, &((struct floppy_drive_params32 *)arg)->spindown);
-			err |= __get_user(f->spindown_offset, &((struct floppy_drive_params32 *)arg)->spindown_offset);
-			err |= __get_user(f->select_delay, &((struct floppy_drive_params32 *)arg)->select_delay);
-			err |= __get_user(f->rps, &((struct floppy_drive_params32 *)arg)->rps);
-			err |= __get_user(f->tracks, &((struct floppy_drive_params32 *)arg)->tracks);
-			err |= __get_user(f->timeout, &((struct floppy_drive_params32 *)arg)->timeout);
-			err |= __get_user(f->interleave_sect, &((struct floppy_drive_params32 *)arg)->interleave_sect);
-			err |= __copy_from_user(&f->max_errors, &((struct floppy_drive_params32 *)arg)->max_errors, sizeof(f->max_errors));
-			err |= __get_user(f->flags, &((struct floppy_drive_params32 *)arg)->flags);
-			err |= __get_user(f->read_track, &((struct floppy_drive_params32 *)arg)->read_track);
-			err |= __copy_from_user(f->autodetect, ((struct floppy_drive_params32 *)arg)->autodetect, sizeof(f->autodetect));
-			err |= __get_user(f->checkfreq, &((struct floppy_drive_params32 *)arg)->checkfreq);
-			err |= __get_user(f->native_format, &((struct floppy_drive_params32 *)arg)->native_format);
+			err = __get_user(f->cmos, &uf->cmos);
+			err |= __get_user(f->max_dtr, &uf->max_dtr);
+			err |= __get_user(f->hlt, &uf->hlt);
+			err |= __get_user(f->hut, &uf->hut);
+			err |= __get_user(f->srt, &uf->srt);
+			err |= __get_user(f->spinup, &uf->spinup);
+			err |= __get_user(f->spindown, &uf->spindown);
+			err |= __get_user(f->spindown_offset, &uf->spindown_offset);
+			err |= __get_user(f->select_delay, &uf->select_delay);
+			err |= __get_user(f->rps, &uf->rps);
+			err |= __get_user(f->tracks, &uf->tracks);
+			err |= __get_user(f->timeout, &uf->timeout);
+			err |= __get_user(f->interleave_sect, &uf->interleave_sect);
+			err |= __copy_from_user(&f->max_errors, &uf->max_errors, sizeof(f->max_errors));
+			err |= __get_user(f->flags, &uf->flags);
+			err |= __get_user(f->read_track, &uf->read_track);
+			err |= __copy_from_user(f->autodetect, uf->autodetect, sizeof(f->autodetect));
+			err |= __get_user(f->checkfreq, &uf->checkfreq);
+			err |= __get_user(f->native_format, &uf->native_format);
 			if (err) {
 				err = -EFAULT;
 				goto out;
@@ -2177,83 +2212,90 @@ static int fd_ioctl_trans(unsigned int f
 			err |= __put_user(f->rate, &((struct floppy_struct32 *)arg)->rate);
 			err |= __put_user(f->spec1, &((struct floppy_struct32 *)arg)->spec1);
 			err |= __put_user(f->fmt_gap, &((struct floppy_struct32 *)arg)->fmt_gap);
-			err |= __put_user((u64)f->name, &((struct floppy_struct32 *)arg)->name);
+			err |= __put_user((u64)f->name, (compat_caddr_t*)&((struct floppy_struct32 *)arg)->name);
 			break;
 		}
 		case FDGETDRVPRM32:
 		{
+			struct floppy_drive_params32 *uf;
 			struct floppy_drive_params *f = karg;
 
-			err = __put_user(f->cmos, &((struct floppy_drive_params32 *)arg)->cmos);
-			err |= __put_user(f->max_dtr, &((struct floppy_drive_params32 *)arg)->max_dtr);
-			err |= __put_user(f->hlt, &((struct floppy_drive_params32 *)arg)->hlt);
-			err |= __put_user(f->hut, &((struct floppy_drive_params32 *)arg)->hut);
-			err |= __put_user(f->srt, &((struct floppy_drive_params32 *)arg)->srt);
-			err |= __put_user(f->spinup, &((struct floppy_drive_params32 *)arg)->spinup);
-			err |= __put_user(f->spindown, &((struct floppy_drive_params32 *)arg)->spindown);
-			err |= __put_user(f->spindown_offset, &((struct floppy_drive_params32 *)arg)->spindown_offset);
-			err |= __put_user(f->select_delay, &((struct floppy_drive_params32 *)arg)->select_delay);
-			err |= __put_user(f->rps, &((struct floppy_drive_params32 *)arg)->rps);
-			err |= __put_user(f->tracks, &((struct floppy_drive_params32 *)arg)->tracks);
-			err |= __put_user(f->timeout, &((struct floppy_drive_params32 *)arg)->timeout);
-			err |= __put_user(f->interleave_sect, &((struct floppy_drive_params32 *)arg)->interleave_sect);
-			err |= __copy_to_user(&((struct floppy_drive_params32 *)arg)->max_errors, &f->max_errors, sizeof(f->max_errors));
-			err |= __put_user(f->flags, &((struct floppy_drive_params32 *)arg)->flags);
-			err |= __put_user(f->read_track, &((struct floppy_drive_params32 *)arg)->read_track);
-			err |= __copy_to_user(((struct floppy_drive_params32 *)arg)->autodetect, f->autodetect, sizeof(f->autodetect));
-			err |= __put_user(f->checkfreq, &((struct floppy_drive_params32 *)arg)->checkfreq);
-			err |= __put_user(f->native_format, &((struct floppy_drive_params32 *)arg)->native_format);
+			uf = compat_ptr(arg);
+			err = __put_user(f->cmos, &uf->cmos);
+			err |= __put_user(f->max_dtr, &uf->max_dtr);
+			err |= __put_user(f->hlt, &uf->hlt);
+			err |= __put_user(f->hut, &uf->hut);
+			err |= __put_user(f->srt, &uf->srt);
+			err |= __put_user(f->spinup, &uf->spinup);
+			err |= __put_user(f->spindown, &uf->spindown);
+			err |= __put_user(f->spindown_offset, &uf->spindown_offset);
+			err |= __put_user(f->select_delay, &uf->select_delay);
+			err |= __put_user(f->rps, &uf->rps);
+			err |= __put_user(f->tracks, &uf->tracks);
+			err |= __put_user(f->timeout, &uf->timeout);
+			err |= __put_user(f->interleave_sect, &uf->interleave_sect);
+			err |= __copy_to_user(&uf->max_errors, &f->max_errors, sizeof(f->max_errors));
+			err |= __put_user(f->flags, &uf->flags);
+			err |= __put_user(f->read_track, &uf->read_track);
+			err |= __copy_to_user(uf->autodetect, f->autodetect, sizeof(f->autodetect));
+			err |= __put_user(f->checkfreq, &uf->checkfreq);
+			err |= __put_user(f->native_format, &uf->native_format);
 			break;
 		}
 		case FDGETDRVSTAT32:
 		case FDPOLLDRVSTAT32:
 		{
+			struct floppy_drive_struct32 *uf;
 			struct floppy_drive_struct *f = karg;
 
-			err = __put_user(f->flags, &((struct floppy_drive_struct32 *)arg)->flags);
-			err |= __put_user(f->spinup_date, &((struct floppy_drive_struct32 *)arg)->spinup_date);
-			err |= __put_user(f->select_date, &((struct floppy_drive_struct32 *)arg)->select_date);
-			err |= __put_user(f->first_read_date, &((struct floppy_drive_struct32 *)arg)->first_read_date);
-			err |= __put_user(f->probed_format, &((struct floppy_drive_struct32 *)arg)->probed_format);
-			err |= __put_user(f->track, &((struct floppy_drive_struct32 *)arg)->track);
-			err |= __put_user(f->maxblock, &((struct floppy_drive_struct32 *)arg)->maxblock);
-			err |= __put_user(f->maxtrack, &((struct floppy_drive_struct32 *)arg)->maxtrack);
-			err |= __put_user(f->generation, &((struct floppy_drive_struct32 *)arg)->generation);
-			err |= __put_user(f->keep_data, &((struct floppy_drive_struct32 *)arg)->keep_data);
-			err |= __put_user(f->fd_ref, &((struct floppy_drive_struct32 *)arg)->fd_ref);
-			err |= __put_user(f->fd_device, &((struct floppy_drive_struct32 *)arg)->fd_device);
-			err |= __put_user(f->last_checked, &((struct floppy_drive_struct32 *)arg)->last_checked);
-			err |= __put_user((u64)f->dmabuf, &((struct floppy_drive_struct32 *)arg)->dmabuf);
-			err |= __put_user((u64)f->bufblocks, &((struct floppy_drive_struct32 *)arg)->bufblocks);
+			uf = compat_ptr(arg);
+			err = __put_user(f->flags, &uf->flags);
+			err |= __put_user(f->spinup_date, &uf->spinup_date);
+			err |= __put_user(f->select_date, &uf->select_date);
+			err |= __put_user(f->first_read_date, &uf->first_read_date);
+			err |= __put_user(f->probed_format, &uf->probed_format);
+			err |= __put_user(f->track, &uf->track);
+			err |= __put_user(f->maxblock, &uf->maxblock);
+			err |= __put_user(f->maxtrack, &uf->maxtrack);
+			err |= __put_user(f->generation, &uf->generation);
+			err |= __put_user(f->keep_data, &uf->keep_data);
+			err |= __put_user(f->fd_ref, &uf->fd_ref);
+			err |= __put_user(f->fd_device, &uf->fd_device);
+			err |= __put_user(f->last_checked, &uf->last_checked);
+			err |= __put_user((u64)f->dmabuf, &uf->dmabuf);
+			err |= __put_user((u64)f->bufblocks, &uf->bufblocks);
 			break;
 		}
 		case FDGETFDCSTAT32:
 		{
+			struct floppy_fdc_state32 *uf;
 			struct floppy_fdc_state *f = karg;
 
-			err = __put_user(f->spec1, &((struct floppy_fdc_state32 *)arg)->spec1);
-			err |= __put_user(f->spec2, &((struct floppy_fdc_state32 *)arg)->spec2);
-			err |= __put_user(f->dtr, &((struct floppy_fdc_state32 *)arg)->dtr);
-			err |= __put_user(f->version, &((struct floppy_fdc_state32 *)arg)->version);
-			err |= __put_user(f->dor, &((struct floppy_fdc_state32 *)arg)->dor);
-			err |= __put_user(f->address, &((struct floppy_fdc_state32 *)arg)->address);
-			err |= __copy_to_user((char *)&((struct floppy_fdc_state32 *)arg)->address
-			    		   + sizeof(((struct floppy_fdc_state32 *)arg)->address),
+			uf = compat_ptr(arg);
+			err = __put_user(f->spec1, &uf->spec1);
+			err |= __put_user(f->spec2, &uf->spec2);
+			err |= __put_user(f->dtr, &uf->dtr);
+			err |= __put_user(f->version, &uf->version);
+			err |= __put_user(f->dor, &uf->dor);
+			err |= __put_user(f->address, &uf->address);
+			err |= __copy_to_user((char *)&uf->address + sizeof(uf->address),
 					   (char *)&f->address + sizeof(f->address), sizeof(int));
-			err |= __put_user(f->driver_version, &((struct floppy_fdc_state32 *)arg)->driver_version);
-			err |= __copy_to_user(((struct floppy_fdc_state32 *)arg)->track, f->track, sizeof(f->track));
+			err |= __put_user(f->driver_version, &uf->driver_version);
+			err |= __copy_to_user(uf->track, f->track, sizeof(f->track));
 			break;
 		}
 		case FDWERRORGET32:
 		{
+			struct floppy_write_errors32 *uf;
 			struct floppy_write_errors *f = karg;
 
-			err = __put_user(f->write_errors, &((struct floppy_write_errors32 *)arg)->write_errors);
-			err |= __put_user(f->first_error_sector, &((struct floppy_write_errors32 *)arg)->first_error_sector);
-			err |= __put_user(f->first_error_generation, &((struct floppy_write_errors32 *)arg)->first_error_generation);
-			err |= __put_user(f->last_error_sector, &((struct floppy_write_errors32 *)arg)->last_error_sector);
-			err |= __put_user(f->last_error_generation, &((struct floppy_write_errors32 *)arg)->last_error_generation);
-			err |= __put_user(f->badness, &((struct floppy_write_errors32 *)arg)->badness);
+			uf = compat_ptr(arg);
+			err = __put_user(f->write_errors, &uf->write_errors);
+			err |= __put_user(f->first_error_sector, &uf->first_error_sector);
+			err |= __put_user(f->first_error_generation, &uf->first_error_generation);
+			err |= __put_user(f->last_error_sector, &uf->last_error_sector);
+			err |= __put_user(f->last_error_generation, &uf->last_error_generation);
+			err |= __put_user(f->badness, &uf->badness);
 			break;
 		}
 		default:
@@ -2278,7 +2320,7 @@ struct mtd_oob_buf32 {
 static int mtd_rw_oob(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
 	struct mtd_oob_buf	*buf = compat_alloc_user_space(sizeof(*buf));
-	struct mtd_oob_buf32	*buf32 = (struct mtd_oob_buf32 *) arg;
+	struct mtd_oob_buf32	*buf32 = compat_ptr(arg);
 	u32 data;
 	char *datap;
 	unsigned int real_cmd;
@@ -2291,7 +2333,7 @@ static int mtd_rw_oob(unsigned int fd, u
 			 2 * sizeof(u32)) ||
 	    get_user(data, &buf32->ptr))
 		return -EFAULT;
-	datap = (void *) (unsigned long) data;
+	datap = compat_ptr(data);
 	if (put_user(datap, &buf->ptr))
 		return -EFAULT;
 
@@ -2325,7 +2367,7 @@ put_dirent32 (struct dirent *d, struct c
         return ret;
 }
 
-static int vfat_ioctl32(unsigned fd, unsigned cmd,  void *ptr)
+static int vfat_ioctl32(unsigned fd, unsigned cmd, unsigned long arg)
 {
 	int ret;
 	mm_segment_t oldfs = get_fs();
@@ -2345,8 +2387,8 @@ static int vfat_ioctl32(unsigned fd, uns
 	ret = sys_ioctl(fd,cmd,(unsigned long)&d);
 	set_fs(oldfs);
 	if (ret >= 0) {
-		ret |= put_dirent32(&d[0], (struct compat_dirent *)ptr);
-		ret |= put_dirent32(&d[1], ((struct compat_dirent *)ptr) + 1);
+		ret |= put_dirent32(&d[0], (struct compat_dirent *)compat_ptr(arg));
+		ret |= put_dirent32(&d[1], ((struct compat_dirent *)compat_ptr(arg)) + 1);
 	}
 	return ret;
 }
@@ -2406,7 +2448,7 @@ static int set_raw32_request(struct raw_
         return ret;
 }
 
-static int raw_ioctl(unsigned fd, unsigned cmd,  void *ptr)
+static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
 {
         int ret;
 
@@ -2414,7 +2456,7 @@ static int raw_ioctl(unsigned fd, unsign
         case RAW_SETBIND:
         case RAW_GETBIND: {
                 struct raw_config_request req;
-                struct raw32_config_request *user_req = ptr;
+                struct raw32_config_request *user_req = compat_ptr(arg);
                 mm_segment_t oldfs = get_fs();
 
                 if ((ret = get_raw32_request(&req, user_req)))
@@ -2430,7 +2472,7 @@ static int raw_ioctl(unsigned fd, unsign
                 break;
         }
         default:
-                ret = sys_ioctl(fd,cmd,(unsigned long)ptr);
+                ret = sys_ioctl(fd, cmd, arg);
                 break;
         }
         return ret;
@@ -2454,14 +2496,15 @@ struct serial_struct32 {
         compat_uint_t   iomem_base;
         unsigned short  iomem_reg_shift;
         unsigned int    port_high;
+     /* compat_ulong_t  iomap_base FIXME */
         compat_int_t    reserved[1];
 };
 
-static int serial_struct_ioctl(unsigned fd, unsigned cmd,  void *ptr)
+static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
 {
         typedef struct serial_struct SS;
         typedef struct serial_struct32 SS32;
-        struct serial_struct32 *ss32 = ptr;
+        struct serial_struct32 *ss32 = compat_ptr(arg);
         int err;
         struct serial_struct ss;
         mm_segment_t oldseg = get_fs();
@@ -2515,7 +2558,7 @@ static int do_usbdevfs_control(unsigned 
         void *uptr, *kptr;
         int err;
 
-        uctrl = (struct usbdevfs_ctrltransfer32 *) arg;
+        uctrl = compat_ptr(arg);
 
         if (copy_from_user(&kctrl, uctrl,
                            (sizeof(struct usbdevfs_ctrltransfer32) -
@@ -2576,7 +2619,7 @@ static int do_usbdevfs_bulk(unsigned int
         void *uptr, *kptr;
         int err;
 
-	ubulk = (struct usbdevfs_bulktransfer32 *) arg;
+	ubulk = compat_ptr(arg);
 
         if (get_user(kbulk.ep, &ubulk->ep) ||
             get_user(kbulk.len, &ubulk->len) ||
@@ -2771,7 +2814,7 @@ static int do_usbdevfs_urb(unsigned int 
 	unsigned int buflen;
 	int err;
 
-	uurb = (struct usbdevfs_urb32 *) arg;
+	uurb = compat_ptr(arg);
 
 	err = -ENOMEM;
 	kurb = kmalloc(sizeof(struct usbdevfs_urb) +
@@ -2836,7 +2879,7 @@ static int do_usbdevfs_reapurb(unsigned 
         set_fs(old_fs);
 
         if (err >= 0 &&
-            put_user((u32)(u64)kptr, (u32 *)arg))
+            put_user((u32)(u64)kptr, (u32 *)compat_ptr(arg)))
                 err = -EFAULT;
 
         return err;
@@ -2857,13 +2900,13 @@ static int do_usbdevfs_discsignal(unsign
         u32 uctx;
         int err;
 
-        udis = (struct usbdevfs_disconnectsignal32 *) arg;
+        udis = compat_ptr(arg);
 
         if (get_user(kdis.signr, &udis->signr) ||
             __get_user(uctx, &udis->context))
                 return -EFAULT;
 
-        kdis.context = (void *) (long)uctx;
+        kdis.context = compat_ptr(uctx);
 
         old_fs = get_fs();
         set_fs(KERNEL_DS);
@@ -2970,6 +3013,48 @@ static int do_i2c_smbus_ioctl(unsigned i
 	return sys_ioctl(fd, cmd, (unsigned long)tdata);
 }
 
+struct compat_iw_point {
+	compat_caddr_t pointer;
+	__u16 length;
+	__u16 flags;
+};
+
+static int do_wireless_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
+{
+	struct iwreq *iwr, *iwr_u;
+	struct iw_point *iwp;
+	struct compat_iw_point *iwp_u;
+	compat_caddr_t pointer;
+	__u16 length, flags;
+
+	iwr_u = (struct iwreq *) compat_ptr(arg);
+	iwp_u = (struct compat_iw_point *) &iwr_u->u.data;
+	iwr = compat_alloc_user_space(sizeof(*iwr));
+	if (iwr == NULL)
+		return -ENOMEM;
+
+	iwp = &iwr->u.data;
+
+	if (verify_area(VERIFY_WRITE, iwr, sizeof(*iwr)))
+		return -EFAULT;
+
+	if (__copy_in_user(&iwr->ifr_ifrn.ifrn_name[0],
+			   &iwr_u->ifr_ifrn.ifrn_name[0],
+			   sizeof(iwr->ifr_ifrn.ifrn_name)))
+		return -EFAULT;
+
+	if (__get_user(pointer, &iwp_u->pointer) ||
+	    __get_user(length, &iwp_u->length) ||
+	    __get_user(flags, &iwp_u->flags))
+		return -EFAULT;
+
+	if (__put_user(compat_ptr(pointer), &iwp->pointer) ||
+	    __put_user(length, &iwp->length) ||
+	    __put_user(flags, &iwp->flags))
+		return -EFAULT;
+
+	return sys_ioctl(fd, cmd, (unsigned long) iwr);
+}
 
 #undef CODE
 #endif
@@ -3133,6 +3218,20 @@ HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_u
 HANDLE_IOCTL(I2C_FUNCS, w_long)
 HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl)
 HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl)
+/* wireless */
+HANDLE_IOCTL(SIOCGIWRANGE, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCSIWSPY, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCGIWSPY, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCSIWTHRSPY, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCGIWTHRSPY, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCGIWAPLIST, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCGIWSCAN, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCSIWESSID, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCGIWESSID, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCSIWNICKN, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCGIWNICKN, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCSIWENCODE, do_wireless_ioctl)
+HANDLE_IOCTL(SIOCGIWENCODE, do_wireless_ioctl)
 
 #undef DECLARES
 #endif
diff -puN fs/cramfs/inode.c~linus fs/cramfs/inode.c
--- 25/fs/cramfs/inode.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/cramfs/inode.c	2004-01-19 22:17:23.000000000 -0800
@@ -112,8 +112,8 @@ static int next_buffer;
  */
 static void *cramfs_read(struct super_block *sb, unsigned int offset, unsigned int len)
 {
-	struct buffer_head * bh_array[BLKS_PER_BUF];
-	struct buffer_head * read_array[BLKS_PER_BUF];
+	struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping;
+	struct page *pages[BLKS_PER_BUF];
 	unsigned i, blocknr, buffer, unread;
 	unsigned long devsize;
 	char *data;
@@ -138,33 +138,36 @@ static void *cramfs_read(struct super_bl
 		return read_buffers[i] + blk_offset;
 	}
 
-	devsize = sb->s_bdev->bd_inode->i_size >> 12;
-	if (!devsize)
-		devsize = ~0UL;
+	devsize = mapping->host->i_size >> PAGE_CACHE_SHIFT;
 
 	/* Ok, read in BLKS_PER_BUF pages completely first. */
 	unread = 0;
 	for (i = 0; i < BLKS_PER_BUF; i++) {
-		struct buffer_head *bh;
+		struct page *page = NULL;
 
-		bh = NULL;
 		if (blocknr + i < devsize) {
-			bh = sb_getblk(sb, blocknr + i);
-			if (!buffer_uptodate(bh))
-				read_array[unread++] = bh;
+			page = read_cache_page(mapping, blocknr + i,
+				(filler_t *)mapping->a_ops->readpage,
+				NULL);
+			/* synchronous error? */
+			if (IS_ERR(page))
+				page = NULL;
 		}
-		bh_array[i] = bh;
+		pages[i] = page;
 	}
 
-	if (unread) {
-		ll_rw_block(READ, unread, read_array);
-		do {
-			unread--;
-			wait_on_buffer(read_array[unread]);
-		} while (unread);
+	for (i = 0; i < BLKS_PER_BUF; i++) {
+		struct page *page = pages[i];
+		if (page) {
+			wait_on_page_locked(page);
+			if (!PageUptodate(page)) {
+				/* asynchronous error */
+				page_cache_release(page);
+				pages[i] = NULL;
+			}
+		}
 	}
 
-	/* Ok, copy them to the staging area without sleeping. */
 	buffer = next_buffer;
 	next_buffer = NEXT_BUFFER(buffer);
 	buffer_blocknr[buffer] = blocknr;
@@ -172,10 +175,11 @@ static void *cramfs_read(struct super_bl
 
 	data = read_buffers[buffer];
 	for (i = 0; i < BLKS_PER_BUF; i++) {
-		struct buffer_head * bh = bh_array[i];
-		if (bh) {
-			memcpy(data, bh->b_data, PAGE_CACHE_SIZE);
-			brelse(bh);
+		struct page *page = pages[i];
+		if (page) {
+			memcpy(data, kmap(page), PAGE_CACHE_SIZE);
+			kunmap(page);
+			page_cache_release(page);
 		} else
 			memset(data, 0, PAGE_CACHE_SIZE);
 		data += PAGE_CACHE_SIZE;
@@ -202,8 +206,6 @@ static int cramfs_fill_super(struct supe
 	sb->s_fs_info = sbi;
 	memset(sbi, 0, sizeof(struct cramfs_sb_info));
 
-	sb_set_blocksize(sb, PAGE_CACHE_SIZE);
-
 	/* Invalidate the read buffers on mount: think disk change.. */
 	down(&read_mutex);
 	for (i = 0; i < READ_BUFFERS; i++)
diff -puN fs/devfs/base.c~linus fs/devfs/base.c
--- 25/fs/devfs/base.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/devfs/base.c	2004-01-19 22:17:23.000000000 -0800
@@ -1955,15 +1955,9 @@ static int devfs_notify_change (struct d
     return 0;
 }   /*  End Function devfs_notify_change  */
 
-static void devfs_clear_inode (struct inode *inode)
-{
-    if ( S_ISBLK (inode->i_mode) ) bdput (inode->i_bdev);
-}   /*  End Function devfs_clear_inode  */
-
 static struct super_operations devfs_sops =
 { 
     .drop_inode    = generic_delete_inode,
-    .clear_inode   = devfs_clear_inode,
     .statfs        = simple_statfs,
 };
 
@@ -2015,11 +2009,7 @@ static struct inode *_devfs_get_vfs_inod
 	inode->i_rdev = de->u.cdev.dev;
     }
     else if ( S_ISBLK (de->mode) )
-    {
-	inode->i_rdev = de->u.bdev.dev;
-	if (bd_acquire (inode) != 0)
-		PRINTK ("(%d): no block device from bdget()\n",(int)inode->i_ino);
-    }
+	init_special_inode(inode, de->mode, de->u.bdev.dev);
     else if ( S_ISFIFO (de->mode) )
     	inode->i_fop = &def_fifo_fops;
     else if ( S_ISDIR (de->mode) )
@@ -2118,11 +2108,7 @@ static int devfs_open (struct inode *ino
     if (de == NULL) return -ENODEV;
     if ( S_ISDIR (de->mode) ) return 0;
     file->private_data = de->info;
-    if ( S_ISBLK (inode->i_mode) )
-    {
-	file->f_op = &def_blk_fops;
-	err = def_blk_fops.open (inode, file); /* Module refcount unchanged */
-    } else if (S_ISCHR(inode->i_mode)) {
+    if (S_ISCHR(inode->i_mode)) {
 	ops = devfs_get_ops (de);  /*  Now have module refcount  */
 	file->f_op = ops;
 	if (file->f_op)
diff -puN fs/dnotify.c~linus fs/dnotify.c
--- 25/fs/dnotify.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/dnotify.c	2004-01-19 22:17:23.000000000 -0800
@@ -165,6 +165,7 @@ void dnotify_parent(struct dentry *dentr
 		spin_unlock(&dentry->d_lock);
 	}
 }
+EXPORT_SYMBOL_GPL(dnotify_parent);
 
 static int __init dnotify_init(void)
 {
diff -puN fs/eventpoll.c~linus fs/eventpoll.c
--- 25/fs/eventpoll.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/eventpoll.c	2004-01-19 22:17:23.000000000 -0800
@@ -740,6 +740,7 @@ static int ep_getfd(int *efd, struct ino
 	d_add(dentry, inode);
 	file->f_vfsmnt = mntget(eventpoll_mnt);
 	file->f_dentry = dget(dentry);
+	file->f_mapping = inode->i_mapping;
 
 	file->f_pos = 0;
 	file->f_flags = O_RDONLY;
diff -puN fs/exec.c~linus fs/exec.c
--- 25/fs/exec.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/exec.c	2004-01-19 22:17:23.000000000 -0800
@@ -121,7 +121,7 @@ asmlinkage long sys_uselib(const char __
 	struct nameidata nd;
 	int error;
 
-	nd.intent.open.flags = O_RDONLY;
+	nd.intent.open.flags = FMODE_READ;
 	error = __user_walk(library, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
 	if (error)
 		goto out;
@@ -471,8 +471,12 @@ static inline void free_arg_pages(struct
 struct file *open_exec(const char *name)
 {
 	struct nameidata nd;
-	int err = path_lookup(name, LOOKUP_FOLLOW, &nd);
-	struct file *file = ERR_PTR(err);
+	int err;
+	struct file *file;
+
+	nd.intent.open.flags = FMODE_READ;
+	err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
+	file = ERR_PTR(err);
 
 	if (!err) {
 		struct inode *inode = nd.dentry->d_inode;
diff -puN fs/ext2/balloc.c~linus fs/ext2/balloc.c
--- 25/fs/ext2/balloc.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/ext2/balloc.c	2004-01-19 22:17:23.000000000 -0800
@@ -527,7 +527,8 @@ unsigned long ext2_count_free_blocks (st
 	int i;
 #ifdef EXT2FS_DEBUG
 	unsigned long bitmap_count, x;
-	
+	struct ext2_super_block *es;
+
 	lock_super (sb);
 	es = EXT2_SB(sb)->s_es;
 	desc_count = 0;
@@ -550,7 +551,8 @@ unsigned long ext2_count_free_blocks (st
 		brelse(bitmap_bh);
 	}
 	printk("ext2_count_free_blocks: stored = %lu, computed = %lu, %lu\n",
-	       le32_to_cpu(es->s_free_blocks_count), desc_count, bitmap_count);
+		(long)le32_to_cpu(es->s_free_blocks_count),
+		desc_count, bitmap_count);
 	unlock_super (sb);
 	return bitmap_count;
 #else
diff -puN fs/ext2/ialloc.c~linus fs/ext2/ialloc.c
--- 25/fs/ext2/ialloc.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/ext2/ialloc.c	2004-01-19 22:17:23.000000000 -0800
@@ -507,7 +507,7 @@ repeat_in_this_group:
 				group = 0;
 			continue;
 		}
-		if (ext2_set_bit_atomic(sb_bgl_lock(EXT2_SB(sb), group),
+		if (ext2_set_bit_atomic(sb_bgl_lock(sbi, group),
 						ino, bitmap_bh->b_data)) {
 			/* we lost this inode */
 			if (++ino >= EXT2_INODES_PER_GROUP(sb)) {
@@ -543,23 +543,23 @@ got:
 		goto fail;
 	}
 
-	percpu_counter_mod(&EXT2_SB(sb)->s_freeinodes_counter, -1);
+	percpu_counter_mod(&sbi->s_freeinodes_counter, -1);
 	if (S_ISDIR(mode))
-		percpu_counter_inc(&EXT2_SB(sb)->s_dirs_counter);
+		percpu_counter_inc(&sbi->s_dirs_counter);
 
-	spin_lock(sb_bgl_lock(EXT2_SB(sb), group));
+	spin_lock(sb_bgl_lock(sbi, group));
 	gdp->bg_free_inodes_count =
                 cpu_to_le16(le16_to_cpu(gdp->bg_free_inodes_count) - 1);
 	if (S_ISDIR(mode)) {
-		if (EXT2_SB(sb)->s_debts[group] < 255)
-			EXT2_SB(sb)->s_debts[group]++;
+		if (sbi->s_debts[group] < 255)
+			sbi->s_debts[group]++;
 		gdp->bg_used_dirs_count =
 			cpu_to_le16(le16_to_cpu(gdp->bg_used_dirs_count) + 1);
 	} else {
-		if (EXT2_SB(sb)->s_debts[group])
-			EXT2_SB(sb)->s_debts[group]--;
+		if (sbi->s_debts[group])
+			sbi->s_debts[group]--;
 	}
-	spin_unlock(sb_bgl_lock(EXT2_SB(sb), group));
+	spin_unlock(sb_bgl_lock(sbi, group));
 
 	sb->s_dirt = 1;
 	mark_buffer_dirty(bh2);
@@ -599,7 +599,9 @@ got:
 	ei->i_dir_start_lookup = 0;
 	ei->i_state = EXT2_STATE_NEW;
 	ext2_set_inode_flags(inode);
-	inode->i_generation = EXT2_SB(sb)->s_next_generation++;
+	spin_lock(&sbi->s_next_gen_lock);
+	inode->i_generation = sbi->s_next_generation++;
+	spin_unlock(&sbi->s_next_gen_lock);
 	insert_inode_hash(inode);
 
 	if (DQUOT_ALLOC_INODE(inode)) {
@@ -636,10 +638,9 @@ unsigned long ext2_count_free_inodes (st
 	int i;	
 
 #ifdef EXT2FS_DEBUG
-	struct ext2_super_block * es;
+	struct ext2_super_block *es;
 	unsigned long bitmap_count = 0;
 	struct buffer_head *bitmap_bh = NULL;
-	int i;
 
 	lock_super (sb);
 	es = EXT2_SB(sb)->s_es;
@@ -656,7 +657,7 @@ unsigned long ext2_count_free_inodes (st
 			continue;
 
 		x = ext2_count_free(bitmap_bh, EXT2_INODES_PER_GROUP(sb) / 8);
-		printk ("group %d: stored = %d, counted = %lu\n",
+		printk("group %d: stored = %d, counted = %u\n",
 			i, le16_to_cpu(desc->bg_free_inodes_count), x);
 		bitmap_count += x;
 	}
diff -puN fs/ext2/inode.c~linus fs/ext2/inode.c
--- 25/fs/ext2/inode.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/ext2/inode.c	2004-01-19 22:17:23.000000000 -0800
@@ -659,7 +659,7 @@ ext2_direct_IO(int rw, struct kiocb *ioc
 			loff_t offset, unsigned long nr_segs)
 {
 	struct file *file = iocb->ki_filp;
-	struct inode *inode = file->f_dentry->d_inode->i_mapping->host;
+	struct inode *inode = file->f_mapping->host;
 
 	return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
 				offset, nr_segs, ext2_get_blocks, NULL);
diff -puN fs/ext2/super.c~linus fs/ext2/super.c
--- 25/fs/ext2/super.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/ext2/super.c	2004-01-19 22:17:23.000000000 -0800
@@ -809,6 +809,7 @@ static int ext2_fill_super(struct super_
 	}
 	sbi->s_gdb_count = db_count;
 	get_random_bytes(&sbi->s_next_generation, sizeof(u32));
+	spin_lock_init(&sbi->s_next_gen_lock);
 	/*
 	 * set up enough so that it can read an inode
 	 */
diff -puN fs/ext3/ialloc.c~linus fs/ext3/ialloc.c
--- 25/fs/ext3/ialloc.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/ext3/ialloc.c	2004-01-19 22:17:23.000000000 -0800
@@ -446,8 +446,8 @@ struct inode *ext3_new_inode(handle_t *h
 		return ERR_PTR(-ENOMEM);
 	ei = EXT3_I(inode);
 
-	es = EXT3_SB(sb)->s_es;
 	sbi = EXT3_SB(sb);
+	es = sbi->s_es;
 	if (S_ISDIR(mode)) {
 		if (test_opt (sb, OLDALLOC))
 			group = find_group_dir(sb, dir);
@@ -591,7 +591,9 @@ got:
 	if (IS_DIRSYNC(inode))
 		handle->h_sync = 1;
 	insert_inode_hash(inode);
-	inode->i_generation = EXT3_SB(sb)->s_next_generation++;
+	spin_lock(&sbi->s_next_gen_lock);
+	inode->i_generation = sbi->s_next_generation++;
+	spin_unlock(&sbi->s_next_gen_lock);
 
 	ei->i_state = EXT3_STATE_NEW;
 
diff -puN fs/ext3/inode.c~linus fs/ext3/inode.c
--- 25/fs/ext3/inode.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/ext3/inode.c	2004-01-19 22:17:23.000000000 -0800
@@ -1532,7 +1532,7 @@ static int ext3_direct_IO(int rw, struct
 			unsigned long nr_segs)
 {
 	struct file *file = iocb->ki_filp;
-	struct inode *inode = file->f_dentry->d_inode->i_mapping->host;
+	struct inode *inode = file->f_mapping->host;
 	struct ext3_inode_info *ei = EXT3_I(inode);
 	handle_t *handle = NULL;
 	int ret;
diff -puN fs/ext3/super.c~linus fs/ext3/super.c
--- 25/fs/ext3/super.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/ext3/super.c	2004-01-19 22:17:23.000000000 -0800
@@ -31,6 +31,7 @@
 #include <linux/smp_lock.h>
 #include <linux/buffer_head.h>
 #include <linux/vfs.h>
+#include <linux/random.h>
 #include <asm/uaccess.h>
 #include "xattr.h"
 #include "acl.h"
@@ -1287,6 +1288,8 @@ static int ext3_fill_super (struct super
 		goto failed_mount2;
 	}
 	sbi->s_gdb_count = db_count;
+	get_random_bytes(&sbi->s_next_generation, sizeof(u32));
+	spin_lock_init(&sbi->s_next_gen_lock);
 	/*
 	 * set up enough so that it can read an inode
 	 */
diff -puN fs/fcntl.c~linus fs/fcntl.c
--- 25/fs/fcntl.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/fcntl.c	2004-01-19 22:17:23.000000000 -0800
@@ -229,8 +229,8 @@ static int setfl(int fd, struct file * f
 		   arg |= O_NONBLOCK;
 
 	if (arg & O_DIRECT) {
-		if (!inode->i_mapping || !inode->i_mapping->a_ops ||
-			!inode->i_mapping->a_ops->direct_IO)
+		if (!filp->f_mapping || !filp->f_mapping->a_ops ||
+			!filp->f_mapping->a_ops->direct_IO)
 				return -EINVAL;
 	}
 
@@ -609,9 +609,15 @@ EXPORT_SYMBOL(__kill_fasync);
 
 void kill_fasync(struct fasync_struct **fp, int sig, int band)
 {
-	read_lock(&fasync_lock);
-	__kill_fasync(*fp, sig, band);
-	read_unlock(&fasync_lock);
+	/* First a quick test without locking: usually
+	 * the list is empty.
+	 */
+	if (*fp) {
+		read_lock(&fasync_lock);
+		/* reread *fp after obtaining the lock */
+		__kill_fasync(*fp, sig, band);
+		read_unlock(&fasync_lock);
+	}
 }
 
 EXPORT_SYMBOL(kill_fasync);
diff -puN fs/file_table.c~linus fs/file_table.c
--- 25/fs/file_table.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/file_table.c	2004-01-19 22:17:23.000000000 -0800
@@ -120,6 +120,7 @@ int open_private_file(struct file *filp,
 	filp->f_mode   = (flags+1) & O_ACCMODE;
 	atomic_set(&filp->f_count, 1);
 	filp->f_dentry = dentry;
+	filp->f_mapping = dentry->d_inode->i_mapping;
 	filp->f_uid    = current->fsuid;
 	filp->f_gid    = current->fsgid;
 	filp->f_op     = dentry->d_inode->i_fop;
diff -puN fs/freevxfs/vxfs_super.c~linus fs/freevxfs/vxfs_super.c
--- 25/fs/freevxfs/vxfs_super.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/freevxfs/vxfs_super.c	2004-01-19 22:17:23.000000000 -0800
@@ -53,6 +53,8 @@ MODULE_AUTHOR("Christoph Hellwig");
 MODULE_DESCRIPTION("Veritas Filesystem (VxFS) driver");
 MODULE_LICENSE("Dual BSD/GPL");
 
+MODULE_ALIAS("vxfs"); /* makes mount -t vxfs autoload the module */
+
 
 static void		vxfs_put_super(struct super_block *);
 static int		vxfs_statfs(struct super_block *, struct kstatfs *);
diff -puN fs/fs-writeback.c~linus fs/fs-writeback.c
--- 25/fs/fs-writeback.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/fs-writeback.c	2004-01-19 22:17:23.000000000 -0800
@@ -514,7 +514,7 @@ EXPORT_SYMBOL(write_inode_now);
  *    OSYNC_INODE:    the inode itself
  */
 
-int generic_osync_inode(struct inode *inode, int what)
+int generic_osync_inode(struct inode *inode, struct address_space *mapping, int what)
 {
 	int err = 0;
 	int need_write_inode_now = 0;
@@ -522,14 +522,14 @@ int generic_osync_inode(struct inode *in
 
 	current->flags |= PF_SYNCWRITE;
 	if (what & OSYNC_DATA)
-		err = filemap_fdatawrite(inode->i_mapping);
+		err = filemap_fdatawrite(mapping);
 	if (what & (OSYNC_METADATA|OSYNC_DATA)) {
-		err2 = sync_mapping_buffers(inode->i_mapping);
+		err2 = sync_mapping_buffers(mapping);
 		if (!err)
 			err = err2;
 	}
 	if (what & OSYNC_DATA) {
-		err2 = filemap_fdatawait(inode->i_mapping);
+		err2 = filemap_fdatawait(mapping);
 		if (!err)
 			err = err2;
 	}
diff -puN fs/hugetlbfs/inode.c~linus fs/hugetlbfs/inode.c
--- 25/fs/hugetlbfs/inode.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/hugetlbfs/inode.c	2004-01-19 22:17:23.000000000 -0800
@@ -788,6 +788,7 @@ struct file *hugetlb_zero_setup(size_t s
 	inode->i_nlink = 0;
 	file->f_vfsmnt = mntget(hugetlbfs_vfsmount);
 	file->f_dentry = dentry;
+	file->f_mapping = inode->i_mapping;
 	file->f_op = &hugetlbfs_file_operations;
 	file->f_mode = FMODE_WRITE | FMODE_READ;
 	return file;
diff -puN fs/intermezzo/file.c~linus fs/intermezzo/file.c
--- 25/fs/intermezzo/file.c~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/intermezzo/file.c	2004-01-19 22:17:23.000000000 -0800
@@ -336,7 +336,7 @@ static void presto_apply_write_policy(st
                                 unlock_kernel();
                                 return; 
                         }
-                        error = presto_journal_close(&rec, fset, file,
+                        error = presto_journal_close(&rec, fset, fdata,
                                                      file->f_dentry,
                                                      &fdata->fd_version,
                                                      &new_file_ver);
diff -puN fs/intermezzo/intermezzo_fs.h~linus fs/intermezzo/intermezzo_fs.h
--- 25/fs/intermezzo/intermezzo_fs.h~linus	2004-01-19 22:17:06.000000000 -0800
+++ 25-akpm/fs/intermezzo/intermezzo_fs.h	2004-01-19 22:17:23.000000000 -0800
@@ -603,7 +603,7 @@ int presto_journal_rename(struct rec_inf
 int presto_journal_open(struct rec_info *, struct presto_file_set *,
                         struct dentry *, struct presto_version *old_ver);
 int presto_journal_close(struct rec_info *rec, struct presto_file_set *,
-                         struct file *, struct dentry *,
+                         struct presto_file_data *, struct dentry *,
                          struct presto_version *old_file_ver,
                          struct presto_version *new_file_ver);
 int presto_write_lml_close(struct rec_info *rec,
diff -puN fs/intermezzo/journal.c~linus fs/intermezzo/journal.c
--- 25/fs/intermezzo/journal.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/intermezzo/journal.c	2004-01-19 22:17:23.000000000 -0800
@@ -2103,12 +2103,11 @@ int presto_journal_unlink(struct rec_inf
 
 int
 presto_journal_close(struct rec_info *rec, struct presto_file_set *fset,
-                     struct file *file, struct dentry *dentry,
+                     struct presto_file_data *fd, struct dentry *dentry,
                      struct presto_version *old_file_ver,
                      struct presto_version *new_file_ver)
 {
         int opcode = KML_OPCODE_CLOSE;
-        struct presto_file_data *fd;
         char *buffer, *path, *logrecord, record[316];
         struct dentry *root;
         int error, size, i;
@@ -2137,7 +2136,6 @@ presto_journal_close(struct rec_info *re
 
         root = fset->fset_dentry;
 
-        fd = (struct presto_file_data *)file->private_data;
         if (fd) {
                 open_ngroups = fd->fd_ngroups;
                 for (i = 0; i < fd->fd_ngroups; i++)
diff -puN fs/intermezzo/presto.c~linus fs/intermezzo/presto.c
--- 25/fs/intermezzo/presto.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/intermezzo/presto.c	2004-01-19 22:17:23.000000000 -0800
@@ -259,11 +259,8 @@ int lento_cancel_lml(char *path, 
 
 
         if (info->flags & LENTO_FL_WRITE_KML) {
-                struct file file;
-                file.private_data = NULL;
-                file.f_dentry = dentry; 
                 presto_getversion(&new_ver, dentry->d_inode);
-                error = presto_journal_close(&rec, fset, &file, dentry, 
+                error = presto_journal_close(&rec, fset, NULL, dentry,
                                              &new_ver);
                 if ( error ) {
                         EXIT; 
diff -puN fs/intermezzo/vfs.c~linus fs/intermezzo/vfs.c
--- 25/fs/intermezzo/vfs.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/intermezzo/vfs.c	2004-01-19 22:17:23.000000000 -0800
@@ -321,7 +321,7 @@ int presto_do_close(struct presto_file_s
         }
 
         if (fdata->fd_info.flags & LENTO_FL_KML) 
-                rc = presto_journal_close(&rec, fset, file, file->f_dentry,
+                rc = presto_journal_close(&rec, fset, fdata, file->f_dentry,
                                           &fdata->fd_version, 
                                           &fdata->fd_info.remote_version);
         if (rc) { 
@@ -431,14 +431,11 @@ int presto_do_setattr(struct presto_file
 
         if ( presto_do_kml(info, dentry) ) {
                 if ((iattr->ia_valid & ATTR_SIZE) && (old_size != inode->i_size)) {
-                        struct file file;
                         /* Journal a close whenever we see a potential truncate
                         * At the receiving end, lento should explicitly remove
                         * ATTR_SIZE from the list of valid attributes */
                         presto_getversion(&new_ver, inode);
-                        file.private_data = NULL;
-                        file.f_dentry = dentry;
-                        error = presto_journal_close(&rec, fset, &file, dentry,
+                        error = presto_journal_close(&rec, fset, NULL, dentry,
                                                      &old_ver, &new_ver);
                 }
 
@@ -2086,7 +2083,9 @@ static struct file *presto_filp_dopen(st
                 }
         }
 
+	/* XXX: where the fuck is ->f_vfsmnt? */
         f->f_dentry = dentry;
+        f->f_mapping = dentry->d_inode->i_mapping;
         f->f_pos = 0;
         //f->f_reada = 0;
         f->f_op = NULL;
diff -puN fs/ioctl.c~linus fs/ioctl.c
--- 25/fs/ioctl.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/ioctl.c	2004-01-19 22:17:23.000000000 -0800
@@ -22,7 +22,7 @@ static int file_ioctl(struct file *filp,
 	switch (cmd) {
 		case FIBMAP:
 		{
-			struct address_space *mapping = inode->i_mapping;
+			struct address_space *mapping = filp->f_mapping;
 			int res;
 			/* do we support this mess? */
 			if (!mapping->a_ops->bmap)
diff -puN fs/jbd/transaction.c~linus fs/jbd/transaction.c
--- 25/fs/jbd/transaction.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/jbd/transaction.c	2004-01-19 22:17:23.000000000 -0800
@@ -85,7 +85,7 @@ static int start_this_handle(journal_t *
 	int needed;
 	int nblocks = handle->h_buffer_credits;
 	transaction_t *new_transaction = NULL;
-	int ret;
+	int ret = 0;
 
 	if (nblocks > journal->j_max_transaction_buffers) {
 		printk(KERN_ERR "JBD: %s wants too many credits (%d > %d)\n",
@@ -231,7 +231,7 @@ repeat_locked:
 out:
 	if (new_transaction)
 		kfree(new_transaction);
-	return 0;
+	return ret;
 }
 
 /* Allocate a new handle.  This should probably be in a slab... */
diff -puN fs/jffs/intrep.c~linus fs/jffs/intrep.c
--- 25/fs/jffs/intrep.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/jffs/intrep.c	2004-01-19 22:17:23.000000000 -0800
@@ -3337,18 +3337,16 @@ jffs_garbage_collect_thread(void *ptr)
 	int result = 0;
 	D1(int i = 1);
 
+	daemonize("jffs_gcd");
+
 	c->gc_task = current;
 
 	lock_kernel();
-	exit_mm(c->gc_task);
-
-	set_special_pids(1, 1);
 	init_completion(&c->gc_thread_comp); /* barrier */ 
 	spin_lock_irq(&current->sighand->siglock);
 	siginitsetinv (&current->blocked, sigmask(SIGHUP) | sigmask(SIGKILL) | sigmask(SIGSTOP) | sigmask(SIGCONT));
 	recalc_sigpending();
 	spin_unlock_irq(&current->sighand->siglock);
-	strcpy(current->comm, "jffs_gcd");
 
 	D1(printk (KERN_NOTICE "jffs_garbage_collect_thread(): Starting infinite loop.\n"));
 
diff -puN fs/jfs/inode.c~linus fs/jfs/inode.c
--- 25/fs/jfs/inode.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/jfs/inode.c	2004-01-19 22:17:23.000000000 -0800
@@ -306,7 +306,7 @@ static int jfs_direct_IO(int rw, struct 
 			loff_t offset, unsigned long nr_segs)
 {
 	struct file *file = iocb->ki_filp;
-	struct inode *inode = file->f_dentry->d_inode->i_mapping->host;
+	struct inode *inode = file->f_mapping->host;
 
 	return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
 				offset, nr_segs, jfs_get_blocks, NULL);
diff -puN fs/jfs/super.c~linus fs/jfs/super.c
--- 25/fs/jfs/super.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/jfs/super.c	2004-01-19 22:17:23.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- *   Copyright (C) International Business Machines Corp., 2000-2003
+ *   Copyright (C) International Business Machines Corp., 2000-2004
  *   Portions Copyright (C) Christoph Hellwig, 2001-2002
  *
  *   This program is free software;  you can redistribute it and/or modify
@@ -203,7 +203,7 @@ static void jfs_put_super(struct super_b
 
 enum {
 	Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
-	Opt_errors, Opt_ignore, Opt_err,
+	Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err,
 };
 
 static match_table_t tokens = {
@@ -211,6 +211,7 @@ static match_table_t tokens = {
 	{Opt_nointegrity, "nointegrity"},
 	{Opt_iocharset, "iocharset=%s"},
 	{Opt_resize, "resize=%u"},
+	{Opt_resize_nosize, "resize"},
 	{Opt_errors, "errors=%s"},
 	{Opt_ignore, "noquota"},
 	{Opt_ignore, "quota"},
@@ -261,14 +262,16 @@ static int parse_options(char *options, 
 		case Opt_resize:
 		{
 			char *resize = args[0].from;
-			if (!resize || !*resize) {
-				*newLVSize = sb->s_bdev->bd_inode->i_size >>
-					sb->s_blocksize_bits;
-				if (*newLVSize == 0)
-					printk(KERN_ERR
-					"JFS: Cannot determine volume size\n");
-			} else
-				*newLVSize = simple_strtoull(resize, &resize, 0);
+			*newLVSize = simple_strtoull(resize, &resize, 0);
+			break;
+		}
+		case Opt_resize_nosize:
+		{
+			*newLVSize = sb->s_bdev->bd_inode->i_size >>
+				sb->s_blocksize_bits;
+			if (*newLVSize == 0)
+				printk(KERN_ERR
+				       "JFS: Cannot determine volume size\n");
 			break;
 		}
 		case Opt_errors:
diff -puN fs/jfs/xattr.c~linus fs/jfs/xattr.c
--- 25/fs/jfs/xattr.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/jfs/xattr.c	2004-01-19 22:17:23.000000000 -0800
@@ -499,7 +499,7 @@ static int ea_get(struct inode *inode, s
 		if (ea_buf->xattr == NULL)
 			return -ENOMEM;
 
-		ea_buf->flag |= EA_MALLOC;
+		ea_buf->flag = EA_MALLOC;
 		ea_buf->max_size = (size + sb->s_blocksize - 1) &
 		    ~(sb->s_blocksize - 1);
 
@@ -668,12 +668,13 @@ static int can_set_system_xattr(struct i
 	 */
 	if (strcmp(name, XATTR_NAME_ACL_ACCESS) == 0) {
 		acl = posix_acl_from_xattr(value, value_len);
-		if (acl < 0) {
+		if (IS_ERR(acl)) {
+			rc = PTR_ERR(acl);
 			printk(KERN_ERR "posix_acl_from_xattr returned %d\n",
 			       rc);
 			return rc;
 		}
-		if (acl > 0) {
+		if (acl) {
 			mode_t mode = inode->i_mode;
 			rc = posix_acl_equiv_mode(acl, &mode);
 			posix_acl_release(acl);
diff -puN fs/libfs.c~linus fs/libfs.c
--- 25/fs/libfs.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/libfs.c	2004-01-19 22:17:23.000000000 -0800
@@ -155,6 +155,7 @@ int dcache_readdir(struct file * filp, v
 			}
 			spin_unlock(&dcache_lock);
 	}
+	update_atime(dentry->d_inode);
 	return 0;
 }
 
diff -puN fs/locks.c~linus fs/locks.c
--- 25/fs/locks.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/locks.c	2004-01-19 22:17:23.000000000 -0800
@@ -1454,7 +1454,7 @@ int fcntl_setlk(struct file *filp, unsig
 	 */
 	if (IS_MANDLOCK(inode) &&
 	    (inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID) {
-		struct address_space *mapping = inode->i_mapping;
+		struct address_space *mapping = filp->f_mapping;
 
 		if (!list_empty(&mapping->i_mmap_shared)) {
 			error = -EAGAIN;
@@ -1592,7 +1592,7 @@ int fcntl_setlk64(struct file *filp, uns
 	 */
 	if (IS_MANDLOCK(inode) &&
 	    (inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID) {
-		struct address_space *mapping = inode->i_mapping;
+		struct address_space *mapping = filp->f_mapping;
 
 		if (!list_empty(&mapping->i_mmap_shared)) {
 			error = -EAGAIN;
diff -puN fs/nfs/dir.c~linus fs/nfs/dir.c
--- 25/fs/nfs/dir.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/nfs/dir.c	2004-01-19 22:17:23.000000000 -0800
@@ -1281,13 +1281,8 @@ nfs_permission(struct inode *inode, int 
 	int mode = inode->i_mode;
 	int res;
 
-	/* Are we checking permissions on anything other than lookup? */
-	if (!(mask & MAY_EXEC)) {
-		/* We only need to check permissions on file open() and access() */
-		if (!nd || !(nd->flags & (LOOKUP_OPEN|LOOKUP_ACCESS)))
-			return 0;
-	}
-
+	if (mask == 0)
+		return 0;
 	if (mask & MAY_WRITE) {
 		/*
 		 *
@@ -1306,6 +1301,12 @@ nfs_permission(struct inode *inode, int 
 		if (IS_IMMUTABLE(inode))
 			return -EACCES;
 	}
+	/* Are we checking permissions on anything other than lookup/execute? */
+	if ((mask & MAY_EXEC) == 0) {
+		/* We only need to check permissions on file open() and access() */
+		if (!nd || !(nd->flags & (LOOKUP_OPEN|LOOKUP_ACCESS)))
+			return 0;
+	}
 
 	lock_kernel();
 
diff -puN fs/nfsd/nfsfh.c~linus fs/nfsd/nfsfh.c
--- 25/fs/nfsd/nfsfh.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/nfsd/nfsfh.c	2004-01-19 22:17:24.000000000 -0800
@@ -164,6 +164,9 @@ fh_verify(struct svc_rqst *rqstp, struct
 			goto out;
 		}
 
+		/* Set user creds for this exportpoint */
+		nfsd_setuser(rqstp, exp);
+
 		/*
 		 * Look up the dentry using the NFS file handle.
 		 */
@@ -224,9 +227,6 @@ fh_verify(struct svc_rqst *rqstp, struct
 	inode = dentry->d_inode;
 
 
-	/* Set user creds for this exportpoint */
-	nfsd_setuser(rqstp, exp);
-
 	/* Type check. The correct error return for type mismatches
 	 * does not seem to be generally agreed upon. SunOS seems to
 	 * use EISDIR if file isn't S_IFREG; a comment in the NFSv3
@@ -489,3 +489,21 @@ fh_put(struct svc_fh *fhp)
 	return;
 }
 
+/*
+ * Shorthand for dprintk()'s
+ */
+char * SVCFH_fmt(struct svc_fh *fhp)
+{
+	struct knfsd_fh *fh = &fhp->fh_handle;
+
+	static char buf[80];
+	sprintf(buf, "%d: %08x %08x %08x %08x %08x %08x",
+		fh->fh_size,
+		fh->fh_base.fh_pad[0],
+		fh->fh_base.fh_pad[1],
+		fh->fh_base.fh_pad[2],
+		fh->fh_base.fh_pad[3],
+		fh->fh_base.fh_pad[4],
+		fh->fh_base.fh_pad[5]);
+	return buf;
+}
diff -puN fs/nfsd/nfsxdr.c~linus fs/nfsd/nfsxdr.c
--- 25/fs/nfsd/nfsxdr.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/nfsd/nfsxdr.c	2004-01-19 22:17:24.000000000 -0800
@@ -130,6 +130,17 @@ decode_sattr(u32 *p, struct iattr *iap)
 		iap->ia_valid |= ATTR_MTIME | ATTR_MTIME_SET;
 		iap->ia_mtime.tv_sec = tmp;
 		iap->ia_mtime.tv_nsec = tmp1 * 1000; 
+		/*
+		 * Passing the invalid value useconds=1000000 for mtime
+		 * is a Sun convention for "set both mtime and atime to
+		 * current server time".  It's needed to make permissions
+		 * checks for the "touch" program across v2 mounts to
+		 * Solaris and Irix boxes work correctly. See description of
+		 * sattr in section 6.1 of "NFS Illustrated" by
+		 * Brent Callaghan, Addison-Wesley, ISBN 0-201-32750-5
+		 */
+		if (tmp1 == 1000000)
+			iap->ia_valid &= ~(ATTR_ATIME_SET|ATTR_MTIME_SET);
 	}
 	return p;
 }
diff -puN fs/nfsd/vfs.c~linus fs/nfsd/vfs.c
--- 25/fs/nfsd/vfs.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/nfsd/vfs.c	2004-01-19 22:17:24.000000000 -0800
@@ -43,6 +43,7 @@
 #endif /* CONFIG_NFSD_V3 */
 #include <linux/nfsd/nfsfh.h>
 #include <linux/quotaops.h>
+#include <linux/dnotify.h>
 
 #include <asm/uaccess.h>
 
@@ -161,7 +162,7 @@ nfsd_lookup(struct svc_rqst *rqstp, stru
 			struct dentry *dp;
 			struct vfsmount *mnt = mntget(exp->ex_mnt);
 			dentry = dget(dparent);
-			while(follow_up(&mnt, &dentry))
+			while(dentry == mnt->mnt_root && follow_up(&mnt, &dentry))
 				;
 			dp = dget_parent(dentry);
 			dput(dentry);
@@ -173,7 +174,7 @@ nfsd_lookup(struct svc_rqst *rqstp, stru
 				err = PTR_ERR(exp2);
 				dput(dentry);
 				mntput(mnt);
-				goto out;
+				goto out_nfserr;
 			}
 			if (!exp2) {
 				dput(dentry);
@@ -680,6 +681,7 @@ nfsd_read(struct svc_rqst *rqstp, struct
 		nfsdstats.io_read += err;
 		*count = err;
 		err = 0;
+		dnotify_parent(file.f_dentry, DN_ACCESS);
 	} else 
 		err = nfserrno(err);
 out_close:
@@ -745,9 +747,11 @@ nfsd_write(struct svc_rqst *rqstp, struc
 	/* Write the data. */
 	oldfs = get_fs(); set_fs(KERNEL_DS);
 	err = vfs_writev(&file, vec, vlen, &offset);
-	if (err >= 0)
-		nfsdstats.io_write += cnt;
 	set_fs(oldfs);
+	if (err >= 0) {
+		nfsdstats.io_write += cnt;
+		dnotify_parent(file.f_dentry, DN_MODIFY);
+	}
 
 	/* clear setuid/setgid flag after write */
 	if (err >= 0 && (inode->i_mode & (S_ISUID | S_ISGID))) {
diff -puN fs/nfs/file.c~linus fs/nfs/file.c
--- 25/fs/nfs/file.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/nfs/file.c	2004-01-19 22:17:23.000000000 -0800
@@ -266,7 +266,7 @@ out_swapfile:
 int
 nfs_lock(struct file *filp, int cmd, struct file_lock *fl)
 {
-	struct inode * inode = filp->f_dentry->d_inode;
+	struct inode * inode = filp->f_mapping->host;
 	int	status = 0;
 	int	status2;
 
@@ -309,13 +309,13 @@ nfs_lock(struct file *filp, int cmd, str
 	 * Flush all pending writes before doing anything
 	 * with locks..
 	 */
-	status = filemap_fdatawrite(inode->i_mapping);
+	status = filemap_fdatawrite(filp->f_mapping);
 	down(&inode->i_sem);
 	status2 = nfs_wb_all(inode);
 	if (!status)
 		status = status2;
 	up(&inode->i_sem);
-	status2 = filemap_fdatawait(inode->i_mapping);
+	status2 = filemap_fdatawait(filp->f_mapping);
 	if (!status)
 		status = status2;
 	if (status < 0)
@@ -335,11 +335,11 @@ nfs_lock(struct file *filp, int cmd, str
 	 */
  out_ok:
 	if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
-		filemap_fdatawrite(inode->i_mapping);
+		filemap_fdatawrite(filp->f_mapping);
 		down(&inode->i_sem);
 		nfs_wb_all(inode);      /* we may have slept */
 		up(&inode->i_sem);
-		filemap_fdatawait(inode->i_mapping);
+		filemap_fdatawait(filp->f_mapping);
 		nfs_zap_caches(inode);
 	}
 	return status;
diff -puN fs/nfs/inode.c~linus fs/nfs/inode.c
--- 25/fs/nfs/inode.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/nfs/inode.c	2004-01-19 22:17:24.000000000 -0800
@@ -791,6 +791,8 @@ out_no_inode:
 	goto out;
 }
 
+#define NFS_VALID_ATTRS (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|ATTR_ATIME|ATTR_ATIME_SET|ATTR_MTIME|ATTR_MTIME_SET)
+
 int
 nfs_setattr(struct dentry *dentry, struct iattr *attr)
 {
@@ -798,6 +800,11 @@ nfs_setattr(struct dentry *dentry, struc
 	struct nfs_fattr fattr;
 	int error;
 
+	/* Optimization: if the end result is no change, don't RPC */
+	attr->ia_valid &= NFS_VALID_ATTRS;
+	if (attr->ia_valid == 0)
+		return 0;
+
 	lock_kernel();
 
 	/*
@@ -813,6 +820,8 @@ printk("nfs_setattr: revalidate failed, 
 
 	if (!S_ISREG(inode->i_mode)) {
 		attr->ia_valid &= ~ATTR_SIZE;
+		if (attr->ia_valid == 0)
+			goto out;
 	} else {
 		filemap_fdatawrite(inode->i_mapping);
 		error = nfs_wb_all(inode);
diff -puN fs/nfs/write.c~linus fs/nfs/write.c
--- 25/fs/nfs/write.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/nfs/write.c	2004-01-19 22:17:24.000000000 -0800
@@ -228,8 +228,19 @@ nfs_writepage(struct page *page, struct 
 	unsigned long end_index;
 	unsigned offset = PAGE_CACHE_SIZE;
 	loff_t i_size = i_size_read(inode);
+	int inode_referenced = 0;
 	int err;
 
+	/*
+	 * Note: We need to ensure that we have a reference to the inode
+	 *       if we are to do asynchronous writes. If not, waiting
+	 *       in nfs_wait_on_request() may deadlock with clear_inode().
+	 *
+	 *       If igrab() fails here, then it is in any case safe to
+	 *       call nfs_wb_page(), since there will be no pending writes.
+	 */
+	if (igrab(inode) != 0)
+		inode_referenced = 1;
 	end_index = i_size >> PAGE_CACHE_SHIFT;
 
 	/* Ensure we've flushed out any previous writes */
@@ -247,7 +258,8 @@ nfs_writepage(struct page *page, struct 
 		goto out;
 do_it:
 	lock_kernel();
-	if (NFS_SERVER(inode)->wsize >= PAGE_CACHE_SIZE && !IS_SYNC(inode)) {
+	if (NFS_SERVER(inode)->wsize >= PAGE_CACHE_SIZE && !IS_SYNC(inode) &&
+			inode_referenced) {
 		err = nfs_writepage_async(NULL, inode, page, 0, offset);
 		if (err >= 0)
 			err = 0;
@@ -259,6 +271,8 @@ do_it:
 	unlock_kernel();
 out:
 	unlock_page(page);
+	if (inode_referenced)
+		iput(inode);
 	return err; 
 }
 
@@ -1074,9 +1088,12 @@ int nfs_commit_file(struct inode *inode,
 
 	spin_lock(&nfs_wreq_lock);
 	res = nfs_scan_commit(inode, &head, file, idx_start, npages);
-	spin_unlock(&nfs_wreq_lock);
-	if (res)
+	if (res) {
+		res += nfs_scan_commit(inode, &head, NULL, 0, 0);
+		spin_unlock(&nfs_wreq_lock);
 		error = nfs_commit_list(&head, how);
+	} else
+		spin_unlock(&nfs_wreq_lock);
 	if (error < 0)
 		return error;
 	return res;
diff -puN fs/ntfs/ChangeLog~linus fs/ntfs/ChangeLog
--- 25/fs/ntfs/ChangeLog~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/ntfs/ChangeLog	2004-01-19 22:17:24.000000000 -0800
@@ -20,6 +20,14 @@ ToDo:
 	  sufficient for synchronisation here. We then just need to make sure
 	  ntfs_readpage/writepage/truncate interoperate properly with us.
 
+2.1.6 - Fix minor bug in handling of compressed directories.
+
+	- Fix bug in handling of compressed directories.  A compressed
+	  directory is not really compressed so when we set the ->i_blocks
+	  field of a compressed directory inode we were setting it from the
+	  non-existing field ni->itype.compressed.size which gave random
+	  results...  For directories we now always use ni->allocated_size.
+
 2.1.5 - Fix minor bug in attribute list attribute handling.
 
 	- Fix bug in attribute list handling.  Actually it is not as much a bug
diff -puN fs/ntfs/inode.c~linus fs/ntfs/inode.c
--- 25/fs/ntfs/inode.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/ntfs/inode.c	2004-01-19 22:17:24.000000000 -0800
@@ -1,7 +1,7 @@
 /**
  * inode.c - NTFS kernel inode handling. Part of the Linux-NTFS project.
  *
- * Copyright (c) 2001-2003 Anton Altaparmakov
+ * Copyright (c) 2001-2004 Anton Altaparmakov
  *
  * This program/include file is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as published
@@ -1046,7 +1046,7 @@ no_data_attr_special_case:
 	 * sizes of all non-resident attributes present to give us the Linux
 	 * correct size that should go into i_blocks (after division by 512).
 	 */
-	if (!NInoCompressed(ni))
+	if (S_ISDIR(vi->i_mode) || !NInoCompressed(ni))
 		vi->i_blocks = ni->allocated_size >> 9;
 	else
 		vi->i_blocks = ni->itype.compressed.size >> 9;
diff -puN fs/ntfs/Makefile~linus fs/ntfs/Makefile
--- 25/fs/ntfs/Makefile~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/ntfs/Makefile	2004-01-19 22:17:24.000000000 -0800
@@ -5,7 +5,7 @@ obj-$(CONFIG_NTFS_FS) += ntfs.o
 ntfs-objs := aops.o attrib.o compress.o debug.o dir.o file.o inode.o mft.o \
 	     mst.o namei.o super.o sysctl.o time.o unistr.o upcase.o
 
-EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.5\"
+EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.6\"
 
 ifeq ($(CONFIG_NTFS_DEBUG),y)
 EXTRA_CFLAGS += -DDEBUG
diff -puN fs/open.c~linus fs/open.c
--- 25/fs/open.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/open.c	2004-01-19 22:17:24.000000000 -0800
@@ -776,7 +776,8 @@ struct file *dentry_open(struct dentry *
 			goto cleanup_file;
 	}
 
-	file_ra_state_init(&f->f_ra, inode->i_mapping);
+	f->f_mapping = inode->i_mapping;
+	file_ra_state_init(&f->f_ra, f->f_mapping);
 	f->f_dentry = dentry;
 	f->f_vfsmnt = mnt;
 	f->f_pos = 0;
@@ -792,8 +793,8 @@ struct file *dentry_open(struct dentry *
 
 	/* NB: we're sure to have correct a_ops only after f_op->open */
 	if (f->f_flags & O_DIRECT) {
-		if (!inode->i_mapping || !inode->i_mapping->a_ops ||
-			!inode->i_mapping->a_ops->direct_IO) {
+		if (!f->f_mapping || !f->f_mapping->a_ops ||
+			!f->f_mapping->a_ops->direct_IO) {
 				fput(f);
 				f = ERR_PTR(-EINVAL);
 		}
diff -puN fs/pipe.c~linus fs/pipe.c
--- 25/fs/pipe.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/pipe.c	2004-01-19 22:17:24.000000000 -0800
@@ -650,6 +650,7 @@ int do_pipe(int *fd)
 	d_add(dentry, inode);
 	f1->f_vfsmnt = f2->f_vfsmnt = mntget(mntget(pipe_mnt));
 	f1->f_dentry = f2->f_dentry = dget(dentry);
+	f1->f_mapping = f2->f_mapping = inode->i_mapping;
 
 	/* read file */
 	f1->f_pos = f2->f_pos = 0;
diff -puN fs/proc/base.c~linus fs/proc/base.c
--- 25/fs/proc/base.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/proc/base.c	2004-01-19 22:17:24.000000000 -0800
@@ -1669,14 +1669,26 @@ out:
  * tasklist lock while doing this, and we must release it before
  * we actually do the filldir itself, so we use a temp buffer..
  */
-static int get_tgid_list(int index, unsigned int *tgids)
+static int get_tgid_list(int index, unsigned long version, unsigned int *tgids)
 {
 	struct task_struct *p;
 	int nr_tgids = 0;
 
 	index--;
 	read_lock(&tasklist_lock);
-	for_each_process(p) {
+	p = NULL;
+	if (version) {
+		p = find_task_by_pid(version);
+		if (!thread_group_leader(p))
+			p = NULL;
+	}
+
+	if (p)
+		index = 0;
+	else
+		p = next_task(&init_task);
+
+	for ( ; p != &init_task; p = next_task(p)) {
 		int tgid = p->pid;
 		if (!pid_alive(p))
 			continue;
@@ -1739,7 +1751,10 @@ int proc_pid_readdir(struct file * filp,
 		nr++;
 	}
 
-	nr_tgids = get_tgid_list(nr, tgid_array);
+	/*
+	 * f_version caches the last tgid which was returned from readdir
+	 */
+	nr_tgids = get_tgid_list(nr, filp->f_version, tgid_array);
 
 	for (i = 0; i < nr_tgids; i++) {
 		int tgid = tgid_array[i];
@@ -1748,8 +1763,10 @@ int proc_pid_readdir(struct file * filp,
 
 		do buf[--j] = '0' + (tgid % 10); while (tgid/=10);
 
-		if (filldir(dirent, buf+j, PROC_NUMBUF-j, filp->f_pos, ino, DT_DIR) < 0)
+		if (filldir(dirent, buf+j, PROC_NUMBUF-j, filp->f_pos, ino, DT_DIR) < 0) {
+			filp->f_version = tgid;
 			break;
+		}
 		filp->f_pos++;
 	}
 	return 0;
diff -puN fs/proc/proc_devtree.c~linus fs/proc/proc_devtree.c
--- 25/fs/proc/proc_devtree.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/proc/proc_devtree.c	2004-01-19 22:17:24.000000000 -0800
@@ -11,6 +11,20 @@
 #include <asm/prom.h>
 #include <asm/uaccess.h>
 
+#ifndef HAVE_ARCH_DEVTREE_FIXUPS
+static inline void set_node_proc_entry(struct device_node *np, struct proc_dir_entry *de)
+{
+}
+
+static void inline set_node_name_link(struct device_node *np, struct proc_dir_entry *de)
+{
+}
+
+static void inline set_node_addr_link(struct device_node *np, struct proc_dir_entry *de)
+{
+}
+#endif
+
 static struct proc_dir_entry *proc_device_tree;
 
 /*
@@ -44,7 +58,7 @@ static int property_read_proc(char *page
 /*
  * Process a node, adding entries for its children and its properties.
  */
-static void add_node(struct device_node *np, struct proc_dir_entry *de)
+void proc_device_tree_add_node(struct device_node *np, struct proc_dir_entry *de)
 {
 	struct property *pp;
 	struct proc_dir_entry *ent;
@@ -53,6 +67,7 @@ static void add_node(struct device_node 
 	int l;
 	struct proc_dir_entry *list, **lastp, *al;
 
+	set_node_proc_entry(np, de);
 	lastp = &list;
 	for (pp = np->properties; pp != 0; pp = pp->next) {
 		/*
@@ -70,7 +85,8 @@ static void add_node(struct device_node 
 		*lastp = ent;
 		lastp = &ent->next;
 	}
-	for (child = np->child; child != 0; child = child->sibling) {
+	child = NULL;
+	while ((child = of_get_next_child(np, child))) {
 		p = strrchr(child->full_name, '/');
 		if (p == 0)
 			p = child->full_name;
@@ -85,7 +101,7 @@ static void add_node(struct device_node 
 			break;
 		*lastp = ent;
 		lastp = &ent->next;
-		add_node(child, ent);
+		proc_device_tree_add_node(child, ent);
 
 		/*
 		 * If we left the address part on the name, consider
@@ -98,26 +114,32 @@ static void add_node(struct device_node 
 		 * If this is the first node with a given name property,
 		 * add a symlink with the name property as its name.
 		 */
-		for (sib = np->child; sib != child; sib = sib->sibling)
+		sib = NULL;
+		while ((sib = of_get_next_child(np, sib)) && sib != child)
 			if (sib->name && strcmp(sib->name, child->name) == 0)
 				break;
 		if (sib == child && strncmp(p, child->name, l) != 0) {
 			al = proc_symlink(child->name, de, ent->name);
-			if (al == 0)
+			if (al == 0) {
+				of_node_put(sib);
 				break;
+			}
+			set_node_name_link(child, al);
 			*lastp = al;
 			lastp = &al->next;
 		}
-
+		of_node_put(sib);
 		/*
 		 * Add another directory with the @address part as its name.
 		 */
 		al = proc_symlink(at, de, ent->name);
 		if (al == 0)
 			break;
+		set_node_addr_link(child, al);
 		*lastp = al;
 		lastp = &al->next;
 	}
+	of_node_put(child);
 	*lastp = 0;
 	de->subdir = list;
 }
@@ -133,10 +155,11 @@ void proc_device_tree_init(void)
 	proc_device_tree = proc_mkdir("device-tree", 0);
 	if (proc_device_tree == 0)
 		return;
-	root = find_path_device("/");
+	root = of_find_node_by_path("/");
 	if (root == 0) {
 		printk(KERN_ERR "/proc/device-tree: can't find root\n");
 		return;
 	}
-	add_node(root, proc_device_tree);
+	proc_device_tree_add_node(root, proc_device_tree);
+	of_node_put(root);
 }
diff -puN fs/proc/proc_misc.c~linus fs/proc/proc_misc.c
--- 25/fs/proc/proc_misc.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/proc/proc_misc.c	2004-01-19 22:17:24.000000000 -0800
@@ -378,10 +378,9 @@ int show_stat(struct seq_file *p, void *
 	jif = ((u64)now.tv_sec * HZ) + (now.tv_usec/(1000000/HZ)) - jif;
 	do_div(jif, HZ);
 
-	for (i = 0; i < NR_CPUS; i++) {
+	for_each_cpu(i) {
 		int j;
 
-		if (!cpu_online(i)) continue;
 		user += kstat_cpu(i).cpustat.user;
 		nice += kstat_cpu(i).cpustat.nice;
 		system += kstat_cpu(i).cpustat.system;
@@ -401,8 +400,7 @@ int show_stat(struct seq_file *p, void *
 		jiffies_to_clock_t(iowait),
 		jiffies_to_clock_t(irq),
 		jiffies_to_clock_t(softirq));
-	for (i = 0; i < NR_CPUS; i++){
-		if (!cpu_online(i)) continue;
+	for_each_online_cpu(i) {
 		seq_printf(p, "cpu%d %u %u %u %u %u %u %u\n",
 			i,
 			jiffies_to_clock_t(kstat_cpu(i).cpustat.user),
diff -puN fs/proc/task_mmu.c~linus fs/proc/task_mmu.c
--- 25/fs/proc/task_mmu.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/proc/task_mmu.c	2004-01-19 22:17:24.000000000 -0800
@@ -76,22 +76,6 @@ int task_statm(struct mm_struct *mm, int
 	return size;
 }
 
-#ifdef AT_SYSINFO_EHDR
-
-static struct vm_area_struct gate_vmarea = {
-	/* Do _not_ mark this area as readable, cuz not the entire range may be readable
-	   (e.g., due to execute-only pages or holes) and the tools that read
-	   /proc/PID/maps should read the interesting bits from the gate-DSO file
-	   instead.  */
-	.vm_start = FIXADDR_USER_START,
-	.vm_end = FIXADDR_USER_END
-};
-
-# define gate_map()	&gate_vmarea
-#else
-# define gate_map()	NULL
-#endif
-
 static int show_map(struct seq_file *m, void *v)
 {
 	struct vm_area_struct *map = v;
@@ -146,15 +130,16 @@ static void *m_start(struct seq_file *m,
 		up_read(&mm->mmap_sem);
 		mmput(mm);
 		if (l == -1)
-			map = gate_map();
+			map = get_gate_vma(task);
 	}
 	return map;
 }
 
 static void m_stop(struct seq_file *m, void *v)
 {
+	struct task_struct *task = m->private;
 	struct vm_area_struct *map = v;
-	if (map && map != gate_map()) {
+	if (map && map != get_gate_vma(task)) {
 		struct mm_struct *mm = map->vm_mm;
 		up_read(&mm->mmap_sem);
 		mmput(mm);
@@ -163,13 +148,14 @@ static void m_stop(struct seq_file *m, v
 
 static void *m_next(struct seq_file *m, void *v, loff_t *pos)
 {
+	struct task_struct *task = m->private;
 	struct vm_area_struct *map = v;
 	(*pos)++;
 	if (map->vm_next)
 		return map->vm_next;
 	m_stop(m, v);
-	if (map != gate_map())
-		return gate_map();
+	if (map != get_gate_vma(task))
+		return get_gate_vma(task);
 	return NULL;
 }
 
diff -puN fs/read_write.c~linus fs/read_write.c
--- 25/fs/read_write.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/read_write.c	2004-01-19 22:17:24.000000000 -0800
@@ -28,7 +28,7 @@ EXPORT_SYMBOL(generic_ro_fops);
 loff_t generic_file_llseek(struct file *file, loff_t offset, int origin)
 {
 	long long retval;
-	struct inode *inode = file->f_dentry->d_inode->i_mapping->host;
+	struct inode *inode = file->f_mapping->host;
 
 	down(&inode->i_sem);
 	switch (origin) {
diff -puN fs/reiserfs/file.c~linus fs/reiserfs/file.c
--- 25/fs/reiserfs/file.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/reiserfs/file.c	2004-01-19 22:17:24.000000000 -0800
@@ -8,6 +8,7 @@
 #include <linux/smp_lock.h>
 #include <asm/uaccess.h>
 #include <linux/pagemap.h>
+#include <linux/writeback.h>
 
 /*
 ** We pack the tails of files on file close, not at the time they are written.
@@ -1052,7 +1053,7 @@ ssize_t reiserfs_file_write( struct file
     /* Check if we can write to specified region of file, file
        is not overly big and this kind of stuff. Adjust pos and
        count, if needed */
-    res = generic_write_checks(inode, file, &pos, &count, 0);
+    res = generic_write_checks(file, &pos, &count, 0);
     if (res)
 	goto out;
 
@@ -1176,10 +1177,11 @@ ssize_t reiserfs_file_write( struct file
 	buf += write_bytes;
 	*ppos = pos += write_bytes;
 	count -= write_bytes;
+	balance_dirty_pages_ratelimited(inode->i_mapping);
     }
 
     if ((file->f_flags & O_SYNC) || IS_SYNC(inode))
-	res = generic_osync_inode(inode, OSYNC_METADATA|OSYNC_DATA);
+	res = generic_osync_inode(inode, file->f_mapping, OSYNC_METADATA|OSYNC_DATA);
 
     up(&inode->i_sem);
     return (already_written != 0)?already_written:res;
diff -puN fs/reiserfs/inode.c~linus fs/reiserfs/inode.c
--- 25/fs/reiserfs/inode.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/reiserfs/inode.c	2004-01-19 22:17:24.000000000 -0800
@@ -2375,7 +2375,7 @@ static int reiserfs_direct_IO(int rw, st
 			      loff_t offset, unsigned long nr_segs)
 {
     struct file *file = iocb->ki_filp;
-    struct inode *inode = file->f_dentry->d_inode->i_mapping->host;
+    struct inode *inode = file->f_mapping->host;
 
     return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
 			      offset, nr_segs, reiserfs_get_blocks_direct_io, NULL);
diff -puN fs/reiserfs/journal.c~linus fs/reiserfs/journal.c
--- 25/fs/reiserfs/journal.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/reiserfs/journal.c	2004-01-19 22:17:24.000000000 -0800
@@ -1937,18 +1937,13 @@ static int journal_init_dev( struct supe
 
 	journal -> j_dev_file = filp_open( jdev_name, 0, 0 );
 	if( !IS_ERR( journal -> j_dev_file ) ) {
-		struct inode *jdev_inode;
-
-		jdev_inode = journal -> j_dev_file -> f_dentry -> d_inode;
-		journal -> j_dev_bd = jdev_inode -> i_bdev;
+		struct inode *jdev_inode = journal->j_dev_file->f_mapping->host;
 		if( !S_ISBLK( jdev_inode -> i_mode ) ) {
 			printk( "journal_init_dev: '%s' is not a block device\n", jdev_name );
 			result = -ENOTBLK;
-		} else if( jdev_inode -> i_bdev == NULL ) {
-			printk( "journal_init_dev: bdev uninitialized for '%s'\n", jdev_name );
-			result = -ENOMEM;
 		} else  {
 			/* ok */
+			journal->j_dev_bd = I_BDEV(jdev_inode);
 			set_blocksize(journal->j_dev_bd, super->s_blocksize);
 		}
 	} else {
diff -puN fs/xfs/linux/xfs_aops.c~linus fs/xfs/linux/xfs_aops.c
--- 25/fs/xfs/linux/xfs_aops.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/linux/xfs_aops.c	2004-01-19 22:17:24.000000000 -0800
@@ -51,10 +51,11 @@
 #include "xfs_inode.h"
 #include "xfs_error.h"
 #include "xfs_rw.h"
+#include "xfs_iomap.h"
 #include <linux/mpage.h>
 
 STATIC void convert_page(struct inode *, struct page *,
-			page_buf_bmap_t *, void *, int, int);
+			xfs_iomap_t *, void *, int, int);
 
 void
 linvfs_unwritten_done(
@@ -85,11 +86,9 @@ linvfs_unwritten_convert(
 	vnode_t		*vp = XFS_BUF_FSPRIVATE(bp, vnode_t *);
 	int		error;
 
-	if (atomic_read(&bp->pb_hold) < 1) 
-		BUG();
-
+	BUG_ON(atomic_read(&bp->pb_hold) < 1);
 	VOP_BMAP(vp, XFS_BUF_OFFSET(bp), XFS_BUF_SIZE(bp),
-			BMAP_UNWRITTEN, NULL, NULL, error);
+			BMAPI_UNWRITTEN, NULL, NULL, error);
 	XFS_BUF_SET_FSPRIVATE(bp, NULL);
 	XFS_BUF_CLR_IODONE_FUNC(bp);
 	XFS_BUF_UNDATAIO(bp);
@@ -117,7 +116,7 @@ linvfs_unwritten_convert_direct(
 		vnode_t	*vp = LINVFS_GET_VP(inode);
 		int	error;
 
-		VOP_BMAP(vp, offset, size, BMAP_UNWRITTEN, NULL, NULL, error);
+		VOP_BMAP(vp, offset, size, BMAPI_UNWRITTEN, NULL, NULL, error);
 	}
 }
 
@@ -126,26 +125,26 @@ map_blocks(
 	struct inode		*inode,
 	loff_t			offset,
 	ssize_t			count,
-	page_buf_bmap_t		*pbmapp,
+	xfs_iomap_t		*iomapp,
 	int			flags)
 {
 	vnode_t			*vp = LINVFS_GET_VP(inode);
-	int			error, nmaps = 1;
+	int			error, niomaps = 1;
 
-	if (((flags & (BMAP_DIRECT|BMAP_SYNC)) == BMAP_DIRECT) &&
+	if (((flags & (BMAPI_DIRECT|BMAPI_SYNC)) == BMAPI_DIRECT) &&
 	    (offset >= i_size_read(inode)))
 		count = max_t(ssize_t, count, XFS_WRITE_IO_LOG);
 retry:
-	VOP_BMAP(vp, offset, count, flags, pbmapp, &nmaps, error);
+	VOP_BMAP(vp, offset, count, flags, iomapp, &niomaps, error);
 	if ((error == EAGAIN) || (error == EIO))
 		return -error;
-	if (unlikely((flags & (BMAP_WRITE|BMAP_DIRECT)) ==
-					(BMAP_WRITE|BMAP_DIRECT) && nmaps &&
-					(pbmapp->pbm_flags & PBMF_DELAY))) {
-		flags = BMAP_ALLOCATE;
+	if (unlikely((flags & (BMAPI_WRITE|BMAPI_DIRECT)) ==
+					(BMAPI_WRITE|BMAPI_DIRECT) && niomaps &&
+					(iomapp->iomap_flags & IOMAP_DELAY))) {
+		flags = BMAPI_ALLOCATE;
 		goto retry;
 	}
-	if (flags & (BMAP_WRITE|BMAP_ALLOCATE)) {
+	if (flags & (BMAPI_WRITE|BMAPI_ALLOCATE)) {
 		VMODIFY(vp);
 	}
 	return -error;
@@ -156,10 +155,10 @@ retry:
  * Finds the corresponding mapping in block @map array of the
  * given @offset within a @page.
  */
-STATIC page_buf_bmap_t *
+STATIC xfs_iomap_t *
 match_offset_to_mapping(
 	struct page		*page,
-	page_buf_bmap_t		*map,
+	xfs_iomap_t		*iomapp,
 	unsigned long		offset)
 {
 	loff_t			full_offset;	/* offset from start of file */
@@ -170,10 +169,10 @@ match_offset_to_mapping(
 	full_offset <<= PAGE_CACHE_SHIFT;	/* offset from file start */
 	full_offset += offset;			/* offset from page start */
 
-	if (full_offset < map->pbm_offset)
+	if (full_offset < iomapp->iomap_offset)
 		return NULL;
-	if (map->pbm_offset + map->pbm_bsize > full_offset)
-		return map;
+	if (iomapp->iomap_offset + iomapp->iomap_bsize > full_offset)
+		return iomapp;
 	return NULL;
 }
 
@@ -183,30 +182,30 @@ map_buffer_at_offset(
 	struct buffer_head	*bh,
 	unsigned long		offset,
 	int			block_bits,
-	page_buf_bmap_t		*mp)
+	xfs_iomap_t		*iomapp)
 {
-	page_buf_daddr_t	bn;
+	xfs_daddr_t		bn;
 	loff_t			delta;
 	int			sector_shift;
 
-	ASSERT(!(mp->pbm_flags & PBMF_HOLE));
-	ASSERT(!(mp->pbm_flags & PBMF_DELAY));
-	ASSERT(mp->pbm_bn != PAGE_BUF_DADDR_NULL);
+	ASSERT(!(iomapp->iomap_flags & IOMAP_HOLE));
+	ASSERT(!(iomapp->iomap_flags & IOMAP_DELAY));
+	ASSERT(iomapp->iomap_bn != IOMAP_DADDR_NULL);
 
 	delta = page->index;
 	delta <<= PAGE_CACHE_SHIFT;
 	delta += offset;
-	delta -= mp->pbm_offset;
+	delta -= iomapp->iomap_offset;
 	delta >>= block_bits;
 
 	sector_shift = block_bits - BBSHIFT;
-	bn = mp->pbm_bn >> sector_shift;
+	bn = iomapp->iomap_bn >> sector_shift;
 	bn += delta;
-	ASSERT((bn << sector_shift) >= mp->pbm_bn);
+	ASSERT((bn << sector_shift) >= iomapp->iomap_bn);
 
 	lock_buffer(bh);
 	bh->b_blocknr = bn;
-	bh->b_bdev = mp->pbm_target->pbr_bdev;
+	bh->b_bdev = iomapp->iomap_target->pbr_bdev;
 	set_buffer_mapped(bh);
 	clear_buffer_delay(bh);
 }
@@ -222,7 +221,7 @@ STATIC struct page *
 probe_unwritten_page(
 	struct address_space	*mapping,
 	unsigned long		index,
-	page_buf_bmap_t		*mp,
+	xfs_iomap_t		*iomapp,
 	page_buf_t		*pb,
 	unsigned long		max_offset,
 	unsigned long		*fsbs,
@@ -245,11 +244,11 @@ probe_unwritten_page(
 		do {
 			if (!buffer_unwritten(bh))
 				break;
-			if (!match_offset_to_mapping(page, mp, p_offset))
+			if (!match_offset_to_mapping(page, iomapp, p_offset))
 				break;
 			if (p_offset >= max_offset)
 				break;
-			map_buffer_at_offset(page, bh, p_offset, bbits, mp);
+			map_buffer_at_offset(page, bh, p_offset, bbits, iomapp);
 			set_buffer_unwritten_io(bh);
 			bh->b_private = pb;
 			p_offset += bh->b_size;
@@ -394,11 +393,12 @@ map_unwritten(
 	struct buffer_head	*curr,
 	unsigned long		p_offset,
 	int			block_bits,
-	page_buf_bmap_t		*mp,
+	xfs_iomap_t		*iomapp,
+	int			startio,
 	int			all_bh)
 {
 	struct buffer_head	*bh = curr;
-	page_buf_bmap_t		*tmp;
+	xfs_iomap_t		*tmp;
 	page_buf_t		*pb;
 	loff_t			offset, size;
 	unsigned long		nblocks = 0;
@@ -407,8 +407,8 @@ map_unwritten(
 	offset <<= PAGE_CACHE_SHIFT;
 	offset += p_offset;
 
-	pb = pagebuf_lookup(mp->pbm_target,
-			    mp->pbm_offset, mp->pbm_bsize, 0);
+	pb = pagebuf_lookup(iomapp->iomap_target,
+			    iomapp->iomap_offset, iomapp->iomap_bsize, 0);
 	if (!pb)
 		return -EAGAIN;
 
@@ -433,10 +433,10 @@ map_unwritten(
 	do {
 		if (!buffer_unwritten(bh))
 			break;
-		tmp = match_offset_to_mapping(start_page, mp, p_offset);
+		tmp = match_offset_to_mapping(start_page, iomapp, p_offset);
 		if (!tmp)
 			break;
-		map_buffer_at_offset(start_page, bh, p_offset, block_bits, mp);
+		map_buffer_at_offset(start_page, bh, p_offset, block_bits, iomapp);
 		set_buffer_unwritten_io(bh);
 		bh->b_private = pb;
 		p_offset += bh->b_size;
@@ -444,8 +444,8 @@ map_unwritten(
 	} while ((bh = bh->b_this_page) != head);
 
 	if (unlikely(nblocks == 0)) {
-		printk("XFS: bad unwritten extent map: bh=0x%p, mp=0x%p\n",
-			curr, mp);
+		printk("XFS: bad unwritten extent map: bh=0x%p, iomapp=0x%p\n",
+		       curr, iomapp);
 		BUG();
 	}
 
@@ -461,26 +461,26 @@ map_unwritten(
 		struct page		*page;
 
 		tlast = i_size_read(inode) >> PAGE_CACHE_SHIFT;
-		tloff = (mp->pbm_offset + mp->pbm_bsize) >> PAGE_CACHE_SHIFT;
+		tloff = (iomapp->iomap_offset + iomapp->iomap_bsize) >> PAGE_CACHE_SHIFT;
 		tloff = min(tlast, tloff);
 		for (tindex = start_page->index + 1; tindex < tloff; tindex++) {
-			page = probe_unwritten_page(mapping, tindex, mp, pb,
+			page = probe_unwritten_page(mapping, tindex, iomapp, pb,
 						PAGE_CACHE_SIZE, &bs, bbits);
 			if (!page)
 				break;
 			nblocks += bs;
 			atomic_add(bs, &pb->pb_io_remaining);
-			convert_page(inode, page, mp, pb, 1, all_bh);
+			convert_page(inode, page, iomapp, pb, startio, all_bh);
 		}
 
 		if (tindex == tlast &&
 		    (tloff = (i_size_read(inode) & (PAGE_CACHE_SIZE - 1)))) {
-			page = probe_unwritten_page(mapping, tindex, mp, pb,
+			page = probe_unwritten_page(mapping, tindex, iomapp, pb,
 							tloff, &bs, bbits);
 			if (page) {
 				nblocks += bs;
 				atomic_add(bs, &pb->pb_io_remaining);
-				convert_page(inode, page, mp, pb, 1, all_bh);
+				convert_page(inode, page, iomapp, pb, startio, all_bh);
 			}
 		}
 	}
@@ -542,13 +542,13 @@ STATIC void
 convert_page(
 	struct inode		*inode,
 	struct page		*page,
-	page_buf_bmap_t		*maps,
+	xfs_iomap_t		*iomapp,
 	void			*private,
 	int			startio,
 	int			all_bh)
 {
 	struct buffer_head	*bh_arr[MAX_BUF_PER_PAGE], *bh, *head;
-	page_buf_bmap_t		*mp = maps, *tmp;
+	xfs_iomap_t		*mp = iomapp, *tmp;
 	unsigned long		end, offset, end_index;
 	int			i = 0, index = 0;
 	int			bbits = inode->i_blkbits;
@@ -575,17 +575,17 @@ convert_page(
 		tmp = match_offset_to_mapping(page, mp, offset);
 		if (!tmp)
 			continue;
-		ASSERT(!(tmp->pbm_flags & PBMF_HOLE));
-		ASSERT(!(tmp->pbm_flags & PBMF_DELAY));
+		ASSERT(!(tmp->iomap_flags & IOMAP_HOLE));
+		ASSERT(!(tmp->iomap_flags & IOMAP_DELAY));
 
 		/* If this is a new unwritten extent buffer (i.e. one
 		 * that we haven't passed in private data for, we must
 		 * now map this buffer too.
 		 */
 		if (buffer_unwritten(bh) && !bh->b_end_io) {
-			ASSERT(tmp->pbm_flags & PBMF_UNWRITTEN);
+			ASSERT(tmp->iomap_flags & IOMAP_UNWRITTEN);
 			map_unwritten(inode, page, head, bh,
-						offset, bbits, tmp, all_bh);
+					offset, bbits, tmp, startio, all_bh);
 		} else if (! (buffer_unwritten(bh) && buffer_locked(bh))) {
 			map_buffer_at_offset(page, bh, offset, bbits, tmp);
 			if (buffer_unwritten(bh)) {
@@ -618,19 +618,19 @@ STATIC void
 cluster_write(
 	struct inode		*inode,
 	unsigned long		tindex,
-	page_buf_bmap_t		*mp,
+	xfs_iomap_t		*iomapp,
 	int			startio,
 	int			all_bh)
 {
 	unsigned long		tlast;
 	struct page		*page;
 
-	tlast = (mp->pbm_offset + mp->pbm_bsize) >> PAGE_CACHE_SHIFT;
+	tlast = (iomapp->iomap_offset + iomapp->iomap_bsize) >> PAGE_CACHE_SHIFT;
 	for (; tindex < tlast; tindex++) {
 		page = probe_delalloc_page(inode, tindex);
 		if (!page)
 			break;
-		convert_page(inode, page, mp, NULL, startio, all_bh);
+		convert_page(inode, page, iomapp, NULL, startio, all_bh);
 	}
 }
 
@@ -661,20 +661,21 @@ page_state_convert(
 	int		unmapped) /* also implies page uptodate */
 {
 	struct buffer_head	*bh_arr[MAX_BUF_PER_PAGE], *bh, *head;
-	page_buf_bmap_t		*mp, map;
+	xfs_iomap_t		*iomp, iomap;
 	unsigned long		p_offset = 0, end_index;
 	loff_t			offset, end_offset;
 	int			len, err, i, cnt = 0, uptodate = 1;
-	int			flags = startio ? 0 : BMAP_TRYLOCK;
+	int			flags = startio ? 0 : BMAPI_TRYLOCK;
 	int			page_dirty = 1;
 
 
 	/* Are we off the end of the file ? */
 	end_index = i_size_read(inode) >> PAGE_CACHE_SHIFT;
 	if (page->index >= end_index) {
-		unsigned remaining = i_size_read(inode) & (PAGE_CACHE_SIZE-1);
-		if ((page->index >= end_index+1) || !remaining) {
-			return -EIO;
+		if ((page->index >= end_index + 1) ||
+		    !(i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) {
+			err = -EIO;
+			goto error;
 		}
 	}
 
@@ -684,16 +685,19 @@ page_state_convert(
 		end_offset = i_size_read(inode);
 
 	bh = head = page_buffers(page);
-	mp = NULL;
+	iomp = NULL;
 
 	len = bh->b_size;
 	do {
-		if (!(PageUptodate(page) || buffer_uptodate(bh)) && !startio) {
-			goto next_bh;
-		}
+		if (offset >= end_offset)
+			break;
+		if (!buffer_uptodate(bh))
+			uptodate = 0;
+		if (!(PageUptodate(page) || buffer_uptodate(bh)) && !startio)
+			continue;
 
-		if (mp) {
-			mp = match_offset_to_mapping(page, &map, p_offset);
+		if (iomp) {
+			iomp = match_offset_to_mapping(page, &iomap, p_offset);
 		}
 
 		/*
@@ -701,21 +705,21 @@ page_state_convert(
 		 * extent state conversion transaction on completion.
 		 */
 		if (buffer_unwritten(bh)) {
-			if (!mp) {
-				err = map_blocks(inode, offset, len, &map,
-						BMAP_READ|BMAP_IGNSTATE);
+			if (!iomp) {
+				err = map_blocks(inode, offset, len, &iomap,
+						BMAPI_READ|BMAPI_IGNSTATE);
 				if (err) {
 					goto error;
 				}
-				mp = match_offset_to_mapping(page, &map,
+				iomp = match_offset_to_mapping(page, &iomap,
 								p_offset);
 			}
-			if (mp) {
+			if (iomp) {
 				if (!bh->b_end_io) {
 					err = map_unwritten(inode, page,
 							head, bh, p_offset,
-							inode->i_blkbits,
-							mp, unmapped);
+							inode->i_blkbits, iomp,
+							startio, unmapped);
 					if (err) {
 						goto error;
 					}
@@ -734,18 +738,18 @@ page_state_convert(
 		 * We can return EAGAIN here in the release page case.
 		 */
 		} else if (buffer_delay(bh)) {
-			if (!mp) {
-				err = map_blocks(inode, offset, len, &map,
-					BMAP_ALLOCATE | flags);
+			if (!iomp) {
+				err = map_blocks(inode, offset, len, &iomap,
+					BMAPI_ALLOCATE | flags);
 				if (err) {
 					goto error;
 				}
-				mp = match_offset_to_mapping(page, &map,
+				iomp = match_offset_to_mapping(page, &iomap,
 								p_offset);
 			}
-			if (mp) {
+			if (iomp) {
 				map_buffer_at_offset(page, bh, p_offset,
-					inode->i_blkbits, mp);
+					inode->i_blkbits, iomp);
 				if (startio) {
 					bh_arr[cnt++] = bh;
 				} else {
@@ -766,22 +770,22 @@ page_state_convert(
 				 * was found, and we are in a path where we
 				 * need to write the whole page out.
 				 */
-				if (!mp) {
+				if (!iomp) {
 					size = probe_unmapped_cluster(
 							inode, page, bh, head);
 					err = map_blocks(inode, offset,
-						size, &map,
-						BMAP_WRITE | BMAP_MMAP);
+						size, &iomap,
+						BMAPI_WRITE | BMAPI_MMAP);
 					if (err) {
 						goto error;
 					}
-					mp = match_offset_to_mapping(page, &map,
+					iomp = match_offset_to_mapping(page, &iomap,
 								     p_offset);
 				}
-				if (mp) {
+				if (iomp) {
 					map_buffer_at_offset(page,
 							bh, p_offset,
-							inode->i_blkbits, mp);
+							inode->i_blkbits, iomp);
 					if (startio) {
 						bh_arr[cnt++] = bh;
 					} else {
@@ -799,14 +803,8 @@ page_state_convert(
 				}
 			}
 		}
-
-next_bh:
-		if (!buffer_uptodate(bh))
-			uptodate = 0;
-		offset += len;
-		p_offset += len;
-		bh = bh->b_this_page;
-	} while (offset < end_offset);
+	} while (offset += len, p_offset += len,
+		((bh = bh->b_this_page) != head));
 
 	if (uptodate && bh == head)
 		SetPageUptodate(page);
@@ -814,8 +812,8 @@ next_bh:
 	if (startio)
 		submit_page(page, bh_arr, cnt);
 
-	if (mp)
-		cluster_write(inode, page->index + 1, mp, startio, unmapped);
+	if (iomp)
+		cluster_write(inode, page->index + 1, iomp, startio, unmapped);
 
 	return page_dirty;
 
@@ -849,7 +847,7 @@ linvfs_get_block_core(
 	bmapi_flags_t		flags)
 {
 	vnode_t			*vp = LINVFS_GET_VP(inode);
-	page_buf_bmap_t		pbmap;
+	xfs_iomap_t		iomap;
 	int			retpbbm = 1;
 	int			error;
 	ssize_t			size;
@@ -866,32 +864,32 @@ linvfs_get_block_core(
 		size = 1 << inode->i_blkbits;
 
 	VOP_BMAP(vp, offset, size,
-		create ? flags : BMAP_READ, &pbmap, &retpbbm, error);
+		create ? flags : BMAPI_READ, &iomap, &retpbbm, error);
 	if (error)
 		return -error;
 
 	if (retpbbm == 0)
 		return 0;
 
-	if (pbmap.pbm_bn != PAGE_BUF_DADDR_NULL) {
-		page_buf_daddr_t	bn;
+	if (iomap.iomap_bn != IOMAP_DADDR_NULL) {
+		xfs_daddr_t		bn;
 		loff_t			delta;
 
 		/* For unwritten extents do not report a disk address on
 		 * the read case.
 		 */
-		if (create || ((pbmap.pbm_flags & PBMF_UNWRITTEN) == 0)) {
-			delta = offset - pbmap.pbm_offset;
+		if (create || ((iomap.iomap_flags & IOMAP_UNWRITTEN) == 0)) {
+			delta = offset - iomap.iomap_offset;
 			delta >>= inode->i_blkbits;
 
-			bn = pbmap.pbm_bn >> (inode->i_blkbits - BBSHIFT);
+			bn = iomap.iomap_bn >> (inode->i_blkbits - BBSHIFT);
 			bn += delta;
 
 			bh_result->b_blocknr = bn;
-			bh_result->b_bdev = pbmap.pbm_target->pbr_bdev;
+			bh_result->b_bdev = iomap.iomap_target->pbr_bdev;
 			set_buffer_mapped(bh_result);
 		}
-		if (pbmap.pbm_flags & PBMF_UNWRITTEN) {
+		if (iomap.iomap_flags & IOMAP_UNWRITTEN) {
 			if (create) {
 				if (direct)
 					bh_result->b_private = inode;
@@ -902,29 +900,32 @@ linvfs_get_block_core(
 		}
 	}
 
+	/* If this is a realtime file, data might be on a new device */
+	bh_result->b_bdev = iomap.iomap_target->pbr_bdev;
+
 	/* If we previously allocated a block out beyond eof and
 	 * we are now coming back to use it then we will need to
 	 * flag it as new even if it has a disk address.
 	 */
 	if (create &&
 	    ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) ||
-	     (offset >= i_size_read(inode)) || (pbmap.pbm_flags & PBMF_NEW))) {
+	     (offset >= i_size_read(inode)) || (iomap.iomap_flags & IOMAP_NEW))) {
 		set_buffer_new(bh_result);
 	}
 
-	if (pbmap.pbm_flags & PBMF_DELAY) {
+	if (iomap.iomap_flags & IOMAP_DELAY) {
 		if (unlikely(direct))
 			BUG();
 		if (create) {
 			set_buffer_mapped(bh_result);
 			set_buffer_uptodate(bh_result);
 		}
-		bh_result->b_bdev = pbmap.pbm_target->pbr_bdev;
+		bh_result->b_bdev = iomap.iomap_target->pbr_bdev;
 		set_buffer_delay(bh_result);
 	}
 
 	if (blocks) {
-		size = (pbmap.pbm_bsize - pbmap.pbm_delta); 
+		size = (iomap.iomap_bsize - iomap.iomap_delta); 
 		bh_result->b_size = min_t(ssize_t, size, blocks << inode->i_blkbits);
 	}
 
@@ -939,7 +940,7 @@ linvfs_get_block(
 	int			create)
 {
 	return linvfs_get_block_core(inode, iblock, 0, bh_result,
-					create, 0, BMAP_WRITE);
+					create, 0, BMAPI_WRITE);
 }
 
 STATIC int
@@ -950,7 +951,7 @@ linvfs_get_block_sync(
 	int			create)
 {
 	return linvfs_get_block_core(inode, iblock, 0, bh_result,
-					create, 0, BMAP_SYNC|BMAP_WRITE);
+					create, 0, BMAPI_SYNC|BMAPI_WRITE);
 }
 
 STATIC int
@@ -962,7 +963,7 @@ linvfs_get_blocks_direct(
 	int			create)
 {
 	return linvfs_get_block_core(inode, iblock, max_blocks, bh_result,
-					create, 1, BMAP_WRITE|BMAP_DIRECT);
+					create, 1, BMAPI_WRITE|BMAPI_DIRECT);
 }
 
 STATIC int
@@ -974,17 +975,17 @@ linvfs_direct_IO(
 	unsigned long		nr_segs)
 {
 	struct file	*file = iocb->ki_filp;
-	struct inode	*inode = file->f_dentry->d_inode->i_mapping->host;
+	struct inode	*inode = file->f_mapping->host;
 	vnode_t		*vp = LINVFS_GET_VP(inode);
-	page_buf_bmap_t	pbmap;
+	xfs_iomap_t	iomap;
 	int		maps = 1;
 	int		error;
 
-	VOP_BMAP(vp, offset, 0, BMAP_DEVICE, &pbmap, &maps, error);
+	VOP_BMAP(vp, offset, 0, BMAPI_DEVICE, &iomap, &maps, error);
 	if (error)
 		return -error;
 
-        return blockdev_direct_IO(rw, iocb, inode, pbmap.pbm_target->pbr_bdev,
+	return blockdev_direct_IO(rw, iocb, inode, iomap.iomap_target->pbr_bdev,
 		iov, offset, nr_segs,
 		linvfs_get_blocks_direct,
 		linvfs_unwritten_convert_direct);
diff -puN fs/xfs/linux/xfs_file.c~linus fs/xfs/linux/xfs_file.c
--- 25/fs/xfs/linux/xfs_file.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/linux/xfs_file.c	2004-01-19 22:17:24.000000000 -0800
@@ -112,7 +112,7 @@ __linvfs_write(
 {
 	struct iovec	iov = {(void *)buf, count};
 	struct file	*file = iocb->ki_filp;
-	struct inode	*inode = file->f_dentry->d_inode->i_mapping->host;
+	struct inode	*inode = file->f_mapping->host;
 	vnode_t		*vp = LINVFS_GET_VP(inode);
 	int		error;
 
@@ -160,7 +160,7 @@ __linvfs_readv(
 	unsigned long		nr_segs,
 	loff_t			*ppos)
 {
-	struct inode	*inode = file->f_dentry->d_inode->i_mapping->host;
+	struct inode	*inode = file->f_mapping->host;
 	vnode_t		*vp = LINVFS_GET_VP(inode);
 	struct		kiocb kiocb;
 	int		error;
@@ -207,7 +207,7 @@ __linvfs_writev(
 	unsigned long		nr_segs,
 	loff_t			*ppos)
 {
-	struct inode	*inode = file->f_dentry->d_inode->i_mapping->host;
+	struct inode	*inode = file->f_mapping->host;
 	vnode_t		*vp = LINVFS_GET_VP(inode);
 	struct		kiocb kiocb;
 	int		error;
diff -puN fs/xfs/linux/xfs_globals.c~linus fs/xfs/linux/xfs_globals.c
--- 25/fs/xfs/linux/xfs_globals.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/linux/xfs_globals.c	2004-01-19 22:17:24.000000000 -0800
@@ -36,9 +36,57 @@
  */
 
 #include "xfs.h"
+
+#include "xfs_fs.h"
+#include "xfs_buf.h"
+#include "xfs_inum.h"
+#include "xfs_log.h"
+#include "xfs_clnt.h"
+#include "xfs_trans.h"
+#include "xfs_sb.h"
+#include "xfs_ag.h"
+#include "xfs_dir.h"
+#include "xfs_dir2.h"
+#include "xfs_imap.h"
+#include "xfs_alloc.h"
+#include "xfs_dmapi.h"
+#include "xfs_quota.h"
+#include "xfs_mount.h"
+#include "xfs_alloc_btree.h"
 #include "xfs_bmap_btree.h"
+#include "xfs_ialloc_btree.h"
+#include "xfs_btree.h"
+#include "xfs_ialloc.h"
+#include "xfs_attr_sf.h"
+#include "xfs_dir_sf.h"
+#include "xfs_dir2_sf.h"
+#include "xfs_dinode.h"
+#include "xfs_inode.h"
+#include "xfs_bmap.h"
 #include "xfs_bit.h"
+#include "xfs_rtalloc.h"
+#include "xfs_error.h"
+#include "xfs_itable.h"
 #include "xfs_rw.h"
+#include "xfs_da_btree.h"
+#include "xfs_dir_leaf.h"
+#include "xfs_dir2_data.h"
+#include "xfs_dir2_leaf.h"
+#include "xfs_dir2_block.h"
+#include "xfs_dir2_node.h"
+#include "xfs_dir2_trace.h"
+#include "xfs_acl.h"
+#include "xfs_cap.h"
+#include "xfs_mac.h"
+#include "xfs_attr.h"
+#include "xfs_attr_leaf.h"
+#include "xfs_inode_item.h"
+#include "xfs_buf_item.h"
+#include "xfs_extfree_item.h"
+#include "xfs_log_priv.h"
+#include "xfs_trans_priv.h"
+#include "xfs_trans_space.h"
+#include "xfs_utils.h"
 
 /*
  * System memory size - used to scale certain data structures in XFS.
@@ -69,10 +117,34 @@ xfs_param_t xfs_params = {
  */
 cred_t sys_cred_val, *sys_cred = &sys_cred_val;
 
-/* Export XFS symbols used by xfsidbg */
+/*
+ * Export symbols used for XFS debugging
+ */
 EXPORT_SYMBOL(xfs_next_bit);
 EXPORT_SYMBOL(xfs_contig_bits);
 EXPORT_SYMBOL(xfs_bmbt_get_all);
 #if ARCH_CONVERT != ARCH_NOCONVERT
 EXPORT_SYMBOL(xfs_bmbt_disk_get_all);
 #endif
+
+/*
+ * Export symbols used for XFS tracing
+ */
+#ifdef XFS_ALLOC_TRACE
+EXPORT_SYMBOL(xfs_alloc_trace_buf);
+#endif
+#ifdef XFS_BMAP_TRACE
+EXPORT_SYMBOL(xfs_bmap_trace_buf);
+#endif
+#ifdef XFS_BMBT_TRACE
+EXPORT_SYMBOL(xfs_bmbt_trace_buf);
+#endif
+#ifdef XFS_ATTR_TRACE
+EXPORT_SYMBOL(xfs_attr_trace_buf);
+#endif  
+#ifdef XFS_DIR2_TRACE
+EXPORT_SYMBOL(xfs_dir2_trace_buf);
+#endif   
+#ifdef XFS_DIR_TRACE
+EXPORT_SYMBOL(xfs_dir_trace_buf);
+#endif
diff -puN fs/xfs/linux/xfs_ioctl.c~linus fs/xfs/linux/xfs_ioctl.c
--- 25/fs/xfs/linux/xfs_ioctl.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/linux/xfs_ioctl.c	2004-01-19 22:17:24.000000000 -0800
@@ -943,7 +943,7 @@ xfs_ioc_bulkstat(
 					bulkreq.ubuffer, &done);
 		} else {
 			error = xfs_bulkstat(mp, NULL, &inlast, &count,
-				(bulkstat_one_pf)xfs_bulkstat_one,
+				(bulkstat_one_pf)xfs_bulkstat_one, NULL,
 				sizeof(xfs_bstat_t), bulkreq.ubuffer,
 				BULKSTAT_FG_QUICK, &done);
 		}
diff -puN fs/xfs/linux/xfs_iomap.c~linus fs/xfs/linux/xfs_iomap.c
--- 25/fs/xfs/linux/xfs_iomap.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/linux/xfs_iomap.c	2004-01-19 22:17:24.000000000 -0800
@@ -67,6 +67,7 @@
 #include "xfs_buf_item.h"
 #include "xfs_trans_space.h"
 #include "xfs_utils.h"
+#include "xfs_iomap.h"
 
 #define XFS_WRITEIO_ALIGN(mp,off)	(((off) >> mp->m_writeio_log) \
 						<< mp->m_writeio_log)
@@ -74,14 +75,14 @@
 #define XFS_WRITE_IMAPS		XFS_BMAP_MAX_NMAP
 
 STATIC int
-_xfs_imap_to_bmap(
+xfs_imap_to_bmap(
 	xfs_iocore_t	*io,
 	xfs_off_t	offset,
-	int		new,
 	xfs_bmbt_irec_t *imap,
-	page_buf_bmap_t	*pbmapp,
+	xfs_iomap_t	*iomapp,
 	int		imaps,			/* Number of imap entries */
-	int		pbmaps)			/* Number of pbmap entries */
+	int		iomaps,			/* Number of iomap entries */
+	int		flags)
 {
 	xfs_mount_t	*mp;
 	xfs_fsize_t	nisize;
@@ -93,35 +94,32 @@ _xfs_imap_to_bmap(
 	if (io->io_new_size > nisize)
 		nisize = io->io_new_size;
 
-	for (pbm = 0; imaps && pbm < pbmaps; imaps--, pbmapp++, imap++, pbm++) {
-		pbmapp->pbm_target = io->io_flags & XFS_IOCORE_RT ?
+	for (pbm = 0; imaps && pbm < iomaps; imaps--, iomapp++, imap++, pbm++) {
+		iomapp->iomap_target = io->io_flags & XFS_IOCORE_RT ?
 			mp->m_rtdev_targp : mp->m_ddev_targp;
-		pbmapp->pbm_offset = XFS_FSB_TO_B(mp, imap->br_startoff);
-		pbmapp->pbm_delta = offset - pbmapp->pbm_offset;
-		pbmapp->pbm_bsize = XFS_FSB_TO_B(mp, imap->br_blockcount);
-		pbmapp->pbm_flags = 0;
+		iomapp->iomap_offset = XFS_FSB_TO_B(mp, imap->br_startoff);
+		iomapp->iomap_delta = offset - iomapp->iomap_offset;
+		iomapp->iomap_bsize = XFS_FSB_TO_B(mp, imap->br_blockcount);
+		iomapp->iomap_flags = flags;
 
 		start_block = imap->br_startblock;
 		if (start_block == HOLESTARTBLOCK) {
-			pbmapp->pbm_bn = PAGE_BUF_DADDR_NULL;
-			pbmapp->pbm_flags = PBMF_HOLE;
+			iomapp->iomap_bn = IOMAP_DADDR_NULL;
+			iomapp->iomap_flags = IOMAP_HOLE;
 		} else if (start_block == DELAYSTARTBLOCK) {
-			pbmapp->pbm_bn = PAGE_BUF_DADDR_NULL;
-			pbmapp->pbm_flags = PBMF_DELAY;
+			iomapp->iomap_bn = IOMAP_DADDR_NULL;
+			iomapp->iomap_flags = IOMAP_DELAY;
 		} else {
-			pbmapp->pbm_bn = XFS_FSB_TO_DB_IO(io, start_block);
+			iomapp->iomap_bn = XFS_FSB_TO_DB_IO(io, start_block);
 			if (ISUNWRITTEN(imap))
-				pbmapp->pbm_flags |= PBMF_UNWRITTEN;
+				iomapp->iomap_flags |= IOMAP_UNWRITTEN;
 		}
 
-		if ((pbmapp->pbm_offset + pbmapp->pbm_bsize) >= nisize) {
-			pbmapp->pbm_flags |= PBMF_EOF;
+		if ((iomapp->iomap_offset + iomapp->iomap_bsize) >= nisize) {
+			iomapp->iomap_flags |= IOMAP_EOF;
 		}
 
-		if (new)
-			pbmapp->pbm_flags |= PBMF_NEW;
-
-		offset += pbmapp->pbm_bsize - pbmapp->pbm_delta;
+		offset += iomapp->iomap_bsize - iomapp->iomap_delta;
 	}
 	return pbm;	/* Return the number filled */
 }
@@ -132,54 +130,54 @@ xfs_iomap(
 	xfs_off_t	offset,
 	ssize_t		count,
 	int		flags,
-	page_buf_bmap_t	*pbmapp,
-	int		*npbmaps)
+	xfs_iomap_t	*iomapp,
+	int		*niomaps)
 {
 	xfs_mount_t	*mp = io->io_mount;
 	xfs_fileoff_t	offset_fsb, end_fsb;
 	int		error = 0;
-	int		new = 0;
 	int		lockmode = 0;
 	xfs_bmbt_irec_t	imap;
 	int		nimaps = 1;
-	int		bmap_flags = 0;
+	int		bmapi_flags = 0;
+	int		iomap_flags = 0;
 
 	if (XFS_FORCED_SHUTDOWN(mp))
-		return -XFS_ERROR(EIO);
+		return XFS_ERROR(EIO);
 
 	switch (flags &
-		(BMAP_READ | BMAP_WRITE | BMAP_ALLOCATE |
-		 BMAP_UNWRITTEN | BMAP_DEVICE)) {
-	case BMAP_READ:
+		(BMAPI_READ | BMAPI_WRITE | BMAPI_ALLOCATE |
+		 BMAPI_UNWRITTEN | BMAPI_DEVICE)) {
+	case BMAPI_READ:
 		lockmode = XFS_LCK_MAP_SHARED(mp, io);
-		bmap_flags = XFS_BMAPI_ENTIRE;
-		if (flags & BMAP_IGNSTATE)
-			bmap_flags |= XFS_BMAPI_IGSTATE;
+		bmapi_flags = XFS_BMAPI_ENTIRE;
+		if (flags & BMAPI_IGNSTATE)
+			bmapi_flags |= XFS_BMAPI_IGSTATE;
 		break;
-	case BMAP_WRITE:
+	case BMAPI_WRITE:
 		lockmode = XFS_ILOCK_EXCL|XFS_EXTSIZE_WR;
-		bmap_flags = 0;
+		bmapi_flags = 0;
 		XFS_ILOCK(mp, io, lockmode);
 		break;
-	case BMAP_ALLOCATE:
+	case BMAPI_ALLOCATE:
 		lockmode = XFS_ILOCK_SHARED|XFS_EXTSIZE_RD;
-		bmap_flags = XFS_BMAPI_ENTIRE;
+		bmapi_flags = XFS_BMAPI_ENTIRE;
 		/* Attempt non-blocking lock */
-		if (flags & BMAP_TRYLOCK) {
+		if (flags & BMAPI_TRYLOCK) {
 			if (!XFS_ILOCK_NOWAIT(mp, io, lockmode))
 				return XFS_ERROR(EAGAIN);
 		} else {
 			XFS_ILOCK(mp, io, lockmode);
 		}
 		break;
-	case BMAP_UNWRITTEN:
+	case BMAPI_UNWRITTEN:
 		goto phase2;
-	case BMAP_DEVICE:
+	case BMAPI_DEVICE:
 		lockmode = XFS_LCK_MAP_SHARED(mp, io);
-		pbmapp->pbm_target = io->io_flags & XFS_IOCORE_RT ?
+		iomapp->iomap_target = io->io_flags & XFS_IOCORE_RT ?
 			mp->m_rtdev_targp : mp->m_ddev_targp;
 		error = 0;
-		*npbmaps = 1;
+		*niomaps = 1;
 		goto out;
 	default:
 		BUG();
@@ -192,30 +190,30 @@ xfs_iomap(
 	offset_fsb = XFS_B_TO_FSBT(mp, offset);
 
 	error = XFS_BMAPI(mp, NULL, io, offset_fsb,
-			(xfs_filblks_t)(end_fsb - offset_fsb) ,
-			bmap_flags,  NULL, 0, &imap,
+			(xfs_filblks_t)(end_fsb - offset_fsb),
+			bmapi_flags,  NULL, 0, &imap,
 			&nimaps, NULL);
 
 	if (error)
 		goto out;
 
 phase2:
-	switch (flags & (BMAP_WRITE|BMAP_ALLOCATE|BMAP_UNWRITTEN)) {
-	case BMAP_WRITE:
+	switch (flags & (BMAPI_WRITE|BMAPI_ALLOCATE|BMAPI_UNWRITTEN)) {
+	case BMAPI_WRITE:
 		/* If we found an extent, return it */
 		if (nimaps && (imap.br_startblock != HOLESTARTBLOCK))
 			break;
 
-		if (flags & (BMAP_DIRECT|BMAP_MMAP)) {
+		if (flags & (BMAPI_DIRECT|BMAPI_MMAP)) {
 			error = XFS_IOMAP_WRITE_DIRECT(mp, io, offset,
 					count, flags, &imap, &nimaps, nimaps);
 		} else {
 			error = XFS_IOMAP_WRITE_DELAY(mp, io, offset, count,
 					flags, &imap, &nimaps);
 		}
-		new = 1;
+		iomap_flags = IOMAP_NEW;
 		break;
-	case BMAP_ALLOCATE:
+	case BMAPI_ALLOCATE:
 		/* If we found an extent, return it */
 		XFS_IUNLOCK(mp, io, lockmode);
 		lockmode = 0;
@@ -225,7 +223,7 @@ phase2:
 
 		error = XFS_IOMAP_WRITE_ALLOCATE(mp, io, &imap, &nimaps);
 		break;
-	case BMAP_UNWRITTEN:
+	case BMAPI_UNWRITTEN:
 		lockmode = 0;
 		error = XFS_IOMAP_WRITE_UNWRITTEN(mp, io, offset, count);
 		nimaps = 0;
@@ -233,10 +231,10 @@ phase2:
 	}
 
 	if (nimaps) {
-		*npbmaps = _xfs_imap_to_bmap(io, offset, new, &imap,
-					pbmapp, nimaps, *npbmaps);
-	} else if (npbmaps) {
-		*npbmaps = 0;
+		*niomaps = xfs_imap_to_bmap(io, offset, &imap,
+					iomapp, nimaps, *niomaps, iomap_flags);
+	} else if (niomaps) {
+		*niomaps = 0;
 	}
 
 out:
@@ -251,29 +249,25 @@ xfs_flush_space(
 	int		*fsynced,
 	int		*ioflags)
 {
-	vnode_t		*vp = XFS_ITOV(ip);
-
 	switch (*fsynced) {
 	case 0:
 		if (ip->i_delayed_blks) {
 			xfs_iunlock(ip, XFS_ILOCK_EXCL);
-			filemap_fdatawrite(LINVFS_GET_IP(vp)->i_mapping);
+			xfs_flush_inode(ip);
 			xfs_ilock(ip, XFS_ILOCK_EXCL);
 			*fsynced = 1;
 		} else {
-			*ioflags |= BMAP_SYNC;
+			*ioflags |= BMAPI_SYNC;
 			*fsynced = 2;
 		}
 		return 0;
 	case 1:
 		*fsynced = 2;
-		*ioflags |= BMAP_SYNC;
+		*ioflags |= BMAPI_SYNC;
 		return 0;
 	case 2:
 		xfs_iunlock(ip, XFS_ILOCK_EXCL);
-		sync_blockdev(vp->v_vfsp->vfs_super->s_bdev);
-		xfs_log_force(ip->i_mount, (xfs_lsn_t)0,
-						XFS_LOG_FORCE|XFS_LOG_SYNC);
+		xfs_flush_device(ip);
 		xfs_ilock(ip, XFS_ILOCK_EXCL);
 		*fsynced = 3;
 		return 0;
@@ -400,7 +394,7 @@ xfs_iomap_write_direct(
 	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
 	xfs_trans_ihold(tp, ip);
 
-	if (!(flags & BMAP_MMAP) && (offset < ip->i_d.di_size || rt))
+	if (!(flags & BMAPI_MMAP) && (offset < ip->i_d.di_size || rt))
 		bmapi_flag |= XFS_BMAPI_PREALLOC;
 
 	/*
@@ -499,7 +493,7 @@ retry:
 	 * We don't bother with this for sync writes, because we need
 	 * to minimize the amount we write for good performance.
 	 */
-	if (!(ioflag & BMAP_SYNC) && ((offset + count) > ip->i_d.di_size)) {
+	if (!(ioflag & BMAPI_SYNC) && ((offset + count) > ip->i_d.di_size)) {
 		xfs_off_t	aligned_offset;
 		unsigned int	iosize;
 		xfs_fileoff_t	ioalign;
diff -puN fs/xfs/linux/xfs_iops.c~linus fs/xfs/linux/xfs_iops.c
--- 25/fs/xfs/linux/xfs_iops.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/linux/xfs_iops.c	2004-01-19 22:17:24.000000000 -0800
@@ -110,7 +110,7 @@ linvfs_mknod(
 	vattr_t		va;
 	vnode_t		*vp = NULL, *dvp = LINVFS_GET_VP(dir);
 	xfs_acl_t	*default_acl = NULL;
-	xattr_exists_t	test_default_acl = _ACL_DEFAULT_EXISTS;
+	attrexists_t	test_default_acl = _ACL_DEFAULT_EXISTS;
 	int		error;
 
 	/*
@@ -552,61 +552,6 @@ linvfs_truncate(
 	block_truncate_page(inode->i_mapping, inode->i_size, linvfs_get_block);
 }
 
-
-
-/*
- * Extended attributes interfaces
- */
-
-#define SYSTEM_NAME	"system."	/* VFS shared names/values */
-#define ROOT_NAME	"trusted."	/* root's own names/values */
-#define USER_NAME	"user."		/* user's own names/values */
-STATIC xattr_namespace_t xfs_namespace_array[] = {
-	{ .name= SYSTEM_NAME,	.namelen= sizeof(SYSTEM_NAME)-1,.exists= NULL },
-	{ .name= ROOT_NAME,	.namelen= sizeof(ROOT_NAME)-1,	.exists= NULL },
-	{ .name= USER_NAME,	.namelen= sizeof(USER_NAME)-1,	.exists= NULL },
-	{ .name= NULL }
-};
-xattr_namespace_t *xfs_namespaces = &xfs_namespace_array[0];
-
-#define POSIXACL_ACCESS		"posix_acl_access"
-#define POSIXACL_ACCESS_SIZE	(sizeof(POSIXACL_ACCESS)-1)
-#define POSIXACL_DEFAULT	"posix_acl_default"
-#define POSIXACL_DEFAULT_SIZE	(sizeof(POSIXACL_DEFAULT)-1)
-#define POSIXCAP		"posix_capabilities"
-#define POSIXCAP_SIZE		(sizeof(POSIXCAP)-1)
-#define POSIXMAC		"posix_mac"
-#define POSIXMAC_SIZE		(sizeof(POSIXMAC)-1)
-STATIC xattr_namespace_t sys_namespace_array[] = {
-	{ .name= POSIXACL_ACCESS,
-		.namelen= POSIXACL_ACCESS_SIZE,	 .exists= _ACL_ACCESS_EXISTS },
-	{ .name= POSIXACL_DEFAULT,
-		.namelen= POSIXACL_DEFAULT_SIZE, .exists= _ACL_DEFAULT_EXISTS },
-	{ .name= POSIXCAP,
-		.namelen= POSIXCAP_SIZE,	 .exists= _CAP_EXISTS },
-	{ .name= POSIXMAC,
-		.namelen= POSIXMAC_SIZE,	 .exists= _MAC_EXISTS },
-	{ .name= NULL }
-};
-
-/*
- * Some checks to prevent people abusing EAs to get over quota:
- * - Don't allow modifying user EAs on devices/symlinks;
- * - Don't allow modifying user EAs if sticky bit set;
- */
-STATIC int
-capable_user_xattr(
-	struct inode	*inode)
-{
-	if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode) &&
-	    !capable(CAP_SYS_ADMIN))
-		return 0;
-	if (S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX) &&
-	    (current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
-		return 0;
-	return 1;
-}
-
 STATIC int
 linvfs_setxattr(
 	struct dentry	*dentry,
@@ -615,59 +560,27 @@ linvfs_setxattr(
 	size_t		size,
 	int		flags)
 {
-	struct inode	*inode = dentry->d_inode;
-	vnode_t		*vp = LINVFS_GET_VP(inode);
-	char		*p = (char *)name;
+	vnode_t		*vp = LINVFS_GET_VP(dentry->d_inode);
+	char		*attr = (char *)name;
+	attrnames_t	*namesp;
 	int		xflags = 0;
 	int		error;
 
-	if (strncmp(name, xfs_namespaces[SYSTEM_NAMES].name,
-			xfs_namespaces[SYSTEM_NAMES].namelen) == 0) {
-		error = -EINVAL;
-		if (flags & XATTR_CREATE)
-			 return error;
-		error = -EOPNOTSUPP;
-		p += xfs_namespaces[SYSTEM_NAMES].namelen;
-		if (strcmp(p, POSIXACL_ACCESS) == 0)
-			error = xfs_acl_vset(vp, (void *) data, size,
-						_ACL_TYPE_ACCESS);
-		else if (strcmp(p, POSIXACL_DEFAULT) == 0)
-			error = xfs_acl_vset(vp, (void *) data, size,
-						_ACL_TYPE_DEFAULT);
-		else if (strcmp(p, POSIXCAP) == 0)
-			error = xfs_cap_vset(vp, (void *) data, size);
-		if (!error)
-			error = vn_revalidate(vp);
+	namesp = attr_lookup_namespace(attr, attr_namespaces, ATTR_NAMECOUNT);
+	if (!namesp)
+		return -EOPNOTSUPP;
+	attr += namesp->attr_namelen;
+	error = namesp->attr_capable(vp, NULL);
+	if (error)
 		return error;
-	}
-
-	if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
-		return -EPERM;
 
 	/* Convert Linux syscall to XFS internal ATTR flags */
 	if (flags & XATTR_CREATE)
 		xflags |= ATTR_CREATE;
 	if (flags & XATTR_REPLACE)
 		xflags |= ATTR_REPLACE;
-
-	if (strncmp(name, xfs_namespaces[ROOT_NAMES].name,
-			xfs_namespaces[ROOT_NAMES].namelen) == 0) {
-		if (!capable(CAP_SYS_ADMIN))
-			return -EPERM;
-		xflags |= ATTR_ROOT;
-		p += xfs_namespaces[ROOT_NAMES].namelen;
-		VOP_ATTR_SET(vp, p, (void *) data, size, xflags, NULL, error);
-		return -error;
-	}
-	if (strncmp(name, xfs_namespaces[USER_NAMES].name,
-			xfs_namespaces[USER_NAMES].namelen) == 0) {
-		if (!capable_user_xattr(inode))
-			return -EPERM;
-		p += xfs_namespaces[USER_NAMES].namelen;
-		VOP_ATTR_SET(vp, p, (void *) data, size, xflags, NULL, error);
-		return -error;
-	}
-	return -EOPNOTSUPP;
+	xflags |= namesp->attr_flag;
+	return namesp->attr_set(vp, attr, (void *)data, size, xflags);
 }
 
 STATIC ssize_t
@@ -677,53 +590,27 @@ linvfs_getxattr(
 	void		*data,
 	size_t		size)
 {
-	struct inode	*inode = dentry->d_inode;
-	vnode_t		*vp = LINVFS_GET_VP(inode);
-	char		*p = (char *)name;
+	vnode_t		*vp = LINVFS_GET_VP(dentry->d_inode);
+	char		*attr = (char *)name;
+	attrnames_t	*namesp;
 	int		xflags = 0;
 	ssize_t		error;
 
-	if (strncmp(name, xfs_namespaces[SYSTEM_NAMES].name,
-			xfs_namespaces[SYSTEM_NAMES].namelen) == 0) {
-		error = -EOPNOTSUPP;
-		p += xfs_namespaces[SYSTEM_NAMES].namelen;
-		if (strcmp(p, POSIXACL_ACCESS) == 0)
-			error = xfs_acl_vget(vp, data, size, _ACL_TYPE_ACCESS);
-		else if (strcmp(p, POSIXACL_DEFAULT) == 0)
-			error = xfs_acl_vget(vp, data, size, _ACL_TYPE_DEFAULT);
-		else if (strcmp(p, POSIXCAP) == 0)
-			error = xfs_cap_vget(vp, data, size);
+	namesp = attr_lookup_namespace(attr, attr_namespaces, ATTR_NAMECOUNT);
+	if (!namesp)
+		return -EOPNOTSUPP;
+	attr += namesp->attr_namelen;
+	error = namesp->attr_capable(vp, NULL);
+	if (error)
 		return error;
-	}
 
 	/* Convert Linux syscall to XFS internal ATTR flags */
 	if (!size) {
 		xflags |= ATTR_KERNOVAL;
 		data = NULL;
 	}
-
-	if (strncmp(name, xfs_namespaces[ROOT_NAMES].name,
-			xfs_namespaces[ROOT_NAMES].namelen) == 0) {
-		if (!capable(CAP_SYS_ADMIN))
-			return -EPERM;
-		xflags |= ATTR_ROOT;
-		p += xfs_namespaces[ROOT_NAMES].namelen;
-		VOP_ATTR_GET(vp, p, data, (int *)&size, xflags, NULL, error);
-		if (!error)
-			error = -size;
-		return -error;
-	}
-	if (strncmp(name, xfs_namespaces[USER_NAMES].name,
-			xfs_namespaces[USER_NAMES].namelen) == 0) {
-		p += xfs_namespaces[USER_NAMES].namelen;
-		if (!capable_user_xattr(inode))
-			return -EPERM;
-		VOP_ATTR_GET(vp, p, data, (int *)&size, xflags, NULL, error);
-		if (!error)
-			error = -size;
-		return -error;
-	}
-	return -EOPNOTSUPP;
+	xflags |= namesp->attr_flag;
+	return namesp->attr_get(vp, attr, (void *)data, size, xflags);
 }
 
 STATIC ssize_t
@@ -732,40 +619,18 @@ linvfs_listxattr(
 	char			*data,
 	size_t			size)
 {
-	attrlist_cursor_kern_t	cursor;
-	xattr_namespace_t	*sys;
 	vnode_t			*vp = LINVFS_GET_VP(dentry->d_inode);
-	char			*k = data;
-	int			xflags = ATTR_KERNAMELS;
-	int			result = 0;
-	ssize_t			error;
+	int			error, xflags = ATTR_KERNAMELS;
+	ssize_t			result;
 
 	if (!size)
 		xflags |= ATTR_KERNOVAL;
 	if (capable(CAP_SYS_ADMIN))
 		xflags |= ATTR_KERNFULLS;
 
-	memset(&cursor, 0, sizeof(cursor));
-	VOP_ATTR_LIST(vp, data, size, xflags, &cursor, NULL, error);
-	if (error > 0)
-		return -error;
-	result += -error;
-
-	k += result;		/* advance start of our buffer */
-	for (sys = &sys_namespace_array[0]; sys->name != NULL; sys++) {
-		if (sys->exists == NULL || !sys->exists(vp))
-			continue;
-		result += xfs_namespaces[SYSTEM_NAMES].namelen;
-		result += sys->namelen + 1;
-		if (size) {
-			if (result > size)
-				return -ERANGE;
-			strcpy(k, xfs_namespaces[SYSTEM_NAMES].name);
-			k += xfs_namespaces[SYSTEM_NAMES].namelen;
-			strcpy(k, sys->name);
-			k += sys->namelen + 1;
-		}
-	}
+	error = attr_generic_list(vp, data, size, xflags, &result);
+	if (error < 0)
+		return error;
 	return result;
 }
 
@@ -774,51 +639,25 @@ linvfs_removexattr(
 	struct dentry	*dentry,
 	const char	*name)
 {
-	struct inode	*inode = dentry->d_inode;
-	vnode_t		*vp = LINVFS_GET_VP(inode);
-	char		*p = (char *)name;
+	vnode_t		*vp = LINVFS_GET_VP(dentry->d_inode);
+	char		*attr = (char *)name;
+	attrnames_t	*namesp;
 	int		xflags = 0;
 	int		error;
 
-	if (strncmp(name, xfs_namespaces[SYSTEM_NAMES].name,
-			xfs_namespaces[SYSTEM_NAMES].namelen) == 0) {
-		error = -EOPNOTSUPP;
-		p += xfs_namespaces[SYSTEM_NAMES].namelen;
-		if (strcmp(p, POSIXACL_ACCESS) == 0)
-			error = xfs_acl_vremove(vp, _ACL_TYPE_ACCESS);
-		else if (strcmp(p, POSIXACL_DEFAULT) == 0)
-			error = xfs_acl_vremove(vp, _ACL_TYPE_DEFAULT);
-		else if (strcmp(p, POSIXCAP) == 0)
-			error = xfs_cap_vremove(vp);
+	namesp = attr_lookup_namespace(attr, attr_namespaces, ATTR_NAMECOUNT);
+	if (!namesp)
+		return -EOPNOTSUPP;
+	attr += namesp->attr_namelen;
+	error = namesp->attr_capable(vp, NULL);
+	if (error)
 		return error;
-	}
-
-        if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
-		return -EPERM;
-
-	if (strncmp(name, xfs_namespaces[ROOT_NAMES].name,
-			xfs_namespaces[ROOT_NAMES].namelen) == 0) {
-		if (!capable(CAP_SYS_ADMIN))
-			return -EPERM;
-		xflags |= ATTR_ROOT;
-		p += xfs_namespaces[ROOT_NAMES].namelen;
-		VOP_ATTR_REMOVE(vp, p, xflags, NULL, error);
-		return -error;
-	}
-	if (strncmp(name, xfs_namespaces[USER_NAMES].name,
-			xfs_namespaces[USER_NAMES].namelen) == 0) {
-		p += xfs_namespaces[USER_NAMES].namelen;
-		if (!capable_user_xattr(inode))
-			return -EPERM;
-		VOP_ATTR_REMOVE(vp, p, xflags, NULL, error);
-		return -error;
-	}
-	return -EOPNOTSUPP;
+	xflags |= namesp->attr_flag;
+	return namesp->attr_remove(vp, attr, xflags);
 }
 
 
-struct inode_operations linvfs_file_inode_operations =
-{
+struct inode_operations linvfs_file_inode_operations = {
 	.permission		= linvfs_permission,
 	.truncate		= linvfs_truncate,
 	.getattr		= linvfs_getattr,
@@ -829,8 +668,7 @@ struct inode_operations linvfs_file_inod
 	.removexattr		= linvfs_removexattr,
 };
 
-struct inode_operations linvfs_dir_inode_operations =
-{
+struct inode_operations linvfs_dir_inode_operations = {
 	.create			= linvfs_create,
 	.lookup			= linvfs_lookup,
 	.link			= linvfs_link,
@@ -849,8 +687,7 @@ struct inode_operations linvfs_dir_inode
 	.removexattr		= linvfs_removexattr,
 };
 
-struct inode_operations linvfs_symlink_inode_operations =
-{
+struct inode_operations linvfs_symlink_inode_operations = {
 	.readlink		= linvfs_readlink,
 	.follow_link		= linvfs_follow_link,
 	.permission		= linvfs_permission,
diff -puN fs/xfs/linux/xfs_iops.h~linus fs/xfs/linux/xfs_iops.h
--- 25/fs/xfs/linux/xfs_iops.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/linux/xfs_iops.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -32,30 +32,6 @@
 #ifndef __XFS_IOPS_H__
 #define __XFS_IOPS_H__
 
-/*
- * Extended system attributes.
- * So far only POSIX ACLs are supported, but this will need to
- * grow in time (capabilities, mandatory access control, etc).
- */
-#define XFS_SYSTEM_NAMESPACE	SYSTEM_POSIXACL
-
-/*
- * Define a table of the namespaces XFS supports
- */
-typedef int (*xattr_exists_t)(vnode_t *);
-
-typedef struct xattr_namespace {
-	char		*name;
-	unsigned int	namelen;
-	xattr_exists_t	exists;
-} xattr_namespace_t;
-
-#define SYSTEM_NAMES	0
-#define ROOT_NAMES	1
-#define USER_NAMES	2
-extern struct xattr_namespace *xfs_namespaces;
-
-
 extern struct inode_operations linvfs_file_inode_operations;
 extern struct inode_operations linvfs_dir_inode_operations;
 extern struct inode_operations linvfs_symlink_inode_operations;
@@ -69,4 +45,7 @@ extern struct address_space_operations l
 extern int linvfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
 extern void linvfs_unwritten_done(struct buffer_head *, int);
 
+extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *,
+                        int, unsigned int, unsigned long);
+
 #endif /* __XFS_IOPS_H__ */
diff -puN fs/xfs/linux/xfs_linux.h~linus fs/xfs/linux/xfs_linux.h
--- 25/fs/xfs/linux/xfs_linux.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/linux/xfs_linux.h	2004-01-19 22:17:24.000000000 -0800
@@ -69,9 +69,11 @@
 
 #include <pagebuf/page_buf.h>
 
-#ifndef STATIC
-#define STATIC static
-#endif
+/*
+ * Feature macros (disable/enable)
+ */
+#undef  HAVE_REFCACHE	/* reference cache not needed for NFS in 2.6 */
+#define HAVE_SENDFILE	/* sendfile(2) exists in 2.6, but not in 2.4 */
 
 /*
  * State flag for unwritten extent buffers.
@@ -100,6 +102,11 @@ static inline void set_buffer_unwritten_
 #define xfs_inherit_nodump	xfs_params.inherit_nodump.val
 #define xfs_inherit_noatime	xfs_params.inherit_noatim.val
 
+#define current_cpu()		smp_processor_id()
+#define current_pid()		(current->pid)
+#define current_fsuid(cred)	(current->fsuid)
+#define current_fsgid(cred)	(current->fsgid)
+
 #define NBPP		PAGE_SIZE
 #define DPPSHFT		(PAGE_SHIFT - 9)
 #define NDPP		(1 << (PAGE_SHIFT - 9))
@@ -200,6 +207,11 @@ static inline void set_buffer_unwritten_
 #define howmany(x, y)	(((x)+((y)-1))/(y))
 #define roundup(x, y)	((((x)+((y)-1))/(y))*(y))
 
+static inline void xfs_stack_trace(void)
+{
+	dump_stack();
+}
+
 /* Move the kernel do_div definition off to one side */
 
 #if defined __i386__
diff -puN fs/xfs/linux/xfs_lrw.c~linus fs/xfs/linux/xfs_lrw.c
--- 25/fs/xfs/linux/xfs_lrw.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/linux/xfs_lrw.c	2004-01-19 22:17:24.000000000 -0800
@@ -71,10 +71,76 @@
 #include "xfs_inode_item.h"
 #include "xfs_buf_item.h"
 #include "xfs_utils.h"
+#include "xfs_iomap.h"
 
 #include <linux/capability.h>
 
 
+#if defined(XFS_RW_TRACE)
+void
+xfs_rw_enter_trace(
+	int			tag,
+	xfs_iocore_t		*io,
+	const struct iovec	*iovp,
+	size_t			segs,
+	loff_t			offset,
+	int			ioflags)
+{
+	xfs_inode_t	*ip = XFS_IO_INODE(io);
+
+	if (ip->i_rwtrace == NULL)
+		return;
+	ktrace_enter(ip->i_rwtrace,
+		(void *)(unsigned long)tag,
+		(void *)ip,
+		(void *)((unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff)),
+		(void *)((unsigned long)(ip->i_d.di_size & 0xffffffff)),
+		(void *)(__psint_t)iovp,
+		(void *)((unsigned long)segs),
+		(void *)((unsigned long)((offset >> 32) & 0xffffffff)),
+		(void *)((unsigned long)(offset & 0xffffffff)),
+		(void *)((unsigned long)ioflags),
+		(void *)((unsigned long)((io->io_new_size >> 32) & 0xffffffff)),
+		(void *)((unsigned long)(io->io_new_size & 0xffffffff)),
+		(void *)NULL,
+		(void *)NULL,
+		(void *)NULL,
+		(void *)NULL,
+		(void *)NULL);
+}
+
+void
+xfs_inval_cached_trace(
+	xfs_iocore_t	*io,
+	xfs_off_t	offset,
+	xfs_off_t	len,
+	xfs_off_t	first,
+	xfs_off_t	last)
+{
+	xfs_inode_t	*ip = XFS_IO_INODE(io);
+
+	if (ip->i_rwtrace == NULL)
+		return;
+	ktrace_enter(ip->i_rwtrace,
+		(void *)(__psint_t)XFS_INVAL_CACHED,
+		(void *)ip,
+		(void *)((unsigned long)((offset >> 32) & 0xffffffff)),
+		(void *)((unsigned long)(offset & 0xffffffff)),
+		(void *)((unsigned long)((len >> 32) & 0xffffffff)),
+		(void *)((unsigned long)(len & 0xffffffff)),
+		(void *)((unsigned long)((first >> 32) & 0xffffffff)),
+		(void *)((unsigned long)(first & 0xffffffff)),
+		(void *)((unsigned long)((last >> 32) & 0xffffffff)),
+		(void *)((unsigned long)(last & 0xffffffff)),
+		(void *)NULL,
+		(void *)NULL,
+		(void *)NULL,
+		(void *)NULL,
+		(void *)NULL,
+		(void *)NULL);
+}
+#endif
+
 /*
  *	xfs_iozero
  *
@@ -142,6 +208,59 @@ unlock:
 	return (-status);
 }
 
+/*
+ * xfs_inval_cached_pages
+ * 
+ * This routine is responsible for keeping direct I/O and buffered I/O
+ * somewhat coherent.  From here we make sure that we're at least
+ * temporarily holding the inode I/O lock exclusively and then call
+ * the page cache to flush and invalidate any cached pages.  If there
+ * are no cached pages this routine will be very quick.
+ */
+void
+xfs_inval_cached_pages(
+	vnode_t		*vp,
+	xfs_iocore_t	*io,
+	xfs_off_t	offset,
+	int		write,
+	int		relock)
+{
+	xfs_mount_t	*mp;
+
+	if (!VN_CACHED(vp)) {
+		return;
+	}
+
+	mp = io->io_mount;
+
+	/*
+	 * We need to get the I/O lock exclusively in order
+	 * to safely invalidate pages and mappings.
+	 */
+	if (relock) {
+		XFS_IUNLOCK(mp, io, XFS_IOLOCK_SHARED);
+		XFS_ILOCK(mp, io, XFS_IOLOCK_EXCL);
+	}
+
+	/* Writing beyond EOF creates a hole that must be zeroed */
+	if (write && (offset > XFS_SIZE(mp, io))) {
+		xfs_fsize_t	isize;
+
+		XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
+		isize = XFS_SIZE(mp, io);
+		if (offset > isize) {
+			xfs_zero_eof(vp, io, offset, isize, offset);
+		}
+		XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
+	}
+
+	xfs_inval_cached_trace(io, offset, -1, ctooff(offtoct(offset)), -1);
+	VOP_FLUSHINVAL_PAGES(vp, ctooff(offtoct(offset)), -1, FI_REMAPF_LOCKED);
+	if (relock) {
+		XFS_ILOCK_DEMOTE(mp, io, XFS_IOLOCK_EXCL);
+	}
+}
+
 ssize_t			/* bytes read, or (-)  error */
 xfs_read(
 	bhv_desc_t		*bdp,
@@ -684,9 +803,13 @@ start:
 
 retry:
 	if (ioflags & IO_ISDIRECT) {
-		xfs_inval_cached_pages(vp, &xip->i_iocore, *offset, 1, 1);
+		xfs_inval_cached_pages(vp, io, *offset, 1, 1);
+		xfs_rw_enter_trace(XFS_DIOWR_ENTER,
+				io, iovp, segs, *offset, ioflags);
+	} else {
+		xfs_rw_enter_trace(XFS_WRITE_ENTER,
+				io, iovp, segs, *offset, ioflags);
 	}
-
 	ret = generic_file_aio_write_nolock(iocb, iovp, segs, offset);
 
 	if ((ret == -ENOSPC) &&
@@ -702,7 +825,6 @@ retry:
 		xfs_rwlock(bdp, locktype);
 		*offset = xip->i_d.di_size;
 		goto retry;
-
 	}
 
 	if (*offset > xip->i_d.di_size) {
@@ -846,8 +968,8 @@ xfs_bmap(bhv_desc_t	*bdp,
 	xfs_off_t	offset,
 	ssize_t		count,
 	int		flags,
-	page_buf_bmap_t	*pbmapp,
-	int		*npbmaps)
+	xfs_iomap_t	*iomapp,
+	int		*niomaps)
 {
 	xfs_inode_t	*ip = XFS_BHVTOI(bdp);
 	xfs_iocore_t	*io = &ip->i_iocore;
@@ -856,7 +978,7 @@ xfs_bmap(bhv_desc_t	*bdp,
 	ASSERT(((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) != 0) ==
 	       ((ip->i_iocore.io_flags & XFS_IOCORE_RT) != 0));
 
-	return xfs_iomap(io, offset, count, flags, pbmapp, npbmaps);
+	return xfs_iomap(io, offset, count, flags, iomapp, niomaps);
 }
 
 /*
diff -puN fs/xfs/linux/xfs_lrw.h~linus fs/xfs/linux/xfs_lrw.h
--- 25/fs/xfs/linux/xfs_lrw.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/linux/xfs_lrw.h	2004-01-19 22:17:24.000000000 -0800
@@ -39,21 +39,59 @@ struct xfs_iocore;
 struct xfs_inode;
 struct xfs_bmbt_irec;
 struct page_buf_s;
-struct page_buf_bmap_s;
+struct xfs_iomap;
 
+#if defined(XFS_RW_TRACE)
+/*
+ * Defines for the trace mechanisms in xfs_lrw.c.
+ */
+#define	XFS_RW_KTRACE_SIZE	64
+#define	XFS_STRAT_KTRACE_SIZE	64
+#define	XFS_STRAT_GTRACE_SIZE	512
+
+#define	XFS_READ_ENTER		1
+#define	XFS_WRITE_ENTER		2
 #define XFS_IOMAP_READ_ENTER	3
+#define	XFS_IOMAP_WRITE_ENTER	4
+#define	XFS_IOMAP_READ_MAP	5
+#define	XFS_IOMAP_WRITE_MAP	6
+#define	XFS_IOMAP_WRITE_NOSPACE	7
+#define	XFS_ITRUNC_START	8
+#define	XFS_ITRUNC_FINISH1	9
+#define	XFS_ITRUNC_FINISH2	10
+#define	XFS_CTRUNC1		11
+#define	XFS_CTRUNC2		12
+#define	XFS_CTRUNC3		13
+#define	XFS_CTRUNC4		14
+#define	XFS_CTRUNC5		15
+#define	XFS_CTRUNC6		16
+#define	XFS_BUNMAPI		17
+#define	XFS_INVAL_CACHED	18
+#define	XFS_DIORD_ENTER		19
+#define	XFS_DIOWR_ENTER		20
+extern void xfs_rw_enter_trace(int, struct xfs_iocore *,
+			const struct iovec *, size_t, loff_t, int);
+extern void xfs_inval_cached_trace(struct xfs_iocore *,
+			xfs_off_t, xfs_off_t, xfs_off_t, xfs_off_t);
+#else
+#define xfs_rw_enter_trace(tag, io, iovec, segs, offset, ioflags)
+#define xfs_inval_cached_trace(io, offset, len, first, last)
+#endif
+
 /*
  * Maximum count of bmaps used by read and write paths.
  */
 #define	XFS_MAX_RW_NBMAPS	4
 
 extern int xfs_bmap(struct bhv_desc *, xfs_off_t, ssize_t, int,
-			struct page_buf_bmap_s *, int *);
+			struct xfs_iomap *, int *);
 extern int xfsbdstrat(struct xfs_mount *, struct page_buf_s *);
 extern int xfs_bdstrat_cb(struct page_buf_s *);
 
 extern int xfs_zero_eof(struct vnode *, struct xfs_iocore *, xfs_off_t,
 				xfs_fsize_t, xfs_fsize_t);
+extern void xfs_inval_cached_pages(struct vnode	*, struct xfs_iocore *,
+				xfs_off_t, int, int);
 extern ssize_t xfs_read(struct bhv_desc *, struct kiocb *,
 				const struct iovec *, unsigned int,
 				loff_t *, int, struct cred *);
@@ -64,16 +102,6 @@ extern ssize_t xfs_sendfile(struct bhv_d
 				loff_t *, int, size_t, read_actor_t,
 				void *, struct cred *);
 
-extern int xfs_iomap(struct xfs_iocore *, xfs_off_t, ssize_t, int,
-				struct page_buf_bmap_s *, int *);
-extern int xfs_iomap_write_direct(struct xfs_inode *, loff_t, size_t,
-				int, struct xfs_bmbt_irec *, int *, int);
-extern int xfs_iomap_write_delay(struct xfs_inode *, loff_t, size_t,
-				int, struct xfs_bmbt_irec *, int *);
-extern int xfs_iomap_write_allocate(struct xfs_inode *,
-				struct xfs_bmbt_irec *, int *);
-extern int xfs_iomap_write_unwritten(struct xfs_inode *, loff_t, size_t);
-
 extern int xfs_dev_is_read_only(struct xfs_mount *, char *);
 
 #define XFS_FSB_TO_DB_IO(io,fsb) \
diff -puN fs/xfs/linux/xfs_super.c~linus fs/xfs/linux/xfs_super.c
--- 25/fs/xfs/linux/xfs_super.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/linux/xfs_super.c	2004-01-19 22:17:24.000000000 -0800
@@ -120,7 +120,7 @@ xfs_max_file_offset(
 	 */
 
 #if BITS_PER_LONG == 32
-# if defined(HAVE_SECTOR_T)
+# if defined(CONFIG_LBD)
 	ASSERT(sizeof(sector_t) == 8);
 	pagefactor = PAGE_CACHE_SIZE;
 	bitshift = BITS_PER_LONG;
@@ -241,6 +241,23 @@ xfs_initialize_vnode(
 	}
 }
 
+void
+xfs_flush_inode(
+	xfs_inode_t	*ip)
+{
+	struct inode	*inode = LINVFS_GET_IP(XFS_ITOV(ip));
+
+	filemap_fdatawrite(inode->i_mapping);
+}
+
+void
+xfs_flush_device(
+	xfs_inode_t	*ip)
+{
+	sync_blockdev(XFS_ITOV(ip)->v_vfsp->vfs_super->s_bdev);
+	xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC);
+}
+
 int
 xfs_blkdev_get(
 	xfs_mount_t		*mp,
@@ -860,15 +877,16 @@ init_xfs_fs( void )
 {
 	int			error;
 	struct sysinfo		si;
-	static char		message[] __initdata =
-		KERN_INFO "SGI XFS " XFS_VERSION_STRING " with "
-		XFS_BUILD_OPTIONS " enabled\n";
+	static char		message[] __initdata = KERN_INFO \
+		XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled\n";
 
 	printk(message);
 
 	si_meminfo(&si);
 	xfs_physmem = si.totalram;
 
+	ktrace_init(64);
+
 	error = init_inodecache();
 	if (error < 0)
 		goto undo_inodecache;
@@ -907,12 +925,12 @@ exit_xfs_fs( void )
 	vfs_exitdmapi();
 	pagebuf_terminate();
 	destroy_inodecache();
+	ktrace_uninit();
 }
 
 module_init(init_xfs_fs);
 module_exit(exit_xfs_fs);
 
 MODULE_AUTHOR("Silicon Graphics, Inc.");
-MODULE_DESCRIPTION(
-	"SGI XFS " XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled");
+MODULE_DESCRIPTION(XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled");
 MODULE_LICENSE("GPL");
diff -puN fs/xfs/linux/xfs_super.h~linus fs/xfs/linux/xfs_super.h
--- 25/fs/xfs/linux/xfs_super.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/linux/xfs_super.h	2004-01-19 22:17:24.000000000 -0800
@@ -76,10 +76,10 @@
 # define XFS_BIGFS_STRING
 #endif
 
-#ifdef CONFIG_XFS_VNODE_TRACING
-# define XFS_VNTRACE_STRING	"VN-trace, "
+#ifdef CONFIG_XFS_TRACE
+# define XFS_TRACE_STRING	"tracing, "
 #else
-# define XFS_VNTRACE_STRING
+# define XFS_TRACE_STRING
 #endif
 
 #ifdef XFSDEBUG
@@ -91,7 +91,7 @@
 #define XFS_BUILD_OPTIONS	XFS_ACL_STRING \
 				XFS_REALTIME_STRING \
 				XFS_BIGFS_STRING \
-				XFS_VNTRACE_STRING \
+				XFS_TRACE_STRING \
 				XFS_DBG_STRING /* DBG must be last */
 
 #define LINVFS_GET_VFS(s) \
@@ -99,6 +99,7 @@
 #define LINVFS_SET_VFS(s, vfsp) \
 	((s)->s_fs_info = vfsp)
 
+struct xfs_inode;
 struct xfs_mount;
 struct pb_target;
 struct block_device;
@@ -107,6 +108,9 @@ extern __uint64_t xfs_max_file_offset(un
 
 extern void xfs_initialize_vnode(bhv_desc_t *, vnode_t *, bhv_desc_t *, int);
 
+extern void xfs_flush_inode(struct xfs_inode *);
+extern void xfs_flush_device(struct xfs_inode *);
+
 extern int  xfs_blkdev_get(struct xfs_mount *, const char *,
 				struct block_device **);
 extern void xfs_blkdev_put(struct block_device *);
diff -puN fs/xfs/linux/xfs_sysctl.c~linus fs/xfs/linux/xfs_sysctl.c
--- 25/fs/xfs/linux/xfs_sysctl.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/linux/xfs_sysctl.c	2004-01-19 22:17:24.000000000 -0800
@@ -51,7 +51,7 @@ xfs_stats_clear_proc_handler(
 	int		c, ret, *valp = ctl->data;
 	__uint32_t	vn_active;
 
-	ret = proc_doulongvec_minmax(ctl, write, filp, buffer, lenp);
+	ret = proc_dointvec_minmax(ctl, write, filp, buffer, lenp);
 
 	if (!ret && write && *valp) {
 		printk("XFS Clearing xfsstats\n");
diff -puN fs/xfs/linux/xfs_version.h~linus fs/xfs/linux/xfs_version.h
--- 25/fs/xfs/linux/xfs_version.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/linux/xfs_version.h	2004-01-19 22:17:24.000000000 -0800
@@ -39,6 +39,6 @@
 #ifndef __XFS_VERSION_H__
 #define __XFS_VERSION_H__
 
-#define XFS_VERSION_STRING "for Linux"
+#define XFS_VERSION_STRING "SGI XFS"
 
 #endif /* __XFS_VERSION_H__ */
diff -puN fs/xfs/linux/xfs_vfs.c~linus fs/xfs/linux/xfs_vfs.c
--- 25/fs/xfs/linux/xfs_vfs.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/linux/xfs_vfs.c	2004-01-19 22:17:24.000000000 -0800
@@ -134,7 +134,7 @@ vfs_root(
 int
 vfs_statvfs(
 	struct bhv_desc		*bdp,
-	struct kstatfs		*sp,
+	xfs_statfs_t		*sp,
 	struct vnode		*vp)
 {
 	struct bhv_desc		*next = bdp;
diff -puN fs/xfs/linux/xfs_vfs.h~linus fs/xfs/linux/xfs_vfs.h
--- 25/fs/xfs/linux/xfs_vfs.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/linux/xfs_vfs.h	2004-01-19 22:17:24.000000000 -0800
@@ -33,6 +33,7 @@
 #define __XFS_VFS_H__
 
 #include <linux/vfs.h>
+#include "xfs_fs.h"
 
 struct fid;
 struct cred;
@@ -42,10 +43,12 @@ struct seq_file;
 struct super_block;
 struct xfs_mount_args;
 
+typedef struct kstatfs xfs_statfs_t;
+
 typedef struct vfs {
 	u_int			vfs_flag;	/* flags */
-	fsid_t			vfs_fsid;	/* file system ID */
-	fsid_t			*vfs_altfsid;	/* An ID fixed for life of FS */
+	xfs_fsid_t		vfs_fsid;	/* file system ID */
+	xfs_fsid_t		*vfs_altfsid;	/* An ID fixed for life of FS */
 	bhv_head_t		vfs_bh;		/* head of vfs behavior chain */
 	struct super_block	*vfs_super;	/* Linux superblock structure */
 	struct task_struct	*vfs_sync_task;
@@ -101,7 +104,7 @@ typedef int	(*vfs_unmount_t)(bhv_desc_t 
 typedef int	(*vfs_mntupdate_t)(bhv_desc_t *, int *,
 				struct xfs_mount_args *);
 typedef int	(*vfs_root_t)(bhv_desc_t *, struct vnode **);
-typedef int	(*vfs_statvfs_t)(bhv_desc_t *, struct kstatfs *, struct vnode *);
+typedef int	(*vfs_statvfs_t)(bhv_desc_t *, xfs_statfs_t *, struct vnode *);
 typedef int	(*vfs_sync_t)(bhv_desc_t *, int, struct cred *);
 typedef int	(*vfs_vget_t)(bhv_desc_t *, struct vnode **, struct fid *);
 typedef int	(*vfs_dmapiops_t)(bhv_desc_t *, caddr_t);
@@ -168,7 +171,7 @@ extern int vfs_showargs(bhv_desc_t *, st
 extern int vfs_unmount(bhv_desc_t *, int, struct cred *);
 extern int vfs_mntupdate(bhv_desc_t *, int *, struct xfs_mount_args *);
 extern int vfs_root(bhv_desc_t *, struct vnode **);
-extern int vfs_statvfs(bhv_desc_t *, struct kstatfs *, struct vnode *);
+extern int vfs_statvfs(bhv_desc_t *, xfs_statfs_t *, struct vnode *);
 extern int vfs_sync(bhv_desc_t *, int, struct cred *);
 extern int vfs_vget(bhv_desc_t *, struct vnode **, struct fid *);
 extern int vfs_dmapiops(bhv_desc_t *, caddr_t);
diff -puN fs/xfs/linux/xfs_vnode.c~linus fs/xfs/linux/xfs_vnode.c
--- 25/fs/xfs/linux/xfs_vnode.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/linux/xfs_vnode.c	2004-01-19 22:17:24.000000000 -0800
@@ -98,7 +98,7 @@ vn_reclaim(
 	vp->v_type = VNON;
 	vp->v_fbhv = NULL;
 
-#ifdef CONFIG_XFS_VNODE_TRACING
+#ifdef XFS_VNODE_TRACE
 	ktrace_free(vp->v_trace);
 	vp->v_trace = NULL;
 #endif
@@ -154,9 +154,10 @@ vn_initialize(
 	/* Initialize the first behavior and the behavior chain head. */
 	vn_bhv_head_init(VN_BHV_HEAD(vp), "vnode");
 
-#ifdef	CONFIG_XFS_VNODE_TRACING
+#ifdef	XFS_VNODE_TRACE
 	vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP);
-#endif	/* CONFIG_XFS_VNODE_TRACING */
+	printk("Allocated VNODE_TRACE at 0x%p\n", vp->v_trace);
+#endif	/* XFS_VNODE_TRACE */
 
 	vn_trace_exit(vp, "vn_initialize", (inst_t *)__return_address);
 	return vp;
@@ -392,7 +393,7 @@ vn_remove(
 }
 
 
-#ifdef	CONFIG_XFS_VNODE_TRACING
+#ifdef	XFS_VNODE_TRACE
 
 #define KTRACE_ENTER(vp, vk, s, line, ra)			\
 	ktrace_enter(	(vp)->v_trace,				\
@@ -439,4 +440,4 @@ vn_trace_rele(vnode_t *vp, char *file, i
 {
 	KTRACE_ENTER(vp, VNODE_KTRACE_RELE, file, line, ra);
 }
-#endif	/* CONFIG_XFS_VNODE_TRACING */
+#endif	/* XFS_VNODE_TRACE */
diff -puN fs/xfs/linux/xfs_vnode.h~linus fs/xfs/linux/xfs_vnode.h
--- 25/fs/xfs/linux/xfs_vnode.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/linux/xfs_vnode.h	2004-01-19 22:17:24.000000000 -0800
@@ -62,7 +62,7 @@
 struct uio;
 struct file;
 struct vattr;
-struct page_buf_bmap_s;
+struct xfs_iomap;
 struct attrlist_cursor_kern;
 
 /*
@@ -87,7 +87,7 @@ typedef struct vnode {
 	vn_bhv_head_t	v_bh;			/* behavior head */
 	spinlock_t	v_lock;			/* VN_LOCK/VN_UNLOCK */
 	struct inode	v_inode;		/* Linux inode */
-#ifdef CONFIG_XFS_VNODE_TRACING
+#ifdef XFS_VNODE_TRACE
 	struct ktrace	*v_trace;		/* trace header structure    */
 #endif
 } vnode_t;
@@ -226,7 +226,7 @@ typedef int	(*vop_release_t)(bhv_desc_t 
 typedef int	(*vop_rwlock_t)(bhv_desc_t *, vrwlock_t);
 typedef void	(*vop_rwunlock_t)(bhv_desc_t *, vrwlock_t);
 typedef int	(*vop_bmap_t)(bhv_desc_t *, xfs_off_t, ssize_t, int,
-				struct page_buf_bmap_s *, int *);
+				struct xfs_iomap *, int *);
 typedef int	(*vop_reclaim_t)(bhv_desc_t *);
 typedef int	(*vop_attr_get_t)(bhv_desc_t *, char *, char *, int *, int,
 				struct cred *);
@@ -545,21 +545,17 @@ static inline int vn_count(struct vnode 
 extern vnode_t	*vn_hold(struct vnode *);
 extern void	vn_rele(struct vnode *);
 
-#if defined(CONFIG_XFS_VNODE_TRACING)
-
+#if defined(XFS_VNODE_TRACE)
 #define VN_HOLD(vp)		\
-	((void)vn_hold(vp), \
+	((void)vn_hold(vp),	\
 	  vn_trace_hold(vp, __FILE__, __LINE__, (inst_t *)__return_address))
 #define VN_RELE(vp)		\
 	  (vn_trace_rele(vp, __FILE__, __LINE__, (inst_t *)__return_address), \
 	   iput(LINVFS_GET_IP(vp)))
-
-#else	/* ! (defined(CONFIG_XFS_VNODE_TRACING)) */
-
+#else
 #define VN_HOLD(vp)		((void)vn_hold(vp))
 #define VN_RELE(vp)		(iput(LINVFS_GET_IP(vp)))
-
-#endif	/* ! (defined(CONFIG_XFS_VNODE_TRACING)) */
+#endif
 
 /*
  * Vname handling macros.
@@ -591,6 +587,13 @@ static __inline__ void vn_flagclr(struct
 }
 
 /*
+ * Update modify/access/change times on the vnode
+ */
+#define VN_MTIMESET(vp, tvp)	(LINVFS_GET_IP(vp)->i_mtime = *(tvp))
+#define VN_ATIMESET(vp, tvp)	(LINVFS_GET_IP(vp)->i_atime = *(tvp))
+#define VN_CTIMESET(vp, tvp)	(LINVFS_GET_IP(vp)->i_ctime = *(tvp))
+
+/*
  * Some useful predicates.
  */
 #define VN_MAPPED(vp)	\
@@ -617,13 +620,12 @@ static __inline__ void vn_flagclr(struct
 #define FSYNC_INVAL	0x2	/* flush and invalidate cached data */
 #define FSYNC_DATA	0x4	/* synchronous fsync of data only */
 
-#if (defined(CONFIG_XFS_VNODE_TRACING))
-
-#define	VNODE_TRACE_SIZE	16		/* number of trace entries */
-
 /*
- * Tracing entries.
+ * Tracking vnode activity.
  */
+#if defined(XFS_VNODE_TRACE)
+
+#define	VNODE_TRACE_SIZE	16		/* number of trace entries */
 #define	VNODE_KTRACE_ENTRY	1
 #define	VNODE_KTRACE_EXIT	2
 #define	VNODE_KTRACE_HOLD	3
@@ -635,18 +637,16 @@ extern void vn_trace_exit(struct vnode *
 extern void vn_trace_hold(struct vnode *, char *, int, inst_t *);
 extern void vn_trace_ref(struct vnode *, char *, int, inst_t *);
 extern void vn_trace_rele(struct vnode *, char *, int, inst_t *);
+
 #define	VN_TRACE(vp)		\
 	vn_trace_ref(vp, __FILE__, __LINE__, (inst_t *)__return_address)
-
-#else	/* ! (defined(CONFIG_XFS_VNODE_TRACING)) */
-
+#else
 #define	vn_trace_entry(a,b,c)
 #define	vn_trace_exit(a,b,c)
 #define	vn_trace_hold(a,b,c,d)
 #define	vn_trace_ref(a,b,c,d)
 #define	vn_trace_rele(a,b,c,d)
 #define	VN_TRACE(vp)
-
-#endif	/* ! (defined(CONFIG_XFS_VNODE_TRACING)) */
+#endif
 
 #endif	/* __XFS_VNODE_H__ */
diff -puN fs/xfs/Makefile~linus fs/xfs/Makefile
--- 25/fs/xfs/Makefile~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/Makefile	2004-01-19 22:17:24.000000000 -0800
@@ -34,13 +34,29 @@ EXTRA_CFLAGS +=	 -Ifs/xfs -funsigned-cha
 
 ifeq ($(CONFIG_XFS_DEBUG),y)
 	EXTRA_CFLAGS += -g -DSTATIC="" -DDEBUG -DXFSDEBUG
+	EXTRA_CFLAGS += -DPAGEBUF_LOCK_TRACKING
 endif
-ifeq ($(CONFIG_PAGEBUF_DEBUG),y)
+ifeq ($(CONFIG_XFS_TRACE),y)
+	EXTRA_CFLAGS += -DXFS_ALLOC_TRACE
+	EXTRA_CFLAGS += -DXFS_ATTR_TRACE
+	EXTRA_CFLAGS += -DXFS_BLI_TRACE
+	EXTRA_CFLAGS += -DXFS_BMAP_TRACE
+	EXTRA_CFLAGS += -DXFS_BMBT_TRACE
+	EXTRA_CFLAGS += -DXFS_DIR_TRACE
+	EXTRA_CFLAGS += -DXFS_DIR2_TRACE
+	EXTRA_CFLAGS += -DXFS_DQUOT_TRACE
+	EXTRA_CFLAGS += -DXFS_ILOCK_TRACE
+	EXTRA_CFLAGS += -DXFS_LOG_TRACE
+	EXTRA_CFLAGS += -DXFS_RW_TRACE
 	EXTRA_CFLAGS += -DPAGEBUF_TRACE
+	# EXTRA_CFLAGS += -DXFS_VNODE_TRACE
 endif
 
 obj-$(CONFIG_XFS_FS)		+= xfs.o
 
+ifneq ($(CONFIG_XFS_DMAPI),y)
+xfs-y				+= xfs_dmops.o
+endif
 
 xfs-$(CONFIG_XFS_QUOTA)		+= $(addprefix quota/, \
 				   xfs_dquot.o \
@@ -49,9 +65,10 @@ xfs-$(CONFIG_XFS_QUOTA)		+= $(addprefix 
 				   xfs_qm_syscalls.o \
 				   xfs_qm_bhv.o \
 				   xfs_qm.o)
-
 ifeq ($(CONFIG_XFS_QUOTA),y)
 xfs-$(CONFIG_PROC_FS)		+= quota/xfs_qm_stats.o
+else
+xfs-y				+= xfs_qmops.o
 endif
 
 xfs-$(CONFIG_XFS_RT)		+= xfs_rtalloc.o
@@ -79,7 +96,6 @@ xfs-y				+= xfs_alloc.o \
 				   xfs_dir2_leaf.o \
 				   xfs_dir2_node.o \
 				   xfs_dir2_sf.o \
-				   xfs_dir2_trace.o \
 				   xfs_dir_leaf.o \
 				   xfs_error.o \
 				   xfs_extfree_item.o \
@@ -108,10 +124,10 @@ xfs-y				+= xfs_alloc.o \
 				   xfs_vnodeops.o \
 				   xfs_rw.o
 
+xfs-$(CONFIG_XFS_TRACE)		+= xfs_dir2_trace.o
+
 # Objects in pagebuf/
-xfs-y				+= $(addprefix pagebuf/, \
-				   page_buf.o \
-				   page_buf_locking.o)
+xfs-y				+= pagebuf/page_buf.o
 
 # Objects in linux/
 xfs-y				+= $(addprefix linux/, \
@@ -131,27 +147,10 @@ xfs-y				+= $(addprefix linux/, \
 # Objects in support/
 xfs-y				+= $(addprefix support/, \
 				   debug.o \
-				   ktrace.o \
 				   move.o \
 				   mrlock.o \
 				   qsort.o \
 				   uuid.o)
 
-# Quota and DMAPI stubs
-xfs-y				+= xfs_dmops.o \
-				   xfs_qmops.o
-
-# If both xfs and kdb modules are built in then xfsidbg is built in.  If xfs is
-# a module and kdb modules are being compiled then xfsidbg must be a module, to
-# follow xfs.  If xfs is built in then xfsidbg tracks the kdb module state.
-# This must come after the main xfs code so xfs initialises before xfsidbg.
-# KAO
-ifneq ($(CONFIG_KDB_MODULES),)
-  ifeq ($(CONFIG_XFS_FS),y)
-    obj-$(CONFIG_KDB_MODULES)	+= xfsidbg.o
-  else
-    obj-$(CONFIG_XFS_FS)	+= xfsidbg.o
-  endif
-endif
+xfs-$(CONFIG_XFS_TRACE)		+= support/ktrace.o
 
-CFLAGS_xfsidbg.o += -Iarch/$(ARCH)/kdb
diff -puN fs/xfs/pagebuf/page_buf.c~linus fs/xfs/pagebuf/page_buf.c
--- 25/fs/xfs/pagebuf/page_buf.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/pagebuf/page_buf.c	2004-01-19 22:17:24.000000000 -0800
@@ -58,11 +58,13 @@
 #include <linux/proc_fs.h>
 #include <linux/workqueue.h>
 #include <linux/suspend.h>
+#include <linux/percpu.h>
 
+#include <support/ktrace.h>
 #include <support/debug.h>
 #include <support/kmem.h>
 
-#include "page_buf_internal.h"
+#include "page_buf.h"
 
 #define BBSHIFT		9
 #define BN_ALIGN_MASK	((1 << (PAGE_CACHE_SHIFT - BBSHIFT)) - 1)
@@ -72,50 +74,7 @@
 #endif
 
 /*
- * Debug code
- */
-
-#ifdef PAGEBUF_TRACE
-static spinlock_t		pb_trace_lock = SPIN_LOCK_UNLOCKED;
-struct pagebuf_trace_buf	pb_trace;
-EXPORT_SYMBOL(pb_trace);
-EXPORT_SYMBOL(pb_trace_func);
-#define CIRC_INC(i)	(((i) + 1) & (PB_TRACE_BUFSIZE - 1))
-
-void
-pb_trace_func(
-	page_buf_t	*pb,
-	int		event,
-	void		*misc,
-	void		*ra)
-{
-	int		j;
-	unsigned long	flags;
-
-	if (!pb_params.debug.val) return;
-
-	if (ra == NULL) ra = (void *)__builtin_return_address(0);
-
-	spin_lock_irqsave(&pb_trace_lock, flags);
-	j = pb_trace.start;
-	pb_trace.start = CIRC_INC(j);
-	spin_unlock_irqrestore(&pb_trace_lock, flags);
-
-	pb_trace.buf[j].pb = (unsigned long) pb;
-	pb_trace.buf[j].event = event;
-	pb_trace.buf[j].flags = pb->pb_flags;
-	pb_trace.buf[j].hold = pb->pb_hold.counter;
-	pb_trace.buf[j].lock_value = pb->pb_sema.count.counter;
-	pb_trace.buf[j].task = (void *)current;
-	pb_trace.buf[j].misc = misc;
-	pb_trace.buf[j].ra = ra;
-	pb_trace.buf[j].offset = pb->pb_file_offset;
-	pb_trace.buf[j].size = pb->pb_buffer_length;
-}
-#endif	/* PAGEBUF_TRACE */
-
-/*
- *	File wide globals
+ * File wide globals
  */
 
 STATIC kmem_cache_t *pagebuf_cache;
@@ -129,7 +88,20 @@ STATIC struct workqueue_struct *pagebuf_
  * /proc/sys/vm/pagebuf
  */
 
-pagebuf_param_t pb_params = {
+typedef struct pb_sysctl_val {
+	int	min;
+	int	val;
+	int	max;
+} pb_sysctl_val_t;
+
+struct {
+	pb_sysctl_val_t	flush_interval;	/* interval between runs of the
+					 * delwri flush daemon.  */
+	pb_sysctl_val_t	age_buffer;	/* time for buffer to age before
+					 * we flush it.  */
+	pb_sysctl_val_t	stats_clear;	/* clear the pagebuf stats */
+	pb_sysctl_val_t	debug;		/* debug tracing on or off */
+} pb_params = {
 			  /*	MIN	DFLT	MAX	*/
 	.flush_interval	= {	HZ/2,	HZ,	30*HZ	},
 	.age_buffer	= {	1*HZ,	15*HZ,	300*HZ	},
@@ -137,12 +109,79 @@ pagebuf_param_t pb_params = {
 	.debug		= {	0,	0,	1	},
 };
 
+enum {
+	PB_FLUSH_INT = 1,
+	PB_FLUSH_AGE = 2,
+	PB_STATS_CLEAR = 3,
+	PB_DEBUG = 4,
+};
+
 /*
  * Pagebuf statistics variables
  */
 
+struct pbstats {
+	u_int32_t	pb_get;
+	u_int32_t	pb_create;
+	u_int32_t	pb_get_locked;
+	u_int32_t	pb_get_locked_waited;
+	u_int32_t	pb_busy_locked;
+	u_int32_t	pb_miss_locked;
+	u_int32_t	pb_page_retries;
+	u_int32_t	pb_page_found;
+	u_int32_t	pb_get_read;
+} pbstats;
 DEFINE_PER_CPU(struct pbstats, pbstats);
 
+/* We don't disable preempt, not too worried about poking the
+ * wrong cpu's stat for now */
+#define PB_STATS_INC(count)	(__get_cpu_var(pbstats).count++)
+
+/*
+ * Pagebuf debugging
+ */
+
+#ifdef PAGEBUF_TRACE
+void
+pagebuf_trace(
+	page_buf_t	*pb,
+	char		*id,
+	void		*data,
+	void		*ra)
+{
+	if (!pb_params.debug.val)
+		return;
+	ktrace_enter(pagebuf_trace_buf,
+		pb, id,
+		(void *)(unsigned long)pb->pb_flags,
+		(void *)(unsigned long)pb->pb_hold.counter,
+		(void *)(unsigned long)pb->pb_sema.count.counter,
+		(void *)current,
+		data, ra,
+		(void *)(unsigned long)((pb->pb_file_offset>>32) & 0xffffffff),
+		(void *)(unsigned long)(pb->pb_file_offset & 0xffffffff),
+		(void *)(unsigned long)pb->pb_buffer_length,
+		NULL, NULL, NULL, NULL, NULL);
+}
+ktrace_t *pagebuf_trace_buf;
+EXPORT_SYMBOL(pagebuf_trace_buf);
+#define PAGEBUF_TRACE_SIZE	4096
+#define PB_TRACE(pb, id, data)	\
+	pagebuf_trace(pb, id, (void *)data, (void *)__builtin_return_address(0))
+#else
+#define PB_TRACE(pb, id, data)	do { } while (0)
+#endif
+
+#ifdef PAGEBUF_LOCK_TRACKING
+# define PB_SET_OWNER(pb)	((pb)->pb_last_holder = current->pid)
+# define PB_CLEAR_OWNER(pb)	((pb)->pb_last_holder = -1)
+# define PB_GET_OWNER(pb)	((pb)->pb_last_holder)
+#else
+# define PB_SET_OWNER(pb)	do { } while (0)
+# define PB_CLEAR_OWNER(pb)	do { } while (0)
+# define PB_GET_OWNER(pb)	do { } while (0)
+#endif
+
 /*
  * Pagebuf allocation / freeing.
  */
@@ -198,11 +237,11 @@ typedef struct a_list {
 	void		*vm_addr;
 	struct a_list	*next;
 } a_list_t;
+
 STATIC a_list_t		*as_free_head;
 STATIC int		as_list_len;
 STATIC spinlock_t	as_lock = SPIN_LOCK_UNLOCKED;
 
-
 /*
  * Try to batch vunmaps because they are costly.
  */
@@ -247,16 +286,6 @@ purge_addresses(void)
 }
 
 /*
- *	Locking model:
- *
- *	Buffers associated with inodes for which buffer locking
- *	is not enabled are not protected by semaphores, and are
- *	assumed to be exclusively owned by the caller.  There is
- *	spinlock in the buffer, for use by the caller when concurrent
- *	access is possible.
- */
-
-/*
  *	Internal pagebuf object manipulation
  */
 
@@ -294,7 +323,7 @@ _pagebuf_initialize(
 	init_waitqueue_head(&pb->pb_waiters);
 
 	PB_STATS_INC(pb_create);
-	PB_TRACE(pb, PB_TRACE_REC(get), target);
+	PB_TRACE(pb, "initialize", target);
 }
 
 /*
@@ -343,9 +372,6 @@ _pagebuf_freepages(
 			page_cache_release(page);
 		}
 	}
-
-	if (pb->pb_pages != pb->pb_page_array)
-		kfree(pb->pb_pages);
 }
 
 /*
@@ -361,7 +387,7 @@ _pagebuf_free_object(
 {
 	page_buf_flags_t	pb_flags = pb->pb_flags;
 
-	PB_TRACE(pb, PB_TRACE_REC(free_obj), 0);
+	PB_TRACE(pb, "free_object", 0);
 	pb->pb_flags |= PBF_FREED;
 
 	if (hash) {
@@ -384,20 +410,17 @@ _pagebuf_free_object(
 		if (pb->pb_flags & _PBF_MEM_ALLOCATED) {
 			if (pb->pb_pages) {
 				/* release the pages in the address list */
-				if (pb->pb_pages[0] &&
-				    PageSlab(pb->pb_pages[0])) {
-					/*
-					 * This came from the slab
-					 * allocator free it as such
-					 */
+				if ((pb->pb_pages[0]) &&
+				    (pb->pb_flags & _PBF_MEM_SLAB)) {
 					kfree(pb->pb_addr);
 				} else {
 					_pagebuf_freepages(pb);
 				}
-
+				if (pb->pb_pages != pb->pb_page_array)
+					kfree(pb->pb_pages);
 				pb->pb_pages = NULL;
 			}
-			pb->pb_flags &= ~_PBF_MEM_ALLOCATED;
+			pb->pb_flags &= ~(_PBF_MEM_ALLOCATED|_PBF_MEM_SLAB);
 		}
 	}
 
@@ -572,7 +595,7 @@ mapit:
 		}
 	}
 
-	PB_TRACE(pb, PB_TRACE_REC(look_pg), good_pages);
+	PB_TRACE(pb, "lookup_pages", (long)good_pages);
 
 	return rval;
 }
@@ -663,7 +686,7 @@ found:
 	if (not_locked) {
 		if (!(flags & PBF_TRYLOCK)) {
 			/* wait for buffer ownership */
-			PB_TRACE(pb, PB_TRACE_REC(get_lk), 0);
+			PB_TRACE(pb, "get_lock", 0);
 			pagebuf_lock(pb);
 			PB_STATS_INC(pb_get_locked_waited);
 		} else {
@@ -689,8 +712,9 @@ found:
 				_PBF_LOCKABLE | \
 				_PBF_ALL_PAGES_MAPPED | \
 				_PBF_ADDR_ALLOCATED | \
-				_PBF_MEM_ALLOCATED;
-	PB_TRACE(pb, PB_TRACE_REC(got_lk), 0);
+				_PBF_MEM_ALLOCATED | \
+				_PBF_MEM_SLAB;
+	PB_TRACE(pb, "got_lock", 0);
 	PB_STATS_INC(pb_get_locked);
 	return (pb);
 }
@@ -765,10 +789,11 @@ pagebuf_get(				/* allocate a buffer		*/
 
 	if (flags & PBF_READ) {
 		if (PBF_NOT_DONE(pb)) {
-			PB_TRACE(pb, PB_TRACE_REC(get_read), flags);
+			PB_TRACE(pb, "get_read", (unsigned long)flags);
 			PB_STATS_INC(pb_get_read);
 			pagebuf_iostart(pb, flags);
 		} else if (flags & PBF_ASYNC) {
+			PB_TRACE(pb, "get_read_async", (unsigned long)flags);
 			/*
 			 * Read ahead call which is already satisfied,
 			 * drop the buffer
@@ -778,12 +803,13 @@ pagebuf_get(				/* allocate a buffer		*/
 			pagebuf_rele(pb);
 			return NULL;
 		} else {
+			PB_TRACE(pb, "get_read_done", (unsigned long)flags);
 			/* We do not want read in the flags */
 			pb->pb_flags &= ~PBF_READ;
 		}
+	} else {
+		PB_TRACE(pb, "get_write", (unsigned long)flags);
 	}
-
-	PB_TRACE(pb, PB_TRACE_REC(get_obj), flags);
 	return (pb);
 }
 
@@ -916,8 +942,8 @@ pagebuf_get_no_daddr(
 	page_buf_t		*pb;
 	size_t			tlen = 0;
 
-	if (len > 0x20000)
-		return(NULL);
+	if (unlikely(len > 0x20000))
+		return NULL;
 
 	pb = pagebuf_allocate(flags);
 	if (!pb)
@@ -944,11 +970,11 @@ pagebuf_get_no_daddr(
 		return NULL;
 	}
 	/* otherwise pagebuf_free just ignores it */
-	pb->pb_flags |= _PBF_MEM_ALLOCATED;
+	pb->pb_flags |= (_PBF_MEM_ALLOCATED | _PBF_MEM_SLAB);
 	PB_CLEAR_OWNER(pb);
 	up(&pb->pb_sema);	/* Return unlocked pagebuf */
 
-	PB_TRACE(pb, PB_TRACE_REC(no_daddr), rmem);
+	PB_TRACE(pb, "no_daddr", rmem);
 
 	return pb;
 }
@@ -967,7 +993,7 @@ pagebuf_hold(
 	page_buf_t		*pb)
 {
 	atomic_inc(&pb->pb_hold);
-	PB_TRACE(pb, PB_TRACE_REC(hold), 0);
+	PB_TRACE(pb, "hold", 0);
 }
 
 /*
@@ -1002,7 +1028,7 @@ pagebuf_rele(
 {
 	pb_hash_t		*h;
 
-	PB_TRACE(pb, PB_TRACE_REC(rele), pb->pb_relse);
+	PB_TRACE(pb, "rele", pb->pb_relse);
 	if (pb->pb_flags & _PBF_LOCKABLE) {
 		h = pb_hash(pb);
 		spin_lock(&h->pb_hash_lock);
@@ -1043,6 +1069,95 @@ pagebuf_rele(
 
 
 /*
+ *	Mutual exclusion on buffers.  Locking model:
+ *
+ *	Buffers associated with inodes for which buffer locking
+ *	is not enabled are not protected by semaphores, and are
+ *	assumed to be exclusively owned by the caller.  There is a
+ *	spinlock in the buffer, used by the caller when concurrent
+ *	access is possible.
+ */
+
+/*
+ *	pagebuf_cond_lock
+ *
+ *	pagebuf_cond_lock locks a buffer object, if it is not already locked.
+ *	Note that this in no way
+ *	locks the underlying pages, so it is only useful for synchronizing
+ *	concurrent use of page buffer objects, not for synchronizing independent
+ *	access to the underlying pages.
+ */
+int
+pagebuf_cond_lock(			/* lock buffer, if not locked	*/
+					/* returns -EBUSY if locked)	*/
+	page_buf_t		*pb)
+{
+	int			locked;
+
+	ASSERT(pb->pb_flags & _PBF_LOCKABLE);
+	locked = down_trylock(&pb->pb_sema) == 0;
+	if (locked) {
+		PB_SET_OWNER(pb);
+	}
+	PB_TRACE(pb, "cond_lock", (long)locked);
+	return(locked ? 0 : -EBUSY);
+}
+
+/*
+ *	pagebuf_lock_value
+ *
+ *	Return lock value for a pagebuf
+ */
+int
+pagebuf_lock_value(
+	page_buf_t		*pb)
+{
+	ASSERT(pb->pb_flags & _PBF_LOCKABLE);
+	return(atomic_read(&pb->pb_sema.count));
+}
+
+/*
+ *	pagebuf_lock
+ *
+ *	pagebuf_lock locks a buffer object.  Note that this in no way
+ *	locks the underlying pages, so it is only useful for synchronizing
+ *	concurrent use of page buffer objects, not for synchronizing independent
+ *	access to the underlying pages.
+ */
+int
+pagebuf_lock(
+	page_buf_t		*pb)
+{
+	ASSERT(pb->pb_flags & _PBF_LOCKABLE);
+
+	PB_TRACE(pb, "lock", 0);
+	if (atomic_read(&pb->pb_io_remaining))
+		blk_run_queues();
+	down(&pb->pb_sema);
+	PB_SET_OWNER(pb);
+	PB_TRACE(pb, "locked", 0);
+	return 0;
+}
+
+/*
+ *	pagebuf_unlock
+ *
+ *	pagebuf_unlock releases the lock on the buffer object created by
+ *	pagebuf_lock or pagebuf_cond_lock (not any
+ *	pinning of underlying pages created by pagebuf_pin).
+ */
+void
+pagebuf_unlock(				/* unlock buffer		*/
+	page_buf_t		*pb)	/* buffer to unlock		*/
+{
+	ASSERT(pb->pb_flags & _PBF_LOCKABLE);
+	PB_CLEAR_OWNER(pb);
+	up(&pb->pb_sema);
+	PB_TRACE(pb, "unlock", 0);
+}
+
+
+/*
  *	Pinning Buffer Storage in Memory
  */
 
@@ -1065,7 +1180,7 @@ pagebuf_pin(
 	page_buf_t		*pb)
 {
 	atomic_inc(&pb->pb_pin_count);
-	PB_TRACE(pb, PB_TRACE_REC(pin), pb->pb_pin_count.counter);
+	PB_TRACE(pb, "pin", (long)pb->pb_pin_count.counter);
 }
 
 /*
@@ -1082,7 +1197,7 @@ pagebuf_unpin(
 	if (atomic_dec_and_test(&pb->pb_pin_count)) {
 		wake_up_all(&pb->pb_waiters);
 	}
-	PB_TRACE(pb, PB_TRACE_REC(unpin), pb->pb_pin_count.counter);
+	PB_TRACE(pb, "unpin", (long)pb->pb_pin_count.counter);
 }
 
 int
@@ -1161,7 +1276,7 @@ pagebuf_iodone(
 		pb->pb_flags &= ~(PBF_PARTIAL | PBF_NONE);
 	}
 
-	PB_TRACE(pb, PB_TRACE_REC(done), pb->pb_iodone);
+	PB_TRACE(pb, "iodone", pb->pb_iodone);
 
 	if ((pb->pb_iodone) || (pb->pb_flags & PBF_ASYNC)) {
 		if (schedule) {
@@ -1187,7 +1302,7 @@ pagebuf_ioerror(			/* mark/clear buffer 
 	unsigned int		error)	/* error to store (0 if none)	*/
 {
 	pb->pb_error = error;
-	PB_TRACE(pb, PB_TRACE_REC(ioerror), error);
+	PB_TRACE(pb, "ioerror", (unsigned long)error);
 }
 
 /*
@@ -1211,7 +1326,7 @@ pagebuf_iostart(			/* start I/O on a buf
 {
 	int			status = 0;
 
-	PB_TRACE(pb, PB_TRACE_REC(iostart), flags);
+	PB_TRACE(pb, "iostart", (unsigned long)flags);
 
 	if (flags & PBF_DELWRI) {
 		pb->pb_flags &= ~(PBF_READ | PBF_WRITE | PBF_ASYNC);
@@ -1439,7 +1554,7 @@ int
 pagebuf_iorequest(			/* start real I/O		*/
 	page_buf_t		*pb)	/* buffer to convey to device	*/
 {
-	PB_TRACE(pb, PB_TRACE_REC(ioreq), 0);
+	PB_TRACE(pb, "iorequest", 0);
 
 	if (pb->pb_flags & PBF_DELWRI) {
 		pagebuf_delwri_queue(pb, 1);
@@ -1475,11 +1590,11 @@ int
 pagebuf_iowait(
 	page_buf_t		*pb)
 {
-	PB_TRACE(pb, PB_TRACE_REC(iowait), 0);
+	PB_TRACE(pb, "iowait", 0);
 	if (atomic_read(&pb->pb_io_remaining))
 		blk_run_queues();
 	down(&pb->pb_iodonesema);
-	PB_TRACE(pb, PB_TRACE_REC(iowaited), (int)pb->pb_error);
+	PB_TRACE(pb, "iowaited", (long)pb->pb_error);
 	return pb->pb_error;
 }
 
@@ -1570,7 +1685,7 @@ pagebuf_delwri_queue(
 	page_buf_t		*pb,
 	int			unlock)
 {
-	PB_TRACE(pb, PB_TRACE_REC(delwri_q), unlock);
+	PB_TRACE(pb, "delwri_q", (long)unlock);
 	spin_lock(&pbd_delwrite_lock);
 	/* If already in the queue, dequeue and place at tail */
 	if (!list_empty(&pb->pb_list)) {
@@ -1593,7 +1708,7 @@ void
 pagebuf_delwri_dequeue(
 	page_buf_t		*pb)
 {
-	PB_TRACE(pb, PB_TRACE_REC(delwri_uq), 0);
+	PB_TRACE(pb, "delwri_uq", 0);
 	spin_lock(&pbd_delwrite_lock);
 	list_del_init(&pb->pb_list);
 	pb->pb_flags &= ~PBF_DELWRI;
@@ -1660,7 +1775,7 @@ pagebuf_daemon(
 		list_for_each_safe(curr, next, &pbd_delwrite_queue) {
 			pb = list_entry(curr, page_buf_t, pb_list);
 
-			PB_TRACE(pb, PB_TRACE_REC(walkq1), pagebuf_ispin(pb));
+			PB_TRACE(pb, "walkq1", (long)pagebuf_ispin(pb));
 
 			if ((pb->pb_flags & PBF_DELWRI) && !pagebuf_ispin(pb) &&
 			    (((pb->pb_flags & _PBF_LOCKABLE) == 0) ||
@@ -1733,7 +1848,7 @@ pagebuf_delwri_flush(
 			continue;
 		}
 
-		PB_TRACE(pb, PB_TRACE_REC(walkq2), pagebuf_ispin(pb));
+		PB_TRACE(pb, "walkq2", (long)pagebuf_ispin(pb));
 		if (pagebuf_ispin(pb)) {
 			pincount++;
 			continue;
@@ -1834,7 +1949,7 @@ pb_stats_clear_handler(
 	int			c, ret;
 	int			*valp = ctl->data;
 
-	ret = proc_doulongvec_minmax(ctl, write, filp, buffer, lenp);
+	ret = proc_dointvec_minmax(ctl, write, filp, buffer, lenp);
 
 	if (!ret && write && *valp) {
 		printk("XFS Clearing pbstats\n");
@@ -1955,11 +2070,7 @@ pagebuf_init(void)
 	}
 
 #ifdef PAGEBUF_TRACE
-	pb_trace.buf = (pagebuf_trace_t *)kmalloc(
-			PB_TRACE_BUFSIZE * sizeof(pagebuf_trace_t), GFP_KERNEL);
-	memset(pb_trace.buf, 0, PB_TRACE_BUFSIZE * sizeof(pagebuf_trace_t));
-	pb_trace.start = 0;
-	pb_trace.end = PB_TRACE_BUFSIZE - 1;
+	pagebuf_trace_buf = ktrace_alloc(PAGEBUF_TRACE_SIZE, KM_SLEEP);
 #endif
 
 	pagebuf_daemon_start();
@@ -1991,3 +2102,6 @@ pagebuf_terminate(void)
  *	Module management (for kernel debugger module)
  */
 EXPORT_SYMBOL(pagebuf_offset);
+#ifdef DEBUG
+EXPORT_SYMBOL(pbd_delwrite_queue);
+#endif
diff -puN fs/xfs/pagebuf/page_buf.h~linus fs/xfs/pagebuf/page_buf.h
--- 25/fs/xfs/pagebuf/page_buf.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/pagebuf/page_buf.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -48,11 +48,6 @@
 #include <linux/uio.h>
 
 /*
- * Turn this on to get pagebuf lock ownership
-#define PAGEBUF_LOCK_TRACKING
-*/
-
-/*
  *	Base types
  */
 
@@ -61,8 +56,6 @@ typedef loff_t page_buf_daddr_t;
 
 #define PAGE_BUF_DADDR_NULL ((page_buf_daddr_t) (-1LL))
 
-typedef size_t page_buf_dsize_t;		/* size of buffer in blocks */
-
 #define page_buf_ctob(pp)	((pp) * PAGE_CACHE_SIZE)
 #define page_buf_btoc(dd)	(((dd) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT)
 #define page_buf_btoct(dd)	((dd) >> PAGE_CACHE_SHIFT)
@@ -74,29 +67,6 @@ typedef enum page_buf_rw_e {
 	PBRW_ZERO = 3			/* Zero target memory */
 } page_buf_rw_t;
 
-typedef enum {				/* pbm_flags values */
-	PBMF_EOF =		0x01,	/* mapping contains EOF		*/
-	PBMF_HOLE =		0x02,	/* mapping covers a hole	*/
-	PBMF_DELAY =		0x04,	/* mapping covers delalloc region  */
-	PBMF_UNWRITTEN =	0x20,	/* mapping covers allocated	*/
-					/* but uninitialized file data	*/
-	PBMF_NEW =		0x40	/* just allocated		*/
-} bmap_flags_t;
-
-typedef enum {
-	/* base extent manipulation calls */
-	BMAP_READ = (1 << 0),		/* read extents */
-	BMAP_WRITE = (1 << 1),		/* create extents */
-	BMAP_ALLOCATE = (1 << 2),	/* delayed allocate to real extents */
-	BMAP_UNWRITTEN  = (1 << 3),	/* unwritten extents to real extents */
-	/* modifiers */
-	BMAP_IGNSTATE = (1 << 4),	/* ignore unwritten state on read */
-	BMAP_DIRECT = (1 << 5),		/* direct instead of buffered write */
-	BMAP_MMAP = (1 << 6),		/* allocate for mmap write */
-	BMAP_SYNC = (1 << 7),		/* sync write */
-	BMAP_TRYLOCK = (1 << 8),	/* non-blocking request */
-	BMAP_DEVICE = (1 << 9),		/* we only want to know the device */
-} bmapi_flags_t;
 
 typedef enum page_buf_flags_e {		/* pb_flags values */
 	PBF_READ = (1 << 0),	/* buffer intended for reading from device */
@@ -123,12 +93,13 @@ typedef enum page_buf_flags_e {		/* pb_f
 	_PBF_PRIVATE_BH = (1 << 17), /* do not use public buffer heads	   */
 	_PBF_ALL_PAGES_MAPPED = (1 << 18), /* all pages in range mapped	   */
 	_PBF_ADDR_ALLOCATED = (1 << 19), /* pb_addr space was allocated	   */
-	_PBF_MEM_ALLOCATED = (1 << 20), /* pb_mem+underlying pages alloc'd */
+	_PBF_MEM_ALLOCATED = (1 << 20), /* underlying pages are allocated  */
+	_PBF_MEM_SLAB = (1 << 21), /* underlying pages are slab allocated  */
 
-	PBF_FORCEIO = (1 << 21),
-	PBF_FLUSH = (1 << 22),	/* flush disk write cache		   */
-	PBF_READ_AHEAD = (1 << 23),
-	PBF_RUN_QUEUES = (1 << 24), /* run block device task queue	   */
+	PBF_FORCEIO = (1 << 22), /* ignore any cache state		   */
+	PBF_FLUSH = (1 << 23),	/* flush disk write cache		   */
+	PBF_READ_AHEAD = (1 << 24), /* asynchronous read-ahead		   */
+	PBF_RUN_QUEUES = (1 << 25), /* run block device task queue	   */
 
 } page_buf_flags_t;
 
@@ -146,36 +117,6 @@ typedef struct pb_target {
 } pb_target_t;
 
 /*
- *	page_buf_bmap_t:  File system I/O map
- *
- * The pbm_bn, pbm_offset and pbm_length fields are expressed in disk blocks.
- * The pbm_length field specifies the size of the underlying backing store
- * for the particular mapping.
- *
- * The pbm_bsize, pbm_size and pbm_delta fields are in bytes and indicate
- * the size of the mapping, the number of bytes that are valid to access
- * (read or write), and the offset into the mapping, given the offset
- * supplied to the file I/O map routine.  pbm_delta is the offset of the
- * desired data from the beginning of the mapping.
- *
- * When a request is made to read beyond the logical end of the object,
- * pbm_size may be set to 0, but pbm_offset and pbm_length should be set to
- * the actual amount of underlying storage that has been allocated, if any.
- */
-
-typedef struct page_buf_bmap_s {
-	page_buf_daddr_t pbm_bn;	/* block number in file system	    */
-	pb_target_t	*pbm_target;	/* device to do I/O to		    */
-	loff_t		pbm_offset;	/* byte offset of mapping in file   */
-	size_t		pbm_delta;	/* offset of request into bmap	    */
-	size_t		pbm_bsize;	/* size of this mapping in bytes    */
-	bmap_flags_t	pbm_flags;	/* options flags for mapping	    */
-} page_buf_bmap_t;
-
-typedef page_buf_bmap_t pb_bmap_t;
-
-
-/*
  *	page_buf_t:  Buffer structure for page cache-based buffers
  *
  * This buffer structure is used by the page cache buffer management routines
@@ -381,4 +322,19 @@ extern void pagebuf_delwri_dequeue(
 extern int pagebuf_init(void);
 extern void pagebuf_terminate(void);
 
+
+#ifdef PAGEBUF_TRACE
+extern ktrace_t *pagebuf_trace_buf;
+extern void pagebuf_trace(
+		page_buf_t *,		/* buffer being traced		*/
+		char *,			/* description of operation	*/
+		void *,			/* arbitrary diagnostic value	*/
+		void *);		/* return address		*/
+#else
+# define pagebuf_trace(pb, id, ptr, ra)	do { } while (0)
+#endif
+
+#define pagebuf_target_name(target)	\
+	({ char __b[BDEVNAME_SIZE]; bdevname((target)->pbr_bdev, __b); __b; })
+
 #endif /* __PAGE_BUF_H__ */
diff -puN -L fs/xfs/pagebuf/page_buf_internal.h fs/xfs/pagebuf/page_buf_internal.h~linus /dev/null
--- 25/fs/xfs/pagebuf/page_buf_internal.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 2002 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-/*
- * Written by Steve Lord at SGI
- */
-
-#ifndef __PAGE_BUF_PRIVATE_H__
-#define __PAGE_BUF_PRIVATE_H__
-
-#include <linux/percpu.h>
-#include "page_buf.h"
-
-#define _PAGE_BUF_INTERNAL_
-#define PB_DEFINE_TRACES
-#include "page_buf_trace.h"
-
-#ifdef PAGEBUF_LOCK_TRACKING
-#define PB_SET_OWNER(pb)	(pb->pb_last_holder = current->pid)
-#define PB_CLEAR_OWNER(pb)	(pb->pb_last_holder = -1)
-#define PB_GET_OWNER(pb)	(pb->pb_last_holder)
-#else
-#define PB_SET_OWNER(pb)
-#define PB_CLEAR_OWNER(pb)
-#define PB_GET_OWNER(pb)
-#endif /* PAGEBUF_LOCK_TRACKING */
-
-/* Tracing utilities for pagebuf */
-typedef struct {
-	int			event;
-	unsigned long		pb;
-	page_buf_flags_t	flags;
-	unsigned short		hold;
-	unsigned short		lock_value;
-	void			*task;
-	void			*misc;
-	void			*ra;
-	loff_t			offset;
-	size_t			size;
-} pagebuf_trace_t;
-
-struct pagebuf_trace_buf {
-	pagebuf_trace_t		*buf;
-	volatile int		start;
-	volatile int		end;
-};
-
-#define PB_TRACE_BUFSIZE	1024
-#define CIRC_INC(i)     (((i) + 1) & (PB_TRACE_BUFSIZE - 1))
-
-/*
- * Tunable pagebuf parameters
- */
-
-typedef struct pb_sysctl_val {
-	int min;
-	int val;
-	int max;
-} pb_sysctl_val_t;
-
-typedef struct pagebuf_param {
-	pb_sysctl_val_t	flush_interval;	/* interval between runs of the
-					 * delwri flush daemon.  */
-	pb_sysctl_val_t	age_buffer;	/* time for buffer to age before
-					 * we flush it.  */
-	pb_sysctl_val_t	stats_clear;	/* clear the pagebuf stats */
-	pb_sysctl_val_t	debug;		/* debug tracing on or off */
-} pagebuf_param_t;
-
-enum {
-	PB_FLUSH_INT = 1,
-	PB_FLUSH_AGE = 2,
-	PB_STATS_CLEAR = 3,
-	PB_DEBUG = 4
-};
-
-extern pagebuf_param_t	pb_params;
-
-/*
- * Pagebuf statistics
- */
-
-struct pbstats {
-	u_int32_t	pb_get;
-	u_int32_t	pb_create;
-	u_int32_t	pb_get_locked;
-	u_int32_t	pb_get_locked_waited;
-	u_int32_t	pb_busy_locked;
-	u_int32_t	pb_miss_locked;
-	u_int32_t	pb_page_retries;
-	u_int32_t	pb_page_found;
-	u_int32_t	pb_get_read;
-};
-
-DECLARE_PER_CPU(struct pbstats, pbstats);
-
-/* We don't disable preempt, not too worried about poking the
- * wrong cpu's stat for now */
-#define PB_STATS_INC(count)	(__get_cpu_var(pbstats).count++)
-
-#ifndef STATIC
-# define STATIC	static
-#endif
-
-#endif /* __PAGE_BUF_PRIVATE_H__ */
diff -puN -L fs/xfs/pagebuf/page_buf_locking.c fs/xfs/pagebuf/page_buf_locking.c~linus /dev/null
--- 25/fs/xfs/pagebuf/page_buf_locking.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,139 +0,0 @@
-/*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-/*
- *	page_buf_locking.c
- *
- *	The page_buf module provides an abstract buffer cache model on top of
- *	the Linux page cache.  Cached metadata blocks for a file system are
- *	hashed to the inode for the block device.  The page_buf module
- *	assembles buffer (page_buf_t) objects on demand to aggregate such
- *	cached pages for I/O.  The page_buf_locking module adds support for
- *	locking such page buffers.
- *
- *      Written by Steve Lord at SGI
- *
- */
-
-#include <linux/stddef.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/bitops.h>
-#include <linux/string.h>
-#include <linux/pagemap.h>
-#include <linux/init.h>
-#include <linux/major.h>
-
-#include <support/debug.h>
-
-#include "page_buf_internal.h"
-
-/*
- *	pagebuf_cond_lock
- *
- *	pagebuf_cond_lock locks a buffer object, if it is not already locked.
- *	Note that this in no way
- *	locks the underlying pages, so it is only useful for synchronizing
- *	concurrent use of page buffer objects, not for synchronizing independent
- *	access to the underlying pages.
- */
-int
-pagebuf_cond_lock(			/* lock buffer, if not locked	*/
-					/* returns -EBUSY if locked)	*/
-	page_buf_t		*pb)
-{
-	int			locked;
-
-	ASSERT(pb->pb_flags & _PBF_LOCKABLE);
-
-	locked = down_trylock(&pb->pb_sema) == 0;
-	if (locked) {
-		PB_SET_OWNER(pb);
-	}
-
-	PB_TRACE(pb, PB_TRACE_REC(condlck), locked);
-
-	return(locked ? 0 : -EBUSY);
-}
-
-/*
- *	pagebuf_lock_value
- *
- *	Return lock value for a pagebuf
- */
-int
-pagebuf_lock_value(
-	page_buf_t		*pb)
-{
-	ASSERT(pb->pb_flags & _PBF_LOCKABLE);
-	return(atomic_read(&pb->pb_sema.count));
-}
-
-/*
- *	pagebuf_lock
- *
- *	pagebuf_lock locks a buffer object.  Note that this in no way
- *	locks the underlying pages, so it is only useful for synchronizing
- *	concurrent use of page buffer objects, not for synchronizing independent
- *	access to the underlying pages.
- */
-int
-pagebuf_lock(
-	page_buf_t		*pb)
-{
-	ASSERT(pb->pb_flags & _PBF_LOCKABLE);
-
-	PB_TRACE(pb, PB_TRACE_REC(lock), 0);
-	if (atomic_read(&pb->pb_io_remaining))
-		blk_run_queues();
-	down(&pb->pb_sema);
-	PB_SET_OWNER(pb);
-	PB_TRACE(pb, PB_TRACE_REC(locked), 0);
-	return 0;
-}
-
-/*
- *	pagebuf_unlock
- *
- *	pagebuf_unlock releases the lock on the buffer object created by
- *	pagebuf_lock or pagebuf_cond_lock (not any
- *	pinning of underlying pages created by pagebuf_pin).
- */
-void
-pagebuf_unlock(				/* unlock buffer		*/
-	page_buf_t		*pb)	/* buffer to unlock		*/
-{
-	ASSERT(pb->pb_flags & _PBF_LOCKABLE);
-	PB_CLEAR_OWNER(pb);
-	up(&pb->pb_sema);
-	PB_TRACE(pb, PB_TRACE_REC(unlock), 0);
-}
diff -puN -L fs/xfs/pagebuf/page_buf_trace.h fs/xfs/pagebuf/page_buf_trace.h~linus /dev/null
--- 25/fs/xfs/pagebuf/page_buf_trace.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#ifndef __PAGEBUF_TRACE__
-#define __PAGEBUF_TRACE__
-
-#ifdef PB_DEFINE_TRACES
-#define PB_TRACE_START	typedef enum {
-#define PB_TRACE_REC(x)	pb_trace_point_##x
-#define PB_TRACE_END	} pb_trace_var_t;
-#else
-#define PB_TRACE_START	static char	*event_names[] = {
-#define PB_TRACE_REC(x)	#x
-#define PB_TRACE_END	};
-#endif
-
-PB_TRACE_START
-PB_TRACE_REC(get),
-PB_TRACE_REC(get_obj),
-PB_TRACE_REC(free_obj),
-PB_TRACE_REC(look_pg),
-PB_TRACE_REC(get_read),
-PB_TRACE_REC(no_daddr),
-PB_TRACE_REC(hold),
-PB_TRACE_REC(rele),
-PB_TRACE_REC(done),
-PB_TRACE_REC(ioerror),
-PB_TRACE_REC(iostart),
-PB_TRACE_REC(end_io),
-PB_TRACE_REC(do_io),
-PB_TRACE_REC(ioreq),
-PB_TRACE_REC(iowait),
-PB_TRACE_REC(iowaited),
-PB_TRACE_REC(free_lk),
-PB_TRACE_REC(freed_l),
-PB_TRACE_REC(cmp),
-PB_TRACE_REC(get_lk),
-PB_TRACE_REC(got_lk),
-PB_TRACE_REC(skip),
-PB_TRACE_REC(lock),
-PB_TRACE_REC(locked),
-PB_TRACE_REC(unlock),
-PB_TRACE_REC(avl_ret),
-PB_TRACE_REC(condlck),
-PB_TRACE_REC(avl_ins),
-PB_TRACE_REC(walkq1),
-PB_TRACE_REC(walkq2),
-PB_TRACE_REC(walkq3),
-PB_TRACE_REC(delwri_q),
-PB_TRACE_REC(delwri_uq),
-PB_TRACE_REC(pin),
-PB_TRACE_REC(unpin),
-PB_TRACE_REC(file_write),
-PB_TRACE_REC(external),
-PB_TRACE_END
-
-extern void pb_trace_func(page_buf_t *, int, void *, void *);
-#ifdef PAGEBUF_TRACE
-# define PB_TRACE(pb, event, misc)		\
-	pb_trace_func(pb, event, (void *) misc,	\
-			(void *)__builtin_return_address(0))
-#else
-# define PB_TRACE(pb, event, misc)	do { } while (0)
-#endif
-
-#endif	/* __PAGEBUF_TRACE__ */
diff -puN fs/xfs/quota/xfs_dquot.c~linus fs/xfs/quota/xfs_dquot.c
--- 25/fs/xfs/quota/xfs_dquot.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/quota/xfs_dquot.c	2004-01-19 22:17:24.000000000 -0800
@@ -124,7 +124,7 @@ xfs_qm_dqinit(
 		initnsema(&dqp->q_flock, 1, "fdq");
 		sv_init(&dqp->q_pinwait, SV_DEFAULT, "pdq");
 
-#ifdef DQUOT_TRACING
+#ifdef XFS_DQUOT_TRACE
 		dqp->q_trace = ktrace_alloc(DQUOT_TRACE_SIZE, KM_SLEEP);
 		xfs_dqtrace_entry(dqp, "DQINIT");
 #endif
@@ -148,7 +148,7 @@ xfs_qm_dqinit(
 		 dqp->q_hash = 0;
 		 ASSERT(dqp->dq_flnext == dqp->dq_flprev);
 
-#ifdef DQUOT_TRACING
+#ifdef XFS_DQUOT_TRACE
 		 ASSERT(dqp->q_trace);
 		 xfs_dqtrace_entry(dqp, "DQRECLAIMED_INIT");
 #endif
@@ -173,7 +173,7 @@ xfs_qm_dqdestroy(
 	freesema(&dqp->q_flock);
 	sv_destroy(&dqp->q_pinwait);
 
-#ifdef DQUOT_TRACING
+#ifdef XFS_DQUOT_TRACE
 	if (dqp->q_trace)
 	     ktrace_free(dqp->q_trace);
 	dqp->q_trace = NULL;
@@ -201,20 +201,20 @@ xfs_qm_dqinit_core(
 }
 
 
-#ifdef DQUOT_TRACING
+#ifdef XFS_DQUOT_TRACE
 /*
  * Dquot tracing for debugging.
  */
 /* ARGSUSED */
 void
-xfs_dqtrace_entry__(
-	xfs_dquot_t *dqp,
-	char *func,
-	void *retaddr,
-	xfs_inode_t *ip)
+__xfs_dqtrace_entry(
+	xfs_dquot_t	*dqp,
+	char		*func,
+	void		*retaddr,
+	xfs_inode_t	*ip)
 {
-	xfs_dquot_t *udqp = NULL;
-	int ino;
+	xfs_dquot_t	*udqp = NULL;
+	xfs_ino_t	ino = 0;
 
 	ASSERT(dqp->q_trace);
 	if (ip) {
@@ -227,13 +227,19 @@ xfs_dqtrace_entry__(
 		     (void *)(__psint_t)dqp->q_nrefs,
 		     (void *)(__psint_t)dqp->dq_flags,
 		     (void *)(__psint_t)dqp->q_res_bcount,
-		     (void *)(__psint_t)INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT),
-		     (void *)(__psint_t)INT_GET(dqp->q_core.d_icount, ARCH_CONVERT),
-		     (void *)(__psint_t)INT_GET(dqp->q_core.d_blk_hardlimit, ARCH_CONVERT),
-		     (void *)(__psint_t)INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT),
-		     (void *)(__psint_t)INT_GET(dqp->q_core.d_ino_hardlimit, ARCH_CONVERT),
-		     (void *)(__psint_t)INT_GET(dqp->q_core.d_ino_softlimit, ARCH_CONVERT),
-		     (void *)(__psint_t)INT_GET(dqp->q_core.d_id, ARCH_CONVERT), /* 11 */
+		     (void *)(__psint_t)INT_GET(dqp->q_core.d_bcount,
+						ARCH_CONVERT),
+		     (void *)(__psint_t)INT_GET(dqp->q_core.d_icount,
+						ARCH_CONVERT),
+		     (void *)(__psint_t)INT_GET(dqp->q_core.d_blk_hardlimit,
+						ARCH_CONVERT),
+		     (void *)(__psint_t)INT_GET(dqp->q_core.d_blk_softlimit,
+						ARCH_CONVERT),
+		     (void *)(__psint_t)INT_GET(dqp->q_core.d_ino_hardlimit,
+						ARCH_CONVERT),
+		     (void *)(__psint_t)INT_GET(dqp->q_core.d_ino_softlimit,
+						ARCH_CONVERT),
+		     (void *)(__psint_t)INT_GET(dqp->q_core.d_id, ARCH_CONVERT),
 		     (void *)(__psint_t)current_pid(),
 		     (void *)(__psint_t)ino,
 		     (void *)(__psint_t)retaddr,
@@ -751,7 +757,6 @@ xfs_qm_idtodq(
 	}
 
 	*O_dqpp = dqp;
-	ASSERT(! XFS_DQ_IS_LOCKED(dqp));
 	return (0);
 
  error0:
@@ -1000,7 +1005,6 @@ xfs_qm_dqget(
 	/*
 	 * Dquot lock comes after hashlock in the lock ordering
 	 */
-	ASSERT(! XFS_DQ_IS_LOCKED(dqp));
 	if (ip) {
 		xfs_ilock(ip, XFS_ILOCK_EXCL);
 		if (! XFS_IS_DQTYPE_ON(mp, type)) {
@@ -1504,7 +1508,7 @@ xfs_qm_dqpurge(
 	 */
 	ASSERT(XFS_DQ_IS_ON_FREELIST(dqp));
 
-	dqp->q_mount = NULL;;
+	dqp->q_mount = NULL;
 	dqp->q_hash = NULL;
 	dqp->dq_flags = XFS_DQ_INACTIVE;
 	memset(&dqp->q_core, 0, sizeof(dqp->q_core));
diff -puN fs/xfs/quota/xfs_dquot.h~linus fs/xfs/quota/xfs_dquot.h
--- 25/fs/xfs/quota/xfs_dquot.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/quota/xfs_dquot.h	2004-01-19 22:17:24.000000000 -0800
@@ -99,7 +99,7 @@ typedef struct xfs_dquot {
 	sema_t		 q_flock;	/* flush lock */
 	uint		 q_pincount;	/* pin count for this dquot */
 	sv_t		 q_pinwait;	/* sync var for pinning */
-#ifdef DQUOT_TRACING
+#ifdef XFS_DQUOT_TRACE
 	struct ktrace	*q_trace;	/* trace header structure */
 #endif
 } xfs_dquot_t;
@@ -175,23 +175,25 @@ XFS_DQ_IS_LOCKED(xfs_dquot_t *dqp)
 #define XFS_IS_THIS_QUOTA_OFF(d) (! (XFS_QM_ISUDQ(d) ? \
 				     (XFS_IS_UQUOTA_ON((d)->q_mount)) : \
 				     (XFS_IS_GQUOTA_ON((d)->q_mount))))
-#ifdef DQUOT_TRACING
+
+#ifdef XFS_DQUOT_TRACE
 /*
  * Dquot Tracing stuff.
  */
 #define DQUOT_TRACE_SIZE	64
 #define DQUOT_KTRACE_ENTRY	1
 
+extern void		__xfs_dqtrace_entry(xfs_dquot_t *dqp, char *func,
+					    void *, xfs_inode_t *);
 #define xfs_dqtrace_entry_ino(a,b,ip) \
-xfs_dqtrace_entry__((a), (b), (void*)__return_address, (ip))
+		__xfs_dqtrace_entry((a), (b), (void*)__return_address, (ip))
 #define xfs_dqtrace_entry(a,b) \
-xfs_dqtrace_entry__((a), (b), (void*)__return_address, NULL)
-extern void		xfs_dqtrace_entry__(xfs_dquot_t *dqp, char *func,
-					    void *, xfs_inode_t *);
+		__xfs_dqtrace_entry((a), (b), (void*)__return_address, NULL)
 #else
 #define xfs_dqtrace_entry(a,b)
 #define xfs_dqtrace_entry_ino(a,b,ip)
 #endif
+
 #ifdef QUOTADEBUG
 extern void		xfs_qm_dqprint(xfs_dquot_t *);
 #else
diff -puN fs/xfs/quota/xfs_qm.c~linus fs/xfs/quota/xfs_qm.c
--- 25/fs/xfs/quota/xfs_qm.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/quota/xfs_qm.c	2004-01-19 22:17:24.000000000 -0800
@@ -82,6 +82,7 @@ EXPORT_SYMBOL(xfs_Gqm);	/* used by xfsid
 
 kmem_zone_t	*qm_dqzone;
 kmem_zone_t	*qm_dqtrxzone;
+kmem_shaker_t	xfs_qm_shaker;
 
 STATIC void	xfs_qm_list_init(xfs_dqlist_t *, char *, int);
 STATIC void	xfs_qm_list_destroy(xfs_dqlist_t *);
@@ -112,8 +113,6 @@ extern mutex_t	qcheck_lock;
 #define XQM_LIST_PRINT(l, NXT, title) do { } while (0)
 #endif
 
-struct shrinker *xfs_qm_shrinker;
-
 /*
  * Initialize the XQM structure.
  * Note that there is not one quota manager per file system.
@@ -163,7 +162,7 @@ xfs_Gqm_init(void)
 	} else
 		xqm->qm_dqzone = qm_dqzone;
 
-	xfs_qm_shrinker = set_shrinker(DEFAULT_SEEKS, xfs_qm_shake);
+	xfs_qm_shaker = kmem_shake_register(xfs_qm_shake);
 
 	/*
 	 * The t_dqinfo portion of transactions.
@@ -195,8 +194,7 @@ xfs_qm_destroy(
 
 	ASSERT(xqm != NULL);
 	ASSERT(xqm->qm_nrefs == 0);
-
-	remove_shrinker(xfs_qm_shrinker);
+	kmem_shake_deregister(xfs_qm_shaker);
 	hsize = xqm->qm_dqhashmask + 1;
 	for (i = 0; i < hsize; i++) {
 		xfs_qm_list_destroy(&(xqm->qm_usr_dqhtable[i]));
@@ -806,7 +804,6 @@ xfs_qm_dqattach_one(
 	ASSERT(XFS_DQ_IS_LOCKED(dqp));
 	if (! dolock) {
 		xfs_dqunlock(dqp);
-		ASSERT(!udqhint || !XFS_DQ_IS_LOCKED(udqhint));
 		goto done;
 	}
 	if (! udqhint)
@@ -814,7 +811,6 @@ xfs_qm_dqattach_one(
 
 	ASSERT(udqhint);
 	ASSERT(dolock);
-	ASSERT(! XFS_DQ_IS_LOCKED(udqhint));
 	ASSERT(XFS_DQ_IS_LOCKED(dqp));
 	if (! xfs_qm_dqlock_nowait(udqhint)) {
 		xfs_dqunlock(dqp);
@@ -826,14 +822,10 @@ xfs_qm_dqattach_one(
 	if (udqhint) {
 		if (dolock)
 			ASSERT(XFS_DQ_IS_LOCKED(udqhint));
-		else
-			ASSERT(! XFS_DQ_IS_LOCKED(udqhint));
 	}
 	if (! error) {
 		if (dolock)
 			ASSERT(XFS_DQ_IS_LOCKED(dqp));
-		else
-			ASSERT(! XFS_DQ_IS_LOCKED(dqp));
 	}
 #endif
 	return (error);
@@ -860,9 +852,6 @@ xfs_qm_dqattach_grouphint(
 	if (locked) {
 		ASSERT(XFS_DQ_IS_LOCKED(udq));
 		ASSERT(XFS_DQ_IS_LOCKED(gdq));
-	} else {
-		ASSERT(! XFS_DQ_IS_LOCKED(udq));
-		ASSERT(! XFS_DQ_IS_LOCKED(gdq));
 	}
 #endif
 	if (! locked)
@@ -890,15 +879,12 @@ xfs_qm_dqattach_grouphint(
 		 */
 		xfs_qm_dqrele(tmp);
 
-		ASSERT(! XFS_DQ_IS_LOCKED(udq));
-		ASSERT(! XFS_DQ_IS_LOCKED(gdq));
 		xfs_dqlock(udq);
 		xfs_dqlock(gdq);
 
 	} else {
 		ASSERT(XFS_DQ_IS_LOCKED(udq));
 		if (! locked) {
-			ASSERT(! XFS_DQ_IS_LOCKED(gdq));
 			xfs_dqlock(gdq);
 		}
 	}
@@ -1006,14 +992,10 @@ xfs_qm_dqattach(
 		if (ip->i_udquot) {
 			if (flags & XFS_QMOPT_DQLOCK)
 				ASSERT(XFS_DQ_IS_LOCKED(ip->i_udquot));
-			else
-				ASSERT(! XFS_DQ_IS_LOCKED(ip->i_udquot));
 		}
 		if (ip->i_gdquot) {
 			if (flags & XFS_QMOPT_DQLOCK)
 				ASSERT(XFS_DQ_IS_LOCKED(ip->i_gdquot));
-			else
-				ASSERT(! XFS_DQ_IS_LOCKED(ip->i_gdquot));
 		}
 		if (XFS_IS_UQUOTA_ON(mp))
 			ASSERT(ip->i_udquot);
@@ -1756,7 +1738,10 @@ xfs_qm_dqusage_adjust(
 	xfs_trans_t	*tp,		/* transaction pointer - NULL */
 	xfs_ino_t	ino,		/* inode number to get data for */
 	void		*buffer,	/* not used */
+	int		ubsize,		/* not used */
+	void		*private_data,	/* not used */
 	xfs_daddr_t	bno,		/* starting block of inode cluster */
+	int		*ubused,	/* not used */
 	void		*dip,		/* on-disk inode pointer (not used) */
 	int		*res)		/* result code value */
 {
@@ -1920,7 +1905,7 @@ xfs_qm_quotacheck(
 		 * adjusting the corresponding dquot counters in core.
 		 */
 		if ((error = xfs_bulkstat(mp, NULL, &lastino, &count,
-				     xfs_qm_dqusage_adjust,
+				     xfs_qm_dqusage_adjust, NULL,
 				     structsz, NULL,
 				     BULKSTAT_FG_IGET|BULKSTAT_FG_VFSLOCKED,
 				     &done)))
@@ -2091,7 +2076,7 @@ xfs_qm_shake_freelist(
 			xfs_dqunlock(dqp);
 			xfs_qm_freelist_unlock(xfs_Gqm);
 			if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS)
-				goto out;
+				return (nreclaimed);
 			XQM_STATS_INC(xqmstats.xs_qm_dqwants);
 			goto tryagain;
 		}
@@ -2166,7 +2151,7 @@ xfs_qm_shake_freelist(
 			XFS_DQ_HASH_UNLOCK(hash);
 			xfs_qm_freelist_unlock(xfs_Gqm);
 			if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS)
-				goto out;
+				return (nreclaimed);
 			goto tryagain;
 		}
 		xfs_dqtrace_entry(dqp, "DQSHAKE: UNLINKING");
@@ -2191,14 +2176,12 @@ xfs_qm_shake_freelist(
 		dqp = nextdqp;
 	}
 	xfs_qm_freelist_unlock(xfs_Gqm);
- out:
-	return nreclaimed;
+	return (nreclaimed);
 }
 
 
 /*
- * The shake manager routine called by shaked() when memory is
- * running low.
+ * The kmem_shake interface is invoked when memory is running low.
  */
 /* ARGSUSED */
 STATIC int
@@ -2206,10 +2189,10 @@ xfs_qm_shake(int nr_to_scan, unsigned in
 {
 	int	ndqused, nfree, n;
 
-	if (!(gfp_mask & __GFP_WAIT))
-		return 0;
+	if (!kmem_shake_allow(gfp_mask))
+		return (0);
 	if (!xfs_Gqm)
-		return 0;
+		return (0);
 
 	nfree = xfs_Gqm->qm_dqfreelist.qh_nelems; /* free dquots */
 	/* incore dquots in all f/s's */
@@ -2218,7 +2201,7 @@ xfs_qm_shake(int nr_to_scan, unsigned in
 	ASSERT(ndqused >= 0);
 
 	if (nfree <= ndqused && nfree < ndquot)
-		return 0;
+		return (0);
 
 	ndqused *= xfs_Gqm->qm_dqfree_ratio;	/* target # of free dquots */
 	n = nfree - ndqused - ndquot;		/* # over target */
diff -puN fs/xfs/quota/xfs_qm_syscalls.c~linus fs/xfs/quota/xfs_qm_syscalls.c
--- 25/fs/xfs/quota/xfs_qm_syscalls.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/quota/xfs_qm_syscalls.c	2004-01-19 22:17:24.000000000 -0800
@@ -1301,7 +1301,10 @@ xfs_qm_internalqcheck_adjust(
 	xfs_trans_t	*tp,		/* transaction pointer */
 	xfs_ino_t	ino,		/* inode number to get data for */
 	void		*buffer,	/* not used */
+	int		ubsize,		/* not used */
+	void		*private_data,	/* not used */
 	xfs_daddr_t	bno,		/* starting block of inode cluster */
+	int		*ubused,	/* not used */
 	void		*dip,		/* not used */
 	int		*res)		/* bulkstat result code */
 {
@@ -1403,7 +1406,7 @@ xfs_qm_internalqcheck(
 		 * adjusting the corresponding dquot counters
 		 */
 		if ((error = xfs_bulkstat(mp, NULL, &lastino, &count,
-				 xfs_qm_internalqcheck_adjust,
+				 xfs_qm_internalqcheck_adjust, NULL,
 				 0, NULL, BULKSTAT_FG_IGET, &done))) {
 			break;
 		}
diff -puN fs/xfs/quota/xfs_trans_dquot.c~linus fs/xfs/quota/xfs_trans_dquot.c
--- 25/fs/xfs/quota/xfs_trans_dquot.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/quota/xfs_trans_dquot.c	2004-01-19 22:17:24.000000000 -0800
@@ -835,13 +835,6 @@ xfs_trans_reserve_quota_nblks(
 	ASSERT(ip->i_ino != mp->m_sb.sb_uquotino);
 	ASSERT(ip->i_ino != mp->m_sb.sb_gquotino);
 
-#ifdef QUOTADEBUG
-	if (ip->i_udquot)
-		ASSERT(! XFS_DQ_IS_LOCKED(ip->i_udquot));
-	if (ip->i_gdquot)
-		ASSERT(! XFS_DQ_IS_LOCKED(ip->i_gdquot));
-#endif
-
 	ASSERT(XFS_ISLOCKED_INODE_EXCL(ip));
 	ASSERT(XFS_IS_QUOTA_RUNNING(ip->i_mount));
 	ASSERT((type & ~XFS_QMOPT_FORCE_RES) == XFS_TRANS_DQ_RES_RTBLKS ||
diff -puN fs/xfs/support/debug.h~linus fs/xfs/support/debug.h
--- 25/fs/xfs/support/debug.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/support/debug.h	2004-01-19 22:17:24.000000000 -0800
@@ -44,6 +44,10 @@
 extern void icmn_err(int, char *, va_list);
 extern void cmn_err(int, char *, ...);
 
+#ifndef STATIC
+# define STATIC static
+#endif
+
 #ifdef DEBUG
 # ifdef lint
 #  define ASSERT(EX)	((void)0) /* avoid "constant in conditional" babble */
diff -puN fs/xfs/support/kmem.h~linus fs/xfs/support/kmem.h
--- 25/fs/xfs/support/kmem.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/support/kmem.h	2004-01-19 22:17:24.000000000 -0800
@@ -165,4 +165,25 @@ kmem_zone_free(kmem_zone_t *zone, void *
 	kmem_cache_free(zone, ptr);
 }
 
+typedef struct shrinker *kmem_shaker_t;
+typedef int (*kmem_shake_func_t)(int, unsigned int);
+
+static __inline kmem_shaker_t
+kmem_shake_register(kmem_shake_func_t sfunc)
+{
+	return set_shrinker(DEFAULT_SEEKS, sfunc);
+}
+
+static __inline void
+kmem_shake_deregister(kmem_shaker_t shrinker)
+{
+	remove_shrinker(shrinker);
+}
+
+static __inline int
+kmem_shake_allow(unsigned int gfp_mask)
+{
+	return (gfp_mask & __GFP_WAIT);
+}
+
 #endif /* __XFS_SUPPORT_KMEM_H__ */
diff -puN fs/xfs/support/ktrace.c~linus fs/xfs/support/ktrace.c
--- 25/fs/xfs/support/ktrace.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/support/ktrace.c	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -40,8 +40,6 @@
 #include "debug.h"
 #include "ktrace.h"
 
-#if	(defined(DEBUG) || defined(CONFIG_XFS_VNODE_TRACING))
-
 static kmem_zone_t *ktrace_hdr_zone;
 static kmem_zone_t *ktrace_ent_zone;
 static int          ktrace_zentries;
@@ -121,7 +119,6 @@ ktrace_alloc(int nentries, int sleep)
 	ktp->kt_nentries = nentries;
 	ktp->kt_index    = 0;
 	ktp->kt_rollover = 0;
-
 	return ktp;
 }
 
@@ -182,6 +179,7 @@ ktrace_enter(
 	void            *val15)
 {
 	static lock_t   wrap_lock = SPIN_LOCK_UNLOCKED;
+	unsigned long	flags;
 	int             index;
 	ktrace_entry_t  *ktep;
 
@@ -190,11 +188,11 @@ ktrace_enter(
 	/*
 	 * Grab an entry by pushing the index up to the next one.
 	 */
-	spin_lock(&wrap_lock);
+	spin_lock_irqsave(&wrap_lock, flags);
 	index = ktp->kt_index;
 	if (++ktp->kt_index == ktp->kt_nentries)
 		ktp->kt_index = 0;
-	spin_unlock(&wrap_lock);
+	spin_unlock_irqrestore(&wrap_lock, flags);
 
 	if (!ktp->kt_rollover && index == ktp->kt_nentries - 1)
 		ktp->kt_rollover = 1;
@@ -235,7 +233,6 @@ ktrace_nentries(
 	return (ktp->kt_rollover ? ktp->kt_nentries : ktp->kt_index);
 }
 
-
 /*
  * ktrace_first()
  *
@@ -276,7 +273,7 @@ ktrace_first(ktrace_t   *ktp, ktrace_sna
 	}
 	return ktep;
 }
-
+EXPORT_SYMBOL(ktrace_first);
 
 /*
  * ktrace_next()
@@ -311,11 +308,7 @@ ktrace_next(
 
 	return ktep;
 }
-
-#if	(defined(DEBUG) || defined(CONFIG_XFS_VNODE_TRACING))
-EXPORT_SYMBOL(ktrace_first);
 EXPORT_SYMBOL(ktrace_next);
-#endif
 
 /*
  * ktrace_skip()
@@ -323,7 +316,6 @@ EXPORT_SYMBOL(ktrace_next);
  * Skip the next "count" entries and return the entry after that.
  * Return NULL if this causes us to iterate past the beginning again.
  */
-
 ktrace_entry_t *
 ktrace_skip(
 	ktrace_t        *ktp,
@@ -362,18 +354,3 @@ ktrace_skip(
 	}
 	return ktep;
 }
-
-#else
-
-ktrace_t *
-ktrace_alloc(int nentries, int sleep)
-{
-	/*
-	 * KM_SLEEP callers don't expect failure.
-	 */
-	if (sleep & KM_SLEEP)
-		panic("ktrace_alloc: NULL memory on KM_SLEEP request!");
-
-	return NULL;
-}
-#endif
diff -puN fs/xfs/support/ktrace.h~linus fs/xfs/support/ktrace.h
--- 25/fs/xfs/support/ktrace.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/support/ktrace.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -32,6 +32,7 @@
 #ifndef __XFS_SUPPORT_KTRACE_H__
 #define __XFS_SUPPORT_KTRACE_H__
 
+#include <support/spin.h>
 
 /*
  * Trace buffer entry structure.
@@ -59,16 +60,13 @@ typedef struct ktrace_snap {
 	int		ks_index;	/* current index */
 } ktrace_snap_t;
 
-/*
- * Exported interfaces.
- */
-extern ktrace_t *ktrace_alloc(int, int);
 
-#if	(defined(DEBUG) || defined(CONFIG_XFS_VNODE_TRACING))
+#ifdef CONFIG_XFS_TRACE
 
 extern void ktrace_init(int zentries);
 extern void ktrace_uninit(void);
 
+extern ktrace_t *ktrace_alloc(int, int);
 extern void ktrace_free(ktrace_t *);
 
 extern void ktrace_enter(
@@ -96,10 +94,8 @@ extern ktrace_entry_t   *ktrace_next(ktr
 extern ktrace_entry_t   *ktrace_skip(ktrace_t *, int, ktrace_snap_t *);
 
 #else
+#define ktrace_init(x)	do { } while (0)
+#define ktrace_uninit()	do { } while (0)
+#endif	/* CONFIG_XFS_TRACE */
 
-#define	ktrace_free(ktp)
-#define	ktrace_enter(ktp,v0,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15)
-
-#endif
-
-#endif /* __XFS_SUPPORT_KTRACE_H__ */
+#endif	/* __XFS_SUPPORT_KTRACE_H__ */
diff -puN fs/xfs/support/qsort.c~linus fs/xfs/support/qsort.c
--- 25/fs/xfs/support/qsort.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/support/qsort.c	2004-01-19 22:17:24.000000000 -0800
@@ -1,243 +1,155 @@
-/* Copyright (C) 1991, 1992, 1996, 1997, 1999 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Written by Douglas C. Schmidt (schmidt@ics.uci.edu).
-
-   The GNU C 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.
-
-   The GNU C 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 the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-/* If you consider tuning this algorithm, you should consult first:
-   Engineering a sort function; Jon Bentley and M. Douglas McIlroy;
-   Software - Practice and Experience; Vol. 23 (11), 1249-1265, 1993.  */
+/*
+ * Copyright (c) 1992, 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.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * 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.
+ */
 
 #include <linux/kernel.h>
 #include <linux/string.h>
 
-/* Byte-wise swap two items of size SIZE. */
-#define SWAP(a, b, size)						      \
-  do									      \
-    {									      \
-      register size_t __size = (size);					      \
-      register char *__a = (a), *__b = (b);				      \
-      do								      \
-	{								      \
-	  char __tmp = *__a;						      \
-	  *__a++ = *__b;						      \
-	  *__b++ = __tmp;						      \
-	} while (--__size > 0);						      \
-    } while (0)
-
-/* Discontinue quicksort algorithm when partition gets below this size.
-   This particular magic number was chosen to work best on a Sun 4/260. */
-#define MAX_THRESH 4
-
-/* Stack node declarations used to store unfulfilled partition obligations. */
-typedef struct
-  {
-    char *lo;
-    char *hi;
-  } stack_node;
-
-/* The next 4 #defines implement a very fast in-line stack abstraction. */
-/* The stack needs log (total_elements) entries (we could even subtract
-   log(MAX_THRESH)).  Since total_elements has type size_t, we get as
-   upper bound for log (total_elements):
-   bits per byte (CHAR_BIT) * sizeof(size_t).  */
-#define STACK_SIZE	(8 * sizeof(unsigned long int))
-#define PUSH(low, high)	((void) ((top->lo = (low)), (top->hi = (high)), ++top))
-#define	POP(low, high)	((void) (--top, (low = top->lo), (high = top->hi)))
-#define	STACK_NOT_EMPTY	(stack < top)
-
-
-/* Order size using quicksort.  This implementation incorporates
-   four optimizations discussed in Sedgewick:
-
-   1. Non-recursive, using an explicit stack of pointer that store the
-      next array partition to sort.  To save time, this maximum amount
-      of space required to store an array of SIZE_MAX is allocated on the
-      stack.  Assuming a 32-bit (64 bit) integer for size_t, this needs
-      only 32 * sizeof(stack_node) == 256 bytes (for 64 bit: 1024 bytes).
-      Pretty cheap, actually.
-
-   2. Chose the pivot element using a median-of-three decision tree.
-      This reduces the probability of selecting a bad pivot value and
-      eliminates certain extraneous comparisons.
-
-   3. Only quicksorts TOTAL_ELEMS / MAX_THRESH partitions, leaving
-      insertion sort to order the MAX_THRESH items within each partition.
-      This is a big win, since insertion sort is faster for small, mostly
-      sorted array segments.
-
-   4. The larger of the two sub-partitions is always pushed onto the
-      stack first, with the algorithm then concentrating on the
-      smaller partition.  This *guarantees* no more than log (total_elems)
-      stack size is needed (actually O(1) in this case)!  */
+/*
+ * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
+ */
+#define swapcode(TYPE, parmi, parmj, n) { 		\
+	long i = (n) / sizeof (TYPE); 			\
+	register TYPE *pi = (TYPE *) (parmi); 		\
+	register TYPE *pj = (TYPE *) (parmj); 		\
+	do { 						\
+		register TYPE	t = *pi;		\
+		*pi++ = *pj;				\
+		*pj++ = t;				\
+        } while (--i > 0);				\
+}
 
-void
-qsort (void *const pbase, size_t total_elems, size_t size,
-       int (*cmp)(const void *, const void *))
+#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \
+	es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;
+
+static __inline void
+swapfunc(char *a, char *b, int n, int swaptype)
 {
-  register char *base_ptr = (char *) pbase;
+	if (swaptype <= 1) 
+		swapcode(long, a, b, n)
+	else
+		swapcode(char, a, b, n)
+}
 
-  const size_t max_thresh = MAX_THRESH * size;
+#define swap(a, b)					\
+	if (swaptype == 0) {				\
+		long t = *(long *)(a);			\
+		*(long *)(a) = *(long *)(b);		\
+		*(long *)(b) = t;			\
+	} else						\
+		swapfunc(a, b, es, swaptype)
 
-  if (total_elems == 0)
-    /* Avoid lossage with unsigned arithmetic below.  */
-    return;
-
-  if (total_elems > MAX_THRESH)
-    {
-      char *lo = base_ptr;
-      char *hi = &lo[size * (total_elems - 1)];
-      stack_node stack[STACK_SIZE];
-      stack_node *top = stack + 1;
-
-      while (STACK_NOT_EMPTY)
-	{
-	  char *left_ptr;
-	  char *right_ptr;
-
-	  /* Select median value from among LO, MID, and HI. Rearrange
-	     LO and HI so the three values are sorted. This lowers the
-	     probability of picking a pathological pivot value and
-	     skips a comparison for both the LEFT_PTR and RIGHT_PTR in
-	     the while loops. */
-
-	  char *mid = lo + size * ((hi - lo) / size >> 1);
-
-	  if ((*cmp) ((void *) mid, (void *) lo) < 0)
-	    SWAP (mid, lo, size);
-	  if ((*cmp) ((void *) hi, (void *) mid) < 0)
-	    SWAP (mid, hi, size);
-	  else
-	    goto jump_over;
-	  if ((*cmp) ((void *) mid, (void *) lo) < 0)
-	    SWAP (mid, lo, size);
-	jump_over:;
-
-	  left_ptr  = lo + size;
-	  right_ptr = hi - size;
-
-	  /* Here's the famous ``collapse the walls'' section of quicksort.
-	     Gotta like those tight inner loops!  They are the main reason
-	     that this algorithm runs much faster than others. */
-	  do
-	    {
-	      while ((*cmp) ((void *) left_ptr, (void *) mid) < 0)
-		left_ptr += size;
-
-	      while ((*cmp) ((void *) mid, (void *) right_ptr) < 0)
-		right_ptr -= size;
-
-	      if (left_ptr < right_ptr)
-		{
-		  SWAP (left_ptr, right_ptr, size);
-		  if (mid == left_ptr)
-		    mid = right_ptr;
-		  else if (mid == right_ptr)
-		    mid = left_ptr;
-		  left_ptr += size;
-		  right_ptr -= size;
-		}
-	      else if (left_ptr == right_ptr)
-		{
-		  left_ptr += size;
-		  right_ptr -= size;
-		  break;
+#define vecswap(a, b, n) 	if ((n) > 0) swapfunc(a, b, n, swaptype)
+
+static __inline char *
+med3(char *a, char *b, char *c, int (*cmp)(const void *, const void *))
+{
+	return cmp(a, b) < 0 ?
+	       (cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a ))
+              :(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c ));
+}
+
+void
+qsort(void *aa, size_t n, size_t es, int (*cmp)(const void *, const void *))
+{
+	char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
+	int d, r, swaptype, swap_cnt;
+	register char *a = aa;
+
+loop:	SWAPINIT(a, es);
+	swap_cnt = 0;
+	if (n < 7) {
+		for (pm = (char *)a + es; pm < (char *) a + n * es; pm += es)
+			for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0;
+			     pl -= es)
+				swap(pl, pl - es);
+		return;
+	}
+	pm = (char *)a + (n / 2) * es;
+	if (n > 7) {
+		pl = (char *)a;
+		pn = (char *)a + (n - 1) * es;
+		if (n > 40) {
+			d = (n / 8) * es;
+			pl = med3(pl, pl + d, pl + 2 * d, cmp);
+			pm = med3(pm - d, pm, pm + d, cmp);
+			pn = med3(pn - 2 * d, pn - d, pn, cmp);
 		}
-	    }
-	  while (left_ptr <= right_ptr);
+		pm = med3(pl, pm, pn, cmp);
+	}
+	swap(a, pm);
+	pa = pb = (char *)a + es;
 
-	  /* Set up pointers for next iteration.  First determine whether
-	     left and right partitions are below the threshold size.  If so,
-	     ignore one or both.  Otherwise, push the larger partition's
-	     bounds on the stack and continue sorting the smaller one. */
-
-	  if ((size_t) (right_ptr - lo) <= max_thresh)
-	    {
-	      if ((size_t) (hi - left_ptr) <= max_thresh)
-		/* Ignore both small partitions. */
-		POP (lo, hi);
-	      else
-		/* Ignore small left partition. */
-		lo = left_ptr;
-	    }
-	  else if ((size_t) (hi - left_ptr) <= max_thresh)
-	    /* Ignore small right partition. */
-	    hi = right_ptr;
-	  else if ((right_ptr - lo) > (hi - left_ptr))
-	    {
-	      /* Push larger left partition indices. */
-	      PUSH (lo, right_ptr);
-	      lo = left_ptr;
-	    }
-	  else
-	    {
-	      /* Push larger right partition indices. */
-	      PUSH (left_ptr, hi);
-	      hi = right_ptr;
-	    }
+	pc = pd = (char *)a + (n - 1) * es;
+	for (;;) {
+		while (pb <= pc && (r = cmp(pb, a)) <= 0) {
+			if (r == 0) {
+				swap_cnt = 1;
+				swap(pa, pb);
+				pa += es;
+			}
+			pb += es;
+		}
+		while (pb <= pc && (r = cmp(pc, a)) >= 0) {
+			if (r == 0) {
+				swap_cnt = 1;
+				swap(pc, pd);
+				pd -= es;
+			}
+			pc -= es;
+		}
+		if (pb > pc)
+			break;
+		swap(pb, pc);
+		swap_cnt = 1;
+		pb += es;
+		pc -= es;
+	}
+	if (swap_cnt == 0) {  /* Switch to insertion sort */
+		for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es)
+			for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0; 
+			     pl -= es)
+				swap(pl, pl - es);
+		return;
 	}
-    }
 
-  /* Once the BASE_PTR array is partially sorted by quicksort the rest
-     is completely sorted using insertion sort, since this is efficient
-     for partitions below MAX_THRESH size. BASE_PTR points to the beginning
-     of the array to sort, and END_PTR points at the very last element in
-     the array (*not* one beyond it!). */
-  {
-    char *const end_ptr = &base_ptr[size * (total_elems - 1)];
-    char *tmp_ptr = base_ptr;
-    char *const thresh = min_t(char *const, end_ptr, base_ptr + max_thresh);
-    register char *run_ptr;
-
-    /* Find smallest element in first threshold and place it at the
-       array's beginning.  This is the smallest array element,
-       and the operation speeds up insertion sort's inner loop. */
-
-    for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size)
-      if ((*cmp) ((void *) run_ptr, (void *) tmp_ptr) < 0)
-	tmp_ptr = run_ptr;
-
-    if (tmp_ptr != base_ptr)
-      SWAP (tmp_ptr, base_ptr, size);
-
-    /* Insertion sort, running from left-hand-side up to right-hand-side.  */
-
-    run_ptr = base_ptr + size;
-    while ((run_ptr += size) <= end_ptr)
-      {
-	tmp_ptr = run_ptr - size;
-	while ((*cmp) ((void *) run_ptr, (void *) tmp_ptr) < 0)
-	  tmp_ptr -= size;
-
-	tmp_ptr += size;
-	if (tmp_ptr != run_ptr)
-	  {
-	    char *trav;
-
-	    trav = run_ptr + size;
-	    while (--trav >= run_ptr)
-	      {
-		char c = *trav;
-		char *hi, *lo;
-
-		for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo)
-		  *hi = *lo;
-		*hi = c;
-	      }
-	  }
-      }
-  }
+	pn = (char *)a + n * es;
+	r = min(pa - (char *)a, pb - pa);
+	vecswap(a, pb - r, r);
+	r = min((long)(pd - pc), (long)(pn - pd - es));
+	vecswap(pb, pn - r, r);
+	if ((r = pb - pa) > es)
+		qsort(a, r / es, es, cmp);
+	if ((r = pd - pc) > es) { 
+		/* Iterate rather than recurse to save stack space */
+		a = pn - r;
+		n = r / es;
+		goto loop;
+	}
+/*		qsort(pn - r, r / es, es, cmp);*/
 }
diff -puN fs/xfs/xfs_acl.h~linus fs/xfs/xfs_acl.h
--- 25/fs/xfs/xfs_acl.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_acl.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001-2002 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2001-2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -102,6 +102,8 @@ extern struct kmem_zone *xfs_acl_zone;
 #define xfs_acl_vset(v,p,sz,t)	(-EOPNOTSUPP)
 #define xfs_acl_vget(v,p,sz,t)	(-EOPNOTSUPP)
 #define xfs_acl_vremove(v,t)	(-EOPNOTSUPP)
+#define xfs_acl_vhasacl_access(v)	(0)
+#define xfs_acl_vhasacl_default(v)	(0)
 #define _ACL_DECL(a)		((void)0)
 #define _ACL_ALLOC(a)		(1)	/* successfully allocate nothing */
 #define _ACL_FREE(a)		((void)0)
diff -puN fs/xfs/xfs_alloc.c~linus fs/xfs/xfs_alloc.c
--- 25/fs/xfs/xfs_alloc.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_alloc.c	2004-01-19 22:17:24.000000000 -0800
@@ -54,13 +54,6 @@
 #include "xfs_error.h"
 
 
-#if defined(DEBUG)
-/*
- * Allocation tracing.
- */
-ktrace_t	*xfs_alloc_trace_buf;
-#endif
-
 #define XFS_ABSDIFF(a,b)	(((a) <= (b)) ? ((b) - (a)) : ((a) - (b)))
 
 #define	XFSA_FIXUP_BNO_OK	1
@@ -73,6 +66,8 @@ xfs_alloc_search_busy(xfs_trans_t *tp,
 		    xfs_extlen_t len);
 
 #if defined(XFS_ALLOC_TRACE)
+ktrace_t *xfs_alloc_trace_buf;
+
 #define	TRACE_ALLOC(s,a)	\
 	xfs_alloc_trace_alloc(fname, s, a, __LINE__)
 #define	TRACE_FREE(s,a,b,x,f)	\
@@ -85,8 +80,6 @@ xfs_alloc_search_busy(xfs_trans_t *tp,
 	xfs_alloc_trace_busy(fname, s, mp, ag, -1, -1, sl, tp, XFS_ALLOC_KTRACE_UNBUSY, __LINE__)
 #define	TRACE_BUSYSEARCH(fname,s,ag,agb,l,sl,tp)	\
 	xfs_alloc_trace_busy(fname, s, mp, ag, agb, l, sl, tp, XFS_ALLOC_KTRACE_BUSYSEARCH, __LINE__)
-
-
 #else
 #define	TRACE_ALLOC(s,a)
 #define	TRACE_FREE(s,a,b,x,f)
diff -puN fs/xfs/xfs_alloc.h~linus fs/xfs/xfs_alloc.h
--- 25/fs/xfs/xfs_alloc.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_alloc.h	2004-01-19 22:17:24.000000000 -0800
@@ -95,6 +95,13 @@ typedef struct xfs_alloc_arg {
 
 #ifdef __KERNEL__
 
+#if defined(XFS_ALLOC_TRACE)
+/*
+ * Allocation tracing buffer size.
+ */
+#define	XFS_ALLOC_TRACE_SIZE	4096
+extern ktrace_t *xfs_alloc_trace_buf;
+
 /*
  * Types for alloc tracing.
  */
@@ -104,26 +111,9 @@ typedef struct xfs_alloc_arg {
 #define	XFS_ALLOC_KTRACE_BUSY	4
 #define	XFS_ALLOC_KTRACE_UNBUSY	5
 #define	XFS_ALLOC_KTRACE_BUSYSEARCH	6
-
-
-/*
- * Allocation tracing buffer size.
- */
-#define	XFS_ALLOC_TRACE_SIZE	4096
-
-#ifdef	XFS_ALL_TRACE
-#define	XFS_ALLOC_TRACE
-#endif
-
-#if !defined(DEBUG)
-#undef	XFS_ALLOC_TRACE
 #endif
 
 /*
- * Prototypes for visible xfs_alloc.c routines
- */
-
-/*
  * Compute and fill in value of m_ag_maxlevels.
  */
 void
diff -puN fs/xfs/xfs_arch.h~linus fs/xfs/xfs_arch.h
--- 25/fs/xfs/xfs_arch.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_arch.h	2004-01-19 22:17:24.000000000 -0800
@@ -53,16 +53,18 @@
 
 #define ARCH_NOCONVERT 1
 #if __BYTE_ORDER == __LITTLE_ENDIAN
-#define ARCH_CONVERT   0
+# define ARCH_CONVERT	0
 #else
-#define ARCH_CONVERT   ARCH_NOCONVERT
+# define ARCH_CONVERT	ARCH_NOCONVERT
 #endif
 
 /* generic swapping macros */
 
+#ifndef HAVE_SWABMACROS
 #define INT_SWAP16(type,var) ((typeof(type))(__swab16((__u16)(var))))
 #define INT_SWAP32(type,var) ((typeof(type))(__swab32((__u32)(var))))
 #define INT_SWAP64(type,var) ((typeof(type))(__swab64((__u64)(var))))
+#endif
 
 #define INT_SWAP(type, var) \
     ((sizeof(type) == 8) ? INT_SWAP64(type,var) : \
diff -puN fs/xfs/xfs_attr.c~linus fs/xfs/xfs_attr.c
--- 25/fs/xfs/xfs_attr.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_attr.c	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -63,6 +63,7 @@
 #include "xfs_quota.h"
 #include "xfs_rw.h"
 #include "xfs_trans_space.h"
+#include "xfs_acl.h"
 
 /*
  * xfs_attr.c
@@ -2234,7 +2235,8 @@ xfs_attr_trace_l_c(char *where, struct x
 		(__psunsigned_t)context->count,
 		(__psunsigned_t)context->firstu,
 		(__psunsigned_t)
-			(context->count > 0)
+			((context->count > 0) &&
+			!(context->flags & (ATTR_KERNAMELS|ATTR_KERNOVAL)))
 				? (ATTR_ENTRY(context->alist,
 					      context->count-1)->a_valuelen)
 				: 0,
@@ -2262,7 +2264,8 @@ xfs_attr_trace_l_cn(char *where, struct 
 		(__psunsigned_t)context->count,
 		(__psunsigned_t)context->firstu,
 		(__psunsigned_t)
-			(context->count > 0)
+			((context->count > 0) &&
+			!(context->flags & (ATTR_KERNAMELS|ATTR_KERNOVAL)))
 				? (ATTR_ENTRY(context->alist,
 					      context->count-1)->a_valuelen)
 				: 0,
@@ -2290,7 +2293,8 @@ xfs_attr_trace_l_cb(char *where, struct 
 		(__psunsigned_t)context->count,
 		(__psunsigned_t)context->firstu,
 		(__psunsigned_t)
-			(context->count > 0)
+			((context->count > 0) &&
+			!(context->flags & (ATTR_KERNAMELS|ATTR_KERNOVAL)))
 				? (ATTR_ENTRY(context->alist,
 					      context->count-1)->a_valuelen)
 				: 0,
@@ -2318,7 +2322,8 @@ xfs_attr_trace_l_cl(char *where, struct 
 		(__psunsigned_t)context->count,
 		(__psunsigned_t)context->firstu,
 		(__psunsigned_t)
-			(context->count > 0)
+			((context->count > 0) &&
+			!(context->flags & (ATTR_KERNAMELS|ATTR_KERNOVAL)))
 				? (ATTR_ENTRY(context->alist,
 					      context->count-1)->a_valuelen)
 				: 0,
@@ -2353,3 +2358,307 @@ xfs_attr_trace_enter(int type, char *whe
 					 (void *)a14, (void *)a15);
 }
 #endif	/* XFS_ATTR_TRACE */
+
+
+/*========================================================================
+ * System (pseudo) namespace attribute interface routines.
+ *========================================================================*/
+
+STATIC int
+posix_acl_access_set(
+	vnode_t	*vp, char *name, void *data, size_t size, int xflags)
+{
+	return xfs_acl_vset(vp, data, size, _ACL_TYPE_ACCESS);
+}
+
+STATIC int
+posix_acl_access_remove(
+	struct vnode *vp, char *name, int xflags)
+{
+	return xfs_acl_vremove(vp, _ACL_TYPE_ACCESS);
+}
+
+STATIC int
+posix_acl_access_get(
+	vnode_t *vp, char *name, void *data, size_t size, int xflags)
+{
+	return xfs_acl_vget(vp, data, size, _ACL_TYPE_ACCESS);
+}
+
+STATIC int
+posix_acl_access_exists(
+	vnode_t *vp)
+{
+	return xfs_acl_vhasacl_access(vp);
+}
+
+STATIC int
+posix_acl_default_set(
+	vnode_t	*vp, char *name, void *data, size_t size, int xflags)
+{
+	return xfs_acl_vset(vp, data, size, _ACL_TYPE_DEFAULT);
+}
+
+STATIC int
+posix_acl_default_get(
+	vnode_t *vp, char *name, void *data, size_t size, int xflags)
+{
+	return xfs_acl_vget(vp, data, size, _ACL_TYPE_DEFAULT);
+}
+
+STATIC int
+posix_acl_default_remove(
+	struct vnode *vp, char *name, int xflags)
+{
+	return xfs_acl_vremove(vp, _ACL_TYPE_DEFAULT);
+}
+
+STATIC int
+posix_acl_default_exists(
+	vnode_t *vp)
+{
+	return xfs_acl_vhasacl_default(vp);
+}
+
+struct attrnames posix_acl_access = {
+	.attr_name	= "posix_acl_access",
+	.attr_namelen	= sizeof("posix_acl_access") - 1,
+	.attr_get	= posix_acl_access_get,
+	.attr_set	= posix_acl_access_set,
+	.attr_remove	= posix_acl_access_remove,
+	.attr_exists	= posix_acl_access_exists,
+};
+
+struct attrnames posix_acl_default = {
+	.attr_name	= "posix_acl_default",
+	.attr_namelen	= sizeof("posix_acl_default") - 1,
+	.attr_get	= posix_acl_default_get,
+	.attr_set	= posix_acl_default_set,
+	.attr_remove	= posix_acl_default_remove,
+	.attr_exists	= posix_acl_default_exists,
+};
+
+struct attrnames *attr_system_names[] =
+	{ &posix_acl_access, &posix_acl_default };
+
+
+/*========================================================================
+ * Namespace-prefix-style attribute name interface routines.
+ *========================================================================*/
+
+STATIC int
+attr_generic_set(
+	struct vnode *vp, char *name, void *data, size_t size, int xflags)
+{
+	int 	error;
+
+	VOP_ATTR_SET(vp, name, data, size, xflags, NULL, error);
+	return -error;
+}
+
+STATIC int
+attr_generic_get(
+	struct vnode *vp, char *name, void *data, size_t size, int xflags)
+{
+	int	error, asize = size;
+
+	VOP_ATTR_GET(vp, name, data, &asize, xflags, NULL, error);
+	if (!error)
+		return asize;
+	return -error;
+}
+
+STATIC int
+attr_generic_remove(
+	struct vnode *vp, char *name, int xflags)
+{
+	int	error;
+
+	VOP_ATTR_REMOVE(vp, name, xflags, NULL, error);
+	return -error;
+}
+
+STATIC int
+attr_generic_listadd(
+	attrnames_t		*prefix,
+	attrnames_t		*namesp,
+	void			*data,
+	size_t			size,
+	ssize_t			*result)
+{
+	char			*p = data + *result;
+
+	*result += prefix->attr_namelen;
+	*result += namesp->attr_namelen + 1;
+	if (!size)
+		return 0;
+	if (*result > size)
+		return -ERANGE;
+	strcpy(p, prefix->attr_name);
+	p += prefix->attr_namelen;
+	strcpy(p, namesp->attr_name);
+	p += namesp->attr_namelen + 1;
+	return 0;
+}
+
+STATIC int
+attr_system_list(
+	struct vnode		*vp,
+	void			*data,
+	size_t			size,
+	ssize_t			*result)
+{
+	attrnames_t		*namesp;
+	int			i, error = 0;
+
+	for (i = 0; i < ATTR_SYSCOUNT; i++) {
+		namesp = attr_system_names[i];
+		if (!namesp->attr_exists || !namesp->attr_exists(vp))
+			continue;
+		error = attr_generic_listadd(&attr_system, namesp,
+						data, size, result);
+		if (error)
+			break;
+	}
+	return error;
+}
+
+int
+attr_generic_list(
+	struct vnode *vp, void *data, size_t size, int xflags, ssize_t *result)
+{
+	attrlist_cursor_kern_t	cursor = { 0 };
+	int			error;
+
+	VOP_ATTR_LIST(vp, data, size, xflags, &cursor, NULL, error);
+	if (error > 0)
+		return -error;
+	*result = -error;
+	return attr_system_list(vp, data, size, result);
+}
+
+attrnames_t *
+attr_lookup_namespace(
+	char			*name,
+	struct attrnames	**names,
+	int			nnames)
+{
+	int			i;
+
+	for (i = 0; i < nnames; i++)
+		if (!strncmp(name, names[i]->attr_name, names[i]->attr_namelen))
+			return names[i];
+	return NULL;
+}
+
+/*
+ * Some checks to prevent people abusing EAs to get over quota:
+ * - Don't allow modifying user EAs on devices/symlinks;
+ * - Don't allow modifying user EAs if sticky bit set;
+ */
+STATIC int
+attr_user_capable(
+	struct vnode	*vp,
+	cred_t		*cred)
+{
+	struct inode	*inode = LINVFS_GET_IP(vp);
+
+	if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
+		return -EPERM;
+	if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode) &&
+	    !capable(CAP_SYS_ADMIN))
+		return -EPERM;
+	if (S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX) &&
+	    (current_fsuid(cred) != inode->i_uid) && !capable(CAP_FOWNER))
+		return -EPERM;
+	return 0;
+}
+
+STATIC int
+attr_trusted_capable(
+	struct vnode	*vp,
+	cred_t		*cred)
+{
+	struct inode	*inode = LINVFS_GET_IP(vp);
+
+	if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
+		return -EPERM;
+	if (!capable(CAP_SYS_ADMIN))
+		return -EPERM;
+	return 0;
+}
+
+STATIC int
+attr_system_set(
+	struct vnode *vp, char *name, void *data, size_t size, int xflags)
+{
+	attrnames_t	*namesp;
+	int		error;
+
+	if (xflags & ATTR_CREATE)
+		return -EINVAL;
+
+	namesp = attr_lookup_namespace(name, attr_system_names, ATTR_SYSCOUNT);
+	if (!namesp)
+		return -EOPNOTSUPP;
+	error = namesp->attr_set(vp, name, data, size, xflags);
+	if (!error)
+		error = vn_revalidate(vp);
+	return error;
+}
+
+STATIC int
+attr_system_get(
+	struct vnode *vp, char *name, void *data, size_t size, int xflags)
+{
+	attrnames_t	*namesp;
+
+	namesp = attr_lookup_namespace(name, attr_system_names, ATTR_SYSCOUNT);
+	if (!namesp)
+		return -EOPNOTSUPP;
+	return namesp->attr_get(vp, name, data, size, xflags);
+}
+
+STATIC int
+attr_system_remove(
+	struct vnode *vp, char *name, int xflags)
+{
+	attrnames_t	*namesp;
+
+	namesp = attr_lookup_namespace(name, attr_system_names, ATTR_SYSCOUNT);
+	if (!namesp)
+		return -EOPNOTSUPP;
+	return namesp->attr_remove(vp, name, xflags);
+}
+
+struct attrnames attr_system = {
+	.attr_name	= "system.",
+	.attr_namelen	= sizeof("system.") - 1,
+	.attr_flag	= ATTR_SYSTEM,
+	.attr_get	= attr_system_get,
+	.attr_set	= attr_system_set,
+	.attr_remove	= attr_system_remove,
+	.attr_capable	= (attrcapable_t)fs_noerr,
+};
+
+struct attrnames attr_trusted = {
+	.attr_name	= "trusted.",
+	.attr_namelen	= sizeof("trusted.") - 1,
+	.attr_flag	= ATTR_ROOT,
+	.attr_get	= attr_generic_get,
+	.attr_set	= attr_generic_set,
+	.attr_remove	= attr_generic_remove,
+	.attr_capable	= attr_trusted_capable,
+};
+
+struct attrnames attr_user = {
+	.attr_name	= "user.",
+	.attr_namelen	= sizeof("user.") - 1,
+	.attr_get	= attr_generic_get,
+	.attr_set	= attr_generic_set,
+	.attr_remove	= attr_generic_remove,
+	.attr_capable	= attr_user_capable,
+};
+
+struct attrnames *attr_namespaces[] =
+	{ &attr_system, &attr_trusted, &attr_user };
diff -puN fs/xfs/xfs_attr.h~linus fs/xfs/xfs_attr.h
--- 25/fs/xfs/xfs_attr.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_attr.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2002 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000, 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -45,22 +45,50 @@
  * as possible so as to fit into the literal area of the inode.
  */
 
-#ifdef XFS_ALL_TRACE
-#define	XFS_ATTR_TRACE
-#endif
-
-#if !defined(DEBUG)
-#undef XFS_ATTR_TRACE
-#endif
-
-
 /*========================================================================
  * External interfaces
  *========================================================================*/
 
-#define ATTR_ROOT	0x0002	/* use attrs in root namespace, not user */
+struct cred;
+struct vnode;
+
+typedef int (*attrset_t)(struct vnode *, char *, void *, size_t, int);
+typedef int (*attrget_t)(struct vnode *, char *, void *, size_t, int);
+typedef int (*attrremove_t)(struct vnode *, char *, int);
+typedef int (*attrexists_t)(struct vnode *);
+typedef int (*attrcapable_t)(struct vnode *, struct cred *);
+
+typedef struct attrnames {
+	char *		attr_name;
+	unsigned int	attr_namelen;
+	unsigned int	attr_flag;
+	attrget_t	attr_get;
+	attrset_t	attr_set;
+	attrremove_t	attr_remove;
+	attrexists_t	attr_exists;
+	attrcapable_t	attr_capable;
+} attrnames_t;
+
+#define ATTR_NAMECOUNT	3
+extern struct attrnames attr_user;
+extern struct attrnames attr_system;
+extern struct attrnames attr_trusted;
+extern struct attrnames *attr_namespaces[ATTR_NAMECOUNT];
+
+#define ATTR_SYSCOUNT	2
+extern struct attrnames posix_acl_access;
+extern struct attrnames posix_acl_default;
+extern struct attrnames *attr_system_names[ATTR_SYSCOUNT];
+
+extern attrnames_t *attr_lookup_namespace(char *, attrnames_t **, int);
+extern int attr_generic_list(struct vnode *, void *, size_t, int, ssize_t *);
+
+#define ATTR_DONTFOLLOW	0x0001	/* -- unused, from IRIX -- */
+#define ATTR_ROOT	0x0002	/* use attrs in root (trusted) namespace */
+#define ATTR_TRUST	0x0004	/* -- unused, from IRIX -- */
 #define ATTR_CREATE	0x0010	/* pure create: fail if attr already exists */
 #define ATTR_REPLACE	0x0020	/* pure set: fail if attr does not exist */
+#define ATTR_SYSTEM	0x0100	/* use attrs in system (pseudo) namespace */
 #define ATTR_KERNOTIME	0x1000	/* [kernel] don't update inode timestamps */
 #define ATTR_KERNOVAL	0x2000	/* [kernel] get attr size only, not value */
 #define ATTR_KERNAMELS	0x4000	/* [kernel] list attr names (simple list) */
@@ -135,11 +163,8 @@ typedef struct attrlist_cursor_kern {
  * Function prototypes for the kernel.
  *========================================================================*/
 
-struct cred;
-struct vnode;
 struct xfs_inode;
 struct attrlist_cursor_kern;
-struct xfs_ext_attr;
 struct xfs_da_args;
 
 /*
diff -puN fs/xfs/xfs_attr_leaf.c~linus fs/xfs/xfs_attr_leaf.c
--- 25/fs/xfs/xfs_attr_leaf.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_attr_leaf.c	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -444,8 +444,10 @@ xfs_attr_shortform_list(xfs_attr_list_co
 							< context->bufsize) {
 		for (i = 0, sfe = &sf->list[0];
 				i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) {
-			int ns = (sfe->flags & XFS_ATTR_ROOT)?
-						ROOT_NAMES : USER_NAMES;
+			attrnames_t	*namesp;
+
+			namesp = (sfe->flags & XFS_ATTR_ROOT) ? &attr_trusted :
+				  &attr_user;
 			if (((context->flags & ATTR_ROOT) != 0) !=
 			    ((sfe->flags & XFS_ATTR_ROOT) != 0) &&
 			    !(context->flags & ATTR_KERNFULLS)) {
@@ -454,11 +456,11 @@ xfs_attr_shortform_list(xfs_attr_list_co
 			}
 			if (context->flags & ATTR_KERNOVAL) {
 				ASSERT(context->flags & ATTR_KERNAMELS);
-				context->count += xfs_namespaces[ns].namelen +
+				context->count += namesp->attr_namelen +
 					INT_GET(sfe->namelen, ARCH_CONVERT) + 1;
 			}
 			else {
-				if (xfs_attr_put_listent(context, ns,
+				if (xfs_attr_put_listent(context, namesp,
 						   (char *)sfe->nameval,
 						   (int)sfe->namelen,
 						   (int)INT_GET(sfe->valuelen,
@@ -544,18 +546,22 @@ xfs_attr_shortform_list(xfs_attr_list_co
 	 * Loop putting entries into the user buffer.
 	 */
 	for ( ; i < nsbuf; i++, sbp++) {
-		int ns = (sbp->flags & XFS_ATTR_ROOT)? ROOT_NAMES:USER_NAMES;
+		attrnames_t	*namesp;
+
+		namesp = (sfe->flags & XFS_ATTR_ROOT) ? &attr_trusted :
+			  &attr_user;
+
 		if (cursor->hashval != INT_GET(sbp->hash, ARCH_CONVERT)) {
 			cursor->hashval = INT_GET(sbp->hash, ARCH_CONVERT);
 			cursor->offset = 0;
 		}
 		if (context->flags & ATTR_KERNOVAL) {
 			ASSERT(context->flags & ATTR_KERNAMELS);
-			context->count += xfs_namespaces[ns].namelen
-					+ sbp->namelen + 1;
+			context->count += namesp->attr_namelen +
+						sbp->namelen + 1;
 		}
 		else {
-			if (xfs_attr_put_listent(context, ns,
+			if (xfs_attr_put_listent(context, namesp,
 					sbp->name, sbp->namelen,
 					INT_GET(sbp->valuelen, ARCH_CONVERT)))
 				break;
@@ -2270,7 +2276,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, 
 	retval = 0;
 	for (  ; (i < INT_GET(leaf->hdr.count, ARCH_CONVERT))
 	     && (retval == 0); entry++, i++) {
-		int ns = (entry->flags & XFS_ATTR_ROOT)? ROOT_NAMES:USER_NAMES;
+		attrnames_t	*namesp;
 
 		if (INT_GET(entry->hashval, ARCH_CONVERT) != cursor->hashval) {
 			cursor->hashval = INT_GET(entry->hashval, ARCH_CONVERT);
@@ -2284,14 +2290,17 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, 
 		    !(context->flags & ATTR_KERNFULLS))
 			continue;		/* skip non-matching entries */
 
+		namesp = (entry->flags & XFS_ATTR_ROOT) ? &attr_trusted :
+			  &attr_user;
+
 		if (entry->flags & XFS_ATTR_LOCAL) {
 			name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, i);
 			if (context->flags & ATTR_KERNOVAL) {
 				ASSERT(context->flags & ATTR_KERNAMELS);
-				context->count += xfs_namespaces[ns].namelen
-						+ (int)name_loc->namelen + 1;
+				context->count += namesp->attr_namelen +
+						(int)name_loc->namelen + 1;
 			} else {
-				retval = xfs_attr_put_listent(context, ns,
+				retval = xfs_attr_put_listent(context, namesp,
 					(char *)name_loc->nameval,
 					(int)name_loc->namelen,
 					(int)INT_GET(name_loc->valuelen,
@@ -2301,10 +2310,10 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, 
 			name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i);
 			if (context->flags & ATTR_KERNOVAL) {
 				ASSERT(context->flags & ATTR_KERNAMELS);
-				context->count += xfs_namespaces[ns].namelen
-						+ (int)name_rmt->namelen + 1;
+				context->count += namesp->attr_namelen +
+						(int)name_rmt->namelen + 1;
 			} else {
-				retval = xfs_attr_put_listent(context, ns,
+				retval = xfs_attr_put_listent(context, namesp,
 					(char *)name_rmt->name,
 					(int)name_rmt->namelen,
 					(int)INT_GET(name_rmt->valuelen,
@@ -2333,7 +2342,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, 
 /*ARGSUSED*/
 int
 xfs_attr_put_listent(xfs_attr_list_context_t *context,
-		     int ns, char *name, int namelen, int valuelen)
+		     attrnames_t *namesp, char *name, int namelen, int valuelen)
 {
 	attrlist_ent_t *aep;
 	int arraytop;
@@ -2341,23 +2350,21 @@ xfs_attr_put_listent(xfs_attr_list_conte
 	ASSERT(!(context->flags & ATTR_KERNOVAL));
 	if (context->flags & ATTR_KERNAMELS) {
 		char *offset;
-		xattr_namespace_t *nsp;
 
 		ASSERT(context->count >= 0);
 
-		nsp = &xfs_namespaces[ns];
-		arraytop = context->count + nsp->namelen + namelen+1;
+		arraytop = context->count + namesp->attr_namelen + namelen + 1;
 		if (arraytop > context->firstu) {
 			context->count = -1;	/* insufficient space */
 			return(1);
 		}
 		offset = (char *)context->alist + context->count;
-		strncpy(offset, nsp->name, nsp->namelen);	/* namespace */
-		offset += nsp->namelen;
+		strncpy(offset, namesp->attr_name, namesp->attr_namelen);
+		offset += namesp->attr_namelen;
 		strncpy(offset, name, namelen);			/* real name */
 		offset += namelen;
 		*offset = '\0';
-		context->count += nsp->namelen + namelen + 1;
+		context->count += namesp->attr_namelen + namelen + 1;
 		return(0);
 	}
 
diff -puN fs/xfs/xfs_attr_leaf.h~linus fs/xfs/xfs_attr_leaf.h
--- 25/fs/xfs/xfs_attr_leaf.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_attr_leaf.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2002 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000, 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -44,6 +44,7 @@
 
 struct attrlist;
 struct attrlist_cursor_kern;
+struct attrnames;
 struct xfs_dabuf;
 struct xfs_da_args;
 struct xfs_da_state;
@@ -128,7 +129,7 @@ typedef struct xfs_attr_leaf_name_remote
  * on the system call, they are "or"ed together for various operations.
  */
 #define	XFS_ATTR_LOCAL_BIT	0	/* attr is stored locally */
-#define	XFS_ATTR_ROOT_BIT	1	/* limit access to attr to userid 0 */
+#define	XFS_ATTR_ROOT_BIT	1	/* limit access to trusted attrs */
 #define	XFS_ATTR_INCOMPLETE_BIT	7	/* attr in middle of create/delete */
 #define XFS_ATTR_LOCAL		(1 << XFS_ATTR_LOCAL_BIT)
 #define XFS_ATTR_ROOT		(1 << XFS_ATTR_ROOT_BIT)
@@ -299,7 +300,8 @@ int	xfs_attr_leaf_newentsize(struct xfs_
 					int *local);
 int	xfs_attr_leaf_entsize(struct xfs_attr_leafblock *leaf, int index);
 int	xfs_attr_put_listent(struct xfs_attr_list_context *context,
-			     int ns, char *name, int namelen, int valuelen);
+			     struct attrnames *, char *name, int namelen,
+			     int valuelen);
 int	xfs_attr_rolltrans(struct xfs_trans **transp, struct xfs_inode *dp);
 
 #endif	/* __XFS_ATTR_LEAF_H__ */
diff -puN fs/xfs/xfs_attr_sf.h~linus fs/xfs/xfs_attr_sf.h
--- 25/fs/xfs/xfs_attr_sf.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_attr_sf.h	2004-01-19 22:17:24.000000000 -0800
@@ -104,14 +104,7 @@ int xfs_attr_sf_totsize(struct xfs_inode
 	(INT_GET(((xfs_attr_shortform_t *)((dp)->i_afp->if_u1.if_data))->hdr.totsize, ARCH_CONVERT))
 #endif
 
-#ifdef XFS_ALL_TRACE
-#define	XFS_ATTR_TRACE
-#endif
-
-#if !defined(DEBUG)
-#undef	XFS_ATTR_TRACE
-#endif
-
+#if defined(XFS_ATTR_TRACE)
 /*
  * Kernel tracing support for attribute lists
  */
@@ -121,6 +114,7 @@ struct xfs_da_node_entry;
 struct xfs_attr_leafblock;
 
 #define	XFS_ATTR_TRACE_SIZE	4096	/* size of global trace buffer */
+extern ktrace_t	*xfs_attr_trace_buf;
 
 /*
  * Trace record types.
@@ -130,8 +124,6 @@ struct xfs_attr_leafblock;
 #define	XFS_ATTR_KTRACE_L_CB	3	/* context, btree */
 #define	XFS_ATTR_KTRACE_L_CL	4	/* context, leaf */
 
-#if defined(XFS_ATTR_TRACE)
-
 void xfs_attr_trace_l_c(char *where, struct xfs_attr_list_context *context);
 void xfs_attr_trace_l_cn(char *where, struct xfs_attr_list_context *context,
 			      struct xfs_da_intnode *node);
diff -puN fs/xfs/xfs_bmap_btree.c~linus fs/xfs/xfs_bmap_btree.c
--- 25/fs/xfs/xfs_bmap_btree.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_bmap_btree.c	2004-01-19 22:17:24.000000000 -0800
@@ -81,6 +81,13 @@ STATIC int xfs_bmbt_updkey(xfs_btree_cur
 
 
 #if defined(XFS_BMBT_TRACE)
+
+static char	ARGS[] = "args";
+static char	ENTRY[] = "entry";
+static char	ERROR[] = "error";
+#undef EXIT
+static char	EXIT[] = "exit";
+
 /*
  * Add a trace buffer entry for the arguments given to the routine,
  * generic form.
@@ -305,11 +312,6 @@ xfs_bmbt_trace_cursor(
 	xfs_bmbt_trace_argik(fname, c, i, k, __LINE__)
 #define	XFS_BMBT_TRACE_CURSOR(c,s)	\
 	xfs_bmbt_trace_cursor(fname, c, s, __LINE__)
-static char	ARGS[] = "args";
-static char	ENTRY[] = "entry";
-static char	ERROR[] = "error";
-#undef EXIT
-static char	EXIT[] = "exit";
 #else
 #define	XFS_BMBT_TRACE_ARGBI(c,b,i)
 #define	XFS_BMBT_TRACE_ARGBII(c,b,i,j)
diff -puN fs/xfs/xfs_bmap_btree.h~linus fs/xfs/xfs_bmap_btree.h
--- 25/fs/xfs/xfs_bmap_btree.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_bmap_btree.h	2004-01-19 22:17:24.000000000 -0800
@@ -435,6 +435,10 @@ int xfs_bmap_sanity_check(struct xfs_mou
 	 INT_GET((bb)->bb_numrecs, ARCH_CONVERT) <= (mp)->m_bmap_dmxr[(level) != 0])
 #endif
 
+
+#ifdef __KERNEL__
+
+#if defined(XFS_BMBT_TRACE)
 /*
  * Trace buffer entry types.
  */
@@ -449,18 +453,9 @@ int xfs_bmap_sanity_check(struct xfs_mou
 
 #define XFS_BMBT_TRACE_SIZE	4096	/* size of global trace buffer */
 #define XFS_BMBT_KTRACE_SIZE	32	/* size of per-inode trace buffer */
-
-#if defined(XFS_ALL_TRACE)
-#define XFS_BMBT_TRACE
+extern ktrace_t	*xfs_bmbt_trace_buf;
 #endif
 
-#if !defined(DEBUG)
-#undef XFS_BMBT_TRACE
-#endif
-
-
-#ifdef __KERNEL__
-
 /*
  * Prototypes for xfs_bmap.c to call.
  */
diff -puN fs/xfs/xfs_bmap.c~linus fs/xfs/xfs_bmap.c
--- 25/fs/xfs/xfs_bmap.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_bmap.c	2004-01-19 22:17:24.000000000 -0800
@@ -68,9 +68,6 @@
 #include "xfs_trans_space.h"
 #include "xfs_buf_item.h"
 
-#ifdef DEBUG
-ktrace_t	*xfs_bmap_trace_buf;
-#endif
 
 #ifdef XFSDEBUG
 STATIC void
@@ -404,7 +401,7 @@ xfs_bmap_validate_ret(
 #define	xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
 #endif /* DEBUG */
 
-#if defined(DEBUG) && defined(XFS_RW_TRACE)
+#if defined(XFS_RW_TRACE)
 STATIC void
 xfs_bunmap_trace(
 	xfs_inode_t		*ip,
@@ -414,7 +411,7 @@ xfs_bunmap_trace(
 	inst_t			*ra);
 #else
 #define	xfs_bunmap_trace(ip, bno, len, flags, ra)
-#endif	/* DEBUG && XFS_RW_TRACE */
+#endif	/* XFS_RW_TRACE */
 
 STATIC int
 xfs_bmap_count_tree(
@@ -3543,6 +3540,8 @@ xfs_bmap_search_extents(
 
 
 #ifdef XFS_BMAP_TRACE
+ktrace_t	*xfs_bmap_trace_buf;
+
 /*
  * Add a bmap trace buffer entry.  Base routine for the others.
  */
@@ -3575,14 +3574,14 @@ xfs_bmap_trace_addentry(
 		(void *)(__psint_t)cnt,
 		(void *)(__psunsigned_t)(ip->i_ino >> 32),
 		(void *)(__psunsigned_t)(unsigned)ip->i_ino,
-		(void *)(__psunsigned_t)(INT_GET(r1->l0, ARCH_CONVERT) >> 32),
-		(void *)(__psunsigned_t)(unsigned)(INT_GET(r1->l0, ARCH_CONVERT)),
-		(void *)(__psunsigned_t)(INT_GET(r1->l1, ARCH_CONVERT) >> 32),
-		(void *)(__psunsigned_t)(unsigned)(INT_GET(r1->l1, ARCH_CONVERT)),
-		(void *)(__psunsigned_t)(INT_GET(r2->l0, ARCH_CONVERT) >> 32),
-		(void *)(__psunsigned_t)(unsigned)(INT_GET(r2->l0, ARCH_CONVERT)),
-		(void *)(__psunsigned_t)(INT_GET(r2->l1, ARCH_CONVERT) >> 32),
-		(void *)(__psunsigned_t)(unsigned)(INT_GET(r2->l1, ARCH_CONVERT))
+		(void *)(__psunsigned_t)(r1->l0 >> 32),
+		(void *)(__psunsigned_t)(unsigned)(r1->l0),
+		(void *)(__psunsigned_t)(r1->l1 >> 32),
+		(void *)(__psunsigned_t)(unsigned)(r1->l1),
+		(void *)(__psunsigned_t)(r2->l0 >> 32),
+		(void *)(__psunsigned_t)(unsigned)(r2->l0),
+		(void *)(__psunsigned_t)(r2->l1 >> 32),
+		(void *)(__psunsigned_t)(unsigned)(r2->l1)
 		);
 	ASSERT(ip->i_xtrace);
 	ktrace_enter(ip->i_xtrace,
@@ -3592,14 +3591,14 @@ xfs_bmap_trace_addentry(
 		(void *)(__psint_t)cnt,
 		(void *)(__psunsigned_t)(ip->i_ino >> 32),
 		(void *)(__psunsigned_t)(unsigned)ip->i_ino,
-		(void *)(__psunsigned_t)(INT_GET(r1->l0, ARCH_CONVERT) >> 32),
-		(void *)(__psunsigned_t)(unsigned)(INT_GET(r1->l0, ARCH_CONVERT)),
-		(void *)(__psunsigned_t)(INT_GET(r1->l1, ARCH_CONVERT) >> 32),
-		(void *)(__psunsigned_t)(unsigned)(INT_GET(r1->l1, ARCH_CONVERT)),
-		(void *)(__psunsigned_t)(INT_GET(r2->l0, ARCH_CONVERT) >> 32),
-		(void *)(__psunsigned_t)(unsigned)(INT_GET(r2->l0, ARCH_CONVERT)),
-		(void *)(__psunsigned_t)(INT_GET(r2->l1, ARCH_CONVERT) >> 32),
-		(void *)(__psunsigned_t)(unsigned)(INT_GET(r2->l1, ARCH_CONVERT))
+		(void *)(__psunsigned_t)(r1->l0 >> 32),
+		(void *)(__psunsigned_t)(unsigned)(r1->l0),
+		(void *)(__psunsigned_t)(r1->l1 >> 32),
+		(void *)(__psunsigned_t)(unsigned)(r1->l1),
+		(void *)(__psunsigned_t)(r2->l0 >> 32),
+		(void *)(__psunsigned_t)(unsigned)(r2->l0),
+		(void *)(__psunsigned_t)(r2->l1 >> 32),
+		(void *)(__psunsigned_t)(unsigned)(r2->l1)
 		);
 }
 
@@ -3722,7 +3721,7 @@ xfs_bmap_worst_indlen(
 	return rval;
 }
 
-#if defined(DEBUG) && defined(XFS_RW_TRACE)
+#if defined(XFS_RW_TRACE)
 STATIC void
 xfs_bunmap_trace(
 	xfs_inode_t		*ip,
@@ -3742,7 +3741,7 @@ xfs_bunmap_trace(
 		(void *)(__psint_t)((xfs_dfiloff_t)bno & 0xffffffff),
 		(void *)(__psint_t)len,
 		(void *)(__psint_t)flags,
-		(void *)(__psint_t)private.p_cpuid,
+		(void *)(unsigned long)current_cpu(),
 		(void *)ra,
 		(void *)0,
 		(void *)0,
diff -puN fs/xfs/xfs_bmap.h~linus fs/xfs/xfs_bmap.h
--- 25/fs/xfs/xfs_bmap.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_bmap.h	2004-01-19 22:17:24.000000000 -0800
@@ -90,26 +90,6 @@ int xfs_bmapi_aflag(int w);
 #define	DELAYSTARTBLOCK		((xfs_fsblock_t)-1LL)
 #define	HOLESTARTBLOCK		((xfs_fsblock_t)-2LL)
 
-/*
- * Trace operations for bmap extent tracing
- */
-#define	XFS_BMAP_KTRACE_DELETE	1
-#define	XFS_BMAP_KTRACE_INSERT	2
-#define	XFS_BMAP_KTRACE_PRE_UP	3
-#define	XFS_BMAP_KTRACE_POST_UP	4
-
-#define	XFS_BMAP_TRACE_SIZE	4096	/* size of global trace buffer */
-#define	XFS_BMAP_KTRACE_SIZE	32	/* size of per-inode trace buffer */
-
-#if defined(XFS_ALL_TRACE)
-#define	XFS_BMAP_TRACE
-#endif
-
-#if !defined(DEBUG)
-#undef	XFS_BMAP_TRACE
-#endif
-
-
 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_INIT)
 void xfs_bmap_init(xfs_bmap_free_t *flp, xfs_fsblock_t *fbp);
 #define	XFS_BMAP_INIT(flp,fbp)	xfs_bmap_init(flp,fbp)
@@ -142,6 +122,33 @@ typedef struct xfs_bmalloca {
 } xfs_bmalloca_t;
 
 #ifdef __KERNEL__
+
+#if defined(XFS_BMAP_TRACE)
+/*
+ * Trace operations for bmap extent tracing
+ */
+#define	XFS_BMAP_KTRACE_DELETE	1
+#define	XFS_BMAP_KTRACE_INSERT	2
+#define	XFS_BMAP_KTRACE_PRE_UP	3
+#define	XFS_BMAP_KTRACE_POST_UP	4
+
+#define	XFS_BMAP_TRACE_SIZE	4096	/* size of global trace buffer */
+#define	XFS_BMAP_KTRACE_SIZE	32	/* size of per-inode trace buffer */
+extern ktrace_t	*xfs_bmap_trace_buf;
+
+/*
+ * Add bmap trace insert entries for all the contents of the extent list.
+ */
+void
+xfs_bmap_trace_exlist(
+	char			*fname,		/* function name */
+	struct xfs_inode	*ip,		/* incore inode pointer */
+	xfs_extnum_t		cnt,		/* count of entries in list */
+	int			whichfork);	/* data or attr fork */
+#else
+#define	xfs_bmap_trace_exlist(f,ip,c,w)
+#endif
+
 /*
  * Convert inode from non-attributed to attributed.
  * Must not be in a transaction, ip must not be locked.
@@ -260,20 +267,6 @@ xfs_bmap_read_extents(
 	struct xfs_inode	*ip,		/* incore inode */
 	int			whichfork);	/* data or attr fork */
 
-#if defined(XFS_BMAP_TRACE)
-/*
- * Add bmap trace insert entries for all the contents of the extent list.
- */
-void
-xfs_bmap_trace_exlist(
-	char			*fname,		/* function name */
-	struct xfs_inode	*ip,		/* incore inode pointer */
-	xfs_extnum_t		cnt,		/* count of entries in list */
-	int			whichfork);	/* data or attr fork */
-#else
-#define	xfs_bmap_trace_exlist(f,ip,c,w)
-#endif
-
 /*
  * Map file blocks to filesystem blocks.
  * File range is given by the bno/len pair.
@@ -375,7 +368,7 @@ xfs_bmap_eof(
 int
 xfs_bmap_count_blocks(
 	xfs_trans_t		*tp,
-	xfs_inode_t		*ip,
+	struct xfs_inode	*ip,
 	int			whichfork,
 	int			*count);
 
diff -puN fs/xfs/xfs_buf.h~linus fs/xfs/xfs_buf.h
--- 25/fs/xfs/xfs_buf.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_buf.h	2004-01-19 22:17:24.000000000 -0800
@@ -181,7 +181,7 @@ extern inline xfs_caddr_t xfs_buf_offset
 #define XFS_BUF_SET_VTYPE(bp, type)
 #define XFS_BUF_SET_REF(bp, ref)
 
-#define XFS_BUF_ISPINNED(bp)   pagebuf_ispin(bp)
+#define XFS_BUF_ISPINNED(bp)	pagebuf_ispin(bp)
 
 #define XFS_BUF_VALUSEMA(bp)	pagebuf_lock_value(bp)
 #define XFS_BUF_CPSEMA(bp)	(pagebuf_cond_lock(bp) == 0)
@@ -191,13 +191,11 @@ extern inline xfs_caddr_t xfs_buf_offset
 
 /* setup the buffer target from a buftarg structure */
 #define XFS_BUF_SET_TARGET(bp, target)	\
-	(bp)->pb_target = (target)
-
+		(bp)->pb_target = (target)
 #define XFS_BUF_TARGET(bp)	((bp)->pb_target)
+#define XFS_BUFTARG_NAME(target)	\
+		pagebuf_target_name(target)
 
-#define XFS_BUFTARG_NAME(target) \
-	({ char __b[BDEVNAME_SIZE]; bdevname((target->pbr_bdev), __b); __b; })
-	
 #define XFS_BUF_SET_VTYPE_REF(bp, type, ref)
 #define XFS_BUF_SET_VTYPE(bp, type)
 #define XFS_BUF_SET_REF(bp, ref)
@@ -231,18 +229,11 @@ static inline void	xfs_buf_relse(page_bu
 	pagebuf_rele(bp);
 }
 
-
 #define xfs_bpin(bp)		pagebuf_pin(bp)
 #define xfs_bunpin(bp)		pagebuf_unpin(bp)
 
-#ifdef PAGEBUF_TRACE
-# define PB_DEFINE_TRACES
-# include <pagebuf/page_buf_trace.h>
-# define xfs_buftrace(id, bp)	PB_TRACE(bp, PB_TRACE_REC(external), (void *)id)
-#else
-# define xfs_buftrace(id, bp)	do { } while (0)
-#endif
-
+#define xfs_buftrace(id, bp)	\
+	    pagebuf_trace(bp, id, NULL, (void *)__builtin_return_address(0))
 
 #define xfs_biodone(pb)		    \
 	    pagebuf_iodone(pb, (pb->pb_flags & PBF_FS_DATAIOD), 0)
diff -puN fs/xfs/xfs_buf_item.c~linus fs/xfs/xfs_buf_item.c
--- 25/fs/xfs/xfs_buf_item.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_buf_item.c	2004-01-19 22:17:24.000000000 -0800
@@ -1207,13 +1207,14 @@ xfs_buf_item_trace(
 		     (void *)((unsigned long)bip->bli_flags),
 		     (void *)((unsigned long)bip->bli_recur),
 		     (void *)((unsigned long)atomic_read(&bip->bli_refcount)),
-		     (void *)XFS_BUF_ADDR(bp),
+		     (void *)((unsigned long)
+				(0xFFFFFFFF & XFS_BUF_ADDR(bp) >> 32)),
+		     (void *)((unsigned long)(0xFFFFFFFF & XFS_BUF_ADDR(bp))),
 		     (void *)((unsigned long)XFS_BUF_COUNT(bp)),
-		     (void *)((unsigned long)(0xFFFFFFFF & (XFS_BFLAGS(bp) >> 32))),
-		     (void *)((unsigned long)(0xFFFFFFFF & XFS_BFLAGS(bp))),
+		     (void *)((unsigned long)XFS_BUF_BFLAGS(bp)),
 		     XFS_BUF_FSPRIVATE(bp, void *),
 		     XFS_BUF_FSPRIVATE2(bp, void *),
-		     (void *)((unsigned long)bp->b_pincount),
+		     (void *)(unsigned long)XFS_BUF_ISPINNED(bp),
 		     (void *)XFS_BUF_IODONE_FUNC(bp),
 		     (void *)((unsigned long)(XFS_BUF_VALUSEMA(bp))),
 		     (void *)bip->bli_item.li_desc,
diff -puN fs/xfs/xfs_buf_item.h~linus fs/xfs/xfs_buf_item.h
--- 25/fs/xfs/xfs_buf_item.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_buf_item.h	2004-01-19 22:17:24.000000000 -0800
@@ -104,6 +104,15 @@ typedef struct xfs_buf_log_format_t {
 struct xfs_buf;
 struct ktrace;
 struct xfs_mount;
+struct xfs_buf_log_item;
+
+#if defined(XFS_BLI_TRACE)
+#define	XFS_BLI_TRACE_SIZE	32
+
+void	xfs_buf_item_trace(char *, struct xfs_buf_log_item *);
+#else
+#define	xfs_buf_item_trace(id, bip)
+#endif
 
 /*
  * This is the in core log item structure used to track information
@@ -116,7 +125,7 @@ typedef struct xfs_buf_log_item {
 	unsigned int		bli_flags;	/* misc flags */
 	unsigned int		bli_recur;	/* lock recursion count */
 	atomic_t		bli_refcount;	/* cnt of tp refs */
-#ifdef DEBUG
+#ifdef XFS_BLI_TRACE
 	struct ktrace		*bli_trace;	/* event trace buf */
 #endif
 #ifdef XFS_TRANS_DEBUG
@@ -137,23 +146,6 @@ typedef struct xfs_buf_cancel {
 	struct xfs_buf_cancel	*bc_next;
 } xfs_buf_cancel_t;
 
-#define	XFS_BLI_TRACE_SIZE	32
-
-
-#if defined(XFS_ALL_TRACE)
-#define	XFS_BLI_TRACE
-#endif
-
-#if !defined(DEBUG)
-#undef XFS_BLI_TRACE
-#endif
-
-#if defined(XFS_BLI_TRACE)
-void	xfs_buf_item_trace(char *, xfs_buf_log_item_t *);
-#else
-#define	xfs_buf_item_trace(id, bip)
-#endif
-
 void	xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
 void	xfs_buf_item_relse(struct xfs_buf *);
 void	xfs_buf_item_log(xfs_buf_log_item_t *, uint, uint);
diff -puN fs/xfs/xfs_da_btree.c~linus fs/xfs/xfs_da_btree.c
--- 25/fs/xfs/xfs_da_btree.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_da_btree.c	2004-01-19 22:17:24.000000000 -0800
@@ -66,13 +66,6 @@
 #include "xfs_error.h"
 #include "xfs_bit.h"
 
-#if defined(XFSDEBUG) && defined(CONFIG_KDB)
-#undef xfs_buftrace
-#define xfs_buftrace(A,B) \
-	printk("    xfs_buftrace : %s (0x%p)\n", A, B); \
-	BUG();
-#endif
-
 /*
  * xfs_da_btree.c
  *
diff -puN fs/xfs/xfs_dfrag.c~linus fs/xfs/xfs_dfrag.c
--- 25/fs/xfs/xfs_dfrag.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_dfrag.c	2004-01-19 22:17:24.000000000 -0800
@@ -153,12 +153,12 @@ xfs_swapext(
 	if ((error = _MAC_XFS_IACCESS(tip, MACWRITE, NULL))) {
 		goto error0;
 	}
-	if ((current->fsuid != ip->i_d.di_uid) &&
+	if ((current_fsuid(cred) != ip->i_d.di_uid) &&
 	    (error = xfs_iaccess(ip, S_IWUSR, NULL)) &&
 	    !capable_cred(NULL, CAP_FOWNER)) {
 		goto error0;
 	}
-	if ((current->fsuid != tip->i_d.di_uid) &&
+	if ((current_fsuid(cred) != tip->i_d.di_uid) &&
 	    (error = xfs_iaccess(tip, S_IWUSR, NULL)) &&
 	    !capable_cred(NULL, CAP_FOWNER)) {
 		goto error0;
diff -puN fs/xfs/xfs_dir2_trace.c~linus fs/xfs/xfs_dir2_trace.c
--- 25/fs/xfs/xfs_dir2_trace.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_dir2_trace.c	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -64,36 +64,37 @@ xfs_dir2_trace_enter(
 	char		*where,
 	char		*name,
 	int		namelen,
-	__psunsigned_t	a0,
-	__psunsigned_t	a1,
-	__psunsigned_t	a2,
-	__psunsigned_t	a3,
-	__psunsigned_t	a4,
-	__psunsigned_t	a5,
-	__psunsigned_t	a6)
+	void		*a0,
+	void		*a1,
+	void		*a2,
+	void		*a3,
+	void		*a4,
+	void		*a5,
+	void		*a6,
+	void		*a7)
 {
-	__psunsigned_t	n[6];
+	void		*n[5];
 
 	ASSERT(xfs_dir2_trace_buf);
 	ASSERT(dp->i_dir_trace);
 	if (name)
-		memcpy(n, name, min(sizeof(n), namelen));
+		memcpy(n, name, min((int)sizeof(n), namelen));
 	else
 		memset((char *)n, 0, sizeof(n));
 	ktrace_enter(xfs_dir2_trace_buf,
-		(void *)(__psunsigned_t)type, (void *)where,
+		(void *)(long)type, (void *)where,
 		(void *)a0, (void *)a1, (void *)a2, (void *)a3,
-		(void *)a4, (void *)a5, (void *)a6,
-		(void *)(__psunsigned_t)namelen,
+		(void *)a4, (void *)a5, (void *)a6, (void *)a7,
+		(void *)(long)namelen,
 		(void *)n[0], (void *)n[1], (void *)n[2],
-		(void *)n[3], (void *)n[4], (void *)n[5]);
+		(void *)n[3], (void *)n[4]);
 	ktrace_enter(dp->i_dir_trace,
-		(void *)(__psunsigned_t)type, (void *)where,
+		(void *)(long)type, (void *)where,
 		(void *)a0, (void *)a1, (void *)a2, (void *)a3,
-		(void *)a4, (void *)a5, (void *)a6,
-		(void *)(__psunsigned_t)namelen,
+		(void *)a4, (void *)a5, (void *)a6, (void *)a7,
+		(void *)(long)namelen,
 		(void *)n[0], (void *)n[1], (void *)n[2],
-		(void *)n[3], (void *)n[4], (void *)n[5]);
+		(void *)n[3], (void *)n[4]);
 }
 
 void
@@ -103,9 +104,11 @@ xfs_dir2_trace_args(
 {
 	xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS, where,
 		(char *)args->name, (int)args->namelen,
-		(__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
-		(__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
-		(__psunsigned_t)args->justcheck, 0, 0);
+		(void *)(unsigned long)args->hashval,
+		(void *)((unsigned long)(args->inumber >> 32)),
+		(void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
+		(void *)args->dp, (void *)args->trans,
+		(void *)(unsigned long)args->justcheck, NULL, NULL);
 }
 
 void
@@ -116,10 +119,12 @@ xfs_dir2_trace_args_b(
 {
 	xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_B, where,
 		(char *)args->name, (int)args->namelen,
-		(__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
-		(__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
-		(__psunsigned_t)args->justcheck,
-		(__psunsigned_t)(bp ? bp->bps[0] : NULL), 0);
+		(void *)(unsigned long)args->hashval,
+		(void *)((unsigned long)(args->inumber >> 32)),
+		(void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
+		(void *)args->dp, (void *)args->trans,
+		(void *)(unsigned long)args->justcheck,
+		(void *)(bp ? bp->bps[0] : NULL), NULL);
 }
 
 void
@@ -131,11 +136,13 @@ xfs_dir2_trace_args_bb(
 {
 	xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_BB, where,
 		(char *)args->name, (int)args->namelen,
-		(__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
-		(__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
-		(__psunsigned_t)args->justcheck,
-		(__psunsigned_t)(lbp ? lbp->bps[0] : NULL),
-		(__psunsigned_t)(dbp ? dbp->bps[0] : NULL));
+		(void *)(unsigned long)args->hashval,
+		(void *)((unsigned long)(args->inumber >> 32)),
+		(void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
+		(void *)args->dp, (void *)args->trans,
+		(void *)(unsigned long)args->justcheck,
+		(void *)(lbp ? lbp->bps[0] : NULL),
+		(void *)(dbp ? dbp->bps[0] : NULL));
 }
 
 void
@@ -148,12 +155,14 @@ xfs_dir2_trace_args_bibii(
 	int		sd,
 	int		c)
 {
+	xfs_buf_t	*bpbs = bs ? bs->bps[0] : NULL;
+	xfs_buf_t	*bpbd = bd ? bd->bps[0] : NULL;
+
 	xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_BIBII, where,
 		(char *)args->name, (int)args->namelen,
-		(__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
-		(__psunsigned_t)(bs ? bs->bps[0] : NULL), (__psunsigned_t)ss,
-		(__psunsigned_t)(bd ? bd->bps[0] : NULL), (__psunsigned_t)sd,
-		(__psunsigned_t)c);
+		(void *)args->dp, (void *)args->trans,
+		(void *)bpbs, (void *)(long)ss, (void *)bpbd, (void *)(long)sd,
+		(void *)(long)c, NULL);
 }
 
 void
@@ -163,12 +172,16 @@ xfs_dir2_trace_args_db(
 	xfs_dir2_db_t	db,
 	xfs_dabuf_t	*bp)
 {
+	xfs_buf_t	*dbp = bp ? bp->bps[0] : NULL;
+
 	xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_DB, where,
 		(char *)args->name, (int)args->namelen,
-		(__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
-		(__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
-		(__psunsigned_t)args->justcheck, (__psunsigned_t)db,
-		(__psunsigned_t)(bp ? bp->bps[0] : NULL));
+		(void *)(unsigned long)args->hashval,
+		(void *)((unsigned long)(args->inumber >> 32)),
+		(void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
+		(void *)args->dp, (void *)args->trans,
+		(void *)(unsigned long)args->justcheck, (void *)(long)db,
+		(void *)dbp);
 }
 
 void
@@ -179,9 +192,13 @@ xfs_dir2_trace_args_i(
 {
 	xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_I, where,
 		(char *)args->name, (int)args->namelen,
-		(__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
-		(__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
-		(__psunsigned_t)args->justcheck, (__psunsigned_t)i, 0);
+		(void *)(unsigned long)args->hashval,
+		(void *)((unsigned long)(args->inumber >> 32)),
+		(void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
+		(void *)args->dp, (void *)args->trans,
+		(void *)(unsigned long)args->justcheck,
+		(void *)((unsigned long)(i >> 32)),
+		(void *)((unsigned long)(i & 0xFFFFFFFF)));
 }
 
 void
@@ -192,9 +209,11 @@ xfs_dir2_trace_args_s(
 {
 	xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_S, where,
 		(char *)args->name, (int)args->namelen,
-		(__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
-		(__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
-		(__psunsigned_t)args->justcheck, (__psunsigned_t)s, 0);
+		(void *)(unsigned long)args->hashval,
+		(void *)((unsigned long)(args->inumber >> 32)),
+		(void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
+		(void *)args->dp, (void *)args->trans,
+		(void *)(unsigned long)args->justcheck, (void *)(long)s, 0);
 }
 
 void
@@ -204,11 +223,15 @@ xfs_dir2_trace_args_sb(
 	int		s,
 	xfs_dabuf_t	*bp)
 {
+	xfs_buf_t	*dbp = bp ? bp->bps[0] : NULL;
+
 	xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_SB, where,
 		(char *)args->name, (int)args->namelen,
-		(__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
-		(__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
-		(__psunsigned_t)args->justcheck, (__psunsigned_t)s,
-		(__psunsigned_t)(bp ? bp->bps[0] : NULL));
+		(void *)(unsigned long)args->hashval,
+		(void *)((unsigned long)(args->inumber >> 32)),
+		(void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
+		(void *)args->dp, (void *)args->trans,
+		(void *)(unsigned long)args->justcheck, (void *)(long)s,
+		(void *)dbp);
 }
 #endif	/* XFS_DIR2_TRACE */
diff -puN fs/xfs/xfs_dir2_trace.h~linus fs/xfs/xfs_dir2_trace.h
--- 25/fs/xfs/xfs_dir2_trace.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_dir2_trace.h	2004-01-19 22:17:24.000000000 -0800
@@ -36,20 +36,15 @@
  * Tracing for xfs v2 directories.
  */
 
+#if defined(XFS_DIR2_TRACE)
+
 struct ktrace;
 struct xfs_dabuf;
 struct xfs_da_args;
 
-#ifdef XFS_ALL_TRACE
-#define XFS_DIR2_TRACE
-#endif	/* XFS_ALL_TRACE */
-
-#if !defined(DEBUG)
-#undef XFS_DIR2_TRACE
-#endif	/* !DEBUG */
-
 #define	XFS_DIR2_GTRACE_SIZE		4096	/* global buffer */
 #define	XFS_DIR2_KTRACE_SIZE		32	/* per-inode buffer */
+extern struct ktrace *xfs_dir2_trace_buf;
 
 #define	XFS_DIR2_KTRACE_ARGS		1	/* args only */
 #define	XFS_DIR2_KTRACE_ARGS_B		2	/* args + buffer */
@@ -60,8 +55,6 @@ struct xfs_da_args;
 #define	XFS_DIR2_KTRACE_ARGS_SB		7	/* args, int, buffer */
 #define	XFS_DIR2_KTRACE_ARGS_BIBII	8	/* args, buf/int/buf/int/int */
 
-#ifdef XFS_DIR2_TRACE
-
 void xfs_dir2_trace_args(char *where, struct xfs_da_args *args);
 void xfs_dir2_trace_args_b(char *where, struct xfs_da_args *args,
 			   struct xfs_dabuf *bp);
@@ -90,6 +83,4 @@ void xfs_dir2_trace_args_sb(char *where,
 
 #endif	/* XFS_DIR2_TRACE */
 
-extern struct ktrace *xfs_dir2_trace_buf;
-
 #endif	/* __XFS_DIR2_TRACE_H__ */
diff -puN fs/xfs/xfs_dir.c~linus fs/xfs/xfs_dir.c
--- 25/fs/xfs/xfs_dir.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_dir.c	2004-01-19 22:17:24.000000000 -0800
@@ -1093,10 +1093,10 @@ void
 xfs_dir_trace_g_du(char *where, xfs_inode_t *dp, uio_t *uio)
 {
 	xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DU, where,
-		     (__psunsigned_t)dp, (__psunsigned_t)dp->i_mount,
-		     (__psunsigned_t)(uio->uio_offset >> 32),
-		     (__psunsigned_t)(uio->uio_offset & 0xFFFFFFFF),
-		     (__psunsigned_t)uio->uio_resid,
+		     (void *)dp, (void *)dp->i_mount,
+		     (void *)((unsigned long)(uio->uio_offset >> 32)),
+		     (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
+		     (void *)(unsigned long)uio->uio_resid,
 		     NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 }
 
@@ -1107,11 +1107,11 @@ void
 xfs_dir_trace_g_dub(char *where, xfs_inode_t *dp, uio_t *uio, xfs_dablk_t bno)
 {
 	xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DUB, where,
-		     (__psunsigned_t)dp, (__psunsigned_t)dp->i_mount,
-		     (__psunsigned_t)(uio->uio_offset >> 32),
-		     (__psunsigned_t)(uio->uio_offset & 0xFFFFFFFF),
-		     (__psunsigned_t)uio->uio_resid,
-		     (__psunsigned_t)bno,
+		     (void *)dp, (void *)dp->i_mount,
+		     (void *)((unsigned long)(uio->uio_offset >> 32)),
+		     (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
+		     (void *)(unsigned long)uio->uio_resid,
+		     (void *)(unsigned long)bno,
 		     NULL, NULL, NULL, NULL, NULL, NULL);
 }
 
@@ -1122,15 +1122,21 @@ void
 xfs_dir_trace_g_dun(char *where, xfs_inode_t *dp, uio_t *uio,
 			xfs_da_intnode_t *node)
 {
+	int	last = INT_GET(node->hdr.count, ARCH_CONVERT) - 1;
+
 	xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DUN, where,
-		     (__psunsigned_t)dp, (__psunsigned_t)dp->i_mount,
-		     (__psunsigned_t)(uio->uio_offset >> 32),
-		     (__psunsigned_t)(uio->uio_offset & 0xFFFFFFFF),
-		     (__psunsigned_t)uio->uio_resid,
-		     (__psunsigned_t)INT_GET(node->hdr.info.forw, ARCH_CONVERT),
-		     (__psunsigned_t)INT_GET(node->hdr.count, ARCH_CONVERT),
-		     (__psunsigned_t)INT_GET(node->btree[0].hashval, ARCH_CONVERT),
-		     (__psunsigned_t)INT_GET(node->btree[INT_GET(node->hdr.count, ARCH_CONVERT)-1].hashval, ARCH_CONVERT),
+		     (void *)dp, (void *)dp->i_mount,
+		     (void *)((unsigned long)(uio->uio_offset >> 32)),
+		     (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
+		     (void *)(unsigned long)uio->uio_resid,
+		     (void *)(unsigned long)
+			INT_GET(node->hdr.info.forw, ARCH_CONVERT),
+		     (void *)(unsigned long)
+			INT_GET(node->hdr.count, ARCH_CONVERT),
+		     (void *)(unsigned long)
+			INT_GET(node->btree[0].hashval, ARCH_CONVERT),
+		     (void *)(unsigned long)
+			INT_GET(node->btree[last].hashval, ARCH_CONVERT),
 		     NULL, NULL, NULL);
 }
 
@@ -1141,15 +1147,21 @@ void
 xfs_dir_trace_g_dul(char *where, xfs_inode_t *dp, uio_t *uio,
 			xfs_dir_leafblock_t *leaf)
 {
+	int	last = INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1;
+
 	xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DUL, where,
-		     (__psunsigned_t)dp, (__psunsigned_t)dp->i_mount,
-		     (__psunsigned_t)(uio->uio_offset >> 32),
-		     (__psunsigned_t)(uio->uio_offset & 0xFFFFFFFF),
-		     (__psunsigned_t)uio->uio_resid,
-		     (__psunsigned_t)INT_GET(leaf->hdr.info.forw, ARCH_CONVERT),
-		     (__psunsigned_t)INT_GET(leaf->hdr.count, ARCH_CONVERT),
-		     (__psunsigned_t)INT_GET(leaf->entries[0].hashval, ARCH_CONVERT),
-		     (__psunsigned_t)INT_GET(leaf->entries[ INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT),
+		     (void *)dp, (void *)dp->i_mount,
+		     (void *)((unsigned long)(uio->uio_offset >> 32)),
+		     (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
+		     (void *)(unsigned long)uio->uio_resid,
+		     (void *)(unsigned long)
+			INT_GET(leaf->hdr.info.forw, ARCH_CONVERT),
+		     (void *)(unsigned long)
+			INT_GET(leaf->hdr.count, ARCH_CONVERT),
+		     (void *)(unsigned long)
+			INT_GET(leaf->entries[0].hashval, ARCH_CONVERT),
+		     (void *)(unsigned long)
+			INT_GET(leaf->entries[last].hashval, ARCH_CONVERT),
 		     NULL, NULL, NULL);
 }
 
@@ -1161,11 +1173,12 @@ xfs_dir_trace_g_due(char *where, xfs_ino
 			xfs_dir_leaf_entry_t *entry)
 {
 	xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DUE, where,
-		     (__psunsigned_t)dp, (__psunsigned_t)dp->i_mount,
-		     (__psunsigned_t)(uio->uio_offset >> 32),
-		     (__psunsigned_t)(uio->uio_offset & 0xFFFFFFFF),
-		     (__psunsigned_t)uio->uio_resid,
-		     (__psunsigned_t)INT_GET(entry->hashval, ARCH_CONVERT),
+		     (void *)dp, (void *)dp->i_mount,
+		     (void *)((unsigned long)(uio->uio_offset >> 32)),
+		     (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
+		     (void *)(unsigned long)uio->uio_resid,
+		     (void *)(unsigned long)
+			INT_GET(entry->hashval, ARCH_CONVERT),
 		     NULL, NULL, NULL, NULL, NULL, NULL);
 }
 
@@ -1176,12 +1189,12 @@ void
 xfs_dir_trace_g_duc(char *where, xfs_inode_t *dp, uio_t *uio, xfs_off_t cookie)
 {
 	xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DUC, where,
-		     (__psunsigned_t)dp, (__psunsigned_t)dp->i_mount,
-		     (__psunsigned_t)(uio->uio_offset >> 32),
-		     (__psunsigned_t)(uio->uio_offset & 0xFFFFFFFF),
-		     (__psunsigned_t)uio->uio_resid,
-		     (__psunsigned_t)(cookie >> 32),
-		     (__psunsigned_t)(cookie & 0xFFFFFFFF),
+		     (void *)dp, (void *)dp->i_mount,
+		     (void *)((unsigned long)(uio->uio_offset >> 32)),
+		     (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
+		     (void *)(unsigned long)uio->uio_resid,
+		     (void *)((unsigned long)(cookie >> 32)),
+		     (void *)((unsigned long)(cookie & 0xFFFFFFFF)),
 		     NULL, NULL, NULL, NULL, NULL);
 }
 
@@ -1191,15 +1204,15 @@ xfs_dir_trace_g_duc(char *where, xfs_ino
  */
 void
 xfs_dir_trace_enter(int type, char *where,
-			__psunsigned_t a0, __psunsigned_t a1,
-			__psunsigned_t a2, __psunsigned_t a3,
-			__psunsigned_t a4, __psunsigned_t a5,
-			__psunsigned_t a6, __psunsigned_t a7,
-			__psunsigned_t a8, __psunsigned_t a9,
-			__psunsigned_t a10, __psunsigned_t a11)
+			void * a0, void * a1,
+			void * a2, void * a3,
+			void * a4, void * a5,
+			void * a6, void * a7,
+			void * a8, void * a9,
+			void * a10, void * a11)
 {
 	ASSERT(xfs_dir_trace_buf);
-	ktrace_enter(xfs_dir_trace_buf, (void *)((__psunsigned_t)type),
+	ktrace_enter(xfs_dir_trace_buf, (void *)(unsigned long)type,
 					(void *)where,
 					(void *)a0, (void *)a1, (void *)a2,
 					(void *)a3, (void *)a4, (void *)a5,
diff -puN fs/xfs/xfs_dir.h~linus fs/xfs/xfs_dir.h
--- 25/fs/xfs/xfs_dir.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_dir.h	2004-01-19 22:17:24.000000000 -0800
@@ -43,14 +43,6 @@
  * as possible so as to fit into the literal area of the inode.
  */
 
-#ifdef XFS_ALL_TRACE
-#define	XFS_DIR_TRACE
-#endif
-
-#if !defined(DEBUG)
-#undef XFS_DIR_TRACE
-#endif
-
 /*========================================================================
  * Function prototypes for the kernel.
  *========================================================================*/
diff -puN fs/xfs/xfs_dir_sf.h~linus fs/xfs/xfs_dir_sf.h
--- 25/fs/xfs/xfs_dir_sf.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_dir_sf.h	2004-01-19 22:17:24.000000000 -0800
@@ -126,13 +126,7 @@ int xfs_dir_sf_allfit(int count, int tot
 	       ((uint)sizeof(xfs_dir_sf_entry_t)-1)*(count) + (totallen))
 #endif
 
-#ifdef XFS_ALL_TRACE
-#define	XFS_DIR_TRACE
-#endif
-
-#if !defined(DEBUG)
-#undef XFS_DIR_TRACE
-#endif
+#if defined(XFS_DIR_TRACE)
 
 /*
  * Kernel tracing support for directories.
@@ -145,6 +139,7 @@ struct xfs_dir_leafblock;
 struct xfs_dir_leaf_entry;
 
 #define	XFS_DIR_TRACE_SIZE	4096	/* size of global trace buffer */
+extern ktrace_t	*xfs_dir_trace_buf;
 
 /*
  * Trace record types.
@@ -156,8 +151,6 @@ struct xfs_dir_leaf_entry;
 #define	XFS_DIR_KTRACE_G_DUE	5	/* dp, uio, leaf entry */
 #define	XFS_DIR_KTRACE_G_DUC	6	/* dp, uio, cookie */
 
-#if defined(XFS_DIR_TRACE)
-
 void xfs_dir_trace_g_du(char *where, struct xfs_inode *dp, struct uio *uio);
 void xfs_dir_trace_g_dub(char *where, struct xfs_inode *dp, struct uio *uio,
 			      xfs_dablk_t bno);
@@ -170,12 +163,9 @@ void xfs_dir_trace_g_due(char *where, st
 void xfs_dir_trace_g_duc(char *where, struct xfs_inode *dp, struct uio *uio,
 			      xfs_off_t cookie);
 void xfs_dir_trace_enter(int type, char *where,
-			     __psunsigned_t a0, __psunsigned_t a1,
-			     __psunsigned_t a2, __psunsigned_t a3,
-			     __psunsigned_t a4, __psunsigned_t a5,
-			     __psunsigned_t a6, __psunsigned_t a7,
-			     __psunsigned_t a8, __psunsigned_t a9,
-			     __psunsigned_t a10, __psunsigned_t a11);
+			     void *a0, void *a1, void *a2, void *a3,
+			     void *a4, void *a5, void *a6, void *a7,
+			     void *a8, void *a9, void *a10, void *a11);
 #else
 #define	xfs_dir_trace_g_du(w,d,u)
 #define	xfs_dir_trace_g_dub(w,d,u,b)
diff -puN fs/xfs/xfs_dmapi.h~linus fs/xfs/xfs_dmapi.h
--- 25/fs/xfs/xfs_dmapi.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_dmapi.h	2004-01-19 22:17:24.000000000 -0800
@@ -175,14 +175,6 @@ typedef enum {
 			DM_FLAGS_NDELAY : 0)
 #define AT_DELAY_FLAG(f) ((f&ATTR_NONBLOCK) ? DM_FLAGS_NDELAY : 0)
 
-/*
- *	Macros to turn caller specified delay/block flags into
- *	dm_send_xxxx_event flag DM_FLAGS_NDELAY.
- */
-
-#define FILP_DELAY_FLAG(filp) ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) ? \
-			DM_FLAGS_NDELAY : 0)
-
 
 extern struct bhv_vfsops xfs_dmops;
 
diff -puN fs/xfs/xfs_dmops.c~linus fs/xfs/xfs_dmops.c
--- 25/fs/xfs/xfs_dmops.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_dmops.c	2004-01-19 22:17:24.000000000 -0800
@@ -43,8 +43,6 @@
 #include "xfs_dmapi.h"
 #include "xfs_mount.h"
 
-
-#ifndef CONFIG_XFS_DMAPI
 xfs_dmops_t	xfs_dmcore_xfs = {
 	.xfs_send_data		= (xfs_send_data_t)fs_nosys,
 	.xfs_send_mmap		= (xfs_send_mmap_t)fs_noerr,
@@ -52,4 +50,3 @@ xfs_dmops_t	xfs_dmcore_xfs = {
 	.xfs_send_namesp	= (xfs_send_namesp_t)fs_nosys,
 	.xfs_send_unmount	= (xfs_send_unmount_t)fs_noval,
 };
-#endif /* CONFIG_XFS_DMAPI */
diff -puN fs/xfs/xfs_error.c~linus fs/xfs/xfs_error.c
--- 25/fs/xfs/xfs_error.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_error.c	2004-01-19 22:17:24.000000000 -0800
@@ -102,7 +102,7 @@ xfs_error_test(int error_tag, int *fsidp
 	if (random() % randfactor)
 		return 0;
 
-	memcpy(&fsid, fsidp, sizeof(fsid_t));
+	memcpy(&fsid, fsidp, sizeof(xfs_fsid_t));
 
 	for (i = 0; i < XFS_NUM_INJECT_ERROR; i++)  {
 		if (xfs_etest[i] == error_tag && xfs_etest_fsid[i] == fsid) {
@@ -123,7 +123,7 @@ xfs_errortag_add(int error_tag, xfs_moun
 	int len;
 	int64_t fsid;
 
-	memcpy(&fsid, mp->m_fixedfsid, sizeof(fsid_t));
+	memcpy(&fsid, mp->m_fixedfsid, sizeof(xfs_fsid_t));
 
 	for (i = 0; i < XFS_NUM_INJECT_ERROR; i++)  {
 		if (xfs_etest_fsid[i] == fsid && xfs_etest[i] == error_tag) {
@@ -156,7 +156,7 @@ xfs_errortag_clear(int error_tag, xfs_mo
 	int i;
 	int64_t fsid;
 
-	memcpy(&fsid, mp->m_fixedfsid, sizeof(fsid_t));
+	memcpy(&fsid, mp->m_fixedfsid, sizeof(xfs_fsid_t));
 
 	for (i = 0; i < XFS_NUM_INJECT_ERROR; i++) {
 		if (xfs_etest_fsid[i] == fsid && xfs_etest[i] == error_tag) {
@@ -209,7 +209,7 @@ xfs_errortag_clearall(xfs_mount_t *mp)
 {
 	int64_t fsid;
 
-	memcpy(&fsid, mp->m_fixedfsid, sizeof(fsid_t));
+	memcpy(&fsid, mp->m_fixedfsid, sizeof(xfs_fsid_t));
 
 	return xfs_errortag_clearall_umount(fsid, mp->m_fsname, 1);
 }
@@ -258,12 +258,6 @@ xfs_cmn_err(int panic_tag, int level, xf
 }
 
 void
-xfs_stack_trace(void)
-{
-	dump_stack();
-}
-
-void
 xfs_error_report(
 	char		*tag,
 	int		level,
diff -puN fs/xfs/xfs_fsops.c~linus fs/xfs/xfs_fsops.c
--- 25/fs/xfs/xfs_fsops.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_fsops.c	2004-01-19 22:17:24.000000000 -0800
@@ -51,6 +51,7 @@
 #include "xfs_fsops.h"
 #include "xfs_itable.h"
 #include "xfs_rw.h"
+#include "xfs_refcache.h"
 #include "xfs_trans_space.h"
 #include "xfs_rtalloc.h"
 #include "xfs_dir2.h"
@@ -593,6 +594,9 @@ xfs_fs_freeze(
 	/* Stop new writers */
 	xfs_start_freeze(mp, XFS_FREEZE_WRITE);
 
+	/* Flush the refcache */
+	xfs_refcache_purge_mp(mp);
+
 	/* Flush delalloc and delwri data */
 	VFS_SYNC(vfsp, SYNC_DELWRI|SYNC_WAIT, NULL, error);
 
diff -puN -L fs/xfs/xfsidbg.c fs/xfs/xfsidbg.c~linus /dev/null
--- 25/fs/xfs/xfsidbg.c
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,5442 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-#include "pagebuf/page_buf_internal.h"
-
-#include <linux/ctype.h>
-#include <linux/kdb.h>
-#include <linux/kdbprivate.h>
-#include <linux/mm.h>
-#include <linux/init.h>
-
-#include "xfs_macros.h"
-#include "xfs_types.h"
-#include "xfs_inum.h"
-#include "xfs_log.h"
-#include "xfs_trans.h"
-#include "xfs_sb.h"
-#include "xfs_dir.h"
-#include "xfs_dir2.h"
-#include "xfs_dmapi.h"
-#include "xfs_mount.h"
-#include "xfs_alloc.h"
-#include "xfs_ag.h"
-#include "xfs_alloc_btree.h"
-#include "xfs_bmap_btree.h"
-#include "xfs_ialloc_btree.h"
-#include "xfs_btree.h"
-#include "xfs_buf_item.h"
-#include "xfs_extfree_item.h"
-#include "xfs_inode_item.h"
-#include "xfs_attr_sf.h"
-#include "xfs_dir_sf.h"
-#include "xfs_dir2_sf.h"
-#include "xfs_dinode.h"
-#include "xfs_inode.h"
-#include "xfs_bmap.h"
-#include "xfs_da_btree.h"
-#include "xfs_attr.h"
-#include "xfs_attr_leaf.h"
-#include "xfs_dir_leaf.h"
-#include "xfs_dir2_data.h"
-#include "xfs_dir2_leaf.h"
-#include "xfs_dir2_block.h"
-#include "xfs_dir2_node.h"
-#include "xfs_dir2_trace.h"
-#include "xfs_log_priv.h"
-#include "xfs_log_recover.h"
-#include "xfs_rw.h"
-#include "xfs_bit.h"
-#include "xfs_quota.h"
-#include "quota/xfs_qm.h"
-
-MODULE_AUTHOR("Silicon Graphics, Inc.");
-MODULE_DESCRIPTION("Additional kdb commands for debugging XFS");
-MODULE_LICENSE("GPL");
-
-/*
- * Command table functions.
- */
-static void	xfsidbg_xagf(xfs_agf_t *);
-static void	xfsidbg_xagi(xfs_agi_t *);
-static void	xfsidbg_xaildump(xfs_mount_t *);
-static void	xfsidbg_xalloc(xfs_alloc_arg_t *);
-#ifdef DEBUG
-static void	xfsidbg_xalmtrace(xfs_mount_t *);
-#endif
-static void	xfsidbg_xattrcontext(xfs_attr_list_context_t *);
-static void	xfsidbg_xattrleaf(xfs_attr_leafblock_t *);
-static void	xfsidbg_xattrsf(xfs_attr_shortform_t *);
-static void	xfsidbg_xbirec(xfs_bmbt_irec_t *r);
-static void	xfsidbg_xbmalla(xfs_bmalloca_t *);
-static void	xfsidbg_xbrec(xfs_bmbt_rec_64_t *);
-static void	xfsidbg_xbroot(xfs_inode_t *);
-static void	xfsidbg_xbroota(xfs_inode_t *);
-static void	xfsidbg_xbtcur(xfs_btree_cur_t *);
-static void	xfsidbg_xbuf(xfs_buf_t *);
-static void	xfsidbg_xbuf_real(xfs_buf_t *, int);
-static void	xfsidbg_xchash(xfs_mount_t *mp);
-static void	xfsidbg_xchashlist(xfs_chashlist_t *chl);
-static void	xfsidbg_xdaargs(xfs_da_args_t *);
-static void	xfsidbg_xdabuf(xfs_dabuf_t *);
-static void	xfsidbg_xdanode(xfs_da_intnode_t *);
-static void	xfsidbg_xdastate(xfs_da_state_t *);
-static void	xfsidbg_xdirleaf(xfs_dir_leafblock_t *);
-static void	xfsidbg_xdirsf(xfs_dir_shortform_t *);
-static void	xfsidbg_xdir2free(xfs_dir2_free_t *);
-static void	xfsidbg_xdir2sf(xfs_dir2_sf_t *);
-static void	xfsidbg_xexlist(xfs_inode_t *);
-static void	xfsidbg_xflist(xfs_bmap_free_t *);
-static void	xfsidbg_xhelp(void);
-static void	xfsidbg_xiclog(xlog_in_core_t *);
-static void	xfsidbg_xiclogall(xlog_in_core_t *);
-static void	xfsidbg_xiclogcb(xlog_in_core_t *);
-static void	xfsidbg_xihash(xfs_mount_t *mp);
-static void	xfsidbg_xinodes(xfs_mount_t *);
-static void	xfsidbg_delayed_blocks(xfs_mount_t *);
-static void	xfsidbg_xinodes_quiesce(xfs_mount_t *);
-static void	xfsidbg_xlog(xlog_t *);
-static void	xfsidbg_xlog_ritem(xlog_recover_item_t *);
-static void	xfsidbg_xlog_rtrans(xlog_recover_t *);
-static void	xfsidbg_xlog_rtrans_entire(xlog_recover_t *);
-static void	xfsidbg_xlog_tic(xlog_ticket_t *);
-static void	xfsidbg_xlogitem(xfs_log_item_t *);
-static void	xfsidbg_xmount(xfs_mount_t *);
-static void	xfsidbg_xnode(xfs_inode_t *ip);
-static void	xfsidbg_xcore(xfs_iocore_t *io);
-static void	xfsidbg_xperag(xfs_mount_t *);
-static void	xfsidbg_xqm_diskdq(xfs_disk_dquot_t *);
-static void	xfsidbg_xqm_dqattached_inos(xfs_mount_t *);
-static void	xfsidbg_xqm_dquot(xfs_dquot_t *);
-static void	xfsidbg_xqm_mplist(xfs_mount_t *);
-static void	xfsidbg_xqm_qinfo(xfs_mount_t *mp);
-static void	xfsidbg_xqm_tpdqinfo(xfs_trans_t *tp);
-static void	xfsidbg_xsb(xfs_sb_t *, int convert);
-static void	xfsidbg_xtp(xfs_trans_t *);
-static void	xfsidbg_xtrans_res(xfs_mount_t *);
-#ifdef	CONFIG_XFS_QUOTA
-static void	xfsidbg_xqm(void);
-static void	xfsidbg_xqm_htab(void);
-static void	xfsidbg_xqm_freelist_print(xfs_frlist_t *qlist, char *title);
-static void	xfsidbg_xqm_freelist(void);
-#endif
-
-/* kdb wrappers */
-
-static int	kdbm_xfs_xagf(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xagf((xfs_agf_t *)addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xagi(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xagi((xfs_agi_t *)addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xaildump(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xaildump((xfs_mount_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xalloc(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xalloc((xfs_alloc_arg_t *) addr);
-	return 0;
-}
-
-#ifdef DEBUG
-static int	kdbm_xfs_xalmtrace(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xalmtrace((xfs_mount_t *) addr);
-	return 0;
-}
-#endif /* DEBUG */
-
-static int	kdbm_xfs_xattrcontext(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xattrcontext((xfs_attr_list_context_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xattrleaf(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xattrleaf((xfs_attr_leafblock_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xattrsf(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xattrsf((xfs_attr_shortform_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xbirec(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xbirec((xfs_bmbt_irec_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xbmalla(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xbmalla((xfs_bmalloca_t *)addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xbrec(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xbrec((xfs_bmbt_rec_64_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xbroot(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xbroot((xfs_inode_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xbroota(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xbroota((xfs_inode_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xbtcur(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xbtcur((xfs_btree_cur_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xbuf(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xbuf((xfs_buf_t *) addr);
-	return 0;
-}
-
-
-static int	kdbm_xfs_xchash(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xchash((xfs_mount_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xchashlist(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xchashlist((xfs_chashlist_t *) addr);
-	return 0;
-}
-
-
-static int	kdbm_xfs_xdaargs(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xdaargs((xfs_da_args_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xdabuf(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xdabuf((xfs_dabuf_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xdanode(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xdanode((xfs_da_intnode_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xdastate(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xdastate((xfs_da_state_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xdirleaf(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xdirleaf((xfs_dir_leafblock_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xdirsf(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xdirsf((xfs_dir_shortform_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xdir2free(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xdir2free((xfs_dir2_free_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xdir2sf(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xdir2sf((xfs_dir2_sf_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xexlist(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xexlist((xfs_inode_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xflist(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xflist((xfs_bmap_free_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xhelp(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	if (argc != 0)
-		return KDB_ARGCOUNT;
-
-	xfsidbg_xhelp();
-	return 0;
-}
-
-static int	kdbm_xfs_xiclog(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xiclog((xlog_in_core_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xiclogall(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xiclogall((xlog_in_core_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xiclogcb(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xiclogcb((xlog_in_core_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xihash(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xihash((xfs_mount_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xinodes(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xinodes((xfs_mount_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_delayed_blocks(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_delayed_blocks((xfs_mount_t *) addr);
-	return 0;
-}
-
-
-static int	kdbm_xfs_xinodes_quiesce(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xinodes_quiesce((xfs_mount_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xlog(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xlog((xlog_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xlog_ritem(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xlog_ritem((xlog_recover_item_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xlog_rtrans(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xlog_rtrans((xlog_recover_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xlog_rtrans_entire(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xlog_rtrans_entire((xlog_recover_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xlog_tic(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xlog_tic((xlog_ticket_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xlogitem(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xlogitem((xfs_log_item_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xmount(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xmount((xfs_mount_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xnode(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xnode((xfs_inode_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xcore(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xcore((xfs_iocore_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xperag(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xperag((xfs_mount_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xqm_diskdq(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xqm_diskdq((xfs_disk_dquot_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xqm_dqattached_inos(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xqm_dqattached_inos((xfs_mount_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xqm_dquot(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xqm_dquot((xfs_dquot_t *) addr);
-	return 0;
-}
-
-#ifdef	CONFIG_XFS_QUOTA
-static int	kdbm_xfs_xqm(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	if (argc != 0)
-		return KDB_ARGCOUNT;
-
-	xfsidbg_xqm();
-	return 0;
-}
-
-static int	kdbm_xfs_xqm_freelist(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	if (argc != 0)
-		return KDB_ARGCOUNT;
-
-	xfsidbg_xqm_freelist();
-	return 0;
-}
-
-static int	kdbm_xfs_xqm_htab(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	if (argc != 0)
-		return KDB_ARGCOUNT;
-
-	xfsidbg_xqm_htab();
-	return 0;
-}
-#endif
-
-static int	kdbm_xfs_xqm_mplist(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xqm_mplist((xfs_mount_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xqm_qinfo(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xqm_qinfo((xfs_mount_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xqm_tpdqinfo(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xqm_tpdqinfo((xfs_trans_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xsb(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	unsigned long convert=0;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1 && argc!=2)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-	if (argc==2) {
-	    /* extra argument - conversion flag */
-	    diag = kdbgetaddrarg(argc, argv, &nextarg, &convert, &offset, NULL, regs);
-	    if (diag)
-		    return diag;
-	}
-
-	xfsidbg_xsb((xfs_sb_t *) addr, (int)convert);
-	return 0;
-}
-
-static int	kdbm_xfs_xtp(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xtp((xfs_trans_t *) addr);
-	return 0;
-}
-
-static int	kdbm_xfs_xtrans_res(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-	if (diag)
-		return diag;
-
-	xfsidbg_xtrans_res((xfs_mount_t *) addr);
-	return 0;
-}
-
-/*
- * Vnode descriptor dump.
- * This table is a string version of all the flags defined in vnode.h.
- */
-char *tab_vflags[] = {
-	/* local only flags */
-	"VINACT",		/*	 0x01 */
-	"VRECLM",		/*	 0x02 */
-	"VWAIT",		/*	 0x04 */
-	"VMODIFIED",		/*	 0x08 */
-	"INVALID0x10",		/*	 0x10 */
-	"INVALID0x20",		/*	 0x20 */
-	"INVALID0x40",		/*	 0x40 */
-	"INVALID0x80",		/*	 0x80 */
-	"INVALID0x100",		/*	0x100 */
-	"INVALID0x200",		/*	0x200 */
-	"INVALID0x400",		/*	0x400 */
-	"INVALID0x800",		/*	0x800 */
-	"INVALID0x1000",	/*     0x1000 */
-	"INVALID0x2000",	/*     0x2000 */
-	"INVALID0x4000",	/*     0x4000 */
-	"INVALID0x8000",	/*     0x8000 */
-	"INVALID0x10000",	/*    0x10000 */
-	"INVALID0x20000",	/*    0x20000 */
-	"INVALID0x40000",	/*    0x40000 */
-	"INVALID0x80000",	/*    0x80000 */
-	"VROOT",		/*   0x100000 */
-	"INVALID0x200000",	/*   0x200000 */
-	"INVALID00x400000",	/*   0x400000 */
-	"INVALID0x800000",	/*   0x800000 */
-	"INVALID0x1000000",	/*  0x1000000 */
-	"INVALID0x2000000",	/*  0x2000000 */
-	"VSHARE",		/*  0x4000000 */
-	"INVALID0x8000000",     /*  0x8000000 */
-	"VENF_LOCKING",		/* 0x10000000 */
-	"VOPLOCK",		/* 0x20000000 */
-	"VPURGE",		/* 0x40000000 */
-	"INVALID0x80000000",	/* 0x80000000 */
-	0
-};
-
-
-static char *vnode_type[] = {
-	"VNON", "VREG", "VDIR", "VBLK", "VLNK", "VFIFO", "VBAD", "VSOCK"
-};
-
-static void
-printflags(register uint64_t flags,
-	register char **strings,
-	register char *name)
-{
-	register uint64_t mask = 1;
-
-	if (name)
-		kdb_printf("%s 0x%llx <", name, (unsigned long long)flags);
-
-	while (flags != 0 && *strings) {
-		if (mask & flags) {
-			kdb_printf("%s ", *strings);
-			flags &= ~mask;
-		}
-		mask <<= 1;
-		strings++;
-	}
-
-	if (name)
-		kdb_printf("> ");
-
-	return;
-}
-
-
-static void	printvnode(vnode_t *vp)
-{
-	bhv_desc_t	*bh;
-	kdb_symtab_t	 symtab;
-
-
-	kdb_printf("vnode: 0x%p type ", vp);
-	if ((size_t)vp->v_type >= sizeof(vnode_type)/sizeof(vnode_type[0]))
-		kdb_printf("out of range 0x%x", vp->v_type);
-	else
-		kdb_printf("%s", vnode_type[vp->v_type]);
-	kdb_printf(" v_bh %p\n", &vp->v_bh);
-
-	if ((bh = vp->v_bh.bh_first)) {
-		kdb_printf("   v_inode 0x%p v_bh->bh_first 0x%p pobj 0x%p\n",
-					LINVFS_GET_IP(vp), bh, bh->bd_pdata);
-
-		if (kdbnearsym((unsigned long)bh->bd_ops, &symtab))
-			kdb_printf("   ops %s ", symtab.sym_name);
-		else
-			kdb_printf("   ops %s/0x%p ",
-						"???", (void *)bh->bd_ops);
-	} else {
-		kdb_printf("   v_inode 0x%p v_bh->bh_first = NULLBHV ",
-					LINVFS_GET_IP(vp));
-	}
-
-	printflags((__psunsigned_t)vp->v_flag, tab_vflags, "flag =");
-	kdb_printf("\n");
-
-#ifdef	CONFIG_XFS_VNODE_TRACING
-	kdb_printf("   v_trace 0x%p\n", vp->v_trace);
-#endif	/* CONFIG_XFS_VNODE_TRACING */
-
-	kdb_printf("   v_vfsp 0x%p v_number %Lx\n",
-		vp->v_vfsp, vp->v_number);
-}
-
-
-static int	kdbm_vnode(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr;
-	int nextarg = 1;
-	long offset = 0;
-	int diag;
-	vnode_t		*vp;
-/*	bhv_desc_t	*bh; */
-/*	kdb_symtab_t	 symtab;*/
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-
-	if (diag)
-		return diag;
-
-	vp = (vnode_t *)addr;
-
-	printvnode(vp);
-
-	return 0;
-}
-
-#ifdef	CONFIG_XFS_VNODE_TRACING
-/*
- * Print a vnode trace entry.
- */
-static int
-vn_trace_pr_entry(ktrace_entry_t *ktep)
-{
-	char		funcname[128];
-	kdb_symtab_t	symtab;
-
-
-	if ((__psint_t)ktep->val[0] == 0)
-		return 0;
-
-	if (kdbnearsym((unsigned int)ktep->val[8], &symtab)) {
-		unsigned long offval;
-
-		offval = (unsigned int)ktep->val[8] - symtab.sym_start;
-
-		if (offval)
-			sprintf(funcname, "%s+0x%lx", symtab.sym_name, offval);
-		else
-			sprintf(funcname, "%s", symtab.sym_name);
-	} else
-		funcname[0] = '\0';
-
-
-	switch ((__psint_t)ktep->val[0]) {
-	case VNODE_KTRACE_ENTRY:
-		kdb_printf("entry to %s i_count = %d",
-						(char *)ktep->val[1],
-						(__psint_t)ktep->val[3]);
-		break;
-
-	case VNODE_KTRACE_EXIT:
-		kdb_printf("exit from %s i_count = %d",
-						(char *)ktep->val[1],
-						(__psint_t)ktep->val[3]);
-		break;
-
-	case VNODE_KTRACE_HOLD:
-		if ((__psint_t)ktep->val[3] != 1)
-			kdb_printf("hold @%s:%d(%s) i_count %d => %d ",
-						(char *)ktep->val[1],
-						(__psint_t)ktep->val[2],
-						funcname,
-						(__psint_t)ktep->val[3] - 1,
-						(__psint_t)ktep->val[3]);
-		else
-			kdb_printf("get @%s:%d(%s) i_count = %d",
-						(char *)ktep->val[1],
-						(__psint_t)ktep->val[2],
-						funcname,
-						(__psint_t)ktep->val[3]);
-		break;
-
-	case VNODE_KTRACE_REF:
-		kdb_printf("ref @%s:%d(%s) i_count = %d",
-						(char *)ktep->val[1],
-						(__psint_t)ktep->val[2],
-						funcname,
-						(__psint_t)ktep->val[3]);
-		break;
-
-	case VNODE_KTRACE_RELE:
-		if ((__psint_t)ktep->val[3] != 1)
-			kdb_printf("rele @%s:%d(%s) i_count %d => %d ",
-						(char *)ktep->val[1],
-						(__psint_t)ktep->val[2],
-						funcname,
-						(__psint_t)ktep->val[3],
-						(__psint_t)ktep->val[3] - 1);
-		else
-			kdb_printf("free @%s:%d(%s) i_count = %d",
-						(char *)ktep->val[1],
-						(__psint_t)ktep->val[2],
-						funcname,
-						(__psint_t)ktep->val[3]);
-		break;
-
-	default:
-		kdb_printf("unknown vntrace record\n");
-		return 1;
-	}
-
-	kdb_printf("\n");
-
-	kdb_printf("  cpu = %d pid = %d ",
-			(__psint_t)ktep->val[6], (pid_t)ktep->val[7]);
-
-	printflags((__psunsigned_t)ktep->val[5], tab_vflags, "flag =");
-
-	if (kdbnearsym((unsigned int)ktep->val[4], &symtab)) {
-		unsigned long offval;
-
-		offval = (unsigned int)ktep->val[4] - symtab.sym_start;
-
-		if (offval)
-			kdb_printf("  ra = %s+0x%lx", symtab.sym_name, offval);
-		else
-			kdb_printf("  ra = %s", symtab.sym_name);
-	} else
-		kdb_printf("  ra = ?? 0x%p", (void *)ktep->val[4]);
-
-	return 1;
-}
-
-
-/*
- * Print out the trace buffer attached to the given vnode.
- */
-static int	kdbm_vntrace(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	int		diag;
-	int		nextarg = 1;
-	long		offset = 0;
-	unsigned long	addr;
-	vnode_t		*vp;
-	ktrace_entry_t	*ktep;
-	ktrace_snap_t	kts;
-
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-
-	if (diag)
-		return diag;
-
-	vp = (vnode_t *)addr;
-
-	if (vp->v_trace == NULL) {
-		kdb_printf("The vnode trace buffer is not initialized\n");
-
-		return 0;
-	}
-
-	kdb_printf("vntrace vp 0x%p\n", vp);
-
-	ktep = ktrace_first(vp->v_trace, &kts);
-
-	while (ktep != NULL) {
-		if (vn_trace_pr_entry(ktep))
-			kdb_printf("\n");
-
-		ktep = ktrace_next(vp->v_trace, &kts);
-	}
-
-	return 0;
-}
-/*
- * Print out the trace buffer attached to the given vnode.
- */
-static int	kdbm_vntraceaddr(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	int		diag;
-	int		nextarg = 1;
-	long		offset = 0;
-	unsigned long	addr;
-	struct ktrace	*kt;
-	ktrace_entry_t	*ktep;
-	ktrace_snap_t	kts;
-
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-
-	if (diag)
-		return diag;
-
-	kt = (struct ktrace *)addr;
-
-	kdb_printf("vntraceaddr kt 0x%p\n", kt);
-
-	ktep = ktrace_first(kt, &kts);
-
-	while (ktep != NULL) {
-		if (vn_trace_pr_entry(ktep))
-			kdb_printf("\n");
-
-		ktep = ktrace_next(kt, &kts);
-	}
-
-	return 0;
-}
-#endif	/* CONFIG_XFS_VNODE_TRACING */
-
-
-static void	printinode(struct inode *ip)
-{
-	unsigned long	addr;
-
-
-	if (ip == NULL)
-		return;
-
-	kdb_printf(" i_ino = %lu i_count = %u i_size %Ld\n",
-					ip->i_ino, atomic_read(&ip->i_count),
-					ip->i_size);
-
-	kdb_printf(
-		" i_mode = 0x%x  i_nlink = %d  i_rdev = %u:%u i_state = 0x%lx\n",
-					ip->i_mode, ip->i_nlink,
-					MAJOR(ip->i_rdev),
-					MINOR(ip->i_rdev),
-					ip->i_state);
-
-	kdb_printf(" i_hash.nxt = 0x%p i_hash.prv = 0x%p\n",
-					ip->i_hash.next, ip->i_hash.prev);
-	kdb_printf(" i_list.nxt = 0x%p i_list.prv = 0x%p\n",
-					ip->i_list.next, ip->i_list.prev);
-	kdb_printf(" i_dentry.nxt = 0x%p i_dentry.prv = 0x%p\n",
-					ip->i_dentry.next,
-					ip->i_dentry.prev);
-
-	addr = (unsigned long)ip;
-
-	kdb_printf(" i_sb = 0x%p i_op = 0x%p i_data = 0x%lx nrpages = %lu\n",
-					ip->i_sb, ip->i_op,
-					addr + offsetof(struct inode, i_data),
-					ip->i_data.nrpages);
-
-	kdb_printf("  vnode ptr 0x%p\n", LINVFS_GET_VP(ip));
-}
-
-
-static int	kdbm_vn(
-	int	argc,
-	const char **argv,
-	const char **envp,
-	struct pt_regs *regs)
-{
-	int		diag;
-	int		nextarg = 1;
-/*	char		*symname; */
-	long		offset = 0;
-	unsigned long	addr;
-	struct inode	*ip;
-/*	bhv_desc_t	*bh; */
-#ifdef	CONFIG_XFS_VNODE_TRACING
-	ktrace_entry_t	*ktep;
-	ktrace_snap_t	kts;
-#endif
-	vnode_t		*vp;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-
-	diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-
-	if (diag)
-		return diag;
-
-	vp = (vnode_t *)addr;
-
-	ip = LINVFS_GET_IP(vp);
-
-	kdb_printf("--> Inode @ 0x%p\n", ip);
-	printinode(ip);
-
-	kdb_printf("--> Vnode @ 0x%p\n", vp);
-	printvnode(vp);
-
-#ifdef	CONFIG_XFS_VNODE_TRACING
-
-	kdb_printf("--> Vntrace @ 0x%p/0x%p\n", vp, vp->v_trace);
-
-	if (vp->v_trace == NULL)
-		return 0;
-
-	ktep = ktrace_first(vp->v_trace, &kts);
-
-	while (ktep != NULL) {
-		if (vn_trace_pr_entry(ktep))
-			kdb_printf("\n");
-
-		ktep = ktrace_next(vp->v_trace, &kts);
-	}
-#endif	/* CONFIG_XFS_VNODE_TRACING */
-
-	return 0;
-}
-
-
-/* pagebuf stuff */
-
-static char	*pb_flag_vals[] = {
-/*  0 */ "READ", "WRITE", "MAPPED", "PARTIAL", "ASYNC",
-/*  5 */ "NONE", "DELWRI", "FREED", "SYNC", "MAPPABLE",
-/* 10 */ "STALE", "FS_MANAGED", "INVALID12", "LOCK", "TRYLOCK",
-/* 15 */ "DONT_BLOCK", "LOCKABLE", "PRIVATE_BH", "ALL_PAGES_MAPPED", 
-	 "ADDR_ALLOCATED",
-/* 20 */ "MEM_ALLOCATED", "FORCEIO", "FLUSH", "READ_AHEAD",
-	 NULL };
-
-static char	*pbm_flag_vals[] = {
-	"EOF", "HOLE", "DELAY", "INVALID0x08",
-	"INVALID0x10", "UNWRITTEN", "INVALID0x40", "INVALID0x80",
-	NULL };
-
-
-static char	*map_flags(unsigned long flags, char *mapping[])
-{
-	static	char	buffer[256];
-	int	index;
-	int	offset = 12;
-
-	buffer[0] = '\0';
-
-	for (index = 0; flags && mapping[index]; flags >>= 1, index++) {
-		if (flags & 1) {
-			if ((offset + strlen(mapping[index]) + 1) >= 80) {
-				strcat(buffer, "\n            ");
-				offset = 12;
-			} else if (offset > 12) {
-				strcat(buffer, " ");
-				offset++;
-			}
-			strcat(buffer, mapping[index]);
-			offset += strlen(mapping[index]);
-		}
-	}
-
-	return (buffer);
-}
-
-static char	*pb_flags(page_buf_flags_t pb_flag)
-{
-	return(map_flags((unsigned long) pb_flag, pb_flag_vals));
-}
-
-static int
-kdbm_pb_flags(int argc, const char **argv, const char **envp, struct pt_regs *regs)
-{
-	unsigned long flags;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-
-	diag = kdbgetularg(argv[1], &flags);
-	if (diag)
-		return diag;
-
-	kdb_printf("pb flags 0x%lx = %s\n", flags, pb_flags(flags));
-
-	return 0;
-}
-
-static int
-kdbm_pb(int argc, const char **argv, const char **envp, struct pt_regs *regs)
-{
-	page_buf_t bp;
-	unsigned long addr;
-	long	offset=0;
-	int nextarg;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-
-	nextarg = 1;
-	if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs)) ||
-	    (diag = kdb_getarea(bp, addr)))
-		return diag;
-
-	kdb_printf("page_buf_t at 0x%lx\n", addr);
-	kdb_printf("  pb_flags %s\n", pb_flags(bp.pb_flags));
-	kdb_printf("  pb_target 0x%p pb_hold %d pb_next 0x%p pb_prev 0x%p\n",
-		   bp.pb_target, bp.pb_hold.counter,
-		   bp.pb_list.next, bp.pb_list.prev);
-	kdb_printf("  pb_hash_index %d pb_hash_next 0x%p pb_hash_prev 0x%p\n",
-		   bp.pb_hash_index,
-		   bp.pb_hash_list.next,
-		   bp.pb_hash_list.prev);
-	kdb_printf("  pb_file_offset 0x%llx pb_buffer_length 0x%llx pb_addr 0x%p\n",
-		   (unsigned long long) bp.pb_file_offset,
-		   (unsigned long long) bp.pb_buffer_length,
-		   bp.pb_addr);
-	kdb_printf("  pb_bn 0x%Lx pb_count_desired 0x%lx\n",
-		   bp.pb_bn,
-		   (unsigned long) bp.pb_count_desired);
-	kdb_printf("  pb_io_remaining %d pb_error %u\n",
-		   bp.pb_io_remaining.counter,
-		   bp.pb_error);
-	kdb_printf("  pb_page_count %u pb_offset 0x%x pb_pages 0x%p\n",
-		bp.pb_page_count, bp.pb_offset,
-		bp.pb_pages);
-#ifdef PAGEBUF_LOCK_TRACKING
-	kdb_printf("  pb_iodonesema (%d,%d) pb_sema (%d,%d) pincount (%d) last holder %d\n",
-		   bp.pb_iodonesema.count.counter,
-		   bp.pb_iodonesema.sleepers,
-		   bp.pb_sema.count.counter, bp.pb_sema.sleepers,
-		   bp.pb_pin_count.counter, bp.pb_last_holder);
-#else
-	kdb_printf("  pb_iodonesema (%d,%d) pb_sema (%d,%d) pincount (%d)\n",
-		   bp.pb_iodonesema.count.counter,
-		   bp.pb_iodonesema.sleepers,
-		   bp.pb_sema.count.counter, bp.pb_sema.sleepers,
-		   bp.pb_pin_count.counter);
-#endif
-	if (bp.pb_fspriv || bp.pb_fspriv2) {
-		kdb_printf(  "pb_fspriv 0x%p pb_fspriv2 0x%p\n",
-			   bp.pb_fspriv, bp.pb_fspriv2);
-	}
-
-	return 0;
-}
-
-/* XXXXXXXXXXXXXXXXXXXXXX */
-/* The start of this deliberately looks like a read_descriptor_t in layout */
-typedef struct {
-	read_descriptor_t io_rdesc;
-
-	/* 0x10 */
-	page_buf_rw_t io_dir;	/* read or write */
-	loff_t io_offset;	/* Starting offset of I/O */
-	int io_iovec_nr;	/* Number of entries in iovec */
-
-	/* 0x20 */
-	struct iovec **io_iovec;	/* iovec list indexed by iovec_index */
-	loff_t io_iovec_offset;	/* offset into current iovec. */
-	int io_iovec_index;	/* current iovec being processed */
-	unsigned int io_sshift;	/* sector bit shift */
-	loff_t io_i_size;	/* size of the file */
-} pb_io_desc_t;
-
-static int
-kdbm_pbiodesc(int argc, const char **argv, const char **envp,
-	struct pt_regs *regs)
-{
-	pb_io_desc_t	pbio;
-	unsigned long addr;
-	long	offset=0;
-	int nextarg;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-
-	nextarg = 1;
-	if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs)) ||
-	    (diag = kdb_getarea(pbio, addr)))
-
-	kdb_printf("pb_io_desc_t at 0x%lx\n", addr);
-	kdb_printf("  io_rdesc [ written 0x%lx count 0x%lx buf 0x%p error %d ]\n",
-			(unsigned long) pbio.io_rdesc.written,
-			(unsigned long) pbio.io_rdesc.count,
-			pbio.io_rdesc.buf, pbio.io_rdesc.error);
-
-	kdb_printf("  io_dir %d io_offset 0x%Lx io_iovec_nr 0x%d\n",
-			pbio.io_dir, pbio.io_offset, pbio.io_iovec_nr);
-
-	kdb_printf("  io_iovec 0x%p io_iovec_offset 0x%Lx io_iovec_index 0x%d\n",
-		pbio.io_iovec, pbio.io_iovec_offset, pbio.io_iovec_index);
-
-	kdb_printf("  io_sshift 0x%d io_i_size 0x%Lx\n",
-		pbio.io_sshift, pbio.io_i_size);
-
-	return 0;
-}
-
-static int
-kdbm_pbmap(int argc, const char **argv, const char **envp,
-	struct pt_regs *regs)
-{
-	page_buf_bmap_t	pbm;
-	unsigned long addr;
-	long	offset=0;
-	int nextarg;
-	int diag;
-
-	if (argc != 1)
-		return KDB_ARGCOUNT;
-
-	nextarg = 1;
-	if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs)) ||
-	    (diag = kdb_getarea(pbm, addr)))
-
-	kdb_printf("page_buf_bmap_t at 0x%lx\n", addr);
-	kdb_printf("  pbm_bn 0x%llx pbm_offset 0x%Lx pbm_delta 0x%lx pbm_bsize 0x%lx\n",
-		(long long) pbm.pbm_bn, pbm.pbm_offset,
-		(unsigned long) pbm.pbm_delta, (unsigned long) pbm.pbm_bsize);
-
-	kdb_printf("  pbm_flags %s\n", map_flags(pbm.pbm_flags, pbm_flag_vals));
-
-	return 0;
-}
-
-#ifdef PAGEBUF_TRACE
-# ifdef __PAGEBUF_TRACE__
-# undef __PAGEBUF_TRACE__
-# undef PB_DEFINE_TRACES
-# undef PB_TRACE_START
-# undef PB_TRACE_REC
-# undef PB_TRACE_END
-# endif
-#include "pagebuf/page_buf_trace.h"
-
-#define EV_SIZE	(sizeof(event_names)/sizeof(char *))
-
-void
-pb_trace_core(
-	unsigned long match,
-	char	*event_match,
-	unsigned long long offset,
-	long long mask)
-{
-	extern struct pagebuf_trace_buf pb_trace;
-	int i, total, end;
-	pagebuf_trace_t	*trace;
-	char	*event;
-	char	value[10];
-
-	end = pb_trace.start - 1;
-	if (end < 0)
-		end = PB_TRACE_BUFSIZE - 1;
-
-	if (match && (match < PB_TRACE_BUFSIZE)) {
-		for (i = pb_trace.start, total = 0; i != end; i = CIRC_INC(i)) {
-			trace = &pb_trace.buf[i];
-			if (trace->pb == 0)
-				continue;
-			total++;
-		}
-		total = total - match;
-		for (i = pb_trace.start; i != end && total; i = CIRC_INC(i)) {
-			trace = &pb_trace.buf[i];
-			if (trace->pb == 0)
-				continue;
-			total--;
-		}
-		match = 0;
-	} else
-		i = pb_trace.start;
-	for ( ; i != end; i = CIRC_INC(i)) {
-		trace = &pb_trace.buf[i];
-
-		if (offset) {
-			if ((trace->offset & ~mask) != offset)
-				continue;
-		}
-
-		if (trace->pb == 0)
-			continue;
-
-		if ((match != 0) && (trace->pb != match))
-			continue;
-
-		if ((trace->event < EV_SIZE-1) && event_names[trace->event]) {
-			event = event_names[trace->event];
-		} else if (trace->event == EV_SIZE-1) {
-			event = (char *)trace->misc;
-		} else {
-			event = value;
-			sprintf(value, "%8d", trace->event);
-		}
-
-		if (event_match && strcmp(event, event_match)) {
-			continue;
-		}
-
-
-		kdb_printf("pb 0x%lx [%s] (hold %u lock %d) misc 0x%p",
-			   trace->pb, event,
-			   trace->hold, trace->lock_value,
-			   trace->misc);
-		kdb_symbol_print((unsigned int)trace->ra, NULL,
-			KDB_SP_SPACEB|KDB_SP_PAREN|KDB_SP_NEWLINE);
-		kdb_printf("    offset 0x%Lx size 0x%x task 0x%p\n",
-			   trace->offset, trace->size, trace->task);
-		kdb_printf("    flags: %s\n",
-			   pb_flags(trace->flags));
-	}
-}
-
-
-static int
-kdbm_pbtrace_offset(int argc, const char **argv, const char **envp,
-	struct pt_regs *regs)
-{
-	long mask = 0;
-	unsigned long offset = 0;
-	int diag;
-
-	if (argc > 2)
-		return KDB_ARGCOUNT;
-
-	if (argc > 0) {
-		diag = kdbgetularg(argv[1], &offset);
-		if (diag)
-			return diag;
-	}
-
-	if (argc > 1) {
-		diag = kdbgetularg(argv[1], &mask);
-		if (diag)
-			return diag;
-	}
-
-	pb_trace_core(0, NULL, (unsigned long long)offset,
-			       (long long)mask);	/* sign extent mask */
-	return 0;
-}
-
-static int
-kdbm_pbtrace(int argc, const char **argv, const char **envp,
-	struct pt_regs *regs)
-{
-	unsigned long addr = 0;
-	int diag, nextarg;
-	long offset = 0;
-	char	*event_match = NULL;
-
-	if (argc > 1)
-		return KDB_ARGCOUNT;
-
-	if (argc == 1) {
-		if (isupper(argv[1][0]) || islower(argv[1][0])) {
-			event_match = (char *)argv[1];
-			printk("event match on \"%s\"\n", event_match);
-			argc = 0;
-		} else {
-			nextarg = 1;
-			diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
-			if (diag) {
-				printk("failed to parse %s as a number\n",
-								argv[1]);
-				return diag;
-			}
-		}
-	}
-
-	pb_trace_core(addr, event_match, 0LL, 0LL);
-	return 0;
-}
-
-#else	/* PAGEBUF_TRACE */
-static int
-kdbm_pbtrace(int argc, const char **argv, const char **envp,
-	struct pt_regs *regs)
-{
-	kdb_printf("pagebuf tracing not compiled in\n");
-
-	return 0;
-}
-#endif	/* PAGEBUF_TRACE */
-
-static struct xif {
-	char	*name;
-	int	(*func)(int, const char **, const char **, struct pt_regs *);
-	char	*args;
-	char	*help;
-} xfsidbg_funcs[] = {
-  {  "vn",	kdbm_vn,	"<vnode>", "Dump inode/vnode/trace"},
-  {  "vnode",	kdbm_vnode,	"<vnode>", "Dump vnode"},
-#ifdef	CONFIG_XFS_VNODE_TRACING
-  {  "vntrace",	kdbm_vntrace,	"<vntrace>", "Dump vnode Trace"},
-  {  "vntraceaddr",	kdbm_vntraceaddr, "<vntrace>", "Dump vnode Trace by Address"},
-#endif	/* CONFIG_XFS_VNODE_TRACING */
-  {  "xagf",	kdbm_xfs_xagf,	"<agf>",
-				"Dump XFS allocation group freespace" },
-  {  "xagi",	kdbm_xfs_xagi,	"<agi>",
-				"Dump XFS allocation group inode" },
-  {  "xail",	kdbm_xfs_xaildump,	"<xfs_mount_t>",
-				"Dump XFS AIL for a mountpoint" },
-  {  "xalloc",	kdbm_xfs_xalloc,	"<xfs_alloc_arg_t>",
-				"Dump XFS allocation args structure" },
-#ifdef DEBUG
-  {  "xalmtrc",	kdbm_xfs_xalmtrace,	"<xfs_mount_t>",
-				"Dump XFS alloc mount-point trace" },
-#endif
-  {  "xattrcx",	kdbm_xfs_xattrcontext,	"<xfs_attr_list_context_t>",
-				"Dump XFS attr_list context struct"},
-  {  "xattrlf",	kdbm_xfs_xattrleaf,	"<xfs_attr_leafblock_t>",
-				"Dump XFS attribute leaf block"},
-  {  "xattrsf",	kdbm_xfs_xattrsf,	"<xfs_attr_shortform_t>",
-				"Dump XFS attribute shortform"},
-  {  "xbirec",	kdbm_xfs_xbirec,	"<xfs_bmbt_irec_t",
-				"Dump XFS bmap incore record"},
-  {  "xbmalla",	kdbm_xfs_xbmalla,	"<xfs_bmalloca_t>",
-				"Dump XFS bmalloc args structure"},
-  {  "xbrec",	kdbm_xfs_xbrec,		"<xfs_bmbt_rec_64_t",
-				"Dump XFS bmap record"},
-  {  "xbroot",	kdbm_xfs_xbroot,	"<xfs_inode_t>",
-				"Dump XFS bmap btree root (data)"},
-  {  "xbroota",	kdbm_xfs_xbroota,	"<xfs_inode_t>",
-				"Dump XFS bmap btree root (attr)"},
-  {  "xbtcur",	kdbm_xfs_xbtcur,	"<xfs_btree_cur_t>",
-				"Dump XFS btree cursor"},
-  {  "xbuf",	kdbm_xfs_xbuf,		"<xfs_buf_t>",
-				"Dump XFS data from a buffer"},
-  {  "xchash",	kdbm_xfs_xchash,	"<xfs_mount_t>",
-				"Dump XFS cluster hash"},
-  {  "xchlist",	kdbm_xfs_xchashlist,	"<xfs_chashlist_t>",
-				"Dump XFS cluster hash list"},
-  {  "xd2free",	kdbm_xfs_xdir2free,	"<xfs_dir2_free_t>",
-				"Dump XFS directory v2 freemap"},
-  {  "xdaargs",	kdbm_xfs_xdaargs,	"<xfs_da_args_t>",
-				"Dump XFS dir/attr args structure"},
-  {  "xdabuf",	kdbm_xfs_xdabuf,	"<xfs_dabuf_t>",
-				"Dump XFS dir/attr buf structure"},
-  {  "xdanode",	kdbm_xfs_xdanode,	"<xfs_da_intnode_t>",
-				"Dump XFS dir/attr node block"},
-  {  "xdastat",	kdbm_xfs_xdastate,	"<xfs_da_state_t>",
-				"Dump XFS dir/attr state_blk struct"},
-  {  "xdelay",	kdbm_xfs_delayed_blocks,	"<xfs_mount_t>",
-				"Dump delayed block totals"},
-  {  "xdirlf",	kdbm_xfs_xdirleaf,	"<xfs_dir_leafblock_t>",
-				"Dump XFS directory leaf block"},
-  {  "xdirsf",	kdbm_xfs_xdirsf,	"<xfs_dir_shortform_t>",
-				"Dump XFS directory shortform"},
-  {  "xdir2sf",	kdbm_xfs_xdir2sf,	"<xfs_dir2_sf_t>",
-				"Dump XFS directory v2 shortform"},
-  {  "xdiskdq",	kdbm_xfs_xqm_diskdq,	"<xfs_disk_dquot_t>",
-				"Dump XFS ondisk dquot (quota) struct"},
-  {  "xdqatt",	kdbm_xfs_xqm_dqattached_inos,	"<xfs_mount_t>",
-				 "All incore inodes with dquots"},
-  {  "xdqinfo",	kdbm_xfs_xqm_tpdqinfo,	"<xfs_trans_t>",
-				"Dump dqinfo structure of a trans"},
-  {  "xdquot",	kdbm_xfs_xqm_dquot,	"<xfs_dquot_t>",
-				"Dump XFS dquot (quota) structure"},
-  {  "xexlist",	kdbm_xfs_xexlist,	"<xfs_inode_t>",
-				"Dump XFS bmap extents in inode"},
-  {  "xflist",	kdbm_xfs_xflist,	"<xfs_bmap_free_t>",
-				"Dump XFS to-be-freed extent list"},
-  {  "xhelp",	kdbm_xfs_xhelp,		"",
-				"Print idbg-xfs help"},
-  {  "xicall",	kdbm_xfs_xiclogall,	"<xlog_in_core_t>",
-				"Dump All XFS in-core logs"},
-  {  "xiclog",	kdbm_xfs_xiclog,	"<xlog_in_core_t>",
-				"Dump XFS in-core log"},
-  {  "xihash",	kdbm_xfs_xihash,	"<xfs_mount_t>",
-				"Dump XFS inode hash statistics"},
-  {  "xinodes",	kdbm_xfs_xinodes,	"<xfs_mount_t>",
-				"Dump XFS inodes per mount"},
-  {  "xquiesce",kdbm_xfs_xinodes_quiesce, "<xfs_mount_t>",
-				"Dump non-quiesced XFS inodes per mount"},
-  {  "xl_rcit",	kdbm_xfs_xlog_ritem,	"<xlog_recover_item_t>",
-				"Dump XFS recovery item"},
-  {  "xl_rctr",	kdbm_xfs_xlog_rtrans,	"<xlog_recover_t>",
-				"Dump XFS recovery transaction"},
-  {  "xl_rctr2",kdbm_xfs_xlog_rtrans_entire,	"<xlog_recover_t>",
-				"Dump entire recovery transaction"},
-  {  "xl_tic",	kdbm_xfs_xlog_tic,	"<xlog_ticket_t>",
-				"Dump XFS log ticket"},
-  {  "xlog",	kdbm_xfs_xlog,	"<xlog_t>",
-				"Dump XFS log"},
-  {  "xlogcb",	kdbm_xfs_xiclogcb,	"<xlog_in_core_t>",
-				"Dump XFS in-core log callbacks"},
-  {  "xlogitm",	kdbm_xfs_xlogitem,	"<xfs_log_item_t>",
-				"Dump XFS log item structure"},
-  {  "xmount",	kdbm_xfs_xmount,	"<xfs_mount_t>",
-				"Dump XFS mount structure"},
-  {  "xnode",	kdbm_xfs_xnode,		"<xfs_inode_t>",
-				"Dump XFS inode"},
-  {  "xiocore",	kdbm_xfs_xcore,		"<xfs_iocore_t>",
-				"Dump XFS iocore"},
-  {  "xperag",	kdbm_xfs_xperag,	"<xfs_mount_t>",
-				"Dump XFS per-allocation group data"},
-  {  "xqinfo",  kdbm_xfs_xqm_qinfo,	"<xfs_mount_t>",
-				"Dump mount->m_quotainfo structure"},
-#ifdef	CONFIG_XFS_QUOTA
-  {  "xqm",	kdbm_xfs_xqm,		"",
-				"Dump XFS quota manager structure"},
-  {  "xqmfree",	kdbm_xfs_xqm_freelist,	"",
-				"Dump XFS global freelist of dquots"},
-  {  "xqmhtab",	kdbm_xfs_xqm_htab,	"",
-				"Dump XFS hashtable of dquots"},
-#endif	/* CONFIG_XFS_QUOTA */
-  {  "xqmplist",kdbm_xfs_xqm_mplist,	"<xfs_mount_t>",
-				"Dump XFS all dquots of a f/s"},
-  {  "xsb",	kdbm_xfs_xsb,		"<xfs_sb_t> <cnv>",
-				"Dump XFS superblock"},
-  {  "xtp",	kdbm_xfs_xtp,		"<xfs_trans_t>",
-				"Dump XFS transaction structure"},
-  {  "xtrres",	kdbm_xfs_xtrans_res,	"<xfs_mount_t>",
-				"Dump XFS reservation values"},
-  {  0,		0,	0 }
-};
-
-static int
-__init xfsidbg_init(void)
-{
-	struct xif	*p;
-
-	for (p = xfsidbg_funcs; p->name; p++)
-		kdb_register(p->name, p->func, p->args, p->help, 0);
-
-	kdb_register("pb", kdbm_pb, "<vaddr>", "Display page_buf_t", 0);
-	kdb_register("pbflags", kdbm_pb_flags, "<flags>",
-					"Display page buf flags", 0);
-	kdb_register("pbiodesc", kdbm_pbiodesc, "<pb_io_desc_t *>",
-					"Display I/O Descriptor", 0);
-	kdb_register("pbmap", kdbm_pbmap, "<page_buf_bmap_t *>",
-					"Display Bmap", 0);
-	kdb_register("pbtrace", kdbm_pbtrace, "<vaddr>|<count>",
-					"page_buf_t trace", 0);
-#ifdef PAGEBUF_TRACE
-	kdb_register("pboffset", kdbm_pbtrace_offset, "<addr> [<mask>]",
-					"page_buf_t trace", 0);
-#endif
-	return 0;
-}
-
-static void
-__exit xfsidbg_exit(void)
-{
-	struct xif	*p;
-
-	for (p = xfsidbg_funcs; p->name; p++)
-		kdb_unregister(p->name);
-
-	kdb_unregister("pb");
-	kdb_unregister("pbflags");
-	kdb_unregister("pbmap");
-	kdb_unregister("pbiodesc");
-	kdb_unregister("pbtrace");
-#ifdef PAGEBUF_TRACE
-	kdb_unregister("pboffset");
-#endif
-
-}
-
-/*
- * Argument to xfs_alloc routines, for allocation type.
- */
-static char *xfs_alloctype[] = {
-	"any_ag", "first_ag", "start_ag", "this_ag",
-	"start_bno", "near_bno", "this_bno"
-};
-
-
-/*
- * Prototypes for static functions.
- */
-#ifdef DEBUG
-static int xfs_alloc_trace_entry(ktrace_entry_t *ktep);
-#endif
-static void xfs_broot(xfs_inode_t *ip, xfs_ifork_t *f);
-static void xfs_btalloc(xfs_alloc_block_t *bt, int bsz);
-static void xfs_btbmap(xfs_bmbt_block_t *bt, int bsz);
-static void xfs_btino(xfs_inobt_block_t *bt, int bsz);
-static void xfs_buf_item_print(xfs_buf_log_item_t *blip, int summary);
-static void xfs_dastate_path(xfs_da_state_path_t *p);
-static void xfs_dir2data(void *addr, int size);
-static void xfs_dir2leaf(xfs_dir2_leaf_t *leaf, int size);
-static void xfs_dquot_item_print(xfs_dq_logitem_t *lip, int summary);
-static void xfs_efd_item_print(xfs_efd_log_item_t *efdp, int summary);
-static void xfs_efi_item_print(xfs_efi_log_item_t *efip, int summary);
-static char *xfs_fmtformat(xfs_dinode_fmt_t f);
-static char *xfs_fmtfsblock(xfs_fsblock_t bno, xfs_mount_t *mp);
-static char *xfs_fmtino(xfs_ino_t ino, xfs_mount_t *mp);
-static char *xfs_fmtlsn(xfs_lsn_t *lsnp);
-static char *xfs_fmtmode(int m);
-static char *xfs_fmtsize(size_t i);
-static char *xfs_fmtuuid(uuid_t *);
-static void xfs_inode_item_print(xfs_inode_log_item_t *ilip, int summary);
-static void xfs_inodebuf(xfs_buf_t *bp);
-static void xfs_prdinode(xfs_dinode_t *di, int coreonly, int convert);
-static void xfs_prdinode_core(xfs_dinode_core_t *dip, int convert);
-static void xfs_qoff_item_print(xfs_qoff_logitem_t *lip, int summary);
-static void xfs_xexlist_fork(xfs_inode_t *ip, int whichfork);
-static void xfs_xnode_fork(char *name, xfs_ifork_t *f);
-
-/*
- * Static functions.
- */
-
-#ifdef DEBUG
-/*
- * Print xfs alloc trace buffer entry.
- */
-static int
-xfs_alloc_trace_entry(ktrace_entry_t *ktep)
-{
-	static char *modagf_flags[] = {
-		"magicnum",
-		"versionnum",
-		"seqno",
-		"length",
-		"roots",
-		"levels",
-		"flfirst",
-		"fllast",
-		"flcount",
-		"freeblks",
-		"longest",
-		NULL
-	};
-
-	if (((__psint_t)ktep->val[0] & 0xffff) == 0)
-		return 0;
-	switch ((long)ktep->val[0] & 0xffffL) {
-	case XFS_ALLOC_KTRACE_ALLOC:
-		kdb_printf("alloc %s[%s %d] mp 0x%p\n",
-			(char *)ktep->val[1],
-			ktep->val[2] ? (char *)ktep->val[2] : "",
-			(__psint_t)ktep->val[0] >> 16,
-			(xfs_mount_t *)ktep->val[3]);
-		kdb_printf(
-	"agno %d agbno %d minlen %d maxlen %d mod %d prod %d minleft %d\n",
-			(__psunsigned_t)ktep->val[4],
-			(__psunsigned_t)ktep->val[5],
-			(__psunsigned_t)ktep->val[6],
-			(__psunsigned_t)ktep->val[7],
-			(__psunsigned_t)ktep->val[8],
-			(__psunsigned_t)ktep->val[9],
-			(__psunsigned_t)ktep->val[10]);
-		kdb_printf("total %d alignment %d len %d type %s otype %s\n",
-			(__psunsigned_t)ktep->val[11],
-			(__psunsigned_t)ktep->val[12],
-			(__psunsigned_t)ktep->val[13],
-			xfs_alloctype[((__psint_t)ktep->val[14]) >> 16],
-			xfs_alloctype[((__psint_t)ktep->val[14]) & 0xffff]);
-		kdb_printf("wasdel %d wasfromfl %d isfl %d userdata %d\n",
-			((__psint_t)ktep->val[15] & (1 << 3)) != 0,
-			((__psint_t)ktep->val[15] & (1 << 2)) != 0,
-			((__psint_t)ktep->val[15] & (1 << 1)) != 0,
-			((__psint_t)ktep->val[15] & (1 << 0)) != 0);
-		break;
-	case XFS_ALLOC_KTRACE_FREE:
-		kdb_printf("free %s[%s %d] mp 0x%p\n",
-			(char *)ktep->val[1],
-			ktep->val[2] ? (char *)ktep->val[2] : "",
-			(__psint_t)ktep->val[0] >> 16,
-			(xfs_mount_t *)ktep->val[3]);
-		kdb_printf("agno %d agbno %d len %d isfl %d\n",
-			(__psunsigned_t)ktep->val[4],
-			(__psunsigned_t)ktep->val[5],
-			(__psunsigned_t)ktep->val[6],
-			(__psint_t)ktep->val[7]);
-		break;
-	case XFS_ALLOC_KTRACE_MODAGF:
-		kdb_printf("modagf %s[%s %d] mp 0x%p\n",
-			(char *)ktep->val[1],
-			ktep->val[2] ? (char *)ktep->val[2] : "",
-			(__psint_t)ktep->val[0] >> 16,
-			(xfs_mount_t *)ktep->val[3]);
-		printflags((__psint_t)ktep->val[4], modagf_flags, "modified");
-		kdb_printf("seqno %d length %d roots b %d c %d\n",
-			(__psunsigned_t)ktep->val[5],
-			(__psunsigned_t)ktep->val[6],
-			(__psunsigned_t)ktep->val[7],
-			(__psunsigned_t)ktep->val[8]);
-		kdb_printf("levels b %d c %d flfirst %d fllast %d flcount %d\n",
-			(__psunsigned_t)ktep->val[9],
-			(__psunsigned_t)ktep->val[10],
-			(__psunsigned_t)ktep->val[11],
-			(__psunsigned_t)ktep->val[12],
-			(__psunsigned_t)ktep->val[13]);
-		kdb_printf("freeblks %d longest %d\n",
-			(__psunsigned_t)ktep->val[14],
-			(__psunsigned_t)ktep->val[15]);
-		break;
-
-	case XFS_ALLOC_KTRACE_UNBUSY:
-		kdb_printf("unbusy %s [%s %d] mp 0x%p\n",
-			(char *)ktep->val[1],
-			ktep->val[2] ? (char *)ktep->val[2] : "",
-			(__psint_t)ktep->val[0] >> 16,
-			(xfs_mount_t *)ktep->val[3]);
-		kdb_printf("      agno %d slot %d tp 0x%x\n",
-			(__psunsigned_t)ktep->val[4],
-			(__psunsigned_t)ktep->val[7],
-			(__psunsigned_t)ktep->val[8]);
-		break;
-	case XFS_ALLOC_KTRACE_BUSY:
-		kdb_printf("busy %s [%s %d] mp 0x%p\n",
-			(char *)ktep->val[1],
-			ktep->val[2] ? (char *)ktep->val[2] : "",
-			(__psint_t)ktep->val[0] >> 16,
-			(xfs_mount_t *)ktep->val[3]);
-		kdb_printf("      agno %d agbno %d len %d slot %d tp 0x%x\n",
-			(__psunsigned_t)ktep->val[4],
-			(__psunsigned_t)ktep->val[5],
-			(__psunsigned_t)ktep->val[6],
-			(__psunsigned_t)ktep->val[7],
-			(__psunsigned_t)ktep->val[8]);
-		break;
-	case XFS_ALLOC_KTRACE_BUSYSEARCH:
-		kdb_printf("busy-search %s [%s %d] mp 0x%p\n",
-			(char *)ktep->val[1],
-			ktep->val[2] ? (char *)ktep->val[2] : "",
-			(__psint_t)ktep->val[0] >> 16,
-			(xfs_mount_t *)ktep->val[3]);
-		kdb_printf("      agno %d agbno %d len %d slot %d tp 0x%x\n",
-			(__psunsigned_t)ktep->val[4],
-			(__psunsigned_t)ktep->val[5],
-			(__psunsigned_t)ktep->val[6],
-			(__psunsigned_t)ktep->val[7],
-			(__psunsigned_t)ktep->val[8]);
-		break;
-	default:
-		kdb_printf("unknown alloc trace record\n");
-		break;
-	}
-	return 1;
-}
-#endif /* DEBUG */
-
-/*
- * Print an xfs in-inode bmap btree root.
- */
-static void
-xfs_broot(xfs_inode_t *ip, xfs_ifork_t *f)
-{
-	xfs_bmbt_block_t	*broot;
-	int			format;
-	int			i;
-	xfs_bmbt_key_t		*kp;
-	xfs_bmbt_ptr_t		*pp;
-
-	format = f == &ip->i_df ? ip->i_d.di_format : ip->i_d.di_aformat;
-	if ((f->if_flags & XFS_IFBROOT) == 0 ||
-	    format != XFS_DINODE_FMT_BTREE) {
-		kdb_printf("inode 0x%p not btree format\n", ip);
-		return;
-	}
-	broot = f->if_broot;
-	kdb_printf("block @0x%p magic %x level %d numrecs %d\n",
-		broot, INT_GET(broot->bb_magic, ARCH_CONVERT), INT_GET(broot->bb_level, ARCH_CONVERT), INT_GET(broot->bb_numrecs, ARCH_CONVERT));
-	kp = XFS_BMAP_BROOT_KEY_ADDR(broot, 1, f->if_broot_bytes);
-	pp = XFS_BMAP_BROOT_PTR_ADDR(broot, 1, f->if_broot_bytes);
-	for (i = 1; i <= INT_GET(broot->bb_numrecs, ARCH_CONVERT); i++)
-		kdb_printf("\t%d: startoff %Ld ptr %Lx %s\n",
-			i, INT_GET(kp[i - 1].br_startoff, ARCH_CONVERT), INT_GET(pp[i - 1], ARCH_CONVERT),
-			xfs_fmtfsblock(INT_GET(pp[i - 1], ARCH_CONVERT), ip->i_mount));
-}
-
-/*
- * Print allocation btree block.
- */
-static void
-xfs_btalloc(xfs_alloc_block_t *bt, int bsz)
-{
-	int i;
-
-	kdb_printf("magic 0x%x level %d numrecs %d leftsib 0x%x rightsib 0x%x\n",
-		INT_GET(bt->bb_magic, ARCH_CONVERT), INT_GET(bt->bb_level, ARCH_CONVERT), INT_GET(bt->bb_numrecs, ARCH_CONVERT),
-		INT_GET(bt->bb_leftsib, ARCH_CONVERT), INT_GET(bt->bb_rightsib, ARCH_CONVERT));
-	if (INT_ISZERO(bt->bb_level, ARCH_CONVERT)) {
-
-		for (i = 1; i <= INT_GET(bt->bb_numrecs, ARCH_CONVERT); i++) {
-			xfs_alloc_rec_t *r;
-
-			r = XFS_BTREE_REC_ADDR(bsz, xfs_alloc, bt, i, 0);
-			kdb_printf("rec %d startblock 0x%x blockcount %d\n",
-				i, INT_GET(r->ar_startblock, ARCH_CONVERT), INT_GET(r->ar_blockcount, ARCH_CONVERT));
-		}
-	} else {
-		int mxr;
-
-		mxr = XFS_BTREE_BLOCK_MAXRECS(bsz, xfs_alloc, 0);
-		for (i = 1; i <= INT_GET(bt->bb_numrecs, ARCH_CONVERT); i++) {
-			xfs_alloc_key_t *k;
-			xfs_alloc_ptr_t *p;
-
-			k = XFS_BTREE_KEY_ADDR(bsz, xfs_alloc, bt, i, mxr);
-			p = XFS_BTREE_PTR_ADDR(bsz, xfs_alloc, bt, i, mxr);
-			kdb_printf("key %d startblock 0x%x blockcount %d ptr 0x%x\n",
-				i, INT_GET(k->ar_startblock, ARCH_CONVERT), INT_GET(k->ar_blockcount, ARCH_CONVERT), *p);
-		}
-	}
-}
-
-/*
- * Print a bmap btree block.
- */
-static void
-xfs_btbmap(xfs_bmbt_block_t *bt, int bsz)
-{
-	int i;
-
-	kdb_printf("magic 0x%x level %d numrecs %d leftsib %Lx ",
-		INT_GET(bt->bb_magic, ARCH_CONVERT),
-		INT_GET(bt->bb_level, ARCH_CONVERT),
-		INT_GET(bt->bb_numrecs, ARCH_CONVERT),
-		INT_GET(bt->bb_leftsib, ARCH_CONVERT));
-	kdb_printf("rightsib %Lx\n", INT_GET(bt->bb_rightsib, ARCH_CONVERT));
-	if (INT_ISZERO(bt->bb_level, ARCH_CONVERT)) {
-		for (i = 1; i <= INT_GET(bt->bb_numrecs, ARCH_CONVERT); i++) {
-			xfs_bmbt_rec_t *r;
-			xfs_bmbt_irec_t	irec;
-
-			r = (xfs_bmbt_rec_t *)XFS_BTREE_REC_ADDR(bsz,
-				xfs_bmbt, bt, i, 0);
-
-			xfs_bmbt_disk_get_all((xfs_bmbt_rec_t *)r, &irec);
-			kdb_printf("rec %d startoff %Ld startblock %Lx blockcount %Ld flag %d\n",
-				i, irec.br_startoff,
-				(__uint64_t)irec.br_startblock,
-				irec.br_blockcount, irec.br_state);
-		}
-	} else {
-		int mxr;
-
-		mxr = XFS_BTREE_BLOCK_MAXRECS(bsz, xfs_bmbt, 0);
-		for (i = 1; i <= INT_GET(bt->bb_numrecs, ARCH_CONVERT); i++) {
-			xfs_bmbt_key_t *k;
-			xfs_bmbt_ptr_t *p;
-
-			k = XFS_BTREE_KEY_ADDR(bsz, xfs_bmbt, bt, i, mxr);
-			p = XFS_BTREE_PTR_ADDR(bsz, xfs_bmbt, bt, i, mxr);
-			kdb_printf("key %d startoff %Ld ",
-				i, INT_GET(k->br_startoff, ARCH_CONVERT));
-			kdb_printf("ptr %Lx\n", INT_GET(*p, ARCH_CONVERT));
-		}
-	}
-}
-
-/*
- * Print an inode btree block.
- */
-static void
-xfs_btino(xfs_inobt_block_t *bt, int bsz)
-{
-	int i;
-
-	kdb_printf("magic 0x%x level %d numrecs %d leftsib 0x%x rightsib 0x%x\n",
-		INT_GET(bt->bb_magic, ARCH_CONVERT), INT_GET(bt->bb_level, ARCH_CONVERT), INT_GET(bt->bb_numrecs, ARCH_CONVERT),
-		INT_GET(bt->bb_leftsib, ARCH_CONVERT), INT_GET(bt->bb_rightsib, ARCH_CONVERT));
-	if (INT_ISZERO(bt->bb_level, ARCH_CONVERT)) {
-
-		for (i = 1; i <= INT_GET(bt->bb_numrecs, ARCH_CONVERT); i++) {
-			xfs_inobt_rec_t *r;
-
-			r = XFS_BTREE_REC_ADDR(bsz, xfs_inobt, bt, i, 0);
-			kdb_printf("rec %d startino 0x%x freecount %d, free %Lx\n",
-				i, INT_GET(r->ir_startino, ARCH_CONVERT), INT_GET(r->ir_freecount, ARCH_CONVERT),
-				INT_GET(r->ir_free, ARCH_CONVERT));
-		}
-	} else {
-		int mxr;
-
-		mxr = XFS_BTREE_BLOCK_MAXRECS(bsz, xfs_inobt, 0);
-		for (i = 1; i <= INT_GET(bt->bb_numrecs, ARCH_CONVERT); i++) {
-			xfs_inobt_key_t *k;
-			xfs_inobt_ptr_t *p;
-
-			k = XFS_BTREE_KEY_ADDR(bsz, xfs_inobt, bt, i, mxr);
-			p = XFS_BTREE_PTR_ADDR(bsz, xfs_inobt, bt, i, mxr);
-			kdb_printf("key %d startino 0x%x ptr 0x%x\n",
-				i, INT_GET(k->ir_startino, ARCH_CONVERT), INT_GET(*p, ARCH_CONVERT));
-		}
-	}
-}
-
-/*
- * Print a buf log item.
- */
-static void
-xfs_buf_item_print(xfs_buf_log_item_t *blip, int summary)
-{
-	static char *bli_flags[] = {
-		"hold",		/* 0x1 */
-		"dirty",	/* 0x2 */
-		"stale",	/* 0x4 */
-		"logged",	/* 0x8 */
-		"ialloc",	/* 0x10 */
-		"inode_stale",  /* 0x20 */
-		0
-		};
-	static char *blf_flags[] = {
-		"inode",	/* 0x1 */
-		"cancel",	/* 0x2 */
-		0
-		};
-
-	if (summary) {
-		kdb_printf("buf 0x%p blkno 0x%Lx ", blip->bli_buf,
-			     blip->bli_format.blf_blkno);
-		printflags(blip->bli_flags, bli_flags, "flags:");
-		kdb_printf("\n   ");
-		xfsidbg_xbuf_real(blip->bli_buf, 1);
-		return;
-	}
-	kdb_printf("buf 0x%p recur %d refcount %d flags:",
-		blip->bli_buf, blip->bli_recur,
-		atomic_read(&blip->bli_refcount));
-	printflags(blip->bli_flags, bli_flags, NULL);
-	kdb_printf("\n");
-	kdb_printf("size %d blkno 0x%Lx len 0x%x map size %d map 0x%p\n",
-		blip->bli_format.blf_size, blip->bli_format.blf_blkno,
-		(uint) blip->bli_format.blf_len, blip->bli_format.blf_map_size,
-		&(blip->bli_format.blf_data_map[0]));
-	kdb_printf("blf flags: ");
-	printflags((uint)blip->bli_format.blf_flags, blf_flags, NULL);
-#ifdef XFS_TRANS_DEBUG
-	kdb_printf("orig 0x%x logged 0x%x",
-		blip->bli_orig, blip->bli_logged);
-#endif
-	kdb_printf("\n");
-}
-
-/*
- * Print an xfs_da_state_path structure.
- */
-static void
-xfs_dastate_path(xfs_da_state_path_t *p)
-{
-	int i;
-
-	kdb_printf("active %d\n", p->active);
-	for (i = 0; i < XFS_DA_NODE_MAXDEPTH; i++) {
-		kdb_printf(" blk %d bp 0x%p blkno 0x%x",
-			i, p->blk[i].bp, p->blk[i].blkno);
-		kdb_printf(" index %d hashval 0x%x ",
-			p->blk[i].index, (uint_t)p->blk[i].hashval);
-		switch(p->blk[i].magic) {
-		case XFS_DA_NODE_MAGIC:		kdb_printf("NODE\n");	break;
-		case XFS_DIR_LEAF_MAGIC:	kdb_printf("DIR\n");	break;
-		case XFS_ATTR_LEAF_MAGIC:	kdb_printf("ATTR\n");	break;
-		case XFS_DIR2_LEAFN_MAGIC:	kdb_printf("DIR2\n");	break;
-		default:			kdb_printf("type ??\n");	break;
-		}
-	}
-}
-
-
-/*
- * Print an efd log item.
- */
-static void
-xfs_efd_item_print(xfs_efd_log_item_t *efdp, int summary)
-{
-	int		i;
-	xfs_extent_t	*ep;
-
-	if (summary) {
-		kdb_printf("Extent Free Done: ID 0x%Lx nextents %d (at 0x%p)\n",
-				efdp->efd_format.efd_efi_id,
-				efdp->efd_format.efd_nextents, efdp);
-		return;
-	}
-	kdb_printf("size %d nextents %d next extent %d efip 0x%p\n",
-		efdp->efd_format.efd_size, efdp->efd_format.efd_nextents,
-		efdp->efd_next_extent, efdp->efd_efip);
-	kdb_printf("efi_id 0x%Lx\n", efdp->efd_format.efd_efi_id);
-	kdb_printf("efd extents:\n");
-	ep = &(efdp->efd_format.efd_extents[0]);
-	for (i = 0; i < efdp->efd_next_extent; i++, ep++) {
-		kdb_printf("    block %Lx len %d\n",
-			ep->ext_start, ep->ext_len);
-	}
-}
-
-/*
- * Print an efi log item.
- */
-static void
-xfs_efi_item_print(xfs_efi_log_item_t *efip, int summary)
-{
-	int		i;
-	xfs_extent_t	*ep;
-	static char *efi_flags[] = {
-		"recovered",	/* 0x1 */
-		"committed",	/* 0x2 */
-		"cancelled",	/* 0x4 */
-		0,
-		};
-
-	if (summary) {
-		kdb_printf("Extent Free Intention: ID 0x%Lx nextents %d (at 0x%p)\n",
-				efip->efi_format.efi_id,
-				efip->efi_format.efi_nextents, efip);
-		return;
-	}
-	kdb_printf("size %d nextents %d next extent %d\n",
-		efip->efi_format.efi_size, efip->efi_format.efi_nextents,
-		efip->efi_next_extent);
-	kdb_printf("id %Lx", efip->efi_format.efi_id);
-	printflags(efip->efi_flags, efi_flags, "flags :");
-	kdb_printf("\n");
-	kdb_printf("efi extents:\n");
-	ep = &(efip->efi_format.efi_extents[0]);
-	for (i = 0; i < efip->efi_next_extent; i++, ep++) {
-		kdb_printf("    block %Lx len %d\n",
-			ep->ext_start, ep->ext_len);
-	}
-}
-
-/*
- * Format inode "format" into a static buffer & return it.
- */
-static char *
-xfs_fmtformat(xfs_dinode_fmt_t f)
-{
-	static char *t[] = {
-		"dev",
-		"local",
-		"extents",
-		"btree",
-		"uuid"
-	};
-
-	return t[f];
-}
-
-/*
- * Format fsblock number into a static buffer & return it.
- */
-static char *
-xfs_fmtfsblock(xfs_fsblock_t bno, xfs_mount_t *mp)
-{
-	static char rval[50];
-
-	if (bno == NULLFSBLOCK)
-		sprintf(rval, "NULLFSBLOCK");
-	else if (ISNULLSTARTBLOCK(bno))
-		sprintf(rval, "NULLSTARTBLOCK(%Ld)", STARTBLOCKVAL(bno));
-	else if (mp)
-		sprintf(rval, "%Ld[%x:%x]", (xfs_dfsbno_t)bno,
-			XFS_FSB_TO_AGNO(mp, bno), XFS_FSB_TO_AGBNO(mp, bno));
-	else
-		sprintf(rval, "%Ld", (xfs_dfsbno_t)bno);
-	return rval;
-}
-
-/*
- * Format inode number into a static buffer & return it.
- */
-static char *
-xfs_fmtino(xfs_ino_t ino, xfs_mount_t *mp)
-{
-	static char rval[50];
-
-	if (mp)
-		sprintf(rval, "%llu[%x:%x:%x]",
-			(unsigned long long) ino,
-			XFS_INO_TO_AGNO(mp, ino),
-			XFS_INO_TO_AGBNO(mp, ino),
-			XFS_INO_TO_OFFSET(mp, ino));
-	else
-		sprintf(rval, "%llu", (unsigned long long) ino);
-	return rval;
-}
-
-/*
- * Format an lsn for printing into a static buffer & return it.
- */
-static char *
-xfs_fmtlsn(xfs_lsn_t *lsnp)
-{
-	uint		*wordp;
-	uint		*word2p;
-	static char	buf[20];
-
-	wordp = (uint *)lsnp;
-	word2p = wordp++;
-	sprintf(buf, "[%u:%u]", *wordp, *word2p);
-
-	return buf;
-}
-
-/*
- * Format file mode into a static buffer & return it.
- */
-static char *
-xfs_fmtmode(int m)
-{
-	static char rval[16];
-
-	sprintf(rval, "%c%c%c%c%c%c%c%c%c%c%c%c%c",
-		"?fc?dxb?r?l?S?m?"[(m & IFMT) >> 12],
-		m & ISUID ? 'u' : '-',
-		m & ISGID ? 'g' : '-',
-		m & ISVTX ? 'v' : '-',
-		m & IREAD ? 'r' : '-',
-		m & IWRITE ? 'w' : '-',
-		m & IEXEC ? 'x' : '-',
-		m & (IREAD >> 3) ? 'r' : '-',
-		m & (IWRITE >> 3) ? 'w' : '-',
-		m & (IEXEC >> 3) ? 'x' : '-',
-		m & (IREAD >> 6) ? 'r' : '-',
-		m & (IWRITE >> 6) ? 'w' : '-',
-		m & (IEXEC >> 6) ? 'x' : '-');
-	return rval;
-}
-
-/*
- * Format a size into a static buffer & return it.
- */
-static char *
-xfs_fmtsize(size_t i)
-{
-	static char rval[20];
-
-	/* size_t is 32 bits in 32-bit kernel, 64 bits in 64-bit kernel */
-	sprintf(rval, "0x%lx", (unsigned long) i);
-	return rval;
-}
-
-/*
- * Format a uuid into a static buffer & return it.
- */
-static char *
-xfs_fmtuuid(uuid_t *uu)
-{
-	static char rval[40];
-	char        *o          = rval;
-	char        *i          = (unsigned char*)uu;
-	int         b;
-
-	for (b=0;b<16;b++) {
-	    o+=sprintf(o, "%02x", *i++);
-	    if (b==3||b==5||b==7||b==9) *o++='-';
-	}
-	*o='\0';
-
-	return rval;
-}
-
-/*
- * Print an inode log item.
- */
-static void
-xfs_inode_item_print(xfs_inode_log_item_t *ilip, int summary)
-{
-	static char *ili_flags[] = {
-		"hold",		/* 0x1 */
-		"iolock excl",	/* 0x2 */
-		"iolock shrd",	/* 0x4 */
-		0
-		};
-	static char *ilf_fields[] = {
-		"core",		/* 0x001 */
-		"ddata",	/* 0x002 */
-		"dexts",	/* 0x004 */
-		"dbroot",	/* 0x008 */
-		"dev",		/* 0x010 */
-		"uuid",		/* 0x020 */
-		"adata",	/* 0x040 */
-		"aext",		/* 0x080 */
-		"abroot",	/* 0x100 */
-		0
-		};
-
-	if (summary) {
-		kdb_printf("inode 0x%p logged %d ",
-			ilip->ili_inode, ilip->ili_logged);
-		printflags(ilip->ili_flags, ili_flags, "flags:");
-		printflags(ilip->ili_format.ilf_fields, ilf_fields, "format:");
-		printflags(ilip->ili_last_fields, ilf_fields, "lastfield:");
-		kdb_printf("\n");
-		return;
-	}
-	kdb_printf("inode 0x%p ino 0x%llu logged %d flags: ",
-		ilip->ili_inode, (unsigned long long) ilip->ili_format.ilf_ino,
-		ilip->ili_logged);
-	printflags(ilip->ili_flags, ili_flags, NULL);
-	kdb_printf("\n");
-	kdb_printf("ilock recur %d iolock recur %d ext buf 0x%p\n",
-		ilip->ili_ilock_recur, ilip->ili_iolock_recur,
-		ilip->ili_extents_buf);
-#ifdef XFS_TRANS_DEBUG
-	kdb_printf("root bytes %d root orig 0x%x\n",
-		ilip->ili_root_size, ilip->ili_orig_root);
-#endif
-	kdb_printf("size %d fields: ", ilip->ili_format.ilf_size);
-	printflags(ilip->ili_format.ilf_fields, ilf_fields, "formatfield");
-	kdb_printf(" last fields: ");
-	printflags(ilip->ili_last_fields, ilf_fields, "lastfield");
-	kdb_printf("\n");
-	kdb_printf(" flush lsn %s last lsn %s\n",
-		xfs_fmtlsn(&(ilip->ili_flush_lsn)),
-		xfs_fmtlsn(&(ilip->ili_last_lsn)));
-	kdb_printf("dsize %d, asize %d, rdev 0x%x\n",
-		ilip->ili_format.ilf_dsize,
-		ilip->ili_format.ilf_asize,
-		ilip->ili_format.ilf_u.ilfu_rdev);
-	kdb_printf("blkno 0x%Lx len 0x%x boffset 0x%x\n",
-		ilip->ili_format.ilf_blkno,
-		ilip->ili_format.ilf_len,
-		ilip->ili_format.ilf_boffset);
-}
-
-/*
- * Print a dquot log item.
- */
-/* ARGSUSED */
-static void
-xfs_dquot_item_print(xfs_dq_logitem_t *lip, int summary)
-{
-	kdb_printf("dquot 0x%p\n",
-		lip->qli_dquot);
-
-}
-
-/*
- * Print a quotaoff log item.
- */
-/* ARGSUSED */
-static void
-xfs_qoff_item_print(xfs_qoff_logitem_t *lip, int summary)
-{
-	kdb_printf("start qoff item 0x%p flags 0x%x\n",
-		lip->qql_start_lip, lip->qql_format.qf_flags);
-
-}
-
-/*
- * Print buffer full of inodes.
- */
-static void
-xfs_inodebuf(xfs_buf_t *bp)
-{
-	xfs_dinode_t *di;
-	int n, i;
-
-	n = XFS_BUF_COUNT(bp) >> 8;
-	for (i = 0; i < n; i++) {
-		di = (xfs_dinode_t *)xfs_buf_offset(bp,
-					i * 256);
-		xfs_prdinode(di, 0, ARCH_CONVERT);
-	}
-}
-
-
-/*
- * Print disk inode.
- */
-static void
-xfs_prdinode(xfs_dinode_t *di, int coreonly, int convert)
-{
-	xfs_prdinode_core(&di->di_core, convert);
-	if (!coreonly)
-		kdb_printf("next_unlinked 0x%x u@0x%p\n",
-			INT_GET(di->di_next_unlinked, convert),
-			&di->di_u);
-}
-
-/*
- * Print disk inode core.
- */
-static void
-xfs_prdinode_core(xfs_dinode_core_t *dip, int convert)
-{
-	static char *diflags[] = {
-		"realtime",		/* XFS_DIFLAG_REALTIME */
-		"prealloc",		/* XFS_DIFLAG_PREALLOC */
-		"newrtbm",		/* XFS_DIFLAG_NEWRTBM */
-		"immutable",		/* XFS_DIFLAG_IMMUTABLE */
-		"append",		/* XFS_DIFLAG_APPEND */
-		"sync",			/* XFS_DIFLAG_SYNC */
-		"noatime",		/* XFS_DIFLAG_NOATIME */
-		"nodump",		/* XFS_DIFLAG_NODUMP */
-		NULL
-	};
-
-	kdb_printf("magic 0x%x mode 0%o (%s) version 0x%x format 0x%x (%s)\n",
-		INT_GET(dip->di_magic, convert),
-		INT_GET(dip->di_mode, convert),
-		xfs_fmtmode(INT_GET(dip->di_mode, convert)),
-		INT_GET(dip->di_version, convert),
-		INT_GET(dip->di_format, convert),
-		xfs_fmtformat(
-		    (xfs_dinode_fmt_t)INT_GET(dip->di_format, convert)));
-	kdb_printf("nlink %d uid %d gid %d projid %d flushiter %u\n",
-		INT_GET(dip->di_nlink, convert),
-		INT_GET(dip->di_uid, convert),
-		INT_GET(dip->di_gid, convert),
-		(uint)INT_GET(dip->di_projid, convert),
-		(uint)INT_GET(dip->di_flushiter, convert));
-	kdb_printf("atime 0x%x:%x mtime 0x%x:%x ctime 0x%x:%x\n",
-		INT_GET(dip->di_atime.t_sec, convert),
-		INT_GET(dip->di_atime.t_nsec, convert),
-		INT_GET(dip->di_mtime.t_sec, convert),
-		INT_GET(dip->di_mtime.t_nsec, convert),
-		INT_GET(dip->di_ctime.t_sec, convert),
-		INT_GET(dip->di_ctime.t_nsec, convert));
-	kdb_printf("size 0x%Lx ", INT_GET(dip->di_size, convert));
-	kdb_printf("nblocks %Ld extsize 0x%x nextents 0x%x anextents 0x%x\n",
-		INT_GET(dip->di_nblocks, convert),
-		INT_GET(dip->di_extsize, convert),
-		INT_GET(dip->di_nextents, convert),
-		INT_GET(dip->di_anextents, convert));
-	kdb_printf("forkoff %d aformat 0x%x (%s) dmevmask 0x%x dmstate 0x%x ",
-		INT_GET(dip->di_forkoff, convert),
-		INT_GET(dip->di_aformat, convert),
-		xfs_fmtformat(
-		    (xfs_dinode_fmt_t)INT_GET(dip->di_aformat, convert)),
-		INT_GET(dip->di_dmevmask, convert),
-		INT_GET(dip->di_dmstate, convert));
-	printflags(INT_GET(dip->di_flags, convert), diflags, "flags");
-	kdb_printf("gen 0x%x\n", INT_GET(dip->di_gen, convert));
-}
-
-/*
- * Print xfs extent list for a fork.
- */
-static void
-xfs_xexlist_fork(xfs_inode_t *ip, int whichfork)
-{
-	int nextents, i;
-	xfs_ifork_t *ifp;
-	xfs_bmbt_irec_t irec;
-
-	ifp = XFS_IFORK_PTR(ip, whichfork);
-	if (ifp->if_flags & XFS_IFEXTENTS) {
-		nextents = ifp->if_bytes / sizeof(xfs_bmbt_rec_64_t);
-		kdb_printf("inode 0x%p %cf extents 0x%p nextents 0x%x\n",
-			ip, "da"[whichfork], ifp->if_u1.if_extents, nextents);
-		for (i = 0; i < nextents; i++) {
-			xfs_bmbt_get_all(&ifp->if_u1.if_extents[i], &irec);
-			kdb_printf(
-		"%d: startoff %Ld startblock %s blockcount %Ld flag %d\n",
-			i, irec.br_startoff,
-			xfs_fmtfsblock(irec.br_startblock, ip->i_mount),
-			irec.br_blockcount, irec.br_state);
-		}
-	}
-}
-
-static void
-xfs_xnode_fork(char *name, xfs_ifork_t *f)
-{
-	static char *tab_flags[] = {
-		"inline",	/* XFS_IFINLINE */
-		"extents",	/* XFS_IFEXTENTS */
-		"broot",	/* XFS_IFBROOT */
-		NULL
-	};
-	int *p;
-
-	kdb_printf("%s fork", name);
-	if (f == NULL) {
-		kdb_printf(" empty\n");
-		return;
-	} else
-		kdb_printf("\n");
-	kdb_printf(" bytes %s ", xfs_fmtsize(f->if_bytes));
-	kdb_printf("real_bytes %s lastex 0x%x u1:%s 0x%p\n",
-		xfs_fmtsize(f->if_real_bytes), f->if_lastex,
-		f->if_flags & XFS_IFINLINE ? "data" : "extents",
-		f->if_flags & XFS_IFINLINE ?
-			f->if_u1.if_data :
-			(char *)f->if_u1.if_extents);
-	kdb_printf(" broot 0x%p broot_bytes %s ext_max %d ",
-		f->if_broot, xfs_fmtsize(f->if_broot_bytes), f->if_ext_max);
-	printflags(f->if_flags, tab_flags, "flags");
-	kdb_printf("\n");
-	kdb_printf(" u2");
-	for (p = (int *)&f->if_u2;
-	     p < (int *)((char *)&f->if_u2 + XFS_INLINE_DATA);
-	     p++)
-		kdb_printf(" 0x%x", *p);
-	kdb_printf("\n");
-}
-
-/*
- * Command-level xfs-idbg functions.
- */
-
-/*
- * Print xfs allocation group freespace header.
- */
-static void
-xfsidbg_xagf(xfs_agf_t *agf)
-{
-	kdb_printf("magicnum 0x%x versionnum 0x%x seqno 0x%x length 0x%x\n",
-		INT_GET(agf->agf_magicnum, ARCH_CONVERT),
-		INT_GET(agf->agf_versionnum, ARCH_CONVERT),
-		INT_GET(agf->agf_seqno, ARCH_CONVERT),
-		INT_GET(agf->agf_length, ARCH_CONVERT));
-	kdb_printf("roots b 0x%x c 0x%x levels b %d c %d\n",
-		INT_GET(agf->agf_roots[XFS_BTNUM_BNO], ARCH_CONVERT),
-		INT_GET(agf->agf_roots[XFS_BTNUM_CNT], ARCH_CONVERT),
-		INT_GET(agf->agf_levels[XFS_BTNUM_BNO], ARCH_CONVERT),
-		INT_GET(agf->agf_levels[XFS_BTNUM_CNT], ARCH_CONVERT));
-	kdb_printf("flfirst %d fllast %d flcount %d freeblks %d longest %d\n",
-		INT_GET(agf->agf_flfirst, ARCH_CONVERT),
-		INT_GET(agf->agf_fllast, ARCH_CONVERT),
-		INT_GET(agf->agf_flcount, ARCH_CONVERT),
-		INT_GET(agf->agf_freeblks, ARCH_CONVERT),
-		INT_GET(agf->agf_longest, ARCH_CONVERT));
-}
-
-/*
- * Print xfs allocation group inode header.
- */
-static void
-xfsidbg_xagi(xfs_agi_t *agi)
-{
-	int	i;
-	int	j;
-
-	kdb_printf("magicnum 0x%x versionnum 0x%x seqno 0x%x length 0x%x\n",
-		INT_GET(agi->agi_magicnum, ARCH_CONVERT),
-		INT_GET(agi->agi_versionnum, ARCH_CONVERT),
-		INT_GET(agi->agi_seqno, ARCH_CONVERT),
-		INT_GET(agi->agi_length, ARCH_CONVERT));
-	kdb_printf("count 0x%x root 0x%x level 0x%x\n",
-		INT_GET(agi->agi_count, ARCH_CONVERT),
-		INT_GET(agi->agi_root, ARCH_CONVERT),
-		INT_GET(agi->agi_level, ARCH_CONVERT));
-	kdb_printf("freecount 0x%x newino 0x%x dirino 0x%x\n",
-		INT_GET(agi->agi_freecount, ARCH_CONVERT),
-		INT_GET(agi->agi_newino, ARCH_CONVERT),
-		INT_GET(agi->agi_dirino, ARCH_CONVERT));
-
-	kdb_printf("unlinked buckets\n");
-	for (i = 0; i < XFS_AGI_UNLINKED_BUCKETS; i++) {
-		for (j = 0; j < 4; j++, i++) {
-			kdb_printf("0x%08x ",
-				INT_GET(agi->agi_unlinked[i], ARCH_CONVERT));
-		}
-		kdb_printf("\n");
-	}
-}
-
-
-/*
- * Print an allocation argument structure for XFS.
- */
-static void
-xfsidbg_xalloc(xfs_alloc_arg_t *args)
-{
-	kdb_printf("tp 0x%p mp 0x%p agbp 0x%p pag 0x%p fsbno %s\n",
-		args->tp, args->mp, args->agbp, args->pag,
-		xfs_fmtfsblock(args->fsbno, args->mp));
-	kdb_printf("agno 0x%x agbno 0x%x minlen 0x%x maxlen 0x%x mod 0x%x\n",
-		args->agno, args->agbno, args->minlen, args->maxlen, args->mod);
-	kdb_printf("prod 0x%x minleft 0x%x total 0x%x alignment 0x%x\n",
-		args->prod, args->minleft, args->total, args->alignment);
-	kdb_printf("minalignslop 0x%x len 0x%x type %s otype %s wasdel %d\n",
-		args->minalignslop, args->len, xfs_alloctype[args->type],
-		xfs_alloctype[args->otype], args->wasdel);
-	kdb_printf("wasfromfl %d isfl %d userdata %d\n",
-		args->wasfromfl, args->isfl, args->userdata);
-}
-
-#ifdef DEBUG
-/*
- * Print out all the entries in the alloc trace buf corresponding
- * to the given mount point.
- */
-static void
-xfsidbg_xalmtrace(xfs_mount_t *mp)
-{
-	ktrace_entry_t	*ktep;
-	ktrace_snap_t	kts;
-	extern ktrace_t	*xfs_alloc_trace_buf;
-
-	if (xfs_alloc_trace_buf == NULL) {
-		kdb_printf("The xfs alloc trace buffer is not initialized\n");
-		return;
-	}
-
-	ktep = ktrace_first(xfs_alloc_trace_buf, &kts);
-	while (ktep != NULL) {
-		if ((__psint_t)ktep->val[0] && (xfs_mount_t *)ktep->val[3] == mp) {
-			(void)xfs_alloc_trace_entry(ktep);
-			kdb_printf("\n");
-		}
-		ktep = ktrace_next(xfs_alloc_trace_buf, &kts);
-	}
-}
-#endif /* DEBUG */
-
-/*
- * Print an attr_list() context structure.
- */
-static void
-xfsidbg_xattrcontext(xfs_attr_list_context_t *context)
-{
-	static char *attr_arg_flags[] = {
-		"DONTFOLLOW",	/* 0x0001 */
-		"?",		/* 0x0002 */
-		"?",		/* 0x0004 */
-		"?",		/* 0x0008 */
-		"CREATE",	/* 0x0010 */
-		"?",		/* 0x0020 */
-		"?",		/* 0x0040 */
-		"?",		/* 0x0080 */
-		"?",		/* 0x0100 */
-		"?",		/* 0x0200 */
-		"?",		/* 0x0400 */
-		"?",		/* 0x0800 */
-		"KERNOTIME",	/* 0x1000 */
-		NULL
-	};
-
-	kdb_printf("dp 0x%p, dupcnt %d, resynch %d",
-		    context->dp, context->dupcnt, context->resynch);
-	printflags((__psunsigned_t)context->flags, attr_arg_flags, ", flags");
-	kdb_printf("\ncursor h/b/o 0x%x/0x%x/%d -- p/p/i 0x%x/0x%x/0x%x\n",
-			  context->cursor->hashval, context->cursor->blkno,
-			  context->cursor->offset, context->cursor->pad1,
-			  context->cursor->pad2, context->cursor->initted);
-	kdb_printf("alist 0x%p, bufsize 0x%x, count %d, firstu 0x%x\n",
-		       context->alist, context->bufsize, context->count,
-		       context->firstu);
-}
-
-/*
- * Print attribute leaf block.
- */
-static void
-xfsidbg_xattrleaf(xfs_attr_leafblock_t *leaf)
-{
-	xfs_attr_leaf_hdr_t *h;
-	xfs_da_blkinfo_t *i;
-	xfs_attr_leaf_map_t *m;
-	xfs_attr_leaf_entry_t *e;
-	xfs_attr_leaf_name_local_t *l;
-	xfs_attr_leaf_name_remote_t *r;
-	int j, k;
-
-	h = &leaf->hdr;
-	i = &h->info;
-	kdb_printf("hdr info forw 0x%x back 0x%x magic 0x%x\n",
-		i->forw, i->back, i->magic);
-	kdb_printf("hdr count %d usedbytes %d firstused %d holes %d\n",
-		INT_GET(h->count, ARCH_CONVERT),
-		INT_GET(h->usedbytes, ARCH_CONVERT),
-		INT_GET(h->firstused, ARCH_CONVERT), h->holes);
-	for (j = 0, m = h->freemap; j < XFS_ATTR_LEAF_MAPSIZE; j++, m++) {
-		kdb_printf("hdr freemap %d base %d size %d\n",
-			j, INT_GET(m->base, ARCH_CONVERT),
-			INT_GET(m->size, ARCH_CONVERT));
-	}
-	for (j = 0, e = leaf->entries; j < INT_GET(h->count, ARCH_CONVERT); j++, e++) {
-		kdb_printf("[%2d] hash 0x%x nameidx %d flags 0x%x",
-			j, INT_GET(e->hashval, ARCH_CONVERT),
-			INT_GET(e->nameidx, ARCH_CONVERT), e->flags);
-		if (e->flags & XFS_ATTR_LOCAL)
-			kdb_printf("LOCAL ");
-		if (e->flags & XFS_ATTR_ROOT)
-			kdb_printf("ROOT ");
-		if (e->flags & XFS_ATTR_INCOMPLETE)
-			kdb_printf("INCOMPLETE ");
-		k = ~(XFS_ATTR_LOCAL | XFS_ATTR_ROOT | XFS_ATTR_INCOMPLETE);
-		if ((e->flags & k) != 0)
-			kdb_printf("0x%x", e->flags & k);
-		kdb_printf(">\n     name \"");
-		if (e->flags & XFS_ATTR_LOCAL) {
-			l = XFS_ATTR_LEAF_NAME_LOCAL(leaf, j);
-			for (k = 0; k < l->namelen; k++)
-				kdb_printf("%c", l->nameval[k]);
-			kdb_printf("\"(%d) value \"", l->namelen);
-			for (k = 0; (k < INT_GET(l->valuelen, ARCH_CONVERT)) && (k < 32); k++)
-				kdb_printf("%c", l->nameval[l->namelen + k]);
-			if (k == 32)
-				kdb_printf("...");
-			kdb_printf("\"(%d)\n",
-				INT_GET(l->valuelen, ARCH_CONVERT));
-		} else {
-			r = XFS_ATTR_LEAF_NAME_REMOTE(leaf, j);
-			for (k = 0; k < r->namelen; k++)
-				kdb_printf("%c", r->name[k]);
-			kdb_printf("\"(%d) value blk 0x%x len %d\n",
-				    r->namelen,
-				    INT_GET(r->valueblk, ARCH_CONVERT),
-				    INT_GET(r->valuelen, ARCH_CONVERT));
-		}
-	}
-}
-
-/*
- * Print a shortform attribute list.
- */
-static void
-xfsidbg_xattrsf(xfs_attr_shortform_t *s)
-{
-	xfs_attr_sf_hdr_t *sfh;
-	xfs_attr_sf_entry_t *sfe;
-	int i, j;
-
-	sfh = &s->hdr;
-	kdb_printf("hdr count %d\n", INT_GET(sfh->count, ARCH_CONVERT));
-	for (i = 0, sfe = s->list; i < INT_GET(sfh->count, ARCH_CONVERT); i++) {
-		kdb_printf("entry %d namelen %d name \"", i, sfe->namelen);
-		for (j = 0; j < sfe->namelen; j++)
-			kdb_printf("%c", sfe->nameval[j]);
-		kdb_printf("\" valuelen %d value \"", INT_GET(sfe->valuelen, ARCH_CONVERT));
-		for (j = 0; (j < INT_GET(sfe->valuelen, ARCH_CONVERT)) && (j < 32); j++)
-			kdb_printf("%c", sfe->nameval[sfe->namelen + j]);
-		if (j == 32)
-			kdb_printf("...");
-		kdb_printf("\"\n");
-		sfe = XFS_ATTR_SF_NEXTENTRY(sfe);
-	}
-}
-
-
-/*
- * Print xfs bmap internal record
- */
-static void
-xfsidbg_xbirec(xfs_bmbt_irec_t *r)
-{
-	kdb_printf(
-	"startoff %Ld startblock %Lx blockcount %Ld state %Ld\n",
-		(__uint64_t)r->br_startoff,
-		(__uint64_t)r->br_startblock,
-		(__uint64_t)r->br_blockcount,
-		(__uint64_t)r->br_state);
-}
-
-
-/*
- * Print a bmap alloc argument structure for XFS.
- */
-static void
-xfsidbg_xbmalla(xfs_bmalloca_t *a)
-{
-	kdb_printf("tp 0x%p ip 0x%p eof %d prevp 0x%p\n",
-		a->tp, a->ip, a->eof, a->prevp);
-	kdb_printf("gotp 0x%p firstblock %s alen %d total %d\n",
-		a->gotp, xfs_fmtfsblock(a->firstblock, a->ip->i_mount),
-		a->alen, a->total);
-	kdb_printf("off %s wasdel %d userdata %d minlen %d\n",
-		xfs_fmtfsblock(a->off, a->ip->i_mount), a->wasdel,
-		a->userdata, a->minlen);
-	kdb_printf("minleft %d low %d rval %s aeof %d\n",
-		a->minleft, a->low, xfs_fmtfsblock(a->rval, a->ip->i_mount),
-		a->aeof);
-}
-
-
-/*
- * Print xfs bmap record
- */
-static void
-xfsidbg_xbrec(xfs_bmbt_rec_64_t *r)
-{
-	xfs_bmbt_irec_t	irec;
-
-	xfs_bmbt_get_all((xfs_bmbt_rec_t *)r, &irec);
-	kdb_printf("startoff %Ld startblock %Lx blockcount %Ld flag %d\n",
-		irec.br_startoff, (__uint64_t)irec.br_startblock,
-		irec.br_blockcount, irec.br_state);
-}
-
-/*
- * Print an xfs in-inode bmap btree root (data fork).
- */
-static void
-xfsidbg_xbroot(xfs_inode_t *ip)
-{
-	xfs_broot(ip, &ip->i_df);
-}
-
-/*
- * Print an xfs in-inode bmap btree root (attribute fork).
- */
-static void
-xfsidbg_xbroota(xfs_inode_t *ip)
-{
-	if (ip->i_afp)
-		xfs_broot(ip, ip->i_afp);
-}
-
-/*
- * Print xfs btree cursor.
- */
-static void
-xfsidbg_xbtcur(xfs_btree_cur_t *c)
-{
-	int l;
-
-	kdb_printf("tp 0x%p mp 0x%p\n",
-		c->bc_tp,
-		c->bc_mp);
-	if (c->bc_btnum == XFS_BTNUM_BMAP) {
-		kdb_printf("rec.b ");
-		xfsidbg_xbirec(&c->bc_rec.b);
-	} else if (c->bc_btnum == XFS_BTNUM_INO) {
-		kdb_printf("rec.i startino 0x%x freecount 0x%x free %Lx\n",
-			c->bc_rec.i.ir_startino, c->bc_rec.i.ir_freecount,
-			c->bc_rec.i.ir_free);
-	} else {
-		kdb_printf("rec.a startblock 0x%x blockcount 0x%x\n",
-			c->bc_rec.a.ar_startblock,
-			c->bc_rec.a.ar_blockcount);
-	}
-	kdb_printf("bufs");
-	for (l = 0; l < c->bc_nlevels; l++)
-		kdb_printf(" 0x%p", c->bc_bufs[l]);
-	kdb_printf("\n");
-	kdb_printf("ptrs");
-	for (l = 0; l < c->bc_nlevels; l++)
-		kdb_printf(" 0x%x", c->bc_ptrs[l]);
-	kdb_printf("  ra");
-	for (l = 0; l < c->bc_nlevels; l++)
-		kdb_printf(" %d", c->bc_ra[l]);
-	kdb_printf("\n");
-	kdb_printf("nlevels %d btnum %s blocklog %d\n",
-		c->bc_nlevels,
-		c->bc_btnum == XFS_BTNUM_BNO ? "bno" :
-		(c->bc_btnum == XFS_BTNUM_CNT ? "cnt" :
-		 (c->bc_btnum == XFS_BTNUM_BMAP ? "bmap" : "ino")),
-		c->bc_blocklog);
-	if (c->bc_btnum == XFS_BTNUM_BMAP) {
-		kdb_printf("private forksize 0x%x whichfork %d ip 0x%p flags %d\n",
-			c->bc_private.b.forksize,
-			c->bc_private.b.whichfork,
-			c->bc_private.b.ip,
-			c->bc_private.b.flags);
-		kdb_printf("private firstblock %s flist 0x%p allocated 0x%x\n",
-			xfs_fmtfsblock(c->bc_private.b.firstblock, c->bc_mp),
-			c->bc_private.b.flist,
-			c->bc_private.b.allocated);
-	} else if (c->bc_btnum == XFS_BTNUM_INO) {
-		kdb_printf("private agbp 0x%p agno 0x%x\n",
-			c->bc_private.i.agbp,
-			c->bc_private.i.agno);
-	} else {
-		kdb_printf("private agbp 0x%p agno 0x%x\n",
-			c->bc_private.a.agbp,
-			c->bc_private.a.agno);
-	}
-}
-
-/*
- * Figure out what kind of xfs block the buffer contains,
- * and invoke a print routine.
- */
-static void
-xfsidbg_xbuf(xfs_buf_t *bp)
-{
-	xfsidbg_xbuf_real(bp, 0);
-}
-
-/*
- * Figure out what kind of xfs block the buffer contains,
- * and invoke a print routine (if asked to).
- */
-static void
-xfsidbg_xbuf_real(xfs_buf_t *bp, int summary)
-{
-	void *d;
-	xfs_agf_t *agf;
-	xfs_agi_t *agi;
-	xfs_sb_t *sb;
-	xfs_alloc_block_t *bta;
-	xfs_bmbt_block_t *btb;
-	xfs_inobt_block_t *bti;
-	xfs_attr_leafblock_t *aleaf;
-	xfs_dir_leafblock_t *dleaf;
-	xfs_da_intnode_t *node;
-	xfs_dinode_t *di;
-	xfs_disk_dquot_t *dqb;
-	xfs_dir2_block_t *d2block;
-	xfs_dir2_data_t *d2data;
-	xfs_dir2_leaf_t *d2leaf;
-	xfs_dir2_free_t *d2free;
-
-	d = XFS_BUF_PTR(bp);
-	if (INT_GET((agf = d)->agf_magicnum, ARCH_CONVERT) == XFS_AGF_MAGIC) {
-		if (summary) {
-			kdb_printf("freespace hdr for AG %d (at 0x%p)\n",
-				INT_GET(agf->agf_seqno, ARCH_CONVERT), agf);
-		} else {
-			kdb_printf("buf 0x%p agf 0x%p\n", bp, agf);
-			xfsidbg_xagf(agf);
-		}
-	} else if (INT_GET((agi = d)->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC) {
-		if (summary) {
-			kdb_printf("Inode hdr for AG %d (at 0x%p)\n",
-			       INT_GET(agi->agi_seqno, ARCH_CONVERT), agi);
-		} else {
-			kdb_printf("buf 0x%p agi 0x%p\n", bp, agi);
-			xfsidbg_xagi(agi);
-		}
-	} else if (INT_GET((bta = d)->bb_magic, ARCH_CONVERT) == XFS_ABTB_MAGIC) {
-		if (summary) {
-			kdb_printf("Alloc BNO Btree blk, level %d (at 0x%p)\n",
-				       INT_GET(bta->bb_level, ARCH_CONVERT), bta);
-		} else {
-			kdb_printf("buf 0x%p abtbno 0x%p\n", bp, bta);
-			xfs_btalloc(bta, XFS_BUF_COUNT(bp));
-		}
-	} else if (INT_GET((bta = d)->bb_magic, ARCH_CONVERT) == XFS_ABTC_MAGIC) {
-		if (summary) {
-			kdb_printf("Alloc COUNT Btree blk, level %d (at 0x%p)\n",
-				       INT_GET(bta->bb_level, ARCH_CONVERT), bta);
-		} else {
-			kdb_printf("buf 0x%p abtcnt 0x%p\n", bp, bta);
-			xfs_btalloc(bta, XFS_BUF_COUNT(bp));
-		}
-	} else if (INT_GET((btb = d)->bb_magic, ARCH_CONVERT) == XFS_BMAP_MAGIC) {
-		if (summary) {
-			kdb_printf("Bmap Btree blk, level %d (at 0x%p)\n",
-				      INT_GET(btb->bb_level, ARCH_CONVERT), btb);
-		} else {
-			kdb_printf("buf 0x%p bmapbt 0x%p\n", bp, btb);
-			xfs_btbmap(btb, XFS_BUF_COUNT(bp));
-		}
-	} else if (INT_GET((bti = d)->bb_magic, ARCH_CONVERT) == XFS_IBT_MAGIC) {
-		if (summary) {
-			kdb_printf("Inode Btree blk, level %d (at 0x%p)\n",
-				       INT_GET(bti->bb_level, ARCH_CONVERT), bti);
-		} else {
-			kdb_printf("buf 0x%p inobt 0x%p\n", bp, bti);
-			xfs_btino(bti, XFS_BUF_COUNT(bp));
-		}
-	} else if (INT_GET((aleaf = d)->hdr.info.magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC) {
-		if (summary) {
-			kdb_printf("Attr Leaf, 1st hash 0x%x (at 0x%p)\n",
-				      INT_GET(aleaf->entries[0].hashval, ARCH_CONVERT), aleaf);
-		} else {
-			kdb_printf("buf 0x%p attr leaf 0x%p\n", bp, aleaf);
-			xfsidbg_xattrleaf(aleaf);
-		}
-	} else if (INT_GET((dleaf = d)->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) {
-		if (summary) {
-			kdb_printf("Dir Leaf, 1st hash 0x%x (at 0x%p)\n",
-				     dleaf->entries[0].hashval, dleaf);
-		} else {
-			kdb_printf("buf 0x%p dir leaf 0x%p\n", bp, dleaf);
-			xfsidbg_xdirleaf(dleaf);
-		}
-	} else if (INT_GET((node = d)->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) {
-		if (summary) {
-			kdb_printf("Dir/Attr Node, level %d, 1st hash 0x%x (at 0x%p)\n",
-			      node->hdr.level, node->btree[0].hashval, node);
-		} else {
-			kdb_printf("buf 0x%p dir/attr node 0x%p\n", bp, node);
-			xfsidbg_xdanode(node);
-		}
-	} else if (INT_GET((di = d)->di_core.di_magic, ARCH_CONVERT) == XFS_DINODE_MAGIC) {
-		if (summary) {
-			kdb_printf("Disk Inode (at 0x%p)\n", di);
-		} else {
-			kdb_printf("buf 0x%p dinode 0x%p\n", bp, di);
-			xfs_inodebuf(bp);
-		}
-	} else if (INT_GET((sb = d)->sb_magicnum, ARCH_CONVERT) == XFS_SB_MAGIC) {
-		if (summary) {
-			kdb_printf("Superblock (at 0x%p)\n", sb);
-		} else {
-			kdb_printf("buf 0x%p sb 0x%p\n", bp, sb);
-			/* SB in a buffer - we need to convert */
-			xfsidbg_xsb(sb, 1);
-		}
-	} else if ((dqb = d)->d_magic == XFS_DQUOT_MAGIC) {
-#define XFSIDBG_DQTYPESTR(d)     \
-	((INT_GET((d)->d_flags, ARCH_CONVERT) & XFS_DQ_USER) ? "USR" : \
-	((INT_GET((d)->d_flags, ARCH_CONVERT) & XFS_DQ_GROUP) ? "GRP" : "???"))
-		kdb_printf("Quota blk starting ID [%d], type %s at 0x%p\n",
-			INT_GET(dqb->d_id, ARCH_CONVERT), XFSIDBG_DQTYPESTR(dqb), dqb);
-
-	} else if (INT_GET((d2block = d)->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC) {
-		if (summary) {
-			kdb_printf("Dir2 block (at 0x%p)\n", d2block);
-		} else {
-			kdb_printf("buf 0x%p dir2 block 0x%p\n", bp, d2block);
-			xfs_dir2data((void *)d2block, XFS_BUF_COUNT(bp));
-		}
-	} else if (INT_GET((d2data = d)->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC) {
-		if (summary) {
-			kdb_printf("Dir2 data (at 0x%p)\n", d2data);
-		} else {
-			kdb_printf("buf 0x%p dir2 data 0x%p\n", bp, d2data);
-			xfs_dir2data((void *)d2data, XFS_BUF_COUNT(bp));
-		}
-	} else if (INT_GET((d2leaf = d)->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC) {
-		if (summary) {
-			kdb_printf("Dir2 leaf(1) (at 0x%p)\n", d2leaf);
-		} else {
-			kdb_printf("buf 0x%p dir2 leaf 0x%p\n", bp, d2leaf);
-			xfs_dir2leaf(d2leaf, XFS_BUF_COUNT(bp));
-		}
-	} else if (INT_GET(d2leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC) {
-		if (summary) {
-			kdb_printf("Dir2 leaf(n) (at 0x%p)\n", d2leaf);
-		} else {
-			kdb_printf("buf 0x%p dir2 leaf 0x%p\n", bp, d2leaf);
-			xfs_dir2leaf(d2leaf, XFS_BUF_COUNT(bp));
-		}
-	} else if (INT_GET((d2free = d)->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC) {
-		if (summary) {
-			kdb_printf("Dir2 free (at 0x%p)\n", d2free);
-		} else {
-			kdb_printf("buf 0x%p dir2 free 0x%p\n", bp, d2free);
-			xfsidbg_xdir2free(d2free);
-		}
-	} else {
-		kdb_printf("buf 0x%p unknown 0x%p\n", bp, d);
-	}
-}
-
-
-/*
- * Print an xfs_da_args structure.
- */
-static void
-xfsidbg_xdaargs(xfs_da_args_t *n)
-{
-	char *ch;
-	int i;
-
-	kdb_printf(" name \"");
-	for (i = 0; i < n->namelen; i++) {
-		kdb_printf("%c", n->name[i]);
-	}
-	kdb_printf("\"(%d) value ", n->namelen);
-	if (n->value) {
-		kdb_printf("\"");
-		ch = n->value;
-		for (i = 0; (i < n->valuelen) && (i < 32); ch++, i++) {
-			switch(*ch) {
-			case '\n':	kdb_printf("\n");		break;
-			case '\b':	kdb_printf("\b");		break;
-			case '\t':	kdb_printf("\t");		break;
-			default:	kdb_printf("%c", *ch);	break;
-			}
-		}
-		if (i == 32)
-			kdb_printf("...");
-		kdb_printf("\"(%d)\n", n->valuelen);
-	} else {
-		kdb_printf("(NULL)(%d)\n", n->valuelen);
-	}
-	kdb_printf(" hashval 0x%x whichfork %d flags <",
-		  (uint_t)n->hashval, n->whichfork);
-	if (n->flags & ATTR_ROOT)
-		kdb_printf("ROOT ");
-	if (n->flags & ATTR_CREATE)
-		kdb_printf("CREATE ");
-	if (n->flags & ATTR_REPLACE)
-		kdb_printf("REPLACE ");
-	if (n->flags & XFS_ATTR_INCOMPLETE)
-		kdb_printf("INCOMPLETE ");
-	i = ~(ATTR_ROOT | ATTR_CREATE | ATTR_REPLACE | XFS_ATTR_INCOMPLETE);
-	if ((n->flags & i) != 0)
-		kdb_printf("0x%x", n->flags & i);
-	kdb_printf(">\n");
-	kdb_printf(" rename %d justcheck %d addname %d oknoent %d\n",
-		  n->rename, n->justcheck, n->addname, n->oknoent);
-	kdb_printf(" leaf: blkno %d index %d rmtblkno %d rmtblkcnt %d\n",
-		  n->blkno, n->index, n->rmtblkno, n->rmtblkcnt);
-	kdb_printf(" leaf2: blkno %d index %d rmtblkno %d rmtblkcnt %d\n",
-		  n->blkno2, n->index2, n->rmtblkno2, n->rmtblkcnt2);
-	kdb_printf(" inumber %llu dp 0x%p firstblock 0x%p flist 0x%p\n",
-		  (unsigned long long) n->inumber,
-		  n->dp, n->firstblock, n->flist);
-	kdb_printf(" trans 0x%p total %d\n",
-		  n->trans, n->total);
-}
-
-/*
- * Print a da buffer structure.
- */
-static void
-xfsidbg_xdabuf(xfs_dabuf_t *dabuf)
-{
-	int	i;
-
-	kdb_printf("nbuf %d dirty %d bbcount %d data 0x%p bps",
-		dabuf->nbuf, dabuf->dirty, dabuf->bbcount, dabuf->data);
-	for (i = 0; i < dabuf->nbuf; i++)
-		kdb_printf(" %d:0x%p", i, dabuf->bps[i]);
-	kdb_printf("\n");
-#ifdef XFS_DABUF_DEBUG
-	kdb_printf(" ra 0x%x prev 0x%x next 0x%x dev %s blkno 0x%x\n",
-		dabuf->ra, dabuf->prev, dabuf->next,
-		XFS_BUFTARG_NAME(dabuf->dev), dabuf->blkno);
-#endif
-}
-
-/*
- * Print a directory/attribute internal node block.
- */
-static void
-xfsidbg_xdanode(xfs_da_intnode_t *node)
-{
-	xfs_da_node_hdr_t *h;
-	xfs_da_blkinfo_t *i;
-	xfs_da_node_entry_t *e;
-	int j;
-
-	h = &node->hdr;
-	i = &h->info;
-	kdb_printf("hdr info forw 0x%x back 0x%x magic 0x%x\n",
-		INT_GET(i->forw, ARCH_CONVERT), INT_GET(i->back, ARCH_CONVERT), INT_GET(i->magic, ARCH_CONVERT));
-	kdb_printf("hdr count %d level %d\n",
-		INT_GET(h->count, ARCH_CONVERT), INT_GET(h->level, ARCH_CONVERT));
-	for (j = 0, e = node->btree; j < INT_GET(h->count, ARCH_CONVERT); j++, e++) {
-		kdb_printf("btree %d hashval 0x%x before 0x%x\n",
-			j, (uint_t)INT_GET(e->hashval, ARCH_CONVERT), INT_GET(e->before, ARCH_CONVERT));
-	}
-}
-
-/*
- * Print an xfs_da_state_blk structure.
- */
-static void
-xfsidbg_xdastate(xfs_da_state_t *s)
-{
-	xfs_da_state_blk_t *eblk;
-
-	kdb_printf("args 0x%p mp 0x%p blocksize %u node_ents %u inleaf %u\n",
-		s->args, s->mp, s->blocksize, s->node_ents, s->inleaf);
-	if (s->args)
-		xfsidbg_xdaargs(s->args);
-
-	kdb_printf("path:  ");
-	xfs_dastate_path(&s->path);
-
-	kdb_printf("altpath:  ");
-	xfs_dastate_path(&s->altpath);
-
-	eblk = &s->extrablk;
-	kdb_printf("extra: valid %d, after %d\n", s->extravalid, s->extraafter);
-	kdb_printf(" bp 0x%p blkno 0x%x ", eblk->bp, eblk->blkno);
-	kdb_printf("index %d hashval 0x%x\n", eblk->index, (uint_t)eblk->hashval);
-}
-
-/*
- * Print a directory leaf block.
- */
-static void
-xfsidbg_xdirleaf(xfs_dir_leafblock_t *leaf)
-{
-	xfs_dir_leaf_hdr_t *h;
-	xfs_da_blkinfo_t *i;
-	xfs_dir_leaf_map_t *m;
-	xfs_dir_leaf_entry_t *e;
-	xfs_dir_leaf_name_t *n;
-	int j, k;
-	xfs_ino_t ino;
-
-	h = &leaf->hdr;
-	i = &h->info;
-	kdb_printf("hdr info forw 0x%x back 0x%x magic 0x%x\n",
-		INT_GET(i->forw, ARCH_CONVERT), INT_GET(i->back, ARCH_CONVERT), INT_GET(i->magic, ARCH_CONVERT));
-	kdb_printf("hdr count %d namebytes %d firstused %d holes %d\n",
-		INT_GET(h->count, ARCH_CONVERT), INT_GET(h->namebytes, ARCH_CONVERT), INT_GET(h->firstused, ARCH_CONVERT), h->holes);
-	for (j = 0, m = h->freemap; j < XFS_DIR_LEAF_MAPSIZE; j++, m++) {
-		kdb_printf("hdr freemap %d base %d size %d\n",
-			j, INT_GET(m->base, ARCH_CONVERT), INT_GET(m->size, ARCH_CONVERT));
-	}
-	for (j = 0, e = leaf->entries; j < INT_GET(h->count, ARCH_CONVERT); j++, e++) {
-		n = XFS_DIR_LEAF_NAMESTRUCT(leaf, INT_GET(e->nameidx, ARCH_CONVERT));
-		XFS_DIR_SF_GET_DIRINO_ARCH(&n->inumber, &ino, ARCH_CONVERT);
-		kdb_printf("leaf %d hashval 0x%x nameidx %d inumber %llu ",
-			j, (uint_t)INT_GET(e->hashval, ARCH_CONVERT),
-			INT_GET(e->nameidx, ARCH_CONVERT),
-			(unsigned long long)ino);
-		kdb_printf("namelen %d name \"", e->namelen);
-		for (k = 0; k < e->namelen; k++)
-			kdb_printf("%c", n->name[k]);
-		kdb_printf("\"\n");
-	}
-}
-
-/*
- * Print a directory v2 data block, single or multiple.
- */
-static void
-xfs_dir2data(void *addr, int size)
-{
-	xfs_dir2_data_t *db;
-	xfs_dir2_block_t *bb;
-	xfs_dir2_data_hdr_t *h;
-	xfs_dir2_data_free_t *m;
-	xfs_dir2_data_entry_t *e;
-	xfs_dir2_data_unused_t *u;
-	xfs_dir2_leaf_entry_t *l=NULL;
-	int j, k;
-	char *p;
-	char *t;
-	xfs_dir2_block_tail_t *tail=NULL;
-
-	db = (xfs_dir2_data_t *)addr;
-	bb = (xfs_dir2_block_t *)addr;
-	h = &db->hdr;
-	kdb_printf("hdr magic 0x%x (%s)\nhdr bestfree", INT_GET(h->magic, ARCH_CONVERT),
-		INT_GET(h->magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC ? "DATA" :
-			(INT_GET(h->magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC ? "BLOCK" : ""));
-	for (j = 0, m = h->bestfree; j < XFS_DIR2_DATA_FD_COUNT; j++, m++) {
-		kdb_printf(" %d: 0x%x@0x%x", j, INT_GET(m->length, ARCH_CONVERT), INT_GET(m->offset, ARCH_CONVERT));
-	}
-	kdb_printf("\n");
-	if (INT_GET(h->magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC)
-		t = (char *)db + size;
-	else {
-		/* XFS_DIR2_BLOCK_TAIL_P */
-		tail = (xfs_dir2_block_tail_t *)
-		       ((char *)bb + size - sizeof(xfs_dir2_block_tail_t));
-		l = XFS_DIR2_BLOCK_LEAF_P_ARCH(tail, ARCH_CONVERT);
-		t = (char *)l;
-	}
-	for (p = (char *)(h + 1); p < t; ) {
-		u = (xfs_dir2_data_unused_t *)p;
-		if (u->freetag == XFS_DIR2_DATA_FREE_TAG) {
-			kdb_printf("0x%lx unused freetag 0x%x length 0x%x tag 0x%x\n",
-				(unsigned long) (p - (char *)addr),
-				INT_GET(u->freetag, ARCH_CONVERT),
-				INT_GET(u->length, ARCH_CONVERT),
-				INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P_ARCH(u, ARCH_CONVERT), ARCH_CONVERT));
-			p += INT_GET(u->length, ARCH_CONVERT);
-			continue;
-		}
-		e = (xfs_dir2_data_entry_t *)p;
-		kdb_printf("0x%lx entry inumber %llu namelen %d name \"",
-			(unsigned long) (p - (char *)addr),
-			(unsigned long long) INT_GET(e->inumber, ARCH_CONVERT),
-			e->namelen);
-		for (k = 0; k < e->namelen; k++)
-			kdb_printf("%c", e->name[k]);
-		kdb_printf("\" tag 0x%x\n", INT_GET(*XFS_DIR2_DATA_ENTRY_TAG_P(e), ARCH_CONVERT));
-		p += XFS_DIR2_DATA_ENTSIZE(e->namelen);
-	}
-	if (INT_GET(h->magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC)
-		return;
-	for (j = 0; j < INT_GET(tail->count, ARCH_CONVERT); j++, l++) {
-		kdb_printf("0x%lx leaf %d hashval 0x%x address 0x%x (byte 0x%x)\n",
-			(unsigned long) ((char *)l - (char *)addr), j,
-			(uint_t)INT_GET(l->hashval, ARCH_CONVERT),
-			INT_GET(l->address, ARCH_CONVERT),
-			/* XFS_DIR2_DATAPTR_TO_BYTE */
-			INT_GET(l->address, ARCH_CONVERT) << XFS_DIR2_DATA_ALIGN_LOG);
-	}
-	kdb_printf("0x%lx tail count %d\n",
-		(unsigned long) ((char *)tail - (char *)addr),
-		INT_GET(tail->count, ARCH_CONVERT));
-}
-
-static void
-xfs_dir2leaf(xfs_dir2_leaf_t *leaf, int size)
-{
-	xfs_dir2_leaf_hdr_t *h;
-	xfs_da_blkinfo_t *i;
-	xfs_dir2_leaf_entry_t *e;
-	xfs_dir2_data_off_t *b;
-	xfs_dir2_leaf_tail_t *t;
-	int j;
-
-	h = &leaf->hdr;
-	i = &h->info;
-	e = leaf->ents;
-	kdb_printf("hdr info forw 0x%x back 0x%x magic 0x%x\n",
-		INT_GET(i->forw, ARCH_CONVERT), INT_GET(i->back, ARCH_CONVERT), INT_GET(i->magic, ARCH_CONVERT));
-	kdb_printf("hdr count %d stale %d\n", INT_GET(h->count, ARCH_CONVERT), INT_GET(h->stale, ARCH_CONVERT));
-	for (j = 0; j < INT_GET(h->count, ARCH_CONVERT); j++, e++) {
-		kdb_printf("0x%lx ent %d hashval 0x%x address 0x%x (byte 0x%x)\n",
-			(unsigned long) ((char *)e - (char *)leaf), j,
-			(uint_t)INT_GET(e->hashval, ARCH_CONVERT),
-			INT_GET(e->address, ARCH_CONVERT),
-			/* XFS_DIR2_DATAPTR_TO_BYTE */
-			INT_GET(e->address, ARCH_CONVERT) << XFS_DIR2_DATA_ALIGN_LOG);
-	}
-	if (INT_GET(i->magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC)
-		return;
-	/* XFS_DIR2_LEAF_TAIL_P */
-	t = (xfs_dir2_leaf_tail_t *)((char *)leaf + size - sizeof(*t));
-	b = XFS_DIR2_LEAF_BESTS_P_ARCH(t, ARCH_CONVERT);
-	for (j = 0; j < INT_GET(t->bestcount, ARCH_CONVERT); j++, b++) {
-		kdb_printf("0x%lx best %d 0x%x\n",
-			(unsigned long) ((char *)b - (char *)leaf), j,
-			INT_GET(*b, ARCH_CONVERT));
-	}
-	kdb_printf("tail bestcount %d\n", INT_GET(t->bestcount, ARCH_CONVERT));
-}
-
-/*
- * Print a shortform directory.
- */
-static void
-xfsidbg_xdirsf(xfs_dir_shortform_t *s)
-{
-	xfs_dir_sf_hdr_t *sfh;
-	xfs_dir_sf_entry_t *sfe;
-	xfs_ino_t ino;
-	int i, j;
-
-	sfh = &s->hdr;
-	XFS_DIR_SF_GET_DIRINO_ARCH(&sfh->parent, &ino, ARCH_CONVERT);
-	kdb_printf("hdr parent %llu", (unsigned long long)ino);
-	kdb_printf(" count %d\n", sfh->count);
-	for (i = 0, sfe = s->list; i < sfh->count; i++) {
-		XFS_DIR_SF_GET_DIRINO_ARCH(&sfe->inumber, &ino, ARCH_CONVERT);
-		kdb_printf("entry %d inumber %llu", i, (unsigned long long)ino);
-		kdb_printf(" namelen %d name \"", sfe->namelen);
-		for (j = 0; j < sfe->namelen; j++)
-			kdb_printf("%c", sfe->name[j]);
-		kdb_printf("\"\n");
-		sfe = XFS_DIR_SF_NEXTENTRY(sfe);
-	}
-}
-
-/*
- * Print a shortform v2 directory.
- */
-static void
-xfsidbg_xdir2sf(xfs_dir2_sf_t *s)
-{
-	xfs_dir2_sf_hdr_t *sfh;
-	xfs_dir2_sf_entry_t *sfe;
-	xfs_ino_t ino;
-	int i, j;
-
-	sfh = &s->hdr;
-	ino = XFS_DIR2_SF_GET_INUMBER_ARCH(s, &sfh->parent, ARCH_CONVERT);
-	kdb_printf("hdr count %d i8count %d parent %llu\n",
-		sfh->count, sfh->i8count, (unsigned long long) ino);
-	for (i = 0, sfe = XFS_DIR2_SF_FIRSTENTRY(s); i < sfh->count; i++) {
-		ino = XFS_DIR2_SF_GET_INUMBER_ARCH(s, XFS_DIR2_SF_INUMBERP(sfe), ARCH_CONVERT);
-		kdb_printf("entry %d inumber %llu offset 0x%x namelen %d name \"",
-			i, (unsigned long long) ino,
-			XFS_DIR2_SF_GET_OFFSET_ARCH(sfe, ARCH_CONVERT),
-			sfe->namelen);
-		for (j = 0; j < sfe->namelen; j++)
-			kdb_printf("%c", sfe->name[j]);
-		kdb_printf("\"\n");
-		sfe = XFS_DIR2_SF_NEXTENTRY(s, sfe);
-	}
-}
-
-/*
- * Print a node-form v2 directory freemap block.
- */
-static void
-xfsidbg_xdir2free(xfs_dir2_free_t *f)
-{
-	int	i;
-
-	kdb_printf("hdr magic 0x%x firstdb %d nvalid %d nused %d\n",
-		INT_GET(f->hdr.magic, ARCH_CONVERT), INT_GET(f->hdr.firstdb, ARCH_CONVERT), INT_GET(f->hdr.nvalid, ARCH_CONVERT), INT_GET(f->hdr.nused, ARCH_CONVERT));
-	for (i = 0; i < INT_GET(f->hdr.nvalid, ARCH_CONVERT); i++) {
-		kdb_printf("entry %d db %d count %d\n",
-			i, i + INT_GET(f->hdr.firstdb, ARCH_CONVERT), INT_GET(f->bests[i], ARCH_CONVERT));
-	}
-}
-
-
-/*
- * Print xfs extent list.
- */
-static void
-xfsidbg_xexlist(xfs_inode_t *ip)
-{
-	xfs_xexlist_fork(ip, XFS_DATA_FORK);
-	if (XFS_IFORK_Q(ip))
-		xfs_xexlist_fork(ip, XFS_ATTR_FORK);
-}
-
-/*
- * Print an xfs free-extent list.
- */
-static void
-xfsidbg_xflist(xfs_bmap_free_t *flist)
-{
-	xfs_bmap_free_item_t	*item;
-
-	kdb_printf("flist@0x%p: first 0x%p count %d low %d\n", flist,
-		flist->xbf_first, flist->xbf_count, flist->xbf_low);
-	for (item = flist->xbf_first; item; item = item->xbfi_next) {
-		kdb_printf("item@0x%p: startblock %Lx blockcount %d", item,
-			(xfs_dfsbno_t)item->xbfi_startblock,
-			item->xbfi_blockcount);
-	}
-}
-
-/*
- * Print out the help messages for these functions.
- */
-static void
-xfsidbg_xhelp(void)
-{
-	struct xif	*p;
-
-	for (p = xfsidbg_funcs; p->name; p++)
-		kdb_printf("%-16s %s %s\n", p->name, p->args, p->help);
-}
-
-/*
- * Print out an XFS in-core log structure.
- */
-static void
-xfsidbg_xiclog(xlog_in_core_t *iclog)
-{
-	int i;
-	static char *ic_flags[] = {
-		"ACTIVE",	/* 0x0001 */
-		"WANT_SYNC",	/* 0x0002 */
-		"SYNCING",	/* 0X0004 */
-		"DONE_SYNC",	/* 0X0008 */
-		"DO_CALLBACK",	/* 0X0010 */
-		"CALLBACK",	/* 0X0020 */
-		"DIRTY",	/* 0X0040 */
-		"IOERROR",	/* 0X0080 */
-		"NOTUSED",	/* 0X8000 */
-		0
-	};
-
-	kdb_printf("xlog_in_core/header at 0x%p/0x%p\n",
-		iclog, iclog->hic_data);
-	kdb_printf("magicno: %x  cycle: %d  version: %d  lsn: 0x%Lx\n",
-		INT_GET(iclog->ic_header.h_magicno, ARCH_CONVERT), INT_GET(iclog->ic_header.h_cycle, ARCH_CONVERT),
-		INT_GET(iclog->ic_header.h_version, ARCH_CONVERT), INT_GET(iclog->ic_header.h_lsn, ARCH_CONVERT));
-	kdb_printf("tail_lsn: 0x%Lx  len: %d  prev_block: %d  num_ops: %d\n",
-		INT_GET(iclog->ic_header.h_tail_lsn, ARCH_CONVERT), INT_GET(iclog->ic_header.h_len, ARCH_CONVERT),
-		INT_GET(iclog->ic_header.h_prev_block, ARCH_CONVERT), INT_GET(iclog->ic_header.h_num_logops, ARCH_CONVERT));
-	kdb_printf("cycle_data: ");
-	for (i=0; i<(iclog->ic_size>>BBSHIFT); i++) {
-		kdb_printf("%x  ", INT_GET(iclog->ic_header.h_cycle_data[i], ARCH_CONVERT));
-	}
-	kdb_printf("\n");
-	kdb_printf("size: %d\n", INT_GET(iclog->ic_header.h_size, ARCH_CONVERT));
-	kdb_printf("\n");
-	kdb_printf("--------------------------------------------------\n");
-	kdb_printf("data: 0x%p  &forcesema: 0x%p  next: 0x%p bp: 0x%p\n",
-		iclog->ic_datap, &iclog->ic_forcesema, iclog->ic_next,
-		iclog->ic_bp);
-	kdb_printf("log: 0x%p  callb: 0x%p  callb_tail: 0x%p  roundoff: %d\n",
-		iclog->ic_log, iclog->ic_callback, iclog->ic_callback_tail,
-		iclog->ic_roundoff);
-	kdb_printf("size: %d (OFFSET: %d) refcnt: %d  bwritecnt: %d",
-		iclog->ic_size, iclog->ic_offset,
-		iclog->ic_refcnt, iclog->ic_bwritecnt);
-	if (iclog->ic_state & XLOG_STATE_ALL)
-		printflags(iclog->ic_state, ic_flags, "state:");
-	else
-		kdb_printf("state: INVALID 0x%x", iclog->ic_state);
-	kdb_printf("\n");
-}	/* xfsidbg_xiclog */
-
-
-/*
- * Print all incore logs.
- */
-static void
-xfsidbg_xiclogall(xlog_in_core_t *iclog)
-{
-    xlog_in_core_t *first_iclog = iclog;
-
-    do {
-	xfsidbg_xiclog(iclog);
-	kdb_printf("=================================================\n");
-	iclog = iclog->ic_next;
-    } while (iclog != first_iclog);
-}	/* xfsidbg_xiclogall */
-
-/*
- * Print out the callback structures attached to an iclog.
- */
-static void
-xfsidbg_xiclogcb(xlog_in_core_t *iclog)
-{
-	xfs_log_callback_t	*cb;
-	kdb_symtab_t		 symtab;
-
-	for (cb = iclog->ic_callback; cb != NULL; cb = cb->cb_next) {
-
-		if (kdbnearsym((unsigned long)cb->cb_func, &symtab)) {
-			unsigned long offval;
-
-			offval = (unsigned long)cb->cb_func - symtab.sym_start;
-
-			if (offval)
-				kdb_printf("func = %s+0x%lx",
-							symtab.sym_name,
-							offval);
-			else
-				kdb_printf("func = %s", symtab.sym_name);
-		} else
-			kdb_printf("func = ?? 0x%p", (void *)cb->cb_func);
-
-		kdb_printf(" arg 0x%p next 0x%p\n", cb->cb_arg, cb->cb_next);
-	}
-}
-
-
-/*
- * Print all of the inodes attached to the given mount structure.
- */
-static void
-xfsidbg_xinodes(xfs_mount_t *mp)
-{
-	xfs_inode_t	*ip;
-
-	kdb_printf("xfs_mount at 0x%p\n", mp);
-	ip = mp->m_inodes;
-	if (ip != NULL) {
-		do {
-			if (ip->i_mount == NULL) {
-				ip = ip->i_mnext;
-				continue;
-			}
-			kdb_printf("\n");
-			xfsidbg_xnode(ip);
-			ip = ip->i_mnext;
-		} while (ip != mp->m_inodes);
-	}
-	kdb_printf("\nEnd of Inodes\n");
-}
-
-static void
-xfsidbg_delayed_blocks(xfs_mount_t *mp)
-{
-	xfs_inode_t	*ip;
-	unsigned int	total = 0;
-	unsigned int	icount = 0;
-
-	ip = mp->m_inodes;
-	if (ip != NULL) {
-		do {
-			if (ip->i_mount == NULL) {
-				ip = ip->i_mnext;
-				continue;
-			}
-			if (ip->i_delayed_blks) {
-				total += ip->i_delayed_blks;
-				icount++;
-			}
-			ip = ip->i_mnext;
-		} while (ip != mp->m_inodes);
-	}
-	kdb_printf("delayed blocks total: %d in %d inodes\n", total, icount);
-}
-
-static void
-xfsidbg_xinodes_quiesce(xfs_mount_t *mp)
-{
-	xfs_inode_t	*ip;
-
-	kdb_printf("xfs_mount at 0x%p\n", mp);
-	ip = mp->m_inodes;
-	if (ip != NULL) {
-		do {
-			if (ip->i_mount == NULL) {
-				ip = ip->i_mnext;
-				continue;
-			}
-			if (!(ip->i_flags & XFS_IQUIESCE)) {
-				kdb_printf("ip 0x%p not quiesced\n", ip);
-			}
-			ip = ip->i_mnext;
-		} while (ip != mp->m_inodes);
-	}
-	kdb_printf("\nEnd of Inodes\n");
-}
-
-static char *
-xfsidbg_get_cstate(int state)
-{
-	switch(state) {
-	case  XLOG_STATE_COVER_IDLE:
-		return("idle");
-	case  XLOG_STATE_COVER_NEED:
-		return("need");
-	case  XLOG_STATE_COVER_DONE:
-		return("done");
-	case  XLOG_STATE_COVER_NEED2:
-		return("need2");
-	case  XLOG_STATE_COVER_DONE2:
-		return("done2");
-	default:
-		return("unknown");
-	}
-}
-
-/*
- * Print out an XFS log structure.
- */
-static void
-xfsidbg_xlog(xlog_t *log)
-{
-	int rbytes;
-	int wbytes;
-	static char *t_flags[] = {
-		"CHKSUM_MISMATCH",	/* 0x01 */
-		"ACTIVE_RECOVERY",	/* 0x02 */
-		"RECOVERY_NEEDED",	/* 0x04 */
-		"IO_ERROR",		/* 0x08 */
-		0
-	};
-
-	kdb_printf("xlog at 0x%p\n", log);
-	kdb_printf("&flushsm: 0x%p  flushcnt: %d tic_cnt: %d	 tic_tcnt: %d  \n",
-		&log->l_flushsema, log->l_flushcnt,
-		log->l_ticket_cnt, log->l_ticket_tcnt);
-	kdb_printf("freelist: 0x%p  tail: 0x%p	ICLOG: 0x%p  \n",
-		log->l_freelist, log->l_tail, log->l_iclog);
-	kdb_printf("&icloglock: 0x%p  tail_lsn: %s  last_sync_lsn: %s \n",
-		&log->l_icloglock, xfs_fmtlsn(&log->l_tail_lsn),
-		xfs_fmtlsn(&log->l_last_sync_lsn));
-	kdb_printf("mp: 0x%p  xbuf: 0x%p  roundoff: %d  l_covered_state: %s \n",
-		log->l_mp, log->l_xbuf, log->l_roundoff,
-			xfsidbg_get_cstate(log->l_covered_state));
-	kdb_printf("flags: ");
-	printflags(log->l_flags, t_flags,"log");
-	kdb_printf("  dev: %s logBBstart: %lld logsize: %d logBBsize: %d\n",
-		XFS_BUFTARG_NAME(log->l_targ), (long long) log->l_logBBstart,
-		log->l_logsize,log->l_logBBsize);
-	kdb_printf("curr_cycle: %d  prev_cycle: %d  curr_block: %d  prev_block: %d\n",
-	     log->l_curr_cycle, log->l_prev_cycle, log->l_curr_block,
-	     log->l_prev_block);
-	kdb_printf("iclog_bak: 0x%p  iclog_size: 0x%x (%d)  num iclogs: %d\n",
-		log->l_iclog_bak, log->l_iclog_size, log->l_iclog_size,
-		log->l_iclog_bufs);
-	kdb_printf("l_stripemask %d l_iclog_hsize %d l_iclog_heads %d\n",
-		log->l_stripemask, log->l_iclog_hsize, log->l_iclog_heads);
-	kdb_printf("l_sectbb_log %u l_sectbb_mask %u\n",
-		log->l_sectbb_log, log->l_sectbb_mask);
-	kdb_printf("&grant_lock: 0x%p  resHeadQ: 0x%p  wrHeadQ: 0x%p\n",
-		&log->l_grant_lock, log->l_reserve_headq, log->l_write_headq);
-	kdb_printf("GResCycle: %d  GResBytes: %d  GWrCycle: %d  GWrBytes: %d\n",
-		log->l_grant_reserve_cycle, log->l_grant_reserve_bytes,
-		log->l_grant_write_cycle, log->l_grant_write_bytes);
-	rbytes = log->l_grant_reserve_bytes + log->l_roundoff;
-	wbytes = log->l_grant_write_bytes + log->l_roundoff;
-       kdb_printf("GResBlocks: %d  GResRemain: %d  GWrBlocks: %d  GWrRemain: %d\n",
-	       rbytes / BBSIZE, rbytes % BBSIZE,
-	       wbytes / BBSIZE, wbytes % BBSIZE);
-}	/* xfsidbg_xlog */
-
-
-/*
- * Print out an XFS recovery transaction
- */
-static void
-xfsidbg_xlog_ritem(xlog_recover_item_t *item)
-{
-	int i = XLOG_MAX_REGIONS_IN_ITEM;
-
-	kdb_printf("(xlog_recover_item 0x%p) ", item);
-	kdb_printf("next: 0x%p prev: 0x%p type: %d cnt: %d ttl: %d\n",
-		item->ri_next, item->ri_prev, ITEM_TYPE(item), item->ri_cnt,
-		item->ri_total);
-	for ( ; i > 0; i--) {
-		if (!item->ri_buf[XLOG_MAX_REGIONS_IN_ITEM-i].i_addr)
-			break;
-		kdb_printf("a: 0x%p l: %d ",
-			item->ri_buf[XLOG_MAX_REGIONS_IN_ITEM-i].i_addr,
-			item->ri_buf[XLOG_MAX_REGIONS_IN_ITEM-i].i_len);
-	}
-	kdb_printf("\n");
-}	/* xfsidbg_xlog_ritem */
-
-/*
- * Print out an XFS recovery transaction
- */
-static void
-xfsidbg_xlog_rtrans(xlog_recover_t *trans)
-{
-	xlog_recover_item_t *rip, *first_rip;
-
-	kdb_printf("(xlog_recover 0x%p) ", trans);
-	kdb_printf("tid: %x type: %d items: %d ttid: 0x%x  ",
-		trans->r_log_tid, trans->r_theader.th_type,
-		trans->r_theader.th_num_items, trans->r_theader.th_tid);
-	kdb_printf("itemq: 0x%p\n", trans->r_itemq);
-	if (trans->r_itemq) {
-		rip = first_rip = trans->r_itemq;
-		do {
-			kdb_printf("(recovery item: 0x%p) ", rip);
-			kdb_printf("type: %d cnt: %d total: %d\n",
-				ITEM_TYPE(rip), rip->ri_cnt, rip->ri_total);
-			rip = rip->ri_next;
-		} while (rip != first_rip);
-	}
-}	/* xfsidbg_xlog_rtrans */
-
-static void
-xfsidbg_xlog_buf_logitem(xlog_recover_item_t *item)
-{
-	xfs_buf_log_format_t	*buf_f;
-	int			i, j;
-	int			bit;
-	int			nbits;
-	unsigned int		*data_map;
-	unsigned int		map_size;
-	int			size;
-
-	buf_f = (xfs_buf_log_format_t *)item->ri_buf[0].i_addr;
-	if (buf_f->blf_flags & XFS_BLI_INODE_BUF) {
-		kdb_printf("\tINODE BUF <blkno=0x%Lx, len=0x%x>\n",
-			buf_f->blf_blkno, buf_f->blf_len);
-	} else if (buf_f->blf_flags & (XFS_BLI_UDQUOT_BUF | XFS_BLI_GDQUOT_BUF)) {
-		kdb_printf("\tDQUOT BUF <blkno=0x%Lx, len=0x%x>\n",
-			buf_f->blf_blkno, buf_f->blf_len);
-	} else {
-		data_map = buf_f->blf_data_map;
-		map_size = buf_f->blf_map_size;
-		kdb_printf("\tREG BUF <blkno=0x%Lx, len=0x%x map 0x%p size %d>\n",
-			buf_f->blf_blkno, buf_f->blf_len, data_map, map_size);
-		bit = 0;
-		i = 0;  /* 0 is the buf format structure */
-		while (1) {
-			bit = xfs_next_bit(data_map, map_size, bit);
-			if (bit == -1)
-				break;
-			nbits = xfs_contig_bits(data_map, map_size, bit);
-			size = ((uint)bit << XFS_BLI_SHIFT)+(nbits<<XFS_BLI_SHIFT);
-			kdb_printf("\t\tlogbuf.i_addr 0x%p, size 0x%x\n",
-				item->ri_buf[i].i_addr, size);
-			kdb_printf("\t\t\t\"");
-			for (j=0; j<8 && j<size; j++) {
-				kdb_printf("%02x", ((char *)item->ri_buf[i].i_addr)[j]);
-			}
-			kdb_printf("...\"\n");
-			i++;
-			bit += nbits;
-		}
-
-	}
-}
-
-/*
- * Print out an ENTIRE XFS recovery transaction
- */
-static void
-xfsidbg_xlog_rtrans_entire(xlog_recover_t *trans)
-{
-	xlog_recover_item_t *item, *first_rip;
-
-	kdb_printf("(Recovering Xact 0x%p) ", trans);
-	kdb_printf("tid: %x type: %d nitems: %d ttid: 0x%x  ",
-		trans->r_log_tid, trans->r_theader.th_type,
-		trans->r_theader.th_num_items, trans->r_theader.th_tid);
-	kdb_printf("itemq: 0x%p\n", trans->r_itemq);
-	if (trans->r_itemq) {
-		item = first_rip = trans->r_itemq;
-		do {
-			/*
-			   kdb_printf("(recovery item: 0x%x) ", item);
-			   kdb_printf("type: %d cnt: %d total: %d\n",
-				   item->ri_type, item->ri_cnt, item->ri_total);
-				   */
-			if ((ITEM_TYPE(item) == XFS_LI_BUF) ||
-			    (ITEM_TYPE(item) == XFS_LI_6_1_BUF) ||
-			    (ITEM_TYPE(item) == XFS_LI_5_3_BUF)) {
-				kdb_printf("BUF:");
-				xfsidbg_xlog_buf_logitem(item);
-			} else if ((ITEM_TYPE(item) == XFS_LI_INODE) ||
-				   (ITEM_TYPE(item) == XFS_LI_6_1_INODE) ||
-				   (ITEM_TYPE(item) == XFS_LI_5_3_INODE)) {
-				kdb_printf("INODE:\n");
-			} else if (ITEM_TYPE(item) == XFS_LI_EFI) {
-				kdb_printf("EFI:\n");
-			} else if (ITEM_TYPE(item) == XFS_LI_EFD) {
-				kdb_printf("EFD:\n");
-			} else if (ITEM_TYPE(item) == XFS_LI_DQUOT) {
-				kdb_printf("DQUOT:\n");
-			} else if ((ITEM_TYPE(item) == XFS_LI_QUOTAOFF)) {
-				kdb_printf("QUOTAOFF:\n");
-			} else {
-				kdb_printf("UNKNOWN LOGITEM 0x%x\n", ITEM_TYPE(item));
-			}
-			item = item->ri_next;
-		} while (item != first_rip);
-	}
-}	/* xfsidbg_xlog_rtrans */
-
-/*
- * Print out an XFS ticket structure.
- */
-static void
-xfsidbg_xlog_tic(xlog_ticket_t *tic)
-{
-	static char *t_flags[] = {
-		"INIT",		/* 0x1 */
-		"PERM_RES",	/* 0x2 */
-		"IN_Q",		/* 0x4 */
-		0
-	};
-
-	kdb_printf("xlog_ticket at 0x%p\n", tic);
-	kdb_printf("next: 0x%p  prev: 0x%p  tid: 0x%x  \n",
-		tic->t_next, tic->t_prev, tic->t_tid);
-	kdb_printf("curr_res: %d  unit_res: %d  ocnt: %d  cnt: %d\n",
-		tic->t_curr_res, tic->t_unit_res, (int)tic->t_ocnt,
-		(int)tic->t_cnt);
-	kdb_printf("clientid: %c  \n", tic->t_clientid);
-	printflags(tic->t_flags, t_flags,"ticket");
-	kdb_printf("\n");
-}	/* xfsidbg_xlog_tic */
-
-/*
- * Print out a single log item.
- */
-static void
-xfsidbg_xlogitem(xfs_log_item_t *lip)
-{
-	xfs_log_item_t	*bio_lip;
-	static char *lid_type[] = {
-		"???",		/* 0 */
-		"5-3-buf",	/* 1 */
-		"5-3-inode",	/* 2 */
-		"efi",		/* 3 */
-		"efd",		/* 4 */
-		"iunlink",	/* 5 */
-		"6-1-inode",	/* 6 */
-		"6-1-buf",	/* 7 */
-		"inode",	/* 8 */
-		"buf",		/* 9 */
-		"dquot",	/* 10 */
-		0
-		};
-	static char *li_flags[] = {
-		"in ail",	/* 0x1 */
-		0
-		};
-
-	kdb_printf("type %s mountp 0x%p flags ",
-		lid_type[lip->li_type - XFS_LI_5_3_BUF + 1],
-		lip->li_mountp);
-	printflags((uint)(lip->li_flags), li_flags,"log");
-	kdb_printf("\n");
-	kdb_printf("ail forw 0x%p ail back 0x%p lsn %s desc %p ops 0x%p\n",
-		lip->li_ail.ail_forw, lip->li_ail.ail_back,
-		xfs_fmtlsn(&(lip->li_lsn)), lip->li_desc, lip->li_ops);
-	kdb_printf("iodonefunc &0x%p\n", lip->li_cb);
-	if (lip->li_type == XFS_LI_BUF) {
-		bio_lip = lip->li_bio_list;
-		if (bio_lip != NULL) {
-			kdb_printf("iodone list:\n");
-		}
-		while (bio_lip != NULL) {
-			kdb_printf("item 0x%p func 0x%p\n",
-				bio_lip, bio_lip->li_cb);
-			bio_lip = bio_lip->li_bio_list;
-		}
-	}
-	switch (lip->li_type) {
-	case XFS_LI_BUF:
-		xfs_buf_item_print((xfs_buf_log_item_t *)lip, 0);
-		break;
-	case XFS_LI_INODE:
-		xfs_inode_item_print((xfs_inode_log_item_t *)lip, 0);
-		break;
-	case XFS_LI_EFI:
-		xfs_efi_item_print((xfs_efi_log_item_t *)lip, 0);
-		break;
-	case XFS_LI_EFD:
-		xfs_efd_item_print((xfs_efd_log_item_t *)lip, 0);
-		break;
-	case XFS_LI_DQUOT:
-		xfs_dquot_item_print((xfs_dq_logitem_t *)lip, 0);
-		break;
-	case XFS_LI_QUOTAOFF:
-		xfs_qoff_item_print((xfs_qoff_logitem_t *)lip, 0);
-		break;
-
-	default:
-		kdb_printf("Unknown item type %d\n", lip->li_type);
-		break;
-	}
-}
-
-/*
- * Print out a summary of the AIL hanging off of a mount struct.
- */
-static void
-xfsidbg_xaildump(xfs_mount_t *mp)
-{
-	xfs_log_item_t *lip;
-	static char *lid_type[] = {
-		"???",		/* 0 */
-		"5-3-buf",	/* 1 */
-		"5-3-inode",	/* 2 */
-		"efi",		/* 3 */
-		"efd",		/* 4 */
-		"iunlink",	/* 5 */
-		"6-1-inode",	/* 6 */
-		"6-1-buf",	/* 7 */
-		"inode",	/* 8 */
-		"buf",		/* 9 */
-		"dquot",        /* 10 */
-		0
-		};
-	static char *li_flags[] = {
-		"in ail",	/* 0x1 */
-		0
-		};
-	int count;
-
-	if ((mp->m_ail.ail_forw == NULL) ||
-	    (mp->m_ail.ail_forw == (xfs_log_item_t *)&mp->m_ail)) {
-		kdb_printf("AIL is empty\n");
-		return;
-	}
-	kdb_printf("AIL for mp 0x%p, oldest first\n", mp);
-	lip = (xfs_log_item_t*)mp->m_ail.ail_forw;
-	for (count = 0; lip; count++) {
-		kdb_printf("[%d] type %s ", count,
-			      lid_type[lip->li_type - XFS_LI_5_3_BUF + 1]);
-		printflags((uint)(lip->li_flags), li_flags, "flags:");
-		kdb_printf("  lsn %s\n   ", xfs_fmtlsn(&(lip->li_lsn)));
-		switch (lip->li_type) {
-		case XFS_LI_BUF:
-			xfs_buf_item_print((xfs_buf_log_item_t *)lip, 1);
-			break;
-		case XFS_LI_INODE:
-			xfs_inode_item_print((xfs_inode_log_item_t *)lip, 1);
-			break;
-		case XFS_LI_EFI:
-			xfs_efi_item_print((xfs_efi_log_item_t *)lip, 1);
-			break;
-		case XFS_LI_EFD:
-			xfs_efd_item_print((xfs_efd_log_item_t *)lip, 1);
-			break;
-		case XFS_LI_DQUOT:
-			xfs_dquot_item_print((xfs_dq_logitem_t *)lip, 1);
-			break;
-		case XFS_LI_QUOTAOFF:
-			xfs_qoff_item_print((xfs_qoff_logitem_t *)lip, 1);
-			break;
-		default:
-			kdb_printf("Unknown item type %d\n", lip->li_type);
-			break;
-		}
-
-		if (lip->li_ail.ail_forw == (xfs_log_item_t*)&mp->m_ail) {
-			lip = NULL;
-		} else {
-			lip = lip->li_ail.ail_forw;
-		}
-	}
-}
-
-/*
- * Print xfs mount structure.
- */
-static void
-xfsidbg_xmount(xfs_mount_t *mp)
-{
-	static char *xmount_flags[] = {
-		"WSYNC",	/* 0x0001 */
-		"INO64",	/* 0x0002 */
-		"RQCHK",        /* 0x0004 */
-		"FSCLEAN",	/* 0x0008 */
-		"FSSHUTDN",	/* 0x0010 */
-		"NOATIME",	/* 0x0020 */
-		"RETERR",	/* 0x0040 */
-		"NOALIGN",	/* 0x0080 */
-		"UNSHRD",	/* 0x0100 */
-		"RGSTRD",	/* 0x0200 */
-		"NORECVR",	/* 0x0400 */
-		"SHRD",		/* 0x0800 */
-		"IOSZ",		/* 0x1000 */
-		"OSYNC",	/* 0x2000 */
-		"NOUUID",	/* 0x4000 */
-		"32BIT",	/* 0x8000 */
-		"NOLOGFLUSH",	/* 0x10000 */
-		0
-	};
-
-	static char *quota_flags[] = {
-		"UQ",		/* 0x0001 */
-		"UQE",		/* 0x0002 */
-		"UQCHKD",	/* 0x0004 */
-		"PQ",		/* 0x0008 (IRIX ondisk) */
-		"GQE",		/* 0x0010 */
-		"GQCHKD",	/* 0x0020 */
-		"GQ",		/* 0x0040 */
-		"UQACTV",	/* 0x0080 */
-		"GQACTV",	/* 0x0100 */
-		"QMAYBE",	/* 0x0200 */
-		0
-	};
-
-	kdb_printf("xfs_mount at 0x%p\n", mp);
-	kdb_printf("vfsp 0x%p tid 0x%x ail_lock 0x%p &ail 0x%p\n",
-		XFS_MTOVFS(mp), mp->m_tid, &mp->m_ail_lock, &mp->m_ail);
-	kdb_printf("ail_gen 0x%x &sb 0x%p\n",
-		mp->m_ail_gen, &mp->m_sb);
-	kdb_printf("sb_lock 0x%p sb_bp 0x%p dev %s logdev %s rtdev %s\n",
-		&mp->m_sb_lock, mp->m_sb_bp,
-		mp->m_ddev_targp ?
-			XFS_BUFTARG_NAME(mp->m_ddev_targp) : "none",
-		mp->m_logdev_targp ?
-			XFS_BUFTARG_NAME(mp->m_logdev_targp) : "none",
-		mp->m_rtdev_targp ?
-			XFS_BUFTARG_NAME(mp->m_rtdev_targp) : "none");
-	kdb_printf("bsize %d agfrotor %d agirotor %d ihash 0x%p ihsize %d\n",
-		mp->m_bsize, mp->m_agfrotor, mp->m_agirotor,
-		mp->m_ihash, mp->m_ihsize);
-	kdb_printf("inodes 0x%p ilock 0x%p ireclaims 0x%x\n",
-		mp->m_inodes, &mp->m_ilock, mp->m_ireclaims);
-	kdb_printf("readio_log 0x%x readio_blocks 0x%x ",
-		mp->m_readio_log, mp->m_readio_blocks);
-	kdb_printf("writeio_log 0x%x writeio_blocks 0x%x\n",
-		mp->m_writeio_log, mp->m_writeio_blocks);
-	kdb_printf("logbufs %d logbsize %d LOG 0x%p\n", mp->m_logbufs,
-		mp->m_logbsize, mp->m_log);
-	kdb_printf("rsumlevels 0x%x rsumsize 0x%x rbmip 0x%p rsumip 0x%p\n",
-		mp->m_rsumlevels, mp->m_rsumsize, mp->m_rbmip, mp->m_rsumip);
-	kdb_printf("rootip 0x%p\n", mp->m_rootip);
-	kdb_printf("dircook_elog %d blkbit_log %d blkbb_log %d agno_log %d\n",
-		mp->m_dircook_elog, mp->m_blkbit_log, mp->m_blkbb_log,
-		mp->m_agno_log);
-	kdb_printf("agino_log %d nreadaheads %d inode cluster size %d\n",
-		mp->m_agino_log, mp->m_nreadaheads,
-		mp->m_inode_cluster_size);
-	kdb_printf("blockmask 0x%x blockwsize 0x%x blockwmask 0x%x\n",
-		mp->m_blockmask, mp->m_blockwsize, mp->m_blockwmask);
-	kdb_printf("alloc_mxr[lf,nd] %d %d alloc_mnr[lf,nd] %d %d\n",
-		mp->m_alloc_mxr[0], mp->m_alloc_mxr[1],
-		mp->m_alloc_mnr[0], mp->m_alloc_mnr[1]);
-	kdb_printf("bmap_dmxr[lfnr,ndnr] %d %d bmap_dmnr[lfnr,ndnr] %d %d\n",
-		mp->m_bmap_dmxr[0], mp->m_bmap_dmxr[1],
-		mp->m_bmap_dmnr[0], mp->m_bmap_dmnr[1]);
-	kdb_printf("inobt_mxr[lf,nd] %d %d inobt_mnr[lf,nd] %d %d\n",
-		mp->m_inobt_mxr[0], mp->m_inobt_mxr[1],
-		mp->m_inobt_mnr[0], mp->m_inobt_mnr[1]);
-	kdb_printf("ag_maxlevels %d bm_maxlevels[d,a] %d %d in_maxlevels %d\n",
-		mp->m_ag_maxlevels, mp->m_bm_maxlevels[0],
-		mp->m_bm_maxlevels[1], mp->m_in_maxlevels);
-	kdb_printf("perag 0x%p &peraglock 0x%p &growlock 0x%p\n",
-		mp->m_perag, &mp->m_peraglock, &mp->m_growlock);
-	printflags(mp->m_flags, xmount_flags,"flags");
-	kdb_printf("ialloc_inos %d ialloc_blks %d litino %d\n",
-		mp->m_ialloc_inos, mp->m_ialloc_blks, mp->m_litino);
-	kdb_printf("dir_node_ents %u attr_node_ents %u\n",
-		mp->m_dir_node_ents, mp->m_attr_node_ents);
-	kdb_printf("attroffset %d maxicount %Ld inoalign_mask %d\n",
-		mp->m_attroffset, mp->m_maxicount, mp->m_inoalign_mask);
-	kdb_printf("resblks %Ld resblks_avail %Ld\n", mp->m_resblks,
-		mp->m_resblks_avail);
-#if XFS_BIG_INUMS
-	kdb_printf(" inoadd %llx\n", (unsigned long long) mp->m_inoadd);
-#else
-	kdb_printf("\n");
-#endif
-	if (mp->m_quotainfo)
-		kdb_printf("quotainfo 0x%p (uqip = 0x%p, gqip = 0x%p)\n",
-			mp->m_quotainfo,
-			mp->m_quotainfo->qi_uquotaip,
-			mp->m_quotainfo->qi_gquotaip);
-	else
-		kdb_printf("quotainfo NULL\n");
-	printflags(mp->m_qflags, quota_flags,"quotaflags");
-	kdb_printf("\n");
-	kdb_printf("dalign %d swidth %d sinoalign %d attr_magicpct %d dir_magicpct %d\n",
-		mp->m_dalign, mp->m_swidth, mp->m_sinoalign,
-		mp->m_attr_magicpct, mp->m_dir_magicpct);
-	kdb_printf("mk_sharedro %d inode_quiesce %d sectbb_log %d\n",
-		mp->m_mk_sharedro, mp->m_inode_quiesce, mp->m_sectbb_log);
-	kdb_printf("dirversion %d dirblkfsbs %d &dirops 0x%p\n",
-		mp->m_dirversion, mp->m_dirblkfsbs, &mp->m_dirops);
-	kdb_printf("dirblksize %d dirdatablk 0x%Lx dirleafblk 0x%Lx dirfreeblk 0x%Lx\n",
-		mp->m_dirblksize,
-		(xfs_dfiloff_t)mp->m_dirdatablk,
-		(xfs_dfiloff_t)mp->m_dirleafblk,
-		(xfs_dfiloff_t)mp->m_dirfreeblk);
-	kdb_printf("chsize %d chash 0x%p\n",
-		mp->m_chsize, mp->m_chash);
-	kdb_printf("m_frozen %d m_active_trans %d\n",
-		mp->m_frozen, mp->m_active_trans.counter);
-	if (mp->m_fsname != NULL)
-		kdb_printf("mountpoint \"%s\"\n", mp->m_fsname);
-	else
-		kdb_printf("No name!!!\n");
-
-}
-
-static void
-xfsidbg_xihash(xfs_mount_t *mp)
-{
-	xfs_ihash_t	*ih;
-	int		i;
-	int		j;
-	int		total;
-	int		numzeros;
-	xfs_inode_t	*ip;
-	int		*hist;
-	int		hist_bytes = mp->m_ihsize * sizeof(int);
-	int		hist2[21];
-
-	hist = (int *) kmalloc(hist_bytes, GFP_KERNEL);
-
-	if (hist == NULL) {
-		kdb_printf("xfsidbg_xihash: kmalloc(%d) failed!\n",
-							hist_bytes);
-		return;
-	}
-
-	for (i = 0; i < mp->m_ihsize; i++) {
-		ih = mp->m_ihash + i;
-		j = 0;
-		for (ip = ih->ih_next; ip != NULL; ip = ip->i_next)
-			j++;
-		hist[i] = j;
-	}
-
-	numzeros = total = 0;
-
-	for (i = 0; i < 21; i++)
-		hist2[i] = 0;
-
-	for (i = 0; i < mp->m_ihsize; i++)  {
-		kdb_printf("%d ", hist[i]);
-		total += hist[i];
-		numzeros += hist[i] == 0 ? 1 : 0;
-		if (hist[i] > 20)
-			j = 20;
-		else
-			j = hist[i];
-
-		if (! (j <= 20)) {
-			kdb_printf("xfsidbg_xihash: (j > 20)/%d @ line # %d\n",
-							j, __LINE__);
-			return;
-		}
-
-		hist2[j]++;
-	}
-
-	kdb_printf("\n");
-
-	kdb_printf("total inodes = %d, average length = %d, adjusted average = %d \n",
-		total, total / mp->m_ihsize,
-		total / (mp->m_ihsize - numzeros));
-
-	for (i = 0; i < 21; i++)  {
-		kdb_printf("%d - %d , ", i, hist2[i]);
-	}
-	kdb_printf("\n");
-	kfree(hist);
-}
-
-/*
- * Command to print xfs inodes: kp xnode <addr>
- */
-static void
-xfsidbg_xnode(xfs_inode_t *ip)
-{
-	static char *tab_flags[] = {
-		"grio",		/* XFS_IGRIO */
-		"uiosize",	/* XFS_IUIOSZ */
-		"quiesce",	/* XFS_IQUIESCE */
-		"reclaim",	/* XFS_IRECLAIM */
-		"stale",	/* XFS_ISTALE */
-		NULL
-	};
-
-	kdb_printf("hash 0x%p next 0x%p prevp 0x%p mount 0x%p\n",
-		ip->i_hash,
-		ip->i_next,
-		ip->i_prevp,
-		ip->i_mount);
-	kdb_printf("mnext 0x%p mprev 0x%p vnode 0x%p \n",
-		ip->i_mnext,
-		ip->i_mprev,
-		XFS_ITOV_NULL(ip));
-	kdb_printf("dev %s ino %s\n",
-		XFS_BUFTARG_NAME(ip->i_mount->m_ddev_targp),
-		xfs_fmtino(ip->i_ino, ip->i_mount));
-	kdb_printf("blkno 0x%llx len 0x%x boffset 0x%x\n",
-		(long long) ip->i_blkno,
-		ip->i_len,
-		ip->i_boffset);
-	kdb_printf("transp 0x%p &itemp 0x%p\n",
-		ip->i_transp,
-		ip->i_itemp);
-	kdb_printf("&lock 0x%p &iolock 0x%p",
-		&ip->i_lock,
-		&ip->i_iolock);
-	kdb_printf("&flock 0x%p (%d) pincount 0x%x\n",
-		&ip->i_flock, valusema(&ip->i_flock),
-		xfs_ipincount(ip));
-	kdb_printf("udquotp 0x%p gdquotp 0x%p\n",
-		ip->i_udquot, ip->i_gdquot);
-	kdb_printf("new_size %Lx\n", ip->i_iocore.io_new_size);
-	printflags((int)ip->i_flags, tab_flags, "flags");
-	kdb_printf("\n");
-	kdb_printf("update_core 0x%x update size 0x%x\n",
-		(int)(ip->i_update_core), (int) ip->i_update_size);
-	kdb_printf("gen 0x%x delayed blks %d",
-		ip->i_gen,
-		ip->i_delayed_blks);
-	kdb_printf("\n");
-	kdb_printf("chash 0x%p cnext 0x%p cprev 0x%p\n",
-		ip->i_chash,
-		ip->i_cnext,
-		ip->i_cprev);
-	xfs_xnode_fork("data", &ip->i_df);
-	xfs_xnode_fork("attr", ip->i_afp);
-	kdb_printf("\n");
-	xfs_prdinode_core(&ip->i_d, ARCH_NOCONVERT);
-}
-
-static void
-xfsidbg_xcore(xfs_iocore_t *io)
-{
-	kdb_printf("io_obj 0x%p io_flags 0x%x io_mount 0x%p\n",
-			io->io_obj, io->io_flags, io->io_mount);
-	kdb_printf("new_size %Lx\n", io->io_new_size);
-}
-
-/*
- * Command to print xfs inode cluster hash table: kp xchash <addr>
- */
-static void
-xfsidbg_xchash(xfs_mount_t *mp)
-{
-	int		i;
-	xfs_chash_t	*ch;
-
-	kdb_printf("m_chash 0x%p size %d\n",
-		mp->m_chash, mp->m_chsize);
-	for (i = 0; i < mp->m_chsize; i++) {
-		ch = mp->m_chash + i;
-		kdb_printf("[%3d] ch 0x%p chashlist 0x%p\n", i, ch, ch->ch_list);
-		xfsidbg_xchashlist(ch->ch_list);
-	}
-}
-
-/*
- * Command to print xfs inode cluster hash list: kp xchashlist <addr>
- */
-static void
-xfsidbg_xchashlist(xfs_chashlist_t *chl)
-{
-	xfs_inode_t	*ip;
-
-	while (chl != NULL) {
-		kdb_printf("hashlist inode 0x%p blkno %lld buf 0x%p",
-		       chl->chl_ip, (long long) chl->chl_blkno, chl->chl_buf);
-
-		kdb_printf("\n");
-
-		/* print inodes on chashlist */
-		ip = chl->chl_ip;
-		do {
-			kdb_printf("0x%p ", ip);
-			ip = ip->i_cnext;
-		} while (ip != chl->chl_ip);
-		kdb_printf("\n");
-
-		chl=chl->chl_next;
-	}
-}
-
-/*
- * Print xfs per-ag data structures for filesystem.
- */
-static void
-xfsidbg_xperag(xfs_mount_t *mp)
-{
-	xfs_agnumber_t	agno;
-	xfs_perag_t	*pag;
-	int		busy;
-
-	pag = mp->m_perag;
-	for (agno = 0; agno < mp->m_sb.sb_agcount; agno++, pag++) {
-		kdb_printf("ag %d f_init %d i_init %d\n",
-			agno, pag->pagf_init, pag->pagi_init);
-		if (pag->pagf_init)
-			kdb_printf(
-	"    f_levels[b,c] %d,%d f_flcount %d f_freeblks %d f_longest %d\n"
-	"    f__metadata %d\n",
-				pag->pagf_levels[XFS_BTNUM_BNOi],
-				pag->pagf_levels[XFS_BTNUM_CNTi],
-				pag->pagf_flcount, pag->pagf_freeblks,
-				pag->pagf_longest, pag->pagf_metadata);
-		if (pag->pagi_init)
-			kdb_printf("    i_freecount %d i_inodeok %d\n",
-				pag->pagi_freecount, pag->pagi_inodeok);
-		if (pag->pagf_init) {
-			for (busy = 0; busy < XFS_PAGB_NUM_SLOTS; busy++) {
-				if (pag->pagb_list[busy].busy_length != 0) {
-					kdb_printf(
-		"	 %04d: start %d length %d tp 0x%p\n",
-					    busy,
-					    pag->pagb_list[busy].busy_start,
-					    pag->pagb_list[busy].busy_length,
-					    pag->pagb_list[busy].busy_tp);
-				}
-			}
-		}
-	}
-}
-
-#ifdef CONFIG_XFS_QUOTA
-static void
-xfsidbg_xqm()
-{
-	if (xfs_Gqm == NULL) {
-		kdb_printf("NULL XQM!!\n");
-		return;
-	}
-
-	kdb_printf("usrhtab 0x%p\tgrphtab 0x%p\tndqfree 0x%x\thashmask 0x%x\n",
-		xfs_Gqm->qm_usr_dqhtable,
-		xfs_Gqm->qm_grp_dqhtable,
-		xfs_Gqm->qm_dqfreelist.qh_nelems,
-		xfs_Gqm->qm_dqhashmask);
-	kdb_printf("&freelist 0x%p, totaldquots 0x%x nrefs 0x%x\n",
-		&xfs_Gqm->qm_dqfreelist,
-		atomic_read(&xfs_Gqm->qm_totaldquots),
-		xfs_Gqm->qm_nrefs);
-}
-#endif
-
-static void
-xfsidbg_xqm_diskdq(xfs_disk_dquot_t *d)
-{
-	kdb_printf("magic 0x%x\tversion 0x%x\tID 0x%x (%d)\t\n",
-		INT_GET(d->d_magic, ARCH_CONVERT),
-		INT_GET(d->d_version, ARCH_CONVERT),
-		INT_GET(d->d_id, ARCH_CONVERT),
-		INT_GET(d->d_id, ARCH_CONVERT));
-	kdb_printf("bhard 0x%llx\tbsoft 0x%llx\tihard 0x%llx\tisoft 0x%llx\n",
-		(unsigned long long)INT_GET(d->d_blk_hardlimit, ARCH_CONVERT),
-		(unsigned long long)INT_GET(d->d_blk_softlimit, ARCH_CONVERT),
-		(unsigned long long)INT_GET(d->d_ino_hardlimit, ARCH_CONVERT),
-		(unsigned long long)INT_GET(d->d_ino_softlimit, ARCH_CONVERT));
-	kdb_printf("bcount 0x%llx icount 0x%llx\n",
-		(unsigned long long)INT_GET(d->d_bcount, ARCH_CONVERT),
-		(unsigned long long)INT_GET(d->d_icount, ARCH_CONVERT));
-	kdb_printf("btimer 0x%x itimer 0x%x \n",
-		(int)INT_GET(d->d_btimer, ARCH_CONVERT),
-		(int)INT_GET(d->d_itimer, ARCH_CONVERT));
-}
-
-static void
-xfsidbg_xqm_dquot(xfs_dquot_t *dqp)
-{
-	static char *qflags[] = {
-		"USR",
-		"GRP",
-		"LCKD",
-		"FLKD",
-		"DIRTY",
-		"WANT",
-		"INACT",
-		"MARKER",
-		0
-	};
-	kdb_printf("mount 0x%p hash 0x%p gdquotp 0x%p HL_next 0x%p HL_prevp 0x%p\n",
-		dqp->q_mount,
-		dqp->q_hash,
-		dqp->q_gdquot,
-		dqp->HL_NEXT,
-		dqp->HL_PREVP);
-	kdb_printf("MPL_next 0x%p MPL_prevp 0x%p FL_next 0x%p FL_prev 0x%p\n",
-		dqp->MPL_NEXT,
-		dqp->MPL_PREVP,
-		dqp->dq_flnext,
-		dqp->dq_flprev);
-
-	kdb_printf("nrefs 0x%x, res_bcount %d, ",
-		dqp->q_nrefs, (int) dqp->q_res_bcount);
-	printflags(dqp->dq_flags, qflags, "flags:");
-	kdb_printf("\nblkno 0x%llx\tboffset 0x%x\n",
-		(unsigned long long) dqp->q_blkno, (int) dqp->q_bufoffset);
-	kdb_printf("qlock 0x%p  flock 0x%p (%s) pincount 0x%x\n",
-		&dqp->q_qlock,
-		&dqp->q_flock,
-		(valusema(&dqp->q_flock) <= 0) ? "LCK" : "UNLKD",
-		dqp->q_pincount);
-	kdb_printf("disk-dquot 0x%p\n", &dqp->q_core);
-	xfsidbg_xqm_diskdq(&dqp->q_core);
-
-}
-
-
-#define XQMIDBG_LIST_PRINT(l, NXT) \
-{ \
-	  xfs_dquot_t	*dqp;\
-	  int i = 0; \
-	  kdb_printf("[#%d dquots]\n", (int) (l)->qh_nelems); \
-	  for (dqp = (l)->qh_next; dqp != NULL; dqp = dqp->NXT) {\
-	   kdb_printf( \
-	      "\t%d. [0x%p] \"%d (%s)\"\t blks = %d, inos = %d refs = %d\n", \
-			 ++i, dqp, (int) INT_GET(dqp->q_core.d_id, ARCH_CONVERT), \
-			 DQFLAGTO_TYPESTR(dqp),      \
-			 (int) INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT), \
-			 (int) INT_GET(dqp->q_core.d_icount, ARCH_CONVERT), \
-			 (int) dqp->q_nrefs); }\
-	  kdb_printf("\n"); \
-}
-
-static void
-xfsidbg_xqm_dqattached_inos(xfs_mount_t	*mp)
-{
-	xfs_inode_t	*ip;
-	int		n = 0;
-
-	ip = mp->m_inodes;
-	do {
-		if (ip->i_mount == NULL) {
-			ip = ip->i_mnext;
-			continue;
-		}
-		if (ip->i_udquot || ip->i_gdquot) {
-			n++;
-			kdb_printf("inode = 0x%p, ino %d: udq 0x%p, gdq 0x%p\n",
-				ip, (int)ip->i_ino, ip->i_udquot, ip->i_gdquot);
-		}
-		ip = ip->i_mnext;
-	} while (ip != mp->m_inodes);
-	kdb_printf("\nNumber of inodes with dquots attached: %d\n", n);
-}
-
-#ifdef	CONFIG_XFS_QUOTA
-static void
-xfsidbg_xqm_freelist_print(xfs_frlist_t *qlist, char *title)
-{
-	xfs_dquot_t *dq;
-	int i = 0;
-	kdb_printf("%s (#%d)\n", title, (int) qlist->qh_nelems);
-	FOREACH_DQUOT_IN_FREELIST(dq, qlist) {
-		kdb_printf("\t%d.\t\"%d (%s:0x%p)\"\t bcnt = %d, icnt = %d "
-		       "refs = %d\n",
-		       ++i, (int) INT_GET(dq->q_core.d_id, ARCH_CONVERT),
-		       DQFLAGTO_TYPESTR(dq), dq,
-		       (int) INT_GET(dq->q_core.d_bcount, ARCH_CONVERT),
-		       (int) INT_GET(dq->q_core.d_icount, ARCH_CONVERT),
-		       (int) dq->q_nrefs);
-	}
-}
-
-static void
-xfsidbg_xqm_freelist(void)
-{
-	if (xfs_Gqm) {
-		xfsidbg_xqm_freelist_print(&(xfs_Gqm->qm_dqfreelist), "Freelist");
-	} else
-		kdb_printf("NULL XQM!!\n");
-}
-
-static void
-xfsidbg_xqm_htab(void)
-{
-	int		i;
-	xfs_dqhash_t	*h;
-
-	if (xfs_Gqm == NULL) {
-		kdb_printf("NULL XQM!!\n");
-		return;
-	}
-	for (i = 0; i <= xfs_Gqm->qm_dqhashmask; i++) {
-		h = &xfs_Gqm->qm_usr_dqhtable[i];
-		if (h->qh_next) {
-			kdb_printf("USR %d: ", i);
-			XQMIDBG_LIST_PRINT(h, HL_NEXT);
-		}
-	}
-	for (i = 0; i <= xfs_Gqm->qm_dqhashmask; i++) {
-		h = &xfs_Gqm->qm_grp_dqhtable[i];
-		if (h->qh_next) {
-			kdb_printf("GRP %d: ", i);
-			XQMIDBG_LIST_PRINT(h, HL_NEXT);
-		}
-	}
-}
-#endif
-
-static void
-xfsidbg_xqm_mplist(xfs_mount_t *mp)
-{
-	if (mp->m_quotainfo == NULL) {
-		kdb_printf("NULL quotainfo\n");
-		return;
-	}
-
-	XQMIDBG_LIST_PRINT(&(mp->m_quotainfo->qi_dqlist), MPL_NEXT);
-
-}
-
-
-static void
-xfsidbg_xqm_qinfo(xfs_mount_t *mp)
-{
-	if (mp == NULL || mp->m_quotainfo == NULL) {
-		kdb_printf("NULL quotainfo\n");
-		return;
-	}
-
-	kdb_printf("uqip 0x%p, gqip 0x%p, &pinlock 0x%p &dqlist 0x%p\n",
-		mp->m_quotainfo->qi_uquotaip,
-		mp->m_quotainfo->qi_gquotaip,
-		&mp->m_quotainfo->qi_pinlock,
-		&mp->m_quotainfo->qi_dqlist);
-
-	kdb_printf("nreclaims %d, btmlimit 0x%x, itmlimit 0x%x, RTbtmlim 0x%x\n",
-		(int)mp->m_quotainfo->qi_dqreclaims,
-		(int)mp->m_quotainfo->qi_btimelimit,
-		(int)mp->m_quotainfo->qi_itimelimit,
-		(int)mp->m_quotainfo->qi_rtbtimelimit);
-
-	kdb_printf("bwarnlim 0x%x, iwarnlim 0x%x, &qofflock 0x%p, "
-		"chunklen 0x%x, dqperchunk 0x%x\n",
-		(int)mp->m_quotainfo->qi_bwarnlimit,
-		(int)mp->m_quotainfo->qi_iwarnlimit,
-		&mp->m_quotainfo->qi_quotaofflock,
-		(int)mp->m_quotainfo->qi_dqchunklen,
-		(int)mp->m_quotainfo->qi_dqperchunk);
-}
-
-static void
-xfsidbg_xqm_tpdqinfo(xfs_trans_t *tp)
-{
-	xfs_dqtrx_t	*qa, *q;
-	int		i,j;
-
-	kdb_printf("dqinfo 0x%p\n", tp->t_dqinfo);
-	if (! tp->t_dqinfo)
-		return;
-	kdb_printf("USR: \n");
-	qa = tp->t_dqinfo->dqa_usrdquots;
-	for (j = 0; j < 2; j++) {
-		for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) {
-			if (qa[i].qt_dquot == NULL)
-				break;
-			q = &qa[i];
-			kdb_printf(
-  "\"%d\"[0x%p]: bres %d, bres-used %d, bdelta %d, del-delta %d, icnt-delta %d\n",
-				(int) q->qt_dquot->q_core.d_id,
-				q->qt_dquot,
-				(int) q->qt_blk_res,
-				(int) q->qt_blk_res_used,
-				(int) q->qt_bcount_delta,
-				(int) q->qt_delbcnt_delta,
-				(int) q->qt_icount_delta);
-		}
-		if (j == 0) {
-			qa = tp->t_dqinfo->dqa_grpdquots;
-			kdb_printf("GRP: \n");
-		}
-	}
-
-}
-
-
-
-/*
- * Print xfs superblock.
- */
-static void
-xfsidbg_xsb(xfs_sb_t *sbp, int convert)
-{
-	xfs_arch_t arch=convert?ARCH_CONVERT:ARCH_NOCONVERT;
-
-	kdb_printf(convert?"<converted>\n":"<unconverted>\n");
-
-	kdb_printf("magicnum 0x%x blocksize 0x%x dblocks %Ld rblocks %Ld\n",
-		INT_GET(sbp->sb_magicnum, arch), INT_GET(sbp->sb_blocksize, arch),
-		INT_GET(sbp->sb_dblocks, arch), INT_GET(sbp->sb_rblocks, arch));
-	kdb_printf("rextents %Ld uuid %s logstart %s\n",
-		INT_GET(sbp->sb_rextents, arch),
-		xfs_fmtuuid(&sbp->sb_uuid),
-		xfs_fmtfsblock(INT_GET(sbp->sb_logstart, arch), NULL));
-	kdb_printf("rootino %s ",
-		xfs_fmtino(INT_GET(sbp->sb_rootino, arch), NULL));
-	kdb_printf("rbmino %s ",
-		xfs_fmtino(INT_GET(sbp->sb_rbmino, arch), NULL));
-	kdb_printf("rsumino %s\n",
-		xfs_fmtino(INT_GET(sbp->sb_rsumino, arch), NULL));
-	kdb_printf("rextsize 0x%x agblocks 0x%x agcount 0x%x rbmblocks 0x%x\n",
-		INT_GET(sbp->sb_rextsize, arch),
-		INT_GET(sbp->sb_agblocks, arch),
-		INT_GET(sbp->sb_agcount, arch),
-		INT_GET(sbp->sb_rbmblocks, arch));
-	kdb_printf("logblocks 0x%x versionnum 0x%x sectsize 0x%x inodesize 0x%x\n",
-		INT_GET(sbp->sb_logblocks, arch),
-		INT_GET(sbp->sb_versionnum, arch),
-		INT_GET(sbp->sb_sectsize, arch),
-		INT_GET(sbp->sb_inodesize, arch));
-	kdb_printf("inopblock 0x%x blocklog 0x%x sectlog 0x%x inodelog 0x%x\n",
-		INT_GET(sbp->sb_inopblock, arch),
-		INT_GET(sbp->sb_blocklog, arch),
-		INT_GET(sbp->sb_sectlog, arch),
-		INT_GET(sbp->sb_inodelog, arch));
-	kdb_printf("inopblog %d agblklog %d rextslog %d inprogress %d imax_pct %d\n",
-		INT_GET(sbp->sb_inopblog, arch),
-		INT_GET(sbp->sb_agblklog, arch),
-		INT_GET(sbp->sb_rextslog, arch),
-		INT_GET(sbp->sb_inprogress, arch),
-		INT_GET(sbp->sb_imax_pct, arch));
-	kdb_printf("icount %Lx ifree %Lx fdblocks %Lx frextents %Lx\n",
-		INT_GET(sbp->sb_icount, arch),
-		INT_GET(sbp->sb_ifree, arch),
-		INT_GET(sbp->sb_fdblocks, arch),
-		INT_GET(sbp->sb_frextents, arch));
-	kdb_printf("uquotino %s ", xfs_fmtino(INT_GET(sbp->sb_uquotino, arch), NULL));
-	kdb_printf("gquotino %s ", xfs_fmtino(INT_GET(sbp->sb_gquotino, arch), NULL));
-	kdb_printf("qflags 0x%x flags 0x%x shared_vn %d inoaligmt %d\n",
-		INT_GET(sbp->sb_qflags, arch), INT_GET(sbp->sb_flags, arch), INT_GET(sbp->sb_shared_vn, arch),
-		INT_GET(sbp->sb_inoalignmt, arch));
-	kdb_printf("unit %d width %d dirblklog %d\n",
-		INT_GET(sbp->sb_unit, arch), INT_GET(sbp->sb_width, arch), INT_GET(sbp->sb_dirblklog, arch));
-	kdb_printf("log sunit %d\n", INT_GET(sbp->sb_logsunit, arch));
-}
-
-
-/*
- * Print out an XFS transaction structure.  Print summaries for
- * each of the items.
- */
-static void
-xfsidbg_xtp(xfs_trans_t *tp)
-{
-	xfs_log_item_chunk_t	*licp;
-	xfs_log_item_desc_t	*lidp;
-	xfs_log_busy_chunk_t	*lbcp;
-	int			i;
-	int			chunk;
-	static char *xtp_flags[] = {
-		"dirty",	/* 0x1 */
-		"sb_dirty",	/* 0x2 */
-		"perm_log_res",	/* 0x4 */
-		"sync",         /* 0x08 */
-		"dq_dirty",     /* 0x10 */
-		0
-		};
-	static char *lid_flags[] = {
-		"dirty",	/* 0x1 */
-		"pinned",	/* 0x2 */
-		"sync unlock",	/* 0x4 */
-		"buf stale",	/* 0x8 */
-		0
-		};
-
-	kdb_printf("tp 0x%p type ", tp);
-	switch (tp->t_type) {
-	case XFS_TRANS_SETATTR_NOT_SIZE: kdb_printf("SETATTR_NOT_SIZE");	break;
-	case XFS_TRANS_SETATTR_SIZE:	kdb_printf("SETATTR_SIZE");	break;
-	case XFS_TRANS_INACTIVE:	kdb_printf("INACTIVE");		break;
-	case XFS_TRANS_CREATE:		kdb_printf("CREATE");		break;
-	case XFS_TRANS_CREATE_TRUNC:	kdb_printf("CREATE_TRUNC");	break;
-	case XFS_TRANS_TRUNCATE_FILE:	kdb_printf("TRUNCATE_FILE");	break;
-	case XFS_TRANS_REMOVE:		kdb_printf("REMOVE");		break;
-	case XFS_TRANS_LINK:		kdb_printf("LINK");		break;
-	case XFS_TRANS_RENAME:		kdb_printf("RENAME");		break;
-	case XFS_TRANS_MKDIR:		kdb_printf("MKDIR");		break;
-	case XFS_TRANS_RMDIR:		kdb_printf("RMDIR");		break;
-	case XFS_TRANS_SYMLINK:		kdb_printf("SYMLINK");		break;
-	case XFS_TRANS_SET_DMATTRS:	kdb_printf("SET_DMATTRS");		break;
-	case XFS_TRANS_GROWFS:		kdb_printf("GROWFS");		break;
-	case XFS_TRANS_STRAT_WRITE:	kdb_printf("STRAT_WRITE");		break;
-	case XFS_TRANS_DIOSTRAT:	kdb_printf("DIOSTRAT");		break;
-	case XFS_TRANS_WRITE_SYNC:	kdb_printf("WRITE_SYNC");		break;
-	case XFS_TRANS_WRITEID:		kdb_printf("WRITEID");		break;
-	case XFS_TRANS_ADDAFORK:	kdb_printf("ADDAFORK");		break;
-	case XFS_TRANS_ATTRINVAL:	kdb_printf("ATTRINVAL");		break;
-	case XFS_TRANS_ATRUNCATE:	kdb_printf("ATRUNCATE");		break;
-	case XFS_TRANS_ATTR_SET:	kdb_printf("ATTR_SET");		break;
-	case XFS_TRANS_ATTR_RM:		kdb_printf("ATTR_RM");		break;
-	case XFS_TRANS_ATTR_FLAG:	kdb_printf("ATTR_FLAG");		break;
-	case XFS_TRANS_CLEAR_AGI_BUCKET:  kdb_printf("CLEAR_AGI_BUCKET");	break;
-	case XFS_TRANS_QM_SBCHANGE:	kdb_printf("QM_SBCHANGE");	break;
-	case XFS_TRANS_QM_QUOTAOFF:	kdb_printf("QM_QUOTAOFF");	break;
-	case XFS_TRANS_QM_DQALLOC:	kdb_printf("QM_DQALLOC");		break;
-	case XFS_TRANS_QM_SETQLIM:	kdb_printf("QM_SETQLIM");		break;
-	case XFS_TRANS_QM_DQCLUSTER:	kdb_printf("QM_DQCLUSTER");	break;
-	case XFS_TRANS_QM_QINOCREATE:	kdb_printf("QM_QINOCREATE");	break;
-	case XFS_TRANS_QM_QUOTAOFF_END:	kdb_printf("QM_QOFF_END");		break;
-	case XFS_TRANS_SB_UNIT:		kdb_printf("SB_UNIT");		break;
-	case XFS_TRANS_FSYNC_TS:	kdb_printf("FSYNC_TS");		break;
-	case XFS_TRANS_GROWFSRT_ALLOC:	kdb_printf("GROWFSRT_ALLOC");	break;
-	case XFS_TRANS_GROWFSRT_ZERO:	kdb_printf("GROWFSRT_ZERO");	break;
-	case XFS_TRANS_GROWFSRT_FREE:	kdb_printf("GROWFSRT_FREE");	break;
-
-	default:			kdb_printf("0x%x", tp->t_type);	break;
-	}
-	kdb_printf(" mount 0x%p\n", tp->t_mountp);
-	kdb_printf("flags ");
-	printflags(tp->t_flags, xtp_flags,"xtp");
-	kdb_printf("\n");
-	kdb_printf("callback 0x%p forw 0x%p back 0x%p\n",
-		&tp->t_logcb, tp->t_forw, tp->t_back);
-	kdb_printf("log res %d block res %d block res used %d\n",
-		tp->t_log_res, tp->t_blk_res, tp->t_blk_res_used);
-	kdb_printf("rt res %d rt res used %d\n", tp->t_rtx_res,
-		tp->t_rtx_res_used);
-	kdb_printf("ticket 0x%lx lsn %s commit_lsn %s\n",
-		(unsigned long) tp->t_ticket,
-		xfs_fmtlsn(&tp->t_lsn),
-		xfs_fmtlsn(&tp->t_commit_lsn));
-	kdb_printf("callback 0x%p callarg 0x%p\n",
-		tp->t_callback, tp->t_callarg);
-	kdb_printf("icount delta %ld ifree delta %ld\n",
-		tp->t_icount_delta, tp->t_ifree_delta);
-	kdb_printf("blocks delta %ld res blocks delta %ld\n",
-		tp->t_fdblocks_delta, tp->t_res_fdblocks_delta);
-	kdb_printf("rt delta %ld res rt delta %ld\n",
-		tp->t_frextents_delta, tp->t_res_frextents_delta);
-	kdb_printf("ag freeblks delta %ld ag flist delta %ld ag btree delta %ld\n",
-		tp->t_ag_freeblks_delta, tp->t_ag_flist_delta,
-		tp->t_ag_btree_delta);
-	kdb_printf("dblocks delta %ld agcount delta %ld imaxpct delta %ld\n",
-		tp->t_dblocks_delta, tp->t_agcount_delta, tp->t_imaxpct_delta);
-	kdb_printf("rextsize delta %ld rbmblocks delta %ld\n",
-		tp->t_rextsize_delta, tp->t_rbmblocks_delta);
-	kdb_printf("rblocks delta %ld rextents delta %ld rextslog delta %ld\n",
-		tp->t_rblocks_delta, tp->t_rextents_delta,
-		tp->t_rextslog_delta);
-	kdb_printf("dqinfo 0x%p\n", tp->t_dqinfo);
-	kdb_printf("log items:\n");
-	licp = &tp->t_items;
-	chunk = 0;
-	while (licp != NULL) {
-		if (XFS_LIC_ARE_ALL_FREE(licp)) {
-			licp = licp->lic_next;
-			chunk++;
-			continue;
-		}
-		for (i = 0; i < licp->lic_unused; i++) {
-			if (XFS_LIC_ISFREE(licp, i)) {
-				continue;
-			}
-
-			lidp = XFS_LIC_SLOT(licp, i);
-			kdb_printf("\n");
-			kdb_printf("chunk %d index %d item 0x%p size %d\n",
-				chunk, i, lidp->lid_item, lidp->lid_size);
-			kdb_printf("flags ");
-			printflags(lidp->lid_flags, lid_flags,"lic");
-			kdb_printf("\n");
-			xfsidbg_xlogitem(lidp->lid_item);
-		}
-		chunk++;
-		licp = licp->lic_next;
-	}
-
-	kdb_printf("log busy free %d, list:\n", tp->t_busy_free);
-	lbcp = &tp->t_busy;
-	chunk = 0;
-	while (lbcp != NULL) {
-		kdb_printf("Chunk %d at 0x%p next 0x%p free 0x%08x unused %d\n",
-			chunk, lbcp, lbcp->lbc_next, lbcp->lbc_free,
-			lbcp->lbc_unused);
-		for (i = 0; i < XFS_LBC_NUM_SLOTS; i++) {
-			kdb_printf("  %02d: ag %d idx %d\n",
-				i,
-				lbcp->lbc_busy[i].lbc_ag,
-				lbcp->lbc_busy[i].lbc_idx);
-		}
-		lbcp = lbcp->lbc_next;
-	}
-}
-
-static void
-xfsidbg_xtrans_res(
-	xfs_mount_t	*mp)
-{
-	xfs_trans_reservations_t	*xtrp;
-
-	xtrp = &mp->m_reservations;
-	kdb_printf("write: %d\ttruncate: %d\trename: %d\n",
-		xtrp->tr_write, xtrp->tr_itruncate, xtrp->tr_rename);
-	kdb_printf("link: %d\tremove: %d\tsymlink: %d\n",
-		xtrp->tr_link, xtrp->tr_remove, xtrp->tr_symlink);
-	kdb_printf("create: %d\tmkdir: %d\tifree: %d\n",
-		xtrp->tr_create, xtrp->tr_mkdir, xtrp->tr_ifree);
-	kdb_printf("ichange: %d\tgrowdata: %d\tswrite: %d\n",
-		xtrp->tr_ichange, xtrp->tr_growdata, xtrp->tr_swrite);
-	kdb_printf("addafork: %d\twriteid: %d\tattrinval: %d\n",
-		xtrp->tr_addafork, xtrp->tr_writeid, xtrp->tr_attrinval);
-	kdb_printf("attrset: %d\tattrrm: %d\tclearagi: %d\n",
-		xtrp->tr_attrset, xtrp->tr_attrrm, xtrp->tr_clearagi);
-	kdb_printf("growrtalloc: %d\tgrowrtzero: %d\tgrowrtfree: %d\n",
-		xtrp->tr_growrtalloc, xtrp->tr_growrtzero, xtrp->tr_growrtfree);
-}
-
-module_init(xfsidbg_init)
-module_exit(xfsidbg_exit)
diff -puN fs/xfs/xfs_iget.c~linus fs/xfs/xfs_iget.c
--- 25/fs/xfs/xfs_iget.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_iget.c	2004-01-19 22:17:24.000000000 -0800
@@ -450,13 +450,12 @@ retry:
 		xfs_inode_t	*ip;
 		int		newnode;
 
-
 		vp = LINVFS_GET_VP(inode);
 		if (inode->i_state & I_NEW) {
 inode_allocate:
 			vn_initialize(inode);
 			error = xfs_iget_core(vp, mp, tp, ino,
-							lock_flags, ipp, bno);
+						lock_flags, ipp, bno);
 			if (error) {
 				make_bad_inode(inode);
 				if (inode->i_state & I_NEW)
@@ -506,9 +505,6 @@ xfs_inode_lock_init(
 	mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER,
 		     "xfsino", (long)vp->v_number);
 	mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", vp->v_number);
-#ifdef NOTYET
-	mutex_init(&ip->i_range_lock.r_spinlock, MUTEX_SPIN, "xrange");
-#endif /* NOTYET */
 	init_waitqueue_head(&ip->i_ipin_wait);
 	atomic_set(&ip->i_pincount, 0);
 	init_sema(&ip->i_flock, 1, "xfsfino", vp->v_number);
@@ -830,9 +826,7 @@ xfs_ilock(xfs_inode_t	*ip,
 	} else if (lock_flags & XFS_ILOCK_SHARED) {
 		mraccess(&ip->i_lock);
 	}
-#ifdef XFS_ILOCK_TRACE
-	xfs_ilock_trace(ip, 1, lock_flags, (inst_t *)return_address);
-#endif
+	xfs_ilock_trace(ip, 1, lock_flags, (inst_t *)__return_address);
 }
 
 /*
@@ -895,9 +889,7 @@ xfs_ilock_nowait(xfs_inode_t	*ip,
 			return 0;
 		}
 	}
-#ifdef XFS_ILOCK_TRACE
 	xfs_ilock_trace(ip, 2, lock_flags, (inst_t *)__return_address);
-#endif
 	return 1;
 }
 
@@ -955,9 +947,7 @@ xfs_iunlock(xfs_inode_t	*ip,
 						(xfs_log_item_t*)(ip->i_itemp));
 		}
 	}
-#ifdef XFS_ILOCK_TRACE
 	xfs_ilock_trace(ip, 3, lock_flags, (inst_t *)__return_address);
-#endif
 }
 
 /*
diff -puN fs/xfs/xfs_inode.c~linus fs/xfs/xfs_inode.c
--- 25/fs/xfs/xfs_inode.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_inode.c	2004-01-19 22:17:24.000000000 -0800
@@ -908,9 +908,6 @@ xfs_iread(
 #ifdef XFS_RW_TRACE
 	ip->i_rwtrace = ktrace_alloc(XFS_RW_KTRACE_SIZE, KM_SLEEP);
 #endif
-#ifdef XFS_STRAT_TRACE
-	ip->i_strat_trace = ktrace_alloc(XFS_STRAT_KTRACE_SIZE, KM_SLEEP);
-#endif
 #ifdef XFS_ILOCK_TRACE
 	ip->i_lock_trace = ktrace_alloc(XFS_ILOCK_KTRACE_SIZE, KM_SLEEP);
 #endif
@@ -1144,8 +1141,8 @@ xfs_ialloc(
 	ip->i_d.di_onlink = 0;
 	ip->i_d.di_nlink = nlink;
 	ASSERT(ip->i_d.di_nlink == nlink);
-	ip->i_d.di_uid = current->fsuid;
-	ip->i_d.di_gid = current->fsgid;
+	ip->i_d.di_uid = current_fsuid(cr);
+	ip->i_d.di_gid = current_fsgid(cr);
 	ip->i_d.di_projid = prid;
 	memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
 
@@ -1362,16 +1359,16 @@ xfs_itrunc_trace(
 	ktrace_enter(ip->i_rwtrace,
 		     (void*)((long)tag),
 		     (void*)ip,
-		     (void*)((ip->i_d.di_size >> 32) & 0xffffffff),
-		     (void*)(ip->i_d.di_size & 0xffffffff),
+		     (void*)(unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff),
+		     (void*)(unsigned long)(ip->i_d.di_size & 0xffffffff),
 		     (void*)((long)flag),
-		     (void*)((new_size >> 32) & 0xffffffff),
-		     (void*)(new_size & 0xffffffff),
-		     (void*)((toss_start >> 32) & 0xffffffff),
-		     (void*)(toss_start & 0xffffffff),
-		     (void*)((toss_finish >> 32) & 0xffffffff),
-		     (void*)(toss_finish & 0xffffffff),
-		     (void*)((long)private.p_cpuid),
+		     (void*)(unsigned long)((new_size >> 32) & 0xffffffff),
+		     (void*)(unsigned long)(new_size & 0xffffffff),
+		     (void*)(unsigned long)((toss_start >> 32) & 0xffffffff),
+		     (void*)(unsigned long)(toss_start & 0xffffffff),
+		     (void*)(unsigned long)((toss_finish >> 32) & 0xffffffff),
+		     (void*)(unsigned long)(toss_finish & 0xffffffff),
+		     (void*)(unsigned long)current_cpu(),
 		     (void*)0,
 		     (void*)0,
 		     (void*)0,
@@ -2755,17 +2752,8 @@ xfs_idestroy(
 	}
 	if (ip->i_afp)
 		xfs_idestroy_fork(ip, XFS_ATTR_FORK);
-#ifdef NOTYET
-	if (ip->i_range_lock.r_sleep != NULL) {
-		freesema(ip->i_range_lock.r_sleep);
-		kmem_free(ip->i_range_lock.r_sleep, sizeof(sema_t));
-	}
-#endif /* NOTYET */
 	mrfree(&ip->i_lock);
 	mrfree(&ip->i_iolock);
-#ifdef NOTYET
-	mutex_destroy(&ip->i_range_lock.r_spinlock);
-#endif /* NOTYET */
 	freesema(&ip->i_flock);
 #ifdef XFS_BMAP_TRACE
 	ktrace_free(ip->i_xtrace);
@@ -2776,9 +2764,6 @@ xfs_idestroy(
 #ifdef XFS_RW_TRACE
 	ktrace_free(ip->i_rwtrace);
 #endif
-#ifdef XFS_STRAT_TRACE
-	ktrace_free(ip->i_strat_trace);
-#endif
 #ifdef XFS_ILOCK_TRACE
 	ktrace_free(ip->i_lock_trace);
 #endif
@@ -3707,7 +3692,7 @@ xfs_iaccess(
 	if ((error = _ACL_XFS_IACCESS(ip, mode, cr)) != -1)
 		return error ? XFS_ERROR(error) : 0;
 
-	if (current->fsuid != ip->i_d.di_uid) {
+	if (current_fsuid(cr) != ip->i_d.di_uid) {
 		mode >>= 3;
 		if (!in_group_p((gid_t)ip->i_d.di_gid))
 			mode >>= 3;
@@ -3814,7 +3799,7 @@ xfs_ichgtime(xfs_inode_t *ip,
 	 * We're not supposed to change timestamps in readonly-mounted
 	 * filesystems.  Throw it away if anyone asks us.
 	 */
-	if (vp->v_vfsp->vfs_flag & VFS_RDONLY)
+	if (unlikely(vp->v_vfsp->vfs_flag & VFS_RDONLY))
 		return;
 
 	/*
@@ -3828,17 +3813,17 @@ xfs_ichgtime(xfs_inode_t *ip,
 
 	nanotime(&tv);
 	if (flags & XFS_ICHGTIME_MOD) {
-		inode->i_mtime = tv;
+		VN_MTIMESET(vp, &tv);
 		ip->i_d.di_mtime.t_sec = (__int32_t)tv.tv_sec;
 		ip->i_d.di_mtime.t_nsec = (__int32_t)tv.tv_nsec;
 	}
 	if (flags & XFS_ICHGTIME_ACC) {
-		inode->i_atime  = tv;
+		VN_ATIMESET(vp, &tv);
 		ip->i_d.di_atime.t_sec = (__int32_t)tv.tv_sec;
 		ip->i_d.di_atime.t_nsec = (__int32_t)tv.tv_nsec;
 	}
 	if (flags & XFS_ICHGTIME_CHG) {
-		inode->i_ctime  = tv;
+		VN_CTIMESET(vp, &tv);
 		ip->i_d.di_ctime.t_sec = (__int32_t)tv.tv_sec;
 		ip->i_d.di_ctime.t_nsec = (__int32_t)tv.tv_nsec;
 	}
@@ -3859,17 +3844,18 @@ xfs_ichgtime(xfs_inode_t *ip,
 }
 
 #ifdef XFS_ILOCK_TRACE
+ktrace_t	*xfs_ilock_trace_buf;
+
 void
 xfs_ilock_trace(xfs_inode_t *ip, int lock, unsigned int lockflags, inst_t *ra)
 {
 	ktrace_enter(ip->i_lock_trace,
 		     (void *)ip,
-		      (void *)(__psint_t)lock,		/* 1 = LOCK, 3=UNLOCK, etc */
-		     (void *)(__psint_t)lockflags,	/* XFS_ILOCK_EXCL etc */
-		     (void *)ra,			/* caller of ilock */
-		     (void *)(__psint_t)cpuid(),
-		     (void *)(__psint_t)current_pid(),
+		     (void *)(unsigned long)lock, /* 1 = LOCK, 3=UNLOCK, etc */
+		     (void *)(unsigned long)lockflags, /* XFS_ILOCK_EXCL etc */
+		     (void *)ra,		/* caller of ilock */
+		     (void *)(unsigned long)current_cpu(),
+		     (void *)(unsigned long)current_pid(),
 		     0,0,0,0,0,0,0,0,0,0);
-
 }
-#endif /* ILOCK_TRACE */
+#endif
diff -puN fs/xfs/xfs_inode.h~linus fs/xfs/xfs_inode.h
--- 25/fs/xfs/xfs_inode.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_inode.h	2004-01-19 22:17:24.000000000 -0800
@@ -99,6 +99,13 @@ struct xfs_mount;
 struct xfs_trans;
 struct xfs_dquot;
 
+#if defined(XFS_ILOCK_TRACE)
+#define XFS_ILOCK_KTRACE_SIZE	32
+extern ktrace_t *xfs_ilock_trace_buf;
+extern void xfs_ilock_trace(struct xfs_inode *, int, unsigned int, inst_t *);
+#else
+#define	xfs_ilock_trace(i,n,f,ra)
+#endif
 
 /*
  * This structure is used to communicate which extents of a file
@@ -264,7 +271,10 @@ typedef struct xfs_inode {
 	sema_t			i_flock;	/* inode flush lock */
 	atomic_t		i_pincount;	/* inode pin count */
 	wait_queue_head_t	i_ipin_wait;	/* inode pinning wait queue */
-
+#ifdef HAVE_REFCACHE
+	struct xfs_inode	**i_refcache;	/* ptr to entry in ref cache */
+	struct xfs_inode	*i_release;	/* inode to unref */
+#endif
 	/* I/O state */
 	xfs_iocore_t		i_iocore;	/* I/O core */
 
@@ -280,15 +290,22 @@ typedef struct xfs_inode {
 	struct xfs_inode	*i_cnext;	/* cluster hash link forward */
 	struct xfs_inode	*i_cprev;	/* cluster hash link backward */
 
-#ifdef DEBUG
 	/* Trace buffers per inode. */
+#ifdef XFS_BMAP_TRACE
 	struct ktrace		*i_xtrace;	/* inode extent list trace */
+#endif
+#ifdef XFS_BMBT_TRACE
 	struct ktrace		*i_btrace;	/* inode bmap btree trace */
+#endif
+#ifdef XFS_RW_TRACE
 	struct ktrace		*i_rwtrace;	/* inode read/write trace */
-	struct ktrace		*i_strat_trace;	/* inode strat_write trace */
+#endif
+#ifdef XFS_ILOCK_TRACE
 	struct ktrace		*i_lock_trace;	/* inode lock/unlock trace */
+#endif
+#ifdef XFS_DIR2_TRACE
 	struct ktrace		*i_dir_trace;	/* inode directory trace */
-#endif /* DEBUG */
+#endif
 } xfs_inode_t;
 
 #endif	/* __KERNEL__ */
@@ -536,12 +553,6 @@ extern struct kmem_zone	*xfs_inode_zone;
 extern struct kmem_zone	*xfs_ili_zone;
 extern struct vnodeops	xfs_vnodeops;
 
-#ifdef XFS_ILOCK_TRACE
-#define XFS_ILOCK_KTRACE_SIZE	32
-void	xfs_ilock_trace(xfs_inode_t *ip, int lock, unsigned int lockflags,
-			inst_t *ra);
-#endif
-
 #endif	/* __KERNEL__ */
 
 #endif	/* __XFS_INODE_H__ */
diff -puN fs/xfs/xfs_iocore.c~linus fs/xfs/xfs_iocore.c
--- 25/fs/xfs/xfs_iocore.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_iocore.c	2004-01-19 22:17:24.000000000 -0800
@@ -61,6 +61,7 @@
 #include "xfs_rw.h"
 #include "xfs_quota.h"
 #include "xfs_trans_space.h"
+#include "xfs_iomap.h"
 
 
 STATIC xfs_fsize_t
diff -puN /dev/null fs/xfs/xfs_iomap.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/fs/xfs/xfs_iomap.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2003 Silicon Graphics, Inc.  All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement
+ * or the like.  Any license provided herein, whether implied or
+ * otherwise, applies only to this software file.  Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
+ * Mountain View, CA  94043, or:
+ *
+ * http://www.sgi.com
+ *
+ * For further information regarding this notice, see:
+ *
+ * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+ */
+
+
+
+#ifndef __XFS_IOMAP_H__
+#define __XFS_IOMAP_H__
+
+#define IOMAP_DADDR_NULL ((xfs_daddr_t) (-1LL))
+
+
+typedef enum {				/* iomap_flags values */
+	IOMAP_EOF =		0x01,	/* mapping contains EOF   */
+	IOMAP_HOLE =		0x02,	/* mapping covers a hole  */
+	IOMAP_DELAY =		0x04,	/* mapping covers delalloc region  */
+	IOMAP_UNWRITTEN =	0x20,	/* mapping covers allocated */
+					/* but uninitialized file data  */
+	IOMAP_NEW =		0x40	/* just allocate */
+} iomap_flags_t;
+
+typedef enum {
+	/* base extent manipulation calls */
+	BMAPI_READ = (1 << 0),		/* read extents */
+	BMAPI_WRITE = (1 << 1),		/* create extents */
+	BMAPI_ALLOCATE = (1 << 2),	/* delayed allocate to real extents */
+	BMAPI_UNWRITTEN  = (1 << 3),	/* unwritten extents to real extents */
+	/* modifiers */
+	BMAPI_IGNSTATE = (1 << 4),	/* ignore unwritten state on read */
+	BMAPI_DIRECT = (1 << 5),		/* direct instead of buffered write */
+	BMAPI_MMAP = (1 << 6),		/* allocate for mmap write */
+	BMAPI_SYNC = (1 << 7),		/* sync write */
+	BMAPI_TRYLOCK = (1 << 8),	/* non-blocking request */
+	BMAPI_DEVICE = (1 << 9),	/* we only want to know the device */
+} bmapi_flags_t;
+
+
+/*
+ * xfs_iomap_t:  File system I/O map
+ *
+ * The iomap_bn, iomap_offset and iomap_length fields are expressed in disk blocks.
+ * The iomap_length field specifies the size of the underlying backing store
+ * for the particular mapping.
+ *
+ * The iomap_bsize, iomap_size and iomap_delta fields are in bytes and indicate
+ * the size of the mapping, the number of bytes that are valid to access
+ * (read or write), and the offset into the mapping, given the offset
+ * supplied to the file I/O map routine.  iomap_delta is the offset of the
+ * desired data from the beginning of the mapping.
+ *
+ * When a request is made to read beyond the logical end of the object,
+ * iomap_size may be set to 0, but iomap_offset and iomap_length should be set to
+ * the actual amount of underlying storage that has been allocated, if any.
+ */
+
+typedef struct xfs_iomap {
+	xfs_daddr_t		iomap_bn;
+	xfs_buftarg_t		*iomap_target;
+	loff_t			iomap_offset;
+	size_t			iomap_delta;
+	size_t			iomap_bsize;
+	iomap_flags_t		iomap_flags;
+} xfs_iomap_t;
+
+struct xfs_iocore;
+struct xfs_inode;
+struct xfs_bmbt_irec;
+
+extern int xfs_iomap(struct xfs_iocore *, xfs_off_t, ssize_t, int,
+		     struct xfs_iomap *, int *);
+extern int xfs_iomap_write_direct(struct xfs_inode *, loff_t, size_t,
+				  int, struct xfs_bmbt_irec *, int *, int);
+extern int xfs_iomap_write_delay(struct xfs_inode *, loff_t, size_t, int,
+				 struct xfs_bmbt_irec *, int *);
+extern int xfs_iomap_write_allocate(struct xfs_inode *,
+				struct xfs_bmbt_irec *, int *);
+extern int xfs_iomap_write_unwritten(struct xfs_inode *, loff_t, size_t);
+
+#endif /* __XFS_IOMAP_H__*/
diff -puN fs/xfs/xfs_itable.c~linus fs/xfs/xfs_itable.c
--- 25/fs/xfs/xfs_itable.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_itable.c	2004-01-19 22:17:24.000000000 -0800
@@ -65,7 +65,10 @@ xfs_bulkstat_one(
 	xfs_trans_t	*tp,		/* transaction pointer */
 	xfs_ino_t	ino,		/* inode number to get data for */
 	void		*buffer,	/* buffer to place output in */
+	int		ubsize,		/* size of buffer */
+	void		*private_data,	/* my private data */
 	xfs_daddr_t	bno,		/* starting bno of inode cluster */
+	int		*ubused,	/* bytes used by me */
 	void		*dibuff,	/* on-disk inode buffer */
 	int		*stat)		/* BULKSTAT_RV_... */
 {
@@ -86,6 +89,10 @@ xfs_bulkstat_one(
 		*stat = BULKSTAT_RV_NOTHING;
 		return XFS_ERROR(EINVAL);
 	}
+	if (ubsize < sizeof(*buf)) {
+		*stat = BULKSTAT_RV_NOTHING;
+		return XFS_ERROR(ENOMEM);
+	}
 
 	if (dip == NULL) {
 		/* We're not being passed a pointer to a dinode.  This happens
@@ -218,6 +225,8 @@ xfs_bulkstat_one(
 	}
 
 	*stat = BULKSTAT_RV_DIDONE;
+	if (ubused)
+		*ubused = sizeof(*buf);
 	return 0;
 }
 
@@ -231,6 +240,7 @@ xfs_bulkstat(
 	xfs_ino_t		*lastinop, /* last inode returned */
 	int			*ubcountp, /* size of buffer/count returned */
 	bulkstat_one_pf		formatter, /* func that'd fill a single buf */
+	void			*private_data,/* private data for formatter */
 	size_t			statstruct_size, /* sizeof struct filling */
 	xfs_caddr_t		ubuffer, /* buffer with inode stats */
 	int			flags,	/* defined in xfs_itable.h */
@@ -265,8 +275,10 @@ xfs_bulkstat(
 	int			rval;	/* return value error code */
 	int			tmp;	/* result value from btree calls */
 	int			ubcount; /* size of user's buffer */
-	int			ubleft;	/* spaces left in user's buffer */
+	int			ubleft;	/* bytes left in user's buffer */
 	xfs_caddr_t		ubufp;	/* current pointer into user's buffer */
+	int			ubelem;	/* spaces used in user's buffer */
+	int			ubused;	/* bytes used by formatter */
 	xfs_buf_t		*bp;	/* ptr to on-disk inode cluster buf */
 	xfs_dinode_t		*dip;	/* ptr into bp for specific inode */
 	xfs_inode_t		*ip;	/* ptr to in-core inode struct */
@@ -284,8 +296,9 @@ xfs_bulkstat(
 		*ubcountp = 0;
 		return 0;
 	}
-	ubcount = ubleft = *ubcountp;
-	*ubcountp = 0;
+	ubcount = *ubcountp; /* statstruct's */
+	ubleft = ubcount * statstruct_size; /* bytes */
+	*ubcountp = ubelem = 0;
 	*done = 0;
 	fmterror = 0;
 	ubufp = ubuffer;
@@ -317,7 +330,7 @@ xfs_bulkstat(
 	 * inode returned; 0 means start of the allocation group.
 	 */
 	rval = 0;
-	while (ubleft > 0 && agno < mp->m_sb.sb_agcount) {
+	while ((ubleft/statstruct_size) > 0 && agno < mp->m_sb.sb_agcount) {
 		bp = NULL;
 		down_read(&mp->m_peraglock);
 		error = xfs_ialloc_read_agi(mp, tp, agno, &agbp);
@@ -402,7 +415,7 @@ xfs_bulkstat(
 		 * Loop through inode btree records in this ag,
 		 * until we run out of inodes or space in the buffer.
 		 */
-		while (irbp < irbufend && icount < ubcount) {
+		while (irbp < irbufend && icount < (ubleft/statstruct_size)) {
 			/*
 			 * Loop as long as we're unable to read the
 			 * inode btree.
@@ -453,7 +466,8 @@ xfs_bulkstat(
 		 * Now format all the good inodes into the user's buffer.
 		 */
 		irbufend = irbp;
-		for (irbp = irbuf; irbp < irbufend && ubleft > 0; irbp++) {
+		for (irbp = irbuf;
+		     irbp < irbufend && (ubleft/statstruct_size) > 0; irbp++) {
 			/*
 			 * Read-ahead the next chunk's worth of inodes.
 			 */
@@ -561,14 +575,19 @@ xfs_bulkstat(
 				 * Get the inode and fill in a single buffer.
 				 * BULKSTAT_FG_QUICK uses dip to fill it in.
 				 * BULKSTAT_FG_IGET uses igets.
-				 * See: xfs_bulkstat_one & dm_bulkstat_one.
+				 * See: xfs_bulkstat_one & xfs_dm_bulkstat_one.
 				 * This is also used to count inodes/blks, etc
 				 * in xfs_qm_quotacheck.
 				 */
-				error = formatter(mp, tp, ino, ubufp, bno, dip,
-					&fmterror);
-				if (fmterror == BULKSTAT_RV_NOTHING)
+				ubused = statstruct_size;
+				error = formatter(mp, tp, ino, ubufp,
+						ubleft, private_data,
+						bno, &ubused, dip, &fmterror);
+				if (fmterror == BULKSTAT_RV_NOTHING) {
+					if (error == ENOMEM)
+						ubleft = 0;
 					continue;
+				}
 				if (fmterror == BULKSTAT_RV_GIVEUP) {
 					ubleft = 0;
 					ASSERT(error);
@@ -576,8 +595,9 @@ xfs_bulkstat(
 					break;
 				}
 				if (ubufp)
-					ubufp += statstruct_size;
-				ubleft--;
+					ubufp += ubused;
+				ubleft -= ubused;
+				ubelem++;
 				lastino = ino;
 			}
 		}
@@ -605,7 +625,7 @@ xfs_bulkstat(
 	if (ubuffer)
 		unuseracc(ubuffer, ubcount * statstruct_size, (B_READ|B_PHYS));
 #endif
-	*ubcountp = ubcount - ubleft;
+	*ubcountp = ubelem;
 	if (agno >= mp->m_sb.sb_agcount) {
 		/*
 		 * If we ran out of filesystem, mark lastino as off
@@ -647,7 +667,8 @@ xfs_bulkstat_single(
 	 */
 
 	ino = (xfs_ino_t)*lastinop;
-	error = xfs_bulkstat_one(mp, NULL, ino, &bstat, 0, 0, &res);
+	error = xfs_bulkstat_one(mp, NULL, ino, &bstat, sizeof(bstat),
+				 NULL, 0, NULL, NULL, &res);
 	if (error) {
 		/*
 		 * Special case way failed, do it the "long" way
@@ -656,6 +677,7 @@ xfs_bulkstat_single(
 		(*lastinop)--;
 		count = 1;
 		if (xfs_bulkstat(mp, NULL, lastinop, &count, xfs_bulkstat_one,
+				NULL,
 				sizeof(bstat), buffer, BULKSTAT_FG_IGET, done))
 			return error;
 		if (count == 0 || (xfs_ino_t)*lastinop != ino)
diff -puN fs/xfs/xfs_itable.h~linus fs/xfs/xfs_itable.h
--- 25/fs/xfs/xfs_itable.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_itable.h	2004-01-19 22:17:24.000000000 -0800
@@ -36,15 +36,19 @@
  * xfs_bulkstat() is used to fill in xfs_bstat structures as well as dm_stat
  * structures (by the dmi library). This is a pointer to a formatter function
  * that will iget the inode and fill in the appropriate structure.
- * see xfs_bulkstat_one() and dm_bulkstat_one() in dmi_xfs.c
+ * see xfs_bulkstat_one() and xfs_dm_bulkstat_one() in dmapi_xfs.c
  */
 typedef int (*bulkstat_one_pf)(struct xfs_mount	*mp,
 			       struct xfs_trans	*tp,
 			       xfs_ino_t	ino,
 			       void		*buffer,
+			       int		ubsize,
+			       void		*private_data,
 			       xfs_daddr_t	bno,
+			       int		*ubused,
 			       void		*dip,
 			       int		*stat);
+
 /*
  * Values for stat return value.
  */
@@ -69,6 +73,7 @@ xfs_bulkstat(
 	xfs_ino_t	*lastino,	/* last inode returned */
 	int		*count,		/* size of buffer/count returned */
 	bulkstat_one_pf formatter,	/* func that'd fill a single buf */
+	void		*private_data,	/* private data for formatter */
 	size_t		statstruct_size,/* sizeof struct that we're filling */
 	xfs_caddr_t	ubuffer,	/* buffer with inode stats */
 	int		flags,		/* flag to control access method */
@@ -87,7 +92,10 @@ xfs_bulkstat_one(
 	xfs_trans_t		*tp,
 	xfs_ino_t		ino,
 	void			*buffer,
+	int			ubsize,
+	void			*private_data,
 	xfs_daddr_t		bno,
+	int			*ubused,
 	void			*dibuff,
 	int			*stat);
 
diff -puN fs/xfs/xfs_log.c~linus fs/xfs/xfs_log.c
--- 25/fs/xfs/xfs_log.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_log.c	2004-01-19 22:17:24.000000000 -0800
@@ -159,11 +159,15 @@ xfs_buftarg_t *xlog_target;
 #endif
 
 #if defined(XFS_LOG_TRACE)
+
 void
 xlog_trace_loggrant(xlog_t *log, xlog_ticket_t *tic, xfs_caddr_t string)
 {
-	if (! log->l_grant_trace)
-		log->l_grant_trace = ktrace_alloc(1024, KM_SLEEP);
+	if (! log->l_grant_trace) {
+		log->l_grant_trace = ktrace_alloc(1024, KM_NOSLEEP);
+		if (! log->l_grant_trace)
+			return;
+	}
 
 	ktrace_enter(log->l_grant_trace,
 		     (void *)tic,
@@ -185,31 +189,6 @@ xlog_trace_loggrant(xlog_t *log, xlog_ti
 }
 
 void
-xlog_trace_tic(xlog_t *log, xlog_ticket_t *tic)
-{
-	if (! log->l_trace)
-		log->l_trace = ktrace_alloc(256, KM_SLEEP);
-
-	ktrace_enter(log->l_trace,
-		     (void *)tic,
-		     (void *)((unsigned long)tic->t_curr_res),
-		     (void *)((unsigned long)tic->t_unit_res),
-		     (void *)((unsigned long)tic->t_ocnt),
-		     (void *)((unsigned long)tic->t_cnt),
-		     (void *)((unsigned long)tic->t_flags),
-		     (void *)((unsigned long)7),
-		     (void *)((unsigned long)8),
-		     (void *)((unsigned long)9),
-		     (void *)((unsigned long)10),
-		     (void *)((unsigned long)11),
-		     (void *)((unsigned long)12),
-		     (void *)((unsigned long)13),
-		     (void *)((unsigned long)14),
-		     (void *)((unsigned long)15),
-		     (void *)((unsigned long)16));
-}
-
-void
 xlog_trace_iclog(xlog_in_core_t *iclog, uint state)
 {
 	pid_t pid;
@@ -1044,7 +1023,6 @@ xlog_bdstrat_cb(struct xfs_buf *bp)
  *
  * If the filesystem blocksize is too large, we may need to choose a
  * larger size since the directory code currently logs entire blocks.
- * XXXmiken XXXcurtis
  */
 
 STATIC void
@@ -1059,7 +1037,7 @@ xlog_get_iclog_buffer_size(xfs_mount_t	*
 	 * When logbufs == 0, someone has disabled the log from the FSTAB
 	 * file.  This is not a documented feature.  We need to set xlog_debug
 	 * to zero (this deactivates the log) and set xlog_target to the
-	 * appropriate dev_t.  Only one filesystem may be affected as such
+	 * appropriate device.  Only one filesystem may be affected as such
 	 * since this is just a performance hack to test what we might be able
 	 * to get if the log were not present.
 	 */
@@ -1078,7 +1056,7 @@ xlog_get_iclog_buffer_size(xfs_mount_t	*
 			if (xfs_physmem <= btoc(128*1024*1024)) { 
 				log->l_iclog_bufs = XLOG_MIN_ICLOGS; 
 			} else if (xfs_physmem <= btoc(400*1024*1024)) { 
-				log->l_iclog_bufs = XLOG_MED_ICLOGS;; 
+				log->l_iclog_bufs = XLOG_MED_ICLOGS; 
 			} else {
 				/* 256K with 32K bufs */
 				log->l_iclog_bufs = XLOG_MAX_ICLOGS;
@@ -1087,9 +1065,9 @@ xlog_get_iclog_buffer_size(xfs_mount_t	*
 			log->l_iclog_bufs = mp->m_logbufs;
 
 #if defined(DEBUG) || defined(XLOG_NOLOG)
-		/* We are reactivating a filesystem after it was active */
+		/* We are reactivating a filesystem after it was inactive */
 		if (log->l_targ == xlog_target) {
-			xlog_target = 1; /* XXX(hch): WTF? */
+			xlog_target = NULL;
 			xlog_debug = 1;
 		}
 #endif
@@ -1578,7 +1556,7 @@ xlog_unalloc_log(xlog_t *log)
 		sv_destroy(&iclog->ic_forcesema);
 		sv_destroy(&iclog->ic_writesema);
 		xfs_buf_free(iclog->ic_bp);
-#ifdef DEBUG
+#ifdef XFS_LOG_TRACE
 		if (iclog->ic_trace != NULL) {
 			ktrace_free(iclog->ic_trace);
 		}
@@ -1609,7 +1587,7 @@ xlog_unalloc_log(xlog_t *log)
 		}
 	}
 	xfs_buf_free(log->l_xbuf);
-#ifdef DEBUG
+#ifdef XFS_LOG_TRACE
 	if (log->l_trace != NULL) {
 		ktrace_free(log->l_trace);
 	}
diff -puN fs/xfs/xfs_log.h~linus fs/xfs/xfs_log.h
--- 25/fs/xfs/xfs_log.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_log.h	2004-01-19 22:17:24.000000000 -0800
@@ -53,8 +53,8 @@
  * endian issues in treating two 32 bit numbers as one 64 bit number
  */
 static
-#if defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 95)
-__attribute__((unused))	/* gcc 2.95 miscompiles this when inlined */
+#if defined(__GNUC__) && (__GNUC__ == 2) && ( (__GNUC_MINOR__ == 95) || (__GNUC_MINOR__ == 96))
+__attribute__((unused))	/* gcc 2.95, 2.96 miscompile this when inlined */
 #else
 __inline__
 #endif
diff -puN fs/xfs/xfs_log_priv.h~linus fs/xfs/xfs_log_priv.h
--- 25/fs/xfs/xfs_log_priv.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_log_priv.h	2004-01-19 22:17:24.000000000 -0800
@@ -32,14 +32,6 @@
 #ifndef	__XFS_LOG_PRIV_H__
 #define __XFS_LOG_PRIV_H__
 
-#if defined(XFS_ALL_TRACE)
-#define	XFS_LOG_TRACE
-#endif
-
-#if !defined(DEBUG)
-#undef XFS_LOG_TRACE
-#endif
-
 struct xfs_buf;
 struct ktrace;
 struct log;
@@ -109,6 +101,7 @@ int xlog_btolrbb(int b);
 
 
 #ifdef __KERNEL__
+
 /*
  * get client id from packed copy.
  *
@@ -434,7 +427,7 @@ typedef struct xlog_iclog_fields {
 	struct log		*ic_log;
 	xfs_log_callback_t	*ic_callback;
 	xfs_log_callback_t	**ic_callback_tail;
-#ifdef DEBUG
+#ifdef XFS_LOG_TRACE
 	struct ktrace		*ic_trace;
 #endif
 	int			ic_size;
@@ -531,7 +524,7 @@ typedef struct log {
 	int			l_grant_write_bytes;
 
 	/* The following fields don't need locking */
-#ifdef DEBUG
+#ifdef XFS_LOG_TRACE
 	struct ktrace		*l_trace;
 	struct ktrace		*l_grant_trace;
 #endif
diff -puN fs/xfs/xfs_mount.c~linus fs/xfs/xfs_mount.c
--- 25/fs/xfs/xfs_mount.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_mount.c	2004-01-19 22:17:24.000000000 -0800
@@ -903,7 +903,7 @@ xfs_mountfs(
 	 *  File systems that don't support user level file handles (i.e.
 	 *  all of them except for XFS) will leave vfs_altfsid as NULL.
 	 */
-	vfsp->vfs_altfsid = (fsid_t *)mp->m_fixedfsid;
+	vfsp->vfs_altfsid = (xfs_fsid_t *)mp->m_fixedfsid;
 	mp->m_dmevmask = 0;	/* not persistent; set after each mount */
 
 	/*
diff -puN fs/xfs/xfs_qmops.c~linus fs/xfs/xfs_qmops.c
--- 25/fs/xfs/xfs_qmops.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_qmops.c	2004-01-19 22:17:24.000000000 -0800
@@ -44,7 +44,6 @@
 #include "xfs_mount.h"
 
 
-#ifndef CONFIG_XFS_QUOTA
 STATIC struct xfs_dquot *
 xfs_dqvopchown_default(
 	struct xfs_trans	*tp,
@@ -70,4 +69,3 @@ xfs_qmops_t	xfs_qmcore_xfs = {
 	.xfs_dqvopchown		= xfs_dqvopchown_default,
 	.xfs_dqvopchownresv	= (xfs_dqvopchownresv_t) fs_noerr,
 };
-#endif /* CONFIG_XFS_QUOTA */
diff -puN /dev/null fs/xfs/xfs_refcache.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/fs/xfs/xfs_refcache.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement
+ * or the like.  Any license provided herein, whether implied or
+ * otherwise, applies only to this software file.  Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
+ * Mountain View, CA  94043, or:
+ *
+ * http://www.sgi.com
+ *
+ * For further information regarding this notice, see:
+ *
+ * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+ */
+#ifndef __XFS_REFCACHE_H__
+#define __XFS_REFCACHE_H__
+
+#ifdef HAVE_REFCACHE
+/*
+ * Maximum size (in inodes) for the NFS reference cache
+ */
+#define XFS_REFCACHE_SIZE_MAX	512
+
+struct xfs_inode;
+struct xfs_mount;
+
+extern void xfs_refcache_insert(struct xfs_inode *);
+extern void xfs_refcache_purge_ip(struct xfs_inode *);
+extern void xfs_refcache_purge_mp(struct xfs_mount *);
+extern void xfs_refcache_purge_some(struct xfs_mount *);
+extern void xfs_refcache_resize(int);
+extern void xfs_refcache_destroy(void);
+
+extern void xfs_refcache_iunlock(struct xfs_inode *, uint);
+
+#else
+
+#define xfs_refcache_insert(ip)		do { } while (0)
+#define xfs_refcache_purge_ip(ip)	do { } while (0)
+#define xfs_refcache_purge_mp(mp)	do { } while (0)
+#define xfs_refcache_purge_some(mp)	do { } while (0)
+#define xfs_refcache_resize(size)	do { } while (0)
+#define xfs_refcache_destroy()		do { } while (0)
+
+#define xfs_refcache_iunlock(ip, flags)	xfs_iunlock(ip, flags)
+
+#endif
+
+#endif	/* __XFS_REFCACHE_H__ */
diff -puN fs/xfs/xfs_rename.c~linus fs/xfs/xfs_rename.c
--- 25/fs/xfs/xfs_rename.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_rename.c	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -51,7 +51,7 @@
 #include "xfs_bmap.h"
 #include "xfs_error.h"
 #include "xfs_quota.h"
-#include "xfs_rw.h"
+#include "xfs_refcache.h"
 #include "xfs_utils.h"
 #include "xfs_trans_space.h"
 #include "xfs_da_btree.h"
@@ -343,8 +343,7 @@ xfs_rename(
 	src_is_directory = ((src_ip->i_d.di_mode & S_IFMT) == S_IFDIR);
 
 	/*
-	 * Drop the locks on our inodes so that we can do the ancestor
-	 * check if necessary and start the transaction.
+	 * Drop the locks on our inodes so that we can start the transaction.
 	 */
 	xfs_rename_unlock4(inodes, XFS_ILOCK_SHARED);
 
@@ -486,7 +485,7 @@ xfs_rename(
 		error = xfs_droplink(tp, target_ip);
 		if (error) {
 			rename_which_error_return = __LINE__;
-			goto abort_return;;
+			goto abort_return;
 		}
 		target_ip_dropped = 1;
 
@@ -627,6 +626,7 @@ xfs_rename(
 	 */
 	error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL);
 	if (target_ip != NULL) {
+		xfs_refcache_purge_ip(target_ip);
 		IRELE(target_ip);
 	}
 	/*
diff -puN fs/xfs/xfs_rw.c~linus fs/xfs/xfs_rw.c
--- 25/fs/xfs/xfs_rw.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_rw.c	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -149,6 +149,9 @@ xfs_do_force_shutdown(
 		xfs_cmn_err(XFS_PTAG_SHUTDOWN_CORRUPT, CE_ALERT, mp,
     "Corruption of in-memory data detected.  Shutting down filesystem: %s",
 			mp->m_fsname);
+		if (XFS_ERRLEVEL_HIGH <= xfs_error_level) {
+			xfs_stack_trace();
+		}
 	} else if (!(flags & XFS_FORCE_UMOUNT)) {
 		if (logerror) {
 			xfs_cmn_err(XFS_PTAG_SHUTDOWN_LOGERROR, CE_ALERT, mp,
@@ -351,54 +354,3 @@ xfs_bwrite(
 	}
 	return (error);
 }
-
-/*
- * xfs_inval_cached_pages()
- * This routine is responsible for keeping direct I/O and buffered I/O
- * somewhat coherent.  From here we make sure that we're at least
- * temporarily holding the inode I/O lock exclusively and then call
- * the page cache to flush and invalidate any cached pages.  If there
- * are no cached pages this routine will be very quick.
- */
-void
-xfs_inval_cached_pages(
-	vnode_t		*vp,
-	xfs_iocore_t	*io,
-	xfs_off_t	offset,
-	int		write,
-	int		relock)
-{
-	xfs_mount_t	*mp;
-
-	if (!VN_CACHED(vp)) {
-		return;
-	}
-
-	mp = io->io_mount;
-
-	/*
-	 * We need to get the I/O lock exclusively in order
-	 * to safely invalidate pages and mappings.
-	 */
-	if (relock) {
-		XFS_IUNLOCK(mp, io, XFS_IOLOCK_SHARED);
-		XFS_ILOCK(mp, io, XFS_IOLOCK_EXCL);
-	}
-
-	/* Writing beyond EOF creates a hole that must be zeroed */
-	if (write && (offset > XFS_SIZE(mp, io))) {
-		xfs_fsize_t	isize;
-
-		XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
-		isize = XFS_SIZE(mp, io);
-		if (offset > isize) {
-			xfs_zero_eof(vp, io, offset, isize, offset);
-		}
-		XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
-	}
-
-	VOP_FLUSHINVAL_PAGES(vp, ctooff(offtoct(offset)), -1, FI_REMAPF_LOCKED);
-	if (relock) {
-		XFS_ILOCK_DEMOTE(mp, io, XFS_IOLOCK_EXCL);
-	}
-}
diff -puN fs/xfs/xfs_rw.h~linus fs/xfs/xfs_rw.h
--- 25/fs/xfs/xfs_rw.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_rw.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -32,16 +32,9 @@
 #ifndef	__XFS_RW_H__
 #define	__XFS_RW_H__
 
-struct bhv_desc;
-struct bmapval;
 struct xfs_buf;
-struct cred;
-struct uio;
-struct vnode;
 struct xfs_inode;
-struct xfs_iocore;
 struct xfs_mount;
-struct xfs_trans;
 
 /*
  * Maximum count of bmaps used by read and write paths.
@@ -91,44 +84,6 @@ xfs_daddr_t xfs_fsb_to_db(struct xfs_ino
 		 XFS_FSB_TO_DADDR((io)->io_mount, (fsb)))
 
 /*
- * Defines for the trace mechanisms in xfs_rw.c.
- */
-#define	XFS_RW_KTRACE_SIZE	64
-#define	XFS_STRAT_KTRACE_SIZE	64
-#define	XFS_STRAT_GTRACE_SIZE	512
-
-#define	XFS_READ_ENTER		1
-#define	XFS_WRITE_ENTER		2
-#define XFS_IOMAP_READ_ENTER	3
-#define	XFS_IOMAP_WRITE_ENTER	4
-#define	XFS_IOMAP_READ_MAP	5
-#define	XFS_IOMAP_WRITE_MAP	6
-#define	XFS_IOMAP_WRITE_NOSPACE	7
-#define	XFS_ITRUNC_START	8
-#define	XFS_ITRUNC_FINISH1	9
-#define	XFS_ITRUNC_FINISH2	10
-#define	XFS_CTRUNC1		11
-#define	XFS_CTRUNC2		12
-#define	XFS_CTRUNC3		13
-#define	XFS_CTRUNC4		14
-#define	XFS_CTRUNC5		15
-#define	XFS_CTRUNC6		16
-#define	XFS_BUNMAPI		17
-#define	XFS_INVAL_CACHED	18
-#define	XFS_DIORD_ENTER		19
-#define	XFS_DIOWR_ENTER		20
-
-#if defined(XFS_ALL_TRACE)
-#define	XFS_RW_TRACE
-#define	XFS_STRAT_TRACE
-#endif
-
-#if !defined(DEBUG)
-#undef XFS_RW_TRACE
-#undef XFS_STRAT_TRACE
-#endif
-
-/*
  * Prototypes for functions in xfs_rw.c.
  */
 
@@ -141,14 +96,6 @@ xfs_bwrite(
 	struct xfs_mount	*mp,
 	struct xfs_buf		*bp);
 
-void
-xfs_inval_cached_pages(
-	struct vnode		*vp,
-	struct xfs_iocore	*io,
-	xfs_off_t		offset,
-	int			write,
-	int			relock);
-
 int
 xfs_bioerror(
 	struct xfs_buf		*b);
diff -puN fs/xfs/xfs_trans.c~linus fs/xfs/xfs_trans.c
--- 25/fs/xfs/xfs_trans.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_trans.c	2004-01-19 22:17:24.000000000 -0800
@@ -142,9 +142,9 @@ _xfs_trans_alloc(
 	uint		type)
 {
 	xfs_trans_t	*tp;
+
 	ASSERT(xfs_trans_zone != NULL);
 	tp = kmem_zone_zalloc(xfs_trans_zone, KM_SLEEP);
-	tp->t_dqinfo = NULL;
 
 	/*
 	 * Initialize the transaction structure.
diff -puN fs/xfs/xfs_vfsops.c~linus fs/xfs/xfs_vfsops.c
--- 25/fs/xfs/xfs_vfsops.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_vfsops.c	2004-01-19 22:17:24.000000000 -0800
@@ -60,6 +60,7 @@
 #include "xfs_bmap.h"
 #include "xfs_da_btree.h"
 #include "xfs_rw.h"
+#include "xfs_refcache.h"
 #include "xfs_buf_item.h"
 #include "xfs_extfree_item.h"
 #include "xfs_quota.h"
@@ -74,24 +75,11 @@ STATIC int xfs_sync(bhv_desc_t *, int, c
 int
 xfs_init(void)
 {
-	extern kmem_zone_t	*xfs_da_state_zone;
 	extern kmem_zone_t	*xfs_bmap_free_item_zone;
 	extern kmem_zone_t	*xfs_btree_cur_zone;
-	extern kmem_zone_t	*xfs_inode_zone;
-	extern kmem_zone_t	*xfs_chashlist_zone;
 	extern kmem_zone_t	*xfs_trans_zone;
 	extern kmem_zone_t	*xfs_buf_item_zone;
-	extern kmem_zone_t	*xfs_efd_zone;
-	extern kmem_zone_t	*xfs_efi_zone;
 	extern kmem_zone_t	*xfs_dabuf_zone;
-#ifdef DEBUG_NOT
-	extern ktrace_t	        *xfs_alloc_trace_buf;
-	extern ktrace_t	        *xfs_bmap_trace_buf;
-	extern ktrace_t	        *xfs_bmbt_trace_buf;
-	extern ktrace_t	        *xfs_dir_trace_buf;
-	extern ktrace_t	        *xfs_attr_trace_buf;
-	extern ktrace_t	        *xfs_dir2_trace_buf;
-#endif	/* DEBUG */
 #ifdef XFS_DABUF_DEBUG
 	extern lock_t	        xfs_dabuf_global_lock;
 	spinlock_init(&xfs_dabuf_global_lock, "xfsda");
@@ -132,14 +120,6 @@ xfs_init(void)
 					    "xfs_chashlist");
 	_ACL_ZONE_INIT(xfs_acl_zone, "xfs_acl");
 
-#ifdef CONFIG_XFS_VNODE_TRACING
-	ktrace_init(VNODE_TRACE_SIZE);
-#else
-#ifdef DEBUG
-	ktrace_init(64);
-#endif
-#endif
-
 	/*
 	 * Allocate global trace buffers.
 	 */
@@ -189,6 +169,7 @@ xfs_cleanup(void)
 
 	xfs_cleanup_procfs();
 	xfs_sysctl_unregister();
+	xfs_refcache_destroy();
 
 	kmem_cache_destroy(xfs_bmap_free_item_zone);
 	kmem_cache_destroy(xfs_btree_cur_zone);
@@ -203,9 +184,6 @@ xfs_cleanup(void)
 	kmem_cache_destroy(xfs_ili_zone);
 	kmem_cache_destroy(xfs_chashlist_zone);
 	_ACL_ZONE_DESTROY(xfs_acl_zone);
-#if  (defined(DEBUG) || defined(CONFIG_XFS_VNODE_TRACING))
-	ktrace_uninit();
-#endif
 }
 
 /*
@@ -547,6 +525,12 @@ xfs_unmount(
 					0 : DM_FLAGS_UNWANTED;
 	}
 
+	/*
+	 * First blow any referenced inode from this file system
+	 * out of the reference cache, and delete the timer.
+	 */
+	xfs_refcache_purge_mp(mp);
+
 	XFS_bflush(mp->m_ddev_targp);
 	error = xfs_unmount_flush(mp, 0);
 	if (error)
@@ -617,6 +601,7 @@ xfs_mntupdate(
 	}
 
 	if (*flags & MS_RDONLY) {
+		xfs_refcache_purge_mp(mp);
 		pagebuf_delwri_flush(mp->m_ddev_targp, 0, NULL);
 		xfs_finish_reclaim_all(mp, 0);
 
@@ -758,7 +743,7 @@ xfs_root(
 STATIC int
 xfs_statvfs(
 	bhv_desc_t	*bdp,
-	struct kstatfs	*statp,
+	xfs_statfs_t	*statp,
 	vnode_t		*vp)
 {
 	__uint64_t	fakeinos;
@@ -1489,8 +1474,18 @@ xfs_syncsub(
 	}
 
 	/*
+	 * If this is the periodic sync, then kick some entries out of
+	 * the reference cache.  This ensures that idle entries are
+	 * eventually kicked out of the cache.
+	 */
+	if (flags & SYNC_REFCACHE) {
+		xfs_refcache_purge_some(mp);
+	}
+
+	/*
 	 * Now check to see if the log needs a "dummy" transaction.
 	 */
+
 	if (!(flags & SYNC_REMOUNT) && xfs_log_need_covered(mp)) {
 		xfs_trans_t *tp;
 		xfs_inode_t *ip;
@@ -1789,10 +1784,14 @@ xfs_showargs(
 		char	*str;
 	} xfs_info[] = {
 		/* the few simple ones we can get from the mount struct */
+		{ XFS_MOUNT_WSYNC,		"," MNTOPT_WSYNC },
+		{ XFS_MOUNT_INO64,		"," MNTOPT_INO64 },
 		{ XFS_MOUNT_NOALIGN,		"," MNTOPT_NOALIGN },
+		{ XFS_MOUNT_NOUUID,		"," MNTOPT_NOUUID },
 		{ XFS_MOUNT_NORECOVERY,		"," MNTOPT_NORECOVERY },
 		{ XFS_MOUNT_OSYNCISOSYNC,	"," MNTOPT_OSYNCISOSYNC },
-		{ XFS_MOUNT_NOUUID,		"," MNTOPT_NOUUID },
+		{ XFS_MOUNT_NOLOGFLUSH,		"," MNTOPT_NOLOGFLUSH },
+		{ XFS_MOUNT_IDELETE,		"," MNTOPT_NOIKEEP },
 		{ 0, NULL }
 	};
 	struct proc_xfs_info	*xfs_infop;
@@ -1828,6 +1827,9 @@ xfs_showargs(
 		seq_printf(m, "," MNTOPT_SWIDTH "=%d",
 				(int)XFS_FSB_TO_BB(mp, mp->m_swidth));
 
+	if (!(mp->m_flags & XFS_MOUNT_32BITINOOPT))
+		seq_printf(m, "," MNTOPT_64BITINODE);
+	
 	return 0;
 }
 
diff -puN fs/xfs/xfs_vnodeops.c~linus fs/xfs/xfs_vnodeops.c
--- 25/fs/xfs/xfs_vnodeops.c~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/fs/xfs/xfs_vnodeops.c	2004-01-19 22:17:24.000000000 -0800
@@ -59,6 +59,7 @@
 #include "xfs_da_btree.h"
 #include "xfs_attr.h"
 #include "xfs_rw.h"
+#include "xfs_refcache.h"
 #include "xfs_error.h"
 #include "xfs_bit.h"
 #include "xfs_rtalloc.h"
@@ -77,10 +78,6 @@
  */
 #define SYMLINK_MAPS 2
 
-extern int xfs_ioctl(bhv_desc_t *, struct inode *, struct file *,
-			int, unsigned int, unsigned long);
-
-
 /*
  * For xfs, we check that the file isn't too big to be opened by this kernel.
  * No other open action is required for regular files.  Devices are handled
@@ -434,7 +431,7 @@ xfs_setattr(
 	}
 
 	/* boolean: are we the file owner? */
-	file_owner = (current->fsuid == ip->i_d.di_uid);
+	file_owner = (current_fsuid(credp) == ip->i_d.di_uid);
 
 	/*
 	 * Change various properties of a file.
@@ -1660,6 +1657,12 @@ xfs_release(
 	if (vp->v_vfsp->vfs_flag & VFS_RDONLY)
 		return 0;
 
+#ifdef HAVE_REFCACHE
+	/* If we are in the NFS reference cache then don't do this now */
+	if (ip->i_refcache)
+		return 0;
+#endif
+
 	mp = ip->i_mount;
 
 	if (ip->i_d.di_nlink != 0) {
@@ -2004,7 +2007,8 @@ xfs_create(
 	/*
 	 * Make sure that we have allocated dquot(s) on disk.
 	 */
-	error = XFS_QM_DQVOPALLOC(mp, dp, current->fsuid, current->fsgid,
+	error = XFS_QM_DQVOPALLOC(mp, dp,
+			current_fsuid(credp), current_fsgid(credp),
 			XFS_QMOPT_QUOTALL|XFS_QMOPT_INHERIT, &udqp, &gdqp);
 	if (error)
 		goto std_return;
@@ -2613,6 +2617,14 @@ xfs_remove(
 		goto std_return;
 	}
 
+	/*
+	 * Before we drop our extra reference to the inode, purge it
+	 * from the refcache if it is there.  By waiting until afterwards
+	 * to do the IRELE, we ensure that we won't go inactive in the
+	 * xfs_refcache_purge_ip routine (although that would be OK).
+	 */
+	xfs_refcache_purge_ip(ip);
+
 	vn_trace_exit(XFS_ITOV(ip), __FUNCTION__, (inst_t *)__return_address);
 
 	/*
@@ -2652,6 +2664,14 @@ xfs_remove(
 	cancel_flags |= XFS_TRANS_ABORT;
 	xfs_trans_cancel(tp, cancel_flags);
 
+	/*
+	 * Before we drop our extra reference to the inode, purge it
+	 * from the refcache if it is there.  By waiting until afterwards
+	 * to do the IRELE, we ensure that we won't go inactive in the
+	 * xfs_refcache_purge_ip routine (although that would be OK).
+	 */
+	xfs_refcache_purge_ip(ip);
+
 	IRELE(ip);
 
 	goto std_return;
@@ -2899,7 +2919,8 @@ xfs_mkdir(
 	/*
 	 * Make sure that we have allocated dquot(s) on disk.
 	 */
-	error = XFS_QM_DQVOPALLOC(mp, dp, current->fsuid, current->fsgid,
+	error = XFS_QM_DQVOPALLOC(mp, dp,
+			current_fsuid(credp), current_fsgid(credp),
 			XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp);
 	if (error)
 		goto std_return;
@@ -3456,7 +3477,8 @@ xfs_symlink(
 	/*
 	 * Make sure that we have allocated dquot(s) on disk.
 	 */
-	error = XFS_QM_DQVOPALLOC(mp, dp, current->fsuid, current->fsgid,
+	error = XFS_QM_DQVOPALLOC(mp, dp,
+			current_fsuid(credp), current_fsgid(credp),
 			XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp);
 	if (error)
 		goto std_return;
@@ -3743,7 +3765,14 @@ xfs_rwunlock(
 		return;
 	ip = XFS_BHVTOI(bdp);
 	if (locktype == VRWLOCK_WRITE) {
-		xfs_iunlock (ip, XFS_IOLOCK_EXCL);
+		/*
+		 * In the write case, we may have added a new entry to
+		 * the reference cache.  This might store a pointer to
+		 * an inode to be released in this inode.  If it is there,
+		 * clear the pointer and release the inode after unlocking
+		 * this one.
+		 */
+		xfs_refcache_iunlock(ip, XFS_IOLOCK_EXCL);
 	} else {
 		ASSERT((locktype == VRWLOCK_READ) ||
 		       (locktype == VRWLOCK_WRITE_DIRECT));
@@ -4738,7 +4767,9 @@ vnodeops_t xfs_vnodeops = {
 	BHV_IDENTITY_INIT(VN_BHV_XFS,VNODE_POSITION_XFS),
 	.vop_open		= xfs_open,
 	.vop_read		= xfs_read,
+#ifdef HAVE_SENDFILE
 	.vop_sendfile		= xfs_sendfile,
+#endif
 	.vop_write		= xfs_write,
 	.vop_ioctl		= xfs_ioctl,
 	.vop_getattr		= xfs_getattr,
diff -puN include/asm-alpha/processor.h~linus include/asm-alpha/processor.h
--- 25/include/asm-alpha/processor.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-alpha/processor.h	2004-01-19 22:17:24.000000000 -0800
@@ -78,6 +78,11 @@ unsigned long get_wchan(struct task_stru
 #define ARCH_HAS_PREFETCHW
 #define ARCH_HAS_SPINLOCK_PREFETCH
 
+#ifndef CONFIG_SMP
+/* Nothing to prefetch. */
+#define spin_lock_prefetch(lock)  	do { } while (0)
+#endif
+
 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
 extern inline void prefetch(const void *ptr)  
 { 
@@ -89,10 +94,13 @@ extern inline void prefetchw(const void 
 	__builtin_prefetch(ptr, 1, 3);
 }
 
+#ifdef CONFIG_SMP
 extern inline void spin_lock_prefetch(const void *ptr)  
 {
 	__builtin_prefetch(ptr, 1, 3);
 }
+#endif
+
 #else
 extern inline void prefetch(const void *ptr)  
 { 
@@ -104,10 +112,13 @@ extern inline void prefetchw(const void 
 	__asm__ ("ldq $31,%0" : : "m"(*(char *)ptr)); 
 }
 
+#ifdef CONFIG_SMP
 extern inline void spin_lock_prefetch(const void *ptr)  
 {
 	__asm__ ("ldq $31,%0" : : "m"(*(char *)ptr)); 
 }
+#endif
+
 #endif /* GCC 3.1 */
 
 #endif /* __ASM_ALPHA_PROCESSOR_H */
diff -puN include/asm-alpha/smp.h~linus include/asm-alpha/smp.h
--- 25/include/asm-alpha/smp.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-alpha/smp.h	2004-01-19 22:17:24.000000000 -0800
@@ -48,8 +48,8 @@ extern struct cpuinfo_alpha cpu_data[NR_
 extern cpumask_t cpu_present_mask;
 extern cpumask_t cpu_online_map;
 extern int smp_num_cpus;
+#define cpu_possible_map	cpu_present_mask
 
-#define cpu_possible(cpu)	cpu_isset(cpu, cpu_present_mask)
 #define cpu_online(cpu)		cpu_isset(cpu, cpu_online_map)
 
 extern int smp_call_function_on_cpu(void (*func) (void *info), void *info,int retry, int wait, unsigned long cpu);
diff -puN include/asm-alpha/socket.h~linus include/asm-alpha/socket.h
--- 25/include/asm-alpha/socket.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-alpha/socket.h	2004-01-19 22:17:24.000000000 -0800
@@ -48,6 +48,8 @@
 #define SO_TIMESTAMP		29
 #define SCM_TIMESTAMP		SO_TIMESTAMP
 
+#define SO_PEERSEC		30
+
 /* Security levels - as per NRL IPv6 - don't actually do anything */
 #define SO_SECURITY_AUTHENTICATION		19
 #define SO_SECURITY_ENCRYPTION_TRANSPORT	20
diff -puN include/asm-alpha/topology.h~linus include/asm-alpha/topology.h
--- 25/include/asm-alpha/topology.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-alpha/topology.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,8 +16,7 @@ static inline int cpu_to_node(int cpu)
 	node = alpha_mv.cpuid_to_nid(cpu);
 
 #ifdef DEBUG_NUMA
-	if (node < 0)
-		BUG();
+	BUG_ON(node < 0);
 #endif
 
 	return node;
diff -puN include/asm-arm26/socket.h~linus include/asm-arm26/socket.h
--- 25/include/asm-arm26/socket.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-arm26/socket.h	2004-01-19 22:17:24.000000000 -0800
@@ -45,6 +45,8 @@
 
 #define SO_ACCEPTCONN		30
 
+#define SO_PEERSEC		31
+
 /* Nast libc5 fixup - bletch */
 #if defined(__KERNEL__)
 /* Socket types. */
diff -puN include/asm-arm/arch-ebsa285/io.h~linus include/asm-arm/arch-ebsa285/io.h
--- 25/include/asm-arm/arch-ebsa285/io.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-arm/arch-ebsa285/io.h	2004-01-19 22:17:24.000000000 -0800
@@ -27,15 +27,13 @@
 
 static inline unsigned long ___mem_pci(unsigned long a)
 {
-	if (a <= 0xc0000000 || a >= 0xe0000000)
-		BUG();
+	BUG_ON(a <= 0xc0000000 || a >= 0xe0000000);
 	return a;
 }
 
 static inline unsigned long ___mem_isa(unsigned long a)
 {
-	if (a >= 16*1048576)
-		BUG();
+	BUG_ON(a >= 16*1048576);
 	return PCIMEM_BASE + a;
 }
 #define __mem_pci(a)		___mem_pci((unsigned long)(a))
diff -puN include/asm-arm/arch-nexuspci/io.h~linus include/asm-arm/arch-nexuspci/io.h
--- 25/include/asm-arm/arch-nexuspci/io.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-arm/arch-nexuspci/io.h	2004-01-19 22:17:24.000000000 -0800
@@ -28,8 +28,7 @@ static inline unsigned long ___mem_pci(u
 
 static inline unsigned long ___mem_isa(unsigned long a)
 {
-	if (a >= 16*1048576)
-		BUG();
+	BUG_ON(a >= 16*1048576);
 	return PCIMEM_BASE + a;
 }
 #define __mem_pci(a)		___mem_pci((unsigned long)(a))
diff -puN include/asm-arm/socket.h~linus include/asm-arm/socket.h
--- 25/include/asm-arm/socket.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-arm/socket.h	2004-01-19 22:17:24.000000000 -0800
@@ -45,6 +45,8 @@
 
 #define SO_ACCEPTCONN		30
 
+#define SO_PEERSEC		31
+
 /* Nast libc5 fixup - bletch */
 #if defined(__KERNEL__)
 /* Socket types. */
diff -puN include/asm-cris/arch-v10/byteorder.h~linus include/asm-cris/arch-v10/byteorder.h
--- 25/include/asm-cris/arch-v10/byteorder.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-cris/arch-v10/byteorder.h	2004-01-19 22:17:24.000000000 -0800
@@ -2,20 +2,21 @@
 #define _CRIS_ARCH_BYTEORDER_H
 
 #include <asm/types.h>
+#include <linux/compiler.h>
 
 /* we just define these two (as we can do the swap in a single
  * asm instruction in CRIS) and the arch-independent files will put
  * them together into ntohl etc.
  */
 
-extern __inline__ __const__ __u32 ___arch__swab32(__u32 x)
+extern __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
 {
 	__asm__ ("swapwb %0" : "=r" (x) : "0" (x));
   
 	return(x);
 }
 
-extern __inline__ __const__ __u16 ___arch__swab16(__u16 x)
+extern __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 x)
 {
 	__asm__ ("swapb %0" : "=r" (x) : "0" (x));
 	
diff -puN include/asm-cris/socket.h~linus include/asm-cris/socket.h
--- 25/include/asm-cris/socket.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-cris/socket.h	2004-01-19 22:17:24.000000000 -0800
@@ -47,6 +47,8 @@
 
 #define SO_ACCEPTCONN          30
 
+#define SO_PEERSEC             31
+
 #if defined(__KERNEL__)
 /* Socket types. */
 #define SOCK_STREAM     1               /* stream (connection) socket   */
diff -puN include/asm-generic/percpu.h~linus include/asm-generic/percpu.h
--- 25/include/asm-generic/percpu.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-generic/percpu.h	2004-01-19 22:17:24.000000000 -0800
@@ -29,7 +29,7 @@ do {								\
 #define DEFINE_PER_CPU(type, name) \
     __typeof__(type) per_cpu__##name
 
-#define per_cpu(var, cpu)			((void)cpu, per_cpu__##var)
+#define per_cpu(var, cpu)			(*((void)cpu, &per_cpu__##var))
 #define __get_cpu_var(var)			per_cpu__##var
 
 #endif	/* SMP */
diff -puN include/asm-generic/pgtable.h~linus include/asm-generic/pgtable.h
--- 25/include/asm-generic/pgtable.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-generic/pgtable.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,6 +1,23 @@
 #ifndef _ASM_GENERIC_PGTABLE_H
 #define _ASM_GENERIC_PGTABLE_H
 
+#ifndef __HAVE_ARCH_PTEP_ESTABLISH
+/*
+ * Establish a new mapping:
+ *  - flush the old one
+ *  - update the page tables
+ *  - inform the TLB about the new one
+ *
+ * We hold the mm semaphore for reading and vma->vm_mm->page_table_lock
+ */
+#define ptep_establish(__vma, __address, __ptep, __entry)		\
+do {									\
+	set_pte(__ptep, __entry);					\
+	flush_tlb_page(__vma, __address);				\
+} while (0)
+#endif
+
+#ifndef __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
 static inline int ptep_test_and_clear_young(pte_t *ptep)
 {
 	pte_t pte = *ptep;
@@ -9,7 +26,19 @@ static inline int ptep_test_and_clear_yo
 	set_pte(ptep, pte_mkold(pte));
 	return 1;
 }
+#endif
+
+#ifndef __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
+#define ptep_clear_flush_young(__vma, __address, __ptep)		\
+({									\
+	int __young = ptep_test_and_clear_young(__ptep);		\
+	if (__young)							\
+		flush_tlb_page(__vma, __address);			\
+	__young;							\
+})
+#endif
 
+#ifndef __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
 static inline int ptep_test_and_clear_dirty(pte_t *ptep)
 {
 	pte_t pte = *ptep;
@@ -18,26 +47,62 @@ static inline int ptep_test_and_clear_di
 	set_pte(ptep, pte_mkclean(pte));
 	return 1;
 }
+#endif
+
+#ifndef __HAVE_ARCH_PTEP_CLEAR_DIRTY_FLUSH
+#define ptep_clear_flush_dirty(__vma, __address, __ptep)		\
+({									\
+	int __dirty = ptep_test_and_clear_dirty(__ptep);		\
+	if (__dirty)							\
+		flush_tlb_page(__vma, __address);			\
+	__dirty;							\
+})
+#endif
 
+#ifndef __HAVE_ARCH_PTEP_GET_AND_CLEAR
 static inline pte_t ptep_get_and_clear(pte_t *ptep)
 {
 	pte_t pte = *ptep;
 	pte_clear(ptep);
 	return pte;
 }
+#endif
 
+#ifndef __HAVE_ARCH_PTEP_CLEAR_FLUSH
+#define ptep_clear_flush(__vma, __address, __ptep)			\
+({									\
+	pte_t __pte = ptep_get_and_clear(__ptep);			\
+	flush_tlb_page(__vma, __address);				\
+	__pte;								\
+})
+#endif
+
+#ifndef __HAVE_ARCH_PTEP_SET_WRPROTECT
 static inline void ptep_set_wrprotect(pte_t *ptep)
 {
 	pte_t old_pte = *ptep;
 	set_pte(ptep, pte_wrprotect(old_pte));
 }
+#endif
 
+#ifndef __HAVE_ARCH_PTEP_MKDIRTY
 static inline void ptep_mkdirty(pte_t *ptep)
 {
 	pte_t old_pte = *ptep;
 	set_pte(ptep, pte_mkdirty(old_pte));
 }
+#endif
 
+#ifndef __HAVE_ARCH_PTE_SAME
 #define pte_same(A,B)	(pte_val(A) == pte_val(B))
+#endif
+
+#ifndef __HAVE_ARCH_PAGE_TEST_AND_CLEAR_DIRTY
+#define page_test_and_clear_dirty(page) (0)
+#endif
+
+#ifndef __HAVE_ARCH_PAGE_TEST_AND_CLEAR_YOUNG
+#define page_test_and_clear_young(page) (0)
+#endif
 
 #endif /* _ASM_GENERIC_PGTABLE_H */
diff -puN include/asm-h8300/socket.h~linus include/asm-h8300/socket.h
--- 25/include/asm-h8300/socket.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-h8300/socket.h	2004-01-19 22:17:24.000000000 -0800
@@ -45,6 +45,8 @@
 
 #define SO_ACCEPTCONN		30
 
+#define SO_PEERSEC		31
+
 /* Nast libc5 fixup - bletch */
 #if defined(__KERNEL__)
 /* Socket types. */
diff -puN include/asm-i386/byteorder.h~linus include/asm-i386/byteorder.h
--- 25/include/asm-i386/byteorder.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-i386/byteorder.h	2004-01-19 22:17:24.000000000 -0800
@@ -2,6 +2,7 @@
 #define _I386_BYTEORDER_H
 
 #include <asm/types.h>
+#include <linux/compiler.h>
 
 #ifdef __GNUC__
 
@@ -10,7 +11,7 @@
 #include <linux/config.h>
 #endif
 
-static __inline__ __const__ __u32 ___arch__swab32(__u32 x)
+static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
 {
 #ifdef CONFIG_X86_BSWAP
 	__asm__("bswap %0" : "=r" (x) : "0" (x));
@@ -24,18 +25,7 @@ static __inline__ __const__ __u32 ___arc
 	return x;
 }
 
-/* gcc should generate this for open coded C now too. May be worth switching to 
-   it because inline assembly cannot be scheduled. -AK */
-static __inline__ __const__ __u16 ___arch__swab16(__u16 x)
-{
-	__asm__("xchgb %b0,%h0"		/* swap bytes		*/
-		: "=q" (x)
-		:  "0" (x));
-		return x;
-}
-
-
-static inline __u64 ___arch__swab64(__u64 val) 
+static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 val)
 { 
 	union { 
 		struct { __u32 a,b; } s;
@@ -54,9 +44,11 @@ static inline __u64 ___arch__swab64(__u6
 	return v.u;	
 } 
 
+/* Do not define swab16.  Gcc is smart enough to recognize "C" version and
+   convert it into rotation or exhange.  */
+
 #define __arch__swab64(x) ___arch__swab64(x)
 #define __arch__swab32(x) ___arch__swab32(x)
-#define __arch__swab16(x) ___arch__swab16(x)
 
 #define __BYTEORDER_HAS_U64__
 
diff -puN include/asm-i386/genapic.h~linus include/asm-i386/genapic.h
--- 25/include/asm-i386/genapic.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-i386/genapic.h	2004-01-19 22:17:24.000000000 -0800
@@ -45,6 +45,7 @@ struct genapic { 
 	void (*setup_portio_remap)(void); 
 	int (*check_phys_apicid_present)(int boot_cpu_physical_apicid);
 	void (*enable_apic_mode)(void);
+	u32 (*phys_pkg_id)(u32 cpuid_apic, int index_msb);
 
 	/* mpparse */
 	void (*mpc_oem_bus_info)(struct mpc_config_bus *, char *, 
@@ -105,6 +106,7 @@ struct genapic { 
 	APICFUNC(send_IPI_allbutself), \
 	APICFUNC(send_IPI_all), \
 	APICFUNC(enable_apic_mode), \
+	APICFUNC(phys_pkg_id), \
 	}
 
 extern struct genapic *genapic;
diff -puN include/asm-i386/hpet.h~linus include/asm-i386/hpet.h
--- 25/include/asm-i386/hpet.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-i386/hpet.h	2004-01-19 22:17:24.000000000 -0800
@@ -54,14 +54,10 @@
 #define HPET_T2_CMP	0x148
 #define HPET_T2_ROUTE	0x150
 
-#define HPET_ID_VENDOR	0xffff0000
 #define HPET_ID_LEGSUP	0x00008000
 #define HPET_ID_NUMBER	0x00001f00
 #define HPET_ID_REV	0x000000ff
 
-#define HPET_ID_VENDOR_SHIFT	16
-#define HPET_ID_VENDOR_8086	0x8086
-
 #define HPET_CFG_ENABLE	0x001
 #define HPET_CFG_LEGACY	0x002
 
diff -puN include/asm-i386/mach-bigsmp/mach_apic.h~linus include/asm-i386/mach-bigsmp/mach_apic.h
--- 25/include/asm-i386/mach-bigsmp/mach_apic.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-i386/mach-bigsmp/mach_apic.h	2004-01-19 22:17:24.000000000 -0800
@@ -173,4 +173,9 @@ static inline unsigned int cpu_mask_to_a
 	return apicid;
 }
 
+static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
+{
+	return cpuid_apic >> index_msb;
+}
+
 #endif /* __ASM_MACH_APIC_H */
diff -puN include/asm-i386/mach-default/mach_apic.h~linus include/asm-i386/mach-default/mach_apic.h
--- 25/include/asm-i386/mach-default/mach_apic.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-i386/mach-default/mach_apic.h	2004-01-19 22:17:24.000000000 -0800
@@ -127,4 +127,9 @@ static inline void enable_apic_mode(void
 {
 }
 
+static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
+{
+	return cpuid_apic >> index_msb;
+}
+
 #endif /* __ASM_MACH_APIC_H */
diff -puN include/asm-i386/mach-es7000/mach_apic.h~linus include/asm-i386/mach-es7000/mach_apic.h
--- 25/include/asm-i386/mach-es7000/mach_apic.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-i386/mach-es7000/mach_apic.h	2004-01-19 22:17:24.000000000 -0800
@@ -192,4 +192,9 @@ static inline unsigned int cpu_mask_to_a
 	return apicid;
 }
 
+static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
+{
+	return cpuid_apic >> index_msb;
+}
+
 #endif /* __ASM_MACH_APIC_H */
diff -puN include/asm-i386/mach-generic/mach_apic.h~linus include/asm-i386/mach-generic/mach_apic.h
--- 25/include/asm-i386/mach-generic/mach_apic.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-i386/mach-generic/mach_apic.h	2004-01-19 22:17:24.000000000 -0800
@@ -27,5 +27,6 @@
 #define check_apicid_used (genapic->check_apicid_used)
 #define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid)
 #define enable_apic_mode (genapic->enable_apic_mode)
+#define phys_pkg_id (genapic->phys_pkg_id)
 
 #endif /* __ASM_MACH_APIC_H */
diff -puN include/asm-i386/mach-numaq/mach_apic.h~linus include/asm-i386/mach-numaq/mach_apic.h
--- 25/include/asm-i386/mach-numaq/mach_apic.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-i386/mach-numaq/mach_apic.h	2004-01-19 22:17:24.000000000 -0800
@@ -141,4 +141,10 @@ static inline unsigned int cpu_mask_to_a
 	return (int) 0xF;
 }
 
+/* No NUMA-Q box has a HT CPU, but it can't hurt to use the default code. */
+static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
+{
+	return cpuid_apic >> index_msb;
+}
+
 #endif /* __ASM_MACH_APIC_H */
diff -puN include/asm-i386/mach-summit/mach_apic.h~linus include/asm-i386/mach-summit/mach_apic.h
--- 25/include/asm-i386/mach-summit/mach_apic.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-i386/mach-summit/mach_apic.h	2004-01-19 22:17:24.000000000 -0800
@@ -173,4 +173,15 @@ static inline unsigned int cpu_mask_to_a
 	return apicid;
 }
 
+/* cpuid returns the value latched in the HW at reset, not the APIC ID
+ * register's value.  For any box whose BIOS changes APIC IDs, like
+ * clustered APIC systems, we must use hard_smp_processor_id.
+ *
+ * See Intel's IA-32 SW Dev's Manual Vol2 under CPUID.
+ */
+static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
+{
+	return hard_smp_processor_id() >> index_msb;
+}
+
 #endif /* __ASM_MACH_APIC_H */
diff -puN include/asm-i386/mach-visws/mach_apic.h~linus include/asm-i386/mach-visws/mach_apic.h
--- 25/include/asm-i386/mach-visws/mach_apic.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-i386/mach-visws/mach_apic.h	2004-01-19 22:17:24.000000000 -0800
@@ -88,4 +88,10 @@ static inline unsigned int cpu_mask_to_a
 {
 	return cpus_coerce_const(cpumask);
 }
+
+static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
+{
+	return cpuid_apic >> index_msb;
+}
+
 #endif /* __ASM_MACH_APIC_H */
diff -puN include/asm-i386/pgtable.h~linus include/asm-i386/pgtable.h
--- 25/include/asm-i386/pgtable.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-i386/pgtable.h	2004-01-19 22:17:24.000000000 -0800
@@ -341,4 +341,12 @@ typedef pte_t *pte_addr_t;
 
 #define io_remap_page_range remap_page_range
 
+#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
+#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
+#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
+#define __HAVE_ARCH_PTEP_SET_WRPROTECT
+#define __HAVE_ARCH_PTEP_MKDIRTY
+#define __HAVE_ARCH_PTE_SAME
+#include <asm-generic/pgtable.h>
+
 #endif /* _I386_PGTABLE_H */
diff -puN include/asm-i386/smp.h~linus include/asm-i386/smp.h
--- 25/include/asm-i386/smp.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-i386/smp.h	2004-01-19 22:17:24.000000000 -0800
@@ -53,8 +53,7 @@ extern void zap_low_mappings (void);
 #define smp_processor_id() (current_thread_info()->cpu)
 
 extern cpumask_t cpu_callout_map;
-
-#define cpu_possible(cpu) cpu_isset(cpu, cpu_callout_map)
+#define cpu_possible_map cpu_callout_map
 
 /* We don't mark CPUs online until __cpu_up(), so we need another measure */
 static inline int num_booting_cpus(void)
diff -puN include/asm-i386/socket.h~linus include/asm-i386/socket.h
--- 25/include/asm-i386/socket.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-i386/socket.h	2004-01-19 22:17:24.000000000 -0800
@@ -45,6 +45,8 @@
 
 #define SO_ACCEPTCONN		30
 
+#define SO_PEERSEC		31
+
 /* Nasty libc5 fixup - bletch */
 #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
 /* Socket types. */
diff -puN include/asm-ia64/acpi.h~linus include/asm-ia64/acpi.h
--- 25/include/asm-ia64/acpi.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/acpi.h	2004-01-19 22:17:24.000000000 -0800
@@ -30,6 +30,8 @@
 
 #ifdef __KERNEL__
 
+#include <linux/init.h>
+#include <linux/numa.h>
 #include <asm/system.h>
 
 #define COMPILER_DEPENDENT_INT64	long
@@ -92,7 +94,6 @@ int acpi_register_irq (u32 gsi, u32 pola
 int acpi_irq_to_vector (u32 irq);
 
 #ifdef CONFIG_ACPI_NUMA
-#include <asm/numa.h>
 /* Proximity bitmap length; _PXM is at most 255 (8 bit)*/
 #define MAX_PXM_DOMAINS (256)
 extern int __initdata pxm_to_nid_map[MAX_PXM_DOMAINS];
diff -puN include/asm-ia64/asmmacro.h~linus include/asm-ia64/asmmacro.h
--- 25/include/asm-ia64/asmmacro.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/asmmacro.h	2004-01-19 22:17:24.000000000 -0800
@@ -2,7 +2,7 @@
 #define _ASM_IA64_ASMMACRO_H
 
 /*
- * Copyright (C) 2000-2001, 2003 Hewlett-Packard Co
+ * Copyright (C) 2000-2001, 2003-2004 Hewlett-Packard Co
  *	David Mosberger-Tang <davidm@hpl.hp.com>
  */
 
@@ -89,4 +89,15 @@ name:
 # define FSYS_RETURN	br.ret.sptk.many b6
 #endif
 
+/*
+ * Up until early 2004, use of .align within a function caused bad unwind info.
+ * TEXT_ALIGN(n) expands into ".align n" if a fixed GAS is available or into nothing
+ * otherwise.
+ */
+#ifdef HAVE_WORKING_TEXT_ALIGN
+# define TEXT_ALIGN(n)	.align n
+#else
+# define TEXT_ALIGN(n)
+#endif
+
 #endif /* _ASM_IA64_ASMMACRO_H */
diff -puN include/asm-ia64/byteorder.h~linus include/asm-ia64/byteorder.h
--- 25/include/asm-ia64/byteorder.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/byteorder.h	2004-01-19 22:17:24.000000000 -0800
@@ -8,8 +8,9 @@
 
 #include <asm/types.h>
 #include <asm/intrinsics.h>
+#include <linux/compiler.h>
 
-static __inline__ __const__ __u64
+static __inline__ __attribute_const__ __u64
 __ia64_swab64 (__u64 x)
 {
 	__u64 result;
@@ -18,13 +19,13 @@ __ia64_swab64 (__u64 x)
 	return result;
 }
 
-static __inline__ __const__ __u32
+static __inline__ __attribute_const__ __u32
 __ia64_swab32 (__u32 x)
 {
 	return __ia64_swab64(x) >> 32;
 }
 
-static __inline__ __const__ __u16
+static __inline__ __attribute_const__ __u16
 __ia64_swab16(__u16 x)
 {
 	return __ia64_swab64(x) >> 48;
diff -puN include/asm-ia64/mmzone.h~linus include/asm-ia64/mmzone.h
--- 25/include/asm-ia64/mmzone.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/mmzone.h	2004-01-19 22:17:24.000000000 -0800
@@ -33,5 +33,7 @@ extern unsigned long max_low_pfn;
 #define page_to_pfn(page)	((unsigned long) (page - vmem_map))
 #define pfn_to_page(pfn)	(vmem_map + (pfn))
 
+#else /* CONFIG_DISCONTIGMEM */
+# define NR_MEMBLKS		1
 #endif /* CONFIG_DISCONTIGMEM */
 #endif /* _ASM_IA64_MMZONE_H */
diff -puN include/asm-ia64/numa.h~linus include/asm-ia64/numa.h
--- 25/include/asm-ia64/numa.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/numa.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,7 +16,6 @@
 #ifdef CONFIG_NUMA
 
 #include <linux/cache.h>
-#include <linux/cache.h>
 #include <linux/cpumask.h>
 #include <linux/numa.h>
 #include <linux/smp.h>
diff -puN include/asm-ia64/page.h~linus include/asm-ia64/page.h
--- 25/include/asm-ia64/page.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/page.h	2004-01-19 22:17:24.000000000 -0800
@@ -145,7 +145,7 @@ typedef union ia64_va {
 static __inline__ int
 get_order (unsigned long size)
 {
-	double d = size - 1;
+	long double d = size - 1;
 	long order;
 
 	order = ia64_getf_exp(d);
diff -puN include/asm-ia64/pgtable.h~linus include/asm-ia64/pgtable.h
--- 25/include/asm-ia64/pgtable.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/pgtable.h	2004-01-19 22:17:24.000000000 -0800
@@ -511,4 +511,12 @@ extern void update_mmu_cache (struct vm_
 #define FIXADDR_USER_START	GATE_ADDR
 #define FIXADDR_USER_END	(GATE_ADDR + 2*PERCPU_PAGE_SIZE)
 
+#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
+#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
+#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
+#define __HAVE_ARCH_PTEP_SET_WRPROTECT
+#define __HAVE_ARCH_PTEP_MKDIRTY
+#define __HAVE_ARCH_PTE_SAME
+#include <asm-generic/pgtable.h>
+
 #endif /* _ASM_IA64_PGTABLE_H */
diff -puN include/asm-ia64/smp.h~linus include/asm-ia64/smp.h
--- 25/include/asm-ia64/smp.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/smp.h	2004-01-19 22:17:24.000000000 -0800
@@ -48,7 +48,7 @@ extern volatile int ia64_cpu_to_sapicid[
 
 extern unsigned long ap_wakeup_vector;
 
-#define cpu_possible(cpu)	cpu_isset(cpu, phys_cpu_present_map)
+#define cpu_possible_map phys_cpu_present_map
 
 /*
  * Function to map hard smp processor id to logical id.  Slow, so don't use this in
diff -puN include/asm-ia64/sn/addrs.h~linus include/asm-ia64/sn/addrs.h
--- 25/include/asm-ia64/sn/addrs.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/addrs.h	2004-01-19 22:17:24.000000000 -0800
@@ -17,29 +17,15 @@
 #include <asm/sn/types.h>
 #endif 
 
-#ifndef __ASSEMBLY__
-
-#define PS_UINT_CAST		(__psunsigned_t)
-#define UINT64_CAST		(uint64_t)
 #define HUBREG_CAST		(volatile mmr_t *)
 
-#elif __ASSEMBLY__
-
-#define PS_UINT_CAST
-#define UINT64_CAST
-#define HUBREG_CAST
-
-#endif
-
-
-
 
 /*
  * The following macros are used to index to the beginning of a specific
  * node's address space.
  */
 
-#define NODE_OFFSET(_n)		(UINT64_CAST (_n) << NASID_SHFT)
+#define NODE_OFFSET(_n)		((uint64_t) (_n) << NASID_SHFT)
 
 #define NODE_CAC_BASE(_n)	(CAC_BASE  + NODE_OFFSET(_n))
 #define NODE_HSPEC_BASE(_n)	(HSPEC_BASE + NODE_OFFSET(_n))
@@ -55,7 +41,7 @@
 
 
 #define RAW_NODE_SWIN_BASE(nasid, widget)				\
-	(NODE_IO_BASE(nasid) + (UINT64_CAST (widget) << SWIN_SIZE_BITS))
+	(NODE_IO_BASE(nasid) + ((uint64_t) (widget) << SWIN_SIZE_BITS))
 
 #define WIDGETID_GET(addr)	((unsigned char)((addr >> SWIN_SIZE_BITS) & 0xff))
 
@@ -66,7 +52,7 @@
  */
 
 #define SWIN_SIZE_BITS		24
-#define SWIN_SIZE		(1UL<<24)
+#define SWIN_SIZE		(1UL << 24)
 #define	SWIN_SIZEMASK		(SWIN_SIZE - 1)
 #define	SWIN_WIDGET_MASK	0xF
 
diff -puN include/asm-ia64/sn/alenlist.h~linus include/asm-ia64/sn/alenlist.h
--- 25/include/asm-ia64/sn/alenlist.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/alenlist.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -puN include/asm-ia64/sn/arch.h~linus include/asm-ia64/sn/arch.h
--- 25/include/asm-ia64/sn/arch.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/arch.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -puN -L include/asm-ia64/sn/arc/hinv.h include/asm-ia64/sn/arc/hinv.h~linus /dev/null
--- 25/include/asm-ia64/sn/arc/hinv.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,183 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-/* $Id$
- *
- * ARCS hardware/memory inventory/configuration and system ID definitions.
- */
-#ifndef _ASM_SN_ARC_HINV_H
-#define _ASM_SN_ARC_HINV_H
-
-#include <asm/sn/arc/types.h>
-
-/* configuration query defines */
-typedef enum configclass {
-	SystemClass,
-	ProcessorClass,
-	CacheClass,
-#ifndef	_NT_PROM
-	MemoryClass,
-	AdapterClass,
-	ControllerClass,
-	PeripheralClass
-#else	/* _NT_PROM */
-	AdapterClass,
-	ControllerClass,
-	PeripheralClass,
-	MemoryClass
-#endif	/* _NT_PROM */
-} CONFIGCLASS;
-
-typedef enum configtype {
-	ARC,
-	CPU,
-	FPU,
-	PrimaryICache,
-	PrimaryDCache,
-	SecondaryICache,
-	SecondaryDCache,
-	SecondaryCache,
-#ifndef	_NT_PROM
-	Memory,
-#endif
-	EISAAdapter,
-	TCAdapter,
-	SCSIAdapter,
-	DTIAdapter,
-	MultiFunctionAdapter,
-	DiskController,
-	TapeController,
-	CDROMController,
-	WORMController,
-	SerialController,
-	NetworkController,
-	DisplayController,
-	ParallelController,
-	PointerController,
-	KeyboardController,
-	AudioController,
-	OtherController,
-	DiskPeripheral,
-	FloppyDiskPeripheral,
-	TapePeripheral,
-	ModemPeripheral,
-	MonitorPeripheral,
-	PrinterPeripheral,
-	PointerPeripheral,
-	KeyboardPeripheral,
-	TerminalPeripheral,
-	LinePeripheral,
-	NetworkPeripheral,
-#ifdef	_NT_PROM
-	Memory,
-#endif
-	OtherPeripheral,
-
-	/* new stuff for IP30 */
-	/* added without moving anything */
-	/* except ANONYMOUS. */
-
-	XTalkAdapter,
-	PCIAdapter,
-	GIOAdapter,
-	TPUAdapter,
-	TernaryCache,
-	Anonymous
-} CONFIGTYPE;
-
-typedef enum {
-	Failed = 1,
-	ReadOnly = 2,
-	Removable = 4,
-	ConsoleIn = 8,
-	ConsoleOut = 16,
-	Input = 32,
-	Output = 64
-} IDENTIFIERFLAG;
-
-#ifndef NULL			/* for GetChild(NULL); */
-#define	NULL	0
-#endif
-
-union key_u {
-	struct {
-#ifdef	_MIPSEB
-		unsigned char  c_bsize;		/* block size in lines */
-		unsigned char  c_lsize;		/* line size in bytes/tag */
-		unsigned short c_size;		/* cache size in 4K pages */
-#else	/* _MIPSEL */
-		unsigned short c_size;		/* cache size in 4K pages */
-		unsigned char  c_lsize;		/* line size in bytes/tag */
-		unsigned char  c_bsize;		/* block size in lines */
-#endif	/* _MIPSEL */
-	} cache;
-	ULONG FullKey;
-};
-
-#if _MIPS_SIM == _ABI64
-#define SGI_ARCS_VERS	64			/* sgi 64-bit version */
-#define SGI_ARCS_REV	0			/* rev .00 */
-#else
-#define SGI_ARCS_VERS	1			/* first version */
-#define SGI_ARCS_REV	10			/* rev .10, 3/04/92 */
-#endif
-
-typedef struct component {
-	CONFIGCLASS	Class;
-	CONFIGTYPE	Type;
-	IDENTIFIERFLAG	Flags;
-	USHORT		Version;
-	USHORT		Revision;
-	ULONG 		Key;
-	ULONG		AffinityMask;
-	ULONG		ConfigurationDataSize;
-	ULONG		IdentifierLength;
-	char		*Identifier;
-} COMPONENT;
-
-/* internal structure that holds pathname parsing data */
-struct cfgdata {
-	char *name;			/* full name */
-	int minlen;			/* minimum length to match */
-	CONFIGTYPE type;		/* type of token */
-};
-
-/* System ID */
-typedef struct systemid {
-	CHAR VendorId[8];
-	CHAR ProductId[8];
-} SYSTEMID;
-
-/* memory query functions */
-typedef enum memorytype {
-	ExceptionBlock,
-	SPBPage,			/* ARCS == SystemParameterBlock */
-#ifndef	_NT_PROM
-	FreeContiguous,
-	FreeMemory,
-	BadMemory,
-	LoadedProgram,
-	FirmwareTemporary,
-	FirmwarePermanent
-#else	/* _NT_PROM */
-	FreeMemory,
-	BadMemory,
-	LoadedProgram,
-	FirmwareTemporary,
-	FirmwarePermanent,
-	FreeContiguous
-#endif	/* _NT_PROM */
-} MEMORYTYPE;
-
-typedef struct memorydescriptor {
-	MEMORYTYPE	Type;
-	LONG		BasePage;
-	LONG		PageCount;
-} MEMORYDESCRIPTOR;
-
-#endif /* _ASM_SN_ARC_HINV_H */
diff -puN -L include/asm-ia64/sn/arc/types.h include/asm-ia64/sn/arc/types.h~linus /dev/null
--- 25/include/asm-ia64/sn/arc/types.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,41 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (c) 1999,2001-2003 Silicon Graphics, Inc.  All Rights Reserved.
- * Copyright 1999 Ralf Baechle (ralf@gnu.org)
- */
-#ifndef _ASM_SN_ARC_TYPES_H
-#define _ASM_SN_ARC_TYPES_H
-
-typedef char		CHAR;
-typedef short		SHORT;
-typedef long		LARGE_INTEGER __attribute__ ((__mode__ (__DI__)));
-typedef	long		LONG __attribute__ ((__mode__ (__DI__)));
-typedef unsigned char	UCHAR;
-typedef unsigned short	USHORT;
-typedef unsigned long	ULONG __attribute__ ((__mode__ (__DI__)));
-typedef void		VOID;
-
-/* The pointer types.  We're 64-bit and the firmware is also 64-bit, so
-   live is sane ...  */
-typedef CHAR		*_PCHAR;
-typedef SHORT		*_PSHORT;
-typedef LARGE_INTEGER	*_PLARGE_INTEGER;
-typedef	LONG		*_PLONG;
-typedef UCHAR		*_PUCHAR;
-typedef USHORT		*_PUSHORT;
-typedef ULONG		*_PULONG;
-typedef VOID		*_PVOID;
-
-typedef CHAR		*PCHAR;
-typedef SHORT		*PSHORT;
-typedef LARGE_INTEGER	*PLARGE_INTEGER;
-typedef	LONG		*PLONG;
-typedef UCHAR		*PUCHAR;
-typedef USHORT		*PUSHORT;
-typedef ULONG		*PULONG;
-typedef VOID		*PVOID;
-
-#endif /* _ASM_SN_ARC_TYPES_H */
diff -puN include/asm-ia64/sn/bte.h~linus include/asm-ia64/sn/bte.h
--- 25/include/asm-ia64/sn/bte.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/bte.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,35 +1,9 @@
 /*
- *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
  *
  * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
- * 
- * This program is free software; you can redistribute it and/or modify it 
- * under the terms of version 2 of the GNU General Public License 
- * as published by the Free Software Foundation.
- * 
- * This program is distributed in the hope that it would be useful, but 
- * WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * 
- * Further, this software is distributed without any warranty that it is 
- * free of the rightful claim of any third person regarding infringement 
- * or the like.  Any license provided herein, whether implied or 
- * otherwise, applies only to this software file.  Patent licenses, if 
- * any, provided herein do not apply to combinations of this program with 
- * other software, or any other product whatsoever.
- * 
- * You should have received a copy of the GNU General Public 
- * License along with this program; if not, write the Free Software 
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- * 
- * Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 
- * Mountain View, CA  94043, or:
- * 
- * http://www.sgi.com 
- * 
- * For further information regarding this notice, see: 
- * 
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan
  */
 
 
@@ -107,16 +81,25 @@
 
 
 /* Possible results from bte_copy and bte_unaligned_copy */
+/* The following error codes map into the BTE hardware codes
+ * IIO_ICRB_ECODE_* (in shubio.h). The hardware uses
+ * an error code of 0 (IIO_ICRB_ECODE_DERR), but we want zero
+ * to mean BTE_SUCCESS, so add one (BTEFAIL_OFFSET) to the error
+ * codes to give the following error codes.
+ */
+#define BTEFAIL_OFFSET	1
+
 typedef enum {
 	BTE_SUCCESS,		/* 0 is success */
+	BTEFAIL_DIR,		/* Directory error due to IIO access*/
+	BTEFAIL_POISON,		/* poison error on IO access (write to poison page) */
+	BTEFAIL_WERR,		/* Write error (ie WINV to a Read only line) */
+	BTEFAIL_ACCESS,		/* access error (protection violation) */
+	BTEFAIL_PWERR,		/* Partial Write Error */
+	BTEFAIL_PRERR,		/* Partial Read Error */
+	BTEFAIL_TOUT,		/* CRB Time out */
+	BTEFAIL_XTERR,		/* Incoming xtalk pkt had error bit */
 	BTEFAIL_NOTAVAIL,	/* BTE not available */
-	BTEFAIL_POISON,		/* poison page */
-	BTEFAIL_PROT,		/* Protection violation */
-	BTEFAIL_ACCESS,		/* access error */
-	BTEFAIL_TOUT,		/* Time out */
-	BTEFAIL_XTERR,		/* Diretory error */
-	BTEFAIL_DIR,		/* Diretory error */
-	BTEFAIL_ERROR,		/* Generic error */
 } bte_result_t;
 
 
diff -puN include/asm-ia64/sn/cdl.h~linus include/asm-ia64/sn/cdl.h
--- 25/include/asm-ia64/sn/cdl.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/cdl.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -9,7 +8,9 @@
 #ifndef _ASM_IA64_SN_CDL_H
 #define _ASM_IA64_SN_CDL_H
 
+#ifdef __KERNEL__
 #include <asm/sn/sgi.h>
+#endif
 
 struct cdl {
 	int part_num;			/* Part part number */
diff -puN include/asm-ia64/sn/clksupport.h~linus include/asm-ia64/sn/clksupport.h
--- 25/include/asm-ia64/sn/clksupport.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/clksupport.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
 /*
- *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -31,9 +30,7 @@
 typedef long clkreg_t;
 
 extern unsigned long sn_rtc_cycles_per_second;
-extern unsigned long sn_rtc_usec_per_cyc;
 extern unsigned long sn_rtc_per_itc;
-extern unsigned long sn_rtc_delta;
 
 
 #include <asm/sn/addrs.h>
diff -puN include/asm-ia64/sn/dmamap.h~linus include/asm-ia64/sn/dmamap.h
--- 25/include/asm-ia64/sn/dmamap.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/dmamap.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -9,6 +8,8 @@
 #ifndef _ASM_IA64_SN_DMAMAP_H
 #define _ASM_IA64_SN_DMAMAP_H
 
+#include <asm/sn/types.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -39,31 +40,9 @@ typedef struct dmamap {
 	int		dma_index;	/* Beginning map register to use */
 	int		dma_size;	/* Number of map registers to use */
 	paddr_t		dma_addr;	/* Corresponding bus addr for A24/A32 */
-	caddr_t		dma_virtaddr;	/* Beginning virtual address that is mapped */
+	unsigned long	dma_virtaddr;	/* Beginning virtual address that is mapped */
 } dmamap_t;
 
-struct alenlist_s;
-
-/*
- * Prototypes of exported functions
- */
-extern dmamap_t	*dma_mapalloc(int, int, int, int);
-extern void	dma_mapfree(dmamap_t *);
-extern int	dma_map(dmamap_t *, caddr_t, int);
-extern int	dma_map2(dmamap_t *, caddr_t, caddr_t, int);
-extern paddr_t	dma_mapaddr(dmamap_t *, caddr_t);
-extern int	dma_map_alenlist(dmamap_t *, struct alenlist_s *, size_t);
-extern uint	ev_kvtoiopnum(caddr_t);
-
-/*
- * These variables are defined in master.d/kernel
- */
-extern struct map *a24map[];
-extern struct map *a32map[];
-
-extern int a24_mapsize;
-extern int a32_mapsize;
-
 #ifdef __cplusplus
 }
 #endif
diff -puN include/asm-ia64/sn/driver.h~linus include/asm-ia64/sn/driver.h
--- 25/include/asm-ia64/sn/driver.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/driver.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -puN include/asm-ia64/sn/geo.h~linus include/asm-ia64/sn/geo.h
--- 25/include/asm-ia64/sn/geo.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/geo.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -7,8 +6,8 @@
  * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
  */
 
-#ifndef __SYS_GEO_H__
-#define __SYS_GEO_H__
+#ifndef _ASM_IA64_SN_GEO_H
+#define _ASM_IA64_SN_GEO_H
 
 /* Include a platform-specific geo.h.  It must define at least:
  *   geoid_t:		Geographic identifier data type
@@ -43,4 +42,4 @@ extern void hwcfg_format_geoid_compt(cha
 extern geoid_t hwcfg_geo_get_self(geo_type_t type);
 extern geoid_t hwcfg_geo_get_by_nasid(geo_type_t type, nasid_t nasid);
 
-#endif /* __SYS_GEO_H__ */
+#endif /* _ASM_IA64_SN_GEO_H */
diff -puN include/asm-ia64/sn/hcl.h~linus include/asm-ia64/sn/hcl.h
--- 25/include/asm-ia64/sn/hcl.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/hcl.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -10,20 +9,22 @@
 #define _ASM_IA64_SN_HCL_H
 
 #include <asm/sn/sgi.h>
-#include <asm/sn/invent.h>
 
 extern vertex_hdl_t hwgraph_root;
 extern vertex_hdl_t linux_busnum;
 
+void hwgraph_debug(char *, char *, int, vertex_hdl_t, vertex_hdl_t, char *, ...);
+
+#if 1
+#define HWGRAPH_DEBUG(args) hwgraph_debug args ;
+#else   
+#define HWGRAPH_DEBUG(args)
+#endif  
 
 typedef long            labelcl_info_place_t;
 typedef long            arbitrary_info_t;
 typedef long            arb_info_desc_t;
 
-/* Support for INVENTORY */
-struct inventory_s;
-struct invplace_s;
-
 
 /* 
  * Reserve room in every vertex for 2 pieces of fast access indexed information 
@@ -51,7 +52,14 @@ struct invplace_s;
 #define HWGRAPH_EDGELBL_HW 	"hw"
 #define HWGRAPH_EDGELBL_DOT 	"."
 #define HWGRAPH_EDGELBL_DOTDOT 	".."
-#define graph_edge_place_t uint
+
+#include <asm/sn/labelcl.h>
+#define hwgraph_fastinfo_set(a,b) labelcl_info_replace_IDX(a, HWGRAPH_FASTINFO, b, NULL)
+#define hwgraph_connectpt_set labelcl_info_connectpt_set
+#define hwgraph_generate_path hwgfs_generate_path
+#define hwgraph_path_to_vertex(a) hwgfs_find_handle(NULL, a, 0, 0, 0, 1)
+#define hwgraph_edge_remove(a,b,c)
+#define hwgraph_vertex_unref(a)
 
 /*
  * External declarations of EXPORTED SYMBOLS in hcl.c
@@ -69,25 +77,16 @@ extern int hwgraph_edge_add(vertex_hdl_t
 extern int hwgraph_edge_get(vertex_hdl_t, char *, vertex_hdl_t *);
 
 extern arbitrary_info_t hwgraph_fastinfo_get(vertex_hdl_t);
-extern void hwgraph_fastinfo_set(vertex_hdl_t, arbitrary_info_t );
 extern vertex_hdl_t hwgraph_mk_dir(vertex_hdl_t, const char *, unsigned int, void *);
 
 extern int hwgraph_connectpt_set(vertex_hdl_t, vertex_hdl_t);
 extern vertex_hdl_t hwgraph_connectpt_get(vertex_hdl_t);
-extern int hwgraph_edge_get_next(vertex_hdl_t, char *, vertex_hdl_t *, uint *);
-extern graph_error_t hwgraph_edge_remove(vertex_hdl_t, char *, vertex_hdl_t *);
+extern int hwgraph_edge_get_next(vertex_hdl_t, char *, vertex_hdl_t *, unsigned int *);
 
 extern graph_error_t hwgraph_traverse(vertex_hdl_t, char *, vertex_hdl_t *);
 
 extern int hwgraph_vertex_get_next(vertex_hdl_t *, vertex_hdl_t *);
-extern int hwgraph_inventory_get_next(vertex_hdl_t, invplace_t *, 
-				      inventory_t **);
-extern int hwgraph_inventory_add(vertex_hdl_t, int, int, major_t, minor_t, int);
-extern int hwgraph_inventory_remove(vertex_hdl_t, int, int, major_t, minor_t, int);
-extern int hwgraph_controller_num_get(vertex_hdl_t);
-extern void hwgraph_controller_num_set(vertex_hdl_t, int);
-extern int hwgraph_path_ad(vertex_hdl_t, char *, vertex_hdl_t *);
-extern vertex_hdl_t hwgraph_path_to_vertex(char *);
+extern int hwgraph_path_add(vertex_hdl_t, char *, vertex_hdl_t *);
 extern vertex_hdl_t hwgraph_path_to_dev(char *);
 extern vertex_hdl_t hwgraph_block_device_get(vertex_hdl_t);
 extern vertex_hdl_t hwgraph_char_device_get(vertex_hdl_t);
@@ -103,9 +102,6 @@ extern int hwgraph_info_get_next_LBL(ver
 extern int hwgraph_info_export_LBL(vertex_hdl_t, char *, int);
 extern int hwgraph_info_unexport_LBL(vertex_hdl_t, char *);
 extern int hwgraph_info_remove_LBL(vertex_hdl_t, char *, arbitrary_info_t *);
-extern char * vertex_to_name(vertex_hdl_t, char *, uint);
-extern graph_error_t hwgraph_vertex_unref(vertex_hdl_t);
-
-extern int init_hcl(void);
+extern char *vertex_to_name(vertex_hdl_t, char *, unsigned int);
 
 #endif /* _ASM_IA64_SN_HCL_H */
diff -puN include/asm-ia64/sn/hcl_util.h~linus include/asm-ia64/sn/hcl_util.h
--- 25/include/asm-ia64/sn/hcl_util.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/hcl_util.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -10,7 +9,7 @@
 #ifndef _ASM_IA64_SN_HCL_UTIL_H
 #define _ASM_IA64_SN_HCL_UTIL_H
 
-extern char * dev_to_name(vertex_hdl_t, char *, uint);
+extern char * dev_to_name(vertex_hdl_t, char *, unsigned int);
 extern int device_master_set(vertex_hdl_t, vertex_hdl_t);
 extern vertex_hdl_t device_master_get(vertex_hdl_t);
 extern cnodeid_t master_node_get(vertex_hdl_t);
diff -puN include/asm-ia64/sn/hwgfs.h~linus include/asm-ia64/sn/hwgfs.h
--- 25/include/asm-ia64/sn/hwgfs.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/hwgfs.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,15 +1,13 @@
 #ifndef _ASM_IA64_SN_HWGFS_H
 #define _ASM_IA64_SN_HWGFS_H
 
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
  */
-
 typedef struct dentry *hwgfs_handle_t;
 
 extern hwgfs_handle_t hwgfs_register(hwgfs_handle_t dir, const char *name,
@@ -32,4 +30,4 @@ extern int hwgfs_generate_path(hwgfs_han
 extern void *hwgfs_get_info(hwgfs_handle_t de);
 extern int hwgfs_set_info(hwgfs_handle_t de, void *info);
 
-#endif
+#endif	/* _ASM_IA64_SN_HWGFS_H */
diff -puN include/asm-ia64/sn/intr.h~linus include/asm-ia64/sn/intr.h
--- 25/include/asm-ia64/sn/intr.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/intr.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -puN -L include/asm-ia64/sn/invent.h include/asm-ia64/sn/invent.h~linus /dev/null
--- 25/include/asm-ia64/sn/invent.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,733 +0,0 @@
-/* $Id$
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-#ifndef _ASM_IA64_SN_INVENT_H
-#define _ASM_IA64_SN_INVENT_H
-
-#include <linux/types.h>
-#include <asm/sn/sgi.h>
-/*
- * sys/sn/invent.h --  Kernel Hardware Inventory
- *
- * As the system boots, a list of recognized devices is assembled.
- * This list can then be accessed through syssgi() by user-level programs
- * so that they can learn about available peripherals and the system's
- * hardware configuration.
- *
- * The data is organized into a linked list of structures that are composed
- * of an inventory item class and a class-specific type.  Each instance may
- * also specify a 32-bit "state" which might be size, readiness, or
- * anything else that's relevant.
- *
- */
-
-#define major_t int
-#define minor_t int
-#define app32_ptr_t unsigned long
-#define graph_vertex_place_t long
-#define GRAPH_VERTEX_NONE ((vertex_hdl_t)-1)
-#define GRAPH_EDGE_PLACE_NONE ((graph_edge_place_t)0)
-#define GRAPH_INFO_PLACE_NONE ((graph_info_place_t)0)
-#define GRAPH_VERTEX_PLACE_NONE ((graph_vertex_place_t)0)
-
-
-typedef struct inventory_s {
-	struct	inventory_s *inv_next;	/* next inventory record in list */
-	int	inv_class;		/* class of object */
-	int	inv_type;		/* class sub-type of object */
-	major_t	inv_controller;		/* object major identifier */
-	minor_t	inv_unit;		/* object minor identifier */
-	int	inv_state;		/* information specific to object or
-					   class */
-} inventory_t;
-
-typedef struct cpu_inv_s {
-	int	cpuflavor;	/* differentiate processor */
-	int	cpufq;		/* cpu frequency */
-	int	sdsize;		/* secondary data cache size */
-	int	sdfreq;		/* speed of the secondary cache */
-} cpu_inv_t;
-
-
-typedef struct diag_inv_s{
-         char name[80];
-         int  diagval;
-         int  physid;
-         int  virtid;
-} diag_inv_t;
-
-
-typedef struct router_inv_s{
-  char portmap[80];             /* String indicating which ports int/ext */
-  char type[40];                /* String name: e.g. "star", "meta", etc. */
-  int  freq;                    /* From hub */
-  int  rev;                     /* From hub */
-} router_inv_t;
-
-
-/*
- * NOTE: This file is a central registry for inventory IDs for each
- *       class of inventory object.  It is important to keep the central copy
- *       of this file up-to-date with the work going on in various engineering
- *       projects.  When making changes to this file in an engineering project
- *       tree, please make those changes separately from any others and then
- *       merge the changes to this file into the main line trees in order to
- *       prevent other engineering projects from conflicting with your ID
- *       allocations.
- */
-
-
-/* Inventory Classes */
-/* when adding a new class, add also to classes[] in hinv.c */
-#define INV_PROCESSOR	1
-#define INV_DISK	2
-#define INV_MEMORY	3
-#define INV_SERIAL	4
-#define INV_PARALLEL	5
-#define INV_TAPE	6
-#define INV_GRAPHICS	7
-#define INV_NETWORK	8
-#define INV_SCSI	9	/* SCSI devices other than disk and tape */
-#define INV_AUDIO	10
-#define	INV_IOBD	11
-#define	INV_VIDEO	12
-#define	INV_BUS		13
-#define	INV_MISC	14	/* miscellaneous: a catchall */
-/*** add post-5.2 classes here for backward compatibility ***/
-#define	INV_COMPRESSION	15
-#define	INV_VSCSI	16	/* SCSI devices on jag other than disk and tape */
-#define	INV_DISPLAY     17
-#define	INV_UNC_SCSILUN	18	/* Unconnected SCSI lun */
-#define	INV_PCI		19	/* PCI Bus */
-#define	INV_PCI_NO_DRV	20	/* PCI Bus without any driver */
-#define	INV_PROM	21	/* Different proms in the system */
-#define INV_IEEE1394	22	/* IEEE1394 devices */
-#define INV_RPS		23      /* redundant power source */
-#define INV_TPU		24	/* Tensor Processing Unit */
-#define INV_FCNODE	25	/* Helper class for SCSI classes, not in classes[] */
-#define INV_USB		26	/* Universal Serial Bus */
-#define INV_1394NODE    27      /* helper class for 1394/SPB2 classes, not in classes[] */
-
-/* types for class processor */
-#define INV_CPUBOARD	1
-#define INV_CPUCHIP	2
-#define INV_FPUCHIP	3
-#define INV_CCSYNC	4	/* CC Rev 2+ sync join counter */
-
-/* states for cpu and fpu chips are revision numbers */
-
-/* cpuboard states */
-#define INV_IP20BOARD   10
-#define INV_IP19BOARD   11
-#define INV_IP22BOARD   12
-#define INV_IP21BOARD	13
-#define INV_IP26BOARD	14
-#define INV_IP25BOARD	15
-#define INV_IP30BOARD	16
-#define INV_IP28BOARD	17
-#define INV_IP32BOARD	18
-#define INV_IP27BOARD	19
-#define INV_IPMHSIMBOARD 20
-#define INV_IP33BOARD	21
-#define INV_IP35BOARD	22
-
-/* types for class INV_IOBD */
-#define INV_EVIO	2	/* EVEREST I/O board */
-#define INV_O200IO	3	/* Origin 200 base I/O */
-
-/* IO board types for origin2000  for class INV_IOBD*/
-
-#define INV_O2000BASEIO	0x21	
-#define INV_O2000MSCSI	0x22	
-#define INV_O2000MENET	0x23
-#define INV_O2000HIPPI	0x24
-#define INV_O2000GFX	0x25	
-#define INV_O2000HAROLD 0x26
-#define INV_O2000VME	0x27
-#define INV_O2000MIO	0x28
-#define INV_O2000FC	0x29
-#define INV_O2000LINC	0x2a
-
-#define INV_PCIADAP	4
-/* states for class INV_IOBD type INV_EVERESTIO -- value of eb_type field */
-#define INV_IO4_REV1	0x21	
-
-/* types for class disk */
-/* NB: types MUST be unique within a class.
-   Please check this if adding new types. */
-
-#define INV_SCSICONTROL	1
-#define INV_SCSIDRIVE	2
-#define INV_SCSIFLOPPY	5	/* also cdroms, optical disks, etc. */
-#define INV_JAGUAR	16	/* Interphase Jaguar */
-#define INV_VSCSIDRIVE	17	/* Disk connected to Jaguar */
-#define INV_GIO_SCSICONTROL 18	/* optional GIO SCSI controller */
-#define INV_SCSIRAID	19	/* SCSI attached RAID */
-#define INV_XLVGEN      20	/* Generic XLV disk device */
-#define INV_PCCARD	21	/* PC-card (PCMCIA) devices */
-#define INV_PCI_SCSICONTROL	22   /* optional PCI SCSI controller */
-
-/* states for INV_SCSICONTROL disk type; indicate which chip rev;
- * for 93A and B, unit field has microcode rev. */
-#define INV_WD93	0	/* WD 33C93  */
-#define INV_WD93A	1	/* WD 33C93A */
-#define INV_WD93B	2	/* WD 33C93B */
-#define INV_WD95A	3	/* WD 33C95A */
-#define INV_SCIP95	4       /* SCIP with a WD 33C95A */
-#define INV_ADP7880	5	/* Adaptec 7880 (single channel) */
-#define INV_QL_REV1     6       /* qlogic 1040  */
-#define INV_QL_REV2     7       /* qlogic 1040A */
-#define INV_QL_REV2_4   8       /* qlogic 1040A rev 4 */
-#define INV_QL_REV3     9       /* qlogic 1040B */
-#define INV_FCADP	10	/* Adaptec Emerald Fibrechannel */
-#define INV_QL_REV4     11      /* qlogic 1040B rev 2 */
-#define INV_QL		12	/* Unknown QL version */	
-#define INV_QL_1240     13      /* qlogic 1240 */
-#define INV_QL_1080     14      /* qlogic 1080 */
-#define INV_QL_1280     15      /* qlogic 1280 */
-#define INV_QL_10160    16      /* qlogic 10160 */
-#define INV_QL_12160    17      /* qlogic 12160 */
-#define INV_QL_2100	18	/* qLogic 2100 Fibrechannel */
-#define INV_QL_2200	19	/* qLogic 2200 Fibrechannel */
-#define INV_PR_HIO_D	20	/* Prisa HIO Dual channel */
-#define INV_PR_PCI64_D	21	/* Prisa PCI-64 Dual channel */
-#define INV_QL_2200A	22	/* qLogic 2200A Fibrechannel */
-#define INV_SBP2        23      /* SBP2 protocol over OHCI on 1394 */
-#define INV_QL_2300	24	/* qLogic 2300 Fibrechannel */
-
-
-/* states for INV_SCSIDRIVE type of class disk */
-#define INV_RAID5_LUN	0x100
-#define INV_PRIMARY	0x200	/* primary path */
-#define INV_ALTERNATE	0x400	/* alternate path */
-#define INV_FAILED	0x800	/* path has failed */
-#define INV_XVMVOL	0x1000	/* disk is managed by XVM */
-
-/* states for INV_SCSIFLOPPY type of class disk */
-#define INV_TEAC_FLOPPY 1       /* TEAC 3 1/2 inch floppy drive */
-#define INV_INSITE_FLOPPY 2     /* INSITE, IOMEGA  Io20S, SyQuest floppy drives */
-
-/* END OF CLASS DISK TYPES */
-
-/* types for class memory */
-/* NB. the states for class memory are sizes in bytes */
-#define INV_MAIN	1
-#define INV_DCACHE	3
-#define INV_ICACHE	4
-#define INV_WBUFFER	5
-#define INV_SDCACHE	6
-#define INV_SICACHE	7
-#define INV_SIDCACHE	8
-#define INV_MAIN_MB	9
-#define INV_HUBSPC      10      /* HUBSPC */
-#define INV_TIDCACHE	11
-
-/* types for class serial */
-#define INV_CDSIO	1	/* Central Data serial board */
-#define INV_T3270	2	/* T3270 emulation */
-#define INV_GSE		3	/* SpectraGraphics Gerbil coax cable */
-#define INV_SI		4	/* SNA SDLC controller */
-#define	INV_M333X25 	6	/* X.25 controller */
-#define INV_CDSIO_E	7	/* Central Data serial board on E space */
-#define INV_ONBOARD	8	/* Serial ports per CPU board */
-#define INV_EPC_SERIAL	9	/* EVEREST I/O EPC serial port */
-#define INV_ICA		10	/* IRIS (IBM) Channel Adapter card */
-#define INV_VSC		11	/* SBE VME Synch Comm board */
-#define INV_ISC		12	/* SBE ISA Synch Comm board */
-#define INV_GSC		13	/* SGI GIO Synch Comm board */
-#define INV_ASO_SERIAL	14	/* serial portion of SGI ASO board */
-#define INV_PSC		15	/* SBE PCI Synch Comm board */
-#define INV_IOC3_DMA	16	/* DMA mode IOC3 serial */
-#define INV_IOC3_PIO	17	/* PIO mode IOC3 serial */
-#define INV_INVISIBLE	18	/* invisible inventory entry for kernel use */
-#define INV_ISA_DMA	19	/* DMA mode ISA serial -- O2 */
-
-/* types for class parallel */
-#define INV_GPIB	2	/* National Instrument GPIB board */
-#define INV_GPIB_E	3	/* National Instrument GPIB board on E space*/
-#define INV_EPC_PLP	4	/* EVEREST I/O EPC Parallel Port */
-#define INV_ONBOARD_PLP	5	/* Integral parallel port,
-				      state = 0 -> output only
-				      state = 1 -> bi-directional */
-#define INV_EPP_ECP_PLP	6	/* Integral EPP/ECP parallel port */
-#define INV_EPP_PFD	7	/* External EPP parallel peripheral */
-
-/* types for class tape */
-#define INV_SCSIQIC	1	/* Any SCSI tape, not just QIC{24,150}... */
-#define INV_VSCSITAPE	4	/* SCSI tape connected to Jaguar */
-
-/* sub types for type INV_SCSIQIC and INV_VSCSITAPE (in state) */
-#define TPUNKNOWN	0	/* type not known */
-#define TPQIC24		1	/* QIC24 1/4" cartridge */
-#define TPDAT		2	/* 4mm Digital Audio Tape cartridge */
-#define TPQIC150	3	/* QIC150 1/4" cartridge */
-#define TP9TRACK	4	/* 9 track reel */
-#define TP8MM_8200	5	/* 8 mm video tape cartridge */
-#define TP8MM_8500	6	/* 8 mm video tape cartridge */
-#define TPQIC1000	7	/* QIC1000 1/4" cartridge */
-#define TPQIC1350	8	/* QIC1350 1/4" cartridge */
-#define TP3480		9	/* 3480 compatible cartridge */
-#define TPDLT		10	/* DEC Digital Linear Tape cartridge */
-#define TPD2		11	/* D2 tape cartridge */
-#define TPDLTSTACKER	12	/* DEC Digital Linear Tape stacker */
-#define TPNTP		13	/* IBM Magstar 3590 Tape Device cartridge */
-#define TPNTPSTACKER	14	/* IBM Magstar 3590 Tape Device stacker */
-#define TPSTK9490       15      /* StorageTeK 9490 */
-#define TPSTKSD3        16      /* StorageTeK SD3 */
-#define TPGY10	        17      /* Sony GY-10  */
-#define TP8MM_8900	18	/* 8 mm (AME) tape cartridge */
-#define TPMGSTRMP       19      /* IBM Magster MP 3570 cartridge */
-#define TPMGSTRMPSTCKR  20      /* IBM Magstar MP stacker */
-#define TPSTK4791       21      /* StorageTek 4791 */
-#define TPSTK4781       22      /* StorageTek 4781 */
-#define TPFUJDIANA1     23      /* Fujitsu Diana-1 (M1016/M1017) */
-#define TPFUJDIANA2     24      /* Fujitsu Diana-2 (M2483) */
-#define TPFUJDIANA3     25      /* Fujitsu Diana-3 (M2488) */
-#define TP8MM_AIT	26	/* Sony AIT format tape */
-#define TPTD3600        27      /* Philips TD3600  */
-#define TPTD3600STCKR   28      /* Philips TD3600  stacker */
-#define TPNCTP          29      /* Philips NCTP */
-#define TPGY2120        30      /* Sony GY-2120 (replaces GY-10)  */
-#define TPOVL490E       31      /* Overland Data L490E (3490E compatible) */
-#define TPSTK9840       32      /* StorageTeK 9840 (aka Eagle) */
-
-/* Diagnostics inventory */
-#define INV_CPUDIAGVAL  70
-
-
-/*
- *  GFX invent is a subset of gfxinfo
- */
-
-/* types for class graphics */
-#define INV_GR1BOARD	1	/* GR1 (Eclipse) graphics */
-#define INV_GR1BP	2	/* OBSOLETE - use INV_GR1BIT24 instead */
-#define INV_GR1ZBUFFER	3	/* OBSOLETE - use INV_GR1ZBUF24 instead */
-#define INV_GRODEV	4	/* Clover1 graphics */
-#define INV_GMDEV	5	/* GT graphics */
-#define INV_CG2		6	/* CG2 composite video/genlock board */
-#define INV_VMUXBOARD	7	/* VMUX video mux board */
-#define	INV_VGX		8	/* VGX (PowerVision) graphics */
-#define	INV_VGXT	9	/* VGXT (PowerVision) graphics with IMP5s. */
-#define	INV_LIGHT	10	/* LIGHT graphics */
-#define INV_GR2		11	/* EXPRESS graphics */
-#define INV_RE		12	/* RealityEngine graphics */
-#define INV_VTX		13	/* RealityEngine graphics - VTX variant */
-#define INV_NEWPORT	14	/* Newport graphics */
-#define INV_MGRAS	15	/* Mardigras graphics */
-#define INV_IR		16	/* InfiniteReality graphics */
-#define INV_CRIME	17	/* Moosehead on board CRIME graphics */
-#define INV_IR2		18	/* InfiniteReality2 graphics */
-#define INV_IR2LITE	19	/* Reality graphics */
-#define INV_IR2E	20	/* InfiniteReality2e graphics */
-#define INV_ODSY        21      /* Odyssey graphics */
-#define INV_IR3		22	/* InfiniteReality3 graphics */
-
-/* states for graphics class GR1 */
-#define INV_GR1REMASK	0x7	/* RE version */
-#define INV_GR1REUNK	0x0	/* RE version unknown */
-#define INV_GR1RE1	0x1	/* RE1 */
-#define INV_GR1RE2	0x2	/* RE2 */
-#define INV_GR1BUSMASK	0x38	/* GR1 bus architecture */
-#define INV_GR1PB	0x00	/* Eclipse private bus */
-#define INV_GR1PBVME	0x08	/* VGR2 board VME and private bus interfaces */
-#define INV_GR1TURBO	0x40	/* has turbo option */
-#define INV_GR1BIT24  	0x80    /* has bitplane option */
-#define INV_GR1ZBUF24 	0x100   /* has z-buffer option */
-#define INV_GR1SMALLMON 0x200   /* using 14" monitor */
-#define INV_GR1SMALLMAP 0x400   /* has 256 entry color map */
-#define INV_GR1AUX4 	0x800   /* has AUX/WID plane option */
-
-/* states for graphics class GR2 */
-		/* bitmasks */
-#define INV_GR2_Z	0x1	/* has z-buffer option */
-#define INV_GR2_24	0x2	/* has bitplane option */
-#define INV_GR2_4GE     0x4     /* has 4 GEs */
-#define INV_GR2_1GE	0x8	/* has 1 GEs */
-#define INV_GR2_2GE	0x10	/* has 2 GEs */
-#define INV_GR2_8GE	0x20	/* has 8 GEs */
-#define INV_GR2_GR3	0x40	/* board GR3 */
-#define INV_GR2_GU1	0x80	/* board GU1 */
-#define INV_GR2_INDY    0x100   /* board GR3 on Indy*/
-#define INV_GR2_GR5	0x200	/* board GR3 with 4 GEs, hinv prints GR5-XZ */
-
-		/* supported configurations */
-#define INV_GR2_XS	0x0     /* GR2-XS */
-#define INV_GR2_XSZ	0x1     /* GR2-XS with z-buffer */
-#define INV_GR2_XS24	0x2     /* GR2-XS24 */
-#define INV_GR2_XS24Z	0x3     /* GR2-XS24 with z-buffer */
-#define INV_GR2_XSM	0x4     /* GR2-XSM */
-#define INV_GR2_ELAN	0x7	/* GR2-Elan */
-#define	INV_GR2_XZ	0x13	/* GR2-XZ */
-#define	INV_GR3_XSM	0x44	/* GR3-XSM */
-#define	INV_GR3_ELAN	0x47	/* GR3-Elan */
-#define	INV_GU1_EXTREME	0xa3	/* GU1-Extreme */
-
-/* States for graphics class NEWPORT */
-#define	INV_NEWPORT_XL	0x01	/* Indigo2 XL model */
-#define INV_NEWPORT_24	0x02	/* board has 24 bitplanes */
-#define INV_NEWTON      0x04    /* Triton SUBGR tagging */
-
-/* States for graphics class MGRAS */
-#define INV_MGRAS_ARCHS 0xff000000      /* architectures */
-#define INV_MGRAS_HQ3   0x00000000   /*impact*/
-#define INV_MGRAS_HQ4	0x01000000   /*gamera*/
-#define INV_MGRAS_MOT   0x02000000   /*mothra*/
-#define INV_MGRAS_GES	0x00ff0000	/* number of GEs */
-#define INV_MGRAS_1GE	0x00010000
-#define INV_MGRAS_2GE	0x00020000
-#define INV_MGRAS_RES	0x0000ff00	/* number of REs */
-#define INV_MGRAS_1RE	0x00000100
-#define INV_MGRAS_2RE	0x00000200
-#define INV_MGRAS_TRS	0x000000ff	/* number of TRAMs */
-#define INV_MGRAS_0TR	0x00000000
-#define INV_MGRAS_1TR	0x00000001
-#define INV_MGRAS_2TR	0x00000002
-
-/* States for graphics class CRIME */
-#define INV_CRM_BASE    0x01            /* Moosehead basic model */
-
-/* States for graphics class ODSY */
-#define INV_ODSY_ARCHS      0xff000000 /* architectures */
-#define INV_ODSY_REVA_ARCH  0x01000000 /* Buzz Rev A */
-#define INV_ODSY_REVB_ARCH  0x02000000 /* Buzz Rev B */
-#define INV_ODSY_MEMCFG     0x00ff0000 /* memory configs */
-#define INV_ODSY_MEMCFG_32  0x00010000 /* 32MB memory */
-#define INV_ODSY_MEMCFG_64  0x00020000 /* 64MB memory */
-#define INV_ODSY_MEMCFG_128 0x00030000 /* 128MB memory */
-#define INV_ODSY_MEMCFG_256 0x00040000 /* 256MB memory */
-#define INV_ODSY_MEMCFG_512 0x00050000 /* 512MB memory */
-
-
-/* types for class network */
-#define INV_NET_ETHER		0	/* 10Mb Ethernet */
-#define INV_NET_HYPER		1	/* HyperNet */
-#define	INV_NET_CRAYIOS		2	/* Cray Input/Ouput Subsystem */
-#define	INV_NET_FDDI		3	/* FDDI */
-#define INV_NET_TOKEN		4	/* 16/4 Token Ring */
-#define INV_NET_HIPPI		5	/* HIPPI */
-#define INV_NET_ATM		6	/* ATM */
-#define INV_NET_ISDN_BRI	7	/* ISDN */
-#define INV_NET_ISDN_PRI	8	/* PRI ISDN */
-#define INV_NET_HIPPIS		9	/* HIPPI-Serial */
-#define	INV_NET_GSN		10	/* GSN (aka HIPPI-6400) */
-#define INV_NET_MYRINET		11	/* Myricom PCI network */
-
-/* controllers for network types, unique within class network */
-#define INV_ETHER_EC	0	/* IP6 integral controller */
-#define INV_ETHER_ENP	1	/* CMC board */
-#define INV_ETHER_ET	2	/* IP5 integral controller */
-#define INV_HYPER_HY	3	/* HyperNet controller */
-#define	INV_CRAYIOS_CFEI3 4	/* Cray Front End Interface, v3 */
-#define	INV_FDDI_IMF	5	/* Interphase/Martin 3211 FDDI */
-#define INV_ETHER_EGL	6	/* Interphase V/4207 Eagle */
-#define INV_ETHER_FXP	7	/* CMC C/130 FXP */
-#define INV_FDDI_IPG	8	/* Interphase/SGI 4211 Peregrine FDDI */
-#define INV_TOKEN_FV	9	/* Formation fv1600 Token-Ring board */
-#define INV_FDDI_XPI	10	/* XPI GIO bus FDDI */
-#define INV_TOKEN_GTR	11	/* GTR GIO bus TokenRing */
-#define INV_ETHER_GIO	12	/* IP12/20 optional GIO ethernet controller */
-#define INV_ETHER_EE	13	/* Everest IO4 EPC SEEQ/EDLC */
-#define INV_HIO_HIPPI	14	/* HIO HIPPI for Challenge/Onyx */
-#define INV_ATM_GIO64	15	/* ATM OC-3c Mez card */
-#define INV_ETHER_EP	16	/* 8-port E-Plex Ethernet */
-#define INV_ISDN_SM	17	/* Siemens PEB 2085 */
-#define INV_TOKEN_MTR	18	/* EISA TokenRing */
-#define INV_ETHER_EF	19	/* IOC3 Fast Ethernet */
-#define INV_ISDN_48XP	20	/* Xircom PRI-48XP */
-#define INV_FDDI_RNS	21	/* Rockwell Network Systems FDDI */
-#define INV_HIPPIS_XTK	22	/* Xtalk HIPPI-Serial */
-#define INV_ATM_QUADOC3	23	/* Xtalk Quad OC-3c ATM interface */
-#define INV_TOKEN_MTRPCI 24     /* PCI TokenRing */
-#define INV_ETHER_ECF	25	/* PCI Fast Ethernet */
-#define INV_GFE		26	/* GIO Fast Ethernet */
-#define INV_VFE		27	/* VME Fast Ethernet */
-#define	INV_ETHER_GE	28	/* Gigabit Ethernet */
-#define	INV_ETHER_EFP	INV_ETHER_EF	/* unused (same as IOC3 Fast Ethernet) */
-#define INV_GSN_XTK1	29	/* single xtalk version of GSN */
-#define INV_GSN_XTK2	30	/* dual xtalk version of GSN */
-#define INV_FORE_HE	31	/* FORE HE ATM Card */
-#define INV_FORE_PCA	32	/* FORE PCA ATM Card */
-#define INV_FORE_VMA    33      /* FORE VMA ATM Card */
-#define INV_FORE_ESA    34      /* FORE ESA ATM Card */
-#define INV_FORE_GIA    35      /* FORE GIA ATM Card */
-
-/* Types for class INV_SCSI and INV_VSCSI; The type code is the same as
- * the device type code returned by the Inquiry command, iff the Inquiry
- * command defines a type code for the device in question.  If it doesn't,
- * values over 31 will be used for the device type.
- * Note: the lun is encoded in bits 8-15 of the state.  The
- * state field low 3 bits contains the information from the inquiry
- * cmd that indicates ANSI SCSI 1,2, etc. compliance, and bit 7
- * contains the inquiry info that indicates whether the media is
- * removable.
- */
-#define INV_PRINTER	2	/* SCSI printer */
-#define INV_CPU		3	/* SCSI CPU device */
-#define INV_WORM	4	/* write-once-read-many (e.g. optical disks) */
-#define INV_CDROM	5	/* CD-ROM  */
-#define INV_SCANNER	6	/* scanners */
-#define INV_OPTICAL	7	/* optical disks (read-write) */
-#define INV_CHANGER	8	/* jukebox's for CDROMS, for example */
-#define INV_COMM	9	/* Communications device */
-#define INV_STARCTLR	12	/* Storage Array Controller */
-#define INV_RAIDCTLR	32	/* RAID ctlr actually gives type 0 */
-
-/* bit definitions for state field for class INV_SCSI */
-#define INV_REMOVE	0x80	/* has removable media */
-#define INV_SCSI_MASK	7	/* to which ANSI SCSI standard device conforms*/
-
-/* types for class INV_AUDIO */
-
-#define INV_AUDIO_HDSP		0	/* Indigo DSP system */
-#define INV_AUDIO_VIGRA110	1	/* ViGRA 110 audio board */
-#define INV_AUDIO_VIGRA210	2	/* ViGRA 210 audio board */
-#define INV_AUDIO_A2		3	/* HAL2 / Audio Module for Indigo 2 */
-#define INV_AUDIO_A3		4	/* Moosehead (IP32) AD1843 codec */
-#define INV_AUDIO_RAD		5	/* RAD PCI chip */
-
-/* types for class INV_VIDEO */
-
-#define	INV_VIDEO_LIGHT		0
-#define	INV_VIDEO_VS2		1	/* MultiChannel Option */
-#define	INV_VIDEO_EXPRESS	2	/* kaleidecope video */
-#define	INV_VIDEO_VINO		3
-#define	INV_VIDEO_VO2		4	/* Sirius Video */
-#define	INV_VIDEO_INDY		5	/* Indy Video - kal vid on Newport
-					  gfx on Indy */
-#define	INV_VIDEO_MVP		6	/* Moosehead Video Ports */
-#define	INV_VIDEO_INDY_601	7	/* Indy Video 601 */
-#define	INV_VIDEO_PMUX		8	/* PALMUX video w/ PGR gfx */
-#define	INV_VIDEO_MGRAS		9	/* Galileo 1.5 video */
-#define	INV_VIDEO_DIVO		10	/* DIVO video */
-#define	INV_VIDEO_RACER		11	/* SpeedRacer Pro Video */
-#define	INV_VIDEO_EVO		12	/* EVO Personal Video */
-#define INV_VIDEO_XTHD		13	/* XIO XT-HDTV video */
-#define INV_VIDEO_XTDIGVID      14      /* XIO XT-HDDIGVID video */
-
-/* states for video class INV_VIDEO_EXPRESS */
-
-#define INV_GALILEO_REV		0xF
-#define INV_GALILEO_JUNIOR	0x10
-#define INV_GALILEO_INDY_CAM	0x20
-#define INV_GALILEO_DBOB	0x40
-#define INV_GALILEO_ELANTEC	0x80
-
-/* states for video class VINO */
-
-#define INV_VINO_REV		0xF
-#define INV_VINO_INDY_CAM	0x10
-#define INV_VINO_INDY_NOSW	0x20	/* nebulous - means s/w not installed */
-
-/* states for video class MVP */
-
-#define INV_MVP_REV(x)		(((x)&0x0000000f))
-#define INV_MVP_REV_SW(x)	(((x)&0x000000f0)>>4)
-#define INV_MVP_AV_BOARD(x)	(((x)&0x00000f00)>>8)
-#define	INV_MVP_AV_REV(x)	(((x)&0x0000f000)>>12)
-#define	INV_MVP_CAMERA(x)	(((x)&0x000f0000)>>16)
-#define	INV_MVP_CAM_REV(x)	(((x)&0x00f00000)>>20)
-#define INV_MVP_SDIINF(x)       (((x)&0x0f000000)>>24)
-#define INV_MVP_SDI_REV(x)      (((x)&0xf0000000)>>28)
-
-/* types for class INV_BUS */
-
-#define INV_BUS_VME	0
-#define INV_BUS_EISA	1
-#define INV_BUS_GIO	2
-#define INV_BUS_BT3_PCI	3
-
-/* types for class INV_MISC */
-#define INV_MISC_EPC_EINT	0	/* EPC external interrupts */
-#define INV_MISC_PCKM		1	/* pc keyboard or mouse */
-#define INV_MISC_IOC3_EINT	2	/* IOC3 external interrupts */
-#define INV_MISC_OTHER		3	/* non-specific type */
-
-/*
- * The four components below do not actually have inventory information
- * associated with the vertex. These symbols are used by grio at the 
- * moment to figure out the device type from the vertex. If these get
- * inventory structures in the future, either the type values must
- * remain the same or grio code needs to change.
- */
-
-#define INV_XBOW        	3	/* cross bow */
-#define INV_HUB         	4	/* hub */
-#define INV_PCI_BRIDGE  	5	/* pci bridge */
-#define INV_ROUTER		6	/* router */
-
-/*  types for class INV_PROM */
-#define INV_IO6PROM	0
-#define INV_IP27PROM	1
-#define INV_IP35PROM	2
-
-/* types for class INV_COMPRESSION */
-
-#define	INV_COSMO		0
-#define	INV_INDYCOMP		1
-#define	INV_IMPACTCOMP		2	/* cosmo2, aka impact compression */
-#define	INV_VICE		3 	/* Video imaging & compression engine */
-
-/* types for class INV_DISPLAY */
-#define INV_PRESENTER_BOARD	0       /* Indy Presenter adapter board */
-#define INV_PRESENTER_PANEL	1       /* Indy Presenter board and panel */
-#define INV_ICO_BOARD		2	/* IMPACT channel option board */
-#define INV_DCD_BOARD		3	/* O2 dual channel option board */
-#define INV_7of9_BOARD          4       /* 7of9 flatpanel adapter board */
-#define INV_7of9_PANEL          5       /* 7of9 flatpanel board and panel */
-
-/* types for class INV_IEEE1394 */
-#define INV_OHCI	0	/* Ohci IEEE1394 pci card */
-
-/* state for class INV_IEEE1394 & type INV_OHCI */
-#define INV_IEEE1394_STATE_TI_REV_1 0
-
-/* O2 DVLink 1.1 controller static info */
-#define INV_IEEE1394_CTLR_O2_DVLINK_11 0x8009104c
-
-/* types for class INV_TPU */
-#define	INV_TPU_EXT		0	/* External XIO Tensor Processing Unit */
-#define	INV_TPU_XIO		1	/* Internal XIO Tensor Processing Unit */
-
-/*
- * USB Types.  The upper 8 bits contain general usb device class and are used to
- * qualify the lower 8 bits which contain device type within a usb class.
- * Use USB_INV_DEVCLASS and USB_INV_DEVTYPE to to decode an i_type, and
- * USB_INV_TYPE to set it.
- */
-
-#define USB_INV_DEVCLASS(invtype)	((invtype) >> 8)
-#define USB_INV_DEVTYPE(invtype)	((invtype) & 0xf)
-#define USB_INV_TYPE(usbclass, usbtype)	(((usbclass) << 8) | (usbtype))
-
-/*
- * USB device classes.  These classes might not match the classes as defined
- * by the usb spec, but where possible we will try.
- */
-
-#define USB_INV_CLASS_RH	0x00	/* root hub (ie. controller) */
-#define USB_INV_CLASS_HID	0x03	/* human interface device */
-#define USB_INV_CLASS_HUB	0x09	/* hub device */
-
-/*
- * USB device types within a class.  These will not match USB device types,
- * as the usb is not consistent on how specific types are defined (sometimes
- * they are found in the interface subclass, sometimes (as in HID devices) they
- * are found within data generated by the device (hid report descriptors for
- * example).
- */
-
-/*
- * RH types
- */
-
-#define USB_INV_RH_OHCI		0x01	/* ohci root hub */
-
-/*
- * HID types
- */
-
-#define USB_INV_HID_KEYBOARD	0x01	/* kbd (HID class) */
-#define USB_INV_HID_MOUSE	0x02	/* mouse (HID class) */
-
-/*
- * HUB types - none yet
- */
-
-typedef struct invent_generic_s {
-	unsigned short	ig_module;
-	unsigned short	ig_slot;
-	unsigned char	ig_flag;
-	int	ig_invclass;
-} invent_generic_t;
-
-#define INVENT_ENABLED	0x1
-
-typedef struct invent_membnkinfo {
-	unsigned short	imb_size;	/* bank size in MB */
-	unsigned short	imb_attr;	/* Mem attributes */
-	unsigned int	imb_flag;	/* bank flags */
-} invent_membnkinfo_t;
-
-
-typedef struct invent_meminfo {
-	invent_generic_t 	im_gen;
-	unsigned short	im_size;	/* memory size     */
-	unsigned short	im_banks;	/* number of banks */
-	/*
-	 * declare an array with one element. Each platform is expected to
-	 * allocate the size required based on the number of banks and set
-	 * the im_banks correctly for this array traversal.
-	 */
-	invent_membnkinfo_t im_bank_info[1]; 
-} invent_meminfo_t;
-
-#define INV_MEM_PREMIUM	 0x01
-
-typedef struct invent_cpuinfo {
-	invent_generic_t ic_gen;
-	cpu_inv_t     ic_cpu_info;
-	unsigned short	ic_cpuid;
-	unsigned short	ic_slice;
-	unsigned short  ic_cpumode;
-
-} invent_cpuinfo_t;
-
-typedef struct invent_rpsinfo {
-	invent_generic_t ir_gen;
-	int 		 ir_xbox;	/* is RPS connected to an xbox */
-} invent_rpsinfo_t;
-
-typedef struct invent_miscinfo {
-	invent_generic_t im_gen;
-	int       	 im_rev;
-	int		 im_version;
-	int	         im_type;
-	uint64_t	 im_speed;
-} invent_miscinfo_t;
-
-
-typedef struct invent_routerinfo{
-         invent_generic_t im_gen;
-         router_inv_t     rip;
-} invent_routerinfo_t;
-
-
-
-#ifdef __KERNEL__
-
-typedef struct irix5_inventory_s {
-	app32_ptr_t	inv_next;	/* next inventory record in list */
-	int	inv_class;		/* class of object */
-	int	inv_type;		/* class sub-type of object */
-	major_t	inv_controller;		/* object major identifier */
-	minor_t	inv_unit;		/* object minor identifier */
-	int	inv_state;		/* information specific to object or
-					   class */
-} irix5_inventory_t;
-
-typedef struct invplace_s {
-	vertex_hdl_t		invplace_vhdl;		/* current vertex */
-	vertex_hdl_t		invplace_vplace;	/* place in vertex list */
-	inventory_t		*invplace_inv;		/* place in inv list on vertex */
-} invplace_t; /* Magic cookie placeholder in inventory list */
-
-extern invplace_t invplace_none;
-#define INVPLACE_NONE invplace_none
-
-static inline void device_inventory_add(vertex_hdl_t device, 
-					int class, 
-					int type, 
-					major_t ctlr, 
-					minor_t unit, 
-					int state)
-{
-}
-
-#endif /* __KERNEL__ */
-#endif /* _ASM_IA64_SN_INVENT_H */
diff -puN include/asm-ia64/sn/ioc4.h~linus include/asm-ia64/sn/ioc4.h
--- 25/include/asm-ia64/sn/ioc4.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/ioc4.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,30 +1,9 @@
 /*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
  * Copyright (c) 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
- * 
- * This program is free software; you can redistribute it and/or modify it 
- * under the terms of version 2 of the GNU General Public License 
- * as published by the Free Software Foundation.
- * 
- * This program is distributed in the hope that it would be useful, but 
- * WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * 
- * Further, this software is distributed without any warranty that it is 
- * free of the rightful claim of any third person regarding infringement 
- * or the like.  Any license provided herein, whether implied or 
- * otherwise, applies only to this software file.  Patent licenses, if 
- * any, provided herein do not apply to combinations of this program with 
- * other software, or any other product whatsoever.
- * 
- * You should have received a copy of the GNU General Public 
- * License along with this program; if not, write the Free Software 
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- * 
- * Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 
- * Mountain View, CA  94043, or:
- * 
- * http://www.sgi.com 
- * 
  */
 
 #ifndef _ASM_IA64_SN_IOC4_H
diff -puN include/asm-ia64/sn/ioconfig_bus.h~linus include/asm-ia64/sn/ioconfig_bus.h
--- 25/include/asm-ia64/sn/ioconfig_bus.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/ioconfig_bus.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,35 +1,14 @@
 /*
- * Copyright (c) 2003 Silicon Graphics, Inc.  All Rights Reserved.
- * 
- * This program is free software; you can redistribute it and/or modify it 
- * under the terms of version 2 of the GNU General Public License 
- * as published by the Free Software Foundation.
- * 
- * This program is distributed in the hope that it would be useful, but 
- * WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * 
- * Further, this software is distributed without any warranty that it is 
- * free of the rightful claim of any third person regarding infringement 
- * or the like.  Any license provided herein, whether implied or 
- * otherwise, applies only to this software file.  Patent licenses, if 
- * any, provided herein do not apply to combinations of this program with 
- * other software, or any other product whatsoever.
- * 
- * You should have received a copy of the GNU General Public 
- * License along with this program; if not, write the Free Software 
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- * 
- * Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 
- * Mountain View, CA  94043, or:
- * 
- * http://www.sgi.com 
- * 
- * For further information regarding this notice, see: 
- * 
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2003 Silicon Graphics, Inc.  All Rights Reserved.
  */
 
+#ifndef _ASM_IA64_SN_IOCONFIG_BUS_H
+#define _ASM_IA64_SN_IOCONFIG_BUS_H
+
 #define IOCONFIG_PCIBUS "/boot/efi/ioconfig_pcibus"
 #define POUND_CHAR                   '#'
 #define MAX_LINE_LEN	128
@@ -44,3 +23,5 @@ struct ioconfig_parm {
 struct  ascii_moduleid{
                 unsigned char   io_moduleid[8]; /* pci path name */
 };
+
+#endif	/* _ASM_IA64_SN_IOCONFIG_BUS_H */
diff -puN include/asm-ia64/sn/ioerror.h~linus include/asm-ia64/sn/ioerror.h
--- 25/include/asm-ia64/sn/ioerror.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/ioerror.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -185,13 +184,9 @@ typedef enum {
 typedef int             error_handler_f(void *, int, ioerror_mode_t, ioerror_t *);
 typedef void           *error_handler_arg_t;
 
-extern void             ioerror_dump(char *, int, int, ioerror_t *);
-
 #ifdef	ERROR_DEBUG
-#define	IOERROR_DUMP(x, y, z, t)	ioerror_dump((x), (y), (z), (t))
 #define	IOERR_PRINTF(x)	(x)
 #else
-#define	IOERROR_DUMP(x, y, z, t)
 #define	IOERR_PRINTF(x)
 #endif				/* ERROR_DEBUG */
 
diff -puN include/asm-ia64/sn/ioerror_handling.h~linus include/asm-ia64/sn/ioerror_handling.h
--- 25/include/asm-ia64/sn/ioerror_handling.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/ioerror_handling.h	2004-01-19 22:17:24.000000000 -0800
@@ -8,7 +8,6 @@
 #ifndef _ASM_IA64_SN_IOERROR_HANDLING_H
 #define _ASM_IA64_SN_IOERROR_HANDLING_H
 
-#include <linux/config.h>
 #include <linux/types.h>
 #include <asm/sn/sgi.h>
 
@@ -204,12 +203,6 @@ enum error_priority_e {
 
 typedef uint64_t  error_priority_t;
 
-/* Error state interfaces */
-#if defined(CONFIG_SGI_IO_ERROR_HANDLING)
-extern error_return_code_t	error_state_set(vertex_hdl_t,error_state_t);
-extern error_state_t		error_state_get(vertex_hdl_t);
-#endif
-
 /* Error action interfaces */
 
 extern error_return_code_t	error_action_set(vertex_hdl_t,
@@ -232,45 +225,6 @@ hwgraph_info_get_LBL(v, INFO_LBL_ERROR_S
 #define v_error_skip_env_clear(v)		\
 hwgraph_info_remove_LBL(v, INFO_LBL_ERROR_SKIP_ENV, 0)
 
-/* Skip point interfaces */
-extern error_return_code_t	error_skip_point_jump(vertex_hdl_t, boolean_t);
-extern error_return_code_t	error_skip_point_clear(vertex_hdl_t);
-
-/* REFERENCED */
-#if defined(CONFIG_SGI_IO_ERROR_HANDLING)
-
-inline static int
-error_skip_point_mark(vertex_hdl_t  v)  			 
-{									
-	label_t		*error_env = NULL;	 			
-	int		code = 0;		
-
-	/* Check if we have a valid hwgraph vertex */
-#ifdef	LATER
-	if (!dev_is_vertex(v))
-		return(code);
-#endif
-				
-	/* There is no error jump buffer for this device vertex. Allocate
-	 * one.								 
-	 */								 
-	if (v_error_skip_env_get(v, error_env) != GRAPH_SUCCESS) {	 
-		error_env = snia_kmem_zalloc(sizeof(label_t), KM_NOSLEEP);	 
-		/* Unable to allocate memory for jum buffer. This should 
-		 * be a very rare occurrence.				 
-		 */							 
-		if (!error_env)						 
-			return(-1);					 
-		/* Store the jump buffer information on the vertex.*/	 
-		if (v_error_skip_env_set(v, error_env, 0) != GRAPH_SUCCESS)
-			return(-2);					   
-	}								   
-	ASSERT(v_error_skip_env_get(v, error_env) == GRAPH_SUCCESS);
-	code = setjmp(*error_env);					   
-	return(code);							     
-}
-#endif	/* CONFIG_SGI_IO_ERROR_HANDLING */
-
 typedef uint64_t		counter_t;
 
 extern counter_t		error_retry_count_get(vertex_hdl_t);
@@ -284,13 +238,5 @@ extern counter_t		error_retry_count_decr
 #define	IS_ERROR_INTR_CONTEXT(_ec)	((_ec & IOECODE_DMA) 		|| \
 					 (_ec == IOECODE_PIO_WRITE))
 
-/* Some convenience macros on device state. This state is accessed only 
- * thru the calls the io error handling layer.
- */
-#if defined(CONFIG_SGI_IO_ERROR_HANDLING)
-extern boolean_t		is_device_shutdown(vertex_hdl_t);
-#define IS_DEVICE_SHUTDOWN(_d) 	(is_device_shutdown(_d))
-#endif
-
 #endif /* __KERNEL__ */
 #endif /* _ASM_IA64_SN_IOERROR_HANDLING_H */
diff -puN include/asm-ia64/sn/iograph.h~linus include/asm-ia64/sn/iograph.h
--- 25/include/asm-ia64/sn/iograph.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/iograph.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -19,13 +18,10 @@
 /* edges names */
 #define EDGE_LBL_BUS			"bus"
 #define EDGE_LBL_CONN			".connection"
-#define EDGE_LBL_ECP			"ecp"		/* EPP/ECP plp */
-#define EDGE_LBL_ECPP			"ecpp"
 #define EDGE_LBL_GUEST			".guest"	/* For IOC3 */
 #define EDGE_LBL_HOST			".host"		/* For IOC3 */
 #define EDGE_LBL_PERFMON		"mon"
 #define EDGE_LBL_USRPCI			"usrpci"
-#define EDGE_LBL_VME			"vmebus"
 #define EDGE_LBL_BLOCK			"block"
 #define EDGE_LBL_BOARD			"board"
 #define EDGE_LBL_CHAR			"char"
@@ -35,50 +31,13 @@
 #define EDGE_LBL_DIRECT			"direct"
 #define EDGE_LBL_DISABLED		"disabled"
 #define EDGE_LBL_DISK			"disk"
-#define EDGE_LBL_DMA_ENGINE             "dma_engine"    /* Only available on
-							   VMEbus now        */
-#define EDGE_LBL_NET			"net"		/* all nw. devs */
-#define EDGE_LBL_EF			"ef"		/* For if_ef ethernet */
-#define EDGE_LBL_ET			"et"		/* For if_ee ethernet */
-#define EDGE_LBL_EC			"ec"		/* For if_ec2 ether */
-#define EDGE_LBL_ECF			"ec"		/* For if_ecf enet */
-#define EDGE_LBL_EM			"ec"		/* For O2 ether */
-#define EDGE_LBL_IPG			"ipg"		/* For IPG FDDI */
-#define EDGE_LBL_XPI			"xpi"		/* For IPG FDDI */
-#define EDGE_LBL_HIP			"hip"		/* For HIPPI */
-#define EDGE_LBL_GSN                    "gsn"           /* For GSN */
-#define EDGE_LBL_ATM			"atm"		/* For ATM */
-#define EDGE_LBL_FXP			"fxp"		/* For FXP ether */
-#define EDGE_LBL_EP			"ep"		/* For eplex ether */
-#define EDGE_LBL_VFE			"vfe"		/* For VFE ether */
-#define EDGE_LBL_GFE			"gfe"		/* For GFE ether */
-#define EDGE_LBL_RNS			"rns"		/* RNS PCI FDDI card */
-#define EDGE_LBL_MTR			"mtr"		/* MTR PCI 802.5 card */
-#define EDGE_LBL_FV			"fv"		/* FV VME 802.5 card */
-#define EDGE_LBL_GTR			"gtr"		/* GTR GIO 802.5 card */
-#define EDGE_LBL_ISDN                   "isdn"		/* Digi PCI ISDN-BRI card */
-
-#define EDGE_LBL_EISA			"eisa"
-#define EDGE_LBL_ENET			"ethernet"
-#define EDGE_LBL_FLOPPY			"floppy"
-#define EDGE_LBL_PFD			"pfd"		/* For O2 pfd floppy */
-#define EDGE_LBL_FOP                    "fop"           /* Fetchop pseudo device */
-#define EDGE_LBL_GIO			"gio"
-#define EDGE_LBL_HEART			"heart"		/* For RACER */
-#define EDGE_LBL_HPC			"hpc"
-#define EDGE_LBL_GFX			"gfx"
 #define EDGE_LBL_HUB			"hub"		/* For SN0 */
 #define EDGE_LBL_HW			"hw"
-#define EDGE_LBL_SYNERGY		"synergy"	/* For SNIA only */
-#define EDGE_LBL_IBUS			"ibus"		/* For EVEREST */
 #define EDGE_LBL_INTERCONNECT		"link"
 #define EDGE_LBL_IO			"io"
-#define EDGE_LBL_IO4			"io4"		/* For EVEREST */
-#define EDGE_LBL_IOC3			"ioc3"
 #define EDGE_LBL_LUN                    "lun"
 #define EDGE_LBL_LINUX                  "linux"
 #define EDGE_LBL_LINUX_BUS              EDGE_LBL_LINUX "/bus/pci-x"
-#define EDGE_LBL_MACE                   "mace" 		/* O2 mace */
 #define EDGE_LBL_MACHDEP                "machdep"       /* Platform depedent devices */
 #define EDGE_LBL_MASTER			".master"
 #define EDGE_LBL_MEMORY			"memory"
@@ -93,6 +52,9 @@
 #define EDGE_LBL_PCIX			"pci-x"
 #define EDGE_LBL_PCIX_0			EDGE_LBL_PCIX "/0"
 #define EDGE_LBL_PCIX_1			EDGE_LBL_PCIX "/1"
+#define EDGE_LBL_AGP			"agp"
+#define EDGE_LBL_AGP_0			EDGE_LBL_AGP "/0"
+#define EDGE_LBL_AGP_1			EDGE_LBL_AGP "/1"
 #define EDGE_LBL_PORT			"port"
 #define EDGE_LBL_PROM			"prom"
 #define EDGE_LBL_RACK			"rack"
@@ -103,11 +65,8 @@
 #define EDGE_LBL_SCSI			"scsi"
 #define EDGE_LBL_SCSI_CTLR		"scsi_ctlr"
 #define EDGE_LBL_SLOT			"slot"
-#define EDGE_LBL_TAPE			"tape"
 #define EDGE_LBL_TARGET                 "target"
 #define EDGE_LBL_UNKNOWN		"unknown"
-#define EDGE_LBL_VOLUME			"volume"
-#define EDGE_LBL_VOLUME_HEADER		"volume_header"
 #define EDGE_LBL_XBOW			"xbow"
 #define	EDGE_LBL_XIO			"xio"
 #define EDGE_LBL_XSWITCH		".xswitch"
@@ -115,23 +74,16 @@
 #define EDGE_LBL_XWIDGET		"xwidget"
 #define EDGE_LBL_ELSC			"elsc"
 #define EDGE_LBL_L1			"L1"
-#define EDGE_LBL_MADGE_TR               "Madge-tokenring"
 #define EDGE_LBL_XPLINK			"xplink" 	/* Cross partition */
 #define	EDGE_LBL_XPLINK_NET		"net" 		/* XP network devs */
 #define	EDGE_LBL_XPLINK_RAW		"raw"		/* XP Raw devs */
 #define EDGE_LBL_SLAB			"slab"		/* Slab of a module */
 #define	EDGE_LBL_XPLINK_KERNEL		"kernel"	/* XP kernel devs */
 #define	EDGE_LBL_XPLINK_ADMIN		"admin"	   	/* Partition admin */
-#define	EDGE_LBL_KAIO			"kaio"	   	/* Kernel async i/o poll */
-#define EDGE_LBL_RPS                    "rps"           /* redundant power supply */ 
-#define EDGE_LBL_XBOX_RPS               "xbox_rps"      /* redundant power supply for xbox unit */ 
 #define EDGE_LBL_IOBRICK		"iobrick"
-#define EDGE_LBL_PBRICK			"Pbrick"
-#define EDGE_LBL_PEBRICK		"PEbrick"
 #define EDGE_LBL_PXBRICK		"PXbrick"
+#define EDGE_LBL_OPUSBRICK		"onboardio"
 #define EDGE_LBL_IXBRICK		"IXbrick"
-#define EDGE_LBL_IBRICK			"Ibrick"
-#define EDGE_LBL_XBRICK			"Xbrick"
 #define EDGE_LBL_CGBRICK		"CGbrick"
 #define EDGE_LBL_CPUBUS			"cpubus"	/* CPU Interfaces (SysAd) */
 
@@ -142,25 +94,15 @@
 #define INFO_LBL_CPUID			"_cpuid"
 #define INFO_LBL_CPU_INFO		"_cpu"
 #define INFO_LBL_DETAIL_INVENT		"_detail_invent" /* inventory data*/
-#define INFO_LBL_DEVICE_DESC		"_device_desc"
-#define INFO_LBL_DIAGVAL                "_diag_reason"   /* Reason disabled */
-#define INFO_LBL_DKIOTIME		"_dkiotime"
+#define INFO_LBL_DIAGVAL		"_diag_reason"   /* Reason disabled */
 #define INFO_LBL_DRIVER			"_driver"	/* points to attached device_driver_t */
 #define INFO_LBL_ELSC			"_elsc"
 #define	INFO_LBL_SUBCH			"_subch"	/* system controller subchannel */
-#define INFO_LBL_L1SCP			"_l1scp"	/* points to l1sc_t */
-#define INFO_LBL_FC_PORTNAME		"_fc_portname"
-#define INFO_LBL_GIOIO			"_gioio"
-#define INFO_LBL_GFUNCS			"_gioio_ops"	/* ops vector for gio providers */
 #define INFO_LBL_HUB_INFO		"_hubinfo"
 #define INFO_LBL_HWGFSLIST		"_hwgfs_list"
 #define INFO_LBL_TRAVERSE		"_hwg_traverse" /* hwgraph traverse function */
-#define INFO_LBL_INVENT 		"_invent"	/* inventory data */
-#define INFO_LBL_MLRESET		"_mlreset"	/* present if device preinitialized */
 #define INFO_LBL_MODULE_INFO		"_module"	/* module data ptr */
-#define INFO_LBL_MONDATA		"_mon"		/* monitor data ptr */
 #define INFO_LBL_MDPERF_DATA		"_mdperf"	/* mdperf monitoring*/
-#define INFO_LBL_NIC			"_nic"
 #define INFO_LBL_NODE_INFO		"_node"
 #define	INFO_LBL_PCIBR_HINTS		"_pcibr_hints"
 #define INFO_LBL_PCIIO			"_pciio"
@@ -168,15 +110,11 @@
 #define INFO_LBL_PERMISSIONS		"_permissions"	/* owner, uid, gid */
 #define INFO_LBL_ROUTER_INFO		"_router"
 #define INFO_LBL_SUBDEVS		"_subdevs"	/* subdevice enable bits */
-#define INFO_LBL_VME_FUNCS		"_vmeio_ops"	/* ops vector for VME providers */
 #define INFO_LBL_XSWITCH		"_xswitch"
 #define INFO_LBL_XSWITCH_ID		"_xswitch_id"
 #define INFO_LBL_XSWITCH_VOL		"_xswitch_volunteer"
 #define INFO_LBL_XFUNCS			"_xtalk_ops"	/* ops vector for gio providers */
 #define INFO_LBL_XWIDGET		"_xwidget"
-#define INFO_LBL_GRIO_DSK		"_grio_disk"	/* guaranteed rate I/O */
-#define INFO_LBL_ASYNC_ATTACH           "_async_attach"	/* parallel attachment */
-#define INFO_LBL_GFXID			"_gfxid"	/* gfx pipe ID #s */
 /* Device/Driver  Admin directive labels  */
 #define ADMIN_LBL_INTR_TARGET		"INTR_TARGET"	/* Target cpu for device interrupts*/
 #define ADMIN_LBL_INTR_SWLEVEL		"INTR_SWLEVEL"	/* Priority level of the ithread */
@@ -199,12 +137,6 @@
 							 * thread priority
 							 * default class
 							 */
-/* Special reserved info labels (also hwgfs attributes) */
-#define _DEVNAME_ATTR		"_devname"	/* device name */
-#define _DRIVERNAME_ATTR	"_drivername"	/* driver name */
-#define _INVENT_ATTR		"_inventory"	/* device inventory data */
-#define _MASTERNODE_ATTR	"_masternode"	/* node that "controls" device */
-
 /* Info labels that begin with '_' cannot be overwritten by an attr_set call */
 #define INFO_LBL_RESERVED(name) ((name)[0] == '_')
 
diff -puN include/asm-ia64/sn/io.h~linus include/asm-ia64/sn/io.h
--- 25/include/asm-ia64/sn/io.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/io.h	2004-01-19 22:17:24.000000000 -0800
@@ -41,8 +41,8 @@
 		(((widget) & IIO_ITTE_WIDGET_MASK) << IIO_ITTE_WIDGET_SHIFT)))
 
 #define IIO_ITTE_DISABLE(nasid, bigwin) \
-	IIO_ITTE_PUT((nasid), HUB_PIO_MAP_TO_MEM, \
-		     (bigwin), IIO_ITTE_INVALID_WIDGET, 0)
+	IIO_ITTE_PUT((nasid), (bigwin), HUB_PIO_MAP_TO_MEM, \
+		IIO_ITTE_INVALID_WIDGET, 0)
 
 #define IIO_ITTE_GET(nasid, bigwin) REMOTE_HUB_ADDR((nasid), IIO_ITTE(bigwin))
 
diff -puN include/asm-ia64/sn/klconfig.h~linus include/asm-ia64/sn/klconfig.h
--- 25/include/asm-ia64/sn/klconfig.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/klconfig.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -12,12 +11,6 @@
 #ifndef _ASM_IA64_SN_KLCONFIG_H
 #define _ASM_IA64_SN_KLCONFIG_H
 
-#include <linux/config.h>
-
-/*
- * klconfig.h
- */
-
 /*
  * The KLCONFIG structures store info about the various BOARDs found
  * during Hardware Discovery. In addition, it stores info about the
@@ -41,7 +34,6 @@
 #include <asm/sn/sgi.h>
 #include <asm/sn/addrs.h>
 #include <asm/sn/vector.h>
-#include <asm/sn/arc/hinv.h>
 #include <asm/sn/xtalk/xbow.h>
 #include <asm/sn/xtalk/xtalk.h>
 #include <asm/sn/kldir.h>
@@ -74,10 +66,8 @@ typedef s32 klconf_off_t;
 #define DUPLICATE_BOARD 	0x04    /* Boards like midplanes/routers which
                                    	   are discovered twice. Use one of them */
 #define VISITED_BOARD		0x08	/* Used for compact hub numbering. */
-#define LOCAL_MASTER_IO6	0x10 	/* master io6 for that node */
-#define GLOBAL_MASTER_IO6	0x20
-#define GLOBAL_MASTER_EXT 	0x40  	/* extend master io6 to other bus on ibrick */
-#define SECOND_NIC_PRESENT 	0x80 	/* addons like MIO are present */
+#define LOCAL_MASTER_IO6	0x10    /* master io6 for that node */
+#define KLTYPE_IOBRICK_XBOW	(KLCLASS_MIDPLANE | 0x2)
 
 /* klinfo->flags fields */
 
@@ -88,11 +78,6 @@ typedef s32 klconf_off_t;
 #define KLINFO_CONTROLLER   	0x10 	/* This component is a device controller */
 #define KLINFO_INSTALL   	0x20  	/* Install a driver */
 #define	KLINFO_HEADLESS		0x40	/* Headless (or hubless) component */
-#define IS_CONSOLE_IOC3(i)	((((klinfo_t *)i)->flags) & KLINFO_INSTALL)
-
-#define GB2		0x80000000
-
-#define MAX_RSV_PTRS	32
 
 /* Structures to manage various data storage areas */
 /* The numbers must be contiguous since the array index i
@@ -141,41 +126,13 @@ typedef struct kl_config_hdr {
 
 
 #define KL_CONFIG_HDR(_nasid) 	((kl_config_hdr_t *)(KLCONFIG_ADDR(_nasid)))
-#define KL_CONFIG_INFO_OFFSET(_nasid)					\
-        (KL_CONFIG_HDR(_nasid)->ch_board_info)
-#define KL_CONFIG_INFO_SET_OFFSET(_nasid, _off)				\
-        (KL_CONFIG_HDR(_nasid)->ch_board_info = (_off))
-
-#ifndef __ia64
-#define KL_CONFIG_INFO(_nasid) 						\
-        (lboard_t *)((KL_CONFIG_HDR(_nasid)->ch_board_info) ?		\
-	 NODE_OFFSET_TO_K0((_nasid), KL_CONFIG_HDR(_nasid)->ch_board_info) : \
-	 0)
-#else
-#define NODE_OFFSET_TO_LBOARD(nasid,off)        (lboard_t*)(NODE_CAC_BASE(nasid) + (off))
-
-#define KL_CONFIG_INFO(_nasid)                                          \
-	(lboard_t *)((KL_CONFIG_HDR(_nasid)->ch_board_info) ?           \
-	 NODE_OFFSET_TO_LBOARD((_nasid), KL_CONFIG_HDR(_nasid)->ch_board_info) : \
-	 NULL)
-
-#endif	/* __ia64 */
 
-#define KL_CONFIG_MAGIC(_nasid)		(KL_CONFIG_HDR(_nasid)->ch_magic)
-
-#define KL_CONFIG_CHECK_MAGIC(_nasid)					\
-        (KL_CONFIG_HDR(_nasid)->ch_magic == KLCFGINFO_MAGIC)
+#define NODE_OFFSET_TO_LBOARD(nasid,off)        (lboard_t*)(NODE_CAC_BASE(nasid) + (off))
 
-#define KL_CONFIG_HDR_INIT_MAGIC(_nasid)	\
-                  (KL_CONFIG_HDR(_nasid)->ch_magic = KLCFGINFO_MAGIC)
+#define KL_CONFIG_INFO(_nasid) root_lboard[nasid_to_cnodeid(_nasid)]
 
 /* --- New Macros for the changed kl_config_hdr_t structure --- */
 
-#define PTR_CH_MALLOC_HDR(_k)   ((klc_malloc_hdr_t *)\
-			((__psunsigned_t)_k + (_k->ch_malloc_hdr_off)))
-
-#define KL_CONFIG_CH_MALLOC_HDR(_n)   PTR_CH_MALLOC_HDR(KL_CONFIG_HDR(_n))
-
 #define PTR_CH_CONS_INFO(_k)	((console_t *)\
 			((__psunsigned_t)_k + (_k->ch_cons_off)))
 
@@ -183,12 +140,6 @@ typedef struct kl_config_hdr {
 
 /* ------------------------------------------------------------- */
 
-#define KL_CONFIG_INFO_START(_nasid)	\
-        (klconf_off_t)(KLCONFIG_OFFSET(_nasid) + sizeof(kl_config_hdr_t))
-
-#define KL_CONFIG_BOARD_NASID(_brd)	((_brd)->brd_nasid)
-#define KL_CONFIG_BOARD_SET_NEXT(_brd, _off)	((_brd)->brd_next = (_off))
-
 #define KL_CONFIG_DUPLICATE_BOARD(_brd)	((_brd)->brd_flags & DUPLICATE_BOARD)
 
 #define XBOW_PORT_TYPE_HUB(_xbowp, _link) 	\
@@ -205,9 +156,6 @@ typedef struct kl_config_hdr {
 #define XBOW_PORT_HUB    0x2
 #define XBOW_PORT_ENABLE 0x4
 
-#define	SN0_PORT_FENCE_SHFT	0
-#define	SN0_PORT_FENCE_MASK	(1 << SN0_PORT_FENCE_SHFT)
-
 /*
  * The KLCONFIG area is organized as a LINKED LIST of BOARDs. A BOARD
  * can be either 'LOCAL' or 'REMOTE'. LOCAL means it is attached to 
@@ -301,15 +249,7 @@ typedef struct kl_config_hdr {
  */
 
 /*
- * Values for CPU types
- */
-#define KL_CPU_R4000		0x1	/* Standard R4000 */
-#define KL_CPU_TFP		0x2	/* TFP processor */
-#define	KL_CPU_R10000		0x3	/* R10000 (T5) */
-#define KL_CPU_NONE		(-1)	/* no cpu present in slot */
-
-/*
- * IP27 BOARD classes
+ * BOARD classes
  */
 
 #define KLCLASS_MASK	0xf0   
@@ -347,70 +287,27 @@ typedef struct kl_config_hdr {
 #define KLTYPE_WEIRDCPU (KLCLASS_CPU | 0x0)
 #define KLTYPE_SNIA	(KLCLASS_CPU | 0x1)
 
-#define KLTYPE_WEIRDIO	(KLCLASS_IOBRICK  | 0x0)
-#define KLTYPE_BASEIO	(KLCLASS_IO  | 0x1) /* IOC3, SuperIO, Bridge, SCSI */
-#define KLTYPE_IO6	KLTYPE_BASEIO       /* Additional name */
-#define KLTYPE_4CHSCSI	(KLCLASS_IO  | 0x2)
-#define KLTYPE_MSCSI	KLTYPE_4CHSCSI      /* Additional name */
-#define KLTYPE_ETHERNET	(KLCLASS_IO  | 0x3)
-#define KLTYPE_MENET	KLTYPE_ETHERNET     /* Additional name */
-#define KLTYPE_FDDI  	(KLCLASS_IO  | 0x4)
-#define KLTYPE_UNUSED	(KLCLASS_IO  | 0x5) /* XXX UNUSED */
-#define KLTYPE_HAROLD   (KLCLASS_IO  | 0x6) /* PCI SHOE BOX */
-#define KLTYPE_PCI	KLTYPE_HAROLD
-#define KLTYPE_VME      (KLCLASS_IO  | 0x7) /* Any 3rd party VME card */
-#define KLTYPE_MIO   	(KLCLASS_IO  | 0x8)
-#define KLTYPE_FC    	(KLCLASS_IO  | 0x9)
-#define KLTYPE_LINC    	(KLCLASS_IO  | 0xA)
-#define KLTYPE_TPU    	(KLCLASS_IO  | 0xB) /* Tensor Processing Unit */
-#define KLTYPE_GSN_A   	(KLCLASS_IO  | 0xC) /* Main GSN board */
-#define KLTYPE_GSN_B   	(KLCLASS_IO  | 0xD) /* Auxiliary GSN board */
-#define KLTYPE_SHOEHORN (KLCLASS_IO  | 0xE)
-#define KLTYPE_SERIAL_HIPPI (KLCLASS_IO  | 0xF)
-
-#define KLTYPE_GFX	(KLCLASS_GFX | 0x0) /* unknown graphics type */
-#define KLTYPE_GFX_KONA (KLCLASS_GFX | 0x1) /* KONA graphics on IP27 */
-#define KLTYPE_GFX_MGRA (KLCLASS_GFX | 0x3) /* MGRAS graphics on IP27 */
-
-#define KLTYPE_WEIRDROUTER (KLCLASS_ROUTER | 0x0)
 #define KLTYPE_ROUTER     (KLCLASS_ROUTER | 0x1)
-#define KLTYPE_ROUTER2    KLTYPE_ROUTER		/* Obsolete! */
-#define KLTYPE_NULL_ROUTER (KLCLASS_ROUTER | 0x2)
 #define KLTYPE_META_ROUTER (KLCLASS_ROUTER | 0x3)
 #define KLTYPE_REPEATER_ROUTER (KLCLASS_ROUTER | 0x4)
 
-#define KLTYPE_WEIRDMIDPLANE (KLCLASS_MIDPLANE | 0x0)
-#define KLTYPE_MIDPLANE8  (KLCLASS_MIDPLANE | 0x1) /* 8 slot backplane */
-#define KLTYPE_MIDPLANE    KLTYPE_MIDPLANE8
-#define KLTYPE_IOBRICK_XBOW	(KLCLASS_MIDPLANE | 0x2)
-
 #define KLTYPE_IOBRICK		(KLCLASS_IOBRICK | 0x0)
-#define KLTYPE_IBRICK		(KLCLASS_IOBRICK | 0x1)
-#define KLTYPE_PBRICK		(KLCLASS_IOBRICK | 0x2)
-#define KLTYPE_XBRICK		(KLCLASS_IOBRICK | 0x3)
 #define KLTYPE_NBRICK		(KLCLASS_IOBRICK | 0x4)
-#define KLTYPE_PEBRICK		(KLCLASS_IOBRICK | 0x5)
 #define KLTYPE_PXBRICK		(KLCLASS_IOBRICK | 0x6)
 #define KLTYPE_IXBRICK		(KLCLASS_IOBRICK | 0x7)
 #define KLTYPE_CGBRICK		(KLCLASS_IOBRICK | 0x8)
+#define KLTYPE_OPUSBRICK	(KLCLASS_IOBRICK | 0x9)
 
 
-#define KLTYPE_PBRICK_BRIDGE	KLTYPE_PBRICK
-
 /* The value of type should be more than 8 so that hinv prints
  * out the board name from the NIC string. For values less than
  * 8 the name of the board needs to be hard coded in a few places.
  * When bringup started nic names had not standardized and so we
  * had to hard code. (For people interested in history.) 
  */
-#define KLTYPE_XTHD   	(KLCLASS_PSEUDO_GFX | 0x9)
-
 #define KLTYPE_UNKNOWN	(KLCLASS_UNKNOWN | 0xf)
 
 #define KLTYPE(_x) 	((_x) & KLTYPE_MASK)
-#define IS_MIO_PRESENT(l)	((l->brd_type == KLTYPE_BASEIO) && \
-				 (l->brd_flags & SECOND_NIC_PRESENT))
-#define IS_MIO_IOC3(l,n)	(IS_MIO_PRESENT(l) && (n > 2))
 
 /* 
  * board structures
@@ -418,13 +315,8 @@ typedef struct kl_config_hdr {
 
 #define MAX_COMPTS_PER_BRD 24
 
-#define LOCAL_BOARD 1
-#define REMOTE_BOARD 2
-
-#define LBOARD_STRUCT_VERSION 	2
-
 typedef struct lboard_s {
-	klconf_off_t 	brd_next;         /* Next BOARD */
+	klconf_off_t 	brd_next_any;     /* Next BOARD */
 	unsigned char 	struct_type;      /* type of structure, local or remote */
 	unsigned char 	brd_type;         /* type+class */
 	unsigned char 	brd_sversion;     /* version of this structure */
@@ -444,15 +336,16 @@ typedef struct lboard_s {
 	klconf_off_t 	brd_compts[MAX_COMPTS_PER_BRD]; /* pointers to COMPONENTS */
 	klconf_off_t 	brd_errinfo;      /* Board's error information */
 	struct lboard_s *brd_parent;	  /* Logical parent for this brd */
-	vertex_hdl_t	brd_graph_link;   /* vertex hdl to connect extern compts */
+	char            pad0[4];
 	confidence_t	brd_confidence;	  /* confidence that the board is bad */
 	nasid_t		brd_owner;        /* who owns this board */
 	unsigned char 	brd_nic_flags;    /* To handle 8 more NICs */
-	char		pad[32];	  /* future expansion */
+	char		pad1[24];	  /* future expansion */
 	char		brd_name[32];
+	nasid_t		brd_next_same_host; /* host of next brd w/same nasid */
+	klconf_off_t	brd_next_same;    /* Next BOARD with same nasid */
 } lboard_t;
 
-
 /*
  *	Make sure we pass back the calias space address for local boards.
  *	klconfig board traversal and error structure extraction defines.
@@ -462,33 +355,20 @@ typedef struct lboard_s {
 
 #define KLCF_CLASS(_brd)	KLCLASS((_brd)->brd_type)
 #define KLCF_TYPE(_brd)		KLTYPE((_brd)->brd_type)
-#define KLCF_REMOTE(_brd)  	(((_brd)->struct_type & LOCAL_BOARD) ? 0 : 1)
 #define KLCF_NUM_COMPS(_brd)	((_brd)->brd_numcompts)
 #define KLCF_MODULE_ID(_brd)	((_brd)->brd_module)
 
-#ifndef __ia64
-#define KLCF_NEXT(_brd) 		((_brd)->brd_next ? (lboard_t *)((_brd)->brd_next):  NULL)
-#define KLCF_COMP(_brd, _ndx)   \
-		(klinfo_t *)(NODE_OFFSET_TO_K0(NASID_GET(_brd), \
-						(_brd)->brd_compts[(_ndx)]))
-#define KLCF_COMP_ERROR(_brd, _comp)    \
-		(NODE_OFFSET_TO_K0(NASID_GET(_brd), (_comp)->errinfo))
-
-#else
-
 #define NODE_OFFSET_TO_KLINFO(n,off)    ((klinfo_t*) TO_NODE_CAC(n,off))
 #define KLCF_NEXT(_brd)         \
-        ((_brd)->brd_next ?     \
-         (NODE_OFFSET_TO_LBOARD(NASID_GET(_brd), (_brd)->brd_next)): NULL)
+        ((_brd)->brd_next_same ?     \
+         (NODE_OFFSET_TO_LBOARD((_brd)->brd_next_same_host, (_brd)->brd_next_same)): NULL)
+#define KLCF_NEXT_ANY(_brd)         \
+        ((_brd)->brd_next_any ?     \
+         (NODE_OFFSET_TO_LBOARD(NASID_GET(_brd), (_brd)->brd_next_any)): NULL)
 #define KLCF_COMP(_brd, _ndx)   \
                 ((((_brd)->brd_compts[(_ndx)]) == 0) ? 0 : \
 			(NODE_OFFSET_TO_KLINFO(NASID_GET(_brd), (_brd)->brd_compts[(_ndx)])))
 
-#define KLCF_COMP_ERROR(_brd, _comp)    \
-                (NODE_OFFSET_TO_K0(NASID_GET(_brd), (_comp)->errinfo))
-
-#endif /* __ia64 */
-
 #define KLCF_COMP_TYPE(_comp)	((_comp)->struct_type)
 #define KLCF_BRIDGE_W_ID(_comp)	((_comp)->physid)	/* Widget ID */
 
@@ -515,7 +395,7 @@ typedef struct klinfo_s {               
 	nasid_t		nasid;            /* node number - from parent */
 	char		pad1;		  /* pad out structure. */
 	char		pad2;		  /* pad out structure. */
-	COMPONENT	*arcs_compt;      /* ptr to the arcs struct for ease*/
+	void		*data;
         klconf_off_t	errinfo;          /* component specific errors */
         unsigned short  pad3;             /* pci fields have moved over to */
         unsigned short  pad4;             /* klbri_t */
@@ -537,36 +417,14 @@ typedef struct klinfo_s {               
 #define KLSTRUCT_MEMBNK 	3
 #define KLSTRUCT_XBOW 		4
 #define KLSTRUCT_BRI 		5
-#define KLSTRUCT_IOC3 		6
-#define KLSTRUCT_PCI 		7
-#define KLSTRUCT_VME 		8
 #define KLSTRUCT_ROU		9
 #define KLSTRUCT_GFX 		10
 #define KLSTRUCT_SCSI 		11
-#define KLSTRUCT_FDDI 		12
-#define KLSTRUCT_MIO 		13
 #define KLSTRUCT_DISK 		14
-#define KLSTRUCT_TAPE 		15
 #define KLSTRUCT_CDROM 		16
-#define KLSTRUCT_HUB_UART 	17
-#define KLSTRUCT_IOC3ENET 	18
-#define KLSTRUCT_IOC3UART 	19
-#define KLSTRUCT_UNUSED		20 /* XXX UNUSED */
-#define KLSTRUCT_IOC3PCKM       21
-#define KLSTRUCT_RAD        	22
-#define KLSTRUCT_HUB_TTY        23
-#define KLSTRUCT_IOC3_TTY 	24
-
-/* Early Access IO proms are compatible
-   only with KLSTRUCT values upto 24. */
 
 #define KLSTRUCT_FIBERCHANNEL 	25
 #define KLSTRUCT_MOD_SERIAL_NUM 26
-#define KLSTRUCT_IOC3MS         27
-#define KLSTRUCT_TPU            28
-#define KLSTRUCT_GSN_A          29
-#define KLSTRUCT_GSN_B          30
-#define KLSTRUCT_XTHD           31
 #define KLSTRUCT_QLFIBRE        32
 #define KLSTRUCT_1394           33
 #define KLSTRUCT_USB		34
@@ -576,36 +434,14 @@ typedef struct klinfo_s {               
 #define KLSTRUCT_PEBRICK	38
 #define KLSTRUCT_GIGE           39
 #define KLSTRUCT_IDE		40
+#define KLSTRUCT_IOC4		41
+#define KLSTRUCT_IOC4UART	42
+#define KLSTRUCT_IOC4_TTY	43
+#define KLSTRUCT_IOC4PCKM	44
+#define KLSTRUCT_IOC4MS		45
+#define KLSTRUCT_IOC4_ATA	46
+#define KLSTRUCT_PCIGFX		47
 
-/*
- * These are the indices of various components within a lboard structure.
- */
-
-#define IP27_CPU0_INDEX 0
-#define IP27_CPU1_INDEX 1
-#define IP27_HUB_INDEX 2
-#define IP27_MEM_INDEX 3
-
-#define BASEIO_BRIDGE_INDEX 0
-#define BASEIO_IOC3_INDEX 1
-#define BASEIO_SCSI1_INDEX 2
-#define BASEIO_SCSI2_INDEX 3
-
-#define MIDPLANE_XBOW_INDEX 0
-#define ROUTER_COMPONENT_INDEX 0
-
-#define CH4SCSI_BRIDGE_INDEX 0
-
-/* Info holders for various hardware components */
-
-typedef u64 *pci_t;
-typedef u64 *vmeb_t;
-typedef u64 *vmed_t;
-typedef u64 *fddi_t;
-typedef u64 *scsi_t;
-typedef u64 *mio_t;
-typedef u64 *graphics_t;
-typedef u64 *router_t;
 
 /*
  * The port info in ip27_cfg area translates to a lboart_t in the 
@@ -634,7 +470,7 @@ typedef struct klcpu_s {                
 
 typedef struct klhub_s {			/* HUB */
 	klinfo_t 	hub_info;
-	uint 		hub_flags;		/* PCFG_HUB_xxx flags */
+	unsigned int 	hub_flags;		/* PCFG_HUB_xxx flags */
 #define MAX_NI_PORTS                    2
 	klport_t	hub_port[MAX_NI_PORTS + 1];/* hub is connected to this */
 	nic_t		hub_box_nic;		/* nic of containing box */
@@ -646,7 +482,7 @@ typedef struct klhub_s {			/* HUB */
 
 typedef struct klhub_uart_s {			/* HUB */
 	klinfo_t 	hubuart_info;
-	uint 		hubuart_flags;		/* PCFG_HUB_xxx flags */
+	unsigned int 	hubuart_flags;		/* PCFG_HUB_xxx flags */
 	nic_t		hubuart_box_nic;	/* nic of containing box */
 	unsigned long	pad;
 } klhub_uart_t ;
@@ -662,14 +498,6 @@ typedef struct klmembnk_s {			/* MEMORY 
 	unsigned long	pad;
 } klmembnk_t ;
 
-#define KLCONFIG_MEMBNK_SIZE(_info, _bank)	\
-                            ((_info)->membnk_bnksz[(_bank)])
-
-
-#define MEMBNK_PREMIUM 1
-#define KLCONFIG_MEMBNK_PREMIUM(_info, _bank)	\
-                            ((_info)->membnk_attr & (MEMBNK_PREMIUM << (_bank)))
-
 #define MAX_SERIAL_NUM_SIZE 10
 
 typedef struct klmod_serial_num_s {
@@ -712,48 +540,18 @@ typedef struct klbri_s {                
 	klinfo_t 	bri_info ;
     	unsigned char	bri_eprominfo ;    /* IO6prom connected to bridge */
     	unsigned char	bri_bustype ;      /* PCI/VME BUS bridge/GIO */
-    	pci_t    	pci_specific  ;    /* PCI Board config info */
+    	u64	    	*pci_specific  ;    /* PCI Board config info */
 	klpci_device_t	bri_devices[MAX_PCI_DEVS] ;	/* PCI IDs */
 	klconf_off_t	bri_mfg_nic ;
 	unsigned long	pad;
 } klbri_t ;
 
-#define MAX_IOC3_TTY	2
-
-typedef struct klioc3_s {                          /* IOC3 */
-	klinfo_t 	ioc3_info ;
-    	unsigned char	ioc3_ssram ;        /* Info about ssram */
-    	unsigned char	ioc3_nvram ;        /* Info about nvram */
-    	klinfo_t	ioc3_superio ;      /* Info about superio */
-	klconf_off_t	ioc3_tty_off ;
-	klinfo_t	ioc3_enet ;
-	klconf_off_t	ioc3_enet_off ;
-	klconf_off_t	ioc3_kbd_off ;
-	unsigned long	pad;
-} klioc3_t ;
-
-#define MAX_VME_SLOTS 8
-
-typedef struct klvmeb_s {                          /* VME BRIDGE - PCI CTLR */
-	klinfo_t 	vmeb_info ;
-	vmeb_t		vmeb_specific ;
-    	klconf_off_t   	vmeb_brdinfo[MAX_VME_SLOTS]   ;    /* VME Board config info */
-	unsigned long	pad;
-} klvmeb_t ;
-
-typedef struct klvmed_s {                          /* VME DEVICE - VME BOARD */
-	klinfo_t	vmed_info ;
-	vmed_t		vmed_specific ;
-    	klconf_off_t   	vmed_brdinfo[MAX_VME_SLOTS]   ;    /* VME Board config info */
-	unsigned long	pad;
-} klvmed_t ;
-
 #define ROUTER_VECTOR_VERS	2
 
 /* XXX - Don't we need the number of ports here?!? */
 typedef struct klrou_s {                          /* ROUTER */
 	klinfo_t 	rou_info ;
-	uint		rou_flags ;           /* PCFG_ROUTER_xxx flags */
+	unsigned int	rou_flags ;           /* PCFG_ROUTER_xxx flags */
 	nic_t		rou_box_nic ;         /* nic of the containing module */
     	klport_t 	rou_port[MAX_ROUTER_PORTS + 1] ; /* array index 1 to 6 */
 	klconf_off_t	rou_mfg_nic ;     /* MFG NIC string */
@@ -777,32 +575,15 @@ typedef struct klgfx_s {		/* GRAPHICS De
 	klinfo_t 	gfx_info;
 	klconf_off_t    old_gndevs;	/* for compatibility with older proms */
 	klconf_off_t    old_gdoff0;	/* for compatibility with older proms */
-	uint		cookie;		/* for compatibility with older proms */
-	uint		moduleslot;
+	unsigned int	cookie;		/* for compatibility with older proms */
+	unsigned int	moduleslot;
 	struct klgfx_s	*gfx_next_pipe;
-	graphics_t	gfx_specific;
+	u64		*gfx_specific;
 	klconf_off_t    pad0;		/* for compatibility with older proms */
 	klconf_off_t    gfx_mfg_nic;
 	unsigned long	pad;
 } klgfx_t;
 
-typedef struct klxthd_s {   
-	klinfo_t 	xthd_info ;
-	klconf_off_t	xthd_mfg_nic ;        /* MFG NIC string */
-	unsigned long	pad;
-} klxthd_t ;
-
-typedef struct kltpu_s {                     /* TPU board */
-	klinfo_t 	tpu_info ;
-	klconf_off_t	tpu_mfg_nic ;        /* MFG NIC string */
-	unsigned long	pad;
-} kltpu_t ;
-
-typedef struct klgsn_s {                     /* GSN board */
-	klinfo_t 	gsn_info ;
-	klconf_off_t	gsn_mfg_nic ;        /* MFG NIC string */
-} klgsn_t ;
-
 #define MAX_SCSI_DEVS 16
 
 /*
@@ -814,7 +595,7 @@ typedef struct klgsn_s {                
 
 typedef struct klscsi_s {                          /* SCSI Bus */
 	klinfo_t 	scsi_info ;
-    	scsi_t       	scsi_specific   ; 
+    	u64       	*scsi_specific   ; 
 	unsigned char 	scsi_numdevs ;
 	klconf_off_t	scsi_devinfo[MAX_SCSI_DEVS] ; 
 	unsigned long	pad;
@@ -822,8 +603,8 @@ typedef struct klscsi_s {               
 
 typedef struct klscctl_s {                          /* SCSI Controller */
 	klinfo_t 	scsi_info ;
-	uint		type;
-	uint		scsi_buscnt;                        /* # busses this cntlr */
+	unsigned int	type;
+	unsigned int	scsi_buscnt;                        /* # busses this cntlr */
 	void		*scsi_bus[2];                       /* Pointer to 2 klscsi_t's */
 	unsigned long	pad;
 } klscctl_t ;
@@ -840,11 +621,9 @@ typedef struct klttydev_s {             
 	unsigned long	pad;
 } klttydev_t ;
 
-typedef struct klenetdev_s {                          /* ENET device */
-	klinfo_t 	enetdev_info ;
-	struct net_data *enetdev_cfg ; /* driver fills up this */
-	unsigned long	pad;
-} klenetdev_t ;
+typedef struct klpcigfx_s {                          /* PCI GFX */
+        klinfo_t        gfx_info ;
+} klpcigfx_t ;
 
 typedef struct klkbddev_s {                          /* KBD device */
 	klinfo_t 	kbddev_info ;
@@ -858,21 +637,6 @@ typedef struct klmsdev_s {              
 	unsigned long	pad;
 } klmsdev_t ;
 
-#define MAX_FDDI_DEVS 10 /* XXX Is this true */
-
-typedef struct klfddi_s {                          /* FDDI */
-	klinfo_t 	fddi_info ;
-    	fddi_t        	fddi_specific ;       
-	klconf_off_t	fddi_devinfo[MAX_FDDI_DEVS] ;
-	unsigned long	pad;
-} klfddi_t ;
-
-typedef struct klmio_s {                          /* MIO */
-	klinfo_t 	mio_info ;
-    	mio_t       	mio_specific   ; 
-	unsigned long	pad;
-} klmio_t ;
-
 /*
  * USB info
  */
@@ -890,16 +654,11 @@ typedef union klcomp_s {
 	klmembnk_t 	kc_mem;
 	klxbow_t  	kc_xbow;
 	klbri_t		kc_bri;
-	klioc3_t	kc_ioc3;
-	klvmeb_t	kc_vmeb;
-	klvmed_t	kc_vmed;
 	klrou_t		kc_rou;
 	klgfx_t		kc_gfx;
 	klscsi_t	kc_scsi;
 	klscctl_t	kc_scsi_ctl;
 	klscdev_t	kc_scsi_dev;
-	klfddi_t	kc_fddi;
-	klmio_t		kc_mio;
 	klmod_serial_num_t kc_snum ;
 	klusb_t		kc_usb;
 } klcomp_t;
@@ -907,58 +666,12 @@ typedef union klcomp_s {
 typedef union kldev_s {      /* for device structure allocation */
 	klscdev_t	kc_scsi_dev ;
 	klttydev_t	kc_tty_dev ;
-	klenetdev_t	kc_enet_dev ;
 	klkbddev_t 	kc_kbd_dev ;
 } kldev_t ;
 
-/* Data structure interface routines. TBD */
-
-/* Include launch info in this file itself? TBD */
-
-/*
- * TBD - Can the ARCS and device driver related info also be included in the
- * KLCONFIG area. On the IO4PROM, prom device driver info is part of cfgnode_t 
- * structure, viz private to the IO4prom.
- */
-
-/* 
- * TBD - Allocation issues. 
- *
- * Do we need to Mark off sepatate heaps for lboard_t, rboard_t, component, 
- * errinfo and allocate from them, or have a single heap and allocate all 
- * structures from it. Debug is easier in the former method since we can
- * dump all similar structs in one command, but there will be lots of holes, 
- * in memory and max limits are needed for number of structures.
- * Another way to make it organized, is to have a union of all components
- * and allocate a aligned chunk of memory greater than the biggest
- * component.
- */
-
-typedef union {
-	lboard_t *lbinfo ;
-} biptr_t ;
-
-
-#define BRI_PER_XBOW 6
-#define PCI_PER_BRI  8
-#define DEV_PER_PCI  16
-
-
-/* Virtual dipswitch values (starting from switch "7"): */
-
-#define VDS_NOGFX		0x8000	/* Don't enable gfx and autoboot */
-#define VDS_NOMP		0x100	/* Don't start slave processors */
-#define VDS_MANUMODE		0x80	/* Manufacturing mode */
-#define VDS_NOARB		0x40	/* No bootmaster arbitration */
-#define VDS_PODMODE		0x20	/* Go straight to POD mode */
-#define VDS_NO_DIAGS		0x10	/* Don't run any diags after BM arb */
-#define VDS_DEFAULTS		0x08	/* Use default environment values */
-#define VDS_NOMEMCLEAR		0x04	/* Don't run mem cfg code */
-#define VDS_2ND_IO4		0x02	/* Boot from the second IO4 */
-#define VDS_DEBUG_PROM		0x01	/* Print PROM debugging messages */
-
 /* external declarations of Linux kernel functions. */
 
+extern lboard_t *root_lboard[];
 extern lboard_t *find_lboard(lboard_t *start, unsigned char type);
 extern klinfo_t *find_component(lboard_t *brd, klinfo_t *kli, unsigned char type);
 extern klinfo_t *find_first_component(lboard_t *brd, unsigned char type);
@@ -976,7 +689,6 @@ extern int	config_find_nic_hub(nasid_t, 
 extern int	config_find_xbow(nasid_t, lboard_t **, klxbow_t**);
 extern int 	update_klcfg_cpuinfo(nasid_t, int);
 extern void 	board_to_path(lboard_t *brd, char *path);
-extern moduleid_t get_module_id(nasid_t nasid);
 extern void 	nic_name_convert(char *old_name, char *new_name);
 extern int 	module_brds(nasid_t nasid, lboard_t **module_brds, int n);
 extern lboard_t *brd_from_key(uint64_t key);
diff -puN include/asm-ia64/sn/ksys/elsc.h~linus include/asm-ia64/sn/ksys/elsc.h
--- 25/include/asm-ia64/sn/ksys/elsc.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/ksys/elsc.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,13 +1,12 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * Copyright (C) 1992-1997, 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  */
-#ifndef _ASM_SN_KSYS_ELSC_H
-#define _ASM_SN_KSYS_ELSC_H
+#ifndef _ASM_IA64_SN_KSYS_ELSC_H
+#define _ASM_IA64_SN_KSYS_ELSC_H
 
 /*
  * Error codes
@@ -37,4 +36,4 @@
 #define ELSC_ERROR_NVMAGIC	       (-124)	/* Bad magic no. in NVRAM   */
 #define ELSC_ERROR_MODULE	       (-125)	/* Moduleid processing err  */
 
-#endif /* _ASM_SN_KSYS_ELSC_H */
+#endif /* _ASM_IA64_SN_KSYS_ELSC_H */
diff -puN include/asm-ia64/sn/ksys/l1.h~linus include/asm-ia64/sn/ksys/l1.h
--- 25/include/asm-ia64/sn/ksys/l1.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/ksys/l1.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -7,8 +6,8 @@
  * Copyright (C) 1992-1997,2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  */
 
-#ifndef _ASM_SN_KSYS_L1_H
-#define _ASM_SN_KSYS_L1_H
+#ifndef _ASM_IA64_SN_KSYS_L1_H
+#define _ASM_IA64_SN_KSYS_L1_H
 
 #include <asm/sn/types.h>
 
@@ -88,17 +87,23 @@
 					   command string */
 
 /* brick type response codes */
+#define L1_BRICKTYPE_PX         0x23            /* # */
+#define L1_BRICKTYPE_PE         0x25            /* % */
+#define L1_BRICKTYPE_N_p0       0x26            /* & */
 #define L1_BRICKTYPE_IP45       0x34            /* 4 */
-#define L1_BRICKTYPE_C          0x43            /* C */
-#define L1_BRICKTYPE_I          0x49            /* I */
-#define L1_BRICKTYPE_P          0x50            /* P */
-#define L1_BRICKTYPE_R          0x52            /* R */
-#define L1_BRICKTYPE_X          0x58            /* X */
-#define L1_BRICKTYPE_X2         0x59            /* Y */
-#define L1_BRICKTYPE_N          0x4e            /* N */
-#define L1_BRICKTYPE_PE		0x25		/* % */
-#define L1_BRICKTYPE_PX		0x23		/* # */
-#define L1_BRICKTYPE_IX		0x3d		/* = */
+#define L1_BRICKTYPE_IP41       0x35            /* 5 */
+#define L1_BRICKTYPE_TWISTER    0x36            /* 6 */ /* IP53 & ROUTER */
+#define L1_BRICKTYPE_IX         0x3d            /* = */
+#define L1_BRICKTYPE_IP34       0x61            /* a */
+#define L1_BRICKTYPE_C          0x63            /* c */
+#define L1_BRICKTYPE_I          0x69            /* i */
+#define L1_BRICKTYPE_N          0x6e            /* n */
+#define L1_BRICKTYPE_OPUS       0x6f		/* o */
+#define L1_BRICKTYPE_P          0x70            /* p */
+#define L1_BRICKTYPE_R          0x72            /* r */
+#define L1_BRICKTYPE_CHI_CG     0x76            /* v */
+#define L1_BRICKTYPE_X          0x78            /* x */
+#define L1_BRICKTYPE_X2         0x79            /* y */
 
 /* EEPROM codes (for the "read EEPROM" request) */
 /* c brick */
@@ -130,7 +135,7 @@
 int	elsc_display_line(nasid_t nasid, char *line, int lnum);
 int	iobrick_rack_bay_type_get( nasid_t nasid, unsigned int *rack,
 				   unsigned int *bay, unsigned int *brick_type );
-int	iobrick_module_get( nasid_t nasid );
+int	iomoduleid_get( nasid_t nasid );
 
 
-#endif /* _ASM_SN_KSYS_L1_H */
+#endif /* _ASM_IA64_SN_KSYS_L1_H */
diff -puN include/asm-ia64/sn/labelcl.h~linus include/asm-ia64/sn/labelcl.h
--- 25/include/asm-ia64/sn/labelcl.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/labelcl.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -15,20 +14,6 @@
 #define INFO_DESC_EXPORT  0       	/* export info itself */
 
 /*
- * Internal Error codes.
- */
-typedef enum labelcl_error_e {  LABELCL_SUCCESS,          /* 0 */
-                                LABELCL_DUP,              /* 1 */
-                                LABELCL_NOT_FOUND,        /* 2 */
-                                LABELCL_BAD_PARAM,        /* 3 */
-                                LABELCL_HIT_LIMIT,        /* 4 */
-                                LABELCL_CANNOT_ALLOC,     /* 5 */
-                                LABELCL_ILLEGAL_REQUEST,  /* 6 */
-                                LABELCL_IN_USE            /* 7 */
-                                } labelcl_error_t;
-
-
-/*
  * Description of a label entry.
  */
 typedef struct label_info_s {
diff -puN include/asm-ia64/sn/module.h~linus include/asm-ia64/sn/module.h
--- 25/include/asm-ia64/sn/module.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/module.h	2004-01-19 22:17:24.000000000 -0800
@@ -30,6 +30,7 @@ extern "C" {
 /* parameter for format_module_id() */
 #define MODULE_FORMAT_BRIEF	1
 #define MODULE_FORMAT_LONG	2
+#define MODULE_FORMAT_LCD	3
 
 /*
  *	Module id format
@@ -138,6 +139,8 @@ extern char brick_types[];
 #define MODULE_PEBRICK          8
 #define MODULE_PXBRICK          9
 #define MODULE_IXBRICK          10
+#define MODULE_CGBRICK		11
+#define MODULE_OPUSBRICK        12
 
 /*
  * Moduleid_t comparison macros
@@ -164,7 +167,6 @@ struct module_s {
     /* Fields for Module System Controller */
     int			mesgpend;	/* Message pending                 */
     int			shutdown;	/* Shutdown in progress            */
-    struct semaphore	thdcnt;		/* Threads finished counter        */
     time_t		intrhist[MODULE_HIST_CNT];
     int			histptr;
 
diff -puN -L include/asm-ia64/sn/nag.h include/asm-ia64/sn/nag.h~linus /dev/null
--- 25/include/asm-ia64/sn/nag.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,32 +0,0 @@
-/*
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (c) 2001-2003 Silicon Graphics, Inc.  All rights reserved.
-*/
-
-
-#ifndef _ASM_IA64_SN_NAG_H
-#define _ASM_IA64_SN_NAG_H
-
-
-#define NAG(mesg...) \
-do {										\
-	static unsigned int how_broken = 1;					\
-	static unsigned int threshold = 1;					\
-	if (how_broken == threshold) {						\
-		if (threshold < 10000)						\
-			threshold *= 10;					\
-		if (how_broken > 1)						\
-			printk(KERN_WARNING "%u times: ", how_broken);		\
-		else								\
-			printk(KERN_WARNING);					\
-		printk(mesg);							\
-	}									\
-	how_broken++;								\
-} while (0)
-
-
-#endif /* _ASM_IA64_SN_NAG_H */
diff -puN include/asm-ia64/sn/nodepda.h~linus include/asm-ia64/sn/nodepda.h
--- 25/include/asm-ia64/sn/nodepda.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/nodepda.h	2004-01-19 22:17:24.000000000 -0800
@@ -12,7 +12,6 @@
 #include <linux/config.h>
 #include <asm/sn/sgi.h>
 #include <asm/irq.h>
-#include <asm/topology.h>
 #include <asm/sn/intr.h>
 #include <asm/sn/router.h>
 #include <asm/sn/pda.h>
@@ -66,6 +65,8 @@ struct nodepda_s {
 	nodepda_router_info_t	**npda_rip_last;
 
 
+	spinlock_t		bist_lock;
+
 	/*
 	 * The BTEs on this node are shared by the local cpus
 	 */
diff -puN include/asm-ia64/sn/pci/bridge.h~linus include/asm-ia64/sn/pci/bridge.h
--- 25/include/asm-ia64/sn/pci/bridge.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/pci/bridge.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -38,7 +37,6 @@
 #include <asm/sn/xtalk/xwidget.h>
 #include <asm/sn/pci/pic.h>
 
-extern int io_get_sh_swapper(nasid_t);
 #define BRIDGE_REG_GET32(reg) \
                 __swab32( *(volatile uint32_t *) (((uint64_t)reg)^4) )
 
@@ -47,11 +45,11 @@ extern int io_get_sh_swapper(nasid_t);
 
 /* I/O page size */
 
-#if _PAGESZ == 4096
+#if PAGE_SIZE == 4096
 #define IOPFNSHIFT		12	/* 4K per mapped page */
 #else
 #define IOPFNSHIFT		14	/* 16K per mapped page */
-#endif				/* _PAGESZ */
+#endif				/* PAGE_SIZE */
 
 #define IOPGSIZE		(1 << IOPFNSHIFT)
 #define IOPG(x)			((x) >> IOPFNSHIFT)
@@ -917,12 +915,8 @@ typedef volatile struct bridge_s {
 
 #define PCIBR_TYPE1_CFG(ps)         PCIBRIDGE_TYPE1_CFG((ps)->bs_busnum)
 #define PCIBR_BUS_TYPE0_CFG_DEV0(ps) PCIBR_TYPE0_CFG_DEV(ps, 0)
-#define PCIBR_TYPE0_CFG_DEV(ps, s) \
-    ((IS_PIC_SOFT(ps)) ? PCIBRIDGE_TYPE0_CFG_DEV((ps)->bs_busnum, s+1) : \
-		  	     PCIBRIDGE_TYPE0_CFG_DEV((ps)->bs_busnum, s))
-#define PCIBR_BUS_TYPE0_CFG_DEVF(ps,s,f) \
-    ((IS_PIC_SOFT(ps)) ? PCIBRIDGE_TYPE0_CFG_DEVF((ps)->bs_busnum,(s+1),f) : \
-			     PCIBRIDGE_TYPE0_CFG_DEVF((ps)->bs_busnum,s,f))
+#define PCIBR_TYPE0_CFG_DEV(ps, s) PCIBRIDGE_TYPE0_CFG_DEV((ps)->bs_busnum, s+1)
+#define PCIBR_BUS_TYPE0_CFG_DEVF(ps,s,f) PCIBRIDGE_TYPE0_CFG_DEVF((ps)->bs_busnum,(s+1),f)
 
 #endif				/* LANGUAGE_C */
 
diff -puN include/asm-ia64/sn/pci/pcibr.h~linus include/asm-ia64/sn/pci/pcibr.h
--- 25/include/asm-ia64/sn/pci/pcibr.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/pci/pcibr.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,13 +1,12 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * Copyright (C) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
  */
-#ifndef _ASM_SN_PCI_PCIBR_H
-#define _ASM_SN_PCI_PCIBR_H
+#ifndef _ASM_IA64_SN_PCI_PCIBR_H
+#define _ASM_IA64_SN_PCI_PCIBR_H
 
 #if defined(__KERNEL__)
 
@@ -212,9 +211,6 @@ extern void		pcibr_config_set(vertex_hdl
 					 unsigned size,
 					 uint64_t value);
 
-extern int		pcibr_error_devenable(vertex_hdl_t pconn_vhdl,
-					      int error_code);
-
 extern int		pcibr_wrb_flush(vertex_hdl_t pconn_vhdl);
 extern int		pcibr_rrb_check(vertex_hdl_t pconn_vhdl,
 					int *count_vchan0,
@@ -238,7 +234,7 @@ void			pcibr_set_rrb_callback(vertex_hdl
 					       rrb_alloc_funct_f *func);
 
 extern int		pcibr_device_unregister(vertex_hdl_t);
-extern int		pcibr_dma_enabled(vertex_hdl_t);
+
 /*
  * Bridge-specific flags that can be set via pcibr_device_flags_set
  * and cleared via pcibr_device_flags_clear.  Other flags are
@@ -422,7 +418,7 @@ struct pcibr_slot_info_resp_s {
     int                     resp_bss_ninfo;
     char                    resp_bss_devio_bssd_space[16];
     iopaddr_t               resp_bss_devio_bssd_base; 
-    bridgereg_t             resp_bss_device;
+    uint64_t		    resp_bss_device;
     int                     resp_bss_pmu_uctr;
     int                     resp_bss_d32_uctr;
     int                     resp_bss_d64_uctr;
@@ -430,7 +426,7 @@ struct pcibr_slot_info_resp_s {
     unsigned                resp_bss_d64_flags;
     iopaddr_t               resp_bss_d32_base;
     unsigned                resp_bss_d32_flags;
-    atomic_t                resp_bss_ext_ates_active;
+    atomic_t		    resp_bss_ext_ates_active;
     volatile unsigned      *resp_bss_cmd_pointer;
     unsigned                resp_bss_cmd_shadow;
     int                     resp_bs_rrb_valid;
@@ -438,10 +434,10 @@ struct pcibr_slot_info_resp_s {
     int                     resp_bs_rrb_valid_v2;
     int                     resp_bs_rrb_valid_v3;
     int                     resp_bs_rrb_res;
-    bridgereg_t             resp_b_resp;
-    bridgereg_t             resp_b_int_device;
-    bridgereg_t             resp_b_int_enable;
-    bridgereg_t             resp_b_int_host;
+    uint64_t		    resp_b_resp;
+    uint64_t		    resp_b_int_device;
+    uint64_t		    resp_b_int_enable;
+    uint64_t		    resp_b_int_host;
     picreg_t		    resp_p_int_enable;
     picreg_t		    resp_p_int_host;
     struct pcibr_slot_func_info_resp_s {
@@ -508,4 +504,4 @@ struct pcibr_slot_info_resp_s {
 /* ERANGE                        34    */
 /* EUNATCH                       42    */
 
-#endif				/* _ASM_SN_PCI_PCIBR_H */
+#endif				/* _ASM_IA64_SN_PCI_PCIBR_H */
diff -puN include/asm-ia64/sn/pci/pcibr_private.h~linus include/asm-ia64/sn/pci/pcibr_private.h
--- 25/include/asm-ia64/sn/pci/pcibr_private.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/pci/pcibr_private.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,13 +1,12 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
  */
-#ifndef _ASM_SN_PCI_PCIBR_PRIVATE_H
-#define _ASM_SN_PCI_PCIBR_PRIVATE_H
+#ifndef _ASM_IA64_SN_PCI_PCIBR_PRIVATE_H
+#define _ASM_IA64_SN_PCI_PCIBR_PRIVATE_H
 
 /*
  * pcibr_private.h -- private definitions for pcibr
@@ -44,6 +43,10 @@ cfg_p pcibr_slot_config_addr(bridge_t *,
 cfg_p pcibr_func_config_addr(bridge_t *, pciio_bus_t bus, pciio_slot_t, pciio_function_t, int);
 unsigned pcibr_slot_config_get(bridge_t *, pciio_slot_t, int);
 unsigned pcibr_func_config_get(bridge_t *, pciio_slot_t, pciio_function_t, int);
+extern void pcireg_intr_enable_bit_clr(void *, uint64_t);
+extern void pcireg_intr_enable_bit_set(void *, uint64_t);
+extern void pcireg_intr_addr_addr_set(void *, int, uint64_t);
+extern void pcireg_force_intr_set(void *, int);
 void pcibr_debug(uint32_t, vertex_hdl_t, char *, ...);
 void pcibr_slot_config_set(bridge_t *, pciio_slot_t, int, unsigned);
 void pcibr_func_config_set(bridge_t *, pciio_slot_t, pciio_function_t, int, 
@@ -90,7 +93,7 @@ extern uint32_t pcibr_debug_mask;
  * set, then the overhead for this macro is just an extra 'if' check.
  */
 /* For high frequency events (ie. map allocation, direct translation,...) */
-#if 1 || DEBUG
+#if DEBUG
 #define PCIBR_DEBUG(args) PCIBR_DEBUG_ALWAYS(args)
 #else	/* DEBUG */
 #define PCIBR_DEBUG(args)
@@ -163,8 +166,8 @@ struct pcibr_intr_s {
 #define	bi_flags	bi_pi.pi_flags	/* PCIBR_INTR flags */
 #define	bi_dev		bi_pi.pi_dev	/* associated pci card */
 #define	bi_lines	bi_pi.pi_lines	/* which PCI interrupt line(s) */
-#define bi_func		bi_pi.pi_func	/* handler function (when connected) */
-#define bi_arg		bi_pi.pi_arg	/* handler parameter (when connected) */
+#define	bi_func		bi_pi.pi_func	/* handler function (when connected) */
+#define	bi_arg		bi_pi.pi_arg	/* handler parameter (when connected) */
 #define bi_mustruncpu	bi_pi.pi_mustruncpu /* Where we must run. */
 #define bi_irq		bi_pi.pi_irq	/* IRQ assigned. */
 #define bi_cpu		bi_pi.pi_cpu	/* cpu assigned. */
@@ -200,14 +203,10 @@ struct pcibr_intr_s {
 #define PCIBR_INFO_SLOT_GET_INT(info)	    (((pcibr_info_t)info)->f_dev)
 
 #define PCIBR_DEVICE_TO_SLOT(pcibr_soft, dev_num) \
-	(((dev_num) != PCIIO_SLOT_NONE) ? \
-	    (IS_PIC_SOFT((pcibr_soft)) ? ((dev_num) + 1) : (dev_num)) : \
-	    PCIIO_SLOT_NONE)
+	(((dev_num) != PCIIO_SLOT_NONE) ? ((dev_num) + 1) : PCIIO_SLOT_NONE)
 
 #define PCIBR_SLOT_TO_DEVICE(pcibr_soft, slot) \
-        (((slot) != PCIIO_SLOT_NONE) ? \
-            (IS_PIC_SOFT((pcibr_soft)) ? ((slot) - 1) : (slot)) : \
-            PCIIO_SLOT_NONE)
+        (((slot) != PCIIO_SLOT_NONE) ? ((slot) - 1) : PCIIO_SLOT_NONE)
 
 /*
  * per-connect point pcibr data, including standard pciio data in-line:
@@ -225,11 +224,11 @@ struct pcibr_info_s {
 #define	f_pops		f_c.c_pops	/* cached provider from c_master */
 #define	f_efunc		f_c.c_efunc	/* error handling function */
 #define	f_einfo		f_c.c_einfo	/* first parameter for efunc */
-#define f_window        f_c.c_window    /* state of BASE regs */
+#define	f_window	f_c.c_window	/* state of BASE regs */
 #define	f_rwindow	f_c.c_rwindow	/* expansion ROM BASE regs */
 #define	f_rbase		f_c.c_rbase	/* expansion ROM base */
 #define	f_rsize		f_c.c_rsize	/* expansion ROM size */
-#define f_piospace      f_c.c_piospace  /* additional I/O spaces allocated */
+#define	f_piospace	f_c.c_piospace	/* additional I/O spaces allocated */
 
     /* pcibr-specific connection state */
     int			    f_ibit[4];	/* Bridge bit for each INTx */
@@ -276,9 +275,9 @@ struct pcibr_intr_wrap_s {
 #define PCIBR_BUS_IO_MAX       0x0FFFFFFF
 #define PCIBR_BUS_IO_PAGE      0x100000
 
-#define PCIBR_BUS_SWIN_BASE    _PAGESZ
+#define PCIBR_BUS_SWIN_BASE    PAGE_SIZE
 #define PCIBR_BUS_SWIN_MAX     0x000FFFFF
-#define PCIBR_BUS_SWIN_PAGE    _PAGESZ
+#define PCIBR_BUS_SWIN_PAGE    PAGE_SIZE
 
 #define PCIBR_BUS_MEM_BASE     0x200000
 #define PCIBR_BUS_MEM_MAX      0x3FFFFFFF
@@ -288,12 +287,7 @@ struct pcibr_intr_wrap_s {
 #define PCIBR_BRIDGETYPE_BRIDGE		0
 #define PCIBR_BRIDGETYPE_XBRIDGE	1
 #define PCIBR_BRIDGETYPE_PIC		2
-#define IS_XBRIDGE_SOFT(ps) (ps->bs_bridge_type == PCIBR_BRIDGETYPE_XBRIDGE)
-#define IS_PIC_SOFT(ps)     (ps->bs_bridge_type == PCIBR_BRIDGETYPE_PIC)
-#define IS_PIC_BUSNUM_SOFT(ps, bus)	\
-		(IS_PIC_SOFT(ps) && ((ps)->bs_busnum == (bus)))
-#define IS_BRIDGE_SOFT(ps)  (ps->bs_bridge_type == PCIBR_BRIDGETYPE_BRIDGE)
-#define IS_XBRIDGE_OR_PIC_SOFT(ps) (IS_XBRIDGE_SOFT(ps) || IS_PIC_SOFT(ps))
+#define IS_PIC_BUSNUM_SOFT(ps, bus)	((ps)->bs_busnum == (bus))
 
 /*
  * Runtime checks for workarounds.
@@ -302,11 +296,13 @@ struct pcibr_intr_wrap_s {
 	((1 << XWIDGET_PART_REV_NUM_REV(pcibr_soft->bs_rev_num)) & pv)
 /*
  * Defines for individual WARs. Each is a bitmask of applicable
- * part revision numbers. (1 << 1) == rev A, (1 << 2) == rev B, etc.
+ * part revision numbers. (1 << 1) == rev A, (1 << 2) == rev B,
+ * (3 << 1) == (rev A or rev B), etc
  */
 #define PV854697 (~0)     /* PIC: write 64bit regs as 64bits. permanent */
 #define PV854827 (~0)     /* PIC: fake widget 0xf presence bit. permanent */
-#define PV855271 (1 << 1) /* PIC: PIC: use virt chan iff 64-bit device. */
+#define PV855271 (1 << 1) /* PIC: use virt chan iff 64-bit device. */
+#define PV878674 (~0)     /* PIC: Dont allow 64bit PIOs.  permanent */
 #define PV855272 (1 << 1) /* PIC: runaway interrupt WAR */
 #define PV856155 (1 << 1) /* PIC: arbitration WAR */
 #define PV856864 (1 << 1) /* PIC: lower timeout to free TNUMs quicker */
@@ -314,6 +310,9 @@ struct pcibr_intr_wrap_s {
 #define PV862253 (1 << 1) /* PIC: don't enable write req RAM parity checking */
 #define PV867308 (3 << 1) /* PIC: make LLP error interrupts FATAL for PIC */
 
+/* Bridgetype macros given a pcibr_soft structure */
+#define IS_PIC_SOFT(ps)     (ps->bs_bridge_type == PCIBR_BRIDGETYPE_PIC)
+
 
 /* defines for pcibr_soft_s->bs_bridge_mode */
 #define PCIBR_BRIDGEMODE_PCI_33		0x0
@@ -372,13 +371,15 @@ struct pcibr_soft_s {
     short		    bs_int_ate_size;	/* number of internal ates */
     short		    bs_bridge_type;	/* see defines above */
     short		    bs_bridge_mode;	/* see defines above */
-    int                     bs_rev_num;		/* revision number of Bridge */
+
+    int                     bs_rev_num;	/* revision number of Bridge */
 
     /* bs_dma_flags are the forced dma flags used on all DMAs. Used for
      * working around ASIC rev issues and protocol specific requirements
      */
     unsigned                bs_dma_flags;	/* forced DMA flags */
 
+    nasid_t		    bs_nasid;		/* nasid this bus is on */
     moduleid_t		    bs_moduleid;	/* io brick moduleid */
     short		    bs_bricktype;	/* io brick type */
 
@@ -445,7 +446,7 @@ struct pcibr_soft_s {
 	/* Shadow value for Device(x) register,
 	 * so we don't have to go to the chip.
 	 */
-	bridgereg_t             bss_device;
+	uint64_t		bss_device;
 
 	/* Number of sets on GBR/REALTIME bit outstanding
 	 * Used by Priority I/O for tracking reservations
@@ -522,9 +523,9 @@ struct pcibr_soft_s {
      *  time for the indexed slot/vchan number; array[slot][vchan]
      */
     int                     bs_rrb_fixed;
-    int                     bs_rrb_avail[2];
-    int                     bs_rrb_res[8];
-    int                     bs_rrb_res_dflt[8];
+    int			    bs_rrb_avail[2];
+    int			    bs_rrb_res[8];
+    int			    bs_rrb_res_dflt[8];
     int			    bs_rrb_valid[8][4];
     int			    bs_rrb_valid_dflt[8][4];
     struct {
@@ -537,6 +538,10 @@ struct pcibr_soft_s {
 	 * Bridge interrupt bit.
 	 */
 	struct pcibr_intr_wrap_s  bsi_pcibr_intr_wrap;
+	/* The bus and interrupt bit, used for pcibr_setpciint().
+	 * The pci busnum is bit3, int_bits bit2:0
+	 */
+	uint32_t		bsi_int_bit;
 
     } bs_intr[8];
 
@@ -564,9 +569,6 @@ struct pcibr_soft_s {
      */
     struct br_errintr_info {
 	int                     bserr_toutcnt;
-#ifdef LATER
-	toid_t                  bserr_toutid;	/* Timeout started by errintr */
-#endif	/* LATER */
 	iopaddr_t               bserr_addr;	/* Address where error occured */
 	uint64_t		bserr_intstat;	/* interrupts active at error dump */
     } bs_errinfo;
@@ -602,9 +604,9 @@ struct pcibr_soft_s {
 #define PCIBR_BUS_ADDR_IO_FREED        2  /* Reserved PROM I/O addr freed */
 
     struct bs_errintr_stat_s {
-	uint32_t              bs_errcount_total;
-	uint32_t              bs_lasterr_timestamp;
-	uint32_t              bs_lasterr_snapshot;
+	uint32_t		bs_errcount_total;
+	uint32_t		bs_lasterr_timestamp;
+	uint32_t		bs_lasterr_snapshot;
     } bs_errintr_stat[PCIBR_ISR_MAX_ERRS];
 
     /*
@@ -660,17 +662,6 @@ struct pcibr_hints_s {
 #define pcibr_soft_set(v,i)     (hwgraph_fastinfo_set((v), (arbitrary_info_t)(i)))
 
 /*
- * mem alloc/free macros
- */
-#define NEWAf(ptr,n,f)	(ptr = snia_kmem_zalloc((n)*sizeof (*(ptr)), (f&PCIIO_NOSLEEP)?KM_NOSLEEP:KM_SLEEP))
-#define NEWA(ptr,n)	(ptr = snia_kmem_zalloc((n)*sizeof (*(ptr)), KM_SLEEP))
-#define DELA(ptr,n)	(kfree(ptr))
-
-#define NEWf(ptr,f)	NEWAf(ptr,1,f)
-#define NEW(ptr)	NEWA(ptr,1)
-#define DEL(ptr)	DELA(ptr,1)
-
-/*
  * Additional PIO spaces per slot are
  * recorded in this structure.
  */
@@ -682,17 +673,17 @@ struct pciio_piospace_s {
     size_t                  count;	/* size of PIO space */
 };
 
-/* Use io spin locks. This ensures that all the PIO writes from a particular
- * CPU to a particular IO device are synched before the start of the next
- * set of PIO operations to the same device.
- */
-#ifdef PCI_LATER
-#define pcibr_lock(pcibr_soft)		io_splock(pcibr_soft->bs_lock)
-#define pcibr_unlock(pcibr_soft, s)	io_spunlock(pcibr_soft->bs_lock,s)
-#else
-#define pcibr_lock(pcibr_soft)		1
-#define pcibr_unlock(pcibr_soft, s)	
-#endif	/* PCI_LATER */
+/* 
+ * pcibr_soft structure locking macros
+ */
+inline static unsigned long
+pcibr_lock(pcibr_soft_t pcibr_soft)
+{
+        unsigned long flag;
+        spin_lock_irqsave(&pcibr_soft->bs_lock, flag);
+        return(flag);
+}
+#define pcibr_unlock(pcibr_soft, flag)  spin_unlock_irqrestore(&pcibr_soft->bs_lock, flag)
 
 #define PCIBR_VALID_SLOT(ps, s)     (s < PCIBR_NUM_SLOTS(ps))
 #define PCIBR_D64_BASE_UNSET    (0xFFFFFFFFFFFFFFFF)
@@ -703,18 +694,18 @@ struct pciio_piospace_s {
 #if PCIBR_SOFT_LIST
 typedef struct pcibr_list_s *pcibr_list_p;
 struct pcibr_list_s {
-	pcibr_list_p            bl_next;
-	pcibr_soft_t            bl_soft;
-	vertex_hdl_t          bl_vhdl;
+    pcibr_list_p            bl_next;
+    pcibr_soft_t            bl_soft;
+    vertex_hdl_t            bl_vhdl;
 };
 #endif /* PCIBR_SOFT_LIST */
 
-
-// Devices per widget: 2 buses, 2 slots per bus, 8 functions per slot.
+/* Devices per widget: 2 buses, 2 slots per bus, 8 functions per slot. */
 #define DEV_PER_WIDGET (2*2*8)
 
 struct sn_flush_device_list {
 	int bus;
+	int slot;
 	int pin;
 	struct bar_list {
 		unsigned long start;
@@ -727,13 +718,7 @@ struct sn_flush_device_list {
 
 struct sn_flush_nasid_entry  {
         struct sn_flush_device_list **widget_p;
-        unsigned long        iio_itte1;
-        unsigned long        iio_itte2;
-        unsigned long        iio_itte3;
-        unsigned long        iio_itte4;
-        unsigned long        iio_itte5;
-        unsigned long        iio_itte6;
-        unsigned long        iio_itte7;
+        unsigned long        iio_itte[8];
 };
 
 #endif				/* _ASM_SN_PCI_PCIBR_PRIVATE_H */
diff -puN include/asm-ia64/sn/pci/pci_bus_cvlink.h~linus include/asm-ia64/sn/pci/pci_bus_cvlink.h
--- 25/include/asm-ia64/sn/pci/pci_bus_cvlink.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/pci/pci_bus_cvlink.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,13 +1,12 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
  */
-#ifndef _ASM_SN_PCI_CVLINK_H
-#define _ASM_SN_PCI_CVLINK_H
+#ifndef _ASM_IA64_SN_PCI_CVLINK_H
+#define _ASM_IA64_SN_PCI_CVLINK_H
 
 #include <asm/sn/types.h>
 #include <asm/sn/sgi.h>
@@ -18,7 +17,6 @@
 #include <asm/sn/xtalk/xwidget.h>
 #include <asm/sn/sn_private.h>
 #include <asm/sn/addrs.h>
-#include <asm/sn/invent.h>
 #include <asm/sn/hcl.h>
 #include <asm/sn/hcl_util.h>
 #include <asm/sn/intr.h>
@@ -40,8 +38,6 @@
 #define IS_PCI32G(dev)	((dev)->dma_mask >= 0xffffffff)
 #define IS_PCI32L(dev)	((dev)->dma_mask < 0xffffffff)
 
-#define IS_PIC_DEVICE(dev) ((struct sn_device_sysdata *)dev->sysdata)->isPIC
-
 #define PCIDEV_VERTEX(pci_dev) \
 	(((struct sn_device_sysdata *)((pci_dev)->sysdata))->vhdl)
 
@@ -55,9 +51,9 @@ struct sn_widget_sysdata {
 struct sn_device_sysdata {
         vertex_hdl_t  vhdl;
 	int		isa64;
-	int		isPIC;
 	volatile unsigned int *dma_buf_sync;
 	volatile unsigned int *xbow_buf_sync;
+	pciio_provider_t	*pci_provider;
 };
 
 struct ioports_to_tlbs_s {
@@ -74,4 +70,4 @@ struct ioports_to_tlbs_s {
 			ig:11;
 };
 
-#endif				/* _ASM_SN_PCI_CVLINK_H */
+#endif				/* _ASM_IA64_SN_PCI_CVLINK_H */
diff -puN include/asm-ia64/sn/pci/pci_defs.h~linus include/asm-ia64/sn/pci/pci_defs.h
--- 25/include/asm-ia64/sn/pci/pci_defs.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/pci/pci_defs.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,15 +1,12 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * Copyright (c) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
  */
-#ifndef _ASM_SN_PCI_PCI_DEFS_H
-#define _ASM_SN_PCI_PCI_DEFS_H
-
-#include <linux/config.h>
+#ifndef _ASM_IA64_SN_PCI_PCI_DEFS_H
+#define _ASM_IA64_SN_PCI_PCI_DEFS_H
 
 /* defines for the PCI bus architecture */
 
@@ -245,7 +242,7 @@
 
 #else
 
-extern uint pci_read(void * address, int type);
+extern unsigned int pci_read(void * address, int type);
 extern void pci_write(void * address, int data, int type);
 
 #define BYTE   1
@@ -278,16 +275,6 @@ extern void pci_write(void * address, in
 #define CFG1_DEVICE_SHIFT		11
 #define CFG1_BUS_SHIFT			16
 
-#ifdef CONFIG_SGI_IP32
- /* Definitions related to IP32 PCI Bridge policy
-  * XXX- should probaly be moved to a mace-specific header
-  */
-#define PCI_CONFIG_BITS			0xfe0085ff
-#define	PCI_CONTROL_MRMRA_ENABLE	0x00000800
-#define PCI_FIRST_IO_ADDR		0x1000
-#define PCI_IO_MAP_INCR			0x1000
-#endif /* CONFIG_SGI_IP32 */
-
 /*
  * Class codes
  */
@@ -321,8 +308,6 @@ extern void pci_write(void * address, in
 
 #ifndef __ASSEMBLY__
 
-#ifdef LITTLE_ENDIAN
-
 /*
  * PCI config space definition
  */
@@ -331,24 +316,24 @@ typedef volatile struct pci_cfg_s {
 	uint16_t	dev_id;
 	uint16_t	cmd;
 	uint16_t	status;
-	uchar_t		rev;
-        uchar_t         prog_if;
-	uchar_t		sub_class;
-	uchar_t		class;
-	uchar_t		line_size;
-	uchar_t		lt;
-	uchar_t		hdr_type;
-	uchar_t		bist;
+	uint8_t		rev;
+	uint8_t         prog_if;
+	uint8_t		sub_class;
+	uint8_t		class;
+	uint8_t		line_size;
+	uint8_t		lt;
+	uint8_t		hdr_type;
+	uint8_t		bist;
 	uint32_t	bar[6];
 	uint32_t	cardbus;
 	uint16_t	subsys_vendor_id;
 	uint16_t	subsys_dev_id;
 	uint32_t	exp_rom;
 	uint32_t	res[2];
-	uchar_t		int_line;
-	uchar_t		int_pin;
-	uchar_t		min_gnt;
-	uchar_t		max_lat;
+	uint8_t		int_line;
+	uint8_t		int_pin;
+	uint8_t		min_gnt;
+	uint8_t		max_lat;
 } pci_cfg_t;
 
 /*
@@ -359,21 +344,21 @@ typedef volatile struct pci_cfg1_s {
 	uint16_t	dev_id;
 	uint16_t	cmd;
 	uint16_t	status;
-	uchar_t		rev;
-	uchar_t		prog_if;
-	uchar_t		sub_class;
-	uchar_t		class;
-	uchar_t		line_size;
-	uchar_t		lt;
-	uchar_t		hdr_type;
-	uchar_t		bist;
+	uint8_t		rev;
+	uint8_t		prog_if;
+	uint8_t		sub_class;
+	uint8_t		class;
+	uint8_t		line_size;
+	uint8_t		lt;
+	uint8_t		hdr_type;
+	uint8_t		bist;
 	uint32_t	bar[2];
-	uchar_t		pri_bus_num;
-	uchar_t		snd_bus_num;
-	uchar_t		sub_bus_num;
-	uchar_t		slt;
-	uchar_t		io_base;
-	uchar_t		io_limit;
+	uint8_t		pri_bus_num;
+	uint8_t		snd_bus_num;
+	uint8_t		sub_bus_num;
+	uint8_t		slt;
+	uint8_t		io_base;
+	uint8_t		io_limit;
 	uint16_t	snd_status;
 	uint16_t	mem_base;
 	uint16_t	mem_limit;
@@ -385,8 +370,8 @@ typedef volatile struct pci_cfg1_s {
 	uint16_t	io_limit_upper;
 	uint32_t	res;
 	uint32_t	exp_rom;
-	uchar_t		int_line;
-	uchar_t		int_pin;
+	uint8_t		int_line;
+	uint8_t		int_pin;
 	uint16_t	ppb_control;
 
 } pci_cfg1_t;
@@ -419,117 +404,11 @@ typedef volatile struct cap_pcix_stat_re
 } cap_pcix_stat_reg_t;
 
 typedef volatile struct cap_pcix_type0_s {
-	uchar_t			pcix_cap_id;
-	uchar_t			pcix_cap_nxt;
-	cap_pcix_cmd_reg_t	pcix_type0_command;
-	cap_pcix_stat_reg_t	pcix_type0_status;
-} cap_pcix_type0_t;
-
-#else
-
-/*
- * PCI config space definition
- */
-typedef volatile struct pci_cfg_s {
-	uint16_t	dev_id;
-	uint16_t	vendor_id;
-	uint16_t	status;
-	uint16_t	cmd;
-	uchar_t		class;
-	uchar_t		sub_class;
-	uchar_t		prog_if;
-	uchar_t		rev;
-	uchar_t		bist;
-	uchar_t		hdr_type;
-	uchar_t		lt;
-	uchar_t		line_size;
-	uint32_t	bar[6];
-	uint32_t	cardbus;
-	uint16_t	subsys_dev_id;
-	uint16_t	subsys_vendor_id;
-	uint32_t	exp_rom;
-	uint32_t	res[2];
-	uchar_t		max_lat;
-	uchar_t		min_gnt;
-	uchar_t		int_pin;
-	uchar_t		int_line;
-} pci_cfg_t;
-
-/*
- * PCI Type 1 config space definition for PCI to PCI Bridges (PPBs)
- */
-typedef volatile struct pci_cfg1_s {
-	uint16_t	dev_id;
-	uint16_t	vendor_id;
-	uint16_t	status;
-	uint16_t	cmd;
-	uchar_t		class;
-	uchar_t		sub_class;
-	uchar_t		prog_if;
-	uchar_t		rev;
-	uchar_t		bist;
-	uchar_t		hdr_type;
-	uchar_t		lt;
-	uchar_t		line_size;
-	uint32_t	bar[2];
-	uchar_t		slt;
-	uchar_t		sub_bus_num;
-	uchar_t		snd_bus_num;
-	uchar_t		pri_bus_num;
-	uint16_t	snd_status;
-	uchar_t		io_limit;
-	uchar_t		io_base;
-	uint16_t	mem_limit;
-	uint16_t	mem_base;
-	uint16_t	pmem_limit;
-	uint16_t	pmem_base;
-	uint32_t	pmem_limit_upper;
-	uint32_t	pmem_base_upper;
-	uint16_t	io_limit_upper;
-	uint16_t	io_base_upper;
-	uint32_t	res;
-	uint32_t	exp_rom;
-	uint16_t	ppb_control;
-	uchar_t		int_pin;
-	uchar_t		int_line;
-} pci_cfg1_t;
-
-
-
-/*
- * PCI-X Capability
- */
-typedef volatile struct cap_pcix_cmd_reg_s {
-	uint16_t	reserved1:              9,
-			max_split:		3,
-			max_mem_read_cnt:	2,
-			enable_relaxed_order:	1,
-			data_parity_enable:	1;
-} cap_pcix_cmd_reg_t;
-
-typedef volatile struct cap_pcix_stat_reg_s {
-	uint32_t	reserved1:		2,
-			split_complt_err:	1,
-			max_cum_read:		3,
-			max_out_split:		3,
-			max_mem_read_cnt:	2,
-			device_complex:		1,
-			unexpect_split_complt:	1,
-			split_complt_discard:	1,
-			mhz133_capable:		1,
-			bit64_device:		1,
-			bus_num:		8,
-			dev_num:		5,
-			func_num:		3;
-} cap_pcix_stat_reg_t;
-
-typedef volatile struct cap_pcix_type0_s {
+	uint8_t			pcix_cap_id;
+	uint8_t			pcix_cap_nxt;
 	cap_pcix_cmd_reg_t	pcix_type0_command;
-	uchar_t			pcix_cap_nxt;
-	uchar_t			pcix_cap_id;
 	cap_pcix_stat_reg_t	pcix_type0_status;
 } cap_pcix_type0_t;
 
-#endif
 #endif	/* __ASSEMBLY__ */
-#endif /* _ASM_SN_PCI_PCI_DEFS_H */
+#endif /* _ASM_IA64_SN_PCI_PCI_DEFS_H */
diff -puN include/asm-ia64/sn/pci/pciio.h~linus include/asm-ia64/sn/pci/pciio.h
--- 25/include/asm-ia64/sn/pci/pciio.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/pci/pciio.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,29 +1,38 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
  */
-#ifndef _ASM_SN_PCI_PCIIO_H
-#define _ASM_SN_PCI_PCIIO_H
+#ifndef _ASM_IA64_SN_PCI_PCIIO_H
+#define _ASM_IA64_SN_PCI_PCIIO_H
 
 /*
  * pciio.h -- platform-independent PCI interface
  */
 
-#include <linux/config.h>
+#ifdef __KERNEL__
 #include <linux/ioport.h>
 #include <asm/sn/ioerror.h>
 #include <asm/sn/driver.h>
 #include <asm/sn/hcl.h>
-
+#else
+#include <linux/ioport.h>
+#include <ioerror.h>
+#include <driver.h>
+#include <hcl.h>
+#endif
 
 #ifndef __ASSEMBLY__
 
+#ifdef __KERNEL__
 #include <asm/sn/dmamap.h>
 #include <asm/sn/alenlist.h>
+#else
+#include <dmamap.h>
+#include <alenlist.h>
+#endif
 
 typedef int pciio_vendor_id_t;
 
@@ -188,6 +197,31 @@ typedef enum pciio_endian_e {
 } pciio_endian_t;
 
 /*
+ * Generic PCI bus information
+ */
+typedef enum pciio_asic_type_e {
+    PCIIO_ASIC_TYPE_UNKNOWN, 
+    PCIIO_ASIC_TYPE_MACE,
+    PCIIO_ASIC_TYPE_BRIDGE, 
+    PCIIO_ASIC_TYPE_XBRIDGE,
+    PCIIO_ASIC_TYPE_PIC,
+} pciio_asic_type_t;
+
+typedef enum pciio_bus_type_e {
+    PCIIO_BUS_TYPE_UNKNOWN,
+    PCIIO_BUS_TYPE_PCI,
+    PCIIO_BUS_TYPE_PCIX 
+} pciio_bus_type_t; 
+
+typedef enum pciio_bus_speed_e {
+    PCIIO_BUS_SPEED_UNKNOWN,
+    PCIIO_BUS_SPEED_33,
+    PCIIO_BUS_SPEED_66,
+    PCIIO_BUS_SPEED_100,
+    PCIIO_BUS_SPEED_133
+} pciio_bus_speed_t;
+
+/*
  * Interface to set PCI arbitration priority for devices that require
  * realtime characteristics.  pciio_priority_set is used to switch a
  * device between the PCI high-priority arbitration ring and the low
@@ -212,6 +246,9 @@ typedef struct pciio_piospace_s *pciio_p
 typedef struct pciio_win_info_s *pciio_win_info_t;
 typedef struct pciio_win_map_s *pciio_win_map_t;
 typedef struct pciio_win_alloc_s *pciio_win_alloc_t;
+typedef struct pciio_bus_map_s *pciio_bus_map_t;
+typedef struct pciio_businfo_s *pciio_businfo_t;
+
 
 /* PIO MANAGEMENT */
 
@@ -419,9 +456,6 @@ pciio_config_set_f	(vertex_hdl_t conn,	/
 			 unsigned size,		/* width in bytes (1..4) */
 			 uint64_t value);	/* value to store */
 
-typedef int
-pciio_error_devenable_f (vertex_hdl_t pconn_vhdl, int error_code);
-
 typedef pciio_slot_t
 pciio_error_extract_f	(vertex_hdl_t vhdl,
 			 pciio_space_t *spacep,
@@ -442,8 +476,8 @@ pciio_driver_unreg_callback_f	(vertex_hd
 typedef int
 pciio_device_unregister_f	(vertex_hdl_t conn);
 
-typedef int
-pciio_dma_enabled_f		(vertex_hdl_t conn);
+typedef pciio_businfo_t
+pciio_businfo_get_f		(vertex_hdl_t conn);
 
 /*
  * Adapters that provide a PCI interface adhere to this software interface.
@@ -486,14 +520,15 @@ typedef struct pciio_provider_s {
     pciio_config_set_f	   *config_set;
 
     /* Error handling interface */
-    pciio_error_devenable_f *error_devenable;
     pciio_error_extract_f *error_extract;
 
     /* Callback support */
     pciio_driver_reg_callback_f *driver_reg_callback;
     pciio_driver_unreg_callback_f *driver_unreg_callback;
     pciio_device_unregister_f 	*device_unregister;
-    pciio_dma_enabled_f		*dma_enabled;
+
+    /* GENERIC BUS INFO */
+    pciio_businfo_get_f *businfo_get;
 } pciio_provider_t;
 
 /* PCI devices use these standard PCI provider interfaces */
@@ -526,7 +561,6 @@ extern pciio_endian_set_f pciio_endian_s
 extern pciio_priority_set_f pciio_priority_set;
 extern pciio_config_get_f pciio_config_get;
 extern pciio_config_set_f pciio_config_set;
-extern pciio_error_devenable_f pciio_error_devenable;
 extern pciio_error_extract_f pciio_error_extract;
 
 /* Widgetdev in the IOERROR structure is encoded as follows.
@@ -693,7 +727,6 @@ extern iopaddr_t	pciio_info_rom_base_get
 extern size_t		pciio_info_rom_size_get(pciio_info_t);
 extern int		pciio_info_type1_get(pciio_info_t);
 extern int              pciio_error_handler(vertex_hdl_t, int, ioerror_mode_t, ioerror_t *);
-extern int		pciio_dma_enabled(vertex_hdl_t);
 
 /**
  * sn_pci_set_vchan - Set the requested Virtual Channel bits into the mapped DMA
@@ -730,4 +763,13 @@ sn_pci_set_vchan(struct pci_dev *pci_dev
 }
 
 #endif				/* C or C++ */
-#endif				/* _ASM_SN_PCI_PCIIO_H */
+
+
+/*
+ * Prototypes
+ */
+
+int snia_badaddr_val(volatile void *addr, int len, volatile void *ptr);
+nasid_t snia_get_console_nasid(void);
+nasid_t snia_get_master_baseio_nasid(void);
+#endif				/* _ASM_IA64_SN_PCI_PCIIO_H */
diff -puN include/asm-ia64/sn/pci/pciio_private.h~linus include/asm-ia64/sn/pci/pciio_private.h
--- 25/include/asm-ia64/sn/pci/pciio_private.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/pci/pciio_private.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,13 +1,12 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
  */
-#ifndef _ASM_SN_PCI_PCIIO_PRIVATE_H
-#define _ASM_SN_PCI_PCIIO_PRIVATE_H
+#ifndef _ASM_IA64_SN_PCI_PCIIO_PRIVATE_H
+#define _ASM_IA64_SN_PCI_PCIIO_PRIVATE_H
 
 #include <asm/sn/pci/pciio.h>
 #include <asm/sn/pci/pci_defs.h>
@@ -17,8 +16,6 @@
  * PCI drivers should NOT include this file.
  */
 
-#ident "sys/PCI/pciio_private: $Revision: 1.13 $"
-
 /*
  * All PCI providers set up PIO using this information.
  */
@@ -62,6 +59,20 @@ struct pciio_intr_s {
 #define PCIIO_INTR_NOTHREAD	2	/* interrupt handler wants to be called at interrupt level */
 
 /*
+ * Generic PCI bus information
+ */
+struct pciio_businfo_s {
+    int                 bi_multi_master;/* Bus provider supports multiple */
+                                        /* dma masters behind a single slot. */
+                                        /* Needed to work around a thrashing */
+                                        /* issue in SGI Bridge ASIC and */
+                                        /* its derivatives. */
+    pciio_asic_type_t   bi_asic_type;   /* PCI ASIC type */
+    pciio_bus_type_t    bi_bus_type;    /* PCI bus type */
+    pciio_bus_speed_t   bi_bus_speed;   /* PCI bus speed */
+}; 
+
+/*
  * Some PCI provider implementations keep track of PCI window Base Address
  * Register (BAR) address range assignment via the rmalloc()/rmfree() arena
  * management routines.  These implementations use the following data
@@ -101,6 +112,7 @@ struct pciio_win_alloc_s {
 struct pciio_info_s {
     char                   *c_fingerprint;
     vertex_hdl_t            c_vertex;	/* back pointer to vertex */
+    vertex_hdl_t	    c_hostvertex;/* top most device in tree */
     pciio_bus_t             c_bus;	/* which bus the card is in */
     pciio_slot_t            c_slot;	/* which slot the card is in */
     pciio_function_t        c_func;	/* which func (on multi-func cards) */
@@ -114,6 +126,8 @@ struct pciio_info_s {
 
     struct pciio_win_info_s {           /* state of BASE regs */
         pciio_space_t           w_space;
+        char                    w_code;		/* low 4 bits of MEM BAR */
+						/* low 2 bits of IO BAR */
         iopaddr_t               w_base;
         size_t                  w_size;
         int                     w_devio_index;   /* DevIO[] register used to
@@ -124,7 +138,8 @@ struct pciio_info_s {
 #define c_rbase		c_rwindow.w_base		/* EXPANSION ROM base addr */
 #define c_rsize		c_rwindow.w_size		/* EXPANSION ROM size (bytes) */
     pciio_piospace_t	    c_piospace;	/* additional I/O spaces allocated */
+    int			    c_type1;	/* use type1 addressing */
 };
 
 extern char             pciio_info_fingerprint[];
-#endif				/* _ASM_SN_PCI_PCIIO_PRIVATE_H */
+#endif				/* _ASM_IA64_SN_PCI_PCIIO_PRIVATE_H */
diff -puN include/asm-ia64/sn/pci/pic.h~linus include/asm-ia64/sn/pci/pic.h
--- 25/include/asm-ia64/sn/pci/pic.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/pci/pic.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,22 +1,12 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
  */
-#ifndef _ASM_SN_PCI_PIC_H
-#define _ASM_SN_PCI_PIC_H
-
-
-/*
- * The PIC ASIC is a follow-on to the Bridge and Xbridge ASICs.
- * It shares many of the same registers as those chips and therefore
- * the primary structure for the PIC will be bridge_s as defined
- * in irix/kern/sys/PCI/bridge.h.   This file is intended as a complement
- * to bridge.h, which includes this file.  
- */
+#ifndef _ASM_IA64_SN_PCI_PIC_H
+#define _ASM_IA64_SN_PCI_PIC_H
 
 /*
  * PIC AS DEVICE ZERO
@@ -66,13 +56,13 @@
  */
 
 
-#ifndef __ASSEMBLY__
-
-#ifdef __cplusplus
-extern "C" {
+#ifdef __KERNEL__
+#include <linux/types.h>
+#include <asm/sn/xtalk/xwidget.h>	/* generic widget header */
+#else
+#include <xtalk/xwidget.h>
 #endif
 
-// #include <sys/types.h>
 #include <asm/sn/pci/pciio.h>
 
 
@@ -785,1217 +775,204 @@ extern pciio_provider_t pci_pic_provider
  *
  */
 typedef uint64_t picreg_t;
+typedef uint64_t picate_t;
 
-/*********************************************************************
- * PIC register structures
- *
- */
-
-/*
- * Identification Register
- *
- * The Identification register is a read only register used by the host CPU
- * during configuration to determine the type of the widget. The format is
- * the same as defined in IEEE 1149.1 JTAG Device Identification Register.
- */
-	typedef union pic_id_reg_u {
-		picreg_t	pic_id_reg_regval;
-		struct {
-			picreg_t          :	32; /* 63:32 */
-			picreg_t rev_num  :	4; /* 31:28 */
-			picreg_t part_num :	16; /* 27:12 */
-			picreg_t mfg_num  :	11; /* 11:1 */
-			picreg_t          :	1; /* 0:0 */
-		} pic_id_reg_fld_s;
-	} pic_id_reg_u_t;
-/*
- * Status Register
- *
- * The status register is a read register which holds status information of the
- * Bus Subsection.
- */
-	typedef union pic_stat_reg_u {
-		picreg_t	pic_stat_reg_regval;
-		struct {
-			picreg_t                :	28; /* 63:36 */
-			picreg_t pci_x_speed    :	2; /* 35:34 */
-			picreg_t pci_x_active   :	1; /* 33:33 */
-			picreg_t                :	1; /* 32:32 */
-			picreg_t llp_rec_cnt    :	8; /* 31:24 */
-			picreg_t llp_tx_cnt     :	8; /* 23:16 */
-			picreg_t rx_credit_cnt  :	4; /* 15:12 */
-			picreg_t tx_credit_cnt  :	4; /* 11:8 */
-			picreg_t pci_misc_input :	8; /* 7:0 */
-		} pic_stat_reg_fld_s;
-	} pic_stat_reg_u_t;
-/*
- * Upper Address Holding Register Bus Side Errors
- *
- * The upper address holding register is a read only register which contains
- * the upper 16-bits of the address when certain error occurs (see error cases
- * chapter). Subsequent errors are not logged until the error is cleared. The
- * last logged value is held until the group is cleared and enabled.
- */
-	typedef union pic_upper_bus_err_u {
-		picreg_t	pic_upper_bus_err_regval;
-		struct {
-			picreg_t          :	32; /* 63:32 */
-			picreg_t          :	16; /* 31:16 */
-			picreg_t upp_addr :	16; /* 15:0 */
-		} pic_upper_bus_err_fld_s;
-	} pic_upper_bus_err_u_t;
-/*
- * Lower Address Holding Register Bus Side Errors
- *
- * The lower address holding register is a read only register which contains
- * the address which either can be accessed as a word or double word. Sub-
- * sequent errors are not logged until the error is cleared. The last logged
- * value is held until the group is cleared and enabled.
- */
-	typedef union pic_lower_bus_err_u {
-		picreg_t	pic_lower_bus_err_regval;
-		struct {
-			picreg_t          :	16; /* 63:48 */
-			picreg_t upp_addr :	16; /* 47:32 */
-			picreg_t low_addr :	32; /* 31:0 */
-		} pic_lower_bus_err_fld_s;
-	} pic_lower_bus_err_u_t;
-/*
- * Control Register
- *
- * The control register is a read/write register which holds control informa-
- * tion for the bus subsection.
- */
-	typedef union pic_control_reg_u {
-		picreg_t	pic_control_reg_regval;
-		struct {
-			picreg_t                :	32; /* 63:32 */
-			picreg_t                :	4; /* 31:28 */
-			picreg_t rst_pin_n      :	4; /* 27:24 */
-			picreg_t                :	1; /* 23:23 */
-			picreg_t mem_swap       :	1; /* 22:22 */
-			picreg_t page_size      :	1; /* 21:21 */
-			picreg_t                :	4; /* 20:17 */
-			picreg_t f_bad_pkt      :	1; /* 16:16 */
-			picreg_t llp_xbar_crd   :	4; /* 15:12 */
-			picreg_t clr_rllp_cnt   :	1; /* 11:11 */
-			picreg_t clr_tllp_cnt   :	1; /* 10:10 */
-			picreg_t sys_end        :	1; /* 9:9 */
-			picreg_t                :	3; /* 8:6 */
-			picreg_t pci_speed      :	2; /* 5:4 */
-			picreg_t widget_id      :	4; /* 3:0 */
-		} pic_control_reg_fld_s;
-	} pic_control_reg_u_t;
-/*
- * PCI/PCI-X Request Time-out Value Register
- *
- * This register contains the reload value for the response timer. The request
- * timer counts every 960 nS (32 PCI clocks)
- */
-	typedef union pic_pci_req_to_u {
-		picreg_t	pic_pci_req_to_regval;
-		struct {
-			picreg_t          :	32; /* 63:32 */
-			picreg_t          :	12; /* 31:20 */
-			picreg_t time_out :	20; /* 19:0 */
-		} pic_pci_req_to_fld_s;
-	} pic_pci_req_to_u_t;
-/*
- * Interrupt Destination Upper Address Register
- *
- * The interrupt destination upper address register is a read/write register
- * containing the upper 16-bits of address of the host to which the interrupt
- * is targeted. In addition the target ID is also contained in this register for
- * use in Crosstalk mode.
- */
-	typedef union pic_int_desc_upper_u {
-		picreg_t	pic_int_desc_upper_regval;
-		struct {
-			picreg_t           :	32; /* 63:32 */
-			picreg_t           :	12; /* 31:20 */
-			picreg_t target_id :	4; /* 19:16 */
-			picreg_t upp_addr  :	16; /* 15:0 */
-		} pic_int_desc_upper_fld_s;
-	} pic_int_desc_upper_u_t;
-/*
- * Interrupt Destination Lower Address Register
- *
- * The interrupt destination lower address register is a read/write register
- * which contains the entire address of the host to which the interrupt is tar-
- * geted. In addition the target ID is also contained in this register for use in
- * Crosstalk mode.
- */
-	typedef union pic_int_desc_lower_u {
-		picreg_t	pic_int_desc_lower_regval;
-		struct {
-			picreg_t           :	12; /* 63:52 */
-			picreg_t target_id :	4; /* 51:48 */
-			picreg_t upp_addr  :	16; /* 47:32 */
-			picreg_t low_addr  :	32; /* 31:0 */
-		} pic_int_desc_lower_fld_s;
-	} pic_int_desc_lower_u_t;
-/*
- * Command Word Holding Register Bus Side Errors
- *
- * The command word holding is a read register that holds the command
- * word of a Crosstalk packet when errors occur on the link side (see error
- * chapter). Errors are indicated with error bits in the interrupt status regis-
- * ter. Subsequent errors are not logged until the interrupt is cleared..
- */
-	typedef union pic_cmd_word_bus_err_u {
-		picreg_t	pic_cmd_word_bus_err_regval;
-		struct {
-			picreg_t          :	32; /* 63:32 */
-			picreg_t didn     :	4; /* 31:28 */
-			picreg_t sidn     :	4; /* 27:24 */
-			picreg_t pactyp   :	4; /* 23:20 */
-			picreg_t tnum     :	5; /* 19:15 */
-			picreg_t coherent :	1; /* 14:14 */
-			picreg_t ds       :	2; /* 13:12 */
-			picreg_t gbr      :	1; /* 11:11 */
-			picreg_t vbpm     :	1; /* 10:10 */
-			picreg_t error    :	1; /* 9:9 */
-			picreg_t barrier  :	1; /* 8:8 */
-			picreg_t          :	8; /* 7:0 */
-		} pic_cmd_word_bus_err_fld_s;
-	} pic_cmd_word_bus_err_u_t;
-/*
- * LLP Configuration Register
- *
- * This register contains the configuration information for the LLP modules
- * and is only valid on bus 0 side.
- */
-	typedef union pic_llp_cfg_u {
-		picreg_t	pic_llp_cfg_regval;
-		struct {
-			picreg_t                 :	32; /* 63:32 */
-			picreg_t                 :	6; /* 31:26 */
-			picreg_t llp_maxretry    :	10; /* 25:16 */
-			picreg_t llp_nulltimeout :	6; /* 15:10 */
-			picreg_t llp_maxburst    :	10; /* 9:0 */
-		} pic_llp_cfg_fld_s;
-	} pic_llp_cfg_u_t;
-/*
- * PCI/PCI-X Target Flush Register
- *
- * When read, this register will return a 0x00 after all previous transfers to
- * the PCI bus subsection have completed.
- */
-
-/*
- * Command Word Holding Register Link Side Errors
- *
- * The command word holding is a read-only register that holds the com-
- * mand word of a Crosstalk packet when request fifo overflow or unexpect-
- * ed response errors occur. Errors are indicated with error bits in the
- * interrupt status register. Subsequent errors are not logged until this inter-
- * rupt is cleared.
- */
-	typedef union pic_cmd_word_link_err_u {
-		picreg_t	pic_cmd_word_link_err_regval;
-		struct {
-			picreg_t          :	32; /* 63:32 */
-			picreg_t didn     :	4; /* 31:28 */
-			picreg_t sidn     :	4; /* 27:24 */
-			picreg_t pactyp   :	4; /* 23:20 */
-			picreg_t tnum     :	5; /* 19:15 */
-			picreg_t coherent :	1; /* 14:14 */
-			picreg_t ds       :	2; /* 13:12 */
-			picreg_t gbr      :	1; /* 11:11 */
-			picreg_t vbpm     :	1; /* 10:10 */
-			picreg_t error    :	1; /* 9:9 */
-			picreg_t barrier  :	1; /* 8:8 */
-			picreg_t          :	8; /* 7:0 */
-		} pic_cmd_word_link_err_fld_s;
-	} pic_cmd_word_link_err_u_t;
-/*
- * PCI Response Buffer Error Upper Address Holding Reg
- *
- * The response buffer error upper address holding register is a read only
- * register which contains the upper 16-bits of the address when error asso-
- * ciated with response buffer entries occur. Subsequent errors are not
- * logged until the interrupt is cleared.
- */
-	typedef union pic_pci_rbuf_err_upper_u {
-		picreg_t	pic_pci_rbuf_err_upper_regval;
-		struct {
-			picreg_t          :	32; /* 63:32 */
-			picreg_t          :	9; /* 31:23 */
-			picreg_t dev_num  :	3; /* 22:20 */
-			picreg_t buff_num :	4; /* 19:16 */
-			picreg_t upp_addr :	16; /* 15:0 */
-		} pic_pci_rbuf_err_upper_fld_s;
-	} pic_pci_rbuf_err_upper_u_t;
-/*
- * PCI Response Buffer Error Lower Address Holding Reg
- *
- * The response buffer error lower address holding register is a read only
- * register which contains the address of the error associated with response
- * buffer entries. Subsequent errors are not logged until the interrupt is
- * cleared.
- */
-	typedef union pic_pci_rbuf_err_lower_u {
-		picreg_t	pic_pci_rbuf_err_lower_regval;
-		struct {
-			picreg_t          :	9; /* 63:55 */
-			picreg_t dev_num  :	3; /* 54:52 */
-			picreg_t buff_num :	4; /* 51:48 */
-			picreg_t upp_addr :	16; /* 47:32 */
-			picreg_t low_addr :	32; /* 31:0 */
-		} pic_pci_rbuf_err_lower_fld_s;
-	} pic_pci_rbuf_err_lower_u_t;
-/*
- * Test Pin Control Register
- *
- * This register selects the output function and value to the four test pins on
- * the PIC .
- */
-	typedef union pic_test_pin_cntl_u {
-		picreg_t	pic_test_pin_cntl_regval;
-		struct {
-			picreg_t            :	32; /* 63:32 */
-			picreg_t            :	8; /* 31:24 */
-			picreg_t tdata_out  :	8; /* 23:16 */
-			picreg_t sel_tpin_7 :	2; /* 15:14 */
-			picreg_t sel_tpin_6 :	2; /* 13:12 */
-			picreg_t sel_tpin_5 :	2; /* 11:10 */
-			picreg_t sel_tpin_4 :	2; /* 9:8 */
-			picreg_t sel_tpin_3 :	2; /* 7:6 */
-			picreg_t sel_tpin_2 :	2; /* 5:4 */
-			picreg_t sel_tpin_1 :	2; /* 3:2 */
-			picreg_t sel_tpin_0 :	2; /* 1:0 */
-		} pic_test_pin_cntl_fld_s;
-	} pic_test_pin_cntl_u_t;
-/*
- * Address Holding Register Link Side Errors
- *
- * The address holding register is a read only register which contains the ad-
- * dress which either can be accessed as a word or double word. Subsequent
- * errors are not logged until the error is cleared. The last logged value is
- * held until the group is cleared and enabled.
- */
-	typedef union pic_p_addr_lkerr_u {
-		picreg_t	pic_p_addr_lkerr_regval;
-		struct {
-			picreg_t          :	16; /* 63:48 */
-			picreg_t upp_addr :	16; /* 47:32 */
-			picreg_t low_addr :	32; /* 31:0 */
-		} pic_p_addr_lkerr_fld_s;
-	} pic_p_addr_lkerr_u_t;
-/*
- * PCI Direct Mapping Register
- *
- * This register is used to relocate a 2 GByte region for PCI to Crosstalk
- * transfers.
- */
-	typedef union pic_p_dir_map_u {
-		picreg_t	pic_p_dir_map_regval;
-		struct {
-			picreg_t            :	32; /* 63:32 */
-			picreg_t            :	8; /* 31:24 */
-			picreg_t dir_w_id   :	4; /* 23:20 */
-			picreg_t            :	2; /* 19:18 */
-			picreg_t dir_add512 :	1; /* 17:17 */
-			picreg_t dir_off    :	17; /* 16:0 */
-		} pic_p_dir_map_fld_s;
-	} pic_p_dir_map_u_t;
-/*
- * PCI Page Map Fault Address Register
- *
- * This register contains the address and device number when a page map
- * fault occurred.
- */
-	typedef union pic_p_map_fault_u {
-		picreg_t	pic_p_map_fault_regval;
-		struct {
-			picreg_t             :	32; /* 63:32 */
-			picreg_t             :	10; /* 31:22 */
-			picreg_t pci_addr    :	18; /* 21:4 */
-			picreg_t             :	1; /* 3:3 */
-			picreg_t pci_dev_num :	3; /* 2:0 */
-		} pic_p_map_fault_fld_s;
-	} pic_p_map_fault_u_t;
-/*
- * Arbitration Register
- *
- * This register defines the priority and bus time out timing in PCI bus arbi-
- * tration.
- */
-	typedef union pic_p_arb_u {
-		picreg_t	pic_p_arb_regval;
-		struct {
-			picreg_t               :	32; /* 63:32 */
-			picreg_t               :	8; /* 31:24 */
-			picreg_t dev_broke     :	4; /* 23:20 */
-			picreg_t               :	2; /* 19:18 */
-			picreg_t req_wait_tick :	2; /* 17:16 */
-			picreg_t               :	4; /* 15:12 */
-			picreg_t req_wait_en   :	4; /* 11:8 */
-			picreg_t disarb        :	1; /* 7:7 */
-			picreg_t freeze_gnt    :	1; /* 6:6 */
-			picreg_t               :	1; /* 5:5 */
-			picreg_t en_bridge_hi  :	2; /* 4:3 */
-			picreg_t               :	1; /* 2:2 */
-			picreg_t en_bridge_lo  :	2; /* 1:0 */
-		} pic_p_arb_fld_s;
-	} pic_p_arb_u_t;
-/*
- * Internal Ram Parity Error Register
- *
- * This register logs information about parity errors on internal ram access.
- */
-	typedef union pic_p_ram_perr_u {
-		picreg_t	pic_p_ram_perr_regval;
-		struct {
-			picreg_t         	     :	6; /* 63:58 */
-			picreg_t ate_err_addr        :	10; /* 57:48 */
-			picreg_t         	     :	7; /* 47:41 */
-			picreg_t rd_resp_err_addr    :	9; /* 40:32 */
-			picreg_t wrt_resp_err_addr   :	8; /* 31:24 */
-			picreg_t         	     :	2; /* 23:22 */
-			picreg_t ate_err 	     :	1; /* 21:21 */
-			picreg_t rd_resp_err         :	1; /* 20:20 */
-			picreg_t wrt_resp_err        :	1; /* 19:19 */
-			picreg_t dbe_ate 	     :	3; /* 18:16 */
-			picreg_t dbe_rd  	     :	8; /* 15:8 */
-			picreg_t dbe_wrt 	     :	8; /* 7:0 */
-		} pic_p_ram_perr_fld_s;
-	} pic_p_ram_perr_u_t;
-/*
- * Time-out Register
- *
- * This register determines retry hold off and max retries allowed for PIO
- * accesses to PCI/PCI-X.
- */
-	typedef union pic_p_bus_timeout_u {
-		picreg_t	pic_p_bus_timeout_regval;
-		struct {
-			picreg_t               :	32; /* 63:32 */
-			picreg_t               :	11; /* 31:21 */
-			picreg_t pci_retry_hld :	5; /* 20:16 */
-			picreg_t               :	6; /* 15:10 */
-			picreg_t pci_retry_cnt :	10; /* 9:0 */
-		} pic_p_bus_timeout_fld_s;
-	} pic_p_bus_timeout_u_t;
-/*
- * PCI/PCI-X Type 1 Configuration Register
- *
- * This register is use during accesses to the PCI/PCI-X type 1 configuration
- * space. The bits in this register are used to supplement the address during
- * the configuration cycle to select the correct secondary bus and device.
- */
-	typedef union pic_type1_cfg_u {
-		picreg_t	pic_type1_cfg_regval;
-		struct {
-			picreg_t         :	32; /* 63:32 */
-			picreg_t         :	8; /* 31:24 */
-			picreg_t bus_num :	8; /* 23:16 */
-			picreg_t dev_num :	5; /* 15:11 */
-			picreg_t         :	11; /* 10:0 */
-		} pic_type1_cfg_fld_s;
-	} pic_type1_cfg_u_t;
-/*
- * PCI Bus Error Upper Address Holding Register
- *
- * This register holds the value of the upper address on the PCI Bus when an
- * error occurs.
- */
-	typedef union pic_p_pci_err_upper_u {
-		picreg_t	pic_p_pci_err_upper_regval;
-		struct {
-			picreg_t                :	32; /* 63:32 */
-			picreg_t                :	4; /* 31:28 */
-			picreg_t pci_xtalk_did  :	4; /* 27:24 */
-			picreg_t                :	2; /* 23:22 */
-			picreg_t pci_dac        :	1; /* 21:21 */
-			picreg_t pci_dev_master :	1; /* 20:20 */
-			picreg_t pci_vdev       :	1; /* 19:19 */
-			picreg_t pci_dev_num    :	3; /* 18:16 */
-			picreg_t pci_uaddr_err  :	16; /* 15:0 */
-		} pic_p_pci_err_upper_fld_s;
-	} pic_p_pci_err_upper_u_t;
-/*
- * PCI Bus Error Lower Address Holding Register
- *
- * This register holds the value of the lower address on the PCI Bus when an
- * error occurs.
- */
-	typedef union pic_p_pci_err_lower_u {
-		picreg_t	pic_p_pci_err_lower_regval;
-		struct {
-			picreg_t                :	4; /* 63:60 */
-			picreg_t pci_xtalk_did  :	4; /* 59:56 */
-			picreg_t                :	2; /* 55:54 */
-			picreg_t pci_dac        :	1; /* 53:53 */
-			picreg_t pci_dev_master :	1; /* 52:52 */
-			picreg_t pci_vdev       :	1; /* 51:51 */
-			picreg_t pci_dev_num    :	3; /* 50:48 */
-			picreg_t pci_uaddr_err  :	16; /* 47:32 */
-			picreg_t pci_laddr_err  :	32; /* 31:0 */
-		} pic_p_pci_err_lower_fld_s;
-	} pic_p_pci_err_lower_u_t;
-/*
- * PCI-X Error Address Register
- *
- * This register contains the address on the PCI-X bus when an error oc-
- * curred.
- */
-	typedef union pic_p_pcix_err_addr_u {
-		picreg_t	pic_p_pcix_err_addr_regval;
-		struct {
-			picreg_t pcix_err_addr :	64; /* 63:0 */
-		} pic_p_pcix_err_addr_fld_s;
-	} pic_p_pcix_err_addr_u_t;
-/*
- * PCI-X Error Attribute Register
- *
- * This register contains the attribute data on the PCI-X bus when an error
- * occurred.
- */
-	typedef union pic_p_pcix_err_attr_u {
-		picreg_t	pic_p_pcix_err_attr_regval;
-		struct {
-			picreg_t            :	16; /* 63:48 */
-			picreg_t bus_cmd    :	4; /* 47:44 */
-			picreg_t byte_cnt   :	12; /* 43:32 */
-			picreg_t            :	1; /* 31:31 */
-			picreg_t ns         :	1; /* 30:30 */
-			picreg_t ro         :	1; /* 29:29 */
-			picreg_t tag        :	5; /* 28:24 */
-			picreg_t bus_num    :	8; /* 23:16 */
-			picreg_t dev_num    :	5; /* 15:11 */
-			picreg_t fun_num    :	3; /* 10:8 */
-			picreg_t l_byte_cnt :	8; /* 7:0 */
-		} pic_p_pcix_err_attr_fld_s;
-	} pic_p_pcix_err_attr_u_t;
-/*
- * PCI-X Error Data Register
- *
- * This register contains the Data on the PCI-X bus when an error occurred.
- */
-	typedef union pic_p_pcix_err_data_u {
-		picreg_t	pic_p_pcix_err_data_regval;
-		struct {
-			picreg_t pcix_err_data :	64; /* 63:0 */
-		} pic_p_pcix_err_data_fld_s;
-	} pic_p_pcix_err_data_u_t;
-/*
- * PCI-X Read Request Timeout Error Register
- *
- * This register contains a pointer into the PCI-X read data structure.
- */
-	typedef union pic_p_pcix_read_req_to_u {
-		picreg_t	pic_p_pcix_read_req_to_regval;
-		struct {
-			picreg_t                :	55; /* 63:9 */
-			picreg_t rd_buff_loc    :	5; /* 8:4 */
-			picreg_t rd_buff_struct :	4; /* 3:0 */
-		} pic_p_pcix_read_req_to_fld_s;
-	} pic_p_pcix_read_req_to_u_t;
-/*
- * INT_STATUS Register
- *
- * This is the current interrupt status register which maintains the current
- * status of all the interrupting devices which generated a n interrupt. This
- * register is read only and all the bits are active high. A high bit at
- * INT_STATE means the corresponding INT_N pin has been asserted
- * (low).
- */
-	typedef union pic_p_int_status_u {
-		picreg_t	pic_p_int_status_regval;
-		struct {
-			picreg_t                  :	22; /* 63:42 */
-			picreg_t int_ram_perr     :	1; /* 41:41 */
-			picreg_t bus_arb_broke    :	1; /* 40:40 */
-			picreg_t pci_x_req_tout   :	1; /* 39:39 */
-			picreg_t pci_x_tabort     :	1; /* 38:38 */
-			picreg_t pci_x_perr       :	1; /* 37:37 */
-			picreg_t pci_x_serr       :	1; /* 36:36 */
-			picreg_t pci_x_mretry     :	1; /* 35:35 */
-			picreg_t pci_x_mtout      :	1; /* 34:34 */
-			picreg_t pci_x_da_parity  :	1; /* 33:33 */
-			picreg_t pci_x_ad_parity  :	1; /* 32:32 */
-			picreg_t                  :	1; /* 31:31 */
-			picreg_t pmu_page_fault   :	1; /* 30:30 */
-			picreg_t unexpected_resp  :	1; /* 29:29 */
-			picreg_t bad_xresp_packet :	1; /* 28:28 */
-			picreg_t bad_xreq_packet  :	1; /* 27:27 */
-			picreg_t resp_xtalk_error :	1; /* 26:26 */
-			picreg_t req_xtalk_error  :	1; /* 25:25 */
-			picreg_t invalid_access   :	1; /* 24:24 */
-			picreg_t unsupported_xop  :	1; /* 23:23 */
-			picreg_t xreq_fifo_oflow  :	1; /* 22:22 */
-			picreg_t llp_rec_snerror  :	1; /* 21:21 */
-			picreg_t llp_rec_cberror  :	1; /* 20:20 */
-			picreg_t llp_rcty         :	1; /* 19:19 */
-			picreg_t llp_tx_retry     :	1; /* 18:18 */
-			picreg_t llp_tcty         :	1; /* 17:17 */
-			picreg_t                  :	1; /* 16:16 */
-			picreg_t pci_abort        :	1; /* 15:15 */
-			picreg_t pci_parity       :	1; /* 14:14 */
-			picreg_t pci_serr         :	1; /* 13:13 */
-			picreg_t pci_perr         :	1; /* 12:12 */
-			picreg_t pci_master_tout  :	1; /* 11:11 */
-			picreg_t pci_retry_cnt    :	1; /* 10:10 */
-			picreg_t xread_req_tout   :	1; /* 9:9 */
-			picreg_t                  :	1; /* 8:8 */
-			picreg_t int_state        :	8; /* 7:0 */
-		} pic_p_int_status_fld_s;
-	} pic_p_int_status_u_t;
-/*
- * Interrupt Enable Register
- *
- * This register enables the reporting of interrupt to the host. Each bit in this
- * register corresponds to the same bit in Interrupt Status register. All bits
- * are zero after reset.
- */
-	typedef union pic_p_int_enable_u {
-		picreg_t	pic_p_int_enable_regval;
-		struct {
-			picreg_t                     :	22; /* 63:42 */
-			picreg_t en_int_ram_perr     :	1; /* 41:41 */
-			picreg_t en_bus_arb_broke    :	1; /* 40:40 */
-			picreg_t en_pci_x_req_tout   :	1; /* 39:39 */
-			picreg_t en_pci_x_tabort     :	1; /* 38:38 */
-			picreg_t en_pci_x_perr       :	1; /* 37:37 */
-			picreg_t en_pci_x_serr       :	1; /* 36:36 */
-			picreg_t en_pci_x_mretry     :	1; /* 35:35 */
-			picreg_t en_pci_x_mtout      :	1; /* 34:34 */
-			picreg_t en_pci_x_da_parity  :	1; /* 33:33 */
-			picreg_t en_pci_x_ad_parity  :	1; /* 32:32 */
-			picreg_t                     :	1; /* 31:31 */
-			picreg_t en_pmu_page_fault   :	1; /* 30:30 */
-			picreg_t en_unexpected_resp  :	1; /* 29:29 */
-			picreg_t en_bad_xresp_packet :	1; /* 28:28 */
-			picreg_t en_bad_xreq_packet  :	1; /* 27:27 */
-			picreg_t en_resp_xtalk_error :	1; /* 26:26 */
-			picreg_t en_req_xtalk_error  :	1; /* 25:25 */
-			picreg_t en_invalid_access   :	1; /* 24:24 */
-			picreg_t en_unsupported_xop  :	1; /* 23:23 */
-			picreg_t en_xreq_fifo_oflow  :	1; /* 22:22 */
-			picreg_t en_llp_rec_snerror  :	1; /* 21:21 */
-			picreg_t en_llp_rec_cberror  :	1; /* 20:20 */
-			picreg_t en_llp_rcty         :	1; /* 19:19 */
-			picreg_t en_llp_tx_retry     :	1; /* 18:18 */
-			picreg_t en_llp_tcty         :	1; /* 17:17 */
-			picreg_t                     :	1; /* 16:16 */
-			picreg_t en_pci_abort        :	1; /* 15:15 */
-			picreg_t en_pci_parity       :	1; /* 14:14 */
-			picreg_t en_pci_serr         :	1; /* 13:13 */
-			picreg_t en_pci_perr         :	1; /* 12:12 */
-			picreg_t en_pci_master_tout  :	1; /* 11:11 */
-			picreg_t en_pci_retry_cnt    :	1; /* 10:10 */
-			picreg_t en_xread_req_tout   :	1; /* 9:9 */
-			picreg_t                     :	1; /* 8:8 */
-			picreg_t en_int_state        :	8; /* 7:0 */
-		} pic_p_int_enable_fld_s;
-	} pic_p_int_enable_u_t;
-/*
- * Reset Interrupt Register
- *
- * A write of a "1" clears the bit and rearms the error registers. Writes also
- * clear the error view register.
- */
-	typedef union pic_p_int_rst_u {
-		picreg_t	pic_p_int_rst_regval;
-		struct {
-			picreg_t                       :	22; /* 63:42 */
-			picreg_t logv_int_ram_perr     :	1; /* 41:41 */
-			picreg_t logv_bus_arb_broke    :	1; /* 40:40 */
-			picreg_t logv_pci_x_req_tout   :	1; /* 39:39 */
-			picreg_t logv_pci_x_tabort     :	1; /* 38:38 */
-			picreg_t logv_pci_x_perr       :	1; /* 37:37 */
-			picreg_t logv_pci_x_serr       :	1; /* 36:36 */
-			picreg_t logv_pci_x_mretry     :	1; /* 35:35 */
-			picreg_t logv_pci_x_mtout      :	1; /* 34:34 */
-			picreg_t logv_pci_x_da_parity  :	1; /* 33:33 */
-			picreg_t logv_pci_x_ad_parity  :	1; /* 32:32 */
-			picreg_t                       :	1; /* 31:31 */
-			picreg_t logv_pmu_page_fault   :	1; /* 30:30 */
-			picreg_t logv_unexpected_resp  :	1; /* 29:29 */
-			picreg_t logv_bad_xresp_packet :	1; /* 28:28 */
-			picreg_t logv_bad_xreq_packet  :	1; /* 27:27 */
-			picreg_t logv_resp_xtalk_error :	1; /* 26:26 */
-			picreg_t logv_req_xtalk_error  :	1; /* 25:25 */
-			picreg_t logv_invalid_access   :	1; /* 24:24 */
-			picreg_t logv_unsupported_xop  :	1; /* 23:23 */
-			picreg_t logv_xreq_fifo_oflow  :	1; /* 22:22 */
-			picreg_t logv_llp_rec_snerror  :	1; /* 21:21 */
-			picreg_t logv_llp_rec_cberror  :	1; /* 20:20 */
-			picreg_t logv_llp_rcty         :	1; /* 19:19 */
-			picreg_t logv_llp_tx_retry     :	1; /* 18:18 */
-			picreg_t logv_llp_tcty         :	1; /* 17:17 */
-			picreg_t                       :	1; /* 16:16 */
-			picreg_t logv_pci_abort        :	1; /* 15:15 */
-			picreg_t logv_pci_parity       :	1; /* 14:14 */
-			picreg_t logv_pci_serr         :	1; /* 13:13 */
-			picreg_t logv_pci_perr         :	1; /* 12:12 */
-			picreg_t logv_pci_master_tout  :	1; /* 11:11 */
-			picreg_t logv_pci_retry_cnt    :	1; /* 10:10 */
-			picreg_t logv_xread_req_tout   :	1; /* 9:9 */
-                        picreg_t                       :        2; /* 8:7 */
-			picreg_t multi_clr             :	1; /* 6:6 */
-			picreg_t                       :	6; /* 5:0 */
-		} pic_p_int_rst_fld_s;
-	} pic_p_int_rst_u_t;
-
-/*
- * Interrupt Mode Register
- *
- * This register defines the interrupting mode of the INT_N pins.
- */
-	typedef union pic_p_int_mode_u {
-		picreg_t	pic_p_int_mode_regval;
-		struct {
-			picreg_t            :	32; /* 63:32 */
-			picreg_t            :	24; /* 31:8 */
-			picreg_t en_clr_pkt :	8; /* 7:0 */
-		} pic_p_int_mode_fld_s;
-	} pic_p_int_mode_u_t;
-/*
- * Interrupt Device Select Register
- *
- * This register associates interrupt pins with devices thus allowing buffer
- * management (flushing) when a device interrupt occurs.
- */
-	typedef union pic_p_int_device_u {
-		picreg_t	pic_p_int_device_regval;
-		struct {
-			picreg_t          :	32; /* 63:32 */
-			picreg_t          :	8; /* 31:24 */
-			picreg_t int7_dev :	3; /* 23:21 */
-			picreg_t int6_dev :	3; /* 20:18 */
-			picreg_t int5_dev :	3; /* 17:15 */
-			picreg_t int4_dev :	3; /* 14:12 */
-			picreg_t int3_dev :	3; /* 11:9 */
-			picreg_t int2_dev :	3; /* 8:6 */
-			picreg_t int1_dev :	3; /* 5:3 */
-			picreg_t int0_dev :	3; /* 2:0 */
-		} pic_p_int_device_fld_s;
-	} pic_p_int_device_u_t;
-/*
- * Host Error Interrupt Field Register
- *
- * This register tells which bit location in the host's Interrupt Status register
- * to set or reset when any error condition happens.
- */
-	typedef union pic_p_int_host_err_u {
-		picreg_t	pic_p_int_host_err_regval;
-		struct {
-			picreg_t                :	32; /* 63:32 */
-			picreg_t                :	24; /* 31:8 */
-			picreg_t bridge_err_fld :	8; /* 7:0 */
-		} pic_p_int_host_err_fld_s;
-	} pic_p_int_host_err_u_t;
-/*
- * Interrupt (x) Host Address Register
- *
- * This register allow different host address to be assigned to each interrupt
- * pin and the bit in the host.
- */
-	typedef union pic_p_int_addr_u {
-		picreg_t	pic_p_int_addr_regval;
-		struct {
-			picreg_t          :	8; /* 63:56 */
-			picreg_t int_fld  :	8; /* 55:48 */
-			picreg_t int_addr :	48; /* 47:0 */
-		} pic_p_int_addr_fld_s;
-	} pic_p_int_addr_u_t;
-/*
- * Error Interrupt View Register
- *
- * This register contains the view of which interrupt occur even if they are
- * not currently enabled. The group clear is used to clear these bits just like
- * the interrupt status register bits.
- */
-	typedef union pic_p_err_int_view_u {
-		picreg_t	pic_p_err_int_view_regval;
-		struct {
-			picreg_t                  :	22; /* 63:42 */
-			picreg_t int_ram_perr     :	1; /* 41:41 */
-			picreg_t bus_arb_broke    :	1; /* 40:40 */
-			picreg_t pci_x_req_tout   :	1; /* 39:39 */
-			picreg_t pci_x_tabort     :	1; /* 38:38 */
-			picreg_t pci_x_perr       :	1; /* 37:37 */
-			picreg_t pci_x_serr       :	1; /* 36:36 */
-			picreg_t pci_x_mretry     :	1; /* 35:35 */
-			picreg_t pci_x_mtout      :	1; /* 34:34 */
-			picreg_t pci_x_da_parity  :	1; /* 33:33 */
-			picreg_t pci_x_ad_parity  :	1; /* 32:32 */
-			picreg_t                  :	1; /* 31:31 */
-			picreg_t pmu_page_fault   :	1; /* 30:30 */
-			picreg_t unexpected_resp  :	1; /* 29:29 */
-			picreg_t bad_xresp_packet :	1; /* 28:28 */
-			picreg_t bad_xreq_packet  :	1; /* 27:27 */
-			picreg_t resp_xtalk_error :	1; /* 26:26 */
-			picreg_t req_xtalk_error  :	1; /* 25:25 */
-			picreg_t invalid_access   :	1; /* 24:24 */
-			picreg_t unsupported_xop  :	1; /* 23:23 */
-			picreg_t xreq_fifo_oflow  :	1; /* 22:22 */
-			picreg_t llp_rec_snerror  :	1; /* 21:21 */
-			picreg_t llp_rec_cberror  :	1; /* 20:20 */
-			picreg_t llp_rcty         :	1; /* 19:19 */
-			picreg_t llp_tx_retry     :	1; /* 18:18 */
-			picreg_t llp_tcty         :	1; /* 17:17 */
-			picreg_t                  :	1; /* 16:16 */
-			picreg_t pci_abort        :	1; /* 15:15 */
-			picreg_t pci_parity       :	1; /* 14:14 */
-			picreg_t pci_serr         :	1; /* 13:13 */
-			picreg_t pci_perr         :	1; /* 12:12 */
-			picreg_t pci_master_tout  :	1; /* 11:11 */
-			picreg_t pci_retry_cnt    :	1; /* 10:10 */
-			picreg_t xread_req_tout   :	1; /* 9:9 */
-			picreg_t                  :	9; /* 8:0 */
-		} pic_p_err_int_view_fld_s;
-	} pic_p_err_int_view_u_t;
-
-
-/*
- * Multiple Interrupt Register
- *
- * This register indicates if any interrupt occurs more than once without be-
- * ing cleared.
- */
-	typedef union pic_p_mult_int_u {
-		picreg_t	pic_p_mult_int_regval;
-		struct {
-			picreg_t                  :	22; /* 63:42 */
-			picreg_t int_ram_perr     :	1; /* 41:41 */
-			picreg_t bus_arb_broke    :	1; /* 40:40 */
-			picreg_t pci_x_req_tout   :	1; /* 39:39 */
-			picreg_t pci_x_tabort     :	1; /* 38:38 */
-			picreg_t pci_x_perr       :	1; /* 37:37 */
-			picreg_t pci_x_serr       :	1; /* 36:36 */
-			picreg_t pci_x_mretry     :	1; /* 35:35 */
-			picreg_t pci_x_mtout      :	1; /* 34:34 */
-			picreg_t pci_x_da_parity  :	1; /* 33:33 */
-			picreg_t pci_x_ad_parity  :	1; /* 32:32 */
-			picreg_t                  :	1; /* 31:31 */
-			picreg_t pmu_page_fault   :	1; /* 30:30 */
-			picreg_t unexpected_resp  :	1; /* 29:29 */
-			picreg_t bad_xresp_packet :	1; /* 28:28 */
-			picreg_t bad_xreq_packet  :	1; /* 27:27 */
-			picreg_t resp_xtalk_error :	1; /* 26:26 */
-			picreg_t req_xtalk_error  :	1; /* 25:25 */
-			picreg_t invalid_access   :	1; /* 24:24 */
-			picreg_t unsupported_xop  :	1; /* 23:23 */
-			picreg_t xreq_fifo_oflow  :	1; /* 22:22 */
-			picreg_t llp_rec_snerror  :	1; /* 21:21 */
-			picreg_t llp_rec_cberror  :	1; /* 20:20 */
-			picreg_t llp_rcty         :	1; /* 19:19 */
-			picreg_t llp_tx_retry     :	1; /* 18:18 */
-			picreg_t llp_tcty         :	1; /* 17:17 */
-			picreg_t                  :	1; /* 16:16 */
-			picreg_t pci_abort        :	1; /* 15:15 */
-			picreg_t pci_parity       :	1; /* 14:14 */
-			picreg_t pci_serr         :	1; /* 13:13 */
-			picreg_t pci_perr         :	1; /* 12:12 */
-			picreg_t pci_master_tout  :	1; /* 11:11 */
-			picreg_t pci_retry_cnt    :	1; /* 10:10 */
-			picreg_t xread_req_tout   :	1; /* 9:9 */
-			picreg_t                  :	1; /* 8:8 */
-			picreg_t int_state        :	8; /* 7:0 */
-		} pic_p_mult_int_fld_s;
-	} pic_p_mult_int_u_t;
-/*
- * Force Always Interrupt (x) Register
- *
- * A write to this data independent write only register will force a set inter-
- * rupt to occur as if the interrupt line had transitioned. If the interrupt line
- * is already active an addition set interrupt packet is set. All buffer flush op-
- * erations also occur on this operation.
- */
-
-
-/*
- * Force Interrupt (x) Register
- *
- * A write to this data independent write only register in conjunction with
- * the assertion of the corresponding interrupt line will force a set interrupt
- * to occur as if the interrupt line had transitioned. The interrupt line must
- * be active for this operation to generate a set packet, otherwise the write
- * PIO is ignored. All buffer flush operations also occur when the set packet
- * is sent on this operation.
- */
-
-
-/*
- * Device Registers
- *
- * The Device registers contain device specific and mapping information.
- */
-	typedef union pic_device_reg_u {
-		picreg_t	pic_device_reg_regval;
-		struct {
-			picreg_t               :	32; /* 63:32 */
-			picreg_t               :	2; /* 31:30 */
-			picreg_t en_virtual1   :	1; /* 29:29 */
-			picreg_t en_error_lock :	1; /* 28:28 */
-			picreg_t en_page_chk   :	1; /* 27:27 */
-			picreg_t force_pci_par :	1; /* 26:26 */
-			picreg_t en_virtual0   :	1; /* 25:25 */
-			picreg_t               :	1; /* 24:24 */
-			picreg_t dir_wrt_gen   :	1; /* 23:23 */
-			picreg_t dev_size      :	1; /* 22:22 */
-			picreg_t real_time     :	1; /* 21:21 */
-			picreg_t               :	1; /* 20:20 */
-			picreg_t swap_direct   :	1; /* 19:19 */
-			picreg_t prefetch      :	1; /* 18:18 */
-			picreg_t precise       :	1; /* 17:17 */
-			picreg_t coherent      :	1; /* 16:16 */
-			picreg_t barrier       :	1; /* 15:15 */
-			picreg_t gbr           :	1; /* 14:14 */
-			picreg_t dev_swap      :	1; /* 13:13 */
-			picreg_t dev_io_mem    :	1; /* 12:12 */
-			picreg_t dev_off       :	12; /* 11:0 */
-		} pic_device_reg_fld_s;
-	} pic_device_reg_u_t;
-/*
- * Device (x) Write Request Buffer Flush
- *
- * When read, this register will return a 0x00 after the write buffer associat-
- * ed with the device has been flushed. (PCI Only)
- */
-
-
-/*
- * Even Device Read Response Buffer Register (PCI Only)
- *
- * This register is use to allocate the read response buffers for the even num-
- * bered devices. (0,2)
- */
-	typedef union pic_p_even_resp_u {
-		picreg_t	pic_p_even_resp_regval;
-		struct {
-			picreg_t              :	32; /* 63:32 */
-			picreg_t buff_14_en   :	1; /* 31:31 */
-			picreg_t buff_14_vdev :	2; /* 30:29 */
-			picreg_t buff_14_pdev :	1; /* 28:28 */
-			picreg_t buff_12_en   :	1; /* 27:27 */
-			picreg_t buff_12_vdev :	2; /* 26:25 */
-			picreg_t buff_12_pdev :	1; /* 24:24 */
-			picreg_t buff_10_en   :	1; /* 23:23 */
-			picreg_t buff_10_vdev :	2; /* 22:21 */
-			picreg_t buff_10_pdev :	1; /* 20:20 */
-			picreg_t buff_8_en    :	1; /* 19:19 */
-			picreg_t buff_8_vdev  :	2; /* 18:17 */
-			picreg_t buff_8_pdev  :	1; /* 16:16 */
-			picreg_t buff_6_en    :	1; /* 15:15 */
-			picreg_t buff_6_vdev  :	2; /* 14:13 */
-			picreg_t buff_6_pdev  :	1; /* 12:12 */
-			picreg_t buff_4_en    :	1; /* 11:11 */
-			picreg_t buff_4_vdev  :	2; /* 10:9 */
-			picreg_t buff_4_pdev  :	1; /* 8:8 */
-			picreg_t buff_2_en    :	1; /* 7:7 */
-			picreg_t buff_2_vdev  :	2; /* 6:5 */
-			picreg_t buff_2_pdev  :	1; /* 4:4 */
-			picreg_t buff_0_en    :	1; /* 3:3 */
-			picreg_t buff_0_vdev  :	2; /* 2:1 */
-			picreg_t buff_0_pdev  :	1; /* 0:0 */
-		} pic_p_even_resp_fld_s;
-	} pic_p_even_resp_u_t;
-/*
- * Odd Device Read Response Buffer Register (PCI Only)
- *
- * This register is use to allocate the read response buffers for the odd num-
- * bered devices. (1,3))
- */
-	typedef union pic_p_odd_resp_u {
-		picreg_t	pic_p_odd_resp_regval;
-		struct {
-			picreg_t              :	32; /* 63:32 */
-			picreg_t buff_15_en   :	1; /* 31:31 */
-			picreg_t buff_15_vdev :	2; /* 30:29 */
-			picreg_t buff_15_pdev :	1; /* 28:28 */
-			picreg_t buff_13_en   :	1; /* 27:27 */
-			picreg_t buff_13_vdev :	2; /* 26:25 */
-			picreg_t buff_13_pdev :	1; /* 24:24 */
-			picreg_t buff_11_en   :	1; /* 23:23 */
-			picreg_t buff_11_vdev :	2; /* 22:21 */
-			picreg_t buff_11_pdev :	1; /* 20:20 */
-			picreg_t buff_9_en    :	1; /* 19:19 */
-			picreg_t buff_9_vdev  :	2; /* 18:17 */
-			picreg_t buff_9_pdev  :	1; /* 16:16 */
-			picreg_t buff_7_en    :	1; /* 15:15 */
-			picreg_t buff_7_vdev  :	2; /* 14:13 */
-			picreg_t buff_7_pdev  :	1; /* 12:12 */
-			picreg_t buff_5_en    :	1; /* 11:11 */
-			picreg_t buff_5_vdev  :	2; /* 10:9 */
-			picreg_t buff_5_pdev  :	1; /* 8:8 */
-			picreg_t buff_3_en    :	1; /* 7:7 */
-			picreg_t buff_3_vdev  :	2; /* 6:5 */
-			picreg_t buff_3_pdev  :	1; /* 4:4 */
-			picreg_t buff_1_en    :	1; /* 3:3 */
-			picreg_t buff_1_vdev  :	2; /* 2:1 */
-			picreg_t buff_1_pdev  :	1; /* 0:0 */
-		} pic_p_odd_resp_fld_s;
-	} pic_p_odd_resp_u_t;
-/*
- * Read Response Buffer Status Register (PCI Only)
- *
- * This read only register contains the current response buffer status.
- */
-	typedef union pic_p_resp_status_u {
-		picreg_t	pic_p_resp_status_regval;
-		struct {
-			picreg_t           :	32; /* 63:32 */
-			picreg_t rrb_valid :	16; /* 31:16 */
-			picreg_t rrb_inuse :	16; /* 15:0 */
-		} pic_p_resp_status_fld_s;
-	} pic_p_resp_status_u_t;
-/*
- * Read Response Buffer Clear Register (PCI Only)
- *
- * A write to this register clears the current contents of the buffer.
- */
-	typedef union pic_p_resp_clear_u {
-		picreg_t	pic_p_resp_clear_regval;
-		struct {
-			picreg_t           :	32; /* 63:32 */
-			picreg_t           :	16; /* 31:16 */
-			picreg_t rrb_clear :	16; /* 15:0 */
-		} pic_p_resp_clear_fld_s;
-	} pic_p_resp_clear_u_t;
-/*
- * PCI Read Response Buffer (x) Upper Address Match
- *
- * The PCI Bridge read response buffer upper address register is a read only
- * register which contains the upper 16-bits of the address and status used to
- * select the buffer for a PCI transaction.
- */
-	typedef union pic_p_buf_upper_addr_match_u {
-		picreg_t	pic_p_buf_upper_addr_match_regval;
-		struct {
-			picreg_t          :	32; /* 63:32 */
-			picreg_t filled   :	1; /* 31:31 */
-			picreg_t armed    :	1; /* 30:30 */
-			picreg_t flush    :	1; /* 29:29 */
-			picreg_t xerr     :	1; /* 28:28 */
-			picreg_t pkterr   :	1; /* 27:27 */
-			picreg_t timeout  :	1; /* 26:26 */
-			picreg_t prefetch :	1; /* 25:25 */
-			picreg_t precise  :	1; /* 24:24 */
-			picreg_t dw_be    :	8; /* 23:16 */
-			picreg_t upp_addr :	16; /* 15:0 */
-		} pic_p_buf_upper_addr_match_fld_s;
-	} pic_p_buf_upper_addr_match_u_t;
-/*
- * PCI Read Response Buffer (x) Lower Address Match
- *
- * The PCI Bridge read response buffer lower address Match register is a
- * read only register which contains the address and status used to select the
- * buffer for a PCI transaction.
- */
-	typedef union pic_p_buf_lower_addr_match_u {
-		picreg_t	pic_p_buf_lower_addr_match_regval;
-		struct {
-			picreg_t filled   :	1; /* 63:63 */
-			picreg_t armed    :	1; /* 62:62 */
-			picreg_t flush    :	1; /* 61:61 */
-			picreg_t xerr     :	1; /* 60:60 */
-			picreg_t pkterr   :	1; /* 59:59 */
-			picreg_t timeout  :	1; /* 58:58 */
-			picreg_t prefetch :	1; /* 57:57 */
-			picreg_t precise  :	1; /* 56:56 */
-			picreg_t dw_be    :	8; /* 55:48 */
-			picreg_t upp_addr :	16; /* 47:32 */
-			picreg_t low_addr :	32; /* 31:0 */
-		} pic_p_buf_lower_addr_match_fld_s;
-	} pic_p_buf_lower_addr_match_u_t;
-/*
- * PCI Buffer (x) Flush Count with Data Touch Register
- *
- * This counter is incremented each time the corresponding response buffer
- * is flushed after at least a single data element in the buffer is used. A word
- * write to this address clears the count.
- */
-	typedef union pic_flush_w_touch_u {
-		picreg_t	pic_flush_w_touch_regval;
-		struct {
-			picreg_t           :	32; /* 63:32 */
-			picreg_t           :	16; /* 31:16 */
-			picreg_t touch_cnt :	16; /* 15:0 */
-		} pic_flush_w_touch_fld_s;
-	} pic_flush_w_touch_u_t;
-/*
- * PCI Buffer (x) Flush Count w/o Data Touch Register
- *
- * This counter is incremented each time the corresponding response buffer
- * is flushed without any data element in the buffer being used. A word
- * write to this address clears the count.
- */
-	typedef union pic_flush_wo_touch_u {
-		picreg_t	pic_flush_wo_touch_regval;
-		struct {
-			picreg_t             :	32; /* 63:32 */
-			picreg_t             :	16; /* 31:16 */
-			picreg_t notouch_cnt :	16; /* 15:0 */
-		} pic_flush_wo_touch_fld_s;
-	} pic_flush_wo_touch_u_t;
-/*
- * PCI Buffer (x) Request in Flight Count Register
- *
- * This counter is incremented on each bus clock while the request is in-
- * flight. A word write to this address clears the count. ]
- */
-	typedef union pic_inflight_u {
-		picreg_t	pic_inflight_regval;
-		struct {
-			picreg_t              :	32; /* 63:32 */
-			picreg_t              :	16; /* 31:16 */
-			picreg_t inflight_cnt :	16; /* 15:0 */
-		} pic_inflight_fld_s;
-	} pic_inflight_u_t;
-/*
- * PCI Buffer (x) Prefetch Request Count Register
- *
- * This counter is incremented each time the request using this buffer was
- * generated from the prefetcher. A word write to this address clears the
- * count.
- */
-	typedef union pic_prefetch_u {
-		picreg_t	pic_prefetch_regval;
-		struct {
-			picreg_t              :	32; /* 63:32 */
-			picreg_t              :	16; /* 31:16 */
-			picreg_t prefetch_cnt :	16; /* 15:0 */
-		} pic_prefetch_fld_s;
-	} pic_prefetch_u_t;
-/*
- * PCI Buffer (x) Total PCI Retry Count Register
- *
- * This counter is incremented each time a PCI bus retry occurs and the ad-
- * dress matches the tag for the selected buffer. The buffer must also has this
- * request in-flight. A word write to this address clears the count.
- */
-	typedef union pic_total_pci_retry_u {
-		picreg_t	pic_total_pci_retry_regval;
-		struct {
-			picreg_t           :	32; /* 63:32 */
-			picreg_t           :	16; /* 31:16 */
-			picreg_t retry_cnt :	16; /* 15:0 */
-		} pic_total_pci_retry_fld_s;
-	} pic_total_pci_retry_u_t;
-/*
- * PCI Buffer (x) Max PCI Retry Count Register
- *
- * This counter is contains the maximum retry count for a single request
- * which was in-flight for this buffer. A word write to this address clears the
- * count.
- */
-	typedef union pic_max_pci_retry_u {
-		picreg_t	pic_max_pci_retry_regval;
-		struct {
-			picreg_t               :	32; /* 63:32 */
-			picreg_t               :	16; /* 31:16 */
-			picreg_t max_retry_cnt :	16; /* 15:0 */
-		} pic_max_pci_retry_fld_s;
-	} pic_max_pci_retry_u_t;
-/*
- * PCI Buffer (x) Max Latency Count Register
- *
- * This counter is contains the maximum count (in bus clocks) for a single
- * request which was in-flight for this buffer. A word write to this address
- * clears the count.
- */
-	typedef union pic_max_latency_u {
-		picreg_t	pic_max_latency_regval;
-		struct {
-			picreg_t                 :	32; /* 63:32 */
-			picreg_t                 :	16; /* 31:16 */
-			picreg_t max_latency_cnt :	16; /* 15:0 */
-		} pic_max_latency_fld_s;
-	} pic_max_latency_u_t;
-/*
- * PCI Buffer (x) Clear All Register
- *
- * Any access to this register clears all the count values for the (x) registers.
- */
-
-
-/*
- * PCI-X Registers
- *
- * This register contains the address in the read buffer structure. There are
- * 16 read buffer structures.
- */
-	typedef union pic_rd_buf_addr_u {
-		picreg_t	pic_rd_buf_addr_regval;
-		struct {
-			picreg_t pcix_err_addr :	64; /* 63:0 */
-		} pic_rd_buf_addr_fld_s;
-	} pic_rd_buf_addr_u_t;
-/*
- * PCI-X Read Buffer (x) Attribute Register
- *
- * This register contains the attribute data in the read buffer structure. There
- * are  16 read buffer structures.
- */
-	typedef union pic_px_read_buf_attr_u {
-		picreg_t	pic_px_read_buf_attr_regval;
-		struct {
-			picreg_t                :	16; /* 63:48 */
-			picreg_t bus_cmd        :	4; /* 47:44 */
-			picreg_t byte_cnt       :	12; /* 43:32 */
-			picreg_t entry_valid    :	1; /* 31:31 */
-			picreg_t ns             :	1; /* 30:30 */
-			picreg_t ro             :	1; /* 29:29 */
-			picreg_t tag            :	5; /* 28:24 */
-			picreg_t bus_num        :	8; /* 23:16 */
-			picreg_t dev_num        :	5; /* 15:11 */
-			picreg_t fun_num        :	3; /* 10:8 */
-			picreg_t                :	2; /* 7:6 */
-			picreg_t f_buffer_index :	6; /* 5:0 */
-		} pic_px_read_buf_attr_fld_s;
-	} pic_px_read_buf_attr_u_t;
-/*
- * PCI-X Write Buffer (x) Address Register
- *
- * This register contains the address in the write buffer structure. There are
- * 8 write buffer structures.
- */
-	typedef union pic_px_write_buf_addr_u {
-		picreg_t	pic_px_write_buf_addr_regval;
-		struct {
-			picreg_t pcix_err_addr :	64; /* 63:0 */
-		} pic_px_write_buf_addr_fld_s;
-	} pic_px_write_buf_addr_u_t;
-/*
- * PCI-X Write Buffer (x) Attribute Register
- *
- * This register contains the attribute data in the write buffer structure.
- * There are 8 write buffer structures.
- */
-	typedef union pic_px_write_buf_attr_u {
-		picreg_t	pic_px_write_buf_attr_regval;
-		struct {
-			picreg_t                :	16; /* 63:48 */
-			picreg_t bus_cmd        :	4; /* 47:44 */
-			picreg_t byte_cnt       :	12; /* 43:32 */
-			picreg_t entry_valid    :	1; /* 31:31 */
-			picreg_t ns             :	1; /* 30:30 */
-			picreg_t ro             :	1; /* 29:29 */
-			picreg_t tag            :	5; /* 28:24 */
-			picreg_t bus_num        :	8; /* 23:16 */
-			picreg_t dev_num        :	5; /* 15:11 */
-			picreg_t fun_num        :	3; /* 10:8 */
-			picreg_t                :	2; /* 7:6 */
-			picreg_t f_buffer_index :	6; /* 5:0 */
-		} pic_px_write_buf_attr_fld_s;
-	} pic_px_write_buf_attr_u_t;
-/*
- * PCI-X Write Buffer (x) Valid Register
- *
- * This register contains the valid or inuse cache lines for this buffer struc-
- * ture.
- */
-	typedef union pic_px_write_buf_valid_u {
-		picreg_t	pic_px_write_buf_valid_regval;
-		struct {
-			picreg_t                :	32; /* 63:32 */
-			picreg_t wrt_valid_buff :	32; /* 31:0 */
-		} pic_px_write_buf_valid_fld_s;
-	} pic_px_write_buf_valid_u_t;
+/*****************************************************************************
+ *********************** PIC MMR structure mapping ***************************
+ *****************************************************************************/
+
+/* NOTE: PIC WAR. PV#854697.  PIC does not allow writes just to [31:0]
+ * of a 64-bit register.  When writing PIC registers, always write the 
+ * entire 64 bits.
+ */
+
+typedef volatile struct pic_s {
+
+    /* 0x000000-0x00FFFF -- Local Registers */
+
+    /* 0x000000-0x000057 -- Standard Widget Configuration */
+    picreg_t		p_wid_id;			/* 0x000000 */
+    picreg_t		p_wid_stat;			/* 0x000008 */
+    picreg_t		p_wid_err_upper;		/* 0x000010 */
+    picreg_t		p_wid_err_lower;		/* 0x000018 */
+    #define p_wid_err p_wid_err_lower
+    picreg_t		p_wid_control;			/* 0x000020 */
+    picreg_t		p_wid_req_timeout;		/* 0x000028 */
+    picreg_t		p_wid_int_upper;		/* 0x000030 */
+    picreg_t		p_wid_int_lower;		/* 0x000038 */
+    #define p_wid_int p_wid_int_lower
+    picreg_t		p_wid_err_cmdword;		/* 0x000040 */
+    picreg_t		p_wid_llp;			/* 0x000048 */
+    picreg_t		p_wid_tflush;			/* 0x000050 */
+
+    /* 0x000058-0x00007F -- Bridge-specific Widget Configuration */
+    picreg_t		p_wid_aux_err;			/* 0x000058 */
+    picreg_t		p_wid_resp_upper;		/* 0x000060 */
+    picreg_t		p_wid_resp_lower;		/* 0x000068 */
+    #define p_wid_resp p_wid_resp_lower
+    picreg_t		p_wid_tst_pin_ctrl;		/* 0x000070 */
+    picreg_t		p_wid_addr_lkerr;		/* 0x000078 */
+
+    /* 0x000080-0x00008F -- PMU & MAP */
+    picreg_t		p_dir_map;			/* 0x000080 */
+    picreg_t		_pad_000088;			/* 0x000088 */
+
+    /* 0x000090-0x00009F -- SSRAM */
+    picreg_t		p_map_fault;			/* 0x000090 */
+    picreg_t		_pad_000098;			/* 0x000098 */
+
+    /* 0x0000A0-0x0000AF -- Arbitration */
+    picreg_t		p_arb;				/* 0x0000A0 */
+    picreg_t		_pad_0000A8;			/* 0x0000A8 */
+
+    /* 0x0000B0-0x0000BF -- Number In A Can or ATE Parity Error */
+    picreg_t		p_ate_parity_err;		/* 0x0000B0 */
+    picreg_t		_pad_0000B8;			/* 0x0000B8 */
+
+    /* 0x0000C0-0x0000FF -- PCI/GIO */
+    picreg_t		p_bus_timeout;			/* 0x0000C0 */
+    picreg_t		p_pci_cfg;			/* 0x0000C8 */
+    picreg_t		p_pci_err_upper;		/* 0x0000D0 */
+    picreg_t		p_pci_err_lower;		/* 0x0000D8 */
+    #define p_pci_err p_pci_err_lower
+    picreg_t		_pad_0000E0[4];			/* 0x0000{E0..F8} */
+
+    /* 0x000100-0x0001FF -- Interrupt */
+    picreg_t		p_int_status;			/* 0x000100 */
+    picreg_t		p_int_enable;			/* 0x000108 */
+    picreg_t		p_int_rst_stat;			/* 0x000110 */
+    picreg_t		p_int_mode;			/* 0x000118 */
+    picreg_t		p_int_device;			/* 0x000120 */
+    picreg_t		p_int_host_err;			/* 0x000128 */
+    picreg_t		p_int_addr[8];			/* 0x0001{30,,,68} */
+    picreg_t		p_err_int_view;			/* 0x000170 */
+    picreg_t		p_mult_int;			/* 0x000178 */
+    picreg_t		p_force_always[8];		/* 0x0001{80,,,B8} */
+    picreg_t		p_force_pin[8];			/* 0x0001{C0,,,F8} */
+
+    /* 0x000200-0x000298 -- Device */
+    picreg_t		p_device[4];			/* 0x0002{00,,,18} */
+    picreg_t		_pad_000220[4];			/* 0x0002{20,,,38} */
+    picreg_t		p_wr_req_buf[4];		/* 0x0002{40,,,58} */
+    picreg_t		_pad_000260[4];			/* 0x0002{60,,,78} */
+    picreg_t		p_rrb_map[2];			/* 0x0002{80,,,88} */
+    #define p_even_resp p_rrb_map[0]			/* 0x000280 */
+    #define p_odd_resp  p_rrb_map[1]			/* 0x000288 */
+    picreg_t		p_resp_status;			/* 0x000290 */
+    picreg_t		p_resp_clear;			/* 0x000298 */
+
+    picreg_t		_pad_0002A0[12];		/* 0x0002{A0..F8} */
+
+    /* 0x000300-0x0003F8 -- Buffer Address Match Registers */
+    struct {
+	picreg_t	upper;				/* 0x0003{00,,,F0} */
+	picreg_t	lower;				/* 0x0003{08,,,F8} */
+    } p_buf_addr_match[16];
+
+    /* 0x000400-0x0005FF -- Performance Monitor Registers (even only) */
+    struct {
+	picreg_t	flush_w_touch;			/* 0x000{400,,,5C0} */
+	picreg_t	flush_wo_touch;			/* 0x000{408,,,5C8} */
+	picreg_t	inflight;			/* 0x000{410,,,5D0} */
+	picreg_t	prefetch;			/* 0x000{418,,,5D8} */
+	picreg_t	total_pci_retry;		/* 0x000{420,,,5E0} */
+	picreg_t	max_pci_retry;			/* 0x000{428,,,5E8} */
+	picreg_t	max_latency;			/* 0x000{430,,,5F0} */
+	picreg_t	clear_all;			/* 0x000{438,,,5F8} */
+    } p_buf_count[8];
+
+    
+    /* 0x000600-0x0009FF -- PCI/X registers */
+    picreg_t		p_pcix_bus_err_addr;		/* 0x000600 */
+    picreg_t		p_pcix_bus_err_attr;		/* 0x000608 */
+    picreg_t		p_pcix_bus_err_data;		/* 0x000610 */
+    picreg_t		p_pcix_pio_split_addr;		/* 0x000618 */
+    picreg_t		p_pcix_pio_split_attr;		/* 0x000620 */
+    picreg_t		p_pcix_dma_req_err_attr;	/* 0x000628 */
+    picreg_t		p_pcix_dma_req_err_addr;	/* 0x000630 */
+    picreg_t		p_pcix_timeout;			/* 0x000638 */
+
+    picreg_t		_pad_000640[120];		/* 0x000{640,,,9F8} */
+
+    /* 0x000A00-0x000BFF -- PCI/X Read&Write Buffer */
+    struct {
+	picreg_t	p_buf_addr;			/* 0x000{A00,,,AF0} */
+	picreg_t	p_buf_attr;			/* 0X000{A08,,,AF8} */
+    } p_pcix_read_buf_64[16];
+
+    struct {
+	picreg_t	p_buf_addr;			/* 0x000{B00,,,BE0} */
+	picreg_t	p_buf_attr;			/* 0x000{B08,,,BE8} */
+	picreg_t	p_buf_valid;			/* 0x000{B10,,,BF0} */
+	picreg_t	__pad1;				/* 0x000{B18,,,BF8} */
+    } p_pcix_write_buf_64[8];
+
+    /* End of Local Registers -- Start of Address Map space */
+
+    char		_pad_000c00[0x010000 - 0x000c00];
+
+    /* 0x010000-0x011fff -- Internal ATE RAM (Auto Parity Generation) */
+    picate_t		p_int_ate_ram[1024];		/* 0x010000-0x011fff */
+
+    /* 0x012000-0x013fff -- Internal ATE RAM (Manual Parity Generation) */
+    picate_t		p_int_ate_ram_mp[1024];		/* 0x012000-0x013fff */
+
+    char		_pad_014000[0x18000 - 0x014000];
+
+    /* 0x18000-0x197F8 -- PIC Write Request Ram */
+    picreg_t		p_wr_req_lower[256];		/* 0x18000 - 0x187F8 */
+    picreg_t		p_wr_req_upper[256];		/* 0x18800 - 0x18FF8 */
+    picreg_t		p_wr_req_parity[256];		/* 0x19000 - 0x197F8 */
+
+    char		_pad_019800[0x20000 - 0x019800];
+
+    /* 0x020000-0x027FFF -- PCI Device Configuration Spaces */
+    union {
+	uint8_t		c[0x1000 / 1];			/* 0x02{0000,,,7FFF} */
+	uint16_t	s[0x1000 / 2];			/* 0x02{0000,,,7FFF} */
+	uint32_t	l[0x1000 / 4];			/* 0x02{0000,,,7FFF} */
+	uint64_t	d[0x1000 / 8];			/* 0x02{0000,,,7FFF} */
+	union {
+	    uint8_t	c[0x100 / 1];
+	    uint16_t	s[0x100 / 2];
+	    uint32_t	l[0x100 / 4];
+	    uint64_t	d[0x100 / 8];
+	} f[8];
+    } p_type0_cfg_dev[8];				/* 0x02{0000,,,7FFF} */
+
+    /* 0x028000-0x028FFF -- PCI Type 1 Configuration Space */
+    union {
+	uint8_t		c[0x1000 / 1];			/* 0x028000-0x029000 */
+	uint16_t	s[0x1000 / 2];			/* 0x028000-0x029000 */
+	uint32_t	l[0x1000 / 4];			/* 0x028000-0x029000 */
+	uint64_t	d[0x1000 / 8];			/* 0x028000-0x029000 */
+	union {
+	    uint8_t	c[0x100 / 1];
+	    uint16_t	s[0x100 / 2];
+	    uint32_t	l[0x100 / 4];
+	    uint64_t	d[0x100 / 8];
+	} f[8];
+    } p_type1_cfg;					/* 0x028000-0x029000 */
+
+    char		_pad_029000[0x030000-0x029000];
+
+    /* 0x030000-0x030007 -- PCI Interrupt Acknowledge Cycle */
+    union {
+	uint8_t		c[8 / 1];
+	uint16_t	s[8 / 2];
+	uint32_t	l[8 / 4];
+	uint64_t	d[8 / 8];
+    } p_pci_iack;					/* 0x030000-0x030007 */
+
+    char		_pad_030007[0x040000-0x030008];
+
+    /* 0x040000-0x030007 -- PCIX Special Cycle */
+    union {
+	uint8_t		c[8 / 1];
+	uint16_t	s[8 / 2];
+	uint32_t	l[8 / 4];
+	uint64_t	d[8 / 8];
+    } p_pcix_cycle;					/* 0x040000-0x040007 */
+} pic_t;
 
-#endif				/* __ASSEMBLY__ */
-#endif                          /* _ASM_SN_PCI_PIC_H */
+#endif                          /* _ASM_IA64_SN_PCI_PIC_H */
diff -puN include/asm-ia64/sn/pda.h~linus include/asm-ia64/sn/pda.h
--- 25/include/asm-ia64/sn/pda.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/pda.h	2004-01-19 22:17:24.000000000 -0800
@@ -10,7 +10,6 @@
 
 #include <linux/config.h>
 #include <linux/cache.h>
-#include <linux/numa.h>
 #include <asm/percpu.h>
 #include <asm/system.h>
 #include <asm/processor.h>
@@ -61,6 +60,7 @@ typedef struct pda_s {
 	int		sn_lb_int_war_ticks;
 	int		sn_last_irq;
 	int		sn_first_irq;
+	int		sn_num_irqs;			/* number of irqs targeted for this cpu */
 } pda_t;
 
 
diff -puN include/asm-ia64/sn/pio.h~linus include/asm-ia64/sn/pio.h
--- 25/include/asm-ia64/sn/pio.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/pio.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -30,8 +29,8 @@ typedef volatile ulong*	pioaddr_t;
 
 
 typedef struct piomap {
-	uint		pio_bus;
-	uint		pio_adap;
+	unsigned int	pio_bus;
+	unsigned int	pio_adap;
 	int		pio_flag;
 	int		pio_reg;
 	char		pio_name[7];	/* to identify the mapped device */
diff -puN include/asm-ia64/sn/prio.h~linus include/asm-ia64/sn/prio.h
--- 25/include/asm-ia64/sn/prio.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/prio.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -puN include/asm-ia64/sn/router.h~linus include/asm-ia64/sn/router.h
--- 25/include/asm-ia64/sn/router.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/router.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -puN include/asm-ia64/sn/sgi.h~linus include/asm-ia64/sn/sgi.h
--- 25/include/asm-ia64/sn/sgi.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/sgi.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
 /*
- *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -21,14 +20,15 @@
 
 typedef hwgfs_handle_t vertex_hdl_t;
 
-typedef int64_t  __psint_t;	/* needed by klgraph.c */
-
-typedef enum { B_FALSE, B_TRUE } boolean_t;
+/* Nice general name length that lots of people like to use */
+#ifndef MAXDEVNAME
+#define MAXDEVNAME 256
+#endif
 
 
 /*
-** Possible return values from graph routines.
-*/
+ * Possible return values from graph routines.
+ */
 typedef enum graph_error_e {
 	GRAPH_SUCCESS,		/* 0 */
 	GRAPH_DUP,		/* 1 */
@@ -40,67 +40,15 @@ typedef enum graph_error_e {
 	GRAPH_IN_USE		/* 7 */
 } graph_error_t;
 
-#define KM_SLEEP   0x0000
-#define KM_NOSLEEP 0x0001		/* needed by kmem_alloc_node(), kmem_zalloc()
-					 * calls */
-#define VM_NOSLEEP 0x0001		/* needed kmem_alloc_node(), kmem_zalloc_node
-					 * calls */
-#define XG_WIDGET_PART_NUM      0xC102          /* KONA/xt_regs.h     XG_XT_PART_NUM_VALUE */
-
-typedef uint64_t vhandl_t;
-
-
-#define NBPP PAGE_SIZE
-#define _PAGESZ PAGE_SIZE
-
-#ifndef MAXDEVNAME
-#define MAXDEVNAME 256
-#endif
-
-#define HUB_PIO_CONVEYOR 0x1
 #define CNODEID_NONE ((cnodeid_t)-1)
-#define XTALK_PCI_PART_NUM "030-1275-"
-#define kdebug 0
-
-
-#define COPYIN(a, b, c)		copy_from_user(b,a,c)
-#define COPYOUT(a, b, c)	copy_to_user(b,a,c)
-
-#define BZERO(a,b)		memset(a, 0, b)
-
-#define kern_malloc(x)		kmalloc(x, GFP_KERNEL)
-#define kern_free(x)		kfree(x)
-
-typedef cpuid_t cpu_cookie_t;
 #define CPU_NONE		(-1)
+#define GRAPH_VERTEX_NONE ((vertex_hdl_t)-1)
+
 
 /*
- * mutext support mapping
+ * No code is complete without an Assertion macro
  */
 
-#define mutex_spinlock_init(s)	spin_lock_init(s)
-inline static unsigned long
-mutex_spinlock(spinlock_t *sem) {
-	unsigned long flags = 0;
-//	spin_lock_irqsave(sem, flags);
-	spin_lock(sem);
-	return(flags);
-}
-// #define mutex_spinunlock(s,t)	spin_unlock_irqrestore(s,t)
-#define mutex_spinunlock(s,t)	spin_unlock(s)
-
-
-#define mutex_t			struct semaphore
-#define mutex_init(s)		init_MUTEX(s)
-#define mutex_init_locked(s)	init_MUTEX_LOCKED(s)
-#define mutex_lock(s)		down(s)
-#define mutex_unlock(s)		up(s)
-
-#define io_splock(s)		mutex_spinlock(s)
-#define io_spunlock(s,t)	spin_unlock(s)
-
-#define spin_lock_destroy(s)
-
 #if defined(DISABLE_ASSERT)
 #define ASSERT(expr)
 #define ASSERT_ALWAYS(expr)
@@ -120,58 +68,4 @@ mutex_spinlock(spinlock_t *sem) {
         } } while(0)
 #endif	/* DISABLE_ASSERT */
 
-#define PRINT_PANIC		panic
-
-/* print_register() defs */
-
-/*
- * register values
- * map between numeric values and symbolic values
- */
-struct reg_values {
-	unsigned long long rv_value;
-	char *rv_name;
-};
-
-/*
- * register descriptors are used for formatted prints of register values
- * rd_mask and rd_shift must be defined, other entries may be null
- */
-struct reg_desc {
-	unsigned long long rd_mask;	/* mask to extract field */
-	int rd_shift;		/* shift for extracted value, - >>, + << */
-	char *rd_name;		/* field name */
-	char *rd_format;	/* format to print field */
-	struct reg_values *rd_values;	/* symbolic names of values */
-};
-
-extern void print_register(unsigned long long, struct reg_desc *);
-
-/******************************************
- * Definitions that do not exist in linux *
- ******************************************/
-
-#define DELAY(a)
-
-/************************************************
- * Routines redefined to use linux equivalents. *
- ************************************************/
-
-/* #define FIXME(s) printk("FIXME: [ %s ] in %s at %s:%d\n", s, __FUNCTION__, __FILE__, __LINE__) */
-
-#define FIXME(s)
-
-/* move to stubs.c yet */
-#define dev_to_vhdl(dev) 0
-#define get_timestamp() 0
-#define us_delay(a)
-#define v_mapphys(a,b,c) 0    // printk("Fixme: v_mapphys - soft->base 0x%p\n", b);
-#define splhi()  0
-#define splx(s)
-
-extern void * snia_kmem_alloc_node(register size_t, register int, cnodeid_t);
-extern void * snia_kmem_zalloc(size_t, int);
-extern void * snia_kmem_zalloc_node(register size_t, register int, cnodeid_t );
-extern int is_specified(char *);
-
 #endif /* _ASM_IA64_SN_SGI_H */
diff -puN include/asm-ia64/sn/slotnum.h~linus include/asm-ia64/sn/slotnum.h
--- 25/include/asm-ia64/sn/slotnum.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/slotnum.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -puN include/asm-ia64/sn/sn2/addrs.h~linus include/asm-ia64/sn/sn2/addrs.h
--- 25/include/asm-ia64/sn/sn2/addrs.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/sn2/addrs.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
 /*
- *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -107,9 +106,9 @@ typedef union ia64_sn2_pa {
 #define NASID_META_BITS		0	/* ???? */
 #define NASID_LOCAL_BITS	7	/* same router as SN1 */
 
-#define NODE_ADDRSPACE_SIZE     (UINT64_CAST 1 << NODE_SIZE_BITS)
-#define NASID_MASK              (UINT64_CAST NASID_BITMASK << NASID_SHFT)
-#define NASID_GET(_pa)          (int) ((UINT64_CAST (_pa) >>            \
+#define NODE_ADDRSPACE_SIZE     (1UL << NODE_SIZE_BITS)
+#define NASID_MASK              ((uint64_t) NASID_BITMASK << NASID_SHFT)
+#define NASID_GET(_pa)          (int) (((uint64_t) (_pa) >>            \
                                         NASID_SHFT) & NASID_BITMASK)
 #define PHYS_TO_DMA(x)          ( ((x & NASID_MASK) >> 2) |             \
                                   (x & (NODE_ADDRSPACE_SIZE - 1)) )
@@ -130,9 +129,9 @@ typedef union ia64_sn2_pa {
         : RAW_NODE_SWIN_BASE(nasid, widget))
 #else
 #define NODE_SWIN_BASE(nasid, widget) \
-     (NODE_IO_BASE(nasid) + (UINT64_CAST (widget) << SWIN_SIZE_BITS))
+     (NODE_IO_BASE(nasid) + ((uint64_t) (widget) << SWIN_SIZE_BITS))
 #define LOCAL_SWIN_BASE(widget) \
-	(UNCACHED | LOCAL_MMR_SPACE | ((UINT64_CAST (widget) << SWIN_SIZE_BITS)))
+	(UNCACHED | LOCAL_MMR_SPACE | (((uint64_t) (widget) << SWIN_SIZE_BITS)))
 #endif /* __ASSEMBLY__ */
 
 /*
@@ -142,12 +141,12 @@ typedef union ia64_sn2_pa {
  */
 
 #define BWIN_INDEX_BITS         3
-#define BWIN_SIZE               (UINT64_CAST 1 << BWIN_SIZE_BITS)
+#define BWIN_SIZE               (1UL << BWIN_SIZE_BITS)
 #define BWIN_SIZEMASK           (BWIN_SIZE - 1)
 #define BWIN_WIDGET_MASK        0x7
 #define NODE_BWIN_BASE0(nasid)  (NODE_IO_BASE(nasid) + BWIN_SIZE)
 #define NODE_BWIN_BASE(nasid, bigwin)   (NODE_BWIN_BASE0(nasid) +       \
-                        (UINT64_CAST (bigwin) << BWIN_SIZE_BITS))
+                        ((uint64_t) (bigwin) << BWIN_SIZE_BITS))
 
 #define BWIN_WIDGETADDR(addr)   ((addr) & BWIN_SIZEMASK)
 #define BWIN_WINDOWNUM(addr)    (((addr) >> BWIN_SIZE_BITS) & BWIN_WIDGET_MASK)
diff -puN include/asm-ia64/sn/sn2/arch.h~linus include/asm-ia64/sn/sn2/arch.h
--- 25/include/asm-ia64/sn/sn2/arch.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/sn2/arch.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id: arch.h,v 1.1 2002/02/28 17:31:25 marcelo Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -28,7 +27,7 @@
  * Effectively, it's the maximum number of compact node ids (cnodeid_t).
  * This is not necessarily the same as MAX_NASIDS.
  */
-#define MAX_COMPACT_NODES       128
+#define MAX_COMPACT_NODES       2048
 
 /*
  * MAX_REGIONS refers to the maximum number of hardware partitioned regions.
diff -puN include/asm-ia64/sn/sn2/geo.h~linus include/asm-ia64/sn/sn2/geo.h
--- 25/include/asm-ia64/sn/sn2/geo.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/sn2/geo.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -7,8 +6,8 @@
  * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
  */
 
-#ifndef __SYS_SN_SN2_GEO_H__
-#define __SYS_SN_SN2_GEO_H__
+#ifndef _ASM_IA64_SN_SN2_GEO_H
+#define _ASM_IA64_SN_SN2_GEO_H
 
 /* Headers required by declarations in this file */
 
@@ -106,4 +105,4 @@ typedef union geoid_u {
 
 #define GEO_INVALID_STR		"<invalid>"
 
-#endif /* __SYS_SN_SN2_GEO_H__ */
+#endif /* _ASM_IA64_SN_SN2_GEO_H */
diff -puN include/asm-ia64/sn/sn2/intr.h~linus include/asm-ia64/sn/sn2/intr.h
--- 25/include/asm-ia64/sn/sn2/intr.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/sn2/intr.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id: intr.h,v 1.1 2002/02/28 17:31:25 marcelo Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -puN include/asm-ia64/sn/sn2/shub.h~linus include/asm-ia64/sn/sn2/shub.h
--- 25/include/asm-ia64/sn/sn2/shub.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/sn2/shub.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
 /*
- *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -puN include/asm-ia64/sn/sn2/shubio.h~linus include/asm-ia64/sn/sn2/shubio.h
--- 25/include/asm-ia64/sn/sn2/shubio.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/sn2/shubio.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id: shubio.h,v 1.1 2002/02/28 17:31:25 marcelo Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -220,8 +219,6 @@
 #define    IIO_IPPR                  0x00430008    /* IO Performance Profiling */
 
 
-#ifndef __ASSEMBLY__
-
 /************************************************************************
  *                                                                      *
  * Description:  This register echoes some information from the         *
@@ -2845,8 +2842,6 @@ typedef union ii_ippr_u {
 } ii_ippr_u_t;
 
 
-#endif /* __ASSEMBLY__ */
-
 /**************************************************************************
  *                                                                        *
  * The following defines which were not formed into structures are        *
@@ -3390,7 +3385,6 @@ typedef ii_icrb0_e_u_t icrbe_t;
 #define IO_PERF_SETS	32
 
 #if __KERNEL__
-#ifndef __ASSEMBLY__
 #include <asm/sn/alenlist.h>
 #include <asm/sn/dmamap.h>
 #include <asm/sn/driver.h>
@@ -3626,10 +3620,6 @@ extern int      hub_widget_flags_set(nas
 extern int hub_ioerror_handler(vertex_hdl_t, int, int, struct io_error_s *);
 extern int kl_ioerror_handler(cnodeid_t, cnodeid_t, cpuid_t,
                               int, paddr_t, caddr_t, ioerror_mode_t);
-extern int hub_error_devenable(vertex_hdl_t, int, int);
-extern int  hub_dma_enabled(vertex_hdl_t);
-
-#endif /* __ASSEMBLY__ */
 #endif /* _KERNEL */
 #endif /* _ASM_IA64_SN_SN2_SHUBIO_H */
 
diff -puN include/asm-ia64/sn/sn2/shub_md.h~linus include/asm-ia64/sn/sn2/shub_md.h
--- 25/include/asm-ia64/sn/sn2/shub_md.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/sn2/shub_md.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
 /*
- *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -8,8 +7,8 @@
  */
 
 
-#ifndef _SHUB_MD_H
-#define _SHUB_MD_H
+#ifndef _ASM_IA64_SN_SN2_SHUB_MD_H
+#define _ASM_IA64_SN_SN2_SHUB_MD_H
 
 /* SN2 supports a mostly-flat address space with 4 CPU-visible, evenly spaced, 
    contiguous regions, or "software banks".  On SN2, software bank n begins at 
@@ -273,4 +272,4 @@
 #define MD_BIST_MISCOMPARE(_n) (REMOTE_HUB_L(_n, SH_MMRBIST_ERR) &	\
 		SH_MMRBIST_ERR_DETECTED_MASK)
 
-#endif	/* _SHUB_MD_H */
+#endif	/* _ASM_IA64_SN_SN2_SHUB_MD_H */
diff -puN include/asm-ia64/sn/sn2/sn_private.h~linus include/asm-ia64/sn/sn2/sn_private.h
--- 25/include/asm-ia64/sn/sn2/sn_private.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/sn2/sn_private.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id: sn_private.h,v 1.1 2002/02/28 17:31:26 marcelo Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
@@ -22,12 +21,11 @@ extern void mem_init(void);
 extern void cpu_unenable(cpuid_t);
 extern nasid_t get_lowest_nasid(void);
 extern __psunsigned_t get_master_bridge_base(void);
-extern void set_master_bridge_base(void);
 extern int check_nasid_equiv(nasid_t, nasid_t);
-extern nasid_t get_console_nasid(void);
 extern char get_console_pcislot(void);
 
-extern int is_master_baseio_nasid_widget(nasid_t test_nasid, xwidgetnum_t test_wid);
+extern int is_master_baseio_nasid_widget(nasid_t test_nasid,
+					 xwidgetnum_t test_wid);
 
 /* memsupport.c */
 extern void poison_state_alter_range(__psunsigned_t start, int len, int poison);
@@ -45,7 +43,7 @@ extern int is_POISONED_dir_state(paddr_t
 extern int is_UNOWNED_dir_state(paddr_t);
 #ifdef LATER
 extern void get_dir_ent(paddr_t paddr, int *state,
-			uint64_t *vec_ptr, hubreg_t *elo);
+			uint64_t * vec_ptr, hubreg_t * elo);
 #endif
 
 /* intr.c */
@@ -59,10 +57,11 @@ extern void setrtvector(intr_func_t);
 extern void install_cpuintr(cpuid_t cpu);
 extern void install_dbgintr(cpuid_t cpu);
 extern void install_tlbintr(cpuid_t cpu);
-extern void hub_migrintr_init(cnodeid_t /*cnode*/);
-extern int cause_intr_connect(int level, intr_func_t handler, uint intr_spl_mask);
+extern void hub_migrintr_init(cnodeid_t /*cnode */ );
+extern int cause_intr_connect(int level, intr_func_t handler,
+			      unsigned int intr_spl_mask);
 extern int cause_intr_disconnect(int level);
-extern void intr_dumpvec(cnodeid_t cnode, void (*pf)(char *, ...));
+extern void intr_dumpvec(cnodeid_t cnode, void (*pf) (char *, ...));
 
 /* error_dump.c */
 extern char *hub_rrb_err_type[];
@@ -92,10 +91,10 @@ extern void setup_replication_mask(int m
 
 /* init.c */
 extern cnodeid_t get_compact_nodeid(void);	/* get compact node id */
-extern void init_platform_nodepda(nodepda_t *npda, cnodeid_t node);
+extern void init_platform_nodepda(nodepda_t * npda, cnodeid_t node);
 extern int is_fine_dirmode(void);
 extern void update_node_information(cnodeid_t);
- 
+
 /* shubio.c */
 extern void hubio_init(void);
 extern void hub_merge_clean(nasid_t nasid);
@@ -103,14 +102,14 @@ extern void hub_set_piomode(nasid_t nasi
 
 /* shuberror.c */
 extern void hub_error_init(cnodeid_t);
-extern void dump_error_spool(cpuid_t cpu, void (*pf)(char *, ...));
+extern void dump_error_spool(cpuid_t cpu, void (*pf) (char *, ...));
 extern void hubni_error_handler(char *, int);
 extern int check_ni_errors(void);
 
 /* Used for debugger to signal upper software a breakpoint has taken place */
 
-extern void		*debugger_update;
-extern __psunsigned_t	debugger_stopped;
+extern void *debugger_update;
+extern __psunsigned_t debugger_stopped;
 
 /* 
  * piomap, created by shub_pio_alloc.
@@ -118,11 +117,11 @@ extern __psunsigned_t	debugger_stopped;
  * xtalk_piomap_s by generic xtalk routines.
  */
 struct hub_piomap_s {
-	struct xtalk_piomap_s	hpio_xtalk_info;/* standard crosstalk pio info */
-	vertex_hdl_t		hpio_hub;	/* which shub's mapping registers are set up */
-	short			hpio_holdcnt;	/* count of current users of bigwin mapping */
-	char			hpio_bigwin_num;/* if big window map, which one */
-	int 			hpio_flags;	/* defined below */
+	struct xtalk_piomap_s hpio_xtalk_info;	/* standard crosstalk pio info */
+	vertex_hdl_t hpio_hub;	/* which shub's mapping registers are set up */
+	short hpio_holdcnt;	/* count of current users of bigwin mapping */
+	char hpio_bigwin_num;	/* if big window map, which one */
+	int hpio_flags;		/* defined below */
 };
 /* hub_piomap flags */
 #define HUB_PIOMAP_IS_VALID		0x1
@@ -139,9 +138,9 @@ struct hub_piomap_s {
  * xtalk_dmamap_s by generic xtalk routines.
  */
 struct hub_dmamap_s {
-	struct xtalk_dmamap_s	hdma_xtalk_info;/* standard crosstalk dma info */
-	vertex_hdl_t		hdma_hub;	/* which shub we go through */
-	int			hdma_flags;	/* defined below */
+	struct xtalk_dmamap_s hdma_xtalk_info;	/* standard crosstalk dma info */
+	vertex_hdl_t hdma_hub;	/* which shub we go through */
+	int hdma_flags;		/* defined below */
 };
 /* shub_dmamap flags */
 #define HUB_DMAMAP_IS_VALID		0x1
@@ -154,30 +153,29 @@ struct hub_dmamap_s {
  * xtalk_intr_s by generic xtalk routines.
  */
 struct hub_intr_s {
-	struct xtalk_intr_s	i_xtalk_info;	/* standard crosstalk intr info */
-	ilvl_t			i_swlevel;	/* software level for blocking intr */
-	cpuid_t			i_cpuid;	/* which cpu */
-	int			i_bit;		/* which bit */
-	int			i_flags;
+	struct xtalk_intr_s i_xtalk_info;	/* standard crosstalk intr info */
+	cpuid_t i_cpuid;	/* which cpu */
+	int i_bit;		/* which bit */
+	int i_flags;
 };
 /* flag values */
 #define HUB_INTR_IS_ALLOCED	0x1	/* for debug: allocated */
 #define HUB_INTR_IS_CONNECTED	0x4	/* for debug: connected to a software driver */
 
 typedef struct hubinfo_s {
-	nodepda_t			*h_nodepda;	/* pointer to node's private data area */
-	cnodeid_t			h_cnodeid;	/* compact nodeid */
-	nasid_t				h_nasid;	/* nasid */
+	nodepda_t *h_nodepda;	/* pointer to node's private data area */
+	cnodeid_t h_cnodeid;	/* compact nodeid */
+	nasid_t h_nasid;	/* nasid */
 
 	/* structures for PIO management */
-	xwidgetnum_t			h_widgetid;	/* my widget # (as viewed from xbow) */
-	struct hub_piomap_s		h_small_window_piomap[HUB_WIDGET_ID_MAX+1];
-	wait_queue_head_t		h_bwwait;	/* wait for big window to free */
-	spinlock_t			h_bwlock;	/* guard big window piomap's */
-	spinlock_t			h_crblock;      /* gaurd CRB error handling */
-	int				h_num_big_window_fixed;	/* count number of FIXED maps */
-	struct hub_piomap_s		h_big_window_piomap[HUB_NUM_BIG_WINDOW];
-	hub_intr_t			hub_ii_errintr;
+	xwidgetnum_t h_widgetid;	/* my widget # (as viewed from xbow) */
+	struct hub_piomap_s h_small_window_piomap[HUB_WIDGET_ID_MAX + 1];
+	wait_queue_head_t h_bwwait;	/* wait for big window to free */
+	spinlock_t h_bwlock;		/* guard big window piomap's */
+	spinlock_t h_crblock;		/* gaurd CRB error handling */
+	int h_num_big_window_fixed;	/* count number of FIXED maps */
+	struct hub_piomap_s h_big_window_piomap[HUB_NUM_BIG_WINDOW];
+	hub_intr_t hub_ii_errintr;
 } *hubinfo_t;
 
 #define hubinfo_get(vhdl, infoptr) ((void)hwgraph_info_get_LBL \
@@ -195,10 +193,10 @@ typedef struct hubinfo_s {
 			(&hinfo->h_big_window_piomap[win])
 #define	hubinfo_swin_piomap_get(hinfo, win)	\
 			(&hinfo->h_small_window_piomap[win])
-	
+
 /* cpu-specific information stored under INFO_LBL_CPU_INFO */
 typedef struct cpuinfo_s {
-	cpuid_t		ci_cpuid;	/* CPU ID */
+	cpuid_t ci_cpuid;	/* CPU ID */
 } *cpuinfo_t;
 
 #define cpuinfo_get(vhdl, infoptr) ((void)hwgraph_info_get_LBL \
@@ -211,6 +209,7 @@ typedef struct cpuinfo_s {
 extern void xswitch_vertex_init(vertex_hdl_t xswitch);
 
 extern xtalk_provider_t hub_provider;
+extern int numionodes;
 
 /* du.c */
 int ducons_write(char *buf, int len);
@@ -233,15 +232,15 @@ extern void sysctlr_keepalive(void);
  */
 #define paddr_dimm(_pa)		((_pa & MD_BANK_MASK) >> MD_BANK_SHFT)
 #define paddr_cnode(_pa)	(NASID_TO_COMPACT_NODEID(NASID_GET(_pa)))
-extern void membank_pathname_get(paddr_t,char *);
+extern void membank_pathname_get(paddr_t, char *);
 
 /* To redirect the output into the error buffer */
 #define errbuf_print(_s)	printf("#%s",_s)
 
-extern void crbx(nasid_t nasid, void (*pf)(char *, ...));
+extern void crbx(nasid_t nasid, void (*pf) (char *, ...));
 void bootstrap(void);
 
 /* sndrv.c */
 extern int sndrv_attach(vertex_hdl_t vertex);
 
-#endif /* _ASM_IA64_SN_SN2_SN_PRIVATE_H */
+#endif				/* _ASM_IA64_SN_SN2_SN_PRIVATE_H */
diff -puN include/asm-ia64/sn/sndrv.h~linus include/asm-ia64/sn/sndrv.h
--- 25/include/asm-ia64/sn/sndrv.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/sndrv.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,33 +1,9 @@
 /*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
  * Copyright (c) 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
- * 
- * This program is free software; you can redistribute it and/or modify it 
- * under the terms of version 2 of the GNU General Public License 
- * as published by the Free Software Foundation.
- * 
- * This program is distributed in the hope that it would be useful, but 
- * WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * 
- * Further, this software is distributed without any warranty that it is 
- * free of the rightful claim of any third person regarding infringement 
- * or the like.  Any license provided herein, whether implied or 
- * otherwise, applies only to this software file.  Patent licenses, if 
- * any, provided herein do not apply to combinations of this program with 
- * other software, or any other product whatsoever.
- * 
- * You should have received a copy of the GNU General Public 
- * License along with this program; if not, write the Free Software 
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- * 
- * Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 
- * Mountain View, CA  94043, or:
- * 
- * http://www.sgi.com 
- * 
- * For further information regarding this notice, see: 
- * 
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan
  */
 
 #ifndef _ASM_IA64_SN_SNDRV_H
diff -puN include/asm-ia64/sn/sn_fru.h~linus include/asm-ia64/sn/sn_fru.h
--- 25/include/asm-ia64/sn/sn_fru.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/sn_fru.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -puN include/asm-ia64/sn/sn_private.h~linus include/asm-ia64/sn/sn_private.h
--- 25/include/asm-ia64/sn/sn_private.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/sn_private.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -puN include/asm-ia64/sn/sn_sal.h~linus include/asm-ia64/sn/sn_sal.h
--- 25/include/asm-ia64/sn/sn_sal.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/sn_sal.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,7 +16,9 @@
 #include <asm/sal.h>
 #include <asm/sn/sn_cpuid.h>
 #include <asm/sn/arch.h>
-
+#include <asm/sn/nodepda.h>
+#include <asm/sn/klconfig.h>
+        
 
 // SGI Specific Calls
 #define  SN_SAL_POD_MODE                           0x02000001
@@ -167,28 +169,23 @@ static inline u64
 ia64_sn_get_klconfig_addr(nasid_t nasid)
 {
 	struct ia64_sal_retval ret_stuff;
-	extern u64 klgraph_addr[];
 	int cnodeid;
 
 	cnodeid = nasid_to_cnodeid(nasid);
-	if (klgraph_addr[cnodeid] == 0) {
-		ret_stuff.status = 0;
-		ret_stuff.v0 = 0;
-		ret_stuff.v1 = 0;
-		ret_stuff.v2 = 0;
-		SAL_CALL(ret_stuff, SN_SAL_GET_KLCONFIG_ADDR, (u64)nasid, 0, 0, 0, 0, 0, 0);
-
-		/*
-	 	* We should panic if a valid cnode nasid does not produce
-	 	* a klconfig address.
-	 	*/
-		if (ret_stuff.status != 0) {
-			panic("ia64_sn_get_klconfig_addr: Returned error %lx\n", ret_stuff.status);
-		}
+	ret_stuff.status = 0;
+	ret_stuff.v0 = 0;
+	ret_stuff.v1 = 0;
+	ret_stuff.v2 = 0;
+	SAL_CALL(ret_stuff, SN_SAL_GET_KLCONFIG_ADDR, (u64)nasid, 0, 0, 0, 0, 0, 0);
 
-		klgraph_addr[cnodeid] = ret_stuff.v0;
+	/*
+	 * We should panic if a valid cnode nasid does not produce
+	 * a klconfig address.
+	 */
+	if (ret_stuff.status != 0) {
+		panic("ia64_sn_get_klconfig_addr: Returned error %lx\n", ret_stuff.status);
 	}
-	return(klgraph_addr[cnodeid]);
+	return(ret_stuff.v0);
 }
 
 /*
@@ -597,8 +594,16 @@ static inline int
 sn_change_memprotect(u64 paddr, u64 len, u64 perms, u64 *nasid_array)
 {
 	struct ia64_sal_retval ret_stuff;
-	SAL_CALL(ret_stuff, SN_SAL_MEMPROTECT, paddr, len, nasid_array,
+	int cnodeid;
+	unsigned long irq_flags;
+
+	cnodeid = nasid_to_cnodeid(get_node_number(paddr));
+	spin_lock(&NODEPDA(cnodeid)->bist_lock);
+	local_irq_save(irq_flags);
+	SAL_CALL_NOLOCK(ret_stuff, SN_SAL_MEMPROTECT, paddr, len, nasid_array,
 		 perms, 0, 0, 0);
+	local_irq_restore(irq_flags);
+	spin_unlock(&NODEPDA(cnodeid)->bist_lock);
 	return ret_stuff.status;
 }
 #define SN_MEMPROT_ACCESS_CLASS_0		0x14a080
diff -puN include/asm-ia64/sn/vector.h~linus include/asm-ia64/sn/vector.h
--- 25/include/asm-ia64/sn/vector.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/vector.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
diff -puN include/asm-ia64/sn/xtalk/xbow.h~linus include/asm-ia64/sn/xtalk/xbow.h
--- 25/include/asm-ia64/sn/xtalk/xbow.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/xtalk/xbow.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,13 +1,12 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * Copyright (C) 1992-1997,2000-2003 Silicon Graphics, Inc. All Rights Reserved.
  */
-#ifndef _ASM_SN_SN_XTALK_XBOW_H
-#define _ASM_SN_SN_XTALK_XBOW_H
+#ifndef _ASM_IA64_SN_XTALK_XBOW_H
+#define _ASM_IA64_SN_XTALK_XBOW_H
 
 /*
  * xbow.h - header file for crossbow chip and xbow section of xbridge
@@ -64,7 +63,6 @@ typedef uint32_t      xbowreg_t;
 
 /* Register set for each xbow link */
 typedef volatile struct xb_linkregs_s {
-#ifdef LITTLE_ENDIAN
 /* 
  * we access these through synergy unswizzled space, so the address
  * gets twiddled (i.e. references to 0x4 actually go to 0x0 and vv.)
@@ -86,24 +84,6 @@ typedef volatile struct xb_linkregs_s {
     xbowreg_t               filler6;
     xbowreg_t               link_aux_status;
     xbowreg_t               filler7;
-#else
-    xbowreg_t               filler0;	/* filler for proper alignment */
-    xbowreg_t               link_ibf;
-    xbowreg_t               filler1;
-    xbowreg_t               link_control;
-    xbowreg_t               filler2;
-    xbowreg_t               link_status;
-    xbowreg_t               filler3;
-    xbowreg_t               link_arb_upper;
-    xbowreg_t               filler4;
-    xbowreg_t               link_arb_lower;
-    xbowreg_t               filler5;
-    xbowreg_t               link_status_clr;
-    xbowreg_t               filler6;
-    xbowreg_t               link_reset;
-    xbowreg_t               filler7;
-    xbowreg_t               link_aux_status;
-#endif /* LITTLE_ENDIAN */
 } xb_linkregs_t;
 
 typedef volatile struct xbow_s {
@@ -124,7 +104,6 @@ typedef volatile struct xbow_s {
 #define xb_wid_llp                      xb_widget.w_llp_cfg
 #define xb_wid_stat_clr                 xb_widget.w_tflush
 
-#ifdef LITTLE_ENDIAN
 /* 
  * we access these through synergy unswizzled space, so the address
  * gets twiddled (i.e. references to 0x4 actually go to 0x0 and vv.)
@@ -165,43 +144,6 @@ typedef volatile struct xbow_s {
     xbowreg_t               _pad_0000c8;
     /* end of Xbridge only */
     xbowreg_t               _pad_0000d0[12];
-#else
-    /* xbow-specific widget configuration                  0x000058-0x0000FF */
-    xbowreg_t               _pad_000058;
-    xbowreg_t               xb_wid_arb_reload;  /* 0x00005C */
-    xbowreg_t               _pad_000060;
-    xbowreg_t               xb_perf_ctr_a;      /* 0x000064 */
-    xbowreg_t               _pad_000068;
-    xbowreg_t               xb_perf_ctr_b;      /* 0x00006c */
-    xbowreg_t               _pad_000070;
-    xbowreg_t               xb_nic;     /* 0x000074 */
-
-    /* Xbridge only */
-    xbowreg_t               _pad_000078;
-    xbowreg_t               xb_w0_rst_fnc;      /* 0x00007C */
-    xbowreg_t               _pad_000080;
-    xbowreg_t               xb_l8_rst_fnc;      /* 0x000084 */
-    xbowreg_t               _pad_000088;
-    xbowreg_t               xb_l9_rst_fnc;      /* 0x00008c */
-    xbowreg_t               _pad_000090;
-    xbowreg_t               xb_la_rst_fnc;      /* 0x000094 */
-    xbowreg_t               _pad_000098;
-    xbowreg_t               xb_lb_rst_fnc;      /* 0x00009c */
-    xbowreg_t               _pad_0000a0;
-    xbowreg_t               xb_lc_rst_fnc;      /* 0x0000a4 */
-    xbowreg_t               _pad_0000a8;
-    xbowreg_t               xb_ld_rst_fnc;      /* 0x0000ac */
-    xbowreg_t               _pad_0000b0;
-    xbowreg_t               xb_le_rst_fnc;      /* 0x0000b4 */
-    xbowreg_t               _pad_0000b8;
-    xbowreg_t               xb_lf_rst_fnc;      /* 0x0000bc */
-    xbowreg_t               _pad_0000c0;
-    xbowreg_t               xb_lock;            /* 0x0000c4 */
-    xbowreg_t               _pad_0000c8;
-    xbowreg_t               xb_lock_clr;        /* 0x0000cc */
-    /* end of Xbridge only */
-    xbowreg_t               _pad_0000d0[12];
-#endif /* LITTLE_ENDIAN */
 
     /* Link Specific Registers, port 8..15                 0x000100-0x000300 */
     xb_linkregs_t           xb_link_raw[MAX_XBOW_PORTS];
@@ -430,8 +372,6 @@ typedef struct xbow_cfg_s {
 /*
  * Xbow Widget 0 Command error word
  */
-#ifdef LITTLE_ENDIAN
-
 typedef union xbw0_cmdword_u {
     xbowreg_t               cmdword;
     struct {
@@ -450,27 +390,6 @@ typedef union xbw0_cmdword_u {
     } xbw0_cmdfield;
 } xbw0_cmdword_t;
 
-#else
-
-typedef union xbw0_cmdword_u {
-    xbowreg_t		    cmdword;
-    struct {
-	uint32_t		destid:4,	/* Desination ID number */
-				srcid:4,	/* Source ID number */
-				pactyp:4,	/* Packet type: */
-				tnum:5,		/* Transaction Number */
-				ct:1,	/* Is it a coherent transaction */
-				ds:2,	/* Data size			*/
-				gbr:1,	/* GBR enable ?			*/
-				vbpm:1,		/* Virtual Backplane message */
-				error:1,	/* Error Occured */
-				barr:1,		/* Barrier operation */
-				rsvd:8;		/* Reserved */
-    } xbw0_cmdfield;
-} xbw0_cmdword_t;
-
-#endif
-
 #define	xbcmd_destid	xbw0_cmdfield.destid
 #define	xbcmd_srcid	xbw0_cmdfield.srcid
 #define	xbcmd_pactyp	xbw0_cmdfield.pactyp
@@ -505,7 +424,6 @@ typedef union xbw0_cmdword_u {
 /*
  * Xbow widget 0 Status register format.
  */
-#ifdef LITTLE_ENDIAN
 
 typedef union xbw0_status_u {
     xbowreg_t               statusword;
@@ -524,28 +442,6 @@ typedef union xbw0_status_u {
     } xbw0_stfield;
 } xbw0_status_t;
 
-#else
-
-typedef union xbw0_status_u {
-    xbowreg_t		    statusword;
-    struct {
-	uint32_t		linkXintr:8,	/* link(x) error intr */
-				wid0intr:1,	/* Widget 0 err intr */
-				resvd1:13,
-				src_id:4,	/* source id. Xbridge only */
-				regacc_err:1,	/* Reg Access error	*/
-				/* Xbridge only */
-				w0_recv_tout,	/* receive timeout err */
-				w0_arb_tout,	/* arbiter timeout err */
-				/* End of Xbridge only */
-				xtalk_err:1,	/* Xtalk pkt with error bit */
-				connect_tout:1, /* Connection timeout	*/
-				mult_err:1;	/* Multiple error occurred */
-    } xbw0_stfield;
-} xbw0_status_t;
-
-#endif
-
 #define	xbst_linkXintr		xbw0_stfield.linkXintr
 #define	xbst_w0intr		xbw0_stfield.wid0intr
 #define	xbst_regacc_err		xbw0_stfield.regacc_err
@@ -559,7 +455,6 @@ typedef union xbw0_status_u {
 /*
  * Xbow widget 0 Control register format
  */
-#ifdef LITTLE_ENDIAN
 
 typedef union xbw0_ctrl_u {
     xbowreg_t               ctrlword;
@@ -577,28 +472,6 @@ typedef union xbw0_ctrl_u {
     } xbw0_ctrlfield;
 } xbw0_ctrl_t;
 
-#else
-
-typedef union xbw0_ctrl_u {
-    xbowreg_t		    ctrlword;
-    struct {
-	uint32_t
-				resvd1:24,
-				enable_watchdog:1,	/* Xbridge only */
-				enable_w0_tout_cntr:1,	/* Xbridge only */
-				accerr_intr:1,
-				w0_recv_tout_intr:1,	/* Xbridge only */
-				w0_arg_tout_intr:1,	/* Xbridge only */
-				xtalkerr_intr:1,
-				conntout_intr:1,
-				resvd3:1;
-    } xbw0_ctrlfield;
-} xbw0_ctrl_t;
-
-#endif
-
-#ifdef LITTLE_ENDIAN
-
 typedef union xbow_linkctrl_u {
     xbowreg_t               xbl_ctrlword;
     struct {
@@ -625,36 +498,6 @@ typedef union xbow_linkctrl_u {
     } xb_linkcontrol;
 } xbow_linkctrl_t;
 
-#else
-
-typedef union xbow_linkctrl_u {
-    xbowreg_t		    xbl_ctrlword;
-    struct {
-	uint32_t		alive_intr:1, 
-				rsvd1:1, 
-				perf_mode:2,
-				inbuf_level:3, 
-				send_bm8:1, 
-				force_badllp:1,
-				llp_credit:5, 
-				idest_intr:1, 
-				obuf_intr:1,
-				rsvd2:7, 
-				bwalloc_intr:1, 
-				rcvov_intr:1,
-				trxov_intr:1, 
-				trx_max_retry_intr:1,
-				rcv_err_intr:1, 
-				trx_retry_intr:1, 
-				rsvd3:1,
-				maxto_intr:1, 
-				srcto_intr:1;
-    } xb_linkcontrol;
-} xbow_linkctrl_t;
-
-#endif
-
-
 #define	xbctl_accerr_intr	(xbw0_ctrlfield.accerr_intr)
 #define	xbctl_xtalkerr_intr	(xbw0_ctrlfield.xtalkerr_intr)
 #define	xbctl_cnntout_intr	(xbw0_ctrlfield.conntout_intr)
@@ -667,8 +510,6 @@ typedef union xbow_linkctrl_u {
  * Xbow Link specific Registers structure definitions.
  */
 
-#ifdef LITTLE_ENDIAN
-
 typedef union xbow_linkX_status_u {
     xbowreg_t               linkstatus;
     struct {
@@ -689,30 +530,6 @@ typedef union xbow_linkX_status_u {
     } xb_linkstatus;
 } xbwX_stat_t;
 
-#else
-
-typedef union xbow_linkX_status_u {
-    xbowreg_t		    linkstatus;
-    struct {
-	uint32_t		alive:1,
-				resvd1:12,
-				merror:1,
-				illdest:1,
-				ioe:1,		/* Input overallocation error */
-				bw_errport:8,	/* BW allocation error port   */
-				llp_rxovflow:1,
-				llp_txovflow:1,
-				llp_maxtxretry:1,
-				llp_rcverror:1,
-				llp_xmitretry:1,
-				pkt_toutdest:1, /* reserved in Xbridge */
-				pkt_toutconn:1, /* max_req_tout in Xbridge */
-				pkt_toutsrc:1;
-    } xb_linkstatus;
-} xbwX_stat_t;
-
-#endif
-
 #define	link_alive		xb_linkstatus.alive
 #define	link_multierror		xb_linkstatus.merror
 #define	link_illegal_dest	xb_linkstatus.illdest
@@ -722,8 +539,6 @@ typedef union xbow_linkX_status_u {
 #define link_pkt_toutdest	xb_linkstatus.pkt_toutdest
 #define	link_pkt_toutsrc	xb_linkstatus.pkt_toutsrc
 
-#ifdef LITTLE_ENDIAN
-
 typedef union xbow_aux_linkX_status_u {
     xbowreg_t               aux_linkstatus;
     struct {
@@ -738,27 +553,6 @@ typedef union xbow_aux_linkX_status_u {
     } xb_aux_linkstatus;
 } xbow_aux_link_status_t;
 
-#else
-
-typedef union xbow_aux_linkX_status_u {
-    xbowreg_t		    aux_linkstatus;
-    struct {
-	uint32_t		rx_err_cnt:8,
-				tx_retry_cnt:8,
-				to_src_loc:8,
-				rsvd1:1,
-				fail_mode:1,
-				wid_present:1,
-				bit_mode_8:1,
-				rsvd2:4;
-    } xb_aux_linkstatus;
-} xbow_aux_link_status_t;
-
-#endif
-
-
-#ifdef LITTLE_ENDIAN
-
 typedef union xbow_perf_count_u {
     xbowreg_t               xb_counter_val;
     struct {
@@ -768,19 +562,6 @@ typedef union xbow_perf_count_u {
     } xb_perf;
 } xbow_perfcount_t;
 
-#else
-
-typedef union xbow_perf_count_u {
-    xbowreg_t               xb_counter_val;
-    struct {
-	uint32_t              rsvd:9, 
-				link_select:3, 
-				count:20;
-    } xb_perf;
-} xbow_perfcount_t;
-
-#endif
-
 #define XBOW_COUNTER_MASK	0xFFFFF
 
 extern int              xbow_widget_present(xbow_t * xbow, int port);
@@ -908,4 +689,4 @@ struct macrofield_s     xbow_macrofield[
 #endif				/* MACROFIELD_LINE */
 
 #endif				/* __ASSEMBLY__ */
-#endif                          /* _ASM_SN_SN_XTALK_XBOW_H */
+#endif                          /* _ASM_IA64_SN_XTALK_XBOW_H */
diff -puN include/asm-ia64/sn/xtalk/xbow_info.h~linus include/asm-ia64/sn/xtalk/xbow_info.h
--- 25/include/asm-ia64/sn/xtalk/xbow_info.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/xtalk/xbow_info.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,35 +1,16 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * Copyright (C) 1992-1997,2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  */
-#ifndef _ASM_SN_XTALK_XBOW_INFO_H
-#define _ASM_SN_XTALK_XBOW_INFO_H
+#ifndef _ASM_IA64_SN_XTALK_XBOW_INFO_H
+#define _ASM_IA64_SN_XTALK_XBOW_INFO_H
 
 #include <linux/types.h>
 
 #define XBOW_PERF_MODES	       0x03
-#define XBOW_PERF_COUNTERS     0x02
-
-#define XBOW_MONITOR_NONE      0x00
-#define XBOW_MONITOR_SRC_LINK  0x01
-#define XBOW_MONITOR_DEST_LINK 0x02
-#define XBOW_MONITOR_INP_PKT   0x03
-#define XBOW_MONITOR_MULTIPLEX 0x04
-
-#define XBOW_LINK_MULTIPLEX    0x20
-
-#define XBOW_PERF_TIMEOUT	4
-#define XBOW_STATS_TIMEOUT	HZ
-
-typedef struct xbow_perf_link {
-    uint64_t              xlp_cumulative[XBOW_PERF_MODES];
-    unsigned char           xlp_link_alive;
-} xbow_perf_link_t;
-
 
 typedef struct xbow_link_status {
     uint64_t              rx_err_count;
@@ -37,32 +18,4 @@ typedef struct xbow_link_status {
 } xbow_link_status_t;
 
 
-
-typedef struct xbow_perf {
-    uint32_t              xp_current;
-    unsigned char           xp_link;
-    unsigned char           xp_mode;
-    unsigned char           xp_curlink;
-    unsigned char           xp_curmode;
-    volatile uint32_t    *xp_perf_reg;
-} xbow_perf_t;
-
-extern void             xbow_update_perf_counters(vertex_hdl_t);
-extern xbow_perf_link_t *xbow_get_perf_counters(vertex_hdl_t);
-extern int              xbow_enable_perf_counter(vertex_hdl_t, int, int, int);
-
-#define XBOWIOC_PERF_ENABLE	  	1
-#define XBOWIOC_PERF_DISABLE	 	2
-#define XBOWIOC_PERF_GET	 	3
-#define XBOWIOC_LLP_ERROR_ENABLE 	4
-#define XBOWIOC_LLP_ERROR_DISABLE	5
-#define XBOWIOC_LLP_ERROR_GET	 	6
-
-
-struct xbow_perfarg_t {
-    int                     link;
-    int                     mode;
-    int                     counter;
-};
-
-#endif				/* _ASM_SN_XTALK_XBOW_INFO_H */
+#endif				/* _ASM_IA64_SN_XTALK_XBOW_INFO_H */
diff -puN include/asm-ia64/sn/xtalk/xswitch.h~linus include/asm-ia64/sn/xtalk/xswitch.h
--- 25/include/asm-ia64/sn/xtalk/xswitch.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/xtalk/xswitch.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,13 +1,12 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * Copyright (C) 1992-1997,2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  */
-#ifndef _ASM_SN_XTALK_XSWITCH_H
-#define _ASM_SN_XTALK_XSWITCH_H
+#ifndef _ASM_IA64_SN_XTALK_XSWITCH_H
+#define _ASM_IA64_SN_XTALK_XSWITCH_H
 
 /*
  * xswitch.h - controls the format of the data
@@ -54,4 +53,4 @@ extern vertex_hdl_t     xswitch_info_mas
 
 #endif				/* __ASSEMBLY__ */
 
-#endif				/* _ASM_SN_XTALK_XSWITCH_H */
+#endif				/* _ASM_IA64_SN_XTALK_XSWITCH_H */
diff -puN include/asm-ia64/sn/xtalk/xtalkaddrs.h~linus include/asm-ia64/sn/xtalk/xtalkaddrs.h
--- 25/include/asm-ia64/sn/xtalk/xtalkaddrs.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/xtalk/xtalkaddrs.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,13 +1,12 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * Copyright (C) 1992-1997,2000-2003 Silicon Graphics, Inc. All Rights Reserved.
  */
-#ifndef _ASM_SN_XTALK_XTALKADDRS_H
-#define _ASM_SN_XTALK_XTALKADDRS_H
+#ifndef _ASM_IA64_SN_XTALK_XTALKADDRS_H
+#define _ASM_IA64_SN_XTALK_XTALKADDRS_H
 
 
 /*
@@ -104,4 +103,4 @@
         (widgetreg_t)(*(volatile uint32_t *)(NODE_SWIN_BASE(nasid, widget) + WIDGET_ID))
 
 
-#endif /* _ASM_SN_XTALK_XTALKADDRS_H */
+#endif /* _ASM_IA64_SN_XTALK_XTALKADDRS_H */
diff -puN include/asm-ia64/sn/xtalk/xtalk.h~linus include/asm-ia64/sn/xtalk/xtalk.h
--- 25/include/asm-ia64/sn/xtalk/xtalk.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/xtalk/xtalk.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,16 +1,17 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * Copyright (C) 1992-1997, 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  */
-#ifndef _ASM_SN_XTALK_XTALK_H
-#define _ASM_SN_XTALK_XTALK_H
+#ifndef _ASM_IA64_SN_XTALK_XTALK_H
+#define _ASM_IA64_SN_XTALK_XTALK_H
 #include <linux/config.h>
 
+#ifdef __KERNEL__
 #include "asm/sn/sgi.h"
+#endif
 
 
 /*
@@ -19,7 +20,7 @@
 /*
  * User-level device driver visible types
  */
-typedef int            xwidgetnum_t;	/* xtalk widget number  (0..15) */
+typedef char            xwidgetnum_t;	/* xtalk widget number  (0..15) */
 
 #define XWIDGET_NONE		(-1)
 
@@ -233,16 +234,8 @@ xtalk_widgetdev_enable_f (vertex_hdl_t, 
 typedef void
 xtalk_widgetdev_shutdown_f (vertex_hdl_t, int);
 
-typedef int
-xtalk_dma_enabled_f (vertex_hdl_t);
-
 /* Error Management */
 
-typedef int
-xtalk_error_devenable_f (vertex_hdl_t xconn_vhdl,
-			 int devnum,
-			 int error_code);
-
 /* Early Action Support */
 typedef caddr_t
 xtalk_early_piotrans_addr_f (xwidget_part_num_t part_num,
@@ -285,9 +278,6 @@ typedef struct xtalk_provider_s {
     /* CONFIGURATION MANAGEMENT */
     xtalk_provider_startup_f *provider_startup;
     xtalk_provider_shutdown_f *provider_shutdown;
-
-    /* Error Management     */
-    xtalk_error_devenable_f *error_devenable;
 } xtalk_provider_t;
 
 /* Crosstalk devices use these standard Crosstalk provider interfaces */
@@ -316,8 +306,6 @@ extern xtalk_provider_startup_f xtalk_pr
 extern xtalk_provider_shutdown_f xtalk_provider_shutdown;
 extern xtalk_widgetdev_enable_f xtalk_widgetdev_enable;
 extern xtalk_widgetdev_shutdown_f xtalk_widgetdev_shutdown;
-extern xtalk_dma_enabled_f xtalk_dma_enabled;
-extern xtalk_error_devenable_f xtalk_error_devenable;
 extern xtalk_early_piotrans_addr_f xtalk_early_piotrans_addr;
 
 /* error management */
@@ -397,4 +385,4 @@ typedef void		xtalk_iter_f(vertex_hdl_t 
 extern void		xtalk_iterate(char *prefix, xtalk_iter_f *func);
 
 #endif				/* __KERNEL__ */
-#endif				/* _ASM_SN_XTALK_XTALK_H */
+#endif				/* _ASM_IA64_SN_XTALK_XTALK_H */
diff -puN include/asm-ia64/sn/xtalk/xtalk_private.h~linus include/asm-ia64/sn/xtalk/xtalk_private.h
--- 25/include/asm-ia64/sn/xtalk/xtalk_private.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/xtalk/xtalk_private.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,13 +1,12 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * Copyright (C) 1992-1997, 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
  */
-#ifndef _ASM_SN_XTALK_XTALK_PRIVATE_H
-#define _ASM_SN_XTALK_XTALK_PRIVATE_H
+#ifndef _ASM_IA64_SN_XTALK_XTALK_PRIVATE_H
+#define _ASM_IA64_SN_XTALK_XTALK_PRIVATE_H
 
 #include <asm/sn/ioerror.h>        /* for error function and arg types */
 #include <asm/sn/xtalk/xwidget.h>
@@ -52,12 +51,6 @@ struct xtalk_intr_s {
 /*
  * Xtalk interrupt handler structure access functions
  */
-#define	xtalk_intr_arg(xt)	((xt)->xi_sfarg)
-
-#define	xwidget_hwid_is_sn0_xswitch(_hwid)	\
-		(((_hwid)->part_num == XBOW_WIDGET_PART_NUM ) &&  	\
-		 ((_hwid)->mfg_num == XBOW_WIDGET_MFGR_NUM ))
-
 #define	xwidget_hwid_is_sn1_xswitch(_hwid)	\
 		(((_hwid)->part_num == XXBOW_WIDGET_PART_NUM ||		\
 		  (_hwid)->part_num == PXBOW_WIDGET_PART_NUM) &&  	\
@@ -83,4 +76,4 @@ struct xwidget_info_s {
 
 extern char             widget_info_fingerprint[];
 
-#endif				/* _ASM_SN_XTALK_XTALK_PRIVATE_H */
+#endif				/* _ASM_IA64_SN_XTALK_XTALK_PRIVATE_H */
diff -puN include/asm-ia64/sn/xtalk/xwidget.h~linus include/asm-ia64/sn/xtalk/xwidget.h
--- 25/include/asm-ia64/sn/xtalk/xwidget.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/sn/xtalk/xwidget.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,24 +1,26 @@
-/* $Id$
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
  * Copyright (C) 1992-1997,2000-2003 Silicon Graphics, Inc. All Rights Reserved.
  */
-#ifndef __ASM_SN_XTALK_XWIDGET_H__
-#define __ASM_SN_XTALK_XWIDGET_H__
+#ifndef _ASM_IA64_SN_XTALK_XWIDGET_H
+#define _ASM_IA64_SN_XTALK_XWIDGET_H
 
 /*
  * xwidget.h - generic crosstalk widget header file
  */
 
+#ifdef __KERNEL__
 #include <asm/sn/xtalk/xtalk.h>
 #ifndef __ASSEMBLY__
 #include <asm/sn/cdl.h>
 #endif /* __ASSEMBLY__ */
+#else
+#include <xtalk/xtalk.h>
+#endif
 
-#ifdef LITTLE_ENDIAN
 #define WIDGET_ID			0x00
 #define WIDGET_STATUS			0x08
 #define WIDGET_ERR_UPPER_ADDR		0x10
@@ -30,19 +32,6 @@
 #define WIDGET_ERR_CMD_WORD		0x40
 #define WIDGET_LLP_CFG			0x48
 #define WIDGET_TFLUSH			0x50
-#else	/* !LITTLE_ENDIAN */
-#define WIDGET_ID                       0x04
-#define WIDGET_STATUS                   0x0c
-#define WIDGET_ERR_UPPER_ADDR           0x14
-#define WIDGET_ERR_LOWER_ADDR           0x1c
-#define WIDGET_CONTROL                  0x24
-#define WIDGET_REQ_TIMEOUT              0x2c
-#define WIDGET_INTDEST_UPPER_ADDR       0x34
-#define WIDGET_INTDEST_LOWER_ADDR       0x3c
-#define WIDGET_ERR_CMD_WORD             0x44
-#define WIDGET_LLP_CFG                  0x4c
-#define WIDGET_TFLUSH                   0x54
-#endif
 
 /* WIDGET_ID */
 #define WIDGET_REV_NUM			0xf0000000
@@ -120,7 +109,6 @@ typedef uint32_t      widgetreg_t;
 
 /* widget configuration registers */
 typedef volatile struct widget_cfg {
-#ifdef LITTLE_ENDIAN
 /*
  * we access these through synergy unswizzled space, so the address
  * gets twiddled (i.e. references to 0x4 actually go to 0x0 and vv.)
@@ -148,33 +136,8 @@ typedef volatile struct widget_cfg {
     widgetreg_t		    w_pad_9;	/* 0x48 */
     widgetreg_t		    w_tflush;	/* 0x54 */
     widgetreg_t		    w_pad_10;	/* 0x50 */
-#else
-    widgetreg_t		    w_pad_0;	/* 0x00 */
-    widgetreg_t		    w_id;	/* 0x04 */
-    widgetreg_t		    w_pad_1;	/* 0x08 */
-    widgetreg_t		    w_status;	/* 0x0c */
-    widgetreg_t		    w_pad_2;	/* 0x10 */
-    widgetreg_t		    w_err_upper_addr;	/* 0x14 */
-    widgetreg_t		    w_pad_3;	/* 0x18 */
-    widgetreg_t		    w_err_lower_addr;	/* 0x1c */
-    widgetreg_t		    w_pad_4;	/* 0x20 */
-    widgetreg_t		    w_control;	/* 0x24 */
-    widgetreg_t		    w_pad_5;	/* 0x28 */
-    widgetreg_t		    w_req_timeout;	/* 0x2c */
-    widgetreg_t		    w_pad_6;	/* 0x30 */
-    widgetreg_t		    w_intdest_upper_addr;	/* 0x34 */
-    widgetreg_t		    w_pad_7;	/* 0x38 */
-    widgetreg_t		    w_intdest_lower_addr;	/* 0x3c */
-    widgetreg_t		    w_pad_8;	/* 0x40 */
-    widgetreg_t		    w_err_cmd_word;	/* 0x44 */
-    widgetreg_t		    w_pad_9;	/* 0x48 */
-    widgetreg_t		    w_llp_cfg;	/* 0x4c */
-    widgetreg_t		    w_pad_10;	/* 0x50 */
-    widgetreg_t		    w_tflush;	/* 0x54 */
-#endif /* LITTLE_ENDIAN */
 } widget_cfg_t;
 
-#ifdef LITTLE_ENDIAN
 typedef struct {
     unsigned                other:8;
     unsigned                bo:1;
@@ -188,33 +151,11 @@ typedef struct {
     unsigned                sidn:4;
     unsigned                didn:4;
 } w_err_cmd_word_f;
-#else
-typedef struct {
-    unsigned                didn:4;
-    unsigned                sidn:4;
-    unsigned                pactyp:4;
-    unsigned                tnum:5;
-    unsigned                ct:1;
-    unsigned                ds:2;
-    unsigned                gbr:1;
-    unsigned                vbpm:1;
-    unsigned                error:1;
-    unsigned                bo:1;
-    unsigned                other:8;
-} w_err_cmd_word_f;
-#endif
 
-#ifdef LITTLE_ENDIAN
 typedef union {
     w_err_cmd_word_f        f;
     widgetreg_t             r;
 } w_err_cmd_word_u;
-#else
-typedef union {
-    widgetreg_t             r;
-    w_err_cmd_word_f        f;
-} w_err_cmd_word_u;
-#endif
 
 /* IO widget initialization function */
 typedef struct xwidget_info_s *xwidget_info_t;
@@ -222,19 +163,11 @@ typedef struct xwidget_info_s *xwidget_i
 /*
  * Crosstalk Widget Hardware Identification, as defined in the Crosstalk spec.
  */
-#ifdef LITTLE_ENDIAN
 typedef struct xwidget_hwid_s {
     xwidget_mfg_num_t       mfg_num;
     xwidget_rev_num_t       rev_num;
     xwidget_part_num_t      part_num;
 }                      *xwidget_hwid_t;
-#else
-typedef struct xwidget_hwid_s {
-    xwidget_part_num_t      part_num;
-    xwidget_rev_num_t       rev_num;
-    xwidget_mfg_num_t       mfg_num;
-}                      *xwidget_hwid_t;
-#endif
 
 
 /*
@@ -304,4 +237,4 @@ typedef struct v_widget_s {
 
 #endif				/* __ASSEMBLY__ */
 
-#endif				/* __ASM_SN_XTALK_XWIDGET_H__ */
+#endif				/* _ASM_IA64_SN_XTALK_XWIDGET_H */
diff -puN include/asm-ia64/socket.h~linus include/asm-ia64/socket.h
--- 25/include/asm-ia64/socket.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ia64/socket.h	2004-01-19 22:17:24.000000000 -0800
@@ -52,6 +52,8 @@
 
 #define SO_ACCEPTCONN		30
 
+#define SO_PEERSEC             31
+
 /* Nast libc5 fixup - bletch */
 #if defined(__KERNEL__)
 /* Socket types. */
diff -puN include/asm-m68k/atariints.h~linus include/asm-m68k/atariints.h
--- 25/include/asm-m68k/atariints.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/atariints.h	2004-01-19 22:17:24.000000000 -0800
@@ -180,14 +180,14 @@ static inline void atari_disable_irq( un
  * "stored"
  */
 
-extern inline void atari_turnon_irq( unsigned irq )
+static inline void atari_turnon_irq( unsigned irq )
 
 {
 	if (irq < STMFP_SOURCE_BASE || irq >= SCC_SOURCE_BASE) return;
 	set_mfp_bit( irq, MFP_ENABLE );
 }
 
-extern inline void atari_turnoff_irq( unsigned irq )
+static inline void atari_turnoff_irq( unsigned irq )
 
 {
 	if (irq < STMFP_SOURCE_BASE || irq >= SCC_SOURCE_BASE) return;
@@ -195,14 +195,14 @@ extern inline void atari_turnoff_irq( un
 	clear_mfp_bit( irq, MFP_PENDING );
 }
 
-extern inline void atari_clear_pending_irq( unsigned irq )
+static inline void atari_clear_pending_irq( unsigned irq )
 
 {
 	if (irq < STMFP_SOURCE_BASE || irq >= SCC_SOURCE_BASE) return;
 	clear_mfp_bit( irq, MFP_PENDING );
 }
 
-extern inline int atari_irq_pending( unsigned irq )
+static inline int atari_irq_pending( unsigned irq )
 
 {
 	if (irq < STMFP_SOURCE_BASE || irq >= SCC_SOURCE_BASE) return( 0 );
diff -puN include/asm-m68k/bitops.h~linus include/asm-m68k/bitops.h
--- 25/include/asm-m68k/bitops.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/bitops.h	2004-01-19 22:17:24.000000000 -0800
@@ -21,7 +21,8 @@
    __constant_test_and_set_bit(nr, vaddr) : \
    __generic_test_and_set_bit(nr, vaddr))
 
-extern __inline__ int __constant_test_and_set_bit(int nr,volatile unsigned long * vaddr)
+static inline int __constant_test_and_set_bit(int nr,
+					      volatile unsigned long *vaddr)
 {
 	char retval;
 
@@ -32,7 +33,8 @@ extern __inline__ int __constant_test_an
 	return retval;
 }
 
-extern __inline__ int __generic_test_and_set_bit(int nr,volatile unsigned long * vaddr)
+static inline int __generic_test_and_set_bit(int nr,
+					     volatile unsigned long *vaddr)
 {
 	char retval;
 
@@ -49,13 +51,13 @@ extern __inline__ int __generic_test_and
 
 #define __set_bit(nr,vaddr) set_bit(nr,vaddr) 
 
-extern __inline__ void __constant_set_bit(int nr, volatile unsigned long * vaddr)
+static inline void __constant_set_bit(int nr, volatile unsigned long *vaddr)
 {
 	__asm__ __volatile__ ("bset %1,%0"
 	     : "+m" (((volatile char *)vaddr)[(nr^31) >> 3]) : "di" (nr & 7));
 }
 
-extern __inline__ void __generic_set_bit(int nr, volatile unsigned long * vaddr)
+static inline void __generic_set_bit(int nr, volatile unsigned long *vaddr)
 {
 	__asm__ __volatile__ ("bfset %1@{%0:#1}"
 	     : : "d" (nr^31), "a" (vaddr) : "memory");
@@ -68,7 +70,8 @@ extern __inline__ void __generic_set_bit
 
 #define __test_and_clear_bit(nr,vaddr) test_and_clear_bit(nr,vaddr)
 
-extern __inline__ int __constant_test_and_clear_bit(int nr, volatile unsigned long * vaddr)
+static inline int __constant_test_and_clear_bit(int nr,
+						volatile unsigned long *vaddr)
 {
 	char retval;
 
@@ -79,7 +82,8 @@ extern __inline__ int __constant_test_an
 	return retval;
 }
 
-extern __inline__ int __generic_test_and_clear_bit(int nr, volatile unsigned long * vaddr)
+static inline int __generic_test_and_clear_bit(int nr,
+					       volatile unsigned long *vaddr)
 {
 	char retval;
 
@@ -101,13 +105,13 @@ extern __inline__ int __generic_test_and
    __generic_clear_bit(nr, vaddr))
 #define __clear_bit(nr,vaddr) clear_bit(nr,vaddr)
 
-extern __inline__ void __constant_clear_bit(int nr, volatile unsigned long * vaddr)
+static inline void __constant_clear_bit(int nr, volatile unsigned long *vaddr)
 {
 	__asm__ __volatile__ ("bclr %1,%0"
 	     : "+m" (((volatile char *)vaddr)[(nr^31) >> 3]) : "di" (nr & 7));
 }
 
-extern __inline__ void __generic_clear_bit(int nr, volatile unsigned long * vaddr)
+static inline void __generic_clear_bit(int nr, volatile unsigned long *vaddr)
 {
 	__asm__ __volatile__ ("bfclr %1@{%0:#1}"
 	     : : "d" (nr^31), "a" (vaddr) : "memory");
@@ -121,7 +125,8 @@ extern __inline__ void __generic_clear_b
 #define __test_and_change_bit(nr,vaddr) test_and_change_bit(nr,vaddr)
 #define __change_bit(nr,vaddr) change_bit(nr,vaddr)
 
-extern __inline__ int __constant_test_and_change_bit(int nr, volatile unsigned long * vaddr)
+static inline int __constant_test_and_change_bit(int nr,
+						 volatile unsigned long *vaddr)
 {
 	char retval;
 
@@ -132,7 +137,8 @@ extern __inline__ int __constant_test_an
 	return retval;
 }
 
-extern __inline__ int __generic_test_and_change_bit(int nr, volatile unsigned long * vaddr)
+static inline int __generic_test_and_change_bit(int nr,
+						volatile unsigned long *vaddr)
 {
 	char retval;
 
@@ -147,25 +153,25 @@ extern __inline__ int __generic_test_and
    __constant_change_bit(nr, vaddr) : \
    __generic_change_bit(nr, vaddr))
 
-extern __inline__ void __constant_change_bit(int nr, volatile unsigned long * vaddr)
+static inline void __constant_change_bit(int nr, volatile unsigned long *vaddr)
 {
 	__asm__ __volatile__ ("bchg %1,%0"
 	     : "+m" (((volatile char *)vaddr)[(nr^31) >> 3]) : "di" (nr & 7));
 }
 
-extern __inline__ void __generic_change_bit(int nr, volatile unsigned long * vaddr)
+static inline void __generic_change_bit(int nr, volatile unsigned long *vaddr)
 {
 	__asm__ __volatile__ ("bfchg %1@{%0:#1}"
 	     : : "d" (nr^31), "a" (vaddr) : "memory");
 }
 
-extern __inline__ int test_bit(int nr, const volatile unsigned long * vaddr)
+static inline int test_bit(int nr, const volatile unsigned long *vaddr)
 {
 	return ((1UL << (nr & 31)) & (((const volatile unsigned long *) vaddr)[nr >> 5])) != 0;
 }
 
-extern __inline__ int find_first_zero_bit(const unsigned long *vaddr,
-					  unsigned size)
+static inline int find_first_zero_bit(const unsigned long *vaddr,
+				      unsigned size)
 {
 	const unsigned long *p = vaddr, *addr = vaddr;
 	unsigned long allones = ~0UL;
@@ -188,8 +194,8 @@ extern __inline__ int find_first_zero_bi
 	return ((p - addr) << 5) + (res ^ 31);
 }
 
-extern __inline__ int find_next_zero_bit (const unsigned long *vaddr, int size,
-				      int offset)
+static inline int find_next_zero_bit(const unsigned long *vaddr, int size,
+				     int offset)
 {
 	const unsigned long *addr = vaddr;
 	const unsigned long *p = addr + (offset >> 5);
@@ -218,7 +224,7 @@ extern __inline__ int find_next_zero_bit
  * ffz = Find First Zero in word. Undefined if no zero exists,
  * so code should check against ~0UL first..
  */
-extern __inline__ unsigned long ffz(unsigned long word)
+static inline unsigned long ffz(unsigned long word)
 {
 	int res;
 
@@ -289,8 +295,7 @@ static inline int sched_find_first_bit(c
 
 /* Bitmap functions for the minix filesystem */
 
-extern __inline__ int
-minix_find_first_zero_bit (const void *vaddr, unsigned size)
+static inline int minix_find_first_zero_bit(const void *vaddr, unsigned size)
 {
 	const unsigned short *p = vaddr, *addr = vaddr;
 	int res;
@@ -312,8 +317,7 @@ minix_find_first_zero_bit (const void *v
 	return ((p - addr) << 4) + (res ^ 31);
 }
 
-extern __inline__ int
-minix_test_and_set_bit (int nr, volatile void *vaddr)
+static inline int minix_test_and_set_bit(int nr, volatile void *vaddr)
 {
 	char retval;
 
@@ -325,8 +329,7 @@ minix_test_and_set_bit (int nr, volatile
 
 #define minix_set_bit(nr,addr)	((void)minix_test_and_set_bit(nr,addr))
 
-extern __inline__ int
-minix_test_and_clear_bit (int nr, volatile void *vaddr)
+static inline int minix_test_and_clear_bit(int nr, volatile void *vaddr)
 {
 	char retval;
 
@@ -336,16 +339,14 @@ minix_test_and_clear_bit (int nr, volati
 	return retval;
 }
 
-extern __inline__ int
-minix_test_bit (int nr, const volatile void *vaddr)
+static inline int minix_test_bit(int nr, const volatile void *vaddr)
 {
 	return ((1U << (nr & 15)) & (((const volatile unsigned short *) vaddr)[nr >> 4])) != 0;
 }
 
 /* Bitmap functions for the ext2 filesystem. */
 
-extern __inline__ int
-ext2_set_bit (int nr, volatile void *vaddr)
+static inline int ext2_set_bit(int nr, volatile void *vaddr)
 {
 	char retval;
 
@@ -355,8 +356,7 @@ ext2_set_bit (int nr, volatile void *vad
 	return retval;
 }
 
-extern __inline__ int
-ext2_clear_bit (int nr, volatile void *vaddr)
+static inline int ext2_clear_bit(int nr, volatile void *vaddr)
 {
 	char retval;
 
@@ -384,14 +384,12 @@ ext2_clear_bit (int nr, volatile void *v
 		ret;					\
 	})
 
-extern __inline__ int
-ext2_test_bit (int nr, const volatile void *vaddr)
+static inline int ext2_test_bit(int nr, const volatile void *vaddr)
 {
 	return ((1U << (nr & 7)) & (((const volatile unsigned char *) vaddr)[nr >> 3])) != 0;
 }
 
-extern __inline__ int
-ext2_find_first_zero_bit (const void *vaddr, unsigned size)
+static inline int ext2_find_first_zero_bit(const void *vaddr, unsigned size)
 {
 	const unsigned long *p = vaddr, *addr = vaddr;
 	int res;
@@ -413,8 +411,8 @@ ext2_find_first_zero_bit (const void *va
 	return (p - addr) * 32 + res;
 }
 
-extern __inline__ int
-ext2_find_next_zero_bit (const void *vaddr, unsigned size, unsigned offset)
+static inline int ext2_find_next_zero_bit(const void *vaddr, unsigned size,
+					  unsigned offset)
 {
 	const unsigned long *addr = vaddr;
 	const unsigned long *p = addr + (offset >> 5);
diff -puN include/asm-m68k/byteorder.h~linus include/asm-m68k/byteorder.h
--- 25/include/asm-m68k/byteorder.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/byteorder.h	2004-01-19 22:17:24.000000000 -0800
@@ -2,10 +2,11 @@
 #define _M68K_BYTEORDER_H
 
 #include <asm/types.h>
+#include <linux/compiler.h>
 
 #ifdef __GNUC__
 
-static __inline__ __const__ __u32 ___arch__swab32(__u32 val)
+static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 val)
 {
 	__asm__("rolw #8,%0; swap %0; rolw #8,%0" : "=d" (val) : "0" (val));
 	return val;
diff -puN include/asm-m68k/cacheflush.h~linus include/asm-m68k/cacheflush.h
--- 25/include/asm-m68k/cacheflush.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/cacheflush.h	2004-01-19 22:17:24.000000000 -0800
@@ -83,7 +83,7 @@ extern void cache_push_v(unsigned long v
 #define flush_cache_vmap(start, end)		flush_cache_all()
 #define flush_cache_vunmap(start, end)		flush_cache_all()
 
-extern inline void flush_cache_mm(struct mm_struct *mm)
+static inline void flush_cache_mm(struct mm_struct *mm)
 {
 	if (mm == current->mm)
 		__flush_cache_030();
@@ -91,7 +91,7 @@ extern inline void flush_cache_mm(struct
 
 /* flush_cache_range/flush_cache_page must be macros to avoid
    a dependency on linux/mm.h, which includes this file... */
-extern inline void flush_cache_range(struct vm_area_struct *vma,
+static inline void flush_cache_range(struct vm_area_struct *vma,
 				     unsigned long start,
 				     unsigned long end)
 {
@@ -99,7 +99,7 @@ extern inline void flush_cache_range(str
 	        __flush_cache_030();
 }
 
-extern inline void flush_cache_page(struct vm_area_struct *vma,
+static inline void flush_cache_page(struct vm_area_struct *vma,
 				    unsigned long vmaddr)
 {
  	if (vma->vm_mm == current->mm)
@@ -109,7 +109,7 @@ extern inline void flush_cache_page(stru
 
 /* Push the page at kernel virtual address and clear the icache */
 /* RZ: use cpush %bc instead of cpush %dc, cinv %ic */
-extern inline void __flush_page_to_ram(void *vaddr)
+static inline void __flush_page_to_ram(void *vaddr)
 {
 	if (CPU_IS_040_OR_060) {
 		__asm__ __volatile__("nop\n\t"
diff -puN include/asm-m68k/delay.h~linus include/asm-m68k/delay.h
--- 25/include/asm-m68k/delay.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/delay.h	2004-01-19 22:17:24.000000000 -0800
@@ -9,7 +9,7 @@
  * Delay routines, using a pre-computed "loops_per_jiffy" value.
  */
 
-extern __inline__ void __delay(unsigned long loops)
+static inline void __delay(unsigned long loops)
 {
 	__asm__ __volatile__ ("1: subql #1,%0; jcc 1b"
 		: "=d" (loops) : "0" (loops));
@@ -43,7 +43,8 @@ static inline void __udelay(unsigned lon
 	((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 4295)) : \
 	__udelay(n))
 
-extern __inline__ unsigned long muldiv(unsigned long a, unsigned long b, unsigned long c)
+static inline unsigned long muldiv(unsigned long a, unsigned long b,
+				   unsigned long c)
 {
 	unsigned long tmp;
 
diff -puN include/asm-m68k/dvma.h~linus include/asm-m68k/dvma.h
--- 25/include/asm-m68k/dvma.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/dvma.h	2004-01-19 22:17:24.000000000 -0800
@@ -58,7 +58,8 @@ extern void dvma_free(void *vaddr);
 #define dvma_vtob(x) dvma_vtop(x)
 #define dvma_btov(x) dvma_ptov(x)
 
-extern inline int dvma_map_cpu(unsigned long kaddr, unsigned long vaddr, int len)
+static inline int dvma_map_cpu(unsigned long kaddr, unsigned long vaddr,
+			       int len)
 {
 	return 0;
 }
diff -puN include/asm-m68k/io.h~linus include/asm-m68k/io.h
--- 25/include/asm-m68k/io.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/io.h	2004-01-19 22:17:24.000000000 -0800
@@ -285,20 +285,20 @@ static inline void isa_delay(void)
 #endif /* CONFIG_PCI */
 
 
-extern inline void *ioremap(unsigned long physaddr, unsigned long size)
+static inline void *ioremap(unsigned long physaddr, unsigned long size)
 {
 	return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
 }
-extern inline void *ioremap_nocache(unsigned long physaddr, unsigned long size)
+static inline void *ioremap_nocache(unsigned long physaddr, unsigned long size)
 {
 	return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
 }
-extern inline void *ioremap_writethrough(unsigned long physaddr,
+static inline void *ioremap_writethrough(unsigned long physaddr,
 					 unsigned long size)
 {
 	return __ioremap(physaddr, size, IOMAP_WRITETHROUGH);
 }
-extern inline void *ioremap_fullcache(unsigned long physaddr,
+static inline void *ioremap_fullcache(unsigned long physaddr,
 				      unsigned long size)
 {
 	return __ioremap(physaddr, size, IOMAP_FULL_CACHING);
diff -puN include/asm-m68k/mac_psc.h~linus include/asm-m68k/mac_psc.h
--- 25/include/asm-m68k/mac_psc.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/mac_psc.h	2004-01-19 22:17:24.000000000 -0800
@@ -215,32 +215,32 @@ extern int psc_present;
  *	Access functions
  */
  
-extern inline void psc_write_byte(int offset, __u8 data)
+static inline void psc_write_byte(int offset, __u8 data)
 {
 	*((volatile __u8 *)(psc + offset)) = data;
 }
 
-extern inline void psc_write_word(int offset, __u16 data)
+static inline void psc_write_word(int offset, __u16 data)
 {
 	*((volatile __u16 *)(psc + offset)) = data;
 }
 
-extern inline void psc_write_long(int offset, __u32 data)
+static inline void psc_write_long(int offset, __u32 data)
 {
 	*((volatile __u32 *)(psc + offset)) = data;
 }
 
-extern inline u8 psc_read_byte(int offset)
+static inline u8 psc_read_byte(int offset)
 {
 	return *((volatile __u8 *)(psc + offset));
 }
 
-extern inline u16 psc_read_word(int offset)
+static inline u16 psc_read_word(int offset)
 {
 	return *((volatile __u16 *)(psc + offset));
 }
 
-extern inline u32 psc_read_long(int offset)
+static inline u32 psc_read_long(int offset)
 {
 	return *((volatile __u32 *)(psc + offset));
 }
diff -puN include/asm-m68k/mac_via.h~linus include/asm-m68k/mac_via.h
--- 25/include/asm-m68k/mac_via.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/mac_via.h	2004-01-19 22:17:24.000000000 -0800
@@ -255,7 +255,8 @@ extern volatile __u8 *via1,*via2;
 extern int rbv_present,via_alt_mapping;
 extern __u8 rbv_clear;
 
-extern __inline__ int rbv_set_video_bpp(int bpp) {
+static inline int rbv_set_video_bpp(int bpp)
+{
 	char val = (bpp==1)?0:(bpp==2)?1:(bpp==4)?2:(bpp==8)?3:-1;
 	if (!rbv_present || val<0) return -1;
 	via2[rMonP] = (via2[rMonP] & ~RBV_DEPTH) | val;
diff -puN include/asm-m68k/mmu_context.h~linus include/asm-m68k/mmu_context.h
--- 25/include/asm-m68k/mmu_context.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/mmu_context.h	2004-01-19 22:17:24.000000000 -0800
@@ -13,8 +13,8 @@ static inline void enter_lazy_tlb(struct
 #include <asm/page.h>
 #include <asm/pgalloc.h>
 
-extern inline int
-init_new_context(struct task_struct *tsk, struct mm_struct *mm)
+static inline int init_new_context(struct task_struct *tsk,
+				   struct mm_struct *mm)
 {
 	mm->context = virt_to_phys(mm->pgd);
 	return 0;
@@ -22,7 +22,7 @@ init_new_context(struct task_struct *tsk
 
 #define destroy_context(mm)		do { } while(0)
 
-extern inline void switch_mm_0230(struct mm_struct *mm)
+static inline void switch_mm_0230(struct mm_struct *mm)
 {
 	unsigned long crp[2] = {
 		0x80000000 | _PAGE_TABLE, mm->context
@@ -55,7 +55,7 @@ extern inline void switch_mm_0230(struct
 	asm volatile (".chip 68k");
 }
 
-extern inline void switch_mm_0460(struct mm_struct *mm)
+static inline void switch_mm_0460(struct mm_struct *mm)
 {
 	asm volatile (".chip 68040");
 
@@ -91,7 +91,7 @@ static inline void switch_mm(struct mm_s
 
 #define deactivate_mm(tsk,mm)	do { } while (0)
 
-extern inline void activate_mm(struct mm_struct *prev_mm,
+static inline void activate_mm(struct mm_struct *prev_mm,
 			       struct mm_struct *next_mm)
 {
 	next_mm->context = virt_to_phys(next_mm->pgd);
@@ -144,7 +144,7 @@ static inline void switch_mm(struct mm_s
 
 #define deactivate_mm(tsk,mm)	do { } while (0)
 
-extern inline void activate_mm(struct mm_struct *prev_mm,
+static inline void activate_mm(struct mm_struct *prev_mm,
 			       struct mm_struct *next_mm)
 {
 	activate_context(next_mm);
diff -puN include/asm-m68k/motorola_pgtable.h~linus include/asm-m68k/motorola_pgtable.h
--- 25/include/asm-m68k/motorola_pgtable.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/motorola_pgtable.h	2004-01-19 22:17:24.000000000 -0800
@@ -41,10 +41,14 @@ extern int m68k_pgtable_cachemode;
  * processors >= '040. It is used in pte_mkcache(), and the variable is
  * defined and initialized in head.S */
 
-#if defined(CONFIG_060_WRITETHROUGH)
-extern int m68k_supervisor_cachemode;
-#else
+#if defined(CPU_M68060_ONLY) && defined(CONFIG_060_WRITETHROUGH)
+#define m68k_supervisor_cachemode _PAGE_CACHE040W
+#elif defined(CPU_M68040_OR_M68060_ONLY)
 #define m68k_supervisor_cachemode _PAGE_CACHE040
+#elif defined(CPU_M68020_OR_M68030_ONLY)
+#define m68k_supervisor_cachemode 0
+#else
+extern int m68k_supervisor_cachemode;
 #endif
 
 #if defined(CPU_M68040_OR_M68060_ONLY)
@@ -96,10 +100,13 @@ extern unsigned long mm_cachebits;
  */
 #define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
 
-extern inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
-{ pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot); return pte; }
+static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
+{
+	pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot);
+	return pte;
+}
 
-extern inline void pmd_set(pmd_t * pmdp, pte_t * ptep)
+static inline void pmd_set(pmd_t *pmdp, pte_t *ptep)
 {
 	unsigned long ptbl = virt_to_phys(ptep) | _PAGE_TABLE | _PAGE_ACCESSED;
 	unsigned long *ptr = pmdp->pmd;
@@ -110,8 +117,10 @@ extern inline void pmd_set(pmd_t * pmdp,
 	}
 }
 
-extern inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
-{ pgd_val(*pgdp) = _PAGE_TABLE | _PAGE_ACCESSED | __pa(pmdp); }
+static inline void pgd_set(pgd_t *pgdp, pmd_t *pmdp)
+{
+	pgd_val(*pgdp) = _PAGE_TABLE | _PAGE_ACCESSED | __pa(pmdp);
+}
 
 #define __pte_page(pte) ((unsigned long)__va(pte_val(pte) & PAGE_MASK))
 #define __pmd_page(pmd) ((unsigned long)__va(pmd_val(pmd) & _TABLE_MASK))
@@ -155,36 +164,40 @@ extern inline void pgd_set(pgd_t * pgdp,
  * The following only work if pte_present() is true.
  * Undefined behaviour if not..
  */
-extern inline int pte_read(pte_t pte)		{ return 1; }
-extern inline int pte_write(pte_t pte)		{ return !(pte_val(pte) & _PAGE_RONLY); }
-extern inline int pte_exec(pte_t pte)		{ return 1; }
-extern inline int pte_dirty(pte_t pte)		{ return pte_val(pte) & _PAGE_DIRTY; }
-extern inline int pte_young(pte_t pte)		{ return pte_val(pte) & _PAGE_ACCESSED; }
+static inline int pte_read(pte_t pte)		{ return 1; }
+static inline int pte_write(pte_t pte)		{ return !(pte_val(pte) & _PAGE_RONLY); }
+static inline int pte_exec(pte_t pte)		{ return 1; }
+static inline int pte_dirty(pte_t pte)		{ return pte_val(pte) & _PAGE_DIRTY; }
+static inline int pte_young(pte_t pte)		{ return pte_val(pte) & _PAGE_ACCESSED; }
 static inline int pte_file(pte_t pte)		{ return pte_val(pte) & _PAGE_FILE; }
 
-extern inline pte_t pte_wrprotect(pte_t pte)	{ pte_val(pte) |= _PAGE_RONLY; return pte; }
-extern inline pte_t pte_rdprotect(pte_t pte)	{ return pte; }
-extern inline pte_t pte_exprotect(pte_t pte)	{ return pte; }
-extern inline pte_t pte_mkclean(pte_t pte)	{ pte_val(pte) &= ~_PAGE_DIRTY; return pte; }
-extern inline pte_t pte_mkold(pte_t pte)	{ pte_val(pte) &= ~_PAGE_ACCESSED; return pte; }
-extern inline pte_t pte_mkwrite(pte_t pte)	{ pte_val(pte) &= ~_PAGE_RONLY; return pte; }
-extern inline pte_t pte_mkread(pte_t pte)	{ return pte; }
-extern inline pte_t pte_mkexec(pte_t pte)	{ return pte; }
-extern inline pte_t pte_mkdirty(pte_t pte)	{ pte_val(pte) |= _PAGE_DIRTY; return pte; }
-extern inline pte_t pte_mkyoung(pte_t pte)	{ pte_val(pte) |= _PAGE_ACCESSED; return pte; }
-extern inline pte_t pte_mknocache(pte_t pte)
+static inline pte_t pte_wrprotect(pte_t pte)	{ pte_val(pte) |= _PAGE_RONLY; return pte; }
+static inline pte_t pte_rdprotect(pte_t pte)	{ return pte; }
+static inline pte_t pte_exprotect(pte_t pte)	{ return pte; }
+static inline pte_t pte_mkclean(pte_t pte)	{ pte_val(pte) &= ~_PAGE_DIRTY; return pte; }
+static inline pte_t pte_mkold(pte_t pte)	{ pte_val(pte) &= ~_PAGE_ACCESSED; return pte; }
+static inline pte_t pte_mkwrite(pte_t pte)	{ pte_val(pte) &= ~_PAGE_RONLY; return pte; }
+static inline pte_t pte_mkread(pte_t pte)	{ return pte; }
+static inline pte_t pte_mkexec(pte_t pte)	{ return pte; }
+static inline pte_t pte_mkdirty(pte_t pte)	{ pte_val(pte) |= _PAGE_DIRTY; return pte; }
+static inline pte_t pte_mkyoung(pte_t pte)	{ pte_val(pte) |= _PAGE_ACCESSED; return pte; }
+static inline pte_t pte_mknocache(pte_t pte)
 {
 	pte_val(pte) = (pte_val(pte) & _CACHEMASK040) | m68k_pgtable_cachemode;
 	return pte;
 }
-extern inline pte_t pte_mkcache(pte_t pte)	{ pte_val(pte) = (pte_val(pte) & _CACHEMASK040) | m68k_supervisor_cachemode; return pte; }
+static inline pte_t pte_mkcache(pte_t pte)
+{
+	pte_val(pte) = (pte_val(pte) & _CACHEMASK040) | m68k_supervisor_cachemode;
+	return pte;
+}
 
 #define PAGE_DIR_OFFSET(tsk,address) pgd_offset((tsk),(address))
 
 #define pgd_index(address)     ((address) >> PGDIR_SHIFT)
 
 /* to find an entry in a page-table-directory */
-extern inline pgd_t * pgd_offset(struct mm_struct * mm, unsigned long address)
+static inline pgd_t *pgd_offset(struct mm_struct *mm, unsigned long address)
 {
 	return mm->pgd + pgd_index(address);
 }
@@ -192,20 +205,20 @@ extern inline pgd_t * pgd_offset(struct 
 #define swapper_pg_dir kernel_pg_dir
 extern pgd_t kernel_pg_dir[128];
 
-extern inline pgd_t * pgd_offset_k(unsigned long address)
+static inline pgd_t *pgd_offset_k(unsigned long address)
 {
 	return kernel_pg_dir + (address >> PGDIR_SHIFT);
 }
 
 
 /* Find an entry in the second-level page table.. */
-extern inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address)
+static inline pmd_t *pmd_offset(pgd_t *dir, unsigned long address)
 {
 	return (pmd_t *)__pgd_page(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PMD-1));
 }
 
 /* Find an entry in the third-level page table.. */ 
-extern inline pte_t * pte_offset_kernel(pmd_t * pmdp, unsigned long address)
+static inline pte_t *pte_offset_kernel(pmd_t *pmdp, unsigned long address)
 {
 	return (pte_t *)__pmd_page(*pmdp) + ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1));
 }
diff -puN include/asm-m68knommu/types.h~linus include/asm-m68knommu/types.h
--- 25/include/asm-m68knommu/types.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68knommu/types.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,66 +1 @@
-#ifndef _M68K_TYPES_H
-#define _M68K_TYPES_H
-
-/*
- * This file is never included by application software unless
- * explicitly requested (e.g., via linux/types.h) in which case the
- * application is Linux specific so (user-) name space pollution is
- * not a major issue.  However, for interoperability, libraries still
- * need to be careful to avoid a name clashes.
- */
-
-#ifndef __ASSEMBLY__
-
-typedef unsigned short umode_t;
-
-/*
- * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
- * header files exported to user space
- */
-
-typedef __signed__ char __s8;
-typedef unsigned char __u8;
-
-typedef __signed__ short __s16;
-typedef unsigned short __u16;
-
-typedef __signed__ int __s32;
-typedef unsigned int __u32;
-
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-typedef __signed__ long long __s64;
-typedef unsigned long long __u64;
-#endif
-
-#endif /* __ASSEMBLY__ */
-
-/*
- * These aren't exported outside the kernel to avoid name space clashes
- */
-#ifdef __KERNEL__
-
-#define BITS_PER_LONG 32
-
-#ifndef __ASSEMBLY__
-
-typedef signed char s8;
-typedef unsigned char u8;
-
-typedef signed short s16;
-typedef unsigned short u16;
-
-typedef signed int s32;
-typedef unsigned int u32;
-
-typedef signed long long s64;
-typedef unsigned long long u64;
-
-/* Dma addresses are 32-bits wide.  */
-
-typedef u32 dma_addr_t;
-
-#endif /* __ASSEMBLY__ */
-
-#endif /* __KERNEL__ */
-
-#endif /* _M68K_TYPES_H */
+#include <asm-m68k/types.h>
diff -puN include/asm-m68k/nubus.h~linus include/asm-m68k/nubus.h
--- 25/include/asm-m68k/nubus.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/nubus.h	2004-01-19 22:17:24.000000000 -0800
@@ -15,25 +15,25 @@
 #define nubus_memcpy_fromio(a,b,c)	memcpy((a),(void *)(b),(c))
 #define nubus_memcpy_toio(a,b,c)	memcpy((void *)(a),(b),(c))
 
-extern inline void *nubus_remap_nocache_ser(unsigned long physaddr,
+static inline void *nubus_remap_nocache_ser(unsigned long physaddr,
 					    unsigned long size)
 {
 	return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
 }
 
-extern inline void *nubus_remap_nocache_nonser(unsigned long physaddr,
+static inline void *nubus_remap_nocache_nonser(unsigned long physaddr,
 					       unsigned long size)
 {
 	return __ioremap(physaddr, size, IOMAP_NOCACHE_NONSER);
 }
 
-extern inline void *nbus_remap_writethrough(unsigned long physaddr,
+static inline void *nbus_remap_writethrough(unsigned long physaddr,
 					    unsigned long size)
 {
 	return __ioremap(physaddr, size, IOMAP_WRITETHROUGH);
 }
 
-extern inline void *nubus_remap_fullcache(unsigned long physaddr,
+static inline void *nubus_remap_fullcache(unsigned long physaddr,
 					  unsigned long size)
 {
 	return __ioremap(physaddr, size, IOMAP_FULL_CACHING);
diff -puN include/asm-m68k/page.h~linus include/asm-m68k/page.h
--- 25/include/asm-m68k/page.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/page.h	2004-01-19 22:17:24.000000000 -0800
@@ -110,7 +110,7 @@ typedef struct { unsigned long pgprot; }
 #define PAGE_ALIGN(addr)	(((addr)+PAGE_SIZE-1)&PAGE_MASK)
 
 /* Pure 2^n version of get_order */
-extern __inline__ int get_order(unsigned long size)
+static inline int get_order(unsigned long size)
 {
 	int order;
 
diff -puN include/asm-m68k/pci.h~linus include/asm-m68k/pci.h
--- 25/include/asm-m68k/pci.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/pci.h	2004-01-19 22:17:24.000000000 -0800
@@ -37,12 +37,12 @@ struct pci_bus_info
 
 #define pcibios_assign_all_busses()	0
 
-extern inline void pcibios_set_master(struct pci_dev *dev)
+static inline void pcibios_set_master(struct pci_dev *dev)
 {
 	/* No special bus mastering setup handling */
 }
 
-extern inline void pcibios_penalize_isa_irq(int irq)
+static inline void pcibios_penalize_isa_irq(int irq)
 {
 	/* We don't do dynamic PCI IRQ allocation */
 }
diff -puN include/asm-m68k/pgtable.h~linus include/asm-m68k/pgtable.h
--- 25/include/asm-m68k/pgtable.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/pgtable.h	2004-01-19 22:17:24.000000000 -0800
@@ -114,7 +114,7 @@ extern void *empty_zero_page;
  * It makes no sense to consider whether we cross a memory boundary if
  * we support just one physical chunk of memory.
  */
-extern inline int mm_end_of_chunk (unsigned long addr, int len)
+static inline int mm_end_of_chunk(unsigned long addr, int len)
 {
 	return 0;
 }
@@ -129,8 +129,8 @@ extern void kernel_set_cachemode(void *a
  * tables contain all the necessary information.  The Sun3 does, but
  * they are updated on demand.
  */
-extern inline void update_mmu_cache(struct vm_area_struct * vma,
-	unsigned long address, pte_t pte)
+static inline void update_mmu_cache(struct vm_area_struct *vma,
+				    unsigned long address, pte_t pte)
 {
 }
 
diff -puN include/asm-m68k/processor.h~linus include/asm-m68k/processor.h
--- 25/include/asm-m68k/processor.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/processor.h	2004-01-19 22:17:24.000000000 -0800
@@ -18,14 +18,16 @@
 #include <asm/fpu.h>
 #include <asm/ptrace.h>
 
-extern inline unsigned long rdusp(void) {
-  	unsigned long usp;
+static inline unsigned long rdusp(void)
+{
+	unsigned long usp;
 
 	__asm__ __volatile__("move %/usp,%0" : "=a" (usp));
 	return usp;
 }
 
-extern inline void wrusp(unsigned long usp) {
+static inline void wrusp(unsigned long usp)
+{
 	__asm__ __volatile__("move %0,%/usp" : : "a" (usp));
 }
 
@@ -83,10 +85,11 @@ struct thread_struct {
 	struct task_work work;
 };
 
-#define INIT_THREAD  {						\
-	ksp: sizeof(init_stack) + (unsigned long) init_stack,	\
-	sr: PS_S, 						\
-	fs: __KERNEL_DS,					\
+#define INIT_THREAD  {							\
+	ksp:	sizeof(init_stack) + (unsigned long) init_stack,	\
+	sr:	PS_S,							\
+	fs:	__KERNEL_DS,						\
+	info:	INIT_THREAD_INFO(init_task)				\
 }
 
 /*
diff -puN include/asm-m68k/sbus.h~linus include/asm-m68k/sbus.h
--- 25/include/asm-m68k/sbus.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/sbus.h	2004-01-19 22:17:24.000000000 -0800
@@ -20,17 +20,17 @@ extern void *sparc_alloc_io (u32, void *
 /* sbus IO functions stolen from include/asm-sparc/io.h for the serial driver */
 /* No SBUS on the Sun3, kludge -- sam */
 
-extern inline void _sbus_writeb(unsigned char val, unsigned long addr)
+static inline void _sbus_writeb(unsigned char val, unsigned long addr)
 {
 	*(volatile unsigned char *)addr = val;
 }
 
-extern inline unsigned char _sbus_readb(unsigned long addr)
+static inline unsigned char _sbus_readb(unsigned long addr)
 {
 	return *(volatile unsigned char *)addr;
 }
 
-extern inline void _sbus_writel(unsigned long val, unsigned long addr)
+static inline void _sbus_writel(unsigned long val, unsigned long addr)
 {
 	*(volatile unsigned long *)addr = val;
 
diff -puN include/asm-m68k/semaphore.h~linus include/asm-m68k/semaphore.h
--- 25/include/asm-m68k/semaphore.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/semaphore.h	2004-01-19 22:17:24.000000000 -0800
@@ -52,7 +52,7 @@ struct semaphore {
 #define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
 #define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
 
-extern inline void sema_init (struct semaphore *sem, int val)
+static inline void sema_init(struct semaphore *sem, int val)
 {
 	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER(*sem, val);
 }
@@ -82,7 +82,7 @@ asmlinkage void __up(struct semaphore * 
  * "down_failed" is a special asm handler that calls the C
  * routine that actually waits. See arch/m68k/lib/semaphore.S
  */
-extern inline void down(struct semaphore * sem)
+static inline void down(struct semaphore *sem)
 {
 	register struct semaphore *sem1 __asm__ ("%a1") = sem;
 
@@ -104,7 +104,7 @@ extern inline void down(struct semaphore
 		: "memory");
 }
 
-extern inline int down_interruptible(struct semaphore * sem)
+static inline int down_interruptible(struct semaphore *sem)
 {
 	register struct semaphore *sem1 __asm__ ("%a1") = sem;
 	register int result __asm__ ("%d0");
@@ -129,7 +129,7 @@ extern inline int down_interruptible(str
 	return result;
 }
 
-extern inline int down_trylock(struct semaphore * sem)
+static inline int down_trylock(struct semaphore *sem)
 {
 	register struct semaphore *sem1 __asm__ ("%a1") = sem;
 	register int result __asm__ ("%d0");
@@ -160,7 +160,7 @@ extern inline int down_trylock(struct se
  * The default case (no contention) will result in NO
  * jumps for both down() and up().
  */
-extern inline void up(struct semaphore * sem)
+static inline void up(struct semaphore *sem)
 {
 	register struct semaphore *sem1 __asm__ ("%a1") = sem;
 
diff -puN include/asm-m68k/signal.h~linus include/asm-m68k/signal.h
--- 25/include/asm-m68k/signal.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/signal.h	2004-01-19 22:17:24.000000000 -0800
@@ -176,25 +176,25 @@ typedef struct sigaltstack {
 
 #define __HAVE_ARCH_SIG_BITOPS
 
-extern __inline__ void sigaddset(sigset_t *set, int _sig)
+static inline void sigaddset(sigset_t *set, int _sig)
 {
 	__asm__("bfset %0{%1,#1}" : "=m" (*set) : "id" ((_sig - 1) ^ 31)
 		: "cc");
 }
 
-extern __inline__ void sigdelset(sigset_t *set, int _sig)
+static inline void sigdelset(sigset_t *set, int _sig)
 {
 	__asm__("bfclr %0{%1,#1}" : "=m"(*set) : "id"((_sig - 1) ^ 31)
 		: "cc");
 }
 
-extern __inline__ int __const_sigismember(sigset_t *set, int _sig)
+static inline int __const_sigismember(sigset_t *set, int _sig)
 {
 	unsigned long sig = _sig - 1;
 	return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
 }
 
-extern __inline__ int __gen_sigismember(sigset_t *set, int _sig)
+static inline int __gen_sigismember(sigset_t *set, int _sig)
 {
 	int ret;
 	__asm__("bfextu %1{%2,#1},%0"
@@ -207,7 +207,7 @@ extern __inline__ int __gen_sigismember(
 	 __const_sigismember(set,sig) :		\
 	 __gen_sigismember(set,sig))
 
-extern __inline__ int sigfindinword(unsigned long word)
+static inline int sigfindinword(unsigned long word)
 {
 	__asm__("bfffo %1{#0,#0},%0" : "=d"(word) : "d"(word & -word) : "cc");
 	return word ^ 31;
diff -puN include/asm-m68k/socket.h~linus include/asm-m68k/socket.h
--- 25/include/asm-m68k/socket.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/socket.h	2004-01-19 22:17:24.000000000 -0800
@@ -45,6 +45,8 @@
 
 #define SO_ACCEPTCONN		30
 
+#define SO_PEERSEC             31
+
 /* Nast libc5 fixup - bletch */
 #if defined(__KERNEL__)
 /* Socket types. */
diff -puN include/asm-m68k/string.h~linus include/asm-m68k/string.h
--- 25/include/asm-m68k/string.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/string.h	2004-01-19 22:17:24.000000000 -0800
@@ -82,7 +82,7 @@ static inline char * strchr(const char *
 
 #if 0
 #define __HAVE_ARCH_STRPBRK
-extern inline char * strpbrk(const char * cs,const char * ct)
+static inline char *strpbrk(const char *cs,const char *ct)
 {
   const char *sc1,*sc2;
   
@@ -530,7 +530,8 @@ extern int memcmp(const void * ,const vo
  memcmp((cs),(ct),(n)))
 
 #define __HAVE_ARCH_MEMCHR
-extern inline void * memchr(const void * cs, int c, size_t count) {
+static inline void *memchr(const void *cs, int c, size_t count)
+{
 	/* Someone else can optimize this, I don't care - tonym@mac.linux-m68k.org */
 	unsigned char *ret = (unsigned char *)cs;
 	for(;count>0;count--,ret++)
diff -puN include/asm-m68k/sun3mmu.h~linus include/asm-m68k/sun3mmu.h
--- 25/include/asm-m68k/sun3mmu.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/sun3mmu.h	2004-01-19 22:17:24.000000000 -0800
@@ -69,7 +69,7 @@
 #ifndef __ASSEMBLY__
 
 /* Read bus error status register (implicitly clearing it). */
-extern __inline__ unsigned char sun3_get_buserr (void)
+static inline unsigned char sun3_get_buserr(void)
 {
 	unsigned char sfc, c;
 
@@ -82,7 +82,7 @@ extern __inline__ unsigned char sun3_get
 }
 
 /* Read segmap from hardware MMU. */
-extern __inline__ unsigned long sun3_get_segmap (unsigned long addr)
+static inline unsigned long sun3_get_segmap(unsigned long addr)
 {
         register unsigned long entry;
         unsigned char c, sfc;
@@ -97,7 +97,7 @@ extern __inline__ unsigned long sun3_get
 }
 
 /* Write segmap to hardware MMU. */
-extern __inline__ void sun3_put_segmap (unsigned long addr, unsigned long entry)
+static inline void sun3_put_segmap(unsigned long addr, unsigned long entry)
 {
         unsigned char sfc;
 
@@ -110,7 +110,7 @@ extern __inline__ void sun3_put_segmap (
 }
 
 /* Read PTE from hardware MMU. */
-extern __inline__ unsigned long sun3_get_pte (unsigned long addr)
+static inline unsigned long sun3_get_pte(unsigned long addr)
 {
         register unsigned long entry;
         unsigned char sfc;
@@ -124,7 +124,7 @@ extern __inline__ unsigned long sun3_get
 }
 
 /* Write PTE to hardware MMU. */
-extern __inline__ void sun3_put_pte (unsigned long addr, unsigned long entry)
+static inline void sun3_put_pte(unsigned long addr, unsigned long entry)
 {
         unsigned char sfc;
 
@@ -137,7 +137,7 @@ extern __inline__ void sun3_put_pte (uns
 }
 
 /* get current context */
-extern __inline__ unsigned char sun3_get_context(void)
+static inline unsigned char sun3_get_context(void)
 {
 	unsigned char sfc, c;
 
@@ -150,7 +150,7 @@ extern __inline__ unsigned char sun3_get
 }
 
 /* set alternate context */
-extern __inline__ void sun3_put_context(unsigned char c)
+static inline void sun3_put_context(unsigned char c)
 {
 	unsigned char dfc;
 	GET_DFC(dfc);
diff -puN include/asm-m68k/sun3_pgtable.h~linus include/asm-m68k/sun3_pgtable.h
--- 25/include/asm-m68k/sun3_pgtable.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/sun3_pgtable.h	2004-01-19 22:17:24.000000000 -0800
@@ -103,22 +103,27 @@
  */
 #define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
 
-extern inline pte_t pte_modify (pte_t pte, pgprot_t newprot)
-{ pte_val(pte) = (pte_val(pte) & SUN3_PAGE_CHG_MASK) | pgprot_val(newprot); return pte; }
+static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
+{
+	pte_val(pte) = (pte_val(pte) & SUN3_PAGE_CHG_MASK) | pgprot_val(newprot);
+	return pte;
+}
 
 #define pmd_set(pmdp,ptep) do {} while (0)
 
-extern inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
-{ pgd_val(*pgdp) = virt_to_phys(pmdp); }
+static inline void pgd_set(pgd_t *pgdp, pmd_t *pmdp)
+{
+	pgd_val(*pgdp) = virt_to_phys(pmdp);
+}
 
 #define __pte_page(pte) \
 ((unsigned long) __va ((pte_val (pte) & SUN3_PAGE_PGNUM_MASK) << PAGE_SHIFT))
 #define __pmd_page(pmd) \
 ((unsigned long) __va (pmd_val (pmd) & PAGE_MASK))
 
-extern inline int pte_none (pte_t pte) { return !pte_val (pte); }
-extern inline int pte_present (pte_t pte) { return pte_val (pte) & SUN3_PAGE_VALID; }
-extern inline void pte_clear (pte_t *ptep) { pte_val (*ptep) = 0; }
+static inline int pte_none (pte_t pte) { return !pte_val (pte); }
+static inline int pte_present (pte_t pte) { return pte_val (pte) & SUN3_PAGE_VALID; }
+static inline void pte_clear (pte_t *ptep) { pte_val (*ptep) = 0; }
 
 #define pte_pfn(pte)            (pte_val(pte) & SUN3_PAGE_PGNUM_MASK)
 #define pfn_pte(pfn, pgprot) \
@@ -128,20 +133,20 @@ extern inline void pte_clear (pte_t *pte
 #define pmd_page(pmd)		(mem_map+((__pmd_page(pmd) - PAGE_OFFSET) >> PAGE_SHIFT))
 
 
-extern inline int pmd_none2 (pmd_t *pmd) { return !pmd_val (*pmd); }
+static inline int pmd_none2 (pmd_t *pmd) { return !pmd_val (*pmd); }
 #define pmd_none(pmd) pmd_none2(&(pmd))
-//extern inline int pmd_bad (pmd_t pmd) { return (pmd_val (pmd) & SUN3_PMD_MASK) != SUN3_PMD_MAGIC; }
-extern inline int pmd_bad2 (pmd_t *pmd) { return 0; }
+//static inline int pmd_bad (pmd_t pmd) { return (pmd_val (pmd) & SUN3_PMD_MASK) != SUN3_PMD_MAGIC; }
+static inline int pmd_bad2 (pmd_t *pmd) { return 0; }
 #define pmd_bad(pmd) pmd_bad2(&(pmd))
-extern inline int pmd_present2 (pmd_t *pmd) { return pmd_val (*pmd) & SUN3_PMD_VALID; }
+static inline int pmd_present2 (pmd_t *pmd) { return pmd_val (*pmd) & SUN3_PMD_VALID; }
 /* #define pmd_present(pmd) pmd_present2(&(pmd)) */
 #define pmd_present(pmd) (!pmd_none2(&(pmd)))
-extern inline void pmd_clear (pmd_t *pmdp) { pmd_val (*pmdp) = 0; }
+static inline void pmd_clear (pmd_t *pmdp) { pmd_val (*pmdp) = 0; }
 
-extern inline int pgd_none (pgd_t pgd) { return 0; }
-extern inline int pgd_bad (pgd_t pgd) { return 0; }
-extern inline int pgd_present (pgd_t pgd) { return 1; }
-extern inline void pgd_clear (pgd_t *pgdp) {}
+static inline int pgd_none (pgd_t pgd) { return 0; }
+static inline int pgd_bad (pgd_t pgd) { return 0; }
+static inline int pgd_present (pgd_t pgd) { return 1; }
+static inline void pgd_clear (pgd_t *pgdp) {}
 
 
 #define pte_ERROR(e) \
@@ -157,28 +162,28 @@ extern inline void pgd_clear (pgd_t *pgd
  * Undefined behaviour if not...
  * [we have the full set here even if they don't change from m68k]
  */
-extern inline int pte_read(pte_t pte)		{ return 1; }
-extern inline int pte_write(pte_t pte)		{ return pte_val(pte) & SUN3_PAGE_WRITEABLE; }
-extern inline int pte_exec(pte_t pte)		{ return 1; }
-extern inline int pte_dirty(pte_t pte)		{ return pte_val(pte) & SUN3_PAGE_MODIFIED; }
-extern inline int pte_young(pte_t pte)		{ return pte_val(pte) & SUN3_PAGE_ACCESSED; }
-extern inline int pte_file(pte_t pte)		{ return pte_val(pte) & SUN3_PAGE_ACCESSED; }
-
-extern inline pte_t pte_wrprotect(pte_t pte)	{ pte_val(pte) &= ~SUN3_PAGE_WRITEABLE; return pte; }
-extern inline pte_t pte_rdprotect(pte_t pte)	{ return pte; }
-extern inline pte_t pte_exprotect(pte_t pte)	{ return pte; }
-extern inline pte_t pte_mkclean(pte_t pte)	{ pte_val(pte) &= ~SUN3_PAGE_MODIFIED; return pte; }
-extern inline pte_t pte_mkold(pte_t pte)	{ pte_val(pte) &= ~SUN3_PAGE_ACCESSED; return pte; }
-extern inline pte_t pte_mkwrite(pte_t pte)	{ pte_val(pte) |= SUN3_PAGE_WRITEABLE; return pte; }
-extern inline pte_t pte_mkread(pte_t pte)	{ return pte; }
-extern inline pte_t pte_mkexec(pte_t pte)	{ return pte; }
-extern inline pte_t pte_mkdirty(pte_t pte)	{ pte_val(pte) |= SUN3_PAGE_MODIFIED; return pte; }
-extern inline pte_t pte_mkyoung(pte_t pte)	{ pte_val(pte) |= SUN3_PAGE_ACCESSED; return pte; }
-extern inline pte_t pte_mknocache(pte_t pte)	{ pte_val(pte) |= SUN3_PAGE_NOCACHE; return pte; }
+static inline int pte_read(pte_t pte)		{ return 1; }
+static inline int pte_write(pte_t pte)		{ return pte_val(pte) & SUN3_PAGE_WRITEABLE; }
+static inline int pte_exec(pte_t pte)		{ return 1; }
+static inline int pte_dirty(pte_t pte)		{ return pte_val(pte) & SUN3_PAGE_MODIFIED; }
+static inline int pte_young(pte_t pte)		{ return pte_val(pte) & SUN3_PAGE_ACCESSED; }
+static inline int pte_file(pte_t pte)		{ return pte_val(pte) & SUN3_PAGE_ACCESSED; }
+
+static inline pte_t pte_wrprotect(pte_t pte)	{ pte_val(pte) &= ~SUN3_PAGE_WRITEABLE; return pte; }
+static inline pte_t pte_rdprotect(pte_t pte)	{ return pte; }
+static inline pte_t pte_exprotect(pte_t pte)	{ return pte; }
+static inline pte_t pte_mkclean(pte_t pte)	{ pte_val(pte) &= ~SUN3_PAGE_MODIFIED; return pte; }
+static inline pte_t pte_mkold(pte_t pte)	{ pte_val(pte) &= ~SUN3_PAGE_ACCESSED; return pte; }
+static inline pte_t pte_mkwrite(pte_t pte)	{ pte_val(pte) |= SUN3_PAGE_WRITEABLE; return pte; }
+static inline pte_t pte_mkread(pte_t pte)	{ return pte; }
+static inline pte_t pte_mkexec(pte_t pte)	{ return pte; }
+static inline pte_t pte_mkdirty(pte_t pte)	{ pte_val(pte) |= SUN3_PAGE_MODIFIED; return pte; }
+static inline pte_t pte_mkyoung(pte_t pte)	{ pte_val(pte) |= SUN3_PAGE_ACCESSED; return pte; }
+static inline pte_t pte_mknocache(pte_t pte)	{ pte_val(pte) |= SUN3_PAGE_NOCACHE; return pte; }
 // use this version when caches work...
-//extern inline pte_t pte_mkcache(pte_t pte)	{ pte_val(pte) &= SUN3_PAGE_NOCACHE; return pte; }
+//static inline pte_t pte_mkcache(pte_t pte)	{ pte_val(pte) &= SUN3_PAGE_NOCACHE; return pte; }
 // until then, use:
-extern inline pte_t pte_mkcache(pte_t pte)	{ return pte; }
+static inline pte_t pte_mkcache(pte_t pte)	{ return pte; }
 
 extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
 extern pgd_t kernel_pg_dir[PTRS_PER_PGD];
@@ -193,7 +198,7 @@ extern pgd_t kernel_pg_dir[PTRS_PER_PGD]
 #define pgd_offset_k(address) pgd_offset(&init_mm, address)
 
 /* Find an entry in the second-level pagetable. */
-extern inline pmd_t *pmd_offset (pgd_t *pgd, unsigned long address)
+static inline pmd_t *pmd_offset (pgd_t *pgd, unsigned long address)
 {
 	return (pmd_t *) pgd;
 }
diff -puN include/asm-m68k/system.h~linus include/asm-m68k/system.h
--- 25/include/asm-m68k/system.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/system.h	2004-01-19 22:17:24.000000000 -0800
@@ -7,6 +7,8 @@
 #include <asm/segment.h>
 #include <asm/entry.h>
 
+#ifdef __KERNEL__
+
 /*
  * switch_to(n) should switch tasks to task ptr, first checking that
  * ptr isn't the current task, in which case it does nothing.  This
@@ -156,4 +158,6 @@ static inline unsigned long __xchg(unsig
 }
 #endif
 
+#endif /* __KERNEL__ */
+
 #endif /* _M68K_SYSTEM_H */
diff -puN include/asm-m68k/thread_info.h~linus include/asm-m68k/thread_info.h
--- 25/include/asm-m68k/thread_info.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/thread_info.h	2004-01-19 22:17:24.000000000 -0800
@@ -35,7 +35,7 @@ struct thread_info {
 #define free_thread_info(ti)  free_pages((unsigned long)(ti),1)
 #endif /* PAGE_SHIFT == 13 */
 
-#define init_thread_info	(init_thread_union.thread_info)
+//#define init_thread_info	(init_task.thread.info)
 #define init_stack		(init_thread_union.stack)
 
 #define current_thread_info()	(current->thread_info)
diff -puN include/asm-m68k/tlbflush.h~linus include/asm-m68k/tlbflush.h
--- 25/include/asm-m68k/tlbflush.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/tlbflush.h	2004-01-19 22:17:24.000000000 -0800
@@ -87,7 +87,7 @@ static inline void flush_tlb_kernel_rang
 	flush_tlb_all();
 }
 
-extern inline void flush_tlb_pgtables(struct mm_struct *mm,
+static inline void flush_tlb_pgtables(struct mm_struct *mm,
 				      unsigned long start, unsigned long end)
 {
 }
@@ -214,7 +214,7 @@ static inline void flush_tlb_kernel_page
 	sun3_put_segmap (addr & ~(SUN3_PMEG_SIZE - 1), SUN3_INVALID_PMEG);
 }
 
-extern inline void flush_tlb_pgtables(struct mm_struct *mm,
+static inline void flush_tlb_pgtables(struct mm_struct *mm,
 				      unsigned long start, unsigned long end)
 {
 }
diff -puN include/asm-m68k/uaccess.h~linus include/asm-m68k/uaccess.h
--- 25/include/asm-m68k/uaccess.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/uaccess.h	2004-01-19 22:17:24.000000000 -0800
@@ -14,7 +14,7 @@
 /* We let the MMU do all checking */
 #define access_ok(type,addr,size) 1
 
-extern inline int verify_area(int type, const void * addr, unsigned long size)
+static inline int verify_area(int type, const void *addr, unsigned long size)
 {
 	return access_ok(type,addr,size)?0:-EFAULT;
 }
diff -puN include/asm-m68k/virtconvert.h~linus include/asm-m68k/virtconvert.h
--- 25/include/asm-m68k/virtconvert.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/virtconvert.h	2004-01-19 22:17:24.000000000 -0800
@@ -22,12 +22,12 @@
 extern unsigned long mm_vtop(unsigned long addr) __attribute__ ((const));
 extern unsigned long mm_ptov(unsigned long addr) __attribute__ ((const));
 #else
-extern inline unsigned long mm_vtop(unsigned long vaddr)
+static inline unsigned long mm_vtop(unsigned long vaddr)
 {
 	return __pa(vaddr);
 }
 
-extern inline unsigned long mm_ptov(unsigned long paddr)
+static inline unsigned long mm_ptov(unsigned long paddr)
 {
 	return (unsigned long)__va(paddr);
 }
diff -puN include/asm-m68k/zorro.h~linus include/asm-m68k/zorro.h
--- 25/include/asm-m68k/zorro.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-m68k/zorro.h	2004-01-19 22:17:24.000000000 -0800
@@ -15,25 +15,25 @@
 #define z_memcpy_fromio(a,b,c)	memcpy((a),(void *)(b),(c))
 #define z_memcpy_toio(a,b,c)	memcpy((void *)(a),(b),(c))
 
-extern inline void *z_remap_nocache_ser(unsigned long physaddr, 
-					  unsigned long size)
+static inline void *z_remap_nocache_ser(unsigned long physaddr,
+					unsigned long size)
 {
 	return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
 }
 
-extern inline void *z_remap_nocache_nonser(unsigned long physaddr, 
-					     unsigned long size)
+static inline void *z_remap_nocache_nonser(unsigned long physaddr,
+					   unsigned long size)
 {
 	return __ioremap(physaddr, size, IOMAP_NOCACHE_NONSER);
 }
 
-extern inline void *z_remap_writethrough(unsigned long physaddr,
-					   unsigned long size)
+static inline void *z_remap_writethrough(unsigned long physaddr,
+					 unsigned long size)
 {
 	return __ioremap(physaddr, size, IOMAP_WRITETHROUGH);
 }
-extern inline void *z_remap_fullcache(unsigned long physaddr,
-					unsigned long size)
+static inline void *z_remap_fullcache(unsigned long physaddr,
+				      unsigned long size)
 {
 	return __ioremap(physaddr, size, IOMAP_FULL_CACHING);
 }
diff -puN include/asm-mips/dma-mapping.h~linus include/asm-mips/dma-mapping.h
--- 25/include/asm-mips/dma-mapping.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-mips/dma-mapping.h	2004-01-19 22:17:24.000000000 -0800
@@ -124,8 +124,7 @@ dma_unmap_sg(struct device *dev, struct 
 	for (i = 0; i < nhwentries; i++, sg++) {
 		unsigned long addr;
 
-		if (!sg->page)
-			BUG();
+		BUG_ON(!sg->page);
 
 		addr = (unsigned long) page_address(sg->page);
 		if (addr)
@@ -139,8 +138,7 @@ dma_sync_single(struct device *dev, dma_
 {
 	unsigned long addr;
  
-	if (direction == DMA_NONE)
-		BUG();
+	BUG_ON(direction == DMA_NONE);
  
 	addr = baddr_to_bus(hwdev->bus, dma_handle) + PAGE_OFFSET;
 	dma_cache_wback_inv(addr, size);
@@ -153,8 +151,7 @@ dma_sync_single_range(struct device *dev
 {
 	unsigned long addr;
 
-	if (direction == DMA_NONE)
-		BUG();
+	BUG_ON(direction == DMA_NONE);
 
 	addr = baddr_to_bus(hwdev->bus, dma_handle) + PAGE_OFFSET;
 	dma_cache_wback_inv(addr, size);
@@ -168,8 +165,7 @@ dma_sync_sg(struct device *dev, struct s
 	int i;
 #endif
  
-	if (direction == DMA_NONE)
-		BUG();
+	BUG_ON(direction == DMA_NONE);
  
 	/* Make sure that gcc doesn't leave the empty loop body.  */
 #ifdef CONFIG_NONCOHERENT_IO
diff -puN include/asm-mips/pci.h~linus include/asm-mips/pci.h
--- 25/include/asm-mips/pci.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-mips/pci.h	2004-01-19 22:17:24.000000000 -0800
@@ -113,8 +113,7 @@ static inline void pci_dac_dma_sync_sing
 {
 	unsigned long addr;
 
-	if (direction == PCI_DMA_NONE)
-		BUG();
+	BUG_ON(direction == PCI_DMA_NONE);
 
 	addr = baddr_to_bus(pdev->bus, dma_addr) + PAGE_OFFSET;
 	dma_cache_wback_inv(addr, len);
diff -puN include/asm-mips/smp.h~linus include/asm-mips/smp.h
--- 25/include/asm-mips/smp.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-mips/smp.h	2004-01-19 22:17:24.000000000 -0800
@@ -48,8 +48,8 @@ extern struct call_data_struct *call_dat
 
 extern cpumask_t phys_cpu_present_map;
 extern cpumask_t cpu_online_map;
+#define cpu_possible_map	phys_cpu_present_map
 
-#define cpu_possible(cpu)	cpu_isset(cpu, phys_cpu_present_map)
 #define cpu_online(cpu)		cpu_isset(cpu, cpu_online_map)
 
 static inline unsigned int num_online_cpus(void)
diff -puN include/asm-mips/socket.h~linus include/asm-mips/socket.h
--- 25/include/asm-mips/socket.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-mips/socket.h	2004-01-19 22:17:24.000000000 -0800
@@ -66,6 +66,8 @@ To add: #define SO_REUSEPORT 0x0200	/* A
 #define SO_TIMESTAMP		29
 #define SCM_TIMESTAMP		SO_TIMESTAMP
 
+#define SO_PEERSEC             30
+
 /* Nast libc5 fixup - bletch */
 #if defined(__KERNEL__)
 /* Socket types. */
diff -puN include/asm-parisc/byteorder.h~linus include/asm-parisc/byteorder.h
--- 25/include/asm-parisc/byteorder.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-parisc/byteorder.h	2004-01-19 22:17:24.000000000 -0800
@@ -2,10 +2,11 @@
 #define _PARISC_BYTEORDER_H
 
 #include <asm/types.h>
+#include <linux/compiler.h>
 
 #ifdef __GNUC__
 
-static __inline__ __const__ __u16 ___arch__swab16(__u16 x)
+static __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 x)
 {
 	__asm__("dep %0, 15, 8, %0\n\t"		/* deposit 00ab -> 0bab */
 		"shd %%r0, %0, 8, %0"		/* shift 000000ab -> 00ba */
@@ -14,7 +15,7 @@ static __inline__ __const__ __u16 ___arc
 	return x;
 }
 
-static __inline__ __const__ __u32 ___arch__swab24(__u32 x)
+static __inline__ __attribute_const__ __u32 ___arch__swab24(__u32 x)
 {
 	__asm__("shd %0, %0, 8, %0\n\t"		/* shift xabcxabc -> cxab */
 		"dep %0, 15, 8, %0\n\t"		/* deposit cxab -> cbab */
@@ -24,7 +25,7 @@ static __inline__ __const__ __u32 ___arc
 	return x;
 }
 
-static __inline__ __const__ __u32 ___arch__swab32(__u32 x)
+static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
 {
 	unsigned int temp;
 	__asm__("shd %0, %0, 16, %1\n\t"	/* shift abcdabcd -> cdab */
@@ -47,7 +48,7 @@ static __inline__ __const__ __u32 ___arc
 **      HSHR    67452301 -> *6*4*2*0 into %0
 **      OR      %0 | %1  -> 76543210 into %0 (all done!)
 */
-static __inline__ __const__ __u64 ___arch__swab64(__u64 x) {
+static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x) {
 	__u64 temp;
 	__asm__("permh,3210 %0, %0\n\t"
 		"hshl %0, 8, %1\n\t"
@@ -60,7 +61,7 @@ static __inline__ __const__ __u64 ___arc
 #define __arch__swab64(x) ___arch__swab64(x)
 #define __BYTEORDER_HAS_U64__
 #elif !defined(__STRICT_ANSI__)
-static __inline__ __const__ __u64 ___arch__swab64(__u64 x)
+static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x)
 {
 	__u32 t1 = ___arch__swab32((__u32) x);
 	__u32 t2 = ___arch__swab32((__u32) (x >> 32));
diff -puN include/asm-parisc/mmu_context.h~linus include/asm-parisc/mmu_context.h
--- 25/include/asm-parisc/mmu_context.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-parisc/mmu_context.h	2004-01-19 22:17:24.000000000 -0800
@@ -19,8 +19,7 @@ extern void free_sid(unsigned long);
 static inline int
 init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 {
-	if (atomic_read(&mm->mm_users) != 1)
-	    BUG();
+	BUG_ON(atomic_read(&mm->mm_users) != 1);
 
 	mm->context = alloc_sid();
 	return 0;
@@ -64,7 +63,7 @@ static inline void activate_mm(struct mm
 	 * already, so we should be OK.
 	 */
 
-	if (next == &init_mm) BUG(); /* Should never happen */
+	BUG_ON(next == &init_mm); /* Should never happen */
 
 	if (next->context == 0)
 	    next->context = alloc_sid();
diff -puN include/asm-parisc/pgtable.h~linus include/asm-parisc/pgtable.h
--- 25/include/asm-parisc/pgtable.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-parisc/pgtable.h	2004-01-19 22:17:24.000000000 -0800
@@ -460,4 +460,12 @@ typedef pte_t *pte_addr_t;
 
 #define HAVE_ARCH_UNMAPPED_AREA
 
+#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
+#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
+#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
+#define __HAVE_ARCH_PTEP_SET_WRPROTECT
+#define __HAVE_ARCH_PTEP_MKDIRTY
+#define __HAVE_ARCH_PTE_SAME
+#include <asm-generic/pgtable.h>
+
 #endif /* _PARISC_PGTABLE_H */
diff -puN include/asm-parisc/smp.h~linus include/asm-parisc/smp.h
--- 25/include/asm-parisc/smp.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-parisc/smp.h	2004-01-19 22:17:24.000000000 -0800
@@ -54,7 +54,7 @@ extern unsigned long cpu_present_mask;
 #define smp_processor_id()	(current_thread_info()->cpu)
 #define cpu_online(cpu) cpu_isset(cpu, cpu_online_map)
 
-#define cpu_possible(cpu)       cpu_isset(cpu, cpu_present_mask)
+#define cpu_possible_map	cpu_present_map
 
 #endif /* CONFIG_SMP */
 
diff -puN include/asm-parisc/socket.h~linus include/asm-parisc/socket.h
--- 25/include/asm-parisc/socket.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-parisc/socket.h	2004-01-19 22:17:24.000000000 -0800
@@ -45,6 +45,8 @@
 
 #define SO_ACCEPTCONN		0x401c
 
+#define SO_PEERSEC		0x401d
+
 #if defined(__KERNEL__)
 #define SOCK_STREAM	1	/* stream (connection) socket	*/
 #define SOCK_DGRAM	2	/* datagram (conn.less) socket	*/
diff -puN include/asm-parisc/tlbflush.h~linus include/asm-parisc/tlbflush.h
--- 25/include/asm-parisc/tlbflush.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-parisc/tlbflush.h	2004-01-19 22:17:24.000000000 -0800
@@ -27,7 +27,7 @@ extern void flush_tlb_all(void);
 
 static inline void flush_tlb_mm(struct mm_struct *mm)
 {
-	if (mm == &init_mm) BUG(); /* Should never happen */
+	BUG_ON(mm == &init_mm); /* Should never happen */
 
 #ifdef CONFIG_SMP
 	flush_tlb_all();
diff -puN include/asm-ppc64/byteorder.h~linus include/asm-ppc64/byteorder.h
--- 25/include/asm-ppc64/byteorder.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/byteorder.h	2004-01-19 22:17:24.000000000 -0800
@@ -9,6 +9,7 @@
  */
 
 #include <asm/types.h>
+#include <linux/compiler.h>
 
 #ifdef __GNUC__
 #ifdef __KERNEL__
@@ -40,7 +41,7 @@ static __inline__ void st_le32(volatile 
 }
 
 #if 0
-static __inline__ __const__ __u16 ___arch__swab16(__u16 value)
+static __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 value)
 {
 	__u16 result;
 
@@ -50,7 +51,7 @@ static __inline__ __const__ __u16 ___arc
 	return result;
 }
 
-static __inline__ __const__ __u32 ___arch__swab32(__u32 value)
+static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 value)
 {
 	__u32 result;
 
@@ -62,7 +63,7 @@ static __inline__ __const__ __u32 ___arc
 	return result;
 }
 
-static __inline__ __const__ __u64 ___arch__swab64(__u64 value)
+static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 value)
 {
 	__u64 result;
 #error implement me
diff -puN include/asm-ppc64/compat.h~linus include/asm-ppc64/compat.h
--- 25/include/asm-ppc64/compat.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/compat.h	2004-01-19 22:17:24.000000000 -0800
@@ -53,11 +53,11 @@ struct compat_stat {
 	compat_off_t	st_blksize;
 	compat_off_t	st_blocks;
 	compat_time_t	st_atime;
-	u32		__unused1;
+	u32		st_atime_nsec;
 	compat_time_t	st_mtime;
-	u32		__unused2;
+	u32		st_mtime_nsec;
 	compat_time_t	st_ctime;
-	u32		__unused3;
+	u32		st_ctime_nsec;
 	u32		__unused4[2];
 };
 
diff -puN include/asm-ppc64/cputable.h~linus include/asm-ppc64/cputable.h
--- 25/include/asm-ppc64/cputable.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/cputable.h	2004-01-19 22:17:24.000000000 -0800
@@ -74,10 +74,20 @@ extern struct cpu_spec		*cur_cpu_spec;
 #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)	
+#define FW_FEATURE_TERM		(1UL<<7)	
+#define FW_FEATURE_PERF		(1UL<<8)	
+#define FW_FEATURE_DUMP		(1UL<<9)	
+#define FW_FEATURE_INTERRUPT	(1UL<<10)	
+#define FW_FEATURE_MIGRATE	(1UL<<11)	
+#define FW_FEATURE_PERFMON	(1UL<<12)	
+#define FW_FEATURE_CRQ   	(1UL<<13)	
+#define FW_FEATURE_VIO   	(1UL<<14)	
+#define FW_FEATURE_RDMA   	(1UL<<15)	
+#define FW_FEATURE_LLAN   	(1UL<<16)	
+#define FW_FEATURE_BULK   	(1UL<<17)	
+#define FW_FEATURE_XDABR   	(1UL<<18)	
+#define FW_FEATURE_MULTITCE   	(1UL<<19)	
+#define FW_FEATURE_SPLPAR   	(1UL<<20)	
 
 typedef struct {
     unsigned long val;
@@ -144,11 +154,24 @@ extern firmware_feature_t firmware_featu
 	.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)
+#else
+
+#define BEGIN_FTR_SECTION		"98:\n"
+#define END_FTR_SECTION(msk, val)		\
+"99:\n"						\
+"	.section __ftr_fixup,\"a\";\n"		\
+"	.align 3;\n"				\
+"	.llong "#msk";\n"			\
+"	.llong "#val";\n"			\
+"	.llong 98b;\n"			        \
+"	.llong 99b;\n"	 		        \
+"	.previous\n"
 
 #endif /* __ASSEMBLY__ */
 
+#define END_FTR_SECTION_IFSET(msk)	END_FTR_SECTION((msk), (msk))
+#define END_FTR_SECTION_IFCLR(msk)	END_FTR_SECTION((msk), 0)
+
 #endif /* __ASM_PPC_CPUTABLE_H */
 #endif /* __KERNEL__ */
 
diff -puN include/asm-ppc64/elf.h~linus include/asm-ppc64/elf.h
--- 25/include/asm-ppc64/elf.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/elf.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,6 +1,10 @@
 #ifndef __PPC64_ELF_H
 #define __PPC64_ELF_H
 
+#include <asm/types.h>
+#include <asm/ptrace.h>
+#include <asm/cputable.h>
+
 /* PowerPC relocations defined by the ABIs */
 #define R_PPC_NONE		0
 #define R_PPC_ADDR32		1	/* 32bit absolute address */
@@ -39,8 +43,39 @@
 #define R_PPC_SECTOFF_LO	34
 #define R_PPC_SECTOFF_HI	35
 #define R_PPC_SECTOFF_HA	36
+
+/* PowerPC relocations defined for the TLS access ABI.  */
+#define R_PPC_TLS		67 /* none	(sym+add)@tls */
+#define R_PPC_DTPMOD32		68 /* word32	(sym+add)@dtpmod */
+#define R_PPC_TPREL16		69 /* half16*	(sym+add)@tprel */
+#define R_PPC_TPREL16_LO	70 /* half16	(sym+add)@tprel@l */
+#define R_PPC_TPREL16_HI	71 /* half16	(sym+add)@tprel@h */
+#define R_PPC_TPREL16_HA	72 /* half16	(sym+add)@tprel@ha */
+#define R_PPC_TPREL32		73 /* word32	(sym+add)@tprel */
+#define R_PPC_DTPREL16		74 /* half16*	(sym+add)@dtprel */
+#define R_PPC_DTPREL16_LO	75 /* half16	(sym+add)@dtprel@l */
+#define R_PPC_DTPREL16_HI	76 /* half16	(sym+add)@dtprel@h */
+#define R_PPC_DTPREL16_HA	77 /* half16	(sym+add)@dtprel@ha */
+#define R_PPC_DTPREL32		78 /* word32	(sym+add)@dtprel */
+#define R_PPC_GOT_TLSGD16	79 /* half16*	(sym+add)@got@tlsgd */
+#define R_PPC_GOT_TLSGD16_LO	80 /* half16	(sym+add)@got@tlsgd@l */
+#define R_PPC_GOT_TLSGD16_HI	81 /* half16	(sym+add)@got@tlsgd@h */
+#define R_PPC_GOT_TLSGD16_HA	82 /* half16	(sym+add)@got@tlsgd@ha */
+#define R_PPC_GOT_TLSLD16	83 /* half16*	(sym+add)@got@tlsld */
+#define R_PPC_GOT_TLSLD16_LO	84 /* half16	(sym+add)@got@tlsld@l */
+#define R_PPC_GOT_TLSLD16_HI	85 /* half16	(sym+add)@got@tlsld@h */
+#define R_PPC_GOT_TLSLD16_HA	86 /* half16	(sym+add)@got@tlsld@ha */
+#define R_PPC_GOT_TPREL16	87 /* half16*	(sym+add)@got@tprel */
+#define R_PPC_GOT_TPREL16_LO	88 /* half16	(sym+add)@got@tprel@l */
+#define R_PPC_GOT_TPREL16_HI	89 /* half16	(sym+add)@got@tprel@h */
+#define R_PPC_GOT_TPREL16_HA	90 /* half16	(sym+add)@got@tprel@ha */
+#define R_PPC_GOT_DTPREL16	91 /* half16*	(sym+add)@got@dtprel */
+#define R_PPC_GOT_DTPREL16_LO	92 /* half16*	(sym+add)@got@dtprel@l */
+#define R_PPC_GOT_DTPREL16_HI	93 /* half16*	(sym+add)@got@dtprel@h */
+#define R_PPC_GOT_DTPREL16_HA	94 /* half16*	(sym+add)@got@dtprel@ha */
+
 /* Keep this the last entry.  */
-#define R_PPC_NUM		37
+#define R_PPC_NUM		95
 
 /*
  * ELF register definitions..
@@ -54,7 +89,8 @@
 
 #define ELF_NGREG	48	/* includes nip, msr, lr, etc. */
 #define ELF_NFPREG	33	/* includes fpscr */
-#define ELF_NVRREG	33	/* includes vscr */
+#define ELF_NVRREG32	33	/* includes vscr & vrsave stuffed together */
+#define ELF_NVRREG	34	/* includes vscr & vrsave in split vectors */
 
 typedef unsigned long elf_greg_t64;
 typedef elf_greg_t64 elf_gregset_t64[ELF_NGREG];
@@ -82,6 +118,27 @@ typedef elf_greg_t32 elf_gregset_t32[ELF
 typedef double elf_fpreg_t;
 typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
 
+/* Altivec registers */
+/*
+ * The entries with indexes 0-31 contain the corresponding vector registers. 
+ * The entry with index 32 contains the vscr as the last word (offset 12) 
+ * within the quadword.  This allows the vscr to be stored as either a 
+ * quadword (since it must be copied via a vector register to/from storage) 
+ * or as a word.  The entry with index 33 contains the vrsave as the first 
+ * word (offset 0) within the quadword.
+ *
+ * This definition of the VMX state is compatible with the current PPC32 
+ * ptrace interface.  This allows signal handling and ptrace to use the same 
+ * structures.  This also simplifies the implementation of a bi-arch 
+ * (combined (32- and 64-bit) gdb.
+ *
+ * Note that it's _not_ compatible with 32 bits ucontext which stuffs the
+ * vrsave along with vscr and so only uses 33 vectors for the register set
+ */
+typedef __vector128 elf_vrreg_t;
+typedef elf_vrreg_t elf_vrregset_t[ELF_NVRREG];
+typedef elf_vrreg_t elf_vrregset_t32[ELF_NVRREG32];
+
 /*
  * This is used to ensure we don't load something for the wrong architecture.
  */
@@ -128,13 +185,15 @@ static inline int dump_task_regs(struct 
 extern int dump_task_fpu(struct task_struct *, elf_fpregset_t *); 
 #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
 
+/* XXX Should we define the XFPREGS using altivec ??? */
+
 #endif
 
 /* This yields a mask that user programs can use to figure out what
    instruction set this cpu supports.  This could be done in userspace,
    but it's not easy, and we've already done it here.  */
 
-#define ELF_HWCAP	(0)
+#define ELF_HWCAP	(cur_cpu_spec->cpu_user_features)
 
 /* This yields a string that ld.so will use to load implementation
    specific libraries for optimization.  This is more specific in
@@ -272,7 +331,50 @@ do {									\
 #define R_PPC64_TOC16_LO_DS    64 /* half16ds  #lo(S + A - .TOC.) >> 2.  */
 #define R_PPC64_PLTGOT16_DS    65 /* half16ds* (M + A) >> 2.  */
 #define R_PPC64_PLTGOT16_LO_DS 66 /* half16ds  #lo(M + A) >> 2.  */
+
+/* PowerPC64 relocations defined for the TLS access ABI.  */
+#define R_PPC64_TLS		67 /* none	(sym+add)@tls */
+#define R_PPC64_DTPMOD64	68 /* doubleword64 (sym+add)@dtpmod */
+#define R_PPC64_TPREL16		69 /* half16*	(sym+add)@tprel */
+#define R_PPC64_TPREL16_LO	70 /* half16	(sym+add)@tprel@l */
+#define R_PPC64_TPREL16_HI	71 /* half16	(sym+add)@tprel@h */
+#define R_PPC64_TPREL16_HA	72 /* half16	(sym+add)@tprel@ha */
+#define R_PPC64_TPREL64		73 /* doubleword64 (sym+add)@tprel */
+#define R_PPC64_DTPREL16	74 /* half16*	(sym+add)@dtprel */
+#define R_PPC64_DTPREL16_LO	75 /* half16	(sym+add)@dtprel@l */
+#define R_PPC64_DTPREL16_HI	76 /* half16	(sym+add)@dtprel@h */
+#define R_PPC64_DTPREL16_HA	77 /* half16	(sym+add)@dtprel@ha */
+#define R_PPC64_DTPREL64	78 /* doubleword64 (sym+add)@dtprel */
+#define R_PPC64_GOT_TLSGD16	79 /* half16*	(sym+add)@got@tlsgd */
+#define R_PPC64_GOT_TLSGD16_LO	80 /* half16	(sym+add)@got@tlsgd@l */
+#define R_PPC64_GOT_TLSGD16_HI	81 /* half16	(sym+add)@got@tlsgd@h */
+#define R_PPC64_GOT_TLSGD16_HA	82 /* half16	(sym+add)@got@tlsgd@ha */
+#define R_PPC64_GOT_TLSLD16	83 /* half16*	(sym+add)@got@tlsld */
+#define R_PPC64_GOT_TLSLD16_LO	84 /* half16	(sym+add)@got@tlsld@l */
+#define R_PPC64_GOT_TLSLD16_HI	85 /* half16	(sym+add)@got@tlsld@h */
+#define R_PPC64_GOT_TLSLD16_HA	86 /* half16	(sym+add)@got@tlsld@ha */
+#define R_PPC64_GOT_TPREL16_DS	87 /* half16ds*	(sym+add)@got@tprel */
+#define R_PPC64_GOT_TPREL16_LO_DS 88 /* half16ds (sym+add)@got@tprel@l */
+#define R_PPC64_GOT_TPREL16_HI	89 /* half16	(sym+add)@got@tprel@h */
+#define R_PPC64_GOT_TPREL16_HA	90 /* half16	(sym+add)@got@tprel@ha */
+#define R_PPC64_GOT_DTPREL16_DS	91 /* half16ds*	(sym+add)@got@dtprel */
+#define R_PPC64_GOT_DTPREL16_LO_DS 92 /* half16ds (sym+add)@got@dtprel@l */
+#define R_PPC64_GOT_DTPREL16_HI	93 /* half16	(sym+add)@got@dtprel@h */
+#define R_PPC64_GOT_DTPREL16_HA	94 /* half16	(sym+add)@got@dtprel@ha */
+#define R_PPC64_TPREL16_DS	95 /* half16ds*	(sym+add)@tprel */
+#define R_PPC64_TPREL16_LO_DS	96 /* half16ds	(sym+add)@tprel@l */
+#define R_PPC64_TPREL16_HIGHER	97 /* half16	(sym+add)@tprel@higher */
+#define R_PPC64_TPREL16_HIGHERA	98 /* half16	(sym+add)@tprel@highera */
+#define R_PPC64_TPREL16_HIGHEST	99 /* half16	(sym+add)@tprel@highest */
+#define R_PPC64_TPREL16_HIGHESTA 100 /* half16	(sym+add)@tprel@highesta */
+#define R_PPC64_DTPREL16_DS	101 /* half16ds* (sym+add)@dtprel */
+#define R_PPC64_DTPREL16_LO_DS	102 /* half16ds	(sym+add)@dtprel@l */
+#define R_PPC64_DTPREL16_HIGHER	103 /* half16	(sym+add)@dtprel@higher */
+#define R_PPC64_DTPREL16_HIGHERA 104 /* half16	(sym+add)@dtprel@highera */
+#define R_PPC64_DTPREL16_HIGHEST 105 /* half16	(sym+add)@dtprel@highest */
+#define R_PPC64_DTPREL16_HIGHESTA 106 /* half16	(sym+add)@dtprel@highesta */
+
 /* Keep this the last entry.  */
-#define R_PPC64_NUM		67
+#define R_PPC64_NUM		107
 
 #endif /* __PPC64_ELF_H */
diff -puN include/asm-ppc64/hvcall.h~linus include/asm-ppc64/hvcall.h
--- 25/include/asm-ppc64/hvcall.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/hvcall.h	2004-01-19 22:17:24.000000000 -0800
@@ -9,6 +9,14 @@
 #define H_PTEG_Full	-6	/* PTEG is full */
 #define H_Not_Found	-7	/* PTE was not found" */
 #define H_Reserved_DABR	-8	/* DABR address is reserved by the hypervisor on this processor" */
+#define H_NoMem                 -9
+#define H_Authority            -10
+#define H_Permission           -11
+#define H_Dropped              -12
+#define H_SourceParm           -13
+#define H_DestParm             -14
+#define H_RemoteParm           -15
+#define H_Resource             -16
 
 /* Flags */
 #define H_LARGE_PAGE		(1UL<<(63-16))
@@ -58,6 +66,21 @@
 #define H_IPOLL			0x70
 #define H_XIRR			0x74
 #define H_PERFMON		0x7c
+#define H_MIGRATE_DMA		0x78
+#define H_REGISTER_VPA		0xDC
+#define H_CEDE		        0xE0
+#define H_CONFER		0xE4
+#define H_PROD		        0xE8
+#define H_GET_PPP		0xEC
+#define H_SET_PPP		0xF0
+#define H_SET_PURR		0xF4
+#define H_PIC		        0xF8
+#define H_REG_CRQ		0xFC
+#define H_FREE_CRQ		0x100
+#define H_VIO_SIGNAL		0x104
+#define H_SEND_CRQ		0x108
+#define H_COPY_RDMA             0x110
+#define H_POLL_PENDING	        0x1D8
 
 /* plpar_hcall() -- Generic call interface using above opcodes
  *
@@ -80,3 +103,38 @@ long plpar_hcall(unsigned long opcode,
  * other than status.  Slightly more efficient.
  */
 long plpar_hcall_norets(unsigned long opcode, ...);
+
+/* 
+ * Special hcall interface for ibmveth support.
+ * Takes 8 input parms. Returns a rc and stores the
+ * R4 return value in *out1.
+ */
+long plpar_hcall_8arg_2ret(unsigned long opcode,
+			   unsigned long arg1,
+		  	   unsigned long arg2,
+			   unsigned long arg3,
+			   unsigned long arg4,
+			   unsigned long arg5,
+			   unsigned long arg6,
+			   unsigned long arg7,
+			   unsigned long arg8,
+			   unsigned long *out1);
+
+
+ 
+ 
+/* plpar_hcall_4out()
+ *
+ * same as plpar_hcall except with 4 output arguments.  
+ * 
+ */
+long plpar_hcall_4out(unsigned long opcode,
+		      unsigned long arg1,
+		      unsigned long arg2,
+		      unsigned long arg3,
+		      unsigned long arg4,
+		      unsigned long *out1,
+		      unsigned long *out2,
+		      unsigned long *out3,
+		      unsigned long *out4);
+
diff -puN include/asm-ppc64/io.h~linus include/asm-ppc64/io.h
--- 25/include/asm-ppc64/io.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/io.h	2004-01-19 22:17:24.000000000 -0800
@@ -120,11 +120,15 @@ extern void _outsl_ns(volatile u32 *port
  * Map in an area of physical address space, for accessing
  * I/O devices etc.
  */
+extern int __ioremap_explicit(unsigned long p_addr, unsigned long v_addr,
+		     	      unsigned long size, unsigned long flags);
 extern void *__ioremap(unsigned long address, unsigned long size,
 		       unsigned long flags);
 extern void *ioremap(unsigned long address, unsigned long size);
 #define ioremap_nocache(addr, size)	ioremap((addr), (size))
+extern int iounmap_explicit(void *addr, unsigned long size);
 extern void iounmap(void *addr);
+extern void * reserve_phb_iospace(unsigned long size);
 
 /*
  * Change virtual addresses to physical addresses and vv, for
diff -puN include/asm-ppc64/irq.h~linus include/asm-ppc64/irq.h
--- 25/include/asm-ppc64/irq.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/irq.h	2004-01-19 22:17:24.000000000 -0800
@@ -41,11 +41,6 @@ static inline unsigned long virt_irq_to_
 	return virt_irq_to_real_map[virt_irq];
 }
 
-/*
- * This gets called from serial.c, which is now used on
- * powermacs as well as prep/chrp boxes.
- * Prep and chrp both have cascaded 8259 PICs.
- */
 static __inline__ int irq_canonicalize(int irq)
 {
 	return irq;
diff -puN include/asm-ppc64/iSeries/HvCallCfg.h~linus include/asm-ppc64/iSeries/HvCallCfg.h
--- 25/include/asm-ppc64/iSeries/HvCallCfg.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/HvCallCfg.h	2004-01-19 22:17:24.000000000 -0800
@@ -23,23 +23,18 @@
 //	drive the hypervisor from the OS.
 //
 //=====================================================================================
+#ifndef _HVCALLCFG_H
+#define _HVCALLCFG_H
 
 //-------------------------------------------------------------------
 // Standard Includes
 //-------------------------------------------------------------------
-#ifndef  _HVCALLSC_H
-#include "HvCallSc.h"
-#endif
-
-#ifndef  _HVTYPES_H
+#include <asm/iSeries/HvCallSc.h>
 #include <asm/iSeries/HvTypes.h>
-#endif
 
 //-------------------------------------------------------------------------------------
 // Constants
 //-------------------------------------------------------------------------------------
-#ifndef _HVCALLCFG_H
-#define _HVCALLCFG_H
 
 enum HvCallCfg_ReqQual
 {
@@ -215,5 +210,4 @@ static inline HvLpIndex	HvCallCfg_getHos
 
 }
 
-#endif // _HVCALLCFG_H
-
+#endif /* _HVCALLCFG_H */
diff -puN include/asm-ppc64/iSeries/HvCallEvent.h~linus include/asm-ppc64/iSeries/HvCallEvent.h
--- 25/include/asm-ppc64/iSeries/HvCallEvent.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/HvCallEvent.h	2004-01-19 22:17:24.000000000 -0800
@@ -17,44 +17,27 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
 
-//==================================================================
-//
-//	This file contains the "hypervisor call" interface which is used to
-//	drive the hypervisor from the OS.
-//
-//==================================================================
-
-//-------------------------------------------------------------------
-// Standard Includes
-//-------------------------------------------------------------------
-#ifndef  _HVCALLSC_H
-#include <asm/iSeries/HvCallSc.h>
-#endif
+/*
+ *	This file contains the "hypervisor call" interface which is used to
+ *	drive the hypervisor from the OS.
+ */
+#ifndef _HVCALLEVENT_H
+#define _HVCALLEVENT_H
 
-#ifndef  _HVTYPES_H
+/*
+ * Standard Includes
+ */
+#include <asm/iSeries/HvCallSc.h>
 #include <asm/iSeries/HvTypes.h>
-#endif
-
 #include <asm/abs_addr.h>
 
-//-------------------------------------------------------------------
-// Other Includes
-//-------------------------------------------------------------------
-
-//-------------------------------------------------------------------
-// Constants
-//-------------------------------------------------------------------
-#ifndef _HVCALLEVENT_H
-#define _HVCALLEVENT_H
-
 struct HvLpEvent;
 
 typedef u8 HvLpEvent_Type;
 typedef u8 HvLpEvent_AckInd;
 typedef u8 HvLpEvent_AckType;
 
-struct	HvCallEvent_PackedParms
-{
+struct	HvCallEvent_PackedParms {
 	u8		xAckType:1;
 	u8		xAckInd:1;
 	u8		xRsvd:1;
@@ -68,8 +51,7 @@ struct	HvCallEvent_PackedParms
 typedef u8 HvLpDma_Direction;
 typedef u8 HvLpDma_AddressType;
 
-struct	HvCallEvent_PackedDmaParms
-{
+struct	HvCallEvent_PackedDmaParms {
 	u8		xDirection:1;
 	u8		xLocalAddrType:1;
 	u8		xRemoteAddrType:1;
@@ -101,69 +83,63 @@ typedef u64 HvLpDma_Rc;
 #define HvCallEventSetLpEventQueueInterruptProc		HvCallEvent + 14
 #define HvCallEventRouter15				HvCallEvent + 15
 
-//======================================================================
-static inline void		HvCallEvent_getOverflowLpEvents(u8 queueIndex)
+static inline void HvCallEvent_getOverflowLpEvents(u8 queueIndex)
 {
 	HvCall1(HvCallEventGetOverflowLpEvents,queueIndex);
 	// getPaca()->adjustHmtForNoOfSpinLocksHeld();
 }
-//======================================================================
-static inline void		HvCallEvent_setInterLpQueueIndex(u8 queueIndex)
+
+static inline void HvCallEvent_setInterLpQueueIndex(u8 queueIndex)
 {
 	HvCall1(HvCallEventSetInterLpQueueIndex,queueIndex);
 	// getPaca()->adjustHmtForNoOfSpinLocksHeld();
 }
-//======================================================================
-static inline void		HvCallEvent_setLpEventStack(u8 queueIndex,
-					     char * eventStackAddr,
-					     u32 eventStackSize)
+
+static inline void HvCallEvent_setLpEventStack(u8 queueIndex,
+		char *eventStackAddr, u32 eventStackSize)
 {
 	u64 abs_addr;
-	abs_addr = virt_to_absolute( (unsigned long) eventStackAddr );
 
-	HvCall3(HvCallEventSetLpEventStack, queueIndex, abs_addr, eventStackSize);
+	abs_addr = virt_to_absolute((unsigned long)eventStackAddr);
+	HvCall3(HvCallEventSetLpEventStack, queueIndex, abs_addr,
+			eventStackSize);
 	// getPaca()->adjustHmtForNoOfSpinLocksHeld();
 }
-//======================================================================
-static inline void		HvCallEvent_setLpEventQueueInterruptProc(u8 queueIndex,
-							  u16 lpLogicalProcIndex)
+
+static inline void HvCallEvent_setLpEventQueueInterruptProc(u8 queueIndex,
+		u16 lpLogicalProcIndex)
 {
-	HvCall2(HvCallEventSetLpEventQueueInterruptProc,queueIndex,lpLogicalProcIndex);
+	HvCall2(HvCallEventSetLpEventQueueInterruptProc, queueIndex,
+			lpLogicalProcIndex);
 	// getPaca()->adjustHmtForNoOfSpinLocksHeld();
 }
-//=====================================================================
-static inline HvLpEvent_Rc HvCallEvent_signalLpEvent(struct HvLpEvent* event)
+
+static inline HvLpEvent_Rc HvCallEvent_signalLpEvent(struct HvLpEvent *event)
 {
 	u64 abs_addr;
 	HvLpEvent_Rc retVal;
+
 #ifdef DEBUG_SENDEVENT
-	printk("HvCallEvent_signalLpEvent: *event = %016lx\n ", (unsigned long)event);
+	printk("HvCallEvent_signalLpEvent: *event = %016lx\n ",
+			(unsigned long)event);
 #endif
-	abs_addr = virt_to_absolute( (unsigned long) event );
+	abs_addr = virt_to_absolute((unsigned long)event);
 	retVal = (HvLpEvent_Rc)HvCall1(HvCallEventSignalLpEvent, abs_addr);
 	// getPaca()->adjustHmtForNoOfSpinLocksHeld();
 	return retVal;
 }
-//=====================================================================
-static inline HvLpEvent_Rc  HvCallEvent_signalLpEventFast(HvLpIndex targetLp,
-					   HvLpEvent_Type type,
-					   u16 subtype,
-					   HvLpEvent_AckInd ackInd,
-					   HvLpEvent_AckType ackType,
-					   HvLpInstanceId sourceInstanceId,
-					   HvLpInstanceId targetInstanceId,
-					   u64 correlationToken,
-					   u64 eventData1,
-					   u64 eventData2,
-					   u64 eventData3,
-					   u64 eventData4,
-					   u64 eventData5)
+
+static inline HvLpEvent_Rc HvCallEvent_signalLpEventFast(HvLpIndex targetLp,
+		HvLpEvent_Type type, u16 subtype, HvLpEvent_AckInd ackInd,
+		HvLpEvent_AckType ackType, HvLpInstanceId sourceInstanceId,
+		HvLpInstanceId targetInstanceId, u64 correlationToken,
+		u64 eventData1, u64 eventData2, u64 eventData3,
+		u64 eventData4, u64 eventData5)
 {
 	HvLpEvent_Rc retVal;
 
 	// Pack the misc bits into a single Dword to pass to PLIC
-	union
-	{
+	union {
 		struct HvCallEvent_PackedParms	parms;
 		u64		dword;
 	} packed;
@@ -177,88 +153,84 @@ static inline HvLpEvent_Rc  HvCallEvent_
 	packed.parms.xTargetInstId	= targetInstanceId;
 
 	retVal = (HvLpEvent_Rc)HvCall7(HvCallEventSignalLpEventParms,
-				       packed.dword,
-				       correlationToken,
-				       eventData1,eventData2,
-				       eventData3,eventData4,
-				       eventData5);
+			packed.dword, correlationToken, eventData1,eventData2,
+			eventData3,eventData4, eventData5);
 	// getPaca()->adjustHmtForNoOfSpinLocksHeld();
 	return retVal;
 }
-//====================================================================
-static inline HvLpEvent_Rc	HvCallEvent_ackLpEvent(struct HvLpEvent* event)
+
+static inline HvLpEvent_Rc HvCallEvent_ackLpEvent(struct HvLpEvent *event)
 {
 	u64 abs_addr;
 	HvLpEvent_Rc retVal;
-	abs_addr = virt_to_absolute( (unsigned long) event );
 
+	abs_addr = virt_to_absolute((unsigned long)event);
 	retVal = (HvLpEvent_Rc)HvCall1(HvCallEventAckLpEvent, abs_addr);
 	// getPaca()->adjustHmtForNoOfSpinLocksHeld();
 	return retVal;
 }
-//====================================================================
-static inline HvLpEvent_Rc   HvCallEvent_cancelLpEvent(struct HvLpEvent* event)
+
+static inline HvLpEvent_Rc HvCallEvent_cancelLpEvent(struct HvLpEvent *event)
 {
 	u64 abs_addr;
 	HvLpEvent_Rc retVal;
-	abs_addr = virt_to_absolute( (unsigned long) event );
 
+	abs_addr = virt_to_absolute((unsigned long)event);
 	retVal = (HvLpEvent_Rc)HvCall1(HvCallEventCancelLpEvent, abs_addr);
 	// getPaca()->adjustHmtForNoOfSpinLocksHeld();
 	return retVal;
 }
-//===================================================================
-static inline HvLpInstanceId	HvCallEvent_getSourceLpInstanceId(HvLpIndex targetLp, HvLpEvent_Type type)
+
+static inline HvLpInstanceId HvCallEvent_getSourceLpInstanceId(
+		HvLpIndex targetLp, HvLpEvent_Type type)
 {
 	HvLpInstanceId retVal;	
-	retVal = HvCall2(HvCallEventGetSourceLpInstanceId,targetLp,type);
+
+	retVal = HvCall2(HvCallEventGetSourceLpInstanceId, targetLp, type);
 	// getPaca()->adjustHmtForNoOfSpinLocksHeld();
 	return retVal;
 }
-//===================================================================
-static inline HvLpInstanceId	HvCallEvent_getTargetLpInstanceId(HvLpIndex targetLp, HvLpEvent_Type type)
+
+static inline HvLpInstanceId HvCallEvent_getTargetLpInstanceId(
+		HvLpIndex targetLp, HvLpEvent_Type type)
 {
 	HvLpInstanceId retVal;	
-	retVal = HvCall2(HvCallEventGetTargetLpInstanceId,targetLp,type);
+
+	retVal = HvCall2(HvCallEventGetTargetLpInstanceId, targetLp, type);
 	// getPaca()->adjustHmtForNoOfSpinLocksHeld();
 	return retVal;
 }
-//===================================================================
-static inline void		HvCallEvent_openLpEventPath(HvLpIndex targetLp,
-					     HvLpEvent_Type type)
+
+static inline void HvCallEvent_openLpEventPath(HvLpIndex targetLp,
+		HvLpEvent_Type type)
 {
-	HvCall2(HvCallEventOpenLpEventPath,targetLp,type);
+	HvCall2(HvCallEventOpenLpEventPath, targetLp, type);
 	// getPaca()->adjustHmtForNoOfSpinLocksHeld();
 }
-//===================================================================
-static inline void		HvCallEvent_closeLpEventPath(HvLpIndex targetLp,
-					      HvLpEvent_Type type)
+
+static inline void HvCallEvent_closeLpEventPath(HvLpIndex targetLp,
+		HvLpEvent_Type type)
 {
-	HvCall2(HvCallEventCloseLpEventPath,targetLp,type);
+	HvCall2(HvCallEventCloseLpEventPath, targetLp, type);
 	// getPaca()->adjustHmtForNoOfSpinLocksHeld();
 }
-//===================================================================
-static inline HvLpDma_Rc	HvCallEvent_dmaBufList(HvLpEvent_Type type,
-					HvLpIndex remoteLp,
-					HvLpDma_Direction direction,
-					HvLpInstanceId localInstanceId,
-					HvLpInstanceId remoteInstanceId,
-					HvLpDma_AddressType localAddressType,
-					HvLpDma_AddressType remoteAddressType,
-					// Do these need to be converted to
-					// absolute addresses?
-					u64 localBufList,
-					u64 remoteBufList,
 
-					u32 transferLength)
+static inline HvLpDma_Rc HvCallEvent_dmaBufList(HvLpEvent_Type type,
+		HvLpIndex remoteLp, HvLpDma_Direction direction,
+		HvLpInstanceId localInstanceId,
+		HvLpInstanceId remoteInstanceId,
+		HvLpDma_AddressType localAddressType,
+		HvLpDma_AddressType remoteAddressType,
+		/* Do these need to be converted to absolute addresses? */
+		u64 localBufList, u64 remoteBufList, u32 transferLength)
 {
-	HvLpDma_Rc retVal;	
+	HvLpDma_Rc retVal;
 	// Pack the misc bits into a single Dword to pass to PLIC
-	union
-	{
+	union {
 		struct HvCallEvent_PackedDmaParms	parms;
 		u64		dword;
 	} packed;
+
 	packed.parms.xDirection		= direction;
 	packed.parms.xLocalAddrType	= localAddressType;
 	packed.parms.xRemoteAddrType	= remoteAddressType;
@@ -270,32 +242,27 @@ static inline HvLpDma_Rc	HvCallEvent_dma
 	packed.parms.xRemoteInstId	= remoteInstanceId;
 
 	retVal = (HvLpDma_Rc)HvCall4(HvCallEventDmaBufList,
-				     packed.dword,
-				     localBufList,
-				     remoteBufList,
-				     transferLength);
+			packed.dword, localBufList, remoteBufList,
+			transferLength);
 	// getPaca()->adjustHmtForNoOfSpinLocksHeld();
 	return retVal;
 }
-//=================================================================
-static inline HvLpDma_Rc	HvCallEvent_dmaSingle(HvLpEvent_Type type,
-				       HvLpIndex remoteLp,
-				       HvLpDma_Direction direction,
-				       HvLpInstanceId localInstanceId,
-				       HvLpInstanceId remoteInstanceId,
-				       HvLpDma_AddressType localAddressType,
-				       HvLpDma_AddressType remoteAddressType,
-				       u64 localAddrOrTce,
-				       u64 remoteAddrOrTce,
-				       u32 transferLength)
+
+static inline HvLpDma_Rc HvCallEvent_dmaSingle(HvLpEvent_Type type,
+		HvLpIndex remoteLp, HvLpDma_Direction direction,
+		HvLpInstanceId localInstanceId,
+		HvLpInstanceId remoteInstanceId,
+		HvLpDma_AddressType localAddressType,
+		HvLpDma_AddressType remoteAddressType,
+		u64 localAddrOrTce, u64 remoteAddrOrTce, u32 transferLength)
 {
-	HvLpDma_Rc retVal;	
+	HvLpDma_Rc retVal;
 	// Pack the misc bits into a single Dword to pass to PLIC
-	union
-	{
+	union {
 		struct HvCallEvent_PackedDmaParms	parms;
 		u64		dword;
 	} packed;
+
 	packed.parms.xDirection		= direction;
 	packed.parms.xLocalAddrType	= localAddressType;
 	packed.parms.xRemoteAddrType	= remoteAddressType;
@@ -307,29 +274,24 @@ static inline HvLpDma_Rc	HvCallEvent_dma
 	packed.parms.xRemoteInstId	= remoteInstanceId;
 
 	retVal = (HvLpDma_Rc)HvCall4(HvCallEventDmaSingle,
-				     packed.dword,
-				     localAddrOrTce,
-				     remoteAddrOrTce,
-				     transferLength);
+			packed.dword, localAddrOrTce, remoteAddrOrTce,
+			transferLength);
 	// getPaca()->adjustHmtForNoOfSpinLocksHeld();
 	return retVal;
 }
-//=================================================================
-static inline HvLpDma_Rc	HvCallEvent_dmaToSp(void* local, u32 remote, u32 length, HvLpDma_Direction dir)
+
+static inline HvLpDma_Rc HvCallEvent_dmaToSp(void* local, u32 remote,
+		u32 length, HvLpDma_Direction dir)
 {
 	u64 abs_addr;
 	HvLpDma_Rc retVal;
-	abs_addr = virt_to_absolute( (unsigned long) local );
-    
-	retVal = (HvLpDma_Rc)HvCall4(HvCallEventDmaToSp, 
-				     abs_addr,
-				     remote,
-				     length,
-				     dir);
+
+	abs_addr = virt_to_absolute((unsigned long)local);
+	retVal = (HvLpDma_Rc)HvCall4(HvCallEventDmaToSp, abs_addr, remote,
+			length, dir);
 	// getPaca()->adjustHmtForNoOfSpinLocksHeld();
 	return retVal;
 }
-//================================================================
 
-#endif // _HVCALLEVENT_H
 
+#endif /* _HVCALLEVENT_H */
diff -puN include/asm-ppc64/iSeries/HvCall.h~linus include/asm-ppc64/iSeries/HvCall.h
--- 25/include/asm-ppc64/iSeries/HvCall.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/HvCall.h	2004-01-19 22:17:24.000000000 -0800
@@ -23,25 +23,16 @@
 //	drive the hypervisor from the OS.
 //
 //===========================================================================
+#ifndef _HVCALL_H
+#define _HVCALL_H
 
 //-------------------------------------------------------------------
 // Standard Includes
 //-------------------------------------------------------------------
-#ifndef  _HVCALLSC_H
-#include "HvCallSc.h"
-#endif
-
-#ifndef  _HVTYPES_H
+#include <asm/iSeries/HvCallSc.h>
 #include <asm/iSeries/HvTypes.h>
-#endif
-
 #include <asm/paca.h>
 
-//-------------------------------------------------------------------
-// Constants
-//-------------------------------------------------------------------
-#ifndef _HVCALL_H
-#define _HVCALL_H
 /*
 enum HvCall_ReturnCode
 {
@@ -211,5 +202,4 @@ static inline void HvCall_setDebugBus(un
 	HvCall1(HvCallBaseSetDebugBus, val);
 }
 
-#endif // _HVCALL_H
-
+#endif /* _HVCALL_H */
diff -puN include/asm-ppc64/iSeries/HvCallHpt.h~linus include/asm-ppc64/iSeries/HvCallHpt.h
--- 25/include/asm-ppc64/iSeries/HvCallHpt.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/HvCallHpt.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,6 +16,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
+#ifndef _HVCALLHPT_H
+#define _HVCALLHPT_H
 
 //============================================================================
 //
@@ -24,30 +26,13 @@
 //
 //============================================================================
 
-//-------------------------------------------------------------------
-// Standard Includes
-//-------------------------------------------------------------------
-#ifndef  _HVCALLSC_H
-#include "HvCallSc.h"
-#endif
-
-#ifndef  _HVTYPES_H
+#include <asm/iSeries/HvCallSc.h>
 #include <asm/iSeries/HvTypes.h>
-#endif
-
-//-------------------------------------------------------------------
-// Other Includes
-//-------------------------------------------------------------------
-
-#ifndef _PPC_MMU_H
 #include <asm/mmu.h>
-#endif
 
 //-----------------------------------------------------------------------------
 // Constants
 //-----------------------------------------------------------------------------
-#ifndef _HVCALLHPT_H
-#define _HVCALLHPT_H
 
 #define HvCallHptGetHptAddress		HvCallHpt +  0
 #define HvCallHptGetHptPages		HvCallHpt +  1
@@ -139,5 +124,4 @@ static inline void		HvCallHpt_addValidat
 
 //=============================================================================
 
-#endif // _HVCALLHPT_H
-
+#endif /* _HVCALLHPT_H */
diff -puN include/asm-ppc64/iSeries/HvCallPci.h~linus include/asm-ppc64/iSeries/HvCallPci.h
--- 25/include/asm-ppc64/iSeries/HvCallPci.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/HvCallPci.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,6 +1,6 @@
 /************************************************************************/
 /* Provides the Hypervisor PCI calls for iSeries Linux Parition.        */
-/* Copyright (C) 20yy  <Wayne G Holm> <IBM Corporation>                 */
+/* Copyright (C) 2001  <Wayne G Holm> <IBM Corporation>                 */
 /*                                                                      */
 /* This program is free software; you can redistribute it and/or modify */
 /* it under the terms of the GNU General Public License as published by */
@@ -21,50 +21,25 @@
 /* Change Activity:                                                     */
 /*   Created, Jan 9, 2001                                               */
 /************************************************************************/
-//============================================================================
-//							 Header File Id
-// Name______________:	HvCallPci.H
-//
-// Description_______:
-//
-//	This file contains the "hypervisor call" interface which is used to
-//	drive the hypervisor from SLIC.
-//
-//============================================================================
-
-//-------------------------------------------------------------------
-// Forward declarations 
-//-------------------------------------------------------------------
-
-//-------------------------------------------------------------------
-// Standard Includes
-//-------------------------------------------------------------------
-#ifndef  _HVCALLSC_H
-#include "HvCallSc.h"
-#endif
-
-#ifndef  _HVTYPES_H
-#include <asm/iSeries/HvTypes.h>
-#endif
-
-//-------------------------------------------------------------------
-// Other Includes
-//-------------------------------------------------------------------
-
 
-//-----------------------------------------------------------------------------
-// Constants
-//-----------------------------------------------------------------------------
 #ifndef _HVCALLPCI_H
 #define _HVCALLPCI_H
 
-struct HvCallPci_DsaAddr { // make sure this struct size is 64-bits total
-	u16		busNumber;
-	u8		subBusNumber; 
-	u8		deviceId;     
+#include <asm/iSeries/HvCallSc.h>
+#include <asm/iSeries/HvTypes.h>
+
+/*
+ * DSA == Direct Select Address
+ * this struct must be 64 bits in total
+ */
+struct HvCallPci_DsaAddr {
+	u16		busNumber;		/* PHB index? */
+	u8		subBusNumber; 		/* PCI bus number? */
+	u8		deviceId;     		/* device and function? */
 	u8		barNumber;
 	u8		reserved[3];
 };
+
 union HvDsaMap {
 	u64	DsaAddr;
 	struct HvCallPci_DsaAddr Dsa;
@@ -75,12 +50,13 @@ struct HvCallPci_LoadReturn {
 	u64		value;
 };
 
-enum HvCallPci_DeviceType {HvCallPci_NodeDevice	= 1,
-                        HvCallPci_SpDevice	= 2,	
-                        HvCallPci_IopDevice     = 3,	
-                        HvCallPci_BridgeDevice	= 4,	
-                        HvCallPci_MultiFunctionDevice = 5,	
-                        HvCallPci_IoaDevice	= 6	
+enum HvCallPci_DeviceType {
+	HvCallPci_NodeDevice	= 1,
+	HvCallPci_SpDevice	= 2,	
+	HvCallPci_IopDevice     = 3,	
+	HvCallPci_BridgeDevice	= 4,	
+	HvCallPci_MultiFunctionDevice = 5,	
+	HvCallPci_IoaDevice	= 6	
 };
 
 
@@ -148,9 +124,9 @@ enum HvCallPci_VpdType {
 #define HvCallPciGetBusUnitInfo		HvCallPci + 50
 
 //============================================================================
-static inline u64	HvCallPci_configLoad8(u16 busNumber, u8 subBusNumber,
-					      u8 deviceId, u32 offset,
-					      u8 *value)
+static inline u64 HvCallPci_configLoad8(u16 busNumber, u8 subBusNumber,
+					u8 deviceId, u32 offset,
+					u8 *value)
 {
 	struct HvCallPci_DsaAddr dsa;
 	struct HvCallPci_LoadReturn retVal;
@@ -170,9 +146,9 @@ static inline u64	HvCallPci_configLoad8(
 	return retVal.rc;
 }
 //============================================================================
-static inline u64	HvCallPci_configLoad16(u16 busNumber, u8 subBusNumber,
-					      u8 deviceId, u32 offset,
-					      u16 *value)
+static inline u64 HvCallPci_configLoad16(u16 busNumber, u8 subBusNumber,
+					 u8 deviceId, u32 offset,
+					 u16 *value)
 {
 	struct HvCallPci_DsaAddr dsa;
 	struct HvCallPci_LoadReturn retVal;
@@ -694,4 +670,4 @@ static inline int HvCallPci_getBusAdapte
 	return xRetSize;
 }
 //============================================================================
-#endif // _HVCALLPCI_H
+#endif /* _HVCALLPCI_H */
diff -puN include/asm-ppc64/iSeries/HvCallSc.h~linus include/asm-ppc64/iSeries/HvCallSc.h
--- 25/include/asm-ppc64/iSeries/HvCallSc.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/HvCallSc.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,14 +16,11 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
-
-#ifndef  _HVTYPES_H
-#include <asm/iSeries/HvTypes.h>
-#endif
-
 #ifndef _HVCALLSC_H
 #define _HVCALLSC_H
 
+#include <asm/iSeries/HvTypes.h>
+
 #define HvCallBase		0x8000000000000000
 #define HvCallCc		0x8001000000000000
 #define HvCallCfg		0x8002000000000000
diff -puN include/asm-ppc64/iSeries/HvCallSm.h~linus include/asm-ppc64/iSeries/HvCallSm.h
--- 25/include/asm-ppc64/iSeries/HvCallSm.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/HvCallSm.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,6 +16,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
+#ifndef _HVCALLSM_H
+#define _HVCALLSM_H
 
 //============================================================================
 //
@@ -27,19 +29,12 @@
 //-------------------------------------------------------------------
 // Standard Includes
 //-------------------------------------------------------------------
-#ifndef  _HVCALLSC_H
-#include "HvCallSc.h"
-#endif
-
-#ifndef  _HVTYPES_H
+#include <asm/iSeries/HvCallSc.h>
 #include <asm/iSeries/HvTypes.h>
-#endif
 
 //-----------------------------------------------------------------------------
 // Constants
 //-----------------------------------------------------------------------------
-#ifndef _HVCALLSM_H
-#define _HVCALLSM_H
 
 #define HvCallSmGet64BitsOfAccessMap	HvCallSm  + 11
 
@@ -54,5 +49,4 @@ static inline u64		HvCallSm_get64BitsOfA
 	return retval;
 }
 //============================================================================
-#endif // _HVCALLSM_H
-
+#endif /* _HVCALLSM_H */
diff -puN include/asm-ppc64/iSeries/HvCallXm.h~linus include/asm-ppc64/iSeries/HvCallXm.h
--- 25/include/asm-ppc64/iSeries/HvCallXm.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/HvCallXm.h	2004-01-19 22:17:24.000000000 -0800
@@ -8,6 +8,8 @@
 //	drive the hypervisor from SLIC.
 //
 //============================================================================
+#ifndef _HVCALLXM_H
+#define _HVCALLXM_H
 
 //-------------------------------------------------------------------
 // Forward declarations 
@@ -16,24 +18,12 @@
 //-------------------------------------------------------------------
 // Standard Includes
 //-------------------------------------------------------------------
-#ifndef  _HVCALLSC_H
-#include "HvCallSc.h"
-#endif
-
-#ifndef  _HVTYPES_H
+#include <asm/iSeries/HvCallSc.h>
 #include <asm/iSeries/HvTypes.h>
-#endif
-
-//-------------------------------------------------------------------
-// Other Includes
-//-------------------------------------------------------------------
-
 
 //-----------------------------------------------------------------------------
 // Constants
 //-----------------------------------------------------------------------------
-#ifndef _HVCALLXM_H
-#define _HVCALLXM_H
 
 #define HvCallXmGetTceTableParms	HvCallXm +  0
 #define HvCallXmTestBus			HvCallXm +  1
@@ -102,5 +92,4 @@ static inline u64	HvCallXm_loadTod(void)
 }
 //=====================================================================================
 
-#endif // _HVCALLXM_H
-
+#endif /* _HVCALLXM_H */
diff -puN include/asm-ppc64/iSeries/HvLpConfig.h~linus include/asm-ppc64/iSeries/HvLpConfig.h
--- 25/include/asm-ppc64/iSeries/HvLpConfig.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/HvLpConfig.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,6 +16,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
+#ifndef _HVLPCONFIG_H
+#define _HVLPCONFIG_H
 
 //===========================================================================
 //
@@ -24,24 +26,10 @@
 //
 //===========================================================================
 
-#ifndef  _HVCALLCFG_H
-#include "HvCallCfg.h"
-#endif
-
-#ifndef  _HVTYPES_H
+#include <asm/iSeries/HvCallCfg.h>
 #include <asm/iSeries/HvTypes.h>
-#endif
-
-#ifndef  _ITLPNACA_H
 #include <asm/iSeries/ItLpNaca.h>
-#endif
-
-#ifndef  _LPARDATA_H
 #include <asm/iSeries/LparData.h>
-#endif
-
-#ifndef _HVLPCONFIG_H
-#define _HVLPCONFIG_H
 
 //-------------------------------------------------------------------
 // Constants
@@ -289,4 +277,4 @@ static inline HvLpIndex		HvLpConfig_getH
 }
 //================================================================
 
-#endif // _HVLPCONFIG_H
+#endif /* _HVLPCONFIG_H */
diff -puN include/asm-ppc64/iSeries/HvLpEvent.h~linus include/asm-ppc64/iSeries/HvLpEvent.h
--- 25/include/asm-ppc64/iSeries/HvLpEvent.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/HvLpEvent.h	2004-01-19 22:17:24.000000000 -0800
@@ -28,10 +28,7 @@
 #include <asm/types.h>
 #include <asm/ptrace.h>
 #include <asm/iSeries/HvTypes.h>
-#ifndef _HVCALLEVENT_H
 #include <asm/iSeries/HvCallEvent.h>
-#endif
-
 
 //=====================================================================
 //
diff -puN include/asm-ppc64/iSeries/HvReleaseData.h~linus include/asm-ppc64/iSeries/HvReleaseData.h
--- 25/include/asm-ppc64/iSeries/HvReleaseData.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/HvReleaseData.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,6 +16,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
+#ifndef _HVRELEASEDATA_H
+#define _HVRELEASEDATA_H
 
 //=============================================================================
 //
@@ -23,15 +25,7 @@
 //   release so that it can be changed in the future (ie, the virtual 
 //   address of the OS's NACA).
 //
-//-----------------------------------------------------------------------------
-// Standard Includes
-//-----------------------------------------------------------------------------
-#ifndef	_PPC64_TYPES_H
-#include	<asm/types.h>
-#endif
-
-#ifndef _HVRELEASEDATA_H
-#define _HVRELEASEDATA_H
+#include <asm/types.h>
 
 //=============================================================================
 //
@@ -67,4 +61,4 @@ struct	HvReleaseData
 	char	xRsvd3[20];		// Reserved			x2C-x3F
 };
 
-#endif // _HVRELEASEDATA_H
+#endif /* _HVRELEASEDATA_H */
diff -puN include/asm-ppc64/iSeries/HvTypes.h~linus include/asm-ppc64/iSeries/HvTypes.h
--- 25/include/asm-ppc64/iSeries/HvTypes.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/HvTypes.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,6 +16,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
+#ifndef _HVTYPES_H
+#define _HVTYPES_H
 
 //===========================================================================
 //                                                             Header File Id
@@ -29,13 +31,7 @@
 //
 //===========================================================================
 
-#ifndef _PPC_TYPES_H
-#include        <asm/types.h>
-#endif
-
-
-#ifndef _HVTYPES_H
-#define _HVTYPES_H
+#include <asm/types.h>
 
 //-------------------------------------------------------------------
 // Typedefs
@@ -124,4 +120,4 @@ struct HvLpBufferList {
 	u64 len;
 };
 
-#endif // _HVTYPES_H
+#endif /* _HVTYPES_H */
diff -puN include/asm-ppc64/iSeries/IoHriProcessorVpd.h~linus include/asm-ppc64/iSeries/IoHriProcessorVpd.h
--- 25/include/asm-ppc64/iSeries/IoHriProcessorVpd.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/IoHriProcessorVpd.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,18 +16,15 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
+#ifndef _IOHRIPROCESSORVPD_H
+#define _IOHRIPROCESSORVPD_H
 
 //===================================================================
 //
 //	This struct maps Processor Vpd that is DMAd to SLIC by CSP 
 //
 
-#ifndef	_TYPES_H
 #include <asm/types.h>
-#endif
-
-#ifndef _IOHRIPROCESSORVPD_H
-#define _IOHRIPROCESSORVPD_H
 
 struct IoHriProcessorVpd
 {
@@ -87,4 +84,5 @@ struct IoHriProcessorVpd
 
 	char xProcSrc[72];		// CSP format SRC		xB8-xFF
 };
-#endif // _IOHRIPROCESSORVPD_H
+
+#endif /* _IOHRIPROCESSORVPD_H */
diff -puN include/asm-ppc64/iSeries/iSeries_dma.h~linus include/asm-ppc64/iSeries/iSeries_dma.h
--- 25/include/asm-ppc64/iSeries/iSeries_dma.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/iSeries_dma.h	2004-01-19 22:17:24.000000000 -0800
@@ -21,9 +21,7 @@
 #define _ISERIES_DMA_H
 
 #include <asm/types.h>
-#ifndef __LINUX_SPINLOCK_H
 #include <linux/spinlock.h>
-#endif
 
 // NUM_TCE_LEVELS defines the largest contiguous block
 // of dma (tce) space we can get.  NUM_TCE_LEVELS = 10 
@@ -94,4 +92,4 @@ extern void              create_virtual_
 
 extern void		 create_pci_bus_tce_table( unsigned busNumber );
 
-#endif // _ISERIES_DMA_H
+#endif /* _ISERIES_DMA_H */
diff -puN include/asm-ppc64/iSeries/iSeries_io.h~linus include/asm-ppc64/iSeries/iSeries_io.h
--- 25/include/asm-ppc64/iSeries/iSeries_io.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/iSeries_io.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,8 +1,9 @@
+#ifndef _ISERIES_IO_H
+#define _ISERIES_IO_H
+
 #include <linux/config.h>
 
 #ifdef CONFIG_PPC_ISERIES
-#ifndef _ISERIES_IO_H
-#define _ISERIES_IO_H
 #include <linux/types.h>
 /************************************************************************/
 /* File iSeries_io.h created by Allan Trautman on Thu Dec 28 2000.      */
@@ -41,6 +42,5 @@ extern void* iSeries_memset_io(void *des
 extern void* iSeries_memcpy_toio(void *dest, void *source, size_t n);
 extern void* iSeries_memcpy_fromio(void *dest, void *source, size_t n);
 
-#endif /*  _ISERIES_IO_H         */
-#endif /*  CONFIG_PPC_ISERIES  */
-
+#endif /* CONFIG_PPC_ISERIES */
+#endif /* _ISERIES_IO_H */
diff -puN include/asm-ppc64/iSeries/iSeries_irq.h~linus include/asm-ppc64/iSeries/iSeries_irq.h
--- 25/include/asm-ppc64/iSeries/iSeries_irq.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/iSeries_irq.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,19 +1,11 @@
-
 #ifndef	__ISERIES_IRQ_H__
 #define	__ISERIES_IRQ_H__
 
-
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-unsigned int iSeries_startup_IRQ(unsigned int);
-void iSeries_shutdown_IRQ(unsigned int);
-void iSeries_enable_IRQ(unsigned int);
-void iSeries_disable_IRQ(unsigned int);
-void iSeries_end_IRQ(unsigned int);
 void iSeries_init_IRQ(void);
-void iSeries_init_irqMap(int);
 int  iSeries_allocate_IRQ(HvBusNumber, HvSubBusNumber, HvAgentId);
 int  iSeries_assign_IRQ(int, HvBusNumber, HvSubBusNumber, HvAgentId);
 void iSeries_activate_IRQs(void);
diff -puN include/asm-ppc64/iSeries/iSeries_pci.h~linus include/asm-ppc64/iSeries/iSeries_pci.h
--- 25/include/asm-ppc64/iSeries/iSeries_pci.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/iSeries_pci.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,10 +1,11 @@
 #ifndef _ISERIES_64_PCI_H
 #define _ISERIES_64_PCI_H
+
 /************************************************************************/
 /* File iSeries_pci.h created by Allan Trautman on Tue Feb 20, 2001.    */
 /************************************************************************/
 /* Define some useful macros for the iSeries pci routines.              */
-/* Copyright (C) 20yy  Allan H Trautman, IBM Corporation                */
+/* Copyright (C) 2001  Allan H Trautman, IBM Corporation                */
 /*                                                                      */
 /* This program is free software; you can redistribute it and/or modify */
 /* it under the terms of the GNU General Public License as published by */
@@ -28,77 +29,81 @@
 /*   Ported to ppc64, May 25, 2001                                      */
 /* End Change Activity                                                  */
 /************************************************************************/
+
 #include <asm/iSeries/HvCallPci.h>
 
 struct pci_dev;				/* For Forward Reference        */
 struct iSeries_Device_Node;
+
 /************************************************************************/
-/* Gets iSeries Bus, SubBus, of DevFn using pci_dev* structure          */
+/* Gets iSeries Bus, SubBus, DevFn using iSeries_Device_Node structure */
 /************************************************************************/
-#define ISERIES_BUS(DevPtr)    DevPtr->DsaAddr.busNumber
-#define ISERIES_SUBBUS(DevPtr) DevPtr->DsaAddr.subBusNumber
-#define ISERIES_DEVICE(DevPtr) DevPtr->DsaAddr.deviceId
-#define ISERIES_DEVFUN(DevPtr) DevPtr->DevFn
-#define ISERIES_DSA(DevPtr)   (*(u64*)&DevPtr->DsaAddr)
+
+#define ISERIES_BUS(DevPtr)	DevPtr->DsaAddr.Dsa.busNumber
+#define ISERIES_SUBBUS(DevPtr)	DevPtr->DsaAddr.Dsa.subBusNumber
+#define ISERIES_DEVICE(DevPtr)	DevPtr->DsaAddr.Dsa.deviceId
+#define ISERIES_DSA(DevPtr)	DevPtr->DsaAddr.DsaAddr
+#define ISERIES_DEVFUN(DevPtr)	DevPtr->DevFn
 #define ISERIES_DEVNODE(PciDev) ((struct iSeries_Device_Node*)PciDev->sysdata)
 
 #define EADsMaxAgents 7
-/************************************************************************************/
-/* Decodes Linux DevFn to iSeries DevFn, bridge device, or function.                */
-/* For Linux, see PCI_SLOT and PCI_FUNC in include/linux/pci.h                      */
-/************************************************************************************/
-#define ISERIES_DECODE_DEVFN(linuxdevfn)  (((linuxdevfn & 0x71) << 1) | (linuxdevfn & 0x07))
-#define ISERIES_DECODE_DEVICE(linuxdevfn) (((linuxdevfn & 0x38) >> 3) |(((linuxdevfn & 0x40) >> 2) + 0x10))
-#define ISERIES_DECODE_FUNCTION(linuxdevfn) (linuxdevfn & 0x07)
+
+/************************************************************************/
+/* Decodes Linux DevFn to iSeries DevFn, bridge device, or function.    */
+/* For Linux, see PCI_SLOT and PCI_FUNC in include/linux/pci.h          */
+/************************************************************************/
+
 #define ISERIES_PCI_AGENTID(idsel,func)	((idsel & 0x0F) << 4) | (func  & 0x07)
+#define ISERIES_ENCODE_DEVICE(agentid)	((0x10) | ((agentid&0x20)>>2) | (agentid&07))
 
 #define ISERIES_GET_DEVICE_FROM_SUBBUS(subbus)   ((subbus >> 5) & 0x7)
 #define ISERIES_GET_FUNCTION_FROM_SUBBUS(subbus) ((subbus >> 2) & 0x7)
 
-#define ISERIES_ENCODE_DEVICE(agentid)	((0x10) | ((agentid&0x20)>>2) | (agentid&07))
-/************************************************************************************/
-/* Converts Virtual Address to Real Address for Hypervisor calls                    */
-/************************************************************************************/
-#define REALADDR(virtaddr)  (0x8000000000000000 | (virt_to_absolute((u64)virtaddr) ))
+/*
+ * N.B. the ISERIES_DECODE_* macros are not used anywhere, and I think
+ * the 0x71 (at least) must be wrong - 0x78 maybe?  -- paulus.
+ */
+#define ISERIES_DECODE_DEVFN(linuxdevfn)  (((linuxdevfn & 0x71) << 1) | (linuxdevfn & 0x07))
+#define ISERIES_DECODE_DEVICE(linuxdevfn) (((linuxdevfn & 0x38) >> 3) |(((linuxdevfn & 0x40) >> 2) + 0x10))
+#define ISERIES_DECODE_FUNCTION(linuxdevfn) (linuxdevfn & 0x07)
 
-/************************************************************************************/
-/* Define TRUE and FALSE Values for Al                                              */
-/************************************************************************************/
-#ifndef TRUE
-#define TRUE 1
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
+/************************************************************************/
+/* Converts Virtual Address to Real Address for Hypervisor calls        */
+/************************************************************************/
+
+#define REALADDR(virtaddr)  (0x8000000000000000 | (virt_to_absolute((u64)virtaddr) ))
 
 /************************************************************************/
 /* iSeries Device Information                                           */
 /************************************************************************/
+
 struct iSeries_Device_Node {
-	struct list_head Device_List;    /* Must be first for cast to wo*/
-	struct pci_dev*  PciDev;         /* Pointer to pci_dev structure*/
-        struct HvCallPci_DsaAddr DsaAddr;/* Direct Select Address       */
-                                         /* busNumber,subBusNumber,     */ 
-	                                 /* deviceId, barNumber         */
-	HvAgentId        AgentId;	 /* Hypervisor DevFn            */
-	int              DevFn;          /* Linux devfn                 */
-	int              BarOffset;
-	int              Irq;            /* Assigned IRQ                */
-	int              ReturnCode;	 /* Return Code Holder          */
-	int              IoRetry;        /* Current Retry Count         */
-	int              Flags;          /* Possible flags(disable/bist)*/
-	u16              Vendor;         /* Vendor ID                   */
-	u8               LogicalSlot;    /* Hv Slot Index for Tces      */
-	struct TceTable* DevTceTable;    /* Device TCE Table            */ 
-	u8               PhbId;          /* Phb Card is on.             */
-	u16              Board;          /* Board Number                */
-	u8               FrameId;	 /* iSeries spcn Frame Id       */
-	char             CardLocation[4];/* Char format of planar vpd   */
-	char             Location[20];   /* Frame  1, Card C10          */
+	struct list_head Device_List;
+	struct pci_dev* PciDev;         /* Pointer to pci_dev structure*/
+        union HvDsaMap	DsaAddr;	/* Direct Select Address       */
+                                        /* busNumber,subBusNumber,     */ 
+	                                /* deviceId, barNumber         */
+	HvAgentId       AgentId;	/* Hypervisor DevFn            */
+	int             DevFn;          /* Linux devfn                 */
+	int             BarOffset;
+	int             Irq;            /* Assigned IRQ                */
+	int             ReturnCode;	/* Return Code Holder          */
+	int             IoRetry;        /* Current Retry Count         */
+	int             Flags;          /* Possible flags(disable/bist)*/
+	u16             Vendor;         /* Vendor ID                   */
+	u8              LogicalSlot;    /* Hv Slot Index for Tces      */
+	struct TceTable* DevTceTable;   /* Device TCE Table            */ 
+	u8              PhbId;          /* Phb Card is on.             */
+	u16             Board;          /* Board Number                */
+	u8              FrameId;	/* iSeries spcn Frame Id       */
+	char            CardLocation[4];/* Char format of planar vpd   */
+	char            Location[20];   /* Frame  1, Card C10          */
 };
+
 /************************************************************************/
 /* Location Data extracted from the VPD list and device info.           */
 /************************************************************************/
+
 struct LocationDataStruct { 	/* Location data structure for device  */
 	u16  Bus;               /* iSeries Bus Number              0x00*/
 	u16  Board;             /* iSeries Board                   0x02*/
@@ -108,17 +113,14 @@ struct LocationDataStruct { 	/* Location
 	u8   Card;
 	char CardLocation[4];      
 };
+
 typedef struct LocationDataStruct  LocationData;
 #define LOCATION_DATA_SIZE      48
-/************************************************************************/
-/* Flight Recorder tracing                                              */
-/************************************************************************/
-extern int  iSeries_Set_PciTraceFlag(int TraceFlag);
-extern int  iSeries_Get_PciTraceFlag(void);
 
 /************************************************************************/
 /* Functions                                                            */
 /************************************************************************/
+
 extern LocationData* iSeries_GetLocationData(struct pci_dev* PciDev);
 extern int           iSeries_Device_Information(struct pci_dev*,char*, int);
 extern void          iSeries_Get_Location_Code(struct iSeries_Device_Node*);
diff -puN include/asm-ppc64/iSeries/iSeries_proc.h~linus include/asm-ppc64/iSeries/iSeries_proc.h
--- 25/include/asm-ppc64/iSeries/iSeries_proc.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/iSeries_proc.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,22 +16,15 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
-
-
-/* Change Activity: */
-/* End Change Activity */
-
 #ifndef _ISERIES_PROC_H
 #define _ISERIES_PROC_H
 
 #include <linux/proc_fs.h>
 
 extern void iSeries_proc_early_init(void);
-extern void iSeries_proc_create(void);
 
 typedef void (*iSeriesProcFunction)(struct proc_dir_entry *iSeries_proc);
 
 extern void iSeries_proc_callback(iSeriesProcFunction initFunction);
 
 #endif /* _iSeries_PROC_H */
-
diff -puN include/asm-ppc64/iSeries/ItExtVpdPanel.h~linus include/asm-ppc64/iSeries/ItExtVpdPanel.h
--- 25/include/asm-ppc64/iSeries/ItExtVpdPanel.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/ItExtVpdPanel.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,6 +16,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
+#ifndef _ITEXTVPDPANEL_H
+#define _ITEXTVPDPANEL_H
 
 /*
  *
@@ -31,12 +33,8 @@
  * Standard Includes
  *------------------------------------------------------------------- 
 */
-#ifndef	_PPC_TYPES_H
-#include	<asm/types.h>
-#endif
+#include <asm/types.h>
 
-#ifndef _ITEXTVPDPANEL_H
-#define _ITEXTVPDPANEL_H
 struct ItExtVpdPanel
 {
   // Definition of the Extended Vpd On Panel Data Area
diff -puN include/asm-ppc64/iSeries/ItIplParmsReal.h~linus include/asm-ppc64/iSeries/ItIplParmsReal.h
--- 25/include/asm-ppc64/iSeries/ItIplParmsReal.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/ItIplParmsReal.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,6 +16,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
+#ifndef _ITIPLPARMSREAL_H
+#define _ITIPLPARMSREAL_H
 
 //==============================================================================
 //
@@ -31,12 +33,7 @@
 //-------------------------------------------------------------------
 // Standard Includes
 //-------------------------------------------------------------------
-#ifndef	_PPC_TYPES_H
-#include	<asm/types.h>
-#endif
-
-#ifndef _ITIPLPARMSREAL_H
-#define _ITIPLPARMSREAL_H
+#include <asm/types.h>
 
 struct ItIplParmsReal
 {
@@ -75,4 +72,5 @@ struct ItIplParmsReal
 	u64	xRsvd12;		// Reserved				x30-x37
 	u64	xRsvd13;		// Reserved				x38-x3F
 };
-#endif // _ITIPLPARMSREAL_H
+
+#endif /* _ITIPLPARMSREAL_H */
diff -puN include/asm-ppc64/iSeries/ItLpNaca.h~linus include/asm-ppc64/iSeries/ItLpNaca.h
--- 25/include/asm-ppc64/iSeries/ItLpNaca.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/ItLpNaca.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,6 +16,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
+#ifndef _ITLPNACA_H
+#define _ITLPNACA_H
 
 //=============================================================================
 //
@@ -24,10 +26,6 @@
 //
 //=============================================================================
 
-
-#ifndef _ITLPNACA_H
-#define _ITLPNACA_H
-
 struct ItLpNaca
 {
 //=============================================================================
@@ -87,4 +85,4 @@ struct ItLpNaca
 
 //=============================================================================
 
-#endif // _ITLPNACA_H
+#endif /* _ITLPNACA_H */
diff -puN include/asm-ppc64/iSeries/ItLpPaca.h~linus include/asm-ppc64/iSeries/ItLpPaca.h
--- 25/include/asm-ppc64/iSeries/ItLpPaca.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/ItLpPaca.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,6 +16,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
+#ifndef _ITLPPACA_H
+#define _ITLPPACA_H
 
 //=============================================================================
 //                                   
@@ -24,13 +26,7 @@
 //    
 //
 //----------------------------------------------------------------------------
-#ifndef  _PPC_TYPES_H
 #include <asm/types.h>
-#endif
-
-#ifndef _ITLPPACA_H
-#define _ITLPPACA_H
-
 
 struct ItLpPaca
 {
@@ -110,7 +106,10 @@ struct ItLpPaca
 	u64     xPDCSavedSPRG1;         // Saved SPRG1 for PMC int      x68-x6F
 	u64     xPDCSavedSRR0;          // Saved SRR0 for PMC int       x70-x77
 	volatile u32 xVirtualDecr;	// Virtual DECR for shared procsx78-x7B
-	u32	    xRsvd2_2;		// Reserved			x7C-x7F
+	u16     xSLBCount;              // # of SLBs to maintain        x7C-x7D
+	u8      xIdle;                  // Indicate OS is idle          x7E
+	u8      xRsvd2_2;               // Reserved                     x7F
+
 
 //=============================================================================
 // CACHE_LINE_3 0x0100 - 0x007F: This line is shared with other processors
@@ -131,4 +130,5 @@ struct ItLpPaca
 
 
 };
-#endif // _ITLPPACA_H
+
+#endif /* _ITLPPACA_H */
diff -puN include/asm-ppc64/iSeries/ItLpQueue.h~linus include/asm-ppc64/iSeries/ItLpQueue.h
--- 25/include/asm-ppc64/iSeries/ItLpQueue.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/ItLpQueue.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,6 +16,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
+#ifndef _ITLPQUEUE_H
+#define _ITLPQUEUE_H
 
 //=============================================================================
 //
@@ -24,18 +26,11 @@
 //	events to an LP.  
 //    
 
-#ifndef _PPC_TYPES_H
 #include <asm/types.h>
-#endif
 #include <asm/ptrace.h>
 
-
 struct HvLpEvent;
 
-
-#ifndef _ITLPQUEUE_H
-#define _ITLPQUEUE_H
-
 #define ITMaxLpQueues 8
 
 #define NotUsed		0	// Queue will not be used by PLIC
@@ -94,6 +89,4 @@ static __inline__ void process_iSeries_e
 	: : : "r0", "r3" );	
 }
 
-
-//=============================================================================
-#endif // _ITLPQUEUE_H
+#endif /* _ITLPQUEUE_H */
diff -puN include/asm-ppc64/iSeries/ItLpRegSave.h~linus include/asm-ppc64/iSeries/ItLpRegSave.h
--- 25/include/asm-ppc64/iSeries/ItLpRegSave.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/ItLpRegSave.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,6 +16,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
+#ifndef _ITLPREGSAVE_H
+#define _ITLPREGSAVE_H
 
 //=====================================================================================
 //
@@ -24,9 +26,6 @@
 //    
 //
 
-#ifndef _ITLPREGSAVE_H
-#define _ITLPREGSAVE_H
-
 struct ItLpRegSave
 {
 	u32	xDesc;		// Eye catcher  "LpRS" ebcdic	000-003
@@ -84,4 +83,5 @@ struct ItLpRegSave
 
 	u8	xRsvd3[176];	// Reserved			350-3FF
 };
-#endif // _ITLPREGSAVE_H
+
+#endif /* _ITLPREGSAVE_H */
diff -puN include/asm-ppc64/iSeries/ItVpdAreas.h~linus include/asm-ppc64/iSeries/ItVpdAreas.h
--- 25/include/asm-ppc64/iSeries/ItVpdAreas.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/ItVpdAreas.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,6 +16,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
+#ifndef _ITVPDAREAS_H
+#define _ITVPDAREAS_H
 
 //=====================================================================================
 //
@@ -23,13 +25,7 @@
 //	the OS from PLIC (most of which start from the SP).
 //
 
-#ifndef _PPC_TYPES_H
-#include        <asm/types.h>
-#endif
-
-
-#ifndef _ITVPDAREAS_H
-#define _ITVPDAREAS_H
+#include <asm/types.h>
 
 // VPD Entry index is carved in stone - cannot be changed (easily).
 #define ItVpdCecVpd				   0
@@ -97,4 +93,4 @@ struct	ItVpdAreas
 	void * xSlicVpdAdrs[ItVpdMaxEntries];// Array of VPD buffers	130-1EF
 };
 
-#endif // _ITVPDAREAS_H
+#endif /* _ITVPDAREAS_H */
diff -puN include/asm-ppc64/iSeries/LparMap.h~linus include/asm-ppc64/iSeries/LparMap.h
--- 25/include/asm-ppc64/iSeries/LparMap.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/LparMap.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,14 +16,11 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
-
-#ifndef	_PPC_TYPES_H
-#include	<asm/types.h>
-#endif
-
 #ifndef _LPARMAP_H
 #define _LPARMAP_H
 
+#include <asm/types.h>
+
 /* The iSeries hypervisor will set up mapping for one or more 
  * ESID/VSID pairs (in SLB/segment registers) and will set up
  * mappings of one or more ranges of pages to VAs.
diff -puN include/asm-ppc64/iSeries/mf.h~linus include/asm-ppc64/iSeries/mf.h
--- 25/include/asm-ppc64/iSeries/mf.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/iSeries/mf.h	2004-01-19 22:17:24.000000000 -0800
@@ -23,61 +23,50 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
-
 #ifndef MF_H_INCLUDED
 #define MF_H_INCLUDED
 
+#include <linux/proc_fs.h>
+
 #include <asm/iSeries/HvTypes.h>
 #include <asm/iSeries/HvLpEvent.h>
 
 struct rtc_time;
 
-typedef void (*MFCompleteHandler)( void * clientToken, int returnCode );
-
-extern void mf_allocateLpEvents( HvLpIndex targetLp,
-				 HvLpEvent_Type type,
-				 unsigned size,
-				 unsigned amount,
-				 MFCompleteHandler hdlr,
-				 void * userToken );
-
-extern void mf_deallocateLpEvents( HvLpIndex targetLp,
-				   HvLpEvent_Type type,
-				   unsigned count,
-				   MFCompleteHandler hdlr,
-				   void * userToken );
-
-extern void mf_powerOff( void );
-
-extern void mf_reboot( void );
-
-extern void mf_displaySrc( u32 word );
-extern void mf_displayProgress( u16 value );
+typedef void (*MFCompleteHandler)(void *clientToken, int returnCode);
 
-extern void mf_clearSrc( void );
+extern void mf_allocateLpEvents(HvLpIndex targetLp, HvLpEvent_Type type,
+		unsigned size, unsigned amount, MFCompleteHandler hdlr,
+		void *userToken);
+extern void mf_deallocateLpEvents(HvLpIndex targetLp, HvLpEvent_Type type,
+		unsigned count, MFCompleteHandler hdlr, void *userToken);
+
+extern void mf_powerOff(void);
+extern void mf_reboot(void);
+
+extern void mf_displaySrc(u32 word);
+extern void mf_displayProgress(u16 value);
+extern void mf_clearSrc(void);
 
-extern void mf_init( void );
+extern void mf_init(void);
 
 extern void mf_setSide(char side);
-
 extern char mf_getSide(void);
 
 extern void mf_setCmdLine(const char *cmdline, int size, u64 side);
-
 extern int  mf_getCmdLine(char *cmdline, int *size, u64 side);
 
 extern void mf_getSrcHistory(char *buffer, int size);
 
-extern int mf_setVmlinuxChunk(const char *buffer, int size, int offset, u64 side);
-
+extern int mf_setVmlinuxChunk(const char *buffer, int size, int offset,
+		u64 side);
 extern int mf_getVmlinuxChunk(char *buffer, int *size, int offset, u64 side);
 
 extern int mf_setRtcTime(unsigned long time);
-
 extern int mf_getRtcTime(unsigned long *time);
-
 extern int mf_getRtc( struct rtc_time * tm );
-
 extern int mf_setRtc( struct rtc_time * tm );
 
+extern void mf_proc_init(struct proc_dir_entry *iSeries_proc);
+
 #endif /* MF_H_INCLUDED */
diff -puN -L include/asm-ppc64/iSeries/mf_proc.h include/asm-ppc64/iSeries/mf_proc.h~linus /dev/null
--- 25/include/asm-ppc64/iSeries/mf_proc.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,33 +0,0 @@
-/*
- * mf_proc.h
- * Copyright (C) 2001  Kyle A. Lucke IBM Corporation
- * 
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- */
-
-
-/* Change Activity: */
-/* End Change Activity */
-
-#ifndef _MF_PROC_H
-#define _MF_PROC_H
-
-#include <linux/proc_fs.h>
-
-void mf_proc_init(struct proc_dir_entry *iSeries_proc);
-
-
-#endif /* _MF_PROC_H */
-
diff -puN -L include/asm-ppc64/iSeries/veth-proc.h include/asm-ppc64/iSeries/veth-proc.h~linus /dev/null
--- 25/include/asm-ppc64/iSeries/veth-proc.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,32 +0,0 @@
-/*
- * veth-proc.h
- * Copyright (C) 2001  Kyle A. Lucke IBM Corporation
- * 
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- */
-
-
-/* Change Activity: */
-/* End Change Activity */
-
-#ifndef _VETH_PROC_H
-#define _VETH_PROC_H
-
-#include <linux/proc_fs.h>
-
-void veth_proc_init(struct proc_dir_entry *iSeries_proc);
-
-#endif /* _VETH-PROC_H */
-
diff -puN /dev/null include/asm-ppc64/iSeries/vio.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/asm-ppc64/iSeries/vio.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,129 @@
+/* -*- linux-c -*-
+ *  drivers/char/vio.h
+ *
+ *  iSeries Virtual I/O Message Path header
+ *
+ *  Authors: Dave Boutcher <boutcher@us.ibm.com>
+ *           Ryan Arnold <ryanarn@us.ibm.com>
+ *           Colin Devilbiss <devilbis@us.ibm.com>
+ *
+ * (C) Copyright 2000 IBM Corporation
+ * 
+ * This header file is used by the iSeries virtual I/O device
+ * drivers.  It defines the interfaces to the common functions
+ * (implemented in drivers/char/viopath.h) as well as defining
+ * common functions and structures.  Currently (at the time I 
+ * wrote this comment) the iSeries virtual I/O device drivers
+ * that use this are 
+ *   drivers/block/viodasd.c 
+ *   drivers/char/viocons.c
+ *   drivers/char/viotape.c
+ *   drivers/cdrom/viocd.c
+ *
+ * The iSeries virtual ethernet support (veth.c) uses a whole
+ * different set of functions.
+ * 
+ * This program is free software;  you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) anyu later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of 
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.  
+ *
+ * You should have received a copy of the GNU General Public 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 _VIO_H
+#define _VIO_H
+
+#include <asm/iSeries/HvTypes.h>
+#include <asm/iSeries/HvLpEvent.h>
+
+/* iSeries virtual I/O events use the subtype field in
+ * HvLpEvent to figure out what kind of vio event is coming
+ * in.  We use a table to route these, and this defines
+ * the maximum number of distinct subtypes
+ */
+#define VIO_MAX_SUBTYPES 7
+
+/* Each subtype can register a handler to process their events.
+ * The handler must have this interface.
+ */
+typedef void (vio_event_handler_t) (struct HvLpEvent * event);
+
+int viopath_open(HvLpIndex remoteLp, int subtype, int numReq);
+int viopath_close(HvLpIndex remoteLp, int subtype, int numReq);
+int vio_setHandler(int subtype, vio_event_handler_t * beh);
+int vio_clearHandler(int subtype);
+int viopath_isactive(HvLpIndex lp);
+HvLpInstanceId viopath_sourceinst(HvLpIndex lp);
+HvLpInstanceId viopath_targetinst(HvLpIndex lp);
+void vio_set_hostlp(void);
+void *vio_get_event_buffer(int subtype);
+void vio_free_event_buffer(int subtype, void *buffer);
+
+extern HvLpIndex viopath_hostLp;
+extern HvLpIndex viopath_ourLp;
+
+#define VIO_MESSAGE "iSeries virtual I/O: "
+#define KERN_DEBUG_VIO KERN_DEBUG VIO_MESSAGE
+#define KERN_INFO_VIO KERN_INFO VIO_MESSAGE
+#define KERN_WARNING_VIO KERN_WARNING VIO_MESSAGE
+
+#define VIOCHAR_MAX_DATA 200
+
+#define VIOMAJOR_SUBTYPE_MASK 0xff00
+#define VIOMINOR_SUBTYPE_MASK 0x00ff
+#define VIOMAJOR_SUBTYPE_SHIFT 8
+
+#define VIOVERSION            0x0101
+
+/*
+This is the general structure for VIO errors; each module should have a table
+of them, and each table should be terminated by an entry of { 0, 0, NULL }.
+Then, to find a specific error message, a module should pass its local table
+and the return code.
+*/
+struct vio_error_entry {
+	u16 rc;
+	int errno;
+	const char *msg;
+};
+const struct vio_error_entry *vio_lookup_rc(const struct vio_error_entry
+					    *local_table, u16 rc);
+
+enum viosubtypes {
+	viomajorsubtype_monitor = 0x0100,
+	viomajorsubtype_blockio = 0x0200,
+	viomajorsubtype_chario = 0x0300,
+	viomajorsubtype_config = 0x0400,
+	viomajorsubtype_cdio = 0x0500,
+	viomajorsubtype_tape = 0x0600
+};
+
+
+enum vioconfigsubtype {
+	vioconfigget = 0x0001,
+};
+
+enum viorc {
+	viorc_good = 0x0000,
+	viorc_noConnection = 0x0001,
+	viorc_noReceiver = 0x0002,
+	viorc_noBufferAvailable = 0x0003,
+	viorc_invalidMessageType = 0x0004,
+	viorc_invalidRange = 0x0201,
+	viorc_invalidToken = 0x0202,
+	viorc_DMAError = 0x0203,
+	viorc_useError = 0x0204,
+	viorc_releaseError = 0x0205,
+	viorc_invalidDisk = 0x0206,
+	viorc_openRejected = 0x0301
+};
+
+#endif /* _VIO_H */
diff -puN include/asm-ppc64/machdep.h~linus include/asm-ppc64/machdep.h
--- 25/include/asm-ppc64/machdep.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/machdep.h	2004-01-19 22:17:24.000000000 -0800
@@ -89,6 +89,12 @@ struct machdep_calls {
 	unsigned char	(*udbg_getc)(void);
 	int		(*udbg_getc_poll)(void);
 
+	/* Interface for platform error logging */
+	void 		(*log_error)(char *buf, unsigned int err_type, int fatal);
+
+	ssize_t		(*nvram_write)(char *buf, size_t count, loff_t *index);
+	ssize_t		(*nvram_read)(char *buf, size_t count, loff_t *index);	
+
 #ifdef CONFIG_SMP
 	/* functions for dealing with other cpus */
 	struct smp_ops_t smp_ops;
@@ -113,5 +119,11 @@ void ppc64_attention_msg(unsigned int sr
 /* Print a dump progress message. */
 void ppc64_dump_msg(unsigned int src, const char *msg);
 
+static inline void log_error(char *buf, unsigned int err_type, int fatal)
+{
+	if (ppc_md.log_error)
+		ppc_md.log_error(buf, err_type, fatal);
+}
+
 #endif /* _PPC64_MACHDEP_H */
 #endif /* __KERNEL__ */
diff -puN include/asm-ppc64/memory.h~linus include/asm-ppc64/memory.h
--- 25/include/asm-ppc64/memory.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/memory.h	2004-01-19 22:17:24.000000000 -0800
@@ -42,23 +42,28 @@ static inline void isync(void)
 #endif
 
 /* Macros for adjusting thread priority (hardware multi-threading) */
-
-#if defined(CONFIG_PPC_ISERIES) || defined(CONFIG_HMT)
+#define HMT_very_low()    asm volatile("or 31,31,31   # very low priority")
 #define HMT_low()	asm volatile("or 1,1,1		# low priority")
+#define HMT_medium_low()  asm volatile("or 6,6,6      # medium low priority")
 #define HMT_medium()	asm volatile("or 2,2,2		# medium priority")
+#define HMT_medium_high() asm volatile("or 5,5,5      # medium high priority")
 #define HMT_high()	asm volatile("or 3,3,3		# high priority")
 
+#define HMT_VERY_LOW    "\tor   31,31,31        # very low priority\n"
 #define HMT_LOW		"\tor	1,1,1		# low priority\n"
+#define HMT_MEDIUM_LOW  "\tor   6,6,6           # medium low priority\n"
 #define HMT_MEDIUM	"\tor	2,2,2		# medium priority\n"
+#define HMT_MEDIUM_HIGH "\tor   5,5,5           # medium high priority\n"
 #define HMT_HIGH	"\tor	3,3,3		# high priority\n"
-#else
-#define HMT_low()	do { } while(0)
-#define HMT_medium()	do { } while(0)
-#define HMT_high()	do { } while(0)
 
-#define HMT_LOW
-#define HMT_MEDIUM
-#define HMT_HIGH
-#endif
+/* 
+ * Various operational modes for SMT
+ * Off    : never run threaded
+ * On     : always run threaded
+ * Dynamic: Allow the system to switch modes as needed
+ */
+#define SMT_OFF      0
+#define SMT_ON       1
+#define SMT_DYNAMIC  2
 
 #endif
diff -puN include/asm-ppc64/mmu_context.h~linus include/asm-ppc64/mmu_context.h
--- 25/include/asm-ppc64/mmu_context.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/mmu_context.h	2004-01-19 22:17:24.000000000 -0800
@@ -6,6 +6,7 @@
 #include <linux/mm.h>	
 #include <asm/mmu.h>	
 #include <asm/ppcdebug.h>	
+#include <asm/cputable.h>
 
 /*
  * Copyright (C) 2001 PPC 64 Team, IBM Corp
@@ -139,10 +140,16 @@ extern void flush_stab(struct task_struc
  * switch_mm is the entry point called from the architecture independent
  * code in kernel/sched.c
  */
-static inline void
-switch_mm(struct mm_struct *prev, struct mm_struct *next,
-	  struct task_struct *tsk)
+static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
+			     struct task_struct *tsk)
 {
+#ifdef CONFIG_ALTIVEC
+	asm volatile (
+ BEGIN_FTR_SECTION
+	"dssall;\n"
+ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
+	 : : );
+#endif /* CONFIG_ALTIVEC */
 	flush_stab(tsk, next);
 	cpu_set(smp_processor_id(), next->cpu_vm_mask);
 }
diff -puN include/asm-ppc64/mmu.h~linus include/asm-ppc64/mmu.h
--- 25/include/asm-ppc64/mmu.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/mmu.h	2004-01-19 22:17:24.000000000 -0800
@@ -13,6 +13,8 @@
 #ifndef _PPC64_MMU_H_
 #define _PPC64_MMU_H_
 
+#include <asm/page.h>
+
 #ifndef __ASSEMBLY__
 
 /* Default "unsigned long" context */
@@ -202,29 +204,59 @@ static inline unsigned long hpt_hash(uns
 	return (vsid & 0x7fffffffff) ^ page;
 }
 
-static inline void _tlbie(unsigned long va, int large)
+static inline void __tlbie(unsigned long va, int large)
 {
-	asm volatile("ptesync": : :"memory");
+	/* clear top 16 bits, non SLS segment */
+	va &= ~(0xffffULL << 48);
 
-	if (large) {
-		asm volatile("clrldi	%0,%0,16\n\
-			      tlbie	%0,1" : : "r"(va) : "memory");
-	} else {
-		asm volatile("clrldi	%0,%0,16\n\
-			      tlbie	%0,0" : : "r"(va) : "memory");
-	}
+	if (large)
+		asm volatile("tlbie %0,1" : : "r"(va) : "memory");
+	else
+		asm volatile("tlbie %0,0" : : "r"(va) : "memory");
+}
 
+static inline void tlbie(unsigned long va, int large)
+{
+	asm volatile("ptesync": : :"memory");
+	__tlbie(va, large);
 	asm volatile("eieio; tlbsync; ptesync": : :"memory");
 }
 
-static inline void _tlbiel(unsigned long va)
+static inline void __tlbiel(unsigned long va)
+{
+	/* clear top 16 bits, non SLS segment */
+	va &= ~(0xffffULL << 48);
+
+	/* 
+	 * Thanks to Alan Modra we are now able to use machine specific 
+	 * assembly instructions (like tlbiel) by using the gas -many flag.
+	 * However we have to support older toolchains so for the moment 
+	 * we hardwire it.
+	 */
+#if 0
+	asm volatile("tlbiel %0" : : "r"(va) : "memory");
+#else
+	asm volatile(".long 0x7c000224 | (%0 << 11)" : : "r"(va) : "memory");
+#endif
+}
+
+static inline void tlbiel(unsigned long va)
 {
 	asm volatile("ptesync": : :"memory");
-	asm volatile("clrldi	%0,%0,16\n\
-		      tlbiel	%0" : : "r"(va) : "memory");
+	__tlbiel(va);
 	asm volatile("ptesync": : :"memory");
 }
 
+/*
+ * Handle a fault by adding an HPTE. If the address can't be determined
+ * to be valid via Linux page tables, return 1. If handled return 0
+ */
+extern int __hash_page(unsigned long ea, unsigned long access,
+		       unsigned long vsid, pte_t *ptep, unsigned long trap,
+		       int local);
+
+extern void htab_finish_init(void);
+
 #endif /* __ASSEMBLY__ */
 
 /*
diff -puN include/asm-ppc64/naca.h~linus include/asm-ppc64/naca.h
--- 25/include/asm-ppc64/naca.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/naca.h	2004-01-19 22:17:24.000000000 -0800
@@ -37,7 +37,12 @@ struct naca_struct {
 	u32 dCacheL1LinesPerPage;	/* L1 d-cache lines / page   0x64 */
 	u32 iCacheL1LogLineSize;	/* L1 i-cache line size Log2 0x68 */
 	u32 iCacheL1LinesPerPage;	/* L1 i-cache lines / page   0x6c */
-	u64 resv0[2];                   /* Reserved           0x70 - 0x7F */
+	u64 smt_snooze_delay;           /* Delay (in usec) before    0x70 */
+                                        /* entering ST mode               */
+	u8  smt_state;                  /* 0 = SMT off               0x78 */
+	                                /* 1 = SMT on                     */
+	                                /* 2 = SMT dynamic                */
+	u8  resv0[7];                   /* Reserved           0x70 - 0x7F */
 };
 
 extern struct naca_struct *naca;
diff -puN include/asm-ppc64/nvram.h~linus include/asm-ppc64/nvram.h
--- 25/include/asm-ppc64/nvram.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/nvram.h	2004-01-19 22:17:24.000000000 -0800
@@ -11,6 +11,12 @@
 #ifndef _PPC64_NVRAM_H
 #define _PPC64_NVRAM_H
 
+#define NVRW_CNT 0x20
+#define NVRAM_HEADER_LEN 16 /* sizeof(struct nvram_header) */
+#define NVRAM_BLOCK_LEN 16
+#define NVRAM_MAX_REQ (2080/NVRAM_BLOCK_LEN)
+#define NVRAM_MIN_REQ (1056/NVRAM_BLOCK_LEN)
+
 #define NVRAM_AS0  0x74
 #define NVRAM_AS1  0x75
 #define NVRAM_DATA 0x77
@@ -28,4 +34,37 @@
 #define MOTO_RTC_CONTROLA       0x1FF8
 #define MOTO_RTC_CONTROLB       0x1FF9
 
+#define NVRAM_SIG_SP	0x02	/* support processor */
+#define NVRAM_SIG_OF	0x50	/* open firmware config */
+#define NVRAM_SIG_FW	0x51	/* general firmware */
+#define NVRAM_SIG_HW	0x52	/* hardware (VPD) */
+#define NVRAM_SIG_SYS	0x70	/* system env vars */
+#define NVRAM_SIG_CFG	0x71	/* config data */
+#define NVRAM_SIG_ELOG	0x72	/* error log */
+#define NVRAM_SIG_VEND	0x7e	/* vendor defined */
+#define NVRAM_SIG_FREE	0x7f	/* Free space */
+#define NVRAM_SIG_OS	0xa0	/* OS defined */
+
+/* If change this size, then change the size of NVNAME_LEN */
+struct nvram_header {
+	unsigned char signature;
+	unsigned char checksum;
+	unsigned short length;
+	char name[12];
+};
+
+struct nvram_partition {
+	struct list_head partition;
+	struct nvram_header header;
+	unsigned int index;
+};
+
+
+ssize_t pSeries_nvram_read(char *buf, size_t count, loff_t *index);
+ssize_t pSeries_nvram_write(char *buf, size_t count, loff_t *index);
+int nvram_write_error_log(char * buff, int length, unsigned int err_type);
+int nvram_read_error_log(char * buff, int length, unsigned int * err_type);
+int nvram_clear_error_log(void);
+void nvram_print_partitions(char * label);
+
 #endif /* _PPC64_NVRAM_H */
diff -puN include/asm-ppc64/paca.h~linus include/asm-ppc64/paca.h
--- 25/include/asm-ppc64/paca.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/paca.h	2004-01-19 22:17:24.000000000 -0800
@@ -61,7 +61,7 @@ struct paca_struct {
 	struct ItLpRegSave *xLpRegSavePtr; /* Pointer to LpRegSave for PLIC	0x08 */
 	u64 xCurrent;  		        /* Pointer to current			0x10 */
 	u16 xPacaIndex;			/* Logical processor number		0x18 */
-	u16 active;			/* Is this cpu active?			0x1a */
+        u16 xHwProcNum;                 /* Physical processor number            0x1A */
 	u32 default_decr;		/* Default decrementer value		0x1c */	
 	u64 unused1;
 	u64 xKsave;			/* Saved Kernel stack addr or zero	0x28 */
@@ -94,7 +94,9 @@ struct paca_struct {
 	u32 *prof_buffer;		/* iSeries profiling buffer		0x38 */
 	u32 *prof_stext;		/* iSeries start of kernel text		0x40 */
 	u32 prof_len;			/* iSeries length of profile buffer -1	0x48 */
-	u8  rsvd2[128-76];		/*					0x4C */
+	u8  yielded;                    /* 0 = this processor is running        0x4c */
+	                                /* 1 = this processor is yielded             */
+	u8  rsvd2[128-77];		/*					0x49 */
 
 /*=====================================================================================
  * CACHE_LINE_3 0x0100 - 0x017F
@@ -117,7 +119,7 @@ struct paca_struct {
 	struct ItLpRegSave xRegSav;	/* Register save for proc */
 
 /*=====================================================================================
- * CACHE_LINE_17-18 0x0800 - 0x0EFF Reserved
+ * CACHE_LINE_17-18 0x0800 - 0x08FF Reserved
  *=====================================================================================
  */
 	struct rtas_args xRtas;		/* Per processor RTAS struct */
@@ -126,10 +128,12 @@ struct paca_struct {
 	u8 rsvd5[256-16-sizeof(struct rtas_args)];
 
 /*=====================================================================================
- * CACHE_LINE_19-30 0x0800 - 0x0EFF Reserved
+ * CACHE_LINE_19-30 0x0900 - 0x0EFF Reserved
  *=====================================================================================
  */
-	u8 rsvd6[0x600];
+	u64 slb_shadow[0x20];
+	u64 dispatch_log;
+	u8  rsvd6[0x500 - 0x8];
 
 /*=====================================================================================
  * CACHE_LINE_31 0x0F00 - 0x0F7F Exception stack
diff -puN include/asm-ppc64/pci.h~linus include/asm-ppc64/pci.h
--- 25/include/asm-ppc64/pci.h~linus	2004-01-19 22:17:07.000000000 -0800
+++ 25-akpm/include/asm-ppc64/pci.h	2004-01-19 22:17:24.000000000 -0800
@@ -65,8 +65,7 @@ static inline void pci_dma_sync_single(s
 				       dma_addr_t dma_handle,
 				       size_t size, int direction)
 {
-	if (direction == PCI_DMA_NONE)
-		BUG();
+	BUG_ON(direction == PCI_DMA_NONE);
 	/* nothing to do */
 }
 
@@ -74,8 +73,7 @@ static inline void pci_dma_sync_sg(struc
 				   struct scatterlist *sg,
 				   int nelems, int direction)
 {
-	if (direction == PCI_DMA_NONE)
-		BUG();
+	BUG_ON(direction == PCI_DMA_NONE);
 	/* nothing to do */
 }
 
@@ -135,6 +133,17 @@ extern void
 pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
 			struct resource *res);
 
+extern int
+unmap_bus_range(struct pci_bus *bus);
+
+extern int
+remap_bus_range(struct pci_bus *bus);
+
+extern void
+pcibios_fixup_device_resources(struct pci_dev *dev, struct pci_bus *bus);
+
+extern int pci_read_irq_line(struct pci_dev *dev);
+
 #endif	/* __KERNEL__ */
 
 #endif /* __PPC64_PCI_H */
diff -puN include/asm-ppc64/pgalloc.h~linus include/asm-ppc64/pgalloc.h
--- 25/include/asm-ppc64/pgalloc.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc64/pgalloc.h	2004-01-19 22:17:24.000000000 -0800
@@ -3,7 +3,10 @@
 
 #include <linux/mm.h>
 #include <linux/slab.h>
+#include <linux/cpumask.h>
+#include <linux/percpu.h>
 #include <asm/processor.h>
+#include <asm/tlb.h>
 
 extern kmem_cache_t *zero_cache;
 
@@ -40,8 +43,6 @@ pmd_free(pmd_t *pmd)
 	kmem_cache_free(zero_cache, pmd);
 }
 
-#define __pmd_free_tlb(tlb, pmd)	pmd_free(pmd)
-
 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, pte)
 #define pmd_populate(mm, pmd, pte_page) \
 	pmd_populate_kernel(mm, pmd, page_address(pte_page))
@@ -62,15 +63,57 @@ pte_alloc_one(struct mm_struct *mm, unsi
 
 	return NULL;
 }
-
-static inline void
-pte_free_kernel(pte_t *pte)
+		
+static inline void pte_free_kernel(pte_t *pte)
 {
 	kmem_cache_free(zero_cache, pte);
 }
 
 #define pte_free(pte_page)	pte_free_kernel(page_address(pte_page))
-#define __pte_free_tlb(tlb, pte)	pte_free(pte)
+
+struct pte_freelist_batch
+{
+	struct rcu_head	rcu;
+	unsigned int	index;
+	struct page *	pages[0];
+};
+
+#define PTE_FREELIST_SIZE	((PAGE_SIZE - sizeof(struct pte_freelist_batch) / \
+				  sizeof(struct page *)))
+
+extern void pte_free_now(struct page *ptepage);
+extern void pte_free_submit(struct pte_freelist_batch *batch);
+
+DECLARE_PER_CPU(struct pte_freelist_batch *, pte_freelist_cur);
+
+static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *ptepage)
+{
+	/* This is safe as we are holding page_table_lock */
+        cpumask_t local_cpumask = cpumask_of_cpu(smp_processor_id());
+	struct pte_freelist_batch **batchp = &__get_cpu_var(pte_freelist_cur);
+
+	if (atomic_read(&tlb->mm->mm_users) < 2 ||
+	    cpus_equal(tlb->mm->cpu_vm_mask, local_cpumask)) {
+		pte_free(ptepage);
+		return;
+	}
+
+	if (*batchp == NULL) {
+		*batchp = (struct pte_freelist_batch *)__get_free_page(GFP_ATOMIC);
+		if (*batchp == NULL) {
+			pte_free_now(ptepage);
+			return;
+		}
+		(*batchp)->index = 0;
+	}
+	(*batchp)->pages[(*batchp)->index++] = ptepage;
+	if ((*batchp)->index == PTE_FREELIST_SIZE) {
+		pte_free_submit(*batchp);
+		*batchp = NULL;
+	}
+}
+
+#define __pmd_free_tlb(tlb, pmd)	__pte_free_tlb(tlb, virt_to_page(pmd))
 
 #define check_pgt_cache()	do { } while (0)
 
diff -puN include/asm-ppc64/pgtable.h~linus include/asm-ppc64/pgtable.h
--- 25/include/asm-ppc64/pgtable.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc64/pgtable.h	2004-01-19 22:17:24.000000000 -0800
@@ -7,6 +7,7 @@
  */
 
 #ifndef __ASSEMBLY__
+#include <linux/stddef.h>
 #include <asm/processor.h>		/* For TASK_SIZE */
 #include <asm/mmu.h>
 #include <asm/page.h>
@@ -51,10 +52,11 @@
  * Define the address range of the imalloc VM area.
  * (used for ioremap)
  */
-#define IMALLOC_START (ioremap_bot)
+#define IMALLOC_START     (ioremap_bot)
 #define IMALLOC_VMADDR(x) ((unsigned long)(x))
-#define IMALLOC_BASE  (0xE000000000000000)
-#define IMALLOC_END   (IMALLOC_BASE + VALID_EA_BITS)
+#define PHBS_IO_BASE  	  (0xE000000000000000)	/* Reserve 2 gigs for PHBs */
+#define IMALLOC_BASE      (0xE000000080000000)  
+#define IMALLOC_END       (IMALLOC_BASE + VALID_EA_BITS)
 
 /*
  * Define the address range mapped virt <-> physical
@@ -73,22 +75,23 @@
  * Bits in a linux-style PTE.  These match the bits in the
  * (hardware-defined) PowerPC PTE as closely as possible.
  */
-#define _PAGE_PRESENT	0x001UL	/* software: pte contains a translation */
-#define _PAGE_USER	0x002UL	/* matches one of the PP bits */
-#define _PAGE_RW	0x004UL	/* software: user write access allowed */
-#define _PAGE_GUARDED	0x008UL
-#define _PAGE_COHERENT	0x010UL	/* M: enforce memory coherence (SMP systems) */
-#define _PAGE_NO_CACHE	0x020UL	/* I: cache inhibit */
-#define _PAGE_WRITETHRU	0x040UL	/* W: cache write-through */
-#define _PAGE_DIRTY	0x080UL	/* C: page changed */
-#define _PAGE_ACCESSED	0x100UL	/* R: page referenced */
-#define _PAGE_FILE	0x200UL /* software: pte holds file offset */
-#define _PAGE_HASHPTE	0x400UL	/* software: pte has an associated HPTE */
-#define _PAGE_EXEC	0x800UL	/* software: i-cache coherence required */
-#define _PAGE_SECONDARY 0x8000UL /* software: HPTE is in secondary group */
-#define _PAGE_GROUP_IX  0x7000UL /* software: HPTE index within group */
+#define _PAGE_PRESENT	0x0001 /* software: pte contains a translation */
+#define _PAGE_USER	0x0002 /* matches one of the PP bits */
+#define _PAGE_FILE	0x0002 /* (!present only) software: pte holds file offset */
+#define _PAGE_RW	0x0004 /* software: user write access allowed */
+#define _PAGE_GUARDED	0x0008
+#define _PAGE_COHERENT	0x0010 /* M: enforce memory coherence (SMP systems) */
+#define _PAGE_NO_CACHE	0x0020 /* I: cache inhibit */
+#define _PAGE_WRITETHRU	0x0040 /* W: cache write-through */
+#define _PAGE_DIRTY	0x0080 /* C: page changed */
+#define _PAGE_ACCESSED	0x0100 /* R: page referenced */
+#define _PAGE_EXEC	0x0200 /* software: i-cache coherence required */
+#define _PAGE_HASHPTE	0x0400 /* software: pte has an associated HPTE */
+#define _PAGE_BUSY	0x0800 /* software: PTE & hash are busy */ 
+#define _PAGE_SECONDARY 0x8000 /* software: HPTE is in secondary group */
+#define _PAGE_GROUP_IX  0x7000 /* software: HPTE index within group */
 /* Bits 0x7000 identify the index within an HPT Group */
-#define _PAGE_HPTEFLAGS (_PAGE_HASHPTE | _PAGE_SECONDARY | _PAGE_GROUP_IX)
+#define _PAGE_HPTEFLAGS (_PAGE_BUSY | _PAGE_HASHPTE | _PAGE_SECONDARY | _PAGE_GROUP_IX)
 /* PAGE_MASK gives the right answer below, but only by accident */
 /* It should be preserving the high 48 bits and then specifically */
 /* preserving _PAGE_SECONDARY | _PAGE_GROUP_IX */
@@ -156,8 +159,10 @@ extern unsigned long empty_zero_page[PAG
 #define _PMD_HUGEPAGE	0x00000001U
 #define HUGEPTE_BATCH_SIZE (1<<(HPAGE_SHIFT-PMD_SHIFT))
 
+#ifndef __ASSEMBLY__
 int hash_huge_page(struct mm_struct *mm, unsigned long access,
 		   unsigned long ea, unsigned long vsid, int local);
+#endif /* __ASSEMBLY__ */
 
 #define HAVE_ARCH_UNMAPPED_AREA
 #else
@@ -287,15 +292,17 @@ static inline unsigned long pte_update( 
 					unsigned long set )
 {
 	unsigned long old, tmp;
-
+	
 	__asm__ __volatile__(
 	"1:	ldarx	%0,0,%3		# pte_update\n\
+	andi.	%1,%0,%7\n\
+	bne-	1b \n\
 	andc	%1,%0,%4 \n\
 	or	%1,%1,%5 \n\
 	stdcx.	%1,0,%3 \n\
 	bne-	1b"
 	: "=&r" (old), "=&r" (tmp), "=m" (*p)
-	: "r" (p), "r" (clr), "r" (set), "m" (*p)
+	: "r" (p), "r" (clr), "r" (set), "m" (*p), "i" (_PAGE_BUSY)
 	: "cc" );
 	return old;
 }
@@ -399,6 +406,17 @@ void pgtable_cache_init(void);
 extern void hpte_init_pSeries(void);
 extern void hpte_init_iSeries(void);
 
+/* imalloc region types */
+#define IM_REGION_UNUSED	0x1
+#define IM_REGION_SUBSET	0x2
+#define IM_REGION_EXISTS	0x4
+#define IM_REGION_OVERLAP	0x8
+
+extern struct vm_struct * im_get_free_area(unsigned long size);
+extern struct vm_struct * im_get_area(unsigned long v_addr, unsigned long size,
+			int region_type);
+unsigned long im_free(void *addr);
+
 typedef pte_t *pte_addr_t;
 
 long pSeries_lpar_hpte_insert(unsigned long hpte_group,
@@ -410,5 +428,40 @@ long pSeries_hpte_insert(unsigned long h
 			 unsigned long prpn, int secondary,
 			 unsigned long hpteflags, int bolted, int large);
 
+/*
+ * find_linux_pte returns the address of a linux pte for a given 
+ * effective address and directory.  If not found, it returns zero.
+ */
+static inline pte_t *find_linux_pte(pgd_t *pgdir, unsigned long ea)
+{
+	pgd_t *pg;
+	pmd_t *pm;
+	pte_t *pt = NULL;
+	pte_t pte;
+
+	pg = pgdir + pgd_index(ea);
+	if (!pgd_none(*pg)) {
+
+		pm = pmd_offset(pg, ea);
+		if (pmd_present(*pm)) { 
+			pt = pte_offset_kernel(pm, ea);
+			pte = *pt;
+			if (!pte_present(pte))
+				pt = NULL;
+		}
+	}
+
+	return pt;
+}
+
 #endif /* __ASSEMBLY__ */
+
+#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
+#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
+#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
+#define __HAVE_ARCH_PTEP_SET_WRPROTECT
+#define __HAVE_ARCH_PTEP_MKDIRTY
+#define __HAVE_ARCH_PTE_SAME
+#include <asm-generic/pgtable.h>
+
 #endif /* _PPC64_PGTABLE_H */
diff -puN include/asm-ppc64/ppc32.h~linus include/asm-ppc64/ppc32.h
--- 25/include/asm-ppc64/ppc32.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc64/ppc32.h	2004-01-19 22:17:24.000000000 -0800
@@ -40,12 +40,7 @@
 
 /* These are here to support 32-bit syscalls on a 64-bit kernel. */
 
-typedef union sigval32 {
-	int sival_int;
-	unsigned int sival_ptr;
-} sigval_t32;
-
-typedef struct siginfo32 {
+typedef struct compat_siginfo {
 	int si_signo;
 	int si_errno;
 	int si_code;
@@ -69,7 +64,7 @@ typedef struct siginfo32 {
 		struct {
 			compat_pid_t _pid;		/* sender's pid */
 			compat_uid_t _uid;		/* sender's uid */
-			sigval_t32 _sigval;
+			compat_sigval_t _sigval;
 		} _rt;
 
 		/* SIGCHLD */
@@ -92,7 +87,7 @@ typedef struct siginfo32 {
 			int _fd;
 		} _sigpoll;
 	} _sifields;
-} siginfo_t32;
+} compat_siginfo_t;
 
 #define __old_sigaction32	old_sigaction32
 
@@ -126,14 +121,40 @@ struct sigcontext32 {
 	u32 regs;  /* 4 byte pointer to the pt_regs32 structure. */
 };
 
+struct mcontext32 {
+	elf_gregset_t32		mc_gregs;
+	elf_fpregset_t		mc_fregs;
+	unsigned int		mc_pad[2];
+	elf_vrregset_t32	mc_vregs __attribute__((__aligned__(16)));
+};
+
 struct ucontext32 { 
-	unsigned int	  uc_flags;
-	unsigned int 	  uc_link;
-	stack_32_t	  uc_stack;
-	struct sigcontext32 uc_mcontext;
-	sigset_t	  uc_sigmask;	/* mask last for extensibility */
+	unsigned int	  	uc_flags;
+	unsigned int 	  	uc_link;
+	stack_32_t	 	uc_stack;
+	int		 	uc_pad[7];
+	u32			uc_regs;	/* points to uc_mcontext field */
+	compat_sigset_t	 	uc_sigmask;	/* mask last for extensibility */
+	/* glibc has 1024-bit signal masks, ours are 64-bit */
+	int		 	uc_maskext[30];
+	int		 	uc_pad2[3];
+	struct mcontext32	uc_mcontext;
 };
 
+typedef struct compat_sigevent {
+	compat_sigval_t sigev_value;
+	int sigev_signo;
+	int sigev_notify;
+	union {
+		int _pad[SIGEV_PAD_SIZE];
+		int _tid;
+		struct {
+			compat_uptr_t _function;
+			compat_uptr_t _attribute;
+		} _sigev_thread;
+	} _sigev_un;
+} compat_sigevent_t;
+
 struct ipc_kludge_32 {
 	unsigned int msgp;
 	int msgtyp;
diff -puN include/asm-ppc64/ppc_asm.h~linus include/asm-ppc64/ppc_asm.h
--- 25/include/asm-ppc64/ppc_asm.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc64/ppc_asm.h	2004-01-19 22:17:24.000000000 -0800
@@ -39,6 +39,19 @@
 #define REST_16FPRS(n, base)	REST_8FPRS(n, base); REST_8FPRS(n+8, base)
 #define REST_32FPRS(n, base)	REST_16FPRS(n, base); REST_16FPRS(n+16, base)
 
+#define SAVE_VR(n,b,base)	li b,THREAD_VR0+(16*(n));  stvx n,b,base
+#define SAVE_2VRS(n,b,base)	SAVE_VR(n,b,base); SAVE_VR(n+1,b,base)
+#define SAVE_4VRS(n,b,base)	SAVE_2VRS(n,b,base); SAVE_2VRS(n+2,b,base)
+#define SAVE_8VRS(n,b,base)	SAVE_4VRS(n,b,base); SAVE_4VRS(n+4,b,base)
+#define SAVE_16VRS(n,b,base)	SAVE_8VRS(n,b,base); SAVE_8VRS(n+8,b,base)
+#define SAVE_32VRS(n,b,base)	SAVE_16VRS(n,b,base); SAVE_16VRS(n+16,b,base)
+#define REST_VR(n,b,base)	li b,THREAD_VR0+(16*(n)); lvx n,b,base
+#define REST_2VRS(n,b,base)	REST_VR(n,b,base); REST_VR(n+1,b,base)
+#define REST_4VRS(n,b,base)	REST_2VRS(n,b,base); REST_2VRS(n+2,b,base)
+#define REST_8VRS(n,b,base)	REST_4VRS(n,b,base); REST_4VRS(n+4,b,base)
+#define REST_16VRS(n,b,base)	REST_8VRS(n,b,base); REST_8VRS(n+8,b,base)
+#define REST_32VRS(n,b,base)	REST_16VRS(n,b,base); REST_16VRS(n+16,b,base)
+
 #define CHECKANYINT(ra,rb)			\
 	mfspr	rb,SPRG3;		/* Get Paca address */\
 	ld	ra,PACALPPACA+LPPACAANYINT(rb); /* Get pending interrupt flags */\
diff -puN include/asm-ppc64/processor.h~linus include/asm-ppc64/processor.h
--- 25/include/asm-ppc64/processor.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc64/processor.h	2004-01-19 22:17:24.000000000 -0800
@@ -311,6 +311,7 @@
 #define	SPRN_USIA	0x3AB	/* User Sampled Instruction Address Register */
 #define	SPRN_XER	0x001	/* Fixed Point Exception Register */
 #define	SPRN_ZPR	0x3B0	/* Zone Protection Register */
+#define SPRN_VRSAVE     0x100   /* Vector save */
 
 /* Short-hand versions for a number of the above SPRNs */
 
@@ -371,6 +372,7 @@
 #define	PV_ICESTAR	0x0036
 #define	PV_SSTAR	0x0037
 #define	PV_POWER4p	0x0038
+#define	PV_POWER5	0x003A
 #define	PV_630        	0x0040
 #define	PV_630p	        0x0041
 
@@ -378,6 +380,7 @@
 #define PLATFORM_PSERIES      0x0100
 #define PLATFORM_PSERIES_LPAR 0x0101
 #define PLATFORM_ISERIES_LPAR 0x0201
+#define PLATFORM_LPAR         0x0001
 	
 /*
  * List of interrupt controllers.
@@ -462,11 +465,9 @@ void start_thread(struct pt_regs *regs, 
 void release_thread(struct task_struct *);
 
 /* Prepare to copy thread state - unlazy all lazy status */
-#define prepare_to_copy(tsk)	do { } while (0)
+extern void prepare_to_copy(struct task_struct *tsk);
 
-/*
- * Create a new kernel thread.
- */
+/* Create a new kernel thread. */
 extern long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
 
 /*
@@ -477,6 +478,7 @@ extern long kernel_thread(int (*fn)(void
 
 /* Lazy FPU handling on uni-processor */
 extern struct task_struct *last_task_used_math;
+extern struct task_struct *last_task_used_altivec;
 
 
 #ifdef __KERNEL__
@@ -516,6 +518,14 @@ struct thread_struct {
 	unsigned long	fpexc_mode;	/* Floating-point exception mode */
 	unsigned long	saved_msr;	/* Save MSR across signal handlers */
 	unsigned long	saved_softe;	/* Ditto for Soft Enable/Disable */
+#ifdef CONFIG_ALTIVEC
+	/* Complete AltiVec register set */
+	vector128	vr[32] __attribute((aligned(16)));
+	/* AltiVec status */
+	vector128	vscr __attribute((aligned(16)));
+	unsigned long	vrsave;
+	int		used_vr;	/* set if process has used altivec */
+#endif /* CONFIG_ALTIVEC */
 };
 
 #define INIT_SP		(sizeof(init_stack) + (unsigned long) &init_stack)
diff -puN include/asm-ppc64/proc_fs.h~linus include/asm-ppc64/proc_fs.h
--- 25/include/asm-ppc64/proc_fs.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc64/proc_fs.h	2004-01-19 22:17:24.000000000 -0800
@@ -34,5 +34,6 @@ struct proc_ppc64_t {
 };
 
 extern struct proc_ppc64_t proc_ppc64;
+extern int proc_ppc64_init(void);
 
 #endif /* _PPC64_PROC_FS_H */
diff -puN include/asm-ppc64/prom.h~linus include/asm-ppc64/prom.h
--- 25/include/asm-ppc64/prom.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc64/prom.h	2004-01-19 22:17:24.000000000 -0800
@@ -14,6 +14,8 @@
  * as published by the Free Software Foundation; either version
  * 2 of the License, or (at your option) any later version.
  */
+#include <linux/proc_fs.h>
+#include <asm/atomic.h>
 
 #define PTRRELOC(x)     ((typeof(x))((unsigned long)(x) - offset))
 #define PTRUNRELOC(x)   ((typeof(x))((unsigned long)(x) + offset))
@@ -47,6 +49,17 @@ struct pci_address {
 	u32 a_lo;
 };
 
+struct isa_address {
+	u32 a_hi;
+	u32 a_lo;
+};
+
+struct isa_range {
+	struct isa_address isa_addr;
+	struct pci_address pci_addr;
+	unsigned int size;
+};
+
 struct pci_range32 {
 	struct pci_address child_addr;
 	unsigned int  parent_addr;
@@ -120,6 +133,7 @@ struct device_node {
 	char	*name;
 	char	*type;
 	phandle	node;
+	phandle linux_phandle;
 	int	n_addrs;
 	struct	address_range *addrs;
 	int	n_intrs;
@@ -143,7 +157,43 @@ struct device_node {
 	struct	device_node *sibling;
 	struct	device_node *next;	/* next device of same type */
 	struct	device_node *allnext;	/* next in list of all nodes */
-};
+	struct  proc_dir_entry *pde;       /* this node's proc directory */
+	struct  proc_dir_entry *name_link; /* name symlink */
+	struct  proc_dir_entry *addr_link; /* addr symlink */
+	atomic_t _users;                 /* reference count */
+	unsigned long _flags;
+};
+
+/* flag descriptions */
+#define OF_STALE   0 /* node is slated for deletion */
+#define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */
+
+#define OF_IS_STALE(x) test_bit(OF_STALE, &x->_flags)
+#define OF_MARK_STALE(x) set_bit(OF_STALE, &x->_flags)
+#define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
+#define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
+
+/*
+ * Until 32-bit ppc can add proc_dir_entries to its device_node
+ * definition, we cannot refer to pde, name_link, and addr_link
+ * in arch-independent code.
+ */
+#define HAVE_ARCH_DEVTREE_FIXUPS
+
+static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
+{
+	dn->pde = de;
+}
+
+static void inline set_node_name_link(struct device_node *dn, struct proc_dir_entry *de)
+{
+	dn->name_link = de;
+}
+
+static void inline set_node_addr_link(struct device_node *dn, struct proc_dir_entry *de)
+{
+	dn->addr_link = de;
+}
 
 typedef u32 prom_arg_t;
 
@@ -168,22 +218,43 @@ struct prom_t {
 };
 
 extern struct prom_t prom;
+extern char *of_stdout_device;
 
 extern int boot_cpuid;
 
-/* Prototypes */
-extern void abort(void);
-extern unsigned long prom_init(unsigned long, unsigned long, unsigned long,
-    unsigned long, unsigned long);
-extern void prom_print(const char *msg);
-extern void relocate_nodes(void);
-extern void finish_device_tree(void);
+/* OBSOLETE: Old stlye node lookup */
 extern struct device_node *find_devices(const char *name);
 extern struct device_node *find_type_devices(const char *type);
 extern struct device_node *find_path_device(const char *path);
 extern struct device_node *find_compatible_devices(const char *type,
 						   const char *compat);
 extern struct device_node *find_all_nodes(void);
+
+/* New style node lookup */
+extern struct device_node *of_find_node_by_name(struct device_node *from,
+	const char *name);
+extern struct device_node *of_find_node_by_type(struct device_node *from,
+	const char *type);
+extern struct device_node *of_find_compatible_node(struct device_node *from,
+	const char *type, const char *compat);
+extern struct device_node *of_find_node_by_path(const char *path);
+extern struct device_node *of_find_all_nodes(struct device_node *prev);
+extern struct device_node *of_get_parent(const struct device_node *node);
+extern struct device_node *of_get_next_child(const struct device_node *node,
+					     struct device_node *prev);
+extern struct device_node *of_node_get(struct device_node *node);
+extern void of_node_put(struct device_node *node);
+
+/* For updating the device tree at runtime */
+extern int of_add_node(const char *path, struct property *proplist);
+extern int of_remove_node(struct device_node *np);
+
+/* Other Prototypes */
+extern unsigned long prom_init(unsigned long, unsigned long, unsigned long,
+	unsigned long, unsigned long);
+extern void prom_print(const char *msg);
+extern void relocate_nodes(void);
+extern void finish_device_tree(void);
 extern int device_is_compatible(struct device_node *device, const char *);
 extern int machine_is_compatible(const char *compat);
 extern unsigned char *get_property(struct device_node *node, const char *name,
diff -puN include/asm-ppc64/ptrace.h~linus include/asm-ppc64/ptrace.h
--- 25/include/asm-ppc64/ptrace.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc64/ptrace.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,7 +16,7 @@
  * that the overall structure is a multiple of 16 bytes in length.
  *
  * Note that the offsets of the fields in this struct correspond with
- * the PT_* values below.  This simplifies arch/ppc/kernel/ptrace.c.
+ * the PT_* values below.  This simplifies arch/ppc64/kernel/ptrace.c.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -120,13 +120,41 @@ struct pt_regs32 {
 #define PT_RESULT 43
 
 #define PT_FPR0	48
+
+/* Kernel and userspace will both use this PT_FPSCR value.  32-bit apps will have
+ * visibility to the asm-ppc/ptrace.h header instead of this one.
+ */
+#define PT_FPSCR (PT_FPR0 + 32 + 1)	  /* each FP reg occupies 1 slot in 64-bit space */
+
 #ifdef __KERNEL__
-#define PT_FPSCR (PT_FPR0 + 32 + 1)	  /* each FP reg occupies 1 slot in this space */
-#define PT_FPSCR32 (PT_FPR0 + 2*32 + 1)	  /* To the 32-bit user - each FP reg occupies 2 slots in this space */
-#else
-#define PT_FPSCR (PT_FPR0 + 2*32 + 1)	/* each FP reg occupies 2 slots in this space -- Fix when 64-bit apps. */
+#define PT_FPSCR32 (PT_FPR0 + 2*32 + 1)	  /* each FP reg occupies 2 32-bit userspace slots */
 #endif
 
+#define PT_VR0 82	/* each Vector reg occupies 2 slots in 64-bit */
+#define PT_VSCR (PT_VR0 + 32*2 + 1)
+#define PT_VRSAVE (PT_VR0 + 33*2)
+
+#ifdef __KERNEL__
+#define PT_VR0_32 164	/* each Vector reg occupies 4 slots in 32-bit */
+#define PT_VSCR_32 (PT_VR0 + 32*4 + 3)
+#define PT_VRSAVE_32 (PT_VR0 + 33*4)
+#endif
+
+/*
+ * Get/set all the altivec registers vr0..vr31, vscr, vrsave, in one go. 
+ * The transfer totals 34 quadword.  Quadwords 0-31 contain the 
+ * corresponding vector registers.  Quadword 32 contains the vscr as the 
+ * last word (offset 12) within that quadword.  Quadword 33 contains the 
+ * vrsave as the first word (offset 0) within the quadword.
+ *
+ * This definition of the VMX state is compatible with the current PPC32 
+ * ptrace interface.  This allows signal handling and ptrace to use the same 
+ * structures.  This also simplifies the implementation of a bi-arch 
+ * (combined (32- and 64-bit) gdb.
+ */
+#define PTRACE_GETVRREGS	18
+#define PTRACE_SETVRREGS	19
+
 /* Additional PTRACE requests implemented on PowerPC. */
 #define PPC_PTRACE_GETREGS	      0x99  /* Get GPRs 0 - 31 */
 #define PPC_PTRACE_SETREGS	      0x98  /* Set GPRs 0 - 31 */
diff -puN include/asm-ppc64/rtas.h~linus include/asm-ppc64/rtas.h
--- 25/include/asm-ppc64/rtas.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc64/rtas.h	2004-01-19 22:17:24.000000000 -0800
@@ -19,6 +19,16 @@
 #define RTAS_UNKNOWN_SERVICE (-1)
 #define RTAS_INSTANTIATE_MAX (1UL<<30) /* Don't instantiate rtas at/above this value */
 
+/* Buffer size for ppc_rtas system call. */
+#define RTAS_RMOBUF_MAX (64 * 1024)
+
+/* RTAS return codes */
+#define RTAS_BUSY		-2	/* RTAS Return Status - Busy */
+#define RTAS_EXTENDED_DELAY_MIN 9900
+#define RTAS_EXTENDED_DELAY_MAX 9905
+
+#define RTAS_UNKNOWN_OP		-1099	/* Return Status - Unknown RTAS Token */
+
 /*
  * In general to call RTAS use rtas_token("string") to lookup
  * an RTAS token for the given string (e.g. "event-scan").
@@ -57,11 +67,11 @@ struct rtas_t {
 };
 
 /* Event classes */
-#define INTERNAL_ERROR		0x80000000 /* set bit 0 */
-#define EPOW_WARNING		0x40000000 /* set bit 1 */
-#define POWERMGM_EVENTS		0x20000000 /* set bit 2 */
-#define HOTPLUG_EVENTS		0x10000000 /* set bit 3 */
-#define EVENT_SCAN_ALL_EVENTS	0xf0000000
+#define RTAS_INTERNAL_ERROR		0x80000000 /* set bit 0 */
+#define RTAS_EPOW_WARNING		0x40000000 /* set bit 1 */
+#define RTAS_POWERMGM_EVENTS		0x20000000 /* set bit 2 */
+#define RTAS_HOTPLUG_EVENTS		0x10000000 /* set bit 3 */
+#define RTAS_EVENT_SCAN_ALL_EVENTS	0xf0000000
 
 /* event-scan returns */
 #define SEVERITY_FATAL		0x5
@@ -165,6 +175,9 @@ extern void call_rtas_display_status(cha
 extern void rtas_restart(char *cmd);
 extern void rtas_power_off(void);
 extern void rtas_halt(void);
+extern int rtas_get_sensor(int sensor, int index, int *state);
+extern int rtas_get_power_level(int powerdomain, int *level);
+extern int rtas_set_indicator(int indicator, int index, int new_value);
 
 /* Given an RTAS status code of 9900..9905 compute the hinted delay */
 unsigned int rtas_extended_busy_delay_time(int status);
@@ -173,13 +186,39 @@ static inline int rtas_is_extended_busy(
 	return status >= 9900 && status <= 9909;
 }
 
+extern void pSeries_log_error(char *buf, unsigned int err_type, int fatal);
+
+/* Error types logged.  */
+#define ERR_FLAG_ALREADY_LOGGED	0x0
+#define ERR_FLAG_BOOT		0x1 	/* log was pulled from NVRAM on boot */
+#define ERR_TYPE_RTAS_LOG	0x2	/* from rtas event-scan */
+#define ERR_TYPE_KERNEL_PANIC	0x4	/* from panic() */
+
+/* All the types and not flags */
+#define ERR_TYPE_MASK	(ERR_TYPE_RTAS_LOG | ERR_TYPE_KERNEL_PANIC)
+
+#define RTAS_ERR KERN_ERR "RTAS: "
+ 
+#define RTAS_ERROR_LOG_MAX 2048
+ 
+ 
+/* Event Scan Parameters */
+#define EVENT_SCAN_ALL_EVENTS	0xf0000000
+#define SURVEILLANCE_TOKEN	9000
+#define LOG_NUMBER		64		/* must be a power of two */
+#define LOG_NUMBER_MASK		(LOG_NUMBER-1)
+
 /* 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];
 
+/* RMO buffer reserved for user-space RTAS use */
+extern unsigned long rtas_rmo_buf;
+
 #endif /* _PPC64_RTAS_H */
diff -puN include/asm-ppc64/sigcontext.h~linus include/asm-ppc64/sigcontext.h
--- 25/include/asm-ppc64/sigcontext.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc64/sigcontext.h	2004-01-19 22:17:24.000000000 -0800
@@ -21,6 +21,27 @@ struct sigcontext {
 	struct pt_regs	*regs;
 	elf_gregset_t	gp_regs;
 	elf_fpregset_t	fp_regs;
+/*
+ * To maintain compatibility with current implementations the sigcontext is 
+ * extended by appending a pointer (v_regs) to a quadword type (elf_vrreg_t) 
+ * followed by an unstructured (vmx_reserve) field of 69 doublewords.  This 
+ * allows the array of vector registers to be quadword aligned independent of 
+ * the alignment of the containing sigcontext or ucontext. It is the 
+ * responsibility of the code setting the sigcontext to set this pointer to 
+ * either NULL (if this processor does not support the VMX feature) or the 
+ * address of the first quadword within the allocated (vmx_reserve) area.
+ *
+ * The pointer (v_regs) of vector type (elf_vrreg_t) is type compatible with 
+ * an array of 34 quadword entries (elf_vrregset_t).  The entries with 
+ * indexes 0-31 contain the corresponding vector registers.  The entry with 
+ * index 32 contains the vscr as the last word (offset 12) within the 
+ * quadword.  This allows the vscr to be stored as either a quadword (since 
+ * it must be copied via a vector register to/from storage) or as a word.  
+ * The entry with index 33 contains the vrsave as the first word (offset 0) 
+ * within the quadword.
+ */
+	elf_vrreg_t	*v_regs;
+	long		vmx_reserve[ELF_NVRREG+ELF_NVRREG+1];
 };
 
 #endif /* _ASM_PPC64_SIGCONTEXT_H */
diff -puN include/asm-ppc64/smp.h~linus include/asm-ppc64/smp.h
--- 25/include/asm-ppc64/smp.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc64/smp.h	2004-01-19 22:17:24.000000000 -0800
@@ -22,21 +22,40 @@
 #include <linux/cpumask.h>
 #include <linux/kernel.h>
 
-#ifdef CONFIG_SMP
-
 #ifndef __ASSEMBLY__
 
 #include <asm/paca.h>
 
+#ifdef CONFIG_SMP
+
 extern void smp_message_pass(int target, int msg, unsigned long data, int wait);
 extern void smp_send_tlb_invalidate(int);
 extern void smp_send_xmon_break(int cpu);
 struct pt_regs;
 extern void smp_message_recv(int, struct pt_regs *);
 
-#define cpu_possible(cpu)	paca[cpu].active
 
 #define smp_processor_id() (get_paca()->xPacaIndex)
+#define hard_smp_processor_id() (get_paca()->xHwProcNum)
+
+/*
+ * Retrieve the state of a CPU:
+ * online:          CPU is in a normal run state
+ * possible:        CPU is a candidate to be made online
+ * available:       CPU is candidate for the 'possible' pool
+ *                  Used to get SMT threads started at boot time.
+ * present_at_boot: CPU was available at boot time.  Used in DLPAR
+ *                  code to handle special cases for processor start up.
+ */
+extern cpumask_t cpu_present_at_boot;
+extern cpumask_t cpu_online_map;
+extern cpumask_t cpu_possible_map;
+extern cpumask_t cpu_available_map;
+
+#define cpu_present_at_boot(cpu) cpu_isset(cpu, cpu_present_at_boot)
+#define cpu_online(cpu)          cpu_isset(cpu, cpu_online_map) 
+#define cpu_possible(cpu)        cpu_isset(cpu, cpu_possible_map) 
+#define cpu_available(cpu)       cpu_isset(cpu, cpu_available_map) 
 
 /* Since OpenPIC has only 4 IPIs, we use slightly different message numbers.
  *
@@ -50,7 +69,11 @@ extern void smp_message_recv(int, struct
 void smp_init_iSeries(void);
 void smp_init_pSeries(void);
 
-#endif /* __ASSEMBLY__ */
 #endif /* !(CONFIG_SMP) */
+#endif /* __ASSEMBLY__ */
+
+#define get_hard_smp_processor_id(CPU) (paca[(CPU)].xHwProcNum)
+#define set_hard_smp_processor_id(CPU, VAL) do { (paca[(CPU)].xHwProcNum = VAL); } while (0)
+
 #endif /* !(_PPC64_SMP_H) */
 #endif /* __KERNEL__ */
diff -puN include/asm-ppc64/socket.h~linus include/asm-ppc64/socket.h
--- 25/include/asm-ppc64/socket.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc64/socket.h	2004-01-19 22:17:24.000000000 -0800
@@ -52,6 +52,8 @@
 
 #define SO_ACCEPTCONN           30
 
+#define SO_PEERSEC             31
+
 /* Nast libc5 fixup - bletch */
 #if defined(__KERNEL__)
 /* Socket types. */
diff -puN include/asm-ppc64/system.h~linus include/asm-ppc64/system.h
--- 25/include/asm-ppc64/system.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc64/system.h	2004-01-19 22:17:24.000000000 -0800
@@ -85,6 +85,9 @@ extern int _get_PVR(void);
 extern void giveup_fpu(struct task_struct *);
 extern void disable_kernel_fp(void);
 extern void enable_kernel_fp(void);
+extern void giveup_altivec(struct task_struct *);
+extern void disable_kernel_altivec(void);
+extern void enable_kernel_altivec(void);
 extern void cvt_fd(float *from, double *to, unsigned long *fpscr);
 extern void cvt_df(double *from, float *to, unsigned long *fpscr);
 extern int abs(int);
diff -puN include/asm-ppc64/tlb.h~linus include/asm-ppc64/tlb.h
--- 25/include/asm-ppc64/tlb.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc64/tlb.h	2004-01-19 22:17:24.000000000 -0800
@@ -74,6 +74,8 @@ static inline void __tlb_remove_tlb_entr
 	batch->index = i;
 }
 
+extern void pte_free_finish(void);
+
 static inline void tlb_flush(struct mmu_gather *tlb)
 {
 	int cpu = smp_processor_id();
@@ -86,6 +88,8 @@ static inline void tlb_flush(struct mmu_
 
 	flush_hash_range(tlb->mm->context, batch->index, local);
 	batch->index = 0;
+
+	pte_free_finish();
 }
 
 #endif /* _PPC64_TLB_H */
diff -puN include/asm-ppc64/topology.h~linus include/asm-ppc64/topology.h
--- 25/include/asm-ppc64/topology.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc64/topology.h	2004-01-19 22:17:24.000000000 -0800
@@ -13,8 +13,7 @@ static inline int cpu_to_node(int cpu)
 	node = numa_cpu_lookup_table[cpu];
 
 #ifdef DEBUG_NUMA
-	if (node == -1)
-		BUG();
+	BUG_ON(node == -1);
 #endif
 
 	return node;
diff -puN include/asm-ppc64/uaccess.h~linus include/asm-ppc64/uaccess.h
--- 25/include/asm-ppc64/uaccess.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc64/uaccess.h	2004-01-19 22:17:24.000000000 -0800
@@ -82,7 +82,6 @@ struct exception_table_entry
 
 /* Returns 0 if exception not found and fixup otherwise.  */
 extern unsigned long search_exception_table(unsigned long);
-extern void sort_exception_table(void);
 
 /*
  * These are the main single-value transfer routines.  They automatically
diff -puN include/asm-ppc64/unistd.h~linus include/asm-ppc64/unistd.h
--- 25/include/asm-ppc64/unistd.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc64/unistd.h	2004-01-19 22:17:24.000000000 -0800
@@ -246,9 +246,9 @@
 #define __NR_fadvise64		233
 #define __NR_exit_group		234
 #define __NR_lookup_dcookie	235
-#define __NR_sys_epoll_create	236
-#define __NR_sys_epoll_ctl	237
-#define __NR_sys_epoll_wait	238
+#define __NR_epoll_create	236
+#define __NR_epoll_ctl		237
+#define __NR_epoll_wait		238
 #define __NR_remap_file_pages	239
 #define __NR_timer_create	240
 #define __NR_timer_settime	241
@@ -264,8 +264,10 @@
 #define __NR_utimes		251
 #define __NR_statfs64		252
 #define __NR_fstatfs64		253
+#define __NR_fadvise64_64	254
+#define __NR_rtas		255
 
-#define __NR_syscalls		254
+#define __NR_syscalls		256
 #ifdef __KERNEL__
 #define NR_syscalls	__NR_syscalls
 #endif
@@ -287,6 +289,7 @@
 		register unsigned long __sc_5  __asm__ ("r5");		\
 		register unsigned long __sc_6  __asm__ ("r6");		\
 		register unsigned long __sc_7  __asm__ ("r7");		\
+		register unsigned long __sc_8  __asm__ ("r8");		\
 									\
 		__sc_loadargs_##nr(name, args);				\
 		__asm__ __volatile__					\
@@ -295,10 +298,10 @@
 			: "=&r" (__sc_0),				\
 			  "=&r" (__sc_3),  "=&r" (__sc_4),		\
 			  "=&r" (__sc_5),  "=&r" (__sc_6),		\
-			  "=&r" (__sc_7)				\
+			  "=&r" (__sc_7),  "=&r" (__sc_8)		\
 			: __sc_asm_input_##nr				\
 			: "cr0", "ctr", "memory",			\
-			  "r8", "r9", "r10","r11", "r12");		\
+			        "r9", "r10","r11", "r12");		\
 		__sc_ret = __sc_3;					\
 		__sc_err = __sc_0;					\
 	}								\
@@ -326,6 +329,9 @@
 #define __sc_loadargs_5(name, arg1, arg2, arg3, arg4, arg5)		\
 	__sc_loadargs_4(name, arg1, arg2, arg3, arg4);			\
 	__sc_7 = (unsigned long) (arg5)
+#define __sc_loadargs_6(name, arg1, arg2, arg3, arg4, arg5, arg6)	\
+	__sc_loadargs_5(name, arg1, arg2, arg3, arg4, arg5);		\
+	__sc_8 = (unsigned long) (arg6)
 
 #define __sc_asm_input_0 "0" (__sc_0)
 #define __sc_asm_input_1 __sc_asm_input_0, "1" (__sc_3)
@@ -333,6 +339,7 @@
 #define __sc_asm_input_3 __sc_asm_input_2, "3" (__sc_5)
 #define __sc_asm_input_4 __sc_asm_input_3, "4" (__sc_6)
 #define __sc_asm_input_5 __sc_asm_input_4, "5" (__sc_7)
+#define __sc_asm_input_6 __sc_asm_input_5, "6" (__sc_8)
 
 #define _syscall0(type,name)						\
 type name(void)								\
@@ -369,6 +376,11 @@ type name(type1 arg1, type2 arg2, type3 
 {									\
 	__syscall_nr(5, type, name, arg1, arg2, arg3, arg4, arg5);	\
 }
+#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
+type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6)	\
+{									\
+	__syscall_nr(6, type, name, arg1, arg2, arg3, arg4, arg5, arg6);	\
+}
 
 #ifdef __KERNEL_SYSCALLS__
 
diff -puN /dev/null include/asm-ppc64/vio.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/asm-ppc64/vio.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,130 @@
+/*
+ * IBM PowerPC Virtual I/O Infrastructure Support.
+ *
+ *    Copyright (c) 2003 IBM Corp.
+ *     Dave Engebretsen engebret@us.ibm.com
+ *     Santiago Leon santil@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 _VIO_H
+#define _VIO_H
+
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <asm/hvcall.h>
+#include <asm/prom.h>
+#include <asm/scatterlist.h>
+/* 
+ * Architecture-specific constants for drivers to
+ * extract attributes of the device using vio_get_attribute()
+*/
+#define VETH_MAC_ADDR "local-mac-address"
+#define VETH_MCAST_FILTER_SIZE "ibm,mac-address-filters"
+
+/* End architecture-specific constants */
+
+#define h_vio_signal(ua, mode) \
+  plpar_hcall_norets(H_VIO_SIGNAL, ua, mode)
+
+#define VIO_IRQ_DISABLE		0UL
+#define VIO_IRQ_ENABLE		1UL
+
+struct vio_dev;
+struct vio_driver;
+struct vio_device_id;
+struct TceTable;
+
+int vio_register_driver(struct vio_driver *drv);
+int vio_unregister_driver(struct vio_driver *drv);
+const struct vio_device_id * vio_match_device(const struct vio_device_id *ids, 
+						const struct vio_dev *dev);
+struct vio_dev * __devinit vio_register_device(struct device_node *node_vdev);
+int __devinit vio_unregister_device(struct vio_dev *dev);
+const void * vio_get_attribute(struct vio_dev *vdev, void* which, int* length);
+int vio_get_irq(struct vio_dev *dev);
+struct TceTable * vio_build_tce_table(struct vio_dev *dev);
+int vio_enable_interrupts(struct vio_dev *dev);
+int vio_disable_interrupts(struct vio_dev *dev);
+
+dma_addr_t vio_map_single(struct vio_dev *dev, void *vaddr, 
+			  size_t size, int direction);
+void vio_unmap_single(struct vio_dev *dev, dma_addr_t dma_handle, 
+		      size_t size, int direction);
+int vio_map_sg(struct vio_dev *vdev, struct scatterlist *sglist, 
+	       int nelems, int direction);
+void vio_unmap_sg(struct vio_dev *vdev, struct scatterlist *sglist, 
+		  int nelems, int direction);
+void *vio_alloc_consistent(struct vio_dev *dev, size_t size, 
+			   dma_addr_t *dma_handle);
+void vio_free_consistent(struct vio_dev *dev, size_t size, void *vaddr, 
+			 dma_addr_t dma_handle);
+
+struct vio_device_id {
+	char *type;
+	char *compat;
+/* I don't think we need this
+	unsigned long driver_data;	*/ /* Data private to the driver */
+};
+
+struct vio_driver {
+	struct list_head node;
+	char *name;
+	const struct vio_device_id *id_table;	/* NULL if wants all devices */
+	int  (*probe)  (struct vio_dev *dev, const struct vio_device_id *id);	/* New device inserted */
+	void (*remove) (struct vio_dev *dev);	/* Device removed (NULL if not a hot-plug capable driver) */
+	unsigned long driver_data;
+};
+
+struct vio_bus;
+/*
+ * The vio_dev structure is used to describe virtual I/O devices.
+ */
+struct vio_dev {
+	struct list_head devices_list;   /* node in list of all vio devices */
+	struct device_node *archdata;    /* Open Firmware node */
+	struct vio_bus *bus;            /* bus this device is on */
+	struct vio_driver *driver;      /* owning driver */
+	void *driver_data;              /* data private to the driver */
+	unsigned long unit_address;	
+
+	struct TceTable *tce_table; /* vio_map_* uses this */
+	unsigned int irq;
+	struct proc_dir_entry *procent; /* device entry in /proc/bus/vio */
+};
+
+struct vio_bus {
+	struct list_head devices;       /* list of virtual devices */
+};
+
+
+static inline int vio_module_init(struct vio_driver *drv)
+{
+        int rc = vio_register_driver (drv);
+
+        if (rc > 0)
+                return 0;
+
+        /* iff CONFIG_HOTPLUG and built into kernel, we should
+         * leave the driver around for future hotplug events.
+         * For the module case, a hotplug daemon of some sort
+         * should load a module in response to an insert event. */
+#if defined(CONFIG_HOTPLUG) && !defined(MODULE)
+        if (rc == 0)
+                return 0;
+#else
+        if (rc == 0)
+                rc = -ENODEV;
+#endif
+
+        /* if we get here, we need to clean up vio driver instance
+         * and return some sort of error */
+
+        return rc;
+}
+
+#endif /* _PHYP_H */
diff -puN include/asm-ppc/byteorder.h~linus include/asm-ppc/byteorder.h
--- 25/include/asm-ppc/byteorder.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc/byteorder.h	2004-01-19 22:17:24.000000000 -0800
@@ -2,6 +2,7 @@
 #define _PPC_BYTEORDER_H
 
 #include <asm/types.h>
+#include <linux/compiler.h>
 
 #ifdef __GNUC__
 #ifdef __KERNEL__
@@ -32,7 +33,7 @@ extern __inline__ void st_le32(volatile 
 	__asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr));
 }
 
-static __inline__ __const__ __u16 ___arch__swab16(__u16 value)
+static __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 value)
 {
 	__u16 result;
 
@@ -40,7 +41,7 @@ static __inline__ __const__ __u16 ___arc
 	return result;
 }
 
-static __inline__ __const__ __u32 ___arch__swab32(__u32 value)
+static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 value)
 {
 	__u32 result;
 
diff -puN include/asm-ppc/highmem.h~linus include/asm-ppc/highmem.h
--- 25/include/asm-ppc/highmem.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc/highmem.h	2004-01-19 22:17:24.000000000 -0800
@@ -63,8 +63,7 @@ static inline void *kmap(struct page *pa
 
 static inline void kunmap(struct page *page)
 {
-	if (in_interrupt())
-		BUG();
+	BUG_ON(in_interrupt());
 	if (page < highmem_start_page)
 		return;
 	kunmap_high(page);
@@ -89,8 +88,7 @@ static inline void *kmap_atomic(struct p
 	idx = type + KM_TYPE_NR*smp_processor_id();
 	vaddr = KMAP_FIX_BEGIN + idx * PAGE_SIZE;
 #if HIGHMEM_DEBUG
-	if (!pte_none(*(kmap_pte+idx)))
-		BUG();
+	BUG_ON(!pte_none(*(kmap_pte+idx)));
 #endif
 	set_pte(kmap_pte+idx, mk_pte(page, kmap_prot));
 	flush_tlb_page(0, vaddr);
@@ -110,8 +108,7 @@ static inline void kunmap_atomic(void *k
 		return;
 	}
 
-	if (vaddr != KMAP_FIX_BEGIN + idx * PAGE_SIZE)
-		BUG();
+	BUG_ON(vaddr != KMAP_FIX_BEGIN + idx * PAGE_SIZE);
 
 	/*
 	 * force other mappings to Oops if they'll try to access
diff -puN include/asm-ppc/ibm4xx.h~linus include/asm-ppc/ibm4xx.h
--- 25/include/asm-ppc/ibm4xx.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc/ibm4xx.h	2004-01-19 22:17:24.000000000 -0800
@@ -90,8 +90,6 @@ void ppc4xx_init(unsigned long r3, unsig
 #include <platforms/4xx/ocotea.h>
 #endif
 
-#endif /* CONFIG_40x */
-
 #ifndef __ASSEMBLY__
 /*
  * The "residual" board information structure the boot loader passes
@@ -99,6 +97,7 @@ void ppc4xx_init(unsigned long r3, unsig
  */
 extern bd_t __res;
 #endif
+#endif /* CONFIG_40x */
 
 #endif /* __ASM_IBM4XX_H__ */
 #endif /* __KERNEL__ */
diff -puN include/asm-ppc/mpc8260.h~linus include/asm-ppc/mpc8260.h
--- 25/include/asm-ppc/mpc8260.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc/mpc8260.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,15 +1,36 @@
-/* This is the single file included by all MPC8260 build options.
+/*
  * Since there are many different boards and no standard configuration,
  * we have a unique include file for each.  Rather than change every
  * file that has to include MPC8260 configuration, they all include
  * this one and the configuration switching is done here.
  */
 #ifdef __KERNEL__
-#ifndef __CONFIG_8260_DEFS
-#define __CONFIG_8260_DEFS
+#ifndef __ASM_PPC_MPC8260_H__
+#define __ASM_PPC_MPC8260_H__
 
 #include <linux/config.h>
-#include <platforms/mpc82xx.h>
+
+#ifdef CONFIG_8260
+
+#ifdef CONFIG_EST8260
+#include <platforms/est8260.h>
+#endif
+
+#ifdef CONFIG_SBS8260
+#include <platforms/sbs8260.h>
+#endif
+
+#ifdef CONFIG_RPX6
+#include <platforms/rpxsuper.h>
+#endif
+
+#ifdef CONFIG_WILLOW
+#include <platforms/willow.h>
+#endif
+
+#ifdef CONFIG_TQM8260
+#include <platforms/tqm8260.h>
+#endif
 
 /* Make sure the memory translation stuff is there if PCI not used.
  */
@@ -34,10 +55,13 @@
 #define IO_VIRT_ADDR	IO_PHYS_ADDR
 #endif
 
+#ifndef __ASSEMBLY__
 /* The "residual" data board information structure the boot loader
  * hands to us.
  */
 extern unsigned char __res[];
+#endif
 
-#endif /* !__CONFIG_8260_DEFS */
+#endif /* CONFIG_8260 */
+#endif /* !__ASM_PPC_MPC8260_H__ */
 #endif /* __KERNEL__ */
diff -puN include/asm-ppc/pci.h~linus include/asm-ppc/pci.h
--- 25/include/asm-ppc/pci.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc/pci.h	2004-01-19 22:17:24.000000000 -0800
@@ -105,8 +105,7 @@ static inline dma_addr_t pci_map_single(
 static inline void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
 				    size_t size, int direction)
 {
-	if (direction == PCI_DMA_NONE)
-		BUG();
+	BUG_ON(direction == PCI_DMA_NONE);
 	/* nothing to do */
 }
 
@@ -134,8 +133,7 @@ static inline dma_addr_t pci_map_page(st
 static inline void pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address,
 				  size_t size, int direction)
 {
-	if (direction == PCI_DMA_NONE)
-		BUG();
+	BUG_ON(direction == PCI_DMA_NONE);
 	/* Nothing to do */
 }
 
@@ -159,8 +157,7 @@ static inline int pci_map_sg(struct pci_
 {
 	int i;
 
-	if (direction == PCI_DMA_NONE)
-		BUG();
+	BUG_ON(direction == PCI_DMA_NONE);
 
 	/*
 	 * temporary 2.4 hack
diff -puN include/asm-ppc/pgtable.h~linus include/asm-ppc/pgtable.h
--- 25/include/asm-ppc/pgtable.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc/pgtable.h	2004-01-19 22:17:24.000000000 -0800
@@ -661,5 +661,14 @@ extern void kernel_set_cachemode (unsign
 typedef pte_t *pte_addr_t;
 
 #endif /* !__ASSEMBLY__ */
+
+#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
+#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
+#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
+#define __HAVE_ARCH_PTEP_SET_WRPROTECT
+#define __HAVE_ARCH_PTEP_MKDIRTY
+#define __HAVE_ARCH_PTE_SAME
+#include <asm-generic/pgtable.h>
+
 #endif /* _PPC_PGTABLE_H */
 #endif /* __KERNEL__ */
diff -puN include/asm-ppc/smp.h~linus include/asm-ppc/smp.h
--- 25/include/asm-ppc/smp.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc/smp.h	2004-01-19 22:17:24.000000000 -0800
@@ -48,7 +48,6 @@ extern void smp_local_timer_interrupt(st
 #define smp_processor_id() (current_thread_info()->cpu)
 
 #define cpu_online(cpu) cpu_isset(cpu, cpu_online_map)
-#define cpu_possible(cpu) cpu_isset(cpu, cpu_possible_map)
 
 extern int __cpu_up(unsigned int cpu);
 
diff -puN include/asm-ppc/socket.h~linus include/asm-ppc/socket.h
--- 25/include/asm-ppc/socket.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc/socket.h	2004-01-19 22:17:24.000000000 -0800
@@ -51,6 +51,8 @@
 
 #define SO_ACCEPTCONN		30
 
+#define SO_PEERSEC		31
+
 /* Nast libc5 fixup - bletch */
 #if defined(__KERNEL__)
 /* Socket types. */
diff -puN include/asm-ppc/uaccess.h~linus include/asm-ppc/uaccess.h
--- 25/include/asm-ppc/uaccess.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc/uaccess.h	2004-01-19 22:17:24.000000000 -0800
@@ -60,8 +60,6 @@ struct exception_table_entry
 	unsigned long insn, fixup;
 };
 
-extern void sort_exception_table(void);
-
 /*
  * These are the main single-value transfer routines.  They automatically
  * use the right size if we just have the right pointer type.
diff -puN include/asm-ppc/unistd.h~linus include/asm-ppc/unistd.h
--- 25/include/asm-ppc/unistd.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-ppc/unistd.h	2004-01-19 22:17:24.000000000 -0800
@@ -259,8 +259,9 @@
 #define __NR_statfs64		252
 #define __NR_fstatfs64		253
 #define __NR_fadvise64_64	254
+#define __NR_rtas		255
 
-#define __NR_syscalls		255
+#define __NR_syscalls		256
 
 #define __NR(n)	#n
 
diff -puN include/asm-s390/bitops.h~linus include/asm-s390/bitops.h
--- 25/include/asm-s390/bitops.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/bitops.h	2004-01-19 22:17:24.000000000 -0800
@@ -526,10 +526,10 @@ __constant_test_bit(unsigned long nr, co
  * Find-bit routines..
  */
 static inline int
-find_first_zero_bit(unsigned long * addr, unsigned size)
+find_first_zero_bit(unsigned long * addr, unsigned int size)
 {
 	unsigned long cmp, count;
-        int res;
+        unsigned int res;
 
         if (!size)
                 return 0;
@@ -565,10 +565,10 @@ find_first_zero_bit(unsigned long * addr
 }
 
 static inline int
-find_first_bit(unsigned long * addr, unsigned size)
+find_first_bit(unsigned long * addr, unsigned int size)
 {
 	unsigned long cmp, count;
-        int res;
+        unsigned int res;
 
         if (!size)
                 return 0;
@@ -1022,7 +1022,7 @@ extern inline int ffs (int x)
 /*
  * fls: find last bit set.
  */
-extern __inline__ int fls(int x)
+static __inline__ int fls(int x)
 {
 	int r = 32;
 
@@ -1095,10 +1095,10 @@ extern __inline__ int fls(int x)
 #ifndef __s390x__
 
 static inline int 
-ext2_find_first_zero_bit(void *vaddr, unsigned size)
+ext2_find_first_zero_bit(void *vaddr, unsigned int size)
 {
 	unsigned long cmp, count;
-        int res;
+        unsigned int res;
 
         if (!size)
                 return 0;
@@ -1135,12 +1135,12 @@ ext2_find_first_zero_bit(void *vaddr, un
 }
 
 static inline int 
-ext2_find_next_zero_bit(void *vaddr, unsigned size, unsigned offset)
+ext2_find_next_zero_bit(void *vaddr, unsigned int size, unsigned offset)
 {
         unsigned long *addr = vaddr;
         unsigned long *p = addr + (offset >> 5);
         unsigned long word, reg;
-        int bit = offset & 31UL, res;
+        unsigned int bit = offset & 31UL, res;
 
         if (offset >= size)
                 return size;
diff -puN include/asm-s390/bug.h~linus include/asm-s390/bug.h
--- 25/include/asm-s390/bug.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/bug.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,6 +1,8 @@
 #ifndef _S390_BUG_H
 #define _S390_BUG_H
 
+#include <linux/kernel.h>
+
 #define BUG() do { \
         printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
         __asm__ __volatile__(".long 0"); \
diff -puN include/asm-s390/byteorder.h~linus include/asm-s390/byteorder.h
--- 25/include/asm-s390/byteorder.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/byteorder.h	2004-01-19 22:17:24.000000000 -0800
@@ -14,7 +14,7 @@
 #ifdef __GNUC__
 
 #ifdef __s390x__
-static __inline__ __const__ __u64 ___arch__swab64p(__u64 *x)
+static __inline__ __u64 ___arch__swab64p(__u64 *x)
 {
 	__u64 result;
 
@@ -24,7 +24,7 @@ static __inline__ __const__ __u64 ___arc
 	return result;
 }
 
-static __inline__ __const__ __u64 ___arch__swab64(__u64 x)
+static __inline__ __u64 ___arch__swab64(__u64 x)
 {
 	__u64 result;
 
@@ -40,7 +40,7 @@ static __inline__ void ___arch__swab64s(
 }
 #endif /* __s390x__ */
 
-static __inline__ __const__ __u32 ___arch__swab32p(__u32 *x)
+static __inline__ __u32 ___arch__swab32p(__u32 *x)
 {
 	__u32 result;
 	
@@ -58,7 +58,7 @@ static __inline__ __const__ __u32 ___arc
 	return result;
 }
 
-static __inline__ __const__ __u32 ___arch__swab32(__u32 x)
+static __inline__ __u32 ___arch__swab32(__u32 x)
 {
 #ifndef __s390x__
 	return ___arch__swab32p(&x);
@@ -77,7 +77,7 @@ static __inline__ void ___arch__swab32s(
 	*x = ___arch__swab32p(x);
 }
 
-static __inline__ __const__ __u16 ___arch__swab16p(__u16 *x)
+static __inline__ __u16 ___arch__swab16p(__u16 *x)
 {
 	__u16 result;
 	
@@ -93,7 +93,7 @@ static __inline__ __const__ __u16 ___arc
 	return result;
 }
 
-static __inline__ __const__ __u16 ___arch__swab16(__u16 x)
+static __inline__ __u16 ___arch__swab16(__u16 x)
 {
 	return ___arch__swab16p(&x);
 }
diff -puN include/asm-s390/ccwdev.h~linus include/asm-s390/ccwdev.h
--- 25/include/asm-s390/ccwdev.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/ccwdev.h	2004-01-19 22:17:24.000000000 -0800
@@ -89,10 +89,11 @@ struct ccw_driver {
 	struct module *owner;		/* for automatic MOD_INC_USE_COUNT   */
 	struct ccw_device_id *ids;	/* probe driver with these devs      */
 	int (*probe) (struct ccw_device *); /* ask driver to probe dev 	     */
-	int (*remove) (struct ccw_device *);
+	void (*remove) (struct ccw_device *);
 					/* device is no longer available     */
 	int (*set_online) (struct ccw_device *);
 	int (*set_offline) (struct ccw_device *);
+	int (*notify) (struct ccw_device *, int);
 	struct device_driver driver;	/* higher level structure, don't init
 					   this from your driver	     */
 	char *name;
@@ -149,8 +150,8 @@ extern int ccw_device_clear(struct ccw_d
 extern int read_dev_chars(struct ccw_device *cdev, void **buffer, int length);
 extern int read_conf_data(struct ccw_device *cdev, void **buffer, int *length);
 
-extern void ccw_device_set_online(struct ccw_device *cdev);
-extern void ccw_device_set_offline(struct ccw_device *cdev);
+extern int ccw_device_set_online(struct ccw_device *cdev);
+extern int ccw_device_set_offline(struct ccw_device *cdev);
 
 
 extern struct ciw *ccw_device_get_ciw(struct ccw_device *, __u32 cmd);
@@ -167,4 +168,7 @@ extern struct ccw_device *ccw_device_pro
 extern int _ccw_device_get_device_number(struct ccw_device *);
 extern int _ccw_device_get_subchannel_number(struct ccw_device *);
 
+extern struct device *s390_root_dev_register(const char *);
+extern void s390_root_dev_unregister(struct device *);
+
 #endif /* _S390_CCWDEV_H_ */
diff -puN include/asm-s390/ccwgroup.h~linus include/asm-s390/ccwgroup.h
--- 25/include/asm-s390/ccwgroup.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/ccwgroup.h	2004-01-19 22:17:24.000000000 -0800
@@ -21,8 +21,7 @@ struct ccwgroup_driver {
 	unsigned long driver_id;
 
 	int (*probe) (struct ccwgroup_device *);
-	int (*remove) (struct ccwgroup_device *);
-	int (*release) (struct ccwgroup_driver *);
+	void (*remove) (struct ccwgroup_device *);
 	int (*set_online) (struct ccwgroup_device *);
 	int (*set_offline) (struct ccwgroup_device *);
 
@@ -37,7 +36,7 @@ extern int ccwgroup_create (struct devic
 			    int argc, char *argv[]);
 
 extern int ccwgroup_probe_ccwdev(struct ccw_device *cdev);
-extern int ccwgroup_remove_ccwdev(struct ccw_device *cdev);
+extern void ccwgroup_remove_ccwdev(struct ccw_device *cdev);
 
 #define to_ccwgroupdev(x) container_of((x), struct ccwgroup_device, dev)
 #define to_ccwgroupdrv(x) container_of((x), struct ccwgroup_driver, driver)
diff -puN include/asm-s390/checksum.h~linus include/asm-s390/checksum.h
--- 25/include/asm-s390/checksum.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/checksum.h	2004-01-19 22:17:24.000000000 -0800
@@ -70,7 +70,7 @@ csum_partial_inline(const unsigned char 
 	__asm__ __volatile__ (
 		"0:  cksm %0,%1\n"    /* do checksum on longs */
 		"    jo   0b\n"
-                : "+&d" (sum), "+&a" (rp) : : "cc" );
+                : "+&d" (sum), "+&a" (rp) : : "cc", "memory" );
 #else /* __s390x__ */
 	__asm__ __volatile__ (
 		"    lgr  2,%1\n"    /* address in gpr 2 */
@@ -79,7 +79,7 @@ csum_partial_inline(const unsigned char 
 		"    jo   0b\n"
                 : "+&d" (sum)
 		: "d" (buff), "d" (len)
-                : "cc", "2", "3" );
+                : "cc", "memory", "2", "3" );
 #endif /* __s390x__ */
 	return sum;
 }
@@ -165,7 +165,7 @@ ip_fast_csum(unsigned char *iph, unsigne
 		"    sr   %0,%0\n"   /* set sum to zero */
                 "0:  cksm %0,%1\n"   /* do checksum on longs */
                 "    jo   0b\n"
-                : "=&d" (sum), "+&a" (rp) : : "cc" );
+                : "=&d" (sum), "+&a" (rp) : : "cc", "memory" );
 #else /* __s390x__ */
         __asm__ __volatile__ (
 		"    slgr %0,%0\n"   /* set sum to zero */
@@ -175,7 +175,7 @@ ip_fast_csum(unsigned char *iph, unsigne
                 "    jo   0b\n"
                 : "=&d" (sum)
                 : "d" (iph), "d" (ihl*4)
-                : "cc", "2", "3" );
+                : "cc", "memory", "2", "3" );
 #endif /* __s390x__ */
         return csum_fold(sum);
 }
diff -puN include/asm-s390/cio.h~linus include/asm-s390/cio.h
--- 25/include/asm-s390/cio.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/cio.h	2004-01-19 22:17:24.000000000 -0800
@@ -247,6 +247,14 @@ struct ciw {
 #define DOIO_DENY_PREFETCH	 0x0002 /* don't allow for CCW prefetch */
 #define DOIO_SUPPRESS_INTER	 0x0004 /* suppress intermediate inter. */
 					/* ... for suspended CCWs */
+/* Device or subchannel gone. */
+#define CIO_GONE       0x0001
+/* No path to device. */
+#define CIO_NO_PATH    0x0002
+/* Device has appeared. */
+#define CIO_OPER       0x0004
+/* Sick revalidation of device. */
+#define CIO_REVALIDATE 0x0008
 
 struct diag210 {
 	__u16 vrdcdvno : 16;   /* device number (input) */
diff -puN include/asm-s390/dasd.h~linus include/asm-s390/dasd.h
--- 25/include/asm-s390/dasd.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/dasd.h	2004-01-19 22:17:24.000000000 -0800
@@ -8,7 +8,7 @@
  * any future changes wrt the API will result in a change of the APIVERSION reported
  * to userspace by the DASDAPIVER-ioctl
  *
- * $Revision: 1.4 $
+ * $Revision: 1.6 $
  *
  */
 
@@ -69,9 +69,11 @@ typedef struct dasd_information2_t {
  * values to be used for dasd_information_t.features
  * 0x00: default features
  * 0x01: readonly (ro)
+ * 0x02: use diag discipline (diag)
  */
 #define DASD_FEATURE_DEFAULT  0
 #define DASD_FEATURE_READONLY 1
+#define DASD_FEATURE_USEDIAG  2
 
 #define DASD_PARTN_BITS 2
 
@@ -234,6 +236,8 @@ typedef struct attrib_data_t {
 #define BIODASDINFO2   _IOR(DASD_IOCTL_LETTER,3,dasd_information2_t)
 /* Performance Statistics Read */
 #define BIODASDPSRD    _IOR(DASD_IOCTL_LETTER,4,dasd_rssd_perf_stats_t)
+/* Get Attributes (cache operations) */
+#define BIODASDGATTR   _IOR(DASD_IOCTL_LETTER,5,attrib_data_t) 
 
 
 /* #define BIODASDFORMAT  _IOW(IOCTL_LETTER,0,format_data_t) , deprecated */
diff -puN include/asm-s390/hardirq.h~linus include/asm-s390/hardirq.h
--- 25/include/asm-s390/hardirq.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/hardirq.h	2004-01-19 22:17:24.000000000 -0800
@@ -25,9 +25,17 @@ typedef struct {
 	unsigned int __softirq_pending;
 } irq_cpustat_t;
 
-#define softirq_pending(cpu) (lowcore_ptr[(cpu)]->softirq_pending)
 #define local_softirq_pending() (S390_lowcore.softirq_pending)
 
+/* this is always called with cpu == smp_processor_id() at the moment */
+static inline __u32
+softirq_pending(unsigned int cpu)
+{
+	if (cpu == smp_processor_id())
+		return local_softirq_pending();
+	return lowcore_ptr[cpu]->softirq_pending;
+}
+
 #define __ARCH_IRQ_STAT
 
 /*
@@ -42,12 +50,12 @@ typedef struct {
  *
  * PREEMPT_MASK: 0x000000ff
  * SOFTIRQ_MASK: 0x0000ff00
- * HARDIRQ_MASK: 0x00010000
+ * HARDIRQ_MASK: 0x00ff0000
  */
 
 #define PREEMPT_BITS	8
 #define SOFTIRQ_BITS	8
-#define HARDIRQ_BITS	1
+#define HARDIRQ_BITS	8
 
 #define PREEMPT_SHIFT	0
 #define SOFTIRQ_SHIFT	(PREEMPT_SHIFT + PREEMPT_BITS)
@@ -81,7 +89,6 @@ typedef struct {
 
 #define irq_enter()							\
 do {									\
-	BUG_ON( hardirq_count() );					\
 	(preempt_count() += HARDIRQ_OFFSET);				\
 } while(0)
 	
diff -puN include/asm-s390/idals.h~linus include/asm-s390/idals.h
--- 25/include/asm-s390/idals.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/idals.h	2004-01-19 22:17:24.000000000 -0800
@@ -223,8 +223,7 @@ idal_buffer_to_user(struct idal_buffer *
 	size_t left;
 	int i;
 
-	if (count > ib->size)
-		BUG();
+	BUG_ON(count > ib->size);
 	for (i = 0; count > IDA_BLOCK_SIZE; i++) {
 		left = copy_to_user(to, ib->data[i], IDA_BLOCK_SIZE);
 		if (left)
@@ -244,8 +243,7 @@ idal_buffer_from_user(struct idal_buffer
 	size_t left;
 	int i;
 
-	if (count > ib->size)
-		BUG();
+	BUG_ON(count > ib->size);
 	for (i = 0; count > IDA_BLOCK_SIZE; i++) {
 		left = copy_from_user(ib->data[i], from, IDA_BLOCK_SIZE);
 		if (left)
diff -puN include/asm-s390/ioctl.h~linus include/asm-s390/ioctl.h
--- 25/include/asm-s390/ioctl.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/ioctl.h	2004-01-19 22:17:24.000000000 -0800
@@ -55,11 +55,21 @@
 	 ((nr)   << _IOC_NRSHIFT) | \
 	 ((size) << _IOC_SIZESHIFT))
 
+/* provoke compile error for invalid uses of size argument */
+extern unsigned long __invalid_size_argument_for_IOC;
+#define _IOC_TYPECHECK(t) \
+	((sizeof(t) == sizeof(t[1]) && \
+	  sizeof(t) < (1 << _IOC_SIZEBITS)) ? \
+	  sizeof(t) : __invalid_size_argument_for_IOC)
+
 /* used to create numbers */
 #define _IO(type,nr)		_IOC(_IOC_NONE,(type),(nr),0)
-#define _IOR(type,nr,size)	_IOC(_IOC_READ,(type),(nr),sizeof(size))
-#define _IOW(type,nr,size)	_IOC(_IOC_WRITE,(type),(nr),sizeof(size))
-#define _IOWR(type,nr,size)	_IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
+#define _IOR(type,nr,size)	_IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size)))
+#define _IOW(type,nr,size)	_IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
+#define _IOWR(type,nr,size)	_IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
+#define _IOR_BAD(type,nr,size)	_IOC(_IOC_READ,(type),(nr),sizeof(size))
+#define _IOW_BAD(type,nr,size)	_IOC(_IOC_WRITE,(type),(nr),sizeof(size))
+#define _IOWR_BAD(type,nr,size)	_IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
 
 /* used to decode ioctl numbers.. */
 #define _IOC_DIR(nr)		(((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
diff -puN include/asm-s390/mmu_context.h~linus include/asm-s390/mmu_context.h
--- 25/include/asm-s390/mmu_context.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/mmu_context.h	2004-01-19 22:17:24.000000000 -0800
@@ -14,7 +14,7 @@
  */
 #define init_new_context(tsk,mm)        0
 
-#define destroy_context(mm)             flush_tlb_mm(mm)
+#define destroy_context(mm)             do { } while (0)
 
 static inline void enter_lazy_tlb(struct mm_struct *mm,
                                   struct task_struct *tsk)
diff -puN include/asm-s390/pgalloc.h~linus include/asm-s390/pgalloc.h
--- 25/include/asm-s390/pgalloc.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/pgalloc.h	2004-01-19 22:17:24.000000000 -0800
@@ -84,7 +84,11 @@ static inline void pmd_free (pmd_t *pmd)
 	free_pages((unsigned long) pmd, 2);
 }
 
-#define __pmd_free_tlb(tlb,pmd) pmd_free(pmd)
+#define __pmd_free_tlb(tlb,pmd)			\
+	do {					\
+		tlb_flush_mmu(tlb, 0, 0);	\
+		pmd_free(pmd);			\
+	 } while (0)
 
 static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
 {
@@ -146,7 +150,7 @@ static inline void pte_free(struct page 
         __free_page(pte);
 }
 
-#define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
+#define __pte_free_tlb(tlb,pte) tlb_remove_page(tlb,pte)
 
 /*
  * This establishes kernel virtual mappings (e.g., as a result of a
@@ -155,29 +159,4 @@ static inline void pte_free(struct page 
  */
 #define set_pgdir(addr,entry) do { } while(0)
 
-static inline pte_t ptep_invalidate(struct vm_area_struct *vma, 
-                                    unsigned long address, pte_t *ptep)
-{
-	pte_t pte = *ptep;
-#ifndef __s390x__
-	if (!(pte_val(pte) & _PAGE_INVALID)) {
-		/* S390 has 1mb segments, we are emulating 4MB segments */
-		pte_t *pto = (pte_t *) (((unsigned long) ptep) & 0x7ffffc00);
-		__asm__ __volatile__ ("ipte %0,%1" : : "a" (pto), "a" (address));
-	}
-#else /* __s390x__ */
-	if (!(pte_val(pte) & _PAGE_INVALID)) 
-		__asm__ __volatile__ ("ipte %0,%1" : : "a" (ptep), "a" (address));
-#endif /* __s390x__ */
-	pte_clear(ptep);
-	return pte;
-}
-
-static inline void ptep_establish(struct vm_area_struct *vma, 
-                                  unsigned long address, pte_t *ptep, pte_t entry)
-{
-	ptep_invalidate(vma, address, ptep);
-	set_pte(ptep, entry);
-}
-
 #endif /* _S390_PGALLOC_H */
diff -puN include/asm-s390/pgtable.h~linus include/asm-s390/pgtable.h
--- 25/include/asm-s390/pgtable.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/pgtable.h	2004-01-19 22:17:24.000000000 -0800
@@ -29,9 +29,12 @@
  * the S390 page table tree.
  */
 #ifndef __ASSEMBLY__
+#include <asm/bug.h>
 #include <asm/processor.h>
 #include <linux/threads.h>
 
+struct vm_area_struct; /* forward declaration (include/linux/mm.h) */
+
 extern pgd_t swapper_pg_dir[] __attribute__ ((aligned (4096)));
 extern void paging_init(void);
 
@@ -210,9 +213,6 @@ extern char empty_zero_page[PAGE_SIZE];
 #define _PAGE_RO        0x200          /* HW read-only                     */
 #define _PAGE_INVALID   0x400          /* HW invalid                       */
 
-/* Software bits in the page table entry */
-#define _PAGE_ISCLEAN   0x002
-
 /* Mask and four different kinds of invalid pages. */
 #define _PAGE_INVALID_MASK	0x601
 #define _PAGE_INVALID_EMPTY	0x400
@@ -280,12 +280,12 @@ extern char empty_zero_page[PAGE_SIZE];
  * No mapping available
  */
 #define PAGE_NONE_SHARED  __pgprot(_PAGE_INVALID_NONE)
-#define PAGE_NONE_PRIVATE __pgprot(_PAGE_INVALID_NONE|_PAGE_ISCLEAN)
+#define PAGE_NONE_PRIVATE __pgprot(_PAGE_INVALID_NONE)
 #define PAGE_RO_SHARED	  __pgprot(_PAGE_RO)
-#define PAGE_RO_PRIVATE	  __pgprot(_PAGE_RO|_PAGE_ISCLEAN)
-#define PAGE_COPY	  __pgprot(_PAGE_RO|_PAGE_ISCLEAN)
+#define PAGE_RO_PRIVATE	  __pgprot(_PAGE_RO)
+#define PAGE_COPY	  __pgprot(_PAGE_RO)
 #define PAGE_SHARED	  __pgprot(0)
-#define PAGE_KERNEL	  __pgprot(_PAGE_ISCLEAN)
+#define PAGE_KERNEL	  __pgprot(0)
 
 /*
  * The S390 can't do page protection for execute, and considers that the
@@ -400,20 +400,20 @@ extern inline int pte_write(pte_t pte)
 
 extern inline int pte_dirty(pte_t pte)
 {
-	int skey;
-
-	if (pte_val(pte) & _PAGE_ISCLEAN)
-		return 0;
-	asm volatile ("iske %0,%1" : "=d" (skey) : "a" (pte_val(pte)));
-	return skey & _PAGE_CHANGED;
+	/* A pte is neither clean nor dirty on s/390. The dirty bit
+	 * is in the storage key. See page_test_and_clear_dirty for
+	 * details.
+	 */
+	return 0;
 }
 
 extern inline int pte_young(pte_t pte)
 {
-	int skey;
-
-	asm volatile ("iske %0,%1" : "=d" (skey) : "a" (pte_val(pte)));
-	return skey & _PAGE_REFERENCED;
+	/* A pte is neither young nor old on s/390. The young bit
+	 * is in the storage key. See page_test_and_clear_young for
+	 * details.
+	 */
+	return 0;
 }
 
 /*
@@ -458,20 +458,22 @@ extern inline void pte_clear(pte_t *ptep
  */
 extern inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
-	pte_val(pte) &= PAGE_MASK | _PAGE_ISCLEAN;
-	pte_val(pte) |= pgprot_val(newprot) & ~_PAGE_ISCLEAN;
+	pte_val(pte) &= PAGE_MASK;
+	pte_val(pte) |= pgprot_val(newprot);
 	return pte;
 }
 
 extern inline pte_t pte_wrprotect(pte_t pte)
 {
-	pte_val(pte) |= _PAGE_RO;
+	/* Do not clobber _PAGE_INVALID_NONE pages!  */
+	if (!(pte_val(pte) & _PAGE_INVALID))
+		pte_val(pte) |= _PAGE_RO;
 	return pte;
 }
 
 extern inline pte_t pte_mkwrite(pte_t pte) 
 {
-	pte_val(pte) &= ~(_PAGE_RO | _PAGE_ISCLEAN);
+	pte_val(pte) &= ~_PAGE_RO;
 	return pte;
 }
 
@@ -490,50 +492,49 @@ extern inline pte_t pte_mkdirty(pte_t pt
 	 * sske instruction is slow. It is faster to let the
 	 * next instruction set the dirty bit.
 	 */
-	pte_val(pte) &= ~ _PAGE_ISCLEAN;
 	return pte;
 }
 
 extern inline pte_t pte_mkold(pte_t pte)
 {
-	asm volatile ("rrbe 0,%0" : : "a" (pte_val(pte)) : "cc" );
+	/* S/390 doesn't keep its dirty/referenced bit in the pte.
+	 * There is no point in clearing the real referenced bit.
+	 */
 	return pte;
 }
 
 extern inline pte_t pte_mkyoung(pte_t pte)
 {
-	/* To set the referenced bit we read the first word from the real
-	 * page with a special instruction: load using real address (lura).
-	 * Isn't S/390 a nice architecture ?! */
-	asm volatile ("lura 0,%0" : : "a" (pte_val(pte) & PAGE_MASK) : "0" );
+	/* S/390 doesn't keep its dirty/referenced bit in the pte.
+	 * There is no point in setting the real referenced bit.
+	 */
 	return pte;
 }
 
 static inline int ptep_test_and_clear_young(pte_t *ptep)
 {
-	int ccode;
+	return 0;
+}
 
-	asm volatile ("rrbe 0,%1\n\t"
-		      "ipm  %0\n\t"
-		      "srl  %0,28\n\t" 
-                      : "=d" (ccode) : "a" (pte_val(*ptep)) : "cc" );
-	return ccode & 2;
+static inline int
+ptep_clear_flush_young(struct vm_area_struct *vma,
+			unsigned long address, pte_t *ptep)
+{
+	/* No need to flush TLB; bits are in storage key */
+	return ptep_test_and_clear_young(ptep);
 }
 
 static inline int ptep_test_and_clear_dirty(pte_t *ptep)
 {
-	int skey;
+	return 0;
+}
 
-	if (pte_val(*ptep) & _PAGE_ISCLEAN)
-		return 0;
-	asm volatile ("iske %0,%1" : "=d" (skey) : "a" (*ptep));
-	if ((skey & _PAGE_CHANGED) == 0)
-		return 0;
-	/* We can't clear the changed bit atomically. For now we
-         * clear (!) the page referenced bit. */
-	asm volatile ("sske %0,%1" 
-	              : : "d" (0), "a" (*ptep));
-	return 1;
+static inline int
+ptep_clear_flush_dirty(struct vm_area_struct *vma,
+			unsigned long address, pte_t *ptep)
+{
+	/* No need to flush TLB; bits are in storage key */
+	return ptep_test_and_clear_dirty(ptep);
 }
 
 static inline pte_t ptep_get_and_clear(pte_t *ptep)
@@ -543,6 +544,25 @@ static inline pte_t ptep_get_and_clear(p
 	return pte;
 }
 
+static inline pte_t
+ptep_clear_flush(struct vm_area_struct *vma,
+		 unsigned long address, pte_t *ptep)
+{
+	pte_t pte = *ptep;
+#ifndef __s390x__
+	if (!(pte_val(pte) & _PAGE_INVALID)) {
+		/* S390 has 1mb segments, we are emulating 4MB segments */
+		pte_t *pto = (pte_t *) (((unsigned long) ptep) & 0x7ffffc00);
+		__asm__ __volatile__ ("ipte %0,%1" : : "a" (pto), "a" (address));
+	}
+#else /* __s390x__ */
+	if (!(pte_val(pte) & _PAGE_INVALID)) 
+		__asm__ __volatile__ ("ipte %0,%1" : : "a" (ptep), "a" (address));
+#endif /* __s390x__ */
+	pte_clear(ptep);
+	return pte;
+}
+
 static inline void ptep_set_wrprotect(pte_t *ptep)
 {
 	pte_t old_pte = *ptep;
@@ -554,6 +574,50 @@ static inline void ptep_mkdirty(pte_t *p
 	pte_mkdirty(*ptep);
 }
 
+static inline void
+ptep_establish(struct vm_area_struct *vma, 
+	       unsigned long address, pte_t *ptep, pte_t entry)
+{
+	ptep_clear_flush(vma, address, ptep);
+	set_pte(ptep, entry);
+}
+
+/*
+ * Test and clear dirty bit in storage key.
+ * We can't clear the changed bit atomically. This is a potential
+ * race against modification of the referenced bit. This function
+ * should therefore only be called if it is not mapped in any
+ * address space.
+ */
+#define page_test_and_clear_dirty(page)					  \
+({									  \
+	struct page *__page = (page);					  \
+	unsigned long __physpage = __pa((__page-mem_map) << PAGE_SHIFT);  \
+	int __skey;							  \
+	asm volatile ("iske %0,%1" : "=d" (__skey) : "a" (__physpage));   \
+	if (__skey & _PAGE_CHANGED) {					  \
+		asm volatile ("sske %0,%1"				  \
+			      : : "d" (__skey & ~_PAGE_CHANGED),	  \
+			          "a" (__physpage));			  \
+	}								  \
+	(__skey & _PAGE_CHANGED);					  \
+})
+
+/*
+ * Test and clear referenced bit in storage key.
+ */
+#define page_test_and_clear_young(page)					  \
+({									  \
+	struct page *__page = (page);					  \
+	unsigned long __physpage = __pa((__page-mem_map) << PAGE_SHIFT);  \
+	int __ccode;							  \
+	asm volatile ("rrbe 0,%1\n\t"					  \
+		      "ipm  %0\n\t"					  \
+		      "srl  %0,28\n\t" 					  \
+                      : "=d" (__ccode) : "a" (__physpage) : "cc" );	  \
+	(__ccode & 2);							  \
+})
+
 /*
  * Conversion functions: convert a page and protection to a page entry,
  * and a page entry and page directory to the page they refer to.
@@ -682,9 +746,9 @@ extern inline pte_t mk_swap_pte(unsigned
 	pte_t pte;
 	pte_val(pte) = (type << 1) | (offset << 12) | _PAGE_INVALID_SWAP;
 #ifndef __s390x__
-	pte_val(pte) &= 0x7ffff6fe;  /* better to be paranoid */
+	BUG_ON((pte_val(pte) & 0x80000901) != 0);
 #else /* __s390x__ */
-	pte_val(pte) &= 0xfffffffffffff6fe;  /* better to be paranoid */
+	BUG_ON((pte_val(pte) & 0x901) != 0);
 #endif /* __s390x__ */
 	return pte;
 }
@@ -724,5 +788,19 @@ typedef pte_t *pte_addr_t;
 # define HAVE_ARCH_UNMAPPED_AREA
 #endif /* __s390x__ */
 
+#define __HAVE_ARCH_PTEP_ESTABLISH
+#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
+#define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
+#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
+#define __HAVE_ARCH_PTEP_CLEAR_DIRTY_FLUSH
+#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
+#define __HAVE_ARCH_PTEP_CLEAR_FLUSH
+#define __HAVE_ARCH_PTEP_SET_WRPROTECT
+#define __HAVE_ARCH_PTEP_MKDIRTY
+#define __HAVE_ARCH_PTE_SAME
+#define __HAVE_ARCH_PAGE_TEST_AND_CLEAR_DIRTY
+#define __HAVE_ARCH_PAGE_TEST_AND_CLEAR_YOUNG
+#include <asm-generic/pgtable.h>
+
 #endif /* _S390_PAGE_H */
 
diff -puN include/asm-s390/scatterlist.h~linus include/asm-s390/scatterlist.h
--- 25/include/asm-s390/scatterlist.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/scatterlist.h	2004-01-19 22:17:24.000000000 -0800
@@ -7,6 +7,10 @@ struct scatterlist {
     unsigned int length;
 };
 
-#define ISA_DMA_THRESHOLD (0xffffffffffffffff)
+#ifdef __s390x__
+#define ISA_DMA_THRESHOLD (0xffffffffffffffffUL)
+#else
+#define ISA_DMA_THRESHOLD (0xffffffffUL)
+#endif
 
 #endif /* _ASMS390X_SCATTERLIST_H */
diff -puN include/asm-s390/setup.h~linus include/asm-s390/setup.h
--- 25/include/asm-s390/setup.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/setup.h	2004-01-19 22:17:24.000000000 -0800
@@ -36,6 +36,7 @@ extern unsigned long machine_flags;
 #define MACHINE_HAS_MVPG	(machine_flags & 16)
 #define MACHINE_HAS_DIAG44	(machine_flags & 32)
 #define MACHINE_NEW_STIDP	(machine_flags & 64)
+#define MACHINE_HAS_IDTE	(machine_flags & 128)
 
 #ifndef __s390x__
 #define MACHINE_HAS_IEEE	(machine_flags & 2)
diff -puN include/asm-s390/siginfo.h~linus include/asm-s390/siginfo.h
--- 25/include/asm-s390/siginfo.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/siginfo.h	2004-01-19 22:17:24.000000000 -0800
@@ -14,6 +14,12 @@
 #define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
 #endif
 
+#ifdef CONFIG_ARCH_S390X
+#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 4)
+#else
+#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
+#endif
+
 #include <asm-generic/siginfo.h>
 
 /*
diff -puN include/asm-s390/smp.h~linus include/asm-s390/smp.h
--- 25/include/asm-s390/smp.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/smp.h	2004-01-19 22:17:24.000000000 -0800
@@ -49,7 +49,6 @@ extern cpumask_t cpu_possible_map;
 #define smp_processor_id() (S390_lowcore.cpu_data.cpu_nr)
 
 #define cpu_online(cpu) cpu_isset(cpu, cpu_online_map)
-#define cpu_possible(cpu) cpu_isset(cpu, cpu_possible_map)
 
 extern __inline__ __u16 hard_smp_processor_id(void)
 {
diff -puN include/asm-s390/socket.h~linus include/asm-s390/socket.h
--- 25/include/asm-s390/socket.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/socket.h	2004-01-19 22:17:24.000000000 -0800
@@ -53,6 +53,8 @@
 
 #define SO_ACCEPTCONN		30
 
+#define SO_PEERSEC		31
+
 /* Nast libc5 fixup - bletch */
 #if defined(__KERNEL__)
 /* Socket types. */
diff -puN include/asm-s390/spinlock.h~linus include/asm-s390/spinlock.h
--- 25/include/asm-s390/spinlock.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/spinlock.h	2004-01-19 22:17:24.000000000 -0800
@@ -217,7 +217,7 @@ typedef struct {
 
 extern inline int _raw_write_trylock(rwlock_t *rw)
 {
-	unsigned int result, reg;
+	unsigned long result, reg;
 	
 	__asm__ __volatile__(
 #ifndef __s390x__
diff -puN include/asm-s390/tlbflush.h~linus include/asm-s390/tlbflush.h
--- 25/include/asm-s390/tlbflush.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/tlbflush.h	2004-01-19 22:17:24.000000000 -0800
@@ -99,17 +99,21 @@ static inline void global_flush_tlb(void
 static inline void __flush_tlb_mm(struct mm_struct * mm)
 {
 	cpumask_t local_cpumask;
+
+	if (unlikely(cpus_empty(mm->cpu_vm_mask)))
+		return;
+	if (MACHINE_HAS_IDTE) {
+		asm volatile (".insn rrf,0xb98e0000,0,%0,%1,0"
+			      : : "a" (2048),
+			      "a" (__pa(mm->pgd)&PAGE_MASK) : "cc" );
+		return;
+	}
 	preempt_disable();
 	local_cpumask = cpumask_of_cpu(smp_processor_id());
-	if (cpus_equal(mm->cpu_vm_mask, local_cpumask)) {
-		/* mm was active on more than one cpu. */
-		if (mm == current->active_mm &&
-		    atomic_read(&mm->mm_users) == 1)
-			/* this cpu is the only one using the mm. */
-			mm->cpu_vm_mask = local_cpumask;
-		global_flush_tlb();
-	} else
+	if (cpus_equal(mm->cpu_vm_mask, local_cpumask))
 		local_flush_tlb();
+	else
+		global_flush_tlb();
 	preempt_enable();
 }
 
@@ -136,8 +140,7 @@ static inline void flush_tlb_range(struc
 	__flush_tlb_mm(vma->vm_mm); 
 }
 
-#define flush_tlb_kernel_range(start, end) \
-	__flush_tlb_mm(&init_mm)
+#define flush_tlb_kernel_range(start, end) global_flush_tlb()
 
 #endif
 
diff -puN include/asm-s390/uaccess.h~linus include/asm-s390/uaccess.h
--- 25/include/asm-s390/uaccess.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/uaccess.h	2004-01-19 22:17:24.000000000 -0800
@@ -389,6 +389,26 @@ extern long __copy_from_user_asm(void *t
         err;                                                    \
 })
 
+extern long __copy_in_user_asm(const void *from, long n, void *to);
+
+#define __copy_in_user(to, from, n)				\
+({								\
+	__copy_in_user_asm(from, n, to);			\
+})
+
+#define copy_in_user(to, from, n)				\
+({								\
+	long err = 0;						\
+	__typeof__(n) __n = (n);				\
+	might_sleep();						\
+	if (__access_ok(from,__n) && __access_ok(to,__n)) {	\
+		err = __copy_in_user_asm(from, __n, to);	\
+	}							\
+	else							\
+		err = __n;					\
+	err;							\
+})
+
 /*
  * Copy a null terminated string from userspace.
  */
@@ -594,5 +614,4 @@ clear_user(void *to, unsigned long n)
 	return n;
 }
 
-
-#endif				       /* _S390_UACCESS_H		   */
+#endif /* __S390_UACCESS_H */
diff -puN include/asm-s390/unistd.h~linus include/asm-s390/unistd.h
--- 25/include/asm-s390/unistd.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-s390/unistd.h	2004-01-19 22:17:24.000000000 -0800
@@ -259,8 +259,9 @@
 /*
  * Number 263 is reserved for vserver
  */
+#define __NR_fadvise64_64	264
 
-#define NR_syscalls 264
+#define NR_syscalls 265
 
 /* 
  * There are some system calls that are not present on 64 bit, some
@@ -322,6 +323,7 @@
 #undef  __NR_getdents64
 #undef  __NR_fcntl64
 #undef  __NR_sendfile64
+#undef  __NR_fadvise64_64
 
 #define __NR_select		142
 #define __NR_getrlimit		191	/* SuS compliant getrlimit */
diff -puN -L include/asm-sh/bigsur.h include/asm-sh/bigsur.h~linus /dev/null
--- 25/include/asm-sh/bigsur.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,80 +0,0 @@
-/*
- *
- * Hitachi Big Sur Eval Board support
- *
- * Dustin McIntire (dustin@sensoria.com)
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * Derived from Hitachi SH7751 reference manual
- * 
- */
-
-#ifndef _ASM_BIGSUR_H_
-#define _ASM_BIGSUR_H_
-
-#include <asm/irq.h>
-#include <asm/hd64465.h>
-
-/* 7751 Internal IRQ's used by external CPLD controller */
-#define BIGSUR_IRQ_LOW	0
-#define BIGSUR_IRQ_NUM  14         /* External CPLD level 1 IRQs */
-#define BIGSUR_IRQ_HIGH (BIGSUR_IRQ_LOW + BIGSUR_IRQ_NUM)
-#define BIGSUR_2NDLVL_IRQ_LOW   (HD64465_IRQ_BASE+HD64465_IRQ_NUM)  
-#define BIGSUR_2NDLVL_IRQ_NUM   32 /* Level 2 IRQs = 4 regs * 8 bits */
-#define BIGSUR_2NDLVL_IRQ_HIGH  (BIGSUR_2NDLVL_IRQ_LOW + \
-                                 BIGSUR_2NDLVL_IRQ_NUM)
-
-/* PCI interrupt base number (A_INTA-A_INTD) */
-#define BIGSUR_SH7751_PCI_IRQ_BASE  (BIGSUR_2NDLVL_IRQ_LOW+10)  
-
-/* CPLD registers and external chip addresses */
-#define BIGSUR_HD64464_ADDR	0xB2000000
-#define BIGSUR_DGDR	0xB1FFFE00
-#define BIGSUR_BIDR	0xB1FFFD00
-#define BIGSUR_CSLR	0xB1FFFC00
-#define BIGSUR_SW1R	0xB1FFFB00
-#define BIGSUR_DBGR	0xB1FFFA00
-#define BIGSUR_BDTR	0xB1FFF900
-#define BIGSUR_BDRR	0xB1FFF800
-#define BIGSUR_PPR1	0xB1FFF700
-#define BIGSUR_PPR2	0xB1FFF600
-#define BIGSUR_IDE2	0xB1FFF500
-#define BIGSUR_IDE3	0xB1FFF400
-#define BIGSUR_SPCR	0xB1FFF300
-#define BIGSUR_ETHR	0xB1FE0000
-#define BIGSUR_PPDR	0xB1FDFF00
-#define BIGSUR_ICTL	0xB1FDFE00
-#define BIGSUR_ICMD	0xB1FDFD00
-#define BIGSUR_DMA0	0xB1FDFC00
-#define BIGSUR_DMA1	0xB1FDFB00
-#define BIGSUR_IRQ0	0xB1FDFA00
-#define BIGSUR_IRQ1	0xB1FDF900
-#define BIGSUR_IRQ2	0xB1FDF800
-#define BIGSUR_IRQ3	0xB1FDF700
-#define BIGSUR_IMR0	0xB1FDF600
-#define BIGSUR_IMR1	0xB1FDF500
-#define BIGSUR_IMR2	0xB1FDF400
-#define BIGSUR_IMR3	0xB1FDF300
-#define BIGSUR_IRLMR0	0xB1FDF200
-#define BIGSUR_IRLMR1	0xB1FDF100
-#define BIGSUR_V320USC_ADDR  0xB1000000
-#define BIGSUR_HD64465_ADDR  0xB0000000
-#define BIGSUR_INTERNAL_BASE 0xB0000000
-
-/* SMC ethernet card parameters */
-#define BIGSUR_ETHER_IOPORT		0x220
-
-/* IDE register paramters */
-#define BIGSUR_IDECMD_IOPORT	0x1f0
-#define BIGSUR_IDECTL_IOPORT	0x1f8
-
-/* LED bit position in BIGSUR_CSLR */
-#define BIGSUR_LED  (1<<4)
-
-/* PCI: default LOCAL memory window sizes (seen from PCI bus) */
-#define BIGSUR_LSR0_SIZE    (64*(1<<20)) //64MB
-#define BIGSUR_LSR1_SIZE    (64*(1<<20)) //64MB
-
-#endif /* _ASM_BIGSUR_H_ */
diff -puN include/asm-sh/bigsur/io.h~linus include/asm-sh/bigsur/io.h
--- 25/include/asm-sh/bigsur/io.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/bigsur/io.h	2004-01-19 22:17:24.000000000 -0800
@@ -18,28 +18,9 @@
 #define _ASM_SH_IO_BIGSUR_H
 
 #include <linux/types.h>
-#include <asm/io_generic.h>
 
-extern unsigned char bigsur_inb(unsigned long port);
-extern unsigned short bigsur_inw(unsigned long port);
-extern unsigned int bigsur_inl(unsigned long port);
-
-extern void bigsur_outb(unsigned char value, unsigned long port);
-extern void bigsur_outw(unsigned short value, unsigned long port);
-extern void bigsur_outl(unsigned int value, unsigned long port);
-
-extern unsigned char bigsur_inb_p(unsigned long port);
-extern void bigsur_outb_p(unsigned char value, unsigned long port);
-
-extern void bigsur_insb(unsigned long port, void *addr, unsigned long count);
-extern void bigsur_insw(unsigned long port, void *addr, unsigned long count);
-extern void bigsur_insl(unsigned long port, void *addr, unsigned long count);
-extern void bigsur_outsb(unsigned long port, const void *addr, unsigned long count);
-extern void bigsur_outsw(unsigned long port, const void *addr, unsigned long count);
-extern void bigsur_outsl(unsigned long port, const void *addr, unsigned long count);
 extern unsigned long bigsur_isa_port2addr(unsigned long offset);
 extern int bigsur_irq_demux(int irq);
-extern void bigsur_init_pci(void);
 /* Provision for generic secondary demux step -- used by PCMCIA code */
 extern void bigsur_register_irq_demux(int irq,
 		int (*demux)(int irq, void *dev), void *dev);
@@ -52,38 +33,3 @@ extern void bigsur_port_unmap(u32 basepo
 
 #endif /* _ASM_SH_IO_BIGSUR_H */
 
-#ifdef __WANT_IO_DEF
-
-# define __inb			bigsur_inb
-# define __inw			bigsur_inw
-# define __inl			bigsur_inl
-# define __outb			bigsur_outb
-# define __outw			bigsur_outw
-# define __outl			bigsur_outl
-
-# define __inb_p		bigsur_inb_p
-# define __inw_p		bigsur_inw
-# define __inl_p		bigsur_inl
-# define __outb_p		bigsur_outb_p
-# define __outw_p		bigsur_outw
-# define __outl_p		bigsur_outl
-
-# define __insb			bigsur_insb
-# define __insw			bigsur_insw
-# define __insl			bigsur_insl
-# define __outsb		bigsur_outsb
-# define __outsw		bigsur_outsw
-# define __outsl		bigsur_outsl
-
-# define __readb		generic_readb
-# define __readw		generic_readw
-# define __readl		generic_readl
-# define __writeb		generic_writeb
-# define __writew		generic_writew
-# define __writel		generic_writel
-
-# define __isa_port2addr	bigsur_isa_port2addr
-# define __ioremap		generic_ioremap
-# define __iounmap		generic_iounmap
-
-#endif
diff -puN include/asm-sh/byteorder.h~linus include/asm-sh/byteorder.h
--- 25/include/asm-sh/byteorder.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/byteorder.h	2004-01-19 22:17:24.000000000 -0800
@@ -6,8 +6,9 @@
  */
 
 #include <asm/types.h>
+#include <linux/compiler.h>
 
-static __inline__ __const__ __u32 ___arch__swab32(__u32 x)
+static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
 {
 	__asm__("swap.b	%0, %0\n\t"
 		"swap.w %0, %0\n\t"
@@ -17,7 +18,7 @@ static __inline__ __const__ __u32 ___arc
 	return x;
 }
 
-static __inline__ __const__ __u16 ___arch__swab16(__u16 x)
+static __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 x)
 {
 	__asm__("swap.b %0, %0"
 		: "=r" (x)
diff -puN include/asm-sh/cache.h~linus include/asm-sh/cache.h
--- 25/include/asm-sh/cache.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/cache.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: cache.h,v 1.4 2003/05/06 23:28:50 lethal Exp $
+/* $Id: cache.h,v 1.5 2003/07/16 04:08:29 lethal Exp $
  *
  * include/asm-sh/cache.h
  *
@@ -16,7 +16,8 @@
 #define SH_CACHE_COMBINED	4
 #define SH_CACHE_ASSOC		8
 
-#define SMP_CACHE_BYTES L1_CACHE_BYTES
+#define L1_CACHE_BYTES		(1 << L1_CACHE_SHIFT)
+#define SMP_CACHE_BYTES		L1_CACHE_BYTES
 
 #define L1_CACHE_ALIGN(x)	(((x)+(L1_CACHE_BYTES-1))&~(L1_CACHE_BYTES-1))
 
@@ -28,7 +29,7 @@
 		 __section__(".data.cacheline_aligned")))
 #endif
 
-#define L1_CACHE_SHIFT_MAX 5	/* largest L1 which this arch supports */
+#define L1_CACHE_SHIFT_MAX 	5	/* largest L1 which this arch supports */
 
 struct cache_info {
 	unsigned int ways;
diff -puN include/asm-sh/cat68701/io.h~linus include/asm-sh/cat68701/io.h
--- 25/include/asm-sh/cat68701/io.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/cat68701/io.h	2004-01-19 22:17:24.000000000 -0800
@@ -13,77 +13,10 @@
 #ifndef _ASM_SH_IO_CAT68701_H
 #define _ASM_SH_IO_CAT68701_H
 
-#include <asm/io_generic.h>
-
-extern unsigned char cat68701_inb(unsigned long port);
-extern unsigned short cat68701_inw(unsigned long port);
-extern unsigned int cat68701_inl(unsigned long port);
-
-extern void cat68701_outb(unsigned char value, unsigned long port);
-extern void cat68701_outw(unsigned short value, unsigned long port);
-extern void cat68701_outl(unsigned int value, unsigned long port);
-
-extern unsigned char cat68701_inb_p(unsigned long port);
-extern void cat68701_outb_p(unsigned char value, unsigned long port);
-
-extern void cat68701_insb(unsigned long port, void *addr, unsigned long count);
-extern void cat68701_insw(unsigned long port, void *addr, unsigned long count);
-extern void cat68701_insl(unsigned long port, void *addr, unsigned long count);
-extern void cat68701_outsb(unsigned long port, const void *addr, unsigned long count);
-extern void cat68701_outsw(unsigned long port, const void *addr, unsigned long count);
-extern void cat68701_outsl(unsigned long port, const void *addr, unsigned long count);
-
-extern unsigned char cat68701_readb(unsigned long addr);
-extern unsigned short cat68701_readw(unsigned long addr);
-extern unsigned int cat68701_readl(unsigned long addr);
-extern void cat68701_writeb(unsigned char b, unsigned long addr);
-extern void cat68701_writew(unsigned short b, unsigned long addr);
-extern void cat68701_writel(unsigned int b, unsigned long addr);
-
-extern void * cat68701_ioremap(unsigned long offset, unsigned long size);
-extern void cat68701_iounmap(void *addr);
-
 extern unsigned long cat68701_isa_port2addr(unsigned long offset);
 extern int cat68701_irq_demux(int irq);
 
-extern void setup_cat68701(void);
 extern void init_cat68701_IRQ(void);
 extern void heartbeat_cat68701(void);
 
-#ifdef __WANT_IO_DEF
-
-# define __inb			cat68701_inb
-# define __inw			cat68701_inw
-# define __inl			cat68701_inl
-# define __outb			cat68701_outb
-# define __outw			cat68701_outw
-# define __outl			cat68701_outl
-
-# define __inb_p		cat68701_inb_p
-# define __inw_p		cat68701_inw
-# define __inl_p		cat68701_inl
-# define __outb_p		cat68701_outb_p
-# define __outw_p		cat68701_outw
-# define __outl_p		cat68701_outl
-
-# define __insb			cat68701_insb
-# define __insw			cat68701_insw
-# define __insl			cat68701_insl
-# define __outsb		cat68701_outsb
-# define __outsw		cat68701_outsw
-# define __outsl		cat68701_outsl
-
-# define __readb		cat68701_readb
-# define __readw		cat68701_readw
-# define __readl		cat68701_readl
-# define __writeb		cat68701_writeb
-# define __writew		cat68701_writew
-# define __writel		cat68701_writel
-
-# define __isa_port2addr	cat68701_isa_port2addr
-# define __ioremap		generic_ioremap
-# define __iounmap		generic_iounmap
-
-#endif
-
 #endif /* _ASM_SH_IO_CAT68701_H */
diff -puN /dev/null include/asm-sh/cpu-sh2/addrspace.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/asm-sh/cpu-sh2/addrspace.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,16 @@
+/*
+ * Definitions for the address spaces of the SH-2 CPUs.
+ *
+ * Copyright (C) 2003  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#ifndef __ASM_CPU_SH2_ADDRSPACE_H
+#define __ASM_CPU_SH2_ADDRSPACE_H
+
+/* Should fill here */
+
+#endif /* __ASM_CPU_SH2_ADDRSPACE_H */
+
diff -puN include/asm-sh/cpu-sh2/cache.h~linus include/asm-sh/cpu-sh2/cache.h
--- 25/include/asm-sh/cpu-sh2/cache.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/cpu-sh2/cache.h	2004-01-19 22:17:24.000000000 -0800
@@ -10,7 +10,7 @@
 #ifndef __ASM_CPU_SH2_CACHE_H
 #define __ASM_CPU_SH2_CACHE_H
 
-#define	L1_CACHE_BYTES	16
+#define L1_CACHE_SHIFT	4
 
 #define CCR		0xfffffe92	/* Address of Cache Control Register */
 
diff -puN /dev/null include/asm-sh/cpu-sh2/dma.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/asm-sh/cpu-sh2/dma.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,23 @@
+/*
+ * Definitions for the SH-2 DMAC.
+ *
+ * Copyright (C) 2003  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#ifndef __ASM_CPU_SH2_DMA_H
+#define __ASM_CPU_SH2_DMA_H
+
+#define SH_MAX_DMA_CHANNELS	2
+
+#define SAR	((unsigned long[]){ 0xffffff80, 0xffffff90 })
+#define DAR	((unsigned long[]){ 0xffffff84, 0xffffff94 })
+#define DMATCR	((unsigned long[]){ 0xffffff88, 0xffffff98 })
+#define CHCR	((unsigned long[]){ 0xfffffffc, 0xffffff9c })
+
+#define DMAOR	0xffffffb0
+
+#endif /* __ASM_CPU_SH2_DMA_H */
+
diff -puN /dev/null include/asm-sh/cpu-sh2/shmparam.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/asm-sh/cpu-sh2/shmparam.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,16 @@
+/*
+ * include/asm-sh/cpu-sh2/shmparam.h
+ *
+ * Copyright (C) 2003  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#ifndef __ASM_CPU_SH2_SHMPARAM_H
+#define __ASM_CPU_SH2_SHMPARAM_H
+
+#define	SHMLBA PAGE_SIZE		 /* attach addr a multiple of this */
+
+#endif /* __ASM_CPU_SH2_SHMPARAM_H */
+
diff -puN /dev/null include/asm-sh/cpu-sh2/sigcontext.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/asm-sh/cpu-sh2/sigcontext.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,17 @@
+#ifndef __ASM_CPU_SH2_SIGCONTEXT_H
+#define __ASM_CPU_SH2_SIGCONTEXT_H
+
+struct sigcontext {
+	unsigned long	oldmask;
+
+	/* CPU registers */
+	unsigned long sc_regs[16];
+	unsigned long sc_pc;
+	unsigned long sc_pr;
+	unsigned long sc_sr;
+	unsigned long sc_gbr;
+	unsigned long sc_mach;
+	unsigned long sc_macl;
+};
+
+#endif /* __ASM_CPU_SH2_SIGCONTEXT_H */
diff -puN /dev/null include/asm-sh/cpu-sh2/ubc.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/asm-sh/cpu-sh2/ubc.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,32 @@
+/*
+ * include/asm-sh/cpu-sh2/ubc.h
+ *
+ * Copyright (C) 2003 Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#ifndef __ASM_CPU_SH2_UBC_H
+#define __ASM_CPU_SH2_UBC_H
+
+#define UBC_BARA                0xffffff40
+#define UBC_BAMRA               0xffffff44
+#define UBC_BBRA                0xffffff48
+#define UBC_BARB                0xffffff60
+#define UBC_BAMRB               0xffffff64
+#define UBC_BBRB                0xffffff68
+#define UBC_BDRB                0xffffff70
+#define UBC_BDMRB               0xffffff74
+#define UBC_BRCR                0xffffff78
+
+/*
+ * We don't have any ASID changes to make in the UBC on the SH-2.
+ *
+ * Make these purposely invalid to track misuse.
+ */
+#define UBC_BASRA		0x00000000
+#define UBC_BASRB		0x00000000
+
+#endif /* __ASM_CPU_SH2_UBC_H */
+
diff -puN include/asm-sh/cpu-sh3/cache.h~linus include/asm-sh/cpu-sh3/cache.h
--- 25/include/asm-sh/cpu-sh3/cache.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/cpu-sh3/cache.h	2004-01-19 22:17:24.000000000 -0800
@@ -10,7 +10,7 @@
 #ifndef __ASM_CPU_SH3_CACHE_H
 #define __ASM_CPU_SH3_CACHE_H
 
-#define        L1_CACHE_BYTES  16
+#define L1_CACHE_SHIFT	4
 
 #define CCR		0xffffffec	/* Address of Cache Control Register */
 
diff -puN include/asm-sh/cpu-sh3/dma.h~linus include/asm-sh/cpu-sh3/dma.h
--- 25/include/asm-sh/cpu-sh3/dma.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/cpu-sh3/dma.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,11 +1,7 @@
 #ifndef __ASM_CPU_SH3_DMA_H
 #define __ASM_CPU_SH3_DMA_H
 
-#define SAR ((unsigned long[]){0xa4000020,0xa4000030,0xa4000040,0xa4000050})
-#define DAR ((unsigned long[]){0xa4000024,0xa4000034,0xa4000044,0xa4000054})
-#define DMATCR ((unsigned long[]){0xa4000028,0xa4000038,0xa4000048,0xa4000058})
-#define CHCR ((unsigned long[]){0xa400002c,0xa400003c,0xa400004c,0xa400005c})
-#define DMAOR 0xa4000060UL
+#define SH_DMAC_BASE	0xa4000020
 
 #endif /* __ASM_CPU_SH3_DMA_H */
 
diff -puN include/asm-sh/cpu-sh3/mmu_context.h~linus include/asm-sh/cpu-sh3/mmu_context.h
--- 25/include/asm-sh/cpu-sh3/mmu_context.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/cpu-sh3/mmu_context.h	2004-01-19 22:17:24.000000000 -0800
@@ -21,6 +21,7 @@
 #define MMU_PAGE_ASSOC_BIT	0x80
 
 #define MMU_NTLB_ENTRIES	128	/* for 7708 */
+#define MMU_NTLB_WAYS		4
 #define MMU_CONTROL_INIT	0x007	/* SV=0, TF=1, IX=1, AT=1 */
 
 #endif /* __ASM_CPU_SH3_MMU_CONTEXT_H */
diff -puN /dev/null include/asm-sh/cpu-sh3/sigcontext.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/asm-sh/cpu-sh3/sigcontext.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,17 @@
+#ifndef __ASM_CPU_SH3_SIGCONTEXT_H
+#define __ASM_CPU_SH3_SIGCONTEXT_H
+
+struct sigcontext {
+	unsigned long	oldmask;
+
+	/* CPU registers */
+	unsigned long sc_regs[16];
+	unsigned long sc_pc;
+	unsigned long sc_pr;
+	unsigned long sc_sr;
+	unsigned long sc_gbr;
+	unsigned long sc_mach;
+	unsigned long sc_macl;
+};
+
+#endif /* __ASM_CPU_SH3_SIGCONTEXT_H */
diff -puN include/asm-sh/cpu-sh4/cache.h~linus include/asm-sh/cpu-sh4/cache.h
--- 25/include/asm-sh/cpu-sh4/cache.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/cpu-sh4/cache.h	2004-01-19 22:17:24.000000000 -0800
@@ -10,7 +10,7 @@
 #ifndef __ASM_CPU_SH4_CACHE_H
 #define __ASM_CPU_SH4_CACHE_H
 
-#define        L1_CACHE_BYTES  32
+#define L1_CACHE_SHIFT	5
 
 #define CCR		0xff00001c	/* Address of Cache Control Register */
 #define CCR_CACHE_OCE	0x0001	/* Operand Cache Enable */
diff -puN include/asm-sh/cpu-sh4/dma.h~linus include/asm-sh/cpu-sh4/dma.h
--- 25/include/asm-sh/cpu-sh4/dma.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/cpu-sh4/dma.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,11 +1,7 @@
 #ifndef __ASM_CPU_SH4_DMA_H
 #define __ASM_CPU_SH4_DMA_H
 
-#define SAR ((unsigned long[]){0xbfa00000,0xbfa00010,0xbfa00020,0xbfa00030})
-#define DAR ((unsigned long[]){0xbfa00004,0xbfa00014,0xbfa00024,0xbfa00034})
-#define DMATCR ((unsigned long[]){0xbfa00008,0xbfa00018,0xbfa00028,0xbfa00038})
-#define CHCR ((unsigned long[]){0xbfa0000c,0xbfa0001c,0xbfa0002c,0xbfa0003c})
-#define DMAOR 0xbfa00040UL
+#define SH_DMAC_BASE	0xbfa00000
 
 #endif /* __ASM_CPU_SH4_DMA_H */
 
diff -puN /dev/null include/asm-sh/cpu-sh4/sigcontext.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/asm-sh/cpu-sh4/sigcontext.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,24 @@
+#ifndef __ASM_CPU_SH4_SIGCONTEXT_H
+#define __ASM_CPU_SH4_SIGCONTEXT_H
+
+struct sigcontext {
+	unsigned long	oldmask;
+
+	/* CPU registers */
+	unsigned long sc_regs[16];
+	unsigned long sc_pc;
+	unsigned long sc_pr;
+	unsigned long sc_sr;
+	unsigned long sc_gbr;
+	unsigned long sc_mach;
+	unsigned long sc_macl;
+
+	/* FPU registers */
+	unsigned long sc_fpregs[16];
+	unsigned long sc_xfpregs[16];
+	unsigned int sc_fpscr;
+	unsigned int sc_fpul;
+	unsigned int sc_ownedfp;
+};
+
+#endif /* __ASM_CPU_SH4_SIGCONTEXT_H */
diff -puN /dev/null include/asm-sh/cpu-sh4/sq.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/asm-sh/cpu-sh4/sq.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,48 @@
+/*
+ * include/asm-sh/cpu-sh4/sq.h
+ *
+ * Copyright (C) 2001, 2002, 2003  Paul Mundt
+ * Copyright (C) 2001, 2002  M. R. Brown
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#ifndef __ASM_CPU_SH4_SQ_H
+#define __ASM_CPU_SH4_SQ_H
+
+#include <asm/addrspace.h>
+
+/*
+ * Store queues range from e0000000-e3fffffc, allowing approx. 64MB to be
+ * mapped to any physical address space. Since data is written (and aligned)
+ * to 32-byte boundaries, we need to be sure that all allocations are aligned.
+ */ 
+#define SQ_SIZE                 32
+#define SQ_ALIGN_MASK           (~(SQ_SIZE - 1))
+#define SQ_ALIGN(addr)          (((addr)+SQ_SIZE-1) & SQ_ALIGN_MASK)
+
+#define SQ_QACR0		(P4SEG_REG_BASE  + 0x38)
+#define SQ_QACR1		(P4SEG_REG_BASE  + 0x3c)
+#define SQ_ADDRMAX              (P4SEG_STORE_QUE + 0x04000000)
+
+struct sq_mapping {
+	const char *name;
+
+	unsigned long sq_addr;
+	unsigned long addr;
+	unsigned int size;
+
+	struct list_head list;
+};
+
+/* arch/sh/kernel/cpu/sh4/sq.c */
+extern struct sq_mapping *sq_remap(unsigned long phys, unsigned int size, const char *name);
+extern void sq_unmap(struct sq_mapping *map);
+
+extern void sq_clear(unsigned long addr, unsigned int len);
+extern void sq_flush(void *addr);
+extern void sq_flush_range(unsigned long start, unsigned int len);
+
+#endif /* __ASM_CPU_SH4_SQ_H */
+
diff -puN -L include/asm-sh/dc_sysasic.h include/asm-sh/dc_sysasic.h~linus /dev/null
--- 25/include/asm-sh/dc_sysasic.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,35 +0,0 @@
-/* include/asm-sh/dc_sysasic.h
- *
- * Definitions for the Dreamcast System ASIC and related peripherals.
- *
- * Copyright (c) 2001 M. R. Brown <mrbrown@linuxdc.org>
- *
- * This file is part of the LinuxDC project (www.linuxdc.org)
- *
- * Released under the terms of the GNU GPL v2.0.
- *
- */
-
-#include <asm/irq.h>
-
-/* Hardware events -
-
-   Each of these events correspond to a bit within the Event Mask Registers/
-   Event Status Registers.  Because of the virtual IRQ numbering scheme, a
-   base offset must be used when calculating the virtual IRQ that each event
-   takes.
-*/
-
-#define HW_EVENT_IRQ_BASE  OFFCHIP_IRQ_BASE /* 48 */
-
-/* IRQ 13 */
-#define HW_EVENT_VSYNC     (HW_EVENT_IRQ_BASE +  5) /* VSync */
-#define HW_EVENT_MAPLE_DMA (HW_EVENT_IRQ_BASE + 12) /* Maple DMA complete */
-#define HW_EVENT_GDROM_DMA (HW_EVENT_IRQ_BASE + 14) /* GD-ROM DMA complete */
-
-/* IRQ 11 */
-#define HW_EVENT_GDROM_CMD (HW_EVENT_IRQ_BASE + 32) /* GD-ROM cmd. complete */
-#define HW_EVENT_AICA_SYS  (HW_EVENT_IRQ_BASE + 33) /* AICA-related */
-#define HW_EVENT_EXTERNAL  (HW_EVENT_IRQ_BASE + 35) /* Ext. (expansion) */
-
-#define HW_EVENT_IRQ_MAX (HW_EVENT_IRQ_BASE + 95)
diff -puN include/asm-sh/dma.h~linus include/asm-sh/dma.h
--- 25/include/asm-sh/dma.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/dma.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,80 +1,98 @@
+/*
+ * include/asm-sh/dma.h
+ *
+ * Copyright (C) 2003  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
 #ifndef __ASM_SH_DMA_H
 #define __ASM_SH_DMA_H
 
-#ifdef CONFIG_SH_MPC1211
-#include <asm/mpc1211/dma.h>
-#else
-
 #include <linux/config.h>
+#include <linux/spinlock.h>
 #include <asm/cpu/dma.h>
-#include <asm/io.h>		/* need byte IO */
-
-#define MAX_DMA_CHANNELS 8
-#define SH_MAX_DMA_CHANNELS 4
+#include <asm/semaphore.h>
 
 /* The maximum address that we can perform a DMA transfer to on this platform */
 /* Don't define MAX_DMA_ADDRESS; it's useless on the SuperH and any
    occurrence should be flagged as an error.  */
 /* But... */
 /* XXX: This is not applicable to SuperH, just needed for alloc_bootmem */
-#define MAX_DMA_ADDRESS      (PAGE_OFFSET+0x10000000)
+#define MAX_DMA_ADDRESS		(PAGE_OFFSET+0x10000000)
 
-#define DMTE_IRQ ((int[]){DMTE0_IRQ,DMTE1_IRQ,DMTE2_IRQ,DMTE3_IRQ})
+#ifdef CONFIG_NR_DMA_CHANNELS
+#  define MAX_DMA_CHANNELS	(CONFIG_NR_DMA_CHANNELS)
+#else
+#  define MAX_DMA_CHANNELS	(CONFIG_NR_ONCHIP_DMA_CHANNELS)
+#endif
 
-#define DMA_MODE_READ	0x00	/* I/O to memory, no autoinit, increment, single mode */
-#define DMA_MODE_WRITE	0x01	/* memory to I/O, no autoinit, increment, single mode */
-#define DMA_AUTOINIT	0x10
-
-#define REQ_L	0x00000000
-#define REQ_E	0x00080000
-#define RACK_H	0x00000000
-#define RACK_L	0x00040000
-#define ACK_R	0x00000000
-#define ACK_W	0x00020000
-#define ACK_H	0x00000000
-#define ACK_L	0x00010000
-#define DM_INC	0x00004000
-#define DM_DEC	0x00008000
-#define SM_INC	0x00001000
-#define SM_DEC	0x00002000
-#define RS_DUAL	0x00000000
-#define RS_IN	0x00000200
-#define RS_OUT	0x00000300
-#define TM_BURST 0x0000080
-#define TS_8	0x00000010
-#define TS_16	0x00000020
-#define TS_32	0x00000030
-#define TS_64	0x00000000
-#define TS_BLK	0x00000040
-#define CHCR_DE 0x00000001
-#define CHCR_TE 0x00000002
-#define CHCR_IE 0x00000004
-
-#define DMAOR_COD	0x00000008
-#define DMAOR_AE	0x00000004
-#define DMAOR_NMIF	0x00000002
-#define DMAOR_DME	0x00000001
+/* 
+ * Read and write modes can mean drastically different things depending on the
+ * channel configuration. Consult your DMAC documentation and module
+ * implementation for further clues.
+ */
+#define DMA_MODE_READ		0x00
+#define DMA_MODE_WRITE		0x01
+#define DMA_MODE_MASK		0x01
+
+extern spinlock_t dma_spin_lock;
+
+struct dma_info;
+
+struct dma_ops {
+	const char *name;
+
+	int (*request)(struct dma_info *info);
+	void (*free)(struct dma_info *info);
+
+	int (*get_residue)(struct dma_info *info);
+	int (*xfer)(struct dma_info *info);
+	void (*configure)(struct dma_info *info, unsigned long flags);
+};
+
+struct dma_info {
+	const char *dev_id;
 
-struct dma_info_t {
 	unsigned int chan;
-	unsigned long dev_addr;
 	unsigned int mode;
-	unsigned long mem_addr;
 	unsigned int count;
-};
+	
+	unsigned long sar;
+	unsigned long dar;
+
+	unsigned int configured:1;
+	atomic_t busy;
+
+	struct semaphore sem;
+	struct dma_ops *ops;
+} __attribute__ ((packed));
+
+/* arch/sh/drivers/dma/dma-api.c */
+extern int dma_xfer(unsigned int chan, unsigned long from,
+		    unsigned long to, size_t size, unsigned int mode);
+
+#define dma_write(chan, from, to, size)	\
+	dma_xfer(chan, from, to, size, DMA_MODE_WRITE)
+#define dma_write_page(chan, from, to)	\
+	dma_write(chan, from, to, PAGE_SIZE)
+
+#define dma_read(chan, from, to, size)	\
+	dma_xfer(chan, from, to, size, DMA_MODE_READ)
+#define dma_read_page(chan, from, to)	\
+	dma_read(chan, from, to, PAGE_SIZE)
+
+extern int request_dma(unsigned int chan, const char *dev_id);
+extern void free_dma(unsigned int chan);
+extern int get_dma_residue(unsigned int chan);
+extern struct dma_info *get_dma_info(unsigned int chan);
+extern void dma_wait_for_completion(unsigned int chan);
+extern void dma_configure_channel(unsigned int chan, unsigned long flags);
 
-static __inline__ void clear_dma_ff(unsigned int dmanr){}
+extern int register_dmac(struct dma_ops *ops);
 
-/* These are in arch/sh/kernel/dma.c: */
-extern unsigned long claim_dma_lock(void);
-extern void release_dma_lock(unsigned long flags);
-extern void setup_dma(unsigned int dmanr, struct dma_info_t *info);
-extern void enable_dma(unsigned int dmanr);
-extern void disable_dma(unsigned int dmanr);
-extern void set_dma_mode(unsigned int dmanr, char mode);
-extern void set_dma_addr(unsigned int dmanr, unsigned int a);
-extern void set_dma_count(unsigned int dmanr, unsigned int count);
-extern int get_dma_residue(unsigned int dmanr);
+extern struct dma_info dma_info[];
 
 #ifdef CONFIG_PCI
 extern int isa_dma_bridge_buggy;
@@ -82,6 +100,4 @@ extern int isa_dma_bridge_buggy;
 #define isa_dma_bridge_buggy 	(0)
 #endif
 
-#endif /* CONFIG_SH_MPC1211 */
-
 #endif /* __ASM_SH_DMA_H */
diff -puN /dev/null include/asm-sh/dreamcast/dma.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/asm-sh/dreamcast/dma.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,34 @@
+/*
+ * include/asm-sh/dreamcast/dma.h
+ *
+ * Copyright (C) 2003 Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#ifndef __ASM_SH_DREAMCAST_DMA_H
+#define __ASM_SH_DREAMCAST_DMA_H
+
+/* Number of DMA channels */
+#define ONCHIP_NR_DMA_CHANNELS	4
+#define G2_NR_DMA_CHANNELS	4
+#define PVR2_NR_DMA_CHANNELS	1
+
+/* Channels for cascading */
+#define PVR2_CASCADE_CHAN	2
+#define G2_CASCADE_CHAN		3
+
+/* PVR2 DMA Registers */
+#define PVR2_DMA_BASE		0xa05f6800
+#define PVR2_DMA_ADDR		(PVR2_DMA_BASE + 0)
+#define PVR2_DMA_COUNT		(PVR2_DMA_BASE + 4)
+#define PVR2_DMA_MODE		(PVR2_DMA_BASE + 8)
+#define PVR2_DMA_LMMODE0	(PVR2_DMA_BASE + 132)
+#define PVR2_DMA_LMMODE1	(PVR2_DMA_BASE + 136)
+
+/* G2 DMA Register */
+#define G2_DMA_BASE		0xa05f7800
+
+#endif /* __ASM_SH_DREAMCAST_DMA_H */
+
diff -puN /dev/null include/asm-sh/dreamcast/pci.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/asm-sh/dreamcast/pci.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,25 @@
+/*
+ * include/asm-sh/dreamcast/pci.h
+ *
+ * Copyright (C) 2001, 2002  M. R. Brown
+ * Copyright (C) 2002, 2003  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#ifndef __ASM_SH_DREAMCAST_PCI_H
+#define __ASM_SH_DREAMCAST_PCI_H
+
+#include <asm/mach/sysasic.h>
+
+#define	GAPSPCI_REGS		0x01001400
+#define GAPSPCI_DMA_BASE	0x01840000
+#define GAPSPCI_DMA_SIZE	32768
+#define GAPSPCI_BBA_CONFIG	0x01001600
+#define GAPSPCI_BBA_CONFIG_SIZE	0x2000
+
+#define	GAPSPCI_IRQ		HW_EVENT_EXTERNAL
+
+#endif /* __ASM_SH_DREAMCAST_PCI_H */
+
diff -puN include/asm-sh/dreamcast/sysasic.h~linus include/asm-sh/dreamcast/sysasic.h
--- 25/include/asm-sh/dreamcast/sysasic.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/dreamcast/sysasic.h	2004-01-19 22:17:24.000000000 -0800
@@ -3,12 +3,15 @@
  * Definitions for the Dreamcast System ASIC and related peripherals.
  *
  * Copyright (c) 2001 M. R. Brown <mrbrown@linuxdc.org>
+ * Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
  *
  * This file is part of the LinuxDC project (www.linuxdc.org)
  *
  * Released under the terms of the GNU GPL v2.0.
  *
  */
+#ifndef __ASM_SH_DREAMCAST_SYSASIC_H
+#define __ASM_SH_DREAMCAST_SYSASIC_H
 
 #include <asm/irq.h>
 
@@ -26,6 +29,8 @@
 #define HW_EVENT_VSYNC     (HW_EVENT_IRQ_BASE +  5) /* VSync */
 #define HW_EVENT_MAPLE_DMA (HW_EVENT_IRQ_BASE + 12) /* Maple DMA complete */
 #define HW_EVENT_GDROM_DMA (HW_EVENT_IRQ_BASE + 14) /* GD-ROM DMA complete */
+#define HW_EVENT_G2_DMA    (HW_EVENT_IRQ_BASE + 15) /* G2 DMA complete */
+#define HW_EVENT_PVR2_DMA  (HW_EVENT_IRQ_BASE + 19) /* PVR2 DMA complete */
 
 /* IRQ 11 */
 #define HW_EVENT_GDROM_CMD (HW_EVENT_IRQ_BASE + 32) /* GD-ROM cmd. complete */
@@ -33,3 +38,6 @@
 #define HW_EVENT_EXTERNAL  (HW_EVENT_IRQ_BASE + 35) /* Ext. (expansion) */
 
 #define HW_EVENT_IRQ_MAX (HW_EVENT_IRQ_BASE + 95)
+
+#endif /* __ASM_SH_DREAMCAST_SYSASIC_H */
+
diff -puN -L include/asm-sh/ec3104.h include/asm-sh/ec3104.h~linus /dev/null
--- 25/include/asm-sh/ec3104.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,43 +0,0 @@
-#ifndef __ASM_EC3104_H
-#define __ASM_EC3104_H
-
-
-/*
- * Most of the register set is at 0xb0ec0000 - 0xb0ecffff.
- *
- * as far as I've figured it out the register map is:
- * 0xb0ec0000 - id string
- * 0xb0ec0XXX - power management
- * 0xb0ec1XXX - interrupt control
- * 0xb0ec3XXX - ps2 port (touch pad on aero 8000)
- * 0xb0ec6XXX - i2c
- * 0xb0ec7000 - first serial port (proprietary connector on aero 8000)
- * 0xb0ec8000 - second serial port
- * 0xb0ec9000 - third serial port
- * 0xb0eca000 - fourth serial port (keyboard controller on aero 8000)
- * 0xb0eccXXX - GPIO
- * 0xb0ecdXXX - GPIO
- */
-
-#define EC3104_BASE	0xb0ec0000
-
-#define EC3104_SER4_DATA	(EC3104_BASE+0xa000)
-#define EC3104_SER4_IIR		(EC3104_BASE+0xa008)
-#define EC3104_SER4_MCR		(EC3104_BASE+0xa010)
-#define EC3104_SER4_LSR		(EC3104_BASE+0xa014)
-#define EC3104_SER4_MSR		(EC3104_BASE+0xa018)
-
-/*
- * our ISA bus.  this seems to be real ISA.
- */
-#define EC3104_ISA_BASE	0xa5000000
-
-#define EC3104_IRQ	11
-#define EC3104_IRQBASE	64
-
-#define EC3104_IRQ_SER1	EC3104_IRQBASE + 7
-#define EC3104_IRQ_SER2	EC3104_IRQBASE + 8
-#define EC3104_IRQ_SER3	EC3104_IRQBASE + 9
-#define EC3104_IRQ_SER4	EC3104_IRQBASE + 10
-
-#endif /* __ASM_EC3104_H */
diff -puN include/asm-sh/ec3104/io.h~linus include/asm-sh/ec3104/io.h
--- 25/include/asm-sh/ec3104/io.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/ec3104/io.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,7 +1,6 @@
 #ifndef _ASM_SH_IO_EC3104_H
 #define _ASM_SH_IO_EC3104_H
 
-#include <asm/io_generic.h>
 #include <linux/types.h>
 
 extern unsigned char ec3104_inb(unsigned long port);
@@ -14,41 +13,4 @@ extern void ec3104_outl(unsigned long va
 
 extern int ec3104_irq_demux(int irq);
 
-#ifdef __WANT_IO_DEF
-
-# define __inb			ec3104_inb
-# define __inw			ec3104_inw
-# define __inl			ec3104_inl
-# define __outb			ec3104_outb
-# define __outw			ec3104_outw
-# define __outl			ec3104_outl
-
-# define __inb_p		ec3104_inb
-# define __inw_p		ec3104_inw
-# define __inl_p		ec3104_inl
-# define __outb_p		ec3104_outb
-# define __outw_p		ec3104_outw
-# define __outl_p		ec3104_outl
-
-# define __insb			generic_insb
-# define __insw			generic_insw
-# define __insl			generic_insl
-# define __outsb		generic_outsb
-# define __outsw		generic_outsw
-# define __outsl		generic_outsl
-
-# define __readb		generic_readb
-# define __readw		generic_readw
-# define __readl		generic_readl
-# define __writeb		generic_writeb
-# define __writew		generic_writew
-# define __writel		generic_writel
-
-# define __isa_port2addr	generic_isa_port2addr
-# define __ioremap		generic_ioremap
-# define __ioremap_nocache	generic_ioremap_nocache
-# define __iounmap		generic_iounmap
-
-#endif
-
 #endif /* _ASM_SH_IO_EC3104_H */
diff -puN /dev/null include/asm-sh/flat.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/asm-sh/flat.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,23 @@
+/*
+ * include/asm-sh/flat.h
+ *
+ * uClinux flat-format executables
+ *
+ * Copyright (C) 2003  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive for
+ * more details.
+ */
+#ifndef __ASM_SH_FLAT_H
+#define __ASM_SH_FLAT_H
+
+#define	flat_stack_align(sp)			/* nothing needed */
+#define	flat_argvp_envp_on_stack()		1
+#define	flat_old_ram_flag(flags)		(flags)
+#define	flat_reloc_valid(reloc, size)		((reloc) <= (size))
+#define	flat_get_addr_from_rp(rp, relval)	get_unaligned(rp)
+#define	flat_put_addr_at_rp(rp, val, relval)	put_unaligned(val,rp)
+#define	flat_get_relocate_addr(rel)		(rel)
+
+#endif /* __ASM_SH_FLAT_H */
diff -puN include/asm-sh/hardirq.h~linus include/asm-sh/hardirq.h
--- 25/include/asm-sh/hardirq.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/hardirq.h	2004-01-19 22:17:24.000000000 -0800
@@ -8,8 +8,6 @@
 /* entry.S is sensitive to the offsets of these fields */
 typedef struct {
 	unsigned int __softirq_pending;
-	unsigned int __syscall_count;
-	struct task_struct * __ksoftirqd_task;
 } ____cacheline_aligned irq_cpustat_t;
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
@@ -97,27 +95,4 @@ do {									\
 extern void synchronize_irq(unsigned int irq);
 #endif /* CONFIG_SMP */
 
-/* XXX: MRB-remove
-#define in_interrupt() ({ int __cpu = smp_processor_id(); \
-	(local_irq_count(__cpu) + local_bh_count(__cpu) != 0); })
-
-#define in_irq() (local_irq_count(smp_processor_id()) != 0)
-
-#ifndef CONFIG_SMP
-
-#define hardirq_trylock(cpu)	(local_irq_count(cpu) == 0)
-#define hardirq_endlock(cpu)	do { } while (0)
-
-#define irq_enter(cpu, irq)	(local_irq_count(cpu)++)
-#define irq_exit(cpu, irq)	(local_irq_count(cpu)--)
-
-#define synchronize_irq()	barrier()
-
-#else
-
-#error Super-H SMP is not available
-
-#endif
-*/
-
 #endif /* __ASM_SH_HARDIRQ_H */
diff -puN -L include/asm-sh/hd64461.h include/asm-sh/hd64461.h~linus /dev/null
--- 25/include/asm-sh/hd64461.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,75 +0,0 @@
-#ifndef __ASM_SH_HD64461
-#define __ASM_SH_HD64461
-/*
- *	$Id: hd64461.h,v 1.7 2001/07/07 11:43:58 yaegashi Exp $
- *	Copyright (C) 2000 YAEGASHI Takeshi
- *	Hitachi HD64461 companion chip support
- */
-#include <linux/config.h>
-
-#define HD64461_STBCR	0x10000
-#define HD64461_SYSCR	0x10002
-#define HD64461_SCPUCR	0x10004
-
-#define HD64461_LCDCBAR		0x11000
-#define HD64461_LCDCLOR		0x11002
-#define HD64461_LCDCCRR		0x11004
-#define	HD64461_LDR1		0x11010
-#define	HD64461_LDR2		0x11012
-#define	HD64461_LDHNCR		0x11014
-#define	HD64461_LDHNSR		0x11016
-#define HD64461_LDVNTR		0x11018
-#define HD64461_LDVNDR		0x1101a
-#define HD64461_LDVSPR		0x1101c
-#define HD64461_LDR3		0x1101e
-
-#define HD64461_CPTWAR		0x11030	
-#define HD64461_CPTWDR		0x11032
-#define HD64461_CPTRAR		0x11034	
-#define HD64461_CPTRDR		0x11036
-
-#define HD64461_PCC0ISR         0x12000
-#define HD64461_PCC0GCR         0x12002
-#define HD64461_PCC0CSCR        0x12004
-#define HD64461_PCC0CSCIER      0x12006
-#define HD64461_PCC0SCR         0x12008
-#define HD64461_PCC1ISR         0x12010
-#define HD64461_PCC1GCR         0x12012
-#define HD64461_PCC1CSCR        0x12014
-#define HD64461_PCC1CSCIER      0x12016
-#define HD64461_PCC1SCR         0x12018
-#define HD64461_P0OCR           0x1202a
-#define HD64461_P1OCR           0x1202c
-#define HD64461_PGCR            0x1202e
-
-#define HD64461_GPACR		0x14000
-#define HD64461_GPBCR		0x14002
-#define HD64461_GPCCR		0x14004
-#define HD64461_GPDCR		0x14006
-#define HD64461_GPADR		0x14010
-#define HD64461_GPBDR		0x14012
-#define HD64461_GPCDR		0x14014
-#define HD64461_GPDDR		0x14016
-#define HD64461_GPAICR		0x14020
-#define HD64461_GPBICR		0x14022
-#define HD64461_GPCICR		0x14024
-#define HD64461_GPDICR		0x14026
-#define HD64461_GPAISR		0x14040
-#define HD64461_GPBISR		0x14042
-#define HD64461_GPCISR		0x14044
-#define HD64461_GPDISR		0x14046
-
-#define HD64461_NIRR		0x15000
-#define HD64461_NIMR		0x15002
-
-#ifndef CONFIG_HD64461_IOBASE
-#define CONFIG_HD64461_IOBASE	0xb0000000
-#endif
-#ifndef CONFIG_HD64461_IRQ
-#define CONFIG_HD64461_IRQ	36
-#endif
-
-#define HD64461_IRQBASE		OFFCHIP_IRQ_BASE
-#define HD64461_IRQ_NUM 	16
-
-#endif
diff -puN include/asm-sh/hd64461/io.h~linus include/asm-sh/hd64461/io.h
--- 25/include/asm-sh/hd64461/io.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/hd64461/io.h	2004-01-19 22:17:24.000000000 -0800
@@ -12,8 +12,6 @@
 #ifndef _ASM_SH_IO_HD64461_H
 #define _ASM_SH_IO_HD64461_H
 
-#include <asm/io_generic.h>
-
 extern unsigned char hd64461_inb(unsigned long port);
 extern unsigned short hd64461_inw(unsigned long port);
 extern unsigned int hd64461_inl(unsigned long port);
@@ -25,49 +23,6 @@ extern void hd64461_outl(unsigned int va
 extern unsigned char hd64461_inb_p(unsigned long port);
 extern void hd64461_outb_p(unsigned char value, unsigned long port);
 
-extern void hd64461_insb(unsigned long port, void *addr, unsigned long count);
-extern void hd64461_insw(unsigned long port, void *addr, unsigned long count);
-extern void hd64461_insl(unsigned long port, void *addr, unsigned long count);
-extern void hd64461_outsb(unsigned long port, const void *addr, unsigned long count);
-extern void hd64461_outsw(unsigned long port, const void *addr, unsigned long count);
-extern void hd64461_outsl(unsigned long port, const void *addr, unsigned long count);
 extern int hd64461_irq_demux(int irq);
 
-#ifdef __WANT_IO_DEF
-
-# define __inb			hd64461_inb
-# define __inw			hd64461_inw
-# define __inl			hd64461_inl
-# define __outb			hd64461_outb
-# define __outw			hd64461_outw
-# define __outl			hd64461_outl
-
-# define __inb_p		hd64461_inb_p
-# define __inw_p		hd64461_inw
-# define __inl_p		hd64461_inl
-# define __outb_p		hd64461_outb_p
-# define __outw_p		hd64461_outw
-# define __outl_p		hd64461_outl
-
-# define __insb			hd64461_insb
-# define __insw			hd64461_insw
-# define __insl			hd64461_insl
-# define __outsb		hd64461_outsb
-# define __outsw		hd64461_outsw
-# define __outsl		hd64461_outsl
-
-# define __readb		generic_readb
-# define __readw		generic_readw
-# define __readl		generic_readl
-# define __writeb		generic_writeb
-# define __writew		generic_writew
-# define __writel		generic_writel
-
-# define __isa_port2addr	generic_isa_port2addr
-# define __ioremap		generic_ioremap
-# define __ioremap_nocache	generic_ioremap_nocache
-# define __iounmap		generic_iounmap
-
-#endif
-
 #endif /* _ASM_SH_IO_HD64461_H */
diff -puN -L include/asm-sh/hd64465_gpio.h include/asm-sh/hd64465_gpio.h~linus /dev/null
--- 25/include/asm-sh/hd64465_gpio.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,46 +0,0 @@
-#ifndef _ASM_SH_HD64465_GPIO_
-#define _ASM_SH_HD64465_GPIO_ 1
-/*
- * $Id: hd64465_gpio.h,v 1.2 2001/05/24 00:14:13 gniibe Exp $
- *
- * Hitachi HD64465 companion chip: General Purpose IO pins support.
- * This layer enables other device drivers to configure GPIO
- * pins, get and set their values, and register an interrupt
- * routine for when input pins change in hardware.
- *
- * by Greg Banks <gbanks@pocketpenguins.com>
- * (c) 2000 PocketPenguins Inc.
- */
-#include <asm/hd64465.h>
-
-/* Macro to construct a portpin number (used in all
- * subsequent functions) from a port letter and a pin
- * number, e.g. HD64465_GPIO_PORTPIN('A', 5).
- */
-#define HD64465_GPIO_PORTPIN(port,pin)	(((port)-'A')<<3|(pin))
-
-/* Pin configuration constants for _configure() */
-#define HD64465_GPIO_FUNCTION2	0	/* use the pin's *other* function */
-#define HD64465_GPIO_OUT	1	/* output */
-#define HD64465_GPIO_IN_PULLUP	2	/* input, pull-up MOS on */
-#define HD64465_GPIO_IN		3	/* input */
-
-/* Configure a pin's direction */
-extern void hd64465_gpio_configure(int portpin, int direction);
-
-/* Get, set value */
-extern void hd64465_gpio_set_pin(int portpin, unsigned int value);
-extern unsigned int hd64465_gpio_get_pin(int portpin);
-extern void hd64465_gpio_set_port(int port, unsigned int value);
-extern unsigned int hd64465_gpio_get_port(int port);
-
-/* mode constants for _register_irq() */
-#define HD64465_GPIO_FALLING	0
-#define HD64465_GPIO_RISING	1
-
-/* Interrupt on external value change */
-extern void hd64465_gpio_register_irq(int portpin, int mode,
-	void (*handler)(int portpin, void *dev), void *dev);
-extern void hd64465_gpio_unregister_irq(int portpin);
-
-#endif /* _ASM_SH_HD64465_GPIO_  */
diff -puN -L include/asm-sh/hd64465.h include/asm-sh/hd64465.h~linus /dev/null
--- 25/include/asm-sh/hd64465.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,257 +0,0 @@
-#ifndef _ASM_SH_HD64465_
-#define _ASM_SH_HD64465_ 1
-/*
- * $Id: hd64465.h,v 1.3 2001/02/07 18:31:20 stuart_menefy Exp $
- *
- * Hitachi HD64465 companion chip support
- *
- * by Greg Banks <gbanks@pocketpenguins.com>
- * (c) 2000 PocketPenguins Inc.
- *
- * Derived from <asm/hd64461.h> which bore the message:
- * Copyright (C) 2000 YAEGASHI Takeshi
- */
-#include <linux/config.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-
-/*
- * Note that registers are defined here as virtual port numbers,
- * which have no meaning except to get translated by hd64465_isa_port2addr()
- * to an address in the range 0xb0000000-0xb3ffffff.  Note that
- * this translation happens to consist of adding the lower 16 bits
- * of the virtual port number to 0xb0000000.  Note also that the manual
- * shows addresses as absolute physical addresses starting at 0x10000000,
- * so e.g. the NIRR register is listed as 0x15000 here, 0x10005000 in the
- * manual, and accessed using address 0xb0005000 - Greg.
- */
-
-/* System registers */
-#define HD64465_REG_SRR     0x1000c 	/* System Revision Register */
-#define HD64465_REG_SDID    0x10010 	/* System Device ID Reg */
-#define     HD64465_SDID            0x8122  /* 64465 device ID */
-
-/* Power Management registers */
-#define HD64465_REG_SMSCR   0x10000 	/* System Module Standby Control Reg */
-#define	    HD64465_SMSCR_PS2ST     0x4000  /* PS/2 Standby */
-#define	    HD64465_SMSCR_ADCST     0x1000  /* ADC Standby */
-#define	    HD64465_SMSCR_UARTST    0x0800  /* UART Standby */
-#define	    HD64465_SMSCR_SCDIST    0x0200  /* Serial Codec Standby */
-#define	    HD64465_SMSCR_PPST	    0x0100  /* Parallel Port Standby */
-#define	    HD64465_SMSCR_PC0ST     0x0040  /* PCMCIA0 Standby */
-#define	    HD64465_SMSCR_PC1ST     0x0020  /* PCMCIA1 Standby */
-#define	    HD64465_SMSCR_AFEST     0x0010  /* AFE Standby */
-#define	    HD64465_SMSCR_TM0ST     0x0008  /* Timer0 Standby */
-#define	    HD64465_SMSCR_TM1ST     0x0004  /* Timer1 Standby */
-#define	    HD64465_SMSCR_IRDAST    0x0002  /* IRDA Standby */
-#define	    HD64465_SMSCR_KBCST     0x0001  /* Keyboard Controller Standby */
- 
-/* Interrupt Controller registers */
-#define HD64465_REG_NIRR    0x15000  	/* Interrupt Request Register */
-#define HD64465_REG_NIMR    0x15002  	/* Interrupt Mask Register */
-#define HD64465_REG_NITR    0x15004  	/* Interrupt Trigger Mode Register */
-
-/* Timer registers */
-#define HD64465_REG_TCVR1   0x16000  	/* Timer 1 constant value register  */
-#define HD64465_REG_TCVR0   0x16002	/* Timer 0 constant value register  */
-#define HD64465_REG_TRVR1   0x16004	/* Timer 1 read value register  */
-#define HD64465_REG_TRVR0   0x16006	/* Timer 0 read value register  */
-#define HD64465_REG_TCR1    0x16008	/* Timer 1 control register  */
-#define HD64465_REG_TCR0    0x1600A	/* Timer 0 control register  */
-#define	    HD64465_TCR_EADT 	0x10	    /* Enable ADTRIG# signal */
-#define	    HD64465_TCR_ETMO 	0x08	    /* Enable TMO signal */
-#define	    HD64465_TCR_PST_MASK 0x06	    /* Clock Prescale */
-#define	    HD64465_TCR_PST_1 	0x06	    /* 1:1 */
-#define	    HD64465_TCR_PST_4 	0x04	    /* 1:4 */
-#define	    HD64465_TCR_PST_8 	0x02	    /* 1:8 */
-#define	    HD64465_TCR_PST_16 	0x00	    /* 1:16 */
-#define	    HD64465_TCR_TSTP 	0x01	    /* Start/Stop timer */
-#define HD64465_REG_TIRR    0x1600C	/* Timer interrupt request register  */
-#define HD64465_REG_TIDR    0x1600E	/* Timer interrupt disable register  */
-#define HD64465_REG_PWM1CS  0x16010	/* PWM 1 clock scale register  */
-#define HD64465_REG_PWM1LPC 0x16012	/* PWM 1 low pulse width counter register  */
-#define HD64465_REG_PWM1HPC 0x16014	/* PWM 1 high pulse width counter register  */
-#define HD64465_REG_PWM0CS  0x16018	/* PWM 0 clock scale register  */
-#define HD64465_REG_PWM0LPC 0x1601A	/* PWM 0 low pulse width counter register  */
-#define HD64465_REG_PWM0HPC 0x1601C	/* PWM 0 high pulse width counter register  */
-
-/* Analog/Digital Converter registers */
-#define HD64465_REG_ADDRA   0x1E000	/* A/D data register A */
-#define HD64465_REG_ADDRB   0x1E002	/* A/D data register B */
-#define HD64465_REG_ADDRC   0x1E004	/* A/D data register C */
-#define HD64465_REG_ADDRD   0x1E006	/* A/D data register D */
-#define HD64465_REG_ADCSR   0x1E008	/* A/D control/status register */
-#define     HD64465_ADCSR_ADF	    0x80    /* A/D End Flag */
-#define     HD64465_ADCSR_ADST	    0x40    /* A/D Start Flag */
-#define     HD64465_ADCSR_ADIS	    0x20    /* A/D Interrupt Status */
-#define     HD64465_ADCSR_TRGE	    0x10    /* A/D Trigger Enable */
-#define     HD64465_ADCSR_ADIE	    0x08    /* A/D Interrupt Enable */
-#define     HD64465_ADCSR_SCAN	    0x04    /* A/D Scan Mode */
-#define     HD64465_ADCSR_CH_MASK   0x03    /* A/D Channel */
-#define HD64465_REG_ADCALCR 0x1E00A  	/* A/D calibration sample control */
-#define HD64465_REG_ADCAL   0x1E00C  	/* A/D calibration data register */
-
-
-/* General Purpose I/O ports registers */
-#define HD64465_REG_GPACR   0x14000  	/* Port A Control Register */
-#define HD64465_REG_GPBCR   0x14002  	/* Port B Control Register */
-#define HD64465_REG_GPCCR   0x14004  	/* Port C Control Register */
-#define HD64465_REG_GPDCR   0x14006  	/* Port D Control Register */
-#define HD64465_REG_GPECR   0x14008  	/* Port E Control Register */
-#define HD64465_REG_GPADR   0x14010  	/* Port A Data Register */
-#define HD64465_REG_GPBDR   0x14012  	/* Port B Data Register */
-#define HD64465_REG_GPCDR   0x14014  	/* Port C Data Register */
-#define HD64465_REG_GPDDR   0x14016  	/* Port D Data Register */
-#define HD64465_REG_GPEDR   0x14018  	/* Port E Data Register */
-#define HD64465_REG_GPAICR  0x14020  	/* Port A Interrupt Control Register */
-#define HD64465_REG_GPBICR  0x14022  	/* Port B Interrupt Control Register */
-#define HD64465_REG_GPCICR  0x14024  	/* Port C Interrupt Control Register */
-#define HD64465_REG_GPDICR  0x14026  	/* Port D Interrupt Control Register */
-#define HD64465_REG_GPEICR  0x14028  	/* Port E Interrupt Control Register */
-#define HD64465_REG_GPAISR  0x14040  	/* Port A Interrupt Status Register */
-#define HD64465_REG_GPBISR  0x14042  	/* Port B Interrupt Status Register */
-#define HD64465_REG_GPCISR  0x14044  	/* Port C Interrupt Status Register */
-#define HD64465_REG_GPDISR  0x14046  	/* Port D Interrupt Status Register */
-#define HD64465_REG_GPEISR  0x14048  	/* Port E Interrupt Status Register */
-
-/* PCMCIA bridge interface */
-#define HD64465_REG_PCC0ISR	0x12000	/* socket 0 interface status */ 
-#define     HD64465_PCCISR_PREADY   	 0x80    /* mem card ready / io card IREQ */
-#define     HD64465_PCCISR_PIREQ    	 0x80
-#define     HD64465_PCCISR_PMWP     	 0x40    /* mem card write-protected */
-#define     HD64465_PCCISR_PVS2 	 0x20    /* voltage select pin 2 */
-#define     HD64465_PCCISR_PVS1 	 0x10    /* voltage select pin 1 */
-#define     HD64465_PCCISR_PCD_MASK 	 0x0c    /* card detect */
-#define     HD64465_PCCISR_PBVD_MASK     0x03    /* battery voltage */
-#define     HD64465_PCCISR_PBVD_BATGOOD  0x03    /* battery good */
-#define     HD64465_PCCISR_PBVD_BATWARN  0x01    /* battery low warning */
-#define     HD64465_PCCISR_PBVD_BATDEAD1 0x02    /* battery dead */
-#define     HD64465_PCCISR_PBVD_BATDEAD2 0x00    /* battery dead */
-#define HD64465_REG_PCC0GCR	0x12002	/* socket 0 general control */ 
-#define     HD64465_PCCGCR_PDRV   	 0x80    /* output drive */
-#define     HD64465_PCCGCR_PCCR   	 0x40    /* PC card reset */
-#define     HD64465_PCCGCR_PCCT   	 0x20    /* PC card type, 1=IO&mem, 0=mem */
-#define     HD64465_PCCGCR_PVCC0   	 0x10    /* voltage control pin VCC0SEL0 */
-#define     HD64465_PCCGCR_PMMOD   	 0x08    /* memory mode */
-#define     HD64465_PCCGCR_PPA25   	 0x04    /* pin A25 */
-#define     HD64465_PCCGCR_PPA24   	 0x02    /* pin A24 */
-#define     HD64465_PCCGCR_PREG   	 0x01    /* ping PCC0REG# */
-#define HD64465_REG_PCC0CSCR	0x12004	/* socket 0 card status change */ 
-#define     HD64465_PCCCSCR_PSCDI   	 0x80    /* sw card detect intr */
-#define     HD64465_PCCCSCR_PSWSEL   	 0x40    /* power select */
-#define     HD64465_PCCCSCR_PIREQ   	 0x20    /* IREQ intr req */
-#define     HD64465_PCCCSCR_PSC   	 0x10    /* STSCHG (status change) pin */
-#define     HD64465_PCCCSCR_PCDC   	 0x08    /* CD (card detect) change */
-#define     HD64465_PCCCSCR_PRC   	 0x04    /* ready change */
-#define     HD64465_PCCCSCR_PBW   	 0x02    /* battery warning change */
-#define     HD64465_PCCCSCR_PBD   	 0x01    /* battery dead change */
-#define HD64465_REG_PCC0CSCIER	0x12006	/* socket 0 card status change interrupt enable */ 
-#define     HD64465_PCCCSCIER_PCRE   	 0x80    /* change reset enable */
-#define     HD64465_PCCCSCIER_PIREQE_MASK   	0x60   /* IREQ enable */
-#define     HD64465_PCCCSCIER_PIREQE_DISABLED	0x00   /* IREQ disabled */
-#define     HD64465_PCCCSCIER_PIREQE_LEVEL  	0x20   /* IREQ level-triggered */
-#define     HD64465_PCCCSCIER_PIREQE_FALLING	0x40   /* IREQ falling-edge-trig */
-#define     HD64465_PCCCSCIER_PIREQE_RISING 	0x60   /* IREQ rising-edge-trig */
-#define     HD64465_PCCCSCIER_PSCE   	 0x10    /* status change enable */
-#define     HD64465_PCCCSCIER_PCDE   	 0x08    /* card detect change enable */
-#define     HD64465_PCCCSCIER_PRE   	 0x04    /* ready change enable */
-#define     HD64465_PCCCSCIER_PBWE   	 0x02    /* battery warn change enable */
-#define     HD64465_PCCCSCIER_PBDE   	 0x01    /* battery dead change enable*/
-#define HD64465_REG_PCC0SCR	0x12008	/* socket 0 software control */ 
-#define     HD64465_PCCSCR_SHDN   	 0x10    /* TPS2206 SHutDowN pin */
-#define     HD64465_PCCSCR_SWP   	 0x01    /* write protect */
-#define HD64465_REG_PCCPSR	0x1200A	/* serial power switch control */ 
-#define HD64465_REG_PCC1ISR	0x12010	/* socket 1 interface status */ 
-#define HD64465_REG_PCC1GCR	0x12012	/* socket 1 general control */ 
-#define HD64465_REG_PCC1CSCR	0x12014	/* socket 1 card status change */ 
-#define HD64465_REG_PCC1CSCIER	0x12016	/* socket 1 card status change interrupt enable */ 
-#define HD64465_REG_PCC1SCR	0x12018	/* socket 1 software control */ 
-
-
-/* PS/2 Keyboard and mouse controller -- *not* register compatible */
-#define HD64465_REG_KBCSR   	0x1dc00 /* Keyboard Control/Status reg */
-#define     HD64465_KBCSR_KBCIE   	 0x8000    /* KBCK Input Enable */
-#define     HD64465_KBCSR_KBCOE   	 0x4000    /* KBCK Output Enable */
-#define     HD64465_KBCSR_KBDOE   	 0x2000    /* KB DATA Output Enable */
-#define     HD64465_KBCSR_KBCD   	 0x1000    /* KBCK Driven */
-#define     HD64465_KBCSR_KBDD   	 0x0800    /* KB DATA Driven */
-#define     HD64465_KBCSR_KBCS   	 0x0400    /* KBCK pin Status */
-#define     HD64465_KBCSR_KBDS   	 0x0200    /* KB DATA pin Status */
-#define     HD64465_KBCSR_KBDP   	 0x0100    /* KB DATA Parity bit */
-#define     HD64465_KBCSR_KBD_MASK   	 0x00ff    /* KD DATA shift reg */
-#define HD64465_REG_KBISR   	0x1dc04 /* Keyboard Interrupt Status reg */
-#define     HD64465_KBISR_KBRDF   	 0x0001    /* KB Received Data Full */
-#define HD64465_REG_MSCSR   	0x1dc10 /* Mouse Control/Status reg */
-#define HD64465_REG_MSISR   	0x1dc14 /* Mouse Interrupt Status reg */
-
-
-/*
- * Logical address at which the HD64465 is mapped.  Note that this
- * should always be in the P2 segment (uncached and untranslated).
- */
-#ifndef CONFIG_HD64465_IOBASE
-#define CONFIG_HD64465_IOBASE	0xb0000000
-#endif
-/*
- * The HD64465 multiplexes all its modules' interrupts onto
- * this single interrupt.
- */
-#ifndef CONFIG_HD64465_IRQ
-#define CONFIG_HD64465_IRQ	5
-#endif
-
-
-#define _HD64465_IO_MASK	0xf8000000
-#define is_hd64465_addr(addr) \
-	((addr & _HD64465_IO_MASK) == (CONFIG_HD64465_IOBASE & _HD64465_IO_MASK))
-
-/*
- * A range of 16 virtual interrupts generated by
- * demuxing the HD64465 muxed interrupt.
- */
-#define HD64465_IRQ_BASE	OFFCHIP_IRQ_BASE
-#define HD64465_IRQ_NUM 	16
-#define HD64465_IRQ_ADC     	(HD64465_IRQ_BASE+0)
-#define HD64465_IRQ_USB     	(HD64465_IRQ_BASE+1)
-#define HD64465_IRQ_SCDI    	(HD64465_IRQ_BASE+2)
-#define HD64465_IRQ_PARALLEL	(HD64465_IRQ_BASE+3)
-/* bit 4 is reserved */
-#define HD64465_IRQ_UART    	(HD64465_IRQ_BASE+5)
-#define HD64465_IRQ_IRDA    	(HD64465_IRQ_BASE+6)
-#define HD64465_IRQ_PS2MOUSE	(HD64465_IRQ_BASE+7)
-#define HD64465_IRQ_KBC     	(HD64465_IRQ_BASE+8)
-#define HD64465_IRQ_TIMER1   	(HD64465_IRQ_BASE+9)
-#define HD64465_IRQ_TIMER0  	(HD64465_IRQ_BASE+10)
-#define HD64465_IRQ_GPIO    	(HD64465_IRQ_BASE+11)
-#define HD64465_IRQ_AFE     	(HD64465_IRQ_BASE+12)
-#define HD64465_IRQ_PCMCIA1 	(HD64465_IRQ_BASE+13)
-#define HD64465_IRQ_PCMCIA0 	(HD64465_IRQ_BASE+14)
-#define HD64465_IRQ_PS2KBD     	(HD64465_IRQ_BASE+15)
-
-/* Constants for PCMCIA mappings */
-#define HD64465_PCC_WINDOW	0x01000000
-
-#define HD64465_PCC0_BASE	0xb8000000	/* area 6 */
-#define HD64465_PCC0_ATTR	(HD64465_PCC0_BASE)
-#define HD64465_PCC0_COMM	(HD64465_PCC0_BASE+HD64465_PCC_WINDOW)
-#define HD64465_PCC0_IO		(HD64465_PCC0_BASE+2*HD64465_PCC_WINDOW)
-
-#define HD64465_PCC1_BASE	0xb4000000	/* area 5 */
-#define HD64465_PCC1_ATTR	(HD64465_PCC1_BASE)
-#define HD64465_PCC1_COMM	(HD64465_PCC1_BASE+HD64465_PCC_WINDOW)
-#define HD64465_PCC1_IO		(HD64465_PCC1_BASE+2*HD64465_PCC_WINDOW)
-
-/*
- * Base of USB controller interface (as memory)
- */
-#define HD64465_USB_BASE    	(CONFIG_HD64465_IOBASE+0xb000)
-#define HD64465_USB_LEN    	0x1000
-/*
- * Base of embedded SRAM, used for USB controller.
- */
-#define HD64465_SRAM_BASE    	(CONFIG_HD64465_IOBASE+0x9000)
-#define HD64465_SRAM_LEN    	0x1000
-
-
-
-#endif /* _ASM_SH_HD64465_  */
diff -puN include/asm-sh/hd64465/io.h~linus include/asm-sh/hd64465/io.h
--- 25/include/asm-sh/hd64465/io.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/hd64465/io.h	2004-01-19 22:17:24.000000000 -0800
@@ -16,8 +16,6 @@
 #ifndef _ASM_SH_IO_HD64465_H
 #define _ASM_SH_IO_HD64465_H
 
-#include <asm/io_generic.h>
-
 extern unsigned char hd64465_inb(unsigned long port);
 extern unsigned short hd64465_inw(unsigned long port);
 extern unsigned int hd64465_inl(unsigned long port);
@@ -29,12 +27,6 @@ extern void hd64465_outl(unsigned int va
 extern unsigned char hd64465_inb_p(unsigned long port);
 extern void hd64465_outb_p(unsigned char value, unsigned long port);
 
-extern void hd64465_insb(unsigned long port, void *addr, unsigned long count);
-extern void hd64465_insw(unsigned long port, void *addr, unsigned long count);
-extern void hd64465_insl(unsigned long port, void *addr, unsigned long count);
-extern void hd64465_outsb(unsigned long port, const void *addr, unsigned long count);
-extern void hd64465_outsw(unsigned long port, const void *addr, unsigned long count);
-extern void hd64465_outsl(unsigned long port, const void *addr, unsigned long count);
 extern unsigned long hd64465_isa_port2addr(unsigned long offset);
 extern int hd64465_irq_demux(int irq);
 /* Provision for generic secondary demux step -- used by PCMCIA code */
@@ -49,42 +41,4 @@ extern void hd64465_port_map(unsigned sh
 			     unsigned long addr, unsigned char shift);
 extern void hd64465_port_unmap(unsigned short baseport, unsigned int nports);
 
-
-#ifdef __WANT_IO_DEF
-
-# define __inb			hd64465_inb
-# define __inw			hd64465_inw
-# define __inl			hd64465_inl
-# define __outb			hd64465_outb
-# define __outw			hd64465_outw
-# define __outl			hd64465_outl
-
-# define __inb_p		hd64465_inb_p
-# define __inw_p		hd64465_inw
-# define __inl_p		hd64465_inl
-# define __outb_p		hd64465_outb_p
-# define __outw_p		hd64465_outw
-# define __outl_p		hd64465_outl
-
-# define __insb			hd64465_insb
-# define __insw			hd64465_insw
-# define __insl			hd64465_insl
-# define __outsb		hd64465_outsb
-# define __outsw		hd64465_outsw
-# define __outsl		hd64465_outsl
-
-# define __readb		generic_readb
-# define __readw		generic_readw
-# define __readl		generic_readl
-# define __writeb		generic_writeb
-# define __writew		generic_writew
-# define __writel		generic_writel
-
-# define __isa_port2addr	hd64465_isa_port2addr
-# define __ioremap		generic_ioremap
-# define __iounmap		generic_iounmap
-
-
-#endif
-
 #endif /* _ASM_SH_IO_HD64465_H */
diff -puN -L include/asm-sh/hitachi_7751se.h include/asm-sh/hitachi_7751se.h~linus /dev/null
--- 25/include/asm-sh/hitachi_7751se.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,68 +0,0 @@
-#ifndef __ASM_SH_HITACHI_7751SE_H
-#define __ASM_SH_HITACHI_7751SE_H
-
-/*
- * linux/include/asm-sh/hitachi_7751se.h
- *
- * Copyright (C) 2000  Kazumoto Kojima
- *
- * Hitachi SolutionEngine support
-
- * Modified for 7751 Solution Engine by
- * Ian da Silva and Jeremy Siegel, 2001.
- */
-
-/* Box specific addresses.  */
-
-#define PA_ROM		0x00000000	/* EPROM */
-#define PA_ROM_SIZE	0x00400000	/* EPROM size 4M byte */
-#define PA_FROM		0x01000000	/* EPROM */
-#define PA_FROM_SIZE	0x00400000	/* EPROM size 4M byte */
-#define PA_EXT1		0x04000000
-#define PA_EXT1_SIZE	0x04000000
-#define PA_EXT2		0x08000000
-#define PA_EXT2_SIZE	0x04000000
-#define PA_SDRAM	0x0c000000
-#define PA_SDRAM_SIZE	0x04000000
-
-#define PA_EXT4		0x12000000
-#define PA_EXT4_SIZE	0x02000000
-#define PA_EXT5		0x14000000
-#define PA_EXT5_SIZE	0x04000000
-#define PA_PCIC		0x18000000	/* MR-SHPC-01 PCMCIA */
-
-#define PA_DIPSW0	0xb9000000	/* Dip switch 5,6 */
-#define PA_DIPSW1	0xb9000002	/* Dip switch 7,8 */
-#define PA_LED		0xba000000	/* LED */
-#define	PA_BCR		0xbb000000	/* FPGA on the MS7751SE01 */
-
-#define PA_MRSHPC	0xb83fffe0	/* MR-SHPC-01 PCMCIA controler */
-#define PA_MRSHPC_MW1	0xb8400000	/* MR-SHPC-01 memory window base */
-#define PA_MRSHPC_MW2	0xb8500000	/* MR-SHPC-01 attribute window base */
-#define PA_MRSHPC_IO	0xb8600000	/* MR-SHPC-01 I/O window base */
-#define MRSHPC_MODE     (PA_MRSHPC + 4)
-#define MRSHPC_OPTION   (PA_MRSHPC + 6)
-#define MRSHPC_CSR      (PA_MRSHPC + 8)
-#define MRSHPC_ISR      (PA_MRSHPC + 10)
-#define MRSHPC_ICR      (PA_MRSHPC + 12)
-#define MRSHPC_CPWCR    (PA_MRSHPC + 14)
-#define MRSHPC_MW0CR1   (PA_MRSHPC + 16)
-#define MRSHPC_MW1CR1   (PA_MRSHPC + 18)
-#define MRSHPC_IOWCR1   (PA_MRSHPC + 20)
-#define MRSHPC_MW0CR2   (PA_MRSHPC + 22)
-#define MRSHPC_MW1CR2   (PA_MRSHPC + 24)
-#define MRSHPC_IOWCR2   (PA_MRSHPC + 26)
-#define MRSHPC_CDCR     (PA_MRSHPC + 28)
-#define MRSHPC_PCIC_INFO (PA_MRSHPC + 30)
-
-#define BCR_ILCRA	(PA_BCR + 0)
-#define BCR_ILCRB	(PA_BCR + 2)
-#define BCR_ILCRC	(PA_BCR + 4)
-#define BCR_ILCRD	(PA_BCR + 6)
-#define BCR_ILCRE	(PA_BCR + 8)
-#define BCR_ILCRF	(PA_BCR + 10)
-#define BCR_ILCRG	(PA_BCR + 12)
-
-#define IRQ_79C973	13
-
-#endif  /* __ASM_SH_HITACHI_7751SE_H */
diff -puN -L include/asm-sh/hitachi_se.h include/asm-sh/hitachi_se.h~linus /dev/null
--- 25/include/asm-sh/hitachi_se.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,69 +0,0 @@
-#ifndef __ASM_SH_HITACHI_SE_H
-#define __ASM_SH_HITACHI_SE_H
-
-/*
- * linux/include/asm-sh/hitachi_se.h
- *
- * Copyright (C) 2000  Kazumoto Kojima
- *
- * Hitachi SolutionEngine support
- */
-
-/* Box specific addresses.  */
-
-#define PA_ROM		0x00000000	/* EPROM */
-#define PA_ROM_SIZE	0x00400000	/* EPROM size 4M byte */
-#define PA_FROM		0x01000000	/* EPROM */
-#define PA_FROM_SIZE	0x00400000	/* EPROM size 4M byte */
-#define PA_EXT1		0x04000000
-#define PA_EXT1_SIZE	0x04000000
-#define PA_EXT2		0x08000000
-#define PA_EXT2_SIZE	0x04000000
-#define PA_SDRAM	0x0c000000
-#define PA_SDRAM_SIZE	0x04000000
-
-#define PA_EXT4		0x12000000
-#define PA_EXT4_SIZE	0x02000000
-#define PA_EXT5		0x14000000
-#define PA_EXT5_SIZE	0x04000000
-#define PA_PCIC		0x18000000	/* MR-SHPC-01 PCMCIA */
-
-#define PA_83902	0xb0000000	/* DP83902A */
-#define PA_83902_IF	0xb0040000	/* DP83902A remote io port */
-#define PA_83902_RST	0xb0080000	/* DP83902A reset port */
-
-#define PA_SUPERIO	0xb0400000	/* SMC37C935A super io chip */
-#define PA_DIPSW0	0xb0800000	/* Dip switch 5,6 */
-#define PA_DIPSW1	0xb0800002	/* Dip switch 7,8 */
-#define PA_LED		0xb0c00000	/* LED */
-#define PA_BCR		0xb1400000	/* FPGA */
-
-#define PA_MRSHPC	0xb83fffe0	/* MR-SHPC-01 PCMCIA controller */
-#define PA_MRSHPC_MW1	0xb8400000	/* MR-SHPC-01 memory window base */
-#define PA_MRSHPC_MW2	0xb8500000	/* MR-SHPC-01 attribute window base */
-#define PA_MRSHPC_IO	0xb8600000	/* MR-SHPC-01 I/O window base */
-#define MRSHPC_OPTION   (PA_MRSHPC + 6)
-#define MRSHPC_CSR      (PA_MRSHPC + 8)
-#define MRSHPC_ISR      (PA_MRSHPC + 10)
-#define MRSHPC_ICR      (PA_MRSHPC + 12)
-#define MRSHPC_CPWCR    (PA_MRSHPC + 14)
-#define MRSHPC_MW0CR1   (PA_MRSHPC + 16)
-#define MRSHPC_MW1CR1   (PA_MRSHPC + 18)
-#define MRSHPC_IOWCR1   (PA_MRSHPC + 20)
-#define MRSHPC_MW0CR2   (PA_MRSHPC + 22)
-#define MRSHPC_MW1CR2   (PA_MRSHPC + 24)
-#define MRSHPC_IOWCR2   (PA_MRSHPC + 26)
-#define MRSHPC_CDCR     (PA_MRSHPC + 28)
-#define MRSHPC_PCIC_INFO (PA_MRSHPC + 30)
-
-#define BCR_ILCRA	(PA_BCR + 0)
-#define BCR_ILCRB	(PA_BCR + 2)
-#define BCR_ILCRC	(PA_BCR + 4)
-#define BCR_ILCRD	(PA_BCR + 6)
-#define BCR_ILCRE	(PA_BCR + 8)
-#define BCR_ILCRF	(PA_BCR + 10)
-#define BCR_ILCRG	(PA_BCR + 12)
-
-#define IRQ_STNIC	10
-
-#endif  /* __ASM_SH_HITACHI_SE_H */
diff -puN -L include/asm-sh/io_7751se.h include/asm-sh/io_7751se.h~linus /dev/null
--- 25/include/asm-sh/io_7751se.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,80 +0,0 @@
-/*
- * include/asm-sh/io_7751se.h
- *
- * Modified version of io_se.h for the 7751se-specific functions.
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * IO functions for an Hitachi SolutionEngine
- */
-
-#ifndef _ASM_SH_IO_7751SE_H
-#define _ASM_SH_IO_7751SE_H
-
-#include <asm/io_generic.h>
-
-extern unsigned char sh7751se_inb(unsigned long port);
-extern unsigned short sh7751se_inw(unsigned long port);
-extern unsigned int sh7751se_inl(unsigned long port);
-
-extern void sh7751se_outb(unsigned char value, unsigned long port);
-extern void sh7751se_outw(unsigned short value, unsigned long port);
-extern void sh7751se_outl(unsigned int value, unsigned long port);
-
-extern unsigned char sh7751se_inb_p(unsigned long port);
-extern void sh7751se_outb_p(unsigned char value, unsigned long port);
-
-extern void sh7751se_insb(unsigned long port, void *addr, unsigned long count);
-extern void sh7751se_insw(unsigned long port, void *addr, unsigned long count);
-extern void sh7751se_insl(unsigned long port, void *addr, unsigned long count);
-extern void sh7751se_outsb(unsigned long port, const void *addr, unsigned long count);
-extern void sh7751se_outsw(unsigned long port, const void *addr, unsigned long count);
-extern void sh7751se_outsl(unsigned long port, const void *addr, unsigned long count);
-
-extern unsigned char sh7751se_readb(unsigned long addr);
-extern unsigned short sh7751se_readw(unsigned long addr);
-extern unsigned int sh7751se_readl(unsigned long addr);
-extern void sh7751se_writeb(unsigned char b, unsigned long addr);
-extern void sh7751se_writew(unsigned short b, unsigned long addr);
-extern void sh7751se_writel(unsigned int b, unsigned long addr);
-
-extern unsigned long sh7751se_isa_port2addr(unsigned long offset);
-
-#ifdef __WANT_IO_DEF
-
-# define __inb			sh7751se_inb
-# define __inw			sh7751se_inw
-# define __inl			sh7751se_inl
-# define __outb			sh7751se_outb
-# define __outw			sh7751se_outw
-# define __outl			sh7751se_outl
-
-# define __inb_p		sh7751se_inb_p
-# define __inw_p		sh7751se_inw
-# define __inl_p		sh7751se_inl
-# define __outb_p		sh7751se_outb_p
-# define __outw_p		sh7751se_outw
-# define __outl_p		sh7751se_outl
-
-# define __insb			sh7751se_insb
-# define __insw			sh7751se_insw
-# define __insl			sh7751se_insl
-# define __outsb		sh7751se_outsb
-# define __outsw		sh7751se_outsw
-# define __outsl		sh7751se_outsl
-
-# define __readb		sh7751se_readb
-# define __readw		sh7751se_readw
-# define __readl		sh7751se_readl
-# define __writeb		sh7751se_writeb
-# define __writew		sh7751se_writew
-# define __writel		sh7751se_writel
-
-# define __isa_port2addr	sh7751se_isa_port2addr
-# define __ioremap		generic_ioremap
-# define __iounmap		generic_iounmap
-
-#endif
-
-#endif /* _ASM_SH_IO_7751SE_H */
diff -puN -L include/asm-sh/io_adx.h include/asm-sh/io_adx.h~linus /dev/null
--- 25/include/asm-sh/io_adx.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,86 +0,0 @@
-/*
- * include/asm-sh/io_adx.h
- *
- * Copyright (C) 2001 A&D Co., Ltd.
- *
- * This file may be copied or modified under the terms of the GNU
- * General Public License.  See linux/COPYING for more information.
- *
- * IO functions for an A&D ADX Board
- */
-
-#ifndef _ASM_SH_IO_ADX_H
-#define _ASM_SH_IO_ADX_H
-
-#include <asm/io_generic.h>
-
-extern unsigned char adx_inb(unsigned long port);
-extern unsigned short adx_inw(unsigned long port);
-extern unsigned int adx_inl(unsigned long port);
-
-extern void adx_outb(unsigned char value, unsigned long port);
-extern void adx_outw(unsigned short value, unsigned long port);
-extern void adx_outl(unsigned int value, unsigned long port);
-
-extern unsigned char adx_inb_p(unsigned long port);
-extern void adx_outb_p(unsigned char value, unsigned long port);
-
-extern void adx_insb(unsigned long port, void *addr, unsigned long count);
-extern void adx_insw(unsigned long port, void *addr, unsigned long count);
-extern void adx_insl(unsigned long port, void *addr, unsigned long count);
-extern void adx_outsb(unsigned long port, const void *addr, unsigned long count);
-extern void adx_outsw(unsigned long port, const void *addr, unsigned long count);
-extern void adx_outsl(unsigned long port, const void *addr, unsigned long count);
-
-extern unsigned char adx_readb(unsigned long addr);
-extern unsigned short adx_readw(unsigned long addr);
-extern unsigned int adx_readl(unsigned long addr);
-extern void adx_writeb(unsigned char b, unsigned long addr);
-extern void adx_writew(unsigned short b, unsigned long addr);
-extern void adx_writel(unsigned int b, unsigned long addr);
-
-extern void * adx_ioremap(unsigned long offset, unsigned long size);
-extern void adx_iounmap(void *addr);
-
-extern unsigned long adx_isa_port2addr(unsigned long offset);
-
-extern void setup_adx(void);
-extern void init_adx_IRQ(void);
-
-#ifdef __WANT_IO_DEF
-
-#define __inb		adx_inb
-#define __inw		adx_inw
-#define __inl		adx_inl
-#define __outb		adx_outb
-#define __outw		adx_outw
-#define __outl		adx_outl
-
-#define __inb_p		adx_inb_p
-#define __inw_p		adx_inw
-#define __inl_p		adx_inl
-#define __outb_p	adx_outb_p
-#define __outw_p	adx_outw
-#define __outl_p	adx_outl
-
-#define __insb		adx_insb
-#define __insw		adx_insw
-#define __insl		adx_insl
-#define __outsb		adx_outsb
-#define __outsw		adx_outsw
-#define __outsl		adx_outsl
-
-#define __readb		adx_readb
-#define __readw		adx_readw
-#define __readl		adx_readl
-#define __writeb	adx_writeb
-#define __writew	adx_writew
-#define __writel	adx_writel
-
-#define __isa_port2addr	adx_isa_port2addr
-#define __ioremap	adx_ioremap
-#define __iounmap	adx_iounmap
-
-#endif
-
-#endif /* _ASM_SH_IO_AANDD_H */
diff -puN -L include/asm-sh/io_bigsur.h include/asm-sh/io_bigsur.h~linus /dev/null
--- 25/include/asm-sh/io_bigsur.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,89 +0,0 @@
-/*
- * include/asm-sh/io_bigsur.h
- *
- * By Dustin McIntire (dustin@sensoria.com) (c)2001
- * Derived from io_hd64465.h, which bore the message:
- * By Greg Banks <gbanks@pocketpenguins.com>
- * (c) 2000 PocketPenguins Inc. 
- * and from io_hd64461.h, which bore the message:
- * Copyright 2000 Stuart Menefy (stuart.menefy@st.com)
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * IO functions for a Hitachi Big Sur Evaluation Board.
- */
-
-#ifndef _ASM_SH_IO_BIGSUR_H
-#define _ASM_SH_IO_BIGSUR_H
-
-#include <linux/types.h>
-#include <asm/io_generic.h>
-
-extern unsigned char bigsur_inb(unsigned long port);
-extern unsigned short bigsur_inw(unsigned long port);
-extern unsigned int bigsur_inl(unsigned long port);
-
-extern void bigsur_outb(unsigned char value, unsigned long port);
-extern void bigsur_outw(unsigned short value, unsigned long port);
-extern void bigsur_outl(unsigned int value, unsigned long port);
-
-extern unsigned char bigsur_inb_p(unsigned long port);
-extern void bigsur_outb_p(unsigned char value, unsigned long port);
-
-extern void bigsur_insb(unsigned long port, void *addr, unsigned long count);
-extern void bigsur_insw(unsigned long port, void *addr, unsigned long count);
-extern void bigsur_insl(unsigned long port, void *addr, unsigned long count);
-extern void bigsur_outsb(unsigned long port, const void *addr, unsigned long count);
-extern void bigsur_outsw(unsigned long port, const void *addr, unsigned long count);
-extern void bigsur_outsl(unsigned long port, const void *addr, unsigned long count);
-extern unsigned long bigsur_isa_port2addr(unsigned long offset);
-extern int bigsur_irq_demux(int irq);
-extern void bigsur_init_pci(void);
-/* Provision for generic secondary demux step -- used by PCMCIA code */
-extern void bigsur_register_irq_demux(int irq,
-		int (*demux)(int irq, void *dev), void *dev);
-extern void bigsur_unregister_irq_demux(int irq);
-/* Set this variable to 1 to see port traffic */
-extern int bigsur_io_debug;
-/* Map a range of ports to a range of kernel virtual memory. */
-extern void bigsur_port_map(u32 baseport, u32 nports, u32 addr, u8 shift);
-extern void bigsur_port_unmap(u32 baseport, u32 nports);
-
-#endif /* _ASM_SH_IO_BIGSUR_H */
-
-#ifdef __WANT_IO_DEF
-
-# define __inb			bigsur_inb
-# define __inw			bigsur_inw
-# define __inl			bigsur_inl
-# define __outb			bigsur_outb
-# define __outw			bigsur_outw
-# define __outl			bigsur_outl
-
-# define __inb_p		bigsur_inb_p
-# define __inw_p		bigsur_inw
-# define __inl_p		bigsur_inl
-# define __outb_p		bigsur_outb_p
-# define __outw_p		bigsur_outw
-# define __outl_p		bigsur_outl
-
-# define __insb			bigsur_insb
-# define __insw			bigsur_insw
-# define __insl			bigsur_insl
-# define __outsb		bigsur_outsb
-# define __outsw		bigsur_outsw
-# define __outsl		bigsur_outsl
-
-# define __readb		generic_readb
-# define __readw		generic_readw
-# define __readl		generic_readl
-# define __writeb		generic_writeb
-# define __writew		generic_writew
-# define __writel		generic_writel
-
-# define __isa_port2addr	bigsur_isa_port2addr
-# define __ioremap		generic_ioremap
-# define __iounmap		generic_iounmap
-
-#endif
diff -puN -L include/asm-sh/io_cat68701.h include/asm-sh/io_cat68701.h~linus /dev/null
--- 25/include/asm-sh/io_cat68701.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,89 +0,0 @@
-/*
- * include/asm-sh/io_cat68701.h
- *
- * Copyright 2000 Stuart Menefy (stuart.menefy@st.com)
- *           2001 Yutarou Ebihar (ebihara@si-linux.com)
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * IO functions for an AONE Corp. CAT-68701 SH7708 Borad
- */
-
-#ifndef _ASM_SH_IO_CAT68701_H
-#define _ASM_SH_IO_CAT68701_H
-
-#include <asm/io_generic.h>
-
-extern unsigned char cat68701_inb(unsigned long port);
-extern unsigned short cat68701_inw(unsigned long port);
-extern unsigned int cat68701_inl(unsigned long port);
-
-extern void cat68701_outb(unsigned char value, unsigned long port);
-extern void cat68701_outw(unsigned short value, unsigned long port);
-extern void cat68701_outl(unsigned int value, unsigned long port);
-
-extern unsigned char cat68701_inb_p(unsigned long port);
-extern void cat68701_outb_p(unsigned char value, unsigned long port);
-
-extern void cat68701_insb(unsigned long port, void *addr, unsigned long count);
-extern void cat68701_insw(unsigned long port, void *addr, unsigned long count);
-extern void cat68701_insl(unsigned long port, void *addr, unsigned long count);
-extern void cat68701_outsb(unsigned long port, const void *addr, unsigned long count);
-extern void cat68701_outsw(unsigned long port, const void *addr, unsigned long count);
-extern void cat68701_outsl(unsigned long port, const void *addr, unsigned long count);
-
-extern unsigned char cat68701_readb(unsigned long addr);
-extern unsigned short cat68701_readw(unsigned long addr);
-extern unsigned int cat68701_readl(unsigned long addr);
-extern void cat68701_writeb(unsigned char b, unsigned long addr);
-extern void cat68701_writew(unsigned short b, unsigned long addr);
-extern void cat68701_writel(unsigned int b, unsigned long addr);
-
-extern void * cat68701_ioremap(unsigned long offset, unsigned long size);
-extern void cat68701_iounmap(void *addr);
-
-extern unsigned long cat68701_isa_port2addr(unsigned long offset);
-extern int cat68701_irq_demux(int irq);
-
-extern void setup_cat68701(void);
-extern void init_cat68701_IRQ(void);
-extern void heartbeat_cat68701(void);
-
-#ifdef __WANT_IO_DEF
-
-# define __inb			cat68701_inb
-# define __inw			cat68701_inw
-# define __inl			cat68701_inl
-# define __outb			cat68701_outb
-# define __outw			cat68701_outw
-# define __outl			cat68701_outl
-
-# define __inb_p		cat68701_inb_p
-# define __inw_p		cat68701_inw
-# define __inl_p		cat68701_inl
-# define __outb_p		cat68701_outb_p
-# define __outw_p		cat68701_outw
-# define __outl_p		cat68701_outl
-
-# define __insb			cat68701_insb
-# define __insw			cat68701_insw
-# define __insl			cat68701_insl
-# define __outsb		cat68701_outsb
-# define __outsw		cat68701_outsw
-# define __outsl		cat68701_outsl
-
-# define __readb		cat68701_readb
-# define __readw		cat68701_readw
-# define __readl		cat68701_readl
-# define __writeb		cat68701_writeb
-# define __writew		cat68701_writew
-# define __writel		cat68701_writel
-
-# define __isa_port2addr	cat68701_isa_port2addr
-# define __ioremap		generic_ioremap
-# define __iounmap		generic_iounmap
-
-#endif
-
-#endif /* _ASM_SH_IO_CAT68701_H */
diff -puN -L include/asm-sh/io_dc.h include/asm-sh/io_dc.h~linus /dev/null
--- 25/include/asm-sh/io_dc.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,49 +0,0 @@
-/*
- *	$Id: io_dc.h,v 1.1 2001/04/01 15:02:56 yaegashi Exp $
- *	IO functions for SEGA Dreamcast
- */
-
-#ifndef _ASM_SH_IO_DREAMCAST_H
-#define _ASM_SH_IO_DREAMCAST_H
-
-#include <asm/io_generic.h>
-
-unsigned long dreamcast_isa_port2addr(unsigned long offset);
-
-#ifdef __WANT_IO_DEF
-
-# define __inb			generic_inb
-# define __inw			generic_inw
-# define __inl			generic_inl
-# define __outb			generic_outb
-# define __outw			generic_outw
-# define __outl			generic_outl
-
-# define __inb_p		generic_inb_p
-# define __inw_p		generic_inw
-# define __inl_p		generic_inl
-# define __outb_p		generic_outb_p
-# define __outw_p		generic_outw
-# define __outl_p		generic_outl
-
-# define __insb			generic_insb
-# define __insw			generic_insw
-# define __insl			generic_insl
-# define __outsb		generic_outsb
-# define __outsw		generic_outsw
-# define __outsl		generic_outsl
-
-# define __readb		generic_readb
-# define __readw		generic_readw
-# define __readl		generic_readl
-# define __writeb		generic_writeb
-# define __writew		generic_writew
-# define __writel		generic_writel
-
-# define __isa_port2addr	dreamcast_isa_port2addr
-# define __ioremap		generic_ioremap
-# define __iounmap		generic_iounmap
-
-#endif
-
-#endif /* _ASM_SH_IO_DREAMCAST_H */
diff -puN -L include/asm-sh/io_ec3104.h include/asm-sh/io_ec3104.h~linus /dev/null
--- 25/include/asm-sh/io_ec3104.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,54 +0,0 @@
-#ifndef _ASM_SH_IO_EC3104_H
-#define _ASM_SH_IO_EC3104_H
-
-#include <asm/io_generic.h>
-#include <linux/types.h>
-
-extern unsigned char ec3104_inb(unsigned long port);
-extern unsigned short ec3104_inw(unsigned long port);
-extern unsigned long ec3104_inl(unsigned long port);
-
-extern void ec3104_outb(unsigned char value, unsigned long port);
-extern void ec3104_outw(unsigned short value, unsigned long port);
-extern void ec3104_outl(unsigned long value, unsigned long port);
-
-extern int ec3104_irq_demux(int irq);
-
-#ifdef __WANT_IO_DEF
-
-# define __inb			ec3104_inb
-# define __inw			ec3104_inw
-# define __inl			ec3104_inl
-# define __outb			ec3104_outb
-# define __outw			ec3104_outw
-# define __outl			ec3104_outl
-
-# define __inb_p		ec3104_inb
-# define __inw_p		ec3104_inw
-# define __inl_p		ec3104_inl
-# define __outb_p		ec3104_outb
-# define __outw_p		ec3104_outw
-# define __outl_p		ec3104_outl
-
-# define __insb			generic_insb
-# define __insw			generic_insw
-# define __insl			generic_insl
-# define __outsb		generic_outsb
-# define __outsw		generic_outsw
-# define __outsl		generic_outsl
-
-# define __readb		generic_readb
-# define __readw		generic_readw
-# define __readl		generic_readl
-# define __writeb		generic_writeb
-# define __writew		generic_writew
-# define __writel		generic_writel
-
-# define __isa_port2addr	generic_isa_port2addr
-# define __ioremap		generic_ioremap
-# define __ioremap_nocache	generic_ioremap_nocache
-# define __iounmap		generic_iounmap
-
-#endif
-
-#endif /* _ASM_SH_IO_EC3104_H */
diff -puN -L include/asm-sh/io_generic.h include/asm-sh/io_generic.h~linus /dev/null
--- 25/include/asm-sh/io_generic.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,51 +0,0 @@
-/*
- * include/asm-sh/io_generic.h
- *
- * Copyright 2000 Stuart Menefy (stuart.menefy@st.com)
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * Generic IO functions
- */
-
-#ifndef _ASM_SH_IO_GENERIC_H
-#define _ASM_SH_IO_GENERIC_H
-
-extern unsigned long generic_io_base;
-
-extern unsigned char generic_inb(unsigned long port);
-extern unsigned short generic_inw(unsigned long port);
-extern unsigned int generic_inl(unsigned long port);
-
-extern void generic_outb(unsigned char value, unsigned long port);
-extern void generic_outw(unsigned short value, unsigned long port);
-extern void generic_outl(unsigned int value, unsigned long port);
-
-extern unsigned char generic_inb_p(unsigned long port);
-extern unsigned short generic_inw_p(unsigned long port);
-extern unsigned int generic_inl_p(unsigned long port);
-extern void generic_outb_p(unsigned char value, unsigned long port);
-extern void generic_outw_p(unsigned short value, unsigned long port);
-extern void generic_outl_p(unsigned int value, unsigned long port);
-
-extern void generic_insb(unsigned long port, void *addr, unsigned long count);
-extern void generic_insw(unsigned long port, void *addr, unsigned long count);
-extern void generic_insl(unsigned long port, void *addr, unsigned long count);
-extern void generic_outsb(unsigned long port, const void *addr, unsigned long count);
-extern void generic_outsw(unsigned long port, const void *addr, unsigned long count);
-extern void generic_outsl(unsigned long port, const void *addr, unsigned long count);
-
-extern unsigned char generic_readb(unsigned long addr);
-extern unsigned short generic_readw(unsigned long addr);
-extern unsigned int generic_readl(unsigned long addr);
-extern void generic_writeb(unsigned char b, unsigned long addr);
-extern void generic_writew(unsigned short b, unsigned long addr);
-extern void generic_writel(unsigned int b, unsigned long addr);
-
-extern void *generic_ioremap(unsigned long offset, unsigned long size);
-extern void generic_iounmap(void *addr);
-
-extern unsigned long generic_isa_port2addr(unsigned long offset);
-
-#endif /* _ASM_SH_IO_GENERIC_H */
diff -puN include/asm-sh/io.h~linus include/asm-sh/io.h
--- 25/include/asm-sh/io.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/io.h	2004-01-19 22:17:24.000000000 -0800
@@ -18,8 +18,7 @@
 
 /*
  * We follow the Alpha convention here:
- *  __inb expands to an inline function call (which either calls via the
- *        mach_vec if generic, or a machine specific implementation)
+ *  __inb expands to an inline function call (which calls via the mv)
  *  _inb  is a real function call (note ___raw fns are _ version of __raw)
  *  inb   by default expands to _inb, but the machine specific code may
  *        define it to __inb if it chooses.
@@ -27,6 +26,8 @@
 
 #include <asm/cache.h>
 #include <asm/system.h>
+#include <asm/addrspace.h>
+#include <asm/machvec.h>
 #include <linux/config.h>
 
 /*
@@ -35,11 +36,13 @@
  */
 
 #ifdef __KERNEL__
-#if defined(CONFIG_SH_GENERIC) || defined(CONFIG_SH_CQREEK) || defined(CONFIG_SH_UNKNOWN)
-
-/* In a generic kernel, we always go through the machine vector.  */
-
-#include <asm/machvec.h>
+/*
+ * Since boards are able to define their own set of I/O routines through
+ * their respective machine vector, we always wrap through the mv.
+ *
+ * Also, in the event that a board hasn't provided its own definition for
+ * a given routine, it will be wrapped to generic code at run-time.
+ */
 
 # define __inb(p)	sh_mv.mv_inb((p))
 # define __inw(p)	sh_mv.mv_inw((p))
@@ -55,12 +58,12 @@
 # define __outw_p(x,p)	sh_mv.mv_outw_p((x),(p))
 # define __outl_p(x,p)	sh_mv.mv_outl_p((x),(p))
 
-#define __insb(p,b,c)	sh_mv.mv_insb((p), (b), (c))
-#define __insw(p,b,c)	sh_mv.mv_insw((p), (b), (c))
-#define __insl(p,b,c)	sh_mv.mv_insl((p), (b), (c))
-#define __outsb(p,b,c)	sh_mv.mv_outsb((p), (b), (c))
-#define __outsw(p,b,c)	sh_mv.mv_outsw((p), (b), (c))
-#define __outsl(p,b,c)	sh_mv.mv_outsl((p), (b), (c))
+# define __insb(p,b,c)	sh_mv.mv_insb((p), (b), (c))
+# define __insw(p,b,c)	sh_mv.mv_insw((p), (b), (c))
+# define __insl(p,b,c)	sh_mv.mv_insl((p), (b), (c))
+# define __outsb(p,b,c)	sh_mv.mv_outsb((p), (b), (c))
+# define __outsw(p,b,c)	sh_mv.mv_outsw((p), (b), (c))
+# define __outsl(p,b,c)	sh_mv.mv_outsl((p), (b), (c))
 
 # define __readb(a)	sh_mv.mv_readb((a))
 # define __readw(a)	sh_mv.mv_readw((a))
@@ -102,205 +105,31 @@
 # define __raw_writew	__writew
 # define __raw_writel	__writel
 
-#else
-
-/* Control operations through platform specific headers */
-# define __WANT_IO_DEF
-
-# include <asm/mach/io.h>
-
-#undef __WANT_IO_DEF
-
-#endif /* GENERIC */
-#endif /* __KERNEL__ */
-
-/* These are always function calls, in both kernel and user space */
-extern unsigned char	_inb (unsigned long port);
-extern unsigned short	_inw (unsigned long port);
-extern unsigned int	_inl (unsigned long port);
-extern void		_outb (unsigned char b, unsigned long port);
-extern void		_outw (unsigned short w, unsigned long port);
-extern void		_outl (unsigned int l, unsigned long port);
-extern unsigned char	_inb_p (unsigned long port);
-extern unsigned short	_inw_p (unsigned long port);
-extern unsigned int	_inl_p (unsigned long port);
-extern void		_outb_p (unsigned char b, unsigned long port);
-extern void		_outw_p (unsigned short w, unsigned long port);
-extern void		_outl_p (unsigned int l, unsigned long port);
-extern void		_insb (unsigned long port, void *dst, unsigned long count);
-extern void		_insw (unsigned long port, void *dst, unsigned long count);
-extern void		_insl (unsigned long port, void *dst, unsigned long count);
-extern void		_outsb (unsigned long port, const void *src, unsigned long count);
-extern void		_outsw (unsigned long port, const void *src, unsigned long count);
-extern void		_outsl (unsigned long port, const void *src, unsigned long count);
-extern unsigned char	_readb(unsigned long addr);
-extern unsigned short	_readw(unsigned long addr);
-extern unsigned int	_readl(unsigned long addr);
-extern void		_writeb(unsigned char b, unsigned long addr);
-extern void		_writew(unsigned short b, unsigned long addr);
-extern void		_writel(unsigned int b, unsigned long addr);
-
-#ifdef __KERNEL__
-extern unsigned char	___raw_readb(unsigned long addr);
-extern unsigned short	___raw_readw(unsigned long addr);
-extern unsigned int	___raw_readl(unsigned long addr);
-extern void		___raw_writeb(unsigned char b, unsigned long addr);
-extern void		___raw_writew(unsigned short b, unsigned long addr);
-extern void		___raw_writel(unsigned int b, unsigned long addr);
-#endif
-
-#ifdef __KERNEL__
 /*
  * The platform header files may define some of these macros to use
  * the inlined versions where appropriate.  These macros may also be
  * redefined by userlevel programs.
  */
-#ifndef inb
-# define inb(p)		_inb(p)
-#endif
-#ifndef inw
-# define inw(p)		_inw(p)
-#endif
-#ifndef inl
-# define inl(p)		_inl(p)
-#endif
-
-#ifndef outb
-# define outb(b,p)	_outb((b),(p))
-#endif
-#ifndef outw
-# define outw(w,p)	_outw((w),(p))
-#endif
-#ifndef outl
-# define outl(l,p)	_outl((l),(p))
-#endif
-
-#ifndef inb_p
-# define inb_p		_inb_p
-#endif
-#ifndef inw_p
-# define inw_p		_inw_p
-#endif
-#ifndef inl_p
-# define inl_p		_inl_p
-#endif
-
-#ifndef outb_p
-# define outb_p		_outb_p
-#endif
-#ifndef outw_p
-# define outw_p		_outw_p
-#endif
-#ifndef outl_p
-# define outl_p		_outl_p
-#endif
-
-#ifndef insb
-# define insb(p,d,c)	_insb((p),(d),(c))
-#endif
-#ifndef insw
-# define insw(p,d,c)	_insw((p),(d),(c))
-#endif
-#ifndef insl
-# define insl(p,d,c)	_insl((p),(d),(c))
-#endif
-#ifndef outsb
-# define outsb(p,s,c)	_outsb((p),(s),(c))
-#endif
-#ifndef outsw
-# define outsw(p,s,c)	_outsw((p),(s),(c))
-#endif
-#ifndef outsl
-# define outsl(p,s,c)	_outsl((p),(s),(c))
-#endif
-
 #ifdef __raw_readb
-# define readb(a)	({ unsigned long r_ = __raw_readb(a); mb(); r_; })
+# define readb(a)	({ unsigned long r_ = __raw_readb((unsigned long)a); mb(); r_; })
 #endif
 #ifdef __raw_readw
-# define readw(a)	({ unsigned long r_ = __raw_readw(a); mb(); r_; })
+# define readw(a)	({ unsigned long r_ = __raw_readw((unsigned long)a); mb(); r_; })
 #endif
 #ifdef __raw_readl
-# define readl(a)	({ unsigned long r_ = __raw_readl(a); mb(); r_; })
+# define readl(a)	({ unsigned long r_ = __raw_readl((unsigned long)a); mb(); r_; })
 #endif
 
 #ifdef __raw_writeb
-# define writeb(v,a)	({ __raw_writeb((v),(a)); mb(); })
+# define writeb(v,a)	({ __raw_writeb((v),(unsigned long)(a)); mb(); })
 #endif
 #ifdef __raw_writew
-# define writew(v,a)	({ __raw_writew((v),(a)); mb(); })
+# define writew(v,a)	({ __raw_writew((v),(unsigned long)(a)); mb(); })
 #endif
 #ifdef __raw_writel
-# define writel(v,a)	({ __raw_writel((v),(a)); mb(); })
-#endif
-
-#ifndef __raw_readb
-# define __raw_readb(a)	___raw_readb((unsigned long)(a))
-#endif
-#ifndef __raw_readw
-# define __raw_readw(a)	___raw_readw((unsigned long)(a))
-#endif
-#ifndef __raw_readl
-# define __raw_readl(a)	___raw_readl((unsigned long)(a))
+# define writel(v,a)	({ __raw_writel((v),(unsigned long)(a)); mb(); })
 #endif
 
-#ifndef __raw_writeb
-# define __raw_writeb(v,a)  ___raw_writeb((v),(unsigned long)(a))
-#endif
-#ifndef __raw_writew
-# define __raw_writew(v,a)  ___raw_writew((v),(unsigned long)(a))
-#endif
-#ifndef __raw_writel
-# define __raw_writel(v,a)  ___raw_writel((v),(unsigned long)(a))
-#endif
-
-#ifndef readb
-# define readb(a)	_readb((unsigned long)(a))
-#endif
-#ifndef readw
-# define readw(a)	_readw((unsigned long)(a))
-#endif
-#ifndef readl
-# define readl(a)	_readl((unsigned long)(a))
-#endif
-
-#ifndef writeb
-# define writeb(v,a)	_writeb((v),(unsigned long)(a))
-#endif
-#ifndef writew
-# define writew(v,a)	_writew((v),(unsigned long)(a))
-#endif
-#ifndef writel
-# define writel(v,a)	_writel((v),(unsigned long)(a))
-#endif
-
-#else 
-
-/* Userspace declarations.  */
-
-extern unsigned char	inb(unsigned long port);
-extern unsigned short	inw(unsigned long port);
-extern unsigned int	inl(unsigned long port);
-extern void		outb(unsigned char b, unsigned long port);
-extern void		outw(unsigned short w, unsigned long port);
-extern void		outl(unsigned int l, unsigned long port);
-extern void		insb(unsigned long port, void *dst, unsigned long count);
-extern void		insw(unsigned long port, void *dst, unsigned long count);
-extern void		insl(unsigned long port, void *dst, unsigned long count);
-extern void		outsb(unsigned long port, const void *src, unsigned long count);
-extern void		outsw(unsigned long port, const void *src, unsigned long count);
-extern void		outsl(unsigned long port, const void *src, unsigned long count);
-extern unsigned char	readb(unsigned long addr);
-extern unsigned short	readw(unsigned long addr);
-extern unsigned long	readl(unsigned long addr);
-extern void		writeb(unsigned char b, unsigned long addr);
-extern void		writew(unsigned short b, unsigned long addr);
-extern void		writel(unsigned int b, unsigned long addr);
-
-#endif /* __KERNEL__ */
-
-#ifdef __KERNEL__
-
 /*
  * If the platform has PC-like I/O, this function converts the offset into
  * an address.
@@ -310,6 +139,20 @@ static __inline__ unsigned long isa_port
 	return __isa_port2addr(offset);
 }
 
+/*
+ * This function provides a method for the generic case where a board-specific
+ * isa_port2addr simply needs to return the port + some arbitrary port base.
+ *
+ * We use this at board setup time to implicitly set the port base, and
+ * as a result, we can use the generic isa_port2addr.
+ */
+static inline void __set_io_port_base(unsigned long pbase)
+{
+	extern unsigned long generic_io_base;
+
+	generic_io_base = pbase;
+}
+
 #define isa_readb(a) readb(isa_port2addr(a))
 #define isa_readw(a) readw(isa_port2addr(a))
 #define isa_readl(a) readl(isa_port2addr(a))
@@ -361,8 +204,6 @@ static __inline__ void ctrl_outl(unsigne
 
 #define IO_SPACE_LIMIT 0xffffffff
 
-#include <asm/addrspace.h>
-
 /*
  * Change virtual addresses to physical addresses and vv.
  * These are trivial on the 1:1 Linux/SuperH mapping
@@ -449,4 +290,5 @@ out:
     __flush_wback_region(_start,_size)
 
 #endif /* __KERNEL__ */
+
 #endif /* __ASM_SH_IO_H */
diff -puN -L include/asm-sh/io_hd64461.h include/asm-sh/io_hd64461.h~linus /dev/null
--- 25/include/asm-sh/io_hd64461.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,73 +0,0 @@
-/*
- * include/asm-sh/io_hd64461.h
- *
- * Copyright 2000 Stuart Menefy (stuart.menefy@st.com)
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * IO functions for an HD64461
- */
-
-#ifndef _ASM_SH_IO_HD64461_H
-#define _ASM_SH_IO_HD64461_H
-
-#include <asm/io_generic.h>
-
-extern unsigned char hd64461_inb(unsigned long port);
-extern unsigned short hd64461_inw(unsigned long port);
-extern unsigned int hd64461_inl(unsigned long port);
-
-extern void hd64461_outb(unsigned char value, unsigned long port);
-extern void hd64461_outw(unsigned short value, unsigned long port);
-extern void hd64461_outl(unsigned int value, unsigned long port);
-
-extern unsigned char hd64461_inb_p(unsigned long port);
-extern void hd64461_outb_p(unsigned char value, unsigned long port);
-
-extern void hd64461_insb(unsigned long port, void *addr, unsigned long count);
-extern void hd64461_insw(unsigned long port, void *addr, unsigned long count);
-extern void hd64461_insl(unsigned long port, void *addr, unsigned long count);
-extern void hd64461_outsb(unsigned long port, const void *addr, unsigned long count);
-extern void hd64461_outsw(unsigned long port, const void *addr, unsigned long count);
-extern void hd64461_outsl(unsigned long port, const void *addr, unsigned long count);
-extern int hd64461_irq_demux(int irq);
-
-#ifdef __WANT_IO_DEF
-
-# define __inb			hd64461_inb
-# define __inw			hd64461_inw
-# define __inl			hd64461_inl
-# define __outb			hd64461_outb
-# define __outw			hd64461_outw
-# define __outl			hd64461_outl
-
-# define __inb_p		hd64461_inb_p
-# define __inw_p		hd64461_inw
-# define __inl_p		hd64461_inl
-# define __outb_p		hd64461_outb_p
-# define __outw_p		hd64461_outw
-# define __outl_p		hd64461_outl
-
-# define __insb			hd64461_insb
-# define __insw			hd64461_insw
-# define __insl			hd64461_insl
-# define __outsb		hd64461_outsb
-# define __outsw		hd64461_outsw
-# define __outsl		hd64461_outsl
-
-# define __readb		generic_readb
-# define __readw		generic_readw
-# define __readl		generic_readl
-# define __writeb		generic_writeb
-# define __writew		generic_writew
-# define __writel		generic_writel
-
-# define __isa_port2addr	generic_isa_port2addr
-# define __ioremap		generic_ioremap
-# define __ioremap_nocache	generic_ioremap_nocache
-# define __iounmap		generic_iounmap
-
-#endif
-
-#endif /* _ASM_SH_IO_HD64461_H */
diff -puN -L include/asm-sh/io_hd64465.h include/asm-sh/io_hd64465.h~linus /dev/null
--- 25/include/asm-sh/io_hd64465.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,90 +0,0 @@
-/*
- * include/asm-sh/io_hd64465.h
- *
- * By Greg Banks <gbanks@pocketpenguins.com>
- * (c) 2000 PocketPenguins Inc.
- *
- * Derived from io_hd64461.h, which bore the message:
- * Copyright 2000 Stuart Menefy (stuart.menefy@st.com)
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * IO functions for an HD64465 "Windows CE Intelligent Peripheral Controller".
- */
-
-#ifndef _ASM_SH_IO_HD64465_H
-#define _ASM_SH_IO_HD64465_H
-
-#include <asm/io_generic.h>
-
-extern unsigned char hd64465_inb(unsigned long port);
-extern unsigned short hd64465_inw(unsigned long port);
-extern unsigned int hd64465_inl(unsigned long port);
-
-extern void hd64465_outb(unsigned char value, unsigned long port);
-extern void hd64465_outw(unsigned short value, unsigned long port);
-extern void hd64465_outl(unsigned int value, unsigned long port);
-
-extern unsigned char hd64465_inb_p(unsigned long port);
-extern void hd64465_outb_p(unsigned char value, unsigned long port);
-
-extern void hd64465_insb(unsigned long port, void *addr, unsigned long count);
-extern void hd64465_insw(unsigned long port, void *addr, unsigned long count);
-extern void hd64465_insl(unsigned long port, void *addr, unsigned long count);
-extern void hd64465_outsb(unsigned long port, const void *addr, unsigned long count);
-extern void hd64465_outsw(unsigned long port, const void *addr, unsigned long count);
-extern void hd64465_outsl(unsigned long port, const void *addr, unsigned long count);
-extern unsigned long hd64465_isa_port2addr(unsigned long offset);
-extern int hd64465_irq_demux(int irq);
-/* Provision for generic secondary demux step -- used by PCMCIA code */
-extern void hd64465_register_irq_demux(int irq,
-		int (*demux)(int irq, void *dev), void *dev);
-extern void hd64465_unregister_irq_demux(int irq);
-/* Set this variable to 1 to see port traffic */
-extern int hd64465_io_debug;
-/* Map a range of ports to a range of kernel virtual memory.
- */
-extern void hd64465_port_map(unsigned short baseport, unsigned int nports,
-			     unsigned long addr, unsigned char shift);
-extern void hd64465_port_unmap(unsigned short baseport, unsigned int nports);
-
-
-#ifdef __WANT_IO_DEF
-
-# define __inb			hd64465_inb
-# define __inw			hd64465_inw
-# define __inl			hd64465_inl
-# define __outb			hd64465_outb
-# define __outw			hd64465_outw
-# define __outl			hd64465_outl
-
-# define __inb_p		hd64465_inb_p
-# define __inw_p		hd64465_inw
-# define __inl_p		hd64465_inl
-# define __outb_p		hd64465_outb_p
-# define __outw_p		hd64465_outw
-# define __outl_p		hd64465_outl
-
-# define __insb			hd64465_insb
-# define __insw			hd64465_insw
-# define __insl			hd64465_insl
-# define __outsb		hd64465_outsb
-# define __outsw		hd64465_outsw
-# define __outsl		hd64465_outsl
-
-# define __readb		generic_readb
-# define __readw		generic_readw
-# define __readl		generic_readl
-# define __writeb		generic_writeb
-# define __writew		generic_writew
-# define __writel		generic_writel
-
-# define __isa_port2addr	hd64465_isa_port2addr
-# define __ioremap		generic_ioremap
-# define __iounmap		generic_iounmap
-
-
-#endif
-
-#endif /* _ASM_SH_IO_HD64465_H */
diff -puN -L include/asm-sh/io_se.h include/asm-sh/io_se.h~linus /dev/null
--- 25/include/asm-sh/io_se.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,80 +0,0 @@
-/*
- * include/asm-sh/io_se.h
- *
- * Copyright 2000 Stuart Menefy (stuart.menefy@st.com)
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * IO functions for an Hitachi SolutionEngine
- */
-
-#ifndef _ASM_SH_IO_SE_H
-#define _ASM_SH_IO_SE_H
-
-#include <asm/io_generic.h>
-
-extern unsigned char se_inb(unsigned long port);
-extern unsigned short se_inw(unsigned long port);
-extern unsigned int se_inl(unsigned long port);
-
-extern void se_outb(unsigned char value, unsigned long port);
-extern void se_outw(unsigned short value, unsigned long port);
-extern void se_outl(unsigned int value, unsigned long port);
-
-extern unsigned char se_inb_p(unsigned long port);
-extern void se_outb_p(unsigned char value, unsigned long port);
-
-extern void se_insb(unsigned long port, void *addr, unsigned long count);
-extern void se_insw(unsigned long port, void *addr, unsigned long count);
-extern void se_insl(unsigned long port, void *addr, unsigned long count);
-extern void se_outsb(unsigned long port, const void *addr, unsigned long count);
-extern void se_outsw(unsigned long port, const void *addr, unsigned long count);
-extern void se_outsl(unsigned long port, const void *addr, unsigned long count);
-
-extern unsigned char se_readb(unsigned long addr);
-extern unsigned short se_readw(unsigned long addr);
-extern unsigned int se_readl(unsigned long addr);
-extern void se_writeb(unsigned char b, unsigned long addr);
-extern void se_writew(unsigned short b, unsigned long addr);
-extern void se_writel(unsigned int b, unsigned long addr);
-
-extern unsigned long se_isa_port2addr(unsigned long offset);
-
-#ifdef __WANT_IO_DEF
-
-# define __inb			se_inb
-# define __inw			se_inw
-# define __inl			se_inl
-# define __outb			se_outb
-# define __outw			se_outw
-# define __outl			se_outl
-
-# define __inb_p		se_inb_p
-# define __inw_p		se_inw
-# define __inl_p		se_inl
-# define __outb_p		se_outb_p
-# define __outw_p		se_outw
-# define __outl_p		se_outl
-
-# define __insb			se_insb
-# define __insw			se_insw
-# define __insl			se_insl
-# define __outsb		se_outsb
-# define __outsw		se_outsw
-# define __outsl		se_outsl
-
-# define __readb		se_readb
-# define __readw		se_readw
-# define __readl		se_readl
-# define __writeb		se_writeb
-# define __writew		se_writew
-# define __writel		se_writel
-
-# define __isa_port2addr	se_isa_port2addr
-# define __ioremap		generic_ioremap
-# define __iounmap		generic_iounmap
-
-#endif
-
-#endif /* _ASM_SH_IO_SE_H */
diff -puN -L include/asm-sh/io_sh2000.h include/asm-sh/io_sh2000.h~linus /dev/null
--- 25/include/asm-sh/io_sh2000.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,56 +0,0 @@
-/*
- * include/asm-sh/io_sh2000.h
- *
- * Copyright 2000 Stuart Menefy (stuart.menefy@st.com)
- *           2001 SUGIOKA Toshinobu (sugioka@itonet.co.jp)
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * IO functions for use when we don't know what machine we are on
- */
-
-#ifndef _ASM_SH_IO_SH2000_H
-#define _ASM_SH_IO_SH2000_H
-
-#include <asm/io_generic.h>
-
-unsigned long sh2000_isa_port2addr(unsigned long offset);
-
-#ifdef __WANT_IO_DEF
-
-# define __inb			generic_inb
-# define __inw			generic_inw
-# define __inl			generic_inl
-# define __outb			generic_outb
-# define __outw			generic_outw
-# define __outl			generic_outl
-
-# define __inb_p		generic_inb_p
-# define __inw_p		generic_inw
-# define __inl_p		generic_inl
-# define __outb_p		generic_outb_p
-# define __outw_p		generic_outw
-# define __outl_p		generic_outl
-
-# define __insb			generic_insb
-# define __insw			generic_insw
-# define __insl			generic_insl
-# define __outsb		generic_outsb
-# define __outsw		generic_outsw
-# define __outsl		generic_outsl
-
-# define __readb		generic_readb
-# define __readw		generic_readw
-# define __readl		generic_readl
-# define __writeb		generic_writeb
-# define __writew		generic_writew
-# define __writel		generic_writel
-
-# define __isa_port2addr	sh2000_isa_port2addr
-# define __ioremap		generic_ioremap
-# define __iounmap		generic_iounmap
-
-#endif
-
-#endif /* _ASM_SH_IO_SH2000_H */
diff -puN -L include/asm-sh/io_unknown.h include/asm-sh/io_unknown.h~linus /dev/null
--- 25/include/asm-sh/io_unknown.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,84 +0,0 @@
-/*
- * include/asm-sh/io_unknown.h
- *
- * Copyright 2000 Stuart Menefy (stuart.menefy@st.com)
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * IO functions for use when we don't know what machine we are on
- */
-
-#ifndef _ASM_SH_IO_UNKNOWN_H
-#define _ASM_SH_IO_UNKNOWN_H
-
-extern unsigned char unknown_inb(unsigned long port);
-extern unsigned short unknown_inw(unsigned long port);
-extern unsigned int unknown_inl(unsigned long port);
-
-extern void unknown_outb(unsigned char value, unsigned long port);
-extern void unknown_outw(unsigned short value, unsigned long port);
-extern void unknown_outl(unsigned int value, unsigned long port);
-
-extern unsigned char unknown_inb_p(unsigned long port);
-extern unsigned short unknown_inw_p(unsigned long port);
-extern unsigned int unknown_inl_p(unsigned long port);
-extern void unknown_outb_p(unsigned char value, unsigned long port);
-extern void unknown_outw_p(unsigned short value, unsigned long port);
-extern void unknown_outl_p(unsigned int value, unsigned long port);
-
-extern void unknown_insb(unsigned long port, void *addr, unsigned long count);
-extern void unknown_insw(unsigned long port, void *addr, unsigned long count);
-extern void unknown_insl(unsigned long port, void *addr, unsigned long count);
-extern void unknown_outsb(unsigned long port, const void *addr, unsigned long count);
-extern void unknown_outsw(unsigned long port, const void *addr, unsigned long count);
-extern void unknown_outsl(unsigned long port, const void *addr, unsigned long count);
-
-extern unsigned char unknown_readb(unsigned long addr);
-extern unsigned short unknown_readw(unsigned long addr);
-extern unsigned int unknown_readl(unsigned long addr);
-extern void unknown_writeb(unsigned char b, unsigned long addr);
-extern void unknown_writew(unsigned short b, unsigned long addr);
-extern void unknown_writel(unsigned int b, unsigned long addr);
-
-extern unsigned long unknown_isa_port2addr(unsigned long offset);
-extern void *unknown_ioremap(unsigned long offset, unsigned long size);
-extern void unknown_iounmap(void *addr);
-
-#ifdef __WANT_IO_DEF
-
-# define __inb			unknown_inb
-# define __inw			unknown_inw
-# define __inl			unknown_inl
-# define __outb			unknown_outb
-# define __outw			unknown_outw
-# define __outl			unknown_outl
-
-# define __inb_p		unknown_inb_p
-# define __inw_p		unknown_inw_p
-# define __inl_p		unknown_inl_p
-# define __outb_p		unknown_outb_p
-# define __outw_p		unknown_outw_p
-# define __outl_p		unknown_outl_p
-
-# define __insb			unknown_insb
-# define __insw			unknown_insw
-# define __insl			unknown_insl
-# define __outsb		unknown_outsb
-# define __outsw		unknown_outsw
-# define __outsl		unknown_outsl
-
-# define __readb		unknown_readb
-# define __readw		unknown_readw
-# define __readl		unknown_readl
-# define __writeb		unknown_writeb
-# define __writew		unknown_writew
-# define __writel		unknown_writel
-
-# define __isa_port2addr	unknown_isa_port2addr
-# define __ioremap		unknown_ioremap
-# define __iounmap		unknown_iounmap
-
-#endif
-
-#endif /* _ASM_SH_IO_UNKNOWN_H */
diff -puN include/asm-sh/ipc.h~linus include/asm-sh/ipc.h
--- 25/include/asm-sh/ipc.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/ipc.h	2004-01-19 22:17:24.000000000 -0800
@@ -7,7 +7,7 @@
  * See arch/i386/kernel/sys_i386.c for ugly details..
  */
 struct ipc_kludge {
-	struct msgbuf *msgp;
+	struct msgbuf __user *msgp;
 	long msgtyp;
 };
 
diff -puN include/asm-sh/irq.h~linus include/asm-sh/irq.h
--- 25/include/asm-sh/irq.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/irq.h	2004-01-19 22:17:24.000000000 -0800
@@ -7,6 +7,7 @@
  *
  * Copyright (C) 1999  Niibe Yutaka & Takeshi Yaegashi
  * Copyright (C) 2000  Kazumoto Kojima
+ * Copyright (C) 2003  Paul Mundt
  *
  */
 
@@ -21,6 +22,7 @@
 #define INTC_IPRA	0xffd00004UL
 #define INTC_IPRB	0xffd00008UL
 #define INTC_IPRC	0xffd0000cUL
+#define INTC_IPRD	0xffd00010UL
 #endif
 
 #define TIMER_IRQ	16
@@ -46,6 +48,10 @@
 #define DMTE1_IRQ	35
 #define DMTE2_IRQ	36
 #define DMTE3_IRQ	37
+#define DMTE4_IRQ	44	/* 7751R only */
+#define DMTE5_IRQ	45	/* 7751R only */
+#define DMTE6_IRQ	46	/* 7751R only */
+#define DMTE7_IRQ	47	/* 7751R only */
 #define DMAE_IRQ	38
 #define DMA_IPR_ADDR	INTC_IPRC
 #define DMA_IPR_POS	2
@@ -123,6 +129,8 @@
 #  define ONCHIP_NR_IRQS 48	// Actually 44
 # elif defined(CONFIG_CPU_SUBTYPE_SH7751)
 #  define ONCHIP_NR_IRQS 72
+# elif defined(CONFIG_CPU_SUBTYPE_SH7760)
+#  define ONCHIP_NR_IRQS 110
 # elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
 #  define ONCHIP_NR_IRQS 144
 # endif
@@ -194,7 +202,22 @@ extern void make_ipr_irq(unsigned int ir
 			 int pos,  int priority);
 extern void make_imask_irq(unsigned int irq);
 
-#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)
+#if defined(CONFIG_CPU_SUBTYPE_SH7604)
+#define INTC_IPRA	0xfffffee2UL
+#define INTC_IPRB	0xfffffe60UL
+
+#define INTC_VCRA	0xfffffe62UL
+#define INTC_VCRB	0xfffffe64UL
+#define INTC_VCRC	0xfffffe66UL
+#define INTC_VCRD	0xfffffe68UL
+
+#define INTC_VCRWDT	0xfffffee4UL
+#define INTC_VCRDIV	0xffffff0cUL
+#define INTC_VCRDMA0	0xffffffa0UL
+#define INTC_VCRDMA1	0xffffffa8UL
+
+#define INTC_ICR	0xfffffee0UL
+#elif defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)
 #define INTC_IRR0	0xa4000004UL
 #define INTC_IRR1	0xa4000006UL
 #define INTC_IRR2	0xa4000008UL
@@ -293,61 +316,12 @@ extern void make_intc2_irq(unsigned int 
  
 #endif                                                                        
        
-#ifdef CONFIG_SH_GENERIC
-
-static __inline__ int irq_demux(int irq)
-{
-	if (sh_mv.mv_irq_demux) {
-		irq = sh_mv.mv_irq_demux(irq);
-	}
-	return __irq_demux(irq);
-}
-
-#elif defined(CONFIG_SH_BIGSUR)
-
-extern int bigsur_irq_demux(int irq);
-#define irq_demux(irq) bigsur_irq_demux(irq)
-
-#elif defined(CONFIG_HD64461)
-
-extern int hd64461_irq_demux(int irq);
-#define irq_demux(irq) hd64461_irq_demux(irq)
-
-#elif defined(CONFIG_HD64465)
-
-extern int hd64465_irq_demux(int irq);
-#define irq_demux(irq) hd64465_irq_demux(irq)
-
-#elif defined(CONFIG_SH_EC3104)
-
-extern int ec3104_irq_demux(int irq);
-#define irq_demux ec3104_irq_demux
-
-#elif defined(CONFIG_SH_CAT68701)
-
-extern int cat68701_irq_demux(int irq);
-#define irq_demux cat68701_irq_demux
-
-#elif defined(CONFIG_SH_DREAMCAST)
-
-extern int systemasic_irq_demux(int irq);
-#define irq_demux systemasic_irq_demux
-
-#elif defined(CONFIG_SH_MPC1211)
-
-extern int mpc1211_irq_demux(int irq);
-#define irq_demux mpc1211_irq_demux
-
-#else
-
-#define irq_demux(irq) __irq_demux(irq)
-
-#endif
-
-static __inline__ int irq_canonicalize(int irq)
+static inline int generic_irq_demux(int irq)
 {
 	return irq;
 }
 
+#define irq_canonicalize(irq)	(irq)
+#define irq_demux(irq)		__irq_demux(sh_mv.mv_irq_demux(irq))
 
 #endif /* __ASM_SH_IRQ_H */
diff -puN -L include/asm-sh/keyboard-ec3104.h include/asm-sh/keyboard-ec3104.h~linus /dev/null
--- 25/include/asm-sh/keyboard-ec3104.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,17 +0,0 @@
-extern unsigned char ec3104_kbd_sysrq_xlate[];
-extern int ec3104_kbd_setkeycode(unsigned int scancode, unsigned int keycode);
-extern int ec3104_kbd_getkeycode(unsigned int scancode);
-extern int ec3104_kbd_translate(unsigned char, unsigned char *, char);
-extern char ec3104_kbd_unexpected_up(unsigned char);
-extern void ec3104_kbd_leds(unsigned char);
-extern void ec3104_kbd_init_hw(void);
-
-#define SYSRQ_KEY 0x54
-
-#define kbd_sysrq_xlate ec3104_kbd_sysrq_xlate
-#define kbd_setkeycode ec3104_kbd_setkeycode
-#define kbd_getkeycode ec3104_kbd_getkeycode
-#define kbd_translate ec3104_kbd_translate
-#define kbd_unexpected_up ec3104_kbd_unexpected_up
-#define kbd_leds ec3104_kbd_leds
-#define kbd_init_hw ec3104_kbd_init_hw
diff -puN include/asm-sh/kgdb.h~linus include/asm-sh/kgdb.h
--- 25/include/asm-sh/kgdb.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/kgdb.h	2004-01-19 22:17:24.000000000 -0800
@@ -18,6 +18,8 @@
 
 #include <asm/ptrace.h>
 
+struct console;
+
 /* Same as pt_regs but has vbr in place of syscall_nr */
 struct kgdb_regs {
         unsigned long regs[16];
@@ -89,6 +91,18 @@ extern int     setjmp(jmp_buf __jmpb);
   }                                                           \
 } while (0)
 
+/* KGDB should be able to flush all kernel text space */
+#if defined(CONFIG_CPU_SH4)
+#define kgdb_flush_icache_range(start, end) \
+{									\
+	extern void __flush_purge_region(void *, int);			\
+	__flush_purge_region((void*)(start), (int)(end) - (int)(start));\
+	flush_icache_range((start), (end));				\
+}
+#else
+#define kgdb_flush_icache_range(start, end)	do { } while (0)
+#endif
+
 /* Kernel assert macros */
 #ifdef CONFIG_KGDB_KERNEL_ASSERTS
 
diff -puN /dev/null include/asm-sh/local.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/asm-sh/local.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,7 @@
+#ifndef __ASM_SH_LOCAL_H
+#define __ASM_SH_LOCAL_H
+
+#include <asm-generic/local.h>
+
+#endif /* __ASM_SH_LOCAL_H */
+
diff -puN include/asm-sh/machvec.h~linus include/asm-sh/machvec.h
--- 25/include/asm-sh/machvec.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/machvec.h	2004-01-19 22:17:24.000000000 -0800
@@ -15,13 +15,12 @@
 #include <linux/time.h>
 
 #include <asm/machtypes.h>
+#include <asm/machvec_init.h>
 
 struct timeval;
 
 struct sh_machine_vector
 {
-	const char *mv_name;
-
 	int mv_nr_irqs;
 
 	unsigned char (*mv_inb)(unsigned long);
@@ -59,15 +58,10 @@ struct sh_machine_vector
 
 	int (*mv_irq_demux)(int irq);
 
-	void (*mv_init_arch)(void);
 	void (*mv_init_irq)(void);
 	void (*mv_init_pci)(void);
-	void (*mv_kill_arch)(int);
 
 	void (*mv_heartbeat)(void);
-
-	void (*mv_rtc_gettimeofday)(struct timespec *ts);
-	int (*mv_rtc_settimeofday)(const time_t secs);
 };
 
 extern struct sh_machine_vector sh_mv;
diff -puN include/asm-sh/mc146818rtc.h~linus include/asm-sh/mc146818rtc.h
--- 25/include/asm-sh/mc146818rtc.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/mc146818rtc.h	2004-01-19 22:17:24.000000000 -0800
@@ -23,6 +23,15 @@
 #define CMOS_READ(addr)		__CMOS_READ(addr,b)
 #define CMOS_WRITE(val,addr)	__CMOS_WRITE(val,addr,b)
 
+#elif defined(CONFIG_SH_SECUREEDGE5410)
+#include <asm/snapgear/io.h>
+
+#define RTC_PORT(n)             SECUREEDGE_IOPORT_ADDR
+#define CMOS_READ(addr)         secureedge5410_cmos_read(addr)
+#define CMOS_WRITE(val,addr)    secureedge5410_cmos_write(val,addr)
+extern unsigned char secureedge5410_cmos_read(int addr);
+extern void secureedge5410_cmos_write(unsigned char val, int addr);
+
 #elif defined(CONFIG_CPU_SH4)
 #define RTC_PORT(n)		(R64CNT+(n)*4)
 #define CMOS_READ(addr)		__CMOS_READ(addr,w)
diff -puN include/asm-sh/module.h~linus include/asm-sh/module.h
--- 25/include/asm-sh/module.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/module.h	2004-01-19 22:17:24.000000000 -0800
@@ -14,7 +14,9 @@ struct mod_arch_specific {
 #define Elf_Ehdr		Elf32_Ehdr
 
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
-# ifdef CONFIG_CPU_SH3
+# ifdef CONFIG_CPU_SH2
+#  define MODULE_PROC_FAMILY "SH2LE "
+# elif defined  CONFIG_CPU_SH3
 #  define MODULE_PROC_FAMILY "SH3LE "
 # elif defined  CONFIG_CPU_SH4
 #  define MODULE_PROC_FAMILY "SH4LE "
@@ -22,7 +24,9 @@ struct mod_arch_specific {
 #  error unknown processor family
 # endif
 #else
-# ifdef CONFIG_CPU_SH3
+# ifdef CONFIG_CPU_SH2
+#  define MODULE_PROC_FAMILY "SH2BE "
+# elif defined  CONFIG_CPU_SH3
 #  define MODULE_PROC_FAMILY "SH3BE "
 # elif defined  CONFIG_CPU_SH4
 #  define MODULE_PROC_FAMILY "SH4BE "
diff -puN include/asm-sh/mpc1211/io.h~linus include/asm-sh/mpc1211/io.h
--- 25/include/asm-sh/mpc1211/io.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/mpc1211/io.h	2004-01-19 22:17:24.000000000 -0800
@@ -10,77 +10,13 @@
 #define _ASM_SH_IO_MPC1211_H
 
 #include <linux/time.h>
-#include <asm/io_generic.h>
 
-extern unsigned char mpc1211_inb(unsigned long port);
-extern unsigned short mpc1211_inw(unsigned long port);
-extern unsigned int mpc1211_inl(unsigned long port);
-
-extern void mpc1211_outb(unsigned char value, unsigned long port);
-extern void mpc1211_outw(unsigned short value, unsigned long port);
-extern void mpc1211_outl(unsigned int value, unsigned long port);
-
-extern unsigned char mpc1211_inb_p(unsigned long port);
-extern void mpc1211_outb_p(unsigned char value, unsigned long port);
-
-extern void mpc1211_insb(unsigned long port, void *addr, unsigned long count);
-extern void mpc1211_insw(unsigned long port, void *addr, unsigned long count);
-extern void mpc1211_insl(unsigned long port, void *addr, unsigned long count);
-extern void mpc1211_outsb(unsigned long port, const void *addr, unsigned long count);
-extern void mpc1211_outsw(unsigned long port, const void *addr, unsigned long count);
-extern void mpc1211_outsl(unsigned long port, const void *addr, unsigned long count);
-
-extern unsigned char mpc1211_readb(unsigned long addr);
-extern unsigned short mpc1211_readw(unsigned long addr);
-extern unsigned int mpc1211_readl(unsigned long addr);
-extern void mpc1211_writeb(unsigned char b, unsigned long addr);
-extern void mpc1211_writew(unsigned short b, unsigned long addr);
-extern void mpc1211_writel(unsigned int b, unsigned long addr);
-
-extern unsigned long mpc1211_isa_port2addr(unsigned long offset);
 extern int mpc1211_irq_demux(int irq);
 
-extern void setup_mpc1211(void);
 extern void init_mpc1211_IRQ(void);
 extern void heartbeat_mpc1211(void);
 
 extern void mpc1211_rtc_gettimeofday(struct timeval *tv);
 extern int mpc1211_rtc_settimeofday(const struct timeval *tv);
 
-#ifdef __WANT_IO_DEF
-
-# define __inb			mpc1211_inb
-# define __inw			mpc1211_inw
-# define __inl			mpc1211_inl
-# define __outb			mpc1211_outb
-# define __outw			mpc1211_outw
-# define __outl			mpc1211_outl
-
-# define __inb_p		mpc1211_inb_p
-# define __inw_p		mpc1211_inw
-# define __inl_p		mpc1211_inl
-# define __outb_p		mpc1211_outb_p
-# define __outw_p		mpc1211_outw
-# define __outl_p		mpc1211_outl
-
-# define __insb			mpc1211_insb
-# define __insw			mpc1211_insw
-# define __insl			mpc1211_insl
-# define __outsb		mpc1211_outsb
-# define __outsw		mpc1211_outsw
-# define __outsl		mpc1211_outsl
-
-# define __readb		mpc1211_readb
-# define __readw		mpc1211_readw
-# define __readl		mpc1211_readl
-# define __writeb		mpc1211_writeb
-# define __writew		mpc1211_writew
-# define __writel		mpc1211_writel
-
-# define __isa_port2addr	mpc1211_isa_port2addr
-# define __ioremap		generic_ioremap
-# define __iounmap		generic_iounmap
-
-#endif
-
 #endif /* _ASM_SH_IO_MPC1211_H */
diff -puN include/asm-sh/overdrive/io.h~linus include/asm-sh/overdrive/io.h
--- 25/include/asm-sh/overdrive/io.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/overdrive/io.h	2004-01-19 22:17:24.000000000 -0800
@@ -12,8 +12,6 @@
 #ifndef _ASM_SH_IO_OD_H
 #define _ASM_SH_IO_OD_H
 
-#include <asm/io_generic.h>
-
 extern unsigned char od_inb(unsigned long port);
 extern unsigned short od_inw(unsigned long port);
 extern unsigned int od_inl(unsigned long port);
@@ -38,40 +36,4 @@ extern void od_outsl(unsigned long port,
 
 extern unsigned long od_isa_port2addr(unsigned long offset);
 
-#ifdef __WANT_IO_DEF
-
-# define __inb			od_inb
-# define __inw			od_inw
-# define __inl			od_inl
-# define __outb			od_outb
-# define __outw			od_outw
-# define __outl			od_outl
-
-# define __inb_p		od_inb_p
-# define __inw_p		od_inw_p
-# define __inl_p		od_inl_p
-# define __outb_p		od_outb_p
-# define __outw_p		od_outw_p
-# define __outl_p		od_outl_p
-
-# define __insb			od_insb
-# define __insw			od_insw
-# define __insl			od_insl
-# define __outsb		od_outsb
-# define __outsw		od_outsw
-# define __outsl		od_outsl
-
-# define __readb		generic_readb
-# define __readw		generic_readw
-# define __readl		generic_readl
-# define __writeb		generic_writeb
-# define __writew		generic_writew
-# define __writel		generic_writel
-
-# define __isa_port2addr	od_isa_port2addr
-# define __ioremap		generic_ioremap
-# define __iounmap		generic_iounmap
-
-#endif
-
 #endif /* _ASM_SH_IO_OD_H */
diff -puN include/asm-sh/page.h~linus include/asm-sh/page.h
--- 25/include/asm-sh/page.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/page.h	2004-01-19 22:17:24.000000000 -0800
@@ -24,10 +24,13 @@
 #ifdef __KERNEL__
 #ifndef __ASSEMBLY__
 
-extern void clear_page(void *to);
-extern void copy_page(void *to, void *from);
+extern void (*clear_page)(void *to);
+extern void (*copy_page)(void *to, void *from);
 
-#if defined(CONFIG_CPU_SH3)
+extern void clear_page_slow(void *to);
+extern void copy_page_slow(void *to, void *from);
+
+#if defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH3) || !defined(CONFIG_MMU)
 #define clear_user_page(page, vaddr, pg)	clear_page(page)
 #define copy_user_page(to, from, vaddr, pg)	copy_page(to, from)
 #elif defined(CONFIG_CPU_SH4)
@@ -64,7 +67,7 @@ typedef struct { unsigned long pgprot; }
 /*
  * IF YOU CHANGE THIS, PLEASE ALSO CHANGE
  *
- *	arch/sh/vmlinux.lds.S
+ *	arch/sh/kernel/vmlinux.lds.S
  *
  * which has the same constant encoded..
  */
diff -puN include/asm-sh/pci.h~linus include/asm-sh/pci.h
--- 25/include/asm-sh/pci.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/pci.h	2004-01-19 22:17:24.000000000 -0800
@@ -13,29 +13,25 @@
 
 #define pcibios_assign_all_busses()	1
 
-#if defined(CONFIG_CPU_SUBTYPE_ST40STB1)
-/* These are currently the correct values for the STM overdrive board. 
- * We need some way of setting this on a board specific way, it will 
- * not be the same on other boards I think
- */
-#define PCIBIOS_MIN_IO		0x2000
-#define PCIBIOS_MIN_MEM		0x10000000
-
-#elif defined(CONFIG_SH_DREAMCAST)
-#define PCIBIOS_MIN_IO		0x2000
-#define PCIBIOS_MIN_MEM		0x10000000
-#elif defined(CONFIG_SH_BIGSUR) && defined(CONFIG_CPU_SUBTYPE_SH7751)
-#define PCIBIOS_MIN_IO		0x2000
-#define PCIBIOS_MIN_MEM		0xFD000000
-
-#elif defined(CONFIG_SH_7751_SOLUTION_ENGINE)
-#define PCIBIOS_MIN_IO          0x4000
-#define PCIBIOS_MIN_MEM         0xFD000000
-
-#elif defined(CONFIG_SH_MPC1211)
-#define PCIBIOS_MIN_IO          0x2000
-#define PCIBIOS_MIN_MEM         0xb0000000
-#endif
+/*
+ * A board can define one or more PCI channels that represent built-in (or
+ * external) PCI controllers.
+ */
+struct pci_channel {
+	struct pci_ops *pci_ops;
+	struct resource *io_resource;
+	struct resource *mem_resource;
+	int first_devfn;
+	int last_devfn;
+};
+
+/*
+ * Each board initializes this array and terminates it with a NULL entry.
+ */
+extern struct pci_channel board_pci_channels[];
+
+#define PCIBIOS_MIN_IO		board_pci_channels->io_resource->start
+#define PCIBIOS_MIN_MEM		board_pci_channels->mem_resource->start
 
 struct pci_dev;
 
@@ -251,23 +247,6 @@ static inline int pci_dma_supported(stru
 #define sg_dma_address(sg)	(virt_to_bus((sg)->dma_address))
 #define sg_dma_len(sg)		((sg)->length)
 
-/*
- * A board can define one or more PCI channels that represent built-in (or
- * external) PCI controllers.
- */
-struct pci_channel {
-	struct pci_ops *pci_ops;
-	struct resource *io_resource;
-	struct resource *mem_resource;
-	int first_devfn;
-	int last_devfn;
-};
-
-/*
- * Each board initializes this array and terminates it with a NULL entry.
- */
-extern struct pci_channel board_pci_channels[];
-
 /* Board-specific fixup routines. */
 extern void pcibios_fixup(void);
 extern void pcibios_fixup_irqs(void);
diff -puN -L include/asm-sh/pci-sh7751.h include/asm-sh/pci-sh7751.h~linus /dev/null
--- 25/include/asm-sh/pci-sh7751.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,281 +0,0 @@
-/*
- *	Low-Level PCI Support for SH7751 targets
- *
- *  Dustin McIntire (dustin@sensoria.com) (c) 2001
- *	
- *  May be copied or modified under the terms of the GNU General Public
- *  License.  See linux/COPYING for more information.
- *
- */
-
-#ifndef _PCI_SH7751_H_
-#define _PCI_SH7751_H_
-
-#include <linux/pci.h>
-
-/* set debug level 4=verbose...1=terse */
-//#define DEBUG_PCI 3
-#undef DEBUG_PCI
-
-#ifdef DEBUG_PCI
-#define PCIDBG(n, x...) { if(DEBUG_PCI>=n) printk(x); }
-#else
-#define PCIDBG(n, x...)
-#endif
-
-/* startup values */
-#define PCI_PROBE_BIOS 1
-#define PCI_PROBE_CONF1 2
-#define PCI_PROBE_CONF2 4
-#define PCI_NO_SORT 0x100
-#define PCI_BIOS_SORT 0x200
-#define PCI_NO_CHECKS 0x400
-#define PCI_ASSIGN_ROMS 0x1000
-#define PCI_BIOS_IRQ_SCAN 0x2000
-
-/* Platform Specific Values */
-#define SH7751_VENDOR_ID             0x1054
-#define SH7751_DEVICE_ID             0x3505
-
-/* SH7751 Specific Values */
-#define SH7751_PCI_CONFIG_BASE	     0xFD000000  /* Config space base addr */
-#define SH7751_PCI_CONFIG_SIZE       0x1000000   /* Config space size */
-#define SH7751_PCI_MEMORY_BASE	     0xFD000000  /* Memory space base addr */
-#define SH7751_PCI_MEM_SIZE          0x01000000  /* Size of Memory window */
-#define SH7751_PCI_IO_BASE           0xFE240000  /* IO space base address */
-#define SH7751_PCI_IO_SIZE           0x40000     /* Size of IO window */
-
-#define SH7751_PCIREG_BASE           0xFE200000  /* PCI regs base address */
-#define PCI_REG(n)                  (SH7751_PCIREG_BASE+ n)
-
-#define SH7751_PCICONF0            0x0           /* PCI Config Reg 0 */
-  #define SH7751_PCICONF0_DEVID      0xFFFF0000  /* Device ID */
-  #define SH7751_PCICONF0_VNDID      0x0000FFFF  /* Vendor ID */
-#define SH7751_PCICONF1            0x4           /* PCI Config Reg 1 */
-  #define SH7751_PCICONF1_DPE        0x80000000  /* Data Parity Error */
-  #define SH7751_PCICONF1_SSE        0x40000000  /* System Error Status */
-  #define SH7751_PCICONF1_RMA        0x20000000  /* Master Abort */
-  #define SH7751_PCICONF1_RTA        0x10000000  /* Target Abort Rx Status */
-  #define SH7751_PCICONF1_STA        0x08000000  /* Target Abort Exec Status */
-  #define SH7751_PCICONF1_DEV        0x06000000  /* Timing Status */
-  #define SH7751_PCICONF1_DPD        0x01000000  /* Data Parity Status */
-  #define SH7751_PCICONF1_FBBC       0x00800000  /* Back 2 Back Status */
-  #define SH7751_PCICONF1_UDF        0x00400000  /* User Defined Status */
-  #define SH7751_PCICONF1_66M        0x00200000  /* 66Mhz Operation Status */
-  #define SH7751_PCICONF1_PM         0x00100000  /* Power Management Status */
-  #define SH7751_PCICONF1_PBBE       0x00000200  /* Back 2 Back Control */
-  #define SH7751_PCICONF1_SER        0x00000100  /* SERR Output Control */
-  #define SH7751_PCICONF1_WCC        0x00000080  /* Wait Cycle Control */
-  #define SH7751_PCICONF1_PER        0x00000040  /* Parity Error Response */
-  #define SH7751_PCICONF1_VPS        0x00000020  /* VGA Pallet Snoop */
-  #define SH7751_PCICONF1_MWIE       0x00000010  /* Memory Write+Invalidate */
-  #define SH7751_PCICONF1_SPC        0x00000008  /* Special Cycle Control */
-  #define SH7751_PCICONF1_BUM        0x00000004  /* Bus Master Control */
-  #define SH7751_PCICONF1_MES        0x00000002  /* Memory Space Control */
-  #define SH7751_PCICONF1_IOS        0x00000001  /* I/O Space Control */
-#define SH7751_PCICONF2            0x8           /* PCI Config Reg 2 */
-  #define SH7751_PCICONF2_BCC        0xFF000000  /* Base Class Code */
-  #define SH7751_PCICONF2_SCC        0x00FF0000  /* Sub-Class Code */
-  #define SH7751_PCICONF2_RLPI       0x0000FF00  /* Programming Interface */
-  #define SH7751_PCICONF2_REV        0x000000FF  /* Revision ID */
-#define SH7751_PCICONF3            0xC           /* PCI Config Reg 3 */ 
-  #define SH7751_PCICONF3_BIST7      0x80000000  /* Bist Supported */
-  #define SH7751_PCICONF3_BIST6      0x40000000  /* Bist Executing */
-  #define SH7751_PCICONF3_BIST3_0    0x0F000000  /* Bist Passed */
-  #define SH7751_PCICONF3_HD7        0x00800000  /* Single Funtion device */
-  #define SH7751_PCICONF3_HD6_0      0x007F0000  /* Configuration Layout */
-  #define SH7751_PCICONF3_LAT        0x0000FF00  /* Latency Timer */
-  #define SH7751_PCICONF3_CLS        0x000000FF  /* Cache Line Size */
-#define SH7751_PCICONF4            0x10          /* PCI Config Reg 4 */
-  #define SH7751_PCICONF4_BASE       0xFFFFFFFC  /* I/O Space Base Addr */
-  #define SH7751_PCICONF4_ASI        0x00000001  /* Address Space Type */
-#define SH7751_PCICONF5            0x14          /* PCI Config Reg 5 */
-  #define SH7751_PCICONF5_BASE       0xFFFFFFF0  /* Mem Space Base Addr */
-  #define SH7751_PCICONF5_LAP        0x00000008  /* Prefetch Enabled */
-  #define SH7751_PCICONF5_LAT        0x00000006  /* Local Memory type */
-  #define SH7751_PCICONF5_ASI        0x00000001  /* Address Space Type */  
-#define SH7751_PCICONF6            0x18          /* PCI Config Reg 6 */
-  #define SH7751_PCICONF6_BASE       0xFFFFFFF0  /* Mem Space Base Addr */
-  #define SH7751_PCICONF6_LAP        0x00000008  /* Prefetch Enabled */
-  #define SH7751_PCICONF6_LAT        0x00000006  /* Local Memory type */
-  #define SH7751_PCICONF6_ASI        0x00000001  /* Address Space Type */  
-/* PCICONF7 - PCICONF10 are undefined */
-#define SH7751_PCICONF11           0x2C          /* PCI Config Reg 11 */
-  #define SH7751_PCICONF11_SSID      0xFFFF0000  /* Subsystem ID */
-  #define SH7751_PCICONF11_SVID      0x0000FFFF  /* Subsystem Vendor ID */
-/* PCICONF12 is undefined */
-#define SH7751_PCICONF13           0x34          /* PCI Config Reg 13 */
-  #define SH7751_PCICONF13_CPTR      0x000000FF  /* PM function pointer */
-/* PCICONF14 is undefined */
-#define SH7751_PCICONF15           0x3C          /* PCI Config Reg 15 */
-  #define SH7751_PCICONF15_IPIN      0x000000FF  /* Interrupt Pin */
-#define SH7751_PCICONF16           0x40          /* PCI Config Reg 16 */
-  #define SH7751_PCICONF16_PMES      0xF8000000  /* PME Support */
-  #define SH7751_PCICONF16_D2S       0x04000000  /* D2 Support */
-  #define SH7751_PCICONF16_D1S       0x02000000  /* D1 Support */
-  #define SH7751_PCICONF16_DSI       0x00200000  /* Bit Device Init. */
-  #define SH7751_PCICONF16_PMCK      0x00080000  /* Clock for PME req. */
-  #define SH7751_PCICONF16_VER       0x00070000  /* PM Version */
-  #define SH7751_PCICONF16_NIP       0x0000FF00  /* Next Item Pointer */
-  #define SH7751_PCICONF16_CID       0x000000FF  /* Capability Identifier */
-#define SH7751_PCICONF17           0x44          /* PCI Config Reg 17 */
-  #define SH7751_PCICONF17_DATA      0xFF000000  /* Data field for PM */
-  #define SH7751_PCICONF17_PMES      0x00800000  /* PME Status */
-  #define SH7751_PCICONF17_DSCL      0x00600000  /* Data Scaling Value */
-  #define SH7751_PCICONF17_DSEL      0x001E0000  /* Data Select */
-  #define SH7751_PCICONF17_PMEN      0x00010000  /* PME Enable */
-  #define SH7751_PCICONF17_PWST      0x00000003  /* Power State */
-/* SH7715 Internal PCI Registers */
-#define SH7751_PCICR               0x100         /* PCI Control Register */
-  #define SH7751_PCICR_PREFIX        0xA5000000  /* CR prefix for write */
-  #define SH7751_PCICR_TRSB          0x00000200  /* Target Read Single */
-  #define SH7751_PCICR_BSWP          0x00000100  /* Target Byte Swap */
-  #define SH7751_PCICR_PLUP          0x00000080  /* Enable PCI Pullup */
-  #define SH7751_PCICR_ARBM          0x00000040  /* PCI Arbitration Mode */
-  #define SH7751_PCICR_MD            0x00000030  /* MD9 and MD10 status */
-  #define SH7751_PCICR_SERR          0x00000008  /* SERR output assert */
-  #define SH7751_PCICR_INTA          0x00000004  /* INTA output assert */
-  #define SH7751_PCICR_PRST          0x00000002  /* PCI Reset Assert */
-  #define SH7751_PCICR_CFIN          0x00000001  /* Central Fun. Init Done */
-#define SH7751_PCILSR0             0x104         /* PCI Local Space Register0 */
-#define SH7751_PCILSR1             0x108         /* PCI Local Space Register1 */
-#define SH7751_PCILAR0             0x10C         /* PCI Local Address Register1 */
-#define SH7751_PCILAR1             0x110         /* PCI Local Address Register1 */
-#define SH7751_PCIINT              0x114         /* PCI Interrupt Register */
-  #define SH7751_PCIINT_MLCK         0x00008000  /* Master Lock Error */
-  #define SH7751_PCIINT_TABT         0x00004000  /* Target Abort Error */
-  #define SH7751_PCIINT_TRET         0x00000200  /* Target Retry Error */
-  #define SH7751_PCIINT_MFDE         0x00000100  /* Master Func. Disable Error */
-  #define SH7751_PCIINT_PRTY         0x00000080  /* Address Parity Error */
-  #define SH7751_PCIINT_SERR         0x00000040  /* SERR Detection Error */
-  #define SH7751_PCIINT_TWDP         0x00000020  /* Tgt. Write Parity Error */
-  #define SH7751_PCIINT_TRDP         0x00000010  /* Tgt. Read Parity Error Det. */
-  #define SH7751_PCIINT_MTABT        0x00000008  /* Master-Tgt. Abort Error */
-  #define SH7751_PCIINT_MMABT        0x00000004  /* Master-Master Abort Error */
-  #define SH7751_PCIINT_MWPD         0x00000002  /* Master Write PERR Detect */
-  #define SH7751_PCIINT_MRPD         0x00000002  /* Master Read PERR Detect */
-#define SH7751_PCIINTM             0x118         /* PCI Interrupt Mask Register */
-#define SH7751_PCIALR              0x11C         /* Error Address Register */
-#define SH7751_PCICLR              0x120         /* Error Command/Data Register */
-  #define SH7751_PCICLR_MPIO         0x80000000  /* Error Command/Data Register */
-  #define SH7751_PCICLR_MDMA0        0x40000000  /* DMA0 Transfer Error */
-  #define SH7751_PCICLR_MDMA1        0x20000000  /* DMA1 Transfer Error */
-  #define SH7751_PCICLR_MDMA2        0x10000000  /* DMA2 Transfer Error */
-  #define SH7751_PCICLR_MDMA3        0x08000000  /* DMA3 Transfer Error */
-  #define SH7751_PCICLR_TGT          0x04000000  /* Target Transfer Error */
-  #define SH7751_PCICLR_CMDL         0x0000000F  /* PCI Command at Error */
-#define SH7751_PCIAINT             0x130         /* Arbiter Interrupt Register */
-  #define SH7751_PCIAINT_MBKN        0x00002000  /* Master Broken Interrupt */
-  #define SH7751_PCIAINT_TBTO        0x00001000  /* Target Bus Time Out */
-  #define SH7751_PCIAINT_MBTO        0x00001000  /* Master Bus Time Out */
-  #define SH7751_PCIAINT_TABT        0x00000008  /* Target Abort */
-  #define SH7751_PCIAINT_MABT        0x00000004  /* Master Abort */
-  #define SH7751_PCIAINT_RDPE        0x00000002  /* Read Data Parity Error */
-  #define SH7751_PCIAINT_WDPE        0x00000002  /* Write Data Parity Error */
-#define SH7751_PCIAINTM            0x134         /* Arbiter Int. Mask Register */
-#define SH7751_PCIBMLR             0x138         /* Error Bus Master Register */
-  #define SH7751_PCIBMLR_REQ4        0x00000010  /* REQ4 bus master at error */
-  #define SH7751_PCIBMLR_REQ3        0x00000008  /* REQ3 bus master at error */
-  #define SH7751_PCIBMLR_REQ2        0x00000004  /* REQ2 bus master at error */
-  #define SH7751_PCIBMLR_REQ1        0x00000002  /* REQ1 bus master at error */
-  #define SH7751_PCIBMLR_REQ0        0x00000001  /* REQ0 bus master at error */
-#define SH7751_PCIDMABT            0x140         /* DMA Transfer Arb. Register */
-  #define SH7751_PCIDMABT_RRBN       0x00000001  /* DMA Arbitor Round-Robin */
-#define SH7751_PCIDPA0             0x180         /* DMA0 Transfer Addr. Register */
-#define SH7751_PCIDLA0             0x184         /* DMA0 Local Addr. Register */
-#define SH7751_PCIDTC0             0x188         /* DMA0 Transfer Cnt. Register */
-#define SH7751_PCIDCR0             0x18C         /* DMA0 Control Register */
-  #define SH7751_PCIDCR_ALGN         0x00000600  /* DMA Alignment Mode */
-  #define SH7751_PCIDCR_MAST         0x00000100  /* DMA Termination Type */
-  #define SH7751_PCIDCR_INTM         0x00000080  /* DMA Interrupt Done Mask*/
-  #define SH7751_PCIDCR_INTS         0x00000040  /* DMA Interrupt Done Status */
-  #define SH7751_PCIDCR_LHLD         0x00000020  /* Local Address Control */
-  #define SH7751_PCIDCR_PHLD         0x00000010  /* PCI Address Control*/
-  #define SH7751_PCIDCR_IOSEL        0x00000008  /* PCI Address Space Type */
-  #define SH7751_PCIDCR_DIR          0x00000004  /* DMA Transfer Direction */
-  #define SH7751_PCIDCR_STOP         0x00000002  /* Force DMA Stop */
-  #define SH7751_PCIDCR_STRT         0x00000001  /* DMA Start */
-#define SH7751_PCIDPA1             0x190         /* DMA1 Transfer Addr. Register */
-#define SH7751_PCIDLA1             0x194         /* DMA1 Local Addr. Register */
-#define SH7751_PCIDTC1             0x198         /* DMA1 Transfer Cnt. Register */
-#define SH7751_PCIDCR1             0x19C         /* DMA1 Control Register */
-#define SH7751_PCIDPA2             0x1A0         /* DMA2 Transfer Addr. Register */
-#define SH7751_PCIDLA2             0x1A4         /* DMA2 Local Addr. Register */
-#define SH7751_PCIDTC2             0x1A8         /* DMA2 Transfer Cnt. Register */
-#define SH7751_PCIDCR2             0x1AC         /* DMA2 Control Register */
-#define SH7751_PCIDPA3             0x1B0         /* DMA3 Transfer Addr. Register */
-#define SH7751_PCIDLA3             0x1B4         /* DMA3 Local Addr. Register */
-#define SH7751_PCIDTC3             0x1B8         /* DMA3 Transfer Cnt. Register */
-#define SH7751_PCIDCR3             0x1BC         /* DMA3 Control Register */
-#define SH7751_PCIPAR              0x1C0         /* PIO Address Register */
-  #define SH7751_PCIPAR_CFGEN        0x80000000  /* Configuration Enable */
-  #define SH7751_PCIPAR_BUSNO        0x00FF0000  /* Config. Bus Number */
-  #define SH7751_PCIPAR_DEVNO        0x0000FF00  /* Config. Device Number */
-  #define SH7751_PCIPAR_REGAD        0x000000FC  /* Register Address Number */
-#define SH7751_PCIMBR              0x1C4         /* Memory Base Address Register */
-  #define SH7751_PCIMBR_MASK         0xFF000000  /* Memory Space Mask */
-  #define SH7751_PCIMBR_LOCK         0x00000001  /* Lock Memory Space */
-#define SH7751_PCIIOBR             0x1C8         /* I/O Base Address Register */
-  #define SH7751_PCIIOBR_MASK         0xFFFC0000 /* IO Space Mask */
-  #define SH7751_PCIIOBR_LOCK         0x00000001 /* Lock IO Space */
-#define SH7751_PCIPINT             0x1CC         /* Power Mgmnt Int. Register */
-  #define SH7751_PCIPINT_D3           0x00000002 /* D3 Pwr Mgmt. Interrupt */
-  #define SH7751_PCIPINT_D0           0x00000001 /* D0 Pwr Mgmt. Interrupt */  
-#define SH7751_PCIPINTM            0x1D0         /* Power Mgmnt Mask Register */
-#define SH7751_PCICLKR             0x1D4         /* Clock Ctrl. Register */
-  #define SH7751_PCICLKR_PCSTP        0x00000002 /* PCI Clock Stop */
-  #define SH7751_PCICLKR_BCSTP        0x00000002 /* BCLK Clock Stop */
-/* For definitions of BCR, MCR see ... */
-#define SH7751_PCIBCR1             0x1E0         /* Memory BCR1 Register */
-#define SH7751_PCIBCR2             0x1E4         /* Memory BCR2 Register */
-#define SH7751_PCIWCR1             0x1E8         /* Wait Control 1 Register */
-#define SH7751_PCIWCR2             0x1EC         /* Wait Control 2 Register */
-#define SH7751_PCIWCR3             0x1F0         /* Wait Control 3 Register */
-#define SH7751_PCIMCR              0x1F4         /* Memory Control Register */
-#define SH7751_PCIPCTR             0x200         /* Port Control Register */
-  #define SH7751_PCIPCTR_P2EN        0x000400000 /* Port 2 Enable */
-  #define SH7751_PCIPCTR_P1EN        0x000200000 /* Port 1 Enable */
-  #define SH7751_PCIPCTR_P0EN        0x000100000 /* Port 0 Enable */
-  #define SH7751_PCIPCTR_P2UP        0x000000020 /* Port2 Pull Up Enable */
-  #define SH7751_PCIPCTR_P2IO        0x000000010 /* Port2 Output Enable */
-  #define SH7751_PCIPCTR_P1UP        0x000000008 /* Port1 Pull Up Enable */
-  #define SH7751_PCIPCTR_P1IO        0x000000004 /* Port1 Output Enable */
-  #define SH7751_PCIPCTR_P0UP        0x000000002 /* Port0 Pull Up Enable */
-  #define SH7751_PCIPCTR_P0IO        0x000000001 /* Port0 Output Enable */
-#define SH7751_PCIPDTR             0x204         /* Port Data Register */
-  #define SH7751_PCIPDTR_PB5         0x000000020 /* Port 5 Enable */
-  #define SH7751_PCIPDTR_PB4         0x000000010 /* Port 4 Enable */
-  #define SH7751_PCIPDTR_PB3         0x000000008 /* Port 3 Enable */
-  #define SH7751_PCIPDTR_PB2         0x000000004 /* Port 2 Enable */
-  #define SH7751_PCIPDTR_PB1         0x000000002 /* Port 1 Enable */
-  #define SH7751_PCIPDTR_PB0         0x000000001 /* Port 0 Enable */
-#define SH7751_PCIPDR              0x220         /* Port IO Data Register */
-
-/* Memory Control Registers */
-#define SH7751_BCR1                0xFF800000    /* Memory BCR1 Register */
-#define SH7751_BCR2                0xFF800004    /* Memory BCR2 Register */
-#define SH7751_WCR1                0xFF800008    /* Wait Control 1 Register */
-#define SH7751_WCR2                0xFF80000C    /* Wait Control 2 Register */
-#define SH7751_WCR3                0xFF800010    /* Wait Control 3 Register */
-#define SH7751_MCR                 0xFF800014    /* Memory Control Register */
-
-/* General Memory Config Addresses */
-#define SH7751_CS0_BASE_ADDR       0x0
-#define SH7751_MEM_REGION_SIZE     0x04000000
-#define SH7751_CS1_BASE_ADDR       (SH7751_CS0_BASE_ADDR + SH7751_MEM_REGION_SIZE)
-#define SH7751_CS2_BASE_ADDR       (SH7751_CS1_BASE_ADDR + SH7751_MEM_REGION_SIZE)
-#define SH7751_CS3_BASE_ADDR       (SH7751_CS2_BASE_ADDR + SH7751_MEM_REGION_SIZE)
-#define SH7751_CS4_BASE_ADDR       (SH7751_CS3_BASE_ADDR + SH7751_MEM_REGION_SIZE)
-#define SH7751_CS5_BASE_ADDR       (SH7751_CS4_BASE_ADDR + SH7751_MEM_REGION_SIZE)
-#define SH7751_CS6_BASE_ADDR       (SH7751_CS5_BASE_ADDR + SH7751_MEM_REGION_SIZE)
-
-/* General PCI values */
-#define SH7751_PCI_HOST_BRIDGE		0x6
-
-/* External functions defined per platform i.e. Big Sur, SE... (these could be routed 
- * through the machine vectors... */
-extern int pcibios_init_platform(void);
-extern int pcibios_map_platform_irq(u8 slot, u8 pin);
-
-#endif /* _PCI_SH7751_H_ */
-
diff -puN include/asm-sh/pgalloc.h~linus include/asm-sh/pgalloc.h
--- 25/include/asm-sh/pgalloc.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/pgalloc.h	2004-01-19 22:17:24.000000000 -0800
@@ -42,18 +42,11 @@ static inline void pgd_free(pgd_t *pgd)
 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
 					  unsigned long address)
 {
-	int count = 0;
 	pte_t *pte;
 
-   	do {
-		pte = (pte_t *) __get_free_page(GFP_KERNEL | __GFP_REPEAT);
-		if (pte)
-			clear_page(pte);
-		else {
-			current->state = TASK_UNINTERRUPTIBLE;
-			schedule_timeout(HZ);
-		}
-	} while (!pte && (count++ < 10));
+	pte = (pte_t *) __get_free_page(GFP_KERNEL | __GFP_REPEAT);
+	if (pte)
+		clear_page(pte);
 
 	return pte;
 }
@@ -61,18 +54,11 @@ static inline pte_t *pte_alloc_one_kerne
 static inline struct page *pte_alloc_one(struct mm_struct *mm,
 					 unsigned long address)
 {
-	int count = 0;
 	struct page *pte;
 
-   	do {
-		pte = alloc_pages(GFP_KERNEL, 0);
-		if (pte)
-			clear_page(page_address(pte));
-		else {
-			current->state = TASK_UNINTERRUPTIBLE;
-			schedule_timeout(HZ);
-		}
-	} while (!pte && (count++ < 10));
+   	pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0);
+	if (pte)
+		clear_page(page_address(pte));
 
 	return pte;
 }
diff -puN include/asm-sh/pgtable.h~linus include/asm-sh/pgtable.h
--- 25/include/asm-sh/pgtable.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/pgtable.h	2004-01-19 22:17:24.000000000 -0800
@@ -280,5 +280,13 @@ typedef pte_t *pte_addr_t;
 extern unsigned int kobjsize(const void *objp);
 #endif /* !CONFIG_MMU */
 
+#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
+#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
+#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
+#define __HAVE_ARCH_PTEP_SET_WRPROTECT
+#define __HAVE_ARCH_PTEP_MKDIRTY
+#define __HAVE_ARCH_PTE_SAME
+#include <asm-generic/pgtable.h>
+
 #endif /* __ASM_SH_PAGE_H */
 
diff -puN include/asm-sh/processor.h~linus include/asm-sh/processor.h
--- 25/include/asm-sh/processor.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/processor.h	2004-01-19 22:17:24.000000000 -0800
@@ -2,7 +2,7 @@
  * include/asm-sh/processor.h
  *
  * Copyright (C) 1999, 2000  Niibe Yutaka
- * Copyright (C) 2002 Paul Mundt
+ * Copyright (C) 2002, 2003  Paul Mundt
  */
 
 #ifndef __ASM_SH_PROCESSOR_H
@@ -22,20 +22,27 @@
 /* Core Processor Version Register */
 #define CCN_PVR		0xff000030
 #define CCN_PRR		0xff000044
+
 /*
  *  CPU type and hardware bug flags. Kept separately for each CPU.
+ *
+ *  Each one of these also needs a CONFIG_CPU_SUBTYPE_xxx entry
+ *  in arch/sh/Kconfig, as well as an entry in arch/sh/kernel/setup.c
+ *  for parsing the subtype in get_cpu_subtype().
  */
 enum cpu_type {
-	CPU_SH7604,		/* Represents 7604 */
-	CPU_SH7708,		/* Represents 7707, 7708, 7708S, 7708R, 7709 */
-	CPU_SH7729,		/* Represents 7709A, 7729 */
-	CPU_SH7750,     	/* Represents 7750 */
-	CPU_SH7750S,		/* Represents 7750S */
-	CPU_SH7750R,		/* Represents 7750R */
-	CPU_SH7751,		/* Represents 7751 */
-	CPU_SH7751R,		/* Represents 7751R */
-	CPU_ST40RA,		/* Represents ST40RA (formerly ST40STB1) */
-	CPU_ST40GX1,		/* Represents ST40GX1 */
+	/* SH-2 types */
+	CPU_SH7604,
+
+	/* SH-3 types */
+	CPU_SH7707,  CPU_SH7708, CPU_SH7708S, CPU_SH7708R, CPU_SH7709,
+	CPU_SH7709A, CPU_SH7729, CPU_SH7300,
+
+	/* SH-4 types */
+	CPU_SH7750, CPU_SH7750S, CPU_SH7750R, CPU_SH7751, CPU_SH7751R,
+	CPU_SH7760, CPU_ST40RA, CPU_ST40GX1, CPU_SH4_202, CPU_SH4_501,
+
+	/* Unknown subtype */
 	CPU_SH_NONE
 };
 
@@ -55,12 +62,12 @@ struct sh_cpuinfo {
 	unsigned long flags;
 };
 
+extern struct sh_cpuinfo boot_cpu_data;
+
 #ifdef CONFIG_SMP
 extern struct sh_cpuinfo cpu_data[];
 #define current_cpu_data cpu_data[smp_processor_id()]
 #else
-extern struct sh_cpuinfo boot_cpu_data;
-
 #define cpu_data (&boot_cpu_data)
 #define current_cpu_data boot_cpu_data
 #endif
@@ -87,8 +94,9 @@ extern struct sh_cpuinfo boot_cpu_data;
  * IMASK-bit:
  *     Interrupt level mask
  */
-#define SR_FD    0x00008000
-#define SR_IMASK 0x000000f0
+#define SR_FD		0x00008000
+#define SR_DSP		0x00001000
+#define SR_IMASK	0x000000f0
 
 /*
  * FPU structure and data
@@ -119,7 +127,14 @@ union sh_fpu_union {
 	struct sh_fpu_soft_struct soft;
 };
 
-#define CPU_HAS_FPU	0x0001
+/* 
+ * Processor flags
+ */
+
+#define CPU_HAS_FPU		0x0001	/* Hardware FPU support */
+#define CPU_HAS_P2_FLUSH_BUG	0x0002	/* Need to flush the cache in P2 area */
+#define CPU_HAS_MMU_PAGE_ASSOC	0x0004	/* SH3: TLB way selection bit support */
+#define CPU_HAS_DSP		0x0008	/* SH-DSP: DSP support */
 
 struct thread_struct {
 	unsigned long sp;
@@ -128,16 +143,21 @@ struct thread_struct {
 	unsigned long trap_no, error_code;
 	unsigned long address;
 	/* Hardware debugging registers may come here */
+	unsigned long ubc_pc;
 
 	/* floating point info */
 	union sh_fpu_union fpu;
 };
 
+/* Count of active tasks with UBC settings */
+extern int ubc_usercnt;
+
 #define INIT_THREAD  {						\
 	sizeof(init_stack) + (long) &init_stack, /* sp */	\
 	0,					 /* pc */	\
 	0, 0, 							\
 	0, 							\
+	0, 							\
 	{{{0,}},} 				/* fpu state */	\
 }
 
@@ -239,6 +259,6 @@ extern unsigned long get_wchan(struct ta
 #define KSTK_EIP(tsk)  ((tsk)->thread.pc)
 #define KSTK_ESP(tsk)  ((tsk)->thread.sp)
 
-#define cpu_relax()	barrier()
+#define cpu_relax()	__asm__ __volatile__ ("sleep" : : : "memory")
 
 #endif /* __ASM_SH_PROCESSOR_H */
diff -puN include/asm-sh/ptrace.h~linus include/asm-sh/ptrace.h
--- 25/include/asm-sh/ptrace.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/ptrace.h	2004-01-19 22:17:24.000000000 -0800
@@ -37,13 +37,13 @@
 
 #define REG_SYSCALL	22
 
-#define REG_FPUL	23
+#define REG_FPREG0	23
+#define REG_FPREG15	38
+#define REG_XFREG0	39
+#define REG_XFREG15	54
 
-#define REG_FPREG0	24
-#define REG_FPREG15	39
-#define REG_XDREG0	40
-#define REG_XDREG14	47
-#define REG_FPSCR	48
+#define REG_FPSCR	55
+#define REG_FPUL	56
 
 /* options set using PTRACE_SETOPTIONS */
 #define PTRACE_O_TRACESYSGOOD     0x00000001
@@ -63,6 +63,30 @@ struct pt_regs {
 	long tra;
 };
 
+/*
+ * This struct defines the way the DSP registers are stored on the
+ * kernel stack during a system call or other kernel entry.
+ */
+struct pt_dspregs {
+	unsigned long	a1;
+	unsigned long	a0g;
+	unsigned long	a1g;
+	unsigned long	m0;
+	unsigned long	m1;
+	unsigned long	a0;
+	unsigned long	x0;
+	unsigned long	x1;
+	unsigned long	y0;
+	unsigned long	y1;
+	unsigned long	dsr;
+	unsigned long	rs;
+	unsigned long	re;
+	unsigned long	mod;
+};
+
+#define	PTRACE_GETDSPREGS	55
+#define	PTRACE_SETDSPREGS	56
+
 #ifdef __KERNEL__
 #define user_mode(regs) (((regs)->sr & 0x40000000)==0)
 #define instruction_pointer(regs) ((regs)->pc)
diff -puN include/asm-sh/rtc.h~linus include/asm-sh/rtc.h
--- 25/include/asm-sh/rtc.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/rtc.h	2004-01-19 22:17:24.000000000 -0800
@@ -4,11 +4,11 @@
 #include <asm/machvec.h>
 #include <asm/cpu/rtc.h>
 
-#define rtc_gettimeofday sh_mv.mv_rtc_gettimeofday
-#define rtc_settimeofday sh_mv.mv_rtc_settimeofday
-
 extern void sh_rtc_gettimeofday(struct timespec *ts);
 extern int sh_rtc_settimeofday(const time_t secs);
+extern void (*board_time_init)(void);
+extern void (*rtc_get_time)(struct timespec *);
+extern int (*rtc_set_time)(const time_t);
 
 /* RCR1 Bits */
 #define RCR1_CF		0x80	/* Carry Flag             */
diff -puN include/asm-sh/saturn/io.h~linus include/asm-sh/saturn/io.h
--- 25/include/asm-sh/saturn/io.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/saturn/io.h	2004-01-19 22:17:24.000000000 -0800
@@ -10,48 +10,10 @@
 #ifndef __ASM_SH_SATURN_IO_H
 #define __ASM_SH_SATURN_IO_H
 
-#include <asm/io_generic.h>
-
 /* arch/sh/boards/saturn/io.c */
 extern unsigned long saturn_isa_port2addr(unsigned long offset);
 extern void *saturn_ioremap(unsigned long offset, unsigned long size);
 extern void saturn_iounmap(void *addr);
 
-#ifdef __WANT_IO_DEF
-
-# define __inb			generic_inb
-# define __inw			generic_inw
-# define __inl			generic_inl
-# define __outb			generic_outb
-# define __outw			generic_outw
-# define __outl			generic_outl
-
-# define __inb_p		generic_inb_p
-# define __inw_p		generic_inw
-# define __inl_p		generic_inl
-# define __outb_p		generic_outb_p
-# define __outw_p		generic_outw
-# define __outl_p		generic_outl
-
-# define __insb			generic_insb
-# define __insw			generic_insw
-# define __insl			generic_insl
-# define __outsb		generic_outsb
-# define __outsw		generic_outsw
-# define __outsl		generic_outsl
-
-# define __readb		generic_readb
-# define __readw		generic_readw
-# define __readl		generic_readl
-# define __writeb		generic_writeb
-# define __writew		generic_writew
-# define __writel		generic_writel
-
-# define __isa_port2addr	saturn_isa_port2addr
-# define __ioremap		saturn_ioremap
-# define __iounmap		saturn_iounmap
-
-#endif
-
 #endif /* __ASM_SH_SATURN_IO_H */
 
diff -puN include/asm-sh/se7751/io.h~linus include/asm-sh/se7751/io.h
--- 25/include/asm-sh/se7751/io.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/se7751/io.h	2004-01-19 22:17:24.000000000 -0800
@@ -12,8 +12,6 @@
 #ifndef _ASM_SH_IO_7751SE_H
 #define _ASM_SH_IO_7751SE_H
 
-#include <asm/io_generic.h>
-
 extern unsigned char sh7751se_inb(unsigned long port);
 extern unsigned short sh7751se_inw(unsigned long port);
 extern unsigned int sh7751se_inl(unsigned long port);
@@ -41,40 +39,4 @@ extern void sh7751se_writel(unsigned int
 
 extern unsigned long sh7751se_isa_port2addr(unsigned long offset);
 
-#ifdef __WANT_IO_DEF
-
-# define __inb			sh7751se_inb
-# define __inw			sh7751se_inw
-# define __inl			sh7751se_inl
-# define __outb			sh7751se_outb
-# define __outw			sh7751se_outw
-# define __outl			sh7751se_outl
-
-# define __inb_p		sh7751se_inb_p
-# define __inw_p		sh7751se_inw
-# define __inl_p		sh7751se_inl
-# define __outb_p		sh7751se_outb_p
-# define __outw_p		sh7751se_outw
-# define __outl_p		sh7751se_outl
-
-# define __insb			sh7751se_insb
-# define __insw			sh7751se_insw
-# define __insl			sh7751se_insl
-# define __outsb		sh7751se_outsb
-# define __outsw		sh7751se_outsw
-# define __outsl		sh7751se_outsl
-
-# define __readb		sh7751se_readb
-# define __readw		sh7751se_readw
-# define __readl		sh7751se_readl
-# define __writeb		sh7751se_writeb
-# define __writew		sh7751se_writew
-# define __writel		sh7751se_writel
-
-# define __isa_port2addr	sh7751se_isa_port2addr
-# define __ioremap		generic_ioremap
-# define __iounmap		generic_iounmap
-
-#endif
-
 #endif /* _ASM_SH_IO_7751SE_H */
diff -puN /dev/null include/asm-sh/sections.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/asm-sh/sections.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,9 @@
+#ifndef __ASM_SH_SECTIONS_H
+#define __ASM_SH_SECTIONS_H
+
+#include <asm-generic/sections.h>
+
+extern char _end[];
+
+#endif /* __ASM_SH_SECTIONS_H */
+
diff -puN /dev/null include/asm-sh/segment.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/asm-sh/segment.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,6 @@
+#ifndef __ASM_SH_SEGMENT_H
+#define __ASM_SH_SEGMENT_H
+
+/* Only here because we have some old header files that expect it.. */
+
+#endif /* __ASM_SH_SEGMENT_H */
diff -puN include/asm-sh/se/io.h~linus include/asm-sh/se/io.h
--- 25/include/asm-sh/se/io.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/se/io.h	2004-01-19 22:17:24.000000000 -0800
@@ -12,8 +12,6 @@
 #ifndef _ASM_SH_IO_SE_H
 #define _ASM_SH_IO_SE_H
 
-#include <asm/io_generic.h>
-
 extern unsigned char se_inb(unsigned long port);
 extern unsigned short se_inw(unsigned long port);
 extern unsigned int se_inl(unsigned long port);
@@ -32,49 +30,6 @@ extern void se_outsb(unsigned long port,
 extern void se_outsw(unsigned long port, const void *addr, unsigned long count);
 extern void se_outsl(unsigned long port, const void *addr, unsigned long count);
 
-extern unsigned char se_readb(unsigned long addr);
-extern unsigned short se_readw(unsigned long addr);
-extern unsigned int se_readl(unsigned long addr);
-extern void se_writeb(unsigned char b, unsigned long addr);
-extern void se_writew(unsigned short b, unsigned long addr);
-extern void se_writel(unsigned int b, unsigned long addr);
-
 extern unsigned long se_isa_port2addr(unsigned long offset);
 
-#ifdef __WANT_IO_DEF
-
-# define __inb			se_inb
-# define __inw			se_inw
-# define __inl			se_inl
-# define __outb			se_outb
-# define __outw			se_outw
-# define __outl			se_outl
-
-# define __inb_p		se_inb_p
-# define __inw_p		se_inw
-# define __inl_p		se_inl
-# define __outb_p		se_outb_p
-# define __outw_p		se_outw
-# define __outl_p		se_outl
-
-# define __insb			se_insb
-# define __insw			se_insw
-# define __insl			se_insl
-# define __outsb		se_outsb
-# define __outsw		se_outsw
-# define __outsl		se_outsl
-
-# define __readb		se_readb
-# define __readw		se_readw
-# define __readl		se_readl
-# define __writeb		se_writeb
-# define __writew		se_writew
-# define __writel		se_writel
-
-# define __isa_port2addr	se_isa_port2addr
-# define __ioremap		generic_ioremap
-# define __iounmap		generic_iounmap
-
-#endif
-
 #endif /* _ASM_SH_IO_SE_H */
diff -puN -L include/asm-sh/serial-bigsur.h include/asm-sh/serial-bigsur.h~linus /dev/null
--- 25/include/asm-sh/serial-bigsur.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,27 +0,0 @@
-/*
- * include/asm-sh/serial-bigsur.h
- *
- * Configuration details for Big Sur 16550 based serial ports 
- * i.e. HD64465, PCMCIA, etc.
- */
-
-#ifndef _ASM_SERIAL_BIGSUR_H
-#define _ASM_SERIAL_BIGSUR_H
-#include <asm/hd64465.h>
-
-#define BASE_BAUD (3379200 / 16)
-
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-
-
-#define STD_SERIAL_PORT_DEFNS                   \
-        /* UART CLK   PORT IRQ     FLAGS        */                      \
-        { 0, BASE_BAUD, 0x3F8, HD64465_IRQ_UART, STD_COM_FLAGS } /* ttyS0 */ 
-
-
-#define SERIAL_PORT_DFNS STD_SERIAL_PORT_DEFNS
-
-/* XXX: This should be moved ino irq.h */
-#define irq_canonicalize(x) (x)
-
-#endif /* _ASM_SERIAL_BIGSUR_H */
diff -puN -L include/asm-sh/serial-ec3104.h include/asm-sh/serial-ec3104.h~linus /dev/null
--- 25/include/asm-sh/serial-ec3104.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,22 +0,0 @@
-#include <asm/ec3104.h>
-/* Naturally we don't know the exact value but 115200 baud has a divisor
- * of 9 and 19200 baud has a divisor of 52, so this seems like a good
- * guess.  */
-#define BASE_BAUD (16800000 / 16)
-
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-
-/* there is a fourth serial port with the expected values as well, but
- * it's got the keyboard controller behind it so we can't really use it
- * (without moving the keyboard driver to userspace, which doesn't sound
- * like a very good idea) */
-#define STD_SERIAL_PORT_DEFNS			\
-	/* UART CLK   PORT IRQ     FLAGS        */			\
-	{ 0, BASE_BAUD, 0x11C00, EC3104_IRQBASE+7, STD_COM_FLAGS }, /* ttyS0 */	\
-	{ 0, BASE_BAUD, 0x12000, EC3104_IRQBASE+8, STD_COM_FLAGS }, /* ttyS1 */	\
-	{ 0, BASE_BAUD, 0x12400, EC3104_IRQBASE+9, STD_COM_FLAGS }, /* ttyS2 */
-
-#define SERIAL_PORT_DFNS STD_SERIAL_PORT_DEFNS
-
-/* XXX: This should be moved ino irq.h */
-#define irq_canonicalize(x) (x)
diff -puN include/asm-sh/sigcontext.h~linus include/asm-sh/sigcontext.h
--- 25/include/asm-sh/sigcontext.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/sigcontext.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,26 +1,6 @@
 #ifndef __ASM_SH_SIGCONTEXT_H
 #define __ASM_SH_SIGCONTEXT_H
 
-struct sigcontext {
-	unsigned long	oldmask;
-
-	/* CPU registers */
-	unsigned long sc_regs[16];
-	unsigned long sc_pc;
-	unsigned long sc_pr;
-	unsigned long sc_sr;
-	unsigned long sc_gbr;
-	unsigned long sc_mach;
-	unsigned long sc_macl;
-
-#if defined(CONFIG_CPU_SH4)
-	/* FPU registers */
-	unsigned long sc_fpregs[16];
-	unsigned long sc_xfpregs[16];
-	unsigned int sc_fpscr;
-	unsigned int sc_fpul;
-	unsigned int sc_ownedfp;
-#endif
-};
+#include <asm/cpu/sigcontext.h>
 
 #endif /* __ASM_SH_SIGCONTEXT_H */
diff -puN -L include/asm-sh/smc37c93x.h include/asm-sh/smc37c93x.h~linus /dev/null
--- 25/include/asm-sh/smc37c93x.h
+++ /dev/null	2002-08-30 16:31:37.000000000 -0700
@@ -1,190 +0,0 @@
-#ifndef __ASM_SH_SMC37C93X_H
-#define __ASM_SH_SMC37C93X_H
-
-/*
- * linux/include/asm-sh/smc37c93x.h
- *
- * Copyright (C) 2000  Kazumoto Kojima
- *
- * SMSC 37C93x Super IO Chip support
- */
-
-/* Default base I/O address */
-#define FDC_PRIMARY_BASE	0x3f0
-#define IDE1_PRIMARY_BASE	0x1f0
-#define IDE1_SECONDARY_BASE	0x170
-#define PARPORT_PRIMARY_BASE	0x378
-#define COM1_PRIMARY_BASE	0x2f8
-#define COM2_PRIMARY_BASE	0x3f8
-#define RTC_PRIMARY_BASE	0x070
-#define KBC_PRIMARY_BASE	0x060
-#define AUXIO_PRIMARY_BASE	0x000	/* XXX */
-
-/* Logical device number */
-#define LDN_FDC			0
-#define LDN_IDE1		1
-#define LDN_IDE2		2
-#define LDN_PARPORT		3
-#define LDN_COM1		4
-#define LDN_COM2		5
-#define LDN_RTC			6
-#define LDN_KBC			7
-#define LDN_AUXIO		8
-
-/* Configuration port and key */
-#define CONFIG_PORT		0x3f0
-#define INDEX_PORT		CONFIG_PORT
-#define DATA_PORT		0x3f1
-#define CONFIG_ENTER		0x55
-#define CONFIG_EXIT		0xaa
-
-/* Configuration index */
-#define CURRENT_LDN_INDEX	0x07
-#define POWER_CONTROL_INDEX	0x22
-#define ACTIVATE_INDEX		0x30
-#define IO_BASE_HI_INDEX	0x60
-#define IO_BASE_LO_INDEX	0x61
-#define IRQ_SELECT_INDEX	0x70
-#define DMA_SELECT_INDEX	0x74
-
-#define GPIO46_INDEX		0xc6
-#define GPIO47_INDEX		0xc7
-
-/* UART stuff. Only for debugging.  */
-/* UART Register */
-
-#define UART_RBR	0x0	/* Receiver Buffer Register (Read Only) */
-#define UART_THR	0x0	/* Transmitter Holding Register (Write Only) */
-#define UART_IER	0x2	/* Interrupt Enable Register */
-#define UART_IIR	0x4	/* Interrupt Ident Register (Read Only) */
-#define UART_FCR	0x4	/* FIFO Control Register (Write Only) */
-#define UART_LCR	0x6	/* Line Control Register */
-#define UART_MCR	0x8	/* MODEM Control Register */
-#define UART_LSR	0xa	/* Line Status Register */
-#define UART_MSR	0xc	/* MODEM Status Register */
-#define UART_SCR	0xe	/* Scratch Register */
-#define UART_DLL	0x0	/* Divisor Latch (LS) */
-#define UART_DLM	0x2	/* Divisor Latch (MS) */
-
-#ifndef __ASSEMBLY__
-typedef struct uart_reg {
-	volatile __u16 rbr;
-	volatile __u16 ier;
-	volatile __u16 iir;
-	volatile __u16 lcr;
-	volatile __u16 mcr;
-	volatile __u16 lsr;
-	volatile __u16 msr;
-	volatile __u16 scr;
-} uart_reg;
-#endif /* ! __ASSEMBLY__ */
-
-/* Alias for Write Only Register */
-
-#define thr	rbr
-#define tcr	iir
-
-/* Alias for Divisor Latch Register */
-
-#define dll	rbr
-#define dlm	ier
-#define fcr	iir
-
-/* Interrupt Enable Register */
-
-#define IER_ERDAI	0x0100	/* Enable Received Data Available Interrupt */
-#define IER_ETHREI	0x0200	/* Enable Transmitter Holding Register Empty Interrupt */
-#define IER_ELSI	0x0400	/* Enable Receiver Line Status Interrupt */
-#define IER_EMSI	0x0800	/* Enable MODEM Status Interrupt */
-
-/* Interrupt Ident Register */
-
-#define IIR_IP		0x0100	/* "0" if Interrupt Pending */
-#define IIR_IIB0	0x0200	/* Interrupt ID Bit 0 */
-#define IIR_IIB1	0x0400	/* Interrupt ID Bit 1 */
-#define IIR_IIB2	0x0800	/* Interrupt ID Bit 2 */
-#define IIR_FIFO	0xc000	/* FIFOs enabled */
-
-/* FIFO Control Register */
-
-#define FCR_FEN		0x0100	/* FIFO enable */
-#define FCR_RFRES	0x0200	/* Receiver FIFO reset */
-#define FCR_TFRES	0x0400	/* Transmitter FIFO reset */
-#define FCR_DMA		0x0800	/* DMA mode select */
-#define FCR_RTL		0x4000	/* Receiver triger (LSB) */
-#define FCR_RTM		0x8000	/* Receiver triger (MSB) */
-
-/* Line Control Register */
-
-#define LCR_WLS0	0x0100	/* Word Length Select Bit 0 */
-#define LCR_WLS1	0x0200	/* Word Length Select Bit 1 */
-#define LCR_STB		0x0400	/* Number of Stop Bits */
-#define LCR_PEN		0x0800	/* Parity Enable */
-#define LCR_EPS		0x1000	/* Even Parity Select */
-#define LCR_SP		0x2000	/* Stick Parity */
-#define LCR_SB		0x4000	/* Set Break */
-#define LCR_DLAB	0x8000	/* Divisor Latch Access Bit */
-
-/* MODEM Control Register */
-
-#define MCR_DTR		0x0100	/* Data Terminal Ready */
-#define MCR_RTS		0x0200	/* Request to Send */
-#define MCR_OUT1	0x0400	/* Out 1 */
-#define MCR_IRQEN	0x0800	/* IRQ Enable */
-#define MCR_LOOP	0x1000	/* Loop */
-
-/* Line Status Register */
-
-#define LSR_DR		0x0100	/* Data Ready */
-#define LSR_OE		0x0200	/* Overrun Error */
-#define LSR_PE		0x0400	/* Parity Error */
-#define LSR_FE		0x0800	/* Framing Error */
-#define LSR_BI		0x1000	/* Break Interrupt */
-#define LSR_THRE	0x2000	/* Transmitter Holding Register Empty */
-#define LSR_TEMT	0x4000	/* Transmitter Empty */
-#define LSR_FIFOE	0x8000	/* Receiver FIFO error */
-
-/* MODEM Status Register */
-
-#define MSR_DCTS	0x0100	/* Delta Clear to Send */
-#define MSR_DDSR	0x0200	/* Delta Data Set Ready */
-#define MSR_TERI	0x0400	/* Trailing Edge Ring Indicator */
-#define MSR_DDCD	0x0800	/* Delta Data Carrier Detect */
-#define MSR_CTS		0x1000	/* Clear to Send */
-#define MSR_DSR		0x2000	/* Data Set Ready */
-#define MSR_RI		0x4000	/* Ring Indicator */
-#define MSR_DCD		0x8000	/* Data Carrier Detect */
-
-/* Baud Rate Divisor */
-
-#define UART_CLK	(1843200)	/* 1.8432 MHz */
-#define UART_BAUD(x)	(UART_CLK / (16 * (x)))
-
-/* RTC register definition */
-#define RTC_SECONDS             0
-#define RTC_SECONDS_ALARM       1
-#define RTC_MINUTES             2
-#define RTC_MINUTES_ALARM       3
-#define RTC_HOURS               4
-#define RTC_HOURS_ALARM         5
-#define RTC_DAY_OF_WEEK         6
-#define RTC_DAY_OF_MONTH        7
-#define RTC_MONTH               8
-#define RTC_YEAR                9
-#define RTC_FREQ_SELECT		10
-# define RTC_UIP 0x80
-# define RTC_DIV_CTL 0x70
-/* This RTC can work under 32.768KHz clock only.  */
-# define RTC_OSC_ENABLE 0x20
-# define RTC_OSC_DISABLE 0x00
-#define RTC_CONTROL     	11
-# define RTC_SET 0x80
-# define RTC_PIE 0x40
-# define RTC_AIE 0x20
-# define RTC_UIE 0x10
-# define RTC_SQWE 0x08
-# define RTC_DM_BINARY 0x04
-# define RTC_24H 0x02
-# define RTC_DST_EN 0x01
-
-#endif  /* __ASM_SH_SMC37C93X_H */
diff -puN include/asm-sh/smp.h~linus include/asm-sh/smp.h
--- 25/include/asm-sh/smp.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/smp.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,11 +1,18 @@
 /*
- * Copyright (C) 2002 Paul Mundt
+ * include/asm-sh/smp.h
+ *
+ * Copyright (C) 2002, 2003  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive for
+ * more details.
  */
 #ifndef __ASM_SH_SMP_H
 #define __ASM_SH_SMP_H
 
 #include <linux/config.h>
 #include <linux/bitops.h>
+#include <linux/cpumask.h>
 
 #ifdef CONFIG_SMP
 
@@ -13,18 +20,13 @@
 #include <asm/atomic.h>
 #include <asm/current.h>
 
-extern unsigned long cpu_online_map;
+extern cpumask_t cpu_online_map;
+extern cpumask_t cpu_possible_map;
 
-#define cpu_online(cpu)		(cpu_online_map & (1 << (cpu)))
-#define cpu_possible(cpu)	(cpu_online(cpu))
+#define cpu_online(cpu)		cpu_isset(cpu, cpu_online_map)
 
 #define smp_processor_id()	(current_thread_info()->cpu)
 
-extern inline unsigned int num_online_cpus(void)
-{
-	return hweight32(cpu_online_map);
-}
-
 /* I've no idea what the real meaning of this is */
 #define PROC_CHANGE_PENALTY	20
 
diff -puN /dev/null include/asm-sh/snapgear/io.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/asm-sh/snapgear/io.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,92 @@
+/*
+ * include/asm-sh/snapgear/io.h
+ *
+ * Modified version of io_se.h for the snapgear-specific functions.
+ *
+ * May be copied or modified under the terms of the GNU General Public
+ * License.  See linux/COPYING for more information.
+ *
+ * IO functions for a SnapGear
+ */
+
+#ifndef _ASM_SH_IO_SNAPGEAR_H
+#define _ASM_SH_IO_SNAPGEAR_H
+
+#if defined(CONFIG_CPU_SH4)
+/*
+ * The external interrupt lines, these take up ints 0 - 15 inclusive
+ * depending on the priority for the interrupt.  In fact the priority
+ * is the interrupt :-)
+ */
+
+#define IRL0_IRQ		2
+#define IRL0_IPR_ADDR	INTC_IPRD
+#define IRL0_IPR_POS	3
+#define IRL0_PRIORITY	13
+
+#define IRL1_IRQ		5
+#define IRL1_IPR_ADDR	INTC_IPRD
+#define IRL1_IPR_POS	2
+#define IRL1_PRIORITY	10
+
+#define IRL2_IRQ		8
+#define IRL2_IPR_ADDR	INTC_IPRD
+#define IRL2_IPR_POS	1
+#define IRL2_PRIORITY	7
+
+#define IRL3_IRQ		11
+#define IRL3_IPR_ADDR	INTC_IPRD
+#define IRL3_IPR_POS	0
+#define IRL3_PRIORITY	4
+#endif
+
+extern unsigned char snapgear_inb(unsigned long port);
+extern unsigned short snapgear_inw(unsigned long port);
+extern unsigned int snapgear_inl(unsigned long port);
+
+extern void snapgear_outb(unsigned char value, unsigned long port);
+extern void snapgear_outw(unsigned short value, unsigned long port);
+extern void snapgear_outl(unsigned int value, unsigned long port);
+
+extern unsigned char snapgear_inb_p(unsigned long port);
+extern void snapgear_outb_p(unsigned char value, unsigned long port);
+
+extern void snapgear_insl(unsigned long port, void *addr, unsigned long count);
+extern void snapgear_outsl(unsigned long port, const void *addr, unsigned long count);
+
+extern unsigned long snapgear_isa_port2addr(unsigned long offset);
+
+#ifdef CONFIG_SH_SECUREEDGE5410
+/*
+ * We need to remember what was written to the ioport as some bits
+ * are shared with other functions and you cannot read back what was
+ * written :-|
+ *
+ * Bit        Read                   Write
+ * -----------------------------------------------
+ * D0         DCD on ttySC1          power
+ * D1         Reset Switch           heatbeat
+ * D2         ttySC0 CTS (7100)      LAN
+ * D3         -                      WAN
+ * D4         ttySC0 DCD (7100)      CONSOLE
+ * D5         -                      ONLINE
+ * D6         -                      VPN
+ * D7         -                      DTR on ttySC1
+ * D8         -                      ttySC0 RTS (7100)
+ * D9         -                      ttySC0 DTR (7100)
+ * D10        -                      RTC SCLK
+ * D11        RTC DATA               RTC DATA
+ * D12        -                      RTS RESET
+ */
+
+ #define SECUREEDGE_IOPORT_ADDR ((volatile short *) 0xb0000000)
+ extern unsigned short secureedge5410_ioport;
+
+ #define SECUREEDGE_WRITE_IOPORT(val, mask) (*SECUREEDGE_IOPORT_ADDR = \
+		 (secureedge5410_ioport = \
+		 		((secureedge5410_ioport & ~(mask)) | ((val) & (mask)))))
+ #define SECUREEDGE_READ_IOPORT() \
+ 		 ((*SECUREEDGE_IOPORT_ADDR&0x0817) | (secureedge5410_ioport&~0x0817))
+#endif
+
+#endif /* _ASM_SH_IO_SNAPGEAR_H */
diff -puN include/asm-sh/socket.h~linus include/asm-sh/socket.h
--- 25/include/asm-sh/socket.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/socket.h	2004-01-19 22:17:24.000000000 -0800
@@ -45,6 +45,8 @@
 
 #define SO_ACCEPTCONN		30
 
+#define SO_PEERSEC		31
+
 /* Nast libc5 fixup - bletch */
 #if defined(__KERNEL__)
 /* Socket types. */
diff -puN include/asm-sh/spinlock.h~linus include/asm-sh/spinlock.h
--- 25/include/asm-sh/spinlock.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/spinlock.h	2004-01-19 22:17:24.000000000 -0800
@@ -48,8 +48,7 @@ static inline void _raw_spin_lock(spinlo
 static inline void _raw_spin_unlock(spinlock_t *lock)
 {
 #ifdef CONFIG_DEBUG_SPINLOCK
-	if (!spin_is_locked(lock))
-		BUG();
+	BUG_ON(!spin_is_locked(lock));
 #endif
 
 	lock->lock = 0;
@@ -70,9 +69,10 @@ typedef struct {
 	atomic_t counter;
 } rwlock_t;
 
-#define RW_LOCK_UNLOCKED	(rwlock_t) { { 0 } }
+#define RW_LOCK_BIAS		0x01000000
+#define RW_LOCK_UNLOCKED	(rwlock_t) { { 0 }, { RW_LOCK_BIAS } }
 #define rwlock_init(x)		do { *(x) = RW_LOCK_UNLOCKED; } while (0)
-#define rwlock_is_locked(x)	(*(volatile int *)(x) != 0)
+#define rwlock_is_locked(x)	(atomic_read(&(x)->counter) != RW_LOCK_BIAS)
 
 static inline void _raw_read_lock(rwlock_t *rw)
 {
@@ -104,5 +104,15 @@ static inline void _raw_write_unlock(rwl
 	_raw_spin_unlock(&rw->lock);
 }
 
+static inline int _raw_write_trylock(rwlock_t *rw)
+{
+	if (atomic_sub_and_test(RW_LOCK_BIAS, &rw->counter))
+		return 1;
+	
+	atomic_add(RW_LOCK_BIAS, &rw->counter);
+
+	return 0;
+}
+
 #endif /* __ASM_SH_SPINLOCK_H */
 
diff -puN include/asm-sh/system.h~linus include/asm-sh/system.h
--- 25/include/asm-sh/system.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/system.h	2004-01-19 22:17:24.000000000 -0800
@@ -14,7 +14,7 @@
  */
 
 #define switch_to(prev, next, last) do {				\
- register unsigned long __dummy;					\
+ task_t *__last;							\
  register unsigned long *__ts1 __asm__ ("r1") = &prev->thread.sp;	\
  register unsigned long *__ts2 __asm__ ("r2") = &prev->thread.pc;	\
  register unsigned long *__ts4 __asm__ ("r4") = (unsigned long *)prev;	\
@@ -51,10 +51,11 @@
 		       "mov.l	@r15+, r8\n\t"				\
 		       "lds.l	@r15+, pr\n\t"				\
 		       "ldc.l	@r15+, gbr\n\t"				\
-		       : "=z" (__dummy)					\
+		       : "=z" (__last)					\
 		       : "r" (__ts1), "r" (__ts2), "r" (__ts4), 	\
 			 "r" (__ts5), "r" (__ts6), "r" (__ts7) 		\
 		       : "r3", "t");					\
+	last = __last;							\
 } while (0)
 
 #define nop() __asm__ __volatile__ ("nop")
diff -puN /dev/null include/asm-sh/systemh/7751systemh.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/asm-sh/systemh/7751systemh.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,68 @@
+#ifndef __ASM_SH_SYSTEMH_7751SYSTEMH_H
+#define __ASM_SH_SYSTEMH_7751SYSTEMH_H
+
+/*
+ * linux/include/asm-sh/systemh/7751systemh.h
+ *
+ * Copyright (C) 2000  Kazumoto Kojima
+ *
+ * Hitachi SystemH support
+
+ * Modified for 7751 SystemH by
+ * Jonathan Short, 2002.
+ */
+
+/* Box specific addresses.  */
+
+#define PA_ROM		0x00000000	/* EPROM */
+#define PA_ROM_SIZE	0x00400000	/* EPROM size 4M byte */
+#define PA_FROM		0x01000000	/* EPROM */
+#define PA_FROM_SIZE	0x00400000	/* EPROM size 4M byte */
+#define PA_EXT1		0x04000000
+#define PA_EXT1_SIZE	0x04000000
+#define PA_EXT2		0x08000000
+#define PA_EXT2_SIZE	0x04000000
+#define PA_SDRAM	0x0c000000
+#define PA_SDRAM_SIZE	0x04000000
+
+#define PA_EXT4		0x12000000
+#define PA_EXT4_SIZE	0x02000000
+#define PA_EXT5		0x14000000
+#define PA_EXT5_SIZE	0x04000000
+#define PA_PCIC		0x18000000	/* MR-SHPC-01 PCMCIA */
+
+#define PA_DIPSW0	0xb9000000	/* Dip switch 5,6 */
+#define PA_DIPSW1	0xb9000002	/* Dip switch 7,8 */
+#define PA_LED		0xba000000	/* LED */
+#define	PA_BCR		0xbb000000	/* FPGA on the MS7751SE01 */
+
+#define PA_MRSHPC	0xb83fffe0	/* MR-SHPC-01 PCMCIA controler */
+#define PA_MRSHPC_MW1	0xb8400000	/* MR-SHPC-01 memory window base */
+#define PA_MRSHPC_MW2	0xb8500000	/* MR-SHPC-01 attribute window base */
+#define PA_MRSHPC_IO	0xb8600000	/* MR-SHPC-01 I/O window base */
+#define MRSHPC_MODE     (PA_MRSHPC + 4)
+#define MRSHPC_OPTION   (PA_MRSHPC + 6)
+#define MRSHPC_CSR      (PA_MRSHPC + 8)
+#define MRSHPC_ISR      (PA_MRSHPC + 10)
+#define MRSHPC_ICR      (PA_MRSHPC + 12)
+#define MRSHPC_CPWCR    (PA_MRSHPC + 14)
+#define MRSHPC_MW0CR1   (PA_MRSHPC + 16)
+#define MRSHPC_MW1CR1   (PA_MRSHPC + 18)
+#define MRSHPC_IOWCR1   (PA_MRSHPC + 20)
+#define MRSHPC_MW0CR2   (PA_MRSHPC + 22)
+#define MRSHPC_MW1CR2   (PA_MRSHPC + 24)
+#define MRSHPC_IOWCR2   (PA_MRSHPC + 26)
+#define MRSHPC_CDCR     (PA_MRSHPC + 28)
+#define MRSHPC_PCIC_INFO (PA_MRSHPC + 30)
+
+#define BCR_ILCRA	(PA_BCR + 0)
+#define BCR_ILCRB	(PA_BCR + 2)
+#define BCR_ILCRC	(PA_BCR + 4)
+#define BCR_ILCRD	(PA_BCR + 6)
+#define BCR_ILCRE	(PA_BCR + 8)
+#define BCR_ILCRF	(PA_BCR + 10)
+#define BCR_ILCRG	(PA_BCR + 12)
+
+#define IRQ_79C973	13
+
+#endif  /* __ASM_SH_SYSTEMH_7751SYSTEMH_H */
diff -puN /dev/null include/asm-sh/systemh/io.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/asm-sh/systemh/io.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,43 @@
+/*
+ * include/asm-sh/systemh/io.h
+ *
+ * Stupid I/O definitions for SystemH, cloned from SE7751.
+ *
+ * Copyright (C) 2003  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#ifndef __ASM_SH_SYSTEMH_IO_H
+#define __ASM_SH_SYSTEMH_IO_H
+
+extern unsigned char sh7751systemh_inb(unsigned long port);
+extern unsigned short sh7751systemh_inw(unsigned long port);
+extern unsigned int sh7751systemh_inl(unsigned long port);
+
+extern void sh7751systemh_outb(unsigned char value, unsigned long port);
+extern void sh7751systemh_outw(unsigned short value, unsigned long port);
+extern void sh7751systemh_outl(unsigned int value, unsigned long port);
+
+extern unsigned char sh7751systemh_inb_p(unsigned long port);
+extern void sh7751systemh_outb_p(unsigned char value, unsigned long port);
+
+extern void sh7751systemh_insb(unsigned long port, void *addr, unsigned long count);
+extern void sh7751systemh_insw(unsigned long port, void *addr, unsigned long count);
+extern void sh7751systemh_insl(unsigned long port, void *addr, unsigned long count);
+extern void sh7751systemh_outsb(unsigned long port, const void *addr, unsigned long count);
+extern void sh7751systemh_outsw(unsigned long port, const void *addr, unsigned long count);
+extern void sh7751systemh_outsl(unsigned long port, const void *addr, unsigned long count);
+
+extern unsigned char sh7751systemh_readb(unsigned long addr);
+extern unsigned short sh7751systemh_readw(unsigned long addr);
+extern unsigned int sh7751systemh_readl(unsigned long addr);
+extern void sh7751systemh_writeb(unsigned char b, unsigned long addr);
+extern void sh7751systemh_writew(unsigned short b, unsigned long addr);
+extern void sh7751systemh_writel(unsigned int b, unsigned long addr);
+
+extern unsigned long sh7751systemh_isa_port2addr(unsigned long offset);
+
+#endif /* __ASM_SH_SYSTEMH_IO_H */
+
diff -puN include/asm-sh/timex.h~linus include/asm-sh/timex.h
--- 25/include/asm-sh/timex.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/timex.h	2004-01-19 22:17:24.000000000 -0800
@@ -6,7 +6,7 @@
 #ifndef __ASM_SH_TIMEX_H
 #define __ASM_SH_TIMEX_H
 
-#define CLOCK_TICK_RATE	(current_cpu_data.module_clock/4) /* Underlying HZ */
+#define CLOCK_TICK_RATE		(CONFIG_SH_PCLK_FREQ / 4) /* Underlying HZ */
 #define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
 #define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
 	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
diff -puN include/asm-sh/uaccess.h~linus include/asm-sh/uaccess.h
--- 25/include/asm-sh/uaccess.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/uaccess.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,4 +1,4 @@
-/* $Id: uaccess.h,v 1.9 2003/05/06 23:28:51 lethal Exp $
+/* $Id: uaccess.h,v 1.11 2003/10/13 07:21:20 lethal Exp $
  *
  * User space memory access functions
  *
@@ -140,13 +140,13 @@ static inline int __access_ok(unsigned l
 }
 #endif /* CONFIG_MMU */
 
-static inline int access_ok(int type, const void *p, unsigned long size)
+static inline int access_ok(int type, const void __user *p, unsigned long size)
 {
 	unsigned long addr = (unsigned long)p;
 	return __access_ok(addr, size);
 }
 
-static inline int verify_area(int type, const void * addr, unsigned long size)
+static inline int verify_area(int type, const void __user * addr, unsigned long size)
 {
 	return access_ok(type,addr,size) ? 0 : -EFAULT;
 }
@@ -171,40 +171,64 @@ static inline int verify_area(int type, 
  * doing multiple accesses to the same area (the user has to do the
  * checks by hand with "access_ok()")
  */
-#define __put_user(x,ptr) __put_user_nocheck((x),(ptr),sizeof(*(ptr)))
-#define __get_user(x,ptr) __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
+#define __put_user(x,ptr) \
+  __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
+#define __get_user(x,ptr) \
+  __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
 
 struct __large_struct { unsigned long buf[100]; };
 #define __m(x) (*(struct __large_struct *)(x))
 
-#define __get_user_nocheck(x,ptr,size) ({ \
-long __gu_err; \
-__typeof(*(ptr)) __gu_val; \
-long __gu_addr; \
-__asm__("":"=r" (__gu_val)); \
-__gu_addr = (long) (ptr); \
-__asm__("":"=r" (__gu_err)); \
-switch (size) { \
-case 1: __get_user_asm("b"); break; \
-case 2: __get_user_asm("w"); break; \
-case 4: __get_user_asm("l"); break; \
-default: __get_user_unknown(); break; \
-} x = (__typeof__(*(ptr))) __gu_val; __gu_err; })
-
-#define __get_user_check(x,ptr,size)			\
-({ __typeof__(*(ptr)) __val; long __err;		\
- switch(size) {						\
- case 1: __err = __get_user_1(__val, ptr); break;	\
- case 2: __err = __get_user_2(__val, ptr); break;	\
- case 4: __err = __get_user_4(__val, ptr); break;	\
- default: __get_user_unknown(); break;			\
- }							\
- (x) = __val; __err; })
-
-#define __get_user_1(x,ptr) ({			\
-long __gu_err;					\
-__typeof__(*(ptr)) __gu_val;			\
-long __gu_addr = (long) (ptr);			\
+#define __get_user_size(x,ptr,size,retval)			\
+do {								\
+	retval = 0;						\
+	switch (size) {						\
+	case 1:							\
+		__get_user_asm(x, ptr, retval, "b");		\
+		break;						\
+	case 2:							\
+		__get_user_asm(x, ptr, retval, "w");		\
+		break;						\
+	case 4:							\
+		__get_user_asm(x, ptr, retval, "l");		\
+		break;						\
+	default:						\
+		__get_user_unknown();				\
+		break;						\
+	}							\
+} while (0)
+
+#define __get_user_nocheck(x,ptr,size)				\
+({								\
+	long __gu_err, __gu_val;				\
+	__get_user_size(__gu_val, (ptr), (size), __gu_err);	\
+	(x) = (__typeof__(*(ptr)))__gu_val;			\
+	__gu_err;						\
+})
+
+#define __get_user_check(x,ptr,size)				\
+({								\
+	long __gu_err, __gu_val;				\
+	switch (size) {						\
+	case 1:							\
+		__get_user_1(__gu_val, (ptr), __gu_err);	\
+		break;						\
+	case 2:							\
+		__get_user_2(__gu_val, (ptr), __gu_err);	\
+		break;						\
+	case 4:							\
+		__get_user_4(__gu_val, (ptr), __gu_err);	\
+		break;						\
+	default:						\
+		__get_user_unknown();				\
+		break;						\
+	}							\
+								\
+	(x) = (__typeof__(*(ptr)))__gu_val;			\
+	__gu_err;						\
+})
+
+#define __get_user_1(x,addr,err) ({		\
 __asm__("stc	r7_bank, %1\n\t"		\
 	"mov.l	@(8,%1), %1\n\t"		\
 	"and	%2, %1\n\t"			\
@@ -222,15 +246,12 @@ __asm__("stc	r7_bank, %1\n\t"		\
 	".section	__ex_table,\"a\"\n\t"	\
 	".long	1b, 0b\n\t"			\
 	".previous"				\
-	: "=&r" (__gu_err), "=&r" (__gu_val)	\
-	: "r" (__gu_addr)			\
+	: "=&r" (err), "=&r" (x)		\
+	: "r" (addr)				\
 	: "t");					\
-x = (__typeof__(*(ptr))) __gu_val; __gu_err; })
+})
 
-#define __get_user_2(x,ptr) ({			\
-long __gu_err;					\
-__typeof__(*(ptr)) __gu_val;			\
-long __gu_addr = (long) (ptr);			\
+#define __get_user_2(x,addr,err) ({		\
 __asm__("stc	r7_bank, %1\n\t"		\
 	"mov.l	@(8,%1), %1\n\t"		\
 	"and	%2, %1\n\t"			\
@@ -248,15 +269,12 @@ __asm__("stc	r7_bank, %1\n\t"		\
 	".section	__ex_table,\"a\"\n\t"	\
 	".long	1b, 0b\n\t"			\
 	".previous"				\
-	: "=&r" (__gu_err), "=&r" (__gu_val)	\
-	: "r" (__gu_addr)			\
+	: "=&r" (err), "=&r" (x)		\
+	: "r" (addr)				\
 	: "t");					\
-x = (__typeof__(*(ptr))) __gu_val; __gu_err; })
+})
 
-#define __get_user_4(x,ptr) ({			\
-long __gu_err;					\
-__typeof__(*(ptr)) __gu_val;			\
-long __gu_addr = (long) (ptr);			\
+#define __get_user_4(x,addr,err) ({		\
 __asm__("stc	r7_bank, %1\n\t"		\
 	"mov.l	@(8,%1), %1\n\t"		\
 	"and	%2, %1\n\t"			\
@@ -273,12 +291,12 @@ __asm__("stc	r7_bank, %1\n\t"		\
 	".section	__ex_table,\"a\"\n\t"	\
 	".long	1b, 0b\n\t"			\
 	".previous"				\
-	: "=&r" (__gu_err), "=&r" (__gu_val)	\
-	: "r" (__gu_addr)			\
+	: "=&r" (err), "=&r" (x)		\
+	: "r" (addr)				\
 	: "t");					\
-x = (__typeof__(*(ptr))) __gu_val; __gu_err; })
+})
 
-#define __get_user_asm(insn) \
+#define __get_user_asm(x, addr, err, insn) \
 ({ \
 __asm__ __volatile__( \
 	"1:\n\t" \
@@ -296,43 +314,50 @@ __asm__ __volatile__( \
 	".section	__ex_table,\"a\"\n\t" \
 	".long	1b, 3b\n\t" \
 	".previous" \
-	:"=&r" (__gu_err), "=&r" (__gu_val) \
-	:"m" (__m(__gu_addr)), "i" (-EFAULT)); })
+	:"=&r" (err), "=&r" (x) \
+	:"m" (__m(addr)), "i" (-EFAULT)); })
 
 extern void __get_user_unknown(void);
 
-#define __put_user_nocheck(x,ptr,size) ({ \
-long __pu_err; \
-__typeof__(*(ptr)) __pu_val; \
-long __pu_addr; \
-__pu_val = (x); \
-__pu_addr = (long) (ptr); \
-__asm__("":"=r" (__pu_err)); \
-switch (size) { \
-case 1: __put_user_asm("b"); break; \
-case 2: __put_user_asm("w"); break; \
-case 4: __put_user_asm("l"); break; \
-case 8: __put_user_u64(__pu_val,__pu_addr,__pu_err); break; \
-default: __put_user_unknown(); break; \
-} __pu_err; })
-
-#define __put_user_check(x,ptr,size) ({ \
-long __pu_err; \
-__typeof__(*(ptr)) __pu_val; \
-long __pu_addr; \
-__pu_val = (x); \
-__pu_addr = (long) (ptr); \
-__asm__("":"=r" (__pu_err)); \
-if (__access_ok(__pu_addr,size)) { \
-switch (size) { \
-case 1: __put_user_asm("b"); break; \
-case 2: __put_user_asm("w"); break; \
-case 4: __put_user_asm("l"); break; \
-case 8: __put_user_u64(__pu_val,__pu_addr,__pu_err); break; \
-default: __put_user_unknown(); break; \
-} } __pu_err; })
+#define __put_user_size(x,ptr,size,retval)		\
+do {							\
+	retval = 0;					\
+	switch (size) {					\
+	case 1:						\
+		__put_user_asm(x, ptr, retval, "b");	\
+		break;					\
+	case 2:						\
+		__put_user_asm(x, ptr, retval, "w");	\
+		break;					\
+	case 4:						\
+		__put_user_asm(x, ptr, retval, "l");	\
+		break;					\
+	case 8:						\
+		__put_user_u64(x, ptr, retval);		\
+		break;					\
+	default:					\
+		__put_user_unknown();			\
+	}						\
+} while (0)
+
+#define __put_user_nocheck(x,ptr,size)			\
+({							\
+	long __pu_err;					\
+	__put_user_size((x),(ptr),(size),__pu_err);	\
+	__pu_err;					\
+})
+
+#define __put_user_check(x,ptr,size)				\
+({								\
+	long __pu_err = -EFAULT;				\
+	__typeof__(*(ptr)) *__pu_addr = (ptr);			\
+								\
+	if (__access_ok((unsigned long)__pu_addr,size))		\
+		__put_user_size((x),__pu_addr,(size),__pu_err);	\
+	__pu_err;						\
+})
 
-#define __put_user_asm(insn) \
+#define __put_user_asm(x, addr, err, insn) \
 ({ \
 __asm__ __volatile__( \
 	"1:\n\t" \
@@ -350,8 +375,8 @@ __asm__ __volatile__( \
 	".section	__ex_table,\"a\"\n\t" \
 	".long	1b, 3b\n\t" \
 	".previous" \
-	:"=&r" (__pu_err) \
-	:"r" (__pu_val), "m" (__m(__pu_addr)), "i" (-EFAULT) \
+	:"=&r" (err) \
+	:"r" (x), "m" (__m(addr)), "i" (-EFAULT) \
         :"memory"); })
 
 #if defined(__LITTLE_ENDIAN__)
@@ -449,7 +474,7 @@ __cl_size = __clear_user(__cl_addr, __cl
 __cl_size; })
 
 static __inline__ int
-__strncpy_from_user(unsigned long __dest, unsigned long __src, int __count)
+__strncpy_from_user(unsigned long __dest, unsigned long __user __src, int __count)
 {
 	__kernel_size_t res;
 	unsigned long __dummy, _d, _s;
@@ -498,7 +523,7 @@ __sfu_res = __strncpy_from_user((unsigne
 /*
  * Return the size of a string (including the ending 0!)
  */
-static __inline__ long __strnlen_user(const char *__s, long __n)
+static __inline__ long __strnlen_user(const char __user *__s, long __n)
 {
 	unsigned long res;
 	unsigned long __dummy;
@@ -531,7 +556,7 @@ static __inline__ long __strnlen_user(co
 	return res;
 }
 
-static __inline__ long strnlen_user(const char *s, long n)
+static __inline__ long strnlen_user(const char __user *s, long n)
 {
 	if (!access_ok(VERIFY_READ, s, n))
 		return 0;
@@ -539,7 +564,7 @@ static __inline__ long strnlen_user(cons
 		return __strnlen_user(s, n);
 }
 
-static __inline__ long strlen_user(const char *s)
+static __inline__ long strlen_user(const char __user *s)
 {
 	if (!access_ok(VERIFY_READ, s, 0))
 		return 0;
@@ -547,9 +572,24 @@ static __inline__ long strlen_user(const
 		return __strnlen_user(s, ~0UL >> 1);
 }
 
+/*
+ * The exception table consists of pairs of addresses: the first is the
+ * address of an instruction that is allowed to fault, and the second is
+ * the address at which the program should continue.  No registers are
+ * modified, so it is entirely up to the continuation code to figure out
+ * what to do.
+ *
+ * All the routines below use bits of fixup code that are out of line
+ * with the main instruction path.  This means when everything is well,
+ * we don't even have to jump over them.  Further, they do not intrude
+ * on our cache or tlb entries.
+ */
+
 struct exception_table_entry
 {
 	unsigned long insn, fixup;
 };
 
+extern int fixup_exception(struct pt_regs *regs);
+
 #endif /* __ASM_SH_UACCESS_H */
diff -puN include/asm-sh/unistd.h~linus include/asm-sh/unistd.h
--- 25/include/asm-sh/unistd.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sh/unistd.h	2004-01-19 22:17:24.000000000 -0800
@@ -275,8 +275,14 @@
 #define __NR_clock_gettime	(__NR_timer_create+6)
 #define __NR_clock_getres	(__NR_timer_create+7)
 #define __NR_clock_nanosleep	(__NR_timer_create+8)
+#define __NR_statfs64		268
+#define __NR_fstatfs64		269
+#define __NR_tgkill		270
+#define __NR_utimes		271
+#define __NR_fadvise64_64	272
+#define __NR_vserver		273
 
-#define NR_syscalls 268
+#define NR_syscalls 274
 
 /* user-visible error numbers are in the range -1 - -124: see <asm-sh/errno.h> */
 
@@ -435,6 +441,8 @@ static __inline__ pid_t wait(int * wait_
  * What we want is __attribute__((weak,alias("sys_ni_syscall"))),
  * but it doesn't work on all toolchains, so we just do it by hand
  */
+#ifndef cond_syscall
 #define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall");
+#endif
 
 #endif /* __ASM_SH_UNISTD_H */
diff -puN include/asm-sparc64/floppy.h~linus include/asm-sparc64/floppy.h
--- 25/include/asm-sparc64/floppy.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sparc64/floppy.h	2004-01-19 22:17:24.000000000 -0800
@@ -320,10 +320,9 @@ static void sun_pci_fd_lde_broken_outb(u
 
 static void sun_pci_fd_enable_dma(void)
 {
-	if ((NULL == sun_pci_dma_pending.buf) 	||
+	BUG_ON((NULL == sun_pci_dma_pending.buf) 	||
 	    (0	  == sun_pci_dma_pending.len) 	||
-	    (0	  == sun_pci_dma_pending.direction))
-		BUG();
+	    (0	  == sun_pci_dma_pending.direction));
 
 	sun_pci_dma_current.buf = sun_pci_dma_pending.buf;
 	sun_pci_dma_current.len = sun_pci_dma_pending.len;
diff -puN include/asm-sparc64/smp.h~linus include/asm-sparc64/smp.h
--- 25/include/asm-sparc64/smp.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sparc64/smp.h	2004-01-19 22:17:24.000000000 -0800
@@ -33,7 +33,7 @@
 extern unsigned char boot_cpu_id;
 
 extern cpumask_t phys_cpu_present_map;
-#define cpu_possible(cpu)	cpu_isset(cpu, phys_cpu_present_map)
+#define cpu_possible_map phys_cpu_present_map
 
 #define cpu_online(cpu)		cpu_isset(cpu, cpu_online_map)
 
diff -puN include/asm-sparc64/socket.h~linus include/asm-sparc64/socket.h
--- 25/include/asm-sparc64/socket.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sparc64/socket.h	2004-01-19 22:17:24.000000000 -0800
@@ -45,6 +45,8 @@
 #define SO_TIMESTAMP		0x001d
 #define SCM_TIMESTAMP		SO_TIMESTAMP
 
+#define SO_PEERSEC		0x001e
+
 /* Security levels - as per NRL IPv6 - don't actually do anything */
 #define SO_SECURITY_AUTHENTICATION		0x5001
 #define SO_SECURITY_ENCRYPTION_TRANSPORT	0x5002
diff -puN include/asm-sparc64/tlbflush.h~linus include/asm-sparc64/tlbflush.h
--- 25/include/asm-sparc64/tlbflush.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sparc64/tlbflush.h	2004-01-19 22:17:24.000000000 -0800
@@ -90,10 +90,9 @@ static __inline__ void flush_tlb_pgtable
 {
 	/* Note the signed type.  */
 	long s = start, e = end, vpte_base;
-	if (s > e)
 		/* Nobody should call us with start below VM hole and end above.
 		   See if it is really true.  */
-		BUG();
+	BUG_ON(s > e);
 #if 0
 	/* Currently free_pgtables guarantees this.  */
 	s &= PMD_MASK;
diff -puN include/asm-sparc/elf.h~linus include/asm-sparc/elf.h
--- 25/include/asm-sparc/elf.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sparc/elf.h	2004-01-19 22:17:24.000000000 -0800
@@ -8,8 +8,11 @@
 
 #include <linux/config.h>
 #include <asm/ptrace.h>
+
+#ifdef __KERNEL__
 #include <asm/mbus.h>
 #include <asm/uaccess.h>
+#endif
 
 /*
  * Sparc section types
diff -puN include/asm-sparc/socket.h~linus include/asm-sparc/socket.h
--- 25/include/asm-sparc/socket.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-sparc/socket.h	2004-01-19 22:17:24.000000000 -0800
@@ -45,6 +45,8 @@
 #define SO_TIMESTAMP		0x001d
 #define SCM_TIMESTAMP		SO_TIMESTAMP
 
+#define SO_PEERSEC		0x100e
+
 /* Security levels - as per NRL IPv6 - don't actually do anything */
 #define SO_SECURITY_AUTHENTICATION		0x5001
 #define SO_SECURITY_ENCRYPTION_TRANSPORT	0x5002
diff -puN include/asm-um/smp.h~linus include/asm-um/smp.h
--- 25/include/asm-um/smp.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-um/smp.h	2004-01-19 22:17:24.000000000 -0800
@@ -20,7 +20,7 @@ extern int hard_smp_processor_id(void);
 #define cpu_online(cpu) cpu_isset(cpu, cpu_online_map)
 
 extern int ncpus;
-#define cpu_possible(cpu) (cpu < ncpus)
+
 
 extern inline void smp_cpus_done(unsigned int maxcpus)
 {
diff -puN include/asm-v850/byteorder.h~linus include/asm-v850/byteorder.h
--- 25/include/asm-v850/byteorder.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-v850/byteorder.h	2004-01-19 22:17:24.000000000 -0800
@@ -15,17 +15,18 @@
 #define __V850_BYTEORDER_H__
 
 #include <asm/types.h>
+#include <linux/compiler.h>
 
 #ifdef __GNUC__
 
-static __inline__ __const__ __u32 ___arch__swab32 (__u32 word)
+static __inline__ __attribute_const__ __u32 ___arch__swab32 (__u32 word)
 {
 	__u32 res;
 	__asm__ ("bsw %1, %0" : "=r" (res) : "r" (word));
 	return res;
 }
 
-static __inline__ __const__ __u16 ___arch__swab16 (__u16 half_word)
+static __inline__ __attribute_const__ __u16 ___arch__swab16 (__u16 half_word)
 {
 	__u16 res;
 	__asm__ ("bsh %1, %0" : "=r" (res) : "r" (half_word));
diff -puN include/asm-v850/socket.h~linus include/asm-v850/socket.h
--- 25/include/asm-v850/socket.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-v850/socket.h	2004-01-19 22:17:24.000000000 -0800
@@ -45,6 +45,8 @@
 
 #define SO_ACCEPTCONN		30
 
+#define SO_PEERSEC		31
+
 /* Nast libc5 fixup - bletch */
 #if defined(__KERNEL__)
 /* Socket types. */
diff -puN include/asm-x86_64/byteorder.h~linus include/asm-x86_64/byteorder.h
--- 25/include/asm-x86_64/byteorder.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-x86_64/byteorder.h	2004-01-19 22:17:24.000000000 -0800
@@ -2,16 +2,17 @@
 #define _X86_64_BYTEORDER_H
 
 #include <asm/types.h>
+#include <linux/compiler.h>
 
 #ifdef __GNUC__
 
-static __inline__ __const__ __u64 ___arch__swab64(__u64 x)
+static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x)
 {
 	__asm__("bswapq %0" : "=r" (x) : "0" (x));
 	return x;
 }
 
-static __inline__ __const__ __u32 ___arch__swab32(__u32 x)
+static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
 {
 	__asm__("bswapl %0" : "=r" (x) : "0" (x));
 	return x;
diff -puN include/asm-x86_64/pgalloc.h~linus include/asm-x86_64/pgalloc.h
--- 25/include/asm-x86_64/pgalloc.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-x86_64/pgalloc.h	2004-01-19 22:17:24.000000000 -0800
@@ -24,8 +24,7 @@ extern __inline__ pmd_t *get_pmd(void)
 
 extern __inline__ void pmd_free(pmd_t *pmd)
 {
-	if ((unsigned long)pmd & (PAGE_SIZE-1)) 
-		BUG(); 
+	BUG_ON((unsigned long)pmd & (PAGE_SIZE-1));
 	free_page((unsigned long)pmd);
 }
 
@@ -41,8 +40,7 @@ static inline pgd_t *pgd_alloc (struct m
 
 static inline void pgd_free (pgd_t *pgd)
 {
-	if ((unsigned long)pgd & (PAGE_SIZE-1)) 
-		BUG(); 
+	BUG_ON((unsigned long)pgd & (PAGE_SIZE-1));
 	free_page((unsigned long)pgd);
 }
 
@@ -64,8 +62,7 @@ static inline struct page *pte_alloc_one
 
 extern __inline__ void pte_free_kernel(pte_t *pte)
 {
-	if ((unsigned long)pte & (PAGE_SIZE-1))
-		BUG();
+	BUG_ON((unsigned long)pte & (PAGE_SIZE-1));
 	free_page((unsigned long)pte); 
 }
 
diff -puN include/asm-x86_64/pgtable.h~linus include/asm-x86_64/pgtable.h
--- 25/include/asm-x86_64/pgtable.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-x86_64/pgtable.h	2004-01-19 22:17:24.000000000 -0800
@@ -411,4 +411,12 @@ extern int kern_addr_valid(unsigned long
 #define	kc_offset_to_vaddr(o) \
    (((o) & (1UL << (__VIRTUAL_MASK_SHIFT-1))) ? ((o) | (~__VIRTUAL_MASK)) : (o))
 
+#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
+#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
+#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
+#define __HAVE_ARCH_PTEP_SET_WRPROTECT
+#define __HAVE_ARCH_PTEP_MKDIRTY
+#define __HAVE_ARCH_PTE_SAME
+#include <asm-generic/pgtable.h>
+
 #endif /* _X86_64_PGTABLE_H */
diff -puN include/asm-x86_64/smp.h~linus include/asm-x86_64/smp.h
--- 25/include/asm-x86_64/smp.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-x86_64/smp.h	2004-01-19 22:17:24.000000000 -0800
@@ -57,8 +57,7 @@ void smp_stop_cpu(void);
  */
 
 extern cpumask_t cpu_callout_map;
-
-#define cpu_possible(cpu) cpu_isset(cpu, cpu_callout_map)
+#define cpu_possible_map cpu_callout_map
 #define cpu_online(cpu) cpu_isset(cpu, cpu_online_map)
 
 static inline int num_booting_cpus(void)
diff -puN include/asm-x86_64/socket.h~linus include/asm-x86_64/socket.h
--- 25/include/asm-x86_64/socket.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-x86_64/socket.h	2004-01-19 22:17:24.000000000 -0800
@@ -45,6 +45,8 @@
 
 #define SO_ACCEPTCONN		30
 
+#define SO_PEERSEC             31
+
 /* Nasty libc5 fixup - bletch */
 #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
 /* Socket types. */
diff -puN include/asm-x86_64/spinlock.h~linus include/asm-x86_64/spinlock.h
--- 25/include/asm-x86_64/spinlock.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/asm-x86_64/spinlock.h	2004-01-19 22:17:24.000000000 -0800
@@ -70,10 +70,8 @@ typedef struct {
 static inline void _raw_spin_unlock(spinlock_t *lock)
 {
 #ifdef CONFIG_DEBUG_SPINLOCK
-	if (lock->magic != SPINLOCK_MAGIC)
-		BUG();
-	if (!spin_is_locked(lock))
-		BUG();
+	BUG_ON(lock->magic != SPINLOCK_MAGIC);
+	BUG_ON(!spin_is_locked(lock));
 #endif
 	__asm__ __volatile__(
 		spin_unlock_string
@@ -91,10 +89,8 @@ static inline void _raw_spin_unlock(spin
 {
 	char oldval = 1;
 #ifdef CONFIG_DEBUG_SPINLOCK
-	if (lock->magic != SPINLOCK_MAGIC)
-		BUG();
-	if (!spin_is_locked(lock))
-		BUG();
+	BUG_ON(lock->magic != SPINLOCK_MAGIC);
+	BUG_ON(!spin_is_locked(lock));
 #endif
 	__asm__ __volatile__(
 		spin_unlock_string
@@ -174,8 +170,7 @@ typedef struct {
 static inline void _raw_read_lock(rwlock_t *rw)
 {
 #ifdef CONFIG_DEBUG_SPINLOCK
-	if (rw->magic != RWLOCK_MAGIC)
-		BUG();
+	BUG_ON(rw->magic != RWLOCK_MAGIC);
 #endif
 	__build_read_lock(rw, "__read_lock_failed");
 }
@@ -183,8 +178,7 @@ static inline void _raw_read_lock(rwlock
 static inline void _raw_write_lock(rwlock_t *rw)
 {
 #ifdef CONFIG_DEBUG_SPINLOCK
-	if (rw->magic != RWLOCK_MAGIC)
-		BUG();
+	BUG_ON(rw->magic != RWLOCK_MAGIC);
 #endif
 	__build_write_lock(rw, "__write_lock_failed");
 }
diff -puN include/linux/bio.h~linus include/linux/bio.h
--- 25/include/linux/bio.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/bio.h	2004-01-19 22:17:24.000000000 -0800
@@ -266,8 +266,7 @@ extern inline char *bvec_kmap_irq(struct
 	local_irq_save(*flags);
 	addr = (unsigned long) kmap_atomic(bvec->bv_page, KM_BIO_SRC_IRQ);
 
-	if (addr & ~PAGE_MASK)
-		BUG();
+	BUG_ON(addr & ~PAGE_MASK);
 
 	return (char *) addr + bvec->bv_offset;
 }
diff -puN include/linux/bitmap.h~linus include/linux/bitmap.h
--- 25/include/linux/bitmap.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/bitmap.h	2004-01-19 22:17:24.000000000 -0800
@@ -10,57 +10,11 @@
 #include <linux/bitops.h>
 #include <linux/string.h>
 
-static inline int bitmap_empty(const unsigned long *bitmap, int bits)
-{
-	int k, lim = bits/BITS_PER_LONG;
-	for (k = 0; k < lim; ++k)
-		if (bitmap[k])
-			return 0;
-
-	if (bits % BITS_PER_LONG)
-		if (bitmap[k] & ((1UL << (bits % BITS_PER_LONG)) - 1))
-			return 0;
-
-	return 1;
-}
-
-static inline int bitmap_full(const unsigned long *bitmap, int bits)
-{
-	int k, lim = bits/BITS_PER_LONG;
-	for (k = 0; k < lim; ++k)
-		if (~bitmap[k])
-			return 0;
-
-	if (bits % BITS_PER_LONG)
-		if (~bitmap[k] & ((1UL << (bits % BITS_PER_LONG)) - 1))
-			return 0;
-
-	return 1;
-}
-
-static inline int bitmap_equal(const unsigned long *bitmap1,
-				unsigned long *bitmap2, int bits)
-{
-	int k, lim = bits/BITS_PER_LONG;;
-	for (k = 0; k < lim; ++k)
-		if (bitmap1[k] != bitmap2[k])
-			return 0;
-
-	if (bits % BITS_PER_LONG)
-		if ((bitmap1[k] ^ bitmap2[k]) &
-				((1UL << (bits % BITS_PER_LONG)) - 1))
-			return 0;
-
-	return 1;
-}
-
-static inline void bitmap_complement(unsigned long *bitmap, int bits)
-{
-	int k;
-
-	for (k = 0; k < BITS_TO_LONGS(bits); ++k)
-		bitmap[k] = ~bitmap[k];
-}
+int bitmap_empty(const unsigned long *bitmap, int bits);
+int bitmap_full(const unsigned long *bitmap, int bits);
+int bitmap_equal(const unsigned long *bitmap1,
+			unsigned long *bitmap2, int bits);
+void bitmap_complement(unsigned long *bitmap, int bits);
 
 static inline void bitmap_clear(unsigned long *bitmap, int bits)
 {
@@ -78,81 +32,15 @@ static inline void bitmap_copy(unsigned 
 	memcpy(dst, src, BITS_TO_LONGS(bits)*sizeof(unsigned long));
 }
 
-static inline void bitmap_shift_right(unsigned long *dst,
-				const unsigned long *src, int shift, int bits)
-{
-	int k;
-	DECLARE_BITMAP(__shr_tmp, bits);
-
-	bitmap_clear(__shr_tmp, bits);
-	for (k = 0; k < bits - shift; ++k)
-		if (test_bit(k + shift, src))
-			set_bit(k, __shr_tmp);
-	bitmap_copy(dst, __shr_tmp, bits);
-}
-
-static inline void bitmap_shift_left(unsigned long *dst,
-				const unsigned long *src, int shift, int bits)
-{
-	int k;
-	DECLARE_BITMAP(__shl_tmp, bits);
-
-	bitmap_clear(__shl_tmp, bits);
-	for (k = bits; k >= shift; --k)
-		if (test_bit(k - shift, src))
-			set_bit(k, __shl_tmp);
-	bitmap_copy(dst, __shl_tmp, bits);
-}
-
-static inline void bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
-				const unsigned long *bitmap2, int bits)
-{
-	int k;
-	int nr = BITS_TO_LONGS(bits);
-
-	for (k = 0; k < nr; k++)
-		dst[k] = bitmap1[k] & bitmap2[k];
-}
-
-static inline void bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
-				const unsigned long *bitmap2, int bits)
-{
-	int k;
-	int nr = BITS_TO_LONGS(bits);
-
-	for (k = 0; k < nr; k++)
-		dst[k] = bitmap1[k] | bitmap2[k];
-}
-
-#if BITS_PER_LONG == 32
-static inline int bitmap_weight(const unsigned long *bitmap, int bits)
-{
-	int k, w = 0, lim = bits/BITS_PER_LONG;
-
-	for (k = 0; k < lim; k++)
-		w += hweight32(bitmap[k]);
-
-	if (bits % BITS_PER_LONG)
-		w += hweight32(bitmap[k] &
-				((1UL << (bits % BITS_PER_LONG)) - 1));
-
-	return w;
-}
-#else
-static inline int bitmap_weight(const unsigned long *bitmap, int bits)
-{
-	int k, w = 0, lim = bits/BITS_PER_LONG;
-
-	for (k = 0; k < lim; k++)
-		w += hweight64(bitmap[k]);
-
-	if (bits % BITS_PER_LONG)
-		w += hweight64(bitmap[k] &
-				((1UL << (bits % BITS_PER_LONG)) - 1));
-
-	return w;
-}
-#endif
+void bitmap_shift_right(unsigned long *dst,
+			const unsigned long *src, int shift, int bits);
+void bitmap_shift_left(unsigned long *dst,
+			const unsigned long *src, int shift, int bits);
+void bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
+			const unsigned long *bitmap2, int bits);
+void bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
+			const unsigned long *bitmap2, int bits);
+int bitmap_weight(const unsigned long *bitmap, int bits);
 
 #endif /* __ASSEMBLY__ */
 
diff -puN include/linux/blkdev.h~linus include/linux/blkdev.h
--- 25/include/linux/blkdev.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/blkdev.h	2004-01-19 22:17:24.000000000 -0800
@@ -483,9 +483,9 @@ static inline void blk_queue_bounce(requ
 }
 #endif /* CONFIG_MMU */
 
-#define rq_for_each_bio(bio, rq)	\
+#define rq_for_each_bio(_bio, rq)	\
 	if ((rq->bio))			\
-		for (bio = (rq)->bio; bio; bio = bio->bi_next)
+		for (_bio = (rq)->bio; _bio; _bio = bio->bi_next)
 
 struct sec_size {
 	unsigned block_size;
@@ -541,7 +541,7 @@ static inline void blkdev_dequeue_reques
 
 	list_del_init(&req->queuelist);
 
-	if (req->q)
+	if (req->rl)
 		elv_remove_request(req->q, req);
 }
 
diff -puN include/linux/buffer_head.h~linus include/linux/buffer_head.h
--- 25/include/linux/buffer_head.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/buffer_head.h	2004-01-19 22:17:24.000000000 -0800
@@ -125,8 +125,7 @@ BUFFER_FNS(Write_EIO,write_io_error)
 /* If we *know* page->private refers to buffer_heads */
 #define page_buffers(page)					\
 	({							\
-		if (!PagePrivate(page))				\
-			BUG();					\
+		BUG_ON(!PagePrivate(page));		\
 		((struct buffer_head *)(page)->private);	\
 	})
 #define page_has_buffers(page)	PagePrivate(page)
@@ -210,7 +209,7 @@ int nobh_truncate_page(struct address_sp
 #define OSYNC_METADATA	(1<<0)
 #define OSYNC_DATA	(1<<1)
 #define OSYNC_INODE	(1<<2)
-int generic_osync_inode(struct inode *, int);
+int generic_osync_inode(struct inode *, struct address_space *, int);
 
 
 /*
diff -puN include/linux/byteorder/swab.h~linus include/linux/byteorder/swab.h
--- 25/include/linux/byteorder/swab.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/byteorder/swab.h	2004-01-19 22:17:24.000000000 -0800
@@ -15,6 +15,8 @@
  *
  */
 
+#include <linux/compiler.h>
+
 /* casts are necessary for constants, because we never know how for sure
  * how U/UL/ULL map to __u16, __u32, __u64. At least not in a portable way.
  */
@@ -128,7 +130,7 @@
 #endif /* OPTIMIZE */
 
 
-static __inline__ __const__ __u16 __fswab16(__u16 x)
+static __inline__ __attribute_const__ __u16 __fswab16(__u16 x)
 {
 	return __arch__swab16(x);
 }
@@ -141,7 +143,7 @@ static __inline__ void __swab16s(__u16 *
 	__arch__swab16s(addr);
 }
 
-static __inline__ __const__ __u32 __fswab32(__u32 x)
+static __inline__ __attribute_const__ __u32 __fswab32(__u32 x)
 {
 	return __arch__swab32(x);
 }
@@ -155,7 +157,7 @@ static __inline__ void __swab32s(__u32 *
 }
 
 #ifdef __BYTEORDER_HAS_U64__
-static __inline__ __const__ __u64 __fswab64(__u64 x)
+static __inline__ __attribute_const__ __u64 __fswab64(__u64 x)
 {
 #  ifdef __SWAB_64_THRU_32__
 	__u32 h = x >> 32;
diff -puN include/linux/cdrom.h~linus include/linux/cdrom.h
--- 25/include/linux/cdrom.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/cdrom.h	2004-01-19 22:17:24.000000000 -0800
@@ -5,7 +5,7 @@
  *               1994, 1995   Eberhard Moenkeberg, emoenke@gwdg.de
  *               1996         David van Leeuwen, david@tm.tno.nl
  *               1997, 1998   Erik Andersen, andersee@debian.org
- *               1998-2000    Jens Axboe, axboe@suse.de
+ *               1998-2002    Jens Axboe, axboe@suse.de
  */
  
 #ifndef	_LINUX_CDROM_H
@@ -388,6 +388,9 @@ struct cdrom_generic_command
 #define CDC_DVD_R		0x10000	/* drive can write DVD-R */
 #define CDC_DVD_RAM		0x20000	/* drive can write DVD-RAM */
 #define CDC_MO_DRIVE		0x40000 /* drive is an MO device */
+#define CDC_MRW			0x80000 /* drive can read MRW */
+#define CDC_MRW_W		0x100000 /* drive can write MRW */
+#define CDC_RAM			0x200000 /* ok to open for WRITE */
 
 /* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */
 #define CDS_NO_INFO		0	/* if not implemented */
@@ -715,92 +718,57 @@ struct request_sense {
 	__u8 asb[46];
 };
 
-#ifdef __KERNEL__
-#include <linux/fs.h>		/* not really needed, later.. */
-#include <linux/device.h>
-
-struct cdrom_write_settings {
-	unsigned char fpacket;		/* fixed/variable packets */
-	unsigned long packet_size;	/* write out this number of packets */
-	unsigned long nwa;		/* next writeable address */
-	unsigned char writeable;	/* cdrom is writeable */
-};
-
-/* Uniform cdrom data structures for cdrom.c */
-struct cdrom_device_info {
-	struct cdrom_device_ops  *ops;  /* link to device_ops */
-	struct cdrom_device_info *next; /* next device_info for this major */
-	void *handle;		        /* driver-dependent data */
-/* specifications */
-	int mask;                       /* mask of capability: disables them */
-	int speed;			/* maximum speed for reading data */
-	int capacity;			/* number of discs in jukebox */
-/* device-related storage */
-	int options		: 30;	/* options flags */
-	unsigned mc_flags	: 2;	/* media change buffer flags */
-    	int use_count;                  /* number of times device opened */
-    	char name[20];                  /* name of the device type */
-/* per-device flags */
-        __u8 sanyo_slot		: 2;	/* Sanyo 3 CD changer support */
-        __u8 reserved		: 6;	/* not used yet */
-	struct cdrom_write_settings write;
-};
-
-struct cdrom_device_ops {
-/* routines */
-	int (*open) (struct cdrom_device_info *, int);
-	void (*release) (struct cdrom_device_info *);
-	int (*drive_status) (struct cdrom_device_info *, int);
-	int (*media_changed) (struct cdrom_device_info *, int);
-	int (*tray_move) (struct cdrom_device_info *, int);
-	int (*lock_door) (struct cdrom_device_info *, int);
-	int (*select_speed) (struct cdrom_device_info *, int);
-	int (*select_disc) (struct cdrom_device_info *, int);
-	int (*get_last_session) (struct cdrom_device_info *,
-				 struct cdrom_multisession *);
-	int (*get_mcn) (struct cdrom_device_info *,
-			struct cdrom_mcn *);
-	/* hard reset device */
-	int (*reset) (struct cdrom_device_info *);
-	/* play stuff */
-	int (*audio_ioctl) (struct cdrom_device_info *,unsigned int, void *);
-	/* dev-specific */
- 	int (*dev_ioctl) (struct cdrom_device_info *,
-			  unsigned int, unsigned long);
-/* driver specifications */
-	const int capability;   /* capability flags */
-	int n_minors;           /* number of active minor devices */
-	/* handle uniform packets for scsi type devices (scsi,atapi) */
-	int (*generic_packet) (struct cdrom_device_info *,
-			       struct cdrom_generic_command *);
-};
+/*
+ * feature profile
+ */
+#define CDF_MRW		0x28
 
-/* the general block_device operations structure: */
-extern int cdrom_open(struct cdrom_device_info *, struct inode *, struct file *);
-extern int cdrom_release(struct cdrom_device_info *, struct file *);
-extern int cdrom_ioctl(struct cdrom_device_info *, struct inode *, unsigned, unsigned long);
-extern int cdrom_media_changed(struct cdrom_device_info *);
+/*
+ * media status bits
+ */
+#define CDM_MRW_NOTMRW			0
+#define CDM_MRW_BGFORMAT_INACTIVE	1
+#define CDM_MRW_BGFORMAT_ACTIVE		2
+#define CDM_MRW_BGFORMAT_COMPLETE	3
 
-extern int register_cdrom(struct cdrom_device_info *cdi);
-extern int unregister_cdrom(struct cdrom_device_info *cdi);
+/*
+ * mrw address spaces
+ */
+#define MRW_LBA_DMA			0
+#define MRW_LBA_GAA			1
 
-typedef struct {
-    int data;
-    int audio;
-    int cdi;
-    int xa;
-    long error;
-} tracktype;
+/*
+ * mrw mode pages (first is deprecated) -- probed at init time and
+ * cdi->mrw_mode_page is set
+ */
+#define MRW_MODE_PC_PRE1		0x2c
+#define MRW_MODE_PC			0x03
 
-extern int cdrom_get_last_written(struct cdrom_device_info *cdi, long *last_written);
-extern int cdrom_number_of_slots(struct cdrom_device_info *cdi);
-extern int cdrom_mode_select(struct cdrom_device_info *cdi,
-			     struct cdrom_generic_command *cgc);
-extern int cdrom_mode_sense(struct cdrom_device_info *cdi,
-			    struct cdrom_generic_command *cgc,
-			    int page_code, int page_control);
-extern void init_cdrom_command(struct cdrom_generic_command *cgc,
-			       void *buffer, int len, int type);
+struct mrw_feature_desc {
+	__u16 feature_code;
+#if defined(__BIG_ENDIAN_BITFIELD)
+	__u8 reserved1		: 2;
+	__u8 feature_version	: 4;
+	__u8 persistent		: 1;
+	__u8 curr		: 1;
+#elif defined(__LITTLE_ENDIAN_BITFIELD)
+	__u8 curr		: 1;
+	__u8 persistent		: 1;
+	__u8 feature_version	: 4;
+	__u8 reserved1		: 2;
+#endif
+	__u8 add_len;
+#if defined(__BIG_ENDIAN_BITFIELD)
+	__u8 reserved2		: 7;
+	__u8 write		: 1;
+#elif defined(__LITTLE_ENDIAN_BITFIELD)
+	__u8 write		: 1;
+	__u8 reserved2		: 7;
+#endif
+	__u8 reserved3;
+	__u8 reserved4;
+	__u8 reserved5;
+};
 
 typedef struct {
 	__u16 disc_information_length;
@@ -825,9 +793,13 @@ typedef struct {
 	__u8 did_v			: 1;
         __u8 dbc_v			: 1;
         __u8 uru			: 1;
-        __u8 reserved2			: 5;
+        __u8 reserved2			: 2;
+	__u8 dbit			: 1;
+	__u8 mrw_status			: 2;
 #elif defined(__LITTLE_ENDIAN_BITFIELD)
-        __u8 reserved2			: 5;
+	__u8 mrw_status			: 2;
+	__u8 dbit			: 1;
+        __u8 reserved2			: 2;
         __u8 uru			: 1;
         __u8 dbc_v			: 1;
 	__u8 did_v			: 1;
@@ -884,6 +856,106 @@ typedef struct {
 	__u32 last_rec_address;
 } track_information;
 
+struct feature_header {
+	__u32 data_len;
+	__u8 reserved1;
+	__u8 reserved2;
+	__u16 curr_profile;
+};
+
+struct mode_page_header {
+	__u16 mode_data_length;
+	__u8 medium_type;
+	__u8 reserved1;
+	__u8 reserved2;
+	__u8 reserved3;
+	__u16 desc_length;
+};
+
+#ifdef __KERNEL__
+#include <linux/fs.h>		/* not really needed, later.. */
+#include <linux/device.h>
+
+/* Uniform cdrom data structures for cdrom.c */
+struct cdrom_device_info {
+	struct cdrom_device_ops  *ops;  /* link to device_ops */
+	struct cdrom_device_info *next; /* next device_info for this major */
+	void *handle;		        /* driver-dependent data */
+/* specifications */
+	int mask;                       /* mask of capability: disables them */
+	int speed;			/* maximum speed for reading data */
+	int capacity;			/* number of discs in jukebox */
+/* device-related storage */
+	int options		: 30;	/* options flags */
+	unsigned mc_flags	: 2;	/* media change buffer flags */
+    	int use_count;                  /* number of times device opened */
+    	char name[20];                  /* name of the device type */
+/* per-device flags */
+        __u8 sanyo_slot		: 2;	/* Sanyo 3 CD changer support */
+        __u8 reserved		: 6;	/* not used yet */
+	int for_data;
+	int (*exit)(struct cdrom_device_info *);
+	int mrw_mode_page;
+};
+
+struct cdrom_device_ops {
+/* routines */
+	int (*open) (struct cdrom_device_info *, int);
+	void (*release) (struct cdrom_device_info *);
+	int (*drive_status) (struct cdrom_device_info *, int);
+	int (*media_changed) (struct cdrom_device_info *, int);
+	int (*tray_move) (struct cdrom_device_info *, int);
+	int (*lock_door) (struct cdrom_device_info *, int);
+	int (*select_speed) (struct cdrom_device_info *, int);
+	int (*select_disc) (struct cdrom_device_info *, int);
+	int (*get_last_session) (struct cdrom_device_info *,
+				 struct cdrom_multisession *);
+	int (*get_mcn) (struct cdrom_device_info *,
+			struct cdrom_mcn *);
+	/* hard reset device */
+	int (*reset) (struct cdrom_device_info *);
+	/* play stuff */
+	int (*audio_ioctl) (struct cdrom_device_info *,unsigned int, void *);
+	/* dev-specific */
+ 	int (*dev_ioctl) (struct cdrom_device_info *,
+			  unsigned int, unsigned long);
+/* driver specifications */
+	const int capability;   /* capability flags */
+	int n_minors;           /* number of active minor devices */
+	/* handle uniform packets for scsi type devices (scsi,atapi) */
+	int (*generic_packet) (struct cdrom_device_info *,
+			       struct cdrom_generic_command *);
+};
+
+/* the general block_device operations structure: */
+extern int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip,
+			struct file *fp);
+extern int cdrom_release(struct cdrom_device_info *cdi, struct file *fp);
+extern int cdrom_ioctl(struct cdrom_device_info *cdi, struct inode *ip,
+		unsigned int cmd, unsigned long arg);
+extern int cdrom_media_changed(struct cdrom_device_info *);
+
+extern int register_cdrom(struct cdrom_device_info *cdi);
+extern int unregister_cdrom(struct cdrom_device_info *cdi);
+
+typedef struct {
+    int data;
+    int audio;
+    int cdi;
+    int xa;
+    long error;
+} tracktype;
+
+extern int cdrom_get_last_written(struct cdrom_device_info *cdi, long *last_written);
+extern int cdrom_number_of_slots(struct cdrom_device_info *cdi);
+extern int cdrom_mode_select(struct cdrom_device_info *cdi,
+			     struct cdrom_generic_command *cgc);
+extern int cdrom_mode_sense(struct cdrom_device_info *cdi,
+			    struct cdrom_generic_command *cgc,
+			    int page_code, int page_control);
+extern void init_cdrom_command(struct cdrom_generic_command *cgc,
+			       void *buffer, int len, int type);
+
 /* The SCSI spec says there could be 256 slots. */
 #define CDROM_MAX_SLOTS	256
 
@@ -934,15 +1006,6 @@ typedef enum {
 	mechtype_cartridge_changer  = 5
 } mechtype_t;
 
-struct mode_page_header {
-	__u16 mode_data_length;
-	__u8 medium_type;
-	__u8 reserved1;
-	__u8 reserved2;
-	__u8 reserved3;
-	__u16 desc_length;
-};
-
 typedef struct {
 #if defined(__BIG_ENDIAN_BITFIELD)
 	__u8 ps			: 1;
@@ -1032,6 +1095,41 @@ typedef struct {
 	__u8 reserved3;
 } rpc_state_t;
 
+struct event_header {
+	__u16 data_len;
+#if defined(__BIG_ENDIAN_BITFIELD)
+	__u8 nea		: 1;
+	__u8 reserved1		: 4;
+	__u8 notification_class	: 3;
+#elif defined(__LITTLE_ENDIAN_BITFIELD)
+	__u8 notification_class	: 3;
+	__u8 reserved1		: 4;
+	__u8 nea		: 1;
+#endif
+	__u8 supp_event_class;
+};
+
+struct media_event_desc {
+#if defined(__BIG_ENDIAN_BITFIELD)
+	__u8 reserved1		: 4;
+	__u8 media_event_code	: 4;
+	__u8 reserved2		: 6;
+	__u8 media_present	: 1;
+	__u8 door_open		: 1;
+#elif defined(__LITTLE_ENDIAN_BITFIELD)
+	__u8 media_event_code	: 4;
+	__u8 reserved1		: 4;
+	__u8 door_open		: 1;
+	__u8 media_present	: 1;
+	__u8 reserved2		: 6;
+#endif
+	__u8 start_slot;
+	__u8 end_slot;
+};
+
+extern int cdrom_get_media_event(struct cdrom_device_info *cdi, struct media_event_desc *med);
+extern int cdrom_is_mrw(struct cdrom_device_info *cdi, int *write);
+
 #endif  /* End of kernel only stuff */ 
 
 #endif  /* _LINUX_CDROM_H */
diff -puN include/linux/compat.h~linus include/linux/compat.h
--- 25/include/linux/compat.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/compat.h	2004-01-19 22:17:24.000000000 -0800
@@ -83,5 +83,10 @@ struct compat_dirent {
 	char		d_name[256];
 };
 
+typedef union compat_sigval {
+	compat_int_t	sival_int;
+	compat_uptr_t	sival_ptr;
+} compat_sigval_t;
+
 #endif /* CONFIG_COMPAT */
 #endif /* _LINUX_COMPAT_H */
diff -puN include/linux/compat_ioctl.h~linus include/linux/compat_ioctl.h
--- 25/include/linux/compat_ioctl.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/compat_ioctl.h	2004-01-19 22:17:24.000000000 -0800
@@ -2,6 +2,14 @@
  * compatible types passed or none at all... Please include
  * only stuff that is compatible on *all architectures*.
  */
+#ifndef COMPATIBLE_IOCTL /* pointer to compatible structure or no argument */
+#define COMPATIBLE_IOCTL(cmd)  HANDLE_IOCTL((cmd),(ioctl_trans_handler_t)sys_ioctl)
+#endif
+
+#ifndef ULONG_IOCTL /* argument is an unsigned long integer, not a pointer */
+#define ULONG_IOCTL(cmd)  HANDLE_IOCTL((cmd),(ioctl_trans_handler_t)sys_ioctl)
+#endif
+
 /* Big T */
 COMPATIBLE_IOCTL(TCGETA)
 COMPATIBLE_IOCTL(TCSETA)
@@ -35,18 +43,16 @@ COMPATIBLE_IOCTL(TIOCSTI)
 COMPATIBLE_IOCTL(TIOCOUTQ)
 COMPATIBLE_IOCTL(TIOCSPGRP)
 COMPATIBLE_IOCTL(TIOCGPGRP)
-COMPATIBLE_IOCTL(TIOCSCTTY)
+ULONG_IOCTL(TIOCSCTTY)
 COMPATIBLE_IOCTL(TIOCGPTN)
 COMPATIBLE_IOCTL(TIOCSPTLCK)
 COMPATIBLE_IOCTL(TIOCSERGETLSR)
-#ifdef CONFIG_FB
 /* Big F */
 COMPATIBLE_IOCTL(FBIOGET_VSCREENINFO)
 COMPATIBLE_IOCTL(FBIOPUT_VSCREENINFO)
 COMPATIBLE_IOCTL(FBIOPAN_DISPLAY)
 COMPATIBLE_IOCTL(FBIOGET_CON2FBMAP)
 COMPATIBLE_IOCTL(FBIOPUT_CON2FBMAP)
-#endif
 /* Little f */
 COMPATIBLE_IOCTL(FIOCLEX)
 COMPATIBLE_IOCTL(FIONCLEX)
@@ -68,7 +74,6 @@ COMPATIBLE_IOCTL(HDIO_SET_MULTCOUNT)
 COMPATIBLE_IOCTL(HDIO_DRIVE_CMD)
 COMPATIBLE_IOCTL(HDIO_SET_PIO_MODE)
 COMPATIBLE_IOCTL(HDIO_SET_NICE)
-#ifdef CONFIG_BLK_DEV_FD
 /* 0x02 -- Floppy ioctls */
 COMPATIBLE_IOCTL(FDMSGON)
 COMPATIBLE_IOCTL(FDMSGOFF)
@@ -86,7 +91,6 @@ COMPATIBLE_IOCTL(FDRESET)
 COMPATIBLE_IOCTL(FDTWADDLE)
 COMPATIBLE_IOCTL(FDFMTTRK)
 COMPATIBLE_IOCTL(FDRAWCMD)
-#endif
 /* 0x12 */
 COMPATIBLE_IOCTL(BLKROSET)
 COMPATIBLE_IOCTL(BLKROGET)
@@ -94,8 +98,8 @@ COMPATIBLE_IOCTL(BLKRRPART)
 COMPATIBLE_IOCTL(BLKFLSBUF)
 COMPATIBLE_IOCTL(BLKSECTSET)
 COMPATIBLE_IOCTL(BLKSSZGET)
-COMPATIBLE_IOCTL(BLKRASET)
-COMPATIBLE_IOCTL(BLKFRASET)
+ULONG_IOCTL(BLKRASET)
+ULONG_IOCTL(BLKFRASET)
 /* RAID */
 COMPATIBLE_IOCTL(RAID_VERSION)
 COMPATIBLE_IOCTL(GET_ARRAY_INFO)
@@ -104,20 +108,19 @@ COMPATIBLE_IOCTL(PRINT_RAID_DEBUG)
 COMPATIBLE_IOCTL(RAID_AUTORUN)
 COMPATIBLE_IOCTL(CLEAR_ARRAY)
 COMPATIBLE_IOCTL(ADD_NEW_DISK)
-COMPATIBLE_IOCTL(HOT_REMOVE_DISK)
+ULONG_IOCTL(HOT_REMOVE_DISK)
 COMPATIBLE_IOCTL(SET_ARRAY_INFO)
 COMPATIBLE_IOCTL(SET_DISK_INFO)
 COMPATIBLE_IOCTL(WRITE_RAID_INFO)
 COMPATIBLE_IOCTL(UNPROTECT_ARRAY)
 COMPATIBLE_IOCTL(PROTECT_ARRAY)
-COMPATIBLE_IOCTL(HOT_ADD_DISK)
-COMPATIBLE_IOCTL(SET_DISK_FAULTY)
+ULONG_IOCTL(HOT_ADD_DISK)
+ULONG_IOCTL(SET_DISK_FAULTY)
 COMPATIBLE_IOCTL(RUN_ARRAY)
-COMPATIBLE_IOCTL(START_ARRAY)
+ULONG_IOCTL(START_ARRAY)
 COMPATIBLE_IOCTL(STOP_ARRAY)
 COMPATIBLE_IOCTL(STOP_ARRAY_RO)
 COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
-#ifdef CONFIG_BLK_DEV_DM
 /* DM */
 #ifdef CONFIG_DM_IOCTL_V4
 COMPATIBLE_IOCTL(DM_VERSION)
@@ -145,21 +148,20 @@ COMPATIBLE_IOCTL(DM_DEV_STATUS)
 COMPATIBLE_IOCTL(DM_TARGET_STATUS)
 COMPATIBLE_IOCTL(DM_TARGET_WAIT)
 #endif
-#endif
 /* Big K */
 COMPATIBLE_IOCTL(PIO_FONT)
 COMPATIBLE_IOCTL(GIO_FONT)
-COMPATIBLE_IOCTL(KDSIGACCEPT)
+ULONG_IOCTL(KDSIGACCEPT)
 COMPATIBLE_IOCTL(KDGETKEYCODE)
 COMPATIBLE_IOCTL(KDSETKEYCODE)
-COMPATIBLE_IOCTL(KIOCSOUND)
-COMPATIBLE_IOCTL(KDMKTONE)
+ULONG_IOCTL(KIOCSOUND)
+ULONG_IOCTL(KDMKTONE)
 COMPATIBLE_IOCTL(KDGKBTYPE)
-COMPATIBLE_IOCTL(KDSETMODE)
+ULONG_IOCTL(KDSETMODE)
 COMPATIBLE_IOCTL(KDGETMODE)
-COMPATIBLE_IOCTL(KDSKBMODE)
+ULONG_IOCTL(KDSKBMODE)
 COMPATIBLE_IOCTL(KDGKBMODE)
-COMPATIBLE_IOCTL(KDSKBMETA)
+ULONG_IOCTL(KDSKBMETA)
 COMPATIBLE_IOCTL(KDGKBMETA)
 COMPATIBLE_IOCTL(KDGKBENT)
 COMPATIBLE_IOCTL(KDSKBENT)
@@ -169,9 +171,9 @@ COMPATIBLE_IOCTL(KDGKBDIACR)
 COMPATIBLE_IOCTL(KDSKBDIACR)
 COMPATIBLE_IOCTL(KDKBDREP)
 COMPATIBLE_IOCTL(KDGKBLED)
-COMPATIBLE_IOCTL(KDSKBLED)
+ULONG_IOCTL(KDSKBLED)
 COMPATIBLE_IOCTL(KDGETLED)
-COMPATIBLE_IOCTL(KDSETLED)
+ULONG_IOCTL(KDSETLED)
 COMPATIBLE_IOCTL(GIO_SCRNMAP)
 COMPATIBLE_IOCTL(PIO_SCRNMAP)
 COMPATIBLE_IOCTL(GIO_UNISCRNMAP)
@@ -198,15 +200,14 @@ COMPATIBLE_IOCTL(VT_SETMODE)
 COMPATIBLE_IOCTL(VT_GETMODE)
 COMPATIBLE_IOCTL(VT_GETSTATE)
 COMPATIBLE_IOCTL(VT_OPENQRY)
-COMPATIBLE_IOCTL(VT_ACTIVATE)
-COMPATIBLE_IOCTL(VT_WAITACTIVE)
-COMPATIBLE_IOCTL(VT_RELDISP)
-COMPATIBLE_IOCTL(VT_DISALLOCATE)
+ULONG_IOCTL(VT_ACTIVATE)
+ULONG_IOCTL(VT_WAITACTIVE)
+ULONG_IOCTL(VT_RELDISP)
+ULONG_IOCTL(VT_DISALLOCATE)
 COMPATIBLE_IOCTL(VT_RESIZE)
 COMPATIBLE_IOCTL(VT_RESIZEX)
 COMPATIBLE_IOCTL(VT_LOCKSWITCH)
 COMPATIBLE_IOCTL(VT_UNLOCKSWITCH)
-#if defined(CONFIG_VIDEO_DEV) || defined(CONFIG_VIDEO_DEV_MODULE)
 /* Little v */
 /* Little v, the video4linux ioctls (conflict?) */
 COMPATIBLE_IOCTL(VIDIOCGCAP)
@@ -233,7 +234,6 @@ COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCP
 COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+5, int))
 COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+6, int))
 COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+7, int))
-#endif
 /* Little p (/dev/rtc, /dev/envctrl, etc.) */
 COMPATIBLE_IOCTL(RTC_AIE_ON)
 COMPATIBLE_IOCTL(RTC_AIE_OFF)
@@ -260,8 +260,11 @@ COMPATIBLE_IOCTL(SIOCATMARK)
 COMPATIBLE_IOCTL(SIOCSIFLINK)
 COMPATIBLE_IOCTL(SIOCSIFENCAP)
 COMPATIBLE_IOCTL(SIOCGIFENCAP)
+COMPATIBLE_IOCTL(SIOCSIFNAME)
+/* FIXME: not compatible
 COMPATIBLE_IOCTL(SIOCSIFBR)
 COMPATIBLE_IOCTL(SIOCGIFBR)
+*/
 COMPATIBLE_IOCTL(SIOCSARP)
 COMPATIBLE_IOCTL(SIOCGARP)
 COMPATIBLE_IOCTL(SIOCDARP)
@@ -279,7 +282,7 @@ COMPATIBLE_IOCTL(SIOCSIFVLAN)
 COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
 COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
 COMPATIBLE_IOCTL(SG_EMULATED_HOST)
-COMPATIBLE_IOCTL(SG_SET_TRANSFORM)
+ULONG_IOCTL(SG_SET_TRANSFORM)
 COMPATIBLE_IOCTL(SG_GET_TRANSFORM)
 COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE)
 COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE)
@@ -299,7 +302,6 @@ COMPATIBLE_IOCTL(SG_SCSI_RESET)
 COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE)
 COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN)
 COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN)
-#if defined(CONFIG_PPP) || defined(CONFIG_PPP_MODULE)
 /* PPP stuff */
 COMPATIBLE_IOCTL(PPPIOCGFLAGS)
 COMPATIBLE_IOCTL(PPPIOCSFLAGS)
@@ -333,7 +335,6 @@ COMPATIBLE_IOCTL(PPPIOCGCHAN)
 /* PPPOX */
 COMPATIBLE_IOCTL(PPPOEIOCSFWD)
 COMPATIBLE_IOCTL(PPPOEIOCDFWD)
-#endif
 /* LP */
 COMPATIBLE_IOCTL(LPGETSTATUS)
 /* CDROM stuff */
@@ -348,7 +349,7 @@ COMPATIBLE_IOCTL(CDROMSTART)
 COMPATIBLE_IOCTL(CDROMEJECT)
 COMPATIBLE_IOCTL(CDROMVOLCTRL)
 COMPATIBLE_IOCTL(CDROMSUBCHNL)
-COMPATIBLE_IOCTL(CDROMEJECT_SW)
+ULONG_IOCTL(CDROMEJECT_SW)
 COMPATIBLE_IOCTL(CDROMMULTISESSION)
 COMPATIBLE_IOCTL(CDROM_GET_MCN)
 COMPATIBLE_IOCTL(CDROMRESET)
@@ -356,16 +357,16 @@ COMPATIBLE_IOCTL(CDROMVOLREAD)
 COMPATIBLE_IOCTL(CDROMSEEK)
 COMPATIBLE_IOCTL(CDROMPLAYBLK)
 COMPATIBLE_IOCTL(CDROMCLOSETRAY)
-COMPATIBLE_IOCTL(CDROM_SET_OPTIONS)
-COMPATIBLE_IOCTL(CDROM_CLEAR_OPTIONS)
-COMPATIBLE_IOCTL(CDROM_SELECT_SPEED)
-COMPATIBLE_IOCTL(CDROM_SELECT_DISC)
-COMPATIBLE_IOCTL(CDROM_MEDIA_CHANGED)
-COMPATIBLE_IOCTL(CDROM_DRIVE_STATUS)
+ULONG_IOCTL(CDROM_SET_OPTIONS)
+ULONG_IOCTL(CDROM_CLEAR_OPTIONS)
+ULONG_IOCTL(CDROM_SELECT_SPEED)
+ULONG_IOCTL(CDROM_SELECT_DISC)
+ULONG_IOCTL(CDROM_MEDIA_CHANGED)
+ULONG_IOCTL(CDROM_DRIVE_STATUS)
 COMPATIBLE_IOCTL(CDROM_DISC_STATUS)
 COMPATIBLE_IOCTL(CDROM_CHANGER_NSLOTS)
-COMPATIBLE_IOCTL(CDROM_LOCKDOOR)
-COMPATIBLE_IOCTL(CDROM_DEBUG)
+ULONG_IOCTL(CDROM_LOCKDOOR)
+ULONG_IOCTL(CDROM_DEBUG)
 COMPATIBLE_IOCTL(CDROM_GET_CAPABILITY)
 /* Ignore cdrom.h about these next 5 ioctls, they absolutely do
  * not take a struct cdrom_read, instead they take a struct cdrom_msf
@@ -381,13 +382,12 @@ COMPATIBLE_IOCTL(DVD_READ_STRUCT)
 COMPATIBLE_IOCTL(DVD_WRITE_STRUCT)
 COMPATIBLE_IOCTL(DVD_AUTH)
 /* Big L */
-COMPATIBLE_IOCTL(LOOP_SET_FD)
+ULONG_IOCTL(LOOP_SET_FD)
 COMPATIBLE_IOCTL(LOOP_CLR_FD)
 COMPATIBLE_IOCTL(LOOP_GET_STATUS64)
 COMPATIBLE_IOCTL(LOOP_SET_STATUS64)
 /* Big A */
 /* sparc only */
-#if defined(CONFIG_SOUND) || defined (CONFIG_SOUND_MODULE)
 /* Big Q for sound/OSS */
 COMPATIBLE_IOCTL(SNDCTL_SEQ_RESET)
 COMPATIBLE_IOCTL(SNDCTL_SEQ_SYNC)
@@ -542,10 +542,9 @@ COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5)
 COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS)
 COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS)
 COMPATIBLE_IOCTL(OSS_GETVERSION)
-#endif
 /* AUTOFS */
-COMPATIBLE_IOCTL(AUTOFS_IOC_READY)
-COMPATIBLE_IOCTL(AUTOFS_IOC_FAIL)
+ULONG_IOCTL(AUTOFS_IOC_READY)
+ULONG_IOCTL(AUTOFS_IOC_FAIL)
 COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC)
 COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER)
 COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE)
@@ -572,7 +571,6 @@ COMPATIBLE_IOCTL(NCP_IOC_GETCHARSETS)
 COMPATIBLE_IOCTL(NCP_IOC_SETCHARSETS)
 COMPATIBLE_IOCTL(NCP_IOC_GETDENTRYTTL)
 COMPATIBLE_IOCTL(NCP_IOC_SETDENTRYTTL)
-#if defined(CONFIG_ATM) || defined(CONFIG_ATM_MODULE)
 /* Little a */
 COMPATIBLE_IOCTL(ATMSIGD_CTRL)
 COMPATIBLE_IOCTL(ATMARPD_CTRL)
@@ -589,7 +587,6 @@ COMPATIBLE_IOCTL(ATMTCP_CREATE)
 COMPATIBLE_IOCTL(ATMTCP_REMOVE)
 COMPATIBLE_IOCTL(ATMMPC_CTRL)
 COMPATIBLE_IOCTL(ATMMPC_DATA)
-#endif
 /* Big W */
 /* WIOC_GETSUPPORT not yet implemented -E */
 COMPATIBLE_IOCTL(WDIOC_GETSTATUS)
@@ -604,7 +601,6 @@ COMPATIBLE_IOCTL(RNDGETPOOL)
 COMPATIBLE_IOCTL(RNDADDENTROPY)
 COMPATIBLE_IOCTL(RNDZAPENTCNT)
 COMPATIBLE_IOCTL(RNDCLEARPOOL)
-#if defined(CONFIG_BT) || defined(CONFIG_BT_MODULE)
 /* Bluetooth ioctls */
 COMPATIBLE_IOCTL(HCIDEVUP)
 COMPATIBLE_IOCTL(HCIDEVDOWN)
@@ -635,8 +631,6 @@ COMPATIBLE_IOCTL(BNEPCONNADD)
 COMPATIBLE_IOCTL(BNEPCONNDEL)
 COMPATIBLE_IOCTL(BNEPGETCONNLIST)
 COMPATIBLE_IOCTL(BNEPGETCONNINFO)
-#endif
-#ifdef CONFIG_PCI
 /* Misc. */
 COMPATIBLE_IOCTL(0x41545900)		/* ATYIO_CLKR */
 COMPATIBLE_IOCTL(0x41545901)		/* ATYIO_CLKW */
@@ -644,8 +638,6 @@ COMPATIBLE_IOCTL(PCIIOC_CONTROLLER)
 COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO)
 COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM)
 COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE)
-#endif
-#if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE)
 /* USB */
 COMPATIBLE_IOCTL(USBDEVFS_RESETEP)
 COMPATIBLE_IOCTL(USBDEVFS_SETINTERFACE)
@@ -658,8 +650,6 @@ COMPATIBLE_IOCTL(USBDEVFS_CONNECTINFO)
 COMPATIBLE_IOCTL(USBDEVFS_HUB_PORTINFO)
 COMPATIBLE_IOCTL(USBDEVFS_RESET)
 COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT)
-#endif
-#if defined(CONFIG_MTD) || defined(CONFIG_MTD_MODULE)
 /* MTD */
 COMPATIBLE_IOCTL(MEMGETINFO)
 COMPATIBLE_IOCTL(MEMERASE)
@@ -667,16 +657,15 @@ COMPATIBLE_IOCTL(MEMLOCK)
 COMPATIBLE_IOCTL(MEMUNLOCK)
 COMPATIBLE_IOCTL(MEMGETREGIONCOUNT)
 COMPATIBLE_IOCTL(MEMGETREGIONINFO)
-#endif
 /* NBD */
-COMPATIBLE_IOCTL(NBD_SET_SOCK)
-COMPATIBLE_IOCTL(NBD_SET_BLKSIZE)
-COMPATIBLE_IOCTL(NBD_SET_SIZE)
+ULONG_IOCTL(NBD_SET_SOCK)
+ULONG_IOCTL(NBD_SET_BLKSIZE)
+ULONG_IOCTL(NBD_SET_SIZE)
 COMPATIBLE_IOCTL(NBD_DO_IT)
 COMPATIBLE_IOCTL(NBD_CLEAR_SOCK)
 COMPATIBLE_IOCTL(NBD_CLEAR_QUE)
 COMPATIBLE_IOCTL(NBD_PRINT_DEBUG)
-COMPATIBLE_IOCTL(NBD_SET_SIZE_BLOCKS)
+ULONG_IOCTL(NBD_SET_SIZE_BLOCKS)
 COMPATIBLE_IOCTL(NBD_DISCONNECT)
 /* i2c */
 COMPATIBLE_IOCTL(I2C_SLAVE)
@@ -685,3 +674,34 @@ COMPATIBLE_IOCTL(I2C_TENBIT)
 COMPATIBLE_IOCTL(I2C_PEC)
 COMPATIBLE_IOCTL(I2C_RETRIES)
 COMPATIBLE_IOCTL(I2C_TIMEOUT)
+/* wireless */
+COMPATIBLE_IOCTL(SIOCSIWCOMMIT)
+COMPATIBLE_IOCTL(SIOCGIWNAME)
+COMPATIBLE_IOCTL(SIOCSIWNWID)
+COMPATIBLE_IOCTL(SIOCGIWNWID)
+COMPATIBLE_IOCTL(SIOCSIWFREQ)
+COMPATIBLE_IOCTL(SIOCGIWFREQ)
+COMPATIBLE_IOCTL(SIOCSIWMODE)
+COMPATIBLE_IOCTL(SIOCGIWMODE)
+COMPATIBLE_IOCTL(SIOCSIWSENS)
+COMPATIBLE_IOCTL(SIOCGIWSENS)
+COMPATIBLE_IOCTL(SIOCSIWRANGE)
+COMPATIBLE_IOCTL(SIOCSIWPRIV)
+COMPATIBLE_IOCTL(SIOCGIWPRIV)
+COMPATIBLE_IOCTL(SIOCSIWSTATS)
+COMPATIBLE_IOCTL(SIOCGIWSTATS)
+COMPATIBLE_IOCTL(SIOCSIWAP)
+COMPATIBLE_IOCTL(SIOCGIWAP)
+COMPATIBLE_IOCTL(SIOCSIWSCAN)
+COMPATIBLE_IOCTL(SIOCSIWRATE)
+COMPATIBLE_IOCTL(SIOCGIWRATE)
+COMPATIBLE_IOCTL(SIOCSIWRTS)
+COMPATIBLE_IOCTL(SIOCGIWRTS)
+COMPATIBLE_IOCTL(SIOCSIWFRAG)
+COMPATIBLE_IOCTL(SIOCGIWFRAG)
+COMPATIBLE_IOCTL(SIOCSIWTXPOW)
+COMPATIBLE_IOCTL(SIOCGIWTXPOW)
+COMPATIBLE_IOCTL(SIOCSIWRETRY)
+COMPATIBLE_IOCTL(SIOCGIWRETRY)
+COMPATIBLE_IOCTL(SIOCSIWPOWER)
+COMPATIBLE_IOCTL(SIOCGIWPOWER)
diff -puN include/linux/compiler-gcc2.h~linus include/linux/compiler-gcc2.h
--- 25/include/linux/compiler-gcc2.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/compiler-gcc2.h	2004-01-19 22:17:24.000000000 -0800
@@ -20,4 +20,5 @@
  */
 #if __GNUC_MINOR__ >= 96
 # define __attribute_pure__	__attribute__((pure))
+# define __attribute_const__	__attribute__((__const__))
 #endif
diff -puN include/linux/compiler-gcc3.h~linus include/linux/compiler-gcc3.h
--- 25/include/linux/compiler-gcc3.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/compiler-gcc3.h	2004-01-19 22:17:24.000000000 -0800
@@ -20,3 +20,4 @@
 #endif
 
 #define __attribute_pure__	__attribute__((pure))
+#define __attribute_const__	__attribute__((__const__))
diff -puN include/linux/compiler-gcc+.h~linus include/linux/compiler-gcc+.h
--- 25/include/linux/compiler-gcc+.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/compiler-gcc+.h	2004-01-19 22:17:24.000000000 -0800
@@ -12,3 +12,4 @@
 #define __deprecated		__attribute__((deprecated))
 #define __attribute_used__	__attribute__((__used__))
 #define __attribute_pure__	__attribute__((pure))
+#define __attribute_const__	__attribute__((__const__))
diff -puN include/linux/compiler.h~linus include/linux/compiler.h
--- 25/include/linux/compiler.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/compiler.h	2004-01-19 22:17:24.000000000 -0800
@@ -76,6 +76,24 @@
 # define __attribute_pure__	/* unimplemented */
 #endif
 
+/*
+ * From the GCC manual:
+ *
+ * Many functions do not examine any values except their arguments,
+ * and have no effects except the return value.  Basically this is
+ * just slightly more strict class than the `pure' attribute above,
+ * since function is not allowed to read global memory.
+ *
+ * Note that a function that has pointer arguments and examines the
+ * data pointed to must _not_ be declared `const'.  Likewise, a
+ * function that calls a non-`const' function usually must not be
+ * `const'.  It does not make sense for a `const' function to return
+ * `void'.
+ */
+#ifndef __attribute_const__
+# define __attribute_const__	/* unimplemented */
+#endif
+
 /* Optimization barrier */
 #ifndef barrier
 # define barrier() __memory_barrier()
diff -puN include/linux/cpumask.h~linus include/linux/cpumask.h
--- 25/include/linux/cpumask.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/cpumask.h	2004-01-19 22:17:24.000000000 -0800
@@ -8,32 +8,28 @@
 #ifdef CONFIG_SMP
 
 extern cpumask_t cpu_online_map;
+extern cpumask_t cpu_possible_map;
 
 #define num_online_cpus()		cpus_weight(cpu_online_map)
 #define cpu_online(cpu)			cpu_isset(cpu, cpu_online_map)
+#define cpu_possible(cpu)		cpu_isset(cpu, cpu_possible_map)
+
+#define for_each_cpu_mask(cpu, mask)					\
+	for (cpu = first_cpu_const(mk_cpumask_const(mask));		\
+		cpu < NR_CPUS;						\
+		cpu = next_cpu_const(cpu, mk_cpumask_const(mask)))
+
+#define for_each_cpu(cpu) for_each_cpu_mask(cpu, cpu_possible_map)
+#define for_each_online_cpu(cpu) for_each_cpu_mask(cpu, cpu_online_map)
 #else
 #define	cpu_online_map			cpumask_of_cpu(0)
 #define num_online_cpus()		1
 #define cpu_online(cpu)			({ BUG_ON((cpu) != 0); 1; })
-#endif
-
-static inline int next_online_cpu(int cpu, cpumask_t map)
-{
-	do
-		cpu = next_cpu_const(cpu, mk_cpumask_const(map));
-	while (cpu < NR_CPUS && !cpu_online(cpu));
-	return cpu;
-}
+#define cpu_possible(cpu)		({ BUG_ON((cpu) != 0); 1; })
 
-#define for_each_cpu(cpu, map)						\
-	for (cpu = first_cpu_const(mk_cpumask_const(map));		\
-		cpu < NR_CPUS;						\
-		cpu = next_cpu_const(cpu,mk_cpumask_const(map)))
-
-#define for_each_online_cpu(cpu, map)					\
-	for (cpu = first_cpu_const(mk_cpumask_const(map));		\
-		cpu < NR_CPUS;						\
-		cpu = next_online_cpu(cpu,map))
+#define for_each_cpu(cpu) for (cpu = 0; cpu < 1; cpu++)
+#define for_each_online_cpu(cpu) for (cpu = 0; cpu < 1; cpu++)
+#endif
 
 extern int __mask_snprintf_len(char *buf, unsigned int buflen,
 		const unsigned long *maskp, unsigned int maskbytes);
diff -puN include/linux/dcache.h~linus include/linux/dcache.h
--- 25/include/linux/dcache.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/dcache.h	2004-01-19 22:17:24.000000000 -0800
@@ -270,8 +270,7 @@ extern char * d_path(struct dentry *, st
 static inline struct dentry *dget(struct dentry *dentry)
 {
 	if (dentry) {
-		if (!atomic_read(&dentry->d_count))
-			BUG();
+		BUG_ON(!atomic_read(&dentry->d_count));
 		atomic_inc(&dentry->d_count);
 	}
 	return dentry;
diff -puN include/linux/device.h~linus include/linux/device.h
--- 25/include/linux/device.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/device.h	2004-01-19 22:17:24.000000000 -0800
@@ -46,6 +46,7 @@ struct device;
 struct device_driver;
 struct class;
 struct class_device;
+struct class_simple;
 
 struct bus_type {
 	char			* name;
@@ -155,6 +156,7 @@ struct class {
 			   int num_envp, char *buffer, int buffer_size);
 
 	void	(*release)(struct class_device *dev);
+	void	(*class_release)(struct class *class);
 };
 
 extern int class_register(struct class *);
@@ -246,6 +248,13 @@ struct class_interface {
 extern int class_interface_register(struct class_interface *);
 extern void class_interface_unregister(struct class_interface *);
 
+/* interface for class simple stuff */
+extern struct class_simple *class_simple_create(struct module *owner, char *name);
+extern void class_simple_destroy(struct class_simple *cs);
+extern struct class_device *class_simple_device_add(struct class_simple *cs, dev_t dev, struct device *device, const char *fmt, ...)
+	__attribute__((format(printf,4,5)));
+extern void class_simple_device_remove(dev_t dev);
+
 
 struct device {
 	struct list_head node;		/* node in sibling list */
@@ -354,6 +363,7 @@ extern int (*platform_notify_remove)(str
  */
 extern struct device * get_device(struct device * dev);
 extern void put_device(struct device * dev);
+extern struct device *device_find(const char *name, struct bus_type *bus);
 
 
 /* drivers/base/platform.c */
diff -puN include/linux/efi.h~linus include/linux/efi.h
--- 25/include/linux/efi.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/efi.h	2004-01-19 22:17:24.000000000 -0800
@@ -297,14 +297,22 @@ extern u64 efi_mem_attributes (unsigned 
 extern void efi_initialize_iomem_resources(struct resource *code_resource,
 					struct resource *data_resource);
 extern efi_status_t phys_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc);
-extern unsigned long inline __init efi_get_time(void);
-extern int inline __init efi_set_rtc_mmss(unsigned long nowtime);
+extern inline unsigned long __init efi_get_time(void);
+extern inline int __init efi_set_rtc_mmss(unsigned long nowtime);
 extern struct efi_memory_map memmap;
 
+/*
+ * We play games with efi_enabled so that the compiler will, if possible, remove
+ * EFI-related code altogether.
+ */
 #ifdef CONFIG_EFI
-extern int efi_enabled;
+# ifdef CONFIG_X86
+   extern int efi_enabled;
+# else
+#  define efi_enabled 1
+# endif
 #else
-#define efi_enabled 0
+# define efi_enabled 0
 #endif
 
 /*
diff -puN include/linux/ext2_fs_sb.h~linus include/linux/ext2_fs_sb.h
--- 25/include/linux/ext2_fs_sb.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/ext2_fs_sb.h	2004-01-19 22:17:24.000000000 -0800
@@ -45,6 +45,7 @@ struct ext2_sb_info {
 	int s_desc_per_block_bits;
 	int s_inode_size;
 	int s_first_ino;
+	spinlock_t s_next_gen_lock;
 	u32 s_next_generation;
 	unsigned long s_dir_count;
 	u8 *s_debts;
diff -puN include/linux/ext3_fs_sb.h~linus include/linux/ext3_fs_sb.h
--- 25/include/linux/ext3_fs_sb.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/ext3_fs_sb.h	2004-01-19 22:17:24.000000000 -0800
@@ -49,6 +49,7 @@ struct ext3_sb_info {
 	int s_desc_per_block_bits;
 	int s_inode_size;
 	int s_first_ino;
+	spinlock_t s_next_gen_lock;
 	u32 s_next_generation;
 	u32 s_hash_seed[4];
 	int s_def_hash_version;
diff -puN include/linux/ext3_jbd.h~linus include/linux/ext3_jbd.h
--- 25/include/linux/ext3_jbd.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/ext3_jbd.h	2004-01-19 22:17:24.000000000 -0800
@@ -221,13 +221,24 @@ static inline int ext3_should_journal_da
 
 static inline int ext3_should_order_data(struct inode *inode)
 {
-	return (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA);
+	if (!S_ISREG(inode->i_mode))
+		return 0;
+	if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL)
+		return 0;
+	if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA)
+		return 1;
+	return 0;
 }
 
 static inline int ext3_should_writeback_data(struct inode *inode)
 {
-	return !ext3_should_journal_data(inode) &&
-			!ext3_should_order_data(inode);
+	if (!S_ISREG(inode->i_mode))
+		return 0;
+	if (EXT3_I(inode)->i_flags & EXT3_JOURNAL_DATA_FL)
+		return 0;
+	if (test_opt(inode->i_sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA)
+		return 1;
+	return 0;
 }
 
 #endif	/* _LINUX_EXT3_JBD_H */
diff -puN include/linux/fs.h~linus include/linux/fs.h
--- 25/include/linux/fs.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/fs.h	2004-01-19 22:17:24.000000000 -0800
@@ -353,6 +353,13 @@ struct block_device {
 	int			bd_invalidated;
 	struct gendisk *	bd_disk;
 	struct list_head	bd_list;
+	/*
+	 * Private data.  You must have bd_claim'ed the block_device
+	 * to use this.  NOTE:  bd_claim allows an owner to claim
+	 * the same device multiple times, the owner must take special
+	 * care to not mess up bd_private for that case.
+	 */
+	unsigned long		bd_private;
 };
 
 /*
@@ -480,6 +487,8 @@ static inline unsigned imajor(struct ino
 	return MAJOR(inode->i_rdev);
 }
 
+extern struct block_device *I_BDEV(struct inode *inode);
+
 struct fown_struct {
 	rwlock_t lock;          /* protects pid, uid, euid fields */
 	int pid;		/* pid or -pgrp where SIGIO should be sent */
@@ -523,9 +532,12 @@ struct file {
 	/* needed for tty driver, and maybe others */
 	void			*private_data;
 
+#ifdef CONFIG_EPOLL
 	/* Used by fs/eventpoll.c to link all the hooks to this file */
 	struct list_head	f_ep_links;
 	spinlock_t		f_ep_lock;
+#endif /* #ifdef CONFIG_EPOLL */
+	struct address_space	*f_mapping;
 };
 extern spinlock_t files_lock;
 #define file_list_lock() spin_lock(&files_lock);
@@ -1124,11 +1136,9 @@ enum {BDEV_FILE, BDEV_SWAP, BDEV_FS, BDE
 extern int register_blkdev(unsigned int, const char *);
 extern int unregister_blkdev(unsigned int, const char *);
 extern struct block_device *bdget(dev_t);
-extern int bd_acquire(struct inode *inode);
 extern void bd_forget(struct inode *inode);
 extern void bdput(struct block_device *);
 extern int blkdev_open(struct inode *, struct file *);
-extern int blkdev_close(struct inode *, struct file *);
 extern struct block_device *open_by_devnum(dev_t, unsigned, int);
 extern struct file_operations def_blk_fops;
 extern struct address_space_operations def_blk_aops;
@@ -1296,8 +1306,7 @@ extern int generic_file_readonly_mmap(st
 extern int file_read_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size);
 extern int file_send_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size);
 extern ssize_t generic_file_read(struct file *, char __user *, size_t, loff_t *);
-int generic_write_checks(struct inode *inode, struct file *file,
-			loff_t *pos, size_t *count, int isblk);
+int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk);
 extern ssize_t generic_file_write(struct file *, const char __user *, size_t, loff_t *);
 extern ssize_t generic_file_aio_read(struct kiocb *, char __user *, size_t, loff_t);
 extern ssize_t __generic_file_aio_read(struct kiocb *, const struct iovec *, unsigned long, loff_t *);
@@ -1331,7 +1340,7 @@ static inline void do_generic_file_read(
 					read_descriptor_t * desc,
 					read_actor_t actor)
 {
-	do_generic_mapping_read(filp->f_dentry->d_inode->i_mapping,
+	do_generic_mapping_read(filp->f_mapping,
 				&filp->f_ra,
 				filp,
 				ppos,
diff -puN include/linux/genhd.h~linus include/linux/genhd.h
--- 25/include/linux/genhd.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/genhd.h	2004-01-19 22:17:24.000000000 -0800
@@ -82,7 +82,7 @@ struct gendisk {
 	int major;			/* major number of driver */
 	int first_minor;
 	int minors;
-	char disk_name[16];		/* name of major driver */
+	char disk_name[32];		/* name of major driver */
 	struct hd_struct **part;	/* [indexed by minor] */
 	struct block_device_operations *fops;
 	struct request_queue *queue;
diff -puN include/linux/highmem.h~linus include/linux/highmem.h
--- 25/include/linux/highmem.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/highmem.h	2004-01-19 22:17:24.000000000 -0800
@@ -56,8 +56,7 @@ static inline void memclear_highpage_flu
 {
 	void *kaddr;
 
-	if (offset + size > PAGE_SIZE)
-		BUG();
+	BUG_ON(offset + size > PAGE_SIZE);
 
 	kaddr = kmap_atomic(page, KM_USER0);
 	memset((char *)kaddr + offset, 0, size);
diff -puN include/linux/i2c-id.h~linus include/linux/i2c-id.h
--- 25/include/linux/i2c-id.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/i2c-id.h	2004-01-19 22:17:24.000000000 -0800
@@ -154,6 +154,9 @@
 #define I2C_DRIVERID_W83627HF 1038
 #define I2C_DRIVERID_LM85 1039
 #define I2C_DRIVERID_LM83 1040
+#define I2C_DRIVERID_LM90 1042
+#define I2C_DRIVERID_ASB100 1043
+#define I2C_DRIVERID_W83L785TS 1047
 
 /*
  * ---- Adapter types ----------------------------------------------------
diff -puN include/linux/ide.h~linus include/linux/ide.h
--- 25/include/linux/ide.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/ide.h	2004-01-19 22:17:24.000000000 -0800
@@ -1513,64 +1513,6 @@ int ide_taskfile_ioctl(ide_drive_t *, un
 int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long);
 int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long);
 
-#if 0
-
-#define IDEFLOPPY_PC_BUFFER_SIZE        256
-#define IDETAPE_PC_BUFFER_SIZE          256
-#define IDE_PC_BUFFER_SIZE          256
-
-typedef struct ide_packet_command_s {
-		/* Actual packet bytes */
-	u8 c[12];
-		/* On each retry, we increment retries */
-	int retries;
-		/* Error code */
-	int error;
-		/* Bytes to transfer */
-	int request_transfer;
-		/* Bytes actually transferred */
-	int actually_transferred;
-		/* Size of our data buffer */
-	int buffer_size;
-
-	struct buffer_head *bh;
-	u8 *b_data;
-		/* The corresponding request */
-	struct request *rq;
-# if 0
-		/* Scatter gather table */
-	struct scatterlist *sg;
-# endif
-	int b_count;
-		/* Data buffer */
-	u8 *buffer;
-		/* Pointer into the above buffer */
-	u8 *current_position;
-		/* Called when this packet command is completed */
-	ide_startstop_t (*callback) (ide_drive_t *);
-		/* Temporary buffer */
-	u8 pc_buffer[IDE_PC_BUFFER_SIZE];
-		/* Status/Action bit flags: long for set_bit */
-	unsigned long flags;
-} ide_pc_t;
-
-ide-cd orthoginal :-/
-struct packet_command {
-        char *buffer;
-        int buflen;
-        int stat;
-        int quiet;
-        int timeout;
-        struct request_sense *sense;
-        unsigned char c[12];
-};
-
-#endif
-
-#ifdef CONFIG_PKT_TASK_IOCTL
-extern int pkt_taskfile_ioctl(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long);
-#endif /* CONFIG_PKT_TASK_IOCTL */
-
 extern void ide_delay_50ms(void);
 extern int system_bus_clock(void);
 
diff -puN include/linux/input.h~linus include/linux/input.h
--- 25/include/linux/input.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/input.h	2004-01-19 22:17:24.000000000 -0800
@@ -809,6 +809,7 @@ struct input_dev {
 	int (*erase_effect)(struct input_dev *dev, int effect_id);
 
 	struct input_handle *grab;
+	struct device *dev;
 
 	struct list_head	h_list;
 	struct list_head	node;
@@ -921,7 +922,7 @@ void input_event(struct input_dev *dev, 
 #define input_regs(a,b)		do { (a)->regs = (b); } while (0)
 #define input_sync(a)		do { input_event(a, EV_SYN, SYN_REPORT, 0); (a)->regs = NULL; } while (0)
 
-extern struct class input_class;
+extern struct class_simple *input_class;
 
 #endif
 #endif
diff -puN include/linux/ipv6.h~linus include/linux/ipv6.h
--- 25/include/linux/ipv6.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/ipv6.h	2004-01-19 22:17:24.000000000 -0800
@@ -143,6 +143,7 @@ struct ipv6_devconf {
 	__s32		regen_max_retry;
 	__s32		max_desync_factor;
 #endif
+	__s32		max_addresses;
 	void		*sysctl;
 };
 
@@ -158,13 +159,12 @@ enum {
 	DEVCONF_RTR_SOLICITS,
 	DEVCONF_RTR_SOLICIT_INTERVAL,
 	DEVCONF_RTR_SOLICIT_DELAY,
-#ifdef CONFIG_IPV6_PRIVACY
 	DEVCONF_USE_TEMPADDR,
 	DEVCONF_TEMP_VALID_LFT,
 	DEVCONF_TEMP_PREFERED_LFT,
 	DEVCONF_REGEN_MAX_RETRY,
 	DEVCONF_MAX_DESYNC_FACTOR,
-#endif
+	DEVCONF_MAX_ADDRESSES,
 	DEVCONF_MAX
 };
 
diff -puN include/linux/kernel.h~linus include/linux/kernel.h
--- 25/include/linux/kernel.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/kernel.h	2004-01-19 22:17:24.000000000 -0800
@@ -89,6 +89,8 @@ asmlinkage int printk(const char * fmt, 
 
 unsigned long int_sqrt(unsigned long);
 
+extern int printk_ratelimit(void);
+
 static inline void console_silent(void)
 {
 	console_loglevel = 0;
diff -puN include/linux/kobject.h~linus include/linux/kobject.h
--- 25/include/linux/kobject.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/kobject.h	2004-01-19 22:17:24.000000000 -0800
@@ -56,6 +56,7 @@ extern void kobject_unregister(struct ko
 extern struct kobject * kobject_get(struct kobject *);
 extern void kobject_put(struct kobject *);
 
+extern void kobject_hotplug(const char *action, struct kobject *);
 
 struct kobj_type {
 	void (*release)(struct kobject *);
diff -puN include/linux/miscdevice.h~linus include/linux/miscdevice.h
--- 25/include/linux/miscdevice.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/miscdevice.h	2004-01-19 22:17:24.000000000 -0800
@@ -36,12 +36,15 @@
 
 #define TUN_MINOR	     200
 
+struct device;
+
 struct miscdevice 
 {
 	int minor;
 	const char *name;
 	struct file_operations *fops;
 	struct list_head list;
+	struct device *dev;
 	char devfs_name[64];
 };
 
diff -puN include/linux/mm.h~linus include/linux/mm.h
--- 25/include/linux/mm.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/mm.h	2004-01-19 22:17:24.000000000 -0800
@@ -223,7 +223,6 @@ struct page {
 		atomic_dec_and_test(&(p)->count);	\
 	})
 
-#define page_count(p)		atomic_read(&(p)->count)
 #define set_page_count(p,v) 	atomic_set(&(p)->count, v)
 #define __put_page(p)		atomic_dec(&(p)->count)
 
@@ -231,6 +230,13 @@ extern void FASTCALL(__page_cache_releas
 
 #ifdef CONFIG_HUGETLB_PAGE
 
+static inline int page_count(struct page *p)
+{
+	if (PageCompound(p))
+		p = (struct page *)p->lru.next;
+	return atomic_read(&(p)->count);
+}
+
 static inline void get_page(struct page *page)
 {
 	if (PageCompound(page))
@@ -257,6 +263,8 @@ static inline void put_page(struct page 
 
 #else		/* CONFIG_HUGETLB_PAGE */
 
+#define page_count(p)		atomic_read(&(p)->count)
+
 static inline void get_page(struct page *page)
 {
 	atomic_inc(&page->count);
@@ -322,23 +330,33 @@ static inline void put_page(struct page 
 /*
  * The zone field is never updated after free_area_init_core()
  * sets it, so none of the operations on it need to be atomic.
- * We'll have up to log2(MAX_NUMNODES * MAX_NR_ZONES) zones
- * total, so we use NODES_SHIFT here to get enough bits.
+ * We'll have up to (MAX_NUMNODES * MAX_NR_ZONES) zones total,
+ * so we use (MAX_NODES_SHIFT + MAX_ZONES_SHIFT) here to get enough bits.
  */
-#define ZONE_SHIFT (BITS_PER_LONG - NODES_SHIFT - MAX_NR_ZONES_SHIFT)
+#define NODEZONE_SHIFT (BITS_PER_LONG - MAX_NODES_SHIFT - MAX_ZONES_SHIFT)
+#define NODEZONE(node, zone)	((node << ZONES_SHIFT) | zone)
+
+static inline unsigned long page_zonenum(struct page *page)
+{
+	return (page->flags >> NODEZONE_SHIFT) & (~(~0UL << ZONES_SHIFT));
+}
+static inline unsigned long page_nodenum(struct page *page)
+{
+	return (page->flags >> (NODEZONE_SHIFT + ZONES_SHIFT));
+}
 
 struct zone;
 extern struct zone *zone_table[];
 
 static inline struct zone *page_zone(struct page *page)
 {
-	return zone_table[page->flags >> ZONE_SHIFT];
+	return zone_table[page->flags >> NODEZONE_SHIFT];
 }
 
-static inline void set_page_zone(struct page *page, unsigned long zone_num)
+static inline void set_page_zone(struct page *page, unsigned long nodezone_num)
 {
-	page->flags &= ~(~0UL << ZONE_SHIFT);
-	page->flags |= zone_num << ZONE_SHIFT;
+	page->flags &= ~(~0UL << NODEZONE_SHIFT);
+	page->flags |= nodezone_num << NODEZONE_SHIFT;
 }
 
 #ifndef CONFIG_DISCONTIGMEM
@@ -624,5 +642,33 @@ kernel_map_pages(struct page *page, int 
 }
 #endif
 
+#ifndef CONFIG_ARCH_GATE_AREA
+#ifdef AT_SYSINFO_EHDR
+static inline int in_gate_area(struct task_struct *task, unsigned long addr)
+{
+	if ((addr >= FIXADDR_USER_START) && (addr < FIXADDR_USER_END))
+		return 1;
+	else
+		return 0;
+}
+
+extern struct vm_area_struct gate_vma;
+static inline struct vm_area_struct *get_gate_vma(struct task_struct *tsk)
+{
+	return &gate_vma;
+}
+#else
+static inline int in_gate_area(struct task_struct *task, unsigned long addr)
+{
+	return 0;
+}
+
+static inline struct vm_area_struct *get_gate_vma(struct task_struct *tsk)
+{
+	return NULL;
+}
+#endif
+#endif
+
 #endif /* __KERNEL__ */
 #endif /* _LINUX_MM_H */
diff -puN include/linux/mmzone.h~linus include/linux/mmzone.h
--- 25/include/linux/mmzone.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/mmzone.h	2004-01-19 22:17:24.000000000 -0800
@@ -160,12 +160,19 @@ struct zone {
 #define ZONE_NORMAL		1
 #define ZONE_HIGHMEM		2
 
-#define MAX_NR_ZONES		3	/* Sync this with MAX_NR_ZONES_SHIFT */
-#define MAX_NR_ZONES_SHIFT	2	/* ceil(log2(MAX_NR_ZONES)) */
+#define MAX_NR_ZONES		3	/* Sync this with ZONES_SHIFT */
+#define ZONES_SHIFT		2	/* ceil(log2(MAX_NR_ZONES)) */
 
 #define GFP_ZONEMASK	0x03
 
 /*
+ * The "priority" of VM scanning is how much of the queues we will scan in one
+ * go. A value of 12 for DEF_PRIORITY implies that we will scan 1/4096th of the
+ * queues ("queue_length >> 12") during an aging round.
+ */
+#define DEF_PRIORITY 12
+
+/*
  * One allocation request operates on a zonelist. A zonelist
  * is a list of zones, the first one is the 'goal' of the
  * allocation, the other zones are fallback zones, in decreasing
@@ -303,7 +310,7 @@ int min_free_kbytes_sysctl_handler(struc
 extern struct pglist_data contig_page_data;
 #define NODE_DATA(nid)		(&contig_page_data)
 #define NODE_MEM_MAP(nid)	mem_map
-#define MAX_NODES_SHIFT		0
+#define MAX_NODES_SHIFT		1
 
 #else /* CONFIG_DISCONTIGMEM */
 
@@ -311,7 +318,7 @@ extern struct pglist_data contig_page_da
 
 #if BITS_PER_LONG == 32
 /*
- * with 32 bit flags field, page->zone is currently 8 bits.
+ * with 32 bit page->flags field, we reserve 8 bits for node/zone info.
  * there are 3 zones (2 bits) and this leaves 8-2=6 bits for nodes.
  */
 #define MAX_NODES_SHIFT		6
@@ -328,6 +335,13 @@ extern struct pglist_data contig_page_da
 #error NODES_SHIFT > MAX_NODES_SHIFT
 #endif
 
+/* There are currently 3 zones: DMA, Normal & Highmem, thus we need 2 bits */
+#define MAX_ZONES_SHIFT		2
+
+#if ZONES_SHIFT > MAX_ZONES_SHIFT
+#error ZONES_SHIFT > MAX_ZONES_SHIFT
+#endif
+
 extern DECLARE_BITMAP(node_online_map, MAX_NUMNODES);
 extern DECLARE_BITMAP(memblk_online_map, MAX_NR_MEMBLKS);
 
diff -puN include/linux/module.h~linus include/linux/module.h
--- 25/include/linux/module.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/module.h	2004-01-19 22:17:24.000000000 -0800
@@ -54,12 +54,16 @@ const struct exception_table_entry *
 search_extable(const struct exception_table_entry *first,
 	       const struct exception_table_entry *last,
 	       unsigned long value);
+void sort_extable(struct exception_table_entry *start,
+		  struct exception_table_entry *finish);
+void sort_main_extable(void);
 
 #ifdef MODULE
 #define ___module_cat(a,b) __mod_ ## a ## b
 #define __module_cat(a,b) ___module_cat(a,b)
 #define __MODULE_INFO(tag, name, info)					  \
 static const char __module_cat(name,__LINE__)[]				  \
+  __attribute_used__							  \
   __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info
 
 #define MODULE_GENERIC_TABLE(gtype,name)			\
@@ -142,6 +146,7 @@ void *__symbol_get_gpl(const char *symbo
 #define __CRC_SYMBOL(sym, sec)					\
 	extern void *__crc_##sym __attribute__((weak));		\
 	static const unsigned long __kcrctab_##sym		\
+	__attribute_used__					\
 	__attribute__((section("__kcrctab" sec), unused))	\
 	= (unsigned long) &__crc_##sym;
 #else
@@ -155,6 +160,7 @@ void *__symbol_get_gpl(const char *symbo
 	__attribute__((section("__ksymtab_strings")))		\
 	= MODULE_SYMBOL_PREFIX #sym;                    	\
 	static const struct kernel_symbol __ksymtab_##sym	\
+	__attribute_used__					\
 	__attribute__((section("__ksymtab" sec), unused))	\
 	= { (unsigned long)&sym, __kstrtab_##sym }
 
diff -puN include/linux/moduleparam.h~linus include/linux/moduleparam.h
--- 25/include/linux/moduleparam.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/moduleparam.h	2004-01-19 22:17:24.000000000 -0800
@@ -52,6 +52,7 @@ struct kparam_array
 #define __module_param_call(prefix, name, set, get, arg, perm)		\
 	static char __param_str_##name[] __initdata = prefix #name;	\
 	static struct kernel_param const __param_##name			\
+	__attribute_used__						\
     __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \
 	= { __param_str_##name, perm, set, get, arg }
 
diff -puN include/linux/netdevice.h~linus include/linux/netdevice.h
--- 25/include/linux/netdevice.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/netdevice.h	2004-01-19 22:17:24.000000000 -0800
@@ -831,7 +831,7 @@ static inline void netif_rx_complete(str
 	unsigned long flags;
 
 	local_irq_save(flags);
-	if (!test_bit(__LINK_STATE_RX_SCHED, &dev->state)) BUG();
+	BUG_ON(!test_bit(__LINK_STATE_RX_SCHED, &dev->state));
 	list_del(&dev->poll_list);
 	smp_mb__before_clear_bit();
 	clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
@@ -857,7 +857,7 @@ static inline void netif_poll_enable(str
  */
 static inline void __netif_rx_complete(struct net_device *dev)
 {
-	if (!test_bit(__LINK_STATE_RX_SCHED, &dev->state)) BUG();
+	BUG_ON(!test_bit(__LINK_STATE_RX_SCHED, &dev->state));
 	list_del(&dev->poll_list);
 	smp_mb__before_clear_bit();
 	clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
diff -puN include/linux/net.h~linus include/linux/net.h
--- 25/include/linux/net.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/net.h	2004-01-19 22:17:24.000000000 -0800
@@ -120,9 +120,9 @@ struct proto_ops {
 	int		(*getsockopt)(struct socket *sock, int level,
 				      int optname, char __user *optval, int __user *optlen);
 	int		(*sendmsg)   (struct kiocb *iocb, struct socket *sock,
-				      struct msghdr *m, int total_len);
+				      struct msghdr *m, size_t total_len);
 	int		(*recvmsg)   (struct kiocb *iocb, struct socket *sock,
-				      struct msghdr *m, int total_len,
+				      struct msghdr *m, size_t total_len,
 				      int flags);
 	int		(*mmap)	     (struct file *file, struct socket *sock,
 				      struct vm_area_struct * vma);
@@ -151,13 +151,13 @@ extern int	     sock_create(int family, 
 				 struct socket **res);
 extern void	     sock_release(struct socket *sock);
 extern int   	     sock_sendmsg(struct socket *sock, struct msghdr *msg,
-				  int len);
+				  size_t len);
 extern int	     sock_recvmsg(struct socket *sock, struct msghdr *msg,
-				  int size, int flags);
+				  size_t size, int flags);
 extern int	     sock_readv_writev(int type, struct inode *inode,
 				       struct file *file,
 				       const struct iovec *iov, long count,
-				       long size);
+				       size_t size);
 extern int 	     sock_map_fd(struct socket *sock);
 extern struct socket *sockfd_lookup(int fd, int *err);
 #define		     sockfd_put(sock) fput(sock->file)
@@ -216,9 +216,9 @@ SOCKCALL_WRAP(name, setsockopt, (struct 
 			 char *optval, int optlen), (sock, level, optname, optval, optlen)) \
 SOCKCALL_WRAP(name, getsockopt, (struct socket *sock, int level, int optname, \
 			 char *optval, int *optlen), (sock, level, optname, optval, optlen)) \
-SOCKCALL_WRAP(name, sendmsg, (struct kiocb *iocb, struct socket *sock, struct msghdr *m, int len), \
+SOCKCALL_WRAP(name, sendmsg, (struct kiocb *iocb, struct socket *sock, struct msghdr *m, size_t len), \
 	      (iocb, sock, m, len)) \
-SOCKCALL_WRAP(name, recvmsg, (struct kiocb *iocb, struct socket *sock, struct msghdr *m, int len, int flags), \
+SOCKCALL_WRAP(name, recvmsg, (struct kiocb *iocb, struct socket *sock, struct msghdr *m, size_t len, int flags), \
 	      (iocb, sock, m, len, flags)) \
 SOCKCALL_WRAP(name, mmap, (struct file *file, struct socket *sock, struct vm_area_struct *vma), \
 	      (file, sock, vma)) \
diff -puN include/linux/nfsd/nfsfh.h~linus include/linux/nfsd/nfsfh.h
--- 25/include/linux/nfsd/nfsfh.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/nfsd/nfsfh.h	2004-01-19 22:17:24.000000000 -0800
@@ -186,21 +186,8 @@ static inline void mk_fsid_v2(u32 *fsidv
 /*
  * Shorthand for dprintk()'s
  */
-inline static char * SVCFH_fmt(struct svc_fh *fhp)
-{
-	struct knfsd_fh *fh = &fhp->fh_handle;
-	
-	static char buf[80];
-	sprintf(buf, "%d: %08x %08x %08x %08x %08x %08x",
-		fh->fh_size,
-		fh->fh_base.fh_pad[0],
-		fh->fh_base.fh_pad[1],
-		fh->fh_base.fh_pad[2],
-		fh->fh_base.fh_pad[3],
-		fh->fh_base.fh_pad[4],
-		fh->fh_base.fh_pad[5]);
-	return buf;
-}
+extern char * SVCFH_fmt(struct svc_fh *fhp);
+
 /*
  * Function prototypes
  */
diff -puN include/linux/nfs_fs.h~linus include/linux/nfs_fs.h
--- 25/include/linux/nfs_fs.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/nfs_fs.h	2004-01-19 22:17:24.000000000 -0800
@@ -255,8 +255,7 @@ nfs_file_cred(struct file *file)
 	if (file)
 		cred = (struct rpc_cred *)file->private_data;
 #ifdef RPC_DEBUG
-	if (cred && cred->cr_magic != RPCAUTH_CRED_MAGIC)
-		BUG();
+	BUG_ON(cred && cred->cr_magic != RPCAUTH_CRED_MAGIC);
 #endif
 	return cred;
 }
diff -puN include/linux/pci_ids.h~linus include/linux/pci_ids.h
--- 25/include/linux/pci_ids.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/pci_ids.h	2004-01-19 22:17:24.000000000 -0800
@@ -291,6 +291,7 @@
 #define PCI_DEVICE_ID_ATI_RADEON_Ig	0x4967
 /* Radeon RV280 (9200) */
 #define PCI_DEVICE_ID_ATI_RADEON_Y_	0x5960
+#define PCI_DEVICE_ID_ATI_RADEON_Yd	0x5964
 /* Radeon R300 (9500) */
 #define PCI_DEVICE_ID_ATI_RADEON_AD	0x4144
 /* Radeon R300 (9700) */
@@ -325,7 +326,7 @@
 /* RadeonIGP */
 #define PCI_DEVICE_ID_ATI_RS100		0xcab0
 #define PCI_DEVICE_ID_ATI_RS200		0xcab2
-#define PCI_DEVICE_ID_ATI_RS200_B	0xcbb3
+#define PCI_DEVICE_ID_ATI_RS200_B	0xcbb2
 #define PCI_DEVICE_ID_ATI_RS250		0xcab3
 #define PCI_DEVICE_ID_ATI_RS300_100	0x5830
 #define PCI_DEVICE_ID_ATI_RS300_133	0x5831
@@ -516,6 +517,7 @@
 #define PCI_DEVICE_ID_MATROX_VIA	0x4536
 
 #define PCI_VENDOR_ID_CT		0x102c
+#define PCI_DEVICE_ID_CT_69000		0x00c0
 #define PCI_DEVICE_ID_CT_65545		0x00d8
 #define PCI_DEVICE_ID_CT_65548		0x00dc
 #define PCI_DEVICE_ID_CT_65550		0x00e0
@@ -1444,6 +1446,9 @@
 #define PCI_DEVICE_ID_IKON_10115	0x0115
 #define PCI_DEVICE_ID_IKON_10117	0x0117
 
+#define PCI_VENDOR_ID_SEGA		0x11db
+#define PCI_DEVICE_ID_SEGA_BBA		0x1234
+
 #define PCI_VENDOR_ID_ZORAN		0x11de
 #define PCI_DEVICE_ID_ZORAN_36057	0x6057
 #define PCI_DEVICE_ID_ZORAN_36120	0x6120
diff -puN include/linux/proc_fs.h~linus include/linux/proc_fs.h
--- 25/include/linux/proc_fs.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/proc_fs.h	2004-01-19 22:17:24.000000000 -0800
@@ -131,7 +131,9 @@ extern void proc_tty_unregister_driver(s
 /*
  * proc_devtree.c
  */
+struct device_node;
 extern void proc_device_tree_init(void);
+extern void proc_device_tree_add_node(struct device_node *, struct proc_dir_entry *);
 
 /*
  * proc_rtas.c
diff -puN include/linux/quotaops.h~linus include/linux/quotaops.h
--- 25/include/linux/quotaops.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/quotaops.h	2004-01-19 22:17:24.000000000 -0800
@@ -44,8 +44,7 @@ extern struct quotactl_ops vfs_quotactl_
 
 static __inline__ void DQUOT_INIT(struct inode *inode)
 {
-	if (!inode->i_sb)
-		BUG();
+	BUG_ON(!inode->i_sb);
 	if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode))
 		inode->i_sb->dq_op->initialize(inode, -1);
 }
@@ -53,8 +52,7 @@ static __inline__ void DQUOT_INIT(struct
 static __inline__ void DQUOT_DROP(struct inode *inode)
 {
 	if (IS_QUOTAINIT(inode)) {
-		if (!inode->i_sb)
-			BUG();
+		BUG_ON(!inode->i_sb);
 		inode->i_sb->dq_op->drop(inode);	/* Ops must be set when there's any quota... */
 	}
 }
diff -puN include/linux/rcupdate.h~linus include/linux/rcupdate.h
--- 25/include/linux/rcupdate.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/rcupdate.h	2004-01-19 22:17:24.000000000 -0800
@@ -55,7 +55,7 @@ struct rcu_head {
 };
 
 #define RCU_HEAD_INIT(head) \
-		{ list: LIST_HEAD_INIT(head.list), func: NULL, arg: NULL }
+		{ .list = LIST_HEAD_INIT(head.list), .func = NULL, .arg = NULL }
 #define RCU_HEAD(head) struct rcu_head head = RCU_HEAD_INIT(head)
 #define INIT_RCU_HEAD(ptr) do { \
        INIT_LIST_HEAD(&(ptr)->list); (ptr)->func = NULL; (ptr)->arg = NULL; \
diff -puN include/linux/rtnetlink.h~linus include/linux/rtnetlink.h
--- 25/include/linux/rtnetlink.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/rtnetlink.h	2004-01-19 22:17:24.000000000 -0800
@@ -44,7 +44,10 @@
 #define	RTM_DELTFILTER	(RTM_BASE+29)
 #define	RTM_GETTFILTER	(RTM_BASE+30)
 
-#define	RTM_MAX		(RTM_BASE+31)
+#define RTM_NEWPREFIX	(RTM_BASE+36)
+#define RTM_GETPREFIX	(RTM_BASE+38)
+
+#define	RTM_MAX		(RTM_BASE+39)
 
 /* 
    Generic structure for encapsulation of optional route information.
@@ -459,6 +462,34 @@ struct ifinfomsg
 	unsigned	ifi_change;		/* IFF_* change mask */
 };
 
+/********************************************************************
+ *		prefix information 
+ ****/
+
+struct prefixmsg
+{
+	unsigned char	prefix_family;
+	int		prefix_ifindex;
+	unsigned char	prefix_type;
+	unsigned char	prefix_len;
+	unsigned char	prefix_flags;
+};
+
+enum 
+{
+	PREFIX_UNSPEC,
+	PREFIX_ADDRESS,
+	PREFIX_CACHEINFO,
+};
+
+#define PREFIX_MAX	PREFIX_CACHEINFO
+
+struct prefix_cacheinfo
+{
+	__u32	preferred_time;
+	__u32	valid_time;
+};
+
 /* The struct should be in sync with struct net_device_stats */
 struct rtnl_link_stats
 {
@@ -558,9 +589,18 @@ enum
 	IFLA_INET6_CONF,	/* sysctl parameters		*/
 	IFLA_INET6_STATS,	/* statistics			*/
 	IFLA_INET6_MCAST,	/* MC things. What of them?	*/
+	IFLA_INET6_CACHEINFO,	/* time values and max reasm size */
 };
 
-#define IFLA_INET6_MAX	IFLA_INET6_MCAST
+struct ifla_cacheinfo
+{
+	__u32	max_reasm_len;
+	__u32	tstamp;		/* ipv6InterfaceTable updated timestamp */
+	__u32	reachable_time;
+	__u32	retrans_time;
+};
+
+#define IFLA_INET6_MAX	IFLA_INET6_CACHEINFO
 
 /*****************************************************************
  *		Traffic control messages.
@@ -611,10 +651,13 @@ enum
 #define RTMGRP_IPV6_IFADDR	0x100
 #define RTMGRP_IPV6_MROUTE	0x200
 #define RTMGRP_IPV6_ROUTE	0x400
+#define RTMGRP_IPV6_IFINFO	0x800
 
 #define RTMGRP_DECnet_IFADDR    0x1000
 #define RTMGRP_DECnet_ROUTE     0x4000
 
+#define RTMGRP_IPV6_PREFIX	0x20000
+
 /* End of information exported to user level */
 
 #ifdef __KERNEL__
diff -puN include/linux/sched.h~linus include/linux/sched.h
--- 25/include/linux/sched.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/sched.h	2004-01-19 22:17:24.000000000 -0800
@@ -50,7 +50,7 @@ struct exec_domain;
 #define CLONE_SETTLS	0x00080000	/* create a new TLS for the child */
 #define CLONE_PARENT_SETTID	0x00100000	/* set the TID in the parent */
 #define CLONE_CHILD_CLEARTID	0x00200000	/* clear the TID in the child */
-#define CLONE_DETACHED		0x00400000	/* Not used - CLONE_THREAD implies detached uniquely */
+#define CLONE_DETACHED		0x00400000	/* Unused, ignored */
 #define CLONE_UNTRACED		0x00800000	/* set if the tracing process can't force CLONE_PTRACE on this clone */
 #define CLONE_CHILD_SETTID	0x01000000	/* set the TID in the child */
 #define CLONE_STOPPED		0x02000000	/* Start in stopped state */
@@ -579,6 +579,7 @@ extern int FASTCALL(wake_up_process(stru
  static inline void kick_process(struct task_struct *tsk) { }
 #endif
 extern void FASTCALL(wake_up_forked_process(struct task_struct * tsk));
+extern void FASTCALL(sched_fork(task_t * p));
 extern void FASTCALL(sched_exit(task_t * p));
 
 asmlinkage long sys_wait4(pid_t pid,unsigned int * stat_addr, int options, struct rusage * ru);
diff -puN include/linux/security.h~linus include/linux/security.h
--- 25/include/linux/security.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/security.h	2004-01-19 22:17:24.000000000 -0800
@@ -757,6 +757,22 @@ struct swap_info_struct;
  *	incoming sk_buff @skb has been associated with a particular socket, @sk.
  *	@sk contains the sock (not socket) associated with the incoming sk_buff.
  *	@skb contains the incoming network data.
+ * @socket_getpeersec:
+ *	This hook allows the security module to provide peer socket security
+ *	state to userspace via getsockopt SO_GETPEERSEC.
+ *	@sock is the local socket.
+ *	@optval userspace memory where the security state is to be copied.
+ *	@optlen userspace int where the module should copy the actual length
+ *	of the security state.
+ *	@len as input is the maximum length to copy to userspace provided
+ *	by the caller.
+ *	Return 0 if all is well, otherwise, typical getsockopt return
+ *	values.
+ * @sk_alloc_security:
+ *      Allocate and attach a security structure to the sk->sk_security field,
+ *      which is used to copy security attributes between local stream sockets.
+ * @sk_free_security:
+ *	Deallocate security structure.
  *
  * Security hooks affecting all System V IPC operations.
  *
@@ -1183,6 +1199,9 @@ struct security_operations {
 	int (*socket_setsockopt) (struct socket * sock, int level, int optname);
 	int (*socket_shutdown) (struct socket * sock, int how);
 	int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
+	int (*socket_getpeersec) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
+	int (*sk_alloc_security) (struct sock *sk, int family, int priority);
+	void (*sk_free_security) (struct sock *sk);
 #endif	/* CONFIG_SECURITY_NETWORK */
 };
 
@@ -2564,6 +2583,22 @@ static inline int security_sock_rcv_skb 
 {
 	return security_ops->socket_sock_rcv_skb (sk, skb);
 }
+
+static inline int security_socket_getpeersec(struct socket *sock, char __user *optval,
+					     int __user *optlen, unsigned len)
+{
+	return security_ops->socket_getpeersec(sock, optval, optlen, len);
+}
+
+static inline int security_sk_alloc(struct sock *sk, int family, int priority)
+{
+	return security_ops->sk_alloc_security(sk, family, priority);
+}
+
+static inline void security_sk_free(struct sock *sk)
+{
+	return security_ops->sk_free_security(sk);
+}
 #else	/* CONFIG_SECURITY_NETWORK */
 static inline int security_unix_stream_connect(struct socket * sock,
 					       struct socket * other, 
@@ -2664,6 +2699,21 @@ static inline int security_sock_rcv_skb 
 {
 	return 0;
 }
+
+static inline int security_socket_getpeersec(struct socket *sock, char __user *optval,
+					     int __user *optlen, unsigned len)
+{
+	return -ENOPROTOOPT;
+}
+
+static inline int security_sk_alloc(struct sock *sk, int family, int priority)
+{
+	return 0;
+}
+
+static inline void security_sk_free(struct sock *sk)
+{
+}
 #endif	/* CONFIG_SECURITY_NETWORK */
 
 #endif /* ! __LINUX_SECURITY_H */
diff -puN include/linux/signal.h~linus include/linux/signal.h
--- 25/include/linux/signal.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/signal.h	2004-01-19 22:17:24.000000000 -0800
@@ -207,6 +207,7 @@ static inline void init_sigpending(struc
 	INIT_LIST_HEAD(&sig->list);
 }
 
+extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p);
 extern long do_sigpending(void __user *, unsigned long);
 extern int sigprocmask(int, sigset_t *, sigset_t *);
 
diff -puN include/linux/smp.h~linus include/linux/smp.h
--- 25/include/linux/smp.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/smp.h	2004-01-19 22:17:24.000000000 -0800
@@ -103,7 +103,6 @@ void smp_prepare_boot_cpu(void);
 #define on_each_cpu(func,info,retry,wait)	({ func(info); 0; })
 static inline void smp_send_reschedule(int cpu) { }
 #define num_booting_cpus()			1
-#define cpu_possible(cpu)			({ BUG_ON((cpu) != 0); 1; })
 #define smp_prepare_boot_cpu()			do {} while (0)
 
 #endif /* !SMP */
diff -puN include/linux/smp_lock.h~linus include/linux/smp_lock.h
--- 25/include/linux/smp_lock.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/smp_lock.h	2004-01-19 22:17:24.000000000 -0800
@@ -49,8 +49,7 @@ static inline void lock_kernel(void)
 
 static inline void unlock_kernel(void)
 {
-	if (unlikely(current->lock_depth < 0))
-		BUG();
+	BUG_ON(current->lock_depth < 0);
 	if (likely(--current->lock_depth < 0))
 		put_kernel_lock();
 }
diff -puN include/linux/sunrpc/sched.h~linus include/linux/sunrpc/sched.h
--- 25/include/linux/sunrpc/sched.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/sunrpc/sched.h	2004-01-19 22:17:24.000000000 -0800
@@ -205,7 +205,7 @@ rpc_exit(struct rpc_task *task, int stat
 static __inline__ char *
 rpc_qname(struct rpc_wait_queue *q)
 {
-	return q->name? q->name : "unknown";
+	return ((q && q->name) ? q->name : "unknown");
 }
 #endif
 
diff -puN include/linux/swap.h~linus include/linux/swap.h
--- 25/include/linux/swap.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/swap.h	2004-01-19 22:17:24.000000000 -0800
@@ -173,7 +173,7 @@ extern int rotate_reclaimable_page(struc
 extern void swap_setup(void);
 
 /* linux/mm/vmscan.c */
-extern int try_to_free_pages(struct zone *, unsigned int, unsigned int);
+extern int try_to_free_pages(struct zone **, unsigned int, unsigned int);
 extern int shrink_all_memory(int);
 extern int vm_swappiness;
 
diff -puN include/linux/sysctl.h~linus include/linux/sysctl.h
--- 25/include/linux/sysctl.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/sysctl.h	2004-01-19 22:17:24.000000000 -0800
@@ -127,6 +127,8 @@ enum
 	KERN_PANIC_ON_OOPS=57,  /* int: whether we will panic on an oops */
 	KERN_HPPA_PWRSW=58,	/* int: hppa soft-power enable */
 	KERN_HPPA_UNALIGNED=59,	/* int: hppa unaligned-trap enable */
+	KERN_PRINTK_RATELIMIT=60, /* int: tune printk ratelimiting */
+	KERN_PRINTK_RATELIMIT_BURST=61,	/* int: tune printk ratelimiting */
 };
 
 
@@ -418,7 +420,8 @@ enum {
 	NET_IPV6_TEMP_VALID_LFT=12,
 	NET_IPV6_TEMP_PREFERED_LFT=13,
 	NET_IPV6_REGEN_MAX_RETRY=14,
-	NET_IPV6_MAX_DESYNC_FACTOR=15
+	NET_IPV6_MAX_DESYNC_FACTOR=15,
+	NET_IPV6_MAX_ADDRESSES=16
 };
 
 /* /proc/sys/net/ipv6/icmp */
diff -puN include/linux/videodev2.h~linus include/linux/videodev2.h
--- 25/include/linux/videodev2.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/videodev2.h	2004-01-19 22:17:24.000000000 -0800
@@ -13,7 +13,9 @@
  *		Justin Schoeman
  *		et al.
  */
+#ifdef __KERNEL__
 #include <linux/time.h> /* need struct timeval */
+#endif
 
 /*
  *	M I S C E L L A N E O U S
@@ -111,6 +113,14 @@ enum v4l2_colorspace {
 	V4L2_COLORSPACE_SRGB          = 8,
 };
 
+enum v4l2_priority {
+	V4L2_PRIORITY_UNSET       = 0,  /* not initialized */
+	V4L2_PRIORITY_BACKGROUND  = 1,
+	V4L2_PRIORITY_INTERACTIVE = 2,
+	V4L2_PRIORITY_RECORD      = 3,
+	V4L2_PRIORITY_DEFAULT     = V4L2_PRIORITY_INTERACTIVE,
+};
+
 struct v4l2_rect {
 	__s32   left;
 	__s32   top;
@@ -144,8 +154,9 @@ struct v4l2_capability
 #define V4L2_CAP_VBI_OUTPUT	0x00000020  /* Is a VBI output device */
 #define V4L2_CAP_RDS_CAPTURE	0x00000100  /* RDS data capture */
 
-#define V4L2_CAP_TUNER		0x00010000  /* Has a tuner */
+#define V4L2_CAP_TUNER		0x00010000  /* has a tuner */
 #define V4L2_CAP_AUDIO		0x00020000  /* has audio support */
+#define V4L2_CAP_RADIO		0x00040000  /* is a radio device */
 
 #define V4L2_CAP_READWRITE      0x01000000  /* read/write systemcalls */
 #define V4L2_CAP_ASYNCIO        0x02000000  /* async I/O */
@@ -203,7 +214,7 @@ struct v4l2_pix_format
 #define V4L2_PIX_FMT_MPEG     v4l2_fourcc('M','P','E','G') /* MPEG          */
 
 /*  Vendor-specific formats   */
-#define V4L2_PIX_FMT_WNVA    v4l2_fourcc('W','N','V','A') /* Winnov hw compres */
+#define V4L2_PIX_FMT_WNVA     v4l2_fourcc('W','N','V','A') /* Winnov hw compress */
 
 /*
  *	F O R M A T   E N U M E R A T I O N
@@ -264,6 +275,51 @@ struct v4l2_compression
 	__u32	keyframerate;
 	__u32	pframerate;
 	__u32	reserved[5];
+
+/*  what we'll need for MPEG, extracted from some postings on
+    the v4l list (Gert Vervoort, PlasmaJohn).
+
+system stream:
+  - type: elementary stream(ES), packatised elementary stream(s) (PES)
+    program stream(PS), transport stream(TS)
+  - system bitrate
+  - PS packet size (DVD: 2048 bytes, VCD: 2324 bytes)
+  - TS video PID
+  - TS audio PID
+  - TS PCR PID
+  - TS system information tables (PAT, PMT, CAT, NIT and SIT)
+  - (MPEG-1 systems stream vs. MPEG-2 program stream (TS not supported
+    by MPEG-1 systems)
+
+audio:
+  - type: MPEG (+Layer I,II,III), AC-3, LPCM
+  - bitrate
+  - sampling frequency (DVD: 48 Khz, VCD: 44.1 KHz, 32 kHz)
+  - Trick Modes? (ff, rew)
+  - Copyright
+  - Inverse Telecine
+
+video:
+  - picturesize (SIF, 1/2 D1, 2/3 D1, D1) and PAL/NTSC norm can be set
+    through excisting V4L2 controls
+  - noise reduction, parameters encoder specific?
+  - MPEG video version: MPEG-1, MPEG-2
+  - GOP (Group Of Pictures) definition:
+    - N: number of frames per GOP
+    - M: distance between reference (I,P) frames
+    - open/closed GOP
+  - quantiser matrix: inter Q matrix (64 bytes) and intra Q matrix (64 bytes)
+  - quantiser scale: linear or logarithmic
+  - scanning: alternate or zigzag
+  - bitrate mode: CBR (constant bitrate) or VBR (variable bitrate).
+  - target video bitrate for CBR
+  - target video bitrate for VBR
+  - maximum video bitrate for VBR - min. quantiser value for VBR
+  - max. quantiser value for VBR
+  - adaptive quantisation value
+  - return the number of bytes per GOP or bitrate for bitrate monitoring
+
+*/
 };
 #endif
 
@@ -783,22 +839,22 @@ struct v4l2_streamparm
 #define VIDIOC_QUERYBUF		_IOWR ('V',  9, struct v4l2_buffer)
 #define VIDIOC_G_FBUF		_IOR  ('V', 10, struct v4l2_framebuffer)
 #define VIDIOC_S_FBUF		_IOW  ('V', 11, struct v4l2_framebuffer)
-#define VIDIOC_OVERLAY		_IOWR ('V', 14, int)
+#define VIDIOC_OVERLAY		_IOW  ('V', 14, int)
 #define VIDIOC_QBUF		_IOWR ('V', 15, struct v4l2_buffer)
 #define VIDIOC_DQBUF		_IOWR ('V', 17, struct v4l2_buffer)
 #define VIDIOC_STREAMON		_IOW  ('V', 18, int)
 #define VIDIOC_STREAMOFF	_IOW  ('V', 19, int)
 #define VIDIOC_G_PARM		_IOWR ('V', 21, struct v4l2_streamparm)
-#define VIDIOC_S_PARM		_IOW  ('V', 22, struct v4l2_streamparm)
+#define VIDIOC_S_PARM		_IOWR ('V', 22, struct v4l2_streamparm)
 #define VIDIOC_G_STD		_IOR  ('V', 23, v4l2_std_id)
 #define VIDIOC_S_STD		_IOW  ('V', 24, v4l2_std_id)
 #define VIDIOC_ENUMSTD		_IOWR ('V', 25, struct v4l2_standard)
 #define VIDIOC_ENUMINPUT	_IOWR ('V', 26, struct v4l2_input)
 #define VIDIOC_G_CTRL		_IOWR ('V', 27, struct v4l2_control)
-#define VIDIOC_S_CTRL		_IOW  ('V', 28, struct v4l2_control)
+#define VIDIOC_S_CTRL		_IOWR ('V', 28, struct v4l2_control)
 #define VIDIOC_G_TUNER		_IOWR ('V', 29, struct v4l2_tuner)
 #define VIDIOC_S_TUNER		_IOW  ('V', 30, struct v4l2_tuner)
-#define VIDIOC_G_AUDIO		_IOWR ('V', 33, struct v4l2_audio)
+#define VIDIOC_G_AUDIO		_IOR  ('V', 33, struct v4l2_audio)
 #define VIDIOC_S_AUDIO		_IOW  ('V', 34, struct v4l2_audio)
 #define VIDIOC_QUERYCTRL	_IOWR ('V', 36, struct v4l2_queryctrl)
 #define VIDIOC_QUERYMENU	_IOWR ('V', 37, struct v4l2_querymenu)
@@ -807,7 +863,7 @@ struct v4l2_streamparm
 #define VIDIOC_G_OUTPUT		_IOR  ('V', 46, int)
 #define VIDIOC_S_OUTPUT		_IOWR ('V', 47, int)
 #define VIDIOC_ENUMOUTPUT	_IOWR ('V', 48, struct v4l2_output)
-#define VIDIOC_G_AUDOUT		_IOWR ('V', 49, struct v4l2_audioout)
+#define VIDIOC_G_AUDOUT		_IOR  ('V', 49, struct v4l2_audioout)
 #define VIDIOC_S_AUDOUT		_IOW  ('V', 50, struct v4l2_audioout)
 #define VIDIOC_G_MODULATOR	_IOWR ('V', 54, struct v4l2_modulator)
 #define VIDIOC_S_MODULATOR	_IOW  ('V', 55, struct v4l2_modulator)
@@ -820,6 +876,17 @@ struct v4l2_streamparm
 #define VIDIOC_S_JPEGCOMP	_IOW  ('V', 62, struct v4l2_jpegcompression)
 #define VIDIOC_QUERYSTD      	_IOR  ('V', 63, v4l2_std_id)
 #define VIDIOC_TRY_FMT      	_IOWR ('V', 64, struct v4l2_format)
+#define VIDIOC_ENUMAUDIO	_IOWR ('V', 65, struct v4l2_audio)
+#define VIDIOC_ENUMAUDOUT	_IOWR ('V', 66, struct v4l2_audioout)
+#define VIDIOC_G_PRIORITY       _IOR  ('V', 67, enum v4l2_priority)
+#define VIDIOC_S_PRIORITY       _IOW  ('V', 68, enum v4l2_priority)
+
+/* for compatibility, will go away some day */
+#define VIDIOC_OVERLAY_OLD     	_IOWR ('V', 14, int)
+#define VIDIOC_S_PARM_OLD      	_IOW  ('V', 22, struct v4l2_streamparm)
+#define VIDIOC_S_CTRL_OLD      	_IOW  ('V', 28, struct v4l2_control)
+#define VIDIOC_G_AUDIO_OLD     	_IOWR ('V', 33, struct v4l2_audio)
+#define VIDIOC_G_AUDOUT_OLD    	_IOWR ('V', 49, struct v4l2_audioout)
 
 #define BASE_VIDIOC_PRIVATE	192		/* 192-255 are private */
 
@@ -838,17 +905,29 @@ extern unsigned int v4l2_video_std_fps(s
 extern int v4l2_video_std_construct(struct v4l2_standard *vs,
 				    int id, char *name);
 
-/*  Compatibility layer interface  */
-typedef int (*v4l2_kioctl)(struct inode *inode, struct file *file,
-			   unsigned int cmd, void *arg);
-int v4l_compat_translate_ioctl(struct inode *inode, struct file *file,
-			       int cmd, void *arg, v4l2_kioctl driver_ioctl);
+/* prority handling */
+struct v4l2_prio_state {
+	atomic_t prios[4];
+};
+int v4l2_prio_init(struct v4l2_prio_state *global);
+int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
+		     enum v4l2_priority new);
+int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local);
+int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local);
+enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global);
+int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local);
 
 /* names for fancy debug output */
 extern char *v4l2_field_names[];
 extern char *v4l2_type_names[];
 extern char *v4l2_ioctl_names[];
 
+/*  Compatibility layer interface  --  v4l1-compat module */
+typedef int (*v4l2_kioctl)(struct inode *inode, struct file *file,
+			   unsigned int cmd, void *arg);
+int v4l_compat_translate_ioctl(struct inode *inode, struct file *file,
+			       int cmd, void *arg, v4l2_kioctl driver_ioctl);
+
 #endif /* __KERNEL__ */
 #endif /* __LINUX_VIDEODEV2_H */
 
diff -puN include/linux/videodev.h~linus include/linux/videodev.h
--- 25/include/linux/videodev.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/videodev.h	2004-01-19 22:17:24.000000000 -0800
@@ -3,7 +3,6 @@
 
 #include <linux/types.h>
 #include <linux/version.h>
-#include <linux/device.h>
 
 #define HAVE_V4L2 1
 #include <linux/videodev2.h>
@@ -12,6 +11,7 @@
 
 #include <linux/poll.h>
 #include <linux/mm.h>
+#include <linux/device.h>
 
 struct video_device
 {
@@ -429,7 +429,7 @@ struct video_code
 #define VID_HARDWARE_CPIA2	33
 #define VID_HARDWARE_VICAM      34
 #define VID_HARDWARE_SF16FMR2	35
-#define VID_HARDWARE_W9968CF	36	/* W996[87]CF JPEG USB Dual Mode Cam */
+#define VID_HARDWARE_W9968CF    36
 #endif /* __LINUX_VIDEODEV_H */
 
 /*
diff -puN include/linux/zorro.h~linus include/linux/zorro.h
--- 25/include/linux/zorro.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/linux/zorro.h	2004-01-19 22:17:24.000000000 -0800
@@ -1,7 +1,7 @@
 /*
  *  linux/zorro.h -- Amiga AutoConfig (Zorro) Bus Definitions
  *
- *  Copyright (C) 1995--2000 Geert Uytterhoeven
+ *  Copyright (C) 1995--2003 Geert Uytterhoeven
  *
  *  This file is subject to the terms and conditions of the GNU General Public
  *  License.  See the file COPYING in the main directory of this archive
@@ -13,6 +13,9 @@
 
 #ifndef __ASSEMBLY__
 
+#include <linux/device.h>
+
+
     /*
      *  Each Zorro board has a 32-bit ID of the form
      *
@@ -96,17 +99,17 @@ struct ExpansionRom {
 #define ERTF_MEMLIST	(1<<5)
 
 struct ConfigDev {
-    struct Node 	cd_Node;
-    __u8  		cd_Flags;	/* (read/write) */
-    __u8  		cd_Pad; 	/* reserved */
-    struct ExpansionRom cd_Rom; 	/* copy of board's expansion ROM */
+    struct Node		cd_Node;
+    __u8		cd_Flags;	/* (read/write) */
+    __u8		cd_Pad;		/* reserved */
+    struct ExpansionRom cd_Rom;		/* copy of board's expansion ROM */
     void		*cd_BoardAddr;	/* where in memory the board was placed */
-    __u32 		cd_BoardSize;	/* size of board in bytes */
-    __u16  		cd_SlotAddr;	/* which slot number (PRIVATE) */
-    __u16  		cd_SlotSize;	/* number of slots (PRIVATE) */
+    __u32		cd_BoardSize;	/* size of board in bytes */
+    __u16		cd_SlotAddr;	/* which slot number (PRIVATE) */
+    __u16		cd_SlotSize;	/* number of slots (PRIVATE) */
     void		*cd_Driver;	/* pointer to node of driver */
     struct ConfigDev	*cd_NextCD;	/* linked list of drivers to config */
-    __u32 		cd_Unused[4];	/* for whatever the driver wants */
+    __u32		cd_Unused[4];	/* for whatever the driver wants */
 } __attribute__ ((packed));
 
 #else /* __ASSEMBLY__ */
@@ -157,15 +160,81 @@ CD_sizeof	= CD_Unused+(4*4)
 
 #include <asm/zorro.h>
 
+
+    /*
+     *  Zorro devices
+     */
+
 struct zorro_dev {
     struct ExpansionRom rom;
     zorro_id id;
+    struct zorro_driver *driver;	/* which driver has allocated this device */
+    struct device dev;			/* Generic device interface */
     u16 slotaddr;
     u16 slotsize;
     char name[64];
     struct resource resource;
 };
 
+#define	to_zorro_dev(n)	container_of(n, struct zorro_dev, dev)
+
+
+    /*
+     *  Zorro bus
+     */
+
+struct zorro_bus {
+    struct list_head devices;		/* list of devices on this bus */
+    unsigned int num_resources;		/* number of resources */
+    struct resource resources[4];	/* address space routed to this bus */
+    struct device dev;
+    char name[10];
+};
+
+extern struct zorro_bus zorro_bus;	/* single Zorro bus */
+extern struct bus_type zorro_bus_type;
+
+
+    /*
+     *  Zorro device IDs
+     */
+
+struct zorro_device_id {
+	zorro_id id;			/* Device ID or ZORRO_WILDCARD */
+	unsigned long driver_data;	/* Data private to the driver */
+};
+
+
+    /*
+     *  Zorro device drivers
+     */
+
+struct zorro_driver {
+    struct list_head node;
+    char *name;
+    const struct zorro_device_id *id_table;	/* NULL if wants all devices */
+    int (*probe)(struct zorro_dev *z, const struct zorro_device_id *id);	/* New device inserted */
+    void (*remove)(struct zorro_dev *z);	/* Device removed (NULL if not a hot-plug capable driver) */
+    struct device_driver driver;
+};
+
+#define	to_zorro_driver(drv)	container_of(drv, struct zorro_driver, driver)
+
+
+#define zorro_for_each_dev(dev)	\
+	for (dev = &zorro_autocon[0]; dev < zorro_autocon+zorro_num_autocon; dev++)
+
+
+/* New-style probing */
+extern int zorro_register_driver(struct zorro_driver *);
+extern void zorro_unregister_driver(struct zorro_driver *);
+extern const struct zorro_device_id *zorro_match_device(const struct zorro_device_id *ids, const struct zorro_dev *z);
+static inline struct zorro_driver *zorro_dev_driver(const struct zorro_dev *z)
+{
+    return z->driver;
+}
+
+
 extern unsigned int zorro_num_autocon;	/* # of autoconfig devices found */
 extern struct zorro_dev zorro_autocon[ZORRO_NUM_AUTO];
 
@@ -174,17 +243,65 @@ extern struct zorro_dev zorro_autocon[ZO
      *  Zorro Functions
      */
 
-extern void zorro_name_device(struct zorro_dev *dev);
-
 extern struct zorro_dev *zorro_find_device(zorro_id id,
 					   struct zorro_dev *from);
 
+#define zorro_resource_start(z)	((z)->resource.start)
+#define zorro_resource_end(z)	((z)->resource.end)
+#define zorro_resource_len(z)	((z)->resource.end-(z)->resource.start+1)
+#define zorro_resource_flags(z)	((z)->resource.flags)
+
 #define zorro_request_device(z, name) \
-    request_mem_region((z)->resource.start, \
-		       (z)->resource.end-(z)->resource.start+1, (name))
+    request_mem_region(zorro_resource_start(z), zorro_resource_len(z), name)
 #define zorro_release_device(z) \
-    release_mem_region((z)->resource.start, \
-		       (z)->resource.end-(z)->resource.start+1)
+    release_mem_region(zorro_resource_start(z), zorro_resource_len(z))
+
+/* Similar to the helpers above, these manipulate per-zorro_dev
+ * driver-specific data.  They are really just a wrapper around
+ * the generic device structure functions of these calls.
+ */
+static inline void *zorro_get_drvdata (struct zorro_dev *z)
+{
+	return dev_get_drvdata(&z->dev);
+}
+
+static inline void zorro_set_drvdata (struct zorro_dev *z, void *data)
+{
+	dev_set_drvdata(&z->dev, data);
+}
+
+
+/*
+ * A helper function which helps ensure correct zorro_driver
+ * setup and cleanup for commonly-encountered hotplug/modular cases
+ *
+ * This MUST stay in a header, as it checks for -DMODULE
+ */
+static inline int zorro_module_init(struct zorro_driver *drv)
+{
+	int rc = zorro_register_driver(drv);
+
+	if (rc > 0)
+		return 0;
+
+	/* iff CONFIG_HOTPLUG and built into kernel, we should
+	 * leave the driver around for future hotplug events.
+	 * For the module case, a hotplug daemon of some sort
+	 * should load a module in response to an insert event. */
+#if defined(CONFIG_HOTPLUG) && !defined(MODULE)
+	if (rc == 0)
+		return 0;
+#else
+	if (rc == 0)
+		rc = -ENODEV;
+#endif
+
+	/* if we get here, we need to clean up Zorro driver instance
+	 * and return some sort of error */
+	zorro_unregister_driver(drv);
+
+	return rc;
+}
 
 
     /*
diff -puN include/media/id.h~linus include/media/id.h
--- 25/include/media/id.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/media/id.h	2004-01-19 22:17:24.000000000 -0800
@@ -27,6 +27,9 @@
 #ifndef  I2C_DRIVERID_TDA9874
 # define I2C_DRIVERID_TDA9874 I2C_DRIVERID_EXP0+7
 #endif
+#ifndef  I2C_DRIVERID_SAA6752HS
+# define I2C_DRIVERID_SAA6752HS I2C_DRIVERID_EXP0+8
+#endif
 
 /* algorithms */
 #ifndef I2C_ALGO_SAA7134
diff -puN /dev/null include/media/ir-common.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/media/ir-common.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,61 @@
+/*
+ * some common structs and functions to handle infrared remotes via
+ * input layer ...
+ *
+ * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <linux/version.h>
+#include <linux/input.h>
+
+
+#define IR_TYPE_RC5     1
+#define IR_TYPE_OTHER  99
+
+#define IR_KEYTAB_TYPE	u32
+#define IR_KEYTAB_SIZE	64  // enougth for rc5, probably need more some day ...
+
+#define IR_KEYCODE(tab,code)	(((unsigned)code < IR_KEYTAB_SIZE) \
+				 ? tab[code] : KEY_RESERVED)
+
+struct ir_input_state {
+	/* configuration */
+	int                ir_type;
+	IR_KEYTAB_TYPE     ir_codes[IR_KEYTAB_SIZE];
+
+	/* key info */
+	u32                ir_raw;      /* raw data */
+	u32                ir_key;      /* ir key code */
+	u32                keycode;     /* linux key code */
+	int                keypressed;  /* current state */
+};
+
+extern IR_KEYTAB_TYPE ir_codes_rc5_tv[IR_KEYTAB_SIZE];
+extern IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE];
+
+void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
+		   int ir_type, IR_KEYTAB_TYPE *ir_codes);
+void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir);
+void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
+		      u32 ir_key, u32 ir_raw);
+u32  ir_extract_bits(u32 data, u32 mask);
+
+/*
+ * Local variables:
+ * c-basic-offset: 8
+ * End:
+ */
diff -puN include/media/tuner.h~linus include/media/tuner.h
--- 25/include/media/tuner.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/media/tuner.h	2004-01-19 22:17:24.000000000 -0800
@@ -65,14 +65,16 @@
 #define TUNER_PHILIPS_FM1216ME_MK3  38
 #define TUNER_LG_NTSC_NEW_TAPC   39
 #define TUNER_HITACHI_NTSC       40
-
-
+#define TUNER_PHILIPS_PAL_MK     41
+#define TUNER_PHILIPS_ATSC       42
+#define TUNER_PHILIPS_FM1236_MK3  43
 
 #define NOTUNER 0
 #define PAL     1	/* PAL_BG */
 #define PAL_I   2
 #define NTSC    3
 #define SECAM   4
+#define ATSC    5
 
 #define NoTuner 0
 #define Philips 1
diff -puN include/net/addrconf.h~linus include/net/addrconf.h
--- 25/include/net/addrconf.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/net/addrconf.h	2004-01-19 22:17:24.000000000 -0800
@@ -15,6 +15,8 @@
 
 #define ADDR_CHECK_FREQUENCY		(120*HZ)
 
+#define IPV6_MAX_ADDRESSES		16
+
 struct prefix_info {
 	__u8			type;
 	__u8			length;
@@ -50,10 +52,6 @@ struct prefix_info {
 extern void			addrconf_init(void);
 extern void			addrconf_cleanup(void);
 
-extern int		        addrconf_notify(struct notifier_block *this, 
-						unsigned long event, 
-						void * data);
-
 extern int			addrconf_add_ifaddr(void *arg);
 extern int			addrconf_del_ifaddr(void *arg);
 extern int			addrconf_set_dstaddr(void *arg);
diff -puN include/net/bluetooth/bluetooth.h~linus include/net/bluetooth/bluetooth.h
--- 25/include/net/bluetooth/bluetooth.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/net/bluetooth/bluetooth.h	2004-01-19 22:17:24.000000000 -0800
@@ -47,7 +47,8 @@
 #define BTPROTO_HCI     1
 #define BTPROTO_SCO   	2
 #define BTPROTO_RFCOMM	3
-#define BTPROTO_BNEP    4
+#define BTPROTO_BNEP	4
+#define BTPROTO_CMTP	5
 
 #define SOL_HCI     0
 #define SOL_L2CAP   6
@@ -129,7 +130,7 @@ int  bt_sock_unregister(int proto);
 struct sock *bt_sock_alloc(struct socket *sock, int proto, int pi_size, int prio);
 void bt_sock_link(struct bt_sock_list *l, struct sock *s);
 void bt_sock_unlink(struct bt_sock_list *l, struct sock *s);
-int  bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, int len, int flags);
+int  bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags);
 uint bt_sock_poll(struct file * file, struct socket *sock, poll_table *wait);
 int  bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo);
 
diff -puN include/net/bluetooth/hci_core.h~linus include/net/bluetooth/hci_core.h
--- 25/include/net/bluetooth/hci_core.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/net/bluetooth/hci_core.h	2004-01-19 22:17:24.000000000 -0800
@@ -176,6 +176,12 @@ static inline void inquiry_cache_init(st
 	c->list = NULL;
 }
 
+static inline int inquiry_cache_empty(struct hci_dev *hdev)
+{
+	struct inquiry_cache *c = &hdev->inq_cache;
+	return (c->list == NULL);
+}
+
 static inline long inquiry_cache_age(struct hci_dev *hdev)
 {
 	struct inquiry_cache *c = &hdev->inq_cache;
@@ -281,10 +287,12 @@ static inline void hci_conn_hold(struct 
 static inline void hci_conn_put(struct hci_conn *conn)
 {
 	if (atomic_dec_and_test(&conn->refcnt)) {
-		if (conn->type == SCO_LINK)
+		if (conn->type == ACL_LINK) {
+			unsigned long timeo = (conn->out) ?
+				HCI_DISCONN_TIMEOUT : HCI_DISCONN_TIMEOUT * 2;
+			hci_conn_set_timer(conn, timeo);
+		} else
 			hci_conn_set_timer(conn, HZ / 100);
-		else if (conn->out)
-			hci_conn_set_timer(conn, HCI_DISCONN_TIMEOUT);
 	}
 }
 
diff -puN include/net/bluetooth/hci.h~linus include/net/bluetooth/hci.h
--- 25/include/net/bluetooth/hci.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/net/bluetooth/hci.h	2004-01-19 22:17:24.000000000 -0800
@@ -408,6 +408,16 @@ struct inquiry_info {
 	__u16    clock_offset;
 } __attribute__ ((packed));
 
+#define HCI_EV_INQUIRY_RESULT_WITH_RSSI	0x22
+struct inquiry_info_with_rssi {
+	bdaddr_t bdaddr;
+	__u8     pscan_rep_mode;
+	__u8     pscan_period_mode;
+	__u8     dev_class[3];
+	__u16    clock_offset;
+	__u8     rssi;
+} __attribute__ ((packed));
+
 #define HCI_EV_CONN_COMPLETE 	0x03
 struct hci_ev_conn_complete {
 	__u8     status;
diff -puN include/net/bluetooth/rfcomm.h~linus include/net/bluetooth/rfcomm.h
--- 25/include/net/bluetooth/rfcomm.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/net/bluetooth/rfcomm.h	2004-01-19 22:17:24.000000000 -0800
@@ -167,8 +167,8 @@ struct rfcomm_session {
 	int              initiator;
 
 	/* Default DLC parameters */
+	int    cfc;
 	uint   mtu;
-	uint   credits;
 
 	struct list_head dlcs;
 };
@@ -190,7 +190,7 @@ struct rfcomm_dlc {
 	u8            mscex;
 
 	uint          mtu;
-	uint          credits;
+	uint          cfc;
 	uint          rx_credits;
 	uint          tx_credits;
 
@@ -219,6 +219,11 @@ struct rfcomm_dlc {
 #define RFCOMM_MSCEX_RX     2
 #define RFCOMM_MSCEX_OK     (RFCOMM_MSCEX_TX + RFCOMM_MSCEX_RX)
 
+/* CFC states */
+#define RFCOMM_CFC_UNKNOWN  -1
+#define RFCOMM_CFC_DISABLED 0
+#define RFCOMM_CFC_ENABLED  RFCOMM_MAX_CREDITS
+
 extern struct task_struct *rfcomm_thread;
 extern unsigned long rfcomm_event;
 
diff -puN include/net/flow.h~linus include/net/flow.h
--- 25/include/net/flow.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/net/flow.h	2004-01-19 22:17:24.000000000 -0800
@@ -8,6 +8,7 @@
 #define _NET_FLOW_H
 
 #include <linux/in6.h>
+#include <asm/atomic.h>
 
 struct flowi {
 	int	oif;
diff -puN include/net/if_inet6.h~linus include/net/if_inet6.h
--- 25/include/net/if_inet6.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/net/if_inet6.h	2004-01-19 22:17:24.000000000 -0800
@@ -25,6 +25,10 @@
 #define IF_RA_RCVD	0x20
 #define IF_RS_SENT	0x10
 
+/* prefix flags */
+#define IF_PREFIX_ONLINK	0x01
+#define IF_PREFIX_AUTOCONF	0x02
+
 #ifdef __KERNEL__
 
 struct inet6_ifaddr 
@@ -183,6 +187,7 @@ struct inet6_dev 
 	struct inet6_dev	*next;
 	struct ipv6_devconf	cnf;
 	struct ipv6_devstat	stats;
+	unsigned long		tstamp; /* ipv6InterfaceTable update timestamp */
 };
 
 extern struct ipv6_devconf ipv6_devconf;
diff -puN include/net/inet_common.h~linus include/net/inet_common.h
--- 25/include/net/inet_common.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/net/inet_common.h	2004-01-19 22:17:24.000000000 -0800
@@ -23,11 +23,11 @@ extern int			inet_accept(struct socket *
 extern int			inet_recvmsg(struct kiocb *iocb,
 					     struct socket *sock, 
 					     struct msghdr *ubuf, 
-					     int size, int flags);
+					     size_t size, int flags);
 extern int			inet_sendmsg(struct kiocb *iocb,
 					     struct socket *sock, 
 					     struct msghdr *msg, 
-					     int size);
+					     size_t size);
 extern int			inet_shutdown(struct socket *sock, int how);
 extern unsigned int		inet_poll(struct file * file, struct socket *sock, struct poll_table_struct *wait);
 extern int			inet_setsockopt(struct socket *sock, int level,
diff -puN include/net/ipv6.h~linus include/net/ipv6.h
--- 25/include/net/ipv6.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/net/ipv6.h	2004-01-19 22:17:24.000000000 -0800
@@ -401,12 +401,8 @@ extern int			ipv6_getsockopt(struct sock
 
 extern void			ipv6_packet_init(void);
 
-extern void			ipv6_netdev_notif_init(void);
-
 extern void			ipv6_packet_cleanup(void);
 
-extern void			ipv6_netdev_notif_cleanup(void);
-
 extern int 			ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len);
 extern void			ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, u16 port,
 						u32 info, u8 *payload);
diff -puN include/net/irda/ircomm_tty.h~linus include/net/irda/ircomm_tty.h
--- 25/include/net/irda/ircomm_tty.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/net/irda/ircomm_tty.h	2004-01-19 22:17:24.000000000 -0800
@@ -122,6 +122,9 @@ void ircomm_tty_stop(struct tty_struct *
 void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self);
 
 extern void ircomm_tty_change_speed(struct ircomm_tty_cb *self);
+extern int ircomm_tty_tiocmget(struct tty_struct *tty, struct file *file);
+extern int ircomm_tty_tiocmset(struct tty_struct *tty, struct file *file,
+			       unsigned int set, unsigned int clear);
 extern int ircomm_tty_ioctl(struct tty_struct *tty, struct file *file, 
 			    unsigned int cmd, unsigned long arg);
 extern void ircomm_tty_set_termios(struct tty_struct *tty, 
diff -puN include/net/irda/timer.h~linus include/net/irda/timer.h
--- 25/include/net/irda/timer.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/net/irda/timer.h	2004-01-19 22:17:24.000000000 -0800
@@ -40,14 +40,14 @@ struct lsap_cb;
 struct lap_cb;
 
 /* 
- *  Timeout definitions, some defined in IrLAP p. 92
+ *  Timeout definitions, some defined in IrLAP 6.13.5 - p. 92
  */
 #define POLL_TIMEOUT        (450*HZ/1000)    /* Must never exceed 500 ms */
 #define FINAL_TIMEOUT       (500*HZ/1000)    /* Must never exceed 500 ms */
 
 /* 
- *  Normally twice of p-timer. Note 3, IrLAP p. 60 suggests at least twice 
- *  duration of the P-timer.
+ *  Normally twice of p-timer. Note 3, IrLAP 6.3.11.2 - p. 60 suggests
+ *  at least twice duration of the P-timer.
  */
 #define WD_TIMEOUT          (POLL_TIMEOUT*2)
 
diff -puN include/net/ndisc.h~linus include/net/ndisc.h
--- 25/include/net/ndisc.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/net/ndisc.h	2004-01-19 22:17:24.000000000 -0800
@@ -98,6 +98,17 @@ extern int			igmp6_event_report(struct s
 
 extern void			igmp6_cleanup(void);
 
+#ifdef CONFIG_SYSCTL
+extern int 			ndisc_ifinfo_sysctl_change(ctl_table *ctl,
+							   int write,
+							   struct file * filp,
+							   void __user *buffer,
+							   size_t *lenp);
+#endif
+
+extern void 			inet6_ifinfo_notify(int event,
+						    struct inet6_dev *idev);
+
 static inline struct neighbour * ndisc_get_neigh(struct net_device *dev, struct in6_addr *addr)
 {
 
diff -puN include/net/neighbour.h~linus include/net/neighbour.h
--- 25/include/net/neighbour.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/net/neighbour.h	2004-01-19 22:17:24.000000000 -0800
@@ -47,6 +47,9 @@
 #include <linux/skbuff.h>
 
 #include <linux/err.h>
+#ifdef CONFIG_SYSCTL
+#include <linux/sysctl.h>
+#endif
 
 #define NUD_IN_TIMER	(NUD_INCOMPLETE|NUD_DELAY|NUD_PROBE)
 #define NUD_VALID	(NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE|NUD_PROBE|NUD_STALE|NUD_DELAY)
@@ -206,8 +209,11 @@ extern int neigh_add(struct sk_buff *skb
 extern int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
 extern void neigh_app_ns(struct neighbour *n);
 
-extern int			neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
-						      int p_id, int pdev_id, char *p_name);
+extern int			neigh_sysctl_register(struct net_device *dev, 
+						      struct neigh_parms *p,
+						      int p_id, int pdev_id,
+						      char *p_name,
+						      proc_handler *proc_handler);
 extern void			neigh_sysctl_unregister(struct neigh_parms *p);
 
 /*
diff -puN include/net/sock.h~linus include/net/sock.h
--- 25/include/net/sock.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/net/sock.h	2004-01-19 22:17:24.000000000 -0800
@@ -246,6 +246,7 @@ struct sock {
 	struct socket		*sk_socket;
 	void			*sk_user_data;
 	struct module		*sk_owner;
+	void			*sk_security;
 	void			(*sk_state_change)(struct sock *sk);
 	void			(*sk_data_ready)(struct sock *sk, int bytes);
 	void			(*sk_write_space)(struct sock *sk);
@@ -304,7 +305,24 @@ static __inline__ int __sk_del_node_init
 	return 0;
 }
 
-static inline void __sock_put(struct sock *sk);
+/* Grab socket reference count. This operation is valid only
+   when sk is ALREADY grabbed f.e. it is found in hash table
+   or a list and the lookup is made under lock preventing hash table
+   modifications.
+ */
+
+static inline void sock_hold(struct sock *sk)
+{
+	atomic_inc(&sk->sk_refcnt);
+}
+
+/* Ungrab socket in the context, which assumes that socket refcnt
+   cannot hit zero, f.e. it is true in context of any socketcall.
+ */
+static inline void __sock_put(struct sock *sk)
+{
+	atomic_dec(&sk->sk_refcnt);
+}
 
 static __inline__ int sk_del_node_init(struct sock *sk)
 {
@@ -418,10 +436,10 @@ struct proto {
 					int optname, char *optval, 
 					int *option);  	 
 	int			(*sendmsg)(struct kiocb *iocb, struct sock *sk,
-					   struct msghdr *msg, int len);
+					   struct msghdr *msg, size_t len);
 	int			(*recvmsg)(struct kiocb *iocb, struct sock *sk,
 					   struct msghdr *msg,
-					int len, int noblock, int flags, 
+					size_t len, int noblock, int flags, 
 					int *addr_len);
 	int			(*sendpage)(struct sock *sk, struct page *page,
 					int offset, size_t size, int flags);
@@ -455,8 +473,8 @@ static __inline__ void sk_set_owner(stru
 	 * change the ownership of this struct sock, with one not needed
 	 * transient sk_set_owner call.
 	 */
-	if (unlikely(sk->sk_owner != NULL))
-		BUG();
+	BUG_ON(sk->sk_owner != NULL);
+
 	sk->sk_owner = owner;
 	__module_get(owner);
 }
@@ -609,9 +627,9 @@ extern int			sock_no_getsockopt(struct s
 extern int			sock_no_setsockopt(struct socket *, int, int,
 						   char *, int);
 extern int                      sock_no_sendmsg(struct kiocb *, struct socket *,
-						struct msghdr *, int);
+						struct msghdr *, size_t);
 extern int                      sock_no_recvmsg(struct kiocb *, struct socket *,
-						struct msghdr *, int, int);
+						struct msghdr *, size_t, int);
 extern int			sock_no_mmap(struct file *file,
 					     struct socket *sock,
 					     struct vm_area_struct *vma);
@@ -722,25 +740,6 @@ static inline void sk_filter_charge(stru
  *   use separate SMP lock, so that they are prone too.
  */
 
-/* Grab socket reference count. This operation is valid only
-   when sk is ALREADY grabbed f.e. it is found in hash table
-   or a list and the lookup is made under lock preventing hash table
-   modifications.
- */
-
-static inline void sock_hold(struct sock *sk)
-{
-	atomic_inc(&sk->sk_refcnt);
-}
-
-/* Ungrab socket in the context, which assumes that socket refcnt
-   cannot hit zero, f.e. it is true in context of any socketcall.
- */
-static inline void __sock_put(struct sock *sk)
-{
-	atomic_dec(&sk->sk_refcnt);
-}
-
 /* Ungrab socket and destroy it, if it was the last reference. */
 static inline void sock_put(struct sock *sk)
 {
diff -puN include/net/tcp.h~linus include/net/tcp.h
--- 25/include/net/tcp.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/net/tcp.h	2004-01-19 22:17:24.000000000 -0800
@@ -752,7 +752,7 @@ extern int			tcp_v4_remember_stamp(struc
 extern int		    	tcp_v4_tw_remember_stamp(struct tcp_tw_bucket *tw);
 
 extern int			tcp_sendmsg(struct kiocb *iocb, struct sock *sk,
-					    struct msghdr *msg, int size);
+					    struct msghdr *msg, size_t size);
 extern ssize_t			tcp_sendpage(struct socket *sock, struct page *page, int offset, size_t size, int flags);
 
 extern int			tcp_ioctl(struct sock *sk, 
@@ -846,7 +846,7 @@ extern int			tcp_setsockopt(struct sock 
 extern void			tcp_set_keepalive(struct sock *sk, int val);
 extern int			tcp_recvmsg(struct kiocb *iocb, struct sock *sk,
 					    struct msghdr *msg,
-					    int len, int nonblock, 
+					    size_t len, int nonblock, 
 					    int flags, int *addr_len);
 
 extern int			tcp_listen_start(struct sock *sk);
@@ -1457,7 +1457,7 @@ static __inline__ int tcp_prequeue(struc
 		if (tp->ucopy.memory > sk->sk_rcvbuf) {
 			struct sk_buff *skb1;
 
-			if (sock_owned_by_user(sk)) BUG();
+			BUG_ON(sock_owned_by_user(sk));
 
 			while ((skb1 = __skb_dequeue(&tp->ucopy.prequeue)) != NULL) {
 				sk->sk_backlog_rcv(sk, skb1);
diff -puN include/net/udp.h~linus include/net/udp.h
--- 25/include/net/udp.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/net/udp.h	2004-01-19 22:17:24.000000000 -0800
@@ -68,7 +68,7 @@ extern int	udp_connect(struct sock *sk,
 			    struct sockaddr *usin, int addr_len);
 
 extern int	udp_sendmsg(struct kiocb *iocb, struct sock *sk,
-			    struct msghdr *msg, int len);
+			    struct msghdr *msg, size_t len);
 
 extern int	udp_rcv(struct sk_buff *skb);
 extern int	udp_ioctl(struct sock *sk, int cmd, unsigned long arg);
diff -puN include/pcmcia/cs.h~linus include/pcmcia/cs.h
--- 25/include/pcmcia/cs.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/pcmcia/cs.h	2004-01-19 22:17:24.000000000 -0800
@@ -421,12 +421,6 @@ enum service {
     GetFirstWindow, GetNextWindow, GetMemPage
 };
 
-#ifdef IN_CARD_SERVICES
-extern int CardServices(int func, void *a1, void *a2, void *a3);
-#else
-extern int CardServices(int func, ...);
-#endif
-
 int pcmcia_access_configuration_register(client_handle_t handle, conf_reg_t *reg);
 int pcmcia_bind_device(bind_req_t *req);
 int pcmcia_bind_mtd(mtd_bind_t *req);
diff -puN include/rxrpc/call.h~linus include/rxrpc/call.h
--- 25/include/rxrpc/call.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/rxrpc/call.h	2004-01-19 22:17:24.000000000 -0800
@@ -187,8 +187,7 @@ extern int rxrpc_incoming_call(struct rx
 
 static inline void rxrpc_get_call(struct rxrpc_call *call)
 {
-	if (atomic_read(&call->usage)<=0)
-		BUG();
+	BUG_ON(atomic_read(&call->usage)<=0);
 	atomic_inc(&call->usage);
 	/*printk("rxrpc_get_call(%p{u=%d})\n",(C),atomic_read(&(C)->usage));*/
 }
diff -puN include/rxrpc/connection.h~linus include/rxrpc/connection.h
--- 25/include/rxrpc/connection.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/rxrpc/connection.h	2004-01-19 22:17:24.000000000 -0800
@@ -67,8 +67,7 @@ extern int rxrpc_connection_lookup(struc
 
 static inline void rxrpc_get_connection(struct rxrpc_connection *conn)
 {
-	if (atomic_read(&conn->usage)<0)
-		BUG();
+	BUG_ON(atomic_read(&conn->usage)<0);
 	atomic_inc(&conn->usage);
 	//printk("rxrpc_get_conn(%p{u=%d})\n",conn,atomic_read(&conn->usage));
 }
diff -puN include/rxrpc/message.h~linus include/rxrpc/message.h
--- 25/include/rxrpc/message.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/rxrpc/message.h	2004-01-19 22:17:24.000000000 -0800
@@ -53,8 +53,7 @@ struct rxrpc_message
 extern void __rxrpc_put_message(struct rxrpc_message *msg);
 static inline void rxrpc_put_message(struct rxrpc_message *msg)
 {
-	if (atomic_read(&msg->usage)<=0)
-		BUG();
+	BUG_ON(atomic_read(&msg->usage)<=0);
 	if (atomic_dec_and_test(&msg->usage))
 		__rxrpc_put_message(msg);
 }
diff -puN include/rxrpc/peer.h~linus include/rxrpc/peer.h
--- 25/include/rxrpc/peer.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/rxrpc/peer.h	2004-01-19 22:17:24.000000000 -0800
@@ -72,8 +72,7 @@ extern int rxrpc_peer_lookup(struct rxrp
 
 static inline void rxrpc_get_peer(struct rxrpc_peer *peer)
 {
-	if (atomic_read(&peer->usage)<0)
-		BUG();
+	BUG_ON(atomic_read(&peer->usage)<0);
 	atomic_inc(&peer->usage);
 	//printk("rxrpc_get_peer(%p{u=%d})\n",peer,atomic_read(&peer->usage));
 }
diff -puN include/rxrpc/transport.h~linus include/rxrpc/transport.h
--- 25/include/rxrpc/transport.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/rxrpc/transport.h	2004-01-19 22:17:24.000000000 -0800
@@ -85,8 +85,7 @@ extern int rxrpc_create_transport(unsign
 
 static inline void rxrpc_get_transport(struct rxrpc_transport *trans)
 {
-	if (atomic_read(&trans->usage) <= 0)
-		BUG();
+	BUG_ON(atomic_read(&trans->usage) <= 0);
 	atomic_inc(&trans->usage);
 	//printk("rxrpc_get_transport(%p{u=%d})\n",
 	//       trans, atomic_read(&trans->usage));
diff -puN include/scsi/scsi.h~linus include/scsi/scsi.h
--- 25/include/scsi/scsi.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/scsi/scsi.h	2004-01-19 22:17:24.000000000 -0800
@@ -302,7 +302,7 @@ struct scsi_lun {
 #define QUEUED          0x2004
 #define SOFT_ERROR      0x2005
 #define ADD_TO_MLQUEUE  0x2006
-#define TIMEOUT         0x2007
+#define TIMEOUT_ERROR   0x2007
 
 /*
  * Midlevel queue return values.
diff -puN include/sound/core.h~linus include/sound/core.h
--- 25/include/sound/core.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/include/sound/core.h	2004-01-19 22:17:24.000000000 -0800
@@ -160,6 +160,7 @@ struct _snd_card {
 	int shutdown;			/* this card is going down */
 	wait_queue_head_t shutdown_sleep;
 	struct work_struct free_workq;	/* for free in workqueue */
+	struct device *dev;
 
 #ifdef CONFIG_PM
 	int (*set_power_state) (snd_card_t *card, unsigned int state);
diff -puN /dev/null include/video/kyro.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/include/video/kyro.h	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,94 @@
+/*
+ *  linux/drivers/video/kyro/kryo.h
+ *
+ *  Copyright (C) 2002 STMicroelectronics
+ *  Copyright (C) 2004 Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file COPYING in the main directory of this archive
+ * for more details.
+ */
+
+#ifndef _KYRO_H
+#define _KYRO_H
+
+struct kyrofb_info {
+	void *regbase;
+
+	u32 HTot;	/* Hor Total Time    */
+	u32 HFP;	/* Hor Front Porch   */
+	u32 HST;	/* Hor Sync Time     */
+	u32 HBP;	/* Hor Back Porch    */
+	s32 HSP;		/* Hor Sync Polarity */
+	u32 VTot;	/* Ver Total Time    */
+	u32 VFP;	/* Ver Front Porch   */
+	u32 VST;	/* Ver Sync Time     */
+	u32 VBP;	/* Ver Back Porch    */
+	s32 VSP;		/* Ver Sync Polarity */
+	u32 XRES;	/* X Resolution      */
+	u32 YRES;	/* Y Resolution      */
+	u32 VFREQ;	/* Ver Frequency     */
+	u32 PIXCLK;	/* Pixel Clock       */
+	u32 HCLK;	/* Hor Clock         */
+
+	/* Usefull to hold depth here for Linux */
+	u8 PIXDEPTH;
+
+#ifdef CONFIG_MTRR
+	int mtrr_handle;
+#endif
+};
+
+extern int kyro_dev_init(void);
+extern void kyro_dev_reset(void);
+
+extern unsigned char *kyro_dev_physical_fb_ptr(void);
+extern unsigned char *kyro_dev_virtual_fb_ptr(void);
+extern void *kyro_dev_physical_regs_ptr(void);
+extern void *kyro_dev_virtual_regs_ptr(void);
+extern unsigned int kyro_dev_fb_size(void);
+extern unsigned int kyro_dev_regs_size(void);
+
+extern int kyro_dev_overlay_create(u32 width, u32 height, int bLinear);
+extern u32 kyro_dev_overlay_offset(void);
+extern int kyro_dev_overlay_viewport_set(u32 x, u32 y, u32 width, u32 height);
+
+/*
+ * benedict.gaster@superh.com
+ * Added the follow IOCTLS for the creation of overlay services...
+ */
+#define KYRO_IOC_MAGIC 'k'
+
+#define KYRO_IOCTL_OVERLAY_CREATE       _IO(KYRO_IOC_MAGIC, 0)
+#define KYRO_IOCTL_OVERLAY_VIEWPORT_SET _IO(KYRO_IOC_MAGIC, 1)
+#define KYRO_IOCTL_SET_VIDEO_MODE       _IO(KYRO_IOC_MAGIC, 2)
+#define KYRO_IOCTL_UVSTRIDE             _IO(KYRO_IOC_MAGIC, 3)
+#define KYRO_IOCTL_OVERLAY_OFFSET       _IO(KYRO_IOC_MAGIC, 4)
+#define KYRO_IOCTL_STRIDE               _IO(KYRO_IOC_MAGIC, 5)
+
+/*
+ * The follow 3 structures are used to pass data from user space into the kernel
+ * for the creation of overlay surfaces and setting the video mode.
+ */
+typedef struct _OVERLAY_CREATE {
+	u32 ulWidth;
+	u32 ulHeight;
+	int bLinear;
+} overlay_create;
+
+typedef struct _OVERLAY_VIEWPORT_SET {
+	u32 xOrgin;
+	u32 yOrgin;
+	u32 xSize;
+	u32 ySize;
+} overlay_viewport_set;
+
+typedef struct _SET_VIDEO_MODE {
+	u32 ulWidth;
+	u32 ulHeight;
+	u32 ulScan;
+	u8 displayDepth;
+	int bLinear;
+} set_video_mode;
+
+#endif /* _KYRO_H */
diff -puN init/main.c~linus init/main.c
--- 25/init/main.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/init/main.c	2004-01-19 22:17:24.000000000 -0800
@@ -105,7 +105,7 @@ int system_running;
 
 extern void time_init(void);
 /* Default late time init is NULL. archs can override this later. */
-void (*late_time_init)(void) = NULL;
+void (*late_time_init)(void);
 extern void softirq_init(void);
 
 static char *execute_command;
@@ -435,6 +435,7 @@ asmlinkage void __init start_kernel(void
 	page_address_init();
 	mem_init();
 	kmem_cache_init();
+	sort_main_extable();
 	if (late_time_init)
 		late_time_init();
 	calibrate_delay();
diff -puN kernel/cpu.c~linus kernel/cpu.c
--- 25/kernel/cpu.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/kernel/cpu.c	2004-01-19 22:17:24.000000000 -0800
@@ -14,7 +14,7 @@
 /* This protects CPUs going up and down... */
 DECLARE_MUTEX(cpucontrol);
 
-static struct notifier_block *cpu_chain = NULL;
+static struct notifier_block *cpu_chain;
 
 /* Need to know about CPUs going up/down? */
 int register_cpu_notifier(struct notifier_block *nb)
diff -puN kernel/dma.c~linus kernel/dma.c
--- 25/kernel/dma.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/kernel/dma.c	2004-01-19 22:17:24.000000000 -0800
@@ -136,20 +136,7 @@ static int proc_dma_show(struct seq_file
 
 static int proc_dma_open(struct inode *inode, struct file *file)
 {
-	char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
-	struct seq_file *m;
-	int res;
-
-	if (!buf)
-		return -ENOMEM;
-	res = single_open(file, proc_dma_show, NULL);
-	if (!res) {
-		m = file->private_data;
-		m->buf = buf;
-		m->size = PAGE_SIZE;
-	} else
-		kfree(buf);
-	return res;
+	return single_open(file, proc_dma_show, NULL);
 }
 
 static struct file_operations proc_dma_operations = {
diff -puN kernel/exit.c~linus kernel/exit.c
--- 25/kernel/exit.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/kernel/exit.c	2004-01-19 22:17:24.000000000 -0800
@@ -529,7 +529,8 @@ static inline void reparent_thread(task_
 	p->self_exec_id++;
 
 	if (p->pdeath_signal)
-		send_group_sig_info(p->pdeath_signal, 0, p);
+		/* We already hold the tasklist_lock here.  */
+		group_send_sig_info(p->pdeath_signal, (void *) 0, p);
 
 	/* Move the child from its dying parent to the new one.  */
 	if (unlikely(traced)) {
diff -puN kernel/extable.c~linus kernel/extable.c
--- 25/kernel/extable.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/kernel/extable.c	2004-01-19 22:17:24.000000000 -0800
@@ -16,11 +16,18 @@
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 #include <linux/module.h>
+#include <linux/init.h>
 #include <asm/uaccess.h>
 #include <asm/sections.h>
 
-extern const struct exception_table_entry __start___ex_table[];
-extern const struct exception_table_entry __stop___ex_table[];
+extern struct exception_table_entry __start___ex_table[];
+extern struct exception_table_entry __stop___ex_table[];
+
+/* Sort the kernel's built-in exception table */
+void __init sort_main_extable(void)
+{
+	sort_extable(__start___ex_table, __stop___ex_table);
+}
 
 /* Given an address, look for it in the exception tables. */
 const struct exception_table_entry *search_exception_tables(unsigned long addr)
diff -puN kernel/fork.c~linus kernel/fork.c
--- 25/kernel/fork.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/kernel/fork.c	2004-01-19 22:17:24.000000000 -0800
@@ -60,10 +60,9 @@ int nr_processes(void)
 	int cpu;
 	int total = 0;
 
-	for (cpu = 0; cpu < NR_CPUS; cpu++) {
-		if (cpu_online(cpu))
-			total += per_cpu(process_counts, cpu);
-	}
+	for_each_cpu(cpu)
+		total += per_cpu(process_counts, cpu);
+
 	return total;
 }
 
@@ -316,9 +315,9 @@ static inline int dup_mmap(struct mm_str
 				atomic_dec(&inode->i_writecount);
       
 			/* insert tmp into the share list, just after mpnt */
-			down(&inode->i_mapping->i_shared_sem);
+			down(&file->f_mapping->i_shared_sem);
 			list_add_tail(&tmp->shared, &mpnt->shared);
-			up(&inode->i_mapping->i_shared_sem);
+			up(&file->f_mapping->i_shared_sem);
 		}
 
 		/*
@@ -860,22 +859,6 @@ struct task_struct *copy_process(unsigne
 	if ((clone_flags & CLONE_SIGHAND) && !(clone_flags & CLONE_VM))
 		return ERR_PTR(-EINVAL);
 
-	/*
-	 * CLONE_DETACHED must match CLONE_THREAD: it's a historical
-	 * thing.
-	 */
-	if (!(clone_flags & CLONE_DETACHED) != !(clone_flags & CLONE_THREAD)) {
-		/* Warn about the old no longer supported case so that we see it */
-		if (clone_flags & CLONE_THREAD) {
-			static int count;
-			if (count < 5) {
-				count++;
-				printk(KERN_WARNING "%s trying to use CLONE_THREAD without CLONE_DETACH\n", current->comm);
-			}
-		}
-		return ERR_PTR(-EINVAL);
-	}
-
 	retval = security_task_create(clone_flags);
 	if (retval)
 		goto fork_out;
@@ -910,23 +893,7 @@ struct task_struct *copy_process(unsigne
 	if (p->binfmt && !try_module_get(p->binfmt->module))
 		goto bad_fork_cleanup_put_domain;
 
-#ifdef CONFIG_PREEMPT
-	/*
-	 * schedule_tail drops this_rq()->lock so we compensate with a count
-	 * of 1.  Also, we want to start with kernel preemption disabled.
-	 */
-	p->thread_info->preempt_count = 1;
-#endif
 	p->did_exec = 0;
-
-	/*
-	 * We mark the process as running here, but have not actually
-	 * inserted it onto the runqueue yet. This guarantees that
-	 * nobody will actually run it, and a signal or other external
-	 * event cannot wake it up and insert it on the runqueue either.
-	 */
-	p->state = TASK_RUNNING;
-
 	copy_flags(clone_flags, p);
 	if (clone_flags & CLONE_IDLETASK)
 		p->pid = 0;
@@ -942,15 +909,12 @@ struct task_struct *copy_process(unsigne
 
 	p->proc_dentry = NULL;
 
-	INIT_LIST_HEAD(&p->run_list);
-
 	INIT_LIST_HEAD(&p->children);
 	INIT_LIST_HEAD(&p->sibling);
 	INIT_LIST_HEAD(&p->posix_timers);
 	init_waitqueue_head(&p->wait_chldexit);
 	p->vfork_done = NULL;
 	spin_lock_init(&p->alloc_lock);
-	spin_lock_init(&p->switch_lock);
 	spin_lock_init(&p->proc_lock);
 
 	clear_tsk_thread_flag(p, TIF_SIGPENDING);
@@ -965,7 +929,6 @@ struct task_struct *copy_process(unsigne
 	p->tty_old_pgrp = 0;
 	p->utime = p->stime = 0;
 	p->cutime = p->cstime = 0;
-	p->array = NULL;
 	p->lock_depth = -1;		/* -1 = no lock */
 	p->start_time = get_jiffies_64();
 	p->security = NULL;
@@ -1014,38 +977,12 @@ struct task_struct *copy_process(unsigne
 	p->exit_signal = (clone_flags & CLONE_THREAD) ? -1 : (clone_flags & CSIGNAL);
 	p->pdeath_signal = 0;
 
+	/* Perform scheduler related setup */
+	sched_fork(p);
+
 	/*
-	 * Share the timeslice between parent and child, thus the
-	 * total amount of pending timeslices in the system doesn't change,
-	 * resulting in more scheduling fairness.
-	 */
-	local_irq_disable();
-        p->time_slice = (current->time_slice + 1) >> 1;
-	/*
-	 * The remainder of the first timeslice might be recovered by
-	 * the parent if the child exits early enough.
-	 */
-	p->first_time_slice = 1;
-	current->time_slice >>= 1;
-	p->timestamp = sched_clock();
-	if (!current->time_slice) {
-		/*
-	 	 * This case is rare, it happens when the parent has only
-	 	 * a single jiffy left from its timeslice. Taking the
-		 * runqueue lock is not a problem.
-		 */
-		current->time_slice = 1;
-		preempt_disable();
-		scheduler_tick(0, 0);
-		local_irq_enable();
-		preempt_enable();
-	} else
-		local_irq_enable();
-	/*
-	 * Ok, add it to the run-queues and make it
-	 * visible to the rest of the system.
-	 *
-	 * Let it rip!
+	 * Ok, make it visible to the rest of the system.
+	 * We dont wake it up yet.
 	 */
 	p->tgid = p->pid;
 	p->group_leader = p;
diff -puN kernel/futex.c~linus kernel/futex.c
--- 25/kernel/futex.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/kernel/futex.c	2004-01-19 22:17:24.000000000 -0800
@@ -577,6 +577,7 @@ static int futex_fd(unsigned long uaddr,
 	filp->f_op = &futex_fops;
 	filp->f_vfsmnt = mntget(futex_mnt);
 	filp->f_dentry = dget(futex_mnt->mnt_root);
+	filp->f_mapping = filp->f_dentry->d_inode->i_mapping;
 
 	if (signal) {
 		int err;
diff -puN kernel/module.c~linus kernel/module.c
--- 25/kernel/module.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/kernel/module.c	2004-01-19 22:17:24.000000000 -0800
@@ -687,8 +687,8 @@ sys_delete_module(const char __user *nam
 		goto out;
 	}
 
-	/* Already dying? */
-	if (mod->state == MODULE_STATE_GOING) {
+	/* Doing init or already dying? */
+	if (mod->state != MODULE_STATE_LIVE) {
 		/* FIXME: if (force), slam module count and wake up
                    waiter --RR */
 		DEBUGP("%s already dying\n", mod->name);
@@ -1395,6 +1395,7 @@ static struct module *load_module(void _
 	struct module *mod;
 	long err = 0;
 	void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */
+	struct exception_table_entry *extable;
 
 	DEBUGP("load_module: umod=%p, len=%lu, uargs=%p\n",
 	       umod, len, uargs);
@@ -1611,10 +1612,6 @@ static struct module *load_module(void _
 	}
 #endif
 
-  	/* Set up exception table */
-	mod->num_exentries = sechdrs[exindex].sh_size / sizeof(*mod->extable);
-	mod->extable = (void *)sechdrs[exindex].sh_addr;
-
 	/* Now do relocations. */
 	for (i = 1; i < hdr->e_shnum; i++) {
 		const char *strtab = (char *)sechdrs[strindex].sh_addr;
@@ -1637,6 +1634,11 @@ static struct module *load_module(void _
 			goto cleanup;
 	}
 
+  	/* Set up and sort exception table */
+	mod->num_exentries = sechdrs[exindex].sh_size / sizeof(*mod->extable);
+	mod->extable = extable = (void *)sechdrs[exindex].sh_addr;
+	sort_extable(extable, extable + mod->num_exentries);
+
 	/* Finally, copy percpu area over. */
 	percpu_modcopy(mod->percpu, (void *)sechdrs[pcpuindex].sh_addr,
 		       sechdrs[pcpuindex].sh_size);
diff -puN kernel/posix-timers.c~linus kernel/posix-timers.c
--- 25/kernel/posix-timers.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/kernel/posix-timers.c	2004-01-19 22:17:24.000000000 -0800
@@ -574,7 +574,7 @@ static struct k_itimer * lock_timer(time
  * it is the same as a requeue pending timer WRT to what we should
  * report.
  */
-void inline
+static void
 do_timer_gettime(struct k_itimer *timr, struct itimerspec *cur_setting)
 {
 	unsigned long expires;
diff -puN kernel/printk.c~linus kernel/printk.c
--- 25/kernel/printk.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/kernel/printk.c	2004-01-19 22:17:24.000000000 -0800
@@ -763,3 +763,45 @@ void tty_write_message(struct tty_struct
 		tty->driver->write(tty, 0, msg, strlen(msg));
 	return;
 }
+
+/* minimum time in jiffies between messages */
+int printk_ratelimit_jiffies = 5*HZ;
+
+/* number of messages we send before ratelimiting */
+int printk_ratelimit_burst = 10;
+
+/*
+ * printk rate limiting, lifted from the networking subsystem.
+ *
+ * This enforces a rate limit: not more than one kernel message
+ * every printk_ratelimit_jiffies to make a denial-of-service
+ * attack impossible.
+ */
+int printk_ratelimit(void)
+{
+	static spinlock_t ratelimit_lock = SPIN_LOCK_UNLOCKED;
+	static unsigned long toks = 10*5*HZ;
+	static unsigned long last_msg;
+	static int missed;
+	unsigned long flags;
+	unsigned long now = jiffies;
+
+	spin_lock_irqsave(&ratelimit_lock, flags);
+	toks += now - last_msg;
+	last_msg = now;
+	if (toks > (printk_ratelimit_burst * printk_ratelimit_jiffies))
+		toks = printk_ratelimit_burst * printk_ratelimit_jiffies;
+	if (toks >= printk_ratelimit_jiffies) {
+		int lost = missed;
+		missed = 0;
+		toks -= printk_ratelimit_jiffies;
+		spin_unlock_irqrestore(&ratelimit_lock, flags);
+		if (lost)
+			printk(KERN_WARNING "printk: %d messages suppressed.\n", lost);
+		return 1;
+	}
+	missed++;
+	spin_unlock_irqrestore(&ratelimit_lock, flags);
+	return 0;
+}
+EXPORT_SYMBOL(printk_ratelimit);
diff -puN kernel/sched.c~linus kernel/sched.c
--- 25/kernel/sched.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/kernel/sched.c	2004-01-19 22:17:24.000000000 -0800
@@ -79,13 +79,13 @@
  */
 #define MIN_TIMESLICE		( 10 * HZ / 1000)
 #define MAX_TIMESLICE		(200 * HZ / 1000)
-#define ON_RUNQUEUE_WEIGHT	30
-#define CHILD_PENALTY		95
+#define ON_RUNQUEUE_WEIGHT	 30
+#define CHILD_PENALTY		 95
 #define PARENT_PENALTY		100
-#define EXIT_WEIGHT		3
-#define PRIO_BONUS_RATIO	25
+#define EXIT_WEIGHT		  3
+#define PRIO_BONUS_RATIO	 25
 #define MAX_BONUS		(MAX_USER_PRIO * PRIO_BONUS_RATIO / 100)
-#define INTERACTIVE_DELTA	2
+#define INTERACTIVE_DELTA	  2
 #define MAX_SLEEP_AVG		(AVG_TIMESLICE * MAX_BONUS)
 #define STARVATION_LIMIT	(MAX_SLEEP_AVG)
 #define NS_MAX_SLEEP_AVG	(JIFFIES_TO_NS(MAX_SLEEP_AVG))
@@ -143,7 +143,7 @@
 #define TASK_INTERACTIVE(p) \
 	((p)->prio <= (p)->static_prio - DELTA(p))
 
-#define JUST_INTERACTIVE_SLEEP(p) \
+#define INTERACTIVE_SLEEP(p) \
 	(JIFFIES_TO_NS(MAX_SLEEP_AVG * \
 		(MAX_BONUS / 2 + DELTA((p)) + 1) / MAX_BONUS - 1))
 
@@ -168,7 +168,8 @@
  */
 
 #define BASE_TIMESLICE(p) (MIN_TIMESLICE + \
-	((MAX_TIMESLICE - MIN_TIMESLICE) * (MAX_PRIO-1-(p)->static_prio)/(MAX_USER_PRIO - 1)))
+		((MAX_TIMESLICE - MIN_TIMESLICE) * \
+			(MAX_PRIO-1 - (p)->static_prio) / (MAX_USER_PRIO-1)))
 
 static inline unsigned int task_timeslice(task_t *p)
 {
@@ -199,11 +200,11 @@ struct prio_array {
 struct runqueue {
 	spinlock_t lock;
 	unsigned long nr_running, nr_switches, expired_timestamp,
-			nr_uninterruptible;
+		      nr_uninterruptible, timestamp_last_tick;
 	task_t *curr, *idle;
 	struct mm_struct *prev_mm;
 	prio_array_t *active, *expired, arrays[2];
-	int prev_cpu_load[NR_CPUS];
+	int best_expired_prio, prev_cpu_load[NR_CPUS];
 #ifdef CONFIG_NUMA
 	atomic_t *node_nr_running;
 	int prev_node_load[MAX_NUMNODES];
@@ -225,7 +226,7 @@ static DEFINE_PER_CPU(struct runqueue, r
  * Default context-switch locking:
  */
 #ifndef prepare_arch_switch
-# define prepare_arch_switch(rq, next)	do { } while(0)
+# define prepare_arch_switch(rq, next)	do { } while (0)
 # define finish_arch_switch(rq, next)	spin_unlock_irq(&(rq)->lock)
 # define task_running(rq, p)		((rq)->curr == (p))
 #endif
@@ -269,9 +270,9 @@ __init void node_nr_running_init(void)
 
 #else /* !CONFIG_NUMA */
 
-# define nr_running_init(rq)   do { } while (0)
-# define nr_running_inc(rq)    do { (rq)->nr_running++; } while (0)
-# define nr_running_dec(rq)    do { (rq)->nr_running--; } while (0)
+# define nr_running_init(rq)	do { } while (0)
+# define nr_running_inc(rq)	do { (rq)->nr_running++; } while (0)
+# define nr_running_dec(rq)	do { (rq)->nr_running--; } while (0)
 
 #endif /* CONFIG_NUMA */
 
@@ -396,7 +397,7 @@ static void recalc_task_prio(task_t *p, 
 		 * other processes.
 		 */
 		if (p->mm && p->activated != -1 &&
-			sleep_time > JUST_INTERACTIVE_SLEEP(p)){
+			sleep_time > INTERACTIVE_SLEEP(p)) {
 				p->sleep_avg = JIFFIES_TO_NS(MAX_SLEEP_AVG -
 						AVG_TIMESLICE);
 				if (!HIGH_CREDIT(p))
@@ -413,37 +414,35 @@ static void recalc_task_prio(task_t *p, 
 			 * one timeslice worth of sleep avg bonus.
 			 */
 			if (LOW_CREDIT(p) &&
-				sleep_time > JIFFIES_TO_NS(task_timeslice(p)))
-					sleep_time =
-						JIFFIES_TO_NS(task_timeslice(p));
+			    sleep_time > JIFFIES_TO_NS(task_timeslice(p)))
+				sleep_time = JIFFIES_TO_NS(task_timeslice(p));
 
 			/*
 			 * Non high_credit tasks waking from uninterruptible
 			 * sleep are limited in their sleep_avg rise as they
 			 * are likely to be cpu hogs waiting on I/O
 			 */
-			if (p->activated == -1 && !HIGH_CREDIT(p) && p->mm){
-				if (p->sleep_avg >= JUST_INTERACTIVE_SLEEP(p))
+			if (p->activated == -1 && !HIGH_CREDIT(p) && p->mm) {
+				if (p->sleep_avg >= INTERACTIVE_SLEEP(p))
 					sleep_time = 0;
 				else if (p->sleep_avg + sleep_time >=
-					JUST_INTERACTIVE_SLEEP(p)){
-						p->sleep_avg =
-							JUST_INTERACTIVE_SLEEP(p);
-						sleep_time = 0;
-					}
+						INTERACTIVE_SLEEP(p)) {
+					p->sleep_avg = INTERACTIVE_SLEEP(p);
+					sleep_time = 0;
+				}
 			}
 
 			/*
 			 * This code gives a bonus to interactive tasks.
 			 *
 			 * The boost works by updating the 'average sleep time'
-			 * value here, based on ->timestamp. The more time a task
-			 * spends sleeping, the higher the average gets - and the
-			 * higher the priority boost gets as well.
+			 * value here, based on ->timestamp. The more time a
+			 * task spends sleeping, the higher the average gets -
+			 * and the higher the priority boost gets as well.
 			 */
 			p->sleep_avg += sleep_time;
 
-			if (p->sleep_avg > NS_MAX_SLEEP_AVG){
+			if (p->sleep_avg > NS_MAX_SLEEP_AVG) {
 				p->sleep_avg = NS_MAX_SLEEP_AVG;
 				if (!HIGH_CREDIT(p))
 					p->interactive_credit++;
@@ -470,7 +469,7 @@ static inline void activate_task(task_t 
 	 * This checks to make sure it's not an uninterruptible task
 	 * that is now waking up.
 	 */
-	if (!p->activated){
+	if (!p->activated) {
 		/*
 		 * Tasks which were woken up by interrupts (ie. hw events)
 		 * are most likely of interactive nature. So we give them
@@ -480,13 +479,14 @@ static inline void activate_task(task_t 
 		 */
 		if (in_interrupt())
 			p->activated = 2;
-		else
-		/*
-		 * Normal first-time wakeups get a credit too for on-runqueue
-		 * time, but it will be weighted down:
-		 */
+		else {
+			/*
+			 * Normal first-time wakeups get a credit too for
+			 * on-runqueue time, but it will be weighted down:
+			 */
 			p->activated = 1;
 		}
+	}
 	p->timestamp = now;
 
 	__activate_task(p, rq);
@@ -540,6 +540,43 @@ inline int task_curr(task_t *p)
 }
 
 #ifdef CONFIG_SMP
+typedef struct {
+	struct list_head list;
+	task_t *task;
+	struct completion done;
+} migration_req_t;
+
+/*
+ * The task's runqueue lock must be held, and the new mask must be valid.
+ * Returns true if you have to wait for migration thread.
+ */
+static int __set_cpus_allowed(task_t *p, cpumask_t new_mask,
+				migration_req_t *req)
+{
+	runqueue_t *rq = task_rq(p);
+
+	p->cpus_allowed = new_mask;
+	/*
+	 * Can the task run on the task's current CPU? If not then
+	 * migrate the thread off to a proper CPU.
+	 */
+	if (cpu_isset(task_cpu(p), new_mask))
+		return 0;
+
+	/*
+	 * If the task is not on a runqueue (and not running), then
+	 * it is sufficient to simply update the task's cpu field.
+	 */
+	if (!p->array && !task_running(rq, p)) {
+		set_task_cpu(p, any_online_cpu(p->cpus_allowed));
+		return 0;
+	}
+
+	init_completion(&req->done);
+	req->task = p;
+	list_add(&req->list, &rq->migration_queue);
+	return 1;
+}
 
 /*
  * wait_task_inactive - wait for a thread to unschedule.
@@ -632,13 +669,14 @@ repeat_lock_task:
 			 */
 			if (unlikely(sync && !task_running(rq, p) &&
 				(task_cpu(p) != smp_processor_id()) &&
-				cpu_isset(smp_processor_id(), p->cpus_allowed))) {
+					cpu_isset(smp_processor_id(),
+							p->cpus_allowed))) {
 
 				set_task_cpu(p, smp_processor_id());
 				task_rq_unlock(rq, &flags);
 				goto repeat_lock_task;
 			}
-			if (old_state == TASK_UNINTERRUPTIBLE){
+			if (old_state == TASK_UNINTERRUPTIBLE) {
 				rq->nr_uninterruptible--;
 				/*
 				 * Tasks on involuntary sleep don't earn
@@ -663,7 +701,8 @@ repeat_lock_task:
 }
 int wake_up_process(task_t * p)
 {
-	return try_to_wake_up(p, TASK_STOPPED | TASK_INTERRUPTIBLE | TASK_UNINTERRUPTIBLE, 0);
+	return try_to_wake_up(p, TASK_STOPPED |
+		       		 TASK_INTERRUPTIBLE | TASK_UNINTERRUPTIBLE, 0);
 }
 
 EXPORT_SYMBOL(wake_up_process);
@@ -674,6 +713,60 @@ int wake_up_state(task_t *p, unsigned in
 }
 
 /*
+ * Perform scheduler related setup for a newly forked process p.
+ * p is forked by current.
+ */
+void sched_fork(task_t *p)
+{
+	/*
+	 * We mark the process as running here, but have not actually
+	 * inserted it onto the runqueue yet. This guarantees that
+	 * nobody will actually run it, and a signal or other external
+	 * event cannot wake it up and insert it on the runqueue either.
+	 */
+	p->state = TASK_RUNNING;
+	INIT_LIST_HEAD(&p->run_list);
+	p->array = NULL;
+	spin_lock_init(&p->switch_lock);
+#ifdef CONFIG_PREEMPT
+	/*
+	 * During context-switch we hold precisely one spinlock, which
+	 * schedule_tail drops. (in the common case it's this_rq()->lock,
+	 * but it also can be p->switch_lock.) So we compensate with a count
+	 * of 1. Also, we want to start with kernel preemption disabled.
+	 */
+	p->thread_info->preempt_count = 1;
+#endif
+	/*
+	 * Share the timeslice between parent and child, thus the
+	 * total amount of pending timeslices in the system doesn't change,
+	 * resulting in more scheduling fairness.
+	 */
+	local_irq_disable();
+	p->time_slice = (current->time_slice + 1) >> 1;
+	/*
+	 * The remainder of the first timeslice might be recovered by
+	 * the parent if the child exits early enough.
+	 */
+	p->first_time_slice = 1;
+	current->time_slice >>= 1;
+	p->timestamp = sched_clock();
+	if (!current->time_slice) {
+		/*
+	 	 * This case is rare, it happens when the parent has only
+	 	 * a single jiffy left from its timeslice. Taking the
+		 * runqueue lock is not a problem.
+		 */
+		current->time_slice = 1;
+		preempt_disable();
+		scheduler_tick(0, 0);
+		local_irq_enable();
+		preempt_enable();
+	} else
+		local_irq_enable();
+}
+
+/*
  * wake_up_forked_process - wake up a freshly forked process.
  *
  * This function will do some initial scheduler statistics housekeeping
@@ -800,7 +893,8 @@ asmlinkage void schedule_tail(task_t *pr
  * context_switch - switch to the new MM and the new
  * thread's register state.
  */
-static inline task_t * context_switch(runqueue_t *rq, task_t *prev, task_t *next)
+static inline
+task_t * context_switch(runqueue_t *rq, task_t *prev, task_t *next)
 {
 	struct mm_struct *mm = next->mm;
 	struct mm_struct *oldmm = prev->active_mm;
@@ -845,11 +939,9 @@ unsigned long nr_uninterruptible(void)
 {
 	unsigned long i, sum = 0;
 
-	for (i = 0; i < NR_CPUS; i++) {
-		if (!cpu_online(i))
-			continue;
+	for_each_cpu(i)
 		sum += cpu_rq(i)->nr_uninterruptible;
-	}
+
 	return sum;
 }
 
@@ -857,11 +949,9 @@ unsigned long nr_context_switches(void)
 {
 	unsigned long i, sum = 0;
 
-	for (i = 0; i < NR_CPUS; i++) {
-		if (!cpu_online(i))
-			continue;
+	for_each_cpu(i)
 		sum += cpu_rq(i)->nr_switches;
-	}
+
 	return sum;
 }
 
@@ -869,11 +959,9 @@ unsigned long nr_iowait(void)
 {
 	unsigned long i, sum = 0;
 
-	for (i = 0; i < NR_CPUS; ++i) {
-		if (!cpu_online(i))
-			continue;
+	for_each_cpu(i)
 		sum += atomic_read(&cpu_rq(i)->nr_iowait);
-	}
+
 	return sum;
 }
 
@@ -920,16 +1008,34 @@ static inline void double_rq_unlock(runq
  */
 static void sched_migrate_task(task_t *p, int dest_cpu)
 {
-	cpumask_t old_mask;
+	runqueue_t *rq;
+	migration_req_t req;
+	unsigned long flags;
+	cpumask_t old_mask, new_mask = cpumask_of_cpu(dest_cpu);
 
+	rq = task_rq_lock(p, &flags);
 	old_mask = p->cpus_allowed;
-	if (!cpu_isset(dest_cpu, old_mask))
-		return;
+	if (!cpu_isset(dest_cpu, old_mask) || !cpu_online(dest_cpu))
+		goto out;
+
 	/* force the process onto the specified CPU */
-	set_cpus_allowed(p, cpumask_of_cpu(dest_cpu));
+	if (__set_cpus_allowed(p, new_mask, &req)) {
+		/* Need to wait for migration thread. */
+		task_rq_unlock(rq, &flags);
+		wake_up_process(rq->migration_thread);
+		wait_for_completion(&req.done);
 
-	/* restore the cpus allowed mask */
-	set_cpus_allowed(p, old_mask);
+		/* If we raced with sys_sched_setaffinity, don't
+		 * restore mask. */
+		rq = task_rq_lock(p, &flags);
+		if (likely(cpus_equal(p->cpus_allowed, new_mask))) {
+			/* Restore old mask: won't need migration
+			 * thread, since current cpu is allowed. */
+			BUG_ON(__set_cpus_allowed(p, old_mask, NULL));
+		}
+	}
+out:
+	task_rq_unlock(rq, &flags);
 }
 
 /*
@@ -948,10 +1054,10 @@ static int sched_best_cpu(struct task_st
 	minload = 10000000;
 	for_each_node_with_cpus(i) {
 		/*
-		 * Node load is always divided by nr_cpus_node to normalise 
+		 * Node load is always divided by nr_cpus_node to normalise
 		 * load values in case cpu count differs from node to node.
 		 * We first multiply node_nr_running by 10 to get a little
-		 * better resolution.   
+		 * better resolution.
 		 */
 		load = 10 * atomic_read(&node_nr_running[i]) / nr_cpus_node(i);
 		if (load < minload) {
@@ -990,7 +1096,7 @@ void sched_balance_exec(void)
  *      load_{t} = load_{t-1}/2 + nr_node_running_{t}
  * This way sudden load peaks are flattened out a bit.
  * Node load is divided by nr_cpus_node() in order to compare nodes
- * of different cpu count but also [first] multiplied by 10 to 
+ * of different cpu count but also [first] multiplied by 10 to
  * provide better resolution.
  */
 static int find_busiest_node(int this_node)
@@ -1028,8 +1134,10 @@ static int find_busiest_node(int this_no
  * this_rq is locked already. Recalculate nr_running if we have to
  * drop the runqueue lock.
  */
-static inline unsigned int double_lock_balance(runqueue_t *this_rq,
-	runqueue_t *busiest, int this_cpu, int idle, unsigned int nr_running)
+static inline
+unsigned int double_lock_balance(runqueue_t *this_rq, runqueue_t *busiest,
+				 int this_cpu, int idle,
+				 unsigned int nr_running)
 {
 	if (unlikely(!spin_trylock(&busiest->lock))) {
 		if (busiest < this_rq) {
@@ -1037,7 +1145,8 @@ static inline unsigned int double_lock_b
 			spin_lock(&busiest->lock);
 			spin_lock(&this_rq->lock);
 			/* Need to recalculate nr_running */
-			if (idle || (this_rq->nr_running > this_rq->prev_cpu_load[this_cpu]))
+			if (idle || (this_rq->nr_running >
+					this_rq->prev_cpu_load[this_cpu]))
 				nr_running = this_rq->nr_running;
 			else
 				nr_running = this_rq->prev_cpu_load[this_cpu];
@@ -1050,7 +1159,9 @@ static inline unsigned int double_lock_b
 /*
  * find_busiest_queue - find the busiest runqueue among the cpus in cpumask.
  */
-static inline runqueue_t *find_busiest_queue(runqueue_t *this_rq, int this_cpu, int idle, int *imbalance, cpumask_t cpumask)
+static inline
+runqueue_t *find_busiest_queue(runqueue_t *this_rq, int this_cpu, int idle,
+			       int *imbalance, cpumask_t cpumask)
 {
 	int nr_running, load, max_load, i;
 	runqueue_t *busiest, *rq_src;
@@ -1113,7 +1224,8 @@ static inline runqueue_t *find_busiest_q
 		goto out;
 	}
 
-	nr_running = double_lock_balance(this_rq, busiest, this_cpu, idle, nr_running);
+	nr_running = double_lock_balance(this_rq, busiest, this_cpu,
+					 idle, nr_running);
 	/*
 	 * Make sure nothing changed since we checked the
 	 * runqueue length.
@@ -1130,13 +1242,17 @@ out:
  * pull_task - move a task from a remote runqueue to the local runqueue.
  * Both runqueues must be locked.
  */
-static inline void pull_task(runqueue_t *src_rq, prio_array_t *src_array, task_t *p, runqueue_t *this_rq, int this_cpu)
+static inline
+void pull_task(runqueue_t *src_rq, prio_array_t *src_array, task_t *p,
+	       runqueue_t *this_rq, int this_cpu)
 {
 	dequeue_task(p, src_array);
 	nr_running_dec(src_rq);
 	set_task_cpu(p, this_cpu);
 	nr_running_inc(this_rq);
 	enqueue_task(p, this_rq->active);
+	p->timestamp = sched_clock() -
+				(src_rq->timestamp_last_tick - p->timestamp);
 	/*
 	 * Note that idle threads have a prio of MAX_PRIO, for this test
 	 * to be always true for them.
@@ -1146,25 +1262,25 @@ static inline void pull_task(runqueue_t 
 }
 
 /*
- * Previously:
- *
- * #define CAN_MIGRATE_TASK(p,rq,this_cpu)	\
- *	((!idle || (NS_TO_JIFFIES(now - (p)->timestamp) > \
- *		cache_decay_ticks)) && !task_running(rq, p) && \
- *			cpu_isset(this_cpu, (p)->cpus_allowed))
+ * can_migrate_task - may task p from runqueue rq be migrated to this_cpu?
  */
-
-static inline int
-can_migrate_task(task_t *tsk, runqueue_t *rq, int this_cpu, int idle)
+static inline
+int can_migrate_task(task_t *tsk, runqueue_t *rq, int this_cpu, int idle)
 {
-	unsigned long delta = sched_clock() - tsk->timestamp;
+	unsigned long delta = rq->timestamp_last_tick - tsk->timestamp;
 
-	if (!idle && (delta <= JIFFIES_TO_NS(cache_decay_ticks)))
-		return 0;
+	/*
+	 * We do not migrate tasks that are:
+	 * 1) running (obviously), or
+	 * 2) cannot be migrated to this CPU due to cpus_allowed, or
+	 * 3) are cache-hot on their current CPU.
+	 */
 	if (task_running(rq, tsk))
 		return 0;
 	if (!cpu_isset(this_cpu, tsk->cpus_allowed))
 		return 0;
+	if (!idle && (delta <= JIFFIES_TO_NS(cache_decay_ticks)))
+		return 0;
 	return 1;
 }
 
@@ -1184,7 +1300,8 @@ static void load_balance(runqueue_t *thi
 	struct list_head *head, *curr;
 	task_t *tmp;
 
-	busiest = find_busiest_queue(this_rq, this_cpu, idle, &imbalance, cpumask);
+	busiest = find_busiest_queue(this_rq, this_cpu, idle,
+				     &imbalance, cpumask);
 	if (!busiest)
 		goto out;
 
@@ -1226,13 +1343,6 @@ skip_bitmap:
 skip_queue:
 	tmp = list_entry(curr, task_t, run_list);
 
-	/*
-	 * We do not migrate tasks that are:
-	 * 1) running (obviously), or
-	 * 2) cannot be migrated to this CPU due to cpus_allowed, or
-	 * 3) are cache-hot on their current CPU.
-	 */
-
 	curr = curr->prev;
 
 	if (!can_migrate_task(tmp, busiest, this_cpu, idle)) {
@@ -1242,6 +1352,8 @@ skip_queue:
 		goto skip_bitmap;
 	}
 	pull_task(busiest, array, tmp, this_rq, this_cpu);
+
+	/* Only migrate one task if we are idle */
 	if (!idle && --imbalance) {
 		if (curr != head)
 			goto skip_queue;
@@ -1331,7 +1443,7 @@ static inline void rebalance_tick(runque
 }
 #endif
 
-DEFINE_PER_CPU(struct kernel_stat, kstat) = { { 0 } };
+DEFINE_PER_CPU(struct kernel_stat, kstat);
 
 EXPORT_PER_CPU_SYMBOL(kstat);
 
@@ -1342,12 +1454,14 @@ EXPORT_PER_CPU_SYMBOL(kstat);
  * interactivity of a task if the first expired task had to wait more
  * than a 'reasonable' amount of time. This deadline timeout is
  * load-dependent, as the frequency of array switched decreases with
- * increasing number of running tasks:
+ * increasing number of running tasks. We also ignore the interactivity
+ * if a better static_prio task has expired:
  */
 #define EXPIRED_STARVING(rq) \
-		(STARVATION_LIMIT && ((rq)->expired_timestamp && \
+	((STARVATION_LIMIT && ((rq)->expired_timestamp && \
 		(jiffies - (rq)->expired_timestamp >= \
-			STARVATION_LIMIT * ((rq)->nr_running) + 1)))
+			STARVATION_LIMIT * ((rq)->nr_running) + 1))) || \
+			((rq)->curr->static_prio > (rq)->best_expired_prio))
 
 /*
  * This function gets called by the timer code, with HZ frequency.
@@ -1363,6 +1477,8 @@ void scheduler_tick(int user_ticks, int 
 	runqueue_t *rq = this_rq();
 	task_t *p = current;
 
+	rq->timestamp_last_tick = sched_clock();
+
 	if (rcu_pending(cpu))
 		rcu_check_callbacks(cpu, user_ticks);
 
@@ -1429,6 +1545,8 @@ void scheduler_tick(int user_ticks, int 
 			rq->expired_timestamp = jiffies;
 		if (!TASK_INTERACTIVE(p) || EXPIRED_STARVING(rq)) {
 			enqueue_task(p, rq->expired);
+			if (p->static_prio < rq->best_expired_prio)
+				rq->best_expired_prio = p->static_prio;
 		} else
 			enqueue_task(p, rq->active);
 	} else {
@@ -1549,6 +1667,7 @@ need_resched:
 		rq->expired = array;
 		array = rq->active;
 		rq->expired_timestamp = 0;
+		rq->best_expired_prio = MAX_PRIO;
 	}
 
 	idx = sched_find_first_bit(array->bitmap);
@@ -1573,7 +1692,7 @@ switch_tasks:
 	RCU_qsctr(task_cpu(prev))++;
 
 	prev->sleep_avg -= run_time;
-	if ((long)prev->sleep_avg <= 0){
+	if ((long)prev->sleep_avg <= 0) {
 		prev->sleep_avg = 0;
 		if (!(HIGH_CREDIT(prev) || LOW_CREDIT(prev)))
 			prev->interactive_credit--;
@@ -1650,7 +1769,8 @@ EXPORT_SYMBOL(default_wake_function);
  * started to run but is not in state TASK_RUNNING.  try_to_wake_up() returns
  * zero in this (rare) case, and we handle it by continuing to scan the queue.
  */
-static void __wake_up_common(wait_queue_head_t *q, unsigned int mode, int nr_exclusive, int sync)
+static void __wake_up_common(wait_queue_head_t *q, unsigned int mode,
+			     int nr_exclusive, int sync)
 {
 	struct list_head *tmp, *next;
 
@@ -1727,7 +1847,8 @@ void complete(struct completion *x)
 
 	spin_lock_irqsave(&x->wait.lock, flags);
 	x->done++;
-	__wake_up_common(&x->wait, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, 1, 0);
+	__wake_up_common(&x->wait, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE,
+			 1, 0);
 	spin_unlock_irqrestore(&x->wait.lock, flags);
 }
 
@@ -1739,7 +1860,8 @@ void complete_all(struct completion *x)
 
 	spin_lock_irqsave(&x->wait.lock, flags);
 	x->done += UINT_MAX/2;
-	__wake_up_common(&x->wait, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, 0, 0);
+	__wake_up_common(&x->wait, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE,
+			 0, 0);
 	spin_unlock_irqrestore(&x->wait.lock, flags);
 }
 
@@ -1766,9 +1888,9 @@ void wait_for_completion(struct completi
 
 EXPORT_SYMBOL(wait_for_completion);
 
-#define	SLEEP_ON_VAR				\
-	unsigned long flags;			\
-	wait_queue_t wait;			\
+#define	SLEEP_ON_VAR					\
+	unsigned long flags;				\
+	wait_queue_t wait;				\
 	init_waitqueue_entry(&wait, current);
 
 #define SLEEP_ON_HEAD					\
@@ -1776,9 +1898,9 @@ EXPORT_SYMBOL(wait_for_completion);
 	__add_wait_queue(q, &wait);			\
 	spin_unlock(&q->lock);
 
-#define	SLEEP_ON_TAIL						\
-	spin_lock_irq(&q->lock);				\
-	__remove_wait_queue(q, &wait);				\
+#define	SLEEP_ON_TAIL					\
+	spin_lock_irq(&q->lock);			\
+	__remove_wait_queue(q, &wait);			\
 	spin_unlock_irqrestore(&q->lock, flags);
 
 void interruptible_sleep_on(wait_queue_head_t *q)
@@ -1903,9 +2025,9 @@ asmlinkage long sys_nice(int increment)
 	long nice;
 
 	/*
-	 *	Setpriority might change our priority at the same moment.
-	 *	We don't have to worry. Conceptually one call occurs first
-	 *	and we have a single winner.
+	 * Setpriority might change our priority at the same moment.
+	 * We don't have to worry. Conceptually one call occurs first
+	 * and we have a single winner.
 	 */
 	if (increment < 0) {
 		if (!capable(CAP_SYS_NICE))
@@ -2062,7 +2184,7 @@ static int setscheduler(pid_t pid, int p
 		 * our priority decreased, or if we are not currently running on
 		 * this runqueue and our priority is higher than the current's
 		 */
-		if (rq->curr == p) {
+		if (task_running(rq, p)) {
 			if (p->prio > oldprio)
 				resched_task(rq->curr);
 		} else if (p->prio < rq->curr->prio)
@@ -2085,7 +2207,7 @@ out_nounlock:
  * @param: structure containing the new RT priority.
  */
 asmlinkage long sys_sched_setscheduler(pid_t pid, int policy,
-				      struct sched_param __user *param)
+				       struct sched_param __user *param)
 {
 	return setscheduler(pid, policy, param);
 }
@@ -2392,7 +2514,8 @@ asmlinkage long sys_sched_get_priority_m
  * this syscall writes the default timeslice value of a given process
  * into the user-space timespec buffer. A value of '0' means infinity.
  */
-asmlinkage long sys_sched_rr_get_interval(pid_t pid, struct timespec __user *interval)
+asmlinkage
+long sys_sched_rr_get_interval(pid_t pid, struct timespec __user *interval)
 {
 	int retval = -EINVAL;
 	struct timespec t;
@@ -2560,12 +2683,6 @@ void __init init_idle(task_t *idle, int 
  * 7) we wake up and the migration is done.
  */
 
-typedef struct {
-	struct list_head list;
-	task_t *task;
-	struct completion done;
-} migration_req_t;
-
 /*
  * Change a given task's CPU affinity. Migrate the thread to a
  * proper CPU and schedule it away if the CPU it's executing on
@@ -2578,40 +2695,26 @@ typedef struct {
 int set_cpus_allowed(task_t *p, cpumask_t new_mask)
 {
 	unsigned long flags;
+	int ret = 0;
 	migration_req_t req;
 	runqueue_t *rq;
 
-	if (any_online_cpu(new_mask) == NR_CPUS)
-		return -EINVAL;
-
 	rq = task_rq_lock(p, &flags);
-	p->cpus_allowed = new_mask;
-	/*
-	 * Can the task run on the task's current CPU? If not then
-	 * migrate the thread off to a proper CPU.
-	 */
-	if (cpu_isset(task_cpu(p), new_mask)) {
-		task_rq_unlock(rq, &flags);
-		return 0;
+	if (any_online_cpu(new_mask) == NR_CPUS) {
+		ret = -EINVAL;
+		goto out;
 	}
-	/*
-	 * If the task is not on a runqueue (and not running), then
-	 * it is sufficient to simply update the task's cpu field.
-	 */
-	if (!p->array && !task_running(rq, p)) {
-		set_task_cpu(p, any_online_cpu(p->cpus_allowed));
+
+	if (__set_cpus_allowed(p, new_mask, &req)) {
+		/* Need help from migration thread: drop lock and wait. */
 		task_rq_unlock(rq, &flags);
+		wake_up_process(rq->migration_thread);
+		wait_for_completion(&req.done);
 		return 0;
 	}
-	init_completion(&req.done);
-	req.task = p;
-	list_add(&req.list, &rq->migration_queue);
+out:
 	task_rq_unlock(rq, &flags);
-
-	wake_up_process(rq->migration_thread);
-
-	wait_for_completion(&req.done);
-	return 0;
+	return ret;
 }
 
 EXPORT_SYMBOL_GPL(set_cpus_allowed);
@@ -2636,7 +2739,9 @@ static void move_task_away(struct task_s
 		if (p->prio < rq_dest->curr->prio)
 			resched_task(rq_dest->curr);
 	}
- out:
+	p->timestamp = rq_dest->timestamp_last_tick;
+
+out:
 	double_rq_unlock(this_rq(), rq_dest);
 	local_irq_restore(flags);
 }
@@ -2705,11 +2810,10 @@ static int migration_thread(void * data)
  * migration_call - callback that gets triggered when a CPU is added.
  * Here we can start up the necessary migration thread for the new CPU.
  */
-static int migration_call(struct notifier_block *nfb,
-			  unsigned long action,
+static int migration_call(struct notifier_block *nfb, unsigned long action,
 			  void *hcpu)
 {
-	long cpu = (long) hcpu;
+	long cpu = (long)hcpu;
 	migration_startup_t startup;
 
 	switch (action) {
@@ -2738,7 +2842,8 @@ static int migration_call(struct notifie
 	return NOTIFY_OK;
 }
 
-static struct notifier_block migration_notifier = { &migration_call, NULL, 0 };
+static struct notifier_block migration_notifier
+			= { .notifier_call = &migration_call };
 
 __init int migration_init(void)
 {
@@ -2774,7 +2879,7 @@ static void kstat_init_cpu(int cpu)
 }
 
 static int __devinit kstat_cpu_notify(struct notifier_block *self,
-					unsigned long action, void *hcpu)
+				      unsigned long action, void *hcpu)
 {
 	int cpu = (unsigned long)hcpu;
 	switch(action) {
@@ -2788,13 +2893,14 @@ static int __devinit kstat_cpu_notify(st
 }
 
 static struct notifier_block __devinitdata kstat_nb = {
-	.notifier_call  = kstat_cpu_notify,
-	.next           = NULL,
+	.notifier_call	= kstat_cpu_notify,
+	.next		= NULL,
 };
 
-__init static void init_kstat(void) {
+__init static void init_kstat(void)
+{
 	kstat_cpu_notify(&kstat_nb, (unsigned long)CPU_UP_PREPARE,
-			(void *)(long)smp_processor_id());
+			 (void *)(long)smp_processor_id());
 	register_cpu_notifier(&kstat_nb);
 }
 
@@ -2811,6 +2917,8 @@ void __init sched_init(void)
 		rq = cpu_rq(i);
 		rq->active = rq->arrays;
 		rq->expired = rq->arrays + 1;
+		rq->best_expired_prio = MAX_PRIO;
+
 		spin_lock_init(&rq->lock);
 		INIT_LIST_HEAD(&rq->migration_queue);
 		atomic_set(&rq->nr_iowait, 0);
@@ -2858,7 +2966,7 @@ void __might_sleep(char *file, int line)
 		printk(KERN_ERR "Debug: sleeping function called from invalid"
 				" context at %s:%d\n", file, line);
 		printk("in_atomic():%d, irqs_disabled():%d\n",
-				in_atomic(), irqs_disabled());
+			in_atomic(), irqs_disabled());
 		dump_stack();
 	}
 #endif
diff -puN kernel/sys.c~linus kernel/sys.c
--- 25/kernel/sys.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/kernel/sys.c	2004-01-19 22:17:24.000000000 -0800
@@ -249,8 +249,11 @@ cond_syscall(compat_sys_futex)
 cond_syscall(sys_epoll_create)
 cond_syscall(sys_epoll_ctl)
 cond_syscall(sys_epoll_wait)
+
+/* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read)
 cond_syscall(sys_pciconfig_write)
+cond_syscall(sys_pciconfig_iobase)
 
 static int set_one_prio(struct task_struct *p, int niceval, int error)
 {
diff -puN kernel/sysctl.c~linus kernel/sysctl.c
--- 25/kernel/sysctl.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/kernel/sysctl.c	2004-01-19 22:17:24.000000000 -0800
@@ -60,6 +60,8 @@ extern int cad_pid;
 extern int pid_max;
 extern int sysctl_lower_zone_protection;
 extern int min_free_kbytes;
+extern int printk_ratelimit_jiffies;
+extern int printk_ratelimit_burst;
 
 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
 static int maxolduid = 65535;
@@ -579,6 +581,24 @@ static ctl_table kern_table[] = {
 		.mode		= 0644,
 		.proc_handler	= &proc_dointvec,
 	},
+	{
+		.ctl_name	= KERN_PRINTK_RATELIMIT,
+		.procname	= "printk_ratelimit",
+		.data		= &printk_ratelimit_jiffies,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= &proc_dointvec_jiffies,
+		.strategy	= &sysctl_jiffies,
+	},
+	{
+		.ctl_name	= KERN_PRINTK_RATELIMIT_BURST,
+		.procname	= "printk_ratelimit_burst",
+		.data		= &printk_ratelimit_burst,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= &proc_dointvec,
+		.strategy	= &sysctl_jiffies,
+	},
 	{ .ctl_name = 0 }
 };
 
diff -puN kernel/timer.c~linus kernel/timer.c
--- 25/kernel/timer.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/kernel/timer.c	2004-01-19 22:17:24.000000000 -0800
@@ -332,10 +332,7 @@ int del_timer_sync(struct timer_list *ti
 del_again:
 	ret += del_timer(timer);
 
-	for (i = 0; i < NR_CPUS; i++) {
-		if (!cpu_online(i))
-			continue;
-
+	for_each_cpu(i) {
 		base = &per_cpu(tvec_bases, i);
 		if (base->running_timer == timer) {
 			while (base->running_timer == timer) {
diff -puN kernel/workqueue.c~linus kernel/workqueue.c
--- 25/kernel/workqueue.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/kernel/workqueue.c	2004-01-19 22:17:24.000000000 -0800
@@ -14,13 +14,10 @@
  *   Theodore Ts'o <tytso@mit.edu>
  */
 
-#define __KERNEL_SYSCALLS__
-
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/init.h>
-#include <linux/unistd.h>
 #include <linux/signal.h>
 #include <linux/completion.h>
 #include <linux/workqueue.h>
@@ -171,7 +168,6 @@ static int worker_thread(void *__startup
 	struct k_sigaction sa;
 
 	daemonize("%s/%d", startup->name, cpu);
-	allow_signal(SIGCHLD);
 	current->flags |= PF_IOTHREAD;
 	cwq->thread = current;
 
@@ -180,7 +176,7 @@ static int worker_thread(void *__startup
 
 	complete(&startup->done);
 
-	/* Install a handler so SIGCLD is delivered */
+	/* SIG_IGN makes children autoreap: see do_notify_parent(). */
 	sa.sa.sa_handler = SIG_IGN;
 	sa.sa.sa_flags = 0;
 	siginitset(&sa.sa.sa_mask, sigmask(SIGCHLD));
@@ -200,14 +196,6 @@ static int worker_thread(void *__startup
 
 		if (!list_empty(&cwq->worklist))
 			run_workqueue(cwq);
-
-		if (signal_pending(current)) {
-			while (waitpid(-1, NULL, __WALL|WNOHANG) > 0)
-				/* SIGCHLD - auto-reaping */ ;
-
-			/* zap all other signals */
-			flush_signals(current);
-		}
 	}
 	remove_wait_queue(&cwq->more_work, &wait);
 	complete(&cwq->exit);
@@ -366,9 +354,7 @@ int current_is_keventd(void)
 
 	BUG_ON(!keventd_wq);
 
-	for (cpu = 0; cpu < NR_CPUS; cpu++) {
-		if (!cpu_online(cpu))
-			continue;
+	for_each_cpu(cpu) {
 		cwq = keventd_wq->cpu_wq + cpu;
 		if (current == cwq->thread)
 			return 1;
diff -puN /dev/null lib/bitmap.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/lib/bitmap.c	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,141 @@
+#include <linux/bitmap.h>
+#include <linux/module.h>
+
+int bitmap_empty(const unsigned long *bitmap, int bits)
+{
+	int k, lim = bits/BITS_PER_LONG;
+	for (k = 0; k < lim; ++k)
+		if (bitmap[k])
+			return 0;
+
+	if (bits % BITS_PER_LONG)
+		if (bitmap[k] & ((1UL << (bits % BITS_PER_LONG)) - 1))
+			return 0;
+
+	return 1;
+}
+EXPORT_SYMBOL(bitmap_empty);
+
+int bitmap_full(const unsigned long *bitmap, int bits)
+{
+	int k, lim = bits/BITS_PER_LONG;
+	for (k = 0; k < lim; ++k)
+		if (~bitmap[k])
+			return 0;
+
+	if (bits % BITS_PER_LONG)
+		if (~bitmap[k] & ((1UL << (bits % BITS_PER_LONG)) - 1))
+			return 0;
+
+	return 1;
+}
+EXPORT_SYMBOL(bitmap_full);
+
+int bitmap_equal(const unsigned long *bitmap1,
+		unsigned long *bitmap2, int bits)
+{
+	int k, lim = bits/BITS_PER_LONG;;
+	for (k = 0; k < lim; ++k)
+		if (bitmap1[k] != bitmap2[k])
+			return 0;
+
+	if (bits % BITS_PER_LONG)
+		if ((bitmap1[k] ^ bitmap2[k]) &
+				((1UL << (bits % BITS_PER_LONG)) - 1))
+			return 0;
+
+	return 1;
+}
+EXPORT_SYMBOL(bitmap_equal);
+
+void bitmap_complement(unsigned long *bitmap, int bits)
+{
+	int k;
+	int nr = BITS_TO_LONGS(bits);
+
+	for (k = 0; k < nr; ++k)
+		bitmap[k] = ~bitmap[k];
+}
+EXPORT_SYMBOL(bitmap_complement);
+
+void bitmap_shift_right(unsigned long *dst,
+			const unsigned long *src, int shift, int bits)
+{
+	int k;
+	DECLARE_BITMAP(__shr_tmp, bits);
+
+	bitmap_clear(__shr_tmp, bits);
+	for (k = 0; k < bits - shift; ++k)
+		if (test_bit(k + shift, src))
+			set_bit(k, __shr_tmp);
+	bitmap_copy(dst, __shr_tmp, bits);
+}
+EXPORT_SYMBOL(bitmap_shift_right);
+
+void bitmap_shift_left(unsigned long *dst,
+			const unsigned long *src, int shift, int bits)
+{
+	int k;
+	DECLARE_BITMAP(__shl_tmp, bits);
+
+	bitmap_clear(__shl_tmp, bits);
+	for (k = bits; k >= shift; --k)
+		if (test_bit(k - shift, src))
+			set_bit(k, __shl_tmp);
+	bitmap_copy(dst, __shl_tmp, bits);
+}
+EXPORT_SYMBOL(bitmap_shift_left);
+
+void bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
+				const unsigned long *bitmap2, int bits)
+{
+	int k;
+	int nr = BITS_TO_LONGS(bits);
+
+	for (k = 0; k < nr; k++)
+		dst[k] = bitmap1[k] & bitmap2[k];
+}
+EXPORT_SYMBOL(bitmap_and);
+
+void bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
+				const unsigned long *bitmap2, int bits)
+{
+	int k;
+	int nr = BITS_TO_LONGS(bits);
+
+	for (k = 0; k < nr; k++)
+		dst[k] = bitmap1[k] | bitmap2[k];
+}
+EXPORT_SYMBOL(bitmap_or);
+
+#if BITS_PER_LONG == 32
+int bitmap_weight(const unsigned long *bitmap, int bits)
+{
+	int k, w = 0, lim = bits/BITS_PER_LONG;
+
+	for (k = 0; k < lim; k++)
+		w += hweight32(bitmap[k]);
+
+	if (bits % BITS_PER_LONG)
+		w += hweight32(bitmap[k] &
+				((1UL << (bits % BITS_PER_LONG)) - 1));
+
+	return w;
+}
+#else
+int bitmap_weight(const unsigned long *bitmap, int bits)
+{
+	int k, w = 0, lim = bits/BITS_PER_LONG;
+
+	for (k = 0; k < lim; k++)
+		w += hweight64(bitmap[k]);
+
+	if (bits % BITS_PER_LONG)
+		w += hweight64(bitmap[k] &
+				((1UL << (bits % BITS_PER_LONG)) - 1));
+
+	return w;
+}
+#endif
+EXPORT_SYMBOL(bitmap_weight);
+
diff -puN /dev/null lib/extable.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/lib/extable.c	2004-01-19 22:17:24.000000000 -0800
@@ -0,0 +1,75 @@
+/*
+ * lib/extable.c
+ * Derived from arch/ppc/mm/extable.c and arch/i386/mm/extable.c.
+ *
+ * Copyright (C) 2004 Paul Mackerras, IBM Corp.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <asm/uaccess.h>
+
+extern struct exception_table_entry __start___ex_table[];
+extern struct exception_table_entry __stop___ex_table[];
+
+/*
+ * The exception table needs to be sorted so that the binary
+ * search that we use to find entries in it works properly.
+ * This is used both for the kernel exception table and for
+ * the exception tables of modules that get loaded.
+ */
+void sort_extable(struct exception_table_entry *start,
+		  struct exception_table_entry *finish)
+{
+	struct exception_table_entry el, *p, *q;
+
+	/* insertion sort */
+	for (p = start + 1; p < finish; ++p) {
+		/* start .. p-1 is sorted */
+		if (p[0].insn < p[-1].insn) {
+			/* move element p down to its right place */
+			el = *p;
+			q = p;
+			do {
+				/* el comes before q[-1], move q[-1] up one */
+				q[0] = q[-1];
+				--q;
+			} while (q > start && el.insn < q[-1].insn);
+			*q = el;
+		}
+	}
+}
+
+/*
+ * Search one exception table for an entry corresponding to the
+ * given instruction address, and return the address of the entry,
+ * or NULL if none is found.
+ * We use a binary search, and thus we assume that the table is
+ * already sorted.
+ */
+const struct exception_table_entry *
+search_extable(const struct exception_table_entry *first,
+	       const struct exception_table_entry *last,
+	       unsigned long value)
+{
+	while (first <= last) {
+		const struct exception_table_entry *mid;
+		long diff;
+
+		mid = (last - first) / 2 + first;
+		diff = mid->insn - value;
+		if (diff == 0)
+			return mid;
+		if (diff < 0)
+			first = mid+1;
+		else
+			last = mid-1;
+        }
+        return NULL;
+}
diff -puN lib/kobject.c~linus lib/kobject.c
--- 25/lib/kobject.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/lib/kobject.c	2004-01-19 22:17:24.000000000 -0800
@@ -198,9 +198,24 @@ exit:
 	kfree(envp);
 	return;
 }
+
+void kobject_hotplug(const char *action, struct kobject *kobj)
+{
+	struct kobject * top_kobj = kobj;
+
+	/* If this kobj does not belong to a kset,
+	   try to find a parent that does. */
+	if (!top_kobj->kset && top_kobj->parent) {
+		do {
+			top_kobj = top_kobj->parent;
+		} while (!top_kobj->kset && top_kobj->parent);
+	}
+
+	if (top_kobj->kset && top_kobj->kset->hotplug_ops)
+		kset_hotplug(action, top_kobj->kset, kobj);
+}
 #else
-static void kset_hotplug(const char *action, struct kset *kset,
-			 struct kobject *kobj)
+void kobject_hotplug(const char *action, struct kobject *kobj)
 {
 	return;
 }
@@ -248,7 +263,6 @@ int kobject_add(struct kobject * kobj)
 {
 	int error = 0;
 	struct kobject * parent;
-	struct kobject * top_kobj;
 
 	if (!(kobj = kobject_get(kobj)))
 		return -ENOENT;
@@ -277,18 +291,9 @@ int kobject_add(struct kobject * kobj)
 		if (parent)
 			kobject_put(parent);
 	} else {
-		/* If this kobj does not belong to a kset,
-		   try to find a parent that does. */
-		top_kobj = kobj;
-		if (!top_kobj->kset && top_kobj->parent) {
-			do {
-				top_kobj = top_kobj->parent;
-			} while (!top_kobj->kset && top_kobj->parent);
-		}
-	
-		if (top_kobj->kset && top_kobj->kset->hotplug_ops)
-			kset_hotplug("add", top_kobj->kset, kobj);
+		kobject_hotplug("add", kobj);
 	}
+
 	return error;
 }
 
@@ -396,20 +401,7 @@ void kobject_rename(struct kobject * kob
 
 void kobject_del(struct kobject * kobj)
 {
-	struct kobject * top_kobj;
-
-	/* If this kobj does not belong to a kset,
-	   try to find a parent that does. */
-	top_kobj = kobj;
-	if (!top_kobj->kset && top_kobj->parent) {
-		do {
-			top_kobj = top_kobj->parent;
-		} while (!top_kobj->kset && top_kobj->parent);
-	}
-
-	if (top_kobj->kset && top_kobj->kset->hotplug_ops)
-		kset_hotplug("remove", top_kobj->kset, kobj);
-
+	kobject_hotplug("remove", kobj);
 	sysfs_remove_dir(kobj);
 	unlink(kobj);
 }
@@ -555,7 +547,7 @@ struct kobject * kset_find_obj(struct ks
 	down_read(&kset->subsys->rwsem);
 	list_for_each(entry,&kset->list) {
 		struct kobject * k = to_kobj(entry);
-		if (!strcmp(kobject_name(k),name)) {
+		if (kobject_name(k) && (!strcmp(kobject_name(k),name))) {
 			ret = k;
 			break;
 		}
@@ -638,6 +630,7 @@ EXPORT_SYMBOL(kobject_register);
 EXPORT_SYMBOL(kobject_unregister);
 EXPORT_SYMBOL(kobject_get);
 EXPORT_SYMBOL(kobject_put);
+EXPORT_SYMBOL(kobject_hotplug);
 
 EXPORT_SYMBOL(kset_register);
 EXPORT_SYMBOL(kset_unregister);
diff -puN lib/Makefile~linus lib/Makefile
--- 25/lib/Makefile~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/lib/Makefile	2004-01-19 22:17:24.000000000 -0800
@@ -5,7 +5,8 @@
 
 lib-y := errno.o ctype.o string.o vsprintf.o cmdline.o \
 	 bust_spinlocks.o rbtree.o radix-tree.o dump_stack.o \
-	 kobject.o idr.o div64.o parser.o int_sqrt.o mask.o
+	 kobject.o idr.o div64.o parser.o int_sqrt.o mask.o \
+	 bitmap.o extable.o
 
 lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
 lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
diff -puN MAINTAINERS~linus MAINTAINERS
--- 25/MAINTAINERS~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/MAINTAINERS	2004-01-19 22:17:09.000000000 -0800
@@ -338,35 +338,64 @@ L:	linux-kernel@vger.kernel.org
 S:	Maintained
 
 BLUETOOTH SUBSYSTEM
+P:	Marcel Holtmann
+M:	marcel@holtmann.org
 P:	Maxim Krasnyansky
 M:	maxk@qualcomm.com
+L:	bluez-devel@lists.sf.net
 W:	http://bluez.sf.net
 S:	Maintained
 
 BLUETOOTH RFCOMM LAYER
+P:	Marcel Holtmann
+M:	marcel@holtmann.org
 P:	Maxim Krasnyansky
 M:	maxk@qualcomm.com
 W:	http://bluez.sf.net
 S:	Maintained
 
 BLUETOOTH BNEP LAYER
+P:	Marcel Holtmann
+M:	marcel@holtmann.org
 P:	Maxim Krasnyansky
 M:	maxk@qualcomm.com
 W:	http://bluez.sf.net
 S:	Maintained
 
+BLUETOOTH CMTP LAYER
+P:	Marcel Holtmann
+M:	marcel@holtmann.org
+W:	http://www.holtmann.org/linux/bluetooth/
+S:	Maintained
+
 BLUETOOTH HCI USB DRIVER
+P:	Marcel Holtmann
+M:	marcel@holtmann.org
 P:	Maxim Krasnyansky
 M:	maxk@qualcomm.com
 W:	http://bluez.sf.net
 S:	Maintained
 
 BLUETOOTH HCI UART DRIVER
+P:	Marcel Holtmann
+M:	marcel@holtmann.org
 P:	Maxim Krasnyansky
 M:	maxk@qualcomm.com
 W:	http://bluez.sf.net
 S:	Maintained
 
+BLUETOOTH HCI BCM203X DRIVER
+P:	Marcel Holtmann
+M:	marcel@holtmann.org
+W:	http://www.holtmann.org/linux/bluetooth/
+S:	Maintained
+
+BLUETOOTH HCI BFUSB DRIVER
+P:	Marcel Holtmann
+M:	marcel@holtmann.org
+W:	http://www.holtmann.org/linux/bluetooth/
+S:	Maintained
+
 BLUETOOTH HCI DTL1 DRIVER
 P:	Marcel Holtmann
 M:	marcel@holtmann.org
@@ -608,8 +637,8 @@ W:	http://www.sistina.com/lvm
 S:	Maintained
 
 DEVICE NUMBER REGISTRY
-P:	H. Peter Anvin
-M:	hpa@zytor.com
+P:	John Cagle
+M:	device@lanana.org
 L:	linux-kernel@vger.kernel.org
 S:	Maintained
 
@@ -1135,7 +1164,7 @@ KERNEL AUTOMOUNTER (AUTOFS)
 P:	H. Peter Anvin
 M:	hpa@zytor.com
 L:	autofs@linux.kernel.org
-S:	Maintained
+S:	Odd Fixes
 
 KERNEL AUTOMOUNTER v4 (AUTOFS4)
 P:	Jeremy Fitzhardinge
@@ -1143,11 +1172,11 @@ M:	jeremy@goop.org
 L:	autofs@linux.kernel.org
 S:	Maintained
 
-KERNEL BUILD (Makefile, Rules.make, scripts/*)
-P:	Michael Elizabeth Chastain
-M:	mec@shout.net
-L:	kbuild-devel@lists.sourceforge.net
-W:	http://kbuild.sourceforge.net
+KERNEL BUILD (kbuild: Makefile, scripts/Makefile.*)
+P:	Kai Germaschewski
+M:	kai@germaschewski.name
+P:	Sam Ravnborg
+M:	sam@ravnborg.org
 S:	Maintained 
 
 KERNEL JANITORS
@@ -1482,8 +1511,8 @@ L:	linux-sound@vger.kernel.org
 S:	Maintained
 
 OPROFILE
-P:	John Levon
-M:	levon@movementarian.org
+P:	Philippe Elie
+M:	phil.el@wanadoo.fr
 L:	oprofile-list@lists.sf.net
 S:	Maintained
 
diff -puN mm/fadvise.c~linus mm/fadvise.c
--- 25/mm/fadvise.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/mm/fadvise.c	2004-01-19 22:17:24.000000000 -0800
@@ -23,7 +23,6 @@
 asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
 {
 	struct file *file = fget(fd);
-	struct inode *inode;
 	struct address_space *mapping;
 	struct backing_dev_info *bdi;
 	pgoff_t start_index;
@@ -33,8 +32,7 @@ asmlinkage long sys_fadvise64_64(int fd,
 	if (!file)
 		return -EBADF;
 
-	inode = file->f_dentry->d_inode;
-	mapping = inode->i_mapping;
+	mapping = file->f_mapping;
 	if (!mapping) {
 		ret = -EINVAL;
 		goto out;
diff -puN mm/filemap.c~linus mm/filemap.c
--- 25/mm/filemap.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/mm/filemap.c	2004-01-19 22:17:24.000000000 -0800
@@ -587,22 +587,13 @@ void do_generic_mapping_read(struct addr
 			     read_actor_t actor)
 {
 	struct inode *inode = mapping->host;
-	unsigned long index, offset, last;
+	unsigned long index, offset;
 	struct page *cached_page;
 	int error;
 
 	cached_page = NULL;
 	index = *ppos >> PAGE_CACHE_SHIFT;
 	offset = *ppos & ~PAGE_CACHE_MASK;
-	last = (*ppos + desc->count) >> PAGE_CACHE_SHIFT;
-
-	/*
-	 * Let the readahead logic know upfront about all
-	 * the pages we'll need to satisfy this request
-	 */
-	for (; index < last; index++)
-		page_cache_readahead(mapping, ra, filp, index);
-	index = *ppos >> PAGE_CACHE_SHIFT;
 
 	for (;;) {
 		struct page *page;
@@ -621,6 +612,7 @@ void do_generic_mapping_read(struct addr
 		}
 
 		cond_resched();
+		page_cache_readahead(mapping, ra, filp, index);
 
 		nr = nr - offset;
 find_page:
@@ -812,7 +804,7 @@ __generic_file_aio_read(struct kiocb *io
 		struct address_space *mapping;
 		struct inode *inode;
 
-		mapping = filp->f_dentry->d_inode->i_mapping;
+		mapping = filp->f_mapping;
 		inode = mapping->host;
 		retval = 0;
 		if (!count)
@@ -944,7 +936,7 @@ asmlinkage ssize_t sys_readahead(int fd,
 	file = fget(fd);
 	if (file) {
 		if (file->f_mode & FMODE_READ) {
-			struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
+			struct address_space *mapping = file->f_mapping;
 			unsigned long start = offset >> PAGE_CACHE_SHIFT;
 			unsigned long end = (offset + count - 1) >> PAGE_CACHE_SHIFT;
 			unsigned long len = end - start + 1;
@@ -963,7 +955,7 @@ asmlinkage ssize_t sys_readahead(int fd,
 static int FASTCALL(page_cache_read(struct file * file, unsigned long offset));
 static int page_cache_read(struct file * file, unsigned long offset)
 {
-	struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
+	struct address_space *mapping = file->f_mapping;
 	struct page *page; 
 	int error;
 
@@ -1002,7 +994,7 @@ struct page * filemap_nopage(struct vm_a
 {
 	int error;
 	struct file *file = area->vm_file;
-	struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
+	struct address_space *mapping = file->f_mapping;
 	struct file_ra_state *ra = &file->f_ra;
 	struct inode *inode = mapping->host;
 	struct page *page;
@@ -1187,7 +1179,7 @@ EXPORT_SYMBOL(filemap_nopage);
 static struct page * filemap_getpage(struct file *file, unsigned long pgoff,
 					int nonblock)
 {
-	struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
+	struct address_space *mapping = file->f_mapping;
 	struct page *page;
 	int error;
 
@@ -1299,7 +1291,7 @@ static int filemap_populate(struct vm_ar
 			int nonblock)
 {
 	struct file *file = vma->vm_file;
-	struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
+	struct address_space *mapping = file->f_mapping;
 	struct inode *inode = mapping->host;
 	unsigned long size;
 	struct mm_struct *mm = vma->vm_mm;
@@ -1358,7 +1350,7 @@ static struct vm_operations_struct gener
 
 int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
 {
-	struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
+	struct address_space *mapping = file->f_mapping;
 	struct inode *inode = mapping->host;
 
 	if (!mapping->a_ops->readpage)
@@ -1626,9 +1618,9 @@ filemap_set_next_iovec(const struct iove
  * Returns appropriate error code that caller should return or
  * zero in case that write should be allowed.
  */
-inline int generic_write_checks(struct inode *inode,
-		struct file *file, loff_t *pos, size_t *count, int isblk)
+inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk)
 {
+	struct inode *inode = file->f_mapping->host;
 	unsigned long limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
 
         if (unlikely(*pos < 0))
@@ -1690,7 +1682,7 @@ inline int generic_write_checks(struct i
 			*count = inode->i_sb->s_maxbytes - *pos;
 	} else {
 		loff_t isize;
-		if (bdev_read_only(inode->i_bdev))
+		if (bdev_read_only(I_BDEV(inode)))
 			return -EPERM;
 		isize = i_size_read(inode);
 		if (*pos >= isize) {
@@ -1720,7 +1712,7 @@ generic_file_aio_write_nolock(struct kio
 				unsigned long nr_segs, loff_t *ppos)
 {
 	struct file *file = iocb->ki_filp;
-	struct address_space * mapping = file->f_dentry->d_inode->i_mapping;
+	struct address_space * mapping = file->f_mapping;
 	struct address_space_operations *a_ops = mapping->a_ops;
 	size_t ocount;		/* original count */
 	size_t count;		/* after file limit checks */
@@ -1767,7 +1759,7 @@ generic_file_aio_write_nolock(struct kio
 	current->backing_dev_info = mapping->backing_dev_info;
 	written = 0;
 
-	err = generic_write_checks(inode, file, &pos, &count, isblk);
+	err = generic_write_checks(file, &pos, &count, isblk);
 	if (err)
 		goto out;
 
@@ -1798,7 +1790,7 @@ generic_file_aio_write_nolock(struct kio
 		 * of course not the data as we did direct DMA for the IO.
 		 */
 		if (written >= 0 && file->f_flags & O_SYNC)
-			status = generic_osync_inode(inode, OSYNC_METADATA);
+			status = generic_osync_inode(inode, mapping, OSYNC_METADATA);
 		if (written >= 0 && !is_sync_kiocb(iocb))
 			written = -EIOCBQUEUED;
 		goto out_status;
@@ -1886,7 +1878,7 @@ generic_file_aio_write_nolock(struct kio
 	 */
 	if (status >= 0) {
 		if ((file->f_flags & O_SYNC) || IS_SYNC(inode))
-			status = generic_osync_inode(inode,
+			status = generic_osync_inode(inode, mapping,
 					OSYNC_METADATA|OSYNC_DATA);
 	}
 	
@@ -1920,7 +1912,7 @@ ssize_t generic_file_aio_write(struct ki
 			       size_t count, loff_t pos)
 {
 	struct file *file = iocb->ki_filp;
-	struct inode *inode = file->f_dentry->d_inode->i_mapping->host;
+	struct inode *inode = file->f_mapping->host;
 	ssize_t err;
 	struct iovec local_iov = { .iov_base = (void __user *)buf, .iov_len = count };
 
@@ -1939,7 +1931,7 @@ EXPORT_SYMBOL(generic_file_aio_write);
 ssize_t generic_file_write(struct file *file, const char __user *buf,
 			   size_t count, loff_t *ppos)
 {
-	struct inode	*inode = file->f_dentry->d_inode->i_mapping->host;
+	struct inode	*inode = file->f_mapping->host;
 	ssize_t		err;
 	struct iovec local_iov = { .iov_base = (void __user *)buf, .iov_len = count };
 
@@ -1970,7 +1962,7 @@ EXPORT_SYMBOL(generic_file_readv);
 ssize_t generic_file_writev(struct file *file, const struct iovec *iov,
 			unsigned long nr_segs, loff_t * ppos) 
 {
-	struct inode *inode = file->f_dentry->d_inode;
+	struct inode *inode = file->f_mapping->host;
 	ssize_t ret;
 
 	down(&inode->i_sem);
@@ -1986,7 +1978,7 @@ generic_file_direct_IO(int rw, struct ki
 	loff_t offset, unsigned long nr_segs)
 {
 	struct file *file = iocb->ki_filp;
-	struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
+	struct address_space *mapping = file->f_mapping;
 	ssize_t retval;
 
 	if (mapping->nrpages) {
diff -puN mm/fremap.c~linus mm/fremap.c
--- 25/mm/fremap.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/mm/fremap.c	2004-01-19 22:17:24.000000000 -0800
@@ -19,18 +19,18 @@
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
 
-static inline int zap_pte(struct mm_struct *mm, struct vm_area_struct *vma,
+static inline void zap_pte(struct mm_struct *mm, struct vm_area_struct *vma,
 			unsigned long addr, pte_t *ptep)
 {
 	pte_t pte = *ptep;
 
 	if (pte_none(pte))
-		return 0;
+		return;
 	if (pte_present(pte)) {
 		unsigned long pfn = pte_pfn(pte);
 
 		flush_cache_page(vma, addr);
-		pte = ptep_get_and_clear(ptep);
+		pte = ptep_clear_flush(vma, addr, ptep);
 		if (pfn_valid(pfn)) {
 			struct page *page = pfn_to_page(pfn);
 			if (!PageReserved(page)) {
@@ -41,12 +41,10 @@ static inline int zap_pte(struct mm_stru
 				mm->rss--;
 			}
 		}
-		return 1;
 	} else {
 		if (!pte_file(pte))
 			free_swap_and_cache(pte_to_swp_entry(pte));
 		pte_clear(ptep);
-		return 0;
 	}
 }
 
@@ -57,7 +55,7 @@ static inline int zap_pte(struct mm_stru
 int install_page(struct mm_struct *mm, struct vm_area_struct *vma,
 		unsigned long addr, struct page *page, pgprot_t prot)
 {
-	int err = -ENOMEM, flush;
+	int err = -ENOMEM;
 	pte_t *pte;
 	pgd_t *pgd;
 	pmd_t *pmd;
@@ -78,7 +76,7 @@ int install_page(struct mm_struct *mm, s
 	if (!pte)
 		goto err_unlock;
 
-	flush = zap_pte(mm, vma, addr, pte);
+	zap_pte(mm, vma, addr, pte);
 
 	mm->rss++;
 	flush_icache_page(vma, page);
@@ -86,8 +84,6 @@ int install_page(struct mm_struct *mm, s
 	pte_chain = page_add_rmap(page, pte, pte_chain);
 	pte_val = *pte;
 	pte_unmap(pte);
-	if (flush)
-		flush_tlb_page(vma, addr);
 	update_mmu_cache(vma, addr, pte_val);
 	spin_unlock(&mm->page_table_lock);
 	pte_chain_free(pte_chain);
@@ -109,7 +105,7 @@ EXPORT_SYMBOL(install_page);
 int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma,
 		unsigned long addr, unsigned long pgoff, pgprot_t prot)
 {
-	int err = -ENOMEM, flush;
+	int err = -ENOMEM;
 	pte_t *pte;
 	pgd_t *pgd;
 	pmd_t *pmd;
@@ -126,13 +122,11 @@ int install_file_pte(struct mm_struct *m
 	if (!pte)
 		goto err_unlock;
 
-	flush = zap_pte(mm, vma, addr, pte);
+	zap_pte(mm, vma, addr, pte);
 
 	set_pte(pte, pgoff_to_pte(pgoff));
 	pte_val = *pte;
 	pte_unmap(pte);
-	if (flush)
-		flush_tlb_page(vma, addr);
 	update_mmu_cache(vma, addr, pte_val);
 	spin_unlock(&mm->page_table_lock);
 	return 0;
diff -puN mm/madvise.c~linus mm/madvise.c
--- 25/mm/madvise.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/mm/madvise.c	2004-01-19 22:17:24.000000000 -0800
@@ -65,7 +65,7 @@ static long madvise_willneed(struct vm_a
 		end = vma->vm_end;
 	end = ((end - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
 
-	force_page_cache_readahead(file->f_dentry->d_inode->i_mapping,
+	force_page_cache_readahead(file->f_mapping,
 			file, start, max_sane_readahead(end - start));
 	return 0;
 }
diff -puN mm/memory.c~linus mm/memory.c
--- 25/mm/memory.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/mm/memory.c	2004-01-19 22:17:24.000000000 -0800
@@ -45,6 +45,7 @@
 #include <linux/pagemap.h>
 #include <linux/rmap-locking.h>
 #include <linux/module.h>
+#include <linux/init.h>
 
 #include <asm/pgalloc.h>
 #include <asm/rmap.h>
@@ -651,14 +652,19 @@ follow_page(struct mm_struct *mm, unsign
 	pte = *ptep;
 	pte_unmap(ptep);
 	if (pte_present(pte)) {
-		if (!write || (pte_write(pte) && pte_dirty(pte))) {
-			pfn = pte_pfn(pte);
-			if (pfn_valid(pfn)) {
-				struct page *page = pfn_to_page(pfn);
-
-				mark_page_accessed(page);
-				return page;
-			}
+		if (write && !pte_write(pte))
+			goto out;
+		if (write && !pte_dirty(pte)) {
+			struct page *page = pte_page(pte);
+			if (!PageDirty(page))
+				set_page_dirty(page);
+		}
+		pfn = pte_pfn(pte);
+		if (pfn_valid(pfn)) {
+			struct page *page = pfn_to_page(pfn);
+			
+			mark_page_accessed(page);
+			return page;
 		}
 	}
 
@@ -699,25 +705,13 @@ int get_user_pages(struct task_struct *t
 		struct vm_area_struct *	vma;
 
 		vma = find_extend_vma(mm, start);
-
-#ifdef FIXADDR_USER_START
-		if (!vma &&
-		    start >= FIXADDR_USER_START && start < FIXADDR_USER_END) {
-			static struct vm_area_struct fixmap_vma = {
-				/* Catch users - if there are any valid
-				   ones, we can make this be "&init_mm" or
-				   something.  */
-				.vm_mm = NULL,
-				.vm_start = FIXADDR_USER_START,
-				.vm_end = FIXADDR_USER_END,
-				.vm_page_prot = PAGE_READONLY,
-				.vm_flags = VM_READ | VM_EXEC,
-			};
+		if (!vma && in_gate_area(tsk, start)) {
 			unsigned long pg = start & PAGE_MASK;
+			struct vm_area_struct *gate_vma = get_gate_vma(tsk);
 			pgd_t *pgd;
 			pmd_t *pmd;
 			pte_t *pte;
-			if (write) /* user fixmap pages are read-only */
+			if (write) /* user gate pages are read-only */
 				return i ? : -EFAULT;
 			pgd = pgd_offset_k(pg);
 			if (!pgd)
@@ -733,13 +727,12 @@ int get_user_pages(struct task_struct *t
 				get_page(pages[i]);
 			}
 			if (vmas)
-				vmas[i] = &fixmap_vma;
+				vmas[i] = gate_vma;
 			i++;
 			start += PAGE_SIZE;
 			len--;
 			continue;
 		}
-#endif
 
 		if (!vma || (pages && (vma->vm_flags & VM_IO))
 				|| !(flags & vma->vm_flags))
@@ -863,6 +856,9 @@ int zeromap_page_range(struct vm_area_st
 		address = (address + PGDIR_SIZE) & PGDIR_MASK;
 		dir++;
 	} while (address && (address < end));
+	/*
+	 * Why flush? zeromap_pte_range has a BUG_ON for !pte_none()
+	 */
 	flush_tlb_range(vma, beg, end);
 	spin_unlock(&mm->page_table_lock);
 	return error;
@@ -944,6 +940,9 @@ int remap_page_range(struct vm_area_stru
 		from = (from + PGDIR_SIZE) & PGDIR_MASK;
 		dir++;
 	} while (from && (from < end));
+	/*
+	 * Why flush? remap_pte_range has a BUG_ON for !pte_none()
+	 */
 	flush_tlb_range(vma, beg, end);
 	spin_unlock(&mm->page_table_lock);
 	return error;
@@ -952,28 +951,17 @@ int remap_page_range(struct vm_area_stru
 EXPORT_SYMBOL(remap_page_range);
 
 /*
- * Establish a new mapping:
- *  - flush the old one
- *  - update the page tables
- *  - inform the TLB about the new one
- *
- * We hold the mm semaphore for reading and vma->vm_mm->page_table_lock
- */
-static inline void establish_pte(struct vm_area_struct * vma, unsigned long address, pte_t *page_table, pte_t entry)
-{
-	set_pte(page_table, entry);
-	flush_tlb_page(vma, address);
-	update_mmu_cache(vma, address, entry);
-}
-
-/*
  * We hold the mm semaphore for reading and vma->vm_mm->page_table_lock
  */
 static inline void break_cow(struct vm_area_struct * vma, struct page * new_page, unsigned long address, 
 		pte_t *page_table)
 {
+	pte_t entry;
+
 	flush_cache_page(vma, address);
-	establish_pte(vma, address, page_table, pte_mkwrite(pte_mkdirty(mk_pte(new_page, vma->vm_page_prot))));
+	entry = pte_mkwrite(pte_mkdirty(mk_pte(new_page, vma->vm_page_prot)));
+	ptep_establish(vma, address, page_table, entry);
+	update_mmu_cache(vma, address, entry);
 }
 
 /*
@@ -1002,6 +990,7 @@ static int do_wp_page(struct mm_struct *
 	struct page *old_page, *new_page;
 	unsigned long pfn = pte_pfn(pte);
 	struct pte_chain *pte_chain;
+	pte_t entry;
 
 	if (unlikely(!pfn_valid(pfn))) {
 		/*
@@ -1022,8 +1011,9 @@ static int do_wp_page(struct mm_struct *
 		unlock_page(old_page);
 		if (reuse) {
 			flush_cache_page(vma, address);
-			establish_pte(vma, address, page_table,
-				pte_mkyoung(pte_mkdirty(pte_mkwrite(pte))));
+			entry = pte_mkyoung(pte_mkdirty(pte_mkwrite(pte)));
+			ptep_establish(vma, address, page_table, entry);
+			update_mmu_cache(vma, address, entry);
 			pte_unmap(page_table);
 			spin_unlock(&mm->page_table_lock);
 			return VM_FAULT_MINOR;
@@ -1409,7 +1399,7 @@ do_no_page(struct mm_struct *mm, struct 
 	spin_unlock(&mm->page_table_lock);
 
 	if (vma->vm_file) {
-		mapping = vma->vm_file->f_dentry->d_inode->i_mapping;
+		mapping = vma->vm_file->f_mapping;
 		sequence = atomic_read(&mapping->truncate_count);
 	}
 	smp_rmb();  /* Prevent CPU from reordering lock-free ->nopage() */
@@ -1431,10 +1421,8 @@ retry:
 	 */
 	if (write_access && !(vma->vm_flags & VM_SHARED)) {
 		struct page * page = alloc_page(GFP_HIGHUSER);
-		if (!page) {
-			page_cache_release(new_page);
+		if (!page)
 			goto oom;
-		}
 		copy_user_highpage(page, new_page, address);
 		page_cache_release(new_page);
 		lru_cache_add_active(page);
@@ -1491,6 +1479,7 @@ retry:
 	spin_unlock(&mm->page_table_lock);
 	goto out;
 oom:
+	page_cache_release(new_page);
 	ret = VM_FAULT_OOM;
 out:
 	pte_chain_free(pte_chain);
@@ -1580,7 +1569,8 @@ static inline int handle_pte_fault(struc
 		entry = pte_mkdirty(entry);
 	}
 	entry = pte_mkyoung(entry);
-	establish_pte(vma, address, pte, entry);
+	ptep_establish(vma, address, pte, entry);
+	update_mmu_cache(vma, address, entry);
 	pte_unmap(pte);
 	spin_unlock(&mm->page_table_lock);
 	return VM_FAULT_MINOR;
@@ -1697,3 +1687,18 @@ struct page * vmalloc_to_page(void * vma
 }
 
 EXPORT_SYMBOL(vmalloc_to_page);
+
+#if !defined(CONFIG_ARCH_GATE_AREA) && defined(AT_SYSINFO_EHDR)
+struct vm_area_struct gate_vma;
+
+static int __init gate_vma_init(void)
+{
+	gate_vma.vm_mm = NULL;
+	gate_vma.vm_start = FIXADDR_USER_START;
+	gate_vma.vm_end = FIXADDR_USER_END;
+	gate_vma.vm_page_prot = PAGE_READONLY;
+	gate_vma.vm_flags = 0;
+	return 0;
+}
+__initcall(gate_vma_init);
+#endif
diff -puN mm/mincore.c~linus mm/mincore.c
--- 25/mm/mincore.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/mm/mincore.c	2004-01-19 22:17:24.000000000 -0800
@@ -26,7 +26,7 @@ static unsigned char mincore_page(struct
 	unsigned long pgoff)
 {
 	unsigned char present = 0;
-	struct address_space * as = vma->vm_file->f_dentry->d_inode->i_mapping;
+	struct address_space * as = vma->vm_file->f_mapping;
 	struct page * page;
 
 	page = find_get_page(as, pgoff);
diff -puN mm/mmap.c~linus mm/mmap.c
--- 25/mm/mmap.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/mm/mmap.c	2004-01-19 22:17:24.000000000 -0800
@@ -80,11 +80,10 @@ static void remove_shared_vm_struct(stru
 	struct file *file = vma->vm_file;
 
 	if (file) {
-		struct inode *inode = file->f_dentry->d_inode;
-
-		down(&inode->i_mapping->i_shared_sem);
-		__remove_shared_vm_struct(vma, inode);
-		up(&inode->i_mapping->i_shared_sem);
+		struct address_space *mapping = file->f_mapping;
+		down(&mapping->i_shared_sem);
+		__remove_shared_vm_struct(vma, file->f_dentry->d_inode);
+		up(&mapping->i_shared_sem);
 	}
 }
 
@@ -235,11 +234,10 @@ static inline void __vma_link_file(struc
 
 	file = vma->vm_file;
 	if (file) {
-		struct inode * inode = file->f_dentry->d_inode;
-		struct address_space *mapping = inode->i_mapping;
+		struct address_space *mapping = file->f_mapping;
 
 		if (vma->vm_flags & VM_DENYWRITE)
-			atomic_dec(&inode->i_writecount);
+			atomic_dec(&file->f_dentry->d_inode->i_writecount);
 
 		if (vma->vm_flags & VM_SHARED)
 			list_add_tail(&vma->shared, &mapping->i_mmap_shared);
@@ -265,7 +263,7 @@ static void vma_link(struct mm_struct *m
 	struct address_space *mapping = NULL;
 
 	if (vma->vm_file)
-		mapping = vma->vm_file->f_dentry->d_inode->i_mapping;
+		mapping = vma->vm_file->f_mapping;
 
 	if (mapping)
 		down(&mapping->i_shared_sem);
@@ -383,7 +381,7 @@ static int vma_merge(struct mm_struct *m
 	if (vm_flags & VM_SPECIAL)
 		return 0;
 
-	i_shared_sem = file ? &inode->i_mapping->i_shared_sem : NULL;
+	i_shared_sem = file ? &file->f_mapping->i_shared_sem : NULL;
 
 	if (!prev) {
 		prev = rb_entry(rb_parent, struct vm_area_struct, vm_rb);
@@ -1207,7 +1205,7 @@ int split_vma(struct mm_struct * mm, str
 		new->vm_ops->open(new);
 
 	if (vma->vm_file)
-		 mapping = vma->vm_file->f_dentry->d_inode->i_mapping;
+		 mapping = vma->vm_file->f_mapping;
 
 	if (mapping)
 		down(&mapping->i_shared_sem);
diff -puN mm/mremap.c~linus mm/mremap.c
--- 25/mm/mremap.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/mm/mremap.c	2004-01-19 22:17:24.000000000 -0800
@@ -80,8 +80,8 @@ static inline pte_t *alloc_one_pte_map(s
 }
 
 static int
-copy_one_pte(struct mm_struct *mm, pte_t *src, pte_t *dst,
-		struct pte_chain **pte_chainp)
+copy_one_pte(struct vm_area_struct *vma, unsigned long old_addr,
+	     pte_t *src, pte_t *dst, struct pte_chain **pte_chainp)
 {
 	int error = 0;
 	pte_t pte;
@@ -93,7 +93,7 @@ copy_one_pte(struct mm_struct *mm, pte_t
 	if (!pte_none(*src)) {
 		if (page)
 			page_remove_rmap(page, src);
-		pte = ptep_get_and_clear(src);
+		pte = ptep_clear_flush(vma, old_addr, src);
 		if (!dst) {
 			/* No dest?  We must put it back. */
 			dst = src;
@@ -135,11 +135,15 @@ move_one_page(struct vm_area_struct *vma
 		dst = alloc_one_pte_map(mm, new_addr);
 		if (src == NULL)
 			src = get_one_pte_map_nested(mm, old_addr);
-		error = copy_one_pte(mm, src, dst, &pte_chain);
+		error = copy_one_pte(vma, old_addr, src, dst, &pte_chain);
 		pte_unmap_nested(src);
 		pte_unmap(dst);
-	}
-	flush_tlb_page(vma, old_addr);
+	} else
+		/*
+		 * Why do we need this flush ? If there is no pte for
+		 * old_addr, then there must not be a pte for it as well.
+		 */
+		flush_tlb_page(vma, old_addr);
 	spin_unlock(&mm->page_table_lock);
 	pte_chain_free(pte_chain);
 out:
@@ -315,8 +319,12 @@ unsigned long do_mremap(unsigned long ad
 	old_len = PAGE_ALIGN(old_len);
 	new_len = PAGE_ALIGN(new_len);
 
-	/* Don't allow the degenerate cases */
-	if (!old_len || !new_len)
+	/*
+	 * We allow a zero old-len as a special case
+	 * for DOS-emu "duplicate shm area" thing. But
+	 * a zero new-len is nonsensical.
+	 */
+	if (!new_len)
 		goto out;
 
 	/* new_addr is only valid if MREMAP_FIXED is specified */
diff -puN mm/msync.c~linus mm/msync.c
--- 25/mm/msync.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/mm/msync.c	2004-01-19 22:17:24.000000000 -0800
@@ -24,17 +24,15 @@ static int filemap_sync_pte(pte_t *ptep,
 	unsigned long address, unsigned int flags)
 {
 	pte_t pte = *ptep;
+	unsigned long pfn = pte_pfn(pte);
+	struct page *page;
 
-	if (pte_present(pte) && pte_dirty(pte)) {
-		struct page *page;
-		unsigned long pfn = pte_pfn(pte);
-		if (pfn_valid(pfn)) {
-			page = pfn_to_page(pfn);
-			if (!PageReserved(page) && ptep_test_and_clear_dirty(ptep)) {
-				flush_tlb_page(vma, address);
-				set_page_dirty(page);
-			}
-		}
+	if (pte_present(pte) && pfn_valid(pfn)) {
+		page = pfn_to_page(pfn);
+		if (!PageReserved(page) &&
+		    (ptep_clear_flush_dirty(vma, address, ptep) ||
+		     page_test_and_clear_dirty(page)))
+			set_page_dirty(page);
 	}
 	return 0;
 }
@@ -115,6 +113,10 @@ static int filemap_sync(struct vm_area_s
 		address = (address + PGDIR_SIZE) & PGDIR_MASK;
 		dir++;
 	} while (address && (address < end));
+	/*
+	 * Why flush ? filemap_sync_pte already flushed the tlbs with the
+	 * dirty bits.
+	 */
 	flush_tlb_range(vma, end - size, end);
 
 	spin_unlock(&vma->vm_mm->page_table_lock);
@@ -146,20 +148,20 @@ static int msync_interval(struct vm_area
 		ret = filemap_sync(vma, start, end-start, flags);
 
 		if (!ret && (flags & MS_SYNC)) {
-			struct inode *inode = file->f_dentry->d_inode;
+			struct address_space *mapping = file->f_mapping;
 			int err;
 
-			down(&inode->i_sem);
-			ret = filemap_fdatawrite(inode->i_mapping);
+			down(&mapping->host->i_sem);
+			ret = filemap_fdatawrite(mapping);
 			if (file->f_op && file->f_op->fsync) {
 				err = file->f_op->fsync(file,file->f_dentry,1);
 				if (err && !ret)
 					ret = err;
 			}
-			err = filemap_fdatawait(inode->i_mapping);
+			err = filemap_fdatawait(mapping);
 			if (!ret)
 				ret = err;
-			up(&inode->i_sem);
+			up(&mapping->host->i_sem);
 		}
 	}
 	return ret;
diff -puN mm/nommu.c~linus mm/nommu.c
--- 25/mm/nommu.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/mm/nommu.c	2004-01-19 22:17:24.000000000 -0800
@@ -25,12 +25,12 @@
 #include <asm/tlbflush.h>
 
 void *high_memory;
-struct page *mem_map = NULL;
+struct page *mem_map;
 unsigned long max_mapnr;
 unsigned long num_physpages;
 unsigned long askedalloc, realalloc;
 atomic_t vm_committed_space = ATOMIC_INIT(0);
-int sysctl_overcommit_memory = 0; /* default is heuristic overcommit */
+int sysctl_overcommit_memory; /* default is heuristic overcommit */
 int sysctl_overcommit_ratio = 50; /* default is 50% */
 
 /*
@@ -551,6 +551,11 @@ struct page * follow_page(struct mm_stru
 	return NULL;
 }
 
+struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
+{
+	return NULL;
+}
+
 int remap_page_range(struct vm_area_struct *vma, unsigned long from,
 		unsigned long to, unsigned long size, pgprot_t prot)
 {
diff -puN mm/page_alloc.c~linus mm/page_alloc.c
--- 25/mm/page_alloc.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/mm/page_alloc.c	2004-01-19 22:17:25.000000000 -0800
@@ -50,7 +50,7 @@ EXPORT_SYMBOL(nr_swap_pages);
  * Used by page_zone() to look up the address of the struct zone whose
  * id is encoded in the upper bits of page->flags
  */
-struct zone *zone_table[MAX_NR_ZONES*MAX_NUMNODES];
+struct zone *zone_table[1 << (ZONES_SHIFT + NODES_SHIFT)];
 EXPORT_SYMBOL(zone_table);
 
 static char *zone_names[MAX_NR_ZONES] = { "DMA", "Normal", "HighMem" };
@@ -539,7 +539,7 @@ __alloc_pages(unsigned int gfp_mask, uns
 {
 	const int wait = gfp_mask & __GFP_WAIT;
 	unsigned long min;
-	struct zone **zones, *classzone;
+	struct zone **zones;
 	struct page *page;
 	struct reclaim_state reclaim_state;
 	struct task_struct *p = current;
@@ -554,8 +554,7 @@ __alloc_pages(unsigned int gfp_mask, uns
 		cold = 1;
 
 	zones = zonelist->zones;  /* the list of zones suitable for gfp_mask */
-	classzone = zones[0]; 
-	if (classzone == NULL)    /* no zones in the zonelist */
+	if (zones[0] == NULL)     /* no zones in the zonelist */
 		return NULL;
 
 	/* Go through the zonelist once, looking for a zone with enough free */
@@ -630,7 +629,7 @@ rebalance:
 	reclaim_state.reclaimed_slab = 0;
 	p->reclaim_state = &reclaim_state;
 
-	try_to_free_pages(classzone, gfp_mask, order);
+	try_to_free_pages(zones, gfp_mask, order);
 
 	p->reclaim_state = NULL;
 	p->flags &= ~PF_MEMALLOC;
@@ -670,10 +669,11 @@ rebalance:
 	}
 
 nopage:
-	if (!(gfp_mask & __GFP_NOWARN)) {
-		printk("%s: page allocation failure."
+	if (!(gfp_mask & __GFP_NOWARN) && printk_ratelimit()) {
+		printk(KERN_WARNING "%s: page allocation failure."
 			" order:%d, mode:0x%x\n",
 			p->comm, order, gfp_mask);
+		dump_stack();
 	}
 	return NULL;
 got_pg:
@@ -869,14 +869,14 @@ void __get_page_state(struct page_state 
 	while (cpu < NR_CPUS) {
 		unsigned long *in, *out, off;
 
-		if (!cpu_online(cpu)) {
+		if (!cpu_possible(cpu)) {
 			cpu++;
 			continue;
 		}
 
 		in = (unsigned long *)&per_cpu(page_states, cpu);
 		cpu++;
-		if (cpu < NR_CPUS && cpu_online(cpu))
+		if (cpu < NR_CPUS && cpu_possible(cpu))
 			prefetch(&per_cpu(page_states, cpu));
 		out = (unsigned long *)ret;
 		for (off = 0; off < nr; off++)
@@ -1212,7 +1212,7 @@ void __init memmap_init_zone(struct page
 	struct page *page;
 
 	for (page = start; page < (start + size); page++) {
-		set_page_zone(page, nid * MAX_NR_ZONES + zone);
+		set_page_zone(page, NODEZONE(nid, zone));
 		set_page_count(page, 0);
 		SetPageReserved(page);
 		INIT_LIST_HEAD(&page->list);
@@ -1253,7 +1253,7 @@ static void __init free_area_init_core(s
 		unsigned long size, realsize;
 		unsigned long batch;
 
-		zone_table[nid * MAX_NR_ZONES + j] = zone;
+		zone_table[NODEZONE(nid, j)] = zone;
 		realsize = size = zones_size[j];
 		if (zholes_size)
 			realsize -= zholes_size[j];
@@ -1266,6 +1266,8 @@ static void __init free_area_init_core(s
 		zone->zone_pgdat = pgdat;
 		zone->free_pages = 0;
 
+		zone->temp_priority = zone->prev_priority = DEF_PRIORITY;
+
 		/*
 		 * The per-cpu-pages pools are set to around 1000th of the
 		 * size of the zone.  But no more than 1/4 of a meg - there's
diff -puN mm/page-writeback.c~linus mm/page-writeback.c
--- 25/mm/page-writeback.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/mm/page-writeback.c	2004-01-19 22:17:24.000000000 -0800
@@ -233,6 +233,7 @@ void balance_dirty_pages_ratelimited(str
 	}
 	put_cpu_var(ratelimits);
 }
+EXPORT_SYMBOL(balance_dirty_pages_ratelimited);
 
 /*
  * writeback at least _min_pages, and keep writing until the amount of dirty
diff -puN mm/readahead.c~linus mm/readahead.c
--- 25/mm/readahead.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/mm/readahead.c	2004-01-19 22:17:25.000000000 -0800
@@ -449,12 +449,8 @@ do_io:
 			  * accessed in the current window, there
 			  * is a high probability that around 'n' pages
 			  * shall be used in the next current window.
-			  *
-			  * To minimize lazy-readahead triggered
-			  * in the next current window, read in
-			  * an extra page.
 			  */
-			ra->next_size = preoffset - ra->start + 2;
+			ra->next_size = preoffset - ra->start + 1;
 		}
 		ra->start = offset;
 		ra->size = ra->next_size;
@@ -474,13 +470,9 @@ do_io:
 		/*
 		 * This read request is within the current window.  It is time
 		 * to submit I/O for the ahead window while the application is
-		 * about to step into the ahead window.
-		 * Heuristic: Defer reading the ahead window till we hit
-		 * the last page in the current window. (lazy readahead)
-		 * If we read in earlier we run the risk of wasting
-		 * the ahead window.
+		 * crunching through the current window.
 		 */
-		if (ra->ahead_start == 0 && offset == (ra->start + ra->size -1)) {
+		if (ra->ahead_start == 0) {
 			ra->ahead_start = ra->start + ra->size;
 			ra->ahead_size = ra->next_size;
 			actual = do_page_cache_readahead(mapping, filp,
diff -puN mm/rmap.c~linus mm/rmap.c
--- 25/mm/rmap.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/mm/rmap.c	2004-01-19 22:17:25.000000000 -0800
@@ -117,6 +117,9 @@ int page_referenced(struct page * page)
 	struct pte_chain *pc;
 	int referenced = 0;
 
+	if (page_test_and_clear_young(page))
+		mark_page_accessed(page);
+
 	if (TestClearPageReferenced(page))
 		referenced++;
 
@@ -132,12 +135,10 @@ int page_referenced(struct page * page)
 		for (pc = page->pte.chain; pc; pc = pte_chain_next(pc)) {
 			int i;
 
-			for (i = NRPTE-1; i >= 0; i--) {
+			for (i = pte_chain_idx(pc); i < NRPTE; i++) {
 				pte_addr_t pte_paddr = pc->ptes[i];
 				pte_t *p;
 
-				if (!pte_paddr)
-					break;
 				p = rmap_ptep_map(pte_paddr);
 				if (ptep_test_and_clear_young(p))
 					referenced++;
@@ -242,7 +243,7 @@ void page_remove_rmap(struct page *page,
 	} else {
 		struct pte_chain *start = page->pte.chain;
 		struct pte_chain *next;
-		int victim_i = -1;
+		int victim_i = pte_chain_idx(start);
 
 		for (pc = start; pc; pc = next) {
 			int i;
@@ -253,8 +254,6 @@ void page_remove_rmap(struct page *page,
 			for (i = pte_chain_idx(pc); i < NRPTE; i++) {
 				pte_addr_t pa = pc->ptes[i];
 
-				if (victim_i == -1)
-					victim_i = i;
 				if (pa != pte_paddr)
 					continue;
 				pc->ptes[i] = start->ptes[victim_i];
@@ -271,6 +270,8 @@ void page_remove_rmap(struct page *page,
 		}
 	}
 out:
+	if (page->pte.direct == 0 && page_test_and_clear_dirty(page))
+		set_page_dirty(page);
 	if (!page_mapped(page))
 		dec_page_state(nr_mapped);
 out_unlock:
@@ -329,8 +330,7 @@ static int try_to_unmap_one(struct page 
 
 	/* Nuke the page table entry. */
 	flush_cache_page(vma, address);
-	pte = ptep_get_and_clear(ptep);
-	flush_tlb_page(vma, address);
+	pte = ptep_clear_flush(vma, address, ptep);
 
 	if (PageSwapCache(page)) {
 		/*
@@ -386,7 +386,7 @@ int try_to_unmap(struct page * page)
 {
 	struct pte_chain *pc, *next_pc, *start;
 	int ret = SWAP_SUCCESS;
-	int victim_i = -1;
+	int victim_i;
 
 	/* This page should not be on the pageout lists. */
 	if (PageReserved(page))
@@ -400,6 +400,8 @@ int try_to_unmap(struct page * page)
 	if (PageDirect(page)) {
 		ret = try_to_unmap_one(page, page->pte.direct);
 		if (ret == SWAP_SUCCESS) {
+			if (page_test_and_clear_dirty(page))
+				set_page_dirty(page);
 			page->pte.direct = 0;
 			ClearPageDirect(page);
 		}
@@ -407,6 +409,7 @@ int try_to_unmap(struct page * page)
 	}		
 
 	start = page->pte.chain;
+	victim_i = pte_chain_idx(start);
 	for (pc = start; pc; pc = next_pc) {
 		int i;
 
@@ -416,11 +419,6 @@ int try_to_unmap(struct page * page)
 		for (i = pte_chain_idx(pc); i < NRPTE; i++) {
 			pte_addr_t pte_paddr = pc->ptes[i];
 
-			if (!pte_paddr)
-				continue;
-			if (victim_i == -1) 
-				victim_i = i;
-
 			switch (try_to_unmap_one(page, pte_paddr)) {
 			case SWAP_SUCCESS:
 				/*
@@ -440,6 +438,9 @@ int try_to_unmap(struct page * page)
 				} else {
 					start->next_and_idx++;
 				}
+				if (page->pte.direct == 0 &&
+				    page_test_and_clear_dirty(page))
+					set_page_dirty(page);
 				break;
 			case SWAP_AGAIN:
 				/* Skip this pte, remembering status. */
diff -puN mm/shmem.c~linus mm/shmem.c
--- 25/mm/shmem.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/mm/shmem.c	2004-01-19 22:17:25.000000000 -0800
@@ -1186,7 +1186,7 @@ shmem_file_write(struct file *file, cons
 	pos = *ppos;
 	written = 0;
 
-	err = generic_write_checks(inode, file, &pos, &count, 0);
+	err = generic_write_checks(file, &pos, &count, 0);
 	if (err || !count)
 		goto out;
 
@@ -1978,6 +1978,7 @@ struct file *shmem_file_setup(char *name
 	inode->i_nlink = 0;	/* It is unlinked */
 	file->f_vfsmnt = mntget(shm_mnt);
 	file->f_dentry = dentry;
+	file->f_mapping = inode->i_mapping;
 	file->f_op = &shmem_file_operations;
 	file->f_mode = FMODE_WRITE | FMODE_READ;
 	return(file);
diff -puN mm/swapfile.c~linus mm/swapfile.c
--- 25/mm/swapfile.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/mm/swapfile.c	2004-01-19 22:17:25.000000000 -0800
@@ -912,7 +912,7 @@ static int setup_swap_extents(struct swa
 	sector_t last_block;
 	int ret;
 
-	inode = sis->swap_file->f_dentry->d_inode;
+	inode = sis->swap_file->f_mapping->host;
 	if (S_ISBLK(inode->i_mode)) {
 		ret = add_swap_extent(sis, 0, sis->max, 0);
 		goto done;
@@ -1031,13 +1031,13 @@ asmlinkage long sys_swapoff(const char _
 	if (IS_ERR(victim))
 		goto out;
 
-	mapping = victim->f_dentry->d_inode->i_mapping;
+	mapping = victim->f_mapping;
 	prev = -1;
 	swap_list_lock();
 	for (type = swap_list.head; type >= 0; type = swap_info[type].next) {
 		p = swap_info + type;
 		if ((p->flags & SWP_ACTIVE) == SWP_ACTIVE) {
-			if (p->swap_file->f_dentry->d_inode->i_mapping==mapping)
+			if (p->swap_file->f_mapping == mapping)
 				break;
 		}
 		prev = type;
@@ -1099,13 +1099,12 @@ asmlinkage long sys_swapoff(const char _
 	swap_device_unlock(p);
 	swap_list_unlock();
 	vfree(swap_map);
-	if (S_ISBLK(swap_file->f_dentry->d_inode->i_mode)) {
-		struct block_device *bdev;
-		bdev = swap_file->f_dentry->d_inode->i_bdev;
+	if (S_ISBLK(mapping->host->i_mode)) {
+		struct block_device *bdev = I_BDEV(mapping->host);
 		set_blocksize(bdev, p->old_block_size);
 		bd_release(bdev);
 	} else {
-		up(&swap_file->f_dentry->d_inode->i_mapping->host->i_sem);
+		up(&mapping->host->i_sem);
 	}
 	filp_close(swap_file, NULL);
 	err = 0;
@@ -1231,8 +1230,8 @@ asmlinkage long sys_swapon(const char __
 	int swapfilesize;
 	unsigned short *swap_map;
 	struct page *page = NULL;
-	struct inode *inode;
-	struct inode *downed_inode = NULL;
+	struct inode *inode = NULL;
+	int did_down = 0;
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
@@ -1279,8 +1278,8 @@ asmlinkage long sys_swapon(const char __
 	}
 
 	p->swap_file = swap_file;
-	inode = swap_file->f_dentry->d_inode;
-	mapping = swap_file->f_dentry->d_inode->i_mapping;
+	mapping = swap_file->f_mapping;
+	inode = mapping->host;
 
 	error = -EBUSY;
 	for (i = 0; i < nr_swapfiles; i++) {
@@ -1288,32 +1287,32 @@ asmlinkage long sys_swapon(const char __
 
 		if (i == type || !q->swap_file)
 			continue;
-		if (mapping == q->swap_file->f_dentry->d_inode->i_mapping)
+		if (mapping == q->swap_file->f_mapping)
 			goto bad_swap;
 	}
 
 	error = -EINVAL;
 	if (S_ISBLK(inode->i_mode)) {
-		bdev = inode->i_bdev;
+		bdev = I_BDEV(inode);
 		error = bd_claim(bdev, sys_swapon);
 		if (error < 0) {
 			bdev = NULL;
 			goto bad_swap;
 		}
 		p->old_block_size = block_size(bdev);
-		error = set_blocksize(inode->i_bdev, PAGE_SIZE);
+		error = set_blocksize(bdev, PAGE_SIZE);
 		if (error < 0)
 			goto bad_swap;
 		p->bdev = bdev;
 	} else if (S_ISREG(inode->i_mode)) {
 		p->bdev = inode->i_sb->s_bdev;
-		downed_inode = mapping->host;
-		down(&downed_inode->i_sem);
+		down(&inode->i_sem);
+		did_down = 1;
 	} else {
 		goto bad_swap;
 	}
 
-	swapfilesize = i_size_read(mapping->host) >> PAGE_SHIFT;
+	swapfilesize = i_size_read(inode) >> PAGE_SHIFT;
 
 	/*
 	 * Read the swap header.
@@ -1465,8 +1464,8 @@ out:
 	}
 	if (name)
 		putname(name);
-	if (error && downed_inode)
-		up(&downed_inode->i_sem);
+	if (error && did_down)
+		up(&inode->i_sem);
 	return error;
 }
 
diff -puN mm/vmscan.c~linus mm/vmscan.c
--- 25/mm/vmscan.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/mm/vmscan.c	2004-01-19 22:17:25.000000000 -0800
@@ -38,13 +38,6 @@
 #include <linux/swapops.h>
 
 /*
- * The "priority" of VM scanning is how much of the queues we will scan in one
- * go. A value of 12 for DEF_PRIORITY implies that we will scan 1/4096th of the
- * queues ("queue_length >> 12") during an aging round.
- */
-#define DEF_PRIORITY 12
-
-/*
  * From 0 .. 100.  Higher means more swappy.
  */
 int vm_swappiness = 60;
@@ -803,16 +796,15 @@ shrink_zone(struct zone *zone, int max_s
  * scan then give up on it.
  */
 static int
-shrink_caches(struct zone *classzone, int priority, int *total_scanned,
+shrink_caches(struct zone **zones, int priority, int *total_scanned,
 		int gfp_mask, int nr_pages, struct page_state *ps)
 {
-	struct zone *first_classzone;
-	struct zone *zone;
 	int ret = 0;
+	int i;
 
-	first_classzone = classzone->zone_pgdat->node_zones;
-	for (zone = classzone; zone >= first_classzone; zone--) {
+	for (i = 0; zones[i] != NULL; i++) {
 		int to_reclaim = max(nr_pages, SWAP_CLUSTER_MAX);
+		struct zone *zone = zones[i];
 		int nr_mapped = 0;
 		int max_scan;
 
@@ -855,27 +847,27 @@ shrink_caches(struct zone *classzone, in
  * excessive rotation of the inactive list, which is _supposed_ to be an LRU,
  * yes?
  */
-int try_to_free_pages(struct zone *cz,
+int try_to_free_pages(struct zone **zones,
 		unsigned int gfp_mask, unsigned int order)
 {
 	int priority;
 	int ret = 0;
 	const int nr_pages = SWAP_CLUSTER_MAX;
 	int nr_reclaimed = 0;
-	struct zone *zone;
 	struct reclaim_state *reclaim_state = current->reclaim_state;
+	int i;
 
 	inc_page_state(allocstall);
 
-	for (zone = cz; zone >= cz->zone_pgdat->node_zones; --zone)
-		zone->temp_priority = DEF_PRIORITY;
+	for (i = 0; zones[i] != 0; i++)
+		zones[i]->temp_priority = DEF_PRIORITY;
 
 	for (priority = DEF_PRIORITY; priority >= 0; priority--) {
 		int total_scanned = 0;
 		struct page_state ps;
 
 		get_page_state(&ps);
-		nr_reclaimed += shrink_caches(cz, priority, &total_scanned,
+		nr_reclaimed += shrink_caches(zones, priority, &total_scanned,
 						gfp_mask, nr_pages, &ps);
 		if (nr_reclaimed >= nr_pages) {
 			ret = 1;
@@ -892,7 +884,7 @@ int try_to_free_pages(struct zone *cz,
 
 		/* Take a nap, wait for some writeback to complete */
 		blk_congestion_wait(WRITE, HZ/10);
-		if (cz - cz->zone_pgdat->node_zones < ZONE_HIGHMEM) {
+		if (zones[0] - zones[0]->zone_pgdat->node_zones < ZONE_HIGHMEM) {
 			shrink_slab(total_scanned, gfp_mask);
 			if (reclaim_state) {
 				nr_reclaimed += reclaim_state->reclaimed_slab;
@@ -903,8 +895,8 @@ int try_to_free_pages(struct zone *cz,
 	if ((gfp_mask & __GFP_FS) && !(gfp_mask & __GFP_NORETRY))
 		out_of_memory();
 out:
-	for (zone = cz; zone >= cz->zone_pgdat->node_zones; --zone)
-		zone->prev_priority = zone->temp_priority;
+	for (i = 0; zones[i] != 0; i++)
+		zones[i]->prev_priority = zones[i]->temp_priority;
 	return ret;
 }
 
diff -puN net/appletalk/ddp.c~linus net/appletalk/ddp.c
--- 25/net/appletalk/ddp.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/appletalk/ddp.c	2004-01-19 22:17:25.000000000 -0800
@@ -1552,7 +1552,7 @@ freeit:
 }
 
 static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
-			 int len)
+			 size_t len)
 {
 	struct sock *sk = sock->sk;
 	struct atalk_sock *at = at_sk(sk);
@@ -1712,7 +1712,7 @@ static int atalk_sendmsg(struct kiocb *i
 }
 
 static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
-			 int size, int flags)
+			 size_t size, int flags)
 {
 	struct sock *sk = sock->sk;
 	struct sockaddr_at *sat = (struct sockaddr_at *)msg->msg_name;
diff -puN net/atm/br2684.c~linus net/atm/br2684.c
--- 25/net/atm/br2684.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/atm/br2684.c	2004-01-19 22:17:25.000000000 -0800
@@ -437,6 +437,10 @@ static void br2684_push(struct atm_vcc *
 			dev_kfree_skb(skb);
 			return;
 		}
+
+		/* Strip FCS if present */
+		if (skb->len > 7 && skb->data[7] == 0x01)
+			__skb_trim(skb, skb->len - 4);
 	} else {
 		plen = PADLEN + ETH_HLEN;	/* pad, dstmac,srcmac, ethtype */
 		/* first 2 chars should be 0 */
diff -puN net/atm/clip.c~linus net/atm/clip.c
--- 25/net/atm/clip.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/atm/clip.c	2004-01-19 22:17:25.000000000 -0800
@@ -731,8 +731,6 @@ static struct atm_dev atmarpd_dev = {
 
 static int atm_init_atmarp(struct atm_vcc *vcc)
 {
-	struct net_device *dev;
-
 	if (atmarpd) return -EADDRINUSE;
 	if (start_timer) {
 		start_timer = 0;
@@ -754,9 +752,6 @@ static int atm_init_atmarp(struct atm_vc
 		printk(KERN_ERR "register_netdevice_notifier failed\n");
 	if (register_inetaddr_notifier(&clip_inet_notifier))
 		printk(KERN_ERR "register_inetaddr_notifier failed\n");
-	for (dev = clip_devs; dev; dev = PRIV(dev)->next)
-		if (dev->flags & IFF_UP)
-			(void) to_atmarpd(act_up,PRIV(dev)->number,0);
 	return 0;
 }
 
diff -puN net/atm/common.c~linus net/atm/common.c
--- 25/net/atm/common.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/atm/common.c	2004-01-19 22:17:25.000000000 -0800
@@ -463,7 +463,7 @@ int vcc_connect(struct socket *sock, int
 
 
 int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
-		int size, int flags)
+		size_t size, int flags)
 {
 	struct sock *sk = sock->sk;
 	struct atm_vcc *vcc;
@@ -476,9 +476,8 @@ int vcc_recvmsg(struct kiocb *iocb, stru
 		return -EOPNOTSUPP;
 	vcc = ATM_SD(sock);
 	if (test_bit(ATM_VF_RELEASED,&vcc->flags) ||
-	    test_bit(ATM_VF_CLOSE,&vcc->flags))
-		return -sk->sk_err;
-	if (!test_bit(ATM_VF_READY, &vcc->flags))
+	    test_bit(ATM_VF_CLOSE,&vcc->flags) ||
+	    !test_bit(ATM_VF_READY, &vcc->flags))
 		return 0;
 
 	skb = skb_recv_datagram(sk, flags, flags & MSG_DONTWAIT, &error);
@@ -503,7 +502,7 @@ int vcc_recvmsg(struct kiocb *iocb, stru
 
 
 int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
-		int total_len)
+		size_t total_len)
 {
 	struct sock *sk = sock->sk;
 	DEFINE_WAIT(wait);
@@ -530,12 +529,10 @@ int vcc_sendmsg(struct kiocb *iocb, stru
 	size = m->msg_iov->iov_len;
 	vcc = ATM_SD(sock);
 	if (test_bit(ATM_VF_RELEASED, &vcc->flags) ||
-	    test_bit(ATM_VF_CLOSE, &vcc->flags)) {
-		error = -sk->sk_err;
-		goto out;
-	}
-	if (!test_bit(ATM_VF_READY, &vcc->flags)) {
+	    test_bit(ATM_VF_CLOSE, &vcc->flags) ||
+	    !test_bit(ATM_VF_READY, &vcc->flags)) {
 		error = -EPIPE;
+		send_sig(SIGPIPE, current, 0);
 		goto out;
 	}
 	if (!size) {
@@ -561,12 +558,10 @@ int vcc_sendmsg(struct kiocb *iocb, stru
 			break;
 		}
 		if (test_bit(ATM_VF_RELEASED,&vcc->flags) ||
-		    test_bit(ATM_VF_CLOSE,&vcc->flags)) {
-			error = -sk->sk_err;
-			break;
-		}
-		if (!test_bit(ATM_VF_READY,&vcc->flags)) {
+		    test_bit(ATM_VF_CLOSE,&vcc->flags) ||
+		    !test_bit(ATM_VF_READY,&vcc->flags)) {
 			error = -EPIPE;
+			send_sig(SIGPIPE, current, 0);
 			break;
 		}
 		prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
diff -puN net/atm/common.h~linus net/atm/common.h
--- 25/net/atm/common.h~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/atm/common.h	2004-01-19 22:17:25.000000000 -0800
@@ -14,9 +14,9 @@ int vcc_create(struct socket *sock, int 
 int vcc_release(struct socket *sock);
 int vcc_connect(struct socket *sock, int itf, short vpi, int vci);
 int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
-		int size, int flags);
+		size_t size, int flags);
 int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
-		int total_len);
+		size_t total_len);
 unsigned int vcc_poll(struct file *file, struct socket *sock, poll_table *wait);
 int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
 int vcc_setsockopt(struct socket *sock, int level, int optname, char *optval,
diff -puN net/ax25/af_ax25.c~linus net/ax25/af_ax25.c
--- 25/net/ax25/af_ax25.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/ax25/af_ax25.c	2004-01-19 22:17:25.000000000 -0800
@@ -1401,7 +1401,7 @@ out:
 }
 
 static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock,
-			struct msghdr *msg, int len)
+			struct msghdr *msg, size_t len)
 {
 	struct sockaddr_ax25 *usax = (struct sockaddr_ax25 *)msg->msg_name;
 	struct sock *sk = sock->sk;
@@ -1410,7 +1410,8 @@ static int ax25_sendmsg(struct kiocb *io
 	ax25_digi dtmp, *dp;
 	unsigned char *asmptr;
 	ax25_cb *ax25;
-	int lv, size, err, addr_len = msg->msg_namelen;
+	size_t size;
+	int lv, err, addr_len = msg->msg_namelen;
 
 	if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_EOR)) {
 		return -EINVAL;
@@ -1435,6 +1436,11 @@ static int ax25_sendmsg(struct kiocb *io
 		goto out;
 	}
 
+	if (len > ax25->ax25_dev->dev->mtu) {
+		err = -EMSGSIZE;
+		goto out;
+	}
+		
 	if (usax != NULL) {
 		if (usax->sax25_family != AF_AX25) {
 			err = -EINVAL;
@@ -1580,7 +1586,7 @@ out:
 }
 
 static int ax25_recvmsg(struct kiocb *iocb, struct socket *sock,
-	struct msghdr *msg, int size, int flags)
+	struct msghdr *msg, size_t size, int flags)
 {
 	struct sock *sk = sock->sk;
 	struct sk_buff *skb;
diff -puN net/bluetooth/af_bluetooth.c~linus net/bluetooth/af_bluetooth.c
--- 25/net/bluetooth/af_bluetooth.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/bluetooth/af_bluetooth.c	2004-01-19 22:17:25.000000000 -0800
@@ -59,7 +59,7 @@
 struct proc_dir_entry *proc_bt;
 
 /* Bluetooth sockets */
-#define BT_MAX_PROTO	5
+#define BT_MAX_PROTO	6
 static struct net_proto_family *bt_proto[BT_MAX_PROTO];
 
 static kmem_cache_t *bt_sock_cache;
@@ -201,12 +201,13 @@ struct sock *bt_accept_dequeue(struct so
 }
 
 int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-	struct msghdr *msg, int len, int flags)
+	struct msghdr *msg, size_t len, int flags)
 {
 	int noblock = flags & MSG_DONTWAIT;
 	struct sock *sk = sock->sk;
 	struct sk_buff *skb;
-	int copied, err;
+	size_t copied;
+	int err;
 
 	BT_DBG("sock %p sk %p len %d", sock, sk, len);
 
diff -puN net/bluetooth/bnep/core.c~linus net/bluetooth/bnep/core.c
--- 25/net/bluetooth/bnep/core.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/bluetooth/bnep/core.c	2004-01-19 22:17:25.000000000 -0800
@@ -707,3 +707,4 @@ module_exit(bnep_cleanup_module);
 MODULE_DESCRIPTION("Bluetooth BNEP ver " VERSION);
 MODULE_AUTHOR("David Libault <david.libault@inventel.fr>, Maxim Krasnyanskiy <maxk@qualcomm.com>");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("bt-proto-4");
diff -puN /dev/null net/bluetooth/cmtp/capi.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/net/bluetooth/cmtp/capi.c	2004-01-19 22:17:25.000000000 -0800
@@ -0,0 +1,630 @@
+/* 
+   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/isdn/capilli.h>
+#include <linux/isdn/capicmd.h>
+#include <linux/isdn/capiutil.h>
+
+#include "cmtp.h"
+
+#ifndef CONFIG_BT_CMTP_DEBUG
+#undef  BT_DBG
+#define BT_DBG(D...)
+#endif
+
+#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
+
+
+#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;
+				capi_ctr_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;
+	__u32 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;
+	}
+
+	capi_ctr_handle_message(ctrl, appl, skb);
+}
+
+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 0;
+}
+
+static void cmtp_reset_ctr(struct capi_ctr *ctrl)
+{
+	struct cmtp_session *session = ctrl->driverdata;
+
+	BT_DBG("ctrl %p", ctrl);
+
+	capi_ctr_reseted(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");
+		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) {
+		cmtp_application_del(session, application);
+		return;
+	}
+}
+
+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);
+}
+
+static u16 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 CAPI_ILLAPPNR;
+	}
+
+	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);
+
+	return CAPI_NOERROR;
+}
+
+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\n\n", cmtp_procinfo(ctrl));
+	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);
+}
+
+
+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");
+
+	session->ctrl.owner      = THIS_MODULE;
+	session->ctrl.driverdata = session;
+	strcpy(session->ctrl.name, session->name);
+
+	session->ctrl.driver_name   = "cmtp";
+	session->ctrl.load_firmware = cmtp_load_firmware;
+	session->ctrl.reset_ctr     = cmtp_reset_ctr;
+	session->ctrl.register_appl = cmtp_register_appl;
+	session->ctrl.release_appl  = cmtp_release_appl;
+	session->ctrl.send_message  = cmtp_send_message;
+
+	session->ctrl.procinfo      = cmtp_procinfo;
+	session->ctrl.ctr_read_proc = cmtp_ctr_read_proc;
+
+	if (attach_capi_ctr(&session->ctrl) < 0) {
+		BT_ERR("Can't attach new controller");
+		return -EBUSY;
+	}
+
+	session->num = session->ctrl.cnr;
+
+	BT_DBG("session %p num %d", session, 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)
+{
+	BT_DBG("session %p", session);
+
+	detach_capi_ctr(&session->ctrl);
+}
diff -puN /dev/null net/bluetooth/cmtp/cmtp.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/net/bluetooth/cmtp/cmtp.h	2004-01-19 22:17:25.000000000 -0800
@@ -0,0 +1,136 @@
+/* 
+   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->sk_sleep);
+}
+
+/* CMTP init defines */
+int cmtp_init_sockets(void);
+void cmtp_cleanup_sockets(void);
+
+#endif /* __CMTP_H */
diff -puN /dev/null net/bluetooth/cmtp/core.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/net/bluetooth/cmtp/core.c	2004-01-19 22:17:25.000000000 -0800
@@ -0,0 +1,507 @@
+/* 
+   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 <linux/init.h>
+#include <net/sock.h>
+
+#include <linux/isdn/capilli.h>
+
+#include <net/bluetooth/bluetooth.h>
+#include <net/bluetooth/l2cap.h>
+
+#include "cmtp.h"
+
+#ifndef CONFIG_BT_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)
+{
+	__module_get(THIS_MODULE);
+	list_add(&session->list, &cmtp_session_list);
+}
+
+static void __cmtp_unlink_session(struct cmtp_session *session)
+{
+	list_del(&session->list);
+	module_put(THIS_MODULE);
+}
+
+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;
+
+	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;
+
+	return sock_sendmsg(sock, &msg, len);
+}
+
+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("kcmtpd_ctr_%d", session->num);
+	set_user_nice(current, -15);
+	current->flags |= PF_IOTHREAD;
+
+	set_fs(KERNEL_DS);
+
+	init_waitqueue_entry(&wait, current);
+	add_wait_queue(sk->sk_sleep, &wait);
+	while (!atomic_read(&session->terminate)) {
+		set_current_state(TASK_INTERRUPTIBLE);
+
+		if (sk->sk_state != BT_CONNECTED)
+			break;
+
+		while ((skb = skb_dequeue(&sk->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->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, &bt_sk(sock->sk)->src);
+	baswap(&dst, &bt_sk(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(&bt_sk(sock->sk)->dst);
+	if (s && s->state == BT_CONNECTED) {
+		err = -EEXIST;
+		goto failed;
+	}
+
+	bacpy(&session->bdaddr, &bt_sk(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->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_KERNEL);
+	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)
+{
+	l2cap_load();
+
+	BT_INFO("CMTP (CAPI Emulation) ver %s", VERSION);
+
+	cmtp_init_sockets();
+
+	return 0;
+}
+
+void __exit exit_cmtp(void)
+{
+	cmtp_cleanup_sockets();
+}
+
+module_init(init_cmtp);
+module_exit(exit_cmtp);
+
+MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
+MODULE_DESCRIPTION("Bluetooth CMTP ver " VERSION);
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("bt-proto-5");
diff -puN /dev/null net/bluetooth/cmtp/Kconfig
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/net/bluetooth/cmtp/Kconfig	2004-01-19 22:17:25.000000000 -0800
@@ -0,0 +1,11 @@
+config BT_CMTP
+	tristate "CMTP protocol support"
+	depends on BT && BT_L2CAP && ISDN_CAPI
+	help
+	  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).
+
diff -puN /dev/null net/bluetooth/cmtp/Makefile
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/net/bluetooth/cmtp/Makefile	2004-01-19 22:17:25.000000000 -0800
@@ -0,0 +1,7 @@
+#
+# Makefile for the Linux Bluetooth CMTP layer
+#
+
+obj-$(CONFIG_BT_CMTP) += cmtp.o
+
+cmtp-objs := core.o sock.o capi.o
diff -puN /dev/null net/bluetooth/cmtp/sock.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/net/bluetooth/cmtp/sock.c	2004-01-19 22:17:25.000000000 -0800
@@ -0,0 +1,199 @@
+/* 
+   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/isdn/capilli.h>
+
+#include <asm/system.h>
+#include <asm/uaccess.h>
+
+#include "cmtp.h"
+
+#ifndef CONFIG_BT_CMTP_DEBUG
+#undef  BT_DBG
+#define BT_DBG(D...)
+#endif
+
+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);
+
+	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->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,
+	.owner		= THIS_MODULE,
+	.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;
+
+	if (!(sk = bt_sock_alloc(sock, PF_BLUETOOTH, 0, GFP_KERNEL)))
+		return -ENOMEM;
+
+	sk_set_owner(sk, THIS_MODULE);
+
+	sock->ops = &cmtp_sock_ops;
+
+	sock->state = SS_UNCONNECTED;
+
+	sk->sk_destruct = NULL;
+	sk->sk_protocol = protocol;
+
+	return 0;
+}
+
+static struct net_proto_family cmtp_sock_family_ops = {
+	.family	= PF_BLUETOOTH,
+	.owner	= THIS_MODULE,
+	.create	= cmtp_sock_create
+};
+
+int cmtp_init_sockets(void)
+{
+	bt_sock_register(BTPROTO_CMTP, &cmtp_sock_family_ops);
+
+	return 0;
+}
+
+void cmtp_cleanup_sockets(void)
+{
+	if (bt_sock_unregister(BTPROTO_CMTP))
+		BT_ERR("Can't unregister CMTP socket");
+}
diff -puN net/bluetooth/hci_conn.c~linus net/bluetooth/hci_conn.c
--- 25/net/bluetooth/hci_conn.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/bluetooth/hci_conn.c	2004-01-19 22:17:25.000000000 -0800
@@ -71,7 +71,7 @@ void hci_acl_connect(struct hci_conn *co
 
 	memset(&cp, 0, sizeof(cp));
 	bacpy(&cp.bdaddr, &conn->dst);
-	cp.pscan_rep_mode = 0x01;
+	cp.pscan_rep_mode = 0x02;
 
 	if ((ie = inquiry_cache_lookup(hdev, &conn->dst)) &&
 			inquiry_entry_age(ie) <= INQUIRY_ENTRY_AGE_MAX) {
diff -puN net/bluetooth/hci_core.c~linus net/bluetooth/hci_core.c
--- 25/net/bluetooth/hci_core.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/bluetooth/hci_core.c	2004-01-19 22:17:25.000000000 -0800
@@ -406,6 +406,7 @@ int hci_inquiry(unsigned long arg)
 
 	hci_dev_lock_bh(hdev);
 	if (inquiry_cache_age(hdev) > INQUIRY_CACHE_AGE_MAX || 
+					inquiry_cache_empty(hdev) ||
 					ir.flags & IREQ_CACHE_FLUSH) {
 		inquiry_cache_flush(hdev);
 		do_inquiry = 1;
diff -puN net/bluetooth/hci_event.c~linus net/bluetooth/hci_event.c
--- 25/net/bluetooth/hci_event.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/bluetooth/hci_event.c	2004-01-19 22:17:25.000000000 -0800
@@ -452,6 +452,29 @@ static inline void hci_inquiry_result_ev
 	hci_dev_unlock(hdev);
 }
 
+/* Inquiry Result With RSSI */
+static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct sk_buff *skb)
+{
+	struct inquiry_info_with_rssi *info = (struct inquiry_info_with_rssi *) (skb->data + 1);
+	int num_rsp = *((__u8 *) skb->data);
+
+	BT_DBG("%s num_rsp %d", hdev->name, num_rsp);
+
+	hci_dev_lock(hdev);
+	for (; num_rsp; num_rsp--) {
+		struct inquiry_info tmp;
+		bacpy(&tmp.bdaddr, &info->bdaddr);
+		tmp.pscan_rep_mode    = info->pscan_rep_mode;
+		tmp.pscan_period_mode = info->pscan_period_mode;
+		tmp.pscan_mode        = 0x00;
+		memcpy(tmp.dev_class, &info->dev_class, 3);
+		tmp.clock_offset      = info->clock_offset;
+		info++;
+		inquiry_cache_update(hdev, &tmp);
+	}
+	hci_dev_unlock(hdev);
+}
+
 /* Connect Request */
 static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
 {
@@ -744,6 +767,10 @@ void hci_event_packet(struct hci_dev *hd
 		hci_inquiry_result_evt(hdev, skb);
 		break;
 
+	case HCI_EV_INQUIRY_RESULT_WITH_RSSI:
+		hci_inquiry_result_with_rssi_evt(hdev, skb);
+		break;
+
 	case HCI_EV_CONN_REQUEST:
 		hci_conn_request_evt(hdev, skb);
 		break;
diff -puN net/bluetooth/hci_sock.c~linus net/bluetooth/hci_sock.c
--- 25/net/bluetooth/hci_sock.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/bluetooth/hci_sock.c	2004-01-19 22:17:25.000000000 -0800
@@ -66,20 +66,20 @@ static struct hci_sec_filter hci_sec_fil
 	/* Packet types */
 	0x10,
 	/* Events */
-	{ 0xd9fe, 0x0 },
+	{ 0x1000d9fe, 0x0000300c },
 	/* Commands */
 	{
 		{ 0x0 },
 		/* OGF_LINK_CTL */
-		{ 0x2a000002, 0x0, 0x0, 0x0  },
+		{ 0xbe000006, 0x00000001, 0x0000, 0x00 },
 		/* OGF_LINK_POLICY */
-		{ 0x1200, 0x0, 0x0, 0x0      },
+		{ 0x00005200, 0x00000000, 0x0000, 0x00 },
 		/* OGF_HOST_CTL */
-		{ 0x80100000, 0x202a, 0x0, 0x0 },
+		{ 0xaab00200, 0x2b402aaa, 0x0154, 0x00 },
 		/* OGF_INFO_PARAM */
-		{ 0x22a, 0x0, 0x0, 0x0       },
+		{ 0x000002be, 0x00000000, 0x0000, 0x00 },
 		/* OGF_STATUS_PARAM */
-		{ 0x2e, 0x0, 0x0, 0x0        }
+		{ 0x000000ea, 0x00000000, 0x0000, 0x00 }
 	}
 };
 
@@ -319,7 +319,8 @@ static inline void hci_sock_cmsg(struct 
         	put_cmsg(msg, SOL_HCI, HCI_CMSG_TSTAMP, sizeof(skb->stamp), &skb->stamp);
 }
  
-static int hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, int len, int flags)
+static int hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock, 
+			    struct msghdr *msg, size_t len, int flags)
 {
 	int noblock = flags & MSG_DONTWAIT;
 	struct sock *sk = sock->sk;
@@ -355,7 +356,8 @@ static int hci_sock_recvmsg(struct kiocb
 	return err ? : copied;
 }
 
-static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, int len)
+static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock, 
+			    struct msghdr *msg, size_t len)
 {
 	struct sock *sk = sock->sk;
 	struct hci_dev *hdev;
@@ -370,9 +372,9 @@ static int hci_sock_sendmsg(struct kiocb
 	if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_NOSIGNAL|MSG_ERRQUEUE))
 		return -EINVAL;
 
-	if (len < 4)
+	if (len < 4 || len > HCI_MAX_FRAME_SIZE)
 		return -EINVAL;
-	
+
 	lock_sock(sk);
 
 	if (!(hdev = hci_pi(sk)->hdev)) {
diff -puN net/bluetooth/Kconfig~linus net/bluetooth/Kconfig
--- 25/net/bluetooth/Kconfig~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/bluetooth/Kconfig	2004-01-19 22:17:25.000000000 -0800
@@ -21,6 +21,7 @@ config BT
 	     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 Bluetooth Core
 	  layer.
@@ -57,6 +58,8 @@ source "net/bluetooth/rfcomm/Kconfig"
 
 source "net/bluetooth/bnep/Kconfig"
 
+source "net/bluetooth/cmtp/Kconfig"
+
 source "drivers/bluetooth/Kconfig"
 
 endmenu
diff -puN net/bluetooth/l2cap.c~linus net/bluetooth/l2cap.c
--- 25/net/bluetooth/l2cap.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/bluetooth/l2cap.c	2004-01-19 22:17:25.000000000 -0800
@@ -706,7 +706,8 @@ fail:
 	return err;
 }
 
-static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, int len)
+static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, 
+			      struct msghdr *msg, size_t len)
 {
 	struct sock *sk = sock->sk;
 	int err = 0;
@@ -2201,3 +2202,4 @@ module_exit(l2cap_cleanup);
 MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>");
 MODULE_DESCRIPTION("Bluetooth L2CAP ver " VERSION);
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("bt-proto-0");
diff -puN net/bluetooth/Makefile~linus net/bluetooth/Makefile
--- 25/net/bluetooth/Makefile~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/bluetooth/Makefile	2004-01-19 22:17:25.000000000 -0800
@@ -7,5 +7,6 @@ obj-$(CONFIG_BT_L2CAP)	+= l2cap.o
 obj-$(CONFIG_BT_SCO)	+= sco.o
 obj-$(CONFIG_BT_RFCOMM)	+= rfcomm/
 obj-$(CONFIG_BT_BNEP)	+= bnep/
+obj-$(CONFIG_BT_CMTP)	+= cmtp/
 
 bluetooth-objs := af_bluetooth.o hci_core.o hci_conn.o hci_event.o hci_sock.o hci_proc.o lib.o syms.o
diff -puN net/bluetooth/rfcomm/core.c~linus net/bluetooth/rfcomm/core.c
--- 25/net/bluetooth/rfcomm/core.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/bluetooth/rfcomm/core.c	2004-01-19 22:17:25.000000000 -0800
@@ -52,7 +52,7 @@
 #include <net/bluetooth/l2cap.h>
 #include <net/bluetooth/rfcomm.h>
 
-#define VERSION "1.0"
+#define VERSION "1.1"
 
 #ifndef CONFIG_BT_RFCOMM_DEBUG
 #undef  BT_DBG
@@ -207,7 +207,7 @@ static void rfcomm_dlc_clear_state(struc
 	d->mtu        = RFCOMM_DEFAULT_MTU;
 	d->v24_sig    = RFCOMM_V24_RTC | RFCOMM_V24_RTR | RFCOMM_V24_DV;
 
-	d->credits    = RFCOMM_MAX_CREDITS;
+	d->cfc        = RFCOMM_CFC_DISABLED;
 	d->rx_credits = RFCOMM_DEFAULT_CREDITS;
 }
 
@@ -314,8 +314,8 @@ static int __rfcomm_dlc_open(struct rfco
 	d->state    = BT_CONFIG;
 	rfcomm_dlc_link(s, d);
 
-	d->mtu     = s->mtu;
-	d->credits = s->credits;
+	d->mtu = s->mtu;
+	d->cfc = (s->cfc == RFCOMM_CFC_UNKNOWN) ? 0 : s->cfc;
 
 	if (s->state == BT_CONNECTED)
 		rfcomm_send_pn(s, 1, d);
@@ -415,7 +415,7 @@ void __rfcomm_dlc_throttle(struct rfcomm
 {
 	BT_DBG("dlc %p state %ld", d, d->state);
 
-	if (!d->credits) {
+	if (!d->cfc) {
 		d->v24_sig |= RFCOMM_V24_FC;
 		set_bit(RFCOMM_MSC_PENDING, &d->flags);
 	}
@@ -426,7 +426,7 @@ void __rfcomm_dlc_unthrottle(struct rfco
 {
 	BT_DBG("dlc %p state %ld", d, d->state);
 
-	if (!d->credits) {
+	if (!d->cfc) {
 		d->v24_sig &= ~RFCOMM_V24_FC;
 		set_bit(RFCOMM_MSC_PENDING, &d->flags);
 	}
@@ -479,8 +479,8 @@ struct rfcomm_session *rfcomm_session_ad
 	s->state = state;
 	s->sock  = sock;
 
-	s->mtu     = RFCOMM_DEFAULT_MTU;
-	s->credits = RFCOMM_MAX_CREDITS;
+	s->mtu   = RFCOMM_DEFAULT_MTU;
+	s->cfc   = RFCOMM_CFC_UNKNOWN;
 	
 	list_add(&s->list, &session_list);
 
@@ -752,7 +752,7 @@ static int rfcomm_send_pn(struct rfcomm_
 	pn->ack_timer   = 0;
 	pn->max_retrans = 0;
 
-	if (d->credits) {
+	if (s->cfc) {
 		pn->flow_ctrl = cr ? 0xf0 : 0xe0;
 		pn->credits = RFCOMM_DEFAULT_CREDITS;
 	} else {
@@ -1142,28 +1142,22 @@ static int rfcomm_recv_sabm(struct rfcom
 
 static int rfcomm_apply_pn(struct rfcomm_dlc *d, int cr, struct rfcomm_pn *pn)
 {
+	struct rfcomm_session *s = d->session;
+
 	BT_DBG("dlc %p state %ld dlci %d mtu %d fc 0x%x credits %d", 
 			d, d->state, d->dlci, pn->mtu, pn->flow_ctrl, pn->credits);
 
-	if (cr) {
-		if (pn->flow_ctrl == 0xf0) {
-			d->tx_credits = pn->credits;
-		} else {
-			set_bit(RFCOMM_TX_THROTTLED, &d->flags);
-			d->credits = 0;
-		}
+	if (pn->flow_ctrl == 0xf0 || pn->flow_ctrl == 0xe0) {
+		d->cfc = s->cfc = RFCOMM_CFC_ENABLED;
+		d->tx_credits = pn->credits;
 	} else {
-		if (pn->flow_ctrl == 0xe0) {
-			d->tx_credits = pn->credits;
-		} else {
-			set_bit(RFCOMM_TX_THROTTLED, &d->flags);
-			d->credits = 0;
-		}
+		d->cfc = s->cfc = RFCOMM_CFC_DISABLED;
+		set_bit(RFCOMM_TX_THROTTLED, &d->flags);
 	}
 
 	d->priority = pn->priority;
 
-	d->mtu = btohs(pn->mtu);
+	d->mtu = s->mtu = btohs(pn->mtu);
 
 	return 0;
 }
@@ -1353,7 +1347,7 @@ static int rfcomm_recv_msc(struct rfcomm
 		return 0;
 
 	if (cr) {
-		if (msc->v24_sig & RFCOMM_V24_FC && !d->credits)
+		if (msc->v24_sig & RFCOMM_V24_FC && !d->cfc)
 			set_bit(RFCOMM_TX_THROTTLED, &d->flags);
 		else
 			clear_bit(RFCOMM_TX_THROTTLED, &d->flags);
@@ -1444,7 +1438,7 @@ static int rfcomm_recv_data(struct rfcom
 		goto drop;
 	}
 
-	if (pf && d->credits) {
+	if (pf && d->cfc) {
 		u8 credits = *(u8 *) skb->data; skb_pull(skb, 1);
 
 		d->tx_credits += credits;
@@ -1549,20 +1543,20 @@ static inline int rfcomm_process_tx(stru
 	struct sk_buff *skb;
 	int err;
 
-	BT_DBG("dlc %p state %ld credits %d rx_credits %d tx_credits %d", 
-			d, d->state, d->credits, d->rx_credits, d->tx_credits);
+	BT_DBG("dlc %p state %ld cfc %d rx_credits %d tx_credits %d", 
+			d, d->state, d->cfc, d->rx_credits, d->tx_credits);
 
 	/* Send pending MSC */
 	if (test_and_clear_bit(RFCOMM_MSC_PENDING, &d->flags))
 		rfcomm_send_msc(d->session, 1, d->dlci, d->v24_sig); 
 	
-	if (d->credits) {
+	if (d->cfc) {
 		/* CFC enabled. 
 		 * Give them some credits */
 		if (!test_bit(RFCOMM_RX_THROTTLED, &d->flags) &&
-			       	d->rx_credits <= (d->credits >> 2)) {
-			rfcomm_send_credits(d->session, d->addr, d->credits - d->rx_credits);
-			d->rx_credits = d->credits;
+			       	d->rx_credits <= (d->cfc >> 2)) {
+			rfcomm_send_credits(d->session, d->addr, d->cfc - d->rx_credits);
+			d->rx_credits = d->cfc;
 		}
 	} else {
 		/* CFC disabled.
@@ -1583,7 +1577,7 @@ static inline int rfcomm_process_tx(stru
 		d->tx_credits--;
 	}
 
-	if (d->credits && !d->tx_credits) {
+	if (d->cfc && !d->tx_credits) {
 		/* We're out of TX credits.
 		 * Set TX_THROTTLED flag to avoid unnesary wakeups by dlc_send. */
 		set_bit(RFCOMM_TX_THROTTLED, &d->flags);
@@ -1655,7 +1649,9 @@ static inline void rfcomm_accept_connect
 
 	nsock->type = sock->type;
 	nsock->ops  = sock->ops;
-	
+
+	__module_get(nsock->ops->owner);
+
 	err = sock->ops->accept(sock, nsock, O_NONBLOCK);
 	if (err < 0) {
 		sock_release(nsock);
@@ -1998,3 +1994,4 @@ module_exit(rfcomm_cleanup);
 MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>, Marcel Holtmann <marcel@holtmann.org>");
 MODULE_DESCRIPTION("Bluetooth RFCOMM ver " VERSION);
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("bt-proto-3");
diff -puN net/bluetooth/rfcomm/sock.c~linus net/bluetooth/rfcomm/sock.c
--- 25/net/bluetooth/rfcomm/sock.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/bluetooth/rfcomm/sock.c	2004-01-19 22:17:25.000000000 -0800
@@ -482,12 +482,12 @@ static int rfcomm_sock_getname(struct so
 }
 
 static int rfcomm_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
-			       struct msghdr *msg, int len)
+			       struct msghdr *msg, size_t len)
 {
 	struct sock *sk = sock->sk;
 	struct rfcomm_dlc *d = rfcomm_pi(sk)->dlc;
 	struct sk_buff *skb;
-	int err, size;
+	int err;
 	int sent = 0;
 
 	if (msg->msg_flags & MSG_OOB)
@@ -501,7 +501,7 @@ static int rfcomm_sock_sendmsg(struct ki
 	lock_sock(sk);
 
 	while (len) {
-		size = min_t(uint, len, d->mtu);
+		size_t size = min(len, d->mtu);
 		
 		skb = sock_alloc_send_skb(sk, size + RFCOMM_SKB_RESERVE,
 				msg->msg_flags & MSG_DONTWAIT, &err);
@@ -556,10 +556,11 @@ static long rfcomm_sock_data_wait(struct
 }
 
 static int rfcomm_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
-			       struct msghdr *msg, int size, int flags)
+			       struct msghdr *msg, size_t size, int flags)
 {
 	struct sock *sk = sock->sk;
-	int target, err = 0, copied = 0;
+	int err = 0;
+	size_t target, copied = 0;
 	long timeo;
 
 	if (flags & MSG_OOB)
diff -puN net/bluetooth/sco.c~linus net/bluetooth/sco.c
--- 25/net/bluetooth/sco.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/bluetooth/sco.c	2004-01-19 22:17:25.000000000 -0800
@@ -630,7 +630,8 @@ static int sco_sock_getname(struct socke
 	return 0;
 }
 
-static int sco_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, int len)
+static int sco_sock_sendmsg(struct kiocb *iocb, struct socket *sock, 
+			    struct msghdr *msg, size_t len)
 {
 	struct sock *sk = sock->sk;
 	int err = 0;
@@ -1054,3 +1055,4 @@ module_exit(sco_cleanup);
 MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>");
 MODULE_DESCRIPTION("Bluetooth SCO ver " VERSION);
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("bt-proto-2");
diff -puN net/bridge/br_if.c~linus net/bridge/br_if.c
--- 25/net/bridge/br_if.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/bridge/br_if.c	2004-01-19 22:17:25.000000000 -0800
@@ -252,12 +252,12 @@ int br_get_bridge_ifindices(int *indices
 	struct net_device *dev;
 	int i = 0;
 
-	rtnl_shlock();
+	read_lock(&dev_base_lock);
 	for (dev = dev_base; dev && i < num; dev = dev->next) {
 		if (dev->priv_flags & IFF_EBRIDGE) 
 			indices[i++] = dev->ifindex;
 	}
-	rtnl_shunlock();
+	read_unlock(&dev_base_lock);
 
 	return i;
 }
diff -puN net/core/dev.c~linus net/core/dev.c
--- 25/net/core/dev.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/core/dev.c	2004-01-19 22:17:25.000000000 -0800
@@ -621,6 +621,21 @@ struct net_device *__dev_get_by_flags(un
 }
 
 /**
+ *	dev_valid_name - check if name is okay for network device
+ *	@name: name string
+ *
+ *	Network device names need to be valid file names to
+ *	to allow sysfs to work
+ */
+int dev_valid_name(const char *name)
+{
+	return !(*name == '\0' 
+		 || !strcmp(name, ".")
+		 || !strcmp(name, "..")
+		 || strchr(name, '/'));
+}
+
+/**
  *	dev_alloc_name - allocate a name for a device
  *	@dev: device
  *	@name: name format string
@@ -660,6 +675,41 @@ int dev_alloc_name(struct net_device *de
 	return -ENFILE;	/* Over 100 of the things .. bail out! */
 }
 
+
+/**
+ *	dev_change_name - change name of a device
+ *	@dev: device
+ *	@name: name (or format string) must be at least IFNAMSIZ
+ *
+ *	Change name of a device, can pass format strings "eth%d".
+ *	for wildcarding.
+ */
+int dev_change_name(struct net_device *dev, char *newname)
+{
+	ASSERT_RTNL();
+
+	if (dev->flags & IFF_UP)
+		return -EBUSY;
+
+	if (!dev_valid_name(newname))
+		return -EINVAL;
+
+	if (strchr(newname, '%')) {
+		int err = dev_alloc_name(dev, newname);
+		if (err < 0)
+			return err;
+		strcpy(newname, dev->name);
+	}
+	else if (__dev_get_by_name(newname))
+		return -EEXIST;
+	else
+		strlcpy(dev->name, newname, IFNAMSIZ);
+
+	class_device_rename(&dev->class_dev, dev->name);
+	notifier_call_chain(&netdev_chain, NETDEV_CHANGENAME, dev);
+	return 0;
+}
+
 /**
  *	dev_alloc - allocate a network device and name
  *	@name: name format string
@@ -946,11 +996,29 @@ int dev_close(struct net_device *dev)
  *	The notifier passed is linked into the kernel structures and must
  *	not be reused until it has been unregistered. A negative errno code
  *	is returned on a failure.
+ *
+ * 	When registered all registration and up events are replayed
+ *	to the new notifier to allow device to have a race free 
+ *	view of the network device list.
  */
 
 int register_netdevice_notifier(struct notifier_block *nb)
 {
-	return notifier_chain_register(&netdev_chain, nb);
+	struct net_device *dev;
+	int err;
+
+	rtnl_lock();
+	err = notifier_chain_register(&netdev_chain, nb);
+	if (!err) {
+		for (dev = dev_base; dev; dev = dev->next) {
+			nb->notifier_call(nb, NETDEV_REGISTER, dev);
+
+			if (dev->flags & IFF_UP) 
+				nb->notifier_call(nb, NETDEV_UP, dev);
+		}
+	}
+	rtnl_unlock();
+	return err;
 }
 
 /**
@@ -2341,20 +2409,8 @@ static int dev_ifsioc(struct ifreq *ifr,
 			return 0;
 
 		case SIOCSIFNAME:
-			if (dev->flags & IFF_UP)
-				return -EBUSY;
 			ifr->ifr_newname[IFNAMSIZ-1] = '\0';
-			if (__dev_get_by_name(ifr->ifr_newname))
-				return -EEXIST;
-			err = class_device_rename(&dev->class_dev, 
-						  ifr->ifr_newname);
-			if (!err) {
-				strlcpy(dev->name, ifr->ifr_newname, IFNAMSIZ);
-
-				notifier_call_chain(&netdev_chain,
-						    NETDEV_CHANGENAME, dev);
-			}
-			return err;
+			return dev_change_name(dev, ifr->ifr_newname);
 
 		/*
 		 *	Unknown or private ioctl
@@ -2487,6 +2543,7 @@ int dev_ioctl(unsigned int cmd, void *ar
 		 */
 		case SIOCGMIIPHY:
 		case SIOCGMIIREG:
+		case SIOCSIFNAME:
 			if (!capable(CAP_NET_ADMIN))
 				return -EPERM;
 			dev_load(ifr.ifr_name);
@@ -2518,7 +2575,6 @@ int dev_ioctl(unsigned int cmd, void *ar
 		case SIOCDELMULTI:
 		case SIOCSIFHWBROADCAST:
 		case SIOCSIFTXQLEN:
-		case SIOCSIFNAME:
 		case SIOCSMIIREG:
 		case SIOCBONDENSLAVE:
 		case SIOCBONDRELEASE:
@@ -2668,6 +2724,11 @@ int register_netdevice(struct net_device
 			goto out_err;
 		}
 	}
+ 
+	if (!dev_valid_name(dev->name)) {
+		ret = -EINVAL;
+		goto out_err;
+	}
 
 	dev->ifindex = dev_new_index();
 	if (dev->iflink == -1)
diff -puN net/core/dev_mcast.c~linus net/core/dev_mcast.c
--- 25/net/core/dev_mcast.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/core/dev_mcast.c	2004-01-19 22:17:25.000000000 -0800
@@ -41,6 +41,7 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <linux/init.h>
 #include <net/ip.h>
 #include <net/route.h>
@@ -219,59 +220,78 @@ void dev_mc_discard(struct net_device *d
 }
 
 #ifdef CONFIG_PROC_FS
-static int dev_mc_read_proc(char *buffer, char **start, off_t offset,
-			    int length, int *eof, void *data)
+static void *dev_mc_seq_start(struct seq_file *seq, loff_t *pos)
 {
-	off_t pos = 0, begin = 0;
-	struct dev_mc_list *m;
-	int len = 0;
 	struct net_device *dev;
+	loff_t off = 0;
 
 	read_lock(&dev_base_lock);
 	for (dev = dev_base; dev; dev = dev->next) {
-		spin_lock_bh(&dev->xmit_lock);
-		for (m = dev->mc_list; m; m = m->next) {
-			int i;
-
-			len += sprintf(buffer+len,"%-4d %-15s %-5d %-5d ", dev->ifindex,
-				       dev->name, m->dmi_users, m->dmi_gusers);
-
-			for (i = 0; i < m->dmi_addrlen; i++)
-				len += sprintf(buffer+len, "%02x", m->dmi_addr[i]);
-
-			len += sprintf(buffer+len, "\n");
-
-			pos = begin + len;
-			if (pos < offset) {
-				len = 0;
-				begin = pos;
-			}
-			if (pos > offset + length) {
-				spin_unlock_bh(&dev->xmit_lock);
-				goto done;
-			}
-		}
-		spin_unlock_bh(&dev->xmit_lock);
+		if (off++ == *pos) 
+			return dev;
 	}
-	*eof = 1;
+	return NULL;
+}
 
-done:
+static void *dev_mc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
+{
+	struct net_device *dev = v;
+	++*pos;
+	return dev->next;
+}
+
+static void dev_mc_seq_stop(struct seq_file *seq, void *v)
+{
 	read_unlock(&dev_base_lock);
-	*start = buffer + (offset - begin);
-	len -= (offset - begin);
-	if (len > length)
-		len = length;
-	if (len < 0)
-		len = 0;
-	return len;
 }
+
+
+static int dev_mc_seq_show(struct seq_file *seq, void *v)
+{
+	struct dev_mc_list *m;
+	struct net_device *dev = v;
+
+	spin_lock_bh(&dev->xmit_lock);
+	for (m = dev->mc_list; m; m = m->next) {
+		int i;
+
+		seq_printf(seq, "%-4d %-15s %-5d %-5d ", dev->ifindex,
+			   dev->name, m->dmi_users, m->dmi_gusers);
+
+		for (i = 0; i < m->dmi_addrlen; i++)
+			seq_printf(seq, "%02x", m->dmi_addr[i]);
+
+		seq_putc(seq, '\n');
+	}
+	spin_unlock_bh(&dev->xmit_lock);
+	return 0;
+}
+
+static struct seq_operations dev_mc_seq_ops = {
+	.start = dev_mc_seq_start,
+	.next  = dev_mc_seq_next,
+	.stop  = dev_mc_seq_stop,
+	.show  = dev_mc_seq_show,
+};
+
+static int dev_mc_seq_open(struct inode *inode, struct file *file)
+{
+	return seq_open(file, &dev_mc_seq_ops);
+}
+
+static struct file_operations dev_mc_seq_fops = {
+	.owner	 = THIS_MODULE,
+	.open    = dev_mc_seq_open,
+	.read    = seq_read,
+	.llseek  = seq_lseek,
+	.release = seq_release,
+};
+
 #endif
 
 void __init dev_mcast_init(void)
 {
-#ifdef CONFIG_PROC_FS
-	create_proc_read_entry("net/dev_mcast", 0, 0, dev_mc_read_proc, NULL);
-#endif
+	proc_net_fops_create("dev_mcast", 0, &dev_mc_seq_fops);
 }
 
 EXPORT_SYMBOL(dev_mc_add);
diff -puN net/core/neighbour.c~linus net/core/neighbour.c
--- 25/net/core/neighbour.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/core/neighbour.c	2004-01-19 22:17:25.000000000 -0800
@@ -1629,7 +1629,8 @@ struct neigh_sysctl_table {
 };
 
 int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
-			  int p_id, int pdev_id, char *p_name)
+			  int p_id, int pdev_id, char *p_name, 
+			  proc_handler *handler)
 {
 	struct neigh_sysctl_table *t = kmalloc(sizeof(*t), GFP_KERNEL);
 	const char *dev_name_source = NULL;
@@ -1643,6 +1644,10 @@ int neigh_sysctl_register(struct net_dev
 	t->neigh_vars[1].data  = &p->ucast_probes;
 	t->neigh_vars[2].data  = &p->app_probes;
 	t->neigh_vars[3].data  = &p->retrans_time;
+	if (handler) {
+		t->neigh_vars[3].proc_handler = handler;
+		t->neigh_vars[3].extra1 = dev;
+	}
 	t->neigh_vars[4].data  = &p->base_reachable_time;
 	t->neigh_vars[5].data  = &p->delay_probe_time;
 	t->neigh_vars[6].data  = &p->gc_staletime;
diff -puN net/core/sock.c~linus net/core/sock.c
--- 25/net/core/sock.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/core/sock.c	2004-01-19 22:17:25.000000000 -0800
@@ -564,6 +564,9 @@ int sock_getsockopt(struct socket *sock,
 			v.val = sk->sk_state == TCP_LISTEN;
 			break;
 
+		case SO_PEERSEC:
+			return security_socket_getpeersec(sock, optval, optlen, len);
+
 		default:
 			return(-ENOPROTOOPT);
 	}
@@ -606,6 +609,11 @@ struct sock *sk_alloc(int family, int pr
 			sock_lock_init(sk);
 		}
 		sk->sk_slab = slab;
+		
+		if (security_sk_alloc(sk, family, priority)) {
+			kmem_cache_free(slab, sk);
+			sk = NULL;
+		}
 	}
 	return sk;
 }
@@ -628,6 +636,7 @@ void sk_free(struct sock *sk)
 		printk(KERN_DEBUG "%s: optmem leakage (%d bytes) detected.\n",
 		       __FUNCTION__, atomic_read(&sk->sk_omem_alloc));
 
+	security_sk_free(sk);
 	kmem_cache_free(sk->sk_slab, sk);
 	module_put(owner);
 }
@@ -966,13 +975,13 @@ int sock_no_getsockopt(struct socket *so
 }
 
 int sock_no_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
-		    int flags)
+		    size_t len)
 {
 	return -EOPNOTSUPP;
 }
 
 int sock_no_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
-		    int len, int flags)
+		    size_t len, int flags)
 {
 	return -EOPNOTSUPP;
 }
diff -puN net/decnet/af_decnet.c~linus net/decnet/af_decnet.c
--- 25/net/decnet/af_decnet.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/decnet/af_decnet.c	2004-01-19 22:17:25.000000000 -0800
@@ -1659,13 +1659,13 @@ static int dn_data_ready(struct sock *sk
 
 
 static int dn_recvmsg(struct kiocb *iocb, struct socket *sock,
-	struct msghdr *msg, int size, int flags)
+	struct msghdr *msg, size_t size, int flags)
 {
 	struct sock *sk = sock->sk;
 	struct dn_scp *scp = DN_SK(sk);
 	struct sk_buff_head *queue = &sk->sk_receive_queue;
-	int target = size > 1 ? 1 : 0;
-	int copied = 0;
+	size_t target = size > 1 ? 1 : 0;
+	size_t copied = 0;
 	int rv = 0;
 	struct sk_buff *skb, *nskb;
 	struct dn_skb_cb *cb = NULL;
@@ -1746,7 +1746,7 @@ static int dn_recvmsg(struct kiocb *iocb
 	}
 
 	for(skb = queue->next; skb != (struct sk_buff *)queue; skb = nskb) {
-		int chunk = skb->len;
+		unsigned int chunk = skb->len;
 		cb = DN_SKB_CB(skb);
 
 		if ((chunk + copied) > size)
@@ -1888,20 +1888,20 @@ static int dn_error(struct sock *sk, int
 }
 
 static int dn_sendmsg(struct kiocb *iocb, struct socket *sock,
-	   struct msghdr *msg, int size)
+	   struct msghdr *msg, size_t size)
 {
 	struct sock *sk = sock->sk;
 	struct dn_scp *scp = DN_SK(sk);
-	int mss;
+	size_t mss;
 	struct sk_buff_head *queue = &scp->data_xmit_queue;
 	int flags = msg->msg_flags;
 	int err = 0;
-	int sent = 0;
+	size_t sent = 0;
 	int addr_len = msg->msg_namelen;
 	struct sockaddr_dn *addr = (struct sockaddr_dn *)msg->msg_name;
 	struct sk_buff *skb = NULL;
 	struct dn_skb_cb *cb;
-	int len;
+	size_t len;
 	unsigned char fctype;
 	long timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT);
 
@@ -2363,17 +2363,16 @@ static int __init decnet_init(void)
 	if (!dn_sk_cachep)
 		return -ENOMEM;
 
-	sock_register(&dn_family_ops);
-	dev_add_pack(&dn_dix_packet_type);
-	register_netdevice_notifier(&dn_dev_notifier);
-
-	proc_net_fops_create("decnet", S_IRUGO, &dn_socket_seq_fops);
-
 	dn_neigh_init();
 	dn_dev_init();
 	dn_route_init();
 	dn_fib_init();
 
+	sock_register(&dn_family_ops);
+	dev_add_pack(&dn_dix_packet_type);
+	register_netdevice_notifier(&dn_dev_notifier);
+
+	proc_net_fops_create("decnet", S_IRUGO, &dn_socket_seq_fops);
 	dn_register_sysctl();
 
 	return 0;
diff -puN net/econet/af_econet.c~linus net/econet/af_econet.c
--- 25/net/econet/af_econet.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/econet/af_econet.c	2004-01-19 22:17:25.000000000 -0800
@@ -113,11 +113,12 @@ static void econet_insert_socket(struct 
  */
 
 static int econet_recvmsg(struct kiocb *iocb, struct socket *sock,
-			  struct msghdr *msg, int len, int flags)
+			  struct msghdr *msg, size_t len, int flags)
 {
 	struct sock *sk = sock->sk;
 	struct sk_buff *skb;
-	int copied, err;
+	size_t copied;
+	int err;
 
 	msg->msg_namelen = sizeof(struct sockaddr_ec);
 
@@ -246,7 +247,7 @@ static void ec_tx_done(struct sk_buff *s
  */
 
 static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
-			  struct msghdr *msg, int len)
+			  struct msghdr *msg, size_t len)
 {
 	struct sock *sk = sock->sk;
 	struct sockaddr_ec *saddr=(struct sockaddr_ec *)msg->msg_name;
@@ -308,6 +309,9 @@ static int econet_sendmsg(struct kiocb *
 			return -ENETDOWN;
 	}
 
+	if (len + 15 > dev->mtu)
+		return -EMSGSIZE;
+
 	if (dev->type == ARPHRD_ECONET)
 	{
 		/* Real hardware Econet.  We're not worthy etc. */
diff -puN net/ipv4/af_inet.c~linus net/ipv4/af_inet.c
--- 25/net/ipv4/af_inet.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/ipv4/af_inet.c	2004-01-19 22:17:25.000000000 -0800
@@ -731,7 +731,7 @@ int inet_getname(struct socket *sock, st
 
 
 int inet_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
-		 int size, int flags)
+		 size_t size, int flags)
 {
 	struct sock *sk = sock->sk;
 	int addr_len = 0;
@@ -746,7 +746,7 @@ int inet_recvmsg(struct kiocb *iocb, str
 
 
 int inet_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
-		 int size)
+		 size_t size)
 {
 	struct sock *sk = sock->sk;
 
diff -puN net/ipv4/arp.c~linus net/ipv4/arp.c
--- 25/net/ipv4/arp.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/ipv4/arp.c	2004-01-19 22:17:25.000000000 -0800
@@ -1122,7 +1122,7 @@ void __init arp_init(void)
 	arp_proc_init();
 #ifdef CONFIG_SYSCTL
 	neigh_sysctl_register(NULL, &arp_tbl.parms, NET_IPV4,
-			      NET_IPV4_NEIGH, "ipv4");
+			      NET_IPV4_NEIGH, "ipv4", NULL);
 #endif
 	register_netdevice_notifier(&arp_netdev_notifier);
 }
diff -puN net/ipv4/devinet.c~linus net/ipv4/devinet.c
--- 25/net/ipv4/devinet.c~linus	2004-01-19 22:17:08.000000000 -0800
+++ 25-akpm/net/ipv4/devinet.c	2004-01-19 22:17:25.000000000 -0800
@@ -155,7 +155,7 @@ struct in_device *inetdev_init(struct ne
 	dev_hold(dev);
 #ifdef CONFIG_SYSCTL
 	neigh_sysctl_register(dev, in_dev->arp_parms, NET_IPV4,
-			      NET_IPV4_NEIGH, "ipv4");
+			      NET_IPV4_NEIGH, "ipv4", NULL);
 #endif
 	write_lock_bh(&inetdev_lock);
 	dev->ip_ptr = in_dev;
@@ -910,7 +910,7 @@ static int inetdev_event(struct notifier
 		devinet_sysctl_unregister(&in_dev->cnf);
 		neigh_sysctl_unregister(in_dev->arp_parms);
 		neigh_sysctl_register(dev, in_dev->arp_parms, NET_IPV4,
-				      NET_IPV4_NEIGH, "ipv4");
+				      NET_IPV4_NEIGH, "ipv4", NULL);
 		devinet_sysctl_register(in_dev, &in_dev->cnf);
 #endif
 		break;
diff -puN net/ipv4/igmp.c~linus net/ipv4/igmp.c
--- 25/net/ipv4/igmp.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/ipv4/igmp.c	2004-01-19 22:17:25.000000000 -0800
@@ -1749,11 +1749,10 @@ int ip_mc_source(int add, int omode, str
 			goto done;
 	} else if (pmc->sfmode != omode) {
 		/* allow mode switches for empty-set filters */
+		ip_mc_add_src(in_dev, &mreqs->imr_multiaddr, omode, 0, 0, 0);
 		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;
diff -puN net/ipv4/ipcomp.c~linus net/ipv4/ipcomp.c
--- 25/net/ipv4/ipcomp.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/ipv4/ipcomp.c	2004-01-19 22:17:25.000000000 -0800
@@ -294,6 +294,7 @@ out:
 	return t;
 
 error:
+	t->km.state = XFRM_STATE_DEAD;
 	xfrm_state_put(t);
 	t = NULL;
 	goto out;
diff -puN net/ipv4/ipmr.c~linus net/ipv4/ipmr.c
--- 25/net/ipv4/ipmr.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/ipv4/ipmr.c	2004-01-19 22:17:25.000000000 -0800
@@ -205,6 +205,9 @@ static struct net_device *ipmr_reg_vif(v
 	dev = alloc_netdev(sizeof(struct net_device_stats), "pimreg",
 			   reg_vif_setup);
 
+	if (dev == NULL)
+		return NULL;
+
 	if (register_netdevice(dev)) {
 		kfree(dev);
 		return NULL;
diff -puN net/ipv4/netfilter/ip_tables.c~linus net/ipv4/netfilter/ip_tables.c
--- 25/net/ipv4/netfilter/ip_tables.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/ipv4/netfilter/ip_tables.c	2004-01-19 22:17:25.000000000 -0800
@@ -260,7 +260,7 @@ ipt_do_table(struct sk_buff **pskb,
 	     struct ipt_table *table,
 	     void *userdata)
 {
-	static const char nulldevname[IFNAMSIZ];
+	static const char nulldevname[IFNAMSIZ] __attribute__((aligned(sizeof(long))));
 	u_int16_t offset;
 	struct iphdr *ip;
 	u_int16_t datalen;
diff -puN net/ipv4/netfilter/Kconfig~linus net/ipv4/netfilter/Kconfig
--- 25/net/ipv4/netfilter/Kconfig~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/ipv4/netfilter/Kconfig	2004-01-19 22:17:25.000000000 -0800
@@ -529,10 +529,23 @@ config IP_NF_TARGET_TCPMSS
 
 config IP_NF_ARPTABLES
 	tristate "ARP tables support"
+	help
+	  arptables is a general, extensible packet identification framework.
+	  The ARP packet filtering and mangling (manipulation)subsystems
+	  use this: say Y or M here if you want to use either of those.
+
+	  To compile it as a module, choose M here.  If unsure, say N.
 
 config IP_NF_ARPFILTER
 	tristate "ARP packet filtering"
 	depends on IP_NF_ARPTABLES
+	help
+	  ARP packet filtering defines a table `filter', which has a series of
+	  rules for simple ARP packet filtering at local input and
+	  local output.  On a bridge, you can also specify filtering rules
+	  for forwarded ARP packets. See the man page for arptables(8).
+
+	  To compile it as a module, choose M here.  If unsure, say N.
 
 config IP_NF_ARP_MANGLE
 	tristate "ARP payload mangling"
diff -puN net/ipv4/raw.c~linus net/ipv4/raw.c
--- 25/net/ipv4/raw.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/ipv4/raw.c	2004-01-19 22:17:25.000000000 -0800
@@ -324,7 +324,7 @@ error:
 }
 
 static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
-		       int len)
+		       size_t len)
 {
 	struct inet_opt *inet = inet_sk(sk);
 	struct ipcm_cookie ipc;
@@ -335,17 +335,6 @@ static int raw_sendmsg(struct kiocb *ioc
 	u8  tos;
 	int err;
 
-	/* This check is ONLY to check for arithmetic overflow
-	   on integer(!) len. Not more! Real check will be made
-	   in ip_build_xmit --ANK
-
-	   BTW socket.c -> af_*.c -> ... make multiple
-	   invalid conversions size_t -> int. We MUST repair it f.e.
-	   by replacing all of them with size_t and revise all
-	   the places sort of len += sizeof(struct iphdr)
-	   If len was ULONG_MAX-10 it would be cathastrophe  --ANK
-	 */
-
 	err = -EMSGSIZE;
 	if (len < 0 || len > 0xFFFF)
 		goto out;
@@ -523,10 +512,10 @@ out:	return ret;
  */
 
 int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
-		int len, int noblock, int flags, int *addr_len)
+		size_t len, int noblock, int flags, int *addr_len)
 {
 	struct inet_opt *inet = inet_sk(sk);
-	int copied = 0;
+	size_t copied = 0;
 	int err = -EOPNOTSUPP;
 	struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
 	struct sk_buff *skb;
diff -puN net/ipv4/route.c~linus net/ipv4/route.c
--- 25/net/ipv4/route.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/ipv4/route.c	2004-01-19 22:17:25.000000000 -0800
@@ -2703,12 +2703,9 @@ static int ip_rt_acct_read(char *buffer,
 		memcpy(dst, src, length);
 
 		/* Add the other cpus in, one int at a time */
-		for (i = 1; i < NR_CPUS; i++) {
+		for_each_cpu(i) {
 			unsigned int j;
 
-			if (!cpu_online(i))
-				continue;
-
 			src = ((u32 *) IP_RT_ACCT_CPU(i)) + offset;
 
 			for (j = 0; j < length/4; j++)
diff -puN net/ipv4/tcp.c~linus net/ipv4/tcp.c
--- 25/net/ipv4/tcp.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/ipv4/tcp.c	2004-01-19 22:17:25.000000000 -0800
@@ -1029,7 +1029,7 @@ static inline int select_size(struct soc
 }
 
 int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
-		int size)
+		size_t size)
 {
 	struct iovec *iov;
 	struct tcp_opt *tp = tcp_sk(sk);
@@ -1498,7 +1498,7 @@ int tcp_read_sock(struct sock *sk, read_
  */
 
 int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
-		int len, int nonblock, int flags, int *addr_len)
+		size_t len, int nonblock, int flags, int *addr_len)
 {
 	struct tcp_opt *tp = tcp_sk(sk);
 	int copied = 0;
diff -puN net/ipv4/udp.c~linus net/ipv4/udp.c
--- 25/net/ipv4/udp.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/ipv4/udp.c	2004-01-19 22:17:25.000000000 -0800
@@ -478,7 +478,7 @@ static unsigned short udp_check(struct u
 }
 
 int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
-		int len)
+		size_t len)
 {
 	struct inet_opt *inet = inet_sk(sk);
 	struct udp_opt *up = udp_sk(sk);
@@ -493,18 +493,7 @@ int udp_sendmsg(struct kiocb *iocb, stru
 	int err;
 	int corkreq = up->corkflag || msg->msg_flags&MSG_MORE;
 
-	/* This check is ONLY to check for arithmetic overflow
-	   on integer(!) len. Not more! Real check will be made
-	   in ip_append_* --ANK
-
-	   BTW socket.c -> af_*.c -> ... make multiple
-	   invalid conversions size_t -> int. We MUST repair it f.e.
-	   by replacing all of them with size_t and revise all
-	   the places sort of len += sizeof(struct iphdr)
-	   If len was ULONG_MAX-10 it would be cathastrophe  --ANK
-	 */
-
-	if (len < 0 || len > 0xFFFF)
+	if (len > 0xFFFF)
 		return -EMSGSIZE;
 
 	/* 
@@ -782,7 +771,7 @@ static __inline__ int udp_checksum_compl
  */
 
 int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
-		int len, int noblock, int flags, int *addr_len)
+		size_t len, int noblock, int flags, int *addr_len)
 {
 	struct inet_opt *inet = inet_sk(sk);
   	struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
diff -puN net/ipv6/addrconf.c~linus net/ipv6/addrconf.c
--- 25/net/ipv6/addrconf.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/ipv6/addrconf.c	2004-01-19 22:17:25.000000000 -0800
@@ -81,8 +81,6 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 
-#define IPV6_MAX_ADDRESSES 16
-
 /* Set to 3 to get tracing... */
 #define ACONF_DEBUG 2
 
@@ -138,6 +136,8 @@ static void addrconf_dad_completed(struc
 static void addrconf_rs_timer(unsigned long data);
 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa);
 
+static void inet6_prefix_notify(int event, struct inet6_dev *idev, 
+				struct prefix_info *pinfo);
 static int ipv6_chk_same_addr(const struct in6_addr *addr, struct net_device *dev);
 
 static struct notifier_block *inet6addr_chain;
@@ -160,6 +160,7 @@ struct ipv6_devconf ipv6_devconf = {
 	.regen_max_retry	= REGEN_MAX_RETRY,
 	.max_desync_factor	= MAX_DESYNC_FACTOR,
 #endif
+	.max_addresses		= IPV6_MAX_ADDRESSES,
 };
 
 static struct ipv6_devconf ipv6_devconf_dflt = {
@@ -180,6 +181,7 @@ static struct ipv6_devconf ipv6_devconf_
 	.regen_max_retry	= REGEN_MAX_RETRY,
 	.max_desync_factor	= MAX_DESYNC_FACTOR,
 #endif
+	.max_addresses		= IPV6_MAX_ADDRESSES,
 };
 
 /* IPv6 Wildcard Address and Loopback Address defined by RFC2553 */
@@ -373,9 +375,10 @@ static struct inet6_dev * ipv6_add_dev(s
 		write_unlock_bh(&addrconf_lock);
 
 		ipv6_mc_init_dev(ndev);
-
+		ndev->tstamp = jiffies;
 #ifdef CONFIG_SYSCTL
-		neigh_sysctl_register(dev, ndev->nd_parms, NET_IPV6, NET_IPV6_NEIGH, "ipv6");
+		neigh_sysctl_register(dev, ndev->nd_parms, NET_IPV6, 
+			NET_IPV6_NEIGH, "ipv6", &ndisc_ifinfo_sysctl_change);
 		addrconf_sysctl_register(ndev, &ndev->cnf);
 #endif
 	}
@@ -630,6 +633,7 @@ static int ipv6_create_tempaddr(struct i
 	unsigned long tmp_prefered_lft, tmp_valid_lft;
 	int tmp_plen;
 	int ret = 0;
+	int max_addresses;
 
 	if (ift) {
 		spin_lock_bh(&ift->lock);
@@ -685,9 +689,11 @@ retry:
 				 ifp->prefered_lft, 
 				 idev->cnf.temp_prefered_lft - desync_factor / HZ);
 	tmp_plen = ifp->prefix_len;
+	max_addresses = idev->cnf.max_addresses;
 	write_unlock(&idev->lock);
 	spin_unlock_bh(&ifp->lock);
-	ift = ipv6_count_addresses(idev) < IPV6_MAX_ADDRESSES ?
+	ift = !max_addresses ||
+	      ipv6_count_addresses(idev) < max_addresses ? 
 		ipv6_add_addr(idev, &addr, tmp_plen,
 			      ipv6_addr_type(&addr)&IPV6_ADDR_SCOPE_MASK, IFA_F_TEMPORARY) : 0;
 	if (!ift || IS_ERR(ift)) {
@@ -1390,10 +1396,13 @@ ok:
 		ifp = ipv6_get_ifaddr(&addr, dev);
 
 		if (ifp == NULL && valid_lft) {
+			int max_addresses = in6_dev->cnf.max_addresses;
+
 			/* Do not allow to create too much of autoconfigured
 			 * addresses; this would be too easy way to crash kernel.
 			 */
-			if (ipv6_count_addresses(in6_dev) < IPV6_MAX_ADDRESSES)
+			if (!max_addresses ||
+			    ipv6_count_addresses(in6_dev) < max_addresses)
 				ifp = ipv6_add_addr(in6_dev, &addr, pinfo->prefix_len,
 						    addr_type&IPV6_ADDR_SCOPE_MASK, 0);
 
@@ -1491,6 +1500,7 @@ ok:
 			addrconf_verify(0);
 		}
 	}
+	inet6_prefix_notify(RTM_NEWPREFIX, in6_dev, pinfo);
 	in6_dev_put(in6_dev);
 }
 
@@ -1858,8 +1868,8 @@ static void addrconf_ip6_tnl_config(stru
 	addrconf_add_mroute(dev);
 }
 
-int addrconf_notify(struct notifier_block *this, unsigned long event, 
-		    void * data)
+static int addrconf_notify(struct notifier_block *this, unsigned long event, 
+			   void * data)
 {
 	struct net_device *dev = (struct net_device *) data;
 	struct inet6_dev *idev = __in6_dev_get(dev);
@@ -1890,6 +1900,8 @@ int addrconf_notify(struct notifier_bloc
 				rt6_mtu_change(dev, dev->mtu);
 				idev->cnf.mtu6 = dev->mtu;
 			}
+			idev->tstamp = jiffies;
+			inet6_ifinfo_notify(RTM_NEWLINK, idev);
 			/* If the changed mtu during down is lower than IPV6_MIN_MTU
 			   stop IPv6 on this interface.
 			 */
@@ -1921,7 +1933,7 @@ int addrconf_notify(struct notifier_bloc
 		if (idev) {
 			addrconf_sysctl_unregister(&idev->cnf);
 			neigh_sysctl_unregister(idev->nd_parms);
-			neigh_sysctl_register(dev, idev->nd_parms, NET_IPV6, NET_IPV6_NEIGH, "ipv6");
+			neigh_sysctl_register(dev, idev->nd_parms, NET_IPV6, NET_IPV6_NEIGH, "ipv6", &ndisc_ifinfo_sysctl_change);
 			addrconf_sysctl_register(idev, &idev->cnf);
 		}
 #endif
@@ -1931,6 +1943,14 @@ int addrconf_notify(struct notifier_bloc
 	return NOTIFY_OK;
 }
 
+/*
+ *	addrconf module should be notified of a device going up
+ */
+static struct notifier_block ipv6_dev_notf = {
+	.notifier_call = addrconf_notify,
+	.priority = 0
+};
+
 static int addrconf_ifdown(struct net_device *dev, int how)
 {
 	struct inet6_dev *idev;
@@ -2023,6 +2043,10 @@ static int addrconf_ifdown(struct net_de
 	else
 		ipv6_mc_down(idev);
 
+	/* Step 5: netlink notification of this interface */
+	idev->tstamp = jiffies;
+	inet6_ifinfo_notify(RTM_NEWLINK, idev);
+	
 	/* Shot the device (if unregistered) */
 
 	if (how == 1) {
@@ -2722,19 +2746,22 @@ static void inline ipv6_store_devconf(st
 	array[DEVCONF_REGEN_MAX_RETRY] = cnf->regen_max_retry;
 	array[DEVCONF_MAX_DESYNC_FACTOR] = cnf->max_desync_factor;
 #endif
+	array[DEVCONF_MAX_ADDRESSES] = cnf->max_addresses;
 }
 
-static int inet6_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
-			    struct inet6_dev *idev,
-			    int type, u32 pid, u32 seq)
+static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev, 
+			     u32 pid, u32 seq, int event)
 {
+	struct net_device	*dev = idev->dev;
 	__s32			*array = NULL;
 	struct ifinfomsg	*r;
 	struct nlmsghdr 	*nlh;
 	unsigned char		*b = skb->tail;
 	struct rtattr		*subattr;
+	__u32			mtu = dev->mtu;
+	struct ifla_cacheinfo	ci;
 
-	nlh = NLMSG_PUT(skb, pid, seq, type, sizeof(*r));
+	nlh = NLMSG_PUT(skb, pid, seq, event, sizeof(*r));
 	if (pid) nlh->nlmsg_flags |= NLM_F_MULTI;
 	r = NLMSG_DATA(nlh);
 	r->ifi_family = AF_INET6;
@@ -2749,6 +2776,13 @@ static int inet6_fill_ifinfo(struct sk_b
 
 	RTA_PUT(skb, IFLA_IFNAME, strlen(dev->name)+1, dev->name);
 
+	if (dev->addr_len)
+		RTA_PUT(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr);
+
+	RTA_PUT(skb, IFLA_MTU, sizeof(mtu), &mtu);
+	if (dev->ifindex != dev->iflink)
+		RTA_PUT(skb, IFLA_LINK, sizeof(int), &dev->iflink);
+			
 	subattr = (struct rtattr*)skb->tail;
 
 	RTA_PUT(skb, IFLA_PROTINFO, 0, NULL);
@@ -2756,6 +2790,14 @@ static int inet6_fill_ifinfo(struct sk_b
 	/* return the device flags */
 	RTA_PUT(skb, IFLA_INET6_FLAGS, sizeof(__u32), &idev->if_flags);
 
+	/* return interface cacheinfo */
+	ci.max_reasm_len = IPV6_MAXPLEN;
+	ci.tstamp = (__u32)(TIME_DELTA(idev->tstamp, INITIAL_JIFFIES) / HZ * 100
+		    + TIME_DELTA(idev->tstamp, INITIAL_JIFFIES) % HZ * 100 / HZ);
+	ci.reachable_time = idev->nd_parms->reachable_time;
+	ci.retrans_time = idev->nd_parms->retrans_time;
+	RTA_PUT(skb, IFLA_INET6_CACHEINFO, sizeof(ci), &ci);
+	
 	/* return the device sysctl params */
 	if ((array = kmalloc(DEVCONF_MAX * sizeof(*array), GFP_ATOMIC)) == NULL)
 		goto rtattr_failure;
@@ -2790,8 +2832,8 @@ static int inet6_dump_ifinfo(struct sk_b
 			continue;
 		if ((idev = in6_dev_get(dev)) == NULL)
 			continue;
-		err = inet6_fill_ifinfo(skb, dev, idev, RTM_NEWLINK,
-				NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq);
+		err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid, 
+				cb->nlh->nlmsg_seq, RTM_NEWLINK);
 		in6_dev_put(idev);
 		if (err <= 0)
 			break;
@@ -2802,6 +2844,86 @@ static int inet6_dump_ifinfo(struct sk_b
 	return skb->len;
 }
 
+void inet6_ifinfo_notify(int event, struct inet6_dev *idev)
+{
+	struct sk_buff *skb;
+	/* 128 bytes ?? */
+	int size = NLMSG_SPACE(sizeof(struct ifinfomsg)+128);
+	
+	skb = alloc_skb(size, GFP_ATOMIC);
+	if (!skb) {
+		netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFINFO, ENOBUFS);
+		return;
+	}
+	if (inet6_fill_ifinfo(skb, idev, 0, 0, event) < 0) {
+		kfree_skb(skb);
+		netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFINFO, EINVAL);
+		return;
+	}
+	NETLINK_CB(skb).dst_groups = RTMGRP_IPV6_IFINFO;
+	netlink_broadcast(rtnl, skb, 0, RTMGRP_IPV6_IFINFO, GFP_ATOMIC);
+}
+
+static int inet6_fill_prefix(struct sk_buff *skb, struct inet6_dev *idev,
+			struct prefix_info *pinfo, u32 pid, u32 seq, int event)
+{
+	struct prefixmsg	*pmsg;
+	struct nlmsghdr 	*nlh;
+	unsigned char		*b = skb->tail;
+	struct prefix_cacheinfo	ci;
+
+	nlh = NLMSG_PUT(skb, pid, seq, event, sizeof(*pmsg));
+	
+	if (pid) 
+		nlh->nlmsg_flags |= NLM_F_MULTI;
+	
+	pmsg = NLMSG_DATA(nlh);
+	pmsg->prefix_family = AF_INET6;
+	pmsg->prefix_ifindex = idev->dev->ifindex;
+	pmsg->prefix_len = pinfo->prefix_len;
+	pmsg->prefix_type = pinfo->type;
+	
+	pmsg->prefix_flags = 0;
+	if (pinfo->onlink)
+		pmsg->prefix_flags |= IF_PREFIX_ONLINK;
+	if (pinfo->autoconf)
+		pmsg->prefix_flags |= IF_PREFIX_AUTOCONF;
+
+	RTA_PUT(skb, PREFIX_ADDRESS, sizeof(pinfo->prefix), &pinfo->prefix);
+
+	ci.preferred_time = ntohl(pinfo->prefered);
+	ci.valid_time = ntohl(pinfo->valid);
+	RTA_PUT(skb, PREFIX_CACHEINFO, sizeof(ci), &ci);
+
+	nlh->nlmsg_len = skb->tail - b;
+	return skb->len;
+
+nlmsg_failure:
+rtattr_failure:
+	skb_trim(skb, b - skb->data);
+	return -1;
+}
+
+static void inet6_prefix_notify(int event, struct inet6_dev *idev, 
+			 struct prefix_info *pinfo)
+{
+	struct sk_buff *skb;
+	int size = NLMSG_SPACE(sizeof(struct prefixmsg)+128);
+
+	skb = alloc_skb(size, GFP_ATOMIC);
+	if (!skb) {
+		netlink_set_err(rtnl, 0, RTMGRP_IPV6_PREFIX, ENOBUFS);
+		return;
+	}
+	if (inet6_fill_prefix(skb, idev, pinfo, 0, 0, event) < 0) {
+		kfree_skb(skb);
+		netlink_set_err(rtnl, 0, RTMGRP_IPV6_PREFIX, EINVAL);
+		return;
+	}
+	NETLINK_CB(skb).dst_groups = RTMGRP_IPV6_PREFIX;
+	netlink_broadcast(rtnl, skb, 0, RTMGRP_IPV6_PREFIX, GFP_ATOMIC);
+}
+
 static struct rtnetlink_link inet6_rtnetlink_table[RTM_MAX - RTM_BASE + 1] = {
 	[RTM_GETLINK - RTM_BASE] = { .dumpit	= inet6_dump_ifinfo, },
 	[RTM_NEWADDR - RTM_BASE] = { .doit	= inet6_rtm_newaddr, },
@@ -3050,6 +3172,14 @@ static struct addrconf_sysctl_table
 	 		.proc_handler	=	&proc_dointvec,
 		},
 #endif
+		{
+			.ctl_name	=	NET_IPV6_MAX_ADDRESSES,
+			.procname	=	"max_addresses",
+			.data		=	&ipv6_devconf.max_addresses,
+			.maxlen		=	sizeof(int),
+			.mode		=	0644,
+			.proc_handler	=	&proc_dointvec,
+		},
 	},
 	.addrconf_dev = {
 		{
@@ -3179,9 +3309,7 @@ int unregister_inet6addr_notifier(struct
 
 void __init addrconf_init(void)
 {
-#ifdef MODULE
-	struct net_device *dev;
-#endif
+	register_netdevice_notifier(&ipv6_dev_notf);
 
 #ifdef CONFIG_IPV6_PRIVACY
 	md5_tfm = crypto_alloc_tfm("md5", 0);
@@ -3190,30 +3318,6 @@ void __init addrconf_init(void)
 			"failed to load transform for md5\n");
 #endif
 
-#ifdef MODULE
-	/* This takes sense only during module load. */
-	rtnl_lock();
-	for (dev = dev_base; dev; dev = dev->next) {
-		if (!(dev->flags&IFF_UP))
-			continue;
-
-		switch (dev->type) {
-		case ARPHRD_LOOPBACK:	
-			init_loopback(dev);
-			break;
-		case ARPHRD_ETHER:
-		case ARPHRD_FDDI:
-		case ARPHRD_IEEE802_TR:	
-		case ARPHRD_ARCNET:
-			addrconf_dev_config(dev);
-			break;
-		default:;
-			/* Ignore all other */
-		}
-	}
-	rtnl_unlock();
-#endif
-
 	addrconf_verify(0);
 	rtnetlink_links[PF_INET6] = inet6_rtnetlink_table;
 #ifdef CONFIG_SYSCTL
@@ -3231,6 +3335,8 @@ void addrconf_cleanup(void)
  	struct inet6_ifaddr *ifa;
 	int i;
 
+	unregister_netdevice_notifier(&ipv6_dev_notf);
+
 	rtnetlink_links[PF_INET6] = NULL;
 #ifdef CONFIG_SYSCTL
 	addrconf_sysctl_unregister(&ipv6_devconf_dflt);
@@ -3284,3 +3390,4 @@ void addrconf_cleanup(void)
 #endif
 }
 #endif	/* MODULE */
+
diff -puN net/ipv6/af_inet6.c~linus net/ipv6/af_inet6.c
--- 25/net/ipv6/af_inet6.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/ipv6/af_inet6.c	2004-01-19 22:17:25.000000000 -0800
@@ -802,7 +802,6 @@ static int __init inet6_init(void)
 	if (if6_proc_init())
 		goto proc_if6_fail;
 #endif
-	ipv6_netdev_notif_init();
 	ipv6_packet_init();
 	ip6_route_init();
 	ip6_flowlabel_init();
@@ -869,7 +868,6 @@ static void inet6_exit(void)
 #endif
 	/* Cleanup code parts. */
 	sit_cleanup();
-	ipv6_netdev_notif_cleanup();
 	ip6_flowlabel_cleanup();
 	addrconf_cleanup();
 	ip6_route_cleanup();
diff -puN net/ipv6/ipv6_sockglue.c~linus net/ipv6/ipv6_sockglue.c
--- 25/net/ipv6/ipv6_sockglue.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/ipv6/ipv6_sockglue.c	2004-01-19 22:17:25.000000000 -0800
@@ -62,14 +62,6 @@ static struct packet_type ipv6_packet_ty
 	.func = ipv6_rcv,
 };
 
-/*
- *	addrconf module should be notified of a device going up
- */
-static struct notifier_block ipv6_dev_notf = {
-	.notifier_call = addrconf_notify,
-	.priority = 0
-};
-
 struct ip6_ra_chain *ip6_ra_chain;
 rwlock_t ip6_ra_lock = RW_LOCK_UNLOCKED;
 
@@ -707,19 +699,9 @@ void __init ipv6_packet_init(void)
 	dev_add_pack(&ipv6_packet_type);
 }
 
-void __init ipv6_netdev_notif_init(void)
-{
-	register_netdevice_notifier(&ipv6_dev_notf);
-}
-
 #ifdef MODULE
 void ipv6_packet_cleanup(void)
 {
 	dev_remove_pack(&ipv6_packet_type);
 }
-
-void ipv6_netdev_notif_cleanup(void)
-{
-	unregister_netdevice_notifier(&ipv6_dev_notf);
-}
 #endif
diff -puN net/ipv6/mcast.c~linus net/ipv6/mcast.c
--- 25/net/ipv6/mcast.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/ipv6/mcast.c	2004-01-19 22:17:25.000000000 -0800
@@ -372,9 +372,9 @@ int ip6_mc_source(int add, int omode, st
 			goto done;
 	} else if (pmc->sfmode != omode) {
 		/* allow mode switches for empty-set filters */
+		ip6_mc_add_src(idev, group, omode, 0, 0, 0);
 		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;
diff -puN net/ipv6/ndisc.c~linus net/ipv6/ndisc.c
--- 25/net/ipv6/ndisc.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/ipv6/ndisc.c	2004-01-19 22:17:25.000000000 -0800
@@ -1115,6 +1115,8 @@ static void ndisc_router_discovery(struc
 			if (rtime < HZ/10)
 				rtime = HZ/10;
 			in6_dev->nd_parms->retrans_time = rtime;
+			in6_dev->tstamp = jiffies;
+			inet6_ifinfo_notify(RTM_NEWLINK, in6_dev);
 		}
 
 		rtime = ntohl(ra_msg->reachable_time);
@@ -1128,6 +1130,8 @@ static void ndisc_router_discovery(struc
 				in6_dev->nd_parms->base_reachable_time = rtime;
 				in6_dev->nd_parms->gc_staletime = 3 * rtime;
 				in6_dev->nd_parms->reachable_time = neigh_rand_reach_time(rtime);
+				in6_dev->tstamp = jiffies;
+				inet6_ifinfo_notify(RTM_NEWLINK, in6_dev);
 			}
 		}
 	}
@@ -1492,6 +1496,21 @@ struct notifier_block ndisc_netdev_notif
 	.notifier_call = ndisc_netdev_event,
 };
 
+#ifdef CONFIG_SYSCTL
+int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, struct file * filp, void __user *buffer, size_t *lenp)
+{
+	struct net_device *dev = ctl->extra1;
+	struct inet6_dev *idev;
+
+	if (write && dev && (idev = in6_dev_get(dev)) != NULL) {
+		idev->tstamp = jiffies;
+		inet6_ifinfo_notify(RTM_NEWLINK, idev);
+		in6_dev_put(idev);
+	}
+	return proc_dointvec(ctl, write, filp, buffer, lenp);
+}
+#endif
+
 int __init ndisc_init(struct net_proto_family *ops)
 {
 	struct ipv6_pinfo *np;
@@ -1522,7 +1541,8 @@ int __init ndisc_init(struct net_proto_f
 	neigh_table_init(&nd_tbl);
 
 #ifdef CONFIG_SYSCTL
-	neigh_sysctl_register(NULL, &nd_tbl.parms, NET_IPV6, NET_IPV6_NEIGH, "ipv6");
+	neigh_sysctl_register(NULL, &nd_tbl.parms, NET_IPV6, NET_IPV6_NEIGH, 
+			      "ipv6", &ndisc_ifinfo_sysctl_change);
 #endif
 
 	register_netdevice_notifier(&ndisc_netdev_notifier);
diff -puN net/ipv6/raw.c~linus net/ipv6/raw.c
--- 25/net/ipv6/raw.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/ipv6/raw.c	2004-01-19 22:17:25.000000000 -0800
@@ -345,13 +345,15 @@ int rawv6_rcv(struct sock *sk, struct sk
  *	we return it, otherwise we block.
  */
 
-static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, int len,
+static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
+		  struct msghdr *msg, size_t len,
 		  int noblock, int flags, int *addr_len)
 {
 	struct ipv6_pinfo *np = inet6_sk(sk);
 	struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)msg->msg_name;
 	struct sk_buff *skb;
-	int copied, err;
+	size_t copied;
+	int err;
 
 	if (flags & MSG_OOB)
 		return -EOPNOTSUPP;
@@ -527,7 +529,8 @@ error:
 	IP6_INC_STATS(Ip6OutDiscards);
 	return err; 
 }
-static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, int len)
+static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
+		   struct msghdr *msg, size_t len)
 {
 	struct ipv6_txoptions opt_space;
 	struct sockaddr_in6 * sin6 = (struct sockaddr_in6 *) msg->msg_name;
diff -puN net/ipv6/udp.c~linus net/ipv6/udp.c
--- 25/net/ipv6/udp.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/ipv6/udp.c	2004-01-19 22:17:25.000000000 -0800
@@ -366,12 +366,14 @@ static void udpv6_close(struct sock *sk,
  * 	return it, otherwise we block.
  */
 
-static int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, int len,
+static int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, 
+		  struct msghdr *msg, size_t len,
 		  int noblock, int flags, int *addr_len)
 {
 	struct ipv6_pinfo *np = inet6_sk(sk);
   	struct sk_buff *skb;
-  	int copied, err;
+	size_t copied;
+  	int err;
 
   	if (addr_len)
   		*addr_len=sizeof(struct sockaddr_in6);
@@ -774,7 +776,8 @@ out:
 	return err;
 }
 
-static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, int len)
+static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, 
+		  struct msghdr *msg, size_t len)
 {
 	struct ipv6_txoptions opt_space;
 	struct udp_opt *up = udp_sk(sk);
@@ -841,7 +844,7 @@ do_udp_sendmsg:
 	/* Rough check on arithmetic overflow,
 	   better check is made in ip6_build_xmit
 	   */
-	if (len < 0 || len > INT_MAX - sizeof(struct udphdr))
+	if (len > INT_MAX - sizeof(struct udphdr))
 		return -EMSGSIZE;
 	
 	if (up->pending) {
diff -puN net/ipx/af_ipx.c~linus net/ipx/af_ipx.c
--- 25/net/ipx/af_ipx.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/ipx/af_ipx.c	2004-01-19 22:17:25.000000000 -0800
@@ -1683,7 +1683,7 @@ out:
 }
 
 static int ipx_sendmsg(struct kiocb *iocb, struct socket *sock,
-	struct msghdr *msg, int len)
+	struct msghdr *msg, size_t len)
 {
 	struct sock *sk = sock->sk;
 	struct ipx_opt *ipxs = ipx_sk(sk);
@@ -1698,6 +1698,10 @@ static int ipx_sendmsg(struct kiocb *ioc
 	if (flags & ~MSG_DONTWAIT)
 		goto out;
 
+	/* Max possible packet size limited by 16 bit pktsize in header */
+	if (len >= 65535 - sizeof(struct ipxhdr))
+		goto out;
+
 	if (usipx) {
 		if (!ipxs->port) {
 			struct sockaddr_ipx uaddr;
@@ -1744,7 +1748,7 @@ out:
 
 
 static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock,
-		struct msghdr *msg, int size, int flags)
+		struct msghdr *msg, size_t size, int flags)
 {
 	struct sock *sk = sock->sk;
 	struct ipx_opt *ipxs = ipx_sk(sk);
diff -puN net/ipx/ipx_route.c~linus net/ipx/ipx_route.c
--- 25/net/ipx/ipx_route.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/ipx/ipx_route.c	2004-01-19 22:17:25.000000000 -0800
@@ -169,13 +169,13 @@ int ipxrtr_route_skb(struct sk_buff *skb
  * Route an outgoing frame from a socket.
  */
 int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
-			struct iovec *iov, int len, int noblock)
+			struct iovec *iov, size_t len, int noblock)
 {
 	struct sk_buff *skb;
 	struct ipx_opt *ipxs = ipx_sk(sk);
 	struct ipx_interface *intrfc;
 	struct ipxhdr *ipx;
-	int size;
+	size_t size;
 	int ipx_offset;
 	struct ipx_route *rt = NULL;
 	int rc;
diff -puN net/irda/af_irda.c~linus net/irda/af_irda.c
--- 25/net/irda/af_irda.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/irda/af_irda.c	2004-01-19 22:17:25.000000000 -0800
@@ -1257,7 +1257,7 @@ static int irda_release(struct socket *s
  *    fragment the message if necessary
  */
 static int irda_sendmsg(struct kiocb *iocb, struct socket *sock,
-			struct msghdr *msg, int len)
+			struct msghdr *msg, size_t len)
 {
 	struct sock *sk = sock->sk;
 	struct irda_sock *self;
@@ -1329,12 +1329,13 @@ static int irda_sendmsg(struct kiocb *io
  *    after being read, regardless of how much the user actually read
  */
 static int irda_recvmsg_dgram(struct kiocb *iocb, struct socket *sock,
-			      struct msghdr *msg, int size, int flags)
+			      struct msghdr *msg, size_t size, int flags)
 {
 	struct sock *sk = sock->sk;
 	struct irda_sock *self = irda_sk(sk);
 	struct sk_buff *skb;
-	int copied, err;
+	size_t copied;
+	int err;
 
 	IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
 
@@ -1379,12 +1380,12 @@ static int irda_recvmsg_dgram(struct kio
  * Function irda_recvmsg_stream (iocb, sock, msg, size, flags)
  */
 static int irda_recvmsg_stream(struct kiocb *iocb, struct socket *sock,
-			       struct msghdr *msg, int size, int flags)
+			       struct msghdr *msg, size_t size, int flags)
 {
 	struct sock *sk = sock->sk;
 	struct irda_sock *self = irda_sk(sk);
 	int noblock = flags & MSG_DONTWAIT;
-	int copied = 0;
+	size_t copied = 0;
 	int target = 1;
 	DECLARE_WAITQUEUE(waitq, current);
 
@@ -1505,7 +1506,7 @@ static int irda_recvmsg_stream(struct ki
  *
  */
 static int irda_sendmsg_dgram(struct kiocb *iocb, struct socket *sock,
-			      struct msghdr *msg, int len)
+			      struct msghdr *msg, size_t len)
 {
 	struct sock *sk = sock->sk;
 	struct irda_sock *self;
@@ -1571,7 +1572,7 @@ static int irda_sendmsg_dgram(struct kio
  */
 #ifdef CONFIG_IRDA_ULTRA
 static int irda_sendmsg_ultra(struct kiocb *iocb, struct socket *sock,
-			      struct msghdr *msg, int len)
+			      struct msghdr *msg, size_t len)
 {
 	struct sock *sk = sock->sk;
 	struct irda_sock *self;
@@ -1890,11 +1891,10 @@ static int irda_setsockopt(struct socket
 		case IAS_STRING:
 			/* Should check charset & co */
 			/* Check length */
-			if(ias_opt->attribute.irda_attrib_string.len >
-			   IAS_MAX_STRING) {
-				kfree(ias_opt);
-				return -EINVAL;
-			}
+			/* The length is encoded in a __u8, and
+			 * IAS_MAX_STRING == 256, so there is no way
+			 * userspace can pass us a string too large.
+			 * Jean II */
 			/* NULL terminate the string (avoid troubles) */
 			ias_opt->attribute.irda_attrib_string.string[ias_opt->attribute.irda_attrib_string.len] = '\0';
 			/* Add a string attribute */
diff -puN net/irda/ircomm/ircomm_tty.c~linus net/irda/ircomm/ircomm_tty.c
--- 25/net/irda/ircomm/ircomm_tty.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/irda/ircomm/ircomm_tty.c	2004-01-19 22:17:25.000000000 -0800
@@ -38,6 +38,7 @@
 #include <linux/termios.h>
 #include <linux/tty.h>
 #include <linux/interrupt.h>
+#include <linux/device.h>		/* for MODULE_ALIAS_CHARDEV_MAJOR */
 
 #include <asm/uaccess.h>
 
@@ -85,7 +86,9 @@ static struct tty_operations ops = {
 	.write_room      = ircomm_tty_write_room,
 	.chars_in_buffer = ircomm_tty_chars_in_buffer,
 	.flush_buffer    = ircomm_tty_flush_buffer,
-	.ioctl           = ircomm_tty_ioctl,
+	.ioctl           = ircomm_tty_ioctl,	/* ircomm_tty_ioctl.c */
+	.tiocmget        = ircomm_tty_tiocmget,	/* ircomm_tty_ioctl.c */
+	.tiocmset        = ircomm_tty_tiocmset,	/* ircomm_tty_ioctl.c */
 	.throttle        = ircomm_tty_throttle,
 	.unthrottle      = ircomm_tty_unthrottle,
 	.send_xchar      = ircomm_tty_send_xchar,
@@ -1411,6 +1414,7 @@ done:
 MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
 MODULE_DESCRIPTION("IrCOMM serial TTY driver");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS_CHARDEV_MAJOR(IRCOMM_TTY_MAJOR);
 
 module_init(ircomm_tty_init);
 module_exit(ircomm_tty_cleanup);
diff -puN net/irda/ircomm/ircomm_tty_ioctl.c~linus net/irda/ircomm/ircomm_tty_ioctl.c
--- 25/net/irda/ircomm/ircomm_tty_ioctl.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/irda/ircomm/ircomm_tty_ioctl.c	2004-01-19 22:17:25.000000000 -0800
@@ -190,81 +190,62 @@ void ircomm_tty_set_termios(struct tty_s
 }
 
 /*
- * Function ircomm_tty_get_modem_info (self, value)
+ * Function ircomm_tty_tiocmget (tty, file)
  *
  *    
  *
  */
-static int ircomm_tty_get_modem_info(struct ircomm_tty_cb *self, 
-				     unsigned int *value)
+int ircomm_tty_tiocmget(struct tty_struct *tty, struct file *file)
 {
+	struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
 	unsigned int result;
 
 	IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
+	if (tty->flags & (1 << TTY_IO_ERROR))
+		return -EIO;
+
 	result =  ((self->settings.dte & IRCOMM_RTS) ? TIOCM_RTS : 0)
 		| ((self->settings.dte & IRCOMM_DTR) ? TIOCM_DTR : 0)
 		| ((self->settings.dce & IRCOMM_CD)  ? TIOCM_CAR : 0)
 		| ((self->settings.dce & IRCOMM_RI)  ? TIOCM_RNG : 0)
 		| ((self->settings.dce & IRCOMM_DSR) ? TIOCM_DSR : 0)
 		| ((self->settings.dce & IRCOMM_CTS) ? TIOCM_CTS : 0);
-
-	return put_user(result, value);
+	return result;
 }
 
 /*
- * Function set_modem_info (driver, cmd, value)
+ * Function ircomm_tty_tiocmset (tty, file, set, clear)
  *
  *    
  *
  */
-static int ircomm_tty_set_modem_info(struct ircomm_tty_cb *self, 
-				     unsigned int cmd, unsigned int *value)
+int ircomm_tty_tiocmset(struct tty_struct *tty, struct file *file,
+			unsigned int set, unsigned int clear)
 { 
-	unsigned int arg;
-	__u8 old_rts, old_dtr;
+	struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
 
 	IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
 
+	if (tty->flags & (1 << TTY_IO_ERROR))
+		return -EIO;
+
 	ASSERT(self != NULL, return -1;);
 	ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
 
-	if (get_user(arg, value))
-		return -EFAULT;
-
-	old_rts = self->settings.dte & IRCOMM_RTS;
-	old_dtr = self->settings.dte & IRCOMM_DTR;
+	if (set & TIOCM_RTS)
+		self->settings.dte |= IRCOMM_RTS;
+	if (set & TIOCM_DTR)
+		self->settings.dte |= IRCOMM_DTR;
+
+	if (clear & TIOCM_RTS)
+		self->settings.dte &= ~IRCOMM_RTS;
+	if (clear & TIOCM_DTR)
+		self->settings.dte &= ~IRCOMM_DTR;
 
-	switch (cmd) {
-	case TIOCMBIS: 
-		if (arg & TIOCM_RTS) 
-			self->settings.dte |= IRCOMM_RTS;
-		if (arg & TIOCM_DTR)
-			self->settings.dte |= IRCOMM_DTR;
-		break;
-		
-	case TIOCMBIC:
-		if (arg & TIOCM_RTS)
-			self->settings.dte &= ~IRCOMM_RTS;
-		if (arg & TIOCM_DTR)
- 			self->settings.dte &= ~IRCOMM_DTR;
- 		break;
-		
-	case TIOCMSET:
- 		self->settings.dte = 
-			((self->settings.dte & ~(IRCOMM_RTS | IRCOMM_DTR))
-			 | ((arg & TIOCM_RTS) ? IRCOMM_RTS : 0)
-			 | ((arg & TIOCM_DTR) ? IRCOMM_DTR : 0));
-		break;
-		
-	default:
-		return -EINVAL;
-	}
-	
-	if ((self->settings.dte & IRCOMM_RTS) != old_rts)
+	if ((set|clear) & TIOCM_RTS)
 		self->settings.dte |= IRCOMM_DELTA_RTS;
-
-	if ((self->settings.dte & IRCOMM_DTR) != old_dtr)
+	if ((set|clear) & TIOCM_DTR)
 		self->settings.dte |= IRCOMM_DELTA_DTR;
 
 	ircomm_param_request(self, IRCOMM_DTE, TRUE);
@@ -406,14 +387,6 @@ int ircomm_tty_ioctl(struct tty_struct *
 	}
 
 	switch (cmd) {
-	case TIOCMGET:
-		ret = ircomm_tty_get_modem_info(self, (unsigned int *) arg);
-		break;
-	case TIOCMBIS:
-	case TIOCMBIC:
-	case TIOCMSET:
-		ret = ircomm_tty_set_modem_info(self, cmd, (unsigned int *) arg);
-		break;
 	case TIOCGSERIAL:
 		ret = ircomm_tty_get_serial_info(self, (struct serial_struct *) arg);
 		break;
diff -puN net/irda/irlap_event.c~linus net/irda/irlap_event.c
--- 25/net/irda/irlap_event.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/irda/irlap_event.c	2004-01-19 22:17:25.000000000 -0800
@@ -932,6 +932,12 @@ static int irlap_state_setup(struct irla
 		/* This frame will actually be sent at the new speed */
 		irlap_send_rr_frame(self, CMD_FRAME);
 
+		/* The timer is set to half the normal timer to quickly
+		 * detect a failure to negociate the new connection
+		 * parameters. IrLAP 6.11.3.2, note 3.
+		 * Note that currently we don't process this failure
+		 * properly, as we should do a quick disconnect.
+		 * Jean II */
 		irlap_start_final_timer(self, self->final_timeout/2);
 		irlap_next_state(self, LAP_NRM_P);
 
@@ -1312,7 +1318,12 @@ static int irlap_state_nrm_p(struct irla
 				irlap_resend_rejected_frames(self, CMD_FRAME);
 
 				self->ack_required = FALSE;
-				irlap_start_final_timer(self, self->final_timeout);
+
+				/* Make sure we account for the time
+				 * to transmit our frames. See comemnts
+				 * in irlap_send_data_primary_poll().
+				 * Jean II */
+				irlap_start_final_timer(self, 2 * self->final_timeout);
 
 				/* Keep state, do not move this line */
 				irlap_next_state(self, LAP_NRM_P);
@@ -1352,8 +1363,9 @@ static int irlap_state_nrm_p(struct irla
 				/* Resend rejected frames */
 				irlap_resend_rejected_frames(self, CMD_FRAME);
 
-				/* Give peer some time to retransmit! */
-				irlap_start_final_timer(self, self->final_timeout);
+				/* Give peer some time to retransmit! 
+				 * But account for our own Tx. */
+				irlap_start_final_timer(self, 2 * self->final_timeout);
 
 				/* Keep state, do not move this line */
 				irlap_next_state(self, LAP_NRM_P);
@@ -1450,6 +1462,8 @@ static int irlap_state_nrm_p(struct irla
 			/* Resend rejected frames */
 			irlap_resend_rejected_frames(self, CMD_FRAME);
 
+			/* Final timer ??? Jean II */
+
 			irlap_next_state(self, LAP_NRM_P);
 		} else if (ret == NR_INVALID) {
 			IRDA_DEBUG(1, "%s(), Received RR with "
@@ -1541,7 +1555,7 @@ static int irlap_state_nrm_p(struct irla
 			irlap_send_rr_frame(self, CMD_FRAME);
 		} else
 			irlap_resend_rejected_frames(self, CMD_FRAME);
-		irlap_start_final_timer(self, self->final_timeout);
+		irlap_start_final_timer(self, 2 * self->final_timeout);
 		break;
 	case RECV_SREJ_RSP:
 		irlap_update_nr_received(self, info->nr);
@@ -1550,7 +1564,7 @@ static int irlap_state_nrm_p(struct irla
 			irlap_send_rr_frame(self, CMD_FRAME);
 		} else
 			irlap_resend_rejected_frame(self, CMD_FRAME);
-		irlap_start_final_timer(self, self->final_timeout);
+		irlap_start_final_timer(self, 2 * self->final_timeout);
 		break;
 	case RECV_RD_RSP:
 		IRDA_DEBUG(1, "%s(), RECV_RD_RSP\n", __FUNCTION__);
diff -puN net/irda/irlap_frame.c~linus net/irda/irlap_frame.c
--- 25/net/irda/irlap_frame.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/irda/irlap_frame.c	2004-01-19 22:17:25.000000000 -0800
@@ -779,6 +779,7 @@ void irlap_send_data_primary(struct irla
 void irlap_send_data_primary_poll(struct irlap_cb *self, struct sk_buff *skb)
 {
 	struct sk_buff *tx_skb;
+	int transmission_time;
 
 	/* Stop P timer */
 	del_timer(&self->poll_timer);
@@ -829,13 +830,49 @@ void irlap_send_data_primary_poll(struct
 		}
 	}
 
+	/* How much time we took for transmission of all frames.
+	 * We don't know, so let assume we used the full window. Jean II */
+	transmission_time = self->final_timeout;
+
+	/* Reset parameter so that we can fill next window */
 	self->window = self->window_size;
+
 #ifdef CONFIG_IRDA_DYNAMIC_WINDOW
+	/* Remove what we have not used. Just do a prorata of the
+	 * bytes left in window to window capacity.
+	 * See max_line_capacities[][] in qos.c for details. Jean II */
+	transmission_time -= (self->final_timeout * self->bytes_left
+			      / self->line_capacity);
+	IRDA_DEBUG(4, "%s() adjusting transmission_time : ft=%d, bl=%d, lc=%d -> tt=%d\n", __FUNCTION__, self->final_timeout, self->bytes_left, self->line_capacity, transmission_time);
+
 	/* We are allowed to transmit a maximum number of bytes again. */
 	self->bytes_left = self->line_capacity;
 #endif /* CONFIG_IRDA_DYNAMIC_WINDOW */
 
-	irlap_start_final_timer(self, self->final_timeout);
+	/*
+	 * The network layer has a intermediate buffer between IrLAP
+	 * and the IrDA driver which can contain 8 frames. So, even
+	 * though IrLAP is currently sending the *last* frame of the
+	 * tx-window, the driver most likely has only just started
+	 * sending the *first* frame of the same tx-window.
+	 * I.e. we are always at the very begining of or Tx window.
+	 * Now, we are supposed to set the final timer from the end
+	 * of our tx-window to let the other peer reply. So, we need
+	 * to add extra time to compensate for the fact that we
+	 * are really at the start of tx-window, otherwise the final timer
+	 * might expire before he can answer...
+	 * Jean II
+	 */
+	irlap_start_final_timer(self, self->final_timeout + transmission_time);
+
+	/*
+	 * The clever amongst you might ask why we do this adjustement
+	 * only here, and not in all the other cases in irlap_event.c.
+	 * In all those other case, we only send a very short management
+	 * frame (few bytes), so the adjustement would be lost in the
+	 * noise...
+	 * The exception of course is irlap_resend_rejected_frame().
+	 * Jean II */
 }
 
 /*
@@ -1003,7 +1040,7 @@ void irlap_resend_rejected_frames(struct
 	}
 #if 0 /* Not yet */
 	/*
-	 *  We can now fill the window with additinal data frames
+	 *  We can now fill the window with additional data frames
 	 */
 	while (skb_queue_len( &self->txq) > 0) {
 
diff -puN net/key/af_key.c~linus net/key/af_key.c
--- 25/net/key/af_key.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/key/af_key.c	2004-01-19 22:17:25.000000000 -0800
@@ -1283,6 +1283,7 @@ static int pfkey_delete(struct sock *sk,
 
 static int pfkey_get(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr, void **ext_hdrs)
 {
+	__u8 proto;
 	struct sk_buff *out_skb;
 	struct sadb_msg *out_hdr;
 	struct xfrm_state *x;
@@ -1297,6 +1298,7 @@ static int pfkey_get(struct sock *sk, st
 		return -ESRCH;
 
 	out_skb = pfkey_xfrm_state2msg(x, 1, 3);
+	proto = x->id.proto;
 	xfrm_state_put(x);
 	if (IS_ERR(out_skb))
 		return  PTR_ERR(out_skb);
@@ -1304,7 +1306,7 @@ static int pfkey_get(struct sock *sk, st
 	out_hdr = (struct sadb_msg *) out_skb->data;
 	out_hdr->sadb_msg_version = hdr->sadb_msg_version;
 	out_hdr->sadb_msg_type = SADB_DUMP;
-	out_hdr->sadb_msg_satype = pfkey_proto2satype(x->id.proto);
+	out_hdr->sadb_msg_satype = pfkey_proto2satype(proto);
 	out_hdr->sadb_msg_errno = 0;
 	out_hdr->sadb_msg_reserved = 0;
 	out_hdr->sadb_msg_seq = hdr->sadb_msg_seq;
@@ -2655,7 +2657,7 @@ static int pfkey_send_new_mapping(struct
 }
 
 static int pfkey_sendmsg(struct kiocb *kiocb,
-			 struct socket *sock, struct msghdr *msg, int len)
+			 struct socket *sock, struct msghdr *msg, size_t len)
 {
 	struct sock *sk = sock->sk;
 	struct sk_buff *skb = NULL;
@@ -2697,7 +2699,7 @@ out:
 }
 
 static int pfkey_recvmsg(struct kiocb *kiocb,
-			 struct socket *sock, struct msghdr *msg, int len,
+			 struct socket *sock, struct msghdr *msg, size_t len,
 			 int flags)
 {
 	struct sock *sk = sock->sk;
diff -puN net/llc/af_llc.c~linus net/llc/af_llc.c
--- 25/net/llc/af_llc.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/llc/af_llc.c	2004-01-19 22:17:25.000000000 -0800
@@ -671,12 +671,13 @@ out:
  *	Returns non-negative upon success, negative otherwise.
  */
 static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
-			  struct msghdr *msg, int size, int flags)
+			  struct msghdr *msg, size_t size, int flags)
 {
 	struct sock *sk = sock->sk;
 	struct sockaddr_llc *uaddr = (struct sockaddr_llc *)msg->msg_name;
 	struct sk_buff *skb;
-	int rc = -ENOMEM, copied = 0, timeout;
+	size_t copied = 0;
+	int rc = -ENOMEM, timeout;
 	int noblock = flags & MSG_DONTWAIT;
 
 	dprintk("%s: receiving in %02X from %02X\n", __FUNCTION__,
@@ -725,7 +726,7 @@ out:
  *	Returns non-negative upon success, negative otherwise.
  */
 static int llc_ui_sendmsg(struct kiocb *iocb, struct socket *sock,
-			  struct msghdr *msg, int len)
+			  struct msghdr *msg, size_t len)
 {
 	struct sock *sk = sock->sk;
 	struct llc_opt *llc = llc_sk(sk);
@@ -734,7 +735,8 @@ static int llc_ui_sendmsg(struct kiocb *
 	int noblock = flags & MSG_DONTWAIT;
 	struct net_device *dev;
 	struct sk_buff *skb;
-	int rc = -EINVAL, size = 0, copied = 0, hdrlen;
+	size_t size = 0;
+	int rc = -EINVAL, copied = 0, hdrlen;
 
 	dprintk("%s: sending from %02X to %02X\n", __FUNCTION__,
 		llc->laddr.lsap, llc->daddr.lsap);
diff -puN net/netlink/af_netlink.c~linus net/netlink/af_netlink.c
--- 25/net/netlink/af_netlink.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/netlink/af_netlink.c	2004-01-19 22:17:25.000000000 -0800
@@ -601,7 +601,7 @@ static inline void netlink_rcv_wake(stru
 }
 
 static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock,
-			   struct msghdr *msg, int len)
+			   struct msghdr *msg, size_t len)
 {
 	struct sock_iocb *siocb = kiocb_to_siocb(kiocb);
 	struct sock *sk = sock->sk;
@@ -641,7 +641,7 @@ static int netlink_sendmsg(struct kiocb 
 	}
 
 	err = -EMSGSIZE;
-	if ((unsigned)len > sk->sk_sndbuf - 32)
+	if (len > sk->sk_sndbuf - 32)
 		goto out;
 	err = -ENOBUFS;
 	skb = alloc_skb(len, GFP_KERNEL);
@@ -683,7 +683,7 @@ out:
 }
 
 static int netlink_recvmsg(struct kiocb *kiocb, struct socket *sock,
-			   struct msghdr *msg, int len,
+			   struct msghdr *msg, size_t len,
 			   int flags)
 {
 	struct sock_iocb *siocb = kiocb_to_siocb(kiocb);
@@ -691,7 +691,7 @@ static int netlink_recvmsg(struct kiocb 
 	struct sock *sk = sock->sk;
 	struct netlink_opt *nlk = nlk_sk(sk);
 	int noblock = flags&MSG_DONTWAIT;
-	int copied;
+	size_t copied;
 	struct sk_buff *skb;
 	int err;
 
diff -puN net/netrom/af_netrom.c~linus net/netrom/af_netrom.c
--- 25/net/netrom/af_netrom.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/netrom/af_netrom.c	2004-01-19 22:17:25.000000000 -0800
@@ -1010,7 +1010,7 @@ int nr_rx_frame(struct sk_buff *skb, str
 }
 
 static int nr_sendmsg(struct kiocb *iocb, struct socket *sock,
-		      struct msghdr *msg, int len)
+		      struct msghdr *msg, size_t len)
 {
 	struct sock *sk = sock->sk;
 	nr_cb *nr = nr_sk(sk);
@@ -1119,11 +1119,11 @@ out:
 }
 
 static int nr_recvmsg(struct kiocb *iocb, struct socket *sock,
-		      struct msghdr *msg, int size, int flags)
+		      struct msghdr *msg, size_t size, int flags)
 {
 	struct sock *sk = sock->sk;
 	struct sockaddr_ax25 *sax = (struct sockaddr_ax25 *)msg->msg_name;
-	int copied;
+	size_t copied;
 	struct sk_buff *skb;
 	int er;
 
diff -puN net/packet/af_packet.c~linus net/packet/af_packet.c
--- 25/net/packet/af_packet.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/packet/af_packet.c	2004-01-19 22:17:25.000000000 -0800
@@ -284,7 +284,7 @@ oom:
  */
  
 static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
-			       struct msghdr *msg, int len)
+			       struct msghdr *msg, size_t len)
 {
 	struct sock *sk = sock->sk;
 	struct sockaddr_pkt *saddr=(struct sockaddr_pkt *)msg->msg_name;
@@ -659,7 +659,7 @@ ring_is_full:
 
 
 static int packet_sendmsg(struct kiocb *iocb, struct socket *sock,
-			  struct msghdr *msg, int len)
+			  struct msghdr *msg, size_t len)
 {
 	struct sock *sk = sock->sk;
 	struct sockaddr_ll *saddr=(struct sockaddr_ll *)msg->msg_name;
@@ -1007,7 +1007,7 @@ out:
  */
 
 static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
-			  struct msghdr *msg, int len, int flags)
+			  struct msghdr *msg, size_t len, int flags)
 {
 	struct sock *sk = sock->sk;
 	struct sk_buff *skb;
@@ -1550,7 +1550,7 @@ static int packet_set_ring(struct sock *
 	unsigned long *pg_vec = NULL;
 	struct tpacket_hdr **io_vec = NULL;
 	struct packet_opt *po = pkt_sk(sk);
-	int order = 0;
+	int was_running, num, order = 0;
 	int err = 0;
 
 	if (req->tp_block_nr) {
@@ -1623,10 +1623,13 @@ static int packet_set_ring(struct sock *
 
 	/* Detach socket from network */
 	spin_lock(&po->bind_lock);
-	if (po->running) {
+	was_running = po->running;
+	num = po->num;
+	if (was_running) {
 		__dev_remove_pack(&po->prot_hook);
 		po->num = 0;
 		po->running = 0;
+		__sock_put(sk);
 	}
 	spin_unlock(&po->bind_lock);
 		
@@ -1657,8 +1660,12 @@ static int packet_set_ring(struct sock *
 	}
 
 	spin_lock(&po->bind_lock);
-	if (po->running)
+	if (was_running && !po->running) {
+		sock_hold(sk);
+		po->running = 1;
+		po->num = num;
 		dev_add_pack(&po->prot_hook);
+	}
 	spin_unlock(&po->bind_lock);
 
 	release_sock(sk);
diff -puN net/rose/af_rose.c~linus net/rose/af_rose.c
--- 25/net/rose/af_rose.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/rose/af_rose.c	2004-01-19 22:17:25.000000000 -0800
@@ -1010,7 +1010,7 @@ int rose_rx_call_request(struct sk_buff 
 }
 
 static int rose_sendmsg(struct kiocb *iocb, struct socket *sock,
-			struct msghdr *msg, int len)
+			struct msghdr *msg, size_t len)
 {
 	struct sock *sk = sock->sk;
 	rose_cb *rose = rose_sk(sk);
@@ -1174,15 +1174,15 @@ static int rose_sendmsg(struct kiocb *io
 
 
 static int rose_recvmsg(struct kiocb *iocb, struct socket *sock,
-			struct msghdr *msg, int size, int flags)
+			struct msghdr *msg, size_t size, int flags)
 {
 	struct sock *sk = sock->sk;
 	rose_cb *rose = rose_sk(sk);
 	struct sockaddr_rose *srose = (struct sockaddr_rose *)msg->msg_name;
-	int copied, qbit;
+	size_t copied;
 	unsigned char *asmptr;
 	struct sk_buff *skb;
-	int n, er;
+	int n, er, qbit;
 
 	/*
 	 * This works for seqpacket too. The receiver has ordered the queue for
diff -puN net/rxrpc/call.c~linus net/rxrpc/call.c
--- 25/net/rxrpc/call.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/rxrpc/call.c	2004-01-19 22:17:25.000000000 -0800
@@ -699,7 +699,7 @@ static int rxrpc_call_generate_ACK(struc
 
 		timo = rxrpc_call_dfr_ack_timeout + jiffies;
 
-		_debug("START ACKR TIMER for cj=%lu", timo-call->cjif);
+		_debug("START ACKR TIMER for cj=%lu", timo - call->cjif);
 
 		spin_lock(&call->lock);
 		mod_timer(&call->ackr_dfr_timo, timo);
@@ -722,7 +722,8 @@ static int rxrpc_call_generate_ACK(struc
 
 		/* fill out the appropriate form */
 		ack.bufferSpace	= htons(RXRPC_CALL_ACK_WINDOW_SIZE);
-		ack.maxSkew	= htons(min(call->ackr_high_seq - seq,65535U));
+		ack.maxSkew	= htons(min(call->ackr_high_seq - seq,
+					    65535U));
 		ack.firstPacket	= htonl(call->ackr_win_bot);
 		ack.previousPacket = call->ackr_prev_seq;
 		ack.serial	= hdr->serial;
@@ -825,7 +826,7 @@ void rxrpc_call_do_stuff(struct rxrpc_ca
 
 	_leave("");
 
-} /* end rxrpc_call_do_timeout() */
+} /* end rxrpc_call_do_stuff() */
 
 /*****************************************************************************/
 /*
@@ -1061,7 +1062,7 @@ static void rxrpc_call_receive_data_pack
 		_debug("Call add packet %d to unreadyq", msg->seq);
 
 		/* insert in seq order */
-		list_for_each(_p,&call->app_unreadyq) {
+		list_for_each(_p, &call->app_unreadyq) {
 			pmsg = list_entry(_p, struct rxrpc_message, link);
 			if (pmsg->seq > msg->seq)
 				break;
@@ -2095,7 +2096,8 @@ int rxrpc_call_flush(struct rxrpc_call *
 
 		if (msg->hdr.flags & RXRPC_LAST_PACKET) {
 			msg->hdr.flags &= ~RXRPC_MORE_PACKETS;
-			msg->hdr.flags |= RXRPC_REQUEST_ACK;
+			if (call->app_call_state != RXRPC_CSTATE_CLNT_SND_ARGS)
+				msg->hdr.flags |= RXRPC_REQUEST_ACK;
 		}
 		else {
 			msg->hdr.flags |= RXRPC_MORE_PACKETS;
diff -puN net/rxrpc/krxiod.c~linus net/rxrpc/krxiod.c
--- 25/net/rxrpc/krxiod.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/rxrpc/krxiod.c	2004-01-19 22:17:25.000000000 -0800
@@ -44,12 +44,6 @@ static int rxrpc_krxiod(void *arg)
 
 	daemonize("krxiod");
 
-	/* only certain signals are of interest */
-	spin_lock_irq(&current->sighand->siglock);
-	siginitsetinv(&current->blocked, 0);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
-
 	/* loop around waiting for work to do */
 	do {
 		/* wait for work or to be told to exit */
@@ -116,7 +110,7 @@ static int rxrpc_krxiod(void *arg)
 
 			if (!list_empty(&rxrpc_krxiod_callq)) {
 				call = list_entry(rxrpc_krxiod_callq.next,
-						   struct rxrpc_call,
+						  struct rxrpc_call,
 						  rcv_krxiodq_lk);
 				list_del_init(&call->rcv_krxiodq_lk);
 				atomic_dec(&rxrpc_krxiod_qcount);
@@ -125,7 +119,7 @@ static int rxrpc_krxiod(void *arg)
 				 * away */
 				if (atomic_read(&call->usage) > 0) {
 					_debug("@@@ KRXIOD"
-					       " Begin Attend Call %p",call);
+					       " Begin Attend Call %p", call);
 					rxrpc_get_call(call);
 				}
 				else {
diff -puN net/rxrpc/krxsecd.c~linus net/rxrpc/krxsecd.c
--- 25/net/rxrpc/krxsecd.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/rxrpc/krxsecd.c	2004-01-19 22:17:25.000000000 -0800
@@ -57,12 +57,6 @@ static int rxrpc_krxsecd(void *arg)
 
 	daemonize("krxsecd");
 
-	/* only certain signals are of interest */
-	spin_lock_irq(&current->sighand->siglock);
-	siginitsetinv(&current->blocked, 0);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
-
 	/* loop around waiting for work to do */
 	do {
 		/* wait for work or to be told to exit */
diff -puN net/rxrpc/krxtimod.c~linus net/rxrpc/krxtimod.c
--- 25/net/rxrpc/krxtimod.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/rxrpc/krxtimod.c	2004-01-19 22:17:25.000000000 -0800
@@ -74,12 +74,6 @@ static int krxtimod(void *arg)
 
 	complete(&krxtimod_alive);
 
-	/* only certain signals are of interest */
-	spin_lock_irq(&current->sighand->siglock);
-	siginitsetinv(&current->blocked, 0);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
-
 	/* loop around looking for things to attend to */
  loop:
 	set_current_state(TASK_INTERRUPTIBLE);
diff -puN net/rxrpc/transport.c~linus net/rxrpc/transport.c
--- 25/net/rxrpc/transport.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/rxrpc/transport.c	2004-01-19 22:17:25.000000000 -0800
@@ -130,7 +130,19 @@ int rxrpc_create_transport(unsigned shor
 	return 0;
 
  error:
-	rxrpc_put_transport(trans);
+	/* finish cleaning up the transport (not really needed here, but...) */
+	if (trans->socket)
+		trans->socket->ops->shutdown(trans->socket, 2);
+
+	/* close the socket */
+	if (trans->socket) {
+		trans->socket->sk->sk_user_data = NULL;
+		sock_release(trans->socket);
+		trans->socket = NULL;
+	}
+
+	kfree(trans);
+
 
 	_leave(" = %d", ret);
 	return ret;
diff -puN net/sched/sch_teql.c~linus net/sched/sch_teql.c
--- 25/net/sched/sch_teql.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/sched/sch_teql.c	2004-01-19 22:17:25.000000000 -0800
@@ -456,7 +456,6 @@ static __init void teql_master_setup(str
 }
 
 static LIST_HEAD(master_dev_list);
-static spinlock_t master_dev_lock = SPIN_LOCK_UNLOCKED;
 static int max_equalizers = 1;
 MODULE_PARM(max_equalizers, "i");
 MODULE_PARM_DESC(max_equalizers, "Max number of link equalizers");
@@ -475,13 +474,13 @@ int __init teql_init(void)
 		if (!dev)
 			return -ENOMEM;
 
-		if ((err = register_netdev(dev)))
+		if ((err = register_netdev(dev))) {
+			free_netdev(dev);
 			goto out;
+		}
 
 		master = dev->priv;
-		spin_lock(&master_dev_lock);
 		list_add_tail(&master->master_list, &master_dev_list);
-		spin_unlock(&master_dev_lock);
 	}
  out:
 	return err;
@@ -491,7 +490,6 @@ static void __exit teql_exit(void) 
 {
 	struct teql_master *master, *nxt;
 
-	spin_lock(&master_dev_lock);
 	list_for_each_entry_safe(master, nxt, &master_dev_list, master_list) {
 
 		list_del(&master->master_list);
@@ -500,7 +498,6 @@ static void __exit teql_exit(void) 
 		unregister_netdev(master->dev);
 		free_netdev(master->dev);
 	}
-	spin_unlock(&master_dev_lock);
 }
 
 module_init(teql_init);
diff -puN net/sctp/socket.c~linus net/sctp/socket.c
--- 25/net/sctp/socket.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/sctp/socket.c	2004-01-19 22:17:25.000000000 -0800
@@ -90,7 +90,7 @@ static inline int sctp_wspace(struct sct
 static inline void sctp_set_owner_w(struct sctp_chunk *chunk);
 static void sctp_wfree(struct sk_buff *skb);
 static int sctp_wait_for_sndbuf(struct sctp_association *, long *timeo_p,
-				int msg_len);
+				size_t msg_len);
 static int sctp_wait_for_packet(struct sock * sk, int *err, long *timeo_p);
 static int sctp_wait_for_connect(struct sctp_association *, long *timeo_p);
 static int sctp_wait_for_accept(struct sock *sk, long timeo);
@@ -943,7 +943,7 @@ static int sctp_error(struct sock *sk, i
 SCTP_STATIC int sctp_msghdr_parse(const struct msghdr *, sctp_cmsgs_t *);
 
 SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
-			     struct msghdr *msg, int msg_len)
+			     struct msghdr *msg, size_t msg_len)
 {
 	struct sctp_opt *sp;
 	struct sctp_endpoint *ep;
@@ -965,7 +965,7 @@ SCTP_STATIC int sctp_sendmsg(struct kioc
 	struct list_head *pos;
 	int msg_flags = msg->msg_flags;
 
-	SCTP_DEBUG_PRINTK("sctp_sendmsg(sk: %p, msg: %p, msg_len: %d)\n",
+	SCTP_DEBUG_PRINTK("sctp_sendmsg(sk: %p, msg: %p, msg_len: %u)\n",
 			  sk, msg, msg_len);
 
 	err = 0;
@@ -1021,7 +1021,7 @@ SCTP_STATIC int sctp_sendmsg(struct kioc
 		associd = sinfo->sinfo_assoc_id;
 	}
 
-	SCTP_DEBUG_PRINTK("msg_len: %d, sinfo_flags: 0x%x\n",
+	SCTP_DEBUG_PRINTK("msg_len: %u, sinfo_flags: 0x%x\n",
 			  msg_len, sinfo_flags);
 
 	/* MSG_EOF or MSG_ABORT cannot be set on a TCP-style socket. */
@@ -1377,7 +1377,7 @@ static int sctp_skb_pull(struct sk_buff 
 static struct sk_buff *sctp_skb_recv_datagram(struct sock *, int, int, int *);
 
 SCTP_STATIC int sctp_recvmsg(struct kiocb *iocb, struct sock *sk,
-			     struct msghdr *msg, int len, int noblock,
+			     struct msghdr *msg, size_t len, int noblock,
 			     int flags, int *addr_len)
 {
 	struct sctp_ulpevent *event = NULL;
@@ -4157,14 +4157,14 @@ static void sctp_wfree(struct sk_buff *s
 
 /* Helper function to wait for space in the sndbuf.  */
 static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
-				int msg_len)
+				size_t msg_len)
 {
 	struct sock *sk = asoc->base.sk;
 	int err = 0;
 	long current_timeo = *timeo_p;
 	DEFINE_WAIT(wait);
 
-	SCTP_DEBUG_PRINTK("wait_for_sndbuf: asoc=%p, timeo=%ld, msg_len=%d\n",
+	SCTP_DEBUG_PRINTK("wait_for_sndbuf: asoc=%p, timeo=%ld, msg_len=%u\n",
 	                  asoc, (long)(*timeo_p), msg_len);
 
 	/* Increment the association's refcnt.  */
diff -puN net/socket.c~linus net/socket.c
--- 25/net/socket.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/socket.c	2004-01-19 22:17:25.000000000 -0800
@@ -394,6 +394,7 @@ int sock_map_fd(struct socket *sock)
 		file->f_dentry->d_op = &sockfs_dentry_operations;
 		d_add(file->f_dentry, SOCK_INODE(sock));
 		file->f_vfsmnt = mntget(sock_mnt);
+		file->f_mapping = file->f_dentry->d_inode->i_mapping;
 
 		sock->file = file;
 		file->f_op = SOCK_INODE(sock)->i_fop = &socket_file_ops;
@@ -523,7 +524,8 @@ void sock_release(struct socket *sock)
 	sock->file=NULL;
 }
 
-static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, int size)
+static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock, 
+				 struct msghdr *msg, size_t size)
 {
 	struct sock_iocb *si = kiocb_to_siocb(iocb);
 	int err;
@@ -540,7 +542,7 @@ static inline int __sock_sendmsg(struct 
 	return sock->ops->sendmsg(iocb, sock, msg, size);
 }
 
-int sock_sendmsg(struct socket *sock, struct msghdr *msg, int size)
+int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
 {
 	struct kiocb iocb;
 	int ret;
@@ -553,7 +555,8 @@ int sock_sendmsg(struct socket *sock, st
 }
 
 
-static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, int size, int flags)
+static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock, 
+				 struct msghdr *msg, size_t size, int flags)
 {
 	int err;
 	struct sock_iocb *si = kiocb_to_siocb(iocb);
@@ -571,7 +574,8 @@ static inline int __sock_recvmsg(struct 
 	return sock->ops->recvmsg(iocb, sock, msg, size, flags);
 }
 
-int sock_recvmsg(struct socket *sock, struct msghdr *msg, int size, int flags)
+int sock_recvmsg(struct socket *sock, struct msghdr *msg, 
+		 size_t size, int flags)
 {
 	struct kiocb iocb;
 	int ret;
@@ -668,7 +672,7 @@ ssize_t sock_sendpage(struct file *file,
 }
 
 int sock_readv_writev(int type, struct inode * inode, struct file * file,
-		      const struct iovec * iov, long count, long size)
+		      const struct iovec * iov, long count, size_t size)
 {
 	struct msghdr msg;
 	struct socket *sock;
diff -puN net/unix/af_unix.c~linus net/unix/af_unix.c
--- 25/net/unix/af_unix.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/unix/af_unix.c	2004-01-19 22:17:25.000000000 -0800
@@ -1176,7 +1176,7 @@ static void unix_attach_fds(struct scm_c
  */
 
 static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
-			      struct msghdr *msg, int len)
+			      struct msghdr *msg, size_t len)
 {
 	struct sock_iocb *siocb = kiocb_to_siocb(kiocb);
 	struct sock *sk = sock->sk;
@@ -1217,7 +1217,7 @@ static int unix_dgram_sendmsg(struct kio
 		goto out;
 
 	err = -EMSGSIZE;
-	if ((unsigned)len > sk->sk_sndbuf - 32)
+	if (len > sk->sk_sndbuf - 32)
 		goto out;
 
 	skb = sock_alloc_send_skb(sk, len, msg->msg_flags&MSG_DONTWAIT, &err);
@@ -1324,7 +1324,7 @@ out:
 
 		
 static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
-			       struct msghdr *msg, int len)
+			       struct msghdr *msg, size_t len)
 {
 	struct sock_iocb *siocb = kiocb_to_siocb(kiocb);
 	struct sock *sk = sock->sk;
@@ -1447,7 +1447,7 @@ static void unix_copy_addr(struct msghdr
 }
 
 static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
-			      struct msghdr *msg, int size,
+			      struct msghdr *msg, size_t size,
 			      int flags)
 {
 	struct sock_iocb *siocb = kiocb_to_siocb(iocb);
@@ -1555,7 +1555,7 @@ static long unix_stream_data_wait(struct
 
 
 static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
-			       struct msghdr *msg, int size,
+			       struct msghdr *msg, size_t size,
 			       int flags)
 {
 	struct sock_iocb *siocb = kiocb_to_siocb(iocb);
diff -puN net/x25/af_x25.c~linus net/x25/af_x25.c
--- 25/net/x25/af_x25.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/x25/af_x25.c	2004-01-19 22:17:25.000000000 -0800
@@ -910,7 +910,7 @@ out_clear_request:
 }
 
 static int x25_sendmsg(struct kiocb *iocb, struct socket *sock,
-		       struct msghdr *msg, int len)
+		       struct msghdr *msg, size_t len)
 {
 	struct sock *sk = sock->sk;
 	struct x25_opt *x25 = x25_sk(sk);
@@ -919,7 +919,8 @@ static int x25_sendmsg(struct kiocb *ioc
 	struct sk_buff *skb;
 	unsigned char *asmptr;
 	int noblock = msg->msg_flags & MSG_DONTWAIT;
-	int size, qbit = 0, rc = -EINVAL;
+	size_t size;
+	int qbit = 0, rc = -EINVAL;
 
 	if (msg->msg_flags & ~(MSG_DONTWAIT | MSG_OOB | MSG_EOR))
 		goto out;
@@ -1085,13 +1086,14 @@ out_kfree_skb:
 
 
 static int x25_recvmsg(struct kiocb *iocb, struct socket *sock,
-		       struct msghdr *msg, int size,
+		       struct msghdr *msg, size_t size,
 		       int flags)
 {
 	struct sock *sk = sock->sk;
 	struct x25_opt *x25 = x25_sk(sk);
 	struct sockaddr_x25 *sx25 = (struct sockaddr_x25 *)msg->msg_name;
-	int copied, qbit;
+	size_t copied;
+	int qbit;
 	struct sk_buff *skb;
 	unsigned char *asmptr;
 	int rc = -ENOTCONN;
@@ -1370,9 +1372,6 @@ void x25_kill_by_neigh(struct x25_neigh 
 
 static int __init x25_init(void)
 {
-#ifdef MODULE
-	struct net_device *dev;
-#endif /* MODULE */
 	sock_register(&x25_family_ops);
 
 	dev_add_pack(&x25_packet_type);
@@ -1384,23 +1383,7 @@ static int __init x25_init(void)
 #ifdef CONFIG_SYSCTL
 	x25_register_sysctl();
 #endif
-
 	x25_proc_init();
-#ifdef MODULE
-	/*
-	 *	Register any pre existing devices.
-	 */
-	read_lock(&dev_base_lock);
-	for (dev = dev_base; dev; dev = dev->next) {
-		if ((dev->flags & IFF_UP) && (dev->type == ARPHRD_X25
-#if defined(CONFIG_LLC) || defined(CONFIG_LLC_MODULE)
-					   || dev->type == ARPHRD_ETHER
-#endif
-			))
-			x25_link_device_up(dev);
-	}
-	read_unlock(&dev_base_lock);
-#endif /* MODULE */
 	return 0;
 }
 module_init(x25_init);
diff -puN net/xfrm/xfrm_algo.c~linus net/xfrm/xfrm_algo.c
--- 25/net/xfrm/xfrm_algo.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/xfrm/xfrm_algo.c	2004-01-19 22:17:25.000000000 -0800
@@ -85,7 +85,7 @@ static struct xfrm_algo_desc aalg_list[]
 
 	.uinfo = {
 		.auth = {
-			.icv_truncbits = 128,
+			.icv_truncbits = 96,
 			.icv_fullbits = 256,
 		}
 	},
diff -puN net/xfrm/xfrm_policy.c~linus net/xfrm/xfrm_policy.c
--- 25/net/xfrm/xfrm_policy.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/xfrm/xfrm_policy.c	2004-01-19 22:17:25.000000000 -0800
@@ -775,33 +775,32 @@ restart:
 
 		if (unlikely(nx<0)) {
 			err = nx;
-			if (err == -EAGAIN) {
-				struct task_struct *tsk = current;
-				DECLARE_WAITQUEUE(wait, tsk);
-				if (!flags)
-					goto error;
+			if (err == -EAGAIN && !flags) {
+				DECLARE_WAITQUEUE(wait, current);
 
-				__set_task_state(tsk, TASK_INTERRUPTIBLE);
 				add_wait_queue(&km_waitq, &wait);
-				err = xfrm_tmpl_resolve(policy, fl, xfrm, family);
-				if (err == -EAGAIN)
-					schedule();
-				__set_task_state(tsk, TASK_RUNNING);
+				set_current_state(TASK_INTERRUPTIBLE);
+				schedule();
+				set_current_state(TASK_RUNNING);
 				remove_wait_queue(&km_waitq, &wait);
 
-				if (err == -EAGAIN && signal_pending(current)) {
+				nx = xfrm_tmpl_resolve(policy, fl, xfrm, family);
+
+				if (nx == -EAGAIN && signal_pending(current)) {
 					err = -ERESTART;
 					goto error;
 				}
-				if (err == -EAGAIN ||
+				if (nx == -EAGAIN ||
 				    genid != atomic_read(&flow_cache_genid)) {
 					xfrm_pol_put(policy);
 					goto restart;
 				}
+				err = nx;
 			}
-			if (err)
+			if (err < 0)
 				goto error;
-		} else if (nx == 0) {
+		}
+		if (nx == 0) {
 			/* Flow passes not transformed. */
 			xfrm_pol_put(policy);
 			return 0;
diff -puN net/xfrm/xfrm_user.c~linus net/xfrm/xfrm_user.c
--- 25/net/xfrm/xfrm_user.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/net/xfrm/xfrm_user.c	2004-01-19 22:17:25.000000000 -0800
@@ -241,6 +241,7 @@ static struct xfrm_state *xfrm_state_con
 	return x;
 
 error:
+	x->km.state = XFRM_STATE_DEAD;
 	xfrm_state_put(x);
 error_no_put:
 	*errp = err;
diff -puN scripts/kconfig/mconf.c~linus scripts/kconfig/mconf.c
--- 25/scripts/kconfig/mconf.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/scripts/kconfig/mconf.c	2004-01-19 22:17:25.000000000 -0800
@@ -800,7 +800,6 @@ int main(int ac, char **av)
 		fprintf(stderr, "\n\n"
 			"Your kernel configuration changes were NOT saved."
 			"\n\n");
-		return 1;
 	}
 
 	return 0;
diff -puN scripts/modpost.c~linus scripts/modpost.c
--- 25/scripts/modpost.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/scripts/modpost.c	2004-01-19 22:17:25.000000000 -0800
@@ -446,6 +446,7 @@ add_versions(struct buffer *b, struct mo
 
 	buf_printf(b, "\n");
 	buf_printf(b, "static const struct modversion_info ____versions[]\n");
+	buf_printf(b, "__attribute_used__\n");
 	buf_printf(b, "__attribute__((section(\"__versions\"))) = {\n");
 
 	for (s = mod->unres; s; s = s->next) {
diff -puN security/dummy.c~linus security/dummy.c
--- 25/security/dummy.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/security/dummy.c	2004-01-19 22:17:25.000000000 -0800
@@ -793,6 +793,21 @@ static int dummy_socket_sock_rcv_skb (st
 {
 	return 0;
 }
+
+static int dummy_socket_getpeersec(struct socket *sock, char __user *optval,
+				   int __user *optlen, unsigned len)
+{
+	return -ENOPROTOOPT;
+}
+
+static inline int dummy_sk_alloc_security (struct sock *sk, int family, int priority)
+{
+	return 0;
+}
+
+static inline void dummy_sk_free_security (struct sock *sk)
+{
+}
 #endif	/* CONFIG_SECURITY_NETWORK */
 
 static int dummy_register_security (const char *name, struct security_operations *ops)
@@ -969,6 +984,9 @@ void security_fixup_ops (struct security
 	set_to_dummy_if_null(ops, socket_getsockopt);
 	set_to_dummy_if_null(ops, socket_shutdown);
 	set_to_dummy_if_null(ops, socket_sock_rcv_skb);
+	set_to_dummy_if_null(ops, socket_getpeersec);
+	set_to_dummy_if_null(ops, sk_alloc_security);
+	set_to_dummy_if_null(ops, sk_free_security);
 #endif	/* CONFIG_SECURITY_NETWORK */
 }
 
diff -puN security/Makefile~linus security/Makefile
--- 25/security/Makefile~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/security/Makefile	2004-01-19 22:17:25.000000000 -0800
@@ -12,8 +12,6 @@ endif
 # Object file lists
 obj-$(CONFIG_SECURITY)			+= security.o dummy.o
 # Must precede capability.o in order to stack properly.
-ifeq ($(CONFIG_SECURITY_SELINUX),y)
-	obj-$(CONFIG_SECURITY_SELINUX)	+= selinux/built-in.o
-endif
+obj-$(CONFIG_SECURITY_SELINUX)		+= selinux/built-in.o
 obj-$(CONFIG_SECURITY_CAPABILITIES)	+= commoncap.o capability.o
 obj-$(CONFIG_SECURITY_ROOTPLUG)		+= commoncap.o root_plug.o
diff -puN security/selinux/avc.c~linus security/selinux/avc.c
--- 25/security/selinux/avc.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/security/selinux/avc.c	2004-01-19 22:17:25.000000000 -0800
@@ -22,8 +22,6 @@
 #include <linux/un.h>
 #include <net/af_unix.h>
 #include <linux/ip.h>
-#include <linux/udp.h>
-#include <linux/tcp.h>
 #include "avc.h"
 #include "avc_ss.h"
 #include "class_to_string.h"
@@ -575,17 +573,26 @@ void avc_audit(u32 ssid, u32 tsid,
 			break;
 		case AVC_AUDIT_DATA_FS:
 			if (a->u.fs.dentry) {
+				struct dentry *dentry = a->u.fs.dentry;
 				if (a->u.fs.mnt) {
-					p = d_path(a->u.fs.dentry,
+					p = d_path(dentry,
 						   a->u.fs.mnt,
 						   avc_audit_buffer,
 						   PAGE_SIZE);
 					if (p)
 						printk(" path=%s", p);
+				} else {
+					printk(" name=%s", dentry->d_name.name);
 				}
-				inode = a->u.fs.dentry->d_inode;
+				inode = dentry->d_inode;
 			} else if (a->u.fs.inode) {
+				struct dentry *dentry;
 				inode = a->u.fs.inode;
+				dentry = d_find_alias(inode);
+				if (dentry) {
+					printk(" name=%s", dentry->d_name.name);
+					dput(dentry);
+				}
 			}
 			if (inode)
 				printk(" dev=%s ino=%ld",
@@ -631,41 +638,12 @@ void avc_audit(u32 ssid, u32 tsid,
 					break;
 				}
 			}
-			if (a->u.net.daddr) {
-				printk(" daddr=%d.%d.%d.%d",
-				       NIPQUAD(a->u.net.daddr));
-				if (a->u.net.port)
-					printk(" dest=%d", a->u.net.port);
-			} else if (a->u.net.port)
-				printk(" port=%d", a->u.net.port);
-			if (a->u.net.skb) {
-				struct sk_buff *skb = a->u.net.skb;
-
-				if ((skb->protocol == htons(ETH_P_IP)) &&
-				     skb->nh.iph) {
-					u16 source = 0, dest = 0;
-					u8  protocol = skb->nh.iph->protocol;
-
-
-					if (protocol == IPPROTO_TCP &&
-					    skb->h.th) {
-						source = skb->h.th->source;
-						dest = skb->h.th->dest;
-					}
-					if (protocol == IPPROTO_UDP &&
-					    skb->h.uh) {
-						source = skb->h.uh->source;
-						dest = skb->h.uh->dest;
-					}
+			
+			avc_print_ipv4_addr(a->u.net.saddr, a->u.net.sport,
+			                    "saddr", "src");
+			avc_print_ipv4_addr(a->u.net.daddr, a->u.net.dport,
+			                    "daddr", "dest");
 
-					avc_print_ipv4_addr(skb->nh.iph->saddr,
-					                    source,
-					                    "saddr", "source");
-					avc_print_ipv4_addr(skb->nh.iph->daddr,
-					                    dest,
-					                    "daddr", "dest");
-				}
-			}
 			if (a->u.net.netif)
 				printk(" netif=%s", a->u.net.netif);
 			break;
diff -puN security/selinux/hooks.c~linus security/selinux/hooks.c
--- 25/security/selinux/hooks.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/security/selinux/hooks.c	2004-01-19 22:17:25.000000000 -0800
@@ -44,6 +44,7 @@
 #include <linux/ext2_fs.h>
 #include <linux/proc_fs.h>
 #include <linux/kd.h>
+#include <linux/netfilter_ipv4.h>
 #include <net/icmp.h>
 #include <net/ip.h>		/* for sysctl_local_port_range[] */
 #include <net/tcp.h>		/* struct or_callable used in sock_rcv_skb */
@@ -55,12 +56,14 @@
 #include <linux/netdevice.h>	/* for network interface checks */
 #include <linux/netlink.h>
 #include <linux/tcp.h>
+#include <linux/udp.h>
 #include <linux/quota.h>
 #include <linux/un.h>		/* for Unix socket types */
 #include <net/af_unix.h>	/* for Unix socket types */
 
 #include "avc.h"
 #include "objsec.h"
+#include "netif.h"
 
 #ifdef CONFIG_SECURITY_SELINUX_DEVELOP
 int selinux_enforcing = 0;
@@ -242,6 +245,39 @@ static void superblock_free_security(str
 	kfree(sbsec);
 }
 
+#ifdef CONFIG_SECURITY_NETWORK
+static int sk_alloc_security(struct sock *sk, int family, int priority)
+{
+	struct sk_security_struct *ssec;
+
+	if (family != PF_UNIX)
+		return 0;
+
+	ssec = kmalloc(sizeof(*ssec), priority);
+	if (!ssec)
+		return -ENOMEM;
+
+	memset(ssec, 0, sizeof(*ssec));
+	ssec->magic = SELINUX_MAGIC;
+	ssec->sk = sk;
+	ssec->peer_sid = SECINITSID_UNLABELED;
+	sk->sk_security = ssec;
+
+	return 0;
+}
+
+static void sk_free_security(struct sock *sk)
+{
+	struct task_security_struct *ssec = sk->sk_security;
+
+	if (sk->sk_family != PF_UNIX || ssec->magic != SELINUX_MAGIC)
+		return;
+
+	sk->sk_security = NULL;
+	kfree(ssec);
+}
+#endif	/* CONFIG_SECURITY_NETWORK */
+
 /* The security server must be initialized before
    any labeling or access decisions can be provided. */
 extern int ss_initialized;
@@ -1516,6 +1552,7 @@ static void selinux_bprm_compute_creds(s
 	u32 sid;
 	struct av_decision avd;
 	struct itimerval itimer;
+	struct rlimit *rlim, *initrlim;
 	int rc, i;
 
 	secondary_ops->bprm_compute_creds(bprm);
@@ -1586,6 +1623,26 @@ static void selinux_bprm_compute_creds(s
 			spin_unlock_irq(&current->sighand->siglock);
 		}
 
+		/* Check whether the new SID can inherit resource limits
+		   from the old SID.  If not, reset all soft limits to
+		   the lower of the current task's hard limit and the init
+		   task's soft limit.  Note that the setting of hard limits 
+		   (even to lower them) can be controlled by the setrlimit 
+		   check. The inclusion of the init task's soft limit into
+	           the computation is to avoid resetting soft limits higher
+		   than the default soft limit for cases where the default
+		   is lower than the hard limit, e.g. RLIMIT_CORE or 
+		   RLIMIT_STACK.*/
+		rc = avc_has_perm(tsec->osid, tsec->sid, SECCLASS_PROCESS,
+				  PROCESS__RLIMITINH, NULL, NULL);
+		if (rc) {
+			for (i = 0; i < RLIM_NLIMITS; i++) {
+				rlim = current->rlim + i;
+				initrlim = init_task.rlim+i;
+				rlim->rlim_cur = min(rlim->rlim_max,initrlim->rlim_cur);
+			}
+		}
+
 		/* Wake up the parent if it is waiting so that it can
 		   recheck wait permission to the new task SID. */
 		wake_up_interruptible(&current->parent->wait_chldexit);
@@ -2222,10 +2279,15 @@ static int selinux_task_setnice(struct t
 
 static int selinux_task_setrlimit(unsigned int resource, struct rlimit *new_rlim)
 {
-	/* SELinux does not currently provide a process
-	   resource limit policy based on security contexts.
-	   It does control the use of the CAP_SYS_RESOURCE capability
-	   using the capable hook. */
+	struct rlimit *old_rlim = current->rlim + resource;
+
+	/* Control the ability to change the hard limit (whether
+	   lowering or raising it), so that the hard limit can
+	   later be used as a safe reset point for the soft limit
+	   upon context transitions. See selinux_bprm_compute_creds. */
+	if (old_rlim->rlim_max != new_rlim->rlim_max)
+		return task_has_perm(current, current, PROCESS__SETRLIMIT);
+
 	return 0;
 }
 
@@ -2311,6 +2373,69 @@ static void selinux_task_to_inode(struct
 
 #ifdef CONFIG_SECURITY_NETWORK
 
+static void selinux_parse_skb_ipv4(struct sk_buff *skb, struct avc_audit_data *ad)
+{
+	int dlen, ihlen;
+	struct iphdr *iph;
+
+	if (skb->len < sizeof(struct iphdr))
+		goto out;
+	
+	iph = skb->nh.iph;
+	ihlen = iph->ihl * 4;
+	if (ihlen < sizeof(struct iphdr))
+		goto out;
+
+	dlen = skb->len - ihlen;
+	ad->u.net.saddr = iph->saddr;
+	ad->u.net.daddr = iph->daddr;
+
+	switch (iph->protocol) {
+        case IPPROTO_TCP: {
+        	int offset;
+        	struct tcphdr tcph;
+
+        	if (ntohs(iph->frag_off) & IP_OFFSET)
+        		break;
+        		
+		if (dlen < sizeof(tcph))
+			break;
+
+		offset = skb->nh.raw - skb->data + ihlen;
+		if (skb_copy_bits(skb, offset, &tcph, sizeof(tcph)) < 0)
+			break;
+
+		ad->u.net.sport = tcph.source;
+		ad->u.net.dport = tcph.dest;
+		break;
+        }
+        
+        case IPPROTO_UDP: {
+        	int offset;
+        	struct udphdr udph;
+        	
+        	if (ntohs(iph->frag_off) & IP_OFFSET)
+        		break;
+        		
+        	if (dlen < sizeof(udph))
+        		break;
+
+		offset = skb->nh.raw - skb->data + ihlen;
+        	if (skb_copy_bits(skb, offset, &udph, sizeof(udph)) < 0)
+        		break;	
+
+        	ad->u.net.sport = udph.source;
+        	ad->u.net.dport = udph.dest;
+        	break;
+        }
+
+        default:
+        	break;
+        }
+out:
+	return;
+}
+
 /* socket security operations */
 static int socket_has_perm(struct task_struct *task, struct socket *sock,
 			   u32 perms)
@@ -2375,7 +2500,7 @@ static int selinux_socket_bind(struct so
 
 	err = socket_has_perm(current, sock, SOCKET__BIND);
 	if (err)
-		return err;
+		goto out;
 
 	/*
 	 * If PF_INET, check name_bind permission for the port.
@@ -2387,7 +2512,7 @@ static int selinux_socket_bind(struct so
 		struct sockaddr_in *addr = (struct sockaddr_in *)address;
 		unsigned short snum = ntohs(addr->sin_port);
 		struct sock *sk = sock->sk;
-		u32 sid;
+		u32 sid, node_perm;
 
 		tsec = current->security;
 		isec = SOCK_INODE(sock)->i_security;
@@ -2397,81 +2522,64 @@ static int selinux_socket_bind(struct so
 			err = security_port_sid(sk->sk_family, sk->sk_type,
 						sk->sk_protocol, snum, &sid);
 			if (err)
-				return err;
+				goto out;
 			AVC_AUDIT_DATA_INIT(&ad,NET);
-			ad.u.net.port = snum;
+			ad.u.net.sport = htons(snum);
 			err = avc_has_perm(isec->sid, sid,
 					   isec->sclass,
 					   SOCKET__NAME_BIND, NULL, &ad);
 			if (err)
-				return err;
+				goto out;
+		}
+		
+		switch(sk->sk_protocol) {
+		case IPPROTO_TCP:
+			node_perm = TCP_SOCKET__NODE_BIND;
+			break;
+			
+		case IPPROTO_UDP:
+			node_perm = UDP_SOCKET__NODE_BIND;
+			break;
+			
+		default:
+			node_perm = RAWIP_SOCKET__NODE_BIND;
+			break;
 		}
+		
+		err = security_node_sid(PF_INET, &addr->sin_addr.s_addr,
+		                        sizeof(addr->sin_addr.s_addr), &sid);
+		if (err)
+			goto out;
+		
+		AVC_AUDIT_DATA_INIT(&ad,NET);
+		ad.u.net.sport = htons(snum);
+		ad.u.net.saddr = addr->sin_addr.s_addr;
+		err = avc_has_perm(isec->sid, sid,
+		                   isec->sclass, node_perm, NULL, &ad);
+		if (err)
+			goto out;
 	}
-
-	return 0;
+out:
+	return err;
 }
 
 static int selinux_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen)
 {
-	int err;
-	struct sock *sk = sock->sk;
-	struct avc_audit_data ad;
-	struct task_security_struct *tsec;
-	struct inode_security_struct *isec;
-
-	isec = SOCK_INODE(sock)->i_security;
-
-	tsec = current->security;
-
-	AVC_AUDIT_DATA_INIT(&ad, NET);
-	ad.u.net.sk = sk;
-	err = avc_has_perm(tsec->sid, isec->sid, isec->sclass,
-			   SOCKET__CONNECT, &isec->avcr, &ad);
-	if (err)
-		return err;
-
-	return 0;
+	return socket_has_perm(current, sock, SOCKET__CONNECT);
 }
 
 static int selinux_socket_listen(struct socket *sock, int backlog)
 {
-	int err;
-	struct task_security_struct *tsec;
-	struct inode_security_struct *isec;
-	struct avc_audit_data ad;
-
-	tsec = current->security;
-
-	isec = SOCK_INODE(sock)->i_security;
-
-	AVC_AUDIT_DATA_INIT(&ad, NET);
-	ad.u.net.sk = sock->sk;
-
-	err = avc_has_perm(tsec->sid, isec->sid, isec->sclass,
-			   SOCKET__LISTEN, &isec->avcr, &ad);
-	if (err)
-		return err;
-
-	return 0;
+	return socket_has_perm(current, sock, SOCKET__LISTEN);
 }
 
 static int selinux_socket_accept(struct socket *sock, struct socket *newsock)
 {
 	int err;
-	struct task_security_struct *tsec;
 	struct inode_security_struct *isec;
 	struct inode_security_struct *newisec;
-	struct avc_audit_data ad;
-
-	tsec = current->security;
 
-	isec = SOCK_INODE(sock)->i_security;
-
-	AVC_AUDIT_DATA_INIT(&ad, NET);
-	ad.u.net.sk = sock->sk;
-
-	err = avc_has_perm(tsec->sid, isec->sid, isec->sclass,
-			   SOCKET__ACCEPT, &isec->avcr, &ad);
+	err = socket_has_perm(current, sock, SOCKET__ACCEPT);
 	if (err)
 		return err;
 
@@ -2480,6 +2588,7 @@ static int selinux_socket_accept(struct 
 		return err;
 	newisec = SOCK_INODE(newsock)->i_security;
 
+	isec = SOCK_INODE(sock)->i_security;
 	newisec->sclass = isec->sclass;
 	newisec->sid = isec->sid;
 
@@ -2489,87 +2598,23 @@ static int selinux_socket_accept(struct 
 static int selinux_socket_sendmsg(struct socket *sock, struct msghdr *msg,
  				  int size)
 {
-	struct task_security_struct *tsec;
-	struct inode_security_struct *isec;
-	struct avc_audit_data ad;
-	struct sock *sk;
-	int err;
-
-	isec = SOCK_INODE(sock)->i_security;
-
-	tsec = current->security;
-
-	sk = sock->sk;
-
-	AVC_AUDIT_DATA_INIT(&ad, NET);
-	ad.u.net.sk = sk;
-	err = avc_has_perm(tsec->sid, isec->sid, isec->sclass,
-			   SOCKET__WRITE, &isec->avcr, &ad);
-	if (err)
-		return err;
-
-	return 0;
+	return socket_has_perm(current, sock, SOCKET__WRITE);
 }
 
 static int selinux_socket_recvmsg(struct socket *sock, struct msghdr *msg,
 				  int size, int flags)
 {
-	struct inode_security_struct *isec;
-	struct task_security_struct *tsec;
-	struct avc_audit_data ad;
-	int err;
-
-	isec = SOCK_INODE(sock)->i_security;
-	tsec = current->security;
-
-	AVC_AUDIT_DATA_INIT(&ad,NET);
-	ad.u.net.sk = sock->sk;
-	err = avc_has_perm(tsec->sid, isec->sid, isec->sclass,
-			   SOCKET__READ, &isec->avcr, &ad);
-	if (err)
-		return err;
-
-	return 0;
+	return socket_has_perm(current, sock, SOCKET__READ);
 }
 
 static int selinux_socket_getsockname(struct socket *sock)
 {
-	struct inode_security_struct *isec;
-	struct task_security_struct *tsec;
-	struct avc_audit_data ad;
-	int err;
-
-	tsec = current->security;
-	isec = SOCK_INODE(sock)->i_security;
-
-	AVC_AUDIT_DATA_INIT(&ad,NET);
-	ad.u.net.sk = sock->sk;
-	err = avc_has_perm(tsec->sid, isec->sid, isec->sclass,
-			   SOCKET__GETATTR, &isec->avcr, &ad);
-	if (err)
-		return err;
-
-	return 0;
+	return socket_has_perm(current, sock, SOCKET__GETATTR);
 }
 
 static int selinux_socket_getpeername(struct socket *sock)
 {
-	struct inode_security_struct *isec;
-	struct task_security_struct *tsec;
-	struct avc_audit_data ad;
-	int err;
-
-	tsec = current->security;
-	isec = SOCK_INODE(sock)->i_security;
-
-	AVC_AUDIT_DATA_INIT(&ad,NET);
-	ad.u.net.sk = sock->sk;
-	err = avc_has_perm(tsec->sid, isec->sid, isec->sclass,
-			   SOCKET__GETATTR, &isec->avcr, &ad);
-	if (err)
-		return err;
-
-	return 0;
+	return socket_has_perm(current, sock, SOCKET__GETATTR);
 }
 
 static int selinux_socket_setsockopt(struct socket *sock,int level,int optname)
@@ -2592,6 +2637,7 @@ static int selinux_socket_unix_stream_co
 					      struct socket *other,
 					      struct sock *newsk)
 {
+	struct sk_security_struct *ssec;
 	struct inode_security_struct *isec;
 	struct inode_security_struct *other_isec;
 	struct avc_audit_data ad;
@@ -2610,6 +2656,14 @@ static int selinux_socket_unix_stream_co
 	if (err)
 		return err;
 
+	/* connecting socket */
+	ssec = sock->sk->sk_security;
+	ssec->peer_sid = other_isec->sid;
+	
+	/* server child socket */
+	ssec = newsk->sk_security;
+	ssec->peer_sid = isec->sid;
+	
 	return 0;
 }
 
@@ -2637,7 +2691,253 @@ static int selinux_socket_unix_may_send(
 	return 0;
 }
 
-#endif
+static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
+{
+	int err = 0;
+	u32 netif_perm, node_perm, node_sid, recv_perm = 0;
+	struct socket *sock;
+	struct inode *inode;
+	struct net_device *dev;
+	struct iphdr *iph;
+	struct sel_netif *netif;
+	struct netif_security_struct *nsec;
+	struct inode_security_struct *isec;
+	struct avc_audit_data ad;
+
+	/* Only IPv4 is supported here at this stage */
+	if (sk->sk_family != PF_INET)
+		goto out;
+
+	sock = sk->sk_socket;
+	
+	/* TCP control messages don't always have a socket. */
+	if (!sock)
+		goto out;
+
+	inode = SOCK_INODE(sock);
+	if (!inode)
+		goto out;
+
+	dev = skb->dev;
+	if (!dev)
+		goto out;
+
+	netif = sel_netif_lookup(dev);
+	if (IS_ERR(netif)) {
+		err = PTR_ERR(netif);
+		goto out;
+	}
+	
+	nsec = &netif->nsec;
+	isec = inode->i_security;
+
+	switch (isec->sclass) {
+	case SECCLASS_UDP_SOCKET:
+		netif_perm = NETIF__UDP_RECV;
+		node_perm = NODE__UDP_RECV;
+		recv_perm = UDP_SOCKET__RECV_MSG;
+		break;
+	
+	case SECCLASS_TCP_SOCKET:
+		netif_perm = NETIF__TCP_RECV;
+		node_perm = NODE__TCP_RECV;
+		recv_perm = TCP_SOCKET__RECV_MSG;
+		break;
+	
+	default:
+		netif_perm = NETIF__RAWIP_RECV;
+		node_perm = NODE__RAWIP_RECV;
+		break;
+	}
+
+	AVC_AUDIT_DATA_INIT(&ad, NET);
+	ad.u.net.netif = dev->name;
+	selinux_parse_skb_ipv4(skb, &ad);
+
+	err = avc_has_perm(isec->sid, nsec->if_sid, SECCLASS_NETIF,
+	                   netif_perm, &nsec->avcr, &ad);
+	sel_netif_put(netif);
+	if (err)
+		goto out;
+	
+	/* Fixme: this lookup is inefficient */
+	iph = skb->nh.iph;
+	err = security_node_sid(PF_INET, &iph->saddr, sizeof(iph->saddr), &node_sid);
+	if (err)
+		goto out;
+	
+	err = avc_has_perm(isec->sid, node_sid, SECCLASS_NODE, node_perm, NULL, &ad);
+
+	if (recv_perm) {
+		u32 port_sid;
+
+		/* Fixme: make this more efficient */
+		err = security_port_sid(sk->sk_family, sk->sk_type,
+		                        sk->sk_protocol, ntohs(ad.u.net.sport),
+		                        &port_sid);
+		if (err)
+			goto out;
+
+		err = avc_has_perm(isec->sid, port_sid, isec->sclass,
+		                   recv_perm, NULL, &ad);
+	}
+
+out:	
+	return err;
+}
+
+static int selinux_socket_getpeersec(struct socket *sock, char __user *optval,
+				     int __user *optlen, unsigned len)
+{
+	int err = 0;
+	char *scontext;
+	u32 scontext_len;
+	struct sk_security_struct *ssec;
+	struct inode_security_struct *isec;
+
+	isec = SOCK_INODE(sock)->i_security;
+	if (isec->sclass != SECCLASS_UNIX_STREAM_SOCKET) {
+		err = -ENOPROTOOPT;
+		goto out;
+	}
+
+	ssec = sock->sk->sk_security;
+	
+	err = security_sid_to_context(ssec->peer_sid, &scontext, &scontext_len);
+	if (err)
+		goto out;
+
+	if (scontext_len > len) {
+		err = -ERANGE;
+		goto out_len;
+	}
+
+	if (copy_to_user(optval, scontext, scontext_len))
+		err = -EFAULT;
+
+out_len:
+	if (put_user(scontext_len, optlen))
+		err = -EFAULT;
+
+	kfree(scontext);
+out:	
+	return err;
+}
+
+static int selinux_sk_alloc_security(struct sock *sk, int family, int priority)
+{
+	return sk_alloc_security(sk, family, priority);
+}
+
+static void selinux_sk_free_security(struct sock *sk)
+{
+	sk_free_security(sk);
+}
+
+#ifdef CONFIG_NETFILTER
+static unsigned int selinux_ip_postroute_last(unsigned int hooknum,
+                                              struct sk_buff **pskb,
+                                              const struct net_device *in,
+                                              const struct net_device *out,
+                                              int (*okfn)(struct sk_buff *))
+{
+	int err = NF_ACCEPT;
+	u32 netif_perm, node_perm, node_sid, send_perm = 0;
+	struct sock *sk;
+	struct socket *sock;
+	struct inode *inode;
+	struct iphdr *iph;
+	struct sel_netif *netif;
+	struct sk_buff *skb = *pskb;
+	struct netif_security_struct *nsec;
+	struct inode_security_struct *isec;
+	struct avc_audit_data ad;
+	struct net_device *dev = (struct net_device *)out;
+	
+	sk = skb->sk;
+	if (!sk)
+		goto out;
+		
+	sock = sk->sk_socket;
+	if (!sock)
+		goto out;
+		
+	inode = SOCK_INODE(sock);
+	if (!inode)
+		goto out;
+
+	netif = sel_netif_lookup(dev);
+	if (IS_ERR(netif)) {
+		err = NF_DROP;
+		goto out;
+	}
+	
+	nsec = &netif->nsec;
+	isec = inode->i_security;
+	
+	switch (isec->sclass) {
+	case SECCLASS_UDP_SOCKET:
+		netif_perm = NETIF__UDP_SEND;
+		node_perm = NODE__UDP_SEND;
+		send_perm = UDP_SOCKET__SEND_MSG;
+		break;
+	
+	case SECCLASS_TCP_SOCKET:
+		netif_perm = NETIF__TCP_SEND;
+		node_perm = NODE__TCP_SEND;
+		send_perm = TCP_SOCKET__SEND_MSG;
+		break;
+	
+	default:
+		netif_perm = NETIF__RAWIP_SEND;
+		node_perm = NODE__RAWIP_SEND;
+		break;
+	}
+
+	AVC_AUDIT_DATA_INIT(&ad, NET);
+	ad.u.net.netif = dev->name;
+	selinux_parse_skb_ipv4(skb, &ad);
+
+	err = avc_has_perm(isec->sid, nsec->if_sid, SECCLASS_NETIF,
+	                   netif_perm, &nsec->avcr, &ad) ? NF_DROP : NF_ACCEPT;
+	sel_netif_put(netif);
+	if (err != NF_ACCEPT)
+		goto out;
+		
+	/* Fixme: this lookup is inefficient */
+	iph = skb->nh.iph;
+	err = security_node_sid(PF_INET, &iph->daddr, sizeof(iph->daddr), &node_sid);
+	if (err)
+		goto out;
+	
+	err = avc_has_perm(isec->sid, node_sid, SECCLASS_NODE,
+	                   node_perm, NULL, &ad) ? NF_DROP : NF_ACCEPT;
+	if (err != NF_ACCEPT)
+		goto out;
+
+	if (send_perm) {
+		u32 port_sid;
+		
+		/* Fixme: make this more efficient */
+		err = security_port_sid(sk->sk_family,
+		                        sk->sk_type,
+		                        sk->sk_protocol,
+		                        ntohs(ad.u.net.dport),
+		                        &port_sid) ? NF_DROP : NF_ACCEPT;
+		if (err != NF_ACCEPT)
+			goto out;
+
+		err = avc_has_perm(isec->sid, port_sid, isec->sclass,
+		                   send_perm, NULL, &ad) ? NF_DROP : NF_ACCEPT;
+	}
+
+out:
+	return err;
+}
+
+#endif	/* CONFIG_NETFILTER */
+
+#endif	/* CONFIG_SECURITY_NETWORK */
 
 static int ipc_alloc_security(struct task_struct *task,
 			      struct kern_ipc_perm *perm,
@@ -3372,6 +3672,10 @@ struct security_operations selinux_ops =
 	.socket_getsockopt =		selinux_socket_getsockopt,
 	.socket_setsockopt =		selinux_socket_setsockopt,
 	.socket_shutdown =		selinux_socket_shutdown,
+	.socket_sock_rcv_skb =		selinux_socket_sock_rcv_skb,
+	.socket_getpeersec =		selinux_socket_getpeersec,
+	.sk_alloc_security =		selinux_sk_alloc_security,
+	.sk_free_security =		selinux_sk_free_security,
 #endif
 };
 
@@ -3441,3 +3745,33 @@ next_sb:
    all processes and objects when they are created. */
 security_initcall(selinux_init);
 
+#if defined(CONFIG_SECURITY_NETWORK) && defined(CONFIG_NETFILTER)
+
+static struct nf_hook_ops selinux_ip_ops[] = {
+	{ .hook =	selinux_ip_postroute_last,
+	  .owner =	THIS_MODULE,
+	  .pf =		PF_INET, 
+	  .hooknum =	NF_IP_POST_ROUTING, 
+	  .priority =	NF_IP_PRI_SELINUX_LAST, },
+};
+
+static int __init selinux_nf_ip_init(void)
+{
+	int err = 0;
+
+	if (!selinux_enabled)
+		goto out;
+		
+	printk(KERN_INFO "SELinux:  Registering netfilter hooks\n");
+	
+	err = nf_register_hook(&selinux_ip_ops[0]);
+	if (err)
+		panic("SELinux: nf_register_hook 0 error %d\n", err);
+
+out:
+	return err;
+}
+
+__initcall(selinux_nf_ip_init);
+
+#endif /* CONFIG_SECURITY_NETWORK && CONFIG_NETFILTER */
diff -puN security/selinux/include/avc.h~linus security/selinux/include/avc.h
--- 25/security/selinux/include/avc.h~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/security/selinux/include/avc.h	2004-01-19 22:17:25.000000000 -0800
@@ -63,10 +63,11 @@ struct avc_audit_data {
 		} fs;
 		struct {
 			char *netif;
-			struct sk_buff *skb;
 			struct sock *sk;
-			u16 port;
+			u16 dport;
+			u16 sport;
 			u32 daddr;
+			u32 saddr;
 		} net;
 		int cap;
 		int ipc_id;
diff -puN security/selinux/include/av_permissions.h~linus security/selinux/include/av_permissions.h
--- 25/security/selinux/include/av_permissions.h~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/security/selinux/include/av_permissions.h	2004-01-19 22:17:25.000000000 -0800
@@ -249,6 +249,7 @@
 #define TCP_SOCKET__CONNECTTO                     0x00400000UL
 #define TCP_SOCKET__NEWCONN                       0x00800000UL
 #define TCP_SOCKET__ACCEPTFROM                    0x01000000UL
+#define TCP_SOCKET__NODE_BIND                     0x02000000UL
 
 #define UDP_SOCKET__RELABELTO                     0x00000100UL
 #define UDP_SOCKET__RECV_MSG                      0x00080000UL
@@ -272,6 +273,7 @@
 #define UDP_SOCKET__SEND_MSG                      0x00100000UL
 #define UDP_SOCKET__RECVFROM                      0x00020000UL
 #define UDP_SOCKET__GETATTR                       0x00000010UL
+#define UDP_SOCKET__NODE_BIND                     0x00400000UL
 
 #define RAWIP_SOCKET__RELABELTO                   0x00000100UL
 #define RAWIP_SOCKET__RECV_MSG                    0x00080000UL
@@ -295,6 +297,7 @@
 #define RAWIP_SOCKET__SEND_MSG                    0x00100000UL
 #define RAWIP_SOCKET__RECVFROM                    0x00020000UL
 #define RAWIP_SOCKET__GETATTR                     0x00000010UL
+#define RAWIP_SOCKET__NODE_BIND                   0x00400000UL
 
 #define NODE__TCP_RECV                            0x00000001UL
 #define NODE__TCP_SEND                            0x00000002UL
@@ -451,6 +454,8 @@
 #define PROCESS__SETFSCREATE                      0x00040000UL
 #define PROCESS__NOATSECURE                       0x00080000UL
 #define PROCESS__SIGINH                           0x00100000UL
+#define PROCESS__SETRLIMIT                        0x00200000UL
+#define PROCESS__RLIMITINH                        0x00400000UL
 
 #define IPC__SETATTR                              0x00000008UL
 #define IPC__READ                                 0x00000010UL
diff -puN security/selinux/include/av_perm_to_string.h~linus security/selinux/include/av_perm_to_string.h
--- 25/security/selinux/include/av_perm_to_string.h~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/security/selinux/include/av_perm_to_string.h	2004-01-19 22:17:25.000000000 -0800
@@ -46,6 +46,9 @@ static struct av_perm_to_string av_perm_
    { SECCLASS_UNIX_STREAM_SOCKET, UNIX_STREAM_SOCKET__CONNECTTO, "connectto" },
    { SECCLASS_UNIX_STREAM_SOCKET, UNIX_STREAM_SOCKET__NEWCONN, "newconn" },
    { SECCLASS_UNIX_STREAM_SOCKET, UNIX_STREAM_SOCKET__ACCEPTFROM, "acceptfrom" },
+   { SECCLASS_TCP_SOCKET, TCP_SOCKET__NODE_BIND, "node_bind" },
+   { SECCLASS_UDP_SOCKET, UDP_SOCKET__NODE_BIND, "node_bind" },
+   { SECCLASS_RAWIP_SOCKET, RAWIP_SOCKET__NODE_BIND, "node_bind" },
    { SECCLASS_PROCESS, PROCESS__FORK, "fork" },
    { SECCLASS_PROCESS, PROCESS__TRANSITION, "transition" },
    { SECCLASS_PROCESS, PROCESS__SIGCHLD, "sigchld" },
@@ -67,6 +70,8 @@ static struct av_perm_to_string av_perm_
    { SECCLASS_PROCESS, PROCESS__SETFSCREATE, "setfscreate" },
    { SECCLASS_PROCESS, PROCESS__NOATSECURE, "noatsecure" },
    { SECCLASS_PROCESS, PROCESS__SIGINH, "siginh" },
+   { SECCLASS_PROCESS, PROCESS__SETRLIMIT, "setrlimit" },
+   { SECCLASS_PROCESS, PROCESS__RLIMITINH, "rlimitinh" },
    { SECCLASS_MSGQ, MSGQ__ENQUEUE, "enqueue" },
    { SECCLASS_MSG, MSG__SEND, "send" },
    { SECCLASS_MSG, MSG__RECEIVE, "receive" },
diff -puN /dev/null security/selinux/include/netif.h
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/security/selinux/include/netif.h	2004-01-19 22:17:25.000000000 -0800
@@ -0,0 +1,30 @@
+/*
+ * Network interface table.
+ *
+ * Network interfaces (devices) do not have a security field, so we
+ * maintain a table associating each interface with a SID.
+ *
+ * Author: James Morris <jmorris@redhat.com>
+ *
+ * Copyright (C) 2003 Red Hat, Inc., James Morris <jmorris@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
+ */
+#ifndef _SELINUX_NETIF_H_
+#define _SELINUX_NETIF_H_
+
+struct sel_netif
+{
+	struct list_head list;
+	atomic_t users;
+	struct netif_security_struct nsec;
+	struct rcu_head rcu_head;
+};
+
+struct sel_netif *sel_netif_lookup(struct net_device *dev);
+void sel_netif_put(struct sel_netif *netif);
+
+#endif	/* _SELINUX_NETIF_H_ */
+
diff -puN security/selinux/include/objsec.h~linus security/selinux/include/objsec.h
--- 25/security/selinux/include/objsec.h~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/security/selinux/include/objsec.h	2004-01-19 22:17:25.000000000 -0800
@@ -93,6 +93,19 @@ struct bprm_security_struct {
 	unsigned char set;
 };
 
+struct netif_security_struct {
+	struct net_device *dev;		/* back pointer */
+	u32 if_sid;			/* SID for this interface */
+	u32 msg_sid;			/* default SID for messages received on this interface */
+	struct avc_entry_ref avcr;	/* reference to permissions */
+};
+
+struct sk_security_struct {
+	unsigned long magic;		/* magic number for this module */
+	struct sock *sk;		/* back pointer to sk object */
+	u32 peer_sid;			/* SID of peer */
+};
+
 extern int inode_security_set_sid(struct inode *inode, u32 sid);
 
 #endif /* _SELINUX_OBJSEC_H_ */
diff -puN security/selinux/Makefile~linus security/selinux/Makefile
--- 25/security/selinux/Makefile~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/security/selinux/Makefile	2004-01-19 22:17:25.000000000 -0800
@@ -4,7 +4,9 @@
 
 obj-$(CONFIG_SECURITY_SELINUX) := selinux.o ss/
 
-selinux-objs := avc.o hooks.o selinuxfs.o
+selinux-y := avc.o hooks.o selinuxfs.o
+
+selinux-$(CONFIG_SECURITY_NETWORK) += netif.o
 
 EXTRA_CFLAGS += -Isecurity/selinux/include
 
diff -puN /dev/null security/selinux/netif.c
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ 25-akpm/security/selinux/netif.c	2004-01-19 22:17:25.000000000 -0800
@@ -0,0 +1,239 @@
+/*
+ * Network interface table.
+ *
+ * Network interfaces (devices) do not have a security field, so we
+ * maintain a table associating each interface with a SID.
+ *
+ * Author: James Morris <jmorris@redhat.com>
+ *
+ * Copyright (C) 2003 Red Hat, Inc., James Morris <jmorris@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
+ */
+#include <linux/types.h>
+#include <linux/stddef.h>
+#include <linux/kernel.h>
+#include <linux/list.h>
+#include <linux/notifier.h>
+#include <linux/netdevice.h>
+#include <linux/rcupdate.h>
+
+#include "security.h"
+#include "objsec.h"
+#include "netif.h"
+
+#define SEL_NETIF_HASH_SIZE	64
+#define SEL_NETIF_HASH_MAX	1024
+
+#undef DEBUG
+
+#ifdef DEBUG
+#define DEBUGP printk
+#else
+#define DEBUGP(format, args...)
+#endif
+
+static u32 sel_netif_total;
+static LIST_HEAD(sel_netif_list);
+static spinlock_t sel_netif_lock = SPIN_LOCK_UNLOCKED;
+static struct sel_netif sel_netif_hash[SEL_NETIF_HASH_SIZE];
+
+static inline u32 sel_netif_hasfn(struct net_device *dev)
+{
+	return (dev->ifindex & (SEL_NETIF_HASH_SIZE - 1));
+}
+
+/*
+ * All of the devices should normally fit in the hash, so we optimize
+ * for that case.
+ */
+static struct sel_netif *sel_netif_find(struct net_device *dev)
+{
+	struct list_head *pos;
+	int idx = sel_netif_hasfn(dev);
+
+	__list_for_each_rcu(pos, &sel_netif_hash[idx].list) {
+		struct sel_netif *netif = list_entry(pos,
+		                                     struct sel_netif, list);
+		if (likely(netif->nsec.dev == dev))
+			return netif;
+	}
+	return NULL;
+}
+
+static int sel_netif_insert(struct sel_netif *netif)
+{
+	int idx, ret = 0;
+	
+	if (sel_netif_total >= SEL_NETIF_HASH_MAX) {
+		ret = -ENOSPC;
+		goto out;
+	}
+	
+	idx = sel_netif_hasfn(netif->nsec.dev);
+	list_add_rcu(&netif->list, &sel_netif_hash[idx].list);
+	atomic_set(&netif->users, 1);
+	sel_netif_total++;
+out:
+	return ret;
+}
+
+struct sel_netif *sel_netif_lookup(struct net_device *dev)
+{
+	int ret;
+	struct sel_netif *netif, *new;
+	struct netif_security_struct *nsec;
+
+	rcu_read_lock();
+	netif = sel_netif_find(dev);
+	rcu_read_unlock();
+	
+	if (likely(netif != NULL))
+		goto out_hold;
+	
+	new = kmalloc(sizeof(*new), GFP_ATOMIC);
+	if (!new) {
+		netif = ERR_PTR(-ENOMEM);
+		goto out;
+	}
+	
+	memset(new, 0, sizeof(*new));
+	nsec = &new->nsec;
+
+	ret = security_netif_sid(dev->name, &nsec->if_sid, &nsec->msg_sid);
+	if (ret < 0) {
+		kfree(new);
+		netif = ERR_PTR(ret);
+		goto out;
+	}
+
+	nsec->dev = dev;
+	
+	spin_lock_bh(&sel_netif_lock);
+	
+	netif = sel_netif_find(dev);
+	if (netif) {
+		spin_unlock_bh(&sel_netif_lock);
+		kfree(new);
+		goto out_hold;
+	}
+	
+	sel_netif_insert(new);
+	spin_unlock_bh(&sel_netif_lock);
+	
+	netif = new;
+	
+	DEBUGP("new: ifindex=%u name=%s if_sid=%u msg_sid=%u\n", dev->ifindex, dev->name,
+	        nsec->if_sid, nsec->msg_sid);
+out_hold:
+	atomic_inc(&netif->users);
+out:
+	return netif;
+}
+
+static void sel_netif_free(void *p)
+{
+	struct sel_netif *netif = p;
+	
+	DEBUGP("%s: %s\n", __FUNCTION__, netif->nsec.dev->name);
+	kfree(netif);
+}
+
+static void sel_netif_destroy(struct sel_netif *netif)
+{
+	DEBUGP("%s: %s\n", __FUNCTION__, netif->nsec.dev->name);
+	
+	spin_lock_bh(&sel_netif_lock);
+	list_del_rcu(&netif->list);
+	sel_netif_total--;
+	spin_unlock_bh(&sel_netif_lock);
+
+	call_rcu(&netif->rcu_head, sel_netif_free, netif);
+}
+
+void sel_netif_put(struct sel_netif *netif)
+{
+	if (atomic_dec_and_test(&netif->users))
+		sel_netif_destroy(netif);
+}
+
+static void sel_netif_kill(struct net_device *dev)
+{
+	struct sel_netif *netif;
+	
+	rcu_read_lock();
+	netif = sel_netif_find(dev);
+	rcu_read_unlock();
+
+	/* Drop internal reference */
+	if (netif)
+		sel_netif_put(netif);
+}
+
+static void sel_netif_flush(void)
+{
+	int idx;
+
+	for (idx = 0; idx < SEL_NETIF_HASH_SIZE; idx++) {
+		struct list_head *pos;
+		
+		list_for_each_rcu(pos, &sel_netif_hash[idx].list) {
+			struct sel_netif *netif;
+			
+			netif = list_entry(pos, struct sel_netif, list);
+			if (netif)
+				sel_netif_put(netif);
+		}
+	}
+}
+
+static int sel_netif_avc_callback(u32 event, u32 ssid, u32 tsid,
+                                  u16 class, u32 perms, u32 *retained)
+{
+	if (event == AVC_CALLBACK_RESET) {
+		sel_netif_flush();
+		synchronize_net();
+	}
+	return 0;
+}
+
+static int sel_netif_netdev_notifier_handler(struct notifier_block *this,
+                                             unsigned long event, void *ptr)
+{
+	struct net_device *dev = ptr;
+
+	if (event == NETDEV_DOWN)
+		sel_netif_kill(dev);
+
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block sel_netif_netdev_notifier = {
+	.notifier_call = sel_netif_netdev_notifier_handler,
+};
+
+static __init int sel_netif_init(void)
+{
+	int i, err = 0;
+	
+	if (!selinux_enabled)
+		goto out;
+
+	for (i = 0; i < SEL_NETIF_HASH_SIZE; i++)
+		INIT_LIST_HEAD(&sel_netif_hash[i].list);
+
+	register_netdevice_notifier(&sel_netif_netdev_notifier);
+	
+	err = avc_add_callback(sel_netif_avc_callback, AVC_CALLBACK_RESET,
+	                       SECSID_NULL, SECSID_NULL, SECCLASS_NULL, 0);
+	if (err)
+		panic("avc_add_callback() failed, error %d\n", err);
+
+out:
+	return err;
+}
+
+__initcall(sel_netif_init);
+
diff -puN security/selinux/ss/Makefile~linus security/selinux/ss/Makefile
--- 25/security/selinux/ss/Makefile~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/security/selinux/ss/Makefile	2004-01-19 22:17:25.000000000 -0800
@@ -5,9 +5,7 @@
 EXTRA_CFLAGS += -Isecurity/selinux/include
 obj-y := ss.o
 
-ss-objs := ebitmap.o hashtab.o symtab.o sidtab.o avtab.o policydb.o services.o
+ss-y := ebitmap.o hashtab.o symtab.o sidtab.o avtab.o policydb.o services.o
 
-ifeq ($(CONFIG_SECURITY_SELINUX_MLS),y)
-ss-objs += mls.o
-endif
+ss-$(CONFIG_SECURITY_SELINUX_MLS) += mls.o
 
diff -puN sound/core/sound.c~linus sound/core/sound.c
--- 25/sound/core/sound.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/sound/core/sound.c	2004-01-19 22:17:25.000000000 -0800
@@ -38,9 +38,7 @@
 static int major = CONFIG_SND_MAJOR;
 int snd_major;
 static int cards_limit = SNDRV_CARDS;
-#ifdef CONFIG_DEVFS_FS
 static int device_mode = S_IFCHR | S_IRUGO | S_IWUGO;
-#endif
 
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("Advanced Linux Sound Architecture driver for soundcards.");
@@ -66,6 +64,7 @@ static struct list_head snd_minors_hash[
 
 static DECLARE_MUTEX(sound_mutex);
 
+extern struct class_simple *sound_class;
 #ifdef CONFIG_KMOD
 
 /**
@@ -203,6 +202,7 @@ int snd_register_device(int type, snd_ca
 {
 	int minor = snd_kernel_minor(type, card, dev);
 	snd_minor_t *preg;
+	struct device *device = NULL;
 
 	if (minor < 0)
 		return minor;
@@ -221,10 +221,14 @@ int snd_register_device(int type, snd_ca
 		return -EBUSY;
 	}
 	list_add_tail(&preg->list, &snd_minors_hash[SNDRV_MINOR_CARD(minor)]);
-#ifdef CONFIG_DEVFS_FS
-	if (strncmp(name, "controlC", 8))     /* created in sound.c */
+
+	if (strncmp(name, "controlC", 8)) {	/* created in sound.c */
 		devfs_mk_cdev(MKDEV(major, minor), S_IFCHR | device_mode, "snd/%s", name);
-#endif
+		if (card)
+			device = card->dev;
+		class_simple_device_add(sound_class, MKDEV(major, minor), device, name);
+	}
+
 	up(&sound_mutex);
 	return 0;
 }
@@ -252,10 +256,12 @@ int snd_unregister_device(int type, snd_
 		up(&sound_mutex);
 		return -EINVAL;
 	}
-#ifdef CONFIG_DEVFS_FS
-	if (strncmp(mptr->name, "controlC", 8))	/* created in sound.c */
+
+	if (strncmp(mptr->name, "controlC", 8)) {	/* created in sound.c */
 		devfs_remove("snd/%s", mptr->name);
-#endif
+		class_simple_device_remove(MKDEV(major, minor));
+	}
+
 	list_del(&mptr->list);
 	up(&sound_mutex);
 	kfree(mptr);
@@ -322,9 +328,7 @@ int __exit snd_minor_info_done(void)
 
 static int __init alsa_sound_init(void)
 {
-#ifdef CONFIG_DEVFS_FS
 	short controlnum;
-#endif
 #ifdef CONFIG_SND_OSSEMUL
 	int err;
 #endif
@@ -358,10 +362,10 @@ static int __init alsa_sound_init(void)
 #ifdef CONFIG_SND_OSSEMUL
 	snd_info_minor_register();
 #endif
-#ifdef CONFIG_DEVFS_FS
-	for (controlnum = 0; controlnum < cards_limit; controlnum++) 
+	for (controlnum = 0; controlnum < cards_limit; controlnum++) {
 		devfs_mk_cdev(MKDEV(major, controlnum<<5), S_IFCHR | device_mode, "snd/controlC%d", controlnum);
-#endif
+		class_simple_device_add(sound_class, MKDEV(major, controlnum<<5), NULL, "controlC%d", controlnum);
+	}
 #ifndef MODULE
 	printk(KERN_INFO "Advanced Linux Sound Architecture Driver Version " CONFIG_SND_VERSION CONFIG_SND_DATE ".\n");
 #endif
@@ -372,8 +376,10 @@ static void __exit alsa_sound_exit(void)
 {
 	short controlnum;
 
-	for (controlnum = 0; controlnum < cards_limit; controlnum++)
+	for (controlnum = 0; controlnum < cards_limit; controlnum++) {
 		devfs_remove("snd/controlC%d", controlnum);
+		class_simple_device_remove(MKDEV(major, controlnum<<5));
+	}
 
 #ifdef CONFIG_SND_OSSEMUL
 	snd_info_minor_unregister();
diff -puN sound/oss/dmabuf.c~linus sound/oss/dmabuf.c
--- 25/sound/oss/dmabuf.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/sound/oss/dmabuf.c	2004-01-19 22:17:25.000000000 -0800
@@ -587,7 +587,6 @@ int DMAbuf_getrdbuffer(int dev, char **b
 		spin_unlock_irqrestore(&dmap->lock,flags);
 		timeout = interruptible_sleep_on_timeout(&adev->in_sleeper,
 							 timeout);
-		spin_lock_irqsave(&dmap->lock,flags);
 		if (!timeout) {
 			/* FIXME: include device name */
 			err = -EIO;
@@ -595,6 +594,7 @@ int DMAbuf_getrdbuffer(int dev, char **b
 			dma_reset_input(dev);
 		} else
 			err = -EINTR;
+		spin_lock_irqsave(&dmap->lock,flags);
 	}
 	spin_unlock_irqrestore(&dmap->lock,flags);
 
diff -puN sound/oss/soundcard.c~linus sound/oss/soundcard.c
--- 25/sound/oss/soundcard.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/sound/oss/soundcard.c	2004-01-19 22:17:25.000000000 -0800
@@ -73,6 +73,7 @@ static char     dma_alloc_map[MAX_DMA_CH
 
 
 unsigned long seq_time = 0;	/* Time for /dev/sequencer */
+extern struct class_simple *sound_class;
 
 /*
  * Table for configurable mixer volume handling
@@ -569,6 +570,9 @@ static int __init oss_init(void)
 		devfs_mk_cdev(MKDEV(SOUND_MAJOR, dev_list[i].minor),
 				S_IFCHR | dev_list[i].mode,
 				"sound/%s", dev_list[i].name);
+		class_simple_device_add(sound_class, 
+					MKDEV(SOUND_MAJOR, dev_list[i].minor),
+					NULL, "%s", dev_list[i].name);
 
 		if (!dev_list[i].num)
 			continue;
@@ -578,6 +582,10 @@ static int __init oss_init(void)
 						dev_list[i].minor + (j*0x10)),
 					S_IFCHR | dev_list[i].mode,
 					"sound/%s%d", dev_list[i].name, j);
+			class_simple_device_add(sound_class,
+					MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)),
+					NULL,
+					"%s%d", dev_list[i].name, j);
 		}
 	}
 
@@ -593,10 +601,13 @@ static void __exit oss_cleanup(void)
 
 	for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) {
 		devfs_remove("sound/%s", dev_list[i].name);
+		class_simple_device_remove(MKDEV(SOUND_MAJOR, dev_list[i].minor));
 		if (!dev_list[i].num)
 			continue;
-		for (j = 1; j < *dev_list[i].num; j++)
+		for (j = 1; j < *dev_list[i].num; j++) {
 			devfs_remove("sound/%s%d", dev_list[i].name, j);
+			class_simple_device_remove(MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)));
+		}
 	}
 	
 	unregister_sound_special(1);
diff -puN sound/oss/trident.c~linus sound/oss/trident.c
--- 25/sound/oss/trident.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/sound/oss/trident.c	2004-01-19 22:17:25.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- *	OSS driver for Linux 2.4.x for
+ *	OSS driver for Linux 2.[46].x for
  *
  *	Trident 4D-Wave
  *	SiS 7018
@@ -37,6 +37,15 @@
  *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  *  History
+ *  v0.14.10j
+ *  	January 3 2004 Eugene Teo <eugeneteo@eugeneteo.net>
+ *  	minor cleanup to use pr_debug instead of TRDBG since it is already
+ *  	defined in linux/kernel.h.
+ *  v0.14.10i
+ *      December 29 2003 Muli Ben-Yehuda <mulix@mulix.org>
+ *      major cleanup for 2.6, fix a few error patch buglets
+ *      with returning without properly cleaning up first,
+ *      get rid of lock_kernel().
  *  v0.14.10h
  *	Sept 10 2002 Pascal Schmidt <der.eremit@email.de>
  *	added support for ALi 5451 joystick port
@@ -206,7 +215,7 @@
 #include <linux/interrupt.h>
 #include <linux/pm.h>
 #include <linux/gameport.h>
-#include <linux/kernel.h> 
+#include <linux/kernel.h>
 #include <asm/uaccess.h>
 #include <asm/hardirq.h>
 #include <asm/io.h>
@@ -218,29 +227,29 @@
 
 #include "trident.h"
 
-#define DRIVER_VERSION "0.14.10h-2.5"
+#define DRIVER_VERSION "0.14.10j-2.6"
 
 /* magic numbers to protect our data structures */
-#define TRIDENT_CARD_MAGIC	0x5072696E /* "Prin" */
-#define TRIDENT_STATE_MAGIC	0x63657373 /* "cess" */
+#define TRIDENT_CARD_MAGIC	0x5072696E	/* "Prin" */
+#define TRIDENT_STATE_MAGIC	0x63657373	/* "cess" */
 
-#define TRIDENT_DMA_MASK	0x3fffffff /* DMA buffer mask for pci_alloc_consist */
-#define ALI_DMA_MASK		0x7fffffff /* ALI Tridents have 31-bit DMA. Wow. */
+#define TRIDENT_DMA_MASK	0x3fffffff	/* DMA buffer mask for pci_alloc_consist */
+#define ALI_DMA_MASK		0x7fffffff	/* ALI Tridents have 31-bit DMA. Wow. */
 
 #define NR_HW_CH		32
 
 /* maximum number of AC97 codecs connected, AC97 2.0 defined 4, but 7018 and 4D-NX only
    have 2 SDATA_IN lines (currently) */
-#define NR_AC97		2	
+#define NR_AC97		2
 
 /* minor number of /dev/swmodem (temporary, experimental) */
 #define SND_DEV_SWMODEM	7
 
-static const unsigned ali_multi_channels_5_1[] = { 
-	/*ALI_SURR_LEFT_CHANNEL, ALI_SURR_RIGHT_CHANNEL,*/
-	ALI_CENTER_CHANNEL, 
-	ALI_LEF_CHANNEL, 
-	ALI_SURR_LEFT_CHANNEL, 
+static const unsigned ali_multi_channels_5_1[] = {
+	/*ALI_SURR_LEFT_CHANNEL, ALI_SURR_RIGHT_CHANNEL, */
+	ALI_CENTER_CHANNEL,
+	ALI_LEF_CHANNEL,
+	ALI_SURR_LEFT_CHANNEL,
 	ALI_SURR_RIGHT_CHANNEL
 };
 
@@ -257,7 +266,7 @@ enum {
 	CYBER5050
 };
 
-static char * card_names[] = {
+static char *card_names[] = {
 	"Trident 4DWave DX",
 	"Trident 4DWave NX",
 	"SiS 7018 PCI Audio",
@@ -265,7 +274,7 @@ static char * card_names[] = {
 	"Tvia/IGST CyberPro 5050"
 };
 
-static struct pci_device_id trident_pci_tbl [] = {
+static struct pci_device_id trident_pci_tbl[] = {
 	{PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_TRIDENT_4DWAVE_DX,
 	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, TRIDENT_4D_DX},
 	{PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_TRIDENT_4DWAVE_NX,
@@ -274,12 +283,12 @@ static struct pci_device_id trident_pci_
 	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, SIS_7018},
 	{PCI_VENDOR_ID_ALI, PCI_DEVICE_ID_ALI_5451,
 	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, ALI_5451},
-	{ PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_5050, 
+	{PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_5050,
 	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CYBER5050},
 	{0,}
 };
 
-MODULE_DEVICE_TABLE (pci, trident_pci_tbl);
+MODULE_DEVICE_TABLE(pci, trident_pci_tbl);
 
 /* "software" or virtual channel, an instance of opened /dev/dsp */
 struct trident_state {
@@ -308,13 +317,14 @@ struct trident_state {
 		unsigned fragshift;
 
 		/* our buffer acts like a circular ring */
-		unsigned hwptr;		/* where dma last started, updated by update_ptr */
-		unsigned swptr;		/* where driver last clear/filled, updated by read/write */
-		int count;		/* bytes to be comsumed or been generated by dma machine */
+		unsigned hwptr;	/* where dma last started, updated by update_ptr */
+		unsigned swptr;	/* where driver last clear/filled, updated by read/write */
+		int count;	/* bytes to be comsumed or been generated by dma machine */
 		unsigned total_bytes;	/* total bytes dmaed by hardware */
 
-		unsigned error;		/* number of over/underruns */
-		wait_queue_head_t wait;	/* put process on wait queue when no more space in buffer */
+		unsigned error;	/* number of over/underruns */
+                /* put process on wait queue when no more space in buffer */
+		wait_queue_head_t wait;	
 
 		/* redundant, but makes calculations easier */
 		unsigned fragsize;
@@ -329,14 +339,14 @@ struct trident_state {
 		unsigned ossfragshift;
 		int ossmaxfrags;
 		unsigned subdivision;
-		
+
 	} dmabuf;
 
-	/* 5.1 channels */	
+	/* 5.1 channels */
 	struct trident_state *other_states[4];
 	int multi_channels_adjust_count;
 	unsigned chans_num;
-	unsigned fmt_flag:1;
+	unsigned long fmt_flag;
 	/* Guard against mmap/write/read races */
 	struct semaphore sem;
 
@@ -344,13 +354,15 @@ struct trident_state {
 
 /* hardware channels */
 struct trident_channel {
-	int  num;	/* channel number */
-	u32 lba;	/* Loop Begine Address, where dma buffer starts */
-	u32 eso;	/* End Sample Offset, wehre dma buffer ends (in the unit of samples) */
-	u32 delta;	/* delta value, sample rate / 48k for playback, 48k/sample rate for recording */
-	u16 attribute;	/* control where PCM data go and come  */
+	int num; /* channel number */
+	u32 lba; /* Loop Begine Address, where dma buffer starts */
+	u32 eso; /* End Sample Offset, wehre dma buffer ends */ 
+	         /* (in the unit of samples) */
+	u32 delta; /* delta value, sample rate / 48k for playback, */
+	           /* 48k/sample rate for recording */
+	u16 attribute; /* control where PCM data go and come  */
 	u16 fm_vol;
-	u32 control;	/* signed/unsigned, 8/16 bits, mono/stereo */
+	u32 control; /* signed/unsigned, 8/16 bits, mono/stereo */
 };
 
 struct trident_pcm_bank_address {
@@ -360,16 +372,14 @@ struct trident_pcm_bank_address {
 	u32 aint_en;
 };
 
-static struct trident_pcm_bank_address bank_a_addrs =
-{
+static struct trident_pcm_bank_address bank_a_addrs = {
 	T4D_START_A,
 	T4D_STOP_A,
 	T4D_AINT_A,
 	T4D_AINTEN_A
 };
 
-static struct trident_pcm_bank_address bank_b_addrs =
-{
+static struct trident_pcm_bank_address bank_b_addrs = {
 	T4D_START_B,
 	T4D_STOP_B,
 	T4D_AINT_B,
@@ -380,7 +390,7 @@ struct trident_pcm_bank {
 	/* register addresses to control bank operations */
 	struct trident_pcm_bank_address *addresses;
 	/* each bank has 32 channels */
-	u32 bitmap; /* channel allocation bitmap */
+	u32 bitmap;		/* channel allocation bitmap */
 	struct trident_channel channels[32];
 };
 
@@ -396,16 +406,17 @@ struct trident_card {
 	/* The trident has a certain amount of cross channel interaction
 	   so we use a single per card lock */
 	spinlock_t lock;
-	
+
 	/* PCI device stuff */
-	struct pci_dev * pci_dev;
+	struct pci_dev *pci_dev;
 	u16 pci_id;
 	u8 revision;
 
 	/* soundcore stuff */
 	int dev_audio;
 
-	/* structures for abstraction of hardware facilities, codecs, banks and channels*/
+	/* structures for abstraction of hardware facilities, codecs, */ 
+	/* banks and channels */
 	struct ac97_codec *ac97_codec[NR_AC97];
 	struct trident_pcm_bank banks[NR_BANKS];
 	struct trident_state *states[NR_HW_CH];
@@ -413,13 +424,13 @@ struct trident_card {
 	/* hardware resources */
 	unsigned long iobase;
 	u32 irq;
-	
+
 	/* Function support */
-	struct trident_channel *(*alloc_pcm_channel)(struct trident_card *);
-	struct trident_channel *(*alloc_rec_pcm_channel)(struct trident_card *);
-	void (*free_pcm_channel)(struct trident_card *, unsigned int chan);
-	void (*address_interrupt)(struct trident_card *);
-	
+	struct trident_channel *(*alloc_pcm_channel) (struct trident_card *);
+	struct trident_channel *(*alloc_rec_pcm_channel) (struct trident_card *);
+	void (*free_pcm_channel) (struct trident_card *, unsigned int chan);
+	void (*address_interrupt) (struct trident_card *);
+
 	/* Added by Matt Wu 01-05-2001 for spdif in */
 	int multi_channel_use_count;
 	int rec_channel_use_count;
@@ -434,16 +445,20 @@ struct trident_card {
 	struct gameport gameport;
 };
 
+enum dmabuf_mode {
+	DM_PLAYBACK = 0,
+	DM_RECORD
+};
+
 /* table to map from CHANNELMASK to channel attribute for SiS 7018 */
-static u16 mask2attr [] =
-{
+static u16 mask2attr[] = {
 	PCM_LR, PCM_LR, SURR_LR, CENTER_LFE,
 	HSET, MIC, MODEM_LINE1, MODEM_LINE2,
 	I2S_LR, SPDIF_LR
 };
 
 /* table to map from channel attribute to CHANNELMASK for SiS 7018 */
-static int attr2mask [] = {
+static int attr2mask[] = {
 	DSP_BIND_MODEM1, DSP_BIND_MODEM2, DSP_BIND_FRONT, DSP_BIND_HANDSET,
 	DSP_BIND_I2S, DSP_BIND_CENTER_LFE, DSP_BIND_SURR, DSP_BIND_SPDIF
 };
@@ -462,8 +477,8 @@ static void trident_ac97_set(struct ac97
 static u16 trident_ac97_get(struct ac97_codec *codec, u8 reg);
 
 static int trident_open_mixdev(struct inode *inode, struct file *file);
-static int trident_ioctl_mixdev(struct inode *inode, struct file *file, unsigned int cmd,
-				unsigned long arg);
+static int trident_ioctl_mixdev(struct inode *inode, struct file *file, 
+				unsigned int cmd, unsigned long arg);
 
 static void ali_ac97_set(struct trident_card *card, int secondary, u8 reg, u16 val);
 static u16 ali_ac97_get(struct trident_card *card, int secondary, u8 reg);
@@ -482,14 +497,13 @@ static void ali_setup_spdif_in(struct tr
 static void ali_disable_spdif_in(struct trident_card *card);
 static void ali_disable_special_channel(struct trident_card *card, int ch);
 static void ali_setup_spdif_out(struct trident_card *card, int flag);
-static int ali_write_5_1(struct trident_state *state, const char *buffer,
+static int ali_write_5_1(struct trident_state *state, const char *buffer, 
 			 int cnt_for_multi_channel, unsigned int *copy_count, 
 			 unsigned int *state_cnt);
 static int ali_allocate_other_states_resources(struct trident_state *state, 
 					       int chan_nums);
 static void ali_free_other_states_resources(struct trident_state *state);
 
-
 /* save registers for ALi Power Management */
 static struct ali_saved_registers {
 	unsigned long global_regs[ALI_GLOBAL_REGS];
@@ -503,34 +517,30 @@ static struct ali_saved_registers {
         (cnt) -= (offset);	  \
 	(copy_count) += (offset); \
 } while (0)
-	  
 
-#define lock_set_fmt(state) do { \
-        spin_lock_irqsave(&state->card->lock, flags);			\
-	if (state->fmt_flag) {						\
-	       spin_unlock_irqrestore(&state->card->lock, flags);	\
-               return -EFAULT;					        \
-	}								\
-	state->fmt_flag = 1;						\
-	spin_unlock_irqrestore(&state->card->lock, flags);              \
-} while (0)
-				
-#define unlock_set_fmt(state)  do {                             \
-        spin_lock_irqsave(&state->card->lock, flags);		\
-	state->fmt_flag = 0;					\
-	spin_unlock_irqrestore(&state->card->lock, flags);      \
-} while (0)
+static inline int lock_set_fmt(struct trident_state* state)
+{
+	if (test_and_set_bit(0, &state->fmt_flag))
+		return -EFAULT;
+
+	return 0;
+}
 
-static int trident_enable_loop_interrupts(struct trident_card * card)
+static inline void unlock_set_fmt(struct trident_state* state)
+{
+	clear_bit(0, &state->fmt_flag);
+}
+
+static int
+trident_enable_loop_interrupts(struct trident_card *card)
 {
 	u32 global_control;
 
 	global_control = inl(TRID_REG(card, T4D_LFO_GC_CIR));
 
-	switch (card->pci_id)
-	{
+	switch (card->pci_id) {
 	case PCI_DEVICE_ID_SI_7018:
-		global_control |= (ENDLP_IE | MIDLP_IE| BANK_B_EN);
+		global_control |= (ENDLP_IE | MIDLP_IE | BANK_B_EN);
 		break;
 	case PCI_DEVICE_ID_ALI_5451:
 	case PCI_DEVICE_ID_TRIDENT_4DWAVE_DX:
@@ -539,18 +549,19 @@ static int trident_enable_loop_interrupt
 		global_control |= (ENDLP_IE | MIDLP_IE);
 		break;
 	default:
-		return FALSE;
+		return 0;
 	}
 
 	outl(global_control, TRID_REG(card, T4D_LFO_GC_CIR));
 
-	TRDBG("trident: Enable Loop Interrupts, globctl = 0x%08X\n",
-	      inl(TRID_REG(card, T4D_LFO_GC_CIR)));
+	pr_debug("trident: Enable Loop Interrupts, globctl = 0x%08X\n",
+		 inl(TRID_REG(card, T4D_LFO_GC_CIR)));
 
-	return (TRUE);
+	return 1;
 }
 
-static int trident_disable_loop_interrupts(struct trident_card * card)
+static int
+trident_disable_loop_interrupts(struct trident_card *card)
 {
 	u32 global_control;
 
@@ -558,13 +569,14 @@ static int trident_disable_loop_interrup
 	global_control &= ~(ENDLP_IE | MIDLP_IE);
 	outl(global_control, TRID_REG(card, T4D_LFO_GC_CIR));
 
-	TRDBG("trident: Disabled Loop Interrupts, globctl = 0x%08X\n",
-	      global_control);
+	pr_debug("trident: Disabled Loop Interrupts, globctl = 0x%08X\n",
+		 global_control);
 
-	return (TRUE);
+	return 1;
 }
 
-static void trident_enable_voice_irq(struct trident_card * card, unsigned int channel)
+static void
+trident_enable_voice_irq(struct trident_card *card, unsigned int channel)
 {
 	unsigned int mask = 1 << (channel & 0x1f);
 	struct trident_pcm_bank *bank = &card->banks[channel >> 5];
@@ -576,32 +588,36 @@ static void trident_enable_voice_irq(str
 
 #ifdef DEBUG
 	reg = inl(TRID_REG(card, addr));
-	TRDBG("trident: enabled IRQ on channel %d, %s = 0x%08x(addr:%X)\n",
-	      channel, addr==T4D_AINTEN_B? "AINTEN_B":"AINTEN_A",reg,addr);
-#endif /* DEBUG */ 
+	pr_debug("trident: enabled IRQ on channel %d, %s = 0x%08x(addr:%X)\n",
+		 channel, addr == T4D_AINTEN_B ? "AINTEN_B" : "AINTEN_A",
+		 reg, addr);
+#endif /* DEBUG */
 }
 
-static void trident_disable_voice_irq(struct trident_card * card, unsigned int channel)
+static void
+trident_disable_voice_irq(struct trident_card *card, unsigned int channel)
 {
 	unsigned int mask = 1 << (channel & 0x1f);
 	struct trident_pcm_bank *bank = &card->banks[channel >> 5];
 	u32 reg, addr = bank->addresses->aint_en;
-	
+
 	reg = inl(TRID_REG(card, addr));
 	reg &= ~mask;
 	outl(reg, TRID_REG(card, addr));
-	
+
 	/* Ack the channel in case the interrupt was set before we disable it. */
 	outl(mask, TRID_REG(card, bank->addresses->aint));
 
 #ifdef DEBUG
 	reg = inl(TRID_REG(card, addr));
-	TRDBG("trident: disabled IRQ on channel %d, %s = 0x%08x(addr:%X)\n",
-	      channel, addr==T4D_AINTEN_B? "AINTEN_B":"AINTEN_A",reg,addr);
-#endif /* DEBUG */ 
+	pr_debug("trident: disabled IRQ on channel %d, %s = 0x%08x(addr:%X)\n",
+		 channel, addr == T4D_AINTEN_B ? "AINTEN_B" : "AINTEN_A",
+		 reg, addr);
+#endif /* DEBUG */
 }
 
-static void trident_start_voice(struct trident_card * card, unsigned int channel)
+static void
+trident_start_voice(struct trident_card *card, unsigned int channel)
 {
 	unsigned int mask = 1 << (channel & 0x1f);
 	struct trident_pcm_bank *bank = &card->banks[channel >> 5];
@@ -609,18 +625,20 @@ static void trident_start_voice(struct t
 
 #ifdef DEBUG
 	u32 reg;
-#endif /* DEBUG */ 
+#endif /* DEBUG */
 
 	outl(mask, TRID_REG(card, addr));
 
-#ifdef DEBUG 
+#ifdef DEBUG
 	reg = inl(TRID_REG(card, addr));
-	TRDBG("trident: start voice on channel %d, %s = 0x%08x(addr:%X)\n",
-	      channel, addr==T4D_START_B? "START_B":"START_A",reg,addr);
-#endif /* DEBUG */ 
+	pr_debug("trident: start voice on channel %d, %s = 0x%08x(addr:%X)\n",
+		 channel, addr == T4D_START_B ? "START_B" : "START_A",
+		 reg, addr);
+#endif /* DEBUG */
 }
 
-static void trident_stop_voice(struct trident_card * card, unsigned int channel)
+static void
+trident_stop_voice(struct trident_card *card, unsigned int channel)
 {
 	unsigned int mask = 1 << (channel & 0x1f);
 	struct trident_pcm_bank *bank = &card->banks[channel >> 5];
@@ -628,38 +646,43 @@ static void trident_stop_voice(struct tr
 
 #ifdef DEBUG
 	u32 reg;
-#endif /* DEBUG */ 
+#endif /* DEBUG */
 
 	outl(mask, TRID_REG(card, addr));
 
 #ifdef DEBUG
 	reg = inl(TRID_REG(card, addr));
-	TRDBG("trident: stop voice on channel %d, %s = 0x%08x(addr:%X)\n",
-	      channel, addr==T4D_STOP_B? "STOP_B":"STOP_A",reg,addr);
-#endif /* DEBUG */ 
+	pr_debug("trident: stop voice on channel %d, %s = 0x%08x(addr:%X)\n",
+		 channel, addr == T4D_STOP_B ? "STOP_B" : "STOP_A",
+		 reg, addr);
+#endif /* DEBUG */
 }
 
-static u32 trident_get_interrupt_mask (struct trident_card * card, unsigned int channel)
+static u32
+trident_get_interrupt_mask(struct trident_card *card, unsigned int channel)
 {
 	struct trident_pcm_bank *bank = &card->banks[channel];
 	u32 addr = bank->addresses->aint;
 	return inl(TRID_REG(card, addr));
 }
 
-static int trident_check_channel_interrupt(struct trident_card * card, unsigned int channel)
+static int
+trident_check_channel_interrupt(struct trident_card *card, unsigned int channel)
 {
 	unsigned int mask = 1 << (channel & 0x1f);
-	u32 reg = trident_get_interrupt_mask (card, channel >> 5);
+	u32 reg = trident_get_interrupt_mask(card, channel >> 5);
 
 #ifdef DEBUG
 	if (reg & mask)
-		TRDBG("trident: channel %d has interrupt, %s = 0x%08x\n",
-		      channel,reg==T4D_AINT_B? "AINT_B":"AINT_A", reg);
-#endif /* DEBUG */ 
-	return (reg & mask) ? TRUE : FALSE;
+		pr_debug("trident: channel %d has interrupt, %s = 0x%08x\n",
+			 channel, reg == T4D_AINT_B ? "AINT_B" : "AINT_A",
+			 reg);
+#endif /* DEBUG */
+	return (reg & mask) ? 1 : 0;
 }
 
-static void trident_ack_channel_interrupt(struct trident_card * card, unsigned int channel)
+static void
+trident_ack_channel_interrupt(struct trident_card *card, unsigned int channel)
 {
 	unsigned int mask = 1 << (channel & 0x1f);
 	struct trident_pcm_bank *bank = &card->banks[channel >> 5];
@@ -671,12 +694,13 @@ static void trident_ack_channel_interrup
 
 #ifdef DEBUG
 	reg = inl(TRID_REG(card, T4D_AINT_B));
-	TRDBG("trident: Ack channel %d interrupt, AINT_B = 0x%08x\n",
-	      channel, reg);
-#endif /* DEBUG */ 
+	pr_debug("trident: Ack channel %d interrupt, AINT_B = 0x%08x\n",
+		 channel, reg);
+#endif /* DEBUG */
 }
 
-static struct trident_channel * trident_alloc_pcm_channel(struct trident_card *card)
+static struct trident_channel *
+trident_alloc_pcm_channel(struct trident_card *card)
 {
 	struct trident_pcm_bank *bank;
 	int idx;
@@ -697,28 +721,30 @@ static struct trident_channel * trident_
 	return NULL;
 }
 
-static void trident_free_pcm_channel(struct trident_card *card, unsigned int channel)
+static void
+trident_free_pcm_channel(struct trident_card *card, unsigned int channel)
 {
 	int bank;
-        unsigned char b;
+	unsigned char b;
 
 	if (channel < 31 || channel > 63)
 		return;
 
-	if (card->pci_id == PCI_DEVICE_ID_TRIDENT_4DWAVE_DX ||
-            card->pci_id == PCI_DEVICE_ID_TRIDENT_4DWAVE_NX) {
-          b = inb (TRID_REG(card, T4D_REC_CH));
-          if ((b & ~0x80) == channel)
-            outb(0x0, TRID_REG(card, T4D_REC_CH));
-        }
-            
+	if (card->pci_id == PCI_DEVICE_ID_TRIDENT_4DWAVE_DX || 
+	    card->pci_id == PCI_DEVICE_ID_TRIDENT_4DWAVE_NX) {
+		b = inb(TRID_REG(card, T4D_REC_CH));
+		if ((b & ~0x80) == channel)
+			outb(0x0, TRID_REG(card, T4D_REC_CH));
+	}
+
 	bank = channel >> 5;
 	channel = channel & 0x1f;
-        
+
 	card->banks[bank].bitmap &= ~(1 << (channel));
 }
 
-static struct trident_channel * cyber_alloc_pcm_channel(struct trident_card *card)
+static struct trident_channel *
+cyber_alloc_pcm_channel(struct trident_card *card)
 {
 	struct trident_pcm_bank *bank;
 	int idx;
@@ -743,26 +769,30 @@ static struct trident_channel * cyber_al
 	return NULL;
 }
 
-static void cyber_free_pcm_channel(struct trident_card *card, unsigned int channel)
+static void
+cyber_free_pcm_channel(struct trident_card *card, unsigned int channel)
 {
 	if (channel > 31)
 		return;
 	card->banks[BANK_A].bitmap &= ~(1 << (channel));
 }
 
-static inline void cyber_outidx(int port,int idx,int data)
+static inline void
+cyber_outidx(int port, int idx, int data)
 {
-	outb(idx,port);
-	outb(data,port+1);
+	outb(idx, port);
+	outb(data, port + 1);
 }
 
-static inline int cyber_inidx(int port,int idx)
+static inline int
+cyber_inidx(int port, int idx)
 {
-	outb(idx,port);
-	return inb(port+1);
+	outb(idx, port);
+	return inb(port + 1);
 }
 
-static int cyber_init_ritual(struct trident_card *card)
+static int
+cyber_init_ritual(struct trident_card *card)
 {
 	/* some black magic, taken from SDK samples */
 	/* remove this and nothing will work */
@@ -771,47 +801,47 @@ static int cyber_init_ritual(struct trid
 	unsigned long flags;
 
 	/*
- 	 *	Keep interrupts off for the configure - we don't want to
- 	 *	clash with another cyberpro config event
- 	 */
- 	
-	spin_lock_irqsave(&card->lock, flags); 
+	 *      Keep interrupts off for the configure - we don't want to
+	 *      clash with another cyberpro config event
+	 */
+
+	spin_lock_irqsave(&card->lock, flags);
 	portDat = cyber_inidx(CYBER_PORT_AUDIO, CYBER_IDX_AUDIO_ENABLE);
 	/* enable, if it was disabled */
-	if( (portDat & CYBER_BMSK_AUENZ) != CYBER_BMSK_AUENZ_ENABLE ) {
-		printk(KERN_INFO "cyberpro5050: enabling audio controller\n" );
-		cyber_outidx( CYBER_PORT_AUDIO, CYBER_IDX_AUDIO_ENABLE,
-			portDat | CYBER_BMSK_AUENZ_ENABLE );
+	if ((portDat & CYBER_BMSK_AUENZ) != CYBER_BMSK_AUENZ_ENABLE) {
+		printk(KERN_INFO "cyberpro5050: enabling audio controller\n");
+		cyber_outidx(CYBER_PORT_AUDIO, CYBER_IDX_AUDIO_ENABLE, 
+			     portDat | CYBER_BMSK_AUENZ_ENABLE);
 		/* check again if hardware is enabled now */
 		portDat = cyber_inidx(CYBER_PORT_AUDIO, CYBER_IDX_AUDIO_ENABLE);
 	}
-	if( (portDat & CYBER_BMSK_AUENZ) != CYBER_BMSK_AUENZ_ENABLE )
-	{
-		printk(KERN_ERR "cyberpro5050: initAudioAccess: no success\n" );
+	if ((portDat & CYBER_BMSK_AUENZ) != CYBER_BMSK_AUENZ_ENABLE) {
+		printk(KERN_ERR "cyberpro5050: initAudioAccess: no success\n");
 		ret = -1;
+	} else {
+		cyber_outidx(CYBER_PORT_AUDIO, CYBER_IDX_IRQ_ENABLE, 
+			     CYBER_BMSK_AUDIO_INT_ENABLE);
+		cyber_outidx(CYBER_PORT_AUDIO, 0xbf, 0x01);
+		cyber_outidx(CYBER_PORT_AUDIO, 0xba, 0x20);
+		cyber_outidx(CYBER_PORT_AUDIO, 0xbb, 0x08);
+		cyber_outidx(CYBER_PORT_AUDIO, 0xbf, 0x02);
+		cyber_outidx(CYBER_PORT_AUDIO, 0xb3, 0x06);
+		cyber_outidx(CYBER_PORT_AUDIO, 0xbf, 0x00);
 	}
-	else
-	{
-		cyber_outidx( CYBER_PORT_AUDIO, CYBER_IDX_IRQ_ENABLE, CYBER_BMSK_AUDIO_INT_ENABLE );
-		cyber_outidx( CYBER_PORT_AUDIO, 0xbf, 0x01 );
-		cyber_outidx( CYBER_PORT_AUDIO, 0xba, 0x20 );
-		cyber_outidx( CYBER_PORT_AUDIO, 0xbb, 0x08 );
-		cyber_outidx( CYBER_PORT_AUDIO, 0xbf, 0x02 );
-		cyber_outidx( CYBER_PORT_AUDIO, 0xb3, 0x06 );
-		cyber_outidx( CYBER_PORT_AUDIO, 0xbf, 0x00 );
-	}
-	spin_unlock_irqrestore(&card->lock, flags); 
+	spin_unlock_irqrestore(&card->lock, flags);
 	return ret;
 }
 
 /*  called with spin lock held */
 
-static int trident_load_channel_registers(struct trident_card *card, u32 *data, unsigned int channel)
+static int
+trident_load_channel_registers(struct trident_card *card, u32 * data, 
+			       unsigned int channel)
 {
 	int i;
 
 	if (channel > 63)
-		return FALSE;
+		return 0;
 
 	/* select hardware channel to write */
 	outb(channel, TRID_REG(card, T4D_LFO_GC_CIR));
@@ -821,18 +851,19 @@ static int trident_load_channel_register
 	for (i = 0; i < CHANNEL_REGS; i++) {
 		if (i == 3 && card->pci_id == PCI_DEVICE_ID_ALI_5451)
 			continue;
-		outl(data[i], TRID_REG(card, CHANNEL_START + 4*i));
+		outl(data[i], TRID_REG(card, CHANNEL_START + 4 * i));
 	}
-	if (card->pci_id == PCI_DEVICE_ID_ALI_5451 ||
-		card->pci_id == PCI_DEVICE_ID_INTERG_5050) {
+	if (card->pci_id == PCI_DEVICE_ID_ALI_5451 || 
+	    card->pci_id == PCI_DEVICE_ID_INTERG_5050) {
 		outl(ALI_EMOD_Still, TRID_REG(card, ALI_EBUF1));
 		outl(ALI_EMOD_Still, TRID_REG(card, ALI_EBUF2));
 	}
-	return TRUE;
+	return 1;
 }
 
 /* called with spin lock held */
-static int trident_write_voice_regs(struct trident_state *state)
+static int
+trident_write_voice_regs(struct trident_state *state)
 {
 	unsigned int data[CHANNEL_REGS + 1];
 	struct trident_channel *channel;
@@ -842,37 +873,38 @@ static int trident_write_voice_regs(stru
 	data[1] = channel->lba;
 	data[4] = channel->control;
 
-	switch (state->card->pci_id)
-	{
+	switch (state->card->pci_id) {
 	case PCI_DEVICE_ID_ALI_5451:
-		data[0] = 0; /* Current Sample Offset */
+		data[0] = 0;	/* Current Sample Offset */
 		data[2] = (channel->eso << 16) | (channel->delta & 0xffff);
 		data[3] = 0;
-		break;	
+		break;
 	case PCI_DEVICE_ID_SI_7018:
 	case PCI_DEVICE_ID_INTERG_5050:
-		data[0] = 0; /* Current Sample Offset */
+		data[0] = 0;	/* Current Sample Offset */
 		data[2] = (channel->eso << 16) | (channel->delta & 0xffff);
 		data[3] = (channel->attribute << 16) | (channel->fm_vol & 0xffff);
 		break;
 	case PCI_DEVICE_ID_TRIDENT_4DWAVE_DX:
-		data[0] = 0; /* Current Sample Offset */
+		data[0] = 0;	/* Current Sample Offset */
 		data[2] = (channel->eso << 16) | (channel->delta & 0xffff);
 		data[3] = channel->fm_vol & 0xffff;
 		break;
 	case PCI_DEVICE_ID_TRIDENT_4DWAVE_NX:
 		data[0] = (channel->delta << 24);
-		data[2] = ((channel->delta << 16) & 0xff000000) | (channel->eso & 0x00ffffff);
+		data[2] = ((channel->delta << 16) & 0xff000000) | 
+			(channel->eso & 0x00ffffff);
 		data[3] = channel->fm_vol & 0xffff;
 		break;
 	default:
-		return FALSE;
+		return 0;
 	}
 
 	return trident_load_channel_registers(state->card, data, channel->num);
 }
 
-static int compute_rate_play(u32 rate)
+static int
+compute_rate_play(u32 rate)
 {
 	int delta;
 	/* We special case 44100 and 8000 since rounding with the equation
@@ -890,7 +922,8 @@ static int compute_rate_play(u32 rate)
 	return delta;
 }
 
-static int compute_rate_rec(u32 rate)
+static int
+compute_rate_rec(u32 rate)
 {
 	int delta;
 
@@ -905,9 +938,11 @@ static int compute_rate_rec(u32 rate)
 
 	return delta;
 }
+
 /* set playback sample rate */
-static unsigned int trident_set_dac_rate(struct trident_state * state, unsigned int rate)
-{	
+static unsigned int
+trident_set_dac_rate(struct trident_state *state, unsigned int rate)
+{
 	struct dmabuf *dmabuf = &state->dmabuf;
 
 	if (rate > 48000)
@@ -920,13 +955,14 @@ static unsigned int trident_set_dac_rate
 
 	trident_write_voice_regs(state);
 
-	TRDBG("trident: called trident_set_dac_rate : rate = %d\n", rate);
+	pr_debug("trident: called trident_set_dac_rate : rate = %d\n", rate);
 
 	return rate;
 }
 
 /* set recording sample rate */
-static unsigned int trident_set_adc_rate(struct trident_state * state, unsigned int rate)
+static unsigned int
+trident_set_adc_rate(struct trident_state *state, unsigned int rate)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 
@@ -940,13 +976,14 @@ static unsigned int trident_set_adc_rate
 
 	trident_write_voice_regs(state);
 
-	TRDBG("trident: called trident_set_adc_rate : rate = %d\n", rate);
+	pr_debug("trident: called trident_set_adc_rate : rate = %d\n", rate);
 
 	return rate;
 }
 
-/* prepare channel attributes for playback */ 
-static void trident_play_setup(struct trident_state *state)
+/* prepare channel attributes for playback */
+static void
+trident_play_setup(struct trident_state *state)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 	struct trident_channel *channel = dmabuf->channel;
@@ -960,19 +997,21 @@ static void trident_play_setup(struct tr
 	if (state->card->pci_id != PCI_DEVICE_ID_SI_7018) {
 		channel->attribute = 0;
 		if (state->card->pci_id == PCI_DEVICE_ID_ALI_5451) {
-			if ((channel->num == ALI_SPDIF_IN_CHANNEL) || (channel->num == ALI_PCM_IN_CHANNEL))
+			if ((channel->num == ALI_SPDIF_IN_CHANNEL) || 
+			    (channel->num == ALI_PCM_IN_CHANNEL))
 				ali_disable_special_channel(state->card, channel->num);
-			else if ((inl(TRID_REG(state->card, ALI_GLOBAL_CONTROL)) & ALI_SPDIF_OUT_CH_ENABLE) 
-								&& (channel->num == ALI_SPDIF_OUT_CHANNEL))
-			{
-				ali_set_spdif_out_rate(state->card, state->dmabuf.rate);
+			else if ((inl(TRID_REG(state->card, ALI_GLOBAL_CONTROL)) 
+				  & ALI_SPDIF_OUT_CH_ENABLE)
+				 && (channel->num == ALI_SPDIF_OUT_CHANNEL)) {
+				ali_set_spdif_out_rate(state->card, 
+						       state->dmabuf.rate);
 				state->dmabuf.channel->delta = 0x1000;
 			}
 		}
 	}
 
 	channel->fm_vol = 0x0;
-	
+
 	channel->control = CHANNEL_LOOP;
 	if (dmabuf->fmt & TRIDENT_FMT_16BIT) {
 		/* 16-bits */
@@ -984,18 +1023,19 @@ static void trident_play_setup(struct tr
 		/* stereo */
 		channel->control |= CHANNEL_STEREO;
 
-	TRDBG("trident: trident_play_setup, LBA = 0x%08x, "
-	      "Delta = 0x%08x, ESO = 0x%08x, Control = 0x%08x\n",
-	      channel->lba, channel->delta, channel->eso, channel->control);
+	pr_debug("trident: trident_play_setup, LBA = 0x%08x, Delta = 0x%08x, "
+		 "ESO = 0x%08x, Control = 0x%08x\n", channel->lba,
+		 channel->delta, channel->eso, channel->control);
 
 	trident_write_voice_regs(state);
 }
 
 /* prepare channel attributes for recording */
-static void trident_rec_setup(struct trident_state *state)
+static void
+trident_rec_setup(struct trident_state *state)
 {
 	u16 w;
-	u8  bval;
+	u8 bval;
 
 	struct trident_card *card = state->card;
 	struct dmabuf *dmabuf = &state->dmabuf;
@@ -1003,8 +1043,7 @@ static void trident_rec_setup(struct tri
 	unsigned int rate;
 
 	/* Enable AC-97 ADC (capture) */
-	switch (card->pci_id) 
-	{
+	switch (card->pci_id) {
 	case PCI_DEVICE_ID_ALI_5451:
 		ali_enable_special_channel(state);
 		break;
@@ -1032,24 +1071,25 @@ static void trident_rec_setup(struct tri
 
 	channel->lba = dmabuf->dma_handle;
 	channel->delta = compute_rate_rec(dmabuf->rate);
-	if ((card->pci_id == PCI_DEVICE_ID_ALI_5451) && (channel->num == ALI_SPDIF_IN_CHANNEL)) {
+	if ((card->pci_id == PCI_DEVICE_ID_ALI_5451) && 
+	    (channel->num == ALI_SPDIF_IN_CHANNEL)) {
 		rate = ali_get_spdif_in_rate(card);
-		if (rate == 0)
-		{
-			printk(KERN_WARNING "trident: ALi 5451 S/PDIF input setup error!\n");
+		if (rate == 0) {
+			printk(KERN_WARNING "trident: ALi 5451 "
+			       "S/PDIF input setup error!\n");
 			rate = 48000;
 		}
-		bval = inb(TRID_REG(card,ALI_SPDIF_CTRL));
-		if (bval & 0x10)
-		{
-			outb(bval,TRID_REG(card,ALI_SPDIF_CTRL));
-			printk(KERN_WARNING "trident: cleared ALi 5451 S/PDIF parity error flag.\n");
+		bval = inb(TRID_REG(card, ALI_SPDIF_CTRL));
+		if (bval & 0x10) {
+			outb(bval, TRID_REG(card, ALI_SPDIF_CTRL));
+			printk(KERN_WARNING "trident: cleared ALi "
+			       "5451 S/PDIF parity error flag.\n");
 		}
 
 		if (rate != 48000)
 			channel->delta = ((rate << 12) / dmabuf->rate) & 0x0000ffff;
 	}
-	
+
 	channel->eso = dmabuf->dmasize >> sample_shift[dmabuf->fmt];
 	channel->eso -= 1;
 
@@ -1058,7 +1098,7 @@ static void trident_rec_setup(struct tri
 	}
 
 	channel->fm_vol = 0x0;
-	
+
 	channel->control = CHANNEL_LOOP;
 	if (dmabuf->fmt & TRIDENT_FMT_16BIT) {
 		/* 16-bits */
@@ -1069,17 +1109,18 @@ static void trident_rec_setup(struct tri
 	if (dmabuf->fmt & TRIDENT_FMT_STEREO)
 		/* stereo */
 		channel->control |= CHANNEL_STEREO;
-	
-	TRDBG("trident: trident_rec_setup, LBA = 0x%08x, "
-	      "Delat = 0x%08x, ESO = 0x%08x, Control = 0x%08x\n",
-	      channel->lba, channel->delta, channel->eso, channel->control);
+
+	pr_debug("trident: trident_rec_setup, LBA = 0x%08x, Delat = 0x%08x, "
+		 "ESO = 0x%08x, Control = 0x%08x\n", channel->lba,
+		 channel->delta, channel->eso, channel->control);
 
 	trident_write_voice_regs(state);
 }
 
 /* get current playback/recording dma buffer pointer (byte offset from LBA),
    called with spinlock held! */
-static inline unsigned trident_get_dma_addr(struct trident_state *state)
+static inline unsigned
+trident_get_dma_addr(struct trident_state *state)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 	u32 cso;
@@ -1089,8 +1130,7 @@ static inline unsigned trident_get_dma_a
 
 	outb(dmabuf->channel->num, TRID_REG(state->card, T4D_LFO_GC_CIR));
 
-	switch (state->card->pci_id) 
-	{
+	switch (state->card->pci_id) {
 	case PCI_DEVICE_ID_ALI_5451:
 	case PCI_DEVICE_ID_SI_7018:
 	case PCI_DEVICE_ID_TRIDENT_4DWAVE_DX:
@@ -1106,9 +1146,8 @@ static inline unsigned trident_get_dma_a
 		return 0;
 	}
 
-	
-	TRDBG("trident: trident_get_dma_addr: chip reported channel: %d, "
-	      "cso = 0x%04x\n", dmabuf->channel->num, cso);
+	pr_debug("trident: trident_get_dma_addr: chip reported channel: %d, "
+		 "cso = 0x%04x\n", dmabuf->channel->num, cso);
 
 	/* ESO and CSO are in units of Samples, convert to byte offset */
 	cso <<= sample_shift[dmabuf->fmt];
@@ -1117,7 +1156,8 @@ static inline unsigned trident_get_dma_a
 }
 
 /* Stop recording (lock held) */
-static inline void __stop_adc(struct trident_state *state)
+static inline void
+__stop_adc(struct trident_state *state)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 	unsigned int chan_num = dmabuf->channel->num;
@@ -1128,7 +1168,8 @@ static inline void __stop_adc(struct tri
 	trident_disable_voice_irq(card, chan_num);
 }
 
-static void stop_adc(struct trident_state *state)
+static void
+stop_adc(struct trident_state *state)
 {
 	struct trident_card *card = state->card;
 	unsigned long flags;
@@ -1138,7 +1179,8 @@ static void stop_adc(struct trident_stat
 	spin_unlock_irqrestore(&card->lock, flags);
 }
 
-static void start_adc(struct trident_state *state)
+static void
+start_adc(struct trident_state *state)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 	unsigned int chan_num = dmabuf->channel->num;
@@ -1146,7 +1188,9 @@ static void start_adc(struct trident_sta
 	unsigned long flags;
 
 	spin_lock_irqsave(&card->lock, flags);
-	if ((dmabuf->mapped || dmabuf->count < (signed)dmabuf->dmasize) && dmabuf->ready) {
+	if ((dmabuf->mapped || 
+	     dmabuf->count < (signed) dmabuf->dmasize) && 
+	    dmabuf->ready) {
 		dmabuf->enable |= ADC_RUNNING;
 		trident_enable_voice_irq(card, chan_num);
 		trident_start_voice(card, chan_num);
@@ -1155,7 +1199,8 @@ static void start_adc(struct trident_sta
 }
 
 /* stop playback (lock held) */
-static inline void __stop_dac(struct trident_state *state)
+static inline void
+__stop_dac(struct trident_state *state)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 	unsigned int chan_num = dmabuf->channel->num;
@@ -1164,15 +1209,20 @@ static inline void __stop_dac(struct tri
 	dmabuf->enable &= ~DAC_RUNNING;
 	trident_stop_voice(card, chan_num);
 	if (state->chans_num == 6) {
-		trident_stop_voice(card, state->other_states[0]->dmabuf.channel->num);
-		trident_stop_voice(card, state->other_states[1]->dmabuf.channel->num);
-		trident_stop_voice(card, state->other_states[2]->dmabuf.channel->num);
-		trident_stop_voice(card, state->other_states[3]->dmabuf.channel->num);
+		trident_stop_voice(card, state->other_states[0]->
+				   dmabuf.channel->num);
+		trident_stop_voice(card, state->other_states[1]->
+				   dmabuf.channel->num);
+		trident_stop_voice(card, state->other_states[2]->
+				   dmabuf.channel->num);
+		trident_stop_voice(card, state->other_states[3]->
+				   dmabuf.channel->num);
 	}
 	trident_disable_voice_irq(card, chan_num);
 }
 
-static void stop_dac(struct trident_state *state)
+static void
+stop_dac(struct trident_state *state)
 {
 	struct trident_card *card = state->card;
 	unsigned long flags;
@@ -1180,9 +1230,10 @@ static void stop_dac(struct trident_stat
 	spin_lock_irqsave(&card->lock, flags);
 	__stop_dac(state);
 	spin_unlock_irqrestore(&card->lock, flags);
-}	
+}
 
-static void start_dac(struct trident_state *state)
+static void
+start_dac(struct trident_state *state)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 	unsigned int chan_num = dmabuf->channel->num;
@@ -1195,10 +1246,14 @@ static void start_dac(struct trident_sta
 		trident_enable_voice_irq(card, chan_num);
 		trident_start_voice(card, chan_num);
 		if (state->chans_num == 6) {
-			trident_start_voice(card, state->other_states[0]->dmabuf.channel->num);
-			trident_start_voice(card, state->other_states[1]->dmabuf.channel->num);
-			trident_start_voice(card, state->other_states[2]->dmabuf.channel->num);
-			trident_start_voice(card, state->other_states[3]->dmabuf.channel->num);
+			trident_start_voice(card, state->other_states[0]->
+					    dmabuf.channel->num);
+			trident_start_voice(card, state->other_states[1]->
+					    dmabuf.channel->num);
+			trident_start_voice(card, state->other_states[2]->
+					    dmabuf.channel->num);
+			trident_start_voice(card, state->other_states[3]->
+					    dmabuf.channel->num);
 		}
 	}
 	spin_unlock_irqrestore(&card->lock, flags);
@@ -1207,24 +1262,26 @@ static void start_dac(struct trident_sta
 #define DMABUF_DEFAULTORDER (15-PAGE_SHIFT)
 #define DMABUF_MINORDER 1
 
-/* alloc a DMA buffer of with a buffer of this order */ 
-static int alloc_dmabuf(struct dmabuf* dmabuf, struct pci_dev* pci_dev, int order)
+/* alloc a DMA buffer of with a buffer of this order */
+static int
+alloc_dmabuf(struct dmabuf *dmabuf, struct pci_dev *pci_dev, int order)
 {
 	void *rawbuf = NULL;
 	struct page *page, *pend;
 
-	if (!(rawbuf = pci_alloc_consistent(pci_dev, PAGE_SIZE << order,
+	if (!(rawbuf = pci_alloc_consistent(pci_dev, PAGE_SIZE << order, 
 					    &dmabuf->dma_handle)))
 		return -ENOMEM;
 
-	TRDBG("trident: allocated %ld (order = %d) bytes at %p\n",
-	      PAGE_SIZE << order, order, rawbuf);
+	pr_debug("trident: allocated %ld (order = %d) bytes at %p\n",
+		 PAGE_SIZE << order, order, rawbuf);
 
-	dmabuf->ready  = dmabuf->mapped = 0;
+	dmabuf->ready = dmabuf->mapped = 0;
 	dmabuf->rawbuf = rawbuf;
 	dmabuf->buforder = order;
-	
-	/* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
+
+	/* now mark the pages as reserved; otherwise */ 
+	/* remap_page_range doesn't do what we want */
 	pend = virt_to_page(rawbuf + (PAGE_SIZE << order) - 1);
 	for (page = virt_to_page(rawbuf); page <= pend; page++)
 		SetPageReserved(page);
@@ -1232,41 +1289,44 @@ static int alloc_dmabuf(struct dmabuf* d
 	return 0;
 }
 
-/* allocate the main DMA buffer, playback and recording buffer should be */ 
+/* allocate the main DMA buffer, playback and recording buffer should be */
 /* allocated separately */
-static int alloc_main_dmabuf(struct trident_state *state)
+static int
+alloc_main_dmabuf(struct trident_state *state)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 	int order;
-	int ret = -ENOMEM; 
+	int ret = -ENOMEM;
 
 	/* alloc as big a chunk as we can, FIXME: is this necessary ?? */
 	for (order = DMABUF_DEFAULTORDER; order >= DMABUF_MINORDER; order--) {
 		if (!(ret = alloc_dmabuf(dmabuf, state->card->pci_dev, order)))
-			return 0; 
-		/* else try again */ 
+			return 0;
+		/* else try again */
 	}
-	return ret; 
+	return ret;
 }
 
-/* deallocate a DMA buffer */ 
-static void dealloc_dmabuf(struct dmabuf* dmabuf, struct pci_dev* pci_dev)
+/* deallocate a DMA buffer */
+static void
+dealloc_dmabuf(struct dmabuf *dmabuf, struct pci_dev *pci_dev)
 {
 	struct page *page, *pend;
-	
+
 	if (dmabuf->rawbuf) {
 		/* undo marking the pages as reserved */
 		pend = virt_to_page(dmabuf->rawbuf + (PAGE_SIZE << dmabuf->buforder) - 1);
 		for (page = virt_to_page(dmabuf->rawbuf); page <= pend; page++)
 			ClearPageReserved(page);
-		pci_free_consistent(pci_dev, PAGE_SIZE << dmabuf->buforder,
+		pci_free_consistent(pci_dev, PAGE_SIZE << dmabuf->buforder, 
 				    dmabuf->rawbuf, dmabuf->dma_handle);
 		dmabuf->rawbuf = NULL;
 	}
 	dmabuf->mapped = dmabuf->ready = 0;
 }
 
-static int prog_dmabuf(struct trident_state *state, unsigned rec)
+static int
+prog_dmabuf(struct trident_state *state, enum dmabuf_mode rec)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 	unsigned bytepersec;
@@ -1274,13 +1334,15 @@ static int prog_dmabuf(struct trident_st
 	unsigned bufsize, dma_nums;
 	unsigned long flags;
 	int ret, i, order;
-	
-	lock_set_fmt(state);
+
+	if ((ret = lock_set_fmt(state)) < 0)
+		return ret;
+
 	if (state->chans_num == 6)
 		dma_nums = 5;
-	else 	
+	else
 		dma_nums = 1;
-	
+
 	for (i = 0; i < dma_nums; i++) {
 		if (i > 0) {
 			s = state->other_states[i - 1];
@@ -1302,19 +1364,22 @@ static int prog_dmabuf(struct trident_st
 					return ret;
 				}
 			} else {
-				ret = -ENOMEM; 
-				if ((order = state->dmabuf.buforder - 1) >= DMABUF_MINORDER) {
-					ret = alloc_dmabuf(dmabuf, state->card->pci_dev, order); 
+				ret = -ENOMEM;
+				order = state->dmabuf.buforder - 1;
+				if (order >= DMABUF_MINORDER) {
+					ret = alloc_dmabuf(dmabuf,
+							   state->card->pci_dev,
+							   order);
 				}
 				if (ret) {
-					/* release the main DMA buffer */ 
-					dealloc_dmabuf(&state->dmabuf, state->card->pci_dev); 
-					/* release the auxiliary DMA buffers */ 
-					for (i-=2; i >= 0; i--)
+					/* release the main DMA buffer */
+					dealloc_dmabuf(&state->dmabuf, state->card->pci_dev);
+					/* release the auxiliary DMA buffers */
+					for (i -= 2; i >= 0; i--)
 						dealloc_dmabuf(&state->other_states[i]->dmabuf, 
-							       state->card->pci_dev); 
+							       state->card->pci_dev);
 					unlock_set_fmt(state);
-					return ret; 
+					return ret;
 				}
 			}
 		}
@@ -1323,12 +1388,12 @@ static int prog_dmabuf(struct trident_st
 		bufsize = PAGE_SIZE << dmabuf->buforder;
 		if (dmabuf->ossfragshift) {
 			if ((1000 << dmabuf->ossfragshift) < bytepersec)
-				dmabuf->fragshift = ld2(bytepersec/1000);
+				dmabuf->fragshift = ld2(bytepersec / 1000);
 			else
 				dmabuf->fragshift = dmabuf->ossfragshift;
 		} else {
 			/* lets hand out reasonable big ass buffers by default */
-			dmabuf->fragshift = (dmabuf->buforder + PAGE_SHIFT -2);
+			dmabuf->fragshift = (dmabuf->buforder + PAGE_SHIFT - 2);
 		}
 		dmabuf->numfrag = bufsize >> dmabuf->fragshift;
 		while (dmabuf->numfrag < 4 && dmabuf->fragshift > 3) {
@@ -1341,29 +1406,41 @@ static int prog_dmabuf(struct trident_st
 		dmabuf->fragsamples = dmabuf->fragsize >> sample_shift[dmabuf->fmt];
 		dmabuf->dmasize = dmabuf->numfrag << dmabuf->fragshift;
 
-		memset(dmabuf->rawbuf, (dmabuf->fmt & TRIDENT_FMT_16BIT) ? 0 : 0x80,
+		memset(dmabuf->rawbuf, (dmabuf->fmt & TRIDENT_FMT_16BIT) ? 0 : 0x80, 
 		       dmabuf->dmasize);
 
 		spin_lock_irqsave(&s->card->lock, flags);
-		if (rec) 
+		if (rec == DM_RECORD)
 			trident_rec_setup(s);
-		else 
+		else /* DM_PLAYBACK */
 			trident_play_setup(s);
-		
+
 		spin_unlock_irqrestore(&s->card->lock, flags);
 
 		/* set the ready flag for the dma buffer */
 		dmabuf->ready = 1;
 
-		TRDBG("trident: prog_dmabuf(%d), sample rate = %d, format = %d, numfrag = %d, "
-		      "fragsize = %d dmasize = %d\n",
-		      dmabuf->channel->num, dmabuf->rate, dmabuf->fmt, dmabuf->numfrag,
-		      dmabuf->fragsize, dmabuf->dmasize);
+		pr_debug("trident: prog_dmabuf(%d), sample rate = %d, "
+			 "format = %d, numfrag = %d, fragsize = %d "
+			 "dmasize = %d\n", dmabuf->channel->num,
+			 dmabuf->rate, dmabuf->fmt, dmabuf->numfrag,
+			 dmabuf->fragsize, dmabuf->dmasize);
 	}
 	unlock_set_fmt(state);
 	return 0;
 }
 
+
+static inline int prog_dmabuf_record(struct trident_state* state)
+{
+	return prog_dmabuf(state, DM_RECORD);
+}
+
+static inline int prog_dmabuf_playback(struct trident_state* state)
+{
+	return prog_dmabuf(state, DM_PLAYBACK);
+}
+
 /* we are doing quantum mechanics here, the buffer can only be empty, half or full filled i.e.
    |------------|------------|   or   |xxxxxxxxxxxx|------------|   or   |xxxxxxxxxxxx|xxxxxxxxxxxx|
    but we almost always get this
@@ -1371,7 +1448,8 @@ static int prog_dmabuf(struct trident_st
    so we have to clear the tail space to "silence"
    |xxxxxx000000|------------|   or   |xxxxxxxxxxxx|xxxxxx000000|
 */
-static void trident_clear_tail(struct trident_state *state)
+static void
+trident_clear_tail(struct trident_state *state)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 	unsigned swptr;
@@ -1383,17 +1461,17 @@ static void trident_clear_tail(struct tr
 	swptr = dmabuf->swptr;
 	spin_unlock_irqrestore(&state->card->lock, flags);
 
-	if (swptr == 0 || swptr == dmabuf->dmasize / 2 || swptr == dmabuf->dmasize)
+	if (swptr == 0 || swptr == dmabuf->dmasize / 2 || 
+	    swptr == dmabuf->dmasize)
 		return;
 
-	if (swptr < dmabuf->dmasize/2)
-		len = dmabuf->dmasize/2 - swptr;
+	if (swptr < dmabuf->dmasize / 2)
+		len = dmabuf->dmasize / 2 - swptr;
 	else
 		len = dmabuf->dmasize - swptr;
 
 	memset(dmabuf->rawbuf + swptr, silence, len);
-	if(state->card->pci_id != PCI_DEVICE_ID_ALI_5451)
-	{
+	if (state->card->pci_id != PCI_DEVICE_ID_ALI_5451) {
 		spin_lock_irqsave(&state->card->lock, flags);
 		dmabuf->swptr += len;
 		dmabuf->count += len;
@@ -1404,7 +1482,8 @@ static void trident_clear_tail(struct tr
 	start_dac(state);
 }
 
-static int drain_dac(struct trident_state *state, int nonblock)
+static int
+drain_dac(struct trident_state *state, int nonblock)
 {
 	DECLARE_WAITQUEUE(wait, current);
 	struct dmabuf *dmabuf = &state->dmabuf;
@@ -1440,19 +1519,16 @@ static int drain_dac(struct trident_stat
 
 		/* No matter how much data is left in the buffer, we have to wait until
 		   CSO == ESO/2 or CSO == ESO when address engine interrupts */
-	 	if (state->card->pci_id == PCI_DEVICE_ID_ALI_5451 ||
-		    state->card->pci_id == PCI_DEVICE_ID_INTERG_5050)
-		{	
-			diff = dmabuf->swptr - trident_get_dma_addr(state) + dmabuf->dmasize ;
+		if (state->card->pci_id == PCI_DEVICE_ID_ALI_5451 || 
+		    state->card->pci_id == PCI_DEVICE_ID_INTERG_5050) {
+			diff = dmabuf->swptr - trident_get_dma_addr(state) + dmabuf->dmasize;
 			diff = diff % (dmabuf->dmasize);
-			tmo  = (diff * HZ) / dmabuf->rate;
-		}
-		else
-		{
+			tmo = (diff * HZ) / dmabuf->rate;
+		} else {
 			tmo = (dmabuf->dmasize * HZ) / dmabuf->rate;
 		}
 		tmo >>= sample_shift[dmabuf->fmt];
-		if (!schedule_timeout(tmo ? tmo : 1) && tmo){
+		if (!schedule_timeout(tmo ? tmo : 1) && tmo) {
 			break;
 		}
 	}
@@ -1464,8 +1540,10 @@ static int drain_dac(struct trident_stat
 	return 0;
 }
 
-/* update buffer manangement pointers, especially, dmabuf->count and dmabuf->hwptr */
-static void trident_update_ptr(struct trident_state *state)
+/* update buffer manangement pointers, especially, */ 
+/* dmabuf->count and dmabuf->hwptr */
+static void
+trident_update_ptr(struct trident_state *state)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 	unsigned hwptr, swptr;
@@ -1484,19 +1562,21 @@ static void trident_update_ptr(struct tr
 	if (dmabuf->enable == ADC_RUNNING) {
 		if (dmabuf->mapped) {
 			dmabuf->count -= diff;
-			if (dmabuf->count >= (signed)dmabuf->fragsize)
+			if (dmabuf->count >= (signed) dmabuf->fragsize)
 				wake_up(&dmabuf->wait);
 		} else {
 			dmabuf->count += diff;
 
-			if (dmabuf->count < 0 || dmabuf->count > dmabuf->dmasize) {
-				/* buffer underrun or buffer overrun, we have no way to recover
-				   it here, just stop the machine and let the process force hwptr
-				   and swptr to sync */
+			if (dmabuf->count < 0 || 
+			    dmabuf->count > dmabuf->dmasize) {
+				/* buffer underrun or buffer overrun, */ 
+				/* we have no way to recover it here, just */ 
+				/* stop the machine and let the process */ 
+				/* force hwptr and swptr to sync */
 				__stop_adc(state);
 				dmabuf->error++;
 			}
-			if (dmabuf->count < (signed)dmabuf->dmasize/2)
+			if (dmabuf->count < (signed) dmabuf->dmasize / 2)
 				wake_up(&dmabuf->wait);
 		}
 	}
@@ -1505,19 +1585,19 @@ static void trident_update_ptr(struct tr
 	if (dmabuf->enable == DAC_RUNNING) {
 		if (dmabuf->mapped) {
 			dmabuf->count += diff;
-			if (dmabuf->count >= (signed)dmabuf->fragsize)
+			if (dmabuf->count >= (signed) dmabuf->fragsize)
 				wake_up(&dmabuf->wait);
 		} else {
 			dmabuf->count -= diff;
 
-			if (dmabuf->count < 0 || dmabuf->count > dmabuf->dmasize) {
+			if (dmabuf->count < 0 || 
+			    dmabuf->count > dmabuf->dmasize) {
 				/* buffer underrun or buffer overrun, we have no way to recover
 				   it here, just stop the machine and let the process force hwptr
 				   and swptr to sync */
 				__stop_dac(state);
 				dmabuf->error++;
-			}
-			else if (!dmabuf->endcleared) {
+			} else if (!dmabuf->endcleared) {
 				swptr = dmabuf->swptr;
 				silence = (dmabuf->fmt & TRIDENT_FMT_16BIT ? 0 : 0x80);
 				if (dmabuf->update_flag & ALI_ADDRESS_INT_UPDATE) {
@@ -1525,26 +1605,25 @@ static void trident_update_ptr(struct tr
 					   According to 1/2 algorithm of Address Engine Interrupt,
 					   check the validation of the data of half dmasize. */
 					half_dmasize = dmabuf->dmasize / 2;
-					if ((diff = hwptr - half_dmasize) < 0 )
+					if ((diff = hwptr - half_dmasize) < 0)
 						diff = hwptr;
 					if ((dmabuf->count + diff) < half_dmasize) {
 						//there is invalid data in the end of half buffer
 						if ((clear_cnt = half_dmasize - swptr) < 0)
 							clear_cnt += half_dmasize;
 						//clear the invalid data
-						memset (dmabuf->rawbuf + swptr,
-							silence, clear_cnt);
+						memset(dmabuf->rawbuf + swptr, silence, clear_cnt);
 						if (state->chans_num == 6) {
-						clear_cnt = clear_cnt / 2;
-						swptr = swptr / 2;
-							memset (state->other_states[0]->dmabuf.rawbuf + swptr,
-								silence, clear_cnt);
-							memset (state->other_states[1]->dmabuf.rawbuf + swptr,
-								silence, clear_cnt);
-							memset (state->other_states[2]->dmabuf.rawbuf + swptr,
-								silence, clear_cnt);
-							memset (state->other_states[3]->dmabuf.rawbuf + swptr,
-								silence, clear_cnt);
+							clear_cnt = clear_cnt / 2;
+							swptr = swptr / 2;
+							memset(state->other_states[0]->dmabuf.rawbuf + swptr, 
+							       silence, clear_cnt);
+							memset(state->other_states[1]->dmabuf.rawbuf + swptr, 
+							       silence, clear_cnt);
+							memset(state->other_states[2]->dmabuf.rawbuf + swptr, 
+							       silence, clear_cnt);
+							memset(state->other_states[3]->dmabuf.rawbuf + swptr, 
+							       silence, clear_cnt);
 						}
 						dmabuf->endcleared = 1;
 					}
@@ -1552,18 +1631,18 @@ static void trident_update_ptr(struct tr
 					clear_cnt = dmabuf->fragsize;
 					if ((swptr + clear_cnt) > dmabuf->dmasize)
 						clear_cnt = dmabuf->dmasize - swptr;
-					memset (dmabuf->rawbuf + swptr, silence, clear_cnt);
+					memset(dmabuf->rawbuf + swptr, silence, clear_cnt);
 					if (state->chans_num == 6) {
 						clear_cnt = clear_cnt / 2;
 						swptr = swptr / 2;
-						memset (state->other_states[0]->dmabuf.rawbuf + swptr,
-							silence, clear_cnt);
-						memset (state->other_states[1]->dmabuf.rawbuf + swptr,
-							silence, clear_cnt);
-						memset (state->other_states[2]->dmabuf.rawbuf + swptr,
-							silence, clear_cnt);
-						memset (state->other_states[3]->dmabuf.rawbuf + swptr,
-							silence, clear_cnt);
+						memset(state->other_states[0]->dmabuf.rawbuf + swptr, 
+						       silence, clear_cnt);
+						memset(state->other_states[1]->dmabuf.rawbuf + swptr, 
+						       silence, clear_cnt);
+						memset(state->other_states[2]->dmabuf.rawbuf + swptr, 
+						       silence, clear_cnt);
+						memset(state->other_states[3]->dmabuf.rawbuf + swptr, 
+						       silence, clear_cnt);
 					}
 					dmabuf->endcleared = 1;
 				}
@@ -1571,29 +1650,30 @@ static void trident_update_ptr(struct tr
 			/* trident_update_ptr is called by interrupt handler or by process via
 			   ioctl/poll, we only wake up the waiting process when we have more
 			   than 1/2 buffer free (always true for interrupt handler) */
-			if (dmabuf->count < (signed)dmabuf->dmasize/2)
+			if (dmabuf->count < (signed) dmabuf->dmasize / 2)
 				wake_up(&dmabuf->wait);
 		}
 	}
 	dmabuf->update_flag &= ~ALI_ADDRESS_INT_UPDATE;
 }
 
-static void trident_address_interrupt(struct trident_card *card)
+static void
+trident_address_interrupt(struct trident_card *card)
 {
 	int i;
 	struct trident_state *state;
-	unsigned int channel; 
-	
+	unsigned int channel;
+
 	/* Update the pointers for all channels we are running. */
 	/* FIXME: should read interrupt status only once */
 	for (i = 0; i < NR_HW_CH; i++) {
-		channel = 63 - i; 
+		channel = 63 - i;
 		if (trident_check_channel_interrupt(card, channel)) {
 			trident_ack_channel_interrupt(card, channel);
 			if ((state = card->states[i]) != NULL) {
 				trident_update_ptr(state);
 			} else {
-				printk(KERN_WARNING "trident: spurious channel "
+				printk(KERN_WARNING "trident: spurious channel " 
 				       "irq %d.\n", channel);
 				trident_stop_voice(card, channel);
 				trident_disable_voice_irq(card, channel);
@@ -1602,7 +1682,8 @@ static void trident_address_interrupt(st
 	}
 }
 
-static void ali_hwvol_control(struct trident_card *card, int opt)
+static void
+ali_hwvol_control(struct trident_card *card, int opt)
 {
 	u16 dwTemp, volume[2], mute, diff, *pVol[2];
 
@@ -1610,7 +1691,7 @@ static void ali_hwvol_control(struct tri
 	mute = dwTemp & 0x8000;
 	volume[0] = dwTemp & 0x001f;
 	volume[1] = (dwTemp & 0x1f00) >> 8;
-	if (volume[0] < volume [1]) {
+	if (volume[0] < volume[1]) {
 		pVol[0] = &volume[0];
 		pVol[1] = &volume[1];
 	} else {
@@ -1619,10 +1700,11 @@ static void ali_hwvol_control(struct tri
 	}
 	diff = *(pVol[1]) - *(pVol[0]);
 
-	if (opt == 1) {                     // MUTE
+	if (opt == 1) {		// MUTE
 		dwTemp ^= 0x8000;
-		ali_ac97_write(card->ac97_codec[0], 0x02, dwTemp);
-	} else if (opt == 2) {   // Down
+		ali_ac97_write(card->ac97_codec[0], 
+			       0x02, dwTemp);
+	} else if (opt == 2) {	// Down
 		if (mute)
 			return;
 		if (*(pVol[1]) < 0x001f) {
@@ -1632,21 +1714,21 @@ static void ali_hwvol_control(struct tri
 		dwTemp &= 0xe0e0;
 		dwTemp |= (volume[0]) | (volume[1] << 8);
 		ali_ac97_write(card->ac97_codec[0], 0x02, dwTemp);
-		card->ac97_codec[0]->mixer_state[0] = ((32-volume[0])*25/8) | (((32-volume[1])*25/8) << 8);
-	} else if (opt == 4) {   // Up
+		card->ac97_codec[0]->mixer_state[0] = ((32 - volume[0]) * 25 / 8) | 
+			(((32 - volume[1]) * 25 / 8) << 8);
+	} else if (opt == 4) {	// Up
 		if (mute)
 			return;
-		if (*(pVol[0]) >0) {
+		if (*(pVol[0]) > 0) {
 			(*pVol[0])--;
 			*(pVol[1]) = *(pVol[0]) + diff;
 		}
 		dwTemp &= 0xe0e0;
 		dwTemp |= (volume[0]) | (volume[1] << 8);
 		ali_ac97_write(card->ac97_codec[0], 0x02, dwTemp);
-		card->ac97_codec[0]->mixer_state[0] = ((32-volume[0])*25/8) | (((32-volume[1])*25/8) << 8);
-	} 
-	else 
-	{
+		card->ac97_codec[0]->mixer_state[0] = ((32 - volume[0]) * 25 / 8) | 
+			(((32 - volume[1]) * 25 / 8) << 8);
+	} else {
 		/* Nothing needs doing */
 	}
 }
@@ -1655,12 +1737,13 @@ static void ali_hwvol_control(struct tri
  *	Re-enable reporting of vol change after 0.1 seconds
  */
 
-static void ali_timeout(unsigned long ptr)
+static void
+ali_timeout(unsigned long ptr)
 {
-	struct trident_card *card = (struct trident_card *)ptr;
+	struct trident_card *card = (struct trident_card *) ptr;
 	u16 temp = 0;
 
-	/* Enable GPIO IRQ (MISCINT bit 18h)*/
+	/* Enable GPIO IRQ (MISCINT bit 18h) */
 	temp = inw(TRID_REG(card, T4D_MISCINT + 2));
 	temp |= 0x0004;
 	outw(temp, TRID_REG(card, T4D_MISCINT + 2));
@@ -1669,62 +1752,65 @@ static void ali_timeout(unsigned long pt
 /*
  *	Set up the timer to clear the vol change notification
  */
- 
-static void ali_set_timer(struct trident_card *card)
+
+static void
+ali_set_timer(struct trident_card *card)
 {
 	/* Add Timer Routine to Enable GPIO IRQ */
 	del_timer(&card->timer);	/* Never queue twice */
 	card->timer.function = ali_timeout;
 	card->timer.data = (unsigned long) card;
-	card->timer.expires = jiffies + HZ/10;
+	card->timer.expires = jiffies + HZ / 10;
 	add_timer(&card->timer);
 }
 
 /*
  *	Process a GPIO event
  */
- 
-static void ali_queue_task(struct trident_card *card, int opt)
+
+static void
+ali_queue_task(struct trident_card *card, int opt)
 {
 	u16 temp;
 
-	/* Disable GPIO IRQ (MISCINT bit 18h)*/
+	/* Disable GPIO IRQ (MISCINT bit 18h) */
 	temp = inw(TRID_REG(card, T4D_MISCINT + 2));
-	temp &= (u16)(~0x0004);
+	temp &= (u16) (~0x0004);
 	outw(temp, TRID_REG(card, T4D_MISCINT + 2));
 
 	/* Adjust the volume */
 	ali_hwvol_control(card, opt);
-	
+
 	/* Set the timer for 1/10th sec */
 	ali_set_timer(card);
 }
 
-static void cyber_address_interrupt(struct trident_card *card)
+static void
+cyber_address_interrupt(struct trident_card *card)
 {
-	int i,irq_status;
+	int i, irq_status;
 	struct trident_state *state;
-	unsigned int channel; 
+	unsigned int channel;
 
 	/* Update the pointers for all channels we are running. */
 	/* FIXED: read interrupt status only once */
-	irq_status=inl(TRID_REG(card, T4D_AINT_A) );
+	irq_status = inl(TRID_REG(card, T4D_AINT_A));
 
-	TRDBG("cyber_address_interrupt: irq_status 0x%X\n",irq_status);
+	pr_debug("cyber_address_interrupt: irq_status 0x%X\n", irq_status);
 
 	for (i = 0; i < NR_HW_CH; i++) {
-		channel = 31 - i; 
-		if (irq_status & ( 1 << channel) ) {
-			/* clear bit by writing a 1, zeroes are ignored */ 		
-			outl( (1 << channel), TRID_REG(card, T4D_AINT_A));
-		
-			TRDBG("cyber_interrupt: channel %d\n", channel);
+		channel = 31 - i;
+		if (irq_status & (1 << channel)) {
+			/* clear bit by writing a 1, zeroes are ignored */
+			outl((1 << channel), TRID_REG(card, T4D_AINT_A));
+
+			pr_debug("cyber_interrupt: channel %d\n", channel);
 
 			if ((state = card->states[i]) != NULL) {
 				trident_update_ptr(state);
 			} else {
-				printk(KERN_WARNING "cyber5050: spurious "
-				       "channel irq %d.\n", channel); 
+				printk(KERN_WARNING "cyber5050: spurious " 
+				       "channel irq %d.\n", channel);
 				trident_stop_voice(card, channel);
 				trident_disable_voice_irq(card, channel);
 			}
@@ -1732,46 +1818,50 @@ static void cyber_address_interrupt(stru
 	}
 }
 
-static irqreturn_t trident_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t
+trident_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	struct trident_card *card = (struct trident_card *)dev_id;
+	struct trident_card *card = (struct trident_card *) dev_id;
 	u32 event;
 	u32 gpio;
 
 	spin_lock(&card->lock);
 	event = inl(TRID_REG(card, T4D_MISCINT));
 
-	TRDBG("trident: trident_interrupt called, MISCINT = 0x%08x\n", event);
+	pr_debug("trident: trident_interrupt called, MISCINT = 0x%08x\n",
+		 event);
 
 	if (event & ADDRESS_IRQ) {
 		card->address_interrupt(card);
 	}
 
-	if(card->pci_id == PCI_DEVICE_ID_ALI_5451)
-	{
+	if (card->pci_id == PCI_DEVICE_ID_ALI_5451) {
 		/* GPIO IRQ (H/W Volume Control) */
 		event = inl(TRID_REG(card, T4D_MISCINT));
-		if (event & (1<<25)) {
+		if (event & (1 << 25)) {
 			gpio = inl(TRID_REG(card, ALI_GPIO));
-			if (!timer_pending(&card->timer)) 
-				ali_queue_task(card, gpio&0x07);
+			if (!timer_pending(&card->timer))
+				ali_queue_task(card, gpio & 0x07);
 		}
 		event = inl(TRID_REG(card, T4D_MISCINT));
-		outl(event | (ST_TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW), TRID_REG(card, T4D_MISCINT));
+		outl(event | (ST_TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW), 
+		     TRID_REG(card, T4D_MISCINT));
 		spin_unlock(&card->lock);
 		return IRQ_HANDLED;
 	}
 
 	/* manually clear interrupt status, bad hardware design, blame T^2 */
-	outl((ST_TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW),
+	outl((ST_TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW), 
 	     TRID_REG(card, T4D_MISCINT));
 	spin_unlock(&card->lock);
 	return IRQ_HANDLED;
 }
 
-/* in this loop, dmabuf.count signifies the amount of data that is waiting to be copied to
-   the user's buffer.  it is filled by the dma machine and drained by this loop. */
-static ssize_t trident_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
+/* in this loop, dmabuf.count signifies the amount of data that is waiting */ 
+/* to be copied to the user's buffer.  it is filled by the dma machine and */ 
+/* drained by this loop. */
+static ssize_t
+trident_read(struct file *file, char *buffer, size_t count, loff_t * ppos)
 {
 	struct trident_state *state = (struct trident_state *)file->private_data;
 	struct dmabuf *dmabuf = &state->dmabuf;
@@ -1780,26 +1870,27 @@ static ssize_t trident_read(struct file 
 	unsigned swptr;
 	int cnt;
 
-	TRDBG("trident: trident_read called, count = %d\n", count);
+	pr_debug("trident: trident_read called, count = %d\n", count);
 
 	VALIDATE_STATE(state);
 	if (ppos != &file->f_pos)
 		return -ESPIPE;
-		
+
 	if (dmabuf->mapped)
 		return -ENXIO;
 	if (!access_ok(VERIFY_WRITE, buffer, count))
 		return -EFAULT;
-		
+
 	down(&state->sem);
-	if (!dmabuf->ready && (ret = prog_dmabuf(state, 1)))
+	if (!dmabuf->ready && (ret = prog_dmabuf_record(state)))
 		goto out;
 
 	while (count > 0) {
 		spin_lock_irqsave(&state->card->lock, flags);
 		if (dmabuf->count > (signed) dmabuf->dmasize) {
-			/* buffer overrun, we are recovering from sleep_on_timeout,
-			   resync hwptr and swptr, make process flush the buffer */
+			/* buffer overrun, we are recovering from */ 
+			/* sleep_on_timeout, resync hwptr and swptr, */ 
+			/* make process flush the buffer */
 			dmabuf->count = dmabuf->dmasize;
 			dmabuf->swptr = dmabuf->hwptr;
 		}
@@ -1813,17 +1904,19 @@ static ssize_t trident_read(struct file 
 			cnt = count;
 		if (cnt <= 0) {
 			unsigned long tmo;
-			/* buffer is empty, start the dma machine and wait for data to be
-			   recorded */
+			/* buffer is empty, start the dma machine and */ 
+			/* wait for data to be recorded */
 			start_adc(state);
 			if (file->f_flags & O_NONBLOCK) {
-				if (!ret) ret = -EAGAIN;
+				if (!ret)
+					ret = -EAGAIN;
 				goto out;
 			}
-			
+
 			up(&state->sem);
-			/* No matter how much space left in the buffer, we have to wait until
-			   CSO == ESO/2 or CSO == ESO when address engine interrupts */
+			/* No matter how much space left in the buffer, */ 
+			/* we have to wait until CSO == ESO/2 or CSO == ESO */ 
+			/* when address engine interrupts */
 			tmo = (dmabuf->dmasize * HZ) / (dmabuf->rate * 2);
 			tmo >>= sample_shift[dmabuf->fmt];
 			/* There are two situations when sleep_on_timeout returns, one is when
@@ -1834,22 +1927,22 @@ static ssize_t trident_read(struct file 
 			   which results in a (potential) buffer overrun. And worse, there is
 			   NOTHING we can do to prevent it. */
 			if (!interruptible_sleep_on_timeout(&dmabuf->wait, tmo)) {
-				TRDBG(KERN_ERR "trident: recording schedule timeout, "
-				      "dmasz %u fragsz %u count %i hwptr %u swptr %u\n",
-				      dmabuf->dmasize, dmabuf->fragsize, dmabuf->count,
-				      dmabuf->hwptr, dmabuf->swptr);
+				pr_debug(KERN_ERR "trident: recording schedule timeout, "
+					 "dmasz %u fragsz %u count %i hwptr %u swptr %u\n",
+					 dmabuf->dmasize, dmabuf->fragsize, dmabuf->count,
+					 dmabuf->hwptr, dmabuf->swptr);
 
 				/* a buffer overrun, we delay the recovery until next time the
 				   while loop begin and we REALLY have space to record */
 			}
 			if (signal_pending(current)) {
-				if(!ret) ret = -ERESTARTSYS;
+				if (!ret)
+					ret = -ERESTARTSYS;
 				goto out;
 			}
 			down(&state->sem);
-			if(dmabuf->mapped)
-			{
-				if(!ret)
+			if (dmabuf->mapped) {
+				if (!ret)
 					ret = -ENXIO;
 				goto out;
 			}
@@ -1857,7 +1950,8 @@ static ssize_t trident_read(struct file 
 		}
 
 		if (copy_to_user(buffer, dmabuf->rawbuf + swptr, cnt)) {
-			if (!ret) ret = -EFAULT;
+			if (!ret)
+				ret = -EFAULT;
 			goto out;
 		}
 
@@ -1881,7 +1975,8 @@ out:
 /* in this loop, dmabuf.count signifies the amount of data that is waiting to be dma to
    the soundcard.  it is drained by the dma machine and filled by this loop. */
 
-static ssize_t trident_write(struct file *file, const char *buffer, size_t count, loff_t *ppos)
+static ssize_t
+trident_write(struct file *file, const char *buffer, size_t count, loff_t * ppos)
 {
 	struct trident_state *state = (struct trident_state *)file->private_data;
 	struct dmabuf *dmabuf = &state->dmabuf;
@@ -1891,40 +1986,39 @@ static ssize_t trident_write(struct file
 	int cnt;
 	unsigned int state_cnt;
 	unsigned int copy_count;
+	int lret; /* for lock_set_fmt */
 
-	TRDBG("trident: trident_write called, count = %d\n", count);
+	pr_debug("trident: trident_write called, count = %d\n", count);
 
 	VALIDATE_STATE(state);
 	if (ppos != &file->f_pos)
 		return -ESPIPE;
-	
+
 	/*
-	 *	Guard against an mmap or ioctl while writing
-	 */	
-	 
+	 *      Guard against an mmap or ioctl while writing
+	 */
+
 	down(&state->sem);
-	
-	if (dmabuf->mapped)
-	{
+
+	if (dmabuf->mapped) {
 		ret = -ENXIO;
 		goto out;
 	}
-	if (!dmabuf->ready && (ret = prog_dmabuf(state, 0)))
+	if (!dmabuf->ready && (ret = prog_dmabuf_playback(state)))
 		goto out;
 
-	if (!access_ok(VERIFY_READ, buffer, count))
-	{
-		ret= -EFAULT;
+	if (!access_ok(VERIFY_READ, buffer, count)) {
+		ret = -EFAULT;
 		goto out;
 	}
-	
+
 	ret = 0;
 
 	while (count > 0) {
 		spin_lock_irqsave(&state->card->lock, flags);
 		if (dmabuf->count < 0) {
-			/* buffer underrun, we are recovering from sleep_on_timeout,
-			   resync hwptr and swptr */
+			/* buffer underrun, we are recovering from */ 
+			/* sleep_on_timeout, resync hwptr and swptr */
 			dmabuf->count = 0;
 			dmabuf->swptr = dmabuf->hwptr;
 		}
@@ -1938,56 +2032,68 @@ static ssize_t trident_write(struct file
 			cnt = count;
 		if (cnt <= 0) {
 			unsigned long tmo;
-			/* buffer is full, start the dma machine and wait for data to be
-			   played */
+			/* buffer is full, start the dma machine and */ 
+			/* wait for data to be played */
 			start_dac(state);
 			if (file->f_flags & O_NONBLOCK) {
-				if (!ret) ret = -EAGAIN;
+				if (!ret)
+					ret = -EAGAIN;
 				goto out;
 			}
-			/* No matter how much data left in the buffer, we have to wait until
-			   CSO == ESO/2 or CSO == ESO when address engine interrupts */
+			/* No matter how much data left in the buffer, */ 
+			/* we have to wait until CSO == ESO/2 or CSO == ESO */ 
+			/* when address engine interrupts */
 			lock_set_fmt(state);
 			tmo = (dmabuf->dmasize * HZ) / (dmabuf->rate * 2);
 			tmo >>= sample_shift[dmabuf->fmt];
 			unlock_set_fmt(state);
 			up(&state->sem);
-			
-			/* There are two situations when sleep_on_timeout returns, one is when
-			   the interrupt is serviced correctly and the process is waked up by
-			   ISR ON TIME. Another is when timeout is expired, which means that
-			   either interrupt is NOT serviced correctly (pending interrupt) or it
-			   is TOO LATE for the process to be scheduled to run (scheduler latency)
-			   which results in a (potential) buffer underrun. And worse, there is
-			   NOTHING we can do to prevent it. */
-			if (!interruptible_sleep_on_timeout(&dmabuf->wait, tmo)) {
-				TRDBG(KERN_ERR "trident: playback schedule timeout, "
-				      "dmasz %u fragsz %u count %i hwptr %u swptr %u\n",
-				      dmabuf->dmasize, dmabuf->fragsize, dmabuf->count,
-				      dmabuf->hwptr, dmabuf->swptr);
 
-				/* a buffer underrun, we delay the recovery until next time the
-				   while loop begin and we REALLY have data to play */
+			/* There are two situations when sleep_on_timeout */ 
+			/* returns, one is when the interrupt is serviced */ 
+			/* correctly and the process is waked up by ISR */ 
+			/* ON TIME. Another is when timeout is expired, which */ 
+			/* means that either interrupt is NOT serviced */ 
+			/* correctly (pending interrupt) or it is TOO LATE */ 
+			/* for the process to be scheduled to run */ 
+			/* (scheduler latency) which results in a (potential) */ 
+			/* buffer underrun. And worse, there is NOTHING we */ 
+			/* can do to prevent it. */
+			if (!interruptible_sleep_on_timeout(&dmabuf->wait, tmo)) {
+				pr_debug(KERN_ERR "trident: playback schedule "
+					 "timeout, dmasz %u fragsz %u count %i "
+					 "hwptr %u swptr %u\n", dmabuf->dmasize,
+					 dmabuf->fragsize, dmabuf->count,
+					 dmabuf->hwptr, dmabuf->swptr);
+
+				/* a buffer underrun, we delay the recovery */ 
+				/* until next time the while loop begin and */ 
+				/* we REALLY have data to play */
 			}
 			if (signal_pending(current)) {
-				if (!ret) ret = -ERESTARTSYS;
-				goto out;
+				if (!ret)
+					ret = -ERESTARTSYS;
+				goto out_nolock;
 			}
 			down(&state->sem);
-			if(dmabuf->mapped)
-			{
-				if(!ret)
+			if (dmabuf->mapped) {
+				if (!ret)
 					ret = -ENXIO;
 				goto out;
 			}
 			continue;
 		}
-		lock_set_fmt(state);
+		if ((lret = lock_set_fmt(state)) < 0) {
+			ret = lret;
+			goto out;
+		}
+
 		if (state->chans_num == 6) {
 			copy_count = 0;
 			state_cnt = 0;
-			if (ali_write_5_1(state, buffer, cnt, &copy_count, &state_cnt) == -EFAULT) {
-				if (state_cnt){
+			if (ali_write_5_1(state, buffer, cnt, &copy_count, 
+					  &state_cnt) == -EFAULT) {
+				if (state_cnt) {
 					swptr = (swptr + state_cnt) % dmabuf->dmasize;
 					spin_lock_irqsave(&state->card->lock, flags);
 					dmabuf->swptr = swptr;
@@ -1996,23 +2102,25 @@ static ssize_t trident_write(struct file
 					spin_unlock_irqrestore(&state->card->lock, flags);
 				}
 				ret += copy_count;
-				if (!ret) ret = -EFAULT;
+				if (!ret)
+					ret = -EFAULT;
 				unlock_set_fmt(state);
 				goto out;
 			}
-		}
-		else {
-			if (copy_from_user(dmabuf->rawbuf + swptr, buffer, cnt)) {
-				if (!ret) ret = -EFAULT;
+		} else {
+			if (copy_from_user(dmabuf->rawbuf + swptr, 
+					   buffer, cnt)) {
+				if (!ret)
+					ret = -EFAULT;
 				unlock_set_fmt(state);
 				goto out;
 			}
 			state_cnt = cnt;
 		}
 		unlock_set_fmt(state);
-		
-		swptr = (swptr + state_cnt) % dmabuf->dmasize;		
-		
+
+		swptr = (swptr + state_cnt) % dmabuf->dmasize;
+
 		spin_lock_irqsave(&state->card->lock, flags);
 		dmabuf->swptr = swptr;
 		dmabuf->count += state_cnt;
@@ -2020,18 +2128,19 @@ static ssize_t trident_write(struct file
 		spin_unlock_irqrestore(&state->card->lock, flags);
 
 		count -= cnt;
-		buffer += cnt;	
+		buffer += cnt;
 		ret += cnt;
 		start_dac(state);
 	}
 out:
 	up(&state->sem);
+out_nolock:
 	return ret;
 }
 
-
 /* No kernel lock - we have our own spinlock */
-static unsigned int trident_poll(struct file *file, struct poll_table_struct *wait)
+static unsigned int
+trident_poll(struct file *file, struct poll_table_struct *wait)
 {
 	struct trident_state *state = (struct trident_state *)file->private_data;
 	struct dmabuf *dmabuf = &state->dmabuf;
@@ -2041,23 +2150,21 @@ static unsigned int trident_poll(struct 
 	VALIDATE_STATE(state);
 
 	/*
-	 *	Guard against a parallel poll and write causing multiple
-	 *	prog_dmabuf events
+	 *      Guard against a parallel poll and write causing multiple
+	 *      prog_dmabuf events
 	 */
-	 
+
 	down(&state->sem);
 
 	if (file->f_mode & FMODE_WRITE) {
-		if (!dmabuf->ready && prog_dmabuf(state, 0))
-		{
+		if (!dmabuf->ready && prog_dmabuf_playback(state)) {
 			up(&state->sem);
 			return 0;
 		}
 		poll_wait(file, &dmabuf->wait, wait);
 	}
 	if (file->f_mode & FMODE_READ) {
-		if (!dmabuf->ready && prog_dmabuf(state, 1))
-		{
+		if (!dmabuf->ready && prog_dmabuf_record(state)) {
 			up(&state->sem);
 			return 0;
 		}
@@ -2065,19 +2172,20 @@ static unsigned int trident_poll(struct 
 	}
 
 	up(&state->sem);
-	
+
 	spin_lock_irqsave(&state->card->lock, flags);
 	trident_update_ptr(state);
 	if (file->f_mode & FMODE_READ) {
-		if (dmabuf->count >= (signed)dmabuf->fragsize)
+		if (dmabuf->count >= (signed) dmabuf->fragsize)
 			mask |= POLLIN | POLLRDNORM;
 	}
 	if (file->f_mode & FMODE_WRITE) {
 		if (dmabuf->mapped) {
-			if (dmabuf->count >= (signed)dmabuf->fragsize)
+			if (dmabuf->count >= (signed) dmabuf->fragsize)
 				mask |= POLLOUT | POLLWRNORM;
 		} else {
-			if ((signed)dmabuf->dmasize >= dmabuf->count + (signed)dmabuf->fragsize)
+			if ((signed) dmabuf->dmasize >= dmabuf->count + 
+			    (signed) dmabuf->fragsize)
 				mask |= POLLOUT | POLLWRNORM;
 		}
 	}
@@ -2086,7 +2194,8 @@ static unsigned int trident_poll(struct 
 	return mask;
 }
 
-static int trident_mmap(struct file *file, struct vm_area_struct *vma)
+static int
+trident_mmap(struct file *file, struct vm_area_struct *vma)
 {
 	struct trident_state *state = (struct trident_state *)file->private_data;
 	struct dmabuf *dmabuf = &state->dmabuf;
@@ -2094,20 +2203,19 @@ static int trident_mmap(struct file *fil
 	unsigned long size;
 
 	VALIDATE_STATE(state);
-	lock_kernel();
-	
+
 	/*
-	 *	Lock against poll read write or mmap creating buffers. Also lock
-	 *	a read or write against an mmap.
+	 *      Lock against poll read write or mmap creating buffers. Also lock
+	 *      a read or write against an mmap.
 	 */
-	 
+
 	down(&state->sem);
-	
+
 	if (vma->vm_flags & VM_WRITE) {
-		if ((ret = prog_dmabuf(state, 0)) != 0)
+		if ((ret = prog_dmabuf_playback(state)) != 0)
 			goto out;
 	} else if (vma->vm_flags & VM_READ) {
-		if ((ret = prog_dmabuf(state, 1)) != 0)
+		if ((ret = prog_dmabuf_record(state)) != 0)
 			goto out;
 	} else
 		goto out;
@@ -2119,18 +2227,19 @@ static int trident_mmap(struct file *fil
 	if (size > (PAGE_SIZE << dmabuf->buforder))
 		goto out;
 	ret = -EAGAIN;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(dmabuf->rawbuf),
+	if (remap_page_range(vma, vma->vm_start, virt_to_phys(dmabuf->rawbuf), 
 			     size, vma->vm_page_prot))
 		goto out;
 	dmabuf->mapped = 1;
 	ret = 0;
 out:
 	up(&state->sem);
-	unlock_kernel();
 	return ret;
 }
 
-static int trident_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+static int
+trident_ioctl(struct inode *inode, struct file *file, 
+	      unsigned int cmd, unsigned long arg)
 {
 	struct trident_state *state = (struct trident_state *)file->private_data;
 	struct dmabuf *dmabuf = &state->dmabuf;
@@ -2142,17 +2251,18 @@ static int trident_ioctl(struct inode *i
 	struct trident_card *card = state->card;
 
 	VALIDATE_STATE(state);
-	mapped = ((file->f_mode & FMODE_WRITE) && dmabuf->mapped) ||
-		((file->f_mode & FMODE_READ) && dmabuf->mapped);
-	TRDBG("trident: trident_ioctl, command = %2d, arg = 0x%08x\n",
-	      _IOC_NR(cmd), arg ? *(int *)arg : 0);
 
-	switch (cmd) 
-	{
+
+	mapped = ((file->f_mode & (FMODE_WRITE | FMODE_READ)) && dmabuf->mapped);
+
+	pr_debug("trident: trident_ioctl, command = %2d, arg = 0x%08x\n",
+		 _IOC_NR(cmd), arg ? *(int *) arg : 0);
+
+	switch (cmd) {
 	case OSS_GETVERSION:
-		ret = put_user(SOUND_VERSION, (int *)arg);
+		ret = put_user(SOUND_VERSION, (int *) arg);
 		break;
-		
+
 	case SNDCTL_DSP_RESET:
 		/* FIXME: spin_lock ? */
 		if (file->f_mode & FMODE_WRITE) {
@@ -2176,9 +2286,8 @@ static int trident_ioctl(struct inode *i
 			ret = drain_dac(state, file->f_flags & O_NONBLOCK);
 		break;
 
-	case SNDCTL_DSP_SPEED: /* set smaple rate */
-		if (get_user(val, (int *)arg))
-		{
+	case SNDCTL_DSP_SPEED:	/* set smaple rate */
+		if (get_user(val, (int *) arg)) {
 			ret = -EFAULT;
 			break;
 		}
@@ -2198,16 +2307,17 @@ static int trident_ioctl(struct inode *i
 				spin_unlock_irqrestore(&state->card->lock, flags);
 			}
 		}
-		ret = put_user(dmabuf->rate, (int *)arg);
+		ret = put_user(dmabuf->rate, (int *) arg);
 		break;
 
-	case SNDCTL_DSP_STEREO: /* set stereo or mono channel */
-		if (get_user(val, (int *)arg))
-		{
+	case SNDCTL_DSP_STEREO:	/* set stereo or mono channel */
+		if (get_user(val, (int *) arg)) {
 			ret = -EFAULT;
 			break;
 		}
-		lock_set_fmt(state);
+		if ((ret = lock_set_fmt(state)) < 0)
+			return ret;
+
 		if (file->f_mode & FMODE_WRITE) {
 			stop_dac(state);
 			dmabuf->ready = 0;
@@ -2229,31 +2339,37 @@ static int trident_ioctl(struct inode *i
 
 	case SNDCTL_DSP_GETBLKSIZE:
 		if (file->f_mode & FMODE_WRITE) {
-			if ((val = prog_dmabuf(state, 0)))
+			if ((val = prog_dmabuf_playback(state)))
 				ret = val;
 			else
-				ret = put_user(dmabuf->fragsize, (int *)arg);
+				ret = put_user(dmabuf->fragsize, (int *) arg);
 			break;
 		}
 		if (file->f_mode & FMODE_READ) {
-			if ((val = prog_dmabuf(state, 1)))
+			if ((val = prog_dmabuf_record(state)))
 				ret = val;
 			else
-				ret = put_user(dmabuf->fragsize, (int *)arg);
+				ret = put_user(dmabuf->fragsize, (int *) arg);
 			break;
 		}
+		/* neither READ nor WRITE? is this even possible? */
+		ret = -EINVAL;
+		break;
+
 
-	case SNDCTL_DSP_GETFMTS: /* Returns a mask of supported sample format*/
-		ret = put_user(AFMT_S16_LE|AFMT_U16_LE|AFMT_S8|AFMT_U8, (int *)arg);
+	case SNDCTL_DSP_GETFMTS: /* Returns a mask of supported sample format */
+		ret = put_user(AFMT_S16_LE | AFMT_U16_LE | AFMT_S8 | 
+			       AFMT_U8, (int *) arg);
 		break;
 
-	case SNDCTL_DSP_SETFMT: /* Select sample format */
-		if (get_user(val, (int *)arg))
-		{
+	case SNDCTL_DSP_SETFMT:	/* Select sample format */
+		if (get_user(val, (int *) arg)) {
 			ret = -EFAULT;
 			break;
 		}
-		lock_set_fmt(state);
+		if ((ret = lock_set_fmt(state)) < 0)
+			return ret;
+
 		if (val != AFMT_QUERY) {
 			if (file->f_mode & FMODE_WRITE) {
 				stop_dac(state);
@@ -2273,39 +2389,38 @@ static int trident_ioctl(struct inode *i
 			}
 		}
 		unlock_set_fmt(state);
-		ret = put_user((dmabuf->fmt & TRIDENT_FMT_16BIT) ?
-				AFMT_S16_LE : AFMT_U8, (int *)arg);
+		ret = put_user((dmabuf->fmt & TRIDENT_FMT_16BIT) ? AFMT_S16_LE : 
+			       AFMT_U8, (int *) arg);
 		break;
 
 	case SNDCTL_DSP_CHANNELS:
-		if (get_user(val, (int *)arg))
-		{
+		if (get_user(val, (int *) arg)) {
 			ret = -EFAULT;
 			break;
 		}
 		if (val != 0) {
-			lock_set_fmt(state);
+			if ((ret = lock_set_fmt(state)) < 0)
+				return ret;
+
 			if (file->f_mode & FMODE_WRITE) {
 				stop_dac(state);
 				dmabuf->ready = 0;
-								
+
 				//prevent from memory leak
 				if ((state->chans_num > 2) && (state->chans_num != val)) {
 					ali_free_other_states_resources(state);
 					state->chans_num = 1;
 				}
-				
-				if (val >= 2)
-				{
+
+				if (val >= 2) {
 
 					dmabuf->fmt |= TRIDENT_FMT_STEREO;
 					if ((val == 6) && (state->card->pci_id == PCI_DEVICE_ID_ALI_5451)) {
-
-						if( card->rec_channel_use_count > 0 )
-						{
-							printk(KERN_ERR "trident: Record is working on the card!\n");
+						if (card->rec_channel_use_count > 0) {
+							printk(KERN_ERR "trident: Record is "
+							       "working on the card!\n");
 							ret = -EBUSY;
-							unlock_set_fmt(state); 
+							unlock_set_fmt(state);
 							break;
 						}
 
@@ -2321,12 +2436,11 @@ static int trident_ioctl(struct inode *i
 							unlock_set_fmt(state);
 							break;
 						}
-						state->card->multi_channel_use_count ++;
+						state->card->multi_channel_use_count++;
 						up(&state->card->open_sem);
-					}
-					else val = 2;	/*yield to 2-channels*/
-				}
-				else
+					} else
+						val = 2;	/*yield to 2-channels */
+				} else
 					dmabuf->fmt &= ~TRIDENT_FMT_STEREO;
 				state->chans_num = val;
 			}
@@ -2334,17 +2448,17 @@ static int trident_ioctl(struct inode *i
 				stop_adc(state);
 				dmabuf->ready = 0;
 				if (val >= 2) {
-					if (!((file->f_mode & FMODE_WRITE) && (val == 6)))
+					if (!((file->f_mode & FMODE_WRITE) && 
+					      (val == 6)))
 						val = 2;
 					dmabuf->fmt |= TRIDENT_FMT_STEREO;
-				}
-				else
+				} else
 					dmabuf->fmt &= ~TRIDENT_FMT_STEREO;
 				state->chans_num = val;
 			}
 			unlock_set_fmt(state);
 		}
-		ret = put_user(val, (int *)arg);
+		ret = put_user(val, (int *) arg);
 		break;
 
 	case SNDCTL_DSP_POST:
@@ -2352,18 +2466,15 @@ static int trident_ioctl(struct inode *i
 		break;
 
 	case SNDCTL_DSP_SUBDIVIDE:
-		if (dmabuf->subdivision)
-		{
+		if (dmabuf->subdivision) {
 			ret = -EINVAL;
 			break;
 		}
-		if (get_user(val, (int *)arg))
-		{
+		if (get_user(val, (int *) arg)) {
 			ret = -EFAULT;
 			break;
 		}
-		if (val != 1 && val != 2 && val != 4)
-		{
+		if (val != 1 && val != 2 && val != 4) {
 			ret = -EINVAL;
 			break;
 		}
@@ -2371,8 +2482,7 @@ static int trident_ioctl(struct inode *i
 		break;
 
 	case SNDCTL_DSP_SETFRAGMENT:
-		if (get_user(val, (int *)arg))
-		{
+		if (get_user(val, (int *) arg)) {
 			ret = -EFAULT;
 			break;
 		}
@@ -2389,13 +2499,11 @@ static int trident_ioctl(struct inode *i
 		break;
 
 	case SNDCTL_DSP_GETOSPACE:
-		if (!(file->f_mode & FMODE_WRITE))
-		{
+		if (!(file->f_mode & FMODE_WRITE)) {
 			ret = -EINVAL;
 			break;
 		}
-		if (!dmabuf->ready && (val = prog_dmabuf(state, 0)) != 0)
-		{ 
+		if (!dmabuf->ready && (val = prog_dmabuf_playback(state)) != 0) {
 			ret = val;
 			break;
 		}
@@ -2406,17 +2514,16 @@ static int trident_ioctl(struct inode *i
 		abinfo.fragstotal = dmabuf->numfrag;
 		abinfo.fragments = abinfo.bytes >> dmabuf->fragshift;
 		spin_unlock_irqrestore(&state->card->lock, flags);
-		ret = copy_to_user((void *)arg, &abinfo, sizeof(abinfo)) ? -EFAULT : 0;
+		ret = copy_to_user((void *) arg, &abinfo, sizeof (abinfo)) ? 
+			-EFAULT : 0;
 		break;
 
 	case SNDCTL_DSP_GETISPACE:
-		if (!(file->f_mode & FMODE_READ))
-		{
+		if (!(file->f_mode & FMODE_READ)) {
 			ret = -EINVAL;
 			break;
 		}
-		if (!dmabuf->ready && (val = prog_dmabuf(state, 1)) != 0)
-		{
+		if (!dmabuf->ready && (val = prog_dmabuf_record(state)) != 0) {
 			ret = val;
 			break;
 		}
@@ -2427,7 +2534,8 @@ static int trident_ioctl(struct inode *i
 		abinfo.fragstotal = dmabuf->numfrag;
 		abinfo.fragments = abinfo.bytes >> dmabuf->fragshift;
 		spin_unlock_irqrestore(&state->card->lock, flags);
-		ret = copy_to_user((void *)arg, &abinfo, sizeof(abinfo)) ? -EFAULT : 0;
+		ret = copy_to_user((void *) arg, &abinfo, sizeof (abinfo)) ? 
+			-EFAULT : 0;
 		break;
 
 	case SNDCTL_DSP_NONBLOCK:
@@ -2435,8 +2543,8 @@ static int trident_ioctl(struct inode *i
 		break;
 
 	case SNDCTL_DSP_GETCAPS:
-		ret = put_user(DSP_CAP_REALTIME|DSP_CAP_TRIGGER|DSP_CAP_MMAP|DSP_CAP_BIND,
-			    (int *)arg);
+		ret = put_user(DSP_CAP_REALTIME | DSP_CAP_TRIGGER | 
+			       DSP_CAP_MMAP | DSP_CAP_BIND, (int *) arg);
 		break;
 
 	case SNDCTL_DSP_GETTRIGGER:
@@ -2445,18 +2553,18 @@ static int trident_ioctl(struct inode *i
 			val |= PCM_ENABLE_INPUT;
 		if ((file->f_mode & FMODE_WRITE) && dmabuf->enable)
 			val |= PCM_ENABLE_OUTPUT;
-		ret = put_user(val, (int *)arg);
+		ret = put_user(val, (int *) arg);
 		break;
 
 	case SNDCTL_DSP_SETTRIGGER:
-		if (get_user(val, (int *)arg))
-		{
+		if (get_user(val, (int *) arg)) {
 			ret = -EFAULT;
 			break;
 		}
 		if (file->f_mode & FMODE_READ) {
 			if (val & PCM_ENABLE_INPUT) {
-				if (!dmabuf->ready && (ret = prog_dmabuf(state, 1)))
+				if (!dmabuf->ready && 
+				    (ret = prog_dmabuf_record(state)))
 					break;
 				start_adc(state);
 			} else
@@ -2464,7 +2572,8 @@ static int trident_ioctl(struct inode *i
 		}
 		if (file->f_mode & FMODE_WRITE) {
 			if (val & PCM_ENABLE_OUTPUT) {
-				if (!dmabuf->ready && (ret = prog_dmabuf(state, 0)))
+				if (!dmabuf->ready && 
+				    (ret = prog_dmabuf_playback(state)))
 					break;
 				start_dac(state);
 			} else
@@ -2473,13 +2582,12 @@ static int trident_ioctl(struct inode *i
 		break;
 
 	case SNDCTL_DSP_GETIPTR:
-		if (!(file->f_mode & FMODE_READ))
-		{
+		if (!(file->f_mode & FMODE_READ)) {
 			ret = -EINVAL;
 			break;
 		}
-		if (!dmabuf->ready && (val = prog_dmabuf(state, 1)) != 0)
-		{
+		if (!dmabuf->ready && (val = prog_dmabuf_record(state))
+		    != 0) {
 			ret = val;
 			break;
 		}
@@ -2489,32 +2597,33 @@ static int trident_ioctl(struct inode *i
 		cinfo.blocks = dmabuf->count >> dmabuf->fragshift;
 		cinfo.ptr = dmabuf->hwptr;
 		if (dmabuf->mapped)
-			dmabuf->count &= dmabuf->fragsize-1;
+			dmabuf->count &= dmabuf->fragsize - 1;
 		spin_unlock_irqrestore(&state->card->lock, flags);
-		ret = copy_to_user((void *)arg, &cinfo, sizeof(cinfo))?-EFAULT:0;
+		ret = copy_to_user((void *) arg, &cinfo, sizeof (cinfo)) ? 
+			-EFAULT : 0;
 		break;
 
 	case SNDCTL_DSP_GETOPTR:
-		if (!(file->f_mode & FMODE_WRITE))
-		{
+		if (!(file->f_mode & FMODE_WRITE)) {
 			ret = -EINVAL;
 			break;
 		}
-		if (!dmabuf->ready && (val = prog_dmabuf(state, 0)) != 0)
-		{
+		if (!dmabuf->ready && (val = prog_dmabuf_playback(state))
+		    != 0) {
 			ret = val;
 			break;
 		}
-		
+
 		spin_lock_irqsave(&state->card->lock, flags);
 		trident_update_ptr(state);
 		cinfo.bytes = dmabuf->total_bytes;
 		cinfo.blocks = dmabuf->count >> dmabuf->fragshift;
 		cinfo.ptr = dmabuf->hwptr;
 		if (dmabuf->mapped)
-			dmabuf->count &= dmabuf->fragsize-1;
+			dmabuf->count &= dmabuf->fragsize - 1;
 		spin_unlock_irqrestore(&state->card->lock, flags);
-		ret = copy_to_user((void *)arg, &cinfo, sizeof(cinfo))?-EFAULT:0;
+		ret = copy_to_user((void *) arg, &cinfo, sizeof (cinfo)) ? 
+			-EFAULT : 0;
 		break;
 
 	case SNDCTL_DSP_SETDUPLEX:
@@ -2522,13 +2631,11 @@ static int trident_ioctl(struct inode *i
 		break;
 
 	case SNDCTL_DSP_GETODELAY:
-		if (!(file->f_mode & FMODE_WRITE))
-		{
+		if (!(file->f_mode & FMODE_WRITE)) {
 			ret = -EINVAL;
 			break;
 		}
-		if (!dmabuf->ready && (val = prog_dmabuf(state, 0)) != 0)
-		{
+		if (!dmabuf->ready && (val = prog_dmabuf_playback(state)) != 0) {
 			ret = val;
 			break;
 		}
@@ -2536,37 +2643,35 @@ static int trident_ioctl(struct inode *i
 		trident_update_ptr(state);
 		val = dmabuf->count;
 		spin_unlock_irqrestore(&state->card->lock, flags);
-		ret = put_user(val, (int *)arg);
+		ret = put_user(val, (int *) arg);
 		break;
 
 	case SOUND_PCM_READ_RATE:
-		ret = put_user(dmabuf->rate, (int *)arg);
+		ret = put_user(dmabuf->rate, (int *) arg);
 		break;
 
 	case SOUND_PCM_READ_CHANNELS:
-		ret = put_user((dmabuf->fmt & TRIDENT_FMT_STEREO) ? 2 : 1,
-				(int *)arg);
+		ret = put_user((dmabuf->fmt & TRIDENT_FMT_STEREO) ? 2 : 1, 
+			       (int *) arg);
 		break;
 
 	case SOUND_PCM_READ_BITS:
-		ret = put_user((dmabuf->fmt & TRIDENT_FMT_16BIT) ?
-				AFMT_S16_LE : AFMT_U8, (int *)arg);
+		ret = put_user((dmabuf->fmt & TRIDENT_FMT_16BIT) ? AFMT_S16_LE : 
+			       AFMT_U8, (int *) arg);
 		break;
 
 	case SNDCTL_DSP_GETCHANNELMASK:
-		ret = put_user(DSP_BIND_FRONT|DSP_BIND_SURR|DSP_BIND_CENTER_LFE,
-				(int *)arg);
+		ret = put_user(DSP_BIND_FRONT | DSP_BIND_SURR | 
+			       DSP_BIND_CENTER_LFE,  (int *) arg);
 		break;
 
 	case SNDCTL_DSP_BIND_CHANNEL:
-		if (state->card->pci_id != PCI_DEVICE_ID_SI_7018)
-		{
+		if (state->card->pci_id != PCI_DEVICE_ID_SI_7018) {
 			ret = -EINVAL;
 			break;
 		}
 
-		if (get_user(val, (int *)arg))
-		{
+		if (get_user(val, (int *) arg)) {
 			ret = -EFAULT;
 			break;
 		}
@@ -2576,12 +2681,14 @@ static int trident_ioctl(struct inode *i
 		} else {
 			dmabuf->ready = 0;
 			if (file->f_mode & FMODE_READ)
-				dmabuf->channel->attribute = (CHANNEL_REC|SRC_ENABLE);
+				dmabuf->channel->attribute = (CHANNEL_REC | 
+							      SRC_ENABLE);
 			if (file->f_mode & FMODE_WRITE)
-				dmabuf->channel->attribute = (CHANNEL_SPC_PB|SRC_ENABLE);
+				dmabuf->channel->attribute = (CHANNEL_SPC_PB | 
+							      SRC_ENABLE);
 			dmabuf->channel->attribute |= mask2attr[ffs(val)];
 		}
-		ret = put_user(val, (int *)arg);
+		ret = put_user(val, (int *) arg);
 		break;
 
 	case SNDCTL_DSP_MAPINBUF:
@@ -2592,23 +2699,27 @@ static int trident_ioctl(struct inode *i
 	default:
 		ret = -EINVAL;
 		break;
-		
+
 	}
 	return ret;
 }
 
-static int trident_open(struct inode *inode, struct file *file)
+static int
+trident_open(struct inode *inode, struct file *file)
 {
 	int i = 0;
 	int minor = iminor(inode);
 	struct trident_card *card = devs;
 	struct trident_state *state = NULL;
 	struct dmabuf *dmabuf = NULL;
-	
+
 	/* Added by Matt Wu 01-05-2001 */
-	if(file->f_mode & FMODE_READ)
-	{
-		if(card->pci_id == PCI_DEVICE_ID_ALI_5451) {
+	/* TODO: there's some redundacy here wrt the check below */
+	/* for multi_use_count > 0. Should we return -EBUSY or find */
+	/* a different card? for now, don't break current behaviour */
+	/* -- mulix */
+	if (file->f_mode & FMODE_READ) {
+		if (card->pci_id == PCI_DEVICE_ID_ALI_5451) {
 			if (card->multi_channel_use_count > 0)
 				return -EBUSY;
 		}
@@ -2617,11 +2728,9 @@ static int trident_open(struct inode *in
 	/* find an available virtual channel (instance of /dev/dsp) */
 	while (card != NULL) {
 		down(&card->open_sem);
-		if(file->f_mode & FMODE_READ)
-		{
+		if (file->f_mode & FMODE_READ) {
 			/* Skip opens on cards that are in 6 channel mode */
-			if (card->multi_channel_use_count > 0)
-			{
+			if (card->multi_channel_use_count > 0) {
 				up(&card->open_sem);
 				card = card->next;
 				continue;
@@ -2629,12 +2738,12 @@ static int trident_open(struct inode *in
 		}
 		for (i = 0; i < NR_HW_CH; i++) {
 			if (card->states[i] == NULL) {
-				state = card->states[i] = (struct trident_state *)
-					kmalloc(sizeof(struct trident_state), GFP_KERNEL);
+				state = card->states[i] = kmalloc(sizeof(*state), GFP_KERNEL);
 				if (state == NULL) {
+					up(&card->open_sem);
 					return -ENOMEM;
 				}
-				memset(state, 0, sizeof(struct trident_state));
+				memset(state, 0, sizeof(*state));
 				init_MUTEX(&state->sem);
 				dmabuf = &state->dmabuf;
 				goto found_virt;
@@ -2647,15 +2756,15 @@ static int trident_open(struct inode *in
 	if (!state) {
 		return -ENODEV;
 	}
- found_virt:
+      found_virt:
 	/* found a free virtual channel, allocate hardware channels */
-	if(file->f_mode & FMODE_READ)
+	if (file->f_mode & FMODE_READ)
 		dmabuf->channel = card->alloc_rec_pcm_channel(card);
 	else
 		dmabuf->channel = card->alloc_pcm_channel(card);
-		
+
 	if (dmabuf->channel == NULL) {
-		kfree (card->states[i]);
+		kfree(card->states[i]);
 		card->states[i] = NULL;
 		return -ENODEV;
 	}
@@ -2667,16 +2776,16 @@ static int trident_open(struct inode *in
 	init_waitqueue_head(&dmabuf->wait);
 	file->private_data = state;
 
-	/* set default sample format. According to OSS Programmer's Guide  /dev/dsp
-	   should be default to unsigned 8-bits, mono, with sample rate 8kHz and
-	   /dev/dspW will accept 16-bits sample */
+	/* set default sample format. According to OSS Programmer's */ 
+	/* Guide  /dev/dsp should be default to unsigned 8-bits, mono, */ 
+	/* with sample rate 8kHz and /dev/dspW will accept 16-bits sample */
 	if (file->f_mode & FMODE_WRITE) {
 		dmabuf->fmt &= ~TRIDENT_FMT_MASK;
 		if ((minor & 0x0f) == SND_DEV_DSP16)
 			dmabuf->fmt |= TRIDENT_FMT_16BIT;
 		dmabuf->ossfragshift = 0;
-		dmabuf->ossmaxfrags  = 0;
-		dmabuf->subdivision  = 0;
+		dmabuf->ossmaxfrags = 0;
+		dmabuf->subdivision = 0;
 		if (card->pci_id == PCI_DEVICE_ID_SI_7018) {
 			/* set default channel attribute to normal playback */
 			dmabuf->channel->attribute = CHANNEL_PB;
@@ -2685,54 +2794,55 @@ static int trident_open(struct inode *in
 	}
 
 	if (file->f_mode & FMODE_READ) {
-		/* FIXME: Trident 4d can only record in signed 16-bits stereo, 48kHz sample,
-		   to be dealed with in trident_set_adc_rate() ?? */
+		/* FIXME: Trident 4d can only record in signed 16-bits stereo, */ 
+		/* 48kHz sample, to be dealed with in trident_set_adc_rate() ?? */
 		dmabuf->fmt &= ~TRIDENT_FMT_MASK;
 		if ((minor & 0x0f) == SND_DEV_DSP16)
 			dmabuf->fmt |= TRIDENT_FMT_16BIT;
 		dmabuf->ossfragshift = 0;
-		dmabuf->ossmaxfrags  = 0;
-		dmabuf->subdivision  = 0;
+		dmabuf->ossmaxfrags = 0;
+		dmabuf->subdivision = 0;
 		if (card->pci_id == PCI_DEVICE_ID_SI_7018) {
 			/* set default channel attribute to 0x8a80, record from
-			   PCM L/R FIFO and mono = (left + right + 1)/2*/
-			dmabuf->channel->attribute =
-				(CHANNEL_REC|PCM_LR|MONO_MIX);
+			   PCM L/R FIFO and mono = (left + right + 1)/2 */
+			dmabuf->channel->attribute = (CHANNEL_REC | PCM_LR | 
+						      MONO_MIX);
 		}
 		trident_set_adc_rate(state, 8000);
-	
+
 		/* Added by Matt Wu 01-05-2001 */
-		if(card->pci_id == PCI_DEVICE_ID_ALI_5451)
-			card->rec_channel_use_count ++;
+		if (card->pci_id == PCI_DEVICE_ID_ALI_5451)
+			card->rec_channel_use_count++;
 	}
 
 	state->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
 	up(&card->open_sem);
 
-	TRDBG("trident: open virtual channel %d, hard channel %d\n", 
-              state->virt, dmabuf->channel->num);
+	pr_debug("trident: open virtual channel %d, hard channel %d\n",
+		 state->virt, dmabuf->channel->num);
 
 	return 0;
 }
 
-static int trident_release(struct inode *inode, struct file *file)
+static int
+trident_release(struct inode *inode, struct file *file)
 {
 	struct trident_state *state = (struct trident_state *)file->private_data;
 	struct trident_card *card;
 	struct dmabuf *dmabuf;
 
-	lock_kernel();
+	VALIDATE_STATE(state);
+
 	card = state->card;
 	dmabuf = &state->dmabuf;
-	VALIDATE_STATE(state);
 
 	if (file->f_mode & FMODE_WRITE) {
 		trident_clear_tail(state);
 		drain_dac(state, file->f_flags & O_NONBLOCK);
 	}
 
-	TRDBG("trident: closing virtual channel %d, hard channel %d\n", 
-	      state->virt, dmabuf->channel->num);
+	pr_debug("trident: closing virtual channel %d, hard channel %d\n",
+		 state->virt, dmabuf->channel->num);
 
 	/* stop DMA state machine and free DMA buffers/channels */
 	down(&card->open_sem);
@@ -2760,7 +2870,7 @@ static int trident_release(struct inode 
 
 		/* Added by Matt Wu */
 		if (card->pci_id == PCI_DEVICE_ID_ALI_5451) {
-			if( card->rec_channel_use_count-- < 0 )
+			if (card->rec_channel_use_count-- < 0)
 				card->rec_channel_use_count = 0;
 		}
 	}
@@ -2770,37 +2880,36 @@ static int trident_release(struct inode 
 
 	/* we're covered by the open_sem */
 	up(&card->open_sem);
-	unlock_kernel();
 
 	return 0;
 }
 
-static /*const*/ struct file_operations trident_audio_fops = {
-	.owner		= THIS_MODULE,
-	.llseek		= no_llseek,
-	.read		= trident_read,
-	.write		= trident_write,
-	.poll		= trident_poll,
-	.ioctl		= trident_ioctl,
-	.mmap		= trident_mmap,
-	.open		= trident_open,
-	.release	= trident_release,
+static /*const */ struct file_operations trident_audio_fops = {
+	.owner = THIS_MODULE,
+	.llseek = no_llseek,
+	.read = trident_read,
+	.write = trident_write,
+	.poll = trident_poll,
+	.ioctl = trident_ioctl,
+	.mmap = trident_mmap,
+	.open = trident_open,
+	.release = trident_release,
 };
 
 /* trident specific AC97 functions */
 /* Write AC97 codec registers */
-static void trident_ac97_set(struct ac97_codec *codec, u8 reg, u16 val)
+static void
+trident_ac97_set(struct ac97_codec *codec, u8 reg, u16 val)
 {
 	struct trident_card *card = (struct trident_card *)codec->private_data;
 	unsigned int address, mask, busy;
-	unsigned short count  = 0xffff;
+	unsigned short count = 0xffff;
 	unsigned long flags;
 	u32 data;
 
 	data = ((u32) val) << 16;
 
-	switch (card->pci_id)
-	{
+	switch (card->pci_id) {
 	default:
 	case PCI_DEVICE_ID_SI_7018:
 		address = SI_AC97_WRITE;
@@ -2834,7 +2943,6 @@ static void trident_ac97_set(struct ac97
 			break;
 	} while (count--);
 
-
 	data |= (mask | (reg & AC97_REG_ADDR));
 
 	if (count == 0) {
@@ -2848,7 +2956,8 @@ static void trident_ac97_set(struct ac97
 }
 
 /* Read AC97 codec registers */
-static u16 trident_ac97_get(struct ac97_codec *codec, u8 reg)
+static u16
+trident_ac97_get(struct ac97_codec *codec, u8 reg)
 {
 	struct trident_card *card = (struct trident_card *)codec->private_data;
 	unsigned int address, mask, busy;
@@ -2856,8 +2965,7 @@ static u16 trident_ac97_get(struct ac97_
 	unsigned long flags;
 	u32 data;
 
-	switch (card->pci_id)
-	{
+	switch (card->pci_id) {
 	default:
 	case PCI_DEVICE_ID_SI_7018:
 		address = SI_AC97_READ;
@@ -2905,56 +3013,58 @@ static u16 trident_ac97_get(struct ac97_
 }
 
 /* rewrite ac97 read and write mixer register by hulei for ALI*/
-static int acquirecodecaccess(struct trident_card *card)
+static int
+acquirecodecaccess(struct trident_card *card)
 {
-	u16 wsemamask=0x6000; /* bit 14..13 */
+	u16 wsemamask = 0x6000;	/* bit 14..13 */
 	u16 wsemabits;
-        u16 wcontrol ;
+	u16 wcontrol;
 	int block = 0;
 	int ncount = 25;
 	while (1) {
-		wcontrol = inw(TRID_REG(card,  ALI_AC97_WRITE));
+		wcontrol = inw(TRID_REG(card, ALI_AC97_WRITE));
 		wsemabits = wcontrol & wsemamask;
-		
-		if (wsemabits==0x4000)
-			return 1; /* 0x4000 is audio ,then success */
+
+		if (wsemabits == 0x4000)
+			return 1;	/* 0x4000 is audio ,then success */
 		if (ncount-- < 0)
 			break;
-		if (wsemabits == 0)
-		{
-		unlock:
-			outl(((u32)(wcontrol & 0x1eff)|0x00004000), TRID_REG(card, ALI_AC97_WRITE));
+		if (wsemabits == 0) {
+		      unlock:
+			outl(((u32) (wcontrol & 0x1eff) | 0x00004000), 
+			     TRID_REG(card, ALI_AC97_WRITE));
 			continue;
 		}
 		udelay(20);
 	}
-	if(!block)
-	{
-		TRDBG("accesscodecsemaphore: try unlock\n");
+	if (!block) {
+		pr_debug("accesscodecsemaphore: try unlock\n");
 		block = 1;
 		goto unlock;
 	}
 	return 0;
 }
 
-static void releasecodecaccess(struct trident_card *card)
-{ 
+static void
+releasecodecaccess(struct trident_card *card)
+{
 	unsigned long wcontrol;
-	wcontrol = inl(TRID_REG(card,  ALI_AC97_WRITE));
+	wcontrol = inl(TRID_REG(card, ALI_AC97_WRITE));
 	outl((wcontrol & 0xffff1eff), TRID_REG(card, ALI_AC97_WRITE));
 }
 
-static int waitforstimertick(struct trident_card *card)
+static int
+waitforstimertick(struct trident_card *card)
 {
 	unsigned long chk1, chk2;
 	unsigned int wcount = 0xffff;
-	chk1 = inl(TRID_REG(card,  ALI_STIMER));
-	
-	while(1) {
-		chk2 = inl(TRID_REG(card,  ALI_STIMER));
-		if( (wcount > 0) && chk1 != chk2)
+	chk1 = inl(TRID_REG(card, ALI_STIMER));
+
+	while (1) {
+		chk2 = inl(TRID_REG(card, ALI_STIMER));
+		if ((wcount > 0) && chk1 != chk2)
 			return 1;
-		if(wcount <= 0)
+		if (wcount <= 0)
 			break;
 		udelay(50);
 	}
@@ -2962,16 +3072,17 @@ static int waitforstimertick(struct trid
 }
 
 /* Read AC97 codec registers for ALi*/
-static u16 ali_ac97_get(struct trident_card *card, int secondary, u8 reg)
+static u16
+ali_ac97_get(struct trident_card *card, int secondary, u8 reg)
 {
 	unsigned int address, mask;
 	unsigned int ncount;
-        unsigned long aud_reg;
+	unsigned long aud_reg;
 	u32 data;
-        u16 wcontrol;
-        unsigned long flags;
+	u16 wcontrol;
+	unsigned long flags;
 
-	if(!card)
+	if (!card)
 		BUG();
 
 	address = ALI_AC97_READ;
@@ -2981,121 +3092,127 @@ static u16 ali_ac97_get(struct trident_c
 	mask = ALI_AC97_READ_ACTION | ALI_AC97_AUDIO_BUSY;
 	if (secondary)
 		mask |= ALI_AC97_SECONDARY;
-    
-    	spin_lock_irqsave(&card->lock, flags);
-    	
+
+	spin_lock_irqsave(&card->lock, flags);
+
 	if (!acquirecodecaccess(card))
 		printk(KERN_ERR "access codec fail\n");
-	
+
 	wcontrol = inw(TRID_REG(card, ALI_AC97_WRITE));
 	wcontrol &= 0xfe00;
-	wcontrol |= (0x8000|reg);
-	outw(wcontrol,TRID_REG(card,  ALI_AC97_WRITE));
+	wcontrol |= (0x8000 | reg);
+	outw(wcontrol, TRID_REG(card, ALI_AC97_WRITE));
 
 	data = (mask | (reg & AC97_REG_ADDR));
-	
-	if(!waitforstimertick(card)) {
+
+	if (!waitforstimertick(card)) {
 		printk(KERN_ERR "ali_ac97_read: BIT_CLOCK is dead\n");
 		goto releasecodec;
 	}
-	
-	udelay(20);		
-	
-	ncount=10;
-	
-	while(1) {
-		if ((inw(TRID_REG(card,ALI_AC97_WRITE)) & ALI_AC97_BUSY_READ) != 0)
+
+	udelay(20);
+
+	ncount = 10;
+
+	while (1) {
+		if ((inw(TRID_REG(card, ALI_AC97_WRITE)) & ALI_AC97_BUSY_READ) 
+		    != 0)
 			break;
-		if(ncount <=0)
+		if (ncount <= 0)
 			break;
-		if(ncount--==1) {
-			TRDBG("ali_ac97_read :try clear busy flag\n");
-			aud_reg = inl(TRID_REG(card,  ALI_AC97_WRITE));
-			outl((aud_reg & 0xffff7fff), TRID_REG(card, ALI_AC97_WRITE));
+		if (ncount-- == 1) {
+			pr_debug("ali_ac97_read :try clear busy flag\n");
+			aud_reg = inl(TRID_REG(card, ALI_AC97_WRITE));
+			outl((aud_reg & 0xffff7fff), 
+			     TRID_REG(card, ALI_AC97_WRITE));
 		}
 		udelay(10);
 	}
-	
+
 	data = inl(TRID_REG(card, address));
 
 	spin_unlock_irqrestore(&card->lock, flags);
-	
+
 	return ((u16) (data >> 16));
 
- releasecodec: 
+      releasecodec:
 	releasecodecaccess(card);
 	spin_unlock_irqrestore(&card->lock, flags);
 	printk(KERN_ERR "ali_ac97_read: AC97 CODEC read timed out.\n");
 	return 0;
 }
 
-
 /* Write AC97 codec registers for hulei*/
-static void ali_ac97_set(struct trident_card *card, int secondary, u8 reg, u16 val)
+static void
+ali_ac97_set(struct trident_card *card, int secondary, u8 reg, u16 val)
 {
 	unsigned int address, mask;
 	unsigned int ncount;
 	u32 data;
-        u16 wcontrol;
-        unsigned long flags;
-	
+	u16 wcontrol;
+	unsigned long flags;
+
 	data = ((u32) val) << 16;
-	
-	if(!card)
+
+	if (!card)
 		BUG();
-	
+
 	address = ALI_AC97_WRITE;
 	mask = ALI_AC97_WRITE_ACTION | ALI_AC97_AUDIO_BUSY;
 	if (secondary)
 		mask |= ALI_AC97_SECONDARY;
 	if (card->revision == ALI_5451_V02)
 		mask |= ALI_AC97_WRITE_MIXER_REGISTER;
-		
+
 	spin_lock_irqsave(&card->lock, flags);
-        if (!acquirecodecaccess(card))      
+	if (!acquirecodecaccess(card))
 		printk(KERN_ERR "ali_ac97_write: access codec fail\n");
-			
+
 	wcontrol = inw(TRID_REG(card, ALI_AC97_WRITE));
 	wcontrol &= 0xff00;
-	wcontrol |= (0x8100|reg);/* bit 8=1: (ali1535 )reserved /ali1535+ write */
-	outl(( data |wcontrol), TRID_REG(card,ALI_AC97_WRITE ));
+	wcontrol |= (0x8100 | reg); /* bit 8=1: (ali1535 )reserved/ */ 
+	                            /* ali1535+ write */
+	outl((data | wcontrol), TRID_REG(card, ALI_AC97_WRITE));
 
-        if(!waitforstimertick(card)) {
+	if (!waitforstimertick(card)) {
 		printk(KERN_ERR "BIT_CLOCK is dead\n");
 		goto releasecodec;
 	}
-	
-        ncount = 10;
-	while(1) {
+
+	ncount = 10;
+	while (1) {
 		wcontrol = inw(TRID_REG(card, ALI_AC97_WRITE));
-		if(!(wcontrol & 0x8000))
+		if (!(wcontrol & 0x8000))
 			break;
-		if(ncount <= 0)
+		if (ncount <= 0)
 			break;
-		if(ncount-- == 1) {
-			TRDBG("ali_ac97_set :try clear busy flag!!\n");
-			outw(wcontrol & 0x7fff, TRID_REG(card, ALI_AC97_WRITE));
+		if (ncount-- == 1) {
+			pr_debug("ali_ac97_set :try clear busy flag!!\n");
+			outw(wcontrol & 0x7fff, 
+			     TRID_REG(card, ALI_AC97_WRITE));
 		}
 		udelay(10);
 	}
-	
- releasecodec:
+
+      releasecodec:
 	releasecodecaccess(card);
 	spin_unlock_irqrestore(&card->lock, flags);
 	return;
 }
 
-static void ali_enable_special_channel(struct trident_state *stat)
+static void
+ali_enable_special_channel(struct trident_state *stat)
 {
 	struct trident_card *card = stat->card;
 	unsigned long s_channels;
-	
+
 	s_channels = inl(TRID_REG(card, ALI_GLOBAL_CONTROL));
-	s_channels |= (1<<stat->dmabuf.channel->num);
+	s_channels |= (1 << stat->dmabuf.channel->num);
 	outl(s_channels, TRID_REG(card, ALI_GLOBAL_CONTROL));
 }
 
-static u16 ali_ac97_read(struct ac97_codec *codec, u8 reg)
+static u16
+ali_ac97_read(struct ac97_codec *codec, u8 reg)
 {
 	int id;
 	u16 data;
@@ -3104,25 +3221,26 @@ static u16 ali_ac97_read(struct ac97_cod
 	/* Added by Matt Wu */
 	if (!codec)
 		BUG();
-		
-	card = (struct trident_card *)codec->private_data;
 
-	if(!card->mixer_regs_ready)
+	card = (struct trident_card *) codec->private_data;
+
+	if (!card->mixer_regs_ready)
 		return ali_ac97_get(card, codec->id, reg);
 
 	/*
-	 *	FIXME: need to stop this caching some registers
+	 *      FIXME: need to stop this caching some registers
 	 */
-	if(codec->id)
+	if (codec->id)
 		id = 1;
 	else
 		id = 0;
 
-	data = card->mixer_regs[reg/2][id];
+	data = card->mixer_regs[reg / 2][id];
 	return data;
 }
 
-static void ali_ac97_write(struct ac97_codec *codec, u8 reg, u16 val)
+static void
+ali_ac97_write(struct ac97_codec *codec, u8 reg, u16 val)
 {
 	int id;
 	struct trident_card *card;
@@ -3130,21 +3248,20 @@ static void ali_ac97_write(struct ac97_c
 	/*  Added by Matt Wu */
 	if (!codec)
 		BUG();
-		
-	card = (struct trident_card *)codec->private_data;
 
-	if (!card->mixer_regs_ready)
-	{
+	card = (struct trident_card *) codec->private_data;
+
+	if (!card->mixer_regs_ready) {
 		ali_ac97_set(card, codec->id, reg, val);
 		return;
 	}
 
-	if(codec->id)
+	if (codec->id)
 		id = 1;
 	else
 		id = 0;
 
-	card->mixer_regs[reg/2][id] = val;
+	card->mixer_regs[reg / 2][id] = val;
 	ali_ac97_set(card, codec->id, reg, val);
 }
 
@@ -3153,73 +3270,78 @@ flag:	ALI_SPDIF_OUT_TO_SPDIF_OUT
 	ALI_PCM_TO_SPDIF_OUT
 */
 
-static void ali_setup_spdif_out(struct trident_card *card, int flag)
+static void
+ali_setup_spdif_out(struct trident_card *card, int flag)
 {
 	unsigned long spdif;
 	unsigned char ch;
 
-        char temp;
-        struct pci_dev *pci_dev = NULL;
+	char temp;
+	struct pci_dev *pci_dev = NULL;
 
-        pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, pci_dev);
-        if (pci_dev == NULL)
-                return;
-        pci_read_config_byte(pci_dev, 0x61, &temp);
-        temp |= 0x40;
-        pci_write_config_byte(pci_dev, 0x61, temp);
-        pci_read_config_byte(pci_dev, 0x7d, &temp);
-        temp |= 0x01;
-        pci_write_config_byte(pci_dev, 0x7d, temp);
-        pci_read_config_byte(pci_dev, 0x7e, &temp);
-        temp &= (~0x20);
-        temp |= 0x10;
-        pci_write_config_byte(pci_dev, 0x7e, temp);
+	pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, 
+				  pci_dev);
+	if (pci_dev == NULL)
+		return;
+	pci_read_config_byte(pci_dev, 0x61, &temp);
+	temp |= 0x40;
+	pci_write_config_byte(pci_dev, 0x61, temp);
+	pci_read_config_byte(pci_dev, 0x7d, &temp);
+	temp |= 0x01;
+	pci_write_config_byte(pci_dev, 0x7d, temp);
+	pci_read_config_byte(pci_dev, 0x7e, &temp);
+	temp &= (~0x20);
+	temp |= 0x10;
+	pci_write_config_byte(pci_dev, 0x7e, temp);
 
 	ch = inb(TRID_REG(card, ALI_SCTRL));
 	outb(ch | ALI_SPDIF_OUT_ENABLE, TRID_REG(card, ALI_SCTRL));
 	ch = inb(TRID_REG(card, ALI_SPDIF_CTRL));
 	outb(ch & ALI_SPDIF_OUT_CH_STATUS, TRID_REG(card, ALI_SPDIF_CTRL));
-   
+
 	if (flag & ALI_SPDIF_OUT_TO_SPDIF_OUT) {
-  		spdif = inw(TRID_REG(card, ALI_GLOBAL_CONTROL));
-   		spdif |= ALI_SPDIF_OUT_CH_ENABLE;
-   		spdif &= ALI_SPDIF_OUT_SEL_SPDIF;
-   		outw(spdif, TRID_REG(card, ALI_GLOBAL_CONTROL));
+		spdif = inw(TRID_REG(card, ALI_GLOBAL_CONTROL));
+		spdif |= ALI_SPDIF_OUT_CH_ENABLE;
+		spdif &= ALI_SPDIF_OUT_SEL_SPDIF;
+		outw(spdif, TRID_REG(card, ALI_GLOBAL_CONTROL));
 		spdif = inw(TRID_REG(card, ALI_SPDIF_CS));
 		if (flag & ALI_SPDIF_OUT_NON_PCM)
-   			spdif |= 0x0002;
-		else	spdif &= (~0x0002);
-   		outw(spdif, TRID_REG(card, ALI_SPDIF_CS));
-   	}
-   	else {
-   		spdif = inw(TRID_REG(card, ALI_GLOBAL_CONTROL));
-   		spdif |= ALI_SPDIF_OUT_SEL_PCM;
-   		outw(spdif, TRID_REG(card, ALI_GLOBAL_CONTROL));
-   	}
+			spdif |= 0x0002;
+		else
+			spdif &= (~0x0002);
+		outw(spdif, TRID_REG(card, ALI_SPDIF_CS));
+	} else {
+		spdif = inw(TRID_REG(card, ALI_GLOBAL_CONTROL));
+		spdif |= ALI_SPDIF_OUT_SEL_PCM;
+		outw(spdif, TRID_REG(card, ALI_GLOBAL_CONTROL));
+	}
 }
 
-static void ali_disable_special_channel(struct trident_card *card, int ch)
+static void
+ali_disable_special_channel(struct trident_card *card, int ch)
 {
 	unsigned long sc;
-	
+
 	sc = inl(TRID_REG(card, ALI_GLOBAL_CONTROL));
 	sc &= ~(1 << ch);
 	outl(sc, TRID_REG(card, ALI_GLOBAL_CONTROL));
 }
 
-static void ali_disable_spdif_in(struct trident_card *card)
+static void
+ali_disable_spdif_in(struct trident_card *card)
 {
 	unsigned long spdif;
-	
+
 	spdif = inl(TRID_REG(card, ALI_GLOBAL_CONTROL));
 	spdif &= (~ALI_SPDIF_IN_SUPPORT);
 	outl(spdif, TRID_REG(card, ALI_GLOBAL_CONTROL));
-	
-	ali_disable_special_channel(card, ALI_SPDIF_IN_CHANNEL);	
+
+	ali_disable_special_channel(card, ALI_SPDIF_IN_CHANNEL);
 }
 
-static void ali_setup_spdif_in(struct trident_card *card)
-{	
+static void
+ali_setup_spdif_in(struct trident_card *card)
+{
 	unsigned long spdif;
 
 	//Set SPDIF IN Supported
@@ -3242,93 +3364,93 @@ static void ali_setup_spdif_in(struct tr
 */
 }
 
-static void ali_delay(struct trident_card *card,int interval)
+static void
+ali_delay(struct trident_card *card, int interval)
 {
-	unsigned long  begintimer,currenttimer;
+	unsigned long begintimer, currenttimer;
 
-	begintimer   = inl(TRID_REG(card,  ALI_STIMER));
-	currenttimer = inl(TRID_REG(card,  ALI_STIMER));
+	begintimer = inl(TRID_REG(card, ALI_STIMER));
+	currenttimer = inl(TRID_REG(card, ALI_STIMER));
 
 	while (currenttimer < begintimer + interval)
-		currenttimer = inl(TRID_REG(card,  ALI_STIMER));
+		currenttimer = inl(TRID_REG(card, ALI_STIMER));
 }
 
-static void ali_detect_spdif_rate(struct trident_card *card)
+static void
+ali_detect_spdif_rate(struct trident_card *card)
 {
-	u16 wval  = 0;
+	u16 wval = 0;
 	u16 count = 0;
-	u8  bval = 0, R1 = 0, R2 = 0;
+	u8 bval = 0, R1 = 0, R2 = 0;
 
-	bval  = inb(TRID_REG(card,ALI_SPDIF_CTRL));
+	bval = inb(TRID_REG(card, ALI_SPDIF_CTRL));
 	bval |= 0x02;
-	outb(bval,TRID_REG(card,ALI_SPDIF_CTRL));
+	outb(bval, TRID_REG(card, ALI_SPDIF_CTRL));
 
-	bval  = inb(TRID_REG(card,ALI_SPDIF_CTRL + 1));
+	bval = inb(TRID_REG(card, ALI_SPDIF_CTRL + 1));
 	bval |= 0x1F;
-	outb(bval,TRID_REG(card,ALI_SPDIF_CTRL + 1));
+	outb(bval, TRID_REG(card, ALI_SPDIF_CTRL + 1));
 
-	while (((R1 < 0x0B )||(R1 > 0x0E)) && (R1 != 0x12) && count <= 50000)
-	{
-		count ++;
+	while (((R1 < 0x0B) || (R1 > 0x0E)) && (R1 != 0x12) && 
+	       count <= 50000) {
+		count++;
 
 		ali_delay(card, 6);
 
-		bval = inb(TRID_REG(card,ALI_SPDIF_CTRL + 1));
+		bval = inb(TRID_REG(card, ALI_SPDIF_CTRL + 1));
 		R1 = bval & 0x1F;
 	}
 
-	if (count > 50000)
-	{
-		printk(KERN_WARNING "trident: Error in ali_detect_spdif_rate!\n");
+	if (count > 50000) {
+		printk(KERN_WARNING "trident: Error in "
+		       "ali_detect_spdif_rate!\n");
 		return;
 	}
 
 	count = 0;
 
-	while (count <= 50000)
-	{
-		count ++;
+	while (count <= 50000) {
+		count++;
 
 		ali_delay(card, 6);
 
-		bval = inb(TRID_REG(card,ALI_SPDIF_CTRL + 1));
+		bval = inb(TRID_REG(card, ALI_SPDIF_CTRL + 1));
 		R2 = bval & 0x1F;
 
-		if(R2 != R1)
+		if (R2 != R1)
 			R1 = R2;
 		else
 			break;
 	}
 
-	if (count > 50000)
-	{
-		printk(KERN_WARNING "trident: Error in ali_detect_spdif_rate!\n");
+	if (count > 50000) {
+		printk(KERN_WARNING "trident: Error in "
+		       "ali_detect_spdif_rate!\n");
 		return;
 	}
 
-	switch (R2)
-	{
+	switch (R2) {
 	case 0x0b:
 	case 0x0c:
 	case 0x0d:
 	case 0x0e:
-		wval  = inw(TRID_REG(card,ALI_SPDIF_CTRL + 2));
+		wval = inw(TRID_REG(card, ALI_SPDIF_CTRL + 2));
 		wval &= 0xE0F0;
-		wval |= (u16)0x09 << 8 | (u16)0x05;
-		outw(wval,TRID_REG(card,ALI_SPDIF_CTRL + 2));
+		wval |= (u16) 0x09 << 8 | (u16) 0x05;
+		outw(wval, TRID_REG(card, ALI_SPDIF_CTRL + 2));
 
-		bval  = inb(TRID_REG(card,ALI_SPDIF_CS +3)) & 0xF0;
-		outb(bval|0x02,TRID_REG(card,ALI_SPDIF_CS + 3));
+		bval = inb(TRID_REG(card, ALI_SPDIF_CS + 3)) & 0xF0;
+		outb(bval | 0x02, TRID_REG(card, ALI_SPDIF_CS + 3));
 		break;
 
 	case 0x12:
-		wval  = inw(TRID_REG(card,ALI_SPDIF_CTRL + 2));
+		wval = inw(TRID_REG(card, ALI_SPDIF_CTRL + 2));
 		wval &= 0xE0F0;
-		wval |= (u16)0x0E << 8 | (u16)0x08;
-		outw(wval,TRID_REG(card,ALI_SPDIF_CTRL + 2));
+		wval |= (u16) 0x0E << 8 | (u16) 0x08;
+		outw(wval, TRID_REG(card, ALI_SPDIF_CTRL + 2));
 
-		bval  = inb(TRID_REG(card,ALI_SPDIF_CS +3)) & 0xF0;
-		outb(bval|0x03,TRID_REG(card,ALI_SPDIF_CS + 3));
+		bval = inb(TRID_REG(card, ALI_SPDIF_CS + 3)) & 0xF0;
+		outb(bval | 0x03, TRID_REG(card, ALI_SPDIF_CS + 3));
 		break;
 
 	default:
@@ -3337,23 +3459,23 @@ static void ali_detect_spdif_rate(struct
 
 }
 
-static unsigned int ali_get_spdif_in_rate(struct trident_card *card)
+static unsigned int
+ali_get_spdif_in_rate(struct trident_card *card)
 {
-	u32	dwRate = 0;
-	u8	bval = 0;
+	u32 dwRate = 0;
+	u8 bval = 0;
 
 	ali_detect_spdif_rate(card);
 
-	bval  = inb(TRID_REG(card,ALI_SPDIF_CTRL));
+	bval = inb(TRID_REG(card, ALI_SPDIF_CTRL));
 	bval &= 0x7F;
 	bval |= 0x40;
-	outb(bval,TRID_REG(card,ALI_SPDIF_CTRL));
+	outb(bval, TRID_REG(card, ALI_SPDIF_CTRL));
 
-	bval  = inb(TRID_REG(card,ALI_SPDIF_CS + 3));
+	bval = inb(TRID_REG(card, ALI_SPDIF_CS + 3));
 	bval &= 0x0F;
 
-	switch (bval)
-	{
+	switch (bval) {
 	case 0:
 		dwRate = 44100;
 		break;
@@ -3369,24 +3491,27 @@ static unsigned int ali_get_spdif_in_rat
 	}
 
 	return dwRate;
-	
+
 }
 
-static int ali_close_multi_channels(void)
+static int
+ali_close_multi_channels(void)
 {
 	char temp = 0;
 	struct pci_dev *pci_dev = NULL;
 
-        pci_dev = pci_find_device(PCI_VENDOR_ID_AL,PCI_DEVICE_ID_AL_M1533, pci_dev);
-        if (pci_dev == NULL)
-                return -1;
+	pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, 
+				  pci_dev);
+	if (pci_dev == NULL)
+		return -1;
 	pci_read_config_byte(pci_dev, 0x59, &temp);
 	temp &= ~0x80;
 	pci_write_config_byte(pci_dev, 0x59, temp);
-	
-	pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, pci_dev);
+
+	pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, 
+				  pci_dev);
 	if (pci_dev == NULL)
-                return -1;
+		return -1;
 
 	pci_read_config_byte(pci_dev, 0xB8, &temp);
 	temp &= ~0x20;
@@ -3395,25 +3520,28 @@ static int ali_close_multi_channels(void
 	return 0;
 }
 
-static int ali_setup_multi_channels(struct trident_card *card, int chan_nums)
+static int
+ali_setup_multi_channels(struct trident_card *card, int chan_nums)
 {
 	unsigned long dwValue;
 	char temp = 0;
 	struct pci_dev *pci_dev = NULL;
 
-	pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, pci_dev);
+	pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, 
+				  pci_dev);
 	if (pci_dev == NULL)
-                return -1;
+		return -1;
 	pci_read_config_byte(pci_dev, 0x59, &temp);
 	temp |= 0x80;
 	pci_write_config_byte(pci_dev, 0x59, temp);
-	
-	pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, pci_dev);
- 	if (pci_dev == NULL)
-                return -1;
-	pci_read_config_byte(pci_dev, (int)0xB8, &temp);
+
+	pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, 
+				  pci_dev);
+	if (pci_dev == NULL)
+		return -1;
+	pci_read_config_byte(pci_dev, (int) 0xB8, &temp);
 	temp |= 0x20;
-	pci_write_config_byte(pci_dev, (int)0xB8,(u8) temp);
+	pci_write_config_byte(pci_dev, (int) 0xB8, (u8) temp);
 	if (chan_nums == 6) {
 		dwValue = inl(TRID_REG(card, ALI_SCTRL)) | 0x000f0000;
 		outl(dwValue, TRID_REG(card, ALI_SCTRL));
@@ -3424,11 +3552,10 @@ static int ali_setup_multi_channels(stru
 			ali_ac97_write(card->ac97_codec[0], 0x36, 0);
 			ali_ac97_write(card->ac97_codec[0], 0x38, 0);
 			/*
-			 *	On a board with a single codec you won't get the
-			 *	surround. On other boards configure it.
+			 *      On a board with a single codec you won't get the
+			 *      surround. On other boards configure it.
 			 */
-			if(card->ac97_codec[1]!=NULL)
-			{
+			if (card->ac97_codec[1] != NULL) {
 				ali_ac97_write(card->ac97_codec[1], 0x36, 0);
 				ali_ac97_write(card->ac97_codec[1], 0x38, 0);
 				ali_ac97_write(card->ac97_codec[1], 0x02, 0x0606);
@@ -3441,7 +3568,8 @@ static int ali_setup_multi_channels(stru
 	return -EINVAL;
 }
 
-static void ali_free_pcm_channel(struct trident_card *card, unsigned int channel)
+static void
+ali_free_pcm_channel(struct trident_card *card, unsigned int channel)
 {
 	int bank;
 
@@ -3454,165 +3582,180 @@ static void ali_free_pcm_channel(struct 
 	card->banks[bank].bitmap &= ~(1 << (channel));
 }
 
-static int ali_allocate_other_states_resources(struct trident_state *state, int chan_nums)
+static int
+ali_allocate_other_states_resources(struct trident_state *state, int chan_nums)
 {
 	struct trident_card *card = state->card;
 	struct trident_state *s;
 	int i, state_count = 0;
 	struct trident_pcm_bank *bank;
 	struct trident_channel *channel;
-	
+	unsigned long num;
+
 	bank = &card->banks[BANK_A];
-	
-	if (chan_nums == 6) {
-		for(i = 0;(i < ALI_CHANNELS) && (state_count != 4); i++) {
-			if (!card->states[i]) {
-				if (!(bank->bitmap & (1 << ali_multi_channels_5_1[state_count]))) {
-					bank->bitmap |= (1 << ali_multi_channels_5_1[state_count]);
-					channel = &bank->channels[ali_multi_channels_5_1[state_count]];
-					channel->num = ali_multi_channels_5_1[state_count];
-				}
-				else {
-					state_count--;
-					for (; state_count >= 0; state_count--) {
-						kfree(state->other_states[state_count]);
-						ali_free_pcm_channel(card, ali_multi_channels_5_1[state_count]);
-					}
-					return -EBUSY;
-				}
-				s = card->states[i] = (struct trident_state *)
-						kmalloc(sizeof(struct trident_state), GFP_KERNEL);
-				if (!s) {
-					ali_free_pcm_channel(card, ali_multi_channels_5_1[state_count]);
-					state_count--;
-					for (; state_count >= 0; state_count--) {						
-						ali_free_pcm_channel(card, ali_multi_channels_5_1[state_count]);
-						kfree(state->other_states[state_count]);
-					}
-					return -ENOMEM;
-				}
-				memset(s, 0, sizeof(struct trident_state));
-				
-				s->dmabuf.channel = channel;
-				s->dmabuf.ossfragshift = s->dmabuf.ossmaxfrags = s->dmabuf.subdivision = 0;
-				init_waitqueue_head(&s->dmabuf.wait);
-				s->magic = card->magic;
-				s->card = card;
-				s->virt = i;
-				ali_enable_special_channel(s);
-				state->other_states[state_count++] = s;
+
+	if (chan_nums != 6)
+		return 0;
+
+	for (i = 0; (i < ALI_CHANNELS) && (state_count != 4); i++) {
+		if (card->states[i])
+			continue;
+
+		num = ali_multi_channels_5_1[state_count];
+		if (!(bank->bitmap & (1 << num))) {
+			bank->bitmap |= 1 << num;
+			channel = &bank->channels[num];
+			channel->num = num;
+		} else {
+			state_count--;
+			for (; state_count >= 0; state_count--) {
+				kfree(state->other_states[state_count]);
+				num = ali_multi_channels_5_1[state_count];
+					ali_free_pcm_channel(card, num);
 			}
+			return -EBUSY;
 		}
-		
-		if (state_count != 4) {
+		s = card->states[i] = kmalloc(sizeof(*state), GFP_KERNEL);
+		if (!s) {
+			num = ali_multi_channels_5_1[state_count];
+			ali_free_pcm_channel(card, num);
 			state_count--;
 			for (; state_count >= 0; state_count--) {
+				num = ali_multi_channels_5_1[state_count];
+				ali_free_pcm_channel(card, num);
 				kfree(state->other_states[state_count]);
-				ali_free_pcm_channel(card, ali_multi_channels_5_1[state_count]);
 			}
-			return -EBUSY;
+			return -ENOMEM;
+		}
+		memset(s, 0, sizeof(*state));
+
+		s->dmabuf.channel = channel;
+		s->dmabuf.ossfragshift = s->dmabuf.ossmaxfrags =
+			s->dmabuf.subdivision = 0;
+		init_waitqueue_head(&s->dmabuf.wait);
+		s->magic = card->magic;
+		s->card = card;
+		s->virt = i;
+		ali_enable_special_channel(s);
+		state->other_states[state_count++] = s;
+	}
+
+	if (state_count != 4) {
+		state_count--;
+		for (; state_count >= 0; state_count--) {
+			kfree(state->other_states[state_count]);
+			num = ali_multi_channels_5_1[state_count];
+			ali_free_pcm_channel(card, num);
 		}
+		return -EBUSY;
 	}
 	return 0;
 }
 
-static void ali_save_regs(struct trident_card *card)
+static void
+ali_save_regs(struct trident_card *card)
 {
 	unsigned long flags;
 	int i, j;
 
-	spin_lock_irqsave(&card->lock, flags); 
+	spin_lock_irqsave(&card->lock, flags);
+
+	ali_registers.global_regs[0x2c] = inl(TRID_REG(card, T4D_MISCINT));
+	//ali_registers.global_regs[0x20] = inl(TRID_REG(card,T4D_START_A));    
+	ali_registers.global_regs[0x21] = inl(TRID_REG(card, T4D_STOP_A));
 
-	ali_registers.global_regs[0x2c] = inl(TRID_REG(card,T4D_MISCINT));
-	//ali_registers.global_regs[0x20] = inl(TRID_REG(card,T4D_START_A));	
-	ali_registers.global_regs[0x21] = inl(TRID_REG(card,T4D_STOP_A));
-	
 	//disable all IRQ bits
 	outl(ALI_DISABLE_ALL_IRQ, TRID_REG(card, T4D_MISCINT));
-	
+
 	for (i = 1; i < ALI_MIXER_REGS; i++)
-		ali_registers.mixer_regs[i] = ali_ac97_read (card->ac97_codec[0], i*2);
-	
-	for (i = 0; i < ALI_GLOBAL_REGS; i++)
-	{	
-		if ((i*4 == T4D_MISCINT) || (i*4 == T4D_STOP_A))
+		ali_registers.mixer_regs[i] = ali_ac97_read(card->ac97_codec[0], 
+							    i * 2);
+
+	for (i = 0; i < ALI_GLOBAL_REGS; i++) {
+		if ((i * 4 == T4D_MISCINT) || (i * 4 == T4D_STOP_A))
 			continue;
-		ali_registers.global_regs[i] = inl(TRID_REG(card, i*4));
+		ali_registers.global_regs[i] = inl(TRID_REG(card, i * 4));
 	}
-	
-	for (i = 0; i < ALI_CHANNELS; i++) 
-	{
-		outb(i,TRID_REG(card, T4D_LFO_GC_CIR));
-		for (j = 0; j < ALI_CHANNEL_REGS; j++) 
-			ali_registers.channel_regs[i][j] = inl(TRID_REG(card, j*4 + 0xe0));
+
+	for (i = 0; i < ALI_CHANNELS; i++) {
+		outb(i, TRID_REG(card, T4D_LFO_GC_CIR));
+		for (j = 0; j < ALI_CHANNEL_REGS; j++)
+			ali_registers.channel_regs[i][j] = inl(TRID_REG(card, 
+									j * 4 + 0xe0));
 	}
 
 	//Stop all HW channel
 	outl(ALI_STOP_ALL_CHANNELS, TRID_REG(card, T4D_STOP_A));
 
-	spin_unlock_irqrestore(&card->lock, flags); 
+	spin_unlock_irqrestore(&card->lock, flags);
 }
 
-static void ali_restore_regs(struct trident_card *card)
+static void
+ali_restore_regs(struct trident_card *card)
 {
 	unsigned long flags;
 	int i, j;
 
-	spin_lock_irqsave(&card->lock, flags); 
-	
+	spin_lock_irqsave(&card->lock, flags);
+
 	for (i = 1; i < ALI_MIXER_REGS; i++)
-		ali_ac97_write(card->ac97_codec[0], i*2, ali_registers.mixer_regs[i]);
-	
-	for (i = 0; i < ALI_CHANNELS; i++) 
-	{
-		outb(i,TRID_REG(card, T4D_LFO_GC_CIR));
-		for (j = 0; j < ALI_CHANNEL_REGS; j++) 
-			outl(ali_registers.channel_regs[i][j], TRID_REG(card, j*4 + 0xe0));
-	}
-	
-	for (i = 0; i < ALI_GLOBAL_REGS; i++)
-	{	
-		if ((i*4 == T4D_MISCINT) || (i*4 == T4D_STOP_A) || (i*4 == T4D_START_A))
+		ali_ac97_write(card->ac97_codec[0], i * 2, 
+			       ali_registers.mixer_regs[i]);
+
+	for (i = 0; i < ALI_CHANNELS; i++) {
+		outb(i, TRID_REG(card, T4D_LFO_GC_CIR));
+		for (j = 0; j < ALI_CHANNEL_REGS; j++)
+			outl(ali_registers.channel_regs[i][j], 
+			     TRID_REG(card, j * 4 + 0xe0));
+	}
+
+	for (i = 0; i < ALI_GLOBAL_REGS; i++) {
+		if ((i * 4 == T4D_MISCINT) || (i * 4 == T4D_STOP_A) || 
+		    (i * 4 == T4D_START_A))
 			continue;
-		outl(ali_registers.global_regs[i], TRID_REG(card, i*4));
+		outl(ali_registers.global_regs[i], TRID_REG(card, i * 4));
 	}
-	
+
 	//start HW channel
-	outl(ali_registers.global_regs[0x20], TRID_REG(card,T4D_START_A));
+	outl(ali_registers.global_regs[0x20], TRID_REG(card, T4D_START_A));
 	//restore IRQ enable bits
-	outl(ali_registers.global_regs[0x2c], TRID_REG(card,T4D_MISCINT));
+	outl(ali_registers.global_regs[0x2c], TRID_REG(card, T4D_MISCINT));
 
-	spin_unlock_irqrestore(&card->lock, flags); 
+	spin_unlock_irqrestore(&card->lock, flags);
 }
 
-static int trident_suspend(struct pci_dev *dev, u32 unused)
+static int
+trident_suspend(struct pci_dev *dev, u32 unused)
 {
-	struct trident_card *card = pci_get_drvdata(dev); 
+	struct trident_card *card = pci_get_drvdata(dev);
 
-	if(card->pci_id == PCI_DEVICE_ID_ALI_5451) {
+	if (card->pci_id == PCI_DEVICE_ID_ALI_5451) {
 		ali_save_regs(card);
 	}
 	return 0;
 }
 
-static int trident_resume(struct pci_dev *dev)
+static int
+trident_resume(struct pci_dev *dev)
 {
-	struct trident_card *card = pci_get_drvdata(dev); 
+	struct trident_card *card = pci_get_drvdata(dev);
 
-	if(card->pci_id == PCI_DEVICE_ID_ALI_5451) {
+	if (card->pci_id == PCI_DEVICE_ID_ALI_5451) {
 		ali_restore_regs(card);
 	}
 	return 0;
 }
 
-static struct trident_channel *ali_alloc_pcm_channel(struct trident_card *card)
+static struct trident_channel *
+ali_alloc_pcm_channel(struct trident_card *card)
 {
 	struct trident_pcm_bank *bank;
 	int idx;
 
 	bank = &card->banks[BANK_A];
-	
-	if (inl(TRID_REG(card, ALI_GLOBAL_CONTROL)) & (ALI_SPDIF_OUT_CH_ENABLE)) {
+
+	if (inl(TRID_REG(card, ALI_GLOBAL_CONTROL)) & 
+	    (ALI_SPDIF_OUT_CH_ENABLE)) {
 		idx = ALI_SPDIF_OUT_CHANNEL;
 		if (!(bank->bitmap & (1 << idx))) {
 			struct trident_channel *channel = &bank->channels[idx];
@@ -3621,8 +3764,9 @@ static struct trident_channel *ali_alloc
 			return channel;
 		}
 	}
-	
-	for (idx = ALI_PCM_OUT_CHANNEL_FIRST; idx <= ALI_PCM_OUT_CHANNEL_LAST ; idx++) {
+
+	for (idx = ALI_PCM_OUT_CHANNEL_FIRST; idx <= ALI_PCM_OUT_CHANNEL_LAST; 
+	     idx++) {
 		if (!(bank->bitmap & (1 << idx))) {
 			struct trident_channel *channel = &bank->channels[idx];
 			bank->bitmap |= 1 << idx;
@@ -3632,39 +3776,46 @@ static struct trident_channel *ali_alloc
 	}
 
 	/* no more free channels avaliable */
-//	printk(KERN_ERR "ali: no more channels available on Bank A.\n");
+#if 0 
+	printk(KERN_ERR "ali: no more channels available on Bank A.\n");
+#endif /* 0 */ 
 	return NULL;
 }
 
-static struct trident_channel *ali_alloc_rec_pcm_channel(struct trident_card *card)
+static struct trident_channel *
+ali_alloc_rec_pcm_channel(struct trident_card *card)
 {
 	struct trident_pcm_bank *bank;
 	int idx;
-	
+
 	if (inl(TRID_REG(card, ALI_GLOBAL_CONTROL)) & ALI_SPDIF_IN_SUPPORT)
 		idx = ALI_SPDIF_IN_CHANNEL;
-	else	idx = ALI_PCM_IN_CHANNEL;
+	else
+		idx = ALI_PCM_IN_CHANNEL;
 
 	bank = &card->banks[BANK_A];
-	
+
 	if (!(bank->bitmap & (1 << idx))) {
 		struct trident_channel *channel = &bank->channels[idx];
 		bank->bitmap |= 1 << idx;
 		channel->num = idx;
 		return channel;
 	}
-	
+
 	/* no free recordable channels avaliable */
-//	printk(KERN_ERR "ali: no recordable channels available on Bank A.\n");
+#if 0 
+	printk(KERN_ERR "ali: no recordable channels available on Bank A.\n");
+#endif /* 0 */ 
 	return NULL;
 }
 
-static void ali_set_spdif_out_rate(struct trident_card *card, unsigned int rate)
+static void
+ali_set_spdif_out_rate(struct trident_card *card, unsigned int rate)
 {
 	unsigned char ch_st_sel;
 	unsigned short status_rate;
-	
-	switch(rate) {
+
+	switch (rate) {
 	case 44100:
 		status_rate = 0;
 		break;
@@ -3676,28 +3827,30 @@ static void ali_set_spdif_out_rate(struc
 		status_rate = 0x200;
 		break;
 	}
-	
-	ch_st_sel = inb(TRID_REG(card, ALI_SPDIF_CTRL)) & ALI_SPDIF_OUT_CH_STATUS;	//select spdif_out
-	
-	ch_st_sel |= 0x80;	//select right
+
+	/* select spdif_out */ 
+	ch_st_sel = inb(TRID_REG(card, ALI_SPDIF_CTRL)) & ALI_SPDIF_OUT_CH_STATUS;
+
+	ch_st_sel |= 0x80;	/* select right */ 
 	outb(ch_st_sel, TRID_REG(card, ALI_SPDIF_CTRL));
 	outb(status_rate | 0x20, TRID_REG(card, ALI_SPDIF_CS + 2));
-	
-	ch_st_sel &= (~0x80);	//select left
+
+	ch_st_sel &= (~0x80);	/* select left */ 
 	outb(ch_st_sel, TRID_REG(card, ALI_SPDIF_CTRL));
 	outw(status_rate | 0x10, TRID_REG(card, ALI_SPDIF_CS + 2));
 }
 
-static void ali_address_interrupt(struct trident_card *card)
+static void
+ali_address_interrupt(struct trident_card *card)
 {
 	int i, channel;
 	struct trident_state *state;
 	u32 mask, channel_mask;
-	
-	mask = trident_get_interrupt_mask (card, 0);
+
+	mask = trident_get_interrupt_mask(card, 0);
 	for (i = 0; i < NR_HW_CH; i++) {
 		if ((state = card->states[i]) == NULL)
-			continue;		
+			continue;
 		channel = state->dmabuf.channel->num;
 		if ((channel_mask = 1 << channel) & mask) {
 			mask &= ~channel_mask;
@@ -3724,37 +3877,41 @@ protection is no harm because all DMAs o
 depend on a master state's DMA, and changing the counters of the master
 state DMA is protected by a spinlock.
 */
-static int ali_write_5_1(struct trident_state *state,  
-			 const char *buf, int cnt_for_multi_channel, 
-			 unsigned int *copy_count, 
-			 unsigned int *state_cnt)
+static int
+ali_write_5_1(struct trident_state *state, const char *buf, 
+	      int cnt_for_multi_channel, unsigned int *copy_count, 
+	      unsigned int *state_cnt)
 {
-	
+
 	struct dmabuf *dmabuf = &state->dmabuf;
 	struct dmabuf *dmabuf_temp;
 	const char *buffer = buf;
 	unsigned swptr, other_dma_nums, sample_s;
 	unsigned int i, loop;
-	
+
 	other_dma_nums = 4;
 	sample_s = sample_size[dmabuf->fmt] >> 1;
 	swptr = dmabuf->swptr;
 
 	if ((i = state->multi_channels_adjust_count) > 0) {
 		if (i == 1) {
-			if (copy_from_user(dmabuf->rawbuf + swptr, buffer, sample_s))
+			if (copy_from_user(dmabuf->rawbuf + swptr, 
+					   buffer, sample_s))
 				return -EFAULT;
-			seek_offset(swptr, buffer, cnt_for_multi_channel, sample_s, *copy_count);
+			seek_offset(swptr, buffer, cnt_for_multi_channel, 
+				    sample_s, *copy_count);
 			i--;
 			(*state_cnt) += sample_s;
 			state->multi_channels_adjust_count++;
-		}
-		else	i = i - (state->chans_num - other_dma_nums);
+		} else
+			i = i - (state->chans_num - other_dma_nums);
 		for (; (i < other_dma_nums) && (cnt_for_multi_channel > 0); i++) {
 			dmabuf_temp = &state->other_states[i]->dmabuf;
-			if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, buffer, sample_s))
+			if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, 
+					   buffer, sample_s))
 				return -EFAULT;
-			seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, sample_s, *copy_count);
+			seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, 
+				    sample_s, *copy_count);
 		}
 		if (cnt_for_multi_channel == 0)
 			state->multi_channels_adjust_count += i;
@@ -3762,58 +3919,75 @@ static int ali_write_5_1(struct trident_
 	if (cnt_for_multi_channel > 0) {
 		loop = cnt_for_multi_channel / (state->chans_num * sample_s);
 		for (i = 0; i < loop; i++) {
-			if (copy_from_user(dmabuf->rawbuf + swptr, buffer, sample_s * 2))
+			if (copy_from_user(dmabuf->rawbuf + swptr, buffer, 
+					   sample_s * 2))
 				return -EFAULT;
-			seek_offset(swptr, buffer, cnt_for_multi_channel, sample_s * 2, *copy_count);
+			seek_offset(swptr, buffer, cnt_for_multi_channel, 
+				    sample_s * 2, *copy_count);
 			(*state_cnt) += (sample_s * 2);
-		
+
 			dmabuf_temp = &state->other_states[0]->dmabuf;
-			if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, buffer, sample_s))
+			if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, 
+					   buffer, sample_s))
 				return -EFAULT;
-			seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, sample_s, *copy_count);
-		
+			seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, 
+				    sample_s, *copy_count);
+
 			dmabuf_temp = &state->other_states[1]->dmabuf;
-			if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, buffer, sample_s))
+			if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, 
+					   buffer, sample_s))
 				return -EFAULT;
-			seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, sample_s, *copy_count);
-		
+			seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, 
+				    sample_s, *copy_count);
+
 			dmabuf_temp = &state->other_states[2]->dmabuf;
-			if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, buffer, sample_s))
+			if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, 
+					   buffer, sample_s))
 				return -EFAULT;
-			seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, sample_s, *copy_count);
-				
+			seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, 
+				    sample_s, *copy_count);
+
 			dmabuf_temp = &state->other_states[3]->dmabuf;
-			if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, buffer, sample_s))
+			if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, 
+					   buffer, sample_s))
 				return -EFAULT;
-			seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, sample_s, *copy_count);
+			seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, 
+				    sample_s, *copy_count);
 		}
-		
+
 		if (cnt_for_multi_channel > 0) {
 			state->multi_channels_adjust_count = cnt_for_multi_channel / sample_s;
-			
+
 			if (copy_from_user(dmabuf->rawbuf + swptr, buffer, sample_s))
 				return -EFAULT;
-			seek_offset(swptr, buffer, cnt_for_multi_channel, sample_s, *copy_count);			
+			seek_offset(swptr, buffer, cnt_for_multi_channel, 
+				    sample_s, *copy_count);
 			(*state_cnt) += sample_s;
-			
+
 			if (cnt_for_multi_channel > 0) {
-				if (copy_from_user(dmabuf->rawbuf + swptr, buffer, sample_s))
+				if (copy_from_user(dmabuf->rawbuf + swptr, 
+						   buffer, sample_s))
 					return -EFAULT;
-				seek_offset(swptr, buffer, cnt_for_multi_channel, sample_s, *copy_count);
+				seek_offset(swptr, buffer, cnt_for_multi_channel, 
+					    sample_s, *copy_count);
 				(*state_cnt) += sample_s;
-			
+
 				if (cnt_for_multi_channel > 0) {
-					loop = state->multi_channels_adjust_count - (state->chans_num - other_dma_nums);
+					int diff = state->chans_num - other_dma_nums;
+					loop = state->multi_channels_adjust_count - diff;
 					for (i = 0; i < loop; i++) {
 						dmabuf_temp = &state->other_states[i]->dmabuf;
-						if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, buffer, sample_s))
+						if (copy_from_user(dmabuf_temp->rawbuf + 
+								   dmabuf_temp->swptr, 
+								   buffer, sample_s))
 							return -EFAULT;
-						seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, sample_s, *copy_count);
+						seek_offset(dmabuf_temp->swptr, buffer, 
+							    cnt_for_multi_channel, 
+							    sample_s, *copy_count);
 					}
 				}
 			}
-		}
-		else
+		} else
 			state->multi_channels_adjust_count = 0;
 	}
 	for (i = 0; i < other_dma_nums; i++) {
@@ -3823,15 +3997,16 @@ static int ali_write_5_1(struct trident_
 	return *state_cnt;
 }
 
-static void ali_free_other_states_resources(struct trident_state *state)
+static void
+ali_free_other_states_resources(struct trident_state *state)
 {
 	int i;
 	struct trident_card *card = state->card;
 	struct trident_state *s;
 	unsigned other_states_count;
-	
-	other_states_count = state->chans_num - 2;	/* except PCM L/R channels*/
-	for ( i = 0; i < other_states_count; i++) {
+
+	other_states_count = state->chans_num - 2; /* except PCM L/R channels */
+	for (i = 0; i < other_states_count; i++) {
 		s = state->other_states[i];
 		dealloc_dmabuf(&s->dmabuf, card->pci_dev);
 		ali_disable_special_channel(s->card, s->dmabuf.channel->num);
@@ -3842,35 +4017,38 @@ static void ali_free_other_states_resour
 }
 
 struct proc_dir_entry *res;
-static int ali_write_proc(struct file *file, const char *buffer, unsigned long count, void *data)
+static int
+ali_write_proc(struct file *file, const char *buffer, unsigned long count, void *data)
 {
-	struct trident_card *card = (struct trident_card *)data;
+	struct trident_card *card = (struct trident_card *) data;
 	unsigned long flags;
 	char c;
 
-	if (count<0)
+	if (count < 0)
 		return -EINVAL;
 	if (count == 0)
 		return 0;
 	if (get_user(c, buffer))
 		return -EFAULT;
-	
+
 	spin_lock_irqsave(&card->lock, flags);
 	switch (c) {
-	    case '0':
+	case '0':
 		ali_setup_spdif_out(card, ALI_PCM_TO_SPDIF_OUT);
 		ali_disable_special_channel(card, ALI_SPDIF_OUT_CHANNEL);
 		break;
-	    case '1':
-		ali_setup_spdif_out(card, ALI_SPDIF_OUT_TO_SPDIF_OUT|ALI_SPDIF_OUT_PCM);
+	case '1':
+		ali_setup_spdif_out(card, ALI_SPDIF_OUT_TO_SPDIF_OUT | 
+				    ALI_SPDIF_OUT_PCM);
+		break;
+	case '2':
+		ali_setup_spdif_out(card, ALI_SPDIF_OUT_TO_SPDIF_OUT | 
+				    ALI_SPDIF_OUT_NON_PCM);
 		break;
-	    case '2':
-		ali_setup_spdif_out(card, ALI_SPDIF_OUT_TO_SPDIF_OUT|ALI_SPDIF_OUT_NON_PCM);
-		break;
-	    case '3':
+	case '3':
 		ali_disable_spdif_in(card);	//default
 		break;
-	    case '4':
+	case '4':
 		ali_setup_spdif_in(card);
 		break;
 	}
@@ -3880,7 +4058,8 @@ static int ali_write_proc(struct file *f
 }
 
 /* OSS /dev/mixer file operation methods */
-static int trident_open_mixdev(struct inode *inode, struct file *file)
+static int
+trident_open_mixdev(struct inode *inode, struct file *file)
 {
 	int i = 0;
 	int minor = iminor(inode);
@@ -3888,45 +4067,47 @@ static int trident_open_mixdev(struct in
 
 	for (card = devs; card != NULL; card = card->next)
 		for (i = 0; i < NR_AC97; i++)
-			if (card->ac97_codec[i] != NULL &&
+			if (card->ac97_codec[i] != NULL && 
 			    card->ac97_codec[i]->dev_mixer == minor)
 				goto match;
 
 	if (!card) {
 		return -ENODEV;
 	}
- match:
+      match:
 	file->private_data = card->ac97_codec[i];
 
-
 	return 0;
 }
 
-static int trident_ioctl_mixdev(struct inode *inode, struct file *file, unsigned int cmd,
-				unsigned long arg)
+static int
+trident_ioctl_mixdev(struct inode *inode, struct file *file, unsigned int cmd, 
+		     unsigned long arg)
 {
-	struct ac97_codec *codec = (struct ac97_codec *)file->private_data;
+	struct ac97_codec *codec = (struct ac97_codec *) file->private_data;
 
 	return codec->mixer_ioctl(codec, cmd, arg);
 }
 
-static /*const*/ struct file_operations trident_mixer_fops = {
-	.owner		= THIS_MODULE,
-	.llseek		= no_llseek,
-	.ioctl		= trident_ioctl_mixdev,
-	.open		= trident_open_mixdev,
+static /*const */ struct file_operations trident_mixer_fops = {
+	.owner = THIS_MODULE,
+	.llseek = no_llseek,
+	.ioctl = trident_ioctl_mixdev,
+	.open = trident_open_mixdev,
 };
 
-static int ali_reset_5451(struct trident_card *card)
+static int
+ali_reset_5451(struct trident_card *card)
 {
 	struct pci_dev *pci_dev = NULL;
-	unsigned int   dwVal;
+	unsigned int dwVal;
 	unsigned short wCount, wReg;
 
-	pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, pci_dev);
+	pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, 
+				  pci_dev);
 	if (pci_dev == NULL)
 		return -1;
-	
+
 	pci_read_config_dword(pci_dev, 0x7c, &dwVal);
 	pci_write_config_dword(pci_dev, 0x7c, dwVal | 0x08000000);
 	udelay(5000);
@@ -3945,10 +4126,12 @@ static int ali_reset_5451(struct trident
 	pci_write_config_dword(pci_dev, 0x44, dwVal & 0xfffbffff);
 	udelay(5000);
 
+	/* TODO: recognize if we have a PM capable codec and only do this */
+	/* if the codec is PM capable */
 	wCount = 2000;
-	while(wCount--) {
+	while (wCount--) {
 		wReg = ali_ac97_get(card, 0, AC97_POWER_CONTROL);
-		if((wReg & 0x000f) == 0x000f)
+		if ((wReg & 0x000f) == 0x000f)
 			return 0;
 		udelay(5000);
 	}
@@ -3957,33 +4140,32 @@ static int ali_reset_5451(struct trident
 }
 
 /* AC97 codec initialisation. */
-static int __devinit trident_ac97_init(struct trident_card *card)
+static int __devinit
+trident_ac97_init(struct trident_card *card)
 {
 	int num_ac97 = 0;
 	unsigned long ready_2nd = 0;
 	struct ac97_codec *codec;
 	int i = 0;
-	
 
 	/* initialize controller side of AC link, and find out if secondary codes
 	   really exist */
-	switch (card->pci_id)
-	{
+	switch (card->pci_id) {
 	case PCI_DEVICE_ID_ALI_5451:
-		if (ali_reset_5451(card)) 
-		{
-			printk(KERN_ERR "trident_ac97_init: error resetting 5451.\n");
+		if (ali_reset_5451(card)) {
+			printk(KERN_ERR "trident_ac97_init: error "
+			       "resetting 5451.\n");
 			return -1;
 		}
-		outl(0x80000001,TRID_REG(card, ALI_GLOBAL_CONTROL));
-		outl(0x00000000,TRID_REG(card, T4D_AINTEN_A));
-		outl(0xffffffff,TRID_REG(card, T4D_AINT_A));
-		outl(0x00000000,TRID_REG(card, T4D_MUSICVOL_WAVEVOL));
-		outb(0x10,	TRID_REG(card, ALI_MPUR2));
+		outl(0x80000001, TRID_REG(card, ALI_GLOBAL_CONTROL));
+		outl(0x00000000, TRID_REG(card, T4D_AINTEN_A));
+		outl(0xffffffff, TRID_REG(card, T4D_AINT_A));
+		outl(0x00000000, TRID_REG(card, T4D_MUSICVOL_WAVEVOL));
+		outb(0x10, TRID_REG(card, ALI_MPUR2));
 		ready_2nd = inl(TRID_REG(card, ALI_SCTRL));
 		ready_2nd &= 0x3fff;
 		outl(ready_2nd | PCMOUT | 0x8000, TRID_REG(card, ALI_SCTRL));
-		ready_2nd = inl(TRID_REG(card, ALI_SCTRL)); 
+		ready_2nd = inl(TRID_REG(card, ALI_SCTRL));
 		ready_2nd &= SI_AC97_SECONDARY_READY;
 		if (card->revision < ALI_5451_V02)
 			ready_2nd = 0;
@@ -3992,10 +4174,10 @@ static int __devinit trident_ac97_init(s
 		/* disable AC97 GPIO interrupt */
 		outl(0x00, TRID_REG(card, SI_AC97_GPIO));
 		/* when power up the AC link is in cold reset mode so stop it */
-		outl(PCMOUT|SURROUT|CENTEROUT|LFEOUT|SECONDARY_ID,
+		outl(PCMOUT | SURROUT | CENTEROUT | LFEOUT | SECONDARY_ID, 
 		     TRID_REG(card, SI_SERIAL_INTF_CTRL));
-		/* it take a long time to recover from a cold reset (especially when you have
-		   more than one codec) */
+		/* it take a long time to recover from a cold reset */ 
+		/* (especially when you have more than one codec) */
 		udelay(2000);
 		ready_2nd = inl(TRID_REG(card, SI_SERIAL_INTF_CTRL));
 		ready_2nd &= SI_AC97_SECONDARY_READY;
@@ -4014,10 +4196,10 @@ static int __devinit trident_ac97_init(s
 		/* disable AC97 GPIO interrupt */
 		outl(0x00, TRID_REG(card, SI_AC97_GPIO));
 		/* when power up, the AC link is in cold reset mode, so stop it */
-		outl(PCMOUT|SURROUT|CENTEROUT|LFEOUT,
+		outl(PCMOUT | SURROUT | CENTEROUT | LFEOUT, 
 		     TRID_REG(card, SI_SERIAL_INTF_CTRL));
-		/* it take a long time to recover from a cold reset (especially when you have
-		   more than one codec) */
+		/* it take a long time to recover from a cold reset (especially */ 
+		/* when you have more than one codec) */
 		udelay(2000);
 		ready_2nd = inl(TRID_REG(card, SI_SERIAL_INTF_CTRL));
 		ready_2nd &= SI_AC97_SECONDARY_READY;
@@ -4028,24 +4210,24 @@ static int __devinit trident_ac97_init(s
 		if ((codec = ac97_alloc_codec()) == NULL)
 			return -ENOMEM;
 
-		/* initialize some basic codec information, other fields will be filled
-		   in ac97_probe_codec */
+		/* initialize some basic codec information, other fields */ 
+		/* will be filled in ac97_probe_codec */
 		codec->private_data = card;
 		codec->id = num_ac97;
 
 		if (card->pci_id == PCI_DEVICE_ID_ALI_5451) {
 			codec->codec_read = ali_ac97_read;
 			codec->codec_write = ali_ac97_write;
-		}
-		else {
+		} else {
 			codec->codec_read = trident_ac97_get;
 			codec->codec_write = trident_ac97_set;
 		}
-	
+
 		if (ac97_probe_codec(codec) == 0)
 			break;
 
-		if ((codec->dev_mixer = register_sound_mixer(&trident_mixer_fops, -1)) < 0) {
+		codec->dev_mixer = register_sound_mixer(&trident_mixer_fops, -1);
+		if (codec->dev_mixer < 0) {
 			printk(KERN_ERR "trident: couldn't register mixer!\n");
 			ac97_release_codec(codec);
 			break;
@@ -4062,65 +4244,73 @@ static int __devinit trident_ac97_init(s
 		for (num_ac97 = 0; num_ac97 < NR_AC97; num_ac97++) {
 			if (card->ac97_codec[num_ac97] == NULL)
 				break;
-			for (i=0; i<64;i++)
-				card->mixer_regs[i][num_ac97] = ali_ac97_get(card, num_ac97,i*2);
+			for (i = 0; i < 64; i++) {
+				u16 reg = ali_ac97_get(card, num_ac97, i * 2);
+				card->mixer_regs[i][num_ac97] = reg;
+			}
 		}
 	}
-	return num_ac97+1;
+	return num_ac97 + 1;
 }
 
 /* Gameport functions for the cards ADC gameport */
 
-static unsigned char trident_game_read(struct gameport *gameport)
+static unsigned char
+trident_game_read(struct gameport *gameport)
 {
 	struct trident_card *card = gameport->driver;
 	return inb(TRID_REG(card, T4D_GAME_LEG));
 }
 
-static void trident_game_trigger(struct gameport *gameport)
+static void
+trident_game_trigger(struct gameport *gameport)
 {
 	struct trident_card *card = gameport->driver;
 	outb(0xff, TRID_REG(card, T4D_GAME_LEG));
 }
 
-static int trident_game_cooked_read(struct gameport *gameport, int *axes, int *buttons)
+static int
+trident_game_cooked_read(struct gameport *gameport, int *axes, int *buttons)
 {
-        struct trident_card *card = gameport->driver;
+	struct trident_card *card = gameport->driver;
 	int i;
 
 	*buttons = (~inb(TRID_REG(card, T4D_GAME_LEG)) >> 4) & 0xf;
 
 	for (i = 0; i < 4; i++) {
-		axes[i] = inw(TRID_REG(card, T4D_GAME_AXD) + i * sizeof(u16));
-		if (axes[i] == 0xffff) axes[i] = -1;
+		axes[i] = inw(TRID_REG(card, T4D_GAME_AXD) + i * sizeof (u16));
+		if (axes[i] == 0xffff)
+			axes[i] = -1;
 	}
-        
-        return 0;
+
+	return 0;
 }
 
-static int trident_game_open(struct gameport *gameport, int mode)
+static int
+trident_game_open(struct gameport *gameport, int mode)
 {
 	struct trident_card *card = gameport->driver;
 
 	switch (mode) {
-		case GAMEPORT_MODE_COOKED:
-			outb(0x80, TRID_REG(card, T4D_GAME_CR));
-			wait_ms(20);
-			return 0;
-		case GAMEPORT_MODE_RAW:
-			outb(0x00, TRID_REG(card, T4D_GAME_CR));
-			return 0;
-		default:
-			return -1;
+	case GAMEPORT_MODE_COOKED:
+		outb(0x80, TRID_REG(card, T4D_GAME_CR));
+		wait_ms(20);
+		return 0;
+	case GAMEPORT_MODE_RAW:
+		outb(0x00, TRID_REG(card, T4D_GAME_CR));
+		return 0;
+	default:
+		return -1;
 	}
 
 	return 0;
 }
 
-
-/* install the driver, we do not allocate hardware channel nor DMA buffer now, they are defered 
-   until "ACCESS" time (in prog_dmabuf called by open/read/write/ioctl/mmap) */
-static int __devinit trident_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
+/* install the driver, we do not allocate hardware channel nor DMA buffer */ 
+/* now, they are defered until "ACCESS" time (in prog_dmabuf called by */ 
+/* open/read/write/ioctl/mmap) */
+static int __devinit
+trident_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
 {
 	unsigned long iobase;
 	struct trident_card *card;
@@ -4140,9 +4330,9 @@ static int __devinit trident_probe(struc
 	else
 		dma_mask = TRIDENT_DMA_MASK;
 	if (pci_set_dma_mask(pci_dev, dma_mask)) {
-		printk(KERN_ERR "trident: architecture does not support"
-		       " %s PCI busmaster DMA\n",
-		       pci_dev->device == PCI_DEVICE_ID_ALI_5451 ?
+		printk(KERN_ERR "trident: architecture does not support" 
+		       " %s PCI busmaster DMA\n", 
+		       pci_dev->device == PCI_DEVICE_ID_ALI_5451 ? 
 		       "32-bit" : "30-bit");
 		goto out;
 	}
@@ -4154,17 +4344,17 @@ static int __devinit trident_probe(struc
 		iobase = pci_resource_start(pci_dev, 0);
 
 	if (!request_region(iobase, 256, card_names[pci_id->driver_data])) {
-		printk(KERN_ERR "trident: can't allocate I/O space at 0x%4.4lx\n",
-		       iobase);
+		printk(KERN_ERR "trident: can't allocate I/O space at "
+		       "0x%4.4lx\n", iobase);
 		goto out;
 	}
 
 	rc = -ENOMEM;
-	if ((card = kmalloc(sizeof(struct trident_card), GFP_KERNEL)) == NULL) {
+	if ((card = kmalloc(sizeof(*card), GFP_KERNEL)) == NULL) {
 		printk(KERN_ERR "trident: out of memory\n");
 		goto out_release_region;
 	}
-	memset(card, 0, sizeof(*card));
+	memset(card, 0, sizeof (*card));
 
 	init_timer(&card->timer);
 	card->iobase = iobase;
@@ -4194,15 +4384,15 @@ static int __devinit trident_probe(struc
 
 	pci_set_master(pci_dev);
 
-	printk(KERN_INFO "trident: %s found at IO 0x%04lx, IRQ %d\n",
+	printk(KERN_INFO "trident: %s found at IO 0x%04lx, IRQ %d\n", 
 	       card_names[pci_id->driver_data], card->iobase, card->irq);
 
-	if(card->pci_id == PCI_DEVICE_ID_ALI_5451) {
-		/* ALi channel Management */	
+	if (card->pci_id == PCI_DEVICE_ID_ALI_5451) {
+		/* ALi channel Management */
 		card->alloc_pcm_channel = ali_alloc_pcm_channel;
 		card->alloc_rec_pcm_channel = ali_alloc_rec_pcm_channel;
 		card->free_pcm_channel = ali_free_pcm_channel;
-		
+
 		card->address_interrupt = ali_address_interrupt;
 
 		/* Added by Matt Wu 01-05-2001 for spdif in */
@@ -4210,8 +4400,8 @@ static int __devinit trident_probe(struc
 		card->rec_channel_use_count = 0;
 
 		/* ALi SPDIF OUT function */
-		if(card->revision == ALI_5451_V02) {
-			ali_setup_spdif_out(card, ALI_PCM_TO_SPDIF_OUT);		
+		if (card->revision == ALI_5451_V02) {
+			ali_setup_spdif_out(card, ALI_PCM_TO_SPDIF_OUT);
 			res = create_proc_entry("ALi5451", 0, NULL);
 			if (res) {
 				res->write_proc = ali_write_proc;
@@ -4221,32 +4411,29 @@ static int __devinit trident_probe(struc
 
 		/* Add H/W Volume Control By Matt Wu Jul. 06, 2001 */
 		card->hwvolctl = 0;
-		pci_dev_m1533 = pci_find_device(PCI_VENDOR_ID_AL,PCI_DEVICE_ID_AL_M1533, pci_dev_m1533);
+		pci_dev_m1533 = pci_find_device(PCI_VENDOR_ID_AL, 
+						PCI_DEVICE_ID_AL_M1533, 
+						pci_dev_m1533);
 		rc = -ENODEV;
 		if (pci_dev_m1533 == NULL)
 			goto out_proc_fs;
 		pci_read_config_byte(pci_dev_m1533, 0x63, &bits);
-		if (bits & (1<<5))
+		if (bits & (1 << 5))
 			card->hwvolctl = 1;
-		if (card->hwvolctl) 
-		{
+		if (card->hwvolctl) {
 			/* Clear m1533 pci cfg 78h bit 30 to zero, which makes
 			   GPIO11/12/13 work as ACGP_UP/DOWN/MUTE. */
 			pci_read_config_byte(pci_dev_m1533, 0x7b, &bits);
-			bits &= 0xbf; /*clear bit 6 */
+			bits &= 0xbf;	/*clear bit 6 */
 			pci_write_config_byte(pci_dev_m1533, 0x7b, bits);
 		}
-	}
-	else if(card->pci_id == PCI_DEVICE_ID_INTERG_5050)
-	{
+	} else if (card->pci_id == PCI_DEVICE_ID_INTERG_5050) {
 		card->alloc_pcm_channel = cyber_alloc_pcm_channel;
 		card->alloc_rec_pcm_channel = cyber_alloc_pcm_channel;
 		card->free_pcm_channel = cyber_free_pcm_channel;
 		card->address_interrupt = cyber_address_interrupt;
 		cyber_init_ritual(card);
-	}
-	else
-	{
+	} else {
 		card->alloc_pcm_channel = trident_alloc_pcm_channel;
 		card->alloc_rec_pcm_channel = trident_alloc_pcm_channel;
 		card->free_pcm_channel = trident_free_pcm_channel;
@@ -4255,9 +4442,10 @@ static int __devinit trident_probe(struc
 
 	/* claim our irq */
 	rc = -ENODEV;
-	if (request_irq(card->irq, &trident_interrupt, SA_SHIRQ,
+	if (request_irq(card->irq, &trident_interrupt, SA_SHIRQ, 
 			card_names[pci_id->driver_data], card)) {
-		printk(KERN_ERR "trident: unable to allocate irq %d\n", card->irq);
+		printk(KERN_ERR "trident: unable to allocate irq %d\n", 
+		       card->irq);
 		goto out_proc_fs;
 	}
 	/* register /dev/dsp */
@@ -4271,8 +4459,9 @@ static int __devinit trident_probe(struc
 		/* unregister audio devices */
 		for (i = 0; i < NR_AC97; i++) {
 			if (card->ac97_codec[i] != NULL) {
-				unregister_sound_mixer(card->ac97_codec[i]->dev_mixer);
-				ac97_release_codec(card->ac97_codec[i]);
+				struct ac97_codec* codec = card->ac97_codec[i];
+				unregister_sound_mixer(codec->dev_mixer);
+				ac97_release_codec(codec);
 			}
 		}
 		goto out_unregister_sound_dsp;
@@ -4282,35 +4471,36 @@ static int __devinit trident_probe(struc
 
 	if (card->pci_id == PCI_DEVICE_ID_ALI_5451) {
 		/* Add H/W Volume Control By Matt Wu Jul. 06, 2001 */
-		if(card->hwvolctl) 
-		{
-			/* Enable GPIO IRQ (MISCINT bit 18h)*/
+		if (card->hwvolctl) {
+			/* Enable GPIO IRQ (MISCINT bit 18h) */
 			temp = inw(TRID_REG(card, T4D_MISCINT + 2));
 			temp |= 0x0004;
 			outw(temp, TRID_REG(card, T4D_MISCINT + 2));
 
-			/* Enable H/W Volume Control GLOVAL CONTROL bit 0*/
+			/* Enable H/W Volume Control GLOVAL CONTROL bit 0 */
 			temp = inw(TRID_REG(card, ALI_GLOBAL_CONTROL));
 			temp |= 0x0001;
 			outw(temp, TRID_REG(card, ALI_GLOBAL_CONTROL));
 
 		}
-		if(card->revision == ALI_5451_V02)
+		if (card->revision == ALI_5451_V02)
 			ali_close_multi_channels();
 		/* edited by HMSEO for GT sound */
 #if defined(CONFIG_ALPHA_NAUTILUS) || defined(CONFIG_ALPHA_GENERIC)
 		{
 			u16 ac97_data;
 			extern struct hwrpb_struct *hwrpb;
-		
+
 			if ((hwrpb->sys_type) == 201) {
-				printk(KERN_INFO "trident: Running on Alpha system type Nautilus\n");
+				printk(KERN_INFO "trident: Running on Alpha system "
+				       "type Nautilus\n");
 				ac97_data = ali_ac97_get(card, 0, AC97_POWER_CONTROL);
-				ali_ac97_set(card, 0, AC97_POWER_CONTROL, ac97_data | ALI_EAPD_POWER_DOWN);
+				ali_ac97_set(card, 0, AC97_POWER_CONTROL, 
+					     ac97_data | ALI_EAPD_POWER_DOWN);
 			}
 		}
-#endif /* CONFIG_ALPHA_NAUTILUS || CONFIG_ALPHA_GENERIC */ 
-		/* edited by HMSEO for GT sound*/
+#endif				/* CONFIG_ALPHA_NAUTILUS || CONFIG_ALPHA_GENERIC */
+		/* edited by HMSEO for GT sound */
 	}
 	rc = 0;
 	pci_set_drvdata(pci_dev, card);
@@ -4321,7 +4511,9 @@ static int __devinit trident_probe(struc
 	/* Register gameport */
 	gameport_register_port(&card->gameport);
 
-out:	return rc;
+out:
+	return rc;
+
 out_unregister_sound_dsp:
 	unregister_sound_dsp(card->dev_audio);
 out_free_irq:
@@ -4335,26 +4527,27 @@ out_proc_fs:
 	devs = NULL;
 out_release_region:
 	release_region(iobase, 256);
-	goto out;
+	return rc; 
 }
 
-static void __devexit trident_remove(struct pci_dev *pci_dev)
+static void __devexit
+trident_remove(struct pci_dev *pci_dev)
 {
 	int i;
 	struct trident_card *card = pci_get_drvdata(pci_dev);
 
 	/*
- 	 *	Kill running timers before unload. We can't have them
- 	 *	going off after rmmod!
- 	 */
-	if(card->hwvolctl)
+	 *      Kill running timers before unload. We can't have them
+	 *      going off after rmmod!
+	 */
+	if (card->hwvolctl)
 		del_timer_sync(&card->timer);
-		
+
 	/* ALi S/PDIF and Power Management */
-	if(card->pci_id == PCI_DEVICE_ID_ALI_5451) {
+	if (card->pci_id == PCI_DEVICE_ID_ALI_5451) {
 		ali_setup_spdif_out(card, ALI_PCM_TO_SPDIF_OUT);
-                ali_disable_special_channel(card, ALI_SPDIF_OUT_CHANNEL);
-                ali_disable_spdif_in(card);
+		ali_disable_special_channel(card, ALI_SPDIF_OUT_CHANNEL);
+		ali_disable_spdif_in(card);
 		remove_proc_entry("ALi5451", NULL);
 	}
 
@@ -4381,36 +4574,38 @@ static void __devexit trident_remove(str
 	pci_set_drvdata(pci_dev, NULL);
 }
 
-MODULE_AUTHOR("Alan Cox, Aaron Holtzman, Ollie Lho, Ching Ling Lee");
-MODULE_DESCRIPTION("Trident 4DWave/SiS 7018/ALi 5451 and Tvia/IGST CyberPro5050 PCI Audio Driver");
+MODULE_AUTHOR("Alan Cox, Aaron Holtzman, Ollie Lho, Ching Ling Lee, Muli Ben-Yehuda");
+MODULE_DESCRIPTION("Trident 4DWave/SiS 7018/ALi 5451 and Tvia/IGST CyberPro5050 PCI "
+		   "Audio Driver");
 MODULE_LICENSE("GPL");
 
-
 #define TRIDENT_MODULE_NAME "trident"
 
 static struct pci_driver trident_pci_driver = {
-	.name		= TRIDENT_MODULE_NAME,
-	.id_table	= trident_pci_tbl,
-	.probe		= trident_probe,
-	.remove		= __devexit_p(trident_remove),
-	.suspend	= trident_suspend,
-	.resume		= trident_resume
+	.name = TRIDENT_MODULE_NAME,
+	.id_table = trident_pci_tbl,
+	.probe = trident_probe,
+	.remove = __devexit_p(trident_remove),
+	.suspend = trident_suspend,
+	.resume = trident_resume
 };
 
-static int __init trident_init_module (void)
+static int __init
+trident_init_module(void)
 {
-	printk(KERN_INFO "Trident 4DWave/SiS 7018/ALi 5451,Tvia CyberPro "
-	       "5050 PCI Audio, version " DRIVER_VERSION ", " 
-	       __TIME__ " " __DATE__ "\n");
+	printk(KERN_INFO "Trident 4DWave/SiS 7018/ALi 5451,Tvia CyberPro " 
+	       "5050 PCI Audio, version " DRIVER_VERSION ", " __TIME__ " " 
+	       __DATE__ "\n");
 
 	if (!pci_register_driver(&trident_pci_driver)) {
 		pci_unregister_driver(&trident_pci_driver);
-                return -ENODEV;
+		return -ENODEV;
 	}
 	return 0;
 }
 
-static void __exit trident_cleanup_module (void)
+static void __exit
+trident_cleanup_module(void)
 {
 	pci_unregister_driver(&trident_pci_driver);
 }
diff -puN sound/oss/trident.h~linus sound/oss/trident.h
--- 25/sound/oss/trident.h~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/sound/oss/trident.h	2004-01-19 22:17:25.000000000 -0800
@@ -56,11 +56,6 @@
 #define PCI_DEVICE_ID_ALI_1533		0x1533
 #endif
 
-#ifndef FALSE
-#define FALSE 		0
-#define TRUE  		1
-#endif
-
 #define CHANNEL_REGS	5
 #define CHANNEL_START	0xe0   // The first bytes of the contiguous register space.
 
@@ -360,16 +355,4 @@ static inline unsigned ld2(unsigned int 
 	return r;
 }
 
-#ifdef DEBUG
-
-#define TRDBG(msg, args...) do {          \
-        printk(KERN_DEBUG msg , ##args ); \
-} while (0)
-
-#else /* !defined(DEBUG) */ 
-
-#define TRDBG(msg, args...) do { } while (0)
-
-#endif /* DEBUG */ 
-
 #endif /* __TRID4DWAVE_H */
diff -puN sound/pci/intel8x0.c~linus sound/pci/intel8x0.c
--- 25/sound/pci/intel8x0.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/sound/pci/intel8x0.c	2004-01-19 22:17:25.000000000 -0800
@@ -2591,6 +2591,7 @@ static int __devinit snd_intel8x0_probe(
 			break;
 		}
 	}
+	card->dev = &pci->dev;
 
 	if ((err = snd_intel8x0_create(card, pci, pci_id->driver_data, &chip)) < 0) {
 		snd_card_free(card);
diff -puN sound/pcmcia/vx/vx_entry.c~linus sound/pcmcia/vx/vx_entry.c
--- 25/sound/pcmcia/vx/vx_entry.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/sound/pcmcia/vx/vx_entry.c	2004-01-19 22:17:25.000000000 -0800
@@ -38,9 +38,9 @@ static void vxpocket_release(dev_link_t 
 {
 	if (link->state & DEV_CONFIG) {
 		/* release cs resources */
-		CardServices(ReleaseConfiguration, link->handle);
-		CardServices(ReleaseIO, link->handle, &link->io);
-		CardServices(ReleaseIRQ, link->handle, &link->irq);
+		pcmcia_release_configuration(link->handle);
+		pcmcia_release_io(link->handle, &link->io);
+		pcmcia_release_irq(link->handle, &link->irq);
 		link->state &= ~DEV_CONFIG;
 	}
 }
@@ -58,7 +58,7 @@ static int snd_vxpocket_free(vx_core_t *
 
 	/* Break the link with Card Services */
 	if (link->handle)
-		CardServices(DeregisterClient, link->handle);
+		pcmcia_deregister_client(link->handle);
 
 	hw = vxp->hw_entry;
 	if (hw)
@@ -170,7 +170,7 @@ dev_link_t *snd_vxpocket_attach(struct s
 	client_reg.Version = 0x0210;
 	client_reg.event_callback_args.client_data = link;
 
-	ret = CardServices(RegisterClient, &link->handle, &client_reg);
+	ret = pcmcia_register_client(&link->handle, &client_reg);
 	if (ret != CS_SUCCESS) {
 		cs_error(link->handle, RegisterClient, ret);
 		snd_vxpocket_detach(hw, link);
@@ -253,8 +253,8 @@ void snd_vxpocket_detach_all(struct snd_
  * configuration callback
  */
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static void vxpocket_config(dev_link_t *link)
 {
@@ -274,21 +274,21 @@ static void vxpocket_config(dev_link_t *
 	tuple.TupleDataMax = sizeof(buf);
 	tuple.TupleOffset = 0;
 	tuple.DesiredTuple = CISTPL_CONFIG;
-	CS_CHECK(GetFirstTuple, handle, &tuple);
-	CS_CHECK(GetTupleData, handle, &tuple);
-	CS_CHECK(ParseTuple, handle, &tuple, &parse);
+	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+	CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+	CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
 	link->conf.ConfigBase = parse.config.base;
 	link->conf.ConfigIndex = 1;
 
-	CS_CHECK(GetConfigurationInfo, handle, &conf);
+	CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf));
 	link->conf.Vcc = conf.Vcc;
 
 	/* Configure card */
 	link->state |= DEV_CONFIG;
 
-	CS_CHECK(RequestIO, handle, &link->io);
-	CS_CHECK(RequestIRQ, link->handle, &link->irq);
-	CS_CHECK(RequestConfiguration, link->handle, &link->conf);
+	CS_CHECK(RequestIO, pcmcia_request_io(handle, &link->io));
+	CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
+	CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
 
 	if (snd_vxpocket_assign_resources(chip, link->io.BasePort1, link->irq.AssignedIRQ) < 0)
 		goto failed;
@@ -300,9 +300,9 @@ static void vxpocket_config(dev_link_t *
 cs_failed:
 	cs_error(link->handle, last_fn, last_ret);
 failed:
-	CardServices(ReleaseConfiguration, link->handle);
-	CardServices(ReleaseIO, link->handle, &link->io);
-	CardServices(ReleaseIRQ, link->handle, &link->irq);
+	pcmcia_release_configuration(link->handle);
+	pcmcia_release_io(link->handle, &link->io);
+	pcmcia_release_irq(link->handle, &link->irq);
 }
 
 
@@ -339,7 +339,7 @@ static int vxpocket_event(event_t event,
 	case CS_EVENT_RESET_PHYSICAL:
 		snd_printdd(KERN_DEBUG "RESET_PHYSICAL\n");
 		if (link->state & DEV_CONFIG)
-			CardServices(ReleaseConfiguration, link->handle);
+			pcmcia_release_configuration(link->handle);
 		break;
 	case CS_EVENT_PM_RESUME:
 		snd_printdd(KERN_DEBUG "RESUME\n");
@@ -350,7 +350,7 @@ static int vxpocket_event(event_t event,
 		if (DEV_OK(link)) {
 			//struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip;
 			snd_printdd(KERN_DEBUG "requestconfig...\n");
-			CardServices(RequestConfiguration, link->handle, &link->conf);
+			pcmcia_request_configuration(link->handle, &link->conf);
 			if (chip) {
 				snd_printdd(KERN_DEBUG "calling snd_vx_resume\n");
 				snd_vx_resume(chip);
diff -puN sound/sound_core.c~linus sound/sound_core.c
--- 25/sound/sound_core.c~linus	2004-01-19 22:17:09.000000000 -0800
+++ 25-akpm/sound/sound_core.c	2004-01-19 22:17:25.000000000 -0800
@@ -65,6 +65,9 @@ extern int msnd_classic_init(void);
 extern int msnd_pinnacle_init(void);
 #endif
 
+struct class_simple *sound_class;
+EXPORT_SYMBOL(sound_class);
+
 /*
  *	Low level list operator. Scan the ordered list, find a hole and
  *	join into it. Called with the lock asserted
@@ -171,6 +174,8 @@ static int sound_insert_unit(struct soun
 
 	devfs_mk_cdev(MKDEV(SOUND_MAJOR, s->unit_minor),
 			S_IFCHR | mode, s->name);
+	class_simple_device_add(sound_class, MKDEV(SOUND_MAJOR, s->unit_minor),
+				NULL, s->name+6);
 	return r;
 
  fail:
@@ -193,6 +198,7 @@ static void sound_remove_unit(struct sou
 	spin_unlock(&sound_loader_lock);
 	if (p) {
 		devfs_remove(p->name);
+		class_simple_device_remove(MKDEV(SOUND_MAJOR, p->unit_minor));
 		kfree(p);
 	}
 }
@@ -556,6 +562,7 @@ static void __exit cleanup_soundcore(voi
 	   empty */
 	unregister_chrdev(SOUND_MAJOR, "sound");
 	devfs_remove("sound");
+	class_simple_destroy(sound_class);
 }
 
 static int __init init_soundcore(void)
@@ -565,6 +572,9 @@ static int __init init_soundcore(void)
 		return -EBUSY;
 	}
 	devfs_mk_dir ("sound");
+	sound_class = class_simple_create(THIS_MODULE, "sound");
+	if (IS_ERR(sound_class))
+		return PTR_ERR(sound_class);
 
 	return 0;
 }

_
